diff --git a/.github/scripts/gen-build-failure-report.sh b/.github/scripts/gen-build-failure-report.sh index fd3215fc7fe..c8336a5f7a1 100644 --- a/.github/scripts/gen-build-failure-report.sh +++ b/.github/scripts/gen-build-failure-report.sh @@ -24,12 +24,19 @@ # questions. # +# Import common utils +. report-utils.sh + GITHUB_STEP_SUMMARY="$1" BUILD_DIR="$(ls -d build/*)" # Send signal to the do-build action that we failed touch "$BUILD_DIR/build-failure" +# Collect hs_errs for build-time crashes, e.g. javac, jmod, jlink, CDS. +# These usually land in make/ +hs_err_files=$(ls make/hs_err*.log 2> /dev/null || true) + ( echo '### :boom: Build failure summary' echo '' @@ -46,6 +53,20 @@ touch "$BUILD_DIR/build-failure" echo '' echo '' + for hs_err in $hs_err_files; do + echo "
View HotSpot error log: "$hs_err"" + echo '' + echo '```' + echo "$hs_err:" + echo '' + cat "$hs_err" + echo '```' + echo '
' + echo '' + done + echo '' echo ':arrow_right: To see the entire test log, click the job in the list to the left. To download logs, see the `failure-logs` [artifact above](#artifacts).' ) >> $GITHUB_STEP_SUMMARY + +truncate_summary diff --git a/.github/scripts/gen-test-results.sh b/.github/scripts/gen-test-results.sh index 9e85eef4dc0..6c6cbaa3740 100644 --- a/.github/scripts/gen-test-results.sh +++ b/.github/scripts/gen-test-results.sh @@ -24,6 +24,9 @@ # questions. # +# Import common utils +. report-utils.sh + GITHUB_STEP_SUMMARY="$1" test_suite_name=$(cat build/run-test-prebuilt/test-support/test-last-ids.txt) @@ -89,18 +92,6 @@ for test in $failures $errors; do fi done >> $GITHUB_STEP_SUMMARY -# With many failures, the summary can easily exceed 1024 kB, the limit set by Github -# Trim it down if so. -summary_size=$(wc -c < $GITHUB_STEP_SUMMARY) -if [[ $summary_size -gt 1000000 ]]; then - # Trim to below 1024 kB, and cut off after the last detail group - head -c 1000000 $GITHUB_STEP_SUMMARY | tac | sed -n -e '/<\/details>/,$ p' | tac > $GITHUB_STEP_SUMMARY.tmp - mv $GITHUB_STEP_SUMMARY.tmp $GITHUB_STEP_SUMMARY - ( - echo '' - echo ':x: **WARNING: Summary is too large and has been truncated.**' - echo '' - ) >> $GITHUB_STEP_SUMMARY -fi - echo ':arrow_right: To see the entire test log, click the job in the list to the left.' >> $GITHUB_STEP_SUMMARY + +truncate_summary diff --git a/.github/scripts/report-utils.sh b/.github/scripts/report-utils.sh new file mode 100644 index 00000000000..da5b6c04b3c --- /dev/null +++ b/.github/scripts/report-utils.sh @@ -0,0 +1,41 @@ +#!/bin/bash +# +# Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# 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. +# + +function truncate_summary() { + # With large hs_errs, the summary can easily exceed 1024 kB, the limit set by Github + # Trim it down if so. + summary_size=$(wc -c < $GITHUB_STEP_SUMMARY) + if [[ $summary_size -gt 1000000 ]]; then + # Trim to below 1024 kB, and cut off after the last detail group + head -c 1000000 $GITHUB_STEP_SUMMARY | tac | sed -n -e '/<\/details>/,$ p' | tac > $GITHUB_STEP_SUMMARY.tmp + mv $GITHUB_STEP_SUMMARY.tmp $GITHUB_STEP_SUMMARY + ( + echo '' + echo ':x: **WARNING: Summary is too large and has been truncated.**' + echo '' + ) >> $GITHUB_STEP_SUMMARY + fi +} diff --git a/.github/workflows/build-cross-compile.yml b/.github/workflows/build-cross-compile.yml index fa5a8a61a0a..29750b485e4 100644 --- a/.github/workflows/build-cross-compile.yml +++ b/.github/workflows/build-cross-compile.yml @@ -84,7 +84,7 @@ jobs: - target-cpu: riscv64 gnu-arch: riscv64 debian-arch: riscv64 - debian-repository: https://httpredir.debian.org/debian/ + debian-repository: https://snapshot.debian.org/archive/debian/20240228T034848Z/ debian-version: sid tolerate-sysroot-errors: true diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e4c05acb684..d5958853701 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -384,6 +384,7 @@ jobs: - build-windows-aarch64 - test-linux-x64 - test-macos-x64 + - test-macos-aarch64 - test-windows-x64 steps: diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 00000000000..f4c5e7e67cb --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,3 @@ +# JDK Vulnerabilities + +Please follow the process outlined in the [OpenJDK Vulnerability Policy](https://openjdk.org/groups/vulnerability/report) to disclose vulnerabilities in the JDK. diff --git a/doc/building.html b/doc/building.html index 70753155312..c91d876246c 100644 --- a/doc/building.html +++ b/doc/building.html @@ -614,10 +614,9 @@ be accepted by configure.

--with-toolchain-type=clang.

Apple Xcode

The oldest supported version of Xcode is 13.0.

-

You will need the Xcode command line developer tools to be able to -build the JDK. (Actually, only the command line tools are -needed, not the IDE.) The simplest way to install these is to run:

-
xcode-select --install
+

You will need to download Xcode either from the App Store or specific +versions can be easily located via the Xcode Releases website.

When updating Xcode, it is advisable to keep an older version for building the JDK. To use a specific version of Xcode you have multiple options:

diff --git a/doc/building.md b/doc/building.md index 51ac0cad7d9..47ad9e7c72b 100644 --- a/doc/building.md +++ b/doc/building.md @@ -422,13 +422,9 @@ To use clang instead of gcc on Linux, use `--with-toolchain-type=clang`. The oldest supported version of Xcode is 13.0. -You will need the Xcode command line developer tools to be able to build the -JDK. (Actually, *only* the command line tools are needed, not the IDE.) The -simplest way to install these is to run: - -``` -xcode-select --install -``` +You will need to download Xcode either from the App Store or specific versions +can be easily located via the [Xcode Releases](https://xcodereleases.com) +website. When updating Xcode, it is advisable to keep an older version for building the JDK. To use a specific version of Xcode you have multiple options: diff --git a/make/InterimImage.gmk b/make/InterimImage.gmk index 7e381dbe688..e046f060513 100644 --- a/make/InterimImage.gmk +++ b/make/InterimImage.gmk @@ -27,12 +27,13 @@ default: all include $(SPEC) include MakeBase.gmk + +include Execute.gmk include Modules.gmk ################################################################################ -# Use this file inside the image as target for make rule -JIMAGE_TARGET_FILE := bin/java$(EXECUTABLE_SUFFIX) +INTERIM_JLINK_SUPPORT_DIR := $(SUPPORT_OUTPUTDIR)/interim-image-jlink INTERIM_MODULES_LIST := $(call CommaList, $(INTERIM_IMAGE_MODULES)) @@ -42,19 +43,18 @@ JLINK_TOOL := $(JLINK) -J-Djlink.debug=true \ --module-path $(INTERIM_JMODS_DIR) \ --endian $(OPENJDK_BUILD_CPU_ENDIAN) -$(INTERIM_IMAGE_DIR)/$(JIMAGE_TARGET_FILE): $(JMODS) \ - $(call DependOnVariable, INTERIM_MODULES_LIST) - $(call LogWarn, Creating interim jimage) - $(RM) -r $(INTERIM_IMAGE_DIR) - $(call MakeDir, $(INTERIM_IMAGE_DIR)) - $(call ExecuteWithLog, $(INTERIM_IMAGE_DIR)/jlink, \ - $(JLINK_TOOL) \ - --output $(INTERIM_IMAGE_DIR) \ - --disable-plugin generate-jli-classes \ - --add-modules $(INTERIM_MODULES_LIST)) - $(TOUCH) $@ +$(eval $(call SetupExecute, jlink_interim_image, \ + WARN := Creating interim jimage, \ + DEPS := $(JMODS) $(call DependOnVariable, INTERIM_MODULES_LIST), \ + OUTPUT_DIR := $(INTERIM_IMAGE_DIR), \ + SUPPORT_DIR := $(INTERIM_JLINK_SUPPORT_DIR), \ + PRE_COMMAND := $(RM) -r $(INTERIM_IMAGE_DIR), \ + COMMAND := $(JLINK_TOOL) --output $(INTERIM_IMAGE_DIR) \ + --disable-plugin generate-jli-classes \ + --add-modules $(INTERIM_MODULES_LIST), \ +)) -TARGETS += $(INTERIM_IMAGE_DIR)/$(JIMAGE_TARGET_FILE) +TARGETS += $(jlink_interim_image) ################################################################################ diff --git a/make/Main.gmk b/make/Main.gmk index 46150839f80..4b3efaf651e 100644 --- a/make/Main.gmk +++ b/make/Main.gmk @@ -568,6 +568,10 @@ $(eval $(call SetupTarget, update-build-docs, \ MAKEFILE := UpdateBuildDocs, \ )) +$(eval $(call SetupTarget, update-sleef-source, \ + MAKEFILE := UpdateSleefSource, \ +)) + $(eval $(call SetupTarget, update-x11wrappers, \ MAKEFILE := UpdateX11Wrappers, \ DEPS := java.base-copy buildtools-jdk, \ diff --git a/make/UpdateSleefSource.gmk b/make/UpdateSleefSource.gmk new file mode 100644 index 00000000000..37a28abcb85 --- /dev/null +++ b/make/UpdateSleefSource.gmk @@ -0,0 +1,153 @@ +# +# Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# 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. +# + +################################################################################ + +default: all + +include $(SPEC) +include MakeBase.gmk + +include CopyFiles.gmk +include Execute.gmk + +################################################################################ +# This file is responsible for updating the generated sleef source code files +# that are checked in to the JDK repo, and that are actually used when building. +# This target needs to be re-run every time the source code of libsleef is +# updated from upstream. +################################################################################ + +ifneq ($(COMPILE_TYPE), cross) + $(error Only cross-compilation of libsleef is currently supported) +endif + +ifeq ($(CMAKE), ) + $(error CMake not found. Please install cmake and rerun configure) +endif + +ifneq ($(OPENJDK_BUILD_OS), linux) + $(error This target is only supported on linux) +endif + +SLEEF_SUPPORT_DIR := $(MAKESUPPORT_OUTPUTDIR)/sleef +SLEEF_SOURCE_BASE_DIR := $(TOPDIR)/src/jdk.incubator.vector/linux/native/libsleef +SLEEF_SOURCE_DIR := $(SLEEF_SOURCE_BASE_DIR)/upstream +SLEEF_TARGET_DIR := $(SLEEF_SOURCE_BASE_DIR)/generated +SLEEF_NATIVE_BUILD_DIR := $(SLEEF_SUPPORT_DIR)/native +SLEEF_CROSS_BUILD_DIR := $(SLEEF_SUPPORT_DIR)/cross + +ifeq ($(OPENJDK_TARGET_CPU), aarch64) + CROSS_COMPILATION_FILENAMES := sleefinline_advsimd.h sleefinline_sve.h + EXTRA_CROSS_OPTIONS := -DSLEEF_ENFORCE_SVE=TRUE +else ifeq ($(OPENJDK_TARGET_CPU), riscv64) + CROSS_COMPILATION_FILENAMES := sleefinline_rvvm1.h + EXTRA_CROSS_OPTIONS := -DSLEEF_ENFORCE_RVVM1=TRUE +else + $(error Unsupported platform) +endif +CROSS_COMPILATION_SRC_FILES := $(addprefix $(SLEEF_CROSS_BUILD_DIR)/include/, \ + $(CROSS_COMPILATION_FILENAMES)) + +ifeq ($(TOOLCHAIN_TYPE), clang) + SLEEF_TOOLCHAIN_TYPE := llvm +else + SLEEF_TOOLCHAIN_TYPE := $(TOOLCHAIN_TYPE) +endif + +SLEEF_CMAKE_FILE := toolchains/$(OPENJDK_TARGET_CPU)-$(SLEEF_TOOLCHAIN_TYPE).cmake + +# We need to run CMake twice, first using it to configure the build, and then +# to actually build; and we need to do this twice, once for a native build +# and once for the cross-compilation build. + +$(eval $(call SetupExecute, sleef_native_config, \ + INFO := Configuring native sleef build, \ + OUTPUT_DIR := $(SLEEF_NATIVE_BUILD_DIR), \ + COMMAND := cd $(SLEEF_SOURCE_DIR) && $(CMAKE) -S . -B \ + $(SLEEF_NATIVE_BUILD_DIR), \ +)) + +TARGETS := $(sleef_native_config) + +$(eval $(call SetupExecute, sleef_native_build, \ + INFO := Building native sleef, \ + DEPS := $(sleef_native_config), \ + OUTPUT_DIR := $(SLEEF_NATIVE_BUILD_DIR), \ + COMMAND := cd $(SLEEF_SOURCE_DIR) && $(CMAKE) --build \ + $(SLEEF_NATIVE_BUILD_DIR) -j, \ +)) + +TARGETS := $(sleef_native_build) + +$(eval $(call SetupExecute, sleef_cross_config, \ + INFO := Configuring cross-compiling sleef build, \ + DEPS := $(sleef_native_build), \ + OUTPUT_DIR := $(SLEEF_CROSS_BUILD_DIR), \ + COMMAND := cd $(SLEEF_SOURCE_DIR) && $(CMAKE) -S . -B \ + $(SLEEF_CROSS_BUILD_DIR) \ + -DCMAKE_C_COMPILER=$(CC) \ + -DCMAKE_TOOLCHAIN_FILE=$(SLEEF_CMAKE_FILE) \ + -DNATIVE_BUILD_DIR=$(SLEEF_NATIVE_BUILD_DIR) \ + -DSLEEF_BUILD_INLINE_HEADERS=TRUE \ + $(EXTRA_CROSS_OPTIONS), \ +)) + +TARGETS := $(sleef_cross_config) + +$(eval $(call SetupExecute, sleef_cross_build, \ + INFO := Building cross-compiling sleef, \ + DEPS := $(sleef_cross_config), \ + OUTPUT_DIR := $(SLEEF_NATIVE_BUILD_DIR), \ + COMMAND := cd $(SLEEF_SOURCE_DIR) && $(CMAKE) --build \ + $(SLEEF_CROSS_BUILD_DIR) -j, \ +)) + +TARGETS := $(sleef_cross_build) + +$(CROSS_COMPILATION_SRC_FILES): $(sleef_cross_build) + +# Finally, copy the generated files (and one needed static file) into our +# target directory. + +$(eval $(call SetupCopyFiles, copy_static_sleef_source, \ + FILES := $(SLEEF_SOURCE_DIR)/src/common/misc.h, \ + DEST := $(SLEEF_TARGET_DIR), \ +)) + +TARGETS := $(copy_static_sleef_source) + +$(eval $(call SetupCopyFiles, copy_generated_sleef_source, \ + FILES := $(CROSS_COMPILATION_SRC_FILES), \ + DEST := $(SLEEF_TARGET_DIR), \ +)) + +TARGETS := $(copy_generated_sleef_source) + +################################################################################ + +all: $(TARGETS) + +.PHONY: all default diff --git a/make/autoconf/basic_tools.m4 b/make/autoconf/basic_tools.m4 index 6bfaecb2e69..eceb0ae6cc4 100644 --- a/make/autoconf/basic_tools.m4 +++ b/make/autoconf/basic_tools.m4 @@ -99,6 +99,7 @@ AC_DEFUN_ONCE([BASIC_SETUP_TOOLS], UTIL_REQUIRE_SPECIAL(FGREP, [AC_PROG_FGREP]) # Optional tools, we can do without them + UTIL_LOOKUP_PROGS(CMAKE, cmake) UTIL_LOOKUP_PROGS(DF, df) UTIL_LOOKUP_PROGS(GIT, git) UTIL_LOOKUP_PROGS(NICE, nice) diff --git a/make/autoconf/jvm-features.m4 b/make/autoconf/jvm-features.m4 index bd33315090f..9695644bafe 100644 --- a/make/autoconf/jvm-features.m4 +++ b/make/autoconf/jvm-features.m4 @@ -479,6 +479,22 @@ AC_DEFUN([JVM_FEATURES_CALCULATE_ACTIVE], $JVM_FEATURES_ENABLED, $JVM_FEATURES_DISABLED) ]) +################################################################################ +# Filter the unsupported feature combinations. +# This is called after JVM_FEATURES_ACTIVE are fully populated. +# +AC_DEFUN([JVM_FEATURES_FILTER_UNSUPPORTED], +[ + # G1 late barrier expansion in C2 is not implemented for some platforms. + # Choose not to support G1 in this configuration. + if JVM_FEATURES_IS_ACTIVE(compiler2); then + if test "x$OPENJDK_TARGET_CPU" = "xx86"; then + AC_MSG_NOTICE([G1 cannot be used with C2 on this platform, disabling G1]) + UTIL_GET_NON_MATCHING_VALUES(JVM_FEATURES_ACTIVE, $JVM_FEATURES_ACTIVE, "g1gc") + fi + fi +]) + ################################################################################ # Helper function for JVM_FEATURES_VERIFY. Check if the specified JVM # feature is active. To be used in shell if constructs, like this: @@ -554,6 +570,9 @@ AC_DEFUN_ONCE([JVM_FEATURES_SETUP], # The result is stored in JVM_FEATURES_ACTIVE. JVM_FEATURES_CALCULATE_ACTIVE($variant) + # Filter unsupported feature combinations from JVM_FEATURES_ACTIVE. + JVM_FEATURES_FILTER_UNSUPPORTED + # Verify consistency for JVM_FEATURES_ACTIVE. JVM_FEATURES_VERIFY($variant) diff --git a/make/autoconf/spec.gmk.template b/make/autoconf/spec.gmk.template index d5e08cdb640..20b1d00aa89 100644 --- a/make/autoconf/spec.gmk.template +++ b/make/autoconf/spec.gmk.template @@ -719,6 +719,7 @@ CCACHE := @CCACHE@ # CD is going away, but remains to cater for legacy makefiles. CD := cd CHMOD := @CHMOD@ +CMAKE := @CMAKE@ CODESIGN := @CODESIGN@ CP := @CP@ CUT := @CUT@ diff --git a/make/autoconf/toolchain.m4 b/make/autoconf/toolchain.m4 index 75c8d2b61d0..5b3ef98c736 100644 --- a/make/autoconf/toolchain.m4 +++ b/make/autoconf/toolchain.m4 @@ -358,6 +358,11 @@ AC_DEFUN([TOOLCHAIN_EXTRACT_COMPILER_VERSION], # Copyright (C) 2013 Free Software Foundation, Inc. # This is free software; see the source for copying conditions. There is NO # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + # or look like + # gcc (GCC) 10.2.1 20200825 (Alibaba 10.2.1-3.8 2.32) + # Copyright (C) 2020 Free Software Foundation, Inc. + # This is free software; see the source for copying conditions. There is NO + # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. COMPILER_VERSION_OUTPUT=`$COMPILER --version 2>&1` # Check that this is likely to be GCC. $ECHO "$COMPILER_VERSION_OUTPUT" | $GREP "Free Software Foundation" > /dev/null @@ -371,7 +376,8 @@ AC_DEFUN([TOOLCHAIN_EXTRACT_COMPILER_VERSION], COMPILER_VERSION_STRING=`$ECHO $COMPILER_VERSION_OUTPUT | \ $SED -e 's/ *Copyright .*//'` COMPILER_VERSION_NUMBER=`$ECHO $COMPILER_VERSION_OUTPUT | \ - $SED -e 's/^.* \(@<:@1-9@:>@<:@0-9@:>@*\.@<:@0-9.@:>@*\)@<:@^0-9.@:>@.*$/\1/'` + $AWK -F ')' '{print [$]2}' | \ + $AWK '{print [$]1}'` elif test "x$TOOLCHAIN_TYPE" = xclang; then # clang --version output typically looks like # Apple clang version 15.0.0 (clang-1500.3.9.4) diff --git a/make/common/modules/LauncherCommon.gmk b/make/common/modules/LauncherCommon.gmk index ef65f9e431f..7c2cef58835 100644 --- a/make/common/modules/LauncherCommon.gmk +++ b/make/common/modules/LauncherCommon.gmk @@ -74,7 +74,7 @@ define SetupBuildLauncherBody endif ifneq ($$($1_MAIN_CLASS), ) - $1_JAVA_ARGS += -ms8m + $1_JAVA_ARGS += -Xms8m $1_LAUNCHER_CLASS := -m $$($1_MAIN_MODULE)/$$($1_MAIN_CLASS) endif diff --git a/make/conf/github-actions.conf b/make/conf/github-actions.conf index eca6c05033d..a6b383daa8f 100644 --- a/make/conf/github-actions.conf +++ b/make/conf/github-actions.conf @@ -29,21 +29,21 @@ GTEST_VERSION=1.14.0 JTREG_VERSION=7.4+1 LINUX_X64_BOOT_JDK_EXT=tar.gz -LINUX_X64_BOOT_JDK_URL=https://download.java.net/java/GA/jdk22.0.2/c9ecb94cd31b495da20a27d4581645e8/9/GPL/openjdk-22.0.2_linux-x64_bin.tar.gz -LINUX_X64_BOOT_JDK_SHA256=41536f115668308ecf4eba92aaf6acaeb0936225828b741efd83b6173ba82963 +LINUX_X64_BOOT_JDK_URL=https://download.java.net/java/GA/jdk23/3c5b90190c68498b986a97f276efd28a/37/GPL/openjdk-23_linux-x64_bin.tar.gz +LINUX_X64_BOOT_JDK_SHA256=08fea92724127c6fa0f2e5ea0b07ff4951ccb1e2f22db3c21eebbd7347152a67 ALPINE_LINUX_X64_BOOT_JDK_EXT=tar.gz -ALPINE_LINUX_X64_BOOT_JDK_URL=https://github.com/adoptium/temurin22-binaries/releases/download/jdk-22.0.2%2B9/OpenJDK22U-jdk_x64_alpine-linux_hotspot_22.0.2_9.tar.gz -ALPINE_LINUX_X64_BOOT_JDK_SHA256=49f73414824b1a7c268a611225fa4d7ce5e25600201e0f1cd59f94d1040b5264 +ALPINE_LINUX_X64_BOOT_JDK_URL=https://github.com/adoptium/temurin23-binaries/releases/download/jdk-23%2B37/OpenJDK23U-jdk_x64_alpine-linux_hotspot_23_37.tar.gz +ALPINE_LINUX_X64_BOOT_JDK_SHA256=bff4c78f30d8d173e622bf2f40c36113df47337fc6d1ee5105ed2459841165aa MACOS_AARCH64_BOOT_JDK_EXT=tar.gz -MACOS_AARCH64_BOOT_JDK_URL=https://download.java.net/java/GA/jdk22.0.2/c9ecb94cd31b495da20a27d4581645e8/9/GPL/openjdk-22.0.2_macos-aarch64_bin.tar.gz -MACOS_AARCH64_BOOT_JDK_SHA256=3dab98730234e1a87aec14bcb8171d2cae101e96ff4eed1dab96abbb08e843fd +MACOS_AARCH64_BOOT_JDK_URL=https://download.java.net/java/GA/jdk23/3c5b90190c68498b986a97f276efd28a/37/GPL/openjdk-23_macos-aarch64_bin.tar.gz +MACOS_AARCH64_BOOT_JDK_SHA256=9527bf080a74ae6dca51df413aa826f0c011c6048885e4c8ad112172be8815f3 MACOS_X64_BOOT_JDK_EXT=tar.gz -MACOS_X64_BOOT_JDK_URL=https://download.java.net/java/GA/jdk22.0.2/c9ecb94cd31b495da20a27d4581645e8/9/GPL/openjdk-22.0.2_macos-x64_bin.tar.gz -MACOS_X64_BOOT_JDK_SHA256=e8b3ec7a7077711223d31156e771f11723cd7af31c2017f1bd2eda20855940fb +MACOS_X64_BOOT_JDK_URL=https://download.java.net/java/GA/jdk23/3c5b90190c68498b986a97f276efd28a/37/GPL/openjdk-23_macos-x64_bin.tar.gz +MACOS_X64_BOOT_JDK_SHA256=5c3a909fd2079d0e376dd43c85c4f7d02d08914866f196480bd47784b2a0121e WINDOWS_X64_BOOT_JDK_EXT=zip -WINDOWS_X64_BOOT_JDK_URL=https://download.java.net/java/GA/jdk22.0.2/c9ecb94cd31b495da20a27d4581645e8/9/GPL/openjdk-22.0.2_windows-x64_bin.zip -WINDOWS_X64_BOOT_JDK_SHA256=f2a9b9ab944e71a64637fcdc6b13a1188cf02d4eb9ecf71dc927e98b3e45f5dc +WINDOWS_X64_BOOT_JDK_URL=https://download.java.net/java/GA/jdk23/3c5b90190c68498b986a97f276efd28a/37/GPL/openjdk-23_windows-x64_bin.zip +WINDOWS_X64_BOOT_JDK_SHA256=cba5013874ba50cae543c86fe6423453816c77281e2751a8a9a633d966f1dc04 diff --git a/make/conf/jib-profiles.js b/make/conf/jib-profiles.js index 30c45d4cde1..a85c20b2098 100644 --- a/make/conf/jib-profiles.js +++ b/make/conf/jib-profiles.js @@ -390,8 +390,8 @@ var getJibProfilesCommon = function (input, data) { }; }; - common.boot_jdk_version = "22"; - common.boot_jdk_build_number = "36"; + common.boot_jdk_version = "23"; + common.boot_jdk_build_number = "37"; common.boot_jdk_home = input.get("boot_jdk", "install_path") + "/jdk-" + common.boot_jdk_version + (input.build_os == "macosx" ? ".jdk/Contents/Home" : ""); diff --git a/make/conf/version-numbers.conf b/make/conf/version-numbers.conf index 1d47c2cddd0..055f9ca8866 100644 --- a/make/conf/version-numbers.conf +++ b/make/conf/version-numbers.conf @@ -37,6 +37,6 @@ DEFAULT_VERSION_DATE=2025-03-18 DEFAULT_VERSION_CLASSFILE_MAJOR=68 # "`$EXPR $DEFAULT_VERSION_FEATURE + 44`" DEFAULT_VERSION_CLASSFILE_MINOR=0 DEFAULT_VERSION_DOCS_API_SINCE=11 -DEFAULT_ACCEPTABLE_BOOT_VERSIONS="22 23 24" +DEFAULT_ACCEPTABLE_BOOT_VERSIONS="23 24" DEFAULT_JDK_SOURCE_TARGET_VERSION=24 DEFAULT_PROMOTED_VERSION_PRE=ea diff --git a/make/devkit/createAutoconfBundle.sh b/make/devkit/createAutoconfBundle.sh index 861a0a47242..7363b9cd8a7 100644 --- a/make/devkit/createAutoconfBundle.sh +++ b/make/devkit/createAutoconfBundle.sh @@ -1,6 +1,6 @@ #!/bin/bash -e # -# Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -25,50 +25,70 @@ # # Create a bundle in the current directory, containing what's needed to run -# the 'autoconf' program by the OpenJDK build. +# the 'autoconf' program by the OpenJDK build. To override TARGET_PLATFORM +# just set the variable before running this script. # Autoconf depends on m4, so download and build that first. AUTOCONF_VERSION=2.69 M4_VERSION=1.4.18 PACKAGE_VERSION=1.0.1 -TARGET_PLATFORM=linux_x86 +case `uname -s` in + Darwin) + os=macosx + ;; + Linux) + os=linux + ;; + CYGWIN*) + os=cygwin + ;; +esac +case `uname -m` in + arm64|aarch64) + arch=aarch64 + ;; + amd64|x86_64|x64) + arch=x64 + ;; +esac +TARGET_PLATFORM=${TARGET_PLATFORM:="${os}_${arch}"} + MODULE_NAME=autoconf-$TARGET_PLATFORM-$AUTOCONF_VERSION+$PACKAGE_VERSION BUNDLE_NAME=$MODULE_NAME.tar.gz -TMPDIR=`mktemp -d -t autoconfbundle-XXXX` -trap "rm -rf \"$TMPDIR\"" EXIT +SCRIPT_DIR="$(cd "$(dirname $0)" > /dev/null && pwd)" +OUTPUT_ROOT="${SCRIPT_DIR}/../../build/autoconf" -ORIG_DIR=`pwd` -cd $TMPDIR -OUTPUT_DIR=$TMPDIR/$MODULE_NAME -mkdir -p $OUTPUT_DIR/usr +cd $OUTPUT_ROOT +IMAGE_DIR=$OUTPUT_ROOT/$MODULE_NAME +mkdir -p $IMAGE_DIR/usr # Download and build m4 if test "x$TARGET_PLATFORM" = xcygwin_x64; then # On cygwin 64-bit, just copy the cygwin .exe file - mkdir -p $OUTPUT_DIR/usr/bin - cp /usr/bin/m4 $OUTPUT_DIR/usr/bin + mkdir -p $IMAGE_DIR/usr/bin + cp /usr/bin/m4 $IMAGE_DIR/usr/bin elif test "x$TARGET_PLATFORM" = xcygwin_x86; then # On cygwin 32-bit, just copy the cygwin .exe file - mkdir -p $OUTPUT_DIR/usr/bin - cp /usr/bin/m4 $OUTPUT_DIR/usr/bin + mkdir -p $IMAGE_DIR/usr/bin + cp /usr/bin/m4 $IMAGE_DIR/usr/bin elif test "x$TARGET_PLATFORM" = xlinux_x64; then M4_VERSION=1.4.13-5 wget http://yum.oracle.com/repo/OracleLinux/OL6/latest/x86_64/getPackage/m4-$M4_VERSION.el6.x86_64.rpm - cd $OUTPUT_DIR - rpm2cpio ../m4-$M4_VERSION.el6.x86_64.rpm | cpio -d -i + cd $IMAGE_DIR + rpm2cpio $OUTPUT_ROOT/m4-$M4_VERSION.el6.x86_64.rpm | cpio -d -i elif test "x$TARGET_PLATFORM" = xlinux_x86; then M4_VERSION=1.4.13-5 wget http://yum.oracle.com/repo/OracleLinux/OL6/latest/i386/getPackage/m4-$M4_VERSION.el6.i686.rpm - cd $OUTPUT_DIR - rpm2cpio ../m4-$M4_VERSION.el6.i686.rpm | cpio -d -i + cd $IMAGE_DIR + rpm2cpio $OUTPUT_ROOT/m4-$M4_VERSION.el6.i686.rpm | cpio -d -i else wget https://ftp.gnu.org/gnu/m4/m4-$M4_VERSION.tar.gz tar xzf m4-$M4_VERSION.tar.gz cd m4-$M4_VERSION - ./configure --prefix=$OUTPUT_DIR/usr + ./configure --prefix=$IMAGE_DIR/usr CFLAGS="-w -Wno-everything" make make install cd .. @@ -79,15 +99,14 @@ fi wget https://ftp.gnu.org/gnu/autoconf/autoconf-$AUTOCONF_VERSION.tar.gz tar xzf autoconf-$AUTOCONF_VERSION.tar.gz cd autoconf-$AUTOCONF_VERSION -./configure --prefix=$OUTPUT_DIR/usr M4=$OUTPUT_DIR/usr/bin/m4 +./configure --prefix=$IMAGE_DIR/usr M4=$IMAGE_DIR/usr/bin/m4 make make install cd .. -perl -pi -e "s!$OUTPUT_DIR/!./!" $OUTPUT_DIR/usr/bin/auto* $OUTPUT_DIR/usr/share/autoconf/autom4te.cfg -cp $OUTPUT_DIR/usr/share/autoconf/autom4te.cfg $OUTPUT_DIR/autom4te.cfg +perl -pi -e "s!$IMAGE_DIR/!./!" $IMAGE_DIR/usr/bin/auto* $IMAGE_DIR/usr/share/autoconf/autom4te.cfg -cat > $OUTPUT_DIR/autoconf << EOF +cat > $IMAGE_DIR/autoconf << EOF #!/bin/bash # Get an absolute path to this script this_script_dir=\`dirname \$0\` @@ -100,17 +119,10 @@ export AUTOHEADER="\$this_script_dir/usr/bin/autoheader" export AC_MACRODIR="\$this_script_dir/usr/share/autoconf" export autom4te_perllibdir="\$this_script_dir/usr/share/autoconf" -autom4te_cfg=\$this_script_dir/usr/share/autoconf/autom4te.cfg -cp \$this_script_dir/autom4te.cfg \$autom4te_cfg +PREPEND_INCLUDE="--prepend-include \$this_script_dir/usr/share/autoconf" -echo 'begin-language: "M4sugar"' >> \$autom4te_cfg -echo "args: --prepend-include '"\$this_script_dir/usr/share/autoconf"'" >> \$autom4te_cfg -echo 'end-language: "M4sugar"' >> \$autom4te_cfg - -exec \$this_script_dir/usr/bin/autoconf "\$@" +exec \$this_script_dir/usr/bin/autoconf \$PREPEND_INCLUDE "\$@" EOF -chmod +x $OUTPUT_DIR/autoconf -cd $OUTPUT_DIR -tar -cvzf ../$BUNDLE_NAME * -cd .. -cp $BUNDLE_NAME "$ORIG_DIR" +chmod +x $IMAGE_DIR/autoconf +cd $IMAGE_DIR +tar -cvzf $OUTPUT_ROOT/$BUNDLE_NAME * diff --git a/make/hotspot/gensrc/GensrcAdlc.gmk b/make/hotspot/gensrc/GensrcAdlc.gmk index 8dada3cec0a..ddb2c3e33e5 100644 --- a/make/hotspot/gensrc/GensrcAdlc.gmk +++ b/make/hotspot/gensrc/GensrcAdlc.gmk @@ -200,6 +200,13 @@ ifeq ($(call check-jvm-feature, compiler2), true) ))) endif + ifeq ($(call check-jvm-feature, g1gc), true) + AD_SRC_FILES += $(call uniq, $(wildcard $(foreach d, $(AD_SRC_ROOTS), \ + $d/cpu/$(HOTSPOT_TARGET_CPU_ARCH)/gc/g1/g1_$(HOTSPOT_TARGET_CPU).ad \ + $d/cpu/$(HOTSPOT_TARGET_CPU_ARCH)/gc/g1/g1_$(HOTSPOT_TARGET_CPU_ARCH).ad \ + ))) + endif + SINGLE_AD_SRCFILE := $(ADLC_SUPPORT_DIR)/all-ad-src.ad INSERT_FILENAME_AWK_SCRIPT := \ diff --git a/make/jdk/src/classes/build/tools/cldrconverter/CLDRConverter.java b/make/jdk/src/classes/build/tools/cldrconverter/CLDRConverter.java index 15251358a01..8865e3908ae 100644 --- a/make/jdk/src/classes/build/tools/cldrconverter/CLDRConverter.java +++ b/make/jdk/src/classes/build/tools/cldrconverter/CLDRConverter.java @@ -786,7 +786,10 @@ public class CLDRConverter { String tzKey = Optional.ofNullable((String)handlerSupplMeta.get(tzid)) .orElse(tzid); // Follow link, if needed - var tzLink = tzdbLinks.get(tzKey); + String tzLink = null; + for (var k = tzKey; tzdbLinks.containsKey(k);) { + k = tzLink = tzdbLinks.get(k); + } if (tzLink == null && tzdbLinks.containsValue(tzKey)) { // reverse link search // this is needed as in tzdb, "America/Buenos_Aires" links to @@ -1214,7 +1217,7 @@ public class CLDRConverter { private static Set getAvailableZoneIds() { assert handlerMetaZones != null; if (AVAILABLE_TZIDS == null) { - AVAILABLE_TZIDS = new HashSet<>(ZoneId.getAvailableZoneIds()); + AVAILABLE_TZIDS = new HashSet<>(Arrays.asList(TimeZone.getAvailableIDs())); AVAILABLE_TZIDS.addAll(handlerMetaZones.keySet()); AVAILABLE_TZIDS.remove(MetaZonesParseHandler.NO_METAZONE_KEY); } @@ -1372,6 +1375,7 @@ public class CLDRConverter { private static void generateTZDBShortNamesMap() throws IOException { Files.walk(Path.of(tzDataDir), 1, FileVisitOption.FOLLOW_LINKS) .filter(p -> p.toFile().isFile()) + .filter(p -> p.getFileName().toString().matches("africa|antarctica|asia|australasia|backward|etcetera|europe|northamerica|southamerica")) .forEach(p -> { try { String zone = null; @@ -1394,43 +1398,41 @@ public class CLDRConverter { } // remove comments in-line line = line.replaceAll("[ \t]*#.*", ""); - + var tokens = line.split("[ \t]+", -1); + var token0len = tokens.length > 0 ? tokens[0].length() : 0; // Zone line - if (line.startsWith("Zone")) { + if (token0len > 0 && tokens[0].regionMatches(true, 0, "Zone", 0, token0len)) { if (zone != null) { tzdbShortNamesMap.put(zone, format + NBSP + rule); } - var zl = line.split("[ \t]+", -1); - zone = zl[1]; - rule = zl[3]; - format = flipIfNeeded(inVanguard, zl[4]); + zone = tokens[1]; + rule = tokens[3]; + format = flipIfNeeded(inVanguard, tokens[4]); } else { if (zone != null) { - if (line.startsWith("Rule") || - line.startsWith("Link")) { + if (token0len > 0 && + (tokens[0].regionMatches(true, 0, "Rule", 0, token0len) || + tokens[0].regionMatches(true, 0, "Link", 0, token0len))) { tzdbShortNamesMap.put(zone, format + NBSP + rule); zone = null; rule = null; format = null; } else { - var s = line.split("[ \t]+", -1); - rule = s[2]; - format = flipIfNeeded(inVanguard, s[3]); + rule = tokens[2]; + format = flipIfNeeded(inVanguard, tokens[3]); } } } // Rule line - if (line.startsWith("Rule")) { - var rl = line.split("[ \t]+", -1); - tzdbSubstLetters.put(rl[1] + NBSP + (rl[8].equals("0") ? STD : DST), - rl[9].replace(NO_SUBST, "")); + if (token0len > 0 && tokens[0].regionMatches(true, 0, "Rule", 0, token0len)) { + tzdbSubstLetters.put(tokens[1] + NBSP + (tokens[8].equals("0") ? STD : DST), + tokens[9].replace(NO_SUBST, "")); } // Link line - if (line.startsWith("Link")) { - var ll = line.split("[ \t]+", -1); - tzdbLinks.put(ll[2], ll[1]); + if (token0len > 0 && tokens[0].regionMatches(true, 0, "Link", 0, token0len)) { + tzdbLinks.put(tokens[2], tokens[1]); } } @@ -1491,13 +1493,14 @@ public class CLDRConverter { /* * Convert TZDB offsets to JDK's offsets, eg, "-08" to "GMT-08:00". * If it cannot recognize the pattern, return the argument as is. + * Returning null results in generating the GMT format at runtime. */ private static String convertGMTName(String f) { try { - // Should pre-fill GMT format once COMPAT is gone. - // Till then, fall back to GMT format at runtime, after COMPAT short - // names are populated - ZoneOffset.of(f); + if (!f.equals("%z")) { + // Validate if the format is an offset + ZoneOffset.of(f); + } return null; } catch (DateTimeException dte) { // textual representation. return as is diff --git a/make/jdk/src/classes/build/tools/tzdb/TzdbZoneRulesCompiler.java b/make/jdk/src/classes/build/tools/tzdb/TzdbZoneRulesCompiler.java index 630d3a390d1..426d0bb10ed 100644 --- a/make/jdk/src/classes/build/tools/tzdb/TzdbZoneRulesCompiler.java +++ b/make/jdk/src/classes/build/tools/tzdb/TzdbZoneRulesCompiler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -273,7 +273,7 @@ public final class TzdbZoneRulesCompiler { // link version-region-rules out.writeShort(builtZones.size()); for (Map.Entry entry : builtZones.entrySet()) { - int regionIndex = Arrays.binarySearch(regionArray, entry.getKey()); + int regionIndex = findRegionIndex(regionArray, entry.getKey()); int rulesIndex = rulesList.indexOf(entry.getValue()); out.writeShort(regionIndex); out.writeShort(rulesIndex); @@ -281,8 +281,8 @@ public final class TzdbZoneRulesCompiler { // alias-region out.writeShort(links.size()); for (Map.Entry entry : links.entrySet()) { - int aliasIndex = Arrays.binarySearch(regionArray, entry.getKey()); - int regionIndex = Arrays.binarySearch(regionArray, entry.getValue()); + int aliasIndex = findRegionIndex(regionArray, entry.getKey()); + int regionIndex = findRegionIndex(regionArray, entry.getValue()); out.writeShort(aliasIndex); out.writeShort(regionIndex); } @@ -294,6 +294,14 @@ public final class TzdbZoneRulesCompiler { } } + private static int findRegionIndex(String[] regionArray, String region) { + int index = Arrays.binarySearch(regionArray, region); + if (index < 0) { + throw new IllegalArgumentException("Unknown region: " + region); + } + return index; + } + /** Whether to output verbose messages. */ private boolean verbose; diff --git a/make/jdk/src/classes/build/tools/tzdb/TzdbZoneRulesProvider.java b/make/jdk/src/classes/build/tools/tzdb/TzdbZoneRulesProvider.java index d82e58e3420..ecca3c69c06 100644 --- a/make/jdk/src/classes/build/tools/tzdb/TzdbZoneRulesProvider.java +++ b/make/jdk/src/classes/build/tools/tzdb/TzdbZoneRulesProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -164,7 +164,8 @@ class TzdbZoneRulesProvider { } continue; } - if (line.startsWith("Zone")) { // parse Zone line + int token0len = tokens.length > 0 ? tokens[0].length() : line.length(); + if (line.regionMatches(true, 0, "Zone", 0, token0len)) { // parse Zone line String name = tokens[1]; if (excludedZones.contains(name)){ continue; @@ -182,13 +183,13 @@ class TzdbZoneRulesProvider { if (zLine.parse(tokens, 2)) { openZone = null; } - } else if (line.startsWith("Rule")) { // parse Rule line + } else if (line.regionMatches(true, 0, "Rule", 0, token0len)) { // parse Rule line String name = tokens[1]; if (!rules.containsKey(name)) { rules.put(name, new ArrayList(10)); } rules.get(name).add(new RuleLine().parse(tokens)); - } else if (line.startsWith("Link")) { // parse link line + } else if (line.regionMatches(true, 0, "Link", 0, token0len)) { // parse link line if (tokens.length >= 3) { String realId = tokens[1]; String aliasId = tokens[2]; @@ -304,7 +305,7 @@ class TzdbZoneRulesProvider { month = parseMonth(tokens[off++]); if (off < tokens.length) { String dayRule = tokens[off++]; - if (dayRule.startsWith("last")) { + if (dayRule.regionMatches(true, 0, "last", 0, 4)) { dayOfMonth = -1; dayOfWeek = parseDayOfWeek(dayRule.substring(4)); adjustForwards = false; @@ -355,42 +356,45 @@ class TzdbZoneRulesProvider { } int parseYear(String year, int defaultYear) { - switch (year.toLowerCase()) { - case "min": return 1900; - case "max": return Year.MAX_VALUE; - case "only": return defaultYear; - } + int len = year.length(); + + if (year.regionMatches(true, 0, "minimum", 0, len)) return 1900; + if (year.regionMatches(true, 0, "maximum", 0, len)) return Year.MAX_VALUE; + if (year.regionMatches(true, 0, "only", 0, len)) return defaultYear; + return Integer.parseInt(year); } Month parseMonth(String mon) { - switch (mon) { - case "Jan": return Month.JANUARY; - case "Feb": return Month.FEBRUARY; - case "Mar": return Month.MARCH; - case "Apr": return Month.APRIL; - case "May": return Month.MAY; - case "Jun": return Month.JUNE; - case "Jul": return Month.JULY; - case "Aug": return Month.AUGUST; - case "Sep": return Month.SEPTEMBER; - case "Oct": return Month.OCTOBER; - case "Nov": return Month.NOVEMBER; - case "Dec": return Month.DECEMBER; - } + int len = mon.length(); + + if (mon.regionMatches(true, 0, "January", 0, len)) return Month.JANUARY; + if (mon.regionMatches(true, 0, "February", 0, len)) return Month.FEBRUARY; + if (mon.regionMatches(true, 0, "March", 0, len)) return Month.MARCH; + if (mon.regionMatches(true, 0, "April", 0, len)) return Month.APRIL; + if (mon.regionMatches(true, 0, "May", 0, len)) return Month.MAY; + if (mon.regionMatches(true, 0, "June", 0, len)) return Month.JUNE; + if (mon.regionMatches(true, 0, "July", 0, len)) return Month.JULY; + if (mon.regionMatches(true, 0, "August", 0, len)) return Month.AUGUST; + if (mon.regionMatches(true, 0, "September", 0, len)) return Month.SEPTEMBER; + if (mon.regionMatches(true, 0, "October", 0, len)) return Month.OCTOBER; + if (mon.regionMatches(true, 0, "November", 0, len)) return Month.NOVEMBER; + if (mon.regionMatches(true, 0, "December", 0, len)) return Month.DECEMBER; + throw new IllegalArgumentException("Unknown month: " + mon); } DayOfWeek parseDayOfWeek(String dow) { - switch (dow) { - case "Mon": return DayOfWeek.MONDAY; - case "Tue": return DayOfWeek.TUESDAY; - case "Wed": return DayOfWeek.WEDNESDAY; - case "Thu": return DayOfWeek.THURSDAY; - case "Fri": return DayOfWeek.FRIDAY; - case "Sat": return DayOfWeek.SATURDAY; - case "Sun": return DayOfWeek.SUNDAY; - } + int len = dow.length(); + + if (dow.regionMatches(true, 0, "Monday", 0, len)) return DayOfWeek.MONDAY; + if (dow.regionMatches(true, 0, "Tuesday", 0, len)) return DayOfWeek.TUESDAY; + if (dow.regionMatches(true, 0, "Wednesday", 0, len)) return DayOfWeek.WEDNESDAY; + if (dow.regionMatches(true, 0, "Thursday", 0, len)) return DayOfWeek.THURSDAY; + if (dow.regionMatches(true, 0, "Friday", 0, len)) return DayOfWeek.FRIDAY; + if (dow.regionMatches(true, 0, "Saturday", 0, len)) return DayOfWeek.SATURDAY; + if (dow.regionMatches(true, 0, "Sunday", 0, len)) return DayOfWeek.SUNDAY; + throw new IllegalArgumentException("Unknown day-of-week: " + dow); } diff --git a/make/modules/jdk.hotspot.agent/Lib.gmk b/make/modules/jdk.hotspot.agent/Lib.gmk index f0ede594d0c..12f1c1f2a90 100644 --- a/make/modules/jdk.hotspot.agent/Lib.gmk +++ b/make/modules/jdk.hotspot.agent/Lib.gmk @@ -59,9 +59,7 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBSAPROC, \ OPTIMIZATION := HIGH, \ EXTRA_HEADER_DIRS := java.base:libjvm, \ DISABLED_WARNINGS_gcc := sign-compare, \ - DISABLED_WARNINGS_gcc_LinuxDebuggerLocal.cpp := unused-variable, \ DISABLED_WARNINGS_gcc_ps_core.c := pointer-arith, \ - DISABLED_WARNINGS_gcc_symtab.c := unused-but-set-variable, \ DISABLED_WARNINGS_clang := sign-compare, \ DISABLED_WARNINGS_clang_libproc_impl.c := format-nonliteral, \ DISABLED_WARNINGS_clang_MacosxDebuggerLocal.m := unused-variable, \ diff --git a/make/modules/jdk.incubator.vector/Lib.gmk b/make/modules/jdk.incubator.vector/Lib.gmk index 0620549f05c..bf6ace6f97f 100644 --- a/make/modules/jdk.incubator.vector/Lib.gmk +++ b/make/modules/jdk.incubator.vector/Lib.gmk @@ -37,3 +37,21 @@ ifeq ($(call isTargetOs, linux windows)+$(call isTargetCpu, x86_64)+$(INCLUDE_CO TARGETS += $(BUILD_LIBJSVML) endif + +################################################################################ +## Build libsleef +################################################################################ + +ifeq ($(call isTargetOs, linux)+$(call isTargetCpu, riscv64)+$(INCLUDE_COMPILER2), true+true+true) + $(eval $(call SetupJdkLibrary, BUILD_LIBSLEEF, \ + NAME := sleef, \ + OPTIMIZATION := HIGH, \ + SRC := libsleef/lib, \ + EXTRA_SRC := libsleef/generated, \ + DISABLED_WARNINGS_gcc := unused-function sign-compare tautological-compare ignored-qualifiers, \ + DISABLED_WARNINGS_clang := unused-function sign-compare tautological-compare ignored-qualifiers, \ + CFLAGS := -march=rv64gcv, \ + )) + + TARGETS += $(BUILD_LIBSLEEF) +endif diff --git a/make/test/JtregNativeHotspot.gmk b/make/test/JtregNativeHotspot.gmk index 8916eee90d7..97f2f12cb76 100644 --- a/make/test/JtregNativeHotspot.gmk +++ b/make/test/JtregNativeHotspot.gmk @@ -885,7 +885,7 @@ BUILD_HOTSPOT_JTREG_EXECUTABLES_JDK_LIBS_exedaemonDestroy := java.base:libjvm ifeq ($(call isTargetOs, windows), true) BUILD_HOTSPOT_JTREG_EXECUTABLES_CFLAGS_exeFPRegs := -MT - BUILD_HOTSPOT_JTREG_EXCLUDE += exesigtest.c libterminatedThread.c libTestJNI.c libCompleteExit.c libMonitorWithDeadObjectTest.c libTestPsig.c exeGetCreatedJavaVMs.c + BUILD_HOTSPOT_JTREG_EXCLUDE += exesigtest.c libterminatedThread.c libTestJNI.c libCompleteExit.c libMonitorWithDeadObjectTest.c libTestPsig.c exeGetCreatedJavaVMs.c libTestUnloadedClass.cpp BUILD_HOTSPOT_JTREG_LIBRARIES_JDK_LIBS_libnativeStack := java.base:libjvm BUILD_HOTSPOT_JTREG_LIBRARIES_JDK_LIBS_libVThreadEventTest := java.base:libjvm else @@ -1526,6 +1526,7 @@ else BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libCompleteExit += -lpthread BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libMonitorWithDeadObjectTest += -lpthread BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libnativeStack += -lpthread + BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libTestUnloadedClass += -lpthread BUILD_HOTSPOT_JTREG_LIBRARIES_JDK_LIBS_libVThreadEventTest := java.base:libjvm BUILD_HOTSPOT_JTREG_EXECUTABLES_LIBS_exeGetCreatedJavaVMs := -lpthread BUILD_HOTSPOT_JTREG_EXECUTABLES_JDK_LIBS_exeGetCreatedJavaVMs := java.base:libjvm diff --git a/make/test/JtregNativeJdk.gmk b/make/test/JtregNativeJdk.gmk index d9f1e334a5c..90055cb5c01 100644 --- a/make/test/JtregNativeJdk.gmk +++ b/make/test/JtregNativeJdk.gmk @@ -115,6 +115,8 @@ ifeq ($(call isTargetOs, linux), true) # stripping during the test libraries' build. BUILD_JDK_JTREG_LIBRARIES_CFLAGS_libFib := -g BUILD_JDK_JTREG_LIBRARIES_STRIP_SYMBOLS_libFib := false + # nio tests' libCreationTimeHelper native needs -ldl linker flag + BUILD_JDK_JTREG_LIBRARIES_LDFLAGS_libCreationTimeHelper := -ldl endif ifeq ($(ASAN_ENABLED), true) diff --git a/src/hotspot/cpu/aarch64/aarch64.ad b/src/hotspot/cpu/aarch64/aarch64.ad index fced9cfc35e..d9c77a2f529 100644 --- a/src/hotspot/cpu/aarch64/aarch64.ad +++ b/src/hotspot/cpu/aarch64/aarch64.ad @@ -1244,7 +1244,7 @@ source %{ // r27 is not allocatable when compressed oops is on and heapbase is not // zero, compressed klass pointers doesn't use r27 after JDK-8234794 - if (UseCompressedOops && (CompressedOops::ptrs_base() != nullptr)) { + if (UseCompressedOops && (CompressedOops::base() != nullptr)) { _NO_SPECIAL_REG32_mask.Remove(OptoReg::as_OptoReg(r27->as_VMReg())); _NO_SPECIAL_REG_mask.Remove(OptoReg::as_OptoReg(r27->as_VMReg())); _NO_SPECIAL_PTR_REG_mask.Remove(OptoReg::as_OptoReg(r27->as_VMReg())); @@ -2307,10 +2307,6 @@ const RegMask* Matcher::predicate_reg_mask(void) { return &_PR_REG_mask; } -const TypeVectMask* Matcher::predicate_reg_type(const Type* elemTy, int length) { - return new TypeVectMask(elemTy, length); -} - // Vector calling convention not yet implemented. bool Matcher::supports_vector_calling_convention(void) { return false; @@ -2620,7 +2616,8 @@ static bool is_vector_bitwise_not_pattern(Node* n, Node* m) { bool Matcher::pd_clone_node(Node* n, Node* m, Matcher::MStack& mstack) { if (is_vshift_con_pattern(n, m) || is_vector_bitwise_not_pattern(n, m) || - is_valid_sve_arith_imm_pattern(n, m)) { + is_valid_sve_arith_imm_pattern(n, m) || + is_encode_and_store_pattern(n, m)) { mstack.push(m, Visit); return true; } @@ -2720,7 +2717,7 @@ typedef void (MacroAssembler::* mem_vector_insn)(FloatRegister Rt, { Address addr = mem2address(opcode, base, index, scale, disp); if (addr.getMode() == Address::base_plus_offset) { - // Fix up any out-of-range offsets. + /* Fix up any out-of-range offsets. */ assert_different_registers(rscratch1, base); assert_different_registers(rscratch1, reg); addr = __ legitimize_address(addr, size_in_memory, rscratch1); @@ -2761,11 +2758,7 @@ typedef void (MacroAssembler::* mem_vector_insn)(FloatRegister Rt, int opcode, Register base, int index, int size, int disp) { if (index == -1) { - // Fix up any out-of-range offsets. - assert_different_registers(rscratch1, base); - Address addr = Address(base, disp); - addr = __ legitimize_address(addr, (1 << T), rscratch1); - (masm->*insn)(reg, T, addr); + (masm->*insn)(reg, T, Address(base, disp)); } else { assert(disp == 0, "unsupported address mode"); (masm->*insn)(reg, T, Address(base, as_Register(index), Address::lsl(size))); @@ -2820,7 +2813,7 @@ encode %{ // This encoding class is generated automatically from ad_encode.m4. // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE - enc_class aarch64_enc_ldrsbw(iRegI dst, memory mem) %{ + enc_class aarch64_enc_ldrsbw(iRegI dst, memory1 mem) %{ Register dst_reg = as_Register($dst$$reg); loadStore(masm, &MacroAssembler::ldrsbw, dst_reg, $mem->opcode(), as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp, 1); @@ -2828,7 +2821,7 @@ encode %{ // This encoding class is generated automatically from ad_encode.m4. // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE - enc_class aarch64_enc_ldrsb(iRegI dst, memory mem) %{ + enc_class aarch64_enc_ldrsb(iRegI dst, memory1 mem) %{ Register dst_reg = as_Register($dst$$reg); loadStore(masm, &MacroAssembler::ldrsb, dst_reg, $mem->opcode(), as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp, 1); @@ -2836,7 +2829,7 @@ encode %{ // This encoding class is generated automatically from ad_encode.m4. // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE - enc_class aarch64_enc_ldrb(iRegI dst, memory mem) %{ + enc_class aarch64_enc_ldrb(iRegI dst, memory1 mem) %{ Register dst_reg = as_Register($dst$$reg); loadStore(masm, &MacroAssembler::ldrb, dst_reg, $mem->opcode(), as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp, 1); @@ -2844,7 +2837,7 @@ encode %{ // This encoding class is generated automatically from ad_encode.m4. // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE - enc_class aarch64_enc_ldrb(iRegL dst, memory mem) %{ + enc_class aarch64_enc_ldrb(iRegL dst, memory1 mem) %{ Register dst_reg = as_Register($dst$$reg); loadStore(masm, &MacroAssembler::ldrb, dst_reg, $mem->opcode(), as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp, 1); @@ -2852,7 +2845,7 @@ encode %{ // This encoding class is generated automatically from ad_encode.m4. // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE - enc_class aarch64_enc_ldrshw(iRegI dst, memory mem) %{ + enc_class aarch64_enc_ldrshw(iRegI dst, memory2 mem) %{ Register dst_reg = as_Register($dst$$reg); loadStore(masm, &MacroAssembler::ldrshw, dst_reg, $mem->opcode(), as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp, 2); @@ -2860,7 +2853,7 @@ encode %{ // This encoding class is generated automatically from ad_encode.m4. // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE - enc_class aarch64_enc_ldrsh(iRegI dst, memory mem) %{ + enc_class aarch64_enc_ldrsh(iRegI dst, memory2 mem) %{ Register dst_reg = as_Register($dst$$reg); loadStore(masm, &MacroAssembler::ldrsh, dst_reg, $mem->opcode(), as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp, 2); @@ -2868,7 +2861,7 @@ encode %{ // This encoding class is generated automatically from ad_encode.m4. // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE - enc_class aarch64_enc_ldrh(iRegI dst, memory mem) %{ + enc_class aarch64_enc_ldrh(iRegI dst, memory2 mem) %{ Register dst_reg = as_Register($dst$$reg); loadStore(masm, &MacroAssembler::ldrh, dst_reg, $mem->opcode(), as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp, 2); @@ -2876,7 +2869,7 @@ encode %{ // This encoding class is generated automatically from ad_encode.m4. // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE - enc_class aarch64_enc_ldrh(iRegL dst, memory mem) %{ + enc_class aarch64_enc_ldrh(iRegL dst, memory2 mem) %{ Register dst_reg = as_Register($dst$$reg); loadStore(masm, &MacroAssembler::ldrh, dst_reg, $mem->opcode(), as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp, 2); @@ -2884,7 +2877,7 @@ encode %{ // This encoding class is generated automatically from ad_encode.m4. // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE - enc_class aarch64_enc_ldrw(iRegI dst, memory mem) %{ + enc_class aarch64_enc_ldrw(iRegI dst, memory4 mem) %{ Register dst_reg = as_Register($dst$$reg); loadStore(masm, &MacroAssembler::ldrw, dst_reg, $mem->opcode(), as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp, 4); @@ -2892,7 +2885,7 @@ encode %{ // This encoding class is generated automatically from ad_encode.m4. // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE - enc_class aarch64_enc_ldrw(iRegL dst, memory mem) %{ + enc_class aarch64_enc_ldrw(iRegL dst, memory4 mem) %{ Register dst_reg = as_Register($dst$$reg); loadStore(masm, &MacroAssembler::ldrw, dst_reg, $mem->opcode(), as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp, 4); @@ -2900,7 +2893,7 @@ encode %{ // This encoding class is generated automatically from ad_encode.m4. // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE - enc_class aarch64_enc_ldrsw(iRegL dst, memory mem) %{ + enc_class aarch64_enc_ldrsw(iRegL dst, memory4 mem) %{ Register dst_reg = as_Register($dst$$reg); loadStore(masm, &MacroAssembler::ldrsw, dst_reg, $mem->opcode(), as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp, 4); @@ -2908,7 +2901,7 @@ encode %{ // This encoding class is generated automatically from ad_encode.m4. // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE - enc_class aarch64_enc_ldr(iRegL dst, memory mem) %{ + enc_class aarch64_enc_ldr(iRegL dst, memory8 mem) %{ Register dst_reg = as_Register($dst$$reg); loadStore(masm, &MacroAssembler::ldr, dst_reg, $mem->opcode(), as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp, 8); @@ -2916,7 +2909,7 @@ encode %{ // This encoding class is generated automatically from ad_encode.m4. // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE - enc_class aarch64_enc_ldrs(vRegF dst, memory mem) %{ + enc_class aarch64_enc_ldrs(vRegF dst, memory4 mem) %{ FloatRegister dst_reg = as_FloatRegister($dst$$reg); loadStore(masm, &MacroAssembler::ldrs, dst_reg, $mem->opcode(), as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp, 4); @@ -2924,7 +2917,7 @@ encode %{ // This encoding class is generated automatically from ad_encode.m4. // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE - enc_class aarch64_enc_ldrd(vRegD dst, memory mem) %{ + enc_class aarch64_enc_ldrd(vRegD dst, memory8 mem) %{ FloatRegister dst_reg = as_FloatRegister($dst$$reg); loadStore(masm, &MacroAssembler::ldrd, dst_reg, $mem->opcode(), as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp, 8); @@ -2932,7 +2925,7 @@ encode %{ // This encoding class is generated automatically from ad_encode.m4. // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE - enc_class aarch64_enc_strb(iRegI src, memory mem) %{ + enc_class aarch64_enc_strb(iRegI src, memory1 mem) %{ Register src_reg = as_Register($src$$reg); loadStore(masm, &MacroAssembler::strb, src_reg, $mem->opcode(), as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp, 1); @@ -2940,14 +2933,14 @@ encode %{ // This encoding class is generated automatically from ad_encode.m4. // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE - enc_class aarch64_enc_strb0(memory mem) %{ + enc_class aarch64_enc_strb0(memory1 mem) %{ loadStore(masm, &MacroAssembler::strb, zr, $mem->opcode(), as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp, 1); %} // This encoding class is generated automatically from ad_encode.m4. // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE - enc_class aarch64_enc_strh(iRegI src, memory mem) %{ + enc_class aarch64_enc_strh(iRegI src, memory2 mem) %{ Register src_reg = as_Register($src$$reg); loadStore(masm, &MacroAssembler::strh, src_reg, $mem->opcode(), as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp, 2); @@ -2955,14 +2948,14 @@ encode %{ // This encoding class is generated automatically from ad_encode.m4. // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE - enc_class aarch64_enc_strh0(memory mem) %{ + enc_class aarch64_enc_strh0(memory2 mem) %{ loadStore(masm, &MacroAssembler::strh, zr, $mem->opcode(), as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp, 2); %} // This encoding class is generated automatically from ad_encode.m4. // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE - enc_class aarch64_enc_strw(iRegI src, memory mem) %{ + enc_class aarch64_enc_strw(iRegI src, memory4 mem) %{ Register src_reg = as_Register($src$$reg); loadStore(masm, &MacroAssembler::strw, src_reg, $mem->opcode(), as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp, 4); @@ -2970,14 +2963,14 @@ encode %{ // This encoding class is generated automatically from ad_encode.m4. // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE - enc_class aarch64_enc_strw0(memory mem) %{ + enc_class aarch64_enc_strw0(memory4 mem) %{ loadStore(masm, &MacroAssembler::strw, zr, $mem->opcode(), as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp, 4); %} // This encoding class is generated automatically from ad_encode.m4. // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE - enc_class aarch64_enc_str(iRegL src, memory mem) %{ + enc_class aarch64_enc_str(iRegL src, memory8 mem) %{ Register src_reg = as_Register($src$$reg); // we sometimes get asked to store the stack pointer into the // current thread -- we cannot do that directly on AArch64 @@ -2992,14 +2985,14 @@ encode %{ // This encoding class is generated automatically from ad_encode.m4. // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE - enc_class aarch64_enc_str0(memory mem) %{ + enc_class aarch64_enc_str0(memory8 mem) %{ loadStore(masm, &MacroAssembler::str, zr, $mem->opcode(), as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp, 8); %} // This encoding class is generated automatically from ad_encode.m4. // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE - enc_class aarch64_enc_strs(vRegF src, memory mem) %{ + enc_class aarch64_enc_strs(vRegF src, memory4 mem) %{ FloatRegister src_reg = as_FloatRegister($src$$reg); loadStore(masm, &MacroAssembler::strs, src_reg, $mem->opcode(), as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp, 4); @@ -3007,7 +3000,7 @@ encode %{ // This encoding class is generated automatically from ad_encode.m4. // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE - enc_class aarch64_enc_strd(vRegD src, memory mem) %{ + enc_class aarch64_enc_strd(vRegD src, memory8 mem) %{ FloatRegister src_reg = as_FloatRegister($src$$reg); loadStore(masm, &MacroAssembler::strd, src_reg, $mem->opcode(), as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp, 8); @@ -3015,7 +3008,7 @@ encode %{ // This encoding class is generated automatically from ad_encode.m4. // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE - enc_class aarch64_enc_strb0_ordered(memory mem) %{ + enc_class aarch64_enc_strb0_ordered(memory4 mem) %{ __ membar(Assembler::StoreStore); loadStore(masm, &MacroAssembler::strb, zr, $mem->opcode(), as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp, 1); @@ -3217,7 +3210,7 @@ encode %{ // synchronized read/update encodings - enc_class aarch64_enc_ldaxr(iRegL dst, memory mem) %{ + enc_class aarch64_enc_ldaxr(iRegL dst, memory8 mem) %{ Register dst_reg = as_Register($dst$$reg); Register base = as_Register($mem$$base); int index = $mem$$index; @@ -3245,7 +3238,7 @@ encode %{ } %} - enc_class aarch64_enc_stlxr(iRegLNoSp src, memory mem) %{ + enc_class aarch64_enc_stlxr(iRegLNoSp src, memory8 mem) %{ Register src_reg = as_Register($src$$reg); Register base = as_Register($mem$$base); int index = $mem$$index; @@ -4173,10 +4166,60 @@ operand immIU7() interface(CONST_INTER); %} -// Offset for immediate loads and stores +// Offset for scaled or unscaled immediate loads and stores operand immIOffset() %{ - predicate(n->get_int() >= -256 && n->get_int() <= 65520); + predicate(Address::offset_ok_for_immed(n->get_int(), 0)); + match(ConI); + + op_cost(0); + format %{ %} + interface(CONST_INTER); +%} + +operand immIOffset1() +%{ + predicate(Address::offset_ok_for_immed(n->get_int(), 0)); + match(ConI); + + op_cost(0); + format %{ %} + interface(CONST_INTER); +%} + +operand immIOffset2() +%{ + predicate(Address::offset_ok_for_immed(n->get_int(), 1)); + match(ConI); + + op_cost(0); + format %{ %} + interface(CONST_INTER); +%} + +operand immIOffset4() +%{ + predicate(Address::offset_ok_for_immed(n->get_int(), 2)); + match(ConI); + + op_cost(0); + format %{ %} + interface(CONST_INTER); +%} + +operand immIOffset8() +%{ + predicate(Address::offset_ok_for_immed(n->get_int(), 3)); + match(ConI); + + op_cost(0); + format %{ %} + interface(CONST_INTER); +%} + +operand immIOffset16() +%{ + predicate(Address::offset_ok_for_immed(n->get_int(), 4)); match(ConI); op_cost(0); @@ -4194,6 +4237,56 @@ operand immLOffset() interface(CONST_INTER); %} +operand immLoffset1() +%{ + predicate(Address::offset_ok_for_immed(n->get_long(), 0)); + match(ConL); + + op_cost(0); + format %{ %} + interface(CONST_INTER); +%} + +operand immLoffset2() +%{ + predicate(Address::offset_ok_for_immed(n->get_long(), 1)); + match(ConL); + + op_cost(0); + format %{ %} + interface(CONST_INTER); +%} + +operand immLoffset4() +%{ + predicate(Address::offset_ok_for_immed(n->get_long(), 2)); + match(ConL); + + op_cost(0); + format %{ %} + interface(CONST_INTER); +%} + +operand immLoffset8() +%{ + predicate(Address::offset_ok_for_immed(n->get_long(), 3)); + match(ConL); + + op_cost(0); + format %{ %} + interface(CONST_INTER); +%} + +operand immLoffset16() +%{ + predicate(Address::offset_ok_for_immed(n->get_long(), 4)); + match(ConL); + + op_cost(0); + format %{ %} + interface(CONST_INTER); +%} + // 5 bit signed long integer operand immL5() %{ @@ -5106,7 +5199,7 @@ operand indIndex(iRegP reg, iRegL lreg) %} %} -operand indOffI(iRegP reg, immIOffset off) +operand indOffI1(iRegP reg, immIOffset1 off) %{ constraint(ALLOC_IN_RC(ptr_reg)); match(AddP reg off); @@ -5120,7 +5213,119 @@ operand indOffI(iRegP reg, immIOffset off) %} %} -operand indOffL(iRegP reg, immLOffset off) +operand indOffI2(iRegP reg, immIOffset2 off) +%{ + constraint(ALLOC_IN_RC(ptr_reg)); + match(AddP reg off); + op_cost(0); + format %{ "[$reg, $off]" %} + interface(MEMORY_INTER) %{ + base($reg); + index(0xffffffff); + scale(0x0); + disp($off); + %} +%} + +operand indOffI4(iRegP reg, immIOffset4 off) +%{ + constraint(ALLOC_IN_RC(ptr_reg)); + match(AddP reg off); + op_cost(0); + format %{ "[$reg, $off]" %} + interface(MEMORY_INTER) %{ + base($reg); + index(0xffffffff); + scale(0x0); + disp($off); + %} +%} + +operand indOffI8(iRegP reg, immIOffset8 off) +%{ + constraint(ALLOC_IN_RC(ptr_reg)); + match(AddP reg off); + op_cost(0); + format %{ "[$reg, $off]" %} + interface(MEMORY_INTER) %{ + base($reg); + index(0xffffffff); + scale(0x0); + disp($off); + %} +%} + +operand indOffI16(iRegP reg, immIOffset16 off) +%{ + constraint(ALLOC_IN_RC(ptr_reg)); + match(AddP reg off); + op_cost(0); + format %{ "[$reg, $off]" %} + interface(MEMORY_INTER) %{ + base($reg); + index(0xffffffff); + scale(0x0); + disp($off); + %} +%} + +operand indOffL1(iRegP reg, immLoffset1 off) +%{ + constraint(ALLOC_IN_RC(ptr_reg)); + match(AddP reg off); + op_cost(0); + format %{ "[$reg, $off]" %} + interface(MEMORY_INTER) %{ + base($reg); + index(0xffffffff); + scale(0x0); + disp($off); + %} +%} + +operand indOffL2(iRegP reg, immLoffset2 off) +%{ + constraint(ALLOC_IN_RC(ptr_reg)); + match(AddP reg off); + op_cost(0); + format %{ "[$reg, $off]" %} + interface(MEMORY_INTER) %{ + base($reg); + index(0xffffffff); + scale(0x0); + disp($off); + %} +%} + +operand indOffL4(iRegP reg, immLoffset4 off) +%{ + constraint(ALLOC_IN_RC(ptr_reg)); + match(AddP reg off); + op_cost(0); + format %{ "[$reg, $off]" %} + interface(MEMORY_INTER) %{ + base($reg); + index(0xffffffff); + scale(0x0); + disp($off); + %} +%} + +operand indOffL8(iRegP reg, immLoffset8 off) +%{ + constraint(ALLOC_IN_RC(ptr_reg)); + match(AddP reg off); + op_cost(0); + format %{ "[$reg, $off]" %} + interface(MEMORY_INTER) %{ + base($reg); + index(0xffffffff); + scale(0x0); + disp($off); + %} +%} + +operand indOffL16(iRegP reg, immLoffset16 off) %{ constraint(ALLOC_IN_RC(ptr_reg)); match(AddP reg off); @@ -5496,7 +5701,10 @@ operand iRegL2P(iRegL reg) %{ interface(REG_INTER) %} -opclass vmem(indirect, indIndex, indOffI, indOffL, indOffIN, indOffLN); +opclass vmem2(indirect, indIndex, indOffI2, indOffL2); +opclass vmem4(indirect, indIndex, indOffI4, indOffL4); +opclass vmem8(indirect, indIndex, indOffI8, indOffL8); +opclass vmem16(indirect, indIndex, indOffI16, indOffL16); //----------OPERAND CLASSES---------------------------------------------------- // Operand Classes are groups of operands that are used as to simplify @@ -5508,9 +5716,23 @@ opclass vmem(indirect, indIndex, indOffI, indOffL, indOffIN, indOffLN); // memory is used to define read/write location for load/store // instruction defs. we can turn a memory op into an Address -opclass memory(indirect, indIndexScaled, indIndexScaledI2L, indIndexI2L, indIndex, indOffI, indOffL, - indirectN, indIndexScaledN, indIndexScaledI2LN, indIndexI2LN, indIndexN, indOffIN, - indOffLN, indirectX2P, indOffX2P); +opclass memory1(indirect, indIndexScaled, indIndexScaledI2L, indIndexI2L, indIndex, indOffI1, indOffL1, + indirectN, indIndexScaledN, indIndexScaledI2LN, indIndexI2LN, indIndexN, indirectX2P, indOffX2P); + +opclass memory2(indirect, indIndexScaled, indIndexScaledI2L, indIndexI2L, indIndex, indOffI2, indOffL2, + indirectN, indIndexScaledN, indIndexScaledI2LN, indIndexI2LN, indIndexN, indirectX2P, indOffX2P); + +opclass memory4(indirect, indIndexScaled, indIndexScaledI2L, indIndexI2L, indIndex, indOffI4, indOffL4, + indirectN, indIndexScaledN, indIndexScaledI2LN, indIndexI2LN, indIndexN, indOffIN, indOffLN, indirectX2P, indOffX2P); + +opclass memory8(indirect, indIndexScaled, indIndexScaledI2L, indIndexI2L, indIndex, indOffI8, indOffL8, + indirectN, indIndexScaledN, indIndexScaledI2LN, indIndexI2LN, indIndexN, indOffIN, indOffLN, indirectX2P, indOffX2P); + +// All of the memory operands. For the pipeline description. +opclass memory(indirect, indIndexScaled, indIndexScaledI2L, indIndexI2L, indIndex, + indOffI1, indOffL1, indOffI2, indOffL2, indOffI4, indOffL4, indOffI8, indOffL8, + indirectN, indIndexScaledN, indIndexScaledI2LN, indIndexI2LN, indIndexN, indOffIN, indOffLN, indirectX2P, indOffX2P); + // iRegIorL2I is used for src inputs in rules for 32 bit int (I) // operations. it allows the src to be either an iRegI or a (ConvL2I @@ -6212,7 +6434,7 @@ define %{ // Load Instructions // Load Byte (8 bit signed) -instruct loadB(iRegINoSp dst, memory mem) +instruct loadB(iRegINoSp dst, memory1 mem) %{ match(Set dst (LoadB mem)); predicate(!needs_acquiring_load(n)); @@ -6226,7 +6448,7 @@ instruct loadB(iRegINoSp dst, memory mem) %} // Load Byte (8 bit signed) into long -instruct loadB2L(iRegLNoSp dst, memory mem) +instruct loadB2L(iRegLNoSp dst, memory1 mem) %{ match(Set dst (ConvI2L (LoadB mem))); predicate(!needs_acquiring_load(n->in(1))); @@ -6240,7 +6462,7 @@ instruct loadB2L(iRegLNoSp dst, memory mem) %} // Load Byte (8 bit unsigned) -instruct loadUB(iRegINoSp dst, memory mem) +instruct loadUB(iRegINoSp dst, memory1 mem) %{ match(Set dst (LoadUB mem)); predicate(!needs_acquiring_load(n)); @@ -6254,7 +6476,7 @@ instruct loadUB(iRegINoSp dst, memory mem) %} // Load Byte (8 bit unsigned) into long -instruct loadUB2L(iRegLNoSp dst, memory mem) +instruct loadUB2L(iRegLNoSp dst, memory1 mem) %{ match(Set dst (ConvI2L (LoadUB mem))); predicate(!needs_acquiring_load(n->in(1))); @@ -6268,7 +6490,7 @@ instruct loadUB2L(iRegLNoSp dst, memory mem) %} // Load Short (16 bit signed) -instruct loadS(iRegINoSp dst, memory mem) +instruct loadS(iRegINoSp dst, memory2 mem) %{ match(Set dst (LoadS mem)); predicate(!needs_acquiring_load(n)); @@ -6282,7 +6504,7 @@ instruct loadS(iRegINoSp dst, memory mem) %} // Load Short (16 bit signed) into long -instruct loadS2L(iRegLNoSp dst, memory mem) +instruct loadS2L(iRegLNoSp dst, memory2 mem) %{ match(Set dst (ConvI2L (LoadS mem))); predicate(!needs_acquiring_load(n->in(1))); @@ -6296,7 +6518,7 @@ instruct loadS2L(iRegLNoSp dst, memory mem) %} // Load Char (16 bit unsigned) -instruct loadUS(iRegINoSp dst, memory mem) +instruct loadUS(iRegINoSp dst, memory2 mem) %{ match(Set dst (LoadUS mem)); predicate(!needs_acquiring_load(n)); @@ -6310,7 +6532,7 @@ instruct loadUS(iRegINoSp dst, memory mem) %} // Load Short/Char (16 bit unsigned) into long -instruct loadUS2L(iRegLNoSp dst, memory mem) +instruct loadUS2L(iRegLNoSp dst, memory2 mem) %{ match(Set dst (ConvI2L (LoadUS mem))); predicate(!needs_acquiring_load(n->in(1))); @@ -6324,7 +6546,7 @@ instruct loadUS2L(iRegLNoSp dst, memory mem) %} // Load Integer (32 bit signed) -instruct loadI(iRegINoSp dst, memory mem) +instruct loadI(iRegINoSp dst, memory4 mem) %{ match(Set dst (LoadI mem)); predicate(!needs_acquiring_load(n)); @@ -6338,7 +6560,7 @@ instruct loadI(iRegINoSp dst, memory mem) %} // Load Integer (32 bit signed) into long -instruct loadI2L(iRegLNoSp dst, memory mem) +instruct loadI2L(iRegLNoSp dst, memory4 mem) %{ match(Set dst (ConvI2L (LoadI mem))); predicate(!needs_acquiring_load(n->in(1))); @@ -6352,7 +6574,7 @@ instruct loadI2L(iRegLNoSp dst, memory mem) %} // Load Integer (32 bit unsigned) into long -instruct loadUI2L(iRegLNoSp dst, memory mem, immL_32bits mask) +instruct loadUI2L(iRegLNoSp dst, memory4 mem, immL_32bits mask) %{ match(Set dst (AndL (ConvI2L (LoadI mem)) mask)); predicate(!needs_acquiring_load(n->in(1)->in(1)->as_Load())); @@ -6366,7 +6588,7 @@ instruct loadUI2L(iRegLNoSp dst, memory mem, immL_32bits mask) %} // Load Long (64 bit signed) -instruct loadL(iRegLNoSp dst, memory mem) +instruct loadL(iRegLNoSp dst, memory8 mem) %{ match(Set dst (LoadL mem)); predicate(!needs_acquiring_load(n)); @@ -6380,7 +6602,7 @@ instruct loadL(iRegLNoSp dst, memory mem) %} // Load Range -instruct loadRange(iRegINoSp dst, memory mem) +instruct loadRange(iRegINoSp dst, memory4 mem) %{ match(Set dst (LoadRange mem)); @@ -6393,7 +6615,7 @@ instruct loadRange(iRegINoSp dst, memory mem) %} // Load Pointer -instruct loadP(iRegPNoSp dst, memory mem) +instruct loadP(iRegPNoSp dst, memory8 mem) %{ match(Set dst (LoadP mem)); predicate(!needs_acquiring_load(n) && (n->as_Load()->barrier_data() == 0)); @@ -6407,10 +6629,10 @@ instruct loadP(iRegPNoSp dst, memory mem) %} // Load Compressed Pointer -instruct loadN(iRegNNoSp dst, memory mem) +instruct loadN(iRegNNoSp dst, memory4 mem) %{ match(Set dst (LoadN mem)); - predicate(!needs_acquiring_load(n)); + predicate(!needs_acquiring_load(n) && n->as_Load()->barrier_data() == 0); ins_cost(4 * INSN_COST); format %{ "ldrw $dst, $mem\t# compressed ptr" %} @@ -6421,7 +6643,7 @@ instruct loadN(iRegNNoSp dst, memory mem) %} // Load Klass Pointer -instruct loadKlass(iRegPNoSp dst, memory mem) +instruct loadKlass(iRegPNoSp dst, memory8 mem) %{ match(Set dst (LoadKlass mem)); predicate(!needs_acquiring_load(n)); @@ -6435,7 +6657,7 @@ instruct loadKlass(iRegPNoSp dst, memory mem) %} // Load Narrow Klass Pointer -instruct loadNKlass(iRegNNoSp dst, memory mem) +instruct loadNKlass(iRegNNoSp dst, memory4 mem) %{ match(Set dst (LoadNKlass mem)); predicate(!needs_acquiring_load(n)); @@ -6449,7 +6671,7 @@ instruct loadNKlass(iRegNNoSp dst, memory mem) %} // Load Float -instruct loadF(vRegF dst, memory mem) +instruct loadF(vRegF dst, memory4 mem) %{ match(Set dst (LoadF mem)); predicate(!needs_acquiring_load(n)); @@ -6463,7 +6685,7 @@ instruct loadF(vRegF dst, memory mem) %} // Load Double -instruct loadD(vRegD dst, memory mem) +instruct loadD(vRegD dst, memory8 mem) %{ match(Set dst (LoadD mem)); predicate(!needs_acquiring_load(n)); @@ -6666,38 +6888,8 @@ instruct loadConD(vRegD dst, immD con) %{ // Store Instructions -// Store CMS card-mark Immediate -instruct storeimmCM0(immI0 zero, memory mem) -%{ - match(Set mem (StoreCM mem zero)); - - ins_cost(INSN_COST); - format %{ "storestore (elided)\n\t" - "strb zr, $mem\t# byte" %} - - ins_encode(aarch64_enc_strb0(mem)); - - ins_pipe(istore_mem); -%} - -// Store CMS card-mark Immediate with intervening StoreStore -// needed when using CMS with no conditional card marking -instruct storeimmCM0_ordered(immI0 zero, memory mem) -%{ - match(Set mem (StoreCM mem zero)); - - ins_cost(INSN_COST * 2); - format %{ "storestore\n\t" - "dmb ishst" - "\n\tstrb zr, $mem\t# byte" %} - - ins_encode(aarch64_enc_strb0_ordered(mem)); - - ins_pipe(istore_mem); -%} - // Store Byte -instruct storeB(iRegIorL2I src, memory mem) +instruct storeB(iRegIorL2I src, memory1 mem) %{ match(Set mem (StoreB mem src)); predicate(!needs_releasing_store(n)); @@ -6711,7 +6903,7 @@ instruct storeB(iRegIorL2I src, memory mem) %} -instruct storeimmB0(immI0 zero, memory mem) +instruct storeimmB0(immI0 zero, memory1 mem) %{ match(Set mem (StoreB mem zero)); predicate(!needs_releasing_store(n)); @@ -6725,7 +6917,7 @@ instruct storeimmB0(immI0 zero, memory mem) %} // Store Char/Short -instruct storeC(iRegIorL2I src, memory mem) +instruct storeC(iRegIorL2I src, memory2 mem) %{ match(Set mem (StoreC mem src)); predicate(!needs_releasing_store(n)); @@ -6738,7 +6930,7 @@ instruct storeC(iRegIorL2I src, memory mem) ins_pipe(istore_reg_mem); %} -instruct storeimmC0(immI0 zero, memory mem) +instruct storeimmC0(immI0 zero, memory2 mem) %{ match(Set mem (StoreC mem zero)); predicate(!needs_releasing_store(n)); @@ -6753,7 +6945,7 @@ instruct storeimmC0(immI0 zero, memory mem) // Store Integer -instruct storeI(iRegIorL2I src, memory mem) +instruct storeI(iRegIorL2I src, memory4 mem) %{ match(Set mem(StoreI mem src)); predicate(!needs_releasing_store(n)); @@ -6766,7 +6958,7 @@ instruct storeI(iRegIorL2I src, memory mem) ins_pipe(istore_reg_mem); %} -instruct storeimmI0(immI0 zero, memory mem) +instruct storeimmI0(immI0 zero, memory4 mem) %{ match(Set mem(StoreI mem zero)); predicate(!needs_releasing_store(n)); @@ -6780,7 +6972,7 @@ instruct storeimmI0(immI0 zero, memory mem) %} // Store Long (64 bit signed) -instruct storeL(iRegL src, memory mem) +instruct storeL(iRegL src, memory8 mem) %{ match(Set mem (StoreL mem src)); predicate(!needs_releasing_store(n)); @@ -6794,7 +6986,7 @@ instruct storeL(iRegL src, memory mem) %} // Store Long (64 bit signed) -instruct storeimmL0(immL0 zero, memory mem) +instruct storeimmL0(immL0 zero, memory8 mem) %{ match(Set mem (StoreL mem zero)); predicate(!needs_releasing_store(n)); @@ -6808,7 +7000,7 @@ instruct storeimmL0(immL0 zero, memory mem) %} // Store Pointer -instruct storeP(iRegP src, memory mem) +instruct storeP(iRegP src, memory8 mem) %{ match(Set mem (StoreP mem src)); predicate(!needs_releasing_store(n) && n->as_Store()->barrier_data() == 0); @@ -6822,7 +7014,7 @@ instruct storeP(iRegP src, memory mem) %} // Store Pointer -instruct storeimmP0(immP0 zero, memory mem) +instruct storeimmP0(immP0 zero, memory8 mem) %{ match(Set mem (StoreP mem zero)); predicate(!needs_releasing_store(n) && n->as_Store()->barrier_data() == 0); @@ -6836,10 +7028,10 @@ instruct storeimmP0(immP0 zero, memory mem) %} // Store Compressed Pointer -instruct storeN(iRegN src, memory mem) +instruct storeN(iRegN src, memory4 mem) %{ match(Set mem (StoreN mem src)); - predicate(!needs_releasing_store(n)); + predicate(!needs_releasing_store(n) && n->as_Store()->barrier_data() == 0); ins_cost(INSN_COST); format %{ "strw $src, $mem\t# compressed ptr" %} @@ -6849,10 +7041,10 @@ instruct storeN(iRegN src, memory mem) ins_pipe(istore_reg_mem); %} -instruct storeImmN0(immN0 zero, memory mem) +instruct storeImmN0(immN0 zero, memory4 mem) %{ match(Set mem (StoreN mem zero)); - predicate(!needs_releasing_store(n)); + predicate(!needs_releasing_store(n) && n->as_Store()->barrier_data() == 0); ins_cost(INSN_COST); format %{ "strw zr, $mem\t# compressed ptr" %} @@ -6863,7 +7055,7 @@ instruct storeImmN0(immN0 zero, memory mem) %} // Store Float -instruct storeF(vRegF src, memory mem) +instruct storeF(vRegF src, memory4 mem) %{ match(Set mem (StoreF mem src)); predicate(!needs_releasing_store(n)); @@ -6880,7 +7072,7 @@ instruct storeF(vRegF src, memory mem) // implement storeImmF0 and storeFImmPacked // Store Double -instruct storeD(vRegD src, memory mem) +instruct storeD(vRegD src, memory8 mem) %{ match(Set mem (StoreD mem src)); predicate(!needs_releasing_store(n)); @@ -6894,7 +7086,7 @@ instruct storeD(vRegD src, memory mem) %} // Store Compressed Klass Pointer -instruct storeNKlass(iRegN src, memory mem) +instruct storeNKlass(iRegN src, memory4 mem) %{ predicate(!needs_releasing_store(n)); match(Set mem (StoreNKlass mem src)); @@ -6913,7 +7105,7 @@ instruct storeNKlass(iRegN src, memory mem) // prefetch instructions // Must be safe to execute with invalid address (cannot fault). -instruct prefetchalloc( memory mem ) %{ +instruct prefetchalloc( memory8 mem ) %{ match(PrefetchAllocation mem); ins_cost(INSN_COST); @@ -7086,6 +7278,7 @@ instruct loadP_volatile(iRegPNoSp dst, /* sync_memory*/indirect mem) instruct loadN_volatile(iRegNNoSp dst, /* sync_memory*/indirect mem) %{ match(Set dst (LoadN mem)); + predicate(n->as_Load()->barrier_data() == 0); ins_cost(VOLATILE_REF_COST); format %{ "ldarw $dst, $mem\t# compressed ptr" %} @@ -7253,6 +7446,7 @@ instruct storeimmP0_volatile(immP0 zero, /* sync_memory*/indirect mem) instruct storeN_volatile(iRegN src, /* sync_memory*/indirect mem) %{ match(Set mem (StoreN mem src)); + predicate(n->as_Store()->barrier_data() == 0); ins_cost(VOLATILE_REF_COST); format %{ "stlrw $src, $mem\t# compressed ptr" %} @@ -7265,6 +7459,7 @@ instruct storeN_volatile(iRegN src, /* sync_memory*/indirect mem) instruct storeimmN0_volatile(immN0 zero, /* sync_memory*/indirect mem) %{ match(Set mem (StoreN mem zero)); + predicate(n->as_Store()->barrier_data() == 0); ins_cost(VOLATILE_REF_COST); format %{ "stlrw zr, $mem\t# compressed ptr" %} @@ -7482,7 +7677,7 @@ instruct popCountI(iRegINoSp dst, iRegIorL2I src, vRegF tmp) %{ ins_pipe(pipe_class_default); %} -instruct popCountI_mem(iRegINoSp dst, memory mem, vRegF tmp) %{ +instruct popCountI_mem(iRegINoSp dst, memory4 mem, vRegF tmp) %{ match(Set dst (PopCountI (LoadI mem))); effect(TEMP tmp); ins_cost(INSN_COST * 13); @@ -7523,7 +7718,7 @@ instruct popCountL(iRegINoSp dst, iRegL src, vRegD tmp) %{ ins_pipe(pipe_class_default); %} -instruct popCountL_mem(iRegINoSp dst, memory mem, vRegD tmp) %{ +instruct popCountL_mem(iRegINoSp dst, memory8 mem, vRegD tmp) %{ match(Set dst (PopCountL (LoadL mem))); effect(TEMP tmp); ins_cost(INSN_COST * 13); @@ -8061,6 +8256,7 @@ instruct compareAndSwapP(iRegINoSp res, indirect mem, iRegP oldval, iRegP newval instruct compareAndSwapN(iRegINoSp res, indirect mem, iRegNNoSp oldval, iRegNNoSp newval, rFlagsReg cr) %{ match(Set res (CompareAndSwapN mem (Binary oldval newval))); + predicate(n->as_LoadStore()->barrier_data() == 0); ins_cost(2 * VOLATILE_REF_COST); effect(KILL cr); @@ -8175,7 +8371,7 @@ instruct compareAndSwapPAcq(iRegINoSp res, indirect mem, iRegP oldval, iRegP new instruct compareAndSwapNAcq(iRegINoSp res, indirect mem, iRegNNoSp oldval, iRegNNoSp newval, rFlagsReg cr) %{ - predicate(needs_acquiring_load_exclusive(n)); + predicate(needs_acquiring_load_exclusive(n) && n->as_LoadStore()->barrier_data() == 0); match(Set res (CompareAndSwapN mem (Binary oldval newval))); ins_cost(VOLATILE_REF_COST); @@ -8280,6 +8476,7 @@ instruct compareAndExchangeL(iRegLNoSp res, indirect mem, iRegL oldval, iRegL ne // This pattern is generated automatically from cas.m4. // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE instruct compareAndExchangeN(iRegNNoSp res, indirect mem, iRegN oldval, iRegN newval, rFlagsReg cr) %{ + predicate(n->as_LoadStore()->barrier_data() == 0); match(Set res (CompareAndExchangeN mem (Binary oldval newval))); ins_cost(2 * VOLATILE_REF_COST); effect(TEMP_DEF res, KILL cr); @@ -8389,7 +8586,7 @@ instruct compareAndExchangeLAcq(iRegLNoSp res, indirect mem, iRegL oldval, iRegL // This pattern is generated automatically from cas.m4. // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE instruct compareAndExchangeNAcq(iRegNNoSp res, indirect mem, iRegN oldval, iRegN newval, rFlagsReg cr) %{ - predicate(needs_acquiring_load_exclusive(n)); + predicate(needs_acquiring_load_exclusive(n) && n->as_LoadStore()->barrier_data() == 0); match(Set res (CompareAndExchangeN mem (Binary oldval newval))); ins_cost(VOLATILE_REF_COST); effect(TEMP_DEF res, KILL cr); @@ -8501,6 +8698,7 @@ instruct weakCompareAndSwapL(iRegINoSp res, indirect mem, iRegL oldval, iRegL ne // This pattern is generated automatically from cas.m4. // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE instruct weakCompareAndSwapN(iRegINoSp res, indirect mem, iRegN oldval, iRegN newval, rFlagsReg cr) %{ + predicate(n->as_LoadStore()->barrier_data() == 0); match(Set res (WeakCompareAndSwapN mem (Binary oldval newval))); ins_cost(2 * VOLATILE_REF_COST); effect(KILL cr); @@ -8620,7 +8818,7 @@ instruct weakCompareAndSwapLAcq(iRegINoSp res, indirect mem, iRegL oldval, iRegL // This pattern is generated automatically from cas.m4. // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE instruct weakCompareAndSwapNAcq(iRegINoSp res, indirect mem, iRegN oldval, iRegN newval, rFlagsReg cr) %{ - predicate(needs_acquiring_load_exclusive(n)); + predicate(needs_acquiring_load_exclusive(n) && n->as_LoadStore()->barrier_data() == 0); match(Set res (WeakCompareAndSwapN mem (Binary oldval newval))); ins_cost(VOLATILE_REF_COST); effect(KILL cr); @@ -8681,6 +8879,7 @@ instruct get_and_setL(indirect mem, iRegL newv, iRegLNoSp prev) %{ %} instruct get_and_setN(indirect mem, iRegN newv, iRegINoSp prev) %{ + predicate(n->as_LoadStore()->barrier_data() == 0); match(Set prev (GetAndSetN mem newv)); ins_cost(2 * VOLATILE_REF_COST); format %{ "atomic_xchgw $prev, $newv, [$mem]" %} @@ -8724,7 +8923,7 @@ instruct get_and_setLAcq(indirect mem, iRegL newv, iRegLNoSp prev) %{ %} instruct get_and_setNAcq(indirect mem, iRegN newv, iRegINoSp prev) %{ - predicate(needs_acquiring_load_exclusive(n)); + predicate(needs_acquiring_load_exclusive(n) && n->as_LoadStore()->barrier_data() == 0); match(Set prev (GetAndSetN mem newv)); ins_cost(VOLATILE_REF_COST); format %{ "atomic_xchgw_acq $prev, $newv, [$mem]" %} @@ -16672,7 +16871,7 @@ instruct compressBitsI_reg(iRegINoSp dst, iRegIorL2I src, iRegIorL2I mask, ins_pipe(pipe_slow); %} -instruct compressBitsI_memcon(iRegINoSp dst, memory mem, immI mask, +instruct compressBitsI_memcon(iRegINoSp dst, memory4 mem, immI mask, vRegF tdst, vRegF tsrc, vRegF tmask) %{ match(Set dst (CompressBits (LoadI mem) mask)); effect(TEMP tdst, TEMP tsrc, TEMP tmask); @@ -16709,7 +16908,7 @@ instruct compressBitsL_reg(iRegLNoSp dst, iRegL src, iRegL mask, ins_pipe(pipe_slow); %} -instruct compressBitsL_memcon(iRegLNoSp dst, memory mem, immL mask, +instruct compressBitsL_memcon(iRegLNoSp dst, memory8 mem, immL mask, vRegF tdst, vRegF tsrc, vRegF tmask) %{ match(Set dst (CompressBits (LoadL mem) mask)); effect(TEMP tdst, TEMP tsrc, TEMP tmask); @@ -16746,7 +16945,7 @@ instruct expandBitsI_reg(iRegINoSp dst, iRegIorL2I src, iRegIorL2I mask, ins_pipe(pipe_slow); %} -instruct expandBitsI_memcon(iRegINoSp dst, memory mem, immI mask, +instruct expandBitsI_memcon(iRegINoSp dst, memory4 mem, immI mask, vRegF tdst, vRegF tsrc, vRegF tmask) %{ match(Set dst (ExpandBits (LoadI mem) mask)); effect(TEMP tdst, TEMP tsrc, TEMP tmask); @@ -16784,7 +16983,7 @@ instruct expandBitsL_reg(iRegLNoSp dst, iRegL src, iRegL mask, %} -instruct expandBitsL_memcon(iRegINoSp dst, memory mem, immL mask, +instruct expandBitsL_memcon(iRegINoSp dst, memory8 mem, immL mask, vRegF tdst, vRegF tsrc, vRegF tmask) %{ match(Set dst (ExpandBits (LoadL mem) mask)); effect(TEMP tdst, TEMP tsrc, TEMP tmask); diff --git a/src/hotspot/cpu/aarch64/aarch64_vector.ad b/src/hotspot/cpu/aarch64/aarch64_vector.ad index cdbc4103df8..0d3a240cecf 100644 --- a/src/hotspot/cpu/aarch64/aarch64_vector.ad +++ b/src/hotspot/cpu/aarch64/aarch64_vector.ad @@ -345,7 +345,7 @@ source %{ // ------------------------------ Vector load/store ---------------------------- // Load Vector (16 bits) -instruct loadV2(vReg dst, vmem mem) %{ +instruct loadV2(vReg dst, vmem2 mem) %{ predicate(n->as_LoadVector()->memory_size() == 2); match(Set dst (LoadVector mem)); format %{ "loadV2 $dst, $mem\t# vector (16 bits)" %} @@ -354,7 +354,7 @@ instruct loadV2(vReg dst, vmem mem) %{ %} // Store Vector (16 bits) -instruct storeV2(vReg src, vmem mem) %{ +instruct storeV2(vReg src, vmem2 mem) %{ predicate(n->as_StoreVector()->memory_size() == 2); match(Set mem (StoreVector mem src)); format %{ "storeV2 $mem, $src\t# vector (16 bits)" %} @@ -363,7 +363,7 @@ instruct storeV2(vReg src, vmem mem) %{ %} // Load Vector (32 bits) -instruct loadV4(vReg dst, vmem mem) %{ +instruct loadV4(vReg dst, vmem4 mem) %{ predicate(n->as_LoadVector()->memory_size() == 4); match(Set dst (LoadVector mem)); format %{ "loadV4 $dst, $mem\t# vector (32 bits)" %} @@ -372,7 +372,7 @@ instruct loadV4(vReg dst, vmem mem) %{ %} // Store Vector (32 bits) -instruct storeV4(vReg src, vmem mem) %{ +instruct storeV4(vReg src, vmem4 mem) %{ predicate(n->as_StoreVector()->memory_size() == 4); match(Set mem (StoreVector mem src)); format %{ "storeV4 $mem, $src\t# vector (32 bits)" %} @@ -381,7 +381,7 @@ instruct storeV4(vReg src, vmem mem) %{ %} // Load Vector (64 bits) -instruct loadV8(vReg dst, vmem mem) %{ +instruct loadV8(vReg dst, vmem8 mem) %{ predicate(n->as_LoadVector()->memory_size() == 8); match(Set dst (LoadVector mem)); format %{ "loadV8 $dst, $mem\t# vector (64 bits)" %} @@ -390,7 +390,7 @@ instruct loadV8(vReg dst, vmem mem) %{ %} // Store Vector (64 bits) -instruct storeV8(vReg src, vmem mem) %{ +instruct storeV8(vReg src, vmem8 mem) %{ predicate(n->as_StoreVector()->memory_size() == 8); match(Set mem (StoreVector mem src)); format %{ "storeV8 $mem, $src\t# vector (64 bits)" %} @@ -399,7 +399,7 @@ instruct storeV8(vReg src, vmem mem) %{ %} // Load Vector (128 bits) -instruct loadV16(vReg dst, vmem mem) %{ +instruct loadV16(vReg dst, vmem16 mem) %{ predicate(n->as_LoadVector()->memory_size() == 16); match(Set dst (LoadVector mem)); format %{ "loadV16 $dst, $mem\t# vector (128 bits)" %} @@ -408,7 +408,7 @@ instruct loadV16(vReg dst, vmem mem) %{ %} // Store Vector (128 bits) -instruct storeV16(vReg src, vmem mem) %{ +instruct storeV16(vReg src, vmem16 mem) %{ predicate(n->as_StoreVector()->memory_size() == 16); match(Set mem (StoreVector mem src)); format %{ "storeV16 $mem, $src\t# vector (128 bits)" %} diff --git a/src/hotspot/cpu/aarch64/aarch64_vector_ad.m4 b/src/hotspot/cpu/aarch64/aarch64_vector_ad.m4 index 020a75b51fa..99708e9ef31 100644 --- a/src/hotspot/cpu/aarch64/aarch64_vector_ad.m4 +++ b/src/hotspot/cpu/aarch64/aarch64_vector_ad.m4 @@ -338,7 +338,7 @@ dnl VECTOR_LOAD_STORE($1, $2, $3, $4, $5 ) dnl VECTOR_LOAD_STORE(type, nbytes, arg_name, nbits, size) define(`VECTOR_LOAD_STORE', ` // ifelse(load, $1, Load, Store) Vector ($4 bits) -instruct $1V$2(vReg $3, vmem mem) %{ +instruct $1V$2(vReg $3, vmem$2 mem) %{ predicate(`n->as_'ifelse(load, $1, Load, Store)Vector()->memory_size() == $2); match(Set ifelse(load, $1, dst (LoadVector mem), mem (StoreVector mem src))); format %{ "$1V$2 ifelse(load, $1, `$dst, $mem', `$mem, $src')\t# vector ($4 bits)" %} diff --git a/src/hotspot/cpu/aarch64/ad_encode.m4 b/src/hotspot/cpu/aarch64/ad_encode.m4 index e3d8ea661b6..008dbd2c936 100644 --- a/src/hotspot/cpu/aarch64/ad_encode.m4 +++ b/src/hotspot/cpu/aarch64/ad_encode.m4 @@ -34,7 +34,7 @@ define(access, ` define(load,` // This encoding class is generated automatically from ad_encode.m4. // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE - enc_class aarch64_enc_$2($1 dst, memory mem) %{dnl + enc_class aarch64_enc_$2($1 dst, memory$5 mem) %{dnl access(dst,$2,$3,$4,$5)')dnl load(iRegI,ldrsbw,,,1) load(iRegI,ldrsb,,,1) @@ -53,12 +53,12 @@ load(vRegD,ldrd,Float,,8) define(STORE,` // This encoding class is generated automatically from ad_encode.m4. // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE - enc_class aarch64_enc_$2($1 src, memory mem) %{dnl + enc_class aarch64_enc_$2($1 src, memory$5 mem) %{dnl access(src,$2,$3,$4,$5)')dnl define(STORE0,` // This encoding class is generated automatically from ad_encode.m4. // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE - enc_class aarch64_enc_$2`'0(memory mem) %{ + enc_class aarch64_enc_$2`'0(memory$4 mem) %{ choose(masm,zr,$2,$mem->opcode(), as_$3Register($mem$$base),$mem$$index,$mem$$scale,$mem$$disp,$4)')dnl STORE(iRegI,strb,,,1) @@ -82,7 +82,7 @@ STORE(vRegD,strd,Float,,8) // This encoding class is generated automatically from ad_encode.m4. // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE - enc_class aarch64_enc_strb0_ordered(memory mem) %{ + enc_class aarch64_enc_strb0_ordered(memory4 mem) %{ __ membar(Assembler::StoreStore); loadStore(masm, &MacroAssembler::strb, zr, $mem->opcode(), as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp, 1); diff --git a/src/hotspot/cpu/aarch64/c1_CodeStubs_aarch64.cpp b/src/hotspot/cpu/aarch64/c1_CodeStubs_aarch64.cpp index ca175fe1c47..89a97a4984f 100644 --- a/src/hotspot/cpu/aarch64/c1_CodeStubs_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/c1_CodeStubs_aarch64.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -57,7 +57,7 @@ void CounterOverflowStub::emit_code(LIR_Assembler* ce) { __ mov_metadata(rscratch1, m); ce->store_parameter(rscratch1, 1); ce->store_parameter(_bci, 0); - __ far_call(RuntimeAddress(Runtime1::entry_for(Runtime1::counter_overflow_id))); + __ far_call(RuntimeAddress(Runtime1::entry_for(C1StubId::counter_overflow_id))); ce->add_call_info_here(_info); ce->verify_oop_map(_info); __ b(_continuation); @@ -66,7 +66,7 @@ void CounterOverflowStub::emit_code(LIR_Assembler* ce) { void RangeCheckStub::emit_code(LIR_Assembler* ce) { __ bind(_entry); if (_info->deoptimize_on_exception()) { - address a = Runtime1::entry_for(Runtime1::predicate_failed_trap_id); + address a = Runtime1::entry_for(C1StubId::predicate_failed_trap_id); __ far_call(RuntimeAddress(a)); ce->add_call_info_here(_info); ce->verify_oop_map(_info); @@ -79,13 +79,13 @@ void RangeCheckStub::emit_code(LIR_Assembler* ce) { } else { __ mov(rscratch1, _index->as_jint()); } - Runtime1::StubID stub_id; + C1StubId stub_id; if (_throw_index_out_of_bounds_exception) { - stub_id = Runtime1::throw_index_exception_id; + stub_id = C1StubId::throw_index_exception_id; } else { assert(_array != LIR_Opr::nullOpr(), "sanity"); __ mov(rscratch2, _array->as_pointer_register()); - stub_id = Runtime1::throw_range_check_failed_id; + stub_id = C1StubId::throw_range_check_failed_id; } __ lea(lr, RuntimeAddress(Runtime1::entry_for(stub_id))); __ blr(lr); @@ -100,7 +100,7 @@ PredicateFailedStub::PredicateFailedStub(CodeEmitInfo* info) { void PredicateFailedStub::emit_code(LIR_Assembler* ce) { __ bind(_entry); - address a = Runtime1::entry_for(Runtime1::predicate_failed_trap_id); + address a = Runtime1::entry_for(C1StubId::predicate_failed_trap_id); __ far_call(RuntimeAddress(a)); ce->add_call_info_here(_info); ce->verify_oop_map(_info); @@ -112,7 +112,7 @@ void DivByZeroStub::emit_code(LIR_Assembler* ce) { ce->compilation()->implicit_exception_table()->append(_offset, __ offset()); } __ bind(_entry); - __ far_call(RuntimeAddress(Runtime1::entry_for(Runtime1::throw_div0_exception_id))); + __ far_call(RuntimeAddress(Runtime1::entry_for(C1StubId::throw_div0_exception_id))); ce->add_call_info_here(_info); ce->verify_oop_map(_info); #ifdef ASSERT @@ -124,14 +124,14 @@ void DivByZeroStub::emit_code(LIR_Assembler* ce) { // Implementation of NewInstanceStub -NewInstanceStub::NewInstanceStub(LIR_Opr klass_reg, LIR_Opr result, ciInstanceKlass* klass, CodeEmitInfo* info, Runtime1::StubID stub_id) { +NewInstanceStub::NewInstanceStub(LIR_Opr klass_reg, LIR_Opr result, ciInstanceKlass* klass, CodeEmitInfo* info, C1StubId stub_id) { _result = result; _klass = klass; _klass_reg = klass_reg; _info = new CodeEmitInfo(info); - assert(stub_id == Runtime1::new_instance_id || - stub_id == Runtime1::fast_new_instance_id || - stub_id == Runtime1::fast_new_instance_init_check_id, + assert(stub_id == C1StubId::new_instance_id || + stub_id == C1StubId::fast_new_instance_id || + stub_id == C1StubId::fast_new_instance_init_check_id, "need new_instance id"); _stub_id = stub_id; } @@ -167,7 +167,7 @@ void NewTypeArrayStub::emit_code(LIR_Assembler* ce) { __ bind(_entry); assert(_length->as_register() == r19, "length must in r19,"); assert(_klass_reg->as_register() == r3, "klass_reg must in r3"); - __ far_call(RuntimeAddress(Runtime1::entry_for(Runtime1::new_type_array_id))); + __ far_call(RuntimeAddress(Runtime1::entry_for(C1StubId::new_type_array_id))); ce->add_call_info_here(_info); ce->verify_oop_map(_info); assert(_result->as_register() == r0, "result must in r0"); @@ -190,7 +190,7 @@ void NewObjectArrayStub::emit_code(LIR_Assembler* ce) { __ bind(_entry); assert(_length->as_register() == r19, "length must in r19,"); assert(_klass_reg->as_register() == r3, "klass_reg must in r3"); - __ far_call(RuntimeAddress(Runtime1::entry_for(Runtime1::new_object_array_id))); + __ far_call(RuntimeAddress(Runtime1::entry_for(C1StubId::new_object_array_id))); ce->add_call_info_here(_info); ce->verify_oop_map(_info); assert(_result->as_register() == r0, "result must in r0"); @@ -202,11 +202,11 @@ void MonitorEnterStub::emit_code(LIR_Assembler* ce) { __ bind(_entry); ce->store_parameter(_obj_reg->as_register(), 1); ce->store_parameter(_lock_reg->as_register(), 0); - Runtime1::StubID enter_id; + C1StubId enter_id; if (ce->compilation()->has_fpu_code()) { - enter_id = Runtime1::monitorenter_id; + enter_id = C1StubId::monitorenter_id; } else { - enter_id = Runtime1::monitorenter_nofpu_id; + enter_id = C1StubId::monitorenter_nofpu_id; } __ far_call(RuntimeAddress(Runtime1::entry_for(enter_id))); ce->add_call_info_here(_info); @@ -223,11 +223,11 @@ void MonitorExitStub::emit_code(LIR_Assembler* ce) { } ce->store_parameter(_lock_reg->as_register(), 0); // note: non-blocking leaf routine => no call info needed - Runtime1::StubID exit_id; + C1StubId exit_id; if (ce->compilation()->has_fpu_code()) { - exit_id = Runtime1::monitorexit_id; + exit_id = C1StubId::monitorexit_id; } else { - exit_id = Runtime1::monitorexit_nofpu_id; + exit_id = C1StubId::monitorexit_nofpu_id; } __ adr(lr, _continuation); __ far_jump(RuntimeAddress(Runtime1::entry_for(exit_id))); @@ -255,7 +255,7 @@ void PatchingStub::emit_code(LIR_Assembler* ce) { void DeoptimizeStub::emit_code(LIR_Assembler* ce) { __ bind(_entry); ce->store_parameter(_trap_request, 0); - __ far_call(RuntimeAddress(Runtime1::entry_for(Runtime1::deoptimize_id))); + __ far_call(RuntimeAddress(Runtime1::entry_for(C1StubId::deoptimize_id))); ce->add_call_info_here(_info); DEBUG_ONLY(__ should_not_reach_here()); } @@ -265,9 +265,9 @@ void ImplicitNullCheckStub::emit_code(LIR_Assembler* ce) { address a; if (_info->deoptimize_on_exception()) { // Deoptimize, do not throw the exception, because it is probably wrong to do it here. - a = Runtime1::entry_for(Runtime1::predicate_failed_trap_id); + a = Runtime1::entry_for(C1StubId::predicate_failed_trap_id); } else { - a = Runtime1::entry_for(Runtime1::throw_null_pointer_exception_id); + a = Runtime1::entry_for(C1StubId::throw_null_pointer_exception_id); } ce->compilation()->implicit_exception_table()->append(_offset, __ offset()); diff --git a/src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.cpp b/src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.cpp index 91430be5835..1385366d879 100644 --- a/src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.cpp @@ -321,19 +321,19 @@ void LIR_Assembler::deoptimize_trap(CodeEmitInfo *info) { switch (patching_id(info)) { case PatchingStub::access_field_id: - target = Runtime1::entry_for(Runtime1::access_field_patching_id); + target = Runtime1::entry_for(C1StubId::access_field_patching_id); reloc_type = relocInfo::section_word_type; break; case PatchingStub::load_klass_id: - target = Runtime1::entry_for(Runtime1::load_klass_patching_id); + target = Runtime1::entry_for(C1StubId::load_klass_patching_id); reloc_type = relocInfo::metadata_type; break; case PatchingStub::load_mirror_id: - target = Runtime1::entry_for(Runtime1::load_mirror_patching_id); + target = Runtime1::entry_for(C1StubId::load_mirror_patching_id); reloc_type = relocInfo::oop_type; break; case PatchingStub::load_appendix_id: - target = Runtime1::entry_for(Runtime1::load_appendix_patching_id); + target = Runtime1::entry_for(C1StubId::load_appendix_patching_id); reloc_type = relocInfo::oop_type; break; default: ShouldNotReachHere(); @@ -375,7 +375,7 @@ int LIR_Assembler::emit_exception_handler() { __ verify_not_null_oop(r0); // search an exception handler (r0: exception oop, r3: throwing pc) - __ far_call(RuntimeAddress(Runtime1::entry_for(Runtime1::handle_exception_from_callee_id))); + __ far_call(RuntimeAddress(Runtime1::entry_for(C1StubId::handle_exception_from_callee_id))); __ should_not_reach_here(); guarantee(code_offset() - offset <= exception_handler_size(), "overflow"); __ end_a_stub(); @@ -432,7 +432,7 @@ int LIR_Assembler::emit_unwind_handler() { // remove the activation and dispatch to the unwind handler __ block_comment("remove_frame and dispatch to the unwind handler"); __ remove_frame(initial_frame_size_in_bytes()); - __ far_jump(RuntimeAddress(Runtime1::entry_for(Runtime1::unwind_exception_id))); + __ far_jump(RuntimeAddress(Runtime1::entry_for(C1StubId::unwind_exception_id))); // Emit the slow path assembly if (stub != nullptr) { @@ -875,19 +875,19 @@ void LIR_Assembler::klass2reg_with_patching(Register reg, CodeEmitInfo* info) { switch (patching_id(info)) { case PatchingStub::access_field_id: - target = Runtime1::entry_for(Runtime1::access_field_patching_id); + target = Runtime1::entry_for(C1StubId::access_field_patching_id); reloc_type = relocInfo::section_word_type; break; case PatchingStub::load_klass_id: - target = Runtime1::entry_for(Runtime1::load_klass_patching_id); + target = Runtime1::entry_for(C1StubId::load_klass_patching_id); reloc_type = relocInfo::metadata_type; break; case PatchingStub::load_mirror_id: - target = Runtime1::entry_for(Runtime1::load_mirror_patching_id); + target = Runtime1::entry_for(C1StubId::load_mirror_patching_id); reloc_type = relocInfo::oop_type; break; case PatchingStub::load_appendix_id: - target = Runtime1::entry_for(Runtime1::load_appendix_patching_id); + target = Runtime1::entry_for(C1StubId::load_appendix_patching_id); reloc_type = relocInfo::oop_type; break; default: ShouldNotReachHere(); @@ -1168,8 +1168,8 @@ void LIR_Assembler::emit_opConvert(LIR_OpConvert* op) { void LIR_Assembler::emit_alloc_obj(LIR_OpAllocObj* op) { if (op->init_check()) { - __ ldrb(rscratch1, Address(op->klass()->as_register(), - InstanceKlass::init_state_offset())); + __ lea(rscratch1, Address(op->klass()->as_register(), InstanceKlass::init_state_offset())); + __ ldarb(rscratch1, rscratch1); __ cmpw(rscratch1, InstanceKlass::fully_initialized); add_debug_info_for_null_check_here(op->stub()->info()); __ br(Assembler::NE, *op->stub()->entry()); @@ -1356,7 +1356,7 @@ void LIR_Assembler::emit_typecheck_helper(LIR_OpTypeCheck *op, Label* success, L __ br(Assembler::EQ, *success_target); __ stp(klass_RInfo, k_RInfo, Address(__ pre(sp, -2 * wordSize))); - __ far_call(RuntimeAddress(Runtime1::entry_for(Runtime1::slow_subtype_check_id))); + __ far_call(RuntimeAddress(Runtime1::entry_for(C1StubId::slow_subtype_check_id))); __ ldr(klass_RInfo, Address(__ post(sp, 2 * wordSize))); // result is a boolean __ cbzw(klass_RInfo, *failure_target); @@ -1367,7 +1367,7 @@ void LIR_Assembler::emit_typecheck_helper(LIR_OpTypeCheck *op, Label* success, L __ check_klass_subtype_fast_path(klass_RInfo, k_RInfo, Rtmp1, success_target, failure_target, nullptr); // call out-of-line instance of __ check_klass_subtype_slow_path(...): __ stp(klass_RInfo, k_RInfo, Address(__ pre(sp, -2 * wordSize))); - __ far_call(RuntimeAddress(Runtime1::entry_for(Runtime1::slow_subtype_check_id))); + __ far_call(RuntimeAddress(Runtime1::entry_for(C1StubId::slow_subtype_check_id))); __ ldp(k_RInfo, klass_RInfo, Address(__ post(sp, 2 * wordSize))); // result is a boolean __ cbz(k_RInfo, *failure_target); @@ -1446,7 +1446,7 @@ void LIR_Assembler::emit_opTypeCheck(LIR_OpTypeCheck* op) { __ check_klass_subtype_fast_path(klass_RInfo, k_RInfo, Rtmp1, success_target, failure_target, nullptr); // call out-of-line instance of __ check_klass_subtype_slow_path(...): __ stp(klass_RInfo, k_RInfo, Address(__ pre(sp, -2 * wordSize))); - __ far_call(RuntimeAddress(Runtime1::entry_for(Runtime1::slow_subtype_check_id))); + __ far_call(RuntimeAddress(Runtime1::entry_for(C1StubId::slow_subtype_check_id))); __ ldp(k_RInfo, klass_RInfo, Address(__ post(sp, 2 * wordSize))); // result is a boolean __ cbzw(k_RInfo, *failure_target); @@ -2035,7 +2035,7 @@ void LIR_Assembler::throw_op(LIR_Opr exceptionPC, LIR_Opr exceptionOop, CodeEmit // exception object is not added to oop map by LinearScan // (LinearScan assumes that no oops are in fixed registers) info->add_register_oop(exceptionOop); - Runtime1::StubID unwind_id; + C1StubId unwind_id; // get current pc information // pc is only needed if the method has an exception handler, the unwind code does not need it. @@ -2054,9 +2054,9 @@ void LIR_Assembler::throw_op(LIR_Opr exceptionPC, LIR_Opr exceptionOop, CodeEmit __ verify_not_null_oop(r0); // search an exception handler (r0: exception oop, r3: throwing pc) if (compilation()->has_fpu_code()) { - unwind_id = Runtime1::handle_exception_id; + unwind_id = C1StubId::handle_exception_id; } else { - unwind_id = Runtime1::handle_exception_nofpu_id; + unwind_id = C1StubId::handle_exception_nofpu_id; } __ far_call(RuntimeAddress(Runtime1::entry_for(unwind_id))); @@ -2337,7 +2337,7 @@ void LIR_Assembler::emit_arraycopy(LIR_OpArrayCopy* op) { __ check_klass_subtype_fast_path(src, dst, tmp, &cont, &slow, nullptr); __ PUSH(src, dst); - __ far_call(RuntimeAddress(Runtime1::entry_for(Runtime1::slow_subtype_check_id))); + __ far_call(RuntimeAddress(Runtime1::entry_for(C1StubId::slow_subtype_check_id))); __ POP(src, dst); __ cbnz(src, cont); diff --git a/src/hotspot/cpu/aarch64/c1_LIRGenerator_aarch64.cpp b/src/hotspot/cpu/aarch64/c1_LIRGenerator_aarch64.cpp index 8f1260feba3..4acac65ad5b 100644 --- a/src/hotspot/cpu/aarch64/c1_LIRGenerator_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/c1_LIRGenerator_aarch64.cpp @@ -1246,7 +1246,7 @@ void LIRGenerator::do_NewMultiArray(NewMultiArray* x) { args->append(rank); args->append(varargs); LIR_Opr reg = result_register_for(x->type()); - __ call_runtime(Runtime1::entry_for(Runtime1::new_multi_array_id), + __ call_runtime(Runtime1::entry_for(C1StubId::new_multi_array_id), LIR_OprFact::illegalOpr, reg, args, info); @@ -1277,14 +1277,14 @@ void LIRGenerator::do_CheckCast(CheckCast* x) { CodeStub* stub; if (x->is_incompatible_class_change_check()) { assert(patching_info == nullptr, "can't patch this"); - stub = new SimpleExceptionStub(Runtime1::throw_incompatible_class_change_error_id, LIR_OprFact::illegalOpr, info_for_exception); + stub = new SimpleExceptionStub(C1StubId::throw_incompatible_class_change_error_id, LIR_OprFact::illegalOpr, info_for_exception); } else if (x->is_invokespecial_receiver_check()) { assert(patching_info == nullptr, "can't patch this"); stub = new DeoptimizeStub(info_for_exception, Deoptimization::Reason_class_check, Deoptimization::Action_none); } else { - stub = new SimpleExceptionStub(Runtime1::throw_class_cast_exception_id, obj.result(), info_for_exception); + stub = new SimpleExceptionStub(C1StubId::throw_class_cast_exception_id, obj.result(), info_for_exception); } LIR_Opr reg = rlock_result(x); LIR_Opr tmp3 = LIR_OprFact::illegalOpr; diff --git a/src/hotspot/cpu/aarch64/c1_MacroAssembler_aarch64.cpp b/src/hotspot/cpu/aarch64/c1_MacroAssembler_aarch64.cpp index 89624aeffdd..8d1b3902ce4 100644 --- a/src/hotspot/cpu/aarch64/c1_MacroAssembler_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/c1_MacroAssembler_aarch64.cpp @@ -75,8 +75,8 @@ int C1_MacroAssembler::lock_object(Register hdr, Register obj, Register disp_hdr if (DiagnoseSyncOnValueBasedClasses != 0) { load_klass(hdr, obj); - ldrw(hdr, Address(hdr, Klass::access_flags_offset())); - tstw(hdr, JVM_ACC_IS_VALUE_BASED_CLASS); + ldrb(hdr, Address(hdr, Klass::misc_flags_offset())); + tst(hdr, KlassFlags::_misc_is_value_based_class); br(Assembler::NE, slow_case); } @@ -267,7 +267,7 @@ void C1_MacroAssembler::initialize_object(Register obj, Register klass, Register if (CURRENT_ENV->dtrace_alloc_probes()) { assert(obj == r0, "must be"); - far_call(RuntimeAddress(Runtime1::entry_for(Runtime1::dtrace_object_alloc_id))); + far_call(RuntimeAddress(Runtime1::entry_for(C1StubId::dtrace_object_alloc_id))); } verify_oop(obj); @@ -308,7 +308,7 @@ void C1_MacroAssembler::allocate_array(Register obj, Register len, Register t1, if (CURRENT_ENV->dtrace_alloc_probes()) { assert(obj == r0, "must be"); - far_call(RuntimeAddress(Runtime1::entry_for(Runtime1::dtrace_object_alloc_id))); + far_call(RuntimeAddress(Runtime1::entry_for(C1StubId::dtrace_object_alloc_id))); } verify_oop(obj); diff --git a/src/hotspot/cpu/aarch64/c1_Runtime1_aarch64.cpp b/src/hotspot/cpu/aarch64/c1_Runtime1_aarch64.cpp index 780055a611f..0b9acc0f3a8 100644 --- a/src/hotspot/cpu/aarch64/c1_Runtime1_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/c1_Runtime1_aarch64.cpp @@ -100,10 +100,10 @@ int StubAssembler::call_RT(Register oop_result1, Register metadata_result, addre if (frame_size() == no_frame_size) { leave(); far_jump(RuntimeAddress(StubRoutines::forward_exception_entry())); - } else if (_stub_id == Runtime1::forward_exception_id) { + } else if (_stub_id == (int)C1StubId::forward_exception_id) { should_not_reach_here(); } else { - far_jump(RuntimeAddress(Runtime1::entry_for(Runtime1::forward_exception_id))); + far_jump(RuntimeAddress(Runtime1::entry_for(C1StubId::forward_exception_id))); } bind(L); } @@ -358,7 +358,7 @@ OopMapSet* Runtime1::generate_exception_throw(StubAssembler* sasm, address targe } -OopMapSet* Runtime1::generate_handle_exception(StubID id, StubAssembler *sasm) { +OopMapSet* Runtime1::generate_handle_exception(C1StubId id, StubAssembler *sasm) { __ block_comment("generate_handle_exception"); // incoming parameters @@ -370,7 +370,7 @@ OopMapSet* Runtime1::generate_handle_exception(StubID id, StubAssembler *sasm) { OopMapSet* oop_maps = new OopMapSet(); OopMap* oop_map = nullptr; switch (id) { - case forward_exception_id: + case C1StubId::forward_exception_id: // We're handling an exception in the context of a compiled frame. // The registers have been saved in the standard places. Perform // an exception lookup in the caller and dispatch to the handler @@ -390,12 +390,12 @@ OopMapSet* Runtime1::generate_handle_exception(StubID id, StubAssembler *sasm) { __ str(zr, Address(rthread, JavaThread::vm_result_offset())); __ str(zr, Address(rthread, JavaThread::vm_result_2_offset())); break; - case handle_exception_nofpu_id: - case handle_exception_id: + case C1StubId::handle_exception_nofpu_id: + case C1StubId::handle_exception_id: // At this point all registers MAY be live. - oop_map = save_live_registers(sasm, id != handle_exception_nofpu_id); + oop_map = save_live_registers(sasm, id != C1StubId::handle_exception_nofpu_id); break; - case handle_exception_from_callee_id: { + case C1StubId::handle_exception_from_callee_id: { // At this point all registers except exception oop (r0) and // exception pc (lr) are dead. const int frame_size = 2 /*fp, return address*/; @@ -453,13 +453,13 @@ OopMapSet* Runtime1::generate_handle_exception(StubID id, StubAssembler *sasm) { __ str(r0, Address(rfp, 1*BytesPerWord)); switch (id) { - case forward_exception_id: - case handle_exception_nofpu_id: - case handle_exception_id: + case C1StubId::forward_exception_id: + case C1StubId::handle_exception_nofpu_id: + case C1StubId::handle_exception_id: // Restore the registers that were saved at the beginning. - restore_live_registers(sasm, id != handle_exception_nofpu_id); + restore_live_registers(sasm, id != C1StubId::handle_exception_nofpu_id); break; - case handle_exception_from_callee_id: + case C1StubId::handle_exception_from_callee_id: break; default: ShouldNotReachHere(); } @@ -611,7 +611,7 @@ OopMapSet* Runtime1::generate_patching(StubAssembler* sasm, address target) { } -OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { +OopMapSet* Runtime1::generate_code_for(C1StubId id, StubAssembler* sasm) { const Register exception_oop = r0; const Register exception_pc = r3; @@ -628,7 +628,7 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { OopMap* oop_map = nullptr; switch (id) { { - case forward_exception_id: + case C1StubId::forward_exception_id: { oop_maps = generate_handle_exception(id, sasm); __ leave(); @@ -636,31 +636,31 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case throw_div0_exception_id: + case C1StubId::throw_div0_exception_id: { StubFrame f(sasm, "throw_div0_exception", dont_gc_arguments, does_not_return); oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_div0_exception), false); } break; - case throw_null_pointer_exception_id: + case C1StubId::throw_null_pointer_exception_id: { StubFrame f(sasm, "throw_null_pointer_exception", dont_gc_arguments, does_not_return); oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_null_pointer_exception), false); } break; - case new_instance_id: - case fast_new_instance_id: - case fast_new_instance_init_check_id: + case C1StubId::new_instance_id: + case C1StubId::fast_new_instance_id: + case C1StubId::fast_new_instance_init_check_id: { Register klass = r3; // Incoming Register obj = r0; // Result - if (id == new_instance_id) { + if (id == C1StubId::new_instance_id) { __ set_info("new_instance", dont_gc_arguments); - } else if (id == fast_new_instance_id) { + } else if (id == C1StubId::fast_new_instance_id) { __ set_info("fast new_instance", dont_gc_arguments); } else { - assert(id == fast_new_instance_init_check_id, "bad StubID"); + assert(id == C1StubId::fast_new_instance_init_check_id, "bad C1StubId"); __ set_info("fast new_instance init check", dont_gc_arguments); } @@ -679,7 +679,7 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { break; - case counter_overflow_id: + case C1StubId::counter_overflow_id: { Register bci = r0, method = r1; __ enter(); @@ -697,14 +697,14 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case new_type_array_id: - case new_object_array_id: + case C1StubId::new_type_array_id: + case C1StubId::new_object_array_id: { Register length = r19; // Incoming Register klass = r3; // Incoming Register obj = r0; // Result - if (id == new_type_array_id) { + if (id == C1StubId::new_type_array_id) { __ set_info("new_type_array", dont_gc_arguments); } else { __ set_info("new_object_array", dont_gc_arguments); @@ -717,7 +717,7 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { Register t0 = obj; __ ldrw(t0, Address(klass, Klass::layout_helper_offset())); __ asrw(t0, t0, Klass::_lh_array_tag_shift); - int tag = ((id == new_type_array_id) + int tag = ((id == C1StubId::new_type_array_id) ? Klass::_lh_array_tag_type_value : Klass::_lh_array_tag_obj_value); __ mov(rscratch1, tag); @@ -732,7 +732,7 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { __ enter(); OopMap* map = save_live_registers(sasm); int call_offset; - if (id == new_type_array_id) { + if (id == C1StubId::new_type_array_id) { call_offset = __ call_RT(obj, noreg, CAST_FROM_FN_PTR(address, new_type_array), klass, length); } else { call_offset = __ call_RT(obj, noreg, CAST_FROM_FN_PTR(address, new_object_array), klass, length); @@ -750,7 +750,7 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case new_multi_array_id: + case C1StubId::new_multi_array_id: { StubFrame f(sasm, "new_multi_array", dont_gc_arguments); // r0,: klass // r19,: rank @@ -770,7 +770,7 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case register_finalizer_id: + case C1StubId::register_finalizer_id: { __ set_info("register_finalizer", dont_gc_arguments); @@ -783,8 +783,8 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { Label register_finalizer; Register t = r5; __ load_klass(t, r0); - __ ldrw(t, Address(t, Klass::access_flags_offset())); - __ tbnz(t, exact_log2(JVM_ACC_HAS_FINALIZER), register_finalizer); + __ ldrb(t, Address(t, Klass::misc_flags_offset())); + __ tbnz(t, exact_log2(KlassFlags::_misc_has_finalizer), register_finalizer); __ ret(lr); __ bind(register_finalizer); @@ -802,19 +802,19 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case throw_class_cast_exception_id: + case C1StubId::throw_class_cast_exception_id: { StubFrame f(sasm, "throw_class_cast_exception", dont_gc_arguments, does_not_return); oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_class_cast_exception), true); } break; - case throw_incompatible_class_change_error_id: + case C1StubId::throw_incompatible_class_change_error_id: { StubFrame f(sasm, "throw_incompatible_class_cast_exception", dont_gc_arguments, does_not_return); oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_incompatible_class_change_error), false); } break; - case slow_subtype_check_id: + case C1StubId::slow_subtype_check_id: { // Typical calling sequence: // __ push(klass_RInfo); // object klass or other subclass @@ -857,10 +857,10 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case monitorenter_nofpu_id: + case C1StubId::monitorenter_nofpu_id: save_fpu_registers = false; // fall through - case monitorenter_id: + case C1StubId::monitorenter_id: { StubFrame f(sasm, "monitorenter", dont_gc_arguments); OopMap* map = save_live_registers(sasm, save_fpu_registers); @@ -878,10 +878,10 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case monitorexit_nofpu_id: + case C1StubId::monitorexit_nofpu_id: save_fpu_registers = false; // fall through - case monitorexit_id: + case C1StubId::monitorexit_id: { StubFrame f(sasm, "monitorexit", dont_gc_arguments); OopMap* map = save_live_registers(sasm, save_fpu_registers); @@ -901,7 +901,7 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case deoptimize_id: + case C1StubId::deoptimize_id: { StubFrame f(sasm, "deoptimize", dont_gc_arguments, does_not_return); OopMap* oop_map = save_live_registers(sasm); @@ -918,13 +918,13 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case throw_range_check_failed_id: + case C1StubId::throw_range_check_failed_id: { StubFrame f(sasm, "range_check_failed", dont_gc_arguments, does_not_return); oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_range_check_exception), true); } break; - case unwind_exception_id: + case C1StubId::unwind_exception_id: { __ set_info("unwind_exception", dont_gc_arguments); // note: no stubframe since we are about to leave the current // activation and we are calling a leaf VM function only. @@ -932,54 +932,54 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case access_field_patching_id: + case C1StubId::access_field_patching_id: { StubFrame f(sasm, "access_field_patching", dont_gc_arguments, does_not_return); // we should set up register map oop_maps = generate_patching(sasm, CAST_FROM_FN_PTR(address, access_field_patching)); } break; - case load_klass_patching_id: + case C1StubId::load_klass_patching_id: { StubFrame f(sasm, "load_klass_patching", dont_gc_arguments, does_not_return); // we should set up register map oop_maps = generate_patching(sasm, CAST_FROM_FN_PTR(address, move_klass_patching)); } break; - case load_mirror_patching_id: + case C1StubId::load_mirror_patching_id: { StubFrame f(sasm, "load_mirror_patching", dont_gc_arguments, does_not_return); // we should set up register map oop_maps = generate_patching(sasm, CAST_FROM_FN_PTR(address, move_mirror_patching)); } break; - case load_appendix_patching_id: + case C1StubId::load_appendix_patching_id: { StubFrame f(sasm, "load_appendix_patching", dont_gc_arguments, does_not_return); // we should set up register map oop_maps = generate_patching(sasm, CAST_FROM_FN_PTR(address, move_appendix_patching)); } break; - case handle_exception_nofpu_id: - case handle_exception_id: + case C1StubId::handle_exception_nofpu_id: + case C1StubId::handle_exception_id: { StubFrame f(sasm, "handle_exception", dont_gc_arguments); oop_maps = generate_handle_exception(id, sasm); } break; - case handle_exception_from_callee_id: + case C1StubId::handle_exception_from_callee_id: { StubFrame f(sasm, "handle_exception_from_callee", dont_gc_arguments); oop_maps = generate_handle_exception(id, sasm); } break; - case throw_index_exception_id: + case C1StubId::throw_index_exception_id: { StubFrame f(sasm, "index_range_check_failed", dont_gc_arguments, does_not_return); oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_index_exception), true); } break; - case throw_array_store_exception_id: + case C1StubId::throw_array_store_exception_id: { StubFrame f(sasm, "throw_array_store_exception", dont_gc_arguments, does_not_return); // tos + 0: link // + 1: return address @@ -987,7 +987,7 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case predicate_failed_trap_id: + case C1StubId::predicate_failed_trap_id: { StubFrame f(sasm, "predicate_failed_trap", dont_gc_arguments, does_not_return); @@ -1005,7 +1005,7 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case dtrace_object_alloc_id: + case C1StubId::dtrace_object_alloc_id: { // c_rarg0: object StubFrame f(sasm, "dtrace_object_alloc", dont_gc_arguments); save_live_registers(sasm); diff --git a/src/hotspot/cpu/aarch64/c2_CodeStubs_aarch64.cpp b/src/hotspot/cpu/aarch64/c2_CodeStubs_aarch64.cpp index dabafb9288b..4bd509880f2 100644 --- a/src/hotspot/cpu/aarch64/c2_CodeStubs_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/c2_CodeStubs_aarch64.cpp @@ -64,31 +64,4 @@ void C2EntryBarrierStub::emit(C2_MacroAssembler& masm) { __ emit_int32(0); // nmethod guard value } -int C2HandleAnonOMOwnerStub::max_size() const { - // Max size of stub has been determined by testing with 0, in which case - // C2CodeStubList::emit() will throw an assertion and report the actual size that - // is needed. - return 24; -} - -void C2HandleAnonOMOwnerStub::emit(C2_MacroAssembler& masm) { - __ bind(entry()); - Register mon = monitor(); - Register t = tmp(); - assert(t != noreg, "need tmp register"); - - // Fix owner to be the current thread. - __ str(rthread, Address(mon, ObjectMonitor::owner_offset())); - - // Pop owner object from lock-stack. - __ ldrw(t, Address(rthread, JavaThread::lock_stack_top_offset())); - __ subw(t, t, oopSize); -#ifdef ASSERT - __ str(zr, Address(rthread, t)); -#endif - __ strw(t, Address(rthread, JavaThread::lock_stack_top_offset())); - - __ b(continuation()); -} - #undef __ diff --git a/src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.cpp b/src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.cpp index 19af03d3488..62831ee72ba 100644 --- a/src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.cpp @@ -64,8 +64,8 @@ void C2_MacroAssembler::fast_lock(Register objectReg, Register boxReg, Register if (DiagnoseSyncOnValueBasedClasses != 0) { load_klass(tmp, oop); - ldrw(tmp, Address(tmp, Klass::access_flags_offset())); - tstw(tmp, JVM_ACC_IS_VALUE_BASED_CLASS); + ldrb(tmp, Address(tmp, Klass::misc_flags_offset())); + tst(tmp, KlassFlags::_misc_is_value_based_class); br(Assembler::NE, cont); } @@ -150,10 +150,12 @@ void C2_MacroAssembler::fast_unlock(Register objectReg, Register boxReg, Registe Register oop = objectReg; Register box = boxReg; Register disp_hdr = tmpReg; + Register owner_addr = tmpReg; Register tmp = tmp2Reg; Label cont; Label object_has_monitor; Label count, no_count; + Label unlocked; assert(LockingMode != LM_LIGHTWEIGHT, "lightweight locking should use fast_unlock_lightweight"); assert_different_registers(oop, box, tmp, disp_hdr); @@ -204,14 +206,40 @@ void C2_MacroAssembler::fast_unlock(Register objectReg, Register boxReg, Registe b(cont); bind(notRecursive); + + // Compute owner address. + lea(owner_addr, Address(tmp, ObjectMonitor::owner_offset())); + + // Set owner to null. + // Release to satisfy the JMM + stlr(zr, owner_addr); + // We need a full fence after clearing owner to avoid stranding. + // StoreLoad achieves this. + membar(StoreLoad); + + // Check if the entry lists are empty. ldr(rscratch1, Address(tmp, ObjectMonitor::EntryList_offset())); - ldr(disp_hdr, Address(tmp, ObjectMonitor::cxq_offset())); - orr(rscratch1, rscratch1, disp_hdr); // Will be 0 if both are 0. - cmp(rscratch1, zr); // Sets flags for result - cbnz(rscratch1, cont); - // need a release store here - lea(tmp, Address(tmp, ObjectMonitor::owner_offset())); - stlr(zr, tmp); // set unowned + ldr(tmpReg, Address(tmp, ObjectMonitor::cxq_offset())); + orr(rscratch1, rscratch1, tmpReg); + cmp(rscratch1, zr); + br(Assembler::EQ, cont); // If so we are done. + + // Check if there is a successor. + ldr(rscratch1, Address(tmp, ObjectMonitor::succ_offset())); + cmp(rscratch1, zr); + br(Assembler::NE, unlocked); // If so we are done. + + // Save the monitor pointer in the current thread, so we can try to + // reacquire the lock in SharedRuntime::monitor_exit_helper(). + str(tmp, Address(rthread, JavaThread::unlocked_inflated_monitor_offset())); + + cmp(zr, rthread); // Set Flag to NE => slow path + b(cont); + + bind(unlocked); + cmp(zr, zr); // Set Flag to EQ => fast path + + // Intentional fall-through bind(cont); // flag == EQ indicates success @@ -243,8 +271,8 @@ void C2_MacroAssembler::fast_lock_lightweight(Register obj, Register box, Regist if (DiagnoseSyncOnValueBasedClasses != 0) { load_klass(t1, obj); - ldrw(t1, Address(t1, Klass::access_flags_offset())); - tstw(t1, JVM_ACC_IS_VALUE_BASED_CLASS); + ldrb(t1, Address(t1, Klass::misc_flags_offset())); + tst(t1, KlassFlags::_misc_is_value_based_class); br(Assembler::NE, slow_path); } @@ -498,33 +526,41 @@ void C2_MacroAssembler::fast_unlock_lightweight(Register obj, Register box, Regi bind(not_recursive); - Label release; const Register t2_owner_addr = t2; // Compute owner address. lea(t2_owner_addr, Address(t1_monitor, ObjectMonitor::owner_offset())); + // Set owner to null. + // Release to satisfy the JMM + stlr(zr, t2_owner_addr); + // We need a full fence after clearing owner to avoid stranding. + // StoreLoad achieves this. + membar(StoreLoad); + // Check if the entry lists are empty. ldr(rscratch1, Address(t1_monitor, ObjectMonitor::EntryList_offset())); ldr(t3_t, Address(t1_monitor, ObjectMonitor::cxq_offset())); orr(rscratch1, rscratch1, t3_t); cmp(rscratch1, zr); - br(Assembler::EQ, release); + br(Assembler::EQ, unlocked); // If so we are done. - // The owner may be anonymous and we removed the last obj entry in - // the lock-stack. This loses the information about the owner. - // Write the thread to the owner field so the runtime knows the owner. - str(rthread, Address(t2_owner_addr)); + // Check if there is a successor. + ldr(rscratch1, Address(t1_monitor, ObjectMonitor::succ_offset())); + cmp(rscratch1, zr); + br(Assembler::NE, unlocked); // If so we are done. + + // Save the monitor pointer in the current thread, so we can try to + // reacquire the lock in SharedRuntime::monitor_exit_helper(). + str(t1_monitor, Address(rthread, JavaThread::unlocked_inflated_monitor_offset())); + + cmp(zr, rthread); // Set Flag to NE => slow path b(slow_path); - - bind(release); - // Set owner to null. - // Release to satisfy the JMM - stlr(zr, t2_owner_addr); } bind(unlocked); decrement(Address(rthread, JavaThread::held_monitor_count_offset())); + cmp(zr, zr); // Set Flags to EQ => fast path #ifdef ASSERT // Check that unlocked label is reached with Flags == EQ. diff --git a/src/hotspot/cpu/aarch64/cas.m4 b/src/hotspot/cpu/aarch64/cas.m4 index f8aac0c4939..7e13e153db1 100644 --- a/src/hotspot/cpu/aarch64/cas.m4 +++ b/src/hotspot/cpu/aarch64/cas.m4 @@ -45,7 +45,9 @@ define(`CAS_INSN', // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE instruct compareAndExchange$1$6(iReg$2NoSp res, indirect mem, iReg$2 oldval, iReg$2 newval, rFlagsReg cr) %{ ifelse($1$6,PAcq,INDENT(predicate(needs_acquiring_load_exclusive(n) && (n->as_LoadStore()->barrier_data() == 0));), + $1$6,NAcq,INDENT(predicate(needs_acquiring_load_exclusive(n) && n->as_LoadStore()->barrier_data() == 0);), $1,P,INDENT(predicate(n->as_LoadStore()->barrier_data() == 0);), + $1,N,INDENT(predicate(n->as_LoadStore()->barrier_data() == 0);), $6,Acq,INDENT(predicate(needs_acquiring_load_exclusive(n));), `dnl') match(Set res (CompareAndExchange$1 mem (Binary oldval newval))); @@ -122,7 +124,9 @@ define(`CAS_INSN3', // DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE instruct weakCompareAndSwap$1$6(iRegINoSp res, indirect mem, iReg$2 oldval, iReg$2 newval, rFlagsReg cr) %{ ifelse($1$6,PAcq,INDENT(predicate(needs_acquiring_load_exclusive(n) && (n->as_LoadStore()->barrier_data() == 0));), + $1$6,NAcq,INDENT(predicate(needs_acquiring_load_exclusive(n) && n->as_LoadStore()->barrier_data() == 0);), $1,P,INDENT(predicate(n->as_LoadStore()->barrier_data() == 0);), + $1,N,INDENT(predicate(n->as_LoadStore()->barrier_data() == 0);), $6,Acq,INDENT(predicate(needs_acquiring_load_exclusive(n));), `dnl') match(Set res (WeakCompareAndSwap$1 mem (Binary oldval newval))); diff --git a/src/hotspot/cpu/aarch64/compressedKlass_aarch64.cpp b/src/hotspot/cpu/aarch64/compressedKlass_aarch64.cpp index 54af69ffaba..fc78813c161 100644 --- a/src/hotspot/cpu/aarch64/compressedKlass_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/compressedKlass_aarch64.cpp @@ -129,5 +129,7 @@ void CompressedKlassPointers::initialize(address addr, size_t len) { address const end = addr + len; _base = (end <= (address)unscaled_max) ? nullptr : addr; - _range = end - _base; + // Remember the Klass range: + _klass_range_start = addr; + _klass_range_end = addr + len; } diff --git a/src/hotspot/cpu/aarch64/gc/g1/g1BarrierSetAssembler_aarch64.cpp b/src/hotspot/cpu/aarch64/gc/g1/g1BarrierSetAssembler_aarch64.cpp index d02038b6e91..b978c350ce1 100644 --- a/src/hotspot/cpu/aarch64/gc/g1/g1BarrierSetAssembler_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/gc/g1/g1BarrierSetAssembler_aarch64.cpp @@ -38,7 +38,10 @@ #include "c1/c1_LIRAssembler.hpp" #include "c1/c1_MacroAssembler.hpp" #include "gc/g1/c1/g1BarrierSetC1.hpp" -#endif +#endif // COMPILER1 +#ifdef COMPILER2 +#include "gc/g1/c2/g1BarrierSetC2.hpp" +#endif // COMPILER2 #define __ masm-> @@ -95,6 +98,54 @@ void G1BarrierSetAssembler::gen_write_ref_array_post_barrier(MacroAssembler* mas __ pop(saved_regs, sp); } +static void generate_queue_test_and_insertion(MacroAssembler* masm, ByteSize index_offset, ByteSize buffer_offset, Label& runtime, + const Register thread, const Register value, const Register temp1, const Register temp2) { + // Can we store a value in the given thread's buffer? + // (The index field is typed as size_t.) + __ ldr(temp1, Address(thread, in_bytes(index_offset))); // temp1 := *(index address) + __ cbz(temp1, runtime); // jump to runtime if index == 0 (full buffer) + // The buffer is not full, store value into it. + __ sub(temp1, temp1, wordSize); // temp1 := next index + __ str(temp1, Address(thread, in_bytes(index_offset))); // *(index address) := next index + __ ldr(temp2, Address(thread, in_bytes(buffer_offset))); // temp2 := buffer address + __ str(value, Address(temp2, temp1)); // *(buffer address + next index) := value +} + +static void generate_pre_barrier_fast_path(MacroAssembler* masm, + const Register thread, + const Register tmp1) { + Address in_progress(thread, in_bytes(G1ThreadLocalData::satb_mark_queue_active_offset())); + // Is marking active? + if (in_bytes(SATBMarkQueue::byte_width_of_active()) == 4) { + __ ldrw(tmp1, in_progress); + } else { + assert(in_bytes(SATBMarkQueue::byte_width_of_active()) == 1, "Assumption"); + __ ldrb(tmp1, in_progress); + } +} + +static void generate_pre_barrier_slow_path(MacroAssembler* masm, + const Register obj, + const Register pre_val, + const Register thread, + const Register tmp1, + const Register tmp2, + Label& done, + Label& runtime) { + // Do we need to load the previous value? + if (obj != noreg) { + __ load_heap_oop(pre_val, Address(obj, 0), noreg, noreg, AS_RAW); + } + // Is the previous value null? + __ cbz(pre_val, done); + generate_queue_test_and_insertion(masm, + G1ThreadLocalData::satb_mark_queue_index_offset(), + G1ThreadLocalData::satb_mark_queue_buffer_offset(), + runtime, + thread, pre_val, tmp1, tmp2); + __ b(done); +} + void G1BarrierSetAssembler::g1_write_barrier_pre(MacroAssembler* masm, Register obj, Register pre_val, @@ -115,43 +166,10 @@ void G1BarrierSetAssembler::g1_write_barrier_pre(MacroAssembler* masm, assert_different_registers(obj, pre_val, tmp1, tmp2); assert(pre_val != noreg && tmp1 != noreg && tmp2 != noreg, "expecting a register"); - Address in_progress(thread, in_bytes(G1ThreadLocalData::satb_mark_queue_active_offset())); - Address index(thread, in_bytes(G1ThreadLocalData::satb_mark_queue_index_offset())); - Address buffer(thread, in_bytes(G1ThreadLocalData::satb_mark_queue_buffer_offset())); - - // Is marking active? - if (in_bytes(SATBMarkQueue::byte_width_of_active()) == 4) { - __ ldrw(tmp1, in_progress); - } else { - assert(in_bytes(SATBMarkQueue::byte_width_of_active()) == 1, "Assumption"); - __ ldrb(tmp1, in_progress); - } + generate_pre_barrier_fast_path(masm, thread, tmp1); + // If marking is not active (*(mark queue active address) == 0), jump to done __ cbzw(tmp1, done); - - // Do we need to load the previous value? - if (obj != noreg) { - __ load_heap_oop(pre_val, Address(obj, 0), noreg, noreg, AS_RAW); - } - - // Is the previous value null? - __ cbz(pre_val, done); - - // Can we store original value in the thread's buffer? - // Is index == 0? - // (The index field is typed as size_t.) - - __ ldr(tmp1, index); // tmp := *index_adr - __ cbz(tmp1, runtime); // tmp == 0? - // If yes, goto runtime - - __ sub(tmp1, tmp1, wordSize); // tmp := tmp - wordSize - __ str(tmp1, index); // *index_adr := tmp - __ ldr(tmp2, buffer); - __ add(tmp1, tmp1, tmp2); // tmp := tmp + *buffer_adr - - // Record the previous value - __ str(pre_val, Address(tmp1, 0)); - __ b(done); + generate_pre_barrier_slow_path(masm, obj, pre_val, thread, tmp1, tmp2, done, runtime); __ bind(runtime); @@ -182,6 +200,50 @@ void G1BarrierSetAssembler::g1_write_barrier_pre(MacroAssembler* masm, } +static void generate_post_barrier_fast_path(MacroAssembler* masm, + const Register store_addr, + const Register new_val, + const Register tmp1, + const Register tmp2, + Label& done, + bool new_val_may_be_null) { + // Does store cross heap regions? + __ eor(tmp1, store_addr, new_val); // tmp1 := store address ^ new value + __ lsr(tmp1, tmp1, G1HeapRegion::LogOfHRGrainBytes); // tmp1 := ((store address ^ new value) >> LogOfHRGrainBytes) + __ cbz(tmp1, done); + // Crosses regions, storing null? + if (new_val_may_be_null) { + __ cbz(new_val, done); + } + // Storing region crossing non-null, is card young? + __ lsr(tmp1, store_addr, CardTable::card_shift()); // tmp1 := card address relative to card table base + __ load_byte_map_base(tmp2); // tmp2 := card table base address + __ add(tmp1, tmp1, tmp2); // tmp1 := card address + __ ldrb(tmp2, Address(tmp1)); // tmp2 := card + __ cmpw(tmp2, (int)G1CardTable::g1_young_card_val()); // tmp2 := card == young_card_val? +} + +static void generate_post_barrier_slow_path(MacroAssembler* masm, + const Register thread, + const Register tmp1, + const Register tmp2, + Label& done, + Label& runtime) { + __ membar(Assembler::StoreLoad); // StoreLoad membar + __ ldrb(tmp2, Address(tmp1)); // tmp2 := card + __ cbzw(tmp2, done); + // Storing a region crossing, non-null oop, card is clean. + // Dirty card and log. + STATIC_ASSERT(CardTable::dirty_card_val() == 0); + __ strb(zr, Address(tmp1)); // *(card address) := dirty_card_val + generate_queue_test_and_insertion(masm, + G1ThreadLocalData::dirty_card_queue_index_offset(), + G1ThreadLocalData::dirty_card_queue_buffer_offset(), + runtime, + thread, tmp1, tmp2, rscratch1); + __ b(done); +} + void G1BarrierSetAssembler::g1_write_barrier_post(MacroAssembler* masm, Register store_addr, Register new_val, @@ -194,70 +256,116 @@ void G1BarrierSetAssembler::g1_write_barrier_post(MacroAssembler* masm, assert(store_addr != noreg && new_val != noreg && tmp1 != noreg && tmp2 != noreg, "expecting a register"); - Address queue_index(thread, in_bytes(G1ThreadLocalData::dirty_card_queue_index_offset())); - Address buffer(thread, in_bytes(G1ThreadLocalData::dirty_card_queue_buffer_offset())); - - BarrierSet* bs = BarrierSet::barrier_set(); - CardTableBarrierSet* ctbs = barrier_set_cast(bs); - CardTable* ct = ctbs->card_table(); - Label done; Label runtime; - // Does store cross heap regions? - - __ eor(tmp1, store_addr, new_val); - __ lsr(tmp1, tmp1, G1HeapRegion::LogOfHRGrainBytes); - __ cbz(tmp1, done); - - // crosses regions, storing null? - - __ cbz(new_val, done); - - // storing region crossing non-null, is card already dirty? - - const Register card_addr = tmp1; - - __ lsr(card_addr, store_addr, CardTable::card_shift()); - - // get the address of the card - __ load_byte_map_base(tmp2); - __ add(card_addr, card_addr, tmp2); - __ ldrb(tmp2, Address(card_addr)); - __ cmpw(tmp2, (int)G1CardTable::g1_young_card_val()); + generate_post_barrier_fast_path(masm, store_addr, new_val, tmp1, tmp2, done, true /* new_val_may_be_null */); + // If card is young, jump to done __ br(Assembler::EQ, done); - - assert((int)CardTable::dirty_card_val() == 0, "must be 0"); - - __ membar(Assembler::StoreLoad); - - __ ldrb(tmp2, Address(card_addr)); - __ cbzw(tmp2, done); - - // storing a region crossing, non-null oop, card is clean. - // dirty card and log. - - __ strb(zr, Address(card_addr)); - - __ ldr(rscratch1, queue_index); - __ cbz(rscratch1, runtime); - __ sub(rscratch1, rscratch1, wordSize); - __ str(rscratch1, queue_index); - - __ ldr(tmp2, buffer); - __ str(card_addr, Address(tmp2, rscratch1)); - __ b(done); + generate_post_barrier_slow_path(masm, thread, tmp1, tmp2, done, runtime); __ bind(runtime); // save the live input values RegSet saved = RegSet::of(store_addr); __ push(saved, sp); - __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_field_post_entry), card_addr, thread); + __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_field_post_entry), tmp1, thread); __ pop(saved, sp); __ bind(done); } +#if defined(COMPILER2) + +static void generate_c2_barrier_runtime_call(MacroAssembler* masm, G1BarrierStubC2* stub, const Register arg, const address runtime_path) { + SaveLiveRegisters save_registers(masm, stub); + if (c_rarg0 != arg) { + __ mov(c_rarg0, arg); + } + __ mov(c_rarg1, rthread); + __ mov(rscratch1, runtime_path); + __ blr(rscratch1); +} + +void G1BarrierSetAssembler::g1_write_barrier_pre_c2(MacroAssembler* masm, + Register obj, + Register pre_val, + Register thread, + Register tmp1, + Register tmp2, + G1PreBarrierStubC2* stub) { + assert(thread == rthread, "must be"); + assert_different_registers(obj, pre_val, tmp1, tmp2); + assert(pre_val != noreg && tmp1 != noreg && tmp2 != noreg, "expecting a register"); + + stub->initialize_registers(obj, pre_val, thread, tmp1, tmp2); + + generate_pre_barrier_fast_path(masm, thread, tmp1); + // If marking is active (*(mark queue active address) != 0), jump to stub (slow path) + __ cbnzw(tmp1, *stub->entry()); + + __ bind(*stub->continuation()); +} + +void G1BarrierSetAssembler::generate_c2_pre_barrier_stub(MacroAssembler* masm, + G1PreBarrierStubC2* stub) const { + Assembler::InlineSkippedInstructionsCounter skip_counter(masm); + Label runtime; + Register obj = stub->obj(); + Register pre_val = stub->pre_val(); + Register thread = stub->thread(); + Register tmp1 = stub->tmp1(); + Register tmp2 = stub->tmp2(); + + __ bind(*stub->entry()); + generate_pre_barrier_slow_path(masm, obj, pre_val, thread, tmp1, tmp2, *stub->continuation(), runtime); + + __ bind(runtime); + generate_c2_barrier_runtime_call(masm, stub, pre_val, CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_field_pre_entry)); + __ b(*stub->continuation()); +} + +void G1BarrierSetAssembler::g1_write_barrier_post_c2(MacroAssembler* masm, + Register store_addr, + Register new_val, + Register thread, + Register tmp1, + Register tmp2, + G1PostBarrierStubC2* stub) { + assert(thread == rthread, "must be"); + assert_different_registers(store_addr, new_val, thread, tmp1, tmp2, + rscratch1); + assert(store_addr != noreg && new_val != noreg && tmp1 != noreg + && tmp2 != noreg, "expecting a register"); + + stub->initialize_registers(thread, tmp1, tmp2); + + bool new_val_may_be_null = (stub->barrier_data() & G1C2BarrierPostNotNull) == 0; + generate_post_barrier_fast_path(masm, store_addr, new_val, tmp1, tmp2, *stub->continuation(), new_val_may_be_null); + // If card is not young, jump to stub (slow path) + __ br(Assembler::NE, *stub->entry()); + + __ bind(*stub->continuation()); +} + +void G1BarrierSetAssembler::generate_c2_post_barrier_stub(MacroAssembler* masm, + G1PostBarrierStubC2* stub) const { + Assembler::InlineSkippedInstructionsCounter skip_counter(masm); + Label runtime; + Register thread = stub->thread(); + Register tmp1 = stub->tmp1(); // tmp1 holds the card address. + Register tmp2 = stub->tmp2(); + assert(stub->tmp3() == noreg, "not needed in this platform"); + + __ bind(*stub->entry()); + generate_post_barrier_slow_path(masm, thread, tmp1, tmp2, *stub->continuation(), runtime); + + __ bind(runtime); + generate_c2_barrier_runtime_call(masm, stub, tmp1, CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_field_post_entry)); + __ b(*stub->continuation()); +} + +#endif // COMPILER2 + void G1BarrierSetAssembler::load_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type, Register dst, Address src, Register tmp1, Register tmp2) { bool on_oop = is_reference_type(type); diff --git a/src/hotspot/cpu/aarch64/gc/g1/g1BarrierSetAssembler_aarch64.hpp b/src/hotspot/cpu/aarch64/gc/g1/g1BarrierSetAssembler_aarch64.hpp index 7b4bc8cdc49..4baa18cb945 100644 --- a/src/hotspot/cpu/aarch64/gc/g1/g1BarrierSetAssembler_aarch64.hpp +++ b/src/hotspot/cpu/aarch64/gc/g1/g1BarrierSetAssembler_aarch64.hpp @@ -33,6 +33,8 @@ class LIR_Assembler; class StubAssembler; class G1PreBarrierStub; class G1PostBarrierStub; +class G1PreBarrierStubC2; +class G1PostBarrierStubC2; class G1BarrierSetAssembler: public ModRefBarrierSetAssembler { protected: @@ -69,6 +71,27 @@ public: void generate_c1_post_barrier_runtime_stub(StubAssembler* sasm); #endif +#ifdef COMPILER2 + void g1_write_barrier_pre_c2(MacroAssembler* masm, + Register obj, + Register pre_val, + Register thread, + Register tmp1, + Register tmp2, + G1PreBarrierStubC2* c2_stub); + void generate_c2_pre_barrier_stub(MacroAssembler* masm, + G1PreBarrierStubC2* stub) const; + void g1_write_barrier_post_c2(MacroAssembler* masm, + Register store_addr, + Register new_val, + Register thread, + Register tmp1, + Register tmp2, + G1PostBarrierStubC2* c2_stub); + void generate_c2_post_barrier_stub(MacroAssembler* masm, + G1PostBarrierStubC2* stub) const; +#endif + void load_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type, Register dst, Address src, Register tmp1, Register tmp2); }; diff --git a/src/hotspot/cpu/aarch64/gc/g1/g1_aarch64.ad b/src/hotspot/cpu/aarch64/gc/g1/g1_aarch64.ad new file mode 100644 index 00000000000..081a67d6880 --- /dev/null +++ b/src/hotspot/cpu/aarch64/gc/g1/g1_aarch64.ad @@ -0,0 +1,680 @@ +// +// Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. +// DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +// +// This code is free software; you can redistribute it and/or modify it +// under the terms of the GNU General Public License version 2 only, as +// published by the Free Software Foundation. +// +// This code is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// version 2 for more details (a copy is included in the LICENSE file that +// accompanied this code). +// +// You should have received a copy of the GNU General Public License version +// 2 along with this work; if not, write to the Free Software Foundation, +// Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +// +// Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +// or visit www.oracle.com if you need additional information or have any +// questions. +// + +source_hpp %{ + +#include "gc/g1/c2/g1BarrierSetC2.hpp" +#include "gc/shared/gc_globals.hpp" + +%} + +source %{ + +#include "gc/g1/g1BarrierSetAssembler_aarch64.hpp" +#include "gc/g1/g1BarrierSetRuntime.hpp" + +static void write_barrier_pre(MacroAssembler* masm, + const MachNode* node, + Register obj, + Register pre_val, + Register tmp1, + Register tmp2, + RegSet preserve = RegSet(), + RegSet no_preserve = RegSet()) { + if (!G1PreBarrierStubC2::needs_barrier(node)) { + return; + } + Assembler::InlineSkippedInstructionsCounter skip_counter(masm); + G1BarrierSetAssembler* g1_asm = static_cast(BarrierSet::barrier_set()->barrier_set_assembler()); + G1PreBarrierStubC2* const stub = G1PreBarrierStubC2::create(node); + for (RegSetIterator reg = preserve.begin(); *reg != noreg; ++reg) { + stub->preserve(*reg); + } + for (RegSetIterator reg = no_preserve.begin(); *reg != noreg; ++reg) { + stub->dont_preserve(*reg); + } + g1_asm->g1_write_barrier_pre_c2(masm, obj, pre_val, rthread, tmp1, tmp2, stub); +} + +static void write_barrier_post(MacroAssembler* masm, + const MachNode* node, + Register store_addr, + Register new_val, + Register tmp1, + Register tmp2) { + if (!G1PostBarrierStubC2::needs_barrier(node)) { + return; + } + Assembler::InlineSkippedInstructionsCounter skip_counter(masm); + G1BarrierSetAssembler* g1_asm = static_cast(BarrierSet::barrier_set()->barrier_set_assembler()); + G1PostBarrierStubC2* const stub = G1PostBarrierStubC2::create(node); + g1_asm->g1_write_barrier_post_c2(masm, store_addr, new_val, rthread, tmp1, tmp2, stub); +} + +%} + +// BEGIN This section of the file is automatically generated. Do not edit -------------- + +// This section is generated from g1_aarch64.m4 + + +// This pattern is generated automatically from g1_aarch64.m4. +// DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE +instruct g1StoreP(indirect mem, iRegP src, iRegPNoSp tmp1, iRegPNoSp tmp2, iRegPNoSp tmp3, rFlagsReg cr) +%{ + predicate(UseG1GC && !needs_releasing_store(n) && n->as_Store()->barrier_data() != 0); + match(Set mem (StoreP mem src)); + effect(TEMP tmp1, TEMP tmp2, TEMP tmp3, KILL cr); + ins_cost(INSN_COST); + format %{ "str $src, $mem\t# ptr" %} + ins_encode %{ + write_barrier_pre(masm, this, + $mem$$Register /* obj */, + $tmp1$$Register /* pre_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */, + RegSet::of($mem$$Register, $src$$Register) /* preserve */); + __ str($src$$Register, $mem$$Register); + write_barrier_post(masm, this, + $mem$$Register /* store_addr */, + $src$$Register /* new_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */); + %} + ins_pipe(istore_reg_mem); +%} + +// This pattern is generated automatically from g1_aarch64.m4. +// DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE +instruct g1StorePVolatile(indirect mem, iRegP src, iRegPNoSp tmp1, iRegPNoSp tmp2, iRegPNoSp tmp3, rFlagsReg cr) +%{ + predicate(UseG1GC && needs_releasing_store(n) && n->as_Store()->barrier_data() != 0); + match(Set mem (StoreP mem src)); + effect(TEMP tmp1, TEMP tmp2, TEMP tmp3, KILL cr); + ins_cost(VOLATILE_REF_COST); + format %{ "stlr $src, $mem\t# ptr" %} + ins_encode %{ + write_barrier_pre(masm, this, + $mem$$Register /* obj */, + $tmp1$$Register /* pre_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */, + RegSet::of($mem$$Register, $src$$Register) /* preserve */); + __ stlr($src$$Register, $mem$$Register); + write_barrier_post(masm, this, + $mem$$Register /* store_addr */, + $src$$Register /* new_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */); + %} + ins_pipe(pipe_class_memory); +%} + +// This pattern is generated automatically from g1_aarch64.m4. +// DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE +instruct g1StoreN(indirect mem, iRegN src, iRegPNoSp tmp1, iRegPNoSp tmp2, iRegPNoSp tmp3, rFlagsReg cr) +%{ + predicate(UseG1GC && !needs_releasing_store(n) && n->as_Store()->barrier_data() != 0); + match(Set mem (StoreN mem src)); + effect(TEMP tmp1, TEMP tmp2, TEMP tmp3, KILL cr); + ins_cost(INSN_COST); + format %{ "strw $src, $mem\t# compressed ptr" %} + ins_encode %{ + write_barrier_pre(masm, this, + $mem$$Register /* obj */, + $tmp1$$Register /* pre_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */, + RegSet::of($mem$$Register, $src$$Register) /* preserve */); + __ strw($src$$Register, $mem$$Register); + if ((barrier_data() & G1C2BarrierPost) != 0) { + if ((barrier_data() & G1C2BarrierPostNotNull) == 0) { + __ decode_heap_oop($tmp1$$Register, $src$$Register); + } else { + __ decode_heap_oop_not_null($tmp1$$Register, $src$$Register); + } + } + write_barrier_post(masm, this, + $mem$$Register /* store_addr */, + $tmp1$$Register /* new_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */); + %} + ins_pipe(istore_reg_mem); +%} + +// This pattern is generated automatically from g1_aarch64.m4. +// DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE +instruct g1StoreNVolatile(indirect mem, iRegN src, iRegPNoSp tmp1, iRegPNoSp tmp2, iRegPNoSp tmp3, rFlagsReg cr) +%{ + predicate(UseG1GC && needs_releasing_store(n) && n->as_Store()->barrier_data() != 0); + match(Set mem (StoreN mem src)); + effect(TEMP tmp1, TEMP tmp2, TEMP tmp3, KILL cr); + ins_cost(VOLATILE_REF_COST); + format %{ "stlrw $src, $mem\t# compressed ptr" %} + ins_encode %{ + write_barrier_pre(masm, this, + $mem$$Register /* obj */, + $tmp1$$Register /* pre_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */, + RegSet::of($mem$$Register, $src$$Register) /* preserve */); + __ stlrw($src$$Register, $mem$$Register); + if ((barrier_data() & G1C2BarrierPost) != 0) { + if ((barrier_data() & G1C2BarrierPostNotNull) == 0) { + __ decode_heap_oop($tmp1$$Register, $src$$Register); + } else { + __ decode_heap_oop_not_null($tmp1$$Register, $src$$Register); + } + } + write_barrier_post(masm, this, + $mem$$Register /* store_addr */, + $tmp1$$Register /* new_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */); + %} + ins_pipe(pipe_class_memory); +%} + +// This pattern is generated automatically from g1_aarch64.m4. +// DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE +instruct g1EncodePAndStoreN(indirect mem, iRegP src, iRegPNoSp tmp1, iRegPNoSp tmp2, iRegPNoSp tmp3, rFlagsReg cr) +%{ + predicate(UseG1GC && !needs_releasing_store(n) && n->as_Store()->barrier_data() != 0); + match(Set mem (StoreN mem (EncodeP src))); + effect(TEMP tmp1, TEMP tmp2, TEMP tmp3, KILL cr); + ins_cost(INSN_COST); + format %{ "encode_heap_oop $tmp1, $src\n\t" + "strw $tmp1, $mem\t# compressed ptr" %} + ins_encode %{ + write_barrier_pre(masm, this, + $mem$$Register /* obj */, + $tmp1$$Register /* pre_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */, + RegSet::of($mem$$Register, $src$$Register) /* preserve */); + if ((barrier_data() & G1C2BarrierPostNotNull) == 0) { + __ encode_heap_oop($tmp1$$Register, $src$$Register); + } else { + __ encode_heap_oop_not_null($tmp1$$Register, $src$$Register); + } + __ strw($tmp1$$Register, $mem$$Register); + write_barrier_post(masm, this, + $mem$$Register /* store_addr */, + $src$$Register /* new_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */); + %} + ins_pipe(istore_reg_mem); +%} + +// This pattern is generated automatically from g1_aarch64.m4. +// DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE +instruct g1EncodePAndStoreNVolatile(indirect mem, iRegP src, iRegPNoSp tmp1, iRegPNoSp tmp2, iRegPNoSp tmp3, rFlagsReg cr) +%{ + predicate(UseG1GC && needs_releasing_store(n) && n->as_Store()->barrier_data() != 0); + match(Set mem (StoreN mem (EncodeP src))); + effect(TEMP tmp1, TEMP tmp2, TEMP tmp3, KILL cr); + ins_cost(VOLATILE_REF_COST); + format %{ "encode_heap_oop $tmp1, $src\n\t" + "stlrw $tmp1, $mem\t# compressed ptr" %} + ins_encode %{ + write_barrier_pre(masm, this, + $mem$$Register /* obj */, + $tmp1$$Register /* pre_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */, + RegSet::of($mem$$Register, $src$$Register) /* preserve */); + if ((barrier_data() & G1C2BarrierPostNotNull) == 0) { + __ encode_heap_oop($tmp1$$Register, $src$$Register); + } else { + __ encode_heap_oop_not_null($tmp1$$Register, $src$$Register); + } + __ stlrw($tmp1$$Register, $mem$$Register); + write_barrier_post(masm, this, + $mem$$Register /* store_addr */, + $src$$Register /* new_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */); + %} + ins_pipe(pipe_class_memory); +%} + +// This pattern is generated automatically from g1_aarch64.m4. +// DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE +instruct g1CompareAndExchangeP(iRegPNoSp res, indirect mem, iRegP oldval, iRegP newval, iRegPNoSp tmp1, iRegPNoSp tmp2, rFlagsReg cr) +%{ + predicate(UseG1GC && !needs_acquiring_load_exclusive(n) && n->as_LoadStore()->barrier_data() != 0); + match(Set res (CompareAndExchangeP mem (Binary oldval newval))); + effect(TEMP res, TEMP tmp1, TEMP tmp2, KILL cr); + ins_cost(2 * VOLATILE_REF_COST); + format %{ "cmpxchg $res = $mem, $oldval, $newval\t# ptr" %} + ins_encode %{ + assert_different_registers($oldval$$Register, $mem$$Register); + assert_different_registers($newval$$Register, $mem$$Register); + // Pass $oldval to the pre-barrier (instead of loading from $mem), because + // $oldval is the only value that can be overwritten. + // The same holds for g1CompareAndSwapP and its Acq variant. + write_barrier_pre(masm, this, + noreg /* obj */, + $oldval$$Register /* pre_val */, + $tmp1$$Register /* tmp1 */, + $tmp2$$Register /* tmp2 */, + RegSet::of($mem$$Register, $oldval$$Register, $newval$$Register) /* preserve */, + RegSet::of($res$$Register) /* no_preserve */); + __ cmpxchg($mem$$Register, $oldval$$Register, $newval$$Register, Assembler::xword, + false /* acquire */, true /* release */, false /* weak */, $res$$Register); + write_barrier_post(masm, this, + $mem$$Register /* store_addr */, + $newval$$Register /* new_val */, + $tmp1$$Register /* tmp1 */, + $tmp2$$Register /* tmp2 */); + %} + ins_pipe(pipe_slow); +%} + +// This pattern is generated automatically from g1_aarch64.m4. +// DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE +instruct g1CompareAndExchangePAcq(iRegPNoSp res, indirect mem, iRegP oldval, iRegP newval, iRegPNoSp tmp1, iRegPNoSp tmp2, rFlagsReg cr) +%{ + predicate(UseG1GC && needs_acquiring_load_exclusive(n) && n->as_LoadStore()->barrier_data() != 0); + match(Set res (CompareAndExchangeP mem (Binary oldval newval))); + effect(TEMP res, TEMP tmp1, TEMP tmp2, KILL cr); + ins_cost(VOLATILE_REF_COST); + format %{ "cmpxchg_acq $res = $mem, $oldval, $newval\t# ptr" %} + ins_encode %{ + assert_different_registers($oldval$$Register, $mem$$Register); + assert_different_registers($newval$$Register, $mem$$Register); + // Pass $oldval to the pre-barrier (instead of loading from $mem), because + // $oldval is the only value that can be overwritten. + // The same holds for g1CompareAndSwapP and its Acq variant. + write_barrier_pre(masm, this, + noreg /* obj */, + $oldval$$Register /* pre_val */, + $tmp1$$Register /* tmp1 */, + $tmp2$$Register /* tmp2 */, + RegSet::of($mem$$Register, $oldval$$Register, $newval$$Register) /* preserve */, + RegSet::of($res$$Register) /* no_preserve */); + __ cmpxchg($mem$$Register, $oldval$$Register, $newval$$Register, Assembler::xword, + true /* acquire */, true /* release */, false /* weak */, $res$$Register); + write_barrier_post(masm, this, + $mem$$Register /* store_addr */, + $newval$$Register /* new_val */, + $tmp1$$Register /* tmp1 */, + $tmp2$$Register /* tmp2 */); + %} + ins_pipe(pipe_slow); +%} + +// This pattern is generated automatically from g1_aarch64.m4. +// DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE +instruct g1CompareAndExchangeN(iRegNNoSp res, indirect mem, iRegN oldval, iRegN newval, iRegPNoSp tmp1, iRegPNoSp tmp2, iRegPNoSp tmp3, rFlagsReg cr) +%{ + predicate(UseG1GC && !needs_acquiring_load_exclusive(n) && n->as_LoadStore()->barrier_data() != 0); + match(Set res (CompareAndExchangeN mem (Binary oldval newval))); + effect(TEMP res, TEMP tmp1, TEMP tmp2, TEMP tmp3, KILL cr); + ins_cost(2 * VOLATILE_REF_COST); + format %{ "cmpxchg $res = $mem, $oldval, $newval\t# narrow oop" %} + ins_encode %{ + assert_different_registers($oldval$$Register, $mem$$Register); + assert_different_registers($newval$$Register, $mem$$Register); + write_barrier_pre(masm, this, + $mem$$Register /* obj */, + $tmp1$$Register /* pre_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */, + RegSet::of($mem$$Register, $oldval$$Register, $newval$$Register) /* preserve */, + RegSet::of($res$$Register) /* no_preserve */); + __ cmpxchg($mem$$Register, $oldval$$Register, $newval$$Register, Assembler::word, + false /* acquire */, true /* release */, false /* weak */, $res$$Register); + __ decode_heap_oop($tmp1$$Register, $newval$$Register); + write_barrier_post(masm, this, + $mem$$Register /* store_addr */, + $tmp1$$Register /* new_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */); + %} + ins_pipe(pipe_slow); +%} + +// This pattern is generated automatically from g1_aarch64.m4. +// DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE +instruct g1CompareAndExchangeNAcq(iRegNNoSp res, indirect mem, iRegN oldval, iRegN newval, iRegPNoSp tmp1, iRegPNoSp tmp2, iRegPNoSp tmp3, rFlagsReg cr) +%{ + predicate(UseG1GC && needs_acquiring_load_exclusive(n) && n->as_LoadStore()->barrier_data() != 0); + match(Set res (CompareAndExchangeN mem (Binary oldval newval))); + effect(TEMP res, TEMP tmp1, TEMP tmp2, TEMP tmp3, KILL cr); + ins_cost(VOLATILE_REF_COST); + format %{ "cmpxchg_acq $res = $mem, $oldval, $newval\t# narrow oop" %} + ins_encode %{ + assert_different_registers($oldval$$Register, $mem$$Register); + assert_different_registers($newval$$Register, $mem$$Register); + write_barrier_pre(masm, this, + $mem$$Register /* obj */, + $tmp1$$Register /* pre_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */, + RegSet::of($mem$$Register, $oldval$$Register, $newval$$Register) /* preserve */, + RegSet::of($res$$Register) /* no_preserve */); + __ cmpxchg($mem$$Register, $oldval$$Register, $newval$$Register, Assembler::word, + true /* acquire */, true /* release */, false /* weak */, $res$$Register); + __ decode_heap_oop($tmp1$$Register, $newval$$Register); + write_barrier_post(masm, this, + $mem$$Register /* store_addr */, + $tmp1$$Register /* new_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */); + %} + ins_pipe(pipe_slow); +%} + +// This pattern is generated automatically from g1_aarch64.m4. +// DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE +instruct g1CompareAndSwapP(iRegINoSp res, indirect mem, iRegP newval, iRegPNoSp tmp1, iRegPNoSp tmp2, iRegP oldval, rFlagsReg cr) +%{ + predicate(UseG1GC && !needs_acquiring_load_exclusive(n) && n->as_LoadStore()->barrier_data() != 0); + match(Set res (CompareAndSwapP mem (Binary oldval newval))); + match(Set res (WeakCompareAndSwapP mem (Binary oldval newval))); + effect(TEMP res, TEMP tmp1, TEMP tmp2, KILL cr); + ins_cost(2 * VOLATILE_REF_COST); + format %{ "cmpxchg $mem, $oldval, $newval\t# (ptr)\n\t" + "cset $res, EQ" %} + ins_encode %{ + assert_different_registers($oldval$$Register, $mem$$Register); + assert_different_registers($newval$$Register, $mem$$Register); + write_barrier_pre(masm, this, + noreg /* obj */, + $oldval$$Register /* pre_val */, + $tmp1$$Register /* tmp1 */, + $tmp2$$Register /* tmp2 */, + RegSet::of($mem$$Register, $oldval$$Register, $newval$$Register) /* preserve */, + RegSet::of($res$$Register) /* no_preserve */); + __ cmpxchg($mem$$Register, $oldval$$Register, $newval$$Register, Assembler::xword, + false /* acquire */, true /* release */, false /* weak */, noreg); + __ cset($res$$Register, Assembler::EQ); + write_barrier_post(masm, this, + $mem$$Register /* store_addr */, + $newval$$Register /* new_val */, + $tmp1$$Register /* tmp1 */, + $tmp2$$Register /* tmp2 */); + %} + ins_pipe(pipe_slow); +%} + +// This pattern is generated automatically from g1_aarch64.m4. +// DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE +instruct g1CompareAndSwapPAcq(iRegINoSp res, indirect mem, iRegP newval, iRegPNoSp tmp1, iRegPNoSp tmp2, iRegP oldval, rFlagsReg cr) +%{ + predicate(UseG1GC && needs_acquiring_load_exclusive(n) && n->as_LoadStore()->barrier_data() != 0); + match(Set res (CompareAndSwapP mem (Binary oldval newval))); + match(Set res (WeakCompareAndSwapP mem (Binary oldval newval))); + effect(TEMP res, TEMP tmp1, TEMP tmp2, KILL cr); + ins_cost(VOLATILE_REF_COST); + format %{ "cmpxchg_acq $mem, $oldval, $newval\t# (ptr)\n\t" + "cset $res, EQ" %} + ins_encode %{ + assert_different_registers($oldval$$Register, $mem$$Register); + assert_different_registers($newval$$Register, $mem$$Register); + write_barrier_pre(masm, this, + noreg /* obj */, + $oldval$$Register /* pre_val */, + $tmp1$$Register /* tmp1 */, + $tmp2$$Register /* tmp2 */, + RegSet::of($mem$$Register, $oldval$$Register, $newval$$Register) /* preserve */, + RegSet::of($res$$Register) /* no_preserve */); + __ cmpxchg($mem$$Register, $oldval$$Register, $newval$$Register, Assembler::xword, + true /* acquire */, true /* release */, false /* weak */, noreg); + __ cset($res$$Register, Assembler::EQ); + write_barrier_post(masm, this, + $mem$$Register /* store_addr */, + $newval$$Register /* new_val */, + $tmp1$$Register /* tmp1 */, + $tmp2$$Register /* tmp2 */); + %} + ins_pipe(pipe_slow); +%} + +// This pattern is generated automatically from g1_aarch64.m4. +// DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE +instruct g1CompareAndSwapN(iRegINoSp res, indirect mem, iRegN newval, iRegPNoSp tmp1, iRegPNoSp tmp2, iRegPNoSp tmp3, iRegN oldval, rFlagsReg cr) +%{ + predicate(UseG1GC && !needs_acquiring_load_exclusive(n) && n->as_LoadStore()->barrier_data() != 0); + match(Set res (CompareAndSwapN mem (Binary oldval newval))); + match(Set res (WeakCompareAndSwapN mem (Binary oldval newval))); + effect(TEMP res, TEMP tmp1, TEMP tmp2, TEMP tmp3, KILL cr); + ins_cost(2 * VOLATILE_REF_COST); + format %{ "cmpxchg $mem, $oldval, $newval\t# (narrow oop)\n\t" + "cset $res, EQ" %} + ins_encode %{ + assert_different_registers($oldval$$Register, $mem$$Register); + assert_different_registers($newval$$Register, $mem$$Register); + write_barrier_pre(masm, this, + $mem$$Register /* obj */, + $tmp1$$Register /* pre_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */, + RegSet::of($mem$$Register, $oldval$$Register, $newval$$Register) /* preserve */, + RegSet::of($res$$Register) /* no_preserve */); + __ cmpxchg($mem$$Register, $oldval$$Register, $newval$$Register, Assembler::word, + false /* acquire */, true /* release */, false /* weak */, noreg); + __ cset($res$$Register, Assembler::EQ); + __ decode_heap_oop($tmp1$$Register, $newval$$Register); + write_barrier_post(masm, this, + $mem$$Register /* store_addr */, + $tmp1$$Register /* new_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */); + %} + ins_pipe(pipe_slow); +%} + +// This pattern is generated automatically from g1_aarch64.m4. +// DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE +instruct g1CompareAndSwapNAcq(iRegINoSp res, indirect mem, iRegN newval, iRegPNoSp tmp1, iRegPNoSp tmp2, iRegPNoSp tmp3, iRegN oldval, rFlagsReg cr) +%{ + predicate(UseG1GC && needs_acquiring_load_exclusive(n) && n->as_LoadStore()->barrier_data() != 0); + match(Set res (CompareAndSwapN mem (Binary oldval newval))); + match(Set res (WeakCompareAndSwapN mem (Binary oldval newval))); + effect(TEMP res, TEMP tmp1, TEMP tmp2, TEMP tmp3, KILL cr); + ins_cost(VOLATILE_REF_COST); + format %{ "cmpxchg_acq $mem, $oldval, $newval\t# (narrow oop)\n\t" + "cset $res, EQ" %} + ins_encode %{ + assert_different_registers($oldval$$Register, $mem$$Register); + assert_different_registers($newval$$Register, $mem$$Register); + write_barrier_pre(masm, this, + $mem$$Register /* obj */, + $tmp1$$Register /* pre_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */, + RegSet::of($mem$$Register, $oldval$$Register, $newval$$Register) /* preserve */, + RegSet::of($res$$Register) /* no_preserve */); + __ cmpxchg($mem$$Register, $oldval$$Register, $newval$$Register, Assembler::word, + true /* acquire */, true /* release */, false /* weak */, noreg); + __ cset($res$$Register, Assembler::EQ); + __ decode_heap_oop($tmp1$$Register, $newval$$Register); + write_barrier_post(masm, this, + $mem$$Register /* store_addr */, + $tmp1$$Register /* new_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */); + %} + ins_pipe(pipe_slow); +%} + +// This pattern is generated automatically from g1_aarch64.m4. +// DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE +instruct g1GetAndSetP(indirect mem, iRegP newval, iRegPNoSp tmp1, iRegPNoSp tmp2, iRegPNoSp preval, rFlagsReg cr) +%{ + predicate(UseG1GC && !needs_acquiring_load_exclusive(n) && n->as_LoadStore()->barrier_data() != 0); + match(Set preval (GetAndSetP mem newval)); + effect(TEMP preval, TEMP tmp1, TEMP tmp2, KILL cr); + ins_cost(2 * VOLATILE_REF_COST); + format %{ "atomic_xchg $preval, $newval, [$mem]" %} + ins_encode %{ + assert_different_registers($mem$$Register, $newval$$Register); + write_barrier_pre(masm, this, + $mem$$Register /* obj */, + $preval$$Register /* pre_val (as a temporary register) */, + $tmp1$$Register /* tmp1 */, + $tmp2$$Register /* tmp2 */, + RegSet::of($mem$$Register, $preval$$Register, $newval$$Register) /* preserve */); + __ atomic_xchg($preval$$Register, $newval$$Register, $mem$$Register); + write_barrier_post(masm, this, + $mem$$Register /* store_addr */, + $newval$$Register /* new_val */, + $tmp1$$Register /* tmp1 */, + $tmp2$$Register /* tmp2 */); + %} + ins_pipe(pipe_serial); +%} + +// This pattern is generated automatically from g1_aarch64.m4. +// DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE +instruct g1GetAndSetPAcq(indirect mem, iRegP newval, iRegPNoSp tmp1, iRegPNoSp tmp2, iRegPNoSp preval, rFlagsReg cr) +%{ + predicate(UseG1GC && needs_acquiring_load_exclusive(n) && n->as_LoadStore()->barrier_data() != 0); + match(Set preval (GetAndSetP mem newval)); + effect(TEMP preval, TEMP tmp1, TEMP tmp2, KILL cr); + ins_cost(VOLATILE_REF_COST); + format %{ "atomic_xchg_acq $preval, $newval, [$mem]" %} + ins_encode %{ + assert_different_registers($mem$$Register, $newval$$Register); + write_barrier_pre(masm, this, + $mem$$Register /* obj */, + $preval$$Register /* pre_val (as a temporary register) */, + $tmp1$$Register /* tmp1 */, + $tmp2$$Register /* tmp2 */, + RegSet::of($mem$$Register, $preval$$Register, $newval$$Register) /* preserve */); + __ atomic_xchgal($preval$$Register, $newval$$Register, $mem$$Register); + write_barrier_post(masm, this, + $mem$$Register /* store_addr */, + $newval$$Register /* new_val */, + $tmp1$$Register /* tmp1 */, + $tmp2$$Register /* tmp2 */); + %} + ins_pipe(pipe_serial); +%} + +// This pattern is generated automatically from g1_aarch64.m4. +// DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE +instruct g1GetAndSetN(indirect mem, iRegN newval, iRegPNoSp tmp1, iRegPNoSp tmp2, iRegPNoSp tmp3, iRegNNoSp preval, rFlagsReg cr) +%{ + predicate(UseG1GC && !needs_acquiring_load_exclusive(n) && n->as_LoadStore()->barrier_data() != 0); + match(Set preval (GetAndSetN mem newval)); + effect(TEMP preval, TEMP tmp1, TEMP tmp2, TEMP tmp3, KILL cr); + ins_cost(2 * VOLATILE_REF_COST); + format %{ "atomic_xchgw $preval, $newval, [$mem]" %} + ins_encode %{ + assert_different_registers($mem$$Register, $newval$$Register); + write_barrier_pre(masm, this, + $mem$$Register /* obj */, + $tmp1$$Register /* pre_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */, + RegSet::of($mem$$Register, $preval$$Register, $newval$$Register) /* preserve */); + __ atomic_xchgw($preval$$Register, $newval$$Register, $mem$$Register); + __ decode_heap_oop($tmp1$$Register, $newval$$Register); + write_barrier_post(masm, this, + $mem$$Register /* store_addr */, + $tmp1$$Register /* new_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */); + %} + ins_pipe(pipe_serial); +%} + +// This pattern is generated automatically from g1_aarch64.m4. +// DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE +instruct g1GetAndSetNAcq(indirect mem, iRegN newval, iRegPNoSp tmp1, iRegPNoSp tmp2, iRegPNoSp tmp3, iRegNNoSp preval, rFlagsReg cr) +%{ + predicate(UseG1GC && needs_acquiring_load_exclusive(n) && n->as_LoadStore()->barrier_data() != 0); + match(Set preval (GetAndSetN mem newval)); + effect(TEMP preval, TEMP tmp1, TEMP tmp2, TEMP tmp3, KILL cr); + ins_cost(VOLATILE_REF_COST); + format %{ "atomic_xchgw_acq $preval, $newval, [$mem]" %} + ins_encode %{ + assert_different_registers($mem$$Register, $newval$$Register); + write_barrier_pre(masm, this, + $mem$$Register /* obj */, + $tmp1$$Register /* pre_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */, + RegSet::of($mem$$Register, $preval$$Register, $newval$$Register) /* preserve */); + __ atomic_xchgalw($preval$$Register, $newval$$Register, $mem$$Register); + __ decode_heap_oop($tmp1$$Register, $newval$$Register); + write_barrier_post(masm, this, + $mem$$Register /* store_addr */, + $tmp1$$Register /* new_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */); + %} + ins_pipe(pipe_serial); +%} + +// This pattern is generated automatically from g1_aarch64.m4. +// DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE +instruct g1LoadP(iRegPNoSp dst, indirect mem, iRegPNoSp tmp1, iRegPNoSp tmp2, rFlagsReg cr) +%{ + // This instruction does not need an acquiring counterpart because it is only + // used for reference loading (Reference::get()). The same holds for g1LoadN. + predicate(UseG1GC && !needs_acquiring_load(n) && n->as_Load()->barrier_data() != 0); + match(Set dst (LoadP mem)); + effect(TEMP dst, TEMP tmp1, TEMP tmp2, KILL cr); + ins_cost(4 * INSN_COST); + format %{ "ldr $dst, $mem\t# ptr" %} + ins_encode %{ + __ ldr($dst$$Register, $mem$$Register); + write_barrier_pre(masm, this, + noreg /* obj */, + $dst$$Register /* pre_val */, + $tmp1$$Register /* tmp1 */, + $tmp2$$Register /* tmp2 */); + %} + ins_pipe(iload_reg_mem); +%} + +// This pattern is generated automatically from g1_aarch64.m4. +// DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE +instruct g1LoadN(iRegNNoSp dst, indirect mem, iRegPNoSp tmp1, iRegPNoSp tmp2, iRegPNoSp tmp3, rFlagsReg cr) +%{ + predicate(UseG1GC && !needs_acquiring_load(n) && n->as_Load()->barrier_data() != 0); + match(Set dst (LoadN mem)); + effect(TEMP dst, TEMP tmp1, TEMP tmp2, TEMP tmp3, KILL cr); + ins_cost(4 * INSN_COST); + format %{ "ldrw $dst, $mem\t# compressed ptr" %} + ins_encode %{ + __ ldrw($dst$$Register, $mem$$Register); + if ((barrier_data() & G1C2BarrierPre) != 0) { + __ decode_heap_oop($tmp1$$Register, $dst$$Register); + write_barrier_pre(masm, this, + noreg /* obj */, + $tmp1$$Register /* pre_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */); + } + %} + ins_pipe(iload_reg_mem); +%} + +// END This section of the file is automatically generated. Do not edit -------------- diff --git a/src/hotspot/cpu/aarch64/gc/g1/g1_aarch64.m4 b/src/hotspot/cpu/aarch64/gc/g1/g1_aarch64.m4 new file mode 100644 index 00000000000..8fb1f7e8e42 --- /dev/null +++ b/src/hotspot/cpu/aarch64/gc/g1/g1_aarch64.m4 @@ -0,0 +1,384 @@ +dnl Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. +dnl DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +dnl +dnl This code is free software; you can redistribute it and/or modify it +dnl under the terms of the GNU General Public License version 2 only, as +dnl published by the Free Software Foundation. +dnl +dnl This code is distributed in the hope that it will be useful, but WITHOUT +dnl ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +dnl FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +dnl version 2 for more details (a copy is included in the LICENSE file that +dnl accompanied this code). +dnl +dnl You should have received a copy of the GNU General Public License version +dnl 2 along with this work; if not, write to the Free Software Foundation, +dnl Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +dnl +dnl Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +dnl or visit www.oracle.com if you need additional information or have any +dnl questions. +dnl +// BEGIN This section of the file is automatically generated. Do not edit -------------- + +// This section is generated from g1_aarch64.m4 + +define(`STOREP_INSN', +` +// This pattern is generated automatically from g1_aarch64.m4. +// DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE +instruct g1StoreP$1(indirect mem, iRegP src, iRegPNoSp tmp1, iRegPNoSp tmp2, iRegPNoSp tmp3, rFlagsReg cr) +%{ + predicate(UseG1GC && ifelse($1,Volatile,'needs_releasing_store(n)`,'!needs_releasing_store(n)`) && n->as_Store()->barrier_data() != 0); + match(Set mem (StoreP mem src)); + effect(TEMP tmp1, TEMP tmp2, TEMP tmp3, KILL cr); + ins_cost(ifelse($1,Volatile,VOLATILE_REF_COST,INSN_COST)); + format %{ "$2 $src, $mem\t# ptr" %} + ins_encode %{ + write_barrier_pre(masm, this, + $mem$$Register /* obj */, + $tmp1$$Register /* pre_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */, + RegSet::of($mem$$Register, $src$$Register) /* preserve */); + __ $2($src$$Register, $mem$$Register); + write_barrier_post(masm, this, + $mem$$Register /* store_addr */, + $src$$Register /* new_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */); + %} + ins_pipe(ifelse($1,Volatile,pipe_class_memory,istore_reg_mem)); +%}')dnl +STOREP_INSN(,str) +STOREP_INSN(Volatile,stlr) +dnl +define(`STOREN_INSN', +` +// This pattern is generated automatically from g1_aarch64.m4. +// DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE +instruct g1StoreN$1(indirect mem, iRegN src, iRegPNoSp tmp1, iRegPNoSp tmp2, iRegPNoSp tmp3, rFlagsReg cr) +%{ + predicate(UseG1GC && ifelse($1,Volatile,'needs_releasing_store(n)`,'!needs_releasing_store(n)`) && n->as_Store()->barrier_data() != 0); + match(Set mem (StoreN mem src)); + effect(TEMP tmp1, TEMP tmp2, TEMP tmp3, KILL cr); + ins_cost(ifelse($1,Volatile,VOLATILE_REF_COST,INSN_COST)); + format %{ "$2 $src, $mem\t# compressed ptr" %} + ins_encode %{ + write_barrier_pre(masm, this, + $mem$$Register /* obj */, + $tmp1$$Register /* pre_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */, + RegSet::of($mem$$Register, $src$$Register) /* preserve */); + __ $2($src$$Register, $mem$$Register); + if ((barrier_data() & G1C2BarrierPost) != 0) { + if ((barrier_data() & G1C2BarrierPostNotNull) == 0) { + __ decode_heap_oop($tmp1$$Register, $src$$Register); + } else { + __ decode_heap_oop_not_null($tmp1$$Register, $src$$Register); + } + } + write_barrier_post(masm, this, + $mem$$Register /* store_addr */, + $tmp1$$Register /* new_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */); + %} + ins_pipe(ifelse($1,Volatile,pipe_class_memory,istore_reg_mem)); +%}')dnl +STOREN_INSN(,strw) +STOREN_INSN(Volatile,stlrw) +dnl +define(`ENCODESTOREN_INSN', +` +// This pattern is generated automatically from g1_aarch64.m4. +// DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE +instruct g1EncodePAndStoreN$1(indirect mem, iRegP src, iRegPNoSp tmp1, iRegPNoSp tmp2, iRegPNoSp tmp3, rFlagsReg cr) +%{ + predicate(UseG1GC && ifelse($1,Volatile,'needs_releasing_store(n)`,'!needs_releasing_store(n)`) && n->as_Store()->barrier_data() != 0); + match(Set mem (StoreN mem (EncodeP src))); + effect(TEMP tmp1, TEMP tmp2, TEMP tmp3, KILL cr); + ins_cost(ifelse($1,Volatile,VOLATILE_REF_COST,INSN_COST)); + format %{ "encode_heap_oop $tmp1, $src\n\t" + "$2 $tmp1, $mem\t# compressed ptr" %} + ins_encode %{ + write_barrier_pre(masm, this, + $mem$$Register /* obj */, + $tmp1$$Register /* pre_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */, + RegSet::of($mem$$Register, $src$$Register) /* preserve */); + if ((barrier_data() & G1C2BarrierPostNotNull) == 0) { + __ encode_heap_oop($tmp1$$Register, $src$$Register); + } else { + __ encode_heap_oop_not_null($tmp1$$Register, $src$$Register); + } + __ $2($tmp1$$Register, $mem$$Register); + write_barrier_post(masm, this, + $mem$$Register /* store_addr */, + $src$$Register /* new_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */); + %} + ins_pipe(ifelse($1,Volatile,pipe_class_memory,istore_reg_mem)); +%}')dnl +ENCODESTOREN_INSN(,strw) +ENCODESTOREN_INSN(Volatile,stlrw) +dnl +define(`CAEP_INSN', +` +// This pattern is generated automatically from g1_aarch64.m4. +// DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE +instruct g1CompareAndExchangeP$1(iRegPNoSp res, indirect mem, iRegP oldval, iRegP newval, iRegPNoSp tmp1, iRegPNoSp tmp2, rFlagsReg cr) +%{ + predicate(UseG1GC && ifelse($1,Acq,'needs_acquiring_load_exclusive(n)`,'!needs_acquiring_load_exclusive(n)`) && n->as_LoadStore()->barrier_data() != 0); + match(Set res (CompareAndExchangeP mem (Binary oldval newval))); + effect(TEMP res, TEMP tmp1, TEMP tmp2, KILL cr); + ins_cost(ifelse($1,Acq,VOLATILE_REF_COST,2 * VOLATILE_REF_COST)); + format %{ "cmpxchg$2 $res = $mem, $oldval, $newval\t# ptr" %} + ins_encode %{ + assert_different_registers($oldval$$Register, $mem$$Register); + assert_different_registers($newval$$Register, $mem$$Register); + // Pass $oldval to the pre-barrier (instead of loading from $mem), because + // $oldval is the only value that can be overwritten. + // The same holds for g1CompareAndSwapP and its Acq variant. + write_barrier_pre(masm, this, + noreg /* obj */, + $oldval$$Register /* pre_val */, + $tmp1$$Register /* tmp1 */, + $tmp2$$Register /* tmp2 */, + RegSet::of($mem$$Register, $oldval$$Register, $newval$$Register) /* preserve */, + RegSet::of($res$$Register) /* no_preserve */); + __ cmpxchg($mem$$Register, $oldval$$Register, $newval$$Register, Assembler::xword, + $3 /* acquire */, true /* release */, false /* weak */, $res$$Register); + write_barrier_post(masm, this, + $mem$$Register /* store_addr */, + $newval$$Register /* new_val */, + $tmp1$$Register /* tmp1 */, + $tmp2$$Register /* tmp2 */); + %} + ins_pipe(pipe_slow); +%}')dnl +CAEP_INSN(,,false) +CAEP_INSN(Acq,_acq,true) +dnl +define(`CAEN_INSN', +` +// This pattern is generated automatically from g1_aarch64.m4. +// DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE +instruct g1CompareAndExchangeN$1(iRegNNoSp res, indirect mem, iRegN oldval, iRegN newval, iRegPNoSp tmp1, iRegPNoSp tmp2, iRegPNoSp tmp3, rFlagsReg cr) +%{ + predicate(UseG1GC && ifelse($1,Acq,'needs_acquiring_load_exclusive(n)`,'!needs_acquiring_load_exclusive(n)`) && n->as_LoadStore()->barrier_data() != 0); + match(Set res (CompareAndExchangeN mem (Binary oldval newval))); + effect(TEMP res, TEMP tmp1, TEMP tmp2, TEMP tmp3, KILL cr); + ins_cost(ifelse($1,Acq,VOLATILE_REF_COST,2 * VOLATILE_REF_COST)); + format %{ "cmpxchg$2 $res = $mem, $oldval, $newval\t# narrow oop" %} + ins_encode %{ + assert_different_registers($oldval$$Register, $mem$$Register); + assert_different_registers($newval$$Register, $mem$$Register); + write_barrier_pre(masm, this, + $mem$$Register /* obj */, + $tmp1$$Register /* pre_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */, + RegSet::of($mem$$Register, $oldval$$Register, $newval$$Register) /* preserve */, + RegSet::of($res$$Register) /* no_preserve */); + __ cmpxchg($mem$$Register, $oldval$$Register, $newval$$Register, Assembler::word, + $3 /* acquire */, true /* release */, false /* weak */, $res$$Register); + __ decode_heap_oop($tmp1$$Register, $newval$$Register); + write_barrier_post(masm, this, + $mem$$Register /* store_addr */, + $tmp1$$Register /* new_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */); + %} + ins_pipe(pipe_slow); +%}')dnl +CAEN_INSN(,,false) +CAEN_INSN(Acq,_acq,true) +dnl +define(`CASP_INSN', +` +// This pattern is generated automatically from g1_aarch64.m4. +// DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE +instruct g1CompareAndSwapP$1(iRegINoSp res, indirect mem, iRegP newval, iRegPNoSp tmp1, iRegPNoSp tmp2, iRegP oldval, rFlagsReg cr) +%{ + predicate(UseG1GC && ifelse($1,Acq,'needs_acquiring_load_exclusive(n)`,'!needs_acquiring_load_exclusive(n)`) && n->as_LoadStore()->barrier_data() != 0); + match(Set res (CompareAndSwapP mem (Binary oldval newval))); + match(Set res (WeakCompareAndSwapP mem (Binary oldval newval))); + effect(TEMP res, TEMP tmp1, TEMP tmp2, KILL cr); + ins_cost(ifelse($1,Acq,VOLATILE_REF_COST,2 * VOLATILE_REF_COST)); + format %{ "cmpxchg$2 $mem, $oldval, $newval\t# (ptr)\n\t" + "cset $res, EQ" %} + ins_encode %{ + assert_different_registers($oldval$$Register, $mem$$Register); + assert_different_registers($newval$$Register, $mem$$Register); + write_barrier_pre(masm, this, + noreg /* obj */, + $oldval$$Register /* pre_val */, + $tmp1$$Register /* tmp1 */, + $tmp2$$Register /* tmp2 */, + RegSet::of($mem$$Register, $oldval$$Register, $newval$$Register) /* preserve */, + RegSet::of($res$$Register) /* no_preserve */); + __ cmpxchg($mem$$Register, $oldval$$Register, $newval$$Register, Assembler::xword, + $3 /* acquire */, true /* release */, false /* weak */, noreg); + __ cset($res$$Register, Assembler::EQ); + write_barrier_post(masm, this, + $mem$$Register /* store_addr */, + $newval$$Register /* new_val */, + $tmp1$$Register /* tmp1 */, + $tmp2$$Register /* tmp2 */); + %} + ins_pipe(pipe_slow); +%}')dnl +CASP_INSN(,,false) +CASP_INSN(Acq,_acq,true) +dnl +define(`CASN_INSN', +` +// This pattern is generated automatically from g1_aarch64.m4. +// DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE +instruct g1CompareAndSwapN$1(iRegINoSp res, indirect mem, iRegN newval, iRegPNoSp tmp1, iRegPNoSp tmp2, iRegPNoSp tmp3, iRegN oldval, rFlagsReg cr) +%{ + predicate(UseG1GC && ifelse($1,Acq,'needs_acquiring_load_exclusive(n)`,'!needs_acquiring_load_exclusive(n)`) && n->as_LoadStore()->barrier_data() != 0); + match(Set res (CompareAndSwapN mem (Binary oldval newval))); + match(Set res (WeakCompareAndSwapN mem (Binary oldval newval))); + effect(TEMP res, TEMP tmp1, TEMP tmp2, TEMP tmp3, KILL cr); + ins_cost(ifelse($1,Acq,VOLATILE_REF_COST,2 * VOLATILE_REF_COST)); + format %{ "cmpxchg$2 $mem, $oldval, $newval\t# (narrow oop)\n\t" + "cset $res, EQ" %} + ins_encode %{ + assert_different_registers($oldval$$Register, $mem$$Register); + assert_different_registers($newval$$Register, $mem$$Register); + write_barrier_pre(masm, this, + $mem$$Register /* obj */, + $tmp1$$Register /* pre_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */, + RegSet::of($mem$$Register, $oldval$$Register, $newval$$Register) /* preserve */, + RegSet::of($res$$Register) /* no_preserve */); + __ cmpxchg($mem$$Register, $oldval$$Register, $newval$$Register, Assembler::word, + $3 /* acquire */, true /* release */, false /* weak */, noreg); + __ cset($res$$Register, Assembler::EQ); + __ decode_heap_oop($tmp1$$Register, $newval$$Register); + write_barrier_post(masm, this, + $mem$$Register /* store_addr */, + $tmp1$$Register /* new_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */); + %} + ins_pipe(pipe_slow); +%}')dnl +CASN_INSN(,,false) +CASN_INSN(Acq,_acq,true) +dnl +define(`XCHGP_INSN', +` +// This pattern is generated automatically from g1_aarch64.m4. +// DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE +instruct g1GetAndSetP$1(indirect mem, iRegP newval, iRegPNoSp tmp1, iRegPNoSp tmp2, iRegPNoSp preval, rFlagsReg cr) +%{ + predicate(UseG1GC && ifelse($1,Acq,'needs_acquiring_load_exclusive(n)`,'!needs_acquiring_load_exclusive(n)`) && n->as_LoadStore()->barrier_data() != 0); + match(Set preval (GetAndSetP mem newval)); + effect(TEMP preval, TEMP tmp1, TEMP tmp2, KILL cr); + ins_cost(ifelse($1,Acq,VOLATILE_REF_COST,2 * VOLATILE_REF_COST)); + format %{ "atomic_xchg$2 $preval, $newval, [$mem]" %} + ins_encode %{ + assert_different_registers($mem$$Register, $newval$$Register); + write_barrier_pre(masm, this, + $mem$$Register /* obj */, + $preval$$Register /* pre_val (as a temporary register) */, + $tmp1$$Register /* tmp1 */, + $tmp2$$Register /* tmp2 */, + RegSet::of($mem$$Register, $preval$$Register, $newval$$Register) /* preserve */); + __ $3($preval$$Register, $newval$$Register, $mem$$Register); + write_barrier_post(masm, this, + $mem$$Register /* store_addr */, + $newval$$Register /* new_val */, + $tmp1$$Register /* tmp1 */, + $tmp2$$Register /* tmp2 */); + %} + ins_pipe(pipe_serial); +%}')dnl +XCHGP_INSN(,,atomic_xchg) +XCHGP_INSN(Acq,_acq,atomic_xchgal) +dnl +define(`XCHGN_INSN', +` +// This pattern is generated automatically from g1_aarch64.m4. +// DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE +instruct g1GetAndSetN$1(indirect mem, iRegN newval, iRegPNoSp tmp1, iRegPNoSp tmp2, iRegPNoSp tmp3, iRegNNoSp preval, rFlagsReg cr) +%{ + predicate(UseG1GC && ifelse($1,Acq,'needs_acquiring_load_exclusive(n)`,'!needs_acquiring_load_exclusive(n)`) && n->as_LoadStore()->barrier_data() != 0); + match(Set preval (GetAndSetN mem newval)); + effect(TEMP preval, TEMP tmp1, TEMP tmp2, TEMP tmp3, KILL cr); + ins_cost(ifelse($1,Acq,VOLATILE_REF_COST,2 * VOLATILE_REF_COST)); + format %{ "$2 $preval, $newval, [$mem]" %} + ins_encode %{ + assert_different_registers($mem$$Register, $newval$$Register); + write_barrier_pre(masm, this, + $mem$$Register /* obj */, + $tmp1$$Register /* pre_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */, + RegSet::of($mem$$Register, $preval$$Register, $newval$$Register) /* preserve */); + __ $3($preval$$Register, $newval$$Register, $mem$$Register); + __ decode_heap_oop($tmp1$$Register, $newval$$Register); + write_barrier_post(masm, this, + $mem$$Register /* store_addr */, + $tmp1$$Register /* new_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */); + %} + ins_pipe(pipe_serial); +%}')dnl +XCHGN_INSN(,atomic_xchgw,atomic_xchgw) +XCHGN_INSN(Acq,atomic_xchgw_acq,atomic_xchgalw) + +// This pattern is generated automatically from g1_aarch64.m4. +// DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE +instruct g1LoadP(iRegPNoSp dst, indirect mem, iRegPNoSp tmp1, iRegPNoSp tmp2, rFlagsReg cr) +%{ + // This instruction does not need an acquiring counterpart because it is only + // used for reference loading (Reference::get()). The same holds for g1LoadN. + predicate(UseG1GC && !needs_acquiring_load(n) && n->as_Load()->barrier_data() != 0); + match(Set dst (LoadP mem)); + effect(TEMP dst, TEMP tmp1, TEMP tmp2, KILL cr); + ins_cost(4 * INSN_COST); + format %{ "ldr $dst, $mem\t# ptr" %} + ins_encode %{ + __ ldr($dst$$Register, $mem$$Register); + write_barrier_pre(masm, this, + noreg /* obj */, + $dst$$Register /* pre_val */, + $tmp1$$Register /* tmp1 */, + $tmp2$$Register /* tmp2 */); + %} + ins_pipe(iload_reg_mem); +%} + +// This pattern is generated automatically from g1_aarch64.m4. +// DO NOT EDIT ANYTHING IN THIS SECTION OF THE FILE +instruct g1LoadN(iRegNNoSp dst, indirect mem, iRegPNoSp tmp1, iRegPNoSp tmp2, iRegPNoSp tmp3, rFlagsReg cr) +%{ + predicate(UseG1GC && !needs_acquiring_load(n) && n->as_Load()->barrier_data() != 0); + match(Set dst (LoadN mem)); + effect(TEMP dst, TEMP tmp1, TEMP tmp2, TEMP tmp3, KILL cr); + ins_cost(4 * INSN_COST); + format %{ "ldrw $dst, $mem\t# compressed ptr" %} + ins_encode %{ + __ ldrw($dst$$Register, $mem$$Register); + if ((barrier_data() & G1C2BarrierPre) != 0) { + __ decode_heap_oop($tmp1$$Register, $dst$$Register); + write_barrier_pre(masm, this, + noreg /* obj */, + $tmp1$$Register /* pre_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */); + } + %} + ins_pipe(iload_reg_mem); +%} + +// END This section of the file is automatically generated. Do not edit -------------- diff --git a/src/hotspot/cpu/aarch64/gc/shenandoah/shenandoahBarrierSetAssembler_aarch64.cpp b/src/hotspot/cpu/aarch64/gc/shenandoah/shenandoahBarrierSetAssembler_aarch64.cpp index 06f43820156..84d06dbcc7b 100644 --- a/src/hotspot/cpu/aarch64/gc/shenandoah/shenandoahBarrierSetAssembler_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/gc/shenandoah/shenandoahBarrierSetAssembler_aarch64.cpp @@ -67,9 +67,9 @@ void ShenandoahBarrierSetAssembler::arraycopy_prologue(MacroAssembler* masm, Dec __ push(saved_regs, sp); if (UseCompressedOops) { - __ call_VM_leaf(CAST_FROM_FN_PTR(address, ShenandoahRuntime::arraycopy_barrier_narrow_oop_entry), src, dst, count); + __ call_VM_leaf(CAST_FROM_FN_PTR(address, ShenandoahRuntime::arraycopy_barrier_narrow_oop), src, dst, count); } else { - __ call_VM_leaf(CAST_FROM_FN_PTR(address, ShenandoahRuntime::arraycopy_barrier_oop_entry), src, dst, count); + __ call_VM_leaf(CAST_FROM_FN_PTR(address, ShenandoahRuntime::arraycopy_barrier_oop), src, dst, count); } __ pop(saved_regs, sp); __ bind(done); @@ -164,9 +164,9 @@ void ShenandoahBarrierSetAssembler::satb_write_barrier_pre(MacroAssembler* masm, if (expand_call) { assert(pre_val != c_rarg1, "smashed arg"); - __ super_call_VM_leaf(CAST_FROM_FN_PTR(address, ShenandoahRuntime::write_ref_field_pre_entry), pre_val, thread); + __ super_call_VM_leaf(CAST_FROM_FN_PTR(address, ShenandoahRuntime::write_ref_field_pre), pre_val, thread); } else { - __ call_VM_leaf(CAST_FROM_FN_PTR(address, ShenandoahRuntime::write_ref_field_pre_entry), pre_val, thread); + __ call_VM_leaf(CAST_FROM_FN_PTR(address, ShenandoahRuntime::write_ref_field_pre), pre_val, thread); } __ pop(saved, sp); @@ -698,7 +698,7 @@ void ShenandoahBarrierSetAssembler::generate_c1_pre_barrier_runtime_stub(StubAss __ bind(runtime); __ push_call_clobbered_registers(); __ load_parameter(0, pre_val); - __ call_VM_leaf(CAST_FROM_FN_PTR(address, ShenandoahRuntime::write_ref_field_pre_entry), pre_val, thread); + __ call_VM_leaf(CAST_FROM_FN_PTR(address, ShenandoahRuntime::write_ref_field_pre), pre_val, thread); __ pop_call_clobbered_registers(); __ bind(done); diff --git a/src/hotspot/cpu/aarch64/gc/x/x_aarch64.ad b/src/hotspot/cpu/aarch64/gc/x/x_aarch64.ad index 5e690a8e47b..6e401724baa 100644 --- a/src/hotspot/cpu/aarch64/gc/x/x_aarch64.ad +++ b/src/hotspot/cpu/aarch64/gc/x/x_aarch64.ad @@ -51,7 +51,7 @@ static void x_load_barrier_slow_path(MacroAssembler* masm, const MachNode* node, %} // Load Pointer -instruct xLoadP(iRegPNoSp dst, memory mem, rFlagsReg cr) +instruct xLoadP(iRegPNoSp dst, memory8 mem, rFlagsReg cr) %{ match(Set dst (LoadP mem)); predicate(UseZGC && !ZGenerational && !needs_acquiring_load(n) && (n->as_Load()->barrier_data() != 0)); diff --git a/src/hotspot/cpu/aarch64/gc/z/zAddress_aarch64.cpp b/src/hotspot/cpu/aarch64/gc/z/zAddress_aarch64.cpp index cd834969e1a..fcec3ae64fd 100644 --- a/src/hotspot/cpu/aarch64/gc/z/zAddress_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/gc/z/zAddress_aarch64.cpp @@ -93,7 +93,7 @@ static size_t probe_valid_max_address_bit() { } size_t ZPlatformAddressOffsetBits() { - const static size_t valid_max_address_offset_bits = probe_valid_max_address_bit() + 1; + static const size_t valid_max_address_offset_bits = probe_valid_max_address_bit() + 1; const size_t max_address_offset_bits = valid_max_address_offset_bits - 3; const size_t min_address_offset_bits = max_address_offset_bits - 2; const size_t address_offset = round_up_power_of_2(MaxHeapSize * ZVirtualToPhysicalRatio); diff --git a/src/hotspot/cpu/aarch64/gc/z/z_aarch64.ad b/src/hotspot/cpu/aarch64/gc/z/z_aarch64.ad index 1510b42bfe9..56d45384779 100644 --- a/src/hotspot/cpu/aarch64/gc/z/z_aarch64.ad +++ b/src/hotspot/cpu/aarch64/gc/z/z_aarch64.ad @@ -100,7 +100,7 @@ static void z_store_barrier(MacroAssembler* masm, const MachNode* node, Address %} // Load Pointer -instruct zLoadP(iRegPNoSp dst, memory mem, rFlagsReg cr) +instruct zLoadP(iRegPNoSp dst, memory8 mem, rFlagsReg cr) %{ match(Set dst (LoadP mem)); predicate(UseZGC && ZGenerational && !needs_acquiring_load(n) && n->as_Load()->barrier_data() != 0); diff --git a/src/hotspot/cpu/aarch64/interp_masm_aarch64.cpp b/src/hotspot/cpu/aarch64/interp_masm_aarch64.cpp index 117168de0c5..c6af74c3dcd 100644 --- a/src/hotspot/cpu/aarch64/interp_masm_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/interp_masm_aarch64.cpp @@ -690,8 +690,8 @@ void InterpreterMacroAssembler::lock_object(Register lock_reg) if (DiagnoseSyncOnValueBasedClasses != 0) { load_klass(tmp, obj_reg); - ldrw(tmp, Address(tmp, Klass::access_flags_offset())); - tstw(tmp, JVM_ACC_IS_VALUE_BASED_CLASS); + ldrb(tmp, Address(tmp, Klass::misc_flags_offset())); + tst(tmp, KlassFlags::_misc_is_value_based_class); br(Assembler::NE, slow_case); } diff --git a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp index d09ef26cef9..9835fb5aca1 100644 --- a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp @@ -1838,7 +1838,8 @@ void MacroAssembler::clinit_barrier(Register klass, Register scratch, Label* L_f L_slow_path = &L_fallthrough; } // Fast path check: class is fully initialized - ldrb(scratch, Address(klass, InstanceKlass::init_state_offset())); + lea(scratch, Address(klass, InstanceKlass::init_state_offset())); + ldarb(scratch, scratch); subs(zr, scratch, InstanceKlass::fully_initialized); br(Assembler::EQ, *L_fast_path); @@ -2967,7 +2968,7 @@ void MacroAssembler::verify_heapbase(const char* msg) { if (CheckCompressedOops) { Label ok; push(1 << rscratch1->encoding(), sp); // cmpptr trashes rscratch1 - cmpptr(rheapbase, ExternalAddress(CompressedOops::ptrs_base_addr())); + cmpptr(rheapbase, ExternalAddress(CompressedOops::base_addr())); br(Assembler::EQ, ok); stop(msg); bind(ok); @@ -3133,9 +3134,9 @@ void MacroAssembler::reinit_heapbase() { if (UseCompressedOops) { if (Universe::is_fully_initialized()) { - mov(rheapbase, CompressedOops::ptrs_base()); + mov(rheapbase, CompressedOops::base()); } else { - lea(rheapbase, ExternalAddress(CompressedOops::ptrs_base_addr())); + lea(rheapbase, ExternalAddress(CompressedOops::base_addr())); ldr(rheapbase, Address(rheapbase)); } } @@ -5010,8 +5011,10 @@ void MacroAssembler::decode_heap_oop(Register d, Register s) { verify_heapbase("MacroAssembler::decode_heap_oop: heap base corrupted?"); #endif if (CompressedOops::base() == nullptr) { - if (CompressedOops::shift() != 0 || d != s) { + if (CompressedOops::shift() != 0) { lsl(d, s, CompressedOops::shift()); + } else if (d != s) { + mov(d, s); } } else { Label done; @@ -5082,8 +5085,8 @@ MacroAssembler::KlassDecodeMode MacroAssembler::klass_decode_mode() { if (operand_valid_for_logical_immediate( /*is32*/false, (uint64_t)CompressedKlassPointers::base())) { - const uint64_t range_mask = - (1ULL << log2i(CompressedKlassPointers::range())) - 1; + const size_t range = CompressedKlassPointers::klass_range_end() - CompressedKlassPointers::base(); + const uint64_t range_mask = (1ULL << log2i(range)) - 1; if (((uint64_t)CompressedKlassPointers::base() & range_mask) == 0) { return (_klass_decode_mode = KlassDecodeXor); } diff --git a/src/hotspot/cpu/aarch64/methodHandles_aarch64.cpp b/src/hotspot/cpu/aarch64/methodHandles_aarch64.cpp index 68800d04d69..aa6a9d14ff1 100644 --- a/src/hotspot/cpu/aarch64/methodHandles_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/methodHandles_aarch64.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -27,6 +27,7 @@ #include "asm/macroAssembler.hpp" #include "classfile/javaClasses.inline.hpp" #include "classfile/vmClasses.hpp" +#include "compiler/disassembler.hpp" #include "interpreter/interpreter.hpp" #include "interpreter/interpreterRuntime.hpp" #include "memory/allocation.inline.hpp" @@ -36,7 +37,7 @@ #include "runtime/frame.inline.hpp" #include "runtime/stubRoutines.hpp" -#define __ _masm-> +#define __ Disassembler::hook(__FILE__, __LINE__, _masm)-> #ifdef PRODUCT #define BLOCK_COMMENT(str) /* nothing */ diff --git a/src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp b/src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp index 901ae502999..52996f4c4a5 100644 --- a/src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp @@ -49,6 +49,7 @@ #include "runtime/sharedRuntime.hpp" #include "runtime/signature.hpp" #include "runtime/stubRoutines.hpp" +#include "runtime/timerTrace.hpp" #include "runtime/vframeArray.hpp" #include "utilities/align.hpp" #include "utilities/formatBuffer.hpp" @@ -2181,7 +2182,8 @@ void SharedRuntime::generate_deopt_blob() { pad += 512; // Increase the buffer size when compiling for JVMCI } #endif - CodeBuffer buffer("deopt_blob", 2048+pad, 1024); + const char* name = SharedRuntime::stub_name(SharedStubId::deopt_id); + CodeBuffer buffer(name, 2048+pad, 1024); MacroAssembler* masm = new MacroAssembler(&buffer); int frame_size_in_words; OopMap* map = nullptr; @@ -2232,7 +2234,7 @@ void SharedRuntime::generate_deopt_blob() { int reexecute_offset = __ pc() - start; #if INCLUDE_JVMCI && !defined(COMPILER1) - if (EnableJVMCI && UseJVMCICompiler) { + if (UseJVMCICompiler) { // JVMCI does not use this kind of deoptimization __ should_not_reach_here(); } @@ -2565,20 +2567,23 @@ uint SharedRuntime::out_preserve_stack_slots() { // Generate a special Compile2Runtime blob that saves all registers, // and setup oopmap. // -SafepointBlob* SharedRuntime::generate_handler_blob(address call_ptr, int poll_type) { +SafepointBlob* SharedRuntime::generate_handler_blob(SharedStubId id, address call_ptr) { + assert(is_polling_page_id(id), "expected a polling page stub id"); + ResourceMark rm; OopMapSet *oop_maps = new OopMapSet(); OopMap* map; // Allocate space for the code. Setup code generation tools. - CodeBuffer buffer("handler_blob", 2048, 1024); + const char* name = SharedRuntime::stub_name(id); + CodeBuffer buffer(name, 2048, 1024); MacroAssembler* masm = new MacroAssembler(&buffer); address start = __ pc(); address call_pc = nullptr; int frame_size_in_words; - bool cause_return = (poll_type == POLL_AT_RETURN); - RegisterSaver reg_save(poll_type == POLL_AT_VECTOR_LOOP /* save_vectors */); + bool cause_return = (id == SharedStubId::polling_page_return_handler_id); + RegisterSaver reg_save(id == SharedStubId::polling_page_vectors_safepoint_handler_id /* save_vectors */); // When the signal occurred, the LR was either signed and stored on the stack (in which // case it will be restored from the stack before being used) or unsigned and not stored @@ -2690,12 +2695,14 @@ SafepointBlob* SharedRuntime::generate_handler_blob(address call_ptr, int poll_t // but since this is generic code we don't know what they are and the caller // must do any gc of the args. // -RuntimeStub* SharedRuntime::generate_resolve_blob(address destination, const char* name) { +RuntimeStub* SharedRuntime::generate_resolve_blob(SharedStubId id, address destination) { assert (StubRoutines::forward_exception_entry() != nullptr, "must be generated before"); + assert(is_resolve_id(id), "expected a resolve stub id"); // allocate space for the code ResourceMark rm; + const char* name = SharedRuntime::stub_name(id); CodeBuffer buffer(name, 1000, 512); MacroAssembler* masm = new MacroAssembler(&buffer); @@ -2787,7 +2794,11 @@ RuntimeStub* SharedRuntime::generate_resolve_blob(address destination, const cha // otherwise assume that stack unwinding will be initiated, so // caller saved registers were assumed volatile in the compiler. -RuntimeStub* SharedRuntime::generate_throw_exception(const char* name, address runtime_entry) { +RuntimeStub* SharedRuntime::generate_throw_exception(SharedStubId id, address runtime_entry) { + assert(is_throw_id(id), "expected a throw stub id"); + + const char* name = SharedRuntime::stub_name(id); + // Information about frame layout at time of blocking runtime call. // Note that we only have to preserve callee-saved registers since // the compilers are responsible for supplying a continuation point @@ -2896,7 +2907,8 @@ RuntimeStub* SharedRuntime::generate_jfr_write_checkpoint() { int insts_size = 1024; int locs_size = 64; - CodeBuffer code("jfr_write_checkpoint", insts_size, locs_size); + const char* name = SharedRuntime::stub_name(SharedStubId::jfr_write_checkpoint_id); + CodeBuffer code(name, insts_size, locs_size); OopMapSet* oop_maps = new OopMapSet(); MacroAssembler* masm = new MacroAssembler(&code); @@ -2915,7 +2927,7 @@ RuntimeStub* SharedRuntime::generate_jfr_write_checkpoint() { oop_maps->add_gc_map(the_pc - start, map); RuntimeStub* stub = // codeBlob framesize is in words (not VMRegImpl::slot_size) - RuntimeStub::new_runtime_stub("jfr_write_checkpoint", &code, frame_complete, + RuntimeStub::new_runtime_stub(name, &code, frame_complete, (framesize >> (LogBytesPerWord - LogBytesPerInt)), oop_maps, false); return stub; @@ -2934,7 +2946,8 @@ RuntimeStub* SharedRuntime::generate_jfr_return_lease() { int insts_size = 1024; int locs_size = 64; - CodeBuffer code("jfr_return_lease", insts_size, locs_size); + const char* name = SharedRuntime::stub_name(SharedStubId::jfr_return_lease_id); + CodeBuffer code(name, insts_size, locs_size); OopMapSet* oop_maps = new OopMapSet(); MacroAssembler* masm = new MacroAssembler(&code); @@ -2953,7 +2966,7 @@ RuntimeStub* SharedRuntime::generate_jfr_return_lease() { oop_maps->add_gc_map(the_pc - start, map); RuntimeStub* stub = // codeBlob framesize is in words (not VMRegImpl::slot_size) - RuntimeStub::new_runtime_stub("jfr_return_lease", &code, frame_complete, + RuntimeStub::new_runtime_stub(name, &code, frame_complete, (framesize >> (LogBytesPerWord - LogBytesPerInt)), oop_maps, false); return stub; diff --git a/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp b/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp index b3513a586de..31116e006f0 100644 --- a/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp @@ -3417,15 +3417,15 @@ class StubGenerator: public StubCodeGenerator { Register rscratch3 = r10; Register rscratch4 = r11; - __ andw(rscratch3, r2, r4); - __ bicw(rscratch4, r3, r4); reg_cache.extract_u32(rscratch1, k); __ movw(rscratch2, t); - __ orrw(rscratch3, rscratch3, rscratch4); __ addw(rscratch4, r1, rscratch2); __ addw(rscratch4, rscratch4, rscratch1); - __ addw(rscratch3, rscratch3, rscratch4); - __ rorw(rscratch2, rscratch3, 32 - s); + __ bicw(rscratch2, r3, r4); + __ andw(rscratch3, r2, r4); + __ addw(rscratch2, rscratch2, rscratch4); + __ addw(rscratch2, rscratch2, rscratch3); + __ rorw(rscratch2, rscratch2, 32 - s); __ addw(r1, rscratch2, r2); } @@ -7320,6 +7320,28 @@ class StubGenerator: public StubCodeGenerator { return start; } + // load Method* target of MethodHandle + // j_rarg0 = jobject receiver + // rmethod = result + address generate_upcall_stub_load_target() { + StubCodeMark mark(this, "StubRoutines", "upcall_stub_load_target"); + address start = __ pc(); + + __ resolve_global_jobject(j_rarg0, rscratch1, rscratch2); + // Load target method from receiver + __ load_heap_oop(rmethod, Address(j_rarg0, java_lang_invoke_MethodHandle::form_offset()), rscratch1, rscratch2); + __ load_heap_oop(rmethod, Address(rmethod, java_lang_invoke_LambdaForm::vmentry_offset()), rscratch1, rscratch2); + __ load_heap_oop(rmethod, Address(rmethod, java_lang_invoke_MemberName::method_offset()), rscratch1, rscratch2); + __ access_load_at(T_ADDRESS, IN_HEAP, rmethod, + Address(rmethod, java_lang_invoke_ResolvedMethodName::vmtarget_offset()), + noreg, noreg); + __ str(rmethod, Address(rthread, JavaThread::callee_target_offset())); // just in case callee is deoptimized + + __ ret(lr); + + return start; + } + #undef __ #define __ masm-> @@ -8241,6 +8263,7 @@ class StubGenerator: public StubCodeGenerator { #endif StubRoutines::_upcall_stub_exception_handler = generate_upcall_stub_exception_handler(); + StubRoutines::_upcall_stub_load_target = generate_upcall_stub_load_target(); StubRoutines::aarch64::set_completed(); // Inidicate that arraycopy and zero_blocks stubs are generated } diff --git a/src/hotspot/cpu/aarch64/templateInterpreterGenerator_aarch64.cpp b/src/hotspot/cpu/aarch64/templateInterpreterGenerator_aarch64.cpp index 38d48b86f23..9894841e933 100644 --- a/src/hotspot/cpu/aarch64/templateInterpreterGenerator_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/templateInterpreterGenerator_aarch64.cpp @@ -26,6 +26,7 @@ #include "precompiled.hpp" #include "asm/macroAssembler.inline.hpp" #include "classfile/javaClasses.hpp" +#include "compiler/disassembler.hpp" #include "compiler/compiler_globals.hpp" #include "gc/shared/barrierSetAssembler.hpp" #include "interpreter/bytecodeHistogram.hpp" @@ -67,13 +68,7 @@ // Max size with JVMTI int TemplateInterpreter::InterpreterCodeSize = 200 * 1024; -#define __ _masm-> - -//----------------------------------------------------------------------------- - -extern "C" void entry(CodeBuffer*); - -//----------------------------------------------------------------------------- +#define __ Disassembler::hook(__FILE__, __LINE__, _masm)-> address TemplateInterpreterGenerator::generate_slow_signature_handler() { address entry = __ pc(); @@ -2004,13 +1999,21 @@ void TemplateInterpreterGenerator::set_vtos_entry_points(Template* t, address& vep) { assert(t->is_valid() && t->tos_in() == vtos, "illegal template"); Label L; - aep = __ pc(); __ push_ptr(); __ b(L); - fep = __ pc(); __ push_f(); __ b(L); - dep = __ pc(); __ push_d(); __ b(L); - lep = __ pc(); __ push_l(); __ b(L); - bep = cep = sep = - iep = __ pc(); __ push_i(); - vep = __ pc(); + aep = __ pc(); // atos entry point + __ push_ptr(); + __ b(L); + fep = __ pc(); // ftos entry point + __ push_f(); + __ b(L); + dep = __ pc(); // dtos entry point + __ push_d(); + __ b(L); + lep = __ pc(); // ltos entry point + __ push_l(); + __ b(L); + bep = cep = sep = iep = __ pc(); // [bcsi]tos entry point + __ push_i(); + vep = __ pc(); // vtos entry point __ bind(L); generate_and_dispatch(t); } diff --git a/src/hotspot/cpu/aarch64/templateTable_aarch64.cpp b/src/hotspot/cpu/aarch64/templateTable_aarch64.cpp index f7cf9938157..48ff356f9a5 100644 --- a/src/hotspot/cpu/aarch64/templateTable_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/templateTable_aarch64.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -25,6 +25,7 @@ #include "precompiled.hpp" #include "asm/macroAssembler.inline.hpp" +#include "compiler/disassembler.hpp" #include "compiler/compilerDefinitions.inline.hpp" #include "gc/shared/barrierSetAssembler.hpp" #include "gc/shared/collectedHeap.hpp" @@ -49,7 +50,7 @@ #include "runtime/synchronizer.hpp" #include "utilities/powerOfTwo.hpp" -#define __ _masm-> +#define __ Disassembler::hook(__FILE__, __LINE__, _masm)-> // Address computation: local variables @@ -2191,9 +2192,9 @@ void TemplateTable::_return(TosState state) __ ldr(c_rarg1, aaddress(0)); __ load_klass(r3, c_rarg1); - __ ldrw(r3, Address(r3, Klass::access_flags_offset())); + __ ldrb(r3, Address(r3, Klass::misc_flags_offset())); Label skip_register_finalizer; - __ tbz(r3, exact_log2(JVM_ACC_HAS_FINALIZER), skip_register_finalizer); + __ tbz(r3, exact_log2(KlassFlags::_misc_has_finalizer), skip_register_finalizer); __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::register_finalizer), c_rarg1); diff --git a/src/hotspot/cpu/aarch64/upcallLinker_aarch64.cpp b/src/hotspot/cpu/aarch64/upcallLinker_aarch64.cpp index 28ec07815be..517fccb2d1a 100644 --- a/src/hotspot/cpu/aarch64/upcallLinker_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/upcallLinker_aarch64.cpp @@ -24,6 +24,7 @@ #include "precompiled.hpp" #include "asm/macroAssembler.hpp" +#include "classfile/javaClasses.hpp" #include "logging/logStream.hpp" #include "memory/resourceArea.hpp" #include "prims/upcallLinker.hpp" @@ -117,7 +118,7 @@ static void restore_callee_saved_registers(MacroAssembler* _masm, const ABIDescr static const int upcall_stub_code_base_size = 1024; static const int upcall_stub_size_per_arg = 16; -address UpcallLinker::make_upcall_stub(jobject receiver, Method* entry, +address UpcallLinker::make_upcall_stub(jobject receiver, Symbol* signature, BasicType* out_sig_bt, int total_out_args, BasicType ret_type, jobject jabi, jobject jconv, @@ -222,7 +223,6 @@ address UpcallLinker::make_upcall_stub(jobject receiver, Method* entry, __ block_comment("{ on_entry"); __ lea(c_rarg0, Address(sp, frame_data_offset)); - __ movptr(c_rarg1, (intptr_t)receiver); __ movptr(rscratch1, CAST_FROM_FN_PTR(uint64_t, UpcallLinker::on_entry)); __ blr(rscratch1); __ mov(rthread, r0); @@ -238,12 +238,10 @@ address UpcallLinker::make_upcall_stub(jobject receiver, Method* entry, arg_shuffle.generate(_masm, as_VMStorage(shuffle_reg), abi._shadow_space_bytes, 0); __ block_comment("} argument shuffle"); - __ block_comment("{ receiver "); - __ get_vm_result(j_rarg0, rthread); - __ block_comment("} receiver "); - - __ mov_metadata(rmethod, entry); - __ str(rmethod, Address(rthread, JavaThread::callee_target_offset())); // just in case callee is deoptimized + __ block_comment("{ load target "); + __ movptr(j_rarg0, (intptr_t)receiver); + __ far_call(RuntimeAddress(StubRoutines::upcall_stub_load_target()), rscratch1); // puts target Method* in rmethod + __ block_comment("} load target "); __ push_cont_fastpath(rthread); @@ -318,7 +316,7 @@ address UpcallLinker::make_upcall_stub(jobject receiver, Method* entry, #ifndef PRODUCT stringStream ss; - ss.print("upcall_stub_%s", entry->signature()->as_C_string()); + ss.print("upcall_stub_%s", signature->as_C_string()); const char* name = _masm->code_string(ss.as_string()); #else // PRODUCT const char* name = "upcall_stub"; diff --git a/src/hotspot/cpu/arm/arm.ad b/src/hotspot/cpu/arm/arm.ad index 2c7de0a58a2..bfca986f350 100644 --- a/src/hotspot/cpu/arm/arm.ad +++ b/src/hotspot/cpu/arm/arm.ad @@ -1003,10 +1003,6 @@ const RegMask* Matcher::predicate_reg_mask(void) { return nullptr; } -const TypeVectMask* Matcher::predicate_reg_type(const Type* elemTy, int length) { - return nullptr; -} - // Vector calling convention not yet implemented. bool Matcher::supports_vector_calling_convention(void) { return false; @@ -3890,6 +3886,7 @@ instruct loadRange(iRegI dst, memoryI mem) %{ instruct loadP(iRegP dst, memoryP mem) %{ + predicate(!(UseG1GC && n->as_Load()->barrier_data() != 0)); match(Set dst (LoadP mem)); ins_cost(MEMORY_REF_COST); size(4); @@ -4225,18 +4222,6 @@ instruct storeB(memoryB mem, store_RegI src) %{ ins_pipe(istore_mem_reg); %} -instruct storeCM(memoryB mem, store_RegI src) %{ - match(Set mem (StoreCM mem src)); - ins_cost(MEMORY_REF_COST); - - size(4); - format %{ "STRB $src,$mem\t! CMS card-mark byte" %} - ins_encode %{ - __ strb($src$$Register, $mem$$Address); - %} - ins_pipe(istore_mem_reg); -%} - // Store Char/Short @@ -4356,6 +4341,7 @@ instruct movSP(store_ptr_RegP dst, SPRegP src) %{ instruct storeP(memoryP mem, store_ptr_RegP src) %{ + predicate(!(UseG1GC && n->as_Store()->barrier_data() != 0)); match(Set mem (StoreP mem src)); ins_cost(MEMORY_REF_COST); size(4); @@ -5390,6 +5376,7 @@ instruct compareAndSwapI_bool(memoryex mem, iRegI oldval, iRegI newval, iRegI re %} instruct compareAndSwapP_bool(memoryex mem, iRegP oldval, iRegP newval, iRegI res, iRegI tmp, flagsReg ccr ) %{ + predicate(!(UseG1GC && n->as_LoadStore()->barrier_data() != 0)); match(Set res (CompareAndSwapP mem (Binary oldval newval))); effect( KILL ccr, TEMP tmp); size(28); @@ -5659,6 +5646,7 @@ instruct xchgL(memoryex mem, iRegLd newval, iRegLd res, iRegI tmp, flagsReg ccr) %} instruct xchgP(memoryex mem, iRegP newval, iRegP res, iRegI tmp, flagsReg ccr) %{ + predicate(!(UseG1GC && n->as_LoadStore()->barrier_data() != 0)); match(Set res (GetAndSetP mem newval)); effect(KILL ccr, TEMP tmp, TEMP res); size(16); diff --git a/src/hotspot/cpu/arm/assembler_arm_32.hpp b/src/hotspot/cpu/arm/assembler_arm_32.hpp index dd04ad1ab3a..e53eefac097 100644 --- a/src/hotspot/cpu/arm/assembler_arm_32.hpp +++ b/src/hotspot/cpu/arm/assembler_arm_32.hpp @@ -119,8 +119,9 @@ class RegisterSet { } friend RegisterSet operator | (const RegisterSet set1, const RegisterSet set2) { - assert((set1._encoding & set2._encoding) == 0, - "encoding constraint"); +// why so strong constraint? +// assert((set1._encoding & set2._encoding) == 0, +// "encoding constraint"); return RegisterSet(set1._encoding | set2._encoding); } @@ -142,6 +143,11 @@ class RegisterSet { } return count; } + + static RegisterSet from(RegSet set) { + assert(set.size(), "RegSet must not be empty"); + return RegisterSet(set.bits()); + } }; #if R9_IS_SCRATCHED @@ -157,6 +163,10 @@ class FloatRegisterSet { public: + FloatRegisterSet() { + _encoding = 0; + } + FloatRegisterSet(FloatRegister reg) { if (reg->hi_bit() == 0) { _encoding = reg->hi_bits() << 12 | reg->lo_bit() << 22 | 1; @@ -185,6 +195,15 @@ class FloatRegisterSet { return (_encoding & 0xFFFFFF00) | ((_encoding & 0xFF) << 1); } + static FloatRegisterSet from(FloatRegSet set) { + assert(set.size(), "FloatRegSet must not be empty"); + // the vector load/store instructions operate on a set of consecutive registers. + // for the sake of simplicity, write all registers between the first and last in the set + size_t range = (*set.rbegin())->encoding() - (*set.begin())->encoding() + 1; + // push_float stores float regisgters by pairs + return FloatRegisterSet(*set.begin(), (range+1)/2); + } + }; diff --git a/src/hotspot/cpu/arm/c1_CodeStubs_arm.cpp b/src/hotspot/cpu/arm/c1_CodeStubs_arm.cpp index 3d8dbc38071..8e85fa88a87 100644 --- a/src/hotspot/cpu/arm/c1_CodeStubs_arm.cpp +++ b/src/hotspot/cpu/arm/c1_CodeStubs_arm.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,7 +46,7 @@ void CounterOverflowStub::emit_code(LIR_Assembler* ce) { __ bind(_entry); ce->store_parameter(_bci, 0); ce->store_parameter(_method->as_constant_ptr()->as_metadata(), 1); - __ call(Runtime1::entry_for(Runtime1::counter_overflow_id), relocInfo::runtime_call_type); + __ call(Runtime1::entry_for(C1StubId::counter_overflow_id), relocInfo::runtime_call_type); ce->add_call_info_here(_info); ce->verify_oop_map(_info); @@ -57,7 +57,7 @@ void RangeCheckStub::emit_code(LIR_Assembler* ce) { __ bind(_entry); if (_info->deoptimize_on_exception()) { - __ call(Runtime1::entry_for(Runtime1::predicate_failed_trap_id), relocInfo::runtime_call_type); + __ call(Runtime1::entry_for(C1StubId::predicate_failed_trap_id), relocInfo::runtime_call_type); ce->add_call_info_here(_info); ce->verify_oop_map(_info); debug_only(__ should_not_reach_here()); @@ -73,10 +73,10 @@ void RangeCheckStub::emit_code(LIR_Assembler* ce) { } if (_throw_index_out_of_bounds_exception) { - __ call(Runtime1::entry_for(Runtime1::throw_index_exception_id), relocInfo::runtime_call_type); + __ call(Runtime1::entry_for(C1StubId::throw_index_exception_id), relocInfo::runtime_call_type); } else { __ str(_array->as_pointer_register(), Address(SP, BytesPerWord)); // ??? Correct offset? Correct instruction? - __ call(Runtime1::entry_for(Runtime1::throw_range_check_failed_id), relocInfo::runtime_call_type); + __ call(Runtime1::entry_for(C1StubId::throw_range_check_failed_id), relocInfo::runtime_call_type); } ce->add_call_info_here(_info); ce->verify_oop_map(_info); @@ -89,7 +89,7 @@ PredicateFailedStub::PredicateFailedStub(CodeEmitInfo* info) { void PredicateFailedStub::emit_code(LIR_Assembler* ce) { __ bind(_entry); - __ call(Runtime1::entry_for(Runtime1::predicate_failed_trap_id), relocInfo::runtime_call_type); + __ call(Runtime1::entry_for(C1StubId::predicate_failed_trap_id), relocInfo::runtime_call_type); ce->add_call_info_here(_info); ce->verify_oop_map(_info); debug_only(__ should_not_reach_here()); @@ -100,7 +100,7 @@ void DivByZeroStub::emit_code(LIR_Assembler* ce) { ce->compilation()->implicit_exception_table()->append(_offset, __ offset()); } __ bind(_entry); - __ call(Runtime1::entry_for(Runtime1::throw_div0_exception_id), + __ call(Runtime1::entry_for(C1StubId::throw_div0_exception_id), relocInfo::runtime_call_type); ce->add_call_info_here(_info); DEBUG_ONLY(STOP("DivByZero");) @@ -109,14 +109,14 @@ void DivByZeroStub::emit_code(LIR_Assembler* ce) { // Implementation of NewInstanceStub -NewInstanceStub::NewInstanceStub(LIR_Opr klass_reg, LIR_Opr result, ciInstanceKlass* klass, CodeEmitInfo* info, Runtime1::StubID stub_id) { +NewInstanceStub::NewInstanceStub(LIR_Opr klass_reg, LIR_Opr result, ciInstanceKlass* klass, CodeEmitInfo* info, C1StubId stub_id) { _result = result; _klass = klass; _klass_reg = klass_reg; _info = new CodeEmitInfo(info); - assert(stub_id == Runtime1::new_instance_id || - stub_id == Runtime1::fast_new_instance_id || - stub_id == Runtime1::fast_new_instance_init_check_id, + assert(stub_id == C1StubId::new_instance_id || + stub_id == C1StubId::fast_new_instance_id || + stub_id == C1StubId::fast_new_instance_init_check_id, "need new_instance id"); _stub_id = stub_id; } @@ -148,7 +148,7 @@ void NewTypeArrayStub::emit_code(LIR_Assembler* ce) { assert(_klass_reg->as_register() == R1, "runtime call setup"); assert(_length->as_register() == R2, "runtime call setup"); __ bind(_entry); - __ call(Runtime1::entry_for(Runtime1::new_type_array_id), relocInfo::runtime_call_type); + __ call(Runtime1::entry_for(C1StubId::new_type_array_id), relocInfo::runtime_call_type); ce->add_call_info_here(_info); ce->verify_oop_map(_info); __ b(_continuation); @@ -170,7 +170,7 @@ void NewObjectArrayStub::emit_code(LIR_Assembler* ce) { assert(_klass_reg->as_register() == R1, "runtime call setup"); assert(_length->as_register() == R2, "runtime call setup"); __ bind(_entry); - __ call(Runtime1::entry_for(Runtime1::new_object_array_id), relocInfo::runtime_call_type); + __ call(Runtime1::entry_for(C1StubId::new_object_array_id), relocInfo::runtime_call_type); ce->add_call_info_here(_info); ce->verify_oop_map(_info); __ b(_continuation); @@ -189,9 +189,9 @@ void MonitorEnterStub::emit_code(LIR_Assembler* ce) { __ str(lock_reg, Address(SP, BytesPerWord)); } - Runtime1::StubID enter_id = ce->compilation()->has_fpu_code() ? - Runtime1::monitorenter_id : - Runtime1::monitorenter_nofpu_id; + C1StubId enter_id = ce->compilation()->has_fpu_code() ? + C1StubId::monitorenter_id : + C1StubId::monitorenter_nofpu_id; __ call(Runtime1::entry_for(enter_id), relocInfo::runtime_call_type); ce->add_call_info_here(_info); ce->verify_oop_map(_info); @@ -210,9 +210,9 @@ void MonitorExitStub::emit_code(LIR_Assembler* ce) { __ str(lock_reg, Address(SP)); // Non-blocking leaf routine - no call info needed - Runtime1::StubID exit_id = ce->compilation()->has_fpu_code() ? - Runtime1::monitorexit_id : - Runtime1::monitorexit_nofpu_id; + C1StubId exit_id = ce->compilation()->has_fpu_code() ? + C1StubId::monitorexit_id : + C1StubId::monitorexit_nofpu_id; __ call(Runtime1::entry_for(exit_id), relocInfo::runtime_call_type); __ b(_continuation); } @@ -322,10 +322,10 @@ void PatchingStub::emit_code(LIR_Assembler* ce) { address target = nullptr; relocInfo::relocType reloc_type = relocInfo::none; switch (_id) { - case access_field_id: target = Runtime1::entry_for(Runtime1::access_field_patching_id); break; - case load_klass_id: target = Runtime1::entry_for(Runtime1::load_klass_patching_id); reloc_type = relocInfo::metadata_type; break; - case load_mirror_id: target = Runtime1::entry_for(Runtime1::load_mirror_patching_id); reloc_type = relocInfo::oop_type; break; - case load_appendix_id: target = Runtime1::entry_for(Runtime1::load_appendix_patching_id); reloc_type = relocInfo::oop_type; break; + case access_field_id: target = Runtime1::entry_for(C1StubId::access_field_patching_id); break; + case load_klass_id: target = Runtime1::entry_for(C1StubId::load_klass_patching_id); reloc_type = relocInfo::metadata_type; break; + case load_mirror_id: target = Runtime1::entry_for(C1StubId::load_mirror_patching_id); reloc_type = relocInfo::oop_type; break; + case load_appendix_id: target = Runtime1::entry_for(C1StubId::load_appendix_patching_id); reloc_type = relocInfo::oop_type; break; default: ShouldNotReachHere(); } __ bind(call_patch); @@ -351,7 +351,7 @@ void DeoptimizeStub::emit_code(LIR_Assembler* ce) { __ mov_slow(Rtemp, _trap_request); ce->verify_reserved_argument_area_size(1); __ str(Rtemp, Address(SP)); - __ call(Runtime1::entry_for(Runtime1::deoptimize_id), relocInfo::runtime_call_type); + __ call(Runtime1::entry_for(C1StubId::deoptimize_id), relocInfo::runtime_call_type); ce->add_call_info_here(_info); DEBUG_ONLY(__ should_not_reach_here()); } @@ -362,9 +362,9 @@ void ImplicitNullCheckStub::emit_code(LIR_Assembler* ce) { if (_info->deoptimize_on_exception()) { // Deoptimize, do not throw the exception, because it is // probably wrong to do it here. - a = Runtime1::entry_for(Runtime1::predicate_failed_trap_id); + a = Runtime1::entry_for(C1StubId::predicate_failed_trap_id); } else { - a = Runtime1::entry_for(Runtime1::throw_null_pointer_exception_id); + a = Runtime1::entry_for(C1StubId::throw_null_pointer_exception_id); } ce->compilation()->implicit_exception_table()->append(_offset, __ offset()); __ bind(_entry); diff --git a/src/hotspot/cpu/arm/c1_LIRAssembler_arm.cpp b/src/hotspot/cpu/arm/c1_LIRAssembler_arm.cpp index 999f8fe5904..b14e6f0b4ca 100644 --- a/src/hotspot/cpu/arm/c1_LIRAssembler_arm.cpp +++ b/src/hotspot/cpu/arm/c1_LIRAssembler_arm.cpp @@ -213,7 +213,7 @@ int LIR_Assembler::emit_exception_handler() { // check that there is really an exception __ verify_not_null_oop(Rexception_obj); - __ call(Runtime1::entry_for(Runtime1::handle_exception_from_callee_id), relocInfo::runtime_call_type); + __ call(Runtime1::entry_for(C1StubId::handle_exception_from_callee_id), relocInfo::runtime_call_type); __ should_not_reach_here(); assert(code_offset() - offset <= exception_handler_size(), "overflow"); @@ -253,7 +253,7 @@ int LIR_Assembler::emit_unwind_handler() { // remove the activation and dispatch to the unwind handler __ remove_frame(initial_frame_size_in_bytes()); // restores FP and LR - __ jump(Runtime1::entry_for(Runtime1::unwind_exception_id), relocInfo::runtime_call_type, Rtemp); + __ jump(Runtime1::entry_for(C1StubId::unwind_exception_id), relocInfo::runtime_call_type, Rtemp); // Emit the slow path assembly if (stub != nullptr) { @@ -948,6 +948,7 @@ void LIR_Assembler::emit_alloc_obj(LIR_OpAllocObj* op) { if (op->init_check()) { Register tmp = op->tmp1()->as_register(); __ ldrb(tmp, Address(op->klass()->as_register(), InstanceKlass::init_state_offset())); + __ membar(MacroAssembler::Membar_mask_bits(MacroAssembler::LoadLoad | MacroAssembler::LoadStore), Rtemp); add_debug_info_for_null_check_here(op->stub()->info()); __ cmp(tmp, InstanceKlass::fully_initialized); __ b(*op->stub()->entry(), ne); @@ -1136,7 +1137,7 @@ void LIR_Assembler::emit_opTypeCheck(LIR_OpTypeCheck* op) { __ b(*failure_target, ne); // slow case assert(klass_RInfo == R0 && k_RInfo == R1, "runtime call setup"); - __ call(Runtime1::entry_for(Runtime1::slow_subtype_check_id), relocInfo::runtime_call_type); + __ call(Runtime1::entry_for(C1StubId::slow_subtype_check_id), relocInfo::runtime_call_type); __ cbz(R0, *failure_target); if (op->should_profile()) { Register mdo = klass_RInfo, recv = k_RInfo, tmp1 = Rtemp; @@ -1210,7 +1211,7 @@ void LIR_Assembler::emit_opTypeCheck(LIR_OpTypeCheck* op) { __ cmp(Rtemp, k_RInfo, ne); __ b(*success_target, eq); assert(klass_RInfo == R0 && k_RInfo == R1, "runtime call setup"); - __ call(Runtime1::entry_for(Runtime1::slow_subtype_check_id), relocInfo::runtime_call_type); + __ call(Runtime1::entry_for(C1StubId::slow_subtype_check_id), relocInfo::runtime_call_type); __ cbz(R0, *failure_target); } } else { @@ -1227,7 +1228,7 @@ void LIR_Assembler::emit_opTypeCheck(LIR_OpTypeCheck* op) { __ b(*failure_target, ne); // slow case assert(klass_RInfo == R0 && k_RInfo == R1, "runtime call setup"); - __ call(Runtime1::entry_for(Runtime1::slow_subtype_check_id), relocInfo::runtime_call_type); + __ call(Runtime1::entry_for(C1StubId::slow_subtype_check_id), relocInfo::runtime_call_type); __ cbz(R0, *failure_target); } @@ -1303,7 +1304,7 @@ void LIR_Assembler::emit_opTypeCheck(LIR_OpTypeCheck* op) { } __ b(*success_target, eq); assert(klass_RInfo == R0 && k_RInfo == R1, "runtime call setup"); - __ call(Runtime1::entry_for(Runtime1::slow_subtype_check_id), relocInfo::runtime_call_type); + __ call(Runtime1::entry_for(C1StubId::slow_subtype_check_id), relocInfo::runtime_call_type); if (!op->should_profile()) { move_regs(R0, res); } else { @@ -1334,7 +1335,7 @@ void LIR_Assembler::emit_opTypeCheck(LIR_OpTypeCheck* op) { __ b(*failure_target, ne); // slow case assert(klass_RInfo == R0 && k_RInfo == R1, "runtime call setup"); - __ call(Runtime1::entry_for(Runtime1::slow_subtype_check_id), relocInfo::runtime_call_type); + __ call(Runtime1::entry_for(C1StubId::slow_subtype_check_id), relocInfo::runtime_call_type); if (!op->should_profile()) { move_regs(R0, res); } @@ -1981,9 +1982,9 @@ void LIR_Assembler::throw_op(LIR_Opr exceptionPC, LIR_Opr exceptionOop, CodeEmit assert(exceptionPC->as_register() == Rexception_pc, "must match"); info->add_register_oop(exceptionOop); - Runtime1::StubID handle_id = compilation()->has_fpu_code() ? - Runtime1::handle_exception_id : - Runtime1::handle_exception_nofpu_id; + C1StubId handle_id = compilation()->has_fpu_code() ? + C1StubId::handle_exception_id : + C1StubId::handle_exception_nofpu_id; Label return_address; __ adr(Rexception_pc, return_address); __ call(Runtime1::entry_for(handle_id), relocInfo::runtime_call_type); @@ -2260,7 +2261,7 @@ void LIR_Assembler::emit_arraycopy(LIR_OpArrayCopy* op) { __ mov(altFP_7_11, R1); __ mov(R0, tmp); __ mov(R1, tmp2); - __ call(Runtime1::entry_for(Runtime1::slow_subtype_check_id), relocInfo::runtime_call_type); // does not blow any registers except R0, LR and Rtemp + __ call(Runtime1::entry_for(C1StubId::slow_subtype_check_id), relocInfo::runtime_call_type); // does not blow any registers except R0, LR and Rtemp __ cmp_32(R0, 0); __ mov(R0, R6); __ mov(R1, altFP_7_11); diff --git a/src/hotspot/cpu/arm/c1_LIRGenerator_arm.cpp b/src/hotspot/cpu/arm/c1_LIRGenerator_arm.cpp index f4e3812d77c..adda0c1c290 100644 --- a/src/hotspot/cpu/arm/c1_LIRGenerator_arm.cpp +++ b/src/hotspot/cpu/arm/c1_LIRGenerator_arm.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1054,7 +1054,7 @@ void LIRGenerator::do_NewMultiArray(NewMultiArray* x) { args->append(rank); args->append(varargs); LIR_Opr reg = result_register_for(x->type()); - __ call_runtime(Runtime1::entry_for(Runtime1::new_multi_array_id), + __ call_runtime(Runtime1::entry_for(C1StubId::new_multi_array_id), LIR_OprFact::illegalOpr, reg, args, info); LIR_Opr result = rlock_result(x); @@ -1083,7 +1083,7 @@ void LIRGenerator::do_CheckCast(CheckCast* x) { CodeStub* stub; if (x->is_incompatible_class_change_check()) { assert(patching_info == nullptr, "can't patch this"); - stub = new SimpleExceptionStub(Runtime1::throw_incompatible_class_change_error_id, + stub = new SimpleExceptionStub(C1StubId::throw_incompatible_class_change_error_id, LIR_OprFact::illegalOpr, info_for_exception); } else if (x->is_invokespecial_receiver_check()) { assert(patching_info == nullptr, "can't patch this"); @@ -1091,7 +1091,7 @@ void LIRGenerator::do_CheckCast(CheckCast* x) { Deoptimization::Reason_class_check, Deoptimization::Action_none); } else { - stub = new SimpleExceptionStub(Runtime1::throw_class_cast_exception_id, + stub = new SimpleExceptionStub(C1StubId::throw_class_cast_exception_id, LIR_OprFact::illegalOpr, info_for_exception); } diff --git a/src/hotspot/cpu/arm/c1_MacroAssembler_arm.cpp b/src/hotspot/cpu/arm/c1_MacroAssembler_arm.cpp index f1267587ce4..70542d278ac 100644 --- a/src/hotspot/cpu/arm/c1_MacroAssembler_arm.cpp +++ b/src/hotspot/cpu/arm/c1_MacroAssembler_arm.cpp @@ -195,8 +195,8 @@ int C1_MacroAssembler::lock_object(Register hdr, Register obj, Register disp_hdr if (DiagnoseSyncOnValueBasedClasses != 0) { load_klass(tmp2, obj); - ldr_u32(tmp2, Address(tmp2, Klass::access_flags_offset())); - tst(tmp2, JVM_ACC_IS_VALUE_BASED_CLASS); + ldrb(tmp2, Address(tmp2, Klass::misc_flags_offset())); + tst(tmp2, KlassFlags::_misc_is_value_based_class); b(slow_case, ne); } diff --git a/src/hotspot/cpu/arm/c1_Runtime1_arm.cpp b/src/hotspot/cpu/arm/c1_Runtime1_arm.cpp index 9862a074a68..b5117dedc42 100644 --- a/src/hotspot/cpu/arm/c1_Runtime1_arm.cpp +++ b/src/hotspot/cpu/arm/c1_Runtime1_arm.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -65,7 +65,7 @@ int StubAssembler::call_RT(Register oop_result1, Register metadata_result, addre reset_last_Java_frame(Rtemp); assert(frame_size() != no_frame_size, "frame must be fixed"); - if (_stub_id != Runtime1::forward_exception_id) { + if (_stub_id != (int)C1StubId::forward_exception_id) { ldr(R3, Address(Rthread, Thread::pending_exception_offset())); } @@ -81,10 +81,10 @@ int StubAssembler::call_RT(Register oop_result1, Register metadata_result, addre // Check for pending exception // unpack_with_exception_in_tls path is taken through // Runtime1::exception_handler_for_pc - if (_stub_id != Runtime1::forward_exception_id) { + if (_stub_id != (int)C1StubId::forward_exception_id) { assert(frame_size() != no_frame_size, "cannot directly call forward_exception_id"); cmp(R3, 0); - jump(Runtime1::entry_for(Runtime1::forward_exception_id), relocInfo::runtime_call_type, Rtemp, ne); + jump(Runtime1::entry_for(C1StubId::forward_exception_id), relocInfo::runtime_call_type, Rtemp, ne); } else { #ifdef ASSERT // Should not have pending exception in forward_exception stub @@ -280,7 +280,7 @@ static void restore_sp_for_method_handle(StubAssembler* sasm) { } -OopMapSet* Runtime1::generate_handle_exception(StubID id, StubAssembler* sasm) { +OopMapSet* Runtime1::generate_handle_exception(C1StubId id, StubAssembler* sasm) { __ block_comment("generate_handle_exception"); bool save_fpu_registers = false; @@ -290,7 +290,7 @@ OopMapSet* Runtime1::generate_handle_exception(StubID id, StubAssembler* sasm) { OopMap* oop_map = nullptr; switch (id) { - case forward_exception_id: { + case C1StubId::forward_exception_id: { save_fpu_registers = HaveVFP; oop_map = generate_oop_map(sasm); __ ldr(Rexception_obj, Address(Rthread, Thread::pending_exception_offset())); @@ -299,14 +299,14 @@ OopMapSet* Runtime1::generate_handle_exception(StubID id, StubAssembler* sasm) { __ str(zero, Address(Rthread, Thread::pending_exception_offset())); break; } - case handle_exception_id: + case C1StubId::handle_exception_id: save_fpu_registers = HaveVFP; // fall-through - case handle_exception_nofpu_id: + case C1StubId::handle_exception_nofpu_id: // At this point all registers MAY be live. oop_map = save_live_registers(sasm, save_fpu_registers); break; - case handle_exception_from_callee_id: + case C1StubId::handle_exception_from_callee_id: // At this point all registers except exception oop (R4/R19) and // exception pc (R5/R20) are dead. oop_map = save_live_registers(sasm); // TODO it's not required to save all registers @@ -328,13 +328,13 @@ OopMapSet* Runtime1::generate_handle_exception(StubID id, StubAssembler* sasm) { // Restore the registers that were saved at the beginning, remove // frame and jump to the exception handler. switch (id) { - case forward_exception_id: - case handle_exception_nofpu_id: - case handle_exception_id: + case C1StubId::forward_exception_id: + case C1StubId::handle_exception_nofpu_id: + case C1StubId::handle_exception_id: restore_live_registers(sasm, save_fpu_registers); // Note: the restore live registers includes the jump to LR (patched to R0) break; - case handle_exception_from_callee_id: + case C1StubId::handle_exception_from_callee_id: restore_live_registers_without_return(sasm); // must not jump immediately to handler restore_sp_for_method_handle(sasm); __ ret(); @@ -403,7 +403,7 @@ OopMapSet* Runtime1::generate_patching(StubAssembler* sasm, address target) { } -OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { +OopMapSet* Runtime1::generate_code_for(C1StubId id, StubAssembler* sasm) { const bool must_gc_arguments = true; const bool dont_gc_arguments = false; @@ -411,16 +411,16 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { bool save_fpu_registers = HaveVFP; switch (id) { - case forward_exception_id: + case C1StubId::forward_exception_id: { oop_maps = generate_handle_exception(id, sasm); // does not return on ARM } break; - case new_instance_id: - case fast_new_instance_id: - case fast_new_instance_init_check_id: + case C1StubId::new_instance_id: + case C1StubId::fast_new_instance_id: + case C1StubId::fast_new_instance_init_check_id: { const Register result = R0; const Register klass = R1; @@ -436,7 +436,7 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case counter_overflow_id: + case C1StubId::counter_overflow_id: { OopMap* oop_map = save_live_registers(sasm); __ ldr(R1, Address(SP, arg1_offset)); @@ -448,10 +448,10 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case new_type_array_id: - case new_object_array_id: + case C1StubId::new_type_array_id: + case C1StubId::new_object_array_id: { - if (id == new_type_array_id) { + if (id == C1StubId::new_type_array_id) { __ set_info("new_type_array", dont_gc_arguments); } else { __ set_info("new_object_array", dont_gc_arguments); @@ -463,7 +463,7 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { OopMap* map = save_live_registers(sasm); int call_offset; - if (id == new_type_array_id) { + if (id == C1StubId::new_type_array_id) { call_offset = __ call_RT(result, noreg, CAST_FROM_FN_PTR(address, new_type_array), klass, length); } else { call_offset = __ call_RT(result, noreg, CAST_FROM_FN_PTR(address, new_object_array), klass, length); @@ -477,7 +477,7 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case new_multi_array_id: + case C1StubId::new_multi_array_id: { __ set_info("new_multi_array", dont_gc_arguments); @@ -500,15 +500,15 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case register_finalizer_id: + case C1StubId::register_finalizer_id: { __ set_info("register_finalizer", dont_gc_arguments); - // Do not call runtime if JVM_ACC_HAS_FINALIZER flag is not set + // Do not call runtime if has_finalizer flag is not set __ load_klass(Rtemp, R0); - __ ldr_u32(Rtemp, Address(Rtemp, Klass::access_flags_offset())); + __ ldrb(Rtemp, Address(Rtemp, Klass::misc_flags_offset())); - __ tst(Rtemp, JVM_ACC_HAS_FINALIZER); + __ tst(Rtemp, KlassFlags::_misc_has_finalizer); __ bx(LR, eq); // Call VM @@ -521,78 +521,78 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case throw_range_check_failed_id: + case C1StubId::throw_range_check_failed_id: { __ set_info("range_check_failed", dont_gc_arguments); oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_range_check_exception), true); } break; - case throw_index_exception_id: + case C1StubId::throw_index_exception_id: { __ set_info("index_range_check_failed", dont_gc_arguments); oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_index_exception), true); } break; - case throw_div0_exception_id: + case C1StubId::throw_div0_exception_id: { __ set_info("throw_div0_exception", dont_gc_arguments); oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_div0_exception), false); } break; - case throw_null_pointer_exception_id: + case C1StubId::throw_null_pointer_exception_id: { __ set_info("throw_null_pointer_exception", dont_gc_arguments); oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_null_pointer_exception), false); } break; - case handle_exception_nofpu_id: - case handle_exception_id: + case C1StubId::handle_exception_nofpu_id: + case C1StubId::handle_exception_id: { __ set_info("handle_exception", dont_gc_arguments); oop_maps = generate_handle_exception(id, sasm); } break; - case handle_exception_from_callee_id: + case C1StubId::handle_exception_from_callee_id: { __ set_info("handle_exception_from_callee", dont_gc_arguments); oop_maps = generate_handle_exception(id, sasm); } break; - case unwind_exception_id: + case C1StubId::unwind_exception_id: { __ set_info("unwind_exception", dont_gc_arguments); generate_unwind_exception(sasm); } break; - case throw_array_store_exception_id: + case C1StubId::throw_array_store_exception_id: { __ set_info("throw_array_store_exception", dont_gc_arguments); oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_array_store_exception), true); } break; - case throw_class_cast_exception_id: + case C1StubId::throw_class_cast_exception_id: { __ set_info("throw_class_cast_exception", dont_gc_arguments); oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_class_cast_exception), true); } break; - case throw_incompatible_class_change_error_id: + case C1StubId::throw_incompatible_class_change_error_id: { __ set_info("throw_incompatible_class_cast_exception", dont_gc_arguments); oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_incompatible_class_change_error), false); } break; - case slow_subtype_check_id: + case C1StubId::slow_subtype_check_id: { // (in) R0 - sub, destroyed, // (in) R1 - super, not changed @@ -625,10 +625,10 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case monitorenter_nofpu_id: + case C1StubId::monitorenter_nofpu_id: save_fpu_registers = false; // fall through - case monitorenter_id: + case C1StubId::monitorenter_id: { __ set_info("monitorenter", dont_gc_arguments); const Register obj = R1; @@ -643,10 +643,10 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case monitorexit_nofpu_id: + case C1StubId::monitorexit_nofpu_id: save_fpu_registers = false; // fall through - case monitorexit_id: + case C1StubId::monitorexit_id: { __ set_info("monitorexit", dont_gc_arguments); const Register lock = R1; @@ -659,7 +659,7 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case deoptimize_id: + case C1StubId::deoptimize_id: { __ set_info("deoptimize", dont_gc_arguments); OopMap* oop_map = save_live_registers(sasm); @@ -675,35 +675,35 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case access_field_patching_id: + case C1StubId::access_field_patching_id: { __ set_info("access_field_patching", dont_gc_arguments); oop_maps = generate_patching(sasm, CAST_FROM_FN_PTR(address, access_field_patching)); } break; - case load_klass_patching_id: + case C1StubId::load_klass_patching_id: { __ set_info("load_klass_patching", dont_gc_arguments); oop_maps = generate_patching(sasm, CAST_FROM_FN_PTR(address, move_klass_patching)); } break; - case load_appendix_patching_id: + case C1StubId::load_appendix_patching_id: { __ set_info("load_appendix_patching", dont_gc_arguments); oop_maps = generate_patching(sasm, CAST_FROM_FN_PTR(address, move_appendix_patching)); } break; - case load_mirror_patching_id: + case C1StubId::load_mirror_patching_id: { __ set_info("load_mirror_patching", dont_gc_arguments); oop_maps = generate_patching(sasm, CAST_FROM_FN_PTR(address, move_mirror_patching)); } break; - case predicate_failed_trap_id: + case C1StubId::predicate_failed_trap_id: { __ set_info("predicate_failed_trap", dont_gc_arguments); diff --git a/src/hotspot/cpu/arm/c2_MacroAssembler_arm.cpp b/src/hotspot/cpu/arm/c2_MacroAssembler_arm.cpp index 1db30ce5c68..900bd33fd9d 100644 --- a/src/hotspot/cpu/arm/c2_MacroAssembler_arm.cpp +++ b/src/hotspot/cpu/arm/c2_MacroAssembler_arm.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -86,8 +86,8 @@ void C2_MacroAssembler::fast_lock(Register Roop, Register Rbox, Register Rscratc if (DiagnoseSyncOnValueBasedClasses != 0) { load_klass(Rscratch, Roop); - ldr_u32(Rscratch, Address(Rscratch, Klass::access_flags_offset())); - tst(Rscratch, JVM_ACC_IS_VALUE_BASED_CLASS); + ldrb(Rscratch, Address(Rscratch, Klass::misc_flags_offset())); + tst(Rscratch, KlassFlags::_misc_is_value_based_class); b(done, ne); } diff --git a/src/hotspot/cpu/arm/gc/g1/g1BarrierSetAssembler_arm.cpp b/src/hotspot/cpu/arm/gc/g1/g1BarrierSetAssembler_arm.cpp index 3c5e29aa871..56ae7707fbf 100644 --- a/src/hotspot/cpu/arm/gc/g1/g1BarrierSetAssembler_arm.cpp +++ b/src/hotspot/cpu/arm/gc/g1/g1BarrierSetAssembler_arm.cpp @@ -39,8 +39,10 @@ #include "c1/c1_LIRAssembler.hpp" #include "c1/c1_MacroAssembler.hpp" #include "gc/g1/c1/g1BarrierSetC1.hpp" -#endif - +#endif // COMPILER1 +#ifdef COMPILER2 +#include "gc/g1/c2/g1BarrierSetC2.hpp" +#endif // COMPILER2 #define __ masm-> #ifdef PRODUCT @@ -106,70 +108,87 @@ void G1BarrierSetAssembler::gen_write_ref_array_post_barrier(MacroAssembler* mas #endif // !R9_IS_SCRATCHED } +static void generate_queue_test_and_insertion(MacroAssembler* masm, ByteSize index_offset, ByteSize buffer_offset, Label& runtime, + const Register thread, const Register value, const Register temp1, const Register temp2) { + assert_different_registers(value, temp1, temp2); + // Can we store original value in the thread's buffer? + // (The index field is typed as size_t.) + __ ldr(temp1, Address(thread, in_bytes(index_offset))); // temp1 := *(index address) + __ cbz(temp1, runtime); // jump to runtime if index == 0 (full buffer) + // The buffer is not full, store value into it. + __ sub(temp1, temp1, wordSize); // temp1 := next index + __ str(temp1, Address(thread, in_bytes(index_offset))); // *(index address) := next index + __ ldr(temp2, Address(thread, in_bytes(buffer_offset))); // temp2 := buffer address + // Record the previous value + __ str(value, Address(temp2, temp1)); // *(buffer address + next index) := value + } + +static void generate_pre_barrier_fast_path(MacroAssembler* masm, + const Register thread, + const Register tmp1) { + Address in_progress(thread, in_bytes(G1ThreadLocalData::satb_mark_queue_active_offset())); + // Is marking active? + assert(in_bytes(SATBMarkQueue::byte_width_of_active()) == 1, "adjust this code"); + __ ldrb(tmp1, in_progress); +} + +static void generate_pre_barrier_slow_path(MacroAssembler* masm, + const Register obj, + const Register pre_val, + const Register thread, + const Register tmp1, + const Register tmp2, + Label& done, + Label& runtime) { + // Do we need to load the previous value? + if (obj != noreg) { + __ load_heap_oop(pre_val, Address(obj, 0)); + } + + // Is the previous value null? + __ cbz(pre_val, done); + + generate_queue_test_and_insertion(masm, + G1ThreadLocalData::satb_mark_queue_index_offset(), + G1ThreadLocalData::satb_mark_queue_buffer_offset(), + runtime, + thread, pre_val, tmp1, tmp2); + __ b(done); +} + // G1 pre-barrier. -// Blows all volatile registers R0-R3, Rtemp, LR). -// If store_addr != noreg, then previous value is loaded from [store_addr]; -// in such case store_addr and new_val registers are preserved; +// Blows all volatile registers R0-R3, LR). +// If obj != noreg, then previous value is loaded from [obj]; +// in such case obj and pre_val registers is preserved; // otherwise pre_val register is preserved. void G1BarrierSetAssembler::g1_write_barrier_pre(MacroAssembler* masm, - Register store_addr, - Register new_val, + Register obj, Register pre_val, Register tmp1, Register tmp2) { Label done; Label runtime; - if (store_addr != noreg) { - assert_different_registers(store_addr, new_val, pre_val, tmp1, tmp2, noreg); - } else { - assert (new_val == noreg, "should be"); - assert_different_registers(pre_val, tmp1, tmp2, noreg); - } + assert_different_registers(obj, pre_val, tmp1, tmp2, noreg); - Address in_progress(Rthread, in_bytes(G1ThreadLocalData::satb_mark_queue_active_offset())); - Address index(Rthread, in_bytes(G1ThreadLocalData::satb_mark_queue_index_offset())); - Address buffer(Rthread, in_bytes(G1ThreadLocalData::satb_mark_queue_buffer_offset())); - - // Is marking active? - assert(in_bytes(SATBMarkQueue::byte_width_of_active()) == 1, "adjust this code"); - __ ldrb(tmp1, in_progress); + generate_pre_barrier_fast_path(masm, Rthread, tmp1); + // If marking is not active (*(mark queue active address) == 0), jump to done __ cbz(tmp1, done); - // Do we need to load the previous value? - if (store_addr != noreg) { - __ load_heap_oop(pre_val, Address(store_addr, 0)); - } - - // Is the previous value null? - __ cbz(pre_val, done); - - // Can we store original value in the thread's buffer? - // Is index == 0? - // (The index field is typed as size_t.) - - __ ldr(tmp1, index); // tmp1 := *index_adr - __ ldr(tmp2, buffer); - - __ subs(tmp1, tmp1, wordSize); // tmp1 := tmp1 - wordSize - __ b(runtime, lt); // If negative, goto runtime - - __ str(tmp1, index); // *index_adr := tmp1 - - // Record the previous value - __ str(pre_val, Address(tmp2, tmp1)); - __ b(done); + generate_pre_barrier_slow_path(masm, obj, pre_val, Rthread, tmp1, tmp2, done, runtime); __ bind(runtime); // save the live input values - if (store_addr != noreg) { - // avoid raw_push to support any ordering of store_addr and new_val - __ push(RegisterSet(store_addr) | RegisterSet(new_val)); - } else { - __ push(pre_val); + RegisterSet set = RegisterSet(pre_val) | RegisterSet(R0, R3) | RegisterSet(R12); + // save the live input values + if (obj != noreg) { + // avoid raw_push to support any ordering of store_addr and pre_val + set = set | RegisterSet(obj); } + __ push(set); + if (pre_val != R0) { __ mov(R0, pre_val); } @@ -177,33 +196,17 @@ void G1BarrierSetAssembler::g1_write_barrier_pre(MacroAssembler* masm, __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_field_pre_entry), R0, R1); - if (store_addr != noreg) { - __ pop(RegisterSet(store_addr) | RegisterSet(new_val)); - } else { - __ pop(pre_val); - } - + __ pop(set); __ bind(done); } -// G1 post-barrier. -// Blows all volatile registers R0-R3, Rtemp, LR). -void G1BarrierSetAssembler::g1_write_barrier_post(MacroAssembler* masm, - Register store_addr, - Register new_val, - Register tmp1, - Register tmp2, - Register tmp3) { - - Address queue_index(Rthread, in_bytes(G1ThreadLocalData::dirty_card_queue_index_offset())); - Address buffer(Rthread, in_bytes(G1ThreadLocalData::dirty_card_queue_buffer_offset())); - - BarrierSet* bs = BarrierSet::barrier_set(); - CardTableBarrierSet* ctbs = barrier_set_cast(bs); - CardTable* ct = ctbs->card_table(); - Label done; - Label runtime; - +static void generate_post_barrier_fast_path(MacroAssembler* masm, + const Register store_addr, + const Register new_val, + const Register tmp1, + const Register tmp2, + Label& done, + bool new_val_may_be_null) { // Does store cross heap regions? __ eor(tmp1, store_addr, new_val); @@ -211,22 +214,31 @@ void G1BarrierSetAssembler::g1_write_barrier_post(MacroAssembler* masm, __ b(done, eq); // crosses regions, storing null? - - __ cbz(new_val, done); - + if (new_val_may_be_null) { + __ cbz(new_val, done); + } // storing region crossing non-null, is card already dirty? const Register card_addr = tmp1; - __ mov_address(tmp2, (address)ct->byte_map_base()); + CardTableBarrierSet* ct = barrier_set_cast(BarrierSet::barrier_set()); + __ mov_address(tmp2, (address)ct->card_table()->byte_map_base()); __ add(card_addr, tmp2, AsmOperand(store_addr, lsr, CardTable::card_shift())); __ ldrb(tmp2, Address(card_addr)); __ cmp(tmp2, (int)G1CardTable::g1_young_card_val()); - __ b(done, eq); +} +static void generate_post_barrier_slow_path(MacroAssembler* masm, + const Register thread, + const Register tmp1, + const Register tmp2, + const Register tmp3, + Label& done, + Label& runtime) { __ membar(MacroAssembler::Membar_mask_bits(MacroAssembler::StoreLoad), tmp2); - assert(CardTable::dirty_card_val() == 0, "adjust this code"); + // card_addr is loaded by generate_post_barrier_fast_path + const Register card_addr = tmp1; __ ldrb(tmp2, Address(card_addr)); __ cbz(tmp2, done); @@ -234,29 +246,139 @@ void G1BarrierSetAssembler::g1_write_barrier_post(MacroAssembler* masm, // dirty card and log. __ strb(__ zero_register(tmp2), Address(card_addr)); - - __ ldr(tmp2, queue_index); - __ ldr(tmp3, buffer); - - __ subs(tmp2, tmp2, wordSize); - __ b(runtime, lt); // go to runtime if now negative - - __ str(tmp2, queue_index); - - __ str(card_addr, Address(tmp3, tmp2)); + generate_queue_test_and_insertion(masm, + G1ThreadLocalData::dirty_card_queue_index_offset(), + G1ThreadLocalData::dirty_card_queue_buffer_offset(), + runtime, + thread, card_addr, tmp2, tmp3); __ b(done); +} + + +// G1 post-barrier. +// Blows all volatile registers R0-R3, LR). +void G1BarrierSetAssembler::g1_write_barrier_post(MacroAssembler* masm, + Register store_addr, + Register new_val, + Register tmp1, + Register tmp2, + Register tmp3) { + Label done; + Label runtime; + + generate_post_barrier_fast_path(masm, store_addr, new_val, tmp1, tmp2, done, true /* new_val_may_be_null */); + // If card is young, jump to done + // card_addr and card are loaded by generate_post_barrier_fast_path + const Register card = tmp2; + const Register card_addr = tmp1; + __ b(done, eq); + generate_post_barrier_slow_path(masm, Rthread, card_addr, tmp2, tmp3, done, runtime); __ bind(runtime); + RegisterSet set = RegisterSet(store_addr) | RegisterSet(R0, R3) | RegisterSet(R12); + __ push(set); + if (card_addr != R0) { __ mov(R0, card_addr); } __ mov(R1, Rthread); __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_field_post_entry), R0, R1); + __ pop(set); + __ bind(done); } +#if defined(COMPILER2) + +static void generate_c2_barrier_runtime_call(MacroAssembler* masm, G1BarrierStubC2* stub, const Register arg, const address runtime_path, Register tmp1) { + SaveLiveRegisters save_registers(masm, stub); + if (c_rarg0 != arg) { + __ mov(c_rarg0, arg); + } + __ mov(c_rarg1, Rthread); + __ call_VM_leaf(runtime_path, R0, R1); +} + +void G1BarrierSetAssembler::g1_write_barrier_pre_c2(MacroAssembler* masm, + Register obj, + Register pre_val, + Register thread, + Register tmp1, + Register tmp2, + G1PreBarrierStubC2* stub) { + assert(thread == Rthread, "must be"); + assert_different_registers(obj, pre_val, tmp1, tmp2); + assert(pre_val != noreg && tmp1 != noreg && tmp2 != noreg, "expecting a register"); + + stub->initialize_registers(obj, pre_val, thread, tmp1, tmp2); + + generate_pre_barrier_fast_path(masm, thread, tmp1); + // If marking is active (*(mark queue active address) != 0), jump to stub (slow path) + __ cbnz(tmp1, *stub->entry()); + + __ bind(*stub->continuation()); +} + +void G1BarrierSetAssembler::generate_c2_pre_barrier_stub(MacroAssembler* masm, + G1PreBarrierStubC2* stub) const { + Assembler::InlineSkippedInstructionsCounter skip_counter(masm); + Label runtime; + Register obj = stub->obj(); + Register pre_val = stub->pre_val(); + Register thread = stub->thread(); + Register tmp1 = stub->tmp1(); + Register tmp2 = stub->tmp2(); + + __ bind(*stub->entry()); + generate_pre_barrier_slow_path(masm, obj, pre_val, thread, tmp1, tmp2, *stub->continuation(), runtime); + + __ bind(runtime); + generate_c2_barrier_runtime_call(masm, stub, pre_val, CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_field_pre_entry), tmp1); + __ b(*stub->continuation()); +} + +void G1BarrierSetAssembler::g1_write_barrier_post_c2(MacroAssembler* masm, + Register store_addr, + Register new_val, + Register thread, + Register tmp1, + Register tmp2, + Register tmp3, + G1PostBarrierStubC2* stub) { + assert(thread == Rthread, "must be"); + assert_different_registers(store_addr, new_val, thread, tmp1, tmp2, noreg); + + stub->initialize_registers(thread, tmp1, tmp2, tmp3); + + bool new_val_may_be_null = (stub->barrier_data() & G1C2BarrierPostNotNull) == 0; + generate_post_barrier_fast_path(masm, store_addr, new_val, tmp1, tmp2, *stub->continuation(), new_val_may_be_null); + // If card is not young, jump to stub (slow path) + __ b(*stub->entry(), ne); + + __ bind(*stub->continuation()); +} + +void G1BarrierSetAssembler::generate_c2_post_barrier_stub(MacroAssembler* masm, + G1PostBarrierStubC2* stub) const { + Assembler::InlineSkippedInstructionsCounter skip_counter(masm); + Label runtime; + Register thread = stub->thread(); + Register tmp1 = stub->tmp1(); // tmp1 holds the card address. + Register tmp2 = stub->tmp2(); + Register tmp3 = stub->tmp3(); + + __ bind(*stub->entry()); + generate_post_barrier_slow_path(masm, thread, tmp1, tmp2, tmp3, *stub->continuation(), runtime); + + __ bind(runtime); + generate_c2_barrier_runtime_call(masm, stub, tmp1, CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_field_post_entry), tmp2); + __ b(*stub->continuation()); +} + +#endif // COMPILER2 + void G1BarrierSetAssembler::load_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type, Register dst, Address src, Register tmp1, Register tmp2, Register tmp3) { bool on_oop = type == T_OBJECT || type == T_ARRAY; @@ -268,7 +390,7 @@ void G1BarrierSetAssembler::load_at(MacroAssembler* masm, DecoratorSet decorator if (on_oop && on_reference) { // Generate the G1 pre-barrier code to log the value of // the referent field in an SATB buffer. - g1_write_barrier_pre(masm, noreg, noreg, dst, tmp1, tmp2); + g1_write_barrier_pre(masm, noreg, dst, tmp1, tmp2); } } @@ -295,7 +417,7 @@ void G1BarrierSetAssembler::oop_store_at(MacroAssembler* masm, DecoratorSet deco } if (needs_pre_barrier) { - g1_write_barrier_pre(masm, store_addr, new_val, tmp1, tmp2, tmp3); + g1_write_barrier_pre(masm, store_addr, tmp3 /*pre_val*/, tmp1, tmp2); } if (is_null) { diff --git a/src/hotspot/cpu/arm/gc/g1/g1BarrierSetAssembler_arm.hpp b/src/hotspot/cpu/arm/gc/g1/g1BarrierSetAssembler_arm.hpp index 52932faa3e4..aefde19142e 100644 --- a/src/hotspot/cpu/arm/gc/g1/g1BarrierSetAssembler_arm.hpp +++ b/src/hotspot/cpu/arm/gc/g1/g1BarrierSetAssembler_arm.hpp @@ -33,6 +33,8 @@ class LIR_Assembler; class StubAssembler; class G1PreBarrierStub; class G1PostBarrierStub; +class G1PreBarrierStubC2; +class G1PostBarrierStubC2; class G1BarrierSetAssembler: public ModRefBarrierSetAssembler { protected: @@ -43,7 +45,6 @@ protected: void g1_write_barrier_pre(MacroAssembler* masm, Register store_addr, - Register new_val, Register pre_val, Register tmp1, Register tmp2); @@ -70,6 +71,29 @@ public: void generate_c1_pre_barrier_runtime_stub(StubAssembler* sasm); void generate_c1_post_barrier_runtime_stub(StubAssembler* sasm); #endif + +#ifdef COMPILER2 + void g1_write_barrier_pre_c2(MacroAssembler* masm, + Register obj, + Register pre_val, + Register thread, + Register tmp1, + Register tmp2, + G1PreBarrierStubC2* c2_stub); + void generate_c2_pre_barrier_stub(MacroAssembler* masm, + G1PreBarrierStubC2* stub) const; + void g1_write_barrier_post_c2(MacroAssembler* masm, + Register store_addr, + Register new_val, + Register thread, + Register tmp1, + Register tmp2, + Register tmp3, + G1PostBarrierStubC2* c2_stub); + void generate_c2_post_barrier_stub(MacroAssembler* masm, + G1PostBarrierStubC2* stub) const; +#endif + }; #endif // CPU_ARM_GC_G1_G1BARRIERSETASSEMBLER_ARM_HPP diff --git a/src/hotspot/cpu/arm/gc/g1/g1_arm.ad b/src/hotspot/cpu/arm/gc/g1/g1_arm.ad new file mode 100644 index 00000000000..8a0a9e1aa53 --- /dev/null +++ b/src/hotspot/cpu/arm/gc/g1/g1_arm.ad @@ -0,0 +1,201 @@ +// +// Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. +// DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +// +// This code is free software; you can redistribute it and/or modify it +// under the terms of the GNU General Public License version 2 only, as +// published by the Free Software Foundation. +// +// This code is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// version 2 for more details (a copy is included in the LICENSE file that +// accompanied this code). +// +// You should have received a copy of the GNU General Public License version +// 2 along with this work; if not, write to the Free Software Foundation, +// Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +// +// Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +// or visit www.oracle.com if you need additional information or have any +// questions. +// + +source_hpp %{ + +#include "gc/g1/c2/g1BarrierSetC2.hpp" +#include "gc/shared/gc_globals.hpp" + +%} + +source %{ + +#include "gc/g1/g1BarrierSetAssembler_arm.hpp" +#include "gc/g1/g1BarrierSetRuntime.hpp" + +static void write_barrier_pre(MacroAssembler* masm, + const MachNode* node, + Register obj, + Register pre_val, + Register tmp1, + Register tmp2, + RegSet preserve = RegSet(), + RegSet no_preserve = RegSet()) { + if (!G1PreBarrierStubC2::needs_barrier(node)) { + return; + } + Assembler::InlineSkippedInstructionsCounter skip_counter(masm); + G1BarrierSetAssembler* g1_asm = static_cast(BarrierSet::barrier_set()->barrier_set_assembler()); + G1PreBarrierStubC2* const stub = G1PreBarrierStubC2::create(node); + for (RegSetIterator reg = preserve.begin(); *reg != noreg; ++reg) { + stub->preserve(*reg); + } + for (RegSetIterator reg = no_preserve.begin(); *reg != noreg; ++reg) { + stub->dont_preserve(*reg); + } + g1_asm->g1_write_barrier_pre_c2(masm, obj, pre_val, Rthread, tmp1, tmp2, stub); +} + +static void write_barrier_post(MacroAssembler* masm, + const MachNode* node, + Register store_addr, + Register new_val, + Register tmp1, + Register tmp2, + Register tmp3) { + if (!G1PostBarrierStubC2::needs_barrier(node)) { + return; + } + Assembler::InlineSkippedInstructionsCounter skip_counter(masm); + G1BarrierSetAssembler* g1_asm = static_cast(BarrierSet::barrier_set()->barrier_set_assembler()); + G1PostBarrierStubC2* const stub = G1PostBarrierStubC2::create(node); + g1_asm->g1_write_barrier_post_c2(masm, store_addr, new_val, Rthread, tmp1, tmp2, tmp3, stub); +} + +%} + +instruct g1StoreP(indirect mem, iRegP src, iRegP tmp1, iRegP tmp2, iRegP tmp3, flagsReg icc) +%{ + predicate(UseG1GC && n->as_Store()->barrier_data() != 0); + match(Set mem (StoreP mem src)); + effect(TEMP tmp1, TEMP tmp2, TEMP tmp3, KILL icc); + ins_cost(2 * (MEMORY_REF_COST + BRANCH_COST)); + format %{ "sd $src, $mem\t# ptr" %} + ins_encode %{ + guarantee($mem$$disp == 0, "impossible encoding"); + write_barrier_pre(masm, this, + $mem$$Register /* obj */, + $tmp1$$Register /* pre_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */, + RegSet::of($mem$$Register, $src$$Register) /* preserve */); + __ str($src$$Register, Address($mem$$Register)); + write_barrier_post(masm, this, + $mem$$Register /* store_addr */, + $src$$Register /* new_val */, + $tmp1$$Register /* tmp1 */, + $tmp2$$Register /* tmp2 */, + $tmp3$$Register /* tmp3 */); + %} + ins_pipe(istore_mem_reg); +%} + +instruct g1CompareAndSwapP(iRegI res, indirect mem, iRegP newval, iRegP tmp1, iRegP tmp2, iRegP tmp3, iRegP oldval, flagsReg ccr ) +%{ + predicate(UseG1GC && n->as_LoadStore()->barrier_data() != 0); + match(Set res (CompareAndSwapP mem (Binary oldval newval))); + effect(KILL ccr, TEMP res, TEMP tmp1, TEMP tmp2, TEMP tmp3); + ins_cost(4 * (MEMORY_REF_COST + BRANCH_COST)); + format %{ "loop: \n\t" + "LDREX $tmp1, $mem\t! If $oldval==[$mem] Then store $newval into [$mem]\n\t" + "CMP $tmp1, $oldval\n\t" + "STREX.eq $tmp1, $newval, $mem\n\t" + "MOV.ne $tmp1, 0 \n\t" + "EORS.eq $tmp1,$tmp1, 1 \n\t" + "B.eq loop \n\t" + "MOV $res, $tmp1" %} + ins_encode %{ + guarantee($mem$$disp == 0, "impossible encoding"); + assert_different_registers($oldval$$Register, $mem$$Register); + assert_different_registers($newval$$Register, $mem$$Register); + write_barrier_pre(masm, this, + noreg /* obj */, + $oldval$$Register /* pre_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */, + RegSet::of($mem$$Register, $oldval$$Register, $newval$$Register) /* preserve */, + RegSet::of($res$$Register) /* no_preserve */); + Label loop; + __ bind(loop); + __ ldrex($tmp1$$Register,$mem$$Address); + __ cmp($tmp1$$Register, $oldval$$Register); + __ strex($tmp1$$Register, $newval$$Register, $mem$$Address, eq); + __ mov($tmp1$$Register, 0, ne); + __ eors($tmp1$$Register, $tmp1$$Register, 1, eq); + __ b(loop, eq); + __ mov($res$$Register, $tmp1$$Register); + write_barrier_post(masm, this, + $mem$$Register /* store_addr */, + $newval$$Register /* new_val */, + $tmp1$$Register /* tmp1 */, + $tmp2$$Register /* tmp2 */, + $tmp3$$Register /* tmp3 */); + %} + ins_pipe(long_memory_op); +%} + + +instruct g1GetAndSetP(indirect mem, iRegP newval, iRegP tmp1, iRegP tmp2, iRegP tmp3, iRegP preval, flagsReg ccr) +%{ + predicate(UseG1GC && n->as_LoadStore()->barrier_data() != 0); + match(Set preval (GetAndSetP mem newval)); + effect(KILL ccr, TEMP preval, TEMP tmp1, TEMP tmp2, TEMP tmp3); + ins_cost(4 * (MEMORY_REF_COST + BRANCH_COST)); + format %{ "loop: \n\t" + "LDREX $preval, $mem\n\t" + "STREX $tmp1, $newval, $mem\n\t" + "CMP $tmp1, 0 \n\t" + "B.ne loop \n\t" %} + ins_encode %{ + guarantee($mem$$disp == 0, "impossible encoding"); + assert_different_registers($mem$$Register, $newval$$Register); + write_barrier_pre(masm, this, + $mem$$Register /* obj */, + $preval$$Register /* pre_val (as a temporary register) */, + $tmp1$$Register /* tmp1 */, + $tmp2$$Register /* tmp2 */, + RegSet::of($mem$$Register, $preval$$Register, $newval$$Register) /* preserve */); + Label loop; + __ bind(loop); + __ ldrex($preval$$Register,$mem$$Address); + __ strex($tmp1$$Register, $newval$$Register, $mem$$Address); + __ cmp($tmp1$$Register, 0); + __ b(loop, ne); + write_barrier_post(masm, this, + $mem$$Register /* store_addr */, + $newval$$Register /* new_val */, + $tmp1$$Register /* tmp1 */, + $tmp2$$Register /* tmp2 */, + $tmp3$$Register /* tmp3 */); + %} + ins_pipe(long_memory_op); +%} + +instruct g1LoadP(iRegP dst, indirect mem, iRegP tmp1, iRegP tmp2, flagsReg icc) +%{ + predicate(UseG1GC && n->as_Load()->barrier_data() != 0); + match(Set dst (LoadP mem)); + effect(TEMP dst, TEMP tmp1, TEMP tmp2, KILL icc); + ins_cost(MEMORY_REF_COST + BRANCH_COST); + format %{ "ld $dst, $mem\t# ptr" %} + ins_encode %{ + guarantee($mem$$disp == 0, "impossible encoding"); + __ ldr($dst$$Register, Address($mem$$Register)); + write_barrier_pre(masm, this, + noreg /* obj */, + $dst$$Register /* pre_val */, + $tmp1$$Register /* tmp1 */, + $tmp2$$Register /* tmp2 */); + %} + ins_pipe(iload_mem); +%} diff --git a/src/hotspot/cpu/arm/gc/shared/barrierSetAssembler_arm.cpp b/src/hotspot/cpu/arm/gc/shared/barrierSetAssembler_arm.cpp index ea19730673c..c13a259a1b9 100644 --- a/src/hotspot/cpu/arm/gc/shared/barrierSetAssembler_arm.cpp +++ b/src/hotspot/cpu/arm/gc/shared/barrierSetAssembler_arm.cpp @@ -31,6 +31,10 @@ #include "runtime/javaThread.hpp" #include "runtime/stubRoutines.hpp" +#ifdef COMPILER2 +#include "gc/shared/c2/barrierSetC2.hpp" +#endif // COMPILER2 + #define __ masm-> void BarrierSetAssembler::load_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type, @@ -206,7 +210,57 @@ void BarrierSetAssembler::nmethod_entry_barrier(MacroAssembler* masm) { #ifdef COMPILER2 OptoReg::Name BarrierSetAssembler::refine_register(const Node* node, OptoReg::Name opto_reg) { - Unimplemented(); // This must be implemented to support late barrier expansion. + if (!OptoReg::is_reg(opto_reg)) { + return OptoReg::Bad; + } + + const VMReg vm_reg = OptoReg::as_VMReg(opto_reg); + if (!vm_reg->is_valid()){ + // skip APSR and FPSCR + return OptoReg::Bad; + } + + return opto_reg; } +void SaveLiveRegisters::initialize(BarrierStubC2* stub) { + // Record registers that needs to be saved/restored + RegMaskIterator rmi(stub->preserve_set()); + while (rmi.has_next()) { + const OptoReg::Name opto_reg = rmi.next(); + if (OptoReg::is_reg(opto_reg)) { + const VMReg vm_reg = OptoReg::as_VMReg(opto_reg); + if (vm_reg->is_Register()) { + gp_regs += RegSet::of(vm_reg->as_Register()); + } else if (vm_reg->is_FloatRegister()) { + fp_regs += FloatRegSet::of(vm_reg->as_FloatRegister()); + } else { + fatal("Unknown register type"); + } + } + } + // Remove C-ABI SOE registers that will be updated + gp_regs -= RegSet::range(R4, R11) + RegSet::of(R13, R15); + + // Remove C-ABI SOE fp registers + fp_regs -= FloatRegSet::range(S16, S31); +} + +SaveLiveRegisters::SaveLiveRegisters(MacroAssembler* masm, BarrierStubC2* stub) + : masm(masm), + gp_regs(), + fp_regs() { + // Figure out what registers to save/restore + initialize(stub); + + // Save registers + if (gp_regs.size() > 0) __ push(RegisterSet::from(gp_regs)); + if (fp_regs.size() > 0) __ fpush(FloatRegisterSet::from(fp_regs)); +} + +SaveLiveRegisters::~SaveLiveRegisters() { + // Restore registers + if (fp_regs.size() > 0) __ fpop(FloatRegisterSet::from(fp_regs)); + if (gp_regs.size() > 0) __ pop(RegisterSet::from(gp_regs)); +} #endif // COMPILER2 diff --git a/src/hotspot/cpu/arm/gc/shared/barrierSetAssembler_arm.hpp b/src/hotspot/cpu/arm/gc/shared/barrierSetAssembler_arm.hpp index 60021390ea2..054d172f463 100644 --- a/src/hotspot/cpu/arm/gc/shared/barrierSetAssembler_arm.hpp +++ b/src/hotspot/cpu/arm/gc/shared/barrierSetAssembler_arm.hpp @@ -31,7 +31,9 @@ #ifdef COMPILER2 #include "code/vmreg.hpp" #include "opto/optoreg.hpp" +#include "opto/regmask.hpp" +class BarrierStubC2; class Node; #endif // COMPILER2 @@ -69,4 +71,26 @@ public: #endif // COMPILER2 }; +#ifdef COMPILER2 +// This class saves and restores the registers that need to be preserved across +// the runtime call represented by a given C2 barrier stub. Use as follows: +// { +// SaveLiveRegisters save(masm, stub); +// .. +// __ bl(...); +// .. +// } +class SaveLiveRegisters { +private: + MacroAssembler* const masm; + RegSet gp_regs; + FloatRegSet fp_regs; + +public: + void initialize(BarrierStubC2* stub); + SaveLiveRegisters(MacroAssembler* masm, BarrierStubC2* stub); + ~SaveLiveRegisters(); +}; + +#endif // COMPILER2 #endif // CPU_ARM_GC_SHARED_BARRIERSETASSEMBLER_ARM_HPP diff --git a/src/hotspot/cpu/arm/interp_masm_arm.cpp b/src/hotspot/cpu/arm/interp_masm_arm.cpp index 2874abafc4f..3a81fdddb3c 100644 --- a/src/hotspot/cpu/arm/interp_masm_arm.cpp +++ b/src/hotspot/cpu/arm/interp_masm_arm.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -909,8 +909,8 @@ void InterpreterMacroAssembler::lock_object(Register Rlock) { if (DiagnoseSyncOnValueBasedClasses != 0) { load_klass(R0, Robj); - ldr_u32(R0, Address(R0, Klass::access_flags_offset())); - tst(R0, JVM_ACC_IS_VALUE_BASED_CLASS); + ldrb(R0, Address(R0, Klass::misc_flags_offset())); + tst(R0, KlassFlags::_misc_is_value_based_class); b(slow_case, ne); } diff --git a/src/hotspot/cpu/arm/register_arm.hpp b/src/hotspot/cpu/arm/register_arm.hpp index 9f486d2a625..d8961fd2935 100644 --- a/src/hotspot/cpu/arm/register_arm.hpp +++ b/src/hotspot/cpu/arm/register_arm.hpp @@ -303,6 +303,31 @@ class ConcreteRegisterImpl : public AbstractRegisterImpl { static const int max_fpr; }; +typedef AbstractRegSet RegSet; +typedef AbstractRegSet FloatRegSet; + +template <> +inline Register AbstractRegSet::first() { + if (_bitset == 0) { return noreg; } + return as_Register(count_trailing_zeros(_bitset)); +} + + +template <> +inline FloatRegister AbstractRegSet::first() { + uint32_t first = _bitset & -_bitset; + return first ? as_FloatRegister(exact_log2(first)) : fnoreg; +} + +template <> +inline FloatRegister AbstractRegSet::last() { + if (_bitset == 0) { return fnoreg; } + int last = max_size() - 1 - count_leading_zeros(_bitset); + return as_FloatRegister(last); +} + + + class VFPSystemRegisterImpl; typedef VFPSystemRegisterImpl* VFPSystemRegister; class VFPSystemRegisterImpl : public AbstractRegisterImpl { diff --git a/src/hotspot/cpu/arm/sharedRuntime_arm.cpp b/src/hotspot/cpu/arm/sharedRuntime_arm.cpp index f07c1f8e53c..7c1f3aafe7d 100644 --- a/src/hotspot/cpu/arm/sharedRuntime_arm.cpp +++ b/src/hotspot/cpu/arm/sharedRuntime_arm.cpp @@ -38,6 +38,7 @@ #include "runtime/sharedRuntime.hpp" #include "runtime/safepointMechanism.hpp" #include "runtime/stubRoutines.hpp" +#include "runtime/timerTrace.hpp" #include "runtime/vframeArray.hpp" #include "utilities/align.hpp" #include "utilities/powerOfTwo.hpp" @@ -1360,7 +1361,8 @@ uint SharedRuntime::out_preserve_stack_slots() { //------------------------------generate_deopt_blob---------------------------- void SharedRuntime::generate_deopt_blob() { ResourceMark rm; - CodeBuffer buffer("deopt_blob", 1024, 1024); + const char* name = SharedRuntime::stub_name(SharedStubId::deopt_id); + CodeBuffer buffer(name, 1024, 1024); int frame_size_in_words; OopMapSet* oop_maps; int reexecute_offset; @@ -1601,15 +1603,17 @@ void SharedRuntime::generate_deopt_blob() { // setup oopmap, and calls safepoint code to stop the compiled code for // a safepoint. // -SafepointBlob* SharedRuntime::generate_handler_blob(address call_ptr, int poll_type) { +SafepointBlob* SharedRuntime::generate_handler_blob(SharedStubId id, address call_ptr) { assert(StubRoutines::forward_exception_entry() != nullptr, "must be generated before"); + assert(is_polling_page_id(id), "expected a polling page stub id"); ResourceMark rm; - CodeBuffer buffer("handler_blob", 256, 256); + const char* name = SharedRuntime::stub_name(id); + CodeBuffer buffer(name, 256, 256); int frame_size_words; OopMapSet* oop_maps; - bool cause_return = (poll_type == POLL_AT_RETURN); + bool cause_return = (id == SharedStubId::polling_page_return_handler_id); MacroAssembler* masm = new MacroAssembler(&buffer); address start = __ pc(); @@ -1671,10 +1675,12 @@ SafepointBlob* SharedRuntime::generate_handler_blob(address call_ptr, int poll_t return SafepointBlob::create(&buffer, oop_maps, frame_size_words); } -RuntimeStub* SharedRuntime::generate_resolve_blob(address destination, const char* name) { +RuntimeStub* SharedRuntime::generate_resolve_blob(SharedStubId id, address destination) { assert(StubRoutines::forward_exception_entry() != nullptr, "must be generated before"); + assert(is_resolve_id(id), "expected a resolve stub id"); ResourceMark rm; + const char* name = SharedRuntime::stub_name(id); CodeBuffer buffer(name, 1000, 512); int frame_size_words; OopMapSet *oop_maps; @@ -1733,7 +1739,11 @@ RuntimeStub* SharedRuntime::generate_resolve_blob(address destination, const cha // Continuation point for throwing of implicit exceptions that are not handled in // the current activation. Fabricates an exception oop and initiates normal // exception dispatching in this frame. -RuntimeStub* SharedRuntime::generate_throw_exception(const char* name, address runtime_entry) { +RuntimeStub* SharedRuntime::generate_throw_exception(SharedStubId id, address runtime_entry) { + assert(is_throw_id(id), "expected a throw stub id"); + + const char* name = SharedRuntime::stub_name(id); + int insts_size = 128; int locs_size = 32; @@ -1793,7 +1803,8 @@ RuntimeStub* SharedRuntime::generate_jfr_write_checkpoint() { framesize // inclusive of return address }; - CodeBuffer code("jfr_write_checkpoint", 512, 64); + const char* name = SharedRuntime::stub_name(SharedStubId::jfr_write_checkpoint_id); + CodeBuffer code(name, 512, 64); MacroAssembler* masm = new MacroAssembler(&code); address start = __ pc(); @@ -1818,7 +1829,7 @@ RuntimeStub* SharedRuntime::generate_jfr_write_checkpoint() { oop_maps->add_gc_map(frame_complete, map); RuntimeStub* stub = - RuntimeStub::new_runtime_stub(code.name(), + RuntimeStub::new_runtime_stub(name, &code, frame_complete, (framesize >> (LogBytesPerWord - LogBytesPerInt)), @@ -1836,7 +1847,8 @@ RuntimeStub* SharedRuntime::generate_jfr_return_lease() { framesize // inclusive of return address }; - CodeBuffer code("jfr_return_lease", 512, 64); + const char* name = SharedRuntime::stub_name(SharedStubId::jfr_return_lease_id); + CodeBuffer code(name, 512, 64); MacroAssembler* masm = new MacroAssembler(&code); address start = __ pc(); @@ -1858,7 +1870,7 @@ RuntimeStub* SharedRuntime::generate_jfr_return_lease() { oop_maps->add_gc_map(frame_complete, map); RuntimeStub* stub = - RuntimeStub::new_runtime_stub(code.name(), + RuntimeStub::new_runtime_stub(name, &code, frame_complete, (framesize >> (LogBytesPerWord - LogBytesPerInt)), diff --git a/src/hotspot/cpu/arm/templateInterpreterGenerator_arm.cpp b/src/hotspot/cpu/arm/templateInterpreterGenerator_arm.cpp index 679f07a028e..ec9d237e50d 100644 --- a/src/hotspot/cpu/arm/templateInterpreterGenerator_arm.cpp +++ b/src/hotspot/cpu/arm/templateInterpreterGenerator_arm.cpp @@ -175,6 +175,7 @@ address TemplateInterpreterGenerator::generate_math_entry(AbstractInterpreter::M break; case Interpreter::java_lang_math_fmaD: case Interpreter::java_lang_math_fmaF: + case Interpreter::java_lang_math_tanh: // TODO: Implement intrinsic break; default: diff --git a/src/hotspot/cpu/arm/templateTable_arm.cpp b/src/hotspot/cpu/arm/templateTable_arm.cpp index e657c659588..0974ff1f9a9 100644 --- a/src/hotspot/cpu/arm/templateTable_arm.cpp +++ b/src/hotspot/cpu/arm/templateTable_arm.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -2494,8 +2494,8 @@ void TemplateTable::_return(TosState state) { assert(state == vtos, "only valid state"); __ ldr(R1, aaddress(0)); __ load_klass(Rtemp, R1); - __ ldr_u32(Rtemp, Address(Rtemp, Klass::access_flags_offset())); - __ tbz(Rtemp, exact_log2(JVM_ACC_HAS_FINALIZER), skip_register_finalizer); + __ ldrb(Rtemp, Address(Rtemp, Klass::misc_flags_offset())); + __ tbz(Rtemp, exact_log2(KlassFlags::_misc_has_finalizer), skip_register_finalizer); __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::register_finalizer), R1); @@ -3974,6 +3974,7 @@ void TemplateTable::_new() { // make sure klass is initialized // make sure klass is fully initialized __ ldrb(Rtemp, Address(Rklass, InstanceKlass::init_state_offset())); + __ membar(MacroAssembler::Membar_mask_bits(MacroAssembler::LoadLoad | MacroAssembler::LoadStore), Rtemp); __ cmp(Rtemp, InstanceKlass::fully_initialized); __ b(slow_case, ne); diff --git a/src/hotspot/cpu/arm/upcallLinker_arm.cpp b/src/hotspot/cpu/arm/upcallLinker_arm.cpp index c7645f4a033..696b2001e6b 100644 --- a/src/hotspot/cpu/arm/upcallLinker_arm.cpp +++ b/src/hotspot/cpu/arm/upcallLinker_arm.cpp @@ -25,7 +25,7 @@ #include "prims/upcallLinker.hpp" #include "utilities/debug.hpp" -address UpcallLinker::make_upcall_stub(jobject receiver, Method* entry, +address UpcallLinker::make_upcall_stub(jobject receiver, Symbol* signature, BasicType* out_sig_bt, int total_out_args, BasicType ret_type, jobject jabi, jobject jconv, diff --git a/src/hotspot/cpu/ppc/c1_CodeStubs_ppc.cpp b/src/hotspot/cpu/ppc/c1_CodeStubs_ppc.cpp index dc70c73d4b3..451f3b7e9cd 100644 --- a/src/hotspot/cpu/ppc/c1_CodeStubs_ppc.cpp +++ b/src/hotspot/cpu/ppc/c1_CodeStubs_ppc.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, 2021 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -68,7 +68,7 @@ void RangeCheckStub::emit_code(LIR_Assembler* ce) { __ bind(_entry); if (_info->deoptimize_on_exception()) { - address a = Runtime1::entry_for(Runtime1::predicate_failed_trap_id); + address a = Runtime1::entry_for(C1StubId::predicate_failed_trap_id); //__ load_const_optimized(R0, a); __ add_const_optimized(R0, R29_TOC, MacroAssembler::offset_to_global_toc(a)); __ mtctr(R0); @@ -79,8 +79,8 @@ void RangeCheckStub::emit_code(LIR_Assembler* ce) { return; } - address stub = _throw_index_out_of_bounds_exception ? Runtime1::entry_for(Runtime1::throw_index_exception_id) - : Runtime1::entry_for(Runtime1::throw_range_check_failed_id); + address stub = _throw_index_out_of_bounds_exception ? Runtime1::entry_for(C1StubId::throw_index_exception_id) + : Runtime1::entry_for(C1StubId::throw_range_check_failed_id); //__ load_const_optimized(R0, stub); __ add_const_optimized(R0, R29_TOC, MacroAssembler::offset_to_global_toc(stub)); __ mtctr(R0); @@ -109,7 +109,7 @@ PredicateFailedStub::PredicateFailedStub(CodeEmitInfo* info) { void PredicateFailedStub::emit_code(LIR_Assembler* ce) { __ bind(_entry); - address a = Runtime1::entry_for(Runtime1::predicate_failed_trap_id); + address a = Runtime1::entry_for(C1StubId::predicate_failed_trap_id); //__ load_const_optimized(R0, a); __ add_const_optimized(R0, R29_TOC, MacroAssembler::offset_to_global_toc(a)); __ mtctr(R0); @@ -133,7 +133,7 @@ void CounterOverflowStub::emit_code(LIR_Assembler* ce) { __ load_const_optimized(R0, md.value()); __ std(R0, -8, R1_SP); - address a = Runtime1::entry_for(Runtime1::counter_overflow_id); + address a = Runtime1::entry_for(C1StubId::counter_overflow_id); //__ load_const_optimized(R0, a); __ add_const_optimized(R0, R29_TOC, MacroAssembler::offset_to_global_toc(a)); __ mtctr(R0); @@ -150,7 +150,7 @@ void DivByZeroStub::emit_code(LIR_Assembler* ce) { ce->compilation()->implicit_exception_table()->append(_offset, __ offset()); } __ bind(_entry); - address stub = Runtime1::entry_for(Runtime1::throw_div0_exception_id); + address stub = Runtime1::entry_for(C1StubId::throw_div0_exception_id); //__ load_const_optimized(R0, stub); __ add_const_optimized(R0, R29_TOC, MacroAssembler::offset_to_global_toc(stub)); __ mtctr(R0); @@ -165,9 +165,9 @@ void ImplicitNullCheckStub::emit_code(LIR_Assembler* ce) { address a; if (_info->deoptimize_on_exception()) { // Deoptimize, do not throw the exception, because it is probably wrong to do it here. - a = Runtime1::entry_for(Runtime1::predicate_failed_trap_id); + a = Runtime1::entry_for(C1StubId::predicate_failed_trap_id); } else { - a = Runtime1::entry_for(Runtime1::throw_null_pointer_exception_id); + a = Runtime1::entry_for(C1StubId::throw_null_pointer_exception_id); } if (ImplicitNullChecks || TrapBasedNullChecks) { @@ -199,14 +199,14 @@ void SimpleExceptionStub::emit_code(LIR_Assembler* ce) { // Implementation of NewInstanceStub -NewInstanceStub::NewInstanceStub(LIR_Opr klass_reg, LIR_Opr result, ciInstanceKlass* klass, CodeEmitInfo* info, Runtime1::StubID stub_id) { +NewInstanceStub::NewInstanceStub(LIR_Opr klass_reg, LIR_Opr result, ciInstanceKlass* klass, CodeEmitInfo* info, C1StubId stub_id) { _result = result; _klass = klass; _klass_reg = klass_reg; _info = new CodeEmitInfo(info); - assert(stub_id == Runtime1::new_instance_id || - stub_id == Runtime1::fast_new_instance_id || - stub_id == Runtime1::fast_new_instance_init_check_id, + assert(stub_id == C1StubId::new_instance_id || + stub_id == C1StubId::fast_new_instance_id || + stub_id == C1StubId::fast_new_instance_init_check_id, "need new_instance id"); _stub_id = stub_id; } @@ -236,7 +236,7 @@ NewTypeArrayStub::NewTypeArrayStub(LIR_Opr klass_reg, LIR_Opr length, LIR_Opr re void NewTypeArrayStub::emit_code(LIR_Assembler* ce) { __ bind(_entry); - address entry = Runtime1::entry_for(Runtime1::new_type_array_id); + address entry = Runtime1::entry_for(C1StubId::new_type_array_id); //__ load_const_optimized(R0, entry); __ add_const_optimized(R0, R29_TOC, MacroAssembler::offset_to_global_toc(entry)); __ mr_if_needed(/*op->tmp1()->as_register()*/ R5_ARG3, _length->as_register()); // already sign-extended @@ -259,7 +259,7 @@ NewObjectArrayStub::NewObjectArrayStub(LIR_Opr klass_reg, LIR_Opr length, LIR_Op void NewObjectArrayStub::emit_code(LIR_Assembler* ce) { __ bind(_entry); - address entry = Runtime1::entry_for(Runtime1::new_object_array_id); + address entry = Runtime1::entry_for(C1StubId::new_object_array_id); //__ load_const_optimized(R0, entry); __ add_const_optimized(R0, R29_TOC, MacroAssembler::offset_to_global_toc(entry)); __ mr_if_needed(/*op->tmp1()->as_register()*/ R5_ARG3, _length->as_register()); // already sign-extended @@ -272,7 +272,7 @@ void NewObjectArrayStub::emit_code(LIR_Assembler* ce) { void MonitorEnterStub::emit_code(LIR_Assembler* ce) { __ bind(_entry); - address stub = Runtime1::entry_for(ce->compilation()->has_fpu_code() ? Runtime1::monitorenter_id : Runtime1::monitorenter_nofpu_id); + address stub = Runtime1::entry_for(ce->compilation()->has_fpu_code() ? C1StubId::monitorenter_id : C1StubId::monitorenter_nofpu_id); //__ load_const_optimized(R0, stub); __ add_const_optimized(R0, R29_TOC, MacroAssembler::offset_to_global_toc(stub)); __ mr_if_needed(/*scratch_opr()->as_register()*/ R4_ARG2, _obj_reg->as_register()); @@ -289,7 +289,7 @@ void MonitorExitStub::emit_code(LIR_Assembler* ce) { if (_compute_lock) { ce->monitor_address(_monitor_ix, _lock_reg); } - address stub = Runtime1::entry_for(ce->compilation()->has_fpu_code() ? Runtime1::monitorexit_id : Runtime1::monitorexit_nofpu_id); + address stub = Runtime1::entry_for(ce->compilation()->has_fpu_code() ? C1StubId::monitorexit_id : C1StubId::monitorexit_nofpu_id); //__ load_const_optimized(R0, stub); __ add_const_optimized(R0, R29_TOC, MacroAssembler::offset_to_global_toc(stub)); assert(_lock_reg->as_register() == R4_ARG2, ""); @@ -403,12 +403,12 @@ void PatchingStub::emit_code(LIR_Assembler* ce) { address target = nullptr; relocInfo::relocType reloc_type = relocInfo::none; switch (_id) { - case access_field_id: target = Runtime1::entry_for(Runtime1::access_field_patching_id); break; - case load_klass_id: target = Runtime1::entry_for(Runtime1::load_klass_patching_id); + case access_field_id: target = Runtime1::entry_for(C1StubId::access_field_patching_id); break; + case load_klass_id: target = Runtime1::entry_for(C1StubId::load_klass_patching_id); reloc_type = relocInfo::metadata_type; break; - case load_mirror_id: target = Runtime1::entry_for(Runtime1::load_mirror_patching_id); + case load_mirror_id: target = Runtime1::entry_for(C1StubId::load_mirror_patching_id); reloc_type = relocInfo::oop_type; break; - case load_appendix_id: target = Runtime1::entry_for(Runtime1::load_appendix_patching_id); + case load_appendix_id: target = Runtime1::entry_for(C1StubId::load_appendix_patching_id); reloc_type = relocInfo::oop_type; break; default: ShouldNotReachHere(); } @@ -434,7 +434,7 @@ void PatchingStub::emit_code(LIR_Assembler* ce) { void DeoptimizeStub::emit_code(LIR_Assembler* ce) { __ bind(_entry); - address stub = Runtime1::entry_for(Runtime1::deoptimize_id); + address stub = Runtime1::entry_for(C1StubId::deoptimize_id); //__ load_const_optimized(R0, stub); __ add_const_optimized(R0, R29_TOC, MacroAssembler::offset_to_global_toc(stub)); __ mtctr(R0); diff --git a/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp b/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp index 88d635f2b85..684c06614a9 100644 --- a/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp +++ b/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp @@ -176,7 +176,7 @@ int LIR_Assembler::emit_exception_handler() { } int offset = code_offset(); - address entry_point = CAST_FROM_FN_PTR(address, Runtime1::entry_for(Runtime1::handle_exception_from_callee_id)); + address entry_point = CAST_FROM_FN_PTR(address, Runtime1::entry_for(C1StubId::handle_exception_from_callee_id)); //__ load_const_optimized(R0, entry_point); __ add_const_optimized(R0, R29_TOC, MacroAssembler::offset_to_global_toc(entry_point)); __ mtctr(R0); @@ -222,7 +222,7 @@ int LIR_Assembler::emit_unwind_handler() { } // Dispatch to the unwind logic. - address unwind_stub = Runtime1::entry_for(Runtime1::unwind_exception_id); + address unwind_stub = Runtime1::entry_for(C1StubId::unwind_exception_id); //__ load_const_optimized(R0, unwind_stub); __ add_const_optimized(R0, R29_TOC, MacroAssembler::offset_to_global_toc(unwind_stub)); if (preserve_exception) { __ mr(Rexception, Rexception_save); } @@ -1800,8 +1800,8 @@ void LIR_Assembler::throw_op(LIR_Opr exceptionPC, LIR_Opr exceptionOop, CodeEmit __ calculate_address_from_global_toc(exceptionPC->as_register(), pc_for_athrow, true, true, /*add_relocation*/ true); add_call_info(pc_for_athrow_offset, info); // for exception handler - address stub = Runtime1::entry_for(compilation()->has_fpu_code() ? Runtime1::handle_exception_id - : Runtime1::handle_exception_nofpu_id); + address stub = Runtime1::entry_for(compilation()->has_fpu_code() ? C1StubId::handle_exception_id + : C1StubId::handle_exception_nofpu_id); //__ load_const_optimized(R0, stub); __ add_const_optimized(R0, R29_TOC, MacroAssembler::offset_to_global_toc(stub)); __ mtctr(R0); @@ -1859,7 +1859,7 @@ void LIR_Assembler::emit_arraycopy(LIR_OpArrayCopy* op) { __ stw(R11_scratch1, simm16_offs, tmp); } #endif - __ call_c_with_frame_resize(copyfunc_addr, /*stub does not need resized frame*/ 0); + __ call_c(copyfunc_addr, relocInfo::runtime_call_type); __ nand(tmp, R3_RET, R3_RET); __ subf(length, tmp, length); @@ -2001,7 +2001,7 @@ void LIR_Assembler::emit_arraycopy(LIR_OpArrayCopy* op) { __ check_klass_subtype_fast_path(sub_klass, super_klass, tmp, tmp2, &cont, copyfunc_addr != nullptr ? ©func : &slow, nullptr); - address slow_stc = Runtime1::entry_for(Runtime1::slow_subtype_check_id); + address slow_stc = Runtime1::entry_for(C1StubId::slow_subtype_check_id); //__ load_const_optimized(tmp, slow_stc, tmp2); __ calculate_address_from_global_toc(tmp, slow_stc, true, true, false); __ mtctr(tmp); @@ -2057,7 +2057,7 @@ void LIR_Assembler::emit_arraycopy(LIR_OpArrayCopy* op) { int sco_offset = in_bytes(Klass::super_check_offset_offset()); __ lwz(chk_off, sco_offset, super_k); - __ call_c_with_frame_resize(copyfunc_addr, /*stub does not need resized frame*/ 0); + __ call_c(copyfunc_addr, relocInfo::runtime_call_type); #ifndef PRODUCT if (PrintC1Statistics) { @@ -2181,7 +2181,7 @@ void LIR_Assembler::emit_arraycopy(LIR_OpArrayCopy* op) { // Arraycopy stubs takes a length in number of elements, so don't scale it. __ mr(len, length); - __ call_c_with_frame_resize(entry, /*stub does not need resized frame*/ 0); + __ call_c(entry, relocInfo::runtime_call_type); if (stub != nullptr) { __ bind(*stub->continuation()); @@ -2274,6 +2274,7 @@ void LIR_Assembler::emit_alloc_obj(LIR_OpAllocObj* op) { } __ lbz(op->tmp1()->as_register(), in_bytes(InstanceKlass::init_state_offset()), op->klass()->as_register()); + // acquire barrier included in membar_storestore() which follows the allocation immediately. __ cmpwi(CCR0, op->tmp1()->as_register(), InstanceKlass::fully_initialized); __ bc_far_optimized(Assembler::bcondCRbiIs0, __ bi0(CCR0, Assembler::equal), *op->stub()->entry()); } @@ -2452,7 +2453,7 @@ void LIR_Assembler::emit_typecheck_helper(LIR_OpTypeCheck *op, Label* success, L __ b(*success); } else { // Call out-of-line instance of __ check_klass_subtype_slow_path(...): - address entry = Runtime1::entry_for(Runtime1::slow_subtype_check_id); + address entry = Runtime1::entry_for(C1StubId::slow_subtype_check_id); // Stub needs fixed registers (tmp1-3). Register original_k_RInfo = op->tmp1()->as_register(); Register original_klass_RInfo = op->tmp2()->as_register(); @@ -2543,7 +2544,7 @@ void LIR_Assembler::emit_opTypeCheck(LIR_OpTypeCheck* op) { __ check_klass_subtype_fast_path(klass_RInfo, k_RInfo, Rtmp1, R0, &done, &failure, nullptr); // Call out-of-line instance of __ check_klass_subtype_slow_path(...): - const address slow_path = Runtime1::entry_for(Runtime1::slow_subtype_check_id); + const address slow_path = Runtime1::entry_for(C1StubId::slow_subtype_check_id); //__ load_const_optimized(R0, slow_path); __ add_const_optimized(R0, R29_TOC, MacroAssembler::offset_to_global_toc(slow_path)); __ mtctr(R0); @@ -2850,8 +2851,8 @@ void LIR_Assembler::negate(LIR_Opr left, LIR_Opr dest, LIR_Opr tmp) { void LIR_Assembler::rt_call(LIR_Opr result, address dest, const LIR_OprList* args, LIR_Opr tmp, CodeEmitInfo* info) { // Stubs: Called via rt_call, but dest is a stub address (no function descriptor). - if (dest == Runtime1::entry_for(Runtime1::register_finalizer_id) || - dest == Runtime1::entry_for(Runtime1::new_multi_array_id )) { + if (dest == Runtime1::entry_for(C1StubId::register_finalizer_id) || + dest == Runtime1::entry_for(C1StubId::new_multi_array_id )) { //__ load_const_optimized(R0, dest); __ add_const_optimized(R0, R29_TOC, MacroAssembler::offset_to_global_toc(dest)); __ mtctr(R0); @@ -2862,7 +2863,7 @@ void LIR_Assembler::rt_call(LIR_Opr result, address dest, return; } - __ call_c_with_frame_resize(dest, /*no resizing*/ 0); + __ call_c(dest, relocInfo::runtime_call_type); if (info != nullptr) { add_call_info_here(info); } diff --git a/src/hotspot/cpu/ppc/c1_LIRGenerator_ppc.cpp b/src/hotspot/cpu/ppc/c1_LIRGenerator_ppc.cpp index 04762a22c61..7973e9d0545 100644 --- a/src/hotspot/cpu/ppc/c1_LIRGenerator_ppc.cpp +++ b/src/hotspot/cpu/ppc/c1_LIRGenerator_ppc.cpp @@ -1032,7 +1032,7 @@ void LIRGenerator::do_NewMultiArray(NewMultiArray* x) { args->append(rank); args->append(varargs); const LIR_Opr reg = result_register_for(x->type()); - __ call_runtime(Runtime1::entry_for(Runtime1::new_multi_array_id), + __ call_runtime(Runtime1::entry_for(C1StubId::new_multi_array_id), LIR_OprFact::illegalOpr, reg, args, info); @@ -1067,7 +1067,7 @@ void LIRGenerator::do_CheckCast(CheckCast* x) { if (x->is_incompatible_class_change_check()) { assert(patching_info == nullptr, "can't patch this"); - stub = new SimpleExceptionStub(Runtime1::throw_incompatible_class_change_error_id, + stub = new SimpleExceptionStub(C1StubId::throw_incompatible_class_change_error_id, LIR_OprFact::illegalOpr, info_for_exception); } else if (x->is_invokespecial_receiver_check()) { assert(patching_info == nullptr, "can't patch this"); @@ -1075,7 +1075,7 @@ void LIRGenerator::do_CheckCast(CheckCast* x) { Deoptimization::Reason_class_check, Deoptimization::Action_none); } else { - stub = new SimpleExceptionStub(Runtime1::throw_class_cast_exception_id, obj.result(), info_for_exception); + stub = new SimpleExceptionStub(C1StubId::throw_class_cast_exception_id, obj.result(), info_for_exception); } // Following registers are used by slow_subtype_check: LIR_Opr tmp1 = FrameMap::R4_oop_opr; // super_klass diff --git a/src/hotspot/cpu/ppc/c1_MacroAssembler_ppc.cpp b/src/hotspot/cpu/ppc/c1_MacroAssembler_ppc.cpp index abc439df827..83fad376d29 100644 --- a/src/hotspot/cpu/ppc/c1_MacroAssembler_ppc.cpp +++ b/src/hotspot/cpu/ppc/c1_MacroAssembler_ppc.cpp @@ -86,13 +86,13 @@ void C1_MacroAssembler::lock_object(Register Rmark, Register Roop, Register Rbox if (DiagnoseSyncOnValueBasedClasses != 0) { load_klass(Rscratch, Roop); - lwz(Rscratch, in_bytes(Klass::access_flags_offset()), Rscratch); - testbitdi(CCR0, R0, Rscratch, exact_log2(JVM_ACC_IS_VALUE_BASED_CLASS)); + lbz(Rscratch, in_bytes(Klass::misc_flags_offset()), Rscratch); + testbitdi(CCR0, R0, Rscratch, exact_log2(KlassFlags::_misc_is_value_based_class)); bne(CCR0, slow_int); } if (LockingMode == LM_LIGHTWEIGHT) { - lightweight_lock(Roop, Rmark, Rscratch, slow_int); + lightweight_lock(Rbox, Roop, Rmark, Rscratch, slow_int); } else if (LockingMode == LM_LEGACY) { // ... and mark it unlocked. ori(Rmark, Rmark, markWord::unlocked_value); @@ -293,7 +293,7 @@ void C1_MacroAssembler::initialize_object( if (CURRENT_ENV->dtrace_alloc_probes()) { Unimplemented(); // assert(obj == O0, "must be"); -// call(CAST_FROM_FN_PTR(address, Runtime1::entry_for(Runtime1::dtrace_object_alloc_id)), +// call(CAST_FROM_FN_PTR(address, Runtime1::entry_for(C1StubId::dtrace_object_alloc_id)), // relocInfo::runtime_call_type); } @@ -369,7 +369,7 @@ void C1_MacroAssembler::allocate_array( if (CURRENT_ENV->dtrace_alloc_probes()) { Unimplemented(); //assert(obj == O0, "must be"); - //call(CAST_FROM_FN_PTR(address, Runtime1::entry_for(Runtime1::dtrace_object_alloc_id)), + //call(CAST_FROM_FN_PTR(address, Runtime1::entry_for(C1StubId::dtrace_object_alloc_id)), // relocInfo::runtime_call_type); } @@ -398,20 +398,9 @@ void C1_MacroAssembler::null_check(Register r, Label* Lnull) { if (TrapBasedNullChecks) { // SIGTRAP based trap_null_check(r); } else { // explicit - //const address exception_entry = Runtime1::entry_for(Runtime1::throw_null_pointer_exception_id); + //const address exception_entry = Runtime1::entry_for(C1StubId::throw_null_pointer_exception_id); assert(Lnull != nullptr, "must have Label for explicit check"); cmpdi(CCR0, r, 0); bc_far_optimized(Assembler::bcondCRbiIs1, bi0(CCR0, Assembler::equal), *Lnull); } } - -address C1_MacroAssembler::call_c_with_frame_resize(address dest, int frame_resize) { - if (frame_resize) { resize_frame(-frame_resize, R0); } -#if defined(ABI_ELFv2) - address return_pc = call_c(dest, relocInfo::runtime_call_type); -#else - address return_pc = call_c(CAST_FROM_FN_PTR(FunctionDescriptor*, dest), relocInfo::runtime_call_type); -#endif - if (frame_resize) { resize_frame(frame_resize, R0); } - return return_pc; -} diff --git a/src/hotspot/cpu/ppc/c1_MacroAssembler_ppc.hpp b/src/hotspot/cpu/ppc/c1_MacroAssembler_ppc.hpp index c0a3dd3b83c..381cb63f832 100644 --- a/src/hotspot/cpu/ppc/c1_MacroAssembler_ppc.hpp +++ b/src/hotspot/cpu/ppc/c1_MacroAssembler_ppc.hpp @@ -89,6 +89,5 @@ void null_check(Register r, Label *Lnull = nullptr); - address call_c_with_frame_resize(address dest, int frame_resize); #endif // CPU_PPC_C1_MACROASSEMBLER_PPC_HPP diff --git a/src/hotspot/cpu/ppc/c1_Runtime1_ppc.cpp b/src/hotspot/cpu/ppc/c1_Runtime1_ppc.cpp index 63914c5d1cb..654626d66d8 100644 --- a/src/hotspot/cpu/ppc/c1_Runtime1_ppc.cpp +++ b/src/hotspot/cpu/ppc/c1_Runtime1_ppc.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, 2023 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -62,7 +62,7 @@ int StubAssembler::call_RT(Register oop_result1, Register metadata_result, // ARG1 must hold thread address. mr(R3_ARG1, R16_thread); - address return_pc = call_c_with_frame_resize(entry_point, /*No resize, we have a C compatible frame.*/0); + address return_pc = call_c(entry_point); reset_last_Java_frame(); @@ -97,12 +97,12 @@ int StubAssembler::call_RT(Register oop_result1, Register metadata_result, //load_const_optimized(R0, StubRoutines::forward_exception_entry()); //mtctr(R0); //bctr(); - } else if (_stub_id == Runtime1::forward_exception_id) { + } else if (_stub_id == (int)C1StubId::forward_exception_id) { should_not_reach_here(); } else { // keep stub frame for next call_RT - //load_const_optimized(R0, Runtime1::entry_for(Runtime1::forward_exception_id)); - add_const_optimized(R0, R29_TOC, MacroAssembler::offset_to_global_toc(Runtime1::entry_for(Runtime1::forward_exception_id))); + //load_const_optimized(R0, Runtime1::entry_for(C1StubId::forward_exception_id)); + add_const_optimized(R0, R29_TOC, MacroAssembler::offset_to_global_toc(Runtime1::entry_for(C1StubId::forward_exception_id))); mtctr(R0); bctr(); } @@ -388,7 +388,7 @@ OopMapSet* Runtime1::generate_patching(StubAssembler* sasm, address target) { return oop_maps; } -OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { +OopMapSet* Runtime1::generate_code_for(C1StubId id, StubAssembler* sasm) { OopMapSet* oop_maps = nullptr; // For better readability. @@ -397,22 +397,22 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { // Stub code & info for the different stubs. switch (id) { - case forward_exception_id: + case C1StubId::forward_exception_id: { oop_maps = generate_handle_exception(id, sasm); } break; - case new_instance_id: - case fast_new_instance_id: - case fast_new_instance_init_check_id: + case C1StubId::new_instance_id: + case C1StubId::fast_new_instance_id: + case C1StubId::fast_new_instance_init_check_id: { - if (id == new_instance_id) { + if (id == C1StubId::new_instance_id) { __ set_info("new_instance", dont_gc_arguments); - } else if (id == fast_new_instance_id) { + } else if (id == C1StubId::fast_new_instance_id) { __ set_info("fast new_instance", dont_gc_arguments); } else { - assert(id == fast_new_instance_init_check_id, "bad StubID"); + assert(id == C1StubId::fast_new_instance_init_check_id, "bad C1StubId"); __ set_info("fast new_instance init check", dont_gc_arguments); } @@ -422,15 +422,15 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case counter_overflow_id: + case C1StubId::counter_overflow_id: // Bci and method are on stack. oop_maps = stub_call_with_stack_parms(sasm, noreg, CAST_FROM_FN_PTR(address, counter_overflow), 2); break; - case new_type_array_id: - case new_object_array_id: + case C1StubId::new_type_array_id: + case C1StubId::new_object_array_id: { - if (id == new_type_array_id) { + if (id == C1StubId::new_type_array_id) { __ set_info("new_type_array", dont_gc_arguments); } else { __ set_info("new_object_array", dont_gc_arguments); @@ -439,7 +439,7 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { #ifdef ASSERT // Assert object type is really an array of the proper kind. { - int tag = (id == new_type_array_id) ? Klass::_lh_array_tag_type_value : Klass::_lh_array_tag_obj_value; + int tag = (id == C1StubId::new_type_array_id) ? Klass::_lh_array_tag_type_value : Klass::_lh_array_tag_obj_value; Label ok; __ lwz(R0, in_bytes(Klass::layout_helper_offset()), R4_ARG2); __ srawi(R0, R0, Klass::_lh_array_tag_shift); @@ -453,7 +453,7 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { // We don't support eden allocation. - if (id == new_type_array_id) { + if (id == C1StubId::new_type_array_id) { oop_maps = generate_stub_call(sasm, R3_RET, CAST_FROM_FN_PTR(address, new_type_array), R4_ARG2, R5_ARG3); } else { oop_maps = generate_stub_call(sasm, R3_RET, CAST_FROM_FN_PTR(address, new_object_array), R4_ARG2, R5_ARG3); @@ -461,7 +461,7 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case new_multi_array_id: + case C1StubId::new_multi_array_id: { // R4: klass // R5: rank @@ -471,7 +471,7 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case register_finalizer_id: + case C1StubId::register_finalizer_id: { __ set_info("register_finalizer", dont_gc_arguments); // This code is called via rt_call. Hence, caller-save registers have been saved. @@ -479,8 +479,8 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { // Load the klass and check the has finalizer flag. __ load_klass(t, R3_ARG1); - __ lwz(t, in_bytes(Klass::access_flags_offset()), t); - __ testbitdi(CCR0, R0, t, exact_log2(JVM_ACC_HAS_FINALIZER)); + __ lbz(t, in_bytes(Klass::misc_flags_offset()), t); + __ testbitdi(CCR0, R0, t, exact_log2(KlassFlags::_misc_has_finalizer)); // Return if has_finalizer bit == 0 (CR0.eq). __ bclr(Assembler::bcondCRbiIs1, Assembler::bi0(CCR0, Assembler::equal), Assembler::bhintbhBCLRisReturn); @@ -501,50 +501,50 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case throw_range_check_failed_id: + case C1StubId::throw_range_check_failed_id: { __ set_info("range_check_failed", dont_gc_arguments); // Arguments will be discarded. oop_maps = generate_exception_throw_with_stack_parms(sasm, CAST_FROM_FN_PTR(address, throw_range_check_exception), 2); } break; - case throw_index_exception_id: + case C1StubId::throw_index_exception_id: { __ set_info("index_range_check_failed", dont_gc_arguments); // Arguments will be discarded. oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_index_exception), true); } break; - case throw_div0_exception_id: + case C1StubId::throw_div0_exception_id: { __ set_info("throw_div0_exception", dont_gc_arguments); oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_div0_exception), false); } break; - case throw_null_pointer_exception_id: + case C1StubId::throw_null_pointer_exception_id: { __ set_info("throw_null_pointer_exception", dont_gc_arguments); oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_null_pointer_exception), false); } break; - case handle_exception_nofpu_id: - case handle_exception_id: + case C1StubId::handle_exception_nofpu_id: + case C1StubId::handle_exception_id: { __ set_info("handle_exception", dont_gc_arguments); oop_maps = generate_handle_exception(id, sasm); } break; - case handle_exception_from_callee_id: + case C1StubId::handle_exception_from_callee_id: { __ set_info("handle_exception_from_callee", dont_gc_arguments); oop_maps = generate_handle_exception(id, sasm); } break; - case unwind_exception_id: + case C1StubId::unwind_exception_id: { const Register Rexception = R3 /*LIRGenerator::exceptionOopOpr()*/, Rexception_pc = R4 /*LIRGenerator::exceptionPcOpr()*/, @@ -572,28 +572,28 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case throw_array_store_exception_id: + case C1StubId::throw_array_store_exception_id: { __ set_info("throw_array_store_exception", dont_gc_arguments); oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_array_store_exception), true); } break; - case throw_class_cast_exception_id: + case C1StubId::throw_class_cast_exception_id: { __ set_info("throw_class_cast_exception", dont_gc_arguments); oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_class_cast_exception), true); } break; - case throw_incompatible_class_change_error_id: + case C1StubId::throw_incompatible_class_change_error_id: { __ set_info("throw_incompatible_class_cast_exception", dont_gc_arguments); oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_incompatible_class_change_error), false); } break; - case slow_subtype_check_id: + case C1StubId::slow_subtype_check_id: { // Support for uint StubRoutine::partial_subtype_check( Klass sub, Klass super ); const Register sub_klass = R5, super_klass = R4, @@ -605,12 +605,12 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case monitorenter_nofpu_id: - case monitorenter_id: + case C1StubId::monitorenter_nofpu_id: + case C1StubId::monitorenter_id: { __ set_info("monitorenter", dont_gc_arguments); - int save_fpu_registers = (id == monitorenter_id); + int save_fpu_registers = (id == C1StubId::monitorenter_id); // Make a frame and preserve the caller's caller-save registers. OopMap* oop_map = save_live_registers(sasm, save_fpu_registers); @@ -624,15 +624,15 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case monitorexit_nofpu_id: - case monitorexit_id: + case C1StubId::monitorexit_nofpu_id: + case C1StubId::monitorexit_id: { // note: Really a leaf routine but must setup last java sp // => use call_RT for now (speed can be improved by // doing last java sp setup manually). __ set_info("monitorexit", dont_gc_arguments); - int save_fpu_registers = (id == monitorexit_id); + int save_fpu_registers = (id == C1StubId::monitorexit_id); // Make a frame and preserve the caller's caller-save registers. OopMap* oop_map = save_live_registers(sasm, save_fpu_registers); @@ -646,7 +646,7 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case deoptimize_id: + case C1StubId::deoptimize_id: { __ set_info("deoptimize", dont_gc_arguments); __ std(R0, -8, R1_SP); // Pass trap_request on stack. @@ -662,35 +662,35 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case access_field_patching_id: + case C1StubId::access_field_patching_id: { __ set_info("access_field_patching", dont_gc_arguments); oop_maps = generate_patching(sasm, CAST_FROM_FN_PTR(address, access_field_patching)); } break; - case load_klass_patching_id: + case C1StubId::load_klass_patching_id: { __ set_info("load_klass_patching", dont_gc_arguments); oop_maps = generate_patching(sasm, CAST_FROM_FN_PTR(address, move_klass_patching)); } break; - case load_mirror_patching_id: + case C1StubId::load_mirror_patching_id: { __ set_info("load_mirror_patching", dont_gc_arguments); oop_maps = generate_patching(sasm, CAST_FROM_FN_PTR(address, move_mirror_patching)); } break; - case load_appendix_patching_id: + case C1StubId::load_appendix_patching_id: { __ set_info("load_appendix_patching", dont_gc_arguments); oop_maps = generate_patching(sasm, CAST_FROM_FN_PTR(address, move_appendix_patching)); } break; - case dtrace_object_alloc_id: + case C1StubId::dtrace_object_alloc_id: { // O0: object __ unimplemented("stub dtrace_object_alloc_id"); __ set_info("dtrace_object_alloc", dont_gc_arguments); @@ -710,7 +710,7 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case predicate_failed_trap_id: + case C1StubId::predicate_failed_trap_id: { __ set_info("predicate_failed_trap", dont_gc_arguments); OopMap* oop_map = save_live_registers(sasm); @@ -754,7 +754,7 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } -OopMapSet* Runtime1::generate_handle_exception(StubID id, StubAssembler* sasm) { +OopMapSet* Runtime1::generate_handle_exception(C1StubId id, StubAssembler* sasm) { __ block_comment("generate_handle_exception"); // Save registers, if required. @@ -764,7 +764,7 @@ OopMapSet* Runtime1::generate_handle_exception(StubID id, StubAssembler* sasm) { Rexception_pc = R4 /*LIRGenerator::exceptionPcOpr()*/; switch (id) { - case forward_exception_id: + case C1StubId::forward_exception_id: // We're handling an exception in the context of a compiled frame. // The registers have been saved in the standard places. Perform // an exception lookup in the caller and dispatch to the handler @@ -780,12 +780,12 @@ OopMapSet* Runtime1::generate_handle_exception(StubID id, StubAssembler* sasm) { __ ld(Rexception_pc, _abi0(lr), Rexception_pc); __ std(R0, in_bytes(JavaThread::pending_exception_offset()), R16_thread); break; - case handle_exception_nofpu_id: - case handle_exception_id: + case C1StubId::handle_exception_nofpu_id: + case C1StubId::handle_exception_id: // At this point all registers MAY be live. - oop_map = save_live_registers(sasm, id != handle_exception_nofpu_id, Rexception_pc); + oop_map = save_live_registers(sasm, id != C1StubId::handle_exception_nofpu_id, Rexception_pc); break; - case handle_exception_from_callee_id: + case C1StubId::handle_exception_from_callee_id: // At this point all registers except exception oop and exception pc are dead. oop_map = new OopMap(frame_size_in_bytes / sizeof(jint), 0); sasm->set_frame_size(frame_size_in_bytes / BytesPerWord); @@ -824,13 +824,13 @@ OopMapSet* Runtime1::generate_handle_exception(StubID id, StubAssembler* sasm) { // Restore the registers that were saved at the beginning, remove // the frame and jump to the exception handler. switch (id) { - case forward_exception_id: - case handle_exception_nofpu_id: - case handle_exception_id: - restore_live_registers(sasm, noreg, noreg, id != handle_exception_nofpu_id); + case C1StubId::forward_exception_id: + case C1StubId::handle_exception_nofpu_id: + case C1StubId::handle_exception_id: + restore_live_registers(sasm, noreg, noreg, id != C1StubId::handle_exception_nofpu_id); __ bctr(); break; - case handle_exception_from_callee_id: { + case C1StubId::handle_exception_from_callee_id: { __ pop_frame(); __ ld(Rexception_pc, _abi0(lr), R1_SP); __ mtlr(Rexception_pc); diff --git a/src/hotspot/cpu/ppc/c2_MacroAssembler_ppc.cpp b/src/hotspot/cpu/ppc/c2_MacroAssembler_ppc.cpp index cc69c0abe36..1147c3b42b2 100644 --- a/src/hotspot/cpu/ppc/c2_MacroAssembler_ppc.cpp +++ b/src/hotspot/cpu/ppc/c2_MacroAssembler_ppc.cpp @@ -39,12 +39,12 @@ void C2_MacroAssembler::fast_lock_lightweight(ConditionRegister flag, Register obj, Register box, Register tmp1, Register tmp2, Register tmp3) { - compiler_fast_lock_lightweight_object(flag, obj, tmp1, tmp2, tmp3); + compiler_fast_lock_lightweight_object(flag, obj, box, tmp1, tmp2, tmp3); } void C2_MacroAssembler::fast_unlock_lightweight(ConditionRegister flag, Register obj, Register box, Register tmp1, Register tmp2, Register tmp3) { - compiler_fast_unlock_lightweight_object(flag, obj, tmp1, tmp2, tmp3); + compiler_fast_unlock_lightweight_object(flag, obj, box, tmp1, tmp2, tmp3); } // Intrinsics for CompactStrings diff --git a/src/hotspot/cpu/ppc/frame_ppc.cpp b/src/hotspot/cpu/ppc/frame_ppc.cpp index 4c1ffeb0d76..eb16af5e9db 100644 --- a/src/hotspot/cpu/ppc/frame_ppc.cpp +++ b/src/hotspot/cpu/ppc/frame_ppc.cpp @@ -117,9 +117,9 @@ bool frame::safe_for_sender(JavaThread *thread) { return false; } - common_abi* sender_abi = (common_abi*) fp; + volatile common_abi* sender_abi = (common_abi*) fp; // May get updated concurrently by deoptimization! intptr_t* sender_sp = (intptr_t*) fp; - address sender_pc = (address) sender_abi->lr;; + address sender_pc = (address) sender_abi->lr; if (Continuation::is_return_barrier_entry(sender_pc)) { // If our sender_pc is the return barrier, then our "real" sender is the continuation entry @@ -134,9 +134,18 @@ bool frame::safe_for_sender(JavaThread *thread) { return false; } + intptr_t* unextended_sender_sp = is_interpreted_frame() ? interpreter_frame_sender_sp() : sender_sp; + + // If the sender is a deoptimized nmethod we need to check if the original pc is valid. + nmethod* sender_nm = sender_blob->as_nmethod_or_null(); + if (sender_nm != nullptr && sender_nm->is_deopt_pc(sender_pc)) { + address orig_pc = *(address*)((address)unextended_sender_sp + sender_nm->orig_pc_offset()); + if (!sender_nm->insts_contains_inclusive(orig_pc)) return false; + } + // It should be safe to construct the sender though it might not be valid. - frame sender(sender_sp, sender_pc, nullptr /* unextended_sp */, nullptr /* fp */, sender_blob); + frame sender(sender_sp, sender_pc, unextended_sender_sp, nullptr /* fp */, sender_blob); // Do we have a valid fp? address sender_fp = (address) sender.fp(); diff --git a/src/hotspot/cpu/ppc/gc/g1/g1BarrierSetAssembler_ppc.cpp b/src/hotspot/cpu/ppc/gc/g1/g1BarrierSetAssembler_ppc.cpp index 7d230d301c2..39693bdf925 100644 --- a/src/hotspot/cpu/ppc/gc/g1/g1BarrierSetAssembler_ppc.cpp +++ b/src/hotspot/cpu/ppc/gc/g1/g1BarrierSetAssembler_ppc.cpp @@ -41,10 +41,20 @@ #include "c1/c1_LIRAssembler.hpp" #include "c1/c1_MacroAssembler.hpp" #include "gc/g1/c1/g1BarrierSetC1.hpp" -#endif +#endif // COMPILER1 +#ifdef COMPILER2 +#include "gc/g1/c2/g1BarrierSetC2.hpp" +#endif // COMPILER2 #define __ masm-> +static void generate_marking_inactive_test(MacroAssembler* masm) { + int active_offset = in_bytes(G1ThreadLocalData::satb_mark_queue_active_offset()); + assert(in_bytes(SATBMarkQueue::byte_width_of_active()) == 1, "Assumption"); + __ lbz(R0, active_offset, R16_thread); // tmp1 := *(mark queue active address) + __ cmpwi(CCR0, R0, 0); +} + void G1BarrierSetAssembler::gen_write_ref_array_pre_barrier(MacroAssembler* masm, DecoratorSet decorators, Register from, Register to, Register count, Register preserve1, Register preserve2) { @@ -58,13 +68,7 @@ void G1BarrierSetAssembler::gen_write_ref_array_pre_barrier(MacroAssembler* masm Label filtered; // Is marking active? - if (in_bytes(SATBMarkQueue::byte_width_of_active()) == 4) { - __ lwz(R0, in_bytes(G1ThreadLocalData::satb_mark_queue_active_offset()), R16_thread); - } else { - guarantee(in_bytes(SATBMarkQueue::byte_width_of_active()) == 1, "Assumption"); - __ lbz(R0, in_bytes(G1ThreadLocalData::satb_mark_queue_active_offset()), R16_thread); - } - __ cmpdi(CCR0, R0, 0); + generate_marking_inactive_test(masm); __ beq(CCR0, filtered); __ save_LR(R0); @@ -109,35 +113,48 @@ void G1BarrierSetAssembler::gen_write_ref_array_post_barrier(MacroAssembler* mas __ restore_LR(R0); } +static void generate_queue_insertion(MacroAssembler* masm, ByteSize index_offset, ByteSize buffer_offset, Label& runtime, + const Register value, const Register temp) { + assert_different_registers(value, temp); + // Can we store a value in the given thread's buffer? + // (The index field is typed as size_t.) + __ ld(temp, in_bytes(index_offset), R16_thread); // temp := *(index address) + __ cmpdi(CCR0, temp, 0); // jump to runtime if index == 0 (full buffer) + __ beq(CCR0, runtime); + // The buffer is not full, store value into it. + __ ld(R0, in_bytes(buffer_offset), R16_thread); // R0 := buffer address + __ addi(temp, temp, -wordSize); // temp := next index + __ std(temp, in_bytes(index_offset), R16_thread); // *(index address) := next index + __ stdx(value, temp, R0); // *(buffer address + next index) := value +} + void G1BarrierSetAssembler::g1_write_barrier_pre(MacroAssembler* masm, DecoratorSet decorators, Register obj, RegisterOrConstant ind_or_offs, Register pre_val, Register tmp1, Register tmp2, MacroAssembler::PreservationLevel preservation_level) { + assert_different_registers(pre_val, tmp1, tmp2); + bool not_null = (decorators & IS_NOT_NULL) != 0, preloaded = obj == noreg; Register nv_save = noreg; - if (preloaded) { + // Determine necessary runtime invocation preservation measures + const bool needs_frame = preservation_level >= MacroAssembler::PRESERVATION_FRAME_LR; + const bool preserve_gp_registers = preservation_level >= MacroAssembler::PRESERVATION_FRAME_LR_GP_REGS; + const bool preserve_fp_registers = preservation_level >= MacroAssembler::PRESERVATION_FRAME_LR_GP_FP_REGS; + int nbytes_save = 0; + + if (pre_val->is_volatile() && preloaded && !preserve_gp_registers) { // We are not loading the previous value so make // sure that we don't trash the value in pre_val // with the code below. - assert_different_registers(pre_val, tmp1, tmp2); - if (pre_val->is_volatile()) { - nv_save = !tmp1->is_volatile() ? tmp1 : tmp2; - assert(!nv_save->is_volatile(), "need one nv temp register if pre_val lives in volatile register"); - } + nv_save = !tmp1->is_volatile() ? tmp1 : tmp2; + assert(!nv_save->is_volatile(), "need one nv temp register if pre_val lives in volatile register"); } Label runtime, filtered; - // Is marking active? - if (in_bytes(SATBMarkQueue::byte_width_of_active()) == 4) { - __ lwz(tmp1, in_bytes(G1ThreadLocalData::satb_mark_queue_active_offset()), R16_thread); - } else { - guarantee(in_bytes(SATBMarkQueue::byte_width_of_active()) == 1, "Assumption"); - __ lbz(tmp1, in_bytes(G1ThreadLocalData::satb_mark_queue_active_offset()), R16_thread); - } - __ cmpdi(CCR0, tmp1, 0); + generate_marking_inactive_test(masm); __ beq(CCR0, filtered); // Do we need to load the previous value? @@ -175,28 +192,12 @@ void G1BarrierSetAssembler::g1_write_barrier_pre(MacroAssembler* masm, Decorator // Can we store original value in the thread's buffer? // Is index == 0? // (The index field is typed as size_t.) - const Register Rbuffer = tmp1, Rindex = tmp2; - - __ ld(Rindex, in_bytes(G1ThreadLocalData::satb_mark_queue_index_offset()), R16_thread); - __ cmpdi(CCR0, Rindex, 0); - __ beq(CCR0, runtime); // If index == 0, goto runtime. - __ ld(Rbuffer, in_bytes(G1ThreadLocalData::satb_mark_queue_buffer_offset()), R16_thread); - - __ addi(Rindex, Rindex, -wordSize); // Decrement index. - __ std(Rindex, in_bytes(G1ThreadLocalData::satb_mark_queue_index_offset()), R16_thread); - - // Record the previous value. - __ stdx(pre_val, Rbuffer, Rindex); + generate_queue_insertion(masm, G1ThreadLocalData::satb_mark_queue_index_offset(), G1ThreadLocalData::satb_mark_queue_buffer_offset(), + runtime, pre_val, tmp1); __ b(filtered); __ bind(runtime); - // Determine necessary runtime invocation preservation measures - const bool needs_frame = preservation_level >= MacroAssembler::PRESERVATION_FRAME_LR; - const bool preserve_gp_registers = preservation_level >= MacroAssembler::PRESERVATION_FRAME_LR_GP_REGS; - const bool preserve_fp_registers = preservation_level >= MacroAssembler::PRESERVATION_FRAME_LR_GP_FP_REGS; - int nbytes_save = 0; - // May need to preserve LR. Also needed if current frame is not compatible with C calling convention. if (needs_frame) { if (preserve_gp_registers) { @@ -210,11 +211,11 @@ void G1BarrierSetAssembler::g1_write_barrier_pre(MacroAssembler* masm, Decorator __ push_frame_reg_args(nbytes_save, tmp2); } - if (pre_val->is_volatile() && preloaded && !preserve_gp_registers) { + if (nv_save != noreg) { __ mr(nv_save, pre_val); // Save pre_val across C call if it was preloaded. } __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_field_pre_entry), pre_val, R16_thread); - if (pre_val->is_volatile() && preloaded && !preserve_gp_registers) { + if (nv_save != noreg) { __ mr(pre_val, nv_save); // restore } @@ -230,6 +231,26 @@ void G1BarrierSetAssembler::g1_write_barrier_pre(MacroAssembler* masm, Decorator __ bind(filtered); } +static void generate_region_crossing_test(MacroAssembler* masm, const Register store_addr, const Register new_val) { + __ xorr(R0, store_addr, new_val); // tmp1 := store address ^ new value + __ srdi_(R0, R0, G1HeapRegion::LogOfHRGrainBytes); // tmp1 := ((store address ^ new value) >> LogOfHRGrainBytes) +} + +static Address generate_card_young_test(MacroAssembler* masm, const Register store_addr, const Register tmp1, const Register tmp2) { + CardTableBarrierSet* ct = barrier_set_cast(BarrierSet::barrier_set()); + __ load_const_optimized(tmp1, (address)(ct->card_table()->byte_map_base()), tmp2); + __ srdi(tmp2, store_addr, CardTable::card_shift()); // tmp1 := card address relative to card table base + __ lbzx(R0, tmp1, tmp2); // tmp1 := card address + __ cmpwi(CCR0, R0, (int)G1CardTable::g1_young_card_val()); + return Address(tmp1, tmp2); // return card address +} + +static void generate_card_dirty_test(MacroAssembler* masm, Address card_addr) { + __ membar(Assembler::StoreLoad); // Must reload after StoreLoad membar due to concurrent refinement + __ lbzx(R0, card_addr.base(), card_addr.index()); // tmp2 := card + __ cmpwi(CCR0, R0, (int)G1CardTable::dirty_card_val()); // tmp2 := card == dirty_card_val? +} + void G1BarrierSetAssembler::g1_write_barrier_post(MacroAssembler* masm, DecoratorSet decorators, Register store_addr, Register new_val, Register tmp1, Register tmp2, Register tmp3, @@ -241,9 +262,7 @@ void G1BarrierSetAssembler::g1_write_barrier_post(MacroAssembler* masm, Decorato CardTableBarrierSet* ct = barrier_set_cast(BarrierSet::barrier_set()); - // Does store cross heap regions? - __ xorr(tmp1, store_addr, new_val); - __ srdi_(tmp1, tmp1, G1HeapRegion::LogOfHRGrainBytes); + generate_region_crossing_test(masm, store_addr, new_val); __ beq(CCR0, filtered); // Crosses regions, storing null? @@ -257,43 +276,22 @@ void G1BarrierSetAssembler::g1_write_barrier_post(MacroAssembler* masm, Decorato __ beq(CCR0, filtered); } - // Storing region crossing non-null, is card already dirty? - const Register Rcard_addr = tmp1; - Register Rbase = tmp2; - __ load_const_optimized(Rbase, (address)(ct->card_table()->byte_map_base()), /*temp*/ tmp3); - - __ srdi(Rcard_addr, store_addr, CardTable::card_shift()); - - // Get the address of the card. - __ lbzx(/*card value*/ tmp3, Rbase, Rcard_addr); - __ cmpwi(CCR0, tmp3, (int)G1CardTable::g1_young_card_val()); + Address card_addr = generate_card_young_test(masm, store_addr, tmp1, tmp2); __ beq(CCR0, filtered); - __ membar(Assembler::StoreLoad); - __ lbzx(/*card value*/ tmp3, Rbase, Rcard_addr); // Reload after membar. - __ cmpwi(CCR0, tmp3 /* card value */, (int)G1CardTable::dirty_card_val()); + generate_card_dirty_test(masm, card_addr); __ beq(CCR0, filtered); - // Storing a region crossing, non-null oop, card is clean. - // Dirty card and log. - __ li(tmp3, (int)G1CardTable::dirty_card_val()); - //release(); // G1: oops are allowed to get visible after dirty marking. - __ stbx(tmp3, Rbase, Rcard_addr); + __ li(R0, (int)G1CardTable::dirty_card_val()); + __ stbx(R0, card_addr.base(), card_addr.index()); // *(card address) := dirty_card_val - __ add(Rcard_addr, Rbase, Rcard_addr); // This is the address which needs to get enqueued. - Rbase = noreg; // end of lifetime + Register Rcard_addr = tmp3; + __ add(Rcard_addr, card_addr.base(), card_addr.index()); // This is the address which needs to get enqueued. - const Register Rqueue_index = tmp2, - Rqueue_buf = tmp3; - __ ld(Rqueue_index, in_bytes(G1ThreadLocalData::dirty_card_queue_index_offset()), R16_thread); - __ cmpdi(CCR0, Rqueue_index, 0); - __ beq(CCR0, runtime); // index == 0 then jump to runtime - __ ld(Rqueue_buf, in_bytes(G1ThreadLocalData::dirty_card_queue_buffer_offset()), R16_thread); - - __ addi(Rqueue_index, Rqueue_index, -wordSize); // decrement index - __ std(Rqueue_index, in_bytes(G1ThreadLocalData::dirty_card_queue_index_offset()), R16_thread); - - __ stdx(Rcard_addr, Rqueue_buf, Rqueue_index); // store card + generate_queue_insertion(masm, + G1ThreadLocalData::dirty_card_queue_index_offset(), + G1ThreadLocalData::dirty_card_queue_buffer_offset(), + runtime, Rcard_addr, tmp1); __ b(filtered); __ bind(runtime); @@ -392,6 +390,142 @@ void G1BarrierSetAssembler::resolve_jobject(MacroAssembler* masm, Register value __ bind(done); } +#ifdef COMPILER2 + +static void generate_c2_barrier_runtime_call(MacroAssembler* masm, G1BarrierStubC2* stub, const Register arg, const address runtime_path) { + SaveLiveRegisters save_registers(masm, stub); + __ call_VM_leaf(runtime_path, arg, R16_thread); +} + +void G1BarrierSetAssembler::g1_write_barrier_pre_c2(MacroAssembler* masm, + Register obj, + Register pre_val, + Register tmp1, + Register tmp2, + G1PreBarrierStubC2* stub) { + assert_different_registers(obj, tmp1, tmp2, R0); + assert_different_registers(pre_val, tmp1, R0); + assert(!UseCompressedOops || tmp2 != noreg, "tmp2 needed with CompressedOops"); + + stub->initialize_registers(obj, pre_val, R16_thread, tmp1, tmp2); + + generate_marking_inactive_test(masm); + __ bc_far_optimized(Assembler::bcondCRbiIs0, __ bi0(CCR0, Assembler::equal), *stub->entry()); + + __ bind(*stub->continuation()); +} + +void G1BarrierSetAssembler::generate_c2_pre_barrier_stub(MacroAssembler* masm, + G1PreBarrierStubC2* stub) const { + Assembler::InlineSkippedInstructionsCounter skip_counter(masm); + Label runtime; + Register obj = stub->obj(); + Register pre_val = stub->pre_val(); + Register tmp1 = stub->tmp1(); + + __ bind(*stub->entry()); + + if (obj != noreg) { + // Note: C2 currently doesn't use implicit null checks with barriers. + // Otherwise, obj could be null and the following instruction would raise a SIGSEGV. + if (UseCompressedOops) { + __ lwz(pre_val, 0, obj); + } else { + __ ld(pre_val, 0, obj); + } + } + __ cmpdi(CCR0, pre_val, 0); + __ bc_far_optimized(Assembler::bcondCRbiIs1, __ bi0(CCR0, Assembler::equal), *stub->continuation()); + + Register pre_val_decoded = pre_val; + if (UseCompressedOops) { + pre_val_decoded = __ decode_heap_oop_not_null(stub->tmp2(), pre_val); + } + + generate_queue_insertion(masm, + G1ThreadLocalData::satb_mark_queue_index_offset(), + G1ThreadLocalData::satb_mark_queue_buffer_offset(), + runtime, pre_val_decoded, tmp1); + __ b(*stub->continuation()); + + __ bind(runtime); + generate_c2_barrier_runtime_call(masm, stub, pre_val_decoded, CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_field_pre_entry)); + __ b(*stub->continuation()); +} + +void G1BarrierSetAssembler::g1_write_barrier_post_c2(MacroAssembler* masm, + Register store_addr, + Register new_val, + Register tmp1, + Register tmp2, + G1PostBarrierStubC2* stub, + bool decode_new_val) { + assert_different_registers(store_addr, new_val, tmp1, R0); + assert_different_registers(store_addr, tmp1, tmp2, R0); + + stub->initialize_registers(R16_thread, tmp1, tmp2); + + bool null_check_required = (stub->barrier_data() & G1C2BarrierPostNotNull) == 0; + Register new_val_decoded = new_val; + + if (decode_new_val) { + assert(UseCompressedOops, "or should not be here"); + if (null_check_required && CompressedOops::base() != nullptr) { + // We prefer doing the null check after the region crossing check. + // Only compressed oop modes with base != null require a null check here. + __ cmpwi(CCR0, new_val, 0); + __ beq(CCR0, *stub->continuation()); + null_check_required = false; + } + new_val_decoded = __ decode_heap_oop_not_null(tmp2, new_val); + } + + generate_region_crossing_test(masm, store_addr, new_val_decoded); + __ beq(CCR0, *stub->continuation()); + + // crosses regions, storing null? + if (null_check_required) { + __ cmpdi(CCR0, new_val_decoded, 0); + __ beq(CCR0, *stub->continuation()); + } + + Address card_addr = generate_card_young_test(masm, store_addr, tmp1, tmp2); + assert(card_addr.base() == tmp1 && card_addr.index() == tmp2, "needed by post barrier stub"); + __ bc_far_optimized(Assembler::bcondCRbiIs0, __ bi0(CCR0, Assembler::equal), *stub->entry()); + + __ bind(*stub->continuation()); +} + +void G1BarrierSetAssembler::generate_c2_post_barrier_stub(MacroAssembler* masm, + G1PostBarrierStubC2* stub) const { + Assembler::InlineSkippedInstructionsCounter skip_counter(masm); + Label runtime; + Address card_addr(stub->tmp1(), stub->tmp2()); // See above. + + __ bind(*stub->entry()); + + generate_card_dirty_test(masm, card_addr); + __ bc_far_optimized(Assembler::bcondCRbiIs1, __ bi0(CCR0, Assembler::equal), *stub->continuation()); + + __ li(R0, (int)G1CardTable::dirty_card_val()); + __ stbx(R0, card_addr.base(), card_addr.index()); // *(card address) := dirty_card_val + + Register Rcard_addr = stub->tmp1(); + __ add(Rcard_addr, card_addr.base(), card_addr.index()); // This is the address which needs to get enqueued. + + generate_queue_insertion(masm, + G1ThreadLocalData::dirty_card_queue_index_offset(), + G1ThreadLocalData::dirty_card_queue_buffer_offset(), + runtime, Rcard_addr, stub->tmp2()); + __ b(*stub->continuation()); + + __ bind(runtime); + generate_c2_barrier_runtime_call(masm, stub, Rcard_addr, CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_field_post_entry)); + __ b(*stub->continuation()); +} + +#endif // COMPILER2 + #ifdef COMPILER1 #undef __ @@ -470,13 +604,7 @@ void G1BarrierSetAssembler::generate_c1_pre_barrier_runtime_stub(StubAssembler* __ std(tmp2, -24, R1_SP); // Is marking still active? - if (in_bytes(SATBMarkQueue::byte_width_of_active()) == 4) { - __ lwz(tmp, satb_q_active_byte_offset, R16_thread); - } else { - assert(in_bytes(SATBMarkQueue::byte_width_of_active()) == 1, "Assumption"); - __ lbz(tmp, satb_q_active_byte_offset, R16_thread); - } - __ cmpdi(CCR0, tmp, 0); + generate_marking_inactive_test(sasm); __ beq(CCR0, marking_not_active); __ bind(restart); diff --git a/src/hotspot/cpu/ppc/gc/g1/g1BarrierSetAssembler_ppc.hpp b/src/hotspot/cpu/ppc/gc/g1/g1BarrierSetAssembler_ppc.hpp index d9a252ff6ea..1c9fe8a5d10 100644 --- a/src/hotspot/cpu/ppc/gc/g1/g1BarrierSetAssembler_ppc.hpp +++ b/src/hotspot/cpu/ppc/gc/g1/g1BarrierSetAssembler_ppc.hpp @@ -30,10 +30,16 @@ #include "gc/shared/modRefBarrierSetAssembler.hpp" #include "utilities/macros.hpp" +#ifdef COMPILER2 +#include "gc/g1/c2/g1BarrierSetC2.hpp" +#endif + class LIR_Assembler; class StubAssembler; class G1PreBarrierStub; class G1PostBarrierStub; +class G1PreBarrierStubC2; +class G1PostBarrierStubC2; class G1BarrierSetAssembler: public ModRefBarrierSetAssembler { protected: @@ -59,6 +65,25 @@ protected: MacroAssembler::PreservationLevel preservation_level); public: +#ifdef COMPILER2 + void g1_write_barrier_pre_c2(MacroAssembler* masm, + Register obj, + Register pre_val, + Register tmp1, + Register tmp2, + G1PreBarrierStubC2* c2_stub); + void generate_c2_pre_barrier_stub(MacroAssembler* masm, + G1PreBarrierStubC2* stub) const; + void g1_write_barrier_post_c2(MacroAssembler* masm, + Register store_addr, + Register new_val, + Register tmp1, + Register tmp2, + G1PostBarrierStubC2* c2_stub, + bool decode_new_val); + void generate_c2_post_barrier_stub(MacroAssembler* masm, + G1PostBarrierStubC2* stub) const; +#endif #ifdef COMPILER1 void gen_pre_barrier_stub(LIR_Assembler* ce, G1PreBarrierStub* stub); void gen_post_barrier_stub(LIR_Assembler* ce, G1PostBarrierStub* stub); diff --git a/src/hotspot/cpu/ppc/gc/g1/g1_ppc.ad b/src/hotspot/cpu/ppc/gc/g1/g1_ppc.ad new file mode 100644 index 00000000000..f4163242cad --- /dev/null +++ b/src/hotspot/cpu/ppc/gc/g1/g1_ppc.ad @@ -0,0 +1,684 @@ +// +// Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2024 SAP SE. 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. +// + +source_hpp %{ + +#include "gc/g1/c2/g1BarrierSetC2.hpp" +#include "gc/shared/gc_globals.hpp" + +%} + +source %{ + +#include "gc/g1/g1BarrierSetAssembler_ppc.hpp" +#include "gc/g1/g1BarrierSetRuntime.hpp" + +static void pre_write_barrier(MacroAssembler* masm, + const MachNode* node, + Register obj, + Register pre_val, + Register tmp1, + Register tmp2 = noreg, // only needed with CompressedOops when pre_val needs to be preserved + RegSet preserve = RegSet(), + RegSet no_preserve = RegSet()) { + if (!G1PreBarrierStubC2::needs_barrier(node)) { + return; + } + Assembler::InlineSkippedInstructionsCounter skip_counter(masm); + G1BarrierSetAssembler* g1_asm = static_cast(BarrierSet::barrier_set()->barrier_set_assembler()); + G1PreBarrierStubC2* const stub = G1PreBarrierStubC2::create(node); + for (RegSetIterator reg = preserve.begin(); *reg != noreg; ++reg) { + stub->preserve(*reg); + } + for (RegSetIterator reg = no_preserve.begin(); *reg != noreg; ++reg) { + stub->dont_preserve(*reg); + } + g1_asm->g1_write_barrier_pre_c2(masm, obj, pre_val, tmp1, (tmp2 != noreg) ? tmp2 : pre_val, stub); +} + +static void post_write_barrier(MacroAssembler* masm, + const MachNode* node, + Register store_addr, + Register new_val, + Register tmp1, + Register tmp2, + bool decode_new_val = false) { + if (!G1PostBarrierStubC2::needs_barrier(node)) { + return; + } + Assembler::InlineSkippedInstructionsCounter skip_counter(masm); + G1BarrierSetAssembler* g1_asm = static_cast(BarrierSet::barrier_set()->barrier_set_assembler()); + G1PostBarrierStubC2* const stub = G1PostBarrierStubC2::create(node); + g1_asm->g1_write_barrier_post_c2(masm, store_addr, new_val, tmp1, tmp2, stub, decode_new_val); +} + +%} + +instruct g1StoreP(indirect mem, iRegPsrc src, iRegPdst tmp1, iRegPdst tmp2, flagsRegCR0 cr0) +%{ + predicate(UseG1GC && n->as_Store()->barrier_data() != 0); + match(Set mem (StoreP mem src)); + effect(TEMP tmp1, TEMP tmp2, KILL cr0); + ins_cost(2 * MEMORY_REF_COST); + format %{ "std $mem, $src\t# ptr" %} + ins_encode %{ + pre_write_barrier(masm, this, + $mem$$Register, + $tmp1$$Register, + $tmp2$$Register, + noreg, + RegSet::of($mem$$Register, $src$$Register) /* preserve */); + __ std($src$$Register, 0, $mem$$Register); + post_write_barrier(masm, this, + $mem$$Register, + $src$$Register /* new_val */, + $tmp1$$Register, + $tmp2$$Register); + %} + ins_pipe(pipe_class_default); +%} + +instruct g1StoreN(indirect mem, iRegNsrc src, iRegPdst tmp1, iRegPdst tmp2, flagsRegCR0 cr0) +%{ + predicate(UseG1GC && n->as_Store()->barrier_data() != 0); + match(Set mem (StoreN mem src)); + effect(TEMP tmp1, TEMP tmp2, KILL cr0); + ins_cost(2 * MEMORY_REF_COST); + format %{ "stw $mem, $src\t# ptr" %} + ins_encode %{ + pre_write_barrier(masm, this, + $mem$$Register, + $tmp1$$Register, + $tmp2$$Register, + noreg, + RegSet::of($mem$$Register, $src$$Register) /* preserve */); + __ stw($src$$Register, 0, $mem$$Register); + post_write_barrier(masm, this, + $mem$$Register, + $src$$Register /* new_val */, + $tmp1$$Register, + $tmp2$$Register, + true /* decode_new_val */); + %} + ins_pipe(pipe_class_default); +%} + +instruct g1EncodePAndStoreN(indirect mem, iRegPsrc src, iRegPdst tmp1, iRegPdst tmp2, flagsRegCR0 cr0) +%{ + predicate(UseG1GC && n->as_Store()->barrier_data() != 0); + match(Set mem (StoreN mem (EncodeP src))); + effect(TEMP tmp1, TEMP tmp2, KILL cr0); + ins_cost(2 * MEMORY_REF_COST); + format %{ "encode_heap_oop $src\n\t" + "stw $mem, $src\t# ptr" %} + ins_encode %{ + pre_write_barrier(masm, this, + $mem$$Register, + $tmp1$$Register, + $tmp2$$Register, + noreg, + RegSet::of($mem$$Register, $src$$Register) /* preserve */); + Register encoded_oop = noreg; + if ((barrier_data() & G1C2BarrierPostNotNull) == 0) { + encoded_oop = __ encode_heap_oop($tmp2$$Register, $src$$Register); + } else { + encoded_oop = __ encode_heap_oop_not_null($tmp2$$Register, $src$$Register); + } + __ stw(encoded_oop, 0, $mem$$Register); + post_write_barrier(masm, this, + $mem$$Register, + $src$$Register /* new_val */, + $tmp1$$Register, + $tmp2$$Register); + %} + ins_pipe(pipe_class_default); +%} + +instruct g1CompareAndExchangeP(iRegPdst res, indirect mem, iRegPsrc oldval, iRegPsrc newval, iRegPdst tmp1, iRegPdst tmp2, flagsRegCR0 cr0) +%{ + predicate(UseG1GC && n->as_LoadStore()->barrier_data() != 0 && + (((CompareAndExchangeNode*)n)->order() != MemNode::acquire && ((CompareAndExchangeNode*)n)->order() != MemNode::seqcst)); + match(Set res (CompareAndExchangeP mem (Binary oldval newval))); + effect(TEMP_DEF res, TEMP tmp1, TEMP tmp2, KILL cr0); + format %{ "cmpxchgd $newval, $mem" %} + ins_encode %{ + Label no_update; + __ cmpxchgd(CCR0, $res$$Register, $oldval$$Register, $newval$$Register, $mem$$Register, + MacroAssembler::MemBarNone, MacroAssembler::cmpxchgx_hint_atomic_update(), + noreg, &no_update, true); + // Pass oldval to SATB which is the only value which can get overwritten. + // Can be done after cmpxchg because there's no safepoint here. + pre_write_barrier(masm, this, + noreg, + $oldval$$Register, + $tmp1$$Register, + $tmp2$$Register, + RegSet::of($mem$$Register, $newval$$Register) /* preserve */); + post_write_barrier(masm, this, + $mem$$Register, + $newval$$Register, + $tmp1$$Register, + $tmp2$$Register); + __ bind(no_update); + %} + ins_pipe(pipe_class_default); +%} + +instruct g1CompareAndExchangeP_acq(iRegPdst res, indirect mem, iRegPsrc oldval, iRegPsrc newval, iRegPdst tmp1, iRegPdst tmp2, flagsRegCR0 cr0) +%{ + predicate(UseG1GC && n->as_LoadStore()->barrier_data() != 0 && + (((CompareAndExchangeNode*)n)->order() == MemNode::acquire || ((CompareAndExchangeNode*)n)->order() == MemNode::seqcst)); + match(Set res (CompareAndExchangeP mem (Binary oldval newval))); + effect(TEMP_DEF res, TEMP tmp1, TEMP tmp2, KILL cr0); + format %{ "cmpxchgd acq $newval, $mem" %} + ins_encode %{ + Label no_update; + __ cmpxchgd(CCR0, $res$$Register, $oldval$$Register, $newval$$Register, $mem$$Register, + MacroAssembler::MemBarNone, MacroAssembler::cmpxchgx_hint_atomic_update(), + noreg, &no_update, true); + // Pass oldval to SATB which is the only value which can get overwritten. + // Can be done after cmpxchg because there's no safepoint here. + pre_write_barrier(masm, this, + noreg, + $oldval$$Register, + $tmp1$$Register, + $tmp2$$Register, + RegSet::of($mem$$Register, $newval$$Register) /* preserve */); + post_write_barrier(masm, this, + $mem$$Register, + $newval$$Register, + $tmp1$$Register, + $tmp2$$Register); + __ bind(no_update); + if (support_IRIW_for_not_multiple_copy_atomic_cpu) { + __ isync(); + } else { + // isync would be sufficient in case of CompareAndExchangeAcquire, but we currently don't optimize for that. + __ sync(); + } + %} + ins_pipe(pipe_class_default); +%} + +instruct g1CompareAndExchangeN(iRegNdst res, indirect mem, iRegNsrc oldval, iRegNsrc newval, iRegPdst tmp1, iRegPdst tmp2, flagsRegCR0 cr0) +%{ + predicate(UseG1GC && n->as_LoadStore()->barrier_data() != 0 && + (((CompareAndExchangeNode*)n)->order() != MemNode::acquire && ((CompareAndExchangeNode*)n)->order() != MemNode::seqcst)); + match(Set res (CompareAndExchangeN mem (Binary oldval newval))); + effect(TEMP_DEF res, TEMP tmp1, TEMP tmp2, KILL cr0); + format %{ "cmpxchgw $newval, $mem" %} + ins_encode %{ + Label no_update; + __ cmpxchgw(CCR0, $res$$Register, $oldval$$Register, $newval$$Register, $mem$$Register, + MacroAssembler::MemBarNone, MacroAssembler::cmpxchgx_hint_atomic_update(), + noreg, &no_update, true); + // Pass oldval to SATB which is the only value which can get overwritten. + // Can be done after cmpxchg because there's no safepoint here. + pre_write_barrier(masm, this, + noreg, + $oldval$$Register, + $tmp1$$Register, + $tmp2$$Register, + RegSet::of($mem$$Register, $newval$$Register) /* preserve */); + post_write_barrier(masm, this, + $mem$$Register, + $newval$$Register, + $tmp1$$Register, + $tmp2$$Register, + true /* decode_new_val */); + __ bind(no_update); + %} + ins_pipe(pipe_class_default); +%} + +instruct g1CompareAndExchangeN_acq(iRegNdst res, indirect mem, iRegNsrc oldval, iRegNsrc newval, iRegPdst tmp1, iRegPdst tmp2, flagsRegCR0 cr0) +%{ + predicate(UseG1GC && n->as_LoadStore()->barrier_data() != 0 && + (((CompareAndExchangeNode*)n)->order() == MemNode::acquire || ((CompareAndExchangeNode*)n)->order() == MemNode::seqcst)); + match(Set res (CompareAndExchangeN mem (Binary oldval newval))); + effect(TEMP_DEF res, TEMP tmp1, TEMP tmp2, KILL cr0); + format %{ "cmpxchgw acq $newval, $mem" %} + ins_encode %{ + Label no_update; + __ cmpxchgw(CCR0, $res$$Register, $oldval$$Register, $newval$$Register, $mem$$Register, + MacroAssembler::MemBarNone, MacroAssembler::cmpxchgx_hint_atomic_update(), + noreg, &no_update, true); + // Pass oldval to SATB which is the only value which can get overwritten. + // Can be done after cmpxchg because there's no safepoint here. + pre_write_barrier(masm, this, + noreg, + $oldval$$Register, + $tmp1$$Register, + $tmp2$$Register, + RegSet::of($mem$$Register, $newval$$Register) /* preserve */); + post_write_barrier(masm, this, + $mem$$Register, + $newval$$Register, + $tmp1$$Register, + $tmp2$$Register, + true /* decode_new_val */); + __ bind(no_update); + if (support_IRIW_for_not_multiple_copy_atomic_cpu) { + __ isync(); + } else { + // isync would be sufficient in case of CompareAndExchangeAcquire, but we currently don't optimize for that. + __ sync(); + } + %} + ins_pipe(pipe_class_default); +%} + +instruct g1CompareAndSwapP(iRegIdst res, indirect mem, iRegPsrc oldval, iRegPsrc newval, iRegPdst tmp, flagsRegCR0 cr0) +%{ + predicate(UseG1GC && n->as_LoadStore()->barrier_data() != 0 && + (((CompareAndSwapNode*)n)->order() != MemNode::acquire && ((CompareAndSwapNode*)n)->order() != MemNode::seqcst)); + match(Set res (CompareAndSwapP mem (Binary oldval newval))); + effect(TEMP_DEF res, TEMP tmp, KILL cr0); + format %{ "CMPXCHGD $res, $mem, $oldval, $newval; as bool; ptr" %} + ins_encode %{ + Label no_update; + __ li($res$$Register, 0); + __ cmpxchgd(CCR0, R0, $oldval$$Register, $newval$$Register, $mem$$Register, + MacroAssembler::MemBarNone, MacroAssembler::cmpxchgx_hint_atomic_update(), + noreg, &no_update, true); + // Pass oldval to SATB which is the only value which can get overwritten. + // Can be done after cmpxchg because there's no safepoint here. + pre_write_barrier(masm, this, + noreg, + $oldval$$Register /* pre_val */, + $tmp$$Register, + $res$$Register /* temp */, + RegSet::of($mem$$Register, $newval$$Register) /* preserve */, + RegSet::of($res$$Register) /* no_preserve */); + post_write_barrier(masm, this, + $mem$$Register, + $newval$$Register, + $tmp$$Register, + $res$$Register /* temp */); + __ li($res$$Register, 1); + __ bind(no_update); + %} + ins_pipe(pipe_class_default); +%} + +instruct g1CompareAndSwapP_acq(iRegIdst res, indirect mem, iRegPsrc oldval, iRegPsrc newval, iRegPdst tmp, flagsRegCR0 cr0) +%{ + predicate(UseG1GC && n->as_LoadStore()->barrier_data() != 0 && + (((CompareAndSwapNode*)n)->order() == MemNode::acquire || ((CompareAndSwapNode*)n)->order() == MemNode::seqcst)); + match(Set res (CompareAndSwapP mem (Binary oldval newval))); + effect(TEMP_DEF res, TEMP tmp, KILL cr0); + format %{ "CMPXCHGD acq $res, $mem, $oldval, $newval; as bool; ptr" %} + ins_encode %{ + Label no_update; + __ li($res$$Register, 0); + __ cmpxchgd(CCR0, R0, $oldval$$Register, $newval$$Register, $mem$$Register, + MacroAssembler::MemBarNone, MacroAssembler::cmpxchgx_hint_atomic_update(), + noreg, &no_update, true); + // Pass oldval to SATB which is the only value which can get overwritten. + // Can be done after cmpxchg because there's no safepoint here. + pre_write_barrier(masm, this, + noreg, + $oldval$$Register /* pre_val */, + $tmp$$Register, + $res$$Register /* temp */, + RegSet::of($mem$$Register, $newval$$Register) /* preserve */, + RegSet::of($res$$Register) /* no_preserve */); + post_write_barrier(masm, this, + $mem$$Register, + $newval$$Register, + $tmp$$Register, + $res$$Register /* temp */); + __ li($res$$Register, 1); + __ bind(no_update); + if (support_IRIW_for_not_multiple_copy_atomic_cpu) { + __ isync(); + } else { + // isync would be sufficient in case of CompareAndExchangeAcquire, but we currently don't optimize for that. + __ sync(); + } + %} + ins_pipe(pipe_class_default); +%} + +instruct g1CompareAndSwapN(iRegIdst res, indirect mem, iRegNsrc oldval, iRegNsrc newval, iRegPdst tmp, flagsRegCR0 cr0) +%{ + predicate(UseG1GC && n->as_LoadStore()->barrier_data() != 0 && + (((CompareAndSwapNode*)n)->order() != MemNode::acquire && ((CompareAndSwapNode*)n)->order() != MemNode::seqcst)); + match(Set res (CompareAndSwapN mem (Binary oldval newval))); + effect(TEMP_DEF res, TEMP tmp, KILL cr0); + format %{ "CMPXCHGW $res, $mem, $oldval, $newval; as bool; ptr" %} + ins_encode %{ + Label no_update; + __ li($res$$Register, 0); + __ cmpxchgw(CCR0, R0, $oldval$$Register, $newval$$Register, $mem$$Register, + MacroAssembler::MemBarNone, MacroAssembler::cmpxchgx_hint_atomic_update(), + noreg, &no_update, true); + // Pass oldval to SATB which is the only value which can get overwritten. + // Can be done after cmpxchg because there's no safepoint here. + pre_write_barrier(masm, this, + noreg, + $oldval$$Register /* pre_val */, + $tmp$$Register, + $res$$Register /* temp */, + RegSet::of($mem$$Register, $newval$$Register) /* preserve */, + RegSet::of($res$$Register) /* no_preserve */); + post_write_barrier(masm, this, + $mem$$Register, + $newval$$Register, + $tmp$$Register, + $res$$Register /* temp */, + true /* decode_new_val */); + __ li($res$$Register, 1); + __ bind(no_update); + %} + ins_pipe(pipe_class_default); +%} + +instruct g1CompareAndSwapN_acq(iRegIdst res, indirect mem, iRegNsrc oldval, iRegNsrc newval, iRegPdst tmp, flagsRegCR0 cr0) +%{ + predicate(UseG1GC && n->as_LoadStore()->barrier_data() != 0 && + (((CompareAndSwapNode*)n)->order() == MemNode::acquire || ((CompareAndSwapNode*)n)->order() == MemNode::seqcst)); + match(Set res (CompareAndSwapN mem (Binary oldval newval))); + effect(TEMP_DEF res, TEMP tmp, KILL cr0); + format %{ "CMPXCHGW acq $res, $mem, $oldval, $newval; as bool; ptr" %} + ins_encode %{ + Label no_update; + __ li($res$$Register, 0); + __ cmpxchgw(CCR0, R0, $oldval$$Register, $newval$$Register, $mem$$Register, + MacroAssembler::MemBarNone, MacroAssembler::cmpxchgx_hint_atomic_update(), + noreg, &no_update, true); + // Pass oldval to SATB which is the only value which can get overwritten. + // Can be done after cmpxchg because there's no safepoint here. + pre_write_barrier(masm, this, + noreg, + $oldval$$Register /* pre_val */, + $tmp$$Register, + $res$$Register /* temp */, + RegSet::of($mem$$Register, $newval$$Register) /* preserve */, + RegSet::of($res$$Register) /* no_preserve */); + post_write_barrier(masm, this, + $mem$$Register, + $newval$$Register, + $tmp$$Register, + $res$$Register /* temp */, + true /* decode_new_val */); + __ li($res$$Register, 1); + __ bind(no_update); + if (support_IRIW_for_not_multiple_copy_atomic_cpu) { + __ isync(); + } else { + // isync would be sufficient in case of CompareAndExchangeAcquire, but we currently don't optimize for that. + __ sync(); + } + %} + ins_pipe(pipe_class_default); +%} + +instruct weakG1CompareAndSwapP(iRegIdst res, indirect mem, iRegPsrc oldval, iRegPsrc newval, iRegPdst tmp, flagsRegCR0 cr0) +%{ + predicate(UseG1GC && n->as_LoadStore()->barrier_data() != 0 && + (((CompareAndSwapNode*)n)->order() != MemNode::acquire && ((CompareAndSwapNode*)n)->order() != MemNode::seqcst)); + match(Set res (WeakCompareAndSwapP mem (Binary oldval newval))); + effect(TEMP_DEF res, TEMP tmp, KILL cr0); + format %{ "weak CMPXCHGD $res, $mem, $oldval, $newval; as bool; ptr" %} + ins_encode %{ + Label no_update; + __ li($res$$Register, 0); + __ cmpxchgd(CCR0, R0, $oldval$$Register, $newval$$Register, $mem$$Register, + MacroAssembler::MemBarNone, MacroAssembler::cmpxchgx_hint_atomic_update(), + noreg, &no_update, true, true); + // Pass oldval to SATB which is the only value which can get overwritten. + // Can be done after cmpxchg because there's no safepoint here. + pre_write_barrier(masm, this, + noreg, + $oldval$$Register /* pre_val */, + $tmp$$Register, + $res$$Register /* temp */, + RegSet::of($mem$$Register, $newval$$Register) /* preserve */, + RegSet::of($res$$Register) /* no_preserve */); + post_write_barrier(masm, this, + $mem$$Register, + $newval$$Register, + $tmp$$Register, + $res$$Register /* temp */); + __ li($res$$Register, 1); + __ bind(no_update); + %} + ins_pipe(pipe_class_default); +%} + +instruct weakG1CompareAndSwapP_acq(iRegIdst res, indirect mem, iRegPsrc oldval, iRegPsrc newval, iRegPdst tmp, flagsRegCR0 cr0) +%{ + predicate(UseG1GC && n->as_LoadStore()->barrier_data() != 0 && + (((CompareAndSwapNode*)n)->order() == MemNode::acquire || ((CompareAndSwapNode*)n)->order() == MemNode::seqcst)); + match(Set res (WeakCompareAndSwapP mem (Binary oldval newval))); + effect(TEMP_DEF res, TEMP tmp, KILL cr0); + format %{ "weak CMPXCHGD acq $res, $mem, $oldval, $newval; as bool; ptr" %} + ins_encode %{ + Label no_update; + __ li($res$$Register, 0); + __ cmpxchgd(CCR0, R0, $oldval$$Register, $newval$$Register, $mem$$Register, + MacroAssembler::MemBarNone, MacroAssembler::cmpxchgx_hint_atomic_update(), + noreg, &no_update, true, true); + // Pass oldval to SATB which is the only value which can get overwritten. + // Can be done after cmpxchg because there's no safepoint here. + pre_write_barrier(masm, this, + noreg, + $oldval$$Register /* pre_val */, + $tmp$$Register, + $res$$Register /* temp */, + RegSet::of($mem$$Register, $newval$$Register) /* preserve */, + RegSet::of($res$$Register) /* no_preserve */); + post_write_barrier(masm, this, + $mem$$Register, + $newval$$Register, + $tmp$$Register, + $res$$Register /* temp */); + __ li($res$$Register, 1); + if (support_IRIW_for_not_multiple_copy_atomic_cpu) { + __ isync(); + } else { + // isync would be sufficient in case of CompareAndExchangeAcquire, but we currently don't optimize for that. + __ sync(); + } + __ bind(no_update); // weak version requires no memory barrier on failure + %} + ins_pipe(pipe_class_default); +%} + +instruct weakG1CompareAndSwapN(iRegIdst res, indirect mem, iRegNsrc oldval, iRegNsrc newval, iRegPdst tmp, flagsRegCR0 cr0) +%{ + predicate(UseG1GC && n->as_LoadStore()->barrier_data() != 0 && + (((CompareAndSwapNode*)n)->order() != MemNode::acquire && ((CompareAndSwapNode*)n)->order() != MemNode::seqcst)); + match(Set res (WeakCompareAndSwapN mem (Binary oldval newval))); + effect(TEMP_DEF res, TEMP tmp, KILL cr0); + format %{ "weak CMPXCHGW $res, $mem, $oldval, $newval; as bool; ptr" %} + ins_encode %{ + Label no_update; + __ li($res$$Register, 0); + __ cmpxchgw(CCR0, R0, $oldval$$Register, $newval$$Register, $mem$$Register, + MacroAssembler::MemBarNone, MacroAssembler::cmpxchgx_hint_atomic_update(), + noreg, &no_update, true, true); + // Pass oldval to SATB which is the only value which can get overwritten. + // Can be done after cmpxchg because there's no safepoint here. + pre_write_barrier(masm, this, + noreg, + $oldval$$Register /* pre_val */, + $tmp$$Register, + $res$$Register /* temp */, + RegSet::of($mem$$Register, $newval$$Register) /* preserve */, + RegSet::of($res$$Register) /* no_preserve */); + post_write_barrier(masm, this, + $mem$$Register, + $newval$$Register, + $tmp$$Register, + $res$$Register /* temp */, + true /* decode_new_val */); + __ li($res$$Register, 1); + __ bind(no_update); + %} + ins_pipe(pipe_class_default); +%} + +instruct weakG1CompareAndSwapN_acq(iRegIdst res, indirect mem, iRegNsrc oldval, iRegNsrc newval, iRegPdst tmp, flagsRegCR0 cr0) +%{ + predicate(UseG1GC && n->as_LoadStore()->barrier_data() != 0 && + (((CompareAndSwapNode*)n)->order() == MemNode::acquire || ((CompareAndSwapNode*)n)->order() == MemNode::seqcst)); + match(Set res (WeakCompareAndSwapN mem (Binary oldval newval))); + effect(TEMP_DEF res, TEMP tmp, KILL cr0); + format %{ "weak CMPXCHGW acq $res, $mem, $oldval, $newval; as bool; ptr" %} + ins_encode %{ + Label no_update; + __ li($res$$Register, 0); + __ cmpxchgw(CCR0, R0, $oldval$$Register, $newval$$Register, $mem$$Register, + MacroAssembler::MemBarNone, MacroAssembler::cmpxchgx_hint_atomic_update(), + noreg, &no_update, true, true); + // Pass oldval to SATB which is the only value which can get overwritten. + // Can be done after cmpxchg because there's no safepoint here. + pre_write_barrier(masm, this, + noreg, + $oldval$$Register /* pre_val */, + $tmp$$Register, + $res$$Register /* temp */, + RegSet::of($mem$$Register, $newval$$Register) /* preserve */, + RegSet::of($res$$Register) /* no_preserve */); + post_write_barrier(masm, this, + $mem$$Register, + $newval$$Register, + $tmp$$Register, + $res$$Register /* temp */, + true /* decode_new_val */); + __ li($res$$Register, 1); + if (support_IRIW_for_not_multiple_copy_atomic_cpu) { + __ isync(); + } else { + // isync would be sufficient in case of CompareAndExchangeAcquire, but we currently don't optimize for that. + __ sync(); + } + __ bind(no_update); // weak version requires no memory barrier on failure + %} + ins_pipe(pipe_class_default); +%} + +instruct g1GetAndSetP(iRegPdst res, indirect mem, iRegPsrc newval, iRegPdst tmp1, iRegPdst tmp2, flagsRegCR0 cr0) +%{ + predicate(UseG1GC && n->as_LoadStore()->barrier_data() != 0); + match(Set res (GetAndSetP mem newval)); + effect(TEMP_DEF res, TEMP tmp1, TEMP tmp2, KILL cr0); + format %{ "GetAndSetP $newval, $mem" %} + ins_encode %{ + assert_different_registers($mem$$Register, $newval$$Register); + __ getandsetd($res$$Register, $newval$$Register, $mem$$Register, + MacroAssembler::cmpxchgx_hint_atomic_update()); + // Can be done after cmpxchg because there's no safepoint here. + pre_write_barrier(masm, this, + noreg /* obj */, + $res$$Register /* res */, + $tmp1$$Register, + $tmp2$$Register, + RegSet::of($mem$$Register, $newval$$Register) /* preserve */); + post_write_barrier(masm, this, + $mem$$Register, + $newval$$Register, + $tmp1$$Register, + $tmp2$$Register); + if (support_IRIW_for_not_multiple_copy_atomic_cpu) { + __ isync(); + } else { + __ sync(); + } + %} + ins_pipe(pipe_class_default); +%} + +instruct g1GetAndSetN(iRegNdst res, indirect mem, iRegNsrc newval, iRegPdst tmp1, iRegPdst tmp2, flagsRegCR0 cr0) +%{ + predicate(UseG1GC && n->as_LoadStore()->barrier_data() != 0); + match(Set res (GetAndSetN mem newval)); + effect(TEMP_DEF res, TEMP tmp1, TEMP tmp2, KILL cr0); + format %{ "GetAndSetN $newval, $mem" %} + ins_encode %{ + assert_different_registers($mem$$Register, $newval$$Register); + __ getandsetw($res$$Register, $newval$$Register, $mem$$Register, + MacroAssembler::cmpxchgx_hint_atomic_update()); + // Can be done after cmpxchg because there's no safepoint here. + pre_write_barrier(masm, this, + noreg /* obj */, + $res$$Register /* res */, + $tmp1$$Register, + $tmp2$$Register, + RegSet::of($mem$$Register, $newval$$Register) /* preserve */); + post_write_barrier(masm, this, + $mem$$Register, + $newval$$Register, + $tmp1$$Register, + $tmp2$$Register, + true /* decode_new_val */); + if (support_IRIW_for_not_multiple_copy_atomic_cpu) { + __ isync(); + } else { + __ sync(); + } + %} + ins_pipe(pipe_class_default); +%} + +instruct g1LoadP(iRegPdst dst, memoryAlg4 mem, iRegPdst tmp, flagsRegCR0 cr0) +%{ + predicate(UseG1GC && n->as_Load()->is_unordered() && n->as_Load()->barrier_data() != 0); + // This instruction does not need an acquiring counterpart because it is only + // used for reference loading (Reference::get()). + match(Set dst (LoadP mem)); + effect(TEMP_DEF dst, TEMP tmp, KILL cr0); + ins_cost(2 * MEMORY_REF_COST); + format %{ "ld $dst, $mem\t# ptr" %} + ins_encode %{ + __ ld($dst$$Register, $mem$$disp, $mem$$base$$Register); + pre_write_barrier(masm, this, + noreg /* obj */, + $dst$$Register /* pre_val */, + $tmp$$Register); + %} + ins_pipe(pipe_class_default); +%} + +instruct g1LoadN(iRegNdst dst, memoryAlg4 mem, iRegPdst tmp1, iRegPdst tmp2, flagsRegCR0 cr0) +%{ + predicate(UseG1GC && n->as_Load()->is_unordered() && n->as_Load()->barrier_data() != 0); + // This instruction does not need an acquiring counterpart because it is only + // used for reference loading (Reference::get()). + match(Set dst (LoadN mem)); + effect(TEMP_DEF dst, TEMP tmp1, TEMP tmp2, KILL cr0); + ins_cost(2 * MEMORY_REF_COST); + format %{ "lwz $dst, $mem\t# ptr" %} + ins_encode %{ + __ lwz($dst$$Register, $mem$$disp, $mem$$base$$Register); + pre_write_barrier(masm, this, + noreg /* obj */, + $dst$$Register, + $tmp1$$Register, + $tmp2$$Register); + %} + ins_pipe(pipe_class_default); +%} diff --git a/src/hotspot/cpu/ppc/gc/shenandoah/shenandoahBarrierSetAssembler_ppc.cpp b/src/hotspot/cpu/ppc/gc/shenandoah/shenandoahBarrierSetAssembler_ppc.cpp index 3cb5c5a628f..53150807212 100644 --- a/src/hotspot/cpu/ppc/gc/shenandoah/shenandoahBarrierSetAssembler_ppc.cpp +++ b/src/hotspot/cpu/ppc/gc/shenandoah/shenandoahBarrierSetAssembler_ppc.cpp @@ -144,9 +144,9 @@ void ShenandoahBarrierSetAssembler::arraycopy_prologue(MacroAssembler *masm, Dec // Invoke runtime. address jrt_address = nullptr; if (UseCompressedOops) { - jrt_address = CAST_FROM_FN_PTR(address, ShenandoahRuntime::arraycopy_barrier_narrow_oop_entry); + jrt_address = CAST_FROM_FN_PTR(address, ShenandoahRuntime::arraycopy_barrier_narrow_oop); } else { - jrt_address = CAST_FROM_FN_PTR(address, ShenandoahRuntime::arraycopy_barrier_oop_entry); + jrt_address = CAST_FROM_FN_PTR(address, ShenandoahRuntime::arraycopy_barrier_oop); } assert(jrt_address != nullptr, "jrt routine cannot be found"); @@ -302,7 +302,7 @@ void ShenandoahBarrierSetAssembler::satb_write_barrier_impl(MacroAssembler *masm } // Invoke runtime. - __ call_VM_leaf(CAST_FROM_FN_PTR(address, ShenandoahRuntime::write_ref_field_pre_entry), pre_val, R16_thread); + __ call_VM_leaf(CAST_FROM_FN_PTR(address, ShenandoahRuntime::write_ref_field_pre), pre_val, R16_thread); // Restore to-be-preserved registers. if (!preserve_gp_registers && preloaded_mode && pre_val->is_volatile()) { @@ -906,7 +906,7 @@ void ShenandoahBarrierSetAssembler::generate_c1_pre_barrier_runtime_stub(StubAss __ push_frame_reg_args(nbytes_save, R11_tmp1); // Invoke runtime. - __ call_VM_leaf(CAST_FROM_FN_PTR(address, ShenandoahRuntime::write_ref_field_pre_entry), R0_pre_val, R16_thread); + __ call_VM_leaf(CAST_FROM_FN_PTR(address, ShenandoahRuntime::write_ref_field_pre), R0_pre_val, R16_thread); // Restore to-be-preserved registers. __ pop_frame(); diff --git a/src/hotspot/cpu/ppc/gc/z/zAddress_ppc.cpp b/src/hotspot/cpu/ppc/gc/z/zAddress_ppc.cpp index 136fd7a8ad1..ddeb9adf0a9 100644 --- a/src/hotspot/cpu/ppc/gc/z/zAddress_ppc.cpp +++ b/src/hotspot/cpu/ppc/gc/z/zAddress_ppc.cpp @@ -90,7 +90,7 @@ static size_t probe_valid_max_address_bit() { } size_t ZPlatformAddressOffsetBits() { - const static size_t valid_max_address_offset_bits = probe_valid_max_address_bit() + 1; + static const size_t valid_max_address_offset_bits = probe_valid_max_address_bit() + 1; const size_t max_address_offset_bits = valid_max_address_offset_bits - 3; const size_t min_address_offset_bits = max_address_offset_bits - 2; const size_t address_offset = round_up_power_of_2(MaxHeapSize * ZVirtualToPhysicalRatio); diff --git a/src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp b/src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp index 3acee737a3a..aa77f0169ea 100644 --- a/src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp +++ b/src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, 2023 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -135,15 +135,7 @@ void InterpreterMacroAssembler::check_and_handle_popframe(Register scratch_reg) // Call the Interpreter::remove_activation_preserving_args_entry() // func to get the address of the same-named entrypoint in the // generated interpreter code. -#if defined(ABI_ELFv2) - call_c(CAST_FROM_FN_PTR(address, - Interpreter::remove_activation_preserving_args_entry), - relocInfo::none); -#else - call_c(CAST_FROM_FN_PTR(FunctionDescriptor*, - Interpreter::remove_activation_preserving_args_entry), - relocInfo::none); -#endif + call_c(CAST_FROM_FN_PTR(address, Interpreter::remove_activation_preserving_args_entry)); // Jump to Interpreter::_remove_activation_preserving_args_entry. mtctr(R3_RET); @@ -970,13 +962,13 @@ void InterpreterMacroAssembler::lock_object(Register monitor, Register object) { if (DiagnoseSyncOnValueBasedClasses != 0) { load_klass(tmp, object); - lwz(tmp, in_bytes(Klass::access_flags_offset()), tmp); - testbitdi(CCR0, R0, tmp, exact_log2(JVM_ACC_IS_VALUE_BASED_CLASS)); + lbz(tmp, in_bytes(Klass::misc_flags_offset()), tmp); + testbitdi(CCR0, R0, tmp, exact_log2(KlassFlags::_misc_is_value_based_class)); bne(CCR0, slow_case); } if (LockingMode == LM_LIGHTWEIGHT) { - lightweight_lock(object, header, tmp, slow_case); + lightweight_lock(monitor, object, header, tmp, slow_case); b(count_locking); } else if (LockingMode == LM_LEGACY) { // Load markWord from object into header. diff --git a/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp b/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp index faca90990c8..a194c030a61 100644 --- a/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp +++ b/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp @@ -1293,11 +1293,7 @@ void MacroAssembler::call_VM_base(Register oop_result, // ARG1 must hold thread address. mr(R3_ARG1, R16_thread); -#if defined(ABI_ELFv2) address return_pc = call_c(entry_point, relocInfo::none); -#else - address return_pc = call_c((FunctionDescriptor*)entry_point, relocInfo::none); -#endif reset_last_Java_frame(); @@ -1318,11 +1314,7 @@ void MacroAssembler::call_VM_base(Register oop_result, void MacroAssembler::call_VM_leaf_base(address entry_point) { BLOCK_COMMENT("call_VM_leaf {"); -#if defined(ABI_ELFv2) - call_c(entry_point, relocInfo::none); -#else - call_c(CAST_FROM_FN_PTR(FunctionDescriptor*, entry_point), relocInfo::none); -#endif + call_c(entry_point); BLOCK_COMMENT("} call_VM_leaf"); } @@ -2418,7 +2410,7 @@ void MacroAssembler::verify_secondary_supers_table(Register r_sub_klass, void MacroAssembler::clinit_barrier(Register klass, Register thread, Label* L_fast_path, Label* L_slow_path) { assert(L_fast_path != nullptr || L_slow_path != nullptr, "at least one is required"); - Label L_fallthrough; + Label L_check_thread, L_fallthrough; if (L_fast_path == nullptr) { L_fast_path = &L_fallthrough; } else if (L_slow_path == nullptr) { @@ -2427,10 +2419,14 @@ void MacroAssembler::clinit_barrier(Register klass, Register thread, Label* L_fa // Fast path check: class is fully initialized lbz(R0, in_bytes(InstanceKlass::init_state_offset()), klass); + // acquire by cmp-branch-isync if fully_initialized cmpwi(CCR0, R0, InstanceKlass::fully_initialized); - beq(CCR0, *L_fast_path); + bne(CCR0, L_check_thread); + isync(); + b(*L_fast_path); // Fast path check: current thread is initializer thread + bind(L_check_thread); ld(R0, in_bytes(InstanceKlass::init_thread_offset()), klass); cmpd(CCR0, thread, R0); if (L_slow_path == &L_fallthrough) { @@ -2561,8 +2557,8 @@ void MacroAssembler::compiler_fast_lock_object(ConditionRegister flag, Register if (DiagnoseSyncOnValueBasedClasses != 0) { load_klass(temp, oop); - lwz(temp, in_bytes(Klass::access_flags_offset()), temp); - testbitdi(flag, R0, temp, exact_log2(JVM_ACC_IS_VALUE_BASED_CLASS)); + lbz(temp, in_bytes(Klass::misc_flags_offset()), temp); + testbitdi(flag, R0, temp, exact_log2(KlassFlags::_misc_is_value_based_class)); bne(flag, failure); } @@ -2723,13 +2719,34 @@ void MacroAssembler::compiler_fast_unlock_object(ConditionRegister flag, Registe b(success); bind(notRecursive); + + // Set owner to null. + // Release to satisfy the JMM + release(); + li(temp, 0); + std(temp, in_bytes(ObjectMonitor::owner_offset()), current_header); + // We need a full fence after clearing owner to avoid stranding. + // StoreLoad achieves this. + membar(StoreLoad); + + // Check if the entry lists are empty. ld(temp, in_bytes(ObjectMonitor::EntryList_offset()), current_header); ld(displaced_header, in_bytes(ObjectMonitor::cxq_offset()), current_header); orr(temp, temp, displaced_header); // Will be 0 if both are 0. cmpdi(flag, temp, 0); - bne(flag, failure); - release(); - std(temp, in_bytes(ObjectMonitor::owner_offset()), current_header); + beq(flag, success); // If so we are done. + + // Check if there is a successor. + ld(temp, in_bytes(ObjectMonitor::succ_offset()), current_header); + cmpdi(flag, temp, 0); + bne(flag, success); // If so we are done. + + // Save the monitor pointer in the current thread, so we can try + // to reacquire the lock in SharedRuntime::monitor_exit_helper(). + std(current_header, in_bytes(JavaThread::unlocked_inflated_monitor_offset()), R16_thread); + + crxor(flag, Assembler::equal, flag, Assembler::equal); // Set flag = NE => slow path + b(failure); // flag == EQ indicates success, decrement held monitor count // flag == NE indicates failure @@ -2738,9 +2755,9 @@ void MacroAssembler::compiler_fast_unlock_object(ConditionRegister flag, Registe bind(failure); } -void MacroAssembler::compiler_fast_lock_lightweight_object(ConditionRegister flag, Register obj, Register tmp1, - Register tmp2, Register tmp3) { - assert_different_registers(obj, tmp1, tmp2, tmp3); +void MacroAssembler::compiler_fast_lock_lightweight_object(ConditionRegister flag, Register obj, Register box, + Register tmp1, Register tmp2, Register tmp3) { + assert_different_registers(obj, box, tmp1, tmp2, tmp3); assert(flag == CCR0, "bad condition register"); // Handle inflated monitor. @@ -2750,11 +2767,17 @@ void MacroAssembler::compiler_fast_lock_lightweight_object(ConditionRegister fla // Finish fast lock unsuccessfully. MUST branch to with flag == EQ Label slow_path; + if (UseObjectMonitorTable) { + // Clear cache in case fast locking succeeds. + li(tmp1, 0); + std(tmp1, in_bytes(BasicObjectLock::lock_offset()) + BasicLock::object_monitor_cache_offset_in_bytes(), box); + } + if (DiagnoseSyncOnValueBasedClasses != 0) { load_klass(tmp1, obj); - lwz(tmp1, in_bytes(Klass::access_flags_offset()), tmp1); - testbitdi(flag, R0, tmp1, exact_log2(JVM_ACC_IS_VALUE_BASED_CLASS)); - bne(flag, slow_path); + lbz(tmp1, in_bytes(Klass::misc_flags_offset()), tmp1); + testbitdi(CCR0, R0, tmp1, exact_log2(KlassFlags::_misc_is_value_based_class)); + bne(CCR0, slow_path); } const Register mark = tmp1; @@ -2769,8 +2792,8 @@ void MacroAssembler::compiler_fast_lock_lightweight_object(ConditionRegister fla // Check if lock-stack is full. lwz(top, in_bytes(JavaThread::lock_stack_top_offset()), R16_thread); - cmplwi(flag, top, LockStack::end_offset() - 1); - bgt(flag, slow_path); + cmplwi(CCR0, top, LockStack::end_offset() - 1); + bgt(CCR0, slow_path); // The underflow check is elided. The recursive check will always fail // when the lock stack is empty because of the _bad_oop_sentinel field. @@ -2778,19 +2801,19 @@ void MacroAssembler::compiler_fast_lock_lightweight_object(ConditionRegister fla // Check if recursive. subi(t, top, oopSize); ldx(t, R16_thread, t); - cmpd(flag, obj, t); - beq(flag, push); + cmpd(CCR0, obj, t); + beq(CCR0, push); // Check for monitor (0b10) or locked (0b00). ld(mark, oopDesc::mark_offset_in_bytes(), obj); andi_(t, mark, markWord::lock_mask_in_place); - cmpldi(flag, t, markWord::unlocked_value); - bgt(flag, inflated); - bne(flag, slow_path); + cmpldi(CCR0, t, markWord::unlocked_value); + bgt(CCR0, inflated); + bne(CCR0, slow_path); // Not inflated. - // Try to lock. Transition lock bits 0b00 => 0b01 + // Try to lock. Transition lock bits 0b01 => 0b00 assert(oopDesc::mark_offset_in_bytes() == 0, "required to avoid a lea"); atomically_flip_locked_state(/* is_unlock */ false, obj, mark, slow_path, MacroAssembler::MemBarAcq); @@ -2805,38 +2828,84 @@ void MacroAssembler::compiler_fast_lock_lightweight_object(ConditionRegister fla { // Handle inflated monitor. bind(inflated); + // mark contains the tagged ObjectMonitor*. + const uintptr_t monitor_tag = markWord::monitor_value; + const Register monitor = mark; + const Register owner_addr = tmp2; + Label monitor_locked; + if (!UseObjectMonitorTable) { - // mark contains the tagged ObjectMonitor*. - const Register tagged_monitor = mark; - const uintptr_t monitor_tag = markWord::monitor_value; - const Register owner_addr = tmp2; + // Compute owner address. + addi(owner_addr, mark, in_bytes(ObjectMonitor::owner_offset()) - monitor_tag); + } else { + Label monitor_found; + Register cache_addr = tmp2; + + // Load cache address + addi(cache_addr, R16_thread, in_bytes(JavaThread::om_cache_oops_offset())); + + const int num_unrolled = 2; + for (int i = 0; i < num_unrolled; i++) { + ld(tmp3, 0, cache_addr); + cmpd(CCR0, tmp3, obj); + beq(CCR0, monitor_found); + addi(cache_addr, cache_addr, in_bytes(OMCache::oop_to_oop_difference())); + } + + Label loop; + + // Search for obj in cache. + bind(loop); + + // Check for match. + ld(tmp3, 0, cache_addr); + cmpd(CCR0, tmp3, obj); + beq(CCR0, monitor_found); + + // Search until null encountered, guaranteed _null_sentinel at end. + addi(cache_addr, cache_addr, in_bytes(OMCache::oop_to_oop_difference())); + cmpdi(CCR1, tmp3, 0); + bne(CCR1, loop); + // Cache Miss, CCR0.NE set from cmp above + b(slow_path); + + bind(monitor_found); + ld(monitor, in_bytes(OMCache::oop_to_monitor_difference()), cache_addr); // Compute owner address. - addi(owner_addr, tagged_monitor, in_bytes(ObjectMonitor::owner_offset()) - monitor_tag); + addi(owner_addr, monitor, in_bytes(ObjectMonitor::owner_offset())); + } - // CAS owner (null => current thread). - cmpxchgd(/*flag=*/flag, - /*current_value=*/t, - /*compare_value=*/(intptr_t)0, - /*exchange_value=*/R16_thread, - /*where=*/owner_addr, - MacroAssembler::MemBarRel | MacroAssembler::MemBarAcq, - MacroAssembler::cmpxchgx_hint_acquire_lock()); - beq(flag, locked); + // CAS owner (null => current thread). + cmpxchgd(/*flag=*/CCR0, + /*current_value=*/t, + /*compare_value=*/(intptr_t)0, + /*exchange_value=*/R16_thread, + /*where=*/owner_addr, + MacroAssembler::MemBarRel | MacroAssembler::MemBarAcq, + MacroAssembler::cmpxchgx_hint_acquire_lock()); + beq(CCR0, monitor_locked); - // Check if recursive. - cmpd(flag, t, R16_thread); - bne(flag, slow_path); + // Check if recursive. + cmpd(CCR0, t, R16_thread); + bne(CCR0, slow_path); - // Recursive. + // Recursive. + if (!UseObjectMonitorTable) { + assert_different_registers(tmp1, owner_addr); ld(tmp1, in_bytes(ObjectMonitor::recursions_offset() - ObjectMonitor::owner_offset()), owner_addr); addi(tmp1, tmp1, 1); std(tmp1, in_bytes(ObjectMonitor::recursions_offset() - ObjectMonitor::owner_offset()), owner_addr); } else { - // OMCache lookup not supported yet. Take the slowpath. - // Set flag to NE - crxor(flag, Assembler::equal, flag, Assembler::equal); - b(slow_path); + assert_different_registers(tmp2, monitor); + ld(tmp2, in_bytes(ObjectMonitor::recursions_offset()), monitor); + addi(tmp2, tmp2, 1); + std(tmp2, in_bytes(ObjectMonitor::recursions_offset()), monitor); + } + + bind(monitor_locked); + if (UseObjectMonitorTable) { + std(monitor, BasicLock::object_monitor_cache_offset_in_bytes(), box); } } @@ -2846,21 +2915,21 @@ void MacroAssembler::compiler_fast_lock_lightweight_object(ConditionRegister fla #ifdef ASSERT // Check that locked label is reached with flag == EQ. Label flag_correct; - beq(flag, flag_correct); + beq(CCR0, flag_correct); stop("Fast Lock Flag != EQ"); #endif bind(slow_path); #ifdef ASSERT // Check that slow_path label is reached with flag == NE. - bne(flag, flag_correct); + bne(CCR0, flag_correct); stop("Fast Lock Flag != NE"); bind(flag_correct); #endif // C2 uses the value of flag (NE vs EQ) to determine the continuation. } -void MacroAssembler::compiler_fast_unlock_lightweight_object(ConditionRegister flag, Register obj, Register tmp1, - Register tmp2, Register tmp3) { +void MacroAssembler::compiler_fast_unlock_lightweight_object(ConditionRegister flag, Register obj, Register box, + Register tmp1, Register tmp2, Register tmp3) { assert_different_registers(obj, tmp1, tmp2, tmp3); assert(flag == CCR0, "bad condition register"); @@ -2882,9 +2951,9 @@ void MacroAssembler::compiler_fast_unlock_lightweight_object(ConditionRegister f lwz(top, in_bytes(JavaThread::lock_stack_top_offset()), R16_thread); subi(top, top, oopSize); ldx(t, R16_thread, top); - cmpd(flag, obj, t); + cmpd(CCR0, obj, t); // Top of lock stack was not obj. Must be monitor. - bne(flag, inflated_load_monitor); + bne(CCR0, inflated_load_monitor); // Pop lock-stack. DEBUG_ONLY(li(t, 0);) @@ -2897,8 +2966,8 @@ void MacroAssembler::compiler_fast_unlock_lightweight_object(ConditionRegister f // Check if recursive. subi(t, top, oopSize); ldx(t, R16_thread, t); - cmpd(flag, obj, t); - beq(flag, unlocked); + cmpd(CCR0, obj, t); + beq(CCR0, unlocked); // Not recursive. @@ -2949,62 +3018,74 @@ void MacroAssembler::compiler_fast_unlock_lightweight_object(ConditionRegister f cmplwi(CCR0, top, in_bytes(JavaThread::lock_stack_base_offset())); blt(CCR0, check_done); ldx(t, R16_thread, top); - cmpd(flag, obj, t); - bne(flag, inflated); + cmpd(CCR0, obj, t); + bne(CCR0, inflated); stop("Fast Unlock lock on stack"); bind(check_done); #endif - if (!UseObjectMonitorTable) { - // mark contains the tagged ObjectMonitor*. - const Register monitor = mark; - const uintptr_t monitor_tag = markWord::monitor_value; + // mark contains the tagged ObjectMonitor*. + const Register monitor = mark; + const uintptr_t monitor_tag = markWord::monitor_value; + if (!UseObjectMonitorTable) { // Untag the monitor. subi(monitor, mark, monitor_tag); - - const Register recursions = tmp2; - Label not_recursive; - - // Check if recursive. - ld(recursions, in_bytes(ObjectMonitor::recursions_offset()), monitor); - addic_(recursions, recursions, -1); - blt(CCR0, not_recursive); - - // Recursive unlock. - std(recursions, in_bytes(ObjectMonitor::recursions_offset()), monitor); - crorc(CCR0, Assembler::equal, CCR0, Assembler::equal); - b(unlocked); - - bind(not_recursive); - - Label release_; - const Register t2 = tmp2; - - // Check if the entry lists are empty. - ld(t, in_bytes(ObjectMonitor::EntryList_offset()), monitor); - ld(t2, in_bytes(ObjectMonitor::cxq_offset()), monitor); - orr(t, t, t2); - cmpdi(flag, t, 0); - beq(flag, release_); - - // The owner may be anonymous and we removed the last obj entry in - // the lock-stack. This loses the information about the owner. - // Write the thread to the owner field so the runtime knows the owner. - std(R16_thread, in_bytes(ObjectMonitor::owner_offset()), monitor); - b(slow_path); - - bind(release_); - // Set owner to null. - release(); - // t contains 0 - std(t, in_bytes(ObjectMonitor::owner_offset()), monitor); } else { - // OMCache lookup not supported yet. Take the slowpath. - // Set flag to NE - crxor(flag, Assembler::equal, flag, Assembler::equal); - b(slow_path); + ld(monitor, BasicLock::object_monitor_cache_offset_in_bytes(), box); + // null check with Flags == NE, no valid pointer below alignof(ObjectMonitor*) + cmpldi(CCR0, monitor, checked_cast(alignof(ObjectMonitor*))); + blt(CCR0, slow_path); } + + const Register recursions = tmp2; + Label not_recursive; + + // Check if recursive. + ld(recursions, in_bytes(ObjectMonitor::recursions_offset()), monitor); + addic_(recursions, recursions, -1); + blt(CCR0, not_recursive); + + // Recursive unlock. + std(recursions, in_bytes(ObjectMonitor::recursions_offset()), monitor); + crorc(CCR0, Assembler::equal, CCR0, Assembler::equal); + b(unlocked); + + bind(not_recursive); + + Label set_eq_unlocked; + const Register t2 = tmp2; + + // Set owner to null. + // Release to satisfy the JMM + release(); + li(t, 0); + std(t, in_bytes(ObjectMonitor::owner_offset()), monitor); + // We need a full fence after clearing owner to avoid stranding. + // StoreLoad achieves this. + membar(StoreLoad); + + // Check if the entry lists are empty. + ld(t, in_bytes(ObjectMonitor::EntryList_offset()), monitor); + ld(t2, in_bytes(ObjectMonitor::cxq_offset()), monitor); + orr(t, t, t2); + cmpdi(CCR0, t, 0); + beq(CCR0, unlocked); // If so we are done. + + // Check if there is a successor. + ld(t, in_bytes(ObjectMonitor::succ_offset()), monitor); + cmpdi(CCR0, t, 0); + bne(CCR0, set_eq_unlocked); // If so we are done. + + // Save the monitor pointer in the current thread, so we can try + // to reacquire the lock in SharedRuntime::monitor_exit_helper(). + std(monitor, in_bytes(JavaThread::unlocked_inflated_monitor_offset()), R16_thread); + + crxor(CCR0, Assembler::equal, CCR0, Assembler::equal); // Set flag = NE => slow path + b(slow_path); + + bind(set_eq_unlocked); + crorc(CCR0, Assembler::equal, CCR0, Assembler::equal); // Set flag = EQ => fast path } bind(unlocked); @@ -3013,13 +3094,13 @@ void MacroAssembler::compiler_fast_unlock_lightweight_object(ConditionRegister f #ifdef ASSERT // Check that unlocked label is reached with flag == EQ. Label flag_correct; - beq(flag, flag_correct); + beq(CCR0, flag_correct); stop("Fast Lock Flag != EQ"); #endif bind(slow_path); #ifdef ASSERT // Check that slow_path label is reached with flag == NE. - bne(flag, flag_correct); + bne(CCR0, flag_correct); stop("Fast Lock Flag != NE"); bind(flag_correct); #endif @@ -4648,15 +4729,21 @@ void MacroAssembler::atomically_flip_locked_state(bool is_unlock, Register obj, // // - obj: the object to be locked // - t1, t2: temporary register -void MacroAssembler::lightweight_lock(Register obj, Register t1, Register t2, Label& slow) { +void MacroAssembler::lightweight_lock(Register box, Register obj, Register t1, Register t2, Label& slow) { assert(LockingMode == LM_LIGHTWEIGHT, "only used with new lightweight locking"); - assert_different_registers(obj, t1, t2); + assert_different_registers(box, obj, t1, t2); Label push; const Register top = t1; const Register mark = t2; const Register t = R0; + if (UseObjectMonitorTable) { + // Clear cache in case fast locking succeeds. + li(t, 0); + std(t, in_bytes(BasicObjectLock::lock_offset()) + BasicLock::object_monitor_cache_offset_in_bytes(), box); + } + // Check if the lock-stack is full. lwz(top, in_bytes(JavaThread::lock_stack_top_offset()), R16_thread); cmplwi(CCR0, top, LockStack::end_offset()); @@ -4677,7 +4764,7 @@ void MacroAssembler::lightweight_lock(Register obj, Register t1, Register t2, La andi_(t, t, markWord::lock_mask_in_place); bne(CCR0, slow); - // Try to lock. Transition lock bits 0b00 => 0b01 + // Try to lock. Transition lock bits 0b01 => 0b00 atomically_flip_locked_state(/* is_unlock */ false, obj, mark, slow, MacroAssembler::MemBarAcq); bind(push); diff --git a/src/hotspot/cpu/ppc/macroAssembler_ppc.hpp b/src/hotspot/cpu/ppc/macroAssembler_ppc.hpp index 9a0cf3d8da0..224e7bff995 100644 --- a/src/hotspot/cpu/ppc/macroAssembler_ppc.hpp +++ b/src/hotspot/cpu/ppc/macroAssembler_ppc.hpp @@ -359,7 +359,7 @@ class MacroAssembler: public Assembler { address call_c(Register function_entry); // For tail calls: only branch, don't link, so callee returns to caller of this function. address call_c_and_return_to_caller(Register function_entry); - address call_c(address function_entry, relocInfo::relocType rt); + address call_c(address function_entry, relocInfo::relocType rt = relocInfo::none); #else // Call a C function via a function descriptor and use full C // calling conventions. Updates and returns _last_calls_return_pc. @@ -367,6 +367,9 @@ class MacroAssembler: public Assembler { // For tail calls: only branch, don't link, so callee returns to caller of this function. address call_c_and_return_to_caller(Register function_descriptor); address call_c(const FunctionDescriptor* function_descriptor, relocInfo::relocType rt); + address call_c(address function_entry, relocInfo::relocType rt = relocInfo::none) { + return call_c((const FunctionDescriptor*)function_entry, rt); + } address call_c_using_toc(const FunctionDescriptor* function_descriptor, relocInfo::relocType rt, Register toc); #endif @@ -651,7 +654,7 @@ class MacroAssembler: public Assembler { void inc_held_monitor_count(Register tmp); void dec_held_monitor_count(Register tmp); void atomically_flip_locked_state(bool is_unlock, Register obj, Register tmp, Label& failed, int semantics); - void lightweight_lock(Register obj, Register t1, Register t2, Label& slow); + void lightweight_lock(Register box, Register obj, Register t1, Register t2, Label& slow); void lightweight_unlock(Register obj, Register t1, Label& slow); // allocation (for C1) @@ -672,11 +675,11 @@ class MacroAssembler: public Assembler { void compiler_fast_unlock_object(ConditionRegister flag, Register oop, Register box, Register tmp1, Register tmp2, Register tmp3); - void compiler_fast_lock_lightweight_object(ConditionRegister flag, Register oop, Register tmp1, - Register tmp2, Register tmp3); + void compiler_fast_lock_lightweight_object(ConditionRegister flag, Register oop, Register box, + Register tmp1, Register tmp2, Register tmp3); - void compiler_fast_unlock_lightweight_object(ConditionRegister flag, Register oop, Register tmp1, - Register tmp2, Register tmp3); + void compiler_fast_unlock_lightweight_object(ConditionRegister flag, Register oop, Register box, + Register tmp1, Register tmp2, Register tmp3); // Check if safepoint requested and if so branch void safepoint_poll(Label& slow_path, Register temp, bool at_return, bool in_nmethod); diff --git a/src/hotspot/cpu/ppc/ppc.ad b/src/hotspot/cpu/ppc/ppc.ad index e7e066ebcc6..f74dde0f97e 100644 --- a/src/hotspot/cpu/ppc/ppc.ad +++ b/src/hotspot/cpu/ppc/ppc.ad @@ -1000,6 +1000,10 @@ int MachNode::compute_padding(int current_offset) const { // Should the matcher clone input 'm' of node 'n'? bool Matcher::pd_clone_node(Node* n, Node* m, Matcher::MStack& mstack) { + if (is_encode_and_store_pattern(n, m)) { + mstack.push(m, Visit); + return true; + } return false; } @@ -2150,10 +2154,6 @@ const RegMask* Matcher::predicate_reg_mask(void) { return nullptr; } -const TypeVectMask* Matcher::predicate_reg_type(const Type* elemTy, int length) { - return nullptr; -} - // Vector calling convention not yet implemented. bool Matcher::supports_vector_calling_convention(void) { return false; @@ -5407,7 +5407,7 @@ instruct loadRange(iRegIdst dst, memory mem) %{ // Load Compressed Pointer instruct loadN(iRegNdst dst, memory mem) %{ match(Set dst (LoadN mem)); - predicate(n->as_Load()->is_unordered() || followed_by_acquire(n)); + predicate((n->as_Load()->is_unordered() || followed_by_acquire(n)) && n->as_Load()->barrier_data() == 0); ins_cost(MEMORY_REF_COST); format %{ "LWZ $dst, $mem \t// load compressed ptr" %} @@ -5419,6 +5419,7 @@ instruct loadN(iRegNdst dst, memory mem) %{ // Load Compressed Pointer acquire. instruct loadN_ac(iRegNdst dst, memory mem) %{ match(Set dst (LoadN mem)); + predicate(n->as_Load()->barrier_data() == 0); ins_cost(3*MEMORY_REF_COST); format %{ "LWZ $dst, $mem \t// load acquire compressed ptr\n\t" @@ -5432,7 +5433,7 @@ instruct loadN_ac(iRegNdst dst, memory mem) %{ // Load Compressed Pointer and decode it if narrow_oop_shift == 0. instruct loadN2P_unscaled(iRegPdst dst, memory mem) %{ match(Set dst (DecodeN (LoadN mem))); - predicate(_kids[0]->_leaf->as_Load()->is_unordered() && CompressedOops::shift() == 0); + predicate(_kids[0]->_leaf->as_Load()->is_unordered() && CompressedOops::shift() == 0 && _kids[0]->_leaf->as_Load()->barrier_data() == 0); ins_cost(MEMORY_REF_COST); format %{ "LWZ $dst, $mem \t// DecodeN (unscaled)" %} @@ -6423,6 +6424,7 @@ instruct reinterpretX(vecX dst) %{ // Store Compressed Oop instruct storeN(memory dst, iRegN_P2N src) %{ match(Set dst (StoreN dst src)); + predicate(n->as_Store()->barrier_data() == 0); ins_cost(MEMORY_REF_COST); format %{ "STW $src, $dst \t// compressed oop" %} @@ -6476,23 +6478,6 @@ instruct storeD(memory mem, regD src) %{ ins_pipe(pipe_class_memory); %} -//----------Store Instructions With Zeros-------------------------------------- - -instruct storeCM(memory mem, immI_0 zero) %{ - match(Set mem (StoreCM mem zero)); - ins_cost(MEMORY_REF_COST); - - format %{ "STB #0, $mem \t// CMS card-mark byte store" %} - size(8); - ins_encode %{ - __ li(R0, 0); - // No release barrier: Oops are allowed to get visible after marking. - guarantee($mem$$base$$Register != R1_SP, "use frame_slots_bias"); - __ stb(R0, $mem$$disp, $mem$$base$$Register); - %} - ins_pipe(pipe_class_memory); -%} - // Convert oop pointer into compressed form. // Nodes for postalloc expand. @@ -6598,7 +6583,7 @@ instruct encodeP_not_null_Ex(iRegNdst dst, iRegPsrc src) %{ instruct encodeP_not_null_base_null(iRegNdst dst, iRegPsrc src) %{ match(Set dst (EncodeP src)); predicate(CompressedOops::shift() != 0 && - CompressedOops::base() ==0); + CompressedOops::base() == nullptr); format %{ "SRDI $dst, $src, #3 \t// encodeP, $src != nullptr" %} size(4); @@ -6695,7 +6680,7 @@ instruct decodeN_Ex(iRegPdst dst, iRegNsrc src, flagsReg crx) %{ predicate((n->bottom_type()->is_oopptr()->ptr() != TypePtr::NotNull && n->bottom_type()->is_oopptr()->ptr() != TypePtr::Constant) && CompressedOops::shift() != 0 && - CompressedOops::base() != 0); + CompressedOops::base() != nullptr); ins_cost(4 * DEFAULT_COST); // Should be more expensive than decodeN_Disjoint_isel_Ex. effect(TEMP crx); @@ -6707,7 +6692,7 @@ instruct decodeN_Ex(iRegPdst dst, iRegNsrc src, flagsReg crx) %{ instruct decodeN_nullBase(iRegPdst dst, iRegNsrc src) %{ match(Set dst (DecodeN src)); predicate(CompressedOops::shift() != 0 && - CompressedOops::base() == 0); + CompressedOops::base() == nullptr); format %{ "SLDI $dst, $src, #3 \t// DecodeN (zerobased)" %} size(4); @@ -6825,7 +6810,7 @@ instruct decodeN_notNull_addBase_Ex(iRegPdst dst, iRegNsrc src) %{ predicate((n->bottom_type()->is_oopptr()->ptr() == TypePtr::NotNull || n->bottom_type()->is_oopptr()->ptr() == TypePtr::Constant) && CompressedOops::shift() != 0 && - CompressedOops::base() != 0); + CompressedOops::base() != nullptr); ins_cost(2 * DEFAULT_COST); format %{ "DecodeN $dst, $src \t// $src != nullptr, postalloc expanded" %} @@ -7477,6 +7462,7 @@ instruct compareAndSwapI_regP_regI_regI(iRegIdst res, iRegPdst mem_ptr, iRegIsrc instruct compareAndSwapN_regP_regN_regN(iRegIdst res, iRegPdst mem_ptr, iRegNsrc src1, iRegNsrc src2, flagsRegCR0 cr0) %{ match(Set res (CompareAndSwapN mem_ptr (Binary src1 src2))); + predicate(n->as_LoadStore()->barrier_data() == 0); effect(TEMP_DEF res, TEMP cr0); // TEMP_DEF to avoid jump format %{ "CMPXCHGW $res, $mem_ptr, $src1, $src2; as bool" %} ins_encode %{ @@ -7676,7 +7662,7 @@ instruct weakCompareAndSwapI_acq_regP_regI_regI(iRegIdst res, iRegPdst mem_ptr, instruct weakCompareAndSwapN_regP_regN_regN(iRegIdst res, iRegPdst mem_ptr, iRegNsrc src1, iRegNsrc src2, flagsRegCR0 cr0) %{ match(Set res (WeakCompareAndSwapN mem_ptr (Binary src1 src2))); - predicate(((CompareAndSwapNode*)n)->order() != MemNode::acquire && ((CompareAndSwapNode*)n)->order() != MemNode::seqcst); + predicate(((CompareAndSwapNode*)n)->order() != MemNode::acquire && ((CompareAndSwapNode*)n)->order() != MemNode::seqcst && n->as_LoadStore()->barrier_data() == 0); effect(TEMP_DEF res, TEMP cr0); // TEMP_DEF to avoid jump format %{ "weak CMPXCHGW $res, $mem_ptr, $src1, $src2; as bool" %} ins_encode %{ @@ -7690,7 +7676,7 @@ instruct weakCompareAndSwapN_regP_regN_regN(iRegIdst res, iRegPdst mem_ptr, iReg instruct weakCompareAndSwapN_acq_regP_regN_regN(iRegIdst res, iRegPdst mem_ptr, iRegNsrc src1, iRegNsrc src2, flagsRegCR0 cr0) %{ match(Set res (WeakCompareAndSwapN mem_ptr (Binary src1 src2))); - predicate(((CompareAndSwapNode*)n)->order() == MemNode::acquire || ((CompareAndSwapNode*)n)->order() == MemNode::seqcst); + predicate((((CompareAndSwapNode*)n)->order() == MemNode::acquire || ((CompareAndSwapNode*)n)->order() == MemNode::seqcst) && n->as_LoadStore()->barrier_data() == 0); effect(TEMP_DEF res, TEMP cr0); // TEMP_DEF to avoid jump format %{ "weak CMPXCHGW acq $res, $mem_ptr, $src1, $src2; as bool" %} ins_encode %{ @@ -7939,7 +7925,7 @@ instruct compareAndExchangeI_acq_regP_regI_regI(iRegIdst res, iRegPdst mem_ptr, instruct compareAndExchangeN_regP_regN_regN(iRegNdst res, iRegPdst mem_ptr, iRegNsrc src1, iRegNsrc src2, flagsRegCR0 cr0) %{ match(Set res (CompareAndExchangeN mem_ptr (Binary src1 src2))); - predicate(((CompareAndSwapNode*)n)->order() != MemNode::acquire && ((CompareAndSwapNode*)n)->order() != MemNode::seqcst); + predicate(((CompareAndSwapNode*)n)->order() != MemNode::acquire && ((CompareAndSwapNode*)n)->order() != MemNode::seqcst && n->as_LoadStore()->barrier_data() == 0); effect(TEMP_DEF res, TEMP cr0); format %{ "CMPXCHGW $res, $mem_ptr, $src1, $src2; as narrow oop" %} ins_encode %{ @@ -7953,7 +7939,7 @@ instruct compareAndExchangeN_regP_regN_regN(iRegNdst res, iRegPdst mem_ptr, iReg instruct compareAndExchangeN_acq_regP_regN_regN(iRegNdst res, iRegPdst mem_ptr, iRegNsrc src1, iRegNsrc src2, flagsRegCR0 cr0) %{ match(Set res (CompareAndExchangeN mem_ptr (Binary src1 src2))); - predicate(((CompareAndSwapNode*)n)->order() == MemNode::acquire || ((CompareAndSwapNode*)n)->order() == MemNode::seqcst); + predicate((((CompareAndSwapNode*)n)->order() == MemNode::acquire || ((CompareAndSwapNode*)n)->order() == MemNode::seqcst) && n->as_LoadStore()->barrier_data() == 0); effect(TEMP_DEF res, TEMP cr0); format %{ "CMPXCHGW acq $res, $mem_ptr, $src1, $src2; as narrow oop" %} ins_encode %{ @@ -8262,6 +8248,7 @@ instruct getAndSetP(iRegPdst res, iRegPdst mem_ptr, iRegPsrc src, flagsRegCR0 cr instruct getAndSetN(iRegNdst res, iRegPdst mem_ptr, iRegNsrc src, flagsRegCR0 cr0) %{ match(Set res (GetAndSetN mem_ptr src)); + predicate(n->as_LoadStore()->barrier_data() == 0); effect(TEMP_DEF res, TEMP cr0); format %{ "GetAndSetN $res, $mem_ptr, $src" %} ins_encode %{ @@ -12106,10 +12093,10 @@ instruct cmpFastUnlock(flagsRegCR0 crx, iRegPdst oop, iRegPdst box, iRegPdst tmp ins_pipe(pipe_class_compare); %} -instruct cmpFastLockLightweight(flagsRegCR0 crx, iRegPdst oop, iRegPdst box, iRegPdst tmp1, iRegPdst tmp2) %{ +instruct cmpFastLockLightweight(flagsRegCR0 crx, iRegPdst oop, iRegPdst box, iRegPdst tmp1, iRegPdst tmp2, flagsRegCR1 cr1) %{ predicate(LockingMode == LM_LIGHTWEIGHT); match(Set crx (FastLock oop box)); - effect(TEMP tmp1, TEMP tmp2); + effect(TEMP tmp1, TEMP tmp2, KILL cr1); format %{ "FASTLOCK $oop, $box, $tmp1, $tmp2" %} ins_encode %{ diff --git a/src/hotspot/cpu/ppc/register_ppc.hpp b/src/hotspot/cpu/ppc/register_ppc.hpp index 302d49884fa..b7ba4f053b5 100644 --- a/src/hotspot/cpu/ppc/register_ppc.hpp +++ b/src/hotspot/cpu/ppc/register_ppc.hpp @@ -27,6 +27,7 @@ #define CPU_PPC_REGISTER_PPC_HPP #include "asm/register.hpp" +#include "utilities/count_trailing_zeros.hpp" // forward declaration class VMRegImpl; @@ -555,4 +556,12 @@ constexpr Register R29_TOC = R29; constexpr Register R11_scratch1 = R11; constexpr Register R12_scratch2 = R12; +template <> +inline Register AbstractRegSet::first() { + if (_bitset == 0) { return noreg; } + return as_Register(count_trailing_zeros(_bitset)); +} + +typedef AbstractRegSet RegSet; + #endif // CPU_PPC_REGISTER_PPC_HPP diff --git a/src/hotspot/cpu/ppc/runtime_ppc.cpp b/src/hotspot/cpu/ppc/runtime_ppc.cpp index 8c3bfd4f37b..dbdc16ee5f1 100644 --- a/src/hotspot/cpu/ppc/runtime_ppc.cpp +++ b/src/hotspot/cpu/ppc/runtime_ppc.cpp @@ -99,12 +99,7 @@ void OptoRuntime::generate_exception_blob() { __ set_last_Java_frame(/*sp=*/R1_SP, noreg); __ mr(R3_ARG1, R16_thread); -#if defined(ABI_ELFv2) - __ call_c((address) OptoRuntime::handle_exception_C, relocInfo::none); -#else - __ call_c(CAST_FROM_FN_PTR(FunctionDescriptor*, OptoRuntime::handle_exception_C), - relocInfo::none); -#endif + __ call_c((address) OptoRuntime::handle_exception_C); address calls_return_pc = __ last_calls_return_pc(); # ifdef ASSERT __ cmpdi(CCR0, R3_RET, 0); diff --git a/src/hotspot/cpu/ppc/sharedRuntime_ppc.cpp b/src/hotspot/cpu/ppc/sharedRuntime_ppc.cpp index 98610d21b67..aa8ae6070b6 100644 --- a/src/hotspot/cpu/ppc/sharedRuntime_ppc.cpp +++ b/src/hotspot/cpu/ppc/sharedRuntime_ppc.cpp @@ -2399,7 +2399,7 @@ nmethod *SharedRuntime::generate_native_wrapper(MacroAssembler *masm, // Try fastpath for locking. if (LockingMode == LM_LIGHTWEIGHT) { // fast_lock kills r_temp_1, r_temp_2, r_temp_3. - __ compiler_fast_lock_lightweight_object(CCR0, r_oop, r_temp_1, r_temp_2, r_temp_3); + __ compiler_fast_lock_lightweight_object(CCR0, r_oop, r_box, r_temp_1, r_temp_2, r_temp_3); } else { // fast_lock kills r_temp_1, r_temp_2, r_temp_3. __ compiler_fast_lock_object(CCR0, r_oop, r_box, r_temp_1, r_temp_2, r_temp_3); @@ -2444,12 +2444,7 @@ nmethod *SharedRuntime::generate_native_wrapper(MacroAssembler *masm, // The JNI call // -------------------------------------------------------------------------- -#if defined(ABI_ELFv2) __ call_c(native_func, relocInfo::runtime_call_type); -#else - FunctionDescriptor* fd_native_method = (FunctionDescriptor*) native_func; - __ call_c(fd_native_method, relocInfo::runtime_call_type); -#endif // Now, we are back from the native code. @@ -2610,7 +2605,7 @@ nmethod *SharedRuntime::generate_native_wrapper(MacroAssembler *masm, // Try fastpath for unlocking. if (LockingMode == LM_LIGHTWEIGHT) { - __ compiler_fast_unlock_lightweight_object(CCR0, r_oop, r_temp_1, r_temp_2, r_temp_3); + __ compiler_fast_unlock_lightweight_object(CCR0, r_oop, r_box, r_temp_1, r_temp_2, r_temp_3); } else { __ compiler_fast_unlock_object(CCR0, r_oop, r_box, r_temp_1, r_temp_2, r_temp_3); } @@ -2861,7 +2856,8 @@ void SharedRuntime::generate_deopt_blob() { // Allocate space for the code ResourceMark rm; // Setup code generation tools - CodeBuffer buffer("deopt_blob", 2048, 1024); + const char* name = SharedRuntime::stub_name(SharedStubId::deopt_id); + CodeBuffer buffer(name, 2048, 1024); InterpreterMacroAssembler* masm = new InterpreterMacroAssembler(&buffer); Label exec_mode_initialized; int frame_size_in_words; @@ -3211,23 +3207,25 @@ void OptoRuntime::generate_uncommon_trap_blob() { #endif // COMPILER2 // Generate a special Compile2Runtime blob that saves all registers, and setup oopmap. -SafepointBlob* SharedRuntime::generate_handler_blob(address call_ptr, int poll_type) { +SafepointBlob* SharedRuntime::generate_handler_blob(SharedStubId id, address call_ptr) { assert(StubRoutines::forward_exception_entry() != nullptr, "must be generated before"); + assert(is_polling_page_id(id), "expected a polling page stub id"); ResourceMark rm; OopMapSet *oop_maps = new OopMapSet(); OopMap* map; // Allocate space for the code. Setup code generation tools. - CodeBuffer buffer("handler_blob", 2048, 1024); + const char* name = SharedRuntime::stub_name(id); + CodeBuffer buffer(name, 2048, 1024); MacroAssembler* masm = new MacroAssembler(&buffer); address start = __ pc(); int frame_size_in_bytes = 0; RegisterSaver::ReturnPCLocation return_pc_location; - bool cause_return = (poll_type == POLL_AT_RETURN); + bool cause_return = (id == SharedStubId::polling_page_return_handler_id); if (cause_return) { // Nothing to do here. The frame has already been popped in MachEpilogNode. // Register LR already contains the return pc. @@ -3237,7 +3235,7 @@ SafepointBlob* SharedRuntime::generate_handler_blob(address call_ptr, int poll_t return_pc_location = RegisterSaver::return_pc_is_thread_saved_exception_pc; } - bool save_vectors = (poll_type == POLL_AT_VECTOR_LOOP); + bool save_vectors = (id == SharedStubId::polling_page_vectors_safepoint_handler_id); // Save registers, fpu state, and flags. Set R31 = return pc. map = RegisterSaver::push_frame_reg_args_and_save_live_registers(masm, @@ -3324,11 +3322,13 @@ SafepointBlob* SharedRuntime::generate_handler_blob(address call_ptr, int poll_t // but since this is generic code we don't know what they are and the caller // must do any gc of the args. // -RuntimeStub* SharedRuntime::generate_resolve_blob(address destination, const char* name) { +RuntimeStub* SharedRuntime::generate_resolve_blob(SharedStubId id, address destination) { + assert(is_resolve_id(id), "expected a resolve stub id"); // allocate space for the code ResourceMark rm; + const char* name = SharedRuntime::stub_name(id); CodeBuffer buffer(name, 1000, 512); MacroAssembler* masm = new MacroAssembler(&buffer); @@ -3426,7 +3426,11 @@ RuntimeStub* SharedRuntime::generate_resolve_blob(address destination, const cha // Note: the routine set_pc_not_at_call_for_caller in // SharedRuntime.cpp requires that this code be generated into a // RuntimeStub. -RuntimeStub* SharedRuntime::generate_throw_exception(const char* name, address runtime_entry) { +RuntimeStub* SharedRuntime::generate_throw_exception(SharedStubId id, address runtime_entry) { + assert(is_throw_id(id), "expected a throw stub id"); + + const char* name = SharedRuntime::stub_name(id); + ResourceMark rm; const char* timer_msg = "SharedRuntime generate_throw_exception"; TraceTime timer(timer_msg, TRACETIME_LOG(Info, startuptime)); @@ -3455,11 +3459,7 @@ RuntimeStub* SharedRuntime::generate_throw_exception(const char* name, address r __ set_last_Java_frame(/*sp*/R1_SP, /*pc*/R11_scratch1); __ mr(R3_ARG1, R16_thread); -#if defined(ABI_ELFv2) - __ call_c(runtime_entry, relocInfo::none); -#else - __ call_c(CAST_FROM_FN_PTR(FunctionDescriptor*, runtime_entry), relocInfo::none); -#endif + __ call_c(runtime_entry); // Set an oopmap for the call site. oop_maps->add_gc_map((int)(gc_map_pc - start), map); @@ -3749,7 +3749,8 @@ void SharedRuntime::montgomery_square(jint *a_ints, jint *n_ints, // It returns a jobject handle to the event writer. // The handle is dereferenced and the return value is the event writer oop. RuntimeStub* SharedRuntime::generate_jfr_write_checkpoint() { - CodeBuffer code("jfr_write_checkpoint", 512, 64); + const char* name = SharedRuntime::stub_name(SharedStubId::jfr_write_checkpoint_id); + CodeBuffer code(name, 512, 64); MacroAssembler* masm = new MacroAssembler(&code); Register tmp1 = R10_ARG8; @@ -3777,8 +3778,7 @@ RuntimeStub* SharedRuntime::generate_jfr_write_checkpoint() { oop_maps->add_gc_map(calls_return_pc - start, map); RuntimeStub* stub = // codeBlob framesize is in words (not VMRegImpl::slot_size) - RuntimeStub::new_runtime_stub(code.name(), - &code, frame_complete, + RuntimeStub::new_runtime_stub(name, &code, frame_complete, (framesize >> (LogBytesPerWord - LogBytesPerInt)), oop_maps, false); return stub; @@ -3786,7 +3786,8 @@ RuntimeStub* SharedRuntime::generate_jfr_write_checkpoint() { // For c2: call to return a leased buffer. RuntimeStub* SharedRuntime::generate_jfr_return_lease() { - CodeBuffer code("jfr_return_lease", 512, 64); + const char* name = SharedRuntime::stub_name(SharedStubId::jfr_return_lease_id); + CodeBuffer code(name, 512, 64); MacroAssembler* masm = new MacroAssembler(&code); Register tmp1 = R10_ARG8; @@ -3812,8 +3813,7 @@ RuntimeStub* SharedRuntime::generate_jfr_return_lease() { oop_maps->add_gc_map(calls_return_pc - start, map); RuntimeStub* stub = // codeBlob framesize is in words (not VMRegImpl::slot_size) - RuntimeStub::new_runtime_stub(code.name(), - &code, frame_complete, + RuntimeStub::new_runtime_stub(name, &code, frame_complete, (framesize >> (LogBytesPerWord - LogBytesPerInt)), oop_maps, false); return stub; diff --git a/src/hotspot/cpu/ppc/stubGenerator_ppc.cpp b/src/hotspot/cpu/ppc/stubGenerator_ppc.cpp index ee3f1911e20..206c161287f 100644 --- a/src/hotspot/cpu/ppc/stubGenerator_ppc.cpp +++ b/src/hotspot/cpu/ppc/stubGenerator_ppc.cpp @@ -4587,6 +4587,30 @@ address generate_lookup_secondary_supers_table_stub(u1 super_klass_index) { return start; } + // load Method* target of MethodHandle + // R3_ARG1 = jobject receiver + // R19_method = result Method* + address generate_upcall_stub_load_target() { + + StubCodeMark mark(this, "StubRoutines", "upcall_stub_load_target"); + address start = __ pc(); + + __ resolve_global_jobject(R3_ARG1, R22_tmp2, R23_tmp3, MacroAssembler::PRESERVATION_FRAME_LR_GP_FP_REGS); + // Load target method from receiver + __ load_heap_oop(R19_method, java_lang_invoke_MethodHandle::form_offset(), R3_ARG1, + R22_tmp2, R23_tmp3, MacroAssembler::PRESERVATION_FRAME_LR_GP_FP_REGS, IS_NOT_NULL); + __ load_heap_oop(R19_method, java_lang_invoke_LambdaForm::vmentry_offset(), R19_method, + R22_tmp2, R23_tmp3, MacroAssembler::PRESERVATION_FRAME_LR_GP_FP_REGS, IS_NOT_NULL); + __ load_heap_oop(R19_method, java_lang_invoke_MemberName::method_offset(), R19_method, + R22_tmp2, R23_tmp3, MacroAssembler::PRESERVATION_FRAME_LR_GP_FP_REGS, IS_NOT_NULL); + __ ld(R19_method, java_lang_invoke_ResolvedMethodName::vmtarget_offset(), R19_method); + __ std(R19_method, in_bytes(JavaThread::callee_target_offset()), R16_thread); // just in case callee is deoptimized + + __ blr(); + + return start; + } + // Initialization void generate_initial_stubs() { // Generates all stubs and initializes the entry points @@ -4651,6 +4675,7 @@ address generate_lookup_secondary_supers_table_stub(u1 super_klass_index) { } StubRoutines::_upcall_stub_exception_handler = generate_upcall_stub_exception_handler(); + StubRoutines::_upcall_stub_load_target = generate_upcall_stub_load_target(); } void generate_compiler_stubs() { diff --git a/src/hotspot/cpu/ppc/templateInterpreterGenerator_ppc.cpp b/src/hotspot/cpu/ppc/templateInterpreterGenerator_ppc.cpp index bb746619616..cf3dd4cbd34 100644 --- a/src/hotspot/cpu/ppc/templateInterpreterGenerator_ppc.cpp +++ b/src/hotspot/cpu/ppc/templateInterpreterGenerator_ppc.cpp @@ -1078,6 +1078,7 @@ address TemplateInterpreterGenerator::generate_math_entry(AbstractInterpreter::M case Interpreter::java_lang_math_sin : runtime_entry = CAST_FROM_FN_PTR(address, SharedRuntime::dsin); break; case Interpreter::java_lang_math_cos : runtime_entry = CAST_FROM_FN_PTR(address, SharedRuntime::dcos); break; case Interpreter::java_lang_math_tan : runtime_entry = CAST_FROM_FN_PTR(address, SharedRuntime::dtan); break; + case Interpreter::java_lang_math_tanh : /* run interpreted */ break; case Interpreter::java_lang_math_abs : /* run interpreted */ break; case Interpreter::java_lang_math_sqrt : runtime_entry = CAST_FROM_FN_PTR(address, SharedRuntime::dsqrt); break; case Interpreter::java_lang_math_log : runtime_entry = CAST_FROM_FN_PTR(address, SharedRuntime::dlog); break; @@ -1464,13 +1465,7 @@ address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) { // native result across the call. No oop is present. __ mr(R3_ARG1, R16_thread); -#if defined(ABI_ELFv2) - __ call_c(CAST_FROM_FN_PTR(address, JavaThread::check_special_condition_for_native_trans), - relocInfo::none); -#else - __ call_c(CAST_FROM_FN_PTR(FunctionDescriptor*, JavaThread::check_special_condition_for_native_trans), - relocInfo::none); -#endif + __ call_c(CAST_FROM_FN_PTR(address, JavaThread::check_special_condition_for_native_trans)); __ bind(sync_check_done); diff --git a/src/hotspot/cpu/ppc/templateTable_ppc_64.cpp b/src/hotspot/cpu/ppc/templateTable_ppc_64.cpp index 0ee9348dde8..a55f30eb67d 100644 --- a/src/hotspot/cpu/ppc/templateTable_ppc_64.cpp +++ b/src/hotspot/cpu/ppc/templateTable_ppc_64.cpp @@ -2130,8 +2130,8 @@ void TemplateTable::_return(TosState state) { // Load klass of this obj. __ load_klass(Rklass, R17_tos); - __ lwz(Rklass_flags, in_bytes(Klass::access_flags_offset()), Rklass); - __ testbitdi(CCR0, R0, Rklass_flags, exact_log2(JVM_ACC_HAS_FINALIZER)); + __ lbz(Rklass_flags, in_bytes(Klass::misc_flags_offset()), Rklass); + __ testbitdi(CCR0, R0, Rklass_flags, exact_log2(KlassFlags::_misc_has_finalizer)); __ bfalse(CCR0, Lskip_register_finalizer); __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::register_finalizer), R17_tos /* obj */); diff --git a/src/hotspot/cpu/ppc/upcallLinker_ppc.cpp b/src/hotspot/cpu/ppc/upcallLinker_ppc.cpp index b60fd4f16d1..635bab900d1 100644 --- a/src/hotspot/cpu/ppc/upcallLinker_ppc.cpp +++ b/src/hotspot/cpu/ppc/upcallLinker_ppc.cpp @@ -24,6 +24,7 @@ #include "precompiled.hpp" #include "asm/macroAssembler.inline.hpp" +#include "classfile/javaClasses.hpp" #include "logging/logStream.hpp" #include "memory/resourceArea.hpp" #include "prims/upcallLinker.hpp" @@ -118,7 +119,7 @@ static void restore_callee_saved_registers(MacroAssembler* _masm, const ABIDescr static const int upcall_stub_code_base_size = 1024; static const int upcall_stub_size_per_arg = 16; // arg save & restore + move -address UpcallLinker::make_upcall_stub(jobject receiver, Method* entry, +address UpcallLinker::make_upcall_stub(jobject receiver, Symbol* signature, BasicType* out_sig_bt, int total_out_args, BasicType ret_type, jobject jabi, jobject jconv, @@ -221,7 +222,6 @@ address UpcallLinker::make_upcall_stub(jobject receiver, Method* entry, __ block_comment("{ on_entry"); __ load_const_optimized(call_target_address, CAST_FROM_FN_PTR(uint64_t, UpcallLinker::on_entry), R0); __ addi(R3_ARG1, R1_SP, frame_data_offset); - __ load_const_optimized(R4_ARG2, (intptr_t)receiver, R0); __ call_c(call_target_address); __ mr(R16_thread, R3_RET); __ block_comment("} on_entry"); @@ -236,12 +236,12 @@ address UpcallLinker::make_upcall_stub(jobject receiver, Method* entry, arg_shuffle.generate(_masm, as_VMStorage(callerSP), frame::native_abi_minframe_size, frame::jit_out_preserve_size); __ block_comment("} argument shuffle"); - __ block_comment("{ receiver "); - __ get_vm_result(R3_ARG1); - __ block_comment("} receiver "); - - __ load_const_optimized(R19_method, (intptr_t)entry); - __ std(R19_method, in_bytes(JavaThread::callee_target_offset()), R16_thread); + __ block_comment("{ load target "); + __ load_const_optimized(call_target_address, StubRoutines::upcall_stub_load_target(), R0); + __ load_const_optimized(R3_ARG1, (intptr_t)receiver, R0); + __ mtctr(call_target_address); + __ bctrl(); // loads target Method* into R19_method + __ block_comment("} load target "); __ push_cont_fastpath(); @@ -326,7 +326,7 @@ address UpcallLinker::make_upcall_stub(jobject receiver, Method* entry, #ifndef PRODUCT stringStream ss; - ss.print("upcall_stub_%s", entry->signature()->as_C_string()); + ss.print("upcall_stub_%s", signature->as_C_string()); const char* name = _masm->code_string(ss.as_string()); #else // PRODUCT const char* name = "upcall_stub"; diff --git a/src/hotspot/cpu/riscv/assembler_riscv.hpp b/src/hotspot/cpu/riscv/assembler_riscv.hpp index cba3dd919da..ad3d18fa392 100644 --- a/src/hotspot/cpu/riscv/assembler_riscv.hpp +++ b/src/hotspot/cpu/riscv/assembler_riscv.hpp @@ -46,8 +46,10 @@ class Argument { public: enum { - n_int_register_parameters_c = 8, // x10, x11, ... x17 (c_rarg0, c_rarg1, ...) - n_float_register_parameters_c = 8, // f10, f11, ... f17 (c_farg0, c_farg1, ... ) + // check more info at https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-cc.adoc + n_int_register_parameters_c = 8, // x10, x11, ... x17 (c_rarg0, c_rarg1, ...) + n_float_register_parameters_c = 8, // f10, f11, ... f17 (c_farg0, c_farg1, ... ) + n_vector_register_parameters_c = 16, // v8, v9, ... v23 n_int_register_parameters_j = 8, // x11, ... x17, x10 (j_rarg0, j_rarg1, ...) n_float_register_parameters_j = 8 // f10, f11, ... f17 (j_farg0, j_farg1, ...) @@ -143,6 +145,10 @@ constexpr Register x19_sender_sp = x19; // Sender's SP while in interpreter constexpr Register t0 = x5; constexpr Register t1 = x6; constexpr Register t2 = x7; +constexpr Register t3 = x28; +constexpr Register t4 = x29; +constexpr Register t5 = x30; +constexpr Register t6 = x31; const Register g_INTArgReg[Argument::n_int_register_parameters_c] = { c_rarg0, c_rarg1, c_rarg2, c_rarg3, c_rarg4, c_rarg5, c_rarg6, c_rarg7 @@ -705,6 +711,16 @@ public: emit(insn); } + void fencei() { + unsigned insn = 0; + patch((address)&insn, 6, 0, 0b0001111); // opcode + patch((address)&insn, 11, 7, 0b00000); // rd + patch((address)&insn, 14, 12, 0b001); // func + patch((address)&insn, 19, 15, 0b00000); // rs1 + patch((address)&insn, 31, 20, 0b000000000000); // fm + emit(insn); + } + #define INSN(NAME, op, funct3, funct7) \ void NAME() { \ unsigned insn = 0; \ @@ -1267,6 +1283,7 @@ enum VectorMask { INSN(viota_m, 0b1010111, 0b010, 0b10000, 0b010100); // Vector Single-Width Floating-Point/Integer Type-Convert Instructions + INSN(vfcvt_x_f_v, 0b1010111, 0b001, 0b00001, 0b010010); INSN(vfcvt_f_x_v, 0b1010111, 0b001, 0b00011, 0b010010); INSN(vfcvt_rtz_x_f_v, 0b1010111, 0b001, 0b00111, 0b010010); diff --git a/src/hotspot/cpu/riscv/c1_CodeStubs_riscv.cpp b/src/hotspot/cpu/riscv/c1_CodeStubs_riscv.cpp index b7e1b7863ef..fb810820726 100644 --- a/src/hotspot/cpu/riscv/c1_CodeStubs_riscv.cpp +++ b/src/hotspot/cpu/riscv/c1_CodeStubs_riscv.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, Red Hat Inc. All rights reserved. * Copyright (c) 2020, 2023, Huawei Technologies Co., Ltd. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -62,7 +62,7 @@ void CounterOverflowStub::emit_code(LIR_Assembler* ce) { __ mov_metadata(t0, m); ce->store_parameter(t0, 1); ce->store_parameter(_bci, 0); - __ far_call(RuntimeAddress(Runtime1::entry_for(Runtime1::counter_overflow_id))); + __ far_call(RuntimeAddress(Runtime1::entry_for(C1StubId::counter_overflow_id))); ce->add_call_info_here(_info); ce->verify_oop_map(_info); __ j(_continuation); @@ -71,7 +71,7 @@ void CounterOverflowStub::emit_code(LIR_Assembler* ce) { void RangeCheckStub::emit_code(LIR_Assembler* ce) { __ bind(_entry); if (_info->deoptimize_on_exception()) { - address a = Runtime1::entry_for(Runtime1::predicate_failed_trap_id); + address a = Runtime1::entry_for(C1StubId::predicate_failed_trap_id); __ far_call(RuntimeAddress(a)); ce->add_call_info_here(_info); ce->verify_oop_map(_info); @@ -84,13 +84,13 @@ void RangeCheckStub::emit_code(LIR_Assembler* ce) { } else { __ mv(t0, _index->as_jint()); } - Runtime1::StubID stub_id; + C1StubId stub_id; if (_throw_index_out_of_bounds_exception) { - stub_id = Runtime1::throw_index_exception_id; + stub_id = C1StubId::throw_index_exception_id; } else { assert(_array != LIR_Opr::nullOpr(), "sanity"); __ mv(t1, _array->as_pointer_register()); - stub_id = Runtime1::throw_range_check_failed_id; + stub_id = C1StubId::throw_range_check_failed_id; } // t0 and t1 are used as args in generate_exception_throw, // so use ra as the tmp register for rt_call. @@ -106,7 +106,7 @@ PredicateFailedStub::PredicateFailedStub(CodeEmitInfo* info) { void PredicateFailedStub::emit_code(LIR_Assembler* ce) { __ bind(_entry); - address a = Runtime1::entry_for(Runtime1::predicate_failed_trap_id); + address a = Runtime1::entry_for(C1StubId::predicate_failed_trap_id); __ far_call(RuntimeAddress(a)); ce->add_call_info_here(_info); ce->verify_oop_map(_info); @@ -118,7 +118,7 @@ void DivByZeroStub::emit_code(LIR_Assembler* ce) { ce->compilation()->implicit_exception_table()->append(_offset, __ offset()); } __ bind(_entry); - __ far_call(RuntimeAddress(Runtime1::entry_for(Runtime1::throw_div0_exception_id))); + __ far_call(RuntimeAddress(Runtime1::entry_for(C1StubId::throw_div0_exception_id))); ce->add_call_info_here(_info); ce->verify_oop_map(_info); #ifdef ASSERT @@ -127,14 +127,14 @@ void DivByZeroStub::emit_code(LIR_Assembler* ce) { } // Implementation of NewInstanceStub -NewInstanceStub::NewInstanceStub(LIR_Opr klass_reg, LIR_Opr result, ciInstanceKlass* klass, CodeEmitInfo* info, Runtime1::StubID stub_id) { +NewInstanceStub::NewInstanceStub(LIR_Opr klass_reg, LIR_Opr result, ciInstanceKlass* klass, CodeEmitInfo* info, C1StubId stub_id) { _result = result; _klass = klass; _klass_reg = klass_reg; _info = new CodeEmitInfo(info); - assert(stub_id == Runtime1::new_instance_id || - stub_id == Runtime1::fast_new_instance_id || - stub_id == Runtime1::fast_new_instance_init_check_id, + assert(stub_id == C1StubId::new_instance_id || + stub_id == C1StubId::fast_new_instance_id || + stub_id == C1StubId::fast_new_instance_init_check_id, "need new_instance id"); _stub_id = stub_id; } @@ -163,7 +163,7 @@ void NewTypeArrayStub::emit_code(LIR_Assembler* ce) { __ bind(_entry); assert(_length->as_register() == x9, "length must in x9"); assert(_klass_reg->as_register() == x13, "klass_reg must in x13"); - __ far_call(RuntimeAddress(Runtime1::entry_for(Runtime1::new_type_array_id))); + __ far_call(RuntimeAddress(Runtime1::entry_for(C1StubId::new_type_array_id))); ce->add_call_info_here(_info); ce->verify_oop_map(_info); assert(_result->as_register() == x10, "result must in x10"); @@ -183,7 +183,7 @@ void NewObjectArrayStub::emit_code(LIR_Assembler* ce) { __ bind(_entry); assert(_length->as_register() == x9, "length must in x9"); assert(_klass_reg->as_register() == x13, "klass_reg must in x13"); - __ far_call(RuntimeAddress(Runtime1::entry_for(Runtime1::new_object_array_id))); + __ far_call(RuntimeAddress(Runtime1::entry_for(C1StubId::new_object_array_id))); ce->add_call_info_here(_info); ce->verify_oop_map(_info); assert(_result->as_register() == x10, "result must in x10"); @@ -195,11 +195,11 @@ void MonitorEnterStub::emit_code(LIR_Assembler* ce) { __ bind(_entry); ce->store_parameter(_obj_reg->as_register(), 1); ce->store_parameter(_lock_reg->as_register(), 0); - Runtime1::StubID enter_id; + C1StubId enter_id; if (ce->compilation()->has_fpu_code()) { - enter_id = Runtime1::monitorenter_id; + enter_id = C1StubId::monitorenter_id; } else { - enter_id = Runtime1::monitorenter_nofpu_id; + enter_id = C1StubId::monitorenter_nofpu_id; } __ far_call(RuntimeAddress(Runtime1::entry_for(enter_id))); ce->add_call_info_here(_info); @@ -215,11 +215,11 @@ void MonitorExitStub::emit_code(LIR_Assembler* ce) { } ce->store_parameter(_lock_reg->as_register(), 0); // note: non-blocking leaf routine => no call info needed - Runtime1::StubID exit_id; + C1StubId exit_id; if (ce->compilation()->has_fpu_code()) { - exit_id = Runtime1::monitorexit_id; + exit_id = C1StubId::monitorexit_id; } else { - exit_id = Runtime1::monitorexit_nofpu_id; + exit_id = C1StubId::monitorexit_nofpu_id; } __ la(ra, _continuation); __ far_jump(RuntimeAddress(Runtime1::entry_for(exit_id))); @@ -244,7 +244,7 @@ void PatchingStub::emit_code(LIR_Assembler* ce) { void DeoptimizeStub::emit_code(LIR_Assembler* ce) { __ bind(_entry); ce->store_parameter(_trap_request, 0); - __ far_call(RuntimeAddress(Runtime1::entry_for(Runtime1::deoptimize_id))); + __ far_call(RuntimeAddress(Runtime1::entry_for(C1StubId::deoptimize_id))); ce->add_call_info_here(_info); DEBUG_ONLY(__ should_not_reach_here()); } @@ -253,9 +253,9 @@ void ImplicitNullCheckStub::emit_code(LIR_Assembler* ce) { address a = nullptr; if (_info->deoptimize_on_exception()) { // Deoptimize, do not throw the exception, because it is probably wrong to do it here. - a = Runtime1::entry_for(Runtime1::predicate_failed_trap_id); + a = Runtime1::entry_for(C1StubId::predicate_failed_trap_id); } else { - a = Runtime1::entry_for(Runtime1::throw_null_pointer_exception_id); + a = Runtime1::entry_for(C1StubId::throw_null_pointer_exception_id); } ce->compilation()->implicit_exception_table()->append(_offset, __ offset()); diff --git a/src/hotspot/cpu/riscv/c1_LIRAssembler_arraycopy_riscv.cpp b/src/hotspot/cpu/riscv/c1_LIRAssembler_arraycopy_riscv.cpp index a8f260acae8..01293218938 100644 --- a/src/hotspot/cpu/riscv/c1_LIRAssembler_arraycopy_riscv.cpp +++ b/src/hotspot/cpu/riscv/c1_LIRAssembler_arraycopy_riscv.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2020, 2022, Huawei Technologies Co., Ltd. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -223,7 +223,7 @@ void LIR_Assembler::arraycopy_type_check(Register src, Register src_pos, Registe __ check_klass_subtype_fast_path(src, dst, tmp, &cont, &slow, nullptr); PUSH(src, dst); - __ far_call(RuntimeAddress(Runtime1::entry_for(Runtime1::slow_subtype_check_id))); + __ far_call(RuntimeAddress(Runtime1::entry_for(C1StubId::slow_subtype_check_id))); POP(src, dst); __ bnez(dst, cont); diff --git a/src/hotspot/cpu/riscv/c1_LIRAssembler_riscv.cpp b/src/hotspot/cpu/riscv/c1_LIRAssembler_riscv.cpp index 3d146b87707..828f70e4dec 100644 --- a/src/hotspot/cpu/riscv/c1_LIRAssembler_riscv.cpp +++ b/src/hotspot/cpu/riscv/c1_LIRAssembler_riscv.cpp @@ -305,7 +305,7 @@ int LIR_Assembler::emit_exception_handler() { __ verify_not_null_oop(x10); // search an exception handler (x10: exception oop, x13: throwing pc) - __ far_call(RuntimeAddress(Runtime1::entry_for(Runtime1::handle_exception_from_callee_id))); + __ far_call(RuntimeAddress(Runtime1::entry_for(C1StubId::handle_exception_from_callee_id))); __ should_not_reach_here(); guarantee(code_offset() - offset <= exception_handler_size(), "overflow"); __ end_a_stub(); @@ -361,7 +361,7 @@ int LIR_Assembler::emit_unwind_handler() { // remove the activation and dispatch to the unwind handler __ block_comment("remove_frame and dispatch to the unwind handler"); __ remove_frame(initial_frame_size_in_bytes()); - __ far_jump(RuntimeAddress(Runtime1::entry_for(Runtime1::unwind_exception_id))); + __ far_jump(RuntimeAddress(Runtime1::entry_for(C1StubId::unwind_exception_id))); // Emit the slow path assembly if (stub != nullptr) { @@ -980,6 +980,7 @@ void LIR_Assembler::emit_alloc_obj(LIR_OpAllocObj* op) { if (op->init_check()) { __ lbu(t0, Address(op->klass()->as_register(), InstanceKlass::init_state_offset())); + __ membar(MacroAssembler::LoadLoad | MacroAssembler::LoadStore); __ mv(t1, (u1)InstanceKlass::fully_initialized); add_debug_info_for_null_check_here(op->stub()->info()); __ bne(t0, t1, *op->stub()->entry(), /* is_far */ true); @@ -1088,7 +1089,7 @@ void LIR_Assembler::typecheck_helper_slowcheck(ciKlass *k, Register obj, Registe __ addi(sp, sp, -2 * wordSize); // 2: store k_RInfo and klass_RInfo __ sd(k_RInfo, Address(sp, 0)); // sub klass __ sd(klass_RInfo, Address(sp, wordSize)); // super klass - __ far_call(RuntimeAddress(Runtime1::entry_for(Runtime1::slow_subtype_check_id))); + __ far_call(RuntimeAddress(Runtime1::entry_for(C1StubId::slow_subtype_check_id))); // load result to k_RInfo __ ld(k_RInfo, Address(sp, 0)); __ addi(sp, sp, 2 * wordSize); // 2: pop out k_RInfo and klass_RInfo @@ -1103,7 +1104,7 @@ void LIR_Assembler::typecheck_helper_slowcheck(ciKlass *k, Register obj, Registe __ addi(sp, sp, -2 * wordSize); // 2: store k_RInfo and klass_RInfo __ sd(klass_RInfo, Address(sp, wordSize)); // sub klass __ sd(k_RInfo, Address(sp, 0)); // super klass - __ far_call(RuntimeAddress(Runtime1::entry_for(Runtime1::slow_subtype_check_id))); + __ far_call(RuntimeAddress(Runtime1::entry_for(C1StubId::slow_subtype_check_id))); // load result to k_RInfo __ ld(k_RInfo, Address(sp, 0)); __ addi(sp, sp, 2 * wordSize); // 2: pop out k_RInfo and klass_RInfo @@ -1391,7 +1392,7 @@ void LIR_Assembler::throw_op(LIR_Opr exceptionPC, LIR_Opr exceptionOop, CodeEmit // exception object is not added to oop map by LinearScan // (LinearScan assumes that no oops are in fixed registers) info->add_register_oop(exceptionOop); - Runtime1::StubID unwind_id; + C1StubId unwind_id; // get current pc information // pc is only needed if the method has an exception handler, the unwind code does not need it. @@ -1414,9 +1415,9 @@ void LIR_Assembler::throw_op(LIR_Opr exceptionPC, LIR_Opr exceptionOop, CodeEmit __ verify_not_null_oop(x10); // search an exception handler (x10: exception oop, x13: throwing pc) if (compilation()->has_fpu_code()) { - unwind_id = Runtime1::handle_exception_id; + unwind_id = C1StubId::handle_exception_id; } else { - unwind_id = Runtime1::handle_exception_nofpu_id; + unwind_id = C1StubId::handle_exception_nofpu_id; } __ far_call(RuntimeAddress(Runtime1::entry_for(unwind_id))); __ nop(); @@ -2054,16 +2055,16 @@ void LIR_Assembler::deoptimize_trap(CodeEmitInfo *info) { switch (patching_id(info)) { case PatchingStub::access_field_id: - target = Runtime1::entry_for(Runtime1::access_field_patching_id); + target = Runtime1::entry_for(C1StubId::access_field_patching_id); break; case PatchingStub::load_klass_id: - target = Runtime1::entry_for(Runtime1::load_klass_patching_id); + target = Runtime1::entry_for(C1StubId::load_klass_patching_id); break; case PatchingStub::load_mirror_id: - target = Runtime1::entry_for(Runtime1::load_mirror_patching_id); + target = Runtime1::entry_for(C1StubId::load_mirror_patching_id); break; case PatchingStub::load_appendix_id: - target = Runtime1::entry_for(Runtime1::load_appendix_patching_id); + target = Runtime1::entry_for(C1StubId::load_appendix_patching_id); break; default: ShouldNotReachHere(); } @@ -2152,7 +2153,7 @@ void LIR_Assembler::lir_store_slowcheck(Register k_RInfo, Register klass_RInfo, __ addi(sp, sp, -2 * wordSize); // 2: store k_RInfo and klass_RInfo __ sd(klass_RInfo, Address(sp, wordSize)); // sub klass __ sd(k_RInfo, Address(sp, 0)); // super klass - __ far_call(RuntimeAddress(Runtime1::entry_for(Runtime1::slow_subtype_check_id))); + __ far_call(RuntimeAddress(Runtime1::entry_for(C1StubId::slow_subtype_check_id))); // load result to k_RInfo __ ld(k_RInfo, Address(sp, 0)); __ addi(sp, sp, 2 * wordSize); // 2: pop out k_RInfo and klass_RInfo diff --git a/src/hotspot/cpu/riscv/c1_LIRGenerator_riscv.cpp b/src/hotspot/cpu/riscv/c1_LIRGenerator_riscv.cpp index 409e8dc0a0d..b328d457192 100644 --- a/src/hotspot/cpu/riscv/c1_LIRGenerator_riscv.cpp +++ b/src/hotspot/cpu/riscv/c1_LIRGenerator_riscv.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, Red Hat Inc. All rights reserved. * Copyright (c) 2020, 2022, Huawei Technologies Co., Ltd. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -1030,7 +1030,7 @@ void LIRGenerator::do_NewMultiArray(NewMultiArray* x) { args->append(rank); args->append(varargs); LIR_Opr reg = result_register_for(x->type()); - __ call_runtime(Runtime1::entry_for(Runtime1::new_multi_array_id), + __ call_runtime(Runtime1::entry_for(C1StubId::new_multi_array_id), LIR_OprFact::illegalOpr, reg, args, info); @@ -1062,7 +1062,7 @@ void LIRGenerator::do_CheckCast(CheckCast* x) { CodeStub* stub = nullptr; if (x->is_incompatible_class_change_check()) { assert(patching_info == nullptr, "can't patch this"); - stub = new SimpleExceptionStub(Runtime1::throw_incompatible_class_change_error_id, LIR_OprFact::illegalOpr, + stub = new SimpleExceptionStub(C1StubId::throw_incompatible_class_change_error_id, LIR_OprFact::illegalOpr, info_for_exception); } else if (x->is_invokespecial_receiver_check()) { assert(patching_info == nullptr, "can't patch this"); @@ -1070,7 +1070,7 @@ void LIRGenerator::do_CheckCast(CheckCast* x) { Deoptimization::Reason_class_check, Deoptimization::Action_none); } else { - stub = new SimpleExceptionStub(Runtime1::throw_class_cast_exception_id, obj.result(), info_for_exception); + stub = new SimpleExceptionStub(C1StubId::throw_class_cast_exception_id, obj.result(), info_for_exception); } LIR_Opr reg = rlock_result(x); LIR_Opr tmp3 = LIR_OprFact::illegalOpr; diff --git a/src/hotspot/cpu/riscv/c1_MacroAssembler_riscv.cpp b/src/hotspot/cpu/riscv/c1_MacroAssembler_riscv.cpp index dc1a3d443ac..1e4b66069ee 100644 --- a/src/hotspot/cpu/riscv/c1_MacroAssembler_riscv.cpp +++ b/src/hotspot/cpu/riscv/c1_MacroAssembler_riscv.cpp @@ -64,8 +64,8 @@ int C1_MacroAssembler::lock_object(Register hdr, Register obj, Register disp_hdr if (DiagnoseSyncOnValueBasedClasses != 0) { load_klass(hdr, obj); - lwu(hdr, Address(hdr, Klass::access_flags_offset())); - test_bit(temp, hdr, exact_log2(JVM_ACC_IS_VALUE_BASED_CLASS)); + lbu(hdr, Address(hdr, Klass::misc_flags_offset())); + test_bit(temp, hdr, exact_log2(KlassFlags::_misc_is_value_based_class)); bnez(temp, slow_case, true /* is_far */); } @@ -276,7 +276,7 @@ void C1_MacroAssembler::initialize_object(Register obj, Register klass, Register if (CURRENT_ENV->dtrace_alloc_probes()) { assert(obj == x10, "must be"); - far_call(RuntimeAddress(Runtime1::entry_for(Runtime1::dtrace_object_alloc_id))); + far_call(RuntimeAddress(Runtime1::entry_for(C1StubId::dtrace_object_alloc_id))); } verify_oop(obj); @@ -316,7 +316,7 @@ void C1_MacroAssembler::allocate_array(Register obj, Register len, Register tmp1 if (CURRENT_ENV->dtrace_alloc_probes()) { assert(obj == x10, "must be"); - far_call(RuntimeAddress(Runtime1::entry_for(Runtime1::dtrace_object_alloc_id))); + far_call(RuntimeAddress(Runtime1::entry_for(C1StubId::dtrace_object_alloc_id))); } verify_oop(obj); diff --git a/src/hotspot/cpu/riscv/c1_Runtime1_riscv.cpp b/src/hotspot/cpu/riscv/c1_Runtime1_riscv.cpp index 74f303ffb02..5e4031727c8 100644 --- a/src/hotspot/cpu/riscv/c1_Runtime1_riscv.cpp +++ b/src/hotspot/cpu/riscv/c1_Runtime1_riscv.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, Red Hat Inc. All rights reserved. * Copyright (c) 2020, 2023, Huawei Technologies Co., Ltd. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -98,10 +98,10 @@ int StubAssembler::call_RT(Register oop_result, Register metadata_result, addres if (frame_size() == no_frame_size) { leave(); far_jump(RuntimeAddress(StubRoutines::forward_exception_entry())); - } else if (_stub_id == Runtime1::forward_exception_id) { + } else if (_stub_id == (int)C1StubId::forward_exception_id) { should_not_reach_here(); } else { - far_jump(RuntimeAddress(Runtime1::entry_for(Runtime1::forward_exception_id))); + far_jump(RuntimeAddress(Runtime1::entry_for(C1StubId::forward_exception_id))); } bind(L); } @@ -376,7 +376,7 @@ OopMapSet* Runtime1::generate_exception_throw(StubAssembler* sasm, address targe return oop_maps; } -OopMapSet* Runtime1::generate_handle_exception(StubID id, StubAssembler *sasm) { +OopMapSet* Runtime1::generate_handle_exception(C1StubId id, StubAssembler *sasm) { __ block_comment("generate_handle_exception"); // incoming parameters @@ -388,7 +388,7 @@ OopMapSet* Runtime1::generate_handle_exception(StubID id, StubAssembler *sasm) { OopMap* oop_map = nullptr; switch (id) { - case forward_exception_id: + case C1StubId::forward_exception_id: // We're handling an exception in the context of a compiled frame. // The registers have been saved in the standard places. Perform // an exception lookup in the caller and dispatch to the handler @@ -407,12 +407,12 @@ OopMapSet* Runtime1::generate_handle_exception(StubID id, StubAssembler *sasm) { __ sd(zr, Address(xthread, JavaThread::vm_result_offset())); __ sd(zr, Address(xthread, JavaThread::vm_result_2_offset())); break; - case handle_exception_nofpu_id: - case handle_exception_id: + case C1StubId::handle_exception_nofpu_id: + case C1StubId::handle_exception_id: // At this point all registers MAY be live. - oop_map = save_live_registers(sasm, id != handle_exception_nofpu_id); + oop_map = save_live_registers(sasm, id != C1StubId::handle_exception_nofpu_id); break; - case handle_exception_from_callee_id: { + case C1StubId::handle_exception_from_callee_id: { // At this point all registers except exception oop (x10) and // exception pc (ra) are dead. const int frame_size = 2 /* fp, return address */; @@ -469,13 +469,13 @@ OopMapSet* Runtime1::generate_handle_exception(StubID id, StubAssembler *sasm) { __ sd(x10, Address(fp, frame::return_addr_offset * BytesPerWord)); switch (id) { - case forward_exception_id: - case handle_exception_nofpu_id: - case handle_exception_id: + case C1StubId::forward_exception_id: + case C1StubId::handle_exception_nofpu_id: + case C1StubId::handle_exception_id: // Restore the registers that were saved at the beginning. - restore_live_registers(sasm, id != handle_exception_nofpu_id); + restore_live_registers(sasm, id != C1StubId::handle_exception_nofpu_id); break; - case handle_exception_from_callee_id: + case C1StubId::handle_exception_from_callee_id: break; default: ShouldNotReachHere(); } @@ -621,7 +621,7 @@ OopMapSet* Runtime1::generate_patching(StubAssembler* sasm, address target) { return oop_maps; } -OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { +OopMapSet* Runtime1::generate_code_for(C1StubId id, StubAssembler* sasm) { // for better readability const bool dont_gc_arguments = false; @@ -632,7 +632,7 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { OopMapSet* oop_maps = nullptr; switch (id) { { - case forward_exception_id: + case C1StubId::forward_exception_id: { oop_maps = generate_handle_exception(id, sasm); __ leave(); @@ -640,32 +640,32 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case throw_div0_exception_id: + case C1StubId::throw_div0_exception_id: { StubFrame f(sasm, "throw_div0_exception", dont_gc_arguments, does_not_return); oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_div0_exception), false); } break; - case throw_null_pointer_exception_id: + case C1StubId::throw_null_pointer_exception_id: { StubFrame f(sasm, "throw_null_pointer_exception", dont_gc_arguments, does_not_return); oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_null_pointer_exception), false); } break; - case new_instance_id: - case fast_new_instance_id: - case fast_new_instance_init_check_id: + case C1StubId::new_instance_id: + case C1StubId::fast_new_instance_id: + case C1StubId::fast_new_instance_init_check_id: { Register klass = x13; // Incoming Register obj = x10; // Result - if (id == new_instance_id) { + if (id == C1StubId::new_instance_id) { __ set_info("new_instance", dont_gc_arguments); - } else if (id == fast_new_instance_id) { + } else if (id == C1StubId::fast_new_instance_id) { __ set_info("fast new_instance", dont_gc_arguments); } else { - assert(id == fast_new_instance_init_check_id, "bad StubID"); + assert(id == C1StubId::fast_new_instance_init_check_id, "bad C1StubId"); __ set_info("fast new_instance init check", dont_gc_arguments); } @@ -686,7 +686,7 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { break; - case counter_overflow_id: + case C1StubId::counter_overflow_id: { Register bci = x10; Register method = x11; @@ -710,14 +710,14 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case new_type_array_id: - case new_object_array_id: + case C1StubId::new_type_array_id: + case C1StubId::new_object_array_id: { Register length = x9; // Incoming Register klass = x13; // Incoming Register obj = x10; // Result - if (id == new_type_array_id) { + if (id == C1StubId::new_type_array_id) { __ set_info("new_type_array", dont_gc_arguments); } else { __ set_info("new_object_array", dont_gc_arguments); @@ -730,7 +730,7 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { Register tmp = obj; __ lwu(tmp, Address(klass, Klass::layout_helper_offset())); __ sraiw(tmp, tmp, Klass::_lh_array_tag_shift); - int tag = ((id == new_type_array_id) ? Klass::_lh_array_tag_type_value : Klass::_lh_array_tag_obj_value); + int tag = ((id == C1StubId::new_type_array_id) ? Klass::_lh_array_tag_type_value : Klass::_lh_array_tag_obj_value); __ mv(t0, tag); __ beq(t0, tmp, ok); __ stop("assert(is an array klass)"); @@ -743,7 +743,7 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { OopMap* map = save_live_registers(sasm); assert_cond(map != nullptr); int call_offset = 0; - if (id == new_type_array_id) { + if (id == C1StubId::new_type_array_id) { call_offset = __ call_RT(obj, noreg, CAST_FROM_FN_PTR(address, new_type_array), klass, length); } else { call_offset = __ call_RT(obj, noreg, CAST_FROM_FN_PTR(address, new_object_array), klass, length); @@ -762,7 +762,7 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case new_multi_array_id: + case C1StubId::new_multi_array_id: { StubFrame f(sasm, "new_multi_array", dont_gc_arguments); // x10: klass @@ -785,7 +785,7 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case register_finalizer_id: + case C1StubId::register_finalizer_id: { __ set_info("register_finalizer", dont_gc_arguments); @@ -797,8 +797,8 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { Label register_finalizer; Register t = x15; __ load_klass(t, x10); - __ lwu(t, Address(t, Klass::access_flags_offset())); - __ test_bit(t0, t, exact_log2(JVM_ACC_HAS_FINALIZER)); + __ lbu(t, Address(t, Klass::misc_flags_offset())); + __ test_bit(t0, t, exact_log2(KlassFlags::_misc_has_finalizer)); __ bnez(t0, register_finalizer); __ ret(); @@ -819,14 +819,14 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case throw_class_cast_exception_id: + case C1StubId::throw_class_cast_exception_id: { StubFrame f(sasm, "throw_class_cast_exception", dont_gc_arguments, does_not_return); oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_class_cast_exception), true); } break; - case throw_incompatible_class_change_error_id: + case C1StubId::throw_incompatible_class_change_error_id: { StubFrame f(sasm, "throw_incompatible_class_cast_exception", dont_gc_arguments, does_not_return); oop_maps = generate_exception_throw(sasm, @@ -834,7 +834,7 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case slow_subtype_check_id: + case C1StubId::slow_subtype_check_id: { // Typical calling sequence: // push klass_RInfo (object klass or other subclass) @@ -874,10 +874,10 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case monitorenter_nofpu_id: + case C1StubId::monitorenter_nofpu_id: save_fpu_registers = false; // fall through - case monitorenter_id: + case C1StubId::monitorenter_id: { StubFrame f(sasm, "monitorenter", dont_gc_arguments); OopMap* map = save_live_registers(sasm, save_fpu_registers); @@ -896,10 +896,10 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case monitorexit_nofpu_id: + case C1StubId::monitorexit_nofpu_id: save_fpu_registers = false; // fall through - case monitorexit_id: + case C1StubId::monitorexit_id: { StubFrame f(sasm, "monitorexit", dont_gc_arguments); OopMap* map = save_live_registers(sasm, save_fpu_registers); @@ -920,7 +920,7 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case deoptimize_id: + case C1StubId::deoptimize_id: { StubFrame f(sasm, "deoptimize", dont_gc_arguments, does_not_return); OopMap* oop_map = save_live_registers(sasm); @@ -939,14 +939,14 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case throw_range_check_failed_id: + case C1StubId::throw_range_check_failed_id: { StubFrame f(sasm, "range_check_failed", dont_gc_arguments, does_not_return); oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_range_check_exception), true); } break; - case unwind_exception_id: + case C1StubId::unwind_exception_id: { __ set_info("unwind_exception", dont_gc_arguments); // note: no stubframe since we are about to leave the current @@ -955,7 +955,7 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case access_field_patching_id: + case C1StubId::access_field_patching_id: { StubFrame f(sasm, "access_field_patching", dont_gc_arguments, does_not_return); // we should set up register map @@ -963,7 +963,7 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case load_klass_patching_id: + case C1StubId::load_klass_patching_id: { StubFrame f(sasm, "load_klass_patching", dont_gc_arguments, does_not_return); // we should set up register map @@ -971,7 +971,7 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case load_mirror_patching_id: + case C1StubId::load_mirror_patching_id: { StubFrame f(sasm, "load_mirror_patching", dont_gc_arguments, does_not_return); // we should set up register map @@ -979,7 +979,7 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case load_appendix_patching_id: + case C1StubId::load_appendix_patching_id: { StubFrame f(sasm, "load_appendix_patching", dont_gc_arguments, does_not_return); // we should set up register map @@ -987,29 +987,29 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case handle_exception_nofpu_id: - case handle_exception_id: + case C1StubId::handle_exception_nofpu_id: + case C1StubId::handle_exception_id: { StubFrame f(sasm, "handle_exception", dont_gc_arguments); oop_maps = generate_handle_exception(id, sasm); } break; - case handle_exception_from_callee_id: + case C1StubId::handle_exception_from_callee_id: { StubFrame f(sasm, "handle_exception_from_callee", dont_gc_arguments); oop_maps = generate_handle_exception(id, sasm); } break; - case throw_index_exception_id: + case C1StubId::throw_index_exception_id: { StubFrame f(sasm, "index_range_check_failed", dont_gc_arguments, does_not_return); oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_index_exception), true); } break; - case throw_array_store_exception_id: + case C1StubId::throw_array_store_exception_id: { StubFrame f(sasm, "throw_array_store_exception", dont_gc_arguments, does_not_return); // tos + 0: link @@ -1018,7 +1018,7 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case predicate_failed_trap_id: + case C1StubId::predicate_failed_trap_id: { StubFrame f(sasm, "predicate_failed_trap", dont_gc_arguments, does_not_return); @@ -1038,7 +1038,7 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case dtrace_object_alloc_id: + case C1StubId::dtrace_object_alloc_id: { // c_rarg0: object StubFrame f(sasm, "dtrace_object_alloc", dont_gc_arguments); save_live_registers(sasm); diff --git a/src/hotspot/cpu/riscv/c2_CodeStubs_riscv.cpp b/src/hotspot/cpu/riscv/c2_CodeStubs_riscv.cpp index 7995750aba9..db18525b89c 100644 --- a/src/hotspot/cpu/riscv/c2_CodeStubs_riscv.cpp +++ b/src/hotspot/cpu/riscv/c2_CodeStubs_riscv.cpp @@ -71,32 +71,4 @@ void C2EntryBarrierStub::emit(C2_MacroAssembler& masm) { __ emit_int32(0); // nmethod guard value } -int C2HandleAnonOMOwnerStub::max_size() const { - // Max size of stub has been determined by testing with 0 without using RISC-V compressed - // instruction-set extension, in which case C2CodeStubList::emit() will throw an assertion - // and report the actual size that is needed. - return 20 DEBUG_ONLY(+8); -} - -void C2HandleAnonOMOwnerStub::emit(C2_MacroAssembler& masm) { - __ bind(entry()); - Register mon = monitor(); - Register t = tmp(); - assert(t != noreg, "need tmp register"); - - // Fix owner to be the current thread. - __ sd(xthread, Address(mon, ObjectMonitor::owner_offset())); - - // Pop owner object from lock-stack. - __ lwu(t, Address(xthread, JavaThread::lock_stack_top_offset())); - __ subw(t, t, oopSize); -#ifdef ASSERT - __ add(t0, xthread, t); - __ sd(zr, Address(t0, 0)); -#endif - __ sw(t, Address(xthread, JavaThread::lock_stack_top_offset())); - - __ j(continuation()); -} - #undef __ diff --git a/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp b/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp index a75bfdfc9dc..75f87e35adf 100644 --- a/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp +++ b/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp @@ -68,8 +68,8 @@ void C2_MacroAssembler::fast_lock(Register objectReg, Register boxReg, if (DiagnoseSyncOnValueBasedClasses != 0) { load_klass(tmp, oop); - lwu(tmp, Address(tmp, Klass::access_flags_offset())); - test_bit(tmp, tmp, exact_log2(JVM_ACC_IS_VALUE_BASED_CLASS)); + lbu(tmp, Address(tmp, Klass::misc_flags_offset())); + test_bit(tmp, tmp, exact_log2(KlassFlags::_misc_is_value_based_class)); bnez(tmp, slow_path); } @@ -165,6 +165,7 @@ void C2_MacroAssembler::fast_unlock(Register objectReg, Register boxReg, Register oop = objectReg; Register box = boxReg; Register disp_hdr = tmp1Reg; + Register owner_addr = tmp1Reg; Register tmp = tmp2Reg; Label object_has_monitor; // Finish fast lock successfully. MUST branch to with flag == 0 @@ -222,15 +223,33 @@ void C2_MacroAssembler::fast_unlock(Register objectReg, Register boxReg, j(unlocked); bind(notRecursive); - ld(t0, Address(tmp, ObjectMonitor::EntryList_offset())); - ld(disp_hdr, Address(tmp, ObjectMonitor::cxq_offset())); - orr(t0, t0, disp_hdr); // Will be 0 if both are 0. - bnez(t0, slow_path); + // Compute owner address. + la(owner_addr, Address(tmp, ObjectMonitor::owner_offset())); - // need a release store here - la(tmp, Address(tmp, ObjectMonitor::owner_offset())); + // Set owner to null. + // Release to satisfy the JMM membar(MacroAssembler::LoadStore | MacroAssembler::StoreStore); - sd(zr, Address(tmp)); // set unowned + sd(zr, Address(owner_addr)); + // We need a full fence after clearing owner to avoid stranding. + // StoreLoad achieves this. + membar(StoreLoad); + + // Check if the entry lists are empty. + ld(t0, Address(tmp, ObjectMonitor::EntryList_offset())); + ld(tmp1Reg, Address(tmp, ObjectMonitor::cxq_offset())); + orr(t0, t0, tmp1Reg); + beqz(t0, unlocked); // If so we are done. + + // Check if there is a successor. + ld(t0, Address(tmp, ObjectMonitor::succ_offset())); + bnez(t0, unlocked); // If so we are done. + + // Save the monitor pointer in the current thread, so we can try to + // reacquire the lock in SharedRuntime::monitor_exit_helper(). + sd(tmp, Address(xthread, JavaThread::unlocked_inflated_monitor_offset())); + + mv(flag, 1); + j(slow_path); bind(unlocked); mv(flag, zr); @@ -277,8 +296,8 @@ void C2_MacroAssembler::fast_lock_lightweight(Register obj, Register box, if (DiagnoseSyncOnValueBasedClasses != 0) { load_klass(tmp1, obj); - lwu(tmp1, Address(tmp1, Klass::access_flags_offset())); - test_bit(tmp1, tmp1, exact_log2(JVM_ACC_IS_VALUE_BASED_CLASS)); + lbu(tmp1, Address(tmp1, Klass::misc_flags_offset())); + test_bit(tmp1, tmp1, exact_log2(KlassFlags::_misc_is_value_based_class)); bnez(tmp1, slow_path); } @@ -534,28 +553,35 @@ void C2_MacroAssembler::fast_unlock_lightweight(Register obj, Register box, bind(not_recursive); - Label release; const Register tmp2_owner_addr = tmp2; // Compute owner address. la(tmp2_owner_addr, Address(tmp1_monitor, ObjectMonitor::owner_offset())); + // Set owner to null. + // Release to satisfy the JMM + membar(MacroAssembler::LoadStore | MacroAssembler::StoreStore); + sd(zr, Address(tmp2_owner_addr)); + // We need a full fence after clearing owner to avoid stranding. + // StoreLoad achieves this. + membar(StoreLoad); + // Check if the entry lists are empty. ld(t0, Address(tmp1_monitor, ObjectMonitor::EntryList_offset())); ld(tmp3_t, Address(tmp1_monitor, ObjectMonitor::cxq_offset())); orr(t0, t0, tmp3_t); - beqz(t0, release); + beqz(t0, unlocked); // If so we are done. - // The owner may be anonymous and we removed the last obj entry in - // the lock-stack. This loses the information about the owner. - // Write the thread to the owner field so the runtime knows the owner. - sd(xthread, Address(tmp2_owner_addr)); + // Check if there is a successor. + ld(tmp3_t, Address(tmp1_monitor, ObjectMonitor::succ_offset())); + bnez(tmp3_t, unlocked); // If so we are done. + + // Save the monitor pointer in the current thread, so we can try + // to reacquire the lock in SharedRuntime::monitor_exit_helper(). + sd(tmp1_monitor, Address(xthread, JavaThread::unlocked_inflated_monitor_offset())); + + mv(flag, 1); j(slow_path); - - bind(release); - // Set owner to null. - membar(MacroAssembler::LoadStore | MacroAssembler::StoreStore); - sd(zr, Address(tmp2_owner_addr)); } bind(unlocked); @@ -2385,6 +2411,74 @@ void C2_MacroAssembler::expand_bits_l_v(Register dst, Register src, Register mas expand_bits_v(dst, src, mask, /* is_long */ true); } +// j.l.Math.round(float) +// Returns the closest int to the argument, with ties rounding to positive infinity. +// We need to handle 3 special cases defined by java api spec: +// NaN, +// float >= Integer.MAX_VALUE, +// float <= Integer.MIN_VALUE. +void C2_MacroAssembler::java_round_float_v(VectorRegister dst, VectorRegister src, FloatRegister ftmp, + BasicType bt, uint vector_length) { + // In riscv, there is no straight corresponding rounding mode to satisfy the behaviour defined, + // in java api spec, i.e. any rounding mode can not handle some corner cases, e.g. + // RNE is the closest one, but it ties to "even", which means 1.5/2.5 both will be converted + // to 2, instead of 2 and 3 respectively. + // RUP does not work either, although java api requires "rounding to positive infinity", + // but both 1.3/1.8 will be converted to 2, instead of 1 and 2 respectively. + // + // The optimal solution for non-NaN cases is: + // src+0.5 => dst, with rdn rounding mode, + // convert dst from float to int, with rnd rounding mode. + // and, this solution works as expected for float >= Integer.MAX_VALUE and float <= Integer.MIN_VALUE. + // + // But, we still need to handle NaN explicilty with vector mask instructions. + // + // Check MacroAssembler::java_round_float and C2_MacroAssembler::vector_round_sve in aarch64 for more details. + + csrwi(CSR_FRM, C2_MacroAssembler::rdn); + vsetvli_helper(bt, vector_length); + + // don't rearrage the instructions sequence order without performance testing. + // check MacroAssembler::java_round_float in riscv64 for more details. + mv(t0, jint_cast(0.5f)); + fmv_w_x(ftmp, t0); + + // replacing vfclass with feq as performance optimization + vmfeq_vv(v0, src, src); + // set dst = 0 in cases of NaN + vmv_v_x(dst, zr); + + // dst = (src + 0.5) rounded down towards negative infinity + vfadd_vf(dst, src, ftmp, Assembler::v0_t); + vfcvt_x_f_v(dst, dst, Assembler::v0_t); // in RoundingMode::rdn + + csrwi(CSR_FRM, C2_MacroAssembler::rne); +} + +// java.lang.Math.round(double a) +// Returns the closest long to the argument, with ties rounding to positive infinity. +void C2_MacroAssembler::java_round_double_v(VectorRegister dst, VectorRegister src, FloatRegister ftmp, + BasicType bt, uint vector_length) { + // check C2_MacroAssembler::java_round_float_v above for more details. + + csrwi(CSR_FRM, C2_MacroAssembler::rdn); + vsetvli_helper(bt, vector_length); + + mv(t0, julong_cast(0.5)); + fmv_d_x(ftmp, t0); + + // replacing vfclass with feq as performance optimization + vmfeq_vv(v0, src, src); + // set dst = 0 in cases of NaN + vmv_v_x(dst, zr); + + // dst = (src + 0.5) rounded down towards negative infinity + vfadd_vf(dst, src, ftmp, Assembler::v0_t); + vfcvt_x_f_v(dst, dst, Assembler::v0_t); // in RoundingMode::rdn + + csrwi(CSR_FRM, C2_MacroAssembler::rne); +} + void C2_MacroAssembler::element_compare(Register a1, Register a2, Register result, Register cnt, Register tmp1, Register tmp2, VectorRegister vr1, VectorRegister vr2, VectorRegister vrs, bool islatin, Label &DONE, Assembler::LMUL lmul) { diff --git a/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.hpp b/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.hpp index 4d7f756923c..38351565cc6 100644 --- a/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.hpp +++ b/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.hpp @@ -187,6 +187,9 @@ void expand_bits_i_v(Register dst, Register src, Register mask); void expand_bits_l_v(Register dst, Register src, Register mask); + void java_round_float_v(VectorRegister dst, VectorRegister src, FloatRegister ftmp, BasicType bt, uint vector_length); + void java_round_double_v(VectorRegister dst, VectorRegister src, FloatRegister ftmp, BasicType bt, uint vector_length); + void float16_to_float_v(VectorRegister dst, VectorRegister src, uint vector_length); void float_to_float16_v(VectorRegister dst, VectorRegister src, VectorRegister vtmp, Register tmp, uint vector_length); diff --git a/src/hotspot/cpu/riscv/gc/g1/g1BarrierSetAssembler_riscv.cpp b/src/hotspot/cpu/riscv/gc/g1/g1BarrierSetAssembler_riscv.cpp index 062f8029062..7036c44d99d 100644 --- a/src/hotspot/cpu/riscv/gc/g1/g1BarrierSetAssembler_riscv.cpp +++ b/src/hotspot/cpu/riscv/gc/g1/g1BarrierSetAssembler_riscv.cpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2020, 2023, Huawei Technologies Co., Ltd. All rights reserved. + * Copyright (c) 2020, 2024, Huawei Technologies Co., Ltd. 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 @@ -39,7 +39,10 @@ #include "c1/c1_LIRAssembler.hpp" #include "c1/c1_MacroAssembler.hpp" #include "gc/g1/c1/g1BarrierSetC1.hpp" -#endif +#endif // COMPILER1 +#ifdef COMPILER2 +#include "gc/g1/c2/g1BarrierSetC2.hpp" +#endif // COMPILER2 #define __ masm-> @@ -96,6 +99,55 @@ void G1BarrierSetAssembler::gen_write_ref_array_post_barrier(MacroAssembler* mas __ pop_reg(saved_regs, sp); } +static void generate_queue_test_and_insertion(MacroAssembler* masm, ByteSize index_offset, ByteSize buffer_offset, Label& runtime, + const Register thread, const Register value, const Register tmp1, const Register tmp2) { + // Can we store a value in the given thread's buffer? + // (The index field is typed as size_t.) + __ ld(tmp1, Address(thread, in_bytes(index_offset))); // tmp1 := *(index address) + __ beqz(tmp1, runtime); // jump to runtime if index == 0 (full buffer) + // The buffer is not full, store value into it. + __ sub(tmp1, tmp1, wordSize); // tmp1 := next index + __ sd(tmp1, Address(thread, in_bytes(index_offset))); // *(index address) := next index + __ ld(tmp2, Address(thread, in_bytes(buffer_offset))); // tmp2 := buffer address + __ add(tmp2, tmp2, tmp1); + __ sd(value, Address(tmp2)); // *(buffer address + next index) := value +} + +static void generate_pre_barrier_fast_path(MacroAssembler* masm, + const Register thread, + const Register tmp1) { + Address in_progress(thread, in_bytes(G1ThreadLocalData::satb_mark_queue_active_offset())); + // Is marking active? + if (in_bytes(SATBMarkQueue::byte_width_of_active()) == 4) { + __ lwu(tmp1, in_progress); + } else { + assert(in_bytes(SATBMarkQueue::byte_width_of_active()) == 1, "Assumption"); + __ lbu(tmp1, in_progress); + } +} + +static void generate_pre_barrier_slow_path(MacroAssembler* masm, + const Register obj, + const Register pre_val, + const Register thread, + const Register tmp1, + const Register tmp2, + Label& done, + Label& runtime) { + // Do we need to load the previous value? + if (obj != noreg) { + __ load_heap_oop(pre_val, Address(obj, 0), noreg, noreg, AS_RAW); + } + // Is the previous value null? + __ beqz(pre_val, done, true); + generate_queue_test_and_insertion(masm, + G1ThreadLocalData::satb_mark_queue_index_offset(), + G1ThreadLocalData::satb_mark_queue_buffer_offset(), + runtime, + thread, pre_val, tmp1, tmp2); + __ j(done); +} + void G1BarrierSetAssembler::g1_write_barrier_pre(MacroAssembler* masm, Register obj, Register pre_val, @@ -116,43 +168,10 @@ void G1BarrierSetAssembler::g1_write_barrier_pre(MacroAssembler* masm, assert_different_registers(obj, pre_val, tmp1, tmp2); assert(pre_val != noreg && tmp1 != noreg && tmp2 != noreg, "expecting a register"); - Address in_progress(thread, in_bytes(G1ThreadLocalData::satb_mark_queue_active_offset())); - Address index(thread, in_bytes(G1ThreadLocalData::satb_mark_queue_index_offset())); - Address buffer(thread, in_bytes(G1ThreadLocalData::satb_mark_queue_buffer_offset())); - - // Is marking active? - if (in_bytes(SATBMarkQueue::byte_width_of_active()) == 4) { // 4-byte width - __ lwu(tmp1, in_progress); - } else { - assert(in_bytes(SATBMarkQueue::byte_width_of_active()) == 1, "Assumption"); - __ lbu(tmp1, in_progress); - } + generate_pre_barrier_fast_path(masm, thread, tmp1); + // If marking is not active (*(mark queue active address) == 0), jump to done __ beqz(tmp1, done); - - // Do we need to load the previous value? - if (obj != noreg) { - __ load_heap_oop(pre_val, Address(obj, 0), noreg, noreg, AS_RAW); - } - - // Is the previous value null? - __ beqz(pre_val, done); - - // Can we store original value in the thread's buffer? - // Is index == 0? - // (The index field is typed as size_t.) - - __ ld(tmp1, index); // tmp := *index_adr - __ beqz(tmp1, runtime); // tmp == 0? - // If yes, goto runtime - - __ sub(tmp1, tmp1, wordSize); // tmp := tmp - wordSize - __ sd(tmp1, index); // *index_adr := tmp - __ ld(tmp2, buffer); - __ add(tmp1, tmp1, tmp2); // tmp := tmp + *buffer_adr - - // Record the previous value - __ sd(pre_val, Address(tmp1, 0)); - __ j(done); + generate_pre_barrier_slow_path(masm, obj, pre_val, thread, tmp1, tmp2, done, runtime); __ bind(runtime); @@ -171,6 +190,49 @@ void G1BarrierSetAssembler::g1_write_barrier_pre(MacroAssembler* masm, } +static void generate_post_barrier_fast_path(MacroAssembler* masm, + const Register store_addr, + const Register new_val, + const Register tmp1, + const Register tmp2, + Label& done, + bool new_val_may_be_null) { + // Does store cross heap regions? + __ xorr(tmp1, store_addr, new_val); // tmp1 := store address ^ new value + __ srli(tmp1, tmp1, G1HeapRegion::LogOfHRGrainBytes); // tmp1 := ((store address ^ new value) >> LogOfHRGrainBytes) + __ beqz(tmp1, done); + // Crosses regions, storing null? + if (new_val_may_be_null) { + __ beqz(new_val, done); + } + // Storing region crossing non-null, is card young? + __ srli(tmp1, store_addr, CardTable::card_shift()); // tmp1 := card address relative to card table base + __ load_byte_map_base(tmp2); // tmp2 := card table base address + __ add(tmp1, tmp1, tmp2); // tmp1 := card address + __ lbu(tmp2, Address(tmp1)); // tmp2 := card +} + +static void generate_post_barrier_slow_path(MacroAssembler* masm, + const Register thread, + const Register tmp1, + const Register tmp2, + Label& done, + Label& runtime) { + __ membar(MacroAssembler::StoreLoad); // StoreLoad membar + __ lbu(tmp2, Address(tmp1)); // tmp2 := card + __ beqz(tmp2, done, true); + // Storing a region crossing, non-null oop, card is clean. + // Dirty card and log. + STATIC_ASSERT(CardTable::dirty_card_val() == 0); + __ sb(zr, Address(tmp1)); // *(card address) := dirty_card_val + generate_queue_test_and_insertion(masm, + G1ThreadLocalData::dirty_card_queue_index_offset(), + G1ThreadLocalData::dirty_card_queue_buffer_offset(), + runtime, + thread, tmp1, tmp2, t0); + __ j(done); +} + void G1BarrierSetAssembler::g1_write_barrier_post(MacroAssembler* masm, Register store_addr, Register new_val, @@ -179,73 +241,119 @@ void G1BarrierSetAssembler::g1_write_barrier_post(MacroAssembler* masm, Register tmp2) { assert(thread == xthread, "must be"); assert_different_registers(store_addr, new_val, thread, tmp1, tmp2, t0); - assert(store_addr != noreg && new_val != noreg && tmp1 != noreg && - tmp2 != noreg, "expecting a register"); - - Address queue_index(thread, in_bytes(G1ThreadLocalData::dirty_card_queue_index_offset())); - Address buffer(thread, in_bytes(G1ThreadLocalData::dirty_card_queue_buffer_offset())); - - BarrierSet* bs = BarrierSet::barrier_set(); - CardTableBarrierSet* ctbs = barrier_set_cast(bs); + assert(store_addr != noreg && new_val != noreg && tmp1 != noreg && tmp2 != noreg, + "expecting a register"); Label done; Label runtime; - // Does store cross heap regions? - - __ xorr(tmp1, store_addr, new_val); - __ srli(tmp1, tmp1, G1HeapRegion::LogOfHRGrainBytes); - __ beqz(tmp1, done); - - // crosses regions, storing null? - - __ beqz(new_val, done); - - // storing region crossing non-null, is card already dirty? - - const Register card_addr = tmp1; - - __ srli(card_addr, store_addr, CardTable::card_shift()); - - // get the address of the card - __ load_byte_map_base(tmp2); - __ add(card_addr, card_addr, tmp2); - __ lbu(tmp2, Address(card_addr)); + generate_post_barrier_fast_path(masm, store_addr, new_val, tmp1, tmp2, done, true /* new_val_may_be_null */); + // If card is young, jump to done (tmp2 holds the card value) __ mv(t0, (int)G1CardTable::g1_young_card_val()); - __ beq(tmp2, t0, done); - - assert((int)CardTable::dirty_card_val() == 0, "must be 0"); - - __ membar(MacroAssembler::StoreLoad); - - __ lbu(tmp2, Address(card_addr)); - __ beqz(tmp2, done); - - // storing a region crossing, non-null oop, card is clean. - // dirty card and log. - - __ sb(zr, Address(card_addr)); - - __ ld(t0, queue_index); - __ beqz(t0, runtime); - __ sub(t0, t0, wordSize); - __ sd(t0, queue_index); - - __ ld(tmp2, buffer); - __ add(t0, tmp2, t0); - __ sd(card_addr, Address(t0, 0)); - __ j(done); + __ beq(tmp2, t0, done); // card == young_card_val? + generate_post_barrier_slow_path(masm, thread, tmp1, tmp2, done, runtime); __ bind(runtime); // save the live input values RegSet saved = RegSet::of(store_addr); __ push_reg(saved, sp); - __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_field_post_entry), card_addr, thread); + __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_field_post_entry), tmp1, thread); __ pop_reg(saved, sp); __ bind(done); } +#if defined(COMPILER2) + +static void generate_c2_barrier_runtime_call(MacroAssembler* masm, G1BarrierStubC2* stub, const Register arg, const address runtime_path) { + SaveLiveRegisters save_registers(masm, stub); + if (c_rarg0 != arg) { + __ mv(c_rarg0, arg); + } + __ mv(c_rarg1, xthread); + __ mv(t0, runtime_path); + __ jalr(t0); +} + +void G1BarrierSetAssembler::g1_write_barrier_pre_c2(MacroAssembler* masm, + Register obj, + Register pre_val, + Register thread, + Register tmp1, + Register tmp2, + G1PreBarrierStubC2* stub) { + assert(thread == xthread, "must be"); + assert_different_registers(obj, pre_val, tmp1, tmp2); + assert(pre_val != noreg && tmp1 != noreg && tmp2 != noreg, "expecting a register"); + + stub->initialize_registers(obj, pre_val, thread, tmp1, tmp2); + + generate_pre_barrier_fast_path(masm, thread, tmp1); + // If marking is active (*(mark queue active address) != 0), jump to stub (slow path) + __ bnez(tmp1, *stub->entry(), true); + + __ bind(*stub->continuation()); +} + +void G1BarrierSetAssembler::generate_c2_pre_barrier_stub(MacroAssembler* masm, + G1PreBarrierStubC2* stub) const { + Assembler::InlineSkippedInstructionsCounter skip_counter(masm); + Label runtime; + Register obj = stub->obj(); + Register pre_val = stub->pre_val(); + Register thread = stub->thread(); + Register tmp1 = stub->tmp1(); + Register tmp2 = stub->tmp2(); + + __ bind(*stub->entry()); + generate_pre_barrier_slow_path(masm, obj, pre_val, thread, tmp1, tmp2, *stub->continuation(), runtime); + + __ bind(runtime); + generate_c2_barrier_runtime_call(masm, stub, pre_val, CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_field_pre_entry)); + __ j(*stub->continuation()); +} + +void G1BarrierSetAssembler::g1_write_barrier_post_c2(MacroAssembler* masm, + Register store_addr, + Register new_val, + Register thread, + Register tmp1, + Register tmp2, + G1PostBarrierStubC2* stub) { + assert(thread == xthread, "must be"); + assert_different_registers(store_addr, new_val, thread, tmp1, tmp2, t0); + assert(store_addr != noreg && new_val != noreg && tmp1 != noreg && tmp2 != noreg, + "expecting a register"); + + stub->initialize_registers(thread, tmp1, tmp2); + + bool new_val_may_be_null = (stub->barrier_data() & G1C2BarrierPostNotNull) == 0; + generate_post_barrier_fast_path(masm, store_addr, new_val, tmp1, tmp2, *stub->continuation(), new_val_may_be_null); + // If card is not young, jump to stub (slow path) (tmp2 holds the card value) + __ mv(t0, (int)G1CardTable::g1_young_card_val()); + __ bne(tmp2, t0, *stub->entry(), true); + + __ bind(*stub->continuation()); +} + +void G1BarrierSetAssembler::generate_c2_post_barrier_stub(MacroAssembler* masm, + G1PostBarrierStubC2* stub) const { + Assembler::InlineSkippedInstructionsCounter skip_counter(masm); + Label runtime; + Register thread = stub->thread(); + Register tmp1 = stub->tmp1(); // tmp1 holds the card address. + Register tmp2 = stub->tmp2(); + + __ bind(*stub->entry()); + generate_post_barrier_slow_path(masm, thread, tmp1, tmp2, *stub->continuation(), runtime); + + __ bind(runtime); + generate_c2_barrier_runtime_call(masm, stub, tmp1, CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_field_post_entry)); + __ j(*stub->continuation()); +} + +#endif // COMPILER2 + void G1BarrierSetAssembler::load_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type, Register dst, Address src, Register tmp1, Register tmp2) { bool on_oop = is_reference_type(type); diff --git a/src/hotspot/cpu/riscv/gc/g1/g1BarrierSetAssembler_riscv.hpp b/src/hotspot/cpu/riscv/gc/g1/g1BarrierSetAssembler_riscv.hpp index 96568994079..c7bee2ef6f3 100644 --- a/src/hotspot/cpu/riscv/gc/g1/g1BarrierSetAssembler_riscv.hpp +++ b/src/hotspot/cpu/riscv/gc/g1/g1BarrierSetAssembler_riscv.hpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2020, 2021, Huawei Technologies Co., Ltd. All rights reserved. + * Copyright (c) 2020, 2024, Huawei Technologies Co., Ltd. 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 @@ -36,6 +36,8 @@ class LIR_Assembler; class StubAssembler; class G1PreBarrierStub; class G1PostBarrierStub; +class G1PreBarrierStubC2; +class G1PostBarrierStubC2; class G1BarrierSetAssembler: public ModRefBarrierSetAssembler { protected: @@ -72,6 +74,27 @@ public: void generate_c1_post_barrier_runtime_stub(StubAssembler* sasm); #endif +#ifdef COMPILER2 + void g1_write_barrier_pre_c2(MacroAssembler* masm, + Register obj, + Register pre_val, + Register thread, + Register tmp1, + Register tmp2, + G1PreBarrierStubC2* c2_stub); + void generate_c2_pre_barrier_stub(MacroAssembler* masm, + G1PreBarrierStubC2* stub) const; + void g1_write_barrier_post_c2(MacroAssembler* masm, + Register store_addr, + Register new_val, + Register thread, + Register tmp1, + Register tmp2, + G1PostBarrierStubC2* c2_stub); + void generate_c2_post_barrier_stub(MacroAssembler* masm, + G1PostBarrierStubC2* stub) const; +#endif + void load_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type, Register dst, Address src, Register tmp1, Register tmp2); }; diff --git a/src/hotspot/cpu/riscv/gc/g1/g1_riscv.ad b/src/hotspot/cpu/riscv/gc/g1/g1_riscv.ad new file mode 100644 index 00000000000..7a525323021 --- /dev/null +++ b/src/hotspot/cpu/riscv/gc/g1/g1_riscv.ad @@ -0,0 +1,564 @@ +// +// Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2024, Huawei Technologies Co., Ltd. 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. +// + +source_hpp %{ + +#include "gc/g1/c2/g1BarrierSetC2.hpp" +#include "gc/shared/gc_globals.hpp" + +%} + +source %{ + +#include "gc/g1/g1BarrierSetAssembler_riscv.hpp" +#include "gc/g1/g1BarrierSetRuntime.hpp" + +static void write_barrier_pre(MacroAssembler* masm, + const MachNode* node, + Register obj, + Register pre_val, + Register tmp1, + Register tmp2, + RegSet preserve = RegSet(), + RegSet no_preserve = RegSet()) { + if (!G1PreBarrierStubC2::needs_barrier(node)) { + return; + } + Assembler::InlineSkippedInstructionsCounter skip_counter(masm); + G1BarrierSetAssembler* g1_asm = static_cast(BarrierSet::barrier_set()->barrier_set_assembler()); + G1PreBarrierStubC2* const stub = G1PreBarrierStubC2::create(node); + for (RegSetIterator reg = preserve.begin(); *reg != noreg; ++reg) { + stub->preserve(*reg); + } + for (RegSetIterator reg = no_preserve.begin(); *reg != noreg; ++reg) { + stub->dont_preserve(*reg); + } + g1_asm->g1_write_barrier_pre_c2(masm, obj, pre_val, xthread, tmp1, tmp2, stub); +} + +static void write_barrier_post(MacroAssembler* masm, + const MachNode* node, + Register store_addr, + Register new_val, + Register tmp1, + Register tmp2) { + if (!G1PostBarrierStubC2::needs_barrier(node)) { + return; + } + Assembler::InlineSkippedInstructionsCounter skip_counter(masm); + G1BarrierSetAssembler* g1_asm = static_cast(BarrierSet::barrier_set()->barrier_set_assembler()); + G1PostBarrierStubC2* const stub = G1PostBarrierStubC2::create(node); + g1_asm->g1_write_barrier_post_c2(masm, store_addr, new_val, xthread, tmp1, tmp2, stub); +} + +%} + +instruct g1StoreP(indirect mem, iRegP src, iRegPNoSp tmp1, iRegPNoSp tmp2, iRegPNoSp tmp3, rFlagsReg cr) +%{ + predicate(UseG1GC && n->as_Store()->barrier_data() != 0); + match(Set mem (StoreP mem src)); + effect(TEMP tmp1, TEMP tmp2, TEMP tmp3, KILL cr); + ins_cost(STORE_COST); + format %{ "sd $src, $mem\t# ptr" %} + ins_encode %{ + guarantee($mem$$disp == 0, "impossible encoding"); + write_barrier_pre(masm, this, + $mem$$Register /* obj */, + $tmp1$$Register /* pre_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */, + RegSet::of($mem$$Register, $src$$Register) /* preserve */); + __ sd($src$$Register, Address($mem$$Register)); + write_barrier_post(masm, this, + $mem$$Register /* store_addr */, + $src$$Register /* new_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */); + %} + ins_pipe(istore_reg_mem); +%} + +instruct g1StoreN(indirect mem, iRegN src, iRegPNoSp tmp1, iRegPNoSp tmp2, iRegPNoSp tmp3, rFlagsReg cr) +%{ + predicate(UseG1GC && n->as_Store()->barrier_data() != 0); + match(Set mem (StoreN mem src)); + effect(TEMP tmp1, TEMP tmp2, TEMP tmp3, KILL cr); + ins_cost(STORE_COST); + format %{ "sw $src, $mem\t# compressed ptr" %} + ins_encode %{ + guarantee($mem$$disp == 0, "impossible encoding"); + write_barrier_pre(masm, this, + $mem$$Register /* obj */, + $tmp1$$Register /* pre_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */, + RegSet::of($mem$$Register, $src$$Register) /* preserve */); + __ sw($src$$Register, Address($mem$$Register)); + if ((barrier_data() & G1C2BarrierPost) != 0) { + if ((barrier_data() & G1C2BarrierPostNotNull) == 0) { + __ decode_heap_oop($tmp1$$Register, $src$$Register); + } else { + __ decode_heap_oop_not_null($tmp1$$Register, $src$$Register); + } + } + write_barrier_post(masm, this, + $mem$$Register /* store_addr */, + $tmp1$$Register /* new_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */); + %} + ins_pipe(istore_reg_mem); +%} + +instruct g1EncodePAndStoreN(indirect mem, iRegP src, iRegPNoSp tmp1, iRegPNoSp tmp2, iRegPNoSp tmp3, rFlagsReg cr) +%{ + predicate(UseG1GC && n->as_Store()->barrier_data() != 0); + match(Set mem (StoreN mem (EncodeP src))); + effect(TEMP tmp1, TEMP tmp2, TEMP tmp3, KILL cr); + ins_cost(STORE_COST); + format %{ "encode_heap_oop $tmp1, $src\n\t" + "sw $tmp1, $mem\t# compressed ptr" %} + ins_encode %{ + guarantee($mem$$disp == 0, "impossible encoding"); + write_barrier_pre(masm, this, + $mem$$Register /* obj */, + $tmp1$$Register /* pre_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */, + RegSet::of($mem$$Register, $src$$Register) /* preserve */); + if ((barrier_data() & G1C2BarrierPostNotNull) == 0) { + __ encode_heap_oop($tmp1$$Register, $src$$Register); + } else { + __ encode_heap_oop_not_null($tmp1$$Register, $src$$Register); + } + __ sw($tmp1$$Register, Address($mem$$Register)); + write_barrier_post(masm, this, + $mem$$Register /* store_addr */, + $src$$Register /* new_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */); + %} + ins_pipe(istore_reg_mem); +%} + +instruct g1CompareAndExchangeP(iRegPNoSp res, indirect mem, iRegP oldval, iRegP newval, iRegPNoSp tmp1, iRegPNoSp tmp2, rFlagsReg cr) +%{ + predicate(UseG1GC && n->as_LoadStore()->barrier_data() != 0); + match(Set res (CompareAndExchangeP mem (Binary oldval newval))); + effect(TEMP res, TEMP tmp1, TEMP tmp2, KILL cr); + ins_cost(2 * VOLATILE_REF_COST); + format %{ "cmpxchg $res = $mem, $oldval, $newval\t# ptr" %} + ins_encode %{ + guarantee($mem$$disp == 0, "impossible encoding"); + assert_different_registers($oldval$$Register, $mem$$Register); + assert_different_registers($newval$$Register, $mem$$Register); + // Pass $oldval to the pre-barrier (instead of loading from $mem), because + // $oldval is the only value that can be overwritten. + // The same holds for g1CompareAndSwapP and its Acq variant. + write_barrier_pre(masm, this, + noreg /* obj */, + $oldval$$Register /* pre_val */, + $tmp1$$Register /* tmp1 */, + $tmp2$$Register /* tmp2 */, + RegSet::of($mem$$Register, $oldval$$Register, $newval$$Register) /* preserve */, + RegSet::of($res$$Register) /* no_preserve */); + __ cmpxchg($mem$$Register, $oldval$$Register, $newval$$Register, Assembler::int64, + /*acquire*/ Assembler::relaxed, /*release*/ Assembler::rl, $res$$Register); + write_barrier_post(masm, this, + $mem$$Register /* store_addr */, + $newval$$Register /* new_val */, + $tmp1$$Register /* tmp1 */, + $tmp2$$Register /* tmp2 */); + %} + ins_pipe(pipe_slow); +%} + +instruct g1CompareAndExchangePAcq(iRegPNoSp res, indirect mem, iRegP oldval, iRegP newval, iRegPNoSp tmp1, iRegPNoSp tmp2, rFlagsReg cr) +%{ + predicate(UseG1GC && needs_acquiring_load_reserved(n) && n->as_LoadStore()->barrier_data() != 0); + match(Set res (CompareAndExchangeP mem (Binary oldval newval))); + effect(TEMP res, TEMP tmp1, TEMP tmp2, KILL cr); + ins_cost(VOLATILE_REF_COST); + format %{ "cmpxchg_acq $res = $mem, $oldval, $newval\t# ptr" %} + ins_encode %{ + guarantee($mem$$disp == 0, "impossible encoding"); + assert_different_registers($oldval$$Register, $mem$$Register); + assert_different_registers($newval$$Register, $mem$$Register); + // Pass $oldval to the pre-barrier (instead of loading from $mem), because + // $oldval is the only value that can be overwritten. + // The same holds for g1CompareAndSwapP and its Acq variant. + write_barrier_pre(masm, this, + noreg /* obj */, + $oldval$$Register /* pre_val */, + $tmp1$$Register /* tmp1 */, + $tmp2$$Register /* tmp2 */, + RegSet::of($mem$$Register, $oldval$$Register, $newval$$Register) /* preserve */, + RegSet::of($res$$Register) /* no_preserve */); + __ cmpxchg($mem$$Register, $oldval$$Register, $newval$$Register, Assembler::int64, + /*acquire*/ Assembler::aq, /*release*/ Assembler::rl, $res$$Register); + write_barrier_post(masm, this, + $mem$$Register /* store_addr */, + $newval$$Register /* new_val */, + $tmp1$$Register /* tmp1 */, + $tmp2$$Register /* tmp2 */); + %} + ins_pipe(pipe_slow); +%} + +instruct g1CompareAndExchangeN(iRegNNoSp res, indirect mem, iRegN oldval, iRegN newval, iRegPNoSp tmp1, iRegPNoSp tmp2, iRegPNoSp tmp3, rFlagsReg cr) +%{ + predicate(UseG1GC && n->as_LoadStore()->barrier_data() != 0); + match(Set res (CompareAndExchangeN mem (Binary oldval newval))); + effect(TEMP res, TEMP tmp1, TEMP tmp2, TEMP tmp3, KILL cr); + ins_cost(2 * VOLATILE_REF_COST); + format %{ "cmpxchg $res = $mem, $oldval, $newval\t# narrow oop" %} + ins_encode %{ + guarantee($mem$$disp == 0, "impossible encoding"); + assert_different_registers($oldval$$Register, $mem$$Register); + assert_different_registers($newval$$Register, $mem$$Register); + write_barrier_pre(masm, this, + $mem$$Register /* obj */, + $tmp1$$Register /* pre_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */, + RegSet::of($mem$$Register, $oldval$$Register, $newval$$Register) /* preserve */, + RegSet::of($res$$Register) /* no_preserve */); + __ cmpxchg($mem$$Register, $oldval$$Register, $newval$$Register, Assembler::uint32, + /*acquire*/ Assembler::relaxed, /*release*/ Assembler::rl, $res$$Register); + __ decode_heap_oop($tmp1$$Register, $newval$$Register); + write_barrier_post(masm, this, + $mem$$Register /* store_addr */, + $tmp1$$Register /* new_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */); + %} + ins_pipe(pipe_slow); +%} + +instruct g1CompareAndExchangeNAcq(iRegNNoSp res, indirect mem, iRegN oldval, iRegN newval, iRegPNoSp tmp1, iRegPNoSp tmp2, iRegPNoSp tmp3, rFlagsReg cr) +%{ + predicate(UseG1GC && needs_acquiring_load_reserved(n) && n->as_LoadStore()->barrier_data() != 0); + match(Set res (CompareAndExchangeN mem (Binary oldval newval))); + effect(TEMP res, TEMP tmp1, TEMP tmp2, TEMP tmp3, KILL cr); + ins_cost(VOLATILE_REF_COST); + format %{ "cmpxchg_acq $res = $mem, $oldval, $newval\t# narrow oop" %} + ins_encode %{ + guarantee($mem$$disp == 0, "impossible encoding"); + assert_different_registers($oldval$$Register, $mem$$Register); + assert_different_registers($newval$$Register, $mem$$Register); + write_barrier_pre(masm, this, + $mem$$Register /* obj */, + $tmp1$$Register /* pre_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */, + RegSet::of($mem$$Register, $oldval$$Register, $newval$$Register) /* preserve */, + RegSet::of($res$$Register) /* no_preserve */); + __ cmpxchg($mem$$Register, $oldval$$Register, $newval$$Register, Assembler::uint32, + /*acquire*/ Assembler::aq, /*release*/ Assembler::rl, $res$$Register); + __ decode_heap_oop($tmp1$$Register, $newval$$Register); + write_barrier_post(masm, this, + $mem$$Register /* store_addr */, + $tmp1$$Register /* new_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */); + %} + ins_pipe(pipe_slow); +%} + +instruct g1CompareAndSwapP(iRegINoSp res, indirect mem, iRegP newval, iRegPNoSp tmp1, iRegPNoSp tmp2, iRegP oldval, rFlagsReg cr) +%{ + predicate(UseG1GC && n->as_LoadStore()->barrier_data() != 0); + match(Set res (CompareAndSwapP mem (Binary oldval newval))); + match(Set res (WeakCompareAndSwapP mem (Binary oldval newval))); + effect(TEMP res, TEMP tmp1, TEMP tmp2, KILL cr); + ins_cost(2 * VOLATILE_REF_COST); + format %{ "cmpxchg $mem, $oldval, $newval\t# (ptr)\n\t" + "mv $res, $res == $oldval" %} + ins_encode %{ + guarantee($mem$$disp == 0, "impossible encoding"); + assert_different_registers($oldval$$Register, $mem$$Register); + assert_different_registers($newval$$Register, $mem$$Register); + write_barrier_pre(masm, this, + noreg /* obj */, + $oldval$$Register /* pre_val */, + $tmp1$$Register /* tmp1 */, + $tmp2$$Register /* tmp2 */, + RegSet::of($mem$$Register, $oldval$$Register, $newval$$Register) /* preserve */, + RegSet::of($res$$Register) /* no_preserve */); + __ cmpxchg($mem$$Register, $oldval$$Register, $newval$$Register, Assembler::int64, + /*acquire*/ Assembler::relaxed, /*release*/ Assembler::rl, $res$$Register, + /*result as bool*/ true); + write_barrier_post(masm, this, + $mem$$Register /* store_addr */, + $newval$$Register /* new_val */, + $tmp1$$Register /* tmp1 */, + $tmp2$$Register /* tmp2 */); + %} + ins_pipe(pipe_slow); +%} + +instruct g1CompareAndSwapPAcq(iRegINoSp res, indirect mem, iRegP newval, iRegPNoSp tmp1, iRegPNoSp tmp2, iRegP oldval, rFlagsReg cr) +%{ + predicate(UseG1GC && needs_acquiring_load_reserved(n) && n->as_LoadStore()->barrier_data() != 0); + match(Set res (CompareAndSwapP mem (Binary oldval newval))); + match(Set res (WeakCompareAndSwapP mem (Binary oldval newval))); + effect(TEMP res, TEMP tmp1, TEMP tmp2, KILL cr); + ins_cost(VOLATILE_REF_COST); + format %{ "cmpxchg_acq $mem, $oldval, $newval\t# (ptr)\n\t" + "mv $res, $res == $oldval" %} + ins_encode %{ + guarantee($mem$$disp == 0, "impossible encoding"); + assert_different_registers($oldval$$Register, $mem$$Register); + assert_different_registers($newval$$Register, $mem$$Register); + write_barrier_pre(masm, this, + noreg /* obj */, + $oldval$$Register /* pre_val */, + $tmp1$$Register /* tmp1 */, + $tmp2$$Register /* tmp2 */, + RegSet::of($mem$$Register, $oldval$$Register, $newval$$Register) /* preserve */, + RegSet::of($res$$Register) /* no_preserve */); + __ cmpxchg($mem$$Register, $oldval$$Register, $newval$$Register, Assembler::int64, + /*acquire*/ Assembler::aq, /*release*/ Assembler::rl, $res$$Register, + /*result as bool*/ true); + write_barrier_post(masm, this, + $mem$$Register /* store_addr */, + $newval$$Register /* new_val */, + $tmp1$$Register /* tmp1 */, + $tmp2$$Register /* tmp2 */); + %} + ins_pipe(pipe_slow); +%} + +instruct g1CompareAndSwapN(iRegINoSp res, indirect mem, iRegN newval, iRegPNoSp tmp1, iRegPNoSp tmp2, iRegPNoSp tmp3, iRegN oldval, rFlagsReg cr) +%{ + predicate(UseG1GC && n->as_LoadStore()->barrier_data() != 0); + match(Set res (CompareAndSwapN mem (Binary oldval newval))); + match(Set res (WeakCompareAndSwapN mem (Binary oldval newval))); + effect(TEMP res, TEMP tmp1, TEMP tmp2, TEMP tmp3, KILL cr); + ins_cost(2 * VOLATILE_REF_COST); + format %{ "cmpxchg $mem, $oldval, $newval\t# (narrow oop)\n\t" + "mv $res, $res == $oldval" %} + ins_encode %{ + guarantee($mem$$disp == 0, "impossible encoding"); + assert_different_registers($oldval$$Register, $mem$$Register); + assert_different_registers($newval$$Register, $mem$$Register); + write_barrier_pre(masm, this, + $mem$$Register /* obj */, + $tmp1$$Register /* pre_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */, + RegSet::of($mem$$Register, $oldval$$Register, $newval$$Register) /* preserve */, + RegSet::of($res$$Register) /* no_preserve */); + __ cmpxchg($mem$$Register, $oldval$$Register, $newval$$Register, Assembler::uint32, + /*acquire*/ Assembler::relaxed, /*release*/ Assembler::rl, $res$$Register, + /*result as bool*/ true); + __ decode_heap_oop($tmp1$$Register, $newval$$Register); + write_barrier_post(masm, this, + $mem$$Register /* store_addr */, + $tmp1$$Register /* new_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */); + %} + ins_pipe(pipe_slow); +%} + +instruct g1CompareAndSwapNAcq(iRegINoSp res, indirect mem, iRegN newval, iRegPNoSp tmp1, iRegPNoSp tmp2, iRegPNoSp tmp3, iRegN oldval, rFlagsReg cr) +%{ + predicate(UseG1GC && needs_acquiring_load_reserved(n) && n->as_LoadStore()->barrier_data() != 0); + match(Set res (CompareAndSwapN mem (Binary oldval newval))); + match(Set res (WeakCompareAndSwapN mem (Binary oldval newval))); + effect(TEMP res, TEMP tmp1, TEMP tmp2, TEMP tmp3, KILL cr); + ins_cost(VOLATILE_REF_COST); + format %{ "cmpxchg_acq $mem, $oldval, $newval\t# (narrow oop)\n\t" + "mv $res, $res == $oldval" %} + ins_encode %{ + guarantee($mem$$disp == 0, "impossible encoding"); + assert_different_registers($oldval$$Register, $mem$$Register); + assert_different_registers($newval$$Register, $mem$$Register); + write_barrier_pre(masm, this, + $mem$$Register /* obj */, + $tmp1$$Register /* pre_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */, + RegSet::of($mem$$Register, $oldval$$Register, $newval$$Register) /* preserve */, + RegSet::of($res$$Register) /* no_preserve */); + __ cmpxchg($mem$$Register, $oldval$$Register, $newval$$Register, Assembler::uint32, + /*acquire*/ Assembler::aq, /*release*/ Assembler::rl, $res$$Register, + /*result as bool*/ true); + __ decode_heap_oop($tmp1$$Register, $newval$$Register); + write_barrier_post(masm, this, + $mem$$Register /* store_addr */, + $tmp1$$Register /* new_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */); + %} + ins_pipe(pipe_slow); +%} + +instruct g1GetAndSetP(indirect mem, iRegP newval, iRegPNoSp tmp1, iRegPNoSp tmp2, iRegPNoSp preval, rFlagsReg cr) +%{ + predicate(UseG1GC && n->as_LoadStore()->barrier_data() != 0); + match(Set preval (GetAndSetP mem newval)); + effect(TEMP preval, TEMP tmp1, TEMP tmp2, KILL cr); + ins_cost(2 * VOLATILE_REF_COST); + format %{ "atomic_xchg $preval, $newval, [$mem]" %} + ins_encode %{ + guarantee($mem$$disp == 0, "impossible encoding"); + assert_different_registers($mem$$Register, $newval$$Register); + write_barrier_pre(masm, this, + $mem$$Register /* obj */, + $preval$$Register /* pre_val (as a temporary register) */, + $tmp1$$Register /* tmp1 */, + $tmp2$$Register /* tmp2 */, + RegSet::of($mem$$Register, $preval$$Register, $newval$$Register) /* preserve */); + __ atomic_xchg($preval$$Register, $newval$$Register, $mem$$Register); + write_barrier_post(masm, this, + $mem$$Register /* store_addr */, + $newval$$Register /* new_val */, + $tmp1$$Register /* tmp1 */, + $tmp2$$Register /* tmp2 */); + %} + ins_pipe(pipe_serial); +%} + +instruct g1GetAndSetPAcq(indirect mem, iRegP newval, iRegPNoSp tmp1, iRegPNoSp tmp2, iRegPNoSp preval, rFlagsReg cr) +%{ + predicate(UseG1GC && needs_acquiring_load_reserved(n) && n->as_LoadStore()->barrier_data() != 0); + match(Set preval (GetAndSetP mem newval)); + effect(TEMP preval, TEMP tmp1, TEMP tmp2, KILL cr); + ins_cost(VOLATILE_REF_COST); + format %{ "atomic_xchg_acq $preval, $newval, [$mem]" %} + ins_encode %{ + guarantee($mem$$disp == 0, "impossible encoding"); + assert_different_registers($mem$$Register, $newval$$Register); + write_barrier_pre(masm, this, + $mem$$Register /* obj */, + $preval$$Register /* pre_val (as a temporary register) */, + $tmp1$$Register /* tmp1 */, + $tmp2$$Register /* tmp2 */, + RegSet::of($mem$$Register, $preval$$Register, $newval$$Register) /* preserve */); + __ atomic_xchgal($preval$$Register, $newval$$Register, $mem$$Register); + write_barrier_post(masm, this, + $mem$$Register /* store_addr */, + $newval$$Register /* new_val */, + $tmp1$$Register /* tmp1 */, + $tmp2$$Register /* tmp2 */); + %} + ins_pipe(pipe_serial); +%} + +instruct g1GetAndSetN(indirect mem, iRegN newval, iRegPNoSp tmp1, iRegPNoSp tmp2, iRegPNoSp tmp3, iRegNNoSp preval, rFlagsReg cr) +%{ + predicate(UseG1GC && n->as_LoadStore()->barrier_data() != 0); + match(Set preval (GetAndSetN mem newval)); + effect(TEMP preval, TEMP tmp1, TEMP tmp2, TEMP tmp3, KILL cr); + ins_cost(2 * VOLATILE_REF_COST); + format %{ "atomic_xchgwu $preval, $newval, [$mem]" %} + ins_encode %{ + guarantee($mem$$disp == 0, "impossible encoding"); + assert_different_registers($mem$$Register, $newval$$Register); + write_barrier_pre(masm, this, + $mem$$Register /* obj */, + $tmp1$$Register /* pre_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */, + RegSet::of($mem$$Register, $preval$$Register, $newval$$Register) /* preserve */); + __ atomic_xchgwu($preval$$Register, $newval$$Register, $mem$$Register); + __ decode_heap_oop($tmp1$$Register, $newval$$Register); + write_barrier_post(masm, this, + $mem$$Register /* store_addr */, + $tmp1$$Register /* new_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */); + %} + ins_pipe(pipe_serial); +%} + +instruct g1GetAndSetNAcq(indirect mem, iRegN newval, iRegPNoSp tmp1, iRegPNoSp tmp2, iRegPNoSp tmp3, iRegNNoSp preval, rFlagsReg cr) +%{ + predicate(UseG1GC && needs_acquiring_load_reserved(n) && n->as_LoadStore()->barrier_data() != 0); + match(Set preval (GetAndSetN mem newval)); + effect(TEMP preval, TEMP tmp1, TEMP tmp2, TEMP tmp3, KILL cr); + ins_cost(VOLATILE_REF_COST); + format %{ "atomic_xchgwu_acq $preval, $newval, [$mem]" %} + ins_encode %{ + guarantee($mem$$disp == 0, "impossible encoding"); + assert_different_registers($mem$$Register, $newval$$Register); + write_barrier_pre(masm, this, + $mem$$Register /* obj */, + $tmp1$$Register /* pre_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */, + RegSet::of($mem$$Register, $preval$$Register, $newval$$Register) /* preserve */); + __ atomic_xchgalwu($preval$$Register, $newval$$Register, $mem$$Register); + __ decode_heap_oop($tmp1$$Register, $newval$$Register); + write_barrier_post(masm, this, + $mem$$Register /* store_addr */, + $tmp1$$Register /* new_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */); + %} + ins_pipe(pipe_serial); +%} + +instruct g1LoadP(iRegPNoSp dst, indirect mem, iRegPNoSp tmp1, iRegPNoSp tmp2, rFlagsReg cr) +%{ + predicate(UseG1GC && n->as_Load()->barrier_data() != 0); + match(Set dst (LoadP mem)); + effect(TEMP dst, TEMP tmp1, TEMP tmp2, KILL cr); + ins_cost(LOAD_COST + BRANCH_COST); + format %{ "ld $dst, $mem\t# ptr" %} + ins_encode %{ + guarantee($mem$$disp == 0, "impossible encoding"); + __ ld($dst$$Register, Address($mem$$Register)); + write_barrier_pre(masm, this, + noreg /* obj */, + $dst$$Register /* pre_val */, + $tmp1$$Register /* tmp1 */, + $tmp2$$Register /* tmp2 */); + %} + ins_pipe(iload_reg_mem); +%} + +instruct g1LoadN(iRegNNoSp dst, indirect mem, iRegPNoSp tmp1, iRegPNoSp tmp2, iRegPNoSp tmp3, rFlagsReg cr) +%{ + predicate(UseG1GC && n->as_Load()->barrier_data() != 0); + match(Set dst (LoadN mem)); + effect(TEMP dst, TEMP tmp1, TEMP tmp2, TEMP tmp3, KILL cr); + ins_cost(LOAD_COST + BRANCH_COST); + format %{ "lwu $dst, $mem\t# compressed ptr" %} + ins_encode %{ + guarantee($mem$$disp == 0, "impossible encoding"); + __ lwu($dst$$Register, Address($mem$$Register)); + if ((barrier_data() & G1C2BarrierPre) != 0) { + __ decode_heap_oop($tmp1$$Register, $dst$$Register); + write_barrier_pre(masm, this, + noreg /* obj */, + $tmp1$$Register /* pre_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */); + } + %} + ins_pipe(iload_reg_mem); +%} diff --git a/src/hotspot/cpu/riscv/gc/shenandoah/shenandoahBarrierSetAssembler_riscv.cpp b/src/hotspot/cpu/riscv/gc/shenandoah/shenandoahBarrierSetAssembler_riscv.cpp index 9a79a923277..cc73d14a756 100644 --- a/src/hotspot/cpu/riscv/gc/shenandoah/shenandoahBarrierSetAssembler_riscv.cpp +++ b/src/hotspot/cpu/riscv/gc/shenandoah/shenandoahBarrierSetAssembler_riscv.cpp @@ -70,10 +70,10 @@ void ShenandoahBarrierSetAssembler::arraycopy_prologue(MacroAssembler* masm, Dec __ push_reg(saved_regs, sp); if (UseCompressedOops) { - __ call_VM_leaf(CAST_FROM_FN_PTR(address, ShenandoahRuntime::arraycopy_barrier_narrow_oop_entry), + __ call_VM_leaf(CAST_FROM_FN_PTR(address, ShenandoahRuntime::arraycopy_barrier_narrow_oop), src, dst, count); } else { - __ call_VM_leaf(CAST_FROM_FN_PTR(address, ShenandoahRuntime::arraycopy_barrier_oop_entry), src, dst, count); + __ call_VM_leaf(CAST_FROM_FN_PTR(address, ShenandoahRuntime::arraycopy_barrier_oop), src, dst, count); } __ pop_reg(saved_regs, sp); __ bind(done); @@ -165,9 +165,9 @@ void ShenandoahBarrierSetAssembler::satb_write_barrier_pre(MacroAssembler* masm, // expand_call should be passed true. if (expand_call) { assert(pre_val != c_rarg1, "smashed arg"); - __ super_call_VM_leaf(CAST_FROM_FN_PTR(address, ShenandoahRuntime::write_ref_field_pre_entry), pre_val, thread); + __ super_call_VM_leaf(CAST_FROM_FN_PTR(address, ShenandoahRuntime::write_ref_field_pre), pre_val, thread); } else { - __ call_VM_leaf(CAST_FROM_FN_PTR(address, ShenandoahRuntime::write_ref_field_pre_entry), pre_val, thread); + __ call_VM_leaf(CAST_FROM_FN_PTR(address, ShenandoahRuntime::write_ref_field_pre), pre_val, thread); } __ pop_reg(saved, sp); @@ -645,7 +645,7 @@ void ShenandoahBarrierSetAssembler::generate_c1_pre_barrier_runtime_stub(StubAss __ bind(runtime); __ push_call_clobbered_registers(); __ load_parameter(0, pre_val); - __ call_VM_leaf(CAST_FROM_FN_PTR(address, ShenandoahRuntime::write_ref_field_pre_entry), pre_val, thread); + __ call_VM_leaf(CAST_FROM_FN_PTR(address, ShenandoahRuntime::write_ref_field_pre), pre_val, thread); __ pop_call_clobbered_registers(); __ bind(done); diff --git a/src/hotspot/cpu/riscv/gc/x/x_riscv.ad b/src/hotspot/cpu/riscv/gc/x/x_riscv.ad index ef02f301c6a..b93b7066425 100644 --- a/src/hotspot/cpu/riscv/gc/x/x_riscv.ad +++ b/src/hotspot/cpu/riscv/gc/x/x_riscv.ad @@ -52,11 +52,11 @@ static void x_load_barrier_slow_path(MacroAssembler* masm, const MachNode* node, %} // Load Pointer -instruct xLoadP(iRegPNoSp dst, memory mem, iRegPNoSp tmp) +instruct xLoadP(iRegPNoSp dst, memory mem, iRegPNoSp tmp, rFlagsReg cr) %{ match(Set dst (LoadP mem)); predicate(UseZGC && !ZGenerational && (n->as_Load()->barrier_data() != 0)); - effect(TEMP dst, TEMP tmp); + effect(TEMP dst, TEMP tmp, KILL cr); ins_cost(4 * DEFAULT_COST); @@ -71,11 +71,11 @@ instruct xLoadP(iRegPNoSp dst, memory mem, iRegPNoSp tmp) ins_pipe(iload_reg_mem); %} -instruct xCompareAndSwapP(iRegINoSp res, indirect mem, iRegP oldval, iRegP newval, iRegPNoSp tmp) %{ +instruct xCompareAndSwapP(iRegINoSp res, indirect mem, iRegP oldval, iRegP newval, iRegPNoSp tmp, rFlagsReg cr) %{ match(Set res (CompareAndSwapP mem (Binary oldval newval))); match(Set res (WeakCompareAndSwapP mem (Binary oldval newval))); predicate(UseZGC && !ZGenerational && !needs_acquiring_load_reserved(n) && n->as_LoadStore()->barrier_data() == XLoadBarrierStrong); - effect(TEMP_DEF res, TEMP tmp); + effect(TEMP_DEF res, TEMP tmp, KILL cr); ins_cost(2 * VOLATILE_REF_COST); @@ -105,11 +105,11 @@ instruct xCompareAndSwapP(iRegINoSp res, indirect mem, iRegP oldval, iRegP newva ins_pipe(pipe_slow); %} -instruct xCompareAndSwapPAcq(iRegINoSp res, indirect mem, iRegP oldval, iRegP newval, iRegPNoSp tmp) %{ +instruct xCompareAndSwapPAcq(iRegINoSp res, indirect mem, iRegP oldval, iRegP newval, iRegPNoSp tmp, rFlagsReg cr) %{ match(Set res (CompareAndSwapP mem (Binary oldval newval))); match(Set res (WeakCompareAndSwapP mem (Binary oldval newval))); predicate(UseZGC && !ZGenerational && needs_acquiring_load_reserved(n) && (n->as_LoadStore()->barrier_data() == XLoadBarrierStrong)); - effect(TEMP_DEF res, TEMP tmp); + effect(TEMP_DEF res, TEMP tmp, KILL cr); ins_cost(2 * VOLATILE_REF_COST); @@ -139,10 +139,10 @@ instruct xCompareAndSwapPAcq(iRegINoSp res, indirect mem, iRegP oldval, iRegP ne ins_pipe(pipe_slow); %} -instruct xCompareAndExchangeP(iRegPNoSp res, indirect mem, iRegP oldval, iRegP newval, iRegPNoSp tmp) %{ +instruct xCompareAndExchangeP(iRegPNoSp res, indirect mem, iRegP oldval, iRegP newval, iRegPNoSp tmp, rFlagsReg cr) %{ match(Set res (CompareAndExchangeP mem (Binary oldval newval))); predicate(UseZGC && !ZGenerational && !needs_acquiring_load_reserved(n) && n->as_LoadStore()->barrier_data() == XLoadBarrierStrong); - effect(TEMP_DEF res, TEMP tmp); + effect(TEMP_DEF res, TEMP tmp, KILL cr); ins_cost(2 * VOLATILE_REF_COST); @@ -167,10 +167,10 @@ instruct xCompareAndExchangeP(iRegPNoSp res, indirect mem, iRegP oldval, iRegP n ins_pipe(pipe_slow); %} -instruct xCompareAndExchangePAcq(iRegPNoSp res, indirect mem, iRegP oldval, iRegP newval, iRegPNoSp tmp) %{ +instruct xCompareAndExchangePAcq(iRegPNoSp res, indirect mem, iRegP oldval, iRegP newval, iRegPNoSp tmp, rFlagsReg cr) %{ match(Set res (CompareAndExchangeP mem (Binary oldval newval))); predicate(UseZGC && !ZGenerational && needs_acquiring_load_reserved(n) && n->as_LoadStore()->barrier_data() == XLoadBarrierStrong); - effect(TEMP_DEF res, TEMP tmp); + effect(TEMP_DEF res, TEMP tmp, KILL cr); ins_cost(2 * VOLATILE_REF_COST); @@ -195,10 +195,10 @@ instruct xCompareAndExchangePAcq(iRegPNoSp res, indirect mem, iRegP oldval, iReg ins_pipe(pipe_slow); %} -instruct xGetAndSetP(indirect mem, iRegP newv, iRegPNoSp prev, iRegPNoSp tmp) %{ +instruct xGetAndSetP(indirect mem, iRegP newv, iRegPNoSp prev, iRegPNoSp tmp, rFlagsReg cr) %{ match(Set prev (GetAndSetP mem newv)); predicate(UseZGC && !ZGenerational && !needs_acquiring_load_reserved(n) && n->as_LoadStore()->barrier_data() != 0); - effect(TEMP_DEF prev, TEMP tmp); + effect(TEMP_DEF prev, TEMP tmp, KILL cr); ins_cost(2 * VOLATILE_REF_COST); @@ -212,10 +212,10 @@ instruct xGetAndSetP(indirect mem, iRegP newv, iRegPNoSp prev, iRegPNoSp tmp) %{ ins_pipe(pipe_serial); %} -instruct xGetAndSetPAcq(indirect mem, iRegP newv, iRegPNoSp prev, iRegPNoSp tmp) %{ +instruct xGetAndSetPAcq(indirect mem, iRegP newv, iRegPNoSp prev, iRegPNoSp tmp, rFlagsReg cr) %{ match(Set prev (GetAndSetP mem newv)); predicate(UseZGC && !ZGenerational && needs_acquiring_load_reserved(n) && (n->as_LoadStore()->barrier_data() != 0)); - effect(TEMP_DEF prev, TEMP tmp); + effect(TEMP_DEF prev, TEMP tmp, KILL cr); ins_cost(VOLATILE_REF_COST); diff --git a/src/hotspot/cpu/riscv/gc/z/zAddress_riscv.cpp b/src/hotspot/cpu/riscv/gc/z/zAddress_riscv.cpp index ef13676b02e..df111723d56 100644 --- a/src/hotspot/cpu/riscv/gc/z/zAddress_riscv.cpp +++ b/src/hotspot/cpu/riscv/gc/z/zAddress_riscv.cpp @@ -92,7 +92,7 @@ static size_t probe_valid_max_address_bit() { } size_t ZPlatformAddressOffsetBits() { - const static size_t valid_max_address_offset_bits = probe_valid_max_address_bit() + 1; + static const size_t valid_max_address_offset_bits = probe_valid_max_address_bit() + 1; const size_t max_address_offset_bits = valid_max_address_offset_bits - 3; const size_t min_address_offset_bits = max_address_offset_bits - 2; const size_t address_offset = round_up_power_of_2(MaxHeapSize * ZVirtualToPhysicalRatio); diff --git a/src/hotspot/cpu/riscv/gc/z/zBarrierSetAssembler_riscv.cpp b/src/hotspot/cpu/riscv/gc/z/zBarrierSetAssembler_riscv.cpp index 8fbeaa45371..cbb918ade00 100644 --- a/src/hotspot/cpu/riscv/gc/z/zBarrierSetAssembler_riscv.cpp +++ b/src/hotspot/cpu/riscv/gc/z/zBarrierSetAssembler_riscv.cpp @@ -636,8 +636,20 @@ void ZBarrierSetAssembler::patch_barrier_relocation(address addr, int format) { ShouldNotReachHere(); } - // A full fence is generated before icache_flush by default in invalidate_word - ICache::invalidate_range(addr, bytes); + // If we are using UseCtxFencei no ICache invalidation is needed here. + // Instead every hart will preform an fence.i either by a Java thread + // (due to patching epoch will take it to slow path), + // or by the kernel when a Java thread is moved to a hart. + // The instruction streams changes must only happen before the disarm of + // the nmethod barrier. Where the disarm have a leading full two way fence. + // If this is performed during a safepoint, all Java threads will emit a fence.i + // before transitioning to 'Java', e.g. leaving native or the safepoint wait barrier. + if (!UseCtxFencei) { + // ICache invalidation is a serialization point. + // The above patching of instructions happens before the invalidation. + // Hence it have a leading full two way fence (wr, wr). + ICache::invalidate_range(addr, bytes); + } } #ifdef COMPILER2 diff --git a/src/hotspot/cpu/riscv/gc/z/z_riscv.ad b/src/hotspot/cpu/riscv/gc/z/z_riscv.ad index 4c94e504475..5b545fe8012 100644 --- a/src/hotspot/cpu/riscv/gc/z/z_riscv.ad +++ b/src/hotspot/cpu/riscv/gc/z/z_riscv.ad @@ -90,11 +90,11 @@ static void z_store_barrier(MacroAssembler* masm, const MachNode* node, Address %} // Load Pointer -instruct zLoadP(iRegPNoSp dst, memory mem, iRegPNoSp tmp) +instruct zLoadP(iRegPNoSp dst, memory mem, iRegPNoSp tmp, rFlagsReg cr) %{ match(Set dst (LoadP mem)); predicate(UseZGC && ZGenerational && n->as_Load()->barrier_data() != 0); - effect(TEMP dst, TEMP tmp); + effect(TEMP dst, TEMP tmp, KILL cr); ins_cost(4 * DEFAULT_COST); @@ -110,11 +110,11 @@ instruct zLoadP(iRegPNoSp dst, memory mem, iRegPNoSp tmp) %} // Store Pointer -instruct zStoreP(memory mem, iRegP src, iRegPNoSp tmp1, iRegPNoSp tmp2) +instruct zStoreP(memory mem, iRegP src, iRegPNoSp tmp1, iRegPNoSp tmp2, rFlagsReg cr) %{ predicate(UseZGC && ZGenerational && n->as_Store()->barrier_data() != 0); match(Set mem (StoreP mem src)); - effect(TEMP tmp1, TEMP tmp2); + effect(TEMP tmp1, TEMP tmp2, KILL cr); ins_cost(125); // XXX format %{ "sd $mem, $src\t# ptr" %} @@ -127,11 +127,11 @@ instruct zStoreP(memory mem, iRegP src, iRegPNoSp tmp1, iRegPNoSp tmp2) %} instruct zCompareAndSwapP(iRegINoSp res, indirect mem, iRegP oldval, iRegP newval, - iRegPNoSp oldval_tmp, iRegPNoSp newval_tmp, iRegPNoSp tmp1) %{ + iRegPNoSp oldval_tmp, iRegPNoSp newval_tmp, iRegPNoSp tmp1, rFlagsReg cr) %{ match(Set res (CompareAndSwapP mem (Binary oldval newval))); match(Set res (WeakCompareAndSwapP mem (Binary oldval newval))); predicate(UseZGC && ZGenerational && !needs_acquiring_load_reserved(n) && n->as_LoadStore()->barrier_data() != 0); - effect(TEMP oldval_tmp, TEMP newval_tmp, TEMP tmp1, TEMP_DEF res); + effect(TEMP oldval_tmp, TEMP newval_tmp, TEMP tmp1, TEMP_DEF res, KILL cr); ins_cost(2 * VOLATILE_REF_COST); @@ -150,11 +150,11 @@ instruct zCompareAndSwapP(iRegINoSp res, indirect mem, iRegP oldval, iRegP newva %} instruct zCompareAndSwapPAcq(iRegINoSp res, indirect mem, iRegP oldval, iRegP newval, - iRegPNoSp oldval_tmp, iRegPNoSp newval_tmp, iRegPNoSp tmp1) %{ + iRegPNoSp oldval_tmp, iRegPNoSp newval_tmp, iRegPNoSp tmp1, rFlagsReg cr) %{ match(Set res (CompareAndSwapP mem (Binary oldval newval))); match(Set res (WeakCompareAndSwapP mem (Binary oldval newval))); predicate(UseZGC && ZGenerational && needs_acquiring_load_reserved(n) && n->as_LoadStore()->barrier_data() != 0); - effect(TEMP oldval_tmp, TEMP newval_tmp, TEMP tmp1, TEMP_DEF res); + effect(TEMP oldval_tmp, TEMP newval_tmp, TEMP tmp1, TEMP_DEF res, KILL cr); ins_cost(2 * VOLATILE_REF_COST); @@ -173,10 +173,10 @@ instruct zCompareAndSwapPAcq(iRegINoSp res, indirect mem, iRegP oldval, iRegP ne %} instruct zCompareAndExchangeP(iRegPNoSp res, indirect mem, iRegP oldval, iRegP newval, - iRegPNoSp oldval_tmp, iRegPNoSp newval_tmp, iRegPNoSp tmp1) %{ + iRegPNoSp oldval_tmp, iRegPNoSp newval_tmp, iRegPNoSp tmp1, rFlagsReg cr) %{ match(Set res (CompareAndExchangeP mem (Binary oldval newval))); predicate(UseZGC && ZGenerational && !needs_acquiring_load_reserved(n) && n->as_LoadStore()->barrier_data() != 0); - effect(TEMP oldval_tmp, TEMP newval_tmp, TEMP tmp1, TEMP_DEF res); + effect(TEMP oldval_tmp, TEMP newval_tmp, TEMP tmp1, TEMP_DEF res, KILL cr); ins_cost(2 * VOLATILE_REF_COST); @@ -195,10 +195,10 @@ instruct zCompareAndExchangeP(iRegPNoSp res, indirect mem, iRegP oldval, iRegP n %} instruct zCompareAndExchangePAcq(iRegPNoSp res, indirect mem, iRegP oldval, iRegP newval, - iRegPNoSp oldval_tmp, iRegPNoSp newval_tmp, iRegPNoSp tmp1) %{ + iRegPNoSp oldval_tmp, iRegPNoSp newval_tmp, iRegPNoSp tmp1, rFlagsReg cr) %{ match(Set res (CompareAndExchangeP mem (Binary oldval newval))); predicate(UseZGC && ZGenerational && needs_acquiring_load_reserved(n) && n->as_LoadStore()->barrier_data() != 0); - effect(TEMP oldval_tmp, TEMP newval_tmp, TEMP tmp1, TEMP_DEF res); + effect(TEMP oldval_tmp, TEMP newval_tmp, TEMP tmp1, TEMP_DEF res, KILL cr); ins_cost(2 * VOLATILE_REF_COST); @@ -216,10 +216,10 @@ instruct zCompareAndExchangePAcq(iRegPNoSp res, indirect mem, iRegP oldval, iReg ins_pipe(pipe_slow); %} -instruct zGetAndSetP(indirect mem, iRegP newv, iRegPNoSp prev, iRegPNoSp tmp) %{ +instruct zGetAndSetP(indirect mem, iRegP newv, iRegPNoSp prev, iRegPNoSp tmp, rFlagsReg cr) %{ match(Set prev (GetAndSetP mem newv)); predicate(UseZGC && ZGenerational && !needs_acquiring_load_reserved(n) && n->as_LoadStore()->barrier_data() != 0); - effect(TEMP_DEF prev, TEMP tmp); + effect(TEMP_DEF prev, TEMP tmp, KILL cr); ins_cost(2 * VOLATILE_REF_COST); @@ -234,10 +234,10 @@ instruct zGetAndSetP(indirect mem, iRegP newv, iRegPNoSp prev, iRegPNoSp tmp) %{ ins_pipe(pipe_serial); %} -instruct zGetAndSetPAcq(indirect mem, iRegP newv, iRegPNoSp prev, iRegPNoSp tmp) %{ +instruct zGetAndSetPAcq(indirect mem, iRegP newv, iRegPNoSp prev, iRegPNoSp tmp, rFlagsReg cr) %{ match(Set prev (GetAndSetP mem newv)); predicate(UseZGC && ZGenerational && needs_acquiring_load_reserved(n) && n->as_LoadStore()->barrier_data() != 0); - effect(TEMP_DEF prev, TEMP tmp); + effect(TEMP_DEF prev, TEMP tmp, KILL cr); ins_cost(2 * VOLATILE_REF_COST); diff --git a/src/hotspot/cpu/riscv/globals_riscv.hpp b/src/hotspot/cpu/riscv/globals_riscv.hpp index c2585f2d161..dd31de14704 100644 --- a/src/hotspot/cpu/riscv/globals_riscv.hpp +++ b/src/hotspot/cpu/riscv/globals_riscv.hpp @@ -122,6 +122,8 @@ define_pd_global(intx, InlineSmallCode, 1000); product(bool, UseRVVForBigIntegerShiftIntrinsics, true, \ "Use RVV instructions for left/right shift of BigInteger") \ product(bool, UseTrampolines, false, EXPERIMENTAL, \ - "Far calls uses jal to trampoline.") + "Far calls uses jal to trampoline.") \ + product(bool, UseCtxFencei, false, EXPERIMENTAL, \ + "Use PR_RISCV_CTX_SW_FENCEI_ON to avoid explicit icache flush") #endif // CPU_RISCV_GLOBALS_RISCV_HPP diff --git a/src/hotspot/cpu/riscv/interp_masm_riscv.cpp b/src/hotspot/cpu/riscv/interp_masm_riscv.cpp index 06b7b780d13..3eb7abb5ee3 100644 --- a/src/hotspot/cpu/riscv/interp_masm_riscv.cpp +++ b/src/hotspot/cpu/riscv/interp_masm_riscv.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, 2020, Red Hat Inc. All rights reserved. * Copyright (c) 2020, 2023, Huawei Technologies Co., Ltd. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -750,8 +750,8 @@ void InterpreterMacroAssembler::lock_object(Register lock_reg) if (DiagnoseSyncOnValueBasedClasses != 0) { load_klass(tmp, obj_reg); - lwu(tmp, Address(tmp, Klass::access_flags_offset())); - test_bit(tmp, tmp, exact_log2(JVM_ACC_IS_VALUE_BASED_CLASS)); + lbu(tmp, Address(tmp, Klass::misc_flags_offset())); + test_bit(tmp, tmp, exact_log2(KlassFlags::_misc_is_value_based_class)); bnez(tmp, slow_case); } diff --git a/src/hotspot/cpu/riscv/interpreterRT_riscv.cpp b/src/hotspot/cpu/riscv/interpreterRT_riscv.cpp index 312e5cad963..a0ff429b87a 100644 --- a/src/hotspot/cpu/riscv/interpreterRT_riscv.cpp +++ b/src/hotspot/cpu/riscv/interpreterRT_riscv.cpp @@ -74,6 +74,16 @@ InterpreterRuntime::SignatureHandlerGenerator::SignatureHandlerGenerator( _stack_offset = 0; } +// The C ABI specifies: +// "integer scalars narrower than XLEN bits are widened according to the sign +// of their type up to 32 bits, then sign-extended to XLEN bits." +// Applies for both passed in register and stack. +// +// Java uses 32-bit stack slots; jint, jshort, jchar, jbyte uses one slot. +// Native uses 64-bit stack slots for all integer scalar types. +// +// lw loads the Java stack slot, sign-extends and +// sd store this widened integer into a 64 bit native stack slot. void InterpreterRuntime::SignatureHandlerGenerator::pass_int() { const Address src(from(), Interpreter::local_offset_in_bytes(offset())); @@ -82,7 +92,7 @@ void InterpreterRuntime::SignatureHandlerGenerator::pass_int() { __ lw(reg, src); } else { __ lw(x10, src); - __ sw(x10, Address(to(), next_stack_offset())); + __ sd(x10, Address(to(), next_stack_offset())); } } diff --git a/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp b/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp index a4eaab9b028..46701b6ede3 100644 --- a/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp +++ b/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp @@ -493,6 +493,7 @@ void MacroAssembler::clinit_barrier(Register klass, Register tmp, Label* L_fast_ // Fast path check: class is fully initialized lbu(tmp, Address(klass, InstanceKlass::init_state_offset())); + membar(MacroAssembler::LoadLoad | MacroAssembler::LoadStore); sub(tmp, tmp, InstanceKlass::fully_initialized); beqz(tmp, *L_fast_path); @@ -1454,6 +1455,105 @@ void MacroAssembler::update_word_crc32(Register crc, Register v, Register tmp1, xorr(crc, crc, tmp2); } + +#ifdef COMPILER2 +// This improvement (vectorization) is based on java.base/share/native/libzip/zlib/zcrc32.c. +// To make it, following steps are taken: +// 1. in zcrc32.c, modify N to 16 and related code, +// 2. re-generate the tables needed, we use tables of (N == 16, W == 4) +// 3. finally vectorize the code (original implementation in zcrc32.c is just scalar code). +// New tables for vector version is after table3. +void MacroAssembler::vector_update_crc32(Register crc, Register buf, Register len, + Register tmp1, Register tmp2, Register tmp3, Register tmp4, Register tmp5, + Register table0, Register table3) { + assert_different_registers(t1, crc, buf, len, tmp1, tmp2, tmp3, tmp4, tmp5, table0, table3); + const int N = 16, W = 4; + const int64_t single_table_size = 256; + const Register blks = tmp2; + const Register tmpTable = tmp3, tableN16 = tmp4; + const VectorRegister vcrc = v4, vword = v8, vtmp = v12; + Label VectorLoop; + Label LastBlock; + + add(tableN16, table3, 1*single_table_size*sizeof(juint), tmp1); + mv(tmp5, 0xff); + + if (MaxVectorSize == 16) { + vsetivli(zr, N, Assembler::e32, Assembler::m4, Assembler::ma, Assembler::ta); + } else if (MaxVectorSize == 32) { + vsetivli(zr, N, Assembler::e32, Assembler::m2, Assembler::ma, Assembler::ta); + } else { + assert(MaxVectorSize > 32, "sanity"); + vsetivli(zr, N, Assembler::e32, Assembler::m1, Assembler::ma, Assembler::ta); + } + + vmv_v_x(vcrc, zr); + vmv_s_x(vcrc, crc); + + // multiple of 64 + srli(blks, len, 6); + slli(t1, blks, 6); + sub(len, len, t1); + sub(blks, blks, 1); + blez(blks, LastBlock); + + bind(VectorLoop); + { + mv(tmpTable, tableN16); + + vle32_v(vword, buf); + vxor_vv(vword, vword, vcrc); + + addi(buf, buf, N*4); + + vand_vx(vtmp, vword, tmp5); + vsll_vi(vtmp, vtmp, 2); + vluxei32_v(vcrc, tmpTable, vtmp); + + mv(tmp1, 1); + for (int k = 1; k < W; k++) { + addi(tmpTable, tmpTable, single_table_size*4); + + slli(t1, tmp1, 3); + vsrl_vx(vtmp, vword, t1); + + vand_vx(vtmp, vtmp, tmp5); + vsll_vi(vtmp, vtmp, 2); + vluxei32_v(vtmp, tmpTable, vtmp); + + vxor_vv(vcrc, vcrc, vtmp); + + addi(tmp1, tmp1, 1); + } + + sub(blks, blks, 1); + bgtz(blks, VectorLoop); + } + + bind(LastBlock); + { + vle32_v(vtmp, buf); + vxor_vv(vcrc, vcrc, vtmp); + mv(crc, zr); + for (int i = 0; i < N; i++) { + vmv_x_s(tmp2, vcrc); + // in vmv_x_s, the value is sign-extended to SEW bits, but we need zero-extended here. + zext_w(tmp2, tmp2); + vslidedown_vi(vcrc, vcrc, 1); + xorr(crc, crc, tmp2); + for (int j = 0; j < W; j++) { + andr(t1, crc, tmp5); + shadd(t1, t1, table0, tmp1, 2); + lwu(t1, Address(t1, 0)); + srli(tmp2, crc, 8); + xorr(crc, tmp2, t1); + } + } + addi(buf, buf, N*4); + } +} +#endif // COMPILER2 + /** * @param crc register containing existing CRC (32-bit) * @param buf register pointing to input byte buffer (byte*) @@ -1465,33 +1565,41 @@ void MacroAssembler::kernel_crc32(Register crc, Register buf, Register len, Register table0, Register table1, Register table2, Register table3, Register tmp1, Register tmp2, Register tmp3, Register tmp4, Register tmp5, Register tmp6) { assert_different_registers(crc, buf, len, table0, table1, table2, table3, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6); - Label L_by16_loop, L_unroll_loop, L_unroll_loop_entry, L_by4, L_by4_loop, L_by1, L_by1_loop, L_exit; + Label L_vector_entry, + L_unroll_loop, + L_by4_loop_entry, L_by4_loop, + L_by1_loop, L_exit; + const int64_t single_table_size = 256; const int64_t unroll = 16; const int64_t unroll_words = unroll*wordSize; mv(tmp5, right_32_bits); - subw(len, len, unroll_words); andn(crc, tmp5, crc); const ExternalAddress table_addr = StubRoutines::crc_table_addr(); la(table0, table_addr); - add(table1, table0, 1*256*sizeof(juint), tmp1); - add(table2, table0, 2*256*sizeof(juint), tmp1); - add(table3, table2, 1*256*sizeof(juint), tmp1); + add(table1, table0, 1*single_table_size*sizeof(juint), tmp1); + add(table2, table0, 2*single_table_size*sizeof(juint), tmp1); + add(table3, table2, 1*single_table_size*sizeof(juint), tmp1); - bge(len, zr, L_unroll_loop_entry); - addiw(len, len, unroll_words-4); - bge(len, zr, L_by4_loop); - addiw(len, len, 4); - bgt(len, zr, L_by1_loop); - j(L_exit); +#ifdef COMPILER2 + if (UseRVV) { + const int64_t tmp_limit = MaxVectorSize >= 32 ? unroll_words*3 : unroll_words*5; + mv(tmp1, tmp_limit); + bge(len, tmp1, L_vector_entry); + } +#endif // COMPILER2 + + mv(tmp1, unroll_words); + blt(len, tmp1, L_by4_loop_entry); + + const Register loop_buf_end = tmp3; align(CodeEntryAlignment); - bind(L_unroll_loop_entry); - const Register buf_end = tmp3; - add(buf_end, buf, len); // buf_end will be used as endpoint for loop below + // Entry for L_unroll_loop + add(loop_buf_end, buf, len); // loop_buf_end will be used as endpoint for loop below andi(len, len, unroll_words-1); // len = (len % unroll_words) - sub(len, len, unroll_words); // Length after all iterations + sub(loop_buf_end, loop_buf_end, len); bind(L_unroll_loop); for (int i = 0; i < unroll; i++) { ld(tmp1, Address(buf, i*wordSize)); @@ -1500,44 +1608,52 @@ void MacroAssembler::kernel_crc32(Register crc, Register buf, Register len, } addi(buf, buf, unroll_words); - ble(buf, buf_end, L_unroll_loop); - addiw(len, len, unroll_words-4); - bge(len, zr, L_by4_loop); - addiw(len, len, 4); - bgt(len, zr, L_by1_loop); - j(L_exit); + blt(buf, loop_buf_end, L_unroll_loop); + bind(L_by4_loop_entry); + mv(tmp1, 4); + blt(len, tmp1, L_by1_loop); + add(loop_buf_end, buf, len); // loop_buf_end will be used as endpoint for loop below + andi(len, len, 3); + sub(loop_buf_end, loop_buf_end, len); bind(L_by4_loop); lwu(tmp1, Address(buf)); update_word_crc32(crc, tmp1, tmp2, tmp4, tmp6, table0, table1, table2, table3, false); - subw(len, len, 4); addi(buf, buf, 4); - bge(len, zr, L_by4_loop); - addiw(len, len, 4); - ble(len, zr, L_exit); + blt(buf, loop_buf_end, L_by4_loop); bind(L_by1_loop); + beqz(len, L_exit); + subw(len, len, 1); lwu(tmp1, Address(buf)); andi(tmp2, tmp1, right_8_bits); update_byte_crc32(crc, tmp2, table0); - ble(len, zr, L_exit); + beqz(len, L_exit); subw(len, len, 1); srli(tmp2, tmp1, 8); andi(tmp2, tmp2, right_8_bits); update_byte_crc32(crc, tmp2, table0); - ble(len, zr, L_exit); + beqz(len, L_exit); subw(len, len, 1); srli(tmp2, tmp1, 16); andi(tmp2, tmp2, right_8_bits); update_byte_crc32(crc, tmp2, table0); - ble(len, zr, L_exit); - srli(tmp2, tmp1, 24); - andi(tmp2, tmp2, right_8_bits); - update_byte_crc32(crc, tmp2, table0); +#ifdef COMPILER2 + // put vector code here, otherwise "offset is too large" error occurs. + if (UseRVV) { + // only need to jump exit when UseRVV == true, it's a jump from end of block `L_by1_loop`. + j(L_exit); + + bind(L_vector_entry); + vector_update_crc32(crc, buf, len, tmp1, tmp2, tmp3, tmp4, tmp6, table0, table3); + + bgtz(len, L_by4_loop_entry); + } +#endif // COMPILER2 bind(L_exit); andn(crc, tmp5, crc); @@ -1853,9 +1969,9 @@ int MacroAssembler::patch_oop(address insn_addr, address o) { void MacroAssembler::reinit_heapbase() { if (UseCompressedOops) { if (Universe::is_fully_initialized()) { - mv(xheapbase, CompressedOops::ptrs_base()); + mv(xheapbase, CompressedOops::base()); } else { - ExternalAddress target(CompressedOops::ptrs_base_addr()); + ExternalAddress target(CompressedOops::base_addr()); relocate(target.rspec(), [&] { int32_t offset; la(xheapbase, target.target(), offset); @@ -1968,23 +2084,11 @@ void MacroAssembler::addw(Register Rd, Register Rn, int32_t increment, Register } void MacroAssembler::sub(Register Rd, Register Rn, int64_t decrement, Register temp) { - if (is_simm12(-decrement)) { - addi(Rd, Rn, -decrement); - } else { - assert_different_registers(Rn, temp); - li(temp, decrement); - sub(Rd, Rn, temp); - } + add(Rd, Rn, -decrement, temp); } void MacroAssembler::subw(Register Rd, Register Rn, int32_t decrement, Register temp) { - if (is_simm12(-decrement)) { - addiw(Rd, Rn, -decrement); - } else { - assert_different_registers(Rn, temp); - li(temp, decrement); - subw(Rd, Rn, temp); - } + addw(Rd, Rn, -decrement, temp); } void MacroAssembler::andrw(Register Rd, Register Rs1, Register Rs2) { @@ -2844,7 +2948,7 @@ int MacroAssembler::corrected_idivq(Register result, Register rs1, Register rs2, return idivq_offset; } -// Look up the method for a megamorpic invkkeinterface call. +// Look up the method for a megamorphic invokeinterface call. // The target method is determined by . // The receiver klass is in recv_klass. // On success, the result will be in method_result, and execution falls through. @@ -2859,9 +2963,9 @@ void MacroAssembler::lookup_interface_method(Register recv_klass, assert_different_registers(recv_klass, intf_klass, scan_tmp); assert_different_registers(method_result, intf_klass, scan_tmp); assert(recv_klass != method_result || !return_method, - "recv_klass can be destroyed when mehtid isn't needed"); + "recv_klass can be destroyed when method isn't needed"); assert(itable_index.is_constant() || itable_index.as_register() == method_result, - "caller must be same register for non-constant itable index as for method"); + "caller must use same register for non-constant itable index as for method"); // Compute start of first itableOffsetEntry (which is at the end of the vtable). int vtable_base = in_bytes(Klass::vtable_start_offset()); @@ -3054,6 +3158,13 @@ void MacroAssembler::membar(uint32_t order_constraint) { } } +void MacroAssembler::cmodx_fence() { + BLOCK_COMMENT("cmodx fence"); + if (VM_Version::supports_fencei_barrier()) { + Assembler::fencei(); + } +} + // Form an address from base + offset in Rd. Rd my or may not // actually be used: you must use the Address that is returned. It // is up to you to ensure that the shift provided matches the size @@ -5526,15 +5637,21 @@ static int reg2offset_out(VMReg r) { return (r->reg2stack() + SharedRuntime::out_preserve_stack_slots()) * VMRegImpl::stack_slot_size; } -// On 64 bit we will store integer like items to the stack as -// 64 bits items (riscv64 abi) even though java would only store -// 32bits for a parameter. On 32bit it will simply be 32 bits -// So this routine will do 32->32 on 32bit and 32->64 on 64bit +// The C ABI specifies: +// "integer scalars narrower than XLEN bits are widened according to the sign +// of their type up to 32 bits, then sign-extended to XLEN bits." +// Applies for both passed in register and stack. +// +// Java uses 32-bit stack slots; jint, jshort, jchar, jbyte uses one slot. +// Native uses 64-bit stack slots for all integer scalar types. +// +// lw loads the Java stack slot, sign-extends and +// sd store this widened integer into a 64 bit native stack slot. void MacroAssembler::move32_64(VMRegPair src, VMRegPair dst, Register tmp) { if (src.first()->is_stack()) { if (dst.first()->is_stack()) { // stack to stack - ld(tmp, Address(fp, reg2offset_in(src.first()))); + lw(tmp, Address(fp, reg2offset_in(src.first()))); sd(tmp, Address(sp, reg2offset_out(dst.first()))); } else { // stack to reg diff --git a/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp b/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp index c3161beea11..fd174f241eb 100644 --- a/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp +++ b/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp @@ -431,6 +431,8 @@ class MacroAssembler: public Assembler { } } + void cmodx_fence(); + void pause() { Assembler::fence(w, 0); } @@ -1321,6 +1323,10 @@ public: void update_byte_crc32(Register crc, Register val, Register table); #ifdef COMPILER2 + void vector_update_crc32(Register crc, Register buf, Register len, + Register tmp1, Register tmp2, Register tmp3, Register tmp4, Register tmp5, + Register table0, Register table3); + void mul_add(Register out, Register in, Register offset, Register len, Register k, Register tmp); void wide_mul(Register prod_lo, Register prod_hi, Register n, Register m); @@ -1350,7 +1356,7 @@ public: Register tmp1, Register tmp2, Register tmp3, Register tmp4, Register tmp5, Register tmp6, Register product_hi); -#endif +#endif // COMPILER2 void inflate_lo32(Register Rd, Register Rs, Register tmp1 = t0, Register tmp2 = t1); void inflate_hi32(Register Rd, Register Rs, Register tmp1 = t0, Register tmp2 = t1); diff --git a/src/hotspot/cpu/riscv/methodHandles_riscv.cpp b/src/hotspot/cpu/riscv/methodHandles_riscv.cpp index deeb771d83b..f638db9f0bf 100644 --- a/src/hotspot/cpu/riscv/methodHandles_riscv.cpp +++ b/src/hotspot/cpu/riscv/methodHandles_riscv.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, Red Hat Inc. All rights reserved. * Copyright (c) 2020, 2023, Huawei Technologies Co., Ltd. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -28,6 +28,7 @@ #include "asm/macroAssembler.hpp" #include "classfile/javaClasses.inline.hpp" #include "classfile/vmClasses.hpp" +#include "compiler/disassembler.hpp" #include "interpreter/interpreter.hpp" #include "interpreter/interpreterRuntime.hpp" #include "memory/allocation.inline.hpp" @@ -37,7 +38,7 @@ #include "runtime/frame.inline.hpp" #include "runtime/stubRoutines.hpp" -#define __ _masm-> +#define __ Disassembler::hook(__FILE__, __LINE__, _masm)-> #ifdef PRODUCT #define BLOCK_COMMENT(str) /* nothing */ @@ -444,7 +445,6 @@ void MethodHandles::generate_method_handle_dispatch(MacroAssembler* _masm, __ far_jump(RuntimeAddress(SharedRuntime::throw_IncompatibleClassChangeError_entry())); } } - } #ifndef PRODUCT diff --git a/src/hotspot/cpu/riscv/relocInfo_riscv.cpp b/src/hotspot/cpu/riscv/relocInfo_riscv.cpp index d0903c96e22..18b4302c7e6 100644 --- a/src/hotspot/cpu/riscv/relocInfo_riscv.cpp +++ b/src/hotspot/cpu/riscv/relocInfo_riscv.cpp @@ -55,7 +55,21 @@ void Relocation::pd_set_data_value(address x, bool verify_only) { bytes = MacroAssembler::pd_patch_instruction_size(addr(), x); break; } - ICache::invalidate_range(addr(), bytes); + + // If we are using UseCtxFencei no ICache invalidation is needed here. + // Instead every hart will preform an fence.i either by a Java thread + // (due to patching epoch will take it to slow path), + // or by the kernel when a Java thread is moved to a hart. + // The instruction streams changes must only happen before the disarm of + // the nmethod barrier. Where the disarm have a leading full two way fence. + // If this is performed during a safepoint, all Java threads will emit a fence.i + // before transitioning to 'Java', e.g. leaving native or the safepoint wait barrier. + if (!UseCtxFencei) { + // ICache invalidation is a serialization point. + // The above patching of instructions happens before the invalidation. + // Hence it have a leading full two way fence (wr, wr). + ICache::invalidate_range(addr(), bytes); + } } address Relocation::pd_call_destination(address orig_addr) { diff --git a/src/hotspot/cpu/riscv/riscv.ad b/src/hotspot/cpu/riscv/riscv.ad index db010c9c6c8..54d1f1c0573 100644 --- a/src/hotspot/cpu/riscv/riscv.ad +++ b/src/hotspot/cpu/riscv/riscv.ad @@ -1920,6 +1920,18 @@ bool Matcher::match_rule_supported(int opcode) { case Op_EncodeISOArray: return UseRVV; + // Current test shows that, it brings performance gain when MaxVectorSize >= 32, but brings + // regression when MaxVectorSize == 16. So only enable the intrinsic when MaxVectorSize >= 32. + case Op_RoundVF: + return UseRVV && MaxVectorSize >= 32; + + // For double, current test shows that even with MaxVectorSize == 32, there is still some regression. + // Although there is no hardware to verify it for now, from the trend of performance data on hardwares + // (with vlenb == 16 and 32 respectively), it's promising to bring better performance rather than + // regression for double when MaxVectorSize == 64+. So only enable the intrinsic when MaxVectorSize >= 64. + case Op_RoundVD: + return UseRVV && MaxVectorSize >= 64; + case Op_PopCountI: case Op_PopCountL: return UsePopCountInstruction; @@ -1954,18 +1966,18 @@ const RegMask* Matcher::predicate_reg_mask(void) { return &_VMASK_REG_mask; } -const TypeVectMask* Matcher::predicate_reg_type(const Type* elemTy, int length) { - return new TypeVectMask(elemTy, length); -} - // Vector calling convention not yet implemented. bool Matcher::supports_vector_calling_convention(void) { - return false; + return EnableVectorSupport && UseVectorStubs; } OptoRegPair Matcher::vector_return_value(uint ideal_reg) { - Unimplemented(); - return OptoRegPair(0, 0); + assert(EnableVectorSupport && UseVectorStubs, "sanity"); + assert(ideal_reg == Op_VecA, "sanity"); + // check more info at https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-cc.adoc + int lo = V8_num; + int hi = V8_K_num; + return OptoRegPair(hi, lo); } // Is this branch offset short enough that a short branch can be used? @@ -2212,7 +2224,8 @@ bool Matcher::pd_clone_node(Node* n, Node* m, Matcher::MStack& mstack) { assert_cond(m != nullptr); if (is_vshift_con_pattern(n, m) || // ShiftV src (ShiftCntV con) is_vector_bitwise_not_pattern(n, m) || - is_vector_scalar_bitwise_pattern(n, m)) { + is_vector_scalar_bitwise_pattern(n, m) || + is_encode_and_store_pattern(n, m)) { mstack.push(m, Visit); return true; } @@ -4773,6 +4786,7 @@ instruct loadP(iRegPNoSp dst, memory mem) // Load Compressed Pointer instruct loadN(iRegNNoSp dst, memory mem) %{ + predicate(n->as_Load()->barrier_data() == 0); match(Set dst (LoadN mem)); ins_cost(LOAD_COST); @@ -5021,41 +5035,6 @@ instruct loadConD0(fRegD dst, immD0 con) %{ ins_pipe(fp_load_constant_d); %} -// Store Instructions -// Store CMS card-mark Immediate -instruct storeimmCM0(immI0 zero, memory mem) -%{ - match(Set mem (StoreCM mem zero)); - - ins_cost(STORE_COST); - format %{ "storestore (elided)\n\t" - "sb zr, $mem\t# byte, #@storeimmCM0" %} - - ins_encode %{ - __ sb(zr, Address(as_Register($mem$$base), $mem$$disp)); - %} - - ins_pipe(istore_mem); -%} - -// Store CMS card-mark Immediate with intervening StoreStore -// needed when using CMS with no conditional card marking -instruct storeimmCM0_ordered(immI0 zero, memory mem) -%{ - match(Set mem (StoreCM mem zero)); - - ins_cost(ALU_COST + STORE_COST); - format %{ "membar(StoreStore)\n\t" - "sb zr, $mem\t# byte, #@storeimmCM0_ordered" %} - - ins_encode %{ - __ membar(MacroAssembler::LoadStore | MacroAssembler::StoreStore); - __ sb(zr, Address(as_Register($mem$$base), $mem$$disp)); - %} - - ins_pipe(istore_mem); -%} - // Store Byte instruct storeB(iRegIorL2I src, memory mem) %{ @@ -5208,6 +5187,7 @@ instruct storeimmP0(immP0 zero, memory mem) // Store Compressed Pointer instruct storeN(iRegN src, memory mem) %{ + predicate(n->as_Store()->barrier_data() == 0); match(Set mem (StoreN mem src)); ins_cost(STORE_COST); @@ -5222,6 +5202,7 @@ instruct storeN(iRegN src, memory mem) instruct storeImmN0(immN0 zero, memory mem) %{ + predicate(n->as_Store()->barrier_data() == 0); match(Set mem (StoreN mem zero)); ins_cost(STORE_COST); @@ -5412,6 +5393,7 @@ instruct compareAndSwapP(iRegINoSp res, indirect mem, iRegP oldval, iRegP newval instruct compareAndSwapN(iRegINoSp res, indirect mem, iRegN oldval, iRegN newval) %{ + predicate(n->as_LoadStore()->barrier_data() == 0); match(Set res (CompareAndSwapN mem (Binary oldval newval))); ins_cost(LOAD_COST + STORE_COST + ALU_COST * 8 + BRANCH_COST * 4); @@ -5533,7 +5515,7 @@ instruct compareAndSwapPAcq(iRegINoSp res, indirect mem, iRegP oldval, iRegP new instruct compareAndSwapNAcq(iRegINoSp res, indirect mem, iRegN oldval, iRegN newval) %{ - predicate(needs_acquiring_load_reserved(n)); + predicate(needs_acquiring_load_reserved(n) && n->as_LoadStore()->barrier_data() == 0); match(Set res (CompareAndSwapN mem (Binary oldval newval))); @@ -5641,6 +5623,7 @@ instruct compareAndExchangeL(iRegLNoSp res, indirect mem, iRegL oldval, iRegL ne instruct compareAndExchangeN(iRegNNoSp res, indirect mem, iRegN oldval, iRegN newval) %{ + predicate(n->as_LoadStore()->barrier_data() == 0); match(Set res (CompareAndExchangeN mem (Binary oldval newval))); ins_cost(LOAD_COST + STORE_COST + BRANCH_COST * 3 + ALU_COST * 3); @@ -5774,7 +5757,7 @@ instruct compareAndExchangeLAcq(iRegLNoSp res, indirect mem, iRegL oldval, iRegL instruct compareAndExchangeNAcq(iRegNNoSp res, indirect mem, iRegN oldval, iRegN newval) %{ - predicate(needs_acquiring_load_reserved(n)); + predicate(needs_acquiring_load_reserved(n) && n->as_LoadStore()->barrier_data() == 0); match(Set res (CompareAndExchangeN mem (Binary oldval newval))); @@ -5902,6 +5885,7 @@ instruct weakCompareAndSwapL(iRegINoSp res, indirect mem, iRegL oldval, iRegL ne instruct weakCompareAndSwapN(iRegINoSp res, indirect mem, iRegN oldval, iRegN newval) %{ + predicate(n->as_LoadStore()->barrier_data() == 0); match(Set res (WeakCompareAndSwapN mem (Binary oldval newval))); ins_cost(LOAD_COST + STORE_COST + BRANCH_COST * 2 + ALU_COST * 4); @@ -6033,7 +6017,7 @@ instruct weakCompareAndSwapLAcq(iRegINoSp res, indirect mem, iRegL oldval, iRegL instruct weakCompareAndSwapNAcq(iRegINoSp res, indirect mem, iRegN oldval, iRegN newval) %{ - predicate(needs_acquiring_load_reserved(n)); + predicate(needs_acquiring_load_reserved(n) && n->as_LoadStore()->barrier_data() == 0); match(Set res (WeakCompareAndSwapN mem (Binary oldval newval))); @@ -6105,6 +6089,8 @@ instruct get_and_setL(indirect mem, iRegL newv, iRegLNoSp prev) instruct get_and_setN(indirect mem, iRegN newv, iRegINoSp prev) %{ + predicate(n->as_LoadStore()->barrier_data() == 0); + match(Set prev (GetAndSetN mem newv)); ins_cost(ALU_COST); @@ -6170,7 +6156,7 @@ instruct get_and_setLAcq(indirect mem, iRegL newv, iRegLNoSp prev) instruct get_and_setNAcq(indirect mem, iRegN newv, iRegINoSp prev) %{ - predicate(needs_acquiring_load_reserved(n)); + predicate(needs_acquiring_load_reserved(n) && n->as_LoadStore()->barrier_data() == 0); match(Set prev (GetAndSetN mem newv)); @@ -10054,6 +10040,23 @@ instruct CallLeafDirect(method meth, rFlagsReg cr) ins_pipe(pipe_class_call); %} +// Call Runtime Instruction without safepoint and with vector arguments + +instruct CallLeafDirectVector(method meth, rFlagsReg cr) +%{ + match(CallLeafVector); + + effect(USE meth, KILL cr); + + ins_cost(BRANCH_COST); + + format %{ "CALL, runtime leaf vector $meth" %} + + ins_encode(riscv_enc_java_to_runtime(meth)); + + ins_pipe(pipe_class_call); +%} + // Call Runtime Instruction instruct CallLeafNoFPDirect(method meth, rFlagsReg cr) diff --git a/src/hotspot/cpu/riscv/riscv_v.ad b/src/hotspot/cpu/riscv/riscv_v.ad index 1a51d7583c9..510c0ff5d46 100644 --- a/src/hotspot/cpu/riscv/riscv_v.ad +++ b/src/hotspot/cpu/riscv/riscv_v.ad @@ -4715,6 +4715,34 @@ instruct vsignum_reg(vReg dst, vReg zero, vReg one, vRegMask_V0 v0) %{ ins_pipe(pipe_slow); %} +// ---------------- Round float/double Vector Operations ---------------- + +instruct vround_f(vReg dst, vReg src, fRegF tmp, vRegMask_V0 v0) %{ + match(Set dst (RoundVF src)); + effect(TEMP_DEF dst, TEMP tmp, TEMP v0); + format %{ "java_round_float_v $dst, $src\t" %} + ins_encode %{ + BasicType bt = Matcher::vector_element_basic_type(this); + uint vector_length = Matcher::vector_length(this); + __ java_round_float_v(as_VectorRegister($dst$$reg), as_VectorRegister($src$$reg), + as_FloatRegister($tmp$$reg), bt, vector_length); + %} + ins_pipe(pipe_slow); +%} + +instruct vround_d(vReg dst, vReg src, fRegD tmp, vRegMask_V0 v0) %{ + match(Set dst (RoundVD src)); + effect(TEMP_DEF dst, TEMP tmp, TEMP v0); + format %{ "java_round_double_v $dst, $src\t" %} + ins_encode %{ + BasicType bt = Matcher::vector_element_basic_type(this); + uint vector_length = Matcher::vector_length(this); + __ java_round_double_v(as_VectorRegister($dst$$reg), as_VectorRegister($src$$reg), + as_FloatRegister($tmp$$reg), bt, vector_length); + %} + ins_pipe(pipe_slow); +%} + // -------------------------------- Reverse Bytes Vector Operations ------------------------ instruct vreverse_bytes_masked(vReg dst_src, vRegMask_V0 v0) %{ @@ -4867,11 +4895,10 @@ instruct gather_loadS(vReg dst, indirect mem, vReg idx) %{ effect(TEMP_DEF dst); format %{ "gather_loadS $dst, $mem, $idx" %} ins_encode %{ - __ vmv1r_v(as_VectorRegister($dst$$reg), as_VectorRegister($idx$$reg)); BasicType bt = Matcher::vector_element_basic_type(this); Assembler::SEW sew = Assembler::elemtype_to_sew(bt); __ vsetvli_helper(bt, Matcher::vector_length(this)); - __ vsll_vi(as_VectorRegister($dst$$reg), as_VectorRegister($dst$$reg), (int)sew); + __ vsll_vi(as_VectorRegister($dst$$reg), as_VectorRegister($idx$$reg), (int)sew); __ vluxei32_v(as_VectorRegister($dst$$reg), as_Register($mem$$base), as_VectorRegister($dst$$reg)); %} @@ -4901,11 +4928,10 @@ instruct gather_loadS_masked(vReg dst, indirect mem, vReg idx, vRegMask_V0 v0, v effect(TEMP_DEF dst, TEMP tmp); format %{ "gather_loadS_masked $dst, $mem, $idx, $v0\t# KILL $tmp" %} ins_encode %{ - __ vmv1r_v(as_VectorRegister($tmp$$reg), as_VectorRegister($idx$$reg)); BasicType bt = Matcher::vector_element_basic_type(this); Assembler::SEW sew = Assembler::elemtype_to_sew(bt); __ vsetvli_helper(bt, Matcher::vector_length(this)); - __ vsll_vi(as_VectorRegister($tmp$$reg), as_VectorRegister($tmp$$reg), (int)sew); + __ vsll_vi(as_VectorRegister($tmp$$reg), as_VectorRegister($idx$$reg), (int)sew); __ vxor_vv(as_VectorRegister($dst$$reg), as_VectorRegister($dst$$reg), as_VectorRegister($dst$$reg)); __ vluxei32_v(as_VectorRegister($dst$$reg), as_Register($mem$$base), @@ -4941,11 +4967,10 @@ instruct scatter_storeS(indirect mem, vReg src, vReg idx, vReg tmp) %{ effect(TEMP tmp); format %{ "scatter_storeS $mem, $idx, $src\t# KILL $tmp" %} ins_encode %{ - __ vmv1r_v(as_VectorRegister($tmp$$reg), as_VectorRegister($idx$$reg)); BasicType bt = Matcher::vector_element_basic_type(this, $src); Assembler::SEW sew = Assembler::elemtype_to_sew(bt); __ vsetvli_helper(bt, Matcher::vector_length(this, $src)); - __ vsll_vi(as_VectorRegister($tmp$$reg), as_VectorRegister($tmp$$reg), (int)sew); + __ vsll_vi(as_VectorRegister($tmp$$reg), as_VectorRegister($idx$$reg), (int)sew); __ vsuxei32_v(as_VectorRegister($src$$reg), as_Register($mem$$base), as_VectorRegister($tmp$$reg)); %} @@ -4975,11 +5000,10 @@ instruct scatter_storeS_masked(indirect mem, vReg src, vReg idx, vRegMask_V0 v0, effect(TEMP tmp); format %{ "scatter_storeS_masked $mem, $idx, $src, $v0\t# KILL $tmp" %} ins_encode %{ - __ vmv1r_v(as_VectorRegister($tmp$$reg), as_VectorRegister($idx$$reg)); BasicType bt = Matcher::vector_element_basic_type(this, $src); Assembler::SEW sew = Assembler::elemtype_to_sew(bt); __ vsetvli_helper(bt, Matcher::vector_length(this, $src)); - __ vsll_vi(as_VectorRegister($tmp$$reg), as_VectorRegister($tmp$$reg), (int)sew); + __ vsll_vi(as_VectorRegister($tmp$$reg), as_VectorRegister($idx$$reg), (int)sew); __ vsuxei32_v(as_VectorRegister($src$$reg), as_Register($mem$$base), as_VectorRegister($tmp$$reg), Assembler::v0_t); %} diff --git a/src/hotspot/cpu/riscv/sharedRuntime_riscv.cpp b/src/hotspot/cpu/riscv/sharedRuntime_riscv.cpp index ffd904aed47..2b629fcfcb2 100644 --- a/src/hotspot/cpu/riscv/sharedRuntime_riscv.cpp +++ b/src/hotspot/cpu/riscv/sharedRuntime_riscv.cpp @@ -666,7 +666,20 @@ AdapterHandlerEntry* SharedRuntime::generate_i2c2i_adapters(MacroAssembler *masm int SharedRuntime::vector_calling_convention(VMRegPair *regs, uint num_bits, uint total_args_passed) { - Unimplemented(); + assert(total_args_passed <= Argument::n_vector_register_parameters_c, "unsupported"); + assert(num_bits >= 64 && num_bits <= 2048 && is_power_of_2(num_bits), "unsupported"); + + // check more info at https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-cc.adoc + static const VectorRegister VEC_ArgReg[Argument::n_vector_register_parameters_c] = { + v8, v9, v10, v11, v12, v13, v14, v15, + v16, v17, v18, v19, v20, v21, v22, v23 + }; + + const int next_reg_val = 3; + for (uint i = 0; i < total_args_passed; i++) { + VMReg vmreg = VEC_ArgReg[i]->as_VMReg(); + regs[i].set_pair(vmreg->next(next_reg_val), vmreg); + } return 0; } @@ -2057,7 +2070,8 @@ void SharedRuntime::generate_deopt_blob() { pad += 512; // Increase the buffer size when compiling for JVMCI } #endif - CodeBuffer buffer("deopt_blob", 2048 + pad, 1024); + const char* name = SharedRuntime::stub_name(SharedStubId::deopt_id); + CodeBuffer buffer(name, 2048 + pad, 1024); MacroAssembler* masm = new MacroAssembler(&buffer); int frame_size_in_words = -1; OopMap* map = nullptr; @@ -2109,7 +2123,7 @@ void SharedRuntime::generate_deopt_blob() { int reexecute_offset = __ pc() - start; #if INCLUDE_JVMCI && !defined(COMPILER1) - if (EnableJVMCI && UseJVMCICompiler) { + if (UseJVMCICompiler) { // JVMCI does not use this kind of deoptimization __ should_not_reach_here(); } @@ -2435,22 +2449,25 @@ uint SharedRuntime::out_preserve_stack_slots() { // Generate a special Compile2Runtime blob that saves all registers, // and setup oopmap. // -SafepointBlob* SharedRuntime::generate_handler_blob(address call_ptr, int poll_type) { +SafepointBlob* SharedRuntime::generate_handler_blob(SharedStubId id, address call_ptr) { + assert(is_polling_page_id(id), "expected a polling page stub id"); + ResourceMark rm; OopMapSet *oop_maps = new OopMapSet(); assert_cond(oop_maps != nullptr); OopMap* map = nullptr; // Allocate space for the code. Setup code generation tools. - CodeBuffer buffer("handler_blob", 2048, 1024); + const char* name = SharedRuntime::stub_name(id); + CodeBuffer buffer(name, 2048, 1024); MacroAssembler* masm = new MacroAssembler(&buffer); assert_cond(masm != nullptr); address start = __ pc(); address call_pc = nullptr; int frame_size_in_words = -1; - bool cause_return = (poll_type == POLL_AT_RETURN); - RegisterSaver reg_saver(poll_type == POLL_AT_VECTOR_LOOP /* save_vectors */); + bool cause_return = (id == SharedStubId::polling_page_return_handler_id); + RegisterSaver reg_saver(id == SharedStubId::polling_page_vectors_safepoint_handler_id /* save_vectors */); // Save Integer and Float registers. map = reg_saver.save_live_registers(masm, 0, &frame_size_in_words); @@ -2556,12 +2573,14 @@ SafepointBlob* SharedRuntime::generate_handler_blob(address call_ptr, int poll_t // but since this is generic code we don't know what they are and the caller // must do any gc of the args. // -RuntimeStub* SharedRuntime::generate_resolve_blob(address destination, const char* name) { +RuntimeStub* SharedRuntime::generate_resolve_blob(SharedStubId id, address destination) { assert(StubRoutines::forward_exception_entry() != nullptr, "must be generated before"); + assert(is_resolve_id(id), "expected a resolve stub id"); // allocate space for the code ResourceMark rm; + const char* name = SharedRuntime::stub_name(id); CodeBuffer buffer(name, 1000, 512); MacroAssembler* masm = new MacroAssembler(&buffer); assert_cond(masm != nullptr); @@ -2652,7 +2671,11 @@ RuntimeStub* SharedRuntime::generate_resolve_blob(address destination, const cha // otherwise assume that stack unwinding will be initiated, so // caller saved registers were assumed volatile in the compiler. -RuntimeStub* SharedRuntime::generate_throw_exception(const char* name, address runtime_entry) { +RuntimeStub* SharedRuntime::generate_throw_exception(SharedStubId id, address runtime_entry) { + assert(is_throw_id(id), "expected a throw stub id"); + + const char* name = SharedRuntime::stub_name(id); + // Information about frame layout at time of blocking runtime call. // Note that we only have to preserve callee-saved registers since // the compilers are responsible for supplying a continuation point @@ -2759,7 +2782,8 @@ RuntimeStub* SharedRuntime::generate_jfr_write_checkpoint() { int insts_size = 1024; int locs_size = 64; - CodeBuffer code("jfr_write_checkpoint", insts_size, locs_size); + const char* name = SharedRuntime::stub_name(SharedStubId::jfr_write_checkpoint_id); + CodeBuffer code(name, insts_size, locs_size); OopMapSet* oop_maps = new OopMapSet(); MacroAssembler* masm = new MacroAssembler(&code); @@ -2779,7 +2803,7 @@ RuntimeStub* SharedRuntime::generate_jfr_write_checkpoint() { oop_maps->add_gc_map(the_pc - start, map); RuntimeStub* stub = // codeBlob framesize is in words (not VMRegImpl::slot_size) - RuntimeStub::new_runtime_stub("jfr_write_checkpoint", &code, frame_complete, + RuntimeStub::new_runtime_stub(name, &code, frame_complete, (framesize >> (LogBytesPerWord - LogBytesPerInt)), oop_maps, false); return stub; @@ -2797,7 +2821,8 @@ RuntimeStub* SharedRuntime::generate_jfr_return_lease() { int insts_size = 1024; int locs_size = 64; - CodeBuffer code("jfr_return_lease", insts_size, locs_size); + const char* name = SharedRuntime::stub_name(SharedStubId::jfr_return_lease_id); + CodeBuffer code(name, insts_size, locs_size); OopMapSet* oop_maps = new OopMapSet(); MacroAssembler* masm = new MacroAssembler(&code); @@ -2816,7 +2841,7 @@ RuntimeStub* SharedRuntime::generate_jfr_return_lease() { oop_maps->add_gc_map(the_pc - start, map); RuntimeStub* stub = // codeBlob framesize is in words (not VMRegImpl::slot_size) - RuntimeStub::new_runtime_stub("jfr_return_lease", &code, frame_complete, + RuntimeStub::new_runtime_stub(name, &code, frame_complete, (framesize >> (LogBytesPerWord - LogBytesPerInt)), oop_maps, false); return stub; diff --git a/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp b/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp index 8792dea7de5..bdb92e0b835 100644 --- a/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp +++ b/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp @@ -2428,6 +2428,14 @@ class StubGenerator: public StubCodeGenerator { __ la(t1, ExternalAddress(bs_asm->patching_epoch_addr())); __ lwu(t1, t1); __ sw(t1, thread_epoch_addr); + // There are two ways this can work: + // - The writer did system icache shootdown after the instruction stream update. + // Hence do nothing. + // - The writer trust us to make sure our icache is in sync before entering. + // Hence use cmodx fence (fence.i, may change). + if (UseCtxFencei) { + __ cmodx_fence(); + } __ membar(__ LoadLoad); } @@ -4474,7 +4482,7 @@ class StubGenerator: public StubCodeGenerator { RegSet reg_cache_saved_regs = RegSet::of(x24, x25, x26, x27); // s8, s9, s10, s11 RegSet reg_cache_regs; reg_cache_regs += reg_cache_saved_regs; - reg_cache_regs += RegSet::of(x28, x29, x30, x31); // t3, t4, t5, t6 + reg_cache_regs += RegSet::of(t3, t4, t5, t6); BufRegCache reg_cache(_masm, reg_cache_regs); RegSet saved_regs; @@ -5331,7 +5339,7 @@ class StubGenerator: public StubCodeGenerator { * NOTE: each field will occupy a single vector register group */ void base64_vector_decode_round(Register src, Register dst, Register codec, - Register size, Register stepSrc, Register stepDst, Register failedIdx, Register minusOne, + Register size, Register stepSrc, Register stepDst, Register failedIdx, VectorRegister inputV1, VectorRegister inputV2, VectorRegister inputV3, VectorRegister inputV4, VectorRegister idxV1, VectorRegister idxV2, VectorRegister idxV3, VectorRegister idxV4, VectorRegister outputV1, VectorRegister outputV2, VectorRegister outputV3, @@ -5358,8 +5366,11 @@ class StubGenerator: public StubCodeGenerator { __ vor_vv(outputV1, outputV1, outputV2); __ vmseq_vi(v0, outputV1, -1); __ vfirst_m(failedIdx, v0); - Label NoFailure; - __ beq(failedIdx, minusOne, NoFailure); + Label NoFailure, FailureAtIdx0; + // valid value can only be -1 when < 0 + __ bltz(failedIdx, NoFailure); + // when the first data (at index 0) fails, no need to process data anymore + __ beqz(failedIdx, FailureAtIdx0); __ vsetvli(x0, failedIdx, Assembler::e8, lmul, Assembler::mu, Assembler::tu); __ slli(stepDst, failedIdx, 1); __ add(stepDst, failedIdx, stepDst); @@ -5382,6 +5393,7 @@ class StubGenerator: public StubCodeGenerator { // dst = dst + register_group_len_bytes * 3 __ add(dst, dst, stepDst); + __ BIND(FailureAtIdx0); } /** @@ -5450,8 +5462,8 @@ class StubGenerator: public StubCodeGenerator { Register isMIME = c_rarg6; Register codec = c_rarg7; - Register dstBackup = x31; - Register length = x28; // t3, total length of src data in bytes + Register dstBackup = t6; + Register length = t3; // total length of src data in bytes Label ProcessData, Exit; Label ProcessScalar, ScalarLoop; @@ -5486,10 +5498,8 @@ class StubGenerator: public StubCodeGenerator { Register stepSrcM1 = send; Register stepSrcM2 = doff; Register stepDst = isURL; - Register size = x29; // t4 - Register minusOne = x30; // t5 + Register size = t4; - __ mv(minusOne, -1); __ mv(size, MaxVectorSize * 2); __ mv(stepSrcM1, MaxVectorSize * 4); __ slli(stepSrcM2, stepSrcM1, 1); @@ -5501,7 +5511,7 @@ class StubGenerator: public StubCodeGenerator { // Assembler::m2 __ BIND(ProcessM2); base64_vector_decode_round(src, dst, codec, - size, stepSrcM2, stepDst, failedIdx, minusOne, + size, stepSrcM2, stepDst, failedIdx, v2, v4, v6, v8, // inputs v10, v12, v14, v16, // indexes v18, v20, v22, // outputs @@ -5509,7 +5519,8 @@ class StubGenerator: public StubCodeGenerator { __ sub(length, length, stepSrcM2); // error check - __ bne(failedIdx, minusOne, Exit); + // valid value of failedIdx can only be -1 when < 0 + __ bgez(failedIdx, Exit); __ bge(length, stepSrcM2, ProcessM2); @@ -5521,7 +5532,7 @@ class StubGenerator: public StubCodeGenerator { __ srli(size, size, 1); __ srli(stepDst, stepDst, 1); base64_vector_decode_round(src, dst, codec, - size, stepSrcM1, stepDst, failedIdx, minusOne, + size, stepSrcM1, stepDst, failedIdx, v1, v2, v3, v4, // inputs v5, v6, v7, v8, // indexes v9, v10, v11, // outputs @@ -5529,7 +5540,8 @@ class StubGenerator: public StubCodeGenerator { __ sub(length, length, stepSrcM1); // error check - __ bne(failedIdx, minusOne, Exit); + // valid value of failedIdx can only be -1 when < 0 + __ bgez(failedIdx, Exit); __ BIND(ProcessScalar); __ beqz(length, Exit); @@ -5538,7 +5550,7 @@ class StubGenerator: public StubCodeGenerator { // scalar version { Register byte0 = soff, byte1 = send, byte2 = doff, byte3 = isURL; - Register combined32Bits = x29; // t5 + Register combined32Bits = t4; // encoded: [byte0[5:0] : byte1[5:0] : byte2[5:0]] : byte3[5:0]] => // plain: [byte0[5:0]+byte1[5:4] : byte1[3:0]+byte2[5:2] : byte2[1:0]+byte3[5:0]] @@ -5696,10 +5708,10 @@ class StubGenerator: public StubCodeGenerator { Register nmax = c_rarg4; Register base = c_rarg5; Register count = c_rarg6; - Register temp0 = x28; // t3 - Register temp1 = x29; // t4 - Register temp2 = x30; // t5 - Register temp3 = x31; // t6 + Register temp0 = t3; + Register temp1 = t4; + Register temp2 = t5; + Register temp3 = t6; VectorRegister vzero = v31; VectorRegister vbytes = v8; // group: v8, v9, v10, v11 @@ -6059,6 +6071,58 @@ static const int64_t right_3_bits = right_n_bits(3); return start; } + void generate_vector_math_stubs() { + if (!UseRVV) { + log_info(library)("vector is not supported, skip loading vector math (sleef) library!"); + return; + } + + // Get native vector math stub routine addresses + void* libsleef = nullptr; + char ebuf[1024]; + char dll_name[JVM_MAXPATHLEN]; + if (os::dll_locate_lib(dll_name, sizeof(dll_name), Arguments::get_dll_dir(), "sleef")) { + libsleef = os::dll_load(dll_name, ebuf, sizeof ebuf); + } + if (libsleef == nullptr) { + log_info(library)("Failed to load native vector math (sleef) library, %s!", ebuf); + return; + } + + // Method naming convention + // All the methods are named as _ + // + // Where: + // is the operation name, e.g. sin, cos + // is to indicate float/double + // "fx/dx" for vector float/double operation + // is the precision level + // "u10/u05" represents 1.0/0.5 ULP error bounds + // We use "u10" for all operations by default + // But for those functions do not have u10 support, we use "u05" instead + // rvv, indicates riscv vector extension + // + // e.g. sinfx_u10rvv is the method for computing vector float sin using rvv instructions + // + log_info(library)("Loaded library %s, handle " INTPTR_FORMAT, JNI_LIB_PREFIX "sleef" JNI_LIB_SUFFIX, p2i(libsleef)); + + for (int op = 0; op < VectorSupport::NUM_VECTOR_OP_MATH; op++) { + int vop = VectorSupport::VECTOR_OP_MATH_START + op; + if (vop == VectorSupport::VECTOR_OP_TANH) { // skip tanh because of performance regression + continue; + } + + // The native library does not support u10 level of "hypot". + const char* ulf = (vop == VectorSupport::VECTOR_OP_HYPOT) ? "u05" : "u10"; + + snprintf(ebuf, sizeof(ebuf), "%sfx_%srvv", VectorSupport::mathname[op], ulf); + StubRoutines::_vector_f_math[VectorSupport::VEC_SIZE_SCALABLE][op] = (address)os::dll_lookup(libsleef, ebuf); + + snprintf(ebuf, sizeof(ebuf), "%sdx_%srvv", VectorSupport::mathname[op], ulf); + StubRoutines::_vector_d_math[VectorSupport::VEC_SIZE_SCALABLE][op] = (address)os::dll_lookup(libsleef, ebuf); + } + } + #endif // COMPILER2 /** @@ -6080,26 +6144,17 @@ static const int64_t right_3_bits = right_n_bits(3); address start = __ pc(); + // input parameters const Register crc = c_rarg0; // crc const Register buf = c_rarg1; // source java byte array address const Register len = c_rarg2; // length - const Register table0 = c_rarg3; // crc_table address - const Register table1 = c_rarg4; - const Register table2 = c_rarg5; - const Register table3 = c_rarg6; - - const Register tmp1 = c_rarg7; - const Register tmp2 = t2; - const Register tmp3 = x28; // t3 - const Register tmp4 = x29; // t4 - const Register tmp5 = x30; // t5 - const Register tmp6 = x31; // t6 BLOCK_COMMENT("Entry:"); __ enter(); // required for proper stackwalking of RuntimeStub frame - __ kernel_crc32(crc, buf, len, table0, table1, table2, - table3, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6); + __ kernel_crc32(crc, buf, len, + c_rarg3, c_rarg4, c_rarg5, c_rarg6, // tmp's for tables + c_rarg7, t2, t3, t4, t5, t6); // misc tmps __ leave(); // required for proper stackwalking of RuntimeStub frame __ ret(); @@ -6121,6 +6176,29 @@ static const int64_t right_3_bits = right_n_bits(3); return start; } + // load Method* target of MethodHandle + // j_rarg0 = jobject receiver + // xmethod = Method* result + address generate_upcall_stub_load_target() { + + StubCodeMark mark(this, "StubRoutines", "upcall_stub_load_target"); + address start = __ pc(); + + __ resolve_global_jobject(j_rarg0, t0, t1); + // Load target method from receiver + __ load_heap_oop(xmethod, Address(j_rarg0, java_lang_invoke_MethodHandle::form_offset()), t0, t1); + __ load_heap_oop(xmethod, Address(xmethod, java_lang_invoke_LambdaForm::vmentry_offset()), t0, t1); + __ load_heap_oop(xmethod, Address(xmethod, java_lang_invoke_MemberName::method_offset()), t0, t1); + __ access_load_at(T_ADDRESS, IN_HEAP, xmethod, + Address(xmethod, java_lang_invoke_ResolvedMethodName::vmtarget_offset()), + noreg, noreg); + __ sd(xmethod, Address(xthread, JavaThread::callee_target_offset())); // just in case callee is deoptimized + + __ ret(); + + return start; + } + #undef __ // Initialization @@ -6186,6 +6264,7 @@ static const int64_t right_3_bits = right_n_bits(3); #endif // COMPILER2 StubRoutines::_upcall_stub_exception_handler = generate_upcall_stub_exception_handler(); + StubRoutines::_upcall_stub_load_target = generate_upcall_stub_load_target(); StubRoutines::riscv::set_completed(); } @@ -6264,6 +6343,8 @@ static const int64_t right_3_bits = right_n_bits(3); generate_string_indexof_stubs(); + generate_vector_math_stubs(); + #endif // COMPILER2 } diff --git a/src/hotspot/cpu/riscv/stubRoutines_riscv.cpp b/src/hotspot/cpu/riscv/stubRoutines_riscv.cpp index 05bdeaf7570..6d5492b86b3 100644 --- a/src/hotspot/cpu/riscv/stubRoutines_riscv.cpp +++ b/src/hotspot/cpu/riscv/stubRoutines_riscv.cpp @@ -276,4 +276,219 @@ ATTRIBUTE_ALIGNED(4096) juint StubRoutines::riscv::_crc_table[] = 0xb1b8e695UL, 0xa30d497bUL, 0x1bb12e1eUL, 0x43d23e48UL, 0xfb6e592dUL, 0xe9dbf6c3UL, 0x516791a6UL, 0xccb0a91fUL, 0x740cce7aUL, 0x66b96194UL, 0xde0506f1UL, + + // Tables for vector version + // This improvement (vectorization) is based on java.base/share/native/libzip/zlib/zcrc32.c. + // To make it, following steps are taken: + // 1. in zcrc32.c, modify N to 16 and related code, + // 2. re-generate the tables needed, we use tables of (N == 16, W == 4) + // 3. finally vectorize the code (original implementation in zcrc32.c is just scalar code). + 0x00000000, 0x8f352d95, 0xc51b5d6b, 0x4a2e70fe, 0x5147bc97, + 0xde729102, 0x945ce1fc, 0x1b69cc69, 0xa28f792e, 0x2dba54bb, + 0x67942445, 0xe8a109d0, 0xf3c8c5b9, 0x7cfde82c, 0x36d398d2, + 0xb9e6b547, 0x9e6ff41d, 0x115ad988, 0x5b74a976, 0xd44184e3, + 0xcf28488a, 0x401d651f, 0x0a3315e1, 0x85063874, 0x3ce08d33, + 0xb3d5a0a6, 0xf9fbd058, 0x76cefdcd, 0x6da731a4, 0xe2921c31, + 0xa8bc6ccf, 0x2789415a, 0xe7aeee7b, 0x689bc3ee, 0x22b5b310, + 0xad809e85, 0xb6e952ec, 0x39dc7f79, 0x73f20f87, 0xfcc72212, + 0x45219755, 0xca14bac0, 0x803aca3e, 0x0f0fe7ab, 0x14662bc2, + 0x9b530657, 0xd17d76a9, 0x5e485b3c, 0x79c11a66, 0xf6f437f3, + 0xbcda470d, 0x33ef6a98, 0x2886a6f1, 0xa7b38b64, 0xed9dfb9a, + 0x62a8d60f, 0xdb4e6348, 0x547b4edd, 0x1e553e23, 0x916013b6, + 0x8a09dfdf, 0x053cf24a, 0x4f1282b4, 0xc027af21, 0x142cdab7, + 0x9b19f722, 0xd13787dc, 0x5e02aa49, 0x456b6620, 0xca5e4bb5, + 0x80703b4b, 0x0f4516de, 0xb6a3a399, 0x39968e0c, 0x73b8fef2, + 0xfc8dd367, 0xe7e41f0e, 0x68d1329b, 0x22ff4265, 0xadca6ff0, + 0x8a432eaa, 0x0576033f, 0x4f5873c1, 0xc06d5e54, 0xdb04923d, + 0x5431bfa8, 0x1e1fcf56, 0x912ae2c3, 0x28cc5784, 0xa7f97a11, + 0xedd70aef, 0x62e2277a, 0x798beb13, 0xf6bec686, 0xbc90b678, + 0x33a59bed, 0xf38234cc, 0x7cb71959, 0x369969a7, 0xb9ac4432, + 0xa2c5885b, 0x2df0a5ce, 0x67ded530, 0xe8ebf8a5, 0x510d4de2, + 0xde386077, 0x94161089, 0x1b233d1c, 0x004af175, 0x8f7fdce0, + 0xc551ac1e, 0x4a64818b, 0x6dedc0d1, 0xe2d8ed44, 0xa8f69dba, + 0x27c3b02f, 0x3caa7c46, 0xb39f51d3, 0xf9b1212d, 0x76840cb8, + 0xcf62b9ff, 0x4057946a, 0x0a79e494, 0x854cc901, 0x9e250568, + 0x111028fd, 0x5b3e5803, 0xd40b7596, 0x2859b56e, 0xa76c98fb, + 0xed42e805, 0x6277c590, 0x791e09f9, 0xf62b246c, 0xbc055492, + 0x33307907, 0x8ad6cc40, 0x05e3e1d5, 0x4fcd912b, 0xc0f8bcbe, + 0xdb9170d7, 0x54a45d42, 0x1e8a2dbc, 0x91bf0029, 0xb6364173, + 0x39036ce6, 0x732d1c18, 0xfc18318d, 0xe771fde4, 0x6844d071, + 0x226aa08f, 0xad5f8d1a, 0x14b9385d, 0x9b8c15c8, 0xd1a26536, + 0x5e9748a3, 0x45fe84ca, 0xcacba95f, 0x80e5d9a1, 0x0fd0f434, + 0xcff75b15, 0x40c27680, 0x0aec067e, 0x85d92beb, 0x9eb0e782, + 0x1185ca17, 0x5babbae9, 0xd49e977c, 0x6d78223b, 0xe24d0fae, + 0xa8637f50, 0x275652c5, 0x3c3f9eac, 0xb30ab339, 0xf924c3c7, + 0x7611ee52, 0x5198af08, 0xdead829d, 0x9483f263, 0x1bb6dff6, + 0x00df139f, 0x8fea3e0a, 0xc5c44ef4, 0x4af16361, 0xf317d626, + 0x7c22fbb3, 0x360c8b4d, 0xb939a6d8, 0xa2506ab1, 0x2d654724, + 0x674b37da, 0xe87e1a4f, 0x3c756fd9, 0xb340424c, 0xf96e32b2, + 0x765b1f27, 0x6d32d34e, 0xe207fedb, 0xa8298e25, 0x271ca3b0, + 0x9efa16f7, 0x11cf3b62, 0x5be14b9c, 0xd4d46609, 0xcfbdaa60, + 0x408887f5, 0x0aa6f70b, 0x8593da9e, 0xa21a9bc4, 0x2d2fb651, + 0x6701c6af, 0xe834eb3a, 0xf35d2753, 0x7c680ac6, 0x36467a38, + 0xb97357ad, 0x0095e2ea, 0x8fa0cf7f, 0xc58ebf81, 0x4abb9214, + 0x51d25e7d, 0xdee773e8, 0x94c90316, 0x1bfc2e83, 0xdbdb81a2, + 0x54eeac37, 0x1ec0dcc9, 0x91f5f15c, 0x8a9c3d35, 0x05a910a0, + 0x4f87605e, 0xc0b24dcb, 0x7954f88c, 0xf661d519, 0xbc4fa5e7, + 0x337a8872, 0x2813441b, 0xa726698e, 0xed081970, 0x623d34e5, + 0x45b475bf, 0xca81582a, 0x80af28d4, 0x0f9a0541, 0x14f3c928, + 0x9bc6e4bd, 0xd1e89443, 0x5eddb9d6, 0xe73b0c91, 0x680e2104, + 0x222051fa, 0xad157c6f, 0xb67cb006, 0x39499d93, 0x7367ed6d, + 0xfc52c0f8, + 0x00000000, 0x50b36adc, 0xa166d5b8, 0xf1d5bf64, 0x99bcad31, + 0xc90fc7ed, 0x38da7889, 0x68691255, 0xe8085c23, 0xb8bb36ff, + 0x496e899b, 0x19dde347, 0x71b4f112, 0x21079bce, 0xd0d224aa, + 0x80614e76, 0x0b61be07, 0x5bd2d4db, 0xaa076bbf, 0xfab40163, + 0x92dd1336, 0xc26e79ea, 0x33bbc68e, 0x6308ac52, 0xe369e224, + 0xb3da88f8, 0x420f379c, 0x12bc5d40, 0x7ad54f15, 0x2a6625c9, + 0xdbb39aad, 0x8b00f071, 0x16c37c0e, 0x467016d2, 0xb7a5a9b6, + 0xe716c36a, 0x8f7fd13f, 0xdfccbbe3, 0x2e190487, 0x7eaa6e5b, + 0xfecb202d, 0xae784af1, 0x5fadf595, 0x0f1e9f49, 0x67778d1c, + 0x37c4e7c0, 0xc61158a4, 0x96a23278, 0x1da2c209, 0x4d11a8d5, + 0xbcc417b1, 0xec777d6d, 0x841e6f38, 0xd4ad05e4, 0x2578ba80, + 0x75cbd05c, 0xf5aa9e2a, 0xa519f4f6, 0x54cc4b92, 0x047f214e, + 0x6c16331b, 0x3ca559c7, 0xcd70e6a3, 0x9dc38c7f, 0x2d86f81c, + 0x7d3592c0, 0x8ce02da4, 0xdc534778, 0xb43a552d, 0xe4893ff1, + 0x155c8095, 0x45efea49, 0xc58ea43f, 0x953dcee3, 0x64e87187, + 0x345b1b5b, 0x5c32090e, 0x0c8163d2, 0xfd54dcb6, 0xade7b66a, + 0x26e7461b, 0x76542cc7, 0x878193a3, 0xd732f97f, 0xbf5beb2a, + 0xefe881f6, 0x1e3d3e92, 0x4e8e544e, 0xceef1a38, 0x9e5c70e4, + 0x6f89cf80, 0x3f3aa55c, 0x5753b709, 0x07e0ddd5, 0xf63562b1, + 0xa686086d, 0x3b458412, 0x6bf6eece, 0x9a2351aa, 0xca903b76, + 0xa2f92923, 0xf24a43ff, 0x039ffc9b, 0x532c9647, 0xd34dd831, + 0x83feb2ed, 0x722b0d89, 0x22986755, 0x4af17500, 0x1a421fdc, + 0xeb97a0b8, 0xbb24ca64, 0x30243a15, 0x609750c9, 0x9142efad, + 0xc1f18571, 0xa9989724, 0xf92bfdf8, 0x08fe429c, 0x584d2840, + 0xd82c6636, 0x889f0cea, 0x794ab38e, 0x29f9d952, 0x4190cb07, + 0x1123a1db, 0xe0f61ebf, 0xb0457463, 0x5b0df038, 0x0bbe9ae4, + 0xfa6b2580, 0xaad84f5c, 0xc2b15d09, 0x920237d5, 0x63d788b1, + 0x3364e26d, 0xb305ac1b, 0xe3b6c6c7, 0x126379a3, 0x42d0137f, + 0x2ab9012a, 0x7a0a6bf6, 0x8bdfd492, 0xdb6cbe4e, 0x506c4e3f, + 0x00df24e3, 0xf10a9b87, 0xa1b9f15b, 0xc9d0e30e, 0x996389d2, + 0x68b636b6, 0x38055c6a, 0xb864121c, 0xe8d778c0, 0x1902c7a4, + 0x49b1ad78, 0x21d8bf2d, 0x716bd5f1, 0x80be6a95, 0xd00d0049, + 0x4dce8c36, 0x1d7de6ea, 0xeca8598e, 0xbc1b3352, 0xd4722107, + 0x84c14bdb, 0x7514f4bf, 0x25a79e63, 0xa5c6d015, 0xf575bac9, + 0x04a005ad, 0x54136f71, 0x3c7a7d24, 0x6cc917f8, 0x9d1ca89c, + 0xcdafc240, 0x46af3231, 0x161c58ed, 0xe7c9e789, 0xb77a8d55, + 0xdf139f00, 0x8fa0f5dc, 0x7e754ab8, 0x2ec62064, 0xaea76e12, + 0xfe1404ce, 0x0fc1bbaa, 0x5f72d176, 0x371bc323, 0x67a8a9ff, + 0x967d169b, 0xc6ce7c47, 0x768b0824, 0x263862f8, 0xd7eddd9c, + 0x875eb740, 0xef37a515, 0xbf84cfc9, 0x4e5170ad, 0x1ee21a71, + 0x9e835407, 0xce303edb, 0x3fe581bf, 0x6f56eb63, 0x073ff936, + 0x578c93ea, 0xa6592c8e, 0xf6ea4652, 0x7deab623, 0x2d59dcff, + 0xdc8c639b, 0x8c3f0947, 0xe4561b12, 0xb4e571ce, 0x4530ceaa, + 0x1583a476, 0x95e2ea00, 0xc55180dc, 0x34843fb8, 0x64375564, + 0x0c5e4731, 0x5ced2ded, 0xad389289, 0xfd8bf855, 0x6048742a, + 0x30fb1ef6, 0xc12ea192, 0x919dcb4e, 0xf9f4d91b, 0xa947b3c7, + 0x58920ca3, 0x0821667f, 0x88402809, 0xd8f342d5, 0x2926fdb1, + 0x7995976d, 0x11fc8538, 0x414fefe4, 0xb09a5080, 0xe0293a5c, + 0x6b29ca2d, 0x3b9aa0f1, 0xca4f1f95, 0x9afc7549, 0xf295671c, + 0xa2260dc0, 0x53f3b2a4, 0x0340d878, 0x8321960e, 0xd392fcd2, + 0x224743b6, 0x72f4296a, 0x1a9d3b3f, 0x4a2e51e3, 0xbbfbee87, + 0xeb48845b, + 0x00000000, 0xb61be070, 0xb746c6a1, 0x015d26d1, 0xb5fc8b03, + 0x03e76b73, 0x02ba4da2, 0xb4a1add2, 0xb0881047, 0x0693f037, + 0x07ced6e6, 0xb1d53696, 0x05749b44, 0xb36f7b34, 0xb2325de5, + 0x0429bd95, 0xba6126cf, 0x0c7ac6bf, 0x0d27e06e, 0xbb3c001e, + 0x0f9dadcc, 0xb9864dbc, 0xb8db6b6d, 0x0ec08b1d, 0x0ae93688, + 0xbcf2d6f8, 0xbdaff029, 0x0bb41059, 0xbf15bd8b, 0x090e5dfb, + 0x08537b2a, 0xbe489b5a, 0xafb34bdf, 0x19a8abaf, 0x18f58d7e, + 0xaeee6d0e, 0x1a4fc0dc, 0xac5420ac, 0xad09067d, 0x1b12e60d, + 0x1f3b5b98, 0xa920bbe8, 0xa87d9d39, 0x1e667d49, 0xaac7d09b, + 0x1cdc30eb, 0x1d81163a, 0xab9af64a, 0x15d26d10, 0xa3c98d60, + 0xa294abb1, 0x148f4bc1, 0xa02ee613, 0x16350663, 0x176820b2, + 0xa173c0c2, 0xa55a7d57, 0x13419d27, 0x121cbbf6, 0xa4075b86, + 0x10a6f654, 0xa6bd1624, 0xa7e030f5, 0x11fbd085, 0x841791ff, + 0x320c718f, 0x3351575e, 0x854ab72e, 0x31eb1afc, 0x87f0fa8c, + 0x86addc5d, 0x30b63c2d, 0x349f81b8, 0x828461c8, 0x83d94719, + 0x35c2a769, 0x81630abb, 0x3778eacb, 0x3625cc1a, 0x803e2c6a, + 0x3e76b730, 0x886d5740, 0x89307191, 0x3f2b91e1, 0x8b8a3c33, + 0x3d91dc43, 0x3cccfa92, 0x8ad71ae2, 0x8efea777, 0x38e54707, + 0x39b861d6, 0x8fa381a6, 0x3b022c74, 0x8d19cc04, 0x8c44ead5, + 0x3a5f0aa5, 0x2ba4da20, 0x9dbf3a50, 0x9ce21c81, 0x2af9fcf1, + 0x9e585123, 0x2843b153, 0x291e9782, 0x9f0577f2, 0x9b2cca67, + 0x2d372a17, 0x2c6a0cc6, 0x9a71ecb6, 0x2ed04164, 0x98cba114, + 0x999687c5, 0x2f8d67b5, 0x91c5fcef, 0x27de1c9f, 0x26833a4e, + 0x9098da3e, 0x243977ec, 0x9222979c, 0x937fb14d, 0x2564513d, + 0x214deca8, 0x97560cd8, 0x960b2a09, 0x2010ca79, 0x94b167ab, + 0x22aa87db, 0x23f7a10a, 0x95ec417a, 0xd35e25bf, 0x6545c5cf, + 0x6418e31e, 0xd203036e, 0x66a2aebc, 0xd0b94ecc, 0xd1e4681d, + 0x67ff886d, 0x63d635f8, 0xd5cdd588, 0xd490f359, 0x628b1329, + 0xd62abefb, 0x60315e8b, 0x616c785a, 0xd777982a, 0x693f0370, + 0xdf24e300, 0xde79c5d1, 0x686225a1, 0xdcc38873, 0x6ad86803, + 0x6b854ed2, 0xdd9eaea2, 0xd9b71337, 0x6facf347, 0x6ef1d596, + 0xd8ea35e6, 0x6c4b9834, 0xda507844, 0xdb0d5e95, 0x6d16bee5, + 0x7ced6e60, 0xcaf68e10, 0xcbaba8c1, 0x7db048b1, 0xc911e563, + 0x7f0a0513, 0x7e5723c2, 0xc84cc3b2, 0xcc657e27, 0x7a7e9e57, + 0x7b23b886, 0xcd3858f6, 0x7999f524, 0xcf821554, 0xcedf3385, + 0x78c4d3f5, 0xc68c48af, 0x7097a8df, 0x71ca8e0e, 0xc7d16e7e, + 0x7370c3ac, 0xc56b23dc, 0xc436050d, 0x722de57d, 0x760458e8, + 0xc01fb898, 0xc1429e49, 0x77597e39, 0xc3f8d3eb, 0x75e3339b, + 0x74be154a, 0xc2a5f53a, 0x5749b440, 0xe1525430, 0xe00f72e1, + 0x56149291, 0xe2b53f43, 0x54aedf33, 0x55f3f9e2, 0xe3e81992, + 0xe7c1a407, 0x51da4477, 0x508762a6, 0xe69c82d6, 0x523d2f04, + 0xe426cf74, 0xe57be9a5, 0x536009d5, 0xed28928f, 0x5b3372ff, + 0x5a6e542e, 0xec75b45e, 0x58d4198c, 0xeecff9fc, 0xef92df2d, + 0x59893f5d, 0x5da082c8, 0xebbb62b8, 0xeae64469, 0x5cfda419, + 0xe85c09cb, 0x5e47e9bb, 0x5f1acf6a, 0xe9012f1a, 0xf8faff9f, + 0x4ee11fef, 0x4fbc393e, 0xf9a7d94e, 0x4d06749c, 0xfb1d94ec, + 0xfa40b23d, 0x4c5b524d, 0x4872efd8, 0xfe690fa8, 0xff342979, + 0x492fc909, 0xfd8e64db, 0x4b9584ab, 0x4ac8a27a, 0xfcd3420a, + 0x429bd950, 0xf4803920, 0xf5dd1ff1, 0x43c6ff81, 0xf7675253, + 0x417cb223, 0x402194f2, 0xf63a7482, 0xf213c917, 0x44082967, + 0x45550fb6, 0xf34eefc6, 0x47ef4214, 0xf1f4a264, 0xf0a984b5, + 0x46b264c5, + 0x00000000, 0x7dcd4d3f, 0xfb9a9a7e, 0x8657d741, 0x2c4432bd, + 0x51897f82, 0xd7dea8c3, 0xaa13e5fc, 0x5888657a, 0x25452845, + 0xa312ff04, 0xdedfb23b, 0x74cc57c7, 0x09011af8, 0x8f56cdb9, + 0xf29b8086, 0xb110caf4, 0xccdd87cb, 0x4a8a508a, 0x37471db5, + 0x9d54f849, 0xe099b576, 0x66ce6237, 0x1b032f08, 0xe998af8e, + 0x9455e2b1, 0x120235f0, 0x6fcf78cf, 0xc5dc9d33, 0xb811d00c, + 0x3e46074d, 0x438b4a72, 0xb95093a9, 0xc49dde96, 0x42ca09d7, + 0x3f0744e8, 0x9514a114, 0xe8d9ec2b, 0x6e8e3b6a, 0x13437655, + 0xe1d8f6d3, 0x9c15bbec, 0x1a426cad, 0x678f2192, 0xcd9cc46e, + 0xb0518951, 0x36065e10, 0x4bcb132f, 0x0840595d, 0x758d1462, + 0xf3dac323, 0x8e178e1c, 0x24046be0, 0x59c926df, 0xdf9ef19e, + 0xa253bca1, 0x50c83c27, 0x2d057118, 0xab52a659, 0xd69feb66, + 0x7c8c0e9a, 0x014143a5, 0x871694e4, 0xfadbd9db, 0xa9d02113, + 0xd41d6c2c, 0x524abb6d, 0x2f87f652, 0x859413ae, 0xf8595e91, + 0x7e0e89d0, 0x03c3c4ef, 0xf1584469, 0x8c950956, 0x0ac2de17, + 0x770f9328, 0xdd1c76d4, 0xa0d13beb, 0x2686ecaa, 0x5b4ba195, + 0x18c0ebe7, 0x650da6d8, 0xe35a7199, 0x9e973ca6, 0x3484d95a, + 0x49499465, 0xcf1e4324, 0xb2d30e1b, 0x40488e9d, 0x3d85c3a2, + 0xbbd214e3, 0xc61f59dc, 0x6c0cbc20, 0x11c1f11f, 0x9796265e, + 0xea5b6b61, 0x1080b2ba, 0x6d4dff85, 0xeb1a28c4, 0x96d765fb, + 0x3cc48007, 0x4109cd38, 0xc75e1a79, 0xba935746, 0x4808d7c0, + 0x35c59aff, 0xb3924dbe, 0xce5f0081, 0x644ce57d, 0x1981a842, + 0x9fd67f03, 0xe21b323c, 0xa190784e, 0xdc5d3571, 0x5a0ae230, + 0x27c7af0f, 0x8dd44af3, 0xf01907cc, 0x764ed08d, 0x0b839db2, + 0xf9181d34, 0x84d5500b, 0x0282874a, 0x7f4fca75, 0xd55c2f89, + 0xa89162b6, 0x2ec6b5f7, 0x530bf8c8, 0x88d14467, 0xf51c0958, + 0x734bde19, 0x0e869326, 0xa49576da, 0xd9583be5, 0x5f0feca4, + 0x22c2a19b, 0xd059211d, 0xad946c22, 0x2bc3bb63, 0x560ef65c, + 0xfc1d13a0, 0x81d05e9f, 0x078789de, 0x7a4ac4e1, 0x39c18e93, + 0x440cc3ac, 0xc25b14ed, 0xbf9659d2, 0x1585bc2e, 0x6848f111, + 0xee1f2650, 0x93d26b6f, 0x6149ebe9, 0x1c84a6d6, 0x9ad37197, + 0xe71e3ca8, 0x4d0dd954, 0x30c0946b, 0xb697432a, 0xcb5a0e15, + 0x3181d7ce, 0x4c4c9af1, 0xca1b4db0, 0xb7d6008f, 0x1dc5e573, + 0x6008a84c, 0xe65f7f0d, 0x9b923232, 0x6909b2b4, 0x14c4ff8b, + 0x929328ca, 0xef5e65f5, 0x454d8009, 0x3880cd36, 0xbed71a77, + 0xc31a5748, 0x80911d3a, 0xfd5c5005, 0x7b0b8744, 0x06c6ca7b, + 0xacd52f87, 0xd11862b8, 0x574fb5f9, 0x2a82f8c6, 0xd8197840, + 0xa5d4357f, 0x2383e23e, 0x5e4eaf01, 0xf45d4afd, 0x899007c2, + 0x0fc7d083, 0x720a9dbc, 0x21016574, 0x5ccc284b, 0xda9bff0a, + 0xa756b235, 0x0d4557c9, 0x70881af6, 0xf6dfcdb7, 0x8b128088, + 0x7989000e, 0x04444d31, 0x82139a70, 0xffded74f, 0x55cd32b3, + 0x28007f8c, 0xae57a8cd, 0xd39ae5f2, 0x9011af80, 0xeddce2bf, + 0x6b8b35fe, 0x164678c1, 0xbc559d3d, 0xc198d002, 0x47cf0743, + 0x3a024a7c, 0xc899cafa, 0xb55487c5, 0x33035084, 0x4ece1dbb, + 0xe4ddf847, 0x9910b578, 0x1f476239, 0x628a2f06, 0x9851f6dd, + 0xe59cbbe2, 0x63cb6ca3, 0x1e06219c, 0xb415c460, 0xc9d8895f, + 0x4f8f5e1e, 0x32421321, 0xc0d993a7, 0xbd14de98, 0x3b4309d9, + 0x468e44e6, 0xec9da11a, 0x9150ec25, 0x17073b64, 0x6aca765b, + 0x29413c29, 0x548c7116, 0xd2dba657, 0xaf16eb68, 0x05050e94, + 0x78c843ab, 0xfe9f94ea, 0x8352d9d5, 0x71c95953, 0x0c04146c, + 0x8a53c32d, 0xf79e8e12, 0x5d8d6bee, 0x204026d1, 0xa617f190, + 0xdbdabcaf }; diff --git a/src/hotspot/cpu/riscv/templateInterpreterGenerator_riscv.cpp b/src/hotspot/cpu/riscv/templateInterpreterGenerator_riscv.cpp index 1f32488777d..7c811aa3a0c 100644 --- a/src/hotspot/cpu/riscv/templateInterpreterGenerator_riscv.cpp +++ b/src/hotspot/cpu/riscv/templateInterpreterGenerator_riscv.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, 2020, Red Hat Inc. All rights reserved. * Copyright (c) 2020, 2022, Huawei Technologies Co., Ltd. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -27,6 +27,7 @@ #include "precompiled.hpp" #include "asm/macroAssembler.inline.hpp" #include "classfile/javaClasses.hpp" +#include "compiler/disassembler.hpp" #include "gc/shared/barrierSetAssembler.hpp" #include "interpreter/bytecodeHistogram.hpp" #include "interpreter/bytecodeTracer.hpp" @@ -70,7 +71,7 @@ // Max size with JVMTI int TemplateInterpreter::InterpreterCodeSize = 256 * 1024; -#define __ _masm-> +#define __ Disassembler::hook(__FILE__, __LINE__, _masm)-> //----------------------------------------------------------------------------- @@ -1748,13 +1749,21 @@ void TemplateInterpreterGenerator::set_vtos_entry_points(Template* t, address& vep) { assert(t != nullptr && t->is_valid() && t->tos_in() == vtos, "illegal template"); Label L; - aep = __ pc(); __ push_ptr(); __ j(L); - fep = __ pc(); __ push_f(); __ j(L); - dep = __ pc(); __ push_d(); __ j(L); - lep = __ pc(); __ push_l(); __ j(L); - bep = cep = sep = - iep = __ pc(); __ push_i(); - vep = __ pc(); + aep = __ pc(); // atos entry point + __ push_ptr(); + __ j(L); + fep = __ pc(); // ftos entry point + __ push_f(); + __ j(L); + dep = __ pc(); // dtos entry point + __ push_d(); + __ j(L); + lep = __ pc(); // ltos entry point + __ push_l(); + __ j(L); + bep = cep = sep = iep = __ pc(); // [bcsi]tos entry point + __ push_i(); + vep = __ pc(); // vtos entry point __ bind(L); generate_and_dispatch(t); } diff --git a/src/hotspot/cpu/riscv/templateTable_riscv.cpp b/src/hotspot/cpu/riscv/templateTable_riscv.cpp index fa542343949..2fede262057 100644 --- a/src/hotspot/cpu/riscv/templateTable_riscv.cpp +++ b/src/hotspot/cpu/riscv/templateTable_riscv.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, Red Hat Inc. All rights reserved. * Copyright (c) 2020, 2023, Huawei Technologies Co., Ltd. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -26,6 +26,7 @@ #include "precompiled.hpp" #include "asm/macroAssembler.inline.hpp" +#include "compiler/disassembler.hpp" #include "gc/shared/barrierSetAssembler.hpp" #include "gc/shared/collectedHeap.hpp" #include "gc/shared/tlab_globals.hpp" @@ -49,7 +50,7 @@ #include "runtime/synchronizer.hpp" #include "utilities/powerOfTwo.hpp" -#define __ _masm-> +#define __ Disassembler::hook(__FILE__, __LINE__, _masm)-> // Address computation: local variables @@ -178,7 +179,6 @@ void TemplateTable::patch_bytecode(Bytecodes::Code bc, Register bc_reg, __ la(temp_reg, Address(temp_reg, in_bytes(ResolvedFieldEntry::put_code_offset()))); } // Load-acquire the bytecode to match store-release in ResolvedFieldEntry::fill_in() - __ membar(MacroAssembler::AnyAny); __ lbu(temp_reg, Address(temp_reg, 0)); __ membar(MacroAssembler::LoadLoad | MacroAssembler::LoadStore); __ mv(bc_reg, bc); @@ -320,7 +320,6 @@ void TemplateTable::ldc(LdcType type) { // get type __ addi(x13, x11, tags_offset); __ add(x13, x10, x13); - __ membar(MacroAssembler::AnyAny); __ lbu(x13, Address(x13, 0)); __ membar(MacroAssembler::LoadLoad | MacroAssembler::LoadStore); @@ -2098,9 +2097,9 @@ void TemplateTable::_return(TosState state) { __ ld(c_rarg1, aaddress(0)); __ load_klass(x13, c_rarg1); - __ lwu(x13, Address(x13, Klass::access_flags_offset())); + __ lbu(x13, Address(x13, Klass::misc_flags_offset())); Label skip_register_finalizer; - __ test_bit(t0, x13, exact_log2(JVM_ACC_HAS_FINALIZER)); + __ test_bit(t0, x13, exact_log2(KlassFlags::_misc_has_finalizer)); __ beqz(t0, skip_register_finalizer); __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::register_finalizer), c_rarg1); @@ -2189,7 +2188,6 @@ void TemplateTable::resolve_cache_and_index_for_method(int byte_no, break; } // Load-acquire the bytecode to match store-release in InterpreterRuntime - __ membar(MacroAssembler::AnyAny); __ lbu(temp, Address(temp, 0)); __ membar(MacroAssembler::LoadLoad | MacroAssembler::LoadStore); @@ -2241,7 +2239,6 @@ void TemplateTable::resolve_cache_and_index_for_field(int byte_no, __ la(temp, Address(Rcache, in_bytes(ResolvedFieldEntry::put_code_offset()))); } // Load-acquire the bytecode to match store-release in ResolvedFieldEntry::fill_in() - __ membar(MacroAssembler::AnyAny); __ lbu(temp, Address(temp, 0)); __ membar(MacroAssembler::LoadLoad | MacroAssembler::LoadStore); __ mv(t0, (int) code); // have we resolved this bytecode? @@ -2403,7 +2400,6 @@ void TemplateTable::load_invokedynamic_entry(Register method) { Label resolved; __ load_resolved_indy_entry(cache, index); - __ membar(MacroAssembler::AnyAny); __ ld(method, Address(cache, in_bytes(ResolvedIndyEntry::method_offset()))); __ membar(MacroAssembler::LoadLoad | MacroAssembler::LoadStore); @@ -2418,7 +2414,6 @@ void TemplateTable::load_invokedynamic_entry(Register method) { __ call_VM(noreg, entry, method); // Update registers with resolved info __ load_resolved_indy_entry(cache, index); - __ membar(MacroAssembler::AnyAny); __ ld(method, Address(cache, in_bytes(ResolvedIndyEntry::method_offset()))); __ membar(MacroAssembler::LoadLoad | MacroAssembler::LoadStore); @@ -3533,7 +3528,6 @@ void TemplateTable::_new() { const int tags_offset = Array::base_offset_in_bytes(); __ add(t0, x10, x13); __ la(t0, Address(t0, tags_offset)); - __ membar(MacroAssembler::AnyAny); __ lbu(t0, t0); __ membar(MacroAssembler::LoadLoad | MacroAssembler::LoadStore); __ sub(t1, t0, (u1)JVM_CONSTANT_Class); @@ -3651,7 +3645,6 @@ void TemplateTable::checkcast() { // See if bytecode has already been quicked __ add(t0, x13, Array::base_offset_in_bytes()); __ add(x11, t0, x9); - __ membar(MacroAssembler::AnyAny); __ lbu(x11, x11); __ membar(MacroAssembler::LoadLoad | MacroAssembler::LoadStore); __ sub(t0, x11, (u1)JVM_CONSTANT_Class); @@ -3707,7 +3700,6 @@ void TemplateTable::instanceof() { // See if bytecode has already been quicked __ add(t0, x13, Array::base_offset_in_bytes()); __ add(x11, t0, x9); - __ membar(MacroAssembler::AnyAny); __ lbu(x11, x11); __ membar(MacroAssembler::LoadLoad | MacroAssembler::LoadStore); __ sub(t0, x11, (u1)JVM_CONSTANT_Class); diff --git a/src/hotspot/cpu/riscv/upcallLinker_riscv.cpp b/src/hotspot/cpu/riscv/upcallLinker_riscv.cpp index 383f332f8fd..55160be99d0 100644 --- a/src/hotspot/cpu/riscv/upcallLinker_riscv.cpp +++ b/src/hotspot/cpu/riscv/upcallLinker_riscv.cpp @@ -25,6 +25,7 @@ #include "precompiled.hpp" #include "asm/macroAssembler.hpp" +#include "classfile/javaClasses.hpp" #include "logging/logStream.hpp" #include "memory/resourceArea.hpp" #include "prims/upcallLinker.hpp" @@ -117,7 +118,7 @@ static void restore_callee_saved_registers(MacroAssembler* _masm, const ABIDescr static const int upcall_stub_code_base_size = 1024; static const int upcall_stub_size_per_arg = 16; -address UpcallLinker::make_upcall_stub(jobject receiver, Method* entry, +address UpcallLinker::make_upcall_stub(jobject receiver, Symbol* signature, BasicType* out_sig_bt, int total_out_args, BasicType ret_type, jobject jabi, jobject jconv, @@ -223,7 +224,6 @@ address UpcallLinker::make_upcall_stub(jobject receiver, Method* entry, __ block_comment("{ on_entry"); __ la(c_rarg0, Address(sp, frame_data_offset)); - __ movptr(c_rarg1, (address) receiver); __ rt_call(CAST_FROM_FN_PTR(address, UpcallLinker::on_entry)); __ mv(xthread, x10); __ reinit_heapbase(); @@ -260,12 +260,10 @@ address UpcallLinker::make_upcall_stub(jobject receiver, Method* entry, arg_shuffle.generate(_masm, as_VMStorage(shuffle_reg), abi._shadow_space_bytes, 0); __ block_comment("} argument shuffle"); - __ block_comment("{ receiver "); - __ get_vm_result(j_rarg0, xthread); - __ block_comment("} receiver "); - - __ mov_metadata(xmethod, entry); - __ sd(xmethod, Address(xthread, JavaThread::callee_target_offset())); // just in case callee is deoptimized + __ block_comment("{ load target "); + __ movptr(j_rarg0, (address) receiver); + __ far_call(RuntimeAddress(StubRoutines::upcall_stub_load_target())); // loads Method* into xmethod + __ block_comment("} load target "); __ push_cont_fastpath(xthread); @@ -338,7 +336,7 @@ address UpcallLinker::make_upcall_stub(jobject receiver, Method* entry, #ifndef PRODUCT stringStream ss; - ss.print("upcall_stub_%s", entry->signature()->as_C_string()); + ss.print("upcall_stub_%s", signature->as_C_string()); const char *name = _masm->code_string(ss.as_string()); #else // PRODUCT const char* name = "upcall_stub"; diff --git a/src/hotspot/cpu/riscv/vm_version_riscv.hpp b/src/hotspot/cpu/riscv/vm_version_riscv.hpp index bd4bfe86d9b..8fdde0094f4 100644 --- a/src/hotspot/cpu/riscv/vm_version_riscv.hpp +++ b/src/hotspot/cpu/riscv/vm_version_riscv.hpp @@ -285,6 +285,7 @@ class VM_Version : public Abstract_VM_Version { // RISCV64 supports fast class initialization checks static bool supports_fast_class_init_checks() { return true; } + static bool supports_fencei_barrier() { return ext_Zifencei.enabled(); } }; #endif // CPU_RISCV_VM_VERSION_RISCV_HPP diff --git a/src/hotspot/cpu/s390/c1_CodeStubs_s390.cpp b/src/hotspot/cpu/s390/c1_CodeStubs_s390.cpp index b7f1d360568..e01e4458e38 100644 --- a/src/hotspot/cpu/s390/c1_CodeStubs_s390.cpp +++ b/src/hotspot/cpu/s390/c1_CodeStubs_s390.cpp @@ -48,7 +48,7 @@ void C1SafepointPollStub::emit_code(LIR_Assembler* ce) { void RangeCheckStub::emit_code(LIR_Assembler* ce) { __ bind(_entry); if (_info->deoptimize_on_exception()) { - address a = Runtime1::entry_for (Runtime1::predicate_failed_trap_id); + address a = Runtime1::entry_for (C1StubId::predicate_failed_trap_id); ce->emit_call_c(a); CHECK_BAILOUT(); ce->add_call_info_here(_info); @@ -64,11 +64,11 @@ void RangeCheckStub::emit_code(LIR_Assembler* ce) { __ load_const_optimized(Z_R1_scratch, _index->as_jint()); } - Runtime1::StubID stub_id; + C1StubId stub_id; if (_throw_index_out_of_bounds_exception) { - stub_id = Runtime1::throw_index_exception_id; + stub_id = C1StubId::throw_index_exception_id; } else { - stub_id = Runtime1::throw_range_check_failed_id; + stub_id = C1StubId::throw_range_check_failed_id; __ lgr_if_needed(Z_R0_scratch, _array->as_pointer_register()); } ce->emit_call_c(Runtime1::entry_for (stub_id)); @@ -84,7 +84,7 @@ PredicateFailedStub::PredicateFailedStub(CodeEmitInfo* info) { void PredicateFailedStub::emit_code(LIR_Assembler* ce) { __ bind(_entry); - address a = Runtime1::entry_for (Runtime1::predicate_failed_trap_id); + address a = Runtime1::entry_for (C1StubId::predicate_failed_trap_id); ce->emit_call_c(a); CHECK_BAILOUT(); ce->add_call_info_here(_info); @@ -102,7 +102,7 @@ void CounterOverflowStub::emit_code(LIR_Assembler* ce) { } ce->store_parameter(/*_method->as_register()*/ Z_R1_scratch, 1); ce->store_parameter(_bci, 0); - ce->emit_call_c(Runtime1::entry_for (Runtime1::counter_overflow_id)); + ce->emit_call_c(Runtime1::entry_for (C1StubId::counter_overflow_id)); CHECK_BAILOUT(); ce->add_call_info_here(_info); ce->verify_oop_map(_info); @@ -114,7 +114,7 @@ void DivByZeroStub::emit_code(LIR_Assembler* ce) { ce->compilation()->implicit_exception_table()->append(_offset, __ offset()); } __ bind(_entry); - ce->emit_call_c(Runtime1::entry_for (Runtime1::throw_div0_exception_id)); + ce->emit_call_c(Runtime1::entry_for (C1StubId::throw_div0_exception_id)); CHECK_BAILOUT(); ce->add_call_info_here(_info); debug_only(__ should_not_reach_here()); @@ -124,9 +124,9 @@ void ImplicitNullCheckStub::emit_code(LIR_Assembler* ce) { address a; if (_info->deoptimize_on_exception()) { // Deoptimize, do not throw the exception, because it is probably wrong to do it here. - a = Runtime1::entry_for (Runtime1::predicate_failed_trap_id); + a = Runtime1::entry_for (C1StubId::predicate_failed_trap_id); } else { - a = Runtime1::entry_for (Runtime1::throw_null_pointer_exception_id); + a = Runtime1::entry_for (C1StubId::throw_null_pointer_exception_id); } ce->compilation()->implicit_exception_table()->append(_offset, __ offset()); @@ -151,14 +151,14 @@ void SimpleExceptionStub::emit_code(LIR_Assembler* ce) { debug_only(__ should_not_reach_here()); } -NewInstanceStub::NewInstanceStub(LIR_Opr klass_reg, LIR_Opr result, ciInstanceKlass* klass, CodeEmitInfo* info, Runtime1::StubID stub_id) { +NewInstanceStub::NewInstanceStub(LIR_Opr klass_reg, LIR_Opr result, ciInstanceKlass* klass, CodeEmitInfo* info, C1StubId stub_id) { _result = result; _klass = klass; _klass_reg = klass_reg; _info = new CodeEmitInfo(info); - assert(stub_id == Runtime1::new_instance_id || - stub_id == Runtime1::fast_new_instance_id || - stub_id == Runtime1::fast_new_instance_init_check_id, + assert(stub_id == C1StubId::new_instance_id || + stub_id == C1StubId::fast_new_instance_id || + stub_id == C1StubId::fast_new_instance_init_check_id, "need new_instance id"); _stub_id = stub_id; } @@ -186,7 +186,7 @@ void NewTypeArrayStub::emit_code(LIR_Assembler* ce) { __ bind(_entry); assert(_klass_reg->as_register() == Z_R11, "call target expects klass in Z_R11"); __ lgr_if_needed(Z_R13, _length->as_register()); - address a = Runtime1::entry_for (Runtime1::new_type_array_id); + address a = Runtime1::entry_for (C1StubId::new_type_array_id); ce->emit_call_c(a); CHECK_BAILOUT(); ce->add_call_info_here(_info); @@ -206,7 +206,7 @@ void NewObjectArrayStub::emit_code(LIR_Assembler* ce) { __ bind(_entry); assert(_klass_reg->as_register() == Z_R11, "call target expects klass in Z_R11"); __ lgr_if_needed(Z_R13, _length->as_register()); - address a = Runtime1::entry_for (Runtime1::new_object_array_id); + address a = Runtime1::entry_for (C1StubId::new_object_array_id); ce->emit_call_c(a); CHECK_BAILOUT(); ce->add_call_info_here(_info); @@ -217,11 +217,11 @@ void NewObjectArrayStub::emit_code(LIR_Assembler* ce) { void MonitorEnterStub::emit_code(LIR_Assembler* ce) { __ bind(_entry); - Runtime1::StubID enter_id; + C1StubId enter_id; if (ce->compilation()->has_fpu_code()) { - enter_id = Runtime1::monitorenter_id; + enter_id = C1StubId::monitorenter_id; } else { - enter_id = Runtime1::monitorenter_nofpu_id; + enter_id = C1StubId::monitorenter_nofpu_id; } __ lgr_if_needed(Z_R1_scratch, _obj_reg->as_register()); __ lgr_if_needed(Z_R13, _lock_reg->as_register()); // See LIRGenerator::syncTempOpr(). @@ -242,11 +242,11 @@ void MonitorExitStub::emit_code(LIR_Assembler* ce) { __ lgr_if_needed(Z_R1_scratch, _lock_reg->as_register()); } // Note: non-blocking leaf routine => no call info needed. - Runtime1::StubID exit_id; + C1StubId exit_id; if (ce->compilation()->has_fpu_code()) { - exit_id = Runtime1::monitorexit_id; + exit_id = C1StubId::monitorexit_id; } else { - exit_id = Runtime1::monitorexit_nofpu_id; + exit_id = C1StubId::monitorexit_nofpu_id; } ce->emit_call_c(Runtime1::entry_for (exit_id)); CHECK_BAILOUT(); @@ -378,10 +378,10 @@ void PatchingStub::emit_code(LIR_Assembler* ce) { address target = nullptr; relocInfo::relocType reloc_type = relocInfo::none; switch (_id) { - case access_field_id: target = Runtime1::entry_for (Runtime1::access_field_patching_id); break; - case load_klass_id: target = Runtime1::entry_for (Runtime1::load_klass_patching_id); reloc_type = relocInfo::metadata_type; break; - case load_mirror_id: target = Runtime1::entry_for (Runtime1::load_mirror_patching_id); reloc_type = relocInfo::oop_type; break; - case load_appendix_id: target = Runtime1::entry_for (Runtime1::load_appendix_patching_id); reloc_type = relocInfo::oop_type; break; + case access_field_id: target = Runtime1::entry_for (C1StubId::access_field_patching_id); break; + case load_klass_id: target = Runtime1::entry_for (C1StubId::load_klass_patching_id); reloc_type = relocInfo::metadata_type; break; + case load_mirror_id: target = Runtime1::entry_for (C1StubId::load_mirror_patching_id); reloc_type = relocInfo::oop_type; break; + case load_appendix_id: target = Runtime1::entry_for (C1StubId::load_appendix_patching_id); reloc_type = relocInfo::oop_type; break; default: ShouldNotReachHere(); } __ bind(call_patch); @@ -406,7 +406,7 @@ void PatchingStub::emit_code(LIR_Assembler* ce) { void DeoptimizeStub::emit_code(LIR_Assembler* ce) { __ bind(_entry); __ load_const_optimized(Z_R1_scratch, _trap_request); // Pass trap request in Z_R1_scratch. - ce->emit_call_c(Runtime1::entry_for (Runtime1::deoptimize_id)); + ce->emit_call_c(Runtime1::entry_for (C1StubId::deoptimize_id)); CHECK_BAILOUT(); ce->add_call_info_here(_info); DEBUG_ONLY(__ should_not_reach_here()); diff --git a/src/hotspot/cpu/s390/c1_LIRAssembler_s390.cpp b/src/hotspot/cpu/s390/c1_LIRAssembler_s390.cpp index a5e62169a93..8990cf1663d 100644 --- a/src/hotspot/cpu/s390/c1_LIRAssembler_s390.cpp +++ b/src/hotspot/cpu/s390/c1_LIRAssembler_s390.cpp @@ -172,7 +172,7 @@ int LIR_Assembler::emit_exception_handler() { int offset = code_offset(); - address a = Runtime1::entry_for (Runtime1::handle_exception_from_callee_id); + address a = Runtime1::entry_for (C1StubId::handle_exception_from_callee_id); address call_addr = emit_call_c(a); CHECK_BAILOUT_(-1); __ should_not_reach_here(); @@ -212,7 +212,7 @@ int LIR_Assembler::emit_unwind_handler() { // Perform needed unlocking. MonitorExitStub* stub = nullptr; if (method()->is_synchronized()) { - // Runtime1::monitorexit_id expects lock address in Z_R1_scratch. + // C1StubId::monitorexit_id expects lock address in Z_R1_scratch. LIR_Opr lock = FrameMap::as_opr(Z_R1_scratch); monitor_address(0, lock); stub = new MonitorExitStub(lock, true, 0); @@ -241,7 +241,7 @@ int LIR_Assembler::emit_unwind_handler() { // Z_EXC_PC: exception pc // Dispatch to the unwind logic. - __ load_const_optimized(Z_R5, Runtime1::entry_for (Runtime1::unwind_exception_id)); + __ load_const_optimized(Z_R5, Runtime1::entry_for (C1StubId::unwind_exception_id)); __ z_br(Z_R5); // Emit the slow path assembly. @@ -1910,8 +1910,8 @@ void LIR_Assembler::throw_op(LIR_Opr exceptionPC, LIR_Opr exceptionOop, CodeEmit // Reuse the debug info from the safepoint poll for the throw op itself. __ get_PC(Z_EXC_PC); add_call_info(__ offset(), info); // for exception handler - address stub = Runtime1::entry_for (compilation()->has_fpu_code() ? Runtime1::handle_exception_id - : Runtime1::handle_exception_nofpu_id); + address stub = Runtime1::entry_for (compilation()->has_fpu_code() ? C1StubId::handle_exception_id + : C1StubId::handle_exception_nofpu_id); emit_call_c(stub); } @@ -2116,7 +2116,7 @@ void LIR_Assembler::emit_arraycopy(LIR_OpArrayCopy* op) { store_parameter(src_klass, 0); // sub store_parameter(dst_klass, 1); // super - emit_call_c(Runtime1::entry_for (Runtime1::slow_subtype_check_id)); + emit_call_c(Runtime1::entry_for (C1StubId::slow_subtype_check_id)); CHECK_BAILOUT2(cont, slow); // Sets condition code 0 for match (2 otherwise). __ branch_optimized(Assembler::bcondEqual, cont); @@ -2350,6 +2350,7 @@ void LIR_Assembler::shift_op(LIR_Code code, LIR_Opr left, jint count, LIR_Opr de void LIR_Assembler::emit_alloc_obj(LIR_OpAllocObj* op) { if (op->init_check()) { // Make sure klass is initialized & doesn't have finalizer. + // init_state needs acquire, but S390 is TSO, and so we are already good. const int state_offset = in_bytes(InstanceKlass::init_state_offset()); Register iklass = op->klass()->as_register(); add_debug_info_for_null_check_here(op->stub()->info()); @@ -2539,7 +2540,7 @@ void LIR_Assembler::emit_typecheck_helper(LIR_OpTypeCheck *op, Label* success, L RegisterOrConstant(super_check_offset)); if (need_slow_path) { // Call out-of-line instance of __ check_klass_subtype_slow_path(...): - address a = Runtime1::entry_for (Runtime1::slow_subtype_check_id); + address a = Runtime1::entry_for (C1StubId::slow_subtype_check_id); store_parameter(klass_RInfo, 0); // sub store_parameter(k_RInfo, 1); // super emit_call_c(a); // Sets condition code 0 for match (2 otherwise). @@ -2614,7 +2615,7 @@ void LIR_Assembler::emit_opTypeCheck(LIR_OpTypeCheck* op) { // Perform the fast part of the checking logic. __ check_klass_subtype_fast_path(klass_RInfo, k_RInfo, Rtmp1, success_target, failure_target, nullptr); // Call out-of-line instance of __ check_klass_subtype_slow_path(...): - address a = Runtime1::entry_for (Runtime1::slow_subtype_check_id); + address a = Runtime1::entry_for (C1StubId::slow_subtype_check_id); store_parameter(klass_RInfo, 0); // sub store_parameter(k_RInfo, 1); // super emit_call_c(a); // Sets condition code 0 for match (2 otherwise). diff --git a/src/hotspot/cpu/s390/c1_LIRGenerator_s390.cpp b/src/hotspot/cpu/s390/c1_LIRGenerator_s390.cpp index 619f0f7174f..f998e86256f 100644 --- a/src/hotspot/cpu/s390/c1_LIRGenerator_s390.cpp +++ b/src/hotspot/cpu/s390/c1_LIRGenerator_s390.cpp @@ -885,7 +885,7 @@ void LIRGenerator::do_NewMultiArray(NewMultiArray* x) { args->append(rank); args->append(varargs); LIR_Opr reg = result_register_for (x->type()); - __ call_runtime(Runtime1::entry_for (Runtime1::new_multi_array_id), + __ call_runtime(Runtime1::entry_for (C1StubId::new_multi_array_id), LIR_OprFact::illegalOpr, reg, args, info); @@ -916,14 +916,14 @@ void LIRGenerator::do_CheckCast(CheckCast* x) { CodeStub* stub; if (x->is_incompatible_class_change_check()) { assert(patching_info == nullptr, "can't patch this"); - stub = new SimpleExceptionStub(Runtime1::throw_incompatible_class_change_error_id, LIR_OprFact::illegalOpr, info_for_exception); + stub = new SimpleExceptionStub(C1StubId::throw_incompatible_class_change_error_id, LIR_OprFact::illegalOpr, info_for_exception); } else if (x->is_invokespecial_receiver_check()) { assert(patching_info == nullptr, "can't patch this"); stub = new DeoptimizeStub(info_for_exception, Deoptimization::Reason_class_check, Deoptimization::Action_none); } else { - stub = new SimpleExceptionStub(Runtime1::throw_class_cast_exception_id, obj.result(), info_for_exception); + stub = new SimpleExceptionStub(C1StubId::throw_class_cast_exception_id, obj.result(), info_for_exception); } LIR_Opr reg = rlock_result(x); LIR_Opr tmp1 = new_register(objectType); diff --git a/src/hotspot/cpu/s390/c1_MacroAssembler_s390.cpp b/src/hotspot/cpu/s390/c1_MacroAssembler_s390.cpp index 13b08067821..f6dd20db3d6 100644 --- a/src/hotspot/cpu/s390/c1_MacroAssembler_s390.cpp +++ b/src/hotspot/cpu/s390/c1_MacroAssembler_s390.cpp @@ -72,14 +72,14 @@ void C1_MacroAssembler::lock_object(Register Rmark, Register Roop, Register Rbox if (DiagnoseSyncOnValueBasedClasses != 0) { load_klass(tmp, Roop); - testbit(Address(tmp, Klass::access_flags_offset()), exact_log2(JVM_ACC_IS_VALUE_BASED_CLASS)); + z_tm(Address(tmp, Klass::misc_flags_offset()), KlassFlags::_misc_is_value_based_class); branch_optimized(Assembler::bcondAllOne, slow_case); } assert(LockingMode != LM_MONITOR, "LM_MONITOR is already handled, by emit_lock()"); if (LockingMode == LM_LIGHTWEIGHT) { - lightweight_lock(Roop, Rmark, tmp, slow_case); + lightweight_lock(Rbox, Roop, Rmark, tmp, slow_case); } else if (LockingMode == LM_LEGACY) { NearLabel done; @@ -254,7 +254,7 @@ void C1_MacroAssembler::initialize_object( // Dtrace support is unimplemented. // if (CURRENT_ENV->dtrace_alloc_probes()) { // assert(obj == rax, "must be"); - // call(RuntimeAddress(Runtime1::entry_for (Runtime1::dtrace_object_alloc_id))); + // call(RuntimeAddress(Runtime1::entry_for (C1StubId::dtrace_object_alloc_id))); // } verify_oop(obj, FILE_AND_LINE); @@ -315,7 +315,7 @@ void C1_MacroAssembler::allocate_array( // Dtrace support is unimplemented. // if (CURRENT_ENV->dtrace_alloc_probes()) { // assert(obj == rax, "must be"); - // call(RuntimeAddress(Runtime1::entry_for (Runtime1::dtrace_object_alloc_id))); + // call(RuntimeAddress(Runtime1::entry_for (C1StubId::dtrace_object_alloc_id))); // } verify_oop(obj, FILE_AND_LINE); diff --git a/src/hotspot/cpu/s390/c1_Runtime1_s390.cpp b/src/hotspot/cpu/s390/c1_Runtime1_s390.cpp index decb3a1cafc..2f629c108c9 100644 --- a/src/hotspot/cpu/s390/c1_Runtime1_s390.cpp +++ b/src/hotspot/cpu/s390/c1_Runtime1_s390.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016, 2023 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -98,10 +98,10 @@ int StubAssembler::call_RT(Register oop_result1, Register metadata_result, addre restore_return_pc(); load_const_optimized(Z_R1, StubRoutines::forward_exception_entry()); z_br(Z_R1); - } else if (_stub_id == Runtime1::forward_exception_id) { + } else if (_stub_id == (int)C1StubId::forward_exception_id) { should_not_reach_here(); } else { - load_const_optimized(Z_R1, Runtime1::entry_for (Runtime1::forward_exception_id)); + load_const_optimized(Z_R1, Runtime1::entry_for (C1StubId::forward_exception_id)); z_br(Z_R1); } @@ -305,7 +305,7 @@ OopMapSet* Runtime1::generate_patching(StubAssembler* sasm, address target) { return oop_maps; } -OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { +OopMapSet* Runtime1::generate_code_for(C1StubId id, StubAssembler* sasm) { // for better readability const bool must_gc_arguments = true; @@ -318,26 +318,26 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { // Stub code and info for the different stubs. OopMapSet* oop_maps = nullptr; switch (id) { - case forward_exception_id: + case C1StubId::forward_exception_id: { oop_maps = generate_handle_exception(id, sasm); // will not return } break; - case new_instance_id: - case fast_new_instance_id: - case fast_new_instance_init_check_id: + case C1StubId::new_instance_id: + case C1StubId::fast_new_instance_id: + case C1StubId::fast_new_instance_init_check_id: { Register klass = Z_R11; // Incoming Register obj = Z_R2; // Result - if (id == new_instance_id) { + if (id == C1StubId::new_instance_id) { __ set_info("new_instance", dont_gc_arguments); - } else if (id == fast_new_instance_id) { + } else if (id == C1StubId::fast_new_instance_id) { __ set_info("fast new_instance", dont_gc_arguments); } else { - assert(id == fast_new_instance_init_check_id, "bad StubID"); + assert(id == C1StubId::fast_new_instance_init_check_id, "bad C1StubId"); __ set_info("fast new_instance init check", dont_gc_arguments); } @@ -352,7 +352,7 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case counter_overflow_id: + case C1StubId::counter_overflow_id: { // Arguments : // bci : stack param 0 @@ -371,14 +371,14 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { __ z_br(Z_R14); } break; - case new_type_array_id: - case new_object_array_id: + case C1StubId::new_type_array_id: + case C1StubId::new_object_array_id: { Register length = Z_R13; // Incoming Register klass = Z_R11; // Incoming Register obj = Z_R2; // Result - if (id == new_type_array_id) { + if (id == C1StubId::new_type_array_id) { __ set_info("new_type_array", dont_gc_arguments); } else { __ set_info("new_object_array", dont_gc_arguments); @@ -391,7 +391,7 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { Register t0 = obj; __ mem2reg_opt(t0, Address(klass, Klass::layout_helper_offset()), false); __ z_sra(t0, Klass::_lh_array_tag_shift); - int tag = ((id == new_type_array_id) + int tag = ((id == C1StubId::new_type_array_id) ? Klass::_lh_array_tag_type_value : Klass::_lh_array_tag_obj_value); __ compare32_and_branch(t0, tag, Assembler::bcondEqual, ok); @@ -403,7 +403,7 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { OopMap* map = save_live_registers_except_r2(sasm); int call_offset; - if (id == new_type_array_id) { + if (id == C1StubId::new_type_array_id) { call_offset = __ call_RT(obj, noreg, CAST_FROM_FN_PTR(address, new_type_array), klass, length); } else { call_offset = __ call_RT(obj, noreg, CAST_FROM_FN_PTR(address, new_object_array), klass, length); @@ -418,7 +418,7 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case new_multi_array_id: + case C1StubId::new_multi_array_id: { __ set_info("new_multi_array", dont_gc_arguments); // Z_R3,: klass // Z_R4,: rank @@ -436,14 +436,14 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case register_finalizer_id: + case C1StubId::register_finalizer_id: { __ set_info("register_finalizer", dont_gc_arguments); // Load the klass and check the has finalizer flag. Register klass = Z_ARG2; __ load_klass(klass, Z_ARG1); - __ testbit(Address(klass, Klass::access_flags_offset()), exact_log2(JVM_ACC_HAS_FINALIZER)); + __ z_tm(Address(klass, Klass::misc_flags_offset()), KlassFlags::_misc_has_finalizer); __ z_bcr(Assembler::bcondAllZero, Z_R14); // Return if bit is not set. OopMap* oop_map = save_live_registers(sasm); @@ -459,62 +459,62 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case throw_range_check_failed_id: + case C1StubId::throw_range_check_failed_id: { __ set_info("range_check_failed", dont_gc_arguments); oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_range_check_exception), true); } break; - case throw_index_exception_id: + case C1StubId::throw_index_exception_id: { __ set_info("index_range_check_failed", dont_gc_arguments); oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_index_exception), true); } break; - case throw_div0_exception_id: + case C1StubId::throw_div0_exception_id: { __ set_info("throw_div0_exception", dont_gc_arguments); oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_div0_exception), false); } break; - case throw_null_pointer_exception_id: + case C1StubId::throw_null_pointer_exception_id: { __ set_info("throw_null_pointer_exception", dont_gc_arguments); oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_null_pointer_exception), false); } break; - case handle_exception_nofpu_id: - case handle_exception_id: + case C1StubId::handle_exception_nofpu_id: + case C1StubId::handle_exception_id: { __ set_info("handle_exception", dont_gc_arguments); oop_maps = generate_handle_exception(id, sasm); } break; - case handle_exception_from_callee_id: + case C1StubId::handle_exception_from_callee_id: { __ set_info("handle_exception_from_callee", dont_gc_arguments); oop_maps = generate_handle_exception(id, sasm); } break; - case unwind_exception_id: + case C1StubId::unwind_exception_id: { __ set_info("unwind_exception", dont_gc_arguments); // Note: no stubframe since we are about to leave the current // activation and we are calling a leaf VM function only. generate_unwind_exception(sasm); } break; - case throw_array_store_exception_id: + case C1StubId::throw_array_store_exception_id: { __ set_info("throw_array_store_exception", dont_gc_arguments); oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_array_store_exception), true); } break; - case throw_class_cast_exception_id: + case C1StubId::throw_class_cast_exception_id: { // Z_R1_scratch: object __ set_info("throw_class_cast_exception", dont_gc_arguments); oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_class_cast_exception), true); } break; - case throw_incompatible_class_change_error_id: + case C1StubId::throw_incompatible_class_change_error_id: { __ set_info("throw_incompatible_class_cast_exception", dont_gc_arguments); oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_incompatible_class_change_error), false); } break; - case slow_subtype_check_id: + case C1StubId::slow_subtype_check_id: { // Arguments : // sub : stack param 0 @@ -580,13 +580,13 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { __ z_br(Z_R14); } break; - case monitorenter_nofpu_id: - case monitorenter_id: + case C1StubId::monitorenter_nofpu_id: + case C1StubId::monitorenter_id: { // Z_R1_scratch : object // Z_R13 : lock address (see LIRGenerator::syncTempOpr()) __ set_info("monitorenter", dont_gc_arguments); - int save_fpu_registers = (id == monitorenter_id); + int save_fpu_registers = (id == C1StubId::monitorenter_id); // Make a frame and preserve the caller's caller-save registers. OopMap* oop_map = save_live_registers(sasm, save_fpu_registers); @@ -600,15 +600,15 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case monitorexit_nofpu_id: - case monitorexit_id: + case C1StubId::monitorexit_nofpu_id: + case C1StubId::monitorexit_id: { // Z_R1_scratch : lock address // Note: really a leaf routine but must setup last java sp // => Use call_RT for now (speed can be improved by // doing last java sp setup manually). __ set_info("monitorexit", dont_gc_arguments); - int save_fpu_registers = (id == monitorexit_id); + int save_fpu_registers = (id == C1StubId::monitorexit_id); // Make a frame and preserve the caller's caller-save registers. OopMap* oop_map = save_live_registers(sasm, save_fpu_registers); @@ -622,7 +622,7 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case deoptimize_id: + case C1StubId::deoptimize_id: { // Args: Z_R1_scratch: trap request __ set_info("deoptimize", dont_gc_arguments); Register trap_request = Z_R1_scratch; @@ -639,32 +639,32 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case access_field_patching_id: + case C1StubId::access_field_patching_id: { __ set_info("access_field_patching", dont_gc_arguments); oop_maps = generate_patching(sasm, CAST_FROM_FN_PTR(address, access_field_patching)); } break; - case load_klass_patching_id: + case C1StubId::load_klass_patching_id: { __ set_info("load_klass_patching", dont_gc_arguments); // We should set up register map. oop_maps = generate_patching(sasm, CAST_FROM_FN_PTR(address, move_klass_patching)); } break; - case load_mirror_patching_id: + case C1StubId::load_mirror_patching_id: { __ set_info("load_mirror_patching", dont_gc_arguments); oop_maps = generate_patching(sasm, CAST_FROM_FN_PTR(address, move_mirror_patching)); } break; - case load_appendix_patching_id: + case C1StubId::load_appendix_patching_id: { __ set_info("load_appendix_patching", dont_gc_arguments); oop_maps = generate_patching(sasm, CAST_FROM_FN_PTR(address, move_appendix_patching)); } break; #if 0 - case dtrace_object_alloc_id: + case C1StubId::dtrace_object_alloc_id: { // rax,: object StubFrame f(sasm, "dtrace_object_alloc", dont_gc_arguments); // We can't gc here so skip the oopmap but make sure that all @@ -679,7 +679,7 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case fpu2long_stub_id: + case C1StubId::fpu2long_stub_id: { // rax, and rdx are destroyed, but should be free since the result is returned there // preserve rsi,ecx @@ -754,7 +754,7 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { break; #endif // TODO - case predicate_failed_trap_id: + case C1StubId::predicate_failed_trap_id: { __ set_info("predicate_failed_trap", dont_gc_arguments); @@ -775,14 +775,14 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { default: { - __ should_not_reach_here(FILE_AND_LINE, id); + __ should_not_reach_here(FILE_AND_LINE, (int)id); } break; } return oop_maps; } -OopMapSet* Runtime1::generate_handle_exception(StubID id, StubAssembler *sasm) { +OopMapSet* Runtime1::generate_handle_exception(C1StubId id, StubAssembler *sasm) { __ block_comment("generate_handle_exception"); // incoming parameters: Z_EXC_OOP, Z_EXC_PC @@ -793,7 +793,7 @@ OopMapSet* Runtime1::generate_handle_exception(StubID id, StubAssembler *sasm) { Register reg_fp = Z_R1_scratch; switch (id) { - case forward_exception_id: { + case C1StubId::forward_exception_id: { // We're handling an exception in the context of a compiled frame. // The registers have been saved in the standard places. Perform // an exception lookup in the caller and dispatch to the handler @@ -820,13 +820,13 @@ OopMapSet* Runtime1::generate_handle_exception(StubID id, StubAssembler *sasm) { __ clear_mem(Address(Z_thread, JavaThread::vm_result_2_offset()), sizeof(Metadata*)); break; } - case handle_exception_nofpu_id: - case handle_exception_id: + case C1StubId::handle_exception_nofpu_id: + case C1StubId::handle_exception_id: // At this point all registers MAY be live. DEBUG_ONLY(__ z_lgr(reg_fp, Z_SP);) - oop_map = save_live_registers(sasm, id != handle_exception_nofpu_id, Z_EXC_PC); + oop_map = save_live_registers(sasm, id != C1StubId::handle_exception_nofpu_id, Z_EXC_PC); break; - case handle_exception_from_callee_id: { + case C1StubId::handle_exception_from_callee_id: { // At this point all registers except Z_EXC_OOP and Z_EXC_PC are dead. DEBUG_ONLY(__ z_lgr(reg_fp, Z_SP);) __ save_return_pc(Z_EXC_PC); @@ -875,15 +875,15 @@ OopMapSet* Runtime1::generate_handle_exception(StubID id, StubAssembler *sasm) { __ invalidate_registers(Z_R2); switch(id) { - case forward_exception_id: - case handle_exception_nofpu_id: - case handle_exception_id: + case C1StubId::forward_exception_id: + case C1StubId::handle_exception_nofpu_id: + case C1StubId::handle_exception_id: // Restore the registers that were saved at the beginning. __ z_lgr(Z_R1_scratch, Z_R2); // Restoring live registers kills Z_R2. - restore_live_registers(sasm, id != handle_exception_nofpu_id); // Pops as well the frame. + restore_live_registers(sasm, id != C1StubId::handle_exception_nofpu_id); // Pops as well the frame. __ z_br(Z_R1_scratch); break; - case handle_exception_from_callee_id: { + case C1StubId::handle_exception_from_callee_id: { __ pop_frame(); __ z_br(Z_R2); // Jump to exception handler. } diff --git a/src/hotspot/cpu/s390/c2_MacroAssembler_s390.cpp b/src/hotspot/cpu/s390/c2_MacroAssembler_s390.cpp index 3641d82dabe..025ef4c8915 100644 --- a/src/hotspot/cpu/s390/c2_MacroAssembler_s390.cpp +++ b/src/hotspot/cpu/s390/c2_MacroAssembler_s390.cpp @@ -34,12 +34,12 @@ #define BIND(label) bind(label); BLOCK_COMMENT(#label ":") void C2_MacroAssembler::fast_lock_lightweight(Register obj, Register box, Register temp1, Register temp2) { - compiler_fast_lock_lightweight_object(obj, temp1, temp2); + compiler_fast_lock_lightweight_object(obj, box, temp1, temp2); } void C2_MacroAssembler::fast_unlock_lightweight(Register obj, Register box, Register temp1, Register temp2) { - compiler_fast_unlock_lightweight_object(obj, temp1, temp2); + compiler_fast_unlock_lightweight_object(obj, box, temp1, temp2); } //------------------------------------------------------ diff --git a/src/hotspot/cpu/s390/downcallLinker_s390.cpp b/src/hotspot/cpu/s390/downcallLinker_s390.cpp index 383a3244874..85ddc5bf185 100644 --- a/src/hotspot/cpu/s390/downcallLinker_s390.cpp +++ b/src/hotspot/cpu/s390/downcallLinker_s390.cpp @@ -36,8 +36,8 @@ #define __ _masm-> -static const int native_invoker_code_base_size = 512; -static const int native_invoker_size_per_args = 8; +static const int native_invoker_code_base_size = 384; +static const int native_invoker_size_per_args = 12; RuntimeStub* DowncallLinker::make_downcall_stub(BasicType* signature, int num_args, diff --git a/src/hotspot/cpu/s390/gc/g1/g1BarrierSetAssembler_s390.cpp b/src/hotspot/cpu/s390/gc/g1/g1BarrierSetAssembler_s390.cpp index 37631298920..544c82d34a7 100644 --- a/src/hotspot/cpu/s390/gc/g1/g1BarrierSetAssembler_s390.cpp +++ b/src/hotspot/cpu/s390/gc/g1/g1BarrierSetAssembler_s390.cpp @@ -1,6 +1,6 @@ /* - * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2018, 2023 SAP SE. All rights reserved. + * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024 SAP SE. 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 @@ -42,11 +42,47 @@ #include "c1/c1_LIRAssembler.hpp" #include "c1/c1_MacroAssembler.hpp" #include "gc/g1/c1/g1BarrierSetC1.hpp" -#endif +#endif // COMPILER1 +#ifdef COMPILER2 +#include "gc/g1/c2/g1BarrierSetC2.hpp" +#endif // COMPILER2 #define __ masm-> -#define BLOCK_COMMENT(str) if (PrintAssembly) __ block_comment(str) +#define BLOCK_COMMENT(str) __ block_comment(str) + +static void generate_pre_barrier_fast_path(MacroAssembler* masm, + const Register thread, + const Register tmp1) { + Address in_progress(thread, in_bytes(G1ThreadLocalData::satb_mark_queue_active_offset())); + // Is marking active? + if (in_bytes(SATBMarkQueue::byte_width_of_active()) == 4) { + __ load_and_test_int(tmp1, in_progress); + } else { + assert(in_bytes(SATBMarkQueue::byte_width_of_active()) == 1, "Assumption"); + __ load_and_test_byte(tmp1, in_progress); + } +} + +static void generate_queue_test_and_insertion(MacroAssembler* masm, ByteSize index_offset, ByteSize buffer_offset, Label& runtime, + const Register Z_thread, const Register value, const Register temp) { + BLOCK_COMMENT("generate_queue_test_and_insertion {"); + + assert_different_registers(temp, value); + // Can we store a value in the given thread's buffer? + // (The index field is typed as size_t.) + + __ load_and_test_long(temp, Address(Z_thread, in_bytes(index_offset))); // temp := *(index address) + __ branch_optimized(Assembler::bcondEqual, runtime); // jump to runtime if index == 0 (full buffer) + + // The buffer is not full, store value into it. + __ add2reg(temp, -wordSize); // temp := next index + __ z_stg(temp, in_bytes(index_offset), Z_thread); // *(index address) := next index + + __ z_ag(temp, Address(Z_thread, in_bytes(buffer_offset))); // temp := buffer address + next index + __ z_stg(value, 0, temp); // *(buffer address + next index) := value + BLOCK_COMMENT("} generate_queue_test_and_insertion"); +} void G1BarrierSetAssembler::gen_write_ref_array_pre_barrier(MacroAssembler* masm, DecoratorSet decorators, Register addr, Register count) { @@ -59,13 +95,8 @@ void G1BarrierSetAssembler::gen_write_ref_array_pre_barrier(MacroAssembler* masm assert_different_registers(addr, Z_R0_scratch); // would be destroyed by push_frame() assert_different_registers(count, Z_R0_scratch); // would be destroyed by push_frame() Register Rtmp1 = Z_R0_scratch; - const int active_offset = in_bytes(G1ThreadLocalData::satb_mark_queue_active_offset()); - if (in_bytes(SATBMarkQueue::byte_width_of_active()) == 4) { - __ load_and_test_int(Rtmp1, Address(Z_thread, active_offset)); - } else { - guarantee(in_bytes(SATBMarkQueue::byte_width_of_active()) == 1, "Assumption"); - __ load_and_test_byte(Rtmp1, Address(Z_thread, active_offset)); - } + + generate_pre_barrier_fast_path(masm, Z_thread, Rtmp1); __ z_bre(filtered); // Activity indicator is zero, so there is no marking going on currently. RegisterSaver::save_live_registers(masm, RegisterSaver::arg_registers); // Creates frame. @@ -100,6 +131,181 @@ void G1BarrierSetAssembler::gen_write_ref_array_post_barrier(MacroAssembler* mas } } +#if defined(COMPILER2) + +#undef __ +#define __ masm-> + +static void generate_c2_barrier_runtime_call(MacroAssembler* masm, G1BarrierStubC2* stub, const Register pre_val, const address runtime_path) { + BLOCK_COMMENT("generate_c2_barrier_runtime_call {"); + SaveLiveRegisters save_registers(masm, stub); + __ call_VM_leaf(runtime_path, pre_val, Z_thread); + BLOCK_COMMENT("} generate_c2_barrier_runtime_call"); +} + +void G1BarrierSetAssembler::g1_write_barrier_pre_c2(MacroAssembler* masm, + Register obj, + Register pre_val, + Register thread, + Register tmp1, + G1PreBarrierStubC2* stub) { + + BLOCK_COMMENT("g1_write_barrier_pre_c2 {"); + + assert(thread == Z_thread, "must be"); + assert_different_registers(obj, pre_val, tmp1); + assert(pre_val != noreg && tmp1 != noreg, "expecting a register"); + + stub->initialize_registers(obj, pre_val, thread, tmp1, noreg); + + generate_pre_barrier_fast_path(masm, thread, tmp1); + __ branch_optimized(Assembler::bcondNotEqual, *stub->entry()); // Activity indicator is zero, so there is no marking going on currently. + + __ bind(*stub->continuation()); + + BLOCK_COMMENT("} g1_write_barrier_pre_c2"); +} + +void G1BarrierSetAssembler::generate_c2_pre_barrier_stub(MacroAssembler* masm, + G1PreBarrierStubC2* stub) const { + + BLOCK_COMMENT("generate_c2_pre_barrier_stub {"); + + Assembler::InlineSkippedInstructionsCounter skip_counter(masm); + + Label runtime; + Register obj = stub->obj(); + Register pre_val = stub->pre_val(); + Register thread = stub->thread(); + Register tmp1 = stub->tmp1(); + + __ bind(*stub->entry()); + + BLOCK_COMMENT("generate_pre_val_not_null_test {"); + if (obj != noreg) { + __ load_heap_oop(pre_val, Address(obj), noreg, noreg, AS_RAW); + } + __ z_ltgr(pre_val, pre_val); + __ branch_optimized(Assembler::bcondEqual, *stub->continuation()); + BLOCK_COMMENT("} generate_pre_val_not_null_test"); + + generate_queue_test_and_insertion(masm, + G1ThreadLocalData::satb_mark_queue_index_offset(), + G1ThreadLocalData::satb_mark_queue_buffer_offset(), + runtime, + Z_thread, pre_val, tmp1); + + __ branch_optimized(Assembler::bcondAlways, *stub->continuation()); + + __ bind(runtime); + + generate_c2_barrier_runtime_call(masm, stub, pre_val, CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_field_pre_entry)); + + __ branch_optimized(Assembler::bcondAlways, *stub->continuation()); + + BLOCK_COMMENT("} generate_c2_pre_barrier_stub"); +} + +void G1BarrierSetAssembler::g1_write_barrier_post_c2(MacroAssembler* masm, + Register store_addr, + Register new_val, + Register thread, + Register tmp1, + Register tmp2, + G1PostBarrierStubC2* stub) { + BLOCK_COMMENT("g1_write_barrier_post_c2 {"); + + assert(thread == Z_thread, "must be"); + assert_different_registers(store_addr, new_val, thread, tmp1, tmp2, Z_R1_scratch); + + assert(store_addr != noreg && new_val != noreg && tmp1 != noreg && tmp2 != noreg, "expecting a register"); + + stub->initialize_registers(thread, tmp1, tmp2); + + BLOCK_COMMENT("generate_region_crossing_test {"); + if (VM_Version::has_DistinctOpnds()) { + __ z_xgrk(tmp1, store_addr, new_val); + } else { + __ z_lgr(tmp1, store_addr); + __ z_xgr(tmp1, new_val); + } + __ z_srag(tmp1, tmp1, G1HeapRegion::LogOfHRGrainBytes); + __ branch_optimized(Assembler::bcondEqual, *stub->continuation()); + BLOCK_COMMENT("} generate_region_crossing_test"); + + // crosses regions, storing null? + if ((stub->barrier_data() & G1C2BarrierPostNotNull) == 0) { + __ z_ltgr(new_val, new_val); + __ branch_optimized(Assembler::bcondEqual, *stub->continuation()); + } + + BLOCK_COMMENT("generate_card_young_test {"); + CardTableBarrierSet* ct = barrier_set_cast(BarrierSet::barrier_set()); + // calculate address of card + __ load_const_optimized(tmp2, (address)ct->card_table()->byte_map_base()); // Card table base. + __ z_srlg(tmp1, store_addr, CardTable::card_shift()); // Index into card table. + __ z_algr(tmp1, tmp2); // Explicit calculation needed for cli. + + // Filter young. + __ z_cli(0, tmp1, G1CardTable::g1_young_card_val()); + + BLOCK_COMMENT("} generate_card_young_test"); + + // From here on, tmp1 holds the card address. + __ branch_optimized(Assembler::bcondNotEqual, *stub->entry()); + + __ bind(*stub->continuation()); + + BLOCK_COMMENT("} g1_write_barrier_post_c2"); +} + +void G1BarrierSetAssembler::generate_c2_post_barrier_stub(MacroAssembler* masm, + G1PostBarrierStubC2* stub) const { + + BLOCK_COMMENT("generate_c2_post_barrier_stub {"); + + Assembler::InlineSkippedInstructionsCounter skip_counter(masm); + Label runtime; + + Register thread = stub->thread(); + Register tmp1 = stub->tmp1(); // tmp1 holds the card address. + Register tmp2 = stub->tmp2(); + Register Rcard_addr = tmp1; + + __ bind(*stub->entry()); + + BLOCK_COMMENT("generate_card_clean_test {"); + __ z_sync(); // Required to support concurrent cleaning. + __ z_cli(0, Rcard_addr, 0); // Reload after membar. + __ branch_optimized(Assembler::bcondEqual, *stub->continuation()); + BLOCK_COMMENT("} generate_card_clean_test"); + + BLOCK_COMMENT("generate_dirty_card {"); + // Storing a region crossing, non-null oop, card is clean. + // Dirty card and log. + STATIC_ASSERT(CardTable::dirty_card_val() == 0); + __ z_mvi(0, Rcard_addr, CardTable::dirty_card_val()); + BLOCK_COMMENT("} generate_dirty_card"); + + generate_queue_test_and_insertion(masm, + G1ThreadLocalData::dirty_card_queue_index_offset(), + G1ThreadLocalData::dirty_card_queue_buffer_offset(), + runtime, + Z_thread, tmp1, tmp2); + + __ branch_optimized(Assembler::bcondAlways, *stub->continuation()); + + __ bind(runtime); + + generate_c2_barrier_runtime_call(masm, stub, tmp1, CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_field_post_entry)); + + __ branch_optimized(Assembler::bcondAlways, *stub->continuation()); + + BLOCK_COMMENT("} generate_c2_post_barrier_stub"); +} + +#endif //COMPILER2 + void G1BarrierSetAssembler::load_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type, const Address& src, Register dst, Register tmp1, Register tmp2, Label *L_handle_null) { bool on_oop = is_reference_type(type); @@ -136,9 +342,6 @@ void G1BarrierSetAssembler::g1_write_barrier_pre(MacroAssembler* masm, Decorator const Register Robj = obj ? obj->base() : noreg, Roff = obj ? obj->index() : noreg; - const int active_offset = in_bytes(G1ThreadLocalData::satb_mark_queue_active_offset()); - const int buffer_offset = in_bytes(G1ThreadLocalData::satb_mark_queue_buffer_offset()); - const int index_offset = in_bytes(G1ThreadLocalData::satb_mark_queue_index_offset()); assert_different_registers(Rtmp1, Rtmp2, Z_R0_scratch); // None of the Rtmp must be Z_R0!! assert_different_registers(Robj, Z_R0_scratch); // Used for addressing. Furthermore, push_frame destroys Z_R0!! assert_different_registers(Rval, Z_R0_scratch); // push_frame destroys Z_R0!! @@ -147,14 +350,7 @@ void G1BarrierSetAssembler::g1_write_barrier_pre(MacroAssembler* masm, Decorator BLOCK_COMMENT("g1_write_barrier_pre {"); - // Is marking active? - // Note: value is loaded for test purposes only. No further use here. - if (in_bytes(SATBMarkQueue::byte_width_of_active()) == 4) { - __ load_and_test_int(Rtmp1, Address(Z_thread, active_offset)); - } else { - guarantee(in_bytes(SATBMarkQueue::byte_width_of_active()) == 1, "Assumption"); - __ load_and_test_byte(Rtmp1, Address(Z_thread, active_offset)); - } + generate_pre_barrier_fast_path(masm, Z_thread, Rtmp1); __ z_bre(filtered); // Activity indicator is zero, so there is no marking going on currently. assert(Rpre_val != noreg, "must have a real register"); @@ -194,24 +390,14 @@ void G1BarrierSetAssembler::g1_write_barrier_pre(MacroAssembler* masm, Decorator // We can store the original value in the thread's buffer // only if index > 0. Otherwise, we need runtime to handle. // (The index field is typed as size_t.) - Register Rbuffer = Rtmp1, Rindex = Rtmp2; - assert_different_registers(Rbuffer, Rindex, Rpre_val); - __ z_lg(Rbuffer, buffer_offset, Z_thread); - - __ load_and_test_long(Rindex, Address(Z_thread, index_offset)); - __ z_bre(callRuntime); // If index == 0, goto runtime. - - __ add2reg(Rindex, -wordSize); // Decrement index. - __ z_stg(Rindex, index_offset, Z_thread); - - // Record the previous value. - __ z_stg(Rpre_val, 0, Rbuffer, Rindex); + generate_queue_test_and_insertion(masm, + G1ThreadLocalData::satb_mark_queue_index_offset(), + G1ThreadLocalData::satb_mark_queue_buffer_offset(), + callRuntime, + Z_thread, Rpre_val, Rtmp2); __ z_bru(filtered); // We are done. - Rbuffer = noreg; // end of life - Rindex = noreg; // end of life - __ bind(callRuntime); // Save some registers (inputs and result) over runtime call @@ -326,23 +512,16 @@ void G1BarrierSetAssembler::g1_write_barrier_post(MacroAssembler* masm, Decorato Register Rcard_addr_x = Rcard_addr; Register Rqueue_index = (Rtmp2 != Z_R0_scratch) ? Rtmp2 : Rtmp1; - Register Rqueue_buf = (Rtmp3 != Z_R0_scratch) ? Rtmp3 : Rtmp1; - const int qidx_off = in_bytes(G1ThreadLocalData::dirty_card_queue_index_offset()); - const int qbuf_off = in_bytes(G1ThreadLocalData::dirty_card_queue_buffer_offset()); - if ((Rcard_addr == Rqueue_buf) || (Rcard_addr == Rqueue_index)) { + if (Rcard_addr == Rqueue_index) { Rcard_addr_x = Z_R0_scratch; // Register shortage. We have to use Z_R0. } __ lgr_if_needed(Rcard_addr_x, Rcard_addr); - __ load_and_test_long(Rqueue_index, Address(Z_thread, qidx_off)); - __ z_bre(callRuntime); // Index == 0 then jump to runtime. - - __ z_lg(Rqueue_buf, qbuf_off, Z_thread); - - __ add2reg(Rqueue_index, -wordSize); // Decrement index. - __ z_stg(Rqueue_index, qidx_off, Z_thread); - - __ z_stg(Rcard_addr_x, 0, Rqueue_index, Rqueue_buf); // Store card. + generate_queue_test_and_insertion(masm, + G1ThreadLocalData::dirty_card_queue_index_offset(), + G1ThreadLocalData::dirty_card_queue_buffer_offset(), + callRuntime, + Z_thread, Rcard_addr_x, Rqueue_index); __ z_bru(filtered); __ bind(callRuntime); diff --git a/src/hotspot/cpu/s390/gc/g1/g1BarrierSetAssembler_s390.hpp b/src/hotspot/cpu/s390/gc/g1/g1BarrierSetAssembler_s390.hpp index cc1d51d2fa1..0f0bdd8b83c 100644 --- a/src/hotspot/cpu/s390/gc/g1/g1BarrierSetAssembler_s390.hpp +++ b/src/hotspot/cpu/s390/gc/g1/g1BarrierSetAssembler_s390.hpp @@ -1,6 +1,6 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2018 SAP SE. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024 SAP SE. 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 @@ -34,6 +34,8 @@ class LIR_Assembler; class StubAssembler; class G1PreBarrierStub; class G1PostBarrierStub; +class G1PreBarrierStubC2; +class G1PostBarrierStubC2; class G1BarrierSetAssembler: public ModRefBarrierSetAssembler { protected: @@ -62,7 +64,27 @@ class G1BarrierSetAssembler: public ModRefBarrierSetAssembler { void generate_c1_pre_barrier_runtime_stub(StubAssembler* sasm); void generate_c1_post_barrier_runtime_stub(StubAssembler* sasm); -#endif +#endif // COMPILER1 + +#ifdef COMPILER2 + void g1_write_barrier_pre_c2(MacroAssembler* masm, + Register obj, + Register pre_val, + Register thread, + Register tmp1, + G1PreBarrierStubC2* c2_stub); + void generate_c2_pre_barrier_stub(MacroAssembler* masm, + G1PreBarrierStubC2* stub) const; + void g1_write_barrier_post_c2(MacroAssembler* masm, + Register store_addr, + Register new_val, + Register thread, + Register tmp1, + Register tmp2, + G1PostBarrierStubC2* c2_stub); + void generate_c2_post_barrier_stub(MacroAssembler* masm, + G1PostBarrierStubC2* stub) const; +#endif // COMPILER2 virtual void load_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type, const Address& src, Register dst, Register tmp1, Register tmp2, Label *L_handle_null = nullptr); diff --git a/src/hotspot/cpu/s390/gc/g1/g1_s390.ad b/src/hotspot/cpu/s390/gc/g1/g1_s390.ad new file mode 100644 index 00000000000..31f60c4aeff --- /dev/null +++ b/src/hotspot/cpu/s390/gc/g1/g1_s390.ad @@ -0,0 +1,457 @@ +// +// Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. +// Copyright 2024 IBM Corporation. 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. +// + +source_hpp %{ + +#include "gc/g1/c2/g1BarrierSetC2.hpp" +#include "gc/shared/gc_globals.hpp" + +%} + +source %{ + +#include "gc/g1/g1BarrierSetAssembler_s390.hpp" +#include "gc/g1/g1BarrierSetRuntime.hpp" + +static void write_barrier_pre(MacroAssembler* masm, + const MachNode* node, + Register obj, + Register pre_val, + Register tmp1, + RegSet preserve = RegSet(), + RegSet no_preserve = RegSet()) { + if (!G1PreBarrierStubC2::needs_barrier(node)) { + return; + } + Assembler::InlineSkippedInstructionsCounter skip_counter(masm); + G1BarrierSetAssembler* g1_asm = static_cast(BarrierSet::barrier_set()->barrier_set_assembler()); + G1PreBarrierStubC2* const stub = G1PreBarrierStubC2::create(node); + for (RegSetIterator reg = preserve.begin(); *reg != noreg; ++reg) { + stub->preserve(*reg); + } + for (RegSetIterator reg = no_preserve.begin(); *reg != noreg; ++reg) { + stub->dont_preserve(*reg); + } + g1_asm->g1_write_barrier_pre_c2(masm, obj, pre_val, Z_thread, tmp1, stub); +} + +static void write_barrier_post(MacroAssembler* masm, + const MachNode* node, + Register store_addr, + Register new_val, + Register tmp1, + Register tmp2) { + if (!G1PostBarrierStubC2::needs_barrier(node)) { + return; + } + Assembler::InlineSkippedInstructionsCounter skip_counter(masm); + G1BarrierSetAssembler* g1_asm = static_cast(BarrierSet::barrier_set()->barrier_set_assembler()); + G1PostBarrierStubC2* const stub = G1PostBarrierStubC2::create(node); + g1_asm->g1_write_barrier_post_c2(masm, store_addr, new_val, Z_thread, tmp1, tmp2, stub); +} + +%} // source + +// store pointer +instruct g1StoreP(indirect dst, memoryRegP src, iRegL tmp1, iRegL tmp2, flagsReg cr) %{ + predicate(UseG1GC && n->as_Store()->barrier_data() != 0); + match(Set dst (StoreP dst src)); + effect(TEMP tmp1, TEMP tmp2, KILL cr); + ins_cost(MEMORY_REF_COST); + format %{ "STG $src,$dst\t # ptr" %} + ins_encode %{ + __ block_comment("g1StoreP {"); + write_barrier_pre(masm, this, + $dst$$Register /* obj */, + $tmp1$$Register /* pre_val */, + $tmp2$$Register /* tmp1 */, + RegSet::of($dst$$Register, $src$$Register) /* preserve */); + + __ z_stg($src$$Register, Address($dst$$Register)); + + write_barrier_post(masm, this, + $dst$$Register, /* store_addr */ + $src$$Register /* new_val */, + $tmp1$$Register /* tmp1 */, + $tmp2$$Register /* tmp2 */); + __ block_comment("} g1StoreP"); + %} + ins_pipe(pipe_class_dummy); +%} + +// Store Compressed Pointer +instruct g1StoreN(indirect mem, iRegN_P2N src, iRegL tmp1, iRegL tmp2, iRegL tmp3, flagsReg cr) %{ + predicate(UseG1GC && n->as_Store()->barrier_data() != 0); + match(Set mem (StoreN mem src)); + effect(TEMP tmp1, TEMP tmp2, TEMP tmp3, KILL cr); + ins_cost(MEMORY_REF_COST); + format %{ "STY $src,$mem\t # (cOop)" %} + ins_encode %{ + __ block_comment("g1StoreN {"); + write_barrier_pre(masm, this, + $mem$$Register /* obj */, + $tmp1$$Register /* pre_val */, + $tmp2$$Register /* tmp1 */, + RegSet::of($mem$$Register, $src$$Register) /* preserve */); + + __ z_sty($src$$Register, Address($mem$$Register)); + + if ((barrier_data() & G1C2BarrierPost) != 0) { + if ((barrier_data() & G1C2BarrierPostNotNull) == 0) { + __ oop_decoder($tmp1$$Register, $src$$Register, true /* maybe_null */); + } else { + __ oop_decoder($tmp1$$Register, $src$$Register, false /* maybe_null */); + } + } + + write_barrier_post(masm, this, + $mem$$Register /* store_addr */, + $tmp1$$Register /* new_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */); + __ block_comment("} g1StoreN"); + %} + + ins_pipe(pipe_class_dummy); +%} + +instruct g1CompareAndSwapN(indirect mem_ptr, rarg5RegN oldval, iRegN_P2N newval, iRegI res, iRegL tmp1, iRegL tmp2, iRegL tmp3, flagsReg cr) %{ + predicate(UseG1GC && n->as_LoadStore()->barrier_data() != 0); + match(Set res (CompareAndSwapN mem_ptr (Binary oldval newval))); + match(Set res (WeakCompareAndSwapN mem_ptr (Binary oldval newval))); + effect(USE mem_ptr, TEMP res, TEMP tmp1, TEMP tmp2, TEMP tmp3, USE_KILL oldval, KILL cr); + format %{ "$res = CompareAndSwapN $oldval,$newval,$mem_ptr" %} + ins_encode %{ + assert_different_registers($oldval$$Register, $mem_ptr$$Register); + assert_different_registers($newval$$Register, $mem_ptr$$Register); + __ block_comment("g1compareAndSwapN {"); + + Register Rcomp = reg_to_register_object($oldval$$reg); + Register Rnew = reg_to_register_object($newval$$reg); + Register Raddr = reg_to_register_object($mem_ptr$$reg); + Register Rres = reg_to_register_object($res$$reg); + + write_barrier_pre(masm, this, + Raddr /* obj */, + $tmp1$$Register /* pre_val */, + $tmp2$$Register /* tmp1 */, + RegSet::of(Raddr, Rcomp, Rnew) /* preserve */, + RegSet::of(Rres) /* no_preserve */); + + __ z_cs(Rcomp, Rnew, 0, Raddr); + + assert_different_registers(Rres, Raddr); + if (VM_Version::has_LoadStoreConditional()) { + __ load_const_optimized(Z_R0_scratch, 0L); // false (failed) + __ load_const_optimized(Rres, 1L); // true (succeed) + __ z_locgr(Rres, Z_R0_scratch, Assembler::bcondNotEqual); + } else { + Label done; + __ load_const_optimized(Rres, 0L); // false (failed) + __ z_brne(done); // Assume true to be the common case. + __ load_const_optimized(Rres, 1L); // true (succeed) + __ bind(done); + } + + __ oop_decoder($tmp3$$Register, Rnew, true /* maybe_null */); + + write_barrier_post(masm, this, + Raddr /* store_addr */, + $tmp3$$Register /* new_val */, + $tmp1$$Register /* tmp1 */, + $tmp2$$Register /* tmp2 */); + __ block_comment("} g1compareAndSwapN"); + %} + ins_pipe(pipe_class_dummy); +%} + +instruct g1CompareAndExchangeN(iRegP mem_ptr, rarg5RegN oldval, iRegN_P2N newval, iRegN res, iRegL tmp1, iRegL tmp2, iRegL tmp3, flagsReg cr) %{ + predicate(UseG1GC && n->as_LoadStore()->barrier_data() != 0); + match(Set res (CompareAndExchangeN mem_ptr (Binary oldval newval))); + effect(USE mem_ptr, TEMP res, TEMP tmp1, TEMP tmp2, TEMP tmp3, USE_KILL oldval, KILL cr); + format %{ "$res = CompareAndExchangeN $oldval,$newval,$mem_ptr" %} + ins_encode %{ + assert_different_registers($oldval$$Register, $mem_ptr$$Register); + assert_different_registers($newval$$Register, $mem_ptr$$Register); + __ block_comment("g1CompareAndExchangeN {"); + write_barrier_pre(masm, this, + $mem_ptr$$Register /* obj */, + $tmp1$$Register /* pre_val */, + $tmp2$$Register /* tmp1 */, + RegSet::of($mem_ptr$$Register, $oldval$$Register, $newval$$Register) /* preserve */, + RegSet::of($res$$Register) /* no_preserve */); + + Register Rcomp = reg_to_register_object($oldval$$reg); + Register Rnew = reg_to_register_object($newval$$reg); + Register Raddr = reg_to_register_object($mem_ptr$$reg); + + Register Rres = reg_to_register_object($res$$reg); + assert_different_registers(Rres, Raddr); + + __ z_lgr(Rres, Rcomp); // previous contents + __ z_csy(Rres, Rnew, 0, Raddr); // Try to store new value. + + __ oop_decoder($tmp1$$Register, Rnew, true /* maybe_null */); + + write_barrier_post(masm, this, + Raddr /* store_addr */, + $tmp1$$Register /* new_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */); + __ block_comment("} g1CompareAndExchangeN"); + %} + ins_pipe(pipe_class_dummy); +%} + +// Load narrow oop +instruct g1LoadN(iRegN dst, indirect mem, iRegP tmp1, iRegP tmp2, flagsReg cr) %{ + predicate(UseG1GC && n->as_Load()->barrier_data() != 0); + match(Set dst (LoadN mem)); + effect(TEMP dst, TEMP tmp1, TEMP tmp2, KILL cr); + ins_cost(MEMORY_REF_COST); + format %{ "LoadN $dst,$mem\t # (cOop)" %} + ins_encode %{ + __ block_comment("g1LoadN {"); + __ z_llgf($dst$$Register, Address($mem$$Register)); + if ((barrier_data() & G1C2BarrierPre) != 0) { + __ oop_decoder($tmp1$$Register, $dst$$Register, true); + write_barrier_pre(masm, this, + noreg /* obj */, + $tmp1$$Register /* pre_val */, + $tmp2$$Register ); + } + __ block_comment("} g1LoadN"); + %} + ins_pipe(pipe_class_dummy); +%} + +instruct g1GetAndSetN(indirect mem, iRegN dst, iRegI tmp, iRegL tmp1, iRegL tmp2, iRegL tmp3, flagsReg cr) %{ + predicate(UseG1GC && n->as_LoadStore()->barrier_data() != 0); + match(Set dst (GetAndSetN mem dst)); + effect(KILL cr, TEMP tmp, TEMP tmp1, TEMP tmp2, TEMP tmp3); // USE_DEF dst by match rule. + format %{ "XCHGN $dst,[$mem]\t # EXCHANGE (coop, atomic), temp $tmp" %} + ins_encode %{ + __ block_comment("g1GetAndSetN {"); + assert_different_registers($mem$$Register, $dst$$Register); + write_barrier_pre(masm, this, + $mem$$Register /* obj */, + $tmp1$$Register /* pre_val */, + $tmp2$$Register /* tmp1 */, + RegSet::of($mem$$Register, $dst$$Register) /* preserve */); + + Register Rdst = reg_to_register_object($dst$$reg); + Register Rtmp = reg_to_register_object($tmp$$reg); + guarantee(Rdst != Rtmp, "Fix match rule to use TEMP_DEF"); + Label retry; + + // Iterate until swap succeeds. + __ z_llgf(Rtmp, Address($mem$$Register)); // current contents + __ bind(retry); + // Calculate incremented value. + __ z_csy(Rtmp, Rdst, Address($mem$$Register)); // Try to store new value. + __ z_brne(retry); // Yikes, concurrent update, need to retry. + + __ oop_decoder($tmp1$$Register, $dst$$Register, true /* maybe_null */); + + __ z_lgr(Rdst, Rtmp); // Exchanged value from memory is return value. + + write_barrier_post(masm, this, + $mem$$Register /* store_addr */, + $tmp1$$Register /* new_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */); + + __ block_comment("} g1GetAndSetN"); + %} + ins_pipe(pipe_class_dummy); +%} + +instruct g1CompareAndSwapP(iRegP mem_ptr, rarg5RegP oldval, iRegP_N2P newval, iRegI res, iRegL tmp1, iRegL tmp2, flagsReg cr) %{ + predicate(UseG1GC && n->as_LoadStore()->barrier_data() != 0); + match(Set res (CompareAndSwapP mem_ptr (Binary oldval newval))); + match(Set res (WeakCompareAndSwapP mem_ptr (Binary oldval newval))); + effect(TEMP res, TEMP tmp1, TEMP tmp2, USE mem_ptr, USE_KILL oldval, KILL cr); + format %{ "$res = CompareAndSwapP $oldval,$newval,$mem_ptr" %} + ins_encode %{ + __ block_comment("g1CompareAndSwapP {"); + assert_different_registers($oldval$$Register, $mem_ptr$$Register); + assert_different_registers($newval$$Register, $mem_ptr$$Register); + + Register Rcomp = reg_to_register_object($oldval$$reg); + Register Rnew = reg_to_register_object($newval$$reg); + Register Raddr = reg_to_register_object($mem_ptr$$reg); + Register Rres = reg_to_register_object($res$$reg); + + write_barrier_pre(masm, this, + noreg /* obj */, + Rcomp /* pre_val */, + $tmp1$$Register /* tmp1 */, + RegSet::of(Raddr, Rcomp, Rnew) /* preserve */, + RegSet::of(Rres) /* no_preserve */); + + __ z_csg(Rcomp, Rnew, 0, Raddr); + + if (VM_Version::has_LoadStoreConditional()) { + __ load_const_optimized(Z_R0_scratch, 0L); // false (failed) + __ load_const_optimized(Rres, 1L); // true (succeed) + __ z_locgr(Rres, Z_R0_scratch, Assembler::bcondNotEqual); + } else { + Label done; + __ load_const_optimized(Rres, 0L); // false (failed) + __ z_brne(done); // Assume true to be the common case. + __ load_const_optimized(Rres, 1L); // true (succeed) + __ bind(done); + } + + write_barrier_post(masm, this, + Raddr /* store_addr */, + Rnew /* new_val */, + $tmp1$$Register /* tmp1 */, + $tmp2$$Register /* tmp2 */); + __ block_comment("} g1CompareAndSwapP"); + %} + ins_pipe(pipe_class_dummy); +%} + +instruct g1CompareAndExchangeP(iRegP mem_ptr, rarg5RegP oldval, iRegP_N2P newval, iRegP res, iRegL tmp1, iRegL tmp2, flagsReg cr) %{ + predicate(UseG1GC && n->as_LoadStore()->barrier_data() != 0); + match(Set res (CompareAndExchangeP mem_ptr (Binary oldval newval))); + effect(TEMP res, TEMP tmp1, TEMP tmp2, USE mem_ptr, USE_KILL oldval, KILL cr); + format %{ "$res = CompareAndExchangeP $oldval,$newval,$mem_ptr" %} + ins_encode %{ + __ block_comment("g1CompareAndExchangeP {"); + assert_different_registers($oldval$$Register, $mem_ptr$$Register); + assert_different_registers($newval$$Register, $mem_ptr$$Register); + + // Pass $oldval to the pre-barrier (instead of loading from $mem), because + // $oldval is the only value that can be overwritten. + // The same holds for g1CompareAndSwapP. + write_barrier_pre(masm, this, + noreg /* obj */, + $oldval$$Register /* pre_val */, + $tmp2$$Register /* tmp1 */, + RegSet::of($mem_ptr$$Register, $oldval$$Register, $newval$$Register) /* preserve */, + RegSet::of($res$$Register) /* no_preserve */); + + __ z_lgr($res$$Register, $oldval$$Register); // previous content + + __ z_csg($oldval$$Register, $newval$$Register, 0, $mem_ptr$$reg); + + write_barrier_post(masm, this, + $mem_ptr$$Register /* store_addr */, + $newval$$Register /* new_val */, + $tmp1$$Register /* tmp1 */, + $tmp2$$Register /* tmp2 */); + __ block_comment("} g1CompareAndExchangeP"); + %} + ins_pipe(pipe_class_dummy); +%} + +// Load Pointer +instruct g1LoadP(iRegP dst, memory mem, iRegL tmp1, flagsReg cr) %{ + predicate(UseG1GC && n->as_Load()->barrier_data() != 0); + match(Set dst (LoadP mem)); + effect(TEMP dst, TEMP tmp1, KILL cr); + ins_cost(MEMORY_REF_COST); + format %{ "LG $dst,$mem\t # ptr" %} + ins_encode %{ + __ block_comment("g1LoadP {"); + __ z_lg($dst$$Register, $mem$$Address); + write_barrier_pre(masm, this, + noreg /* obj */, + $dst$$Register /* pre_val */, + $tmp1$$Register ); + __ block_comment("} g1LoadP"); + %} + ins_pipe(pipe_class_dummy); +%} + +instruct g1GetAndSetP(indirect mem, iRegP dst, iRegL tmp, iRegL tmp1, iRegL tmp2, flagsReg cr) %{ + predicate(UseG1GC && n->as_LoadStore()->barrier_data() != 0); + match(Set dst (GetAndSetP mem dst)); + effect(KILL cr, TEMP tmp, TEMP tmp1, TEMP tmp2); // USE_DEF dst by match rule. + format %{ "XCHGP $dst,[$mem]\t # EXCHANGE (oop, atomic), temp $tmp" %} + ins_encode %{ + __ block_comment("g1GetAndSetP {"); + + write_barrier_pre(masm, this, + $mem$$Register /* obj */, + $tmp$$Register /* pre_val (as a temporary register) */, + $tmp1$$Register /* tmp1 */, + RegSet::of($mem$$Register, $dst$$Register) /* preserve */); + + __ z_lgr($tmp1$$Register, $dst$$Register); + Register Rdst = reg_to_register_object($dst$$reg); + Register Rtmp = reg_to_register_object($tmp$$reg); + guarantee(Rdst != Rtmp, "Fix match rule to use TEMP_DEF"); + Label retry; + + // Iterate until swap succeeds. + __ z_lg(Rtmp, Address($mem$$Register)); // current contents + __ bind(retry); + // Calculate incremented value. + __ z_csg(Rtmp, Rdst, Address($mem$$Register)); // Try to store new value. + __ z_brne(retry); // Yikes, concurrent update, need to retry. + __ z_lgr(Rdst, Rtmp); // Exchanged value from memory is return value. + + write_barrier_post(masm, this, + $mem$$Register /* store_addr */, + $tmp1$$Register /* new_val */, + $tmp2$$Register /* tmp1 */, + $tmp$$Register /* tmp2 */); + __ block_comment("} g1GetAndSetP"); + %} + ins_pipe(pipe_class_dummy); +%} + +instruct g1EncodePAndStoreN(indirect mem, iRegP src, iRegL tmp1, iRegL tmp2, flagsReg cr) +%{ + predicate(UseG1GC && n->as_Store()->barrier_data() != 0); + match(Set mem (StoreN mem (EncodeP src))); + effect(TEMP tmp1, TEMP tmp2, KILL cr); + // ins_cost(INSN_COST); + format %{ "encode_heap_oop $tmp1, $src\n\t" + "st $tmp1, $mem\t# compressed ptr" %} + ins_encode %{ + __ block_comment("g1EncodePAndStoreN {"); + write_barrier_pre(masm, this, + $mem$$Register /* obj */, + $tmp1$$Register /* pre_val */, + $tmp2$$Register /* tmp1 */, + RegSet::of($mem$$Register, $src$$Register) /* preserve */); + if ((barrier_data() & G1C2BarrierPostNotNull) == 0) { + __ oop_encoder($tmp1$$Register, $src$$Register, true /* maybe_null */); + } else { + __ oop_encoder($tmp1$$Register, $src$$Register, false /* maybe_null */); + } + __ z_st($tmp1$$Register, Address($mem$$Register)); + write_barrier_post(masm, this, + $mem$$Register /* store_addr */, + $src$$Register /* new_val */, + $tmp1$$Register /* tmp1 */, + $tmp2$$Register /* tmp2 */); + __ block_comment("} g1EncodePAndStoreN"); + %} + ins_pipe(pipe_class_dummy); +%} diff --git a/src/hotspot/cpu/s390/gc/shared/barrierSetAssembler_s390.cpp b/src/hotspot/cpu/s390/gc/shared/barrierSetAssembler_s390.cpp index d3457916bc9..d826b4a06f3 100644 --- a/src/hotspot/cpu/s390/gc/shared/barrierSetAssembler_s390.cpp +++ b/src/hotspot/cpu/s390/gc/shared/barrierSetAssembler_s390.cpp @@ -33,6 +33,9 @@ #include "runtime/jniHandles.hpp" #include "runtime/stubRoutines.hpp" #include "utilities/macros.hpp" +#ifdef COMPILER2 +#include "gc/shared/c2/barrierSetC2.hpp" +#endif // COMPILER2 #define __ masm-> @@ -105,16 +108,60 @@ void BarrierSetAssembler::store_at(MacroAssembler* masm, DecoratorSet decorators } } +// Generic implementation. GCs can provide an optimized one. void BarrierSetAssembler::resolve_jobject(MacroAssembler* masm, Register value, Register tmp1, Register tmp2) { - NearLabel Ldone; - __ z_ltgr(tmp1, value); - __ z_bre(Ldone); // Use null result as-is. - __ z_nill(value, ~JNIHandles::tag_mask); - __ z_lg(value, 0, value); // Resolve (untagged) jobject. + assert_different_registers(value, tmp1, tmp2); + NearLabel done, weak_tag, verify, tagged; + __ z_ltgr(value, value); + __ z_bre(done); // Use null result as-is. + __ z_tmll(value, JNIHandles::tag_mask); + __ z_btrue(tagged); // not zero + + // Resolve Local handle + __ access_load_at(T_OBJECT, IN_NATIVE | AS_RAW, Address(value, 0), value, tmp1, tmp2); + __ z_bru(verify); + + __ bind(tagged); + __ testbit(value, exact_log2(JNIHandles::TypeTag::weak_global)); // test for weak tag + __ z_btrue(weak_tag); + + // resolve global handle + __ access_load_at(T_OBJECT, IN_NATIVE, Address(value, -JNIHandles::TypeTag::global), value, tmp1, tmp2); + __ z_bru(verify); + + __ bind(weak_tag); + // resolve jweak. + __ access_load_at(T_OBJECT, IN_NATIVE | ON_PHANTOM_OOP_REF, + Address(value, -JNIHandles::TypeTag::weak_global), value, tmp1, tmp2); + __ bind(verify); __ verify_oop(value, FILE_AND_LINE); - __ bind(Ldone); + __ bind(done); +} + +// Generic implementation. GCs can provide an optimized one. +void BarrierSetAssembler::resolve_global_jobject(MacroAssembler* masm, Register value, Register tmp1, Register tmp2) { + assert_different_registers(value, tmp1, tmp2); + NearLabel done; + + __ z_ltgr(value, value); + __ z_bre(done); // use null as-is. + +#ifdef ASSERT + { + NearLabel valid_global_tag; + __ testbit(value, exact_log2(JNIHandles::TypeTag::global)); // test for global tag + __ z_btrue(valid_global_tag); + __ stop("non global jobject using resolve_global_jobject"); + __ bind(valid_global_tag); + } +#endif // ASSERT + + // Resolve global handle + __ access_load_at(T_OBJECT, IN_NATIVE, Address(value, -JNIHandles::TypeTag::global), value, tmp1, tmp2); + __ verify_oop(value, FILE_AND_LINE); + __ bind(done); } void BarrierSetAssembler::try_resolve_jobject_in_native(MacroAssembler* masm, Register jni_env, @@ -150,8 +197,93 @@ void BarrierSetAssembler::nmethod_entry_barrier(MacroAssembler* masm) { #ifdef COMPILER2 -OptoReg::Name BarrierSetAssembler::refine_register(const Node* node, OptoReg::Name opto_reg) { - Unimplemented(); // This must be implemented to support late barrier expansion. +OptoReg::Name BarrierSetAssembler::refine_register(const Node* node, OptoReg::Name opto_reg) const { + if (!OptoReg::is_reg(opto_reg)) { + return OptoReg::Bad; + } + + VMReg vm_reg = OptoReg::as_VMReg(opto_reg); + if ((vm_reg->is_Register() || vm_reg ->is_FloatRegister()) && (opto_reg & 1) != 0) { + return OptoReg::Bad; + } + + return opto_reg; +} + +#undef __ +#define __ _masm-> + +SaveLiveRegisters::SaveLiveRegisters(MacroAssembler *masm, BarrierStubC2 *stub) + : _masm(masm), _reg_mask(stub->preserve_set()) { + + const int register_save_size = iterate_over_register_mask(ACTION_COUNT_ONLY) * BytesPerWord; + + _frame_size = align_up(register_save_size, frame::alignment_in_bytes) + frame::z_abi_160_size; // FIXME: this could be restricted to argument only + + __ save_return_pc(); + __ push_frame(_frame_size, Z_R14); // FIXME: check if Z_R1_scaratch can do a job here; + + __ z_lg(Z_R14, _z_common_abi(return_pc) + _frame_size, Z_SP); + + iterate_over_register_mask(ACTION_SAVE, _frame_size); +} + +SaveLiveRegisters::~SaveLiveRegisters() { + iterate_over_register_mask(ACTION_RESTORE, _frame_size); + + __ pop_frame(); + + __ restore_return_pc(); +} + +int SaveLiveRegisters::iterate_over_register_mask(IterationAction action, int offset) { + int reg_save_index = 0; + RegMaskIterator live_regs_iterator(_reg_mask); + + while(live_regs_iterator.has_next()) { + const OptoReg::Name opto_reg = live_regs_iterator.next(); + + // Filter out stack slots (spilled registers, i.e., stack-allocated registers). + if (!OptoReg::is_reg(opto_reg)) { + continue; + } + + const VMReg vm_reg = OptoReg::as_VMReg(opto_reg); + if (vm_reg->is_Register()) { + Register std_reg = vm_reg->as_Register(); + + if (std_reg->encoding() >= Z_R2->encoding() && std_reg->encoding() <= Z_R15->encoding()) { + reg_save_index++; + + if (action == ACTION_SAVE) { + __ z_stg(std_reg, offset - reg_save_index * BytesPerWord, Z_SP); + } else if (action == ACTION_RESTORE) { + __ z_lg(std_reg, offset - reg_save_index * BytesPerWord, Z_SP); + } else { + assert(action == ACTION_COUNT_ONLY, "Sanity"); + } + } + } else if (vm_reg->is_FloatRegister()) { + FloatRegister fp_reg = vm_reg->as_FloatRegister(); + if (fp_reg->encoding() >= Z_F0->encoding() && fp_reg->encoding() <= Z_F15->encoding() + && fp_reg->encoding() != Z_F1->encoding()) { + reg_save_index++; + + if (action == ACTION_SAVE) { + __ z_std(fp_reg, offset - reg_save_index * BytesPerWord, Z_SP); + } else if (action == ACTION_RESTORE) { + __ z_ld(fp_reg, offset - reg_save_index * BytesPerWord, Z_SP); + } else { + assert(action == ACTION_COUNT_ONLY, "Sanity"); + } + } + } else if (false /* vm_reg->is_VectorRegister() */){ + fatal("Vector register support is not there yet!"); + } else { + fatal("Register type is not known"); + } + } + return reg_save_index; } #endif // COMPILER2 diff --git a/src/hotspot/cpu/s390/gc/shared/barrierSetAssembler_s390.hpp b/src/hotspot/cpu/s390/gc/shared/barrierSetAssembler_s390.hpp index f83bbb864ea..fb61adc55b5 100644 --- a/src/hotspot/cpu/s390/gc/shared/barrierSetAssembler_s390.hpp +++ b/src/hotspot/cpu/s390/gc/shared/barrierSetAssembler_s390.hpp @@ -32,7 +32,9 @@ #ifdef COMPILER2 #include "code/vmreg.hpp" #include "opto/optoreg.hpp" +#include "opto/regmask.hpp" +class BarrierStubC2; class Node; #endif // COMPILER2 @@ -51,6 +53,7 @@ public: const Address& addr, Register val, Register tmp1, Register tmp2, Register tmp3); virtual void resolve_jobject(MacroAssembler* masm, Register value, Register tmp1, Register tmp2); + virtual void resolve_global_jobject(MacroAssembler* masm, Register value, Register tmp1, Register tmp2); virtual void try_resolve_jobject_in_native(MacroAssembler* masm, Register jni_env, Register obj, Register tmp, Label& slowpath); @@ -61,8 +64,42 @@ public: #ifdef COMPILER2 OptoReg::Name refine_register(const Node* node, - OptoReg::Name opto_reg); + OptoReg::Name opto_reg) const; #endif // COMPILER2 }; +#ifdef COMPILER2 + +// This class saves and restores the registers that need to be preserved across +// the runtime call represented by a given C2 barrier stub. Use as follows: +// { +// SaveLiveRegisters save(masm, stub); +// .. +// __ call_VM_leaf(...); +// .. +// } + +class SaveLiveRegisters { + MacroAssembler* _masm; + RegMask _reg_mask; + Register _result_reg; + int _frame_size; + + public: + SaveLiveRegisters(MacroAssembler *masm, BarrierStubC2 *stub); + + ~SaveLiveRegisters(); + + private: + enum IterationAction : int { + ACTION_SAVE, + ACTION_RESTORE, + ACTION_COUNT_ONLY + }; + + int iterate_over_register_mask(IterationAction action, int offset = 0); +}; + +#endif // COMPILER2 + #endif // CPU_S390_GC_SHARED_BARRIERSETASSEMBLER_S390_HPP diff --git a/src/hotspot/cpu/s390/gc/shared/modRefBarrierSetAssembler_s390.cpp b/src/hotspot/cpu/s390/gc/shared/modRefBarrierSetAssembler_s390.cpp index fd21dd85e11..f44a72c27ab 100644 --- a/src/hotspot/cpu/s390/gc/shared/modRefBarrierSetAssembler_s390.cpp +++ b/src/hotspot/cpu/s390/gc/shared/modRefBarrierSetAssembler_s390.cpp @@ -1,6 +1,6 @@ /* - * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2018, 2019 SAP SE. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024 SAP SE. 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 @@ -26,6 +26,7 @@ #include "precompiled.hpp" #include "asm/macroAssembler.inline.hpp" #include "gc/shared/modRefBarrierSetAssembler.hpp" +#include "runtime/jniHandles.hpp" #define __ masm-> @@ -58,3 +59,16 @@ void ModRefBarrierSetAssembler::store_at(MacroAssembler* masm, DecoratorSet deco BarrierSetAssembler::store_at(masm, decorators, type, dst, val, tmp1, tmp2, tmp3); } } + +void ModRefBarrierSetAssembler::resolve_jobject(MacroAssembler* masm, Register value, Register tmp1, Register tmp2) { + NearLabel done; + + __ z_ltgr(value, value); + __ z_bre(done); // use null as-is. + + __ z_nill(value, ~JNIHandles::tag_mask); + __ z_lg(value, 0, value); // Resolve (untagged) jobject. + + __ verify_oop(value, FILE_AND_LINE); + __ bind(done); +} diff --git a/src/hotspot/cpu/s390/gc/shared/modRefBarrierSetAssembler_s390.hpp b/src/hotspot/cpu/s390/gc/shared/modRefBarrierSetAssembler_s390.hpp index 865638477cd..7f53d033780 100644 --- a/src/hotspot/cpu/s390/gc/shared/modRefBarrierSetAssembler_s390.hpp +++ b/src/hotspot/cpu/s390/gc/shared/modRefBarrierSetAssembler_s390.hpp @@ -1,6 +1,6 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2018 SAP SE. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024 SAP SE. 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 @@ -48,6 +48,8 @@ public: virtual void store_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type, const Address& dst, Register val, Register tmp1, Register tmp2, Register tmp3); + + virtual void resolve_jobject(MacroAssembler* masm, Register value, Register tmp1, Register tmp2); }; #endif // CPU_S390_GC_SHARED_MODREFBARRIERSETASSEMBLER_S390_HPP diff --git a/src/hotspot/cpu/s390/interp_masm_s390.cpp b/src/hotspot/cpu/s390/interp_masm_s390.cpp index 0b29c31ec96..d00b6c3e2cc 100644 --- a/src/hotspot/cpu/s390/interp_masm_s390.cpp +++ b/src/hotspot/cpu/s390/interp_masm_s390.cpp @@ -1007,12 +1007,12 @@ void InterpreterMacroAssembler::lock_object(Register monitor, Register object) { if (DiagnoseSyncOnValueBasedClasses != 0) { load_klass(tmp, object); - testbit(Address(tmp, Klass::access_flags_offset()), exact_log2(JVM_ACC_IS_VALUE_BASED_CLASS)); + z_tm(Address(tmp, Klass::misc_flags_offset()), KlassFlags::_misc_is_value_based_class); z_btrue(slow_case); } if (LockingMode == LM_LIGHTWEIGHT) { - lightweight_lock(object, header, tmp, slow_case); + lightweight_lock(monitor, object, header, tmp, slow_case); } else if (LockingMode == LM_LEGACY) { // Load markWord from object into header. diff --git a/src/hotspot/cpu/s390/macroAssembler_s390.cpp b/src/hotspot/cpu/s390/macroAssembler_s390.cpp index d527b4d2aea..6bfe5125959 100644 --- a/src/hotspot/cpu/s390/macroAssembler_s390.cpp +++ b/src/hotspot/cpu/s390/macroAssembler_s390.cpp @@ -2127,8 +2127,9 @@ unsigned int MacroAssembler::push_frame_abi160(unsigned int bytes) { // Pop current C frame. void MacroAssembler::pop_frame() { - BLOCK_COMMENT("pop_frame:"); + BLOCK_COMMENT("pop_frame {"); Assembler::z_lg(Z_SP, _z_abi(callers_sp), Z_SP); + BLOCK_COMMENT("} pop_frame"); } // Pop current C frame and restore return PC register (Z_R14). @@ -3458,7 +3459,8 @@ void MacroAssembler::clinit_barrier(Register klass, Register thread, Label* L_fa L_slow_path = &L_fallthrough; } - // Fast path check: class is fully initialized + // Fast path check: class is fully initialized. + // init_state needs acquire, but S390 is TSO, and so we are already good. z_cli(Address(klass, InstanceKlass::init_state_offset()), InstanceKlass::fully_initialized); z_bre(*L_fast_path); @@ -3507,9 +3509,7 @@ void MacroAssembler::compiler_fast_lock_object(Register oop, Register box, Regis if (DiagnoseSyncOnValueBasedClasses != 0) { load_klass(temp, oop); - z_l(temp, Address(temp, Klass::access_flags_offset())); - assert((JVM_ACC_IS_VALUE_BASED_CLASS & 0xFFFF) == 0, "or change following instruction"); - z_nilh(temp, JVM_ACC_IS_VALUE_BASED_CLASS >> 16); + z_tm(Address(temp, Klass::misc_flags_offset()), KlassFlags::_misc_is_value_based_class); z_brne(done); } @@ -3657,12 +3657,38 @@ void MacroAssembler::compiler_fast_unlock_object(Register oop, Register box, Reg bind(not_recursive); - load_and_test_long(temp, Address(currentHeader, OM_OFFSET_NO_MONITOR_VALUE_TAG(EntryList))); - z_brne(done); - load_and_test_long(temp, Address(currentHeader, OM_OFFSET_NO_MONITOR_VALUE_TAG(cxq))); - z_brne(done); + NearLabel check_succ, set_eq_unlocked; + + // Set owner to null. + // Release to satisfy the JMM z_release(); - z_stg(temp/*=0*/, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner), currentHeader); + z_lghi(temp, 0); + z_stg(temp, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner), currentHeader); + // We need a full fence after clearing owner to avoid stranding. + z_fence(); + + // Check if the entry lists are empty. + load_and_test_long(temp, Address(currentHeader, OM_OFFSET_NO_MONITOR_VALUE_TAG(EntryList))); + z_brne(check_succ); + load_and_test_long(temp, Address(currentHeader, OM_OFFSET_NO_MONITOR_VALUE_TAG(cxq))); + z_bre(done); // If so we are done. + + bind(check_succ); + + // Check if there is a successor. + load_and_test_long(temp, Address(currentHeader, OM_OFFSET_NO_MONITOR_VALUE_TAG(succ))); + z_brne(set_eq_unlocked); // If so we are done. + + // Save the monitor pointer in the current thread, so we can try to + // reacquire the lock in SharedRuntime::monitor_exit_helper(). + z_xilf(currentHeader, markWord::monitor_value); + z_stg(currentHeader, Address(Z_thread, JavaThread::unlocked_inflated_monitor_offset())); + + z_ltgr(oop, oop); // Set flag = NE + z_bru(done); + + bind(set_eq_unlocked); + z_cr(temp, temp); // Set flag = EQ bind(done); @@ -3676,6 +3702,11 @@ void MacroAssembler::resolve_jobject(Register value, Register tmp1, Register tmp bs->resolve_jobject(this, value, tmp1, tmp2); } +void MacroAssembler::resolve_global_jobject(Register value, Register tmp1, Register tmp2) { + BarrierSetAssembler* bs = BarrierSet::barrier_set()->barrier_set_assembler(); + bs->resolve_global_jobject(this, value, tmp1, tmp2); +} + // Last_Java_sp must comply to the rules in frame_s390.hpp. void MacroAssembler::set_last_Java_frame(Register last_Java_sp, Register last_Java_pc, bool allow_relocation) { BLOCK_COMMENT("set_last_Java_frame {"); @@ -6004,10 +6035,10 @@ SkipIfEqual::~SkipIfEqual() { // - obj: the object to be locked, contents preserved. // - temp1, temp2: temporary registers, contents destroyed. // Note: make sure Z_R1 is not manipulated here when C2 compiler is in play -void MacroAssembler::lightweight_lock(Register obj, Register temp1, Register temp2, Label& slow) { +void MacroAssembler::lightweight_lock(Register basic_lock, Register obj, Register temp1, Register temp2, Label& slow) { assert(LockingMode == LM_LIGHTWEIGHT, "only used with new lightweight locking"); - assert_different_registers(obj, temp1, temp2); + assert_different_registers(basic_lock, obj, temp1, temp2); Label push; const Register top = temp1; @@ -6019,6 +6050,11 @@ void MacroAssembler::lightweight_lock(Register obj, Register temp1, Register tem // instruction emitted as it is part of C1's null check semantics. z_lg(mark, Address(obj, mark_offset)); + if (UseObjectMonitorTable) { + // Clear cache in case fast locking succeeds. + const Address om_cache_addr = Address(basic_lock, BasicObjectLock::lock_offset() + in_ByteSize((BasicLock::object_monitor_cache_offset_in_bytes()))); + z_mvghi(om_cache_addr, 0); + } // First we need to check if the lock-stack has room for pushing the object reference. z_lgf(top, Address(Z_thread, ls_top_offset)); @@ -6142,8 +6178,8 @@ void MacroAssembler::lightweight_unlock(Register obj, Register temp1, Register t bind(unlocked); } -void MacroAssembler::compiler_fast_lock_lightweight_object(Register obj, Register tmp1, Register tmp2) { - assert_different_registers(obj, tmp1, tmp2); +void MacroAssembler::compiler_fast_lock_lightweight_object(Register obj, Register box, Register tmp1, Register tmp2) { + assert_different_registers(obj, box, tmp1, tmp2); // Handle inflated monitor. NearLabel inflated; @@ -6152,11 +6188,14 @@ void MacroAssembler::compiler_fast_lock_lightweight_object(Register obj, Registe // Finish fast lock unsuccessfully. MUST branch to with flag == EQ NearLabel slow_path; + if (UseObjectMonitorTable) { + // Clear cache in case fast locking succeeds. + z_mvghi(Address(box, BasicLock::object_monitor_cache_offset_in_bytes()), 0); + } + if (DiagnoseSyncOnValueBasedClasses != 0) { load_klass(tmp1, obj); - z_l(tmp1, Address(tmp1, Klass::access_flags_offset())); - assert((JVM_ACC_IS_VALUE_BASED_CLASS & 0xFFFF) == 0, "or change following instruction"); - z_nilh(tmp1, JVM_ACC_IS_VALUE_BASED_CLASS >> 16); + z_tm(Address(tmp1, Klass::misc_flags_offset()), KlassFlags::_misc_is_value_based_class); z_brne(slow_path); } @@ -6218,33 +6257,77 @@ void MacroAssembler::compiler_fast_lock_lightweight_object(Register obj, Registe { // Handle inflated monitor. bind(inflated); + const Register tmp1_monitor = tmp1; if (!UseObjectMonitorTable) { - // mark contains the tagged ObjectMonitor*. - const Register tagged_monitor = mark; - const Register zero = tmp2; - - // Try to CAS m->owner from null to current thread. - // If m->owner is null, then csg succeeds and sets m->owner=THREAD and CR=EQ. - // Otherwise, register zero is filled with the current owner. - z_lghi(zero, 0); - z_csg(zero, Z_thread, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner), tagged_monitor); - z_bre(locked); - - // Check if recursive. - z_cgr(Z_thread, zero); // zero contains the owner from z_csg instruction - z_brne(slow_path); - - // Recursive - z_agsi(Address(tagged_monitor, OM_OFFSET_NO_MONITOR_VALUE_TAG(recursions)), 1ll); - z_cgr(zero, zero); - // z_bru(locked); - // Uncomment above line in the future, for now jump address is right next to us. + assert(tmp1_monitor == mark, "should be the same here"); } else { - // OMCache lookup not supported yet. Take the slowpath. - // Set flag to NE - z_ltgr(obj, obj); + NearLabel monitor_found; + + // load cache address + z_la(tmp1, Address(Z_thread, JavaThread::om_cache_oops_offset())); + + const int num_unrolled = 2; + for (int i = 0; i < num_unrolled; i++) { + z_cg(obj, Address(tmp1)); + z_bre(monitor_found); + add2reg(tmp1, in_bytes(OMCache::oop_to_oop_difference())); + } + + NearLabel loop; + // Search for obj in cache + + bind(loop); + + // check for match. + z_cg(obj, Address(tmp1)); + z_bre(monitor_found); + + // search until null encountered, guaranteed _null_sentinel at end. + add2reg(tmp1, in_bytes(OMCache::oop_to_oop_difference())); + z_cghsi(0, tmp1, 0); + z_brne(loop); // if not EQ to 0, go for another loop + + // we reached to the end, cache miss + z_ltgr(obj, obj); // set CC to NE z_bru(slow_path); + + // cache hit + bind(monitor_found); + z_lg(tmp1_monitor, Address(tmp1, OMCache::oop_to_monitor_difference())); } + NearLabel monitor_locked; + // lock the monitor + + // mark contains the tagged ObjectMonitor*. + const Register tagged_monitor = mark; + const Register zero = tmp2; + + const ByteSize monitor_tag = in_ByteSize(UseObjectMonitorTable ? 0 : checked_cast(markWord::monitor_value)); + const Address owner_address(tmp1_monitor, ObjectMonitor::owner_offset() - monitor_tag); + const Address recursions_address(tmp1_monitor, ObjectMonitor::recursions_offset() - monitor_tag); + + + // Try to CAS m->owner from null to current thread. + // If m->owner is null, then csg succeeds and sets m->owner=THREAD and CR=EQ. + // Otherwise, register zero is filled with the current owner. + z_lghi(zero, 0); + z_csg(zero, Z_thread, owner_address); + z_bre(monitor_locked); + + // Check if recursive. + z_cgr(Z_thread, zero); // zero contains the owner from z_csg instruction + z_brne(slow_path); + + // Recursive + z_agsi(recursions_address, 1ll); + + bind(monitor_locked); + if (UseObjectMonitorTable) { + // Cache the monitor for unlock + z_stg(tmp1_monitor, Address(box, BasicLock::object_monitor_cache_offset_in_bytes())); + } + // set the CC now + z_cgr(obj, obj); } BLOCK_COMMENT("} handle_inflated_monitor_lightweight_locking"); @@ -6269,11 +6352,11 @@ void MacroAssembler::compiler_fast_lock_lightweight_object(Register obj, Registe // C2 uses the value of flag (NE vs EQ) to determine the continuation. } -void MacroAssembler::compiler_fast_unlock_lightweight_object(Register obj, Register tmp1, Register tmp2) { - assert_different_registers(obj, tmp1, tmp2); +void MacroAssembler::compiler_fast_unlock_lightweight_object(Register obj, Register box, Register tmp1, Register tmp2) { + assert_different_registers(obj, box, tmp1, tmp2); // Handle inflated monitor. - NearLabel inflated, inflated_load_monitor; + NearLabel inflated, inflated_load_mark; // Finish fast unlock successfully. MUST reach to with flag == EQ. NearLabel unlocked; // Finish fast unlock unsuccessfully. MUST branch to with flag == NE. @@ -6293,7 +6376,7 @@ void MacroAssembler::compiler_fast_unlock_lightweight_object(Register obj, Regis z_aghi(top, -oopSize); z_cg(obj, Address(Z_thread, top)); - branch_optimized(bcondNotEqual, inflated_load_monitor); + branch_optimized(bcondNotEqual, inflated_load_mark); // Pop lock-stack. #ifdef ASSERT @@ -6314,6 +6397,9 @@ void MacroAssembler::compiler_fast_unlock_lightweight_object(Register obj, Regis // Not recursive // Check for monitor (0b10). + // Because we got here by popping (meaning we pushed in locked) + // there will be no monitor in the box. So we need to push back the obj + // so that the runtime can fix any potential anonymous owner. z_lg(mark, Address(obj, mark_offset)); z_tmll(mark, markWord::monitor_value); if (!UseObjectMonitorTable) { @@ -6352,7 +6438,7 @@ void MacroAssembler::compiler_fast_unlock_lightweight_object(Register obj, Regis { // Handle inflated monitor. - bind(inflated_load_monitor); + bind(inflated_load_mark); z_lg(mark, Address(obj, mark_offset)); @@ -6377,49 +6463,77 @@ void MacroAssembler::compiler_fast_unlock_lightweight_object(Register obj, Regis bind(check_done); #endif // ASSERT + const Register tmp1_monitor = tmp1; + if (!UseObjectMonitorTable) { - // mark contains the tagged ObjectMonitor*. - const Register monitor = mark; - - NearLabel not_recursive; - const Register recursions = tmp2; - - // Check if recursive. - load_and_test_long(recursions, Address(monitor, OM_OFFSET_NO_MONITOR_VALUE_TAG(recursions))); - z_bre(not_recursive); // if 0 then jump, it's not recursive locking - - // Recursive unlock - z_agsi(Address(monitor, OM_OFFSET_NO_MONITOR_VALUE_TAG(recursions)), -1ll); - z_cgr(monitor, monitor); // set the CC to EQUAL - z_bru(unlocked); - - bind(not_recursive); - - NearLabel not_ok; - // Check if the entry lists are empty. - load_and_test_long(tmp2, Address(monitor, OM_OFFSET_NO_MONITOR_VALUE_TAG(EntryList))); - z_brne(not_ok); - load_and_test_long(tmp2, Address(monitor, OM_OFFSET_NO_MONITOR_VALUE_TAG(cxq))); - z_brne(not_ok); - - z_release(); - z_stg(tmp2 /*=0*/, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner), monitor); - - z_bru(unlocked); // CC = EQ here - - bind(not_ok); - - // The owner may be anonymous, and we removed the last obj entry in - // the lock-stack. This loses the information about the owner. - // Write the thread to the owner field so the runtime knows the owner. - z_stg(Z_thread, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner), monitor); - z_bru(slow_path); // CC = NE here + assert(tmp1_monitor == mark, "should be the same here"); } else { - // OMCache lookup not supported yet. Take the slowpath. - // Set flag to NE - z_ltgr(obj, obj); - z_bru(slow_path); + // Uses ObjectMonitorTable. Look for the monitor in our BasicLock on the stack. + z_lg(tmp1_monitor, Address(box, BasicLock::object_monitor_cache_offset_in_bytes())); + // null check with ZF == 0, no valid pointer below alignof(ObjectMonitor*) + z_cghi(tmp1_monitor, alignof(ObjectMonitor*)); + + z_brl(slow_path); } + + // mark contains the tagged ObjectMonitor*. + const Register monitor = mark; + + const ByteSize monitor_tag = in_ByteSize(UseObjectMonitorTable ? 0 : checked_cast(markWord::monitor_value)); + const Address recursions_address{monitor, ObjectMonitor::recursions_offset() - monitor_tag}; + const Address cxq_address{monitor, ObjectMonitor::cxq_offset() - monitor_tag}; + const Address succ_address{monitor, ObjectMonitor::succ_offset() - monitor_tag}; + const Address EntryList_address{monitor, ObjectMonitor::EntryList_offset() - monitor_tag}; + const Address owner_address{monitor, ObjectMonitor::owner_offset() - monitor_tag}; + + NearLabel not_recursive; + const Register recursions = tmp2; + + // Check if recursive. + load_and_test_long(recursions, recursions_address); + z_bre(not_recursive); // if 0 then jump, it's not recursive locking + + // Recursive unlock + z_agsi(recursions_address, -1ll); + z_cgr(monitor, monitor); // set the CC to EQUAL + z_bru(unlocked); + + bind(not_recursive); + + NearLabel check_succ, set_eq_unlocked; + + // Set owner to null. + // Release to satisfy the JMM + z_release(); + z_lghi(tmp2, 0); + z_stg(tmp2 /*=0*/, owner_address); + // We need a full fence after clearing owner to avoid stranding. + z_fence(); + + // Check if the entry lists are empty. + load_and_test_long(tmp2, EntryList_address); + z_brne(check_succ); + load_and_test_long(tmp2, cxq_address); + z_bre(unlocked); // If so we are done. + + bind(check_succ); + + // Check if there is a successor. + load_and_test_long(tmp2, succ_address); + z_brne(set_eq_unlocked); // If so we are done. + + // Save the monitor pointer in the current thread, so we can try to + // reacquire the lock in SharedRuntime::monitor_exit_helper(). + if (!UseObjectMonitorTable) { + z_xilf(monitor, markWord::monitor_value); + } + z_stg(monitor, Address(Z_thread, JavaThread::unlocked_inflated_monitor_offset())); + + z_ltgr(obj, obj); // Set flag = NE + z_bru(slow_path); + + bind(set_eq_unlocked); + z_cr(tmp2, tmp2); // Set flag = EQ } bind(unlocked); diff --git a/src/hotspot/cpu/s390/macroAssembler_s390.hpp b/src/hotspot/cpu/s390/macroAssembler_s390.hpp index 90210eb28c3..5d3a4c29940 100644 --- a/src/hotspot/cpu/s390/macroAssembler_s390.hpp +++ b/src/hotspot/cpu/s390/macroAssembler_s390.hpp @@ -752,12 +752,13 @@ class MacroAssembler: public Assembler { void compiler_fast_lock_object(Register oop, Register box, Register temp1, Register temp2); void compiler_fast_unlock_object(Register oop, Register box, Register temp1, Register temp2); - void lightweight_lock(Register obj, Register tmp1, Register tmp2, Label& slow); + void lightweight_lock(Register basic_lock, Register obj, Register tmp1, Register tmp2, Label& slow); void lightweight_unlock(Register obj, Register tmp1, Register tmp2, Label& slow); - void compiler_fast_lock_lightweight_object(Register obj, Register tmp1, Register tmp2); - void compiler_fast_unlock_lightweight_object(Register obj, Register tmp1, Register tmp2); + void compiler_fast_lock_lightweight_object(Register obj, Register box, Register tmp1, Register tmp2); + void compiler_fast_unlock_lightweight_object(Register obj, Register box, Register tmp1, Register tmp2); void resolve_jobject(Register value, Register tmp1, Register tmp2); + void resolve_global_jobject(Register value, Register tmp1, Register tmp2); // Support for last Java frame (but use call_VM instead where possible). private: @@ -819,7 +820,6 @@ class MacroAssembler: public Assembler { void compare_klass_ptr(Register Rop1, int64_t disp, Register Rbase, bool maybenull); // Access heap oop, handle encoding and GC barriers. - private: void access_store_at(BasicType type, DecoratorSet decorators, const Address& addr, Register val, Register tmp1, Register tmp2, Register tmp3); diff --git a/src/hotspot/cpu/s390/matcher_s390.hpp b/src/hotspot/cpu/s390/matcher_s390.hpp index 6c6cae3c58f..d8b1ae68f6f 100644 --- a/src/hotspot/cpu/s390/matcher_s390.hpp +++ b/src/hotspot/cpu/s390/matcher_s390.hpp @@ -1,6 +1,6 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2017, 2022 SAP SE. All rights reserved. + * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024 SAP SE. 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 @@ -63,11 +63,16 @@ return true; } - // Suppress CMOVL. Conditional move available on z/Architecture only from z196 onwards. Not exploited yet. - static int long_cmove_cost() { return ConditionalMoveLimit; } + // Use conditional move (CMOVL) + static int long_cmove_cost() { + // z196/z11 or later hardware support conditional moves + return VM_Version::has_LoadStoreConditional() ? 0 : ConditionalMoveLimit; + } - // Suppress CMOVF. Conditional move available on z/Architecture only from z196 onwards. Not exploited yet. - static int float_cmove_cost() { return ConditionalMoveLimit; } + static int float_cmove_cost() { + // z196/z11 or later hardware support conditional moves + return VM_Version::has_LoadStoreConditional() ? 0 : ConditionalMoveLimit; + } // Set this as clone_shift_expressions. static bool narrow_oop_use_complex_address() { diff --git a/src/hotspot/cpu/s390/register_s390.hpp b/src/hotspot/cpu/s390/register_s390.hpp index 931e899257e..18af232e569 100644 --- a/src/hotspot/cpu/s390/register_s390.hpp +++ b/src/hotspot/cpu/s390/register_s390.hpp @@ -448,4 +448,12 @@ constexpr Register Z_R0_scratch = Z_R0; constexpr Register Z_R1_scratch = Z_R1; constexpr FloatRegister Z_fscratch_1 = Z_F1; +typedef AbstractRegSet RegSet; + +template <> +inline Register AbstractRegSet::first() { + if (_bitset == 0) { return noreg; } + return as_Register(count_trailing_zeros(_bitset)); +} + #endif // CPU_S390_REGISTER_S390_HPP diff --git a/src/hotspot/cpu/s390/s390.ad b/src/hotspot/cpu/s390/s390.ad index 4de1a4e7b7f..8b897033aa5 100644 --- a/src/hotspot/cpu/s390/s390.ad +++ b/src/hotspot/cpu/s390/s390.ad @@ -1477,10 +1477,6 @@ const RegMask* Matcher::predicate_reg_mask(void) { return nullptr; } -const TypeVectMask* Matcher::predicate_reg_type(const Type* elemTy, int length) { - return nullptr; -} - // Vector calling convention not yet implemented. bool Matcher::supports_vector_calling_convention(void) { return false; @@ -1644,6 +1640,10 @@ const RegMask Matcher::method_handle_invoke_SP_save_mask() { // Should the matcher clone input 'm' of node 'n'? bool Matcher::pd_clone_node(Node* n, Node* m, Matcher::MStack& mstack) { + if (is_encode_and_store_pattern(n, m)) { + mstack.push(m, Visit); + return true; + } return false; } @@ -3913,6 +3913,7 @@ instruct loadL_unaligned(iRegL dst, memory mem) %{ // Load Pointer instruct loadP(iRegP dst, memory mem) %{ match(Set dst (LoadP mem)); + predicate(n->as_Load()->barrier_data() == 0); ins_cost(MEMORY_REF_COST); size(Z_DISP3_SIZE); format %{ "LG $dst,$mem\t # ptr" %} @@ -3924,6 +3925,7 @@ instruct loadP(iRegP dst, memory mem) %{ // LoadP + CastP2L instruct castP2X_loadP(iRegL dst, memory mem) %{ match(Set dst (CastP2X (LoadP mem))); + predicate(n->as_Load()->barrier_data() == 0); ins_cost(MEMORY_REF_COST); size(Z_DISP3_SIZE); format %{ "LG $dst,$mem\t # ptr + p2x" %} @@ -4220,28 +4222,6 @@ instruct storeB(memory mem, iRegI src) %{ ins_pipe(pipe_class_dummy); %} -instruct storeCM(memory mem, immI_0 src) %{ - match(Set mem (StoreCM mem src)); - ins_cost(MEMORY_REF_COST); - // TODO: s390 port size(VARIABLE_SIZE); - format %{ "STC(Y) $src,$mem\t # CMS card-mark byte (must be 0!)" %} - ins_encode %{ - guarantee($mem$$index$$Register != Z_R0, "content will not be used."); - if ($mem$$index$$Register != noreg) { - // Can't use clear_mem --> load const zero and store character. - __ load_const_optimized(Z_R0_scratch, (long)0); - if (Immediate::is_uimm12($mem$$disp)) { - __ z_stc(Z_R0_scratch, $mem$$Address); - } else { - __ z_stcy(Z_R0_scratch, $mem$$Address); - } - } else { - __ clear_mem(Address($mem$$Address), 1); - } - %} - ins_pipe(pipe_class_dummy); -%} - // CHAR/SHORT // Store Char/Short @@ -4286,6 +4266,7 @@ instruct storeL(memory mem, iRegL src) %{ // Store Pointer instruct storeP(memory dst, memoryRegP src) %{ match(Set dst (StoreP dst src)); + predicate(n->as_Store()->barrier_data() == 0); ins_cost(MEMORY_REF_COST); size(Z_DISP3_SIZE); format %{ "STG $src,$dst\t # ptr" %} @@ -4388,6 +4369,7 @@ instruct memInitL(memoryRS mem, immL16 src) %{ // Move Immediate to 8-byte memory. instruct memInitP(memoryRS mem, immP16 src) %{ match(Set mem (StoreP mem src)); + predicate(n->as_Store()->barrier_data() == 0); ins_cost(MEMORY_REF_COST); size(6); format %{ "MVGHI $mem,$src\t # direct mem init 8" %} @@ -4417,6 +4399,7 @@ instruct negL_reg_reg(iRegL dst, immL_0 zero, iRegL src, flagsReg cr) %{ // Load narrow oop instruct loadN(iRegN dst, memory mem) %{ match(Set dst (LoadN mem)); + predicate(n->as_Load()->barrier_data() == 0); ins_cost(MEMORY_REF_COST); size(Z_DISP3_SIZE); format %{ "LoadN $dst,$mem\t # (cOop)" %} @@ -4480,7 +4463,7 @@ instruct loadConNKlass(iRegN dst, immNKlass src) %{ instruct decodeLoadN(iRegP dst, memory mem) %{ match(Set dst (DecodeN (LoadN mem))); - predicate(false && (CompressedOops::base()==nullptr)&&(CompressedOops::shift()==0)); + predicate(false && (CompressedOops::base()==nullptr) && (CompressedOops::shift()==0)); ins_cost(MEMORY_REF_COST); size(Z_DISP3_SIZE); format %{ "DecodeLoadN $dst,$mem\t # (cOop Load+Decode)" %} @@ -4628,7 +4611,7 @@ instruct encodeP(iRegN dst, iRegP src, flagsReg cr) %{ match(Set dst (EncodeP src)); effect(KILL cr); predicate((n->bottom_type()->make_ptr()->ptr() != TypePtr::NotNull) && - (CompressedOops::base() == 0 || + (CompressedOops::base() == nullptr || CompressedOops::base_disjoint() || !ExpandLoadingBaseEncode)); ins_cost(MEMORY_REF_COST+3 * DEFAULT_COST); @@ -4651,7 +4634,7 @@ instruct encodeP_NN(iRegN dst, iRegP src, flagsReg cr) %{ match(Set dst (EncodeP src)); effect(KILL cr); predicate((n->bottom_type()->make_ptr()->ptr() == TypePtr::NotNull) && - (CompressedOops::base() == 0 || + (CompressedOops::base() == nullptr || CompressedOops::base_disjoint() || !ExpandLoadingBaseEncode_NN)); ins_cost(MEMORY_REF_COST+3 * DEFAULT_COST); @@ -4735,6 +4718,7 @@ instruct encodeP_NN_Ex(iRegN dst, iRegP src, flagsReg cr) %{ // Store Compressed Pointer instruct storeN(memory mem, iRegN_P2N src) %{ match(Set mem (StoreN mem src)); + predicate(n->as_Store()->barrier_data() == 0); ins_cost(MEMORY_REF_COST); size(Z_DISP_SIZE); format %{ "ST $src,$mem\t # (cOop)" %} @@ -5146,6 +5130,7 @@ instruct compareAndSwapL_bool(iRegP mem_ptr, rarg5RegL oldval, iRegL newval, iRe instruct compareAndSwapP_bool(iRegP mem_ptr, rarg5RegP oldval, iRegP_N2P newval, iRegI res, flagsReg cr) %{ match(Set res (CompareAndSwapP mem_ptr (Binary oldval newval))); + predicate(n->as_LoadStore()->barrier_data() == 0); effect(USE mem_ptr, USE_KILL oldval, KILL cr); size(18); format %{ "$res = CompareAndSwapP $oldval,$newval,$mem_ptr" %} @@ -5156,6 +5141,7 @@ instruct compareAndSwapP_bool(iRegP mem_ptr, rarg5RegP oldval, iRegP_N2P newval, instruct compareAndSwapN_bool(iRegP mem_ptr, rarg5RegN oldval, iRegN_P2N newval, iRegI res, flagsReg cr) %{ match(Set res (CompareAndSwapN mem_ptr (Binary oldval newval))); + predicate(n->as_LoadStore()->barrier_data() == 0); effect(USE mem_ptr, USE_KILL oldval, KILL cr); size(16); format %{ "$res = CompareAndSwapN $oldval,$newval,$mem_ptr" %} @@ -5443,6 +5429,7 @@ instruct xchgL_reg_mem(memoryRSY mem, iRegL dst, iRegL tmp, flagsReg cr) %{ %} instruct xchgN_reg_mem(memoryRSY mem, iRegN dst, iRegI tmp, flagsReg cr) %{ + predicate(n->as_LoadStore()->barrier_data() == 0); match(Set dst (GetAndSetN mem dst)); effect(KILL cr, TEMP tmp); // USE_DEF dst by match rule. format %{ "XCHGN $dst,[$mem]\t # EXCHANGE (coop, atomic), temp $tmp" %} @@ -5452,6 +5439,7 @@ instruct xchgN_reg_mem(memoryRSY mem, iRegN dst, iRegI tmp, flagsReg cr) %{ instruct xchgP_reg_mem(memoryRSY mem, iRegP dst, iRegL tmp, flagsReg cr) %{ match(Set dst (GetAndSetP mem dst)); + predicate(n->as_LoadStore()->barrier_data() == 0); effect(KILL cr, TEMP tmp); // USE_DEF dst by match rule. format %{ "XCHGP $dst,[$mem]\t # EXCHANGE (oop, atomic), temp $tmp" %} ins_encode(z_enc_SwapL(mem, dst, tmp)); @@ -5926,7 +5914,7 @@ instruct addP_regN_reg_imm20(iRegP dst, iRegP_N2P src1, iRegL src2, immL20 con) instruct addP_mem_imm(memoryRSY mem, immL8 src, flagsReg cr) %{ match(Set mem (StoreP mem (AddP (LoadP mem) src))); effect(KILL cr); - predicate(VM_Version::has_MemWithImmALUOps()); + predicate(VM_Version::has_MemWithImmALUOps() && n->as_LoadStore()->barrier_data() == 0); ins_cost(MEMORY_REF_COST); size(6); format %{ "AGSI $mem,$src\t # direct mem add 8 (ptr)" %} diff --git a/src/hotspot/cpu/s390/sharedRuntime_s390.cpp b/src/hotspot/cpu/s390/sharedRuntime_s390.cpp index 364ef948d91..468610b588e 100644 --- a/src/hotspot/cpu/s390/sharedRuntime_s390.cpp +++ b/src/hotspot/cpu/s390/sharedRuntime_s390.cpp @@ -43,6 +43,7 @@ #include "runtime/sharedRuntime.hpp" #include "runtime/signature.hpp" #include "runtime/stubRoutines.hpp" +#include "runtime/timerTrace.hpp" #include "runtime/vframeArray.hpp" #include "utilities/align.hpp" #include "utilities/macros.hpp" @@ -1713,7 +1714,7 @@ nmethod *SharedRuntime::generate_native_wrapper(MacroAssembler *masm, // Try fastpath for locking. if (LockingMode == LM_LIGHTWEIGHT) { // Fast_lock kills r_temp_1, r_temp_2. - __ compiler_fast_lock_lightweight_object(r_oop, r_tmp1, r_tmp2); + __ compiler_fast_lock_lightweight_object(r_oop, r_box, r_tmp1, r_tmp2); } else { // Fast_lock kills r_temp_1, r_temp_2. __ compiler_fast_lock_object(r_oop, r_box, r_tmp1, r_tmp2); @@ -1917,7 +1918,7 @@ nmethod *SharedRuntime::generate_native_wrapper(MacroAssembler *masm, // Try fastpath for unlocking. if (LockingMode == LM_LIGHTWEIGHT) { // Fast_unlock kills r_tmp1, r_tmp2. - __ compiler_fast_unlock_lightweight_object(r_oop, r_tmp1, r_tmp2); + __ compiler_fast_unlock_lightweight_object(r_oop, r_box, r_tmp1, r_tmp2); } else { // Fast_unlock kills r_tmp1, r_tmp2. __ compiler_fast_unlock_object(r_oop, r_box, r_tmp1, r_tmp2); @@ -2488,7 +2489,8 @@ void SharedRuntime::generate_deopt_blob() { // Allocate space for the code. ResourceMark rm; // Setup code generation tools. - CodeBuffer buffer("deopt_blob", 2048, 1024); + const char* name = SharedRuntime::stub_name(SharedStubId::deopt_id); + CodeBuffer buffer(name, 2048, 1024); InterpreterMacroAssembler* masm = new InterpreterMacroAssembler(&buffer); Label exec_mode_initialized; OopMap* map = nullptr; @@ -2834,23 +2836,25 @@ void OptoRuntime::generate_uncommon_trap_blob() { // // Generate a special Compile2Runtime blob that saves all registers, // and setup oopmap. -SafepointBlob* SharedRuntime::generate_handler_blob(address call_ptr, int poll_type) { +SafepointBlob* SharedRuntime::generate_handler_blob(SharedStubId id, address call_ptr) { assert(StubRoutines::forward_exception_entry() != nullptr, "must be generated before"); + assert(is_polling_page_id(id), "expected a polling page stub id"); ResourceMark rm; OopMapSet *oop_maps = new OopMapSet(); OopMap* map; // Allocate space for the code. Setup code generation tools. - CodeBuffer buffer("handler_blob", 2048, 1024); + const char* name = SharedRuntime::stub_name(id); + CodeBuffer buffer(name, 2048, 1024); MacroAssembler* masm = new MacroAssembler(&buffer); unsigned int start_off = __ offset(); address call_pc = nullptr; int frame_size_in_bytes; - bool cause_return = (poll_type == POLL_AT_RETURN); + bool cause_return = (id == SharedStubId::polling_page_return_handler_id); // Make room for return address (or push it again) if (!cause_return) { __ z_lg(Z_R14, Address(Z_thread, JavaThread::saved_exception_pc_offset())); @@ -2935,12 +2939,14 @@ SafepointBlob* SharedRuntime::generate_handler_blob(address call_ptr, int poll_t // but since this is generic code we don't know what they are and the caller // must do any gc of the args. // -RuntimeStub* SharedRuntime::generate_resolve_blob(address destination, const char* name) { +RuntimeStub* SharedRuntime::generate_resolve_blob(SharedStubId id, address destination) { assert (StubRoutines::forward_exception_entry() != nullptr, "must be generated before"); + assert(is_resolve_id(id), "expected a resolve stub id"); // allocate space for the code ResourceMark rm; + const char* name = SharedRuntime::stub_name(id); CodeBuffer buffer(name, 1000, 512); MacroAssembler* masm = new MacroAssembler(&buffer); @@ -3032,7 +3038,10 @@ RuntimeStub* SharedRuntime::generate_resolve_blob(address destination, const cha // SharedRuntime.cpp requires that this code be generated into a // RuntimeStub. -RuntimeStub* SharedRuntime::generate_throw_exception(const char* name, address runtime_entry) { +RuntimeStub* SharedRuntime::generate_throw_exception(SharedStubId id, address runtime_entry) { + assert(is_throw_id(id), "expected a throw stub id"); + + const char* name = SharedRuntime::stub_name(id); int insts_size = 256; int locs_size = 0; diff --git a/src/hotspot/cpu/s390/stubGenerator_s390.cpp b/src/hotspot/cpu/s390/stubGenerator_s390.cpp index d878731cca5..dd9ed4c9546 100644 --- a/src/hotspot/cpu/s390/stubGenerator_s390.cpp +++ b/src/hotspot/cpu/s390/stubGenerator_s390.cpp @@ -3053,6 +3053,29 @@ class StubGenerator: public StubCodeGenerator { return start; } + // load Method* target of MethodHandle + // Z_ARG1 = jobject receiver + // Z_method = Method* result + address generate_upcall_stub_load_target() { + StubCodeMark mark(this, "StubRoutines", "upcall_stub_load_target"); + address start = __ pc(); + + __ resolve_global_jobject(Z_ARG1, Z_tmp_1, Z_tmp_2); + // Load target method from receiver + __ load_heap_oop(Z_method, Address(Z_ARG1, java_lang_invoke_MethodHandle::form_offset()), + noreg, noreg, IS_NOT_NULL); + __ load_heap_oop(Z_method, Address(Z_method, java_lang_invoke_LambdaForm::vmentry_offset()), + noreg, noreg, IS_NOT_NULL); + __ load_heap_oop(Z_method, Address(Z_method, java_lang_invoke_MemberName::method_offset()), + noreg, noreg, IS_NOT_NULL); + __ z_lg(Z_method, Address(Z_method, java_lang_invoke_ResolvedMethodName::vmtarget_offset())); + __ z_stg(Z_method, Address(Z_thread, JavaThread::callee_target_offset())); // just in case callee is deoptimized + + __ z_br(Z_R14); + + return start; + } + void generate_initial_stubs() { // Generates all stubs and initializes the entry points. @@ -3110,6 +3133,7 @@ class StubGenerator: public StubCodeGenerator { } StubRoutines::_upcall_stub_exception_handler = generate_upcall_stub_exception_handler(); + StubRoutines::_upcall_stub_load_target = generate_upcall_stub_load_target(); } void generate_compiler_stubs() { diff --git a/src/hotspot/cpu/s390/templateInterpreterGenerator_s390.cpp b/src/hotspot/cpu/s390/templateInterpreterGenerator_s390.cpp index c16e4449045..2c2e8ed9e3b 100644 --- a/src/hotspot/cpu/s390/templateInterpreterGenerator_s390.cpp +++ b/src/hotspot/cpu/s390/templateInterpreterGenerator_s390.cpp @@ -1224,6 +1224,7 @@ address TemplateInterpreterGenerator::generate_math_entry(AbstractInterpreter::M case Interpreter::java_lang_math_sin : runtime_entry = CAST_FROM_FN_PTR(address, SharedRuntime::dsin); break; case Interpreter::java_lang_math_cos : runtime_entry = CAST_FROM_FN_PTR(address, SharedRuntime::dcos); break; case Interpreter::java_lang_math_tan : runtime_entry = CAST_FROM_FN_PTR(address, SharedRuntime::dtan); break; + case Interpreter::java_lang_math_tanh : /* run interpreted */ break; case Interpreter::java_lang_math_abs : /* run interpreted */ break; case Interpreter::java_lang_math_sqrt : /* runtime_entry = CAST_FROM_FN_PTR(address, SharedRuntime::dsqrt); not available */ break; case Interpreter::java_lang_math_log : runtime_entry = CAST_FROM_FN_PTR(address, SharedRuntime::dlog); break; diff --git a/src/hotspot/cpu/s390/templateTable_s390.cpp b/src/hotspot/cpu/s390/templateTable_s390.cpp index ef68a5ac83a..0c9f9e031b0 100644 --- a/src/hotspot/cpu/s390/templateTable_s390.cpp +++ b/src/hotspot/cpu/s390/templateTable_s390.cpp @@ -2321,7 +2321,7 @@ void TemplateTable::_return(TosState state) { assert(state == vtos, "only valid state"); __ z_lg(Rthis, aaddress(0)); __ load_klass(Rklass, Rthis); - __ testbit(Address(Rklass, Klass::access_flags_offset()), exact_log2(JVM_ACC_HAS_FINALIZER)); + __ z_tm(Address(Rklass, Klass::misc_flags_offset()), KlassFlags::_misc_has_finalizer); __ z_bfalse(skip_register_finalizer); __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::register_finalizer), Rthis); __ bind(skip_register_finalizer); diff --git a/src/hotspot/cpu/s390/upcallLinker_s390.cpp b/src/hotspot/cpu/s390/upcallLinker_s390.cpp index 734b4e89c7c..8baad40a519 100644 --- a/src/hotspot/cpu/s390/upcallLinker_s390.cpp +++ b/src/hotspot/cpu/s390/upcallLinker_s390.cpp @@ -23,6 +23,7 @@ #include "precompiled.hpp" #include "asm/macroAssembler.inline.hpp" +#include "classfile/javaClasses.hpp" #include "logging/logStream.hpp" #include "memory/resourceArea.hpp" #include "prims/upcallLinker.hpp" @@ -116,7 +117,7 @@ static void restore_callee_saved_registers(MacroAssembler* _masm, const ABIDescr static const int upcall_stub_code_base_size = 1024; static const int upcall_stub_size_per_arg = 16; // arg save & restore + move -address UpcallLinker::make_upcall_stub(jobject receiver, Method* entry, +address UpcallLinker::make_upcall_stub(jobject receiver, Symbol* signature, BasicType* out_sig_bt, int total_out_args, BasicType ret_type, jobject jabi, jobject jconv, @@ -206,7 +207,6 @@ address UpcallLinker::make_upcall_stub(jobject receiver, Method* entry, __ block_comment("on_entry {"); __ load_const_optimized(call_target_address, CAST_FROM_FN_PTR(uint64_t, UpcallLinker::on_entry)); __ z_aghik(Z_ARG1, Z_SP, frame_data_offset); - __ load_const_optimized(Z_ARG2, (intptr_t)receiver); __ call(call_target_address); __ z_lgr(Z_thread, Z_RET); __ block_comment("} on_entry"); @@ -216,12 +216,11 @@ address UpcallLinker::make_upcall_stub(jobject receiver, Method* entry, arg_shuffle.generate(_masm, shuffle_reg, abi._shadow_space_bytes, frame::z_jit_out_preserve_size); __ block_comment("} argument_shuffle"); - __ block_comment("receiver {"); - __ get_vm_result(Z_ARG1); - __ block_comment("} receiver"); - - __ load_const_optimized(Z_method, (intptr_t)entry); - __ z_stg(Z_method, Address(Z_thread, in_bytes(JavaThread::callee_target_offset()))); + __ block_comment("load_target {"); + __ load_const_optimized(Z_ARG1, (intptr_t)receiver); + __ load_const_optimized(call_target_address, StubRoutines::upcall_stub_load_target()); + __ call(call_target_address); // load taget Method* into Z_method + __ block_comment("} load_target"); __ z_lg(call_target_address, Address(Z_method, in_bytes(Method::from_compiled_offset()))); __ call(call_target_address); @@ -274,7 +273,7 @@ address UpcallLinker::make_upcall_stub(jobject receiver, Method* entry, #ifndef PRODUCT stringStream ss; - ss.print("upcall_stub_%s", entry->signature()->as_C_string()); + ss.print("upcall_stub_%s", signature->as_C_string()); const char* name = _masm->code_string(ss.as_string()); #else // PRODUCT const char* name = "upcall_stub"; diff --git a/src/hotspot/cpu/x86/assembler_x86.cpp b/src/hotspot/cpu/x86/assembler_x86.cpp index 207d3fbb61e..c1679cd111f 100644 --- a/src/hotspot/cpu/x86/assembler_x86.cpp +++ b/src/hotspot/cpu/x86/assembler_x86.cpp @@ -1385,6 +1385,14 @@ void Assembler::addl(Address dst, int32_t imm32) { emit_arith_operand(0x81, rax, dst, imm32); } +void Assembler::eaddl(Register dst, Address src, int32_t imm32, bool no_flags) { + InstructionMark im(this); + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_32bit); + evex_prefix_ndd(src, dst->encoding(), 0, VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_arith_operand(0x81, rax, src, imm32); +} + void Assembler::addb(Address dst, int imm8) { InstructionMark im(this); prefix(dst); @@ -1405,12 +1413,6 @@ void Assembler::addb(Register dst, int imm8) { emit_arith_b(0x80, 0xC0, dst, imm8); } -void Assembler::addw(Register dst, Register src) { - emit_int8(0x66); - (void)prefix_and_encode(dst->encoding(), src->encoding()); - emit_arith(0x03, 0xC0, dst, src); -} - void Assembler::addw(Address dst, int imm16) { InstructionMark im(this); emit_int8(0x66); @@ -1435,11 +1437,26 @@ void Assembler::addl(Address dst, Register src) { emit_operand(src, dst, 0); } +void Assembler::eaddl(Register dst, Address src1, Register src2, bool no_flags) { + InstructionMark im(this); + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_32bit); + evex_prefix_ndd(src1, dst->encoding(), src2->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int8(0x01); + emit_operand(src2, src1, 0); +} + void Assembler::addl(Register dst, int32_t imm32) { prefix(dst); emit_arith(0x81, 0xC0, dst, imm32); } +void Assembler::eaddl(Register dst, Register src, int32_t imm32, bool no_flags) { + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + (void) evex_prefix_and_encode_ndd(0, dst->encoding(), src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_arith(0x81, 0xC0, src, imm32); +} + void Assembler::addl(Register dst, Address src) { InstructionMark im(this); prefix(src, dst); @@ -1447,11 +1464,27 @@ void Assembler::addl(Register dst, Address src) { emit_operand(dst, src, 0); } +void Assembler::eaddl(Register dst, Register src1, Address src2, bool no_flags) { + InstructionMark im(this); + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_32bit); + evex_prefix_ndd(src2, dst->encoding(), src1->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int8(0x03); + emit_operand(src1, src2, 0); +} + void Assembler::addl(Register dst, Register src) { (void) prefix_and_encode(dst->encoding(), src->encoding()); emit_arith(0x03, 0xC0, dst, src); } +void Assembler::eaddl(Register dst, Register src1, Register src2, bool no_flags) { + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + (void) evex_prefix_and_encode_ndd(src1->encoding(), dst->encoding(), src2->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + // opcode matches gcc + emit_arith(0x01, 0xC0, src1, src2); +} + void Assembler::addr_nop_4() { assert(UseAddressNop, "no CPU support"); // 4 bytes: NOP DWORD PTR [EAX+0] @@ -1632,22 +1665,31 @@ void Assembler::andb(Address dst, Register src) { emit_operand(src, dst, 0); } -void Assembler::andw(Register dst, Register src) { - (void)prefix_and_encode(dst->encoding(), src->encoding()); - emit_arith(0x23, 0xC0, dst, src); -} - void Assembler::andl(Address dst, int32_t imm32) { InstructionMark im(this); prefix(dst); emit_arith_operand(0x81, as_Register(4), dst, imm32); } +void Assembler::eandl(Register dst, Address src, int32_t imm32, bool no_flags) { + InstructionMark im(this); + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_32bit); + evex_prefix_ndd(src, dst->encoding(), 0, VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_arith_operand(0x81, rsp, src, imm32); +} + void Assembler::andl(Register dst, int32_t imm32) { prefix(dst); emit_arith(0x81, 0xE0, dst, imm32); } +void Assembler::eandl(Register dst, Register src, int32_t imm32, bool no_flags) { + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + (void) evex_prefix_and_encode_ndd(0, dst->encoding(), src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_arith(0x81, 0xE0, src, imm32); +} + void Assembler::andl(Address dst, Register src) { InstructionMark im(this); prefix(dst, src); @@ -1662,11 +1704,27 @@ void Assembler::andl(Register dst, Address src) { emit_operand(dst, src, 0); } +void Assembler::eandl(Register dst, Register src1, Address src2, bool no_flags) { + InstructionMark im(this); + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_32bit); + evex_prefix_ndd(src2, dst->encoding(), src1->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int8(0x23); + emit_operand(src1, src2, 0); +} + void Assembler::andl(Register dst, Register src) { (void) prefix_and_encode(dst->encoding(), src->encoding()); emit_arith(0x23, 0xC0, dst, src); } +void Assembler::eandl(Register dst, Register src1, Register src2, bool no_flags) { + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + (void) evex_prefix_and_encode_ndd(src1->encoding(), dst->encoding(), src2->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + // opcode matches gcc + emit_arith(0x21, 0xC0, src1, src2); +} + void Assembler::andnl(Register dst, Register src1, Register src2) { assert(VM_Version::supports_bmi1(), "bit manipulation instructions not supported"); InstructionAttr attributes(AVX_128bit, /* rex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); @@ -1814,6 +1872,12 @@ void Assembler::cmovl(Condition cc, Register dst, Register src) { emit_opcode_prefix_and_encoding(0x40 | cc, 0xC0, encode); } +void Assembler::ecmovl(Condition cc, Register dst, Register src1, Register src2) { + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = evex_prefix_and_encode_ndd(src1->encoding(), dst->encoding(), src2->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes); + emit_int16((0x40 | cc), (0xC0 | encode)); +} + void Assembler::cmovl(Condition cc, Register dst, Address src) { InstructionMark im(this); NOT_LP64(guarantee(VM_Version::supports_cmov(), "illegal instruction")); @@ -1822,6 +1886,15 @@ void Assembler::cmovl(Condition cc, Register dst, Address src) { emit_operand(dst, src, 0); } +void Assembler::ecmovl(Condition cc, Register dst, Register src1, Address src2) { + InstructionMark im(this); + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_32bit); + evex_prefix_ndd(src2, dst->encoding(), src1->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes); + emit_int8((0x40 | cc)); + emit_operand(src1, src2, 0); +} + void Assembler::cmpb(Address dst, Register reg) { assert(reg->has_byte_register(), "must have byte register"); InstructionMark im(this); @@ -1846,6 +1919,11 @@ void Assembler::cmpb(Address dst, int imm8) { emit_int8(imm8); } +void Assembler::cmpb(Register dst, int imm8) { + prefix(dst); + emit_arith_b(0x80, 0xF8, dst, imm8); +} + void Assembler::cmpl(Address dst, int32_t imm32) { InstructionMark im(this); prefix(dst); @@ -2440,6 +2518,15 @@ void Assembler::decl(Address dst) { emit_operand(rcx, dst, 0); } +void Assembler::edecl(Register dst, Address src, bool no_flags) { + InstructionMark im(this); + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_32bit); + evex_prefix_ndd(src, dst->encoding(), 0, VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int8((unsigned char)0xFF); + emit_operand(rcx, src, 0); +} + void Assembler::divsd(XMMRegister dst, Address src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); InstructionMark im(this); @@ -2485,21 +2572,45 @@ void Assembler::idivl(Register src) { emit_int16((unsigned char)0xF7, (0xF8 | encode)); } +void Assembler::eidivl(Register src, bool no_flags) { // Signed + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = evex_prefix_and_encode_nf(0, 0, src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int16((unsigned char)0xF7, (0xF8 | encode)); +} + void Assembler::divl(Register src) { // Unsigned int encode = prefix_and_encode(src->encoding()); emit_int16((unsigned char)0xF7, (0xF0 | encode)); } +void Assembler::edivl(Register src, bool no_flags) { // Unsigned + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = evex_prefix_and_encode_nf(0, 0, src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int16((unsigned char)0xF7, (0xF0 | encode)); +} + void Assembler::imull(Register src) { int encode = prefix_and_encode(src->encoding()); emit_int16((unsigned char)0xF7, (0xE8 | encode)); } +void Assembler::eimull(Register src, bool no_flags) { + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = evex_prefix_and_encode_nf(0, 0, src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int16((unsigned char)0xF7, (0xE8 | encode)); +} + void Assembler::imull(Register dst, Register src) { int encode = prefix_and_encode(dst->encoding(), src->encoding(), true /* is_map1 */); emit_opcode_prefix_and_encoding((unsigned char)0xAF, 0xC0, encode); } +void Assembler::eimull(Register dst, Register src1, Register src2, bool no_flags) { + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = evex_prefix_and_encode_ndd(src1->encoding(), dst->encoding(), src2->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int16((unsigned char)0xAF, (0xC0 | encode)); +} + void Assembler::imull(Register dst, Address src, int32_t value) { InstructionMark im(this); prefix(src, dst); @@ -2514,6 +2625,22 @@ void Assembler::imull(Register dst, Address src, int32_t value) { } } +void Assembler::eimull(Register dst, Address src, int32_t value, bool no_flags) { + InstructionMark im(this); + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_32bit); + evex_prefix_ndd(src, 0, dst->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + if (is8bit(value)) { + emit_int8((unsigned char)0x6B); + emit_operand(dst, src, 1); + emit_int8(value); + } else { + emit_int8((unsigned char)0x69); + emit_operand(dst, src, 4); + emit_int32(value); + } +} + void Assembler::imull(Register dst, Register src, int value) { int encode = prefix_and_encode(dst->encoding(), src->encoding()); if (is8bit(value)) { @@ -2524,6 +2651,17 @@ void Assembler::imull(Register dst, Register src, int value) { } } +void Assembler::eimull(Register dst, Register src, int value, bool no_flags) { + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = evex_prefix_and_encode_nf(dst->encoding(), 0, src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + if (is8bit(value)) { + emit_int24(0x6B, (0xC0 | encode), value & 0xFF); + } else { + emit_int16(0x69, (0xC0 | encode)); + emit_int32(value); + } +} + void Assembler::imull(Register dst, Address src) { InstructionMark im(this); prefix(src, dst, false, true /* is_map1 */); @@ -2531,6 +2669,14 @@ void Assembler::imull(Register dst, Address src) { emit_operand(dst, src, 0); } +void Assembler::eimull(Register dst, Register src1, Address src2, bool no_flags) { + InstructionMark im(this); + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_32bit); + evex_prefix_ndd(src2, dst->encoding(), src1->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int8((unsigned char)0xAF); + emit_operand(src1, src2, 0); +} void Assembler::incl(Address dst) { // Don't use it directly. Use MacroAssembler::increment() instead. @@ -2540,6 +2686,16 @@ void Assembler::incl(Address dst) { emit_operand(rax, dst, 0); } +void Assembler::eincl(Register dst, Address src, bool no_flags) { + // Don't use it directly. Use MacroAssembler::increment() instead. + InstructionMark im(this); + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_32bit); + evex_prefix_ndd(src, dst->encoding(), 0, VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int8((unsigned char)0xFF); + emit_operand(rax, src, 0); +} + void Assembler::jcc(Condition cc, Label& L, bool maybe_short) { InstructionMark im(this); assert((0 <= cc) && (cc < 16), "illegal cc"); @@ -2707,6 +2863,13 @@ void Assembler::lzcntl(Register dst, Register src) { emit_opcode_prefix_and_encoding((unsigned char)0xBD, 0xC0, encode); } +void Assembler::elzcntl(Register dst, Register src, bool no_flags) { + assert(VM_Version::supports_lzcnt(), "encoding is treated as BSR"); + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = evex_prefix_and_encode_nf(dst->encoding(), 0, src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int16((unsigned char)0xF5, (0xC0 | encode)); +} + void Assembler::lzcntl(Register dst, Address src) { assert(VM_Version::supports_lzcnt(), "encoding is treated as BSR"); InstructionMark im(this); @@ -2716,6 +2879,16 @@ void Assembler::lzcntl(Register dst, Address src) { emit_operand(dst, src, 0); } +void Assembler::elzcntl(Register dst, Address src, bool no_flags) { + assert(VM_Version::supports_lzcnt(), "encoding is treated as BSR"); + InstructionMark im(this); + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_32bit); + evex_prefix_nf(src, 0, dst->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int8((unsigned char)0xF5); + emit_operand(dst, src, 0); +} + // Emit mfence instruction void Assembler::mfence() { NOT_LP64(assert(VM_Version::supports_sse2(), "unsupported");) @@ -3866,11 +4039,26 @@ void Assembler::mull(Address src) { emit_operand(rsp, src, 0); } +void Assembler::emull(Address src, bool no_flags) { + InstructionMark im(this); + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_32bit); + evex_prefix_nf(src, 0, 0, VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int8((unsigned char)0xF7); + emit_operand(rsp, src, 0); +} + void Assembler::mull(Register src) { int encode = prefix_and_encode(src->encoding()); emit_int16((unsigned char)0xF7, (0xE0 | encode)); } +void Assembler::emull(Register src, bool no_flags) { + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = evex_prefix_and_encode_nf(0, 0, src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int16((unsigned char)0xF7, (0xE0 | encode)); +} + void Assembler::mulsd(XMMRegister dst, Address src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); InstructionMark im(this); @@ -3912,6 +4100,12 @@ void Assembler::negl(Register dst) { emit_int16((unsigned char)0xF7, (0xD8 | encode)); } +void Assembler::enegl(Register dst, Register src, bool no_flags) { + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = evex_prefix_and_encode_ndd(0, dst->encoding(), src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int16((unsigned char)0xF7, (0xD8 | encode)); +} + void Assembler::negl(Address dst) { InstructionMark im(this); prefix(dst); @@ -3919,6 +4113,15 @@ void Assembler::negl(Address dst) { emit_operand(as_Register(3), dst, 0); } +void Assembler::enegl(Register dst, Address src, bool no_flags) { + InstructionMark im(this); + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_32bit); + evex_prefix_ndd(src, dst->encoding(), 0, VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int8((unsigned char)0xF7); + emit_operand(as_Register(3), src, 0); +} + void Assembler::nop(uint i) { #ifdef ASSERT assert(i > 0, " "); @@ -4230,22 +4433,48 @@ void Assembler::notl(Register dst) { emit_int16((unsigned char)0xF7, (0xD0 | encode)); } +void Assembler::enotl(Register dst, Register src) { + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = evex_prefix_and_encode_ndd(0, dst->encoding(), src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes); + emit_int16((unsigned char)0xF7, (0xD0 | encode)); +} + void Assembler::orw(Register dst, Register src) { (void)prefix_and_encode(dst->encoding(), src->encoding()); emit_arith(0x0B, 0xC0, dst, src); } +void Assembler::eorw(Register dst, Register src1, Register src2, bool no_flags) { + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + (void) evex_prefix_and_encode_ndd(src1->encoding(), dst->encoding(), src2->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_arith(0x0B, 0xC0, src1, src2); +} + void Assembler::orl(Address dst, int32_t imm32) { InstructionMark im(this); prefix(dst); emit_arith_operand(0x81, rcx, dst, imm32); } +void Assembler::eorl(Register dst, Address src, int32_t imm32, bool no_flags) { + InstructionMark im(this); + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_32bit); + evex_prefix_ndd(src, dst->encoding(), 0, VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_arith_operand(0x81, rcx, src, imm32); +} + void Assembler::orl(Register dst, int32_t imm32) { prefix(dst); emit_arith(0x81, 0xC8, dst, imm32); } +void Assembler::eorl(Register dst, Register src, int32_t imm32, bool no_flags) { + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + evex_prefix_and_encode_ndd(0, dst->encoding(), src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_arith(0x81, 0xC8, src, imm32); +} + void Assembler::orl(Register dst, Address src) { InstructionMark im(this); prefix(src, dst); @@ -4253,11 +4482,27 @@ void Assembler::orl(Register dst, Address src) { emit_operand(dst, src, 0); } +void Assembler::eorl(Register dst, Register src1, Address src2, bool no_flags) { + InstructionMark im(this); + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_64bit); + evex_prefix_ndd(src2, dst->encoding(), src1->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int8(0x0B); + emit_operand(src1, src2, 0); +} + void Assembler::orl(Register dst, Register src) { (void) prefix_and_encode(dst->encoding(), src->encoding()); emit_arith(0x0B, 0xC0, dst, src); } +void Assembler::eorl(Register dst, Register src1, Register src2, bool no_flags) { + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + (void) evex_prefix_and_encode_ndd(src1->encoding(), dst->encoding(), src2->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + // opcode matches gcc + emit_arith(0x09, 0xC0, src1, src2); +} + void Assembler::orl(Address dst, Register src) { InstructionMark im(this); prefix(dst, src); @@ -4265,6 +4510,15 @@ void Assembler::orl(Address dst, Register src) { emit_operand(src, dst, 0); } +void Assembler::eorl(Register dst, Address src1, Register src2, bool no_flags) { + InstructionMark im(this); + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_32bit); + evex_prefix_ndd(src1, dst->encoding(), src2->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int8(0x09); + emit_operand(src2, src1, 0); +} + void Assembler::orb(Address dst, int imm8) { InstructionMark im(this); prefix(dst); @@ -4273,6 +4527,16 @@ void Assembler::orb(Address dst, int imm8) { emit_int8(imm8); } +void Assembler::eorb(Register dst, Address src, int imm8, bool no_flags) { + InstructionMark im(this); + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_8bit); + evex_prefix_ndd(src, dst->encoding(), 0, VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int8((unsigned char)0x80); + emit_operand(rcx, src, 1); + emit_int8(imm8); +} + void Assembler::orb(Address dst, Register src) { InstructionMark im(this); prefix(dst, src, true); @@ -4280,6 +4544,15 @@ void Assembler::orb(Address dst, Register src) { emit_operand(src, dst, 0); } +void Assembler::eorb(Register dst, Address src1, Register src2, bool no_flags) { + InstructionMark im(this); + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_8bit); + evex_prefix_ndd(src1, dst->encoding(), src2->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int8(0x08); + emit_operand(src2, src1, 0); +} + void Assembler::packsswb(XMMRegister dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); InstructionAttr attributes(AVX_128bit, /* rex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true); @@ -5400,6 +5673,16 @@ void Assembler::popcntl(Register dst, Address src) { emit_operand(dst, src, 0); } +void Assembler::epopcntl(Register dst, Address src, bool no_flags) { + assert(VM_Version::supports_popcnt(), "must support"); + InstructionMark im(this); + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_32bit); + evex_prefix_nf(src, 0, dst->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int8((unsigned char)0x88); + emit_operand(dst, src, 0); +} + void Assembler::popcntl(Register dst, Register src) { assert(VM_Version::supports_popcnt(), "must support"); emit_int8((unsigned char)0xF3); @@ -5407,6 +5690,13 @@ void Assembler::popcntl(Register dst, Register src) { emit_opcode_prefix_and_encoding((unsigned char)0xB8, 0xC0, encode); } +void Assembler::epopcntl(Register dst, Register src, bool no_flags) { + assert(VM_Version::supports_popcnt(), "must support"); + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = evex_prefix_and_encode_nf(dst->encoding(), 0, src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int16((unsigned char)0x88, (0xC0 | encode)); +} + void Assembler::evpopcntb(XMMRegister dst, KRegister mask, XMMRegister src, bool merge, int vector_len) { assert(VM_Version::supports_avx512_bitalg(), "must support avx512bitalg feature"); assert(vector_len == AVX_512bit || VM_Version::supports_avx512vl(), ""); @@ -5995,6 +6285,17 @@ void Assembler::rcll(Register dst, int imm8) { } } +void Assembler::ercll(Register dst, Register src, int imm8) { + assert(isShiftCount(imm8), "illegal shift count"); + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = evex_prefix_and_encode_ndd(0, dst->encoding(), src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes); + if (imm8 == 1) { + emit_int16((unsigned char)0xD1, (0xD0 | encode)); + } else { + emit_int24((unsigned char)0xC1, (0xD0 | encode), imm8); + } +} + void Assembler::rcpps(XMMRegister dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse(), "")); InstructionAttr attributes(AVX_128bit, /* rex_w */ false, /* legacy_mode */ true, /* no_mask_reg */ true, /* uses_vl */ false); @@ -6075,11 +6376,28 @@ void Assembler::roll(Register dst, int imm8) { } } +void Assembler::eroll(Register dst, Register src, int imm8, bool no_flags) { + assert(isShiftCount(imm8), "illegal shift count"); + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = evex_prefix_and_encode_ndd(0, dst->encoding(), src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + if (imm8 == 1) { + emit_int16((unsigned char)0xD1, (0xC0 | encode)); + } else { + emit_int24((unsigned char)0xC1, (0xc0 | encode), imm8); + } +} + void Assembler::roll(Register dst) { int encode = prefix_and_encode(dst->encoding()); emit_int16((unsigned char)0xD3, (0xC0 | encode)); } +void Assembler::eroll(Register dst, Register src, bool no_flags) { + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = evex_prefix_and_encode_ndd(0, dst->encoding(), src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int16((unsigned char)0xD3, (0xC0 | encode)); +} + void Assembler::rorl(Register dst, int imm8) { assert(isShiftCount(imm8), "illegal shift count"); int encode = prefix_and_encode(dst->encoding()); @@ -6090,17 +6408,40 @@ void Assembler::rorl(Register dst, int imm8) { } } +void Assembler::erorl(Register dst, Register src, int imm8, bool no_flags) { + assert(isShiftCount(imm8), "illegal shift count"); + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = evex_prefix_and_encode_ndd(0, dst->encoding(), src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + if (imm8 == 1) { + emit_int16((unsigned char)0xD1, (0xC8 | encode)); + } else { + emit_int24((unsigned char)0xC1, (0xc8 | encode), imm8); + } +} + void Assembler::rorl(Register dst) { int encode = prefix_and_encode(dst->encoding()); emit_int16((unsigned char)0xD3, (0xC8 | encode)); } +void Assembler::erorl(Register dst, Register src, bool no_flags) { + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = evex_prefix_and_encode_ndd(0, dst->encoding(), src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int16((unsigned char)0xD3, (0xC8 | encode)); +} + #ifdef _LP64 void Assembler::rorq(Register dst) { int encode = prefixq_and_encode(dst->encoding()); emit_int16((unsigned char)0xD3, (0xC8 | encode)); } +void Assembler::erorq(Register dst, Register src, bool no_flags) { + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = evex_prefix_and_encode_ndd(0, dst->encoding(), src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int16((unsigned char)0xD3, (0xC8 | encode)); +} + void Assembler::rorq(Register dst, int imm8) { assert(isShiftCount(imm8 >> 1), "illegal shift count"); int encode = prefixq_and_encode(dst->encoding()); @@ -6111,11 +6452,28 @@ void Assembler::rorq(Register dst, int imm8) { } } +void Assembler::erorq(Register dst, Register src, int imm8, bool no_flags) { + assert(isShiftCount(imm8), "illegal shift count"); + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = evex_prefix_and_encode_ndd(0, dst->encoding(), src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + if (imm8 == 1) { + emit_int16((unsigned char)0xD1, (0xC8 | encode)); + } else { + emit_int24((unsigned char)0xC1, (0xC8 | encode), imm8); + } +} + void Assembler::rolq(Register dst) { int encode = prefixq_and_encode(dst->encoding()); emit_int16((unsigned char)0xD3, (0xC0 | encode)); } +void Assembler::erolq(Register dst, Register src, bool no_flags) { + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = evex_prefix_and_encode_ndd(0, dst->encoding(), src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int16((unsigned char)0xD3, (0xC0 | encode)); +} + void Assembler::rolq(Register dst, int imm8) { assert(isShiftCount(imm8 >> 1), "illegal shift count"); int encode = prefixq_and_encode(dst->encoding()); @@ -6125,6 +6483,17 @@ void Assembler::rolq(Register dst, int imm8) { emit_int24((unsigned char)0xC1, (0xc0 | encode), imm8); } } + +void Assembler::erolq(Register dst, Register src, int imm8, bool no_flags) { + assert(isShiftCount(imm8), "illegal shift count"); + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = evex_prefix_and_encode_ndd(0, dst->encoding(), src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + if (imm8 == 1) { + emit_int16((unsigned char)0xD1, (0xC0 | encode)); + } else { + emit_int24((unsigned char)0xC1, (0xc0 | encode), imm8); + } + } #endif void Assembler::sahf() { @@ -6150,6 +6519,23 @@ void Assembler::sall(Address dst, int imm8) { } } +void Assembler::esall(Register dst, Address src, int imm8, bool no_flags) { + InstructionMark im(this); + assert(isShiftCount(imm8), "illegal shift count"); + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_32bit); + evex_prefix_ndd(src, dst->encoding(), 0, VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + if (imm8 == 1) { + emit_int8((unsigned char)0xD1); + emit_operand(as_Register(4), src, 0); + } + else { + emit_int8((unsigned char)0xC1); + emit_operand(as_Register(4), src, 1); + emit_int8(imm8); + } +} + void Assembler::sall(Address dst) { InstructionMark im(this); prefix(dst); @@ -6157,6 +6543,15 @@ void Assembler::sall(Address dst) { emit_operand(as_Register(4), dst, 0); } +void Assembler::esall(Register dst, Address src, bool no_flags) { + InstructionMark im(this); + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_32bit); + evex_prefix_ndd(src, dst->encoding(), 0, VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int8((unsigned char)0xD3); + emit_operand(as_Register(4), src, 0); +} + void Assembler::sall(Register dst, int imm8) { assert(isShiftCount(imm8), "illegal shift count"); int encode = prefix_and_encode(dst->encoding()); @@ -6167,11 +6562,28 @@ void Assembler::sall(Register dst, int imm8) { } } +void Assembler::esall(Register dst, Register src, int imm8, bool no_flags) { + assert(isShiftCount(imm8), "illegal shift count"); + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = evex_prefix_and_encode_ndd(0, dst->encoding(), src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + if (imm8 == 1) { + emit_int16((unsigned char)0xD1, (0xE0 | encode)); + } else { + emit_int24((unsigned char)0xC1, (0xE0 | encode), imm8); + } +} + void Assembler::sall(Register dst) { int encode = prefix_and_encode(dst->encoding()); emit_int16((unsigned char)0xD3, (0xE0 | encode)); } +void Assembler::esall(Register dst, Register src, bool no_flags) { + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = evex_prefix_and_encode_ndd(0, dst->encoding(), src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int16((unsigned char)0xD3, (0xE0 | encode)); +} + void Assembler::sarl(Address dst, int imm8) { assert(isShiftCount(imm8), "illegal shift count"); InstructionMark im(this); @@ -6187,6 +6599,23 @@ void Assembler::sarl(Address dst, int imm8) { } } +void Assembler::esarl(Register dst, Address src, int imm8, bool no_flags) { + assert(isShiftCount(imm8), "illegal shift count"); + InstructionMark im(this); + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_32bit); + evex_prefix_ndd(src, dst->encoding(), 0, VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + if (imm8 == 1) { + emit_int8((unsigned char)0xD1); + emit_operand(as_Register(7), src, 0); + } + else { + emit_int8((unsigned char)0xC1); + emit_operand(as_Register(7), src, 1); + emit_int8(imm8); + } +} + void Assembler::sarl(Address dst) { InstructionMark im(this); prefix(dst); @@ -6194,6 +6623,15 @@ void Assembler::sarl(Address dst) { emit_operand(as_Register(7), dst, 0); } +void Assembler::esarl(Register dst, Address src, bool no_flags) { + InstructionMark im(this); + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_32bit); + evex_prefix_ndd(src, dst->encoding(), 0, VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int8((unsigned char)0xD3); + emit_operand(as_Register(7), src, 0); +} + void Assembler::sarl(Register dst, int imm8) { int encode = prefix_and_encode(dst->encoding()); assert(isShiftCount(imm8), "illegal shift count"); @@ -6204,11 +6642,28 @@ void Assembler::sarl(Register dst, int imm8) { } } +void Assembler::esarl(Register dst, Register src, int imm8, bool no_flags) { + assert(isShiftCount(imm8), "illegal shift count"); + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = evex_prefix_and_encode_ndd(0, dst->encoding(), src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + if (imm8 == 1) { + emit_int16((unsigned char)0xD1, (0xF8 | encode)); + } else { + emit_int24((unsigned char)0xC1, (0xF8 | encode), imm8); + } +} + void Assembler::sarl(Register dst) { int encode = prefix_and_encode(dst->encoding()); emit_int16((unsigned char)0xD3, (0xF8 | encode)); } +void Assembler::esarl(Register dst, Register src, bool no_flags) { + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = evex_prefix_and_encode_ndd(0, dst->encoding(), src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int16((unsigned char)0xD3, (0xF8 | encode)); +} + void Assembler::sbbl(Address dst, int32_t imm32) { InstructionMark im(this); prefix(dst); @@ -6220,7 +6675,6 @@ void Assembler::sbbl(Register dst, int32_t imm32) { emit_arith(0x81, 0xD8, dst, imm32); } - void Assembler::sbbl(Register dst, Address src) { InstructionMark im(this); prefix(src, dst); @@ -6313,7 +6767,6 @@ void Assembler::sha256msg2(XMMRegister dst, XMMRegister src) { emit_int16((unsigned char)0xCD, (0xC0 | encode)); } - void Assembler::shll(Register dst, int imm8) { assert(isShiftCount(imm8), "illegal shift count"); int encode = prefix_and_encode(dst->encoding()); @@ -6324,11 +6777,28 @@ void Assembler::shll(Register dst, int imm8) { } } +void Assembler::eshll(Register dst, Register src, int imm8, bool no_flags) { + assert(isShiftCount(imm8), "illegal shift count"); + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = evex_prefix_and_encode_ndd(0, dst->encoding(), src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + if (imm8 == 1 ) { + emit_int16((unsigned char)0xD1, (0xE0 | encode)); + } else { + emit_int24((unsigned char)0xC1, (0xE0 | encode), imm8); + } +} + void Assembler::shll(Register dst) { int encode = prefix_and_encode(dst->encoding()); emit_int16((unsigned char)0xD3, (0xE0 | encode)); } +void Assembler::eshll(Register dst, Register src, bool no_flags) { + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = evex_prefix_and_encode_ndd(0, dst->encoding(), src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int16((unsigned char)0xD3, (0xE0 | encode)); +} + void Assembler::shrl(Register dst, int imm8) { assert(isShiftCount(imm8), "illegal shift count"); int encode = prefix_and_encode(dst->encoding()); @@ -6340,11 +6810,29 @@ void Assembler::shrl(Register dst, int imm8) { } } +void Assembler::eshrl(Register dst, Register src, int imm8, bool no_flags) { + assert(isShiftCount(imm8), "illegal shift count"); + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = evex_prefix_and_encode_ndd(0, dst->encoding(), src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + if (imm8 == 1) { + emit_int16((unsigned char)0xD1, (0xE8 | encode)); + } + else { + emit_int24((unsigned char)0xC1, (0xE8 | encode), imm8); + } +} + void Assembler::shrl(Register dst) { int encode = prefix_and_encode(dst->encoding()); emit_int16((unsigned char)0xD3, (0xE8 | encode)); } +void Assembler::eshrl(Register dst, Register src, bool no_flags) { + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = evex_prefix_and_encode_ndd(0, dst->encoding(), src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int16((unsigned char)0xD3, (0xE8 | encode)); +} + void Assembler::shrl(Address dst) { InstructionMark im(this); prefix(dst); @@ -6352,6 +6840,15 @@ void Assembler::shrl(Address dst) { emit_operand(as_Register(5), dst, 0); } +void Assembler::eshrl(Register dst, Address src, bool no_flags) { + InstructionMark im(this); + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_32bit); + evex_prefix_ndd(src, dst->encoding(), 0, VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int8((unsigned char)0xD3); + emit_operand(as_Register(5), src, 0); +} + void Assembler::shrl(Address dst, int imm8) { InstructionMark im(this); assert(isShiftCount(imm8), "illegal shift count"); @@ -6367,37 +6864,89 @@ void Assembler::shrl(Address dst, int imm8) { } } +void Assembler::eshrl(Register dst, Address src, int imm8, bool no_flags) { + InstructionMark im(this); + assert(isShiftCount(imm8), "illegal shift count"); + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_32bit); + evex_prefix_ndd(src, dst->encoding(), 0, VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + if (imm8 == 1) { + emit_int8((unsigned char)0xD1); + emit_operand(as_Register(5), src, 0); + } + else { + emit_int8((unsigned char)0xC1); + emit_operand(as_Register(5), src, 1); + emit_int8(imm8); + } +} void Assembler::shldl(Register dst, Register src) { int encode = prefix_and_encode(src->encoding(), dst->encoding(), true /* is_map1 */); emit_opcode_prefix_and_encoding((unsigned char)0xA5, 0xC0, encode); } +void Assembler::eshldl(Register dst, Register src1, Register src2, bool no_flags) { + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = evex_prefix_and_encode_ndd(src1->encoding(), dst->encoding(), src2->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int16(0xA5, (0xC0 | encode)); +} + void Assembler::shldl(Register dst, Register src, int8_t imm8) { int encode = prefix_and_encode(src->encoding(), dst->encoding(), true /* is_map1 */); emit_opcode_prefix_and_encoding((unsigned char)0xA4, 0xC0, encode, imm8); } +void Assembler::eshldl(Register dst, Register src1, Register src2, int8_t imm8, bool no_flags) { + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = evex_prefix_and_encode_ndd(src1->encoding(), dst->encoding(), src2->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int24(0x24, (0xC0 | encode), imm8); +} + void Assembler::shrdl(Register dst, Register src) { int encode = prefix_and_encode(src->encoding(), dst->encoding(), true /* is_map1 */); emit_opcode_prefix_and_encoding((unsigned char)0xAD, 0xC0, encode); } +void Assembler::eshrdl(Register dst, Register src1, Register src2, bool no_flags) { + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = evex_prefix_and_encode_ndd(src1->encoding(), dst->encoding(), src2->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int16(0xAD, (0xC0 | encode)); +} + void Assembler::shrdl(Register dst, Register src, int8_t imm8) { int encode = prefix_and_encode(src->encoding(), dst->encoding(), true /* is_map1 */); emit_opcode_prefix_and_encoding((unsigned char)0xAC, 0xC0, encode, imm8); } +void Assembler::eshrdl(Register dst, Register src1, Register src2, int8_t imm8, bool no_flags) { + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = evex_prefix_and_encode_ndd(src1->encoding(), dst->encoding(), src2->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int24(0x2C, (0xC0 | encode), imm8); +} + #ifdef _LP64 void Assembler::shldq(Register dst, Register src, int8_t imm8) { int encode = prefixq_and_encode(src->encoding(), dst->encoding(), true /* is_map1 */); emit_opcode_prefix_and_encoding((unsigned char)0xA4, 0xC0, encode, imm8); } +void Assembler::eshldq(Register dst, Register src1, Register src2, int8_t imm8, bool no_flags) { + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = evex_prefix_and_encode_ndd(src1->encoding(), dst->encoding(), src2->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int24(0x24, (0xC0 | encode), imm8); +} + void Assembler::shrdq(Register dst, Register src, int8_t imm8) { int encode = prefixq_and_encode(src->encoding(), dst->encoding(), true /* is_map1 */); emit_opcode_prefix_and_encoding((unsigned char)0xAC, 0xC0, encode, imm8); } + +void Assembler::eshrdq(Register dst, Register src1, Register src2, int8_t imm8, bool no_flags) { + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = evex_prefix_and_encode_ndd(src1->encoding(), dst->encoding(), src2->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int24(0x2C, (0xC0 | encode), imm8); +} #endif // copies a single word from [esi] to [edi] @@ -6488,6 +7037,14 @@ void Assembler::subl(Address dst, int32_t imm32) { emit_arith_operand(0x81, rbp, dst, imm32); } +void Assembler::esubl(Register dst, Address src, int32_t imm32, bool no_flags) { + InstructionMark im(this); + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_32bit); + evex_prefix_ndd(src, dst->encoding(), 0, VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_arith_operand(0x81, rbp, src, imm32); +} + void Assembler::subl(Address dst, Register src) { InstructionMark im(this); prefix(dst, src); @@ -6495,17 +7052,38 @@ void Assembler::subl(Address dst, Register src) { emit_operand(src, dst, 0); } +void Assembler::esubl(Register dst, Address src1, Register src2, bool no_flags) { + InstructionMark im(this); + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_32bit); + evex_prefix_ndd(src1, dst->encoding(), src2->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int8(0x29); + emit_operand(src2, src1, 0); +} + void Assembler::subl(Register dst, int32_t imm32) { prefix(dst); emit_arith(0x81, 0xE8, dst, imm32); } +void Assembler::esubl(Register dst, Register src, int32_t imm32, bool no_flags) { + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + (void) evex_prefix_and_encode_ndd(0, dst->encoding(), src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_arith(0x81, 0xE8, src, imm32); +} + // Force generation of a 4 byte immediate value even if it fits into 8bit void Assembler::subl_imm32(Register dst, int32_t imm32) { prefix(dst); emit_arith_imm32(0x81, 0xE8, dst, imm32); } +void Assembler::esubl_imm32(Register dst, Register src, int32_t imm32, bool no_flags) { + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + (void) evex_prefix_and_encode_ndd(0, dst->encoding(), src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_arith_imm32(0x81, 0xE8, src, imm32); +} + void Assembler::subl(Register dst, Address src) { InstructionMark im(this); prefix(src, dst); @@ -6513,11 +7091,27 @@ void Assembler::subl(Register dst, Address src) { emit_operand(dst, src, 0); } +void Assembler::esubl(Register dst, Register src1, Address src2, bool no_flags) { + InstructionMark im(this); + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_32bit); + evex_prefix_ndd(src2, dst->encoding(), src1->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int8(0x2B); + emit_operand(src1, src2, 0); +} + void Assembler::subl(Register dst, Register src) { (void) prefix_and_encode(dst->encoding(), src->encoding()); emit_arith(0x2B, 0xC0, dst, src); } +void Assembler::esubl(Register dst, Register src2, Register src1, bool no_flags) { + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + (void) evex_prefix_and_encode_ndd(src1->encoding(), dst->encoding(), src2->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + // opcode matches gcc + emit_arith(0x29, 0xC0, src1, src2); +} + void Assembler::subsd(XMMRegister dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); @@ -6621,6 +7215,13 @@ void Assembler::tzcntl(Register dst, Register src) { emit_opcode_prefix_and_encoding((unsigned char)0xBC, 0xC0, encode); } +void Assembler::etzcntl(Register dst, Register src, bool no_flags) { + assert(VM_Version::supports_bmi1(), "tzcnt instruction not supported"); + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = evex_prefix_and_encode_nf(dst->encoding(), 0, src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int16((unsigned char)0xF4, (0xC0 | encode)); +} + void Assembler::tzcntl(Register dst, Address src) { assert(VM_Version::supports_bmi1(), "tzcnt instruction not supported"); InstructionMark im(this); @@ -6630,6 +7231,16 @@ void Assembler::tzcntl(Register dst, Address src) { emit_operand(dst, src, 0); } +void Assembler::etzcntl(Register dst, Address src, bool no_flags) { + assert(VM_Version::supports_bmi1(), "tzcnt instruction not supported"); + InstructionMark im(this); + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_32bit); + evex_prefix_nf(src, 0, dst->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int8((unsigned char)0xF4); + emit_operand(dst, src, 0); +} + void Assembler::tzcntq(Register dst, Register src) { assert(VM_Version::supports_bmi1(), "tzcnt instruction not supported"); emit_int8((unsigned char)0xF3); @@ -6637,6 +7248,13 @@ void Assembler::tzcntq(Register dst, Register src) { emit_opcode_prefix_and_encoding((unsigned char)0xBC, 0xC0, encode); } +void Assembler::etzcntq(Register dst, Register src, bool no_flags) { + assert(VM_Version::supports_bmi1(), "tzcnt instruction not supported"); + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = evex_prefix_and_encode_nf(dst->encoding(), 0, src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int16((unsigned char)0xF4, (0xC0 | encode)); +} + void Assembler::tzcntq(Register dst, Address src) { assert(VM_Version::supports_bmi1(), "tzcnt instruction not supported"); InstructionMark im(this); @@ -6646,6 +7264,16 @@ void Assembler::tzcntq(Register dst, Address src) { emit_operand(dst, src, 0); } +void Assembler::etzcntq(Register dst, Address src, bool no_flags) { + assert(VM_Version::supports_bmi1(), "tzcnt instruction not supported"); + InstructionMark im(this); + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_64bit); + evex_prefix_nf(src, 0, dst->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int8((unsigned char)0xF4); + emit_operand(dst, src, 0); +} + void Assembler::ucomisd(XMMRegister dst, Address src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); InstructionMark im(this); @@ -6765,11 +7393,25 @@ void Assembler::xorl(Address dst, int32_t imm32) { emit_arith_operand(0x81, as_Register(6), dst, imm32); } +void Assembler::exorl(Register dst, Address src, int32_t imm32, bool no_flags) { + InstructionMark im(this); + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_32bit); + evex_prefix_ndd(src, dst->encoding(), 0, VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_arith_operand(0x81, as_Register(6), src, imm32); +} + void Assembler::xorl(Register dst, int32_t imm32) { prefix(dst); emit_arith(0x81, 0xF0, dst, imm32); } +void Assembler::exorl(Register dst, Register src, int32_t imm32, bool no_flags) { + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + evex_prefix_and_encode_ndd(0, dst->encoding(), src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_arith(0x81, 0xF0, src, imm32); +} + void Assembler::xorl(Register dst, Address src) { InstructionMark im(this); prefix(src, dst); @@ -6777,11 +7419,27 @@ void Assembler::xorl(Register dst, Address src) { emit_operand(dst, src, 0); } +void Assembler::exorl(Register dst, Register src1, Address src2, bool no_flags) { + InstructionMark im(this); + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_32bit); + evex_prefix_ndd(src2, dst->encoding(), src1->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int8(0x33); + emit_operand(src1, src2, 0); +} + void Assembler::xorl(Register dst, Register src) { (void) prefix_and_encode(dst->encoding(), src->encoding()); emit_arith(0x33, 0xC0, dst, src); } +void Assembler::exorl(Register dst, Register src1, Register src2, bool no_flags) { + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + (void) evex_prefix_and_encode_ndd(src1->encoding(), dst->encoding(), src2->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + // opcode matches gcc + emit_arith(0x31, 0xC0, src1, src2); +} + void Assembler::xorl(Address dst, Register src) { InstructionMark im(this); prefix(dst, src); @@ -6789,6 +7447,15 @@ void Assembler::xorl(Address dst, Register src) { emit_operand(src, dst, 0); } +void Assembler::exorl(Register dst, Address src1, Register src2, bool no_flags) { + InstructionMark im(this); + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_32bit); + evex_prefix_ndd(src1, dst->encoding(), src2->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int8(0x31); + emit_operand(src2, src1, 0); +} + void Assembler::xorb(Register dst, Address src) { InstructionMark im(this); prefix(src, dst); @@ -6796,6 +7463,15 @@ void Assembler::xorb(Register dst, Address src) { emit_operand(dst, src, 0); } +void Assembler::exorb(Register dst, Register src1, Address src2, bool no_flags) { + InstructionMark im(this); + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_8bit); + evex_prefix_ndd(src2, dst->encoding(), src1->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int8(0x32); + emit_operand(src1, src2, 0); +} + void Assembler::xorb(Address dst, Register src) { InstructionMark im(this); prefix(dst, src, true); @@ -6803,9 +7479,13 @@ void Assembler::xorb(Address dst, Register src) { emit_operand(src, dst, 0); } -void Assembler::xorw(Register dst, Register src) { - (void)prefix_and_encode(dst->encoding(), src->encoding()); - emit_arith(0x33, 0xC0, dst, src); +void Assembler::exorb(Register dst, Address src1, Register src2, bool no_flags) { + InstructionMark im(this); + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_8bit); + evex_prefix_ndd(src1, dst->encoding(), src2->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int8(0x30); + emit_operand(src2, src1, 0); } void Assembler::xorw(Register dst, Address src) { @@ -6816,6 +7496,16 @@ void Assembler::xorw(Register dst, Address src) { emit_operand(dst, src, 0); } +void Assembler::exorw(Register dst, Register src1, Address src2, bool no_flags) { + InstructionMark im(this); + emit_int8(0x66); + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_64bit); + evex_prefix_ndd(src2, dst->encoding(), src1->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int8(0x33); + emit_operand(src1, src2, 0); +} + // AVX 3-operands scalar float-point arithmetic instructions void Assembler::vaddsd(XMMRegister dst, XMMRegister nds, Address src) { @@ -7363,6 +8053,14 @@ void Assembler::andpd(XMMRegister dst, XMMRegister src) { emit_int16(0x54, (0xC0 | encode)); } +void Assembler::andnpd(XMMRegister dst, XMMRegister src) { + NOT_LP64(assert(VM_Version::supports_sse2(), "")); + InstructionAttr attributes(AVX_128bit, /* rex_w */ !_legacy_mode_dq, /* legacy_mode */ _legacy_mode_dq, /* no_mask_reg */ true, /* uses_vl */ true); + attributes.set_rex_vex_w_reverted(); + int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F, &attributes); + emit_int16(0x55, (0xC0 | encode)); +} + void Assembler::andps(XMMRegister dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse(), "")); InstructionAttr attributes(AVX_128bit, /* rex_w */ false, /* legacy_mode */ _legacy_mode_dq, /* no_mask_reg */ true, /* uses_vl */ true); @@ -8974,6 +9672,15 @@ void Assembler::vinserti64x4(XMMRegister dst, XMMRegister nds, XMMRegister src, emit_int24(0x3A, (0xC0 | encode), imm8 & 0x01); } +void Assembler::evinserti64x2(XMMRegister dst, XMMRegister nds, XMMRegister src, uint8_t imm8, int vector_len) { + assert(VM_Version::supports_avx512dq(), ""); + assert(vector_len == AVX_512bit || VM_Version::supports_avx512vl(), ""); + InstructionAttr attributes(vector_len, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ true); + attributes.set_is_evex_instruction(); + int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes); + emit_int24(0x38, (0xC0 | encode), imm8 & 0x03); +} + // vinsertf forms @@ -11038,6 +11745,21 @@ void Assembler::vbroadcastf128(XMMRegister dst, Address src, int vector_len) { emit_operand(dst, src, 0); } +void Assembler::evbroadcastf64x2(XMMRegister dst, Address src, int vector_len) { + assert(VM_Version::supports_avx512dq(), ""); + assert(vector_len == AVX_512bit || VM_Version::supports_avx512vl(), ""); + assert(dst != xnoreg, "sanity"); + InstructionMark im(this); + InstructionAttr attributes(vector_len, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ true); + attributes.set_address_attributes(/* tuple_type */ EVEX_T2, /* input_size_in_bits */ EVEX_64bit); + attributes.set_is_evex_instruction(); + // swap src<->dst for encoding + vex_prefix(src, 0, dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes); + emit_int8(0x1A); + emit_operand(dst, src, 0); +} + + // gpr source broadcast forms // duplicate 1-byte integer data from src into programmed locations in dest : requires AVX512BW and AVX512VL @@ -11399,6 +12121,12 @@ void Assembler::decl(Register dst) { emit_int8(0x48 | dst->encoding()); } +void Assembler::edecl(Register dst, Register src, bool no_flags) { + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + (void) evex_prefix_and_encode_ndd(0, dst->encoding(), src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int8(0x48 | src->encoding()); +} + // 64bit doesn't use the x87 void Assembler::fabs() { @@ -11837,7 +12565,7 @@ void Assembler::vex_prefix(bool vex_r, bool vex_b, bool vex_x, int nds_enc, VexS // This is a 4 byte encoding void Assembler::evex_prefix(bool vex_r, bool vex_b, bool vex_x, bool evex_r, bool eevex_b, bool evex_v, - bool eevex_x, int nds_enc, VexSimdPrefix pre, VexOpcode opc) { + bool eevex_x, int nds_enc, VexSimdPrefix pre, VexOpcode opc, bool no_flags) { // EVEX 0x62 prefix // byte1 = EVEX_4bytes; @@ -11863,11 +12591,17 @@ void Assembler::evex_prefix(bool vex_r, bool vex_b, bool vex_x, bool evex_r, boo // of form {66, F3, F2} byte3 |= pre; - // P2: byte 4 as zL'Lbv'aaa - // kregs are implemented in the low 3 bits as aaa - int byte4 = (_attributes->is_no_reg_mask()) ? - 0 : - _attributes->get_embedded_opmask_register_specifier(); + // P2: byte 4 as zL'Lbv'aaa or 00LXVF00 where V = V4, X(extended context) = ND and F = NF (no flags) + int byte4 = 0; + if (no_flags) { + assert(_attributes->is_no_reg_mask(), "mask register not supported with no_flags"); + byte4 |= 0x4; + } else { + // kregs are implemented in the low 3 bits as aaa + byte4 = (_attributes->is_no_reg_mask()) ? + 0 : + _attributes->get_embedded_opmask_register_specifier(); + } // EVEX.v` for extending EVEX.vvvv or VIDX byte4 |= (evex_v ? 0: EVEX_V); // third EXEC.b for broadcast actions @@ -11882,11 +12616,12 @@ void Assembler::evex_prefix(bool vex_r, bool vex_b, bool vex_x, bool evex_r, boo emit_int32(EVEX_4bytes, byte2, byte3, byte4); } -void Assembler::vex_prefix(Address adr, int nds_enc, int xreg_enc, VexSimdPrefix pre, VexOpcode opc, InstructionAttr *attributes) { - if (adr.base_needs_rex2() || adr.index_needs_rex2()) { +void Assembler::vex_prefix(Address adr, int nds_enc, int xreg_enc, VexSimdPrefix pre, VexOpcode opc, InstructionAttr *attributes, bool nds_is_ndd, bool no_flags) { + if (adr.base_needs_rex2() || adr.index_needs_rex2() || nds_is_ndd || no_flags) { assert(UseAPX, "APX features not enabled"); } - bool is_extended = adr.base_needs_rex2() || adr.index_needs_rex2() || nds_enc >= 16 || xreg_enc >= 16; + if (nds_is_ndd) attributes->set_extended_context(); + bool is_extended = adr.base_needs_rex2() || adr.index_needs_rex2() || nds_enc >= 16 || xreg_enc >= 16 || nds_is_ndd; bool vex_r = (xreg_enc & 8) == 8; bool vex_b = adr.base_needs_rex(); bool vex_x; @@ -11929,7 +12664,7 @@ void Assembler::vex_prefix(Address adr, int nds_enc, int xreg_enc, VexSimdPrefix bool eevex_x = adr.index_needs_rex2(); bool eevex_b = adr.base_needs_rex2(); attributes->set_is_evex_instruction(); - evex_prefix(vex_r, vex_b, vex_x, evex_r, eevex_b, evex_v, eevex_x, nds_enc, pre, opc); + evex_prefix(vex_r, vex_b, vex_x, evex_r, eevex_b, evex_v, eevex_x, nds_enc, pre, opc, no_flags); } else { if (UseAVX > 2 && attributes->is_rex_vex_w_reverted()) { attributes->set_rex_vex_w(false); @@ -11938,10 +12673,21 @@ void Assembler::vex_prefix(Address adr, int nds_enc, int xreg_enc, VexSimdPrefix } } -int Assembler::vex_prefix_and_encode(int dst_enc, int nds_enc, int src_enc, VexSimdPrefix pre, VexOpcode opc, InstructionAttr *attributes, bool src_is_gpr) { - if (src_is_gpr && src_enc >= 16) { +void Assembler::evex_prefix_ndd(Address adr, int ndd_enc, int xreg_enc, VexSimdPrefix pre, VexOpcode opc, InstructionAttr *attributes, bool no_flags) { + attributes->set_is_evex_instruction(); + vex_prefix(adr, ndd_enc, xreg_enc, pre, opc, attributes, /* nds_is_ndd */ true, no_flags); +} + +void Assembler::evex_prefix_nf(Address adr, int ndd_enc, int xreg_enc, VexSimdPrefix pre, VexOpcode opc, InstructionAttr *attributes, bool no_flags) { + attributes->set_is_evex_instruction(); + vex_prefix(adr, ndd_enc, xreg_enc, pre, opc, attributes, /* nds_is_ndd */ false, no_flags); +} + +int Assembler::vex_prefix_and_encode(int dst_enc, int nds_enc, int src_enc, VexSimdPrefix pre, VexOpcode opc, InstructionAttr *attributes, bool src_is_gpr, bool nds_is_ndd, bool no_flags) { + if (nds_is_ndd || no_flags || (src_is_gpr && src_enc >= 16)) { assert(UseAPX, "APX features not enabled"); } + if (nds_is_ndd) attributes->set_extended_context(); bool is_extended = dst_enc >= 16 || nds_enc >= 16 || src_enc >=16; bool vex_r = (dst_enc & 8) == 8; bool vex_b = (src_enc & 8) == 8; @@ -11983,7 +12729,7 @@ int Assembler::vex_prefix_and_encode(int dst_enc, int nds_enc, int src_enc, VexS // can use vex_x as bank extender on rm encoding vex_x = (src_enc >= 16) && !src_is_gpr; attributes->set_is_evex_instruction(); - evex_prefix(vex_r, vex_b, vex_x, evex_r, evex_b, evex_v, false /*eevex_x*/, nds_enc, pre, opc); + evex_prefix(vex_r, vex_b, vex_x, evex_r, evex_b, evex_v, false /*eevex_x*/, nds_enc, pre, opc, no_flags); } else { if (UseAVX > 2 && attributes->is_rex_vex_w_reverted()) { attributes->set_rex_vex_w(false); @@ -11995,6 +12741,18 @@ int Assembler::vex_prefix_and_encode(int dst_enc, int nds_enc, int src_enc, VexS return (((dst_enc & 7) << 3) | (src_enc & 7)); } +int Assembler::evex_prefix_and_encode_ndd(int dst_enc, int nds_enc, int src_enc, VexSimdPrefix pre, VexOpcode opc, + InstructionAttr *attributes, bool no_flags) { + attributes->set_is_evex_instruction(); + return vex_prefix_and_encode(dst_enc, nds_enc, src_enc, pre, opc, attributes, /* src_is_gpr */ true, /* nds_is_ndd */ true, no_flags); +} + +int Assembler::evex_prefix_and_encode_nf(int dst_enc, int nds_enc, int src_enc, VexSimdPrefix pre, VexOpcode opc, + InstructionAttr *attributes, bool no_flags) { + attributes->set_is_evex_instruction(); + return vex_prefix_and_encode(dst_enc, nds_enc, src_enc, pre, opc, attributes, /* src_is_gpr */ true, /* nds_is_ndd */ false, no_flags); +} + void Assembler::simd_prefix(XMMRegister xreg, XMMRegister nds, Address adr, VexSimdPrefix pre, VexOpcode opc, InstructionAttr *attributes) { if (UseAVX > 0) { @@ -12839,6 +13597,12 @@ void Assembler::incl(Register dst) { emit_int8(0x40 | dst->encoding()); } +void Assembler::eincl(Register dst, Register src, bool no_flags) { + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + (void) evex_prefix_and_encode_ndd(0, dst->encoding(), src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int8(0x40 | src->encoding()); +} + void Assembler::lea(Register dst, Address src) { leal(dst, src); } @@ -13463,28 +14227,67 @@ void Assembler::addq(Address dst, int32_t imm32) { emit_arith_operand(0x81, rax, dst, imm32); } +void Assembler::eaddq(Register dst, Address src, int32_t imm32, bool no_flags) { + InstructionMark im(this); + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_64bit); + evex_prefix_ndd(src, dst->encoding(), 0, VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_arith_operand(0x81, rax, src, imm32); +} + void Assembler::addq(Address dst, Register src) { InstructionMark im(this); emit_prefix_and_int8(get_prefixq(dst, src), 0x01); emit_operand(src, dst, 0); } +void Assembler::eaddq(Register dst, Address src1, Register src2, bool no_flags) { + InstructionMark im(this); + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_64bit); + evex_prefix_ndd(src1, dst->encoding(), src2->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int8(0x01); + emit_operand(src2, src1, 0); +} + void Assembler::addq(Register dst, int32_t imm32) { (void) prefixq_and_encode(dst->encoding()); emit_arith(0x81, 0xC0, dst, imm32); } +void Assembler::eaddq(Register dst, Register src, int32_t imm32, bool no_flags) { + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + (void) evex_prefix_and_encode_ndd(0, dst->encoding(), src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_arith(0x81, 0xC0, src, imm32); +} + void Assembler::addq(Register dst, Address src) { InstructionMark im(this); emit_prefix_and_int8(get_prefixq(src, dst), 0x03); emit_operand(dst, src, 0); } +void Assembler::eaddq(Register dst, Register src1, Address src2, bool no_flags) { + InstructionMark im(this); + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_64bit); + evex_prefix_ndd(src2, dst->encoding(), src1->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int8(0x03); + emit_operand(src1, src2, 0); +} + void Assembler::addq(Register dst, Register src) { (void) prefixq_and_encode(dst->encoding(), src->encoding()); emit_arith(0x03, 0xC0, dst, src); } +void Assembler::eaddq(Register dst, Register src1, Register src2, bool no_flags) { + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + (void) evex_prefix_and_encode_ndd(src1->encoding(), dst->encoding(), src2->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + // opcode matches gcc + emit_arith(0x01, 0xC0, src1, src2); +} + void Assembler::adcxq(Register dst, Register src) { //assert(VM_Version::supports_adx(), "adx instructions not supported"); if (needs_rex2(dst, src)) { @@ -13501,6 +14304,12 @@ void Assembler::adcxq(Register dst, Register src) { } } +void Assembler::eadcxq(Register dst, Register src1, Register src2) { + InstructionAttr attributes(AVX_128bit, /* rex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = evex_prefix_and_encode_ndd(src1->encoding(), dst->encoding(), src2->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_3C, &attributes); + emit_int16((unsigned char)0x66, (0xC0 | encode)); +} + void Assembler::adoxq(Register dst, Register src) { //assert(VM_Version::supports_adx(), "adx instructions not supported"); if (needs_rex2(dst, src)) { @@ -13516,34 +14325,80 @@ void Assembler::adoxq(Register dst, Register src) { (0xC0 | encode)); } } + +void Assembler::eadoxq(Register dst, Register src1, Register src2) { + InstructionAttr attributes(AVX_128bit, /* rex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = evex_prefix_and_encode_ndd(src1->encoding(), dst->encoding(), src2->encoding(), VEX_SIMD_F3, VEX_OPCODE_0F_3C, &attributes); + emit_int16((unsigned char)0x66, (0xC0 | encode)); +} + void Assembler::andq(Address dst, int32_t imm32) { InstructionMark im(this); prefixq(dst); emit_arith_operand(0x81, as_Register(4), dst, imm32); } +void Assembler::eandq(Register dst, Address src, int32_t imm32, bool no_flags) { + InstructionMark im(this); + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_64bit); + evex_prefix_ndd(src, dst->encoding(), 0, VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_arith_operand(0x81, as_Register(4), src, imm32); +} + void Assembler::andq(Register dst, int32_t imm32) { (void) prefixq_and_encode(dst->encoding()); emit_arith(0x81, 0xE0, dst, imm32); } +void Assembler::eandq(Register dst, Register src, int32_t imm32, bool no_flags) { + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + evex_prefix_and_encode_ndd(0, dst->encoding(), src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_arith(0x81, 0xE0, src, imm32); +} + void Assembler::andq(Register dst, Address src) { InstructionMark im(this); emit_prefix_and_int8(get_prefixq(src, dst), 0x23); emit_operand(dst, src, 0); } +void Assembler::eandq(Register dst, Register src1, Address src2, bool no_flags) { + InstructionMark im(this); + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_64bit); + evex_prefix_ndd(src2, dst->encoding(), src1->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int8(0x23); + emit_operand(src1, src2, 0); +} + void Assembler::andq(Register dst, Register src) { (void) prefixq_and_encode(dst->encoding(), src->encoding()); emit_arith(0x23, 0xC0, dst, src); } +void Assembler::eandq(Register dst, Register src1, Register src2, bool no_flags) { + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + (void) evex_prefix_and_encode_ndd(src1->encoding(), dst->encoding(), src2->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + // opcode matches gcc + emit_arith(0x21, 0xC0, src1, src2); +} + void Assembler::andq(Address dst, Register src) { InstructionMark im(this); emit_prefix_and_int8(get_prefixq(dst, src), 0x21); emit_operand(src, dst, 0); } +void Assembler::eandq(Register dst, Address src1, Register src2, bool no_flags) { + InstructionMark im(this); + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_64bit); + evex_prefix_ndd(src1, dst->encoding(), src2->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int8(0x21); + emit_operand(src2, src1, 0); +} + void Assembler::andnq(Register dst, Register src1, Register src2) { assert(VM_Version::supports_bmi1(), "bit manipulation instructions not supported"); InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); @@ -13677,6 +14532,12 @@ void Assembler::cmovq(Condition cc, Register dst, Register src) { emit_opcode_prefix_and_encoding((0x40 | cc), 0xC0, encode); } +void Assembler::ecmovq(Condition cc, Register dst, Register src1, Register src2) { + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = evex_prefix_and_encode_ndd(src1->encoding(), dst->encoding(), src2->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes); + emit_int16((0x40 | cc), (0xC0 | encode)); +} + void Assembler::cmovq(Condition cc, Register dst, Address src) { InstructionMark im(this); int prefix = get_prefixq(src, dst, true /* is_map1 */); @@ -13684,6 +14545,15 @@ void Assembler::cmovq(Condition cc, Register dst, Address src) { emit_operand(dst, src, 0); } +void Assembler::ecmovq(Condition cc, Register dst, Register src1, Address src2) { + InstructionMark im(this); + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_64bit); + evex_prefix_ndd(src2, dst->encoding(), src1->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes); + emit_int8((0x40 | cc)); + emit_operand(src1, src2, 0); +} + void Assembler::cmpq(Address dst, int32_t imm32) { InstructionMark im(this); prefixq(dst); @@ -13785,6 +14655,12 @@ void Assembler::decl(Register dst) { emit_int16((unsigned char)0xFF, (0xC8 | encode)); } +void Assembler::edecl(Register dst, Register src, bool no_flags) { + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = evex_prefix_and_encode_ndd(0, dst->encoding(), src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int16((unsigned char)0xFF, (0xC8 | encode)); +} + void Assembler::decq(Register dst) { // Don't use it directly. Use MacroAssembler::decrementq() instead. // Use two-byte form (one-byte from is a REX prefix in 64-bit mode) @@ -13792,6 +14668,12 @@ void Assembler::decq(Register dst) { emit_int16((unsigned char)0xFF, 0xC8 | encode); } +void Assembler::edecq(Register dst, Register src, bool no_flags) { + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = evex_prefix_and_encode_ndd(0, dst->encoding(), src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int16((unsigned char)0xFF, (0xC8 | encode)); +} + void Assembler::decq(Address dst) { // Don't use it directly. Use MacroAssembler::decrementq() instead. InstructionMark im(this); @@ -13799,6 +14681,15 @@ void Assembler::decq(Address dst) { emit_operand(rcx, dst, 0); } +void Assembler::edecq(Register dst, Address src, bool no_flags) { + InstructionMark im(this); + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_64bit); + evex_prefix_ndd(src, dst->encoding(), 0, VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int8((unsigned char)0xFF); + emit_operand(rcx, src, 0); +} + // can't use REX2 void Assembler::fxrstor(Address src) { InstructionMark im(this); @@ -13832,21 +14723,51 @@ void Assembler::idivq(Register src) { emit_int16((unsigned char)0xF7, (0xF8 | encode)); } +void Assembler::eidivq(Register src, bool no_flags) { + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = evex_prefix_and_encode_nf(0, 0, src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int16((unsigned char)0xF7, (0xF8 | encode)); +} + void Assembler::divq(Register src) { int encode = prefixq_and_encode(src->encoding()); emit_int16((unsigned char)0xF7, (0xF0 | encode)); } +void Assembler::edivq(Register src, bool no_flags) { + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = evex_prefix_and_encode_nf(0, 0, src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int16((unsigned char)0xF7, (0xF0 | encode)); +} + void Assembler::imulq(Register dst, Register src) { int encode = prefixq_and_encode(dst->encoding(), src->encoding(), true /* is_map1 */); emit_opcode_prefix_and_encoding((unsigned char)0xAF, 0xC0, encode); } +void Assembler::eimulq(Register dst, Register src, bool no_flags) { + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = evex_prefix_and_encode_nf(dst->encoding(), 0, src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int16((unsigned char)0xAF, (0xC0 | encode)); +} + +void Assembler::eimulq(Register dst, Register src1, Register src2, bool no_flags) { + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = evex_prefix_and_encode_ndd(src1->encoding(), dst->encoding(), src2->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int16((unsigned char)0xAF, (0xC0 | encode)); +} + void Assembler::imulq(Register src) { int encode = prefixq_and_encode(src->encoding()); emit_int16((unsigned char)0xF7, (0xE8 | encode)); } +void Assembler::eimulq(Register src, bool no_flags) { + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = evex_prefix_and_encode_nf(0, 0, src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int16((unsigned char)0xF7, (0xE8 | encode)); +} + void Assembler::imulq(Register dst, Address src, int32_t value) { InstructionMark im(this); prefixq(src, dst); @@ -13861,6 +14782,22 @@ void Assembler::imulq(Register dst, Address src, int32_t value) { } } +void Assembler::eimulq(Register dst, Address src, int32_t value, bool no_flags) { + InstructionMark im(this); + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_32bit); + evex_prefix_nf(src, 0, dst->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + if (is8bit(value)) { + emit_int8((unsigned char)0x6B); + emit_operand(dst, src, 1); + emit_int8(value); + } else { + emit_int8((unsigned char)0x69); + emit_operand(dst, src, 4); + emit_int32(value); + } +} + void Assembler::imulq(Register dst, Register src, int value) { int encode = prefixq_and_encode(dst->encoding(), src->encoding()); if (is8bit(value)) { @@ -13871,6 +14808,17 @@ void Assembler::imulq(Register dst, Register src, int value) { } } +void Assembler::eimulq(Register dst, Register src, int value, bool no_flags) { + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = vex_prefix_and_encode(dst->encoding(), 0, src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, /* src_is_gpr */ true, /* nds_is_ndd */ false, no_flags); + if (is8bit(value)) { + emit_int24(0x6B, (0xC0 | encode), (value & 0xFF)); + } else { + emit_int16(0x69, (0xC0 | encode)); + emit_int32(value); + } +} + void Assembler::imulq(Register dst, Address src) { InstructionMark im(this); int prefix = get_prefixq(src, dst, true /* is_map1 */); @@ -13878,6 +14826,23 @@ void Assembler::imulq(Register dst, Address src) { emit_operand(dst, src, 0); } +void Assembler::eimulq(Register dst, Address src, bool no_flags) { + InstructionMark im(this); + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + vex_prefix(src, 0, dst->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F, &attributes, /* nds_is_ndd */ false, no_flags); + emit_int8((unsigned char)0xAF); + emit_operand(dst, src, 0); +} + +void Assembler::eimulq(Register dst, Register src1, Address src2, bool no_flags) { + InstructionMark im(this); + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_32bit); + evex_prefix_ndd(src2, dst->encoding(), src1->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int8((unsigned char)0xAF); + emit_operand(src1, src2, 0); +} + void Assembler::incl(Register dst) { // Don't use it directly. Use MacroAssembler::incrementl() instead. // Use two-byte form (one-byte from is a REX prefix in 64-bit mode) @@ -13885,6 +14850,15 @@ void Assembler::incl(Register dst) { emit_int16((unsigned char)0xFF, (0xC0 | encode)); } +void Assembler::eincl(Register dst, Register src, bool no_flags) { + // Don't use it directly. Use MacroAssembler::incrementl() instead. + // Use two-byte form (one-byte from is a REX prefix in 64-bit mode) + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + // int encode = evex_prefix_and_encode_ndd(0, dst->encoding(), src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + int encode = evex_prefix_and_encode_ndd(0, dst->encoding(), src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int16((unsigned char)0xFF, (0xC0 | encode)); +} + void Assembler::incq(Register dst) { // Don't use it directly. Use MacroAssembler::incrementq() instead. // Use two-byte form (one-byte from is a REX prefix in 64-bit mode) @@ -13892,6 +14866,14 @@ void Assembler::incq(Register dst) { emit_int16((unsigned char)0xFF, (0xC0 | encode)); } +void Assembler::eincq(Register dst, Register src, bool no_flags) { + // Don't use it directly. Use MacroAssembler::incrementq() instead. + // Use two-byte form (one-byte from is a REX prefix in 64-bit mode) + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = evex_prefix_and_encode_ndd(0, dst->encoding(), src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int16((unsigned char)0xFF, (0xC0 | encode)); +} + void Assembler::incq(Address dst) { // Don't use it directly. Use MacroAssembler::incrementq() instead. InstructionMark im(this); @@ -13899,6 +14881,16 @@ void Assembler::incq(Address dst) { emit_operand(rax, dst, 0); } +void Assembler::eincq(Register dst, Address src, bool no_flags) { + // Don't use it directly. Use MacroAssembler::incrementq() instead. + InstructionMark im(this); + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_64bit); + evex_prefix_ndd(src, dst->encoding(), 0, VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int8((unsigned char) 0xFF); + emit_operand(rax, src, 0); +} + void Assembler::lea(Register dst, Address src) { leaq(dst, src); } @@ -13967,6 +14959,13 @@ void Assembler::lzcntq(Register dst, Register src) { emit_opcode_prefix_and_encoding((unsigned char)0xBD, 0xC0, encode); } +void Assembler::elzcntq(Register dst, Register src, bool no_flags) { + assert(VM_Version::supports_lzcnt(), "encoding is treated as BSR"); + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = evex_prefix_and_encode_nf(dst->encoding(), 0, src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int16((unsigned char)0xF5, (0xC0 | encode)); +} + void Assembler::lzcntq(Register dst, Address src) { assert(VM_Version::supports_lzcnt(), "encoding is treated as BSR"); InstructionMark im(this); @@ -13976,6 +14975,16 @@ void Assembler::lzcntq(Register dst, Address src) { emit_operand(dst, src, 0); } +void Assembler::elzcntq(Register dst, Address src, bool no_flags) { + assert(VM_Version::supports_lzcnt(), "encoding is treated as BSR"); + InstructionMark im(this); + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_64bit); + evex_prefix_nf(src, 0, dst->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int8((unsigned char)0xF5); + emit_operand(dst, src, 0); +} + void Assembler::movdq(XMMRegister dst, Register src) { // table D-1 says MMX/SSE2 NOT_LP64(assert(VM_Version::supports_sse2(), "")); @@ -14098,11 +15107,26 @@ void Assembler::mulq(Address src) { emit_operand(rsp, src, 0); } +void Assembler::emulq(Address src, bool no_flags) { + InstructionMark im(this); + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_64bit); + evex_prefix_nf(src, 0, 0, VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int8(0xF7); + emit_operand(rsp, src, 0); +} + void Assembler::mulq(Register src) { int encode = prefixq_and_encode(src->encoding()); emit_int16((unsigned char)0xF7, (0xE0 | encode)); } +void Assembler::emulq(Register src, bool no_flags) { + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = evex_prefix_and_encode_nf(0, 0, src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int16((unsigned char)0xF7, (0xE0 | encode)); +} + void Assembler::mulxq(Register dst1, Register dst2, Register src) { assert(VM_Version::supports_bmi2(), "bit manipulation instructions not supported"); InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); @@ -14115,17 +15139,38 @@ void Assembler::negq(Register dst) { emit_int16((unsigned char)0xF7, (0xD8 | encode)); } +void Assembler::enegq(Register dst, Register src, bool no_flags) { + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = evex_prefix_and_encode_ndd(0, dst->encoding(), src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int16((unsigned char)0xF7, (0xD8 | encode)); +} + void Assembler::negq(Address dst) { InstructionMark im(this); emit_prefix_and_int8(get_prefixq(dst), (unsigned char)0xF7); emit_operand(as_Register(3), dst, 0); } +void Assembler::enegq(Register dst, Address src, bool no_flags) { + InstructionMark im(this); + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_64bit); + evex_prefix_ndd(src, dst->encoding(), 0, VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int8((unsigned char)0xF7); + emit_operand(as_Register(3), src, 0); +} + void Assembler::notq(Register dst) { int encode = prefixq_and_encode(dst->encoding()); emit_int16((unsigned char)0xF7, (0xD0 | encode)); } +void Assembler::enotq(Register dst, Register src) { + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = evex_prefix_and_encode_ndd(0, dst->encoding(), src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes); + emit_int16((unsigned char)0xF7, (0xD0 | encode)); +} + void Assembler::btq(Register dst, Register src) { int encode = prefixq_and_encode(src->encoding(), dst->encoding(), true /* is_map1 */); emit_opcode_prefix_and_encoding((unsigned char)0xA3, 0xC0, encode); @@ -14162,33 +15207,78 @@ void Assembler::orq(Address dst, int32_t imm32) { emit_arith_operand(0x81, as_Register(1), dst, imm32); } +void Assembler::eorq(Register dst, Address src, int32_t imm32, bool no_flags) { + InstructionMark im(this); + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_64bit); + evex_prefix_ndd(src, dst->encoding(), 0, VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_arith_operand(0x81, as_Register(1), src, imm32); +} + void Assembler::orq(Address dst, Register src) { InstructionMark im(this); emit_prefix_and_int8(get_prefixq(dst, src), (unsigned char)0x09); emit_operand(src, dst, 0); } +void Assembler::eorq(Register dst, Address src1, Register src2, bool no_flags) { + InstructionMark im(this); + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_64bit); + evex_prefix_ndd(src1, dst->encoding(), src2->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int8(0x09); + emit_operand(src2, src1, 0); +} + void Assembler::orq(Register dst, int32_t imm32) { (void) prefixq_and_encode(dst->encoding()); emit_arith(0x81, 0xC8, dst, imm32); } +void Assembler::eorq(Register dst, Register src, int32_t imm32, bool no_flags) { + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + evex_prefix_and_encode_ndd(0, dst->encoding(), src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_arith(0x81, 0xC8, src, imm32); +} + void Assembler::orq_imm32(Register dst, int32_t imm32) { (void) prefixq_and_encode(dst->encoding()); emit_arith_imm32(0x81, 0xC8, dst, imm32); } +void Assembler::eorq_imm32(Register dst, Register src, int32_t imm32, bool no_flags) { + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + (void) evex_prefix_and_encode_ndd(0, dst->encoding(), src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_arith_imm32(0x81, 0xC8, src, imm32); +} + void Assembler::orq(Register dst, Address src) { InstructionMark im(this); emit_prefix_and_int8(get_prefixq(src, dst), 0x0B); emit_operand(dst, src, 0); } +void Assembler::eorq(Register dst, Register src1, Address src2, bool no_flags) { + InstructionMark im(this); + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_64bit); + evex_prefix_ndd(src2, dst->encoding(), src1->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int8(0x0B); + emit_operand(src1, src2, 0); +} + void Assembler::orq(Register dst, Register src) { (void) prefixq_and_encode(dst->encoding(), src->encoding()); emit_arith(0x0B, 0xC0, dst, src); } +void Assembler::eorq(Register dst, Register src1, Register src2, bool no_flags) { + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + (void) evex_prefix_and_encode_ndd(src1->encoding(), dst->encoding(), src2->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + // opcode matches gcc + emit_arith(0x09, 0xC0, src1, src2); +} + void Assembler::popcntq(Register dst, Address src) { assert(VM_Version::supports_popcnt(), "must support"); InstructionMark im(this); @@ -14197,6 +15287,16 @@ void Assembler::popcntq(Register dst, Address src) { emit_operand(dst, src, 0); } +void Assembler::epopcntq(Register dst, Address src, bool no_flags) { + assert(VM_Version::supports_popcnt(), "must support"); + InstructionMark im(this); + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_64bit); + evex_prefix_nf(src, 0, dst->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int8((unsigned char) 0x88); + emit_operand(dst, src, 0); +} + void Assembler::popcntq(Register dst, Register src) { assert(VM_Version::supports_popcnt(), "must support"); emit_int8((unsigned char)0xF3); @@ -14204,6 +15304,13 @@ void Assembler::popcntq(Register dst, Register src) { emit_opcode_prefix_and_encoding((unsigned char)0xB8, 0xC0, encode); } +void Assembler::epopcntq(Register dst, Register src, bool no_flags) { + assert(VM_Version::supports_popcnt(), "must support"); + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = evex_prefix_and_encode_nf(dst->encoding(), 0, src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int16((unsigned char)0x88, (0xC0 | encode)); +} + void Assembler::popq(Address dst) { InstructionMark im(this); emit_prefix_and_int8(get_prefixq(dst), (unsigned char)0x8F); @@ -14422,6 +15529,17 @@ void Assembler::rclq(Register dst, int imm8) { } } +void Assembler::erclq(Register dst, Register src, int imm8) { + assert(isShiftCount(imm8 >> 1), "illegal shift count"); + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = evex_prefix_and_encode_ndd(0, dst->encoding(), src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes); + if (imm8 == 1) { + emit_int16((unsigned char)0xD1, (0xD0 | encode)); + } else { + emit_int24((unsigned char)0xC1, (0xD0 | encode), imm8); + } +} + void Assembler::rcrq(Register dst, int imm8) { assert(isShiftCount(imm8 >> 1), "illegal shift count"); int encode = prefixq_and_encode(dst->encoding()); @@ -14432,6 +15550,17 @@ void Assembler::rcrq(Register dst, int imm8) { } } +void Assembler::ercrq(Register dst, Register src, int imm8) { + assert(isShiftCount(imm8 >> 1), "illegal shift count"); + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = evex_prefix_and_encode_ndd(0, dst->encoding(), src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes); + if (imm8 == 1) { + emit_int16((unsigned char)0xD1, (0xD8 | encode)); + } else { + emit_int24((unsigned char)0xC1, (0xD8 | encode), imm8); + } +} + void Assembler::rorxl(Register dst, Register src, int imm8) { assert(VM_Version::supports_bmi2(), "bit manipulation instructions not supported"); InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); @@ -14483,12 +15612,38 @@ void Assembler::salq(Address dst, int imm8) { } } +void Assembler::esalq(Register dst, Address src, int imm8, bool no_flags) { + InstructionMark im(this); + assert(isShiftCount(imm8 >> 1), "illegal shift count"); + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_64bit); + evex_prefix_ndd(src, dst->encoding(), 0, VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + if (imm8 == 1) { + emit_int8((unsigned char)0xD1); + emit_operand(as_Register(4), src, 0); + } + else { + emit_int8((unsigned char)0xC1); + emit_operand(as_Register(4), src, 1); + emit_int8(imm8); + } +} + void Assembler::salq(Address dst) { InstructionMark im(this); emit_prefix_and_int8(get_prefixq(dst), (unsigned char)0xD3); emit_operand(as_Register(4), dst, 0); } +void Assembler::esalq(Register dst, Address src, bool no_flags) { + InstructionMark im(this); + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_64bit); + evex_prefix_ndd(src, dst->encoding(), 0, VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int8((unsigned char)0xD3); + emit_operand(as_Register(4), src, 0); +} + void Assembler::salq(Register dst, int imm8) { assert(isShiftCount(imm8 >> 1), "illegal shift count"); int encode = prefixq_and_encode(dst->encoding()); @@ -14499,11 +15654,28 @@ void Assembler::salq(Register dst, int imm8) { } } +void Assembler::esalq(Register dst, Register src, int imm8, bool no_flags) { + assert(isShiftCount(imm8 >> 1), "illegal shift count"); + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = evex_prefix_and_encode_ndd(0, dst->encoding(), src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + if (imm8 == 1) { + emit_int16((unsigned char)0xD1, (0xE0 | encode)); + } else { + emit_int24((unsigned char)0xC1, (0xE0 | encode), imm8); + } +} + void Assembler::salq(Register dst) { int encode = prefixq_and_encode(dst->encoding()); emit_int16((unsigned char)0xD3, (0xE0 | encode)); } +void Assembler::esalq(Register dst, Register src, bool no_flags) { + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = evex_prefix_and_encode_ndd(0, dst->encoding(), src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int16((unsigned char)0xD3, (0xE0 | encode)); +} + void Assembler::sarq(Address dst, int imm8) { InstructionMark im(this); assert(isShiftCount(imm8 >> 1), "illegal shift count"); @@ -14518,12 +15690,38 @@ void Assembler::sarq(Address dst, int imm8) { } } +void Assembler::esarq(Register dst, Address src, int imm8, bool no_flags) { + assert(isShiftCount(imm8 >> 1), "illegal shift count"); + InstructionMark im(this); + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_64bit); + evex_prefix_ndd(src, dst->encoding(), 0, VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + if (imm8 == 1) { + emit_int8((unsigned char)0xD1); + emit_operand(as_Register(7), src, 0); + } + else { + emit_int8((unsigned char)0xC1); + emit_operand(as_Register(7), src, 1); + emit_int8(imm8); + } +} + void Assembler::sarq(Address dst) { InstructionMark im(this); emit_prefix_and_int8(get_prefixq(dst), (unsigned char)0xD3); emit_operand(as_Register(7), dst, 0); } +void Assembler::esarq(Register dst, Address src, bool no_flags) { + InstructionMark im(this); + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_64bit); + evex_prefix_ndd(src, dst->encoding(), 0, VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int8((unsigned char)0xD3); + emit_operand(as_Register(7), src, 0); +} + void Assembler::sarq(Register dst, int imm8) { assert(isShiftCount(imm8 >> 1), "illegal shift count"); int encode = prefixq_and_encode(dst->encoding()); @@ -14534,10 +15732,26 @@ void Assembler::sarq(Register dst, int imm8) { } } +void Assembler::esarq(Register dst, Register src, int imm8, bool no_flags) { + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = evex_prefix_and_encode_ndd(0, dst->encoding(), src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + if (imm8 == 1) { + emit_int16((unsigned char)0xD1, (0xF8 | encode)); + } else { + emit_int24((unsigned char)0xC1, (0xF8 | encode), imm8); + } +} + void Assembler::sarq(Register dst) { int encode = prefixq_and_encode(dst->encoding()); emit_int16((unsigned char)0xD3, (0xF8 | encode)); } + +void Assembler::esarq(Register dst, Register src, bool no_flags) { + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = evex_prefix_and_encode_ndd(0, dst->encoding(), src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int16((unsigned char)0xD3, (0xF8 | encode)); +} #endif void Assembler::sbbq(Address dst, int32_t imm32) { @@ -14572,11 +15786,28 @@ void Assembler::shlq(Register dst, int imm8) { } } +void Assembler::eshlq(Register dst, Register src, int imm8, bool no_flags) { + assert(isShiftCount(imm8 >> 1), "illegal shift count"); + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = evex_prefix_and_encode_ndd(0, dst->encoding(), src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + if (imm8 == 1 ) { + emit_int16((unsigned char)0xD1, (0xE0 | encode)); + } else { + emit_int24((unsigned char)0xC1, (0xE0 | encode), imm8); + } +} + void Assembler::shlq(Register dst) { int encode = prefixq_and_encode(dst->encoding()); emit_int16((unsigned char)0xD3, (0xE0 | encode)); } +void Assembler::eshlq(Register dst, Register src, bool no_flags) { + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = evex_prefix_and_encode_ndd(0, dst->encoding(), src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int16((unsigned char)0xD3, (0xE0 | encode)); +} + void Assembler::shrq(Register dst, int imm8) { assert(isShiftCount(imm8 >> 1), "illegal shift count"); int encode = prefixq_and_encode(dst->encoding()); @@ -14588,17 +15819,44 @@ void Assembler::shrq(Register dst, int imm8) { } } +void Assembler::eshrq(Register dst, Register src, int imm8, bool no_flags) { + assert(isShiftCount(imm8 >> 1), "illegal shift count"); + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = evex_prefix_and_encode_ndd(0, dst->encoding(), src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + if (imm8 == 1) { + emit_int16((unsigned char)0xD1, (0xE8 | encode)); + } + else { + emit_int24((unsigned char)0xC1, (0xE8 | encode), imm8); + } +} + void Assembler::shrq(Register dst) { int encode = prefixq_and_encode(dst->encoding()); emit_int16((unsigned char)0xD3, 0xE8 | encode); } +void Assembler::eshrq(Register dst, Register src, bool no_flags) { + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = evex_prefix_and_encode_ndd(0, dst->encoding(), src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int16((unsigned char)0xD3, (0xE8 | encode)); +} + void Assembler::shrq(Address dst) { InstructionMark im(this); emit_prefix_and_int8(get_prefixq(dst), (unsigned char)0xD3); emit_operand(as_Register(5), dst, 0); } +void Assembler::eshrq(Register dst, Address src, bool no_flags) { + InstructionMark im(this); + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_64bit); + evex_prefix_ndd(src, dst->encoding(), 0, VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int8((unsigned char)0xD3); + emit_operand(as_Register(5), src, 0); +} + void Assembler::shrq(Address dst, int imm8) { InstructionMark im(this); assert(isShiftCount(imm8 >> 1), "illegal shift count"); @@ -14613,40 +15871,102 @@ void Assembler::shrq(Address dst, int imm8) { } } +void Assembler::eshrq(Register dst, Address src, int imm8, bool no_flags) { + InstructionMark im(this); + assert(isShiftCount(imm8 >> 1), "illegal shift count"); + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_64bit); + evex_prefix_ndd(src, dst->encoding(), 0, VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + if (imm8 == 1) { + emit_int8((unsigned char)0xD1); + emit_operand(as_Register(5), src, 0); + } + else { + emit_int8((unsigned char)0xC1); + emit_operand(as_Register(5), src, 1); + emit_int8(imm8); + } +} + void Assembler::subq(Address dst, int32_t imm32) { InstructionMark im(this); prefixq(dst); emit_arith_operand(0x81, rbp, dst, imm32); } +void Assembler::esubq(Register dst, Address src, int32_t imm32, bool no_flags) { + InstructionMark im(this); + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_64bit); + evex_prefix_ndd(src, dst->encoding(), 0, VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_arith_operand(0x81, rbp, src, imm32); +} + void Assembler::subq(Address dst, Register src) { InstructionMark im(this); emit_prefix_and_int8(get_prefixq(dst, src), 0x29); emit_operand(src, dst, 0); } +void Assembler::esubq(Register dst, Address src1, Register src2, bool no_flags) { + InstructionMark im(this); + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_64bit); + evex_prefix_ndd(src1, dst->encoding(), src2->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int8(0x29); + emit_operand(src2, src1, 0); +} + void Assembler::subq(Register dst, int32_t imm32) { (void) prefixq_and_encode(dst->encoding()); emit_arith(0x81, 0xE8, dst, imm32); } +void Assembler::esubq(Register dst, Register src, int32_t imm32, bool no_flags) { + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + (void) evex_prefix_and_encode_ndd(0, dst->encoding(), src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_arith(0x81, 0xE8, src, imm32); +} + // Force generation of a 4 byte immediate value even if it fits into 8bit void Assembler::subq_imm32(Register dst, int32_t imm32) { (void) prefixq_and_encode(dst->encoding()); emit_arith_imm32(0x81, 0xE8, dst, imm32); } +void Assembler::esubq_imm32(Register dst, Register src, int32_t imm32, bool no_flags) { + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + (void) evex_prefix_and_encode_ndd(0, dst->encoding(), src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_arith_imm32(0x81, 0xE8, src, imm32); +} + void Assembler::subq(Register dst, Address src) { InstructionMark im(this); emit_prefix_and_int8(get_prefixq(src, dst), 0x2B); emit_operand(dst, src, 0); } +void Assembler::esubq(Register dst, Register src1, Address src2, bool no_flags) { + InstructionMark im(this); + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_64bit); + evex_prefix_ndd(src2, dst->encoding(), src1->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int8(0x2B); + emit_operand(src1, src2, 0); +} + void Assembler::subq(Register dst, Register src) { (void) prefixq_and_encode(dst->encoding(), src->encoding()); emit_arith(0x2B, 0xC0, dst, src); } +void Assembler::esubq(Register dst, Register src1, Register src2, bool no_flags) { + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + (void) evex_prefix_and_encode_ndd(src1->encoding(), dst->encoding(), src2->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + // opcode matches gcc + emit_arith(0x29, 0xC0, src1, src2); +} + void Assembler::testq(Address dst, int32_t imm32) { InstructionMark im(this); emit_prefix_and_int8(get_prefixq(dst), (unsigned char)0xF7); @@ -14704,29 +16024,77 @@ void Assembler::xorq(Register dst, Register src) { emit_arith(0x33, 0xC0, dst, src); } +void Assembler::exorq(Register dst, Register src1, Register src2, bool no_flags) { + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + (void) evex_prefix_and_encode_ndd(src1->encoding(), dst->encoding(), src2->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + // opcode matches gcc + emit_arith(0x31, 0xC0, src1, src2); +} + void Assembler::xorq(Register dst, Address src) { InstructionMark im(this); emit_prefix_and_int8(get_prefixq(src, dst), 0x33); emit_operand(dst, src, 0); } +void Assembler::exorq(Register dst, Register src1, Address src2, bool no_flags) { + InstructionMark im(this); + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_64bit); + evex_prefix_ndd(src2, dst->encoding(), src1->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int8(0x33); + emit_operand(src1, src2, 0); +} + void Assembler::xorq(Register dst, int32_t imm32) { (void) prefixq_and_encode(dst->encoding()); emit_arith(0x81, 0xF0, dst, imm32); } +void Assembler::exorq(Register dst, Register src, int32_t imm32, bool no_flags) { + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + evex_prefix_and_encode_ndd(0, dst->encoding(), src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_arith(0x81, 0xF0, src, imm32); +} + void Assembler::xorq(Address dst, int32_t imm32) { InstructionMark im(this); prefixq(dst); emit_arith_operand(0x81, as_Register(6), dst, imm32); } +void Assembler::exorq(Register dst, Address src, int32_t imm32, bool no_flags) { + InstructionMark im(this); + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_64bit); + evex_prefix_ndd(src, dst->encoding(), 0, VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_arith_operand(0x81, as_Register(6), src, imm32); +} + void Assembler::xorq(Address dst, Register src) { InstructionMark im(this); emit_prefix_and_int8(get_prefixq(dst, src), 0x31); emit_operand(src, dst, 0); } +void Assembler::esetzucc(Condition cc, Register dst) { + assert(VM_Version::supports_apx_f(), ""); + assert(0 <= cc && cc < 16, "illegal cc"); + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + // Encoding Format : eevex_prefix (4 bytes) | opcode_cc | modrm + int encode = evex_prefix_and_encode_ndd(0, 0, dst->encoding(), VEX_SIMD_F2, /* MAP4 */VEX_OPCODE_0F_3C, &attributes); + emit_opcode_prefix_and_encoding((0x40 | cc), 0xC0, encode); +} + +void Assembler::exorq(Register dst, Address src1, Register src2, bool no_flags) { + InstructionMark im(this); + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_NOSCALE, /* input_size_in_bits */ EVEX_64bit); + evex_prefix_ndd(src1, dst->encoding(), src2->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F_3C, &attributes, no_flags); + emit_int8(0x31); + emit_operand(src2, src1, 0); +} + #endif // !LP64 void InstructionAttr::set_address_attributes(int tuple_type, int input_size_in_bits) { diff --git a/src/hotspot/cpu/x86/assembler_x86.hpp b/src/hotspot/cpu/x86/assembler_x86.hpp index 28457b7005b..eace7bb9cc1 100644 --- a/src/hotspot/cpu/x86/assembler_x86.hpp +++ b/src/hotspot/cpu/x86/assembler_x86.hpp @@ -789,14 +789,26 @@ private: void vex_prefix(bool vex_r, bool vex_b, bool vex_x, int nds_enc, VexSimdPrefix pre, VexOpcode opc); void evex_prefix(bool vex_r, bool vex_b, bool vex_x, bool evex_v, bool evex_r, bool evex_b, - bool eevex_x, int nds_enc, VexSimdPrefix pre, VexOpcode opc); + bool eevex_x, int nds_enc, VexSimdPrefix pre, VexOpcode opc, bool no_flags = false); + + void evex_prefix_ndd(Address adr, int ndd_enc, int xreg_enc, VexSimdPrefix pre, VexOpcode opc, + InstructionAttr *attributes, bool no_flags = false); + + void evex_prefix_nf(Address adr, int ndd_enc, int xreg_enc, VexSimdPrefix pre, VexOpcode opc, + InstructionAttr *attributes, bool no_flags = false); void vex_prefix(Address adr, int nds_enc, int xreg_enc, VexSimdPrefix pre, VexOpcode opc, - InstructionAttr *attributes); + InstructionAttr *attributes, bool nds_is_ndd = false, bool no_flags = false); int vex_prefix_and_encode(int dst_enc, int nds_enc, int src_enc, VexSimdPrefix pre, VexOpcode opc, - InstructionAttr *attributes, bool src_is_gpr = false); + InstructionAttr *attributes, bool src_is_gpr = false, bool nds_is_ndd = false, bool no_flags = false); + + int evex_prefix_and_encode_ndd(int dst_enc, int nds_enc, int src_enc, VexSimdPrefix pre, VexOpcode opc, + InstructionAttr *attributes, bool no_flags = false); + + int evex_prefix_and_encode_nf(int dst_enc, int nds_enc, int src_enc, VexSimdPrefix pre, VexOpcode opc, + InstructionAttr *attributes, bool no_flags = false); void simd_prefix(XMMRegister xreg, XMMRegister nds, Address adr, VexSimdPrefix pre, VexOpcode opc, InstructionAttr *attributes); @@ -941,13 +953,20 @@ private: // the product flag UseIncDec value. void decl(Register dst); + void edecl(Register dst, Register src, bool no_flags); void decl(Address dst); + void edecl(Register dst, Address src, bool no_flags); void decq(Address dst); + void edecq(Register dst, Address src, bool no_flags); void incl(Register dst); + void eincl(Register dst, Register src, bool no_flags); void incl(Address dst); + void eincl(Register dst, Address src, bool no_flags); void incq(Register dst); + void eincq(Register dst, Register src, bool no_flags); void incq(Address dst); + void eincq(Register dst, Address src, bool no_flags); // New cpus require use of movsd and movss to avoid partial register stall // when loading from memory. But for old Opteron use movlpd instead of movsd. @@ -1020,7 +1039,7 @@ private: void pusha_uncached(); void popa_uncached(); - // APX ISA extensions for register save/restore optimizations. + // APX ISA Extensions for register save/restore optimizations. void push2(Register src1, Register src2, bool with_ppx = false); void pop2(Register src1, Register src2, bool with_ppx = false); void push2p(Register src1, Register src2); @@ -1028,9 +1047,13 @@ private: void pushp(Register src); void popp(Register src); + // New Zero Upper setcc instruction. + void esetzucc(Condition cc, Register dst); + #endif void vzeroupper_uncached(); void decq(Register dst); + void edecq(Register dst, Register src, bool no_flags); void pusha(); void popa(); @@ -1068,28 +1091,39 @@ private: void addb(Address dst, int imm8); void addb(Address dst, Register src); void addb(Register dst, int imm8); - void addw(Register dst, Register src); void addw(Address dst, int imm16); void addw(Address dst, Register src); void addl(Address dst, int32_t imm32); + void eaddl(Register dst, Address src, int32_t imm32, bool no_flags); void addl(Address dst, Register src); + void eaddl(Register dst, Address src1, Register src2, bool no_flags); void addl(Register dst, int32_t imm32); + void eaddl(Register dst, Register src, int32_t imm32, bool no_flags); void addl(Register dst, Address src); + void eaddl(Register dst, Register src1, Address src2, bool no_flags); void addl(Register dst, Register src); + void eaddl(Register dst, Register src1, Register src2, bool no_flags); void addq(Address dst, int32_t imm32); + void eaddq(Register dst, Address src, int32_t imm32, bool no_flags); void addq(Address dst, Register src); + void eaddq(Register dst, Address src1, Register src2, bool no_flags); void addq(Register dst, int32_t imm32); + void eaddq(Register dst, Register src, int32_t imm32, bool no_flags); void addq(Register dst, Address src); + void eaddq(Register dst, Register src1, Address src2, bool no_flags); void addq(Register dst, Register src); + void eaddq(Register dst, Register src1, Register src2, bool no_flags); #ifdef _LP64 //Add Unsigned Integers with Carry Flag void adcxq(Register dst, Register src); + void eadcxq(Register dst, Register src1, Register src2); //Add Unsigned Integers with Overflow Flag void adoxq(Register dst, Register src); + void eadoxq(Register dst, Register src1, Register src2); #endif void addr_nop_4(); @@ -1120,20 +1154,28 @@ private: void vaesdec(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len); void vaesdeclast(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len); - void andw(Register dst, Register src); void andb(Address dst, Register src); void andl(Address dst, int32_t imm32); + void eandl(Register dst, Address src, int32_t imm32, bool no_flags); void andl(Register dst, int32_t imm32); + void eandl(Register dst, Register src, int32_t imm32, bool no_flags); void andl(Register dst, Address src); + void eandl(Register dst, Register src1, Address src2, bool no_flags); void andl(Register dst, Register src); + void eandl(Register dst, Register src1, Register src2, bool no_flags); void andl(Address dst, Register src); void andq(Address dst, int32_t imm32); + void eandq(Register dst, Address src, int32_t imm32, bool no_flags); void andq(Register dst, int32_t imm32); + void eandq(Register dst, Register src, int32_t imm32, bool no_flags); void andq(Register dst, Address src); + void eandq(Register dst, Register src1, Address src2, bool no_flags); void andq(Register dst, Register src); + void eandq(Register dst, Register src1, Register src2, bool no_flags); void andq(Address dst, Register src); + void eandq(Register dst, Address src1, Register src2, bool no_flags); // BMI instructions void andnl(Register dst, Register src1, Register src2); @@ -1184,15 +1226,20 @@ private: void clwb(Address adr); void cmovl(Condition cc, Register dst, Register src); + void ecmovl(Condition cc, Register dst, Register src1, Register src2); void cmovl(Condition cc, Register dst, Address src); + void ecmovl(Condition cc, Register dst, Register src1, Address src2); void cmovq(Condition cc, Register dst, Register src); + void ecmovq(Condition cc, Register dst, Register src1, Register src2); void cmovq(Condition cc, Register dst, Address src); + void ecmovq(Condition cc, Register dst, Register src1, Address src2); void cmpb(Address dst, int imm8); void cmpb(Address dst, Register reg); void cmpb(Register reg, Address dst); + void cmpb(Register reg, int imm8); void cmpl(Address dst, int32_t imm32); void cmpl(Register dst, int32_t imm32); @@ -1490,25 +1537,41 @@ private: void hlt(); void idivl(Register src); + void eidivl(Register src, bool no_flags); void divl(Register src); // Unsigned division + void edivl(Register src, bool no_flags); // Unsigned division #ifdef _LP64 void idivq(Register src); + void eidivq(Register src, bool no_flags); void divq(Register src); // Unsigned division + void edivq(Register src, bool no_flags); // Unsigned division #endif void imull(Register src); + void eimull(Register src, bool no_flags); void imull(Register dst, Register src); + void eimull(Register dst, Register src1, Register src2, bool no_flags); void imull(Register dst, Register src, int value); + void eimull(Register dst, Register src, int value, bool no_flags); void imull(Register dst, Address src, int value); + void eimull(Register dst, Address src, int value, bool no_flags); void imull(Register dst, Address src); + void eimull(Register dst, Register src1, Address src2, bool no_flags); #ifdef _LP64 void imulq(Register dst, Register src); + void eimulq(Register dst, Register src, bool no_flags); + void eimulq(Register dst, Register src1, Register src2, bool no_flags); void imulq(Register dst, Register src, int value); + void eimulq(Register dst, Register src, int value, bool no_flags); void imulq(Register dst, Address src, int value); + void eimulq(Register dst, Address src, int value, bool no_flags); void imulq(Register dst, Address src); + void eimulq(Register dst, Address src, bool no_flags); + void eimulq(Register dst, Register src1, Address src2, bool no_flags); void imulq(Register dst); + void eimulq(Register dst, bool no_flags); #endif // jcc is the generic conditional branch generator to run- @@ -1567,11 +1630,15 @@ private: void size_prefix(); void lzcntl(Register dst, Register src); + void elzcntl(Register dst, Register src, bool no_flags); void lzcntl(Register dst, Address src); + void elzcntl(Register dst, Address src, bool no_flags); #ifdef _LP64 void lzcntq(Register dst, Register src); + void elzcntq(Register dst, Register src, bool no_flags); void lzcntq(Register dst, Address src); + void elzcntq(Register dst, Address src, bool no_flags); #endif enum Membar_mask_bits { @@ -1787,11 +1854,15 @@ private: // Unsigned multiply with RAX destination register void mull(Address src); + void emull(Address src, bool no_flags); void mull(Register src); + void emull(Register src, bool no_flags); #ifdef _LP64 void mulq(Address src); + void emulq(Address src, bool no_flags); void mulq(Register src); + void emulq(Register src, bool no_flags); void mulxq(Register dst1, Register dst2, Register src); #endif @@ -1804,19 +1875,25 @@ private: void mulss(XMMRegister dst, XMMRegister src); void negl(Register dst); + void enegl(Register dst, Register src, bool no_flags); void negl(Address dst); + void enegl(Register dst, Address src, bool no_flags); #ifdef _LP64 void negq(Register dst); + void enegq(Register dst, Register src, bool no_flags); void negq(Address dst); + void enegq(Register dst, Address src, bool no_flags); #endif void nop(uint i = 1); void notl(Register dst); + void enotl(Register dst, Register src); #ifdef _LP64 void notq(Register dst); + void enotq(Register dst, Register src); void btsq(Address dst, int imm8); void btrq(Address dst, int imm8); @@ -1825,22 +1902,36 @@ private: void btq(Register dst, Register src); void orw(Register dst, Register src); + void eorw(Register dst, Register src1, Register src2, bool no_flags); void orl(Address dst, int32_t imm32); + void eorl(Register dst, Address src, int32_t imm32, bool no_flags); void orl(Register dst, int32_t imm32); + void eorl(Register dst, Register src, int32_t imm32, bool no_flags); void orl(Register dst, Address src); + void eorl(Register dst, Register src1, Address src2, bool no_flags); void orl(Register dst, Register src); + void eorl(Register dst, Register src1, Register src2, bool no_flags); void orl(Address dst, Register src); + void eorl(Register dst, Address src1, Register src2, bool no_flags); void orb(Address dst, int imm8); + void eorb(Register dst, Address src, int imm8, bool no_flags); void orb(Address dst, Register src); + void eorb(Register dst, Address src1, Register src2, bool no_flags); void orq(Address dst, int32_t imm32); + void eorq(Register dst, Address src, int32_t imm32, bool no_flags); void orq(Address dst, Register src); + void eorq(Register dst, Address src1, Register src2, bool no_flags); void orq(Register dst, int32_t imm32); + void eorq(Register dst, Register src, int32_t imm32, bool no_flags); void orq_imm32(Register dst, int32_t imm32); + void eorq_imm32(Register dst, Register src, int32_t imm32, bool no_flags); void orq(Register dst, Address src); + void eorq(Register dst, Register src1, Address src2, bool no_flags); void orq(Register dst, Register src); + void eorq(Register dst, Register src1, Register src2, bool no_flags); // Pack with signed saturation void packsswb(XMMRegister dst, XMMRegister src); @@ -2026,7 +2117,9 @@ private: #endif void popcntl(Register dst, Address src); + void epopcntl(Register dst, Address src, bool no_flags); void popcntl(Register dst, Register src); + void epopcntl(Register dst, Register src, bool no_flags); void evpopcntb(XMMRegister dst, KRegister mask, XMMRegister src, bool merge, int vector_len); void evpopcntw(XMMRegister dst, KRegister mask, XMMRegister src, bool merge, int vector_len); @@ -2035,7 +2128,9 @@ private: #ifdef _LP64 void popcntq(Register dst, Address src); + void epopcntq(Register dst, Address src, bool no_flags); void popcntq(Register dst, Register src); + void epopcntq(Register dst, Register src, bool no_flags); #endif // Prefetches (SSE, SSE2, 3DNOW only) @@ -2135,10 +2230,13 @@ private: void pushq(Address src); void rcll(Register dst, int imm8); + void ercll(Register dst, Register src, int imm8); void rclq(Register dst, int imm8); + void erclq(Register dst, Register src, int imm8); void rcrq(Register dst, int imm8); + void ercrq(Register dst, Register src, int imm8); void rcpps(XMMRegister dst, XMMRegister src); @@ -2149,18 +2247,26 @@ private: void ret(int imm16); void roll(Register dst); + void eroll(Register dst, Register src, bool no_flags); void roll(Register dst, int imm8); + void eroll(Register dst, Register src, int imm8, bool no_flags); void rorl(Register dst); + void erorl(Register dst, Register src, bool no_flags); void rorl(Register dst, int imm8); + void erorl(Register dst, Register src, int imm8, bool no_flags); #ifdef _LP64 void rolq(Register dst); + void erolq(Register dst, Register src, bool no_flags); void rolq(Register dst, int imm8); + void erolq(Register dst, Register src, int imm8, bool no_flags); void rorq(Register dst); + void erorq(Register dst, Register src, bool no_flags); void rorq(Register dst, int imm8); + void erorq(Register dst, Register src, int imm8, bool no_flags); void rorxl(Register dst, Register src, int imm8); void rorxl(Register dst, Address src, int imm8); void rorxq(Register dst, Register src, int imm8); @@ -2170,25 +2276,41 @@ private: void sahf(); void sall(Register dst, int imm8); + void esall(Register dst, Register src, int imm8, bool no_flags); void sall(Register dst); + void esall(Register dst, Register src, bool no_flags); void sall(Address dst, int imm8); + void esall(Register dst, Address src, int imm8, bool no_flags); void sall(Address dst); + void esall(Register dst, Address src, bool no_flags); void sarl(Address dst, int imm8); + void esarl(Register dst, Address src, int imm8, bool no_flags); void sarl(Address dst); + void esarl(Register dst, Address src, bool no_flags); void sarl(Register dst, int imm8); + void esarl(Register dst, Register src, int imm8, bool no_flags); void sarl(Register dst); + void esarl(Register dst, Register src, bool no_flags); #ifdef _LP64 void salq(Register dst, int imm8); + void esalq(Register dst, Register src, int imm8, bool no_flags); void salq(Register dst); + void esalq(Register dst, Register src, bool no_flags); void salq(Address dst, int imm8); + void esalq(Register dst, Address src, int imm8, bool no_flags); void salq(Address dst); + void esalq(Register dst, Address src, bool no_flags); void sarq(Address dst, int imm8); + void esarq(Register dst, Address src, int imm8, bool no_flags); void sarq(Address dst); + void esarq(Register dst, Address src, bool no_flags); void sarq(Register dst, int imm8); + void esarq(Register dst, Register src, int imm8, bool no_flags); void sarq(Register dst); + void esarq(Register dst, Register src, bool no_flags); #endif void sbbl(Address dst, int32_t imm32); @@ -2220,29 +2342,47 @@ private: void sha256msg2(XMMRegister dst, XMMRegister src); void shldl(Register dst, Register src); + void eshldl(Register dst, Register src1, Register src2, bool no_flags); void shldl(Register dst, Register src, int8_t imm8); + void eshldl(Register dst, Register src1, Register src2, int8_t imm8, bool no_flags); void shrdl(Register dst, Register src); + void eshrdl(Register dst, Register src1, Register src2, bool no_flags); void shrdl(Register dst, Register src, int8_t imm8); + void eshrdl(Register dst, Register src1, Register src2, int8_t imm8, bool no_flags); #ifdef _LP64 void shldq(Register dst, Register src, int8_t imm8); + void eshldq(Register dst, Register src1, Register src2, int8_t imm8, bool no_flags); void shrdq(Register dst, Register src, int8_t imm8); + void eshrdq(Register dst, Register src1, Register src2, int8_t imm8, bool no_flags); #endif void shll(Register dst, int imm8); + void eshll(Register dst, Register src, int imm8, bool no_flags); void shll(Register dst); + void eshll(Register dst, Register src, bool no_flags); void shlq(Register dst, int imm8); + void eshlq(Register dst, Register src, int imm8, bool no_flags); void shlq(Register dst); + void eshlq(Register dst, Register src, bool no_flags); void shrl(Register dst, int imm8); + void eshrl(Register dst, Register src, int imm8, bool no_flags); void shrl(Register dst); + void eshrl(Register dst, Register src, bool no_flags); void shrl(Address dst); + void eshrl(Register dst, Address src, bool no_flags); void shrl(Address dst, int imm8); + void eshrl(Register dst, Address src, int imm8, bool no_flags); void shrq(Register dst, int imm8); + void eshrq(Register dst, Register src, int imm8, bool no_flags); void shrq(Register dst); + void eshrq(Register dst, Register src, bool no_flags); void shrq(Address dst); + void eshrq(Register dst, Address src, bool no_flags); void shrq(Address dst, int imm8); + void eshrq(Register dst, Address src, int imm8, bool no_flags); void smovl(); // QQQ generic? @@ -2262,20 +2402,32 @@ private: void stmxcsr( Address dst ); void subl(Address dst, int32_t imm32); + void esubl(Register dst, Address src, int32_t imm32, bool no_flags); void subl(Address dst, Register src); + void esubl(Register dst, Address src1, Register src2, bool no_flags); void subl(Register dst, int32_t imm32); + void esubl(Register dst, Register src, int32_t imm32, bool no_flags); void subl(Register dst, Address src); + void esubl(Register dst, Register src1, Address src2, bool no_flags); void subl(Register dst, Register src); + void esubl(Register dst, Register src1, Register src2, bool no_flags); void subq(Address dst, int32_t imm32); + void esubq(Register dst, Address src, int32_t imm32, bool no_flags); void subq(Address dst, Register src); + void esubq(Register dst, Address src1, Register src2, bool no_flags); void subq(Register dst, int32_t imm32); + void esubq(Register dst, Register src, int32_t imm32, bool no_flags); void subq(Register dst, Address src); + void esubq(Register dst, Register src1, Address src2, bool no_flags); void subq(Register dst, Register src); + void esubq(Register dst, Register src1, Register src2, bool no_flags); // Force generation of a 4 byte immediate value even if it fits into 8bit void subl_imm32(Register dst, int32_t imm32); + void esubl_imm32(Register dst, Register src, int32_t imm32, bool no_flags); void subq_imm32(Register dst, int32_t imm32); + void esubq_imm32(Register dst, Register src, int32_t imm32, bool no_flags); // Subtract Scalar Double-Precision Floating-Point Values void subsd(XMMRegister dst, Address src); @@ -2300,9 +2452,13 @@ private: // BMI - count trailing zeros void tzcntl(Register dst, Register src); + void etzcntl(Register dst, Register src, bool no_flags); void tzcntl(Register dst, Address src); + void etzcntl(Register dst, Address src, bool no_flags); void tzcntq(Register dst, Register src); + void etzcntq(Register dst, Register src, bool no_flags); void tzcntq(Register dst, Address src); + void etzcntq(Register dst, Address src, bool no_flags); // Unordered Compare Scalar Double-Precision Floating-Point Values and set EFLAGS void ucomisd(XMMRegister dst, Address src); @@ -2335,21 +2491,33 @@ private: void xgetbv(); void xorl(Register dst, int32_t imm32); + void exorl(Register dst, Register src, int32_t imm32, bool no_flags); void xorl(Address dst, int32_t imm32); + void exorl(Register dst, Address src, int32_t imm32, bool no_flags); void xorl(Register dst, Address src); + void exorl(Register dst, Register src1, Address src2, bool no_flags); void xorl(Register dst, Register src); + void exorl(Register dst, Register src1, Register src2, bool no_flags); void xorl(Address dst, Register src); + void exorl(Register dst, Address src1, Register src2, bool no_flags); void xorb(Address dst, Register src); + void exorb(Register dst, Address src1, Register src2, bool no_flags); void xorb(Register dst, Address src); - void xorw(Register dst, Register src); + void exorb(Register dst, Register src1, Address src2, bool no_flags); void xorw(Register dst, Address src); + void exorw(Register dst, Register src1, Address src2, bool no_flags); void xorq(Register dst, Address src); + void exorq(Register dst, Register src1, Address src2, bool no_flags); void xorq(Address dst, int32_t imm32); + void exorq(Register dst, Address src, int32_t imm32, bool no_flags); void xorq(Register dst, Register src); + void exorq(Register dst, Register src1, Register src2, bool no_flags); void xorq(Register dst, int32_t imm32); + void exorq(Register dst, Register src, int32_t imm32, bool no_flags); void xorq(Address dst, Register src); + void exorq(Register dst, Address src1, Register src2, bool no_flags); // AVX 3-operands scalar instructions (encoded with VEX prefix) @@ -2464,6 +2632,7 @@ private: // Bitwise Logical AND of Packed Floating-Point Values void andpd(XMMRegister dst, XMMRegister src); + void andnpd(XMMRegister dst, XMMRegister src); void andps(XMMRegister dst, XMMRegister src); void vandpd(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len); void vandps(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len); @@ -2818,6 +2987,7 @@ private: void vinserti32x4(XMMRegister dst, XMMRegister nds, XMMRegister src, uint8_t imm8); void vinserti32x4(XMMRegister dst, XMMRegister nds, Address src, uint8_t imm8); void vinserti64x4(XMMRegister dst, XMMRegister nds, XMMRegister src, uint8_t imm8); + void evinserti64x2(XMMRegister dst, XMMRegister nds, XMMRegister src, uint8_t imm8, int vector_len); // vinsertf forms void vinsertf128(XMMRegister dst, XMMRegister nds, XMMRegister src, uint8_t imm8); @@ -2867,6 +3037,7 @@ private: void vbroadcastsd(XMMRegister dst, XMMRegister src, int vector_len); void vbroadcastsd(XMMRegister dst, Address src, int vector_len); void vbroadcastf128(XMMRegister dst, Address src, int vector_len); + void evbroadcastf64x2(XMMRegister dst, Address src, int vector_len); // gpr sourced byte/word/dword/qword replicate void evpbroadcastb(XMMRegister dst, Register src, int vector_len); diff --git a/src/hotspot/cpu/x86/c1_CodeStubs_x86.cpp b/src/hotspot/cpu/x86/c1_CodeStubs_x86.cpp index 7d89b148ba2..71ca9351f86 100644 --- a/src/hotspot/cpu/x86/c1_CodeStubs_x86.cpp +++ b/src/hotspot/cpu/x86/c1_CodeStubs_x86.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -110,7 +110,7 @@ void CounterOverflowStub::emit_code(LIR_Assembler* ce) { Metadata *m = _method->as_constant_ptr()->as_metadata(); ce->store_parameter(m, 1); ce->store_parameter(_bci, 0); - __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::counter_overflow_id))); + __ call(RuntimeAddress(Runtime1::entry_for(C1StubId::counter_overflow_id))); ce->add_call_info_here(_info); ce->verify_oop_map(_info); __ jmp(_continuation); @@ -119,7 +119,7 @@ void CounterOverflowStub::emit_code(LIR_Assembler* ce) { void RangeCheckStub::emit_code(LIR_Assembler* ce) { __ bind(_entry); if (_info->deoptimize_on_exception()) { - address a = Runtime1::entry_for(Runtime1::predicate_failed_trap_id); + address a = Runtime1::entry_for(C1StubId::predicate_failed_trap_id); __ call(RuntimeAddress(a)); ce->add_call_info_here(_info); ce->verify_oop_map(_info); @@ -133,11 +133,11 @@ void RangeCheckStub::emit_code(LIR_Assembler* ce) { } else { ce->store_parameter(_index->as_jint(), 0); } - Runtime1::StubID stub_id; + C1StubId stub_id; if (_throw_index_out_of_bounds_exception) { - stub_id = Runtime1::throw_index_exception_id; + stub_id = C1StubId::throw_index_exception_id; } else { - stub_id = Runtime1::throw_range_check_failed_id; + stub_id = C1StubId::throw_range_check_failed_id; ce->store_parameter(_array->as_pointer_register(), 1); } __ call(RuntimeAddress(Runtime1::entry_for(stub_id))); @@ -152,7 +152,7 @@ PredicateFailedStub::PredicateFailedStub(CodeEmitInfo* info) { void PredicateFailedStub::emit_code(LIR_Assembler* ce) { __ bind(_entry); - address a = Runtime1::entry_for(Runtime1::predicate_failed_trap_id); + address a = Runtime1::entry_for(C1StubId::predicate_failed_trap_id); __ call(RuntimeAddress(a)); ce->add_call_info_here(_info); ce->verify_oop_map(_info); @@ -164,7 +164,7 @@ void DivByZeroStub::emit_code(LIR_Assembler* ce) { ce->compilation()->implicit_exception_table()->append(_offset, __ offset()); } __ bind(_entry); - __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::throw_div0_exception_id))); + __ call(RuntimeAddress(Runtime1::entry_for(C1StubId::throw_div0_exception_id))); ce->add_call_info_here(_info); debug_only(__ should_not_reach_here()); } @@ -172,14 +172,14 @@ void DivByZeroStub::emit_code(LIR_Assembler* ce) { // Implementation of NewInstanceStub -NewInstanceStub::NewInstanceStub(LIR_Opr klass_reg, LIR_Opr result, ciInstanceKlass* klass, CodeEmitInfo* info, Runtime1::StubID stub_id) { +NewInstanceStub::NewInstanceStub(LIR_Opr klass_reg, LIR_Opr result, ciInstanceKlass* klass, CodeEmitInfo* info, C1StubId stub_id) { _result = result; _klass = klass; _klass_reg = klass_reg; _info = new CodeEmitInfo(info); - assert(stub_id == Runtime1::new_instance_id || - stub_id == Runtime1::fast_new_instance_id || - stub_id == Runtime1::fast_new_instance_init_check_id, + assert(stub_id == C1StubId::new_instance_id || + stub_id == C1StubId::fast_new_instance_id || + stub_id == C1StubId::fast_new_instance_init_check_id, "need new_instance id"); _stub_id = stub_id; } @@ -212,7 +212,7 @@ void NewTypeArrayStub::emit_code(LIR_Assembler* ce) { __ bind(_entry); assert(_length->as_register() == rbx, "length must in rbx,"); assert(_klass_reg->as_register() == rdx, "klass_reg must in rdx"); - __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::new_type_array_id))); + __ call(RuntimeAddress(Runtime1::entry_for(C1StubId::new_type_array_id))); ce->add_call_info_here(_info); ce->verify_oop_map(_info); assert(_result->as_register() == rax, "result must in rax,"); @@ -235,7 +235,7 @@ void NewObjectArrayStub::emit_code(LIR_Assembler* ce) { __ bind(_entry); assert(_length->as_register() == rbx, "length must in rbx,"); assert(_klass_reg->as_register() == rdx, "klass_reg must in rdx"); - __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::new_object_array_id))); + __ call(RuntimeAddress(Runtime1::entry_for(C1StubId::new_object_array_id))); ce->add_call_info_here(_info); ce->verify_oop_map(_info); assert(_result->as_register() == rax, "result must in rax,"); @@ -247,11 +247,11 @@ void MonitorEnterStub::emit_code(LIR_Assembler* ce) { __ bind(_entry); ce->store_parameter(_obj_reg->as_register(), 1); ce->store_parameter(_lock_reg->as_register(), 0); - Runtime1::StubID enter_id; + C1StubId enter_id; if (ce->compilation()->has_fpu_code()) { - enter_id = Runtime1::monitorenter_id; + enter_id = C1StubId::monitorenter_id; } else { - enter_id = Runtime1::monitorenter_nofpu_id; + enter_id = C1StubId::monitorenter_nofpu_id; } __ call(RuntimeAddress(Runtime1::entry_for(enter_id))); ce->add_call_info_here(_info); @@ -268,11 +268,11 @@ void MonitorExitStub::emit_code(LIR_Assembler* ce) { } ce->store_parameter(_lock_reg->as_register(), 0); // note: non-blocking leaf routine => no call info needed - Runtime1::StubID exit_id; + C1StubId exit_id; if (ce->compilation()->has_fpu_code()) { - exit_id = Runtime1::monitorexit_id; + exit_id = C1StubId::monitorexit_id; } else { - exit_id = Runtime1::monitorexit_nofpu_id; + exit_id = C1StubId::monitorexit_nofpu_id; } __ call(RuntimeAddress(Runtime1::entry_for(exit_id))); __ jmp(_continuation); @@ -407,10 +407,10 @@ void PatchingStub::emit_code(LIR_Assembler* ce) { address target = nullptr; relocInfo::relocType reloc_type = relocInfo::none; switch (_id) { - case access_field_id: target = Runtime1::entry_for(Runtime1::access_field_patching_id); break; - case load_klass_id: target = Runtime1::entry_for(Runtime1::load_klass_patching_id); reloc_type = relocInfo::metadata_type; break; - case load_mirror_id: target = Runtime1::entry_for(Runtime1::load_mirror_patching_id); reloc_type = relocInfo::oop_type; break; - case load_appendix_id: target = Runtime1::entry_for(Runtime1::load_appendix_patching_id); reloc_type = relocInfo::oop_type; break; + case access_field_id: target = Runtime1::entry_for(C1StubId::access_field_patching_id); break; + case load_klass_id: target = Runtime1::entry_for(C1StubId::load_klass_patching_id); reloc_type = relocInfo::metadata_type; break; + case load_mirror_id: target = Runtime1::entry_for(C1StubId::load_mirror_patching_id); reloc_type = relocInfo::oop_type; break; + case load_appendix_id: target = Runtime1::entry_for(C1StubId::load_appendix_patching_id); reloc_type = relocInfo::oop_type; break; default: ShouldNotReachHere(); } __ bind(call_patch); @@ -440,7 +440,7 @@ void PatchingStub::emit_code(LIR_Assembler* ce) { void DeoptimizeStub::emit_code(LIR_Assembler* ce) { __ bind(_entry); ce->store_parameter(_trap_request, 0); - __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::deoptimize_id))); + __ call(RuntimeAddress(Runtime1::entry_for(C1StubId::deoptimize_id))); ce->add_call_info_here(_info); DEBUG_ONLY(__ should_not_reach_here()); } @@ -450,9 +450,9 @@ void ImplicitNullCheckStub::emit_code(LIR_Assembler* ce) { address a; if (_info->deoptimize_on_exception()) { // Deoptimize, do not throw the exception, because it is probably wrong to do it here. - a = Runtime1::entry_for(Runtime1::predicate_failed_trap_id); + a = Runtime1::entry_for(C1StubId::predicate_failed_trap_id); } else { - a = Runtime1::entry_for(Runtime1::throw_null_pointer_exception_id); + a = Runtime1::entry_for(C1StubId::throw_null_pointer_exception_id); } ce->compilation()->implicit_exception_table()->append(_offset, __ offset()); diff --git a/src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp b/src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp index e2fde10b98d..6d9812c11ae 100644 --- a/src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp +++ b/src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp @@ -399,7 +399,7 @@ int LIR_Assembler::emit_exception_handler() { __ verify_not_null_oop(rax); // search an exception handler (rax: exception oop, rdx: throwing pc) - __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::handle_exception_from_callee_id))); + __ call(RuntimeAddress(Runtime1::entry_for(C1StubId::handle_exception_from_callee_id))); __ should_not_reach_here(); guarantee(code_offset() - offset <= exception_handler_size(), "overflow"); __ end_a_stub(); @@ -463,7 +463,7 @@ int LIR_Assembler::emit_unwind_handler() { // remove the activation and dispatch to the unwind handler __ remove_frame(initial_frame_size_in_bytes()); - __ jump(RuntimeAddress(Runtime1::entry_for(Runtime1::unwind_exception_id))); + __ jump(RuntimeAddress(Runtime1::entry_for(C1StubId::unwind_exception_id))); // Emit the slow path assembly if (stub != nullptr) { @@ -1566,7 +1566,7 @@ void LIR_Assembler::emit_opConvert(LIR_OpConvert* op) { // instruction sequence too long to inline it here { - __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::fpu2long_stub_id))); + __ call(RuntimeAddress(Runtime1::entry_for(C1StubId::fpu2long_stub_id))); } break; #endif // _LP64 @@ -1578,6 +1578,7 @@ void LIR_Assembler::emit_opConvert(LIR_OpConvert* op) { void LIR_Assembler::emit_alloc_obj(LIR_OpAllocObj* op) { if (op->init_check()) { add_debug_info_for_null_check_here(op->stub()->info()); + // init_state needs acquire, but x86 is TSO, and so we are already good. __ cmpb(Address(op->klass()->as_register(), InstanceKlass::init_state_offset()), InstanceKlass::fully_initialized); @@ -1781,7 +1782,7 @@ void LIR_Assembler::emit_typecheck_helper(LIR_OpTypeCheck *op, Label* success, L #else __ pushklass(k->constant_encoding(), noreg); #endif // _LP64 - __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::slow_subtype_check_id))); + __ call(RuntimeAddress(Runtime1::entry_for(C1StubId::slow_subtype_check_id))); __ pop(klass_RInfo); __ pop(klass_RInfo); // result is a boolean @@ -1795,7 +1796,7 @@ void LIR_Assembler::emit_typecheck_helper(LIR_OpTypeCheck *op, Label* success, L // call out-of-line instance of __ check_klass_subtype_slow_path(...): __ push(klass_RInfo); __ push(k_RInfo); - __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::slow_subtype_check_id))); + __ call(RuntimeAddress(Runtime1::entry_for(C1StubId::slow_subtype_check_id))); __ pop(klass_RInfo); __ pop(k_RInfo); // result is a boolean @@ -1874,7 +1875,7 @@ void LIR_Assembler::emit_opTypeCheck(LIR_OpTypeCheck* op) { // call out-of-line instance of __ check_klass_subtype_slow_path(...): __ push(klass_RInfo); __ push(k_RInfo); - __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::slow_subtype_check_id))); + __ call(RuntimeAddress(Runtime1::entry_for(C1StubId::slow_subtype_check_id))); __ pop(klass_RInfo); __ pop(k_RInfo); // result is a boolean @@ -2893,7 +2894,7 @@ void LIR_Assembler::throw_op(LIR_Opr exceptionPC, LIR_Opr exceptionOop, CodeEmit // exception object is not added to oop map by LinearScan // (LinearScan assumes that no oops are in fixed registers) info->add_register_oop(exceptionOop); - Runtime1::StubID unwind_id; + C1StubId unwind_id; // get current pc information // pc is only needed if the method has an exception handler, the unwind code does not need it. @@ -2905,9 +2906,9 @@ void LIR_Assembler::throw_op(LIR_Opr exceptionPC, LIR_Opr exceptionOop, CodeEmit __ verify_not_null_oop(rax); // search an exception handler (rax: exception oop, rdx: throwing pc) if (compilation()->has_fpu_code()) { - unwind_id = Runtime1::handle_exception_id; + unwind_id = C1StubId::handle_exception_id; } else { - unwind_id = Runtime1::handle_exception_nofpu_id; + unwind_id = C1StubId::handle_exception_nofpu_id; } __ call(RuntimeAddress(Runtime1::entry_for(unwind_id))); @@ -3262,7 +3263,7 @@ void LIR_Assembler::emit_arraycopy(LIR_OpArrayCopy* op) { __ push(src); __ push(dst); - __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::slow_subtype_check_id))); + __ call(RuntimeAddress(Runtime1::entry_for(C1StubId::slow_subtype_check_id))); __ pop(dst); __ pop(src); diff --git a/src/hotspot/cpu/x86/c1_LIRGenerator_x86.cpp b/src/hotspot/cpu/x86/c1_LIRGenerator_x86.cpp index d3add6975b4..36e2021138f 100644 --- a/src/hotspot/cpu/x86/c1_LIRGenerator_x86.cpp +++ b/src/hotspot/cpu/x86/c1_LIRGenerator_x86.cpp @@ -807,7 +807,11 @@ void LIRGenerator::do_MathIntrinsic(Intrinsic* x) { if (x->id() == vmIntrinsics::_dexp || x->id() == vmIntrinsics::_dlog || x->id() == vmIntrinsics::_dpow || x->id() == vmIntrinsics::_dcos || x->id() == vmIntrinsics::_dsin || x->id() == vmIntrinsics::_dtan || - x->id() == vmIntrinsics::_dlog10) { + x->id() == vmIntrinsics::_dlog10 +#ifdef _LP64 + || x->id() == vmIntrinsics::_dtanh +#endif + ) { do_LibmIntrinsic(x); return; } @@ -989,11 +993,17 @@ void LIRGenerator::do_LibmIntrinsic(Intrinsic* x) { break; case vmIntrinsics::_dtan: if (StubRoutines::dtan() != nullptr) { - __ call_runtime_leaf(StubRoutines::dtan(), getThreadTemp(), result_reg, cc->args()); + __ call_runtime_leaf(StubRoutines::dtan(), getThreadTemp(), result_reg, cc->args()); } else { __ call_runtime_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dtan), getThreadTemp(), result_reg, cc->args()); } break; + case vmIntrinsics::_dtanh: + assert(StubRoutines::dtanh() != nullptr, "tanh intrinsic not found"); + if (StubRoutines::dtanh() != nullptr) { + __ call_runtime_leaf(StubRoutines::dtanh(), getThreadTemp(), result_reg, cc->args()); + } + break; default: ShouldNotReachHere(); } #endif // _LP64 @@ -1430,7 +1440,7 @@ void LIRGenerator::do_NewMultiArray(NewMultiArray* x) { args->append(rank); args->append(varargs); LIR_Opr reg = result_register_for(x->type()); - __ call_runtime(Runtime1::entry_for(Runtime1::new_multi_array_id), + __ call_runtime(Runtime1::entry_for(C1StubId::new_multi_array_id), LIR_OprFact::illegalOpr, reg, args, info); @@ -1463,12 +1473,12 @@ void LIRGenerator::do_CheckCast(CheckCast* x) { CodeStub* stub; if (x->is_incompatible_class_change_check()) { assert(patching_info == nullptr, "can't patch this"); - stub = new SimpleExceptionStub(Runtime1::throw_incompatible_class_change_error_id, LIR_OprFact::illegalOpr, info_for_exception); + stub = new SimpleExceptionStub(C1StubId::throw_incompatible_class_change_error_id, LIR_OprFact::illegalOpr, info_for_exception); } else if (x->is_invokespecial_receiver_check()) { assert(patching_info == nullptr, "can't patch this"); stub = new DeoptimizeStub(info_for_exception, Deoptimization::Reason_class_check, Deoptimization::Action_none); } else { - stub = new SimpleExceptionStub(Runtime1::throw_class_cast_exception_id, obj.result(), info_for_exception); + stub = new SimpleExceptionStub(C1StubId::throw_class_cast_exception_id, obj.result(), info_for_exception); } LIR_Opr reg = rlock_result(x); LIR_Opr tmp3 = LIR_OprFact::illegalOpr; diff --git a/src/hotspot/cpu/x86/c1_MacroAssembler_x86.cpp b/src/hotspot/cpu/x86/c1_MacroAssembler_x86.cpp index 576592d05aa..bf5b90db5fc 100644 --- a/src/hotspot/cpu/x86/c1_MacroAssembler_x86.cpp +++ b/src/hotspot/cpu/x86/c1_MacroAssembler_x86.cpp @@ -58,8 +58,7 @@ int C1_MacroAssembler::lock_object(Register hdr, Register obj, Register disp_hdr if (DiagnoseSyncOnValueBasedClasses != 0) { load_klass(hdr, obj, rscratch1); - movl(hdr, Address(hdr, Klass::access_flags_offset())); - testl(hdr, JVM_ACC_IS_VALUE_BASED_CLASS); + testb(Address(hdr, Klass::misc_flags_offset()), KlassFlags::_misc_is_value_based_class); jcc(Assembler::notZero, slow_case); } @@ -272,7 +271,7 @@ void C1_MacroAssembler::initialize_object(Register obj, Register klass, Register if (CURRENT_ENV->dtrace_alloc_probes()) { assert(obj == rax, "must be"); - call(RuntimeAddress(Runtime1::entry_for(Runtime1::dtrace_object_alloc_id))); + call(RuntimeAddress(Runtime1::entry_for(C1StubId::dtrace_object_alloc_id))); } verify_oop(obj); @@ -310,7 +309,7 @@ void C1_MacroAssembler::allocate_array(Register obj, Register len, Register t1, if (CURRENT_ENV->dtrace_alloc_probes()) { assert(obj == rax, "must be"); - call(RuntimeAddress(Runtime1::entry_for(Runtime1::dtrace_object_alloc_id))); + call(RuntimeAddress(Runtime1::entry_for(C1StubId::dtrace_object_alloc_id))); } verify_oop(obj); diff --git a/src/hotspot/cpu/x86/c1_Runtime1_x86.cpp b/src/hotspot/cpu/x86/c1_Runtime1_x86.cpp index dc051127fea..1ccb06df489 100644 --- a/src/hotspot/cpu/x86/c1_Runtime1_x86.cpp +++ b/src/hotspot/cpu/x86/c1_Runtime1_x86.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -60,7 +60,7 @@ int StubAssembler::call_RT(Register oop_result1, Register metadata_result, addre #ifdef _LP64 // At a method handle call, the stack may not be properly aligned // when returning with an exception. - align_stack = (stub_id() == Runtime1::handle_exception_from_callee_id); + align_stack = (stub_id() == (int)C1StubId::handle_exception_from_callee_id); #endif #ifdef _LP64 @@ -124,10 +124,10 @@ int StubAssembler::call_RT(Register oop_result1, Register metadata_result, addre if (frame_size() == no_frame_size) { leave(); jump(RuntimeAddress(StubRoutines::forward_exception_entry())); - } else if (_stub_id == Runtime1::forward_exception_id) { + } else if (_stub_id == (int)C1StubId::forward_exception_id) { should_not_reach_here(); } else { - jump(RuntimeAddress(Runtime1::entry_for(Runtime1::forward_exception_id))); + jump(RuntimeAddress(Runtime1::entry_for(C1StubId::forward_exception_id))); } bind(L); } @@ -671,7 +671,7 @@ OopMapSet* Runtime1::generate_exception_throw(StubAssembler* sasm, address targe } -OopMapSet* Runtime1::generate_handle_exception(StubID id, StubAssembler *sasm) { +OopMapSet* Runtime1::generate_handle_exception(C1StubId id, StubAssembler *sasm) { __ block_comment("generate_handle_exception"); // incoming parameters @@ -684,7 +684,7 @@ OopMapSet* Runtime1::generate_handle_exception(StubID id, StubAssembler *sasm) { OopMapSet* oop_maps = new OopMapSet(); OopMap* oop_map = nullptr; switch (id) { - case forward_exception_id: + case C1StubId::forward_exception_id: // We're handling an exception in the context of a compiled frame. // The registers have been saved in the standard places. Perform // an exception lookup in the caller and dispatch to the handler @@ -703,12 +703,12 @@ OopMapSet* Runtime1::generate_handle_exception(StubID id, StubAssembler *sasm) { __ movptr(Address(thread, JavaThread::vm_result_offset()), NULL_WORD); __ movptr(Address(thread, JavaThread::vm_result_2_offset()), NULL_WORD); break; - case handle_exception_nofpu_id: - case handle_exception_id: + case C1StubId::handle_exception_nofpu_id: + case C1StubId::handle_exception_id: // At this point all registers MAY be live. - oop_map = save_live_registers(sasm, 1 /*thread*/, id != handle_exception_nofpu_id); + oop_map = save_live_registers(sasm, 1 /*thread*/, id != C1StubId::handle_exception_nofpu_id); break; - case handle_exception_from_callee_id: { + case C1StubId::handle_exception_from_callee_id: { // At this point all registers except exception oop (RAX) and // exception pc (RDX) are dead. const int frame_size = 2 /*BP, return address*/ NOT_LP64(+ 1 /*thread*/) WIN64_ONLY(+ frame::arg_reg_save_area_bytes / BytesPerWord); @@ -775,13 +775,13 @@ OopMapSet* Runtime1::generate_handle_exception(StubID id, StubAssembler *sasm) { __ movptr(Address(rbp, 1*BytesPerWord), rax); switch (id) { - case forward_exception_id: - case handle_exception_nofpu_id: - case handle_exception_id: + case C1StubId::forward_exception_id: + case C1StubId::handle_exception_nofpu_id: + case C1StubId::handle_exception_id: // Restore the registers that were saved at the beginning. - restore_live_registers(sasm, id != handle_exception_nofpu_id); + restore_live_registers(sasm, id != C1StubId::handle_exception_nofpu_id); break; - case handle_exception_from_callee_id: + case C1StubId::handle_exception_from_callee_id: // WIN64_ONLY: No need to add frame::arg_reg_save_area_bytes to SP // since we do a leave anyway. @@ -935,7 +935,7 @@ OopMapSet* Runtime1::generate_patching(StubAssembler* sasm, address target) { __ testptr(rax, rax); // have we deoptimized? __ jump_cc(Assembler::equal, - RuntimeAddress(Runtime1::entry_for(Runtime1::forward_exception_id))); + RuntimeAddress(Runtime1::entry_for(C1StubId::forward_exception_id))); // the deopt blob expects exceptions in the special fields of // JavaThread, so copy and clear pending exception. @@ -1007,7 +1007,7 @@ OopMapSet* Runtime1::generate_patching(StubAssembler* sasm, address target) { } -OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { +OopMapSet* Runtime1::generate_code_for(C1StubId id, StubAssembler* sasm) { // for better readability const bool must_gc_arguments = true; @@ -1019,7 +1019,7 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { // stub code & info for the different stubs OopMapSet* oop_maps = nullptr; switch (id) { - case forward_exception_id: + case C1StubId::forward_exception_id: { oop_maps = generate_handle_exception(id, sasm); __ leave(); @@ -1027,19 +1027,19 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case new_instance_id: - case fast_new_instance_id: - case fast_new_instance_init_check_id: + case C1StubId::new_instance_id: + case C1StubId::fast_new_instance_id: + case C1StubId::fast_new_instance_init_check_id: { Register klass = rdx; // Incoming Register obj = rax; // Result - if (id == new_instance_id) { + if (id == C1StubId::new_instance_id) { __ set_info("new_instance", dont_gc_arguments); - } else if (id == fast_new_instance_id) { + } else if (id == C1StubId::fast_new_instance_id) { __ set_info("fast new_instance", dont_gc_arguments); } else { - assert(id == fast_new_instance_init_check_id, "bad StubID"); + assert(id == C1StubId::fast_new_instance_init_check_id, "bad C1StubId"); __ set_info("fast new_instance init check", dont_gc_arguments); } @@ -1058,7 +1058,7 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { break; - case counter_overflow_id: + case C1StubId::counter_overflow_id: { Register bci = rax, method = rbx; __ enter(); @@ -1076,14 +1076,14 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case new_type_array_id: - case new_object_array_id: + case C1StubId::new_type_array_id: + case C1StubId::new_object_array_id: { Register length = rbx; // Incoming Register klass = rdx; // Incoming Register obj = rax; // Result - if (id == new_type_array_id) { + if (id == C1StubId::new_type_array_id) { __ set_info("new_type_array", dont_gc_arguments); } else { __ set_info("new_object_array", dont_gc_arguments); @@ -1096,7 +1096,7 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { Register t0 = obj; __ movl(t0, Address(klass, Klass::layout_helper_offset())); __ sarl(t0, Klass::_lh_array_tag_shift); - int tag = ((id == new_type_array_id) + int tag = ((id == C1StubId::new_type_array_id) ? Klass::_lh_array_tag_type_value : Klass::_lh_array_tag_obj_value); __ cmpl(t0, tag); @@ -1110,7 +1110,7 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { __ enter(); OopMap* map = save_live_registers(sasm, 3); int call_offset; - if (id == new_type_array_id) { + if (id == C1StubId::new_type_array_id) { call_offset = __ call_RT(obj, noreg, CAST_FROM_FN_PTR(address, new_type_array), klass, length); } else { call_offset = __ call_RT(obj, noreg, CAST_FROM_FN_PTR(address, new_object_array), klass, length); @@ -1128,7 +1128,7 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case new_multi_array_id: + case C1StubId::new_multi_array_id: { StubFrame f(sasm, "new_multi_array", dont_gc_arguments); // rax,: klass // rbx,: rank @@ -1145,7 +1145,7 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case register_finalizer_id: + case C1StubId::register_finalizer_id: { __ set_info("register_finalizer", dont_gc_arguments); @@ -1166,8 +1166,7 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { Label register_finalizer; Register t = rsi; __ load_klass(t, rax, rscratch1); - __ movl(t, Address(t, Klass::access_flags_offset())); - __ testl(t, JVM_ACC_HAS_FINALIZER); + __ testb(Address(t, Klass::misc_flags_offset()), KlassFlags::_misc_has_finalizer); __ jcc(Assembler::notZero, register_finalizer); __ ret(0); @@ -1186,44 +1185,44 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case throw_range_check_failed_id: + case C1StubId::throw_range_check_failed_id: { StubFrame f(sasm, "range_check_failed", dont_gc_arguments); oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_range_check_exception), true); } break; - case throw_index_exception_id: + case C1StubId::throw_index_exception_id: { StubFrame f(sasm, "index_range_check_failed", dont_gc_arguments); oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_index_exception), true); } break; - case throw_div0_exception_id: + case C1StubId::throw_div0_exception_id: { StubFrame f(sasm, "throw_div0_exception", dont_gc_arguments); oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_div0_exception), false); } break; - case throw_null_pointer_exception_id: + case C1StubId::throw_null_pointer_exception_id: { StubFrame f(sasm, "throw_null_pointer_exception", dont_gc_arguments); oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_null_pointer_exception), false); } break; - case handle_exception_nofpu_id: - case handle_exception_id: + case C1StubId::handle_exception_nofpu_id: + case C1StubId::handle_exception_id: { StubFrame f(sasm, "handle_exception", dont_gc_arguments); oop_maps = generate_handle_exception(id, sasm); } break; - case handle_exception_from_callee_id: + case C1StubId::handle_exception_from_callee_id: { StubFrame f(sasm, "handle_exception_from_callee", dont_gc_arguments); oop_maps = generate_handle_exception(id, sasm); } break; - case unwind_exception_id: + case C1StubId::unwind_exception_id: { __ set_info("unwind_exception", dont_gc_arguments); // note: no stubframe since we are about to leave the current // activation and we are calling a leaf VM function only. @@ -1231,7 +1230,7 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case throw_array_store_exception_id: + case C1StubId::throw_array_store_exception_id: { StubFrame f(sasm, "throw_array_store_exception", dont_gc_arguments); // tos + 0: link // + 1: return address @@ -1239,19 +1238,19 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case throw_class_cast_exception_id: + case C1StubId::throw_class_cast_exception_id: { StubFrame f(sasm, "throw_class_cast_exception", dont_gc_arguments); oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_class_cast_exception), true); } break; - case throw_incompatible_class_change_error_id: + case C1StubId::throw_incompatible_class_change_error_id: { StubFrame f(sasm, "throw_incompatible_class_cast_exception", dont_gc_arguments); oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_incompatible_class_change_error), false); } break; - case slow_subtype_check_id: + case C1StubId::slow_subtype_check_id: { // Typical calling sequence: // __ push(klass_RInfo); // object klass or other subclass @@ -1304,10 +1303,10 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case monitorenter_nofpu_id: + case C1StubId::monitorenter_nofpu_id: save_fpu_registers = false; // fall through - case monitorenter_id: + case C1StubId::monitorenter_id: { StubFrame f(sasm, "monitorenter", dont_gc_arguments); OopMap* map = save_live_registers(sasm, 3, save_fpu_registers); @@ -1325,10 +1324,10 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case monitorexit_nofpu_id: + case C1StubId::monitorexit_nofpu_id: save_fpu_registers = false; // fall through - case monitorexit_id: + case C1StubId::monitorexit_id: { StubFrame f(sasm, "monitorexit", dont_gc_arguments); OopMap* map = save_live_registers(sasm, 2, save_fpu_registers); @@ -1348,7 +1347,7 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case deoptimize_id: + case C1StubId::deoptimize_id: { StubFrame f(sasm, "deoptimize", dont_gc_arguments); const int num_rt_args = 2; // thread, trap_request @@ -1365,35 +1364,35 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case access_field_patching_id: + case C1StubId::access_field_patching_id: { StubFrame f(sasm, "access_field_patching", dont_gc_arguments); // we should set up register map oop_maps = generate_patching(sasm, CAST_FROM_FN_PTR(address, access_field_patching)); } break; - case load_klass_patching_id: + case C1StubId::load_klass_patching_id: { StubFrame f(sasm, "load_klass_patching", dont_gc_arguments); // we should set up register map oop_maps = generate_patching(sasm, CAST_FROM_FN_PTR(address, move_klass_patching)); } break; - case load_mirror_patching_id: + case C1StubId::load_mirror_patching_id: { StubFrame f(sasm, "load_mirror_patching", dont_gc_arguments); // we should set up register map oop_maps = generate_patching(sasm, CAST_FROM_FN_PTR(address, move_mirror_patching)); } break; - case load_appendix_patching_id: + case C1StubId::load_appendix_patching_id: { StubFrame f(sasm, "load_appendix_patching", dont_gc_arguments); // we should set up register map oop_maps = generate_patching(sasm, CAST_FROM_FN_PTR(address, move_appendix_patching)); } break; - case dtrace_object_alloc_id: + case C1StubId::dtrace_object_alloc_id: { // rax,: object StubFrame f(sasm, "dtrace_object_alloc", dont_gc_arguments); // we can't gc here so skip the oopmap but make sure that all @@ -1408,7 +1407,7 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case fpu2long_stub_id: + case C1StubId::fpu2long_stub_id: { #ifdef _LP64 Label done; @@ -1497,7 +1496,7 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { } break; - case predicate_failed_trap_id: + case C1StubId::predicate_failed_trap_id: { StubFrame f(sasm, "predicate_failed_trap", dont_gc_arguments); diff --git a/src/hotspot/cpu/x86/c2_CodeStubs_x86.cpp b/src/hotspot/cpu/x86/c2_CodeStubs_x86.cpp index 1990488d8a0..44f897529e7 100644 --- a/src/hotspot/cpu/x86/c2_CodeStubs_x86.cpp +++ b/src/hotspot/cpu/x86/c2_CodeStubs_x86.cpp @@ -80,8 +80,6 @@ int C2FastUnlockLightweightStub::max_size() const { void C2FastUnlockLightweightStub::emit(C2_MacroAssembler& masm) { assert(_t == rax, "must be"); - Label restore_held_monitor_count_and_slow_path; - { // Restore lock-stack and handle the unlock in runtime. __ bind(_push_and_slow_path); @@ -91,61 +89,9 @@ void C2FastUnlockLightweightStub::emit(C2_MacroAssembler& masm) { __ movptr(Address(_thread, _t), _obj); #endif __ addl(Address(_thread, JavaThread::lock_stack_top_offset()), oopSize); - } - - { // Restore held monitor count and slow path. - - __ bind(restore_held_monitor_count_and_slow_path); - __ bind(_slow_path); - // Restore held monitor count. - __ increment(Address(_thread, JavaThread::held_monitor_count_offset())); - // increment will always result in ZF = 0 (no overflows). + // addl will always result in ZF = 0 (no overflows). __ jmp(slow_path_continuation()); } - - { // Handle monitor medium path. - - __ bind(_check_successor); - - Label fix_zf_and_unlocked; - const Register monitor = _mark; - -#ifndef _LP64 - __ jmpb(restore_held_monitor_count_and_slow_path); -#else // _LP64 - const ByteSize monitor_tag = in_ByteSize(UseObjectMonitorTable ? 0 : checked_cast(markWord::monitor_value)); - const Address succ_address(monitor, ObjectMonitor::succ_offset() - monitor_tag); - const Address owner_address(monitor, ObjectMonitor::owner_offset() - monitor_tag); - - // successor null check. - __ cmpptr(succ_address, NULL_WORD); - __ jccb(Assembler::equal, restore_held_monitor_count_and_slow_path); - - // Release lock. - __ movptr(owner_address, NULL_WORD); - - // Fence. - // Instead of MFENCE we use a dummy locked add of 0 to the top-of-stack. - __ lock(); __ addl(Address(rsp, 0), 0); - - // Recheck successor. - __ cmpptr(succ_address, NULL_WORD); - // Observed a successor after the release -> fence we have handed off the monitor - __ jccb(Assembler::notEqual, fix_zf_and_unlocked); - - // Try to relock, if it fails the monitor has been handed over - // TODO: Caveat, this may fail due to deflation, which does - // not handle the monitor handoff. Currently only works - // due to the responsible thread. - __ xorptr(rax, rax); - __ lock(); __ cmpxchgptr(_thread, owner_address); - __ jccb (Assembler::equal, restore_held_monitor_count_and_slow_path); -#endif - - __ bind(fix_zf_and_unlocked); - __ xorl(rax, rax); - __ jmp(unlocked_continuation()); - } } #undef __ diff --git a/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp b/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp index 5dbfdbc225d..aba5344b7e4 100644 --- a/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp +++ b/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp @@ -277,8 +277,7 @@ void C2_MacroAssembler::fast_lock(Register objReg, Register boxReg, Register tmp if (DiagnoseSyncOnValueBasedClasses != 0) { load_klass(tmpReg, objReg, scrReg); - movl(tmpReg, Address(tmpReg, Klass::access_flags_offset())); - testl(tmpReg, JVM_ACC_IS_VALUE_BASED_CLASS); + testb(Address(tmpReg, Klass::misc_flags_offset()), KlassFlags::_misc_is_value_based_class); jcc(Assembler::notZero, DONE_LABEL); } @@ -460,87 +459,43 @@ void C2_MacroAssembler::fast_unlock(Register objReg, Register boxReg, Register t // IA32's memory-model is SPO, so STs are ordered with respect to // each other and there's no need for an explicit barrier (fence). // See also http://gee.cs.oswego.edu/dl/jmm/cookbook.html. -#ifndef _LP64 - // Note that we could employ various encoding schemes to reduce - // the number of loads below (currently 4) to just 2 or 3. - // Refer to the comments in synchronizer.cpp. - // In practice the chain of fetches doesn't seem to impact performance, however. - xorptr(boxReg, boxReg); - orptr(boxReg, Address(tmpReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(recursions))); - jccb (Assembler::notZero, DONE_LABEL); - movptr(boxReg, Address(tmpReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(EntryList))); - orptr(boxReg, Address(tmpReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(cxq))); - jccb (Assembler::notZero, DONE_LABEL); - movptr(Address(tmpReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner)), NULL_WORD); - jmpb (DONE_LABEL); -#else // _LP64 - // It's inflated - Label CheckSucc, LNotRecursive, LSuccess, LGoSlowPath; + Label LSuccess, LNotRecursive; cmpptr(Address(tmpReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(recursions)), 0); jccb(Assembler::equal, LNotRecursive); // Recursive inflated unlock - decq(Address(tmpReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(recursions))); + decrement(Address(tmpReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(recursions))); jmpb(LSuccess); bind(LNotRecursive); + + // Set owner to null. + // Release to satisfy the JMM + movptr(Address(tmpReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner)), NULL_WORD); + // We need a full fence after clearing owner to avoid stranding. + // StoreLoad achieves this. + membar(StoreLoad); + + // Check if the entry lists are empty. movptr(boxReg, Address(tmpReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(cxq))); orptr(boxReg, Address(tmpReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(EntryList))); - jccb (Assembler::notZero, CheckSucc); - // Without cast to int32_t this style of movptr will destroy r10 which is typically obj. - movptr(Address(tmpReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner)), NULL_WORD); - jmpb (DONE_LABEL); + jccb(Assembler::zero, LSuccess); // If so we are done. - // Try to avoid passing control into the slow_path ... - bind (CheckSucc); - - // The following optional optimization can be elided if necessary - // Effectively: if (succ == null) goto slow path - // The code reduces the window for a race, however, - // and thus benefits performance. + // Check if there is a successor. cmpptr(Address(tmpReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(succ)), NULL_WORD); - jccb (Assembler::zero, LGoSlowPath); + jccb(Assembler::notZero, LSuccess); // If so we are done. - xorptr(boxReg, boxReg); - // Without cast to int32_t this style of movptr will destroy r10 which is typically obj. - movptr(Address(tmpReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner)), NULL_WORD); + // Save the monitor pointer in the current thread, so we can try to + // reacquire the lock in SharedRuntime::monitor_exit_helper(). + andptr(tmpReg, ~(int32_t)markWord::monitor_value); +#ifndef _LP64 + get_thread(boxReg); + movptr(Address(boxReg, JavaThread::unlocked_inflated_monitor_offset()), tmpReg); +#else // _LP64 + movptr(Address(r15_thread, JavaThread::unlocked_inflated_monitor_offset()), tmpReg); +#endif - // Memory barrier/fence - // Dekker pivot point -- fulcrum : ST Owner; MEMBAR; LD Succ - // Instead of MFENCE we use a dummy locked add of 0 to the top-of-stack. - // This is faster on Nehalem and AMD Shanghai/Barcelona. - // See https://blogs.oracle.com/dave/entry/instruction_selection_for_volatile_fences - // We might also restructure (ST Owner=0;barrier;LD _Succ) to - // (mov box,0; xchgq box, &m->Owner; LD _succ) . - lock(); addl(Address(rsp, 0), 0); - - cmpptr(Address(tmpReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(succ)), NULL_WORD); - jccb (Assembler::notZero, LSuccess); - - // Rare inopportune interleaving - race. - // The successor vanished in the small window above. - // The lock is contended -- (cxq|EntryList) != null -- and there's no apparent successor. - // We need to ensure progress and succession. - // Try to reacquire the lock. - // If that fails then the new owner is responsible for succession and this - // thread needs to take no further action and can exit via the fast path (success). - // If the re-acquire succeeds then pass control into the slow path. - // As implemented, this latter mode is horrible because we generated more - // coherence traffic on the lock *and* artificially extended the critical section - // length while by virtue of passing control into the slow path. - - // box is really RAX -- the following CMPXCHG depends on that binding - // cmpxchg R,[M] is equivalent to rax = CAS(M,rax,R) - lock(); - cmpxchgptr(r15_thread, Address(tmpReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner))); - // There's no successor so we tried to regrab the lock. - // If that didn't work, then another thread grabbed the - // lock so we're done (and exit was a success). - jccb (Assembler::notEqual, LSuccess); - // Intentional fall-through into slow path - - bind (LGoSlowPath); orl (boxReg, 1); // set ICC.ZF=0 to indicate failure jmpb (DONE_LABEL); @@ -548,7 +503,6 @@ void C2_MacroAssembler::fast_unlock(Register objReg, Register boxReg, Register t testl (boxReg, 0); // set ICC.ZF=1 to indicate success jmpb (DONE_LABEL); -#endif if (LockingMode == LM_LEGACY) { bind (Stacked); movptr(tmpReg, Address (boxReg, 0)); // re-fetch @@ -597,8 +551,7 @@ void C2_MacroAssembler::fast_lock_lightweight(Register obj, Register box, Regist if (DiagnoseSyncOnValueBasedClasses != 0) { load_klass(rax_reg, obj, t); - movl(rax_reg, Address(rax_reg, Klass::access_flags_offset())); - testl(rax_reg, JVM_ACC_IS_VALUE_BASED_CLASS); + testb(Address(rax_reg, Klass::misc_flags_offset()), KlassFlags::_misc_is_value_based_class); jcc(Assembler::notZero, slow_path); } @@ -746,10 +699,7 @@ void C2_MacroAssembler::fast_unlock_lightweight(Register obj, Register reg_rax, // Handle inflated monitor. Label inflated, inflated_check_lock_stack; // Finish fast unlock successfully. MUST jump with ZF == 1 - Label unlocked; - - // Assume success. - decrement(Address(thread, JavaThread::held_monitor_count_offset())); + Label unlocked, slow_path; const Register mark = t; const Register monitor = t; @@ -765,8 +715,6 @@ void C2_MacroAssembler::fast_unlock_lightweight(Register obj, Register reg_rax, } Label& push_and_slow_path = stub == nullptr ? dummy : stub->push_and_slow_path(); - Label& check_successor = stub == nullptr ? dummy : stub->check_successor(); - Label& slow_path = stub == nullptr ? dummy : stub->slow_path(); { // Lightweight Unlock @@ -841,6 +789,7 @@ void C2_MacroAssembler::fast_unlock_lightweight(Register obj, Register reg_rax, const ByteSize monitor_tag = in_ByteSize(UseObjectMonitorTable ? 0 : checked_cast(markWord::monitor_value)); const Address recursions_address{monitor, ObjectMonitor::recursions_offset() - monitor_tag}; const Address cxq_address{monitor, ObjectMonitor::cxq_offset() - monitor_tag}; + const Address succ_address{monitor, ObjectMonitor::succ_offset() - monitor_tag}; const Address EntryList_address{monitor, ObjectMonitor::EntryList_offset() - monitor_tag}; const Address owner_address{monitor, ObjectMonitor::owner_offset() - monitor_tag}; @@ -848,27 +797,42 @@ void C2_MacroAssembler::fast_unlock_lightweight(Register obj, Register reg_rax, // Check if recursive. cmpptr(recursions_address, 0); - jccb(Assembler::notEqual, recursive); + jccb(Assembler::notZero, recursive); + + // Set owner to null. + // Release to satisfy the JMM + movptr(owner_address, NULL_WORD); + // We need a full fence after clearing owner to avoid stranding. + // StoreLoad achieves this. + membar(StoreLoad); // Check if the entry lists are empty. movptr(reg_rax, cxq_address); orptr(reg_rax, EntryList_address); - jcc(Assembler::notZero, check_successor); + jccb(Assembler::zero, unlocked); // If so we are done. - // Release lock. - movptr(owner_address, NULL_WORD); - jmpb(unlocked); + // Check if there is a successor. + cmpptr(succ_address, NULL_WORD); + jccb(Assembler::notZero, unlocked); // If so we are done. + + // Save the monitor pointer in the current thread, so we can try to + // reacquire the lock in SharedRuntime::monitor_exit_helper(). + if (!UseObjectMonitorTable) { + andptr(monitor, ~(int32_t)markWord::monitor_value); + } + movptr(Address(thread, JavaThread::unlocked_inflated_monitor_offset()), monitor); + + orl(t, 1); // Fast Unlock ZF = 0 + jmpb(slow_path); // Recursive unlock. bind(recursive); decrement(recursions_address); - xorl(t, t); } bind(unlocked); - if (stub != nullptr) { - bind(stub->unlocked_continuation()); - } + decrement(Address(thread, JavaThread::held_monitor_count_offset())); + xorl(t, t); // Fast Unlock ZF = 1 #ifdef ASSERT // Check that unlocked label is reached with ZF set. @@ -877,6 +841,7 @@ void C2_MacroAssembler::fast_unlock_lightweight(Register obj, Register reg_rax, stop("Fast Unlock ZF != 1"); #endif + bind(slow_path); if (stub != nullptr) { bind(stub->slow_path_continuation()); } diff --git a/src/hotspot/cpu/x86/downcallLinker_x86_64.cpp b/src/hotspot/cpu/x86/downcallLinker_x86_64.cpp index 41039e0cfd8..e4b25ce00d6 100644 --- a/src/hotspot/cpu/x86/downcallLinker_x86_64.cpp +++ b/src/hotspot/cpu/x86/downcallLinker_x86_64.cpp @@ -34,8 +34,8 @@ #define __ _masm-> -static const int native_invoker_code_base_size = 512; -static const int native_invoker_size_per_arg = 8; +static const int native_invoker_code_base_size = 256; +static const int native_invoker_size_per_arg = 16; RuntimeStub* DowncallLinker::make_downcall_stub(BasicType* signature, int num_args, diff --git a/src/hotspot/cpu/x86/gc/g1/g1BarrierSetAssembler_x86.cpp b/src/hotspot/cpu/x86/gc/g1/g1BarrierSetAssembler_x86.cpp index b52be627776..b6be4012519 100644 --- a/src/hotspot/cpu/x86/gc/g1/g1BarrierSetAssembler_x86.cpp +++ b/src/hotspot/cpu/x86/gc/g1/g1BarrierSetAssembler_x86.cpp @@ -38,7 +38,10 @@ #include "c1/c1_LIRAssembler.hpp" #include "c1/c1_MacroAssembler.hpp" #include "gc/g1/c1/g1BarrierSetC1.hpp" -#endif +#endif // COMPILER1 +#ifdef COMPILER2 +#include "gc/g1/c2/g1BarrierSetC2.hpp" +#endif // COMPILER2 #define __ masm-> @@ -160,6 +163,56 @@ void G1BarrierSetAssembler::load_at(MacroAssembler* masm, DecoratorSet decorator } } +static void generate_queue_insertion(MacroAssembler* masm, ByteSize index_offset, ByteSize buffer_offset, Label& runtime, + const Register thread, const Register value, const Register temp) { + // This code assumes that buffer index is pointer sized. + STATIC_ASSERT(in_bytes(SATBMarkQueue::byte_width_of_index()) == sizeof(intptr_t)); + // Can we store a value in the given thread's buffer? + // (The index field is typed as size_t.) + __ movptr(temp, Address(thread, in_bytes(index_offset))); // temp := *(index address) + __ testptr(temp, temp); // index == 0? + __ jcc(Assembler::zero, runtime); // jump to runtime if index == 0 (full buffer) + // The buffer is not full, store value into it. + __ subptr(temp, wordSize); // temp := next index + __ movptr(Address(thread, in_bytes(index_offset)), temp); // *(index address) := next index + __ addptr(temp, Address(thread, in_bytes(buffer_offset))); // temp := buffer address + next index + __ movptr(Address(temp, 0), value); // *(buffer address + next index) := value +} + +static void generate_pre_barrier_fast_path(MacroAssembler* masm, + const Register thread) { + Address in_progress(thread, in_bytes(G1ThreadLocalData::satb_mark_queue_active_offset())); + // Is marking active? + if (in_bytes(SATBMarkQueue::byte_width_of_active()) == 4) { + __ cmpl(in_progress, 0); + } else { + assert(in_bytes(SATBMarkQueue::byte_width_of_active()) == 1, "Assumption"); + __ cmpb(in_progress, 0); + } +} + +static void generate_pre_barrier_slow_path(MacroAssembler* masm, + const Register obj, + const Register pre_val, + const Register thread, + const Register tmp, + Label& done, + Label& runtime) { + // Do we need to load the previous value? + if (obj != noreg) { + __ load_heap_oop(pre_val, Address(obj, 0), noreg, noreg, AS_RAW); + } + // Is the previous value null? + __ cmpptr(pre_val, NULL_WORD); + __ jcc(Assembler::equal, done); + generate_queue_insertion(masm, + G1ThreadLocalData::satb_mark_queue_index_offset(), + G1ThreadLocalData::satb_mark_queue_buffer_offset(), + runtime, + thread, pre_val, tmp); + __ jmp(done); +} + void G1BarrierSetAssembler::g1_write_barrier_pre(MacroAssembler* masm, Register obj, Register pre_val, @@ -185,43 +238,10 @@ void G1BarrierSetAssembler::g1_write_barrier_pre(MacroAssembler* masm, assert(pre_val != rax, "check this code"); } - Address in_progress(thread, in_bytes(G1ThreadLocalData::satb_mark_queue_active_offset())); - Address index(thread, in_bytes(G1ThreadLocalData::satb_mark_queue_index_offset())); - Address buffer(thread, in_bytes(G1ThreadLocalData::satb_mark_queue_buffer_offset())); - - // Is marking active? - if (in_bytes(SATBMarkQueue::byte_width_of_active()) == 4) { - __ cmpl(in_progress, 0); - } else { - assert(in_bytes(SATBMarkQueue::byte_width_of_active()) == 1, "Assumption"); - __ cmpb(in_progress, 0); - } + generate_pre_barrier_fast_path(masm, thread); + // If marking is not active (*(mark queue active address) == 0), jump to done __ jcc(Assembler::equal, done); - - // Do we need to load the previous value? - if (obj != noreg) { - __ load_heap_oop(pre_val, Address(obj, 0), noreg, noreg, AS_RAW); - } - - // Is the previous value null? - __ cmpptr(pre_val, NULL_WORD); - __ jcc(Assembler::equal, done); - - // Can we store original value in the thread's buffer? - // Is index == 0? - // (The index field is typed as size_t.) - - __ movptr(tmp, index); // tmp := *index_adr - __ cmpptr(tmp, 0); // tmp == 0? - __ jcc(Assembler::equal, runtime); // If yes, goto runtime - - __ subptr(tmp, wordSize); // tmp := tmp - wordSize - __ movptr(index, tmp); // *index_adr := tmp - __ addptr(tmp, buffer); // tmp := tmp + *buffer_adr - - // Record the previous value - __ movptr(Address(tmp, 0), pre_val); - __ jmp(done); + generate_pre_barrier_slow_path(masm, obj, pre_val, thread, tmp, done, runtime); __ bind(runtime); @@ -263,6 +283,54 @@ void G1BarrierSetAssembler::g1_write_barrier_pre(MacroAssembler* masm, __ bind(done); } +static void generate_post_barrier_fast_path(MacroAssembler* masm, + const Register store_addr, + const Register new_val, + const Register tmp, + const Register tmp2, + Label& done, + bool new_val_may_be_null) { + CardTableBarrierSet* ct = barrier_set_cast(BarrierSet::barrier_set()); + // Does store cross heap regions? + __ movptr(tmp, store_addr); // tmp := store address + __ xorptr(tmp, new_val); // tmp := store address ^ new value + __ shrptr(tmp, G1HeapRegion::LogOfHRGrainBytes); // ((store address ^ new value) >> LogOfHRGrainBytes) == 0? + __ jcc(Assembler::equal, done); + // Crosses regions, storing null? + if (new_val_may_be_null) { + __ cmpptr(new_val, NULL_WORD); // new value == null? + __ jcc(Assembler::equal, done); + } + // Storing region crossing non-null, is card young? + __ movptr(tmp, store_addr); // tmp := store address + __ shrptr(tmp, CardTable::card_shift()); // tmp := card address relative to card table base + // Do not use ExternalAddress to load 'byte_map_base', since 'byte_map_base' is NOT + // a valid address and therefore is not properly handled by the relocation code. + __ movptr(tmp2, (intptr_t)ct->card_table()->byte_map_base()); // tmp2 := card table base address + __ addptr(tmp, tmp2); // tmp := card address + __ cmpb(Address(tmp, 0), G1CardTable::g1_young_card_val()); // *(card address) == young_card_val? +} + +static void generate_post_barrier_slow_path(MacroAssembler* masm, + const Register thread, + const Register tmp, + const Register tmp2, + Label& done, + Label& runtime) { + __ membar(Assembler::Membar_mask_bits(Assembler::StoreLoad)); // StoreLoad membar + __ cmpb(Address(tmp, 0), G1CardTable::dirty_card_val()); // *(card address) == dirty_card_val? + __ jcc(Assembler::equal, done); + // Storing a region crossing, non-null oop, card is clean. + // Dirty card and log. + __ movb(Address(tmp, 0), G1CardTable::dirty_card_val()); // *(card address) := dirty_card_val + generate_queue_insertion(masm, + G1ThreadLocalData::dirty_card_queue_index_offset(), + G1ThreadLocalData::dirty_card_queue_buffer_offset(), + runtime, + thread, tmp, tmp2); + __ jmp(done); +} + void G1BarrierSetAssembler::g1_write_barrier_post(MacroAssembler* masm, Register store_addr, Register new_val, @@ -273,74 +341,125 @@ void G1BarrierSetAssembler::g1_write_barrier_post(MacroAssembler* masm, assert(thread == r15_thread, "must be"); #endif // _LP64 - Address queue_index(thread, in_bytes(G1ThreadLocalData::dirty_card_queue_index_offset())); - Address buffer(thread, in_bytes(G1ThreadLocalData::dirty_card_queue_buffer_offset())); - - CardTableBarrierSet* ct = - barrier_set_cast(BarrierSet::barrier_set()); - Label done; Label runtime; - // Does store cross heap regions? - - __ movptr(tmp, store_addr); - __ xorptr(tmp, new_val); - __ shrptr(tmp, G1HeapRegion::LogOfHRGrainBytes); + generate_post_barrier_fast_path(masm, store_addr, new_val, tmp, tmp2, done, true /* new_val_may_be_null */); + // If card is young, jump to done __ jcc(Assembler::equal, done); - - // crosses regions, storing null? - - __ cmpptr(new_val, NULL_WORD); - __ jcc(Assembler::equal, done); - - // storing region crossing non-null, is card already dirty? - - const Register card_addr = tmp; - const Register cardtable = tmp2; - - __ movptr(card_addr, store_addr); - __ shrptr(card_addr, CardTable::card_shift()); - // Do not use ExternalAddress to load 'byte_map_base', since 'byte_map_base' is NOT - // a valid address and therefore is not properly handled by the relocation code. - __ movptr(cardtable, (intptr_t)ct->card_table()->byte_map_base()); - __ addptr(card_addr, cardtable); - - __ cmpb(Address(card_addr, 0), G1CardTable::g1_young_card_val()); - __ jcc(Assembler::equal, done); - - __ membar(Assembler::Membar_mask_bits(Assembler::StoreLoad)); - __ cmpb(Address(card_addr, 0), G1CardTable::dirty_card_val()); - __ jcc(Assembler::equal, done); - - - // storing a region crossing, non-null oop, card is clean. - // dirty card and log. - - __ movb(Address(card_addr, 0), G1CardTable::dirty_card_val()); - - // The code below assumes that buffer index is pointer sized. - STATIC_ASSERT(in_bytes(G1DirtyCardQueue::byte_width_of_index()) == sizeof(intptr_t)); - - __ movptr(tmp2, queue_index); - __ testptr(tmp2, tmp2); - __ jcc(Assembler::zero, runtime); - __ subptr(tmp2, wordSize); - __ movptr(queue_index, tmp2); - __ addptr(tmp2, buffer); - __ movptr(Address(tmp2, 0), card_addr); - __ jmp(done); + generate_post_barrier_slow_path(masm, thread, tmp, tmp2, done, runtime); __ bind(runtime); // save the live input values RegSet saved = RegSet::of(store_addr NOT_LP64(COMMA thread)); __ push_set(saved); - __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_field_post_entry), card_addr, thread); + __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_field_post_entry), tmp, thread); __ pop_set(saved); __ bind(done); } +#if defined(COMPILER2) + +static void generate_c2_barrier_runtime_call(MacroAssembler* masm, G1BarrierStubC2* stub, const Register arg, const address runtime_path) { +#ifdef _LP64 + SaveLiveRegisters save_registers(masm, stub); + if (c_rarg0 != arg) { + __ mov(c_rarg0, arg); + } + __ mov(c_rarg1, r15_thread); + // rax is a caller-saved, non-argument-passing register, so it does not + // interfere with c_rarg0 or c_rarg1. If it contained any live value before + // entering this stub, it is saved at this point, and restored after the + // call. If it did not contain any live value, it is free to be used. In + // either case, it is safe to use it here as a call scratch register. + __ call(RuntimeAddress(runtime_path), rax); +#else + Unimplemented(); +#endif // _LP64 +} + +void G1BarrierSetAssembler::g1_write_barrier_pre_c2(MacroAssembler* masm, + Register obj, + Register pre_val, + Register thread, + Register tmp, + G1PreBarrierStubC2* stub) { +#ifdef _LP64 + assert(thread == r15_thread, "must be"); +#endif // _LP64 + assert(pre_val != noreg, "check this code"); + if (obj != noreg) { + assert_different_registers(obj, pre_val, tmp); + } + + stub->initialize_registers(obj, pre_val, thread, tmp); + + generate_pre_barrier_fast_path(masm, thread); + // If marking is active (*(mark queue active address) != 0), jump to stub (slow path) + __ jcc(Assembler::notEqual, *stub->entry()); + + __ bind(*stub->continuation()); +} + +void G1BarrierSetAssembler::generate_c2_pre_barrier_stub(MacroAssembler* masm, + G1PreBarrierStubC2* stub) const { + Assembler::InlineSkippedInstructionsCounter skip_counter(masm); + Label runtime; + Register obj = stub->obj(); + Register pre_val = stub->pre_val(); + Register thread = stub->thread(); + Register tmp = stub->tmp1(); + assert(stub->tmp2() == noreg, "not needed in this platform"); + + __ bind(*stub->entry()); + generate_pre_barrier_slow_path(masm, obj, pre_val, thread, tmp, *stub->continuation(), runtime); + + __ bind(runtime); + generate_c2_barrier_runtime_call(masm, stub, pre_val, CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_field_pre_entry)); + __ jmp(*stub->continuation()); +} + +void G1BarrierSetAssembler::g1_write_barrier_post_c2(MacroAssembler* masm, + Register store_addr, + Register new_val, + Register thread, + Register tmp, + Register tmp2, + G1PostBarrierStubC2* stub) { +#ifdef _LP64 + assert(thread == r15_thread, "must be"); +#endif // _LP64 + + stub->initialize_registers(thread, tmp, tmp2); + + bool new_val_may_be_null = (stub->barrier_data() & G1C2BarrierPostNotNull) == 0; + generate_post_barrier_fast_path(masm, store_addr, new_val, tmp, tmp2, *stub->continuation(), new_val_may_be_null); + // If card is not young, jump to stub (slow path) + __ jcc(Assembler::notEqual, *stub->entry()); + + __ bind(*stub->continuation()); +} + +void G1BarrierSetAssembler::generate_c2_post_barrier_stub(MacroAssembler* masm, + G1PostBarrierStubC2* stub) const { + Assembler::InlineSkippedInstructionsCounter skip_counter(masm); + Label runtime; + Register thread = stub->thread(); + Register tmp = stub->tmp1(); // tmp holds the card address. + Register tmp2 = stub->tmp2(); + assert(stub->tmp3() == noreg, "not needed in this platform"); + + __ bind(*stub->entry()); + generate_post_barrier_slow_path(masm, thread, tmp, tmp2, *stub->continuation(), runtime); + + __ bind(runtime); + generate_c2_barrier_runtime_call(masm, stub, tmp, CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_field_post_entry)); + __ jmp(*stub->continuation()); +} + +#endif // COMPILER2 + void G1BarrierSetAssembler::oop_store_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type, Address dst, Register val, Register tmp1, Register tmp2, Register tmp3) { bool in_heap = (decorators & IN_HEAP) != 0; diff --git a/src/hotspot/cpu/x86/gc/g1/g1BarrierSetAssembler_x86.hpp b/src/hotspot/cpu/x86/gc/g1/g1BarrierSetAssembler_x86.hpp index a5695f5657a..4dbb1efd885 100644 --- a/src/hotspot/cpu/x86/gc/g1/g1BarrierSetAssembler_x86.hpp +++ b/src/hotspot/cpu/x86/gc/g1/g1BarrierSetAssembler_x86.hpp @@ -32,6 +32,9 @@ class LIR_Assembler; class StubAssembler; class G1PreBarrierStub; class G1PostBarrierStub; +class G1BarrierStubC2; +class G1PreBarrierStubC2; +class G1PostBarrierStubC2; class G1BarrierSetAssembler: public ModRefBarrierSetAssembler { protected: @@ -65,6 +68,26 @@ class G1BarrierSetAssembler: public ModRefBarrierSetAssembler { virtual void load_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type, Register dst, Address src, Register tmp1, Register tmp_thread); + +#ifdef COMPILER2 + void g1_write_barrier_pre_c2(MacroAssembler* masm, + Register obj, + Register pre_val, + Register thread, + Register tmp, + G1PreBarrierStubC2* c2_stub); + void generate_c2_pre_barrier_stub(MacroAssembler* masm, + G1PreBarrierStubC2* stub) const; + void g1_write_barrier_post_c2(MacroAssembler* masm, + Register store_addr, + Register new_val, + Register thread, + Register tmp, + Register tmp2, + G1PostBarrierStubC2* c2_stub); + void generate_c2_post_barrier_stub(MacroAssembler* masm, + G1PostBarrierStubC2* stub) const; +#endif // COMPILER2 }; #endif // CPU_X86_GC_G1_G1BARRIERSETASSEMBLER_X86_HPP diff --git a/src/hotspot/cpu/x86/gc/g1/g1_x86_64.ad b/src/hotspot/cpu/x86/gc/g1/g1_x86_64.ad new file mode 100644 index 00000000000..8c1559f90f4 --- /dev/null +++ b/src/hotspot/cpu/x86/gc/g1/g1_x86_64.ad @@ -0,0 +1,371 @@ +// +// Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. +// DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +// +// This code is free software; you can redistribute it and/or modify it +// under the terms of the GNU General Public License version 2 only, as +// published by the Free Software Foundation. +// +// This code is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// version 2 for more details (a copy is included in the LICENSE file that +// accompanied this code). +// +// You should have received a copy of the GNU General Public License version +// 2 along with this work; if not, write to the Free Software Foundation, +// Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +// +// Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +// or visit www.oracle.com if you need additional information or have any +// questions. +// + +source_hpp %{ + +#include "gc/g1/c2/g1BarrierSetC2.hpp" +#include "gc/shared/gc_globals.hpp" + +%} + +source %{ + +#include "gc/g1/g1BarrierSetAssembler_x86.hpp" +#include "gc/g1/g1BarrierSetRuntime.hpp" + +static void write_barrier_pre(MacroAssembler* masm, + const MachNode* node, + Register obj, + Register pre_val, + Register tmp, + RegSet preserve = RegSet(), + RegSet no_preserve = RegSet()) { + if (!G1PreBarrierStubC2::needs_barrier(node)) { + return; + } + Assembler::InlineSkippedInstructionsCounter skip_counter(masm); + G1BarrierSetAssembler* g1_asm = static_cast(BarrierSet::barrier_set()->barrier_set_assembler()); + G1PreBarrierStubC2* const stub = G1PreBarrierStubC2::create(node); + for (RegSetIterator reg = preserve.begin(); *reg != noreg; ++reg) { + stub->preserve(*reg); + } + for (RegSetIterator reg = no_preserve.begin(); *reg != noreg; ++reg) { + stub->dont_preserve(*reg); + } + g1_asm->g1_write_barrier_pre_c2(masm, obj, pre_val, r15_thread, tmp, stub); +} + +static void write_barrier_post(MacroAssembler* masm, + const MachNode* node, + Register store_addr, + Register new_val, + Register tmp1, + Register tmp2) { + if (!G1PostBarrierStubC2::needs_barrier(node)) { + return; + } + Assembler::InlineSkippedInstructionsCounter skip_counter(masm); + G1BarrierSetAssembler* g1_asm = static_cast(BarrierSet::barrier_set()->barrier_set_assembler()); + G1PostBarrierStubC2* const stub = G1PostBarrierStubC2::create(node); + g1_asm->g1_write_barrier_post_c2(masm, store_addr, new_val, r15_thread, tmp1, tmp2, stub); +} + +%} + +instruct g1StoreP(memory mem, any_RegP src, rRegP tmp1, rRegP tmp2, rRegP tmp3, rFlagsReg cr) +%{ + predicate(UseG1GC && n->as_Store()->barrier_data() != 0); + match(Set mem (StoreP mem src)); + effect(TEMP tmp1, TEMP tmp2, TEMP tmp3, KILL cr); + ins_cost(125); // XXX + format %{ "movq $mem, $src\t# ptr" %} + ins_encode %{ + // Materialize the store address internally (as opposed to defining 'mem' as + // an indirect memory operand) to reduce the overhead of LCM when processing + // large basic blocks with many stores. Such basic blocks arise, for + // instance, from static initializations of large String arrays. + // The same holds for g1StoreN and g1EncodePAndStoreN. + __ lea($tmp1$$Register, $mem$$Address); + write_barrier_pre(masm, this, + $tmp1$$Register /* obj */, + $tmp2$$Register /* pre_val */, + $tmp3$$Register /* tmp */, + RegSet::of($tmp1$$Register, $src$$Register) /* preserve */); + __ movq(Address($tmp1$$Register, 0), $src$$Register); + write_barrier_post(masm, this, + $tmp1$$Register /* store_addr */, + $src$$Register /* new_val */, + $tmp3$$Register /* tmp1 */, + $tmp2$$Register /* tmp2 */); + %} + ins_pipe(ialu_mem_reg); +%} + +instruct g1StoreN(memory mem, rRegN src, rRegP tmp1, rRegP tmp2, rRegP tmp3, rFlagsReg cr) +%{ + predicate(UseG1GC && n->as_Store()->barrier_data() != 0); + match(Set mem (StoreN mem src)); + effect(TEMP tmp1, TEMP tmp2, TEMP tmp3, KILL cr); + ins_cost(125); // XXX + format %{ "movl $mem, $src\t# ptr" %} + ins_encode %{ + __ lea($tmp1$$Register, $mem$$Address); + write_barrier_pre(masm, this, + $tmp1$$Register /* obj */, + $tmp2$$Register /* pre_val */, + $tmp3$$Register /* tmp */, + RegSet::of($tmp1$$Register, $src$$Register) /* preserve */); + __ movl(Address($tmp1$$Register, 0), $src$$Register); + if ((barrier_data() & G1C2BarrierPost) != 0) { + __ movl($tmp2$$Register, $src$$Register); + if ((barrier_data() & G1C2BarrierPostNotNull) == 0) { + __ decode_heap_oop($tmp2$$Register); + } else { + __ decode_heap_oop_not_null($tmp2$$Register); + } + } + write_barrier_post(masm, this, + $tmp1$$Register /* store_addr */, + $tmp2$$Register /* new_val */, + $tmp3$$Register /* tmp1 */, + $tmp2$$Register /* tmp2 */); + %} + ins_pipe(ialu_mem_reg); +%} + +instruct g1EncodePAndStoreN(memory mem, any_RegP src, rRegP tmp1, rRegP tmp2, rRegP tmp3, rFlagsReg cr) +%{ + predicate(UseG1GC && n->as_Store()->barrier_data() != 0); + match(Set mem (StoreN mem (EncodeP src))); + effect(TEMP tmp1, TEMP tmp2, TEMP tmp3, KILL cr); + ins_cost(125); // XXX + format %{ "encode_heap_oop $src\n\t" + "movl $mem, $src\t# ptr" %} + ins_encode %{ + __ lea($tmp1$$Register, $mem$$Address); + write_barrier_pre(masm, this, + $tmp1$$Register /* obj */, + $tmp2$$Register /* pre_val */, + $tmp3$$Register /* tmp */, + RegSet::of($tmp1$$Register, $src$$Register) /* preserve */); + __ movq($tmp2$$Register, $src$$Register); + if ((barrier_data() & G1C2BarrierPostNotNull) == 0) { + __ encode_heap_oop($tmp2$$Register); + } else { + __ encode_heap_oop_not_null($tmp2$$Register); + } + __ movl(Address($tmp1$$Register, 0), $tmp2$$Register); + write_barrier_post(masm, this, + $tmp1$$Register /* store_addr */, + $src$$Register /* new_val */, + $tmp3$$Register /* tmp1 */, + $tmp2$$Register /* tmp2 */); + %} + ins_pipe(ialu_mem_reg); +%} + +instruct g1CompareAndExchangeP(indirect mem, rRegP newval, rRegP tmp1, rRegP tmp2, rRegP tmp3, rax_RegP oldval, rFlagsReg cr) +%{ + predicate(UseG1GC && n->as_LoadStore()->barrier_data() != 0); + match(Set oldval (CompareAndExchangeP mem (Binary oldval newval))); + effect(TEMP tmp1, TEMP tmp2, TEMP tmp3, KILL cr); + format %{ "lock\n\t" + "cmpxchgq $newval, $mem" %} + ins_encode %{ + assert_different_registers($oldval$$Register, $mem$$Register); + // Pass $oldval to the pre-barrier (instead of loading from $mem), because + // $oldval is the only value that can be overwritten. + // The same holds for g1CompareAndSwapP. + write_barrier_pre(masm, this, + noreg /* obj */, + $oldval$$Register /* pre_val */, + $tmp3$$Register /* tmp */, + RegSet::of($mem$$Register, $newval$$Register, $oldval$$Register) /* preserve */); + __ movq($tmp1$$Register, $newval$$Register); + __ lock(); + __ cmpxchgq($tmp1$$Register, Address($mem$$Register, 0)); + write_barrier_post(masm, this, + $mem$$Register /* store_addr */, + $tmp1$$Register /* new_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */); + %} + ins_pipe(pipe_cmpxchg); +%} + +instruct g1CompareAndExchangeN(indirect mem, rRegN newval, rRegP tmp1, rRegP tmp2, rRegP tmp3, rax_RegN oldval, rFlagsReg cr) +%{ + predicate(UseG1GC && n->as_LoadStore()->barrier_data() != 0); + match(Set oldval (CompareAndExchangeN mem (Binary oldval newval))); + effect(TEMP tmp1, TEMP tmp2, TEMP tmp3, KILL cr); + format %{ "lock\n\t" + "cmpxchgq $newval, $mem" %} + ins_encode %{ + assert_different_registers($oldval$$Register, $mem$$Register); + write_barrier_pre(masm, this, + $mem$$Register /* obj */, + $tmp2$$Register /* pre_val */, + $tmp3$$Register /* tmp */, + RegSet::of($mem$$Register, $newval$$Register, $oldval$$Register) /* preserve */); + __ movl($tmp1$$Register, $newval$$Register); + __ lock(); + __ cmpxchgl($tmp1$$Register, Address($mem$$Register, 0)); + __ decode_heap_oop($tmp1$$Register); + write_barrier_post(masm, this, + $mem$$Register /* store_addr */, + $tmp1$$Register /* new_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */); + %} + ins_pipe(pipe_cmpxchg); +%} + +instruct g1CompareAndSwapP(rRegI res, indirect mem, rRegP newval, rRegP tmp1, rRegP tmp2, rRegP tmp3, rax_RegP oldval, rFlagsReg cr) +%{ + predicate(UseG1GC && n->as_LoadStore()->barrier_data() != 0); + match(Set res (CompareAndSwapP mem (Binary oldval newval))); + match(Set res (WeakCompareAndSwapP mem (Binary oldval newval))); + effect(TEMP res, TEMP tmp1, TEMP tmp2, TEMP tmp3, KILL oldval, KILL cr); + format %{ "lock\n\t" + "cmpxchgq $newval, $mem\n\t" + "sete $res\n\t" + "movzbl $res, $res" %} + ins_encode %{ + assert_different_registers($oldval$$Register, $mem$$Register); + write_barrier_pre(masm, this, + noreg /* obj */, + $oldval$$Register /* pre_val */, + $tmp3$$Register /* tmp */, + RegSet::of($mem$$Register, $newval$$Register, $oldval$$Register) /* preserve */, + RegSet::of($res$$Register) /* no_preserve */); + __ movq($tmp1$$Register, $newval$$Register); + __ lock(); + __ cmpxchgq($tmp1$$Register, Address($mem$$Register, 0)); + __ setb(Assembler::equal, $res$$Register); + __ movzbl($res$$Register, $res$$Register); + write_barrier_post(masm, this, + $mem$$Register /* store_addr */, + $tmp1$$Register /* new_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */); + %} + ins_pipe(pipe_cmpxchg); +%} + +instruct g1CompareAndSwapN(rRegI res, indirect mem, rRegN newval, rRegP tmp1, rRegP tmp2, rRegP tmp3, rax_RegN oldval, rFlagsReg cr) +%{ + predicate(UseG1GC && n->as_LoadStore()->barrier_data() != 0); + match(Set res (CompareAndSwapN mem (Binary oldval newval))); + match(Set res (WeakCompareAndSwapN mem (Binary oldval newval))); + effect(TEMP res, TEMP tmp1, TEMP tmp2, TEMP tmp3, KILL oldval, KILL cr); + format %{ "lock\n\t" + "cmpxchgq $newval, $mem\n\t" + "sete $res\n\t" + "movzbl $res, $res" %} + ins_encode %{ + assert_different_registers($oldval$$Register, $mem$$Register); + write_barrier_pre(masm, this, + $mem$$Register /* obj */, + $tmp2$$Register /* pre_val */, + $tmp3$$Register /* tmp */, + RegSet::of($mem$$Register, $newval$$Register, $oldval$$Register) /* preserve */, + RegSet::of($res$$Register) /* no_preserve */); + __ movl($tmp1$$Register, $newval$$Register); + __ lock(); + __ cmpxchgl($tmp1$$Register, Address($mem$$Register, 0)); + __ setb(Assembler::equal, $res$$Register); + __ movzbl($res$$Register, $res$$Register); + __ decode_heap_oop($tmp1$$Register); + write_barrier_post(masm, this, + $mem$$Register /* store_addr */, + $tmp1$$Register /* new_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */); + %} + ins_pipe(pipe_cmpxchg); +%} + +instruct g1GetAndSetP(indirect mem, rRegP newval, rRegP tmp1, rRegP tmp2, rRegP tmp3, rFlagsReg cr) +%{ + predicate(UseG1GC && n->as_LoadStore()->barrier_data() != 0); + match(Set newval (GetAndSetP mem newval)); + effect(TEMP tmp1, TEMP tmp2, TEMP tmp3, KILL cr); + format %{ "xchgq $newval, $mem" %} + ins_encode %{ + assert_different_registers($mem$$Register, $newval$$Register); + write_barrier_pre(masm, this, + $mem$$Register /* obj */, + $tmp2$$Register /* pre_val */, + $tmp3$$Register /* tmp */, + RegSet::of($mem$$Register, $newval$$Register) /* preserve */); + __ movq($tmp1$$Register, $newval$$Register); + __ xchgq($newval$$Register, Address($mem$$Register, 0)); + write_barrier_post(masm, this, + $mem$$Register /* store_addr */, + $tmp1$$Register /* new_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */); + %} + ins_pipe(pipe_cmpxchg); +%} + +instruct g1GetAndSetN(indirect mem, rRegN newval, rRegP tmp1, rRegP tmp2, rRegP tmp3, rFlagsReg cr) +%{ + predicate(UseG1GC && n->as_LoadStore()->barrier_data() != 0); + match(Set newval (GetAndSetN mem newval)); + effect(TEMP tmp1, TEMP tmp2, TEMP tmp3, KILL cr); + format %{ "xchgq $newval, $mem" %} + ins_encode %{ + assert_different_registers($mem$$Register, $newval$$Register); + write_barrier_pre(masm, this, + $mem$$Register /* obj */, + $tmp2$$Register /* pre_val */, + $tmp3$$Register /* tmp */, + RegSet::of($mem$$Register, $newval$$Register) /* preserve */); + __ movl($tmp1$$Register, $newval$$Register); + __ decode_heap_oop($tmp1$$Register); + __ xchgl($newval$$Register, Address($mem$$Register, 0)); + write_barrier_post(masm, this, + $mem$$Register /* store_addr */, + $tmp1$$Register /* new_val */, + $tmp2$$Register /* tmp1 */, + $tmp3$$Register /* tmp2 */); + %} + ins_pipe(pipe_cmpxchg); +%} + +instruct g1LoadP(rRegP dst, memory mem, rRegP tmp, rFlagsReg cr) +%{ + predicate(UseG1GC && n->as_Load()->barrier_data() != 0); + match(Set dst (LoadP mem)); + effect(TEMP dst, TEMP tmp, KILL cr); + ins_cost(125); // XXX + format %{ "movq $dst, $mem\t# ptr" %} + ins_encode %{ + __ movq($dst$$Register, $mem$$Address); + write_barrier_pre(masm, this, + noreg /* obj */, + $dst$$Register /* pre_val */, + $tmp$$Register /* tmp */); + %} + ins_pipe(ialu_reg_mem); // XXX +%} + +instruct g1LoadN(rRegN dst, memory mem, rRegP tmp1, rRegP tmp2, rFlagsReg cr) +%{ + predicate(UseG1GC && n->as_Load()->barrier_data() != 0); + match(Set dst (LoadN mem)); + effect(TEMP dst, TEMP tmp1, TEMP tmp2, KILL cr); + ins_cost(125); // XXX + format %{ "movl $dst, $mem\t# compressed ptr" %} + ins_encode %{ + __ movl($dst$$Register, $mem$$Address); + __ movl($tmp1$$Register, $dst$$Register); + __ decode_heap_oop($tmp1$$Register); + write_barrier_pre(masm, this, + noreg /* obj */, + $tmp1$$Register /* pre_val */, + $tmp2$$Register /* tmp */); + %} + ins_pipe(ialu_reg_mem); // XXX +%} diff --git a/src/hotspot/cpu/x86/gc/shenandoah/shenandoahBarrierSetAssembler_x86.cpp b/src/hotspot/cpu/x86/gc/shenandoah/shenandoahBarrierSetAssembler_x86.cpp index 47078dff907..a7682fe0c38 100644 --- a/src/hotspot/cpu/x86/gc/shenandoah/shenandoahBarrierSetAssembler_x86.cpp +++ b/src/hotspot/cpu/x86/gc/shenandoah/shenandoahBarrierSetAssembler_x86.cpp @@ -163,12 +163,12 @@ void ShenandoahBarrierSetAssembler::arraycopy_prologue(MacroAssembler* masm, Dec assert(dst == rsi, "expected"); assert(count == rdx, "expected"); if (UseCompressedOops) { - __ call_VM_leaf(CAST_FROM_FN_PTR(address, ShenandoahRuntime::arraycopy_barrier_narrow_oop_entry), + __ call_VM_leaf(CAST_FROM_FN_PTR(address, ShenandoahRuntime::arraycopy_barrier_narrow_oop), src, dst, count); } else #endif { - __ call_VM_leaf(CAST_FROM_FN_PTR(address, ShenandoahRuntime::arraycopy_barrier_oop_entry), + __ call_VM_leaf(CAST_FROM_FN_PTR(address, ShenandoahRuntime::arraycopy_barrier_oop), src, dst, count); } @@ -296,9 +296,9 @@ void ShenandoahBarrierSetAssembler::satb_write_barrier_pre(MacroAssembler* masm, __ push(thread); __ push(pre_val); #endif - __ MacroAssembler::call_VM_leaf_base(CAST_FROM_FN_PTR(address, ShenandoahRuntime::write_ref_field_pre_entry), 2); + __ MacroAssembler::call_VM_leaf_base(CAST_FROM_FN_PTR(address, ShenandoahRuntime::write_ref_field_pre), 2); } else { - __ call_VM_leaf(CAST_FROM_FN_PTR(address, ShenandoahRuntime::write_ref_field_pre_entry), LP64_ONLY(c_rarg0) NOT_LP64(pre_val), thread); + __ call_VM_leaf(CAST_FROM_FN_PTR(address, ShenandoahRuntime::write_ref_field_pre), LP64_ONLY(c_rarg0) NOT_LP64(pre_val), thread); } NOT_LP64( __ pop(thread); ) @@ -925,7 +925,7 @@ void ShenandoahBarrierSetAssembler::generate_c1_pre_barrier_runtime_stub(StubAss // load the pre-value __ load_parameter(0, rcx); - __ call_VM_leaf(CAST_FROM_FN_PTR(address, ShenandoahRuntime::write_ref_field_pre_entry), rcx, thread); + __ call_VM_leaf(CAST_FROM_FN_PTR(address, ShenandoahRuntime::write_ref_field_pre), rcx, thread); __ restore_live_registers(true); diff --git a/src/hotspot/cpu/x86/gc/x/x_x86_64.ad b/src/hotspot/cpu/x86/gc/x/x_x86_64.ad index 116fb3cbc6d..ba4b3cb6df0 100644 --- a/src/hotspot/cpu/x86/gc/x/x_x86_64.ad +++ b/src/hotspot/cpu/x86/gc/x/x_x86_64.ad @@ -126,8 +126,7 @@ instruct xCompareAndSwapP(rRegI res, indirect mem, rRegP newval, rRegP tmp, rFla format %{ "lock\n\t" "cmpxchgq $newval, $mem\n\t" - "sete $res\n\t" - "movzbl $res, $res" %} + "setcc $res \t# emits sete + movzbl or setzue for APX" %} ins_encode %{ precond($oldval$$Register == rax); @@ -135,8 +134,7 @@ instruct xCompareAndSwapP(rRegI res, indirect mem, rRegP newval, rRegP tmp, rFla if (barrier_data() != XLoadBarrierElided) { __ cmpptr($tmp$$Register, rax); } - __ setb(Assembler::equal, $res$$Register); - __ movzbl($res$$Register, $res$$Register); + __ setcc(Assembler::equal, $res$$Register); %} ins_pipe(pipe_cmpxchg); diff --git a/src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.cpp b/src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.cpp index f5f0d6c8841..65d7c1e3303 100644 --- a/src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.cpp +++ b/src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.cpp @@ -636,7 +636,7 @@ void ZBarrierSetAssembler::copy_load_at(MacroAssembler* masm, // Remove metadata bits so that the store side (vectorized or non-vectorized) can // inject the store-good color with an or instruction. - __ andq(dst, _zpointer_address_mask); + __ andq(dst, ZPointerAddressMask); if ((decorators & ARRAYCOPY_CHECKCAST) != 0) { // The checkcast arraycopy needs to be able to dereference the oops in order to perform a typechecks. diff --git a/src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.hpp b/src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.hpp index 7c3716ba0da..5fbc7ea1be1 100644 --- a/src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.hpp +++ b/src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.hpp @@ -64,7 +64,7 @@ private: GrowableArrayCHeap _store_good_relocations; public: - static const int32_t _zpointer_address_mask = 0xFFFF0000; + static const int32_t ZPointerAddressMask = 0xFFFF0000; ZBarrierSetAssembler(); diff --git a/src/hotspot/cpu/x86/gc/z/z_x86_64.ad b/src/hotspot/cpu/x86/gc/z/z_x86_64.ad index 1a4499c3d44..455d622acdf 100644 --- a/src/hotspot/cpu/x86/gc/z/z_x86_64.ad +++ b/src/hotspot/cpu/x86/gc/z/z_x86_64.ad @@ -141,7 +141,7 @@ instruct zLoadPNullCheck(rFlagsReg cr, memory op, immP0 zero) ins_encode %{ // A null pointer will have all address bits 0. This mask sign extends // all address bits, so we can test if the address is 0. - __ testq($op$$Address, ZBarrierSetAssembler::_zpointer_address_mask); + __ testq($op$$Address, ZBarrierSetAssembler::ZPointerAddressMask); %} ins_pipe(ialu_cr_reg_imm); %} @@ -212,8 +212,7 @@ instruct zCompareAndSwapP(rRegI res, indirect mem, rRegP newval, rRegP tmp, rax_ format %{ "lock\n\t" "cmpxchgq $newval, $mem\n\t" - "sete $res\n\t" - "movzbl $res, $res" %} + "setcc $res \t# emits sete + movzbl or setzue for APX" %} ins_encode %{ assert_different_registers($oldval$$Register, $mem$$Register); @@ -222,8 +221,7 @@ instruct zCompareAndSwapP(rRegI res, indirect mem, rRegP newval, rRegP tmp, rax_ z_color(masm, this, $oldval$$Register); __ lock(); __ cmpxchgptr($tmp$$Register, mem_addr); - __ setb(Assembler::equal, $res$$Register); - __ movzbl($res$$Register, $res$$Register); + __ setcc(Assembler::equal, $res$$Register); %} ins_pipe(pipe_cmpxchg); diff --git a/src/hotspot/cpu/x86/interp_masm_x86.cpp b/src/hotspot/cpu/x86/interp_masm_x86.cpp index 249506c13ff..f4b95d846c6 100644 --- a/src/hotspot/cpu/x86/interp_masm_x86.cpp +++ b/src/hotspot/cpu/x86/interp_masm_x86.cpp @@ -1175,8 +1175,7 @@ void InterpreterMacroAssembler::lock_object(Register lock_reg) { if (DiagnoseSyncOnValueBasedClasses != 0) { load_klass(tmp_reg, obj_reg, rklass_decode_tmp); - movl(tmp_reg, Address(tmp_reg, Klass::access_flags_offset())); - testl(tmp_reg, JVM_ACC_IS_VALUE_BASED_CLASS); + testb(Address(tmp_reg, Klass::misc_flags_offset()), KlassFlags::_misc_is_value_based_class); jcc(Assembler::notZero, slow_case); } diff --git a/src/hotspot/cpu/x86/macroAssembler_x86.cpp b/src/hotspot/cpu/x86/macroAssembler_x86.cpp index ba337751d19..018258a012e 100644 --- a/src/hotspot/cpu/x86/macroAssembler_x86.cpp +++ b/src/hotspot/cpu/x86/macroAssembler_x86.cpp @@ -5084,7 +5084,8 @@ void MacroAssembler::clinit_barrier(Register klass, Register thread, Label* L_fa L_slow_path = &L_fallthrough; } - // Fast path check: class is fully initialized + // Fast path check: class is fully initialized. + // init_state needs acquire, but x86 is TSO, and so we are already good. cmpb(Address(klass, InstanceKlass::init_state_offset()), InstanceKlass::fully_initialized); jcc(Assembler::equal, *L_fast_path); @@ -5756,7 +5757,7 @@ void MacroAssembler::verify_heapbase(const char* msg) { assert (Universe::heap() != nullptr, "java heap should be initialized"); if (CheckCompressedOops) { Label ok; - ExternalAddress src2(CompressedOops::ptrs_base_addr()); + ExternalAddress src2(CompressedOops::base_addr()); const bool is_src2_reachable = reachable(src2); if (!is_src2_reachable) { push(rscratch1); // cmpptr trashes rscratch1 @@ -6047,10 +6048,10 @@ void MacroAssembler::reinit_heapbase() { if (CompressedOops::base() == nullptr) { MacroAssembler::xorptr(r12_heapbase, r12_heapbase); } else { - mov64(r12_heapbase, (int64_t)CompressedOops::ptrs_base()); + mov64(r12_heapbase, (int64_t)CompressedOops::base()); } } else { - movptr(r12_heapbase, ExternalAddress(CompressedOops::ptrs_base_addr())); + movptr(r12_heapbase, ExternalAddress(CompressedOops::base_addr())); } } } @@ -10421,4 +10422,13 @@ void MacroAssembler::restore_legacy_gprs() { movq(rax, Address(rsp, 15 * wordSize)); addq(rsp, 16 * wordSize); } + +void MacroAssembler::setcc(Assembler::Condition comparison, Register dst) { + if (VM_Version::supports_apx_f()) { + esetzucc(comparison, dst); + } else { + setb(comparison, dst); + movzbl(dst, dst); + } +} #endif diff --git a/src/hotspot/cpu/x86/macroAssembler_x86.hpp b/src/hotspot/cpu/x86/macroAssembler_x86.hpp index 594f0b95ca3..2ce4fc40e90 100644 --- a/src/hotspot/cpu/x86/macroAssembler_x86.hpp +++ b/src/hotspot/cpu/x86/macroAssembler_x86.hpp @@ -2154,6 +2154,7 @@ public: #ifdef _LP64 void save_legacy_gprs(); void restore_legacy_gprs(); + void setcc(Assembler::Condition comparison, Register dst); #endif }; diff --git a/src/hotspot/cpu/x86/macroAssembler_x86_md5.cpp b/src/hotspot/cpu/x86/macroAssembler_x86_md5.cpp index 439c17b10d3..09d379a4296 100644 --- a/src/hotspot/cpu/x86/macroAssembler_x86_md5.cpp +++ b/src/hotspot/cpu/x86/macroAssembler_x86_md5.cpp @@ -81,8 +81,8 @@ void MacroAssembler::fast_md5(Register buf, Address state, Address ofs, Address notl(rsi); \ andl(rdi, r2); \ andl(rsi, r3); \ - orl(rsi, rdi); \ addl(r1, rsi); \ + addl(r1, rdi); \ roll(r1, s); \ addl(r1, r2); diff --git a/src/hotspot/cpu/x86/sharedRuntime_x86_32.cpp b/src/hotspot/cpu/x86/sharedRuntime_x86_32.cpp index 273bbcc6525..c6ab00cc9ee 100644 --- a/src/hotspot/cpu/x86/sharedRuntime_x86_32.cpp +++ b/src/hotspot/cpu/x86/sharedRuntime_x86_32.cpp @@ -2062,7 +2062,8 @@ void SharedRuntime::generate_deopt_blob() { ResourceMark rm; // setup code generation tools // note: the buffer code size must account for StackShadowPages=50 - CodeBuffer buffer("deopt_blob", 1536, 1024); + const char* name = SharedRuntime::stub_name(SharedStubId::deopt_id); + CodeBuffer buffer(name, 1536, 1024); MacroAssembler* masm = new MacroAssembler(&buffer); int frame_size_in_words; OopMap* map = nullptr; @@ -2403,13 +2404,14 @@ void SharedRuntime::generate_deopt_blob() { // setup oopmap, and calls safepoint code to stop the compiled code for // a safepoint. // -SafepointBlob* SharedRuntime::generate_handler_blob(address call_ptr, int poll_type) { +SafepointBlob* SharedRuntime::generate_handler_blob(SharedStubId id, address call_ptr) { // Account for thread arg in our frame const int additional_words = 1; int frame_size_in_words; assert (StubRoutines::forward_exception_entry() != nullptr, "must be generated before"); + assert(is_polling_page_id(id), "expected a polling page stub id"); ResourceMark rm; OopMapSet *oop_maps = new OopMapSet(); @@ -2417,14 +2419,15 @@ SafepointBlob* SharedRuntime::generate_handler_blob(address call_ptr, int poll_t // allocate space for the code // setup code generation tools - CodeBuffer buffer("handler_blob", 2048, 1024); + const char* name = SharedRuntime::stub_name(id); + CodeBuffer buffer(name, 2048, 1024); MacroAssembler* masm = new MacroAssembler(&buffer); const Register java_thread = rdi; // callee-saved for VC++ address start = __ pc(); address call_pc = nullptr; - bool cause_return = (poll_type == POLL_AT_RETURN); - bool save_vectors = (poll_type == POLL_AT_VECTOR_LOOP); + bool cause_return = (id == SharedStubId::polling_page_return_handler_id); + bool save_vectors = (id == SharedStubId::polling_page_vectors_safepoint_handler_id); // If cause_return is true we are at a poll_return and there is // the return address on the stack to the caller on the nmethod @@ -2556,12 +2559,14 @@ SafepointBlob* SharedRuntime::generate_handler_blob(address call_ptr, int poll_t // but since this is generic code we don't know what they are and the caller // must do any gc of the args. // -RuntimeStub* SharedRuntime::generate_resolve_blob(address destination, const char* name) { +RuntimeStub* SharedRuntime::generate_resolve_blob(SharedStubId id, address destination) { assert (StubRoutines::forward_exception_entry() != nullptr, "must be generated before"); + assert(is_resolve_id(id), "expected a resolve stub id"); // allocate space for the code ResourceMark rm; + const char* name = SharedRuntime::stub_name(id); CodeBuffer buffer(name, 1000, 512); MacroAssembler* masm = new MacroAssembler(&buffer); @@ -2662,7 +2667,10 @@ RuntimeStub* SharedRuntime::generate_resolve_blob(address destination, const cha // exceptions (e.g., NullPointerException or AbstractMethodError on entry) are // either at call sites or otherwise assume that stack unwinding will be initiated, // so caller saved registers were assumed volatile in the compiler. -RuntimeStub* SharedRuntime::generate_throw_exception(const char* name, address runtime_entry) { +RuntimeStub* SharedRuntime::generate_throw_exception(SharedStubId id, address runtime_entry) { + assert(is_throw_id(id), "expected a throw stub id"); + + const char* name = SharedRuntime::stub_name(id); // Information about frame layout at time of blocking runtime call. // Note that we only have to preserve callee-saved registers since @@ -2776,7 +2784,8 @@ RuntimeStub* SharedRuntime::generate_jfr_write_checkpoint() { int insts_size = 1024; int locs_size = 64; - CodeBuffer code("jfr_write_checkpoint", insts_size, locs_size); + const char* name = SharedRuntime::stub_name(SharedStubId::jfr_write_checkpoint_id); + CodeBuffer code(name, insts_size, locs_size); OopMapSet* oop_maps = new OopMapSet(); MacroAssembler* masm = new MacroAssembler(&code); @@ -2795,7 +2804,7 @@ RuntimeStub* SharedRuntime::generate_jfr_write_checkpoint() { oop_maps->add_gc_map(the_pc - start, map); RuntimeStub* stub = // codeBlob framesize is in words (not VMRegImpl::slot_size) - RuntimeStub::new_runtime_stub("jfr_write_checkpoint", &code, frame_complete, + RuntimeStub::new_runtime_stub(name, &code, frame_complete, (framesize >> (LogBytesPerWord - LogBytesPerInt)), oop_maps, false); return stub; @@ -2817,7 +2826,8 @@ RuntimeStub* SharedRuntime::generate_jfr_return_lease() { int insts_size = 1024; int locs_size = 64; - CodeBuffer code("jfr_return_lease", insts_size, locs_size); + const char* name = SharedRuntime::stub_name(SharedStubId::jfr_return_lease_id); + CodeBuffer code(name, insts_size, locs_size); OopMapSet* oop_maps = new OopMapSet(); MacroAssembler* masm = new MacroAssembler(&code); @@ -2835,7 +2845,7 @@ RuntimeStub* SharedRuntime::generate_jfr_return_lease() { oop_maps->add_gc_map(the_pc - start, map); RuntimeStub* stub = // codeBlob framesize is in words (not VMRegImpl::slot_size) - RuntimeStub::new_runtime_stub("jfr_return_lease", &code, frame_complete, + RuntimeStub::new_runtime_stub(name, &code, frame_complete, (framesize >> (LogBytesPerWord - LogBytesPerInt)), oop_maps, false); return stub; diff --git a/src/hotspot/cpu/x86/sharedRuntime_x86_64.cpp b/src/hotspot/cpu/x86/sharedRuntime_x86_64.cpp index 05ec85ef09a..174e2e02779 100644 --- a/src/hotspot/cpu/x86/sharedRuntime_x86_64.cpp +++ b/src/hotspot/cpu/x86/sharedRuntime_x86_64.cpp @@ -2623,7 +2623,8 @@ void SharedRuntime::generate_deopt_blob() { pad += 512; // Increase the buffer size when compiling for JVMCI } #endif - CodeBuffer buffer("deopt_blob", 2560+pad, 1024); + const char* name = SharedRuntime::stub_name(SharedStubId::deopt_id); + CodeBuffer buffer(name, 2560+pad, 1024); MacroAssembler* masm = new MacroAssembler(&buffer); int frame_size_in_words; OopMap* map = nullptr; @@ -2673,7 +2674,7 @@ void SharedRuntime::generate_deopt_blob() { int reexecute_offset = __ pc() - start; #if INCLUDE_JVMCI && !defined(COMPILER1) - if (EnableJVMCI && UseJVMCICompiler) { + if (UseJVMCICompiler) { // JVMCI does not use this kind of deoptimization __ should_not_reach_here(); } @@ -2981,23 +2982,25 @@ void SharedRuntime::generate_deopt_blob() { // Generate a special Compile2Runtime blob that saves all registers, // and setup oopmap. // -SafepointBlob* SharedRuntime::generate_handler_blob(address call_ptr, int poll_type) { +SafepointBlob* SharedRuntime::generate_handler_blob(SharedStubId id, address call_ptr) { assert(StubRoutines::forward_exception_entry() != nullptr, "must be generated before"); + assert(is_polling_page_id(id), "expected a polling page stub id"); ResourceMark rm; OopMapSet *oop_maps = new OopMapSet(); OopMap* map; // Allocate space for the code. Setup code generation tools. - CodeBuffer buffer("handler_blob", 2348, 1024); + const char* name = SharedRuntime::stub_name(id); + CodeBuffer buffer(name, 2348, 1024); MacroAssembler* masm = new MacroAssembler(&buffer); address start = __ pc(); address call_pc = nullptr; int frame_size_in_words; - bool cause_return = (poll_type == POLL_AT_RETURN); - bool save_wide_vectors = (poll_type == POLL_AT_VECTOR_LOOP); + bool cause_return = (id == SharedStubId::polling_page_return_handler_id); + bool save_wide_vectors = (id == SharedStubId::polling_page_vectors_safepoint_handler_id); // Make room for return address (or push it again) if (!cause_return) { @@ -3140,12 +3143,14 @@ SafepointBlob* SharedRuntime::generate_handler_blob(address call_ptr, int poll_t // but since this is generic code we don't know what they are and the caller // must do any gc of the args. // -RuntimeStub* SharedRuntime::generate_resolve_blob(address destination, const char* name) { +RuntimeStub* SharedRuntime::generate_resolve_blob(SharedStubId id, address destination) { assert (StubRoutines::forward_exception_entry() != nullptr, "must be generated before"); + assert(is_resolve_id(id), "expected a resolve stub id"); // allocate space for the code ResourceMark rm; + const char* name = SharedRuntime::stub_name(id); CodeBuffer buffer(name, 1552, 512); MacroAssembler* masm = new MacroAssembler(&buffer); @@ -3232,7 +3237,11 @@ RuntimeStub* SharedRuntime::generate_resolve_blob(address destination, const cha // AbstractMethodError on entry) are either at call sites or // otherwise assume that stack unwinding will be initiated, so // caller saved registers were assumed volatile in the compiler. -RuntimeStub* SharedRuntime::generate_throw_exception(const char* name, address runtime_entry) { +RuntimeStub* SharedRuntime::generate_throw_exception(SharedStubId id, address runtime_entry) { + assert(is_throw_id(id), "expected a throw stub id"); + + const char* name = SharedRuntime::stub_name(id); + // Information about frame layout at time of blocking runtime call. // Note that we only have to preserve callee-saved registers since // the compilers are responsible for supplying a continuation point @@ -3591,7 +3600,8 @@ RuntimeStub* SharedRuntime::generate_jfr_write_checkpoint() { framesize // inclusive of return address }; - CodeBuffer code("jfr_write_checkpoint", 1024, 64); + const char* name = SharedRuntime::stub_name(SharedStubId::jfr_write_checkpoint_id); + CodeBuffer code(name, 1024, 64); MacroAssembler* masm = new MacroAssembler(&code); address start = __ pc(); @@ -3616,7 +3626,7 @@ RuntimeStub* SharedRuntime::generate_jfr_write_checkpoint() { oop_maps->add_gc_map(frame_complete, map); RuntimeStub* stub = - RuntimeStub::new_runtime_stub(code.name(), + RuntimeStub::new_runtime_stub(name, &code, frame_complete, (framesize >> (LogBytesPerWord - LogBytesPerInt)), @@ -3635,7 +3645,8 @@ RuntimeStub* SharedRuntime::generate_jfr_return_lease() { framesize // inclusive of return address }; - CodeBuffer code("jfr_return_lease", 1024, 64); + const char* name = SharedRuntime::stub_name(SharedStubId::jfr_return_lease_id); + CodeBuffer code(name, 1024, 64); MacroAssembler* masm = new MacroAssembler(&code); address start = __ pc(); @@ -3657,7 +3668,7 @@ RuntimeStub* SharedRuntime::generate_jfr_return_lease() { oop_maps->add_gc_map(frame_complete, map); RuntimeStub* stub = - RuntimeStub::new_runtime_stub(code.name(), + RuntimeStub::new_runtime_stub(name, &code, frame_complete, (framesize >> (LogBytesPerWord - LogBytesPerInt)), diff --git a/src/hotspot/cpu/x86/stubGenerator_x86_64.cpp b/src/hotspot/cpu/x86/stubGenerator_x86_64.cpp index 2bc4a0a9cba..ee6311c25f6 100644 --- a/src/hotspot/cpu/x86/stubGenerator_x86_64.cpp +++ b/src/hotspot/cpu/x86/stubGenerator_x86_64.cpp @@ -24,6 +24,7 @@ #include "precompiled.hpp" #include "asm/macroAssembler.hpp" +#include "classfile/javaClasses.hpp" #include "classfile/vmIntrinsics.hpp" #include "compiler/oopMap.hpp" #include "gc/shared/barrierSet.hpp" @@ -3573,6 +3574,9 @@ void StubGenerator::generate_libm_stubs() { if (vmIntrinsics::is_intrinsic_available(vmIntrinsics::_dtan)) { StubRoutines::_dtan = generate_libmTan(); // from stubGenerator_x86_64_tan.cpp } + if (vmIntrinsics::is_intrinsic_available(vmIntrinsics::_dtanh)) { + StubRoutines::_dtanh = generate_libmTanh(); // from stubGenerator_x86_64_tanh.cpp + } if (vmIntrinsics::is_intrinsic_available(vmIntrinsics::_dexp)) { StubRoutines::_dexp = generate_libmExp(); // from stubGenerator_x86_64_exp.cpp } @@ -3793,6 +3797,28 @@ address StubGenerator::generate_upcall_stub_exception_handler() { return start; } +// load Method* target of MethodHandle +// j_rarg0 = jobject receiver +// rbx = result +address StubGenerator::generate_upcall_stub_load_target() { + StubCodeMark mark(this, "StubRoutines", "upcall_stub_load_target"); + address start = __ pc(); + + __ resolve_global_jobject(j_rarg0, r15_thread, rscratch1); + // Load target method from receiver + __ load_heap_oop(rbx, Address(j_rarg0, java_lang_invoke_MethodHandle::form_offset()), rscratch1); + __ load_heap_oop(rbx, Address(rbx, java_lang_invoke_LambdaForm::vmentry_offset()), rscratch1); + __ load_heap_oop(rbx, Address(rbx, java_lang_invoke_MemberName::method_offset()), rscratch1); + __ access_load_at(T_ADDRESS, IN_HEAP, rbx, + Address(rbx, java_lang_invoke_ResolvedMethodName::vmtarget_offset()), + noreg, noreg); + __ movptr(Address(r15_thread, JavaThread::callee_target_offset()), rbx); // just in case callee is deoptimized + + __ ret(0); + + return start; +} + address StubGenerator::generate_lookup_secondary_supers_table_stub(u1 super_klass_index) { StubCodeMark mark(this, "StubRoutines", "lookup_secondary_supers_table"); @@ -3952,6 +3978,7 @@ void StubGenerator::generate_final_stubs() { } StubRoutines::_upcall_stub_exception_handler = generate_upcall_stub_exception_handler(); + StubRoutines::_upcall_stub_load_target = generate_upcall_stub_load_target(); } void StubGenerator::generate_compiler_stubs() { @@ -4157,41 +4184,41 @@ void StubGenerator::generate_compiler_stubs() { log_info(library)("Loaded library %s, handle " INTPTR_FORMAT, JNI_LIB_PREFIX "jsvml" JNI_LIB_SUFFIX, p2i(libjsvml)); if (UseAVX > 2) { - for (int op = 0; op < VectorSupport::NUM_SVML_OP; op++) { - int vop = VectorSupport::VECTOR_OP_SVML_START + op; + for (int op = 0; op < VectorSupport::NUM_VECTOR_OP_MATH; op++) { + int vop = VectorSupport::VECTOR_OP_MATH_START + op; if ((!VM_Version::supports_avx512dq()) && (vop == VectorSupport::VECTOR_OP_LOG || vop == VectorSupport::VECTOR_OP_LOG10 || vop == VectorSupport::VECTOR_OP_POW)) { continue; } - snprintf(ebuf, sizeof(ebuf), "__jsvml_%sf16_ha_z0", VectorSupport::svmlname[op]); + snprintf(ebuf, sizeof(ebuf), "__jsvml_%sf16_ha_z0", VectorSupport::mathname[op]); StubRoutines::_vector_f_math[VectorSupport::VEC_SIZE_512][op] = (address)os::dll_lookup(libjsvml, ebuf); - snprintf(ebuf, sizeof(ebuf), "__jsvml_%s8_ha_z0", VectorSupport::svmlname[op]); + snprintf(ebuf, sizeof(ebuf), "__jsvml_%s8_ha_z0", VectorSupport::mathname[op]); StubRoutines::_vector_d_math[VectorSupport::VEC_SIZE_512][op] = (address)os::dll_lookup(libjsvml, ebuf); } } const char* avx_sse_str = (UseAVX >= 2) ? "l9" : ((UseAVX == 1) ? "e9" : "ex"); - for (int op = 0; op < VectorSupport::NUM_SVML_OP; op++) { - int vop = VectorSupport::VECTOR_OP_SVML_START + op; + for (int op = 0; op < VectorSupport::NUM_VECTOR_OP_MATH; op++) { + int vop = VectorSupport::VECTOR_OP_MATH_START + op; if (vop == VectorSupport::VECTOR_OP_POW) { continue; } - snprintf(ebuf, sizeof(ebuf), "__jsvml_%sf4_ha_%s", VectorSupport::svmlname[op], avx_sse_str); + snprintf(ebuf, sizeof(ebuf), "__jsvml_%sf4_ha_%s", VectorSupport::mathname[op], avx_sse_str); StubRoutines::_vector_f_math[VectorSupport::VEC_SIZE_64][op] = (address)os::dll_lookup(libjsvml, ebuf); - snprintf(ebuf, sizeof(ebuf), "__jsvml_%sf4_ha_%s", VectorSupport::svmlname[op], avx_sse_str); + snprintf(ebuf, sizeof(ebuf), "__jsvml_%sf4_ha_%s", VectorSupport::mathname[op], avx_sse_str); StubRoutines::_vector_f_math[VectorSupport::VEC_SIZE_128][op] = (address)os::dll_lookup(libjsvml, ebuf); - snprintf(ebuf, sizeof(ebuf), "__jsvml_%sf8_ha_%s", VectorSupport::svmlname[op], avx_sse_str); + snprintf(ebuf, sizeof(ebuf), "__jsvml_%sf8_ha_%s", VectorSupport::mathname[op], avx_sse_str); StubRoutines::_vector_f_math[VectorSupport::VEC_SIZE_256][op] = (address)os::dll_lookup(libjsvml, ebuf); - snprintf(ebuf, sizeof(ebuf), "__jsvml_%s1_ha_%s", VectorSupport::svmlname[op], avx_sse_str); + snprintf(ebuf, sizeof(ebuf), "__jsvml_%s1_ha_%s", VectorSupport::mathname[op], avx_sse_str); StubRoutines::_vector_d_math[VectorSupport::VEC_SIZE_64][op] = (address)os::dll_lookup(libjsvml, ebuf); - snprintf(ebuf, sizeof(ebuf), "__jsvml_%s2_ha_%s", VectorSupport::svmlname[op], avx_sse_str); + snprintf(ebuf, sizeof(ebuf), "__jsvml_%s2_ha_%s", VectorSupport::mathname[op], avx_sse_str); StubRoutines::_vector_d_math[VectorSupport::VEC_SIZE_128][op] = (address)os::dll_lookup(libjsvml, ebuf); - snprintf(ebuf, sizeof(ebuf), "__jsvml_%s4_ha_%s", VectorSupport::svmlname[op], avx_sse_str); + snprintf(ebuf, sizeof(ebuf), "__jsvml_%s4_ha_%s", VectorSupport::mathname[op], avx_sse_str); StubRoutines::_vector_d_math[VectorSupport::VEC_SIZE_256][op] = (address)os::dll_lookup(libjsvml, ebuf); } } diff --git a/src/hotspot/cpu/x86/stubGenerator_x86_64.hpp b/src/hotspot/cpu/x86/stubGenerator_x86_64.hpp index d65c681585d..7280e9fbe95 100644 --- a/src/hotspot/cpu/x86/stubGenerator_x86_64.hpp +++ b/src/hotspot/cpu/x86/stubGenerator_x86_64.hpp @@ -376,11 +376,22 @@ class StubGenerator: public StubCodeGenerator { void roundDec(XMMRegister key, int rnum); void lastroundDec(XMMRegister key, int rnum); void gfmul_avx512(XMMRegister ghash, XMMRegister hkey); - void generateHtbl_48_block_zmm(Register htbl, Register avx512_subkeyHtbl, Register rscratch); - void ghash16_encrypt16_parallel(Register key, Register subkeyHtbl, XMMRegister ctr_blockx, - XMMRegister aad_hashx, Register in, Register out, Register data, Register pos, bool reduction, - XMMRegister addmask, bool no_ghash_input, Register rounds, Register ghash_pos, - bool final_reduction, int index, XMMRegister counter_inc_mask); + void ghash16_encrypt_parallel16_avx512(Register in, Register out, Register ct, Register pos, Register avx512_subkeyHtbl, + Register CTR_CHECK, Register NROUNDS, Register key, XMMRegister CTR, XMMRegister GHASH, + XMMRegister ADDBE_4x4, XMMRegister ADDBE_1234, XMMRegister ADD_1234, XMMRegister SHUF_MASK, + bool hk_broadcast, bool is_hash_start, bool do_hash_reduction, bool do_hash_hxor, + bool no_ghash_in, int ghashin_offset, int aesout_offset, int hashkey_offset); + void generateHtbl_32_blocks_avx512(Register htbl, Register avx512_htbl); + void initial_blocks_16_avx512(Register in, Register out, Register ct, Register pos, Register key, Register avx512_subkeyHtbl, + Register CTR_CHECK, Register rounds, XMMRegister CTR, XMMRegister GHASH, XMMRegister ADDBE_4x4, + XMMRegister ADDBE_1234, XMMRegister ADD_1234, XMMRegister SHUF_MASK, int stack_offset); + void gcm_enc_dec_last_avx512(Register len, Register in, Register pos, XMMRegister HASH, XMMRegister SHUFM, Register subkeyHtbl, + int ghashin_offset, int hashkey_offset, bool start_ghash, bool do_reduction); + void ghash16_avx512(bool start_ghash, bool do_reduction, bool uload_shuffle, bool hk_broadcast, bool do_hxor, + Register in, Register pos, Register subkeyHtbl, XMMRegister HASH, XMMRegister SHUFM, int in_offset, + int in_disp, int displacement, int hashkey_offset); + void aesgcm_avx512(Register in, Register len, Register ct, Register out, Register key, + Register state, Register subkeyHtbl, Register avx512_subkeyHtbl, Register counter); // AVX2 AES-GCM related functions void initial_blocks_avx2(XMMRegister ctr, Register rounds, Register key, Register len, Register in, Register out, Register ct, XMMRegister aad_hashx, Register pos); @@ -546,6 +557,7 @@ class StubGenerator: public StubCodeGenerator { address generate_libmSin(); address generate_libmCos(); address generate_libmTan(); + address generate_libmTanh(); address generate_libmExp(); address generate_libmPow(); address generate_libmLog(); @@ -608,6 +620,7 @@ class StubGenerator: public StubCodeGenerator { // shared exception handler for FFM upcall stubs address generate_upcall_stub_exception_handler(); + address generate_upcall_stub_load_target(); // Specialized stub implementations for UseSecondarySupersTable. address generate_lookup_secondary_supers_table_stub(u1 super_klass_index); diff --git a/src/hotspot/cpu/x86/stubGenerator_x86_64_aes.cpp b/src/hotspot/cpu/x86/stubGenerator_x86_64_aes.cpp index 9744169498c..f14d368c376 100644 --- a/src/hotspot/cpu/x86/stubGenerator_x86_64_aes.cpp +++ b/src/hotspot/cpu/x86/stubGenerator_x86_64_aes.cpp @@ -1,5 +1,5 @@ /* -* Copyright (c) 2019, 2023, Intel Corporation. All rights reserved. +* Copyright (c) 2019, 2024, Intel Corporation. All rights reserved. * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -172,6 +172,38 @@ static address ghash_polynomial_two_one_addr() { return (address)GHASH_POLYNOMIAL_TWO_ONE; } +// This mask is used for incrementing counter value +ATTRIBUTE_ALIGNED(64) static const uint64_t COUNTER_MASK_ADDBE_4444[] = { + 0x0000000000000000ULL, 0x0400000000000000ULL, + 0x0000000000000000ULL, 0x0400000000000000ULL, + 0x0000000000000000ULL, 0x0400000000000000ULL, + 0x0000000000000000ULL, 0x0400000000000000ULL, +}; +static address counter_mask_addbe_4444_addr() { + return (address)COUNTER_MASK_ADDBE_4444; +} + +// This mask is used for incrementing counter value +ATTRIBUTE_ALIGNED(64) static const uint64_t COUNTER_MASK_ADDBE_1234[] = { + 0x0000000000000000ULL, 0x0100000000000000ULL, + 0x0000000000000000ULL, 0x0200000000000000ULL, + 0x0000000000000000ULL, 0x0300000000000000ULL, + 0x0000000000000000ULL, 0x0400000000000000ULL, +}; +static address counter_mask_addbe_1234_addr() { + return (address)COUNTER_MASK_ADDBE_1234; +} + +// This mask is used for incrementing counter value +ATTRIBUTE_ALIGNED(64) static const uint64_t COUNTER_MASK_ADD_1234[] = { + 0x0000000000000001ULL, 0x0000000000000000ULL, + 0x0000000000000002ULL, 0x0000000000000000ULL, + 0x0000000000000003ULL, 0x0000000000000000ULL, + 0x0000000000000004ULL, 0x0000000000000000ULL, +}; +static address counter_mask_add_1234_addr() { + return (address)COUNTER_MASK_ADD_1234; +} // AES intrinsic stubs @@ -209,10 +241,10 @@ void StubGenerator::generate_aes_stubs() { // len = rdx (c_rarg1) | rdi (c_rarg1) // ct = r8 (c_rarg2) | rdx (c_rarg2) // out = r9 (c_rarg3) | rcx (c_rarg3) -// key = r10 | r8 (c_rarg4) -// state = r13 | r9 (c_rarg5) -// subkeyHtbl = r14 | r11 -// counter = rsi | r12 +// key = rsi | r8 (c_rarg4) +// state = rdi | r9 (c_rarg5) +// subkeyHtbl = r10 | r10 +// counter = r11 | r11 // // Output: // rax - number of processed bytes @@ -230,31 +262,31 @@ address StubGenerator::generate_galoisCounterMode_AESCrypt() { const Register key = c_rarg4; const Register state = c_rarg5; const Address subkeyH_mem(rbp, 2 * wordSize); - const Register subkeyHtbl = r11; - const Register avx512_subkeyHtbl = r13; + const Register subkeyHtbl = r10; + const Register avx512_subkeyHtbl = r12; const Address counter_mem(rbp, 3 * wordSize); - const Register counter = r12; + const Register counter = r11; #else const Address key_mem(rbp, 6 * wordSize); - const Register key = r10; + const Register key = rsi; const Address state_mem(rbp, 7 * wordSize); - const Register state = r13; + const Register state = rdi; const Address subkeyH_mem(rbp, 8 * wordSize); - const Register subkeyHtbl = r14; + const Register subkeyHtbl = r10; const Register avx512_subkeyHtbl = r12; const Address counter_mem(rbp, 9 * wordSize); - const Register counter = rsi; + const Register counter = r11; #endif __ enter(); // Save state before entering routine - __ push(r12); - __ push(r13); - __ push(r14); - __ push(r15); - __ push(rbx); + __ push(r12);//holds pointer to avx512_subkeyHtbl + __ push(r14);//holds CTR_CHECK value to check for overflow + __ push(r15);//holds number of rounds + __ push(rbx);//scratch register #ifdef _WIN64 // on win64, fill len_reg from stack position __ push(rsi); + __ push(rdi); __ movptr(key, key_mem); __ movptr(state, state_mem); #endif @@ -262,24 +294,24 @@ address StubGenerator::generate_galoisCounterMode_AESCrypt() { __ movptr(counter, counter_mem); // Align stack __ andq(rsp, -64); - __ subptr(rsp, 96 * longSize); // Create space on the stack for htbl entries + __ subptr(rsp, 200 * longSize); // Create space on the stack for 64 htbl entries and 8 zmm AES entries __ movptr(avx512_subkeyHtbl, rsp); - aesgcm_encrypt(in, len, ct, out, key, state, subkeyHtbl, avx512_subkeyHtbl, counter); + aesgcm_avx512(in, len, ct, out, key, state, subkeyHtbl, avx512_subkeyHtbl, counter); __ vzeroupper(); // Restore state before leaving routine #ifdef _WIN64 __ lea(rsp, Address(rbp, -6 * wordSize)); + __ pop(rdi); __ pop(rsi); #else - __ lea(rsp, Address(rbp, -5 * wordSize)); + __ lea(rsp, Address(rbp, -4 * wordSize)); #endif __ pop(rbx); __ pop(r15); __ pop(r14); - __ pop(r13); __ pop(r12); __ leave(); // required for proper stackwalking of RuntimeStub frame @@ -2708,87 +2740,100 @@ void StubGenerator::gfmul_avx512(XMMRegister GH, XMMRegister HK) { __ vpternlogq(GH, 0x96, TMP1, TMP2, Assembler::AVX_512bit); } -void StubGenerator::generateHtbl_48_block_zmm(Register htbl, Register avx512_htbl, Register rscratch) { +// Holds 64 Htbl entries, 32 HKey and 32 HkKey (derived from HKey) +void StubGenerator::generateHtbl_32_blocks_avx512(Register htbl, Register avx512_htbl) { const XMMRegister HK = xmm6; - const XMMRegister ZT5 = xmm4; - const XMMRegister ZT7 = xmm7; - const XMMRegister ZT8 = xmm8; - - Label GFMUL_AVX512; + const XMMRegister ZT1 = xmm0, ZT2 = xmm1, ZT3 = xmm2, ZT4 = xmm3; + const XMMRegister ZT5 = xmm4, ZT6 = xmm5, ZT7 = xmm7, ZT8 = xmm8; + const XMMRegister ZT10 = xmm10, ZT11 = xmm11, ZT12 = xmm12; __ movdqu(HK, Address(htbl, 0)); - __ movdqu(xmm10, ExternalAddress(ghash_long_swap_mask_addr()), rscratch); - __ vpshufb(HK, HK, xmm10, Assembler::AVX_128bit); - - __ movdqu(xmm11, ExternalAddress(ghash_polynomial_addr()), rscratch); - __ movdqu(xmm12, ExternalAddress(ghash_polynomial_two_one_addr()), rscratch); + __ movdqu(ZT10, ExternalAddress(ghash_long_swap_mask_addr()), r15); + __ vpshufb(HK, HK, ZT10, Assembler::AVX_128bit); + __ movdqu(ZT11, ExternalAddress(ghash_polynomial_addr()), r15); + __ movdqu(ZT12, ExternalAddress(ghash_polynomial_two_one_addr()), r15); // Compute H ^ 2 from the input subkeyH - __ movdqu(xmm2, xmm6); - __ vpsllq(xmm6, xmm6, 1, Assembler::AVX_128bit); - __ vpsrlq(xmm2, xmm2, 63, Assembler::AVX_128bit); - __ movdqu(xmm1, xmm2); - __ vpslldq(xmm2, xmm2, 8, Assembler::AVX_128bit); - __ vpsrldq(xmm1, xmm1, 8, Assembler::AVX_128bit); - __ vpor(xmm6, xmm6, xmm2, Assembler::AVX_128bit); + __ movdqu(ZT3, HK); + __ vpsllq(HK, HK, 1, Assembler::AVX_128bit); + __ vpsrlq(ZT3, ZT3, 63, Assembler::AVX_128bit); + __ movdqu(ZT2, ZT3); + __ vpslldq(ZT3, ZT3, 8, Assembler::AVX_128bit); + __ vpsrldq(ZT2, ZT2, 8, Assembler::AVX_128bit); + __ vpor(HK, HK, ZT3, Assembler::AVX_128bit); + __ vpshufd(ZT3, ZT2, 0x24, Assembler::AVX_128bit); + __ vpcmpeqd(ZT3, ZT3, ZT12, Assembler::AVX_128bit); + __ vpand(ZT3, ZT3, ZT11, Assembler::AVX_128bit); + __ vpxor(HK, HK, ZT3, Assembler::AVX_128bit); + __ movdqu(Address(avx512_htbl, 16 * 31), HK); // H ^ 2 - __ vpshufd(xmm2, xmm1, 0x24, Assembler::AVX_128bit); - __ vpcmpeqd(xmm2, xmm2, xmm12, Assembler::AVX_128bit); - __ vpand(xmm2, xmm2, xmm11, Assembler::AVX_128bit); - __ vpxor(xmm6, xmm6, xmm2, Assembler::AVX_128bit); - __ movdqu(Address(avx512_htbl, 16 * 47), xmm6); // H ^ 2 - // Compute the remaining three powers of H using XMM registers and all following powers using ZMM __ movdqu(ZT5, HK); - __ vinserti32x4(ZT7, ZT7, HK, 3); + __ evinserti64x2(ZT7, ZT7, HK, 3, Assembler::AVX_512bit); + //calculate HashKey ^ 2 << 1 mod poly gfmul_avx512(ZT5, HK); - __ movdqu(Address(avx512_htbl, 16 * 46), ZT5); // H ^ 2 * 2 - __ vinserti32x4(ZT7, ZT7, ZT5, 2); + __ movdqu(Address(avx512_htbl, 16 * 30), ZT5); + __ evinserti64x2(ZT7, ZT7, ZT5, 2, Assembler::AVX_512bit); + //calculate HashKey ^ 3 << 1 mod poly gfmul_avx512(ZT5, HK); - __ movdqu(Address(avx512_htbl, 16 * 45), ZT5); // H ^ 2 * 3 - __ vinserti32x4(ZT7, ZT7, ZT5, 1); + __ movdqu(Address(avx512_htbl, 16 * 29), ZT5); + __ evinserti64x2(ZT7, ZT7, ZT5, 1, Assembler::AVX_512bit); + //calculate HashKey ^ 4 << 1 mod poly gfmul_avx512(ZT5, HK); - __ movdqu(Address(avx512_htbl, 16 * 44), ZT5); // H ^ 2 * 4 - __ vinserti32x4(ZT7, ZT7, ZT5, 0); + __ movdqu(Address(avx512_htbl, 16 * 28), ZT5); + __ evinserti64x2(ZT7, ZT7, ZT5, 0, Assembler::AVX_512bit); + // ZT5 amd ZT7 to be cleared(hash key) + //calculate HashKeyK = HashKey x POLY + __ evmovdquq(xmm11, ExternalAddress(ghash_polynomial_addr()), Assembler::AVX_512bit, r15); + __ evpclmulqdq(ZT1, ZT7, xmm11, 0x10, Assembler::AVX_512bit); + __ vpshufd(ZT2, ZT7, 78, Assembler::AVX_512bit); + __ evpxorq(ZT1, ZT1, ZT2, Assembler::AVX_512bit); + __ evmovdquq(Address(avx512_htbl, 16 * 60), ZT1, Assembler::AVX_512bit); + //**ZT1 amd ZT2 to be cleared(hash key) - __ evshufi64x2(ZT5, ZT5, ZT5, 0x00, Assembler::AVX_512bit); - __ evmovdquq(ZT8, ZT7, Assembler::AVX_512bit); - gfmul_avx512(ZT7, ZT5); - __ evmovdquq(Address(avx512_htbl, 16 * 40), ZT7, Assembler::AVX_512bit); - __ evshufi64x2(ZT5, ZT7, ZT7, 0x00, Assembler::AVX_512bit); - gfmul_avx512(ZT8, ZT5); - __ evmovdquq(Address(avx512_htbl, 16 * 36), ZT8, Assembler::AVX_512bit); - gfmul_avx512(ZT7, ZT5); - __ evmovdquq(Address(avx512_htbl, 16 * 32), ZT7, Assembler::AVX_512bit); - gfmul_avx512(ZT8, ZT5); - __ evmovdquq(Address(avx512_htbl, 16 * 28), ZT8, Assembler::AVX_512bit); - gfmul_avx512(ZT7, ZT5); - __ evmovdquq(Address(avx512_htbl, 16 * 24), ZT7, Assembler::AVX_512bit); - gfmul_avx512(ZT8, ZT5); - __ evmovdquq(Address(avx512_htbl, 16 * 20), ZT8, Assembler::AVX_512bit); - gfmul_avx512(ZT7, ZT5); - __ evmovdquq(Address(avx512_htbl, 16 * 16), ZT7, Assembler::AVX_512bit); - gfmul_avx512(ZT8, ZT5); - __ evmovdquq(Address(avx512_htbl, 16 * 12), ZT8, Assembler::AVX_512bit); - gfmul_avx512(ZT7, ZT5); - __ evmovdquq(Address(avx512_htbl, 16 * 8), ZT7, Assembler::AVX_512bit); - gfmul_avx512(ZT8, ZT5); - __ evmovdquq(Address(avx512_htbl, 16 * 4), ZT8, Assembler::AVX_512bit); - gfmul_avx512(ZT7, ZT5); - __ evmovdquq(Address(avx512_htbl, 16 * 0), ZT7, Assembler::AVX_512bit); - __ ret(0); -} + //switch to 4x128 - bit computations now + __ evshufi64x2(ZT5, ZT5, ZT5, 0x00, Assembler::AVX_512bit); //;; broadcast HashKey ^ 4 across all ZT5 + __ evmovdquq(ZT8, ZT7, Assembler::AVX_512bit);//; save HashKey ^ 4 to HashKey ^ 1 in ZT8 + //**ZT8 to be cleared(hash key) -#define vclmul_reduce(out, poly, hi128, lo128, tmp0, tmp1) \ -__ evpclmulqdq(tmp0, poly, lo128, 0x01, Assembler::AVX_512bit); \ -__ vpslldq(tmp0, tmp0, 8, Assembler::AVX_512bit); \ -__ evpxorq(tmp0, lo128, tmp0, Assembler::AVX_512bit); \ -__ evpclmulqdq(tmp1, poly, tmp0, 0x00, Assembler::AVX_512bit); \ -__ vpsrldq(tmp1, tmp1, 4, Assembler::AVX_512bit); \ -__ evpclmulqdq(out, poly, tmp0, 0x10, Assembler::AVX_512bit); \ -__ vpslldq(out, out, 4, Assembler::AVX_512bit); \ -__ vpternlogq(out, 0x96, tmp1, hi128, Assembler::AVX_512bit); \ + //calculate HashKey ^ 5 << 1 mod poly, HashKey ^ 6 << 1 mod poly, ... HashKey ^ 8 << 1 mod poly + gfmul_avx512(ZT7, ZT5); + __ evmovdquq(Address(avx512_htbl, 16 * 24), ZT7, Assembler::AVX_512bit);//; HashKey ^ 8 to HashKey ^ 5 in ZT7 now + + //calculate HashKeyX = HashKey x POLY + __ evpclmulqdq(ZT1, ZT7, xmm11, 0x10, Assembler::AVX_512bit); + __ vpshufd(ZT2, ZT7, 78, Assembler::AVX_512bit); + __ evpxorq(ZT1, ZT1, ZT2, Assembler::AVX_512bit); + __ evmovdquq(Address(avx512_htbl, 16 * 56), ZT1, Assembler::AVX_512bit); + + __ evshufi64x2(ZT5, ZT7, ZT7, 0x00, Assembler::AVX_512bit);//;; broadcast HashKey ^ 8 across all ZT5 + + for (int i = 20, j = 52; i > 0;) { + gfmul_avx512(ZT8, ZT5); + __ evmovdquq(Address(avx512_htbl, 16 * i), ZT8, Assembler::AVX_512bit); + //calculate HashKeyK = HashKey x POLY + __ evpclmulqdq(ZT1, ZT8, xmm11, 0x10, Assembler::AVX_512bit); + __ vpshufd(ZT2, ZT8, 78, Assembler::AVX_512bit); + __ evpxorq(ZT1, ZT1, ZT2, Assembler::AVX_512bit); + __ evmovdquq(Address(avx512_htbl, 16 * j), ZT1, Assembler::AVX_512bit); + + i -= 4; + j -= 4; + //compute HashKey ^ (8 + n), HashKey ^ (7 + n), ... HashKey ^ (5 + n) + gfmul_avx512(ZT7, ZT5); + __ evmovdquq(Address(avx512_htbl, 16 * i), ZT7, Assembler::AVX_512bit); + + //calculate HashKeyK = HashKey x POLY + __ evpclmulqdq(ZT1, ZT7, xmm11, 0x10, Assembler::AVX_512bit); + __ vpshufd(ZT2, ZT7, 78, Assembler::AVX_512bit); + __ evpxorq(ZT1, ZT1, ZT2, Assembler::AVX_512bit); + __ evmovdquq(Address(avx512_htbl, 16 * j), ZT1, Assembler::AVX_512bit); + + i -= 4; + j -= 4; + } + } #define vhpxori4x128(reg, tmp) \ __ vextracti64x4(tmp, reg, 1); \ @@ -2820,21 +2865,17 @@ __ evmovdquq(dst2, Address(src, position, Address::times_1, 1 * 64), Assembler:: __ evmovdquq(dst3, Address(src, position, Address::times_1, 2 * 64), Assembler::AVX_512bit); \ __ evmovdquq(dst4, Address(src, position, Address::times_1, 3 * 64), Assembler::AVX_512bit); \ -#define carrylessMultiply(dst00, dst01, dst10, dst11, ghdata, hkey) \ -__ evpclmulqdq(dst00, ghdata, hkey, 0x00, Assembler::AVX_512bit); \ -__ evpclmulqdq(dst01, ghdata, hkey, 0x01, Assembler::AVX_512bit); \ -__ evpclmulqdq(dst10, ghdata, hkey, 0x10, Assembler::AVX_512bit); \ -__ evpclmulqdq(dst11, ghdata, hkey, 0x11, Assembler::AVX_512bit); \ +#define carrylessMultiply(dst00, dst01, dst10, dst11, ghdata, hkey2, hkey1) \ +__ evpclmulqdq(dst00, ghdata, hkey2, 0x00, Assembler::AVX_512bit); \ +__ evpclmulqdq(dst01, ghdata, hkey2, 0x10, Assembler::AVX_512bit); \ +__ evpclmulqdq(dst10, ghdata, hkey1, 0x01, Assembler::AVX_512bit); \ +__ evpclmulqdq(dst11, ghdata, hkey1, 0x11, Assembler::AVX_512bit); \ -#define shuffleExorRnd1Key(dst0, dst1, dst2, dst3, shufmask, rndkey) \ -__ vpshufb(dst0, dst0, shufmask, Assembler::AVX_512bit); \ -__ evpxorq(dst0, dst0, rndkey, Assembler::AVX_512bit); \ -__ vpshufb(dst1, dst1, shufmask, Assembler::AVX_512bit); \ -__ evpxorq(dst1, dst1, rndkey, Assembler::AVX_512bit); \ -__ vpshufb(dst2, dst2, shufmask, Assembler::AVX_512bit); \ -__ evpxorq(dst2, dst2, rndkey, Assembler::AVX_512bit); \ -__ vpshufb(dst3, dst3, shufmask, Assembler::AVX_512bit); \ -__ evpxorq(dst3, dst3, rndkey, Assembler::AVX_512bit); \ +#define shuffle(dst0, dst1, dst2, dst3, src0, src1, src2, src3, shufmask) \ +__ vpshufb(dst0, src0, shufmask, Assembler::AVX_512bit); \ +__ vpshufb(dst1, src1, shufmask, Assembler::AVX_512bit); \ +__ vpshufb(dst2, src2, shufmask, Assembler::AVX_512bit); \ +__ vpshufb(dst3, src3, shufmask, Assembler::AVX_512bit); \ #define xorBeforeStore(dst0, dst1, dst2, dst3, src0, src1, src2, src3) \ __ evpxorq(dst0, dst0, src0, Assembler::AVX_512bit); \ @@ -2848,211 +2889,462 @@ __ vpternlogq(dst1, 0x96, src12, src13, Assembler::AVX_512bit); \ __ vpternlogq(dst2, 0x96, src22, src23, Assembler::AVX_512bit); \ __ vpternlogq(dst3, 0x96, src32, src33, Assembler::AVX_512bit); \ -void StubGenerator::ghash16_encrypt16_parallel(Register key, Register subkeyHtbl, XMMRegister ctr_blockx, XMMRegister aad_hashx, - Register in, Register out, Register data, Register pos, bool first_time_reduction, XMMRegister addmask, bool ghash_input, Register rounds, - Register ghash_pos, bool final_reduction, int i, XMMRegister counter_inc_mask) { - Label AES_192, AES_256, LAST_AES_RND; +//schoolbook multiply of 16 blocks(8 x 16 bytes) +//it is assumed that data read is already shuffledand +void StubGenerator::ghash16_avx512(bool start_ghash, bool do_reduction, bool uload_shuffle, bool hk_broadcast, bool do_hxor, + Register in, Register pos, Register subkeyHtbl, XMMRegister HASH, XMMRegister SHUFM, int in_offset, + int in_disp, int displacement, int hashkey_offset) { const XMMRegister ZTMP0 = xmm0; const XMMRegister ZTMP1 = xmm3; const XMMRegister ZTMP2 = xmm4; const XMMRegister ZTMP3 = xmm5; + const XMMRegister ZTMP4 = xmm6; const XMMRegister ZTMP5 = xmm7; const XMMRegister ZTMP6 = xmm10; const XMMRegister ZTMP7 = xmm11; const XMMRegister ZTMP8 = xmm12; const XMMRegister ZTMP9 = xmm13; - const XMMRegister ZTMP10 = xmm15; - const XMMRegister ZTMP11 = xmm16; - const XMMRegister ZTMP12 = xmm17; + const XMMRegister ZTMPA = xmm26; + const XMMRegister ZTMPB = xmm23; + const XMMRegister GH = xmm24; + const XMMRegister GL = xmm25; + const int hkey_gap = 16 * 32; - const XMMRegister ZTMP13 = xmm19; - const XMMRegister ZTMP14 = xmm20; - const XMMRegister ZTMP15 = xmm21; - const XMMRegister ZTMP16 = xmm30; - const XMMRegister ZTMP17 = xmm31; - const XMMRegister ZTMP18 = xmm1; - const XMMRegister ZTMP19 = xmm2; - const XMMRegister ZTMP20 = xmm8; - const XMMRegister ZTMP21 = xmm22; - const XMMRegister ZTMP22 = xmm23; - - // Pre increment counters - __ vpaddd(ZTMP0, ctr_blockx, counter_inc_mask, Assembler::AVX_512bit); - __ vpaddd(ZTMP1, ZTMP0, counter_inc_mask, Assembler::AVX_512bit); - __ vpaddd(ZTMP2, ZTMP1, counter_inc_mask, Assembler::AVX_512bit); - __ vpaddd(ZTMP3, ZTMP2, counter_inc_mask, Assembler::AVX_512bit); - // Save counter value - __ evmovdquq(ctr_blockx, ZTMP3, Assembler::AVX_512bit); - - // Reuse ZTMP17 / ZTMP18 for loading AES Keys - // Pre-load AES round keys - ev_load_key(ZTMP17, key, 0, xmm29); - ev_load_key(ZTMP18, key, 1 * 16, xmm29); - - // ZTMP19 & ZTMP20 used for loading hash key - // Pre-load hash key - __ evmovdquq(ZTMP19, Address(subkeyHtbl, i * 64), Assembler::AVX_512bit); - __ evmovdquq(ZTMP20, Address(subkeyHtbl, ++i * 64), Assembler::AVX_512bit); - // Load data for computing ghash - __ evmovdquq(ZTMP21, Address(data, ghash_pos, Address::times_1, 0 * 64), Assembler::AVX_512bit); - __ vpshufb(ZTMP21, ZTMP21, xmm24, Assembler::AVX_512bit); - - // Xor cipher block 0 with input ghash, if available - if (ghash_input) { - __ evpxorq(ZTMP21, ZTMP21, aad_hashx, Assembler::AVX_512bit); - } - // Load data for computing ghash - __ evmovdquq(ZTMP22, Address(data, ghash_pos, Address::times_1, 1 * 64), Assembler::AVX_512bit); - __ vpshufb(ZTMP22, ZTMP22, xmm24, Assembler::AVX_512bit); - - // stitch AES rounds with GHASH - // AES round 0, xmm24 has shuffle mask - shuffleExorRnd1Key(ZTMP0, ZTMP1, ZTMP2, ZTMP3, xmm24, ZTMP17); - // Reuse ZTMP17 / ZTMP18 for loading remaining AES Keys - ev_load_key(ZTMP17, key, 2 * 16, xmm29); - // GHASH 4 blocks - carrylessMultiply(ZTMP6, ZTMP7, ZTMP8, ZTMP5, ZTMP21, ZTMP19); - // Load the next hkey and Ghash data - __ evmovdquq(ZTMP19, Address(subkeyHtbl, ++i * 64), Assembler::AVX_512bit); - __ evmovdquq(ZTMP21, Address(data, ghash_pos, Address::times_1, 2 * 64), Assembler::AVX_512bit); - __ vpshufb(ZTMP21, ZTMP21, xmm24, Assembler::AVX_512bit); - - // AES round 1 - roundEncode(ZTMP18, ZTMP0, ZTMP1, ZTMP2, ZTMP3); - ev_load_key(ZTMP18, key, 3 * 16, xmm29); - - // GHASH 4 blocks(11 to 8) - carrylessMultiply(ZTMP10, ZTMP12, ZTMP11, ZTMP9, ZTMP22, ZTMP20); - // Load the next hkey and GDATA - __ evmovdquq(ZTMP20, Address(subkeyHtbl, ++i * 64), Assembler::AVX_512bit); - __ evmovdquq(ZTMP22, Address(data, ghash_pos, Address::times_1, 3 * 64), Assembler::AVX_512bit); - __ vpshufb(ZTMP22, ZTMP22, xmm24, Assembler::AVX_512bit); - - // AES round 2 - roundEncode(ZTMP17, ZTMP0, ZTMP1, ZTMP2, ZTMP3); - ev_load_key(ZTMP17, key, 4 * 16, xmm29); - - // GHASH 4 blocks(7 to 4) - carrylessMultiply(ZTMP14, ZTMP16, ZTMP15, ZTMP13, ZTMP21, ZTMP19); - // AES rounds 3 - roundEncode(ZTMP18, ZTMP0, ZTMP1, ZTMP2, ZTMP3); - ev_load_key(ZTMP18, key, 5 * 16, xmm29); - - // Gather(XOR) GHASH for 12 blocks - xorGHASH(ZTMP5, ZTMP6, ZTMP8, ZTMP7, ZTMP9, ZTMP13, ZTMP10, ZTMP14, ZTMP12, ZTMP16, ZTMP11, ZTMP15); - - // AES rounds 4 - roundEncode(ZTMP17, ZTMP0, ZTMP1, ZTMP2, ZTMP3); - ev_load_key(ZTMP17, key, 6 * 16, xmm29); - - // load plain / cipher text(recycle registers) - loadData(in, pos, ZTMP13, ZTMP14, ZTMP15, ZTMP16); - - // AES rounds 5 - roundEncode(ZTMP18, ZTMP0, ZTMP1, ZTMP2, ZTMP3); - ev_load_key(ZTMP18, key, 7 * 16, xmm29); - // GHASH 4 blocks(3 to 0) - carrylessMultiply(ZTMP10, ZTMP12, ZTMP11, ZTMP9, ZTMP22, ZTMP20); - - // AES round 6 - roundEncode(ZTMP17, ZTMP0, ZTMP1, ZTMP2, ZTMP3); - ev_load_key(ZTMP17, key, 8 * 16, xmm29); - - // gather GHASH in ZTMP6(low) and ZTMP5(high) - if (first_time_reduction) { - __ vpternlogq(ZTMP7, 0x96, ZTMP8, ZTMP12, Assembler::AVX_512bit); - __ evpxorq(xmm25, ZTMP7, ZTMP11, Assembler::AVX_512bit); - __ evpxorq(xmm27, ZTMP5, ZTMP9, Assembler::AVX_512bit); - __ evpxorq(xmm26, ZTMP6, ZTMP10, Assembler::AVX_512bit); - } else if (!first_time_reduction && !final_reduction) { - xorGHASH(ZTMP7, xmm25, xmm27, xmm26, ZTMP8, ZTMP12, ZTMP7, ZTMP11, ZTMP5, ZTMP9, ZTMP6, ZTMP10); + if (uload_shuffle) { + __ evmovdquq(ZTMP9, Address(subkeyHtbl, in_offset * 16 + in_disp), Assembler::AVX_512bit); + __ vpshufb(ZTMP9, ZTMP9, SHUFM, Assembler::AVX_512bit); + } else { + __ evmovdquq(ZTMP9, Address(subkeyHtbl, in_offset * 16 + in_disp), Assembler::AVX_512bit); } - if (final_reduction) { - // Phase one: Add mid products together - // Also load polynomial constant for reduction - __ vpternlogq(ZTMP7, 0x96, ZTMP8, ZTMP12, Assembler::AVX_512bit); - __ vpternlogq(ZTMP7, 0x96, xmm25, ZTMP11, Assembler::AVX_512bit); - __ vpsrldq(ZTMP11, ZTMP7, 8, Assembler::AVX_512bit); - __ vpslldq(ZTMP7, ZTMP7, 8, Assembler::AVX_512bit); - __ evmovdquq(ZTMP12, ExternalAddress(ghash_polynomial_reduction_addr()), Assembler::AVX_512bit, rbx /*rscratch*/); + if (start_ghash) { + __ evpxorq(ZTMP9, ZTMP9, HASH, Assembler::AVX_512bit); } - // AES round 7 - roundEncode(ZTMP18, ZTMP0, ZTMP1, ZTMP2, ZTMP3); - ev_load_key(ZTMP18, key, 9 * 16, xmm29); - if (final_reduction) { - __ vpternlogq(ZTMP5, 0x96, ZTMP9, ZTMP11, Assembler::AVX_512bit); - __ evpxorq(ZTMP5, ZTMP5, xmm27, Assembler::AVX_512bit); - __ vpternlogq(ZTMP6, 0x96, ZTMP10, ZTMP7, Assembler::AVX_512bit); - __ evpxorq(ZTMP6, ZTMP6, xmm26, Assembler::AVX_512bit); + if (hk_broadcast) { + __ evbroadcastf64x2(ZTMP8, Address(subkeyHtbl, hashkey_offset + displacement + 0 * 64), Assembler::AVX_512bit); + __ evbroadcastf64x2(ZTMPA, Address(subkeyHtbl, hashkey_offset + displacement + hkey_gap + 0 * 64), Assembler::AVX_512bit); + } else { + __ evmovdquq(ZTMP8, Address(subkeyHtbl, hashkey_offset + displacement + 0 * 64), Assembler::AVX_512bit); + __ evmovdquq(ZTMPA, Address(subkeyHtbl, hashkey_offset + displacement + hkey_gap + 0 * 64), Assembler::AVX_512bit); } - // AES round 8 - roundEncode(ZTMP17, ZTMP0, ZTMP1, ZTMP2, ZTMP3); - ev_load_key(ZTMP17, key, 10 * 16, xmm29); - // Horizontal xor of low and high 4*128 - if (final_reduction) { - vhpxori4x128(ZTMP5, ZTMP9); - vhpxori4x128(ZTMP6, ZTMP10); - } - // AES round 9 - roundEncode(ZTMP18, ZTMP0, ZTMP1, ZTMP2, ZTMP3); - // First phase of reduction - if (final_reduction) { - __ evpclmulqdq(ZTMP10, ZTMP12, ZTMP6, 0x01, Assembler::AVX_128bit); - __ vpslldq(ZTMP10, ZTMP10, 8, Assembler::AVX_128bit); - __ evpxorq(ZTMP10, ZTMP6, ZTMP10, Assembler::AVX_128bit); - } - __ cmpl(rounds, 52); - __ jcc(Assembler::greaterEqual, AES_192); - __ jmp(LAST_AES_RND); - // AES rounds up to 11 (AES192) or 13 (AES256) - __ bind(AES_192); - roundEncode(ZTMP17, ZTMP0, ZTMP1, ZTMP2, ZTMP3); - ev_load_key(ZTMP18, key, 11 * 16, xmm29); - roundEncode(ZTMP18, ZTMP0, ZTMP1, ZTMP2, ZTMP3); - ev_load_key(ZTMP17, key, 12 * 16, xmm29); - __ cmpl(rounds, 60); - __ jcc(Assembler::aboveEqual, AES_256); - __ jmp(LAST_AES_RND); + carrylessMultiply(ZTMP0, ZTMP1, ZTMP2, ZTMP3, ZTMP9, ZTMPA, ZTMP8); - __ bind(AES_256); - roundEncode(ZTMP17, ZTMP0, ZTMP1, ZTMP2, ZTMP3); - ev_load_key(ZTMP18, key, 13 * 16, xmm29); - roundEncode(ZTMP18, ZTMP0, ZTMP1, ZTMP2, ZTMP3); - ev_load_key(ZTMP17, key, 14 * 16, xmm29); - - __ bind(LAST_AES_RND); - // Second phase of reduction - if (final_reduction) { - __ evpclmulqdq(ZTMP9, ZTMP12, ZTMP10, 0x00, Assembler::AVX_128bit); - __ vpsrldq(ZTMP9, ZTMP9, 4, Assembler::AVX_128bit); // Shift-R 1-DW to obtain 2-DWs shift-R - __ evpclmulqdq(ZTMP11, ZTMP12, ZTMP10, 0x10, Assembler::AVX_128bit); - __ vpslldq(ZTMP11, ZTMP11, 4, Assembler::AVX_128bit); // Shift-L 1-DW for result - // ZTMP5 = ZTMP5 X ZTMP11 X ZTMP9 - __ vpternlogq(ZTMP5, 0x96, ZTMP11, ZTMP9, Assembler::AVX_128bit); + //ghash blocks 4 - 7 + if (uload_shuffle) { + __ evmovdquq(ZTMP9, Address(subkeyHtbl, in_offset * 16 + in_disp + 64), Assembler::AVX_512bit); + __ vpshufb(ZTMP9, ZTMP9, SHUFM, Assembler::AVX_512bit); + } else { + __ evmovdquq(ZTMP9, Address(subkeyHtbl, in_offset * 16 + in_disp + 64), Assembler::AVX_512bit); + } + + if (hk_broadcast) { + __ evbroadcastf64x2(ZTMP8, Address(subkeyHtbl, hashkey_offset + displacement + 1 * 64), Assembler::AVX_512bit);; + __ evbroadcastf64x2(ZTMPA, Address(subkeyHtbl, hashkey_offset + displacement + hkey_gap + 1 * 64), Assembler::AVX_512bit); + } else { + __ evmovdquq(ZTMP8, Address(subkeyHtbl, hashkey_offset + displacement + 1 * 64), Assembler::AVX_512bit); + __ evmovdquq(ZTMPA, Address(subkeyHtbl, hashkey_offset + displacement + hkey_gap + 1 * 64), Assembler::AVX_512bit); + } + + carrylessMultiply(ZTMP4, ZTMP5, ZTMP6, ZTMP7, ZTMP9, ZTMPA, ZTMP8); + + //update sums + if (start_ghash) { + __ evpxorq(GL, ZTMP0, ZTMP2, Assembler::AVX_512bit);//T2 = THL + TLL + __ evpxorq(GH, ZTMP1, ZTMP3, Assembler::AVX_512bit);//T1 = THH + TLH + } else { //mid, end, end_reduce + __ vpternlogq(GL, 0x96, ZTMP0, ZTMP2, Assembler::AVX_512bit);//T2 = THL + TLL + __ vpternlogq(GH, 0x96, ZTMP1, ZTMP3, Assembler::AVX_512bit);//T1 = THH + TLH + } + //ghash blocks 8 - 11 + if (uload_shuffle) { + __ evmovdquq(ZTMP9, Address(subkeyHtbl, in_offset * 16 + in_disp + 128), Assembler::AVX_512bit); + __ vpshufb(ZTMP9, ZTMP9, SHUFM, Assembler::AVX_512bit); + } else { + __ evmovdquq(ZTMP9, Address(subkeyHtbl, in_offset * 16 + in_disp + 128), Assembler::AVX_512bit); + } + if (hk_broadcast) { + __ evbroadcastf64x2(ZTMP8, Address(subkeyHtbl, hashkey_offset + displacement + 2 * 64), Assembler::AVX_512bit); + __ evbroadcastf64x2(ZTMPA, Address(subkeyHtbl, hashkey_offset + displacement + hkey_gap + 2 * 64), Assembler::AVX_512bit); + } else { + __ evmovdquq(ZTMP8, Address(subkeyHtbl, hashkey_offset + displacement + 2 * 64), Assembler::AVX_512bit); + __ evmovdquq(ZTMPA, Address(subkeyHtbl, hashkey_offset + displacement + hkey_gap + 2 * 64), Assembler::AVX_512bit); + } + + carrylessMultiply(ZTMP0, ZTMP1, ZTMP2, ZTMP3, ZTMP9, ZTMPA, ZTMP8); + + //update sums + __ vpternlogq(GL, 0x96, ZTMP6, ZTMP4, Assembler::AVX_512bit);//T2 = THL + TLL + __ vpternlogq(GH, 0x96, ZTMP7, ZTMP5, Assembler::AVX_512bit);//T1 = THH + TLH + //ghash blocks 12 - 15 + if (uload_shuffle) { + __ evmovdquq(ZTMP9, Address(subkeyHtbl, in_offset * 16 + in_disp + 192), Assembler::AVX_512bit); + __ vpshufb(ZTMP9, ZTMP9, SHUFM, Assembler::AVX_512bit); + } else { + __ evmovdquq(ZTMP9, Address(subkeyHtbl, in_offset * 16 + in_disp + 192), Assembler::AVX_512bit); + } + + if (hk_broadcast) { + __ evbroadcastf64x2(ZTMP8, Address(subkeyHtbl, hashkey_offset + displacement + 3 * 64), Assembler::AVX_512bit); + __ evbroadcastf64x2(ZTMPA, Address(subkeyHtbl, hashkey_offset + displacement + hkey_gap + 3 * 64), Assembler::AVX_512bit); + } else { + __ evmovdquq(ZTMP8, Address(subkeyHtbl, hashkey_offset + displacement + 3 * 64), Assembler::AVX_512bit); + __ evmovdquq(ZTMPA, Address(subkeyHtbl, hashkey_offset + displacement + hkey_gap + 3 * 64), Assembler::AVX_512bit); + } + carrylessMultiply(ZTMP4, ZTMP5, ZTMP6, ZTMP7, ZTMP9, ZTMPA, ZTMP8); + + //update sums + xorGHASH(GL, GH, GL, GH, ZTMP0, ZTMP2, ZTMP1, ZTMP3, ZTMP6, ZTMP4, ZTMP7, ZTMP5); + + if (do_reduction) { + //new reduction + __ evmovdquq(ZTMPB, ExternalAddress(ghash_polynomial_addr()), Assembler::AVX_512bit, rbx /*rscratch*/); + __ evpclmulqdq(HASH, GL, ZTMPB, 0x10, Assembler::AVX_512bit); + __ vpshufd(ZTMP0, GL, 78, Assembler::AVX_512bit); + __ vpternlogq(HASH, 0x96, GH, ZTMP0, Assembler::AVX_512bit); + if (do_hxor) { + vhpxori4x128(HASH, ZTMP0); + } } - // Last AES round - lastroundEncode(ZTMP17, ZTMP0, ZTMP1, ZTMP2, ZTMP3); - // XOR against plain / cipher text - xorBeforeStore(ZTMP0, ZTMP1, ZTMP2, ZTMP3, ZTMP13, ZTMP14, ZTMP15, ZTMP16); - // store cipher / plain text - storeData(out, pos, ZTMP0, ZTMP1, ZTMP2, ZTMP3); } -void StubGenerator::aesgcm_encrypt(Register in, Register len, Register ct, Register out, Register key, - Register state, Register subkeyHtbl, Register avx512_subkeyHtbl, Register counter) { - Label ENC_DEC_DONE, GENERATE_HTBL_48_BLKS, AES_192, AES_256, STORE_CT, GHASH_LAST_32, - AES_32_BLOCKS, GHASH_AES_PARALLEL, LOOP, ACCUMULATE, GHASH_16_AES_16; - const XMMRegister CTR_BLOCKx = xmm9; +//Stitched GHASH of 16 blocks(with reduction) with encryption of 0 blocks +void StubGenerator::gcm_enc_dec_last_avx512(Register len, Register in, Register pos, XMMRegister HASH, XMMRegister SHUFM, Register subkeyHtbl, + int ghashin_offset, int hashkey_offset, bool start_ghash, bool do_reduction) { + //there is 0 blocks to cipher so there are only 16 blocks for ghash and reduction + ghash16_avx512(start_ghash, do_reduction, false, false, true, in, pos, subkeyHtbl, HASH, SHUFM, ghashin_offset, 0, 0, hashkey_offset); +} + +//Main GCM macro stitching cipher with GHASH +//encrypts 16 blocks at a time +//ghash the 16 previously encrypted ciphertext blocks +void StubGenerator::ghash16_encrypt_parallel16_avx512(Register in, Register out, Register ct, Register pos, Register avx512_subkeyHtbl, + Register CTR_CHECK, Register NROUNDS, Register key, XMMRegister CTR_BE, XMMRegister GHASH_IN, + XMMRegister ADDBE_4x4, XMMRegister ADDBE_1234, XMMRegister ADD_1234, XMMRegister SHFMSK, + bool hk_broadcast, bool is_hash_start, bool do_hash_reduction, bool do_hash_hxor, + bool no_ghash_in, int ghashin_offset, int aesout_offset, int hashkey_offset) { + const XMMRegister B00_03 = xmm0; + const XMMRegister B04_07 = xmm3; + const XMMRegister B08_11 = xmm4; + const XMMRegister B12_15 = xmm5; + const XMMRegister THH1 = xmm6; + const XMMRegister THL1 = xmm7; + const XMMRegister TLH1 = xmm10; + const XMMRegister TLL1 = xmm11, THH2 = xmm12, THL2 = xmm13, TLH2 = xmm15; + const XMMRegister TLL2 = xmm16, THH3 = xmm17, THL3 = xmm19, TLH3 = xmm20; + const XMMRegister TLL3 = xmm21, DATA1 = xmm17, DATA2 = xmm19, DATA3 = xmm20, DATA4 = xmm21; + const XMMRegister AESKEY1 = xmm30, AESKEY2 = xmm31; + const XMMRegister GHKEY1 = xmm1, GHKEY2 = xmm18, GHDAT1 = xmm8, GHDAT2 = xmm22; + const XMMRegister ZT = xmm23, TO_REDUCE_L = xmm25, TO_REDUCE_H = xmm24; + const int hkey_gap = 16 * 32; + + Label blocks_overflow, blocks_ok, skip_shuffle, cont, aes_256, aes_192, last_aes_rnd; + + __ cmpb(CTR_CHECK, (256 - 16)); + __ jcc(Assembler::aboveEqual, blocks_overflow); + __ vpaddd(B00_03, CTR_BE, ADDBE_1234, Assembler::AVX_512bit); + __ vpaddd(B04_07, B00_03, ADDBE_4x4, Assembler::AVX_512bit); + __ vpaddd(B08_11, B04_07, ADDBE_4x4, Assembler::AVX_512bit); + __ vpaddd(B12_15, B08_11, ADDBE_4x4, Assembler::AVX_512bit); + __ jmp(blocks_ok); + __ bind(blocks_overflow); + __ vpshufb(CTR_BE, CTR_BE, SHFMSK, Assembler::AVX_512bit); + __ evmovdquq(B12_15, ExternalAddress(counter_mask_linc4_addr()), Assembler::AVX_512bit, rbx /*rscratch*/); + __ vpaddd(B00_03, CTR_BE, ADD_1234, Assembler::AVX_512bit); + __ vpaddd(B04_07, B00_03, B12_15, Assembler::AVX_512bit); + __ vpaddd(B08_11, B04_07, B12_15, Assembler::AVX_512bit); + __ vpaddd(B12_15, B08_11, B12_15, Assembler::AVX_512bit); + shuffle(B00_03, B04_07, B08_11, B12_15, B00_03, B04_07, B08_11, B12_15, SHFMSK); + + __ bind(blocks_ok); + + //pre - load constants + ev_load_key(AESKEY1, key, 0, rbx); + if (!no_ghash_in) { + __ evpxorq(GHDAT1, GHASH_IN, Address(avx512_subkeyHtbl, 16 * ghashin_offset), Assembler::AVX_512bit); + } else { + __ evmovdquq(GHDAT1, Address(avx512_subkeyHtbl, 16 * ghashin_offset), Assembler::AVX_512bit); + } + + if (hk_broadcast) { + __ evbroadcastf64x2(GHKEY1, Address(avx512_subkeyHtbl, hashkey_offset + 0 * 64), Assembler::AVX_512bit); + __ evbroadcastf64x2(GHKEY2, Address(avx512_subkeyHtbl, hashkey_offset + hkey_gap + 0 * 64), Assembler::AVX_512bit); + } else { + __ evmovdquq(GHKEY1, Address(avx512_subkeyHtbl, hashkey_offset + 0 * 64), Assembler::AVX_512bit); + __ evmovdquq(GHKEY2, Address(avx512_subkeyHtbl, hashkey_offset + hkey_gap + 0 * 64), Assembler::AVX_512bit); + } + + //save counter for the next round + //increment counter overflow check register + __ evshufi64x2(CTR_BE, B12_15, B12_15, 255, Assembler::AVX_512bit); + __ addb(CTR_CHECK, 16); + + //pre - load constants + ev_load_key(AESKEY2, key, 1 * 16, rbx); + __ evmovdquq(GHDAT2, Address(avx512_subkeyHtbl, 16 * (ghashin_offset +4)), Assembler::AVX_512bit); + + //stitch AES rounds with GHASH + //AES round 0 + __ evpxorq(B00_03, B00_03, AESKEY1, Assembler::AVX_512bit); + __ evpxorq(B04_07, B04_07, AESKEY1, Assembler::AVX_512bit); + __ evpxorq(B08_11, B08_11, AESKEY1, Assembler::AVX_512bit); + __ evpxorq(B12_15, B12_15, AESKEY1, Assembler::AVX_512bit); + ev_load_key(AESKEY1, key, 2 * 16, rbx); + + //GHASH 4 blocks(15 to 12) + carrylessMultiply(TLL1, TLH1, THL1, THH1, GHDAT1, GHKEY2, GHKEY1); + + if (hk_broadcast) { + __ evbroadcastf64x2(GHKEY1, Address(avx512_subkeyHtbl, hashkey_offset + 1 * 64), Assembler::AVX_512bit); + __ evbroadcastf64x2(GHKEY2, Address(avx512_subkeyHtbl, hashkey_offset + hkey_gap + 1 * 64), Assembler::AVX_512bit); + } else { + __ evmovdquq(GHKEY1, Address(avx512_subkeyHtbl, hashkey_offset + 1 * 64), Assembler::AVX_512bit); + __ evmovdquq(GHKEY2, Address(avx512_subkeyHtbl, hashkey_offset + hkey_gap + 1 * 64), Assembler::AVX_512bit); + } + + __ evmovdquq(GHDAT1, Address(avx512_subkeyHtbl, 16 * (ghashin_offset + 8)), Assembler::AVX_512bit); + + //AES round 1 + roundEncode(AESKEY2, B00_03, B04_07, B08_11, B12_15); + + ev_load_key(AESKEY2, key, 3 * 16, rbx); + + //GHASH 4 blocks(11 to 8) + carrylessMultiply(TLL2, TLH2, THL2, THH2, GHDAT2, GHKEY2, GHKEY1); + + if (hk_broadcast) { + __ evbroadcastf64x2(GHKEY1, Address(avx512_subkeyHtbl, hashkey_offset + 2 * 64), Assembler::AVX_512bit); + __ evbroadcastf64x2(GHKEY2, Address(avx512_subkeyHtbl, hashkey_offset + hkey_gap + 2 * 64), Assembler::AVX_512bit); + } else { + __ evmovdquq(GHKEY1, Address(avx512_subkeyHtbl, hashkey_offset + 2 * 64 ), Assembler::AVX_512bit); + __ evmovdquq(GHKEY2, Address(avx512_subkeyHtbl, hashkey_offset + hkey_gap + 2 * 64), Assembler::AVX_512bit); + } + __ evmovdquq(GHDAT2, Address(avx512_subkeyHtbl, 16 * (ghashin_offset + 12)), Assembler::AVX_512bit); + + //AES round 2 + roundEncode(AESKEY1, B00_03, B04_07, B08_11, B12_15); + ev_load_key(AESKEY1, key, 4 * 16, rbx); + + //GHASH 4 blocks(7 to 4) + carrylessMultiply(TLL3, TLH3, THL3, THH3, GHDAT1, GHKEY2, GHKEY1); + + if (hk_broadcast) { + __ evbroadcastf64x2(GHKEY1, Address(avx512_subkeyHtbl, hashkey_offset + 3 * 64), Assembler::AVX_512bit); + __ evbroadcastf64x2(GHKEY2, Address(avx512_subkeyHtbl, hashkey_offset + hkey_gap + 3 * 64), Assembler::AVX_512bit); + } else { + __ evmovdquq(GHKEY1, Address(avx512_subkeyHtbl, hashkey_offset + 3 * 64), Assembler::AVX_512bit); + __ evmovdquq(GHKEY2, Address(avx512_subkeyHtbl, hashkey_offset + hkey_gap + 3 * 64), Assembler::AVX_512bit); + } + + //AES rounds 3 + roundEncode(AESKEY2, B00_03, B04_07, B08_11, B12_15); + ev_load_key(AESKEY2, key, 5 * 16, rbx); + + //Gather(XOR) GHASH for 12 blocks + xorGHASH(TLL1, TLH1, THL1, THH1, TLL2, TLL3, TLH2, TLH3, THL2, THL3, THH2, THH3); + + //AES rounds 4 + roundEncode(AESKEY1, B00_03, B04_07, B08_11, B12_15); + ev_load_key(AESKEY1, key, 6 * 16, rbx); + + //load plain / cipher text(recycle GH3xx registers) + loadData(in, pos, DATA1, DATA2, DATA3, DATA4); + + //AES rounds 5 + roundEncode(AESKEY2, B00_03, B04_07, B08_11, B12_15); + ev_load_key(AESKEY2, key, 7 * 16, rbx); + + //GHASH 4 blocks(3 to 0) + carrylessMultiply(TLL2, TLH2, THL2, THH2, GHDAT2, GHKEY2, GHKEY1); + + //AES round 6 + roundEncode(AESKEY1, B00_03, B04_07, B08_11, B12_15); + ev_load_key(AESKEY1, key, 8 * 16, rbx); + + //gather GHASH in TO_REDUCE_H / L + if (is_hash_start) { + __ evpxorq(TO_REDUCE_L, TLL2, THL2, Assembler::AVX_512bit); + __ evpxorq(TO_REDUCE_H, THH2, TLH2, Assembler::AVX_512bit); + __ vpternlogq(TO_REDUCE_L, 0x96, TLL1, THL1, Assembler::AVX_512bit); + __ vpternlogq(TO_REDUCE_H, 0x96, THH1, TLH1, Assembler::AVX_512bit); + } else { + //not the first round so sums need to be updated + xorGHASH(TO_REDUCE_L, TO_REDUCE_H, TO_REDUCE_L, TO_REDUCE_H, TLL2, THL2, THH2, TLH2, TLL1, THL1, THH1, TLH1); + } + + //AES round 7 + roundEncode(AESKEY2, B00_03, B04_07, B08_11, B12_15); + ev_load_key(AESKEY2, key, 9 * 16, rbx); + + //new reduction + if (do_hash_reduction) { + __ evmovdquq(ZT, ExternalAddress(ghash_polynomial_reduction_addr()), Assembler::AVX_512bit, rbx /*rscratch*/); + __ evpclmulqdq(THH1, TO_REDUCE_L, ZT, 0x10, Assembler::AVX_512bit); + __ vpshufd(TO_REDUCE_L, TO_REDUCE_L, 78, Assembler::AVX_512bit); + __ vpternlogq(THH1, 0x96, TO_REDUCE_H, TO_REDUCE_L, Assembler::AVX_512bit); + } + + //AES round 8 + roundEncode(AESKEY1, B00_03, B04_07, B08_11, B12_15); + ev_load_key(AESKEY1, key, 10 * 16, rbx); + + //horizontalxor of 4 reduced hashes + if (do_hash_hxor) { + vhpxori4x128(THH1, TLL1); + } + + //AES round 9 + roundEncode(AESKEY2, B00_03, B04_07, B08_11, B12_15); + ev_load_key(AESKEY2, key, 11 * 16, rbx); + //AES rounds up to 11 (AES192) or 13 (AES256) + //AES128 is done + __ cmpl(NROUNDS, 52); + __ jcc(Assembler::less, last_aes_rnd); + __ bind(aes_192); + roundEncode(AESKEY1, B00_03, B04_07, B08_11, B12_15); + ev_load_key(AESKEY1, key, 12 * 16, rbx); + roundEncode(AESKEY2, B00_03, B04_07, B08_11, B12_15); + __ cmpl(NROUNDS, 60); + __ jcc(Assembler::less, last_aes_rnd); + __ bind(aes_256); + ev_load_key(AESKEY2, key, 13 * 16, rbx); + roundEncode(AESKEY1, B00_03, B04_07, B08_11, B12_15); + ev_load_key(AESKEY1, key, 14 * 16, rbx); + roundEncode(AESKEY2, B00_03, B04_07, B08_11, B12_15); + + __ bind(last_aes_rnd); + //the last AES round + lastroundEncode(AESKEY1, B00_03, B04_07, B08_11, B12_15); + //AESKEY1and AESKEY2 contain AES round keys + + //XOR against plain / cipher text + xorBeforeStore(B00_03, B04_07, B08_11, B12_15, DATA1, DATA2, DATA3, DATA4); + + //store cipher / plain text + storeData(out, pos, B00_03, B04_07, B08_11, B12_15); + //**B00_03, B04_07, B08_011, B12_B15 may contain sensitive data + + //shuffle cipher text blocks for GHASH computation + __ cmpptr(ct, out); + __ jcc(Assembler::notEqual, skip_shuffle); + shuffle(B00_03, B04_07, B08_11, B12_15, B00_03, B04_07, B08_11, B12_15, SHFMSK); + __ jmp(cont); + __ bind(skip_shuffle); + shuffle(B00_03, B04_07, B08_11, B12_15, DATA1, DATA2, DATA3, DATA4, SHFMSK); + + //**B00_03, B04_07, B08_011, B12_B15 overwritten with shuffled cipher text + __ bind(cont); + //store shuffled cipher text for ghashing + __ evmovdquq(Address(avx512_subkeyHtbl, 16 * aesout_offset), B00_03, Assembler::AVX_512bit); + __ evmovdquq(Address(avx512_subkeyHtbl, 16 * (aesout_offset + 4)), B04_07, Assembler::AVX_512bit); + __ evmovdquq(Address(avx512_subkeyHtbl, 16 * (aesout_offset + 8)), B08_11, Assembler::AVX_512bit); + __ evmovdquq(Address(avx512_subkeyHtbl, 16 * (aesout_offset + 12)), B12_15, Assembler::AVX_512bit); +} + + +//Encrypt / decrypt the initial 16 blocks +void StubGenerator::initial_blocks_16_avx512(Register in, Register out, Register ct, Register pos, Register key, Register avx512_subkeyHtbl, + Register CTR_CHECK, Register rounds, XMMRegister CTR, XMMRegister GHASH, XMMRegister ADDBE_4x4, + XMMRegister ADDBE_1234, XMMRegister ADD_1234, XMMRegister SHUF_MASK, int stack_offset) { + const XMMRegister B00_03 = xmm7; + const XMMRegister B04_07 = xmm10; + const XMMRegister B08_11 = xmm11; + const XMMRegister B12_15 = xmm12; + const XMMRegister T0 = xmm0; + const XMMRegister T1 = xmm3; + const XMMRegister T2 = xmm4; + const XMMRegister T3 = xmm5; + const XMMRegister T4 = xmm6; + const XMMRegister T5 = xmm30; + + Label next_16_overflow, next_16_ok, cont, skip_shuffle, aes_256, aes_192, last_aes_rnd; + //prepare counter blocks + __ cmpb(CTR_CHECK, (256 - 16)); + __ jcc(Assembler::aboveEqual, next_16_overflow); + __ vpaddd(B00_03, CTR, ADDBE_1234, Assembler::AVX_512bit); + __ vpaddd(B04_07, B00_03, ADDBE_4x4, Assembler::AVX_512bit); + __ vpaddd(B08_11, B04_07, ADDBE_4x4, Assembler::AVX_512bit); + __ vpaddd(B12_15, B08_11, ADDBE_4x4, Assembler::AVX_512bit); + __ jmp(next_16_ok); + __ bind(next_16_overflow); + __ vpshufb(CTR, CTR, SHUF_MASK, Assembler::AVX_512bit); + __ evmovdquq(B12_15, ExternalAddress(counter_mask_linc4_addr()), Assembler::AVX_512bit, rbx); + __ vpaddd(B00_03, CTR, ADD_1234, Assembler::AVX_512bit); + __ vpaddd(B04_07, B00_03, B12_15, Assembler::AVX_512bit); + __ vpaddd(B08_11, B04_07, B12_15, Assembler::AVX_512bit); + __ vpaddd(B12_15, B08_11, B12_15, Assembler::AVX_512bit); + shuffle(B00_03, B04_07, B08_11, B12_15, B00_03, B04_07, B08_11, B12_15, SHUF_MASK); + __ bind(next_16_ok); + __ evshufi64x2(CTR, B12_15, B12_15, 255, Assembler::AVX_512bit); + __ addb(CTR_CHECK, 16); + + //load 16 blocks of data + loadData(in, pos, T0, T1, T2, T3); + + //move to AES encryption rounds + __ movdqu(T5, ExternalAddress(key_shuffle_mask_addr()), rbx /*rscratch*/); + ev_load_key(T4, key, 0, T5); + __ evpxorq(B00_03, B00_03, T4, Assembler::AVX_512bit); + __ evpxorq(B04_07, B04_07, T4, Assembler::AVX_512bit); + __ evpxorq(B08_11, B08_11, T4, Assembler::AVX_512bit); + __ evpxorq(B12_15, B12_15, T4, Assembler::AVX_512bit); + + for (int i = 1; i < 10; i++) { + ev_load_key(T4, key, i * 16, T5); + roundEncode(T4, B00_03, B04_07, B08_11, B12_15); + } + + ev_load_key(T4, key, 10 * 16, T5); + __ cmpl(rounds, 52); + __ jcc(Assembler::less, last_aes_rnd); + __ bind(aes_192); + roundEncode(T4, B00_03, B04_07, B08_11, B12_15); + ev_load_key(T4, key, 16 * 11, T5); + roundEncode(T4, B00_03, B04_07, B08_11, B12_15); + ev_load_key(T4, key, 16 * 12, T5); + __ cmpl(rounds, 60); + __ jcc(Assembler::less, last_aes_rnd); + __ bind(aes_256); + roundEncode(T4, B00_03, B04_07, B08_11, B12_15); + ev_load_key(T4, key, 16 * 13, T5); + roundEncode(T4, B00_03, B04_07, B08_11, B12_15); + ev_load_key(T4, key, 16 * 14, T5); + + __ bind(last_aes_rnd); + lastroundEncode(T4, B00_03, B04_07, B08_11, B12_15); + + //xor against text + xorBeforeStore(B00_03, B04_07, B08_11, B12_15, T0, T1, T2, T3); + + //store + storeData(out, pos, B00_03, B04_07, B08_11, B12_15); + + __ cmpptr(ct, out); + __ jcc(Assembler::equal, skip_shuffle); + //decryption - cipher text needs to go to GHASH phase + shuffle(B00_03, B04_07, B08_11, B12_15, T0, T1, T2, T3, SHUF_MASK); + __ jmp(cont); + __ bind(skip_shuffle); + shuffle(B00_03, B04_07, B08_11, B12_15, B00_03, B04_07, B08_11, B12_15, SHUF_MASK); + + //B00_03, B04_07, B08_11, B12_15 overwritten with shuffled cipher text + __ bind(cont); + __ evmovdquq(Address(avx512_subkeyHtbl, 16 * stack_offset), B00_03, Assembler::AVX_512bit); + __ evmovdquq(Address(avx512_subkeyHtbl, 16 * (stack_offset + 4)), B04_07, Assembler::AVX_512bit); + __ evmovdquq(Address(avx512_subkeyHtbl, 16 * (stack_offset + 8)), B08_11, Assembler::AVX_512bit); + __ evmovdquq(Address(avx512_subkeyHtbl, 16 * (stack_offset + 12)), B12_15, Assembler::AVX_512bit); +} + +void StubGenerator::aesgcm_avx512(Register in, Register len, Register ct, Register out, Register key, Register state, + Register subkeyHtbl, Register avx512_subkeyHtbl, Register counter) { + Label ENC_DEC_DONE, MESG_BELOW_32_BLKS, NO_BIG_BLKS, ENCRYPT_BIG_BLKS_NO_HXOR, + ENCRYPT_BIG_NBLKS, ENCRYPT_16_BLKS, ENCRYPT_N_GHASH_32_N_BLKS, GHASH_DONE; + const XMMRegister CTR_BLOCKx = xmm2; const XMMRegister AAD_HASHx = xmm14; - const Register pos = rax; - const Register rounds = r15; - const Register ghash_pos = NOT_WIN64( r14) WIN64_ONLY( r11 ); const XMMRegister ZTMP0 = xmm0; - const XMMRegister ZTMP1 = xmm3; - const XMMRegister ZTMP2 = xmm4; - const XMMRegister ZTMP3 = xmm5; + const XMMRegister ZTMP1 = xmm3; //**sensitive + const XMMRegister ZTMP2 = xmm4; //**sensitive(small data) + const XMMRegister ZTMP3 = xmm5; //**sensitive(small data) const XMMRegister ZTMP4 = xmm6; const XMMRegister ZTMP5 = xmm7; const XMMRegister ZTMP6 = xmm10; @@ -3066,235 +3358,170 @@ void StubGenerator::aesgcm_encrypt(Register in, Register len, Register ct, Regis const XMMRegister ZTMP14 = xmm20; const XMMRegister ZTMP15 = xmm21; const XMMRegister ZTMP16 = xmm30; - const XMMRegister COUNTER_INC_MASK = xmm18; + const XMMRegister ZTMP17 = xmm31; + const XMMRegister ZTMP18 = xmm1; + const XMMRegister ZTMP19 = xmm18; + const XMMRegister ZTMP20 = xmm8; + const XMMRegister ZTMP21 = xmm22; + const XMMRegister ZTMP22 = xmm23; + const XMMRegister ZTMP23 = xmm26; + const XMMRegister GH = xmm24; + const XMMRegister GL = xmm25; + const XMMRegister SHUF_MASK = xmm29; + const XMMRegister ADDBE_4x4 = xmm27; + const XMMRegister ADDBE_1234 = xmm28; + const XMMRegister ADD_1234 = xmm9; + const KRegister MASKREG = k1; + const Register pos = rax; + const Register rounds = r15; + const Register CTR_CHECK = r14; - __ movl(pos, 0); // Total length processed - // Min data size processed = 768 bytes - __ cmpl(len, 768); - __ jcc(Assembler::less, ENC_DEC_DONE); + const int stack_offset = 64; + const int ghashin_offset = 64; + const int aesout_offset = 64; + const int hashkey_offset = 0; + const int hashkey_gap = 16 * 32; + const int HashKey_32 = 0; + const int HashKey_16 = 16 * 16; - // Generate 48 constants for htbl - __ call(GENERATE_HTBL_48_BLKS, relocInfo::none); - int index = 0; // Index for choosing subkeyHtbl entry - __ movl(ghash_pos, 0); // Pointer for ghash read and store operations + __ movl(pos, 0); + __ cmpl(len, 256); + __ jcc(Assembler::lessEqual, ENC_DEC_DONE); - // Move initial counter value and STATE value into variables + /* Structure of the Htbl is as follows: + * Where 0 - 31 we have 32 Hashkey's and 32-63 we have 32 HashKeyK (derived from HashKey) + * Rest 8 entries are for storing CTR values post AES rounds + * ---------------------------------------------------------------------------------------- + Hashkey32 -> 16 * 0 + Hashkey31 -> 16 * 1 + Hashkey30 -> 16 * 2 + ........ + Hashkey1 -> 16 * 31 + --------------------- + HaskeyK32 -> 16 * 32 + HashkeyK31 -> 16 * 33 + ......... + HashkeyK1 -> 16 * 63 + --------------------- + 1st set of AES Entries + B00_03 -> 16 * 64 + B04_07 -> 16 * 68 + B08_11 -> 16 * 72 + B12_15 -> 16 * 80 + --------------------- + 2nd set of AES Entries + B00_03 -> 16 * 84 + B04_07 -> 16 * 88 + B08_11 -> 16 * 92 + B12_15 -> 16 * 96 + ---------------------*/ + generateHtbl_32_blocks_avx512(subkeyHtbl, avx512_subkeyHtbl); + + //Move initial counter value and STATE value into variables __ movdqu(CTR_BLOCKx, Address(counter, 0)); __ movdqu(AAD_HASHx, Address(state, 0)); - // Load lswap mask for ghash + + //Load lswap mask for ghash __ movdqu(xmm24, ExternalAddress(ghash_long_swap_mask_addr()), rbx /*rscratch*/); - // Shuffle input state using lswap mask + //Shuffle input state using lswap mask __ vpshufb(AAD_HASHx, AAD_HASHx, xmm24, Assembler::AVX_128bit); // Compute #rounds for AES based on the length of the key array __ movl(rounds, Address(key, arrayOopDesc::length_offset_in_bytes() - arrayOopDesc::base_offset_in_bytes(T_INT))); - // Broadcast counter value to 512 bit register + __ evmovdquq(ADDBE_4x4, ExternalAddress(counter_mask_addbe_4444_addr()), Assembler::AVX_512bit, rbx /*rscratch*/); + __ evmovdquq(ADDBE_1234, ExternalAddress(counter_mask_addbe_1234_addr()), Assembler::AVX_512bit, rbx /*rscratch*/); + __ evmovdquq(SHUF_MASK, ExternalAddress(counter_shuffle_mask_addr()), Assembler::AVX_512bit, rbx /*rscratch*/); + __ evmovdquq(ADD_1234, ExternalAddress(counter_mask_add_1234_addr()), Assembler::AVX_512bit, rbx /*rscratch*/); + + //Shuffle counter, subtract 1 from the pre-incremented counter value and broadcast counter value to 512 bit register + __ vpshufb(CTR_BLOCKx, CTR_BLOCKx, SHUF_MASK, Assembler::AVX_128bit); + __ vpsubd(CTR_BLOCKx, CTR_BLOCKx, ADD_1234, Assembler::AVX_128bit); __ evshufi64x2(CTR_BLOCKx, CTR_BLOCKx, CTR_BLOCKx, 0, Assembler::AVX_512bit); - // Load counter shuffle mask - __ evmovdquq(xmm24, ExternalAddress(counter_shuffle_mask_addr()), Assembler::AVX_512bit, rbx /*rscratch*/); - // Shuffle counter - __ vpshufb(CTR_BLOCKx, CTR_BLOCKx, xmm24, Assembler::AVX_512bit); - // Load mask for incrementing counter - __ evmovdquq(COUNTER_INC_MASK, ExternalAddress(counter_mask_linc4_addr()), Assembler::AVX_512bit, rbx /*rscratch*/); - // Pre-increment counter - __ vpaddd(ZTMP5, CTR_BLOCKx, ExternalAddress(counter_mask_linc0_addr()), Assembler::AVX_512bit, rbx /*rscratch*/); - __ vpaddd(ZTMP6, ZTMP5, COUNTER_INC_MASK, Assembler::AVX_512bit); - __ vpaddd(ZTMP7, ZTMP6, COUNTER_INC_MASK, Assembler::AVX_512bit); - __ vpaddd(ZTMP8, ZTMP7, COUNTER_INC_MASK, Assembler::AVX_512bit); + __ movdl(CTR_CHECK, CTR_BLOCKx); + __ andl(CTR_CHECK, 255); - // Begin 32 blocks of AES processing - __ bind(AES_32_BLOCKS); - // Save incremented counter before overwriting it with AES data - __ evmovdquq(CTR_BLOCKx, ZTMP8, Assembler::AVX_512bit); + // Reshuffle counter + __ vpshufb(CTR_BLOCKx, CTR_BLOCKx, SHUF_MASK, Assembler::AVX_512bit); - // Move 256 bytes of data - loadData(in, pos, ZTMP0, ZTMP1, ZTMP2, ZTMP3); - // Load key shuffle mask - __ movdqu(xmm29, ExternalAddress(key_shuffle_mask_addr()), rbx /*rscratch*/); - // Load 0th AES round key - ev_load_key(ZTMP4, key, 0, xmm29); - // AES-ROUND0, xmm24 has the shuffle mask - shuffleExorRnd1Key(ZTMP5, ZTMP6, ZTMP7, ZTMP8, xmm24, ZTMP4); + initial_blocks_16_avx512(in, out, ct, pos, key, avx512_subkeyHtbl, CTR_CHECK, rounds, CTR_BLOCKx, AAD_HASHx, ADDBE_4x4, ADDBE_1234, ADD_1234, SHUF_MASK, stack_offset); + __ addl(pos, 16 * 16); + __ cmpl(len, 32 * 16); + __ jcc(Assembler::below, MESG_BELOW_32_BLKS); - for (int j = 1; j < 10; j++) { - ev_load_key(ZTMP4, key, j * 16, xmm29); - roundEncode(ZTMP4, ZTMP5, ZTMP6, ZTMP7, ZTMP8); - } - ev_load_key(ZTMP4, key, 10 * 16, xmm29); - // AES rounds up to 11 (AES192) or 13 (AES256) - __ cmpl(rounds, 52); - __ jcc(Assembler::greaterEqual, AES_192); - lastroundEncode(ZTMP4, ZTMP5, ZTMP6, ZTMP7, ZTMP8); - __ jmp(STORE_CT); + initial_blocks_16_avx512(in, out, ct, pos, key, avx512_subkeyHtbl, CTR_CHECK, rounds, CTR_BLOCKx, AAD_HASHx, ADDBE_4x4, ADDBE_1234, ADD_1234, SHUF_MASK, stack_offset + 16); + __ addl(pos, 16 * 16); + __ subl(len, 32 * 16); - __ bind(AES_192); - roundEncode(ZTMP4, ZTMP5, ZTMP6, ZTMP7, ZTMP8); - ev_load_key(ZTMP4, key, 11 * 16, xmm29); - roundEncode(ZTMP4, ZTMP5, ZTMP6, ZTMP7, ZTMP8); - __ cmpl(rounds, 60); - __ jcc(Assembler::aboveEqual, AES_256); - ev_load_key(ZTMP4, key, 12 * 16, xmm29); - lastroundEncode(ZTMP4, ZTMP5, ZTMP6, ZTMP7, ZTMP8); - __ jmp(STORE_CT); + __ cmpl(len, 32 * 16); + __ jcc(Assembler::below, NO_BIG_BLKS); - __ bind(AES_256); - ev_load_key(ZTMP4, key, 12 * 16, xmm29); - roundEncode(ZTMP4, ZTMP5, ZTMP6, ZTMP7, ZTMP8); - ev_load_key(ZTMP4, key, 13 * 16, xmm29); - roundEncode(ZTMP4, ZTMP5, ZTMP6, ZTMP7, ZTMP8); - ev_load_key(ZTMP4, key, 14 * 16, xmm29); - // Last AES round - lastroundEncode(ZTMP4, ZTMP5, ZTMP6, ZTMP7, ZTMP8); + __ bind(ENCRYPT_BIG_BLKS_NO_HXOR); + __ cmpl(len, 2 * 32 * 16); + __ jcc(Assembler::below, ENCRYPT_BIG_NBLKS); + ghash16_encrypt_parallel16_avx512(in, out, ct, pos, avx512_subkeyHtbl, CTR_CHECK, rounds, key, CTR_BLOCKx, AAD_HASHx, ADDBE_4x4, ADDBE_1234, ADD_1234, SHUF_MASK, + true, true, false, false, false, ghashin_offset, aesout_offset, HashKey_32); + __ addl(pos, 16 * 16); - __ bind(STORE_CT); - // Xor the encrypted key with PT to obtain CT - xorBeforeStore(ZTMP5, ZTMP6, ZTMP7, ZTMP8, ZTMP0, ZTMP1, ZTMP2, ZTMP3); - storeData(out, pos, ZTMP5, ZTMP6, ZTMP7, ZTMP8); - // 16 blocks encryption completed - __ addl(pos, 256); - __ cmpl(pos, 512); - __ jcc(Assembler::aboveEqual, GHASH_AES_PARALLEL); - __ vpaddd(ZTMP5, CTR_BLOCKx, COUNTER_INC_MASK, Assembler::AVX_512bit); - __ vpaddd(ZTMP6, ZTMP5, COUNTER_INC_MASK, Assembler::AVX_512bit); - __ vpaddd(ZTMP7, ZTMP6, COUNTER_INC_MASK, Assembler::AVX_512bit); - __ vpaddd(ZTMP8, ZTMP7, COUNTER_INC_MASK, Assembler::AVX_512bit); - __ jmp(AES_32_BLOCKS); + ghash16_encrypt_parallel16_avx512(in, out, ct, pos, avx512_subkeyHtbl, CTR_CHECK, rounds, key, CTR_BLOCKx, AAD_HASHx, ADDBE_4x4, ADDBE_1234, ADD_1234, SHUF_MASK, + true, false, true, false, true, ghashin_offset + 16, aesout_offset + 16, HashKey_16); + __ evmovdquq(AAD_HASHx, ZTMP4, Assembler::AVX_512bit); + __ addl(pos, 16 * 16); + __ subl(len, 32 * 16); + __ jmp(ENCRYPT_BIG_BLKS_NO_HXOR); - __ bind(GHASH_AES_PARALLEL); - // Ghash16_encrypt16_parallel takes place in the order with three reduction values: - // 1) First time -> cipher xor input ghash - // 2) No reduction -> accumulate multiplication values - // 3) Final reduction post 48 blocks -> new ghash value is computed for the next round - // Reduction value = first time - ghash16_encrypt16_parallel(key, avx512_subkeyHtbl, CTR_BLOCKx, AAD_HASHx, in, out, ct, pos, true, xmm24, true, rounds, ghash_pos, false, index, COUNTER_INC_MASK); - __ addl(pos, 256); - __ addl(ghash_pos, 256); - index += 4; + __ bind(ENCRYPT_BIG_NBLKS); + ghash16_encrypt_parallel16_avx512(in, out, ct, pos, avx512_subkeyHtbl, CTR_CHECK, rounds, key, CTR_BLOCKx, AAD_HASHx, ADDBE_4x4, ADDBE_1234, ADD_1234, SHUF_MASK, + false, true, false, false, false, ghashin_offset, aesout_offset, HashKey_32); + __ addl(pos, 16 * 16); + ghash16_encrypt_parallel16_avx512(in, out, ct, pos, avx512_subkeyHtbl, CTR_CHECK, rounds, key, CTR_BLOCKx, AAD_HASHx, ADDBE_4x4, ADDBE_1234, ADD_1234, SHUF_MASK, + false, false, true, true, true, ghashin_offset + 16, aesout_offset + 16, HashKey_16); - // At this point we have processed 768 bytes of AES and 256 bytes of GHASH. - // If the remaining length is less than 768, process remaining 512 bytes of ghash in GHASH_LAST_32 code - __ subl(len, 768); - __ cmpl(len, 768); - __ jcc(Assembler::less, GHASH_LAST_32); + __ movdqu(AAD_HASHx, ZTMP4); + __ addl(pos, 16 * 16); + __ subl(len, 32 * 16); - // AES 16 blocks and GHASH 16 blocks in parallel - // For multiples of 48 blocks we will do ghash16_encrypt16 interleaved multiple times - // Reduction value = no reduction means that the carryless multiplication values are accumulated for further calculations - // Each call uses 4 subkeyHtbl values, so increment the index by 4. - __ bind(GHASH_16_AES_16); - // Reduction value = no reduction - ghash16_encrypt16_parallel(key, avx512_subkeyHtbl, CTR_BLOCKx, AAD_HASHx, in, out, ct, pos, false, xmm24, false, rounds, ghash_pos, false, index, COUNTER_INC_MASK); - __ addl(pos, 256); - __ addl(ghash_pos, 256); - index += 4; - // Reduction value = final reduction means that the accumulated values have to be reduced as we have completed 48 blocks of ghash - ghash16_encrypt16_parallel(key, avx512_subkeyHtbl, CTR_BLOCKx, AAD_HASHx, in, out, ct, pos, false, xmm24, false, rounds, ghash_pos, true, index, COUNTER_INC_MASK); - __ addl(pos, 256); - __ addl(ghash_pos, 256); - // Calculated ghash value needs to be __ moved to AAD_HASHX so that we can restart the ghash16-aes16 pipeline - __ movdqu(AAD_HASHx, ZTMP5); - index = 0; // Reset subkeyHtbl index + __ bind(NO_BIG_BLKS); + __ cmpl(len, 16 * 16); + __ jcc(Assembler::aboveEqual, ENCRYPT_16_BLKS); - // Restart the pipeline - // Reduction value = first time - ghash16_encrypt16_parallel(key, avx512_subkeyHtbl, CTR_BLOCKx, AAD_HASHx, in, out, ct, pos, true, xmm24, true, rounds, ghash_pos, false, index, COUNTER_INC_MASK); - __ addl(pos, 256); - __ addl(ghash_pos, 256); - index += 4; + __ bind(ENCRYPT_N_GHASH_32_N_BLKS); + ghash16_avx512(true, false, false, false, true, in, pos, avx512_subkeyHtbl, AAD_HASHx, SHUF_MASK, stack_offset, 0, 0, HashKey_32); + gcm_enc_dec_last_avx512(len, in, pos, AAD_HASHx, SHUF_MASK, avx512_subkeyHtbl, ghashin_offset + 16, HashKey_16, false, true); + __ jmp(GHASH_DONE); - __ subl(len, 768); - __ cmpl(len, 768); - __ jcc(Assembler::greaterEqual, GHASH_16_AES_16); + __ bind(ENCRYPT_16_BLKS); + ghash16_encrypt_parallel16_avx512(in, out, ct, pos, avx512_subkeyHtbl, CTR_CHECK, rounds, key, CTR_BLOCKx, AAD_HASHx, ADDBE_4x4, ADDBE_1234, ADD_1234, SHUF_MASK, + false, true, false, false, false, ghashin_offset, aesout_offset, HashKey_32); - // GHASH last 32 blocks processed here - // GHASH products accumulated in ZMM27, ZMM25 and ZMM26 during GHASH16-AES16 operation is used - __ bind(GHASH_LAST_32); - // Use rbx as a pointer to the htbl; For last 32 blocks of GHASH, use key# 4-11 entry in subkeyHtbl - __ movl(rbx, 256); - // Load cipher blocks - __ evmovdquq(ZTMP13, Address(ct, ghash_pos, Address::times_1, 0 * 64), Assembler::AVX_512bit); - __ evmovdquq(ZTMP14, Address(ct, ghash_pos, Address::times_1, 1 * 64), Assembler::AVX_512bit); - __ vpshufb(ZTMP13, ZTMP13, xmm24, Assembler::AVX_512bit); - __ vpshufb(ZTMP14, ZTMP14, xmm24, Assembler::AVX_512bit); - // Load ghash keys - __ evmovdquq(ZTMP15, Address(avx512_subkeyHtbl, rbx, Address::times_1, 0 * 64), Assembler::AVX_512bit); - __ evmovdquq(ZTMP16, Address(avx512_subkeyHtbl, rbx, Address::times_1, 1 * 64), Assembler::AVX_512bit); + ghash16_avx512(false, true, false, false, true, in, pos, avx512_subkeyHtbl, AAD_HASHx, SHUF_MASK, stack_offset, 16 * 16, 0, HashKey_16); - // Ghash blocks 0 - 3 - carrylessMultiply(ZTMP2, ZTMP3, ZTMP4, ZTMP1, ZTMP13, ZTMP15); - // Ghash blocks 4 - 7 - carrylessMultiply(ZTMP6, ZTMP7, ZTMP8, ZTMP5, ZTMP14, ZTMP16); + __ bind(MESG_BELOW_32_BLKS); + __ subl(len, 16 * 16); + __ addl(pos, 16 * 16); + gcm_enc_dec_last_avx512(len, in, pos, AAD_HASHx, SHUF_MASK, avx512_subkeyHtbl, ghashin_offset, HashKey_16, true, true); - __ vpternlogq(ZTMP1, 0x96, ZTMP5, xmm27, Assembler::AVX_512bit); // ZTMP1 = ZTMP1 + ZTMP5 + zmm27 - __ vpternlogq(ZTMP2, 0x96, ZTMP6, xmm26, Assembler::AVX_512bit); // ZTMP2 = ZTMP2 + ZTMP6 + zmm26 - __ vpternlogq(ZTMP3, 0x96, ZTMP7, xmm25, Assembler::AVX_512bit); // ZTMP3 = ZTMP3 + ZTMP7 + zmm25 - __ evpxorq(ZTMP4, ZTMP4, ZTMP8, Assembler::AVX_512bit); // ZTMP4 = ZTMP4 + ZTMP8 - - __ addl(ghash_pos, 128); - __ addl(rbx, 128); - - // Ghash remaining blocks - __ bind(LOOP); - __ cmpl(ghash_pos, pos); - __ jcc(Assembler::aboveEqual, ACCUMULATE); - // Load next cipher blocks and corresponding ghash keys - __ evmovdquq(ZTMP13, Address(ct, ghash_pos, Address::times_1, 0 * 64), Assembler::AVX_512bit); - __ evmovdquq(ZTMP14, Address(ct, ghash_pos, Address::times_1, 1 * 64), Assembler::AVX_512bit); - __ vpshufb(ZTMP13, ZTMP13, xmm24, Assembler::AVX_512bit); - __ vpshufb(ZTMP14, ZTMP14, xmm24, Assembler::AVX_512bit); - __ evmovdquq(ZTMP15, Address(avx512_subkeyHtbl, rbx, Address::times_1, 0 * 64), Assembler::AVX_512bit); - __ evmovdquq(ZTMP16, Address(avx512_subkeyHtbl, rbx, Address::times_1, 1 * 64), Assembler::AVX_512bit); - - // ghash blocks 0 - 3 - carrylessMultiply(ZTMP6, ZTMP7, ZTMP8, ZTMP5, ZTMP13, ZTMP15); - - // ghash blocks 4 - 7 - carrylessMultiply(ZTMP10, ZTMP11, ZTMP12, ZTMP9, ZTMP14, ZTMP16); - - // update sums - // ZTMP1 = ZTMP1 + ZTMP5 + ZTMP9 - // ZTMP2 = ZTMP2 + ZTMP6 + ZTMP10 - // ZTMP3 = ZTMP3 + ZTMP7 xor ZTMP11 - // ZTMP4 = ZTMP4 + ZTMP8 xor ZTMP12 - xorGHASH(ZTMP1, ZTMP2, ZTMP3, ZTMP4, ZTMP5, ZTMP9, ZTMP6, ZTMP10, ZTMP7, ZTMP11, ZTMP8, ZTMP12); - __ addl(ghash_pos, 128); - __ addl(rbx, 128); - __ jmp(LOOP); - - // Integrate ZTMP3/ZTMP4 into ZTMP1 and ZTMP2 - __ bind(ACCUMULATE); - __ evpxorq(ZTMP3, ZTMP3, ZTMP4, Assembler::AVX_512bit); - __ vpsrldq(ZTMP7, ZTMP3, 8, Assembler::AVX_512bit); - __ vpslldq(ZTMP8, ZTMP3, 8, Assembler::AVX_512bit); - __ evpxorq(ZTMP1, ZTMP1, ZTMP7, Assembler::AVX_512bit); - __ evpxorq(ZTMP2, ZTMP2, ZTMP8, Assembler::AVX_512bit); - - // Add ZTMP1 and ZTMP2 128 - bit words horizontally - vhpxori4x128(ZTMP1, ZTMP11); - vhpxori4x128(ZTMP2, ZTMP12); - // Load reduction polynomial and compute final reduction - __ evmovdquq(ZTMP15, ExternalAddress(ghash_polynomial_reduction_addr()), Assembler::AVX_512bit, rbx /*rscratch*/); - vclmul_reduce(AAD_HASHx, ZTMP15, ZTMP1, ZTMP2, ZTMP3, ZTMP4); - - // Pre-increment counter for next operation - __ vpaddd(CTR_BLOCKx, CTR_BLOCKx, xmm18, Assembler::AVX_128bit); - // Shuffle counter and save the updated value - __ vpshufb(CTR_BLOCKx, CTR_BLOCKx, xmm24, Assembler::AVX_512bit); + __ bind(GHASH_DONE); + //Pre-increment counter for next operation, make sure that counter value is incremented on the LSB + __ vpshufb(CTR_BLOCKx, CTR_BLOCKx, SHUF_MASK, Assembler::AVX_128bit); + __ vpaddd(CTR_BLOCKx, CTR_BLOCKx, ADD_1234, Assembler::AVX_128bit); + __ vpshufb(CTR_BLOCKx, CTR_BLOCKx, SHUF_MASK, Assembler::AVX_128bit); __ movdqu(Address(counter, 0), CTR_BLOCKx); - // Load ghash lswap mask + //Load ghash lswap mask __ movdqu(xmm24, ExternalAddress(ghash_long_swap_mask_addr()), rbx /*rscratch*/); - // Shuffle ghash using lbswap_mask and store it + //Shuffle ghash using lbswap_mask and store it __ vpshufb(AAD_HASHx, AAD_HASHx, xmm24, Assembler::AVX_128bit); __ movdqu(Address(state, 0), AAD_HASHx); - __ jmp(ENC_DEC_DONE); - __ bind(GENERATE_HTBL_48_BLKS); - generateHtbl_48_block_zmm(subkeyHtbl, avx512_subkeyHtbl, rbx /*rscratch*/); + //Zero out sensitive data + __ evpxorq(ZTMP21, ZTMP21, ZTMP21, Assembler::AVX_512bit); + __ evpxorq(ZTMP0, ZTMP0, ZTMP0, Assembler::AVX_512bit); + __ evpxorq(ZTMP1, ZTMP1, ZTMP1, Assembler::AVX_512bit); + __ evpxorq(ZTMP2, ZTMP2, ZTMP2, Assembler::AVX_512bit); + __ evpxorq(ZTMP3, ZTMP3, ZTMP3, Assembler::AVX_512bit); __ bind(ENC_DEC_DONE); - __ movq(rax, pos); } //Implements data * hashkey mod (128, 127, 126, 121, 0) diff --git a/src/hotspot/cpu/x86/stubGenerator_x86_64_arraycopy.cpp b/src/hotspot/cpu/x86/stubGenerator_x86_64_arraycopy.cpp index 5b316881d03..c72c32e796d 100644 --- a/src/hotspot/cpu/x86/stubGenerator_x86_64_arraycopy.cpp +++ b/src/hotspot/cpu/x86/stubGenerator_x86_64_arraycopy.cpp @@ -2627,7 +2627,6 @@ address StubGenerator::generate_unsafe_setmemory(const char *name, // Fill words { - Label L_wordsTail, L_wordsLoop, L_wordsTailLoop; UnsafeMemoryAccessMark umam(this, true, true); // At this point, we know the lower bit of size is zero and a @@ -2641,7 +2640,6 @@ address StubGenerator::generate_unsafe_setmemory(const char *name, // Fill QUADWORDs { - Label L_qwordLoop, L_qwordsTail, L_qwordsTailLoop; UnsafeMemoryAccessMark umam(this, true, true); // At this point, we know the lower 3 bits of size are zero and a @@ -2658,7 +2656,6 @@ address StubGenerator::generate_unsafe_setmemory(const char *name, // Fill DWORDs { - Label L_dwordLoop, L_dwordsTail, L_dwordsTailLoop; UnsafeMemoryAccessMark umam(this, true, true); // At this point, we know the lower 2 bits of size are zero and a diff --git a/src/hotspot/cpu/x86/stubGenerator_x86_64_ghash.cpp b/src/hotspot/cpu/x86/stubGenerator_x86_64_ghash.cpp index 2056fa05765..5a9b0848413 100644 --- a/src/hotspot/cpu/x86/stubGenerator_x86_64_ghash.cpp +++ b/src/hotspot/cpu/x86/stubGenerator_x86_64_ghash.cpp @@ -1,5 +1,5 @@ /* -* Copyright (c) 2019, 2021, Intel Corporation. All rights reserved. +* Copyright (c) 2019, 2024, Intel Corporation. All rights reserved. * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -57,7 +57,10 @@ address StubGenerator::ghash_byte_swap_mask_addr() { // Polynomial x^128+x^127+x^126+x^121+1 ATTRIBUTE_ALIGNED(16) static const uint64_t GHASH_POLYNOMIAL[] = { - 0x0000000000000001UL, 0xC200000000000000UL, + 0x0000000000000001ULL, 0xC200000000000000ULL, + 0x0000000000000001ULL, 0xC200000000000000ULL, + 0x0000000000000001ULL, 0xC200000000000000ULL, + 0x0000000000000001ULL, 0xC200000000000000ULL }; address StubGenerator::ghash_polynomial_addr() { return (address)GHASH_POLYNOMIAL; diff --git a/src/hotspot/cpu/x86/stubGenerator_x86_64_tanh.cpp b/src/hotspot/cpu/x86/stubGenerator_x86_64_tanh.cpp new file mode 100644 index 00000000000..92ac78e15cb --- /dev/null +++ b/src/hotspot/cpu/x86/stubGenerator_x86_64_tanh.cpp @@ -0,0 +1,502 @@ +/* +* Copyright (c) 2024, Intel Corporation. All rights reserved. +* Intel Math Library (LIBM) Source Code +* +* 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. +* +*/ + +#include "precompiled.hpp" +#include "macroAssembler_x86.hpp" +#include "stubGenerator_x86_64.hpp" + +/******************************************************************************/ +// ALGORITHM DESCRIPTION +// --------------------- +// +// tanh(x)=(exp(x)-exp(-x))/(exp(x)+exp(-x))=(1-exp(-2*x))/(1+exp(-2*x)) +// +// Let |x|=xH+xL (upper 26 bits, lower 27 bits) +// log2(e) rounded to 26 bits (high part) plus a double precision low part is +// L2EH+L2EL (upper 26, lower 53 bits) +// +// Let xH*L2EH=k+f+r`, where (k+f)*2^8*2=int(xH*L2EH*2^9), +// f=0.b1 b2 ... b8, k integer +// 2^{-f} is approximated as Tn[f]+Dn[f] +// Tn stores the high 53 bits, Dn stores (2^{-f}-Tn[f]) rounded to double precision +// +// r=r`+xL*L2EH+|x|*L2EL, |r|<2^{-9}+2^{-14}, +// for |x| in [23/64,3*2^7) +// e^{-2*|x|}=2^{-k-f}*2^{-r} ~ 2^{-k}*(Tn+Dn)*(1+p)=(T0+D0)*(1+p) +// +// For |x| in [2^{-4},2^5): +// 2^{-r}-1 ~ p=c1*r+c2*r^2+..+c5*r^5 +// Let R=1/(1+T0+p*T0), truncated to 35 significant bits +// R=1/(1+T0+D0+p*(T0+D0))*(1+eps), |eps|<2^{-33} +// 1+T0+D0+p*(T0+D0)=KH+KL, where +// KH=(1+T0+c1*r*T0)_high (leading 17 bits) +// KL=T0_low+D0+(c1*r*T0)_low+c1*r*D0+(c2*r^2+..c5*r^5)*T0 +// eps ~ (R*KH-1)+R*KL +// 1/(1+T0+D0+p*(T0+D0)) ~ R-R*eps +// The result is approximated as (1-T0-D0-(T0+D0)*p)*(R-R*eps) +// 1-T0-D0-(T0+D0)*p=-((KH-2)+KL) +// The result is formed as +// (KH-2)*R+(-(KH-2)*R*eps+(KL*R-KL*R*eps)), with the correct sign +// set at the end +// +// For |x| in [2^{-64},2^{-4}): +// A Taylor series expansion is used (x+p3*x^3+..+p13*x^{13}) +// +// For |x|<2^{-64}: x is returned +// +// For |x|>=2^32: return +/-1 +// +// Special cases: +// tanh(NaN) = quiet NaN, and raise invalid exception +// tanh(INF) = that INF +// tanh(+/-0) = +/-0 +// +/******************************************************************************/ + +ATTRIBUTE_ALIGNED(4) static const juint _HALFMASK[] = +{ + 4160749568, 2147483647 +}; + +ATTRIBUTE_ALIGNED(4) static const juint _ONEMASK[] = +{ + 0, 1072693248 +}; + +ATTRIBUTE_ALIGNED(4) static const juint _TWOMASK[] = +{ + 0, 1073741824 +}; + +ATTRIBUTE_ALIGNED(16) static const juint _MASK3[] = +{ + 0, 4294967280, 0, 4294967280 +}; + +ATTRIBUTE_ALIGNED(16) static const juint _RMASK[] = +{ + 4294705152, 4294967295, 4294705152, 4294967295 +}; + +ATTRIBUTE_ALIGNED(16) static const juint _L2E[] = +{ + 1610612736, 1082594631, 4166901572, 1055174155 +}; + +ATTRIBUTE_ALIGNED(16) static const juint _Shifter[] = +{ + 0, 1127743488, 0, 3275227136 +}; + +ATTRIBUTE_ALIGNED(16) static const juint _cv[] = +{ + 3884607281, 3168131199, 3607404735, 3190582024, 1874480759, + 1032041131, 4286760334, 1053736893, 4277811695, 3211144770, + 0, 0 +}; + +ATTRIBUTE_ALIGNED(4) static const juint _pv[] = +{ + 236289503, 1064135997, 463583772, 3215696314, 1441186365, + 3212977891, 286331153, 1069617425, 2284589306, 1066820852, + 1431655765, 3218429269 +}; + +ATTRIBUTE_ALIGNED(16) static const juint _T2_neg_f[] = +{ + 0, 1072693248, 0, 0, 1797923801, 1072687577, + 1950547427, 1013229059, 730821105, 1072681922, 2523232743, 1012067188, + 915592468, 1072676282, 352947894, 3161024371, 2174652632, 1072670657, + 4087714590, 1014450259, 35929225, 1072665048, 2809788041, 3159436968, + 2912730644, 1072659453, 3490067722, 3163405074, 2038973688, 1072653874, + 892941374, 1016046459, 1533953344, 1072648310, 769171851, 1015665633, + 1222472308, 1072642761, 1054357470, 3161021018, 929806999, 1072637227, + 3205336643, 1015259557, 481706282, 1072631708, 1696079173, 3162710528, + 3999357479, 1072626203, 2258941616, 1015924724, 2719515920, 1072620714, + 2760332941, 1015137933, 764307441, 1072615240, 3021057420, 3163329523, + 2256325230, 1072609780, 580117746, 1015317295, 2728693978, 1072604335, + 396109971, 3163462691, 2009970496, 1072598905, 2159039665, 3162572948, + 4224142467, 1072593489, 3389820386, 1015207202, 610758006, 1072588089, + 1965209397, 3161866232, 3884662774, 1072582702, 2158611599, 1014210185, + 991358482, 1072577331, 838715019, 3163157668, 351641897, 1072571974, + 2172261526, 3163010599, 1796832535, 1072566631, 3176955716, 3160585513, + 863738719, 1072561303, 1326992220, 3162613197, 1679558232, 1072555989, + 2390342287, 3163333970, 4076975200, 1072550689, 2029000899, 1015208535, + 3594158869, 1072545404, 2456521700, 3163256561, 64696965, 1072540134, + 1768797490, 1015816960, 1912561781, 1072534877, 3147495102, 1015678253, + 382305176, 1072529635, 2347622376, 3162578625, 3898795731, 1072524406, + 1249994144, 1011869818, 3707479175, 1072519192, 3613079303, 1014164738, + 3939148246, 1072513992, 3210352148, 1015274323, 135105010, 1072508807, + 1906148728, 3163375739, 721996136, 1072503635, 563754734, 1015371318, + 1242007932, 1072498477, 1132034716, 3163339831, 1532734324, 1072493333, + 3094216535, 3163162857, 1432208378, 1072488203, 1401068914, 3162363963, + 778901109, 1072483087, 2248183955, 3161268751, 3706687593, 1072477984, + 3521726940, 1013253067, 1464976603, 1072472896, 3507292405, 3161977534, + 2483480501, 1072467821, 1216371780, 1013034172, 2307442995, 1072462760, + 3190117721, 3162404539, 777507147, 1072457713, 4282924205, 1015187533, + 2029714210, 1072452679, 613660079, 1015099143, 1610600570, 1072447659, + 3766732298, 1015760183, 3657065772, 1072442652, 399025623, 3162957078, + 3716502172, 1072437659, 2303740125, 1014042725, 1631695677, 1072432680, + 2717633076, 3162344026, 1540824585, 1072427714, 1064017011, 3163487690, + 3287523847, 1072422761, 1625971539, 3157009955, 2420883922, 1072417822, + 2049810052, 1014119888, 3080351519, 1072412896, 3379126788, 3157218001, + 815859274, 1072407984, 240396590, 3163487443, 4062661092, 1072403084, + 1422616006, 3163255318, 4076559943, 1072398198, 2119478331, 3160758351, + 703710506, 1072393326, 1384660846, 1015195891, 2380618042, 1072388466, + 3149557219, 3163320799, 364333489, 1072383620, 3923737744, 3161421373, + 3092190715, 1072378786, 814012168, 3159523422, 1822067026, 1072373966, + 1241994956, 1015340290, 697153126, 1072369159, 1283515429, 3163283189, + 3861050111, 1072364364, 254893773, 3162813180, 2572866477, 1072359583, + 878562433, 1015521741, 977020788, 1072354815, 3065100517, 1015541563, + 3218338682, 1072350059, 3404164304, 3162477108, 557149882, 1072345317, + 3672720709, 1014537265, 1434058175, 1072340587, 251133233, 1015085769, + 1405169241, 1072335870, 2998539689, 3162830951, 321958744, 1072331166, + 3401933767, 1015794558, 2331271250, 1072326474, 812057446, 1012207446, + 2990417245, 1072321795, 3683467745, 3163369326, 2152073944, 1072317129, + 1486860576, 3163203456, 3964284211, 1072312475, 2111583915, 1015427164, + 3985553595, 1072307834, 4002146062, 1015834136, 2069751141, 1072303206, + 1562170675, 3162724681, 2366108318, 1072298590, 2867985102, 3161762254, + 434316067, 1072293987, 2028358766, 1013458122, 424392917, 1072289396, + 2749202995, 3162838718, 2191782032, 1072284817, 2960257726, 1013742662, + 1297350157, 1072280251, 1308022040, 3163412558, 1892288442, 1072275697, + 2446255666, 3162600381, 3833209506, 1072271155, 2722920684, 1013754842, + 2682146384, 1072266626, 2082178513, 3163363419, 2591453363, 1072262109, + 2132396182, 3159074198, 3418903055, 1072257604, 2527457337, 3160820604, + 727685349, 1072253112, 2038246809, 3162358742, 2966275557, 1072248631, + 2176155324, 3159842759, 1403662306, 1072244163, 2788809599, 3161671007, + 194117574, 1072239707, 777528612, 3163412089, 3492293770, 1072235262, + 2248032210, 1015386826, 2568320822, 1072230830, 2732824428, 1014352915, + 1577608921, 1072226410, 1875489510, 3162968394, 380978316, 1072222002, + 854188970, 3160462686, 3134592888, 1072217605, 4232266862, 1015991134, + 1110089947, 1072213221, 1451641639, 1015474673, 2759350287, 1072208848, + 1148526634, 1015894933, 3649726105, 1072204487, 4085036346, 1015649474, + 3643909174, 1072200138, 3537586109, 1014354647, 2604962541, 1072195801, + 2614425274, 3163539192, 396319521, 1072191476, 4172420816, 3159074632, + 1176749997, 1072187162, 2738998779, 3162035844, 515457527, 1072182860, + 836709333, 1015651226, 2571947539, 1072178569, 3558159064, 3163376669, + 2916157145, 1072174290, 219487565, 1015309367, 1413356050, 1072170023, + 1651349291, 3162668166, 2224145553, 1072165767, 3482522030, 3161489169, + 919555682, 1072161523, 3121969534, 1012948226, 1660913392, 1072157290, + 4218599604, 1015135707, 19972402, 1072153069, 3507899862, 1016009292, + 158781403, 1072148859, 2221464712, 3163286453, 1944781191, 1072144660, + 3993278767, 3161724279, 950803702, 1072140473, 1655364926, 1015237032, + 1339972927, 1072136297, 167908909, 1015572152, 2980802057, 1072132132, + 378619896, 1015773303, 1447192521, 1072127979, 1462857171, 3162514521, + 903334909, 1072123837, 1636462108, 1015039997, 1218806132, 1072119706, + 1818613052, 3162548441, 2263535754, 1072115586, 752233586, 3162639008, + 3907805044, 1072111477, 2257091225, 3161550407, 1727278727, 1072107380, + 3562710623, 1011471940, 4182873220, 1072103293, 629542646, 3161996303, + 2555984613, 1072099218, 2652555442, 3162552692, 1013258799, 1072095154, + 1748797611, 3160129082, 3721688645, 1072091100, 3069276937, 1015839401, + 1963711167, 1072087058, 1744767757, 3160574294, 4201977662, 1072083026, + 748330254, 1013594357, 1719614413, 1072079006, 330458198, 3163282740, + 2979960120, 1072074996, 2599109725, 1014498493, 3561793907, 1072070997, + 1157054053, 1011890350, 3339203574, 1072067009, 1483497780, 3162408754, + 2186617381, 1072063032, 2270764084, 3163272713, 4273770423, 1072059065, + 3383180809, 3163218901, 885834528, 1072055110, 1973258547, 3162261564, + 488188413, 1072051165, 3199821029, 1015564048, 2956612997, 1072047230, + 2118169751, 3162735553, 3872257780, 1072043306, 1253592103, 1015958334, + 3111574537, 1072039393, 2606161479, 3162759746, 551349105, 1072035491, + 3821916050, 3162106589, 363667784, 1072031599, 813753950, 1015785209, + 2425981843, 1072027717, 2830390851, 3163346599, 2321106615, 1072023846, + 2171176610, 1009535771, 4222122499, 1072019985, 1277378074, 3163256737, + 3712504873, 1072016135, 88491949, 1015427660, 671025100, 1072012296, + 3832014351, 3163022030, 3566716925, 1072008466, 1536826856, 1014142433, + 3689071823, 1072004647, 2321004996, 3162552716, 917841882, 1072000839, + 18715565, 1015659308, 3723038930, 1071997040, 378465264, 3162569582, + 3395129871, 1071993252, 4025345435, 3162335388, 4109806887, 1071989474, + 422403966, 1014469229, 1453150082, 1071985707, 498154669, 3161488062, + 3896463087, 1071981949, 1139797873, 3161233805, 2731501122, 1071978202, + 1774031855, 3162470021, 2135241198, 1071974465, 1236747871, 1013589147, + 1990012071, 1071970738, 3529070563, 3162813193, 2178460671, 1071967021, + 777878098, 3162842493, 2583551245, 1071963314, 3161094195, 1015606491, + 3088564500, 1071959617, 1762311517, 1015045673, 3577096743, 1071955930, + 2951496418, 1013793687, 3933059031, 1071952253, 2133366768, 3161531832, + 4040676318, 1071948586, 4090609238, 1015663458, 3784486610, 1071944929, + 1581883040, 3161698953, 3049340112, 1071941282, 3062915824, 1013170595, + 1720398391, 1071937645, 3980678963, 3163300080, 3978100823, 1071934017, + 3513027190, 1015845963, 1118294578, 1071930400, 2197495694, 3159909401, + 1617004845, 1071926792, 82804944, 1010342778, 1065662932, 1071923194, + 2533670915, 1014530238, 3645941911, 1071919605, 3814685081, 3161573341, + 654919306, 1071916027, 3232961757, 3163047469, 569847338, 1071912458, + 472945272, 3159290729, 3278348324, 1071908898, 3069497416, 1014750712, + 78413852, 1071905349, 4183226867, 3163017251, 3743175029, 1071901808, + 2072812490, 3162175075, 1276261410, 1071898278, 300981948, 1014684169, + 1156440435, 1071894757, 2351451249, 1013967056, 3272845541, 1071891245, + 928852419, 3163488248, 3219942644, 1071887743, 3798990616, 1015368806, + 887463927, 1071884251, 3596744163, 3160794166, 460407023, 1071880768, + 4237175092, 3163138469, 1829099622, 1071877294, 1016661181, 3163461005, + 589198666, 1071873830, 2664346172, 3163157962, 926591435, 1071870375, + 3208833762, 3162913514, 2732492859, 1071866929, 2691479646, 3162255684, + 1603444721, 1071863493, 1548633640, 3162201326, 1726216749, 1071860066, + 2466808228, 3161676405, 2992903935, 1071856648, 2218154406, 1015228193, + 1000925746, 1071853240, 1018491672, 3163309544, 4232894513, 1071849840, + 2383938684, 1014668519, 3991843581, 1071846450, 4092853457, 1014585763, + 171030293, 1071843070, 3526460132, 1014428778, 1253935211, 1071839698, + 1395382931, 3159702613, 2839424854, 1071836335, 1171596163, 1013041679, + 526652809, 1071832982, 4223459736, 1015879375, 2799960843, 1071829637, + 1423655381, 1015022151, 964107055, 1071826302, 2800439588, 3162833221, + 3504003472, 1071822975, 3594001060, 3157330652, 1724976915, 1071819658, + 420909223, 3163117379, 4112506593, 1071816349, 2947355221, 1014371048, + 1972484976, 1071813050, 675290301, 3161640050, 3790955393, 1071809759, + 2352942462, 3163180090, 874372905, 1071806478, 100263788, 1015940732, + 1709341917, 1071803205, 2571168217, 1014152499, 1897844341, 1071799941, + 1254300460, 1015275938, 1337108031, 1071796686, 3203724452, 1014677845, + 4219606026, 1071793439, 2434574742, 1014681548, 1853186616, 1071790202, + 3066496371, 1015656574, 2725843665, 1071786973, 1433917087, 1014838523, + 2440944790, 1071783753, 2492769774, 1014147454, 897099801, 1071780542, + 754756297, 1015241005, 2288159958, 1071777339, 2169144469, 1014876021, + 2218315341, 1071774145, 2694295388, 3163288868, 586995997, 1071770960, + 41662348, 3162627992, 1588871207, 1071767783, 143439582, 3162963416, + 828946858, 1071764615, 10642492, 1015939438, 2502433899, 1071761455, + 2148595913, 1015023991, 2214878420, 1071758304, 892270087, 3163116422, + 4162030108, 1071755161, 2763428480, 1015529349, 3949972341, 1071752027, + 2068408548, 1014913868, 1480023343, 1071748902, 2247196168, 1015327453, + 948735466, 1071745785, 3516338028, 3162574883, 2257959872, 1071742676, + 3802946148, 1012964927, 1014845819, 1071739576, 3117910646, 3161559105, + 1416741826, 1071736484, 2196380210, 1011413563, 3366293073, 1071733400, + 3119426314, 1014120554, 2471440686, 1071730325, 968836267, 3162214888, + 2930322912, 1071727258, 2599499422, 3162714047, 351405227, 1071724200, + 3125337328, 3159822479, 3228316108, 1071721149, 3010241991, 3158422804, + 2875075254, 1071718107, 4144233330, 3163333716, 3490863953, 1071715073, + 960797498, 3162948880, 685187902, 1071712048, 378731989, 1014843115, + 2952712987, 1071709030, 3293494651, 3160120301, 1608493509, 1071706021, + 3159622171, 3162807737, 852742562, 1071703020, 667253586, 1009793559, + 590962156, 1071700027, 3829346666, 3163275597, 728909815, 1071697042, + 383930225, 1015029468, 1172597893, 1071694065, 114433263, 1015347593, + 1828292879, 1071691096, 1255956747, 1015588398, 2602514713, 1071688135, + 2268929336, 1014354284, 3402036099, 1071685182, 405889334, 1015105656, + 4133881824, 1071682237, 2148155345, 3162931299, 410360776, 1071679301, + 1269990655, 1011975870, 728934454, 1071676372, 1413842688, 1014178612, + 702412510, 1071673451, 3803266087, 3162280415, 238821257, 1071670538, + 1469694871, 3162884987, 3541402996, 1071667632, 2759177317, 1014854626, + 1928746161, 1071664735, 983617676, 1014285177, 3899555717, 1071661845, + 427280750, 3162546972, 772914124, 1071658964, 4004372762, 1012230161, + 1048019041, 1071656090, 1398474845, 3160510595, 339411585, 1071653224, + 264588982, 3161636657, 2851812149, 1071650365, 2595802551, 1015767337, + 4200250559, 1071647514, 2808127345, 3161781938 +}; + +#define __ _masm-> + +address StubGenerator::generate_libmTanh() { + StubCodeMark mark(this, "StubRoutines", "libmTanh"); + address start = __ pc(); + + Label L_2TAG_PACKET_0_0_1, L_2TAG_PACKET_1_0_1, L_2TAG_PACKET_2_0_1, L_2TAG_PACKET_3_0_1; + Label L_2TAG_PACKET_4_0_1, L_2TAG_PACKET_5_0_1; + Label B1_2, B1_4; + + address HALFMASK = (address)_HALFMASK; + address ONEMASK = (address)_ONEMASK; + address TWOMASK = (address)_TWOMASK; + address MASK3 = (address)_MASK3; + address RMASK = (address)_RMASK; + address L2E = (address)_L2E; + address Shifter = (address)_Shifter; + address cv = (address)_cv; + address pv = (address)_pv; + address T2_neg_f = (address) _T2_neg_f; + + __ enter(); // required for proper stackwalking of RuntimeStub frame + + __ bind(B1_2); + __ movsd(xmm3, ExternalAddress(HALFMASK), r11 /*rscratch*/); + __ xorpd(xmm4, xmm4); + __ movsd(xmm1, ExternalAddress(L2E), r11 /*rscratch*/); + __ movsd(xmm2, ExternalAddress(L2E + 8), r11 /*rscratch*/); + __ movl(rax, 32768); + __ pinsrw(xmm4, rax, 3); + __ movsd(xmm6, ExternalAddress(Shifter), r11 /*rscratch*/); + __ pextrw(rcx, xmm0, 3); + __ andpd(xmm3, xmm0); + __ andnpd(xmm4, xmm0); + __ pshufd(xmm5, xmm4, 68); + __ movl(rdx, 32768); + __ andl(rdx, rcx); + __ andl(rcx, 32767); + __ subl(rcx, 16304); + __ cmpl(rcx, 144); + __ jcc(Assembler::aboveEqual, L_2TAG_PACKET_0_0_1); + __ subsd(xmm4, xmm3); + __ mulsd(xmm3, xmm1); + __ mulsd(xmm2, xmm5); + __ cvtsd2siq(rax, xmm3); + __ movq(xmm7, xmm3); + __ addsd(xmm3, xmm6); + __ mulsd(xmm1, xmm4); + __ movsd(xmm4, ExternalAddress(ONEMASK), r11 /*rscratch*/); + __ subsd(xmm3, xmm6); + __ xorpd(xmm0, xmm0); + __ addsd(xmm2, xmm1); + __ subsd(xmm7, xmm3); + __ movdqu(xmm6, ExternalAddress(cv), r11 /*rscratch*/); + __ addsd(xmm2, xmm7); + __ movl(rcx, 255); + __ andl(rcx, rax); + __ addl(rcx, rcx); + __ lea(r8, ExternalAddress(T2_neg_f)); + __ movdqu(xmm5, Address(r8, rcx, Address::times(8))); + __ shrl(rax, 4); + __ andl(rax, 65520); + __ subl(rax, 16368); + __ negl(rax); + __ pinsrw(xmm0, rax, 3); + __ movdqu(xmm1, ExternalAddress(cv + 16), r11 /*rscratch*/); + __ pshufd(xmm0, xmm0, 68); + __ mulpd(xmm0, xmm5); + __ movsd(xmm7, ExternalAddress(cv + 32), r11 /*rscratch*/); + __ pshufd(xmm2, xmm2, 68); + __ movq(xmm5, xmm4); + __ addsd(xmm4, xmm0); + __ mulpd(xmm6, xmm2); + __ mulsd(xmm7, xmm2); + __ mulpd(xmm2, xmm2); + __ addpd(xmm1, xmm6); + __ mulsd(xmm2, xmm2); + __ movsd(xmm3, ExternalAddress(ONEMASK), r11 /*rscratch*/); + __ mulpd(xmm1, xmm2); + __ pshufd(xmm6, xmm1, 78); + __ addsd(xmm1, xmm6); + __ movq(xmm6, xmm1); + __ addsd(xmm1, xmm7); + __ mulsd(xmm1, xmm0); + __ addsd(xmm1, xmm4); + __ andpd(xmm4, ExternalAddress(MASK3), r11 /*rscratch*/); + __ divsd(xmm5, xmm1); + __ subsd(xmm3, xmm4); + __ pshufd(xmm1, xmm0, 238); + __ addsd(xmm3, xmm0); + __ movq(xmm2, xmm4); + __ addsd(xmm3, xmm1); + __ mulsd(xmm1, xmm7); + __ mulsd(xmm7, xmm0); + __ addsd(xmm3, xmm1); + __ addsd(xmm4, xmm7); + __ movsd(xmm1, ExternalAddress(RMASK), r11 /*rscratch*/); + __ mulsd(xmm6, xmm0); + __ andpd(xmm4, ExternalAddress(MASK3), r11 /*rscratch*/); + __ addsd(xmm3, xmm6); + __ movq(xmm6, xmm4); + __ subsd(xmm2, xmm4); + __ addsd(xmm2, xmm7); + __ movsd(xmm7, ExternalAddress(ONEMASK), r11 /*rscratch*/); + __ andpd(xmm5, xmm1); + __ addsd(xmm3, xmm2); + __ mulsd(xmm4, xmm5); + __ xorpd(xmm2, xmm2); + __ mulsd(xmm3, xmm5); + __ subsd(xmm6, ExternalAddress(TWOMASK), r11 /*rscratch*/); + __ subsd(xmm4, xmm7); + __ xorl(rdx, 32768); + __ pinsrw(xmm2, rdx, 3); + __ addsd(xmm4, xmm3); + __ mulsd(xmm6, xmm5); + __ movq(xmm1, xmm3); + __ mulsd(xmm3, xmm4); + __ movq(xmm0, xmm6); + __ mulsd(xmm6, xmm4); + __ subsd(xmm1, xmm3); + __ subsd(xmm1, xmm6); + __ addsd(xmm0, xmm1); + __ xorpd(xmm0, xmm2); + __ jmp(B1_4); + + __ bind(L_2TAG_PACKET_0_0_1); + __ addl(rcx, 960); + __ cmpl(rcx, 1104); + __ jcc(Assembler::aboveEqual, L_2TAG_PACKET_1_0_1); + __ movdqu(xmm2, ExternalAddress(pv), r11 /*rscratch*/); + __ pshufd(xmm1, xmm0, 68); + __ movdqu(xmm3, ExternalAddress(pv + 16), r11 /*rscratch*/); + __ mulpd(xmm1, xmm1); + __ movdqu(xmm4, ExternalAddress(pv + 32), r11 /*rscratch*/); + __ mulpd(xmm2, xmm1); + __ pshufd(xmm5, xmm1, 68); + __ addpd(xmm2, xmm3); + __ mulsd(xmm5, xmm5); + __ mulpd(xmm2, xmm1); + __ mulsd(xmm5, xmm5); + __ addpd(xmm2, xmm4); + __ mulpd(xmm2, xmm5); + __ pshufd(xmm5, xmm2, 238); + __ addsd(xmm2, xmm5); + __ mulsd(xmm2, xmm0); + __ addsd(xmm0, xmm2); + __ jmp(B1_4); + + __ bind(L_2TAG_PACKET_1_0_1); + __ addl(rcx, 15344); + __ cmpl(rcx, 16448); + __ jcc(Assembler::aboveEqual, L_2TAG_PACKET_2_0_1); + __ cmpl(rcx, 16); + __ jcc(Assembler::below, L_2TAG_PACKET_3_0_1); + __ xorpd(xmm2, xmm2); + __ movl(rax, 17392); + __ pinsrw(xmm2, rax, 3); + __ mulsd(xmm2, xmm0); + __ addsd(xmm2, xmm0); + __ jmp(B1_4); + + __ bind(L_2TAG_PACKET_3_0_1); + __ movq(xmm2, xmm0); + __ mulsd(xmm2, xmm2); + __ jmp(B1_4); + + __ bind(L_2TAG_PACKET_2_0_1); + __ cmpl(rcx, 32752); + __ jcc(Assembler::aboveEqual, L_2TAG_PACKET_4_0_1); + __ xorpd(xmm2, xmm2); + __ movl(rcx, 15344); + __ pinsrw(xmm2, rcx, 3); + __ movq(xmm3, xmm2); + __ mulsd(xmm2, xmm2); + __ addsd(xmm2, xmm3); + + __ bind(L_2TAG_PACKET_5_0_1); + __ xorpd(xmm0, xmm0); + __ orl(rdx, 16368); + __ pinsrw(xmm0, rdx, 3); + __ jmp(B1_4); + + __ bind(L_2TAG_PACKET_4_0_1); + __ movq(xmm2, xmm0); + __ movdl(rax, xmm0); + __ psrlq(xmm2, 20); + __ movdl(rcx, xmm2); + __ orl(rcx, rax); + __ cmpl(rcx, 0); + __ jcc(Assembler::equal, L_2TAG_PACKET_5_0_1); + __ addsd(xmm0, xmm0); + + __ bind(B1_4); + __ leave(); // required for proper stackwalking of RuntimeStub frame + __ ret(0); + + return start; +} + +#undef __ diff --git a/src/hotspot/cpu/x86/templateInterpreterGenerator_x86_32.cpp b/src/hotspot/cpu/x86/templateInterpreterGenerator_x86_32.cpp index ba9eb32e8c1..75611524e3b 100644 --- a/src/hotspot/cpu/x86/templateInterpreterGenerator_x86_32.cpp +++ b/src/hotspot/cpu/x86/templateInterpreterGenerator_x86_32.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -373,6 +373,10 @@ address TemplateInterpreterGenerator::generate_math_entry(AbstractInterpreter::M // [ lo(arg) ] // [ hi(arg) ] // + if (kind == Interpreter::java_lang_math_tanh) { + return nullptr; + } + if (kind == Interpreter::java_lang_math_fmaD) { if (!UseFMA) { return nullptr; // Generate a vanilla entry diff --git a/src/hotspot/cpu/x86/templateInterpreterGenerator_x86_64.cpp b/src/hotspot/cpu/x86/templateInterpreterGenerator_x86_64.cpp index 26eea4c1d6a..5ea2d8eba25 100644 --- a/src/hotspot/cpu/x86/templateInterpreterGenerator_x86_64.cpp +++ b/src/hotspot/cpu/x86/templateInterpreterGenerator_x86_64.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -465,6 +465,10 @@ address TemplateInterpreterGenerator::generate_math_entry(AbstractInterpreter::M } else { __ call_VM_leaf0(CAST_FROM_FN_PTR(address, SharedRuntime::dtan)); } + } else if (kind == Interpreter::java_lang_math_tanh) { + assert(StubRoutines::dtanh() != nullptr, "not initialized"); + __ movdbl(xmm0, Address(rsp, wordSize)); + __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dtanh()))); } else if (kind == Interpreter::java_lang_math_abs) { assert(StubRoutines::x86::double_sign_mask() != nullptr, "not initialized"); __ movdbl(xmm0, Address(rsp, wordSize)); diff --git a/src/hotspot/cpu/x86/templateTable_x86.cpp b/src/hotspot/cpu/x86/templateTable_x86.cpp index fc6844aedd6..527d961259e 100644 --- a/src/hotspot/cpu/x86/templateTable_x86.cpp +++ b/src/hotspot/cpu/x86/templateTable_x86.cpp @@ -2579,8 +2579,7 @@ void TemplateTable::_return(TosState state) { Register robj = LP64_ONLY(c_rarg1) NOT_LP64(rax); __ movptr(robj, aaddress(0)); __ load_klass(rdi, robj, rscratch1); - __ movl(rdi, Address(rdi, Klass::access_flags_offset())); - __ testl(rdi, JVM_ACC_HAS_FINALIZER); + __ testb(Address(rdi, Klass::misc_flags_offset()), KlassFlags::_misc_has_finalizer); Label skip_register_finalizer; __ jcc(Assembler::zero, skip_register_finalizer); @@ -4049,6 +4048,7 @@ void TemplateTable::_new() { __ push(rcx); // save the contexts of klass for initializing the header // make sure klass is initialized + // init_state needs acquire, but x86 is TSO, and so we are already good. #ifdef _LP64 assert(VM_Version::supports_fast_class_init_checks(), "must support fast class initialization checks"); __ clinit_barrier(rcx, r15_thread, nullptr /*L_fast_path*/, &slow_case); diff --git a/src/hotspot/cpu/x86/upcallLinker_x86_32.cpp b/src/hotspot/cpu/x86/upcallLinker_x86_32.cpp index e5075e180d9..d795c751d02 100644 --- a/src/hotspot/cpu/x86/upcallLinker_x86_32.cpp +++ b/src/hotspot/cpu/x86/upcallLinker_x86_32.cpp @@ -24,7 +24,7 @@ #include "precompiled.hpp" #include "prims/upcallLinker.hpp" -address UpcallLinker::make_upcall_stub(jobject receiver, Method* entry, +address UpcallLinker::make_upcall_stub(jobject receiver, Symbol* signature, BasicType* out_sig_bt, int total_out_args, BasicType ret_type, jobject jabi, jobject jconv, diff --git a/src/hotspot/cpu/x86/upcallLinker_x86_64.cpp b/src/hotspot/cpu/x86/upcallLinker_x86_64.cpp index 82179f9022e..bc261bfd93f 100644 --- a/src/hotspot/cpu/x86/upcallLinker_x86_64.cpp +++ b/src/hotspot/cpu/x86/upcallLinker_x86_64.cpp @@ -23,7 +23,7 @@ #include "precompiled.hpp" #include "asm/macroAssembler.hpp" -#include "code/codeBlob.hpp" +#include "classfile/javaClasses.hpp" #include "code/codeBlob.hpp" #include "code/vmreg.inline.hpp" #include "compiler/disassembler.hpp" @@ -169,10 +169,10 @@ static void restore_callee_saved_registers(MacroAssembler* _masm, const ABIDescr __ block_comment("} restore_callee_saved_regs "); } -static const int upcall_stub_code_base_size = 1024; +static const int upcall_stub_code_base_size = 1200; static const int upcall_stub_size_per_arg = 16; -address UpcallLinker::make_upcall_stub(jobject receiver, Method* entry, +address UpcallLinker::make_upcall_stub(jobject receiver, Symbol* signature, BasicType* out_sig_bt, int total_out_args, BasicType ret_type, jobject jabi, jobject jconv, @@ -281,7 +281,6 @@ address UpcallLinker::make_upcall_stub(jobject receiver, Method* entry, __ block_comment("{ on_entry"); __ vzeroupper(); __ lea(c_rarg0, Address(rsp, frame_data_offset)); - __ movptr(c_rarg1, (intptr_t)receiver); // stack already aligned __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, UpcallLinker::on_entry))); __ movptr(r15_thread, rax); @@ -297,12 +296,10 @@ address UpcallLinker::make_upcall_stub(jobject receiver, Method* entry, arg_shuffle.generate(_masm, shuffle_reg, abi._shadow_space_bytes, 0); __ block_comment("} argument shuffle"); - __ block_comment("{ receiver "); - __ get_vm_result(j_rarg0, r15_thread); - __ block_comment("} receiver "); - - __ mov_metadata(rbx, entry); - __ movptr(Address(r15_thread, JavaThread::callee_target_offset()), rbx); // just in case callee is deoptimized + __ block_comment("{ load target "); + __ movptr(j_rarg0, (intptr_t)receiver); + __ call(RuntimeAddress(StubRoutines::upcall_stub_load_target())); // puts target Method* in rbx + __ block_comment("} load target "); __ push_cont_fastpath(); @@ -377,7 +374,7 @@ address UpcallLinker::make_upcall_stub(jobject receiver, Method* entry, #ifndef PRODUCT stringStream ss; - ss.print("upcall_stub_%s", entry->signature()->as_C_string()); + ss.print("upcall_stub_%s", signature->as_C_string()); const char* name = _masm->code_string(ss.freeze()); #else // PRODUCT const char* name = "upcall_stub"; diff --git a/src/hotspot/cpu/x86/vm_version_x86.cpp b/src/hotspot/cpu/x86/vm_version_x86.cpp index 6216cf44b88..038797924a9 100644 --- a/src/hotspot/cpu/x86/vm_version_x86.cpp +++ b/src/hotspot/cpu/x86/vm_version_x86.cpp @@ -437,6 +437,7 @@ class VM_Version_StubGenerator: public StubCodeGenerator { __ cmpl(rax, 0x80000); __ jcc(Assembler::notEqual, vector_save_restore); +#ifndef PRODUCT bool save_apx = UseAPX; VM_Version::set_apx_cpuFeatures(); UseAPX = true; @@ -453,6 +454,7 @@ class VM_Version_StubGenerator: public StubCodeGenerator { __ movq(Address(rsi, 8), r31); UseAPX = save_apx; +#endif #endif __ bind(vector_save_restore); // @@ -1045,6 +1047,10 @@ void VM_Version::get_processor_features() { FLAG_SET_DEFAULT(UseAPX, apx_supported ? true : false); } + if (!UseAPX) { + _features &= ~CPU_APX_F; + } + if (UseAVX < 2) { _features &= ~CPU_AVX2; _features &= ~CPU_AVX_IFMA; diff --git a/src/hotspot/cpu/x86/x86.ad b/src/hotspot/cpu/x86/x86.ad index 2b29dd14e4b..c88fa1ec5ce 100644 --- a/src/hotspot/cpu/x86/x86.ad +++ b/src/hotspot/cpu/x86/x86.ad @@ -2231,10 +2231,6 @@ const RegMask* Matcher::predicate_reg_mask(void) { return &_VECTMASK_REG_mask; } -const TypeVectMask* Matcher::predicate_reg_type(const Type* elemTy, int length) { - return new TypeVectMask(elemTy, length); -} - // Max vector size in bytes. 0 if not supported. int Matcher::vector_width_in_bytes(BasicType bt) { assert(is_java_primitive(bt), "only primitive type vectors"); @@ -2457,6 +2453,10 @@ bool Matcher::pd_clone_node(Node* n, Node* m, Matcher::MStack& mstack) { mstack.push(m, Visit); // m = ShiftCntV return true; } + if (is_encode_and_store_pattern(n, m)) { + mstack.push(m, Visit); + return true; + } return false; } diff --git a/src/hotspot/cpu/x86/x86_32.ad b/src/hotspot/cpu/x86/x86_32.ad index 7aa4f6a29a1..7c9695571da 100644 --- a/src/hotspot/cpu/x86/x86_32.ad +++ b/src/hotspot/cpu/x86/x86_32.ad @@ -6322,17 +6322,6 @@ instruct storeImmB(memory mem, immI8 src) %{ ins_pipe( ialu_mem_imm ); %} -// Store CMS card-mark Immediate -instruct storeImmCM(memory mem, immI8 src) %{ - match(Set mem (StoreCM mem src)); - - ins_cost(150); - format %{ "MOV8 $mem,$src\t! CMS card-mark imm0" %} - opcode(0xC6); /* C6 /0 */ - ins_encode( SetInstMark, OpcP, RMopc_Mem(0x00,mem), Con8or32(src), ClearInstMark); - ins_pipe( ialu_mem_imm ); -%} - // Store Double instruct storeDPR( memory mem, regDPR1 src) %{ predicate(UseSSE<=1); diff --git a/src/hotspot/cpu/x86/x86_64.ad b/src/hotspot/cpu/x86/x86_64.ad index 3bc4cac2f06..c3fa4c16e55 100644 --- a/src/hotspot/cpu/x86/x86_64.ad +++ b/src/hotspot/cpu/x86/x86_64.ad @@ -657,8 +657,7 @@ static void emit_cmpfp3(MacroAssembler* masm, Register dst) { __ movl(dst, -1); __ jcc(Assembler::parity, done); __ jcc(Assembler::below, done); - __ setb(Assembler::notEqual, dst); - __ movzbl(dst, dst); + __ setcc(Assembler::notEqual, dst); __ bind(done); } @@ -4342,6 +4341,7 @@ instruct loadP(rRegP dst, memory mem) // Load Compressed Pointer instruct loadN(rRegN dst, memory mem) %{ + predicate(n->as_Load()->barrier_data() == 0); match(Set dst (LoadN mem)); ins_cost(125); // XXX @@ -5127,6 +5127,7 @@ instruct storeImmP(memory mem, immP31 src) // Store Compressed Pointer instruct storeN(memory mem, rRegN src) %{ + predicate(n->as_Store()->barrier_data() == 0); match(Set mem (StoreN mem src)); ins_cost(125); // XXX @@ -5151,7 +5152,7 @@ instruct storeNKlass(memory mem, rRegN src) instruct storeImmN0(memory mem, immN0 zero) %{ - predicate(CompressedOops::base() == nullptr); + predicate(CompressedOops::base() == nullptr && n->as_Store()->barrier_data() == 0); match(Set mem (StoreN mem zero)); ins_cost(125); // XXX @@ -5164,6 +5165,7 @@ instruct storeImmN0(memory mem, immN0 zero) instruct storeImmN(memory mem, immN src) %{ + predicate(n->as_Store()->barrier_data() == 0); match(Set mem (StoreN mem src)); ins_cost(150); // XXX @@ -5296,32 +5298,6 @@ instruct storeImmB(memory mem, immI8 src) ins_pipe(ialu_mem_imm); %} -// Store CMS card-mark Immediate -instruct storeImmCM0_reg(memory mem, immI_0 zero) -%{ - predicate(UseCompressedOops && (CompressedOops::base() == nullptr)); - match(Set mem (StoreCM mem zero)); - - ins_cost(125); // XXX - format %{ "movb $mem, R12\t# CMS card-mark byte 0 (R12_heapbase==0)" %} - ins_encode %{ - __ movb($mem$$Address, r12); - %} - ins_pipe(ialu_mem_reg); -%} - -instruct storeImmCM0(memory mem, immI_0 src) -%{ - match(Set mem (StoreCM mem src)); - - ins_cost(150); // XXX - format %{ "movb $mem, $src\t# CMS card-mark byte 0" %} - ins_encode %{ - __ movb($mem$$Address, $src$$constant); - %} - ins_pipe(ialu_mem_imm); -%} - // Store Float instruct storeF(memory mem, regF src) %{ @@ -6388,7 +6364,7 @@ instruct cmovP_regUCF2_eq(cmpOpUCF2 cop, rFlagsRegUCF cr, rRegP dst, rRegP src) ins_pipe(pipe_cmov_reg); %} -instruct cmovL_imm_01(rRegL dst, immI_1 src, rFlagsReg cr, cmpOp cop) +instruct cmovL_imm_01(rRegL dst, immL1 src, rFlagsReg cr, cmpOp cop) %{ predicate(n->in(2)->in(2)->is_Con() && n->in(2)->in(2)->get_long() == 0); match(Set dst (CMoveL (Binary cop cr) (Binary src dst))); @@ -6426,7 +6402,7 @@ instruct cmovL_mem(cmpOp cop, rFlagsReg cr, rRegL dst, memory src) ins_pipe(pipe_cmov_mem); // XXX %} -instruct cmovL_imm_01U(rRegL dst, immI_1 src, rFlagsRegU cr, cmpOpU cop) +instruct cmovL_imm_01U(rRegL dst, immL1 src, rFlagsRegU cr, cmpOpU cop) %{ predicate(n->in(2)->in(2)->is_Con() && n->in(2)->in(2)->get_long() == 0); match(Set dst (CMoveL (Binary cop cr) (Binary src dst))); @@ -6452,7 +6428,7 @@ instruct cmovL_regU(cmpOpU cop, rFlagsRegU cr, rRegL dst, rRegL src) ins_pipe(pipe_cmov_reg); // XXX %} -instruct cmovL_imm_01UCF(rRegL dst, immI_1 src, rFlagsRegUCF cr, cmpOpUCF cop) +instruct cmovL_imm_01UCF(rRegL dst, immL1 src, rFlagsRegUCF cr, cmpOpUCF cop) %{ predicate(n->in(2)->in(2)->is_Con() && n->in(2)->in(2)->get_long() == 0); match(Set dst (CMoveL (Binary cop cr) (Binary src dst))); @@ -7070,13 +7046,11 @@ instruct compareAndSwapP(rRegI res, format %{ "cmpxchgq $mem_ptr,$newval\t# " "If rax == $mem_ptr then store $newval into $mem_ptr\n\t" - "sete $res\n\t" - "movzbl $res, $res" %} + "setcc $res \t# emits sete + movzbl or setzue for APX" %} ins_encode %{ __ lock(); __ cmpxchgq($newval$$Register, $mem_ptr$$Address); - __ setb(Assembler::equal, $res$$Register); - __ movzbl($res$$Register, $res$$Register); + __ setcc(Assembler::equal, $res$$Register); %} ins_pipe( pipe_cmpxchg ); %} @@ -7092,13 +7066,11 @@ instruct compareAndSwapL(rRegI res, format %{ "cmpxchgq $mem_ptr,$newval\t# " "If rax == $mem_ptr then store $newval into $mem_ptr\n\t" - "sete $res\n\t" - "movzbl $res, $res" %} + "setcc $res \t# emits sete + movzbl or setzue for APX" %} ins_encode %{ __ lock(); __ cmpxchgq($newval$$Register, $mem_ptr$$Address); - __ setb(Assembler::equal, $res$$Register); - __ movzbl($res$$Register, $res$$Register); + __ setcc(Assembler::equal, $res$$Register); %} ins_pipe( pipe_cmpxchg ); %} @@ -7114,13 +7086,11 @@ instruct compareAndSwapI(rRegI res, format %{ "cmpxchgl $mem_ptr,$newval\t# " "If rax == $mem_ptr then store $newval into $mem_ptr\n\t" - "sete $res\n\t" - "movzbl $res, $res" %} + "setcc $res \t# emits sete + movzbl or setzue for APX" %} ins_encode %{ __ lock(); __ cmpxchgl($newval$$Register, $mem_ptr$$Address); - __ setb(Assembler::equal, $res$$Register); - __ movzbl($res$$Register, $res$$Register); + __ setcc(Assembler::equal, $res$$Register); %} ins_pipe( pipe_cmpxchg ); %} @@ -7136,13 +7106,11 @@ instruct compareAndSwapB(rRegI res, format %{ "cmpxchgb $mem_ptr,$newval\t# " "If rax == $mem_ptr then store $newval into $mem_ptr\n\t" - "sete $res\n\t" - "movzbl $res, $res" %} + "setcc $res \t# emits sete + movzbl or setzue for APX" %} ins_encode %{ __ lock(); __ cmpxchgb($newval$$Register, $mem_ptr$$Address); - __ setb(Assembler::equal, $res$$Register); - __ movzbl($res$$Register, $res$$Register); + __ setcc(Assembler::equal, $res$$Register); %} ins_pipe( pipe_cmpxchg ); %} @@ -7158,13 +7126,11 @@ instruct compareAndSwapS(rRegI res, format %{ "cmpxchgw $mem_ptr,$newval\t# " "If rax == $mem_ptr then store $newval into $mem_ptr\n\t" - "sete $res\n\t" - "movzbl $res, $res" %} + "setcc $res \t# emits sete + movzbl or setzue for APX" %} ins_encode %{ __ lock(); __ cmpxchgw($newval$$Register, $mem_ptr$$Address); - __ setb(Assembler::equal, $res$$Register); - __ movzbl($res$$Register, $res$$Register); + __ setcc(Assembler::equal, $res$$Register); %} ins_pipe( pipe_cmpxchg ); %} @@ -7173,19 +7139,18 @@ instruct compareAndSwapN(rRegI res, memory mem_ptr, rax_RegN oldval, rRegN newval, rFlagsReg cr) %{ + predicate(n->as_LoadStore()->barrier_data() == 0); match(Set res (CompareAndSwapN mem_ptr (Binary oldval newval))); match(Set res (WeakCompareAndSwapN mem_ptr (Binary oldval newval))); effect(KILL cr, KILL oldval); format %{ "cmpxchgl $mem_ptr,$newval\t# " "If rax == $mem_ptr then store $newval into $mem_ptr\n\t" - "sete $res\n\t" - "movzbl $res, $res" %} + "setcc $res \t# emits sete + movzbl or setzue for APX" %} ins_encode %{ __ lock(); __ cmpxchgl($newval$$Register, $mem_ptr$$Address); - __ setb(Assembler::equal, $res$$Register); - __ movzbl($res$$Register, $res$$Register); + __ setcc(Assembler::equal, $res$$Register); %} ins_pipe( pipe_cmpxchg ); %} @@ -7262,6 +7227,7 @@ instruct compareAndExchangeN( memory mem_ptr, rax_RegN oldval, rRegN newval, rFlagsReg cr) %{ + predicate(n->as_LoadStore()->barrier_data() == 0); match(Set oldval (CompareAndExchangeN mem_ptr (Binary oldval newval))); effect(KILL cr); @@ -7483,6 +7449,7 @@ instruct xchgP( memory mem, rRegP newval) %{ %} instruct xchgN( memory mem, rRegN newval) %{ + predicate(n->as_LoadStore()->barrier_data() == 0); match(Set newval (GetAndSetN mem newval)); format %{ "XCHGL $newval,$mem]" %} ins_encode %{ @@ -9729,13 +9696,11 @@ instruct cmpLTMask(rRegI dst, rRegI p, rRegI q, rFlagsReg cr) ins_cost(400); format %{ "cmpl $p, $q\t# cmpLTMask\n\t" - "setlt $dst\n\t" - "movzbl $dst, $dst\n\t" + "setcc $dst \t# emits setlt + movzbl or setzul for APX" "negl $dst" %} ins_encode %{ __ cmpl($p$$Register, $q$$Register); - __ setb(Assembler::less, $dst$$Register); - __ movzbl($dst$$Register, $dst$$Register); + __ setcc(Assembler::less, $dst$$Register); __ negl($dst$$Register); %} ins_pipe(pipe_slow); @@ -11674,6 +11639,7 @@ instruct compN_rReg(rFlagsRegU cr, rRegN op1, rRegN op2) instruct compN_rReg_mem(rFlagsRegU cr, rRegN src, memory mem) %{ + predicate(n->in(2)->as_Load()->barrier_data() == 0); match(Set cr (CmpN src (LoadN mem))); format %{ "cmpl $src, $mem\t# compressed ptr" %} @@ -11695,6 +11661,7 @@ instruct compN_rReg_imm(rFlagsRegU cr, rRegN op1, immN op2) %{ instruct compN_mem_imm(rFlagsRegU cr, memory mem, immN src) %{ + predicate(n->in(2)->as_Load()->barrier_data() == 0); match(Set cr (CmpN src (LoadN mem))); format %{ "cmpl $mem, $src\t# compressed ptr" %} @@ -11735,7 +11702,8 @@ instruct testN_reg(rFlagsReg cr, rRegN src, immN0 zero) %{ instruct testN_mem(rFlagsReg cr, memory mem, immN0 zero) %{ - predicate(CompressedOops::base() != nullptr); + predicate(CompressedOops::base() != nullptr && + n->in(1)->as_Load()->barrier_data() == 0); match(Set cr (CmpN (LoadN mem) zero)); ins_cost(500); // XXX @@ -11748,7 +11716,8 @@ instruct testN_mem(rFlagsReg cr, memory mem, immN0 zero) instruct testN_mem_reg0(rFlagsReg cr, memory mem, immN0 zero) %{ - predicate(CompressedOops::base() == nullptr); + predicate(CompressedOops::base() == nullptr && + n->in(1)->as_Load()->barrier_data() == 0); match(Set cr (CmpN (LoadN mem) zero)); format %{ "cmpl R12, $mem\t# compressed ptr (R12_heapbase==0)" %} @@ -11860,16 +11829,14 @@ instruct cmpU3_reg_reg(rRegI dst, rRegI src1, rRegI src2, rFlagsReg flags) format %{ "cmpl $src1, $src2\t# CmpL3\n\t" "movl $dst, -1\n\t" "jb,u done\n\t" - "setne $dst\n\t" - "movzbl $dst, $dst\n\t" + "setcc $dst \t# emits setne + movzbl or setzune for APX" "done:" %} ins_encode %{ Label done; __ cmpl($src1$$Register, $src2$$Register); __ movl($dst$$Register, -1); __ jccb(Assembler::below, done); - __ setb(Assembler::notZero, $dst$$Register); - __ movzbl($dst$$Register, $dst$$Register); + __ setcc(Assembler::notZero, $dst$$Register); __ bind(done); %} ins_pipe(pipe_slow); @@ -11886,16 +11853,14 @@ instruct cmpL3_reg_reg(rRegI dst, rRegL src1, rRegL src2, rFlagsReg flags) format %{ "cmpq $src1, $src2\t# CmpL3\n\t" "movl $dst, -1\n\t" "jl,s done\n\t" - "setne $dst\n\t" - "movzbl $dst, $dst\n\t" + "setcc $dst \t# emits setne + movzbl or setzune for APX" "done:" %} ins_encode %{ Label done; __ cmpq($src1$$Register, $src2$$Register); __ movl($dst$$Register, -1); __ jccb(Assembler::less, done); - __ setb(Assembler::notZero, $dst$$Register); - __ movzbl($dst$$Register, $dst$$Register); + __ setcc(Assembler::notZero, $dst$$Register); __ bind(done); %} ins_pipe(pipe_slow); @@ -11912,16 +11877,14 @@ instruct cmpUL3_reg_reg(rRegI dst, rRegL src1, rRegL src2, rFlagsReg flags) format %{ "cmpq $src1, $src2\t# CmpL3\n\t" "movl $dst, -1\n\t" "jb,u done\n\t" - "setne $dst\n\t" - "movzbl $dst, $dst\n\t" + "setcc $dst \t# emits setne + movzbl or setzune for APX" "done:" %} ins_encode %{ Label done; __ cmpq($src1$$Register, $src2$$Register); __ movl($dst$$Register, -1); __ jccb(Assembler::below, done); - __ setb(Assembler::notZero, $dst$$Register); - __ movzbl($dst$$Register, $dst$$Register); + __ setcc(Assembler::notZero, $dst$$Register); __ bind(done); %} ins_pipe(pipe_slow); diff --git a/src/hotspot/cpu/zero/sharedRuntime_zero.cpp b/src/hotspot/cpu/zero/sharedRuntime_zero.cpp index 454f8e5f632..18ceb9514d3 100644 --- a/src/hotspot/cpu/zero/sharedRuntime_zero.cpp +++ b/src/hotspot/cpu/zero/sharedRuntime_zero.cpp @@ -105,15 +105,15 @@ void SharedRuntime::generate_deopt_blob() { _deopt_blob = generate_empty_deopt_blob(); } -SafepointBlob* SharedRuntime::generate_handler_blob(address call_ptr, int poll_type) { +SafepointBlob* SharedRuntime::generate_handler_blob(SharedStubId id, address call_ptr) { return generate_empty_safepoint_blob(); } -RuntimeStub* SharedRuntime::generate_resolve_blob(address destination, const char* name) { +RuntimeStub* SharedRuntime::generate_resolve_blob(SharedStubId id, address destination) { return generate_empty_runtime_stub(); } -RuntimeStub* SharedRuntime::generate_throw_exception(const char* name, address runtime_entry) { +RuntimeStub* SharedRuntime::generate_throw_exception(SharedStubId id, address runtime_entry) { return generate_empty_runtime_stub(); } diff --git a/src/hotspot/cpu/zero/upcallLinker_zero.cpp b/src/hotspot/cpu/zero/upcallLinker_zero.cpp index 6447dac86c9..408ebc32820 100644 --- a/src/hotspot/cpu/zero/upcallLinker_zero.cpp +++ b/src/hotspot/cpu/zero/upcallLinker_zero.cpp @@ -24,7 +24,7 @@ #include "precompiled.hpp" #include "prims/upcallLinker.hpp" -address UpcallLinker::make_upcall_stub(jobject mh, Method* entry, +address UpcallLinker::make_upcall_stub(jobject mh, Symbol* signature, BasicType* out_sig_bt, int total_out_args, BasicType ret_type, jobject jabi, jobject jconv, diff --git a/src/hotspot/cpu/zero/vm_version_zero.cpp b/src/hotspot/cpu/zero/vm_version_zero.cpp index 1fcf4b10862..7312dd11646 100644 --- a/src/hotspot/cpu/zero/vm_version_zero.cpp +++ b/src/hotspot/cpu/zero/vm_version_zero.cpp @@ -116,11 +116,6 @@ void VM_Version::initialize() { FLAG_SET_DEFAULT(UseVectorizedMismatchIntrinsic, false); } - if ((LockingMode != LM_LEGACY) && (LockingMode != LM_MONITOR)) { - warning("Unsupported locking mode for this CPU."); - FLAG_SET_DEFAULT(LockingMode, LM_LEGACY); - } - // Enable error context decoding on known platforms #if defined(IA32) || defined(AMD64) || defined(ARM) || \ defined(AARCH64) || defined(PPC) || defined(RISCV) || \ diff --git a/src/hotspot/cpu/zero/zeroInterpreter_zero.cpp b/src/hotspot/cpu/zero/zeroInterpreter_zero.cpp index 2b53042ef10..aab43e73396 100644 --- a/src/hotspot/cpu/zero/zeroInterpreter_zero.cpp +++ b/src/hotspot/cpu/zero/zeroInterpreter_zero.cpp @@ -485,26 +485,30 @@ int ZeroInterpreter::native_entry(Method* method, intptr_t UNUSED, TRAPS) { // Unlock if necessary if (monitor) { - BasicLock *lock = monitor->lock(); - markWord header = lock->displaced_header(); - oop rcvr = monitor->obj(); - monitor->set_obj(nullptr); - - bool dec_monitor_count = true; - if (header.to_pointer() != nullptr) { - markWord old_header = markWord::encode(lock); - if (rcvr->cas_set_mark(header, old_header) != old_header) { - monitor->set_obj(rcvr); - dec_monitor_count = false; - InterpreterRuntime::monitorexit(monitor); + bool success = false; + if (LockingMode == LM_LEGACY) { + BasicLock* lock = monitor->lock(); + oop rcvr = monitor->obj(); + monitor->set_obj(nullptr); + success = true; + markWord header = lock->displaced_header(); + if (header.to_pointer() != nullptr) { // Check for recursive lock + markWord old_header = markWord::encode(lock); + if (rcvr->cas_set_mark(header, old_header) != old_header) { + monitor->set_obj(rcvr); + success = false; + } + } + if (success) { + THREAD->dec_held_monitor_count(); } } - if (dec_monitor_count) { - THREAD->dec_held_monitor_count(); + if (!success) { + InterpreterRuntime::monitorexit(monitor); } } - unwind_and_return: + unwind_and_return: // Unwind the current activation thread->pop_zero_frame(); diff --git a/src/hotspot/os/aix/osThread_aix.cpp b/src/hotspot/os/aix/osThread_aix.cpp index 4049d6b58b7..ab08a766156 100644 --- a/src/hotspot/os/aix/osThread_aix.cpp +++ b/src/hotspot/os/aix/osThread_aix.cpp @@ -23,32 +23,27 @@ * */ -// no precompiled headers - -#include "memory/allocation.inline.hpp" -#include "runtime/handles.inline.hpp" -#include "runtime/mutexLocker.hpp" -#include "runtime/os.hpp" +#include "precompiled.hpp" +#include "memory/allocation.hpp" +#include "runtime/mutex.hpp" #include "runtime/osThread.hpp" -#include "runtime/safepoint.hpp" -#include "runtime/vmThread.hpp" -void OSThread::pd_initialize() { - _thread_id = 0; - _kernel_thread_id = 0; - _siginfo = nullptr; - _ucontext = nullptr; - _expanding_stack = 0; - _alt_sig_stack = nullptr; - - _last_cpu_times.sys = _last_cpu_times.user = 0L; +#include +OSThread::OSThread() + : _thread_id(0), + _thread_type(), + _kernel_thread_id(0), + _caller_sigmask(), + sr(), + _siginfo(nullptr), + _ucontext(nullptr), + _expanding_stack(0), + _alt_sig_stack(nullptr), + _startThread_lock(new Monitor(Mutex::event, "startThread_lock")) { sigemptyset(&_caller_sigmask); - - _startThread_lock = new Monitor(Mutex::event, "startThread_lock"); - assert(_startThread_lock != nullptr, "check"); } -void OSThread::pd_destroy() { +OSThread::~OSThread() { delete _startThread_lock; } diff --git a/src/hotspot/os/aix/osThread_aix.hpp b/src/hotspot/os/aix/osThread_aix.hpp index 5feb3c5799a..8f3799d0701 100644 --- a/src/hotspot/os/aix/osThread_aix.hpp +++ b/src/hotspot/os/aix/osThread_aix.hpp @@ -26,23 +26,18 @@ #ifndef OS_AIX_OSTHREAD_AIX_HPP #define OS_AIX_OSTHREAD_AIX_HPP - public: +#include "runtime/osThreadBase.hpp" +#include "suspendResume_posix.hpp" +#include "utilities/globalDefinitions.hpp" + +class OSThread : public OSThreadBase { + friend class VMStructs; + typedef pthread_t thread_id_t; - private: + thread_id_t _thread_id; int _thread_type; - public: - - int thread_type() const { - return _thread_type; - } - void set_thread_type(int type) { - _thread_type = type; - } - - private: - // On AIX, we use the pthread id as OSThread::thread_id and keep the kernel thread id // separately for diagnostic purposes. // @@ -54,15 +49,27 @@ sigset_t _caller_sigmask; // Caller's signal mask public: + OSThread(); + ~OSThread(); + + int thread_type() const { + return _thread_type; + } + void set_thread_type(int type) { + _thread_type = type; + } // Methods to save/restore caller's signal mask sigset_t caller_sigmask() const { return _caller_sigmask; } void set_caller_sigmask(sigset_t sigmask) { _caller_sigmask = sigmask; } -#ifndef PRODUCT - // Used for debugging, return a unique integer for each thread. - int thread_identifier() const { return _thread_id; } -#endif + thread_id_t thread_id() const { + return _thread_id; + } + void set_thread_id(thread_id_t id) { + _thread_id = id; + } + tid_t kernel_thread_id() const { return _kernel_thread_id; } @@ -71,7 +78,7 @@ } pthread_t pthread_id() const { - // Here: same as OSThread::thread_id() + // Here: same as thread_id() return _thread_id; } @@ -79,7 +86,6 @@ // suspension support. // *************************************************************** - public: // flags that support signal based suspend/resume on Aix are in a // separate class to avoid confusion with many flags in OSThread that // are used by VM level suspend/resume. @@ -125,22 +131,10 @@ return _startThread_lock; } - // *************************************************************** - // Platform dependent initialization and cleanup - // *************************************************************** - - private: - - void pd_initialize(); - void pd_destroy(); - - public: - - // The last measured values of cpu timing to prevent the "stale - // value return" bug in thread_cpu_time. - volatile struct { - jlong sys; - jlong user; - } _last_cpu_times; + // Printing + uintx thread_id_for_printing() const override { + return (uintx)_thread_id; + } +}; #endif // OS_AIX_OSTHREAD_AIX_HPP diff --git a/src/hotspot/os/aix/os_aix.cpp b/src/hotspot/os/aix/os_aix.cpp index fd16a7984a6..63aa53f0a23 100644 --- a/src/hotspot/os/aix/os_aix.cpp +++ b/src/hotspot/os/aix/os_aix.cpp @@ -2483,16 +2483,6 @@ int os::open(const char *path, int oflag, int mode) { return fd; } -// return current position of file pointer -jlong os::current_file_offset(int fd) { - return (jlong)::lseek(fd, (off_t)0, SEEK_CUR); -} - -// move file pointer to the specified offset -jlong os::seek_to_file_offset(int fd, jlong offset) { - return (jlong)::lseek(fd, (off_t)offset, SEEK_SET); -} - // current_thread_cpu_time(bool) and thread_cpu_time(Thread*, bool) // are used by JVM M&M and JVMTI to get user+sys or user CPU time // of a thread. diff --git a/src/hotspot/os/aix/vmStructs_aix.hpp b/src/hotspot/os/aix/vmStructs_aix.hpp index 1a2f4c4bf6e..f3bbc80e62c 100644 --- a/src/hotspot/os/aix/vmStructs_aix.hpp +++ b/src/hotspot/os/aix/vmStructs_aix.hpp @@ -29,9 +29,20 @@ // constants required by the Serviceability Agent. This file is // referenced by vmStructs.cpp. -#define VM_STRUCTS_OS(nonstatic_field, static_field, unchecked_nonstatic_field, volatile_nonstatic_field, nonproduct_nonstatic_field, c2_nonstatic_field, unchecked_c1_static_field, unchecked_c2_static_field) +#define VM_STRUCTS_OS(nonstatic_field, static_field, unchecked_nonstatic_field, volatile_nonstatic_field, nonproduct_nonstatic_field, c2_nonstatic_field, unchecked_c1_static_field, unchecked_c2_static_field) \ + \ + /******************************/ \ + /* Threads (NOTE: incomplete) */ \ + /******************************/ \ + nonstatic_field(OSThread, _thread_id, pthread_t) \ -#define VM_TYPES_OS(declare_type, declare_toplevel_type, declare_oop_type, declare_integer_type, declare_unsigned_integer_type, declare_c1_toplevel_type, declare_c2_type, declare_c2_toplevel_type) +#define VM_TYPES_OS(declare_type, declare_toplevel_type, declare_oop_type, declare_integer_type, declare_unsigned_integer_type, declare_c1_toplevel_type, declare_c2_type, declare_c2_toplevel_type) \ + \ + /**********************/ \ + /* Posix Thread IDs */ \ + /**********************/ \ + \ + declare_unsigned_integer_type(pthread_t) #define VM_INT_CONSTANTS_OS(declare_constant, declare_preprocessor_constant, declare_c1_constant, declare_c2_constant, declare_c2_preprocessor_constant) diff --git a/src/hotspot/os/bsd/gc/z/zPhysicalMemoryBacking_bsd.cpp b/src/hotspot/os/bsd/gc/z/zPhysicalMemoryBacking_bsd.cpp index 29825a9eab2..2e56c092a79 100644 --- a/src/hotspot/os/bsd/gc/z/zPhysicalMemoryBacking_bsd.cpp +++ b/src/hotspot/os/bsd/gc/z/zPhysicalMemoryBacking_bsd.cpp @@ -22,10 +22,10 @@ */ #include "precompiled.hpp" -#include "gc/shared/gcLogPrecious.hpp" #include "gc/z/zAddress.inline.hpp" #include "gc/z/zErrno.hpp" #include "gc/z/zGlobals.hpp" +#include "gc/z/zInitialize.hpp" #include "gc/z/zLargePages.inline.hpp" #include "gc/z/zPhysicalMemory.inline.hpp" #include "gc/z/zPhysicalMemoryBacking_bsd.hpp" @@ -82,7 +82,7 @@ ZPhysicalMemoryBacking::ZPhysicalMemoryBacking(size_t max_capacity) _base = (uintptr_t)os::reserve_memory(max_capacity); if (_base == 0) { // Failed - log_error_pd(gc)("Failed to reserve address space for backing memory"); + ZInitialize::error("Failed to reserve address space for backing memory"); return; } diff --git a/src/hotspot/os/bsd/osThread_bsd.cpp b/src/hotspot/os/bsd/osThread_bsd.cpp index 7b9ad1f76a8..4080ea1bf29 100644 --- a/src/hotspot/os/bsd/osThread_bsd.cpp +++ b/src/hotspot/os/bsd/osThread_bsd.cpp @@ -22,30 +22,32 @@ * */ -// no precompiled headers -#include "memory/allocation.inline.hpp" -#include "runtime/mutexLocker.hpp" +#include "precompiled.hpp" +#include "memory/allocation.hpp" +#include "runtime/mutex.hpp" #include "runtime/osThread.hpp" #include -void OSThread::pd_initialize() { +OSThread::OSThread() + : _thread_id( #ifdef __APPLE__ - _thread_id = 0; + 0 #else - _thread_id = nullptr; + nullptr #endif - _unique_thread_id = 0; - _pthread_id = nullptr; - _siginfo = nullptr; - _ucontext = nullptr; - _expanding_stack = 0; - _alt_sig_stack = nullptr; - + ), + _thread_type(), + _pthread_id(nullptr), + _unique_thread_id(0), + _caller_sigmask(), + sr(), + _siginfo(nullptr), + _ucontext(nullptr), + _expanding_stack(0), + _alt_sig_stack(nullptr), + _startThread_lock(new Monitor(Mutex::event, "startThread_lock")) { sigemptyset(&_caller_sigmask); - - _startThread_lock = new Monitor(Mutex::event, "startThread_lock"); - assert(_startThread_lock !=nullptr, "check"); } // Additional thread_id used to correlate threads in SA @@ -64,6 +66,6 @@ void OSThread::set_unique_thread_id() { #endif } -void OSThread::pd_destroy() { +OSThread::~OSThread() { delete _startThread_lock; } diff --git a/src/hotspot/os/bsd/osThread_bsd.hpp b/src/hotspot/os/bsd/osThread_bsd.hpp index 11376835063..e54e7195f98 100644 --- a/src/hotspot/os/bsd/osThread_bsd.hpp +++ b/src/hotspot/os/bsd/osThread_bsd.hpp @@ -25,19 +25,12 @@ #ifndef OS_BSD_OSTHREAD_BSD_HPP #define OS_BSD_OSTHREAD_BSD_HPP - private: - int _thread_type; +#include "runtime/osThreadBase.hpp" +#include "suspendResume_posix.hpp" +#include "utilities/globalDefinitions.hpp" - public: - - int thread_type() const { - return _thread_type; - } - void set_thread_type(int type) { - _thread_type = type; - } - - private: +class OSThread : public OSThreadBase { + friend class VMStructs; #ifdef __APPLE__ typedef thread_t thread_id_t; @@ -45,6 +38,9 @@ typedef pid_t thread_id_t; #endif + thread_id_t _thread_id; + int _thread_type; + // _pthread_id is the pthread id, which is used by library calls // (e.g. pthread_kill). pthread_t _pthread_id; @@ -57,15 +53,26 @@ sigset_t _caller_sigmask; // Caller's signal mask public: + OSThread(); + ~OSThread(); + + int thread_type() const { + return _thread_type; + } + void set_thread_type(int type) { + _thread_type = type; + } // Methods to save/restore caller's signal mask sigset_t caller_sigmask() const { return _caller_sigmask; } void set_caller_sigmask(sigset_t sigmask) { _caller_sigmask = sigmask; } -#ifndef PRODUCT - // Used for debugging, return a unique integer for each thread. - intptr_t thread_identifier() const { return (intptr_t)_pthread_id; } -#endif + thread_id_t thread_id() const { + return _thread_id; + } + void set_thread_id(thread_id_t id) { + _thread_id = id; + } pthread_t pthread_id() const { return _pthread_id; @@ -80,7 +87,6 @@ // suspension support. // *************************************************************** -public: // flags that support signal based suspend/resume on Bsd are in a // separate class to avoid confusion with many flags in OSThread that // are used by VM level suspend/resume. @@ -126,17 +132,9 @@ public: return _startThread_lock; } - // *************************************************************** - // Platform dependent initialization and cleanup - // *************************************************************** - -private: - - void pd_initialize(); - void pd_destroy(); - -// Reconciliation History -// osThread_solaris.hpp 1.24 99/08/27 13:11:54 -// End + uintx thread_id_for_printing() const override { + return (uintx)_thread_id; + } +}; #endif // OS_BSD_OSTHREAD_BSD_HPP diff --git a/src/hotspot/os/bsd/os_bsd.cpp b/src/hotspot/os/bsd/os_bsd.cpp index 9ad7c35e6bd..18818268c1f 100644 --- a/src/hotspot/os/bsd/os_bsd.cpp +++ b/src/hotspot/os/bsd/os_bsd.cpp @@ -2400,16 +2400,6 @@ int os::open(const char *path, int oflag, int mode) { return fd; } -// return current position of file pointer -jlong os::current_file_offset(int fd) { - return (jlong)::lseek(fd, (off_t)0, SEEK_CUR); -} - -// move file pointer to the specified offset -jlong os::seek_to_file_offset(int fd, jlong offset) { - return (jlong)::lseek(fd, (off_t)offset, SEEK_SET); -} - // current_thread_cpu_time(bool) and thread_cpu_time(Thread*, bool) // are used by JVM M&M and JVMTI to get user+sys or user CPU time // of a thread. diff --git a/src/hotspot/os/bsd/vmStructs_bsd.hpp b/src/hotspot/os/bsd/vmStructs_bsd.hpp index 84c1be77374..8c9c132e1c2 100644 --- a/src/hotspot/os/bsd/vmStructs_bsd.hpp +++ b/src/hotspot/os/bsd/vmStructs_bsd.hpp @@ -31,9 +31,21 @@ // constants required by the Serviceability Agent. This file is // referenced by vmStructs.cpp. -#define VM_STRUCTS_OS(nonstatic_field, static_field, unchecked_nonstatic_field, volatile_nonstatic_field, nonproduct_nonstatic_field, c2_nonstatic_field, unchecked_c1_static_field, unchecked_c2_static_field) +#define VM_STRUCTS_OS(nonstatic_field, static_field, unchecked_nonstatic_field, volatile_nonstatic_field, nonproduct_nonstatic_field, c2_nonstatic_field, unchecked_c1_static_field, unchecked_c2_static_field) \ + \ + /******************************/ \ + /* Threads (NOTE: incomplete) */ \ + /******************************/ \ + nonstatic_field(OSThread, _thread_id, OSThread::thread_id_t) \ + nonstatic_field(OSThread, _unique_thread_id, uint64_t) -#define VM_TYPES_OS(declare_type, declare_toplevel_type, declare_oop_type, declare_integer_type, declare_unsigned_integer_type, declare_c1_toplevel_type, declare_c2_type, declare_c2_toplevel_type) +#define VM_TYPES_OS(declare_type, declare_toplevel_type, declare_oop_type, declare_integer_type, declare_unsigned_integer_type, declare_c1_toplevel_type, declare_c2_type, declare_c2_toplevel_type) \ + \ + /**********************/ \ + /* Thread IDs */ \ + /**********************/ \ + \ + declare_unsigned_integer_type(OSThread::thread_id_t) #define VM_INT_CONSTANTS_OS(declare_constant, declare_preprocessor_constant, declare_c1_constant, declare_c2_constant, declare_c2_preprocessor_constant) diff --git a/src/hotspot/os/linux/cgroupSubsystem_linux.cpp b/src/hotspot/os/linux/cgroupSubsystem_linux.cpp index 1da0e44dbf4..d51499611a8 100644 --- a/src/hotspot/os/linux/cgroupSubsystem_linux.cpp +++ b/src/hotspot/os/linux/cgroupSubsystem_linux.cpp @@ -609,7 +609,7 @@ jlong CgroupSubsystem::memory_limit_in_bytes() { bool CgroupController::read_string(const char* filename, char* buf, size_t buf_size) { assert(buf != nullptr, "buffer must not be null"); assert(filename != nullptr, "filename must be given"); - char* s_path = subsystem_path(); + const char* s_path = subsystem_path(); if (s_path == nullptr) { log_debug(os, container)("read_string: subsystem path is null"); return false; @@ -679,7 +679,7 @@ bool CgroupController::read_numerical_key_value(const char* filename, const char assert(key != nullptr, "key must be given"); assert(result != nullptr, "result pointer must not be null"); assert(filename != nullptr, "file to search in must be given"); - char* s_path = subsystem_path(); + const char* s_path = subsystem_path(); if (s_path == nullptr) { log_debug(os, container)("read_numerical_key_value: subsystem path is null"); return false; diff --git a/src/hotspot/os/linux/cgroupSubsystem_linux.hpp b/src/hotspot/os/linux/cgroupSubsystem_linux.hpp index 4d5fa5d4879..40948dc5e28 100644 --- a/src/hotspot/os/linux/cgroupSubsystem_linux.hpp +++ b/src/hotspot/os/linux/cgroupSubsystem_linux.hpp @@ -103,9 +103,15 @@ } class CgroupController: public CHeapObj { + protected: + char* _cgroup_path; + char* _mount_point; public: - virtual char* subsystem_path() = 0; + virtual const char* subsystem_path() = 0; virtual bool is_read_only() = 0; + const char* cgroup_path() { return _cgroup_path; } + const char* mount_point() { return _mount_point; } + virtual bool needs_hierarchy_adjustment() { return false; } /* Read a numerical value as unsigned long * @@ -202,7 +208,12 @@ class CgroupCpuController: public CHeapObj { virtual int cpu_quota() = 0; virtual int cpu_period() = 0; virtual int cpu_shares() = 0; + virtual bool needs_hierarchy_adjustment() = 0; virtual bool is_read_only() = 0; + virtual const char* subsystem_path() = 0; + virtual void set_subsystem_path(const char* cgroup_path) = 0; + virtual const char* mount_point() = 0; + virtual const char* cgroup_path() = 0; }; // Pure virtual class representing version agnostic memory controllers @@ -217,7 +228,12 @@ class CgroupMemoryController: public CHeapObj { virtual jlong rss_usage_in_bytes() = 0; virtual jlong cache_usage_in_bytes() = 0; virtual void print_version_specific_info(outputStream* st, julong host_mem) = 0; + virtual bool needs_hierarchy_adjustment() = 0; virtual bool is_read_only() = 0; + virtual const char* subsystem_path() = 0; + virtual void set_subsystem_path(const char* cgroup_path) = 0; + virtual const char* mount_point() = 0; + virtual const char* cgroup_path() = 0; }; class CgroupSubsystem: public CHeapObj { diff --git a/src/hotspot/os/linux/cgroupUtil_linux.cpp b/src/hotspot/os/linux/cgroupUtil_linux.cpp index 24046991905..bc0e018d6be 100644 --- a/src/hotspot/os/linux/cgroupUtil_linux.cpp +++ b/src/hotspot/os/linux/cgroupUtil_linux.cpp @@ -22,6 +22,7 @@ * */ +#include "os_linux.hpp" #include "cgroupUtil_linux.hpp" int CgroupUtil::processor_count(CgroupCpuController* cpu_ctrl, int host_cpus) { @@ -46,3 +47,113 @@ int CgroupUtil::processor_count(CgroupCpuController* cpu_ctrl, int host_cpus) { log_trace(os, container)("OSContainer::active_processor_count: %d", result); return result; } + +void CgroupUtil::adjust_controller(CgroupMemoryController* mem) { + if (!mem->needs_hierarchy_adjustment()) { + // nothing to do + return; + } + log_trace(os, container)("Adjusting controller path for memory: %s", mem->subsystem_path()); + assert(mem->cgroup_path() != nullptr, "invariant"); + char* orig = os::strdup(mem->cgroup_path()); + char* cg_path = os::strdup(orig); + char* last_slash; + assert(cg_path[0] == '/', "cgroup path must start with '/'"); + julong phys_mem = os::Linux::physical_memory(); + char* limit_cg_path = nullptr; + jlong limit = mem->read_memory_limit_in_bytes(phys_mem); + jlong lowest_limit = phys_mem; + while ((last_slash = strrchr(cg_path, '/')) != cg_path) { + *last_slash = '\0'; // strip path + // update to shortened path and try again + mem->set_subsystem_path(cg_path); + limit = mem->read_memory_limit_in_bytes(phys_mem); + if (limit >= 0 && limit < lowest_limit) { + lowest_limit = limit; + os::free(limit_cg_path); // handles nullptr + limit_cg_path = os::strdup(cg_path); + } + } + // need to check limit at mount point + mem->set_subsystem_path("/"); + limit = mem->read_memory_limit_in_bytes(phys_mem); + if (limit >= 0 && limit < lowest_limit) { + lowest_limit = limit; + os::free(limit_cg_path); // handles nullptr + limit_cg_path = os::strdup("/"); + } + assert(lowest_limit >= 0, "limit must be positive"); + if ((julong)lowest_limit != phys_mem) { + // we've found a lower limit anywhere in the hierarchy, + // set the path to the limit path + assert(limit_cg_path != nullptr, "limit path must be set"); + mem->set_subsystem_path(limit_cg_path); + log_trace(os, container)("Adjusted controller path for memory to: %s. " + "Lowest limit was: " JLONG_FORMAT, + mem->subsystem_path(), + lowest_limit); + } else { + log_trace(os, container)("No lower limit found for memory in hierarchy %s, " + "adjusting to original path %s", + mem->mount_point(), orig); + mem->set_subsystem_path(orig); + } + os::free(cg_path); + os::free(orig); + os::free(limit_cg_path); +} + +void CgroupUtil::adjust_controller(CgroupCpuController* cpu) { + if (!cpu->needs_hierarchy_adjustment()) { + // nothing to do + return; + } + log_trace(os, container)("Adjusting controller path for cpu: %s", cpu->subsystem_path()); + assert(cpu->cgroup_path() != nullptr, "invariant"); + char* orig = os::strdup(cpu->cgroup_path()); + char* cg_path = os::strdup(orig); + char* last_slash; + assert(cg_path[0] == '/', "cgroup path must start with '/'"); + int host_cpus = os::Linux::active_processor_count(); + int cpus = CgroupUtil::processor_count(cpu, host_cpus); + int lowest_limit = host_cpus; + char* limit_cg_path = nullptr; + while ((last_slash = strrchr(cg_path, '/')) != cg_path) { + *last_slash = '\0'; // strip path + // update to shortened path and try again + cpu->set_subsystem_path(cg_path); + cpus = CgroupUtil::processor_count(cpu, host_cpus); + if (cpus != host_cpus && cpus < lowest_limit) { + lowest_limit = cpus; + os::free(limit_cg_path); // handles nullptr + limit_cg_path = os::strdup(cg_path); + } + } + // need to check limit at mount point + cpu->set_subsystem_path("/"); + cpus = CgroupUtil::processor_count(cpu, host_cpus); + if (cpus != host_cpus && cpus < lowest_limit) { + lowest_limit = cpus; + os::free(limit_cg_path); // handles nullptr + limit_cg_path = os::strdup(cg_path); + } + assert(lowest_limit >= 0, "limit must be positive"); + if (lowest_limit != host_cpus) { + // we've found a lower limit anywhere in the hierarchy, + // set the path to the limit path + assert(limit_cg_path != nullptr, "limit path must be set"); + cpu->set_subsystem_path(limit_cg_path); + log_trace(os, container)("Adjusted controller path for cpu to: %s. " + "Lowest limit was: %d", + cpu->subsystem_path(), + lowest_limit); + } else { + log_trace(os, container)("No lower limit found for cpu in hierarchy %s, " + "adjusting to original path %s", + cpu->mount_point(), orig); + cpu->set_subsystem_path(orig); + } + os::free(cg_path); + os::free(orig); + os::free(limit_cg_path); +} diff --git a/src/hotspot/os/linux/cgroupUtil_linux.hpp b/src/hotspot/os/linux/cgroupUtil_linux.hpp index fdcc4806c3b..19220af3177 100644 --- a/src/hotspot/os/linux/cgroupUtil_linux.hpp +++ b/src/hotspot/os/linux/cgroupUtil_linux.hpp @@ -32,6 +32,12 @@ class CgroupUtil: AllStatic { public: static int processor_count(CgroupCpuController* cpu, int host_cpus); + // Given a memory controller, adjust its path to a point in the hierarchy + // that represents the closest memory limit. + static void adjust_controller(CgroupMemoryController* m); + // Given a cpu controller, adjust its path to a point in the hierarchy + // that represents the closest cpu limit. + static void adjust_controller(CgroupCpuController* c); }; #endif // CGROUP_UTIL_LINUX_HPP diff --git a/src/hotspot/os/linux/cgroupV1Subsystem_linux.cpp b/src/hotspot/os/linux/cgroupV1Subsystem_linux.cpp index d7f9918afda..388ee5c6ea0 100644 --- a/src/hotspot/os/linux/cgroupV1Subsystem_linux.cpp +++ b/src/hotspot/os/linux/cgroupV1Subsystem_linux.cpp @@ -38,7 +38,15 @@ * Set directory to subsystem specific files based * on the contents of the mountinfo and cgroup files. */ -void CgroupV1Controller::set_subsystem_path(char *cgroup_path) { +void CgroupV1Controller::set_subsystem_path(const char* cgroup_path) { + if (_cgroup_path != nullptr) { + os::free(_cgroup_path); + } + if (_path != nullptr) { + os::free(_path); + _path = nullptr; + } + _cgroup_path = os::strdup(cgroup_path); stringStream ss; if (_root != nullptr && cgroup_path != nullptr) { if (strcmp(_root, "/") == 0) { @@ -52,7 +60,7 @@ void CgroupV1Controller::set_subsystem_path(char *cgroup_path) { ss.print_raw(_mount_point); _path = os::strdup(ss.base()); } else { - char *p = strstr(cgroup_path, _root); + char *p = strstr((char*)cgroup_path, _root); if (p != nullptr && p == _root) { if (strlen(cgroup_path) > strlen(_root)) { ss.print_raw(_mount_point); @@ -66,27 +74,15 @@ void CgroupV1Controller::set_subsystem_path(char *cgroup_path) { } } -/* uses_mem_hierarchy - * - * Return whether or not hierarchical cgroup accounting is being - * done. - * - * return: - * A number > 0 if true, or - * OSCONTAINER_ERROR for not supported +/* + * The common case, containers, we have _root == _cgroup_path, and thus set the + * controller path to the _mount_point. This is where the limits are exposed in + * the cgroup pseudo filesystem (at the leaf) and adjustment of the path won't + * be needed for that reason. */ -jlong CgroupV1MemoryController::uses_mem_hierarchy() { - julong use_hierarchy; - CONTAINER_READ_NUMBER_CHECKED(reader(), "/memory.use_hierarchy", "Use Hierarchy", use_hierarchy); - return (jlong)use_hierarchy; -} - -void CgroupV1MemoryController::set_subsystem_path(char *cgroup_path) { - reader()->set_subsystem_path(cgroup_path); - jlong hierarchy = uses_mem_hierarchy(); - if (hierarchy > 0) { - set_hierarchical(true); - } +bool CgroupV1Controller::needs_hierarchy_adjustment() { + assert(_cgroup_path != nullptr, "sanity"); + return strcmp(_root, _cgroup_path) != 0; } static inline @@ -115,20 +111,6 @@ jlong CgroupV1MemoryController::read_memory_limit_in_bytes(julong phys_mem) { julong memlimit; CONTAINER_READ_NUMBER_CHECKED(reader(), "/memory.limit_in_bytes", "Memory Limit", memlimit); if (memlimit >= phys_mem) { - log_trace(os, container)("Non-Hierarchical Memory Limit is: Unlimited"); - if (is_hierarchical()) { - julong hier_memlimit; - bool is_ok = reader()->read_numerical_key_value("/memory.stat", "hierarchical_memory_limit", &hier_memlimit); - if (!is_ok) { - return OSCONTAINER_ERROR; - } - log_trace(os, container)("Hierarchical Memory Limit is: " JULONG_FORMAT, hier_memlimit); - if (hier_memlimit < phys_mem) { - verbose_log(hier_memlimit, phys_mem); - return (jlong)hier_memlimit; - } - log_trace(os, container)("Hierarchical Memory Limit is: Unlimited"); - } verbose_log(memlimit, phys_mem); return (jlong)-1; } else { @@ -150,26 +132,10 @@ jlong CgroupV1MemoryController::read_memory_limit_in_bytes(julong phys_mem) { * upper bound) */ jlong CgroupV1MemoryController::read_mem_swap(julong host_total_memsw) { - julong hier_memswlimit; julong memswlimit; CONTAINER_READ_NUMBER_CHECKED(reader(), "/memory.memsw.limit_in_bytes", "Memory and Swap Limit", memswlimit); if (memswlimit >= host_total_memsw) { - log_trace(os, container)("Non-Hierarchical Memory and Swap Limit is: Unlimited"); - if (is_hierarchical()) { - const char* matchline = "hierarchical_memsw_limit"; - bool is_ok = reader()->read_numerical_key_value("/memory.stat", - matchline, - &hier_memswlimit); - if (!is_ok) { - return OSCONTAINER_ERROR; - } - log_trace(os, container)("Hierarchical Memory and Swap Limit is: " JULONG_FORMAT, hier_memswlimit); - if (hier_memswlimit >= host_total_memsw) { - log_trace(os, container)("Hierarchical Memory and Swap Limit is: Unlimited"); - } else { - return (jlong)hier_memswlimit; - } - } + log_trace(os, container)("Memory and Swap Limit is: Unlimited"); return (jlong)-1; } else { return (jlong)memswlimit; @@ -233,6 +199,21 @@ jlong CgroupV1MemoryController::memory_soft_limit_in_bytes(julong phys_mem) { } } +// Constructor +CgroupV1Subsystem::CgroupV1Subsystem(CgroupV1Controller* cpuset, + CgroupV1CpuController* cpu, + CgroupV1Controller* cpuacct, + CgroupV1Controller* pids, + CgroupV1MemoryController* memory) : + _cpuset(cpuset), + _cpuacct(cpuacct), + _pids(pids) { + CgroupUtil::adjust_controller(memory); + CgroupUtil::adjust_controller(cpu); + _memory = new CachingCgroupController(memory); + _cpu = new CachingCgroupController(cpu); +} + bool CgroupV1Subsystem::is_containerized() { // containerized iff all required controllers are mounted // read-only. See OSContainer::is_containerized() for diff --git a/src/hotspot/os/linux/cgroupV1Subsystem_linux.hpp b/src/hotspot/os/linux/cgroupV1Subsystem_linux.hpp index 56af87881e7..0c191ab91c7 100644 --- a/src/hotspot/os/linux/cgroupV1Subsystem_linux.hpp +++ b/src/hotspot/os/linux/cgroupV1Subsystem_linux.hpp @@ -28,6 +28,7 @@ #include "runtime/os.hpp" #include "memory/allocation.hpp" #include "cgroupSubsystem_linux.hpp" +#include "cgroupUtil_linux.hpp" // Cgroups version 1 specific implementation @@ -35,7 +36,6 @@ class CgroupV1Controller: public CgroupController { private: /* mountinfo contents */ char* _root; - char* _mount_point; bool _read_only; /* Constructed subsystem directory */ @@ -45,24 +45,27 @@ class CgroupV1Controller: public CgroupController { CgroupV1Controller(char *root, char *mountpoint, bool ro) : _root(os::strdup(root)), - _mount_point(os::strdup(mountpoint)), _read_only(ro), _path(nullptr) { + _cgroup_path = nullptr; + _mount_point = os::strdup(mountpoint); } // Shallow copy constructor CgroupV1Controller(const CgroupV1Controller& o) : _root(o._root), - _mount_point(o._mount_point), _read_only(o._read_only), _path(o._path) { + _cgroup_path = o._cgroup_path; + _mount_point = o._mount_point; } ~CgroupV1Controller() { // At least one subsystem controller exists with paths to malloc'd path // names } - void set_subsystem_path(char *cgroup_path); - char *subsystem_path() override { return _path; } + void set_subsystem_path(const char *cgroup_path); + const char* subsystem_path() override { return _path; } bool is_read_only() override { return _read_only; } + bool needs_hierarchy_adjustment() override; }; class CgroupV1MemoryController final : public CgroupMemoryController { @@ -71,8 +74,9 @@ class CgroupV1MemoryController final : public CgroupMemoryController { CgroupV1Controller _reader; CgroupV1Controller* reader() { return &_reader; } public: - bool is_hierarchical() { return _uses_mem_hierarchy; } - void set_subsystem_path(char *cgroup_path); + void set_subsystem_path(const char *cgroup_path) override { + reader()->set_subsystem_path(cgroup_path); + } jlong read_memory_limit_in_bytes(julong upper_bound) override; jlong memory_usage_in_bytes() override; jlong memory_and_swap_limit_in_bytes(julong host_mem, julong host_swap) override; @@ -85,23 +89,22 @@ class CgroupV1MemoryController final : public CgroupMemoryController { jlong kernel_memory_limit_in_bytes(julong host_mem); jlong kernel_memory_max_usage_in_bytes(); void print_version_specific_info(outputStream* st, julong host_mem) override; + bool needs_hierarchy_adjustment() override { + return reader()->needs_hierarchy_adjustment(); + } bool is_read_only() override { return reader()->is_read_only(); } + const char* subsystem_path() override { return reader()->subsystem_path(); } + const char* mount_point() override { return reader()->mount_point(); } + const char* cgroup_path() override { return reader()->cgroup_path(); } private: - /* Some container runtimes set limits via cgroup - * hierarchy. If set to true consider also memory.stat - * file if everything else seems unlimited */ - bool _uses_mem_hierarchy; - jlong uses_mem_hierarchy(); - void set_hierarchical(bool value) { _uses_mem_hierarchy = value; } jlong read_mem_swappiness(); jlong read_mem_swap(julong host_total_memsw); public: CgroupV1MemoryController(const CgroupV1Controller& reader) - : _reader(reader), - _uses_mem_hierarchy(false) { + : _reader(reader) { } }; @@ -115,12 +118,22 @@ class CgroupV1CpuController final : public CgroupCpuController { int cpu_quota() override; int cpu_period() override; int cpu_shares() override; - void set_subsystem_path(char *cgroup_path) { + void set_subsystem_path(const char *cgroup_path) override { reader()->set_subsystem_path(cgroup_path); } bool is_read_only() override { return reader()->is_read_only(); } + const char* subsystem_path() override { + return reader()->subsystem_path(); + } + const char* mount_point() override { + return reader()->mount_point(); + } + bool needs_hierarchy_adjustment() override { + return reader()->needs_hierarchy_adjustment(); + } + const char* cgroup_path() override { return reader()->cgroup_path(); } public: CgroupV1CpuController(const CgroupV1Controller& reader) : _reader(reader) { @@ -130,6 +143,12 @@ class CgroupV1CpuController final : public CgroupCpuController { class CgroupV1Subsystem: public CgroupSubsystem { public: + CgroupV1Subsystem(CgroupV1Controller* cpuset, + CgroupV1CpuController* cpu, + CgroupV1Controller* cpuacct, + CgroupV1Controller* pids, + CgroupV1MemoryController* memory); + jlong kernel_memory_usage_in_bytes(); jlong kernel_memory_limit_in_bytes(); jlong kernel_memory_max_usage_in_bytes(); @@ -155,18 +174,6 @@ class CgroupV1Subsystem: public CgroupSubsystem { CgroupV1Controller* _cpuacct = nullptr; CgroupV1Controller* _pids = nullptr; - public: - CgroupV1Subsystem(CgroupV1Controller* cpuset, - CgroupV1CpuController* cpu, - CgroupV1Controller* cpuacct, - CgroupV1Controller* pids, - CgroupV1MemoryController* memory) : - _memory(new CachingCgroupController(memory)), - _cpuset(cpuset), - _cpu(new CachingCgroupController(cpu)), - _cpuacct(cpuacct), - _pids(pids) { - } }; #endif // CGROUP_V1_SUBSYSTEM_LINUX_HPP diff --git a/src/hotspot/os/linux/cgroupV2Subsystem_linux.cpp b/src/hotspot/os/linux/cgroupV2Subsystem_linux.cpp index 8f7e12d0954..62e8cac3a62 100644 --- a/src/hotspot/os/linux/cgroupV2Subsystem_linux.cpp +++ b/src/hotspot/os/linux/cgroupV2Subsystem_linux.cpp @@ -25,6 +25,22 @@ #include "cgroupV2Subsystem_linux.hpp" #include "cgroupUtil_linux.hpp" +// Constructor +CgroupV2Controller::CgroupV2Controller(char* mount_path, + char *cgroup_path, + bool ro) : _read_only(ro), + _path(construct_path(mount_path, cgroup_path)) { + _cgroup_path = os::strdup(cgroup_path); + _mount_point = os::strdup(mount_path); +} +// Shallow copy constructor +CgroupV2Controller::CgroupV2Controller(const CgroupV2Controller& o) : + _read_only(o._read_only), + _path(o._path) { + _cgroup_path = o._cgroup_path; + _mount_point = o._mount_point; +} + /* cpu_shares * * Return the amount of cpu shares available to the process @@ -95,6 +111,17 @@ int CgroupV2CpuController::cpu_quota() { return limit; } +// Constructor +CgroupV2Subsystem::CgroupV2Subsystem(CgroupV2MemoryController * memory, + CgroupV2CpuController* cpu, + CgroupV2Controller unified) : + _unified(unified) { + CgroupUtil::adjust_controller(memory); + CgroupUtil::adjust_controller(cpu); + _memory = new CachingCgroupController(memory); + _cpu = new CachingCgroupController(cpu); +} + bool CgroupV2Subsystem::is_containerized() { return _unified.is_read_only() && _memory->controller()->is_read_only() && @@ -264,6 +291,18 @@ jlong memory_swap_limit_value(CgroupV2Controller* ctrl) { return swap_limit; } +void CgroupV2Controller::set_subsystem_path(const char* cgroup_path) { + if (_path != nullptr) { + os::free(_path); + } + _path = construct_path(_mount_point, cgroup_path); +} + +// For cgv2 we only need hierarchy walk if the cgroup path isn't '/' (root) +bool CgroupV2Controller::needs_hierarchy_adjustment() { + return strcmp(_cgroup_path, "/") != 0; +} + void CgroupV2MemoryController::print_version_specific_info(outputStream* st, julong phys_mem) { jlong swap_current = memory_swap_current_value(reader()); jlong swap_limit = memory_swap_limit_value(reader()); @@ -272,7 +311,7 @@ void CgroupV2MemoryController::print_version_specific_info(outputStream* st, jul OSContainer::print_container_helper(st, swap_limit, "memory_swap_max_limit_in_bytes"); } -char* CgroupV2Controller::construct_path(char* mount_path, char *cgroup_path) { +char* CgroupV2Controller::construct_path(char* mount_path, const char* cgroup_path) { stringStream ss; ss.print_raw(mount_path); if (strcmp(cgroup_path, "/") != 0) { diff --git a/src/hotspot/os/linux/cgroupV2Subsystem_linux.hpp b/src/hotspot/os/linux/cgroupV2Subsystem_linux.hpp index cd100f29874..56dcadd670f 100644 --- a/src/hotspot/os/linux/cgroupV2Subsystem_linux.hpp +++ b/src/hotspot/os/linux/cgroupV2Subsystem_linux.hpp @@ -26,39 +26,28 @@ #define CGROUP_V2_SUBSYSTEM_LINUX_HPP #include "cgroupSubsystem_linux.hpp" +#include "cgroupUtil_linux.hpp" class CgroupV2Controller: public CgroupController { private: - /* the mount path of the cgroup v2 hierarchy */ - char *_mount_path; - /* The cgroup path for the controller */ - char *_cgroup_path; bool _read_only; /* Constructed full path to the subsystem directory */ char *_path; - static char* construct_path(char* mount_path, char *cgroup_path); + static char* construct_path(char* mount_path, const char *cgroup_path); public: - CgroupV2Controller(char* mount_path, - char *cgroup_path, - bool ro) : _mount_path(os::strdup(mount_path)), - _cgroup_path(os::strdup(cgroup_path)), - _read_only(ro), - _path(construct_path(mount_path, cgroup_path)) { - } + CgroupV2Controller(char* mount_path, char *cgroup_path, bool ro); // Shallow copy constructor - CgroupV2Controller(const CgroupV2Controller& o) : - _mount_path(o._mount_path), - _cgroup_path(o._cgroup_path), - _read_only(o._read_only), - _path(o._path) { - } + CgroupV2Controller(const CgroupV2Controller& o); ~CgroupV2Controller() { // At least one controller exists with references to the paths } - char *subsystem_path() override { return _path; } + const char* subsystem_path() override { return _path; } + bool needs_hierarchy_adjustment() override; + // Allow for optional updates of the subsystem path + void set_subsystem_path(const char* cgroup_path); bool is_read_only() override { return _read_only; } }; @@ -75,6 +64,17 @@ class CgroupV2CpuController: public CgroupCpuController { bool is_read_only() override { return reader()->is_read_only(); } + const char* subsystem_path() override { + return reader()->subsystem_path(); + } + bool needs_hierarchy_adjustment() override { + return reader()->needs_hierarchy_adjustment(); + } + void set_subsystem_path(const char* cgroup_path) override { + reader()->set_subsystem_path(cgroup_path); + } + const char* mount_point() override { return reader()->mount_point(); } + const char* cgroup_path() override { return reader()->cgroup_path(); } }; class CgroupV2MemoryController final: public CgroupMemoryController { @@ -97,6 +97,17 @@ class CgroupV2MemoryController final: public CgroupMemoryController { bool is_read_only() override { return reader()->is_read_only(); } + const char* subsystem_path() override { + return reader()->subsystem_path(); + } + bool needs_hierarchy_adjustment() override { + return reader()->needs_hierarchy_adjustment(); + } + void set_subsystem_path(const char* cgroup_path) override { + reader()->set_subsystem_path(cgroup_path); + } + const char* mount_point() override { return reader()->mount_point(); } + const char* cgroup_path() override { return reader()->cgroup_path(); } }; class CgroupV2Subsystem: public CgroupSubsystem { @@ -110,13 +121,9 @@ class CgroupV2Subsystem: public CgroupSubsystem { CgroupV2Controller* unified() { return &_unified; } public: - CgroupV2Subsystem(CgroupV2MemoryController* memory, + CgroupV2Subsystem(CgroupV2MemoryController * memory, CgroupV2CpuController* cpu, - CgroupV2Controller unified) : - _unified(unified), - _memory(new CachingCgroupController(memory)), - _cpu(new CachingCgroupController(cpu)) { - } + CgroupV2Controller unified); char * cpu_cpuset_cpus() override; char * cpu_cpuset_memory_nodes() override; diff --git a/src/hotspot/os/linux/gc/z/zPhysicalMemoryBacking_linux.cpp b/src/hotspot/os/linux/gc/z/zPhysicalMemoryBacking_linux.cpp index b80124cc34e..b648876ac60 100644 --- a/src/hotspot/os/linux/gc/z/zPhysicalMemoryBacking_linux.cpp +++ b/src/hotspot/os/linux/gc/z/zPhysicalMemoryBacking_linux.cpp @@ -27,6 +27,7 @@ #include "gc/z/zArray.inline.hpp" #include "gc/z/zErrno.hpp" #include "gc/z/zGlobals.hpp" +#include "gc/z/zInitialize.hpp" #include "gc/z/zLargePages.inline.hpp" #include "gc/z/zMountPoint_linux.hpp" #include "gc/z/zNUMA.inline.hpp" @@ -103,14 +104,14 @@ #define ZFILENAME_HEAP "java_heap" // Preferred tmpfs mount points, ordered by priority -static const char* z_preferred_tmpfs_mountpoints[] = { +static const char* ZPreferredTmpfsMountpoints[] = { "/dev/shm", "/run/shm", nullptr }; // Preferred hugetlbfs mount points, ordered by priority -static const char* z_preferred_hugetlbfs_mountpoints[] = { +static const char* ZPreferredHugetlbfsMountpoints[] = { "/dev/hugepages", "/hugepages", nullptr @@ -129,6 +130,7 @@ ZPhysicalMemoryBacking::ZPhysicalMemoryBacking(size_t max_capacity) // Create backing file _fd = create_fd(ZFILENAME_HEAP); if (_fd == -1) { + ZInitialize::error("Failed to create heap backing file"); return; } @@ -136,7 +138,7 @@ ZPhysicalMemoryBacking::ZPhysicalMemoryBacking(size_t max_capacity) while (ftruncate(_fd, max_capacity) == -1) { if (errno != EINTR) { ZErrno err; - log_error_p(gc)("Failed to truncate backing file (%s)", err.to_string()); + ZInitialize::error("Failed to truncate backing file (%s)", err.to_string()); return; } } @@ -145,7 +147,7 @@ ZPhysicalMemoryBacking::ZPhysicalMemoryBacking(size_t max_capacity) struct statfs buf; if (fstatfs(_fd, &buf) == -1) { ZErrno err; - log_error_p(gc)("Failed to determine filesystem type for backing file (%s)", err.to_string()); + ZInitialize::error("Failed to determine filesystem type for backing file (%s)", err.to_string()); return; } @@ -158,39 +160,39 @@ ZPhysicalMemoryBacking::ZPhysicalMemoryBacking(size_t max_capacity) // Make sure the filesystem type matches requested large page type if (ZLargePages::is_transparent() && !is_tmpfs()) { - log_error_p(gc)("-XX:+UseTransparentHugePages can only be enabled when using a %s filesystem", - ZFILESYSTEM_TMPFS); + ZInitialize::error("-XX:+UseTransparentHugePages can only be enabled when using a %s filesystem", + ZFILESYSTEM_TMPFS); return; } if (ZLargePages::is_transparent() && !tmpfs_supports_transparent_huge_pages()) { - log_error_p(gc)("-XX:+UseTransparentHugePages on a %s filesystem not supported by kernel", - ZFILESYSTEM_TMPFS); + ZInitialize::error("-XX:+UseTransparentHugePages on a %s filesystem not supported by kernel", + ZFILESYSTEM_TMPFS); return; } if (ZLargePages::is_explicit() && !is_hugetlbfs()) { - log_error_p(gc)("-XX:+UseLargePages (without -XX:+UseTransparentHugePages) can only be enabled " - "when using a %s filesystem", ZFILESYSTEM_HUGETLBFS); + ZInitialize::error("-XX:+UseLargePages (without -XX:+UseTransparentHugePages) can only be enabled " + "when using a %s filesystem", ZFILESYSTEM_HUGETLBFS); return; } if (!ZLargePages::is_explicit() && is_hugetlbfs()) { - log_error_p(gc)("-XX:+UseLargePages must be enabled when using a %s filesystem", - ZFILESYSTEM_HUGETLBFS); + ZInitialize::error("-XX:+UseLargePages must be enabled when using a %s filesystem", + ZFILESYSTEM_HUGETLBFS); return; } // Make sure the filesystem block size is compatible if (ZGranuleSize % _block_size != 0) { - log_error_p(gc)("Filesystem backing the heap has incompatible block size (" SIZE_FORMAT ")", - _block_size); + ZInitialize::error("Filesystem backing the heap has incompatible block size (" SIZE_FORMAT ")", + _block_size); return; } if (is_hugetlbfs() && _block_size != ZGranuleSize) { - log_error_p(gc)("%s filesystem has unexpected block size " SIZE_FORMAT " (expected " SIZE_FORMAT ")", - ZFILESYSTEM_HUGETLBFS, _block_size, ZGranuleSize); + ZInitialize::error("%s filesystem has unexpected block size " SIZE_FORMAT " (expected " SIZE_FORMAT ")", + ZFILESYSTEM_HUGETLBFS, _block_size, ZGranuleSize); return; } @@ -226,8 +228,8 @@ int ZPhysicalMemoryBacking::create_file_fd(const char* name) const { ? ZFILESYSTEM_HUGETLBFS : ZFILESYSTEM_TMPFS; const char** const preferred_mountpoints = ZLargePages::is_explicit() - ? z_preferred_hugetlbfs_mountpoints - : z_preferred_tmpfs_mountpoints; + ? ZPreferredHugetlbfsMountpoints + : ZPreferredTmpfsMountpoints; // Find mountpoint ZMountPoint mountpoint(filesystem, preferred_mountpoints); diff --git a/src/hotspot/os/linux/osThread_linux.cpp b/src/hotspot/os/linux/osThread_linux.cpp index 9c77cb32f6d..3dd6e3bbcd1 100644 --- a/src/hotspot/os/linux/osThread_linux.cpp +++ b/src/hotspot/os/linux/osThread_linux.cpp @@ -22,27 +22,27 @@ * */ -// no precompiled headers -#include "memory/allocation.inline.hpp" +#include "precompiled.hpp" +#include "memory/allocation.hpp" #include "runtime/mutex.hpp" #include "runtime/osThread.hpp" #include -void OSThread::pd_initialize() { - _thread_id = 0; - _pthread_id = 0; - _siginfo = nullptr; - _ucontext = nullptr; - _expanding_stack = 0; - _alt_sig_stack = nullptr; - +OSThread::OSThread() + : _thread_id(0), + _thread_type(), + _pthread_id(0), + _caller_sigmask(), + sr(), + _siginfo(nullptr), + _ucontext(nullptr), + _expanding_stack(0), + _alt_sig_stack(nullptr), + _startThread_lock(new Monitor(Mutex::event, "startThread_lock")) { sigemptyset(&_caller_sigmask); - - _startThread_lock = new Monitor(Mutex::event, "startThread_lock"); - assert(_startThread_lock !=nullptr, "check"); } -void OSThread::pd_destroy() { +OSThread::~OSThread() { delete _startThread_lock; } diff --git a/src/hotspot/os/linux/osThread_linux.hpp b/src/hotspot/os/linux/osThread_linux.hpp index a849673af62..f8dfd5a213b 100644 --- a/src/hotspot/os/linux/osThread_linux.hpp +++ b/src/hotspot/os/linux/osThread_linux.hpp @@ -24,21 +24,19 @@ #ifndef OS_LINUX_OSTHREAD_LINUX_HPP #define OS_LINUX_OSTHREAD_LINUX_HPP - public: + +#include "runtime/osThreadBase.hpp" +#include "suspendResume_posix.hpp" +#include "utilities/globalDefinitions.hpp" + +class OSThread : public OSThreadBase { + friend class VMStructs; + typedef pid_t thread_id_t; - private: + thread_id_t _thread_id; int _thread_type; - public: - - int thread_type() const { - return _thread_type; - } - void set_thread_type(int type) { - _thread_type = type; - } - // _pthread_id is the pthread id, which is used by library calls // (e.g. pthread_kill). pthread_t _pthread_id; @@ -46,15 +44,26 @@ sigset_t _caller_sigmask; // Caller's signal mask public: + OSThread(); + ~OSThread(); + + int thread_type() const { + return _thread_type; + } + void set_thread_type(int type) { + _thread_type = type; + } // Methods to save/restore caller's signal mask sigset_t caller_sigmask() const { return _caller_sigmask; } void set_caller_sigmask(sigset_t sigmask) { _caller_sigmask = sigmask; } -#ifndef PRODUCT - // Used for debugging, return a unique integer for each thread. - int thread_identifier() const { return _thread_id; } -#endif + thread_id_t thread_id() const { + return _thread_id; + } + void set_thread_id(thread_id_t id) { + _thread_id = id; + } pthread_t pthread_id() const { return _pthread_id; @@ -67,7 +76,6 @@ // suspension support. // *************************************************************** -public: // flags that support signal based suspend/resume on Linux are in a // separate class to avoid confusion with many flags in OSThread that // are used by VM level suspend/resume. @@ -113,17 +121,10 @@ public: return _startThread_lock; } - // *************************************************************** - // Platform dependent initialization and cleanup - // *************************************************************** - -private: - - void pd_initialize(); - void pd_destroy(); - -// Reconciliation History -// osThread_solaris.hpp 1.24 99/08/27 13:11:54 -// End + // Printing + uintx thread_id_for_printing() const override { + return (uintx)_thread_id; + } +}; #endif // OS_LINUX_OSTHREAD_LINUX_HPP diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp index d4699567733..c80663fec3d 100644 --- a/src/hotspot/os/linux/os_linux.cpp +++ b/src/hotspot/os/linux/os_linux.cpp @@ -817,7 +817,7 @@ static void *thread_native_entry(Thread *thread) { OSThread* osthread = thread->osthread(); Monitor* sync = osthread->startThread_lock(); - osthread->set_thread_id(checked_cast(os::current_thread_id())); + osthread->set_thread_id(checked_cast(os::current_thread_id())); if (UseNUMA) { int lgrp_id = os::numa_get_group_id(); @@ -4602,7 +4602,7 @@ static void workaround_expand_exec_shield_cs_limit() { return; // No matter, we tried, best effort. } - MemTracker::record_virtual_memory_type((address)codebuf, mtInternal); + MemTracker::record_virtual_memory_tag((address)codebuf, mtInternal); log_info(os)("[CS limit NX emulation work-around, exec code at: %p]", codebuf); @@ -5053,16 +5053,6 @@ int os::open(const char *path, int oflag, int mode) { return fd; } -// return current position of file pointer -jlong os::current_file_offset(int fd) { - return (jlong)::lseek(fd, (off_t)0, SEEK_CUR); -} - -// move file pointer to the specified offset -jlong os::seek_to_file_offset(int fd, jlong offset) { - return (jlong)::lseek(fd, (off_t)offset, SEEK_SET); -} - static jlong slow_thread_cpu_time(Thread *thread, bool user_sys_cpu_time); static jlong fast_cpu_time(Thread *thread) { diff --git a/src/hotspot/os/linux/os_linux.hpp b/src/hotspot/os/linux/os_linux.hpp index 6b902e82802..1d4aecda936 100644 --- a/src/hotspot/os/linux/os_linux.hpp +++ b/src/hotspot/os/linux/os_linux.hpp @@ -30,9 +30,7 @@ // os::Linux defines the interface to Linux operating systems class os::Linux { - friend class CgroupSubsystem; friend class os; - friend class OSContainer; static int (*_pthread_getcpuclockid)(pthread_t, clockid_t *); static int (*_pthread_setname_np)(pthread_t, const char*); @@ -58,7 +56,6 @@ class os::Linux { static julong available_memory(); static julong free_memory(); - static int active_processor_count(); static void initialize_system_info(); @@ -93,6 +90,7 @@ class os::Linux { bool has_steal_ticks; }; + static int active_processor_count(); static void kernel_version(long* major, long* minor); // which_logical_cpu=-1 returns accumulated ticks for all cpus. diff --git a/src/hotspot/os/linux/vmStructs_linux.hpp b/src/hotspot/os/linux/vmStructs_linux.hpp index 818f6bb188f..3b82ac58ac6 100644 --- a/src/hotspot/os/linux/vmStructs_linux.hpp +++ b/src/hotspot/os/linux/vmStructs_linux.hpp @@ -31,9 +31,22 @@ // constants required by the Serviceability Agent. This file is // referenced by vmStructs.cpp. -#define VM_STRUCTS_OS(nonstatic_field, static_field, unchecked_nonstatic_field, volatile_nonstatic_field, nonproduct_nonstatic_field, c2_nonstatic_field, unchecked_c1_static_field, unchecked_c2_static_field) +#define VM_STRUCTS_OS(nonstatic_field, static_field, unchecked_nonstatic_field, volatile_nonstatic_field, nonproduct_nonstatic_field, c2_nonstatic_field, unchecked_c1_static_field, unchecked_c2_static_field) \ + \ + /******************************/ \ + /* Threads (NOTE: incomplete) */ \ + /******************************/ \ + nonstatic_field(OSThread, _thread_id, pid_t) \ + nonstatic_field(OSThread, _pthread_id, pthread_t) -#define VM_TYPES_OS(declare_type, declare_toplevel_type, declare_oop_type, declare_integer_type, declare_unsigned_integer_type, declare_c1_toplevel_type, declare_c2_type, declare_c2_toplevel_type) +#define VM_TYPES_OS(declare_type, declare_toplevel_type, declare_oop_type, declare_integer_type, declare_unsigned_integer_type, declare_c1_toplevel_type, declare_c2_type, declare_c2_toplevel_type) \ + \ + /**********************/ \ + /* Posix Thread IDs */ \ + /**********************/ \ + \ + declare_integer_type(pid_t) \ + declare_unsigned_integer_type(pthread_t) #define VM_INT_CONSTANTS_OS(declare_constant, declare_preprocessor_constant, declare_c1_constant, declare_c2_constant, declare_c2_preprocessor_constant) diff --git a/src/hotspot/os/posix/os_posix.cpp b/src/hotspot/os/posix/os_posix.cpp index 26bff6c8bd4..cc29f209160 100644 --- a/src/hotspot/os/posix/os_posix.cpp +++ b/src/hotspot/os/posix/os_posix.cpp @@ -348,6 +348,16 @@ int os::create_file_for_heap(const char* dir) { return fd; } +// return current position of file pointer +jlong os::current_file_offset(int fd) { + return (jlong)::lseek(fd, (off_t)0, SEEK_CUR); +} + +// move file pointer to the specified offset +jlong os::seek_to_file_offset(int fd, jlong offset) { + return (jlong)::lseek(fd, (off_t)offset, SEEK_SET); +} + // Is a (classpath) directory empty? bool os::dir_is_empty(const char* path) { DIR *dir = nullptr; @@ -367,7 +377,7 @@ bool os::dir_is_empty(const char* path) { return result; } -static char* reserve_mmapped_memory(size_t bytes, char* requested_addr, MEMFLAGS flag) { +static char* reserve_mmapped_memory(size_t bytes, char* requested_addr, MemTag mem_tag) { char * addr; int flags = MAP_PRIVATE NOT_AIX( | MAP_NORESERVE ) | MAP_ANONYMOUS; if (requested_addr != nullptr) { @@ -382,7 +392,7 @@ static char* reserve_mmapped_memory(size_t bytes, char* requested_addr, MEMFLAGS flags, -1, 0); if (addr != MAP_FAILED) { - MemTracker::record_virtual_memory_reserve((address)addr, bytes, CALLER_PC, flag); + MemTracker::record_virtual_memory_reserve((address)addr, bytes, CALLER_PC, mem_tag); return addr; } return nullptr; @@ -495,7 +505,7 @@ char* os::reserve_memory_aligned(size_t size, size_t alignment, bool exec) { return chop_extra_memory(size, alignment, extra_base, extra_size); } -char* os::map_memory_to_file_aligned(size_t size, size_t alignment, int file_desc, MEMFLAGS flag) { +char* os::map_memory_to_file_aligned(size_t size, size_t alignment, int file_desc, MemTag mem_tag) { size_t extra_size = calculate_aligned_extra_size(size, alignment); // For file mapping, we do not call os:map_memory_to_file(size,fd) since: // - we later chop away parts of the mapping using os::release_memory and that could fail if the @@ -503,7 +513,7 @@ char* os::map_memory_to_file_aligned(size_t size, size_t alignment, int file_des // - The memory API os::reserve_memory uses is an implementation detail. It may (and usually is) // mmap but it also may System V shared memory which cannot be uncommitted as a whole, so // chopping off and unmapping excess bits back and front (see below) would not work. - char* extra_base = reserve_mmapped_memory(extra_size, nullptr, flag); + char* extra_base = reserve_mmapped_memory(extra_size, nullptr, mem_tag); if (extra_base == nullptr) { return nullptr; } diff --git a/src/hotspot/os/windows/globals_windows.hpp b/src/hotspot/os/windows/globals_windows.hpp index 78cbac6e9cc..8f0a6261cc0 100644 --- a/src/hotspot/os/windows/globals_windows.hpp +++ b/src/hotspot/os/windows/globals_windows.hpp @@ -38,6 +38,10 @@ product(bool, UseAllWindowsProcessorGroups, false, \ "Use all processor groups on supported Windows versions") \ \ +product(bool, EnableAllLargePageSizesForWindows, false, \ + "Enable support for multiple large page sizes on " \ + "Windows Server") \ + \ product(bool, UseOSErrorReporting, false, \ "Let VM fatal error propagate to the OS (ie. WER on Windows)") diff --git a/src/hotspot/os/windows/memMapPrinter_windows.cpp b/src/hotspot/os/windows/memMapPrinter_windows.cpp new file mode 100644 index 00000000000..eb6b24a9d13 --- /dev/null +++ b/src/hotspot/os/windows/memMapPrinter_windows.cpp @@ -0,0 +1,253 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, Red Hat, Inc. and/or its affiliates. + * 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. + * + */ + +#include "precompiled.hpp" +#include "nmt/memMapPrinter.hpp" +#include "os_windows.hpp" +#include "runtime/vm_version.hpp" + +#include +#include +#include +#include + +/* maximum number of mapping records returned */ +static const int MAX_REGIONS_RETURNED = 1000000; + +class MappingInfo { +public: + stringStream _ap_buffer; + stringStream _state_buffer; + stringStream _protect_buffer; + stringStream _type_buffer; + char _file_name[MAX_PATH]; + + MappingInfo() {} + + void process(MEMORY_BASIC_INFORMATION& mem_info) { + _ap_buffer.reset(); + _state_buffer.reset(); + _protect_buffer.reset(); + _type_buffer.reset(); + get_protect_string(_ap_buffer, mem_info.AllocationProtect); + get_state_string(_state_buffer, mem_info); + get_protect_string(_protect_buffer, mem_info.Protect); + get_type_string(_type_buffer, mem_info); + _file_name[0] = 0; + if (mem_info.Type == MEM_IMAGE) { + HMODULE hModule = 0; + if (GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, static_cast(mem_info.AllocationBase), &hModule)) { + GetModuleFileName(hModule, _file_name, sizeof(_file_name)); + } + } + } + + void get_protect_string(outputStream& out, DWORD prot) { + const char read_c = prot & (PAGE_READONLY | PAGE_READWRITE | PAGE_EXECUTE_READ | PAGE_EXECUTE_READWRITE | PAGE_WRITECOPY | PAGE_EXECUTE_WRITECOPY) ? 'r' : '-'; + const char write_c = prot & (PAGE_READWRITE | PAGE_WRITECOPY | PAGE_EXECUTE_READWRITE | PAGE_EXECUTE_WRITECOPY) ? 'w' : '-'; + const char execute_c = prot & (PAGE_EXECUTE | PAGE_EXECUTE_READ | PAGE_EXECUTE_READWRITE | PAGE_EXECUTE_WRITECOPY) ? 'x' : '-'; + out.print("%c%c%c", read_c, write_c, execute_c); + if (prot & (PAGE_WRITECOPY | PAGE_EXECUTE_WRITECOPY)) { + out.put('c'); + } + if (prot & PAGE_GUARD) { + out.put('g'); + } + if (prot & PAGE_NOCACHE) { + out.put('n'); + } + if (prot & PAGE_WRITECOMBINE) { + out.put('W'); + } + const DWORD bits = PAGE_NOACCESS | PAGE_READONLY | PAGE_READWRITE | PAGE_EXECUTE_READ | PAGE_EXECUTE_READWRITE + | PAGE_WRITECOPY | PAGE_EXECUTE_WRITECOPY | PAGE_EXECUTE + | PAGE_GUARD | PAGE_NOCACHE | PAGE_WRITECOMBINE; + if ((prot & bits) != prot) { + out.print_cr("Unknown Windows memory protection value: 0x%x unknown bits: 0x%x", prot, prot & ~bits); + assert(false, "Unknown Windows memory protection value: 0x%x unknown bits: 0x%x", prot, prot & ~bits); + } + } + + void get_state_string(outputStream& out, MEMORY_BASIC_INFORMATION& mem_info) { + if (mem_info.State == MEM_COMMIT) { + out.put('c'); + } else if (mem_info.State == MEM_FREE) { + out.put('f'); + } else if (mem_info.State == MEM_RESERVE) { + out.put('r'); + } else { + out.print_cr("Unknown Windows memory state value: 0x%x", mem_info.State); + assert(false, "Unknown Windows memory state value: 0x%x", mem_info.State); + } + } + + void get_type_string(outputStream& out, MEMORY_BASIC_INFORMATION& mem_info) { + if (mem_info.Type == MEM_IMAGE) { + out.print("img"); + } else if (mem_info.Type == MEM_MAPPED) { + out.print("map"); + } else if (mem_info.Type == MEM_PRIVATE) { + out.print("pvt"); + } else if (mem_info.Type == 0 && mem_info.State == MEM_FREE) { + out.print("---"); + } else { + out.print_cr("Unknown Windows memory type 0x%x", mem_info.Type); + assert(false, "Unknown Windows memory type 0x%x", mem_info.Type); + } + } +}; + +class MappingInfoSummary { + unsigned _num_mappings; + size_t _total_region_size; // combined resident set size + size_t _total_committed; // combined committed size + class WinOsInfo : public os::win32 { + public: + static void printOsInfo(outputStream* st) { + st->print("OS:"); + os::win32::print_windows_version(st); + os::win32::print_uptime_info(st); + VM_Version::print_platform_virtualization_info(st); + os::print_memory_info(st); + } + }; +public: + MappingInfoSummary() : _num_mappings(0), _total_region_size(0), + _total_committed(0) {} + + void add_mapping(const MEMORY_BASIC_INFORMATION& mem_info, const MappingInfo& mapping_info) { + if (mem_info.State != MEM_FREE) { + _num_mappings++; + _total_region_size += mem_info.RegionSize; + _total_committed += mem_info.State == MEM_COMMIT ? mem_info.RegionSize : 0; + } + } + + void print_on(const MappingPrintSession& session) const { + outputStream* st = session.out(); + WinOsInfo::printOsInfo(st); + st->print_cr("current process reserved memory: " PROPERFMT, PROPERFMTARGS(_total_region_size)); + st->print_cr("current process committed memory: " PROPERFMT, PROPERFMTARGS(_total_committed)); + st->print_cr("current process region count: " PROPERFMT, PROPERFMTARGS(_num_mappings)); + } +}; + +class MappingInfoPrinter { + const MappingPrintSession& _session; +public: + MappingInfoPrinter(const MappingPrintSession& session) : + _session(session) + {} + + void print_single_mapping(const MEMORY_BASIC_INFORMATION& mem_info, const MappingInfo& mapping_info) const { + outputStream* st = _session.out(); +#define INDENT_BY(n) \ + if (st->fill_to(n) == 0) { \ + st->print(" "); \ + } + st->print(PTR_FORMAT "-" PTR_FORMAT, mem_info.BaseAddress, static_cast(mem_info.BaseAddress) + mem_info.RegionSize); + INDENT_BY(38); + st->print("%12zu", mem_info.RegionSize); + INDENT_BY(51); + st->print("%s", mapping_info._protect_buffer.base()); + INDENT_BY(57); + st->print("%s-%s", mapping_info._state_buffer.base(), mapping_info._type_buffer.base()); + INDENT_BY(63); + st->print("%#11llx", reinterpret_cast(mem_info.BaseAddress) - reinterpret_cast(mem_info.AllocationBase)); + INDENT_BY(72); + if (_session.print_nmt_info_for_region(mem_info.BaseAddress, static_cast(mem_info.BaseAddress) + mem_info.RegionSize)) { + st->print(" "); + } + st->print_raw(mapping_info._file_name); + #undef INDENT_BY + st->cr(); + } + + void print_legend() const { + outputStream* st = _session.out(); + st->print_cr("from, to, vsize: address range and size"); + st->print_cr("prot: protection:"); + st->print_cr(" rwx: read / write / execute"); + st->print_cr(" c: copy on write"); + st->print_cr(" g: guard"); + st->print_cr(" n: no cache"); + st->print_cr(" W: write combine"); + st->print_cr("state: region state and type:"); + st->print_cr(" state: committed / reserved"); + st->print_cr(" type: image / mapped / private"); + st->print_cr("file: file mapped, if mapping is not anonymous"); + st->print_cr("vm info: VM information (requires NMT)"); + { + streamIndentor si(st, 16); + _session.print_nmt_flag_legend(); + } + } + + void print_header() const { + outputStream* st = _session.out(); + // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 + // 01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 + // 0x00007ffb24565000-0x00007ffb24a7e000 5345280 r-- c-img 0x1155000 C:\work\jdk\build\fastdebug\jdk\bin\server\jvm.dll + st->print_cr("from to vsize prot state offset vminfo/file"); + st->print_cr("==========================================================================================="); + } +}; + +void MemMapPrinter::pd_print_all_mappings(const MappingPrintSession& session) { + + HANDLE hProcess = GetCurrentProcess(); + + MappingInfoPrinter printer(session); + MappingInfoSummary summary; + + outputStream* const st = session.out(); + + printer.print_legend(); + st->cr(); + printer.print_header(); + + MEMORY_BASIC_INFORMATION mem_info; + MappingInfo mapping_info; + + int region_count = 0; + ::memset(&mem_info, 0, sizeof(mem_info)); + for (char* ptr = 0; VirtualQueryEx(hProcess, ptr, &mem_info, sizeof(mem_info)) == sizeof(mem_info); ) { + assert(mem_info.RegionSize > 0, "RegionSize is not greater than zero"); + if (++region_count > MAX_REGIONS_RETURNED) { + st->print_cr("limit of %d regions reached (results inaccurate)", region_count); + break; + } + mapping_info.process(mem_info); + if (mem_info.State != MEM_FREE) { + printer.print_single_mapping(mem_info, mapping_info); + summary.add_mapping(mem_info, mapping_info); + } + ptr += mem_info.RegionSize; + ::memset(&mem_info, 0, sizeof(mem_info)); + } + st->cr(); + summary.print_on(session); + st->cr(); +} diff --git a/src/hotspot/os/windows/osThread_windows.cpp b/src/hotspot/os/windows/osThread_windows.cpp index 5f369bb7aa0..922b4b0104b 100644 --- a/src/hotspot/os/windows/osThread_windows.cpp +++ b/src/hotspot/os/windows/osThread_windows.cpp @@ -22,17 +22,17 @@ * */ -// no precompiled headers -#include "runtime/os.hpp" +#include "precompiled.hpp" #include "runtime/osThread.hpp" -void OSThread::pd_initialize() { - set_thread_handle(nullptr); - set_thread_id(0); - set_interrupt_event(nullptr); -} +#include -void OSThread::pd_destroy() { +OSThread::OSThread() + : _thread_id(0), + _thread_handle(nullptr), + _interrupt_event(nullptr) {} + +OSThread::~OSThread() { if (_interrupt_event != nullptr) { CloseHandle(_interrupt_event); } diff --git a/src/hotspot/os/windows/osThread_windows.hpp b/src/hotspot/os/windows/osThread_windows.hpp index 5bd07646b17..e54783aef1c 100644 --- a/src/hotspot/os/windows/osThread_windows.hpp +++ b/src/hotspot/os/windows/osThread_windows.hpp @@ -25,17 +25,29 @@ #ifndef OS_WINDOWS_OSTHREAD_WINDOWS_HPP #define OS_WINDOWS_OSTHREAD_WINDOWS_HPP - typedef void* HANDLE; - public: - typedef unsigned long thread_id_t; +#include "runtime/osThreadBase.hpp" +#include "utilities/globalDefinitions.hpp" + +class OSThread : public OSThreadBase { + friend class VMStructs; + + typedef unsigned long thread_id_t; + typedef void* HANDLE; + + thread_id_t _thread_id; - private: // Win32-specific thread information HANDLE _thread_handle; // Win32 thread handle HANDLE _interrupt_event; // Event signalled on thread interrupt for use by // Process.waitFor(). public: + OSThread(); + ~OSThread(); + + thread_id_t thread_id() const { return _thread_id; } + void set_thread_id(thread_id_t id) { _thread_id = id; } + // The following will only apply in the Win32 implementation, and should only // be visible in the concrete class, not this which should be an abstract base class HANDLE thread_handle() const { return _thread_handle; } @@ -45,13 +57,9 @@ // This is specialized on Windows to interact with the _interrupt_event. void set_interrupted(bool z); -#ifndef PRODUCT - // Used for debugging, return a unique integer for each thread. - int thread_identifier() const { return _thread_id; } -#endif - - private: - void pd_initialize(); - void pd_destroy(); + uintx thread_id_for_printing() const override { + return (uintx)_thread_id; + } +}; #endif // OS_WINDOWS_OSTHREAD_WINDOWS_HPP diff --git a/src/hotspot/os/windows/os_windows.cpp b/src/hotspot/os/windows/os_windows.cpp index 1d1d9d3e1a4..0d5727b98f4 100644 --- a/src/hotspot/os/windows/os_windows.cpp +++ b/src/hotspot/os/windows/os_windows.cpp @@ -63,6 +63,7 @@ #include "runtime/sharedRuntime.hpp" #include "runtime/statSampler.hpp" #include "runtime/stubRoutines.hpp" +#include "runtime/suspendedThreadTask.hpp" #include "runtime/threadCritical.hpp" #include "runtime/threads.hpp" #include "runtime/timer.hpp" @@ -1947,7 +1948,10 @@ void os::win32::print_windows_version(outputStream* st) { // - 2016 GA 10/2016 build: 14393 // - 2019 GA 11/2018 build: 17763 // - 2022 GA 08/2021 build: 20348 - if (build_number > 20347) { + // - 2025 Preview build : 26040 + if (build_number > 26039) { + st->print("Server 2025"); + } else if (build_number > 20347) { st->print("Server 2022"); } else if (build_number > 17762) { st->print("Server 2019"); @@ -3123,7 +3127,7 @@ class NUMANodeListHolder { static size_t _large_page_size = 0; -static bool request_lock_memory_privilege() { +bool os::win32::request_lock_memory_privilege() { HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, os::current_process_id()); @@ -3307,14 +3311,14 @@ static char* allocate_pages_individually(size_t bytes, char* addr, DWORD flags, return p_buf; } -static size_t large_page_init_decide_size() { +size_t os::win32::large_page_init_decide_size() { // print a warning if any large page related flag is specified on command line bool warn_on_failure = !FLAG_IS_DEFAULT(UseLargePages) || !FLAG_IS_DEFAULT(LargePageSizeInBytes); -#define WARN(msg) if (warn_on_failure) { warning(msg); } +#define WARN(...) if (warn_on_failure) { warning(__VA_ARGS__); } - if (!request_lock_memory_privilege()) { + if (!os::win32::request_lock_memory_privilege()) { WARN("JVM cannot use large page memory because it does not have enough privilege to lock pages in memory."); return 0; } @@ -3325,15 +3329,26 @@ static size_t large_page_init_decide_size() { return 0; } -#if defined(IA32) || defined(AMD64) - if (size > 4*M || LargePageSizeInBytes > 4*M) { +#if defined(IA32) + if (size > 4 * M || LargePageSizeInBytes > 4 * M) { WARN("JVM cannot use large pages bigger than 4mb."); return 0; } +#elif defined(AMD64) + if (!EnableAllLargePageSizesForWindows) { + if (size > 4 * M || LargePageSizeInBytes > 4 * M) { + WARN("JVM cannot use large pages bigger than 4mb."); + return 0; + } + } #endif - if (LargePageSizeInBytes > 0 && LargePageSizeInBytes % size == 0) { - size = LargePageSizeInBytes; + if (LargePageSizeInBytes > 0) { + if (LargePageSizeInBytes % size == 0) { + size = LargePageSizeInBytes; + } else { + WARN("The specified large page size (%d) is not a multiple of the minimum large page size (%d), defaulting to minimum page size.", LargePageSizeInBytes, size); + } } #undef WARN @@ -3346,12 +3361,23 @@ void os::large_page_init() { return; } - _large_page_size = large_page_init_decide_size(); + _large_page_size = os::win32::large_page_init_decide_size(); const size_t default_page_size = os::vm_page_size(); if (_large_page_size > default_page_size) { +#if !defined(IA32) + if (EnableAllLargePageSizesForWindows) { + size_t min_size = GetLargePageMinimum(); + + // Populate _page_sizes with large page sizes less than or equal to _large_page_size, ensuring each page size is double the size of the previous one. + for (size_t page_size = min_size; page_size < _large_page_size; page_size *= 2) { + _page_sizes.add(page_size); + } + } +#endif + _page_sizes.add(_large_page_size); } - + // Set UseLargePages based on whether a large page size was successfully determined UseLargePages = _large_page_size != 0; } @@ -3428,7 +3454,7 @@ char* os::replace_existing_mapping_with_file_mapping(char* base, size_t size, in // Multiple threads can race in this code but it's not possible to unmap small sections of // virtual space to get requested alignment, like posix-like os's. // Windows prevents multiple thread from remapping over each other so this loop is thread-safe. -static char* map_or_reserve_memory_aligned(size_t size, size_t alignment, int file_desc, MEMFLAGS flag = mtNone) { +static char* map_or_reserve_memory_aligned(size_t size, size_t alignment, int file_desc, MemTag mem_tag = mtNone) { assert(is_aligned(alignment, os::vm_allocation_granularity()), "Alignment must be a multiple of allocation granularity (page size)"); assert(is_aligned(size, os::vm_allocation_granularity()), @@ -3441,8 +3467,8 @@ static char* map_or_reserve_memory_aligned(size_t size, size_t alignment, int fi static const int max_attempts = 20; for (int attempt = 0; attempt < max_attempts && aligned_base == nullptr; attempt ++) { - char* extra_base = file_desc != -1 ? os::map_memory_to_file(extra_size, file_desc, flag) : - os::reserve_memory(extra_size, false, flag); + char* extra_base = file_desc != -1 ? os::map_memory_to_file(extra_size, file_desc, mem_tag) : + os::reserve_memory(extra_size, false, mem_tag); if (extra_base == nullptr) { return nullptr; } @@ -3458,8 +3484,8 @@ static char* map_or_reserve_memory_aligned(size_t size, size_t alignment, int fi // Attempt to map, into the just vacated space, the slightly smaller aligned area. // Which may fail, hence the loop. - aligned_base = file_desc != -1 ? os::attempt_map_memory_to_file_at(aligned_base, size, file_desc, flag) : - os::attempt_reserve_memory_at(aligned_base, size, false, flag); + aligned_base = file_desc != -1 ? os::attempt_map_memory_to_file_at(aligned_base, size, file_desc, mem_tag) : + os::attempt_reserve_memory_at(aligned_base, size, false, mem_tag); } assert(aligned_base != nullptr, @@ -3473,8 +3499,8 @@ char* os::reserve_memory_aligned(size_t size, size_t alignment, bool exec) { return map_or_reserve_memory_aligned(size, alignment, -1 /* file_desc */); } -char* os::map_memory_to_file_aligned(size_t size, size_t alignment, int fd, MEMFLAGS flag) { - return map_or_reserve_memory_aligned(size, alignment, fd, flag); +char* os::map_memory_to_file_aligned(size_t size, size_t alignment, int fd, MemTag mem_tag) { + return map_or_reserve_memory_aligned(size, alignment, fd, mem_tag); } char* os::pd_reserve_memory(size_t bytes, bool exec) { @@ -3615,7 +3641,6 @@ static char* reserve_large_pages_aligned(size_t size, size_t alignment, bool exe char* os::pd_reserve_memory_special(size_t bytes, size_t alignment, size_t page_size, char* addr, bool exec) { assert(UseLargePages, "only for large pages"); - assert(page_size == os::large_page_size(), "Currently only support one large page size on Windows"); assert(is_aligned(addr, alignment), "Must be"); assert(is_aligned(addr, page_size), "Must be"); @@ -3624,11 +3649,17 @@ char* os::pd_reserve_memory_special(size_t bytes, size_t alignment, size_t page_ return nullptr; } + // Ensure GetLargePageMinimum() returns a valid positive value + size_t large_page_min = GetLargePageMinimum(); + if (large_page_min <= 0) { + return nullptr; + } + // The requested alignment can be larger than the page size, for example with G1 // the alignment is bound to the heap region size. So this reservation needs to // ensure that the requested alignment is met. When there is a requested address // this solves it self, since it must be properly aligned already. - if (addr == nullptr && alignment > page_size) { + if (addr == nullptr && alignment > large_page_min) { return reserve_large_pages_aligned(bytes, alignment, exec); } @@ -4090,6 +4121,39 @@ int os::win32::_build_minor = 0; bool os::win32::_processor_group_warning_displayed = false; bool os::win32::_job_object_processor_group_warning_displayed = false; +void getWindowsInstallationType(char* buffer, int bufferSize) { + HKEY hKey; + const char* subKey = "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"; + const char* valueName = "InstallationType"; + + DWORD valueLength = bufferSize; + + // Initialize buffer with empty string + buffer[0] = '\0'; + + // Open the registry key + if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, subKey, 0, KEY_READ, &hKey) != ERROR_SUCCESS) { + // Return empty buffer if key cannot be opened + return; + } + + // Query the value + if (RegQueryValueExA(hKey, valueName, NULL, NULL, (LPBYTE)buffer, &valueLength) != ERROR_SUCCESS) { + RegCloseKey(hKey); + buffer[0] = '\0'; + return; + } + + RegCloseKey(hKey); +} + +bool isNanoServer() { + const int BUFFER_SIZE = 256; + char installationType[BUFFER_SIZE]; + getWindowsInstallationType(installationType, BUFFER_SIZE); + return (strcmp(installationType, "Nano Server") == 0); +} + void os::win32::initialize_windows_version() { assert(_major_version == 0, "windows version already initialized."); @@ -4107,7 +4171,13 @@ void os::win32::initialize_windows_version() { warning("Attempt to determine system directory failed: %s", buf_len != 0 ? error_msg_buffer : ""); return; } - strncat(kernel32_path, "\\kernel32.dll", MAX_PATH - ret); + + if (isNanoServer()) { + // On Windows Nanoserver the kernel32.dll is located in the forwarders subdirectory + strncat(kernel32_path, "\\forwarders\\kernel32.dll", MAX_PATH - ret); + } else { + strncat(kernel32_path, "\\kernel32.dll", MAX_PATH - ret); + } DWORD version_size = GetFileVersionInfoSize(kernel32_path, nullptr); if (version_size == 0) { @@ -5741,11 +5811,23 @@ void Parker::unpark() { SetEvent(_ParkHandle); } +// Platform Mutex/Monitor implementation + +PlatformMutex::PlatformMutex() { + InitializeCriticalSection(&_mutex); +} + PlatformMutex::~PlatformMutex() { DeleteCriticalSection(&_mutex); } -// Platform Monitor implementation +PlatformMonitor::PlatformMonitor() { + InitializeConditionVariable(&_cond); +} + +PlatformMonitor::~PlatformMonitor() { + // There is no DeleteConditionVariable API +} // Must already be locked int PlatformMonitor::wait(uint64_t millis) { @@ -5911,7 +5993,7 @@ static void do_resume(HANDLE* h) { // retrieve a suspend/resume context capable handle // from the tid. Caller validates handle return value. void get_thread_handle_for_extended_context(HANDLE* h, - OSThread::thread_id_t tid) { + DWORD tid) { if (h != nullptr) { *h = OpenThread(THREAD_SUSPEND_RESUME | THREAD_GET_CONTEXT | THREAD_QUERY_INFORMATION, FALSE, tid); } diff --git a/src/hotspot/os/windows/os_windows.hpp b/src/hotspot/os/windows/os_windows.hpp index 3bc5ab9eef1..1d523724300 100644 --- a/src/hotspot/os/windows/os_windows.hpp +++ b/src/hotspot/os/windows/os_windows.hpp @@ -65,6 +65,8 @@ class os::win32 { static void setmode_streams(); static bool is_windows_11_or_greater(); static bool is_windows_server_2022_or_greater(); + static bool request_lock_memory_privilege(); + static size_t large_page_init_decide_size(); static int windows_major_version() { assert(_major_version > 0, "windows version not initialized."); return _major_version; diff --git a/src/hotspot/os/windows/os_windows.inline.hpp b/src/hotspot/os/windows/os_windows.inline.hpp index bb2da39d422..e9b30a33dfd 100644 --- a/src/hotspot/os/windows/os_windows.inline.hpp +++ b/src/hotspot/os/windows/os_windows.inline.hpp @@ -49,30 +49,23 @@ inline void os::map_stack_shadow_pages(address sp) { // If we decrement stack pointer more than one page // the OS may not map an intervening page into our space // and may fault on a memory access to interior of our frame. + address original_sp = sp; const size_t page_size = os::vm_page_size(); const size_t n_pages = StackOverflow::stack_shadow_zone_size() / page_size; for (size_t pages = 1; pages <= n_pages; pages++) { sp -= page_size; *sp = 0; } + StackOverflow* state = JavaThread::current()->stack_overflow_state(); + assert(original_sp > state->shadow_zone_safe_limit(), "original_sp=" INTPTR_FORMAT ", " + "shadow_zone_safe_limit=" INTPTR_FORMAT, p2i(original_sp), p2i(state->shadow_zone_safe_limit())); + state->set_shadow_zone_growth_watermark(original_sp); } inline bool os::numa_has_group_homing() { return false; } // Platform Mutex/Monitor implementation -inline PlatformMutex::PlatformMutex() { - InitializeCriticalSection(&_mutex); -} - -inline PlatformMonitor::PlatformMonitor() { - InitializeConditionVariable(&_cond); -} - -inline PlatformMonitor::~PlatformMonitor() { - // There is no DeleteConditionVariable API -} - inline void PlatformMutex::lock() { EnterCriticalSection(&_mutex); } diff --git a/src/hotspot/os/windows/vmStructs_windows.hpp b/src/hotspot/os/windows/vmStructs_windows.hpp index 2550e685f16..93f4ea7c811 100644 --- a/src/hotspot/os/windows/vmStructs_windows.hpp +++ b/src/hotspot/os/windows/vmStructs_windows.hpp @@ -29,9 +29,18 @@ // constants required by the Serviceability Agent. This file is // referenced by vmStructs.cpp. -#define VM_STRUCTS_OS(nonstatic_field, static_field, unchecked_nonstatic_field, volatile_nonstatic_field, nonproduct_nonstatic_field, c2_nonstatic_field, unchecked_c1_static_field, unchecked_c2_static_field) +#define VM_STRUCTS_OS(nonstatic_field, static_field, unchecked_nonstatic_field, volatile_nonstatic_field, nonproduct_nonstatic_field, c2_nonstatic_field, unchecked_c1_static_field, unchecked_c2_static_field) \ + \ + /******************************/ \ + /* Threads (NOTE: incomplete) */ \ + /******************************/ \ + \ + nonstatic_field(OSThread, _thread_id, OSThread::thread_id_t) \ + unchecked_nonstatic_field(OSThread, _thread_handle, sizeof(HANDLE)) /* NOTE: no type */ -#define VM_TYPES_OS(declare_type, declare_toplevel_type, declare_oop_type, declare_integer_type, declare_unsigned_integer_type, declare_c1_toplevel_type, declare_c2_type, declare_c2_toplevel_type) +#define VM_TYPES_OS(declare_type, declare_toplevel_type, declare_oop_type, declare_integer_type, declare_unsigned_integer_type, declare_c1_toplevel_type, declare_c2_type, declare_c2_toplevel_type) \ + \ + declare_unsigned_integer_type(OSThread::thread_id_t) #define VM_INT_CONSTANTS_OS(declare_constant, declare_preprocessor_constant, declare_c1_constant, declare_c2_constant, declare_c2_preprocessor_constant) diff --git a/src/hotspot/os_cpu/aix_ppc/vmStructs_aix_ppc.hpp b/src/hotspot/os_cpu/aix_ppc/vmStructs_aix_ppc.hpp index 157d57f8e0f..123cd67248f 100644 --- a/src/hotspot/os_cpu/aix_ppc/vmStructs_aix_ppc.hpp +++ b/src/hotspot/os_cpu/aix_ppc/vmStructs_aix_ppc.hpp @@ -30,21 +30,9 @@ // constants required by the Serviceability Agent. This file is // referenced by vmStructs.cpp. -#define VM_STRUCTS_OS_CPU(nonstatic_field, static_field, unchecked_nonstatic_field, volatile_nonstatic_field, nonproduct_nonstatic_field, c2_nonstatic_field, unchecked_c1_static_field, unchecked_c2_static_field) \ - \ - /******************************/ \ - /* Threads (NOTE: incomplete) */ \ - /******************************/ \ - nonstatic_field(OSThread, _thread_id, pthread_t) \ +#define VM_STRUCTS_OS_CPU(nonstatic_field, static_field, unchecked_nonstatic_field, volatile_nonstatic_field, nonproduct_nonstatic_field, c2_nonstatic_field, unchecked_c1_static_field, unchecked_c2_static_field) - -#define VM_TYPES_OS_CPU(declare_type, declare_toplevel_type, declare_oop_type, declare_integer_type, declare_unsigned_integer_type, declare_c1_toplevel_type, declare_c2_type, declare_c2_toplevel_type) \ - \ - /**********************/ \ - /* Posix Thread IDs */ \ - /**********************/ \ - \ - declare_unsigned_integer_type(pthread_t) +#define VM_TYPES_OS_CPU(declare_type, declare_toplevel_type, declare_oop_type, declare_integer_type, declare_unsigned_integer_type, declare_c1_toplevel_type, declare_c2_type, declare_c2_toplevel_type) #define VM_INT_CONSTANTS_OS_CPU(declare_constant, declare_preprocessor_constant, declare_c1_constant, declare_c2_constant, declare_c2_preprocessor_constant) diff --git a/src/hotspot/os_cpu/bsd_aarch64/vmStructs_bsd_aarch64.hpp b/src/hotspot/os_cpu/bsd_aarch64/vmStructs_bsd_aarch64.hpp index 07b878106cf..c384afac7ec 100644 --- a/src/hotspot/os_cpu/bsd_aarch64/vmStructs_bsd_aarch64.hpp +++ b/src/hotspot/os_cpu/bsd_aarch64/vmStructs_bsd_aarch64.hpp @@ -31,22 +31,9 @@ // constants required by the Serviceability Agent. This file is // referenced by vmStructs.cpp. -#define VM_STRUCTS_OS_CPU(nonstatic_field, static_field, unchecked_nonstatic_field, volatile_nonstatic_field, nonproduct_nonstatic_field, c2_nonstatic_field, unchecked_c1_static_field, unchecked_c2_static_field) \ - \ - /******************************/ \ - /* Threads (NOTE: incomplete) */ \ - /******************************/ \ - nonstatic_field(OSThread, _thread_id, OSThread::thread_id_t) \ - nonstatic_field(OSThread, _unique_thread_id, uint64_t) +#define VM_STRUCTS_OS_CPU(nonstatic_field, static_field, unchecked_nonstatic_field, volatile_nonstatic_field, nonproduct_nonstatic_field, c2_nonstatic_field, unchecked_c1_static_field, unchecked_c2_static_field) - -#define VM_TYPES_OS_CPU(declare_type, declare_toplevel_type, declare_oop_type, declare_integer_type, declare_unsigned_integer_type, declare_c1_toplevel_type, declare_c2_type, declare_c2_toplevel_type) \ - \ - /**********************/ \ - /* Thread IDs */ \ - /**********************/ \ - \ - declare_unsigned_integer_type(OSThread::thread_id_t) +#define VM_TYPES_OS_CPU(declare_type, declare_toplevel_type, declare_oop_type, declare_integer_type, declare_unsigned_integer_type, declare_c1_toplevel_type, declare_c2_type, declare_c2_toplevel_type) #define VM_INT_CONSTANTS_OS_CPU(declare_constant, declare_preprocessor_constant, declare_c1_constant, declare_c2_constant, declare_c2_preprocessor_constant) diff --git a/src/hotspot/os_cpu/bsd_x86/vmStructs_bsd_x86.hpp b/src/hotspot/os_cpu/bsd_x86/vmStructs_bsd_x86.hpp index fb43541fa77..b48ea82712e 100644 --- a/src/hotspot/os_cpu/bsd_x86/vmStructs_bsd_x86.hpp +++ b/src/hotspot/os_cpu/bsd_x86/vmStructs_bsd_x86.hpp @@ -29,22 +29,9 @@ // constants required by the Serviceability Agent. This file is // referenced by vmStructs.cpp. -#define VM_STRUCTS_OS_CPU(nonstatic_field, static_field, unchecked_nonstatic_field, volatile_nonstatic_field, nonproduct_nonstatic_field, c2_nonstatic_field, unchecked_c1_static_field, unchecked_c2_static_field) \ - \ - /******************************/ \ - /* Threads (NOTE: incomplete) */ \ - /******************************/ \ - nonstatic_field(OSThread, _thread_id, OSThread::thread_id_t) \ - nonstatic_field(OSThread, _unique_thread_id, uint64_t) +#define VM_STRUCTS_OS_CPU(nonstatic_field, static_field, unchecked_nonstatic_field, volatile_nonstatic_field, nonproduct_nonstatic_field, c2_nonstatic_field, unchecked_c1_static_field, unchecked_c2_static_field) - -#define VM_TYPES_OS_CPU(declare_type, declare_toplevel_type, declare_oop_type, declare_integer_type, declare_unsigned_integer_type, declare_c1_toplevel_type, declare_c2_type, declare_c2_toplevel_type) \ - \ - /**********************/ \ - /* Thread IDs */ \ - /**********************/ \ - \ - declare_unsigned_integer_type(OSThread::thread_id_t) +#define VM_TYPES_OS_CPU(declare_type, declare_toplevel_type, declare_oop_type, declare_integer_type, declare_unsigned_integer_type, declare_c1_toplevel_type, declare_c2_type, declare_c2_toplevel_type) #define VM_INT_CONSTANTS_OS_CPU(declare_constant, declare_preprocessor_constant, declare_c1_constant, declare_c2_constant, declare_c2_preprocessor_constant) diff --git a/src/hotspot/os_cpu/linux_aarch64/vmStructs_linux_aarch64.hpp b/src/hotspot/os_cpu/linux_aarch64/vmStructs_linux_aarch64.hpp index f2ad002996b..3c8e9c44414 100644 --- a/src/hotspot/os_cpu/linux_aarch64/vmStructs_linux_aarch64.hpp +++ b/src/hotspot/os_cpu/linux_aarch64/vmStructs_linux_aarch64.hpp @@ -30,23 +30,9 @@ // constants required by the Serviceability Agent. This file is // referenced by vmStructs.cpp. -#define VM_STRUCTS_OS_CPU(nonstatic_field, static_field, unchecked_nonstatic_field, volatile_nonstatic_field, nonproduct_nonstatic_field, c2_nonstatic_field, unchecked_c1_static_field, unchecked_c2_static_field) \ - \ - /******************************/ \ - /* Threads (NOTE: incomplete) */ \ - /******************************/ \ - nonstatic_field(OSThread, _thread_id, OSThread::thread_id_t) \ - nonstatic_field(OSThread, _pthread_id, pthread_t) +#define VM_STRUCTS_OS_CPU(nonstatic_field, static_field, unchecked_nonstatic_field, volatile_nonstatic_field, nonproduct_nonstatic_field, c2_nonstatic_field, unchecked_c1_static_field, unchecked_c2_static_field) - -#define VM_TYPES_OS_CPU(declare_type, declare_toplevel_type, declare_oop_type, declare_integer_type, declare_unsigned_integer_type, declare_c1_toplevel_type, declare_c2_type, declare_c2_toplevel_type) \ - \ - /**********************/ \ - /* Posix Thread IDs */ \ - /**********************/ \ - \ - declare_integer_type(OSThread::thread_id_t) \ - declare_unsigned_integer_type(pthread_t) +#define VM_TYPES_OS_CPU(declare_type, declare_toplevel_type, declare_oop_type, declare_integer_type, declare_unsigned_integer_type, declare_c1_toplevel_type, declare_c2_type, declare_c2_toplevel_type) #define VM_INT_CONSTANTS_OS_CPU(declare_constant, declare_preprocessor_constant, declare_c1_constant, declare_c2_constant, declare_c2_preprocessor_constant) diff --git a/src/hotspot/os_cpu/linux_arm/vmStructs_linux_arm.hpp b/src/hotspot/os_cpu/linux_arm/vmStructs_linux_arm.hpp index 9b4bd0faf0a..120726bf55f 100644 --- a/src/hotspot/os_cpu/linux_arm/vmStructs_linux_arm.hpp +++ b/src/hotspot/os_cpu/linux_arm/vmStructs_linux_arm.hpp @@ -29,22 +29,9 @@ // constants required by the Serviceability Agent. This file is // referenced by vmStructs.cpp. -#define VM_STRUCTS_OS_CPU(nonstatic_field, static_field, unchecked_nonstatic_field, volatile_nonstatic_field, nonproduct_nonstatic_field, c2_nonstatic_field, unchecked_c1_static_field, unchecked_c2_static_field) \ - \ - /******************************/ \ - /* Threads (NOTE: incomplete) */ \ - /******************************/ \ - nonstatic_field(OSThread, _thread_id, OSThread::thread_id_t) \ - nonstatic_field(OSThread, _pthread_id, pthread_t) +#define VM_STRUCTS_OS_CPU(nonstatic_field, static_field, unchecked_nonstatic_field, volatile_nonstatic_field, nonproduct_nonstatic_field, c2_nonstatic_field, unchecked_c1_static_field, unchecked_c2_static_field) -#define VM_TYPES_OS_CPU(declare_type, declare_toplevel_type, declare_oop_type, declare_integer_type, declare_unsigned_integer_type, declare_c1_toplevel_type, declare_c2_type, declare_c2_toplevel_type) \ - \ - /**********************/ \ - /* Posix Thread IDs */ \ - /**********************/ \ - \ - declare_integer_type(OSThread::thread_id_t) \ - declare_unsigned_integer_type(pthread_t) +#define VM_TYPES_OS_CPU(declare_type, declare_toplevel_type, declare_oop_type, declare_integer_type, declare_unsigned_integer_type, declare_c1_toplevel_type, declare_c2_type, declare_c2_toplevel_type) #define VM_INT_CONSTANTS_OS_CPU(declare_constant, declare_preprocessor_constant, declare_c1_constant, declare_c2_constant, declare_c2_preprocessor_constant) diff --git a/src/hotspot/os_cpu/linux_ppc/vmStructs_linux_ppc.hpp b/src/hotspot/os_cpu/linux_ppc/vmStructs_linux_ppc.hpp index 9464c359770..ae948c73031 100644 --- a/src/hotspot/os_cpu/linux_ppc/vmStructs_linux_ppc.hpp +++ b/src/hotspot/os_cpu/linux_ppc/vmStructs_linux_ppc.hpp @@ -30,23 +30,9 @@ // constants required by the Serviceability Agent. This file is // referenced by vmStructs.cpp. -#define VM_STRUCTS_OS_CPU(nonstatic_field, static_field, unchecked_nonstatic_field, volatile_nonstatic_field, nonproduct_nonstatic_field, c2_nonstatic_field, unchecked_c1_static_field, unchecked_c2_static_field) \ - \ - /******************************/ \ - /* Threads (NOTE: incomplete) */ \ - /******************************/ \ - nonstatic_field(OSThread, _thread_id, pid_t) \ - nonstatic_field(OSThread, _pthread_id, pthread_t) +#define VM_STRUCTS_OS_CPU(nonstatic_field, static_field, unchecked_nonstatic_field, volatile_nonstatic_field, nonproduct_nonstatic_field, c2_nonstatic_field, unchecked_c1_static_field, unchecked_c2_static_field) - -#define VM_TYPES_OS_CPU(declare_type, declare_toplevel_type, declare_oop_type, declare_integer_type, declare_unsigned_integer_type, declare_c1_toplevel_type, declare_c2_type, declare_c2_toplevel_type) \ - \ - /**********************/ \ - /* Posix Thread IDs */ \ - /**********************/ \ - \ - declare_integer_type(pid_t) \ - declare_unsigned_integer_type(pthread_t) +#define VM_TYPES_OS_CPU(declare_type, declare_toplevel_type, declare_oop_type, declare_integer_type, declare_unsigned_integer_type, declare_c1_toplevel_type, declare_c2_type, declare_c2_toplevel_type) #define VM_INT_CONSTANTS_OS_CPU(declare_constant, declare_preprocessor_constant, declare_c1_constant, declare_c2_constant, declare_c2_preprocessor_constant) diff --git a/src/hotspot/os_cpu/linux_riscv/orderAccess_linux_riscv.hpp b/src/hotspot/os_cpu/linux_riscv/orderAccess_linux_riscv.hpp index a7dc84770f8..368d6c971fa 100644 --- a/src/hotspot/os_cpu/linux_riscv/orderAccess_linux_riscv.hpp +++ b/src/hotspot/os_cpu/linux_riscv/orderAccess_linux_riscv.hpp @@ -54,6 +54,24 @@ inline void OrderAccess::fence() { } inline void OrderAccess::cross_modify_fence_impl() { + // From 3 “Zifencei” Instruction-Fetch Fence, Version 2.0 + // "RISC-V does not guarantee that stores to instruction memory will be made + // visible to instruction fetches on a RISC-V hart until that hart executes a + // FENCE.I instruction. A FENCE.I instruction ensures that a subsequent + // instruction fetch on a RISC-V hart will see any previous data stores + // already visible to the same RISC-V hart. FENCE.I does not ensure that other + // RISC-V harts’ instruction fetches will observe the local hart’s stores in a + // multiprocessor system." + // + // Hence to be able to use fence.i directly we need a kernel that supports + // PR_RISCV_CTX_SW_FENCEI_ON. Thus if context switch to another hart we are + // ensured that instruction fetch will see any previous data stores + // + // The alternative is using full system IPI (system wide icache sync) then + // this barrier is not strictly needed. As this is emitted in runtime slow-path + // we will just always emit it, typically after a safepoint. + guarantee(VM_Version::supports_fencei_barrier(), "Linux kernel require fence.i"); + __asm__ volatile("fence.i" : : : "memory"); } #endif // OS_CPU_LINUX_RISCV_ORDERACCESS_LINUX_RISCV_HPP diff --git a/src/hotspot/os_cpu/linux_riscv/vmStructs_linux_riscv.hpp b/src/hotspot/os_cpu/linux_riscv/vmStructs_linux_riscv.hpp index 6cf7683a586..3946394c19b 100644 --- a/src/hotspot/os_cpu/linux_riscv/vmStructs_linux_riscv.hpp +++ b/src/hotspot/os_cpu/linux_riscv/vmStructs_linux_riscv.hpp @@ -30,23 +30,9 @@ // constants required by the Serviceability Agent. This file is // referenced by vmStructs.cpp. -#define VM_STRUCTS_OS_CPU(nonstatic_field, static_field, unchecked_nonstatic_field, volatile_nonstatic_field, nonproduct_nonstatic_field, c2_nonstatic_field, unchecked_c1_static_field, unchecked_c2_static_field) \ - \ - /******************************/ \ - /* Threads (NOTE: incomplete) */ \ - /******************************/ \ - nonstatic_field(OSThread, _thread_id, OSThread::thread_id_t) \ - nonstatic_field(OSThread, _pthread_id, pthread_t) +#define VM_STRUCTS_OS_CPU(nonstatic_field, static_field, unchecked_nonstatic_field, volatile_nonstatic_field, nonproduct_nonstatic_field, c2_nonstatic_field, unchecked_c1_static_field, unchecked_c2_static_field) - -#define VM_TYPES_OS_CPU(declare_type, declare_toplevel_type, declare_oop_type, declare_integer_type, declare_unsigned_integer_type, declare_c1_toplevel_type, declare_c2_type, declare_c2_toplevel_type) \ - \ - /**********************/ \ - /* Posix Thread IDs */ \ - /**********************/ \ - \ - declare_integer_type(OSThread::thread_id_t) \ - declare_unsigned_integer_type(pthread_t) +#define VM_TYPES_OS_CPU(declare_type, declare_toplevel_type, declare_oop_type, declare_integer_type, declare_unsigned_integer_type, declare_c1_toplevel_type, declare_c2_type, declare_c2_toplevel_type) #define VM_INT_CONSTANTS_OS_CPU(declare_constant, declare_preprocessor_constant, declare_c1_constant, declare_c2_constant, declare_c2_preprocessor_constant) diff --git a/src/hotspot/os_cpu/linux_riscv/vm_version_linux_riscv.cpp b/src/hotspot/os_cpu/linux_riscv/vm_version_linux_riscv.cpp index 3f9f26b525b..a3a226502f6 100644 --- a/src/hotspot/os_cpu/linux_riscv/vm_version_linux_riscv.cpp +++ b/src/hotspot/os_cpu/linux_riscv/vm_version_linux_riscv.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #ifndef HWCAP_ISA_I #define HWCAP_ISA_I nth_bit('I' - 'A') @@ -82,6 +83,23 @@ __v; \ }) +// prctl PR_RISCV_SET_ICACHE_FLUSH_CTX is from Linux 6.9 +#ifndef PR_RISCV_SET_ICACHE_FLUSH_CTX +#define PR_RISCV_SET_ICACHE_FLUSH_CTX 71 +#endif +#ifndef PR_RISCV_CTX_SW_FENCEI_ON +#define PR_RISCV_CTX_SW_FENCEI_ON 0 +#endif +#ifndef PR_RISCV_CTX_SW_FENCEI_OFF +#define PR_RISCV_CTX_SW_FENCEI_OFF 1 +#endif +#ifndef PR_RISCV_SCOPE_PER_PROCESS +#define PR_RISCV_SCOPE_PER_PROCESS 0 +#endif +#ifndef PR_RISCV_SCOPE_PER_THREAD +#define PR_RISCV_SCOPE_PER_THREAD 1 +#endif + uint32_t VM_Version::cpu_vector_length() { assert(ext_V.enabled(), "should not call this"); return (uint32_t)read_csr(CSR_VLENB); @@ -102,6 +120,7 @@ void VM_Version::setup_cpu_available_features() { if (!RiscvHwprobe::probe_features()) { os_aux_features(); } + char* uarch = os_uarch_additional_features(); vendor_features(); @@ -155,6 +174,24 @@ void VM_Version::setup_cpu_available_features() { i++; } + // Linux kernel require Zifencei + if (!ext_Zifencei.enabled()) { + log_info(os, cpu)("Zifencei not found, required by Linux, enabling."); + ext_Zifencei.enable_feature(); + } + + if (UseCtxFencei) { + // Note that we can set this up only for effected threads + // via PR_RISCV_SCOPE_PER_THREAD, i.e. on VM attach/deattach. + int ret = prctl(PR_RISCV_SET_ICACHE_FLUSH_CTX, PR_RISCV_CTX_SW_FENCEI_ON, PR_RISCV_SCOPE_PER_PROCESS); + if (ret == 0) { + log_debug(os, cpu)("UseCtxFencei (PR_RISCV_CTX_SW_FENCEI_ON) enabled."); + } else { + FLAG_SET_ERGO(UseCtxFencei, false); + log_info(os, cpu)("UseCtxFencei (PR_RISCV_CTX_SW_FENCEI_ON) disabled, unsupported by kernel."); + } + } + _features_string = os::strdup(buf); } diff --git a/src/hotspot/os_cpu/linux_s390/vmStructs_linux_s390.hpp b/src/hotspot/os_cpu/linux_s390/vmStructs_linux_s390.hpp index 0442510fa24..a0fb5eb1a6a 100644 --- a/src/hotspot/os_cpu/linux_s390/vmStructs_linux_s390.hpp +++ b/src/hotspot/os_cpu/linux_s390/vmStructs_linux_s390.hpp @@ -30,23 +30,9 @@ // constants required by the Serviceability Agent. This file is // referenced by vmStructs.cpp. -#define VM_STRUCTS_OS_CPU(nonstatic_field, static_field, unchecked_nonstatic_field, volatile_nonstatic_field, nonproduct_nonstatic_field, c2_nonstatic_field, unchecked_c1_static_field, unchecked_c2_static_field) \ - \ - /******************************/ \ - /* Threads (NOTE: incomplete) */ \ - /******************************/ \ - nonstatic_field(OSThread, _thread_id, pid_t) \ - nonstatic_field(OSThread, _pthread_id, pthread_t) +#define VM_STRUCTS_OS_CPU(nonstatic_field, static_field, unchecked_nonstatic_field, volatile_nonstatic_field, nonproduct_nonstatic_field, c2_nonstatic_field, unchecked_c1_static_field, unchecked_c2_static_field) - -#define VM_TYPES_OS_CPU(declare_type, declare_toplevel_type, declare_oop_type, declare_integer_type, declare_unsigned_integer_type, declare_c1_toplevel_type, declare_c2_type, declare_c2_toplevel_type) \ - \ - /**********************/ \ - /* Posix Thread IDs */ \ - /**********************/ \ - \ - declare_integer_type(pid_t) \ - declare_unsigned_integer_type(pthread_t) +#define VM_TYPES_OS_CPU(declare_type, declare_toplevel_type, declare_oop_type, declare_integer_type, declare_unsigned_integer_type, declare_c1_toplevel_type, declare_c2_type, declare_c2_toplevel_type) #define VM_INT_CONSTANTS_OS_CPU(declare_constant, declare_preprocessor_constant, declare_c1_constant, declare_c2_constant, declare_c2_preprocessor_constant) diff --git a/src/hotspot/os_cpu/linux_x86/vmStructs_linux_x86.hpp b/src/hotspot/os_cpu/linux_x86/vmStructs_linux_x86.hpp index 277486549c0..8f6d3657237 100644 --- a/src/hotspot/os_cpu/linux_x86/vmStructs_linux_x86.hpp +++ b/src/hotspot/os_cpu/linux_x86/vmStructs_linux_x86.hpp @@ -29,23 +29,9 @@ // constants required by the Serviceability Agent. This file is // referenced by vmStructs.cpp. -#define VM_STRUCTS_OS_CPU(nonstatic_field, static_field, unchecked_nonstatic_field, volatile_nonstatic_field, nonproduct_nonstatic_field, c2_nonstatic_field, unchecked_c1_static_field, unchecked_c2_static_field) \ - \ - /******************************/ \ - /* Threads (NOTE: incomplete) */ \ - /******************************/ \ - nonstatic_field(OSThread, _thread_id, OSThread::thread_id_t) \ - nonstatic_field(OSThread, _pthread_id, pthread_t) +#define VM_STRUCTS_OS_CPU(nonstatic_field, static_field, unchecked_nonstatic_field, volatile_nonstatic_field, nonproduct_nonstatic_field, c2_nonstatic_field, unchecked_c1_static_field, unchecked_c2_static_field) - -#define VM_TYPES_OS_CPU(declare_type, declare_toplevel_type, declare_oop_type, declare_integer_type, declare_unsigned_integer_type, declare_c1_toplevel_type, declare_c2_type, declare_c2_toplevel_type) \ - \ - /**********************/ \ - /* Posix Thread IDs */ \ - /**********************/ \ - \ - declare_integer_type(OSThread::thread_id_t) \ - declare_unsigned_integer_type(pthread_t) +#define VM_TYPES_OS_CPU(declare_type, declare_toplevel_type, declare_oop_type, declare_integer_type, declare_unsigned_integer_type, declare_c1_toplevel_type, declare_c2_type, declare_c2_toplevel_type) #define VM_INT_CONSTANTS_OS_CPU(declare_constant, declare_preprocessor_constant, declare_c1_constant, declare_c2_constant, declare_c2_preprocessor_constant) diff --git a/src/hotspot/os_cpu/windows_aarch64/vmStructs_windows_aarch64.hpp b/src/hotspot/os_cpu/windows_aarch64/vmStructs_windows_aarch64.hpp index 220787823dc..18a5588b743 100644 --- a/src/hotspot/os_cpu/windows_aarch64/vmStructs_windows_aarch64.hpp +++ b/src/hotspot/os_cpu/windows_aarch64/vmStructs_windows_aarch64.hpp @@ -29,18 +29,9 @@ // constants required by the Serviceability Agent. This file is // referenced by vmStructs.cpp. -#define VM_STRUCTS_OS_CPU(nonstatic_field, static_field, unchecked_nonstatic_field, volatile_nonstatic_field, nonproduct_nonstatic_field, c2_nonstatic_field, unchecked_c1_static_field, unchecked_c2_static_field) \ - \ - /******************************/ \ - /* Threads (NOTE: incomplete) */ \ - /******************************/ \ - \ - nonstatic_field(OSThread, _thread_id, OSThread::thread_id_t) \ - unchecked_nonstatic_field(OSThread, _thread_handle, sizeof(HANDLE)) /* NOTE: no type */ +#define VM_STRUCTS_OS_CPU(nonstatic_field, static_field, unchecked_nonstatic_field, volatile_nonstatic_field, nonproduct_nonstatic_field, c2_nonstatic_field, unchecked_c1_static_field, unchecked_c2_static_field) -#define VM_TYPES_OS_CPU(declare_type, declare_toplevel_type, declare_oop_type, declare_integer_type, declare_unsigned_integer_type, declare_c1_toplevel_type, declare_c2_type, declare_c2_toplevel_type) \ - \ - declare_unsigned_integer_type(OSThread::thread_id_t) +#define VM_TYPES_OS_CPU(declare_type, declare_toplevel_type, declare_oop_type, declare_integer_type, declare_unsigned_integer_type, declare_c1_toplevel_type, declare_c2_type, declare_c2_toplevel_type) #define VM_INT_CONSTANTS_OS_CPU(declare_constant, declare_preprocessor_constant, declare_c1_constant, declare_c2_constant, declare_c2_preprocessor_constant) diff --git a/src/hotspot/os_cpu/windows_x86/vmStructs_windows_x86.hpp b/src/hotspot/os_cpu/windows_x86/vmStructs_windows_x86.hpp index 9f50a7ed9ae..985a6a331da 100644 --- a/src/hotspot/os_cpu/windows_x86/vmStructs_windows_x86.hpp +++ b/src/hotspot/os_cpu/windows_x86/vmStructs_windows_x86.hpp @@ -29,18 +29,9 @@ // constants required by the Serviceability Agent. This file is // referenced by vmStructs.cpp. -#define VM_STRUCTS_OS_CPU(nonstatic_field, static_field, unchecked_nonstatic_field, volatile_nonstatic_field, nonproduct_nonstatic_field, c2_nonstatic_field, unchecked_c1_static_field, unchecked_c2_static_field) \ - \ - /******************************/ \ - /* Threads (NOTE: incomplete) */ \ - /******************************/ \ - \ - nonstatic_field(OSThread, _thread_id, OSThread::thread_id_t) \ - unchecked_nonstatic_field(OSThread, _thread_handle, sizeof(HANDLE)) /* NOTE: no type */ +#define VM_STRUCTS_OS_CPU(nonstatic_field, static_field, unchecked_nonstatic_field, volatile_nonstatic_field, nonproduct_nonstatic_field, c2_nonstatic_field, unchecked_c1_static_field, unchecked_c2_static_field) -#define VM_TYPES_OS_CPU(declare_type, declare_toplevel_type, declare_oop_type, declare_integer_type, declare_unsigned_integer_type, declare_c1_toplevel_type, declare_c2_type, declare_c2_toplevel_type) \ - \ - declare_unsigned_integer_type(OSThread::thread_id_t) +#define VM_TYPES_OS_CPU(declare_type, declare_toplevel_type, declare_oop_type, declare_integer_type, declare_unsigned_integer_type, declare_c1_toplevel_type, declare_c2_type, declare_c2_toplevel_type) #define VM_INT_CONSTANTS_OS_CPU(declare_constant, declare_preprocessor_constant, declare_c1_constant, declare_c2_constant, declare_c2_preprocessor_constant) diff --git a/src/hotspot/share/adlc/adlArena.cpp b/src/hotspot/share/adlc/adlArena.cpp index d29a255a905..ebd1f74911d 100644 --- a/src/hotspot/share/adlc/adlArena.cpp +++ b/src/hotspot/share/adlc/adlArena.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -45,6 +45,7 @@ void* AdlReAllocateHeap(void* old_ptr, size_t size) { } void* AdlChunk::operator new(size_t requested_size, size_t length) throw() { + assert(requested_size <= SIZE_MAX - length, "overflow"); return AdlCHeapObj::operator new(requested_size + length); } @@ -62,8 +63,6 @@ void AdlChunk::chop() { AdlChunk *k = this; while( k ) { AdlChunk *tmp = k->_next; - // clear out this chunk (to detect allocation bugs) - memset(k, 0xBE, k->_len); free(k); // Free chunk (was malloc'd) k = tmp; } @@ -129,6 +128,7 @@ void* AdlArena::grow( size_t x ) { //------------------------------calloc----------------------------------------- // Allocate zeroed storage in AdlArena void *AdlArena::Acalloc( size_t items, size_t x ) { + assert(items <= SIZE_MAX / x, "overflow"); size_t z = items*x; // Total size needed void *ptr = Amalloc(z); // Get space memset( ptr, 0, z ); // Zap space @@ -136,21 +136,26 @@ void *AdlArena::Acalloc( size_t items, size_t x ) { } //------------------------------realloc---------------------------------------- +static size_t pointer_delta(const void *left, const void *right) { + assert(left >= right, "pointer delta underflow"); + return (uintptr_t)left - (uintptr_t)right; +} + // Reallocate storage in AdlArena. void *AdlArena::Arealloc( void *old_ptr, size_t old_size, size_t new_size ) { char *c_old = (char*)old_ptr; // Handy name - // Stupid fast special case - if( new_size <= old_size ) { // Shrink in-place - if( c_old+old_size == _hwm) // Attempt to free the excess bytes - _hwm = c_old+new_size; // Adjust hwm - return c_old; - } - // See if we can resize in-place - if( (c_old+old_size == _hwm) && // Adjusting recent thing - (c_old+new_size <= _max) ) { // Still fits where it sits - _hwm = c_old+new_size; // Adjust hwm - return c_old; // Return old pointer + // Reallocating the latest allocation? + if (c_old + old_size == _hwm) { + assert(_chunk->bottom() <= c_old, "invariant"); + + // Reallocate in place if it fits. Also handles shrinking + if (pointer_delta(_max, c_old) >= new_size) { + _hwm = c_old + new_size; + return c_old; + } + } else if (new_size <= old_size) { // Shrink in place + return c_old; } // Oops, got to relocate guts diff --git a/src/hotspot/share/adlc/adlArena.hpp b/src/hotspot/share/adlc/adlArena.hpp index 254f414f707..2e8d8ae8ae2 100644 --- a/src/hotspot/share/adlc/adlArena.hpp +++ b/src/hotspot/share/adlc/adlArena.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -105,8 +105,10 @@ public: // Fast allocate in the arena. Common case is: pointer test + increment. void* Amalloc(size_t x) { #ifdef _LP64 + assert(x <= SIZE_MAX - (8-1), "overflow"); x = (x + (8-1)) & ((unsigned)(-8)); #else + assert(x <= SIZE_MAX - (4-1), "overflow"); x = (x + (4-1)) & ((unsigned)(-4)); #endif if (_hwm + x > _max) { diff --git a/src/hotspot/share/adlc/forms.cpp b/src/hotspot/share/adlc/forms.cpp index 068d745254e..c34a73ea1e1 100644 --- a/src/hotspot/share/adlc/forms.cpp +++ b/src/hotspot/share/adlc/forms.cpp @@ -276,7 +276,6 @@ Form::DataType Form::is_load_from_memory(const char *opType) const { Form::DataType Form::is_store_to_memory(const char *opType) const { if( strcmp(opType,"StoreB")==0) return Form::idealB; - if( strcmp(opType,"StoreCM")==0) return Form::idealB; if( strcmp(opType,"StoreC")==0) return Form::idealC; if( strcmp(opType,"StoreD")==0) return Form::idealD; if( strcmp(opType,"StoreF")==0) return Form::idealF; diff --git a/src/hotspot/share/adlc/formssel.cpp b/src/hotspot/share/adlc/formssel.cpp index e7df38ff221..ac2d3d94153 100644 --- a/src/hotspot/share/adlc/formssel.cpp +++ b/src/hotspot/share/adlc/formssel.cpp @@ -3654,7 +3654,6 @@ int MatchNode::needs_ideal_memory_edge(FormDict &globals) const { #if INCLUDE_SHENANDOAHGC "ShenandoahCompareAndSwapN", "ShenandoahCompareAndSwapP", "ShenandoahWeakCompareAndSwapP", "ShenandoahWeakCompareAndSwapN", "ShenandoahCompareAndExchangeP", "ShenandoahCompareAndExchangeN", #endif - "StoreCM", "GetAndSetB", "GetAndSetS", "GetAndAddI", "GetAndSetI", "GetAndSetP", "GetAndAddB", "GetAndAddS", "GetAndAddL", "GetAndSetL", "GetAndSetN", "ClearArray" @@ -4357,7 +4356,7 @@ bool MatchRule::is_vector() const { "RoundDoubleModeV","RotateLeftV" , "RotateRightV", "LoadVector","StoreVector", "LoadVectorGather", "StoreVectorScatter", "LoadVectorGatherMasked", "StoreVectorScatterMasked", "VectorTest", "VectorLoadMask", "VectorStoreMask", "VectorBlend", "VectorInsert", - "VectorRearrange","VectorLoadShuffle", "VectorLoadConst", + "VectorRearrange", "VectorLoadShuffle", "VectorLoadConst", "VectorCastB2X", "VectorCastS2X", "VectorCastI2X", "VectorCastL2X", "VectorCastF2X", "VectorCastD2X", "VectorCastF2HF", "VectorCastHF2F", "VectorUCastB2X", "VectorUCastS2X", "VectorUCastI2X", diff --git a/src/hotspot/share/asm/register.hpp b/src/hotspot/share/asm/register.hpp index 7dfc9b03f87..6078edecb4a 100644 --- a/src/hotspot/share/asm/register.hpp +++ b/src/hotspot/share/asm/register.hpp @@ -276,19 +276,23 @@ inline constexpr bool different_registers(R first_register, Rx... more_registers } template -inline void assert_different_registers(R first_register, Rx... more_registers) { +inline void assert_different_registers_impl(const char* file, int line, R first_register, Rx... more_registers) { #ifdef ASSERT if (!different_registers(first_register, more_registers...)) { const R regs[] = { first_register, more_registers... }; // Find a duplicate entry. for (size_t i = 0; i < ARRAY_SIZE(regs) - 1; ++i) { for (size_t j = i + 1; j < ARRAY_SIZE(regs); ++j) { - assert(!regs[i]->is_valid() || regs[i] != regs[j], - "Multiple uses of register: %s", regs[i]->name()); + if (regs[i]->is_valid()) { + assert_with_file_and_line(regs[i] != regs[j], file, line, "regs[%zu] and regs[%zu] are both: %s", + i, j, regs[i]->name()); + } } } } #endif } +#define assert_different_registers(...) assert_different_registers_impl(__FILE__, __LINE__, __VA_ARGS__) + #endif // SHARE_ASM_REGISTER_HPP diff --git a/src/hotspot/share/c1/c1_CodeStubs.hpp b/src/hotspot/share/c1/c1_CodeStubs.hpp index 04e379842e1..9abfa45785b 100644 --- a/src/hotspot/share/c1/c1_CodeStubs.hpp +++ b/src/hotspot/share/c1/c1_CodeStubs.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -264,10 +264,10 @@ class NewInstanceStub: public CodeStub { LIR_Opr _klass_reg; LIR_Opr _result; CodeEmitInfo* _info; - Runtime1::StubID _stub_id; + C1StubId _stub_id; public: - NewInstanceStub(LIR_Opr klass_reg, LIR_Opr result, ciInstanceKlass* klass, CodeEmitInfo* info, Runtime1::StubID stub_id); + NewInstanceStub(LIR_Opr klass_reg, LIR_Opr result, ciInstanceKlass* klass, CodeEmitInfo* info, C1StubId stub_id); virtual void emit_code(LIR_Assembler* e); virtual CodeEmitInfo* info() const { return _info; } virtual void visit(LIR_OpVisitState* visitor) { @@ -515,11 +515,11 @@ public: class SimpleExceptionStub: public CodeStub { private: LIR_Opr _obj; - Runtime1::StubID _stub; + C1StubId _stub; CodeEmitInfo* _info; public: - SimpleExceptionStub(Runtime1::StubID stub, LIR_Opr obj, CodeEmitInfo* info): + SimpleExceptionStub(C1StubId stub, LIR_Opr obj, CodeEmitInfo* info): _obj(obj), _stub(stub), _info(info) { FrameMap* f = Compilation::current()->frame_map(); f->update_reserved_argument_area_size(2 * BytesPerWord); @@ -546,7 +546,7 @@ class SimpleExceptionStub: public CodeStub { class ArrayStoreExceptionStub: public SimpleExceptionStub { public: - ArrayStoreExceptionStub(LIR_Opr obj, CodeEmitInfo* info): SimpleExceptionStub(Runtime1::throw_array_store_exception_id, obj, info) {} + ArrayStoreExceptionStub(LIR_Opr obj, CodeEmitInfo* info): SimpleExceptionStub(C1StubId::throw_array_store_exception_id, obj, info) {} #ifndef PRODUCT virtual void print_name(outputStream* out) const { out->print("ArrayStoreExceptionStub"); } #endif // PRODUCT diff --git a/src/hotspot/share/c1/c1_Compilation.cpp b/src/hotspot/share/c1/c1_Compilation.cpp index 48201a86053..7e0d439aff4 100644 --- a/src/hotspot/share/c1/c1_Compilation.cpp +++ b/src/hotspot/share/c1/c1_Compilation.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -274,8 +274,6 @@ void Compilation::emit_lir() { // Assign physical registers to LIR operands using a linear scan algorithm. allocator->do_linear_scan(); CHECK_BAILOUT(); - - _max_spills = allocator->max_spills(); } if (BailoutAfterLIR) { @@ -568,7 +566,6 @@ Compilation::Compilation(AbstractCompiler* compiler, ciEnv* env, ciMethod* metho , _method(method) , _osr_bci(osr_bci) , _hir(nullptr) -, _max_spills(-1) , _frame_map(nullptr) , _masm(nullptr) , _has_exception_handlers(false) diff --git a/src/hotspot/share/c1/c1_Compilation.hpp b/src/hotspot/share/c1/c1_Compilation.hpp index d55a8debca7..0ac0a4d4169 100644 --- a/src/hotspot/share/c1/c1_Compilation.hpp +++ b/src/hotspot/share/c1/c1_Compilation.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -73,7 +73,6 @@ class Compilation: public StackObj { ciMethod* _method; int _osr_bci; IR* _hir; - int _max_spills; FrameMap* _frame_map; C1_MacroAssembler* _masm; bool _has_exception_handlers; @@ -151,7 +150,6 @@ class Compilation: public StackObj { int osr_bci() const { return _osr_bci; } bool is_osr_compile() const { return osr_bci() >= 0; } IR* hir() const { return _hir; } - int max_spills() const { return _max_spills; } FrameMap* frame_map() const { return _frame_map; } CodeBuffer* code() { return &_code; } C1_MacroAssembler* masm() const { return _masm; } diff --git a/src/hotspot/share/c1/c1_Compiler.cpp b/src/hotspot/share/c1/c1_Compiler.cpp index e1c4e90d063..a0944c864e6 100644 --- a/src/hotspot/share/c1/c1_Compiler.cpp +++ b/src/hotspot/share/c1/c1_Compiler.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -167,6 +167,9 @@ bool Compiler::is_intrinsic_supported(vmIntrinsics::ID id) { case vmIntrinsics::_dsin: case vmIntrinsics::_dcos: case vmIntrinsics::_dtan: + #if defined(AMD64) + case vmIntrinsics::_dtanh: + #endif case vmIntrinsics::_dlog: case vmIntrinsics::_dlog10: case vmIntrinsics::_dexp: diff --git a/src/hotspot/share/c1/c1_GraphBuilder.cpp b/src/hotspot/share/c1/c1_GraphBuilder.cpp index dc4475a4b81..02be6f8d49e 100644 --- a/src/hotspot/share/c1/c1_GraphBuilder.cpp +++ b/src/hotspot/share/c1/c1_GraphBuilder.cpp @@ -1389,6 +1389,11 @@ void GraphBuilder::jsr(int dest) { // If the bytecodes are strange (jumping out of a jsr block) then we // might end up trying to re-parse a block containing a jsr which // has already been activated. Watch for this case and bail out. + if (next_bci() >= method()->code_size()) { + // This can happen if the subroutine does not terminate with a ret, + // effectively turning the jsr into a goto. + BAILOUT("too-complicated jsr/ret structure"); + } for (ScopeData* cur_scope_data = scope_data(); cur_scope_data != nullptr && cur_scope_data->parsing_jsr() && cur_scope_data->scope() == scope(); cur_scope_data = cur_scope_data->parent()) { @@ -3334,6 +3339,7 @@ GraphBuilder::GraphBuilder(Compilation* compilation, IRScope* scope) case vmIntrinsics::_dsin : // fall through case vmIntrinsics::_dcos : // fall through case vmIntrinsics::_dtan : // fall through + case vmIntrinsics::_dtanh : // fall through case vmIntrinsics::_dlog : // fall through case vmIntrinsics::_dlog10 : // fall through case vmIntrinsics::_dexp : // fall through @@ -3736,6 +3742,9 @@ bool GraphBuilder::try_inline_intrinsics(ciMethod* callee, bool ignore_return) { bool GraphBuilder::try_inline_jsr(int jsr_dest_bci) { // Introduce a new callee continuation point - all Ret instructions // will be replaced with Gotos to this point. + if (next_bci() >= method()->code_size()) { + return false; + } BlockBegin* cont = block_at(next_bci()); assert(cont != nullptr, "continuation must exist (BlockListBuilder starts a new block after a jsr"); diff --git a/src/hotspot/share/c1/c1_LIR.hpp b/src/hotspot/share/c1/c1_LIR.hpp index 5d73ab5b88d..c568caeca4b 100644 --- a/src/hotspot/share/c1/c1_LIR.hpp +++ b/src/hotspot/share/c1/c1_LIR.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,6 +29,7 @@ #include "c1/c1_ValueType.hpp" #include "oops/method.hpp" #include "utilities/globalDefinitions.hpp" +#include "utilities/macros.hpp" class BlockBegin; class BlockList; @@ -1122,7 +1123,7 @@ class LIR_Op: public CompilationResourceObj { } #endif - virtual const char * name() const PRODUCT_RETURN0; + virtual const char * name() const PRODUCT_RETURN_NULL; virtual void visit(LIR_OpVisitState* state); int id() const { return _id; } @@ -1400,7 +1401,7 @@ class LIR_Op1: public LIR_Op { virtual bool is_patching() { return _patch != lir_patch_none; } virtual void emit_code(LIR_Assembler* masm); virtual LIR_Op1* as_Op1() { return this; } - virtual const char * name() const PRODUCT_RETURN0; + virtual const char * name() const PRODUCT_RETURN_NULL; void set_in_opr(LIR_Opr opr) { _opr = opr; } @@ -2033,8 +2034,9 @@ class LIR_OpProfileCall : public LIR_Op { virtual void print_instr(outputStream* out) const PRODUCT_RETURN; bool should_profile_receiver_type() const { bool callee_is_static = _profiled_callee->is_loaded() && _profiled_callee->is_static(); + bool callee_is_private = _profiled_callee->is_loaded() && _profiled_callee->is_private(); Bytecodes::Code bc = _profiled_method->java_code_at_bci(_profiled_bci); - bool call_is_virtual = (bc == Bytecodes::_invokevirtual && !_profiled_callee->can_be_statically_bound()) || bc == Bytecodes::_invokeinterface; + bool call_is_virtual = (bc == Bytecodes::_invokevirtual && !callee_is_private) || bc == Bytecodes::_invokeinterface; return C1ProfileVirtualCalls && call_is_virtual && !callee_is_static; } }; diff --git a/src/hotspot/share/c1/c1_LIRGenerator.cpp b/src/hotspot/share/c1/c1_LIRGenerator.cpp index 7b519804bfe..74fdf7a5b76 100644 --- a/src/hotspot/share/c1/c1_LIRGenerator.cpp +++ b/src/hotspot/share/c1/c1_LIRGenerator.cpp @@ -659,7 +659,7 @@ void LIRGenerator::new_instance(LIR_Opr dst, ciInstanceKlass* klass, bool is_unr if (UseFastNewInstance && klass->is_loaded() && !Klass::layout_helper_needs_slow_path(klass->layout_helper())) { - Runtime1::StubID stub_id = klass->is_initialized() ? Runtime1::fast_new_instance_id : Runtime1::fast_new_instance_init_check_id; + C1StubId stub_id = klass->is_initialized() ? C1StubId::fast_new_instance_id : C1StubId::fast_new_instance_init_check_id; CodeStub* slow_path = new NewInstanceStub(klass_reg, dst, klass, info, stub_id); @@ -670,7 +670,7 @@ void LIRGenerator::new_instance(LIR_Opr dst, ciInstanceKlass* klass, bool is_unr __ allocate_object(dst, scratch1, scratch2, scratch3, scratch4, oopDesc::header_size(), instance_size, klass_reg, !klass->is_initialized(), slow_path); } else { - CodeStub* slow_path = new NewInstanceStub(klass_reg, dst, klass, info, Runtime1::new_instance_id); + CodeStub* slow_path = new NewInstanceStub(klass_reg, dst, klass, info, C1StubId::new_instance_id); __ branch(lir_cond_always, slow_path); __ branch_destination(slow_path->continuation()); } @@ -1479,7 +1479,7 @@ void LIRGenerator::do_RegisterFinalizer(Intrinsic* x) { args->append(receiver.result()); CodeEmitInfo* info = state_for(x, x->state()); call_runtime(&signature, args, - CAST_FROM_FN_PTR(address, Runtime1::entry_for(Runtime1::register_finalizer_id)), + CAST_FROM_FN_PTR(address, Runtime1::entry_for(C1StubId::register_finalizer_id)), voidType, info); set_no_result(x); @@ -2971,6 +2971,7 @@ void LIRGenerator::do_Intrinsic(Intrinsic* x) { case vmIntrinsics::_dsqrt: // fall through case vmIntrinsics::_dsqrt_strict: // fall through case vmIntrinsics::_dtan: // fall through + case vmIntrinsics::_dtanh: // fall through case vmIntrinsics::_dsin : // fall through case vmIntrinsics::_dcos : // fall through case vmIntrinsics::_dexp : // fall through diff --git a/src/hotspot/share/c1/c1_Runtime1.cpp b/src/hotspot/share/c1/c1_Runtime1.cpp index 8524f37177b..915f00f77c5 100644 --- a/src/hotspot/share/c1/c1_Runtime1.cpp +++ b/src/hotspot/share/c1/c1_Runtime1.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -109,10 +109,13 @@ void StubAssembler::set_num_rt_args(int args) { // Implementation of Runtime1 -CodeBlob* Runtime1::_blobs[Runtime1::number_of_ids]; +CodeBlob* Runtime1::_blobs[(int)C1StubId::NUM_STUBIDS]; + +#define C1_BLOB_NAME_DEFINE(name) "C1 Runtime " # name "_blob", const char *Runtime1::_blob_names[] = { - RUNTIME1_STUBS(STUB_NAME, LAST_STUB_NAME) + C1_STUBS_DO(C1_BLOB_NAME_DEFINE) }; +#undef C1_STUB_NAME_DEFINE #ifndef PRODUCT // statistics @@ -190,17 +193,17 @@ static void deopt_caller(JavaThread* current) { } } -class StubIDStubAssemblerCodeGenClosure: public StubAssemblerCodeGenClosure { +class C1StubIdStubAssemblerCodeGenClosure: public StubAssemblerCodeGenClosure { private: - Runtime1::StubID _id; + C1StubId _id; public: - StubIDStubAssemblerCodeGenClosure(Runtime1::StubID id) : _id(id) {} + C1StubIdStubAssemblerCodeGenClosure(C1StubId id) : _id(id) {} virtual OopMapSet* generate_code(StubAssembler* sasm) { return Runtime1::generate_code_for(_id, sasm); } }; -CodeBlob* Runtime1::generate_blob(BufferBlob* buffer_blob, int stub_id, const char* name, bool expect_oop_map, StubAssemblerCodeGenClosure* cl) { +CodeBlob* Runtime1::generate_blob(BufferBlob* buffer_blob, C1StubId id, const char* name, bool expect_oop_map, StubAssemblerCodeGenClosure* cl) { ResourceMark rm; // create code buffer for code storage CodeBuffer code(buffer_blob); @@ -212,7 +215,7 @@ CodeBlob* Runtime1::generate_blob(BufferBlob* buffer_blob, int stub_id, const ch Compilation::setup_code_buffer(&code, 0); // create assembler for code generation - StubAssembler* sasm = new StubAssembler(&code, name, stub_id); + StubAssembler* sasm = new StubAssembler(&code, name, (int)id); // generate code for runtime stub oop_maps = cl->generate_code(sasm); assert(oop_maps == nullptr || sasm->frame_size() != no_frame_size, @@ -237,40 +240,41 @@ CodeBlob* Runtime1::generate_blob(BufferBlob* buffer_blob, int stub_id, const ch return blob; } -void Runtime1::generate_blob_for(BufferBlob* buffer_blob, StubID id) { - assert(0 <= id && id < number_of_ids, "illegal stub id"); +void Runtime1::generate_blob_for(BufferBlob* buffer_blob, C1StubId id) { + assert(C1StubId::NO_STUBID < id && id < C1StubId::NUM_STUBIDS, "illegal stub id"); bool expect_oop_map = true; #ifdef ASSERT // Make sure that stubs that need oopmaps have them switch (id) { // These stubs don't need to have an oopmap - case dtrace_object_alloc_id: - case slow_subtype_check_id: - case fpu2long_stub_id: - case unwind_exception_id: - case counter_overflow_id: + case C1StubId::dtrace_object_alloc_id: + case C1StubId::slow_subtype_check_id: + case C1StubId::fpu2long_stub_id: + case C1StubId::unwind_exception_id: + case C1StubId::counter_overflow_id: expect_oop_map = false; break; default: break; } #endif - StubIDStubAssemblerCodeGenClosure cl(id); + C1StubIdStubAssemblerCodeGenClosure cl(id); CodeBlob* blob = generate_blob(buffer_blob, id, name_for(id), expect_oop_map, &cl); // install blob - _blobs[id] = blob; + _blobs[(int)id] = blob; } void Runtime1::initialize(BufferBlob* blob) { // platform-dependent initialization initialize_pd(); // generate stubs - for (int id = 0; id < number_of_ids; id++) generate_blob_for(blob, (StubID)id); + int limit = (int)C1StubId::NUM_STUBIDS; + for (int id = 0; id < limit; id++) generate_blob_for(blob, (C1StubId)id); // printing #ifndef PRODUCT if (PrintSimpleStubs) { ResourceMark rm; - for (int id = 0; id < number_of_ids; id++) { + for (int id = 0; id < limit; id++) { _blobs[id]->print(); if (_blobs[id]->oop_maps() != nullptr) { _blobs[id]->oop_maps()->print(); @@ -282,20 +286,22 @@ void Runtime1::initialize(BufferBlob* blob) { bs->generate_c1_runtime_stubs(blob); } -CodeBlob* Runtime1::blob_for(StubID id) { - assert(0 <= id && id < number_of_ids, "illegal stub id"); - return _blobs[id]; +CodeBlob* Runtime1::blob_for(C1StubId id) { + assert(C1StubId::NO_STUBID < id && id < C1StubId::NUM_STUBIDS, "illegal stub id"); + return _blobs[(int)id]; } -const char* Runtime1::name_for(StubID id) { - assert(0 <= id && id < number_of_ids, "illegal stub id"); - return _blob_names[id]; +const char* Runtime1::name_for(C1StubId id) { + assert(C1StubId::NO_STUBID < id && id < C1StubId::NUM_STUBIDS, "illegal stub id"); + return _blob_names[(int)id]; } const char* Runtime1::name_for_address(address entry) { - for (int id = 0; id < number_of_ids; id++) { - if (entry == entry_for((StubID)id)) return name_for((StubID)id); + int limit = (int)C1StubId::NUM_STUBIDS; + for (int i = 0; i < limit; i++) { + C1StubId id = (C1StubId)i; + if (entry == entry_for(id)) return name_for(id); } #define FUNCTION_CASE(a, f) \ @@ -341,6 +347,7 @@ const char* Runtime1::name_for_address(address entry) { FUNCTION_CASE(entry, StubRoutines::dsin()); FUNCTION_CASE(entry, StubRoutines::dcos()); FUNCTION_CASE(entry, StubRoutines::dtan()); + FUNCTION_CASE(entry, StubRoutines::dtanh()); #undef FUNCTION_CASE @@ -425,8 +432,8 @@ JRT_ENTRY(void, Runtime1::new_multi_array(JavaThread* current, Klass* klass, int JRT_END -JRT_ENTRY(void, Runtime1::unimplemented_entry(JavaThread* current, StubID id)) - tty->print_cr("Runtime1::entry_for(%d) returned unimplemented entry point", id); +JRT_ENTRY(void, Runtime1::unimplemented_entry(JavaThread* current, C1StubId id)) + tty->print_cr("Runtime1::entry_for(%d) returned unimplemented entry point", (int)id); JRT_END @@ -525,8 +532,8 @@ JRT_ENTRY_NO_ASYNC(static address, exception_handler_for_pc_helper(JavaThread* c // This function is called when we are about to throw an exception. Therefore, // we have to poll the stack watermark barrier to make sure that not yet safe // stack frames are made safe before returning into them. - if (current->last_frame().cb() == Runtime1::blob_for(Runtime1::handle_exception_from_callee_id)) { - // The Runtime1::handle_exception_from_callee_id handler is invoked after the + if (current->last_frame().cb() == Runtime1::blob_for(C1StubId::handle_exception_from_callee_id)) { + // The C1StubId::handle_exception_from_callee_id handler is invoked after the // frame has been unwound. It instead builds its own stub frame, to call the // runtime. But the throwing frame has already been unwound here. StackWatermarkSet::after_unwind(current); @@ -922,7 +929,7 @@ static Klass* resolve_field_return_klass(const methodHandle& caller, int bci, TR // Therefore, if there is any chance of a race condition, we try to // patch only naturally aligned words, as single, full-word writes. -JRT_ENTRY(void, Runtime1::patch_code(JavaThread* current, Runtime1::StubID stub_id )) +JRT_ENTRY(void, Runtime1::patch_code(JavaThread* current, C1StubId stub_id )) #ifndef PRODUCT if (PrintC1Statistics) { _patch_code_slowcase_cnt++; @@ -959,9 +966,9 @@ JRT_ENTRY(void, Runtime1::patch_code(JavaThread* current, Runtime1::StubID stub_ Handle mirror(current, nullptr); // oop needed by load_mirror_patching code Handle appendix(current, nullptr); // oop needed by appendix_patching code bool load_klass_or_mirror_patch_id = - (stub_id == Runtime1::load_klass_patching_id || stub_id == Runtime1::load_mirror_patching_id); + (stub_id == C1StubId::load_klass_patching_id || stub_id == C1StubId::load_mirror_patching_id); - if (stub_id == Runtime1::access_field_patching_id) { + if (stub_id == C1StubId::access_field_patching_id) { Bytecode_field field_access(caller_method, bci); fieldDescriptor result; // initialize class if needed @@ -1044,7 +1051,7 @@ JRT_ENTRY(void, Runtime1::patch_code(JavaThread* current, Runtime1::StubID stub_ default: fatal("unexpected bytecode for load_klass_or_mirror_patch_id"); } load_klass = k; - } else if (stub_id == load_appendix_patching_id) { + } else if (stub_id == C1StubId::load_appendix_patching_id) { Bytecode_invoke bytecode(caller_method, bci); Bytecodes::Code bc = bytecode.invoke_code(); @@ -1128,7 +1135,7 @@ JRT_ENTRY(void, Runtime1::patch_code(JavaThread* current, Runtime1::StubID stub_ if (TracePatching) { ttyLocker ttyl; tty->print_cr(" Patching %s at bci %d at address " INTPTR_FORMAT " (%s)", Bytecodes::name(code), bci, - p2i(instr_pc), (stub_id == Runtime1::access_field_patching_id) ? "field" : "klass"); + p2i(instr_pc), (stub_id == C1StubId::access_field_patching_id) ? "field" : "klass"); nmethod* caller_code = CodeCache::find_nmethod(caller_frame.pc()); assert(caller_code != nullptr, "nmethod not found"); @@ -1144,7 +1151,7 @@ JRT_ENTRY(void, Runtime1::patch_code(JavaThread* current, Runtime1::StubID stub_ } // depending on the code below, do_patch says whether to copy the patch body back into the nmethod bool do_patch = true; - if (stub_id == Runtime1::access_field_patching_id) { + if (stub_id == C1StubId::access_field_patching_id) { // The offset may not be correct if the class was not loaded at code generation time. // Set it now. NativeMovRegMem* n_move = nativeMovRegMem_at(copy_buff); @@ -1170,7 +1177,7 @@ JRT_ENTRY(void, Runtime1::patch_code(JavaThread* current, Runtime1::StubID stub_ assert(n_copy->data() == 0 || n_copy->data() == (intptr_t)Universe::non_oop_word(), "illegal init value"); - if (stub_id == Runtime1::load_klass_patching_id) { + if (stub_id == C1StubId::load_klass_patching_id) { assert(load_klass != nullptr, "klass not set"); n_copy->set_data((intx) (load_klass)); } else { @@ -1182,7 +1189,7 @@ JRT_ENTRY(void, Runtime1::patch_code(JavaThread* current, Runtime1::StubID stub_ Disassembler::decode(copy_buff, copy_buff + *byte_count, tty); } } - } else if (stub_id == Runtime1::load_appendix_patching_id) { + } else if (stub_id == C1StubId::load_appendix_patching_id) { NativeMovConstReg* n_copy = nativeMovConstReg_at(copy_buff); assert(n_copy->data() == 0 || n_copy->data() == (intptr_t)Universe::non_oop_word(), @@ -1201,7 +1208,7 @@ JRT_ENTRY(void, Runtime1::patch_code(JavaThread* current, Runtime1::StubID stub_ // first replace the tail, then the call #ifdef ARM if((load_klass_or_mirror_patch_id || - stub_id == Runtime1::load_appendix_patching_id) && + stub_id == C1StubId::load_appendix_patching_id) && nativeMovConstReg_at(copy_buff)->is_pc_relative()) { nmethod* nm = CodeCache::find_nmethod(instr_pc); address addr = nullptr; @@ -1209,13 +1216,13 @@ JRT_ENTRY(void, Runtime1::patch_code(JavaThread* current, Runtime1::StubID stub_ RelocIterator mds(nm, copy_buff, copy_buff + 1); while (mds.next()) { if (mds.type() == relocInfo::oop_type) { - assert(stub_id == Runtime1::load_mirror_patching_id || - stub_id == Runtime1::load_appendix_patching_id, "wrong stub id"); + assert(stub_id == C1StubId::load_mirror_patching_id || + stub_id == C1StubId::load_appendix_patching_id, "wrong stub id"); oop_Relocation* r = mds.oop_reloc(); addr = (address)r->oop_addr(); break; } else if (mds.type() == relocInfo::metadata_type) { - assert(stub_id == Runtime1::load_klass_patching_id, "wrong stub id"); + assert(stub_id == C1StubId::load_klass_patching_id, "wrong stub id"); metadata_Relocation* r = mds.metadata_reloc(); addr = (address)r->metadata_addr(); break; @@ -1238,9 +1245,9 @@ JRT_ENTRY(void, Runtime1::patch_code(JavaThread* current, Runtime1::StubID stub_ NativeGeneralJump::replace_mt_safe(instr_pc, copy_buff); if (load_klass_or_mirror_patch_id || - stub_id == Runtime1::load_appendix_patching_id) { + stub_id == C1StubId::load_appendix_patching_id) { relocInfo::relocType rtype = - (stub_id == Runtime1::load_klass_patching_id) ? + (stub_id == C1StubId::load_klass_patching_id) ? relocInfo::metadata_type : relocInfo::oop_type; // update relocInfo to metadata @@ -1278,9 +1285,9 @@ JRT_END #else // DEOPTIMIZE_WHEN_PATCHING -static bool is_patching_needed(JavaThread* current, Runtime1::StubID stub_id) { - if (stub_id == Runtime1::load_klass_patching_id || - stub_id == Runtime1::load_mirror_patching_id) { +static bool is_patching_needed(JavaThread* current, C1StubId stub_id) { + if (stub_id == C1StubId::load_klass_patching_id || + stub_id == C1StubId::load_mirror_patching_id) { // last java frame on stack vframeStream vfst(current, true); assert(!vfst.at_end(), "Java frame must exist"); @@ -1309,7 +1316,7 @@ static bool is_patching_needed(JavaThread* current, Runtime1::StubID stub_id) { return true; } -void Runtime1::patch_code(JavaThread* current, Runtime1::StubID stub_id) { +void Runtime1::patch_code(JavaThread* current, C1StubId stub_id) { #ifndef PRODUCT if (PrintC1Statistics) { _patch_code_slowcase_cnt++; @@ -1364,7 +1371,7 @@ int Runtime1::move_klass_patching(JavaThread* current) { { // Enter VM mode ResetNoHandleMark rnhm; - patch_code(current, load_klass_patching_id); + patch_code(current, C1StubId::load_klass_patching_id); } // Back in JAVA, use no oops DON'T safepoint @@ -1381,7 +1388,7 @@ int Runtime1::move_mirror_patching(JavaThread* current) { { // Enter VM mode ResetNoHandleMark rnhm; - patch_code(current, load_mirror_patching_id); + patch_code(current, C1StubId::load_mirror_patching_id); } // Back in JAVA, use no oops DON'T safepoint @@ -1398,7 +1405,7 @@ int Runtime1::move_appendix_patching(JavaThread* current) { { // Enter VM mode ResetNoHandleMark rnhm; - patch_code(current, load_appendix_patching_id); + patch_code(current, C1StubId::load_appendix_patching_id); } // Back in JAVA, use no oops DON'T safepoint @@ -1425,7 +1432,7 @@ int Runtime1::access_field_patching(JavaThread* current) { { // Enter VM mode ResetNoHandleMark rnhm; - patch_code(current, access_field_patching_id); + patch_code(current, C1StubId::access_field_patching_id); } // Back in JAVA, use no oops DON'T safepoint diff --git a/src/hotspot/share/c1/c1_Runtime1.hpp b/src/hotspot/share/c1/c1_Runtime1.hpp index 2e4c9f8a733..330c4067504 100644 --- a/src/hotspot/share/c1/c1_Runtime1.hpp +++ b/src/hotspot/share/c1/c1_Runtime1.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,6 +30,7 @@ #include "interpreter/interpreter.hpp" #include "memory/allStatic.hpp" #include "runtime/deoptimization.hpp" +#include "runtime/stubDeclarations.hpp" class StubAssembler; @@ -37,61 +38,26 @@ class StubAssembler; // runtime routines needed by code code generated // by the Compiler1. -#define RUNTIME1_STUBS(stub, last_entry) \ - stub(dtrace_object_alloc) \ - stub(unwind_exception) \ - stub(forward_exception) \ - stub(throw_range_check_failed) /* throws ArrayIndexOutOfBoundsException */ \ - stub(throw_index_exception) /* throws IndexOutOfBoundsException */ \ - stub(throw_div0_exception) \ - stub(throw_null_pointer_exception) \ - stub(register_finalizer) \ - stub(new_instance) \ - stub(fast_new_instance) \ - stub(fast_new_instance_init_check) \ - stub(new_type_array) \ - stub(new_object_array) \ - stub(new_multi_array) \ - stub(handle_exception_nofpu) /* optimized version that does not preserve fpu registers */ \ - stub(handle_exception) \ - stub(handle_exception_from_callee) \ - stub(throw_array_store_exception) \ - stub(throw_class_cast_exception) \ - stub(throw_incompatible_class_change_error) \ - stub(slow_subtype_check) \ - stub(monitorenter) \ - stub(monitorenter_nofpu) /* optimized version that does not preserve fpu registers */ \ - stub(monitorexit) \ - stub(monitorexit_nofpu) /* optimized version that does not preserve fpu registers */ \ - stub(deoptimize) \ - stub(access_field_patching) \ - stub(load_klass_patching) \ - stub(load_mirror_patching) \ - stub(load_appendix_patching) \ - stub(fpu2long_stub) \ - stub(counter_overflow) \ - stub(predicate_failed_trap) \ - last_entry(number_of_ids) - -#define DECLARE_STUB_ID(x) x ## _id , -#define DECLARE_LAST_STUB_ID(x) x -#define STUB_NAME(x) #x " Runtime1 stub", -#define LAST_STUB_NAME(x) #x " Runtime1 stub" - class StubAssemblerCodeGenClosure: public Closure { public: virtual OopMapSet* generate_code(StubAssembler* sasm) = 0; }; +// define C1StubId enum tags: unwind_exception_id etc + +#define C1_STUB_ID_ENUM_DECLARE(name) STUB_ID_NAME(name), +enum class C1StubId :int { + NO_STUBID = -1, + C1_STUBS_DO(C1_STUB_ID_ENUM_DECLARE) + NUM_STUBIDS +}; +#undef C1_STUB_ID_ENUM_DECLARE + class Runtime1: public AllStatic { friend class VMStructs; friend class ArrayCopyStub; - public: - enum StubID { - RUNTIME1_STUBS(DECLARE_STUB_ID, DECLARE_LAST_STUB_ID) - }; - +public: // statistics #ifndef PRODUCT static uint _generic_arraycopystub_cnt; @@ -115,17 +81,17 @@ class Runtime1: public AllStatic { #endif private: - static CodeBlob* _blobs[number_of_ids]; + static CodeBlob* _blobs[(int)C1StubId::NUM_STUBIDS]; static const char* _blob_names[]; // stub generation public: - static CodeBlob* generate_blob(BufferBlob* buffer_blob, int stub_id, const char* name, bool expect_oop_map, StubAssemblerCodeGenClosure *cl); - static void generate_blob_for(BufferBlob* blob, StubID id); - static OopMapSet* generate_code_for(StubID id, StubAssembler* sasm); + static CodeBlob* generate_blob(BufferBlob* buffer_blob, C1StubId id, const char* name, bool expect_oop_map, StubAssemblerCodeGenClosure *cl); + static void generate_blob_for(BufferBlob* blob, C1StubId id); + static OopMapSet* generate_code_for(C1StubId id, StubAssembler* sasm); private: static OopMapSet* generate_exception_throw(StubAssembler* sasm, address target, bool has_argument); - static OopMapSet* generate_handle_exception(StubID id, StubAssembler* sasm); + static OopMapSet* generate_handle_exception(C1StubId id, StubAssembler* sasm); static void generate_unwind_exception(StubAssembler *sasm); static OopMapSet* generate_patching(StubAssembler* sasm, address target); @@ -140,7 +106,7 @@ class Runtime1: public AllStatic { static address counter_overflow(JavaThread* current, int bci, Method* method); - static void unimplemented_entry(JavaThread* current, StubID id); + static void unimplemented_entry(JavaThread* current, C1StubId id); static address exception_handler_for_pc(JavaThread* current); @@ -162,7 +128,7 @@ class Runtime1: public AllStatic { static int move_mirror_patching(JavaThread* current); static int move_appendix_patching(JavaThread* current); - static void patch_code(JavaThread* current, StubID stub_id); + static void patch_code(JavaThread* current, C1StubId stub_id); public: // initialization @@ -170,9 +136,9 @@ class Runtime1: public AllStatic { static void initialize_pd(); // stubs - static CodeBlob* blob_for (StubID id); - static address entry_for(StubID id) { return blob_for(id)->code_begin(); } - static const char* name_for (StubID id); + static CodeBlob* blob_for (C1StubId id); + static address entry_for(C1StubId id) { return blob_for(id)->code_begin(); } + static const char* name_for (C1StubId id); static const char* name_for_address(address entry); // platform might add runtime names. diff --git a/src/hotspot/share/cds/archiveBuilder.cpp b/src/hotspot/share/cds/archiveBuilder.cpp index 76b6698a400..3c67216d4c5 100644 --- a/src/hotspot/share/cds/archiveBuilder.cpp +++ b/src/hotspot/share/cds/archiveBuilder.cpp @@ -1104,6 +1104,17 @@ class ArchiveBuilder::CDSMapLogger : AllStatic { LogStreamHandle(Info, cds, map) st; + HeapRootSegments segments = heap_info->heap_root_segments(); + assert(segments.base_offset() == 0, "Sanity"); + + for (size_t seg_idx = 0; seg_idx < segments.count(); seg_idx++) { + address requested_start = ArchiveHeapWriter::buffered_addr_to_requested_addr(start); + st.print_cr(PTR_FORMAT ": Heap roots segment [%d]", + p2i(requested_start), segments.size_in_elems(seg_idx)); + start += segments.size_in_bytes(seg_idx); + } + log_heap_roots(); + while (start < end) { size_t byte_size; oop source_oop = ArchiveHeapWriter::buffered_addr_to_source_obj(start); @@ -1114,12 +1125,6 @@ class ArchiveBuilder::CDSMapLogger : AllStatic { // This is a regular oop that got archived. print_oop_with_requested_addr_cr(&st, source_oop, false); byte_size = source_oop->size() * BytesPerWord; - } else if (start == ArchiveHeapWriter::buffered_heap_roots_addr()) { - // HeapShared::roots() is copied specially, so it doesn't exist in - // ArchiveHeapWriter::BufferOffsetToSourceObjectTable. - // See ArchiveHeapWriter::copy_roots_to_buffer(). - st.print_cr("HeapShared::roots[%d]", HeapShared::pending_roots()->length()); - byte_size = ArchiveHeapWriter::heap_roots_word_size() * BytesPerWord; } else if ((byte_size = ArchiveHeapWriter::get_filler_size_at(start)) > 0) { // We have a filler oop, which also does not exist in BufferOffsetToSourceObjectTable. st.print_cr("filler " SIZE_FORMAT " bytes", byte_size); @@ -1132,8 +1137,6 @@ class ArchiveBuilder::CDSMapLogger : AllStatic { if (source_oop != nullptr) { log_oop_details(heap_info, source_oop, /*buffered_addr=*/start); - } else if (start == ArchiveHeapWriter::buffered_heap_roots_addr()) { - log_heap_roots(); } start = oop_end; } diff --git a/src/hotspot/share/cds/archiveHeapLoader.cpp b/src/hotspot/share/cds/archiveHeapLoader.cpp index feaf245d22c..0e7ef08064c 100644 --- a/src/hotspot/share/cds/archiveHeapLoader.cpp +++ b/src/hotspot/share/cds/archiveHeapLoader.cpp @@ -374,8 +374,17 @@ void ArchiveHeapLoader::finish_initialization() { if (is_in_use()) { patch_native_pointers(); intptr_t bottom = is_loaded() ? _loaded_heap_bottom : _mapped_heap_bottom; - intptr_t roots_oop = bottom + FileMapInfo::current_info()->heap_roots_offset(); - HeapShared::init_roots(cast_to_oop(roots_oop)); + + // The heap roots are stored in one or more segments that are laid out consecutively. + // The size of each segment (except for the last one) is max_size_in_{elems,bytes}. + HeapRootSegments segments = FileMapInfo::current_info()->heap_root_segments(); + HeapShared::init_root_segment_sizes(segments.max_size_in_elems()); + intptr_t first_segment_addr = bottom + segments.base_offset(); + for (size_t c = 0; c < segments.count(); c++) { + oop segment_oop = cast_to_oop(first_segment_addr + (c * segments.max_size_in_bytes())); + assert(segment_oop->is_objArray(), "Must be"); + HeapShared::add_root_segment((objArrayOop)segment_oop); + } } } diff --git a/src/hotspot/share/cds/archiveHeapWriter.cpp b/src/hotspot/share/cds/archiveHeapWriter.cpp index bf49805658c..710e693bfdb 100644 --- a/src/hotspot/share/cds/archiveHeapWriter.cpp +++ b/src/hotspot/share/cds/archiveHeapWriter.cpp @@ -52,9 +52,9 @@ GrowableArrayCHeap* ArchiveHeapWriter::_buffer = nullptr; // The following are offsets from buffer_bottom() size_t ArchiveHeapWriter::_buffer_used; -size_t ArchiveHeapWriter::_heap_roots_offset; -size_t ArchiveHeapWriter::_heap_roots_word_size; +// Heap root segments +HeapRootSegments ArchiveHeapWriter::_heap_root_segments; address ArchiveHeapWriter::_requested_bottom; address ArchiveHeapWriter::_requested_top; @@ -88,7 +88,6 @@ void ArchiveHeapWriter::init() { _native_pointers = new GrowableArrayCHeap(2048); _source_objs = new GrowableArrayCHeap(10000); - guarantee(UseG1GC, "implementation limitation"); guarantee(MIN_GC_REGION_ALIGNMENT <= G1HeapRegion::min_region_size_in_words() * HeapWordSize, "must be"); } } @@ -164,10 +163,6 @@ address ArchiveHeapWriter::buffered_addr_to_requested_addr(address buffered_addr return _requested_bottom + buffered_address_to_offset(buffered_addr); } -oop ArchiveHeapWriter::heap_roots_requested_address() { - return cast_to_oop(_requested_bottom + _heap_roots_offset); -} - address ArchiveHeapWriter::requested_address() { assert(_buffer != nullptr, "must be initialized"); return _requested_bottom; @@ -186,54 +181,85 @@ void ArchiveHeapWriter::ensure_buffer_space(size_t min_bytes) { _buffer->at_grow(to_array_index(min_bytes)); } -void ArchiveHeapWriter::copy_roots_to_buffer(GrowableArrayCHeap* roots) { - Klass* k = Universe::objectArrayKlass(); // already relocated to point to archived klass - int length = roots->length(); - _heap_roots_word_size = objArrayOopDesc::object_size(length); - size_t byte_size = _heap_roots_word_size * HeapWordSize; - if (byte_size >= MIN_GC_REGION_ALIGNMENT) { - log_error(cds, heap)("roots array is too large. Please reduce the number of classes"); - vm_exit(1); - } +objArrayOop ArchiveHeapWriter::allocate_root_segment(size_t offset, int element_count) { + HeapWord* mem = offset_to_buffered_address(offset); + memset(mem, 0, objArrayOopDesc::object_size(element_count)); - maybe_fill_gc_region_gap(byte_size); - - size_t new_used = _buffer_used + byte_size; - ensure_buffer_space(new_used); - - HeapWord* mem = offset_to_buffered_address(_buffer_used); - memset(mem, 0, byte_size); - { - // This is copied from MemAllocator::finish - oopDesc::set_mark(mem, markWord::prototype()); - oopDesc::release_set_klass(mem, k); - } - { - // This is copied from ObjArrayAllocator::initialize - arrayOopDesc::set_length(mem, length); - } - - objArrayOop arrayOop = objArrayOop(cast_to_oop(mem)); - for (int i = 0; i < length; i++) { - // Do not use arrayOop->obj_at_put(i, o) as arrayOop is outside of the real heap! - oop o = roots->at(i); - if (UseCompressedOops) { - * arrayOop->obj_at_addr(i) = CompressedOops::encode(o); - } else { - * arrayOop->obj_at_addr(i) = o; - } - } - log_info(cds, heap)("archived obj roots[%d] = " SIZE_FORMAT " bytes, klass = %p, obj = %p", length, byte_size, k, mem); - - _heap_roots_offset = _buffer_used; - _buffer_used = new_used; + // The initialization code is copied from MemAllocator::finish and ObjArrayAllocator::initialize. + oopDesc::set_mark(mem, markWord::prototype()); + oopDesc::release_set_klass(mem, Universe::objectArrayKlass()); + arrayOopDesc::set_length(mem, element_count); + return objArrayOop(cast_to_oop(mem)); } +void ArchiveHeapWriter::root_segment_at_put(objArrayOop segment, int index, oop root) { + // Do not use arrayOop->obj_at_put(i, o) as arrayOop is outside the real heap! + if (UseCompressedOops) { + *segment->obj_at_addr(index) = CompressedOops::encode(root); + } else { + *segment->obj_at_addr(index) = root; + } +} + +void ArchiveHeapWriter::copy_roots_to_buffer(GrowableArrayCHeap* roots) { + // Depending on the number of classes we are archiving, a single roots array may be + // larger than MIN_GC_REGION_ALIGNMENT. Roots are allocated first in the buffer, which + // allows us to chop the large array into a series of "segments". Current layout + // starts with zero or more segments exactly fitting MIN_GC_REGION_ALIGNMENT, and end + // with a single segment that may be smaller than MIN_GC_REGION_ALIGNMENT. + // This is simple and efficient. We do not need filler objects anywhere between the segments, + // or immediately after the last segment. This allows starting the object dump immediately + // after the roots. + + assert((_buffer_used % MIN_GC_REGION_ALIGNMENT) == 0, + "Pre-condition: Roots start at aligned boundary: " SIZE_FORMAT, _buffer_used); + + int max_elem_count = ((MIN_GC_REGION_ALIGNMENT - arrayOopDesc::header_size_in_bytes()) / heapOopSize); + assert(objArrayOopDesc::object_size(max_elem_count)*HeapWordSize == MIN_GC_REGION_ALIGNMENT, + "Should match exactly"); + + HeapRootSegments segments(_buffer_used, + roots->length(), + MIN_GC_REGION_ALIGNMENT, + max_elem_count); + + int root_index = 0; + for (size_t seg_idx = 0; seg_idx < segments.count(); seg_idx++) { + int size_elems = segments.size_in_elems(seg_idx); + size_t size_bytes = segments.size_in_bytes(seg_idx); + + size_t oop_offset = _buffer_used; + _buffer_used = oop_offset + size_bytes; + ensure_buffer_space(_buffer_used); + + assert((oop_offset % MIN_GC_REGION_ALIGNMENT) == 0, + "Roots segment " SIZE_FORMAT " start is not aligned: " SIZE_FORMAT, + segments.count(), oop_offset); + + objArrayOop seg_oop = allocate_root_segment(oop_offset, size_elems); + for (int i = 0; i < size_elems; i++) { + root_segment_at_put(seg_oop, i, roots->at(root_index++)); + } + + log_info(cds, heap)("archived obj root segment [%d] = " SIZE_FORMAT " bytes, obj = " PTR_FORMAT, + size_elems, size_bytes, p2i(seg_oop)); + } + + assert(root_index == roots->length(), "Post-condition: All roots are handled"); + + _heap_root_segments = segments; +} + +// The goal is to sort the objects in increasing order of: +// - objects that have only oop pointers +// - objects that have both native and oop pointers +// - objects that have only native pointers +// - objects that have no pointers static int oop_sorting_rank(oop o) { bool has_oop_ptr, has_native_ptr; HeapShared::get_pointer_info(o, has_oop_ptr, has_native_ptr); - if (!has_oop_ptr) { + if (has_oop_ptr) { if (!has_native_ptr) { return 0; } else { @@ -248,11 +274,6 @@ static int oop_sorting_rank(oop o) { } } -// The goal is to sort the objects in increasing order of: -// - objects that have no pointers -// - objects that have only native pointers -// - objects that have both native and oop pointers -// - objects that have only oop pointers int ArchiveHeapWriter::compare_objs_by_oop_fields(HeapObjOrder* a, HeapObjOrder* b) { int rank_a = a->_rank; int rank_b = b->_rank; @@ -282,6 +303,10 @@ void ArchiveHeapWriter::sort_source_objs() { } void ArchiveHeapWriter::copy_source_objs_to_buffer(GrowableArrayCHeap* roots) { + // There could be multiple root segments, which we want to be aligned by region. + // Putting them ahead of objects makes sure we waste no space. + copy_roots_to_buffer(roots); + sort_source_objs(); for (int i = 0; i < _source_objs_order->length(); i++) { int src_obj_index = _source_objs_order->at(i)._index; @@ -295,8 +320,6 @@ void ArchiveHeapWriter::copy_source_objs_to_buffer(GrowableArrayCHeapmaybe_grow(); } - copy_roots_to_buffer(roots); - log_info(cds)("Size of heap region = " SIZE_FORMAT " bytes, %d objects, %d roots, %d native ptrs", _buffer_used, _source_objs->length() + 1, roots->length(), _num_native_ptrs); } @@ -430,32 +453,36 @@ size_t ArchiveHeapWriter::copy_one_source_obj_to_buffer(oop src_obj) { void ArchiveHeapWriter::set_requested_address(ArchiveHeapInfo* info) { assert(!info->is_used(), "only set once"); - assert(UseG1GC, "must be"); - address heap_end = (address)G1CollectedHeap::heap()->reserved().end(); - log_info(cds, heap)("Heap end = %p", heap_end); size_t heap_region_byte_size = _buffer_used; assert(heap_region_byte_size > 0, "must archived at least one object!"); - if (UseCompressedOops) { - _requested_bottom = align_down(heap_end - heap_region_byte_size, G1HeapRegion::GrainBytes); + if (UseG1GC) { + address heap_end = (address)G1CollectedHeap::heap()->reserved().end(); + log_info(cds, heap)("Heap end = %p", heap_end); + _requested_bottom = align_down(heap_end - heap_region_byte_size, G1HeapRegion::GrainBytes); + _requested_bottom = align_down(_requested_bottom, MIN_GC_REGION_ALIGNMENT); + assert(is_aligned(_requested_bottom, G1HeapRegion::GrainBytes), "sanity"); + } else { + _requested_bottom = align_up(CompressedOops::begin(), MIN_GC_REGION_ALIGNMENT); + } } else { // We always write the objects as if the heap started at this address. This // makes the contents of the archive heap deterministic. // // Note that at runtime, the heap address is selected by the OS, so the archive // heap will not be mapped at 0x10000000, and the contents need to be patched. - _requested_bottom = (address)NOCOOPS_REQUESTED_BASE; + _requested_bottom = align_up((address)NOCOOPS_REQUESTED_BASE, MIN_GC_REGION_ALIGNMENT); } - assert(is_aligned(_requested_bottom, G1HeapRegion::GrainBytes), "sanity"); + assert(is_aligned(_requested_bottom, MIN_GC_REGION_ALIGNMENT), "sanity"); _requested_top = _requested_bottom + _buffer_used; info->set_buffer_region(MemRegion(offset_to_buffered_address(0), offset_to_buffered_address(_buffer_used))); - info->set_heap_roots_offset(_heap_roots_offset); + info->set_heap_root_segments(_heap_root_segments); } // Oop relocation @@ -543,12 +570,6 @@ void ArchiveHeapWriter::update_header_for_requested_obj(oop requested_obj, oop s } } -// Relocate an element in the buffered copy of HeapShared::roots() -template void ArchiveHeapWriter::relocate_root_at(oop requested_roots, int index, CHeapBitMap* oopmap) { - size_t offset = (size_t)((objArrayOop)requested_roots)->obj_at_offset(index); - relocate_field_in_buffer((T*)(buffered_heap_roots_addr() + offset), oopmap); -} - class ArchiveHeapWriter::EmbeddedOopRelocator: public BasicOopIterateClosure { oop _src_obj; address _buffered_obj; @@ -600,14 +621,24 @@ void ArchiveHeapWriter::relocate_embedded_oops(GrowableArrayCHeaplength() : 0; - for (int i = 0; i < length; i++) { + for (size_t seg_idx = 0; seg_idx < _heap_root_segments.count(); seg_idx++) { + size_t seg_offset = _heap_root_segments.segment_offset(seg_idx); + + objArrayOop requested_obj = (objArrayOop)requested_obj_from_buffer_offset(seg_offset); + update_header_for_requested_obj(requested_obj, nullptr, Universe::objectArrayKlass()); + address buffered_obj = offset_to_buffered_address
(seg_offset); + int length = _heap_root_segments.size_in_elems(seg_idx); + if (UseCompressedOops) { - relocate_root_at(requested_roots, i, heap_info->oopmap()); + for (int i = 0; i < length; i++) { + narrowOop* addr = (narrowOop*)(buffered_obj + objArrayOopDesc::obj_at_offset(i)); + relocate_field_in_buffer(addr, heap_info->oopmap()); + } } else { - relocate_root_at(requested_roots, i, heap_info->oopmap()); + for (int i = 0; i < length; i++) { + oop* addr = (oop*)(buffered_obj + objArrayOopDesc::obj_at_offset(i)); + relocate_field_in_buffer(addr, heap_info->oopmap()); + } } } diff --git a/src/hotspot/share/cds/archiveHeapWriter.hpp b/src/hotspot/share/cds/archiveHeapWriter.hpp index 352aeb9a08f..29ea50ba5fe 100644 --- a/src/hotspot/share/cds/archiveHeapWriter.hpp +++ b/src/hotspot/share/cds/archiveHeapWriter.hpp @@ -41,8 +41,7 @@ class ArchiveHeapInfo { MemRegion _buffer_region; // Contains the archived objects to be written into the CDS archive. CHeapBitMap _oopmap; CHeapBitMap _ptrmap; - size_t _heap_roots_offset; // Offset of the HeapShared::roots() object, from the bottom - // of the archived heap objects, in bytes. + HeapRootSegments _heap_root_segments; public: ArchiveHeapInfo() : _buffer_region(), _oopmap(128, mtClassShared), _ptrmap(128, mtClassShared) {} @@ -57,8 +56,8 @@ public: CHeapBitMap* oopmap() { return &_oopmap; } CHeapBitMap* ptrmap() { return &_ptrmap; } - void set_heap_roots_offset(size_t n) { _heap_roots_offset = n; } - size_t heap_roots_offset() const { return _heap_roots_offset; } + void set_heap_root_segments(HeapRootSegments segments) { _heap_root_segments = segments; }; + HeapRootSegments heap_root_segments() { return _heap_root_segments; } }; #if INCLUDE_CDS_JAVA_HEAP @@ -112,11 +111,10 @@ class ArchiveHeapWriter : AllStatic { public: static const intptr_t NOCOOPS_REQUESTED_BASE = 0x10000000; - // The minimum region size of all collectors that are supported by CDS in - // ArchiveHeapLoader::can_map() mode. Currently only G1 is supported. G1's region size - // depends on -Xmx, but can never be smaller than 1 * M. - // (TODO: Perhaps change to 256K to be compatible with Shenandoah) - static constexpr int MIN_GC_REGION_ALIGNMENT = 1 * M; + // The minimum region size of all collectors that are supported by CDS. + // G1 heap region size can never be smaller than 1M. + // Shenandoah heap region size can never be smaller than 256K. + static constexpr int MIN_GC_REGION_ALIGNMENT = 256 * K; private: class EmbeddedOopRelocator; @@ -130,9 +128,8 @@ private: // The number of bytes that have written into _buffer (may be smaller than _buffer->length()). static size_t _buffer_used; - // The bottom of the copy of Heap::roots() inside this->_buffer. - static size_t _heap_roots_offset; - static size_t _heap_roots_word_size; + // The heap root segments information. + static HeapRootSegments _heap_root_segments; // The address range of the requested location of the archived heap objects. static address _requested_bottom; @@ -193,6 +190,8 @@ private: return buffered_addr - buffer_bottom(); } + static void root_segment_at_put(objArrayOop segment, int index, oop root); + static objArrayOop allocate_root_segment(size_t offset, int element_count); static void copy_roots_to_buffer(GrowableArrayCHeap* roots); static void copy_source_objs_to_buffer(GrowableArrayCHeap* roots); static size_t copy_one_source_obj_to_buffer(oop src_obj); @@ -219,7 +218,6 @@ private: template static T* requested_addr_to_buffered_addr(T* p); template static void relocate_field_in_buffer(T* field_addr_in_buffer, CHeapBitMap* oopmap); template static void mark_oop_pointer(T* buffered_addr, CHeapBitMap* oopmap); - template static void relocate_root_at(oop requested_roots, int index, CHeapBitMap* oopmap); static void update_header_for_requested_obj(oop requested_obj, oop src_obj, Klass* src_klass); @@ -234,13 +232,6 @@ public: static bool is_string_too_large_to_archive(oop string); static void write(GrowableArrayCHeap*, ArchiveHeapInfo* heap_info); static address requested_address(); // requested address of the lowest achived heap object - static oop heap_roots_requested_address(); // requested address of HeapShared::roots() - static address buffered_heap_roots_addr() { - return offset_to_buffered_address
(_heap_roots_offset); - } - static size_t heap_roots_word_size() { - return _heap_roots_word_size; - } static size_t get_filler_size_at(address buffered_addr); static void mark_native_pointer(oop src_obj, int offset); diff --git a/src/hotspot/share/cds/archiveUtils.cpp b/src/hotspot/share/cds/archiveUtils.cpp index 76cfa441fa7..4622a27cbec 100644 --- a/src/hotspot/share/cds/archiveUtils.cpp +++ b/src/hotspot/share/cds/archiveUtils.cpp @@ -369,3 +369,24 @@ void ArchiveUtils::log_to_classlist(BootstrapInfo* bootstrap_specifier, TRAPS) { } } } + +size_t HeapRootSegments::size_in_bytes(size_t seg_idx) { + assert(seg_idx < _count, "In range"); + return objArrayOopDesc::object_size(size_in_elems(seg_idx)) * HeapWordSize; +} + +int HeapRootSegments::size_in_elems(size_t seg_idx) { + assert(seg_idx < _count, "In range"); + if (seg_idx != _count - 1) { + return _max_size_in_elems; + } else { + // Last slice, leftover + return _roots_count % _max_size_in_elems; + } +} + +size_t HeapRootSegments::segment_offset(size_t seg_idx) { + assert(seg_idx < _count, "In range"); + return _base_offset + seg_idx * _max_size_in_bytes; +} + diff --git a/src/hotspot/share/cds/archiveUtils.hpp b/src/hotspot/share/cds/archiveUtils.hpp index 32cef97886f..5a78bc26ee6 100644 --- a/src/hotspot/share/cds/archiveUtils.hpp +++ b/src/hotspot/share/cds/archiveUtils.hpp @@ -250,4 +250,44 @@ public: static void log_to_classlist(BootstrapInfo* bootstrap_specifier, TRAPS) NOT_CDS_RETURN; }; +class HeapRootSegments { +private: + size_t _base_offset; + size_t _count; + int _roots_count; + int _max_size_in_bytes; + int _max_size_in_elems; + +public: + size_t base_offset() { return _base_offset; } + size_t count() { return _count; } + int roots_count() { return _roots_count; } + int max_size_in_bytes() { return _max_size_in_bytes; } + int max_size_in_elems() { return _max_size_in_elems; } + + size_t size_in_bytes(size_t seg_idx); + int size_in_elems(size_t seg_idx); + size_t segment_offset(size_t seg_idx); + + // Trivial copy assignments are allowed to copy the entire object representation. + // We also inline this class into archive header. Therefore, it is important to make + // sure any gaps in object representation are initialized to zeroes. This is why + // constructors memset before doing field assignments. + HeapRootSegments() { + memset(this, 0, sizeof(*this)); + } + HeapRootSegments(size_t base_offset, int roots_count, int max_size_in_bytes, int max_size_in_elems) { + memset(this, 0, sizeof(*this)); + _base_offset = base_offset; + _count = (roots_count + max_size_in_elems - 1) / max_size_in_elems; + _roots_count = roots_count; + _max_size_in_bytes = max_size_in_bytes; + _max_size_in_elems = max_size_in_elems; + } + + // This class is trivially copyable and assignable. + HeapRootSegments(const HeapRootSegments&) = default; + HeapRootSegments& operator=(const HeapRootSegments&) = default; +}; + #endif // SHARE_CDS_ARCHIVEUTILS_HPP diff --git a/src/hotspot/share/cds/cdsConfig.cpp b/src/hotspot/share/cds/cdsConfig.cpp index a0a562eca21..5915424c4fe 100644 --- a/src/hotspot/share/cds/cdsConfig.cpp +++ b/src/hotspot/share/cds/cdsConfig.cpp @@ -236,7 +236,7 @@ void CDSConfig::init_shared_archive_paths() { } void CDSConfig::check_internal_module_property(const char* key, const char* value) { - if (Arguments::is_internal_module_property(key)) { + if (Arguments::is_internal_module_property(key) && !Arguments::is_module_path_property(key)) { stop_using_optimized_module_handling(); log_info(cds)("optimized module handling: disabled due to incompatible property: %s=%s", key, value); } diff --git a/src/hotspot/share/cds/classListParser.cpp b/src/hotspot/share/cds/classListParser.cpp index b2695ac2e78..694a179d7ee 100644 --- a/src/hotspot/share/cds/classListParser.cpp +++ b/src/hotspot/share/cds/classListParser.cpp @@ -463,7 +463,7 @@ void ClassListParser::check_class_name(const char* class_name) { err = "class name too long"; } else { assert(Symbol::max_length() < INT_MAX && len < INT_MAX, "must be"); - if (!UTF8::is_legal_utf8((const unsigned char*)class_name, (int)len, /*version_leq_47*/false)) { + if (!UTF8::is_legal_utf8((const unsigned char*)class_name, len, /*version_leq_47*/false)) { err = "class name is not valid UTF8"; } } @@ -508,7 +508,9 @@ InstanceKlass* ClassListParser::load_class_from_source(Symbol* class_name, TRAPS THROW_NULL(vmSymbols::java_lang_ClassNotFoundException()); } - InstanceKlass* k = UnregisteredClasses::load_class(class_name, _source, CHECK_NULL); + ResourceMark rm; + char * source_path = os::strdup_check_oom(ClassLoader::uri_to_path(_source)); + InstanceKlass* k = UnregisteredClasses::load_class(class_name, source_path, CHECK_NULL); if (k->local_interfaces()->length() != _interfaces->length()) { print_specified_interfaces(); print_actual_interfaces(k); @@ -849,4 +851,3 @@ void ClassListParser::parse_constant_pool_tag() { ClassPrelinker::preresolve_field_and_method_cp_entries(THREAD, ik, &preresolve_list); } } - diff --git a/src/hotspot/share/cds/classListWriter.cpp b/src/hotspot/share/cds/classListWriter.cpp index 78cd092445b..1b9f589f1c5 100644 --- a/src/hotspot/share/cds/classListWriter.cpp +++ b/src/hotspot/share/cds/classListWriter.cpp @@ -174,6 +174,8 @@ void ClassListWriter::write_to_stream(const InstanceKlass* k, outputStream* stre } } + // NB: the string following "source: " is not really a proper file name, but rather + // a truncated URI referring to a file. It must be decoded after reading. #ifdef _WINDOWS // "file:/C:/dir/foo.jar" -> "C:/dir/foo.jar" stream->print(" source: %s", cfs->source() + 6); diff --git a/src/hotspot/share/cds/filemap.cpp b/src/hotspot/share/cds/filemap.cpp index 35c43157b1a..715fce5f3fc 100644 --- a/src/hotspot/share/cds/filemap.cpp +++ b/src/hotspot/share/cds/filemap.cpp @@ -289,7 +289,11 @@ void FileMapHeader::print(outputStream* st) { st->print_cr("- has_non_jar_in_classpath: %d", _has_non_jar_in_classpath); st->print_cr("- requested_base_address: " INTPTR_FORMAT, p2i(_requested_base_address)); st->print_cr("- mapped_base_address: " INTPTR_FORMAT, p2i(_mapped_base_address)); - st->print_cr("- heap_roots_offset: " SIZE_FORMAT, _heap_roots_offset); + st->print_cr("- heap_root_segments.roots_count: %d" , _heap_root_segments.roots_count()); + st->print_cr("- heap_root_segments.base_offset: " SIZE_FORMAT_X, _heap_root_segments.base_offset()); + st->print_cr("- heap_root_segments.count: " SIZE_FORMAT, _heap_root_segments.count()); + st->print_cr("- heap_root_segments.max_size_elems: %d", _heap_root_segments.max_size_in_elems()); + st->print_cr("- heap_root_segments.max_size_bytes: %d", _heap_root_segments.max_size_in_bytes()); st->print_cr("- _heap_oopmap_start_pos: " SIZE_FORMAT, _heap_oopmap_start_pos); st->print_cr("- _heap_ptrmap_start_pos: " SIZE_FORMAT, _heap_ptrmap_start_pos); st->print_cr("- _rw_ptrmap_start_pos: " SIZE_FORMAT, _rw_ptrmap_start_pos); @@ -577,7 +581,7 @@ int FileMapInfo::get_module_shared_path_index(Symbol* location) { // skip_uri_protocol was also called during dump time -- see ClassLoaderExt::process_module_table() ResourceMark rm; - const char* file = ClassLoader::skip_uri_protocol(location->as_C_string()); + const char* file = ClassLoader::uri_to_path(location->as_C_string()); for (int i = ClassLoaderExt::app_module_paths_start_index(); i < get_number_of_shared_paths(); i++) { SharedClassPathEntry* ent = shared_path(i); if (!ent->is_non_existent()) { @@ -777,12 +781,12 @@ bool FileMapInfo::check_paths(int shared_path_start_idx, int num_paths, Growable assert(strlen(rp_array->at(i)) > (size_t)runtime_prefix_len, "sanity"); const char* runtime_path = rp_array->at(i) + runtime_prefix_len; if (!os::same_files(dumptime_path, runtime_path)) { - return true; + return false; } i++; j++; } - return false; + return true; } bool FileMapInfo::validate_boot_class_paths() { @@ -806,7 +810,7 @@ bool FileMapInfo::validate_boot_class_paths() { char* rp = skip_first_path_entry(runtime_boot_path); assert(shared_path(0)->is_modules_image(), "first shared_path must be the modules image"); int dp_len = header()->app_class_paths_start_index() - 1; // ignore the first path to the module image - bool mismatch = false; + bool match = true; bool relaxed_check = !header()->has_platform_or_app_classes(); if (dp_len == 0 && rp == nullptr) { @@ -819,7 +823,7 @@ bool FileMapInfo::validate_boot_class_paths() { if (check_paths_existence(rp)) { // If a path exists in the runtime boot paths, it is considered a mismatch // since there's no boot path specified during dump time. - mismatch = true; + match = false; } } } else if (dp_len > 0 && rp != nullptr) { @@ -836,16 +840,16 @@ bool FileMapInfo::validate_boot_class_paths() { // check the full runtime boot path, must match with dump time num = rp_len; } - mismatch = check_paths(1, num, rp_array, 0, 0); + match = check_paths(1, num, rp_array, 0, 0); } else { // create_path_array() ignores non-existing paths. Although the dump time and runtime boot classpath lengths // are the same initially, after the call to create_path_array(), the runtime boot classpath length could become // shorter. We consider boot classpath mismatch in this case. - mismatch = true; + match = false; } } - if (mismatch) { + if (!match) { // The paths are different return classpath_failure("[BOOT classpath mismatch, actual =", runtime_boot_path); } @@ -856,7 +860,7 @@ bool FileMapInfo::validate_app_class_paths(int shared_app_paths_len) { const char *appcp = Arguments::get_appclasspath(); assert(appcp != nullptr, "null app classpath"); int rp_len = num_paths(appcp); - bool mismatch = false; + bool match = false; if (rp_len < shared_app_paths_len) { return classpath_failure("Run time APP classpath is shorter than the one at dump time: ", appcp); } @@ -885,8 +889,8 @@ bool FileMapInfo::validate_app_class_paths(int shared_app_paths_len) { // run 2: -cp x.jar:NE4:b.jar -> x.jar:b.jar -> mismatched int j = header()->app_class_paths_start_index(); - mismatch = check_paths(j, shared_app_paths_len, rp_array, 0, 0); - if (mismatch) { + match = check_paths(j, shared_app_paths_len, rp_array, 0, 0); + if (!match) { // To facilitate app deployment, we allow the JAR files to be moved *together* to // a different location, as long as they are still stored under the same directory // structure. E.g., the following is OK. @@ -897,10 +901,10 @@ bool FileMapInfo::validate_app_class_paths(int shared_app_paths_len) { if (dumptime_prefix_len != 0 || runtime_prefix_len != 0) { log_info(class, path)("LCP length for app classpath (dumptime: %u, runtime: %u)", dumptime_prefix_len, runtime_prefix_len); - mismatch = check_paths(j, shared_app_paths_len, rp_array, + match = check_paths(j, shared_app_paths_len, rp_array, dumptime_prefix_len, runtime_prefix_len); } - if (mismatch) { + if (!match) { return classpath_failure("[APP classpath mismatch, actual: -Djava.class.path=", appcp); } } @@ -922,15 +926,35 @@ void FileMapInfo::log_paths(const char* msg, int start_idx, int end_idx) { } } +void FileMapInfo::extract_module_paths(const char* runtime_path, GrowableArray* module_paths) { + GrowableArray* path_array = create_path_array(runtime_path); + int num_paths = path_array->length(); + for (int i = 0; i < num_paths; i++) { + const char* name = path_array->at(i); + ClassLoaderExt::extract_jar_files_from_path(name, module_paths); + } + // module paths are stored in sorted order in the CDS archive. + module_paths->sort(ClassLoaderExt::compare_module_path_by_name); +} + bool FileMapInfo::check_module_paths() { - const char* rp = Arguments::get_property("jdk.module.path"); - int num_paths = CDSConfig::num_archives(rp); - if (num_paths != header()->num_module_paths()) { + const char* runtime_path = Arguments::get_property("jdk.module.path"); + int archived_num_module_paths = header()->num_module_paths(); + if (runtime_path == nullptr && archived_num_module_paths == 0) { + return true; + } + if ((runtime_path == nullptr && archived_num_module_paths > 0) || + (runtime_path != nullptr && archived_num_module_paths == 0)) { return false; } ResourceMark rm; - GrowableArray* rp_array = create_path_array(rp); - return check_paths(header()->app_module_paths_start_index(), num_paths, rp_array, 0, 0); + GrowableArray* module_paths = new GrowableArray(3); + extract_module_paths(runtime_path, module_paths); + int num_paths = module_paths->length(); + if (num_paths != archived_num_module_paths) { + return false; + } + return check_paths(header()->app_module_paths_start_index(), num_paths, module_paths, 0, 0); } bool FileMapInfo::validate_shared_path_table() { @@ -940,6 +964,16 @@ bool FileMapInfo::validate_shared_path_table() { // Load the shared path table info from the archive header _shared_path_table = header()->shared_path_table(); + + bool matched_module_paths = true; + if (CDSConfig::is_dumping_dynamic_archive() || header()->has_full_module_graph()) { + matched_module_paths = check_module_paths(); + } + if (header()->has_full_module_graph() && !matched_module_paths) { + CDSConfig::stop_using_optimized_module_handling(); + log_info(cds)("optimized module handling: disabled because of mismatched module paths"); + } + if (CDSConfig::is_dumping_dynamic_archive()) { // Only support dynamic dumping with the usage of the default CDS archive // or a simple base archive. @@ -955,7 +989,7 @@ bool FileMapInfo::validate_shared_path_table() { "Dynamic archiving is disabled because base layer archive has appended boot classpath"); } if (header()->num_module_paths() > 0) { - if (!check_module_paths()) { + if (!matched_module_paths) { CDSConfig::disable_dumping_dynamic_archive(); log_warning(cds)( "Dynamic archiving is disabled because base layer archive has a different module path"); @@ -1577,39 +1611,38 @@ static size_t write_bitmap(const CHeapBitMap* map, char* output, size_t offset) return offset + size_in_bytes; } -// The start of the archived heap has many primitive arrays (String -// bodies) that are not marked by the oop/ptr maps. So we must have -// lots of leading zeros. -size_t FileMapInfo::remove_bitmap_leading_zeros(CHeapBitMap* map) { - size_t old_zeros = map->find_first_set_bit(0); +// The sorting code groups the objects with non-null oop/ptrs together. +// Relevant bitmaps then have lots of leading and trailing zeros, which +// we do not have to store. +size_t FileMapInfo::remove_bitmap_zeros(CHeapBitMap* map) { + BitMap::idx_t first_set = map->find_first_set_bit(0); + BitMap::idx_t last_set = map->find_last_set_bit(0); size_t old_size = map->size(); // Slice and resize bitmap - map->truncate(old_zeros, map->size()); + map->truncate(first_set, last_set + 1); - DEBUG_ONLY( - size_t new_zeros = map->find_first_set_bit(0); - assert(new_zeros == 0, "Should have removed leading zeros"); - ) + assert(map->at(0), "First bit should be set"); + assert(map->at(map->size() - 1), "Last bit should be set"); assert(map->size() <= old_size, "sanity"); - return old_zeros; + + return first_set; } char* FileMapInfo::write_bitmap_region(CHeapBitMap* rw_ptrmap, CHeapBitMap* ro_ptrmap, ArchiveHeapInfo* heap_info, size_t &size_in_bytes) { - size_t removed_rw_zeros = remove_bitmap_leading_zeros(rw_ptrmap); - size_t removed_ro_zeros = remove_bitmap_leading_zeros(ro_ptrmap); - header()->set_rw_ptrmap_start_pos(removed_rw_zeros); - header()->set_ro_ptrmap_start_pos(removed_ro_zeros); + size_t removed_rw_leading_zeros = remove_bitmap_zeros(rw_ptrmap); + size_t removed_ro_leading_zeros = remove_bitmap_zeros(ro_ptrmap); + header()->set_rw_ptrmap_start_pos(removed_rw_leading_zeros); + header()->set_ro_ptrmap_start_pos(removed_ro_leading_zeros); size_in_bytes = rw_ptrmap->size_in_bytes() + ro_ptrmap->size_in_bytes(); if (heap_info->is_used()) { - // Remove leading zeros - size_t removed_oop_zeros = remove_bitmap_leading_zeros(heap_info->oopmap()); - size_t removed_ptr_zeros = remove_bitmap_leading_zeros(heap_info->ptrmap()); - - header()->set_heap_oopmap_start_pos(removed_oop_zeros); - header()->set_heap_ptrmap_start_pos(removed_ptr_zeros); + // Remove leading and trailing zeros + size_t removed_oop_leading_zeros = remove_bitmap_zeros(heap_info->oopmap()); + size_t removed_ptr_leading_zeros = remove_bitmap_zeros(heap_info->ptrmap()); + header()->set_heap_oopmap_start_pos(removed_oop_leading_zeros); + header()->set_heap_ptrmap_start_pos(removed_ptr_leading_zeros); size_in_bytes += heap_info->oopmap()->size_in_bytes(); size_in_bytes += heap_info->ptrmap()->size_in_bytes(); @@ -1647,7 +1680,7 @@ size_t FileMapInfo::write_heap_region(ArchiveHeapInfo* heap_info) { char* buffer_start = heap_info->buffer_start(); size_t buffer_size = heap_info->buffer_byte_size(); write_region(MetaspaceShared::hp, buffer_start, buffer_size, false, false); - header()->set_heap_roots_offset(heap_info->heap_roots_offset()); + header()->set_heap_root_segments(heap_info->heap_root_segments()); return buffer_size; } @@ -1712,10 +1745,10 @@ void FileMapInfo::close() { */ static char* map_memory(int fd, const char* file_name, size_t file_offset, char *addr, size_t bytes, bool read_only, - bool allow_exec, MEMFLAGS flags = mtNone) { + bool allow_exec, MemTag mem_tag = mtNone) { char* mem = os::map_memory(fd, file_name, file_offset, addr, bytes, AlwaysPreTouch ? false : read_only, - allow_exec, flags); + allow_exec, mem_tag); if (mem != nullptr && AlwaysPreTouch) { os::pretouch_memory(mem, mem + bytes); } @@ -2174,7 +2207,7 @@ bool FileMapInfo::map_heap_region_impl() { _mapped_heap_memregion = MemRegion(start, word_size); - // Map the archived heap data. No need to call MemTracker::record_virtual_memory_type() + // Map the archived heap data. No need to call MemTracker::record_virtual_memory_tag() // for mapped region as it is part of the reserved java heap, which is already recorded. char* addr = (char*)_mapped_heap_memregion.start(); char* base; diff --git a/src/hotspot/share/cds/filemap.hpp b/src/hotspot/share/cds/filemap.hpp index 7b10c16920b..6650f524408 100644 --- a/src/hotspot/share/cds/filemap.hpp +++ b/src/hotspot/share/cds/filemap.hpp @@ -25,6 +25,7 @@ #ifndef SHARE_CDS_FILEMAP_HPP #define SHARE_CDS_FILEMAP_HPP +#include "cds/archiveUtils.hpp" #include "cds/metaspaceShared.hpp" #include "include/cds.h" #include "logging/logLevel.hpp" @@ -225,8 +226,7 @@ private: bool _use_optimized_module_handling;// No module-relation VM options were specified, so we can skip // some expensive operations. bool _has_full_module_graph; // Does this CDS archive contain the full archived module graph? - size_t _heap_roots_offset; // Offset of the HeapShared::roots() object, from the bottom - // of the archived heap objects, in bytes. + HeapRootSegments _heap_root_segments; // Heap root segments info size_t _heap_oopmap_start_pos; // The first bit in the oopmap corresponds to this position in the heap. size_t _heap_ptrmap_start_pos; // The first bit in the ptrmap corresponds to this position in the heap. size_t _rw_ptrmap_start_pos; // The first bit in the ptrmap corresponds to this position in the rw region @@ -270,7 +270,8 @@ public: bool has_non_jar_in_classpath() const { return _has_non_jar_in_classpath; } bool compressed_oops() const { return _compressed_oops; } bool compressed_class_pointers() const { return _compressed_class_ptrs; } - size_t heap_roots_offset() const { return _heap_roots_offset; } + HeapRootSegments heap_root_segments() const { return _heap_root_segments; } + bool has_full_module_graph() const { return _has_full_module_graph; } size_t heap_oopmap_start_pos() const { return _heap_oopmap_start_pos; } size_t heap_ptrmap_start_pos() const { return _heap_ptrmap_start_pos; } size_t rw_ptrmap_start_pos() const { return _rw_ptrmap_start_pos; } @@ -285,7 +286,7 @@ public: void set_cloned_vtables(char* p) { set_as_offset(p, &_cloned_vtables_offset); } void set_serialized_data(char* p) { set_as_offset(p, &_serialized_data_offset); } void set_mapped_base_address(char* p) { _mapped_base_address = p; } - void set_heap_roots_offset(size_t n) { _heap_roots_offset = n; } + void set_heap_root_segments(HeapRootSegments segments) { _heap_root_segments = segments; } void set_heap_oopmap_start_pos(size_t n) { _heap_oopmap_start_pos = n; } void set_heap_ptrmap_start_pos(size_t n) { _heap_ptrmap_start_pos = n; } void set_rw_ptrmap_start_pos(size_t n) { _rw_ptrmap_start_pos = n; } @@ -385,7 +386,7 @@ public: address narrow_oop_base() const { return header()->narrow_oop_base(); } int narrow_oop_shift() const { return header()->narrow_oop_shift(); } uintx max_heap_size() const { return header()->max_heap_size(); } - size_t heap_roots_offset() const { return header()->heap_roots_offset(); } + HeapRootSegments heap_root_segments() const { return header()->heap_root_segments(); } size_t core_region_alignment() const { return header()->core_region_alignment(); } size_t heap_oopmap_start_pos() const { return header()->heap_oopmap_start_pos(); } size_t heap_ptrmap_start_pos() const { return header()->heap_ptrmap_start_pos(); } @@ -445,7 +446,7 @@ public: void write_header(); void write_region(int region, char* base, size_t size, bool read_only, bool allow_exec); - size_t remove_bitmap_leading_zeros(CHeapBitMap* map); + size_t remove_bitmap_zeros(CHeapBitMap* map); char* write_bitmap_region(CHeapBitMap* rw_ptrmap, CHeapBitMap* ro_ptrmap, ArchiveHeapInfo* heap_info, size_t &size_in_bytes); size_t write_heap_region(ArchiveHeapInfo* heap_info); @@ -554,6 +555,7 @@ public: GrowableArray* rp_array, unsigned int dumptime_prefix_len, unsigned int runtime_prefix_len) NOT_CDS_RETURN_(false); + void extract_module_paths(const char* runtime_path, GrowableArray* module_paths); bool validate_boot_class_paths() NOT_CDS_RETURN_(false); bool validate_app_class_paths(int shared_app_paths_len) NOT_CDS_RETURN_(false); bool map_heap_region_impl() NOT_CDS_JAVA_HEAP_RETURN_(false); diff --git a/src/hotspot/share/cds/heapShared.cpp b/src/hotspot/share/cds/heapShared.cpp index abfc0f9d64b..81aa7ac94dc 100644 --- a/src/hotspot/share/cds/heapShared.cpp +++ b/src/hotspot/share/cds/heapShared.cpp @@ -33,6 +33,7 @@ #include "cds/heapShared.hpp" #include "cds/metaspaceShared.hpp" #include "classfile/classLoaderData.hpp" +#include "classfile/classLoaderExt.hpp" #include "classfile/javaClasses.inline.hpp" #include "classfile/modules.hpp" #include "classfile/stringTable.hpp" @@ -55,6 +56,7 @@ #include "oops/oop.inline.hpp" #include "oops/typeArrayOop.inline.hpp" #include "prims/jvmtiExport.hpp" +#include "runtime/arguments.hpp" #include "runtime/fieldDescriptor.inline.hpp" #include "runtime/init.hpp" #include "runtime/javaCalls.hpp" @@ -133,7 +135,8 @@ static ArchivableStaticFieldInfo fmg_archive_subgraph_entry_fields[] = { KlassSubGraphInfo* HeapShared::_default_subgraph_info; GrowableArrayCHeap* HeapShared::_pending_roots = nullptr; -OopHandle HeapShared::_roots; +GrowableArrayCHeap* HeapShared::_root_segments; +int HeapShared::_root_segment_max_size_elems; OopHandle HeapShared::_scratch_basic_type_mirrors[T_VOID+1]; MetaspaceObjToOopHandleTable* HeapShared::_scratch_java_mirror_table = nullptr; MetaspaceObjToOopHandleTable* HeapShared::_scratch_references_table = nullptr; @@ -225,7 +228,7 @@ int HeapShared::append_root(oop obj) { return _pending_roots->append(obj); } -objArrayOop HeapShared::roots() { +objArrayOop HeapShared::root_segment(int segment_idx) { if (CDSConfig::is_dumping_heap()) { assert(Thread::current() == (Thread*)VMThread::vm_thread(), "should be in vm thread"); if (!HeapShared::can_write()) { @@ -235,17 +238,35 @@ objArrayOop HeapShared::roots() { assert(CDSConfig::is_using_archive(), "must be"); } - objArrayOop roots = (objArrayOop)_roots.resolve(); - assert(roots != nullptr, "should have been initialized"); - return roots; + objArrayOop segment = (objArrayOop)_root_segments->at(segment_idx).resolve(); + assert(segment != nullptr, "should have been initialized"); + return segment; +} + +void HeapShared::get_segment_indexes(int idx, int& seg_idx, int& int_idx) { + assert(_root_segment_max_size_elems > 0, "sanity"); + + // Try to avoid divisions for the common case. + if (idx < _root_segment_max_size_elems) { + seg_idx = 0; + int_idx = idx; + } else { + seg_idx = idx / _root_segment_max_size_elems; + int_idx = idx % _root_segment_max_size_elems; + } + + assert(idx == seg_idx * _root_segment_max_size_elems + int_idx, + "sanity: %d index maps to %d segment and %d internal", idx, seg_idx, int_idx); } // Returns an objArray that contains all the roots of the archived objects oop HeapShared::get_root(int index, bool clear) { assert(index >= 0, "sanity"); assert(!CDSConfig::is_dumping_heap() && CDSConfig::is_using_archive(), "runtime only"); - assert(!_roots.is_empty(), "must have loaded shared heap"); - oop result = roots()->obj_at(index); + assert(!_root_segments->is_empty(), "must have loaded shared heap"); + int seg_idx, int_idx; + get_segment_indexes(index, seg_idx, int_idx); + oop result = root_segment(seg_idx)->obj_at(int_idx); if (clear) { clear_root(index); } @@ -256,11 +277,13 @@ void HeapShared::clear_root(int index) { assert(index >= 0, "sanity"); assert(CDSConfig::is_using_archive(), "must be"); if (ArchiveHeapLoader::is_in_use()) { + int seg_idx, int_idx; + get_segment_indexes(index, seg_idx, int_idx); if (log_is_enabled(Debug, cds, heap)) { - oop old = roots()->obj_at(index); + oop old = root_segment(seg_idx)->obj_at(int_idx); log_debug(cds, heap)("Clearing root %d: was " PTR_FORMAT, index, p2i(old)); } - roots()->obj_at_put(index, nullptr); + root_segment(seg_idx)->obj_at_put(int_idx, nullptr); } } @@ -461,11 +484,13 @@ void HeapShared::archive_objects(ArchiveHeapInfo *heap_info) { // Cache for recording where the archived objects are copied to create_archived_object_cache(); - log_info(cds)("Heap range = [" PTR_FORMAT " - " PTR_FORMAT "]", - UseCompressedOops ? p2i(CompressedOops::begin()) : - p2i((address)G1CollectedHeap::heap()->reserved().start()), - UseCompressedOops ? p2i(CompressedOops::end()) : - p2i((address)G1CollectedHeap::heap()->reserved().end())); + if (UseCompressedOops || UseG1GC) { + log_info(cds)("Heap range = [" PTR_FORMAT " - " PTR_FORMAT "]", + UseCompressedOops ? p2i(CompressedOops::begin()) : + p2i((address)G1CollectedHeap::heap()->reserved().start()), + UseCompressedOops ? p2i(CompressedOops::end()) : + p2i((address)G1CollectedHeap::heap()->reserved().end())); + } copy_objects(); CDSHeapVerifier::verify(); @@ -764,11 +789,17 @@ void HeapShared::write_subgraph_info_table() { } } -void HeapShared::init_roots(oop roots_oop) { - if (roots_oop != nullptr) { - assert(ArchiveHeapLoader::is_in_use(), "must be"); - _roots = OopHandle(Universe::vm_global(), roots_oop); +void HeapShared::add_root_segment(objArrayOop segment_oop) { + assert(segment_oop != nullptr, "must be"); + assert(ArchiveHeapLoader::is_in_use(), "must be"); + if (_root_segments == nullptr) { + _root_segments = new GrowableArrayCHeap(10); } + _root_segments->push(OopHandle(Universe::vm_global(), segment_oop)); +} + +void HeapShared::init_root_segment_sizes(int max_size_elems) { + _root_segment_max_size_elems = max_size_elems; } void HeapShared::serialize_tables(SerializeClosure* soc) { @@ -855,6 +886,17 @@ void HeapShared::initialize_from_archived_subgraph(JavaThread* current, Klass* k return; // nothing to do } + if (k->name()->equals("jdk/internal/module/ArchivedModuleGraph") && + !CDSConfig::is_using_optimized_module_handling() && + // archive was created with --module-path + ClassLoaderExt::num_module_paths() > 0) { + // ArchivedModuleGraph was created with a --module-path that's different than the runtime --module-path. + // Thus, it might contain references to modules that do not exist at runtime. We cannot use it. + log_info(cds, heap)("Skip initializing ArchivedModuleGraph subgraph: is_using_optimized_module_handling=%s num_module_paths=%d", + BOOL_TO_STR(CDSConfig::is_using_optimized_module_handling()), ClassLoaderExt::num_module_paths()); + return; + } + ExceptionMark em(THREAD); const ArchivedKlassSubGraphInfoRecord* record = resolve_or_init_classes_for_subgraph_of(k, /*do_init=*/true, THREAD); @@ -1103,6 +1145,13 @@ bool HeapShared::archive_reachable_objects_from(int level, // these objects that are referenced (directly or indirectly) by static fields. ResourceMark rm; log_error(cds, heap)("Cannot archive object of class %s", orig_obj->klass()->external_name()); + if (log_is_enabled(Trace, cds, heap)) { + WalkOopAndArchiveClosure* walker = WalkOopAndArchiveClosure::current(); + if (walker != nullptr) { + LogStream ls(Log(cds, heap)::trace()); + CDSHeapVerifier::trace_to_root(&ls, walker->referencing_obj()); + } + } MetaspaceShared::unrecoverable_writing_error(); } @@ -1304,6 +1353,9 @@ void HeapShared::check_default_subgraph_classes() { name == vmSymbols::java_lang_ArithmeticException() || name == vmSymbols::java_lang_NullPointerException() || name == vmSymbols::java_lang_InternalError() || + name == vmSymbols::java_lang_ArrayIndexOutOfBoundsException() || + name == vmSymbols::java_lang_ArrayStoreException() || + name == vmSymbols::java_lang_ClassCastException() || name == vmSymbols::object_array_signature() || name == vmSymbols::byte_array_signature() || name == vmSymbols::char_array_signature(), diff --git a/src/hotspot/share/cds/heapShared.hpp b/src/hotspot/share/cds/heapShared.hpp index 0ba20f1e313..01d664945ee 100644 --- a/src/hotspot/share/cds/heapShared.hpp +++ b/src/hotspot/share/cds/heapShared.hpp @@ -143,13 +143,13 @@ class HeapShared: AllStatic { friend class VerifySharedOopClosure; public: - // Can this VM write a heap region into the CDS archive? Currently only G1+compressed{oops,cp} + // Can this VM write a heap region into the CDS archive? Currently only {G1|Parallel|Serial}+compressed_cp static bool can_write() { CDS_JAVA_HEAP_ONLY( if (_disable_writing) { return false; } - return (UseG1GC && UseCompressedClassPointers); + return (UseG1GC || UseParallelGC || UseSerialGC) && UseCompressedClassPointers; ) NOT_CDS_JAVA_HEAP(return false;) } @@ -290,7 +290,8 @@ private: static KlassSubGraphInfo* _default_subgraph_info; static GrowableArrayCHeap* _pending_roots; - static OopHandle _roots; + static GrowableArrayCHeap* _root_segments; + static int _root_segment_max_size_elems; static OopHandle _scratch_basic_type_mirrors[T_VOID+1]; static MetaspaceObjToOopHandleTable* _scratch_java_mirror_table; static MetaspaceObjToOopHandleTable* _scratch_references_table; @@ -399,12 +400,14 @@ private: static GrowableArrayCHeap* pending_roots() { return _pending_roots; } // Dump-time and runtime - static objArrayOop roots(); + static objArrayOop root_segment(int segment_idx); static oop get_root(int index, bool clear=false); // Run-time only static void clear_root(int index); + static void get_segment_indexes(int index, int& segment_index, int& internal_index); + static void setup_test_class(const char* test_class_name) PRODUCT_RETURN; #endif // INCLUDE_CDS_JAVA_HEAP @@ -422,7 +425,8 @@ private: static void init_for_dumping(TRAPS) NOT_CDS_JAVA_HEAP_RETURN; static void write_subgraph_info_table() NOT_CDS_JAVA_HEAP_RETURN; - static void init_roots(oop roots_oop) NOT_CDS_JAVA_HEAP_RETURN; + static void add_root_segment(objArrayOop segment_oop) NOT_CDS_JAVA_HEAP_RETURN; + static void init_root_segment_sizes(int max_size_elems) NOT_CDS_JAVA_HEAP_RETURN; static void serialize_tables(SerializeClosure* soc) NOT_CDS_JAVA_HEAP_RETURN; #ifndef PRODUCT diff --git a/src/hotspot/share/cds/metaspaceShared.cpp b/src/hotspot/share/cds/metaspaceShared.cpp index 4d978a7ad88..6f646e162ec 100644 --- a/src/hotspot/share/cds/metaspaceShared.cpp +++ b/src/hotspot/share/cds/metaspaceShared.cpp @@ -77,6 +77,7 @@ #include "runtime/globals.hpp" #include "runtime/globals_extension.hpp" #include "runtime/handles.inline.hpp" +#include "runtime/javaCalls.hpp" #include "runtime/os.inline.hpp" #include "runtime/safepointVerifiers.hpp" #include "runtime/sharedRuntime.hpp" @@ -300,6 +301,7 @@ void MetaspaceShared::post_initialize(TRAPS) { } ClassLoaderExt::init_paths_start_index(info->app_class_paths_start_index()); ClassLoaderExt::init_app_module_paths_start_index(info->app_module_paths_start_index()); + ClassLoaderExt::init_num_module_paths(info->header()->num_module_paths()); } } } @@ -791,9 +793,22 @@ void MetaspaceShared::preload_and_dump_impl(StaticArchiveBuilder& builder, TRAPS // Do this at the very end, when no Java code will be executed. Otherwise // some new strings may be added to the intern table. StringTable::allocate_shared_strings_array(CHECK); + } else { + log_info(cds)("Not dumping heap, reset CDSConfig::_is_using_optimized_module_handling"); + CDSConfig::stop_using_optimized_module_handling(); } #endif + // Dummy call to load classes used at CDS runtime + JavaValue result(T_OBJECT); + Handle path_string = java_lang_String::create_from_str("dummy.jar", CHECK); + JavaCalls::call_static(&result, + vmClasses::jdk_internal_loader_ClassLoaders_klass(), + vmSymbols::toFileURL_name(), + vmSymbols::toFileURL_signature(), + path_string, + CHECK); + VM_PopulateDumpSharedSpace op(builder); VMThread::execute(&op); @@ -1299,7 +1314,7 @@ char* MetaspaceShared::reserve_address_space_for_archives(FileMapInfo* static_ma assert(base_address == nullptr || (address)archive_space_rs.base() == base_address, "Sanity"); // Register archive space with NMT. - MemTracker::record_virtual_memory_type(archive_space_rs.base(), mtClassShared); + MemTracker::record_virtual_memory_tag(archive_space_rs.base(), mtClassShared); return archive_space_rs.base(); } return nullptr; @@ -1361,8 +1376,8 @@ char* MetaspaceShared::reserve_address_space_for_archives(FileMapInfo* static_ma return nullptr; } // NMT: fix up the space tags - MemTracker::record_virtual_memory_type(archive_space_rs.base(), mtClassShared); - MemTracker::record_virtual_memory_type(class_space_rs.base(), mtClass); + MemTracker::record_virtual_memory_tag(archive_space_rs.base(), mtClassShared); + MemTracker::record_virtual_memory_tag(class_space_rs.base(), mtClass); } else { if (use_archive_base_addr && base_address != nullptr) { total_space_rs = ReservedSpace(total_range_size, base_address_alignment, diff --git a/src/hotspot/share/ci/ciEnv.cpp b/src/hotspot/share/ci/ciEnv.cpp index 3079d469ebe..155ce032400 100644 --- a/src/hotspot/share/ci/ciEnv.cpp +++ b/src/hotspot/share/ci/ciEnv.cpp @@ -100,10 +100,6 @@ ciSymbol* ciEnv::_unloaded_cisymbol = nullptr; ciInstanceKlass* ciEnv::_unloaded_ciinstance_klass = nullptr; ciObjArrayKlass* ciEnv::_unloaded_ciobjarrayklass = nullptr; -jobject ciEnv::_ArrayIndexOutOfBoundsException_handle = nullptr; -jobject ciEnv::_ArrayStoreException_handle = nullptr; -jobject ciEnv::_ClassCastException_handle = nullptr; - #ifndef PRODUCT static bool firstEnv = true; #endif /* PRODUCT */ @@ -158,10 +154,16 @@ ciEnv::ciEnv(CompileTask* task) o = Universe::arithmetic_exception_instance(); assert(o != nullptr, "should have been initialized"); _ArithmeticException_instance = get_object(o)->as_instance(); + o = Universe::array_index_out_of_bounds_exception_instance(); + assert(o != nullptr, "should have been initialized"); + _ArrayIndexOutOfBoundsException_instance = get_object(o)->as_instance(); + o = Universe::array_store_exception_instance(); + assert(o != nullptr, "should have been initialized"); + _ArrayStoreException_instance = get_object(o)->as_instance(); + o = Universe::class_cast_exception_instance(); + assert(o != nullptr, "should have been initialized"); + _ClassCastException_instance = get_object(o)->as_instance(); - _ArrayIndexOutOfBoundsException_instance = nullptr; - _ArrayStoreException_instance = nullptr; - _ClassCastException_instance = nullptr; _the_null_string = nullptr; _the_min_jint_string = nullptr; @@ -363,29 +365,6 @@ void ciEnv::cache_dtrace_flags() { _dtrace_alloc_probes = DTraceAllocProbes; } -// ------------------------------------------------------------------ -// helper for lazy exception creation -ciInstance* ciEnv::get_or_create_exception(jobject& handle, Symbol* name) { - VM_ENTRY_MARK; - if (handle == nullptr) { - // Cf. universe.cpp, creation of Universe::_null_ptr_exception_instance. - InstanceKlass* ik = SystemDictionary::find_instance_klass(THREAD, name, Handle(), Handle()); - jobject objh = nullptr; - if (ik != nullptr) { - oop obj = ik->allocate_instance(THREAD); - if (!HAS_PENDING_EXCEPTION) - objh = JNIHandles::make_global(Handle(THREAD, obj)); - } - if (HAS_PENDING_EXCEPTION) { - CLEAR_PENDING_EXCEPTION; - } else { - handle = objh; - } - } - oop obj = JNIHandles::resolve(handle); - return obj == nullptr? nullptr: get_object(obj)->as_instance(); -} - ciInstanceKlass* ciEnv::get_box_klass_for_primitive_type(BasicType type) { switch (type) { case T_BOOLEAN: return Boolean_klass(); @@ -403,31 +382,6 @@ ciInstanceKlass* ciEnv::get_box_klass_for_primitive_type(BasicType type) { } } -ciInstance* ciEnv::ArrayIndexOutOfBoundsException_instance() { - if (_ArrayIndexOutOfBoundsException_instance == nullptr) { - _ArrayIndexOutOfBoundsException_instance - = get_or_create_exception(_ArrayIndexOutOfBoundsException_handle, - vmSymbols::java_lang_ArrayIndexOutOfBoundsException()); - } - return _ArrayIndexOutOfBoundsException_instance; -} -ciInstance* ciEnv::ArrayStoreException_instance() { - if (_ArrayStoreException_instance == nullptr) { - _ArrayStoreException_instance - = get_or_create_exception(_ArrayStoreException_handle, - vmSymbols::java_lang_ArrayStoreException()); - } - return _ArrayStoreException_instance; -} -ciInstance* ciEnv::ClassCastException_instance() { - if (_ClassCastException_instance == nullptr) { - _ClassCastException_instance - = get_or_create_exception(_ClassCastException_handle, - vmSymbols::java_lang_ClassCastException()); - } - return _ClassCastException_instance; -} - ciInstance* ciEnv::the_null_string() { if (_the_null_string == nullptr) { VM_ENTRY_MARK; @@ -1662,7 +1616,10 @@ void ciEnv::dump_replay_data_helper(outputStream* out) { for (int i = 0; i < objects->length(); i++) { objects->at(i)->dump_replay_data(out); } - dump_compile_data(out); + + if (this->task() != nullptr) { + dump_compile_data(out); + } out->flush(); } diff --git a/src/hotspot/share/ci/ciEnv.hpp b/src/hotspot/share/ci/ciEnv.hpp index 5ee9b420033..6c66633ee17 100644 --- a/src/hotspot/share/ci/ciEnv.hpp +++ b/src/hotspot/share/ci/ciEnv.hpp @@ -94,10 +94,6 @@ private: static ciInstanceKlass* _unloaded_ciinstance_klass; static ciObjArrayKlass* _unloaded_ciobjarrayklass; - static jobject _ArrayIndexOutOfBoundsException_handle; - static jobject _ArrayStoreException_handle; - static jobject _ClassCastException_handle; - ciInstance* _NullPointerException_instance; ciInstance* _ArithmeticException_instance; ciInstance* _ArrayIndexOutOfBoundsException_instance; @@ -230,8 +226,6 @@ private: ciMethod* get_method_from_handle(Method* method); - ciInstance* get_or_create_exception(jobject& handle, Symbol* name); - // Get a ciMethod representing either an unfound method or // a method with an unloaded holder. Ensures uniqueness of // the result. @@ -402,11 +396,18 @@ public: assert(_ArithmeticException_instance != nullptr, "initialization problem"); return _ArithmeticException_instance; } - - // Lazy constructors: - ciInstance* ArrayIndexOutOfBoundsException_instance(); - ciInstance* ArrayStoreException_instance(); - ciInstance* ClassCastException_instance(); + ciInstance* ArrayIndexOutOfBoundsException_instance() { + assert(_ArrayIndexOutOfBoundsException_instance != nullptr, "initialization problem"); + return _ArrayIndexOutOfBoundsException_instance; + } + ciInstance* ArrayStoreException_instance() { + assert(_ArrayStoreException_instance != nullptr, "initialization problem"); + return _ArrayStoreException_instance; + } + ciInstance* ClassCastException_instance() { + assert(_ClassCastException_instance != nullptr, "initialization problem"); + return _ClassCastException_instance; + } ciInstance* the_null_string(); ciInstance* the_min_jint_string(); diff --git a/src/hotspot/share/ci/ciInstanceKlass.cpp b/src/hotspot/share/ci/ciInstanceKlass.cpp index 240bb25ae3a..a9342eeada4 100644 --- a/src/hotspot/share/ci/ciInstanceKlass.cpp +++ b/src/hotspot/share/ci/ciInstanceKlass.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -59,7 +59,7 @@ ciInstanceKlass::ciInstanceKlass(Klass* k) : AccessFlags access_flags = ik->access_flags(); _flags = ciFlags(access_flags); - _has_finalizer = access_flags.has_finalizer(); + _has_finalizer = ik->has_finalizer(); _has_subklass = flags().is_final() ? subklass_false : subklass_unknown; _init_state = ik->init_state(); _has_nonstatic_fields = ik->has_nonstatic_fields(); diff --git a/src/hotspot/share/ci/ciKlass.cpp b/src/hotspot/share/ci/ciKlass.cpp index 6e70d69f05d..efdd2512f90 100644 --- a/src/hotspot/share/ci/ciKlass.cpp +++ b/src/hotspot/share/ci/ciKlass.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -226,6 +226,15 @@ jint ciKlass::access_flags() { ) } +// ------------------------------------------------------------------ +// ciKlass::misc_flags +klass_flags_t ciKlass::misc_flags() { + assert(is_loaded(), "not loaded"); + GUARDED_VM_ENTRY( + return get_Klass()->misc_flags(); + ) +} + // ------------------------------------------------------------------ // ciKlass::print_impl // diff --git a/src/hotspot/share/ci/ciKlass.hpp b/src/hotspot/share/ci/ciKlass.hpp index 2dd5a5e2c0b..10d8395ed7f 100644 --- a/src/hotspot/share/ci/ciKlass.hpp +++ b/src/hotspot/share/ci/ciKlass.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -107,6 +107,13 @@ public: return false; } + bool is_in_encoding_range() { + Klass* k = get_Klass(); + bool is_in_encoding_range = CompressedKlassPointers::is_encodable(k); + assert(is_in_encoding_range || k->is_interface() || k->is_abstract(), "sanity"); + return is_in_encoding_range; + } + // Attempt to get a klass using this ciKlass's loader. ciKlass* find_klass(ciSymbol* klass_name); // Note: To find a class from its name string, use ciSymbol::make, @@ -121,6 +128,9 @@ public: // Fetch Klass::access_flags. jint access_flags(); + // Fetch Klass::misc_flags. + klass_flags_t misc_flags(); + // What kind of ciObject is this? bool is_klass() const { return true; } diff --git a/src/hotspot/share/ci/ciMethod.cpp b/src/hotspot/share/ci/ciMethod.cpp index 94b405cdbfa..a74a812c6a2 100644 --- a/src/hotspot/share/ci/ciMethod.cpp +++ b/src/hotspot/share/ci/ciMethod.cpp @@ -1249,7 +1249,6 @@ bool ciMethod::has_jsrs () const { FETCH_FLAG_FROM_VM(has_jsrs); bool ciMethod::is_getter () const { FETCH_FLAG_FROM_VM(is_getter); } bool ciMethod::is_setter () const { FETCH_FLAG_FROM_VM(is_setter); } bool ciMethod::is_accessor () const { FETCH_FLAG_FROM_VM(is_accessor); } -bool ciMethod::is_initializer () const { FETCH_FLAG_FROM_VM(is_initializer); } bool ciMethod::is_empty () const { FETCH_FLAG_FROM_VM(is_empty_method); } bool ciMethod::is_boxing_method() const { diff --git a/src/hotspot/share/ci/ciMethod.hpp b/src/hotspot/share/ci/ciMethod.hpp index 5cb63204d0b..cc524930192 100644 --- a/src/hotspot/share/ci/ciMethod.hpp +++ b/src/hotspot/share/ci/ciMethod.hpp @@ -352,7 +352,6 @@ class ciMethod : public ciMetadata { bool is_getter () const; bool is_setter () const; bool is_accessor () const; - bool is_initializer () const; bool is_empty () const; bool can_be_statically_bound() const { return _can_be_statically_bound; } bool has_reserved_stack_access() const { return _has_reserved_stack_access; } diff --git a/src/hotspot/share/classfile/classFileParser.cpp b/src/hotspot/share/classfile/classFileParser.cpp index 407078d64fc..c8e95149b7c 100644 --- a/src/hotspot/share/classfile/classFileParser.cpp +++ b/src/hotspot/share/classfile/classFileParser.cpp @@ -1150,30 +1150,40 @@ static void parse_annotations(const ConstantPool* const cp, if (AnnotationCollector::_unknown == id) continue; coll->set_annotation(id); if (AnnotationCollector::_java_lang_Deprecated == id) { - assert(count <= 2, "change this if more element-value pairs are added to the @Deprecated annotation"); - // @Deprecated can specify forRemoval=true + // @Deprecated can specify forRemoval=true, which we need + // to record for JFR to use. If the annotation is not well-formed + // then we may not be able to determine that. const u1* offset = abase + member_off; - for (int i = 0; i < count; ++i) { + // There are only 2 members in @Deprecated. + int n_members = MIN2(count, 2); + for (int i = 0; i < n_members; ++i) { int member_index = Bytes::get_Java_u2((address)offset); offset += 2; member = check_symbol_at(cp, member_index); - if (member == vmSymbols::since()) { - assert(*((address)offset) == s_tag_val, "invariant"); + if (member == vmSymbols::since() && + (*((address)offset) == s_tag_val)) { + // Found `since` first so skip over it offset += 3; - continue; } - if (member == vmSymbols::for_removal()) { - assert(*((address)offset) == b_tag_val, "invariant"); + else if (member == vmSymbols::for_removal() && + (*((address)offset) == b_tag_val)) { const u2 boolean_value_index = Bytes::get_Java_u2((address)offset + 1); - if (cp->int_at(boolean_value_index) == 1) { + // No guarantee the entry is valid so check it refers to an int in the CP. + if (cp->is_within_bounds(boolean_value_index) && + cp->tag_at(boolean_value_index).is_int() && + cp->int_at(boolean_value_index) == 1) { // forRemoval == true coll->set_annotation(AnnotationCollector::_java_lang_Deprecated_for_removal); } + break; // no need to check further + } + else { + // This @Deprecated annotation is malformed so we don't try to + // determine whether forRemoval is set. break; } - } - continue; + continue; // proceed to next annotation } if (AnnotationCollector::_jdk_internal_vm_annotation_Contended == id) { @@ -1194,11 +1204,21 @@ static void parse_annotations(const ConstantPool* const cp, && s_tag_val == *(abase + tag_off) && member == vmSymbols::value_name()) { group_index = Bytes::get_Java_u2((address)abase + s_con_off); - if (cp->symbol_at(group_index)->utf8_length() == 0) { - group_index = 0; // default contended group + // No guarantee the group_index is valid so check it refers to a + // symbol in the CP. + if (cp->is_within_bounds(group_index) && + cp->tag_at(group_index).is_utf8()) { + // Seems valid, so check for empty string and reset + if (cp->symbol_at(group_index)->utf8_length() == 0) { + group_index = 0; // default contended group + } + } else { + // Not valid so use the default + group_index = 0; } } coll->set_contended_group(group_index); + continue; // proceed to next annotation } } } @@ -1352,105 +1372,16 @@ void ClassFileParser::parse_field_attributes(const ClassFileStream* const cfs, } -// Field allocation types. Used for computing field offsets. - -enum FieldAllocationType { - STATIC_OOP, // Oops - STATIC_BYTE, // Boolean, Byte, char - STATIC_SHORT, // shorts - STATIC_WORD, // ints - STATIC_DOUBLE, // aligned long or double - NONSTATIC_OOP, - NONSTATIC_BYTE, - NONSTATIC_SHORT, - NONSTATIC_WORD, - NONSTATIC_DOUBLE, - MAX_FIELD_ALLOCATION_TYPE, - BAD_ALLOCATION_TYPE = -1 -}; - -static FieldAllocationType _basic_type_to_atype[2 * (T_CONFLICT + 1)] = { - BAD_ALLOCATION_TYPE, // 0 - BAD_ALLOCATION_TYPE, // 1 - BAD_ALLOCATION_TYPE, // 2 - BAD_ALLOCATION_TYPE, // 3 - NONSTATIC_BYTE , // T_BOOLEAN = 4, - NONSTATIC_SHORT, // T_CHAR = 5, - NONSTATIC_WORD, // T_FLOAT = 6, - NONSTATIC_DOUBLE, // T_DOUBLE = 7, - NONSTATIC_BYTE, // T_BYTE = 8, - NONSTATIC_SHORT, // T_SHORT = 9, - NONSTATIC_WORD, // T_INT = 10, - NONSTATIC_DOUBLE, // T_LONG = 11, - NONSTATIC_OOP, // T_OBJECT = 12, - NONSTATIC_OOP, // T_ARRAY = 13, - BAD_ALLOCATION_TYPE, // T_VOID = 14, - BAD_ALLOCATION_TYPE, // T_ADDRESS = 15, - BAD_ALLOCATION_TYPE, // T_NARROWOOP = 16, - BAD_ALLOCATION_TYPE, // T_METADATA = 17, - BAD_ALLOCATION_TYPE, // T_NARROWKLASS = 18, - BAD_ALLOCATION_TYPE, // T_CONFLICT = 19, - BAD_ALLOCATION_TYPE, // 0 - BAD_ALLOCATION_TYPE, // 1 - BAD_ALLOCATION_TYPE, // 2 - BAD_ALLOCATION_TYPE, // 3 - STATIC_BYTE , // T_BOOLEAN = 4, - STATIC_SHORT, // T_CHAR = 5, - STATIC_WORD, // T_FLOAT = 6, - STATIC_DOUBLE, // T_DOUBLE = 7, - STATIC_BYTE, // T_BYTE = 8, - STATIC_SHORT, // T_SHORT = 9, - STATIC_WORD, // T_INT = 10, - STATIC_DOUBLE, // T_LONG = 11, - STATIC_OOP, // T_OBJECT = 12, - STATIC_OOP, // T_ARRAY = 13, - BAD_ALLOCATION_TYPE, // T_VOID = 14, - BAD_ALLOCATION_TYPE, // T_ADDRESS = 15, - BAD_ALLOCATION_TYPE, // T_NARROWOOP = 16, - BAD_ALLOCATION_TYPE, // T_METADATA = 17, - BAD_ALLOCATION_TYPE, // T_NARROWKLASS = 18, - BAD_ALLOCATION_TYPE, // T_CONFLICT = 19, -}; - -static FieldAllocationType basic_type_to_atype(bool is_static, BasicType type) { - assert(type >= T_BOOLEAN && type < T_VOID, "only allowable values"); - FieldAllocationType result = _basic_type_to_atype[type + (is_static ? (T_CONFLICT + 1) : 0)]; - assert(result != BAD_ALLOCATION_TYPE, "bad type"); - return result; -} - -class ClassFileParser::FieldAllocationCount : public ResourceObj { - public: - u2 count[MAX_FIELD_ALLOCATION_TYPE]; - - FieldAllocationCount() { - for (int i = 0; i < MAX_FIELD_ALLOCATION_TYPE; i++) { - count[i] = 0; - } - } - - void update(bool is_static, BasicType type) { - FieldAllocationType atype = basic_type_to_atype(is_static, type); - if (atype != BAD_ALLOCATION_TYPE) { - // Make sure there is no overflow with injected fields. - assert(count[atype] < 0xFFFF, "More than 65535 fields"); - count[atype]++; - } - } -}; - // Side-effects: populates the _fields, _fields_annotations, // _fields_type_annotations fields void ClassFileParser::parse_fields(const ClassFileStream* const cfs, bool is_interface, - FieldAllocationCount* const fac, ConstantPool* cp, const int cp_size, u2* const java_fields_count_ptr, TRAPS) { assert(cfs != nullptr, "invariant"); - assert(fac != nullptr, "invariant"); assert(cp != nullptr, "invariant"); assert(java_fields_count_ptr != nullptr, "invariant"); @@ -1544,8 +1475,10 @@ void ClassFileParser::parse_fields(const ClassFileStream* const cfs, const BasicType type = cp->basic_type_for_signature_at(signature_index); - // Update FieldAllocationCount for this kind of field - fac->update(is_static, type); + // Update number of static oop fields. + if (is_static && is_reference_type(type)) { + _static_oop_count++; + } FieldInfo fi(access_flags, name_index, signature_index, constantvalue_index, fieldFlags); fi.set_index(n); @@ -1590,10 +1523,6 @@ void ClassFileParser::parse_fields(const ClassFileStream* const cfs, FieldInfo fi(aflags, (u2)(injected[n].name_index), (u2)(injected[n].signature_index), 0, fflags); fi.set_index(index); _temp_field_info->append(fi); - - // Update FieldAllocationCount for this kind of field - const BasicType type = Signature::basic_type(injected[n].signature()); - fac->update(false, type); index++; } } @@ -4559,7 +4488,8 @@ void ClassFileParser::verify_legal_utf8(const unsigned char* buffer, int length, TRAPS) const { assert(_need_verify, "only called when _need_verify is true"); - if (!UTF8::is_legal_utf8(buffer, length, _major_version <= 47)) { + // Note: 0 <= length < 64K, as it comes from a u2 entry in the CP. + if (!UTF8::is_legal_utf8(buffer, static_cast(length), _major_version <= 47)) { classfile_parse_error("Illegal UTF8 string in constant pool in class file %s", THREAD); } } @@ -5116,8 +5046,7 @@ void ClassFileParser::fill_instance_klass(InstanceKlass* ik, // Not yet: supers are done below to support the new subtype-checking fields ik->set_nonstatic_field_size(_field_info->_nonstatic_field_size); ik->set_has_nonstatic_fields(_field_info->_has_nonstatic_fields); - assert(_fac != nullptr, "invariant"); - ik->set_static_oop_field_count(_fac->count[STATIC_OOP]); + ik->set_static_oop_field_count(_static_oop_count); // this transfers ownership of a lot of arrays from // the parser onto the InstanceKlass* @@ -5173,9 +5102,7 @@ void ClassFileParser::fill_instance_klass(InstanceKlass* ik, ik->set_has_nonstatic_concrete_methods(_has_nonstatic_concrete_methods); ik->set_declares_nonstatic_concrete_methods(_declares_nonstatic_concrete_methods); - if (_is_hidden) { - ik->set_is_hidden(); - } + assert(!_is_hidden || ik->is_hidden(), "must be set already"); // Set PackageEntry for this_klass oop cl = ik->class_loader(); @@ -5361,6 +5288,7 @@ ClassFileParser::ClassFileParser(ClassFileStream* stream, _is_hidden(cl_info->is_hidden()), _can_access_vm_annotations(cl_info->can_access_vm_annotations()), _orig_cp_size(0), + _static_oop_count(0), _super_klass(), _cp(nullptr), _fieldinfo_stream(nullptr), @@ -5381,7 +5309,6 @@ ClassFileParser::ClassFileParser(ClassFileStream* stream, _klass(nullptr), _klass_to_deallocate(nullptr), _parsed_annotations(nullptr), - _fac(nullptr), _field_info(nullptr), _temp_field_info(nullptr), _method_ordering(nullptr), @@ -5707,10 +5634,8 @@ void ClassFileParser::parse_stream(const ClassFileStream* const stream, assert(_local_interfaces != nullptr, "invariant"); // Fields (offsets are filled in later) - _fac = new FieldAllocationCount(); parse_fields(stream, _access_flags.is_interface(), - _fac, cp, cp_size, &_java_fields_count, @@ -5868,7 +5793,6 @@ void ClassFileParser::post_process_parsed_stream(const ClassFileStream* const st _itable_size = _access_flags.is_interface() ? 0 : klassItable::compute_itable_size(_transitive_interfaces); - assert(_fac != nullptr, "invariant"); assert(_parsed_annotations != nullptr, "invariant"); _field_info = new FieldLayoutInfo(); diff --git a/src/hotspot/share/classfile/classFileParser.hpp b/src/hotspot/share/classfile/classFileParser.hpp index 69d1f357ca5..d32dd6d5f78 100644 --- a/src/hotspot/share/classfile/classFileParser.hpp +++ b/src/hotspot/share/classfile/classFileParser.hpp @@ -86,7 +86,6 @@ class ClassFileParser { friend class FieldLayout; class ClassAnnotationCollector; - class FieldAllocationCount; class FieldAnnotationCollector; public: @@ -116,6 +115,7 @@ class ClassFileParser { const bool _is_hidden; const bool _can_access_vm_annotations; int _orig_cp_size; + unsigned int _static_oop_count; // Metadata created before the instance klass is created. Must be deallocated // if not transferred to the InstanceKlass upon successful class loading @@ -141,7 +141,6 @@ class ClassFileParser { InstanceKlass* _klass_to_deallocate; // an InstanceKlass* to be destroyed ClassAnnotationCollector* _parsed_annotations; - FieldAllocationCount* _fac; FieldLayoutInfo* _field_info; GrowableArray* _temp_field_info; const intArray* _method_ordering; @@ -260,7 +259,6 @@ class ClassFileParser { void parse_fields(const ClassFileStream* const cfs, bool is_interface, - FieldAllocationCount* const fac, ConstantPool* cp, const int cp_size, u2* const java_fields_count_ptr, @@ -549,6 +547,7 @@ class ClassFileParser { bool is_hidden() const { return _is_hidden; } bool is_interface() const { return _access_flags.is_interface(); } + bool is_abstract() const { return _access_flags.is_abstract(); } ClassLoaderData* loader_data() const { return _loader_data; } const Symbol* class_name() const { return _class_name; } diff --git a/src/hotspot/share/classfile/classLoader.cpp b/src/hotspot/share/classfile/classLoader.cpp index e410824e300..9a68e264044 100644 --- a/src/hotspot/share/classfile/classLoader.cpp +++ b/src/hotspot/share/classfile/classLoader.cpp @@ -81,6 +81,9 @@ #include "utilities/ostream.hpp" #include "utilities/utf8.hpp" +#include +#include + // Entry point in java.dll for path canonicalization typedef int (*canonicalize_fn_t)(const char *orig, char *out, int len); @@ -579,6 +582,8 @@ void ClassLoader::setup_module_search_path(JavaThread* current, const char* path new_entry = create_class_path_entry(current, path, &st, false /*is_boot_append */, false /* from_class_path_attr */); if (new_entry != nullptr) { + // ClassLoaderExt::process_module_table() filters out non-jar entries before calling this function. + assert(new_entry->is_jar_file(), "module path entry %s is not a jar file", new_entry->name()); add_to_module_path_entries(path, new_entry); } } @@ -834,7 +839,8 @@ bool ClassLoader::add_to_app_classpath_entries(JavaThread* current, ClassPathEntry* e = _app_classpath_entries; if (check_for_duplicates) { while (e != nullptr) { - if (strcmp(e->name(), entry->name()) == 0) { + if (strcmp(e->name(), entry->name()) == 0 && + e->from_class_path_attr() == entry->from_class_path_attr()) { // entry already exists return false; } @@ -1208,7 +1214,7 @@ InstanceKlass* ClassLoader::load_class(Symbol* name, PackageEntry* pkg_entry, bo } #if INCLUDE_CDS -char* ClassLoader::skip_uri_protocol(char* source) { +static const char* skip_uri_protocol(const char* source) { if (strncmp(source, "file:", 5) == 0) { // file: protocol path could start with file:/ or file:/// // locate the char after all the forward slashes @@ -1227,6 +1233,47 @@ char* ClassLoader::skip_uri_protocol(char* source) { return source; } +static char decode_percent_encoded(const char *str, size_t& index) { + if (str[index] == '%' + && isxdigit(str[index + 1]) + && isxdigit(str[index + 2])) { + char hex[3]; + hex[0] = str[index + 1]; + hex[1] = str[index + 2]; + hex[2] = '\0'; + index += 2; + return (char) strtol(hex, NULL, 16); + } + return str[index]; +} + +char* ClassLoader::uri_to_path(const char* uri) { + const size_t len = strlen(uri) + 1; + char* path = NEW_RESOURCE_ARRAY(char, len); + + uri = skip_uri_protocol(uri); + + if (strncmp(uri, "//", 2) == 0) { + // Skip the empty "authority" part + uri += 2; + } + +#ifdef _WINDOWS + if (uri[0] == '/') { + // Absolute path name on Windows does not begin with a slash + uri += 1; + } +#endif + + size_t path_index = 0; + for (size_t i = 0; i < strlen(uri); ++i) { + char decoded = decode_percent_encoded(uri, i); + path[path_index++] = decoded; + } + path[path_index] = '\0'; + return path; +} + // Record the shared classpath index and loader type for classes loaded // by the builtin loaders at dump time. void ClassLoader::record_result(JavaThread* current, InstanceKlass* ik, @@ -1260,7 +1307,7 @@ void ClassLoader::record_result(JavaThread* current, InstanceKlass* ik, // Save the path from the file: protocol or the module name from the jrt: protocol // if no protocol prefix is found, path is the same as stream->source(). This path // must be valid since the class has been successfully parsed. - char* path = skip_uri_protocol(src); + const char* path = ClassLoader::uri_to_path(src); assert(path != nullptr, "sanity"); for (int i = 0; i < FileMapInfo::get_number_of_shared_paths(); i++) { SharedClassPathEntry* ent = FileMapInfo::shared_path(i); diff --git a/src/hotspot/share/classfile/classLoader.hpp b/src/hotspot/share/classfile/classLoader.hpp index af625082dda..e44059b7247 100644 --- a/src/hotspot/share/classfile/classLoader.hpp +++ b/src/hotspot/share/classfile/classLoader.hpp @@ -382,7 +382,7 @@ class ClassLoader: AllStatic { // entries during shared classpath setup time. static int num_module_path_entries(); static void exit_with_path_failure(const char* error, const char* message); - static char* skip_uri_protocol(char* source); + static char* uri_to_path(const char* uri); static void record_result(JavaThread* current, InstanceKlass* ik, const ClassFileStream* stream, bool redefined); #endif diff --git a/src/hotspot/share/classfile/classLoaderExt.cpp b/src/hotspot/share/classfile/classLoaderExt.cpp index 78e29f990d7..16981669deb 100644 --- a/src/hotspot/share/classfile/classLoaderExt.cpp +++ b/src/hotspot/share/classfile/classLoaderExt.cpp @@ -55,6 +55,7 @@ jshort ClassLoaderExt::_app_class_paths_start_index = ClassLoaderExt::max_classpath_index; jshort ClassLoaderExt::_app_module_paths_start_index = ClassLoaderExt::max_classpath_index; jshort ClassLoaderExt::_max_used_path_index = 0; +int ClassLoaderExt::_num_module_paths = 0; bool ClassLoaderExt::_has_app_classes = false; bool ClassLoaderExt::_has_platform_classes = false; bool ClassLoaderExt::_has_non_jar_in_classpath = false; @@ -89,23 +90,25 @@ void ClassLoaderExt::setup_app_search_path(JavaThread* current) { os::free(app_class_path); } +int ClassLoaderExt::compare_module_path_by_name(const char** p1, const char** p2) { + return strcmp(*p1, *p2); +} + void ClassLoaderExt::process_module_table(JavaThread* current, ModuleEntryTable* met) { ResourceMark rm(current); - GrowableArray* module_paths = new GrowableArray(5); + GrowableArray* module_paths = new GrowableArray(5); class ModulePathsGatherer : public ModuleClosure { JavaThread* _current; - GrowableArray* _module_paths; + GrowableArray* _module_paths; public: - ModulePathsGatherer(JavaThread* current, GrowableArray* module_paths) : + ModulePathsGatherer(JavaThread* current, GrowableArray* module_paths) : _current(current), _module_paths(module_paths) {} void do_module(ModuleEntry* m) { - char* path = m->location()->as_C_string(); - if (strncmp(path, "file:", 5) == 0) { - path = ClassLoader::skip_uri_protocol(path); - char* path_copy = NEW_RESOURCE_ARRAY(char, strlen(path) + 1); - strcpy(path_copy, path); - _module_paths->append(path_copy); + char* uri = m->location()->as_C_string(); + if (strncmp(uri, "file:", 5) == 0) { + char* path = ClassLoader::uri_to_path(uri); + extract_jar_files_from_path(path, _module_paths); } } }; @@ -116,6 +119,10 @@ void ClassLoaderExt::process_module_table(JavaThread* current, ModuleEntryTable* met->modules_do(&gatherer); } + // Sort the module paths before storing into CDS archive for simpler + // checking at runtime. + module_paths->sort(compare_module_path_by_name); + for (int i = 0; i < module_paths->length(); i++) { ClassLoader::setup_module_search_path(current, module_paths->at(i)); } @@ -131,6 +138,38 @@ void ClassLoaderExt::setup_module_paths(JavaThread* current) { process_module_table(current, met); } +bool ClassLoaderExt::has_jar_suffix(const char* filename) { + // In jdk.internal.module.ModulePath.readModule(), it checks for the ".jar" suffix. + // Performing the same check here. + const char* dot = strrchr(filename, '.'); + if (dot != nullptr && strcmp(dot + 1, "jar") == 0) { + return true; + } + return false; +} + +void ClassLoaderExt::extract_jar_files_from_path(const char* path, GrowableArray* module_paths) { + DIR* dirp = os::opendir(path); + if (dirp == nullptr && errno == ENOTDIR && has_jar_suffix(path)) { + module_paths->append(path); + } else { + if (dirp != nullptr) { + struct dirent* dentry; + while ((dentry = os::readdir(dirp)) != nullptr) { + const char* file_name = dentry->d_name; + if (has_jar_suffix(file_name)) { + size_t full_name_len = strlen(path) + strlen(file_name) + strlen(os::file_separator()) + 1; + char* full_name = NEW_RESOURCE_ARRAY(char, full_name_len); + int n = os::snprintf(full_name, full_name_len, "%s%s%s", path, os::file_separator(), file_name); + assert((size_t)n == full_name_len - 1, "Unexpected number of characters in string"); + module_paths->append(full_name); + } + } + os::closedir(dirp); + } + } +} + char* ClassLoaderExt::read_manifest(JavaThread* current, ClassPathEntry* entry, jint *manifest_size, bool clean_text) { const char* name = "META-INF/MANIFEST.MF"; @@ -213,6 +252,15 @@ void ClassLoaderExt::process_jar_manifest(JavaThread* current, ClassPathEntry* e char sep = os::file_separator()[0]; const char* dir_name = entry->name(); const char* dir_tail = strrchr(dir_name, sep); +#ifdef _WINDOWS + // On Windows, we also support forward slash as the file separator when locating entries in the classpath entry. + const char* dir_tail2 = strrchr(dir_name, '/'); + if (dir_tail == nullptr) { + dir_tail = dir_tail2; + } else if (dir_tail2 != nullptr && dir_tail2 > dir_tail) { + dir_tail = dir_tail2; + } +#endif int dir_len; if (dir_tail == nullptr) { dir_len = 0; diff --git a/src/hotspot/share/classfile/classLoaderExt.hpp b/src/hotspot/share/classfile/classLoaderExt.hpp index b76ce3ff33a..c3c0b00d55e 100644 --- a/src/hotspot/share/classfile/classLoaderExt.hpp +++ b/src/hotspot/share/classfile/classLoaderExt.hpp @@ -53,12 +53,15 @@ private: static jshort _app_module_paths_start_index; // the largest path index being used during CDS dump time static jshort _max_used_path_index; + // number of module paths + static int _num_module_paths; static bool _has_app_classes; static bool _has_platform_classes; static bool _has_non_jar_in_classpath; static char* read_manifest(JavaThread* current, ClassPathEntry* entry, jint *manifest_size, bool clean_text); + static bool has_jar_suffix(const char* filename); public: static void process_jar_manifest(JavaThread* current, ClassPathEntry* entry); @@ -68,6 +71,8 @@ public: static void setup_search_paths(JavaThread* current); static void setup_module_paths(JavaThread* current); + static void extract_jar_files_from_path(const char* path, GrowableArray* module_paths); + static int compare_module_path_by_name(const char** p1, const char** p2); static char* read_manifest(JavaThread* current, ClassPathEntry* entry, jint *manifest_size) { // Remove all the new-line continuations (which wrap long lines at 72 characters, see @@ -87,6 +92,8 @@ public: static jshort max_used_path_index() { return _max_used_path_index; } + static int num_module_paths() { return _num_module_paths; } + static void set_max_used_path_index(jshort used_index) { _max_used_path_index = used_index; } @@ -99,6 +106,10 @@ public: _app_module_paths_start_index = module_start; } + static void init_num_module_paths(int num_module_paths) { + _num_module_paths = num_module_paths; + } + static bool is_boot_classpath(int classpath_index) { return classpath_index < _app_class_paths_start_index; } diff --git a/src/hotspot/share/classfile/fieldLayoutBuilder.hpp b/src/hotspot/share/classfile/fieldLayoutBuilder.hpp index cda64788acf..9b0d80b2a55 100644 --- a/src/hotspot/share/classfile/fieldLayoutBuilder.hpp +++ b/src/hotspot/share/classfile/fieldLayoutBuilder.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -101,17 +101,13 @@ class LayoutRawBlock : public ResourceObj { // sort fields in decreasing order. // Note: with line types, the comparison should include alignment constraint if sizes are equals static int compare_size_inverted(LayoutRawBlock** x, LayoutRawBlock** y) { -#ifdef _WINDOWS - // qsort() on Windows reverse the order of fields with the same size - // the extension of the comparison function below preserves this order int diff = (*y)->size() - (*x)->size(); + // qsort() may reverse the order of fields with the same size. + // The extension is to ensure stable sort. if (diff == 0) { diff = (*x)->field_index() - (*y)->field_index(); } return diff; -#else - return (*y)->size() - (*x)->size(); -#endif // _WINDOWS } }; diff --git a/src/hotspot/share/classfile/javaClasses.cpp b/src/hotspot/share/classfile/javaClasses.cpp index b6ef682ae09..0ad36cd21db 100644 --- a/src/hotspot/share/classfile/javaClasses.cpp +++ b/src/hotspot/share/classfile/javaClasses.cpp @@ -3052,9 +3052,10 @@ void java_lang_ClassFrameInfo::serialize_offsets(SerializeClosure* f) { static int get_flags(const methodHandle& m) { int flags = (jushort)( m->access_flags().as_short() & JVM_RECOGNIZED_METHOD_MODIFIERS ); - if (m->is_initializer()) { + if (m->is_object_initializer()) { flags |= java_lang_invoke_MemberName::MN_IS_CONSTRUCTOR; } else { + // Note: Static initializers can be here. Record them as plain methods. flags |= java_lang_invoke_MemberName::MN_IS_METHOD; } if (m->caller_sensitive()) { diff --git a/src/hotspot/share/classfile/symbolTable.cpp b/src/hotspot/share/classfile/symbolTable.cpp index 19306a2a9db..50453cee61d 100644 --- a/src/hotspot/share/classfile/symbolTable.cpp +++ b/src/hotspot/share/classfile/symbolTable.cpp @@ -174,7 +174,8 @@ public: log_trace_symboltable_helper(&value, "Freeing permanent symbol"); size_t alloc_size = SymbolTableHash::get_dynamic_node_size(value.byte_size()); if (!SymbolTable::arena()->Afree(memory, alloc_size)) { - log_trace_symboltable_helper(&value, "Leaked permanent symbol"); + // Can't access the symbol after Afree, but we just printed it above. + NOT_PRODUCT(log_trace(symboltable)(" - Leaked permanent symbol");) } } SymbolTable::item_removed(); diff --git a/src/hotspot/share/classfile/systemDictionary.cpp b/src/hotspot/share/classfile/systemDictionary.cpp index e32d124013d..7b307a0b8a3 100644 --- a/src/hotspot/share/classfile/systemDictionary.cpp +++ b/src/hotspot/share/classfile/systemDictionary.cpp @@ -285,8 +285,7 @@ Symbol* SystemDictionary::class_name_symbol(const char* name, Symbol* exception, return nullptr; } // Callers should ensure that the name is never an illegal UTF8 string. - assert(UTF8::is_legal_utf8((const unsigned char*)name, - static_cast(name_len), false), + assert(UTF8::is_legal_utf8((const unsigned char*)name, name_len, false), "Class name is not a valid utf8 string."); // Make a new symbol for the class name. @@ -1070,7 +1069,7 @@ bool SystemDictionary::check_shared_class_super_type(InstanceKlass* klass, Insta } Klass *found = resolve_with_circularity_detection(klass->name(), super_type->name(), - class_loader, protection_domain, is_superclass, CHECK_0); + class_loader, protection_domain, is_superclass, CHECK_false); if (found == super_type) { return true; } else { @@ -1089,16 +1088,21 @@ bool SystemDictionary::check_shared_class_super_types(InstanceKlass* ik, Handle // If unexpected superclass or interfaces are found, we cannot // load from the shared archive. - if (ik->super() != nullptr && - !check_shared_class_super_type(ik, InstanceKlass::cast(ik->super()), - class_loader, protection_domain, true, THREAD)) { - return false; + if (ik->super() != nullptr) { + bool check_super = check_shared_class_super_type(ik, InstanceKlass::cast(ik->super()), + class_loader, protection_domain, true, + CHECK_false); + if (!check_super) { + return false; + } } Array* interfaces = ik->local_interfaces(); int num_interfaces = interfaces->length(); for (int index = 0; index < num_interfaces; index++) { - if (!check_shared_class_super_type(ik, interfaces->at(index), class_loader, protection_domain, false, THREAD)) { + bool check_interface = check_shared_class_super_type(ik, interfaces->at(index), class_loader, protection_domain, false, + CHECK_false); + if (!check_interface) { return false; } } @@ -1150,10 +1154,13 @@ InstanceKlass* SystemDictionary::load_shared_class(InstanceKlass* ik, Symbol* class_name = ik->name(); if (!is_shared_class_visible(class_name, ik, pkg_entry, class_loader)) { + ik->set_shared_loading_failed(); return nullptr; } - if (!check_shared_class_super_types(ik, class_loader, protection_domain, THREAD)) { + bool check = check_shared_class_super_types(ik, class_loader, protection_domain, CHECK_NULL); + if (!check) { + ik->set_shared_loading_failed(); return nullptr; } diff --git a/src/hotspot/share/classfile/systemDictionary.hpp b/src/hotspot/share/classfile/systemDictionary.hpp index ee50aa38dd0..04980291716 100644 --- a/src/hotspot/share/classfile/systemDictionary.hpp +++ b/src/hotspot/share/classfile/systemDictionary.hpp @@ -293,13 +293,6 @@ public: const char* message); static const char* find_nest_host_error(const constantPoolHandle& pool, int which); -protected: - static InstanceKlass* _well_known_klasses[]; - -private: - // table of box klasses (int_klass, etc.) - static InstanceKlass* _box_klasses[T_VOID+1]; - static OopHandle _java_system_loader; static OopHandle _java_platform_loader; diff --git a/src/hotspot/share/classfile/systemDictionaryShared.cpp b/src/hotspot/share/classfile/systemDictionaryShared.cpp index 8bb06e6dca4..ce7f862a7b6 100644 --- a/src/hotspot/share/classfile/systemDictionaryShared.cpp +++ b/src/hotspot/share/classfile/systemDictionaryShared.cpp @@ -274,9 +274,16 @@ bool SystemDictionaryShared::check_for_exclusion_impl(InstanceKlass* k) { return warn_excluded(k, "Has been redefined"); } if (!k->is_hidden() && k->shared_classpath_index() < 0 && is_builtin(k)) { - // These are classes loaded from unsupported locations (such as those loaded by JVMTI native - // agent during dump time). - return warn_excluded(k, "Unsupported location"); + if (k->name()->starts_with("java/lang/invoke/BoundMethodHandle$Species_")) { + // This class is dynamically generated by the JDK + ResourceMark rm; + log_info(cds)("Skipping %s because it is dynamically generated", k->name()->as_C_string()); + return true; // exclude without warning + } else { + // These are classes loaded from unsupported locations (such as those loaded by JVMTI native + // agent during dump time). + return warn_excluded(k, "Unsupported location"); + } } if (k->signers() != nullptr) { // We cannot include signed classes in the archive because the certificates diff --git a/src/hotspot/share/classfile/vmClasses.cpp b/src/hotspot/share/classfile/vmClasses.cpp index 0b9b437c67b..b62d699dfe2 100644 --- a/src/hotspot/share/classfile/vmClasses.cpp +++ b/src/hotspot/share/classfile/vmClasses.cpp @@ -45,14 +45,6 @@ InstanceKlass* vmClasses::_klasses[static_cast(vmClassID::LIMIT)] = { nullptr /*, nullptr...*/ }; InstanceKlass* vmClasses::_box_klasses[T_VOID+1] = { nullptr /*, nullptr...*/ }; - -// CDS: scan and relocate all classes referenced by _klasses[]. -void vmClasses::metaspace_pointers_do(MetaspaceClosure* it) { - for (auto id : EnumRange{}) { - it->push(klass_addr_at(id)); - } -} - bool vmClasses::is_loaded(InstanceKlass* klass) { return klass != nullptr && klass->is_loaded(); } @@ -205,8 +197,6 @@ void vmClasses::resolve_all(TRAPS) { _box_klasses[T_SHORT] = vmClasses::Short_klass(); _box_klasses[T_INT] = vmClasses::Integer_klass(); _box_klasses[T_LONG] = vmClasses::Long_klass(); - //_box_klasses[T_OBJECT] = vmClasses::object_klass(); - //_box_klasses[T_ARRAY] = vmClasses::object_klass(); #ifdef ASSERT if (CDSConfig::is_using_archive()) { diff --git a/src/hotspot/share/classfile/vmClasses.hpp b/src/hotspot/share/classfile/vmClasses.hpp index f2b8c5666ee..4fa078c50cd 100644 --- a/src/hotspot/share/classfile/vmClasses.hpp +++ b/src/hotspot/share/classfile/vmClasses.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,6 @@ class ClassLoaderData; class InstanceKlass; -class MetaspaceClosure; class vmClasses : AllStatic { friend class VMStructs; @@ -95,7 +94,6 @@ public: return &_klasses[as_int(id)]; } - static void metaspace_pointers_do(MetaspaceClosure* it); static void resolve_all(TRAPS); static BasicType box_klass_type(Klass* k); // inverse of box_klass diff --git a/src/hotspot/share/classfile/vmIntrinsics.cpp b/src/hotspot/share/classfile/vmIntrinsics.cpp index b470eb9b838..5e352e42efb 100644 --- a/src/hotspot/share/classfile/vmIntrinsics.cpp +++ b/src/hotspot/share/classfile/vmIntrinsics.cpp @@ -90,6 +90,7 @@ bool vmIntrinsics::preserves_state(vmIntrinsics::ID id) { case vmIntrinsics::_dsin: case vmIntrinsics::_dcos: case vmIntrinsics::_dtan: + case vmIntrinsics::_dtanh: case vmIntrinsics::_dlog: case vmIntrinsics::_dlog10: case vmIntrinsics::_dexp: @@ -141,6 +142,7 @@ bool vmIntrinsics::can_trap(vmIntrinsics::ID id) { case vmIntrinsics::_dsin: case vmIntrinsics::_dcos: case vmIntrinsics::_dtan: + case vmIntrinsics::_dtanh: case vmIntrinsics::_dlog: case vmIntrinsics::_dlog10: case vmIntrinsics::_dexp: @@ -288,6 +290,7 @@ bool vmIntrinsics::disabled_by_jvm_flags(vmIntrinsics::ID id) { case vmIntrinsics::_dsin: case vmIntrinsics::_dcos: case vmIntrinsics::_dtan: + case vmIntrinsics::_dtanh: case vmIntrinsics::_dlog: case vmIntrinsics::_dexp: case vmIntrinsics::_dpow: diff --git a/src/hotspot/share/classfile/vmIntrinsics.hpp b/src/hotspot/share/classfile/vmIntrinsics.hpp index 4b772c171d5..b6ce21797a6 100644 --- a/src/hotspot/share/classfile/vmIntrinsics.hpp +++ b/src/hotspot/share/classfile/vmIntrinsics.hpp @@ -135,7 +135,7 @@ class methodHandle; do_name(log_name,"log") do_name(log10_name,"log10") do_name(pow_name,"pow") \ do_name(exp_name,"exp") do_name(min_name,"min") do_name(max_name,"max") \ do_name(floor_name, "floor") do_name(ceil_name, "ceil") do_name(rint_name, "rint") \ - do_name(round_name, "round") \ + do_name(round_name, "round") do_name(tanh_name,"tanh") \ \ do_name(addExact_name,"addExact") \ do_name(decrementExact_name,"decrementExact") \ @@ -161,6 +161,7 @@ class methodHandle; do_intrinsic(_dcos, java_lang_Math, cos_name, double_double_signature, F_S) \ do_intrinsic(_dtan, java_lang_Math, tan_name, double_double_signature, F_S) \ do_intrinsic(_datan2, java_lang_Math, atan2_name, double2_double_signature, F_S) \ + do_intrinsic(_dtanh, java_lang_Math, tanh_name, double_double_signature, F_S) \ do_intrinsic(_dsqrt, java_lang_Math, sqrt_name, double_double_signature, F_S) \ do_intrinsic(_dlog, java_lang_Math, log_name, double_double_signature, F_S) \ do_intrinsic(_dlog10, java_lang_Math, log10_name, double_double_signature, F_S) \ @@ -1007,6 +1008,15 @@ class methodHandle; "Ljdk/internal/vm/vector/VectorSupport$Vector;") \ do_name(vector_shuffle_to_vector_name, "shuffleToVector") \ \ + do_intrinsic(_VectorWrapShuffleIndexes, jdk_internal_vm_vector_VectorSupport, vector_wrap_shuffle_indexes_name, \ + vector_wrap_shuffle_indexes_sig, F_S) \ + do_signature(vector_wrap_shuffle_indexes_sig, "(Ljava/lang/Class;" \ + "Ljava/lang/Class;" \ + "Ljdk/internal/vm/vector/VectorSupport$VectorShuffle;" \ + "ILjdk/internal/vm/vector/VectorSupport$WrapShuffleIndexesOperation;)" \ + "Ljdk/internal/vm/vector/VectorSupport$VectorShuffle;") \ + do_name(vector_wrap_shuffle_indexes_name, "wrapShuffleIndexes") \ + \ do_intrinsic(_VectorLoadOp, jdk_internal_vm_vector_VectorSupport, vector_load_op_name, vector_load_op_sig, F_S) \ do_signature(vector_load_op_sig, "(Ljava/lang/Class;" \ "Ljava/lang/Class;" \ @@ -1128,6 +1138,18 @@ class methodHandle; "Ljdk/internal/vm/vector/VectorSupport$Vector;") \ do_name(vector_rearrange_name, "rearrangeOp") \ \ + do_intrinsic(_VectorSelectFrom, jdk_internal_vm_vector_VectorSupport, vector_select_from_name, vector_select_from_sig, F_S) \ + do_signature(vector_select_from_sig, "(Ljava/lang/Class;" \ + "Ljava/lang/Class;" \ + "Ljava/lang/Class;" \ + "I" \ + "Ljdk/internal/vm/vector/VectorSupport$Vector;" \ + "Ljdk/internal/vm/vector/VectorSupport$Vector;" \ + "Ljdk/internal/vm/vector/VectorSupport$VectorMask;" \ + "Ljdk/internal/vm/vector/VectorSupport$VectorSelectFromOp;)" \ + "Ljdk/internal/vm/vector/VectorSupport$Vector;") \ + do_name(vector_select_from_name, "selectFromOp") \ + \ do_intrinsic(_VectorExtract, jdk_internal_vm_vector_VectorSupport, vector_extract_name, vector_extract_sig, F_S) \ do_signature(vector_extract_sig, "(Ljava/lang/Class;" \ "Ljava/lang/Class;" \ diff --git a/src/hotspot/share/code/codeBlob.cpp b/src/hotspot/share/code/codeBlob.cpp index 81c4d001078..23f621ffec8 100644 --- a/src/hotspot/share/code/codeBlob.cpp +++ b/src/hotspot/share/code/codeBlob.cpp @@ -41,7 +41,7 @@ #include "runtime/handles.inline.hpp" #include "runtime/interfaceSupport.inline.hpp" #include "runtime/javaFrameAnchor.hpp" -#include "runtime/jniHandles.hpp" +#include "runtime/jniHandles.inline.hpp" #include "runtime/mutexLocker.hpp" #include "runtime/safepoint.hpp" #include "runtime/sharedRuntime.hpp" @@ -623,7 +623,7 @@ UpcallStub* UpcallStub::create(const char* name, CodeBuffer* cb, jobject receive // Track memory usage statistic after releasing CodeCache_lock MemoryService::track_code_cache_memory_usage(); - trace_new_stub(blob, "UpcallStub"); + trace_new_stub(blob, "UpcallStub - ", name); return blob; } @@ -772,6 +772,10 @@ void UpcallStub::verify() { void UpcallStub::print_on(outputStream* st) const { RuntimeBlob::print_on(st); print_value_on(st); + st->print_cr("Frame data offset: %d", (int) _frame_data_offset); + oop recv = JNIHandles::resolve(_receiver); + st->print("Receiver MH="); + recv->print_on(st); Disassembler::decode((RuntimeBlob*)this, st); } diff --git a/src/hotspot/share/code/codeBlob.hpp b/src/hotspot/share/code/codeBlob.hpp index 26ae5f7df59..8ecd9e21537 100644 --- a/src/hotspot/share/code/codeBlob.hpp +++ b/src/hotspot/share/code/codeBlob.hpp @@ -595,6 +595,7 @@ class UpcallLinker; // A (Panama) upcall stub. Not used by JNI. class UpcallStub: public RuntimeBlob { + friend class VMStructs; friend class UpcallLinker; private: jobject _receiver; diff --git a/src/hotspot/share/code/codeCache.cpp b/src/hotspot/share/code/codeCache.cpp index 11e070862fe..f0769e240dd 100644 --- a/src/hotspot/share/code/codeCache.cpp +++ b/src/hotspot/share/code/codeCache.cpp @@ -1767,9 +1767,13 @@ void CodeCache::print_codelist(outputStream* st) { nmethod* nm = iter.method(); ResourceMark rm; char* method_name = nm->method()->name_and_sig_as_C_string(); - st->print_cr("%d %d %d %s [" INTPTR_FORMAT ", " INTPTR_FORMAT " - " INTPTR_FORMAT "]", + const char* jvmci_name = nullptr; +#if INCLUDE_JVMCI + jvmci_name = nm->jvmci_name(); +#endif + st->print_cr("%d %d %d %s%s%s [" INTPTR_FORMAT ", " INTPTR_FORMAT " - " INTPTR_FORMAT "]", nm->compile_id(), nm->comp_level(), nm->get_state(), - method_name, + method_name, jvmci_name ? " jvmci_name=" : "", jvmci_name ? jvmci_name : "", (intptr_t)nm->header_begin(), (intptr_t)nm->code_begin(), (intptr_t)nm->code_end()); } } @@ -1811,12 +1815,20 @@ void CodeCache::write_perf_map(const char* filename, outputStream* st) { while (iter.next()) { CodeBlob *cb = iter.method(); ResourceMark rm; - const char* method_name = - cb->is_nmethod() ? cb->as_nmethod()->method()->external_name() - : cb->name(); - fs.print_cr(INTPTR_FORMAT " " INTPTR_FORMAT " %s", + const char* method_name = nullptr; + const char* jvmci_name = nullptr; + if (cb->is_nmethod()) { + nmethod* nm = cb->as_nmethod(); + method_name = nm->method()->external_name(); +#if INCLUDE_JVMCI + jvmci_name = nm->jvmci_name(); +#endif + } else { + method_name = cb->name(); + } + fs.print_cr(INTPTR_FORMAT " " INTPTR_FORMAT " %s%s%s", (intptr_t)cb->code_begin(), (intptr_t)cb->code_size(), - method_name); + method_name, jvmci_name ? " jvmci_name=" : "", jvmci_name ? jvmci_name : ""); } } #endif // LINUX diff --git a/src/hotspot/share/code/codeHeapState.cpp b/src/hotspot/share/code/codeHeapState.cpp index 48c8410ac47..1ea3f258dd2 100644 --- a/src/hotspot/share/code/codeHeapState.cpp +++ b/src/hotspot/share/code/codeHeapState.cpp @@ -735,7 +735,16 @@ void CodeHeapState::aggregate(outputStream* out, CodeHeap* heap, size_t granular } else { blob_name = os::strdup(cb->name()); } - +#if INCLUDE_JVMCI + const char* jvmci_name = nm->jvmci_name(); + if (jvmci_name != nullptr) { + size_t size = ::strlen(blob_name) + ::strlen(" jvmci_name=") + ::strlen(jvmci_name) + 1; + char* new_blob_name = (char*)os::malloc(size, mtInternal); + os::snprintf(new_blob_name, size, "%s jvmci_name=%s", blob_name, jvmci_name); + os::free((void*)blob_name); + blob_name = new_blob_name; + } +#endif nm_size = nm->total_size(); compile_id = nm->compile_id(); comp_lvl = (CompLevel)(nm->comp_level()); @@ -2184,6 +2193,12 @@ void CodeHeapState::print_names(outputStream* out, CodeHeap* heap) { ast->print("%s.", classNameS); ast->print("%s", methNameS); ast->print("%s", methSigS); +#if INCLUDE_JVMCI + const char* jvmci_name = nm->jvmci_name(); + if (jvmci_name != nullptr) { + ast->print(" jvmci_name=%s", jvmci_name); + } +#endif } else { ast->print("%s", blob_name); } diff --git a/src/hotspot/share/code/compiledIC.cpp b/src/hotspot/share/code/compiledIC.cpp index 079c8199b18..684aee509ee 100644 --- a/src/hotspot/share/code/compiledIC.cpp +++ b/src/hotspot/share/code/compiledIC.cpp @@ -83,6 +83,7 @@ void CompiledICData::initialize(CallInfo* call_info, Klass* receiver_klass) { _speculated_klass = (uintptr_t)receiver_klass; } if (call_info->call_kind() == CallInfo::itable_call) { + assert(call_info->resolved_method() != nullptr, "virtual or interface method must be found"); _itable_defc_klass = call_info->resolved_method()->method_holder(); _itable_refc_klass = call_info->resolved_klass(); } @@ -238,6 +239,7 @@ void CompiledIC::set_to_megamorphic(CallInfo* call_info) { return; } #ifdef ASSERT + assert(call_info->resolved_method() != nullptr, "virtual or interface method must be found"); int index = call_info->resolved_method()->itable_index(); assert(index == itable_index, "CallInfo pre-computes this"); InstanceKlass* k = call_info->resolved_method()->method_holder(); @@ -254,6 +256,7 @@ void CompiledIC::set_to_megamorphic(CallInfo* call_info) { } } + assert(call_info->selected_method() != nullptr, "virtual or interface method must be found"); log_trace(inlinecache)("IC@" INTPTR_FORMAT ": to megamorphic %s entry: " INTPTR_FORMAT, p2i(_call->instruction_address()), call_info->selected_method()->print_value_string(), p2i(entry)); @@ -290,7 +293,7 @@ bool CompiledIC::is_monomorphic() const { } bool CompiledIC::is_megamorphic() const { - return VtableStubs::entry_point(destination()) != nullptr;; + return VtableStubs::entry_point(destination()) != nullptr; } bool CompiledIC::is_speculated_klass(Klass* receiver_klass) { diff --git a/src/hotspot/share/code/dependencies.cpp b/src/hotspot/share/code/dependencies.cpp index 074846e2e79..260da40b87a 100644 --- a/src/hotspot/share/code/dependencies.cpp +++ b/src/hotspot/share/code/dependencies.cpp @@ -893,7 +893,7 @@ void Dependencies::DepStream::print_dependency(outputStream* st, Klass* witness, void Dependencies::DepStream::initial_asserts(size_t byte_limit) { assert(must_be_in_vm(), "raw oops here"); _byte_limit = byte_limit; - _type = (DepType)(end_marker-1); // defeat "already at end" assert + _type = undefined_dependency; // defeat "already at end" assert assert((_code!=nullptr) + (_deps!=nullptr) == 1, "one or t'other"); } #endif //ASSERT diff --git a/src/hotspot/share/code/dependencies.hpp b/src/hotspot/share/code/dependencies.hpp index 124db0b1369..d11c51a66dc 100644 --- a/src/hotspot/share/code/dependencies.hpp +++ b/src/hotspot/share/code/dependencies.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -103,6 +103,9 @@ class Dependencies: public ResourceObj { // type now includes N, that is, all super types of N. // enum DepType { + // _type is initially set to -1, to prevent "already at end" assert + undefined_dependency = -1, + end_marker = 0, // An 'evol' dependency simply notes that the contents of the diff --git a/src/hotspot/share/code/dependencyContext.cpp b/src/hotspot/share/code/dependencyContext.cpp index d7ce8e92acf..0e6b99d172d 100644 --- a/src/hotspot/share/code/dependencyContext.cpp +++ b/src/hotspot/share/code/dependencyContext.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -227,6 +227,10 @@ void DependencyContext::remove_and_mark_for_deoptimization_all_dependents(Deopti } #ifndef PRODUCT +bool DependencyContext::is_empty() { + return dependencies() == nullptr; +} + void DependencyContext::print_dependent_nmethods(bool verbose) { int idx = 0; for (nmethodBucket* b = dependencies_not_unloading(); b != nullptr; b = b->next_not_unloading()) { diff --git a/src/hotspot/share/code/dependencyContext.hpp b/src/hotspot/share/code/dependencyContext.hpp index e8d2ac41d0d..13b845cb59d 100644 --- a/src/hotspot/share/code/dependencyContext.hpp +++ b/src/hotspot/share/code/dependencyContext.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -124,6 +124,7 @@ class DependencyContext : public StackObj { #ifndef PRODUCT void print_dependent_nmethods(bool verbose); + bool is_empty(); #endif //PRODUCT bool is_dependent_nmethod(nmethod* nm); }; diff --git a/src/hotspot/share/compiler/compilerDefinitions.cpp b/src/hotspot/share/compiler/compilerDefinitions.cpp index ee0c73254f1..7b091d8ade5 100644 --- a/src/hotspot/share/compiler/compilerDefinitions.cpp +++ b/src/hotspot/share/compiler/compilerDefinitions.cpp @@ -497,11 +497,6 @@ bool CompilerConfig::check_args_consistency(bool status) { "Invalid NonNMethodCodeHeapSize=%dK. Must be at least %uK.\n", NonNMethodCodeHeapSize/K, min_code_cache_size/K); status = false; - } else if (InlineCacheBufferSize > NonNMethodCodeHeapSize / 2) { - jio_fprintf(defaultStream::error_stream(), - "Invalid InlineCacheBufferSize=" SIZE_FORMAT "K. Must be less than or equal to " SIZE_FORMAT "K.\n", - InlineCacheBufferSize/K, NonNMethodCodeHeapSize/2/K); - status = false; } #ifdef _LP64 diff --git a/src/hotspot/share/compiler/methodLiveness.cpp b/src/hotspot/share/compiler/methodLiveness.cpp index 1b764882d10..7d65b20a159 100644 --- a/src/hotspot/share/compiler/methodLiveness.cpp +++ b/src/hotspot/share/compiler/methodLiveness.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -222,6 +222,9 @@ void MethodLiveness::init_basic_blocks() { dest = _block_map->at(bytes.get_dest()); assert(dest != nullptr, "branch destination must start a block."); dest->add_normal_predecessor(current_block); + if (bci + Bytecodes::length_for(code) >= method_len) { + break; + } BasicBlock *jsrExit = _block_map->at(current_block->limit_bci()); assert(jsrExit != nullptr, "jsr return bci must start a block."); jsr_exit_list->append(jsrExit); @@ -232,6 +235,9 @@ void MethodLiveness::init_basic_blocks() { dest = _block_map->at(bytes.get_far_dest()); assert(dest != nullptr, "branch destination must start a block."); dest->add_normal_predecessor(current_block); + if (bci + Bytecodes::length_for(code) >= method_len) { + break; + } BasicBlock *jsrExit = _block_map->at(current_block->limit_bci()); assert(jsrExit != nullptr, "jsr return bci must start a block."); jsr_exit_list->append(jsrExit); diff --git a/src/hotspot/share/compiler/oopMap.cpp b/src/hotspot/share/compiler/oopMap.cpp index 09b9feee3db..376057aa72e 100644 --- a/src/hotspot/share/compiler/oopMap.cpp +++ b/src/hotspot/share/compiler/oopMap.cpp @@ -246,10 +246,13 @@ private: }; void OopMapSort::sort() { +#ifdef ASSERT for (OopMapStream oms(_map); !oms.is_done(); oms.next()) { OopMapValue omv = oms.current(); - assert(omv.type() == OopMapValue::oop_value || omv.type() == OopMapValue::narrowoop_value || omv.type() == OopMapValue::derived_oop_value || omv.type() == OopMapValue::callee_saved_value, ""); + assert(omv.type() == OopMapValue::oop_value || omv.type() == OopMapValue::narrowoop_value || + omv.type() == OopMapValue::derived_oop_value || omv.type() == OopMapValue::callee_saved_value, ""); } +#endif for (OopMapStream oms(_map); !oms.is_done(); oms.next()) { if (oms.current().type() == OopMapValue::callee_saved_value) { diff --git a/src/hotspot/share/compiler/oopMap.inline.hpp b/src/hotspot/share/compiler/oopMap.inline.hpp index f2a3b3ba834..05ef53f8231 100644 --- a/src/hotspot/share/compiler/oopMap.inline.hpp +++ b/src/hotspot/share/compiler/oopMap.inline.hpp @@ -66,12 +66,10 @@ void OopMapDo::iterate_oops_do(const frame continue; #ifndef COMPILER2 - COMPILER1_PRESENT(ShouldNotReachHere();) #if INCLUDE_JVMCI - if (UseJVMCICompiler) { - ShouldNotReachHere(); - } + if (!EnableJVMCI) #endif + ShouldNotReachHere(); #endif // !COMPILER2 address loc = fr->oopmapreg_to_location(omv.reg(), reg_map); diff --git a/src/hotspot/share/gc/g1/c1/g1BarrierSetC1.cpp b/src/hotspot/share/gc/g1/c1/g1BarrierSetC1.cpp index f82b5cfcc55..449ff2e4acf 100644 --- a/src/hotspot/share/gc/g1/c1/g1BarrierSetC1.cpp +++ b/src/hotspot/share/gc/g1/c1/g1BarrierSetC1.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -219,8 +219,8 @@ class C1G1PostBarrierCodeGenClosure : public StubAssemblerCodeGenClosure { void G1BarrierSetC1::generate_c1_runtime_stubs(BufferBlob* buffer_blob) { C1G1PreBarrierCodeGenClosure pre_code_gen_cl; C1G1PostBarrierCodeGenClosure post_code_gen_cl; - _pre_barrier_c1_runtime_code_blob = Runtime1::generate_blob(buffer_blob, -1, "g1_pre_barrier_slow", + _pre_barrier_c1_runtime_code_blob = Runtime1::generate_blob(buffer_blob, C1StubId::NO_STUBID, "g1_pre_barrier_slow", false, &pre_code_gen_cl); - _post_barrier_c1_runtime_code_blob = Runtime1::generate_blob(buffer_blob, -1, "g1_post_barrier_slow", + _post_barrier_c1_runtime_code_blob = Runtime1::generate_blob(buffer_blob, C1StubId::NO_STUBID, "g1_post_barrier_slow", false, &post_code_gen_cl); } diff --git a/src/hotspot/share/gc/g1/c2/g1BarrierSetC2.cpp b/src/hotspot/share/gc/g1/c2/g1BarrierSetC2.cpp index 13b993546cd..4ec7e10cd9a 100644 --- a/src/hotspot/share/gc/g1/c2/g1BarrierSetC2.cpp +++ b/src/hotspot/share/gc/g1/c2/g1BarrierSetC2.cpp @@ -24,49 +24,32 @@ #include "precompiled.hpp" #include "classfile/javaClasses.hpp" +#include "code/vmreg.inline.hpp" #include "gc/g1/c2/g1BarrierSetC2.hpp" #include "gc/g1/g1BarrierSet.hpp" +#include "gc/g1/g1BarrierSetAssembler.hpp" #include "gc/g1/g1BarrierSetRuntime.hpp" #include "gc/g1/g1CardTable.hpp" #include "gc/g1/g1ThreadLocalData.hpp" #include "gc/g1/g1HeapRegion.hpp" #include "opto/arraycopynode.hpp" +#include "opto/block.hpp" #include "opto/compile.hpp" #include "opto/escape.hpp" #include "opto/graphKit.hpp" #include "opto/idealKit.hpp" +#include "opto/machnode.hpp" #include "opto/macro.hpp" +#include "opto/memnode.hpp" +#include "opto/node.hpp" +#include "opto/output.hpp" +#include "opto/regalloc.hpp" #include "opto/rootnode.hpp" +#include "opto/runtime.hpp" #include "opto/type.hpp" +#include "utilities/growableArray.hpp" #include "utilities/macros.hpp" -const TypeFunc *G1BarrierSetC2::write_ref_field_pre_entry_Type() { - const Type **fields = TypeTuple::fields(2); - fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // original field value - fields[TypeFunc::Parms+1] = TypeRawPtr::NOTNULL; // thread - const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields); - - // create result type (range) - fields = TypeTuple::fields(0); - const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0, fields); - - return TypeFunc::make(domain, range); -} - -const TypeFunc *G1BarrierSetC2::write_ref_field_post_entry_Type() { - const Type **fields = TypeTuple::fields(2); - fields[TypeFunc::Parms+0] = TypeRawPtr::NOTNULL; // Card addr - fields[TypeFunc::Parms+1] = TypeRawPtr::NOTNULL; // thread - const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields); - - // create result type (range) - fields = TypeTuple::fields(0); - const TypeTuple *range = TypeTuple::make(TypeFunc::Parms, fields); - - return TypeFunc::make(domain, range); -} - -#define __ ideal. /* * Determine if the G1 pre-barrier can be removed. The pre-barrier is * required by SATB to make sure all objects live at the start of the @@ -84,8 +67,6 @@ const TypeFunc *G1BarrierSetC2::write_ref_field_post_entry_Type() { * The compiler needs to determine that the object in which a field is about * to be written is newly allocated, and that no prior store to the same field * has happened since the allocation. - * - * Returns true if the pre-barrier can be removed */ bool G1BarrierSetC2::g1_can_remove_pre_barrier(GraphKit* kit, PhaseValues* phase, @@ -97,34 +78,28 @@ bool G1BarrierSetC2::g1_can_remove_pre_barrier(GraphKit* kit, AllocateNode* alloc = AllocateNode::Ideal_allocation(base); if (offset == Type::OffsetBot) { - return false; // cannot unalias unless there are precise offsets + return false; // Cannot unalias unless there are precise offsets. } - if (alloc == nullptr) { - return false; // No allocation found + return false; // No allocation found. } intptr_t size_in_bytes = type2aelembytes(bt); - - Node* mem = kit->memory(adr_idx); // start searching here... + Node* mem = kit->memory(adr_idx); // Start searching here. for (int cnt = 0; cnt < 50; cnt++) { - if (mem->is_Store()) { - Node* st_adr = mem->in(MemNode::Address); intptr_t st_offset = 0; Node* st_base = AddPNode::Ideal_base_and_offset(st_adr, phase, st_offset); if (st_base == nullptr) { - break; // inscrutable pointer + break; // Inscrutable pointer. } - - // Break we have found a store with same base and offset as ours so break if (st_base == base && st_offset == offset) { + // We have found a store with same base and offset as ours. break; } - if (st_offset != offset && st_offset != Type::OffsetBot) { const int MAX_STORE = BytesPerLong; if (st_offset >= offset + size_in_bytes || @@ -136,20 +111,18 @@ bool G1BarrierSetC2::g1_can_remove_pre_barrier(GraphKit* kit, // in the same sequence of RawMem effects. We sometimes initialize // a whole 'tile' of array elements with a single jint or jlong.) mem = mem->in(MemNode::Memory); - continue; // advance through independent store memory + continue; // Advance through independent store memory. } } - if (st_base != base && MemNode::detect_ptr_independence(base, alloc, st_base, AllocateNode::Ideal_allocation(st_base), phase)) { - // Success: The bases are provably independent. + // Success: the bases are provably independent. mem = mem->in(MemNode::Memory); - continue; // advance through independent store memory + continue; // Advance through independent store memory. } } else if (mem->is_Proj() && mem->in(0)->is_Initialize()) { - InitializeNode* st_init = mem->in(0)->as_Initialize(); AllocateNode* st_alloc = st_init->allocation(); @@ -157,7 +130,7 @@ bool G1BarrierSetC2::g1_can_remove_pre_barrier(GraphKit* kit, // The alloc variable is guaranteed to not be null here from earlier check. if (alloc == st_alloc) { // Check that the initialization is storing null so that no previous store - // has been moved up and directly write a reference + // has been moved up and directly write a reference. Node* captured_store = st_init->find_captured_store(offset, type2aelembytes(T_OBJECT), phase); @@ -166,164 +139,55 @@ bool G1BarrierSetC2::g1_can_remove_pre_barrier(GraphKit* kit, } } } - // Unless there is an explicit 'continue', we must bail out here, // because 'mem' is an inscrutable memory state (e.g., a call). break; } - return false; } -// G1 pre/post barriers -void G1BarrierSetC2::pre_barrier(GraphKit* kit, - bool do_load, - Node* ctl, - Node* obj, - Node* adr, - uint alias_idx, - Node* val, - const TypeOopPtr* val_type, - Node* pre_val, - BasicType bt) const { - // Some sanity checks - // Note: val is unused in this routine. - - if (do_load) { - // We need to generate the load of the previous value - assert(obj != nullptr, "must have a base"); - assert(adr != nullptr, "where are loading from?"); - assert(pre_val == nullptr, "loaded already?"); - assert(val_type != nullptr, "need a type"); - - if (use_ReduceInitialCardMarks() - && g1_can_remove_pre_barrier(kit, &kit->gvn(), adr, bt, alias_idx)) { - return; - } - - } else { - // In this case both val_type and alias_idx are unused. - assert(pre_val != nullptr, "must be loaded already"); - // Nothing to be done if pre_val is null. - if (pre_val->bottom_type() == TypePtr::NULL_PTR) return; - assert(pre_val->bottom_type()->basic_type() == T_OBJECT, "or we shouldn't be here"); - } - assert(bt == T_OBJECT, "or we shouldn't be here"); - - IdealKit ideal(kit, true); - - Node* tls = __ thread(); // ThreadLocalStorage - - Node* no_base = __ top(); - Node* zero = __ ConI(0); - Node* zeroX = __ ConX(0); - - float likely = PROB_LIKELY(0.999); - float unlikely = PROB_UNLIKELY(0.999); - - BasicType active_type = in_bytes(SATBMarkQueue::byte_width_of_active()) == 4 ? T_INT : T_BYTE; - assert(in_bytes(SATBMarkQueue::byte_width_of_active()) == 4 || in_bytes(SATBMarkQueue::byte_width_of_active()) == 1, "flag width"); - - // Offsets into the thread - const int marking_offset = in_bytes(G1ThreadLocalData::satb_mark_queue_active_offset()); - const int index_offset = in_bytes(G1ThreadLocalData::satb_mark_queue_index_offset()); - const int buffer_offset = in_bytes(G1ThreadLocalData::satb_mark_queue_buffer_offset()); - - // Now the actual pointers into the thread - Node* marking_adr = __ AddP(no_base, tls, __ ConX(marking_offset)); - Node* buffer_adr = __ AddP(no_base, tls, __ ConX(buffer_offset)); - Node* index_adr = __ AddP(no_base, tls, __ ConX(index_offset)); - - // Now some of the values - Node* marking = __ load(__ ctrl(), marking_adr, TypeInt::INT, active_type, Compile::AliasIdxRaw); - - // if (!marking) - __ if_then(marking, BoolTest::ne, zero, unlikely); { - BasicType index_bt = TypeX_X->basic_type(); - assert(sizeof(size_t) == type2aelembytes(index_bt), "Loading G1 SATBMarkQueue::_index with wrong size."); - Node* index = __ load(__ ctrl(), index_adr, TypeX_X, index_bt, Compile::AliasIdxRaw); - - if (do_load) { - // load original value - pre_val = __ load(__ ctrl(), adr, val_type, bt, alias_idx, false, MemNode::unordered, LoadNode::Pinned); - } - - // if (pre_val != nullptr) - __ if_then(pre_val, BoolTest::ne, kit->null()); { - Node* buffer = __ load(__ ctrl(), buffer_adr, TypeRawPtr::NOTNULL, T_ADDRESS, Compile::AliasIdxRaw); - - // is the queue for this thread full? - __ if_then(index, BoolTest::ne, zeroX, likely); { - - // decrement the index - Node* next_index = kit->gvn().transform(new SubXNode(index, __ ConX(sizeof(intptr_t)))); - - // Now get the buffer location we will log the previous value into and store it - Node *log_addr = __ AddP(no_base, buffer, next_index); - __ store(__ ctrl(), log_addr, pre_val, T_OBJECT, Compile::AliasIdxRaw, MemNode::unordered); - // update the index - __ store(__ ctrl(), index_adr, next_index, index_bt, Compile::AliasIdxRaw, MemNode::unordered); - - } __ else_(); { - - // logging buffer is full, call the runtime - const TypeFunc *tf = write_ref_field_pre_entry_Type(); - __ make_leaf_call(tf, CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_field_pre_entry), "write_ref_field_pre_entry", pre_val, tls); - } __ end_if(); // (!index) - } __ end_if(); // (pre_val != nullptr) - } __ end_if(); // (!marking) - - // Final sync IdealKit and GraphKit. - kit->final_sync(ideal); -} - /* - * G1 similar to any GC with a Young Generation requires a way to keep track of - * references from Old Generation to Young Generation to make sure all live + * G1, similar to any GC with a Young Generation, requires a way to keep track + * of references from Old Generation to Young Generation to make sure all live * objects are found. G1 also requires to keep track of object references * between different regions to enable evacuation of old regions, which is done - * as part of mixed collections. References are tracked in remembered sets and - * is continuously updated as reference are written to with the help of the - * post-barrier. + * as part of mixed collections. References are tracked in remembered sets, + * which are continuously updated as references are written to with the help of + * the post-barrier. * - * To reduce the number of updates to the remembered set the post-barrier - * filters updates to fields in objects located in the Young Generation, - * the same region as the reference, when the null is being written or - * if the card is already marked as dirty by an earlier write. + * To reduce the number of updates to the remembered set, the post-barrier + * filters out updates to fields in objects located in the Young Generation, the + * same region as the reference, when null is being written, or if the card is + * already marked as dirty by an earlier write. * * Under certain circumstances it is possible to avoid generating the - * post-barrier completely if it is possible during compile time to prove - * the object is newly allocated and that no safepoint exists between the - * allocation and the store. + * post-barrier completely, if it is possible during compile time to prove the + * object is newly allocated and that no safepoint exists between the allocation + * and the store. This can be seen as a compile-time version of the + * above-mentioned Young Generation filter. * - * In the case of slow allocation the allocation code must handle the barrier - * as part of the allocation in the case the allocated object is not located - * in the nursery; this would happen for humongous objects. - * - * Returns true if the post barrier can be removed + * In the case of a slow allocation, the allocation code must handle the barrier + * as part of the allocation if the allocated object is not located in the + * nursery; this would happen for humongous objects. */ bool G1BarrierSetC2::g1_can_remove_post_barrier(GraphKit* kit, - PhaseValues* phase, Node* store, + PhaseValues* phase, Node* store_ctrl, Node* adr) const { intptr_t offset = 0; Node* base = AddPNode::Ideal_base_and_offset(adr, phase, offset); AllocateNode* alloc = AllocateNode::Ideal_allocation(base); if (offset == Type::OffsetBot) { - return false; // cannot unalias unless there are precise offsets + return false; // Cannot unalias unless there are precise offsets. } - if (alloc == nullptr) { - return false; // No allocation found + return false; // No allocation found. } - // Start search from Store node - Node* mem = store->in(MemNode::Control); + Node* mem = store_ctrl; // Start search from Store node. if (mem->is_Proj() && mem->in(0)->is_Initialize()) { - InitializeNode* st_init = mem->in(0)->as_Initialize(); AllocateNode* st_alloc = st_init->allocation(); - // Make sure we are looking at the same allocation if (alloc == st_alloc) { return true; @@ -333,725 +197,362 @@ bool G1BarrierSetC2::g1_can_remove_post_barrier(GraphKit* kit, return false; } -// -// Update the card table and add card address to the queue -// -void G1BarrierSetC2::g1_mark_card(GraphKit* kit, - IdealKit& ideal, - Node* card_adr, - Node* oop_store, - uint oop_alias_idx, - Node* index, - Node* index_adr, - Node* buffer, - const TypeFunc* tf) const { - Node* zero = __ ConI(0); - Node* zeroX = __ ConX(0); - Node* no_base = __ top(); - BasicType card_bt = T_BYTE; - // Smash zero into card. MUST BE ORDERED WRT TO STORE - __ storeCM(__ ctrl(), card_adr, zero, oop_store, oop_alias_idx, card_bt, Compile::AliasIdxRaw); - - // Now do the queue work - __ if_then(index, BoolTest::ne, zeroX); { - - Node* next_index = kit->gvn().transform(new SubXNode(index, __ ConX(sizeof(intptr_t)))); - Node* log_addr = __ AddP(no_base, buffer, next_index); - - // Order, see storeCM. - __ store(__ ctrl(), log_addr, card_adr, T_ADDRESS, Compile::AliasIdxRaw, MemNode::unordered); - __ store(__ ctrl(), index_adr, next_index, TypeX_X->basic_type(), Compile::AliasIdxRaw, MemNode::unordered); - - } __ else_(); { - __ make_leaf_call(tf, CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_field_post_entry), "write_ref_field_post_entry", card_adr, __ thread()); - } __ end_if(); - -} - -void G1BarrierSetC2::post_barrier(GraphKit* kit, - Node* ctl, - Node* oop_store, - Node* obj, - Node* adr, - uint alias_idx, - Node* val, - BasicType bt, - bool use_precise) const { - // If we are writing a null then we need no post barrier - - if (val != nullptr && val->is_Con() && val->bottom_type() == TypePtr::NULL_PTR) { - // Must be null - const Type* t = val->bottom_type(); - assert(t == Type::TOP || t == TypePtr::NULL_PTR, "must be null"); - // No post barrier if writing null - return; - } - - if (use_ReduceInitialCardMarks() && obj == kit->just_allocated_object(kit->control())) { - // We can skip marks on a freshly-allocated object in Eden. - // Keep this code in sync with CardTableBarrierSet::on_slowpath_allocation_exit. - // That routine informs GC to take appropriate compensating steps, - // upon a slow-path allocation, so as to make this card-mark - // elision safe. - return; - } - - if (use_ReduceInitialCardMarks() - && g1_can_remove_post_barrier(kit, &kit->gvn(), oop_store, adr)) { - return; - } - - if (!use_precise) { - // All card marks for a (non-array) instance are in one place: - adr = obj; - } - // (Else it's an array (or unknown), and we want more precise card marks.) - assert(adr != nullptr, ""); - - IdealKit ideal(kit, true); - - Node* tls = __ thread(); // ThreadLocalStorage - - Node* no_base = __ top(); - float likely = PROB_LIKELY_MAG(3); - float unlikely = PROB_UNLIKELY_MAG(3); - Node* young_card = __ ConI((jint)G1CardTable::g1_young_card_val()); - Node* dirty_card = __ ConI((jint)G1CardTable::dirty_card_val()); - Node* zeroX = __ ConX(0); - - const TypeFunc *tf = write_ref_field_post_entry_Type(); - - // Offsets into the thread - const int index_offset = in_bytes(G1ThreadLocalData::dirty_card_queue_index_offset()); - const int buffer_offset = in_bytes(G1ThreadLocalData::dirty_card_queue_buffer_offset()); - - // Pointers into the thread - - Node* buffer_adr = __ AddP(no_base, tls, __ ConX(buffer_offset)); - Node* index_adr = __ AddP(no_base, tls, __ ConX(index_offset)); - - // Now some values - // Use ctrl to avoid hoisting these values past a safepoint, which could - // potentially reset these fields in the JavaThread. - Node* index = __ load(__ ctrl(), index_adr, TypeX_X, TypeX_X->basic_type(), Compile::AliasIdxRaw); - Node* buffer = __ load(__ ctrl(), buffer_adr, TypeRawPtr::NOTNULL, T_ADDRESS, Compile::AliasIdxRaw); - - // Convert the store obj pointer to an int prior to doing math on it - // Must use ctrl to prevent "integerized oop" existing across safepoint - Node* cast = __ CastPX(__ ctrl(), adr); - - // Divide pointer by card size - Node* card_offset = __ URShiftX( cast, __ ConI(CardTable::card_shift()) ); - - // Combine card table base and card offset - Node* card_adr = __ AddP(no_base, byte_map_base_node(kit), card_offset ); - - // If we know the value being stored does it cross regions? - - if (val != nullptr) { - // Does the store cause us to cross regions? - - // Should be able to do an unsigned compare of region_size instead of - // and extra shift. Do we have an unsigned compare?? - // Node* region_size = __ ConI(1 << G1HeapRegion::LogOfHRGrainBytes); - Node* xor_res = __ URShiftX ( __ XorX( cast, __ CastPX(__ ctrl(), val)), __ ConI(checked_cast(G1HeapRegion::LogOfHRGrainBytes))); - - // if (xor_res == 0) same region so skip - __ if_then(xor_res, BoolTest::ne, zeroX, likely); { - - // No barrier if we are storing a null. - __ if_then(val, BoolTest::ne, kit->null(), likely); { - - // Ok must mark the card if not already dirty - - // load the original value of the card - Node* card_val = __ load(__ ctrl(), card_adr, TypeInt::INT, T_BYTE, Compile::AliasIdxRaw); - - __ if_then(card_val, BoolTest::ne, young_card, unlikely); { - kit->sync_kit(ideal); - kit->insert_mem_bar(Op_MemBarVolatile, oop_store); - __ sync_kit(kit); - - Node* card_val_reload = __ load(__ ctrl(), card_adr, TypeInt::INT, T_BYTE, Compile::AliasIdxRaw); - __ if_then(card_val_reload, BoolTest::ne, dirty_card); { - g1_mark_card(kit, ideal, card_adr, oop_store, alias_idx, index, index_adr, buffer, tf); - } __ end_if(); - } __ end_if(); - } __ end_if(); - } __ end_if(); - } else { - // The Object.clone() intrinsic uses this path if !ReduceInitialCardMarks. - // We don't need a barrier here if the destination is a newly allocated object - // in Eden. Otherwise, GC verification breaks because we assume that cards in Eden - // are set to 'g1_young_gen' (see G1CardTable::verify_g1_young_region()). - assert(!use_ReduceInitialCardMarks(), "can only happen with card marking"); - Node* card_val = __ load(__ ctrl(), card_adr, TypeInt::INT, T_BYTE, Compile::AliasIdxRaw); - __ if_then(card_val, BoolTest::ne, young_card); { - g1_mark_card(kit, ideal, card_adr, oop_store, alias_idx, index, index_adr, buffer, tf); - } __ end_if(); - } - - // Final sync IdealKit and GraphKit. - kit->final_sync(ideal); -} - -// Helper that guards and inserts a pre-barrier. -void G1BarrierSetC2::insert_pre_barrier(GraphKit* kit, Node* base_oop, Node* offset, - Node* pre_val, bool need_mem_bar) const { - // We could be accessing the referent field of a reference object. If so, when G1 - // is enabled, we need to log the value in the referent field in an SATB buffer. - // This routine performs some compile time filters and generates suitable - // runtime filters that guard the pre-barrier code. - // Also add memory barrier for non volatile load from the referent field - // to prevent commoning of loads across safepoint. - - // Some compile time checks. - - // If offset is a constant, is it java_lang_ref_Reference::_reference_offset? - const TypeX* otype = offset->find_intptr_t_type(); - if (otype != nullptr && otype->is_con() && - otype->get_con() != java_lang_ref_Reference::referent_offset()) { - // Constant offset but not the reference_offset so just return - return; - } - - // We only need to generate the runtime guards for instances. - const TypeOopPtr* btype = base_oop->bottom_type()->isa_oopptr(); - if (btype != nullptr) { - if (btype->isa_aryptr()) { - // Array type so nothing to do - return; - } - - const TypeInstPtr* itype = btype->isa_instptr(); - if (itype != nullptr) { - // Can the klass of base_oop be statically determined to be - // _not_ a sub-class of Reference and _not_ Object? - ciKlass* klass = itype->instance_klass(); - if (klass->is_loaded() && - !klass->is_subtype_of(kit->env()->Reference_klass()) && - !kit->env()->Object_klass()->is_subtype_of(klass)) { - return; - } - } - } - - // The compile time filters did not reject base_oop/offset so - // we need to generate the following runtime filters - // - // if (offset == java_lang_ref_Reference::_reference_offset) { - // if (instance_of(base, java.lang.ref.Reference)) { - // pre_barrier(_, pre_val, ...); - // } - // } - - float likely = PROB_LIKELY( 0.999); - float unlikely = PROB_UNLIKELY(0.999); - - IdealKit ideal(kit); - - Node* referent_off = __ ConX(java_lang_ref_Reference::referent_offset()); - - __ if_then(offset, BoolTest::eq, referent_off, unlikely); { - // Update graphKit memory and control from IdealKit. - kit->sync_kit(ideal); - - Node* ref_klass_con = kit->makecon(TypeKlassPtr::make(kit->env()->Reference_klass())); - Node* is_instof = kit->gen_instanceof(base_oop, ref_klass_con); - - // Update IdealKit memory and control from graphKit. - __ sync_kit(kit); - - Node* one = __ ConI(1); - // is_instof == 0 if base_oop == nullptr - __ if_then(is_instof, BoolTest::eq, one, unlikely); { - - // Update graphKit from IdeakKit. - kit->sync_kit(ideal); - - // Use the pre-barrier to record the value in the referent field - pre_barrier(kit, false /* do_load */, - __ ctrl(), - nullptr /* obj */, nullptr /* adr */, max_juint /* alias_idx */, nullptr /* val */, nullptr /* val_type */, - pre_val /* pre_val */, - T_OBJECT); - if (need_mem_bar) { - // Add memory barrier to prevent commoning reads from this field - // across safepoint since GC can change its value. - kit->insert_mem_bar(Op_MemBarCPUOrder); - } - // Update IdealKit from graphKit. - __ sync_kit(kit); - - } __ end_if(); // _ref_type != ref_none - } __ end_if(); // offset == referent_offset - - // Final sync IdealKit and GraphKit. - kit->final_sync(ideal); -} - -#undef __ - Node* G1BarrierSetC2::load_at_resolved(C2Access& access, const Type* val_type) const { DecoratorSet decorators = access.decorators(); - Node* adr = access.addr().node(); - Node* obj = access.base(); - - bool anonymous = (decorators & C2_UNSAFE_ACCESS) != 0; - bool mismatched = (decorators & C2_MISMATCHED) != 0; - bool unknown = (decorators & ON_UNKNOWN_OOP_REF) != 0; - bool in_heap = (decorators & IN_HEAP) != 0; - bool in_native = (decorators & IN_NATIVE) != 0; bool on_weak = (decorators & ON_WEAK_OOP_REF) != 0; bool on_phantom = (decorators & ON_PHANTOM_OOP_REF) != 0; - bool is_unordered = (decorators & MO_UNORDERED) != 0; bool no_keepalive = (decorators & AS_NO_KEEPALIVE) != 0; - bool is_mixed = !in_heap && !in_native; - bool need_cpu_mem_bar = !is_unordered || mismatched || is_mixed; - - Node* top = Compile::current()->top(); - Node* offset = adr->is_AddP() ? adr->in(AddPNode::Offset) : top; - - // If we are reading the value of the referent field of a Reference - // object (either by using Unsafe directly or through reflection) - // then, if G1 is enabled, we need to record the referent in an - // SATB log buffer using the pre-barrier mechanism. - // Also we need to add memory barrier to prevent commoning reads - // from this field across safepoint since GC can change its value. - bool need_read_barrier = (((on_weak || on_phantom) && !no_keepalive) || - (in_heap && unknown && offset != top && obj != top)); - - if (!access.is_oop() || !need_read_barrier) { - return CardTableBarrierSetC2::load_at_resolved(access, val_type); + // If we are reading the value of the referent field of a Reference object, we + // need to record the referent in an SATB log buffer using the pre-barrier + // mechanism. Also we need to add a memory barrier to prevent commoning reads + // from this field across safepoints, since GC can change its value. + bool need_read_barrier = ((on_weak || on_phantom) && !no_keepalive); + if (access.is_oop() && need_read_barrier) { + access.set_barrier_data(G1C2BarrierPre); } - - assert(access.is_parse_access(), "entry not supported at optimization time"); - - C2ParseAccess& parse_access = static_cast(access); - GraphKit* kit = parse_access.kit(); - Node* load; - - Node* control = kit->control(); - const TypePtr* adr_type = access.addr().type(); - MemNode::MemOrd mo = access.mem_node_mo(); - bool requires_atomic_access = (decorators & MO_UNORDERED) == 0; - bool unaligned = (decorators & C2_UNALIGNED) != 0; - bool unsafe = (decorators & C2_UNSAFE_ACCESS) != 0; - // Pinned control dependency is the strictest. So it's ok to substitute it for any other. - load = kit->make_load(control, adr, val_type, access.type(), adr_type, mo, - LoadNode::Pinned, requires_atomic_access, unaligned, mismatched, unsafe, - access.barrier_data()); - - - if (on_weak || on_phantom) { - // Use the pre-barrier to record the value in the referent field - pre_barrier(kit, false /* do_load */, - kit->control(), - nullptr /* obj */, nullptr /* adr */, max_juint /* alias_idx */, nullptr /* val */, nullptr /* val_type */, - load /* pre_val */, T_OBJECT); - // Add memory barrier to prevent commoning reads from this field - // across safepoint since GC can change its value. - kit->insert_mem_bar(Op_MemBarCPUOrder); - } else if (unknown) { - // We do not require a mem bar inside pre_barrier if need_mem_bar - // is set: the barriers would be emitted by us. - insert_pre_barrier(kit, obj, offset, load, !need_cpu_mem_bar); - } - - return load; -} - -bool G1BarrierSetC2::is_gc_barrier_node(Node* node) const { - if (CardTableBarrierSetC2::is_gc_barrier_node(node)) { - return true; - } - if (node->Opcode() != Op_CallLeaf) { - return false; - } - CallLeafNode *call = node->as_CallLeaf(); - if (call->_name == nullptr) { - return false; - } - - return strcmp(call->_name, "write_ref_field_pre_entry") == 0 || strcmp(call->_name, "write_ref_field_post_entry") == 0; -} - -bool G1BarrierSetC2::is_g1_pre_val_load(Node* n) { - if (n->is_Load() && n->as_Load()->has_pinned_control_dependency()) { - // Make sure the only users of it are: CmpP, StoreP, and a call to write_ref_field_pre_entry - - // Skip possible decode - if (n->outcnt() == 1 && n->unique_out()->is_DecodeN()) { - n = n->unique_out(); - } - - if (n->outcnt() == 3) { - int found = 0; - for (SimpleDUIterator iter(n); iter.has_next(); iter.next()) { - Node* use = iter.get(); - if (use->is_Cmp() || use->is_Store()) { - ++found; - } else if (use->is_CallLeaf()) { - CallLeafNode* call = use->as_CallLeaf(); - if (strcmp(call->_name, "write_ref_field_pre_entry") == 0) { - ++found; - } - } - } - if (found == 3) { - return true; - } - } - } - return false; -} - -bool G1BarrierSetC2::is_gc_pre_barrier_node(Node *node) const { - return is_g1_pre_val_load(node); + return CardTableBarrierSetC2::load_at_resolved(access, val_type); } void G1BarrierSetC2::eliminate_gc_barrier(PhaseMacroExpand* macro, Node* node) const { - if (is_g1_pre_val_load(node)) { - macro->replace_node(node, macro->zerocon(node->as_Load()->bottom_type()->basic_type())); - } else { - assert(node->Opcode() == Op_CastP2X, "ConvP2XNode required"); - assert(node->outcnt() <= 2, "expects 1 or 2 users: Xor and URShift nodes"); - // It could be only one user, URShift node, in Object.clone() intrinsic - // but the new allocation is passed to arraycopy stub and it could not - // be scalar replaced. So we don't check the case. + eliminate_gc_barrier_data(node); +} - // An other case of only one user (Xor) is when the value check for null - // in G1 post barrier is folded after CCP so the code which used URShift - // is removed. - - // Take Region node before eliminating post barrier since it also - // eliminates CastP2X node when it has only one user. - Node* this_region = node->in(0); - assert(this_region != nullptr, ""); - - // Remove G1 post barrier. - - // Search for CastP2X->Xor->URShift->Cmp path which - // checks if the store done to a different from the value's region. - // And replace Cmp with #0 (false) to collapse G1 post barrier. - Node* xorx = node->find_out_with(Op_XorX); - if (xorx != nullptr) { - Node* shift = xorx->unique_out(); - Node* cmpx = shift->unique_out(); - assert(cmpx->is_Cmp() && cmpx->unique_out()->is_Bool() && - cmpx->unique_out()->as_Bool()->_test._test == BoolTest::ne, - "missing region check in G1 post barrier"); - macro->replace_node(cmpx, macro->makecon(TypeInt::CC_EQ)); - - // Remove G1 pre barrier. - - // Search "if (marking != 0)" check and set it to "false". - // There is no G1 pre barrier if previous stored value is null - // (for example, after initialization). - if (this_region->is_Region() && this_region->req() == 3) { - int ind = 1; - if (!this_region->in(ind)->is_IfFalse()) { - ind = 2; - } - if (this_region->in(ind)->is_IfFalse() && - this_region->in(ind)->in(0)->Opcode() == Op_If) { - Node* bol = this_region->in(ind)->in(0)->in(1); - assert(bol->is_Bool(), ""); - cmpx = bol->in(1); - if (bol->as_Bool()->_test._test == BoolTest::ne && - cmpx->is_Cmp() && cmpx->in(2) == macro->intcon(0) && - cmpx->in(1)->is_Load()) { - Node* adr = cmpx->in(1)->as_Load()->in(MemNode::Address); - const int marking_offset = in_bytes(G1ThreadLocalData::satb_mark_queue_active_offset()); - if (adr->is_AddP() && adr->in(AddPNode::Base) == macro->top() && - adr->in(AddPNode::Address)->Opcode() == Op_ThreadLocal && - adr->in(AddPNode::Offset) == macro->MakeConX(marking_offset)) { - macro->replace_node(cmpx, macro->makecon(TypeInt::CC_EQ)); - } - } - } - } - } else { - assert(!use_ReduceInitialCardMarks(), "can only happen with card marking"); - // This is a G1 post barrier emitted by the Object.clone() intrinsic. - // Search for the CastP2X->URShiftX->AddP->LoadB->Cmp path which checks if the card - // is marked as young_gen and replace the Cmp with 0 (false) to collapse the barrier. - Node* shift = node->find_out_with(Op_URShiftX); - assert(shift != nullptr, "missing G1 post barrier"); - Node* addp = shift->unique_out(); - Node* load = addp->find_out_with(Op_LoadB); - assert(load != nullptr, "missing G1 post barrier"); - Node* cmpx = load->unique_out(); - assert(cmpx->is_Cmp() && cmpx->unique_out()->is_Bool() && - cmpx->unique_out()->as_Bool()->_test._test == BoolTest::ne, - "missing card value check in G1 post barrier"); - macro->replace_node(cmpx, macro->makecon(TypeInt::CC_EQ)); - // There is no G1 pre barrier in this case - } - // Now CastP2X can be removed since it is used only on dead path - // which currently still alive until igvn optimize it. - assert(node->outcnt() == 0 || node->unique_out()->Opcode() == Op_URShiftX, ""); - macro->replace_node(node, macro->top()); +void G1BarrierSetC2::eliminate_gc_barrier_data(Node* node) const { + if (node->is_LoadStore()) { + LoadStoreNode* loadstore = node->as_LoadStore(); + loadstore->set_barrier_data(0); + } else if (node->is_Mem()) { + MemNode* mem = node->as_Mem(); + mem->set_barrier_data(0); } } -Node* G1BarrierSetC2::step_over_gc_barrier(Node* c) const { - if (!use_ReduceInitialCardMarks() && - c != nullptr && c->is_Region() && c->req() == 3) { - for (uint i = 1; i < c->req(); i++) { - if (c->in(i) != nullptr && c->in(i)->is_Region() && - c->in(i)->req() == 3) { - Node* r = c->in(i); - for (uint j = 1; j < r->req(); j++) { - if (r->in(j) != nullptr && r->in(j)->is_Proj() && - r->in(j)->in(0) != nullptr && - r->in(j)->in(0)->Opcode() == Op_CallLeaf && - r->in(j)->in(0)->as_Call()->entry_point() == CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_field_post_entry)) { - Node* call = r->in(j)->in(0); - c = c->in(i == 1 ? 2 : 1); - if (c != nullptr && c->Opcode() != Op_Parm) { - c = c->in(0); - if (c != nullptr) { - c = c->in(0); - assert(call->in(0) == nullptr || - call->in(0)->in(0) == nullptr || - call->in(0)->in(0)->in(0) == nullptr || - call->in(0)->in(0)->in(0)->in(0) == nullptr || - call->in(0)->in(0)->in(0)->in(0)->in(0) == nullptr || - c == call->in(0)->in(0)->in(0)->in(0)->in(0), "bad barrier shape"); - return c; - } - } - } - } - } - } +static void refine_barrier_by_new_val_type(const Node* n) { + if (n->Opcode() != Op_StoreP && + n->Opcode() != Op_StoreN) { + return; } - return c; + MemNode* store = n->as_Mem(); + const Node* newval = n->in(MemNode::ValueIn); + assert(newval != nullptr, ""); + const Type* newval_bottom = newval->bottom_type(); + TypePtr::PTR newval_type = newval_bottom->make_ptr()->ptr(); + uint8_t barrier_data = store->barrier_data(); + if (!newval_bottom->isa_oopptr() && + !newval_bottom->isa_narrowoop() && + newval_type != TypePtr::Null) { + // newval is neither an OOP nor null, so there is no barrier to refine. + assert(barrier_data == 0, "non-OOP stores should have no barrier data"); + return; + } + if (barrier_data == 0) { + // No barrier to refine. + return; + } + if (newval_type == TypePtr::Null) { + // Simply elide post-barrier if writing null. + barrier_data &= ~G1C2BarrierPost; + barrier_data &= ~G1C2BarrierPostNotNull; + } else if (((barrier_data & G1C2BarrierPost) != 0) && + newval_type == TypePtr::NotNull) { + // If the post-barrier has not been elided yet (e.g. due to newval being + // freshly allocated), mark it as not-null (simplifies barrier tests and + // compressed OOPs logic). + barrier_data |= G1C2BarrierPostNotNull; + } + store->set_barrier_data(barrier_data); + return; } -#ifdef ASSERT -bool G1BarrierSetC2::has_cas_in_use_chain(Node *n) const { - Unique_Node_List visited; +// Refine (not really expand) G1 barriers by looking at the new value type +// (whether it is necessarily null or necessarily non-null). +bool G1BarrierSetC2::expand_barriers(Compile* C, PhaseIterGVN& igvn) const { + ResourceMark rm; + VectorSet visited; Node_List worklist; - worklist.push(n); + worklist.push(C->root()); while (worklist.size() > 0) { - Node* x = worklist.pop(); - if (visited.member(x)) { + Node* n = worklist.pop(); + if (visited.test_set(n->_idx)) { continue; - } else { - visited.push(x); } - - if (x->is_LoadStore()) { - int op = x->Opcode(); - if (op == Op_CompareAndExchangeP || op == Op_CompareAndExchangeN || - op == Op_CompareAndSwapP || op == Op_CompareAndSwapN || - op == Op_WeakCompareAndSwapP || op == Op_WeakCompareAndSwapN) { - return true; - } - } - if (!x->is_CFG()) { - for (SimpleDUIterator iter(x); iter.has_next(); iter.next()) { - Node* use = iter.get(); - worklist.push(use); + refine_barrier_by_new_val_type(n); + for (uint j = 0; j < n->req(); j++) { + Node* in = n->in(j); + if (in != nullptr) { + worklist.push(in); } } } return false; } -void G1BarrierSetC2::verify_pre_load(Node* marking_if, Unique_Node_List& loads /*output*/) const { - assert(loads.size() == 0, "Loads list should be empty"); - Node* pre_val_if = marking_if->find_out_with(Op_IfTrue)->find_out_with(Op_If); - if (pre_val_if != nullptr) { - Unique_Node_List visited; - Node_List worklist; - Node* pre_val = pre_val_if->in(1)->in(1)->in(1); - - worklist.push(pre_val); - while (worklist.size() > 0) { - Node* x = worklist.pop(); - if (visited.member(x)) { - continue; - } else { - visited.push(x); - } - - if (has_cas_in_use_chain(x)) { - loads.clear(); - return; - } - - if (x->is_Con()) { - continue; - } - if (x->is_EncodeP() || x->is_DecodeN()) { - worklist.push(x->in(1)); - continue; - } - if (x->is_Load() || x->is_LoadStore()) { - assert(x->in(0) != nullptr, "Pre-val load has to have a control"); - loads.push(x); - continue; - } - if (x->is_Phi()) { - for (uint i = 1; i < x->req(); i++) { - worklist.push(x->in(i)); - } - continue; - } - assert(false, "Pre-val anomaly"); - } +uint G1BarrierSetC2::estimated_barrier_size(const Node* node) const { + // These Ideal node counts are extracted from the pre-matching Ideal graph + // generated when compiling the following method with early barrier expansion: + // static void write(MyObject obj1, Object o) { + // obj1.o1 = o; + // } + uint8_t barrier_data = MemNode::barrier_data(node); + uint nodes = 0; + if ((barrier_data & G1C2BarrierPre) != 0) { + nodes += 50; } + if ((barrier_data & G1C2BarrierPost) != 0) { + nodes += 60; + } + return nodes; } -void G1BarrierSetC2::verify_no_safepoints(Compile* compile, Node* marking_check_if, const Unique_Node_List& loads) const { - if (loads.size() == 0) { +bool G1BarrierSetC2::can_initialize_object(const StoreNode* store) const { + assert(store->Opcode() == Op_StoreP || store->Opcode() == Op_StoreN, "OOP store expected"); + // It is OK to move the store across the object initialization boundary only + // if it does not have any barrier, or if it has barriers that can be safely + // elided (because of the compensation steps taken on the allocation slow path + // when ReduceInitialCardMarks is enabled). + return (MemNode::barrier_data(store) == 0) || use_ReduceInitialCardMarks(); +} + +void G1BarrierSetC2::clone_at_expansion(PhaseMacroExpand* phase, ArrayCopyNode* ac) const { + if (ac->is_clone_inst() && !use_ReduceInitialCardMarks()) { + clone_in_runtime(phase, ac, G1BarrierSetRuntime::clone_addr(), "G1BarrierSetRuntime::clone"); return; } + BarrierSetC2::clone_at_expansion(phase, ac); +} - if (loads.size() == 1) { // Handle the typical situation when there a single pre-value load - // that is dominated by the marking_check_if, that's true when the - // barrier itself does the pre-val load. - Node *pre_val = loads.at(0); - if (pre_val->in(0)->in(0) == marking_check_if) { // IfTrue->If +Node* G1BarrierSetC2::store_at_resolved(C2Access& access, C2AccessValue& val) const { + DecoratorSet decorators = access.decorators(); + bool anonymous = (decorators & ON_UNKNOWN_OOP_REF) != 0; + bool in_heap = (decorators & IN_HEAP) != 0; + bool tightly_coupled_alloc = (decorators & C2_TIGHTLY_COUPLED_ALLOC) != 0; + bool need_store_barrier = !(tightly_coupled_alloc && use_ReduceInitialCardMarks()) && (in_heap || anonymous); + if (access.is_oop() && need_store_barrier) { + access.set_barrier_data(get_store_barrier(access)); + if (tightly_coupled_alloc) { + assert(!use_ReduceInitialCardMarks(), + "post-barriers are only needed for tightly-coupled initialization stores when ReduceInitialCardMarks is disabled"); + // Pre-barriers are unnecessary for tightly-coupled initialization stores. + access.set_barrier_data(access.barrier_data() & ~G1C2BarrierPre); + } + } + return BarrierSetC2::store_at_resolved(access, val); +} + +Node* G1BarrierSetC2::atomic_cmpxchg_val_at_resolved(C2AtomicParseAccess& access, Node* expected_val, + Node* new_val, const Type* value_type) const { + GraphKit* kit = access.kit(); + if (!access.is_oop()) { + return BarrierSetC2::atomic_cmpxchg_val_at_resolved(access, expected_val, new_val, value_type); + } + access.set_barrier_data(G1C2BarrierPre | G1C2BarrierPost); + return BarrierSetC2::atomic_cmpxchg_val_at_resolved(access, expected_val, new_val, value_type); +} + +Node* G1BarrierSetC2::atomic_cmpxchg_bool_at_resolved(C2AtomicParseAccess& access, Node* expected_val, + Node* new_val, const Type* value_type) const { + GraphKit* kit = access.kit(); + if (!access.is_oop()) { + return BarrierSetC2::atomic_cmpxchg_bool_at_resolved(access, expected_val, new_val, value_type); + } + access.set_barrier_data(G1C2BarrierPre | G1C2BarrierPost); + return BarrierSetC2::atomic_cmpxchg_bool_at_resolved(access, expected_val, new_val, value_type); +} + +Node* G1BarrierSetC2::atomic_xchg_at_resolved(C2AtomicParseAccess& access, Node* new_val, const Type* value_type) const { + GraphKit* kit = access.kit(); + if (!access.is_oop()) { + return BarrierSetC2::atomic_xchg_at_resolved(access, new_val, value_type); + } + access.set_barrier_data(G1C2BarrierPre | G1C2BarrierPost); + return BarrierSetC2::atomic_xchg_at_resolved(access, new_val, value_type); +} + +class G1BarrierSetC2State : public BarrierSetC2State { +private: + GrowableArray* _stubs; + +public: + G1BarrierSetC2State(Arena* arena) + : BarrierSetC2State(arena), + _stubs(new (arena) GrowableArray(arena, 8, 0, nullptr)) {} + + GrowableArray* stubs() { + return _stubs; + } + + bool needs_liveness_data(const MachNode* mach) const { + return G1PreBarrierStubC2::needs_barrier(mach) || + G1PostBarrierStubC2::needs_barrier(mach); + } + + bool needs_livein_data() const { + return false; + } +}; + +static G1BarrierSetC2State* barrier_set_state() { + return reinterpret_cast(Compile::current()->barrier_set_state()); +} + +G1BarrierStubC2::G1BarrierStubC2(const MachNode* node) : BarrierStubC2(node) {} + +G1PreBarrierStubC2::G1PreBarrierStubC2(const MachNode* node) : G1BarrierStubC2(node) {} + +bool G1PreBarrierStubC2::needs_barrier(const MachNode* node) { + return (node->barrier_data() & G1C2BarrierPre) != 0; +} + +G1PreBarrierStubC2* G1PreBarrierStubC2::create(const MachNode* node) { + G1PreBarrierStubC2* const stub = new (Compile::current()->comp_arena()) G1PreBarrierStubC2(node); + if (!Compile::current()->output()->in_scratch_emit_size()) { + barrier_set_state()->stubs()->append(stub); + } + return stub; +} + +void G1PreBarrierStubC2::initialize_registers(Register obj, Register pre_val, Register thread, Register tmp1, Register tmp2) { + _obj = obj; + _pre_val = pre_val; + _thread = thread; + _tmp1 = tmp1; + _tmp2 = tmp2; +} + +Register G1PreBarrierStubC2::obj() const { + return _obj; +} + +Register G1PreBarrierStubC2::pre_val() const { + return _pre_val; +} + +Register G1PreBarrierStubC2::thread() const { + return _thread; +} + +Register G1PreBarrierStubC2::tmp1() const { + return _tmp1; +} + +Register G1PreBarrierStubC2::tmp2() const { + return _tmp2; +} + +void G1PreBarrierStubC2::emit_code(MacroAssembler& masm) { + G1BarrierSetAssembler* bs = static_cast(BarrierSet::barrier_set()->barrier_set_assembler()); + bs->generate_c2_pre_barrier_stub(&masm, this); +} + +G1PostBarrierStubC2::G1PostBarrierStubC2(const MachNode* node) : G1BarrierStubC2(node) {} + +bool G1PostBarrierStubC2::needs_barrier(const MachNode* node) { + return (node->barrier_data() & G1C2BarrierPost) != 0; +} + +G1PostBarrierStubC2* G1PostBarrierStubC2::create(const MachNode* node) { + G1PostBarrierStubC2* const stub = new (Compile::current()->comp_arena()) G1PostBarrierStubC2(node); + if (!Compile::current()->output()->in_scratch_emit_size()) { + barrier_set_state()->stubs()->append(stub); + } + return stub; +} + +void G1PostBarrierStubC2::initialize_registers(Register thread, Register tmp1, Register tmp2, Register tmp3) { + _thread = thread; + _tmp1 = tmp1; + _tmp2 = tmp2; + _tmp3 = tmp3; +} + +Register G1PostBarrierStubC2::thread() const { + return _thread; +} + +Register G1PostBarrierStubC2::tmp1() const { + return _tmp1; +} + +Register G1PostBarrierStubC2::tmp2() const { + return _tmp2; +} + +Register G1PostBarrierStubC2::tmp3() const { + return _tmp3; +} + +void G1PostBarrierStubC2::emit_code(MacroAssembler& masm) { + G1BarrierSetAssembler* bs = static_cast(BarrierSet::barrier_set()->barrier_set_assembler()); + bs->generate_c2_post_barrier_stub(&masm, this); +} + +void* G1BarrierSetC2::create_barrier_state(Arena* comp_arena) const { + return new (comp_arena) G1BarrierSetC2State(comp_arena); +} + +int G1BarrierSetC2::get_store_barrier(C2Access& access) const { + if (!access.is_parse_access()) { + // Only support for eliding barriers at parse time for now. + return G1C2BarrierPre | G1C2BarrierPost; + } + GraphKit* kit = (static_cast(access)).kit(); + Node* ctl = kit->control(); + Node* adr = access.addr().node(); + uint adr_idx = kit->C->get_alias_index(access.addr().type()); + assert(adr_idx != Compile::AliasIdxTop, "use other store_to_memory factory"); + + bool can_remove_pre_barrier = g1_can_remove_pre_barrier(kit, &kit->gvn(), adr, access.type(), adr_idx); + + // We can skip marks on a freshly-allocated object in Eden. Keep this code in + // sync with CardTableBarrierSet::on_slowpath_allocation_exit. That routine + // informs GC to take appropriate compensating steps, upon a slow-path + // allocation, so as to make this card-mark elision safe. + // The post-barrier can also be removed if null is written. This case is + // handled by G1BarrierSetC2::expand_barriers, which runs at the end of C2's + // platform-independent optimizations to exploit stronger type information. + bool can_remove_post_barrier = use_ReduceInitialCardMarks() && + ((access.base() == kit->just_allocated_object(ctl)) || + g1_can_remove_post_barrier(kit, &kit->gvn(), ctl, adr)); + + int barriers = 0; + if (!can_remove_pre_barrier) { + barriers |= G1C2BarrierPre; + } + if (!can_remove_post_barrier) { + barriers |= G1C2BarrierPost; + } + + return barriers; +} + +void G1BarrierSetC2::late_barrier_analysis() const { + compute_liveness_at_stubs(); +} + +void G1BarrierSetC2::emit_stubs(CodeBuffer& cb) const { + MacroAssembler masm(&cb); + GrowableArray* const stubs = barrier_set_state()->stubs(); + for (int i = 0; i < stubs->length(); i++) { + // Make sure there is enough space in the code buffer + if (cb.insts()->maybe_expand_to_ensure_remaining(PhaseOutput::MAX_inst_size) && cb.blob() == nullptr) { + ciEnv::current()->record_failure("CodeCache is full"); return; } + stubs->at(i)->emit_code(masm); } - - // All other cases are when pre-value loads dominate the marking check. - Unique_Node_List controls; - for (uint i = 0; i < loads.size(); i++) { - Node *c = loads.at(i)->in(0); - controls.push(c); - } - - Unique_Node_List visited; - Unique_Node_List safepoints; - Node_List worklist; - uint found = 0; - - worklist.push(marking_check_if); - while (worklist.size() > 0 && found < controls.size()) { - Node* x = worklist.pop(); - if (x == nullptr || x == compile->top()) continue; - if (visited.member(x)) { - continue; - } else { - visited.push(x); - } - - if (controls.member(x)) { - found++; - } - if (x->is_Region()) { - for (uint i = 1; i < x->req(); i++) { - worklist.push(x->in(i)); - } - } else { - if (!x->is_SafePoint()) { - worklist.push(x->in(0)); - } else { - safepoints.push(x); - } - } - } - assert(found == controls.size(), "Pre-barrier structure anomaly or possible safepoint"); + masm.flush(); } -void G1BarrierSetC2::verify_gc_barriers(Compile* compile, CompilePhase phase) const { - if (phase != BarrierSetC2::BeforeCodeGen) { - return; +#ifndef PRODUCT +void G1BarrierSetC2::dump_barrier_data(const MachNode* mach, outputStream* st) const { + if ((mach->barrier_data() & G1C2BarrierPre) != 0) { + st->print("pre "); } - // Verify G1 pre-barriers - const int marking_offset = in_bytes(G1ThreadLocalData::satb_mark_queue_active_offset()); - - Unique_Node_List visited; - Node_List worklist; - // We're going to walk control flow backwards starting from the Root - worklist.push(compile->root()); - while (worklist.size() > 0) { - Node* x = worklist.pop(); - if (x == nullptr || x == compile->top()) continue; - if (visited.member(x)) { - continue; - } else { - visited.push(x); - } - - if (x->is_Region()) { - for (uint i = 1; i < x->req(); i++) { - worklist.push(x->in(i)); - } - } else { - worklist.push(x->in(0)); - // We are looking for the pattern: - // /->ThreadLocal - // If->Bool->CmpI->LoadB->AddP->ConL(marking_offset) - // \->ConI(0) - // We want to verify that the If and the LoadB have the same control - // See GraphKit::g1_write_barrier_pre() - if (x->is_If()) { - IfNode *iff = x->as_If(); - if (iff->in(1)->is_Bool() && iff->in(1)->in(1)->is_Cmp()) { - CmpNode *cmp = iff->in(1)->in(1)->as_Cmp(); - if (cmp->Opcode() == Op_CmpI && cmp->in(2)->is_Con() && cmp->in(2)->bottom_type()->is_int()->get_con() == 0 - && cmp->in(1)->is_Load()) { - LoadNode* load = cmp->in(1)->as_Load(); - if (load->Opcode() == Op_LoadB && load->in(2)->is_AddP() && load->in(2)->in(2)->Opcode() == Op_ThreadLocal - && load->in(2)->in(3)->is_Con() - && load->in(2)->in(3)->bottom_type()->is_intptr_t()->get_con() == marking_offset) { - - Node* if_ctrl = iff->in(0); - Node* load_ctrl = load->in(0); - - if (if_ctrl != load_ctrl) { - // Skip possible CProj->NeverBranch in infinite loops - if ((if_ctrl->is_Proj() && if_ctrl->Opcode() == Op_CProj) - && if_ctrl->in(0)->is_NeverBranch()) { - if_ctrl = if_ctrl->in(0)->in(0); - } - } - assert(load_ctrl != nullptr && if_ctrl == load_ctrl, "controls must match"); - - Unique_Node_List loads; - verify_pre_load(iff, loads); - verify_no_safepoints(compile, iff, loads); - } - } - } - } - } + if ((mach->barrier_data() & G1C2BarrierPost) != 0) { + st->print("post "); + } + if ((mach->barrier_data() & G1C2BarrierPostNotNull) != 0) { + st->print("notnull "); } } -#endif - -bool G1BarrierSetC2::escape_add_to_con_graph(ConnectionGraph* conn_graph, PhaseGVN* gvn, Unique_Node_List* delayed_worklist, Node* n, uint opcode) const { - if (opcode == Op_StoreP) { - Node* adr = n->in(MemNode::Address); - const Type* adr_type = gvn->type(adr); - // Pointer stores in G1 barriers looks like unsafe access. - // Ignore such stores to be able scalar replace non-escaping - // allocations. - if (adr_type->isa_rawptr() && adr->is_AddP()) { - Node* base = conn_graph->get_addp_base(adr); - if (base->Opcode() == Op_LoadP && - base->in(MemNode::Address)->is_AddP()) { - adr = base->in(MemNode::Address); - Node* tls = conn_graph->get_addp_base(adr); - if (tls->Opcode() == Op_ThreadLocal) { - int offs = (int) gvn->find_intptr_t_con(adr->in(AddPNode::Offset), Type::OffsetBot); - const int buf_offset = in_bytes(G1ThreadLocalData::satb_mark_queue_buffer_offset()); - if (offs == buf_offset) { - return true; // G1 pre barrier previous oop value store. - } - if (offs == in_bytes(G1ThreadLocalData::dirty_card_queue_buffer_offset())) { - return true; // G1 post barrier card address store. - } - } - } - } - } - return false; -} +#endif // !PRODUCT diff --git a/src/hotspot/share/gc/g1/c2/g1BarrierSetC2.hpp b/src/hotspot/share/gc/g1/c2/g1BarrierSetC2.hpp index c445a87d2e4..dc333d8c331 100644 --- a/src/hotspot/share/gc/g1/c2/g1BarrierSetC2.hpp +++ b/src/hotspot/share/gc/g1/c2/g1BarrierSetC2.hpp @@ -31,29 +31,62 @@ class PhaseTransform; class Type; class TypeFunc; +const int G1C2BarrierPre = 1; +const int G1C2BarrierPost = 2; +const int G1C2BarrierPostNotNull = 4; + +class G1BarrierStubC2 : public BarrierStubC2 { +public: + G1BarrierStubC2(const MachNode* node); + virtual void emit_code(MacroAssembler& masm) = 0; +}; + +class G1PreBarrierStubC2 : public G1BarrierStubC2 { +private: + Register _obj; + Register _pre_val; + Register _thread; + Register _tmp1; + Register _tmp2; + +protected: + G1PreBarrierStubC2(const MachNode* node); + +public: + static bool needs_barrier(const MachNode* node); + static G1PreBarrierStubC2* create(const MachNode* node); + void initialize_registers(Register obj, Register pre_val, Register thread, Register tmp1 = noreg, Register tmp2 = noreg); + Register obj() const; + Register pre_val() const; + Register thread() const; + Register tmp1() const; + Register tmp2() const; + virtual void emit_code(MacroAssembler& masm); +}; + +class G1PostBarrierStubC2 : public G1BarrierStubC2 { +private: + Register _thread; + Register _tmp1; + Register _tmp2; + Register _tmp3; + +protected: + G1PostBarrierStubC2(const MachNode* node); + +public: + static bool needs_barrier(const MachNode* node); + static G1PostBarrierStubC2* create(const MachNode* node); + void initialize_registers(Register thread, Register tmp1 = noreg, Register tmp2 = noreg, Register tmp3 = noreg); + Register thread() const; + Register tmp1() const; + Register tmp2() const; + Register tmp3() const; + virtual void emit_code(MacroAssembler& masm); +}; + class G1BarrierSetC2: public CardTableBarrierSetC2 { protected: - virtual void pre_barrier(GraphKit* kit, - bool do_load, - Node* ctl, - Node* obj, - Node* adr, - uint adr_idx, - Node* val, - const TypeOopPtr* val_type, - Node* pre_val, - BasicType bt) const; - - virtual void post_barrier(GraphKit* kit, - Node* ctl, - Node* store, - Node* obj, - Node* adr, - uint adr_idx, - Node* val, - BasicType bt, - bool use_precise) const; - bool g1_can_remove_pre_barrier(GraphKit* kit, PhaseValues* phase, Node* adr, @@ -64,44 +97,31 @@ protected: PhaseValues* phase, Node* store, Node* adr) const; - void g1_mark_card(GraphKit* kit, - IdealKit& ideal, - Node* card_adr, - Node* oop_store, - uint oop_alias_idx, - Node* index, - Node* index_adr, - Node* buffer, - const TypeFunc* tf) const; - - // Helper for unsafe accesses, that may or may not be on the referent field. - // Generates the guards that check whether the result of - // Unsafe.getReference should be recorded in an SATB log buffer. - void insert_pre_barrier(GraphKit* kit, Node* base_oop, Node* offset, Node* pre_val, bool need_mem_bar) const; - - static const TypeFunc* write_ref_field_pre_entry_Type(); - static const TypeFunc* write_ref_field_post_entry_Type(); + int get_store_barrier(C2Access& access) const; virtual Node* load_at_resolved(C2Access& access, const Type* val_type) const; + virtual Node* store_at_resolved(C2Access& access, C2AccessValue& val) const; + virtual Node* atomic_cmpxchg_val_at_resolved(C2AtomicParseAccess& access, Node* expected_val, + Node* new_val, const Type* value_type) const; + virtual Node* atomic_cmpxchg_bool_at_resolved(C2AtomicParseAccess& access, Node* expected_val, + Node* new_val, const Type* value_type) const; + virtual Node* atomic_xchg_at_resolved(C2AtomicParseAccess& access, Node* new_val, const Type* value_type) const; -#ifdef ASSERT - bool has_cas_in_use_chain(Node* x) const; - void verify_pre_load(Node* marking_check_if, Unique_Node_List& loads /*output*/) const; - void verify_no_safepoints(Compile* compile, Node* marking_load, const Unique_Node_List& loads) const; -#endif - - static bool is_g1_pre_val_load(Node* n); public: - virtual bool is_gc_pre_barrier_node(Node* node) const; - virtual bool is_gc_barrier_node(Node* node) const; virtual void eliminate_gc_barrier(PhaseMacroExpand* macro, Node* node) const; - virtual Node* step_over_gc_barrier(Node* c) const; + virtual void eliminate_gc_barrier_data(Node* node) const; + virtual bool expand_barriers(Compile* C, PhaseIterGVN& igvn) const; + virtual uint estimated_barrier_size(const Node* node) const; + virtual bool can_initialize_object(const StoreNode* store) const; + virtual void clone_at_expansion(PhaseMacroExpand* phase, + ArrayCopyNode* ac) const; + virtual void* create_barrier_state(Arena* comp_arena) const; + virtual void emit_stubs(CodeBuffer& cb) const; + virtual void late_barrier_analysis() const; -#ifdef ASSERT - virtual void verify_gc_barriers(Compile* compile, CompilePhase phase) const; +#ifndef PRODUCT + virtual void dump_barrier_data(const MachNode* mach, outputStream* st) const; #endif - - virtual bool escape_add_to_con_graph(ConnectionGraph* conn_graph, PhaseGVN* gvn, Unique_Node_List* delayed_worklist, Node* n, uint opcode) const; }; #endif // SHARE_GC_G1_C2_G1BARRIERSETC2_HPP diff --git a/src/hotspot/share/gc/g1/g1BarrierSetRuntime.cpp b/src/hotspot/share/gc/g1/g1BarrierSetRuntime.cpp index a0fce437807..2e247f46c93 100644 --- a/src/hotspot/share/gc/g1/g1BarrierSetRuntime.cpp +++ b/src/hotspot/share/gc/g1/g1BarrierSetRuntime.cpp @@ -61,3 +61,11 @@ JRT_LEAF(void, G1BarrierSetRuntime::write_ref_field_post_entry(volatile G1CardTa G1DirtyCardQueue& queue = G1ThreadLocalData::dirty_card_queue(thread); G1BarrierSet::dirty_card_queue_set().enqueue(queue, card_addr); JRT_END + +JRT_LEAF(void, G1BarrierSetRuntime::clone(oopDesc* src, oopDesc* dst, size_t size)) + HeapAccess<>::clone(src, dst, size); +JRT_END + +address G1BarrierSetRuntime::clone_addr() { + return reinterpret_cast
(clone); +} diff --git a/src/hotspot/share/gc/g1/g1BarrierSetRuntime.hpp b/src/hotspot/share/gc/g1/g1BarrierSetRuntime.hpp index 366679f032b..f98e94096e7 100644 --- a/src/hotspot/share/gc/g1/g1BarrierSetRuntime.hpp +++ b/src/hotspot/share/gc/g1/g1BarrierSetRuntime.hpp @@ -35,6 +35,8 @@ class oopDesc; class JavaThread; class G1BarrierSetRuntime: public AllStatic { +private: + static void clone(oopDesc* src, oopDesc* dst, size_t size); public: using CardValue = G1CardTable::CardValue; @@ -46,6 +48,8 @@ public: // C2 slow-path runtime calls. static void write_ref_field_pre_entry(oopDesc* orig, JavaThread *thread); static void write_ref_field_post_entry(volatile CardValue* card_addr, JavaThread* thread); + + static address clone_addr(); }; #endif // SHARE_GC_G1_G1BARRIERSETRUNTIME_HPP diff --git a/src/hotspot/share/gc/g1/g1BatchedTask.hpp b/src/hotspot/share/gc/g1/g1BatchedTask.hpp index aa16f4ddfd4..020fda634e4 100644 --- a/src/hotspot/share/gc/g1/g1BatchedTask.hpp +++ b/src/hotspot/share/gc/g1/g1BatchedTask.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,7 +29,7 @@ #include "gc/shared/workerThread.hpp" #include "memory/allocation.hpp" -template +template class GrowableArrayCHeap; // G1AbstractSubTask represents a task to be performed either within a diff --git a/src/hotspot/share/gc/g1/g1CollectionSet.cpp b/src/hotspot/share/gc/g1/g1CollectionSet.cpp index d315497268f..ec90fd37750 100644 --- a/src/hotspot/share/gc/g1/g1CollectionSet.cpp +++ b/src/hotspot/share/gc/g1/g1CollectionSet.cpp @@ -26,7 +26,7 @@ #include "gc/g1/g1Analytics.hpp" #include "gc/g1/g1CollectedHeap.inline.hpp" #include "gc/g1/g1CollectionSet.hpp" -#include "gc/g1/g1CollectionSetCandidates.hpp" +#include "gc/g1/g1CollectionSetCandidates.inline.hpp" #include "gc/g1/g1CollectorState.hpp" #include "gc/g1/g1HeapRegion.inline.hpp" #include "gc/g1/g1HeapRegionRemSet.inline.hpp" @@ -346,20 +346,16 @@ void G1CollectionSet::finalize_old_part(double time_remaining_ms) { G1CollectionCandidateRegionList pinned_retained_regions; if (collector_state()->in_mixed_phase()) { - time_remaining_ms = _policy->select_candidates_from_marking(&candidates()->marking_regions(), - time_remaining_ms, - &initial_old_regions, - &_optional_old_regions, - &pinned_marking_regions); + time_remaining_ms = select_candidates_from_marking(time_remaining_ms, + &initial_old_regions, + &pinned_marking_regions); } else { log_debug(gc, ergo, cset)("Do not add marking candidates to collection set due to pause type."); } - _policy->select_candidates_from_retained(&candidates()->retained_regions(), - time_remaining_ms, - &initial_old_regions, - &_optional_old_regions, - &pinned_retained_regions); + select_candidates_from_retained(time_remaining_ms, + &initial_old_regions, + &pinned_retained_regions); // Move initially selected old regions to collection set directly. move_candidates_to_collection_set(&initial_old_regions); @@ -394,6 +390,215 @@ void G1CollectionSet::move_candidates_to_collection_set(G1CollectionCandidateReg candidates()->remove(regions); } +static void print_finish_message(const char* reason, bool from_marking) { + log_debug(gc, ergo, cset)("Finish adding %s candidates to collection set (%s).", + from_marking ? "marking" : "retained", reason); +} + +double G1CollectionSet::select_candidates_from_marking(double time_remaining_ms, + G1CollectionCandidateRegionList* initial_old_regions, + G1CollectionCandidateRegionList* pinned_old_regions) { + uint num_expensive_regions = 0; + + uint num_initial_regions_selected = 0; + uint num_optional_regions_selected = 0; + uint num_pinned_regions = 0; + + double predicted_initial_time_ms = 0.0; + double predicted_optional_time_ms = 0.0; + + double optional_threshold_ms = time_remaining_ms * _policy->optional_prediction_fraction(); + + const uint min_old_cset_length = _policy->calc_min_old_cset_length(candidates()->last_marking_candidates_length()); + const uint max_old_cset_length = MAX2(min_old_cset_length, _policy->calc_max_old_cset_length()); + const uint max_optional_regions = max_old_cset_length - min_old_cset_length; + bool check_time_remaining = _policy->use_adaptive_young_list_length(); + + G1CollectionCandidateList* marking_list = &candidates()->marking_regions(); + assert(marking_list != nullptr, "must be"); + + log_debug(gc, ergo, cset)("Start adding marking candidates to collection set. " + "Min %u regions, max %u regions, available %u regions" + "time remaining %1.2fms, optional threshold %1.2fms", + min_old_cset_length, max_old_cset_length, marking_list->length(), time_remaining_ms, optional_threshold_ms); + + G1CollectionCandidateListIterator iter = marking_list->begin(); + for (; iter != marking_list->end(); ++iter) { + if (num_initial_regions_selected + num_optional_regions_selected >= max_old_cset_length) { + // Added maximum number of old regions to the CSet. + print_finish_message("Maximum number of regions reached", true); + break; + } + G1HeapRegion* hr = (*iter)->_r; + // Skip evacuating pinned marking regions because we are not getting any free + // space from them (and we expect to get free space from marking candidates). + // Also prepare to move them to retained regions to be evacuated optionally later + // to not impact the mixed phase too much. + if (hr->has_pinned_objects()) { + num_pinned_regions++; + (*iter)->update_num_unreclaimed(); + log_trace(gc, ergo, cset)("Marking candidate %u can not be reclaimed currently. Skipping.", hr->hrm_index()); + pinned_old_regions->append(hr); + continue; + } + double predicted_time_ms = _policy->predict_region_total_time_ms(hr, false); + time_remaining_ms = MAX2(time_remaining_ms - predicted_time_ms, 0.0); + // Add regions to old set until we reach the minimum amount + if (initial_old_regions->length() < min_old_cset_length) { + initial_old_regions->append(hr); + num_initial_regions_selected++; + predicted_initial_time_ms += predicted_time_ms; + // Record the number of regions added with no time remaining + if (time_remaining_ms == 0.0) { + num_expensive_regions++; + } + } else if (!check_time_remaining) { + // In the non-auto-tuning case, we'll finish adding regions + // to the CSet if we reach the minimum. + print_finish_message("Region amount reached min", true); + break; + } else { + // Keep adding regions to old set until we reach the optional threshold + if (time_remaining_ms > optional_threshold_ms) { + predicted_initial_time_ms += predicted_time_ms; + initial_old_regions->append(hr); + num_initial_regions_selected++; + } else if (time_remaining_ms > 0) { + // Keep adding optional regions until time is up. + assert(_optional_old_regions.length() < max_optional_regions, "Should not be possible."); + predicted_optional_time_ms += predicted_time_ms; + _optional_old_regions.append(hr); + num_optional_regions_selected++; + } else { + print_finish_message("Predicted time too high", true); + break; + } + } + } + if (iter == marking_list->end()) { + log_debug(gc, ergo, cset)("Marking candidates exhausted."); + } + + if (num_expensive_regions > 0) { + log_debug(gc, ergo, cset)("Added %u marking candidates to collection set although the predicted time was too high.", + num_expensive_regions); + } + + log_debug(gc, ergo, cset)("Finish adding marking candidates to collection set. Initial: %u, optional: %u, pinned: %u, " + "predicted initial time: %1.2fms, predicted optional time: %1.2fms, time remaining: %1.2fms", + num_initial_regions_selected, num_optional_regions_selected, num_pinned_regions, + predicted_initial_time_ms, predicted_optional_time_ms, time_remaining_ms); + + assert(initial_old_regions->length() == num_initial_regions_selected, "must be"); + assert(_optional_old_regions.length() == num_optional_regions_selected, "must be"); + return time_remaining_ms; +} + +void G1CollectionSet::select_candidates_from_retained(double time_remaining_ms, + G1CollectionCandidateRegionList* initial_old_regions, + G1CollectionCandidateRegionList* pinned_old_regions) { + uint num_initial_regions_selected = 0; + uint num_optional_regions_selected = 0; + uint num_expensive_regions_selected = 0; + uint num_pinned_regions = 0; + + double predicted_initial_time_ms = 0.0; + double predicted_optional_time_ms = 0.0; + + uint const min_regions = _policy->min_retained_old_cset_length(); + // We want to make sure that on the one hand we process the retained regions asap, + // but on the other hand do not take too many of them as optional regions. + // So we split the time budget into budget we will unconditionally take into the + // initial old regions, and budget for taking optional regions from the retained + // list. + double optional_time_remaining_ms = _policy->max_time_for_retaining(); + time_remaining_ms = MIN2(time_remaining_ms, optional_time_remaining_ms); + + G1CollectionCandidateList* retained_list = &candidates()->retained_regions(); + + log_debug(gc, ergo, cset)("Start adding retained candidates to collection set. " + "Min %u regions, available %u, " + "time remaining %1.2fms, optional remaining %1.2fms", + min_regions, retained_list->length(), time_remaining_ms, optional_time_remaining_ms); + + for (G1CollectionSetCandidateInfo* ci : *retained_list) { + G1HeapRegion* r = ci->_r; + double predicted_time_ms = _policy->predict_region_total_time_ms(r, collector_state()->in_young_only_phase()); + bool fits_in_remaining_time = predicted_time_ms <= time_remaining_ms; + // If we can't reclaim that region ignore it for now. + if (r->has_pinned_objects()) { + num_pinned_regions++; + if (ci->update_num_unreclaimed()) { + log_trace(gc, ergo, cset)("Retained candidate %u can not be reclaimed currently. Skipping.", r->hrm_index()); + } else { + log_trace(gc, ergo, cset)("Retained candidate %u can not be reclaimed currently. Dropping.", r->hrm_index()); + pinned_old_regions->append(r); + } + continue; + } + + if (fits_in_remaining_time || (num_expensive_regions_selected < min_regions)) { + predicted_initial_time_ms += predicted_time_ms; + if (!fits_in_remaining_time) { + num_expensive_regions_selected++; + } + initial_old_regions->append(r); + num_initial_regions_selected++; + } else if (predicted_time_ms <= optional_time_remaining_ms) { + predicted_optional_time_ms += predicted_time_ms; + _optional_old_regions.append(r); + num_optional_regions_selected++; + } else { + // Fits neither initial nor optional time limit. Exit. + break; + } + time_remaining_ms = MAX2(0.0, time_remaining_ms - predicted_time_ms); + optional_time_remaining_ms = MAX2(0.0, optional_time_remaining_ms - predicted_time_ms); + } + + uint num_regions_selected = num_initial_regions_selected + num_optional_regions_selected; + if (num_regions_selected == retained_list->length()) { + log_debug(gc, ergo, cset)("Retained candidates exhausted."); + } + if (num_expensive_regions_selected > 0) { + log_debug(gc, ergo, cset)("Added %u retained candidates to collection set although the predicted time was too high.", + num_expensive_regions_selected); + } + + log_debug(gc, ergo, cset)("Finish adding retained candidates to collection set. Initial: %u, optional: %u, pinned: %u, " + "predicted initial time: %1.2fms, predicted optional time: %1.2fms, " + "time remaining: %1.2fms optional time remaining %1.2fms", + num_initial_regions_selected, num_optional_regions_selected, num_pinned_regions, + predicted_initial_time_ms, predicted_optional_time_ms, time_remaining_ms, optional_time_remaining_ms); +} + +void G1CollectionSet::select_candidates_from_optional_regions(double time_remaining_ms, + G1CollectionCandidateRegionList* selected_regions) { + assert(optional_region_length() > 0, + "Should only be called when there are optional regions"); + + double total_prediction_ms = 0.0; + + for (G1HeapRegion* r : _optional_old_regions) { + double prediction_ms = _policy->predict_region_total_time_ms(r, false); + + if (prediction_ms > time_remaining_ms) { + log_debug(gc, ergo, cset)("Prediction %.3fms for region %u does not fit remaining time: %.3fms.", + prediction_ms, r->hrm_index(), time_remaining_ms); + break; + } + // This region will be included in the next optional evacuation. + + total_prediction_ms += prediction_ms; + time_remaining_ms -= prediction_ms; + + selected_regions->append(r); + } + + log_debug(gc, ergo, cset)("Prepared %u regions out of %u for optional evacuation. Total predicted time: %.3fms", + selected_regions->length(), _optional_old_regions.length(), total_prediction_ms); +} + void G1CollectionSet::prepare_optional_regions(G1CollectionCandidateRegionList* regions){ uint cur_index = 0; for (G1HeapRegion* r : *regions) { @@ -441,9 +646,8 @@ bool G1CollectionSet::finalize_optional_for_evacuation(double remaining_pause_ti update_incremental_marker(); G1CollectionCandidateRegionList selected_regions; - _policy->calculate_optional_collection_set_regions(&_optional_old_regions, - remaining_pause_time, - &selected_regions); + select_candidates_from_optional_regions(remaining_pause_time, + &selected_regions); move_candidates_to_collection_set(&selected_regions); diff --git a/src/hotspot/share/gc/g1/g1CollectionSet.hpp b/src/hotspot/share/gc/g1/g1CollectionSet.hpp index e569d3ee966..5280ba7d0fd 100644 --- a/src/hotspot/share/gc/g1/g1CollectionSet.hpp +++ b/src/hotspot/share/gc/g1/g1CollectionSet.hpp @@ -196,6 +196,22 @@ class G1CollectionSet { // and retained collection set candidates. void finalize_old_part(double time_remaining_ms); + // Calculate and fill in the initial, optional and pinned old gen candidate regions from + // the given candidate list and the remaining time. + // Returns the remaining time. + double select_candidates_from_marking(double time_remaining_ms, + G1CollectionCandidateRegionList* initial_old_regions, + G1CollectionCandidateRegionList* pinned_old_regions); + + void select_candidates_from_retained(double time_remaining_ms, + G1CollectionCandidateRegionList* initial_old_regions, + G1CollectionCandidateRegionList* pinned_old_regions); + + // Calculate the number of optional regions from the given collection set candidates, + // the remaining time and the maximum number of these regions. + void select_candidates_from_optional_regions(double time_remaining_ms, + G1CollectionCandidateRegionList* selected); + // Iterate the part of the collection set given by the offset and length applying the given // G1HeapRegionClosure. The worker_id will determine where in the part to start the iteration // to allow for more efficient parallel iteration. diff --git a/src/hotspot/share/gc/g1/g1FullCollector.cpp b/src/hotspot/share/gc/g1/g1FullCollector.cpp index 4c66c526151..5789b44e618 100644 --- a/src/hotspot/share/gc/g1/g1FullCollector.cpp +++ b/src/hotspot/share/gc/g1/g1FullCollector.cpp @@ -172,7 +172,6 @@ public: bool do_heap_region(G1HeapRegion* hr) { hr->prepare_for_full_gc(); - hr->uninstall_group_cardset(); G1CollectedHeap::heap()->prepare_region_for_full_compaction(hr); _collector->before_marking_update_attribute_table(hr); return false; diff --git a/src/hotspot/share/gc/g1/g1FullGCResetMetadataTask.cpp b/src/hotspot/share/gc/g1/g1FullGCResetMetadataTask.cpp index 4c93aca8492..910f878ef7f 100644 --- a/src/hotspot/share/gc/g1/g1FullGCResetMetadataTask.cpp +++ b/src/hotspot/share/gc/g1/g1FullGCResetMetadataTask.cpp @@ -37,6 +37,8 @@ void G1FullGCResetMetadataTask::G1ResetMetadataClosure::reset_region_metadata(G1 } bool G1FullGCResetMetadataTask::G1ResetMetadataClosure::do_heap_region(G1HeapRegion* hr) { + hr->uninstall_group_cardset(); + uint const region_idx = hr->hrm_index(); if (!_collector->is_compaction_target(region_idx)) { assert(!hr->is_free(), "all free regions should be compaction targets"); diff --git a/src/hotspot/share/gc/g1/g1HeapRegionPrinter.hpp b/src/hotspot/share/gc/g1/g1HeapRegionPrinter.hpp index d7b1a6da92c..577a8552091 100644 --- a/src/hotspot/share/gc/g1/g1HeapRegionPrinter.hpp +++ b/src/hotspot/share/gc/g1/g1HeapRegionPrinter.hpp @@ -35,8 +35,8 @@ class G1HeapRegionPrinter : public AllStatic { // Print an action event. static void print(const char* action, G1HeapRegion* hr) { - log_trace(gc, region)("G1HR %s(%s) [" PTR_FORMAT ", " PTR_FORMAT ", " PTR_FORMAT "]", - action, hr->get_type_str(), p2i(hr->bottom()), p2i(hr->top()), p2i(hr->end())); + log_trace(gc, region)("G1HR %4u %s(%s) [" PTR_FORMAT ", " PTR_FORMAT ", " PTR_FORMAT "]", + hr->hrm_index(), action, hr->get_type_str(), p2i(hr->bottom()), p2i(hr->top()), p2i(hr->end())); } public: diff --git a/src/hotspot/share/gc/g1/g1MonotonicArena.cpp b/src/hotspot/share/gc/g1/g1MonotonicArena.cpp index 81748d277cf..b2706d7a946 100644 --- a/src/hotspot/share/gc/g1/g1MonotonicArena.cpp +++ b/src/hotspot/share/gc/g1/g1MonotonicArena.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,22 +29,22 @@ #include "runtime/vmOperations.hpp" #include "utilities/globalCounter.inline.hpp" -G1MonotonicArena::Segment::Segment(uint slot_size, uint num_slots, Segment* next, MEMFLAGS flag) : +G1MonotonicArena::Segment::Segment(uint slot_size, uint num_slots, Segment* next, MemTag mem_tag) : _slot_size(slot_size), _num_slots(num_slots), _next(next), _next_allocate(0), - _mem_flag(flag) { + _mem_tag(mem_tag) { _bottom = ((char*) this) + header_size(); } G1MonotonicArena::Segment* G1MonotonicArena::Segment::create_segment(uint slot_size, uint num_slots, Segment* next, - MEMFLAGS mem_flag) { + MemTag mem_tag) { size_t block_size = size_in_bytes(slot_size, num_slots); - char* alloc_block = NEW_C_HEAP_ARRAY(char, block_size, mem_flag); - return new (alloc_block) Segment(slot_size, num_slots, next, mem_flag); + char* alloc_block = NEW_C_HEAP_ARRAY(char, block_size, mem_tag); + return new (alloc_block) Segment(slot_size, num_slots, next, mem_tag); } void G1MonotonicArena::Segment::delete_segment(Segment* segment) { @@ -54,7 +54,7 @@ void G1MonotonicArena::Segment::delete_segment(Segment* segment) { GlobalCounter::write_synchronize(); } segment->~Segment(); - FREE_C_HEAP_ARRAY(_mem_flag, segment); + FREE_C_HEAP_ARRAY(_mem_tag, segment); } void G1MonotonicArena::SegmentFreeList::bulk_add(Segment& first, @@ -108,7 +108,7 @@ G1MonotonicArena::Segment* G1MonotonicArena::new_segment(Segment* const prev) { uint prev_num_slots = (prev != nullptr) ? prev->num_slots() : 0; uint num_slots = _alloc_options->next_num_slots(prev_num_slots); - next = Segment::create_segment(slot_size(), num_slots, prev, _alloc_options->mem_flag()); + next = Segment::create_segment(slot_size(), num_slots, prev, _alloc_options->mem_tag()); } else { assert(slot_size() == next->slot_size() , "Mismatch %d != %d", slot_size(), next->slot_size()); diff --git a/src/hotspot/share/gc/g1/g1MonotonicArena.hpp b/src/hotspot/share/gc/g1/g1MonotonicArena.hpp index bf46e4a3351..b51f3e37db1 100644 --- a/src/hotspot/share/gc/g1/g1MonotonicArena.hpp +++ b/src/hotspot/share/gc/g1/g1MonotonicArena.hpp @@ -27,7 +27,7 @@ #define SHARE_GC_G1_G1MONOTONICARENA_HPP #include "gc/shared/freeListAllocator.hpp" -#include "nmt/memflags.hpp" +#include "nmt/memTag.hpp" #include "utilities/globalDefinitions.hpp" #include "utilities/lockFreeStack.hpp" @@ -120,7 +120,7 @@ class G1MonotonicArena::Segment { // to _num_slots (can be larger because we atomically increment this value and // check only afterwards if the allocation has been successful). uint volatile _next_allocate; - const MEMFLAGS _mem_flag; + const MemTag _mem_tag; char* _bottom; // Actual data. // Do not add class member variables beyond this point @@ -136,7 +136,7 @@ class G1MonotonicArena::Segment { NONCOPYABLE(Segment); - Segment(uint slot_size, uint num_slots, Segment* next, MEMFLAGS flag); + Segment(uint slot_size, uint num_slots, Segment* next, MemTag mem_tag); ~Segment() = default; public: Segment* volatile* next_addr() { return &_next; } @@ -173,7 +173,7 @@ public: return header_size() + payload_size(slot_size, num_slots); } - static Segment* create_segment(uint slot_size, uint num_slots, Segment* next, MEMFLAGS mem_flag); + static Segment* create_segment(uint slot_size, uint num_slots, Segment* next, MemTag mem_tag); static void delete_segment(Segment* segment); // Copies the contents of this segment into the destination. @@ -222,7 +222,7 @@ public: class G1MonotonicArena::AllocOptions { protected: - const MEMFLAGS _mem_flag; + const MemTag _mem_tag; const uint _slot_size; const uint _initial_num_slots; // Defines a limit to the number of slots in the segment @@ -230,8 +230,8 @@ protected: const uint _slot_alignment; public: - AllocOptions(MEMFLAGS mem_flag, uint slot_size, uint initial_num_slots, uint max_num_slots, uint alignment) : - _mem_flag(mem_flag), + AllocOptions(MemTag mem_tag, uint slot_size, uint initial_num_slots, uint max_num_slots, uint alignment) : + _mem_tag(mem_tag), _slot_size(align_up(slot_size, alignment)), _initial_num_slots(initial_num_slots), _max_num_slots(max_num_slots), @@ -250,7 +250,7 @@ public: uint slot_alignment() const { return _slot_alignment; } - MEMFLAGS mem_flag() const {return _mem_flag; } + MemTag mem_tag() const {return _mem_tag; } }; #endif //SHARE_GC_G1_MONOTONICARENA_HPP diff --git a/src/hotspot/share/gc/g1/g1ParScanThreadState.hpp b/src/hotspot/share/gc/g1/g1ParScanThreadState.hpp index 1cfd6fca08a..3f7fefd8a07 100644 --- a/src/hotspot/share/gc/g1/g1ParScanThreadState.hpp +++ b/src/hotspot/share/gc/g1/g1ParScanThreadState.hpp @@ -87,8 +87,6 @@ class G1ParScanThreadState : public CHeapObj { // Indicates whether in the last generation (old) there is no more space // available for allocation. bool _old_gen_is_full; - // Size (in elements) of a partial objArray task chunk. - size_t _partial_objarray_chunk_size; PartialArrayStateAllocator* _partial_array_state_allocator; PartialArrayTaskStepper _partial_array_stepper; StringDedup::Requests _string_dedup_requests; diff --git a/src/hotspot/share/gc/g1/g1Policy.cpp b/src/hotspot/share/gc/g1/g1Policy.cpp index e7e57c962c7..1b71901f0fe 100644 --- a/src/hotspot/share/gc/g1/g1Policy.cpp +++ b/src/hotspot/share/gc/g1/g1Policy.cpp @@ -53,7 +53,7 @@ #include "gc/shared/gcTraceTime.inline.hpp" G1Policy::G1Policy(STWGCTimer* gc_timer) : - _predictor(G1ConfidencePercent / 100.0), + _predictor((100 - G1ConfidencePercent) / 100.0), _analytics(new G1Analytics(&_predictor)), _remset_tracker(), _mmu_tracker(new G1MMUTracker(GCPauseIntervalMillis / 1000.0, MaxGCPauseMillis / 1000.0)), @@ -1467,219 +1467,6 @@ uint G1Policy::calc_max_old_cset_length() const { return (uint)ceil(result); } -static void print_finish_message(const char* reason, bool from_marking) { - log_debug(gc, ergo, cset)("Finish adding %s candidates to collection set (%s).", - from_marking ? "marking" : "retained", reason); -} - -double G1Policy::select_candidates_from_marking(G1CollectionCandidateList* marking_list, - double time_remaining_ms, - G1CollectionCandidateRegionList* initial_old_regions, - G1CollectionCandidateRegionList* optional_old_regions, - G1CollectionCandidateRegionList* pinned_old_regions) { - assert(marking_list != nullptr, "must be"); - - uint num_expensive_regions = 0; - - uint num_initial_regions_selected = 0; - uint num_optional_regions_selected = 0; - uint num_pinned_regions = 0; - - double predicted_initial_time_ms = 0.0; - double predicted_optional_time_ms = 0.0; - - double optional_threshold_ms = time_remaining_ms * optional_prediction_fraction(); - - const uint min_old_cset_length = calc_min_old_cset_length(candidates()->last_marking_candidates_length()); - const uint max_old_cset_length = MAX2(min_old_cset_length, calc_max_old_cset_length()); - const uint max_optional_regions = max_old_cset_length - min_old_cset_length; - bool check_time_remaining = use_adaptive_young_list_length(); - - log_debug(gc, ergo, cset)("Start adding marking candidates to collection set. " - "Min %u regions, max %u regions, available %u regions" - "time remaining %1.2fms, optional threshold %1.2fms", - min_old_cset_length, max_old_cset_length, marking_list->length(), time_remaining_ms, optional_threshold_ms); - - G1CollectionCandidateListIterator iter = marking_list->begin(); - for (; iter != marking_list->end(); ++iter) { - if (num_initial_regions_selected + num_optional_regions_selected >= max_old_cset_length) { - // Added maximum number of old regions to the CSet. - print_finish_message("Maximum number of regions reached", true); - break; - } - G1HeapRegion* hr = (*iter)->_r; - // Skip evacuating pinned marking regions because we are not getting any free - // space from them (and we expect to get free space from marking candidates). - // Also prepare to move them to retained regions to be evacuated optionally later - // to not impact the mixed phase too much. - if (hr->has_pinned_objects()) { - num_pinned_regions++; - (*iter)->update_num_unreclaimed(); - log_trace(gc, ergo, cset)("Marking candidate %u can not be reclaimed currently. Skipping.", hr->hrm_index()); - pinned_old_regions->append(hr); - continue; - } - double predicted_time_ms = predict_region_total_time_ms(hr, false); - time_remaining_ms = MAX2(time_remaining_ms - predicted_time_ms, 0.0); - // Add regions to old set until we reach the minimum amount - if (initial_old_regions->length() < min_old_cset_length) { - initial_old_regions->append(hr); - num_initial_regions_selected++; - predicted_initial_time_ms += predicted_time_ms; - // Record the number of regions added with no time remaining - if (time_remaining_ms == 0.0) { - num_expensive_regions++; - } - } else if (!check_time_remaining) { - // In the non-auto-tuning case, we'll finish adding regions - // to the CSet if we reach the minimum. - print_finish_message("Region amount reached min", true); - break; - } else { - // Keep adding regions to old set until we reach the optional threshold - if (time_remaining_ms > optional_threshold_ms) { - predicted_initial_time_ms += predicted_time_ms; - initial_old_regions->append(hr); - num_initial_regions_selected++; - } else if (time_remaining_ms > 0) { - // Keep adding optional regions until time is up. - assert(optional_old_regions->length() < max_optional_regions, "Should not be possible."); - predicted_optional_time_ms += predicted_time_ms; - optional_old_regions->append(hr); - num_optional_regions_selected++; - } else { - print_finish_message("Predicted time too high", true); - break; - } - } - } - if (iter == marking_list->end()) { - log_debug(gc, ergo, cset)("Marking candidates exhausted."); - } - - if (num_expensive_regions > 0) { - log_debug(gc, ergo, cset)("Added %u marking candidates to collection set although the predicted time was too high.", - num_expensive_regions); - } - - log_debug(gc, ergo, cset)("Finish adding marking candidates to collection set. Initial: %u, optional: %u, pinned: %u, " - "predicted initial time: %1.2fms, predicted optional time: %1.2fms, time remaining: %1.2fms", - num_initial_regions_selected, num_optional_regions_selected, num_pinned_regions, - predicted_initial_time_ms, predicted_optional_time_ms, time_remaining_ms); - - assert(initial_old_regions->length() == num_initial_regions_selected, "must be"); - assert(optional_old_regions->length() == num_optional_regions_selected, "must be"); - return time_remaining_ms; -} - -void G1Policy::select_candidates_from_retained(G1CollectionCandidateList* retained_list, - double time_remaining_ms, - G1CollectionCandidateRegionList* initial_old_regions, - G1CollectionCandidateRegionList* optional_old_regions, - G1CollectionCandidateRegionList* pinned_old_regions) { - - uint const min_regions = min_retained_old_cset_length(); - - uint num_initial_regions_selected = 0; - uint num_optional_regions_selected = 0; - uint num_expensive_regions_selected = 0; - uint num_pinned_regions = 0; - - double predicted_initial_time_ms = 0.0; - double predicted_optional_time_ms = 0.0; - - // We want to make sure that on the one hand we process the retained regions asap, - // but on the other hand do not take too many of them as optional regions. - // So we split the time budget into budget we will unconditionally take into the - // initial old regions, and budget for taking optional regions from the retained - // list. - double optional_time_remaining_ms = max_time_for_retaining(); - time_remaining_ms = MIN2(time_remaining_ms, optional_time_remaining_ms); - - log_debug(gc, ergo, cset)("Start adding retained candidates to collection set. " - "Min %u regions, available %u, " - "time remaining %1.2fms, optional remaining %1.2fms", - min_regions, retained_list->length(), time_remaining_ms, optional_time_remaining_ms); - - for (G1CollectionSetCandidateInfo* ci : *retained_list) { - G1HeapRegion* r = ci->_r; - double predicted_time_ms = predict_region_total_time_ms(r, collector_state()->in_young_only_phase()); - bool fits_in_remaining_time = predicted_time_ms <= time_remaining_ms; - // If we can't reclaim that region ignore it for now. - if (r->has_pinned_objects()) { - num_pinned_regions++; - if (ci->update_num_unreclaimed()) { - log_trace(gc, ergo, cset)("Retained candidate %u can not be reclaimed currently. Skipping.", r->hrm_index()); - } else { - log_trace(gc, ergo, cset)("Retained candidate %u can not be reclaimed currently. Dropping.", r->hrm_index()); - pinned_old_regions->append(r); - } - continue; - } - - if (fits_in_remaining_time || (num_expensive_regions_selected < min_regions)) { - predicted_initial_time_ms += predicted_time_ms; - if (!fits_in_remaining_time) { - num_expensive_regions_selected++; - } - initial_old_regions->append(r); - num_initial_regions_selected++; - } else if (predicted_time_ms <= optional_time_remaining_ms) { - predicted_optional_time_ms += predicted_time_ms; - optional_old_regions->append(r); - num_optional_regions_selected++; - } else { - // Fits neither initial nor optional time limit. Exit. - break; - } - time_remaining_ms = MAX2(0.0, time_remaining_ms - predicted_time_ms); - optional_time_remaining_ms = MAX2(0.0, optional_time_remaining_ms - predicted_time_ms); - } - - uint num_regions_selected = num_initial_regions_selected + num_optional_regions_selected; - if (num_regions_selected == retained_list->length()) { - log_debug(gc, ergo, cset)("Retained candidates exhausted."); - } - if (num_expensive_regions_selected > 0) { - log_debug(gc, ergo, cset)("Added %u retained candidates to collection set although the predicted time was too high.", - num_expensive_regions_selected); - } - - log_debug(gc, ergo, cset)("Finish adding retained candidates to collection set. Initial: %u, optional: %u, pinned: %u, " - "predicted initial time: %1.2fms, predicted optional time: %1.2fms, " - "time remaining: %1.2fms optional time remaining %1.2fms", - num_initial_regions_selected, num_optional_regions_selected, num_pinned_regions, - predicted_initial_time_ms, predicted_optional_time_ms, time_remaining_ms, optional_time_remaining_ms); -} - -void G1Policy::calculate_optional_collection_set_regions(G1CollectionCandidateRegionList* optional_regions, - double time_remaining_ms, - G1CollectionCandidateRegionList* selected_regions) { - assert(_collection_set->optional_region_length() > 0, - "Should only be called when there are optional regions"); - - double total_prediction_ms = 0.0; - - for (G1HeapRegion* r : *optional_regions) { - double prediction_ms = predict_region_total_time_ms(r, false); - - if (prediction_ms > time_remaining_ms) { - log_debug(gc, ergo, cset)("Prediction %.3fms for region %u does not fit remaining time: %.3fms.", - prediction_ms, r->hrm_index(), time_remaining_ms); - break; - } - // This region will be included in the next optional evacuation. - - total_prediction_ms += prediction_ms; - time_remaining_ms -= prediction_ms; - - selected_regions->append(r); - } - - log_debug(gc, ergo, cset)("Prepared %u regions out of %u for optional evacuation. Total predicted time: %.3fms", - selected_regions->length(), optional_regions->length(), total_prediction_ms); -} - void G1Policy::transfer_survivors_to_cset(const G1SurvivorRegions* survivors) { start_adding_survivor_regions(); diff --git a/src/hotspot/share/gc/g1/g1Policy.hpp b/src/hotspot/share/gc/g1/g1Policy.hpp index 98d44408467..9a6ffb570be 100644 --- a/src/hotspot/share/gc/g1/g1Policy.hpp +++ b/src/hotspot/share/gc/g1/g1Policy.hpp @@ -335,27 +335,7 @@ public: // Amount of allowed waste in bytes in the collection set. size_t allowed_waste_in_collection_set() const; - // Calculate and fill in the initial, optional and pinned old gen candidate regions from - // the given candidate list and the remaining time. - // Returns the remaining time. - double select_candidates_from_marking(G1CollectionCandidateList* marking_list, - double time_remaining_ms, - G1CollectionCandidateRegionList* initial_old_regions, - G1CollectionCandidateRegionList* optional_old_regions, - G1CollectionCandidateRegionList* pinned_old_regions); - void select_candidates_from_retained(G1CollectionCandidateList* retained_list, - double time_remaining_ms, - G1CollectionCandidateRegionList* initial_old_regions, - G1CollectionCandidateRegionList* optional_old_regions, - G1CollectionCandidateRegionList* pinned_old_regions); - - // Calculate the number of optional regions from the given collection set candidates, - // the remaining time and the maximum number of these regions and return the number - // of actually selected regions in num_optional_regions. - void calculate_optional_collection_set_regions(G1CollectionCandidateRegionList* optional_old_regions, - double time_remaining_ms, - G1CollectionCandidateRegionList* selected); private: @@ -423,12 +403,12 @@ private: size_t desired_survivor_size(uint max_regions) const; +public: // Fraction used when predicting how many optional regions to include in // the CSet. This fraction of the available time is used for optional regions, // the rest is used to add old regions to the normal CSet. double optional_prediction_fraction() const { return 0.2; } -public: // Fraction used when evacuating the optional regions. This fraction of the // remaining time is used to choose what regions to include in the evacuation. double optional_evacuation_fraction() const { return 0.75; } diff --git a/src/hotspot/share/gc/g1/g1Predictions.hpp b/src/hotspot/share/gc/g1/g1Predictions.hpp index 510f296a9f3..ae2a8f41880 100644 --- a/src/hotspot/share/gc/g1/g1Predictions.hpp +++ b/src/hotspot/share/gc/g1/g1Predictions.hpp @@ -29,8 +29,9 @@ // Utility class containing various helper methods for prediction. class G1Predictions { - private: - double _sigma; +private: + // Scale factor indicating to which degree stddev should be taking into account in predictions. + double _stddev_scale; // This function is used to estimate the stddev of sample sets. There is some // special consideration of small sample sets: the actual stddev for them is @@ -46,16 +47,14 @@ class G1Predictions { } return estimate; } - public: - G1Predictions(double sigma) : _sigma(sigma) { - assert(sigma >= 0.0, "Confidence must be larger than or equal to zero"); + +public: + G1Predictions(double stddev_scale) : _stddev_scale(stddev_scale) { + assert(stddev_scale >= 0.0, "must be"); } - // Confidence factor. - double sigma() const { return _sigma; } - double predict(TruncatedSeq const* seq) const { - return seq->davg() + _sigma * stddev_estimate(seq); + return seq->davg() + _stddev_scale * stddev_estimate(seq); } double predict_in_unit_interval(TruncatedSeq const* seq) const { diff --git a/src/hotspot/share/gc/g1/g1RegionToSpaceMapper.cpp b/src/hotspot/share/gc/g1/g1RegionToSpaceMapper.cpp index 5f903960cce..4403b4c8dd9 100644 --- a/src/hotspot/share/gc/g1/g1RegionToSpaceMapper.cpp +++ b/src/hotspot/share/gc/g1/g1RegionToSpaceMapper.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,15 +40,15 @@ G1RegionToSpaceMapper::G1RegionToSpaceMapper(ReservedSpace rs, size_t page_size, size_t region_granularity, size_t commit_factor, - MEMFLAGS type) : + MemTag mem_tag) : _listener(nullptr), _storage(rs, used_size, page_size), _region_commit_map(rs.size() * commit_factor / region_granularity, mtGC), - _memory_type(type) { + _memory_tag(mem_tag) { guarantee(is_power_of_2(page_size), "must be"); guarantee(is_power_of_2(region_granularity), "must be"); - MemTracker::record_virtual_memory_type((address)rs.base(), type); + MemTracker::record_virtual_memory_tag((address)rs.base(), mem_tag); } // Used to manually signal a mapper to handle a set of regions as committed. @@ -72,8 +72,8 @@ class G1RegionsLargerThanCommitSizeMapper : public G1RegionToSpaceMapper { size_t page_size, size_t alloc_granularity, size_t commit_factor, - MEMFLAGS type) : - G1RegionToSpaceMapper(rs, actual_size, page_size, alloc_granularity, commit_factor, type), + MemTag mem_tag) : + G1RegionToSpaceMapper(rs, actual_size, page_size, alloc_granularity, commit_factor, mem_tag), _pages_per_region(alloc_granularity / (page_size * commit_factor)) { guarantee(alloc_granularity >= page_size, "allocation granularity smaller than commit granularity"); @@ -97,7 +97,7 @@ class G1RegionsLargerThanCommitSizeMapper : public G1RegionToSpaceMapper { const size_t start_page = (size_t)start_idx * _pages_per_region; const size_t size_in_pages = num_regions * _pages_per_region; bool zero_filled = _storage.commit(start_page, size_in_pages); - if (_memory_type == mtJavaHeap) { + if (_memory_tag == mtJavaHeap) { for (uint region_index = start_idx; region_index < start_idx + num_regions; region_index++ ) { void* address = _storage.page_start(region_index * _pages_per_region); size_t size_in_bytes = _storage.page_size() * _pages_per_region; @@ -150,7 +150,7 @@ class G1RegionsSmallerThanCommitSizeMapper : public G1RegionToSpaceMapper { } void numa_request_on_node(size_t page_idx) { - if (_memory_type == mtJavaHeap) { + if (_memory_tag == mtJavaHeap) { uint region = (uint)(page_idx * _regions_per_page); void* address = _storage.page_start(page_idx); size_t size_in_bytes = _storage.page_size(); @@ -164,8 +164,8 @@ class G1RegionsSmallerThanCommitSizeMapper : public G1RegionToSpaceMapper { size_t page_size, size_t alloc_granularity, size_t commit_factor, - MEMFLAGS type) : - G1RegionToSpaceMapper(rs, actual_size, page_size, alloc_granularity, commit_factor, type), + MemTag mem_tag) : + G1RegionToSpaceMapper(rs, actual_size, page_size, alloc_granularity, commit_factor, mem_tag), _regions_per_page((page_size * commit_factor) / alloc_granularity), _lock(Mutex::service-3, "G1Mapper_lock") { @@ -263,10 +263,10 @@ G1RegionToSpaceMapper* G1RegionToSpaceMapper::create_mapper(ReservedSpace rs, size_t page_size, size_t region_granularity, size_t commit_factor, - MEMFLAGS type) { + MemTag mem_tag) { if (region_granularity >= (page_size * commit_factor)) { - return new G1RegionsLargerThanCommitSizeMapper(rs, actual_size, page_size, region_granularity, commit_factor, type); + return new G1RegionsLargerThanCommitSizeMapper(rs, actual_size, page_size, region_granularity, commit_factor, mem_tag); } else { - return new G1RegionsSmallerThanCommitSizeMapper(rs, actual_size, page_size, region_granularity, commit_factor, type); + return new G1RegionsSmallerThanCommitSizeMapper(rs, actual_size, page_size, region_granularity, commit_factor, mem_tag); } } diff --git a/src/hotspot/share/gc/g1/g1RegionToSpaceMapper.hpp b/src/hotspot/share/gc/g1/g1RegionToSpaceMapper.hpp index 02498b394b3..5ef0f8ec5ab 100644 --- a/src/hotspot/share/gc/g1/g1RegionToSpaceMapper.hpp +++ b/src/hotspot/share/gc/g1/g1RegionToSpaceMapper.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -52,9 +52,9 @@ class G1RegionToSpaceMapper : public CHeapObj { // Mapping management CHeapBitMap _region_commit_map; - MEMFLAGS _memory_type; + MemTag _memory_tag; - G1RegionToSpaceMapper(ReservedSpace rs, size_t used_size, size_t page_size, size_t region_granularity, size_t commit_factor, MEMFLAGS type); + G1RegionToSpaceMapper(ReservedSpace rs, size_t used_size, size_t page_size, size_t region_granularity, size_t commit_factor, MemTag mem_tag); void fire_on_commit(uint start_idx, size_t num_regions, bool zero_filled); public: @@ -85,7 +85,7 @@ class G1RegionToSpaceMapper : public CHeapObj { size_t page_size, size_t region_granularity, size_t byte_translation_factor, - MEMFLAGS type); + MemTag mem_tag); }; #endif // SHARE_GC_G1_G1REGIONTOSPACEMAPPER_HPP diff --git a/src/hotspot/share/gc/g1/g1RemSet.cpp b/src/hotspot/share/gc/g1/g1RemSet.cpp index f5f65cf1c48..bb5ac5036fe 100644 --- a/src/hotspot/share/gc/g1/g1RemSet.cpp +++ b/src/hotspot/share/gc/g1/g1RemSet.cpp @@ -967,6 +967,10 @@ class G1MergeHeapRootsTask : public WorkerTask { _merged[G1GCPhaseTimes::MergeRSCards] += increment; } + void dec_remset_cards(size_t decrement) { + _merged[G1GCPhaseTimes::MergeRSCards] -= decrement; + } + size_t merged(uint i) const { return _merged[i]; } }; @@ -1091,6 +1095,11 @@ class G1MergeHeapRootsTask : public WorkerTask { G1MergeCardSetStats stats() { _merge_card_set_cache.flush(); + // Compensation for the dummy cards that were initially pushed into the + // card cache. + // We do not need to compensate for the other counters because the dummy + // card mark will never update another counter because it is initally "dirty". + _stats.dec_remset_cards(G1MergeCardSetCache::CacheSize); return _stats; } }; diff --git a/src/hotspot/share/gc/g1/g1_globals.hpp b/src/hotspot/share/gc/g1/g1_globals.hpp index c8016ddc0dd..ed02ba2dc5c 100644 --- a/src/hotspot/share/gc/g1/g1_globals.hpp +++ b/src/hotspot/share/gc/g1/g1_globals.hpp @@ -111,7 +111,8 @@ range(1, max_intx) \ \ product(uint, G1ConfidencePercent, 50, \ - "Confidence level for MMU/pause predictions") \ + "Confidence level for MMU/pause predictions. A higher value " \ + "means that G1 will use less safety margin for its predictions.") \ range(1, 100) \ \ product(uintx, G1SummarizeRSetStatsPeriod, 0, DIAGNOSTIC, \ diff --git a/src/hotspot/share/gc/parallel/objectStartArray.cpp b/src/hotspot/share/gc/parallel/objectStartArray.cpp index b1fc956a54a..ef9de7abfd7 100644 --- a/src/hotspot/share/gc/parallel/objectStartArray.cpp +++ b/src/hotspot/share/gc/parallel/objectStartArray.cpp @@ -51,7 +51,7 @@ void ObjectStartArray::initialize(MemRegion reserved_region) { if (!backing_store.is_reserved()) { vm_exit_during_initialization("Could not reserve space for ObjectStartArray"); } - MemTracker::record_virtual_memory_type(backing_store.base(), mtGC); + MemTracker::record_virtual_memory_tag(backing_store.base(), mtGC); // We do not commit any memory initially _virtual_space.initialize(backing_store); diff --git a/src/hotspot/share/gc/parallel/parMarkBitMap.cpp b/src/hotspot/share/gc/parallel/parMarkBitMap.cpp index 658c3ef106f..46a178500e5 100644 --- a/src/hotspot/share/gc/parallel/parMarkBitMap.cpp +++ b/src/hotspot/share/gc/parallel/parMarkBitMap.cpp @@ -51,7 +51,7 @@ ParMarkBitMap::initialize(MemRegion covered_region) os::trace_page_sizes("Mark Bitmap", raw_bytes, raw_bytes, rs.base(), rs.size(), used_page_sz); - MemTracker::record_virtual_memory_type((address)rs.base(), mtGC); + MemTracker::record_virtual_memory_tag((address)rs.base(), mtGC); _virtual_space = new PSVirtualSpace(rs, page_sz); if (_virtual_space != nullptr && _virtual_space->expand_by(_reserved_byte_size)) { diff --git a/src/hotspot/share/gc/parallel/psParallelCompact.cpp b/src/hotspot/share/gc/parallel/psParallelCompact.cpp index 4bff8f8a7d0..1ab7b2af7ed 100644 --- a/src/hotspot/share/gc/parallel/psParallelCompact.cpp +++ b/src/hotspot/share/gc/parallel/psParallelCompact.cpp @@ -235,7 +235,7 @@ ParallelCompactData::create_vspace(size_t count, size_t element_size) os::trace_page_sizes("Parallel Compact Data", raw_bytes, raw_bytes, rs.base(), rs.size(), page_sz); - MemTracker::record_virtual_memory_type((address)rs.base(), mtGC); + MemTracker::record_virtual_memory_tag((address)rs.base(), mtGC); PSVirtualSpace* vspace = new PSVirtualSpace(rs, page_sz); if (vspace != nullptr) { diff --git a/src/hotspot/share/gc/parallel/psScavenge.hpp b/src/hotspot/share/gc/parallel/psScavenge.hpp index 99d0487760b..55abdfd3cf3 100644 --- a/src/hotspot/share/gc/parallel/psScavenge.hpp +++ b/src/hotspot/share/gc/parallel/psScavenge.hpp @@ -34,9 +34,7 @@ #include "oops/oop.hpp" #include "utilities/stack.hpp" -class ReferenceProcessor; class ParallelScavengeHeap; -class ParallelScavengeTracer; class PSIsAliveClosure; class STWGCTimer; diff --git a/src/hotspot/share/gc/serial/serialBlockOffsetTable.cpp b/src/hotspot/share/gc/serial/serialBlockOffsetTable.cpp index 59b7f130df3..31f18652c63 100644 --- a/src/hotspot/share/gc/serial/serialBlockOffsetTable.cpp +++ b/src/hotspot/share/gc/serial/serialBlockOffsetTable.cpp @@ -42,7 +42,7 @@ SerialBlockOffsetTable::SerialBlockOffsetTable(MemRegion reserved, vm_exit_during_initialization("Could not reserve enough space for heap offset array"); } - MemTracker::record_virtual_memory_type((address)rs.base(), mtGC); + MemTracker::record_virtual_memory_tag((address)rs.base(), mtGC); if (!_vs.initialize(rs, 0)) { vm_exit_during_initialization("Could not reserve enough space for heap offset array"); diff --git a/src/hotspot/share/gc/shared/c2/barrierSetC2.cpp b/src/hotspot/share/gc/shared/c2/barrierSetC2.cpp index 59e02452044..643a7936b9b 100644 --- a/src/hotspot/share/gc/shared/c2/barrierSetC2.cpp +++ b/src/hotspot/share/gc/shared/c2/barrierSetC2.cpp @@ -109,6 +109,10 @@ Label* BarrierStubC2::continuation() { return &_continuation; } +uint8_t BarrierStubC2::barrier_data() const { + return _node->barrier_data(); +} + void BarrierStubC2::preserve(Register r) { const VMReg vm_reg = r->as_VMReg(); assert(vm_reg->is_Register(), "r must be a general-purpose register"); diff --git a/src/hotspot/share/gc/shared/c2/barrierSetC2.hpp b/src/hotspot/share/gc/shared/c2/barrierSetC2.hpp index c1485c069c8..00fbf1f2c9f 100644 --- a/src/hotspot/share/gc/shared/c2/barrierSetC2.hpp +++ b/src/hotspot/share/gc/shared/c2/barrierSetC2.hpp @@ -254,6 +254,8 @@ public: Label* entry(); // Return point from the stub (typically end of barrier). Label* continuation(); + // High-level, GC-specific barrier flags. + uint8_t barrier_data() const; // Preserve the value in reg across runtime calls in this barrier. void preserve(Register reg); @@ -340,6 +342,8 @@ public: // Estimated size of the node barrier in number of C2 Ideal nodes. // This is used to guide heuristics in C2, e.g. whether to unroll a loop. virtual uint estimated_barrier_size(const Node* node) const { return 0; } + // Whether the given store can be used to initialize a newly allocated object. + virtual bool can_initialize_object(const StoreNode* store) const { return true; } enum CompilePhase { BeforeOptimize, diff --git a/src/hotspot/share/gc/shared/c2/cardTableBarrierSetC2.cpp b/src/hotspot/share/gc/shared/c2/cardTableBarrierSetC2.cpp index 87bb9f3cd51..11b742156a8 100644 --- a/src/hotspot/share/gc/shared/c2/cardTableBarrierSetC2.cpp +++ b/src/hotspot/share/gc/shared/c2/cardTableBarrierSetC2.cpp @@ -125,39 +125,10 @@ void CardTableBarrierSetC2::post_barrier(GraphKit* kit, kit->final_sync(ideal); } -void CardTableBarrierSetC2::clone(GraphKit* kit, Node* src, Node* dst, Node* size, bool is_array) const { - BarrierSetC2::clone(kit, src, dst, size, is_array); - const TypePtr* raw_adr_type = TypeRawPtr::BOTTOM; - - // If necessary, emit some card marks afterwards. (Non-arrays only.) - bool card_mark = !is_array && !use_ReduceInitialCardMarks(); - if (card_mark) { - assert(!is_array, ""); - // Put in store barrier for any and all oops we are sticking - // into this object. (We could avoid this if we could prove - // that the object type contains no oop fields at all.) - Node* no_particular_value = nullptr; - Node* no_particular_field = nullptr; - int raw_adr_idx = Compile::AliasIdxRaw; - post_barrier(kit, kit->control(), - kit->memory(raw_adr_type), - dst, - no_particular_field, - raw_adr_idx, - no_particular_value, - T_OBJECT, - false); - } -} - bool CardTableBarrierSetC2::use_ReduceInitialCardMarks() const { return ReduceInitialCardMarks; } -bool CardTableBarrierSetC2::is_gc_barrier_node(Node* node) const { - return ModRefBarrierSetC2::is_gc_barrier_node(node) || node->Opcode() == Op_StoreCM; -} - void CardTableBarrierSetC2::eliminate_gc_barrier(PhaseMacroExpand* macro, Node* node) const { assert(node->Opcode() == Op_CastP2X, "ConvP2XNode required"); Node *shift = node->unique_out(); diff --git a/src/hotspot/share/gc/shared/c2/cardTableBarrierSetC2.hpp b/src/hotspot/share/gc/shared/c2/cardTableBarrierSetC2.hpp index 9512f09ff8a..3bbf14892d3 100644 --- a/src/hotspot/share/gc/shared/c2/cardTableBarrierSetC2.hpp +++ b/src/hotspot/share/gc/shared/c2/cardTableBarrierSetC2.hpp @@ -42,8 +42,6 @@ protected: Node* byte_map_base_node(GraphKit* kit) const; public: - virtual void clone(GraphKit* kit, Node* src, Node* dst, Node* size, bool is_array) const; - virtual bool is_gc_barrier_node(Node* node) const; virtual void eliminate_gc_barrier(PhaseMacroExpand* macro, Node* node) const; virtual bool array_copy_requires_gc_barriers(bool tightly_coupled_alloc, BasicType type, bool is_clone, bool is_clone_instance, ArrayCopyPhase phase) const; diff --git a/src/hotspot/share/gc/shared/cardTable.cpp b/src/hotspot/share/gc/shared/cardTable.cpp index 95f7058f4e4..acd4bda6e10 100644 --- a/src/hotspot/share/gc/shared/cardTable.cpp +++ b/src/hotspot/share/gc/shared/cardTable.cpp @@ -84,7 +84,7 @@ void CardTable::initialize(void* region0_start, void* region1_start) { MAX2(_page_size, os::vm_allocation_granularity()); ReservedSpace heap_rs(_byte_map_size, rs_align, _page_size); - MemTracker::record_virtual_memory_type((address)heap_rs.base(), mtGC); + MemTracker::record_virtual_memory_tag((address)heap_rs.base(), mtGC); os::trace_page_sizes("Card Table", num_bytes, num_bytes, heap_rs.base(), heap_rs.size(), _page_size); diff --git a/src/hotspot/share/gc/shared/oopStorage.cpp b/src/hotspot/share/gc/shared/oopStorage.cpp index 7117b86b264..2373d6b1d93 100644 --- a/src/hotspot/share/gc/shared/oopStorage.cpp +++ b/src/hotspot/share/gc/shared/oopStorage.cpp @@ -127,10 +127,10 @@ OopStorage::ActiveArray::~ActiveArray() { } OopStorage::ActiveArray* OopStorage::ActiveArray::create(size_t size, - MEMFLAGS memflags, + MemTag mem_tag, AllocFailType alloc_fail) { size_t size_in_bytes = blocks_offset() + sizeof(Block*) * size; - void* mem = NEW_C_HEAP_ARRAY3(char, size_in_bytes, memflags, CURRENT_PC, alloc_fail); + void* mem = NEW_C_HEAP_ARRAY3(char, size_in_bytes, mem_tag, CURRENT_PC, alloc_fail); if (mem == nullptr) return nullptr; return new (mem) ActiveArray(size); } @@ -300,7 +300,12 @@ void OopStorage::Block::set_active_index(size_t index) { size_t OopStorage::Block::active_index_safe(const Block* block) { STATIC_ASSERT(sizeof(intptr_t) == sizeof(block->_active_index)); - return SafeFetchN((intptr_t*)&block->_active_index, 0); + // Be careful, because block could be a false positive from block_for_ptr. + assert(block != nullptr, "precondition"); + uintptr_t block_addr = reinterpret_cast(block); + uintptr_t index_loc = block_addr + offset_of(Block, _active_index); + static_assert(sizeof(size_t) == sizeof(intptr_t), "assumption"); + return static_cast(SafeFetchN(reinterpret_cast(index_loc), 0)); } unsigned OopStorage::Block::get_index(const oop* ptr) const { @@ -343,7 +348,7 @@ OopStorage::Block* OopStorage::Block::new_block(const OopStorage* owner) { // _data must be first member: aligning block => aligning _data. STATIC_ASSERT(_data_pos == 0); size_t size_needed = allocation_size(); - void* memory = NEW_C_HEAP_ARRAY_RETURN_NULL(char, size_needed, owner->memflags()); + void* memory = NEW_C_HEAP_ARRAY_RETURN_NULL(char, size_needed, owner->mem_tag()); if (memory == nullptr) { return nullptr; } @@ -366,21 +371,23 @@ void OopStorage::Block::delete_block(const Block& block) { OopStorage::Block* OopStorage::Block::block_for_ptr(const OopStorage* owner, const oop* ptr) { STATIC_ASSERT(_data_pos == 0); - // Const-ness of ptr is not related to const-ness of containing block. + assert(ptr != nullptr, "precondition"); // Blocks are allocated section-aligned, so get the containing section. - oop* section_start = align_down(const_cast(ptr), block_alignment); + uintptr_t section_start = align_down(reinterpret_cast(ptr), block_alignment); // Start with a guess that the containing section is the last section, // so the block starts section_count-1 sections earlier. - oop* section = section_start - (section_size * (section_count - 1)); + size_t section_size_in_bytes = sizeof(oop) * section_size; + uintptr_t section = section_start - (section_size_in_bytes * (section_count - 1)); // Walk up through the potential block start positions, looking for // the owner in the expected location. If we're below the actual block // start position, the value at the owner position will be some oop // (possibly null), which can never match the owner. intptr_t owner_addr = reinterpret_cast(owner); - for (unsigned i = 0; i < section_count; ++i, section += section_size) { - Block* candidate = reinterpret_cast(section); - if (SafeFetchN(&candidate->_owner_address, 0) == owner_addr) { - return candidate; + for (unsigned i = 0; i < section_count; ++i, section += section_size_in_bytes) { + uintptr_t owner_loc = section + offset_of(Block, _owner_address); + static_assert(sizeof(OopStorage*) == sizeof(intptr_t), "assumption"); + if (SafeFetchN(reinterpret_cast(owner_loc), 0) == owner_addr) { + return reinterpret_cast(section); } } return nullptr; @@ -575,7 +582,7 @@ bool OopStorage::expand_active_array() { log_debug(oopstorage, blocks)("%s: expand active array " SIZE_FORMAT, name(), new_size); ActiveArray* new_array = ActiveArray::create(new_size, - memflags(), + mem_tag(), AllocFailStrategy::RETURN_NULL); if (new_array == nullptr) return false; new_array->copy_from(old_array); @@ -643,8 +650,7 @@ public: } }; -OopStorage::Block* OopStorage::find_block_or_null(const oop* ptr) const { - assert(ptr != nullptr, "precondition"); +OopStorage::Block* OopStorage::block_for_ptr(const oop* ptr) const { return Block::block_for_ptr(this, ptr); } @@ -771,7 +777,7 @@ static inline void check_release_entry(const oop* entry) { void OopStorage::release(const oop* ptr) { check_release_entry(ptr); - Block* block = find_block_or_null(ptr); + Block* block = block_for_ptr(ptr); assert(block != nullptr, "%s: invalid release " PTR_FORMAT, name(), p2i(ptr)); log_trace(oopstorage, ref)("%s: releasing " PTR_FORMAT, name(), p2i(ptr)); block->release_entries(block->bitmask_for_entry(ptr), this); @@ -782,7 +788,7 @@ void OopStorage::release(const oop* const* ptrs, size_t size) { size_t i = 0; while (i < size) { check_release_entry(ptrs[i]); - Block* block = find_block_or_null(ptrs[i]); + Block* block = block_for_ptr(ptrs[i]); assert(block != nullptr, "%s: invalid release " PTR_FORMAT, name(), p2i(ptrs[i])); size_t count = 0; uintx releasing = 0; @@ -805,8 +811,8 @@ void OopStorage::release(const oop* const* ptrs, size_t size) { } } -OopStorage* OopStorage::create(const char* name, MEMFLAGS memflags) { - return new (memflags) OopStorage(name, memflags); +OopStorage* OopStorage::create(const char* name, MemTag mem_tag) { + return new (mem_tag) OopStorage(name, mem_tag); } const size_t initial_active_array_size = 8; @@ -819,9 +825,9 @@ static Mutex* make_oopstorage_mutex(const char* storage_name, return new PaddedMutex(rank, name); } -OopStorage::OopStorage(const char* name, MEMFLAGS memflags) : +OopStorage::OopStorage(const char* name, MemTag mem_tag) : _name(os::strdup(name)), - _active_array(ActiveArray::create(initial_active_array_size, memflags)), + _active_array(ActiveArray::create(initial_active_array_size, mem_tag)), _allocation_list(), _deferred_updates(nullptr), _allocation_mutex(make_oopstorage_mutex(name, "alloc", Mutex::oopstorage)), @@ -829,7 +835,7 @@ OopStorage::OopStorage(const char* name, MEMFLAGS memflags) : _num_dead_callback(nullptr), _allocation_count(0), _concurrent_iteration_count(0), - _memflags(memflags), + _mem_tag(mem_tag), _needs_cleanup(false) { _active_array->increment_refcount(); @@ -989,7 +995,8 @@ bool OopStorage::delete_empty_blocks() { } OopStorage::EntryStatus OopStorage::allocation_status(const oop* ptr) const { - const Block* block = find_block_or_null(ptr); + if (ptr == nullptr) return INVALID_ENTRY; + const Block* block = block_for_ptr(ptr); if (block != nullptr) { // Prevent block deletion and _active_array modification. MutexLocker ml(_allocation_mutex, Mutex::_no_safepoint_check_flag); @@ -1030,7 +1037,7 @@ size_t OopStorage::total_memory_usage() const { return total_size; } -MEMFLAGS OopStorage::memflags() const { return _memflags; } +MemTag OopStorage::mem_tag() const { return _mem_tag; } // Parallel iteration support @@ -1135,6 +1142,26 @@ void OopStorage::BasicParState::report_num_dead() const { const char* OopStorage::name() const { return _name; } +bool OopStorage::print_containing(const oop* addr, outputStream* st) { + if (addr != nullptr) { + Block* block = block_for_ptr(addr); + if (block != nullptr && block->print_containing(addr, st)) { + st->print(" in oop storage \"%s\"", name()); + return true; + } + } + return false; +} + +bool OopStorage::Block::print_containing(const oop* addr, outputStream* st) { + if (contains(addr)) { + st->print(PTR_FORMAT " is a pointer %u/%zu into block %zu", + p2i(addr), get_index(addr), ARRAY_SIZE(_data), _active_index); + return true; + } + return false; +} + #ifndef PRODUCT void OopStorage::print_on(outputStream* st) const { diff --git a/src/hotspot/share/gc/shared/oopStorage.hpp b/src/hotspot/share/gc/shared/oopStorage.hpp index dfc0f83fc19..34c980a0586 100644 --- a/src/hotspot/share/gc/shared/oopStorage.hpp +++ b/src/hotspot/share/gc/shared/oopStorage.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -74,7 +74,7 @@ class outputStream; class OopStorage : public CHeapObjBase { public: - static OopStorage* create(const char* name, MEMFLAGS memflags); + static OopStorage* create(const char* name, MemTag mem_tag); ~OopStorage(); // These count and usage accessors are racy unless at a safepoint. @@ -89,8 +89,8 @@ public: // bookkeeping overhead, including this storage object. size_t total_memory_usage() const; - // The memory type for allocations. - MEMFLAGS memflags() const; + // The memory tag for allocations. + MemTag mem_tag() const; enum EntryStatus { INVALID_ENTRY, @@ -213,6 +213,7 @@ public: // Debugging and logging support. const char* name() const; void print_on(outputStream* st) const PRODUCT_RETURN; + bool print_containing(const oop* addr, outputStream* st); // Provides access to storage internals, for unit testing. // Declare, but not define, the public class OopStorage::TestAccess. @@ -273,21 +274,21 @@ private: // mutable because this gets set even for const iteration. mutable int _concurrent_iteration_count; - // The memory type for allocations. - MEMFLAGS _memflags; + // The memory tag for allocations. + MemTag _mem_tag; // Flag indicating this storage object is a candidate for empty block deletion. volatile bool _needs_cleanup; // Clients construct via "create" factory function. - OopStorage(const char* name, MEMFLAGS memflags); + OopStorage(const char* name, MemTag mem_tag); NONCOPYABLE(OopStorage); bool try_add_block(); Block* block_for_allocation(); void log_block_transition(Block* block, const char* new_state) const; - Block* find_block_or_null(const oop* ptr) const; + Block* block_for_ptr(const oop* ptr) const; void delete_empty_block(const Block& block); bool reduce_deferred_updates(); void record_needs_cleanup(); diff --git a/src/hotspot/share/gc/shared/oopStorage.inline.hpp b/src/hotspot/share/gc/shared/oopStorage.inline.hpp index e1e815acd09..da0926a20b6 100644 --- a/src/hotspot/share/gc/shared/oopStorage.inline.hpp +++ b/src/hotspot/share/gc/shared/oopStorage.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -60,7 +60,7 @@ class OopStorage::ActiveArray { public: static ActiveArray* create(size_t size, - MEMFLAGS memflags = mtGC, + MemTag mem_tag = mtGC, AllocFailType alloc_fail = AllocFailStrategy::EXIT_OOM); static void destroy(ActiveArray* ba); @@ -184,7 +184,10 @@ public: void set_active_index(size_t index); static size_t active_index_safe(const Block* block); // Returns 0 if access fails. - // Returns null if ptr is not in a block or not allocated in that block. + // Return block of owner containing ptr, if ptr is a valid entry of owner. + // If ptr is not a valid entry of owner then returns either null or a "false + // positive" pointer; see allocation_status. + // precondition: ptr != nullptr static Block* block_for_ptr(const OopStorage* owner, const oop* ptr); oop* allocate(); @@ -196,6 +199,8 @@ public: template bool iterate(F f); template bool iterate(F f) const; + + bool print_containing(const oop* addr, outputStream* st); }; // class Block inline OopStorage::Block* OopStorage::AllocationList::head() { diff --git a/src/hotspot/share/gc/shared/oopStorageSet.cpp b/src/hotspot/share/gc/shared/oopStorageSet.cpp index e119e570759..e3a9fccbad3 100644 --- a/src/hotspot/share/gc/shared/oopStorageSet.cpp +++ b/src/hotspot/share/gc/shared/oopStorageSet.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,18 +31,18 @@ OopStorage* OopStorageSet::_storages[all_count] = {}; -OopStorage* OopStorageSet::create_strong(const char* name, MEMFLAGS memflags) { +OopStorage* OopStorageSet::create_strong(const char* name, MemTag mem_tag) { static uint registered_strong = 0; assert(registered_strong < strong_count, "More registered strong storages than slots"); - OopStorage* storage = OopStorage::create(name, memflags); + OopStorage* storage = OopStorage::create(name, mem_tag); _storages[strong_start + registered_strong++] = storage; return storage; } -OopStorage* OopStorageSet::create_weak(const char* name, MEMFLAGS memflags) { +OopStorage* OopStorageSet::create_weak(const char* name, MemTag mem_tag) { static uint registered_weak = 0; assert(registered_weak < weak_count, "More registered strong storages than slots"); - OopStorage* storage = OopStorage::create(name, memflags); + OopStorage* storage = OopStorage::create(name, mem_tag); _storages[weak_start + registered_weak++] = storage; return storage; } @@ -82,6 +82,25 @@ template OopStorage* OopStorageSet::get_storage(StrongId); template OopStorage* OopStorageSet::get_storage(WeakId); template OopStorage* OopStorageSet::get_storage(Id); +bool OopStorageSet::print_containing(const void* addr, outputStream* st) { + if (addr != nullptr) { + const void* aligned_addr = align_down(addr, alignof(oop)); + for (OopStorage* storage : Range()) { + // Check for null for extra safety: might get here while handling error + // before storage initialization. + if ((storage != nullptr) && storage->print_containing((oop*) aligned_addr, st)) { + if (aligned_addr != addr) { + st->print_cr(" (unaligned)"); + } else { + st->cr(); + } + return true; + } + } + } + return false; +} + #ifdef ASSERT void OopStorageSet::verify_initialized(uint index) { diff --git a/src/hotspot/share/gc/shared/oopStorageSet.hpp b/src/hotspot/share/gc/shared/oopStorageSet.hpp index 26e0e9f5a77..867172c41ad 100644 --- a/src/hotspot/share/gc/shared/oopStorageSet.hpp +++ b/src/hotspot/share/gc/shared/oopStorageSet.hpp @@ -25,7 +25,8 @@ #ifndef SHARE_GC_SHARED_OOPSTORAGESET_HPP #define SHARE_GC_SHARED_OOPSTORAGESET_HPP -#include "nmt/memflags.hpp" +#include "nmt/memTag.hpp" +#include "oops/oop.hpp" #include "utilities/debug.hpp" #include "utilities/enumIterator.hpp" #include "utilities/globalDefinitions.hpp" @@ -79,8 +80,8 @@ public: static OopStorage* storage(WeakId id) { return get_storage(id); } static OopStorage* storage(Id id) { return get_storage(id); } - static OopStorage* create_strong(const char* name, MEMFLAGS memflags); - static OopStorage* create_weak(const char* name, MEMFLAGS memflags); + static OopStorage* create_strong(const char* name, MemTag mem_tag); + static OopStorage* create_weak(const char* name, MemTag mem_tag); // Support iteration over the storage objects. template class Range; @@ -89,6 +90,8 @@ public: template static void strong_oops_do(Closure* cl); + // Debugging: print location info, if in storage. + static bool print_containing(const void* addr, outputStream* st); }; ENUMERATOR_VALUE_RANGE(OopStorageSet::StrongId, diff --git a/src/hotspot/share/gc/shared/partialArrayState.cpp b/src/hotspot/share/gc/shared/partialArrayState.cpp index fd23a320222..48ef974ecfa 100644 --- a/src/hotspot/share/gc/shared/partialArrayState.cpp +++ b/src/hotspot/share/gc/shared/partialArrayState.cpp @@ -26,7 +26,7 @@ #include "gc/shared/partialArrayState.hpp" #include "memory/allocation.inline.hpp" #include "memory/arena.hpp" -#include "nmt/memflags.hpp" +#include "nmt/memTag.hpp" #include "oops/oopsHierarchy.hpp" #include "runtime/atomic.hpp" #include "runtime/orderAccess.hpp" diff --git a/src/hotspot/share/gc/shared/stringdedup/stringDedupProcessor.cpp b/src/hotspot/share/gc/shared/stringdedup/stringDedupProcessor.cpp index aab2f5d3123..ab85c293941 100644 --- a/src/hotspot/share/gc/shared/stringdedup/stringDedupProcessor.cpp +++ b/src/hotspot/share/gc/shared/stringdedup/stringDedupProcessor.cpp @@ -35,7 +35,7 @@ #include "gc/shared/stringdedup/stringDedupTable.hpp" #include "logging/log.hpp" #include "memory/iterator.hpp" -#include "nmt/memflags.hpp" +#include "nmt/memTag.hpp" #include "oops/access.inline.hpp" #include "runtime/atomic.hpp" #include "runtime/cpuTimeCounters.hpp" diff --git a/src/hotspot/share/gc/shared/taskqueue.hpp b/src/hotspot/share/gc/shared/taskqueue.hpp index f4a3731583b..efbc1882fbe 100644 --- a/src/hotspot/share/gc/shared/taskqueue.hpp +++ b/src/hotspot/share/gc/shared/taskqueue.hpp @@ -116,8 +116,8 @@ void TaskQueueStats::reset() { // TaskQueueSuper collects functionality common to all GenericTaskQueue instances. -template -class TaskQueueSuper: public CHeapObj { +template +class TaskQueueSuper: public CHeapObj { protected: // Internal type for indexing the queue; also used for the tag. typedef NOT_LP64(uint16_t) LP64_ONLY(uint32_t) idx_t; @@ -324,39 +324,39 @@ public: // practice of parallel programming (PPoPP 2013), 69-80 // -template -class GenericTaskQueue: public TaskQueueSuper { +template +class GenericTaskQueue: public TaskQueueSuper { protected: - typedef typename TaskQueueSuper::Age Age; - typedef typename TaskQueueSuper::idx_t idx_t; + typedef typename TaskQueueSuper::Age Age; + typedef typename TaskQueueSuper::idx_t idx_t; - using TaskQueueSuper::MOD_N_MASK; + using TaskQueueSuper::MOD_N_MASK; - using TaskQueueSuper::bottom_relaxed; - using TaskQueueSuper::bottom_acquire; + using TaskQueueSuper::bottom_relaxed; + using TaskQueueSuper::bottom_acquire; - using TaskQueueSuper::set_bottom_relaxed; - using TaskQueueSuper::release_set_bottom; + using TaskQueueSuper::set_bottom_relaxed; + using TaskQueueSuper::release_set_bottom; - using TaskQueueSuper::age_relaxed; - using TaskQueueSuper::set_age_relaxed; - using TaskQueueSuper::cmpxchg_age; - using TaskQueueSuper::age_top_relaxed; + using TaskQueueSuper::age_relaxed; + using TaskQueueSuper::set_age_relaxed; + using TaskQueueSuper::cmpxchg_age; + using TaskQueueSuper::age_top_relaxed; - using TaskQueueSuper::increment_index; - using TaskQueueSuper::decrement_index; - using TaskQueueSuper::dirty_size; - using TaskQueueSuper::clean_size; - using TaskQueueSuper::assert_not_underflow; + using TaskQueueSuper::increment_index; + using TaskQueueSuper::decrement_index; + using TaskQueueSuper::dirty_size; + using TaskQueueSuper::clean_size; + using TaskQueueSuper::assert_not_underflow; public: - typedef typename TaskQueueSuper::PopResult PopResult; + typedef typename TaskQueueSuper::PopResult PopResult; - using TaskQueueSuper::max_elems; - using TaskQueueSuper::size; + using TaskQueueSuper::max_elems; + using TaskQueueSuper::size; #if TASKQUEUE_STATS - using TaskQueueSuper::stats; + using TaskQueueSuper::stats; #endif private: @@ -428,12 +428,12 @@ public: // Note that size() is not hidden--it returns the number of elements in the // TaskQueue, and does not include the size of the overflow stack. This // simplifies replacement of GenericTaskQueues with OverflowTaskQueues. -template -class OverflowTaskQueue: public GenericTaskQueue +template +class OverflowTaskQueue: public GenericTaskQueue { public: - typedef Stack overflow_t; - typedef GenericTaskQueue taskqueue_t; + typedef Stack overflow_t; + typedef GenericTaskQueue taskqueue_t; TASKQUEUE_STATS_ONLY(using taskqueue_t::stats;) @@ -467,11 +467,11 @@ public: virtual uint tasks() const = 0; }; -template class TaskQueueSetSuperImpl: public CHeapObj, public TaskQueueSetSuper { +template class TaskQueueSetSuperImpl: public CHeapObj, public TaskQueueSetSuper { }; -template -class GenericTaskQueueSet: public TaskQueueSetSuperImpl { +template +class GenericTaskQueueSet: public TaskQueueSetSuperImpl { public: typedef typename T::element_type E; typedef typename T::PopResult PopResult; @@ -518,29 +518,29 @@ public: #endif // TASKQUEUE_STATS }; -template void -GenericTaskQueueSet::register_queue(uint i, T* q) { +template void +GenericTaskQueueSet::register_queue(uint i, T* q) { assert(i < _n, "index out of range."); _queues[i] = q; } -template T* -GenericTaskQueueSet::queue(uint i) { +template T* +GenericTaskQueueSet::queue(uint i) { assert(i < _n, "index out of range."); return _queues[i]; } #ifdef ASSERT -template -void GenericTaskQueueSet::assert_empty() const { +template +void GenericTaskQueueSet::assert_empty() const { for (uint j = 0; j < _n; j++) { _queues[j]->assert_empty(); } } #endif // ASSERT -template -uint GenericTaskQueueSet::tasks() const { +template +uint GenericTaskQueueSet::tasks() const { uint n = 0; for (uint j = 0; j < _n; j++) { n += _queues[j]->size(); diff --git a/src/hotspot/share/gc/shared/taskqueue.inline.hpp b/src/hotspot/share/gc/shared/taskqueue.inline.hpp index f937ce8a2e9..8e65cfd704f 100644 --- a/src/hotspot/share/gc/shared/taskqueue.inline.hpp +++ b/src/hotspot/share/gc/shared/taskqueue.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,30 +38,30 @@ #include "utilities/ostream.hpp" #include "utilities/stack.inline.hpp" -template -inline GenericTaskQueueSet::GenericTaskQueueSet(uint n) : _n(n) { +template +inline GenericTaskQueueSet::GenericTaskQueueSet(uint n) : _n(n) { typedef T* GenericTaskQueuePtr; - _queues = NEW_C_HEAP_ARRAY(GenericTaskQueuePtr, n, F); + _queues = NEW_C_HEAP_ARRAY(GenericTaskQueuePtr, n, MT); for (uint i = 0; i < n; i++) { _queues[i] = nullptr; } } -template -inline GenericTaskQueueSet::~GenericTaskQueueSet() { +template +inline GenericTaskQueueSet::~GenericTaskQueueSet() { FREE_C_HEAP_ARRAY(T*, _queues); } #if TASKQUEUE_STATS -template -void GenericTaskQueueSet::print_taskqueue_stats_hdr(outputStream* const st, const char* label) { +template +void GenericTaskQueueSet::print_taskqueue_stats_hdr(outputStream* const st, const char* label) { st->print_cr("GC Task Stats %s", label); st->print("thr "); TaskQueueStats::print_header(1, st); st->cr(); st->print("--- "); TaskQueueStats::print_header(2, st); st->cr(); } -template -void GenericTaskQueueSet::print_taskqueue_stats(outputStream* const st, const char* label) { +template +void GenericTaskQueueSet::print_taskqueue_stats(outputStream* const st, const char* label) { print_taskqueue_stats_hdr(st, label); TaskQueueStats totals; @@ -75,16 +75,16 @@ void GenericTaskQueueSet::print_taskqueue_stats(outputStream* const st, co DEBUG_ONLY(totals.verify()); } -template -void GenericTaskQueueSet::reset_taskqueue_stats() { +template +void GenericTaskQueueSet::reset_taskqueue_stats() { const uint n = size(); for (uint i = 0; i < n; ++i) { queue(i)->stats.reset(); } } -template -inline void GenericTaskQueueSet::print_and_reset_taskqueue_stats(const char* label) { +template +inline void GenericTaskQueueSet::print_and_reset_taskqueue_stats(const char* label) { if (!log_is_enabled(Trace, gc, task, stats)) { return; } @@ -97,19 +97,19 @@ inline void GenericTaskQueueSet::print_and_reset_taskqueue_stats(const cha } #endif // TASKQUEUE_STATS -template -inline GenericTaskQueue::GenericTaskQueue() : - _elems(MallocArrayAllocator::allocate(N, F)), +template +inline GenericTaskQueue::GenericTaskQueue() : + _elems(MallocArrayAllocator::allocate(N, MT)), _last_stolen_queue_id(InvalidQueueId), _seed(17 /* random number */) {} -template -inline GenericTaskQueue::~GenericTaskQueue() { +template +inline GenericTaskQueue::~GenericTaskQueue() { MallocArrayAllocator::free(_elems); } -template inline bool -GenericTaskQueue::push(E t) { +template inline bool +GenericTaskQueue::push(E t) { uint localBot = bottom_relaxed(); assert(localBot < N, "_bottom out of range."); idx_t top = age_top_relaxed(); @@ -134,8 +134,8 @@ GenericTaskQueue::push(E t) { return false; // Queue is full. } -template -inline bool OverflowTaskQueue::push(E t) { +template +inline bool OverflowTaskQueue::push(E t) { if (!taskqueue_t::push(t)) { overflow_stack()->push(t); TASKQUEUE_STATS_ONLY(stats.record_overflow(overflow_stack()->size())); @@ -143,8 +143,8 @@ inline bool OverflowTaskQueue::push(E t) { return true; } -template -inline bool OverflowTaskQueue::try_push_to_taskqueue(E t) { +template +inline bool OverflowTaskQueue::try_push_to_taskqueue(E t) { return taskqueue_t::push(t); } @@ -154,8 +154,8 @@ inline bool OverflowTaskQueue::try_push_to_taskqueue(E t) { // whenever the queue goes empty which it will do here if this thread // gets the last task or in pop_global() if the queue wraps (top == 0 // and pop_global() succeeds, see pop_global()). -template -bool GenericTaskQueue::pop_local_slow(uint localBot, Age oldAge) { +template +bool GenericTaskQueue::pop_local_slow(uint localBot, Age oldAge) { // This queue was observed to contain exactly one element; either this // thread will claim it, or a competing "pop_global". In either case, // the queue will be logically empty afterwards. Create a new Age value @@ -187,8 +187,8 @@ bool GenericTaskQueue::pop_local_slow(uint localBot, Age oldAge) { return false; } -template inline bool -GenericTaskQueue::pop_local(E& t, uint threshold) { +template inline bool +GenericTaskQueue::pop_local(E& t, uint threshold) { uint localBot = bottom_relaxed(); // This value cannot be N-1. That can only occur as a result of // the assignment to bottom in this method. If it does, this method @@ -224,8 +224,8 @@ GenericTaskQueue::pop_local(E& t, uint threshold) { } } -template -bool OverflowTaskQueue::pop_overflow(E& t) +template +bool OverflowTaskQueue::pop_overflow(E& t) { if (overflow_empty()) return false; t = overflow_stack()->pop(); @@ -253,8 +253,8 @@ bool OverflowTaskQueue::pop_overflow(E& t) // (3) Owner starts a push, writing elems[bottom]. At the same time, Thief // reads elems[oldAge.top]. The owner's bottom == the thief's oldAge.top. // (4) Thief will discard the read value, because its cmpxchg of age will fail. -template -typename GenericTaskQueue::PopResult GenericTaskQueue::pop_global(E& t) { +template +typename GenericTaskQueue::PopResult GenericTaskQueue::pop_global(E& t) { Age oldAge = age_relaxed(); // Architectures with non-multi-copy-atomic memory model require a @@ -311,13 +311,13 @@ inline int randomParkAndMiller(int *seed0) { return seed; } -template -int GenericTaskQueue::next_random_queue_id() { +template +int GenericTaskQueue::next_random_queue_id() { return randomParkAndMiller(&_seed); } -template -typename GenericTaskQueueSet::PopResult GenericTaskQueueSet::steal_best_of_2(uint queue_num, E& t) { +template +typename GenericTaskQueueSet::PopResult GenericTaskQueueSet::steal_best_of_2(uint queue_num, E& t) { T* const local_queue = queue(queue_num); if (_n > 2) { uint k1 = queue_num; @@ -372,8 +372,8 @@ typename GenericTaskQueueSet::PopResult GenericTaskQueueSet::steal_b } } -template -bool GenericTaskQueueSet::steal(uint queue_num, E& t) { +template +bool GenericTaskQueueSet::steal(uint queue_num, E& t) { uint const num_retries = 2 * _n; TASKQUEUE_STATS_ONLY(uint contended_in_a_row = 0;) @@ -394,9 +394,9 @@ bool GenericTaskQueueSet::steal(uint queue_num, E& t) { return false; } -template +template template -inline void GenericTaskQueue::iterate(Fn fn) { +inline void GenericTaskQueue::iterate(Fn fn) { uint iters = size(); uint index = bottom_relaxed(); for (uint i = 0; i < iters; ++i) { diff --git a/src/hotspot/share/gc/shenandoah/c1/shenandoahBarrierSetC1.cpp b/src/hotspot/share/gc/shenandoah/c1/shenandoahBarrierSetC1.cpp index 6b104e7e199..0e8b02d247e 100644 --- a/src/hotspot/share/gc/shenandoah/c1/shenandoahBarrierSetC1.cpp +++ b/src/hotspot/share/gc/shenandoah/c1/shenandoahBarrierSetC1.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2022, Red Hat, Inc. All rights reserved. + * Copyright (c) 2018, 2024, 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 @@ -263,27 +263,27 @@ public: void ShenandoahBarrierSetC1::generate_c1_runtime_stubs(BufferBlob* buffer_blob) { C1ShenandoahPreBarrierCodeGenClosure pre_code_gen_cl; - _pre_barrier_c1_runtime_code_blob = Runtime1::generate_blob(buffer_blob, -1, + _pre_barrier_c1_runtime_code_blob = Runtime1::generate_blob(buffer_blob, C1StubId::NO_STUBID, "shenandoah_pre_barrier_slow", false, &pre_code_gen_cl); if (ShenandoahLoadRefBarrier) { C1ShenandoahLoadReferenceBarrierCodeGenClosure lrb_strong_code_gen_cl(ON_STRONG_OOP_REF); - _load_reference_barrier_strong_rt_code_blob = Runtime1::generate_blob(buffer_blob, -1, + _load_reference_barrier_strong_rt_code_blob = Runtime1::generate_blob(buffer_blob, C1StubId::NO_STUBID, "shenandoah_load_reference_barrier_strong_slow", false, &lrb_strong_code_gen_cl); C1ShenandoahLoadReferenceBarrierCodeGenClosure lrb_strong_native_code_gen_cl(ON_STRONG_OOP_REF | IN_NATIVE); - _load_reference_barrier_strong_native_rt_code_blob = Runtime1::generate_blob(buffer_blob, -1, + _load_reference_barrier_strong_native_rt_code_blob = Runtime1::generate_blob(buffer_blob, C1StubId::NO_STUBID, "shenandoah_load_reference_barrier_strong_native_slow", false, &lrb_strong_native_code_gen_cl); C1ShenandoahLoadReferenceBarrierCodeGenClosure lrb_weak_code_gen_cl(ON_WEAK_OOP_REF); - _load_reference_barrier_weak_rt_code_blob = Runtime1::generate_blob(buffer_blob, -1, + _load_reference_barrier_weak_rt_code_blob = Runtime1::generate_blob(buffer_blob, C1StubId::NO_STUBID, "shenandoah_load_reference_barrier_weak_slow", false, &lrb_weak_code_gen_cl); C1ShenandoahLoadReferenceBarrierCodeGenClosure lrb_phantom_code_gen_cl(ON_PHANTOM_OOP_REF | IN_NATIVE); - _load_reference_barrier_phantom_rt_code_blob = Runtime1::generate_blob(buffer_blob, -1, + _load_reference_barrier_phantom_rt_code_blob = Runtime1::generate_blob(buffer_blob, C1StubId::NO_STUBID, "shenandoah_load_reference_barrier_phantom_slow", false, &lrb_phantom_code_gen_cl); } diff --git a/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.cpp b/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.cpp index d2820f3aa26..7ac9dcc2e81 100644 --- a/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.cpp +++ b/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.cpp @@ -249,8 +249,9 @@ void ShenandoahBarrierSetC2::satb_write_barrier_pre(GraphKit* kit, } __ else_(); { // logging buffer is full, call the runtime - const TypeFunc *tf = ShenandoahBarrierSetC2::write_ref_field_pre_entry_Type(); - __ make_leaf_call(tf, CAST_FROM_FN_PTR(address, ShenandoahRuntime::write_ref_field_pre_entry), "shenandoah_wb_pre", pre_val, tls); + const TypeFunc *tf = ShenandoahBarrierSetC2::write_ref_field_pre_Type(); + __ make_leaf_call(tf, CAST_FROM_FN_PTR(address, ShenandoahRuntime::write_ref_field_pre), "shenandoah_wb_pre", + pre_val, tls); } __ end_if(); // (!index) } __ end_if(); // (pre_val != nullptr) } __ end_if(); // (!marking) @@ -268,7 +269,12 @@ void ShenandoahBarrierSetC2::satb_write_barrier_pre(GraphKit* kit, bool ShenandoahBarrierSetC2::is_shenandoah_wb_pre_call(Node* call) { return call->is_CallLeaf() && - call->as_CallLeaf()->entry_point() == CAST_FROM_FN_PTR(address, ShenandoahRuntime::write_ref_field_pre_entry); + call->as_CallLeaf()->entry_point() == CAST_FROM_FN_PTR(address, ShenandoahRuntime::write_ref_field_pre); +} + +bool ShenandoahBarrierSetC2::is_shenandoah_clone_call(Node* call) { + return call->is_CallLeaf() && + call->as_CallLeaf()->entry_point() == CAST_FROM_FN_PTR(address, ShenandoahRuntime::clone_barrier); } bool ShenandoahBarrierSetC2::is_shenandoah_lrb_call(Node* call) { @@ -281,7 +287,8 @@ bool ShenandoahBarrierSetC2::is_shenandoah_lrb_call(Node* call) { (entry_point == CAST_FROM_FN_PTR(address, ShenandoahRuntime::load_reference_barrier_strong_narrow)) || (entry_point == CAST_FROM_FN_PTR(address, ShenandoahRuntime::load_reference_barrier_weak)) || (entry_point == CAST_FROM_FN_PTR(address, ShenandoahRuntime::load_reference_barrier_weak_narrow)) || - (entry_point == CAST_FROM_FN_PTR(address, ShenandoahRuntime::load_reference_barrier_phantom)); + (entry_point == CAST_FROM_FN_PTR(address, ShenandoahRuntime::load_reference_barrier_phantom)) || + (entry_point == CAST_FROM_FN_PTR(address, ShenandoahRuntime::load_reference_barrier_phantom_narrow)); } bool ShenandoahBarrierSetC2::is_shenandoah_marking_if(PhaseValues* phase, Node* n) { @@ -427,7 +434,7 @@ void ShenandoahBarrierSetC2::insert_pre_barrier(GraphKit* kit, Node* base_oop, N #undef __ -const TypeFunc* ShenandoahBarrierSetC2::write_ref_field_pre_entry_Type() { +const TypeFunc* ShenandoahBarrierSetC2::write_ref_field_pre_Type() { const Type **fields = TypeTuple::fields(2); fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // original field value fields[TypeFunc::Parms+1] = TypeRawPtr::NOTNULL; // thread @@ -440,7 +447,7 @@ const TypeFunc* ShenandoahBarrierSetC2::write_ref_field_pre_entry_Type() { return TypeFunc::make(domain, range); } -const TypeFunc* ShenandoahBarrierSetC2::shenandoah_clone_barrier_Type() { +const TypeFunc* ShenandoahBarrierSetC2::clone_barrier_Type() { const Type **fields = TypeTuple::fields(1); fields[TypeFunc::Parms+0] = TypeOopPtr::NOTNULL; // src oop const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1, fields); @@ -452,7 +459,7 @@ const TypeFunc* ShenandoahBarrierSetC2::shenandoah_clone_barrier_Type() { return TypeFunc::make(domain, range); } -const TypeFunc* ShenandoahBarrierSetC2::shenandoah_load_reference_barrier_Type() { +const TypeFunc* ShenandoahBarrierSetC2::load_reference_barrier_Type() { const Type **fields = TypeTuple::fields(2); fields[TypeFunc::Parms+0] = TypeOopPtr::BOTTOM; // original field value fields[TypeFunc::Parms+1] = TypeRawPtr::BOTTOM; // original load address @@ -674,20 +681,11 @@ bool ShenandoahBarrierSetC2::is_gc_pre_barrier_node(Node* node) const { return is_shenandoah_wb_pre_call(node); } -// Support for GC barriers emitted during parsing bool ShenandoahBarrierSetC2::is_gc_barrier_node(Node* node) const { - if (node->Opcode() == Op_ShenandoahLoadReferenceBarrier) return true; - if (node->Opcode() != Op_CallLeaf && node->Opcode() != Op_CallLeafNoFP) { - return false; - } - CallLeafNode *call = node->as_CallLeaf(); - if (call->_name == nullptr) { - return false; - } - - return strcmp(call->_name, "shenandoah_clone_barrier") == 0 || - strcmp(call->_name, "shenandoah_cas_obj") == 0 || - strcmp(call->_name, "shenandoah_wb_pre") == 0; + return (node->Opcode() == Op_ShenandoahLoadReferenceBarrier) || + is_shenandoah_lrb_call(node) || + is_shenandoah_wb_pre_call(node) || + is_shenandoah_clone_call(node); } Node* ShenandoahBarrierSetC2::step_over_gc_barrier(Node* c) const { @@ -801,11 +799,11 @@ void ShenandoahBarrierSetC2::clone_at_expansion(PhaseMacroExpand* phase, ArrayCo // Heap is unstable, call into clone barrier stub Node* call = phase->make_leaf_call(unstable_ctrl, mem, - ShenandoahBarrierSetC2::shenandoah_clone_barrier_Type(), - CAST_FROM_FN_PTR(address, ShenandoahRuntime::shenandoah_clone_barrier), - "shenandoah_clone", - TypeRawPtr::BOTTOM, - src_base); + ShenandoahBarrierSetC2::clone_barrier_Type(), + CAST_FROM_FN_PTR(address, ShenandoahRuntime::clone_barrier), + "shenandoah_clone", + TypeRawPtr::BOTTOM, + src_base); call = phase->transform_later(call); ctrl = phase->transform_later(new ProjNode(call, TypeFunc::Control)); @@ -980,7 +978,7 @@ void ShenandoahBarrierSetC2::verify_gc_barriers(Compile* compile, CompilePhase p Node* ShenandoahBarrierSetC2::ideal_node(PhaseGVN* phase, Node* n, bool can_reshape) const { if (is_shenandoah_wb_pre_call(n)) { - uint cnt = ShenandoahBarrierSetC2::write_ref_field_pre_entry_Type()->domain()->cnt(); + uint cnt = ShenandoahBarrierSetC2::write_ref_field_pre_Type()->domain()->cnt(); if (n->req() > cnt) { Node* addp = n->in(cnt); if (has_only_shenandoah_wb_pre_uses(addp)) { @@ -1066,7 +1064,7 @@ bool ShenandoahBarrierSetC2::final_graph_reshaping(Compile* compile, Node* n, ui assert (n->is_Call(), ""); CallNode *call = n->as_Call(); if (ShenandoahBarrierSetC2::is_shenandoah_wb_pre_call(call)) { - uint cnt = ShenandoahBarrierSetC2::write_ref_field_pre_entry_Type()->domain()->cnt(); + uint cnt = ShenandoahBarrierSetC2::write_ref_field_pre_Type()->domain()->cnt(); if (call->req() > cnt) { assert(call->req() == cnt + 1, "only one extra input"); Node *addp = call->in(cnt); diff --git a/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.hpp b/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.hpp index 4619b217e96..6e241b39ce9 100644 --- a/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.hpp +++ b/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.hpp @@ -85,6 +85,7 @@ public: static ShenandoahBarrierSetC2* bsc2(); static bool is_shenandoah_wb_pre_call(Node* call); + static bool is_shenandoah_clone_call(Node* call); static bool is_shenandoah_lrb_call(Node* call); static bool is_shenandoah_marking_if(PhaseValues* phase, Node* n); static bool is_shenandoah_state_load(Node* n); @@ -92,9 +93,9 @@ public: ShenandoahBarrierSetC2State* state() const; - static const TypeFunc* write_ref_field_pre_entry_Type(); - static const TypeFunc* shenandoah_clone_barrier_Type(); - static const TypeFunc* shenandoah_load_reference_barrier_Type(); + static const TypeFunc* write_ref_field_pre_Type(); + static const TypeFunc* clone_barrier_Type(); + static const TypeFunc* load_reference_barrier_Type(); virtual bool has_load_barrier_nodes() const { return true; } // This is the entry-point for the backend to perform accesses through the Access API. diff --git a/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp b/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp index 0a51f742995..efa0ced603c 100644 --- a/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp +++ b/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp @@ -414,7 +414,7 @@ void ShenandoahBarrierC2Support::verify(RootNode* root) { "cipherBlockChaining_decryptAESCrypt", { { TypeFunc::Parms, ShenandoahLoad }, { TypeFunc::Parms+1, ShenandoahStore }, { TypeFunc::Parms+2, ShenandoahLoad }, { TypeFunc::Parms+3, ShenandoahLoad }, { -1, ShenandoahNone}, { -1, ShenandoahNone} }, - "shenandoah_clone_barrier", + "shenandoah_clone", { { TypeFunc::Parms, ShenandoahLoad }, { -1, ShenandoahNone}, { -1, ShenandoahNone}, { -1, ShenandoahNone}, { -1, ShenandoahNone}, { -1, ShenandoahNone} }, "ghash_processBlocks", @@ -995,7 +995,7 @@ void ShenandoahBarrierC2Support::call_lrb_stub(Node*& ctrl, Node*& val, Node* lo name = "load_reference_barrier_phantom"; } } - Node* call = new CallLeafNode(ShenandoahBarrierSetC2::shenandoah_load_reference_barrier_Type(), calladdr, name, TypeRawPtr::BOTTOM); + Node* call = new CallLeafNode(ShenandoahBarrierSetC2::load_reference_barrier_Type(), calladdr, name, TypeRawPtr::BOTTOM); call->init_req(TypeFunc::Control, ctrl); call->init_req(TypeFunc::I_O, phase->C->top()); diff --git a/src/hotspot/share/gc/shenandoah/shenandoahCollectionSet.cpp b/src/hotspot/share/gc/shenandoah/shenandoahCollectionSet.cpp index 25062c5317d..70401b42461 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahCollectionSet.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahCollectionSet.cpp @@ -1,5 +1,6 @@ /* * Copyright (c) 2016, 2023, Red Hat, Inc. All rights reserved. + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -57,7 +58,7 @@ ShenandoahCollectionSet::ShenandoahCollectionSet(ShenandoahHeap* heap, ReservedS // subsystem for mapping not-yet-written-to pages to a single physical backing page, // but this is not guaranteed, and would confuse NMT and other memory accounting tools. - MemTracker::record_virtual_memory_type(_map_space.base(), mtGC); + MemTracker::record_virtual_memory_tag(_map_space.base(), mtGC); size_t page_size = os::vm_page_size(); diff --git a/src/hotspot/share/gc/shenandoah/shenandoahConcurrentMark.cpp b/src/hotspot/share/gc/shenandoah/shenandoahConcurrentMark.cpp index 6ed75a9d961..75cdb99e177 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahConcurrentMark.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahConcurrentMark.cpp @@ -225,8 +225,7 @@ void ShenandoahConcurrentMark::finish_mark() { assert(Thread::current()->is_VM_thread(), "Must by VM Thread"); finish_mark_work(); assert(task_queues()->is_empty(), "Should be empty"); - TASKQUEUE_STATS_ONLY(task_queues()->print_taskqueue_stats()); - TASKQUEUE_STATS_ONLY(task_queues()->reset_taskqueue_stats()); + TASKQUEUE_STATS_ONLY(task_queues()->print_and_reset_taskqueue_stats("")); ShenandoahHeap* const heap = ShenandoahHeap::heap(); heap->set_concurrent_mark_in_progress(false); diff --git a/src/hotspot/share/gc/shenandoah/shenandoahControlThread.cpp b/src/hotspot/share/gc/shenandoah/shenandoahControlThread.cpp index 95a70de5790..df2d6d092e6 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahControlThread.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahControlThread.cpp @@ -177,10 +177,13 @@ void ShenandoahControlThread::run_service() { // it is a normal completion, or the abort. heap->free_set()->log_status_under_lock(); - // Notify Universe about new heap usage. This has implications for - // global soft refs policy, and we better report it every time heap - // usage goes down. - heap->update_capacity_and_used_at_gc(); + { + // Notify Universe about new heap usage. This has implications for + // global soft refs policy, and we better report it every time heap + // usage goes down. + ShenandoahHeapLocker locker(heap->lock()); + heap->update_capacity_and_used_at_gc(); + } // Signal that we have completed a visit to all live objects. heap->record_whole_heap_examined_timestamp(); @@ -371,6 +374,16 @@ void ShenandoahControlThread::request_gc(GCCause::Cause cause) { } void ShenandoahControlThread::handle_requested_gc(GCCause::Cause cause) { + // For normal requested GCs (System.gc) we want to block the caller. However, + // for whitebox requested GC, we want to initiate the GC and return immediately. + // The whitebox caller thread will arrange for itself to wait until the GC notifies + // it that has reached the requested breakpoint (phase in the GC). + if (cause == GCCause::_wb_breakpoint) { + _requested_gc_cause = cause; + _gc_requested.set(); + return; + } + // Make sure we have at least one complete GC cycle before unblocking // from the explicit GC request. // @@ -390,9 +403,7 @@ void ShenandoahControlThread::handle_requested_gc(GCCause::Cause cause) { _requested_gc_cause = cause; _gc_requested.set(); - if (cause != GCCause::_wb_breakpoint) { - ml.wait(); - } + ml.wait(); current_gc_id = get_gc_id(); } } diff --git a/src/hotspot/share/gc/shenandoah/shenandoahFreeSet.cpp b/src/hotspot/share/gc/shenandoah/shenandoahFreeSet.cpp index 3dfc6a79665..310cd5b8061 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahFreeSet.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahFreeSet.cpp @@ -910,7 +910,6 @@ void ShenandoahFreeSet::try_recycle_trashed(ShenandoahHeapRegion* r) { void ShenandoahFreeSet::recycle_trash() { // lock is not reentrable, check we don't have it shenandoah_assert_not_heaplocked(); - size_t count = 0; for (size_t i = 0; i < _heap->num_regions(); i++) { ShenandoahHeapRegion* r = _heap->get_region(i); @@ -919,16 +918,45 @@ void ShenandoahFreeSet::recycle_trash() { } } - // Relinquish the lock after this much time passed. - static constexpr jlong deadline_ns = 30000; // 30 us + size_t total_batches = 0; + jlong batch_start_time = 0; + jlong recycle_trash_start_time = os::javaTimeNanos(); // This value will be treated as the initial batch_start_time + jlong batch_end_time = recycle_trash_start_time; + // Process as many batches as can be processed within 10 us. + static constexpr jlong deadline_ns = 10000; // 10 us size_t idx = 0; + jlong predicted_next_batch_end_time; + jlong batch_process_time_estimate = 0; while (idx < count) { - os::naked_yield(); // Yield to allow allocators to take the lock - ShenandoahHeapLocker locker(_heap->lock()); - const jlong deadline = os::javaTimeNanos() + deadline_ns; - while (idx < count && os::javaTimeNanos() < deadline) { - try_recycle_trashed(_trash_regions[idx++]); + if (idx > 0) { + os::naked_yield(); // Yield to allow allocators to take the lock, except on the first iteration } + // Avoid another call to javaTimeNanos() if we already know time at which last batch ended + batch_start_time = batch_end_time; + const jlong deadline = batch_start_time + deadline_ns; + + ShenandoahHeapLocker locker(_heap->lock()); + do { + // Measurements on typical 2024 hardware suggest it typically requires between 1400 and 2000 ns to process a batch of + // 32 regions, assuming low contention with other threads. Sometimes this goes higher, when mutator threads + // are contending for CPU cores and/or the heap lock. On this hardware with a 10 us deadline, we expect 3-6 batches + // to be processed between yields most of the time. + // + // Note that deadline is enforced since the end of previous batch. In the case that yield() or acquisition of heap lock + // takes a "long time", we will have less time to process regions, but we will always process at least one batch between + // yields. Yielding more frequently when there is heavy contention for the heap lock or for CPU cores is considered the + // right thing to do. + const size_t REGIONS_PER_BATCH = 32; + size_t max_idx = MIN2(count, idx + REGIONS_PER_BATCH); + while (idx < max_idx) { + try_recycle_trashed(_trash_regions[idx++]); + } + total_batches++; + batch_end_time = os::javaTimeNanos(); + // Estimate includes historic combination of yield times and heap lock acquisition times. + batch_process_time_estimate = (batch_end_time - recycle_trash_start_time) / total_batches; + predicted_next_batch_end_time = batch_end_time + batch_process_time_estimate; + } while ((idx < count) && (predicted_next_batch_end_time < deadline)); } } @@ -1009,7 +1037,9 @@ void ShenandoahFreeSet::find_regions_with_alloc_capacity(size_t &cset_regions) { } } } - _partitions.establish_mutator_intervals(mutator_leftmost, mutator_rightmost, mutator_leftmost_empty, mutator_rightmost_empty, + idx_t rightmost_idx = (mutator_leftmost == max_regions)? -1: (idx_t) mutator_rightmost; + idx_t rightmost_empty_idx = (mutator_leftmost_empty == max_regions)? -1: (idx_t) mutator_rightmost_empty; + _partitions.establish_mutator_intervals(mutator_leftmost, rightmost_idx, mutator_leftmost_empty, rightmost_empty_idx, mutator_regions, mutator_used); } @@ -1134,7 +1164,7 @@ void ShenandoahFreeSet::reserve_regions(size_t to_reserve) { } if (LogTarget(Info, gc, free)::is_enabled()) { - size_t reserve = _partitions.capacity_of(ShenandoahFreeSetPartitionId::Collector); + size_t reserve = _partitions.available_in(ShenandoahFreeSetPartitionId::Collector); if (reserve < to_reserve) { log_debug(gc)("Wanted " PROPERFMT " for young reserve, but only reserved: " PROPERFMT, PROPERFMTARGS(to_reserve), PROPERFMTARGS(reserve)); diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp index a587cc417e3..7ae4a1cf8b3 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp @@ -252,7 +252,7 @@ jint ShenandoahHeap::initialize() { bitmap_size_orig, bitmap_page_size, bitmap.base(), bitmap.size(), bitmap.page_size()); - MemTracker::record_virtual_memory_type(bitmap.base(), mtGC); + MemTracker::record_virtual_memory_tag(bitmap.base(), mtGC); _bitmap_region = MemRegion((HeapWord*) bitmap.base(), bitmap.size() / HeapWordSize); _bitmap_region_special = bitmap.special(); @@ -276,7 +276,7 @@ jint ShenandoahHeap::initialize() { os::commit_memory_or_exit(verify_bitmap.base(), verify_bitmap.size(), bitmap_page_size, false, "Cannot commit verification bitmap memory"); } - MemTracker::record_virtual_memory_type(verify_bitmap.base(), mtGC); + MemTracker::record_virtual_memory_tag(verify_bitmap.base(), mtGC); MemRegion verify_bitmap_region = MemRegion((HeapWord *) verify_bitmap.base(), verify_bitmap.size() / HeapWordSize); _verification_bit_map.initialize(_heap_region, verify_bitmap_region); _verifier = new ShenandoahVerifier(this, &_verification_bit_map); @@ -290,7 +290,7 @@ jint ShenandoahHeap::initialize() { bitmap_size_orig, aux_bitmap_page_size, aux_bitmap.base(), aux_bitmap.size(), aux_bitmap.page_size()); - MemTracker::record_virtual_memory_type(aux_bitmap.base(), mtGC); + MemTracker::record_virtual_memory_tag(aux_bitmap.base(), mtGC); _aux_bitmap_region = MemRegion((HeapWord*) aux_bitmap.base(), aux_bitmap.size() / HeapWordSize); _aux_bitmap_region_special = aux_bitmap.special(); _aux_bit_map.initialize(_heap_region, _aux_bitmap_region); @@ -308,7 +308,7 @@ jint ShenandoahHeap::initialize() { region_storage_size_orig, region_page_size, region_storage.base(), region_storage.size(), region_storage.page_size()); - MemTracker::record_virtual_memory_type(region_storage.base(), mtGC); + MemTracker::record_virtual_memory_tag(region_storage.base(), mtGC); if (!region_storage.special()) { os::commit_memory_or_exit(region_storage.base(), region_storage_size, region_page_size, false, "Cannot commit region memory"); @@ -693,7 +693,7 @@ void ShenandoahHeap::notify_mutator_alloc_words(size_t words, bool waste) { if (ShenandoahPacing) { control_thread()->pacing_notify_alloc(words); if (waste) { - pacer()->claim_for_alloc(words, true); + pacer()->claim_for_alloc(words); } } } diff --git a/src/hotspot/share/gc/shenandoah/shenandoahPacer.cpp b/src/hotspot/share/gc/shenandoah/shenandoahPacer.cpp index 0fc6744c15a..8d10b7cbfcf 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahPacer.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahPacer.cpp @@ -65,6 +65,7 @@ void ShenandoahPacer::setup_for_mark() { size_t non_taxable = free * ShenandoahPacingCycleSlack / 100; size_t taxable = free - non_taxable; + taxable = MAX2(1, taxable); double tax = 1.0 * live / taxable; // base tax for available free space tax *= 1; // mark can succeed with immediate garbage, claim all available space @@ -88,6 +89,7 @@ void ShenandoahPacer::setup_for_evac() { size_t non_taxable = free * ShenandoahPacingCycleSlack / 100; size_t taxable = free - non_taxable; + taxable = MAX2(1, taxable); double tax = 1.0 * used / taxable; // base tax for available free space tax *= 2; // evac is followed by update-refs, claim 1/2 of remaining free @@ -112,6 +114,7 @@ void ShenandoahPacer::setup_for_updaterefs() { size_t non_taxable = free * ShenandoahPacingCycleSlack / 100; size_t taxable = free - non_taxable; + taxable = MAX2(1, taxable); double tax = 1.0 * used / taxable; // base tax for available free space tax *= 1; // update-refs is the last phase, claim the remaining free @@ -189,7 +192,8 @@ void ShenandoahPacer::restart_with(size_t non_taxable_bytes, double tax_rate) { _need_notify_waiters.try_set(); } -bool ShenandoahPacer::claim_for_alloc(size_t words, bool force) { +template +bool ShenandoahPacer::claim_for_alloc(size_t words) { assert(ShenandoahPacing, "Only be here when pacing is enabled"); intptr_t tax = MAX2(1, words * Atomic::load(&_tax_rate)); @@ -198,7 +202,7 @@ bool ShenandoahPacer::claim_for_alloc(size_t words, bool force) { intptr_t new_val = 0; do { cur = Atomic::load(&_budget); - if (cur < tax && !force) { + if (cur < tax && !FORCE) { // Progress depleted, alas. return false; } @@ -207,6 +211,9 @@ bool ShenandoahPacer::claim_for_alloc(size_t words, bool force) { return true; } +template bool ShenandoahPacer::claim_for_alloc(size_t words); +template bool ShenandoahPacer::claim_for_alloc(size_t words); + void ShenandoahPacer::unpace_for_alloc(intptr_t epoch, size_t words) { assert(ShenandoahPacing, "Only be here when pacing is enabled"); @@ -227,18 +234,11 @@ void ShenandoahPacer::pace_for_alloc(size_t words) { assert(ShenandoahPacing, "Only be here when pacing is enabled"); // Fast path: try to allocate right away - bool claimed = claim_for_alloc(words, false); + bool claimed = claim_for_alloc(words); if (claimed) { return; } - // Forcefully claim the budget: it may go negative at this point, and - // GC should replenish for this and subsequent allocations. After this claim, - // we would wait a bit until our claim is matched by additional progress, - // or the time budget depletes. - claimed = claim_for_alloc(words, true); - assert(claimed, "Should always succeed"); - // Threads that are attaching should not block at all: they are not // fully initialized yet. Blocking them would be awkward. // This is probably the path that allocates the thread oop itself. @@ -249,32 +249,25 @@ void ShenandoahPacer::pace_for_alloc(size_t words) { JavaThread* current = JavaThread::current(); if (current->is_attaching_via_jni() || !current->is_active_Java_thread()) { + claim_for_alloc(words); return; } - double start = os::elapsedTime(); - - size_t max_ms = ShenandoahPacingMaxDelay; - size_t total_ms = 0; - - while (true) { + jlong const max_delay = ShenandoahPacingMaxDelay * NANOSECS_PER_MILLISEC; + jlong const start_time = os::elapsed_counter(); + while (!claimed && (os::elapsed_counter() - start_time) < max_delay) { // We could instead assist GC, but this would suffice for now. - size_t cur_ms = (max_ms > total_ms) ? (max_ms - total_ms) : 1; - wait(cur_ms); - - double end = os::elapsedTime(); - total_ms = (size_t)((end - start) * 1000); - - if (total_ms > max_ms || Atomic::load(&_budget) >= 0) { - // Exiting if either: - // a) Spent local time budget to wait for enough GC progress. - // Breaking out and allocating anyway, which may mean we outpace GC, - // and start Degenerated GC cycle. - // b) The budget had been replenished, which means our claim is satisfied. - ShenandoahThreadLocalData::add_paced_time(JavaThread::current(), end - start); - break; - } + wait(1); + claimed = claim_for_alloc(words); } + if (!claimed) { + // Spent local time budget to wait for enough GC progress. + // Force allocating anyway, which may mean we outpace GC, + // and start Degenerated GC cycle. + claimed = claim_for_alloc(words); + assert(claimed, "Should always succeed"); + } + ShenandoahThreadLocalData::add_paced_time(current, (double)(os::elapsed_counter() - start_time) / NANOSECS_PER_SEC); } void ShenandoahPacer::wait(size_t time_ms) { diff --git a/src/hotspot/share/gc/shenandoah/shenandoahPacer.hpp b/src/hotspot/share/gc/shenandoah/shenandoahPacer.hpp index 1c2bf00eb56..44ad2700f87 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahPacer.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahPacer.hpp @@ -107,7 +107,9 @@ public: inline void report_alloc(size_t words); - bool claim_for_alloc(size_t words, bool force); + template + bool claim_for_alloc(size_t words); + void pace_for_alloc(size_t words); void unpace_for_alloc(intptr_t epoch, size_t words); diff --git a/src/hotspot/share/gc/shenandoah/shenandoahRuntime.cpp b/src/hotspot/share/gc/shenandoah/shenandoahRuntime.cpp index 2c727de5857..b217c641824 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahRuntime.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahRuntime.cpp @@ -31,22 +31,19 @@ #include "oops/oop.inline.hpp" #include "utilities/copy.hpp" -void ShenandoahRuntime::arraycopy_barrier_oop_entry(oop* src, oop* dst, size_t length) { - ShenandoahBarrierSet *bs = ShenandoahBarrierSet::barrier_set(); - bs->arraycopy_barrier(src, dst, length); -} +JRT_LEAF(void, ShenandoahRuntime::arraycopy_barrier_oop(oop* src, oop* dst, size_t length)) + ShenandoahBarrierSet::barrier_set()->arraycopy_barrier(src, dst, length); +JRT_END -void ShenandoahRuntime::arraycopy_barrier_narrow_oop_entry(narrowOop* src, narrowOop* dst, size_t length) { - ShenandoahBarrierSet *bs = ShenandoahBarrierSet::barrier_set(); - bs->arraycopy_barrier(src, dst, length); -} +JRT_LEAF(void, ShenandoahRuntime::arraycopy_barrier_narrow_oop(narrowOop* src, narrowOop* dst, size_t length)) + ShenandoahBarrierSet::barrier_set()->arraycopy_barrier(src, dst, length); +JRT_END -// Shenandoah pre write barrier slowpath -JRT_LEAF(void, ShenandoahRuntime::write_ref_field_pre_entry(oopDesc* orig, JavaThread *thread)) +JRT_LEAF(void, ShenandoahRuntime::write_ref_field_pre(oopDesc * orig, JavaThread * thread)) assert(thread == JavaThread::current(), "pre-condition"); assert(orig != nullptr, "should be optimized out"); shenandoah_assert_correct(nullptr, orig); - // store the original value that was in the field reference + // Capture the original value that was in the field reference. assert(ShenandoahThreadLocalData::satb_mark_queue(thread).is_active(), "Shouldn't be here otherwise"); SATBMarkQueue& queue = ShenandoahThreadLocalData::satb_mark_queue(thread); ShenandoahBarrierSet::satb_mark_queue_set().enqueue_known_active(queue, orig); @@ -60,26 +57,24 @@ JRT_LEAF(oopDesc*, ShenandoahRuntime::load_reference_barrier_strong_narrow(oopDe return ShenandoahBarrierSet::barrier_set()->load_reference_barrier_mutator(src, load_addr); JRT_END -// Shenandoah clone barrier: makes sure that references point to to-space -// in cloned objects. -JRT_LEAF(void, ShenandoahRuntime::shenandoah_clone_barrier(oopDesc* src)) +JRT_LEAF(oopDesc*, ShenandoahRuntime::load_reference_barrier_weak(oopDesc* src, oop* load_addr)) + return (oopDesc*) ShenandoahBarrierSet::barrier_set()->load_reference_barrier(ON_WEAK_OOP_REF, oop(src), load_addr); +JRT_END + +JRT_LEAF(oopDesc*, ShenandoahRuntime::load_reference_barrier_weak_narrow(oopDesc* src, narrowOop* load_addr)) + return (oopDesc*) ShenandoahBarrierSet::barrier_set()->load_reference_barrier(ON_WEAK_OOP_REF, oop(src), load_addr); +JRT_END + +JRT_LEAF(oopDesc*, ShenandoahRuntime::load_reference_barrier_phantom(oopDesc* src, oop* load_addr)) + return (oopDesc*) ShenandoahBarrierSet::barrier_set()->load_reference_barrier(ON_PHANTOM_OOP_REF, oop(src), load_addr); +JRT_END + +JRT_LEAF(oopDesc*, ShenandoahRuntime::load_reference_barrier_phantom_narrow(oopDesc* src, narrowOop* load_addr)) + return (oopDesc*) ShenandoahBarrierSet::barrier_set()->load_reference_barrier(ON_PHANTOM_OOP_REF, oop(src), load_addr); +JRT_END + +JRT_LEAF(void, ShenandoahRuntime::clone_barrier(oopDesc* src)) oop s = oop(src); shenandoah_assert_correct(nullptr, s); ShenandoahBarrierSet::barrier_set()->clone_barrier(s); JRT_END - -JRT_LEAF(oopDesc*, ShenandoahRuntime::load_reference_barrier_weak(oopDesc * src, oop* load_addr)) - return (oopDesc*) ShenandoahBarrierSet::barrier_set()->load_reference_barrier(ON_WEAK_OOP_REF, oop(src), load_addr); -JRT_END - -JRT_LEAF(oopDesc*, ShenandoahRuntime::load_reference_barrier_weak_narrow(oopDesc * src, narrowOop* load_addr)) - return (oopDesc*) ShenandoahBarrierSet::barrier_set()->load_reference_barrier(ON_WEAK_OOP_REF, oop(src), load_addr); -JRT_END - -JRT_LEAF(oopDesc*, ShenandoahRuntime::load_reference_barrier_phantom(oopDesc * src, oop* load_addr)) - return (oopDesc*) ShenandoahBarrierSet::barrier_set()->load_reference_barrier(ON_PHANTOM_OOP_REF, oop(src), load_addr); -JRT_END - -JRT_LEAF(oopDesc*, ShenandoahRuntime::load_reference_barrier_phantom_narrow(oopDesc * src, narrowOop* load_addr)) - return (oopDesc*) ShenandoahBarrierSet::barrier_set()->load_reference_barrier(ON_PHANTOM_OOP_REF, oop(src), load_addr); -JRT_END diff --git a/src/hotspot/share/gc/shenandoah/shenandoahRuntime.hpp b/src/hotspot/share/gc/shenandoah/shenandoahRuntime.hpp index e187e4360b1..4ad8fc997ea 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahRuntime.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahRuntime.hpp @@ -33,10 +33,10 @@ class oopDesc; class ShenandoahRuntime : public AllStatic { public: - static void arraycopy_barrier_oop_entry(oop* src, oop* dst, size_t length); - static void arraycopy_barrier_narrow_oop_entry(narrowOop* src, narrowOop* dst, size_t length); + static void arraycopy_barrier_oop(oop* src, oop* dst, size_t length); + static void arraycopy_barrier_narrow_oop(narrowOop* src, narrowOop* dst, size_t length); - static void write_ref_field_pre_entry(oopDesc* orig, JavaThread* thread); + static void write_ref_field_pre(oopDesc* orig, JavaThread* thread); static oopDesc* load_reference_barrier_strong(oopDesc* src, oop* load_addr); static oopDesc* load_reference_barrier_strong_narrow(oopDesc* src, narrowOop* load_addr); @@ -47,7 +47,7 @@ public: static oopDesc* load_reference_barrier_phantom(oopDesc* src, oop* load_addr); static oopDesc* load_reference_barrier_phantom_narrow(oopDesc* src, narrowOop* load_addr); - static void shenandoah_clone_barrier(oopDesc* src); + static void clone_barrier(oopDesc* src); }; #endif // SHARE_GC_SHENANDOAH_SHENANDOAHRUNTIME_HPP diff --git a/src/hotspot/share/gc/shenandoah/shenandoahSTWMark.cpp b/src/hotspot/share/gc/shenandoah/shenandoahSTWMark.cpp index 05cd8ef66b9..9a30b1fed87 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahSTWMark.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahSTWMark.cpp @@ -133,8 +133,7 @@ void ShenandoahSTWMark::mark() { ShenandoahCodeRoots::disarm_nmethods(); assert(task_queues()->is_empty(), "Should be empty"); - TASKQUEUE_STATS_ONLY(task_queues()->print_taskqueue_stats()); - TASKQUEUE_STATS_ONLY(task_queues()->reset_taskqueue_stats()); + TASKQUEUE_STATS_ONLY(task_queues()->print_and_reset_taskqueue_stats("")); } void ShenandoahSTWMark::mark_roots(uint worker_id) { diff --git a/src/hotspot/share/gc/shenandoah/shenandoahSimpleBitMap.cpp b/src/hotspot/share/gc/shenandoah/shenandoahSimpleBitMap.cpp index c3e8108752f..127e6324fb0 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahSimpleBitMap.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahSimpleBitMap.cpp @@ -23,7 +23,7 @@ */ #include "precompiled.hpp" -#include "gc/shenandoah/shenandoahSimpleBitMap.hpp" +#include "gc/shenandoah/shenandoahSimpleBitMap.inline.hpp" ShenandoahSimpleBitMap::ShenandoahSimpleBitMap(size_t num_bits) : _num_bits(num_bits), @@ -43,8 +43,8 @@ size_t ShenandoahSimpleBitMap::count_leading_ones(idx_t start_idx) const { assert((start_idx >= 0) && (start_idx < _num_bits), "precondition"); size_t array_idx = start_idx >> LogBitsPerWord; uintx element_bits = _bitmap[array_idx]; - uintx bit_number = start_idx & right_n_bits(LogBitsPerWord); - uintx mask = ~right_n_bits(bit_number); + uintx bit_number = start_idx & (BitsPerWord - 1); + uintx mask = ~tail_mask(bit_number); size_t counted_ones = 0; while ((element_bits & mask) == mask) { // All bits numbered >= bit_number are set @@ -54,7 +54,7 @@ size_t ShenandoahSimpleBitMap::count_leading_ones(idx_t start_idx) const { // Strength reduction: array_idx = (start_idx >> LogBitsPerWord) array_idx++; element_bits = _bitmap[array_idx]; - // Constant folding: bit_number = start_idx & right_n_bits(LogBitsPerWord); + // Constant folding: bit_number = start_idx & (BitsPerWord - 1); bit_number = 0; // Constant folding: mask = ~right_n_bits(bit_number); mask = ~0; @@ -70,9 +70,9 @@ size_t ShenandoahSimpleBitMap::count_trailing_ones(idx_t last_idx) const { assert((last_idx >= 0) && (last_idx < _num_bits), "precondition"); size_t array_idx = last_idx >> LogBitsPerWord; uintx element_bits = _bitmap[array_idx]; - uintx bit_number = last_idx & right_n_bits(LogBitsPerWord); + uintx bit_number = last_idx & (BitsPerWord - 1); // All ones from bit 0 to the_bit - uintx mask = right_n_bits(bit_number + 1); + uintx mask = tail_mask(bit_number + 1); size_t counted_ones = 0; while ((element_bits & mask) == mask) { // All bits numbered <= bit_number are set @@ -81,7 +81,7 @@ size_t ShenandoahSimpleBitMap::count_trailing_ones(idx_t last_idx) const { // Dead code: do not need to compute: last_idx -= found_ones; array_idx--; element_bits = _bitmap[array_idx]; - // Constant folding: bit_number = last_idx & right_n_bits(LogBitsPerWord); + // Constant folding: bit_number = last_idx & (BitsPerWord - 1); bit_number = BitsPerWord - 1; // Constant folding: mask = right_n_bits(bit_number + 1); mask = ~0; @@ -99,7 +99,7 @@ bool ShenandoahSimpleBitMap::is_forward_consecutive_ones(idx_t start_idx, idx_t start_idx, count); assert(start_idx + count <= (idx_t) _num_bits, "precondition"); size_t array_idx = start_idx >> LogBitsPerWord; - uintx bit_number = start_idx & right_n_bits(LogBitsPerWord); + uintx bit_number = start_idx & (BitsPerWord - 1); uintx element_bits = _bitmap[array_idx]; uintx bits_to_examine = BitsPerWord - bit_number; element_bits >>= bit_number; @@ -128,7 +128,7 @@ bool ShenandoahSimpleBitMap::is_backward_consecutive_ones(idx_t last_idx, idx_t assert((last_idx >= 0) && (last_idx < _num_bits), "precondition"); assert(last_idx - count >= -1, "precondition"); size_t array_idx = last_idx >> LogBitsPerWord; - uintx bit_number = last_idx & right_n_bits(LogBitsPerWord); + uintx bit_number = last_idx & (BitsPerWord - 1); uintx element_bits = _bitmap[array_idx]; uintx bits_to_examine = bit_number + 1; element_bits <<= (BitsPerWord - bits_to_examine); @@ -161,10 +161,10 @@ idx_t ShenandoahSimpleBitMap::find_first_consecutive_set_bits(idx_t beg, idx_t e return end; } uintx array_idx = beg >> LogBitsPerWord; - uintx bit_number = beg & right_n_bits(LogBitsPerWord); + uintx bit_number = beg & (BitsPerWord - 1); uintx element_bits = _bitmap[array_idx]; if (bit_number > 0) { - uintx mask_out = right_n_bits(bit_number); + uintx mask_out = tail_mask(bit_number); element_bits &= ~mask_out; } @@ -222,9 +222,9 @@ idx_t ShenandoahSimpleBitMap::find_first_consecutive_set_bits(idx_t beg, idx_t e } array_idx = beg >> LogBitsPerWord; element_bits = _bitmap[array_idx]; - bit_number = beg & right_n_bits(LogBitsPerWord); + bit_number = beg & (BitsPerWord - 1); if (bit_number > 0) { - size_t mask_out = right_n_bits(bit_number); + size_t mask_out = tail_mask(bit_number); element_bits &= ~mask_out; } } @@ -242,10 +242,10 @@ idx_t ShenandoahSimpleBitMap::find_last_consecutive_set_bits(const idx_t beg, id } size_t array_idx = end >> LogBitsPerWord; - uintx bit_number = end & right_n_bits(LogBitsPerWord); + uintx bit_number = end & (BitsPerWord - 1); uintx element_bits = _bitmap[array_idx]; if (bit_number < BitsPerWord - 1) { - uintx mask_in = right_n_bits(bit_number + 1); + uintx mask_in = tail_mask(bit_number + 1); element_bits &= mask_in; } @@ -280,10 +280,10 @@ idx_t ShenandoahSimpleBitMap::find_last_consecutive_set_bits(const idx_t beg, id return beg; } array_idx = end >> LogBitsPerWord; - bit_number = end & right_n_bits(LogBitsPerWord); + bit_number = end & (BitsPerWord - 1); element_bits = _bitmap[array_idx]; if (bit_number < BitsPerWord - 1){ - size_t mask_in = right_n_bits(bit_number + 1); + size_t mask_in = tail_mask(bit_number + 1); element_bits &= mask_in; } } diff --git a/src/hotspot/share/gc/shenandoah/shenandoahSimpleBitMap.hpp b/src/hotspot/share/gc/shenandoah/shenandoahSimpleBitMap.hpp index c22e9527002..55d21b06e4b 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahSimpleBitMap.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahSimpleBitMap.hpp @@ -50,7 +50,7 @@ typedef ssize_t idx_t; // ShenandoahSimpleBitMap resembles CHeapBitMap but adds missing support for find_first_consecutive_set_bits() and // find_last_consecutive_set_bits. An alternative refactoring of code would subclass CHeapBitMap, but this might // break abstraction rules, because efficient implementation requires assumptions about superclass internals that -// might be violatee through future software maintenance. +// might be violated through future software maintenance. class ShenandoahSimpleBitMap { const idx_t _num_bits; const size_t _num_words; @@ -80,11 +80,13 @@ private: bool is_forward_consecutive_ones(idx_t start_idx, idx_t count) const; bool is_backward_consecutive_ones(idx_t last_idx, idx_t count) const; + static inline uintx tail_mask(uintx bit_number); + public: inline idx_t aligned_index(idx_t idx) const { assert((idx >= 0) && (idx < _num_bits), "precondition"); - idx_t array_idx = idx & ~right_n_bits(LogBitsPerWord); + idx_t array_idx = idx & ~(BitsPerWord - 1); return array_idx; } @@ -107,7 +109,7 @@ public: inline void set_bit(idx_t idx) { assert((idx >= 0) && (idx < _num_bits), "precondition"); size_t array_idx = idx >> LogBitsPerWord; - uintx bit_number = idx & right_n_bits(LogBitsPerWord); + uintx bit_number = idx & (BitsPerWord - 1); uintx the_bit = nth_bit(bit_number); _bitmap[array_idx] |= the_bit; } @@ -116,7 +118,7 @@ public: assert((idx >= 0) && (idx < _num_bits), "precondition"); assert(idx >= 0, "precondition"); size_t array_idx = idx >> LogBitsPerWord; - uintx bit_number = idx & right_n_bits(LogBitsPerWord); + uintx bit_number = idx & (BitsPerWord - 1); uintx the_bit = nth_bit(bit_number); _bitmap[array_idx] &= ~the_bit; } @@ -125,9 +127,9 @@ public: assert((idx >= 0) && (idx < _num_bits), "precondition"); assert(idx >= 0, "precondition"); size_t array_idx = idx >> LogBitsPerWord; - uintx bit_number = idx & right_n_bits(LogBitsPerWord); + uintx bit_number = idx & (BitsPerWord - 1); uintx the_bit = nth_bit(bit_number); - return (_bitmap[array_idx] & the_bit)? true: false; + return (_bitmap[array_idx] & the_bit) != 0; } // Return the index of the first set bit in the range [beg, size()), or size() if none found. diff --git a/src/hotspot/share/gc/shenandoah/shenandoahSimpleBitMap.inline.hpp b/src/hotspot/share/gc/shenandoah/shenandoahSimpleBitMap.inline.hpp index 3e602ed11e0..4582ab9a781 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahSimpleBitMap.inline.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahSimpleBitMap.inline.hpp @@ -27,15 +27,22 @@ #include "gc/shenandoah/shenandoahSimpleBitMap.hpp" +inline uintx ShenandoahSimpleBitMap::tail_mask(uintx bit_number) { + if (bit_number >= BitsPerWord) { + return -1; + } + return (uintx(1) << bit_number) - 1; +} + inline idx_t ShenandoahSimpleBitMap::find_first_set_bit(idx_t beg, idx_t end) const { assert((beg >= 0) && (beg < _num_bits), "precondition"); assert((end > beg) && (end <= _num_bits), "precondition"); do { size_t array_idx = beg >> LogBitsPerWord; - uintx bit_number = beg & right_n_bits(LogBitsPerWord); + uintx bit_number = beg & (BitsPerWord - 1); uintx element_bits = _bitmap[array_idx]; if (bit_number > 0) { - uintx mask_out = right_n_bits(bit_number); + uintx mask_out = tail_mask(bit_number); element_bits &= ~mask_out; } if (element_bits) { @@ -62,10 +69,10 @@ inline idx_t ShenandoahSimpleBitMap::find_last_set_bit(idx_t beg, idx_t end) con assert((beg >= -1) && (beg < end), "precondition"); do { idx_t array_idx = end >> LogBitsPerWord; - uintx bit_number = end & right_n_bits(LogBitsPerWord); + uint8_t bit_number = end & (BitsPerWord - 1); uintx element_bits = _bitmap[array_idx]; if (bit_number < BitsPerWord - 1){ - uintx mask_in = right_n_bits(bit_number + 1); + uintx mask_in = tail_mask(bit_number + 1); element_bits &= mask_in; } if (element_bits) { diff --git a/src/hotspot/share/gc/shenandoah/shenandoahTaskqueue.cpp b/src/hotspot/share/gc/shenandoah/shenandoahTaskqueue.cpp index 3cddc0c6c0a..eb185c197bd 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahTaskqueue.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahTaskqueue.cpp @@ -51,45 +51,6 @@ bool ShenandoahObjToScanQueueSet::is_empty() { return true; } -#if TASKQUEUE_STATS -void ShenandoahObjToScanQueueSet::print_taskqueue_stats_hdr(outputStream* const st) { - st->print_raw_cr("GC Task Stats"); - st->print_raw("thr "); TaskQueueStats::print_header(1, st); st->cr(); - st->print_raw("--- "); TaskQueueStats::print_header(2, st); st->cr(); -} - -void ShenandoahObjToScanQueueSet::print_taskqueue_stats() const { - if (!log_develop_is_enabled(Trace, gc, task, stats)) { - return; - } - Log(gc, task, stats) log; - ResourceMark rm; - LogStream ls(log.trace()); - outputStream* st = &ls; - print_taskqueue_stats_hdr(st); - - ShenandoahObjToScanQueueSet* queues = const_cast(this); - TaskQueueStats totals; - const uint n = size(); - for (uint i = 0; i < n; ++i) { - st->print(UINT32_FORMAT_W(3), i); - queues->queue(i)->stats.print(st); - st->cr(); - totals += queues->queue(i)->stats; - } - st->print("tot "); totals.print(st); st->cr(); - DEBUG_ONLY(totals.verify()); - -} - -void ShenandoahObjToScanQueueSet::reset_taskqueue_stats() { - const uint n = size(); - for (uint i = 0; i < n; ++i) { - queue(i)->stats.reset(); - } -} -#endif // TASKQUEUE_STATS - bool ShenandoahTerminatorTerminator::should_exit_termination() { return _heap->cancelled_gc(); } diff --git a/src/hotspot/share/gc/shenandoah/shenandoahTaskqueue.hpp b/src/hotspot/share/gc/shenandoah/shenandoahTaskqueue.hpp index 50f18a8c73f..10887ad8c19 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahTaskqueue.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahTaskqueue.hpp @@ -1,5 +1,6 @@ /* * Copyright (c) 2016, 2024, Red Hat, Inc. All rights reserved. + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,7 +29,7 @@ #include "gc/shared/taskTerminator.hpp" #include "gc/shared/taskqueue.hpp" #include "gc/shenandoah/shenandoahPadding.hpp" -#include "nmt/memflags.hpp" +#include "nmt/memTag.hpp" #include "runtime/atomic.hpp" #include "runtime/javaThread.hpp" #include "runtime/mutex.hpp" @@ -36,11 +37,11 @@ class ShenandoahHeap; -template -class BufferedOverflowTaskQueue: public OverflowTaskQueue +template +class BufferedOverflowTaskQueue: public OverflowTaskQueue { public: - typedef OverflowTaskQueue taskqueue_t; + typedef OverflowTaskQueue taskqueue_t; BufferedOverflowTaskQueue() : _buf_empty(true) {}; @@ -301,8 +302,8 @@ public: typedef BufferedOverflowTaskQueue ShenandoahBufferedOverflowTaskQueue; typedef Padded ShenandoahObjToScanQueue; -template -class ParallelClaimableQueueSet: public GenericTaskQueueSet { +template +class ParallelClaimableQueueSet: public GenericTaskQueueSet { private: shenandoah_padding(0); volatile jint _claimed_index; @@ -311,10 +312,10 @@ private: debug_only(uint _reserved; ) public: - using GenericTaskQueueSet::size; + using GenericTaskQueueSet::size; public: - ParallelClaimableQueueSet(int n) : GenericTaskQueueSet(n), _claimed_index(0) { + ParallelClaimableQueueSet(int n) : GenericTaskQueueSet(n), _claimed_index(0) { debug_only(_reserved = 0; ) } @@ -331,9 +332,9 @@ public: debug_only(uint get_reserved() const { return (uint)_reserved; }) }; -template -T* ParallelClaimableQueueSet::claim_next() { - jint size = (jint)GenericTaskQueueSet::size(); +template +T* ParallelClaimableQueueSet::claim_next() { + jint size = (jint)GenericTaskQueueSet::size(); if (_claimed_index >= size) { return nullptr; @@ -342,7 +343,7 @@ T* ParallelClaimableQueueSet::claim_next() { jint index = Atomic::add(&_claimed_index, 1, memory_order_relaxed); if (index <= size) { - return GenericTaskQueueSet::queue((uint)index - 1); + return GenericTaskQueueSet::queue((uint)index - 1); } else { return nullptr; } @@ -354,12 +355,6 @@ public: bool is_empty(); void clear(); - -#if TASKQUEUE_STATS - static void print_taskqueue_stats_hdr(outputStream* const st); - void print_taskqueue_stats() const; - void reset_taskqueue_stats(); -#endif // TASKQUEUE_STATS }; class ShenandoahTerminatorTerminator : public TerminatorTerminator { diff --git a/src/hotspot/share/gc/shenandoah/shenandoahTaskqueue.inline.hpp b/src/hotspot/share/gc/shenandoah/shenandoahTaskqueue.inline.hpp index fa770021742..9fa4fabc1c7 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahTaskqueue.inline.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahTaskqueue.inline.hpp @@ -1,5 +1,6 @@ /* * Copyright (c) 2016, 2019, Red Hat, Inc. All rights reserved. + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,8 +31,8 @@ #include "gc/shared/taskqueue.inline.hpp" #include "utilities/stack.inline.hpp" -template -bool BufferedOverflowTaskQueue::pop(E &t) { +template +bool BufferedOverflowTaskQueue::pop(E &t) { if (!_buf_empty) { t = _elem; _buf_empty = true; @@ -45,8 +46,8 @@ bool BufferedOverflowTaskQueue::pop(E &t) { return taskqueue_t::pop_overflow(t); } -template -inline bool BufferedOverflowTaskQueue::push(E t) { +template +inline bool BufferedOverflowTaskQueue::push(E t) { if (_buf_empty) { _elem = t; _buf_empty = false; @@ -58,8 +59,8 @@ inline bool BufferedOverflowTaskQueue::push(E t) { return true; } -template -void BufferedOverflowTaskQueue::clear() { +template +void BufferedOverflowTaskQueue::clear() { _buf_empty = true; taskqueue_t::set_empty(); taskqueue_t::overflow_stack()->clear(); diff --git a/src/hotspot/share/gc/x/c1/xBarrierSetC1.cpp b/src/hotspot/share/gc/x/c1/xBarrierSetC1.cpp index caf7eb2e514..6f64392cefc 100644 --- a/src/hotspot/share/gc/x/c1/xBarrierSetC1.cpp +++ b/src/hotspot/share/gc/x/c1/xBarrierSetC1.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -225,7 +225,7 @@ public: static address generate_c1_runtime_stub(BufferBlob* blob, DecoratorSet decorators, const char* name) { XLoadBarrierRuntimeStubCodeGenClosure cl(decorators); - CodeBlob* const code_blob = Runtime1::generate_blob(blob, -1 /* stub_id */, name, false /* expect_oop_map*/, &cl); + CodeBlob* const code_blob = Runtime1::generate_blob(blob, C1StubId::NO_STUBID /* stub_id */, name, false /* expect_oop_map*/, &cl); return code_blob->code_begin(); } diff --git a/src/hotspot/share/gc/x/xVirtualMemory.cpp b/src/hotspot/share/gc/x/xVirtualMemory.cpp index 1d66cdd069e..63cb789d8de 100644 --- a/src/hotspot/share/gc/x/xVirtualMemory.cpp +++ b/src/hotspot/share/gc/x/xVirtualMemory.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -182,7 +182,7 @@ bool XVirtualMemoryManager::reserve(size_t max_capacity) { void XVirtualMemoryManager::nmt_reserve(uintptr_t start, size_t size) { MemTracker::record_virtual_memory_reserve((void*)start, size, CALLER_PC); - MemTracker::record_virtual_memory_type((void*)start, mtJavaHeap); + MemTracker::record_virtual_memory_tag((void*)start, mtJavaHeap); } bool XVirtualMemoryManager::is_initialized() const { diff --git a/src/hotspot/share/gc/z/c1/zBarrierSetC1.cpp b/src/hotspot/share/gc/z/c1/zBarrierSetC1.cpp index 68e215e9ebc..9c16714b26e 100644 --- a/src/hotspot/share/gc/z/c1/zBarrierSetC1.cpp +++ b/src/hotspot/share/gc/z/c1/zBarrierSetC1.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -507,7 +507,7 @@ public: static address generate_c1_load_runtime_stub(BufferBlob* blob, DecoratorSet decorators, const char* name) { ZLoadBarrierRuntimeStubCodeGenClosure cl(decorators); - CodeBlob* const code_blob = Runtime1::generate_blob(blob, -1 /* stub_id */, name, false /* expect_oop_map*/, &cl); + CodeBlob* const code_blob = Runtime1::generate_blob(blob, C1StubId::NO_STUBID /* stub_id */, name, false /* expect_oop_map*/, &cl); return code_blob->code_begin(); } @@ -527,7 +527,7 @@ public: static address generate_c1_store_runtime_stub(BufferBlob* blob, bool self_healing, const char* name) { ZStoreBarrierRuntimeStubCodeGenClosure cl(self_healing); - CodeBlob* const code_blob = Runtime1::generate_blob(blob, -1 /* stub_id */, name, false /* expect_oop_map*/, &cl); + CodeBlob* const code_blob = Runtime1::generate_blob(blob, C1StubId::NO_STUBID /* stub_id */, name, false /* expect_oop_map*/, &cl); return code_blob->code_begin(); } diff --git a/src/hotspot/share/gc/z/c2/zBarrierSetC2.cpp b/src/hotspot/share/gc/z/c2/zBarrierSetC2.cpp index f72e84eaf59..a46681d131c 100644 --- a/src/hotspot/share/gc/z/c2/zBarrierSetC2.cpp +++ b/src/hotspot/share/gc/z/c2/zBarrierSetC2.cpp @@ -46,7 +46,7 @@ #include "utilities/growableArray.hpp" #include "utilities/macros.hpp" -template +template class ZArenaHashtable : public ResourceObj { class ZArenaHashtableEntry : public ResourceObj { public: @@ -55,10 +55,10 @@ class ZArenaHashtable : public ResourceObj { V _value; }; - static const size_t _table_mask = _table_size - 1; + static const size_t TableMask = TableSize - 1; Arena* _arena; - ZArenaHashtableEntry* _table[_table_size]; + ZArenaHashtableEntry* _table[TableSize]; public: class Iterator { @@ -84,7 +84,7 @@ public: if (_current_entry != nullptr) { _current_entry = _current_entry->_next; } - while (_current_entry == nullptr && ++_current_index < _table_size) { + while (_current_entry == nullptr && ++_current_index < TableSize) { _current_entry = _table->_table[_current_index]; } } @@ -100,12 +100,12 @@ public: ZArenaHashtableEntry* entry = new (_arena) ZArenaHashtableEntry(); entry->_key = key; entry->_value = value; - entry->_next = _table[key & _table_mask]; - _table[key & _table_mask] = entry; + entry->_next = _table[key & TableMask]; + _table[key & TableMask] = entry; } V* get(K key) const { - for (ZArenaHashtableEntry* e = _table[key & _table_mask]; e != nullptr; e = e->_next) { + for (ZArenaHashtableEntry* e = _table[key & TableMask]; e != nullptr; e = e->_next) { if (e->_key == key) { return &(e->_value); } diff --git a/src/hotspot/share/gc/z/zBarrierSet.hpp b/src/hotspot/share/gc/z/zBarrierSet.hpp index bf233df683a..9c20211e228 100644 --- a/src/hotspot/share/gc/z/zBarrierSet.hpp +++ b/src/hotspot/share/gc/z/zBarrierSet.hpp @@ -155,7 +155,7 @@ public: }; template<> struct BarrierSet::GetName { - static const BarrierSet::Name value = BarrierSet::ZBarrierSet; + static const BarrierSet::Name Value = BarrierSet::ZBarrierSet; }; template<> struct BarrierSet::GetType { diff --git a/src/hotspot/share/gc/z/zCollectedHeap.cpp b/src/hotspot/share/gc/z/zCollectedHeap.cpp index ccfa7af6b7d..8afefd5a7cc 100644 --- a/src/hotspot/share/gc/z/zCollectedHeap.cpp +++ b/src/hotspot/share/gc/z/zCollectedHeap.cpp @@ -49,6 +49,7 @@ #include "memory/universe.hpp" #include "oops/stackChunkOop.hpp" #include "runtime/continuationJavaClasses.hpp" +#include "runtime/java.hpp" #include "runtime/jniHandles.inline.hpp" #include "runtime/stackWatermarkSet.hpp" #include "services/memoryUsage.hpp" @@ -60,7 +61,7 @@ ZCollectedHeap* ZCollectedHeap::heap() { ZCollectedHeap::ZCollectedHeap() : _barrier_set(), - _initialize(&_barrier_set), + _initializer(&_barrier_set), _heap(), _driver_minor(new ZDriverMinor()), _driver_major(new ZDriverMajor()), @@ -78,11 +79,14 @@ const char* ZCollectedHeap::name() const { jint ZCollectedHeap::initialize() { if (!_heap.is_initialized()) { + vm_shutdown_during_initialization(ZInitialize::error_message()); return JNI_ENOMEM; } Universe::set_verify_data(~(ZAddressHeapBase - 1) | 0x7, ZAddressHeapBase); + ZInitialize::finish(); + return JNI_OK; } diff --git a/src/hotspot/share/gc/z/zCollectedHeap.hpp b/src/hotspot/share/gc/z/zCollectedHeap.hpp index 528bacd8df8..434204e16b8 100644 --- a/src/hotspot/share/gc/z/zCollectedHeap.hpp +++ b/src/hotspot/share/gc/z/zCollectedHeap.hpp @@ -43,7 +43,7 @@ class ZCollectedHeap : public CollectedHeap { private: ZBarrierSet _barrier_set; - ZInitialize _initialize; + ZInitializer _initializer; ZHeap _heap; ZDriverMinor* _driver_minor; ZDriverMajor* _driver_major; diff --git a/src/hotspot/share/gc/z/zDirector.cpp b/src/hotspot/share/gc/z/zDirector.cpp index 3ba8698bd8e..481525c425a 100644 --- a/src/hotspot/share/gc/z/zDirector.cpp +++ b/src/hotspot/share/gc/z/zDirector.cpp @@ -488,7 +488,8 @@ static bool rule_major_allocation_rate(const ZDirectorStats& stats) { // Calculate the GC cost for each reclaimed byte const double current_young_gc_time_per_bytes_freed = double(young_gc_time) / double(reclaimed_per_young_gc); - const double current_old_gc_time_per_bytes_freed = double(old_gc_time) / double(reclaimed_per_old_gc); + const double current_old_gc_time_per_bytes_freed = reclaimed_per_old_gc == 0 ? std::numeric_limits::infinity() + : (double(old_gc_time) / double(reclaimed_per_old_gc)); // Calculate extra time per young collection inflicted by *not* doing an // old collection that frees up memory in the old generation. @@ -838,7 +839,7 @@ void ZDirector::evaluate_rules() { } bool ZDirector::wait_for_tick() { - const uint64_t interval_ms = MILLIUNITS / decision_hz; + const uint64_t interval_ms = MILLIUNITS / DecisionHz; ZLocker locker(&_monitor); diff --git a/src/hotspot/share/gc/z/zDirector.hpp b/src/hotspot/share/gc/z/zDirector.hpp index 73c556a2fbd..929ec6c2c56 100644 --- a/src/hotspot/share/gc/z/zDirector.hpp +++ b/src/hotspot/share/gc/z/zDirector.hpp @@ -29,7 +29,7 @@ class ZDirector : public ZThread { private: - static const uint64_t decision_hz = 100; + static const uint64_t DecisionHz = 100; static ZDirector* _director; ZConditionLock _monitor; diff --git a/src/hotspot/share/gc/z/zForwarding.cpp b/src/hotspot/share/gc/z/zForwarding.cpp index d8a3913806c..4df6e9a2d81 100644 --- a/src/hotspot/share/gc/z/zForwarding.cpp +++ b/src/hotspot/share/gc/z/zForwarding.cpp @@ -73,7 +73,7 @@ void ZForwarding::in_place_relocation_finish() { if (_from_age == ZPageAge::old || _to_age != ZPageAge::old) { // Only do this for non-promoted pages, that still need to reset live map. // Done with iterating over the "from-page" view, so can now drop the _livemap. - _page->finalize_reset_for_in_place_relocation(); + _page->reset_livemap(); } // Disable relaxed ZHeap::is_in checks diff --git a/src/hotspot/share/gc/z/zHeap.cpp b/src/hotspot/share/gc/z/zHeap.cpp index 21ff7037962..1e917bb5ee3 100644 --- a/src/hotspot/share/gc/z/zHeap.cpp +++ b/src/hotspot/share/gc/z/zHeap.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,6 +34,7 @@ #include "gc/z/zHeap.inline.hpp" #include "gc/z/zHeapIterator.hpp" #include "gc/z/zHeuristics.hpp" +#include "gc/z/zInitialize.hpp" #include "gc/z/zPage.inline.hpp" #include "gc/z/zPageTable.inline.hpp" #include "gc/z/zResurrection.hpp" @@ -74,7 +75,7 @@ ZHeap::ZHeap() // Prime cache if (!_page_allocator.prime_cache(_old.workers(), InitialHeapSize)) { - log_error_p(gc)("Failed to allocate initial Java heap (" SIZE_FORMAT "M)", InitialHeapSize / M); + ZInitialize::error("Failed to allocate initial Java heap (" SIZE_FORMAT "M)", InitialHeapSize / M); return; } @@ -240,20 +241,19 @@ void ZHeap::undo_alloc_page(ZPage* page) { log_trace(gc)("Undo page allocation, thread: " PTR_FORMAT " (%s), page: " PTR_FORMAT ", size: " SIZE_FORMAT, p2i(Thread::current()), ZUtils::thread_name(), p2i(page), page->size()); - free_page(page); + free_page(page, false /* allow_defragment */); } -void ZHeap::free_page(ZPage* page) { +void ZHeap::free_page(ZPage* page, bool allow_defragment) { // Remove page table entry _page_table.remove(page); if (page->is_old()) { - page->verify_remset_cleared_current(); - page->verify_remset_cleared_previous(); + page->remset_delete(); } // Free page - _page_allocator.free_page(page); + _page_allocator.free_page(page, allow_defragment); } size_t ZHeap::free_empty_pages(const ZArray* pages) { @@ -261,12 +261,10 @@ size_t ZHeap::free_empty_pages(const ZArray* pages) { // Remove page table entries ZArrayIterator iter(pages); for (ZPage* page; iter.next(&page);) { - if (page->is_old()) { - // The remset of pages should be clean when installed into the page - // cache. - page->remset_clear(); - } _page_table.remove(page); + if (page->is_old()) { + page->remset_delete(); + } freed += page->size(); } diff --git a/src/hotspot/share/gc/z/zHeap.hpp b/src/hotspot/share/gc/z/zHeap.hpp index 18fa0d6349b..7b75c63cf8c 100644 --- a/src/hotspot/share/gc/z/zHeap.hpp +++ b/src/hotspot/share/gc/z/zHeap.hpp @@ -104,7 +104,7 @@ public: // Page allocation ZPage* alloc_page(ZPageType type, size_t size, ZAllocationFlags flags, ZPageAge age); void undo_alloc_page(ZPage* page); - void free_page(ZPage* page); + void free_page(ZPage* page, bool allow_defragment); size_t free_empty_pages(const ZArray* pages); // Object allocation diff --git a/src/hotspot/share/gc/z/zInitialize.cpp b/src/hotspot/share/gc/z/zInitialize.cpp index 52229bf2830..e37fc550bfe 100644 --- a/src/hotspot/share/gc/z/zInitialize.cpp +++ b/src/hotspot/share/gc/z/zInitialize.cpp @@ -22,6 +22,7 @@ */ #include "precompiled.hpp" +#include "gc/shared/gcLogPrecious.hpp" #include "gc/z/zAddress.hpp" #include "gc/z/zBarrierSet.hpp" #include "gc/z/zCPU.hpp" @@ -38,9 +39,19 @@ #include "gc/z/zThreadLocalAllocBuffer.hpp" #include "gc/z/zTracer.hpp" #include "logging/log.hpp" +#include "nmt/memTag.hpp" #include "runtime/vm_version.hpp" +#include "utilities/formatBuffer.hpp" -ZInitialize::ZInitialize(ZBarrierSet* barrier_set) { +char ZInitialize::_error_message[ErrorMessageLength] = {}; +bool ZInitialize::_had_error = false; +bool ZInitialize::_finished = false; + +ZInitializer::ZInitializer(ZBarrierSet* barrier_set) { + ZInitialize::initialize(barrier_set); +} + +void ZInitialize::initialize(ZBarrierSet* barrier_set) { log_info(gc, init)("Initializing %s", ZName); log_info(gc, init)("Version: %s (%s)", VM_Version::vm_release(), @@ -62,3 +73,51 @@ ZInitialize::ZInitialize(ZBarrierSet* barrier_set) { pd_initialize(); } + +void ZInitialize::register_error(bool debug, const char *error_msg) { + guarantee(!_finished, "Only register errors during initialization"); + + if (!_had_error) { + strncpy(_error_message, error_msg, ErrorMessageLength - 1); + _had_error = true; + } + + if (debug) { + log_error_pd(gc)("%s", error_msg); + } else { + log_error_p(gc)("%s", error_msg); + } +} + +void ZInitialize::error(const char* msg_format, ...) { + va_list argp; + va_start(argp, msg_format); + const FormatBuffer error_msg(FormatBufferDummy(), msg_format, argp); + va_end(argp); + register_error(false /* debug */, error_msg); +} + +void ZInitialize::error_d(const char* msg_format, ...) { + va_list argp; + va_start(argp, msg_format); + const FormatBuffer error_msg(FormatBufferDummy(), msg_format, argp); + va_end(argp); + register_error(true /* debug */, error_msg); +} + +bool ZInitialize::had_error() { + return _had_error; +} + +const char* ZInitialize::error_message() { + assert(had_error(), "Should have registered an error"); + if (had_error()) { + return _error_message; + } + return "Unknown error, check error GC logs"; +} + +void ZInitialize::finish() { + guarantee(!_finished, "Only finish initialization once"); + _finished = true; +} diff --git a/src/hotspot/share/gc/z/zInitialize.hpp b/src/hotspot/share/gc/z/zInitialize.hpp index 599b6566234..3c551b4c622 100644 --- a/src/hotspot/share/gc/z/zInitialize.hpp +++ b/src/hotspot/share/gc/z/zInitialize.hpp @@ -24,16 +24,39 @@ #ifndef SHARE_GC_Z_ZINITIALIZE_HPP #define SHARE_GC_Z_ZINITIALIZE_HPP -#include "memory/allocation.hpp" +#include "memory/allStatic.hpp" +#include "utilities/compilerWarnings.hpp" + +#include class ZBarrierSet; -class ZInitialize { +class ZInitializer { +public: + ZInitializer(ZBarrierSet* barrier_set); +}; + +class ZInitialize : public AllStatic { private: - void pd_initialize(); + static constexpr size_t ErrorMessageLength = 256; + + static char _error_message[ErrorMessageLength]; + static bool _had_error; + static bool _finished; + + static void register_error(bool debug, const char *error_msg); + + static void pd_initialize(); public: - ZInitialize(ZBarrierSet* barrier_set); + static void error(const char* msg_format, ...) ATTRIBUTE_PRINTF(1, 2); + static void error_d(const char* msg_format, ...) ATTRIBUTE_PRINTF(1, 2); + + static bool had_error(); + static const char* error_message(); + + static void initialize(ZBarrierSet* barrier_set); + static void finish(); }; #endif // SHARE_GC_Z_ZINITIALIZE_HPP diff --git a/src/hotspot/share/gc/z/zLiveMap.cpp b/src/hotspot/share/gc/z/zLiveMap.cpp index 4123620f8b7..715ebc62917 100644 --- a/src/hotspot/share/gc/z/zLiveMap.cpp +++ b/src/hotspot/share/gc/z/zLiveMap.cpp @@ -35,9 +35,9 @@ static const ZStatCounter ZCounterMarkSeqNumResetContention("Contention", "Mark SeqNum Reset Contention", ZStatUnitOpsPerSecond); static const ZStatCounter ZCounterMarkSegmentResetContention("Contention", "Mark Segment Reset Contention", ZStatUnitOpsPerSecond); -static size_t bitmap_size(uint32_t size, size_t nsegments) { +static size_t bitmap_size(uint32_t size, size_t NumSegments) { // We need at least one bit per segment - return MAX2(size, nsegments) * 2; + return MAX2(size, NumSegments) * 2; } ZLiveMap::ZLiveMap(uint32_t size) @@ -46,7 +46,7 @@ ZLiveMap::ZLiveMap(uint32_t size) _live_bytes(0), _segment_live_bits(0), _segment_claim_bits(0), - _bitmap(bitmap_size(size, nsegments)), + _bitmap(bitmap_size(size, NumSegments)), _segment_shift(log2i_exact(segment_size())) {} void ZLiveMap::reset(ZGenerationId id) { @@ -127,7 +127,7 @@ void ZLiveMap::reset_segment(BitMap::idx_t segment) { } void ZLiveMap::resize(uint32_t size) { - const size_t new_bitmap_size = bitmap_size(size, nsegments); + const size_t new_bitmap_size = bitmap_size(size, NumSegments); if (_bitmap.size() != new_bitmap_size) { _bitmap.reinitialize(new_bitmap_size, false /* clear */); _segment_shift = log2i_exact(segment_size()); diff --git a/src/hotspot/share/gc/z/zLiveMap.hpp b/src/hotspot/share/gc/z/zLiveMap.hpp index f8b16d06dc5..7c18e1db060 100644 --- a/src/hotspot/share/gc/z/zLiveMap.hpp +++ b/src/hotspot/share/gc/z/zLiveMap.hpp @@ -35,7 +35,7 @@ class ZLiveMap { friend class ZLiveMapTest; private: - static const size_t nsegments = 64; + static const size_t NumSegments = 64; volatile uint32_t _seqnum; volatile uint32_t _live_objects; diff --git a/src/hotspot/share/gc/z/zLiveMap.inline.hpp b/src/hotspot/share/gc/z/zLiveMap.inline.hpp index 28390b72a89..a9382522480 100644 --- a/src/hotspot/share/gc/z/zLiveMap.inline.hpp +++ b/src/hotspot/share/gc/z/zLiveMap.inline.hpp @@ -52,19 +52,19 @@ inline size_t ZLiveMap::live_bytes() const { } inline const BitMapView ZLiveMap::segment_live_bits() const { - return BitMapView(const_cast(&_segment_live_bits), nsegments); + return BitMapView(const_cast(&_segment_live_bits), NumSegments); } inline const BitMapView ZLiveMap::segment_claim_bits() const { - return BitMapView(const_cast(&_segment_claim_bits), nsegments); + return BitMapView(const_cast(&_segment_claim_bits), NumSegments); } inline BitMapView ZLiveMap::segment_live_bits() { - return BitMapView(&_segment_live_bits, nsegments); + return BitMapView(&_segment_live_bits, NumSegments); } inline BitMapView ZLiveMap::segment_claim_bits() { - return BitMapView(&_segment_claim_bits, nsegments); + return BitMapView(&_segment_claim_bits, NumSegments); } inline bool ZLiveMap::is_segment_live(BitMap::idx_t segment) const { @@ -80,15 +80,15 @@ inline bool ZLiveMap::claim_segment(BitMap::idx_t segment) { } inline BitMap::idx_t ZLiveMap::first_live_segment() const { - return segment_live_bits().find_first_set_bit(0, nsegments); + return segment_live_bits().find_first_set_bit(0, NumSegments); } inline BitMap::idx_t ZLiveMap::next_live_segment(BitMap::idx_t segment) const { - return segment_live_bits().find_first_set_bit(segment + 1, nsegments); + return segment_live_bits().find_first_set_bit(segment + 1, NumSegments); } inline BitMap::idx_t ZLiveMap::segment_size() const { - return _bitmap.size() / nsegments; + return _bitmap.size() / NumSegments; } inline BitMap::idx_t ZLiveMap::index_to_segment(BitMap::idx_t index) const { @@ -167,7 +167,7 @@ inline void ZLiveMap::iterate(ZGenerationId id, Function function) { return true; }; - for (BitMap::idx_t segment = first_live_segment(); segment < nsegments; segment = next_live_segment(segment)) { + for (BitMap::idx_t segment = first_live_segment(); segment < NumSegments; segment = next_live_segment(segment)) { // For each live segment iterate_segment(segment, live_only); } diff --git a/src/hotspot/share/gc/z/zMarkStackAllocator.cpp b/src/hotspot/share/gc/z/zMarkStackAllocator.cpp index a9e404a0f55..100036dc3fe 100644 --- a/src/hotspot/share/gc/z/zMarkStackAllocator.cpp +++ b/src/hotspot/share/gc/z/zMarkStackAllocator.cpp @@ -22,8 +22,8 @@ */ #include "precompiled.hpp" -#include "gc/shared/gcLogPrecious.hpp" #include "gc/shared/gc_globals.hpp" +#include "gc/z/zInitialize.hpp" #include "gc/z/zLock.inline.hpp" #include "gc/z/zMarkStack.inline.hpp" #include "gc/z/zMarkStackAllocator.hpp" @@ -43,7 +43,7 @@ ZMarkStackSpace::ZMarkStackSpace() const size_t size = ZMarkStackSpaceLimit; const uintptr_t addr = (uintptr_t)os::reserve_memory(size, !ExecMem, mtGC); if (addr == 0) { - log_error_pd(gc, marking)("Failed to reserve address space for mark stacks"); + ZInitialize::error_d("Failed to reserve address space for mark stacks"); return; } diff --git a/src/hotspot/share/gc/z/zNMT.cpp b/src/hotspot/share/gc/z/zNMT.cpp index 41d99b102bf..b23452eb156 100644 --- a/src/hotspot/share/gc/z/zNMT.cpp +++ b/src/hotspot/share/gc/z/zNMT.cpp @@ -26,7 +26,7 @@ #include "gc/z/zGlobals.hpp" #include "gc/z/zNMT.hpp" #include "gc/z/zVirtualMemory.hpp" -#include "nmt/memflags.hpp" +#include "nmt/memTag.hpp" #include "nmt/memTracker.hpp" #include "nmt/memoryFileTracker.hpp" #include "utilities/nativeCallStack.hpp" diff --git a/src/hotspot/share/gc/z/zObjectAllocator.cpp b/src/hotspot/share/gc/z/zObjectAllocator.cpp index 27a5965700f..bf6dc98fc72 100644 --- a/src/hotspot/share/gc/z/zObjectAllocator.cpp +++ b/src/hotspot/share/gc/z/zObjectAllocator.cpp @@ -25,6 +25,7 @@ #include "gc/z/zGlobals.hpp" #include "gc/z/zHeap.inline.hpp" #include "gc/z/zHeuristics.hpp" +#include "gc/z/zLock.inline.hpp" #include "gc/z/zObjectAllocator.hpp" #include "gc/z/zPage.inline.hpp" #include "gc/z/zPageTable.inline.hpp" @@ -45,8 +46,9 @@ ZObjectAllocator::ZObjectAllocator(ZPageAge age) _use_per_cpu_shared_small_pages(ZHeuristics::use_per_cpu_shared_small_pages()), _used(0), _undone(0), + _shared_small_page(nullptr), _shared_medium_page(nullptr), - _shared_small_page(nullptr) {} + _medium_page_alloc_lock() {} ZPage** ZObjectAllocator::shared_small_page_addr() { return _use_per_cpu_shared_small_pages ? _shared_small_page.addr() : _shared_small_page.addr(0); @@ -126,6 +128,42 @@ zaddress ZObjectAllocator::alloc_object_in_shared_page(ZPage** shared_page, return addr; } +zaddress ZObjectAllocator::alloc_object_in_medium_page(size_t size, + ZAllocationFlags flags) { + zaddress addr = zaddress::null; + ZPage** shared_medium_page = _shared_medium_page.addr(); + ZPage* page = Atomic::load_acquire(shared_medium_page); + + if (page != nullptr) { + addr = page->alloc_object_atomic(size); + } + + if (is_null(addr)) { + // When a new medium page is required, we synchronize the allocation + // of the new page using a lock. This is to avoid having multiple + // threads requesting a medium page from the page cache when we know + // only one of the will succeed in installing the page at this layer. + ZLocker locker(&_medium_page_alloc_lock); + + // When holding the lock we can't allow the page allocator to stall, + // which in the common case it won't. The page allocation is thus done + // in a non-blocking fashion and only if this fails we below (while not + // holding the lock) do the blocking page allocation. + ZAllocationFlags non_blocking_flags = flags; + non_blocking_flags.set_non_blocking(); + + addr = alloc_object_in_shared_page(shared_medium_page, ZPageType::medium, ZPageSizeMedium, size, non_blocking_flags); + } + + if (is_null(addr) && !flags.non_blocking()) { + // The above allocation attempts failed and this allocation should stall + // until memory is available. Redo the allocation with blocking enabled. + addr = alloc_object_in_shared_page(shared_medium_page, ZPageType::medium, ZPageSizeMedium, size, flags); + } + + return addr; +} + zaddress ZObjectAllocator::alloc_large_object(size_t size, ZAllocationFlags flags) { zaddress addr = zaddress::null; @@ -141,7 +179,7 @@ zaddress ZObjectAllocator::alloc_large_object(size_t size, ZAllocationFlags flag } zaddress ZObjectAllocator::alloc_medium_object(size_t size, ZAllocationFlags flags) { - return alloc_object_in_shared_page(_shared_medium_page.addr(), ZPageType::medium, ZPageSizeMedium, size, flags); + return alloc_object_in_medium_page(size, flags); } zaddress ZObjectAllocator::alloc_small_object(size_t size, ZAllocationFlags flags) { diff --git a/src/hotspot/share/gc/z/zObjectAllocator.hpp b/src/hotspot/share/gc/z/zObjectAllocator.hpp index 8aa185646fa..5377972b7ba 100644 --- a/src/hotspot/share/gc/z/zObjectAllocator.hpp +++ b/src/hotspot/share/gc/z/zObjectAllocator.hpp @@ -26,6 +26,7 @@ #include "gc/z/zAddress.hpp" #include "gc/z/zAllocationFlags.hpp" +#include "gc/z/zLock.hpp" #include "gc/z/zPageAge.hpp" #include "gc/z/zPageType.hpp" #include "gc/z/zValue.hpp" @@ -39,8 +40,9 @@ private: const bool _use_per_cpu_shared_small_pages; ZPerCPU _used; ZPerCPU _undone; - ZContended _shared_medium_page; ZPerCPU _shared_small_page; + ZContended _shared_medium_page; + ZLock _medium_page_alloc_lock; ZPage** shared_small_page_addr(); ZPage* const* shared_small_page_addr() const; @@ -56,6 +58,9 @@ private: size_t size, ZAllocationFlags flags); + zaddress alloc_object_in_medium_page(size_t size, + ZAllocationFlags flags); + zaddress alloc_large_object(size_t size, ZAllocationFlags flags); zaddress alloc_medium_object(size_t size, ZAllocationFlags flags); zaddress alloc_small_object(size_t size, ZAllocationFlags flags); diff --git a/src/hotspot/share/gc/z/zPage.cpp b/src/hotspot/share/gc/z/zPage.cpp index 318b2417ee5..ff56768e9ad 100644 --- a/src/hotspot/share/gc/z/zPage.cpp +++ b/src/hotspot/share/gc/z/zPage.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -57,14 +57,9 @@ ZPage::ZPage(ZPageType type, const ZVirtualMemory& vmem, const ZPhysicalMemory& } ZPage* ZPage::clone_limited() const { - // Only copy type and memory layouts. Let the rest be lazily reconstructed when needed. - return new ZPage(_type, _virtual, _physical); -} - -ZPage* ZPage::clone_limited_promote_flipped() const { + // Only copy type and memory layouts, and also update _top. Let the rest be + // lazily reconstructed when needed. ZPage* const page = new ZPage(_type, _virtual, _physical); - - // The page is still filled with the same objects, need to retain the top pointer. page->_top = _top; return page; @@ -83,63 +78,19 @@ void ZPage::reset_seqnum() { Atomic::store(&_seqnum_other, ZGeneration::generation(_generation_id == ZGenerationId::young ? ZGenerationId::old : ZGenerationId::young)->seqnum()); } -void ZPage::remset_clear() { - _remembered_set.clear_all(); +void ZPage::remset_alloc() { + // Remsets should only be allocated/initialized once and only for old pages. + assert(!_remembered_set.is_initialized(), "Should not be initialized"); + assert(is_old(), "Only old pages need a remset"); + + _remembered_set.initialize(size()); } -void ZPage::verify_remset_after_reset(ZPageAge prev_age, ZPageResetType type) { - // Young-to-old reset - if (prev_age != ZPageAge::old) { - verify_remset_cleared_previous(); - verify_remset_cleared_current(); - return; - } - - // Old-to-old reset - switch (type) { - case ZPageResetType::Splitting: - // Page is on the way to be destroyed or reused, delay - // clearing until the page is reset for Allocation. - break; - - case ZPageResetType::InPlaceRelocation: - // Relocation failed and page is being compacted in-place. - // The remset bits are flipped each young mark start, so - // the verification code below needs to use the right remset. - if (ZGeneration::old()->active_remset_is_current()) { - verify_remset_cleared_previous(); - } else { - verify_remset_cleared_current(); - } - break; - - case ZPageResetType::FlipAging: - fatal("Should not have called this for old-to-old flipping"); - break; - - case ZPageResetType::Allocation: - verify_remset_cleared_previous(); - verify_remset_cleared_current(); - break; - }; +void ZPage::remset_delete() { + _remembered_set.delete_all(); } -void ZPage::reset_remembered_set() { - if (is_young()) { - // Remset not needed - return; - } - - // Clearing of remsets is done when freeing a page, so this code only - // needs to ensure the remset is initialized the first time a page - // becomes old. - if (!_remembered_set.is_initialized()) { - _remembered_set.initialize(size()); - } -} - -void ZPage::reset(ZPageAge age, ZPageResetType type) { - const ZPageAge prev_age = _age; +void ZPage::reset(ZPageAge age) { _age = age; _last_used = 0; @@ -148,31 +99,19 @@ void ZPage::reset(ZPageAge age, ZPageResetType type) { : ZGenerationId::young; reset_seqnum(); - - // Flip aged pages are still filled with the same objects, need to retain the top pointer. - if (type != ZPageResetType::FlipAging) { - _top = to_zoffset_end(start()); - } - - reset_remembered_set(); - verify_remset_after_reset(prev_age, type); - - if (type != ZPageResetType::InPlaceRelocation || (prev_age != ZPageAge::old && age == ZPageAge::old)) { - // Promoted in-place relocations reset the live map, - // because they clone the page. - _livemap.reset(); - } } -void ZPage::finalize_reset_for_in_place_relocation() { - // Now we're done iterating over the livemaps +void ZPage::reset_livemap() { _livemap.reset(); } +void ZPage::reset_top_for_allocation() { + _top = to_zoffset_end(start()); +} + void ZPage::reset_type_and_size(ZPageType type) { _type = type; _livemap.resize(object_max_count()); - _remembered_set.resize(size()); } ZPage* ZPage::retype(ZPageType type) { @@ -188,11 +127,9 @@ ZPage* ZPage::split(size_t split_of_size) { ZPage* ZPage::split_with_pmem(ZPageType type, const ZPhysicalMemory& pmem) { // Resize this page const ZVirtualMemory vmem = _virtual.split(pmem.size()); + assert(vmem.end() == _virtual.start(), "Should be consecutive"); reset_type_and_size(type_from_size(_virtual.size())); - reset(_age, ZPageResetType::Splitting); - - assert(vmem.end() == _virtual.start(), "Should be consecutive"); log_trace(gc, page)("Split page [" PTR_FORMAT ", " PTR_FORMAT ", " PTR_FORMAT "]", untype(vmem.start()), @@ -267,12 +204,8 @@ void ZPage::verify_remset_cleared_previous() const { } } -void ZPage::clear_remset_current() { - _remembered_set.clear_current(); -} - void ZPage::clear_remset_previous() { - _remembered_set.clear_previous(); + _remembered_set.clear_previous(); } void ZPage::swap_remset_bitmaps() { diff --git a/src/hotspot/share/gc/z/zPage.hpp b/src/hotspot/share/gc/z/zPage.hpp index e07b338c710..9b6c155f77d 100644 --- a/src/hotspot/share/gc/z/zPage.hpp +++ b/src/hotspot/share/gc/z/zPage.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,18 +36,6 @@ class ZGeneration; -enum class ZPageResetType { - // Normal allocation path - Allocation, - // Relocation failed and started to relocate in-place - InPlaceRelocation, - // Page was not selected for relocation, all objects - // stayed, but the page aged. - FlipAging, - // The page was split and needs to be reset - Splitting, -}; - class ZPage : public CHeapObj { friend class VMStructs; friend class ZList; @@ -82,17 +70,13 @@ private: const ZGeneration* generation() const; void reset_seqnum(); - void reset_remembered_set(); ZPage* split_with_pmem(ZPageType type, const ZPhysicalMemory& pmem); - void verify_remset_after_reset(ZPageAge prev_age, ZPageResetType type); - public: ZPage(ZPageType type, const ZVirtualMemory& vmem, const ZPhysicalMemory& pmem); ZPage* clone_limited() const; - ZPage* clone_limited_promote_flipped() const; uint32_t object_max_count() const; size_t object_alignment_shift() const; @@ -128,10 +112,9 @@ public: uint64_t last_used() const; void set_last_used(); - void reset(ZPageAge age, ZPageResetType type); - - void finalize_reset_for_in_place_relocation(); - + void reset(ZPageAge age); + void reset_livemap(); + void reset_top_for_allocation(); void reset_type_and_size(ZPageType type); ZPage* retype(ZPageType type); @@ -172,7 +155,8 @@ public: void clear_remset_range_non_par_current(uintptr_t l_offset, size_t size); void swap_remset_bitmaps(); - void remset_clear(); + void remset_alloc(); + void remset_delete(); ZBitMap::ReverseIterator remset_reverse_iterator_previous(); BitMap::Iterator remset_iterator_limited_current(uintptr_t l_offset, size_t size); @@ -197,7 +181,6 @@ public: void verify_remset_cleared_current() const; void verify_remset_cleared_previous() const; - void clear_remset_current(); void clear_remset_previous(); void* remset_current(); diff --git a/src/hotspot/share/gc/z/zPageAllocator.cpp b/src/hotspot/share/gc/z/zPageAllocator.cpp index b1fb1e48373..010241294a7 100644 --- a/src/hotspot/share/gc/z/zPageAllocator.cpp +++ b/src/hotspot/share/gc/z/zPageAllocator.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -275,7 +275,7 @@ bool ZPageAllocator::prime_cache(ZWorkers* workers, size_t size) { workers->run_all(&task); } - free_page(page); + free_page(page, false /* allow_defragment */); return true; } @@ -462,6 +462,38 @@ void ZPageAllocator::destroy_page(ZPage* page) { safe_destroy_page(page); } +bool ZPageAllocator::should_defragment(const ZPage* page) const { + // A small page can end up at a high address (second half of the address space) + // if we've split a larger page or we have a constrained address space. To help + // fight address space fragmentation we remap such pages to a lower address, if + // a lower address is available. + return page->type() == ZPageType::small && + page->start() >= to_zoffset(_virtual.reserved() / 2) && + page->start() > _virtual.lowest_available_address(); +} + +ZPage* ZPageAllocator::defragment_page(ZPage* page) { + // Harvest the physical memory (which is committed) + ZPhysicalMemory pmem; + ZPhysicalMemory& old_pmem = page->physical_memory(); + pmem.add_segments(old_pmem); + old_pmem.remove_segments(); + + _unmapper->unmap_and_destroy_page(page); + + // Allocate new virtual memory at a low address + const ZVirtualMemory vmem = _virtual.alloc(pmem.size(), true /* force_low_address */); + + // Create the new page and map it + ZPage* new_page = new ZPage(ZPageType::small, vmem, pmem); + map_page(new_page); + + // Update statistics + ZStatInc(ZCounterDefragment); + + return new_page; +} + bool ZPageAllocator::is_alloc_allowed(size_t size) const { const size_t available = _current_max_capacity - _used - _claimed; return available >= size; @@ -623,16 +655,6 @@ ZPage* ZPageAllocator::alloc_page_create(ZPageAllocation* allocation) { return new ZPage(allocation->type(), vmem, pmem); } -bool ZPageAllocator::should_defragment(const ZPage* page) const { - // A small page can end up at a high address (second half of the address space) - // if we've split a larger page or we have a constrained address space. To help - // fight address space fragmentation we remap such pages to a lower address, if - // a lower address is available. - return page->type() == ZPageType::small && - page->start() >= to_zoffset(_virtual.reserved() / 2) && - page->start() > _virtual.lowest_available_address(); -} - bool ZPageAllocator::is_alloc_satisfied(ZPageAllocation* allocation) const { // The allocation is immediately satisfied if the list of pages contains // exactly one page, with the type and size that was requested. However, @@ -652,12 +674,6 @@ bool ZPageAllocator::is_alloc_satisfied(ZPageAllocation* allocation) const { return false; } - if (should_defragment(page)) { - // Defragment address space - ZStatInc(ZCounterDefragment); - return false; - } - // Allocation immediately satisfied return true; } @@ -729,7 +745,12 @@ retry: // Reset page. This updates the page's sequence number and must // be done after we potentially blocked in a safepoint (stalled) // where the global sequence number was updated. - page->reset(age, ZPageResetType::Allocation); + page->reset(age); + page->reset_top_for_allocation(); + page->reset_livemap(); + if (age == ZPageAge::old) { + page->remset_alloc(); + } // Update allocation statistics. Exclude gc relocations to avoid // artificial inflation of the allocation rate during relocation. @@ -768,6 +789,18 @@ void ZPageAllocator::satisfy_stalled() { } } +ZPage* ZPageAllocator::prepare_to_recycle(ZPage* page, bool allow_defragment) { + // Make sure we have a page that is safe to recycle + ZPage* const to_recycle = _safe_recycle.register_and_clone_if_activated(page); + + // Defragment the page before recycle if allowed and needed + if (allow_defragment && should_defragment(to_recycle)) { + return defragment_page(to_recycle); + } + + return to_recycle; +} + void ZPageAllocator::recycle_page(ZPage* page) { // Set time when last used page->set_last_used(); @@ -776,9 +809,11 @@ void ZPageAllocator::recycle_page(ZPage* page) { _cache.free_page(page); } -void ZPageAllocator::free_page(ZPage* page) { +void ZPageAllocator::free_page(ZPage* page, bool allow_defragment) { const ZGenerationId generation_id = page->generation_id(); - ZPage* const to_recycle = _safe_recycle.register_and_clone_if_activated(page); + + // Prepare page for recycling before taking the lock + ZPage* const to_recycle = prepare_to_recycle(page, allow_defragment); ZLocker locker(&_lock); @@ -795,11 +830,12 @@ void ZPageAllocator::free_page(ZPage* page) { } void ZPageAllocator::free_pages(const ZArray* pages) { - ZArray to_recycle; + ZArray to_recycle_pages; size_t young_size = 0; size_t old_size = 0; + // Prepare pages for recycling before taking the lock ZArrayIterator pages_iter(pages); for (ZPage* page; pages_iter.next(&page);) { if (page->is_young()) { @@ -807,7 +843,12 @@ void ZPageAllocator::free_pages(const ZArray* pages) { } else { old_size += page->size(); } - to_recycle.push(_safe_recycle.register_and_clone_if_activated(page)); + + // Prepare to recycle + ZPage* const to_recycle = prepare_to_recycle(page, true /* allow_defragment */); + + // Register for recycling + to_recycle_pages.push(to_recycle); } ZLocker locker(&_lock); @@ -818,7 +859,7 @@ void ZPageAllocator::free_pages(const ZArray* pages) { decrease_used_generation(ZGenerationId::old, old_size); // Free pages - ZArrayIterator iter(&to_recycle); + ZArrayIterator iter(&to_recycle_pages); for (ZPage* page; iter.next(&page);) { recycle_page(page); } @@ -828,11 +869,16 @@ void ZPageAllocator::free_pages(const ZArray* pages) { } void ZPageAllocator::free_pages_alloc_failed(ZPageAllocation* allocation) { - ZArray to_recycle; + ZArray to_recycle_pages; + // Prepare pages for recycling before taking the lock ZListRemoveIterator allocation_pages_iter(allocation->pages()); for (ZPage* page; allocation_pages_iter.next(&page);) { - to_recycle.push(_safe_recycle.register_and_clone_if_activated(page)); + // Prepare to recycle + ZPage* const to_recycle = prepare_to_recycle(page, false /* allow_defragment */); + + // Register for recycling + to_recycle_pages.push(to_recycle); } ZLocker locker(&_lock); @@ -844,7 +890,7 @@ void ZPageAllocator::free_pages_alloc_failed(ZPageAllocation* allocation) { size_t freed = 0; // Free any allocated/flushed pages - ZArrayIterator iter(&to_recycle); + ZArrayIterator iter(&to_recycle_pages); for (ZPage* page; iter.next(&page);) { freed += page->size(); recycle_page(page); diff --git a/src/hotspot/share/gc/z/zPageAllocator.hpp b/src/hotspot/share/gc/z/zPageAllocator.hpp index 5d3d59a4163..7df83a10eaf 100644 --- a/src/hotspot/share/gc/z/zPageAllocator.hpp +++ b/src/hotspot/share/gc/z/zPageAllocator.hpp @@ -104,13 +104,15 @@ private: void destroy_page(ZPage* page); + bool should_defragment(const ZPage* page) const; + ZPage* defragment_page(ZPage* page); + bool is_alloc_allowed(size_t size) const; bool alloc_page_common_inner(ZPageType type, size_t size, ZList* pages); bool alloc_page_common(ZPageAllocation* allocation); bool alloc_page_stall(ZPageAllocation* allocation); bool alloc_page_or_stall(ZPageAllocation* allocation); - bool should_defragment(const ZPage* page) const; bool is_alloc_satisfied(ZPageAllocation* allocation) const; ZPage* alloc_page_create(ZPageAllocation* allocation); ZPage* alloc_page_finalize(ZPageAllocation* allocation); @@ -149,9 +151,10 @@ public: void reset_statistics(ZGenerationId id); ZPage* alloc_page(ZPageType type, size_t size, ZAllocationFlags flags, ZPageAge age); + ZPage* prepare_to_recycle(ZPage* page, bool allow_defragment); void recycle_page(ZPage* page); void safe_destroy_page(ZPage* page); - void free_page(ZPage* page); + void free_page(ZPage* page, bool allow_defragment); void free_pages(const ZArray* pages); void enable_safe_destroy() const; diff --git a/src/hotspot/share/gc/z/zReferenceProcessor.hpp b/src/hotspot/share/gc/z/zReferenceProcessor.hpp index f8e924ed99f..31c789ee859 100644 --- a/src/hotspot/share/gc/z/zReferenceProcessor.hpp +++ b/src/hotspot/share/gc/z/zReferenceProcessor.hpp @@ -36,8 +36,8 @@ class ZReferenceProcessor : public ReferenceDiscoverer { friend class ZReferenceProcessorTask; private: - static const size_t reference_type_count = REF_PHANTOM + 1; - typedef size_t Counters[reference_type_count]; + static const size_t ReferenceTypeCount = REF_PHANTOM + 1; + typedef size_t Counters[ReferenceTypeCount]; ZWorkers* const _workers; ReferencePolicy* _soft_reference_policy; diff --git a/src/hotspot/share/gc/z/zRelocate.cpp b/src/hotspot/share/gc/z/zRelocate.cpp index b55a1863bde..7f69c0752bc 100644 --- a/src/hotspot/share/gc/z/zRelocate.cpp +++ b/src/hotspot/share/gc/z/zRelocate.cpp @@ -411,7 +411,7 @@ static void retire_target_page(ZGeneration* generation, ZPage* page) { // relocate the remaining objects, leaving the target page empty when // relocation completed. if (page->used() == 0) { - ZHeap::heap()->free_page(page); + ZHeap::heap()->free_page(page, true /* allow_defragment */); } } @@ -843,7 +843,23 @@ private: // Promotions happen through a new cloned page ZPage* const to_page = promotion ? from_page->clone_limited() : from_page; - to_page->reset(to_age, ZPageResetType::InPlaceRelocation); + + // Reset page for in-place relocation + to_page->reset(to_age); + to_page->reset_top_for_allocation(); + if (promotion) { + to_page->remset_alloc(); + } + + // Verify that the inactive remset is clear when resetting the page for + // in-place relocation. + if (from_page->age() == ZPageAge::old) { + if (ZGeneration::old()->active_remset_is_current()) { + to_page->verify_remset_cleared_previous(); + } else { + to_page->verify_remset_cleared_current(); + } + } // Clear remset bits for all objects that were relocated // before this page became an in-place relocated page. @@ -927,35 +943,15 @@ public: return ZGeneration::old()->active_remset_is_current(); } - void clear_remset_before_reuse(ZPage* page, bool in_place) { + void clear_remset_before_in_place_reuse(ZPage* page) { if (_forwarding->from_age() != ZPageAge::old) { // No remset bits return; } - if (in_place) { - // Clear 'previous' remset bits. For in-place relocated pages, the previous - // remset bits are always used, even when active_remset_is_current(). - page->clear_remset_previous(); - - return; - } - - // Normal relocate - - // Clear active remset bits - if (active_remset_is_current()) { - page->clear_remset_current(); - } else { - page->clear_remset_previous(); - } - - // Verify that inactive remset bits are all cleared - if (active_remset_is_current()) { - page->verify_remset_cleared_previous(); - } else { - page->verify_remset_cleared_current(); - } + // Clear 'previous' remset bits. For in-place relocated pages, the previous + // remset bits are always used, even when active_remset_is_current(). + page->clear_remset_previous(); } void finish_in_place_relocation() { @@ -1001,7 +997,7 @@ public: ZPage* const page = _forwarding->detach_page(); // Ensure that previous remset bits are cleared - clear_remset_before_reuse(page, true /* in_place */); + clear_remset_before_in_place_reuse(page); page->log_msg(" (relocate page done in-place)"); @@ -1013,15 +1009,10 @@ public: // Wait for all other threads to call release_page ZPage* const page = _forwarding->detach_page(); - // Ensure that all remset bits are cleared - // Note: cleared after detach_page, when we know that - // the young generation isn't scanning the remset. - clear_remset_before_reuse(page, false /* in_place */); - page->log_msg(" (relocate page done normal)"); // Free page - ZHeap::heap()->free_page(page); + ZHeap::heap()->free_page(page, true /* allow_defragment */); } } }; @@ -1270,8 +1261,14 @@ public: prev_page->log_msg(promotion ? " (flip promoted)" : " (flip survived)"); // Setup to-space page - ZPage* const new_page = promotion ? prev_page->clone_limited_promote_flipped() : prev_page; - new_page->reset(to_age, ZPageResetType::FlipAging); + ZPage* const new_page = promotion ? prev_page->clone_limited() : prev_page; + + // Reset page for flip aging + new_page->reset(to_age); + new_page->reset_livemap(); + if (promotion) { + new_page->remset_alloc(); + } if (promotion) { ZGeneration::young()->flip_promote(prev_page, new_page); diff --git a/src/hotspot/share/gc/z/zRemembered.cpp b/src/hotspot/share/gc/z/zRemembered.cpp index fe60a8dc950..dc28b6d937d 100644 --- a/src/hotspot/share/gc/z/zRemembered.cpp +++ b/src/hotspot/share/gc/z/zRemembered.cpp @@ -125,7 +125,7 @@ bool ZRemembered::should_scan_page(ZPage* page) const { return false; } -bool ZRemembered::scan_page(ZPage* page) const { +bool ZRemembered::scan_page_and_clear_remset(ZPage* page) const { const bool can_trust_live_bits = page->is_relocatable() && !ZGeneration::old()->is_phase_mark(); @@ -151,6 +151,20 @@ bool ZRemembered::scan_page(ZPage* page) const { // All objects are dead - do nothing } + if (ZVerifyRemembered) { + // Make sure self healing of pointers is ordered before clearing of + // the previous bits so that ZVerify::after_scan can detect missing + // remset entries accurately. + OrderAccess::storestore(); + } + + // If we have consumed the remset entries above we also clear them. + // The exception is if the page is completely empty/garbage, where we don't + // want to race with an old collection modifying the remset as well. + if (!can_trust_live_bits || page->is_marked()) { + page->clear_remset_previous(); + } + return result; } @@ -500,16 +514,7 @@ public: if (page != nullptr) { if (_remembered->should_scan_page(page)) { // Visit all entries pointing into young gen - bool found_roots = _remembered->scan_page(page); - - // ... and as a side-effect clear the previous entries - if (ZVerifyRemembered) { - // Make sure self healing of pointers is ordered before clearing of - // the previous bits so that ZVerify::after_scan can detect missing - // remset entries accurately. - OrderAccess::storestore(); - } - page->clear_remset_previous(); + bool found_roots = _remembered->scan_page_and_clear_remset(page); if (found_roots && !left_marking) { // Follow remembered set when possible diff --git a/src/hotspot/share/gc/z/zRemembered.hpp b/src/hotspot/share/gc/z/zRemembered.hpp index f7c74e8c531..815d5c787d3 100644 --- a/src/hotspot/share/gc/z/zRemembered.hpp +++ b/src/hotspot/share/gc/z/zRemembered.hpp @@ -73,7 +73,7 @@ private: bool should_scan_page(ZPage* page) const; - bool scan_page(ZPage* page) const; + bool scan_page_and_clear_remset(ZPage* page) const; bool scan_forwarding(ZForwarding* forwarding, void* context) const; public: diff --git a/src/hotspot/share/gc/z/zRememberedSet.cpp b/src/hotspot/share/gc/z/zRememberedSet.cpp index cb92e38db2e..f605401648d 100644 --- a/src/hotspot/share/gc/z/zRememberedSet.cpp +++ b/src/hotspot/share/gc/z/zRememberedSet.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -55,18 +55,10 @@ void ZRememberedSet::initialize(size_t page_size) { _bitmap[1].initialize(size_in_bits, true /* clear */); } -void ZRememberedSet::resize(size_t page_size) { - // The bitmaps only need to be resized if remset has been - // initialized, and hence the bitmaps have been initialized. - if (is_initialized()) { - const BitMap::idx_t size_in_bits = to_bit_size(page_size); - - // The bitmaps need to be cleared when free, but since this function is - // only used for shrinking the clear argument is correct but not crucial. - assert(size_in_bits <= _bitmap[0].size(), "Only used for shrinking"); - _bitmap[0].resize(size_in_bits, true /* clear */); - _bitmap[1].resize(size_in_bits, true /* clear */); - } +void ZRememberedSet::delete_all() { + assert(is_initialized(), "precondition"); + _bitmap[0].resize(0); + _bitmap[1].resize(0); } bool ZRememberedSet::is_cleared_current() const { @@ -77,15 +69,6 @@ bool ZRememberedSet::is_cleared_previous() const { return previous()->is_empty(); } -void ZRememberedSet::clear_all() { - clear_current(); - clear_previous(); -} - -void ZRememberedSet::clear_current() { - current()->clear_large(); -} - void ZRememberedSet::clear_previous() { previous()->clear_large(); } diff --git a/src/hotspot/share/gc/z/zRememberedSet.hpp b/src/hotspot/share/gc/z/zRememberedSet.hpp index d18c357f0dd..c3c6e8bc313 100644 --- a/src/hotspot/share/gc/z/zRememberedSet.hpp +++ b/src/hotspot/share/gc/z/zRememberedSet.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -114,8 +114,7 @@ public: bool is_initialized() const; void initialize(size_t page_size); - - void resize(size_t page_size); + void delete_all(); bool at_current(uintptr_t offset) const; bool at_previous(uintptr_t offset) const; @@ -133,8 +132,6 @@ public: bool is_cleared_current() const; bool is_cleared_previous() const; - void clear_all(); - void clear_current(); void clear_previous(); void swap_remset_bitmaps(); diff --git a/src/hotspot/share/gc/z/zStackWatermark.cpp b/src/hotspot/share/gc/z/zStackWatermark.cpp index ead5300e9c3..0c7ec553e5c 100644 --- a/src/hotspot/share/gc/z/zStackWatermark.cpp +++ b/src/hotspot/share/gc/z/zStackWatermark.cpp @@ -130,7 +130,7 @@ void ZStackWatermark::save_old_watermark() { } else { // Found none too replace - push it to the top _old_watermarks_newest++; - assert(_old_watermarks_newest < _old_watermarks_max, "Unexpected amount of old watermarks"); + assert(_old_watermarks_newest < OldWatermarksMax, "Unexpected amount of old watermarks"); } // Install old watermark diff --git a/src/hotspot/share/gc/z/zStackWatermark.hpp b/src/hotspot/share/gc/z/zStackWatermark.hpp index fd4efeef761..f2cf59d3b4a 100644 --- a/src/hotspot/share/gc/z/zStackWatermark.hpp +++ b/src/hotspot/share/gc/z/zStackWatermark.hpp @@ -59,8 +59,8 @@ class ZStackWatermark : public StackWatermark { private: // Stores old watermarks, which describes the // colors of the non-processed part of the stack. - const static int _old_watermarks_max = 3; - ZColorWatermark _old_watermarks[_old_watermarks_max]; + static const int OldWatermarksMax = 3; + ZColorWatermark _old_watermarks[OldWatermarksMax]; int _old_watermarks_newest; ThreadLocalAllocStats _stats; diff --git a/src/hotspot/share/gc/z/zStat.cpp b/src/hotspot/share/gc/z/zStat.cpp index c2a7a23c04f..56b3590960f 100644 --- a/src/hotspot/share/gc/z/zStat.cpp +++ b/src/hotspot/share/gc/z/zStat.cpp @@ -1019,7 +1019,7 @@ ZStatMutatorAllocRateStats ZStatMutatorAllocRate::stats() { // Stat thread // ZStat::ZStat() - : _metronome(sample_hz) { + : _metronome(SampleHz) { set_name("ZStat"); create_and_start(); ZStatMutatorAllocRate::initialize(); @@ -1098,11 +1098,11 @@ void ZStat::terminate() { // class ZStatTablePrinter { private: - static const size_t _buffer_size = 256; + static const size_t BufferSize = 256; const size_t _column0_width; const size_t _columnN_width; - char _buffer[_buffer_size]; + char _buffer[BufferSize]; public: class ZColumn { @@ -1119,7 +1119,7 @@ public: } size_t print(size_t position, const char* fmt, va_list va) { - const int res = jio_vsnprintf(_buffer + position, _buffer_size - position, fmt, va); + const int res = jio_vsnprintf(_buffer + position, BufferSize - position, fmt, va); if (res < 0) { return 0; } diff --git a/src/hotspot/share/gc/z/zStat.hpp b/src/hotspot/share/gc/z/zStat.hpp index d7482dbe6aa..d7fff6d7b8e 100644 --- a/src/hotspot/share/gc/z/zStat.hpp +++ b/src/hotspot/share/gc/z/zStat.hpp @@ -384,7 +384,7 @@ public: // class ZStat : public ZThread { private: - static const uint64_t sample_hz = 1; + static const uint64_t SampleHz = 1; ZMetronome _metronome; diff --git a/src/hotspot/share/gc/z/zStoreBarrierBuffer.cpp b/src/hotspot/share/gc/z/zStoreBarrierBuffer.cpp index c94551dc62d..78106aad729 100644 --- a/src/hotspot/share/gc/z/zStoreBarrierBuffer.cpp +++ b/src/hotspot/share/gc/z/zStoreBarrierBuffer.cpp @@ -55,7 +55,7 @@ ZStoreBarrierBuffer::ZStoreBarrierBuffer() _last_installed_color(), _base_pointer_lock(), _base_pointers(), - _current(ZBufferStoreBarriers ? _buffer_size_bytes : 0) {} + _current(ZBufferStoreBarriers ? BufferSizeBytes : 0) {} void ZStoreBarrierBuffer::initialize() { _last_processed_color = ZPointerStoreGoodMask; @@ -63,11 +63,11 @@ void ZStoreBarrierBuffer::initialize() { } void ZStoreBarrierBuffer::clear() { - _current = _buffer_size_bytes; + _current = BufferSizeBytes; } bool ZStoreBarrierBuffer::is_empty() const { - return _current == _buffer_size_bytes; + return _current == BufferSizeBytes; } void ZStoreBarrierBuffer::install_base_pointers_inner() { @@ -79,7 +79,7 @@ void ZStoreBarrierBuffer::install_base_pointers_inner() { (ZPointer::remap_bits(_last_processed_color) & ZPointerRemappedOldMask) == 0, "Should not have double bit errors"); - for (size_t i = current(); i < _buffer_length; ++i) { + for (size_t i = current(); i < BufferLength; ++i) { const ZStoreBarrierEntry& entry = _buffer[i]; volatile zpointer* const p = entry._p; const zaddress_unsafe p_unsafe = to_zaddress_unsafe((uintptr_t)p); @@ -229,7 +229,7 @@ void ZStoreBarrierBuffer::on_new_phase() { // Install all base pointers for relocation install_base_pointers(); - for (size_t i = current(); i < _buffer_length; ++i) { + for (size_t i = current(); i < BufferLength; ++i) { on_new_phase_relocate(i); on_new_phase_remember(i); on_new_phase_mark(i); @@ -259,7 +259,7 @@ void ZStoreBarrierBuffer::on_error(outputStream* st) { st->print_cr(" _last_processed_color: " PTR_FORMAT, _last_processed_color); st->print_cr(" _last_installed_color: " PTR_FORMAT, _last_installed_color); - for (size_t i = current(); i < _buffer_length; ++i) { + for (size_t i = current(); i < BufferLength; ++i) { st->print_cr(" [%2zu]: base: " PTR_FORMAT " p: " PTR_FORMAT " prev: " PTR_FORMAT, i, untype(_base_pointers[i]), @@ -276,7 +276,7 @@ void ZStoreBarrierBuffer::flush() { OnError on_error(this); VMErrorCallbackMark mark(&on_error); - for (size_t i = current(); i < _buffer_length; ++i) { + for (size_t i = current(); i < BufferLength; ++i) { const ZStoreBarrierEntry& entry = _buffer[i]; const zaddress addr = ZBarrier::make_load_good(entry._prev); ZBarrier::mark_and_remember(entry._p, addr); @@ -296,7 +296,7 @@ bool ZStoreBarrierBuffer::is_in(volatile zpointer* p) { const uintptr_t last_remap_bits = ZPointer::remap_bits(buffer->_last_processed_color) & ZPointerRemappedMask; const bool needs_remap = last_remap_bits != ZPointerRemapped; - for (size_t i = buffer->current(); i < _buffer_length; ++i) { + for (size_t i = buffer->current(); i < BufferLength; ++i) { const ZStoreBarrierEntry& entry = buffer->_buffer[i]; volatile zpointer* entry_p = entry._p; diff --git a/src/hotspot/share/gc/z/zStoreBarrierBuffer.hpp b/src/hotspot/share/gc/z/zStoreBarrierBuffer.hpp index 5903edb6ad4..68984a15a1e 100644 --- a/src/hotspot/share/gc/z/zStoreBarrierBuffer.hpp +++ b/src/hotspot/share/gc/z/zStoreBarrierBuffer.hpp @@ -42,10 +42,10 @@ class ZStoreBarrierBuffer : public CHeapObj { friend class ZVerify; private: - static const size_t _buffer_length = 32; - static const size_t _buffer_size_bytes = _buffer_length * sizeof(ZStoreBarrierEntry); + static const size_t BufferLength = 32; + static const size_t BufferSizeBytes = BufferLength * sizeof(ZStoreBarrierEntry); - ZStoreBarrierEntry _buffer[_buffer_length]; + ZStoreBarrierEntry _buffer[BufferLength]; // Color from previous phase this buffer was processed uintptr_t _last_processed_color; @@ -54,7 +54,7 @@ private: uintptr_t _last_installed_color; ZLock _base_pointer_lock; - zaddress_unsafe _base_pointers[_buffer_length]; + zaddress_unsafe _base_pointers[BufferLength]; // sizeof(ZStoreBarrierEntry) scaled index growing downwards size_t _current; diff --git a/src/hotspot/share/gc/z/zValue.hpp b/src/hotspot/share/gc/z/zValue.hpp index 29f1b707e7c..4953978297f 100644 --- a/src/hotspot/share/gc/z/zValue.hpp +++ b/src/hotspot/share/gc/z/zValue.hpp @@ -39,7 +39,7 @@ private: static uintptr_t _end; public: - static const size_t offset = 4 * K; + static const size_t Offset = 4 * K; static uintptr_t alloc(size_t size); }; diff --git a/src/hotspot/share/gc/z/zValue.inline.hpp b/src/hotspot/share/gc/z/zValue.inline.hpp index 2367bac0f0a..c2aa8bbbb40 100644 --- a/src/hotspot/share/gc/z/zValue.inline.hpp +++ b/src/hotspot/share/gc/z/zValue.inline.hpp @@ -44,7 +44,7 @@ template uintptr_t ZValueStorage::_top = 0; template uintptr_t ZValueStorage::alloc(size_t size) { - assert(size <= offset, "Allocation too large"); + assert(size <= Offset, "Allocation too large"); // Allocate entry in existing memory block const uintptr_t addr = align_up(_top, S::alignment()); @@ -56,10 +56,10 @@ uintptr_t ZValueStorage::alloc(size_t size) { } // Allocate new block of memory - const size_t block_alignment = offset; - const size_t block_size = offset * S::count(); + const size_t block_alignment = Offset; + const size_t block_size = Offset * S::count(); _top = ZUtils::alloc_aligned_unfreeable(block_alignment, block_size); - _end = _top + offset; + _end = _top + Offset; // Retry allocation return alloc(size); @@ -119,7 +119,7 @@ inline uint32_t ZPerWorkerStorage::id() { template inline uintptr_t ZValue::value_addr(uint32_t value_id) const { - return _addr + (value_id * S::offset); + return _addr + (value_id * S::Offset); } template diff --git a/src/hotspot/share/gc/z/zVerify.cpp b/src/hotspot/share/gc/z/zVerify.cpp index b735965e9d4..03b50e110e4 100644 --- a/src/hotspot/share/gc/z/zVerify.cpp +++ b/src/hotspot/share/gc/z/zVerify.cpp @@ -589,7 +589,7 @@ void ZVerify::on_color_flip() { for (JavaThreadIteratorWithHandle jtiwh; JavaThread* const jt = jtiwh.next(); ) { const ZStoreBarrierBuffer* const buffer = ZThreadLocalData::store_barrier_buffer(jt); - for (size_t i = buffer->current(); i < ZStoreBarrierBuffer::_buffer_length; ++i) { + for (size_t i = buffer->current(); i < ZStoreBarrierBuffer::BufferLength; ++i) { volatile zpointer* const p = buffer->_buffer[i]._p; bool created = false; z_verify_store_barrier_buffer_table->put_if_absent(p, true, &created); diff --git a/src/hotspot/share/gc/z/zVirtualMemory.cpp b/src/hotspot/share/gc/z/zVirtualMemory.cpp index 6b53b2ba7c8..2160aa38948 100644 --- a/src/hotspot/share/gc/z/zVirtualMemory.cpp +++ b/src/hotspot/share/gc/z/zVirtualMemory.cpp @@ -27,6 +27,7 @@ #include "gc/z/zAddress.inline.hpp" #include "gc/z/zAddressSpaceLimit.hpp" #include "gc/z/zGlobals.hpp" +#include "gc/z/zInitialize.hpp" #include "gc/z/zNMT.hpp" #include "gc/z/zVirtualMemory.inline.hpp" #include "utilities/align.hpp" @@ -44,7 +45,7 @@ ZVirtualMemoryManager::ZVirtualMemoryManager(size_t max_capacity) // Reserve address space if (!reserve(max_capacity)) { - log_error_pd(gc)("Failed to reserve enough address space for Java heap"); + ZInitialize::error_d("Failed to reserve enough address space for Java heap"); return; } diff --git a/src/hotspot/share/interpreter/abstractInterpreter.cpp b/src/hotspot/share/interpreter/abstractInterpreter.cpp index 2fad5ba39ef..616ba29c62b 100644 --- a/src/hotspot/share/interpreter/abstractInterpreter.cpp +++ b/src/hotspot/share/interpreter/abstractInterpreter.cpp @@ -74,7 +74,9 @@ void AbstractInterpreter::print() { tty->print_cr("avg codelet size = %6d bytes", _code->used_space() / _code->number_of_stubs()); tty->cr(); } + _should_print_instructions = PrintInterpreter; _code->print(); + _should_print_instructions = false; tty->print_cr("----------------------------------------------------------------------"); tty->cr(); } @@ -91,6 +93,8 @@ address AbstractInterpreter::_slow_signature_handler; address AbstractInterpreter::_entry_table [AbstractInterpreter::number_of_method_entries]; address AbstractInterpreter::_native_abi_to_tosca [AbstractInterpreter::number_of_result_handlers]; +bool AbstractInterpreter::_should_print_instructions = false; + //------------------------------------------------------------------------------------------------------------------------ // Generation of complete interpreter @@ -138,6 +142,7 @@ AbstractInterpreter::MethodKind AbstractInterpreter::method_kind(const methodHan case vmIntrinsics::_dsin: return java_lang_math_sin; case vmIntrinsics::_dcos: return java_lang_math_cos; case vmIntrinsics::_dtan: return java_lang_math_tan; + case vmIntrinsics::_dtanh: return java_lang_math_tanh; case vmIntrinsics::_dabs: return java_lang_math_abs; case vmIntrinsics::_dlog: return java_lang_math_log; case vmIntrinsics::_dlog10: return java_lang_math_log10; @@ -198,6 +203,7 @@ vmIntrinsics::ID AbstractInterpreter::method_intrinsic(MethodKind kind) { case java_lang_math_sin : return vmIntrinsics::_dsin; case java_lang_math_cos : return vmIntrinsics::_dcos; case java_lang_math_tan : return vmIntrinsics::_dtan; + case java_lang_math_tanh : return vmIntrinsics::_dtanh; case java_lang_math_abs : return vmIntrinsics::_dabs; case java_lang_math_log : return vmIntrinsics::_dlog; case java_lang_math_log10 : return vmIntrinsics::_dlog10; @@ -309,6 +315,7 @@ void AbstractInterpreter::print_method_kind(MethodKind kind) { case java_lang_math_sin : tty->print("java_lang_math_sin" ); break; case java_lang_math_cos : tty->print("java_lang_math_cos" ); break; case java_lang_math_tan : tty->print("java_lang_math_tan" ); break; + case java_lang_math_tanh : tty->print("java_lang_math_tanh" ); break; case java_lang_math_abs : tty->print("java_lang_math_abs" ); break; case java_lang_math_log : tty->print("java_lang_math_log" ); break; case java_lang_math_log10 : tty->print("java_lang_math_log10" ); break; diff --git a/src/hotspot/share/interpreter/abstractInterpreter.hpp b/src/hotspot/share/interpreter/abstractInterpreter.hpp index e487b152b76..55fb58021a0 100644 --- a/src/hotspot/share/interpreter/abstractInterpreter.hpp +++ b/src/hotspot/share/interpreter/abstractInterpreter.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -72,6 +72,7 @@ class AbstractInterpreter: AllStatic { java_lang_math_sin, // implementation of java.lang.Math.sin (x) java_lang_math_cos, // implementation of java.lang.Math.cos (x) java_lang_math_tan, // implementation of java.lang.Math.tan (x) + java_lang_math_tanh, // implementation of java.lang.Math.tanh (x) java_lang_math_abs, // implementation of java.lang.Math.abs (x) java_lang_math_sqrt, // implementation of java.lang.Math.sqrt (x) java_lang_math_sqrt_strict, // implementation of java.lang.StrictMath.sqrt(x) @@ -125,6 +126,8 @@ class AbstractInterpreter: AllStatic { static address _rethrow_exception_entry; // rethrows an activation in previous frame + static bool _should_print_instructions; // only with PrintInterpreter and when printing all InterpreterCodelet + friend class AbstractInterpreterGenerator; friend class InterpreterMacroAssembler; @@ -132,6 +135,7 @@ class AbstractInterpreter: AllStatic { // Initialization/debugging static void initialize(); static StubQueue* code() { return _code; } + static bool should_print_instructions() { return _should_print_instructions; } // Method activation @@ -151,6 +155,7 @@ class AbstractInterpreter: AllStatic { case vmIntrinsics::_dsin : // fall thru case vmIntrinsics::_dcos : // fall thru case vmIntrinsics::_dtan : // fall thru + case vmIntrinsics::_dtanh : // fall thru case vmIntrinsics::_dabs : // fall thru case vmIntrinsics::_dsqrt : // fall thru case vmIntrinsics::_dsqrt_strict : // fall thru diff --git a/src/hotspot/share/interpreter/bytecodeTracer.cpp b/src/hotspot/share/interpreter/bytecodeTracer.cpp index e5a3e9c16f4..cdb53b62f8c 100644 --- a/src/hotspot/share/interpreter/bytecodeTracer.cpp +++ b/src/hotspot/share/interpreter/bytecodeTracer.cpp @@ -105,7 +105,7 @@ class BytecodePrinter { // the incoming method. We could lose a line of trace output. // This is acceptable in a debug-only feature. st->cr(); - st->print("[%ld] ", (long) Thread::current()->osthread()->thread_id()); + st->print("[" UINTX_FORMAT "] ", Thread::current()->osthread()->thread_id_for_printing()); method->print_name(st); st->cr(); _current_method = method(); @@ -128,7 +128,7 @@ class BytecodePrinter { code == Bytecodes::_return_register_finalizer || (code >= Bytecodes::_ireturn && code <= Bytecodes::_return)) { int bci = (int)(bcp - method->code_base()); - st->print("[%ld] ", (long) Thread::current()->osthread()->thread_id()); + st->print("[" UINTX_FORMAT "] ", Thread::current()->osthread()->thread_id_for_printing()); if (Verbose) { st->print("%8d %4d " INTPTR_FORMAT " " INTPTR_FORMAT " %s", BytecodeCounter::counter_value(), bci, tos, tos2, Bytecodes::name(code)); diff --git a/src/hotspot/share/interpreter/bytecodeUtils.cpp b/src/hotspot/share/interpreter/bytecodeUtils.cpp index 34fd2b8d566..d86eda0cbe9 100644 --- a/src/hotspot/share/interpreter/bytecodeUtils.cpp +++ b/src/hotspot/share/interpreter/bytecodeUtils.cpp @@ -643,7 +643,7 @@ int ExceptionMessageBuilder::do_instruction(int bci) { } } - constantTag tag = cp->tag_at(cp_index); + constantTag tag = cp->constant_tag_at(cp_index); if (tag.is_klass() || tag.is_unresolved_klass() || tag.is_method() || tag.is_interface_method() || tag.is_field() || tag.is_string()) { diff --git a/src/hotspot/share/interpreter/interpreter.cpp b/src/hotspot/share/interpreter/interpreter.cpp index 3c4ff4c1749..cba26f5aa6a 100644 --- a/src/hotspot/share/interpreter/interpreter.cpp +++ b/src/hotspot/share/interpreter/interpreter.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -66,7 +66,7 @@ void InterpreterCodelet::verify() {} void InterpreterCodelet::print_on(outputStream* st) const { ttyLocker ttyl; - if (PrintInterpreter) { + if (AbstractInterpreter::should_print_instructions()) { st->cr(); st->print_cr("----------------------------------------------------------------------"); } @@ -76,7 +76,7 @@ void InterpreterCodelet::print_on(outputStream* st) const { st->print_cr("[" INTPTR_FORMAT ", " INTPTR_FORMAT "] %d bytes", p2i(code_begin()), p2i(code_end()), code_size()); - if (PrintInterpreter) { + if (AbstractInterpreter::should_print_instructions()) { st->cr(); Disassembler::decode(code_begin(), code_end(), st NOT_PRODUCT(COMMA &_asm_remarks)); } diff --git a/src/hotspot/share/interpreter/linkResolver.cpp b/src/hotspot/share/interpreter/linkResolver.cpp index cadc3e8a2e8..36847580d9c 100644 --- a/src/hotspot/share/interpreter/linkResolver.cpp +++ b/src/hotspot/share/interpreter/linkResolver.cpp @@ -87,7 +87,7 @@ void CallInfo::set_interface(Klass* resolved_klass, // we should pick the vtable index from the resolved method. // In that case, the caller must call set_virtual instead of set_interface. assert(resolved_method->method_holder()->is_interface(), ""); - assert(itable_index == resolved_method()->itable_index(), ""); + assert(itable_index == resolved_method->itable_index(), ""); set_common(resolved_klass, resolved_method, selected_method, CallInfo::itable_call, itable_index, CHECK); } @@ -1541,7 +1541,7 @@ void LinkResolver::runtime_resolve_interface_method(CallInfo& result, } // resolve the method in the receiver class, unless it is private - if (!is_abstract_interpretation && !resolved_method()->is_private()) { + if (!is_abstract_interpretation && !resolved_method->is_private()) { // do lookup based on receiver klass // This search must match the linktime preparation search for itable initialization // to correctly enforce loader constraints for interface method inheritance. @@ -1590,17 +1590,17 @@ void LinkResolver::runtime_resolve_interface_method(CallInfo& result, assert(is_abstract_interpretation || vtable_index == selected_method->vtable_index(), "sanity check"); result.set_virtual(resolved_klass, resolved_method, selected_method, vtable_index, CHECK); } else if (resolved_method->has_itable_index()) { - int itable_index = resolved_method()->itable_index(); + int itable_index = resolved_method->itable_index(); log_develop_trace(itables)(" -- itable index: %d", itable_index); result.set_interface(resolved_klass, resolved_method, selected_method, itable_index, CHECK); } else { int index = resolved_method->vtable_index(); log_develop_trace(itables)(" -- non itable/vtable index: %d", index); assert(index == Method::nonvirtual_vtable_index, "Oops hit another case!"); - assert(resolved_method()->is_private() || - (resolved_method()->is_final() && resolved_method->method_holder() == vmClasses::Object_klass()), + assert(resolved_method->is_private() || + (resolved_method->is_final() && resolved_method->method_holder() == vmClasses::Object_klass()), "Should only have non-virtual invokeinterface for private or final-Object methods!"); - assert(resolved_method()->can_be_statically_bound(), "Should only have non-virtual invokeinterface for statically bound methods!"); + assert(resolved_method->can_be_statically_bound(), "Should only have non-virtual invokeinterface for statically bound methods!"); // This sets up the nonvirtual form of "virtual" call (as needed for final and private methods) result.set_virtual(resolved_klass, resolved_method, resolved_method, index, CHECK); } diff --git a/src/hotspot/share/interpreter/linkResolver.hpp b/src/hotspot/share/interpreter/linkResolver.hpp index 340c7d412d5..69bdf56137d 100644 --- a/src/hotspot/share/interpreter/linkResolver.hpp +++ b/src/hotspot/share/interpreter/linkResolver.hpp @@ -99,7 +99,6 @@ class CallInfo : public StackObj { // Materialize a java.lang.invoke.ResolvedMethodName for this resolved_method void set_resolved_method_name(TRAPS); - BasicType result_type() const { return selected_method()->result_type(); } CallKind call_kind() const { return _call_kind; } int vtable_index() const { // Even for interface calls the vtable index could be non-negative. diff --git a/src/hotspot/share/interpreter/templateInterpreterGenerator.cpp b/src/hotspot/share/interpreter/templateInterpreterGenerator.cpp index 9cd6f5ceffb..3f497c3360b 100644 --- a/src/hotspot/share/interpreter/templateInterpreterGenerator.cpp +++ b/src/hotspot/share/interpreter/templateInterpreterGenerator.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -192,6 +192,7 @@ void TemplateInterpreterGenerator::generate_all() { method_entry(java_lang_math_sin ) method_entry(java_lang_math_cos ) method_entry(java_lang_math_tan ) + method_entry(java_lang_math_tanh ) method_entry(java_lang_math_abs ) method_entry(java_lang_math_sqrt ) method_entry(java_lang_math_sqrt_strict) @@ -457,6 +458,7 @@ address TemplateInterpreterGenerator::generate_intrinsic_entry(AbstractInterpret case Interpreter::java_lang_math_sin : // fall thru case Interpreter::java_lang_math_cos : // fall thru case Interpreter::java_lang_math_tan : // fall thru + case Interpreter::java_lang_math_tanh : // fall thru case Interpreter::java_lang_math_abs : // fall thru case Interpreter::java_lang_math_log : // fall thru case Interpreter::java_lang_math_log10 : // fall thru diff --git a/src/hotspot/share/interpreter/templateInterpreterGenerator.hpp b/src/hotspot/share/interpreter/templateInterpreterGenerator.hpp index bcccff2fe82..b0afcb52795 100644 --- a/src/hotspot/share/interpreter/templateInterpreterGenerator.hpp +++ b/src/hotspot/share/interpreter/templateInterpreterGenerator.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -74,7 +74,7 @@ class TemplateInterpreterGenerator: public AbstractInterpreterGenerator { void set_safepoints_for_all_bytes(); // Helpers for generate_and_dispatch - address generate_trace_code(TosState state) PRODUCT_RETURN0; + address generate_trace_code(TosState state) PRODUCT_RETURN_NULL; void count_bytecode() PRODUCT_RETURN; void histogram_bytecode(Template* t) PRODUCT_RETURN; void histogram_bytecode_pair(Template* t) PRODUCT_RETURN; diff --git a/src/hotspot/share/interpreter/zero/zeroInterpreterGenerator.cpp b/src/hotspot/share/interpreter/zero/zeroInterpreterGenerator.cpp index e08d9553c3e..27ea1b97067 100644 --- a/src/hotspot/share/interpreter/zero/zeroInterpreterGenerator.cpp +++ b/src/hotspot/share/interpreter/zero/zeroInterpreterGenerator.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright 2007, 2008, 2009, 2010, 2011 Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -54,6 +54,7 @@ void ZeroInterpreterGenerator::generate_all() { method_entry(java_lang_math_sin ); method_entry(java_lang_math_cos ); method_entry(java_lang_math_tan ); + method_entry(java_lang_math_tanh ); method_entry(java_lang_math_abs ); method_entry(java_lang_math_sqrt ); method_entry(java_lang_math_sqrt_strict); @@ -95,6 +96,7 @@ address ZeroInterpreterGenerator::generate_method_entry( case Interpreter::java_lang_math_sin : // fall thru case Interpreter::java_lang_math_cos : // fall thru case Interpreter::java_lang_math_tan : // fall thru + case Interpreter::java_lang_math_tanh : // fall thru case Interpreter::java_lang_math_abs : // fall thru case Interpreter::java_lang_math_log : // fall thru case Interpreter::java_lang_math_log10 : // fall thru diff --git a/src/hotspot/share/jfr/leakprofiler/chains/jfrbitset.hpp b/src/hotspot/share/jfr/leakprofiler/chains/jfrbitset.hpp index 8f1d2b4d5b1..9a123a91629 100644 --- a/src/hotspot/share/jfr/leakprofiler/chains/jfrbitset.hpp +++ b/src/hotspot/share/jfr/leakprofiler/chains/jfrbitset.hpp @@ -25,7 +25,7 @@ #ifndef SHARE_JFR_LEAKPROFILER_JFRBITSET_HPP #define SHARE_JFR_LEAKPROFILER_JFRBITSET_HPP -#include "nmt/memflags.hpp" +#include "nmt/memTag.hpp" #include "utilities/objectBitSet.inline.hpp" typedef ObjectBitSet JFRBitSet; diff --git a/src/hotspot/share/jfr/metadata/metadata.xml b/src/hotspot/share/jfr/metadata/metadata.xml index 0782f94a903..babb24f28ea 100644 --- a/src/hotspot/share/jfr/metadata/metadata.xml +++ b/src/hotspot/share/jfr/metadata/metadata.xml @@ -735,7 +735,7 @@ + description="Native memory usage for a given memory tag in the JVM" period="everyChunk"> diff --git a/src/hotspot/share/jfr/periodic/jfrNativeMemoryEvent.cpp b/src/hotspot/share/jfr/periodic/jfrNativeMemoryEvent.cpp index 2b861081215..6c0584f50ff 100644 --- a/src/hotspot/share/jfr/periodic/jfrNativeMemoryEvent.cpp +++ b/src/hotspot/share/jfr/periodic/jfrNativeMemoryEvent.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -63,10 +63,10 @@ void JfrNativeMemoryEvent::send_total_event(const Ticks& timestamp) { event.commit(); } -void JfrNativeMemoryEvent::send_type_event(const Ticks& starttime, MEMFLAGS flag, size_t reserved, size_t committed) { +void JfrNativeMemoryEvent::send_type_event(const Ticks& starttime, MemTag mem_tag, size_t reserved, size_t committed) { EventNativeMemoryUsage event(UNTIMED); event.set_starttime(starttime); - event.set_type(NMTUtil::flag_to_index(flag)); + event.set_type(NMTUtil::tag_to_index(mem_tag)); event.set_reserved(reserved); event.set_committed(committed); event.commit(); @@ -79,12 +79,12 @@ void JfrNativeMemoryEvent::send_type_events(const Ticks& timestamp) { NMTUsage* usage = get_usage(timestamp); - for (int index = 0; index < mt_number_of_types; index ++) { - MEMFLAGS flag = NMTUtil::index_to_flag(index); - if (flag == mtNone) { + for (int index = 0; index < mt_number_of_tags; index ++) { + MemTag mem_tag = NMTUtil::index_to_tag(index); + if (mem_tag == mtNone) { // Skip mtNone since it is not really used. continue; } - send_type_event(timestamp, flag, usage->reserved(flag), usage->committed(flag)); + send_type_event(timestamp, mem_tag, usage->reserved(mem_tag), usage->committed(mem_tag)); } } diff --git a/src/hotspot/share/jfr/periodic/jfrNativeMemoryEvent.hpp b/src/hotspot/share/jfr/periodic/jfrNativeMemoryEvent.hpp index c5a476c78a8..f2628bc1287 100644 --- a/src/hotspot/share/jfr/periodic/jfrNativeMemoryEvent.hpp +++ b/src/hotspot/share/jfr/periodic/jfrNativeMemoryEvent.hpp @@ -25,7 +25,7 @@ #ifndef SHARE_JFR_PERIODIC_JFRNATIVEMEMORYEVENT_HPP #define SHARE_JFR_PERIODIC_JFRNATIVEMEMORYEVENT_HPP -#include "nmt/memflags.hpp" +#include "nmt/memTag.hpp" #include "nmt/nmtUsage.hpp" #include "utilities/globalDefinitions.hpp" #include "utilities/ticks.hpp" @@ -35,7 +35,7 @@ // so no more synchronization is needed. class JfrNativeMemoryEvent : public AllStatic { private: - static void send_type_event(const Ticks& starttime, MEMFLAGS flag, size_t reserved, size_t committed); + static void send_type_event(const Ticks& starttime, MemTag mem_tag, size_t reserved, size_t committed); public: static void send_total_event(const Ticks& timestamp); static void send_type_events(const Ticks& timestamp); diff --git a/src/hotspot/share/jfr/recorder/checkpoint/types/jfrType.cpp b/src/hotspot/share/jfr/recorder/checkpoint/types/jfrType.cpp index 5cd9e6b253b..63c7a027373 100644 --- a/src/hotspot/share/jfr/recorder/checkpoint/types/jfrType.cpp +++ b/src/hotspot/share/jfr/recorder/checkpoint/types/jfrType.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -332,10 +332,10 @@ void CompilerTypeConstant::serialize(JfrCheckpointWriter& writer) { } void NMTTypeConstant::serialize(JfrCheckpointWriter& writer) { - writer.write_count(mt_number_of_types); - for (int i = 0; i < mt_number_of_types; ++i) { + writer.write_count(mt_number_of_tags); + for (int i = 0; i < mt_number_of_tags; ++i) { writer.write_key(i); - MEMFLAGS flag = NMTUtil::index_to_flag(i); - writer.write(NMTUtil::flag_to_name(flag)); + MemTag mem_tag = NMTUtil::index_to_tag(i); + writer.write(NMTUtil::tag_to_name(mem_tag)); } } diff --git a/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeSet.cpp b/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeSet.cpp index 279b871d818..a53eaa474f3 100644 --- a/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeSet.cpp +++ b/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeSet.cpp @@ -484,6 +484,9 @@ static void do_primitives() { static void do_unloading_klass(Klass* klass) { assert(klass != nullptr, "invariant"); assert(_subsystem_callback != nullptr, "invariant"); + if (klass->is_instance_klass() && InstanceKlass::cast(klass)->is_scratch_class()) { + return; + } if (JfrKlassUnloading::on_unload(klass)) { _subsystem_callback->do_artifact(klass); } diff --git a/src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceIdKlassQueue.cpp b/src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceIdKlassQueue.cpp index 483c18a3e02..30f2afd880c 100644 --- a/src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceIdKlassQueue.cpp +++ b/src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceIdKlassQueue.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,7 +30,6 @@ #include "jfr/support/jfrThreadLocal.hpp" #include "jfr/utilities/jfrEpochQueue.inline.hpp" #include "jfr/utilities/jfrTypes.hpp" -#include "memory/metaspace.hpp" #include "oops/compressedKlass.inline.hpp" #include "utilities/macros.hpp" @@ -75,13 +74,14 @@ static size_t element_size(bool compressed) { return compressed ? NARROW_ELEMENT_SIZE : ELEMENT_SIZE; } -static bool can_compress_element(traceid id) { - return Metaspace::using_class_space() && id < uncompressed_threshold; +static bool can_compress_element(const Klass* klass) { + return CompressedKlassPointers::is_encodable(klass) && + JfrTraceId::load_raw(klass) < uncompressed_threshold; } static size_t element_size(const Klass* klass) { assert(klass != nullptr, "invariant"); - return element_size(can_compress_element(JfrTraceId::load_raw(klass))); + return element_size(can_compress_element(klass)); } static bool is_unloaded(traceid id, bool previous_epoch) { @@ -137,7 +137,8 @@ static inline void store_traceid(JfrEpochQueueNarrowKlassElement* element, trace } static void store_compressed_element(traceid id, const Klass* klass, u1* pos) { - assert(can_compress_element(id), "invariant"); + assert(can_compress_element(klass), "invariant"); + assert(id == JfrTraceId::load_raw(klass), "invariant"); JfrEpochQueueNarrowKlassElement* const element = new (pos) JfrEpochQueueNarrowKlassElement(); store_traceid(element, id); element->compressed_klass = encode(klass); @@ -153,7 +154,7 @@ static void store_element(const Klass* klass, u1* pos) { assert(pos != nullptr, "invariant"); assert(klass != nullptr, "invariant"); const traceid id = JfrTraceId::load_raw(klass); - if (can_compress_element(id)) { + if (can_compress_element(klass)) { store_compressed_element(id, klass, pos); return; } diff --git a/src/hotspot/share/jfr/recorder/service/jfrOptionSet.cpp b/src/hotspot/share/jfr/recorder/service/jfrOptionSet.cpp index 595fcc9c65d..4982e24e898 100644 --- a/src/hotspot/share/jfr/recorder/service/jfrOptionSet.cpp +++ b/src/hotspot/share/jfr/recorder/service/jfrOptionSet.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -208,7 +208,7 @@ static DCmdArgument _dcmd_globalbuffersize( static DCmdArgument _dcmd_numglobalbuffers( "numglobalbuffers", "Number of global buffers", - "JULONG", + "INT", false, default_num_global_buffers); @@ -222,7 +222,7 @@ static DCmdArgument _dcmd_maxchunksize( static DCmdArgument _dcmd_old_object_queue_size ( "old-object-queue-size", "Maximum number of old objects to track", - "JINT", + "INT", false, default_old_object_queue_size); @@ -245,7 +245,7 @@ static DCmdArgument _dcmd_sample_protection( static DCmdArgument _dcmd_stackdepth( "stackdepth", "Stack depth for stacktraces (minimum 1, maximum 2048)", - "JULONG", + "INT", false, default_stack_depth); diff --git a/src/hotspot/share/jfr/recorder/storage/jfrVirtualMemory.cpp b/src/hotspot/share/jfr/recorder/storage/jfrVirtualMemory.cpp index 78309f00913..aaae65ed10d 100644 --- a/src/hotspot/share/jfr/recorder/storage/jfrVirtualMemory.cpp +++ b/src/hotspot/share/jfr/recorder/storage/jfrVirtualMemory.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -117,7 +117,7 @@ bool JfrVirtualMemorySegment::initialize(size_t reservation_size_request_bytes) _rs.base(), _rs.size(), os::vm_page_size()); - MemTracker::record_virtual_memory_type((address)_rs.base(), mtTracing); + MemTracker::record_virtual_memory_tag((address)_rs.base(), mtTracing); assert(is_aligned(_rs.base(), os::vm_page_size()), "invariant"); assert(is_aligned(_rs.size(), os::vm_page_size()), "invariant"); diff --git a/src/hotspot/share/jfr/support/jfrNativeLibraryLoadEvent.cpp b/src/hotspot/share/jfr/support/jfrNativeLibraryLoadEvent.cpp index 920e07eca45..5e80e31a998 100644 --- a/src/hotspot/share/jfr/support/jfrNativeLibraryLoadEvent.cpp +++ b/src/hotspot/share/jfr/support/jfrNativeLibraryLoadEvent.cpp @@ -1,5 +1,5 @@ /* -* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. +* Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -117,6 +117,7 @@ static void commit(const HelperType& helper) { JavaThread* jt = JavaThread::cast(thread); if (jt->thread_state() == _thread_in_native) { // For a JavaThread to take a JFR stacktrace, it must be in _thread_in_vm. Can safepoint here. + MACOS_AARCH64_ONLY(ThreadWXEnable __wx(WXWrite, jt)); ThreadInVMfromNative transition(jt); event.commit(); return; diff --git a/src/hotspot/share/jvmci/jvmciCompiler.cpp b/src/hotspot/share/jvmci/jvmciCompiler.cpp index 2b8684f7ab8..04cdb4b4b4f 100644 --- a/src/hotspot/share/jvmci/jvmciCompiler.cpp +++ b/src/hotspot/share/jvmci/jvmciCompiler.cpp @@ -87,7 +87,7 @@ void JVMCICompiler::bootstrap(TRAPS) { int len = objectMethods->length(); for (int i = 0; i < len; i++) { methodHandle mh(THREAD, objectMethods->at(i)); - if (!mh->is_native() && !mh->is_static() && !mh->is_initializer()) { + if (!mh->is_native() && !mh->is_static() && !mh->is_object_initializer() && !mh->is_static_initializer()) { ResourceMark rm; int hot_count = 10; // TODO: what's the appropriate value? CompileBroker::compile_method(mh, InvocationEntryBci, CompLevel_full_optimization, mh, hot_count, CompileTask::Reason_Bootstrap, CHECK); diff --git a/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp b/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp index d231fbe8a6a..ba1155e6694 100644 --- a/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp +++ b/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp @@ -2178,7 +2178,7 @@ C2V_VMENTRY_NULL(jobjectArray, getDeclaredConstructors, (JNIEnv* env, jobject, A GrowableArray constructors_array; for (int i = 0; i < iklass->methods()->length(); i++) { Method* m = iklass->methods()->at(i); - if (m->is_initializer() && !m->is_static()) { + if (m->is_object_initializer()) { constructors_array.append(m); } } @@ -2205,7 +2205,7 @@ C2V_VMENTRY_NULL(jobjectArray, getDeclaredMethods, (JNIEnv* env, jobject, ARGUME GrowableArray methods_array; for (int i = 0; i < iklass->methods()->length(); i++) { Method* m = iklass->methods()->at(i); - if (!m->is_initializer() && !m->is_overpass()) { + if (!m->is_object_initializer() && !m->is_static_initializer() && !m->is_overpass()) { methods_array.append(m); } } @@ -2921,12 +2921,11 @@ C2V_VMENTRY_NULL(jobject, asReflectionExecutable, (JNIEnv* env, jobject, ARGUMEN requireInHotSpot("asReflectionExecutable", JVMCI_CHECK_NULL); methodHandle m(THREAD, UNPACK_PAIR(Method, method)); oop executable; - if (m->is_initializer()) { - if (m->is_static_initializer()) { - JVMCI_THROW_MSG_NULL(IllegalArgumentException, - "Cannot create java.lang.reflect.Method for class initializer"); - } + if (m->is_object_initializer()) { executable = Reflection::new_constructor(m, CHECK_NULL); + } else if (m->is_static_initializer()) { + JVMCI_THROW_MSG_NULL(IllegalArgumentException, + "Cannot create java.lang.reflect.Method for class initializer"); } else { executable = Reflection::new_method(m, false, CHECK_NULL); } diff --git a/src/hotspot/share/jvmci/jvmciCompilerToVM.hpp b/src/hotspot/share/jvmci/jvmciCompilerToVM.hpp index fa4b1c75c05..0773de6ddba 100644 --- a/src/hotspot/share/jvmci/jvmciCompilerToVM.hpp +++ b/src/hotspot/share/jvmci/jvmciCompilerToVM.hpp @@ -116,6 +116,7 @@ class CompilerToVM { static address dsin; static address dcos; static address dtan; + static address dtanh; static address dexp; static address dlog; static address dlog10; diff --git a/src/hotspot/share/jvmci/jvmciCompilerToVMInit.cpp b/src/hotspot/share/jvmci/jvmciCompilerToVMInit.cpp index 26c88abec0f..1612038008a 100644 --- a/src/hotspot/share/jvmci/jvmciCompilerToVMInit.cpp +++ b/src/hotspot/share/jvmci/jvmciCompilerToVMInit.cpp @@ -135,6 +135,7 @@ int CompilerToVM::Data::sizeof_ZStoreBarrierEntry = sizeof(ZStoreBarrierEntry); address CompilerToVM::Data::dsin; address CompilerToVM::Data::dcos; address CompilerToVM::Data::dtan; +address CompilerToVM::Data::dtanh; address CompilerToVM::Data::dexp; address CompilerToVM::Data::dlog; address CompilerToVM::Data::dlog10; @@ -268,6 +269,19 @@ void CompilerToVM::Data::initialize(JVMCI_TRAPS) { SET_TRIGFUNC(dpow); #undef SET_TRIGFUNC + +#define SET_TRIGFUNC_OR_NULL(name) \ + if (StubRoutines::name() != nullptr) { \ + name = StubRoutines::name(); \ + } else { \ + name = nullptr; \ + } + + SET_TRIGFUNC_OR_NULL(dtanh); + +#undef SET_TRIGFUNC_OR_NULL + + } static jboolean is_c1_supported(vmIntrinsics::ID id){ diff --git a/src/hotspot/share/jvmci/jvmci_globals.cpp b/src/hotspot/share/jvmci/jvmci_globals.cpp index 86d8491b733..2ae38044df0 100644 --- a/src/hotspot/share/jvmci/jvmci_globals.cpp +++ b/src/hotspot/share/jvmci/jvmci_globals.cpp @@ -26,6 +26,7 @@ #include "compiler/compilerDefinitions.hpp" #include "gc/shared/gcConfig.hpp" #include "jvm.h" +#include "jvmci/jvmci.hpp" #include "jvmci/jvmci_globals.hpp" #include "logging/log.hpp" #include "runtime/arguments.hpp" @@ -80,20 +81,25 @@ bool JVMCIGlobals::check_jvmci_flags_are_consistent() { CHECK_NOT_SET(LibJVMCICompilerThreadHidden, UseJVMCICompiler) if (UseJVMCICompiler) { - if (FLAG_IS_DEFAULT(UseJVMCINativeLibrary) && !UseJVMCINativeLibrary) { - char path[JVM_MAXPATHLEN]; - if (os::dll_locate_lib(path, sizeof(path), Arguments::get_dll_dir(), JVMCI_SHARED_LIBRARY_NAME)) { - // If a JVMCI native library is present, - // we enable UseJVMCINativeLibrary by default. - FLAG_SET_DEFAULT(UseJVMCINativeLibrary, true); - } - } if (!FLAG_IS_DEFAULT(EnableJVMCI) && !EnableJVMCI) { jio_fprintf(defaultStream::error_stream(), "Improperly specified VM option UseJVMCICompiler: EnableJVMCI cannot be disabled\n"); return false; } FLAG_SET_DEFAULT(EnableJVMCI, true); + } + + if (EnableJVMCI) { + if (FLAG_IS_DEFAULT(UseJVMCINativeLibrary) && !UseJVMCINativeLibrary) { + if (JVMCI::shared_library_exists()) { + // If a JVMCI native library is present, + // we enable UseJVMCINativeLibrary by default. + FLAG_SET_DEFAULT(UseJVMCINativeLibrary, true); + } + } + } + + if (UseJVMCICompiler) { if (BootstrapJVMCI && UseJVMCINativeLibrary) { jio_fprintf(defaultStream::error_stream(), "-XX:+BootstrapJVMCI is not compatible with -XX:+UseJVMCINativeLibrary\n"); return false; diff --git a/src/hotspot/share/jvmci/jvmci_globals.hpp b/src/hotspot/share/jvmci/jvmci_globals.hpp index 1f2c0c647ab..4da49b24e6e 100644 --- a/src/hotspot/share/jvmci/jvmci_globals.hpp +++ b/src/hotspot/share/jvmci/jvmci_globals.hpp @@ -45,7 +45,7 @@ class fileStream; constraint) \ \ product(bool, EnableJVMCI, false, EXPERIMENTAL, \ - "Enable JVMCI") \ + "Enable JVMCI. Defaults to true if UseJVMCICompiler is true.") \ \ product(bool, UseGraalJIT, false, EXPERIMENTAL, \ "Select the Graal JVMCI compiler. This is an alias for: " \ @@ -140,12 +140,14 @@ class fileStream; product(bool, UseJVMCINativeLibrary, false, EXPERIMENTAL, \ "Execute JVMCI Java code from a shared library (\"libjvmci\") " \ "instead of loading it from class files and executing it " \ - "on the HotSpot heap. Defaults to true if EnableJVMCIProduct is " \ - "true and a JVMCI native library is available.") \ + "on the HotSpot heap. Defaults to true if UseJVMCICompiler or " \ + "EnableJVMCI is true and a JVMCI native library is available.") \ \ - product(double, JVMCINativeLibraryThreadFraction, 0.33, EXPERIMENTAL, \ + product(double, JVMCINativeLibraryThreadFraction, 0.66, EXPERIMENTAL, \ "The fraction of compiler threads used by libjvmci. " \ - "The remaining compiler threads are used by C1.") \ + "The remaining compiler threads are used by C1. " \ + "Reducing this value could reduce the max RSS but " \ + "also increase the warmup time.") \ range(0.0, 1.0) \ \ product(ccstr, JVMCINativeLibraryErrorFile, nullptr, EXPERIMENTAL, \ diff --git a/src/hotspot/share/jvmci/vmStructs_jvmci.cpp b/src/hotspot/share/jvmci/vmStructs_jvmci.cpp index 1526f81295b..05081197c4b 100644 --- a/src/hotspot/share/jvmci/vmStructs_jvmci.cpp +++ b/src/hotspot/share/jvmci/vmStructs_jvmci.cpp @@ -38,6 +38,7 @@ #include "runtime/continuationEntry.hpp" #include "runtime/deoptimization.hpp" #include "runtime/flags/jvmFlag.hpp" +#include "runtime/objectMonitor.hpp" #include "runtime/osThread.hpp" #include "runtime/sharedRuntime.hpp" #include "runtime/stubRoutines.hpp" @@ -240,12 +241,12 @@ nonstatic_field(JavaThread, _jvmci_reserved_oop0, oop) \ nonstatic_field(JavaThread, _should_post_on_exceptions_flag, int) \ nonstatic_field(JavaThread, _jni_environment, JNIEnv) \ - nonstatic_field(JavaThread, _poll_data, SafepointMechanism::ThreadData) \ nonstatic_field(JavaThread, _stack_overflow_state._reserved_stack_activation, address) \ nonstatic_field(JavaThread, _held_monitor_count, intx) \ nonstatic_field(JavaThread, _lock_stack, LockStack) \ nonstatic_field(JavaThread, _om_cache, OMCache) \ nonstatic_field(JavaThread, _cont_entry, ContinuationEntry*) \ + nonstatic_field(JavaThread, _unlocked_inflated_monitor, ObjectMonitor*) \ JVMTI_ONLY(nonstatic_field(JavaThread, _is_in_VTMS_transition, bool)) \ JVMTI_ONLY(nonstatic_field(JavaThread, _is_in_tmp_VTMS_transition, bool)) \ JVMTI_ONLY(nonstatic_field(JavaThread, _is_disable_suspend, bool)) \ @@ -274,6 +275,7 @@ nonstatic_field(Klass, _class_loader_data, ClassLoaderData*) \ nonstatic_field(Klass, _bitmap, uintx) \ nonstatic_field(Klass, _hash_slot, uint8_t) \ + nonstatic_field(Klass, _misc_flags._flags, u1) \ \ nonstatic_field(LocalVariableTableElement, start_bci, u2) \ nonstatic_field(LocalVariableTableElement, length, u2) \ @@ -406,6 +408,7 @@ static_field(StubRoutines, _cont_thaw, address) \ static_field(StubRoutines, _lookup_secondary_supers_table_slow_path_stub, address) \ \ + nonstatic_field(Thread, _poll_data, SafepointMechanism::ThreadData) \ nonstatic_field(Thread, _tlab, ThreadLocalAllocBuffer) \ nonstatic_field(Thread, _allocated_bytes, jlong) \ JFR_ONLY(nonstatic_field(Thread, _jfr_thread_local, JfrThreadLocal)) \ @@ -482,10 +485,6 @@ declare_constant(JVMCINMethodData::SPECULATION_LENGTH_BITS) \ \ declare_constant(JVM_ACC_WRITTEN_FLAGS) \ - declare_constant(JVM_ACC_HAS_FINALIZER) \ - declare_constant(JVM_ACC_IS_CLONEABLE_FAST) \ - declare_constant(JVM_ACC_IS_HIDDEN_CLASS) \ - declare_constant(JVM_ACC_IS_VALUE_BASED_CLASS) \ declare_constant(FieldInfo::FieldFlags::_ff_injected) \ declare_constant(FieldInfo::FieldFlags::_ff_stable) \ declare_preprocessor_constant("JVM_ACC_VARARGS", JVM_ACC_VARARGS) \ @@ -733,6 +732,10 @@ \ declare_constant(InstanceKlassFlags::_misc_has_nonstatic_concrete_methods) \ declare_constant(InstanceKlassFlags::_misc_declares_nonstatic_concrete_methods) \ + declare_constant(KlassFlags::_misc_is_hidden_class) \ + declare_constant(KlassFlags::_misc_is_value_based_class) \ + declare_constant(KlassFlags::_misc_has_finalizer) \ + declare_constant(KlassFlags::_misc_is_cloneable_fast) \ \ declare_constant(JumpData::taken_off_set) \ declare_constant(JumpData::displacement_off_set) \ diff --git a/src/hotspot/share/logging/logSelection.cpp b/src/hotspot/share/logging/logSelection.cpp index aea5719b36d..1e7ba3a8878 100644 --- a/src/hotspot/share/logging/logSelection.cpp +++ b/src/hotspot/share/logging/logSelection.cpp @@ -33,11 +33,11 @@ const LogSelection LogSelection::Invalid; -LogSelection::LogSelection() : _ntags(0), _wildcard(false), _level(LogLevel::Invalid), _tag_sets_selected(0) { +LogSelection::LogSelection() : _ntags(0), _tags(), _wildcard(false), _level(LogLevel::Invalid), _tag_sets_selected(0) { } LogSelection::LogSelection(const LogTagType tags[LogTag::MaxTags], bool wildcard, LogLevelType level) - : _ntags(0), _wildcard(wildcard), _level(level), _tag_sets_selected(0) { + : _ntags(0), _tags(), _wildcard(wildcard), _level(level), _tag_sets_selected(0) { while (_ntags < LogTag::MaxTags && tags[_ntags] != LogTag::__NO_TAG) { _tags[_ntags] = tags[_ntags]; _ntags++; diff --git a/src/hotspot/share/memory/allocation.cpp b/src/hotspot/share/memory/allocation.cpp index 0f2ff7840b8..096ee696421 100644 --- a/src/hotspot/share/memory/allocation.cpp +++ b/src/hotspot/share/memory/allocation.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,10 +36,10 @@ // allocate using malloc; will fail if no memory available char* AllocateHeap(size_t size, - MEMFLAGS flags, + MemTag mem_tag, const NativeCallStack& stack, AllocFailType alloc_failmode /* = AllocFailStrategy::EXIT_OOM*/) { - char* p = (char*) os::malloc(size, flags, stack); + char* p = (char*) os::malloc(size, mem_tag, stack); if (p == nullptr && alloc_failmode == AllocFailStrategy::EXIT_OOM) { vm_exit_out_of_memory(size, OOM_MALLOC_ERROR, "AllocateHeap"); } @@ -47,16 +47,16 @@ char* AllocateHeap(size_t size, } char* AllocateHeap(size_t size, - MEMFLAGS flags, + MemTag mem_tag, AllocFailType alloc_failmode /* = AllocFailStrategy::EXIT_OOM*/) { - return AllocateHeap(size, flags, CALLER_PC, alloc_failmode); + return AllocateHeap(size, mem_tag, CALLER_PC, alloc_failmode); } char* ReallocateHeap(char *old, size_t size, - MEMFLAGS flag, + MemTag mem_tag, AllocFailType alloc_failmode) { - char* p = (char*) os::realloc(old, size, flag, CALLER_PC); + char* p = (char*) os::realloc(old, size, mem_tag, CALLER_PC); if (p == nullptr && alloc_failmode == AllocFailStrategy::EXIT_OOM) { vm_exit_out_of_memory(size, OOM_MALLOC_ERROR, "ReallocateHeap"); } @@ -75,14 +75,16 @@ void* MetaspaceObj::operator new(size_t size, ClassLoaderData* loader_data, size_t word_size, MetaspaceObj::Type type, TRAPS) throw() { // Klass has its own operator new - return Metaspace::allocate(loader_data, word_size, type, THREAD); + assert(type != ClassType, "class has its own operator new"); + return Metaspace::allocate(loader_data, word_size, type, /*use_class_space*/ false, THREAD); } void* MetaspaceObj::operator new(size_t size, ClassLoaderData* loader_data, size_t word_size, MetaspaceObj::Type type) throw() { assert(!Thread::current()->is_Java_thread(), "only allowed by non-Java thread"); - return Metaspace::allocate(loader_data, word_size, type); + assert(type != ClassType, "class has its own operator new"); + return Metaspace::allocate(loader_data, word_size, type, /*use_class_space*/ false); } bool MetaspaceObj::is_valid(const MetaspaceObj* p) { @@ -117,16 +119,16 @@ void* AnyObj::operator new(size_t size, Arena *arena) { return res; } -void* AnyObj::operator new(size_t size, MEMFLAGS flags) throw() { - address res = (address)AllocateHeap(size, flags, CALLER_PC); +void* AnyObj::operator new(size_t size, MemTag mem_tag) throw() { + address res = (address)AllocateHeap(size, mem_tag, CALLER_PC); DEBUG_ONLY(set_allocation_type(res, C_HEAP);) return res; } void* AnyObj::operator new(size_t size, const std::nothrow_t& nothrow_constant, - MEMFLAGS flags) throw() { + MemTag mem_tag) throw() { // should only call this with std::nothrow, use other operator new() otherwise - address res = (address)AllocateHeap(size, flags, CALLER_PC, AllocFailStrategy::RETURN_NULL); + address res = (address)AllocateHeap(size, mem_tag, CALLER_PC, AllocFailStrategy::RETURN_NULL); DEBUG_ONLY(if (res!= nullptr) set_allocation_type(res, C_HEAP);) return res; } diff --git a/src/hotspot/share/memory/allocation.hpp b/src/hotspot/share/memory/allocation.hpp index da5f7b19830..9841ce3183c 100644 --- a/src/hotspot/share/memory/allocation.hpp +++ b/src/hotspot/share/memory/allocation.hpp @@ -26,7 +26,7 @@ #define SHARE_MEMORY_ALLOCATION_HPP #include "memory/allStatic.hpp" -#include "nmt/memflags.hpp" +#include "nmt/memTag.hpp" #include "utilities/debug.hpp" #include "utilities/globalDefinitions.hpp" #include "utilities/macros.hpp" @@ -94,9 +94,9 @@ typedef AllocFailStrategy::AllocFailEnum AllocFailType; // NEW_C_HEAP_OBJ* // FREE_C_HEAP_OBJ // -// char* AllocateHeap(size_t size, MEMFLAGS flags, const NativeCallStack& stack, AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM); -// char* AllocateHeap(size_t size, MEMFLAGS flags, AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM); -// char* ReallocateHeap(char *old, size_t size, MEMFLAGS flag, AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM); +// char* AllocateHeap(size_t size, MemTag mem_tag, const NativeCallStack& stack, AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM); +// char* AllocateHeap(size_t size, MemTag mem_tag, AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM); +// char* ReallocateHeap(char *old, size_t size, MemTag mem_tag, AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM); // void FreeHeap(void* p); // @@ -106,16 +106,16 @@ class NativeCallStack; char* AllocateHeap(size_t size, - MEMFLAGS flags, + MemTag mem_tag, const NativeCallStack& stack, AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM); char* AllocateHeap(size_t size, - MEMFLAGS flags, + MemTag mem_tag, AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM); char* ReallocateHeap(char *old, size_t size, - MEMFLAGS flag, + MemTag mem_tag, AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM); // handles null pointers @@ -123,50 +123,50 @@ void FreeHeap(void* p); class CHeapObjBase { public: - ALWAYSINLINE void* operator new(size_t size, MEMFLAGS f) { - return AllocateHeap(size, f); + ALWAYSINLINE void* operator new(size_t size, MemTag mem_tag) { + return AllocateHeap(size, mem_tag); } ALWAYSINLINE void* operator new(size_t size, - MEMFLAGS f, + MemTag mem_tag, const NativeCallStack& stack) { - return AllocateHeap(size, f, stack); + return AllocateHeap(size, mem_tag, stack); } ALWAYSINLINE void* operator new(size_t size, - MEMFLAGS f, + MemTag mem_tag, const std::nothrow_t&, const NativeCallStack& stack) throw() { - return AllocateHeap(size, f, stack, AllocFailStrategy::RETURN_NULL); + return AllocateHeap(size, mem_tag, stack, AllocFailStrategy::RETURN_NULL); } ALWAYSINLINE void* operator new(size_t size, - MEMFLAGS f, + MemTag mem_tag, const std::nothrow_t&) throw() { - return AllocateHeap(size, f, AllocFailStrategy::RETURN_NULL); + return AllocateHeap(size, mem_tag, AllocFailStrategy::RETURN_NULL); } - ALWAYSINLINE void* operator new[](size_t size, MEMFLAGS f) { - return AllocateHeap(size, f); + ALWAYSINLINE void* operator new[](size_t size, MemTag mem_tag) { + return AllocateHeap(size, mem_tag); } ALWAYSINLINE void* operator new[](size_t size, - MEMFLAGS f, + MemTag mem_tag, const NativeCallStack& stack) { - return AllocateHeap(size, f, stack); + return AllocateHeap(size, mem_tag, stack); } ALWAYSINLINE void* operator new[](size_t size, - MEMFLAGS f, + MemTag mem_tag, const std::nothrow_t&, const NativeCallStack& stack) throw() { - return AllocateHeap(size, f, stack, AllocFailStrategy::RETURN_NULL); + return AllocateHeap(size, mem_tag, stack, AllocFailStrategy::RETURN_NULL); } ALWAYSINLINE void* operator new[](size_t size, - MEMFLAGS f, + MemTag mem_tag, const std::nothrow_t&) throw() { - return AllocateHeap(size, f, AllocFailStrategy::RETURN_NULL); + return AllocateHeap(size, mem_tag, AllocFailStrategy::RETURN_NULL); } void operator delete(void* p) { FreeHeap(p); } @@ -174,43 +174,43 @@ class CHeapObjBase { }; // Uses the implicitly static new and delete operators of CHeapObjBase -template +template class CHeapObj { public: ALWAYSINLINE void* operator new(size_t size) { - return CHeapObjBase::operator new(size, F); + return CHeapObjBase::operator new(size, MT); } ALWAYSINLINE void* operator new(size_t size, const NativeCallStack& stack) { - return CHeapObjBase::operator new(size, F, stack); + return CHeapObjBase::operator new(size, MT, stack); } ALWAYSINLINE void* operator new(size_t size, const std::nothrow_t& nt, const NativeCallStack& stack) throw() { - return CHeapObjBase::operator new(size, F, nt, stack); + return CHeapObjBase::operator new(size, MT, nt, stack); } ALWAYSINLINE void* operator new(size_t size, const std::nothrow_t& nt) throw() { - return CHeapObjBase::operator new(size, F, nt); + return CHeapObjBase::operator new(size, MT, nt); } ALWAYSINLINE void* operator new[](size_t size) { - return CHeapObjBase::operator new[](size, F); + return CHeapObjBase::operator new[](size, MT); } ALWAYSINLINE void* operator new[](size_t size, const NativeCallStack& stack) { - return CHeapObjBase::operator new[](size, F, stack); + return CHeapObjBase::operator new[](size, MT, stack); } ALWAYSINLINE void* operator new[](size_t size, const std::nothrow_t& nt, const NativeCallStack& stack) throw() { - return CHeapObjBase::operator new[](size, F, nt, stack); + return CHeapObjBase::operator new[](size, MT, nt, stack); } ALWAYSINLINE void* operator new[](size_t size, const std::nothrow_t& nt) throw() { - return CHeapObjBase::operator new[](size, F, nt); + return CHeapObjBase::operator new[](size, MT, nt); } void operator delete(void* p) { @@ -439,10 +439,10 @@ protected: public: // CHeap allocations - void* operator new(size_t size, MEMFLAGS flags) throw(); - void* operator new [](size_t size, MEMFLAGS flags) throw() = delete; - void* operator new(size_t size, const std::nothrow_t& nothrow_constant, MEMFLAGS flags) throw(); - void* operator new [](size_t size, const std::nothrow_t& nothrow_constant, MEMFLAGS flags) throw() = delete; + void* operator new(size_t size, MemTag mem_tag) throw(); + void* operator new [](size_t size, MemTag mem_tag) throw() = delete; + void* operator new(size_t size, const std::nothrow_t& nothrow_constant, MemTag mem_tag) throw(); + void* operator new [](size_t size, const std::nothrow_t& nothrow_constant, MemTag mem_tag) throw() = delete; // Arena allocations void* operator new(size_t size, Arena *arena); @@ -510,36 +510,36 @@ protected: #define NEW_RESOURCE_OBJ_RETURN_NULL(type)\ NEW_RESOURCE_ARRAY_RETURN_NULL(type, 1) -#define NEW_C_HEAP_ARRAY3(type, size, memflags, pc, allocfail)\ - (type*) AllocateHeap((size) * sizeof(type), memflags, pc, allocfail) +#define NEW_C_HEAP_ARRAY3(type, size, mem_tag, pc, allocfail)\ + (type*) AllocateHeap((size) * sizeof(type), mem_tag, pc, allocfail) -#define NEW_C_HEAP_ARRAY2(type, size, memflags, pc)\ - (type*) (AllocateHeap((size) * sizeof(type), memflags, pc)) +#define NEW_C_HEAP_ARRAY2(type, size, mem_tag, pc)\ + (type*) (AllocateHeap((size) * sizeof(type), mem_tag, pc)) -#define NEW_C_HEAP_ARRAY(type, size, memflags)\ - (type*) (AllocateHeap((size) * sizeof(type), memflags)) +#define NEW_C_HEAP_ARRAY(type, size, mem_tag)\ + (type*) (AllocateHeap((size) * sizeof(type), mem_tag)) -#define NEW_C_HEAP_ARRAY2_RETURN_NULL(type, size, memflags, pc)\ - NEW_C_HEAP_ARRAY3(type, (size), memflags, pc, AllocFailStrategy::RETURN_NULL) +#define NEW_C_HEAP_ARRAY2_RETURN_NULL(type, size, mem_tag, pc)\ + NEW_C_HEAP_ARRAY3(type, (size), mem_tag, pc, AllocFailStrategy::RETURN_NULL) -#define NEW_C_HEAP_ARRAY_RETURN_NULL(type, size, memflags)\ - NEW_C_HEAP_ARRAY2(type, (size), memflags, AllocFailStrategy::RETURN_NULL) +#define NEW_C_HEAP_ARRAY_RETURN_NULL(type, size, mem_tag)\ + NEW_C_HEAP_ARRAY2(type, (size), mem_tag, AllocFailStrategy::RETURN_NULL) -#define REALLOC_C_HEAP_ARRAY(type, old, size, memflags)\ - (type*) (ReallocateHeap((char*)(old), (size) * sizeof(type), memflags)) +#define REALLOC_C_HEAP_ARRAY(type, old, size, mem_tag)\ + (type*) (ReallocateHeap((char*)(old), (size) * sizeof(type), mem_tag)) -#define REALLOC_C_HEAP_ARRAY_RETURN_NULL(type, old, size, memflags)\ - (type*) (ReallocateHeap((char*)(old), (size) * sizeof(type), memflags, AllocFailStrategy::RETURN_NULL)) +#define REALLOC_C_HEAP_ARRAY_RETURN_NULL(type, old, size, mem_tag)\ + (type*) (ReallocateHeap((char*)(old), (size) * sizeof(type), mem_tag, AllocFailStrategy::RETURN_NULL)) #define FREE_C_HEAP_ARRAY(type, old) \ FreeHeap((char*)(old)) // allocate type in heap without calling ctor -#define NEW_C_HEAP_OBJ(type, memflags)\ - NEW_C_HEAP_ARRAY(type, 1, memflags) +#define NEW_C_HEAP_OBJ(type, mem_tag)\ + NEW_C_HEAP_ARRAY(type, 1, mem_tag) -#define NEW_C_HEAP_OBJ_RETURN_NULL(type, memflags)\ - NEW_C_HEAP_ARRAY_RETURN_NULL(type, 1, memflags) +#define NEW_C_HEAP_OBJ_RETURN_NULL(type, mem_tag)\ + NEW_C_HEAP_ARRAY_RETURN_NULL(type, 1, mem_tag) // deallocate obj of type in heap without calling dtor #define FREE_C_HEAP_OBJ(objname)\ @@ -568,8 +568,8 @@ class MmapArrayAllocator : public AllStatic { static size_t size_for(size_t length); public: - static E* allocate_or_null(size_t length, MEMFLAGS flags); - static E* allocate(size_t length, MEMFLAGS flags); + static E* allocate_or_null(size_t length, MemTag mem_tag); + static E* allocate(size_t length, MemTag mem_tag); static void free(E* addr, size_t length); }; @@ -579,8 +579,8 @@ class MallocArrayAllocator : public AllStatic { public: static size_t size_for(size_t length); - static E* allocate(size_t length, MEMFLAGS flags); - static E* reallocate(E* addr, size_t new_length, MEMFLAGS flags); + static E* allocate(size_t length, MemTag mem_tag); + static E* reallocate(E* addr, size_t new_length, MemTag mem_tag); static void free(E* addr); }; diff --git a/src/hotspot/share/memory/allocation.inline.hpp b/src/hotspot/share/memory/allocation.inline.hpp index 4a1b0b0c597..8d531c6dd23 100644 --- a/src/hotspot/share/memory/allocation.inline.hpp +++ b/src/hotspot/share/memory/allocation.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -55,10 +55,10 @@ size_t MmapArrayAllocator::size_for(size_t length) { } template -E* MmapArrayAllocator::allocate_or_null(size_t length, MEMFLAGS flags) { +E* MmapArrayAllocator::allocate_or_null(size_t length, MemTag mem_tag) { size_t size = size_for(length); - char* addr = os::reserve_memory(size, !ExecMem, flags); + char* addr = os::reserve_memory(size, !ExecMem, mem_tag); if (addr == nullptr) { return nullptr; } @@ -72,10 +72,10 @@ E* MmapArrayAllocator::allocate_or_null(size_t length, MEMFLAGS flags) { } template -E* MmapArrayAllocator::allocate(size_t length, MEMFLAGS flags) { +E* MmapArrayAllocator::allocate(size_t length, MemTag mem_tag) { size_t size = size_for(length); - char* addr = os::reserve_memory(size, !ExecMem, flags); + char* addr = os::reserve_memory(size, !ExecMem, mem_tag); if (addr == nullptr) { vm_exit_out_of_memory(size, OOM_MMAP_ERROR, "Allocator (reserve)"); } @@ -97,13 +97,13 @@ size_t MallocArrayAllocator::size_for(size_t length) { } template -E* MallocArrayAllocator::allocate(size_t length, MEMFLAGS flags) { - return (E*)AllocateHeap(size_for(length), flags); +E* MallocArrayAllocator::allocate(size_t length, MemTag mem_tag) { + return (E*)AllocateHeap(size_for(length), mem_tag); } template -E* MallocArrayAllocator::reallocate(E* addr, size_t new_length, MEMFLAGS flags) { - return (E*)ReallocateHeap((char*)addr, size_for(new_length), flags); +E* MallocArrayAllocator::reallocate(E* addr, size_t new_length, MemTag mem_tag) { + return (E*)ReallocateHeap((char*)addr, size_for(new_length), mem_tag); } template diff --git a/src/hotspot/share/memory/arena.cpp b/src/hotspot/share/memory/arena.cpp index 435a8cfdd58..51d7cda9c61 100644 --- a/src/hotspot/share/memory/arena.cpp +++ b/src/hotspot/share/memory/arena.cpp @@ -222,8 +222,8 @@ void Chunk::next_chop(Chunk* k) { k->_next = nullptr; } -Arena::Arena(MEMFLAGS flag, Tag tag, size_t init_size) : - _flags(flag), _tag(tag), +Arena::Arena(MemTag mem_tag, Tag tag, size_t init_size) : + _mem_tag(mem_tag), _tag(tag), _size_in_bytes(0), _first(nullptr), _chunk(nullptr), _hwm(nullptr), _max(nullptr) @@ -233,13 +233,13 @@ Arena::Arena(MEMFLAGS flag, Tag tag, size_t init_size) : _first = _chunk; _hwm = _chunk->bottom(); // Save the cached hwm, max _max = _chunk->top(); - MemTracker::record_new_arena(flag); + MemTracker::record_new_arena(mem_tag); set_size_in_bytes(init_size); } Arena::~Arena() { destruct_contents(); - MemTracker::record_arena_free(_flags); + MemTracker::record_arena_free(_mem_tag); } // Destroy this arenas contents and reset to empty @@ -259,8 +259,8 @@ void Arena::set_size_in_bytes(size_t size) { if (_size_in_bytes != size) { ssize_t delta = size - size_in_bytes(); _size_in_bytes = size; - MemTracker::record_arena_size_change(delta, _flags); - if (CompilationMemoryStatistic::enabled() && _flags == mtCompiler) { + MemTracker::record_arena_size_change(delta, _mem_tag); + if (CompilationMemoryStatistic::enabled() && _mem_tag == mtCompiler) { Thread* const t = Thread::current(); if (t != nullptr && t->is_Compiler_thread()) { CompilationMemoryStatistic::on_arena_change(delta, this); @@ -286,7 +286,7 @@ void* Arena::grow(size_t x, AllocFailType alloc_failmode) { // (Note: all chunk sizes have to be 64-bit aligned) size_t len = MAX2(ARENA_ALIGN(x), (size_t) Chunk::size); - if (MemTracker::check_exceeds_limit(x, _flags)) { + if (MemTracker::check_exceeds_limit(x, _mem_tag)) { return nullptr; } @@ -311,8 +311,6 @@ void* Arena::grow(size_t x, AllocFailType alloc_failmode) { return result; } - - // Reallocate storage in Arena. void *Arena::Arealloc(void* old_ptr, size_t old_size, size_t new_size, AllocFailType alloc_failmode) { if (new_size == 0) { @@ -324,21 +322,21 @@ void *Arena::Arealloc(void* old_ptr, size_t old_size, size_t new_size, AllocFail return Amalloc(new_size, alloc_failmode); // as with realloc(3), a null old ptr is equivalent to malloc(3) } char *c_old = (char*)old_ptr; // Handy name - // Stupid fast special case - if( new_size <= old_size ) { // Shrink in-place - if( c_old+old_size == _hwm) // Attempt to free the excess bytes - _hwm = c_old+new_size; // Adjust hwm - return c_old; - } - // make sure that new_size is legal + // Make sure that new_size is legal size_t corrected_new_size = ARENA_ALIGN(new_size); - // See if we can resize in-place - if( (c_old+old_size == _hwm) && // Adjusting recent thing - (c_old+corrected_new_size <= _max) ) { // Still fits where it sits - _hwm = c_old+corrected_new_size; // Adjust hwm - return c_old; // Return old pointer + // Reallocating the latest allocation? + if (c_old + old_size == _hwm) { + assert(_chunk->bottom() <= c_old, "invariant"); + + // Reallocate in place if it fits. Also handles shrinking + if (pointer_delta(_max, c_old, 1) >= corrected_new_size) { + _hwm = c_old + corrected_new_size; + return c_old; + } + } else if (new_size <= old_size) { // Shrink in place + return c_old; } // Oops, got to relocate guts diff --git a/src/hotspot/share/memory/arena.hpp b/src/hotspot/share/memory/arena.hpp index 1f3c5eb4e8b..5f0def2a655 100644 --- a/src/hotspot/share/memory/arena.hpp +++ b/src/hotspot/share/memory/arena.hpp @@ -107,7 +107,7 @@ public: static const char* tag_desc[static_cast(Arena::Tag::tag_count)]; private: - const MEMFLAGS _flags; // Memory tracking flags + const MemTag _mem_tag; // Native Memory Tracking tag const Tag _tag; size_t _size_in_bytes; // Size of arena (used for native memory tracking) @@ -138,7 +138,7 @@ protected: public: // Start the chunk_pool cleaner task static void start_chunk_pool_cleaner_task(); - Arena(MEMFLAGS memflag, Tag tag = Tag::tag_other, size_t init_size = Chunk::init_size); + Arena(MemTag mem_tag, Tag tag = Tag::tag_other, size_t init_size = Chunk::init_size); ~Arena(); void destruct_contents(); char* hwm() const { return _hwm; } diff --git a/src/hotspot/share/memory/guardedMemory.cpp b/src/hotspot/share/memory/guardedMemory.cpp index 7b676d72588..12ffde3cc1b 100644 --- a/src/hotspot/share/memory/guardedMemory.cpp +++ b/src/hotspot/share/memory/guardedMemory.cpp @@ -23,7 +23,7 @@ */ #include "precompiled.hpp" #include "memory/guardedMemory.hpp" -#include "nmt/memflags.hpp" +#include "nmt/memTag.hpp" #include "runtime/os.hpp" void* GuardedMemory::wrap_copy(const void* ptr, const size_t len, const void* tag) { diff --git a/src/hotspot/share/memory/heap.cpp b/src/hotspot/share/memory/heap.cpp index 98e59f58184..658ec3e8de7 100644 --- a/src/hotspot/share/memory/heap.cpp +++ b/src/hotspot/share/memory/heap.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -232,7 +232,7 @@ bool CodeHeap::reserve(ReservedSpace rs, size_t committed_size, size_t segment_s return false; } - MemTracker::record_virtual_memory_type((address)_segmap.low_boundary(), mtCode); + MemTracker::record_virtual_memory_tag((address)_segmap.low_boundary(), mtCode); assert(_segmap.committed_size() >= (size_t) _number_of_committed_segments, "could not commit enough space for segment map"); assert(_segmap.reserved_size() >= (size_t) _number_of_reserved_segments , "could not reserve enough space for segment map"); diff --git a/src/hotspot/share/memory/memRegion.cpp b/src/hotspot/share/memory/memRegion.cpp index 7dd7e1be4ab..d6565b00324 100644 --- a/src/hotspot/share/memory/memRegion.cpp +++ b/src/hotspot/share/memory/memRegion.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -102,8 +102,8 @@ MemRegion MemRegion::minus(const MemRegion mr2) const { return MemRegion(); } -MemRegion* MemRegion::create_array(size_t length, MEMFLAGS flags) { - MemRegion* result = NEW_C_HEAP_ARRAY(MemRegion, length, flags); +MemRegion* MemRegion::create_array(size_t length, MemTag mem_tag) { + MemRegion* result = NEW_C_HEAP_ARRAY(MemRegion, length, mem_tag); for (size_t i = 0; i < length; i++) { ::new (&result[i]) MemRegion(); } diff --git a/src/hotspot/share/memory/memRegion.hpp b/src/hotspot/share/memory/memRegion.hpp index 5d3d635c650..920efe75288 100644 --- a/src/hotspot/share/memory/memRegion.hpp +++ b/src/hotspot/share/memory/memRegion.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -90,7 +90,7 @@ public: bool is_empty() const { return word_size() == 0; } // Creates and initializes an array of MemRegions of the given length. - static MemRegion* create_array(size_t length, MEMFLAGS flags); + static MemRegion* create_array(size_t length, MemTag mem_tag); static void destroy_array(MemRegion* array, size_t length); }; diff --git a/src/hotspot/share/memory/metaspace.cpp b/src/hotspot/share/memory/metaspace.cpp index 9b3b36f8be0..f86be4774d5 100644 --- a/src/hotspot/share/memory/metaspace.cpp +++ b/src/hotspot/share/memory/metaspace.cpp @@ -772,7 +772,7 @@ void Metaspace::global_initialize() { } // Mark class space as such - MemTracker::record_virtual_memory_type((address)rs.base(), mtClass); + MemTracker::record_virtual_memory_tag((address)rs.base(), mtClass); // Initialize space Metaspace::initialize_class_space(rs); @@ -830,7 +830,7 @@ size_t Metaspace::max_allocation_word_size() { // is suitable for calling from non-Java threads. // Callers are responsible for checking null. MetaWord* Metaspace::allocate(ClassLoaderData* loader_data, size_t word_size, - MetaspaceObj::Type type) { + MetaspaceObj::Type type, bool use_class_space) { assert(word_size <= Metaspace::max_allocation_word_size(), "allocation size too large (" SIZE_FORMAT ")", word_size); @@ -840,7 +840,7 @@ MetaWord* Metaspace::allocate(ClassLoaderData* loader_data, size_t word_size, // Deal with concurrent unloading failed allocation starvation MetaspaceCriticalAllocation::block_if_concurrent_purge(); - MetadataType mdtype = (type == MetaspaceObj::ClassType) ? ClassType : NonClassType; + MetadataType mdtype = use_class_space ? ClassType : NonClassType; // Try to allocate metadata. MetaWord* result = loader_data->metaspace_non_null()->allocate(word_size, mdtype); @@ -856,7 +856,7 @@ MetaWord* Metaspace::allocate(ClassLoaderData* loader_data, size_t word_size, } MetaWord* Metaspace::allocate(ClassLoaderData* loader_data, size_t word_size, - MetaspaceObj::Type type, TRAPS) { + MetaspaceObj::Type type, bool use_class_space, TRAPS) { if (HAS_PENDING_EXCEPTION) { assert(false, "Should not allocate with exception pending"); @@ -864,10 +864,10 @@ MetaWord* Metaspace::allocate(ClassLoaderData* loader_data, size_t word_size, } assert(!THREAD->owns_locks(), "allocating metaspace while holding mutex"); - MetaWord* result = allocate(loader_data, word_size, type); + MetaWord* result = allocate(loader_data, word_size, type, use_class_space); if (result == nullptr) { - MetadataType mdtype = (type == MetaspaceObj::ClassType) ? ClassType : NonClassType; + MetadataType mdtype = use_class_space ? ClassType : NonClassType; tracer()->report_metaspace_allocation_failure(loader_data, word_size, type, mdtype); // Allocation failed. diff --git a/src/hotspot/share/memory/metaspace.hpp b/src/hotspot/share/memory/metaspace.hpp index 6de901b25d1..fc405a389ee 100644 --- a/src/hotspot/share/memory/metaspace.hpp +++ b/src/hotspot/share/memory/metaspace.hpp @@ -110,12 +110,12 @@ public: static size_t max_allocation_word_size(); static MetaWord* allocate(ClassLoaderData* loader_data, size_t word_size, - MetaspaceObj::Type type, TRAPS); + MetaspaceObj::Type type, bool use_class_space, TRAPS); // Non-TRAPS version of allocate which can be called by a non-Java thread, that returns // null on failure. static MetaWord* allocate(ClassLoaderData* loader_data, size_t word_size, - MetaspaceObj::Type type); + MetaspaceObj::Type type, bool use_class_space); // Returns true if the pointer points into class space, non-class metaspace, or the // metadata portion of the CDS archive. diff --git a/src/hotspot/share/memory/metaspace/virtualSpaceNode.cpp b/src/hotspot/share/memory/metaspace/virtualSpaceNode.cpp index a8afbc130c9..83a591e4cad 100644 --- a/src/hotspot/share/memory/metaspace/virtualSpaceNode.cpp +++ b/src/hotspot/share/memory/metaspace/virtualSpaceNode.cpp @@ -259,7 +259,7 @@ VirtualSpaceNode* VirtualSpaceNode::create_node(size_t word_size, if (!rs.is_reserved()) { vm_exit_out_of_memory(word_size * BytesPerWord, OOM_MMAP_ERROR, "Failed to reserve memory for metaspace"); } - MemTracker::record_virtual_memory_type(rs.base(), mtMetaspace); + MemTracker::record_virtual_memory_tag(rs.base(), mtMetaspace); assert_is_aligned(rs.base(), chunklevel::MAX_CHUNK_BYTE_SIZE); InternalStats::inc_num_vsnodes_births(); return new VirtualSpaceNode(rs, true, limiter, reserve_words_counter, commit_words_counter); diff --git a/src/hotspot/share/memory/padded.hpp b/src/hotspot/share/memory/padded.hpp index bca1d168cb5..7e0e0615208 100644 --- a/src/hotspot/share/memory/padded.hpp +++ b/src/hotspot/share/memory/padded.hpp @@ -25,7 +25,7 @@ #ifndef SHARE_MEMORY_PADDED_HPP #define SHARE_MEMORY_PADDED_HPP -#include "nmt/memflags.hpp" +#include "nmt/memTag.hpp" #include "utilities/align.hpp" #include "utilities/globalDefinitions.hpp" @@ -89,7 +89,7 @@ class PaddedEnd : public PaddedEndImpl { // Helper class to create an array of PaddedEnd objects. All elements will // start at a multiple of alignment and the size will be aligned to alignment. -template +template class PaddedArray { public: // Creates an aligned padded array. @@ -100,7 +100,7 @@ class PaddedArray { // Helper class to create an array of references to arrays of primitive types // Both the array of references and the data arrays are aligned to the given // alignment. The allocated memory is zero-filled. -template +template class Padded2DArray { public: // Creates an aligned padded 2D array. @@ -112,7 +112,7 @@ class Padded2DArray { // Helper class to create an array of T objects. The array as a whole will // start at a multiple of alignment and its size will be aligned to alignment. -template +template class PaddedPrimitiveArray { public: static T* create_unfreeable(size_t length); diff --git a/src/hotspot/share/memory/padded.inline.hpp b/src/hotspot/share/memory/padded.inline.hpp index 72001e3aad6..ba477bfe88f 100644 --- a/src/hotspot/share/memory/padded.inline.hpp +++ b/src/hotspot/share/memory/padded.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,13 +34,13 @@ // Creates an aligned padded array. // The memory can't be deleted since the raw memory chunk is not returned. -template -PaddedEnd* PaddedArray::create_unfreeable(uint length) { +template +PaddedEnd* PaddedArray::create_unfreeable(uint length) { // Check that the PaddedEnd class works as intended. STATIC_ASSERT(is_aligned(sizeof(PaddedEnd), alignment)); // Allocate a chunk of memory large enough to allow for some alignment. - void* chunk = AllocateHeap(length * sizeof(PaddedEnd) + alignment, flags); + void* chunk = AllocateHeap(length * sizeof(PaddedEnd) + alignment, MT); // Make the initial alignment. PaddedEnd* aligned_padded_array = (PaddedEnd*)align_up(chunk, alignment); @@ -53,8 +53,8 @@ PaddedEnd* PaddedArray::create_unfreeable(uint length) { return aligned_padded_array; } -template -T** Padded2DArray::create_unfreeable(uint rows, uint columns, size_t* allocation_size) { +template +T** Padded2DArray::create_unfreeable(uint rows, uint columns, size_t* allocation_size) { // Calculate and align the size of the first dimension's table. size_t table_size = align_up(rows * sizeof(T*), alignment); // The size of the separate rows. @@ -63,7 +63,7 @@ T** Padded2DArray::create_unfreeable(uint rows, uint column size_t total_size = table_size + rows * row_size + alignment; // Allocate a chunk of memory large enough to allow alignment of the chunk. - void* chunk = MmapArrayAllocator::allocate(total_size, flags); + void* chunk = MmapArrayAllocator::allocate(total_size, MT); // Clear the allocated memory. // Align the chunk of memory. T** result = (T**)align_up(chunk, alignment); @@ -81,16 +81,16 @@ T** Padded2DArray::create_unfreeable(uint rows, uint column return result; } -template -T* PaddedPrimitiveArray::create_unfreeable(size_t length) { +template +T* PaddedPrimitiveArray::create_unfreeable(size_t length) { void* temp; return create(length, &temp); } -template -T* PaddedPrimitiveArray::create(size_t length, void** alloc_base) { +template +T* PaddedPrimitiveArray::create(size_t length, void** alloc_base) { // Allocate a chunk of memory large enough to allow for some alignment. - void* chunk = AllocateHeap(length * sizeof(T) + alignment, flags); + void* chunk = AllocateHeap(length * sizeof(T) + alignment, MT); memset(chunk, 0, length * sizeof(T) + alignment); diff --git a/src/hotspot/share/memory/resourceArea.hpp b/src/hotspot/share/memory/resourceArea.hpp index 5fd376068c5..b9a1904b507 100644 --- a/src/hotspot/share/memory/resourceArea.hpp +++ b/src/hotspot/share/memory/resourceArea.hpp @@ -51,11 +51,11 @@ class ResourceArea: public Arena { #endif // ASSERT public: - ResourceArea(MEMFLAGS flags = mtThread) : - Arena(flags, Arena::Tag::tag_ra) DEBUG_ONLY(COMMA _nesting(0)) {} + ResourceArea(MemTag mem_tag = mtThread) : + Arena(mem_tag, Arena::Tag::tag_ra) DEBUG_ONLY(COMMA _nesting(0)) {} - ResourceArea(size_t init_size, MEMFLAGS flags = mtThread) : - Arena(flags, Arena::Tag::tag_ra, init_size) DEBUG_ONLY(COMMA _nesting(0)) { + ResourceArea(size_t init_size, MemTag mem_tag = mtThread) : + Arena(mem_tag, Arena::Tag::tag_ra, init_size) DEBUG_ONLY(COMMA _nesting(0)) { } char* allocate_bytes(size_t size, AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM); diff --git a/src/hotspot/share/memory/universe.cpp b/src/hotspot/share/memory/universe.cpp index 8f20f331235..4b6554173f9 100644 --- a/src/hotspot/share/memory/universe.cpp +++ b/src/hotspot/share/memory/universe.cpp @@ -229,6 +229,9 @@ public: static BuiltinException _null_ptr_exception; static BuiltinException _arithmetic_exception; static BuiltinException _internal_error; +static BuiltinException _array_index_out_of_bounds_exception; +static BuiltinException _array_store_exception; +static BuiltinException _class_cast_exception; objArrayOop Universe::the_empty_class_array () { return (objArrayOop)_the_empty_class_array.resolve(); @@ -246,6 +249,9 @@ oop Universe::the_min_jint_string() { return _the_min_jint_string. oop Universe::null_ptr_exception_instance() { return _null_ptr_exception.instance(); } oop Universe::arithmetic_exception_instance() { return _arithmetic_exception.instance(); } oop Universe::internal_error_instance() { return _internal_error.instance(); } +oop Universe::array_index_out_of_bounds_exception_instance() { return _array_index_out_of_bounds_exception.instance(); } +oop Universe::array_store_exception_instance() { return _array_store_exception.instance(); } +oop Universe::class_cast_exception_instance() { return _class_cast_exception.instance(); } oop Universe::the_null_sentinel() { return _the_null_sentinel.resolve(); } @@ -302,6 +308,9 @@ void Universe::archive_exception_instances() { _null_ptr_exception.store_in_cds(); _arithmetic_exception.store_in_cds(); _internal_error.store_in_cds(); + _array_index_out_of_bounds_exception.store_in_cds(); + _array_store_exception.store_in_cds(); + _class_cast_exception.store_in_cds(); } void Universe::load_archived_object_instances() { @@ -318,6 +327,9 @@ void Universe::load_archived_object_instances() { _null_ptr_exception.load_from_cds(); _arithmetic_exception.load_from_cds(); _internal_error.load_from_cds(); + _array_index_out_of_bounds_exception.load_from_cds(); + _array_store_exception.load_from_cds(); + _class_cast_exception.load_from_cds(); } } #endif @@ -334,6 +346,9 @@ void Universe::serialize(SerializeClosure* f) { _null_ptr_exception.serialize(f); _arithmetic_exception.serialize(f); _internal_error.serialize(f); + _array_index_out_of_bounds_exception.serialize(f); + _array_store_exception.serialize(f); + _class_cast_exception.serialize(f); #endif f->do_ptr(&_fillerArrayKlass); @@ -1083,10 +1098,12 @@ bool universe_post_init() { Universe::_delayed_stack_overflow_error_message = OopHandle(Universe::vm_global(), instance); } - // Setup preallocated NullPointerException/ArithmeticException - // (used for a cheap & dirty solution in compiler exception handling) + // Setup preallocated exceptions used for a cheap & dirty solution in compiler exception handling _null_ptr_exception.init_if_empty(vmSymbols::java_lang_NullPointerException(), CHECK_false); _arithmetic_exception.init_if_empty(vmSymbols::java_lang_ArithmeticException(), CHECK_false); + _array_index_out_of_bounds_exception.init_if_empty(vmSymbols::java_lang_ArrayIndexOutOfBoundsException(), CHECK_false); + _array_store_exception.init_if_empty(vmSymbols::java_lang_ArrayStoreException(), CHECK_false); + _class_cast_exception.init_if_empty(vmSymbols::java_lang_ClassCastException(), CHECK_false); // Virtual Machine Error for when we get into a situation we can't resolve Klass* k = vmClasses::InternalError_klass(); diff --git a/src/hotspot/share/memory/universe.hpp b/src/hotspot/share/memory/universe.hpp index c7bdb8f2339..0a3b9eaae01 100644 --- a/src/hotspot/share/memory/universe.hpp +++ b/src/hotspot/share/memory/universe.hpp @@ -230,6 +230,9 @@ class Universe: AllStatic { static oop null_ptr_exception_instance(); static oop arithmetic_exception_instance(); static oop internal_error_instance(); + static oop array_index_out_of_bounds_exception_instance(); + static oop array_store_exception_instance(); + static oop class_cast_exception_instance(); static oop vm_exception() { return internal_error_instance(); } static Array* the_array_interfaces_array() { return _the_array_interfaces_array; } diff --git a/src/hotspot/share/memory/virtualspace.cpp b/src/hotspot/share/memory/virtualspace.cpp index c27e607353a..0cc81ce85a6 100644 --- a/src/hotspot/share/memory/virtualspace.cpp +++ b/src/hotspot/share/memory/virtualspace.cpp @@ -653,7 +653,7 @@ ReservedHeapSpace::ReservedHeapSpace(size_t size, size_t alignment, size_t page_ "area must be distinguishable from marks for mark-sweep"); if (base() != nullptr) { - MemTracker::record_virtual_memory_type((address)base(), mtJavaHeap); + MemTracker::record_virtual_memory_tag((address)base(), mtJavaHeap); } if (_fd_for_heap != -1) { @@ -671,7 +671,7 @@ ReservedCodeSpace::ReservedCodeSpace(size_t r_size, size_t rs_align, size_t rs_page_size) : ReservedSpace() { initialize(r_size, rs_align, rs_page_size, /*requested address*/ nullptr, /*executable*/ true); - MemTracker::record_virtual_memory_type((address)base(), mtCode); + MemTracker::record_virtual_memory_tag((address)base(), mtCode); } // VirtualSpace diff --git a/src/hotspot/share/nmt/allocationSite.hpp b/src/hotspot/share/nmt/allocationSite.hpp index 022fb6f4390..a7bc2e96250 100644 --- a/src/hotspot/share/nmt/allocationSite.hpp +++ b/src/hotspot/share/nmt/allocationSite.hpp @@ -25,7 +25,7 @@ #ifndef SHARE_NMT_ALLOCATIONSITE_HPP #define SHARE_NMT_ALLOCATIONSITE_HPP -#include "nmt/memflags.hpp" +#include "nmt/memTag.hpp" #include "utilities/nativeCallStack.hpp" // Allocation site represents a code path that makes a memory @@ -33,9 +33,9 @@ class AllocationSite { private: const NativeCallStack _call_stack; - const MEMFLAGS _flag; + const MemTag _mem_tag; public: - AllocationSite(const NativeCallStack& stack, MEMFLAGS flag) : _call_stack(stack), _flag(flag) { } + AllocationSite(const NativeCallStack& stack, MemTag mem_tag) : _call_stack(stack), _mem_tag(mem_tag) { } bool equals(const NativeCallStack& stack) const { return _call_stack.equals(stack); @@ -49,7 +49,7 @@ class AllocationSite { return &_call_stack; } - MEMFLAGS flag() const { return _flag; } + MemTag mem_tag() const { return _mem_tag; } }; #endif // SHARE_NMT_ALLOCATIONSITE_HPP diff --git a/src/hotspot/share/nmt/arrayWithFreeList.hpp b/src/hotspot/share/nmt/arrayWithFreeList.hpp index 13aa1045fe7..2c1812dcc52 100644 --- a/src/hotspot/share/nmt/arrayWithFreeList.hpp +++ b/src/hotspot/share/nmt/arrayWithFreeList.hpp @@ -31,7 +31,7 @@ // A flat array of elements E, backed by C-heap, growing on-demand. It allows for // returning arbitrary elements and keeps them in a freelist. Elements can be uniquely // identified via array index. -template +template class ArrayWithFreeList { // An E must be trivially copyable and destructible, but it may be constructed @@ -52,7 +52,7 @@ private: E e; }; - GrowableArrayCHeap _backing_storage; + GrowableArrayCHeap _backing_storage; I _free_start; bool is_in_bounds(I i) { diff --git a/src/hotspot/share/nmt/mallocHeader.cpp b/src/hotspot/share/nmt/mallocHeader.cpp index d5a7b689c2a..defe2fc045d 100644 --- a/src/hotspot/share/nmt/mallocHeader.cpp +++ b/src/hotspot/share/nmt/mallocHeader.cpp @@ -26,16 +26,16 @@ #include "nmt/mallocHeader.inline.hpp" #include "nmt/mallocSiteTable.hpp" -#include "nmt/memflags.hpp" +#include "nmt/memTag.hpp" #include "runtime/os.hpp" #include "utilities/debug.hpp" #include "utilities/globalDefinitions.hpp" #include "utilities/nativeCallStack.hpp" #include "utilities/ostream.hpp" -// The malloc header, as well as the coming VMATree implementation, rely on MEMFLAGS +// The malloc header, as well as the coming VMATree implementation, rely on MemTag // fitting into eight bits. -STATIC_ASSERT(sizeof(MEMFLAGS) == sizeof(uint8_t)); +STATIC_ASSERT(sizeof(MemTag) == sizeof(uint8_t)); void MallocHeader::print_block_on_error(outputStream* st, address bad_address) const { assert(bad_address >= (address)this, "sanity"); diff --git a/src/hotspot/share/nmt/mallocHeader.hpp b/src/hotspot/share/nmt/mallocHeader.hpp index 9f9f7f97ea7..6711c2b993e 100644 --- a/src/hotspot/share/nmt/mallocHeader.hpp +++ b/src/hotspot/share/nmt/mallocHeader.hpp @@ -26,7 +26,7 @@ #ifndef SHARE_NMT_MALLOCHEADER_HPP #define SHARE_NMT_MALLOCHEADER_HPP -#include "nmt/memflags.hpp" +#include "nmt/memTag.hpp" #include "utilities/globalDefinitions.hpp" #include "utilities/macros.hpp" #include "utilities/nativeCallStack.hpp" @@ -92,7 +92,7 @@ class MallocHeader { NOT_LP64(uint32_t _alt_canary); const size_t _size; const uint32_t _mst_marker; - const MEMFLAGS _flags; + const MemTag _mem_tag; const uint8_t _unused; uint16_t _canary; @@ -121,19 +121,20 @@ public: // Contains all of the necessary data to to deaccount block with NMT. struct FreeInfo { const size_t size; - const MEMFLAGS flags; + const MemTag mem_tag; const uint32_t mst_marker; }; - inline MallocHeader(size_t size, MEMFLAGS flags, uint32_t mst_marker); + inline MallocHeader(size_t size, MemTag mem_tag, uint32_t mst_marker); - inline size_t size() const { return _size; } - inline MEMFLAGS flags() const { return _flags; } + inline static size_t malloc_overhead() { return sizeof(MallocHeader) + sizeof(uint16_t); } + inline size_t size() const { return _size; } + inline MemTag mem_tag() const { return _mem_tag; } inline uint32_t mst_marker() const { return _mst_marker; } // Return the necessary data to deaccount the block with NMT. FreeInfo free_info() { - return FreeInfo{this->size(), this->flags(), this->mst_marker()}; + return FreeInfo{this->size(), this->mem_tag(), this->mst_marker()}; } inline void mark_block_as_dead(); inline void revive(); diff --git a/src/hotspot/share/nmt/mallocHeader.inline.hpp b/src/hotspot/share/nmt/mallocHeader.inline.hpp index d763241b36d..34ec891d33f 100644 --- a/src/hotspot/share/nmt/mallocHeader.inline.hpp +++ b/src/hotspot/share/nmt/mallocHeader.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2021, 2022 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -34,8 +34,8 @@ #include "utilities/macros.hpp" #include "utilities/nativeCallStack.hpp" -inline MallocHeader::MallocHeader(size_t size, MEMFLAGS flags, uint32_t mst_marker) - : _size(size), _mst_marker(mst_marker), _flags(flags), +inline MallocHeader::MallocHeader(size_t size, MemTag mem_tag, uint32_t mst_marker) + : _size(size), _mst_marker(mst_marker), _mem_tag(mem_tag), _unused(0), _canary(_header_canary_live_mark) { assert(size < max_reasonable_malloc_size, "Too large allocation size?"); diff --git a/src/hotspot/share/nmt/mallocLimit.cpp b/src/hotspot/share/nmt/mallocLimit.cpp index 746c3b9201b..5e16a406821 100644 --- a/src/hotspot/share/nmt/mallocLimit.cpp +++ b/src/hotspot/share/nmt/mallocLimit.cpp @@ -25,7 +25,7 @@ #include "precompiled.hpp" #include "nmt/mallocLimit.hpp" -#include "nmt/memflags.hpp" +#include "nmt/memTag.hpp" #include "nmt/nmtCommon.hpp" #include "runtime/java.hpp" #include "runtime/globals.hpp" @@ -80,7 +80,7 @@ public: // Check if string at position matches a category name. // Advances position on match. - bool match_category(MEMFLAGS* out) { + bool match_category(MemTag* out) { if (eof()) { return false; } @@ -90,9 +90,9 @@ public: } stringStream ss; ss.print("%.*s", (int)(end - _p), _p); - MEMFLAGS f = NMTUtil::string_to_flag(ss.base()); - if (f != mtNone) { - *out = f; + MemTag mem_tag = NMTUtil::string_to_mem_tag(ss.base()); + if (mem_tag != mtNone) { + *out = mem_tag; _p = end; return true; } @@ -131,16 +131,16 @@ void MallocLimitSet::set_global_limit(size_t s, MallocLimitMode flag) { _glob.sz = s; _glob.mode = flag; } -void MallocLimitSet::set_category_limit(MEMFLAGS f, size_t s, MallocLimitMode flag) { - const int i = NMTUtil::flag_to_index(f); +void MallocLimitSet::set_category_limit(MemTag mem_tag, size_t s, MallocLimitMode flag) { + const int i = NMTUtil::tag_to_index(mem_tag); _cat[i].sz = s; _cat[i].mode = flag; } void MallocLimitSet::reset() { set_global_limit(0, MallocLimitMode::trigger_fatal); _glob.sz = 0; _glob.mode = MallocLimitMode::trigger_fatal; - for (int i = 0; i < mt_number_of_types; i++) { - set_category_limit(NMTUtil::index_to_flag(i), 0, MallocLimitMode::trigger_fatal); + for (int i = 0; i < mt_number_of_tags; i++) { + set_category_limit(NMTUtil::index_to_tag(i), 0, MallocLimitMode::trigger_fatal); } } @@ -150,10 +150,10 @@ void MallocLimitSet::print_on(outputStream* st) const { st->print_cr("MallocLimit: total limit: " PROPERFMT " (%s)", PROPERFMTARGS(_glob.sz), mode_to_name(_glob.mode)); } else { - for (int i = 0; i < mt_number_of_types; i++) { + for (int i = 0; i < mt_number_of_tags; i++) { if (_cat[i].sz > 0) { st->print_cr("MallocLimit: category \"%s\" limit: " PROPERFMT " (%s)", - NMTUtil::flag_to_enum_name(NMTUtil::index_to_flag(i)), + NMTUtil::tag_to_enum_name(NMTUtil::index_to_tag(i)), PROPERFMTARGS(_cat[i].sz), mode_to_name(_cat[i].mode)); } } @@ -187,13 +187,13 @@ bool MallocLimitSet::parse_malloclimit_option(const char* v, const char** err) { // Category-specific form? else { while (!sst.eof()) { - MEMFLAGS f; + MemTag mem_tag; // Match category, followed by : - BAIL_UNLESS(sst.match_category(&f), "Expected category name"); + BAIL_UNLESS(sst.match_category(&mem_tag), "Expected category name"); BAIL_UNLESS(sst.match_char(':'), "Expected colon following category"); - malloclimit* const modified_limit = &_cat[NMTUtil::flag_to_index(f)]; + malloclimit* const modified_limit = &_cat[NMTUtil::tag_to_index(mem_tag)]; // Match size BAIL_UNLESS(sst.match_size(&modified_limit->sz), "Expected size"); diff --git a/src/hotspot/share/nmt/mallocLimit.hpp b/src/hotspot/share/nmt/mallocLimit.hpp index 2034e3ce24b..ec6799b41a3 100644 --- a/src/hotspot/share/nmt/mallocLimit.hpp +++ b/src/hotspot/share/nmt/mallocLimit.hpp @@ -27,7 +27,7 @@ #define SHARE_SERVICES_MALLOCLIMIT_HPP #include "memory/allStatic.hpp" -#include "nmt/memflags.hpp" +#include "nmt/memTag.hpp" #include "utilities/debug.hpp" #include "utilities/globalDefinitions.hpp" @@ -46,18 +46,18 @@ class outputStream; class MallocLimitSet { malloclimit _glob; // global limit - malloclimit _cat[mt_number_of_types]; // per-category limit + malloclimit _cat[mt_number_of_tags]; // per-category limit public: MallocLimitSet(); void reset(); bool parse_malloclimit_option(const char* optionstring, const char** err); - void set_global_limit(size_t s, MallocLimitMode flag); - void set_category_limit(MEMFLAGS f, size_t s, MallocLimitMode flag); + void set_global_limit(size_t s, MallocLimitMode type); + void set_category_limit(MemTag mem_tag, size_t s, MallocLimitMode mode); const malloclimit* global_limit() const { return &_glob; } - const malloclimit* category_limit(MEMFLAGS f) const { return &_cat[(int)f]; } + const malloclimit* category_limit(MemTag mem_tag) const { return &_cat[(int)mem_tag]; } void print_on(outputStream* st) const; }; @@ -69,7 +69,7 @@ class MallocLimitHandler : public AllStatic { public: static const malloclimit* global_limit() { return _limits.global_limit(); } - static const malloclimit* category_limit(MEMFLAGS f) { return _limits.category_limit(f); } + static const malloclimit* category_limit(MemTag mem_tag) { return _limits.category_limit(mem_tag); } static void initialize(const char* options); static void print_on(outputStream* st); diff --git a/src/hotspot/share/nmt/mallocSiteTable.cpp b/src/hotspot/share/nmt/mallocSiteTable.cpp index 0fdf9e0f83d..9411f76c491 100644 --- a/src/hotspot/share/nmt/mallocSiteTable.cpp +++ b/src/hotspot/share/nmt/mallocSiteTable.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -111,15 +111,15 @@ bool MallocSiteTable::walk(MallocSiteWalker* walker) { * 2. Overflow hash bucket. * Under any of above circumstances, caller should handle the situation. */ -MallocSite* MallocSiteTable::lookup_or_add(const NativeCallStack& key, uint32_t* marker, MEMFLAGS flags) { - assert(flags != mtNone, "Should have a real memory type"); +MallocSite* MallocSiteTable::lookup_or_add(const NativeCallStack& key, uint32_t* marker, MemTag mem_tag) { + assert(mem_tag != mtNone, "Should have a real memory tag"); const unsigned int hash = key.calculate_hash(); const unsigned int index = hash_to_index(hash); *marker = 0; // First entry for this hash bucket if (_table[index] == nullptr) { - MallocSiteHashtableEntry* entry = new_entry(key, flags); + MallocSiteHashtableEntry* entry = new_entry(key, mem_tag); // OOM check if (entry == nullptr) return nullptr; @@ -137,14 +137,14 @@ MallocSite* MallocSiteTable::lookup_or_add(const NativeCallStack& key, uint32_t* while (head != nullptr && pos_idx < MAX_BUCKET_LENGTH) { if (head->hash() == hash) { MallocSite* site = head->data(); - if (site->flag() == flags && site->equals(key)) { + if (site->mem_tag() == mem_tag && site->equals(key)) { *marker = build_marker(index, pos_idx); return head->data(); } } if (head->next() == nullptr && pos_idx < (MAX_BUCKET_LENGTH - 1)) { - MallocSiteHashtableEntry* entry = new_entry(key, flags); + MallocSiteHashtableEntry* entry = new_entry(key, mem_tag); // OOM check if (entry == nullptr) return nullptr; if (head->atomic_insert(entry)) { @@ -177,10 +177,10 @@ MallocSite* MallocSiteTable::malloc_site(uint32_t marker) { // Allocates MallocSiteHashtableEntry object. Special call stack // (pre-installed allocation site) has to be used to avoid infinite // recursion. -MallocSiteHashtableEntry* MallocSiteTable::new_entry(const NativeCallStack& key, MEMFLAGS flags) { +MallocSiteHashtableEntry* MallocSiteTable::new_entry(const NativeCallStack& key, MemTag mem_tag) { void* p = AllocateHeap(sizeof(MallocSiteHashtableEntry), mtNMT, *hash_entry_allocation_stack(), AllocFailStrategy::RETURN_NULL); - return ::new (p) MallocSiteHashtableEntry(key, flags); + return ::new (p) MallocSiteHashtableEntry(key, mem_tag); } bool MallocSiteTable::walk_malloc_site(MallocSiteWalker* walker) { diff --git a/src/hotspot/share/nmt/mallocSiteTable.hpp b/src/hotspot/share/nmt/mallocSiteTable.hpp index ae9266f5369..472bc397dd4 100644 --- a/src/hotspot/share/nmt/mallocSiteTable.hpp +++ b/src/hotspot/share/nmt/mallocSiteTable.hpp @@ -38,8 +38,8 @@ class MallocSite : public AllocationSite { MemoryCounter _c; public: - MallocSite(const NativeCallStack& stack, MEMFLAGS flags) : - AllocationSite(stack, flags) {} + MallocSite(const NativeCallStack& stack, MemTag mem_tag) : + AllocationSite(stack, mem_tag) {} void allocate(size_t size) { _c.allocate(size); } void deallocate(size_t size) { _c.deallocate(size); } @@ -63,9 +63,9 @@ class MallocSiteHashtableEntry : public CHeapObj { public: - MallocSiteHashtableEntry(NativeCallStack stack, MEMFLAGS flags): - _malloc_site(stack, flags), _hash(stack.calculate_hash()), _next(nullptr) { - assert(flags != mtNone, "Expect a real memory type"); + MallocSiteHashtableEntry(NativeCallStack stack, MemTag mem_tag): + _malloc_site(stack, mem_tag), _hash(stack.calculate_hash()), _next(nullptr) { + assert(mem_tag != mtNone, "Expect a real memory tag"); } inline const MallocSiteHashtableEntry* next() const { @@ -147,8 +147,8 @@ class MallocSiteTable : AllStatic { // 1. out of memory // 2. overflow hash bucket static inline bool allocation_at(const NativeCallStack& stack, size_t size, - uint32_t* marker, MEMFLAGS flags) { - MallocSite* site = lookup_or_add(stack, marker, flags); + uint32_t* marker, MemTag mem_tag) { + MallocSite* site = lookup_or_add(stack, marker, mem_tag); if (site != nullptr) site->allocate(size); return site != nullptr; } @@ -170,9 +170,9 @@ class MallocSiteTable : AllStatic { static void print_tuning_statistics(outputStream* st); private: - static MallocSiteHashtableEntry* new_entry(const NativeCallStack& key, MEMFLAGS flags); + static MallocSiteHashtableEntry* new_entry(const NativeCallStack& key, MemTag mem_tag); - static MallocSite* lookup_or_add(const NativeCallStack& key, uint32_t* marker, MEMFLAGS flags); + static MallocSite* lookup_or_add(const NativeCallStack& key, uint32_t* marker, MemTag mem_tag); static MallocSite* malloc_site(uint32_t marker); static bool walk(MallocSiteWalker* walker); diff --git a/src/hotspot/share/nmt/mallocTracker.cpp b/src/hotspot/share/nmt/mallocTracker.cpp index 021ce5d1332..6829db90b4b 100644 --- a/src/hotspot/share/nmt/mallocTracker.cpp +++ b/src/hotspot/share/nmt/mallocTracker.cpp @@ -69,7 +69,7 @@ void MallocMemorySnapshot::copy_to(MallocMemorySnapshot* s) { s->_all_mallocs = _all_mallocs; size_t total_size = 0; size_t total_count = 0; - for (int index = 0; index < mt_number_of_types; index ++) { + for (int index = 0; index < mt_number_of_tags; index ++) { s->_malloc[index] = _malloc[index]; total_size += s->_malloc[index].malloc_size(); total_count += s->_malloc[index].malloc_count(); @@ -81,7 +81,7 @@ void MallocMemorySnapshot::copy_to(MallocMemorySnapshot* s) { // Total malloc'd memory used by arenas size_t MallocMemorySnapshot::total_arena() const { size_t amount = 0; - for (int index = 0; index < mt_number_of_types; index ++) { + for (int index = 0; index < mt_number_of_tags; index ++) { amount += _malloc[index].arena_size(); } return amount; @@ -91,7 +91,7 @@ size_t MallocMemorySnapshot::total_arena() const { // from total chunks to get total free chunk size void MallocMemorySnapshot::make_adjustment() { size_t arena_size = total_arena(); - int chunk_idx = NMTUtil::flag_to_index(mtChunk); + int chunk_idx = NMTUtil::tag_to_index(mtChunk); _malloc[chunk_idx].record_free(arena_size); _all_mallocs.deallocate(arena_size); } @@ -128,11 +128,11 @@ bool MallocMemorySummary::total_limit_reached(size_t s, size_t so_far, const mal return true; } -bool MallocMemorySummary::category_limit_reached(MEMFLAGS f, size_t s, size_t so_far, const malloclimit* limit) { +bool MallocMemorySummary::category_limit_reached(MemTag mem_tag, size_t s, size_t so_far, const malloclimit* limit) { #define FORMATTED \ "MallocLimit: reached category \"%s\" limit (triggering allocation size: " PROPERFMT ", allocated so far: " PROPERFMT ", limit: " PROPERFMT ") ", \ - NMTUtil::flag_to_enum_name(f), PROPERFMTARGS(s), PROPERFMTARGS(so_far), PROPERFMTARGS(limit->sz) + NMTUtil::tag_to_enum_name(mem_tag), PROPERFMTARGS(s), PROPERFMTARGS(so_far), PROPERFMTARGS(limit->sz) // If we hit the limit during error reporting, we print a short warning but otherwise ignore it. // We don't want to risk recursive assertion or torn hs-err logs. @@ -167,20 +167,20 @@ bool MallocTracker::initialize(NMT_TrackingLevel level) { } // Record a malloc memory allocation -void* MallocTracker::record_malloc(void* malloc_base, size_t size, MEMFLAGS flags, +void* MallocTracker::record_malloc(void* malloc_base, size_t size, MemTag mem_tag, const NativeCallStack& stack) { assert(MemTracker::enabled(), "precondition"); assert(malloc_base != nullptr, "precondition"); - MallocMemorySummary::record_malloc(size, flags); + MallocMemorySummary::record_malloc(size, mem_tag); uint32_t mst_marker = 0; if (MemTracker::tracking_level() == NMT_detail) { - MallocSiteTable::allocation_at(stack, size, &mst_marker, flags); + MallocSiteTable::allocation_at(stack, size, &mst_marker, mem_tag); } // Uses placement global new operator to initialize malloc header - MallocHeader* const header = ::new (malloc_base)MallocHeader(size, flags, mst_marker); + MallocHeader* const header = ::new (malloc_base)MallocHeader(size, mem_tag, mst_marker); void* const memblock = (void*)((char*)malloc_base + sizeof(MallocHeader)); // The alignment check: 8 bytes alignment for 32 bit systems. @@ -192,7 +192,7 @@ void* MallocTracker::record_malloc(void* malloc_base, size_t size, MEMFLAGS flag { const MallocHeader* header2 = MallocHeader::resolve_checked(memblock); assert(header2->size() == size, "Wrong size"); - assert(header2->flags() == flags, "Wrong flags"); + assert(header2->mem_tag() == mem_tag, "Wrong memory tag"); } #endif @@ -213,7 +213,7 @@ void* MallocTracker::record_free_block(void* memblock) { } void MallocTracker::deaccount(MallocHeader::FreeInfo free_info) { - MallocMemorySummary::record_free(free_info.size, free_info.flags); + MallocMemorySummary::record_free(free_info.size, free_info.mem_tag); if (MemTracker::tracking_level() == NMT_detail) { MallocSiteTable::deallocation_at(free_info.size, free_info.mst_marker); } @@ -296,7 +296,7 @@ bool MallocTracker::print_pointer_information(const void* p, outputStream* st) { p2i(p), where, (block->is_dead() ? "dead" : "live"), p2i(block + 1), // lets print the payload start, not the header - block->size(), NMTUtil::flag_to_enum_name(block->flags())); + block->size(), NMTUtil::tag_to_enum_name(block->mem_tag())); if (MemTracker::tracking_level() == NMT_detail) { NativeCallStack ncs; if (MallocSiteTable::access_stack(ncs, *block)) { diff --git a/src/hotspot/share/nmt/mallocTracker.hpp b/src/hotspot/share/nmt/mallocTracker.hpp index 9c14ea04bf0..de30f32373e 100644 --- a/src/hotspot/share/nmt/mallocTracker.hpp +++ b/src/hotspot/share/nmt/mallocTracker.hpp @@ -27,7 +27,7 @@ #define SHARE_NMT_MALLOCTRACKER_HPP #include "nmt/mallocHeader.hpp" -#include "nmt/memflags.hpp" +#include "nmt/memTag.hpp" #include "nmt/nmtCommon.hpp" #include "runtime/atomic.hpp" #include "runtime/threadCritical.hpp" @@ -150,23 +150,23 @@ class MallocMemorySnapshot { friend class MallocMemorySummary; private: - MallocMemory _malloc[mt_number_of_types]; + MallocMemory _malloc[mt_number_of_tags]; MemoryCounter _all_mallocs; public: - inline MallocMemory* by_type(MEMFLAGS flags) { - int index = NMTUtil::flag_to_index(flags); + inline MallocMemory* by_type(MemTag mem_tag) { + int index = NMTUtil::tag_to_index(mem_tag); return &_malloc[index]; } - inline const MallocMemory* by_type(MEMFLAGS flags) const { - int index = NMTUtil::flag_to_index(flags); + inline const MallocMemory* by_type(MemTag mem_tag) const { + int index = NMTUtil::tag_to_index(mem_tag); return &_malloc[index]; } inline size_t malloc_overhead() const { - return _all_mallocs.count() * sizeof(MallocHeader); + return _all_mallocs.count() * MallocHeader::malloc_overhead(); } // Total malloc invocation count @@ -214,31 +214,31 @@ class MallocMemorySummary : AllStatic { // Called when a total limit break was detected. // Will return true if the limit was handled, false if it was ignored. - static bool category_limit_reached(MEMFLAGS f, size_t s, size_t so_far, const malloclimit* limit); + static bool category_limit_reached(MemTag mem_tag, size_t s, size_t so_far, const malloclimit* limit); public: static void initialize(); - static inline void record_malloc(size_t size, MEMFLAGS flag) { - as_snapshot()->by_type(flag)->record_malloc(size); + static inline void record_malloc(size_t size, MemTag mem_tag) { + as_snapshot()->by_type(mem_tag)->record_malloc(size); as_snapshot()->_all_mallocs.allocate(size); } - static inline void record_free(size_t size, MEMFLAGS flag) { - as_snapshot()->by_type(flag)->record_free(size); + static inline void record_free(size_t size, MemTag mem_tag) { + as_snapshot()->by_type(mem_tag)->record_free(size); as_snapshot()->_all_mallocs.deallocate(size); } - static inline void record_new_arena(MEMFLAGS flag) { - as_snapshot()->by_type(flag)->record_new_arena(); + static inline void record_new_arena(MemTag mem_tag) { + as_snapshot()->by_type(mem_tag)->record_new_arena(); } - static inline void record_arena_free(MEMFLAGS flag) { - as_snapshot()->by_type(flag)->record_arena_free(); + static inline void record_arena_free(MemTag mem_tag) { + as_snapshot()->by_type(mem_tag)->record_arena_free(); } - static inline void record_arena_size_change(ssize_t size, MEMFLAGS flag) { - as_snapshot()->by_type(flag)->record_arena_size_change(size); + static inline void record_arena_size_change(ssize_t size, MemTag mem_tag) { + as_snapshot()->by_type(mem_tag)->record_arena_size_change(size); } static void snapshot(MallocMemorySnapshot* s) { @@ -257,7 +257,7 @@ class MallocMemorySummary : AllStatic { // MallocLimit: returns true if allocating s bytes on f would trigger // either global or the category limit - static inline bool check_exceeds_limit(size_t s, MEMFLAGS f); + static inline bool check_exceeds_limit(size_t s, MemTag mem_tag); }; @@ -269,7 +269,7 @@ class MallocTracker : AllStatic { // The overhead that is incurred by switching on NMT (we need, per malloc allocation, // space for header and 16-bit footer) - static const size_t overhead_per_malloc = sizeof(MallocHeader) + sizeof(uint16_t); + static inline size_t overhead_per_malloc() { return MallocHeader::malloc_overhead(); } // Parameter name convention: // memblock : the beginning address for user data @@ -280,7 +280,7 @@ class MallocTracker : AllStatic { // // Record malloc on specified memory block - static void* record_malloc(void* malloc_base, size_t size, MEMFLAGS flags, + static void* record_malloc(void* malloc_base, size_t size, MemTag mem_tag, const NativeCallStack& stack); // Given a block returned by os::malloc() or os::realloc(): @@ -289,21 +289,21 @@ class MallocTracker : AllStatic { // Given the free info from a block, de-account block from NMT. static void deaccount(MallocHeader::FreeInfo free_info); - static inline void record_new_arena(MEMFLAGS flags) { - MallocMemorySummary::record_new_arena(flags); + static inline void record_new_arena(MemTag mem_tag) { + MallocMemorySummary::record_new_arena(mem_tag); } - static inline void record_arena_free(MEMFLAGS flags) { - MallocMemorySummary::record_arena_free(flags); + static inline void record_arena_free(MemTag mem_tag) { + MallocMemorySummary::record_arena_free(mem_tag); } - static inline void record_arena_size_change(ssize_t size, MEMFLAGS flags) { - MallocMemorySummary::record_arena_size_change(size, flags); + static inline void record_arena_size_change(ssize_t size, MemTag mem_tag) { + MallocMemorySummary::record_arena_size_change(size, mem_tag); } // MallocLimt: Given an allocation size s, check if mallocing this much - // under category f would hit either the global limit or the limit for category f. - static inline bool check_exceeds_limit(size_t s, MEMFLAGS f); + // for MemTag would hit either the global limit or the limit for MemTag. + static inline bool check_exceeds_limit(size_t s, MemTag mem_tag); // Given a pointer, look for the containing malloc block. // Print the block. Note that since there is very low risk of memory looking diff --git a/src/hotspot/share/nmt/mallocTracker.inline.hpp b/src/hotspot/share/nmt/mallocTracker.inline.hpp index 243f965a382..19d3775ed77 100644 --- a/src/hotspot/share/nmt/mallocTracker.inline.hpp +++ b/src/hotspot/share/nmt/mallocTracker.inline.hpp @@ -32,7 +32,7 @@ #include "utilities/globalDefinitions.hpp" // Returns true if allocating s bytes on f would trigger either global or the category limit -inline bool MallocMemorySummary::check_exceeds_limit(size_t s, MEMFLAGS f) { +inline bool MallocMemorySummary::check_exceeds_limit(size_t s, MemTag mem_tag) { // Note: checks are ordered to have as little impact as possible on the standard code path, // when MallocLimit is unset, resp. it is set but we have reached no limit yet. @@ -50,12 +50,12 @@ inline bool MallocMemorySummary::check_exceeds_limit(size_t s, MEMFLAGS f) { } } else { // Category Limit? - l = MallocLimitHandler::category_limit(f); + l = MallocLimitHandler::category_limit(mem_tag); if (l->sz > 0) { - const MallocMemory* mm = as_snapshot()->by_type(f); + const MallocMemory* mm = as_snapshot()->by_type(mem_tag); size_t so_far = mm->malloc_size() + mm->arena_size(); if ((so_far + s) > l->sz) { - return category_limit_reached(f, s, so_far, l); + return category_limit_reached(mem_tag, s, so_far, l); } } } @@ -64,8 +64,8 @@ inline bool MallocMemorySummary::check_exceeds_limit(size_t s, MEMFLAGS f) { return false; } -inline bool MallocTracker::check_exceeds_limit(size_t s, MEMFLAGS f) { - return MallocMemorySummary::check_exceeds_limit(s, f); +inline bool MallocTracker::check_exceeds_limit(size_t s, MemTag mem_tag) { + return MallocMemorySummary::check_exceeds_limit(s, mem_tag); } diff --git a/src/hotspot/share/nmt/memBaseline.cpp b/src/hotspot/share/nmt/memBaseline.cpp index 7c7dd3ec24e..6f82b2de9f1 100644 --- a/src/hotspot/share/nmt/memBaseline.cpp +++ b/src/hotspot/share/nmt/memBaseline.cpp @@ -61,11 +61,11 @@ int compare_malloc_site(const MallocSite& s1, const MallocSite& s2) { return s1.call_stack()->compare(*s2.call_stack()); } -// Sort into allocation site addresses and memory type order for baseline comparison +// Sort into allocation site addresses and memory tag order for baseline comparison int compare_malloc_site_and_type(const MallocSite& s1, const MallocSite& s2) { int res = compare_malloc_site(s1, s2); if (res == 0) { - res = (int)(NMTUtil::flag_to_index(s1.flag()) - NMTUtil::flag_to_index(s2.flag())); + res = (int)(NMTUtil::tag_to_index(s1.mem_tag()) - NMTUtil::tag_to_index(s2.mem_tag())); } return res; @@ -207,7 +207,7 @@ bool MemBaseline::aggregate_virtual_memory_allocation_sites() { const ReservedMemoryRegion* rgn; VirtualMemoryAllocationSite* site; while ((rgn = itr.next()) != nullptr) { - VirtualMemoryAllocationSite tmp(*rgn->call_stack(), rgn->flag()); + VirtualMemoryAllocationSite tmp(*rgn->call_stack(), rgn->mem_tag()); site = allocation_sites.find(tmp); if (site == nullptr) { LinkedListNode* node = diff --git a/src/hotspot/share/nmt/memBaseline.hpp b/src/hotspot/share/nmt/memBaseline.hpp index 903f5580511..be389e375e3 100644 --- a/src/hotspot/share/nmt/memBaseline.hpp +++ b/src/hotspot/share/nmt/memBaseline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -53,7 +53,7 @@ class MemBaseline { by_address, // by memory address by_size, // by memory size by_site, // by call site where the memory is allocated from - by_site_and_type // by call site and memory type + by_site_and_type // by call site and memory tag }; private: @@ -144,14 +144,14 @@ class MemBaseline { return bl->_malloc_memory_snapshot.malloc_overhead(); } - MallocMemory* malloc_memory(MEMFLAGS flag) { + MallocMemory* malloc_memory(MemTag mem_tag) { assert(baseline_type() != Not_baselined, "Not yet baselined"); - return _malloc_memory_snapshot.by_type(flag); + return _malloc_memory_snapshot.by_type(mem_tag); } - VirtualMemory* virtual_memory(MEMFLAGS flag) { + VirtualMemory* virtual_memory(MemTag mem_tag) { assert(baseline_type() != Not_baselined, "Not yet baselined"); - return _virtual_memory_snapshot.by_type(flag); + return _virtual_memory_snapshot.by_type(mem_tag); } @@ -203,7 +203,7 @@ class MemBaseline { void malloc_sites_to_size_order(); // Sort allocation sites in call site address order void malloc_sites_to_allocation_site_order(); - // Sort allocation sites in call site address and memory type order + // Sort allocation sites in call site address and memory tag order void malloc_sites_to_allocation_site_and_type_order(); // Sort allocation sites in reserved size order diff --git a/src/hotspot/share/nmt/memMapPrinter.cpp b/src/hotspot/share/nmt/memMapPrinter.cpp index 5f920b102a9..34ddb7a8713 100644 --- a/src/hotspot/share/nmt/memMapPrinter.cpp +++ b/src/hotspot/share/nmt/memMapPrinter.cpp @@ -25,15 +25,15 @@ #include "precompiled.hpp" -#ifdef LINUX +#if defined(LINUX) || defined(_WIN64) #include "gc/shared/collectedHeap.hpp" #include "logging/logAsyncWriter.hpp" #include "memory/allocation.hpp" #include "memory/universe.hpp" #include "memory/resourceArea.hpp" -#include "nmt/memflags.hpp" -#include "nmt/memFlagBitmap.hpp" +#include "nmt/memTag.hpp" +#include "nmt/memTagBitmap.hpp" #include "nmt/memMapPrinter.hpp" #include "nmt/memTracker.hpp" #include "nmt/virtualMemoryTracker.hpp" @@ -50,9 +50,9 @@ /// NMT mechanics // Short, clear, descriptive names for all possible markers. Note that we only expect to see -// those that have been used with mmap. Flags left out are printed with their nmt flag name. +// those that have been used with mmap. Flags left out are printed with their nmt tags name. #define NMT_FLAGS_DO(f) \ - /* flag, short, description */ \ + /* mem_tag, short, description */ \ f(mtGCCardSet, "CARDTBL", "GC Card table") \ f(mtClassShared, "CDS", "CDS archives") \ f(mtClass, "CLASS", "Class Space") \ @@ -67,11 +67,11 @@ f(mtTest, "TEST", "JVM internal test mappings") //end -static const char* get_shortname_for_nmt_flag(MEMFLAGS f) { -#define DO(flag, shortname, text) if (flag == f) return shortname; +static const char* get_shortname_for_mem_tag(MemTag mem_tag) { +#define DO(t, shortname, text) if (t == mem_tag) return shortname; NMT_FLAGS_DO(DO) #undef DO - return NMTUtil::flag_to_enum_name(f); + return NMTUtil::tag_to_enum_name(mem_tag); } /// NMT virtual memory @@ -80,7 +80,7 @@ static bool range_intersects(const void* from1, const void* to1, const void* fro return MAX2(from1, from2) < MIN2(to1, to2); } -// A Cache that correlates range with MEMFLAG, optimized to be iterated quickly +// A Cache that correlates range with MemTag, optimized to be iterated quickly // (cache friendly). class CachedNMTInformation : public VirtualMemoryWalker { struct Range { const void* from; const void* to; }; @@ -88,24 +88,24 @@ class CachedNMTInformation : public VirtualMemoryWalker { // structure would have, and it allows for faster iteration of ranges since more // of them fit into a cache line. Range* _ranges; - MEMFLAGS* _flags; + MemTag* _mem_tags; size_t _count, _capacity; mutable size_t _last; public: - CachedNMTInformation() : _ranges(nullptr), _flags(nullptr), + CachedNMTInformation() : _ranges(nullptr), _mem_tags(nullptr), _count(0), _capacity(0), _last(0) {} ~CachedNMTInformation() { ALLOW_C_FUNCTION(free, ::free(_ranges);) - ALLOW_C_FUNCTION(free, ::free(_flags);) + ALLOW_C_FUNCTION(free, ::free(_mem_tags);) } - bool add(const void* from, const void* to, MEMFLAGS f) { + bool add(const void* from, const void* to, MemTag mem_tag) { // We rely on NMT regions being sorted by base assert(_count == 0 || (from >= _ranges[_count - 1].to), "NMT regions unordered?"); - // we can just fold two regions if they are adjacent and have the same flag. - if (_count > 0 && from == _ranges[_count - 1].to && f == _flags[_count - 1]) { + // we can just fold two regions if they are adjacent and have the same mem_tag. + if (_count > 0 && from == _ranges[_count - 1].to && mem_tag == _mem_tags[_count - 1]) { _ranges[_count - 1].to = to; return true; } @@ -114,8 +114,8 @@ public: const size_t new_capacity = MAX2((size_t)4096, 2 * _capacity); // Unfortunately, we need to allocate manually, raw, since we must prevent NMT deadlocks (ThreadCritical). ALLOW_C_FUNCTION(realloc, _ranges = (Range*)::realloc(_ranges, new_capacity * sizeof(Range));) - ALLOW_C_FUNCTION(realloc, _flags = (MEMFLAGS*)::realloc(_flags, new_capacity * sizeof(MEMFLAGS));) - if (_ranges == nullptr || _flags == nullptr) { + ALLOW_C_FUNCTION(realloc, _mem_tags = (MemTag*)::realloc(_mem_tags, new_capacity * sizeof(MemTag));) + if (_ranges == nullptr || _mem_tags == nullptr) { // In case of OOM lets make no fuss. Just return. return false; } @@ -123,14 +123,14 @@ public: } assert(_capacity > _count, "Sanity"); _ranges[_count] = Range { from, to }; - _flags[_count] = f; + _mem_tags[_count] = mem_tag; _count++; return true; } // Given a vma [from, to), find all regions that intersect with this vma and // return their collective flags. - MemFlagBitmap lookup(const void* from, const void* to) const { + MemTagBitmap lookup(const void* from, const void* to) const { assert(from <= to, "Sanity"); // We optimize for sequential lookups. Since this class is used when a list // of OS mappings is scanned (VirtualQuery, /proc/pid/maps), and these lists @@ -139,10 +139,10 @@ public: // the range is to the right of the given section, we need to re-start the search _last = 0; } - MemFlagBitmap bm; + MemTagBitmap bm; for(uintx i = _last; i < _count; i++) { if (range_intersects(from, to, _ranges[i].from, _ranges[i].to)) { - bm.set_flag(_flags[i]); + bm.set_tag(_mem_tags[i]); } else if (to <= _ranges[i].from) { _last = i; break; @@ -153,7 +153,7 @@ public: bool do_allocation_site(const ReservedMemoryRegion* rgn) override { // Cancel iteration if we run out of memory (add returns false); - return add(rgn->base(), rgn->end(), rgn->flag()); + return add(rgn->base(), rgn->end(), rgn->mem_tag()); } // Iterate all NMT virtual memory regions and fill this cache. @@ -247,16 +247,16 @@ bool MappingPrintSession::print_nmt_info_for_region(const void* vma_from, const // print NMT information, if available if (MemTracker::enabled()) { // Correlate vma region (from, to) with NMT region(s) we collected previously. - const MemFlagBitmap flags = _nmt_info.lookup(vma_from, vma_to); + const MemTagBitmap flags = _nmt_info.lookup(vma_from, vma_to); if (flags.has_any()) { - for (int i = 0; i < mt_number_of_types; i++) { - const MEMFLAGS flag = (MEMFLAGS)i; - if (flags.has_flag(flag)) { + for (int i = 0; i < mt_number_of_tags; i++) { + const MemTag mem_tag = (MemTag)i; + if (flags.has_tag(mem_tag)) { if (num_printed > 0) { _out->put(','); } - _out->print("%s", get_shortname_for_nmt_flag(flag)); - if (flag == mtThreadStack) { + _out->print("%s", get_shortname_for_mem_tag(mem_tag)); + if (mem_tag == mtThreadStack) { print_thread_details_for_supposed_stack_address(vma_from, vma_to, _out); } num_printed++; diff --git a/src/hotspot/share/nmt/memMapPrinter.hpp b/src/hotspot/share/nmt/memMapPrinter.hpp index aa35a830001..7f3ef9abca8 100644 --- a/src/hotspot/share/nmt/memMapPrinter.hpp +++ b/src/hotspot/share/nmt/memMapPrinter.hpp @@ -27,10 +27,10 @@ #define SHARE_SERVICES_MEMMAPPRINTER_HPP #include "memory/allStatic.hpp" -#include "nmt/memflags.hpp" +#include "nmt/memTag.hpp" #include "utilities/globalDefinitions.hpp" -#ifdef LINUX +#if defined(LINUX) || defined(_WIN64) class outputStream; class CachedNMTInformation; diff --git a/src/hotspot/share/nmt/memReporter.cpp b/src/hotspot/share/nmt/memReporter.cpp index d53782dfdaa..6ce6206ebcc 100644 --- a/src/hotspot/share/nmt/memReporter.cpp +++ b/src/hotspot/share/nmt/memReporter.cpp @@ -26,7 +26,7 @@ #include "memory/metaspace.hpp" #include "memory/metaspaceUtils.hpp" #include "nmt/mallocTracker.hpp" -#include "nmt/memflags.hpp" +#include "nmt/memTag.hpp" #include "nmt/memReporter.hpp" #include "nmt/memoryFileTracker.hpp" #include "nmt/threadStackTracker.hpp" @@ -70,17 +70,17 @@ void MemReporterBase::print_total(size_t reserved, size_t committed, size_t peak } } -void MemReporterBase::print_malloc(const MemoryCounter* c, MEMFLAGS flag) const { +void MemReporterBase::print_malloc(const MemoryCounter* c, MemTag mem_tag) const { const char* scale = current_scale(); outputStream* out = output(); - const char* alloc_type = (flag == mtThreadStack) ? "" : "malloc="; + const char* alloc_type = (mem_tag == mtThreadStack) ? "" : "malloc="; const size_t amount = c->size(); const size_t count = c->count(); - if (flag != mtNone) { + if (mem_tag != mtNone) { out->print("(%s" SIZE_FORMAT "%s type=%s", alloc_type, - amount_in_current_scale(amount), scale, NMTUtil::flag_to_name(flag)); + amount_in_current_scale(amount), scale, NMTUtil::tag_to_name(mem_tag)); } else { out->print("(%s" SIZE_FORMAT "%s", alloc_type, amount_in_current_scale(amount), scale); @@ -176,31 +176,31 @@ void MemSummaryReporter::report() { out->cr(); out->cr(); - // Summary by memory type - for (int index = 0; index < mt_number_of_types; index ++) { - MEMFLAGS flag = NMTUtil::index_to_flag(index); + // Summary by memory tag + for (int index = 0; index < mt_number_of_tags; index ++) { + MemTag mem_tag = NMTUtil::index_to_tag(index); // thread stack is reported as part of thread category - if (flag == mtThreadStack) continue; - MallocMemory* malloc_memory = _malloc_snapshot->by_type(flag); - VirtualMemory* virtual_memory = _vm_snapshot->by_type(flag); + if (mem_tag == mtThreadStack) continue; + MallocMemory* malloc_memory = _malloc_snapshot->by_type(mem_tag); + VirtualMemory* virtual_memory = _vm_snapshot->by_type(mem_tag); - report_summary_of_type(flag, malloc_memory, virtual_memory); + report_summary_of_type(mem_tag, malloc_memory, virtual_memory); } } -void MemSummaryReporter::report_summary_of_type(MEMFLAGS flag, +void MemSummaryReporter::report_summary_of_type(MemTag mem_tag, MallocMemory* malloc_memory, VirtualMemory* virtual_memory) { size_t reserved_amount = reserved_total (malloc_memory, virtual_memory); size_t committed_amount = committed_total(malloc_memory, virtual_memory); // Count thread's native stack in "Thread" category - if (flag == mtThread) { + if (mem_tag == mtThread) { const VirtualMemory* thread_stack_usage = (const VirtualMemory*)_vm_snapshot->by_type(mtThreadStack); reserved_amount += thread_stack_usage->reserved(); committed_amount += thread_stack_usage->committed(); - } else if (flag == mtNMT) { + } else if (mem_tag == mtNMT) { // Count malloc headers in "NMT" category reserved_amount += _malloc_snapshot->malloc_overhead(); committed_amount += _malloc_snapshot->malloc_overhead(); @@ -219,10 +219,10 @@ void MemSummaryReporter::report_summary_of_type(MEMFLAGS flag, outputStream* out = output(); const char* scale = current_scale(); constexpr int indent = 28; - out->print("-%*s (", indent - 2, NMTUtil::flag_to_name(flag)); + out->print("-%*s (", indent - 2, NMTUtil::tag_to_name(mem_tag)); print_total(reserved_amount, committed_amount); #if INCLUDE_CDS - if (flag == mtClassShared) { + if (mem_tag == mtClassShared) { size_t read_only_bytes = FileMapInfo::readonly_total(); output()->print(", readonly=" SIZE_FORMAT "%s", amount_in_current_scale(read_only_bytes), scale); @@ -232,12 +232,12 @@ void MemSummaryReporter::report_summary_of_type(MEMFLAGS flag, streamIndentor si(out, indent); - if (flag == mtClass) { + if (mem_tag == mtClass) { // report class count out->print_cr("(classes #" SIZE_FORMAT ")", (_instance_class_count + _array_class_count)); out->print_cr("( instance classes #" SIZE_FORMAT ", array classes #" SIZE_FORMAT ")", _instance_class_count, _array_class_count); - } else if (flag == mtThread) { + } else if (mem_tag == mtThread) { const VirtualMemory* thread_stack_usage = _vm_snapshot->by_type(mtThreadStack); // report thread count @@ -263,11 +263,11 @@ void MemSummaryReporter::report_summary_of_type(MEMFLAGS flag, out->cr(); } - if (flag == mtNMT && + if (mem_tag == mtNMT && amount_in_current_scale(_malloc_snapshot->malloc_overhead()) > 0) { out->print_cr("(tracking overhead=" SIZE_FORMAT "%s)", amount_in_current_scale(_malloc_snapshot->malloc_overhead()), scale); - } else if (flag == mtClass) { + } else if (mem_tag == mtClass) { // Metadata information report_metadata(Metaspace::NonClassType); if (Metaspace::using_class_space()) { @@ -338,12 +338,12 @@ int MemDetailReporter::report_malloc_sites() { } const NativeCallStack* stack = malloc_site->call_stack(); _stackprinter.print_stack(stack); - MEMFLAGS flag = malloc_site->flag(); - assert(NMTUtil::flag_is_valid(flag) && flag != mtNone, - "Must have a valid memory type"); + MemTag mem_tag = malloc_site->mem_tag(); + assert(NMTUtil::tag_is_valid(mem_tag) && mem_tag != mtNone, + "Must have a valid memory tag"); INDENT_BY(29, out->print("("); - print_malloc(malloc_site->counter(), flag); + print_malloc(malloc_site->counter(), mem_tag); out->print_cr(")"); ) out->cr(); @@ -378,9 +378,9 @@ int MemDetailReporter::report_virtual_memory_allocation_sites() { INDENT_BY(29, out->print("("); print_total(virtual_memory_site->reserved(), virtual_memory_site->committed()); - const MEMFLAGS flag = virtual_memory_site->flag(); - if (flag != mtNone) { - out->print(" Type=%s", NMTUtil::flag_to_name(flag)); + const MemTag mem_tag = virtual_memory_site->mem_tag(); + if (mem_tag != mtNone) { + out->print(" Type=%s", NMTUtil::tag_to_name(mem_tag)); } out->print_cr(")"); ) @@ -423,7 +423,7 @@ void MemDetailReporter::report_virtual_memory_region(const ReservedMemoryRegion* const char* region_type = (all_committed ? "reserved and committed" : "reserved"); out->cr(); print_virtual_memory_region(region_type, reserved_rgn->base(), reserved_rgn->size()); - out->print(" for %s", NMTUtil::flag_to_name(reserved_rgn->flag())); + out->print(" for %s", NMTUtil::tag_to_name(reserved_rgn->mem_tag())); if (stack->is_empty()) { out->cr(); } else { @@ -519,31 +519,31 @@ void MemSummaryDiffReporter::report_diff() { out->cr(); out->cr(); - // Summary diff by memory type - for (int index = 0; index < mt_number_of_types; index ++) { - MEMFLAGS flag = NMTUtil::index_to_flag(index); + // Summary diff by memory tag + for (int index = 0; index < mt_number_of_tags; index ++) { + MemTag mem_tag = NMTUtil::index_to_tag(index); // thread stack is reported as part of thread category - if (flag == mtThreadStack) continue; - diff_summary_of_type(flag, - _early_baseline.malloc_memory(flag), - _early_baseline.virtual_memory(flag), + if (mem_tag == mtThreadStack) continue; + diff_summary_of_type(mem_tag, + _early_baseline.malloc_memory(mem_tag), + _early_baseline.virtual_memory(mem_tag), _early_baseline.metaspace_stats(), - _current_baseline.malloc_memory(flag), - _current_baseline.virtual_memory(flag), + _current_baseline.malloc_memory(mem_tag), + _current_baseline.virtual_memory(mem_tag), _current_baseline.metaspace_stats()); } } void MemSummaryDiffReporter::print_malloc_diff(size_t current_amount, size_t current_count, - size_t early_amount, size_t early_count, MEMFLAGS flags) const { + size_t early_amount, size_t early_count, MemTag mem_tag) const { const char* scale = current_scale(); outputStream* out = output(); - const char* alloc_type = (flags == mtThread) ? "" : "malloc="; + const char* alloc_tag = (mem_tag == mtThread) ? "" : "malloc="; - out->print("%s" SIZE_FORMAT "%s", alloc_type, amount_in_current_scale(current_amount), scale); + out->print("%s" SIZE_FORMAT "%s", alloc_tag, amount_in_current_scale(current_amount), scale); // Report type only if it is valid and not under "thread" category - if (flags != mtNone && flags != mtThread) { - out->print(" type=%s", NMTUtil::flag_to_name(flags)); + if (mem_tag != mtNone && mem_tag != mtThread) { + out->print(" type=%s", NMTUtil::tag_to_name(mem_tag)); } int64_t amount_diff = diff_in_current_scale(current_amount, early_amount); @@ -594,7 +594,7 @@ void MemSummaryDiffReporter::print_virtual_memory_diff(size_t current_reserved, } -void MemSummaryDiffReporter::diff_summary_of_type(MEMFLAGS flag, +void MemSummaryDiffReporter::diff_summary_of_type(MemTag mem_tag, const MallocMemory* early_malloc, const VirtualMemory* early_vm, const MetaspaceCombinedStats& early_ms, const MallocMemory* current_malloc, const VirtualMemory* current_vm, @@ -613,7 +613,7 @@ void MemSummaryDiffReporter::diff_summary_of_type(MEMFLAGS flag, size_t early_committed_amount = committed_total(early_malloc, early_vm); // Adjust virtual memory total - if (flag == mtThread) { + if (mem_tag == mtThread) { const VirtualMemory* early_thread_stack_usage = _early_baseline.virtual_memory(mtThreadStack); const VirtualMemory* current_thread_stack_usage = @@ -624,7 +624,7 @@ void MemSummaryDiffReporter::diff_summary_of_type(MEMFLAGS flag, current_reserved_amount += current_thread_stack_usage->reserved(); current_committed_amount += current_thread_stack_usage->committed(); - } else if (flag == mtNMT) { + } else if (mem_tag == mtNMT) { early_reserved_amount += _early_baseline.malloc_tracking_overhead(); early_committed_amount += _early_baseline.malloc_tracking_overhead(); @@ -636,7 +636,7 @@ void MemSummaryDiffReporter::diff_summary_of_type(MEMFLAGS flag, diff_in_current_scale(current_reserved_amount, early_reserved_amount) != 0) { // print summary line - out->print("-%*s (", indent - 2, NMTUtil::flag_to_name(flag)); + out->print("-%*s (", indent - 2, NMTUtil::tag_to_name(mem_tag)); print_virtual_memory_diff(current_reserved_amount, current_committed_amount, early_reserved_amount, early_committed_amount); out->print_cr(")"); @@ -644,7 +644,7 @@ void MemSummaryDiffReporter::diff_summary_of_type(MEMFLAGS flag, streamIndentor si(out, indent); // detail lines - if (flag == mtClass) { + if (mem_tag == mtClass) { // report class count out->print("(classes #" SIZE_FORMAT, _current_baseline.class_count()); const ssize_t class_count_diff = @@ -668,7 +668,7 @@ void MemSummaryDiffReporter::diff_summary_of_type(MEMFLAGS flag, } out->print_cr(")"); - } else if (flag == mtThread) { + } else if (mem_tag == mtThread) { // report thread count out->print("(threads #" SIZE_FORMAT, _current_baseline.thread_count()); const ssize_t thread_count_diff = counter_diff(_current_baseline.thread_count(), _early_baseline.thread_count()); @@ -696,7 +696,7 @@ void MemSummaryDiffReporter::diff_summary_of_type(MEMFLAGS flag, if (amount_in_current_scale(current_malloc_amount) > 0 || diff_in_current_scale(current_malloc_amount, early_malloc_amount) != 0) { out->print("("); - print_malloc_diff(current_malloc_amount, (flag == mtChunk) ? 0 : current_malloc->malloc_count(), + print_malloc_diff(current_malloc_amount, (mem_tag == mtChunk) ? 0 : current_malloc->malloc_count(), early_malloc_amount, early_malloc->malloc_count(), mtNone); out->print_cr(")"); } @@ -720,7 +720,7 @@ void MemSummaryDiffReporter::diff_summary_of_type(MEMFLAGS flag, } // Report native memory tracking overhead - if (flag == mtNMT) { + if (mem_tag == mtNMT) { size_t current_tracking_overhead = amount_in_current_scale(_current_baseline.malloc_tracking_overhead()); size_t early_tracking_overhead = amount_in_current_scale(_early_baseline.malloc_tracking_overhead()); @@ -733,7 +733,7 @@ void MemSummaryDiffReporter::diff_summary_of_type(MEMFLAGS flag, out->print(" " INT64_PLUS_FORMAT "%s", overhead_diff, scale); } out->print_cr(")"); - } else if (flag == mtClass) { + } else if (mem_tag == mtClass) { print_metaspace_diff(current_ms, early_ms); } out->cr(); @@ -847,9 +847,9 @@ void MemDetailDiffReporter::diff_virtual_memory_sites() const { } else if (compVal > 0) { old_virtual_memory_site(early_site); early_site = early_itr.next(); - } else if (early_site->flag() != current_site->flag()) { - // This site was originally allocated with one flag, then released, - // then re-allocated at the same site (as far as we can tell) with a different flag. + } else if (early_site->mem_tag() != current_site->mem_tag()) { + // This site was originally allocated with one memory tag, then released, + // then re-allocated at the same site (as far as we can tell) with a different memory tag. old_virtual_memory_site(early_site); early_site = early_itr.next(); new_virtual_memory_site(current_site); @@ -866,29 +866,29 @@ void MemDetailDiffReporter::diff_virtual_memory_sites() const { void MemDetailDiffReporter::new_malloc_site(const MallocSite* malloc_site) const { diff_malloc_site(malloc_site->call_stack(), malloc_site->size(), malloc_site->count(), - 0, 0, malloc_site->flag()); + 0, 0, malloc_site->mem_tag()); } void MemDetailDiffReporter::old_malloc_site(const MallocSite* malloc_site) const { diff_malloc_site(malloc_site->call_stack(), 0, 0, malloc_site->size(), - malloc_site->count(), malloc_site->flag()); + malloc_site->count(), malloc_site->mem_tag()); } void MemDetailDiffReporter::diff_malloc_site(const MallocSite* early, const MallocSite* current) const { - if (early->flag() != current->flag()) { + if (early->mem_tag() != current->mem_tag()) { // If malloc site type changed, treat it as deallocation of old type and // allocation of new type. old_malloc_site(early); new_malloc_site(current); } else { diff_malloc_site(current->call_stack(), current->size(), current->count(), - early->size(), early->count(), early->flag()); + early->size(), early->count(), early->mem_tag()); } } void MemDetailDiffReporter::diff_malloc_site(const NativeCallStack* stack, size_t current_size, - size_t current_count, size_t early_size, size_t early_count, MEMFLAGS flags) const { + size_t current_count, size_t early_size, size_t early_count, MemTag mem_tag) const { outputStream* out = output(); assert(stack != nullptr, "null stack"); @@ -900,7 +900,7 @@ void MemDetailDiffReporter::diff_malloc_site(const NativeCallStack* stack, size_ _stackprinter.print_stack(stack); INDENT_BY(28, out->print("("); - print_malloc_diff(current_size, current_count, early_size, early_count, flags); + print_malloc_diff(current_size, current_count, early_size, early_count, mem_tag); out->print_cr(")"); ) out->cr(); @@ -909,21 +909,21 @@ void MemDetailDiffReporter::diff_malloc_site(const NativeCallStack* stack, size_ void MemDetailDiffReporter::new_virtual_memory_site(const VirtualMemoryAllocationSite* site) const { - diff_virtual_memory_site(site->call_stack(), site->reserved(), site->committed(), 0, 0, site->flag()); + diff_virtual_memory_site(site->call_stack(), site->reserved(), site->committed(), 0, 0, site->mem_tag()); } void MemDetailDiffReporter::old_virtual_memory_site(const VirtualMemoryAllocationSite* site) const { - diff_virtual_memory_site(site->call_stack(), 0, 0, site->reserved(), site->committed(), site->flag()); + diff_virtual_memory_site(site->call_stack(), 0, 0, site->reserved(), site->committed(), site->mem_tag()); } void MemDetailDiffReporter::diff_virtual_memory_site(const VirtualMemoryAllocationSite* early, const VirtualMemoryAllocationSite* current) const { diff_virtual_memory_site(current->call_stack(), current->reserved(), current->committed(), - early->reserved(), early->committed(), current->flag()); + early->reserved(), early->committed(), current->mem_tag()); } void MemDetailDiffReporter::diff_virtual_memory_site(const NativeCallStack* stack, size_t current_reserved, - size_t current_committed, size_t early_reserved, size_t early_committed, MEMFLAGS flag) const { + size_t current_committed, size_t early_reserved, size_t early_committed, MemTag mem_tag) const { outputStream* out = output(); // no change @@ -936,8 +936,8 @@ void MemDetailDiffReporter::diff_virtual_memory_site(const NativeCallStack* stac INDENT_BY(28, out->print("(mmap: "); print_virtual_memory_diff(current_reserved, current_committed, early_reserved, early_committed); - if (flag != mtNone) { - out->print(" Type=%s", NMTUtil::flag_to_name(flag)); + if (mem_tag != mtNone) { + out->print(" Type=%s", NMTUtil::tag_to_name(mem_tag)); } out->print_cr(")"); ) diff --git a/src/hotspot/share/nmt/memReporter.hpp b/src/hotspot/share/nmt/memReporter.hpp index 095c0550939..773377b5e20 100644 --- a/src/hotspot/share/nmt/memReporter.hpp +++ b/src/hotspot/share/nmt/memReporter.hpp @@ -108,7 +108,7 @@ class MemReporterBase : public StackObj { // Print summary total, malloc and virtual memory void print_total(size_t reserved, size_t committed, size_t peak = 0) const; - void print_malloc(const MemoryCounter* c, MEMFLAGS flag = mtNone) const; + void print_malloc(const MemoryCounter* c, MemTag mem_tag = mtNone) const; void print_virtual_memory(size_t reserved, size_t committed, size_t peak) const; void print_arena(const MemoryCounter* c) const; @@ -138,8 +138,8 @@ class MemSummaryReporter : public MemReporterBase { // Generate summary report virtual void report(); private: - // Report summary for each memory type - void report_summary_of_type(MEMFLAGS type, MallocMemory* malloc_memory, + // Report summary for each memory tag + void report_summary_of_type(MemTag mem_tag, MallocMemory* malloc_memory, VirtualMemory* virtual_memory); void report_metadata(Metaspace::MetadataType type) const; @@ -203,8 +203,8 @@ class MemSummaryDiffReporter : public MemReporterBase { virtual void report_diff(); private: - // report the comparison of each memory type - void diff_summary_of_type(MEMFLAGS type, + // report the comparison of each mem_tag + void diff_summary_of_type(MemTag mem_tag, const MallocMemory* early_malloc, const VirtualMemory* early_vm, const MetaspaceCombinedStats& early_ms, const MallocMemory* current_malloc, const VirtualMemory* current_vm, @@ -212,7 +212,7 @@ class MemSummaryDiffReporter : public MemReporterBase { protected: void print_malloc_diff(size_t current_amount, size_t current_count, - size_t early_amount, size_t early_count, MEMFLAGS flags) const; + size_t early_amount, size_t early_count, MemTag mem_tag) const; void print_virtual_memory_diff(size_t current_reserved, size_t current_committed, size_t early_reserved, size_t early_committed) const; void print_arena_diff(size_t current_amount, size_t current_count, @@ -262,9 +262,9 @@ class MemDetailDiffReporter : public MemSummaryDiffReporter { const VirtualMemoryAllocationSite* current) const; void diff_malloc_site(const NativeCallStack* stack, size_t current_size, - size_t currrent_count, size_t early_size, size_t early_count, MEMFLAGS flags) const; + size_t currrent_count, size_t early_size, size_t early_count, MemTag mem_tag) const; void diff_virtual_memory_site(const NativeCallStack* stack, size_t current_reserved, - size_t current_committed, size_t early_reserved, size_t early_committed, MEMFLAGS flag) const; + size_t current_committed, size_t early_reserved, size_t early_committed, MemTag mem_tag) const; }; #endif // SHARE_NMT_MEMREPORTER_HPP diff --git a/src/hotspot/share/nmt/memflags.hpp b/src/hotspot/share/nmt/memTag.hpp similarity index 84% rename from src/hotspot/share/nmt/memflags.hpp rename to src/hotspot/share/nmt/memTag.hpp index 530c9ae9d95..9255645638d 100644 --- a/src/hotspot/share/nmt/memflags.hpp +++ b/src/hotspot/share/nmt/memTag.hpp @@ -22,13 +22,13 @@ * */ -#ifndef SHARE_NMT_MEMFLAGS_HPP -#define SHARE_NMT_MEMFLAGS_HPP +#ifndef SHARE_NMT_MEM_TAG_HPP +#define SHARE_NMT_MEM_TAG_HPP #include "utilities/globalDefinitions.hpp" -#define MEMORY_TYPES_DO(f) \ - /* Memory type by sub systems. It occupies lower byte. */ \ +#define MEMORY_TAG_DO(f) \ + /* Memory tag by sub systems. It occupies lower byte. */ \ f(mtJavaHeap, "Java Heap") /* Java heap */ \ f(mtClass, "Class") /* Java classes */ \ f(mtThread, "Thread") /* thread objects */ \ @@ -61,22 +61,22 @@ f(mtNone, "Unknown") \ //end -#define MEMORY_TYPE_DECLARE_ENUM(type, human_readable) \ - type, +#define MEMORY_TAG_DECLARE_ENUM(mem_tag, human_readable) \ +mem_tag, -enum class MEMFLAGS : uint8_t { - MEMORY_TYPES_DO(MEMORY_TYPE_DECLARE_ENUM) - mt_number_of_types // number of memory types (mtDontTrack - // is not included as validate type) +enum class MemTag : uint8_t { + MEMORY_TAG_DO(MEMORY_TAG_DECLARE_ENUM) + mt_number_of_tags // number of memory tags (mtDontTrack + // is not included as validate tag) }; -#define MEMORY_TYPE_SHORTNAME(type, human_readable) \ - constexpr MEMFLAGS type = MEMFLAGS::type; +#define MEMORY_TAG_SHORTNAME(mem_tag, human_readable) \ + constexpr MemTag mem_tag = MemTag::mem_tag; -// Generate short aliases for the enum values. E.g. mtGC instead of MEMFLAGS::mtGC. -MEMORY_TYPES_DO(MEMORY_TYPE_SHORTNAME) +// Generate short aliases for the enum values. E.g. mtGC instead of MemTag::mtGC. +MEMORY_TAG_DO(MEMORY_TAG_SHORTNAME) // Make an int version of the sentinel end value. -constexpr int mt_number_of_types = static_cast(MEMFLAGS::mt_number_of_types); +constexpr int mt_number_of_tags = static_cast(MemTag::mt_number_of_tags); -#endif // SHARE_NMT_MEMFLAGS_HPP +#endif // SHARE_NMT_MEM_TAG_HPP diff --git a/src/hotspot/share/nmt/memFlagBitmap.hpp b/src/hotspot/share/nmt/memTagBitmap.hpp similarity index 75% rename from src/hotspot/share/nmt/memFlagBitmap.hpp rename to src/hotspot/share/nmt/memTagBitmap.hpp index 0464179948b..f65dce60fa6 100644 --- a/src/hotspot/share/nmt/memFlagBitmap.hpp +++ b/src/hotspot/share/nmt/memTagBitmap.hpp @@ -23,34 +23,34 @@ * */ -#ifndef SHARE_NMT_MEMFLAGBITMAP_HPP -#define SHARE_NMT_MEMFLAGBITMAP_HPP +#ifndef SHARE_NMT_MEMTAGBITMAP_HPP +#define SHARE_NMT_MEMTAGBITMAP_HPP -#include "nmt/memflags.hpp" +#include "nmt/memTag.hpp" #include "utilities/debug.hpp" #include "utilities/globalDefinitions.hpp" -class MemFlagBitmap { +class MemTagBitmap { uint32_t _v; - STATIC_ASSERT(sizeof(_v) * BitsPerByte >= mt_number_of_types); + STATIC_ASSERT(sizeof(_v) * BitsPerByte >= mt_number_of_tags); public: - MemFlagBitmap(uint32_t v = 0) : _v(v) {} - MemFlagBitmap(const MemFlagBitmap& o) : _v(o._v) {} + MemTagBitmap(uint32_t v = 0) : _v(v) {} + MemTagBitmap(const MemTagBitmap& o) : _v(o._v) {} uint32_t raw_value() const { return _v; } - void set_flag(MEMFLAGS f) { - const int bitno = (int)f; + void set_tag(MemTag mem_tag) { + const int bitno = (int)mem_tag; _v |= nth_bit(bitno); } - bool has_flag(MEMFLAGS f) const { - const int bitno = (int)f; + bool has_tag(MemTag mem_tag) const { + const int bitno = (int)mem_tag; return _v & nth_bit(bitno); } bool has_any() const { return _v > 0; } }; -#endif // SHARE_NMT_NMTUSAGE_HPP +#endif // SHARE_NMT_MEMTAGBITMAP_HPP diff --git a/src/hotspot/share/nmt/memTracker.cpp b/src/hotspot/share/nmt/memTracker.cpp index f40f9428443..fb9c9a50db1 100644 --- a/src/hotspot/share/nmt/memTracker.cpp +++ b/src/hotspot/share/nmt/memTracker.cpp @@ -63,7 +63,7 @@ void MemTracker::initialize() { // Memory type is encoded into tracking header as a byte field, // make sure that we don't overflow it. - STATIC_ASSERT(mt_number_of_types <= max_jubyte); + STATIC_ASSERT(mt_number_of_tags <= max_jubyte); if (level > NMT_off) { if (!MallocTracker::initialize(level) || diff --git a/src/hotspot/share/nmt/memTracker.hpp b/src/hotspot/share/nmt/memTracker.hpp index 74aa9f803b1..6ba1db2e7ff 100644 --- a/src/hotspot/share/nmt/memTracker.hpp +++ b/src/hotspot/share/nmt/memTracker.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -72,14 +72,14 @@ class MemTracker : AllStatic { // Per-malloc overhead incurred by NMT, depending on the current NMT level static size_t overhead_per_malloc() { - return enabled() ? MallocTracker::overhead_per_malloc : 0; + return enabled() ? MallocTracker::overhead_per_malloc() : 0; } - static inline void* record_malloc(void* mem_base, size_t size, MEMFLAGS flag, + static inline void* record_malloc(void* mem_base, size_t size, MemTag mem_tag, const NativeCallStack& stack) { assert(mem_base != nullptr, "caller should handle null"); if (enabled()) { - return MallocTracker::record_malloc(mem_base, size, flag, stack); + return MallocTracker::record_malloc(mem_base, size, mem_tag, stack); } return mem_base; } @@ -99,34 +99,34 @@ class MemTracker : AllStatic { } // Record creation of an arena - static inline void record_new_arena(MEMFLAGS flag) { + static inline void record_new_arena(MemTag mem_tag) { if (!enabled()) return; - MallocTracker::record_new_arena(flag); + MallocTracker::record_new_arena(mem_tag); } // Record destruction of an arena - static inline void record_arena_free(MEMFLAGS flag) { + static inline void record_arena_free(MemTag mem_tag) { if (!enabled()) return; - MallocTracker::record_arena_free(flag); + MallocTracker::record_arena_free(mem_tag); } // Record arena size change. Arena size is the size of all arena // chunks that are backing up the arena. - static inline void record_arena_size_change(ssize_t diff, MEMFLAGS flag) { + static inline void record_arena_size_change(ssize_t diff, MemTag mem_tag) { if (!enabled()) return; - MallocTracker::record_arena_size_change(diff, flag); + MallocTracker::record_arena_size_change(diff, mem_tag); } // Note: virtual memory operations should only ever be called after NMT initialization // (we do not do any reservations before that). static inline void record_virtual_memory_reserve(void* addr, size_t size, const NativeCallStack& stack, - MEMFLAGS flag = mtNone) { + MemTag mem_tag = mtNone) { assert_post_init(); if (!enabled()) return; if (addr != nullptr) { ThreadCritical tc; - VirtualMemoryTracker::add_reserved_region((address)addr, size, stack, flag); + VirtualMemoryTracker::add_reserved_region((address)addr, size, stack, mem_tag); } } @@ -147,12 +147,12 @@ class MemTracker : AllStatic { } static inline void record_virtual_memory_reserve_and_commit(void* addr, size_t size, - const NativeCallStack& stack, MEMFLAGS flag = mtNone) { + const NativeCallStack& stack, MemTag mem_tag = mtNone) { assert_post_init(); if (!enabled()) return; if (addr != nullptr) { ThreadCritical tc; - VirtualMemoryTracker::add_reserved_region((address)addr, size, stack, flag); + VirtualMemoryTracker::add_reserved_region((address)addr, size, stack, mem_tag); VirtualMemoryTracker::add_committed_region((address)addr, size, stack); } } @@ -183,12 +183,12 @@ class MemTracker : AllStatic { } static inline void allocate_memory_in(MemoryFileTracker::MemoryFile* file, size_t offset, size_t size, - const NativeCallStack& stack, MEMFLAGS flag) { + const NativeCallStack& stack, MemTag mem_tag) { assert_post_init(); if (!enabled()) return; assert(file != nullptr, "must be"); MemoryFileTracker::Instance::Locker lock; - MemoryFileTracker::Instance::allocate_memory(file, offset, size, stack, flag); + MemoryFileTracker::Instance::allocate_memory(file, offset, size, stack, mem_tag); } static inline void free_memory_in(MemoryFileTracker::MemoryFile* file, @@ -206,21 +206,21 @@ class MemTracker : AllStatic { // // The two new memory regions will be both registered under stack and // memory flags of the original region. - static inline void record_virtual_memory_split_reserved(void* addr, size_t size, size_t split, MEMFLAGS flag, MEMFLAGS split_flag) { + static inline void record_virtual_memory_split_reserved(void* addr, size_t size, size_t split, MemTag mem_tag, MemTag split_tag) { assert_post_init(); if (!enabled()) return; if (addr != nullptr) { ThreadCritical tc; - VirtualMemoryTracker::split_reserved_region((address)addr, size, split, flag, split_flag); + VirtualMemoryTracker::split_reserved_region((address)addr, size, split, mem_tag, split_tag); } } - static inline void record_virtual_memory_type(void* addr, MEMFLAGS flag) { + static inline void record_virtual_memory_tag(void* addr, MemTag mem_tag) { assert_post_init(); if (!enabled()) return; if (addr != nullptr) { ThreadCritical tc; - VirtualMemoryTracker::set_reserved_region_type((address)addr, flag); + VirtualMemoryTracker::set_reserved_region_type((address)addr, mem_tag); } } @@ -262,8 +262,8 @@ class MemTracker : AllStatic { static void tuning_statistics(outputStream* out); // MallocLimt: Given an allocation size s, check if mallocing this much - // under category f would hit either the global limit or the limit for category f. - static inline bool check_exceeds_limit(size_t s, MEMFLAGS f); + // for MemTag would hit either the global limit or the limit for MemTag. + static inline bool check_exceeds_limit(size_t s, MemTag mem_tag); // Given an unknown pointer, check if it points into a known region; print region if found // and return true; false if not found. diff --git a/src/hotspot/share/nmt/memTracker.inline.hpp b/src/hotspot/share/nmt/memTracker.inline.hpp index 500f2a75d8c..a850c6b07fd 100644 --- a/src/hotspot/share/nmt/memTracker.inline.hpp +++ b/src/hotspot/share/nmt/memTracker.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2023 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -30,11 +30,11 @@ #include "nmt/mallocTracker.inline.hpp" -inline bool MemTracker::check_exceeds_limit(size_t s, MEMFLAGS f) { +inline bool MemTracker::check_exceeds_limit(size_t s, MemTag mem_tag) { if (!enabled()) { return false; } - return MallocTracker::check_exceeds_limit(s, f); + return MallocTracker::check_exceeds_limit(s, mem_tag); } #endif // SHARE_NMT_MEMTRACKER_INLINE_HPP diff --git a/src/hotspot/share/nmt/memoryFileTracker.cpp b/src/hotspot/share/nmt/memoryFileTracker.cpp index 25f2667e5c3..ede483ed337 100644 --- a/src/hotspot/share/nmt/memoryFileTracker.cpp +++ b/src/hotspot/share/nmt/memoryFileTracker.cpp @@ -42,23 +42,23 @@ MemoryFileTracker::MemoryFileTracker(bool is_detailed_mode) void MemoryFileTracker::allocate_memory(MemoryFile* file, size_t offset, size_t size, const NativeCallStack& stack, - MEMFLAGS flag) { + MemTag mem_tag) { NativeCallStackStorage::StackIndex sidx = _stack_storage.push(stack); - VMATree::RegionData regiondata(sidx, flag); + VMATree::RegionData regiondata(sidx, mem_tag); VMATree::SummaryDiff diff = file->_tree.commit_mapping(offset, size, regiondata); - for (int i = 0; i < mt_number_of_types; i++) { - VirtualMemory* summary = file->_summary.by_type(NMTUtil::index_to_flag(i)); - summary->reserve_memory(diff.flag[i].commit); - summary->commit_memory(diff.flag[i].commit); + for (int i = 0; i < mt_number_of_tags; i++) { + VirtualMemory* summary = file->_summary.by_type(NMTUtil::index_to_tag(i)); + summary->reserve_memory(diff.tag[i].commit); + summary->commit_memory(diff.tag[i].commit); } } void MemoryFileTracker::free_memory(MemoryFile* file, size_t offset, size_t size) { VMATree::SummaryDiff diff = file->_tree.release_mapping(offset, size); - for (int i = 0; i < mt_number_of_types; i++) { - VirtualMemory* summary = file->_summary.by_type(NMTUtil::index_to_flag(i)); - summary->reserve_memory(diff.flag[i].commit); - summary->commit_memory(diff.flag[i].commit); + for (int i = 0; i < mt_number_of_tags; i++) { + VirtualMemory* summary = file->_summary.by_type(NMTUtil::index_to_tag(i)); + summary->reserve_memory(diff.tag[i].commit); + summary->commit_memory(diff.tag[i].commit); } } @@ -79,7 +79,7 @@ void MemoryFileTracker::print_report_on(const MemoryFile* file, outputStream* st return; } #ifdef ASSERT - if (broken_start != nullptr && prev->val().out.type() != current->val().in.type()) { + if (broken_start != nullptr && prev->val().out.mem_tag() != current->val().in.mem_tag()) { broken_start = prev; broken_end = current; } @@ -91,7 +91,7 @@ void MemoryFileTracker::print_report_on(const MemoryFile* file, outputStream* st start_addr, end_addr, NMTUtil::amount_in_scale(end_addr - start_addr, scale), NMTUtil::scale_name(scale), - NMTUtil::flag_to_name(prev->val().out.flag())); + NMTUtil::tag_to_name(prev->val().out.mem_tag())); { streamIndentor si(stream, 4); _stack_storage.get(prev->val().out.stack()).print_on(stream); @@ -138,8 +138,8 @@ bool MemoryFileTracker::Instance::initialize(NMT_TrackingLevel tracking_level) { void MemoryFileTracker::Instance::allocate_memory(MemoryFile* file, size_t offset, size_t size, const NativeCallStack& stack, - MEMFLAGS flag) { - _tracker->allocate_memory(file, offset, size, stack, flag); + MemTag mem_tag) { + _tracker->allocate_memory(file, offset, size, stack, mem_tag); } void MemoryFileTracker::Instance::free_memory(MemoryFile* file, size_t offset, size_t size) { @@ -181,9 +181,9 @@ const GrowableArrayCHeap& MemoryFileTrack void MemoryFileTracker::summary_snapshot(VirtualMemorySnapshot* snapshot) const { for (int d = 0; d < _files.length(); d++) { const MemoryFile* file = _files.at(d); - for (int i = 0; i < mt_number_of_types; i++) { - VirtualMemory* snap = snapshot->by_type(NMTUtil::index_to_flag(i)); - const VirtualMemory* current = file->_summary.by_type(NMTUtil::index_to_flag(i)); + for (int i = 0; i < mt_number_of_tags; i++) { + VirtualMemory* snap = snapshot->by_type(NMTUtil::index_to_tag(i)); + const VirtualMemory* current = file->_summary.by_type(NMTUtil::index_to_tag(i)); // Only account the committed memory. snap->commit_memory(current->committed()); } diff --git a/src/hotspot/share/nmt/memoryFileTracker.hpp b/src/hotspot/share/nmt/memoryFileTracker.hpp index 432b6f9d99e..42902701a16 100644 --- a/src/hotspot/share/nmt/memoryFileTracker.hpp +++ b/src/hotspot/share/nmt/memoryFileTracker.hpp @@ -66,7 +66,7 @@ public: MemoryFileTracker(bool is_detailed_mode); void allocate_memory(MemoryFile* file, size_t offset, size_t size, const NativeCallStack& stack, - MEMFLAGS flag); + MemTag mem_tag); void free_memory(MemoryFile* file, size_t offset, size_t size); MemoryFile* make_file(const char* descriptive_name); @@ -96,7 +96,7 @@ public: static void free_file(MemoryFile* device); static void allocate_memory(MemoryFile* device, size_t offset, size_t size, - const NativeCallStack& stack, MEMFLAGS flag); + const NativeCallStack& stack, MemTag mem_tag); static void free_memory(MemoryFile* device, size_t offset, size_t size); static void summary_snapshot(VirtualMemorySnapshot* snapshot); diff --git a/src/hotspot/share/nmt/nativeCallStackPrinter.hpp b/src/hotspot/share/nmt/nativeCallStackPrinter.hpp index deebb338626..78fd541fc98 100644 --- a/src/hotspot/share/nmt/nativeCallStackPrinter.hpp +++ b/src/hotspot/share/nmt/nativeCallStackPrinter.hpp @@ -27,7 +27,7 @@ #define SHARE_NMT_NATIVECALLSTACKPRINTER_HPP #include "memory/arena.hpp" -#include "nmt/memflags.hpp" +#include "nmt/memTag.hpp" #include "utilities/globalDefinitions.hpp" #include "utilities/resourceHash.hpp" diff --git a/src/hotspot/share/nmt/nmtCommon.cpp b/src/hotspot/share/nmt/nmtCommon.cpp index dadb830f291..24a4cb1105a 100644 --- a/src/hotspot/share/nmt/nmtCommon.cpp +++ b/src/hotspot/share/nmt/nmtCommon.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,11 +29,11 @@ STATIC_ASSERT(NMT_off > NMT_unknown); STATIC_ASSERT(NMT_summary > NMT_off); STATIC_ASSERT(NMT_detail > NMT_summary); -#define MEMORY_TYPE_DECLARE_NAME(type, human_readable) \ +#define MEMORY_TAG_DECLARE_NAME(type, human_readable) \ { #type, human_readable }, NMTUtil::S NMTUtil::_strings[] = { - MEMORY_TYPES_DO(MEMORY_TYPE_DECLARE_NAME) + MEMORY_TAG_DO(MEMORY_TAG_DECLARE_NAME) }; const char* NMTUtil::scale_name(size_t scale) { @@ -87,14 +87,14 @@ NMT_TrackingLevel NMTUtil::parse_tracking_level(const char* s) { return NMT_unknown; } -MEMFLAGS NMTUtil::string_to_flag(const char* s) { - for (int i = 0; i < mt_number_of_types; i ++) { +MemTag NMTUtil::string_to_mem_tag(const char* s) { + for (int i = 0; i < mt_number_of_tags; i ++) { assert(::strlen(_strings[i].enum_s) > 2, "Sanity"); // should always start with "mt" if (::strcasecmp(_strings[i].human_readable, s) == 0 || ::strcasecmp(_strings[i].enum_s, s) == 0 || ::strcasecmp(_strings[i].enum_s + 2, s) == 0) // "mtXXX" -> match also "XXX" or "xxx" { - return (MEMFLAGS)i; + return (MemTag)i; } } return mtNone; diff --git a/src/hotspot/share/nmt/nmtCommon.hpp b/src/hotspot/share/nmt/nmtCommon.hpp index 8ca0965b3d3..3f72960f21f 100644 --- a/src/hotspot/share/nmt/nmtCommon.hpp +++ b/src/hotspot/share/nmt/nmtCommon.hpp @@ -28,7 +28,7 @@ #define SHARE_NMT_NMTCOMMON_HPP #include "memory/allStatic.hpp" -#include "nmt/memflags.hpp" +#include "nmt/memTag.hpp" #include "utilities/align.hpp" #include "utilities/globalDefinitions.hpp" @@ -75,37 +75,37 @@ const int NMT_TrackingStackDepth = 4; // A few common utilities for native memory tracking class NMTUtil : AllStatic { public: - // Check if index is a valid MEMFLAGS enum value (including mtNone) - static inline bool flag_index_is_valid(int index) { - return index >= 0 && index < mt_number_of_types; + // Check if index is a valid MemTag enum value (including mtNone) + static inline bool tag_index_is_valid(int index) { + return index >= 0 && index < mt_number_of_tags; } - // Check if flag value is a valid MEMFLAGS enum value (including mtNone) - static inline bool flag_is_valid(MEMFLAGS flag) { - const int index = static_cast(flag); - return flag_index_is_valid(index); + // Check if tag value is a valid MemTag enum value (including mtNone) + static inline bool tag_is_valid(MemTag mem_tag) { + const int index = static_cast(mem_tag); + return tag_index_is_valid(index); } - // Map memory type to index - static inline int flag_to_index(MEMFLAGS flag) { - assert(flag_is_valid(flag), "Invalid flag (%u)", (unsigned)flag); - return static_cast(flag); + // Map memory tag to index + static inline int tag_to_index(MemTag mem_tag) { + assert(tag_is_valid(mem_tag), "Invalid type (%u)", (unsigned)mem_tag); + return static_cast(mem_tag); } - // Map memory type to human readable name - static const char* flag_to_name(MEMFLAGS flag) { - return _strings[flag_to_index(flag)].human_readable; + // Map memory tag to human readable name + static const char* tag_to_name(MemTag mem_tag) { + return _strings[tag_to_index(mem_tag)].human_readable; } - // Map memory type to literalized enum name (e.g. "mtTest") - static const char* flag_to_enum_name(MEMFLAGS flag) { - return _strings[flag_to_index(flag)].enum_s; + // Map memory tag to literalized enum name (e.g. "mtTest") + static const char* tag_to_enum_name(MemTag mem_tag) { + return _strings[tag_to_index(mem_tag)].enum_s; } - // Map an index to memory type - static MEMFLAGS index_to_flag(int index) { - assert(flag_index_is_valid(index), "Invalid flag index (%d)", index); - return static_cast(index); + // Map an index to memory tag + static MemTag index_to_tag(int index) { + assert(tag_index_is_valid(index), "Invalid type index (%d)", index); + return static_cast(index); } // Memory size scale @@ -121,10 +121,10 @@ class NMTUtil : AllStatic { // string is not a valid level. static NMT_TrackingLevel parse_tracking_level(const char* s); - // Given a string, return associated flag. mtNone if name is invalid. + // Given a string, return associated mem_tag. mtNone if name is invalid. // String can be either the human readable name or the // stringified enum (with or without leading "mt". In all cases, case is ignored. - static MEMFLAGS string_to_flag(const char* name); + static MemTag string_to_mem_tag(const char* name); // Returns textual representation of a tracking level. static const char* tracking_level_to_string(NMT_TrackingLevel level); @@ -134,7 +134,7 @@ class NMTUtil : AllStatic { const char* enum_s; // e.g. "mtNMT" const char* human_readable; // e.g. "Native Memory Tracking" }; - static S _strings[mt_number_of_types]; + static S _strings[mt_number_of_tags]; }; diff --git a/src/hotspot/share/nmt/nmtPreInit.cpp b/src/hotspot/share/nmt/nmtPreInit.cpp index a8ff18f3b62..0aa74566f42 100644 --- a/src/hotspot/share/nmt/nmtPreInit.cpp +++ b/src/hotspot/share/nmt/nmtPreInit.cpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2022, 2023 SAP SE. All rights reserved. - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -198,8 +198,8 @@ void NMTPreInit::create_table() { } // Allocate with os::malloc (hidden to prevent having to include os.hpp) -void* NMTPreInit::do_os_malloc(size_t size, MEMFLAGS memflags) { - return os::malloc(size, memflags); +void* NMTPreInit::do_os_malloc(size_t size, MemTag mem_tag) { + return os::malloc(size, mem_tag); } // Switches from NMT pre-init state to NMT post-init state; diff --git a/src/hotspot/share/nmt/nmtPreInit.hpp b/src/hotspot/share/nmt/nmtPreInit.hpp index 38a34616b3f..1524c2bd7dc 100644 --- a/src/hotspot/share/nmt/nmtPreInit.hpp +++ b/src/hotspot/share/nmt/nmtPreInit.hpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2022, 2023 SAP SE. All rights reserved. - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -255,7 +255,7 @@ class NMTPreInit : public AllStatic { } // Just a wrapper for os::malloc to avoid including os.hpp here. - static void* do_os_malloc(size_t size, MEMFLAGS memflags); + static void* do_os_malloc(size_t size, MemTag mem_tag); public: @@ -283,7 +283,7 @@ public: // Called from os::realloc. // Returns true if reallocation was handled here; in that case, // *rc contains the return address. - static bool handle_realloc(void** rc, void* old_p, size_t new_size, MEMFLAGS memflags) { + static bool handle_realloc(void** rc, void* old_p, size_t new_size, MemTag mem_tag) { if (old_p == nullptr) { // realloc(null, n) return handle_malloc(rc, new_size); } @@ -322,7 +322,7 @@ public: // and confusing us. const NMTPreInitAllocation* a = find_in_map(old_p); if (a != nullptr) { // this was originally a pre-init allocation - void* p_new = do_os_malloc(new_size, memflags); + void* p_new = do_os_malloc(new_size, mem_tag); ::memcpy(p_new, a->payload, MIN2(a->size, new_size)); (*rc) = p_new; return true; diff --git a/src/hotspot/share/nmt/nmtUsage.cpp b/src/hotspot/share/nmt/nmtUsage.cpp index 62c41225441..a854f001593 100644 --- a/src/hotspot/share/nmt/nmtUsage.cpp +++ b/src/hotspot/share/nmt/nmtUsage.cpp @@ -57,9 +57,9 @@ void NMTUsage::update_malloc_usage() { const MallocMemorySnapshot* ms = MallocMemorySummary::as_snapshot(); size_t total_arena_size = 0; - for (int i = 0; i < mt_number_of_types; i++) { - MEMFLAGS flag = NMTUtil::index_to_flag(i); - const MallocMemory* mm = ms->by_type(flag); + for (int i = 0; i < mt_number_of_tags; i++) { + MemTag mem_tag = NMTUtil::index_to_tag(i); + const MallocMemory* mm = ms->by_type(mem_tag); _malloc_by_type[i] = mm->malloc_size() + mm->arena_size(); total_arena_size += mm->arena_size(); } @@ -68,11 +68,11 @@ void NMTUsage::update_malloc_usage() { _malloc_total = ms->total(); // Adjustment due to mtChunk double counting. - _malloc_by_type[NMTUtil::flag_to_index(mtChunk)] -= total_arena_size; + _malloc_by_type[NMTUtil::tag_to_index(mtChunk)] -= total_arena_size; _malloc_total -= total_arena_size; // Adjust mtNMT to include malloc overhead. - _malloc_by_type[NMTUtil::flag_to_index(mtNMT)] += ms->malloc_overhead(); + _malloc_by_type[NMTUtil::tag_to_index(mtNMT)] += ms->malloc_overhead(); } void NMTUsage::update_vm_usage() { @@ -81,9 +81,9 @@ void NMTUsage::update_vm_usage() { // Reset total to allow recalculation. _vm_total.committed = 0; _vm_total.reserved = 0; - for (int i = 0; i < mt_number_of_types; i++) { - MEMFLAGS flag = NMTUtil::index_to_flag(i); - const VirtualMemory* vm = vms->by_type(flag); + for (int i = 0; i < mt_number_of_tags; i++) { + MemTag mem_tag = NMTUtil::index_to_tag(i); + const VirtualMemory* vm = vms->by_type(mem_tag); _vm_by_type[i].reserved = vm->reserved(); _vm_by_type[i].committed = vm->committed(); @@ -116,12 +116,12 @@ size_t NMTUsage::total_committed() const { return _malloc_total + _vm_total.committed; } -size_t NMTUsage::reserved(MEMFLAGS flag) const { - int index = NMTUtil::flag_to_index(flag); +size_t NMTUsage::reserved(MemTag mem_tag) const { + int index = NMTUtil::tag_to_index(mem_tag); return _malloc_by_type[index] + _vm_by_type[index].reserved; } -size_t NMTUsage::committed(MEMFLAGS flag) const { - int index = NMTUtil::flag_to_index(flag); +size_t NMTUsage::committed(MemTag mem_tag) const { + int index = NMTUtil::tag_to_index(mem_tag); return _malloc_by_type[index] + _vm_by_type[index].committed; } diff --git a/src/hotspot/share/nmt/nmtUsage.hpp b/src/hotspot/share/nmt/nmtUsage.hpp index cfff59db9af..390d207250c 100644 --- a/src/hotspot/share/nmt/nmtUsage.hpp +++ b/src/hotspot/share/nmt/nmtUsage.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,9 +41,9 @@ struct NMTUsageOptions { class NMTUsage : public CHeapObj { private: - size_t _malloc_by_type[mt_number_of_types]; + size_t _malloc_by_type[mt_number_of_tags]; size_t _malloc_total; - NMTUsagePair _vm_by_type[mt_number_of_types]; + NMTUsagePair _vm_by_type[mt_number_of_tags]; NMTUsagePair _vm_total; NMTUsageOptions _usage_options; @@ -61,8 +61,8 @@ public: size_t total_reserved() const; size_t total_committed() const; - size_t reserved(MEMFLAGS flag) const; - size_t committed(MEMFLAGS flag) const; + size_t reserved(MemTag mem_tag) const; + size_t committed(MemTag mem_tag) const; }; #endif // SHARE_NMT_NMTUSAGE_HPP diff --git a/src/hotspot/share/nmt/virtualMemoryTracker.cpp b/src/hotspot/share/nmt/virtualMemoryTracker.cpp index d25f3689a42..d298381f103 100644 --- a/src/hotspot/share/nmt/virtualMemoryTracker.cpp +++ b/src/hotspot/share/nmt/virtualMemoryTracker.cpp @@ -142,7 +142,7 @@ bool ReservedMemoryRegion::add_committed_region(address addr, size_t size, const // At this point the previous overlapping regions have been // cleared, and the full region is guaranteed to be inserted. - VirtualMemorySummary::record_committed_memory(size, flag()); + VirtualMemorySummary::record_committed_memory(size, mem_tag()); // Try to merge with prev and possibly next. if (try_merge_with(prev, addr, size, stack)) { @@ -212,14 +212,14 @@ bool ReservedMemoryRegion::remove_uncommitted_region(address addr, size_t sz) { crgn = head->data(); if (crgn->same_region(addr, sz)) { - VirtualMemorySummary::record_uncommitted_memory(crgn->size(), flag()); + VirtualMemorySummary::record_uncommitted_memory(crgn->size(), mem_tag()); _committed_regions.remove_after(prev); return true; } // del_rgn contains crgn if (del_rgn.contain_region(crgn->base(), crgn->size())) { - VirtualMemorySummary::record_uncommitted_memory(crgn->size(), flag()); + VirtualMemorySummary::record_uncommitted_memory(crgn->size(), mem_tag()); head = head->next(); _committed_regions.remove_after(prev); continue; // don't update head or prev @@ -230,20 +230,20 @@ bool ReservedMemoryRegion::remove_uncommitted_region(address addr, size_t sz) { // (1) Found addr+size in current crgn as well. (del_rgn is contained in crgn) if (crgn->contain_address(end - 1)) { - VirtualMemorySummary::record_uncommitted_memory(sz, flag()); + VirtualMemorySummary::record_uncommitted_memory(sz, mem_tag()); return remove_uncommitted_region(head, addr, sz); // done! } else { // (2) Did not find del_rgn's end in crgn. size_t size = crgn->end() - del_rgn.base(); crgn->exclude_region(addr, size); - VirtualMemorySummary::record_uncommitted_memory(size, flag()); + VirtualMemorySummary::record_uncommitted_memory(size, mem_tag()); } } else if (crgn->contain_address(end - 1)) { // Found del_rgn's end, but not its base addr. size_t size = del_rgn.end() - crgn->base(); crgn->exclude_region(crgn->base(), size); - VirtualMemorySummary::record_uncommitted_memory(size, flag()); + VirtualMemorySummary::record_uncommitted_memory(size, mem_tag()); return true; // should be done if the list is sorted properly! } @@ -292,19 +292,19 @@ size_t ReservedMemoryRegion::committed_size() const { return committed; } -void ReservedMemoryRegion::set_flag(MEMFLAGS f) { - assert((flag() == mtNone || flag() == f), - "Overwrite memory type for region [" INTPTR_FORMAT "-" INTPTR_FORMAT "), %u->%u.", - p2i(base()), p2i(end()), (unsigned)flag(), (unsigned)f); - if (flag() != f) { - VirtualMemorySummary::move_reserved_memory(flag(), f, size()); - VirtualMemorySummary::move_committed_memory(flag(), f, committed_size()); - _flag = f; +void ReservedMemoryRegion::set_mem_tag(MemTag new_mem_tag) { + assert((mem_tag() == mtNone || mem_tag() == new_mem_tag), + "Overwrite memory tag for region [" INTPTR_FORMAT "-" INTPTR_FORMAT "), %u->%u.", + p2i(base()), p2i(end()), (unsigned)mem_tag(), (unsigned)new_mem_tag); + if (mem_tag() != new_mem_tag) { + VirtualMemorySummary::move_reserved_memory(mem_tag(), new_mem_tag, size()); + VirtualMemorySummary::move_committed_memory(mem_tag(), new_mem_tag, committed_size()); + _mem_tag = new_mem_tag; } } address ReservedMemoryRegion::thread_stack_uncommitted_bottom() const { - assert(flag() == mtThreadStack, "Only for thread stack"); + assert(mem_tag() == mtThreadStack, "Only for thread stack"); LinkedListNode* head = _committed_regions.head(); address bottom = base(); address top = base() + size(); @@ -334,26 +334,26 @@ bool VirtualMemoryTracker::initialize(NMT_TrackingLevel level) { } bool VirtualMemoryTracker::add_reserved_region(address base_addr, size_t size, - const NativeCallStack& stack, MEMFLAGS flag) { + const NativeCallStack& stack, MemTag mem_tag) { assert(base_addr != nullptr, "Invalid address"); assert(size > 0, "Invalid size"); assert(_reserved_regions != nullptr, "Sanity check"); - ReservedMemoryRegion rgn(base_addr, size, stack, flag); + ReservedMemoryRegion rgn(base_addr, size, stack, mem_tag); ReservedMemoryRegion* reserved_rgn = _reserved_regions->find(rgn); log_debug(nmt)("Add reserved region \'%s\' (" INTPTR_FORMAT ", " SIZE_FORMAT ")", - rgn.flag_name(), p2i(rgn.base()), rgn.size()); + rgn.mem_tag_name(), p2i(rgn.base()), rgn.size()); if (reserved_rgn == nullptr) { - VirtualMemorySummary::record_reserved_memory(size, flag); + VirtualMemorySummary::record_reserved_memory(size, mem_tag); return _reserved_regions->add(rgn) != nullptr; } else { // Deal with recursive reservation // os::reserve_memory() -> pd_reserve_memory() -> os::reserve_memory() // See JDK-8198226. if (reserved_rgn->same_region(base_addr, size) && - (reserved_rgn->flag() == flag || reserved_rgn->flag() == mtNone)) { + (reserved_rgn->mem_tag() == mem_tag || reserved_rgn->mem_tag() == mtNone)) { reserved_rgn->set_call_stack(stack); - reserved_rgn->set_flag(flag); + reserved_rgn->set_mem_tag(mem_tag); return true; } else { assert(reserved_rgn->overlap_region(base_addr, size), "Must be"); @@ -362,16 +362,16 @@ bool VirtualMemoryTracker::add_reserved_region(address base_addr, size_t size, // It can happen when the regions are thread stacks, as JNI // thread does not detach from VM before exits, and leads to // leak JavaThread object - if (reserved_rgn->flag() == mtThreadStack) { + if (reserved_rgn->mem_tag() == mtThreadStack) { guarantee(!CheckJNICalls, "Attached JNI thread exited without being detached"); // Overwrite with new region // Release old region - VirtualMemorySummary::record_uncommitted_memory(reserved_rgn->committed_size(), reserved_rgn->flag()); - VirtualMemorySummary::record_released_memory(reserved_rgn->size(), reserved_rgn->flag()); + VirtualMemorySummary::record_uncommitted_memory(reserved_rgn->committed_size(), reserved_rgn->mem_tag()); + VirtualMemorySummary::record_released_memory(reserved_rgn->size(), reserved_rgn->mem_tag()); // Add new region - VirtualMemorySummary::record_reserved_memory(rgn.size(), flag); + VirtualMemorySummary::record_reserved_memory(rgn.size(), mem_tag); *reserved_rgn = rgn; return true; @@ -380,27 +380,27 @@ bool VirtualMemoryTracker::add_reserved_region(address base_addr, size_t size, // CDS mapping region. // CDS reserves the whole region for mapping CDS archive, then maps each section into the region. // NMT reports CDS as a whole. - if (reserved_rgn->flag() == mtClassShared) { + if (reserved_rgn->mem_tag() == mtClassShared) { log_debug(nmt)("CDS reserved region \'%s\' as a whole (" INTPTR_FORMAT ", " SIZE_FORMAT ")", - reserved_rgn->flag_name(), p2i(reserved_rgn->base()), reserved_rgn->size()); + reserved_rgn->mem_tag_name(), p2i(reserved_rgn->base()), reserved_rgn->size()); assert(reserved_rgn->contain_region(base_addr, size), "Reserved CDS region should contain this mapping region"); return true; } // Mapped CDS string region. // The string region(s) is part of the java heap. - if (reserved_rgn->flag() == mtJavaHeap) { + if (reserved_rgn->mem_tag() == mtJavaHeap) { log_debug(nmt)("CDS reserved region \'%s\' as a whole (" INTPTR_FORMAT ", " SIZE_FORMAT ")", - reserved_rgn->flag_name(), p2i(reserved_rgn->base()), reserved_rgn->size()); + reserved_rgn->mem_tag_name(), p2i(reserved_rgn->base()), reserved_rgn->size()); assert(reserved_rgn->contain_region(base_addr, size), "Reserved heap region should contain this mapping region"); return true; } // Print some more details. Don't use UL here to avoid circularities. - tty->print_cr("Error: existing region: [" INTPTR_FORMAT "-" INTPTR_FORMAT "), flag %u.\n" - " new region: [" INTPTR_FORMAT "-" INTPTR_FORMAT "), flag %u.", - p2i(reserved_rgn->base()), p2i(reserved_rgn->end()), (unsigned)reserved_rgn->flag(), - p2i(base_addr), p2i(base_addr + size), (unsigned)flag); + tty->print_cr("Error: existing region: [" INTPTR_FORMAT "-" INTPTR_FORMAT "), memory tag %u.\n" + " new region: [" INTPTR_FORMAT "-" INTPTR_FORMAT "), memory tag %u.", + p2i(reserved_rgn->base()), p2i(reserved_rgn->end()), (unsigned)reserved_rgn->mem_tag(), + p2i(base_addr), p2i(base_addr + size), (unsigned)mem_tag); if (MemTracker::tracking_level() == NMT_detail) { tty->print_cr("Existing region allocated from:"); reserved_rgn->call_stack()->print_on(tty); @@ -413,7 +413,7 @@ bool VirtualMemoryTracker::add_reserved_region(address base_addr, size_t size, } } -void VirtualMemoryTracker::set_reserved_region_type(address addr, MEMFLAGS flag) { +void VirtualMemoryTracker::set_reserved_region_type(address addr, MemTag mem_tag) { assert(addr != nullptr, "Invalid address"); assert(_reserved_regions != nullptr, "Sanity check"); @@ -421,10 +421,10 @@ void VirtualMemoryTracker::set_reserved_region_type(address addr, MEMFLAGS flag) ReservedMemoryRegion* reserved_rgn = _reserved_regions->find(rgn); if (reserved_rgn != nullptr) { assert(reserved_rgn->contain_address(addr), "Containment"); - if (reserved_rgn->flag() != flag) { - assert(reserved_rgn->flag() == mtNone, "Overwrite memory type (should be mtNone, is: \"%s\")", - NMTUtil::flag_to_name(reserved_rgn->flag())); - reserved_rgn->set_flag(flag); + if (reserved_rgn->mem_tag() != mem_tag) { + assert(reserved_rgn->mem_tag() == mtNone, "Overwrite memory tag (should be mtNone, is: \"%s\")", + NMTUtil::tag_to_name(reserved_rgn->mem_tag())); + reserved_rgn->set_mem_tag(mem_tag); } } } @@ -440,13 +440,13 @@ bool VirtualMemoryTracker::add_committed_region(address addr, size_t size, if (reserved_rgn == nullptr) { log_debug(nmt)("Add committed region \'%s\', No reserved region found for (" INTPTR_FORMAT ", " SIZE_FORMAT ")", - rgn.flag_name(), p2i(rgn.base()), rgn.size()); + rgn.mem_tag_name(), p2i(rgn.base()), rgn.size()); } assert(reserved_rgn != nullptr, "Add committed region, No reserved region found"); assert(reserved_rgn->contain_region(addr, size), "Not completely contained"); bool result = reserved_rgn->add_committed_region(addr, size, stack); log_debug(nmt)("Add committed region \'%s\'(" INTPTR_FORMAT ", " SIZE_FORMAT ") %s", - reserved_rgn->flag_name(), p2i(rgn.base()), rgn.size(), (result ? "Succeeded" : "Failed")); + reserved_rgn->mem_tag_name(), p2i(rgn.base()), rgn.size(), (result ? "Succeeded" : "Failed")); return result; } @@ -459,10 +459,10 @@ bool VirtualMemoryTracker::remove_uncommitted_region(address addr, size_t size) ReservedMemoryRegion* reserved_rgn = _reserved_regions->find(rgn); assert(reserved_rgn != nullptr, "No reserved region (" INTPTR_FORMAT ", " SIZE_FORMAT ")", p2i(addr), size); assert(reserved_rgn->contain_region(addr, size), "Not completely contained"); - const char* flag_name = reserved_rgn->flag_name(); // after remove, info is not complete + const char* type_name = reserved_rgn->mem_tag_name(); // after remove, info is not complete bool result = reserved_rgn->remove_uncommitted_region(addr, size); log_debug(nmt)("Removed uncommitted region \'%s\' (" INTPTR_FORMAT ", " SIZE_FORMAT ") %s", - flag_name, p2i(addr), size, (result ? " Succeeded" : "Failed")); + type_name, p2i(addr), size, (result ? " Succeeded" : "Failed")); return result; } @@ -474,15 +474,15 @@ bool VirtualMemoryTracker::remove_released_region(ReservedMemoryRegion* rgn) { ReservedMemoryRegion backup(*rgn); bool result = rgn->remove_uncommitted_region(rgn->base(), rgn->size()); log_debug(nmt)("Remove uncommitted region \'%s\' (" INTPTR_FORMAT ", " SIZE_FORMAT ") %s", - backup.flag_name(), p2i(backup.base()), backup.size(), (result ? "Succeeded" : "Failed")); + backup.mem_tag_name(), p2i(backup.base()), backup.size(), (result ? "Succeeded" : "Failed")); if (!result) { return false; } - VirtualMemorySummary::record_released_memory(rgn->size(), rgn->flag()); + VirtualMemorySummary::record_released_memory(rgn->size(), rgn->mem_tag()); result = _reserved_regions->remove(*rgn); log_debug(nmt)("Removed region \'%s\' (" INTPTR_FORMAT ", " SIZE_FORMAT ") from _reserved_regions %s" , - backup.flag_name(), p2i(backup.base()), backup.size(), (result ? "Succeeded" : "Failed")); + backup.mem_tag_name(), p2i(backup.base()), backup.size(), (result ? "Succeeded" : "Failed")); return result; } @@ -508,7 +508,7 @@ bool VirtualMemoryTracker::remove_released_region(address addr, size_t size) { return false; } - if (reserved_rgn->flag() == mtClassShared) { + if (reserved_rgn->mem_tag() == mtClassShared) { if (reserved_rgn->contain_region(addr, size)) { // This is an unmapped CDS region, which is part of the reserved shared // memory region. @@ -523,14 +523,14 @@ bool VirtualMemoryTracker::remove_released_region(address addr, size_t size) { (size - reserved_rgn->size())); ReservedMemoryRegion* cls_rgn = _reserved_regions->find(class_rgn); assert(cls_rgn != nullptr, "Class space region not recorded?"); - assert(cls_rgn->flag() == mtClass, "Must be class type"); + assert(cls_rgn->mem_tag() == mtClass, "Must be class mem tag"); remove_released_region(reserved_rgn); remove_released_region(cls_rgn); return true; } } - VirtualMemorySummary::record_released_memory(size, reserved_rgn->flag()); + VirtualMemorySummary::record_released_memory(size, reserved_rgn->mem_tag()); assert(reserved_rgn->contain_region(addr, size), "Not completely contained"); if (reserved_rgn->base() == addr || @@ -541,7 +541,7 @@ bool VirtualMemoryTracker::remove_released_region(address addr, size_t size) { address top = reserved_rgn->end(); address high_base = addr + size; ReservedMemoryRegion high_rgn(high_base, top - high_base, - *reserved_rgn->call_stack(), reserved_rgn->flag()); + *reserved_rgn->call_stack(), reserved_rgn->mem_tag()); // use original region for lower region reserved_rgn->exclude_region(addr, top - addr); @@ -557,8 +557,8 @@ bool VirtualMemoryTracker::remove_released_region(address addr, size_t size) { // Given an existing memory mapping registered with NMT, split the mapping in // two. The newly created two mappings will be registered under the call -// stack and the memory flags of the original section. -bool VirtualMemoryTracker::split_reserved_region(address addr, size_t size, size_t split, MEMFLAGS flag, MEMFLAGS split_flag) { +// stack and the memory tags of the original section. +bool VirtualMemoryTracker::split_reserved_region(address addr, size_t size, size_t split, MemTag mem_tag, MemTag split_tag) { ReservedMemoryRegion rgn(addr, size); ReservedMemoryRegion* reserved_rgn = _reserved_regions->find(rgn); @@ -567,15 +567,15 @@ bool VirtualMemoryTracker::split_reserved_region(address addr, size_t size, size assert(reserved_rgn->committed_size() == 0, "Splitting committed region?"); NativeCallStack original_stack = *reserved_rgn->call_stack(); - MEMFLAGS original_flags = reserved_rgn->flag(); + MemTag original_tag = reserved_rgn->mem_tag(); - const char* name = reserved_rgn->flag_name(); + const char* name = reserved_rgn->mem_tag_name(); remove_released_region(reserved_rgn); log_debug(nmt)("Split region \'%s\' (" INTPTR_FORMAT ", " SIZE_FORMAT ") with size " SIZE_FORMAT, name, p2i(rgn.base()), rgn.size(), split); // Now, create two new regions. - add_reserved_region(addr, split, original_stack, flag); - add_reserved_region(addr + split, size - split, original_stack, split_flag); + add_reserved_region(addr, split, original_stack, mem_tag); + add_reserved_region(addr + split, size - split, original_stack, split_tag); return true; } @@ -621,7 +621,7 @@ public: SnapshotThreadStackWalker() {} bool do_allocation_site(const ReservedMemoryRegion* rgn) { - if (rgn->flag() == mtThreadStack) { + if (rgn->mem_tag() == mtThreadStack) { address stack_bottom = rgn->thread_stack_uncommitted_bottom(); address committed_start; size_t committed_size; @@ -688,7 +688,7 @@ public: bool do_allocation_site(const ReservedMemoryRegion* rgn) { if (rgn->contain_address(_p)) { _st->print_cr(PTR_FORMAT " in mmap'd memory region [" PTR_FORMAT " - " PTR_FORMAT "], tag %s", - p2i(_p), p2i(rgn->base()), p2i(rgn->base() + rgn->size()), NMTUtil::flag_to_enum_name(rgn->flag())); + p2i(_p), p2i(rgn->base()), p2i(rgn->base() + rgn->size()), NMTUtil::tag_to_enum_name(rgn->mem_tag())); if (MemTracker::tracking_level() == NMT_detail) { _stackprinter.print_stack(rgn->call_stack()); _st->cr(); diff --git a/src/hotspot/share/nmt/virtualMemoryTracker.hpp b/src/hotspot/share/nmt/virtualMemoryTracker.hpp index e84245ce1f8..6e36d3a858a 100644 --- a/src/hotspot/share/nmt/virtualMemoryTracker.hpp +++ b/src/hotspot/share/nmt/virtualMemoryTracker.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -77,8 +77,8 @@ class VirtualMemory { class VirtualMemoryAllocationSite : public AllocationSite { VirtualMemory _c; public: - VirtualMemoryAllocationSite(const NativeCallStack& stack, MEMFLAGS flag) : - AllocationSite(stack, flag) { } + VirtualMemoryAllocationSite(const NativeCallStack& stack, MemTag mem_tag) : + AllocationSite(stack, mem_tag) { } inline void reserve_memory(size_t sz) { _c.reserve_memory(sz); } inline void commit_memory (size_t sz) { _c.commit_memory(sz); } @@ -95,22 +95,22 @@ class VirtualMemorySnapshot : public ResourceObj { friend class VirtualMemorySummary; private: - VirtualMemory _virtual_memory[mt_number_of_types]; + VirtualMemory _virtual_memory[mt_number_of_tags]; public: - inline VirtualMemory* by_type(MEMFLAGS flag) { - int index = NMTUtil::flag_to_index(flag); + inline VirtualMemory* by_type(MemTag mem_tag) { + int index = NMTUtil::tag_to_index(mem_tag); return &_virtual_memory[index]; } - inline const VirtualMemory* by_type(MEMFLAGS flag) const { - int index = NMTUtil::flag_to_index(flag); + inline const VirtualMemory* by_type(MemTag mem_tag) const { + int index = NMTUtil::tag_to_index(mem_tag); return &_virtual_memory[index]; } inline size_t total_reserved() const { size_t amount = 0; - for (int index = 0; index < mt_number_of_types; index ++) { + for (int index = 0; index < mt_number_of_tags; index ++) { amount += _virtual_memory[index].reserved(); } return amount; @@ -118,14 +118,14 @@ class VirtualMemorySnapshot : public ResourceObj { inline size_t total_committed() const { size_t amount = 0; - for (int index = 0; index < mt_number_of_types; index ++) { + for (int index = 0; index < mt_number_of_tags; index ++) { amount += _virtual_memory[index].committed(); } return amount; } void copy_to(VirtualMemorySnapshot* s) { - for (int index = 0; index < mt_number_of_types; index ++) { + for (int index = 0; index < mt_number_of_tags; index ++) { s->_virtual_memory[index] = _virtual_memory[index]; } } @@ -134,32 +134,32 @@ class VirtualMemorySnapshot : public ResourceObj { class VirtualMemorySummary : AllStatic { public: - static inline void record_reserved_memory(size_t size, MEMFLAGS flag) { - as_snapshot()->by_type(flag)->reserve_memory(size); + static inline void record_reserved_memory(size_t size, MemTag mem_tag) { + as_snapshot()->by_type(mem_tag)->reserve_memory(size); } - static inline void record_committed_memory(size_t size, MEMFLAGS flag) { - as_snapshot()->by_type(flag)->commit_memory(size); + static inline void record_committed_memory(size_t size, MemTag mem_tag) { + as_snapshot()->by_type(mem_tag)->commit_memory(size); } - static inline void record_uncommitted_memory(size_t size, MEMFLAGS flag) { - as_snapshot()->by_type(flag)->uncommit_memory(size); + static inline void record_uncommitted_memory(size_t size, MemTag mem_tag) { + as_snapshot()->by_type(mem_tag)->uncommit_memory(size); } - static inline void record_released_memory(size_t size, MEMFLAGS flag) { - as_snapshot()->by_type(flag)->release_memory(size); + static inline void record_released_memory(size_t size, MemTag mem_tag) { + as_snapshot()->by_type(mem_tag)->release_memory(size); } - // Move virtual memory from one memory type to another. - // Virtual memory can be reserved before it is associated with a memory type, and tagged + // Move virtual memory from one memory tag to another. + // Virtual memory can be reserved before it is associated with a memory tag, and tagged // as 'unknown'. Once the memory is tagged, the virtual memory will be moved from 'unknown' - // type to specified memory type. - static inline void move_reserved_memory(MEMFLAGS from, MEMFLAGS to, size_t size) { + // type to specified memory tag. + static inline void move_reserved_memory(MemTag from, MemTag to, size_t size) { as_snapshot()->by_type(from)->release_memory(size); as_snapshot()->by_type(to)->reserve_memory(size); } - static inline void move_committed_memory(MEMFLAGS from, MEMFLAGS to, size_t size) { + static inline void move_committed_memory(MemTag from, MemTag to, size_t size) { as_snapshot()->by_type(from)->uncommit_memory(size); as_snapshot()->by_type(to)->commit_memory(size); } @@ -293,16 +293,16 @@ class ReservedMemoryRegion : public VirtualMemoryRegion { _committed_regions; NativeCallStack _stack; - MEMFLAGS _flag; + MemTag _mem_tag; public: ReservedMemoryRegion(address base, size_t size, const NativeCallStack& stack, - MEMFLAGS flag = mtNone) : - VirtualMemoryRegion(base, size), _stack(stack), _flag(flag) { } + MemTag mem_tag = mtNone) : + VirtualMemoryRegion(base, size), _stack(stack), _mem_tag(mem_tag) { } ReservedMemoryRegion(address base, size_t size) : - VirtualMemoryRegion(base, size), _stack(NativeCallStack::empty_stack()), _flag(mtNone) { } + VirtualMemoryRegion(base, size), _stack(NativeCallStack::empty_stack()), _mem_tag(mtNone) { } // Copy constructor ReservedMemoryRegion(const ReservedMemoryRegion& rr) : @@ -313,8 +313,8 @@ class ReservedMemoryRegion : public VirtualMemoryRegion { inline void set_call_stack(const NativeCallStack& stack) { _stack = stack; } inline const NativeCallStack* call_stack() const { return &_stack; } - void set_flag(MEMFLAGS flag); - inline MEMFLAGS flag() const { return _flag; } + void set_mem_tag(MemTag mem_tag); + inline MemTag mem_tag() const { return _mem_tag; } // uncommitted thread stack bottom, above guard pages if there is any. address thread_stack_uncommitted_bottom() const; @@ -336,8 +336,8 @@ class ReservedMemoryRegion : public VirtualMemoryRegion { set_base(other.base()); set_size(other.size()); - _stack = *other.call_stack(); - _flag = other.flag(); + _stack = *other.call_stack(); + _mem_tag = other.mem_tag(); _committed_regions.clear(); CommittedRegionIterator itr = other.iterate_committed_regions(); @@ -350,7 +350,7 @@ class ReservedMemoryRegion : public VirtualMemoryRegion { return *this; } - const char* flag_name() const { return NMTUtil::flag_to_name(_flag); } + const char* mem_tag_name() const { return NMTUtil::tag_to_name(_mem_tag); } private: // The committed region contains the uncommitted region, subtract the uncommitted @@ -380,18 +380,18 @@ class VirtualMemoryTracker : AllStatic { public: static bool initialize(NMT_TrackingLevel level); - static bool add_reserved_region (address base_addr, size_t size, const NativeCallStack& stack, MEMFLAGS flag = mtNone); + static bool add_reserved_region (address base_addr, size_t size, const NativeCallStack& stack, MemTag mem_tag = mtNone); static bool add_committed_region (address base_addr, size_t size, const NativeCallStack& stack); static bool remove_uncommitted_region (address base_addr, size_t size); static bool remove_released_region (address base_addr, size_t size); static bool remove_released_region (ReservedMemoryRegion* rgn); - static void set_reserved_region_type (address addr, MEMFLAGS flag); + static void set_reserved_region_type (address addr, MemTag mem_tag); // Given an existing memory mapping registered with NMT, split the mapping in // two. The newly created two mappings will be registered under the call - // stack and the memory flags of the original section. - static bool split_reserved_region(address addr, size_t size, size_t split, MEMFLAGS flag, MEMFLAGS split_flag); + // stack and the memory tag of the original section. + static bool split_reserved_region(address addr, size_t size, size_t split, MemTag mem_tag, MemTag split_type); // Walk virtual memory data structure for creating baseline, etc. static bool walk_virtual_memory(VirtualMemoryWalker* walker); diff --git a/src/hotspot/share/nmt/vmatree.cpp b/src/hotspot/share/nmt/vmatree.cpp index cef2d48e816..65a5bdb94ae 100644 --- a/src/hotspot/share/nmt/vmatree.cpp +++ b/src/hotspot/share/nmt/vmatree.cpp @@ -24,6 +24,7 @@ */ #include "precompiled.hpp" +#include "logging/log.hpp" #include "nmt/vmatree.hpp" #include "utilities/growableArray.hpp" @@ -34,7 +35,9 @@ const char* VMATree::statetype_strings[3] = { }; VMATree::SummaryDiff VMATree::register_mapping(position A, position B, StateType state, - const RegionData& metadata) { + const RegionData& metadata, bool use_tag_inplace) { + assert(!use_tag_inplace || metadata.mem_tag == mtNone, + "If using use_tag_inplace, then the supplied tag should be mtNone, was instead: %s", NMTUtil::tag_to_name(metadata.mem_tag)); if (A == B) { // A 0-sized mapping isn't worth recording. return SummaryDiff(); @@ -55,6 +58,10 @@ VMATree::SummaryDiff VMATree::register_mapping(position A, position B, StateType AddressState LEQ_A; TreapNode* leqA_n = _tree.closest_leq(A); if (leqA_n == nullptr) { + assert(!use_tag_inplace, "Cannot use the tag inplace if no pre-existing tag exists. From: " PTR_FORMAT " To: " PTR_FORMAT, A, B); + if (use_tag_inplace) { + log_debug(nmt)("Cannot use the tag inplace if no pre-existing tag exists. From: " PTR_FORMAT " To: " PTR_FORMAT, A, B); + } // No match. We add the A node directly, unless it would have no effect. if (!stA.is_noop()) { _tree.upsert(A, stA); @@ -62,6 +69,17 @@ VMATree::SummaryDiff VMATree::register_mapping(position A, position B, StateType } else { LEQ_A_found = true; LEQ_A = AddressState{leqA_n->key(), leqA_n->val()}; + StateType leqA_state = leqA_n->val().out.type(); + StateType new_state = stA.out.type(); + // If we specify use_tag_inplace then the new region takes over the current tag instead of the tag in metadata. + // This is important because the VirtualMemoryTracker API doesn't require supplying the tag for some operations. + if (use_tag_inplace) { + assert(leqA_n->val().out.type() != StateType::Released, "Should not use inplace the tag of a released region"); + MemTag tag = leqA_n->val().out.mem_tag(); + stA.out.set_tag(tag); + stB.in.set_tag(tag); + } + // Unless we know better, let B's outgoing state be the outgoing state of the node at or preceding A. // Consider the case where the found node is the start of a region enclosing [A,B) stB.out = leqA_n->val().out; @@ -83,8 +101,8 @@ VMATree::SummaryDiff VMATree::register_mapping(position A, position B, StateType } else { // If the state is not matching then we have different operations, such as: // reserve [x1, A); ... commit [A, x2); or - // reserve [x1, A), flag1; ... reserve [A, x2), flag2; or - // reserve [A, x1), flag1; ... reserve [A, x2), flag2; + // reserve [x1, A), mem_tag1; ... reserve [A, x2), mem_tag2; or + // reserve [A, x1), mem_tag1; ... reserve [A, x2), mem_tag2; // then we re-use the existing out node, overwriting its old metadata. leqA_n->val() = stA; } @@ -147,7 +165,7 @@ VMATree::SummaryDiff VMATree::register_mapping(position A, position B, StateType if (to_be_deleted_inbetween_a_b.length() == 0 && LEQ_A_found) { // We must have smashed a hole in an existing region (or replaced it entirely). // LEQ_A < A < B <= C - SingleDiff& rescom = diff.flag[NMTUtil::flag_to_index(LEQ_A.out().flag())]; + SingleDiff& rescom = diff.tag[NMTUtil::tag_to_index(LEQ_A.out().mem_tag())]; if (LEQ_A.out().type() == StateType::Reserved) { rescom.reserve -= B - A; } else if (LEQ_A.out().type() == StateType::Committed) { @@ -163,7 +181,7 @@ VMATree::SummaryDiff VMATree::register_mapping(position A, position B, StateType _tree.remove(delete_me.address); // Perform summary accounting - SingleDiff& rescom = diff.flag[NMTUtil::flag_to_index(delete_me.in().flag())]; + SingleDiff& rescom = diff.tag[NMTUtil::tag_to_index(delete_me.in().mem_tag())]; if (delete_me.in().type() == StateType::Reserved) { rescom.reserve -= delete_me.address - prev.address; } else if (delete_me.in().type() == StateType::Committed) { @@ -178,17 +196,17 @@ VMATree::SummaryDiff VMATree::register_mapping(position A, position B, StateType // A - prev - B - (some node >= B) // It might be that prev.address == B == (some node >= B), this is fine. if (prev.out().type() == StateType::Reserved) { - SingleDiff& rescom = diff.flag[NMTUtil::flag_to_index(prev.out().flag())]; + SingleDiff& rescom = diff.tag[NMTUtil::tag_to_index(prev.out().mem_tag())]; rescom.reserve -= B - prev.address; } else if (prev.out().type() == StateType::Committed) { - SingleDiff& rescom = diff.flag[NMTUtil::flag_to_index(prev.out().flag())]; + SingleDiff& rescom = diff.tag[NMTUtil::tag_to_index(prev.out().mem_tag())]; rescom.commit -= B - prev.address; rescom.reserve -= B - prev.address; } } // Finally, we can register the new region [A, B)'s summary data. - SingleDiff& rescom = diff.flag[NMTUtil::flag_to_index(metadata.flag)]; + SingleDiff& rescom = diff.tag[NMTUtil::tag_to_index(metadata.mem_tag)]; if (state == StateType::Reserved) { rescom.reserve += B - A; } else if (state == StateType::Committed) { diff --git a/src/hotspot/share/nmt/vmatree.hpp b/src/hotspot/share/nmt/vmatree.hpp index 3316219a1d3..cfb3c8ab524 100644 --- a/src/hotspot/share/nmt/vmatree.hpp +++ b/src/hotspot/share/nmt/vmatree.hpp @@ -35,7 +35,7 @@ // A VMATree stores a sequence of points on the natural number line. // Each of these points stores information about a state change. // For example, the state may go from released memory to committed memory, -// or from committed memory of a certain MEMFLAGS to committed memory of a different MEMFLAGS. +// or from committed memory of a certain MemTag to committed memory of a different MemTag. // The set of points is stored in a balanced binary tree for efficient querying and updating. class VMATree { friend class NMTVMATreeTest; @@ -66,18 +66,18 @@ public: return statetype_strings[static_cast(type)]; } - // Each point has some stack and a flag associated with it. + // Each point has some stack and a tag associated with it. struct RegionData { const NativeCallStackStorage::StackIndex stack_idx; - const MEMFLAGS flag; + const MemTag mem_tag; - RegionData() : stack_idx(), flag(mtNone) {} + RegionData() : stack_idx(), mem_tag(mtNone) {} - RegionData(NativeCallStackStorage::StackIndex stack_idx, MEMFLAGS flag) - : stack_idx(stack_idx), flag(flag) {} + RegionData(NativeCallStackStorage::StackIndex stack_idx, MemTag mem_tag) + : stack_idx(stack_idx), mem_tag(mem_tag) {} static bool equals(const RegionData& a, const RegionData& b) { - return a.flag == b.flag && + return a.mem_tag == b.mem_tag && NativeCallStackStorage::equals(a.stack_idx, b.stack_idx); } }; @@ -87,29 +87,33 @@ public: private: struct IntervalState { private: - // Store the type and flag as two bytes - uint8_t type_flag[2]; + // Store the type and mem_tag as two bytes + uint8_t type_tag[2]; NativeCallStackStorage::StackIndex sidx; public: - IntervalState() : type_flag{0,0}, sidx() {} + IntervalState() : type_tag{0,0}, sidx() {} IntervalState(const StateType type, const RegionData data) { - assert(!(type == StateType::Released) || data.flag == mtNone, "Released type must have flag mtNone"); - type_flag[0] = static_cast(type); - type_flag[1] = static_cast(data.flag); + assert(!(type == StateType::Released) || data.mem_tag == mtNone, "Released type must have memory tag mtNone"); + type_tag[0] = static_cast(type); + type_tag[1] = static_cast(data.mem_tag); sidx = data.stack_idx; } StateType type() const { - return static_cast(type_flag[0]); + return static_cast(type_tag[0]); } - MEMFLAGS flag() const { - return static_cast(type_flag[1]); + MemTag mem_tag() const { + return static_cast(type_tag[1]); } RegionData regiondata() const { - return RegionData{sidx, flag()}; + return RegionData{sidx, mem_tag()}; + } + + void set_tag(MemTag tag) { + type_tag[1] = static_cast(tag); } NativeCallStackStorage::StackIndex stack() const { @@ -159,22 +163,28 @@ public: delta commit; }; struct SummaryDiff { - SingleDiff flag[mt_number_of_types]; + SingleDiff tag[mt_number_of_tags]; SummaryDiff() { - for (int i = 0; i < mt_number_of_types; i++) { - flag[i] = SingleDiff{0, 0}; + for (int i = 0; i < mt_number_of_tags; i++) { + tag[i] = SingleDiff{0, 0}; } } }; - SummaryDiff register_mapping(position A, position B, StateType state, const RegionData& metadata); + private: + SummaryDiff register_mapping(position A, position B, StateType state, const RegionData& metadata, bool use_tag_inplace = false); + public: SummaryDiff reserve_mapping(position from, position sz, const RegionData& metadata) { - return register_mapping(from, from + sz, StateType::Reserved, metadata); + return register_mapping(from, from + sz, StateType::Reserved, metadata, false); } - SummaryDiff commit_mapping(position from, position sz, const RegionData& metadata) { - return register_mapping(from, from + sz, StateType::Committed, metadata); + SummaryDiff commit_mapping(position from, position sz, const RegionData& metadata, bool use_tag_inplace = false) { + return register_mapping(from, from + sz, StateType::Committed, metadata, use_tag_inplace); + } + + SummaryDiff uncommit_mapping(position from, position sz, const RegionData& metadata) { + return register_mapping(from, from + sz, StateType::Reserved, metadata, true); } SummaryDiff release_mapping(position from, position sz) { diff --git a/src/hotspot/share/oops/annotations.hpp b/src/hotspot/share/oops/annotations.hpp index 0260de2d8d4..4e9fa56ace9 100644 --- a/src/hotspot/share/oops/annotations.hpp +++ b/src/hotspot/share/oops/annotations.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -89,7 +89,6 @@ class Annotations: public MetaspaceObj { // Turn metadata annotations into a Java heap object (oop) static typeArrayOop make_java_array(AnnotationArray* annotations, TRAPS); - bool is_klass() const { return false; } void metaspace_pointers_do(MetaspaceClosure* it); MetaspaceObj::Type type() const { return AnnotationsType; } diff --git a/src/hotspot/share/oops/array.inline.hpp b/src/hotspot/share/oops/array.inline.hpp index 196792334e5..28f8a35dc0d 100644 --- a/src/hotspot/share/oops/array.inline.hpp +++ b/src/hotspot/share/oops/array.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,7 @@ template inline void* Array::operator new(size_t size, ClassLoaderData* loader_data, int length, TRAPS) throw() { size_t word_size = Array::size(length); return (void*) Metaspace::allocate(loader_data, word_size, - MetaspaceObj::array_type(sizeof(T)), THREAD); + MetaspaceObj::array_type(sizeof(T)), false, THREAD); } #endif // SHARE_OOPS_ARRAY_INLINE_HPP diff --git a/src/hotspot/share/oops/arrayKlass.cpp b/src/hotspot/share/oops/arrayKlass.cpp index 275913e3f7f..fd362ae8a06 100644 --- a/src/hotspot/share/oops/arrayKlass.cpp +++ b/src/hotspot/share/oops/arrayKlass.cpp @@ -42,6 +42,10 @@ #include "oops/oop.inline.hpp" #include "runtime/handles.inline.hpp" +void* ArrayKlass::operator new(size_t size, ClassLoaderData* loader_data, size_t word_size, TRAPS) throw() { + return Metaspace::allocate(loader_data, word_size, MetaspaceObj::ClassType, true, THREAD); +} + ArrayKlass::ArrayKlass() { assert(CDSConfig::is_dumping_static_archive() || CDSConfig::is_using_archive(), "only for CDS"); } diff --git a/src/hotspot/share/oops/arrayKlass.hpp b/src/hotspot/share/oops/arrayKlass.hpp index 681d101e0e2..1c1d01fc32a 100644 --- a/src/hotspot/share/oops/arrayKlass.hpp +++ b/src/hotspot/share/oops/arrayKlass.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -49,6 +49,8 @@ class ArrayKlass: public Klass { ArrayKlass(Symbol* name, KlassKind kind); ArrayKlass(); + void* operator new(size_t size, ClassLoaderData* loader_data, size_t word_size, TRAPS) throw(); + public: // Testing operation DEBUG_ONLY(bool is_array_klass_slow() const { return true; }) diff --git a/src/hotspot/share/oops/compressedKlass.cpp b/src/hotspot/share/oops/compressedKlass.cpp index 4a94eb9bde0..02483d25a9a 100644 --- a/src/hotspot/share/oops/compressedKlass.cpp +++ b/src/hotspot/share/oops/compressedKlass.cpp @@ -25,7 +25,7 @@ #include "precompiled.hpp" #include "logging/log.hpp" #include "memory/metaspace.hpp" -#include "oops/compressedKlass.hpp" +#include "oops/compressedKlass.inline.hpp" #include "runtime/globals.hpp" #include "runtime/os.hpp" #include "utilities/debug.hpp" @@ -34,7 +34,8 @@ address CompressedKlassPointers::_base = nullptr; int CompressedKlassPointers::_shift = 0; -size_t CompressedKlassPointers::_range = 0; +address CompressedKlassPointers::_klass_range_start = nullptr; +address CompressedKlassPointers::_klass_range_end = nullptr; #ifdef _LP64 @@ -60,9 +61,12 @@ void CompressedKlassPointers::initialize_for_given_encoding(address addr, size_t assert(requested_base == addr, "Invalid requested base"); assert(encoding_range_end >= end, "Encoding does not cover the full Klass range"); + // Remember Klass range: + _klass_range_start = addr; + _klass_range_end = addr + len; + _base = requested_base; _shift = requested_shift; - _range = encoding_range_size; DEBUG_ONLY(assert_is_valid_encoding(addr, len, _base, _shift);) } @@ -87,6 +91,11 @@ char* CompressedKlassPointers::reserve_address_space_for_16bit_move(size_t size, #if !defined(AARCH64) || defined(ZERO) // On aarch64 we have an own version; all other platforms use the default version void CompressedKlassPointers::initialize(address addr, size_t len) { + + // Remember the Klass range: + _klass_range_start = addr; + _klass_range_end = addr + len; + // The default version of this code tries, in order of preference: // -unscaled (base=0 shift=0) // -zero-based (base=0 shift>0) @@ -111,16 +120,20 @@ void CompressedKlassPointers::initialize(address addr, size_t len) { _shift = 0; } } - _range = end - _base; DEBUG_ONLY(assert_is_valid_encoding(addr, len, _base, _shift);) } #endif // !AARCH64 || ZERO void CompressedKlassPointers::print_mode(outputStream* st) { - st->print_cr("Narrow klass base: " PTR_FORMAT ", Narrow klass shift: %d, " - "Narrow klass range: " SIZE_FORMAT_X, p2i(base()), shift(), - range()); + if (UseCompressedClassPointers) { + st->print_cr("Narrow klass base: " PTR_FORMAT ", Narrow klass shift: %d", + p2i(base()), shift()); + st->print_cr("Encoding Range: " RANGE2FMT, RANGE2FMTARGS(_base, encoding_range_end())); + st->print_cr("Klass Range: " RANGE2FMT, RANGE2FMTARGS(_klass_range_start, _klass_range_end)); + } else { + st->print_cr("UseCompressedClassPointers off"); + } } #endif // _LP64 diff --git a/src/hotspot/share/oops/compressedKlass.hpp b/src/hotspot/share/oops/compressedKlass.hpp index 1c1bce101a4..8f89b0550ff 100644 --- a/src/hotspot/share/oops/compressedKlass.hpp +++ b/src/hotspot/share/oops/compressedKlass.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,6 +31,69 @@ class outputStream; class Klass; +// Narrow Klass Encoding +// +// Klass Range: +// a contiguous memory range into which we place Klass that should be encodable. Not every Klass +// needs to be encodable. There is only one such memory range. +// If CDS is disabled, this Klass Range is the same as the metaspace class space. If CDS is enabled, the +// Klass Range contains both CDS and class space adjacent to each other (with a potential small +// unused alignment gap between them). +// +// Encoding Range: +// This is the range covered by the current encoding scheme. The encoding scheme is defined by +// the encoding base, encoding shift and (implicitly) the bit size of the narrowKlass. The +// Encoding Range is: +// [ ... + (1 << ( + ) ) +// +// Note that while the Klass Range must be contained within the Encoding Range, the Encoding Range +// is typically a lot larger than the Klass Range: +// - the encoding base can start before the Klass Range start (specifically, it can start at 0 for +// zero-based encoding) +// - the end of the Encoding Range usually extends far beyond the end of the Klass Range. +// +// +// Examples: +// +// "unscaled" (zero-based zero-shift) encoding, CDS off, class space of 1G starts at 0x4B00_0000: +// - Encoding Range: [0 .. 0x1_0000_0000 ) (4 GB) +// - Klass Range: [0x4B00_0000 .. 0x 8B00_0000 ) (1 GB) +// +// +// _base _klass_range_start _klass_range_end encoding end +// | |//////////////////////////////| | +// | ... |///////1gb class space////////| ... | +// | |//////////////////////////////| | +// 0x0 0x4B00_0000 0x8B00_0000 0x1_0000_0000 +// +// +// +// "zero-based" (but scaled) encoding, shift=3, CDS off, 1G Class space at 0x7_C000_0000 (31GB): +// - Encoding Range: [0 .. 0x8_0000_0000 ) (32 GB) +// - Klass Range: [0x7_C000_0000 .. 0x8_0000_0000 ) (1 GB) +// +// encoding end +// _base _klass_range_start _klass_range_end +// | |//////////////////////////////| +// | ... |///////1gb class space////////| +// | |//////////////////////////////| +// 0x0 0x7_C000_0000 0x8_0000_0000 +// +// +// CDS enabled, 128MB CDS region starts 0x8_0000_0000, followed by a 1GB class space. Encoding +// base will point to CDS region start, shift=0: +// - Encoding Range: [0x8_0000_0000 .. 0x9_0000_0000 ) (4 GB) +// - Klass Range: [0x8_0000_0000 .. 0x8_4800_0000 ) (128 MB + 1 GB) +// +// _base +// _klass_range_start _klass_range_end encoding end +// |//////////|///////////////////////////| | +// |///CDS////|////1gb class space////////| ... ... | +// |//////////|///////////////////////////| | +// | | | +// 0x8_0000_0000 0x8_4800_0000 0x9_0000_0000 +// + // If compressed klass pointers then use narrowKlass. typedef juint narrowKlass; @@ -50,12 +113,10 @@ class CompressedKlassPointers : public AllStatic { static address _base; static int _shift; - // Together with base, this defines the address range within which Klass - // structures will be located: [base, base+range). While the maximal - // possible encoding range is 4|32G for shift 0|3, if we know beforehand - // the expected range of Klass* pointers will be smaller, a platform - // could use this info to optimize encoding. - static size_t _range; + // Start and end of the Klass Range. + // Note: guaranteed to be aligned to KlassAlignmentInBytes + static address _klass_range_start; + static address _klass_range_end; // Helper function for common cases. static char* reserve_address_space_X(uintptr_t from, uintptr_t to, size_t size, size_t alignment, bool aslr); @@ -92,9 +153,13 @@ public: static void print_mode(outputStream* st); static address base() { return _base; } - static size_t range() { return _range; } static int shift() { return _shift; } + static address klass_range_start() { return _klass_range_start; } + static address klass_range_end() { return _klass_range_end; } + + static inline address encoding_range_end(); + static bool is_null(Klass* v) { return v == nullptr; } static bool is_null(narrowKlass v) { return v == 0; } @@ -107,6 +172,13 @@ public: static inline narrowKlass encode_not_null(Klass* v); static inline narrowKlass encode(Klass* v); + + // Returns whether the pointer is in the memory region used for encoding compressed + // class pointers. This includes CDS. + static inline bool is_encodable(const void* p) { + return (address) p >= _klass_range_start && + (address) p < _klass_range_end; + } }; #endif // SHARE_OOPS_COMPRESSEDKLASS_HPP diff --git a/src/hotspot/share/oops/compressedKlass.inline.hpp b/src/hotspot/share/oops/compressedKlass.inline.hpp index 87ef2102b38..c9c9af24ad8 100644 --- a/src/hotspot/share/oops/compressedKlass.inline.hpp +++ b/src/hotspot/share/oops/compressedKlass.inline.hpp @@ -51,7 +51,7 @@ inline narrowKlass CompressedKlassPointers::encode_not_null(Klass* v, address na assert(!is_null(v), "klass value can never be zero"); assert(check_alignment(v), "Address not aligned"); uint64_t pd = (uint64_t)(pointer_delta(v, narrow_base, 1)); - assert(KlassEncodingMetaspaceMax > pd, "change encoding max if new encoding"); + assert(KlassEncodingMetaspaceMax > pd, "change encoding max if new encoding (Klass " PTR_FORMAT ", Base " PTR_FORMAT ")", p2i(v), p2i(narrow_base)); uint64_t result = pd >> shift; assert((result & CONST64(0xffffffff00000000)) == 0, "narrow klass pointer overflow"); assert(decode_not_null((narrowKlass)result, narrow_base, shift) == v, "reversibility"); @@ -82,4 +82,9 @@ inline narrowKlass CompressedKlassPointers::encode(Klass* v) { return is_null(v) ? (narrowKlass)0 : encode_not_null(v); } +inline address CompressedKlassPointers::encoding_range_end() { + const int max_bits = (sizeof(narrowKlass) * BitsPerByte) + _shift; // narrowKlass are 32 bit + return _base + nth_bit(max_bits); +} + #endif // SHARE_OOPS_COMPRESSEDKLASS_INLINE_HPP diff --git a/src/hotspot/share/oops/compressedOops.cpp b/src/hotspot/share/oops/compressedOops.cpp index 08f78b1d773..ec41dd85219 100644 --- a/src/hotspot/share/oops/compressedOops.cpp +++ b/src/hotspot/share/oops/compressedOops.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,8 +35,10 @@ #include "runtime/globals.hpp" // For UseCompressedOops. -NarrowPtrStruct CompressedOops::_narrow_oop = { nullptr, 0, true }; -MemRegion CompressedOops::_heap_address_range; +address CompressedOops::_base = nullptr; +int CompressedOops::_shift = 0; +bool CompressedOops::_use_implicit_null_checks = true; +MemRegion CompressedOops::_heap_address_range; // Choose the heap base address and oop encoding mode // when compressed oops are used: @@ -59,7 +61,7 @@ void CompressedOops::initialize(const ReservedHeapSpace& heap_space) { } if ((uint64_t)heap_space.end() <= OopEncodingHeapMax) { // Did reserve heap below 32Gb. Can use base == 0; - set_base(0); + set_base(nullptr); } else { set_base((address)heap_space.compressed_oop_base()); } @@ -88,16 +90,16 @@ void CompressedOops::initialize(const ReservedHeapSpace& heap_space) { void CompressedOops::set_base(address base) { assert(UseCompressedOops, "no compressed oops?"); - _narrow_oop._base = base; + _base = base; } void CompressedOops::set_shift(int shift) { - _narrow_oop._shift = shift; + _shift = shift; } void CompressedOops::set_use_implicit_null_checks(bool use) { assert(UseCompressedOops, "no compressed ptrs?"); - _narrow_oop._use_implicit_null_checks = use; + _use_implicit_null_checks = use; } bool CompressedOops::is_in(void* addr) { @@ -113,7 +115,7 @@ CompressedOops::Mode CompressedOops::mode() { return DisjointBaseNarrowOop; } - if (base() != 0) { + if (base() != nullptr) { return HeapBasedNarrowOop; } @@ -148,14 +150,14 @@ bool CompressedOops::is_disjoint_heap_base_address(address addr) { // Check for disjoint base compressed oops. bool CompressedOops::base_disjoint() { - return _narrow_oop._base != nullptr && is_disjoint_heap_base_address(_narrow_oop._base); + return _base != nullptr && is_disjoint_heap_base_address(_base); } // Check for real heapbased compressed oops. // We must subtract the base as the bits overlap. // If we negate above function, we also get unscaled and zerobased. bool CompressedOops::base_overlaps() { - return _narrow_oop._base != nullptr && !is_disjoint_heap_base_address(_narrow_oop._base); + return _base != nullptr && !is_disjoint_heap_base_address(_base); } void CompressedOops::print_mode(outputStream* st) { @@ -164,7 +166,7 @@ void CompressedOops::print_mode(outputStream* st) { st->print(", Compressed Oops mode: %s", mode_to_string(mode())); - if (base() != 0) { + if (base() != nullptr) { st->print(": " PTR_FORMAT, p2i(base())); } diff --git a/src/hotspot/share/oops/compressedOops.hpp b/src/hotspot/share/oops/compressedOops.hpp index cd3f00393ca..33af420305c 100644 --- a/src/hotspot/share/oops/compressedOops.hpp +++ b/src/hotspot/share/oops/compressedOops.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,23 +34,18 @@ class outputStream; class ReservedHeapSpace; -struct NarrowPtrStruct { - // Base address for oop-within-java-object materialization. - // null if using wide oops or zero based narrow oops. - address _base; - // Number of shift bits for encoding/decoding narrow ptrs. - // 0 if using wide ptrs or zero based unscaled narrow ptrs, - // LogMinObjAlignmentInBytes otherwise. - int _shift; - // Generate code with implicit null checks for narrow ptrs. - bool _use_implicit_null_checks; -}; - class CompressedOops : public AllStatic { friend class VMStructs; - // For UseCompressedOops. - static NarrowPtrStruct _narrow_oop; + // Base address for oop-within-java-object materialization. + // null if using wide oops or zero based narrow oops. + static address _base; + // Number of shift bits for encoding/decoding narrow ptrs. + // 0 if using wide oops or zero based unscaled narrow oops, + // LogMinObjAlignmentInBytes otherwise. + static int _shift; + // Generate code with implicit null checks for narrow oops. + static bool _use_implicit_null_checks; // The address range of the heap static MemRegion _heap_address_range; @@ -73,8 +68,7 @@ public: UnscaledNarrowOop = 0, ZeroBasedNarrowOop = 1, DisjointBaseNarrowOop = 2, - HeapBasedNarrowOop = 3, - AnyNarrowOopMode = 4 + HeapBasedNarrowOop = 3 }; // The representation type for narrowOop is assumed to be uint32_t. @@ -87,15 +81,13 @@ public: static void set_shift(int shift); static void set_use_implicit_null_checks(bool use); - static address base() { return _narrow_oop._base; } + static address base() { return _base; } + static address base_addr() { return (address)&_base; } static address begin() { return (address)_heap_address_range.start(); } static address end() { return (address)_heap_address_range.end(); } static bool is_base(void* addr) { return (base() == (address)addr); } - static int shift() { return _narrow_oop._shift; } - static bool use_implicit_null_checks() { return _narrow_oop._use_implicit_null_checks; } - - static address ptrs_base_addr() { return (address)&_narrow_oop._base; } - static address ptrs_base() { return _narrow_oop._base; } + static int shift() { return _shift; } + static bool use_implicit_null_checks() { return _use_implicit_null_checks; } static bool is_in(void* addr); static bool is_in(MemRegion mr); diff --git a/src/hotspot/share/oops/constMethod.hpp b/src/hotspot/share/oops/constMethod.hpp index 5f0c49f9319..47fcb0d5572 100644 --- a/src/hotspot/share/oops/constMethod.hpp +++ b/src/hotspot/share/oops/constMethod.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -470,7 +470,6 @@ public: // Deallocation for RedefineClasses void deallocate_contents(ClassLoaderData* loader_data); - bool is_klass() const { return false; } DEBUG_ONLY(bool on_stack() { return false; }) void metaspace_pointers_do(MetaspaceClosure* it); diff --git a/src/hotspot/share/oops/constantPool.hpp b/src/hotspot/share/oops/constantPool.hpp index 7a17c62ddaf..bcc9a08dd6c 100644 --- a/src/hotspot/share/oops/constantPool.hpp +++ b/src/hotspot/share/oops/constantPool.hpp @@ -37,6 +37,7 @@ #include "utilities/align.hpp" #include "utilities/bytes.hpp" #include "utilities/constantTag.hpp" +#include "utilities/macros.hpp" #include "utilities/resourceHash.hpp" // A ConstantPool is an array containing class constants as described in the @@ -781,7 +782,7 @@ private: int pre_resolve_shared_klasses(TRAPS); // Debugging - const char* printable_name_at(int cp_index) PRODUCT_RETURN0; + const char* printable_name_at(int cp_index) PRODUCT_RETURN_NULL; private: diff --git a/src/hotspot/share/oops/cpCache.cpp b/src/hotspot/share/oops/cpCache.cpp index 817a35959f3..321d8add755 100644 --- a/src/hotspot/share/oops/cpCache.cpp +++ b/src/hotspot/share/oops/cpCache.cpp @@ -604,6 +604,7 @@ void ConstantPoolCache::adjust_method_entries(bool * trace_name_printed) { if (old_method == nullptr || !old_method->is_old()) { continue; } + assert(!old_method->is_deleted(), "cannot delete these methods"); Method* new_method = old_method->get_new_method(); resolved_indy_entry_at(j)->adjust_method_entry(new_method); log_adjust("indy", old_method, new_method, trace_name_printed); diff --git a/src/hotspot/share/oops/cpCache.hpp b/src/hotspot/share/oops/cpCache.hpp index c741201c833..f95f141d845 100644 --- a/src/hotspot/share/oops/cpCache.hpp +++ b/src/hotspot/share/oops/cpCache.hpp @@ -231,7 +231,6 @@ class ConstantPoolCache: public MetaspaceObj { // RedefineClasses support DEBUG_ONLY(bool on_stack() { return false; }) void deallocate_contents(ClassLoaderData* data); - bool is_klass() const { return false; } void record_gc_epoch(); uint64_t gc_epoch() { return _gc_epoch; } diff --git a/src/hotspot/share/oops/instanceKlass.cpp b/src/hotspot/share/oops/instanceKlass.cpp index 650279db1be..6b6d35ee026 100644 --- a/src/hotspot/share/oops/instanceKlass.cpp +++ b/src/hotspot/share/oops/instanceKlass.cpp @@ -437,6 +437,11 @@ const char* InstanceKlass::nest_host_error() { } } +void* InstanceKlass::operator new(size_t size, ClassLoaderData* loader_data, size_t word_size, + bool use_class_space, TRAPS) throw() { + return Metaspace::allocate(loader_data, word_size, ClassType, use_class_space, THREAD); +} + InstanceKlass* InstanceKlass::allocate_instance_klass(const ClassFileParser& parser, TRAPS) { const int size = InstanceKlass::size(parser.vtable_size(), parser.itable_size(), @@ -449,23 +454,24 @@ InstanceKlass* InstanceKlass::allocate_instance_klass(const ClassFileParser& par assert(loader_data != nullptr, "invariant"); InstanceKlass* ik; + const bool use_class_space = !parser.is_interface() && !parser.is_abstract(); // Allocation if (parser.is_instance_ref_klass()) { // java.lang.ref.Reference - ik = new (loader_data, size, THREAD) InstanceRefKlass(parser); + ik = new (loader_data, size, use_class_space, THREAD) InstanceRefKlass(parser); } else if (class_name == vmSymbols::java_lang_Class()) { // mirror - java.lang.Class - ik = new (loader_data, size, THREAD) InstanceMirrorKlass(parser); + ik = new (loader_data, size, use_class_space, THREAD) InstanceMirrorKlass(parser); } else if (is_stack_chunk_class(class_name, loader_data)) { // stack chunk - ik = new (loader_data, size, THREAD) InstanceStackChunkKlass(parser); + ik = new (loader_data, size, use_class_space, THREAD) InstanceStackChunkKlass(parser); } else if (is_class_loader(class_name, parser)) { // class loader - java.lang.ClassLoader - ik = new (loader_data, size, THREAD) InstanceClassLoaderKlass(parser); + ik = new (loader_data, size, use_class_space, THREAD) InstanceClassLoaderKlass(parser); } else { // normal - ik = new (loader_data, size, THREAD) InstanceKlass(parser); + ik = new (loader_data, size, use_class_space, THREAD) InstanceKlass(parser); } // Check for pending exception before adding to the loader data and incrementing @@ -2659,8 +2665,8 @@ void InstanceKlass::restore_unshareable_info(ClassLoaderData* loader_data, Handl array_klasses()->restore_unshareable_info(class_loader_data(), Handle(), CHECK); } - // Initialize @ValueBased class annotation - if (DiagnoseSyncOnValueBasedClasses && has_value_based_class_annotation()) { + // Initialize @ValueBased class annotation if not already set in the archived klass. + if (DiagnoseSyncOnValueBasedClasses && has_value_based_class_annotation() && !is_value_based()) { set_is_value_based(); } } @@ -2715,6 +2721,13 @@ static void clear_all_breakpoints(Method* m) { #endif void InstanceKlass::unload_class(InstanceKlass* ik) { + + if (ik->is_scratch_class()) { + assert(ik->dependencies().is_empty(), "dependencies should be empty for scratch classes"); + return; + } + assert(ik->is_loaded(), "class should be loaded " PTR_FORMAT, p2i(ik)); + // Release dependencies. ik->dependencies().remove_all_dependents(); @@ -4090,7 +4103,7 @@ void InstanceKlass::set_init_state(ClassState state) { assert(good_state || state == allocated, "illegal state transition"); #endif assert(_init_thread == nullptr, "should be cleared before state change"); - _init_state = state; + Atomic::release_store(&_init_state, state); } #if INCLUDE_JVMTI diff --git a/src/hotspot/share/oops/instanceKlass.hpp b/src/hotspot/share/oops/instanceKlass.hpp index b639b820d10..45d65f273c8 100644 --- a/src/hotspot/share/oops/instanceKlass.hpp +++ b/src/hotspot/share/oops/instanceKlass.hpp @@ -25,6 +25,7 @@ #ifndef SHARE_OOPS_INSTANCEKLASS_HPP #define SHARE_OOPS_INSTANCEKLASS_HPP +#include "memory/allocation.hpp" #include "memory/referenceType.hpp" #include "oops/annotations.hpp" #include "oops/constMethod.hpp" @@ -144,6 +145,8 @@ class InstanceKlass: public Klass { protected: InstanceKlass(const ClassFileParser& parser, KlassKind kind = Kind, ReferenceType reference_type = REF_NONE); + void* operator new(size_t size, ClassLoaderData* loader_data, size_t word_size, bool use_class_space, TRAPS) throw(); + public: InstanceKlass(); @@ -504,14 +507,14 @@ public: public: // initialization state - bool is_loaded() const { return _init_state >= loaded; } - bool is_linked() const { return _init_state >= linked; } - bool is_initialized() const { return _init_state == fully_initialized; } - bool is_not_initialized() const { return _init_state < being_initialized; } - bool is_being_initialized() const { return _init_state == being_initialized; } - bool is_in_error_state() const { return _init_state == initialization_error; } + bool is_loaded() const { return init_state() >= loaded; } + bool is_linked() const { return init_state() >= linked; } + bool is_initialized() const { return init_state() == fully_initialized; } + bool is_not_initialized() const { return init_state() < being_initialized; } + bool is_being_initialized() const { return init_state() == being_initialized; } + bool is_in_error_state() const { return init_state() == initialization_error; } bool is_reentrant_initialization(Thread *thread) { return thread == _init_thread; } - ClassState init_state() const { return _init_state; } + ClassState init_state() const { return Atomic::load_acquire(&_init_state); } const char* init_state_name() const; bool is_rewritten() const { return _misc_flags.rewritten(); } diff --git a/src/hotspot/share/oops/klass.cpp b/src/hotspot/share/oops/klass.cpp index 964bb030b96..9e90b4846a6 100644 --- a/src/hotspot/share/oops/klass.cpp +++ b/src/hotspot/share/oops/klass.cpp @@ -65,7 +65,7 @@ void Klass::set_java_mirror(Handle m) { } bool Klass::is_cloneable() const { - return _access_flags.is_cloneable_fast() || + return _misc_flags.is_cloneable_fast() || is_subtype_of(vmClasses::Cloneable_klass()); } @@ -76,7 +76,7 @@ void Klass::set_is_cloneable() { } else if (is_instance_klass() && InstanceKlass::cast(this)->reference_type() != REF_NONE) { // Reference cloning should not be intrinsified and always happen in JVM_Clone. } else { - _access_flags.set_is_cloneable_fast(); + _misc_flags.set_is_cloneable_fast(true); } } @@ -247,10 +247,6 @@ Method* Klass::uncached_lookup_method(const Symbol* name, const Symbol* signatur return nullptr; } -void* Klass::operator new(size_t size, ClassLoaderData* loader_data, size_t word_size, TRAPS) throw() { - return Metaspace::allocate(loader_data, word_size, MetaspaceObj::ClassType, THREAD); -} - Klass::Klass() : _kind(UnknownKlassKind) { assert(CDSConfig::is_dumping_static_archive() || CDSConfig::is_using_archive(), "only for cds"); } @@ -975,6 +971,7 @@ void Klass::oop_print_on(oop obj, outputStream* st) { // print class st->print(BULLET"klass: "); obj->klass()->print_value_on(st); + st->print(BULLET"flags: "); _misc_flags.print_on(st); st->cr(); st->cr(); } diff --git a/src/hotspot/share/oops/klass.hpp b/src/hotspot/share/oops/klass.hpp index 6ec6ac889be..b782799927b 100644 --- a/src/hotspot/share/oops/klass.hpp +++ b/src/hotspot/share/oops/klass.hpp @@ -27,6 +27,7 @@ #include "memory/iterator.hpp" #include "memory/memRegion.hpp" +#include "oops/klassFlags.hpp" #include "oops/markWord.hpp" #include "oops/metadata.hpp" #include "oops/oop.hpp" @@ -165,6 +166,8 @@ class Klass : public Metadata { // Keep it away from the beginning of a Klass to avoid cacheline // contention that may happen when a nearby object is modified. AccessFlags _access_flags; // Access flags. The class/interface distinction is stored here. + // Some flags created by the JVM, not in the class file itself, + // are in _misc_flags below. JFR_ONLY(DEFINE_TRACE_ID_FIELD;) @@ -194,6 +197,8 @@ private: }; #endif + KlassFlags _misc_flags; + CDS_JAVA_HEAP_ONLY(int _archived_mirror_index;) protected: @@ -201,8 +206,6 @@ protected: Klass(KlassKind kind); Klass(); - void* operator new(size_t size, ClassLoaderData* loader_data, size_t word_size, TRAPS) throw(); - public: int kind() { return _kind; } @@ -428,6 +431,7 @@ protected: static ByteSize next_sibling_offset() { return byte_offset_of(Klass, _next_sibling); } #endif static ByteSize bitmap_offset() { return byte_offset_of(Klass, _bitmap); } + static ByteSize misc_flags_offset() { return byte_offset_of(Klass, _misc_flags._flags); } // Unpacking layout_helper: static const int _lh_neutral_value = 0; // neutral non-array non-instance value @@ -692,12 +696,14 @@ protected: bool is_super() const { return _access_flags.is_super(); } bool is_synthetic() const { return _access_flags.is_synthetic(); } void set_is_synthetic() { _access_flags.set_is_synthetic(); } - bool has_finalizer() const { return _access_flags.has_finalizer(); } - void set_has_finalizer() { _access_flags.set_has_finalizer(); } - bool is_hidden() const { return access_flags().is_hidden_class(); } - void set_is_hidden() { _access_flags.set_is_hidden_class(); } - bool is_value_based() { return _access_flags.is_value_based_class(); } - void set_is_value_based() { _access_flags.set_is_value_based_class(); } + bool has_finalizer() const { return _misc_flags.has_finalizer(); } + void set_has_finalizer() { _misc_flags.set_has_finalizer(true); } + bool is_hidden() const { return _misc_flags.is_hidden_class(); } + void set_is_hidden() { _misc_flags.set_is_hidden_class(true); } + bool is_value_based() const { return _misc_flags.is_value_based_class(); } + void set_is_value_based() { _misc_flags.set_is_value_based_class(true); } + + klass_flags_t misc_flags() const { return _misc_flags.value(); } inline bool is_non_strong_hidden() const; diff --git a/src/hotspot/share/oops/klass.inline.hpp b/src/hotspot/share/oops/klass.inline.hpp index a72868a08d8..f549940ef95 100644 --- a/src/hotspot/share/oops/klass.inline.hpp +++ b/src/hotspot/share/oops/klass.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,8 +37,7 @@ inline oop Klass::klass_holder() const { } inline bool Klass::is_non_strong_hidden() const { - return access_flags().is_hidden_class() && - class_loader_data()->has_class_mirror_holder(); + return is_hidden() && class_loader_data()->has_class_mirror_holder(); } // Iff the class loader (or mirror for non-strong hidden classes) is alive the diff --git a/src/hotspot/share/oops/klassFlags.cpp b/src/hotspot/share/oops/klassFlags.cpp new file mode 100644 index 00000000000..6399762e8df --- /dev/null +++ b/src/hotspot/share/oops/klassFlags.cpp @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#include "precompiled.hpp" +#include "oops/klassFlags.hpp" +#include "utilities/ostream.hpp" + +void KlassFlags::print_on(outputStream* st) const { +#define KLASS_FLAGS_PRINT(name, ignore) \ + if (name()) st->print(#name " "); + KLASS_FLAGS_DO(KLASS_FLAGS_PRINT) +#undef KLASS_FLAGS_PRINT +} diff --git a/src/hotspot/share/oops/klassFlags.hpp b/src/hotspot/share/oops/klassFlags.hpp new file mode 100644 index 00000000000..3e71bb3c1b3 --- /dev/null +++ b/src/hotspot/share/oops/klassFlags.hpp @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_OOPS_KLASSFLAGS_HPP +#define SHARE_OOPS_KLASSFLAGS_HPP + +#include "utilities/globalDefinitions.hpp" + +class outputStream; + +// The Klass class contains only parse-time flags and are used by generated code, even though +// most apply to InstanceKlass, access is more straightforward through Klass pointers. +// These flags are JVM internal and not part of the AccessFlags classfile specification. + +using klass_flags_t = u1; + +class KlassFlags { + friend class VMStructs; + friend class JVMCIVMStructs; + + public: +#define KLASS_FLAGS_DO(flag) \ + flag(is_hidden_class , 1 << 0) \ + flag(is_value_based_class , 1 << 1) \ + flag(has_finalizer , 1 << 2) \ + flag(is_cloneable_fast , 1 << 3) \ + /* end of list */ + +#define KLASS_FLAGS_ENUM_NAME(name, value) _misc_##name = value, + enum { + KLASS_FLAGS_DO(KLASS_FLAGS_ENUM_NAME) + }; +#undef KLASS_FLAGS_ENUM_NAME + + // These flags are write-once before the class is published and then read-only + // so don't require atomic updates. + klass_flags_t _flags; + + public: + KlassFlags() : _flags(0) {} + + klass_flags_t value() const { return _flags; } + + // Create getters and setters for the flag values. +#define KLASS_FLAGS_GET_SET(name, ignore) \ + bool name() const { return (_flags & _misc_##name) != 0; } \ + void set_##name(bool b) { \ + assert(!name(), "set once"); \ + if (b) _flags |= _misc_##name; \ + } + KLASS_FLAGS_DO(KLASS_FLAGS_GET_SET) +#undef KLASS_FLAGS_GET_SET + + void print_on(outputStream* st) const; +}; + +#endif // SHARE_OOPS_KLASSFLAGS_HPP diff --git a/src/hotspot/share/oops/klassVtable.cpp b/src/hotspot/share/oops/klassVtable.cpp index cbc379709f1..e1bffc90d51 100644 --- a/src/hotspot/share/oops/klassVtable.cpp +++ b/src/hotspot/share/oops/klassVtable.cpp @@ -1230,9 +1230,10 @@ void klassItable::initialize_itable_and_check_constraints(TRAPS) { } inline bool interface_method_needs_itable_index(Method* m) { - if (m->is_static()) return false; // e.g., Stream.empty - if (m->is_initializer()) return false; // or - if (m->is_private()) return false; // uses direct call + if (m->is_static()) return false; // e.g., Stream.empty + if (m->is_object_initializer()) return false; // + if (m->is_static_initializer()) return false; // + if (m->is_private()) return false; // uses direct call // If an interface redeclares a method from java.lang.Object, // it should already have a vtable index, don't touch it. // e.g., CharSequence.toString (from initialize_vtable) diff --git a/src/hotspot/share/oops/method.cpp b/src/hotspot/share/oops/method.cpp index f4dcd4f1493..a1b380d3646 100644 --- a/src/hotspot/share/oops/method.cpp +++ b/src/hotspot/share/oops/method.cpp @@ -846,10 +846,6 @@ bool Method::is_constant_getter() const { Bytecodes::is_return(java_code_at(last_index))); } -bool Method::is_initializer() const { - return is_object_initializer() || is_static_initializer(); -} - bool Method::has_valid_initializer_flags() const { return (is_static() || method_holder()->major_version() < 51); diff --git a/src/hotspot/share/oops/method.hpp b/src/hotspot/share/oops/method.hpp index 905c53a4ea3..6ffaebcdfda 100644 --- a/src/hotspot/share/oops/method.hpp +++ b/src/hotspot/share/oops/method.hpp @@ -576,9 +576,6 @@ public: // returns true if the method does nothing but return a constant of primitive type bool is_constant_getter() const; - // returns true if the method is an initializer ( or ). - bool is_initializer() const; - // returns true if the method is static OR if the classfile version < 51 bool has_valid_initializer_flags() const; diff --git a/src/hotspot/share/oops/oop.cpp b/src/hotspot/share/oops/oop.cpp index fde91969ea5..38dee491a10 100644 --- a/src/hotspot/share/oops/oop.cpp +++ b/src/hotspot/share/oops/oop.cpp @@ -218,14 +218,3 @@ void oopDesc::release_float_field_put(int offset, jfloat value) { Atomic:: jdouble oopDesc::double_field_acquire(int offset) const { return Atomic::load_acquire(field_addr(offset)); } void oopDesc::release_double_field_put(int offset, jdouble value) { Atomic::release_store(field_addr(offset), value); } - -#ifdef ASSERT -bool oopDesc::size_might_change() { - // UseParallelGC and UseG1GC can change the length field - // of an "old copy" of an object array in the young gen so it indicates - // the grey portion of an already copied array. This will cause the first - // disjunct below to fail if the two comparands are computed across such - // a concurrent change. - return Universe::heap()->is_stw_gc_active() && is_objArray() && is_forwarded() && (UseParallelGC || UseG1GC); -} -#endif diff --git a/src/hotspot/share/oops/oop.hpp b/src/hotspot/share/oops/oop.hpp index 2d827699b41..a330b3df529 100644 --- a/src/hotspot/share/oops/oop.hpp +++ b/src/hotspot/share/oops/oop.hpp @@ -319,8 +319,6 @@ class oopDesc { // for error reporting static void* load_oop_raw(oop obj, int offset); - - DEBUG_ONLY(bool size_might_change();) }; // An oopDesc is not initialized via a constructor. Space is allocated in diff --git a/src/hotspot/share/oops/oop.inline.hpp b/src/hotspot/share/oops/oop.inline.hpp index ffcc9af24c3..95b99b215fa 100644 --- a/src/hotspot/share/oops/oop.inline.hpp +++ b/src/hotspot/share/oops/oop.inline.hpp @@ -190,7 +190,7 @@ size_t oopDesc::size_given_klass(Klass* klass) { // skipping the intermediate round to HeapWordSize. s = align_up(size_in_bytes, MinObjAlignmentInBytes) / HeapWordSize; - assert(s == klass->oop_size(this) || size_might_change(), "wrong array object size"); + assert(s == klass->oop_size(this), "wrong array object size"); } else { // Must be zero, so bite the bullet and take the virtual call. s = klass->oop_size(this); diff --git a/src/hotspot/share/oops/recordComponent.hpp b/src/hotspot/share/oops/recordComponent.hpp index f9f4cdb5ee4..2472d3828fd 100644 --- a/src/hotspot/share/oops/recordComponent.hpp +++ b/src/hotspot/share/oops/recordComponent.hpp @@ -83,8 +83,6 @@ class RecordComponent: public MetaspaceObj { static bool is_read_only_by_default() { return true; } DEBUG_ONLY(bool on_stack() { return false; }) // for template - bool is_klass() const { return false; } - #ifndef PRODUCT void print_on(outputStream* st) const; #endif diff --git a/src/hotspot/share/opto/addnode.cpp b/src/hotspot/share/opto/addnode.cpp index 9a7d93dc469..802af20adae 100644 --- a/src/hotspot/share/opto/addnode.cpp +++ b/src/hotspot/share/opto/addnode.cpp @@ -395,9 +395,159 @@ Node* AddNode::IdealIL(PhaseGVN* phase, bool can_reshape, BasicType bt) { } } + // Convert a + a + ... + a into a*n + Node* serial_additions = convert_serial_additions(phase, bt); + if (serial_additions != nullptr) { + return serial_additions; + } + return AddNode::Ideal(phase, can_reshape); } +// Try to convert a serial of additions into a single multiplication. Also convert `(a * CON) + a` to `(CON + 1) * a` as +// a side effect. On success, a new MulNode is returned. +Node* AddNode::convert_serial_additions(PhaseGVN* phase, BasicType bt) { + // We need to make sure that the current AddNode is not part of a MulNode that has already been optimized to a + // power-of-2 addition (e.g., 3 * a => (a << 2) + a). Without this check, GVN would keep trying to optimize the same + // node and can't progress. For example, 3 * a => (a << 2) + a => 3 * a => (a << 2) + a => ... + if (find_power_of_two_addition_pattern(this, bt, nullptr) != nullptr) { + return nullptr; + } + + Node* in1 = in(1); + Node* in2 = in(2); + jlong multiplier; + + // While multiplications can be potentially optimized to power-of-2 subtractions (e.g., a * 7 => (a << 3) - a), + // (x - y) + y => x is already handled by the Identity() methods. So, we don't need to check for that pattern here. + if (find_simple_addition_pattern(in1, bt, &multiplier) == in2 + || find_simple_lshift_pattern(in1, bt, &multiplier) == in2 + || find_simple_multiplication_pattern(in1, bt, &multiplier) == in2 + || find_power_of_two_addition_pattern(in1, bt, &multiplier) == in2) { + multiplier++; // +1 for the in2 term + + Node* con = (bt == T_INT) + ? (Node*) phase->intcon((jint) multiplier) // intentional type narrowing to allow overflow at max_jint + : (Node*) phase->longcon(multiplier); + return MulNode::make(con, in2, bt); + } + + return nullptr; +} + +// Try to match `a + a`. On success, return `a` and set `2` as `multiplier`. +// The method matches `n` for pattern: AddNode(a, a). +Node* AddNode::find_simple_addition_pattern(Node* n, BasicType bt, jlong* multiplier) { + if (n->Opcode() == Op_Add(bt) && n->in(1) == n->in(2)) { + *multiplier = 2; + return n->in(1); + } + + return nullptr; +} + +// Try to match `a << CON`. On success, return `a` and set `1 << CON` as `multiplier`. +// Match `n` for pattern: LShiftNode(a, CON). +// Note that the power-of-2 multiplication optimization could potentially convert a MulNode to this pattern. +Node* AddNode::find_simple_lshift_pattern(Node* n, BasicType bt, jlong* multiplier) { + // Note that power-of-2 multiplication optimization could potentially convert a MulNode to this pattern + if (n->Opcode() == Op_LShift(bt) && n->in(2)->is_Con()) { + Node* con = n->in(2); + if (con->is_top()) { + return nullptr; + } + + *multiplier = ((jlong) 1 << con->get_int()); + return n->in(1); + } + + return nullptr; +} + +// Try to match `CON * a`. On success, return `a` and set `CON` as `multiplier`. +// Match `n` for patterns: +// - MulNode(CON, a) +// - MulNode(a, CON) +Node* AddNode::find_simple_multiplication_pattern(Node* n, BasicType bt, jlong* multiplier) { + // This optimization technically only produces MulNode(CON, a), but we might as match MulNode(a, CON), too. + if (n->Opcode() == Op_Mul(bt) && (n->in(1)->is_Con() || n->in(2)->is_Con())) { + Node* con = n->in(1); + Node* base = n->in(2); + + // swap ConNode to lhs for easier matching + if (!con->is_Con()) { + swap(con, base); + } + + if (con->is_top()) { + return nullptr; + } + + *multiplier = con->get_integer_as_long(bt); + return base; + } + + return nullptr; +} + +// Try to match `(a << CON1) + (a << CON2)`. On success, return `a` and set `(1 << CON1) + (1 << CON2)` as `multiplier`. +// Match `n` for patterns: +// - AddNode(LShiftNode(a, CON), LShiftNode(a, CON)/a) +// - AddNode(LShiftNode(a, CON)/a, LShiftNode(a, CON)) +// given that lhs is different from rhs. +// Note that one of the term of the addition could simply be `a` (i.e., a << 0). Calling this function with `multiplier` +// being null is safe. +Node* AddNode::find_power_of_two_addition_pattern(Node* n, BasicType bt, jlong* multiplier) { + if (n->Opcode() == Op_Add(bt) && n->in(1) != n->in(2)) { + Node* lhs = n->in(1); + Node* rhs = n->in(2); + + // swap LShiftNode to lhs for easier matching + if (lhs->Opcode() != Op_LShift(bt)) { + swap(lhs, rhs); + } + + // AddNode(LShiftNode(a, CON), *)? + if (lhs->Opcode() != Op_LShift(bt) || !lhs->in(2)->is_Con()) { + return nullptr; + } + + jlong lhs_multiplier = 0; + if (multiplier != nullptr) { + Node* con = lhs->in(2); + if (con->is_top()) { + return nullptr; + } + + lhs_multiplier = (jlong) 1 << con->get_int(); + } + + // AddNode(LShiftNode(a, CON), a)? + if (lhs->in(1) == rhs) { + if (multiplier != nullptr) { + *multiplier = lhs_multiplier + 1; + } + + return rhs; + } + + // AddNode(LShiftNode(a, CON), LShiftNode(a, CON2))? + if (rhs->Opcode() == Op_LShift(bt) && lhs->in(1) == rhs->in(1) && rhs->in(2)->is_Con()) { + if (multiplier != nullptr) { + Node* con = rhs->in(2); + if (con->is_top()) { + return nullptr; + } + + *multiplier = lhs_multiplier + ((jlong) 1 << con->get_int()); + } + + return lhs->in(1); + } + return nullptr; + } + return nullptr; +} Node* AddINode::Ideal(PhaseGVN* phase, bool can_reshape) { Node* in1 = in(1); diff --git a/src/hotspot/share/opto/addnode.hpp b/src/hotspot/share/opto/addnode.hpp index 8879606954a..8afbb440572 100644 --- a/src/hotspot/share/opto/addnode.hpp +++ b/src/hotspot/share/opto/addnode.hpp @@ -42,6 +42,13 @@ typedef const Pair ConstAddOperands; // by virtual functions. class AddNode : public Node { virtual uint hash() const; + + Node* convert_serial_additions(PhaseGVN* phase, BasicType bt); + static Node* find_simple_addition_pattern(Node* n, BasicType bt, jlong* multiplier); + static Node* find_simple_lshift_pattern(Node* n, BasicType bt, jlong* multiplier); + static Node* find_simple_multiplication_pattern(Node* n, BasicType bt, jlong* multiplier); + static Node* find_power_of_two_addition_pattern(Node* n, BasicType bt, jlong* multiplier); + public: AddNode( Node *in1, Node *in2 ) : Node(nullptr,in1,in2) { init_class_id(Class_Add); diff --git a/src/hotspot/share/opto/block.cpp b/src/hotspot/share/opto/block.cpp index 1af085cd128..b39db528691 100644 --- a/src/hotspot/share/opto/block.cpp +++ b/src/hotspot/share/opto/block.cpp @@ -398,7 +398,10 @@ PhaseCFG::PhaseCFG(Arena* arena, RootNode* root, Matcher& matcher) Node *x = new GotoNode(nullptr); x->init_req(0, x); _goto = matcher.match_tree(x); - assert(_goto != nullptr, ""); + assert(_goto != nullptr || C->failure_is_artificial(), ""); + if (C->failing()) { + return; + } _goto->set_req(0,_goto); // Build the CFG in Reverse Post Order diff --git a/src/hotspot/share/opto/buildOopMap.cpp b/src/hotspot/share/opto/buildOopMap.cpp index 4591e87da2d..b553cc6ea69 100644 --- a/src/hotspot/share/opto/buildOopMap.cpp +++ b/src/hotspot/share/opto/buildOopMap.cpp @@ -235,6 +235,13 @@ OopMap *OopFlow::build_oop_map( Node *n, int max_reg, PhaseRegAlloc *regalloc, i Node *def = _defs[reg]; // Get reaching def assert( def, "since live better have reaching def" ); + if (def->is_MachTemp()) { + assert(!def->bottom_type()->isa_oop_ptr(), + "ADLC only assigns OOP types to MachTemp defs corresponding to xRegN operands"); + // Exclude MachTemp definitions even if they are typed as oops. + continue; + } + // Classify the reaching def as oop, derived, callee-save, dead, or other const Type *t = def->bottom_type(); if( t->isa_oop_ptr() ) { // Oop or derived? diff --git a/src/hotspot/share/opto/c2_CodeStubs.hpp b/src/hotspot/share/opto/c2_CodeStubs.hpp index 5db7596e072..e778cfcde47 100644 --- a/src/hotspot/share/opto/c2_CodeStubs.hpp +++ b/src/hotspot/share/opto/c2_CodeStubs.hpp @@ -105,7 +105,6 @@ private: Register _thread; Label _slow_path; Label _push_and_slow_path; - Label _check_successor; Label _unlocked_continuation; public: C2FastUnlockLightweightStub(Register obj, Register mark, Register t, Register thread) : C2CodeStub(), @@ -114,26 +113,10 @@ public: void emit(C2_MacroAssembler& masm); Label& slow_path() { return _slow_path; } Label& push_and_slow_path() { return _push_and_slow_path; } - Label& check_successor() { return _check_successor; } Label& unlocked_continuation() { return _unlocked_continuation; } Label& slow_path_continuation() { return continuation(); } }; -#ifdef _LP64 -class C2HandleAnonOMOwnerStub : public C2CodeStub { -private: - Register _monitor; - Register _tmp; -public: - C2HandleAnonOMOwnerStub(Register monitor, Register tmp = noreg) : C2CodeStub(), - _monitor(monitor), _tmp(tmp) {} - Register monitor() { return _monitor; } - Register tmp() { return _tmp; } - int max_size() const; - void emit(C2_MacroAssembler& masm); -}; -#endif - //-----------------------------C2GeneralStub----------------------------------- // A generalized stub that can be used to implement an arbitrary stub in a // type-safe manner. An example: diff --git a/src/hotspot/share/opto/c2_globals.hpp b/src/hotspot/share/opto/c2_globals.hpp index 7288533cd33..c14162ddf6e 100644 --- a/src/hotspot/share/opto/c2_globals.hpp +++ b/src/hotspot/share/opto/c2_globals.hpp @@ -58,6 +58,9 @@ product(bool, StressMacroExpansion, false, DIAGNOSTIC, \ "Randomize macro node expansion order") \ \ + product(bool, StressUnstableIfTraps, false, DIAGNOSTIC, \ + "Randomly take unstable if traps") \ + \ product(uint, StressSeed, 0, DIAGNOSTIC, \ "Seed for randomized stress testing (if unset, a random one is " \ "generated). The seed is recorded in the compilation log, if " \ @@ -67,6 +70,14 @@ develop(bool, StressMethodHandleLinkerInlining, false, \ "Stress inlining through method handle linkers") \ \ + develop(bool, StressBailout, false, \ + "Perform bailouts randomly at C2 failing() checks") \ + \ + develop(uint, StressBailoutMean, 100000, \ + "The expected number of failing() checks made until " \ + "a random bailout.") \ + range(1, max_juint) \ + \ develop(intx, OptoPrologueNops, 0, \ "Insert this many extra nop instructions " \ "in the prologue of every nmethod") \ diff --git a/src/hotspot/share/opto/c2compiler.cpp b/src/hotspot/share/opto/c2compiler.cpp index 2f087858efd..151c320cadd 100644 --- a/src/hotspot/share/opto/c2compiler.cpp +++ b/src/hotspot/share/opto/c2compiler.cpp @@ -610,6 +610,7 @@ bool C2Compiler::is_intrinsic_supported(vmIntrinsics::ID id) { case vmIntrinsics::_dsin: case vmIntrinsics::_dcos: case vmIntrinsics::_dtan: + case vmIntrinsics::_dtanh: case vmIntrinsics::_dabs: case vmIntrinsics::_fabs: case vmIntrinsics::_iabs: @@ -810,6 +811,7 @@ bool C2Compiler::is_intrinsic_supported(vmIntrinsics::ID id) { case vmIntrinsics::_VectorFromBitsCoerced: case vmIntrinsics::_VectorShuffleIota: case vmIntrinsics::_VectorShuffleToVector: + case vmIntrinsics::_VectorWrapShuffleIndexes: case vmIntrinsics::_VectorLoadOp: case vmIntrinsics::_VectorLoadMaskedOp: case vmIntrinsics::_VectorStoreOp: @@ -820,6 +822,7 @@ bool C2Compiler::is_intrinsic_supported(vmIntrinsics::ID id) { case vmIntrinsics::_VectorTest: case vmIntrinsics::_VectorBlend: case vmIntrinsics::_VectorRearrange: + case vmIntrinsics::_VectorSelectFrom: case vmIntrinsics::_VectorCompare: case vmIntrinsics::_VectorBroadcastInt: case vmIntrinsics::_VectorConvert: diff --git a/src/hotspot/share/opto/callGenerator.cpp b/src/hotspot/share/opto/callGenerator.cpp index afd9ca25a56..36fca9f61b6 100644 --- a/src/hotspot/share/opto/callGenerator.cpp +++ b/src/hotspot/share/opto/callGenerator.cpp @@ -623,7 +623,10 @@ void CallGenerator::do_late_inline_helper() { // check for unreachable loop CallProjections callprojs; - call->extract_projections(&callprojs, true); + // Similar to incremental inlining, don't assert that all call + // projections are still there for post-parse call devirtualization. + bool do_asserts = !is_mh_late_inline() && !is_virtual_late_inline(); + call->extract_projections(&callprojs, true, do_asserts); if ((callprojs.fallthrough_catchproj == call->in(0)) || (callprojs.catchall_catchproj == call->in(0)) || (callprojs.fallthrough_memproj == call->in(TypeFunc::Memory)) || @@ -647,7 +650,7 @@ void CallGenerator::do_late_inline_helper() { if (is_pure_call() && result_not_used) { GraphKit kit(call->jvms()); - kit.replace_call(call, C->top(), true); + kit.replace_call(call, C->top(), true, do_asserts); } else { // Make a clone of the JVMState that appropriate to use for driving a parse JVMState* old_jvms = call->jvms(); @@ -729,7 +732,7 @@ void CallGenerator::do_late_inline_helper() { } C->set_inlining_progress(true); C->set_do_cleanup(kit.stopped()); // path is dead; needs cleanup - kit.replace_call(call, result, true); + kit.replace_call(call, result, true, do_asserts); } } diff --git a/src/hotspot/share/opto/callnode.cpp b/src/hotspot/share/opto/callnode.cpp index d715e653343..e800b3c736b 100644 --- a/src/hotspot/share/opto/callnode.cpp +++ b/src/hotspot/share/opto/callnode.cpp @@ -755,7 +755,7 @@ Node *CallNode::match( const ProjNode *proj, const Matcher *match ) { if (Opcode() == Op_CallLeafVector) { // If the return is in vector, compute appropriate regmask taking into account the whole range - if(ideal_reg >= Op_VecS && ideal_reg <= Op_VecZ) { + if(ideal_reg >= Op_VecA && ideal_reg <= Op_VecZ) { if(OptoReg::is_valid(regs.second())) { for (OptoReg::Name r = regs.first(); r <= regs.second(); r = OptoReg::add(r, 1)) { rm.Insert(r); diff --git a/src/hotspot/share/opto/cfgnode.hpp b/src/hotspot/share/opto/cfgnode.hpp index 5edd31fa716..ac8896705de 100644 --- a/src/hotspot/share/opto/cfgnode.hpp +++ b/src/hotspot/share/opto/cfgnode.hpp @@ -347,7 +347,6 @@ class IfNode : public MultiBranchNode { bool is_null_check(ProjNode* proj, PhaseIterGVN* igvn); bool is_side_effect_free_test(ProjNode* proj, PhaseIterGVN* igvn); void reroute_side_effect_free_unc(ProjNode* proj, ProjNode* dom_proj, PhaseIterGVN* igvn); - ProjNode* uncommon_trap_proj(CallStaticJavaNode*& call) const; bool fold_compares_helper(ProjNode* proj, ProjNode* success, ProjNode* fail, PhaseIterGVN* igvn); static bool is_dominator_unc(CallStaticJavaNode* dom_unc, CallStaticJavaNode* unc); @@ -442,6 +441,7 @@ public: static Node* up_one_dom(Node* curr, bool linear_only = false); bool is_zero_trip_guard() const; Node* dominated_by(Node* prev_dom, PhaseIterGVN* igvn, bool pin_array_access_nodes); + ProjNode* uncommon_trap_proj(CallStaticJavaNode*& call, Deoptimization::DeoptReason reason = Deoptimization::Reason_none) const; // Takes the type of val and filters it through the test represented // by if_proj and returns a more refined type if one is produced. diff --git a/src/hotspot/share/opto/chaitin.cpp b/src/hotspot/share/opto/chaitin.cpp index 220b916436e..be0aadacbc2 100644 --- a/src/hotspot/share/opto/chaitin.cpp +++ b/src/hotspot/share/opto/chaitin.cpp @@ -479,6 +479,9 @@ void PhaseChaitin::Register_Allocate() { } uint new_max_lrg_id = Split(_lrg_map.max_lrg_id(), &split_arena); // Split spilling LRG everywhere + if (C->failing()) { + return; + } _lrg_map.set_max_lrg_id(new_max_lrg_id); // Bail out if unique gets too large (ie - unique > MaxNodeLimit - 2*NodeLimitFudgeFactor) // or we failed to split @@ -551,6 +554,9 @@ void PhaseChaitin::Register_Allocate() { return; } uint new_max_lrg_id = Split(_lrg_map.max_lrg_id(), &split_arena); // Split spilling LRG everywhere + if (C->failing()) { + return; + } _lrg_map.set_max_lrg_id(new_max_lrg_id); // Bail out if unique gets too large (ie - unique > MaxNodeLimit - 2*NodeLimitFudgeFactor) C->check_node_count(2 * NodeLimitFudgeFactor, "out of nodes after split"); diff --git a/src/hotspot/share/opto/classes.hpp b/src/hotspot/share/opto/classes.hpp index 8bee6279446..215e48ef9da 100644 --- a/src/hotspot/share/opto/classes.hpp +++ b/src/hotspot/share/opto/classes.hpp @@ -341,7 +341,6 @@ macro(Start) macro(StartOSR) macro(StoreB) macro(StoreC) -macro(StoreCM) macro(StoreD) macro(StoreF) macro(StoreI) diff --git a/src/hotspot/share/opto/compile.cpp b/src/hotspot/share/opto/compile.cpp index a9d73364e2d..c6b316e5277 100644 --- a/src/hotspot/share/opto/compile.cpp +++ b/src/hotspot/share/opto/compile.cpp @@ -719,6 +719,11 @@ Compile::Compile( ciEnv* ci_env, ciMethod* target, int osr_bci, method()->ensure_method_data(); } + if (StressLCM || StressGCM || StressIGVN || StressCCP || + StressIncrementalInlining || StressMacroExpansion || StressUnstableIfTraps || StressBailout) { + initialize_stress_seed(directive); + } + Init(/*do_aliasing=*/ true); print_compile_messages(); @@ -754,14 +759,14 @@ Compile::Compile( ciEnv* ci_env, ciMethod* target, int osr_bci, init_tf(TypeFunc::make(domain, range)); StartNode* s = new StartOSRNode(root(), domain); initial_gvn()->set_type_bottom(s); - init_start(s); + verify_start(s); cg = CallGenerator::for_osr(method(), entry_bci()); } else { // Normal case. init_tf(TypeFunc::make(method())); StartNode* s = new StartNode(root(), tf()->domain()); initial_gvn()->set_type_bottom(s); - init_start(s); + verify_start(s); if (method()->intrinsic_id() == vmIntrinsics::_Reference_get) { // With java.lang.ref.reference.get() we must go through the // intrinsic - even when get() is the root @@ -793,7 +798,7 @@ Compile::Compile( ciEnv* ci_env, ciMethod* target, int osr_bci, assert(failure_reason() != nullptr, "expect reason for parse failure"); stringStream ss; ss.print("method parse failed: %s", failure_reason()); - record_method_not_compilable(ss.as_string()); + record_method_not_compilable(ss.as_string() DEBUG_ONLY(COMMA true)); return; } GraphKit kit(jvms); @@ -843,11 +848,6 @@ Compile::Compile( ciEnv* ci_env, ciMethod* target, int osr_bci, if (failing()) return; NOT_PRODUCT( verify_graph_edges(); ) - if (StressLCM || StressGCM || StressIGVN || StressCCP || - StressIncrementalInlining || StressMacroExpansion) { - initialize_stress_seed(directive); - } - // Now optimize Optimize(); if (failing()) return; @@ -973,7 +973,7 @@ Compile::Compile( ciEnv* ci_env, _types = new (comp_arena()) Type_Array(comp_arena()); _node_hash = new (comp_arena()) NodeHash(comp_arena(), 255); - if (StressLCM || StressGCM) { + if (StressLCM || StressGCM || StressBailout) { initialize_stress_seed(directive); } @@ -1018,6 +1018,7 @@ void Compile::Init(bool aliasing) { #ifdef ASSERT _phase_optimize_finished = false; + _phase_verify_ideal_loop = false; _exception_backedge = false; _type_verify = nullptr; #endif @@ -1105,13 +1106,12 @@ void Compile::Init(bool aliasing) { probe_alias_cache(nullptr)->_index = AliasIdxTop; } -//---------------------------init_start---------------------------------------- -// Install the StartNode on this compile object. -void Compile::init_start(StartNode* s) { - if (failing()) - return; // already failing - assert(s == start(), ""); +#ifdef ASSERT +// Verify that the current StartNode is valid. +void Compile::verify_start(StartNode* s) const { + assert(failing_internal() || s == start(), "should be StartNode"); } +#endif /** * Return the 'StartNode'. We must not have a pending failure, since the ideal graph @@ -1119,7 +1119,7 @@ void Compile::init_start(StartNode* s) { * the ideal graph. */ StartNode* Compile::start() const { - assert (!failing(), "Must not have pending failure. Reason is: %s", failure_reason()); + assert (!failing_internal() || C->failure_is_artificial(), "Must not have pending failure. Reason is: %s", failure_reason()); for (DUIterator_Fast imax, i = root()->fast_outs(imax); i < imax; i++) { Node* start = root()->fast_out(i); if (start->is_Start()) { @@ -1466,12 +1466,18 @@ const TypePtr *Compile::flatten_alias_type( const TypePtr *tj ) const { } else { ciInstanceKlass *canonical_holder = ik->get_canonical_holder(offset); assert(offset < canonical_holder->layout_helper_size_in_bytes(), ""); - if (!ik->equals(canonical_holder) || tj->offset() != offset) { - if( is_known_inst ) { - tj = to = TypeInstPtr::make(to->ptr(), canonical_holder, true, nullptr, offset, to->instance_id()); - } else { - tj = to = TypeInstPtr::make(to->ptr(), canonical_holder, false, nullptr, offset); - } + assert(tj->offset() == offset, "no change to offset expected"); + bool xk = to->klass_is_exact(); + int instance_id = to->instance_id(); + + // If the input type's class is the holder: if exact, the type only includes interfaces implemented by the holder + // but if not exact, it may include extra interfaces: build new type from the holder class to make sure only + // its interfaces are included. + if (xk && ik->equals(canonical_holder)) { + assert(tj == TypeInstPtr::make(to->ptr(), canonical_holder, is_known_inst, nullptr, offset, instance_id), "exact type should be canonical type"); + } else { + assert(xk || !is_known_inst, "Known instance should be exact type"); + tj = to = TypeInstPtr::make(to->ptr(), canonical_holder, is_known_inst, nullptr, offset, instance_id); } } } @@ -1701,6 +1707,8 @@ Compile::AliasType* Compile::find_alias_type(const TypePtr* adr_type, bool no_cr alias_type(idx)->set_rewritable(false); if (flat->offset() == in_bytes(Klass::access_flags_offset())) alias_type(idx)->set_rewritable(false); + if (flat->offset() == in_bytes(Klass::misc_flags_offset())) + alias_type(idx)->set_rewritable(false); if (flat->offset() == in_bytes(Klass::java_mirror_offset())) alias_type(idx)->set_rewritable(false); if (flat->offset() == in_bytes(Klass::secondary_super_cache_offset())) @@ -2113,7 +2121,7 @@ void Compile::inline_incrementally(PhaseIterGVN& igvn) { igvn_worklist()->ensure_empty(); // should be done with igvn while (inline_incrementally_one()) { - assert(!failing(), "inconsistent"); + assert(!failing_internal() || failure_is_artificial(), "inconsistent"); } if (failing()) return; @@ -2156,7 +2164,7 @@ void Compile::process_late_inline_calls_no_inline(PhaseIterGVN& igvn) { igvn_worklist()->ensure_empty(); // should be done with igvn while (inline_incrementally_one()) { - assert(!failing(), "inconsistent"); + assert(!failing_internal() || failure_is_artificial(), "inconsistent"); } if (failing()) return; @@ -2943,6 +2951,9 @@ void Compile::Code_Gen() { // Build a proper-looking CFG PhaseCFG cfg(node_arena(), root(), matcher); + if (failing()) { + return; + } _cfg = &cfg; { TracePhase tp("scheduler", &timers[_t_scheduler]); @@ -3050,52 +3061,6 @@ struct Final_Reshape_Counts : public StackObj { int get_inner_loop_count() const { return _inner_loop_count; } }; -// Eliminate trivially redundant StoreCMs and accumulate their -// precedence edges. -void Compile::eliminate_redundant_card_marks(Node* n) { - assert(n->Opcode() == Op_StoreCM, "expected StoreCM"); - if (n->in(MemNode::Address)->outcnt() > 1) { - // There are multiple users of the same address so it might be - // possible to eliminate some of the StoreCMs - Node* mem = n->in(MemNode::Memory); - Node* adr = n->in(MemNode::Address); - Node* val = n->in(MemNode::ValueIn); - Node* prev = n; - bool done = false; - // Walk the chain of StoreCMs eliminating ones that match. As - // long as it's a chain of single users then the optimization is - // safe. Eliminating partially redundant StoreCMs would require - // cloning copies down the other paths. - while (mem->Opcode() == Op_StoreCM && mem->outcnt() == 1 && !done) { - if (adr == mem->in(MemNode::Address) && - val == mem->in(MemNode::ValueIn)) { - // redundant StoreCM - if (mem->req() > MemNode::OopStore) { - // Hasn't been processed by this code yet. - n->add_prec(mem->in(MemNode::OopStore)); - } else { - // Already converted to precedence edge - for (uint i = mem->req(); i < mem->len(); i++) { - // Accumulate any precedence edges - if (mem->in(i) != nullptr) { - n->add_prec(mem->in(i)); - } - } - // Everything above this point has been processed. - done = true; - } - // Eliminate the previous StoreCM - prev->set_req(MemNode::Memory, mem->in(MemNode::Memory)); - assert(mem->outcnt() == 0, "should be dead"); - mem->disconnect_inputs(this); - } else { - prev = mem; - } - mem = prev->in(MemNode::Memory); - } - } -} - //------------------------------final_graph_reshaping_impl---------------------- // Implement items 1-5 from final_graph_reshaping below. void Compile::final_graph_reshaping_impl(Node *n, Final_Reshape_Counts& frc, Unique_Node_List& dead_nodes) { @@ -3160,6 +3125,30 @@ void Compile::final_graph_reshaping_impl(Node *n, Final_Reshape_Counts& frc, Uni } } +void Compile::handle_div_mod_op(Node* n, BasicType bt, bool is_unsigned) { + if (!UseDivMod) { + return; + } + + // Check if "a % b" and "a / b" both exist + Node* d = n->find_similar(Op_DivIL(bt, is_unsigned)); + if (d == nullptr) { + return; + } + + // Replace them with a fused divmod if supported + if (Matcher::has_match_rule(Op_DivModIL(bt, is_unsigned))) { + DivModNode* divmod = DivModNode::make(n, bt, is_unsigned); + d->subsume_by(divmod->div_proj(), this); + n->subsume_by(divmod->mod_proj(), this); + } else { + // Replace "a % b" with "a - ((a / b) * b)" + Node* mult = MulNode::make(d, d->in(2), bt); + Node* sub = SubNode::make(d->in(1), mult, bt); + n->subsume_by(sub, this); + } +} + void Compile::final_graph_reshaping_main_switch(Node* n, Final_Reshape_Counts& frc, uint nop, Unique_Node_List& dead_nodes) { switch( nop ) { // Count all float operations that may use FPU @@ -3241,18 +3230,6 @@ void Compile::final_graph_reshaping_main_switch(Node* n, Final_Reshape_Counts& f } break; } - - case Op_StoreCM: - { - // Convert OopStore dependence into precedence edge - Node* prec = n->in(MemNode::OopStore); - n->del_req(MemNode::OopStore); - n->add_prec(prec); - eliminate_redundant_card_marks(n); - } - - // fall through - case Op_StoreB: case Op_StoreC: case Op_StoreI: @@ -3322,8 +3299,9 @@ void Compile::final_graph_reshaping_main_switch(Node* n, Final_Reshape_Counts& f bool is_oop = t->isa_oopptr() != nullptr; bool is_klass = t->isa_klassptr() != nullptr; - if ((is_oop && Matcher::const_oop_prefer_decode() ) || - (is_klass && Matcher::const_klass_prefer_decode())) { + if ((is_oop && UseCompressedOops && Matcher::const_oop_prefer_decode() ) || + (is_klass && UseCompressedClassPointers && Matcher::const_klass_prefer_decode() && + t->isa_klassptr()->exact_klass()->is_in_encoding_range())) { Node* nn = nullptr; int op = is_oop ? Op_ConN : Op_ConNKlass; @@ -3608,83 +3586,19 @@ void Compile::final_graph_reshaping_main_switch(Node* n, Final_Reshape_Counts& f #endif case Op_ModI: - if (UseDivMod) { - // Check if a%b and a/b both exist - Node* d = n->find_similar(Op_DivI); - if (d) { - // Replace them with a fused divmod if supported - if (Matcher::has_match_rule(Op_DivModI)) { - DivModINode* divmod = DivModINode::make(n); - d->subsume_by(divmod->div_proj(), this); - n->subsume_by(divmod->mod_proj(), this); - } else { - // replace a%b with a-((a/b)*b) - Node* mult = new MulINode(d, d->in(2)); - Node* sub = new SubINode(d->in(1), mult); - n->subsume_by(sub, this); - } - } - } + handle_div_mod_op(n, T_INT, false); break; case Op_ModL: - if (UseDivMod) { - // Check if a%b and a/b both exist - Node* d = n->find_similar(Op_DivL); - if (d) { - // Replace them with a fused divmod if supported - if (Matcher::has_match_rule(Op_DivModL)) { - DivModLNode* divmod = DivModLNode::make(n); - d->subsume_by(divmod->div_proj(), this); - n->subsume_by(divmod->mod_proj(), this); - } else { - // replace a%b with a-((a/b)*b) - Node* mult = new MulLNode(d, d->in(2)); - Node* sub = new SubLNode(d->in(1), mult); - n->subsume_by(sub, this); - } - } - } + handle_div_mod_op(n, T_LONG, false); break; case Op_UModI: - if (UseDivMod) { - // Check if a%b and a/b both exist - Node* d = n->find_similar(Op_UDivI); - if (d) { - // Replace them with a fused unsigned divmod if supported - if (Matcher::has_match_rule(Op_UDivModI)) { - UDivModINode* divmod = UDivModINode::make(n); - d->subsume_by(divmod->div_proj(), this); - n->subsume_by(divmod->mod_proj(), this); - } else { - // replace a%b with a-((a/b)*b) - Node* mult = new MulINode(d, d->in(2)); - Node* sub = new SubINode(d->in(1), mult); - n->subsume_by(sub, this); - } - } - } + handle_div_mod_op(n, T_INT, true); break; case Op_UModL: - if (UseDivMod) { - // Check if a%b and a/b both exist - Node* d = n->find_similar(Op_UDivL); - if (d) { - // Replace them with a fused unsigned divmod if supported - if (Matcher::has_match_rule(Op_UDivModL)) { - UDivModLNode* divmod = UDivModLNode::make(n); - d->subsume_by(divmod->div_proj(), this); - n->subsume_by(divmod->mod_proj(), this); - } else { - // replace a%b with a-((a/b)*b) - Node* mult = new MulLNode(d, d->in(2)); - Node* sub = new SubLNode(d->in(1), mult); - n->subsume_by(sub, this); - } - } - } + handle_div_mod_op(n, T_LONG, true); break; case Op_LoadVector: @@ -4367,7 +4281,7 @@ void Compile::verify_graph_edges(bool no_dead_code) { // to backtrack and retry without subsuming loads. Other than this backtracking // behavior, the Compile's failure reason is quietly copied up to the ciEnv // by the logic in C2Compiler. -void Compile::record_failure(const char* reason) { +void Compile::record_failure(const char* reason DEBUG_ONLY(COMMA bool allow_multiple_failures)) { if (log() != nullptr) { log()->elem("failure reason='%s' phase='compile'", reason); } @@ -4377,6 +4291,8 @@ void Compile::record_failure(const char* reason) { if (CaptureBailoutInformation) { _first_failure_details = new CompilationFailureInfo(reason); } + } else { + assert(!StressBailout || allow_multiple_failures, "should have handled previous failure."); } if (!C->failure_reason_is(C2Compiler::retry_no_subsuming_loads())) { @@ -4404,7 +4320,9 @@ Compile::TracePhase::TracePhase(const char* name, elapsedTimer* accumulator) } Compile::TracePhase::~TracePhase() { - if (_compile->failing()) return; + if (_compile->failing_internal()) { + return; // timing code, not stressing bailouts. + } #ifdef ASSERT if (PrintIdealNodeCount) { tty->print_cr("phase name='%s' nodes='%d' live='%d' live_graph_walk='%d'", @@ -5095,6 +5013,22 @@ bool Compile::randomized_select(int count) { return (random() & RANDOMIZED_DOMAIN_MASK) < (RANDOMIZED_DOMAIN / count); } +#ifdef ASSERT +// Failures are geometrically distributed with probability 1/StressBailoutMean. +bool Compile::fail_randomly() { + if ((random() % StressBailoutMean) != 0) { + return false; + } + record_failure("StressBailout"); + return true; +} + +bool Compile::failure_is_artificial() { + assert(failing_internal(), "should be failing"); + return C->failure_reason_is("StressBailout"); +} +#endif + CloneMap& Compile::clone_map() { return _clone_map; } void Compile::set_clone_map(Dict* d) { _clone_map._dict = d; } @@ -5182,7 +5116,7 @@ void Compile::sort_macro_nodes() { } void Compile::print_method(CompilerPhaseType cpt, int level, Node* n) { - if (failing()) { return; } + if (failing_internal()) { return; } // failing_internal to not stress bailouts from printing code. EventCompilerPhase event(UNTIMED); if (event.should_commit()) { CompilerEvent::PhaseEvent::post(event, C->_latest_stage_start_counter, cpt, C->_compile_id, level); @@ -5196,7 +5130,20 @@ void Compile::print_method(CompilerPhaseType cpt, int level, Node* n) { ss.print(" %d", iter); } if (n != nullptr) { - ss.print(": %d %s ", n->_idx, NodeClassNames[n->Opcode()]); + ss.print(": %d %s", n->_idx, NodeClassNames[n->Opcode()]); + if (n->is_Call()) { + CallNode* call = n->as_Call(); + if (call->_name != nullptr) { + // E.g. uncommon traps etc. + ss.print(" - %s", call->_name); + } else if (call->is_CallJava()) { + CallJavaNode* call_java = call->as_CallJava(); + if (call_java->method() != nullptr) { + ss.print(" -"); + call_java->method()->print_short_name(&ss); + } + } + } } const char* name = ss.as_string(); diff --git a/src/hotspot/share/opto/compile.hpp b/src/hotspot/share/opto/compile.hpp index 15c91f6ad12..6568828125f 100644 --- a/src/hotspot/share/opto/compile.hpp +++ b/src/hotspot/share/opto/compile.hpp @@ -391,6 +391,8 @@ class Compile : public Phase { DEBUG_ONLY(Unique_Node_List* _modified_nodes;) // List of nodes which inputs were modified DEBUG_ONLY(bool _phase_optimize_finished;) // Used for live node verification while creating new nodes + DEBUG_ONLY(bool _phase_verify_ideal_loop;) // Are we in PhaseIdealLoop verification? + // Arenas for new-space and old-space nodes. // Swapped between using _node_arena. // The lifetime of the old-space nodes is during xform. @@ -786,6 +788,12 @@ private: void set_post_loop_opts_phase() { _post_loop_opts_phase = true; } void reset_post_loop_opts_phase() { _post_loop_opts_phase = false; } +#ifdef ASSERT + bool phase_verify_ideal_loop() const { return _phase_verify_ideal_loop; } + void set_phase_verify_ideal_loop() { _phase_verify_ideal_loop = true; } + void reset_phase_verify_ideal_loop() { _phase_verify_ideal_loop = false; } +#endif + bool allow_macro_nodes() { return _allow_macro_nodes; } void reset_allow_macro_nodes() { _allow_macro_nodes = false; } @@ -815,7 +823,7 @@ private: ciEnv* env() const { return _env; } CompileLog* log() const { return _log; } - bool failing() const { + bool failing_internal() const { return _env->failing() || _failure_reason.get() != nullptr; } @@ -827,6 +835,27 @@ private: const CompilationFailureInfo* first_failure_details() const { return _first_failure_details; } + bool failing() { + if (failing_internal()) { + return true; + } +#ifdef ASSERT + // Disable stress code for PhaseIdealLoop verification (would have cascading effects). + if (phase_verify_ideal_loop()) { + return false; + } + if (StressBailout) { + return fail_randomly(); + } +#endif + return false; + } + +#ifdef ASSERT + bool fail_randomly(); + bool failure_is_artificial(); +#endif + bool failure_reason_is(const char* r) const { return (r == _failure_reason.get()) || (r != nullptr && @@ -834,11 +863,11 @@ private: strcmp(r, _failure_reason.get()) == 0); } - void record_failure(const char* reason); - void record_method_not_compilable(const char* reason) { + void record_failure(const char* reason DEBUG_ONLY(COMMA bool allow_multiple_failures = false)); + void record_method_not_compilable(const char* reason DEBUG_ONLY(COMMA bool allow_multiple_failures = false)) { env()->record_method_not_compilable(reason); // Record failure reason. - record_failure(reason); + record_failure(reason DEBUG_ONLY(COMMA allow_multiple_failures)); } bool check_node_count(uint margin, const char* reason) { if (oom()) { @@ -864,7 +893,7 @@ private: RootNode* root() const { return _root; } void set_root(RootNode* r) { _root = r; } StartNode* start() const; // (Derived from root.) - void init_start(StartNode* s); + void verify_start(StartNode* s) const NOT_DEBUG_RETURN; Node* immutable_memory(); Node* recent_alloc_ctl() const { return _recent_alloc_ctl; } @@ -1215,7 +1244,7 @@ private: void final_graph_reshaping_impl(Node *n, Final_Reshape_Counts& frc, Unique_Node_List& dead_nodes); void final_graph_reshaping_main_switch(Node* n, Final_Reshape_Counts& frc, uint nop, Unique_Node_List& dead_nodes); void final_graph_reshaping_walk(Node_Stack& nstack, Node* root, Final_Reshape_Counts& frc, Unique_Node_List& dead_nodes); - void eliminate_redundant_card_marks(Node* n); + void handle_div_mod_op(Node* n, BasicType bt, bool is_unsigned); // Logic cone optimization. void optimize_logic_cones(PhaseIterGVN &igvn); diff --git a/src/hotspot/share/opto/divnode.cpp b/src/hotspot/share/opto/divnode.cpp index 967d6661eec..b9a207b2dee 100644 --- a/src/hotspot/share/opto/divnode.cpp +++ b/src/hotspot/share/opto/divnode.cpp @@ -1360,6 +1360,24 @@ DivModNode::DivModNode( Node *c, Node *dividend, Node *divisor ) : MultiNode(3) init_req(2, divisor); } +DivModNode* DivModNode::make(Node* div_or_mod, BasicType bt, bool is_unsigned) { + assert(bt == T_INT || bt == T_LONG, "only int or long input pattern accepted"); + + if (bt == T_INT) { + if (is_unsigned) { + return UDivModINode::make(div_or_mod); + } else { + return DivModINode::make(div_or_mod); + } + } else { + if (is_unsigned) { + return UDivModLNode::make(div_or_mod); + } else { + return DivModLNode::make(div_or_mod); + } + } +} + //------------------------------make------------------------------------------ DivModINode* DivModINode::make(Node* div_or_mod) { Node* n = div_or_mod; diff --git a/src/hotspot/share/opto/divnode.hpp b/src/hotspot/share/opto/divnode.hpp index 12368642fb2..b2298faee78 100644 --- a/src/hotspot/share/opto/divnode.hpp +++ b/src/hotspot/share/opto/divnode.hpp @@ -202,6 +202,8 @@ public: virtual bool is_CFG() const { return false; } virtual uint ideal_reg() const { return NotAMachineReg; } + static DivModNode* make(Node* div_or_mod, BasicType bt, bool is_unsigned); + ProjNode* div_proj() { return proj_out_or_null(div_proj_num); } ProjNode* mod_proj() { return proj_out_or_null(mod_proj_num); } }; diff --git a/src/hotspot/share/opto/escape.cpp b/src/hotspot/share/opto/escape.cpp index eb6887f11ba..b26480ba9b3 100644 --- a/src/hotspot/share/opto/escape.cpp +++ b/src/hotspot/share/opto/escape.cpp @@ -2043,7 +2043,7 @@ void ConnectionGraph::add_call_node(CallNode* call) { ciMethod* meth = call->as_CallJava()->method(); if (meth == nullptr) { const char* name = call->as_CallStaticJava()->_name; - assert(strncmp(name, "_multianewarray", 15) == 0, "TODO: add failed case check"); + assert(strncmp(name, "C2 Runtime multianewarray", 25) == 0, "TODO: add failed case check"); // Returns a newly allocated non-escaped object. add_java_object(call, PointsToNode::NoEscape); set_not_scalar_replaceable(ptnode_adr(call_idx) NOT_PRODUCT(COMMA "is result of multinewarray")); @@ -2738,7 +2738,7 @@ int ConnectionGraph::find_init_values_phantom(JavaObjectNode* pta) { #ifdef ASSERT if (!pta->arraycopy_dst() && alloc->as_CallStaticJava()->method() == nullptr) { const char* name = alloc->as_CallStaticJava()->_name; - assert(strncmp(name, "_multianewarray", 15) == 0, "sanity"); + assert(strncmp(name, "C2 Runtime multianewarray", 25) == 0, "sanity"); } #endif // Non-escaped allocation returned from Java or runtime call have unknown values in fields. @@ -4009,10 +4009,6 @@ void ConnectionGraph::move_inst_mem(Node* n, GrowableArray &orig_phi --i; #ifdef ASSERT } else if (use->is_Mem()) { - if (use->Opcode() == Op_StoreCM && use->in(MemNode::OopStore) == n) { - // Don't move related cardmark. - continue; - } // Memory nodes should have new memory input. tp = igvn->type(use->in(MemNode::Address))->isa_ptr(); assert(tp != nullptr, "ptr type"); @@ -4564,7 +4560,7 @@ void ConnectionGraph::split_unique_types(GrowableArray &alloc_worklist, // They overwrite memory edge corresponding to destination array, memnode_worklist.append_if_missing(use); } else if (!(op == Op_CmpP || op == Op_Conv2B || - op == Op_CastP2X || op == Op_StoreCM || + op == Op_CastP2X || op == Op_FastLock || op == Op_AryEq || op == Op_StrComp || op == Op_CountPositives || op == Op_StrCompressedCopy || op == Op_StrInflatedCopy || @@ -4703,9 +4699,6 @@ void ConnectionGraph::split_unique_types(GrowableArray &alloc_worklist, if (use->is_Phi() || use->is_ClearArray()) { memnode_worklist.append_if_missing(use); } else if (use->is_Mem() && use->in(MemNode::Memory) == n) { - if (use->Opcode() == Op_StoreCM) { // Ignore cardmark stores - continue; - } memnode_worklist.append_if_missing(use); } else if (use->is_MemBar() || use->is_CallLeaf()) { if (use->in(TypeFunc::Memory) == n) { // Ignore precedent edge diff --git a/src/hotspot/share/opto/gcm.cpp b/src/hotspot/share/opto/gcm.cpp index 3880bea07d7..c46d69058e9 100644 --- a/src/hotspot/share/opto/gcm.cpp +++ b/src/hotspot/share/opto/gcm.cpp @@ -216,19 +216,13 @@ void PhaseCFG::schedule_pinned_nodes(VectorSet &visited) { for (uint i = node->len()-1; i >= node->req(); i--) { Node* m = node->in(i); if (m == nullptr) continue; - - // Only process precedence edges that are CFG nodes. Safepoints and control projections can be in the middle of a block - if (is_CFG(m)) { - node->rm_prec(i); - if (n == nullptr) { - n = m; - } else { - assert(is_dominator(n, m) || is_dominator(m, n), "one must dominate the other"); - n = is_dominator(n, m) ? m : n; - } + assert(is_CFG(m), "must be a CFG node"); + node->rm_prec(i); + if (n == nullptr) { + n = m; } else { - assert(node->is_Mach(), "sanity"); - assert(node->as_Mach()->ideal_Opcode() == Op_StoreCM, "must be StoreCM node"); + assert(is_dominator(n, m) || is_dominator(m, n), "one must dominate the other"); + n = is_dominator(n, m) ? m : n; } } if (n != nullptr) { @@ -562,6 +556,103 @@ bool PhaseCFG::unrelated_load_in_store_null_block(Node* store, Node* load) { return false; } +class DefUseMemStatesQueue : public StackObj { +private: + class DefUsePair : public StackObj { + private: + Node* _def; // memory state + Node* _use; // use of the memory state that also modifies the memory state + + public: + DefUsePair(Node* def, Node* use) : + _def(def), _use(use) { + } + + DefUsePair() : + _def(nullptr), _use(nullptr) { + } + + Node* def() const { + return _def; + } + + Node* use() const { + return _use; + } + }; + + GrowableArray _queue; + GrowableArray _worklist_visited; // visited mergemem nodes + + bool already_enqueued(Node* def_mem, PhiNode* use_phi) const { + // def_mem is one of the inputs of use_phi and at least one input of use_phi is + // not def_mem. It's however possible that use_phi has def_mem as input multiple + // times. If that happens, use_phi is recorded as a use of def_mem multiple + // times as well. When PhaseCFG::insert_anti_dependences() goes over + // uses of def_mem and enqueues them for processing, use_phi would then be + // enqueued for processing multiple times when it only needs to be + // processed once. The code below checks if use_phi as a use of def_mem was + // already enqueued to avoid redundant processing of use_phi. + int j = _queue.length()-1; + // If there are any use of def_mem already enqueued, they were enqueued + // last (all use of def_mem are processed in one go). + for (; j >= 0; j--) { + const DefUsePair& def_use_pair = _queue.at(j); + if (def_use_pair.def() != def_mem) { + // We're done with the uses of def_mem + break; + } + if (def_use_pair.use() == use_phi) { + return true; + } + } +#ifdef ASSERT + for (; j >= 0; j--) { + const DefUsePair& def_use_pair = _queue.at(j); + assert(def_use_pair.def() != def_mem, "Should be done with the uses of def_mem"); + } +#endif + return false; + } + +public: + DefUseMemStatesQueue(ResourceArea* area) { + } + + void push(Node* def_mem_state, Node* use_mem_state) { + if (use_mem_state->is_MergeMem()) { + // Be sure we don't get into combinatorial problems. + if (!_worklist_visited.append_if_missing(use_mem_state->as_MergeMem())) { + return; // already on work list; do not repeat + } + } else if (use_mem_state->is_Phi()) { + // A Phi could have the same mem as input multiple times. If that's the case, we don't need to enqueue it + // more than once. We otherwise allow phis to be repeated; they can merge two relevant states. + if (already_enqueued(def_mem_state, use_mem_state->as_Phi())) { + return; + } + } + + _queue.push(DefUsePair(def_mem_state, use_mem_state)); + } + + bool is_nonempty() const { + return _queue.is_nonempty(); + } + + Node* top_def() const { + return _queue.top().def(); + } + + Node* top_use() const { + return _queue.top().use(); + } + + void pop() { + _queue.pop(); + } +}; + //--------------------------insert_anti_dependences--------------------------- // A load may need to witness memory that nearby stores can overwrite. // For each nearby store, either insert an "anti-dependence" edge @@ -579,6 +670,7 @@ bool PhaseCFG::unrelated_load_in_store_null_block(Node* store, Node* load) { // preserve anti-dependences. The caller may also hoist the load // above the LCA, if it is not the early block. Block* PhaseCFG::insert_anti_dependences(Block* LCA, Node* load, bool verify) { + ResourceMark rm; assert(load->needs_anti_dependence_check(), "must be a load of some sort"); assert(LCA != nullptr, ""); DEBUG_ONLY(Block* LCA_orig = LCA); @@ -625,10 +717,8 @@ Block* PhaseCFG::insert_anti_dependences(Block* LCA, Node* load, bool verify) { early = memory_early_block(load, early, this); } - ResourceArea *area = Thread::current()->resource_area(); - Node_List worklist_mem(area); // prior memory state to store - Node_List worklist_store(area); // possible-def to explore - Node_List worklist_visited(area); // visited mergemem nodes + ResourceArea* area = Thread::current()->resource_area(); + DefUseMemStatesQueue worklist_def_use_mem_states(area); // prior memory state to store and possible-def to explore Node_List non_early_stores(area); // all relevant stores outside of early bool must_raise_LCA = false; @@ -644,60 +734,81 @@ Block* PhaseCFG::insert_anti_dependences(Block* LCA, Node* load, bool verify) { // The relevant stores "nearby" the load consist of a tree rooted // at initial_mem, with internal nodes of type MergeMem. // Therefore, the branches visited by the worklist are of this form: - // initial_mem -> (MergeMem ->)* store + // initial_mem -> (MergeMem ->)* Memory state modifying node + // Memory state modifying nodes include Store and Phi nodes and any node for which needs_anti_dependence_check() + // returns false. // The anti-dependence constraints apply only to the fringe of this tree. Node* initial_mem = load->in(MemNode::Memory); - worklist_store.push(initial_mem); - worklist_visited.push(initial_mem); - worklist_mem.push(nullptr); - while (worklist_store.size() > 0) { + + // We don't optimize the memory graph for pinned loads, so we may need to raise the + // root of our search tree through the corresponding slices of MergeMem nodes to + // get to the node that really creates the memory state for this slice. + if (load_alias_idx >= Compile::AliasIdxRaw) { + while (initial_mem->is_MergeMem()) { + MergeMemNode* mm = initial_mem->as_MergeMem(); + Node* p = mm->memory_at(load_alias_idx); + if (p != mm->base_memory()) { + initial_mem = p; + } else { + break; + } + } + } + worklist_def_use_mem_states.push(nullptr, initial_mem); + while (worklist_def_use_mem_states.is_nonempty()) { // Examine a nearby store to see if it might interfere with our load. - Node* mem = worklist_mem.pop(); - Node* store = worklist_store.pop(); - uint op = store->Opcode(); + Node* def_mem_state = worklist_def_use_mem_states.top_def(); + Node* use_mem_state = worklist_def_use_mem_states.top_use(); + worklist_def_use_mem_states.pop(); + + uint op = use_mem_state->Opcode(); + +#ifdef ASSERT + // CacheWB nodes are peculiar in a sense that they both are anti-dependent and produce memory. + // Allow them to be treated as a store. + bool is_cache_wb = false; + if (use_mem_state->is_Mach()) { + int ideal_op = use_mem_state->as_Mach()->ideal_Opcode(); + is_cache_wb = (ideal_op == Op_CacheWB); + } + assert(!use_mem_state->needs_anti_dependence_check() || is_cache_wb, "no loads"); +#endif // MergeMems do not directly have anti-deps. // Treat them as internal nodes in a forward tree of memory states, // the leaves of which are each a 'possible-def'. - if (store == initial_mem // root (exclusive) of tree we are searching + if (use_mem_state == initial_mem // root (exclusive) of tree we are searching || op == Op_MergeMem // internal node of tree we are searching ) { - mem = store; // It's not a possibly interfering store. - if (store == initial_mem) + def_mem_state = use_mem_state; // It's not a possibly interfering store. + if (use_mem_state == initial_mem) initial_mem = nullptr; // only process initial memory once - for (DUIterator_Fast imax, i = mem->fast_outs(imax); i < imax; i++) { - store = mem->fast_out(i); - if (store->is_MergeMem()) { - // Be sure we don't get into combinatorial problems. - // (Allow phis to be repeated; they can merge two relevant states.) - uint j = worklist_visited.size(); - for (; j > 0; j--) { - if (worklist_visited.at(j-1) == store) break; - } - if (j > 0) continue; // already on work list; do not repeat - worklist_visited.push(store); + for (DUIterator_Fast imax, i = def_mem_state->fast_outs(imax); i < imax; i++) { + use_mem_state = def_mem_state->fast_out(i); + if (use_mem_state->needs_anti_dependence_check()) { + // use_mem_state is also a kind of load (i.e. needs_anti_dependence_check), and it is not a memory state + // modifying node (store, Phi or MergeMem). Hence, load can't be anti dependent on this node. + continue; } - worklist_mem.push(mem); - worklist_store.push(store); + worklist_def_use_mem_states.push(def_mem_state, use_mem_state); } continue; } if (op == Op_MachProj || op == Op_Catch) continue; - if (store->needs_anti_dependence_check()) continue; // not really a store // Compute the alias index. Loads and stores with different alias // indices do not need anti-dependence edges. Wide MemBar's are // anti-dependent on everything (except immutable memories). - const TypePtr* adr_type = store->adr_type(); + const TypePtr* adr_type = use_mem_state->adr_type(); if (!C->can_alias(adr_type, load_alias_idx)) continue; // Most slow-path runtime calls do NOT modify Java memory, but // they can block and so write Raw memory. - if (store->is_Mach()) { - MachNode* mstore = store->as_Mach(); + if (use_mem_state->is_Mach()) { + MachNode* mstore = use_mem_state->as_Mach(); if (load_alias_idx != Compile::AliasIdxRaw) { // Check for call into the runtime using the Java calling // convention (and from there into a wrapper); it has no @@ -736,10 +847,10 @@ Block* PhaseCFG::insert_anti_dependences(Block* LCA, Node* load, bool verify) { // or else observe that 'store' is all the way up in the // earliest legal block for 'load'. In the latter case, // immediately insert an anti-dependence edge. - Block* store_block = get_block_for_node(store); + Block* store_block = get_block_for_node(use_mem_state); assert(store_block != nullptr, "unused killing projections skipped above"); - if (store->is_Phi()) { + if (use_mem_state->is_Phi()) { // Loop-phis need to raise load before input. (Other phis are treated // as store below.) // @@ -754,8 +865,8 @@ Block* PhaseCFG::insert_anti_dependences(Block* LCA, Node* load, bool verify) { // Do not assert(store_block != early, "Phi merging memory after access") // PhiNode may be at start of block 'early' with backedge to 'early' DEBUG_ONLY(bool found_match = false); - for (uint j = PhiNode::Input, jmax = store->req(); j < jmax; j++) { - if (store->in(j) == mem) { // Found matching input? + for (uint j = PhiNode::Input, jmax = use_mem_state->req(); j < jmax; j++) { + if (use_mem_state->in(j) == def_mem_state) { // Found matching input? DEBUG_ONLY(found_match = true); Block* pred_block = get_block_for_node(store_block->pred(j)); if (pred_block != early) { @@ -781,21 +892,21 @@ Block* PhaseCFG::insert_anti_dependences(Block* LCA, Node* load, bool verify) { // will find him on the non_early_stores list and stick him // with a precedence edge. // (But, don't bother if LCA is already raised all the way.) - if (LCA != early && !unrelated_load_in_store_null_block(store, load)) { + if (LCA != early && !unrelated_load_in_store_null_block(use_mem_state, load)) { store_block->set_raise_LCA_mark(load_index); must_raise_LCA = true; - non_early_stores.push(store); + non_early_stores.push(use_mem_state); } } else { // Found a possibly-interfering store in the load's 'early' block. // This means 'load' cannot sink at all in the dominator tree. // Add an anti-dep edge, and squeeze 'load' into the highest block. - assert(store != load->find_exact_control(load->in(0)), "dependence cycle found"); + assert(use_mem_state != load->find_exact_control(load->in(0)), "dependence cycle found"); if (verify) { - assert(store->find_edge(load) != -1 || unrelated_load_in_store_null_block(store, load), + assert(use_mem_state->find_edge(load) != -1 || unrelated_load_in_store_null_block(use_mem_state, load), "missing precedence edge"); } else { - store->add_prec(load); + use_mem_state->add_prec(load); } LCA = early; // This turns off the process of gathering non_early_stores. @@ -1420,8 +1531,8 @@ void PhaseCFG::schedule_late(VectorSet &visited, Node_Stack &stack) { C->record_failure(C2Compiler::retry_no_subsuming_loads()); } else { // Bailout without retry when (early->_dom_depth > LCA->_dom_depth) - assert(false, "graph should be schedulable"); - C->record_method_not_compilable("late schedule failed: incorrect graph"); + assert(C->failure_is_artificial(), "graph should be schedulable"); + C->record_method_not_compilable("late schedule failed: incorrect graph" DEBUG_ONLY(COMMA true)); } return; } @@ -1601,8 +1712,8 @@ void PhaseCFG::global_code_motion() { Block* block = get_block(i); if (!schedule_local(block, ready_cnt, visited, recalc_pressure_nodes)) { if (!C->failure_reason_is(C2Compiler::retry_no_subsuming_loads())) { - assert(false, "local schedule failed"); - C->record_method_not_compilable("local schedule failed"); + assert(C->failure_is_artificial(), "local schedule failed"); + C->record_method_not_compilable("local schedule failed" DEBUG_ONLY(COMMA true)); } _regalloc = nullptr; return; diff --git a/src/hotspot/share/opto/generateOptoStub.cpp b/src/hotspot/share/opto/generateOptoStub.cpp index e22f484c179..2f940439045 100644 --- a/src/hotspot/share/opto/generateOptoStub.cpp +++ b/src/hotspot/share/opto/generateOptoStub.cpp @@ -261,7 +261,7 @@ void GraphKit::gen_stub(address C_function, frameptr(), returnadr()); root()->add_req(_gvn.transform(to_exc)); // bind to root to keep live - C->init_start(start); + C->verify_start(start); //----------------------------- // If this is a normal subroutine return, issue the return and be done. diff --git a/src/hotspot/share/opto/graphKit.cpp b/src/hotspot/share/opto/graphKit.cpp index 3bc5b9a8b2a..fe8ca76e318 100644 --- a/src/hotspot/share/opto/graphKit.cpp +++ b/src/hotspot/share/opto/graphKit.cpp @@ -340,7 +340,9 @@ static inline void add_one_req(Node* dstphi, Node* src) { // having a control input of its exception map, rather than null. Such // regions do not appear except in this function, and in use_exception_state. void GraphKit::combine_exception_states(SafePointNode* ex_map, SafePointNode* phi_map) { - if (failing()) return; // dying anyway... + if (failing_internal()) { + return; // dying anyway... + } JVMState* ex_jvms = ex_map->_jvms; assert(ex_jvms->same_calls_as(phi_map->_jvms), "consistent call chains"); assert(ex_jvms->stkoff() == phi_map->_jvms->stkoff(), "matching locals"); @@ -446,7 +448,7 @@ void GraphKit::combine_exception_states(SafePointNode* ex_map, SafePointNode* ph //--------------------------use_exception_state-------------------------------- Node* GraphKit::use_exception_state(SafePointNode* phi_map) { - if (failing()) { stop(); return top(); } + if (failing_internal()) { stop(); return top(); } Node* region = phi_map->control(); Node* hidden_merge_mark = root(); assert(phi_map->jvms()->map() == phi_map, "sanity: 1-1 relation"); @@ -1556,6 +1558,7 @@ Node* GraphKit::make_load(Node* ctl, Node* adr, const Type* t, BasicType bt, bool mismatched, bool unsafe, uint8_t barrier_data) { + assert(adr_idx == C->get_alias_index(_gvn.type(adr)->isa_ptr()), "slice of address and input slice don't match"); assert(adr_idx != Compile::AliasIdxTop, "use other make_load factory" ); const TypePtr* adr_type = nullptr; // debug-mode-only argument debug_only(adr_type = C->get_adr_type(adr_idx)); @@ -1585,6 +1588,7 @@ Node* GraphKit::store_to_memory(Node* ctl, Node* adr, Node *val, BasicType bt, bool unsafe, int barrier_data) { assert(adr_idx != Compile::AliasIdxTop, "use other store_to_memory factory" ); + assert(adr_idx == C->get_alias_index(_gvn.type(adr)->isa_ptr()), "slice of address and input slice don't match"); const TypePtr* adr_type = nullptr; debug_only(adr_type = C->get_adr_type(adr_idx)); Node *mem = memory(adr_idx); @@ -1926,7 +1930,7 @@ static void add_mergemem_users_to_worklist(Unique_Node_List& wl, Node* mem) { } // Replace the call with the current state of the kit. -void GraphKit::replace_call(CallNode* call, Node* result, bool do_replaced_nodes) { +void GraphKit::replace_call(CallNode* call, Node* result, bool do_replaced_nodes, bool do_asserts) { JVMState* ejvms = nullptr; if (has_exceptions()) { ejvms = transfer_exceptions_into_jvms(); @@ -1940,7 +1944,7 @@ void GraphKit::replace_call(CallNode* call, Node* result, bool do_replaced_nodes // Find all the needed outputs of this call CallProjections callprojs; - call->extract_projections(&callprojs, true); + call->extract_projections(&callprojs, true, do_asserts); Unique_Node_List wl; Node* init_mem = call->in(TypeFunc::Memory); @@ -2056,7 +2060,9 @@ Node* GraphKit::uncommon_trap(int trap_request, ciKlass* klass, const char* comment, bool must_throw, bool keep_exact_action) { - if (failing()) stop(); + if (failing_internal()) { + stop(); + } if (stopped()) return nullptr; // trap reachable? // Note: If ProfileTraps is true, and if a deopt. actually @@ -3008,7 +3014,7 @@ void GraphKit::guard_klass_being_initialized(Node* klass) { Node* adr = basic_plus_adr(top(), klass, init_state_off); Node* init_state = LoadNode::make(_gvn, nullptr, immutable_memory(), adr, adr->bottom_type()->is_ptr(), TypeInt::BYTE, - T_BYTE, MemNode::unordered); + T_BYTE, MemNode::acquire); init_state = _gvn.transform(init_state); Node* being_initialized_state = makecon(TypeInt::make(InstanceKlass::being_initialized)); diff --git a/src/hotspot/share/opto/graphKit.hpp b/src/hotspot/share/opto/graphKit.hpp index e7f17c72a1b..3333b7d1bd9 100644 --- a/src/hotspot/share/opto/graphKit.hpp +++ b/src/hotspot/share/opto/graphKit.hpp @@ -82,7 +82,7 @@ class GraphKit : public Phase { #ifdef ASSERT ~GraphKit() { - assert(failing() || !has_exceptions(), + assert(failing_internal() || !has_exceptions(), "unless compilation failed, user must call transfer_exceptions_into_jvms"); } #endif @@ -182,6 +182,7 @@ class GraphKit : public Phase { // Tell if the compilation is failing. bool failing() const { return C->failing(); } + bool failing_internal() const { return C->failing_internal(); } // Set _map to null, signalling a stop to further bytecode execution. // Preserve the map intact for future use, and return it back to the caller. @@ -730,7 +731,7 @@ class GraphKit : public Phase { // Replace the call with the current state of the kit. Requires // that the call was generated with separate io_projs so that // exceptional control flow can be handled properly. - void replace_call(CallNode* call, Node* result, bool do_replaced_nodes = false); + void replace_call(CallNode* call, Node* result, bool do_replaced_nodes = false, bool do_asserts = true); // helper functions for statistics void increment_counter(address counter_addr); // increment a debug counter diff --git a/src/hotspot/share/opto/idealKit.cpp b/src/hotspot/share/opto/idealKit.cpp index 80c4791cfd5..baa055bc60a 100644 --- a/src/hotspot/share/opto/idealKit.cpp +++ b/src/hotspot/share/opto/idealKit.cpp @@ -381,26 +381,6 @@ Node* IdealKit::store(Node* ctl, Node* adr, Node *val, BasicType bt, return st; } -// Card mark store. Must be ordered so that it will come after the store of -// the oop. -Node* IdealKit::storeCM(Node* ctl, Node* adr, Node *val, Node* oop_store, int oop_adr_idx, - BasicType bt, - int adr_idx) { - assert(adr_idx != Compile::AliasIdxTop, "use other store_to_memory factory" ); - const TypePtr* adr_type = nullptr; - debug_only(adr_type = C->get_adr_type(adr_idx)); - Node *mem = memory(adr_idx); - - // Add required edge to oop_store, optimizer does not support precedence edges. - // Convert required edge to precedence edge before allocation. - Node* st = new StoreCMNode(ctl, mem, adr, adr_type, val, oop_store, oop_adr_idx); - - st = transform(st); - set_memory(st, adr_idx); - - return st; -} - //---------------------------- do_memory_merge -------------------------------- // The memory from one merging cvstate needs to be merged with the memory for another // join cvstate. If the join cvstate doesn't have a merged memory yet then we diff --git a/src/hotspot/share/opto/idealKit.hpp b/src/hotspot/share/opto/idealKit.hpp index 20acec47211..727b70129ef 100644 --- a/src/hotspot/share/opto/idealKit.hpp +++ b/src/hotspot/share/opto/idealKit.hpp @@ -234,15 +234,6 @@ class IdealKit: public StackObj { bool require_atomic_access = false, bool mismatched = false); - // Store a card mark ordered after store_oop - Node* storeCM(Node* ctl, - Node* adr, - Node* val, - Node* oop_store, - int oop_adr_idx, - BasicType bt, - int adr_idx); - // Trivial call Node* make_leaf_call(const TypeFunc *slow_call_type, address slow_call, diff --git a/src/hotspot/share/opto/ifnode.cpp b/src/hotspot/share/opto/ifnode.cpp index 8e5cd270213..4313b2cf907 100644 --- a/src/hotspot/share/opto/ifnode.cpp +++ b/src/hotspot/share/opto/ifnode.cpp @@ -840,9 +840,9 @@ bool IfNode::is_dominator_unc(CallStaticJavaNode* dom_unc, CallStaticJavaNode* u } // Return projection that leads to an uncommon trap if any -ProjNode* IfNode::uncommon_trap_proj(CallStaticJavaNode*& call) const { +ProjNode* IfNode::uncommon_trap_proj(CallStaticJavaNode*& call, Deoptimization::DeoptReason reason) const { for (int i = 0; i < 2; i++) { - call = proj_out(i)->is_uncommon_trap_proj(); + call = proj_out(i)->is_uncommon_trap_proj(reason); if (call != nullptr) { return proj_out(i); } diff --git a/src/hotspot/share/opto/lcm.cpp b/src/hotspot/share/opto/lcm.cpp index 9db94748ca2..2a40cf000d8 100644 --- a/src/hotspot/share/opto/lcm.cpp +++ b/src/hotspot/share/opto/lcm.cpp @@ -161,6 +161,14 @@ void PhaseCFG::implicit_null_check(Block* block, Node *proj, Node *val, int allo Node *m = val->out(i); if( !m->is_Mach() ) continue; MachNode *mach = m->as_Mach(); + if (mach->barrier_data() != 0) { + // Using memory accesses with barriers to perform implicit null checks is + // not supported. These operations might expand into multiple assembly + // instructions during code emission, including new memory accesses (e.g. + // in G1's pre-barrier), which would invalidate the implicit null + // exception table. + continue; + } was_store = false; int iop = mach->ideal_Opcode(); switch( iop ) { @@ -183,7 +191,6 @@ void PhaseCFG::implicit_null_check(Block* block, Node *proj, Node *val, int allo break; case Op_StoreB: case Op_StoreC: - case Op_StoreCM: case Op_StoreD: case Op_StoreF: case Op_StoreI: @@ -715,7 +722,6 @@ void PhaseCFG::adjust_register_pressure(Node* n, Block* block, intptr_t* recalc_ switch (iop) { case Op_StoreB: case Op_StoreC: - case Op_StoreCM: case Op_StoreD: case Op_StoreF: case Op_StoreI: @@ -996,21 +1002,6 @@ bool PhaseCFG::schedule_local(Block* block, GrowableArray& ready_cnt, Vecto local++; // One more block-local input } ready_cnt.at_put(n->_idx, local); // Count em up - -#ifdef ASSERT - if (UseG1GC) { - if( n->is_Mach() && n->as_Mach()->ideal_Opcode() == Op_StoreCM ) { - // Check the precedence edges - for (uint prec = n->req(); prec < n->len(); prec++) { - Node* oop_store = n->in(prec); - if (oop_store != nullptr) { - assert(get_block_for_node(oop_store)->_dom_depth <= block->_dom_depth, "oop_store must dominate card-mark"); - } - } - } - } -#endif - // A few node types require changing a required edge to a precedence edge // before allocation. if( n->is_Mach() && n->req() > TypeFunc::Parms && @@ -1196,7 +1187,7 @@ bool PhaseCFG::schedule_local(Block* block, GrowableArray& ready_cnt, Vecto // to the Compile object, and the C2Compiler will see it and retry. C->record_failure(C2Compiler::retry_no_subsuming_loads()); } else { - assert(false, "graph should be schedulable"); + assert(C->failure_is_artificial(), "graph should be schedulable"); } // assert( phi_cnt == end_idx(), "did not schedule all" ); return false; diff --git a/src/hotspot/share/opto/library_call.cpp b/src/hotspot/share/opto/library_call.cpp index 24901855b91..4ab4eea6f8f 100644 --- a/src/hotspot/share/opto/library_call.cpp +++ b/src/hotspot/share/opto/library_call.cpp @@ -254,6 +254,7 @@ bool LibraryCallKit::try_to_inline(int predicate) { case vmIntrinsics::_dsin: case vmIntrinsics::_dcos: case vmIntrinsics::_dtan: + case vmIntrinsics::_dtanh: case vmIntrinsics::_dabs: case vmIntrinsics::_fabs: case vmIntrinsics::_iabs: @@ -716,6 +717,8 @@ bool LibraryCallKit::try_to_inline(int predicate) { return inline_vector_mask_operation(); case vmIntrinsics::_VectorShuffleToVector: return inline_vector_shuffle_to_vector(); + case vmIntrinsics::_VectorWrapShuffleIndexes: + return inline_vector_wrap_shuffle_indexes(); case vmIntrinsics::_VectorLoadOp: return inline_vector_mem_operation(/*is_store=*/false); case vmIntrinsics::_VectorLoadMaskedOp: @@ -736,6 +739,8 @@ bool LibraryCallKit::try_to_inline(int predicate) { return inline_vector_blend(); case vmIntrinsics::_VectorRearrange: return inline_vector_rearrange(); + case vmIntrinsics::_VectorSelectFrom: + return inline_vector_select_from(); case vmIntrinsics::_VectorCompare: return inline_vector_compare(); case vmIntrinsics::_VectorBroadcastInt: @@ -1879,6 +1884,9 @@ bool LibraryCallKit::inline_math_native(vmIntrinsics::ID id) { return StubRoutines::dtan() != nullptr ? runtime_math(OptoRuntime::Math_D_D_Type(), StubRoutines::dtan(), "dtan") : runtime_math(OptoRuntime::Math_D_D_Type(), CAST_FROM_FN_PTR(address, SharedRuntime::dtan), "TAN"); + case vmIntrinsics::_dtanh: + return StubRoutines::dtanh() != nullptr ? + runtime_math(OptoRuntime::Math_D_D_Type(), StubRoutines::dtanh(), "dtanh") : false; case vmIntrinsics::_dexp: return StubRoutines::dexp() != nullptr ? runtime_math(OptoRuntime::Math_D_D_Type(), StubRoutines::dexp(), "dexp") : @@ -2044,7 +2052,7 @@ LibraryCallKit::classify_unsafe_addr(Node* &base, Node* &offset, BasicType type) if (base_type == nullptr) { // Unknown type. return Type::AnyPtr; - } else if (base_type == TypePtr::NULL_PTR) { + } else if (_gvn.type(base->uncast()) == TypePtr::NULL_PTR) { // Since this is a null+long form, we have to switch to a rawptr. base = _gvn.transform(new CastX2PNode(offset)); offset = MakeConX(0); @@ -2362,8 +2370,9 @@ bool LibraryCallKit::inline_unsafe_access(bool is_store, const BasicType type, c SafePointNode* old_map = clone_map(); Node* adr = make_unsafe_address(base, offset, type, kind == Relaxed); + assert(!stopped(), "Inlining of unsafe access failed: address construction stopped unexpectedly"); - if (_gvn.type(base)->isa_ptr() == TypePtr::NULL_PTR) { + if (_gvn.type(base->uncast())->isa_ptr() == TypePtr::NULL_PTR) { if (type != T_OBJECT) { decorators |= IN_NATIVE; // off-heap primitive access } else { @@ -2895,7 +2904,7 @@ bool LibraryCallKit::inline_unsafe_allocate() { Node* insp = basic_plus_adr(kls, in_bytes(InstanceKlass::init_state_offset())); // Use T_BOOLEAN for InstanceKlass::_init_state so the compiler // can generate code to load it as unsigned byte. - Node* inst = make_load(nullptr, insp, TypeInt::UBYTE, T_BOOLEAN, MemNode::unordered); + Node* inst = make_load(nullptr, insp, TypeInt::UBYTE, T_BOOLEAN, MemNode::acquire); Node* bits = intcon(InstanceKlass::fully_initialized); test = _gvn.transform(new SubINode(inst, bits)); // The 'test' is non-zero if we need to take a slow path. @@ -2950,11 +2959,10 @@ bool LibraryCallKit::inline_native_notify_jvmti_funcs(address funcAddr, const ch Node* thread = ideal.thread(); Node* jt_addr = basic_plus_adr(thread, in_bytes(JavaThread::is_in_VTMS_transition_offset())); Node* vt_addr = basic_plus_adr(vt_oop, java_lang_Thread::is_in_VTMS_transition_offset()); - const TypePtr *addr_type = _gvn.type(addr)->isa_ptr(); sync_kit(ideal); - access_store_at(nullptr, jt_addr, addr_type, hide, _gvn.type(hide), T_BOOLEAN, IN_NATIVE | MO_UNORDERED); - access_store_at(nullptr, vt_addr, addr_type, hide, _gvn.type(hide), T_BOOLEAN, IN_NATIVE | MO_UNORDERED); + access_store_at(nullptr, jt_addr, _gvn.type(jt_addr)->is_ptr(), hide, _gvn.type(hide), T_BOOLEAN, IN_NATIVE | MO_UNORDERED); + access_store_at(nullptr, vt_addr, _gvn.type(vt_addr)->is_ptr(), hide, _gvn.type(hide), T_BOOLEAN, IN_NATIVE | MO_UNORDERED); ideal.sync_kit(this); } ideal.end_if(); @@ -3316,7 +3324,9 @@ bool LibraryCallKit::inline_native_getEventWriter() { // Load the raw epoch value from the threadObj. Node* threadObj_epoch_offset = basic_plus_adr(threadObj, java_lang_Thread::jfr_epoch_offset()); - Node* threadObj_epoch_raw = access_load_at(threadObj, threadObj_epoch_offset, TypeRawPtr::BOTTOM, TypeInt::CHAR, T_CHAR, + Node* threadObj_epoch_raw = access_load_at(threadObj, threadObj_epoch_offset, + _gvn.type(threadObj_epoch_offset)->isa_ptr(), + TypeInt::CHAR, T_CHAR, IN_HEAP | MO_UNORDERED | C2_MISMATCHED | C2_CONTROL_DEPENDENT_LOAD); // Mask off the excluded information from the epoch. @@ -3335,7 +3345,8 @@ bool LibraryCallKit::inline_native_getEventWriter() { // Load the raw epoch value from the vthread. Node* vthread_epoch_offset = basic_plus_adr(vthread, java_lang_Thread::jfr_epoch_offset()); - Node* vthread_epoch_raw = access_load_at(vthread, vthread_epoch_offset, TypeRawPtr::BOTTOM, TypeInt::CHAR, T_CHAR, + Node* vthread_epoch_raw = access_load_at(vthread, vthread_epoch_offset, _gvn.type(vthread_epoch_offset)->is_ptr(), + TypeInt::CHAR, T_CHAR, IN_HEAP | MO_UNORDERED | C2_MISMATCHED | C2_CONTROL_DEPENDENT_LOAD); // Mask off the excluded information from the epoch. @@ -3581,7 +3592,7 @@ void LibraryCallKit::extend_setCurrentThread(Node* jt, Node* thread) { // Load the raw epoch value from the vthread. Node* epoch_offset = basic_plus_adr(thread, java_lang_Thread::jfr_epoch_offset()); - Node* epoch_raw = access_load_at(thread, epoch_offset, TypeRawPtr::BOTTOM, TypeInt::CHAR, T_CHAR, + Node* epoch_raw = access_load_at(thread, epoch_offset, _gvn.type(epoch_offset)->is_ptr(), TypeInt::CHAR, T_CHAR, IN_HEAP | MO_UNORDERED | C2_MISMATCHED | C2_CONTROL_DEPENDENT_LOAD); // Mask off the excluded information from the epoch. @@ -3860,13 +3871,14 @@ Node* LibraryCallKit::load_klass_from_mirror_common(Node* mirror, } //--------------------(inline_native_Class_query helpers)--------------------- -// Use this for JVM_ACC_INTERFACE, JVM_ACC_IS_CLONEABLE_FAST, JVM_ACC_HAS_FINALIZER. +// Use this for JVM_ACC_INTERFACE. // Fall through if (mods & mask) == bits, take the guard otherwise. -Node* LibraryCallKit::generate_access_flags_guard(Node* kls, int modifier_mask, int modifier_bits, RegionNode* region) { +Node* LibraryCallKit::generate_klass_flags_guard(Node* kls, int modifier_mask, int modifier_bits, RegionNode* region, + ByteSize offset, const Type* type, BasicType bt) { // Branch around if the given klass has the given modifier bit set. // Like generate_guard, adds a new path onto the region. - Node* modp = basic_plus_adr(kls, in_bytes(Klass::access_flags_offset())); - Node* mods = make_load(nullptr, modp, TypeInt::INT, T_INT, MemNode::unordered); + Node* modp = basic_plus_adr(kls, in_bytes(offset)); + Node* mods = make_load(nullptr, modp, type, bt, MemNode::unordered); Node* mask = intcon(modifier_mask); Node* bits = intcon(modifier_bits); Node* mbit = _gvn.transform(new AndINode(mods, mask)); @@ -3875,10 +3887,18 @@ Node* LibraryCallKit::generate_access_flags_guard(Node* kls, int modifier_mask, return generate_fair_guard(bol, region); } Node* LibraryCallKit::generate_interface_guard(Node* kls, RegionNode* region) { - return generate_access_flags_guard(kls, JVM_ACC_INTERFACE, 0, region); + return generate_klass_flags_guard(kls, JVM_ACC_INTERFACE, 0, region, + Klass::access_flags_offset(), TypeInt::INT, T_INT); } + +// Use this for testing if Klass is_hidden, has_finalizer, and is_cloneable_fast. +Node* LibraryCallKit::generate_misc_flags_guard(Node* kls, int modifier_mask, int modifier_bits, RegionNode* region) { + return generate_klass_flags_guard(kls, modifier_mask, modifier_bits, region, + Klass::misc_flags_offset(), TypeInt::UBYTE, T_BOOLEAN); +} + Node* LibraryCallKit::generate_hidden_class_guard(Node* kls, RegionNode* region) { - return generate_access_flags_guard(kls, JVM_ACC_IS_HIDDEN_CLASS, 0, region); + return generate_misc_flags_guard(kls, KlassFlags::_misc_is_hidden_class, 0, region); } //-------------------------inline_native_Class_query------------------- @@ -5320,12 +5340,12 @@ bool LibraryCallKit::inline_native_clone(bool is_virtual) { // The object must be easily cloneable and must not have a finalizer. // Both of these conditions may be checked in a single test. // We could optimize the test further, but we don't care. - generate_access_flags_guard(obj_klass, - // Test both conditions: - JVM_ACC_IS_CLONEABLE_FAST | JVM_ACC_HAS_FINALIZER, - // Must be cloneable but not finalizer: - JVM_ACC_IS_CLONEABLE_FAST, - slow_region); + generate_misc_flags_guard(obj_klass, + // Test both conditions: + KlassFlags::_misc_is_cloneable_fast | KlassFlags::_misc_has_finalizer, + // Must be cloneable but not finalizer: + KlassFlags::_misc_is_cloneable_fast, + slow_region); } if (!stopped()) { diff --git a/src/hotspot/share/opto/library_call.hpp b/src/hotspot/share/opto/library_call.hpp index 4ae9d0216e9..4a853045174 100644 --- a/src/hotspot/share/opto/library_call.hpp +++ b/src/hotspot/share/opto/library_call.hpp @@ -156,9 +156,11 @@ class LibraryCallKit : public GraphKit { region, null_path, offset); } - Node* generate_access_flags_guard(Node* kls, - int modifier_mask, int modifier_bits, - RegionNode* region); + Node* generate_klass_flags_guard(Node* kls, int modifier_mask, int modifier_bits, RegionNode* region, + ByteSize offset, const Type* type, BasicType bt); + Node* generate_misc_flags_guard(Node* kls, + int modifier_mask, int modifier_bits, + RegionNode* region); Node* generate_interface_guard(Node* kls, RegionNode* region); Node* generate_hidden_class_guard(Node* kls, RegionNode* region); Node* generate_array_guard(Node* kls, RegionNode* region) { @@ -351,6 +353,7 @@ class LibraryCallKit : public GraphKit { bool inline_vector_nary_operation(int n); bool inline_vector_frombits_coerced(); bool inline_vector_shuffle_to_vector(); + bool inline_vector_wrap_shuffle_indexes(); bool inline_vector_shuffle_iota(); Node* partially_wrap_indexes(Node* index_vec, int num_elem, BasicType type_bt); bool inline_vector_mask_operation(); @@ -361,6 +364,7 @@ class LibraryCallKit : public GraphKit { bool inline_vector_test(); bool inline_vector_blend(); bool inline_vector_rearrange(); + bool inline_vector_select_from(); bool inline_vector_compare(); bool inline_vector_broadcast_int(); bool inline_vector_convert(); @@ -370,7 +374,7 @@ class LibraryCallKit : public GraphKit { bool inline_index_vector(); bool inline_index_partially_in_upper_range(); - Node* gen_call_to_svml(int vector_api_op_id, BasicType bt, int num_elem, Node* opd1, Node* opd2); + Node* gen_call_to_vector_math(int vector_api_op_id, BasicType bt, int num_elem, Node* opd1, Node* opd2); enum VectorMaskUseType { VecMaskUseLoad = 1 << 0, diff --git a/src/hotspot/share/opto/loopTransform.cpp b/src/hotspot/share/opto/loopTransform.cpp index 6e537054643..c3cc8532e7d 100644 --- a/src/hotspot/share/opto/loopTransform.cpp +++ b/src/hotspot/share/opto/loopTransform.cpp @@ -1464,7 +1464,8 @@ IfTrueNode* PhaseIdealLoop::create_initialized_assertion_predicate(IfNode* templ Node* new_stride, Node* control) { assert(assertion_predicate_has_loop_opaque_node(template_assertion_predicate), "must find OpaqueLoop* nodes for Template Assertion Predicate"); - InitializedAssertionPredicate initialized_assertion_predicate(template_assertion_predicate, new_init, new_stride, this); + InitializedAssertionPredicateCreator initialized_assertion_predicate(template_assertion_predicate, new_init, + new_stride, this); IfTrueNode* success_proj = initialized_assertion_predicate.create(control); assert(!assertion_predicate_has_loop_opaque_node(success_proj->in(0)->as_If()), "Initialized Assertion Predicates do not have OpaqueLoop* nodes in the bool expression anymore"); @@ -1683,8 +1684,8 @@ void PhaseIdealLoop::insert_pre_post_loops(IdealLoopTree *loop, Node_List &old_n // use by range check elimination. Node *pre_opaq = new Opaque1Node(C, pre_limit, limit); - register_new_node(pre_limit, pre_head->in(0)); - register_new_node(pre_opaq , pre_head->in(0)); + register_new_node(pre_limit, pre_head->in(LoopNode::EntryControl)); + register_new_node(pre_opaq , pre_head->in(LoopNode::EntryControl)); // Since no other users of pre-loop compare, I can hack limit directly assert(cmp_end->outcnt() == 1, "no other users"); @@ -2790,6 +2791,7 @@ void PhaseIdealLoop::do_range_check(IdealLoopTree *loop, Node_List &old_new) { // Find the main loop limit; we will trim it's iterations // to not ever trip end tests Node *main_limit = cl->limit(); + Node* main_limit_ctrl = get_ctrl(main_limit); // Check graph shape. Cannot optimize a loop if zero-trip // Opaque1 node is optimized away and then another round @@ -2822,9 +2824,15 @@ void PhaseIdealLoop::do_range_check(IdealLoopTree *loop, Node_List &old_new) { } Opaque1Node *pre_opaq = (Opaque1Node*)pre_opaq1; Node *pre_limit = pre_opaq->in(1); + Node* pre_limit_ctrl = get_ctrl(pre_limit); // Where do we put new limit calculations - Node *pre_ctrl = pre_end->loopnode()->in(LoopNode::EntryControl); + Node* pre_ctrl = pre_end->loopnode()->in(LoopNode::EntryControl); + // Range check elimination optimizes out conditions whose parameters are loop invariant in the main loop. They usually + // have control above the pre loop, but there's no guarantee that they do. There's no guarantee either that the pre + // loop limit has control that's out of loop (a previous round of range check elimination could have set a limit that's + // not loop invariant). + Node* new_limit_ctrl = dominated_node(pre_ctrl, pre_limit_ctrl); // Ensure the original loop limit is available from the // pre-loop Opaque1 node. @@ -2884,14 +2892,14 @@ void PhaseIdealLoop::do_range_check(IdealLoopTree *loop, Node_List &old_new) { Node *limit = cmp->in(2); int scale_con= 1; // Assume trip counter not scaled - Node *limit_c = get_ctrl(limit); - if (loop->is_member(get_loop(limit_c))) { + Node* limit_ctrl = get_ctrl(limit); + if (loop->is_member(get_loop(limit_ctrl))) { // Compare might have operands swapped; commute them b_test = b_test.commute(); rc_exp = cmp->in(2); limit = cmp->in(1); - limit_c = get_ctrl(limit); - if (loop->is_member(get_loop(limit_c))) { + limit_ctrl = get_ctrl(limit); + if (loop->is_member(get_loop(limit_ctrl))) { continue; // Both inputs are loop varying; cannot RCE } } @@ -2900,11 +2908,11 @@ void PhaseIdealLoop::do_range_check(IdealLoopTree *loop, Node_List &old_new) { // 'limit' maybe pinned below the zero trip test (probably from a // previous round of rce), in which case, it can't be used in the // zero trip test expression which must occur before the zero test's if. - if (is_dominator(ctrl, limit_c)) { + if (is_dominator(ctrl, limit_ctrl)) { continue; // Don't rce this check but continue looking for other candidates. } - assert(is_dominator(compute_early_ctrl(limit, limit_c), pre_end), "node pinned on loop exit test?"); + assert(is_dominator(compute_early_ctrl(limit, limit_ctrl), pre_end), "node pinned on loop exit test?"); // Check for scaled induction variable plus an offset Node *offset = nullptr; @@ -2913,19 +2921,26 @@ void PhaseIdealLoop::do_range_check(IdealLoopTree *loop, Node_List &old_new) { continue; } - Node *offset_c = get_ctrl(offset); - if (loop->is_member(get_loop(offset_c))) { + Node* offset_ctrl = get_ctrl(offset); + if (loop->is_member(get_loop(offset_ctrl))) { continue; // Offset is not really loop invariant } // Here we know 'offset' is loop invariant. // As above for the 'limit', the 'offset' maybe pinned below the // zero trip test. - if (is_dominator(ctrl, offset_c)) { + if (is_dominator(ctrl, offset_ctrl)) { continue; // Don't rce this check but continue looking for other candidates. } - assert(is_dominator(compute_early_ctrl(offset, offset_c), pre_end), "node pinned on loop exit test?"); + // offset and limit can have control set below the pre loop when they are not loop invariant in the pre loop. + // Update their control (and the control of inputs as needed) to be above pre_end + offset_ctrl = ensure_node_and_inputs_are_above_pre_end(pre_end, offset); + limit_ctrl = ensure_node_and_inputs_are_above_pre_end(pre_end, limit); + + // offset and limit could have control below new_limit_ctrl if they are not loop invariant in the pre loop. + new_limit_ctrl = dominated_node(new_limit_ctrl, offset_ctrl, limit_ctrl); + #ifdef ASSERT if (TraceRangeLimitCheck) { tty->print_cr("RC bool node%s", flip ? " flipped:" : ":"); @@ -2945,16 +2960,16 @@ void PhaseIdealLoop::do_range_check(IdealLoopTree *loop, Node_List &old_new) { jlong lscale_con = scale_con; Node* int_offset = offset; offset = new ConvI2LNode(offset); - register_new_node(offset, pre_ctrl); + register_new_node(offset, new_limit_ctrl); Node* int_limit = limit; limit = new ConvI2LNode(limit); - register_new_node(limit, pre_ctrl); + register_new_node(limit, new_limit_ctrl); // Adjust pre and main loop limits to guard the correct iteration set if (cmp->Opcode() == Op_CmpU) { // Unsigned compare is really 2 tests if (b_test._test == BoolTest::lt) { // Range checks always use lt // The underflow and overflow limits: 0 <= scale*I+offset < limit - add_constraint(stride_con, lscale_con, offset, zero, limit, pre_ctrl, &pre_limit, &main_limit); + add_constraint(stride_con, lscale_con, offset, zero, limit, new_limit_ctrl, &pre_limit, &main_limit); Node* init = cl->init_trip(); Node* opaque_init = new OpaqueLoopInitNode(C, init); register_new_node(opaque_init, loop_entry); @@ -3013,22 +3028,22 @@ void PhaseIdealLoop::do_range_check(IdealLoopTree *loop, Node_List &old_new) { // Convert (I*scale+offset) >= Limit to (I*(-scale)+(-offset)) <= -Limit lscale_con = -lscale_con; offset = new SubLNode(zero, offset); - register_new_node(offset, pre_ctrl); + register_new_node(offset, new_limit_ctrl); limit = new SubLNode(zero, limit); - register_new_node(limit, pre_ctrl); + register_new_node(limit, new_limit_ctrl); // Fall into LE case case BoolTest::le: if (b_test._test != BoolTest::gt) { // Convert X <= Y to X < Y+1 limit = new AddLNode(limit, one); - register_new_node(limit, pre_ctrl); + register_new_node(limit, new_limit_ctrl); } // Fall into LT case case BoolTest::lt: // The underflow and overflow limits: MIN_INT <= scale*I+offset < limit // Note: (MIN_INT+1 == -MAX_INT) is used instead of MIN_INT here // to avoid problem with scale == -1: MIN_INT/(-1) == MIN_INT. - add_constraint(stride_con, lscale_con, offset, mini, limit, pre_ctrl, &pre_limit, &main_limit); + add_constraint(stride_con, lscale_con, offset, mini, limit, new_limit_ctrl, &pre_limit, &main_limit); break; default: if (PrintOpto) { @@ -3072,8 +3087,14 @@ void PhaseIdealLoop::do_range_check(IdealLoopTree *loop, Node_List &old_new) { // Computed pre-loop limit can be outside of loop iterations range. pre_limit = (stride_con > 0) ? (Node*)new MinINode(pre_limit, orig_limit) : (Node*)new MaxINode(pre_limit, orig_limit); - register_new_node(pre_limit, pre_ctrl); + register_new_node(pre_limit, new_limit_ctrl); } + // new pre_limit can push Bool/Cmp/Opaque nodes down (when one of the eliminated condition has parameters that are not + // loop invariant in the pre loop. + set_ctrl(pre_opaq, new_limit_ctrl); + set_ctrl(pre_end->cmp_node(), new_limit_ctrl); + set_ctrl(pre_end->in(1), new_limit_ctrl); + _igvn.replace_input_of(pre_opaq, 1, pre_limit); // Note:: we are making the main loop limit no longer precise; @@ -3093,7 +3114,7 @@ void 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"); + assert(main_limit == cl->limit() || get_ctrl(main_limit) == new_limit_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. @@ -3101,7 +3122,7 @@ void PhaseIdealLoop::do_range_check(IdealLoopTree *loop, Node_List &old_new) { // may be too pessimistic. A CastII here guarantees it's not lost. main_limit = new CastIINode(pre_ctrl, main_limit, TypeInt::make(upward ? min_jint : orig_limit_t->_lo, upward ? orig_limit_t->_hi : max_jint, Type::WidenMax)); - register_new_node(main_limit, pre_ctrl); + register_new_node(main_limit, new_limit_ctrl); // Hack the now-private loop bounds _igvn.replace_input_of(main_cmp, 2, main_limit); if (abs_stride_is_one) { @@ -3112,6 +3133,37 @@ void PhaseIdealLoop::do_range_check(IdealLoopTree *loop, Node_List &old_new) { // The OpaqueNode is unshared by design assert(opqzm->outcnt() == 1, "cannot hack shared node"); _igvn.replace_input_of(opqzm, 1, main_limit); + // new main_limit can push Bool/Cmp nodes down (when one of the eliminated condition has parameters that are not loop + // invariant in the pre loop. + set_ctrl(opqzm, new_limit_ctrl); + set_ctrl(iffm->in(1)->in(1), new_limit_ctrl); + set_ctrl(iffm->in(1), new_limit_ctrl); +} + +// Adjust control for node and its inputs (and inputs of its inputs) to be above the pre end +Node* PhaseIdealLoop::ensure_node_and_inputs_are_above_pre_end(CountedLoopEndNode* pre_end, Node* node) { + Node* control = get_ctrl(node); + assert(is_dominator(compute_early_ctrl(node, control), pre_end), "node pinned on loop exit test?"); + + if (is_dominator(control, pre_end)) { + return control; + } + control = pre_end->in(0); + ResourceMark rm; + Unique_Node_List wq; + wq.push(node); + for (uint i = 0; i < wq.size(); i++) { + Node* n = wq.at(i); + assert(is_dominator(compute_early_ctrl(n, get_ctrl(n)), pre_end), "node pinned on loop exit test?"); + set_ctrl(n, control); + for (uint j = 0; j < n->req(); j++) { + Node* in = n->in(j); + if (in != nullptr && has_ctrl(in) && !is_dominator(get_ctrl(in), pre_end)) { + wq.push(in); + } + } + } + return control; } bool IdealLoopTree::compute_has_range_checks() const { @@ -3765,7 +3817,7 @@ bool PhaseIdealLoop::match_fill_loop(IdealLoopTree* lpt, Node*& store, Node*& st break; } int opc = n->Opcode(); - if (opc == Op_StoreP || opc == Op_StoreN || opc == Op_StoreNKlass || opc == Op_StoreCM) { + if (opc == Op_StoreP || opc == Op_StoreN || opc == Op_StoreNKlass) { msg = "oop fills not handled"; break; } diff --git a/src/hotspot/share/opto/loopnode.cpp b/src/hotspot/share/opto/loopnode.cpp index b4c134570e6..6cb50b3dee2 100644 --- a/src/hotspot/share/opto/loopnode.cpp +++ b/src/hotspot/share/opto/loopnode.cpp @@ -692,14 +692,24 @@ SafePointNode* PhaseIdealLoop::find_safepoint(Node* back_control, Node* x, Ideal // We can only use that safepoint if there's no side effect between the backedge and the safepoint. - // mm is used for book keeping + // mm is the memory state at the safepoint (when it's a MergeMem) + // no_side_effect_since_safepoint() goes over the memory state at the backedge. It resets the mm input for each + // component of the memory state it encounters so it points to the base memory. Once no_side_effect_since_safepoint() + // is done, if no side effect after the safepoint was found, mm should transform to the base memory: the states at + // the backedge and safepoint are the same so all components of the memory state at the safepoint should have been + // reset. MergeMemNode* mm = nullptr; #ifdef ASSERT if (mem->is_MergeMem()) { mm = mem->clone()->as_MergeMem(); _igvn._worklist.push(mm); for (MergeMemStream mms(mem->as_MergeMem()); mms.next_non_empty(); ) { - if (mms.alias_idx() != Compile::AliasIdxBot && loop != get_loop(ctrl_or_self(mms.memory()))) { + // Loop invariant memory state won't be reset by no_side_effect_since_safepoint(). Do it here. + // Escape Analysis can add state to mm that it doesn't add to the backedge memory Phis, breaking verification + // code that relies on mm. Clear that extra state here. + if (mms.alias_idx() != Compile::AliasIdxBot && + (loop != get_loop(ctrl_or_self(mms.memory())) || + (mms.adr_type()->isa_oop_ptr() && mms.adr_type()->is_known_instance()))) { mm->set_memory_at(mms.alias_idx(), mem->as_MergeMem()->base_memory()); } } @@ -1918,12 +1928,28 @@ bool PhaseIdealLoop::is_counted_loop(Node* x, IdealLoopTree*&loop, BasicType iv_ // Since stride > 0 and limit_correction <= stride + 1, we can restate this with no over- or underflow into: // max_int - canonicalized_correction - limit_correction >= limit // Since canonicalized_correction and limit_correction are both constants, we can replace them with a new constant: - // final_correction = canonicalized_correction + limit_correction + // (v) final_correction = canonicalized_correction + limit_correction + // // which gives us: // // Final predicate condition: // max_int - final_correction >= limit // + // However, we need to be careful that (v) does not over- or underflow. + // We know that: + // canonicalized_correction = stride - 1 + // and + // limit_correction <= stride + 1 + // and thus + // canonicalized_correction + limit_correction <= 2 * stride + // To prevent an over- or underflow of (v), we must ensure that + // 2 * stride <= max_int + // which can safely be checked without over- or underflow with + // (vi) stride != min_int AND abs(stride) <= max_int / 2 + // + // We could try to further optimize the cases where (vi) does not hold but given that such large strides are + // very uncommon and the loop would only run for a very few iterations anyway, we simply bail out if (vi) fails. + // // (2) Loop Limit Check Predicate for (ii): // Using (ii): init < limit // @@ -1954,6 +1980,10 @@ bool PhaseIdealLoop::is_counted_loop(Node* x, IdealLoopTree*&loop, BasicType iv_ // there is no overflow of the iv phi after the first iteration. In this case, we don't need to check (ii) // again and can skip the predicate. + // Check (vi) and bail out if the stride is too big. + if (stride_con == min_signed_integer(iv_bt) || (ABS(stride_con) > max_signed_integer(iv_bt) / 2)) { + return false; + } // Accounting for (LE3) and (LE4) where we use pre-incremented phis in the loop exit check. const jlong limit_correction_for_pre_iv_exit_check = (phi_incr != nullptr) ? stride_con : 0; @@ -4319,13 +4349,21 @@ void PhaseIdealLoop::mark_loop_associated_parse_predicates_useful() { } } +// This visitor marks all visited Parse Predicates useful. +class ParsePredicateUsefulMarker : public PredicateVisitor { + public: + using PredicateVisitor::visit; + + void visit(const ParsePredicate& parse_predicate) override { + parse_predicate.head()->mark_useful(); + } +}; + void PhaseIdealLoop::mark_useful_parse_predicates_for_loop(IdealLoopTree* loop) { Node* entry = loop->_head->as_Loop()->skip_strip_mined()->in(LoopNode::EntryControl); - const Predicates predicates(entry); - ParsePredicateIterator iterator(predicates); - while (iterator.has_next()) { - iterator.next()->mark_useful(); - } + const PredicateIterator predicate_iterator(entry); + ParsePredicateUsefulMarker useful_marker; + predicate_iterator.for_each(useful_marker); } void PhaseIdealLoop::add_useless_parse_predicates_to_igvn_worklist() { @@ -4511,23 +4549,6 @@ bool PhaseIdealLoop::process_expensive_nodes() { return progress; } -#ifdef ASSERT -// Goes over all children of the root of the loop tree. Check if any of them have a path -// down to Root, that does not go via a NeverBranch exit. -bool PhaseIdealLoop::only_has_infinite_loops() { - ResourceMark rm; - Unique_Node_List worklist; - // start traversal at all loop heads of first-level loops - for (IdealLoopTree* l = _ltree_root->_child; l != nullptr; l = l->_next) { - Node* head = l->_head; - assert(head->is_Region(), ""); - worklist.push(head); - } - return RegionNode::are_all_nodes_in_infinite_subgraph(worklist); -} -#endif - - //============================================================================= //----------------------------build_and_optimize------------------------------- // Create a PhaseLoop. Build the ideal Loop tree. Map each Ideal Node to @@ -4586,13 +4607,9 @@ void PhaseIdealLoop::build_and_optimize() { return; } - // Verify that the has_loops() flag set at parse time is consistent - // with the just built loop tree. With infinite loops, it could be - // that one pass of loop opts only finds infinite loops, clears the - // has_loops() flag but adds NeverBranch nodes so the next loop opts - // verification pass finds a non empty loop tree. When the back edge + // Verify that the has_loops() flag set at parse time is consistent with the just built loop tree. When the back edge // is an exception edge, parsing doesn't set has_loops(). - assert(_ltree_root->_child == nullptr || C->has_loops() || only_has_infinite_loops() || C->has_exception_backedge(), "parsing found no loops but there are some"); + assert(_ltree_root->_child == nullptr || C->has_loops() || C->has_exception_backedge(), "parsing found no loops but there are some"); // No loops after all if( !_ltree_root->_child && !_verify_only ) C->set_has_loops(false); @@ -4936,7 +4953,9 @@ void PhaseIdealLoop::verify() const { bool success = true; PhaseIdealLoop phase_verify(_igvn, this); - if (C->failing()) return; + if (C->failing_internal()) { + return; + } // Verify ctrl and idom of every node. success &= verify_idom_and_nodes(C->root(), &phase_verify); @@ -5425,7 +5444,7 @@ void PhaseIdealLoop::build_loop_tree() { if ( bltstack.length() == stack_size ) { // There were no additional children, post visit node now (void)bltstack.pop(); // Remove node from stack - pre_order = build_loop_tree_impl( n, pre_order ); + pre_order = build_loop_tree_impl(n, pre_order); // Check for bailout if (C->failing()) { return; @@ -5443,7 +5462,7 @@ void PhaseIdealLoop::build_loop_tree() { } //------------------------------build_loop_tree_impl--------------------------- -int PhaseIdealLoop::build_loop_tree_impl( Node *n, int pre_order ) { +int PhaseIdealLoop::build_loop_tree_impl(Node* n, int pre_order) { // ---- Post-pass Work ---- // Pre-walked but not post-walked nodes need a pre_order number. @@ -5454,24 +5473,24 @@ int PhaseIdealLoop::build_loop_tree_impl( Node *n, int pre_order ) { // for it. Then find the tightest enclosing loop for the self Node. for (DUIterator_Fast imax, i = n->fast_outs(imax); i < imax; i++) { Node* m = n->fast_out(i); // Child - if( n == m ) continue; // Ignore control self-cycles - if( !m->is_CFG() ) continue;// Ignore non-CFG edges + if (n == m) continue; // Ignore control self-cycles + if (!m->is_CFG()) continue;// Ignore non-CFG edges IdealLoopTree *l; // Child's loop - if( !is_postvisited(m) ) { // Child visited but not post-visited? + if (!is_postvisited(m)) { // Child visited but not post-visited? // Found a backedge - assert( get_preorder(m) < pre_order, "should be backedge" ); + assert(get_preorder(m) < pre_order, "should be backedge"); // Check for the RootNode, which is already a LoopNode and is allowed // to have multiple "backedges". - if( m == C->root()) { // Found the root? + if (m == C->root()) { // Found the root? l = _ltree_root; // Root is the outermost LoopNode } else { // Else found a nested loop // Insert a LoopNode to mark this loop. l = new IdealLoopTree(this, m, n); } // End of Else found a nested loop - if( !has_loop(m) ) // If 'm' does not already have a loop set + if (!has_loop(m)) { // If 'm' does not already have a loop set set_loop(m, l); // Set loop header to loop now - + } } else { // Else not a nested loop if (!_loop_or_ctrl[m->_idx]) continue; // Dead code has no loop IdealLoopTree* m_loop = get_loop(m); @@ -5480,23 +5499,17 @@ int PhaseIdealLoop::build_loop_tree_impl( Node *n, int pre_order ) { // is a member of some outer enclosing loop. Since there are no // shared headers (I've split them already) I only need to go up // at most 1 level. - while( l && l->_head == m ) // Successor heads loop? + while (l && l->_head == m) { // Successor heads loop? l = l->_parent; // Move up 1 for me + } // If this loop is not properly parented, then this loop // has no exit path out, i.e. its an infinite loop. - if( !l ) { + if (!l) { // Make loop "reachable" from root so the CFG is reachable. Basically // insert a bogus loop exit that is never taken. 'm', the loop head, // points to 'n', one (of possibly many) fall-in paths. There may be // many backedges as well. - // Here I set the loop to be the root loop. I could have, after - // inserting a bogus loop exit, restarted the recursion and found my - // new loop exit. This would make the infinite loop a first-class - // loop and it would then get properly optimized. What's the use of - // optimizing an infinite loop? - l = _ltree_root; // Oops, found infinite loop - if (!_verify_only) { // Insert the NeverBranch between 'm' and it's control user. NeverBranchNode *iff = new NeverBranchNode( m ); @@ -5520,7 +5533,7 @@ int PhaseIdealLoop::build_loop_tree_impl( Node *n, int pre_order ) { // Now create the never-taken loop exit Node *if_f = new CProjNode( iff, 1 ); _igvn.register_new_node_with_optimizer(if_f); - set_loop(if_f, l); + set_loop(if_f, _ltree_root); // Find frame ptr for Halt. Relies on the optimizer // V-N'ing. Easier and quicker than searching through // the program structure. @@ -5529,10 +5542,27 @@ int PhaseIdealLoop::build_loop_tree_impl( Node *n, int pre_order ) { // Halt & Catch Fire Node* halt = new HaltNode(if_f, frame, "never-taken loop exit reached"); _igvn.register_new_node_with_optimizer(halt); - set_loop(halt, l); + set_loop(halt, _ltree_root); _igvn.add_input_to(C->root(), halt); } set_loop(C->root(), _ltree_root); + // move to outer most loop with same header + l = m_loop; + while (true) { + IdealLoopTree* next = l->_parent; + if (next == nullptr || next->_head != m) { + break; + } + l = next; + } + // properly insert infinite loop in loop tree + sort(_ltree_root, l); + // fix child link from parent + IdealLoopTree* p = l->_parent; + l->_next = p->_child; + p->_child = l; + // code below needs enclosing loop + l = l->_parent; } } if (is_postvisited(l->_head)) { @@ -5586,7 +5616,7 @@ int PhaseIdealLoop::build_loop_tree_impl( Node *n, int pre_order ) { assert( get_loop(n) == innermost, "" ); IdealLoopTree *p = innermost->_parent; IdealLoopTree *l = innermost; - while( p && l->_head == n ) { + while (p && l->_head == n) { l->_next = p->_child; // Put self on parents 'next child' p->_child = l; // Make self as first child of parent l = p; // Now walk up the parent chain @@ -5600,7 +5630,7 @@ int PhaseIdealLoop::build_loop_tree_impl( Node *n, int pre_order ) { // Record tightest enclosing loop for self. Mark as post-visited. set_loop(n, innermost); // Also record has_call flag early on - if( innermost ) { + if (innermost) { if( n->is_Call() && !n->is_CallLeaf() && !n->is_macro() ) { // Do not count uncommon calls if( !n->is_CallStaticJava() || !n->as_CallStaticJava()->_name ) { @@ -6277,6 +6307,43 @@ void PhaseIdealLoop::build_loop_late_post(Node *n) { build_loop_late_post_work(n, true); } +// Class to visit all predicates in a predicate chain to find out which are dominated by a given node. Keeps track of +// the entry to the earliest predicate that is still dominated by the given dominator. This class is used when trying to +// legally skip all predicates when figuring out the latest placement such that a node does not interfere with Loop +// Predication or creating a Loop Limit Check Predicate later. +class DominatedPredicates : public UnifiedPredicateVisitor { + Node* const _dominator; + Node* _earliest_dominated_predicate_entry; + bool _should_continue; + PhaseIdealLoop* const _phase; + + public: + DominatedPredicates(Node* dominator, Node* start_node, PhaseIdealLoop* phase) + : _dominator(dominator), + _earliest_dominated_predicate_entry(start_node), + _should_continue(true), + _phase(phase) {} + NONCOPYABLE(DominatedPredicates); + + bool should_continue() const override { + return _should_continue; + } + + // Returns the entry to the earliest predicate that is still dominated by the given dominator (all could be dominated). + Node* earliest_dominated_predicate_entry() const { + return _earliest_dominated_predicate_entry; + } + + void visit_predicate(const Predicate& predicate) override { + Node* entry = predicate.entry(); + if (_phase->is_strict_dominator(entry, _dominator)) { + _should_continue = false; + } else { + _earliest_dominated_predicate_entry = entry; + } + } +}; + void PhaseIdealLoop::build_loop_late_post_work(Node *n, bool pinned) { if (n->req() == 2 && (n->Opcode() == Op_ConvI2L || n->Opcode() == Op_CastII) && !C->major_progress() && !_verify_only) { @@ -6388,14 +6455,10 @@ void PhaseIdealLoop::build_loop_late_post_work(Node *n, bool pinned) { // Move the node above predicates as far up as possible so a // following pass of Loop Predication doesn't hoist a predicate // that depends on it above that node. - PredicateEntryIterator predicate_iterator(least); - while (predicate_iterator.has_next()) { - Node* next_predicate_entry = predicate_iterator.next_entry(); - if (is_strict_dominator(next_predicate_entry, early)) { - break; - } - least = next_predicate_entry; - } + const PredicateIterator predicate_iterator(least); + DominatedPredicates dominated_predicates(early, least, this); + predicate_iterator.for_each(dominated_predicates); + least = dominated_predicates.earliest_dominated_predicate_entry(); } // Try not to place code on a loop entry projection // which can inhibit range check elimination. diff --git a/src/hotspot/share/opto/loopnode.hpp b/src/hotspot/share/opto/loopnode.hpp index 369f446adbb..3aa67bcb5cb 100644 --- a/src/hotspot/share/opto/loopnode.hpp +++ b/src/hotspot/share/opto/loopnode.hpp @@ -966,10 +966,6 @@ private: const Node_List& old_new); void insert_loop_limit_check_predicate(ParsePredicateSuccessProj* loop_limit_check_parse_proj, Node* cmp_limit, Node* bol); -#ifdef ASSERT - bool only_has_infinite_loops(); -#endif - void log_loop_tree(); public: @@ -1076,7 +1072,7 @@ private: // Place 'n' in some loop nest, where 'n' is a CFG node void build_loop_tree(); - int build_loop_tree_impl( Node *n, int pre_order ); + int build_loop_tree_impl(Node* n, int pre_order); // Insert loop into the existing loop tree. 'innermost' is a leaf of the // loop tree, not the root. IdealLoopTree *sort( IdealLoopTree *loop, IdealLoopTree *innermost ); @@ -1132,7 +1128,9 @@ private: _verify_only(verify_me == nullptr), _mode(LoopOptsVerify), _nodes_required(UINT_MAX) { + DEBUG_ONLY(C->set_phase_verify_ideal_loop();) build_and_optimize(); + DEBUG_ONLY(C->reset_phase_verify_ideal_loop();) } #endif @@ -1184,6 +1182,16 @@ public: } Node *dom_lca_internal( Node *n1, Node *n2 ) const; + Node* dominated_node(Node* c1, Node* c2) { + assert(is_dominator(c1, c2) || is_dominator(c2, c1), "nodes must be related"); + return is_dominator(c1, c2) ? c2 : c1; + } + + // Return control node that's dominated by the 2 others + Node* dominated_node(Node* c1, Node* c2, Node* c3) { + return dominated_node(c1, dominated_node(c2, c3)); + } + // Build and verify the loop tree without modifying the graph. This // is useful to verify that all inputs properly dominate their uses. static void verify(PhaseIterGVN& igvn) { @@ -1784,6 +1792,8 @@ public: bool can_move_to_inner_loop(Node* n, LoopNode* n_loop, Node* x); void pin_array_access_nodes_dependent_on(Node* ctrl); + + Node* ensure_node_and_inputs_are_above_pre_end(CountedLoopEndNode* pre_end, Node* node); }; diff --git a/src/hotspot/share/opto/loopopts.cpp b/src/hotspot/share/opto/loopopts.cpp index 7f42d2d4beb..654262d21cb 100644 --- a/src/hotspot/share/opto/loopopts.cpp +++ b/src/hotspot/share/opto/loopopts.cpp @@ -4548,7 +4548,6 @@ void PhaseIdealLoop::move_unordered_reduction_out_of_loop(IdealLoopTree* loop) { const TypeVect* vec_t = last_ur->vect_type(); uint vector_length = vec_t->length(); BasicType bt = vec_t->element_basic_type(); - const Type* bt_t = Type::get_const_basic_type(bt); // Convert opcode from vector-reduction -> scalar -> normal-vector-op const int sopc = VectorNode::scalar_opcode(last_ur->Opcode(), bt); @@ -4628,7 +4627,7 @@ void PhaseIdealLoop::move_unordered_reduction_out_of_loop(IdealLoopTree* loop) { Node* identity_scalar = ReductionNode::make_identity_con_scalar(_igvn, sopc, bt); set_ctrl(identity_scalar, C->root()); - VectorNode* identity_vector = VectorNode::scalar2vector(identity_scalar, vector_length, bt_t); + VectorNode* identity_vector = VectorNode::scalar2vector(identity_scalar, vector_length, bt); register_new_node(identity_vector, C->root()); assert(vec_t == identity_vector->vect_type(), "matching vector type"); VectorNode::trace_new_vector(identity_vector, "Unordered Reduction"); diff --git a/src/hotspot/share/opto/matcher.cpp b/src/hotspot/share/opto/matcher.cpp index bf773d43d3d..2031b09ca9d 100644 --- a/src/hotspot/share/opto/matcher.cpp +++ b/src/hotspot/share/opto/matcher.cpp @@ -194,6 +194,9 @@ void Matcher::match( ) { } // One-time initialization of some register masks. init_spill_mask( C->root()->in(1) ); + if (C->failing()) { + return; + } _return_addr_mask = return_addr(); #ifdef _LP64 // Pointers take 2 slots in 64-bit land @@ -287,10 +290,16 @@ void Matcher::match( ) { // preserve area, locks & pad2. OptoReg::Name reg1 = warp_incoming_stk_arg(vm_parm_regs[i].first()); + if (C->failing()) { + return; + } if( OptoReg::is_valid(reg1)) _calling_convention_mask[i].Insert(reg1); OptoReg::Name reg2 = warp_incoming_stk_arg(vm_parm_regs[i].second()); + if (C->failing()) { + return; + } if( OptoReg::is_valid(reg2)) _calling_convention_mask[i].Insert(reg2); @@ -386,7 +395,7 @@ void Matcher::match( ) { // Don't set control, it will confuse GCM since there are no uses. // The control will be set when this node is used first time // in find_base_for_derived(). - assert(_mach_null != nullptr, ""); + assert(_mach_null != nullptr || C->failure_is_artificial(), ""); // bailouts are handled below. C->set_root(xroot->is_Root() ? xroot->as_Root() : nullptr); @@ -404,7 +413,7 @@ void Matcher::match( ) { assert(C->failure_reason() != nullptr, "graph lost: reason unknown"); ss.print("graph lost: reason unknown"); } - C->record_method_not_compilable(ss.as_string()); + C->record_method_not_compilable(ss.as_string() DEBUG_ONLY(COMMA true)); } if (C->failing()) { // delete old; @@ -1439,10 +1448,16 @@ MachNode *Matcher::match_sfpt( SafePointNode *sfpt ) { } // Grab first register, adjust stack slots and insert in mask. OptoReg::Name reg1 = warp_outgoing_stk_arg(first, begin_out_arg_area, out_arg_limit_per_call ); + if (C->failing()) { + return nullptr; + } if (OptoReg::is_valid(reg1)) rm->Insert( reg1 ); // Grab second register (if any), adjust stack slots and insert in mask. OptoReg::Name reg2 = warp_outgoing_stk_arg(second, begin_out_arg_area, out_arg_limit_per_call ); + if (C->failing()) { + return nullptr; + } if (OptoReg::is_valid(reg2)) rm->Insert( reg2 ); } // End of for all arguments @@ -1594,6 +1609,14 @@ static bool match_into_reg( const Node *n, Node *m, Node *control, int i, bool s // the same register. See find_shared_node. return false; } else { // Not a constant + if (!shared && Matcher::is_encode_and_store_pattern(n, m)) { + // Make it possible to match "encode and store" patterns with non-shared + // encode operations that are pinned to a control node (e.g. by CastPP + // node removal in final graph reshaping). The matched instruction cannot + // float above the encode's control node because it is pinned to the + // store's control node. + return false; + } // Stop recursion if they have different Controls. Node* m_control = m->in(0); // Control of load's memory can post-dominates load's control. @@ -2671,6 +2694,10 @@ bool Matcher::gen_narrow_oop_implicit_null_checks() { // Compute RegMask for an ideal register. const RegMask* Matcher::regmask_for_ideal_register(uint ideal_reg, Node* ret) { + assert(!C->failing_internal() || C->failure_is_artificial(), "already failing."); + if (C->failing()) { + return nullptr; + } const Type* t = Type::mreg2type[ideal_reg]; if (t == nullptr) { assert(ideal_reg >= Op_VecA && ideal_reg <= Op_VecZ, "not a vector: %d", ideal_reg); @@ -2701,7 +2728,10 @@ const RegMask* Matcher::regmask_for_ideal_register(uint ideal_reg, Node* ret) { default: ShouldNotReachHere(); } MachNode* mspill = match_tree(spill); - assert(mspill != nullptr, "matching failed: %d", ideal_reg); + assert(mspill != nullptr || C->failure_is_artificial(), "matching failed: %d", ideal_reg); + if (C->failing()) { + return nullptr; + } // Handle generic vector operand case if (Matcher::supports_generic_vector_operands && t->isa_vect()) { specialize_mach_node(mspill); @@ -2833,9 +2863,21 @@ bool Matcher::is_non_long_integral_vector(const Node* n) { return is_subword_type(bt) || bt == T_INT; } +bool Matcher::is_encode_and_store_pattern(const Node* n, const Node* m) { + if (n == nullptr || + m == nullptr || + n->Opcode() != Op_StoreN || + !m->is_EncodeP() || + n->as_Store()->barrier_data() == 0) { + return false; + } + assert(m == n->in(MemNode::ValueIn), "m should be input to n"); + return true; +} + #ifdef ASSERT bool Matcher::verify_after_postselect_cleanup() { - assert(!C->failing(), "sanity"); + assert(!C->failing_internal() || C->failure_is_artificial(), "sanity"); if (supports_generic_vector_operands) { Unique_Node_List useful; C->identify_useful_nodes(useful); diff --git a/src/hotspot/share/opto/matcher.hpp b/src/hotspot/share/opto/matcher.hpp index 84e48086f92..de3b23aa6d2 100644 --- a/src/hotspot/share/opto/matcher.hpp +++ b/src/hotspot/share/opto/matcher.hpp @@ -342,7 +342,6 @@ public: static bool vector_needs_partial_operations(Node* node, const TypeVect* vt); static const RegMask* predicate_reg_mask(void); - static const TypeVectMask* predicate_reg_type(const Type* elemTy, int length); // Vector width in bytes static int vector_width_in_bytes(BasicType bt); @@ -385,6 +384,8 @@ public: return ((bt & BoolTest::unsigned_compare) == BoolTest::unsigned_compare); } + static bool is_encode_and_store_pattern(const Node* n, const Node* m); + // These calls are all generated by the ADLC // Java-Java calling convention diff --git a/src/hotspot/share/opto/memnode.cpp b/src/hotspot/share/opto/memnode.cpp index 2d79857b62a..27c0d16fac1 100644 --- a/src/hotspot/share/opto/memnode.cpp +++ b/src/hotspot/share/opto/memnode.cpp @@ -1981,6 +1981,12 @@ LoadNode::load_array_final_field(const TypeKlassPtr *tkls, assert(this->Opcode() == Op_LoadI, "must load an int from _access_flags"); return TypeInt::make(klass->access_flags()); } + if (tkls->offset() == in_bytes(Klass::misc_flags_offset())) { + // The field is Klass::_misc_flags. Return its (constant) value. + // (Folds up the 2nd indirection in Reflection.getClassAccessFlags(aClassConstant).) + assert(this->Opcode() == Op_LoadUB, "must load an unsigned byte from _misc_flags"); + return TypeInt::make(klass->misc_flags()); + } if (tkls->offset() == in_bytes(Klass::layout_helper_offset())) { // The field is Klass::_layout_helper. Return its constant value if known. assert(this->Opcode() == Op_LoadI, "must load an int from _layout_helper"); @@ -3456,9 +3462,7 @@ Node *StoreNode::Ideal(PhaseGVN *phase, bool can_reshape) { Node* address = in(MemNode::Address); Node* value = in(MemNode::ValueIn); // Back-to-back stores to same address? Fold em up. Generally - // unsafe if I have intervening uses... Also disallowed for StoreCM - // since they must follow each StoreP operation. Redundant StoreCMs - // are eliminated just before matching in final_graph_reshape. + // unsafe if I have intervening uses. { Node* st = mem; // If Store 'st' has more than one use, we cannot fold 'st' away. @@ -3468,7 +3472,7 @@ Node *StoreNode::Ideal(PhaseGVN *phase, bool can_reshape) { // require exactly ONE user until such time as we clone 'mem' for // each of 'mem's uses (thus making the exactly-1-user-rule hold // true). - while (st->is_Store() && st->outcnt() == 1 && st->Opcode() != Op_StoreCM) { + while (st->is_Store() && st->outcnt() == 1) { // Looking at a dead closed cycle of memory? assert(st != st->in(MemNode::Memory), "dead loop in StoreNode::Ideal"); assert(Opcode() == st->Opcode() || @@ -3775,48 +3779,6 @@ Node *StoreCNode::Ideal(PhaseGVN *phase, bool can_reshape){ return StoreNode::Ideal(phase, can_reshape); } -//============================================================================= -//------------------------------Identity--------------------------------------- -Node* StoreCMNode::Identity(PhaseGVN* phase) { - // No need to card mark when storing a null ptr - Node* my_store = in(MemNode::OopStore); - if (my_store->is_Store()) { - const Type *t1 = phase->type( my_store->in(MemNode::ValueIn) ); - if( t1 == TypePtr::NULL_PTR ) { - return in(MemNode::Memory); - } - } - return this; -} - -//============================================================================= -//------------------------------Ideal--------------------------------------- -Node *StoreCMNode::Ideal(PhaseGVN *phase, bool can_reshape){ - Node* progress = StoreNode::Ideal(phase, can_reshape); - if (progress != nullptr) return progress; - - Node* my_store = in(MemNode::OopStore); - if (my_store->is_MergeMem()) { - Node* mem = my_store->as_MergeMem()->memory_at(oop_alias_idx()); - set_req_X(MemNode::OopStore, mem, phase); - return this; - } - - return nullptr; -} - -//------------------------------Value----------------------------------------- -const Type* StoreCMNode::Value(PhaseGVN* phase) const { - // Either input is TOP ==> the result is TOP (checked in StoreNode::Value). - // If extra input is TOP ==> the result is TOP - const Type* t = phase->type(in(MemNode::OopStore)); - if (t == Type::TOP) { - return Type::TOP; - } - return StoreNode::Value(phase); -} - - //============================================================================= //----------------------------------SCMemProjNode------------------------------ const Type* SCMemProjNode::Value(PhaseGVN* phase) const @@ -4638,6 +4600,11 @@ intptr_t InitializeNode::can_capture_store(StoreNode* st, PhaseGVN* phase, bool Node* mem = st->in(MemNode::Memory); if (!(mem->is_Proj() && mem->in(0) == this)) return FAIL; // must not be preceded by other stores + BarrierSetC2* bs = BarrierSet::barrier_set()->barrier_set_c2(); + if ((st->Opcode() == Op_StoreP || st->Opcode() == Op_StoreN) && + !bs->can_initialize_object(st)) { + return FAIL; + } Node* adr = st->in(MemNode::Address); intptr_t offset; AllocateNode* alloc = AllocateNode::Ideal_allocation(adr, phase, offset); diff --git a/src/hotspot/share/opto/memnode.hpp b/src/hotspot/share/opto/memnode.hpp index 85d206749f6..1ca3a4b16ce 100644 --- a/src/hotspot/share/opto/memnode.hpp +++ b/src/hotspot/share/opto/memnode.hpp @@ -55,8 +55,7 @@ public: enum { Control, // When is it safe to do this load? Memory, // Chunk of memory is being loaded from Address, // Actually address, derived from base - ValueIn, // Value to store - OopStore // Preceding oop store, only in StoreCM + ValueIn // Value to store }; typedef enum { unordered = 0, acquire, // Load has to acquire or be succeeded by MemBarAcquire. @@ -124,11 +123,7 @@ public: // Raw access function, to allow copying of adr_type efficiently in // product builds and retain the debug info for debug builds. const TypePtr *raw_adr_type() const { -#ifdef ASSERT - return _adr_type; -#else - return 0; -#endif + return DEBUG_ONLY(_adr_type) NOT_DEBUG(nullptr); } // Return the barrier data of n, if available, or 0 otherwise. @@ -781,36 +776,6 @@ public: virtual BasicType memory_type() const { return T_NARROWKLASS; } }; -//------------------------------StoreCMNode----------------------------------- -// Store card-mark byte to memory for CM -// The last StoreCM before a SafePoint must be preserved and occur after its "oop" store -// Preceding equivalent StoreCMs may be eliminated. -class StoreCMNode : public StoreNode { - private: - virtual uint hash() const { return StoreNode::hash() + _oop_alias_idx; } - virtual bool cmp( const Node &n ) const { - return _oop_alias_idx == ((StoreCMNode&)n)._oop_alias_idx - && StoreNode::cmp(n); - } - virtual uint size_of() const { return sizeof(*this); } - int _oop_alias_idx; // The alias_idx of OopStore - -public: - StoreCMNode( Node *c, Node *mem, Node *adr, const TypePtr* at, Node *val, Node *oop_store, int oop_alias_idx ) : - StoreNode(c, mem, adr, at, val, oop_store, MemNode::release), - _oop_alias_idx(oop_alias_idx) { - assert(_oop_alias_idx >= Compile::AliasIdxRaw || - (_oop_alias_idx == Compile::AliasIdxBot && !Compile::current()->do_aliasing()), - "bad oop alias idx"); - } - virtual int Opcode() const; - virtual Node* Identity(PhaseGVN* phase); - virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); - virtual const Type* Value(PhaseGVN* phase) const; - virtual BasicType memory_type() const { return T_VOID; } // unspecific - int oop_alias_idx() const { return _oop_alias_idx; } -}; - //------------------------------SCMemProjNode--------------------------------------- // This class defines a projection of the memory state of a store conditional node. // These nodes return a value, but also update memory. diff --git a/src/hotspot/share/opto/mulnode.cpp b/src/hotspot/share/opto/mulnode.cpp index 1f22c608323..ad98fda025f 100644 --- a/src/hotspot/share/opto/mulnode.cpp +++ b/src/hotspot/share/opto/mulnode.cpp @@ -594,6 +594,69 @@ const Type* MulHiValue(const Type *t1, const Type *t2, const Type *bot) { return TypeLong::LONG; } +template +static const IntegerType* and_value(const IntegerType* r0, const IntegerType* r1) { + typedef typename IntegerType::NativeType NativeType; + static_assert(std::is_signed::value, "Native type of IntegerType must be signed!"); + + int widen = MAX2(r0->_widen, r1->_widen); + + // If both types are constants, we can calculate a constant result. + if (r0->is_con() && r1->is_con()) { + return IntegerType::make(r0->get_con() & r1->get_con()); + } + + // If both ranges are positive, the result will range from 0 up to the hi value of the smaller range. The minimum + // of the two constrains the upper bound because any higher value in the other range will see all zeroes, so it will be masked out. + if (r0->_lo >= 0 && r1->_lo >= 0) { + return IntegerType::make(0, MIN2(r0->_hi, r1->_hi), widen); + } + + // If only one range is positive, the result will range from 0 up to that range's maximum value. + // For the operation 'x & C' where C is a positive constant, the result will be in the range [0..C]. With that observation, + // we can say that for any integer c such that 0 <= c <= C will also be in the range [0..C]. Therefore, 'x & [c..C]' + // where c >= 0 will be in the range [0..C]. + if (r0->_lo >= 0) { + return IntegerType::make(0, r0->_hi, widen); + } + + if (r1->_lo >= 0) { + return IntegerType::make(0, r1->_hi, widen); + } + + // At this point, all positive ranges will have already been handled, so the only remaining cases will be negative ranges + // and constants. + + assert(r0->_lo < 0 && r1->_lo < 0, "positive ranges should already be handled!"); + + // As two's complement means that both numbers will start with leading 1s, the lower bound of both ranges will contain + // the common leading 1s of both minimum values. In order to count them with count_leading_zeros, the bits are inverted. + NativeType sel_val = ~MIN2(r0->_lo, r1->_lo); + + NativeType min; + if (sel_val == 0) { + // Since count_leading_zeros is undefined at 0, we short-circuit the condition where both ranges have a minimum of -1. + min = -1; + } else { + // To get the number of bits to shift, we count the leading 0-bits and then subtract one, as the sign bit is already set. + int shift_bits = count_leading_zeros(sel_val) - 1; + min = std::numeric_limits::min() >> shift_bits; + } + + NativeType max; + if (r0->_hi < 0 && r1->_hi < 0) { + // If both ranges are negative, then the same optimization as both positive ranges will apply, and the smaller hi + // value will mask off any bits set by higher values. + max = MIN2(r0->_hi, r1->_hi); + } else { + // In the case of ranges that cross zero, negative values can cause the higher order bits to be set, so the maximum + // positive value can be as high as the larger hi value. + max = MAX2(r0->_hi, r1->_hi); + } + + return IntegerType::make(min, max, widen); +} + //============================================================================= //------------------------------mul_ring--------------------------------------- // Supplied function returns the product of the inputs IN THE CURRENT RING. @@ -601,29 +664,10 @@ const Type* MulHiValue(const Type *t1, const Type *t2, const Type *bot) { // This also type-checks the inputs for sanity. Guaranteed never to // be passed a TOP or BOTTOM type, these are filtered out by pre-check. const Type *AndINode::mul_ring( const Type *t0, const Type *t1 ) const { - const TypeInt *r0 = t0->is_int(); // Handy access - const TypeInt *r1 = t1->is_int(); - int widen = MAX2(r0->_widen,r1->_widen); + const TypeInt* r0 = t0->is_int(); + const TypeInt* r1 = t1->is_int(); - // If either input is a constant, might be able to trim cases - if( !r0->is_con() && !r1->is_con() ) - return TypeInt::INT; // No constants to be had - - // Both constants? Return bits - if( r0->is_con() && r1->is_con() ) - return TypeInt::make( r0->get_con() & r1->get_con() ); - - if( r0->is_con() && r0->get_con() > 0 ) - return TypeInt::make(0, r0->get_con(), widen); - - if( r1->is_con() && r1->get_con() > 0 ) - return TypeInt::make(0, r1->get_con(), widen); - - if( r0 == TypeInt::BOOL || r1 == TypeInt::BOOL ) { - return TypeInt::BOOL; - } - - return TypeInt::INT; // No constants to be had + return and_value(r0, r1); } const Type* AndINode::Value(PhaseGVN* phase) const { @@ -751,25 +795,10 @@ Node *AndINode::Ideal(PhaseGVN *phase, bool can_reshape) { // This also type-checks the inputs for sanity. Guaranteed never to // be passed a TOP or BOTTOM type, these are filtered out by pre-check. const Type *AndLNode::mul_ring( const Type *t0, const Type *t1 ) const { - const TypeLong *r0 = t0->is_long(); // Handy access - const TypeLong *r1 = t1->is_long(); - int widen = MAX2(r0->_widen,r1->_widen); + const TypeLong* r0 = t0->is_long(); + const TypeLong* r1 = t1->is_long(); - // If either input is a constant, might be able to trim cases - if( !r0->is_con() && !r1->is_con() ) - return TypeLong::LONG; // No constants to be had - - // Both constants? Return bits - if( r0->is_con() && r1->is_con() ) - return TypeLong::make( r0->get_con() & r1->get_con() ); - - if( r0->is_con() && r0->get_con() > 0 ) - return TypeLong::make(CONST64(0), r0->get_con(), widen); - - if( r1->is_con() && r1->get_con() > 0 ) - return TypeLong::make(CONST64(0), r1->get_con(), widen); - - return TypeLong::LONG; // No constants to be had + return and_value(r0, r1); } const Type* AndLNode::Value(PhaseGVN* phase) const { diff --git a/src/hotspot/share/opto/node.hpp b/src/hotspot/share/opto/node.hpp index bc5842866a1..07a623e2f93 100644 --- a/src/hotspot/share/opto/node.hpp +++ b/src/hotspot/share/opto/node.hpp @@ -2066,4 +2066,36 @@ inline int Op_Cast(BasicType bt) { return Op_CastLL; } +inline int Op_DivIL(BasicType bt, bool is_unsigned) { + assert(bt == T_INT || bt == T_LONG, "only for int or longs"); + if (bt == T_INT) { + if (is_unsigned) { + return Op_UDivI; + } else { + return Op_DivI; + } + } + if (is_unsigned) { + return Op_UDivL; + } else { + return Op_DivL; + } +} + +inline int Op_DivModIL(BasicType bt, bool is_unsigned) { + assert(bt == T_INT || bt == T_LONG, "only for int or longs"); + if (bt == T_INT) { + if (is_unsigned) { + return Op_UDivModI; + } else { + return Op_DivModI; + } + } + if (is_unsigned) { + return Op_UDivModL; + } else { + return Op_DivModL; + } +} + #endif // SHARE_OPTO_NODE_HPP diff --git a/src/hotspot/share/opto/output.cpp b/src/hotspot/share/opto/output.cpp index b3f251bb361..2865cf67429 100644 --- a/src/hotspot/share/opto/output.cpp +++ b/src/hotspot/share/opto/output.cpp @@ -1665,30 +1665,7 @@ void PhaseOutput::fill_buffer(C2_MacroAssembler* masm, uint* blk_starts) { } } } - } -#ifdef ASSERT - // Check that oop-store precedes the card-mark - else if (mach->ideal_Opcode() == Op_StoreCM) { - uint storeCM_idx = j; - int count = 0; - for (uint prec = mach->req(); prec < mach->len(); prec++) { - Node *oop_store = mach->in(prec); // Precedence edge - if (oop_store == nullptr) continue; - count++; - uint i4; - for (i4 = 0; i4 < last_inst; ++i4) { - if (block->get_node(i4) == oop_store) { - break; - } - } - // Note: This test can provide a false failure if other precedence - // edges have been added to the storeCMNode. - assert(i4 == last_inst || i4 < storeCM_idx, "CM card-mark executes before oop-store"); - } - assert(count > 0, "storeCM expects at least one precedence edge"); - } -#endif - else if (!n->is_Proj()) { + } else if (!n->is_Proj()) { // Remember the beginning of the previous instruction, in case // it's followed by a flag-kill and a null-check. Happens on // Intel all the time, with add-to-memory kind of opcodes. @@ -1715,7 +1692,7 @@ void PhaseOutput::fill_buffer(C2_MacroAssembler* masm, uint* blk_starts) { node_offsets[n->_idx] = masm->offset(); } #endif - assert(!C->failing(), "Should not reach here if failing."); + assert(!C->failing_internal() || C->failure_is_artificial(), "Should not reach here if failing."); // "Normal" instruction case DEBUG_ONLY(uint instr_offset = masm->offset()); @@ -2022,6 +1999,8 @@ void PhaseOutput::FillExceptionTables(uint cnt, uint *call_returns, uint *inct_s // Handle implicit null exception table updates if (n->is_MachNullCheck()) { + assert(n->in(1)->as_Mach()->barrier_data() == 0, + "Implicit null checks on memory accesses with barriers are not yet supported"); uint block_num = block->non_connector_successor(0)->_pre_order; _inc_table.append(inct_starts[inct_cnt++], blk_labels[block_num].loc_pos()); continue; @@ -3391,7 +3370,7 @@ uint PhaseOutput::scratch_emit_size(const Node* n) { n->emit(&masm, C->regalloc()); // Emitting into the scratch buffer should not fail - assert (!C->failing(), "Must not have pending failure. Reason is: %s", C->failure_reason()); + assert(!C->failing_internal() || C->failure_is_artificial(), "Must not have pending failure. Reason is: %s", C->failure_reason()); if (is_branch) // Restore label. n->as_MachBranch()->label_set(saveL, save_bnum); diff --git a/src/hotspot/share/opto/parse.hpp b/src/hotspot/share/opto/parse.hpp index a2690aa6704..039283bc863 100644 --- a/src/hotspot/share/opto/parse.hpp +++ b/src/hotspot/share/opto/parse.hpp @@ -426,7 +426,7 @@ class Parse : public GraphKit { void set_parse_bci(int bci); // Must this parse be aborted? - bool failing() { return C->failing(); } + bool failing() const { return C->failing_internal(); } // might have cascading effects, not stressing bailouts for now. Block* rpo_at(int rpo) { assert(0 <= rpo && rpo < _block_count, "oob"); @@ -612,6 +612,11 @@ class Parse : public GraphKit { // Use speculative type to optimize CmpP node Node* optimize_cmp_with_klass(Node* c); + // Stress unstable if traps + void stress_trap(IfNode* orig_iff, Node* counter, Node* incr_store); + // Increment counter used by StressUnstableIfTraps + void increment_trap_stress_counter(Node*& counter, Node*& incr_store); + public: #ifndef PRODUCT // Handle PrintOpto, etc. diff --git a/src/hotspot/share/opto/parse1.cpp b/src/hotspot/share/opto/parse1.cpp index 05627450585..d4a6a9ce5b7 100644 --- a/src/hotspot/share/opto/parse1.cpp +++ b/src/hotspot/share/opto/parse1.cpp @@ -1651,7 +1651,7 @@ void Parse::merge_new_path(int target_bci) { // The ex_oop must be pushed on the stack, unlike throw_to_exit. void Parse::merge_exception(int target_bci) { #ifdef ASSERT - if (target_bci < bci()) { + if (target_bci <= bci()) { C->set_exception_backedge(); } #endif @@ -2123,10 +2123,10 @@ void Parse::call_register_finalizer() { Node* klass_addr = basic_plus_adr( receiver, receiver, oopDesc::klass_offset_in_bytes() ); Node* klass = _gvn.transform(LoadKlassNode::make(_gvn, nullptr, immutable_memory(), klass_addr, TypeInstPtr::KLASS)); - Node* access_flags_addr = basic_plus_adr(klass, klass, in_bytes(Klass::access_flags_offset())); - Node* access_flags = make_load(nullptr, access_flags_addr, TypeInt::INT, T_INT, MemNode::unordered); + Node* access_flags_addr = basic_plus_adr(klass, klass, in_bytes(Klass::misc_flags_offset())); + Node* access_flags = make_load(nullptr, access_flags_addr, TypeInt::UBYTE, T_BOOLEAN, MemNode::unordered); - Node* mask = _gvn.transform(new AndINode(access_flags, intcon(JVM_ACC_HAS_FINALIZER))); + Node* mask = _gvn.transform(new AndINode(access_flags, intcon(KlassFlags::_misc_has_finalizer))); Node* check = _gvn.transform(new CmpINode(mask, intcon(0))); Node* test = _gvn.transform(new BoolNode(check, BoolTest::ne)); diff --git a/src/hotspot/share/opto/parse2.cpp b/src/hotspot/share/opto/parse2.cpp index cbd9323c3a9..6b7cb4eaa99 100644 --- a/src/hotspot/share/opto/parse2.cpp +++ b/src/hotspot/share/opto/parse2.cpp @@ -1371,10 +1371,27 @@ inline int Parse::repush_if_args() { return bc_depth; } +// Used by StressUnstableIfTraps +static volatile int _trap_stress_counter = 0; + +void Parse::increment_trap_stress_counter(Node*& counter, Node*& incr_store) { + Node* counter_addr = makecon(TypeRawPtr::make((address)&_trap_stress_counter)); + counter = make_load(control(), counter_addr, TypeInt::INT, T_INT, Compile::AliasIdxRaw, MemNode::unordered); + counter = _gvn.transform(new AddINode(counter, intcon(1))); + incr_store = store_to_memory(control(), counter_addr, counter, T_INT, Compile::AliasIdxRaw, MemNode::unordered); +} + //----------------------------------do_ifnull---------------------------------- void Parse::do_ifnull(BoolTest::mask btest, Node *c) { int target_bci = iter().get_dest(); + Node* counter = nullptr; + Node* incr_store = nullptr; + bool do_stress_trap = StressUnstableIfTraps && ((C->random() % 2) == 0); + if (do_stress_trap) { + increment_trap_stress_counter(counter, incr_store); + } + Block* branch_block = successor_for_bci(target_bci); Block* next_block = successor_for_bci(iter().next_bci()); @@ -1439,6 +1456,10 @@ void Parse::do_ifnull(BoolTest::mask btest, Node *c) { } else { // Path is live. adjust_map_after_if(BoolTest(btest).negate(), c, 1.0-prob, next_block); } + + if (do_stress_trap) { + stress_trap(iff, counter, incr_store); + } } //------------------------------------do_if------------------------------------ @@ -1468,6 +1489,13 @@ void Parse::do_if(BoolTest::mask btest, Node* c) { return; } + Node* counter = nullptr; + Node* incr_store = nullptr; + bool do_stress_trap = StressUnstableIfTraps && ((C->random() % 2) == 0); + if (do_stress_trap) { + increment_trap_stress_counter(counter, incr_store); + } + // Sanity check the probability value assert(0.0f < prob && prob < 1.0f,"Bad probability in Parser"); @@ -1550,9 +1578,58 @@ void Parse::do_if(BoolTest::mask btest, Node* c) { } else { adjust_map_after_if(untaken_btest, c, untaken_prob, next_block); } + + if (do_stress_trap) { + stress_trap(iff, counter, incr_store); + } +} + +// Force unstable if traps to be taken randomly to trigger intermittent bugs such as incorrect debug information. +// Add another if before the unstable if that checks a "random" condition at runtime (a simple shared counter) and +// then either takes the trap or executes the original, unstable if. +void Parse::stress_trap(IfNode* orig_iff, Node* counter, Node* incr_store) { + // Search for an unstable if trap + CallStaticJavaNode* trap = nullptr; + assert(orig_iff->Opcode() == Op_If && orig_iff->outcnt() == 2, "malformed if"); + ProjNode* trap_proj = orig_iff->uncommon_trap_proj(trap, Deoptimization::Reason_unstable_if); + if (trap == nullptr || !trap->jvms()->should_reexecute()) { + // No suitable trap found. Remove unused counter load and increment. + C->gvn_replace_by(incr_store, incr_store->in(MemNode::Memory)); + return; + } + + // Remove trap from optimization list since we add another path to the trap. + bool success = C->remove_unstable_if_trap(trap, true); + assert(success, "Trap already modified"); + + // Add a check before the original if that will trap with a certain frequency and execute the original if otherwise + int freq_log = (C->random() % 31) + 1; // Random logarithmic frequency in [1, 31] + Node* mask = intcon(right_n_bits(freq_log)); + counter = _gvn.transform(new AndINode(counter, mask)); + Node* cmp = _gvn.transform(new CmpINode(counter, intcon(0))); + Node* bol = _gvn.transform(new BoolNode(cmp, BoolTest::mask::eq)); + IfNode* iff = _gvn.transform(new IfNode(orig_iff->in(0), bol, orig_iff->_prob, orig_iff->_fcnt))->as_If(); + Node* if_true = _gvn.transform(new IfTrueNode(iff)); + Node* if_false = _gvn.transform(new IfFalseNode(iff)); + assert(!if_true->is_top() && !if_false->is_top(), "trap always / never taken"); + + // Trap + assert(trap_proj->outcnt() == 1, "some other nodes are dependent on the trap projection"); + + Node* trap_region = new RegionNode(3); + trap_region->set_req(1, trap_proj); + trap_region->set_req(2, if_true); + trap->set_req(0, _gvn.transform(trap_region)); + + // Don't trap, execute original if + orig_iff->set_req(0, if_false); } bool Parse::path_is_suitable_for_uncommon_trap(float prob) const { + // Randomly skip emitting an uncommon trap + if (StressUnstableIfTraps && ((C->random() % 2) == 0)) { + return false; + } // Don't want to speculate on uncommon traps when running with -Xcomp if (!UseInterpreter) { return false; diff --git a/src/hotspot/share/opto/predicates.cpp b/src/hotspot/share/opto/predicates.cpp index 3887e8a5f6c..18eea3a10bc 100644 --- a/src/hotspot/share/opto/predicates.cpp +++ b/src/hotspot/share/opto/predicates.cpp @@ -73,14 +73,6 @@ ParsePredicateNode* ParsePredicate::init_parse_predicate(Node* parse_predicate_p return nullptr; } -bool ParsePredicate::is_predicate(Node* maybe_success_proj) { - if (!maybe_success_proj->is_IfProj()) { - return false; - } - IfNode* if_node = maybe_success_proj->in(0)->as_If(); - return if_node->is_ParsePredicate(); -} - Deoptimization::DeoptReason RegularPredicateWithUCT::uncommon_trap_reason(IfProjNode* if_proj) { CallStaticJavaNode* uct_call = if_proj->is_uncommon_trap_if_pattern(); if (uct_call == nullptr) { @@ -90,27 +82,31 @@ Deoptimization::DeoptReason RegularPredicateWithUCT::uncommon_trap_reason(IfProj } bool RegularPredicateWithUCT::is_predicate(Node* maybe_success_proj) { - if (may_be_predicate_if(maybe_success_proj)) { - IfProjNode* success_proj = maybe_success_proj->as_IfProj(); - const Deoptimization::DeoptReason deopt_reason = uncommon_trap_reason(success_proj); - return (deopt_reason == Deoptimization::Reason_loop_limit_check || - deopt_reason == Deoptimization::Reason_predicate || - deopt_reason == Deoptimization::Reason_profile_predicate); + if (RegularPredicate::may_be_predicate_if(maybe_success_proj)) { + return has_valid_uncommon_trap(maybe_success_proj); } else { return false; } } -bool RegularPredicateWithUCT::is_predicate(Node* node, Deoptimization::DeoptReason deopt_reason) { - if (may_be_predicate_if(node)) { +bool RegularPredicateWithUCT::has_valid_uncommon_trap(const Node* success_proj) { + assert(RegularPredicate::may_be_predicate_if(success_proj), "must have been checked before"); + const Deoptimization::DeoptReason deopt_reason = uncommon_trap_reason(success_proj->as_IfProj()); + return (deopt_reason == Deoptimization::Reason_loop_limit_check || + deopt_reason == Deoptimization::Reason_predicate || + deopt_reason == Deoptimization::Reason_profile_predicate); +} + +bool RegularPredicateWithUCT::is_predicate(const Node* node, Deoptimization::DeoptReason deopt_reason) { + if (RegularPredicate::may_be_predicate_if(node)) { return deopt_reason == uncommon_trap_reason(node->as_IfProj()); } else { return false; } } -// A Runtime Predicate must have an If or a RangeCheck node, while the If should not be a zero trip guard check. -bool RegularPredicateWithUCT::may_be_predicate_if(Node* node) { +// A Regular Predicate must have an If or a RangeCheck node, while the If should not be a zero trip guard check. +bool RegularPredicate::may_be_predicate_if(const Node* node) { if (node->is_IfProj()) { const IfNode* if_node = node->in(0)->as_If(); const int opcode_if = if_node->Opcode(); @@ -122,39 +118,43 @@ bool RegularPredicateWithUCT::may_be_predicate_if(Node* node) { return false; } -bool RuntimePredicate::is_success_proj(Node* node, Deoptimization::DeoptReason deopt_reason) { +// Runtime Predicates always have an UCT since they could normally fail at runtime. In this case we execute the trap +// on the failing path. +bool RuntimePredicate::is_predicate(Node* node) { + return RegularPredicateWithUCT::is_predicate(node); +} + +bool RuntimePredicate::is_predicate(Node* node, Deoptimization::DeoptReason deopt_reason) { return RegularPredicateWithUCT::is_predicate(node, deopt_reason); } -ParsePredicateIterator::ParsePredicateIterator(const Predicates& predicates) : _current_index(0) { - const PredicateBlock* loop_limit_check_predicate_block = predicates.loop_limit_check_predicate_block(); - if (loop_limit_check_predicate_block->has_parse_predicate()) { - _parse_predicates.push(loop_limit_check_predicate_block->parse_predicate()); +// A Template Assertion Predicate has an If/RangeCheckNode and either an UCT or a halt node depending on where it +// was created. +bool TemplateAssertionPredicate::is_predicate(Node* node) { + if (!RegularPredicate::may_be_predicate_if(node)) { + return false; } - if (UseProfiledLoopPredicate) { - const PredicateBlock* profiled_loop_predicate_block = predicates.profiled_loop_predicate_block(); - if (profiled_loop_predicate_block->has_parse_predicate()) { - _parse_predicates.push(profiled_loop_predicate_block->parse_predicate()); - } - } - if (UseLoopPredicate) { - const PredicateBlock* loop_predicate_block = predicates.loop_predicate_block(); - if (loop_predicate_block->has_parse_predicate()) { - _parse_predicates.push(loop_predicate_block->parse_predicate()); - } + IfNode* if_node = node->in(0)->as_If(); + if (if_node->in(1)->is_Opaque4()) { + return RegularPredicateWithUCT::has_valid_uncommon_trap(node) || AssertionPredicateWithHalt::has_halt(node); } + return false; } -ParsePredicateNode* ParsePredicateIterator::next() { - assert(has_next(), "always check has_next() first"); - return _parse_predicates.at(_current_index++); +// Initialized Assertion Predicates always have the dedicated opaque node and a halt node. +bool InitializedAssertionPredicate::is_predicate(Node* node) { + if (!AssertionPredicateWithHalt::is_predicate(node)) { + return false; + } + IfNode* if_node = node->in(0)->as_If(); + return if_node->in(1)->is_OpaqueInitializedAssertionPredicate(); } #ifdef ASSERT // Check that the block has at most one Parse Predicate and that we only find Regular Predicate nodes (i.e. IfProj, // If, or RangeCheck nodes). -void PredicateBlock::verify_block() { - Node* next = _parse_predicate.entry(); // Skip unique Parse Predicate of this block if present +void RegularPredicateBlock::verify_block(Node* tail) { + Node* next = tail; while (next != _entry) { assert(!next->is_ParsePredicate(), "can only have one Parse Predicate in a block"); const int opcode = next->Opcode(); @@ -166,17 +166,6 @@ void PredicateBlock::verify_block() { } #endif // ASSERT -// Walk over all Regular Predicates of this block (if any) and return the first node not belonging to the block -// anymore (i.e. entry to the first Regular Predicate in this block if any or `regular_predicate_proj` otherwise). -Node* PredicateBlock::skip_regular_predicates(Node* regular_predicate_proj, Deoptimization::DeoptReason deopt_reason) { - Node* entry = regular_predicate_proj; - while (RuntimePredicate::is_success_proj(entry, deopt_reason)) { - assert(entry->in(0)->as_If(), "must be If node"); - entry = entry->in(0)->in(0); - } - return entry; -} - // This strategy clones the OpaqueLoopInit and OpaqueLoopStride nodes. class CloneStrategy : public TransformStrategyForOpaqueLoopNodes { PhaseIdealLoop* const _phase; @@ -381,8 +370,8 @@ bool TemplateAssertionExpressionNode::is_template_assertion_predicate(Node* node return node->is_If() && node->in(1)->is_Opaque4(); } -InitializedAssertionPredicate::InitializedAssertionPredicate(IfNode* template_assertion_predicate, Node* new_init, - Node* new_stride, PhaseIdealLoop* phase) +InitializedAssertionPredicateCreator::InitializedAssertionPredicateCreator(IfNode* template_assertion_predicate, Node* new_init, + Node* new_stride, PhaseIdealLoop* phase) : _template_assertion_predicate(template_assertion_predicate), _new_init(new_init), _new_stride(new_stride), @@ -408,7 +397,7 @@ InitializedAssertionPredicate::InitializedAssertionPredicate(IfNode* template_as // success fail path new success new Halt // proj (Halt or UCT) proj // -IfTrueNode* InitializedAssertionPredicate::create(Node* control) { +IfTrueNode* InitializedAssertionPredicateCreator::create(Node* control) { IdealLoopTree* loop = _phase->get_loop(control); OpaqueInitializedAssertionPredicateNode* assertion_expression = create_assertion_expression(control); IfNode* if_node = create_if_node(control, assertion_expression, loop); @@ -417,7 +406,7 @@ IfTrueNode* InitializedAssertionPredicate::create(Node* control) { } // Create a new Assertion Expression to be used as bool input for the Initialized Assertion Predicate IfNode. -OpaqueInitializedAssertionPredicateNode* InitializedAssertionPredicate::create_assertion_expression(Node* control) { +OpaqueInitializedAssertionPredicateNode* InitializedAssertionPredicateCreator::create_assertion_expression(Node* control) { Opaque4Node* template_opaque = _template_assertion_predicate->in(1)->as_Opaque4(); TemplateAssertionExpression template_assertion_expression(template_opaque); Opaque4Node* tmp_opaque = template_assertion_expression.clone_and_replace_init_and_stride(_new_init, _new_stride, @@ -428,9 +417,9 @@ OpaqueInitializedAssertionPredicateNode* InitializedAssertionPredicate::create_a return assertion_expression; } -IfNode* InitializedAssertionPredicate::create_if_node(Node* control, - OpaqueInitializedAssertionPredicateNode* assertion_expression, - IdealLoopTree* loop) { +IfNode* InitializedAssertionPredicateCreator::create_if_node(Node* control, + OpaqueInitializedAssertionPredicateNode* assertion_expression, + IdealLoopTree* loop) { const int if_opcode = _template_assertion_predicate->Opcode(); NOT_PRODUCT(const AssertionPredicateType assertion_predicate_type = _template_assertion_predicate->assertion_predicate_type();) IfNode* if_node = if_opcode == Op_If ? @@ -440,19 +429,19 @@ IfNode* InitializedAssertionPredicate::create_if_node(Node* control, return if_node; } -IfTrueNode* InitializedAssertionPredicate::create_success_path(IfNode* if_node, IdealLoopTree* loop) { +IfTrueNode* InitializedAssertionPredicateCreator::create_success_path(IfNode* if_node, IdealLoopTree* loop) { IfTrueNode* success_proj = new IfTrueNode(if_node); _phase->register_control(success_proj, loop, if_node); return success_proj; } -void InitializedAssertionPredicate::create_fail_path(IfNode* if_node, IdealLoopTree* loop) { +void InitializedAssertionPredicateCreator::create_fail_path(IfNode* if_node, IdealLoopTree* loop) { IfFalseNode* fail_proj = new IfFalseNode(if_node); _phase->register_control(fail_proj, loop, if_node); create_halt_node(fail_proj, loop); } -void InitializedAssertionPredicate::create_halt_node(IfFalseNode* fail_proj, IdealLoopTree* loop) { +void InitializedAssertionPredicateCreator::create_halt_node(IfFalseNode* fail_proj, IdealLoopTree* loop) { StartNode* start_node = _phase->C->start(); Node* frame = new ParmNode(start_node, TypeFunc::FramePtr); _phase->register_new_node(frame, start_node); @@ -461,17 +450,45 @@ void InitializedAssertionPredicate::create_halt_node(IfFalseNode* fail_proj, Ide _phase->register_control(halt, loop, fail_proj); } -// Is current node pointed to by iterator a predicate? -bool PredicateEntryIterator::has_next() const { - return ParsePredicate::is_predicate(_current) || - RegularPredicateWithUCT::is_predicate(_current) || - AssertionPredicateWithHalt::is_predicate(_current); +#ifndef PRODUCT +void PredicateBlock::dump() const { + dump(""); } -// Skip the current predicate pointed to by iterator by returning the input into the predicate. This could possibly be -// a non-predicate node. -Node* PredicateEntryIterator::next_entry() { - assert(has_next(), "current must be predicate"); - _current = _current->in(0)->in(0); - return _current; +void PredicateBlock::dump(const char* prefix) const { + if (is_non_empty()) { + PredicatePrinter printer(prefix); + PredicateBlockIterator iterator(_tail, _deopt_reason); + iterator.for_each(printer); + } else { + tty->print_cr("%s- ", prefix); + } } + +// Dumps all predicates from the loop to the earliest predicate in a pretty format. +void Predicates::dump() const { + if (has_any()) { + Node* loop_head = _tail->unique_ctrl_out(); + tty->print_cr("%d %s:", loop_head->_idx, loop_head->Name()); + tty->print_cr("- Loop Limit Check Predicate Block:"); + _loop_limit_check_predicate_block.dump(" "); + tty->print_cr("- Profiled Loop Predicate Block:"); + _profiled_loop_predicate_block.dump(" "); + tty->print_cr("- Loop Predicate Block:"); + _loop_predicate_block.dump(" "); + tty->cr(); + } else { + tty->print_cr(""); + } +} + +void Predicates::dump_at(Node* node) { + Predicates predicates(node); + predicates.dump(); +} + +// Debug method to dump all predicates that are found above 'loop_node'. +void Predicates::dump_for_loop(LoopNode* loop_node) { + dump_at(loop_node->skip_strip_mined()->in(LoopNode::EntryControl)); +} +#endif // NOT PRODUCT diff --git a/src/hotspot/share/opto/predicates.hpp b/src/hotspot/share/opto/predicates.hpp index 96f5c438b80..b38b888cc3d 100644 --- a/src/hotspot/share/opto/predicates.hpp +++ b/src/hotspot/share/opto/predicates.hpp @@ -30,6 +30,11 @@ #include "opto/opaquenode.hpp" class IdealLoopTree; +class InitializedAssertionPredicate; +class ParsePredicate; +class PredicateVisitor; +class RuntimePredicate; +class TemplateAssertionPredicate; /* * There are different kinds of predicates throughout the code. We differentiate between the following predicates: @@ -152,7 +157,8 @@ class IdealLoopTree; * together. * - Loop Limit Check Groups the Loop Limit Check Predicate (if created) and the Loop Limit * Predicate Block: Check Parse Predicate (if not removed, yet) together. - * + * - Regular Predicate Block: A block that only contains the Regular Predicates of a Predicate Block without the + * Parse Predicate. * * Initially, before applying any loop-splitting optimizations, we find the following structure after Loop Predication * (predicates inside square brackets [] do not need to exist if there are no checks to hoist): @@ -205,6 +211,41 @@ enum class AssertionPredicateType { }; #endif // NOT PRODUCT +// Interface to represent a C2 predicate. A predicate is always represented by two CFG nodes: +// - An If node (head) +// - An IfProj node representing the success projection of the If node (tail). +class Predicate : public StackObj { + public: + // Return the unique entry CFG node into the predicate. + virtual Node* entry() const = 0; + + // Return the head node of the predicate which is either: + // - A ParsePredicateNode if the predicate is a Parse Predicate + // - An IfNode or RangeCheckNode, otherwise. + virtual IfNode* head() const = 0; + + // Return the tail node of the predicate. Runtime Predicates can either have a true of false projection as success + // projection while Parse Predicates and Assertion Predicates always have a true projection as success projection. + virtual IfProjNode* tail() const = 0; +}; + +// Generic predicate visitor that does nothing. Subclass this visitor to add customized actions for each predicate. +// The visit methods of this visitor are called from the predicate iterator classes which walk the predicate chain. +// Use the UnifiedPredicateVisitor if the type of the predicate does not matter. +class PredicateVisitor : StackObj { + public: + virtual void visit(const ParsePredicate& parse_predicate) {} + virtual void visit(const RuntimePredicate& runtime_predicate) {} + virtual void visit(const TemplateAssertionPredicate& template_assertion_predicate) {} + virtual void visit(const InitializedAssertionPredicate& initialized_assertion_predicate) {} + + // This method can be overridden to stop the predicate iterators from visiting more predicates further up in the + // predicate chain. + virtual bool should_continue() const { + return true; + } +}; + // Class to represent Assertion Predicates with a HaltNode instead of an UCT (i.e. either an Initialized Assertion // Predicate or a Template Assertion Predicate created after the initial one at Loop Predication). class AssertionPredicatesWithHalt : public StackObj { @@ -228,9 +269,15 @@ class AssertionPredicatesWithHalt : public StackObj { // Note that all other Regular Predicates have an UCT node. class AssertionPredicateWithHalt : public StackObj { static bool has_assertion_predicate_opaque(const Node* predicate_proj); - static bool has_halt(const Node* success_proj); public: static bool is_predicate(const Node* maybe_success_proj); + static bool has_halt(const Node* success_proj); +}; + +// Utility class representing a Regular Predicate which is either a Runtime Predicate or an Assertion Predicate. +class RegularPredicate : public StackObj { + public: + static bool may_be_predicate_if(const Node* node); }; // Class to represent a single Regular Predicate with an UCT. This could either be: @@ -239,15 +286,15 @@ class AssertionPredicateWithHalt : public StackObj { // Note that all other Regular Predicates have a Halt node. class RegularPredicateWithUCT : public StackObj { static Deoptimization::DeoptReason uncommon_trap_reason(IfProjNode* if_proj); - static bool may_be_predicate_if(Node* node); public: static bool is_predicate(Node* maybe_success_proj); - static bool is_predicate(Node* node, Deoptimization::DeoptReason deopt_reason); + static bool is_predicate(const Node* node, Deoptimization::DeoptReason deopt_reason); + static bool has_valid_uncommon_trap(const Node* success_proj); }; // Class to represent a Parse Predicate. -class ParsePredicate : public StackObj { +class ParsePredicate : public Predicate { ParsePredicateSuccessProj* _success_proj; ParsePredicateNode* _parse_predicate_node; Node* _entry; @@ -267,7 +314,7 @@ class ParsePredicate : public StackObj { // Returns the control input node into this Parse Predicate if it is valid. Otherwise, it returns the passed node // into the constructor of this class. - Node* entry() const { + Node* entry() const override { return _entry; } @@ -277,23 +324,102 @@ class ParsePredicate : public StackObj { return _parse_predicate_node != nullptr; } - ParsePredicateNode* node() const { + ParsePredicateNode* head() const override { assert(is_valid(), "must be valid"); return _parse_predicate_node; } - ParsePredicateSuccessProj* success_proj() const { + ParsePredicateSuccessProj* tail() const override { assert(is_valid(), "must be valid"); return _success_proj; } - - static bool is_predicate(Node* maybe_success_proj); }; -// Utility class for queries on Runtime Predicates. -class RuntimePredicate : public StackObj { +// Class to represent a Runtime Predicate which always has an associated UCT on the failing path. +class RuntimePredicate : public Predicate { + IfProjNode* _success_proj; + IfNode* _if_node; + public: - static bool is_success_proj(Node* node, Deoptimization::DeoptReason deopt_reason); + explicit RuntimePredicate(IfProjNode* success_proj) + : _success_proj(success_proj), + _if_node(success_proj->in(0)->as_If()) { + assert(is_predicate(success_proj), "must be valid"); + } + NONCOPYABLE(RuntimePredicate); + + private: + static bool is_predicate(Node* maybe_success_proj); + + public: + Node* entry() const override { + return _if_node->in(0); + } + + IfNode* head() const override { + return _if_node; + } + + IfProjNode* tail() const override { + return _success_proj; + } + + static bool is_predicate(Node* node, Deoptimization::DeoptReason deopt_reason); +}; + +// Class to represent a Template Assertion Predicate. +class TemplateAssertionPredicate : public Predicate { + IfTrueNode* _success_proj; + IfNode* _if_node; + + public: + explicit TemplateAssertionPredicate(IfTrueNode* success_proj) + : _success_proj(success_proj), + _if_node(success_proj->in(0)->as_If()) { + assert(is_predicate(success_proj), "must be valid"); + } + + Node* entry() const override { + return _if_node->in(0); + } + + IfNode* head() const override { + return _if_node; + } + + IfTrueNode* tail() const override { + return _success_proj; + } + + static bool is_predicate(Node* node); +}; + +// Class to represent an Initialized Assertion Predicate which always has a halt node on the failing path. +// This predicate should never fail at runtime by design. +class InitializedAssertionPredicate : public Predicate { + IfTrueNode* _success_proj; + IfNode* _if_node; + + public: + explicit InitializedAssertionPredicate(IfTrueNode* success_proj) + : _success_proj(success_proj), + _if_node(success_proj->in(0)->as_If()) { + assert(is_predicate(success_proj), "must be valid"); + } + + Node* entry() const override { + return _if_node->in(0); + } + + IfNode* head() const override { + return _if_node; + } + + IfTrueNode* tail() const override { + return _success_proj; + } + + static bool is_predicate(Node* node); }; // Interface to transform OpaqueLoopInit and OpaqueLoopStride nodes of a Template Assertion Expression. @@ -395,16 +521,16 @@ class TemplateAssertionExpressionNode : public StackObj { }; // This class creates a new Initialized Assertion Predicate. -class InitializedAssertionPredicate : public StackObj { +class InitializedAssertionPredicateCreator : public StackObj { IfNode* const _template_assertion_predicate; Node* const _new_init; Node* const _new_stride; PhaseIdealLoop* const _phase; public: - InitializedAssertionPredicate(IfNode* template_assertion_predicate, Node* new_init, Node* new_stride, - PhaseIdealLoop* phase); - NONCOPYABLE(InitializedAssertionPredicate); + InitializedAssertionPredicateCreator(IfNode* template_assertion_predicate, Node* new_init, Node* new_stride, + PhaseIdealLoop* phase); + NONCOPYABLE(InitializedAssertionPredicateCreator); IfTrueNode* create(Node* control); @@ -416,23 +542,208 @@ class InitializedAssertionPredicate : public StackObj { IfTrueNode* create_success_path(IfNode* if_node, IdealLoopTree* loop); }; +// This class iterates through all predicates of a Regular Predicate Block and applies the given visitor to each. +class RegularPredicateBlockIterator : public StackObj { + Node* const _start_node; + const Deoptimization::DeoptReason _deopt_reason; + + public: + RegularPredicateBlockIterator(Node* start_node, Deoptimization::DeoptReason deopt_reason) + : _start_node(start_node), + _deopt_reason(deopt_reason) {} + NONCOPYABLE(RegularPredicateBlockIterator); + + // Skip all predicates by just following the inputs. We do not call any user provided visitor. + Node* skip_all() const { + PredicateVisitor do_nothing; // No real visits, just do nothing. + return for_each(do_nothing); + } + + // Walk over all predicates of this block (if any) and apply the given 'predicate_visitor' to each predicate. + // Returns the entry to the earliest predicate. + Node* for_each(PredicateVisitor& predicate_visitor) const { + Node* current = _start_node; + while (predicate_visitor.should_continue()) { + if (TemplateAssertionPredicate::is_predicate(current)) { + TemplateAssertionPredicate template_assertion_predicate(current->as_IfTrue()); + predicate_visitor.visit(template_assertion_predicate); + current = template_assertion_predicate.entry(); + } else if (RuntimePredicate::is_predicate(current, _deopt_reason)) { + RuntimePredicate runtime_predicate(current->as_IfProj()); + predicate_visitor.visit(runtime_predicate); + current = runtime_predicate.entry(); + } else if (InitializedAssertionPredicate::is_predicate(current)) { + InitializedAssertionPredicate initialized_assertion_predicate(current->as_IfTrue()); + predicate_visitor.visit(initialized_assertion_predicate); + current = initialized_assertion_predicate.entry(); + } else { + // Either a Parse Predicate or not a Regular Predicate. In both cases, the node does not belong to this block. + break; + } + } + return current; + } +}; + +// This class iterates through all predicates of a Predicate Block and applies the given visitor to each. +class PredicateBlockIterator : public StackObj { + Node* const _start_node; + const ParsePredicate _parse_predicate; // Could be missing. + const RegularPredicateBlockIterator _regular_predicate_block_iterator; + + public: + PredicateBlockIterator(Node* start_node, Deoptimization::DeoptReason deopt_reason) + : _start_node(start_node), + _parse_predicate(start_node, deopt_reason), + _regular_predicate_block_iterator(_parse_predicate.entry(), deopt_reason) {} + + // Walk over all predicates of this block (if any) and apply the given 'predicate_visitor' to each predicate. + // Returns the entry to the earliest predicate. + Node* for_each(PredicateVisitor& predicate_visitor) const { + if (!predicate_visitor.should_continue()) { + return _start_node; + } + if (_parse_predicate.is_valid()) { + predicate_visitor.visit(_parse_predicate); + } + return _regular_predicate_block_iterator.for_each(predicate_visitor); + } +}; + +// Class to walk over all predicates starting at a node, which usually is the loop entry node, and following the inputs. +// At each predicate, a PredicateVisitor is applied which the user can implement freely. +class PredicateIterator : public StackObj { + Node* _start_node; + + public: + explicit PredicateIterator(Node* start_node) + : _start_node(start_node) {} + NONCOPYABLE(PredicateIterator); + + // Apply the 'predicate_visitor' for each predicate found in the predicate chain started at the provided node. + // Returns the entry to the earliest predicate. + Node* for_each(PredicateVisitor& predicate_visitor) const { + Node* current = _start_node; + PredicateBlockIterator loop_limit_check_predicate_iterator(current, Deoptimization::Reason_loop_limit_check); + current = loop_limit_check_predicate_iterator.for_each(predicate_visitor); + PredicateBlockIterator profiled_loop_predicate_iterator(current, Deoptimization::Reason_profile_predicate); + current = profiled_loop_predicate_iterator.for_each(predicate_visitor); + PredicateBlockIterator loop_predicate_iterator(current, Deoptimization::Reason_predicate); + return loop_predicate_iterator.for_each(predicate_visitor); + } +}; + +// Unified PredicateVisitor which only provides a single visit method for a generic Predicate. This visitor can be used +// when it does not matter what kind of predicate is visited. Note that we override all normal visit methods from +// PredicateVisitor by calling the unified method. These visit methods are marked final such that they cannot be +// overridden by implementors of this class. +class UnifiedPredicateVisitor : public PredicateVisitor { + public: + virtual void visit(const TemplateAssertionPredicate& template_assertion_predicate) override final { + visit_predicate(template_assertion_predicate); + } + + virtual void visit(const ParsePredicate& parse_predicate) override final { + visit_predicate(parse_predicate); + } + + virtual void visit(const RuntimePredicate& runtime_predicate) override final { + visit_predicate(runtime_predicate); + } + + virtual void visit(const InitializedAssertionPredicate& initialized_assertion_predicate) override final { + visit_predicate(initialized_assertion_predicate); + } + + virtual void visit_predicate(const Predicate& predicate) = 0; +}; + +// A block of Regular Predicates inside a Predicate Block without its Parse Predicate. +class RegularPredicateBlock : public StackObj { + const Deoptimization::DeoptReason _deopt_reason; + Node* const _entry; + + public: + RegularPredicateBlock(Node* tail, Deoptimization::DeoptReason deopt_reason) + : _deopt_reason(deopt_reason), + _entry(skip_all(tail)) { + DEBUG_ONLY(verify_block(tail);) + } + NONCOPYABLE(RegularPredicateBlock); + + private: + // Walk over all Regular Predicates of this block (if any) and return the first node not belonging to the block + // anymore (i.e. entry to the first Regular Predicate in this block if any or `tail` otherwise). + Node* skip_all(Node* tail) const { + RegularPredicateBlockIterator iterator(tail, _deopt_reason); + return iterator.skip_all(); + } + + DEBUG_ONLY(void verify_block(Node* tail);) + + public: + Node* entry() const { + return _entry; + } +}; + +#ifndef PRODUCT +// Visitor class to print all the visited predicates. Used by the Predicates class which does the printing starting +// at the loop node and then following the inputs to the earliest predicate. +class PredicatePrinter : public PredicateVisitor { + const char* _prefix; // Prefix added to each dumped string. + + public: + explicit PredicatePrinter(const char* prefix) : _prefix(prefix) {} + NONCOPYABLE(PredicatePrinter); + + void visit(const ParsePredicate& parse_predicate) override { + print_predicate_node("Parse Predicate", parse_predicate); + } + + void visit(const RuntimePredicate& runtime_predicate) override { + print_predicate_node("Runtime Predicate", runtime_predicate); + } + + void visit(const TemplateAssertionPredicate& template_assertion_predicate) override { + print_predicate_node("Template Assertion Predicate", template_assertion_predicate); + } + + void visit(const InitializedAssertionPredicate& initialized_assertion_predicate) override { + print_predicate_node("Initialized Assertion Predicate", initialized_assertion_predicate); + } + + private: + void print_predicate_node(const char* predicate_name, const Predicate& predicate) const { + tty->print_cr("%s- %s: %d %s", _prefix, predicate_name, predicate.head()->_idx, predicate.head()->Name()); + } +}; +#endif // NOT PRODUCT // This class represents a Predicate Block (i.e. either a Loop Predicate Block, a Profiled Loop Predicate Block, // or a Loop Limit Check Predicate Block). It contains zero or more Regular Predicates followed by a Parse Predicate // which, however, does not need to exist (we could already have decided to remove Parse Predicates for this loop). class PredicateBlock : public StackObj { - ParsePredicate _parse_predicate; // Could be missing. - Node* _entry; - - static Node* skip_regular_predicates(Node* regular_predicate_proj, Deoptimization::DeoptReason deopt_reason); - DEBUG_ONLY(void verify_block();) + const ParsePredicate _parse_predicate; // Could be missing. + const RegularPredicateBlock _regular_predicate_block; + Node* const _entry; +#ifndef PRODUCT + // Used for dumping. + Node* const _tail; + const Deoptimization::DeoptReason _deopt_reason; +#endif // NOT PRODUCT public: - PredicateBlock(Node* predicate_proj, Deoptimization::DeoptReason deopt_reason) - : _parse_predicate(predicate_proj, deopt_reason), - _entry(skip_regular_predicates(_parse_predicate.entry(), deopt_reason)) { - DEBUG_ONLY(verify_block();) - } + PredicateBlock(Node* tail, Deoptimization::DeoptReason deopt_reason) + : _parse_predicate(tail, deopt_reason), + _regular_predicate_block(_parse_predicate.entry(), deopt_reason), + _entry(_regular_predicate_block.entry()) +#ifndef PRODUCT + , _tail(tail) + , _deopt_reason(deopt_reason) +#endif // NOT PRODUCT + {} + NONCOPYABLE(PredicateBlock); // Returns the control input node into this Regular Predicate block. This is either: // - The control input to the first If node in the block representing a Runtime Predicate if there is at least one @@ -453,11 +764,11 @@ class PredicateBlock : public StackObj { } ParsePredicateNode* parse_predicate() const { - return _parse_predicate.node(); + return _parse_predicate.head(); } ParsePredicateSuccessProj* parse_predicate_success_proj() const { - return _parse_predicate.success_proj(); + return _parse_predicate.tail(); } bool has_runtime_predicates() const { @@ -471,25 +782,31 @@ class PredicateBlock : public StackObj { Node* skip_parse_predicate() const { return _parse_predicate.entry(); } + +#ifndef PRODUCT + void dump() const; + void dump(const char* prefix) const; +#endif // NOT PRODUCT }; // This class takes a loop entry node and finds all the available predicates for the loop. class Predicates : public StackObj { - Node* _loop_entry; - PredicateBlock _loop_limit_check_predicate_block; - PredicateBlock _profiled_loop_predicate_block; - PredicateBlock _loop_predicate_block; - Node* _entry; + Node* const _tail; + const PredicateBlock _loop_limit_check_predicate_block; + const PredicateBlock _profiled_loop_predicate_block; + const PredicateBlock _loop_predicate_block; + Node* const _entry; public: - Predicates(Node* loop_entry) - : _loop_entry(loop_entry), + explicit Predicates(Node* loop_entry) + : _tail(loop_entry), _loop_limit_check_predicate_block(loop_entry, Deoptimization::Reason_loop_limit_check), _profiled_loop_predicate_block(_loop_limit_check_predicate_block.entry(), Deoptimization::Reason_profile_predicate), _loop_predicate_block(_profiled_loop_predicate_block.entry(), Deoptimization::Reason_predicate), _entry(_loop_predicate_block.entry()) {} + NONCOPYABLE(Predicates); // Returns the control input the first predicate if there are any predicates. If there are no predicates, the same // node initially passed to the constructor is returned. @@ -510,35 +827,17 @@ class Predicates : public StackObj { } bool has_any() const { - return _entry != _loop_entry; - } -}; - -// This class iterates over the Parse Predicates of a loop. -class ParsePredicateIterator : public StackObj { - GrowableArray _parse_predicates; - int _current_index; - - public: - ParsePredicateIterator(const Predicates& predicates); - - bool has_next() const { - return _current_index < _parse_predicates.length(); + return _entry != _tail; } - ParsePredicateNode* next(); +#ifndef PRODUCT + /* + * Debug printing functions. + */ + void dump() const; + static void dump_at(Node* node); + static void dump_for_loop(LoopNode* loop_node); +#endif // NOT PRODUCT }; -// Special predicate iterator that can be used to walk through predicate entries, regardless of whether the predicate -// belongs to the same loop or not (i.e. leftovers from already folded nodes). The iterator returns the next entry -// to a predicate. -class PredicateEntryIterator : public StackObj { - Node* _current; - - public: - explicit PredicateEntryIterator(Node* start) : _current(start) {}; - - bool has_next() const; - Node* next_entry(); -}; #endif // SHARE_OPTO_PREDICATES_HPP diff --git a/src/hotspot/share/opto/reg_split.cpp b/src/hotspot/share/opto/reg_split.cpp index 9f89c683b34..6d948aff011 100644 --- a/src/hotspot/share/opto/reg_split.cpp +++ b/src/hotspot/share/opto/reg_split.cpp @@ -306,8 +306,8 @@ static Node* clone_node(Node* def, Block *b, Compile* C) { C->record_failure(C2Compiler::retry_no_subsuming_loads()); } else { // Bailout without retry - assert(false, "RA Split failed: attempt to clone node with anti_dependence"); - C->record_method_not_compilable("RA Split failed: attempt to clone node with anti_dependence"); + assert(C->failure_is_artificial(), "RA Split failed: attempt to clone node with anti_dependence"); + C->record_method_not_compilable("RA Split failed: attempt to clone node with anti_dependence" DEBUG_ONLY(COMMA true)); } return nullptr; } diff --git a/src/hotspot/share/opto/runtime.cpp b/src/hotspot/share/opto/runtime.cpp index 54408146d0c..3dd94f619fd 100644 --- a/src/hotspot/share/opto/runtime.cpp +++ b/src/hotspot/share/opto/runtime.cpp @@ -88,34 +88,27 @@ // At command line specify the parameters: -XX:+FullGCALot -XX:FullGCALotStart=100000000 +#define C2_BLOB_FIELD_DEFINE(name, type) \ + type OptoRuntime:: BLOB_FIELD_NAME(name) = nullptr; +#define C2_STUB_FIELD_NAME(name) _ ## name ## _Java +#define C2_STUB_FIELD_DEFINE(name, f, t, r) \ + address OptoRuntime:: C2_STUB_FIELD_NAME(name) = nullptr; +#define C2_JVMTI_STUB_FIELD_DEFINE(name) \ + address OptoRuntime:: STUB_FIELD_NAME(name) = nullptr; +C2_STUBS_DO(C2_BLOB_FIELD_DEFINE, C2_STUB_FIELD_DEFINE, C2_JVMTI_STUB_FIELD_DEFINE) +#undef C2_BLOB_FIELD_DEFINE +#undef C2_STUB_FIELD_DEFINE +#undef C2_JVMTI_STUB_FIELD_DEFINE - -// Compiled code entry points -address OptoRuntime::_new_instance_Java = nullptr; -address OptoRuntime::_new_array_Java = nullptr; -address OptoRuntime::_new_array_nozero_Java = nullptr; -address OptoRuntime::_multianewarray2_Java = nullptr; -address OptoRuntime::_multianewarray3_Java = nullptr; -address OptoRuntime::_multianewarray4_Java = nullptr; -address OptoRuntime::_multianewarray5_Java = nullptr; -address OptoRuntime::_multianewarrayN_Java = nullptr; -address OptoRuntime::_vtable_must_compile_Java = nullptr; -address OptoRuntime::_complete_monitor_locking_Java = nullptr; -address OptoRuntime::_monitor_notify_Java = nullptr; -address OptoRuntime::_monitor_notifyAll_Java = nullptr; -address OptoRuntime::_rethrow_Java = nullptr; - -address OptoRuntime::_slow_arraycopy_Java = nullptr; -address OptoRuntime::_register_finalizer_Java = nullptr; -#if INCLUDE_JVMTI -address OptoRuntime::_notify_jvmti_vthread_start = nullptr; -address OptoRuntime::_notify_jvmti_vthread_end = nullptr; -address OptoRuntime::_notify_jvmti_vthread_mount = nullptr; -address OptoRuntime::_notify_jvmti_vthread_unmount = nullptr; -#endif - -UncommonTrapBlob* OptoRuntime::_uncommon_trap_blob; -ExceptionBlob* OptoRuntime::_exception_blob; +#define C2_BLOB_NAME_DEFINE(name, type) "C2 Runtime " # name "_blob", +#define C2_STUB_NAME_DEFINE(name, f, t, r) "C2 Runtime " # name, +#define C2_JVMTI_STUB_NAME_DEFINE(name) "C2 Runtime " # name, +const char* OptoRuntime::_stub_names[] = { + C2_STUBS_DO(C2_BLOB_NAME_DEFINE, C2_STUB_NAME_DEFINE, C2_JVMTI_STUB_NAME_DEFINE) +}; +#undef C2_BLOB_NAME_DEFINE +#undef C2_STUB_NAME_DEFINE +#undef C2_JVMTI_STUB_NAME_DEFINE // This should be called in an assertion at the start of OptoRuntime routines // which are entered from compiled code (all of them) @@ -132,46 +125,72 @@ static bool check_compiled_frame(JavaThread* thread) { } #endif // ASSERT - +/* #define gen(env, var, type_func_gen, c_func, fancy_jump, pass_tls, return_pc) \ var = generate_stub(env, type_func_gen, CAST_FROM_FN_PTR(address, c_func), #var, fancy_jump, pass_tls, return_pc); \ if (var == nullptr) { return false; } +*/ + +#define GEN_C2_BLOB(name, type) \ + generate_ ## name ## _blob(); + +// a few helper macros to conjure up generate_stub call arguments +#define C2_STUB_FIELD_NAME(name) _ ## name ## _Java +#define C2_STUB_TYPEFUNC(name) name ## _Type +#define C2_STUB_C_FUNC(name) CAST_FROM_FN_PTR(address, name ## _C) +#define C2_STUB_NAME(name) stub_name(OptoStubId::name ## _id) + +// Almost all the C functions targeted from the generated stubs are +// implemented locally to OptoRuntime with names that can be generated +// from the stub name by appending suffix '_C'. However, in two cases +// a common target method also needs to be called from shared runtime +// stubs. In these two cases the opto stubs rely on method +// imlementations defined in class SharedRuntime. The following +// defines temporarily rebind the generated names to reference the +// relevant implementations. + +#define GEN_C2_STUB(name, fancy_jump, pass_tls, pass_retpc ) \ + C2_STUB_FIELD_NAME(name) = \ + generate_stub(env, \ + C2_STUB_TYPEFUNC(name), \ + C2_STUB_C_FUNC(name), \ + C2_STUB_NAME(name), \ + fancy_jump, \ + pass_tls, \ + pass_retpc); \ + if (C2_STUB_FIELD_NAME(name) == nullptr) { return false; } \ + +#define C2_JVMTI_STUB_C_FUNC(name) CAST_FROM_FN_PTR(address, SharedRuntime::name) + +#define GEN_C2_JVMTI_STUB(name) \ + STUB_FIELD_NAME(name) = \ + generate_stub(env, \ + notify_jvmti_vthread_Type, \ + C2_JVMTI_STUB_C_FUNC(name), \ + C2_STUB_NAME(name), \ + 0, \ + true, \ + false); \ + if (STUB_FIELD_NAME(name) == nullptr) { return false; } \ bool OptoRuntime::generate(ciEnv* env) { - generate_uncommon_trap_blob(); - generate_exception_blob(); - - // Note: tls: Means fetching the return oop out of the thread-local storage - // - // variable/name type-function-gen , runtime method ,fncy_jp, tls,retpc - // ------------------------------------------------------------------------------------------------------------------------------- - gen(env, _new_instance_Java , new_instance_Type , new_instance_C , 0 , true, false); - gen(env, _new_array_Java , new_array_Type , new_array_C , 0 , true, false); - gen(env, _new_array_nozero_Java , new_array_Type , new_array_nozero_C , 0 , true, false); - gen(env, _multianewarray2_Java , multianewarray2_Type , multianewarray2_C , 0 , true, false); - gen(env, _multianewarray3_Java , multianewarray3_Type , multianewarray3_C , 0 , true, false); - gen(env, _multianewarray4_Java , multianewarray4_Type , multianewarray4_C , 0 , true, false); - gen(env, _multianewarray5_Java , multianewarray5_Type , multianewarray5_C , 0 , true, false); - gen(env, _multianewarrayN_Java , multianewarrayN_Type , multianewarrayN_C , 0 , true, false); -#if INCLUDE_JVMTI - gen(env, _notify_jvmti_vthread_start , notify_jvmti_vthread_Type , SharedRuntime::notify_jvmti_vthread_start, 0, true, false); - gen(env, _notify_jvmti_vthread_end , notify_jvmti_vthread_Type , SharedRuntime::notify_jvmti_vthread_end, 0, true, false); - gen(env, _notify_jvmti_vthread_mount , notify_jvmti_vthread_Type , SharedRuntime::notify_jvmti_vthread_mount, 0, true, false); - gen(env, _notify_jvmti_vthread_unmount , notify_jvmti_vthread_Type , SharedRuntime::notify_jvmti_vthread_unmount, 0, true, false); -#endif - gen(env, _complete_monitor_locking_Java , complete_monitor_enter_Type , SharedRuntime::complete_monitor_locking_C, 0, false, false); - gen(env, _monitor_notify_Java , monitor_notify_Type , monitor_notify_C , 0 , false, false); - gen(env, _monitor_notifyAll_Java , monitor_notify_Type , monitor_notifyAll_C , 0 , false, false); - gen(env, _rethrow_Java , rethrow_Type , rethrow_C , 2 , true , true ); - - gen(env, _slow_arraycopy_Java , slow_arraycopy_Type , SharedRuntime::slow_arraycopy_C , 0 , false, false); - gen(env, _register_finalizer_Java , register_finalizer_Type , register_finalizer , 0 , false, false); + C2_STUBS_DO(GEN_C2_BLOB, GEN_C2_STUB, GEN_C2_JVMTI_STUB) return true; } -#undef gen +#undef GEN_C2_BLOB + +#undef C2_STUB_FIELD_NAME +#undef C2_STUB_TYPEFUNC +#undef C2_STUB_C_FUNC +#undef C2_STUB_NAME +#undef GEN_C2_STUB + +#undef C2_JVMTI_STUB_C_FUNC +#undef GEN_C2_JVMTI_STUB +// #undef gen // Helper method to do generation of RunTimeStub's @@ -201,6 +220,19 @@ const char* OptoRuntime::stub_name(address entry) { #endif } +// local methods passed as arguments to stub generator that forward +// control to corresponding JRT methods of SharedRuntime + +void OptoRuntime::slow_arraycopy_C(oopDesc* src, jint src_pos, + oopDesc* dest, jint dest_pos, + jint length, JavaThread* thread) { + SharedRuntime::slow_arraycopy_C(src, src_pos, dest, dest_pos, length, thread); +} + +void OptoRuntime::complete_monitor_locking_C(oopDesc* obj, BasicLock* lock, JavaThread* current) { + SharedRuntime::complete_monitor_locking_C(obj, lock, current); +} + //============================================================================= // Opto compiler runtime routines @@ -529,6 +561,10 @@ const TypeFunc *OptoRuntime::new_array_Type() { return TypeFunc::make(domain, range); } +const TypeFunc *OptoRuntime::new_array_nozero_Type() { + return new_array_Type(); +} + const TypeFunc *OptoRuntime::multianewarray_Type(int ndim) { // create input type (domain) const int nargs = ndim + 1; @@ -607,6 +643,9 @@ const TypeFunc *OptoRuntime::complete_monitor_enter_Type() { return TypeFunc::make(domain,range); } +const TypeFunc *OptoRuntime::complete_monitor_locking_Type() { + return complete_monitor_enter_Type(); +} //----------------------------------------------------------------------------- const TypeFunc *OptoRuntime::complete_monitor_exit_Type() { @@ -637,6 +676,10 @@ const TypeFunc *OptoRuntime::monitor_notify_Type() { return TypeFunc::make(domain, range); } +const TypeFunc *OptoRuntime::monitor_notifyAll_Type() { + return monitor_notify_Type(); +} + const TypeFunc* OptoRuntime::flush_windows_Type() { // create input type (domain) const Type** fields = TypeTuple::fields(1); @@ -1827,7 +1870,7 @@ const TypeFunc *OptoRuntime::dtrace_object_alloc_Type() { } -JRT_ENTRY_NO_ASYNC(void, OptoRuntime::register_finalizer(oopDesc* obj, JavaThread* current)) +JRT_ENTRY_NO_ASYNC(void, OptoRuntime::register_finalizer_C(oopDesc* obj, JavaThread* current)) assert(oopDesc::is_oop(obj), "must be a valid oop"); assert(obj->klass()->has_finalizer(), "shouldn't be here otherwise"); InstanceKlass::register_finalizer(instanceOop(obj), CHECK); diff --git a/src/hotspot/share/opto/runtime.hpp b/src/hotspot/share/opto/runtime.hpp index 34c2780a2f8..da08fc0f386 100644 --- a/src/hotspot/share/opto/runtime.hpp +++ b/src/hotspot/share/opto/runtime.hpp @@ -30,6 +30,7 @@ #include "opto/optoreg.hpp" #include "opto/type.hpp" #include "runtime/deoptimization.hpp" +#include "runtime/stubDeclarations.hpp" #include "runtime/vframe.hpp" //------------------------------OptoRuntime------------------------------------ @@ -98,37 +99,46 @@ private: typedef const TypeFunc*(*TypeFunc_generator)(); +// define OptoStubId enum tags: uncommon_trap_id etc + +#define C2_BLOB_ID_ENUM_DECLARE(name, type) STUB_ID_NAME(name), +#define C2_STUB_ID_ENUM_DECLARE(name, f, t, r) STUB_ID_NAME(name), +#define C2_JVMTI_STUB_ID_ENUM_DECLARE(name) STUB_ID_NAME(name), +enum class OptoStubId :int { + NO_STUBID = -1, + C2_STUBS_DO(C2_BLOB_ID_ENUM_DECLARE, C2_STUB_ID_ENUM_DECLARE, C2_JVMTI_STUB_ID_ENUM_DECLARE) + NUM_STUBIDS +}; +#undef C2_BLOB_ID_ENUM_DECLARE +#undef C2_STUB_ID_ENUM_DECLARE +#undef C2_JVMTI_STUB_ID_ENUM_DECLARE + class OptoRuntime : public AllStatic { friend class Matcher; // allow access to stub names private: + // declare opto stub address/blob holder static fields +#define C2_BLOB_FIELD_DECLARE(name, type) \ + static type BLOB_FIELD_NAME(name); +#define C2_STUB_FIELD_NAME(name) _ ## name ## _Java +#define C2_STUB_FIELD_DECLARE(name, f, t, r) \ + static address C2_STUB_FIELD_NAME(name) ; +#define C2_JVMTI_STUB_FIELD_DECLARE(name) \ + static address STUB_FIELD_NAME(name); + + C2_STUBS_DO(C2_BLOB_FIELD_DECLARE, C2_STUB_FIELD_DECLARE, C2_JVMTI_STUB_FIELD_DECLARE) + +#undef C2_BLOB_FIELD_DECLARE +#undef C2_STUB_FIELD_NAME +#undef C2_STUB_FIELD_DECLARE +#undef C2_JVMTI_STUB_FIELD_DECLARE + + // Stub names indexed by sharedStubId + static const char *_stub_names[]; + // define stubs static address generate_stub(ciEnv* ci_env, TypeFunc_generator gen, address C_function, const char* name, int is_fancy_jump, bool pass_tls, bool return_pc); - // References to generated stubs - static address _new_instance_Java; - static address _new_array_Java; - static address _new_array_nozero_Java; - static address _multianewarray2_Java; - static address _multianewarray3_Java; - static address _multianewarray4_Java; - static address _multianewarray5_Java; - static address _multianewarrayN_Java; - static address _vtable_must_compile_Java; - static address _complete_monitor_locking_Java; - static address _rethrow_Java; - static address _monitor_notify_Java; - static address _monitor_notifyAll_Java; - - static address _slow_arraycopy_Java; - static address _register_finalizer_Java; -#if INCLUDE_JVMTI - static address _notify_jvmti_vthread_start; - static address _notify_jvmti_vthread_end; - static address _notify_jvmti_vthread_mount; - static address _notify_jvmti_vthread_unmount; -#endif - // // Implementation of runtime methods // ================================= @@ -148,6 +158,13 @@ class OptoRuntime : public AllStatic { static void multianewarray5_C(Klass* klass, int len1, int len2, int len3, int len4, int len5, JavaThread* current); static void multianewarrayN_C(Klass* klass, arrayOopDesc* dims, JavaThread* current); + // local methods passed as arguments to stub generator that forward + // control to corresponding JRT methods of SharedRuntime + static void slow_arraycopy_C(oopDesc* src, jint src_pos, + oopDesc* dest, jint dest_pos, + jint length, JavaThread* thread); + static void complete_monitor_locking_C(oopDesc* obj, BasicLock* lock, JavaThread* current); + public: static void monitor_notify_C(oopDesc* obj, JavaThread* current); static void monitor_notifyAll_C(oopDesc* obj, JavaThread* current); @@ -168,13 +185,10 @@ private: // CodeBlob support // =================================================================== - static UncommonTrapBlob* _uncommon_trap_blob; - static ExceptionBlob* _exception_blob; - static void generate_uncommon_trap_blob(void); static void generate_exception_blob(); - static void register_finalizer(oopDesc* obj, JavaThread* current); + static void register_finalizer_C(oopDesc* obj, JavaThread* current); public: @@ -188,6 +202,12 @@ private: // Returns the name of a stub static const char* stub_name(address entry); + // Returns the name associated with a given stub id + static const char* stub_name(OptoStubId id) { + assert(id > OptoStubId::NO_STUBID && id < OptoStubId::NUM_STUBIDS, "stub id out of range"); + return _stub_names[(int)id]; + } + // access to runtime stubs entry points for java code static address new_instance_Java() { return _new_instance_Java; } static address new_array_Java() { return _new_array_Java; } @@ -197,7 +217,6 @@ private: static address multianewarray4_Java() { return _multianewarray4_Java; } static address multianewarray5_Java() { return _multianewarray5_Java; } static address multianewarrayN_Java() { return _multianewarrayN_Java; } - static address vtable_must_compile_stub() { return _vtable_must_compile_Java; } static address complete_monitor_locking_Java() { return _complete_monitor_locking_Java; } static address monitor_notify_Java() { return _monitor_notify_Java; } static address monitor_notifyAll_Java() { return _monitor_notifyAll_Java; } @@ -227,6 +246,7 @@ private: static const TypeFunc* new_instance_Type(); // object allocation (slow case) static const TypeFunc* new_array_Type (); // [a]newarray (slow case) + static const TypeFunc* new_array_nozero_Type (); // [a]newarray (slow case) static const TypeFunc* multianewarray_Type(int ndim); // multianewarray static const TypeFunc* multianewarray2_Type(); // multianewarray static const TypeFunc* multianewarray3_Type(); // multianewarray @@ -234,8 +254,10 @@ private: static const TypeFunc* multianewarray5_Type(); // multianewarray static const TypeFunc* multianewarrayN_Type(); // multianewarray static const TypeFunc* complete_monitor_enter_Type(); + static const TypeFunc* complete_monitor_locking_Type(); static const TypeFunc* complete_monitor_exit_Type(); static const TypeFunc* monitor_notify_Type(); + static const TypeFunc* monitor_notifyAll_Type(); static const TypeFunc* uncommon_trap_Type(); static const TypeFunc* athrow_Type(); static const TypeFunc* rethrow_Type(); diff --git a/src/hotspot/share/opto/superword.cpp b/src/hotspot/share/opto/superword.cpp index bb5fed78b02..20c8dfbff17 100644 --- a/src/hotspot/share/opto/superword.cpp +++ b/src/hotspot/share/opto/superword.cpp @@ -657,9 +657,6 @@ void VLoopMemorySlices::get_slice_in_reverse_order(PhiNode* head, MemNode* tail, // or need to run igvn.optimize() again before SLP } else if (out->is_memory_phi() && !_vloop.in_bb(out)) { // Ditto. Not sure what else to check further. - } else if (out->Opcode() == Op_StoreCM && out->in(MemNode::OopStore) == n) { - // StoreCM has an input edge used as a precedence edge. - // Maybe an issue when oop stores are vectorized. } else { assert(out == prev || prev == nullptr, "no branches off of store slice"); } diff --git a/src/hotspot/share/opto/superwordVTransformBuilder.cpp b/src/hotspot/share/opto/superwordVTransformBuilder.cpp index b0a0c97cb16..6c2d3a3be35 100644 --- a/src/hotspot/share/opto/superwordVTransformBuilder.cpp +++ b/src/hotspot/share/opto/superwordVTransformBuilder.cpp @@ -228,8 +228,8 @@ VTransformNode* SuperWordVTransformBuilder::get_or_make_vtnode_vector_input_at_i return shift_count; } else { // Replicate the scalar same_input to every vector element. - const Type* element_type = _vloop_analyzer.types().velt_type(p0); - if (index == 2 && VectorNode::is_scalar_rotate(p0) && element_type->isa_long()) { + BasicType element_type = _vloop_analyzer.types().velt_basic_type(p0); + if (index == 2 && VectorNode::is_scalar_rotate(p0) && element_type == T_LONG) { // Scalar rotate has int rotation value, but the scalar rotate expects longs. assert(same_input->bottom_type()->isa_int(), "scalar rotate expects int rotation"); VTransformNode* conv = new (_vtransform.arena()) VTransformConvI2LNode(_vtransform); diff --git a/src/hotspot/share/opto/type.cpp b/src/hotspot/share/opto/type.cpp index 967b4a815d0..70cd46c900d 100644 --- a/src/hotspot/share/opto/type.cpp +++ b/src/hotspot/share/opto/type.cpp @@ -679,7 +679,7 @@ void Type::Initialize_shared(Compile* current) { // get_zero_type() should not happen for T_CONFLICT _zero_type[T_CONFLICT]= nullptr; - TypeVect::VECTMASK = (TypeVect*)(new TypeVectMask(TypeInt::BOOL, MaxVectorSize))->hashcons(); + TypeVect::VECTMASK = (TypeVect*)(new TypeVectMask(T_BOOLEAN, MaxVectorSize))->hashcons(); mreg2type[Op_RegVectMask] = TypeVect::VECTMASK; if (Matcher::supports_scalable_vector()) { @@ -687,20 +687,20 @@ void Type::Initialize_shared(Compile* current) { } // Vector predefined types, it needs initialized _const_basic_type[]. - if (Matcher::vector_size_supported(T_BYTE,4)) { - TypeVect::VECTS = TypeVect::make(T_BYTE,4); + if (Matcher::vector_size_supported(T_BYTE, 4)) { + TypeVect::VECTS = TypeVect::make(T_BYTE, 4); } - if (Matcher::vector_size_supported(T_FLOAT,2)) { - TypeVect::VECTD = TypeVect::make(T_FLOAT,2); + if (Matcher::vector_size_supported(T_FLOAT, 2)) { + TypeVect::VECTD = TypeVect::make(T_FLOAT, 2); } - if (Matcher::vector_size_supported(T_FLOAT,4)) { - TypeVect::VECTX = TypeVect::make(T_FLOAT,4); + if (Matcher::vector_size_supported(T_FLOAT, 4)) { + TypeVect::VECTX = TypeVect::make(T_FLOAT, 4); } - if (Matcher::vector_size_supported(T_FLOAT,8)) { - TypeVect::VECTY = TypeVect::make(T_FLOAT,8); + if (Matcher::vector_size_supported(T_FLOAT, 8)) { + TypeVect::VECTY = TypeVect::make(T_FLOAT, 8); } - if (Matcher::vector_size_supported(T_FLOAT,16)) { - TypeVect::VECTZ = TypeVect::make(T_FLOAT,16); + if (Matcher::vector_size_supported(T_FLOAT, 16)) { + TypeVect::VECTZ = TypeVect::make(T_FLOAT, 16); } mreg2type[Op_VecA] = TypeVect::VECTA; @@ -2482,58 +2482,59 @@ bool TypeAry::ary_must_be_exact() const { //==============================TypeVect======================================= // Convenience common pre-built types. -const TypeVect *TypeVect::VECTA = nullptr; // vector length agnostic -const TypeVect *TypeVect::VECTS = nullptr; // 32-bit vectors -const TypeVect *TypeVect::VECTD = nullptr; // 64-bit vectors -const TypeVect *TypeVect::VECTX = nullptr; // 128-bit vectors -const TypeVect *TypeVect::VECTY = nullptr; // 256-bit vectors -const TypeVect *TypeVect::VECTZ = nullptr; // 512-bit vectors -const TypeVect *TypeVect::VECTMASK = nullptr; // predicate/mask vector +const TypeVect* TypeVect::VECTA = nullptr; // vector length agnostic +const TypeVect* TypeVect::VECTS = nullptr; // 32-bit vectors +const TypeVect* TypeVect::VECTD = nullptr; // 64-bit vectors +const TypeVect* TypeVect::VECTX = nullptr; // 128-bit vectors +const TypeVect* TypeVect::VECTY = nullptr; // 256-bit vectors +const TypeVect* TypeVect::VECTZ = nullptr; // 512-bit vectors +const TypeVect* TypeVect::VECTMASK = nullptr; // predicate/mask vector //------------------------------make------------------------------------------- -const TypeVect* TypeVect::make(const Type *elem, uint length, bool is_mask) { +const TypeVect* TypeVect::make(BasicType elem_bt, uint length, bool is_mask) { if (is_mask) { - return makemask(elem, length); + return makemask(elem_bt, length); } - BasicType elem_bt = elem->array_element_basic_type(); assert(is_java_primitive(elem_bt), "only primitive types in vector"); assert(Matcher::vector_size_supported(elem_bt, length), "length in range"); int size = length * type2aelembytes(elem_bt); switch (Matcher::vector_ideal_reg(size)) { case Op_VecA: - return (TypeVect*)(new TypeVectA(elem, length))->hashcons(); + return (TypeVect*)(new TypeVectA(elem_bt, length))->hashcons(); case Op_VecS: - return (TypeVect*)(new TypeVectS(elem, length))->hashcons(); + return (TypeVect*)(new TypeVectS(elem_bt, length))->hashcons(); case Op_RegL: case Op_VecD: case Op_RegD: - return (TypeVect*)(new TypeVectD(elem, length))->hashcons(); + return (TypeVect*)(new TypeVectD(elem_bt, length))->hashcons(); case Op_VecX: - return (TypeVect*)(new TypeVectX(elem, length))->hashcons(); + return (TypeVect*)(new TypeVectX(elem_bt, length))->hashcons(); case Op_VecY: - return (TypeVect*)(new TypeVectY(elem, length))->hashcons(); + return (TypeVect*)(new TypeVectY(elem_bt, length))->hashcons(); case Op_VecZ: - return (TypeVect*)(new TypeVectZ(elem, length))->hashcons(); + return (TypeVect*)(new TypeVectZ(elem_bt, length))->hashcons(); } ShouldNotReachHere(); return nullptr; } -const TypeVect *TypeVect::makemask(const Type* elem, uint length) { - BasicType elem_bt = elem->array_element_basic_type(); +const TypeVect* TypeVect::makemask(BasicType elem_bt, uint length) { if (Matcher::has_predicated_vectors() && Matcher::match_rule_supported_vector_masked(Op_VectorLoadMask, length, elem_bt)) { - return TypeVectMask::make(elem, length); + return TypeVectMask::make(elem_bt, length); } else { - return make(elem, length); + return make(elem_bt, length); } } //------------------------------meet------------------------------------------- -// Compute the MEET of two types. It returns a new Type object. -const Type *TypeVect::xmeet( const Type *t ) const { +// Compute the MEET of two types. Since each TypeVect is the only instance of +// its species, meeting often returns itself +const Type* TypeVect::xmeet(const Type* t) const { // Perform a fast test for common case; meeting the same types together. - if( this == t ) return this; // Meeting same type-rep? + if (this == t) { + return this; + } // Current "this->_base" is Vector switch (t->base()) { // switch on original type @@ -2543,13 +2544,7 @@ const Type *TypeVect::xmeet( const Type *t ) const { default: // All else is a mistake typerr(t); - case VectorMask: { - const TypeVectMask* v = t->is_vectmask(); - assert( base() == v->base(), ""); - assert(length() == v->length(), ""); - assert(element_basic_type() == v->element_basic_type(), ""); - return TypeVect::makemask(_elem->xmeet(v->_elem), _length); - } + case VectorMask: case VectorA: case VectorS: case VectorD: @@ -2557,10 +2552,10 @@ const Type *TypeVect::xmeet( const Type *t ) const { case VectorY: case VectorZ: { // Meeting 2 vectors? const TypeVect* v = t->is_vect(); - assert( base() == v->base(), ""); + assert(base() == v->base(), ""); assert(length() == v->length(), ""); assert(element_basic_type() == v->element_basic_type(), ""); - return TypeVect::make(_elem->xmeet(v->_elem), _length); + return this; } case Top: break; @@ -2569,26 +2564,26 @@ const Type *TypeVect::xmeet( const Type *t ) const { } //------------------------------xdual------------------------------------------ -// Dual: compute field-by-field dual -const Type *TypeVect::xdual() const { - return new TypeVect(base(), _elem->dual(), _length); +// Since each TypeVect is the only instance of its species, it is self-dual +const Type* TypeVect::xdual() const { + return this; } //------------------------------eq--------------------------------------------- // Structural equality check for Type representations -bool TypeVect::eq(const Type *t) const { - const TypeVect *v = t->is_vect(); - return (_elem == v->_elem) && (_length == v->_length); +bool TypeVect::eq(const Type* t) const { + const TypeVect* v = t->is_vect(); + return (element_basic_type() == v->element_basic_type()) && (length() == v->length()); } //------------------------------hash------------------------------------------- // Type-specific hashing function. uint TypeVect::hash(void) const { - return (uint)(uintptr_t)_elem + (uint)(uintptr_t)_length; + return (uint)base() + (uint)(uintptr_t)_elem_bt + (uint)(uintptr_t)_length; } //------------------------------singleton-------------------------------------- -// TRUE if Type is a singleton type, FALSE otherwise. Singletons are simple +// TRUE if Type is a singleton type, FALSE otherwise. Singletons are simple // constants (Ldi nodes). Vector is singleton if all elements are the same // constant value (when vector is created with Replicate code). bool TypeVect::singleton(void) const { @@ -2598,52 +2593,36 @@ bool TypeVect::singleton(void) const { } bool TypeVect::empty(void) const { - return _elem->empty(); + return false; } //------------------------------dump2------------------------------------------ #ifndef PRODUCT -void TypeVect::dump2(Dict &d, uint depth, outputStream *st) const { +void TypeVect::dump2(Dict& d, uint depth, outputStream* st) const { switch (base()) { case VectorA: - st->print("vectora["); break; + st->print("vectora"); break; case VectorS: - st->print("vectors["); break; + st->print("vectors"); break; case VectorD: - st->print("vectord["); break; + st->print("vectord"); break; case VectorX: - st->print("vectorx["); break; + st->print("vectorx"); break; case VectorY: - st->print("vectory["); break; + st->print("vectory"); break; case VectorZ: - st->print("vectorz["); break; + st->print("vectorz"); break; case VectorMask: - st->print("vectormask["); break; + st->print("vectormask"); break; default: ShouldNotReachHere(); } - st->print("%d]:{", _length); - _elem->dump2(d, depth, st); - st->print("}"); + st->print("<%c,%u>", type2char(element_basic_type()), length()); } #endif -bool TypeVectMask::eq(const Type *t) const { - const TypeVectMask *v = t->is_vectmask(); - return (element_type() == v->element_type()) && (length() == v->length()); -} - -const Type *TypeVectMask::xdual() const { - return new TypeVectMask(element_type()->dual(), length()); -} - -const TypeVectMask *TypeVectMask::make(const BasicType elem_bt, uint length) { - return make(get_const_basic_type(elem_bt), length); -} - -const TypeVectMask *TypeVectMask::make(const Type* elem, uint length) { - const TypeVectMask* mtype = Matcher::predicate_reg_type(elem, length); - return (TypeVectMask*) const_cast(mtype)->hashcons(); +const TypeVectMask* TypeVectMask::make(const BasicType elem_bt, uint length) { + return (TypeVectMask*) (new TypeVectMask(elem_bt, length))->hashcons(); } //============================================================================= @@ -3132,8 +3111,8 @@ const TypeRawPtr *TypeRawPtr::make( enum PTR ptr ) { return (TypeRawPtr*)(new TypeRawPtr(ptr,nullptr))->hashcons(); } -const TypeRawPtr *TypeRawPtr::make( address bits ) { - assert( bits, "Use TypePtr for null" ); +const TypeRawPtr *TypeRawPtr::make(address bits) { + assert(bits != nullptr, "Use TypePtr for null"); return (TypeRawPtr*)(new TypeRawPtr(Constant,bits))->hashcons(); } @@ -3222,15 +3201,21 @@ const TypePtr* TypeRawPtr::add_offset(intptr_t offset) const { case TypePtr::BotPTR: case TypePtr::NotNull: return this; - case TypePtr::Null: case TypePtr::Constant: { - address bits = _bits+offset; - if ( bits == 0 ) return TypePtr::NULL_PTR; - return make( bits ); + uintptr_t bits = (uintptr_t)_bits; + uintptr_t sum = bits + offset; + if (( offset < 0 ) + ? ( sum > bits ) // Underflow? + : ( sum < bits )) { // Overflow? + return BOTTOM; + } else if ( sum == 0 ) { + return TypePtr::NULL_PTR; + } else { + return make( (address)sum ); + } } default: ShouldNotReachHere(); } - return nullptr; // Lint noise } //------------------------------eq--------------------------------------------- @@ -3260,23 +3245,28 @@ void TypeRawPtr::dump2( Dict &d, uint depth, outputStream *st ) const { // Convenience common pre-built type. const TypeOopPtr *TypeOopPtr::BOTTOM; -TypeInterfaces::TypeInterfaces() - : Type(Interfaces), _list(Compile::current()->type_arena(), 0, 0, nullptr), +TypeInterfaces::TypeInterfaces(ciInstanceKlass** interfaces_base, int nb_interfaces) + : Type(Interfaces), _interfaces(interfaces_base, nb_interfaces), _hash(0), _exact_klass(nullptr) { - DEBUG_ONLY(_initialized = true); -} - -TypeInterfaces::TypeInterfaces(GrowableArray* interfaces) - : Type(Interfaces), _list(Compile::current()->type_arena(), interfaces->length(), 0, nullptr), - _hash(0), _exact_klass(nullptr) { - for (int i = 0; i < interfaces->length(); i++) { - add(interfaces->at(i)); - } + _interfaces.sort(compare); initialize(); } const TypeInterfaces* TypeInterfaces::make(GrowableArray* interfaces) { - TypeInterfaces* result = (interfaces == nullptr) ? new TypeInterfaces() : new TypeInterfaces(interfaces); + // hashcons() can only delete the last thing that was allocated: to + // make sure all memory for the newly created TypeInterfaces can be + // freed if an identical one exists, allocate space for the array of + // interfaces right after the TypeInterfaces object so that they + // form a contiguous piece of memory. + int nb_interfaces = interfaces == nullptr ? 0 : interfaces->length(); + size_t total_size = sizeof(TypeInterfaces) + nb_interfaces * sizeof(ciInstanceKlass*); + + void* allocated_mem = operator new(total_size); + ciInstanceKlass** interfaces_base = (ciInstanceKlass**)((char*)allocated_mem + sizeof(TypeInterfaces)); + for (int i = 0; i < nb_interfaces; ++i) { + interfaces_base[i] = interfaces->at(i); + } + TypeInterfaces* result = ::new (allocated_mem) TypeInterfaces(interfaces_base, nb_interfaces); return (const TypeInterfaces*)result->hashcons(); } @@ -3295,20 +3285,18 @@ int TypeInterfaces::compare(ciInstanceKlass* const& k1, ciInstanceKlass* const& return 0; } -void TypeInterfaces::add(ciInstanceKlass* interface) { - assert(interface->is_interface(), "for interfaces only"); - _list.insert_sorted(interface); - verify(); +int TypeInterfaces::compare(ciInstanceKlass** k1, ciInstanceKlass** k2) { + return compare(*k1, *k2); } bool TypeInterfaces::eq(const Type* t) const { const TypeInterfaces* other = (const TypeInterfaces*)t; - if (_list.length() != other->_list.length()) { + if (_interfaces.length() != other->_interfaces.length()) { return false; } - for (int i = 0; i < _list.length(); i++) { - ciKlass* k1 = _list.at(i); - ciKlass* k2 = other->_list.at(i); + for (int i = 0; i < _interfaces.length(); i++) { + ciKlass* k1 = _interfaces.at(i); + ciKlass* k2 = other->_interfaces.at(i); if (!k1->equals(k2)) { return false; } @@ -3319,12 +3307,12 @@ bool TypeInterfaces::eq(const Type* t) const { bool TypeInterfaces::eq(ciInstanceKlass* k) const { assert(k->is_loaded(), "should be loaded"); GrowableArray* interfaces = k->transitive_interfaces(); - if (_list.length() != interfaces->length()) { + if (_interfaces.length() != interfaces->length()) { return false; } for (int i = 0; i < interfaces->length(); i++) { bool found = false; - _list.find_sorted(interfaces->at(i), found); + _interfaces.find_sorted(interfaces->at(i), found); if (!found) { return false; } @@ -3344,8 +3332,8 @@ const Type* TypeInterfaces::xdual() const { void TypeInterfaces::compute_hash() { uint hash = 0; - for (int i = 0; i < _list.length(); i++) { - ciKlass* k = _list.at(i); + for (int i = 0; i < _interfaces.length(); i++) { + ciKlass* k = _interfaces.at(i); hash += k->hash(); } _hash = hash; @@ -3356,13 +3344,13 @@ static int compare_interfaces(ciInstanceKlass** k1, ciInstanceKlass** k2) { } void TypeInterfaces::dump(outputStream* st) const { - if (_list.length() == 0) { + if (_interfaces.length() == 0) { return; } ResourceMark rm; st->print(" ("); GrowableArray interfaces; - interfaces.appendAll(&_list); + interfaces.appendAll(&_interfaces); // Sort the interfaces so they are listed in the same order from one run to the other of the same compilation interfaces.sort(compare_interfaces); for (int i = 0; i < interfaces.length(); i++) { @@ -3377,9 +3365,9 @@ void TypeInterfaces::dump(outputStream* st) const { #ifdef ASSERT void TypeInterfaces::verify() const { - for (int i = 1; i < _list.length(); i++) { - ciInstanceKlass* k1 = _list.at(i-1); - ciInstanceKlass* k2 = _list.at(i); + for (int i = 1; i < _interfaces.length(); i++) { + ciInstanceKlass* k1 = _interfaces.at(i-1); + ciInstanceKlass* k2 = _interfaces.at(i); assert(compare(k2, k1) > 0, "should be ordered"); assert(k1 != k2, "no duplicate"); } @@ -3390,23 +3378,23 @@ const TypeInterfaces* TypeInterfaces::union_with(const TypeInterfaces* other) co GrowableArray result_list; int i = 0; int j = 0; - while (i < _list.length() || j < other->_list.length()) { - while (i < _list.length() && - (j >= other->_list.length() || - compare(_list.at(i), other->_list.at(j)) < 0)) { - result_list.push(_list.at(i)); + while (i < _interfaces.length() || j < other->_interfaces.length()) { + while (i < _interfaces.length() && + (j >= other->_interfaces.length() || + compare(_interfaces.at(i), other->_interfaces.at(j)) < 0)) { + result_list.push(_interfaces.at(i)); i++; } - while (j < other->_list.length() && - (i >= _list.length() || - compare(other->_list.at(j), _list.at(i)) < 0)) { - result_list.push(other->_list.at(j)); + while (j < other->_interfaces.length() && + (i >= _interfaces.length() || + compare(other->_interfaces.at(j), _interfaces.at(i)) < 0)) { + result_list.push(other->_interfaces.at(j)); j++; } - if (i < _list.length() && - j < other->_list.length() && - _list.at(i) == other->_list.at(j)) { - result_list.push(_list.at(i)); + if (i < _interfaces.length() && + j < other->_interfaces.length() && + _interfaces.at(i) == other->_interfaces.at(j)) { + result_list.push(_interfaces.at(i)); i++; j++; } @@ -3414,14 +3402,14 @@ const TypeInterfaces* TypeInterfaces::union_with(const TypeInterfaces* other) co const TypeInterfaces* result = TypeInterfaces::make(&result_list); #ifdef ASSERT result->verify(); - for (int i = 0; i < _list.length(); i++) { - assert(result->_list.contains(_list.at(i)), "missing"); + for (int i = 0; i < _interfaces.length(); i++) { + assert(result->_interfaces.contains(_interfaces.at(i)), "missing"); } - for (int i = 0; i < other->_list.length(); i++) { - assert(result->_list.contains(other->_list.at(i)), "missing"); + for (int i = 0; i < other->_interfaces.length(); i++) { + assert(result->_interfaces.contains(other->_interfaces.at(i)), "missing"); } - for (int i = 0; i < result->_list.length(); i++) { - assert(_list.contains(result->_list.at(i)) || other->_list.contains(result->_list.at(i)), "missing"); + for (int i = 0; i < result->_interfaces.length(); i++) { + assert(_interfaces.contains(result->_interfaces.at(i)) || other->_interfaces.contains(result->_interfaces.at(i)), "missing"); } #endif return result; @@ -3431,21 +3419,21 @@ const TypeInterfaces* TypeInterfaces::intersection_with(const TypeInterfaces* ot GrowableArray result_list; int i = 0; int j = 0; - while (i < _list.length() || j < other->_list.length()) { - while (i < _list.length() && - (j >= other->_list.length() || - compare(_list.at(i), other->_list.at(j)) < 0)) { + while (i < _interfaces.length() || j < other->_interfaces.length()) { + while (i < _interfaces.length() && + (j >= other->_interfaces.length() || + compare(_interfaces.at(i), other->_interfaces.at(j)) < 0)) { i++; } - while (j < other->_list.length() && - (i >= _list.length() || - compare(other->_list.at(j), _list.at(i)) < 0)) { + while (j < other->_interfaces.length() && + (i >= _interfaces.length() || + compare(other->_interfaces.at(j), _interfaces.at(i)) < 0)) { j++; } - if (i < _list.length() && - j < other->_list.length() && - _list.at(i) == other->_list.at(j)) { - result_list.push(_list.at(i)); + if (i < _interfaces.length() && + j < other->_interfaces.length() && + _interfaces.at(i) == other->_interfaces.at(j)) { + result_list.push(_interfaces.at(i)); i++; j++; } @@ -3453,14 +3441,14 @@ const TypeInterfaces* TypeInterfaces::intersection_with(const TypeInterfaces* ot const TypeInterfaces* result = TypeInterfaces::make(&result_list); #ifdef ASSERT result->verify(); - for (int i = 0; i < _list.length(); i++) { - assert(!other->_list.contains(_list.at(i)) || result->_list.contains(_list.at(i)), "missing"); + for (int i = 0; i < _interfaces.length(); i++) { + assert(!other->_interfaces.contains(_interfaces.at(i)) || result->_interfaces.contains(_interfaces.at(i)), "missing"); } - for (int i = 0; i < other->_list.length(); i++) { - assert(!_list.contains(other->_list.at(i)) || result->_list.contains(other->_list.at(i)), "missing"); + for (int i = 0; i < other->_interfaces.length(); i++) { + assert(!_interfaces.contains(other->_interfaces.at(i)) || result->_interfaces.contains(other->_interfaces.at(i)), "missing"); } - for (int i = 0; i < result->_list.length(); i++) { - assert(_list.contains(result->_list.at(i)) && other->_list.contains(result->_list.at(i)), "missing"); + for (int i = 0; i < result->_interfaces.length(); i++) { + assert(_interfaces.contains(result->_interfaces.at(i)) && other->_interfaces.contains(result->_interfaces.at(i)), "missing"); } #endif return result; @@ -3473,13 +3461,13 @@ ciInstanceKlass* TypeInterfaces::exact_klass() const { } void TypeInterfaces::compute_exact_klass() { - if (_list.length() == 0) { + if (_interfaces.length() == 0) { _exact_klass = nullptr; return; } ciInstanceKlass* res = nullptr; - for (int i = 0; i < _list.length(); i++) { - ciInstanceKlass* interface = _list.at(i); + for (int i = 0; i < _interfaces.length(); i++) { + ciInstanceKlass* interface = _interfaces.at(i); if (eq(interface)) { assert(res == nullptr, ""); res = interface; @@ -3490,8 +3478,8 @@ void TypeInterfaces::compute_exact_klass() { #ifdef ASSERT void TypeInterfaces::verify_is_loaded() const { - for (int i = 0; i < _list.length(); i++) { - ciKlass* interface = _list.at(i); + for (int i = 0; i < _interfaces.length(); i++) { + ciKlass* interface = _interfaces.at(i); assert(interface->is_loaded(), "Interface not loaded"); } } diff --git a/src/hotspot/share/opto/type.hpp b/src/hotspot/share/opto/type.hpp index b9883d51391..f6b7efcae3b 100644 --- a/src/hotspot/share/opto/type.hpp +++ b/src/hotspot/share/opto/type.hpp @@ -784,112 +784,96 @@ public: //------------------------------TypeVect--------------------------------------- // Class of Vector Types class TypeVect : public Type { - const Type* _elem; // Vector's element type - const uint _length; // Elements in vector (power of 2) + const BasicType _elem_bt; // Vector's element type + const uint _length; // Elements in vector (power of 2) protected: - TypeVect(TYPES t, const Type* elem, uint length) : Type(t), - _elem(elem), _length(length) {} + TypeVect(TYPES t, BasicType elem_bt, uint length) : Type(t), + _elem_bt(elem_bt), _length(length) {} public: - const Type* element_type() const { return _elem; } - BasicType element_basic_type() const { return _elem->array_element_basic_type(); } + BasicType element_basic_type() const { return _elem_bt; } uint length() const { return _length; } uint length_in_bytes() const { - return _length * type2aelembytes(element_basic_type()); + return _length * type2aelembytes(element_basic_type()); } - virtual bool eq(const Type *t) const; + virtual bool eq(const Type* t) const; virtual uint hash() const; // Type specific hashing virtual bool singleton(void) const; // TRUE if type is a singleton virtual bool empty(void) const; // TRUE if type is vacuous - static const TypeVect *make(const BasicType elem_bt, uint length, bool is_mask = false) { - // Use bottom primitive type. - return make(get_const_basic_type(elem_bt), length, is_mask); - } - // Used directly by Replicate nodes to construct singleton vector. - static const TypeVect *make(const Type* elem, uint length, bool is_mask = false); + static const TypeVect* make(const BasicType elem_bt, uint length, bool is_mask = false); + static const TypeVect* makemask(const BasicType elem_bt, uint length); - static const TypeVect *makemask(const BasicType elem_bt, uint length) { - // Use bottom primitive type. - return makemask(get_const_basic_type(elem_bt), length); - } - static const TypeVect *makemask(const Type* elem, uint length); + virtual const Type* xmeet( const Type *t) const; + virtual const Type* xdual() const; // Compute dual right now. - - virtual const Type *xmeet( const Type *t) const; - virtual const Type *xdual() const; // Compute dual right now. - - static const TypeVect *VECTA; - static const TypeVect *VECTS; - static const TypeVect *VECTD; - static const TypeVect *VECTX; - static const TypeVect *VECTY; - static const TypeVect *VECTZ; - static const TypeVect *VECTMASK; + static const TypeVect* VECTA; + static const TypeVect* VECTS; + static const TypeVect* VECTD; + static const TypeVect* VECTX; + static const TypeVect* VECTY; + static const TypeVect* VECTZ; + static const TypeVect* VECTMASK; #ifndef PRODUCT - virtual void dump2(Dict &d, uint, outputStream *st) const; // Specialized per-Type dumping + virtual void dump2(Dict& d, uint, outputStream* st) const; // Specialized per-Type dumping #endif }; class TypeVectA : public TypeVect { friend class TypeVect; - TypeVectA(const Type* elem, uint length) : TypeVect(VectorA, elem, length) {} + TypeVectA(BasicType elem_bt, uint length) : TypeVect(VectorA, elem_bt, length) {} }; class TypeVectS : public TypeVect { friend class TypeVect; - TypeVectS(const Type* elem, uint length) : TypeVect(VectorS, elem, length) {} + TypeVectS(BasicType elem_bt, uint length) : TypeVect(VectorS, elem_bt, length) {} }; class TypeVectD : public TypeVect { friend class TypeVect; - TypeVectD(const Type* elem, uint length) : TypeVect(VectorD, elem, length) {} + TypeVectD(BasicType elem_bt, uint length) : TypeVect(VectorD, elem_bt, length) {} }; class TypeVectX : public TypeVect { friend class TypeVect; - TypeVectX(const Type* elem, uint length) : TypeVect(VectorX, elem, length) {} + TypeVectX(BasicType elem_bt, uint length) : TypeVect(VectorX, elem_bt, length) {} }; class TypeVectY : public TypeVect { friend class TypeVect; - TypeVectY(const Type* elem, uint length) : TypeVect(VectorY, elem, length) {} + TypeVectY(BasicType elem_bt, uint length) : TypeVect(VectorY, elem_bt, length) {} }; class TypeVectZ : public TypeVect { friend class TypeVect; - TypeVectZ(const Type* elem, uint length) : TypeVect(VectorZ, elem, length) {} + TypeVectZ(BasicType elem_bt, uint length) : TypeVect(VectorZ, elem_bt, length) {} }; class TypeVectMask : public TypeVect { public: friend class TypeVect; - TypeVectMask(const Type* elem, uint length) : TypeVect(VectorMask, elem, length) {} - virtual bool eq(const Type *t) const; - virtual const Type *xdual() const; + TypeVectMask(BasicType elem_bt, uint length) : TypeVect(VectorMask, elem_bt, length) {} static const TypeVectMask* make(const BasicType elem_bt, uint length); - static const TypeVectMask* make(const Type* elem, uint length); }; // Set of implemented interfaces. Referenced from TypeOopPtr and TypeKlassPtr. class TypeInterfaces : public Type { private: - GrowableArray _list; + GrowableArrayFromArray _interfaces; uint _hash; ciInstanceKlass* _exact_klass; DEBUG_ONLY(bool _initialized;) void initialize(); - void add(ciInstanceKlass* interface); void verify() const NOT_DEBUG_RETURN; void compute_hash(); void compute_exact_klass(); - TypeInterfaces(); - TypeInterfaces(GrowableArray* interfaces); + + TypeInterfaces(ciInstanceKlass** interfaces_base, int nb_interfaces); NONCOPYABLE(TypeInterfaces); public: @@ -904,12 +888,13 @@ public: bool contains(const TypeInterfaces* other) const { return intersection_with(other)->eq(other); } - bool empty() const { return _list.length() == 0; } + bool empty() const { return _interfaces.length() == 0; } ciInstanceKlass* exact_klass() const; void verify_is_loaded() const NOT_DEBUG_RETURN; static int compare(ciInstanceKlass* const& k1, ciInstanceKlass* const& k2); + static int compare(ciInstanceKlass** k1, ciInstanceKlass** k2); const Type* xmeet(const Type* t) const; diff --git a/src/hotspot/share/opto/vectorIntrinsics.cpp b/src/hotspot/share/opto/vectorIntrinsics.cpp index cfcd903e79d..838f87eac01 100644 --- a/src/hotspot/share/opto/vectorIntrinsics.cpp +++ b/src/hotspot/share/opto/vectorIntrinsics.cpp @@ -468,11 +468,11 @@ bool LibraryCallKit::inline_vector_nary_operation(int n) { Node* operation = nullptr; if (opc == Op_CallLeafVector) { assert(UseVectorStubs, "sanity"); - operation = gen_call_to_svml(opr->get_con(), elem_bt, num_elem, opd1, opd2); + operation = gen_call_to_vector_math(opr->get_con(), elem_bt, num_elem, opd1, opd2); if (operation == nullptr) { - log_if_needed(" ** svml call failed for %s_%s_%d", - (elem_bt == T_FLOAT)?"float":"double", - VectorSupport::svmlname[opr->get_con() - VectorSupport::VECTOR_OP_SVML_START], + log_if_needed(" ** Vector math call failed for %s_%s_%d", + (elem_bt == T_FLOAT) ? "float" : "double", + VectorSupport::mathname[opr->get_con() - VectorSupport::VECTOR_OP_MATH_START], num_elem * type2aelembytes(elem_bt)); return false; } @@ -524,17 +524,16 @@ bool LibraryCallKit::inline_vector_nary_operation(int n) { Node* LibraryCallKit::partially_wrap_indexes(Node* index_vec, int num_elem, BasicType elem_bt) { assert(elem_bt == T_BYTE, "Shuffles use byte array based backing storage."); const TypeVect* vt = TypeVect::make(elem_bt, num_elem); - const Type* type_bt = Type::get_const_basic_type(elem_bt); Node* mod_mask = gvn().makecon(TypeInt::make(num_elem-1)); - Node* bcast_mod_mask = gvn().transform(VectorNode::scalar2vector(mod_mask, num_elem, type_bt)); + Node* bcast_mod_mask = gvn().transform(VectorNode::scalar2vector(mod_mask, num_elem, elem_bt)); BoolTest::mask pred = BoolTest::ugt; ConINode* pred_node = (ConINode*)gvn().makecon(TypeInt::make(pred)); Node* lane_cnt = gvn().makecon(TypeInt::make(num_elem)); - Node* bcast_lane_cnt = gvn().transform(VectorNode::scalar2vector(lane_cnt, num_elem, type_bt)); - const TypeVect* vmask_type = TypeVect::makemask(type_bt, num_elem); - Node* mask = gvn().transform(new VectorMaskCmpNode(pred, bcast_lane_cnt, index_vec, pred_node, vmask_type)); + Node* bcast_lane_cnt = gvn().transform(VectorNode::scalar2vector(lane_cnt, num_elem, elem_bt)); + const TypeVect* vmask_type = TypeVect::makemask(elem_bt, num_elem); + Node* mask = gvn().transform(new VectorMaskCmpNode(pred, bcast_lane_cnt, index_vec, pred_node, vmask_type)); // Make the indices greater than lane count as -ve values to match the java side implementation. index_vec = gvn().transform(VectorNode::make(Op_AndV, index_vec, bcast_mod_mask, vt)); @@ -600,8 +599,7 @@ bool LibraryCallKit::inline_vector_shuffle_iota() { return false; } - const Type * type_bt = Type::get_const_basic_type(elem_bt); - const TypeVect * vt = TypeVect::make(type_bt, num_elem); + const TypeVect* vt = TypeVect::make(elem_bt, num_elem); Node* res = gvn().transform(new VectorLoadConstNode(gvn().makecon(TypeInt::ZERO), vt)); @@ -609,7 +607,7 @@ bool LibraryCallKit::inline_vector_shuffle_iota() { Node* step = argument(5); if (step_multiply) { - Node* bcast_step = gvn().transform(VectorNode::scalar2vector(step, num_elem, type_bt)); + Node* bcast_step = gvn().transform(VectorNode::scalar2vector(step, num_elem, elem_bt)); res = gvn().transform(VectorNode::make(Op_MulVB, res, bcast_step, vt)); } else if (step_val->get_con() > 1) { Node* cnt = gvn().makecon(TypeInt::make(log2i_exact(step_val->get_con()))); @@ -618,12 +616,12 @@ bool LibraryCallKit::inline_vector_shuffle_iota() { } if (!start_val->is_con() || start_val->get_con() != 0) { - Node* bcast_start = gvn().transform(VectorNode::scalar2vector(start, num_elem, type_bt)); + Node* bcast_start = gvn().transform(VectorNode::scalar2vector(start, num_elem, elem_bt)); res = gvn().transform(VectorNode::make(Op_AddVB, res, bcast_start, vt)); } - Node * mod_val = gvn().makecon(TypeInt::make(num_elem-1)); - Node * bcast_mod = gvn().transform(VectorNode::scalar2vector(mod_val, num_elem, type_bt)); + Node* mod_val = gvn().makecon(TypeInt::make(num_elem-1)); + Node* bcast_mod = gvn().transform(VectorNode::scalar2vector(mod_val, num_elem, elem_bt)); if (do_wrap) { // Wrap the indices greater than lane count. @@ -757,6 +755,63 @@ bool LibraryCallKit::inline_vector_shuffle_to_vector() { return true; } +// public static +// > +// SH wrapShuffleIndexes(Class eClass, Class shClass, SH sh, int length, +// ShuffleWrapIndexesOperation defaultImpl) +bool LibraryCallKit::inline_vector_wrap_shuffle_indexes() { + const TypeInstPtr* elem_klass = gvn().type(argument(0))->isa_instptr(); + const TypeInstPtr* shuffle_klass = gvn().type(argument(1))->isa_instptr(); + Node* shuffle = argument(2); + const TypeInt* vlen = gvn().type(argument(3))->isa_int(); + + if (elem_klass == nullptr || shuffle_klass == nullptr || shuffle->is_top() || vlen == nullptr || + !vlen->is_con() || shuffle_klass->const_oop() == nullptr) { + // not enough info for intrinsification + return false; + } + + if (!is_klass_initialized(shuffle_klass)) { + log_if_needed(" ** klass argument not initialized"); + return false; + } + + int num_elem = vlen->get_con(); + if ((num_elem < 4) || !is_power_of_2(num_elem)) { + log_if_needed(" ** vlen < 4 or not power of two=%d", num_elem); + return false; + } + + // Shuffles use byte array based backing storage + BasicType shuffle_bt = T_BYTE; + if (!arch_supports_vector(Op_AndV, num_elem, shuffle_bt, VecMaskNotUsed) || + !arch_supports_vector(Op_Replicate, num_elem, shuffle_bt, VecMaskNotUsed)) { + log_if_needed(" ** not supported: op=wrapShuffleIndexes vlen=%d etype=%s", + num_elem, type2name(shuffle_bt)); + return false; + } + + ciKlass* sbox_klass = shuffle_klass->const_oop()->as_instance()->java_lang_Class_klass(); + const TypeInstPtr* shuffle_box_type = TypeInstPtr::make_exact(TypePtr::NotNull, sbox_klass); + + // Unbox shuffle with true flag to indicate its load shuffle to vector + // shuffle is a byte array + Node* shuffle_vec = unbox_vector(shuffle, shuffle_box_type, shuffle_bt, num_elem, true); + + const TypeVect* vt = TypeVect::make(shuffle_bt, num_elem); + Node* mod_mask = gvn().makecon(TypeInt::make(num_elem - 1)); + Node* bcast_mod_mask = gvn().transform(VectorNode::scalar2vector(mod_mask, num_elem, shuffle_bt)); + // Wrap the indices greater than lane count. + Node* res = gvn().transform(VectorNode::make(Op_AndV, shuffle_vec, bcast_mod_mask, vt)); + + // Wrap it up in VectorBox to keep object type information. + res = box_vector(res, shuffle_box_type, shuffle_bt, num_elem); + set_result(res); + C->set_max_vector_size(MAX2(C->max_vector_size(), (uint)(num_elem * type2aelembytes(shuffle_bt)))); + return true; +} + // public static // , @@ -850,7 +905,7 @@ bool LibraryCallKit::inline_vector_frombits_coerced() { } default: fatal("%s", type2name(elem_bt)); } - broadcast = VectorNode::scalar2vector(elem, num_elem, Type::get_const_basic_type(elem_bt), is_mask); + broadcast = VectorNode::scalar2vector(elem, num_elem, elem_bt, is_mask); broadcast = gvn().transform(broadcast); } @@ -1294,7 +1349,7 @@ bool LibraryCallKit::inline_vector_mem_masked_operation(bool is_store) { } else { // Use the vector blend to implement the masked load vector. The biased elements are zeros. Node* zero = gvn().transform(gvn().zerocon(mem_elem_bt)); - zero = gvn().transform(VectorNode::scalar2vector(zero, mem_num_elem, Type::get_const_basic_type(mem_elem_bt))); + zero = gvn().transform(VectorNode::scalar2vector(zero, mem_num_elem, mem_elem_bt)); vload = gvn().transform(LoadVectorNode::make(0, control(), memory(addr), addr, addr_type, mem_num_elem, mem_elem_bt)); vload = gvn().transform(new VectorBlendNode(zero, vload, mask)); } @@ -1620,7 +1675,7 @@ bool LibraryCallKit::inline_vector_reduction() { assert(mask != nullptr || !is_masked_op, "Masked op needs the mask value never null"); if (mask != nullptr && !use_predicate) { - Node* reduce_identity = gvn().transform(VectorNode::scalar2vector(init, num_elem, Type::get_const_basic_type(elem_bt))); + Node* reduce_identity = gvn().transform(VectorNode::scalar2vector(init, num_elem, elem_bt)); value = gvn().transform(new VectorBlendNode(reduce_identity, value, mask)); } @@ -2001,7 +2056,7 @@ bool LibraryCallKit::inline_vector_rearrange() { const TypeVect* vt = v1->bottom_type()->is_vect(); rearrange = gvn().transform(rearrange); Node* zero = gvn().makecon(Type::get_zero_type(elem_bt)); - Node* zerovec = gvn().transform(VectorNode::scalar2vector(zero, num_elem, Type::get_const_basic_type(elem_bt))); + Node* zerovec = gvn().transform(VectorNode::scalar2vector(zero, num_elem, elem_bt)); rearrange = new VectorBlendNode(zerovec, rearrange, mask); } } @@ -2013,12 +2068,12 @@ bool LibraryCallKit::inline_vector_rearrange() { return true; } -static address get_svml_address(int vop, int bits, BasicType bt, char* name_ptr, int name_len) { +static address get_vector_math_address(int vop, int bits, BasicType bt, char* name_ptr, int name_len) { address addr = nullptr; assert(UseVectorStubs, "sanity"); assert(name_ptr != nullptr, "unexpected"); - assert((vop >= VectorSupport::VECTOR_OP_SVML_START) && (vop <= VectorSupport::VECTOR_OP_SVML_END), "unexpected"); - int op = vop - VectorSupport::VECTOR_OP_SVML_START; + assert((vop >= VectorSupport::VECTOR_OP_MATH_START) && (vop <= VectorSupport::VECTOR_OP_MATH_END), "unexpected"); + int op = vop - VectorSupport::VECTOR_OP_MATH_START; switch(bits) { case 64: //fallthough @@ -2026,34 +2081,190 @@ static address get_svml_address(int vop, int bits, BasicType bt, char* name_ptr, case 256: //fallthough case 512: if (bt == T_FLOAT) { - snprintf(name_ptr, name_len, "vector_%s_float%d", VectorSupport::svmlname[op], bits); + snprintf(name_ptr, name_len, "vector_%s_float_%dbits_fixed", VectorSupport::mathname[op], bits); addr = StubRoutines::_vector_f_math[exact_log2(bits/64)][op]; } else { assert(bt == T_DOUBLE, "must be FP type only"); - snprintf(name_ptr, name_len, "vector_%s_double%d", VectorSupport::svmlname[op], bits); + snprintf(name_ptr, name_len, "vector_%s_double_%dbits_fixed", VectorSupport::mathname[op], bits); addr = StubRoutines::_vector_d_math[exact_log2(bits/64)][op]; } break; default: - snprintf(name_ptr, name_len, "invalid"); - addr = nullptr; - Unimplemented(); + if (!Matcher::supports_scalable_vector() || !Matcher::vector_size_supported(bt, bits/type2aelembytes(bt)) ) { + snprintf(name_ptr, name_len, "invalid"); + addr = nullptr; + Unimplemented(); + } break; } + if (addr == nullptr && Matcher::supports_scalable_vector()) { + if (bt == T_FLOAT) { + snprintf(name_ptr, name_len, "vector_%s_float_%dbits_scalable", VectorSupport::mathname[op], bits); + addr = StubRoutines::_vector_f_math[VectorSupport::VEC_SIZE_SCALABLE][op]; + } else { + assert(bt == T_DOUBLE, "must be FP type only"); + snprintf(name_ptr, name_len, "vector_%s_double_%dbits_scalable", VectorSupport::mathname[op], bits); + addr = StubRoutines::_vector_d_math[VectorSupport::VEC_SIZE_SCALABLE][op]; + } + } + return addr; } -Node* LibraryCallKit::gen_call_to_svml(int vector_api_op_id, BasicType bt, int num_elem, Node* opd1, Node* opd2) { +// public static +// , +// M extends VectorMask, +// E> +// V selectFromOp(Class vClass, Class mClass, Class eClass, +// int length, V v1, V v2, M m, +// VectorSelectFromOp defaultImpl) +bool LibraryCallKit::inline_vector_select_from() { + const TypeInstPtr* vector_klass = gvn().type(argument(0))->isa_instptr(); + const TypeInstPtr* mask_klass = gvn().type(argument(1))->isa_instptr(); + const TypeInstPtr* elem_klass = gvn().type(argument(2))->isa_instptr(); + const TypeInt* vlen = gvn().type(argument(3))->isa_int(); + + if (vector_klass == nullptr || elem_klass == nullptr || vlen == nullptr || + vector_klass->const_oop() == nullptr || + elem_klass->const_oop() == nullptr || + !vlen->is_con()) { + log_if_needed(" ** missing constant: vclass=%s etype=%s vlen=%s", + NodeClassNames[argument(0)->Opcode()], + NodeClassNames[argument(2)->Opcode()], + NodeClassNames[argument(3)->Opcode()]); + return false; // not enough info for intrinsification + } + if (!is_klass_initialized(vector_klass)) { + log_if_needed(" ** klass argument not initialized"); + return false; + } + ciType* elem_type = elem_klass->const_oop()->as_instance()->java_mirror_type(); + if (!elem_type->is_primitive_type()) { + log_if_needed(" ** not a primitive bt=%d", elem_type->basic_type()); + return false; // should be primitive type + } + BasicType elem_bt = elem_type->basic_type(); + int num_elem = vlen->get_con(); + if (!is_power_of_2(num_elem)) { + log_if_needed(" ** vlen not power of two=%d", num_elem); + return false; + } + + int cast_vopc = VectorCastNode::opcode(-1, elem_bt); // from vector of type elem_bt + if (!arch_supports_vector(Op_VectorLoadShuffle, num_elem, elem_bt, VecMaskNotUsed)|| + !arch_supports_vector(Op_AndV, num_elem, T_BYTE, VecMaskNotUsed) || + !arch_supports_vector(Op_Replicate, num_elem, T_BYTE, VecMaskNotUsed) || + !arch_supports_vector(cast_vopc, num_elem, T_BYTE, VecMaskNotUsed)) { + log_if_needed(" ** not supported: arity=0 op=selectFrom vlen=%d etype=%s ismask=no", + num_elem, type2name(elem_bt)); + return false; // not supported + } + + bool is_masked_op = argument(6)->bottom_type() != TypePtr::NULL_PTR; + bool use_predicate = is_masked_op; + if (is_masked_op && + (mask_klass == nullptr || + mask_klass->const_oop() == nullptr || + !is_klass_initialized(mask_klass))) { + log_if_needed(" ** mask_klass argument not initialized"); + return false; // not supported + } + VectorMaskUseType checkFlags = (VectorMaskUseType)(is_masked_op ? (VecMaskUseLoad | VecMaskUsePred) : VecMaskNotUsed); + if (!arch_supports_vector(Op_VectorRearrange, num_elem, elem_bt, checkFlags)) { + use_predicate = false; + if(!is_masked_op || + (!arch_supports_vector(Op_VectorRearrange, num_elem, elem_bt, VecMaskNotUsed) || + !arch_supports_vector(Op_VectorBlend, num_elem, elem_bt, VecMaskUseLoad) || + !arch_supports_vector(Op_Replicate, num_elem, elem_bt, VecMaskNotUsed))) { + log_if_needed(" ** not supported: op=selectFrom vlen=%d etype=%s is_masked_op=%d", + num_elem, type2name(elem_bt), is_masked_op); + return false; // not supported + } + } + ciKlass* vbox_klass = vector_klass->const_oop()->as_instance()->java_lang_Class_klass(); + const TypeInstPtr* vbox_type = TypeInstPtr::make_exact(TypePtr::NotNull, vbox_klass); + + // v1 is the index vector + Node* v1 = unbox_vector(argument(4), vbox_type, elem_bt, num_elem); + // v2 is the vector being rearranged + Node* v2 = unbox_vector(argument(5), vbox_type, elem_bt, num_elem); + + if (v1 == nullptr) { + log_if_needed(" ** unbox failed v1=%s", NodeClassNames[argument(4)->Opcode()]); + return false; // operand unboxing failed + } + + if (v2 == nullptr) { + log_if_needed(" ** unbox failed v2=%s", NodeClassNames[argument(5)->Opcode()]); + return false; // operand unboxing failed + } + + Node* mask = nullptr; + if (is_masked_op) { + ciKlass* mbox_klass = mask_klass->const_oop()->as_instance()->java_lang_Class_klass(); + const TypeInstPtr* mbox_type = TypeInstPtr::make_exact(TypePtr::NotNull, mbox_klass); + mask = unbox_vector(argument(6), mbox_type, elem_bt, num_elem); + if (mask == nullptr) { + log_if_needed(" ** unbox failed mask=%s", NodeClassNames[argument(6)->Opcode()]); + return false; + } + } + + // cast index vector from elem_bt vector to byte vector + const TypeVect* byte_vt = TypeVect::make(T_BYTE, num_elem); + Node* byte_shuffle = gvn().transform(VectorCastNode::make(cast_vopc, v1, T_BYTE, num_elem)); + + // wrap the byte vector lanes to (num_elem - 1) to form the shuffle vector where num_elem is vector length + // this is a simple AND operation as we come here only for power of two vector length + Node* mod_val = gvn().makecon(TypeInt::make(num_elem-1)); + Node* bcast_mod = gvn().transform(VectorNode::scalar2vector(mod_val, num_elem, T_BYTE)); + byte_shuffle = gvn().transform(VectorNode::make(Op_AndV, byte_shuffle, bcast_mod, byte_vt)); + + // load the shuffle to use in rearrange + const TypeVect* shuffle_vt = TypeVect::make(elem_bt, num_elem); + Node* load_shuffle = gvn().transform(new VectorLoadShuffleNode(byte_shuffle, shuffle_vt)); + + // and finally rearrange + Node* rearrange = new VectorRearrangeNode(v2, load_shuffle); + if (is_masked_op) { + if (use_predicate) { + // masked rearrange is supported so use that directly + rearrange->add_req(mask); + rearrange->add_flag(Node::Flag_is_predicated_vector); + } else { + // masked rearrange is not supported so emulate usig blend + const TypeVect* vt = v1->bottom_type()->is_vect(); + rearrange = gvn().transform(rearrange); + + // create a zero vector with each lane element set as zero + Node* zero = gvn().makecon(Type::get_zero_type(elem_bt)); + Node* zerovec = gvn().transform(VectorNode::scalar2vector(zero, num_elem, elem_bt)); + + // For each lane for which mask is set, blend in the rearranged lane into zero vector + rearrange = new VectorBlendNode(zerovec, rearrange, mask); + } + } + rearrange = gvn().transform(rearrange); + + // box the result + Node* box = box_vector(rearrange, vbox_type, elem_bt, num_elem); + set_result(box); + + C->set_max_vector_size(MAX2(C->max_vector_size(), (uint)(num_elem * type2aelembytes(elem_bt)))); + return true; +} + +Node* LibraryCallKit::gen_call_to_vector_math(int vector_api_op_id, BasicType bt, int num_elem, Node* opd1, Node* opd2) { assert(UseVectorStubs, "sanity"); - assert(vector_api_op_id >= VectorSupport::VECTOR_OP_SVML_START && vector_api_op_id <= VectorSupport::VECTOR_OP_SVML_END, "need valid op id"); + assert(vector_api_op_id >= VectorSupport::VECTOR_OP_MATH_START && vector_api_op_id <= VectorSupport::VECTOR_OP_MATH_END, "need valid op id"); assert(opd1 != nullptr, "must not be null"); const TypeVect* vt = TypeVect::make(bt, num_elem); const TypeFunc* call_type = OptoRuntime::Math_Vector_Vector_Type(opd2 != nullptr ? 2 : 1, vt, vt); char name[100] = ""; - // Get address for svml method. - address addr = get_svml_address(vector_api_op_id, vt->length_in_bytes() * BitsPerByte, bt, name, 100); + // Get address for vector math method. + address addr = get_vector_math_address(vector_api_op_id, vt->length_in_bytes() * BitsPerByte, bt, name, 100); if (addr == nullptr) { return nullptr; @@ -2176,9 +2387,8 @@ bool LibraryCallKit::inline_vector_broadcast_int() { } else { assert(is_rotate, "unexpected operation"); if (!is_const_rotate) { - const Type * type_bt = Type::get_const_basic_type(elem_bt); cnt = elem_bt == T_LONG ? gvn().transform(new ConvI2LNode(cnt)) : cnt; - opd2 = gvn().transform(VectorNode::scalar2vector(cnt, num_elem, type_bt)); + opd2 = gvn().transform(VectorNode::scalar2vector(cnt, num_elem, elem_bt)); } else { // Constant shift value. opd2 = cnt; @@ -2836,7 +3046,7 @@ bool LibraryCallKit::inline_index_vector() { } default: fatal("%s", type2name(elem_bt)); } - scale = gvn().transform(VectorNode::scalar2vector(scale, num_elem, Type::get_const_basic_type(elem_bt))); + scale = gvn().transform(VectorNode::scalar2vector(scale, num_elem, elem_bt)); index = gvn().transform(VectorNode::make(vmul_op, index, scale, vt)); } @@ -2949,7 +3159,7 @@ bool LibraryCallKit::inline_index_partially_in_upper_range() { } default: fatal("%s", type2name(elem_bt)); } - indexLimit = gvn().transform(VectorNode::scalar2vector(indexLimit, num_elem, Type::get_const_basic_type(elem_bt))); + indexLimit = gvn().transform(VectorNode::scalar2vector(indexLimit, num_elem, elem_bt)); // Load the "iota" vector. const TypeVect* vt = TypeVect::make(elem_bt, num_elem); diff --git a/src/hotspot/share/opto/vectornode.cpp b/src/hotspot/share/opto/vectornode.cpp index 72b49c043b6..094d4dca564 100644 --- a/src/hotspot/share/opto/vectornode.cpp +++ b/src/hotspot/share/opto/vectornode.cpp @@ -799,15 +799,13 @@ VectorNode* VectorNode::make(int opc, Node* n1, Node* n2, Node* n3, uint vlen, B } // Scalar promotion -VectorNode* VectorNode::scalar2vector(Node* s, uint vlen, const Type* opd_t, bool is_mask) { - BasicType bt = opd_t->array_element_basic_type(); +VectorNode* VectorNode::scalar2vector(Node* s, uint vlen, BasicType bt, bool is_mask) { if (is_mask && Matcher::match_rule_supported_vector(Op_MaskAll, vlen, bt)) { - const TypeVect* vt = TypeVect::make(opd_t, vlen, true); + const TypeVect* vt = TypeVect::make(bt, vlen, true); return new MaskAllNode(s, vt); } - const TypeVect* vt = opd_t->singleton() ? TypeVect::make(opd_t, vlen) - : TypeVect::make(bt, vlen); + const TypeVect* vt = TypeVect::make(bt, vlen); return new ReplicateNode(s, vt); } @@ -1626,8 +1624,6 @@ Node* VectorNode::degenerate_vector_rotate(Node* src, Node* cnt, bool is_rotate_ Node* const_one_node = nullptr; assert(cnt->bottom_type()->isa_vect(), "Unexpected shift"); - const Type* elem_ty = Type::get_const_basic_type(bt); - if (bt == T_LONG) { shift_mask_node = phase->longcon(shift_mask); const_one_node = phase->longcon(1L); @@ -1639,8 +1635,8 @@ Node* VectorNode::degenerate_vector_rotate(Node* src, Node* cnt, bool is_rotate_ subVopc = VectorNode::opcode(Op_SubI, bt); addVopc = VectorNode::opcode(Op_AddI, bt); } - Node* vector_mask = phase->transform(VectorNode::scalar2vector(shift_mask_node, vlen, elem_ty)); - Node* vector_one = phase->transform(VectorNode::scalar2vector(const_one_node, vlen, elem_ty)); + Node* vector_mask = phase->transform(VectorNode::scalar2vector(shift_mask_node, vlen, bt)); + Node* vector_one = phase->transform(VectorNode::scalar2vector(const_one_node, vlen, bt)); shiftRCnt = cnt; shiftRCnt = phase->transform(VectorNode::make(Op_AndV, shiftRCnt, vector_mask, vt)); @@ -1882,12 +1878,12 @@ Node* NegVNode::degenerate_integral_negate(PhaseGVN* phase, bool is_predicated) const_one = phase->intcon(1); add_opc = Op_AddI; } - const_minus_one = phase->transform(VectorNode::scalar2vector(const_minus_one, vlen, Type::get_const_basic_type(bt))); + const_minus_one = phase->transform(VectorNode::scalar2vector(const_minus_one, vlen, bt)); Node* xorv = VectorNode::make(Op_XorV, in(1), const_minus_one, vt); xorv->add_req(in(2)); xorv->add_flag(Node::Flag_is_predicated_vector); phase->transform(xorv); - const_one = phase->transform(VectorNode::scalar2vector(const_one, vlen, Type::get_const_basic_type(bt))); + const_one = phase->transform(VectorNode::scalar2vector(const_one, vlen, bt)); Node* addv = VectorNode::make(VectorNode::opcode(add_opc, bt), xorv, const_one, vt); addv->add_req(in(2)); addv->add_flag(Node::Flag_is_predicated_vector); @@ -1904,7 +1900,7 @@ Node* NegVNode::degenerate_integral_negate(PhaseGVN* phase, bool is_predicated) const_zero = phase->intcon(0); sub_opc = Op_SubI; } - const_zero = phase->transform(VectorNode::scalar2vector(const_zero, vlen, Type::get_const_basic_type(bt))); + const_zero = phase->transform(VectorNode::scalar2vector(const_zero, vlen, bt)); return VectorNode::make(VectorNode::opcode(sub_opc, bt), const_zero, in(1), vt); } @@ -2069,8 +2065,7 @@ Node* XorVNode::Ideal(PhaseGVN* phase, bool can_reshape) { if (!is_predicated_vector() && (in(1) == in(2))) { BasicType bt = vect_type()->element_basic_type(); Node* zero = phase->transform(phase->zerocon(bt)); - return VectorNode::scalar2vector(zero, length(), Type::get_const_basic_type(bt), - bottom_type()->isa_vectmask() != nullptr); + return VectorNode::scalar2vector(zero, length(), bt, bottom_type()->isa_vectmask() != nullptr); } return nullptr; } diff --git a/src/hotspot/share/opto/vectornode.hpp b/src/hotspot/share/opto/vectornode.hpp index 23ddebaf338..d23e6b8c926 100644 --- a/src/hotspot/share/opto/vectornode.hpp +++ b/src/hotspot/share/opto/vectornode.hpp @@ -75,7 +75,7 @@ class VectorNode : public TypeNode { virtual Node* Ideal(PhaseGVN* phase, bool can_reshape); - static VectorNode* scalar2vector(Node* s, uint vlen, const Type* opd_t, bool is_mask = false); + static VectorNode* scalar2vector(Node* s, uint vlen, BasicType bt, bool is_mask = false); static VectorNode* shift_count(int opc, Node* cnt, uint vlen, BasicType bt); static VectorNode* make(int opc, Node* n1, Node* n2, uint vlen, BasicType bt, bool is_var_shift = false); static VectorNode* make(int vopc, Node* n1, Node* n2, const TypeVect* vt, bool is_mask = false, bool is_var_shift = false); diff --git a/src/hotspot/share/opto/vtransform.cpp b/src/hotspot/share/opto/vtransform.cpp index e40157caa36..7c7aca3b90e 100644 --- a/src/hotspot/share/opto/vtransform.cpp +++ b/src/hotspot/share/opto/vtransform.cpp @@ -422,8 +422,7 @@ void VTransformScalarNode::print_spec() const { } void VTransformReplicateNode::print_spec() const { - tty->print("vlen=%d element_type=", _vlen); - _element_type->dump(); + tty->print("vlen=%d element_type=%s", _vlen, type2name(_element_type)); } void VTransformShiftCountNode::print_spec() const { diff --git a/src/hotspot/share/opto/vtransform.hpp b/src/hotspot/share/opto/vtransform.hpp index 071674533a7..ee298e7fe72 100644 --- a/src/hotspot/share/opto/vtransform.hpp +++ b/src/hotspot/share/opto/vtransform.hpp @@ -354,9 +354,9 @@ public: class VTransformReplicateNode : public VTransformNode { private: int _vlen; - const Type* _element_type; + BasicType _element_type; public: - VTransformReplicateNode(VTransform& vtransform, int vlen, const Type* element_type) : + VTransformReplicateNode(VTransform& vtransform, int vlen, BasicType element_type) : VTransformNode(vtransform, 2), _vlen(vlen), _element_type(element_type) {} virtual VTransformApplyResult apply(const VLoopAnalyzer& vloop_analyzer, const GrowableArray& vnode_idx_to_transformed_node) const override; diff --git a/src/hotspot/share/prims/jni.cpp b/src/hotspot/share/prims/jni.cpp index fbb2c6e3e08..a869e9821a0 100644 --- a/src/hotspot/share/prims/jni.cpp +++ b/src/hotspot/share/prims/jni.cpp @@ -444,9 +444,11 @@ JNI_ENTRY(jobject, jni_ToReflectedMethod(JNIEnv *env, jclass cls, jmethodID meth methodHandle m (THREAD, Method::resolve_jmethod_id(method_id)); assert(m->is_static() == (isStatic != 0), "jni_ToReflectedMethod access flags doesn't match"); oop reflection_method; - if (m->is_initializer()) { + if (m->is_object_initializer()) { reflection_method = Reflection::new_constructor(m, CHECK_NULL); } else { + // Note: Static initializers can theoretically be here, if JNI users manage + // to get their jmethodID. Record them as plain methods. reflection_method = Reflection::new_method(m, false, CHECK_NULL); } ret = JNIHandles::make_local(THREAD, reflection_method); @@ -2409,7 +2411,7 @@ static char* get_bad_address() { if (bad_address != nullptr) { os::protect_memory(bad_address, size, os::MEM_PROT_READ, /*is_committed*/false); - MemTracker::record_virtual_memory_type((void*)bad_address, mtInternal); + MemTracker::record_virtual_memory_tag((void*)bad_address, mtInternal); } } return bad_address; diff --git a/src/hotspot/share/prims/jniCheck.cpp b/src/hotspot/share/prims/jniCheck.cpp index 87543686c3c..8c1f9f53b34 100644 --- a/src/hotspot/share/prims/jniCheck.cpp +++ b/src/hotspot/share/prims/jniCheck.cpp @@ -475,7 +475,7 @@ void jniCheck::validate_class_descriptor(JavaThread* thr, const char* name) { } // Verify that the class name given is a valid utf8 string - if (!UTF8::is_legal_utf8((const unsigned char*)name, (int)strlen(name), false)) { + if (!UTF8::is_legal_utf8((const unsigned char*)name, strlen(name), false)) { char msg[JVM_MAXPATHLEN]; jio_snprintf(msg, JVM_MAXPATHLEN, "%s%s%s", fatal_non_utf8_class_name1, name, fatal_non_utf8_class_name2); ReportJNIFatalError(thr, msg); diff --git a/src/hotspot/share/prims/jvm.cpp b/src/hotspot/share/prims/jvm.cpp index 6425f5f583f..5d5d8aa7df9 100644 --- a/src/hotspot/share/prims/jvm.cpp +++ b/src/hotspot/share/prims/jvm.cpp @@ -809,7 +809,7 @@ JVM_ENTRY(jclass, JVM_FindClassFromBootLoader(JNIEnv* env, // into the constant pool. return nullptr; } - assert(UTF8::is_legal_utf8((const unsigned char*)name, (int)strlen(name), false), "illegal UTF name"); + assert(UTF8::is_legal_utf8((const unsigned char*)name, strlen(name), false), "illegal UTF name"); TempNewSymbol h_name = SymbolTable::new_symbol(name); Klass* k = SystemDictionary::resolve_or_null(h_name, CHECK_NULL); @@ -1826,14 +1826,6 @@ JVM_ENTRY(jobjectArray, JVM_GetRecordComponents(JNIEnv* env, jclass ofClass)) } JVM_END -static bool select_method(const methodHandle& method, bool want_constructor) { - if (want_constructor) { - return (method->is_initializer() && !method->is_static()); - } else { - return (!method->is_initializer() && !method->is_overpass()); - } -} - static jobjectArray get_class_declared_methods_helper( JNIEnv *env, jclass ofClass, jboolean publicOnly, @@ -1866,14 +1858,22 @@ static jobjectArray get_class_declared_methods_helper( GrowableArray* idnums = new GrowableArray(methods_length); int num_methods = 0; + // Select methods matching the criteria. for (int i = 0; i < methods_length; i++) { - methodHandle method(THREAD, methods->at(i)); - if (select_method(method, want_constructor)) { - if (!publicOnly || method->is_public()) { - idnums->push(method->method_idnum()); - ++num_methods; - } + Method* method = methods->at(i); + if (want_constructor && !method->is_object_initializer()) { + continue; } + if (!want_constructor && + (method->is_object_initializer() || method->is_static_initializer() || + method->is_overpass())) { + continue; + } + if (publicOnly && !method->is_public()) { + continue; + } + idnums->push(method->method_idnum()); + ++num_methods; } // Allocate result @@ -2175,10 +2175,11 @@ static jobject get_method_at_helper(const constantPoolHandle& cp, jint index, bo THROW_MSG_NULL(vmSymbols::java_lang_RuntimeException(), "Unable to look up method in target class"); } oop method; - if (!m->is_initializer() || m->is_static()) { - method = Reflection::new_method(m, true, CHECK_NULL); - } else { + if (m->is_object_initializer()) { method = Reflection::new_constructor(m, CHECK_NULL); + } else { + // new_method accepts as Method here + method = Reflection::new_method(m, true, CHECK_NULL); } return JNIHandles::make_local(THREAD, method); } @@ -2947,9 +2948,10 @@ JVM_ENTRY(void, JVM_StartThread(JNIEnv* env, jobject jthread)) // We must release the Threads_lock before we can post a jvmti event // in Thread::start. { + ConditionalMutexLocker throttle_ml(ThreadsLockThrottle_lock, UseThreadsLockThrottleLock); // Ensure that the C++ Thread and OSThread structures aren't freed before // we operate. - MutexLocker mu(Threads_lock); + MutexLocker ml(Threads_lock); // Since JDK 5 the java.lang.Thread threadStatus is used to prevent // re-starting an already started thread, so we should usually find diff --git a/src/hotspot/share/prims/jvmtiAgentList.hpp b/src/hotspot/share/prims/jvmtiAgentList.hpp index 671def02681..d53f5e63d9b 100644 --- a/src/hotspot/share/prims/jvmtiAgentList.hpp +++ b/src/hotspot/share/prims/jvmtiAgentList.hpp @@ -25,7 +25,7 @@ #ifndef SHARE_PRIMS_JVMTIAGENTLIST_HPP #define SHARE_PRIMS_JVMTIAGENTLIST_HPP -#include "nmt/memflags.hpp" +#include "nmt/memTag.hpp" #include "prims/jvmtiAgent.hpp" #include "utilities/growableArray.hpp" diff --git a/src/hotspot/share/prims/jvmtiEnv.cpp b/src/hotspot/share/prims/jvmtiEnv.cpp index a36d12059a9..097ce331540 100644 --- a/src/hotspot/share/prims/jvmtiEnv.cpp +++ b/src/hotspot/share/prims/jvmtiEnv.cpp @@ -3132,7 +3132,9 @@ JvmtiEnv::GetFieldName(fieldDescriptor* fdesc_ptr, char** name_ptr, char** signa // declaring_class_ptr - pre-checked for null jvmtiError JvmtiEnv::GetFieldDeclaringClass(fieldDescriptor* fdesc_ptr, jclass* declaring_class_ptr) { - + // As for the GetFieldDeclaringClass method, the XSL generated C++ code that calls it has + // a jclass of the relevant class or a subclass of it, which is fine in terms of ensuring + // the holder is kept alive. *declaring_class_ptr = get_jni_class_non_null(fdesc_ptr->field_holder()); return JVMTI_ERROR_NONE; } /* end GetFieldDeclaringClass */ @@ -3210,7 +3212,9 @@ JvmtiEnv::GetMethodName(Method* method, char** name_ptr, char** signature_ptr, c jvmtiError JvmtiEnv::GetMethodDeclaringClass(Method* method, jclass* declaring_class_ptr) { NULL_CHECK(method, JVMTI_ERROR_INVALID_METHODID); - (*declaring_class_ptr) = get_jni_class_non_null(method->method_holder()); + Klass* k = method->method_holder(); + Handle holder(Thread::current(), k->klass_holder()); // keep the klass alive + (*declaring_class_ptr) = get_jni_class_non_null(k); return JVMTI_ERROR_NONE; } /* end GetMethodDeclaringClass */ diff --git a/src/hotspot/share/prims/jvmtiEnvBase.cpp b/src/hotspot/share/prims/jvmtiEnvBase.cpp index a05d6998093..167ca557cde 100644 --- a/src/hotspot/share/prims/jvmtiEnvBase.cpp +++ b/src/hotspot/share/prims/jvmtiEnvBase.cpp @@ -599,6 +599,7 @@ JvmtiEnvBase::jvf_for_thread_and_depth(JavaThread* java_thread, jint depth) { jclass JvmtiEnvBase::get_jni_class_non_null(Klass* k) { assert(k != nullptr, "k != null"); + assert(k->is_loader_alive(), "Must be alive"); Thread *thread = Thread::current(); return (jclass)jni_reference(Handle(thread, k->java_mirror())); } diff --git a/src/hotspot/share/prims/methodHandles.cpp b/src/hotspot/share/prims/methodHandles.cpp index 4f33055d6a3..498da559cf5 100644 --- a/src/hotspot/share/prims/methodHandles.cpp +++ b/src/hotspot/share/prims/methodHandles.cpp @@ -313,8 +313,9 @@ oop MethodHandles::init_method_MemberName(Handle mname, CallInfo& info) { case CallInfo::direct_call: vmindex = Method::nonvirtual_vtable_index; if (m->is_static()) { + assert(!m->is_static_initializer(), "Cannot be static initializer"); flags |= IS_METHOD | (JVM_REF_invokeStatic << REFERENCE_KIND_SHIFT); - } else if (m->is_initializer()) { + } else if (m->is_object_initializer()) { flags |= IS_CONSTRUCTOR | (JVM_REF_invokeSpecial << REFERENCE_KIND_SHIFT); } else { // "special" reflects that this is a direct call, not that it diff --git a/src/hotspot/share/prims/upcallLinker.cpp b/src/hotspot/share/prims/upcallLinker.cpp index b02746911a8..1abce57652a 100644 --- a/src/hotspot/share/prims/upcallLinker.cpp +++ b/src/hotspot/share/prims/upcallLinker.cpp @@ -22,7 +22,7 @@ */ #include "precompiled.hpp" -#include "classfile/javaClasses.hpp" +#include "classfile/javaClasses.inline.hpp" #include "classfile/symbolTable.hpp" #include "classfile/systemDictionary.hpp" #include "compiler/compilationPolicy.hpp" @@ -73,7 +73,7 @@ JavaThread* UpcallLinker::maybe_attach_and_get_thread() { } // modelled after JavaCallWrapper::JavaCallWrapper -JavaThread* UpcallLinker::on_entry(UpcallStub::FrameData* context, jobject receiver) { +JavaThread* UpcallLinker::on_entry(UpcallStub::FrameData* context) { JavaThread* thread = maybe_attach_and_get_thread(); guarantee(thread->thread_state() == _thread_in_native, "wrong thread state for upcall"); context->thread = thread; @@ -108,8 +108,6 @@ JavaThread* UpcallLinker::on_entry(UpcallStub::FrameData* context, jobject recei debug_only(thread->inc_java_call_counter()); thread->set_active_handles(context->new_handles); // install new handle block and reset Java frame linkage - thread->set_vm_result(JNIHandles::resolve(receiver)); - return thread; } @@ -138,11 +136,10 @@ void UpcallLinker::on_exit(UpcallStub::FrameData* context) { } void UpcallLinker::handle_uncaught_exception(oop exception) { - ResourceMark rm; - // Based on CATCH macro tty->print_cr("Uncaught exception:"); - exception->print(); - ShouldNotReachHere(); + Handle exception_h(Thread::current(), exception); + java_lang_Throwable::print_stack_trace(exception_h, tty); + fatal("Unrecoverable uncaught exception encountered"); } JVM_ENTRY(jlong, UL_MakeUpcallStub(JNIEnv *env, jclass unused, jobject mh, jobject abi, jobject conv, @@ -150,36 +147,30 @@ JVM_ENTRY(jlong, UL_MakeUpcallStub(JNIEnv *env, jclass unused, jobject mh, jobje ResourceMark rm(THREAD); Handle mh_h(THREAD, JNIHandles::resolve(mh)); jobject mh_j = JNIHandles::make_global(mh_h); + oop type = java_lang_invoke_MethodHandle::type(mh_h()); - oop lform = java_lang_invoke_MethodHandle::form(mh_h()); - oop vmentry = java_lang_invoke_LambdaForm::vmentry(lform); - Method* entry = java_lang_invoke_MemberName::vmtarget(vmentry); - const methodHandle mh_entry(THREAD, entry); - - assert(entry->method_holder()->is_initialized(), "no clinit barrier"); - CompilationPolicy::compile_if_required(mh_entry, CHECK_0); - - assert(entry->is_static(), "static only"); // Fill in the signature array, for the calling-convention call. - const int total_out_args = entry->size_of_parameters(); - assert(total_out_args > 0, "receiver arg"); + const int total_out_args = java_lang_invoke_MethodType::ptype_slot_count(type) + 1; // +1 for receiver + bool create_new = true; + TempNewSymbol signature = java_lang_invoke_MethodType::as_signature(type, create_new); BasicType* out_sig_bt = NEW_RESOURCE_ARRAY(BasicType, total_out_args); BasicType ret_type; { int i = 0; - SignatureStream ss(entry->signature()); + out_sig_bt[i++] = T_OBJECT; // receiver MH + SignatureStream ss(signature); for (; !ss.at_return_type(); ss.next()) { out_sig_bt[i++] = ss.type(); // Collect remaining bits of signature if (ss.type() == T_LONG || ss.type() == T_DOUBLE) out_sig_bt[i++] = T_VOID; // Longs & doubles take 2 Java slots } - assert(i == total_out_args, ""); + assert(i == total_out_args, "%d != %d", i, total_out_args); ret_type = ss.type(); } return (jlong) UpcallLinker::make_upcall_stub( - mh_j, entry, out_sig_bt, total_out_args, ret_type, + mh_j, signature, out_sig_bt, total_out_args, ret_type, abi, conv, needs_return_buffer, checked_cast(ret_buf_size)); JVM_END diff --git a/src/hotspot/share/prims/upcallLinker.hpp b/src/hotspot/share/prims/upcallLinker.hpp index d80516b2566..765ed63fc5a 100644 --- a/src/hotspot/share/prims/upcallLinker.hpp +++ b/src/hotspot/share/prims/upcallLinker.hpp @@ -34,10 +34,10 @@ class UpcallLinker { private: static JavaThread* maybe_attach_and_get_thread(); - static JavaThread* on_entry(UpcallStub::FrameData* context, jobject receiver); + static JavaThread* on_entry(UpcallStub::FrameData* context); static void on_exit(UpcallStub::FrameData* context); public: - static address make_upcall_stub(jobject mh, Method* entry, + static address make_upcall_stub(jobject mh, Symbol* signature, BasicType* out_sig_bt, int total_out_args, BasicType ret_type, jobject jabi, jobject jconv, diff --git a/src/hotspot/share/prims/vectorSupport.cpp b/src/hotspot/share/prims/vectorSupport.cpp index e0517c91e95..65bc6c48fee 100644 --- a/src/hotspot/share/prims/vectorSupport.cpp +++ b/src/hotspot/share/prims/vectorSupport.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -43,7 +43,7 @@ #endif // COMPILER2 #ifdef COMPILER2 -const char* VectorSupport::svmlname[VectorSupport::NUM_SVML_OP] = { +const char* VectorSupport::mathname[VectorSupport::NUM_VECTOR_OP_MATH] = { "tan", "tanh", "sin", diff --git a/src/hotspot/share/prims/vectorSupport.hpp b/src/hotspot/share/prims/vectorSupport.hpp index 7302e006064..6f8e52e9ec0 100644 --- a/src/hotspot/share/prims/vectorSupport.hpp +++ b/src/hotspot/share/prims/vectorSupport.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -121,9 +121,9 @@ class VectorSupport : AllStatic { VECTOR_OP_EXPM1 = 117, VECTOR_OP_HYPOT = 118, - VECTOR_OP_SVML_START = VECTOR_OP_TAN, - VECTOR_OP_SVML_END = VECTOR_OP_HYPOT, - NUM_SVML_OP = VECTOR_OP_SVML_END - VECTOR_OP_SVML_START + 1 + VECTOR_OP_MATH_START = VECTOR_OP_TAN, + VECTOR_OP_MATH_END = VECTOR_OP_HYPOT, + NUM_VECTOR_OP_MATH = VECTOR_OP_MATH_END - VECTOR_OP_MATH_START + 1 }; enum { @@ -131,7 +131,8 @@ class VectorSupport : AllStatic { VEC_SIZE_128 = 1, VEC_SIZE_256 = 2, VEC_SIZE_512 = 3, - NUM_VEC_SIZES = 4 + VEC_SIZE_SCALABLE = 4, + NUM_VEC_SIZES = 5 }; enum { @@ -139,7 +140,7 @@ class VectorSupport : AllStatic { MODE_BITS_COERCED_LONG_TO_MASK = 1 }; - static const char* svmlname[VectorSupport::NUM_SVML_OP]; + static const char* mathname[VectorSupport::NUM_VECTOR_OP_MATH]; static int vop2ideal(jint vop, BasicType bt); diff --git a/src/hotspot/share/prims/whitebox.cpp b/src/hotspot/share/prims/whitebox.cpp index 8a08a12a0b0..24f6156224d 100644 --- a/src/hotspot/share/prims/whitebox.cpp +++ b/src/hotspot/share/prims/whitebox.cpp @@ -676,7 +676,7 @@ WB_END #endif // INCLUDE_G1GC -// Alloc memory using the test memory type so that we can use that to see if +// Alloc memory using the test memory tag so that we can use that to see if // NMT picks it up correctly WB_ENTRY(jlong, WB_NMTMalloc(JNIEnv* env, jobject o, jlong size)) jlong addr = 0; @@ -692,11 +692,11 @@ WB_ENTRY(jlong, WB_NMTMallocWithPseudoStack(JNIEnv* env, jobject o, jlong size, return (jlong)(uintptr_t)os::malloc(size, mtTest, stack); WB_END -// Alloc memory with pseudo call stack and specific memory type. -WB_ENTRY(jlong, WB_NMTMallocWithPseudoStackAndType(JNIEnv* env, jobject o, jlong size, jint pseudo_stack, jint type)) +// Alloc memory with pseudo call stack and specific memory tag. +WB_ENTRY(jlong, WB_NMTMallocWithPseudoStackAndType(JNIEnv* env, jobject o, jlong size, jint pseudo_stack, jint mem_tag)) address pc = (address)(size_t)pseudo_stack; NativeCallStack stack(&pc, 1); - return (jlong)(uintptr_t)os::malloc(size, (MEMFLAGS)type, stack); + return (jlong)(uintptr_t)os::malloc(size, (MemTag)mem_tag, stack); WB_END // Free the memory allocated by NMTAllocTest @@ -708,21 +708,21 @@ WB_ENTRY(jlong, WB_NMTReserveMemory(JNIEnv* env, jobject o, jlong size)) jlong addr = 0; addr = (jlong)(uintptr_t)os::reserve_memory(size); - MemTracker::record_virtual_memory_type((address)addr, mtTest); + MemTracker::record_virtual_memory_tag((address)addr, mtTest); return addr; WB_END WB_ENTRY(jlong, WB_NMTAttemptReserveMemoryAt(JNIEnv* env, jobject o, jlong addr, jlong size)) addr = (jlong)(uintptr_t)os::attempt_reserve_memory_at((char*)(uintptr_t)addr, (size_t)size); - MemTracker::record_virtual_memory_type((address)addr, mtTest); + MemTracker::record_virtual_memory_tag((address)addr, mtTest); return addr; WB_END WB_ENTRY(void, WB_NMTCommitMemory(JNIEnv* env, jobject o, jlong addr, jlong size)) os::commit_memory((char *)(uintptr_t)addr, size, !ExecMem); - MemTracker::record_virtual_memory_type((address)(uintptr_t)addr, mtTest); + MemTracker::record_virtual_memory_tag((address)(uintptr_t)addr, mtTest); WB_END WB_ENTRY(void, WB_NMTUncommitMemory(JNIEnv* env, jobject o, jlong addr, jlong size)) @@ -2159,7 +2159,8 @@ WB_ENTRY(jboolean, WB_IsJVMCISupportedByGC(JNIEnv* env)) WB_END WB_ENTRY(jboolean, WB_CanWriteJavaHeapArchive(JNIEnv* env)) - return HeapShared::can_write(); + return HeapShared::can_write() + && ArchiveHeapLoader::can_use(); // work-around JDK-8341371 WB_END @@ -2497,6 +2498,13 @@ WB_ENTRY(jint, WB_ValidateCgroup(JNIEnv* env, return ret; WB_END +// Available cpus of the host machine, Linux only. +// Used in container testing. +WB_ENTRY(jint, WB_HostCPUs(JNIEnv* env, jobject o)) + LINUX_ONLY(return os::Linux::active_processor_count();) + return -1; // Not used/implemented on other platforms +WB_END + WB_ENTRY(void, WB_PrintOsInfo(JNIEnv* env, jobject o)) os::print_os_info(tty); WB_END @@ -2938,6 +2946,7 @@ static JNINativeMethod methods[] = { (void*)&WB_ValidateCgroup }, {CC"hostPhysicalMemory", CC"()J", (void*)&WB_HostPhysicalMemory }, {CC"hostPhysicalSwap", CC"()J", (void*)&WB_HostPhysicalSwap }, + {CC"hostCPUs", CC"()I", (void*)&WB_HostCPUs }, {CC"printOsInfo", CC"()V", (void*)&WB_PrintOsInfo }, {CC"disableElfSectionCache", CC"()V", (void*)&WB_DisableElfSectionCache }, {CC"resolvedMethodItemsCount", CC"()J", (void*)&WB_ResolvedMethodItemsCount }, diff --git a/src/hotspot/share/runtime/arguments.cpp b/src/hotspot/share/runtime/arguments.cpp index 0d0b58412ae..fe9641063b3 100644 --- a/src/hotspot/share/runtime/arguments.cpp +++ b/src/hotspot/share/runtime/arguments.cpp @@ -336,6 +336,11 @@ bool Arguments::is_internal_module_property(const char* property) { return false; } +// Return true if the key matches the --module-path property name ("jdk.module.path"). +bool Arguments::is_module_path_property(const char* key) { + return (strcmp(key, MODULE_PROPERTY_PREFIX PATH) == 0); +} + // Process java launcher properties. void Arguments::process_sun_java_launcher_properties(JavaVMInitArgs* args) { // See if sun.java.launcher or sun.java.launcher.is_altjvm is defined. @@ -1817,17 +1822,6 @@ bool Arguments::check_vm_args_consistency() { } #endif -#if !defined(X86) && !defined(AARCH64) && !defined(RISCV64) && !defined(ARM) && !defined(PPC64) && !defined(S390) - if (LockingMode == LM_LIGHTWEIGHT) { - FLAG_SET_CMDLINE(LockingMode, LM_LEGACY); - warning("New lightweight locking not supported on this platform"); - } - if (UseObjectMonitorTable) { - FLAG_SET_CMDLINE(UseObjectMonitorTable, false); - warning("UseObjectMonitorTable not supported on this platform"); - } -#endif - if (UseObjectMonitorTable && LockingMode != LM_LIGHTWEIGHT) { // ObjectMonitorTable requires lightweight locking. FLAG_SET_CMDLINE(UseObjectMonitorTable, false); diff --git a/src/hotspot/share/runtime/arguments.hpp b/src/hotspot/share/runtime/arguments.hpp index 8251db3d0d5..e1bfc0438dc 100644 --- a/src/hotspot/share/runtime/arguments.hpp +++ b/src/hotspot/share/runtime/arguments.hpp @@ -461,6 +461,7 @@ class Arguments : AllStatic { static int PropertyList_readable_count(SystemProperty* pl); static bool is_internal_module_property(const char* option); + static bool is_module_path_property(const char* key); // Miscellaneous System property value getter and setters. static void set_dll_dir(const char *value) { _sun_boot_library_path->set_value(value); } diff --git a/src/hotspot/share/runtime/basicLock.inline.hpp b/src/hotspot/share/runtime/basicLock.inline.hpp index c04c8e5b117..1090241c3e1 100644 --- a/src/hotspot/share/runtime/basicLock.inline.hpp +++ b/src/hotspot/share/runtime/basicLock.inline.hpp @@ -39,7 +39,7 @@ inline void BasicLock::set_displaced_header(markWord header) { inline ObjectMonitor* BasicLock::object_monitor_cache() const { assert(UseObjectMonitorTable, "must be"); -#if defined(X86) || defined(AARCH64) || defined(RISCV64) +#if !defined(ZERO) && (defined(X86) || defined(AARCH64) || defined(RISCV64) || defined(PPC64) || defined(S390)) return reinterpret_cast(get_metadata()); #else // Other platforms do not make use of the cache yet, diff --git a/src/hotspot/share/runtime/continuationFreezeThaw.cpp b/src/hotspot/share/runtime/continuationFreezeThaw.cpp index 0a763d76bad..e36b252362b 100644 --- a/src/hotspot/share/runtime/continuationFreezeThaw.cpp +++ b/src/hotspot/share/runtime/continuationFreezeThaw.cpp @@ -277,12 +277,31 @@ public: } }; +#ifdef _WINDOWS +static void map_stack_pages(JavaThread* thread, size_t size, address sp) { + address new_sp = sp - size; + address watermark = thread->stack_overflow_state()->shadow_zone_growth_watermark(); + + if (new_sp < watermark) { + size_t page_size = os::vm_page_size(); + address last_touched_page = watermark - StackOverflow::stack_shadow_zone_size(); + size_t pages_to_touch = align_up(watermark - new_sp, page_size) / page_size; + while (pages_to_touch-- > 0) { + last_touched_page -= page_size; + *last_touched_page = 0; + } + thread->stack_overflow_state()->set_shadow_zone_growth_watermark(new_sp); + } +} +#endif + static bool stack_overflow_check(JavaThread* thread, size_t size, address sp) { const size_t page_size = os::vm_page_size(); if (size > page_size) { if (sp - size < thread->stack_overflow_state()->shadow_zone_safe_limit()) { return false; } + WINDOWS_ONLY(map_stack_pages(thread, size, sp)); } return true; } @@ -2043,7 +2062,7 @@ NOINLINE intptr_t* ThawBase::thaw_slow(stackChunkOop chunk, bool return_barrier) assert(_cont.chunk_invariant(), ""); - JVMTI_ONLY(if (!return_barrier) invalidate_jvmti_stack(_thread)); + JVMTI_ONLY(invalidate_jvmti_stack(_thread)); _thread->set_cont_fastpath(_fastpath); diff --git a/src/hotspot/share/runtime/deoptimization.cpp b/src/hotspot/share/runtime/deoptimization.cpp index 7961e56598f..2006f340450 100644 --- a/src/hotspot/share/runtime/deoptimization.cpp +++ b/src/hotspot/share/runtime/deoptimization.cpp @@ -447,7 +447,7 @@ bool Deoptimization::deoptimize_objects_internal(JavaThread* thread, GrowableArr RegisterMap map(chunk->at(0)->register_map()); bool deoptimized_objects = false; - bool const jvmci_enabled = JVMCI_ONLY(UseJVMCICompiler) NOT_JVMCI(false); + bool const jvmci_enabled = JVMCI_ONLY(EnableJVMCI) NOT_JVMCI(false); // Reallocate the non-escaping objects and restore their fields. if (jvmci_enabled COMPILER2_PRESENT(|| (DoEscapeAnalysis && EliminateAllocations) diff --git a/src/hotspot/share/runtime/escapeBarrier.hpp b/src/hotspot/share/runtime/escapeBarrier.hpp index df32deef986..454e0b555e1 100644 --- a/src/hotspot/share/runtime/escapeBarrier.hpp +++ b/src/hotspot/share/runtime/escapeBarrier.hpp @@ -71,7 +71,7 @@ public: // Revert ea based optimizations for given deoptee thread EscapeBarrier(bool barrier_active, JavaThread* calling_thread, JavaThread* deoptee_thread) : _calling_thread(calling_thread), _deoptee_thread(deoptee_thread), - _barrier_active(barrier_active && (JVMCI_ONLY(UseJVMCICompiler) NOT_JVMCI(false) + _barrier_active(barrier_active && (JVMCI_ONLY(EnableJVMCI) NOT_JVMCI(false) COMPILER2_PRESENT(|| DoEscapeAnalysis))) { if (_barrier_active) sync_and_suspend_one(); @@ -80,7 +80,7 @@ public: // Revert ea based optimizations for all java threads EscapeBarrier(bool barrier_active, JavaThread* calling_thread) : _calling_thread(calling_thread), _deoptee_thread(nullptr), - _barrier_active(barrier_active && (JVMCI_ONLY(UseJVMCICompiler) NOT_JVMCI(false) + _barrier_active(barrier_active && (JVMCI_ONLY(EnableJVMCI) NOT_JVMCI(false) COMPILER2_PRESENT(|| DoEscapeAnalysis))) { if (_barrier_active) sync_and_suspend_all(); diff --git a/src/hotspot/share/runtime/flags/allFlags.hpp b/src/hotspot/share/runtime/flags/allFlags.hpp index af5645b2b8f..edeb1cd4024 100644 --- a/src/hotspot/share/runtime/flags/allFlags.hpp +++ b/src/hotspot/share/runtime/flags/allFlags.hpp @@ -57,14 +57,6 @@ range, \ constraint) \ \ - CDS_FLAGS( \ - develop, \ - develop_pd, \ - product, \ - product_pd, \ - range, \ - constraint) \ - \ JVMCI_ONLY(JVMCI_FLAGS( \ develop, \ develop_pd, \ @@ -97,6 +89,14 @@ range, \ constraint) \ \ + CDS_FLAGS( \ + develop, \ + develop_pd, \ + product, \ + product_pd, \ + range, \ + constraint) \ + \ RUNTIME_FLAGS( \ develop, \ develop_pd, \ diff --git a/src/hotspot/share/runtime/frame.cpp b/src/hotspot/share/runtime/frame.cpp index e193271eff6..17078a69ab9 100644 --- a/src/hotspot/share/runtime/frame.cpp +++ b/src/hotspot/share/runtime/frame.cpp @@ -719,6 +719,8 @@ void frame::print_on_error(outputStream* st, char* buf, int buflen, bool verbose st->print("v ~MethodHandlesAdapterBlob " PTR_FORMAT, p2i(pc())); } else if (_cb->is_uncommon_trap_stub()) { st->print("v ~UncommonTrapBlob " PTR_FORMAT, p2i(pc())); + } else if (_cb->is_upcall_stub()) { + st->print("v ~UpcallStub::%s " PTR_FORMAT, _cb->name(), p2i(pc())); } else { st->print("v blob " PTR_FORMAT, p2i(pc())); } @@ -1116,6 +1118,19 @@ void frame::oops_entry_do(OopClosure* f, const RegisterMap* map) const { entry_frame_call_wrapper()->oops_do(f); } +void frame::oops_upcall_do(OopClosure* f, const RegisterMap* map) const { + assert(map != nullptr, "map must be set"); + if (map->include_argument_oops()) { + // Upcall stubs call a MethodHandle impl method of which only the receiver + // is ever an oop. + // Currently we should not be able to get here, since there are no + // safepoints in the one resolve stub we can get into (handle_wrong_method) + // Leave this here as a trap in case we ever do: + ShouldNotReachHere(); // not implemented + } + _cb->as_upcall_stub()->oops_do(f, *this); +} + bool frame::is_deoptimized_frame() const { assert(_deopt_state != unknown, "not answerable"); if (_deopt_state == is_deoptimized) { @@ -1147,7 +1162,7 @@ void frame::oops_do_internal(OopClosure* f, NMethodClosure* cf, } else if (is_entry_frame()) { oops_entry_do(f, map); } else if (is_upcall_stub_frame()) { - _cb->as_upcall_stub()->oops_do(f, *this); + oops_upcall_do(f, map); } else if (CodeCache::contains(pc())) { oops_nmethod_do(f, cf, df, derived_mode, map); } else { diff --git a/src/hotspot/share/runtime/frame.hpp b/src/hotspot/share/runtime/frame.hpp index 1c57e3de4da..50aafce3837 100644 --- a/src/hotspot/share/runtime/frame.hpp +++ b/src/hotspot/share/runtime/frame.hpp @@ -464,6 +464,7 @@ class frame { const RegisterMap* map, bool use_interpreter_oop_map_cache) const; void oops_entry_do(OopClosure* f, const RegisterMap* map) const; + void oops_upcall_do(OopClosure* f, const RegisterMap* map) const; void oops_nmethod_do(OopClosure* f, NMethodClosure* cf, DerivedOopClosure* df, DerivedPointerIterationMode derived_mode, const RegisterMap* map) const; diff --git a/src/hotspot/share/runtime/globals.hpp b/src/hotspot/share/runtime/globals.hpp index d442894798b..b568e769304 100644 --- a/src/hotspot/share/runtime/globals.hpp +++ b/src/hotspot/share/runtime/globals.hpp @@ -289,9 +289,6 @@ const int ObjectAlignmentInBytes = 8; product(bool, UseInlineCaches, true, \ "Use Inline Caches for virtual calls ") \ \ - product(size_t, InlineCacheBufferSize, 10*K, EXPERIMENTAL, \ - "InlineCacheBuffer size") \ - \ product(bool, InlineArrayCopy, true, DIAGNOSTIC, \ "Inline arraycopy native that is known to be part of " \ "base library DLL") \ @@ -1201,9 +1198,6 @@ const int ObjectAlignmentInBytes = 8; product(bool, UseCompiler, true, \ "Use Just-In-Time compilation") \ \ - develop(intx, CounterHalfLifeTime, 30, \ - "Half-life time of invocation counters (in seconds)") \ - \ product(bool, AlwaysCompileLoopMethods, false, \ "When using recompilation, never interpret methods " \ "containing loops") \ @@ -1997,6 +1991,10 @@ const int ObjectAlignmentInBytes = 8; \ product(bool, StressSecondarySupers, false, DIAGNOSTIC, \ "Use a terrible hash function in order to generate many collisions.") \ + \ + product(bool, UseThreadsLockThrottleLock, true, DIAGNOSTIC, \ + "Use an extra lock during Thread start and exit to alleviate" \ + "contention on Threads_lock.") \ // end of RUNTIME_FLAGS diff --git a/src/hotspot/share/runtime/handles.hpp b/src/hotspot/share/runtime/handles.hpp index 39e59cc1ef0..8ed16d33a2f 100644 --- a/src/hotspot/share/runtime/handles.hpp +++ b/src/hotspot/share/runtime/handles.hpp @@ -187,7 +187,7 @@ class HandleArea: public Arena { HandleArea* _prev; // link to outer (older) area public: // Constructor - HandleArea(MEMFLAGS flags, HandleArea* prev) : Arena(flags, Tag::tag_ha, Chunk::tiny_size) { + HandleArea(MemTag mem_tag, HandleArea* prev) : Arena(mem_tag, Tag::tag_ha, Chunk::tiny_size) { debug_only(_handle_mark_nesting = 0); debug_only(_no_handle_mark_nesting = 0); _prev = prev; diff --git a/src/hotspot/share/runtime/javaThread.cpp b/src/hotspot/share/runtime/javaThread.cpp index 416e79d5844..14528f6d908 100644 --- a/src/hotspot/share/runtime/javaThread.cpp +++ b/src/hotspot/share/runtime/javaThread.cpp @@ -409,8 +409,8 @@ void JavaThread::check_for_valid_safepoint_state() { // A JavaThread is a normal Java thread -JavaThread::JavaThread(MEMFLAGS flags) : - Thread(flags), +JavaThread::JavaThread(MemTag mem_tag) : + Thread(mem_tag), // Initialize fields _on_thread_list(false), DEBUG_ONLY(_java_call_counter(0) COMMA) @@ -487,6 +487,7 @@ JavaThread::JavaThread(MEMFLAGS flags) : _cont_fastpath_thread_state(1), _held_monitor_count(0), _jni_monitor_count(0), + _unlocked_inflated_monitor(nullptr), _handshake(this), @@ -634,7 +635,7 @@ void JavaThread::block_if_vm_exited() { } } -JavaThread::JavaThread(ThreadFunction entry_point, size_t stack_sz, MEMFLAGS flags) : JavaThread(flags) { +JavaThread::JavaThread(ThreadFunction entry_point, size_t stack_sz, MemTag mem_tag) : JavaThread(mem_tag) { set_entry_point(entry_point); // Create the native thread itself. // %note runtime_23 diff --git a/src/hotspot/share/runtime/javaThread.hpp b/src/hotspot/share/runtime/javaThread.hpp index 54a11dad9b8..bda438612e3 100644 --- a/src/hotspot/share/runtime/javaThread.hpp +++ b/src/hotspot/share/runtime/javaThread.hpp @@ -238,8 +238,6 @@ class JavaThread: public Thread { // Safepoint support public: // Expose _thread_state for SafeFetchInt() volatile JavaThreadState _thread_state; - private: - SafepointMechanism::ThreadData _poll_data; ThreadSafepointState* _safepoint_state; // Holds information about a thread during a safepoint address _saved_exception_pc; // Saved pc of instruction where last implicit exception happened NOT_PRODUCT(bool _requires_cross_modify_fence;) // State used by VerifyCrossModifyFence @@ -464,6 +462,7 @@ class JavaThread: public Thread { // It's signed for error detection. intx _held_monitor_count; // used by continuations for fast lock detection intx _jni_monitor_count; + ObjectMonitor* _unlocked_inflated_monitor; private: @@ -479,8 +478,8 @@ private: public: // Constructor - JavaThread(MEMFLAGS flags = mtThread); // delegating constructor - JavaThread(ThreadFunction entry_point, size_t stack_size = 0, MEMFLAGS flags = mtThread); + JavaThread(MemTag mem_tag = mtThread); // delegating constructor + JavaThread(ThreadFunction entry_point, size_t stack_size = 0, MemTag mem_tag = mtThread); ~JavaThread(); // Factory method to create a new JavaThread whose attach state is "is attaching" @@ -597,6 +596,22 @@ private: SafepointMechanism::ThreadData* poll_data() { return &_poll_data; } + static ByteSize polling_word_offset() { + ByteSize offset = byte_offset_of(Thread, _poll_data) + + byte_offset_of(SafepointMechanism::ThreadData, _polling_word); + // At least on x86_64, safepoint polls encode the offset as disp8 imm. + assert(in_bytes(offset) < 128, "Offset >= 128"); + return offset; + } + + static ByteSize polling_page_offset() { + ByteSize offset = byte_offset_of(Thread, _poll_data) + + byte_offset_of(SafepointMechanism::ThreadData, _polling_page); + // At least on x86_64, safepoint polls encode the offset as disp8 imm. + assert(in_bytes(offset) < 128, "Offset >= 128"); + return offset; + } + void set_requires_cross_modify_fence(bool val) PRODUCT_RETURN NOT_PRODUCT({ _requires_cross_modify_fence = val; }) // Continuation support @@ -615,6 +630,12 @@ private: intx jni_monitor_count() { return _jni_monitor_count; } void clear_jni_monitor_count() { _jni_monitor_count = 0; } + // Support for SharedRuntime::monitor_exit_helper() + ObjectMonitor* unlocked_inflated_monitor() const { return _unlocked_inflated_monitor; } + void clear_unlocked_inflated_monitor() { + _unlocked_inflated_monitor = nullptr; + } + inline bool is_vthread_mounted() const; inline const ContinuationEntry* vthread_continuation() const; @@ -780,8 +801,6 @@ private: static ByteSize vm_result_offset() { return byte_offset_of(JavaThread, _vm_result); } static ByteSize vm_result_2_offset() { return byte_offset_of(JavaThread, _vm_result_2); } static ByteSize thread_state_offset() { return byte_offset_of(JavaThread, _thread_state); } - static ByteSize polling_word_offset() { return byte_offset_of(JavaThread, _poll_data) + byte_offset_of(SafepointMechanism::ThreadData, _polling_word);} - static ByteSize polling_page_offset() { return byte_offset_of(JavaThread, _poll_data) + byte_offset_of(SafepointMechanism::ThreadData, _polling_page);} static ByteSize saved_exception_pc_offset() { return byte_offset_of(JavaThread, _saved_exception_pc); } static ByteSize osthread_offset() { return byte_offset_of(JavaThread, _osthread); } #if INCLUDE_JVMCI @@ -828,6 +847,7 @@ private: static ByteSize cont_fastpath_offset() { return byte_offset_of(JavaThread, _cont_fastpath); } static ByteSize held_monitor_count_offset() { return byte_offset_of(JavaThread, _held_monitor_count); } static ByteSize jni_monitor_count_offset() { return byte_offset_of(JavaThread, _jni_monitor_count); } + static ByteSize unlocked_inflated_monitor_offset() { return byte_offset_of(JavaThread, _unlocked_inflated_monitor); } #if INCLUDE_JVMTI static ByteSize is_in_VTMS_transition_offset() { return byte_offset_of(JavaThread, _is_in_VTMS_transition); } diff --git a/src/hotspot/share/runtime/lightweightSynchronizer.cpp b/src/hotspot/share/runtime/lightweightSynchronizer.cpp index 0e360dba97b..7cf7c201faf 100644 --- a/src/hotspot/share/runtime/lightweightSynchronizer.cpp +++ b/src/hotspot/share/runtime/lightweightSynchronizer.cpp @@ -29,7 +29,7 @@ #include "logging/log.hpp" #include "memory/allStatic.hpp" #include "memory/resourceArea.hpp" -#include "nmt/memflags.hpp" +#include "nmt/memTag.hpp" #include "oops/oop.inline.hpp" #include "runtime/atomic.hpp" #include "runtime/basicLock.inline.hpp" @@ -60,14 +60,14 @@ class ObjectMonitorTable : AllStatic { } static void* allocate_node(void* context, size_t size, Value const& value) { ObjectMonitorTable::inc_items_count(); - return AllocateHeap(size, MEMFLAGS::mtObjectMonitor); + return AllocateHeap(size, mtObjectMonitor); }; static void free_node(void* context, void* memory, Value const& value) { ObjectMonitorTable::dec_items_count(); FreeHeap(memory); } }; - using ConcurrentTable = ConcurrentHashTable; + using ConcurrentTable = ConcurrentHashTable; static ConcurrentTable* _table; static volatile size_t _items_count; @@ -635,8 +635,11 @@ void LightweightSynchronizer::enter_for(Handle obj, BasicLock* lock, JavaThread* bool entered = monitor->enter_for(locking_thread); assert(entered, "recursive ObjectMonitor::enter_for must succeed"); } else { - // It is assumed that enter_for must enter on an object without contention. - monitor = inflate_and_enter(obj(), ObjectSynchronizer::inflate_cause_monitor_enter, locking_thread, current); + do { + // It is assumed that enter_for must enter on an object without contention. + monitor = inflate_and_enter(obj(), ObjectSynchronizer::inflate_cause_monitor_enter, locking_thread, current); + // But there may still be a race with deflation. + } while (monitor == nullptr); } assert(monitor != nullptr, "LightweightSynchronizer::enter_for must succeed"); diff --git a/src/hotspot/share/runtime/mutexLocker.cpp b/src/hotspot/share/runtime/mutexLocker.cpp index f033f426249..769c7695192 100644 --- a/src/hotspot/share/runtime/mutexLocker.cpp +++ b/src/hotspot/share/runtime/mutexLocker.cpp @@ -45,7 +45,6 @@ Mutex* SharedDictionary_lock = nullptr; Monitor* ClassInitError_lock = nullptr; Mutex* Module_lock = nullptr; Mutex* CompiledIC_lock = nullptr; -Mutex* InlineCacheBuffer_lock = nullptr; Mutex* VMStatistic_lock = nullptr; Mutex* JmethodIdCreation_lock = nullptr; Mutex* JfieldIdCreation_lock = nullptr; @@ -67,6 +66,7 @@ Monitor* CodeCache_lock = nullptr; Mutex* TouchedMethodLog_lock = nullptr; Mutex* RetData_lock = nullptr; Monitor* VMOperation_lock = nullptr; +Monitor* ThreadsLockThrottle_lock = nullptr; Monitor* Threads_lock = nullptr; Mutex* NonJavaThreadsList_lock = nullptr; Mutex* NonJavaThreadsListSync_lock = nullptr; @@ -262,7 +262,7 @@ void mutex_init() { MUTEX_DEFN(JfieldIdCreation_lock , PaddedMutex , safepoint); - MUTEX_DEFN(CompiledIC_lock , PaddedMutex , nosafepoint); // locks VtableStubs_lock, InlineCacheBuffer_lock + MUTEX_DEFN(CompiledIC_lock , PaddedMutex , nosafepoint); // locks VtableStubs_lock MUTEX_DEFN(MethodCompileQueue_lock , PaddedMonitor, safepoint); MUTEX_DEFN(CompileStatistics_lock , PaddedMutex , safepoint); MUTEX_DEFN(DirectivesStack_lock , PaddedMutex , nosafepoint); @@ -318,8 +318,9 @@ void mutex_init() { MUTEX_DEFN(JVMCIRuntime_lock , PaddedMonitor, safepoint, true); #endif + MUTEX_DEFN(ThreadsLockThrottle_lock , PaddedMonitor, safepoint); + // These locks have relative rankings, and inherit safepoint checking attributes from that rank. - MUTEX_DEFL(InlineCacheBuffer_lock , PaddedMutex , CompiledIC_lock); MUTEX_DEFL(VtableStubs_lock , PaddedMutex , CompiledIC_lock); // Also holds DumpTimeTable_lock MUTEX_DEFL(CodeCache_lock , PaddedMonitor, VtableStubs_lock); MUTEX_DEFL(NMethodState_lock , PaddedMutex , CodeCache_lock); diff --git a/src/hotspot/share/runtime/mutexLocker.hpp b/src/hotspot/share/runtime/mutexLocker.hpp index 160e6c97db0..98cb27d0b81 100644 --- a/src/hotspot/share/runtime/mutexLocker.hpp +++ b/src/hotspot/share/runtime/mutexLocker.hpp @@ -40,7 +40,6 @@ extern Mutex* SharedDictionary_lock; // a lock on the CDS shared dic extern Monitor* ClassInitError_lock; // a lock on the class initialization error table extern Mutex* Module_lock; // a lock on module and package related data structures extern Mutex* CompiledIC_lock; // a lock used to guard compiled IC patching and access -extern Mutex* InlineCacheBuffer_lock; // a lock used to guard the InlineCacheBuffer extern Mutex* VMStatistic_lock; // a lock used to guard statistics count increment extern Mutex* JmethodIdCreation_lock; // a lock on creating JNI method identifiers extern Mutex* JfieldIdCreation_lock; // a lock on creating JNI static field identifiers @@ -62,6 +61,8 @@ extern Monitor* CodeCache_lock; // a lock on the CodeCache extern Mutex* TouchedMethodLog_lock; // a lock on allocation of LogExecutedMethods info extern Mutex* RetData_lock; // a lock on installation of RetData inside method data extern Monitor* VMOperation_lock; // a lock on queue of vm_operations waiting to execute +extern Monitor* ThreadsLockThrottle_lock; // used by Thread start/exit to reduce competition for Threads_lock, + // so a VM thread calling a safepoint is prioritized extern Monitor* Threads_lock; // a lock on the Threads table of active Java threads // (also used by Safepoints too to block threads creation/destruction) extern Mutex* NonJavaThreadsList_lock; // a lock on the NonJavaThreads list diff --git a/src/hotspot/share/runtime/objectMonitor.cpp b/src/hotspot/share/runtime/objectMonitor.cpp index 367d79a5283..755d49d2c6c 100644 --- a/src/hotspot/share/runtime/objectMonitor.cpp +++ b/src/hotspot/share/runtime/objectMonitor.cpp @@ -178,7 +178,7 @@ OopStorage* ObjectMonitor::_oop_storage = nullptr; // // Cxq points to the set of Recently Arrived Threads attempting entry. // Because we push threads onto _cxq with CAS, the RATs must take the form of -// a singly-linked LIFO. We drain _cxq into EntryList at unlock-time when +// a singly-linked LIFO. We drain _cxq into EntryList at unlock-time when // the unlocking thread notices that EntryList is null but _cxq is != null. // // The EntryList is ordered by the prevailing queue discipline and @@ -210,19 +210,6 @@ OopStorage* ObjectMonitor::_oop_storage = nullptr; // unpark the notifyee. Unparking a notifee in notify() is inefficient - // it's likely the notifyee would simply impale itself on the lock held // by the notifier. -// -// * An interesting alternative is to encode cxq as (List,LockByte) where -// the LockByte is 0 iff the monitor is owned. _owner is simply an auxiliary -// variable, like _recursions, in the scheme. The threads or Events that form -// the list would have to be aligned in 256-byte addresses. A thread would -// try to acquire the lock or enqueue itself with CAS, but exiting threads -// could use a 1-0 protocol and simply STB to set the LockByte to 0. -// Note that is is *not* word-tearing, but it does presume that full-word -// CAS operations are coherent with intermix with STB operations. That's true -// on most common processors. -// -// * See also http://blogs.sun.com/dave - // Check that object() and set_object() are called from the right context: static void check_object_context() { @@ -257,7 +244,6 @@ ObjectMonitor::ObjectMonitor(oop object) : _EntryList(nullptr), _cxq(nullptr), _succ(nullptr), - _Responsible(nullptr), _SpinDuration(ObjectMonitor::Knob_SpinLimit), _contentions(0), _WaitSet(nullptr), @@ -320,17 +306,11 @@ bool ObjectMonitor::enter_is_async_deflating() { return false; } -void ObjectMonitor::enter_for_with_contention_mark(JavaThread* locking_thread, ObjectMonitorContentionMark& contention_mark) { - // Used by ObjectSynchronizer::enter_for to enter for another thread. - // The monitor is private to or already owned by locking_thread which must be suspended. - // So this code may only contend with deflation. - assert(locking_thread == Thread::current() || locking_thread->is_obj_deopt_suspend(), "must be"); +bool ObjectMonitor::TryLockWithContentionMark(JavaThread* locking_thread, ObjectMonitorContentionMark& contention_mark) { assert(contention_mark._monitor == this, "must be"); assert(!is_being_async_deflated(), "must be"); - void* prev_owner = try_set_owner_from(nullptr, locking_thread); - bool success = false; if (prev_owner == nullptr) { @@ -343,8 +323,16 @@ void ObjectMonitor::enter_for_with_contention_mark(JavaThread* locking_thread, O // Racing with deflation. prev_owner = try_set_owner_from(DEFLATER_MARKER, locking_thread); if (prev_owner == DEFLATER_MARKER) { - // Cancelled deflation. Increment contentions as part of the deflation protocol. - add_to_contentions(1); + // We successfully cancelled the in-progress async deflation by + // changing owner from DEFLATER_MARKER to current. We now extend + // the lifetime of the contention_mark (e.g. contentions++) here + // to prevent the deflater thread from winning the last part of + // the 2-part async deflation protocol after the regular + // decrement occurs when the contention_mark goes out of + // scope. ObjectMonitor::deflate_monitor() which is called by + // the deflater thread will decrement contentions after it + // recognizes that the async deflation was cancelled. + contention_mark.extend(); success = true; } else if (prev_owner == nullptr) { // At this point we cannot race with deflation as we have both incremented @@ -360,12 +348,28 @@ void ObjectMonitor::enter_for_with_contention_mark(JavaThread* locking_thread, O set_owner_from_BasicLock(prev_owner, locking_thread); success = true; } + assert(!success || owner_raw() == locking_thread, "must be"); + + return success; +} + +void ObjectMonitor::enter_for_with_contention_mark(JavaThread* locking_thread, ObjectMonitorContentionMark& contention_mark) { + // Used by LightweightSynchronizer::inflate_and_enter in deoptimization path to enter for another thread. + // The monitor is private to or already owned by locking_thread which must be suspended. + // So this code may only contend with deflation. + assert(locking_thread == Thread::current() || locking_thread->is_obj_deopt_suspend(), "must be"); + bool success = TryLockWithContentionMark(locking_thread, contention_mark); + assert(success, "Failed to enter_for: locking_thread=" INTPTR_FORMAT - ", this=" INTPTR_FORMAT "{owner=" INTPTR_FORMAT "}, observed owner: " INTPTR_FORMAT, - p2i(locking_thread), p2i(this), p2i(owner_raw()), p2i(prev_owner)); + ", this=" INTPTR_FORMAT "{owner=" INTPTR_FORMAT "}", + p2i(locking_thread), p2i(this), p2i(owner_raw())); } bool ObjectMonitor::enter_for(JavaThread* locking_thread) { + // Used by ObjectSynchronizer::enter_for() to enter for another thread. + // The monitor is private to or already owned by locking_thread which must be suspended. + // So this code may only contend with deflation. + assert(locking_thread == Thread::current() || locking_thread->is_obj_deopt_suspend(), "must be"); // Block out deflation as soon as possible. ObjectMonitorContentionMark contention_mark(this); @@ -375,19 +379,29 @@ bool ObjectMonitor::enter_for(JavaThread* locking_thread) { return false; } - enter_for_with_contention_mark(locking_thread, contention_mark); + bool success = TryLockWithContentionMark(locking_thread, contention_mark); + + assert(success, "Failed to enter_for: locking_thread=" INTPTR_FORMAT + ", this=" INTPTR_FORMAT "{owner=" INTPTR_FORMAT "}", + p2i(locking_thread), p2i(this), p2i(owner_raw())); assert(owner_raw() == locking_thread, "must be"); return true; } -bool ObjectMonitor::try_enter(JavaThread* current) { - // TryLock avoids the CAS +bool ObjectMonitor::try_enter(JavaThread* current, bool check_for_recursion) { + // TryLock avoids the CAS and handles deflation. TryLockResult r = TryLock(current); if (r == TryLockResult::Success) { assert(_recursions == 0, "invariant"); return true; } + // If called from SharedRuntime::monitor_exit_helper(), we know that + // this thread doesn't already own the lock. + if (!check_for_recursion) { + return false; + } + if (r == TryLockResult::HasOwner && owner() == current) { _recursions++; return true; @@ -400,7 +414,6 @@ bool ObjectMonitor::try_enter(JavaThread* current) { set_owner_from_BasicLock(cur, current); // Convert from BasicLock* to Thread*. return true; } - return false; } @@ -561,16 +574,40 @@ void ObjectMonitor::enter_with_contention_mark(JavaThread *current, ObjectMonito ObjectMonitor::TryLockResult ObjectMonitor::TryLock(JavaThread* current) { void* own = owner_raw(); - if (own != nullptr) return TryLockResult::HasOwner; - if (try_set_owner_from(nullptr, current) == nullptr) { - assert(_recursions == 0, "invariant"); - return TryLockResult::Success; + void* first_own = own; + + for (;;) { + if (own == DEFLATER_MARKER) { + // Block out deflation as soon as possible. + ObjectMonitorContentionMark contention_mark(this); + + // Check for deflation. + if (enter_is_async_deflating()) { + // Treat deflation as interference. + return TryLockResult::Interference; + } + if (TryLockWithContentionMark(current, contention_mark)) { + assert(_recursions == 0, "invariant"); + return TryLockResult::Success; + } else { + // Deflation won or change of owner; dont spin + break; + } + } else if (own == nullptr) { + void* prev_own = try_set_owner_from(nullptr, current); + if (prev_own == nullptr) { + assert(_recursions == 0, "invariant"); + return TryLockResult::Success; + } else { + // The lock had been free momentarily, but we lost the race to the lock. + own = prev_own; + } + } else { + // Retry doesn't make as much sense because the lock was just acquired. + break; + } } - // The lock had been free momentarily, but we lost the race to the lock. - // Interference -- the CAS failed. - // We can either return -1 or retry. - // Retry doesn't make as much sense because the lock was just acquired. - return TryLockResult::Interference; + return first_own == own ? TryLockResult::HasOwner : TryLockResult::Interference; } // Deflate the specified ObjectMonitor if not in-use. Returns true if it @@ -746,8 +783,6 @@ const char* ObjectMonitor::is_busy_to_string(stringStream* ss) { return ss->base(); } -#define MAX_RECHECK_INTERVAL 1000 - void ObjectMonitor::EnterI(JavaThread* current) { assert(current->thread_state() == _thread_blocked, "invariant"); @@ -755,25 +790,6 @@ void ObjectMonitor::EnterI(JavaThread* current) { if (TryLock(current) == TryLockResult::Success) { assert(_succ != current, "invariant"); assert(owner_raw() == current, "invariant"); - assert(_Responsible != current, "invariant"); - return; - } - - if (try_set_owner_from(DEFLATER_MARKER, current) == DEFLATER_MARKER) { - // Cancelled the in-progress async deflation by changing owner from - // DEFLATER_MARKER to current. As part of the contended enter protocol, - // contentions was incremented to a positive value before EnterI() - // was called and that prevents the deflater thread from winning the - // last part of the 2-part async deflation protocol. After EnterI() - // returns to enter(), contentions is decremented because the caller - // now owns the monitor. We bump contentions an extra time here to - // prevent the deflater thread from winning the last part of the - // 2-part async deflation protocol after the regular decrement - // occurs in enter(). The deflater thread will decrement contentions - // after it recognizes that the async deflation was cancelled. - add_to_contentions(1); - assert(_succ != current, "invariant"); - assert(_Responsible != current, "invariant"); return; } @@ -789,14 +805,12 @@ void ObjectMonitor::EnterI(JavaThread* current) { if (TrySpin(current)) { assert(owner_raw() == current, "invariant"); assert(_succ != current, "invariant"); - assert(_Responsible != current, "invariant"); return; } // The Spin failed -- Enqueue and park the thread ... assert(_succ != current, "invariant"); assert(owner_raw() != current, "invariant"); - assert(_Responsible != current, "invariant"); // Enqueue "current" on ObjectMonitor's _cxq. // @@ -826,40 +840,10 @@ void ObjectMonitor::EnterI(JavaThread* current) { if (TryLock(current) == TryLockResult::Success) { assert(_succ != current, "invariant"); assert(owner_raw() == current, "invariant"); - assert(_Responsible != current, "invariant"); return; } } - // Check for cxq|EntryList edge transition to non-null. This indicates - // the onset of contention. While contention persists exiting threads - // will use a ST:MEMBAR:LD 1-1 exit protocol. When contention abates exit - // operations revert to the faster 1-0 mode. This enter operation may interleave - // (race) a concurrent 1-0 exit operation, resulting in stranding, so we - // arrange for one of the contending thread to use a timed park() operations - // to detect and recover from the race. (Stranding is form of progress failure - // where the monitor is unlocked but all the contending threads remain parked). - // That is, at least one of the contended threads will periodically poll _owner. - // One of the contending threads will become the designated "Responsible" thread. - // The Responsible thread uses a timed park instead of a normal indefinite park - // operation -- it periodically wakes and checks for and recovers from potential - // strandings admitted by 1-0 exit operations. We need at most one Responsible - // thread per-monitor at any given moment. Only threads on cxq|EntryList may - // be responsible for a monitor. - // - // Currently, one of the contended threads takes on the added role of "Responsible". - // A viable alternative would be to use a dedicated "stranding checker" thread - // that periodically iterated over all the threads (or active monitors) and unparked - // successors where there was risk of stranding. This would help eliminate the - // timer scalability issues we see on some platforms as we'd only have one thread - // -- the checker -- parked on a timer. - - if (nxt == nullptr && _EntryList == nullptr) { - // Try to assume the role of responsible thread for the monitor. - // CONSIDER: ST vs CAS vs { if (Responsible==null) Responsible=current } - Atomic::replace_if_null(&_Responsible, current); - } - // The lock might have been released while this thread was occupied queueing // itself onto _cxq. To close the race and avoid "stranding" and // progress-liveness failure we must resample-retry _owner before parking. @@ -871,8 +855,6 @@ void ObjectMonitor::EnterI(JavaThread* current) { // to defer the state transitions until absolutely necessary, // and in doing so avoid some transitions ... - int recheckInterval = 1; - for (;;) { if (TryLock(current) == TryLockResult::Success) { @@ -881,37 +863,12 @@ void ObjectMonitor::EnterI(JavaThread* current) { assert(owner_raw() != current, "invariant"); // park self - if (_Responsible == current) { - current->_ParkEvent->park((jlong) recheckInterval); - // Increase the recheckInterval, but clamp the value. - recheckInterval *= 8; - if (recheckInterval > MAX_RECHECK_INTERVAL) { - recheckInterval = MAX_RECHECK_INTERVAL; - } - } else { - current->_ParkEvent->park(); - } + current->_ParkEvent->park(); if (TryLock(current) == TryLockResult::Success) { break; } - if (try_set_owner_from(DEFLATER_MARKER, current) == DEFLATER_MARKER) { - // Cancelled the in-progress async deflation by changing owner from - // DEFLATER_MARKER to current. As part of the contended enter protocol, - // contentions was incremented to a positive value before EnterI() - // was called and that prevents the deflater thread from winning the - // last part of the 2-part async deflation protocol. After EnterI() - // returns to enter(), contentions is decremented because the caller - // now owns the monitor. We bump contentions an extra time here to - // prevent the deflater thread from winning the last part of the - // 2-part async deflation protocol after the regular decrement - // occurs in enter(). The deflater thread will decrement contentions - // after it recognizes that the async deflation was cancelled. - add_to_contentions(1); - break; - } - // The lock is still contested. // Keep a tally of the # of futile wakeups. @@ -953,44 +910,23 @@ void ObjectMonitor::EnterI(JavaThread* current) { assert(owner_raw() == current, "invariant"); UnlinkAfterAcquire(current, &node); - if (_succ == current) _succ = nullptr; - - assert(_succ != current, "invariant"); - if (_Responsible == current) { - _Responsible = nullptr; - OrderAccess::fence(); // Dekker pivot-point - - // We may leave threads on cxq|EntryList without a designated - // "Responsible" thread. This is benign. When this thread subsequently - // exits the monitor it can "see" such preexisting "old" threads -- - // threads that arrived on the cxq|EntryList before the fence, above -- - // by LDing cxq|EntryList. Newly arrived threads -- that is, threads - // that arrive on cxq after the ST:MEMBAR, above -- will set Responsible - // non-null and elect a new "Responsible" timer thread. - // - // This thread executes: - // ST Responsible=null; MEMBAR (in enter epilogue - here) - // LD cxq|EntryList (in subsequent exit) - // - // Entering threads in the slow/contended path execute: - // ST cxq=nonnull; MEMBAR; LD Responsible (in enter prolog) - // The (ST cxq; MEMBAR) is accomplished with CAS(). - // - // The MEMBAR, above, prevents the LD of cxq|EntryList in the subsequent - // exit operation from floating above the ST Responsible=null. + if (_succ == current) { + _succ = nullptr; + // Note that we don't need to do OrderAccess::fence() after clearing + // _succ here, since we own the lock. } // We've acquired ownership with CAS(). // CAS is serializing -- it has MEMBAR/FENCE-equivalent semantics. // But since the CAS() this thread may have also stored into _succ, - // EntryList, cxq or Responsible. These meta-data updates must be + // EntryList or cxq. These meta-data updates must be // visible __before this thread subsequently drops the lock. // Consider what could occur if we didn't enforce this constraint -- // STs to monitor meta-data and user-data could reorder with (become // visible after) the ST in exit that drops ownership of the lock. // Some other thread could then acquire the lock, but observe inconsistent // or old monitor meta-data and heap data. That violates the JMM. - // To that end, the 1-0 exit() operation must have at least STST|LDST + // To that end, the exit() operation must have at least STST|LDST // "release" barrier semantics. Specifically, there must be at least a // STST|LDST barrier in exit() before the ST of null into _owner that drops // the lock. The barrier ensures that changes to monitor meta-data and data @@ -1000,8 +936,7 @@ void ObjectMonitor::EnterI(JavaThread* current) { // // Critically, any prior STs to _succ or EntryList must be visible before // the ST of null into _owner in the *subsequent* (following) corresponding - // monitorexit. Recall too, that in 1-0 mode monitorexit does not necessarily - // execute a serializing instruction. + // monitorexit. return; } @@ -1174,39 +1109,32 @@ void ObjectMonitor::UnlinkAfterAcquire(JavaThread* current, ObjectWaiter* curren // In that case exit() is called with _thread_state == _thread_blocked, // but the monitor's _contentions field is > 0, which inhibits reclamation. // -// 1-0 exit -// ~~~~~~~~ -// ::exit() uses a canonical 1-1 idiom with a MEMBAR although some of -// the fast-path operators have been optimized so the common ::exit() -// operation is 1-0, e.g., see macroAssembler_x86.cpp: fast_unlock(). -// The code emitted by fast_unlock() elides the usual MEMBAR. This -// greatly improves latency -- MEMBAR and CAS having considerable local -// latency on modern processors -- but at the cost of "stranding". Absent the -// MEMBAR, a thread in fast_unlock() can race a thread in the slow -// ::enter() path, resulting in the entering thread being stranding -// and a progress-liveness failure. Stranding is extremely rare. -// We use timers (timed park operations) & periodic polling to detect -// and recover from stranding. Potentially stranded threads periodically -// wake up and poll the lock. See the usage of the _Responsible variable. +// This is the exit part of the locking protocol, often implemented in +// C2_MacroAssembler::fast_unlock() // -// The CAS() in enter provides for safety and exclusion, while the CAS or -// MEMBAR in exit provides for progress and avoids stranding. 1-0 locking -// eliminates the CAS/MEMBAR from the exit path, but it admits stranding. -// We detect and recover from stranding with timers. +// 1. A release barrier ensures that changes to monitor meta-data +// (_succ, _EntryList, _cxq) and data protected by the lock will be +// visible before we release the lock. +// 2. Release the lock by clearing the owner. +// 3. A storeload MEMBAR is needed between releasing the owner and +// subsequently reading meta-data to safely determine if the lock is +// contended (step 4) without an elected successor (step 5). +// 4. If both _EntryList and _cxq are null, we are done, since there is no +// other thread waiting on the lock to wake up. I.e. there is no +// contention. +// 5. If there is a successor (_succ is non-null), we are done. The +// responsibility for guaranteeing progress-liveness has now implicitly +// been moved from the exiting thread to the successor. +// 6. There are waiters in the entry list (_EntryList and/or cxq are +// non-null), but there is no successor (_succ is null), so we need to +// wake up (unpark) a waiting thread to avoid stranding. // -// If a thread transiently strands it'll park until (a) another -// thread acquires the lock and then drops the lock, at which time the -// exiting thread will notice and unpark the stranded thread, or, (b) -// the timer expires. If the lock is high traffic then the stranding latency -// will be low due to (a). If the lock is low traffic then the odds of -// stranding are lower, although the worst-case stranding latency -// is longer. Critically, we don't want to put excessive load in the -// platform's timer subsystem. We want to minimize both the timer injection -// rate (timers created/sec) as well as the number of timers active at -// any one time. (more precisely, we want to minimize timer-seconds, which is -// the integral of the # of active timers at any instant over time). -// Both impinge on OS scalability. Given that, at most one thread parked on -// a monitor will use a timer. +// Note that since only the current lock owner can manipulate the _EntryList +// or drain _cxq, we need to reacquire the lock before we can wake up +// (unpark) a waiting thread. +// +// The CAS() in enter provides for safety and exclusion, while the +// MEMBAR in exit provides for progress and avoids stranding. // // There is also the risk of a futile wake-up. If we drop the lock // another thread can reacquire the lock immediately, and we can @@ -1248,10 +1176,6 @@ void ObjectMonitor::exit(JavaThread* current, bool not_suspended) { return; } - // Invariant: after setting Responsible=null an thread must execute - // a MEMBAR or other serializing instruction before fetching EntryList|cxq. - _Responsible = nullptr; - #if INCLUDE_JFR // get the owner's thread id for the MonitorEnter event // if it is enabled and the thread isn't suspended @@ -1278,14 +1202,15 @@ void ObjectMonitor::exit(JavaThread* current, bool not_suspended) { // Other threads are blocked trying to acquire the lock. // Normally the exiting thread is responsible for ensuring succession, - // but if other successors are ready or other entering threads are spinning - // then this thread can simply store null into _owner and exit without - // waking a successor. The existence of spinners or ready successors - // guarantees proper succession (liveness). Responsibility passes to the - // ready or running successors. The exiting thread delegates the duty. - // More precisely, if a successor already exists this thread is absolved - // of the responsibility of waking (unparking) one. - // + // but if this thread observes other successors are ready or other + // entering threads are spinning after it has stored null into _owner + // then it can exit without waking a successor. The existence of + // spinners or ready successors guarantees proper succession (liveness). + // Responsibility passes to the ready or running successors. The exiting + // thread delegates the duty. More precisely, if a successor already + // exists this thread is absolved of the responsibility of waking + // (unparking) one. + // The _succ variable is critical to reducing futile wakeup frequency. // _succ identifies the "heir presumptive" thread that has been made // ready (unparked) but that has not yet run. We need only one such @@ -1296,24 +1221,20 @@ void ObjectMonitor::exit(JavaThread* current, bool not_suspended) { // Note that spinners in Enter() also set _succ non-null. // In the current implementation spinners opportunistically set // _succ so that exiting threads might avoid waking a successor. - // Another less appealing alternative would be for the exiting thread - // to drop the lock and then spin briefly to see if a spinner managed - // to acquire the lock. If so, the exiting thread could exit - // immediately without waking a successor, otherwise the exiting - // thread would need to dequeue and wake a successor. - // (Note that we'd need to make the post-drop spin short, but no - // shorter than the worst-case round-trip cache-line migration time. - // The dropped lock needs to become visible to the spinner, and then - // the acquisition of the lock by the spinner must become visible to - // the exiting thread). + // Which means that the exiting thread could exit immediately without + // waking a successor, if it observes a successor after it has dropped + // the lock. Note that the dropped lock needs to become visible to the + // spinner. // It appears that an heir-presumptive (successor) must be made ready. // Only the current lock owner can manipulate the EntryList or // drain _cxq, so we need to reacquire the lock. If we fail // to reacquire the lock the responsibility for ensuring succession // falls to the new owner. - // - if (try_set_owner_from(nullptr, current) != nullptr) { + + if (TryLock(current) != TryLockResult::Success) { + // Some other thread acquired the lock (or the monitor was + // deflated). Either way we are done. return; } @@ -1376,7 +1297,7 @@ void ObjectMonitor::exit(JavaThread* current, bool not_suspended) { q = p; } - // In 1-0 mode we need: ST EntryList; MEMBAR #storestore; ST _owner = nullptr + // We need to: ST EntryList; MEMBAR #storestore; ST _owner = nullptr // The MEMBAR is satisfied by the release_store() operation in ExitEpilog(). // See if we can abdicate to a spinner instead of waking a thread. @@ -1566,8 +1487,6 @@ void ObjectMonitor::wait(jlong millis, bool interruptible, TRAPS) { AddWaiter(&node); Thread::SpinRelease(&_WaitSetLock); - _Responsible = nullptr; - intx save = _recursions; // record the old recursion count _waiters++; // increment the number of waiters _recursions = 0; // set the recursion level to be 1 @@ -2245,7 +2164,6 @@ void ObjectMonitor::print() const { print_on(tty); } // _EntryList = 0x0000000000000000 // _cxq = 0x0000000000000000 // _succ = 0x0000000000000000 -// _Responsible = 0x0000000000000000 // _SpinDuration = 5000 // _contentions = 0 // _WaitSet = 0x0000700009756248 @@ -2274,7 +2192,6 @@ void ObjectMonitor::print_debug_style_on(outputStream* st) const { st->print_cr(" _EntryList = " INTPTR_FORMAT, p2i(_EntryList)); st->print_cr(" _cxq = " INTPTR_FORMAT, p2i(_cxq)); st->print_cr(" _succ = " INTPTR_FORMAT, p2i(_succ)); - st->print_cr(" _Responsible = " INTPTR_FORMAT, p2i(_Responsible)); st->print_cr(" _SpinDuration = %d", _SpinDuration); st->print_cr(" _contentions = %d", contentions()); st->print_cr(" _WaitSet = " INTPTR_FORMAT, p2i(_WaitSet)); diff --git a/src/hotspot/share/runtime/objectMonitor.hpp b/src/hotspot/share/runtime/objectMonitor.hpp index ef85559c2b6..30d2e509416 100644 --- a/src/hotspot/share/runtime/objectMonitor.hpp +++ b/src/hotspot/share/runtime/objectMonitor.hpp @@ -179,7 +179,6 @@ class ObjectMonitor : public CHeapObj { ObjectWaiter* volatile _cxq; // LL of recently-arrived threads blocked on entry. JavaThread* volatile _succ; // Heir presumptive thread - used for futile wakeup throttling - JavaThread* volatile _Responsible; volatile int _SpinDuration; @@ -348,7 +347,7 @@ class ObjectMonitor : public CHeapObj { void enter_for_with_contention_mark(JavaThread* locking_thread, ObjectMonitorContentionMark& contention_mark); bool enter_for(JavaThread* locking_thread); bool enter(JavaThread* current); - bool try_enter(JavaThread* current); + bool try_enter(JavaThread* current, bool check_for_recursion = true); bool spin_enter(JavaThread* current); void enter_with_contention_mark(JavaThread* current, ObjectMonitorContentionMark& contention_mark); void exit(JavaThread* current, bool not_suspended = true); @@ -377,6 +376,7 @@ class ObjectMonitor : public CHeapObj { enum class TryLockResult { Interference = -1, HasOwner = 0, Success = 1 }; + bool TryLockWithContentionMark(JavaThread* locking_thread, ObjectMonitorContentionMark& contention_mark); TryLockResult TryLock(JavaThread* current); bool TrySpin(JavaThread* current); @@ -395,12 +395,17 @@ class ObjectMonitorContentionMark : StackObj { DEBUG_ONLY(friend class ObjectMonitor;) ObjectMonitor* _monitor; + bool _extended; NONCOPYABLE(ObjectMonitorContentionMark); public: explicit ObjectMonitorContentionMark(ObjectMonitor* monitor); ~ObjectMonitorContentionMark(); + + // Extends the contention scope beyond this objects lifetime. + // Requires manual decrement of the contentions counter. + void extend(); }; #endif // SHARE_RUNTIME_OBJECTMONITOR_HPP diff --git a/src/hotspot/share/runtime/objectMonitor.inline.hpp b/src/hotspot/share/runtime/objectMonitor.inline.hpp index d26c459b1b4..6d3c6ff24c3 100644 --- a/src/hotspot/share/runtime/objectMonitor.inline.hpp +++ b/src/hotspot/share/runtime/objectMonitor.inline.hpp @@ -206,15 +206,32 @@ inline void ObjectMonitor::set_next_om(ObjectMonitor* new_value) { Atomic::store(&_next_om, new_value); } +// Block out deflation. inline ObjectMonitorContentionMark::ObjectMonitorContentionMark(ObjectMonitor* monitor) - : _monitor(monitor) { + : _monitor(monitor), _extended(false) { + // Contentions is incremented to a positive value as part of the + // contended enter protocol, which prevents the deflater thread from + // winning the last part of the 2-part async deflation + // protocol. See: ObjectMonitor::deflate_monitor() and + // ObjectMonitor::TryLockWithContentionMark(). _monitor->add_to_contentions(1); } inline ObjectMonitorContentionMark::~ObjectMonitorContentionMark() { + // Decrement contentions when the contention mark goes out of + // scope. This opens up for deflation, if the contention mark + // hasn't been extended. _monitor->add_to_contentions(-1); } +inline void ObjectMonitorContentionMark::extend() { + // Used by ObjectMonitor::TryLockWithContentionMark() to "extend the + // lifetime" of the contention mark. + assert(!_extended, "extending twice is probably a bad design"); + _monitor->add_to_contentions(1); + _extended = true; +} + inline oop ObjectMonitor::object_peek() const { if (_object.is_null()) { return nullptr; diff --git a/src/hotspot/share/runtime/os.cpp b/src/hotspot/share/runtime/os.cpp index a8f3bc5c1d5..8b1c52a5d33 100644 --- a/src/hotspot/share/runtime/os.cpp +++ b/src/hotspot/share/runtime/os.cpp @@ -32,6 +32,7 @@ #include "code/codeCache.hpp" #include "code/vtableStubs.hpp" #include "gc/shared/gcVMOperations.hpp" +#include "gc/shared/oopStorageSet.hpp" #include "interpreter/interpreter.hpp" #include "jvm.h" #include "logging/log.hpp" @@ -600,16 +601,16 @@ bool os::find_builtin_agent(JvmtiAgent* agent, const char *syms[], // --------------------- heap allocation utilities --------------------- -char *os::strdup(const char *str, MEMFLAGS flags) { +char *os::strdup(const char *str, MemTag mem_tag) { size_t size = strlen(str); - char *dup_str = (char *)malloc(size + 1, flags); + char *dup_str = (char *)malloc(size + 1, mem_tag); if (dup_str == nullptr) return nullptr; strcpy(dup_str, str); return dup_str; } -char* os::strdup_check_oom(const char* str, MEMFLAGS flags) { - char* p = os::strdup(str, flags); +char* os::strdup_check_oom(const char* str, MemTag mem_tag) { + char* p = os::strdup(str, mem_tag); if (p == nullptr) { vm_exit_out_of_memory(strlen(str) + 1, OOM_MALLOC_ERROR, "os::strdup_check_oom"); } @@ -629,11 +630,11 @@ static void break_if_ptr_caught(void* ptr) { } #endif // ASSERT -void* os::malloc(size_t size, MEMFLAGS flags) { - return os::malloc(size, flags, CALLER_PC); +void* os::malloc(size_t size, MemTag mem_tag) { + return os::malloc(size, mem_tag, CALLER_PC); } -void* os::malloc(size_t size, MEMFLAGS memflags, const NativeCallStack& stack) { +void* os::malloc(size_t size, MemTag mem_tag, const NativeCallStack& stack) { // Special handling for NMT preinit phase before arguments are parsed void* rc = nullptr; @@ -651,7 +652,7 @@ void* os::malloc(size_t size, MEMFLAGS memflags, const NativeCallStack& stack) { size = MAX2((size_t)1, size); // Observe MallocLimit - if (MemTracker::check_exceeds_limit(size, memflags)) { + if (MemTracker::check_exceeds_limit(size, mem_tag)) { return nullptr; } @@ -667,7 +668,7 @@ void* os::malloc(size_t size, MEMFLAGS memflags, const NativeCallStack& stack) { return nullptr; } - void* const inner_ptr = MemTracker::record_malloc((address)outer_ptr, size, memflags, stack); + void* const inner_ptr = MemTracker::record_malloc((address)outer_ptr, size, mem_tag, stack); if (CDSConfig::is_dumping_static_archive()) { // Need to deterministically fill all the alignment gaps in C++ structures. @@ -679,20 +680,20 @@ void* os::malloc(size_t size, MEMFLAGS memflags, const NativeCallStack& stack) { return inner_ptr; } -void* os::realloc(void *memblock, size_t size, MEMFLAGS flags) { - return os::realloc(memblock, size, flags, CALLER_PC); +void* os::realloc(void *memblock, size_t size, MemTag mem_tag) { + return os::realloc(memblock, size, mem_tag, CALLER_PC); } -void* os::realloc(void *memblock, size_t size, MEMFLAGS memflags, const NativeCallStack& stack) { +void* os::realloc(void *memblock, size_t size, MemTag mem_tag, const NativeCallStack& stack) { // Special handling for NMT preinit phase before arguments are parsed void* rc = nullptr; - if (NMTPreInit::handle_realloc(&rc, memblock, size, memflags)) { + if (NMTPreInit::handle_realloc(&rc, memblock, size, mem_tag)) { return rc; } if (memblock == nullptr) { - return os::malloc(size, memflags, stack); + return os::malloc(size, mem_tag, stack); } DEBUG_ONLY(check_crash_protection()); @@ -715,15 +716,15 @@ void* os::realloc(void *memblock, size_t size, MEMFLAGS memflags, const NativeCa const size_t old_size = MallocTracker::malloc_header(memblock)->size(); // Observe MallocLimit - if ((size > old_size) && MemTracker::check_exceeds_limit(size - old_size, memflags)) { + if ((size > old_size) && MemTracker::check_exceeds_limit(size - old_size, mem_tag)) { return nullptr; } // Perform integrity checks on and mark the old block as dead *before* calling the real realloc(3) since it // may invalidate the old block, including its header. MallocHeader* header = MallocHeader::resolve_checked(memblock); - assert(memflags == header->flags(), "weird NMT flags mismatch (new:\"%s\" != old:\"%s\")\n", - NMTUtil::flag_to_name(memflags), NMTUtil::flag_to_name(header->flags())); + assert(mem_tag == header->mem_tag(), "weird NMT type mismatch (new:\"%s\" != old:\"%s\")\n", + NMTUtil::tag_to_name(mem_tag), NMTUtil::tag_to_name(header->mem_tag())); const MallocHeader::FreeInfo free_info = header->free_info(); header->mark_block_as_dead(); @@ -742,7 +743,7 @@ void* os::realloc(void *memblock, size_t size, MEMFLAGS memflags, const NativeCa // After a successful realloc(3), we account the resized block with its new size // to NMT. - void* const new_inner_ptr = MemTracker::record_malloc(new_outer_ptr, size, memflags, stack); + void* const new_inner_ptr = MemTracker::record_malloc(new_outer_ptr, size, mem_tag, stack); #ifdef ASSERT assert(old_size == free_info.size, "Sanity"); @@ -1317,6 +1318,11 @@ void os::print_location(outputStream* st, intptr_t x, bool verbose) { } #endif + // Ask if any OopStorage knows about this address. + if (OopStorageSet::print_containing(addr, st)) { + return; + } + // Still nothing? If NMT is enabled, we can ask what it thinks... if (MemTracker::print_containing_region(addr, st)) { return; @@ -1871,10 +1877,10 @@ bool os::create_stack_guard_pages(char* addr, size_t bytes) { return os::pd_create_stack_guard_pages(addr, bytes); } -char* os::reserve_memory(size_t bytes, bool executable, MEMFLAGS flags) { +char* os::reserve_memory(size_t bytes, bool executable, MemTag mem_tag) { char* result = pd_reserve_memory(bytes, executable); if (result != nullptr) { - MemTracker::record_virtual_memory_reserve(result, bytes, CALLER_PC, flags); + MemTracker::record_virtual_memory_reserve(result, bytes, CALLER_PC, mem_tag); log_debug(os, map)("Reserved " RANGEFMT, RANGEFMTARGS(result, bytes)); } else { log_info(os, map)("Reserve failed (%zu bytes)", bytes); @@ -1882,10 +1888,10 @@ char* os::reserve_memory(size_t bytes, bool executable, MEMFLAGS flags) { return result; } -char* os::attempt_reserve_memory_at(char* addr, size_t bytes, bool executable, MEMFLAGS flag) { +char* os::attempt_reserve_memory_at(char* addr, size_t bytes, bool executable, MemTag mem_tag) { char* result = SimulateFullAddressSpace ? nullptr : pd_attempt_reserve_memory_at(addr, bytes, executable); if (result != nullptr) { - MemTracker::record_virtual_memory_reserve((address)result, bytes, CALLER_PC, flag); + MemTracker::record_virtual_memory_reserve((address)result, bytes, CALLER_PC, mem_tag); log_debug(os, map)("Reserved " RANGEFMT, RANGEFMTARGS(result, bytes)); } else { log_info(os, map)("Attempt to reserve " RANGEFMT " failed", @@ -2235,31 +2241,31 @@ void os::pretouch_memory(void* start, void* end, size_t page_size) { } } -char* os::map_memory_to_file(size_t bytes, int file_desc, MEMFLAGS flag) { +char* os::map_memory_to_file(size_t bytes, int file_desc, MemTag mem_tag) { // Could have called pd_reserve_memory() followed by replace_existing_mapping_with_file_mapping(), // but AIX may use SHM in which case its more trouble to detach the segment and remap memory to the file. // On all current implementations null is interpreted as any available address. char* result = os::map_memory_to_file(nullptr /* addr */, bytes, file_desc); if (result != nullptr) { - MemTracker::record_virtual_memory_reserve_and_commit(result, bytes, CALLER_PC, flag); + MemTracker::record_virtual_memory_reserve_and_commit(result, bytes, CALLER_PC, mem_tag); } return result; } -char* os::attempt_map_memory_to_file_at(char* addr, size_t bytes, int file_desc, MEMFLAGS flag) { +char* os::attempt_map_memory_to_file_at(char* addr, size_t bytes, int file_desc, MemTag mem_tag) { char* result = pd_attempt_map_memory_to_file_at(addr, bytes, file_desc); if (result != nullptr) { - MemTracker::record_virtual_memory_reserve_and_commit((address)result, bytes, CALLER_PC, flag); + MemTracker::record_virtual_memory_reserve_and_commit((address)result, bytes, CALLER_PC, mem_tag); } return result; } char* os::map_memory(int fd, const char* file_name, size_t file_offset, char *addr, size_t bytes, bool read_only, - bool allow_exec, MEMFLAGS flags) { + bool allow_exec, MemTag mem_tag) { char* result = pd_map_memory(fd, file_name, file_offset, addr, bytes, read_only, allow_exec); if (result != nullptr) { - MemTracker::record_virtual_memory_reserve_and_commit((address)result, bytes, CALLER_PC, flags); + MemTracker::record_virtual_memory_reserve_and_commit((address)result, bytes, CALLER_PC, mem_tag); } return result; } diff --git a/src/hotspot/share/runtime/os.hpp b/src/hotspot/share/runtime/os.hpp index 1d81612c033..35a5be77b60 100644 --- a/src/hotspot/share/runtime/os.hpp +++ b/src/hotspot/share/runtime/os.hpp @@ -450,14 +450,14 @@ class os: AllStatic { inline static size_t cds_core_region_alignment(); // Reserves virtual memory. - static char* reserve_memory(size_t bytes, bool executable = false, MEMFLAGS flags = mtNone); + static char* reserve_memory(size_t bytes, bool executable = false, MemTag mem_tag = mtNone); // Reserves virtual memory that starts at an address that is aligned to 'alignment'. static char* reserve_memory_aligned(size_t size, size_t alignment, bool executable = false); // Attempts to reserve the virtual memory at [addr, addr + bytes). // Does not overwrite existing mappings. - static char* attempt_reserve_memory_at(char* addr, size_t bytes, bool executable = false, MEMFLAGS flag = mtNone); + static char* attempt_reserve_memory_at(char* addr, size_t bytes, bool executable = false, MemTag mem_tag = mtNone); // Given an address range [min, max), attempts to reserve memory within this area, with the given alignment. // If randomize is true, the location will be randomized. @@ -509,16 +509,16 @@ class os: AllStatic { static int create_file_for_heap(const char* dir); // Map memory to the file referred by fd. This function is slightly different from map_memory() // and is added to be used for implementation of -XX:AllocateHeapAt - static char* map_memory_to_file(size_t size, int fd, MEMFLAGS flag = mtNone); - static char* map_memory_to_file_aligned(size_t size, size_t alignment, int fd, MEMFLAGS flag = mtNone); + static char* map_memory_to_file(size_t size, int fd, MemTag mem_tag = mtNone); + static char* map_memory_to_file_aligned(size_t size, size_t alignment, int fd, MemTag mem_tag = mtNone); static char* map_memory_to_file(char* base, size_t size, int fd); - static char* attempt_map_memory_to_file_at(char* base, size_t size, int fd, MEMFLAGS flag = mtNone); + static char* attempt_map_memory_to_file_at(char* base, size_t size, int fd, MemTag mem_tag = mtNone); // Replace existing reserved memory with file mapping static char* replace_existing_mapping_with_file_mapping(char* base, size_t size, int fd); static char* map_memory(int fd, const char* file_name, size_t file_offset, char *addr, size_t bytes, bool read_only = false, - bool allow_exec = false, MEMFLAGS flags = mtNone); + bool allow_exec = false, MemTag mem_tag = mtNone); static bool unmap_memory(char *addr, size_t bytes); static void disclaim_memory(char *addr, size_t bytes); static void realign_memory(char *addr, size_t bytes, size_t alignment_hint); @@ -900,16 +900,16 @@ class os: AllStatic { static int get_native_stack(address* stack, int size, int toSkip = 0); // General allocation (must be MT-safe) - static void* malloc (size_t size, MEMFLAGS flags, const NativeCallStack& stack); - static void* malloc (size_t size, MEMFLAGS flags); - static void* realloc (void *memblock, size_t size, MEMFLAGS flag, const NativeCallStack& stack); - static void* realloc (void *memblock, size_t size, MEMFLAGS flag); + static void* malloc (size_t size, MemTag mem_tag, const NativeCallStack& stack); + static void* malloc (size_t size, MemTag mem_tag); + static void* realloc (void *memblock, size_t size, MemTag mem_tag, const NativeCallStack& stack); + static void* realloc (void *memblock, size_t size, MemTag mem_tag); // handles null pointers static void free (void *memblock); - static char* strdup(const char *, MEMFLAGS flags = mtInternal); // Like strdup + static char* strdup(const char *, MemTag mem_tag = mtInternal); // Like strdup // Like strdup, but exit VM when strdup() returns null - static char* strdup_check_oom(const char*, MEMFLAGS flags = mtInternal); + static char* strdup_check_oom(const char*, MemTag mem_tag = mtInternal); // SocketInterface (ex HPI SocketInterface ) static int socket_close(int fd); diff --git a/src/hotspot/share/runtime/osThread.hpp b/src/hotspot/share/runtime/osThread.hpp index b0e0588a6a2..597cf8e4d3f 100644 --- a/src/hotspot/share/runtime/osThread.hpp +++ b/src/hotspot/share/runtime/osThread.hpp @@ -25,111 +25,8 @@ #ifndef SHARE_RUNTIME_OSTHREAD_HPP #define SHARE_RUNTIME_OSTHREAD_HPP -#include "runtime/frame.hpp" -#include "runtime/handles.hpp" -#include "runtime/javaFrameAnchor.hpp" -#include "runtime/objectMonitor.hpp" -#include "runtime/suspendedThreadTask.hpp" #include "utilities/macros.hpp" - -#if defined(LINUX) || defined(AIX) || defined(BSD) -#include "suspendResume_posix.hpp" -#endif - -class Monitor; - -// The OSThread class holds OS-specific thread information. It is equivalent -// to the sys_thread_t structure of the classic JVM implementation. - -// The thread states represented by the ThreadState values are platform-specific -// and are likely to be only approximate, because most OSes don't give you access -// to precise thread state information. - -// Note: the ThreadState is legacy code and is not correctly implemented. -// Uses of ThreadState need to be replaced by the state in the JavaThread. - -enum ThreadState { - ALLOCATED, // Memory has been allocated but not initialized - INITIALIZED, // The thread has been initialized but yet started - RUNNABLE, // Has been started and is runnable, but not necessarily running - MONITOR_WAIT, // Waiting on a contended monitor lock - CONDVAR_WAIT, // Waiting on a condition variable - OBJECT_WAIT, // Waiting on an Object.wait() call - BREAKPOINTED, // Suspended at breakpoint - SLEEPING, // Thread.sleep() - ZOMBIE // All done, but not reclaimed yet -}; - -typedef int (*OSThreadStartFunc)(void*); - -class OSThread: public CHeapObj { - friend class VMStructs; - friend class JVMCIVMStructs; - private: - volatile ThreadState _state; // Thread state *hint* - - // Methods - public: - void set_state(ThreadState state) { _state = state; } - ThreadState get_state() { return _state; } - - OSThread(); - ~OSThread(); - - // Printing - void print_on(outputStream* st) const; - void print() const; - - // Platform dependent stuff +// The actual class declaration is platform specific. #include OS_HEADER(osThread) - public: - - thread_id_t thread_id() const { return _thread_id; } - - void set_thread_id(thread_id_t id) { _thread_id = id; } - - private: - // _thread_id is kernel thread id (similar to LWP id on Solaris). Each - // thread has a unique thread_id (BsdThreads or NPTL). It can be used - // to access /proc. - thread_id_t _thread_id; -}; - - -// Utility class for use with condition variables: -class OSThreadWaitState : public StackObj { - OSThread* _osthread; - ThreadState _old_state; - public: - OSThreadWaitState(OSThread* osthread, bool is_object_wait) { - _osthread = osthread; - _old_state = osthread->get_state(); - if (is_object_wait) { - osthread->set_state(OBJECT_WAIT); - } else { - osthread->set_state(CONDVAR_WAIT); - } - } - ~OSThreadWaitState() { - _osthread->set_state(_old_state); - } -}; - - -// Utility class for use with contended monitors: -class OSThreadContendState : public StackObj { - OSThread* _osthread; - ThreadState _old_state; - public: - OSThreadContendState(OSThread* osthread) { - _osthread = osthread; - _old_state = osthread->get_state(); - osthread->set_state(MONITOR_WAIT); - } - ~OSThreadContendState() { - _osthread->set_state(_old_state); - } -}; - #endif // SHARE_RUNTIME_OSTHREAD_HPP diff --git a/src/hotspot/share/runtime/osThread.cpp b/src/hotspot/share/runtime/osThreadBase.cpp similarity index 87% rename from src/hotspot/share/runtime/osThread.cpp rename to src/hotspot/share/runtime/osThreadBase.cpp index edaefaa1070..7bb7ae6aa69 100644 --- a/src/hotspot/share/runtime/osThread.cpp +++ b/src/hotspot/share/runtime/osThreadBase.cpp @@ -24,19 +24,11 @@ #include "precompiled.hpp" #include "oops/oop.inline.hpp" -#include "runtime/osThread.hpp" - -OSThread::OSThread() { - pd_initialize(); -} - -OSThread::~OSThread() { - pd_destroy(); -} +#include "runtime/osThreadBase.hpp" // Printing -void OSThread::print_on(outputStream *st) const { - st->print("nid=" UINT64_FORMAT " ", (uint64_t)thread_id()); +void OSThreadBase::print_on(outputStream *st) const { + st->print("nid=" UINTX_FORMAT " ", thread_id_for_printing()); switch (_state) { case ALLOCATED: st->print("allocated "); break; case INITIALIZED: st->print("initialized "); break; @@ -51,4 +43,4 @@ void OSThread::print_on(outputStream *st) const { } } -void OSThread::print() const { print_on(tty); } +void OSThreadBase::print() const { print_on(tty); } diff --git a/src/hotspot/share/runtime/osThreadBase.hpp b/src/hotspot/share/runtime/osThreadBase.hpp new file mode 100644 index 00000000000..4063da18519 --- /dev/null +++ b/src/hotspot/share/runtime/osThreadBase.hpp @@ -0,0 +1,115 @@ +/* + * Copyright (c) 1997, 2022, 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. + * + */ + +#ifndef SHARE_RUNTIME_OSTHREAD_BASE_HPP +#define SHARE_RUNTIME_OSTHREAD_BASE_HPP + +#include "memory/allocation.hpp" + +class Monitor; + +// The OSThread class holds OS-specific thread information. It is equivalent +// to the sys_thread_t structure of the classic JVM implementation. + +// The thread states represented by the ThreadState values are platform-specific +// and are likely to be only approximate, because most OSes don't give you access +// to precise thread state information. + +// Note: the ThreadState is legacy code and is not correctly implemented. +// Uses of ThreadState need to be replaced by the state in the JavaThread. + +enum ThreadState { + ALLOCATED, // Memory has been allocated but not initialized + INITIALIZED, // The thread has been initialized but yet started + RUNNABLE, // Has been started and is runnable, but not necessarily running + MONITOR_WAIT, // Waiting on a contended monitor lock + CONDVAR_WAIT, // Waiting on a condition variable + OBJECT_WAIT, // Waiting on an Object.wait() call + BREAKPOINTED, // Suspended at breakpoint + SLEEPING, // Thread.sleep() + ZOMBIE // All done, but not reclaimed yet +}; + +typedef int (*OSThreadStartFunc)(void*); + +class OSThreadBase: public CHeapObj { + friend class VMStructs; + friend class JVMCIVMStructs; + private: + volatile ThreadState _state; // Thread state *hint* + + // Methods + public: + OSThreadBase() {} + virtual ~OSThreadBase() {} + NONCOPYABLE(OSThreadBase); + + void set_state(ThreadState state) { _state = state; } + ThreadState get_state() { return _state; } + + + virtual uintx thread_id_for_printing() const = 0; + + // Printing + void print_on(outputStream* st) const; + void print() const; +}; + + +// Utility class for use with condition variables: +class OSThreadWaitState : public StackObj { + OSThreadBase* _osthread; + ThreadState _old_state; + public: + OSThreadWaitState(OSThreadBase* osthread, bool is_object_wait) { + _osthread = osthread; + _old_state = osthread->get_state(); + if (is_object_wait) { + osthread->set_state(OBJECT_WAIT); + } else { + osthread->set_state(CONDVAR_WAIT); + } + } + ~OSThreadWaitState() { + _osthread->set_state(_old_state); + } +}; + + +// Utility class for use with contended monitors: +class OSThreadContendState : public StackObj { + OSThreadBase* _osthread; + ThreadState _old_state; + public: + OSThreadContendState(OSThreadBase* osthread) { + _osthread = osthread; + _old_state = osthread->get_state(); + osthread->set_state(MONITOR_WAIT); + } + ~OSThreadContendState() { + _osthread->set_state(_old_state); + } +}; + +#endif // SHARE_RUNTIME_OSTHREAD_BASE_HPP diff --git a/src/hotspot/share/runtime/reflection.cpp b/src/hotspot/share/runtime/reflection.cpp index ab3d82ad7e2..15172b7f4c3 100644 --- a/src/hotspot/share/runtime/reflection.cpp +++ b/src/hotspot/share/runtime/reflection.cpp @@ -766,10 +766,10 @@ static Handle new_type(Symbol* signature, Klass* k, TRAPS) { } oop Reflection::new_method(const methodHandle& method, bool for_constant_pool_access, TRAPS) { - // Allow sun.reflect.ConstantPool to refer to methods as java.lang.reflect.Methods. - assert(!method()->is_initializer() || - (for_constant_pool_access && method()->is_static()), - "should call new_constructor instead"); + // Allow jdk.internal.reflect.ConstantPool to refer to methods as java.lang.reflect.Methods. + assert(!method()->is_object_initializer() && + (for_constant_pool_access || !method()->is_static_initializer()), + "Should not be the initializer"); InstanceKlass* holder = method->method_holder(); int slot = method->method_idnum(); @@ -817,7 +817,7 @@ oop Reflection::new_method(const methodHandle& method, bool for_constant_pool_ac oop Reflection::new_constructor(const methodHandle& method, TRAPS) { - assert(method()->is_initializer(), "should call new_method instead"); + assert(method()->is_object_initializer(), "Should be the initializer"); InstanceKlass* holder = method->method_holder(); int slot = method->method_idnum(); diff --git a/src/hotspot/share/runtime/safepointMechanism.cpp b/src/hotspot/share/runtime/safepointMechanism.cpp index 624583db3d1..a6aadf5ebc4 100644 --- a/src/hotspot/share/runtime/safepointMechanism.cpp +++ b/src/hotspot/share/runtime/safepointMechanism.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -60,7 +60,7 @@ void SafepointMechanism::default_initialize() { const size_t allocation_size = 2 * page_size; char* polling_page = os::reserve_memory(allocation_size); os::commit_memory_or_exit(polling_page, allocation_size, false, "Unable to commit Safepoint polling page"); - MemTracker::record_virtual_memory_type((address)polling_page, mtSafepoint); + MemTracker::record_virtual_memory_tag((address)polling_page, mtSafepoint); char* bad_page = polling_page; char* good_page = polling_page + page_size; diff --git a/src/hotspot/share/runtime/sharedRuntime.cpp b/src/hotspot/share/runtime/sharedRuntime.cpp index f98d031a2cd..e4d4e6aea0f 100644 --- a/src/hotspot/share/runtime/sharedRuntime.cpp +++ b/src/hotspot/share/runtime/sharedRuntime.cpp @@ -92,61 +92,61 @@ // Shared runtime stub routines reside in their own unique blob with a // single entry point -RuntimeStub* SharedRuntime::_wrong_method_blob; -RuntimeStub* SharedRuntime::_wrong_method_abstract_blob; -RuntimeStub* SharedRuntime::_ic_miss_blob; -RuntimeStub* SharedRuntime::_resolve_opt_virtual_call_blob; -RuntimeStub* SharedRuntime::_resolve_virtual_call_blob; -RuntimeStub* SharedRuntime::_resolve_static_call_blob; -DeoptimizationBlob* SharedRuntime::_deopt_blob; -SafepointBlob* SharedRuntime::_polling_page_vectors_safepoint_handler_blob; -SafepointBlob* SharedRuntime::_polling_page_safepoint_handler_blob; -SafepointBlob* SharedRuntime::_polling_page_return_handler_blob; - -RuntimeStub* SharedRuntime::_throw_AbstractMethodError_blob; -RuntimeStub* SharedRuntime::_throw_IncompatibleClassChangeError_blob; -RuntimeStub* SharedRuntime::_throw_NullPointerException_at_call_blob; -RuntimeStub* SharedRuntime::_throw_StackOverflowError_blob; -RuntimeStub* SharedRuntime::_throw_delayed_StackOverflowError_blob; - -#if INCLUDE_JFR -RuntimeStub* SharedRuntime::_jfr_write_checkpoint_blob = nullptr; -RuntimeStub* SharedRuntime::_jfr_return_lease_blob = nullptr; -#endif +#define SHARED_STUB_FIELD_DEFINE(name, type) \ + type SharedRuntime::BLOB_FIELD_NAME(name); + SHARED_STUBS_DO(SHARED_STUB_FIELD_DEFINE) +#undef SHARED_STUB_FIELD_DEFINE nmethod* SharedRuntime::_cont_doYield_stub; +#define SHARED_STUB_NAME_DECLARE(name, type) "Shared Runtime " # name "_blob", +const char *SharedRuntime::_stub_names[] = { + SHARED_STUBS_DO(SHARED_STUB_NAME_DECLARE) +}; + //----------------------------generate_stubs----------------------------------- void SharedRuntime::generate_initial_stubs() { // Build this early so it's available for the interpreter. _throw_StackOverflowError_blob = - generate_throw_exception("StackOverflowError throw_exception", + generate_throw_exception(SharedStubId::throw_StackOverflowError_id, CAST_FROM_FN_PTR(address, SharedRuntime::throw_StackOverflowError)); } void SharedRuntime::generate_stubs() { - _wrong_method_blob = generate_resolve_blob(CAST_FROM_FN_PTR(address, SharedRuntime::handle_wrong_method), "wrong_method_stub"); - _wrong_method_abstract_blob = generate_resolve_blob(CAST_FROM_FN_PTR(address, SharedRuntime::handle_wrong_method_abstract), "wrong_method_abstract_stub"); - _ic_miss_blob = generate_resolve_blob(CAST_FROM_FN_PTR(address, SharedRuntime::handle_wrong_method_ic_miss), "ic_miss_stub"); - _resolve_opt_virtual_call_blob = generate_resolve_blob(CAST_FROM_FN_PTR(address, SharedRuntime::resolve_opt_virtual_call_C), "resolve_opt_virtual_call"); - _resolve_virtual_call_blob = generate_resolve_blob(CAST_FROM_FN_PTR(address, SharedRuntime::resolve_virtual_call_C), "resolve_virtual_call"); - _resolve_static_call_blob = generate_resolve_blob(CAST_FROM_FN_PTR(address, SharedRuntime::resolve_static_call_C), "resolve_static_call"); + _wrong_method_blob = + generate_resolve_blob(SharedStubId::wrong_method_id, + CAST_FROM_FN_PTR(address, SharedRuntime::handle_wrong_method)); + _wrong_method_abstract_blob = + generate_resolve_blob(SharedStubId::wrong_method_abstract_id, + CAST_FROM_FN_PTR(address, SharedRuntime::handle_wrong_method_abstract)); + _ic_miss_blob = + generate_resolve_blob(SharedStubId::ic_miss_id, + CAST_FROM_FN_PTR(address, SharedRuntime::handle_wrong_method_ic_miss)); + _resolve_opt_virtual_call_blob = + generate_resolve_blob(SharedStubId::resolve_opt_virtual_call_id, + CAST_FROM_FN_PTR(address, SharedRuntime::resolve_opt_virtual_call_C)); + _resolve_virtual_call_blob = + generate_resolve_blob(SharedStubId::resolve_virtual_call_id, + CAST_FROM_FN_PTR(address, SharedRuntime::resolve_virtual_call_C)); + _resolve_static_call_blob = + generate_resolve_blob(SharedStubId::resolve_static_call_id, + CAST_FROM_FN_PTR(address, SharedRuntime::resolve_static_call_C)); _throw_delayed_StackOverflowError_blob = - generate_throw_exception("delayed StackOverflowError throw_exception", + generate_throw_exception(SharedStubId::throw_delayed_StackOverflowError_id, CAST_FROM_FN_PTR(address, SharedRuntime::throw_delayed_StackOverflowError)); _throw_AbstractMethodError_blob = - generate_throw_exception("AbstractMethodError throw_exception", + generate_throw_exception(SharedStubId::throw_AbstractMethodError_id, CAST_FROM_FN_PTR(address, SharedRuntime::throw_AbstractMethodError)); _throw_IncompatibleClassChangeError_blob = - generate_throw_exception("IncompatibleClassChangeError throw_exception", + generate_throw_exception(SharedStubId::throw_IncompatibleClassChangeError_id, CAST_FROM_FN_PTR(address, SharedRuntime::throw_IncompatibleClassChangeError)); _throw_NullPointerException_at_call_blob = - generate_throw_exception("NullPointerException at call throw_exception", + generate_throw_exception(SharedStubId::throw_NullPointerException_at_call_id, CAST_FROM_FN_PTR(address, SharedRuntime::throw_NullPointerException_at_call)); AdapterHandlerLibrary::initialize(); @@ -155,11 +155,17 @@ void SharedRuntime::generate_stubs() { // Vectors are generated only by C2 and JVMCI. bool support_wide = is_wide_vector(MaxVectorSize); if (support_wide) { - _polling_page_vectors_safepoint_handler_blob = generate_handler_blob(CAST_FROM_FN_PTR(address, SafepointSynchronize::handle_polling_page_exception), POLL_AT_VECTOR_LOOP); + _polling_page_vectors_safepoint_handler_blob = + generate_handler_blob(SharedStubId::polling_page_vectors_safepoint_handler_id, + CAST_FROM_FN_PTR(address, SafepointSynchronize::handle_polling_page_exception)); } #endif // COMPILER2_OR_JVMCI - _polling_page_safepoint_handler_blob = generate_handler_blob(CAST_FROM_FN_PTR(address, SafepointSynchronize::handle_polling_page_exception), POLL_AT_LOOP); - _polling_page_return_handler_blob = generate_handler_blob(CAST_FROM_FN_PTR(address, SafepointSynchronize::handle_polling_page_exception), POLL_AT_RETURN); + _polling_page_safepoint_handler_blob = + generate_handler_blob(SharedStubId::polling_page_safepoint_handler_id, + CAST_FROM_FN_PTR(address, SafepointSynchronize::handle_polling_page_exception)); + _polling_page_return_handler_blob = + generate_handler_blob(SharedStubId::polling_page_return_handler_id, + CAST_FROM_FN_PTR(address, SafepointSynchronize::handle_polling_page_exception)); generate_deopt_blob(); } @@ -645,7 +651,7 @@ void SharedRuntime::throw_and_post_jvmti_exception(JavaThread* current, Handle h } #if INCLUDE_JVMCI - if (EnableJVMCI && UseJVMCICompiler) { + if (EnableJVMCI) { vframeStream vfst(current, true); methodHandle method = methodHandle(current, vfst.method()); int bci = vfst.bci(); @@ -1957,6 +1963,26 @@ void SharedRuntime::monitor_exit_helper(oopDesc* obj, BasicLock* lock, JavaThrea assert(JavaThread::current() == current, "invariant"); // Exit must be non-blocking, and therefore no exceptions can be thrown. ExceptionMark em(current); + + // Check if C2_MacroAssembler::fast_unlock() or + // C2_MacroAssembler::fast_unlock_lightweight() unlocked an inflated + // monitor before going slow path. Since there is no safepoint + // polling when calling into the VM, we can be sure that the monitor + // hasn't been deallocated. + ObjectMonitor* m = current->unlocked_inflated_monitor(); + if (m != nullptr) { + assert(m->owner_raw() != current, "must be"); + current->clear_unlocked_inflated_monitor(); + + // We need to reacquire the lock before we can call ObjectSynchronizer::exit(). + if (!m->try_enter(current, /*check_for_recursion*/ false)) { + // Some other thread acquired the lock (or the monitor was + // deflated). Either way we are done. + current->dec_held_monitor_count(); + return; + } + } + // The object could become unlocked through a JNI call, which we have no other checks for. // Give a fatal message if CheckJNICalls. Otherwise we ignore it. if (obj->is_unlocked()) { diff --git a/src/hotspot/share/runtime/sharedRuntime.hpp b/src/hotspot/share/runtime/sharedRuntime.hpp index 00a72f5db1e..f530c0ad2a8 100644 --- a/src/hotspot/share/runtime/sharedRuntime.hpp +++ b/src/hotspot/share/runtime/sharedRuntime.hpp @@ -30,6 +30,7 @@ #include "interpreter/linkResolver.hpp" #include "memory/allStatic.hpp" #include "memory/resourceArea.hpp" +#include "runtime/stubDeclarations.hpp" #include "utilities/macros.hpp" class AdapterHandlerEntry; @@ -42,37 +43,57 @@ class vframeStream; // Java exceptions), locking/unlocking mechanisms, statistical // information, etc. +// define SharedStubId enum tags: wrong_method_id, etc + +#define SHARED_STUB_ID_ENUM_DECLARE(name, type) STUB_ID_NAME(name), +enum class SharedStubId :int { + NO_STUBID = -1, + SHARED_STUBS_DO(SHARED_STUB_ID_ENUM_DECLARE) + NUM_STUBIDS +}; +#undef SHARED_STUB_ID_ENUM_DECLARE + class SharedRuntime: AllStatic { friend class VMStructs; private: - // Shared stub locations + // Declare shared stub fields +#define SHARED_STUB_FIELD_DECLARE(name, type) \ + static type BLOB_FIELD_NAME(name); + SHARED_STUBS_DO(SHARED_STUB_FIELD_DECLARE) +#undef SHARED_STUB_FIELD_DECLARE - static RuntimeStub* _wrong_method_blob; - static RuntimeStub* _wrong_method_abstract_blob; - static RuntimeStub* _ic_miss_blob; - static RuntimeStub* _resolve_opt_virtual_call_blob; - static RuntimeStub* _resolve_virtual_call_blob; - static RuntimeStub* _resolve_static_call_blob; - - static DeoptimizationBlob* _deopt_blob; - - static SafepointBlob* _polling_page_vectors_safepoint_handler_blob; - static SafepointBlob* _polling_page_safepoint_handler_blob; - static SafepointBlob* _polling_page_return_handler_blob; +#ifdef ASSERT + static bool is_resolve_id(SharedStubId id) { + return (id == SharedStubId::wrong_method_id || + id == SharedStubId::wrong_method_abstract_id || + id == SharedStubId::ic_miss_id || + id == SharedStubId::resolve_opt_virtual_call_id || + id == SharedStubId::resolve_virtual_call_id || + id == SharedStubId::resolve_static_call_id); + } + static bool is_polling_page_id(SharedStubId id) { + return (id == SharedStubId::polling_page_vectors_safepoint_handler_id || + id == SharedStubId::polling_page_safepoint_handler_id || + id == SharedStubId::polling_page_return_handler_id); + } + static bool is_throw_id(SharedStubId id) { + return (id == SharedStubId::throw_AbstractMethodError_id || + id == SharedStubId::throw_IncompatibleClassChangeError_id || + id == SharedStubId::throw_NullPointerException_at_call_id || + id == SharedStubId::throw_StackOverflowError_id || + id == SharedStubId::throw_delayed_StackOverflowError_id); + } +#endif + // cont_doYieldStub is not yet folded into the general model for + // shared stub/blob handling. It is actually a specially generated + // native wrapper for a specific native method, as also is it's + // counterpart the continuation do_enter method. static nmethod* _cont_doYield_stub; - static RuntimeStub* _throw_AbstractMethodError_blob; - static RuntimeStub* _throw_IncompatibleClassChangeError_blob; - static RuntimeStub* _throw_NullPointerException_at_call_blob; - static RuntimeStub* _throw_StackOverflowError_blob; - static RuntimeStub* _throw_delayed_StackOverflowError_blob; - -#if INCLUDE_JFR - static RuntimeStub* _jfr_write_checkpoint_blob; - static RuntimeStub* _jfr_return_lease_blob; -#endif + // Stub names indexed by SharedStubId + static const char *_stub_names[]; #ifndef PRODUCT // Counters @@ -80,10 +101,9 @@ class SharedRuntime: AllStatic { #endif // !PRODUCT private: - enum { POLL_AT_RETURN, POLL_AT_LOOP, POLL_AT_VECTOR_LOOP }; - static SafepointBlob* generate_handler_blob(address call_ptr, int poll_type); - static RuntimeStub* generate_resolve_blob(address destination, const char* name); - static RuntimeStub* generate_throw_exception(const char* name, address runtime_entry); + static SafepointBlob* generate_handler_blob(SharedStubId id, address call_ptr); + static RuntimeStub* generate_resolve_blob(SharedStubId id, address destination); + static RuntimeStub* generate_throw_exception(SharedStubId id, address runtime_entry); public: static void generate_initial_stubs(void); static void generate_stubs(void); @@ -97,6 +117,11 @@ class SharedRuntime: AllStatic { static RuntimeStub* generate_jfr_return_lease(); #endif + static const char *stub_name(SharedStubId id) { + assert(id > SharedStubId::NO_STUBID && id < SharedStubId::NUM_STUBIDS, "stub id out of range"); + return _stub_names[(int)id]; + } + // max bytes for each dtrace string parameter enum { max_dtrace_string_size = 256 }; diff --git a/src/hotspot/share/runtime/stackOverflow.hpp b/src/hotspot/share/runtime/stackOverflow.hpp index b897c86d249..4734a6c6788 100644 --- a/src/hotspot/share/runtime/stackOverflow.hpp +++ b/src/hotspot/share/runtime/stackOverflow.hpp @@ -293,6 +293,16 @@ class StackOverflow { return _shadow_zone_safe_limit; } + address shadow_zone_growth_watermark() const { + assert(_shadow_zone_growth_watermark != nullptr, "Don't call this before the field is initialized."); + return _shadow_zone_growth_watermark; + } + + void set_shadow_zone_growth_watermark(address new_watermark) { + assert(_shadow_zone_growth_watermark != nullptr, "Don't call this before the field is initialized."); + _shadow_zone_growth_watermark = new_watermark; + } + void create_stack_guard_pages(); void remove_stack_guard_pages(); diff --git a/src/hotspot/share/runtime/statSampler.cpp b/src/hotspot/share/runtime/statSampler.cpp index 5fd038bf845..bbd8d3096bb 100644 --- a/src/hotspot/share/runtime/statSampler.cpp +++ b/src/hotspot/share/runtime/statSampler.cpp @@ -201,7 +201,8 @@ void StatSampler::assert_system_property(const char* name, const char* value, TR // convert Java String to utf8 string char* system_value = java_lang_String::as_utf8_string(value_oop); - assert(strcmp(value, system_value) == 0, "property value mustn't differ from System.getProperty"); + assert(strcmp(value, system_value) == 0, "property value mustn't differ from System.getProperty. Our value is: %s, System.getProperty is: %s", + value, system_value); #endif // ASSERT } diff --git a/src/hotspot/share/runtime/stubDeclarations.hpp b/src/hotspot/share/runtime/stubDeclarations.hpp new file mode 100644 index 00000000000..ccca14c61b5 --- /dev/null +++ b/src/hotspot/share/runtime/stubDeclarations.hpp @@ -0,0 +1,181 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 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. + * + */ + +#ifndef SHARE_RUNTIME_STUBDECLARATIONS_HPP +#define SHARE_RUNTIME_STUBDECLARATIONS_HPP + +#include "utilities/macros.hpp" + +// macros for generating definitions and declarations for shared, c1 +// and opto blob fields and associated stub ids + +// Different shared stubs can have different blob types and may +// include some JFR stubs +// +// n.b resolve, handler and throw stubs must remain grouped in the +// same order to allow id values to be range checked + +#if INCLUDE_JFR +// do_blob(name, type) +#define SHARED_JFR_STUBS_DO(do_blob) \ + do_blob(jfr_write_checkpoint, RuntimeStub*) \ + do_blob(jfr_return_lease, RuntimeStub*) \ + +#else +#define SHARED_JFR_STUBS_DO(do_blob) +#endif + +// do_blob(name, type) +#define SHARED_STUBS_DO(do_blob) \ + do_blob(deopt, DeoptimizationBlob*) \ + /* resolve stubs */ \ + do_blob(wrong_method, RuntimeStub*) \ + do_blob(wrong_method_abstract, RuntimeStub*) \ + do_blob(ic_miss, RuntimeStub*) \ + do_blob(resolve_opt_virtual_call, RuntimeStub*) \ + do_blob(resolve_virtual_call, RuntimeStub*) \ + do_blob(resolve_static_call, RuntimeStub*) \ + /* handler stubs */ \ + do_blob(polling_page_vectors_safepoint_handler, SafepointBlob*) \ + do_blob(polling_page_safepoint_handler, SafepointBlob*) \ + do_blob(polling_page_return_handler, SafepointBlob*) \ + /* throw stubs */ \ + do_blob(throw_AbstractMethodError, RuntimeStub*) \ + do_blob(throw_IncompatibleClassChangeError, RuntimeStub*) \ + do_blob(throw_NullPointerException_at_call, RuntimeStub*) \ + do_blob(throw_StackOverflowError, RuntimeStub*) \ + do_blob(throw_delayed_StackOverflowError, RuntimeStub*) \ + /* other stubs */ \ + SHARED_JFR_STUBS_DO(do_blob) \ + +// C1 stubs are always generated in a generic CodeBlob + +#ifdef COMPILER1 +// do_blob(name) +#define C1_STUBS_DO(do_blob) \ + do_blob(dtrace_object_alloc) \ + do_blob(unwind_exception) \ + do_blob(forward_exception) \ + do_blob(throw_range_check_failed) /* throws ArrayIndexOutOfBoundsException */ \ + do_blob(throw_index_exception) /* throws IndexOutOfBoundsException */ \ + do_blob(throw_div0_exception) \ + do_blob(throw_null_pointer_exception) \ + do_blob(register_finalizer) \ + do_blob(new_instance) \ + do_blob(fast_new_instance) \ + do_blob(fast_new_instance_init_check) \ + do_blob(new_type_array) \ + do_blob(new_object_array) \ + do_blob(new_multi_array) \ + do_blob(handle_exception_nofpu) /* optimized version that does not preserve fpu registers */ \ + do_blob(handle_exception) \ + do_blob(handle_exception_from_callee) \ + do_blob(throw_array_store_exception) \ + do_blob(throw_class_cast_exception) \ + do_blob(throw_incompatible_class_change_error) \ + do_blob(slow_subtype_check) \ + do_blob(monitorenter) \ + do_blob(monitorenter_nofpu) /* optimized version that does not preserve fpu registers */ \ + do_blob(monitorexit) \ + do_blob(monitorexit_nofpu) /* optimized version that does not preserve fpu registers */ \ + do_blob(deoptimize) \ + do_blob(access_field_patching) \ + do_blob(load_klass_patching) \ + do_blob(load_mirror_patching) \ + do_blob(load_appendix_patching) \ + do_blob(fpu2long_stub) \ + do_blob(counter_overflow) \ + do_blob(predicate_failed_trap) \ + +#else +#define C1_STUBS_DO(do_blob) +#endif + +// Opto stubs can be stored as entries with just an address or as +// blobs of different types. The former may include some JVMTI stubs. +// +// n.b. blobs and stub defines are generated in the order defined by +// C2_STUBS_DO, allowing dependencies from any givem stub on its +// predecessors to be guaranteed. That explains the initial placement +// of the blob declarations and intermediate placement of the jvmti +// stubs. + +#ifdef COMPILER2 +// do_jvmti_stub(name) +#if INCLUDE_JVMTI +#define C2_JVMTI_STUBS_DO(do_jvmti_stub) \ + do_jvmti_stub(notify_jvmti_vthread_start) \ + do_jvmti_stub(notify_jvmti_vthread_end) \ + do_jvmti_stub(notify_jvmti_vthread_mount) \ + do_jvmti_stub(notify_jvmti_vthread_unmount) \ + +#else +#define C2_JVMTI_STUBS_DO(do_jvmti_stub) +#endif // INCLUDE_JVMTI + +// do_blob(name, type) +// do_stub(name, fancy_jump, pass_tls, return_pc) +// do_jvmti_stub(name) +// +// n.b. non-jvmti stubs may employ a special type of jump (0, 1 or 2) +// and require access to TLS and the return pc. jvmti stubs always +// employ jump 0, and require no special access +#define C2_STUBS_DO(do_blob, do_stub, do_jvmti_stub) \ + do_blob(uncommon_trap, UncommonTrapBlob*) \ + do_blob(exception, ExceptionBlob*) \ + do_stub(new_instance, 0, true, false) \ + do_stub(new_array, 0, true, false) \ + do_stub(new_array_nozero, 0, true, false) \ + do_stub(multianewarray2, 0, true, false) \ + do_stub(multianewarray3, 0, true, false) \ + do_stub(multianewarray4, 0, true, false) \ + do_stub(multianewarray5, 0, true, false) \ + do_stub(multianewarrayN, 0, true, false) \ + C2_JVMTI_STUBS_DO(do_jvmti_stub) \ + do_stub(complete_monitor_locking, 0, false, false) \ + do_stub(monitor_notify, 0, false, false) \ + do_stub(monitor_notifyAll, 0, false, false) \ + do_stub(rethrow, 2, true, true) \ + do_stub(slow_arraycopy, 0, false, false) \ + do_stub(register_finalizer, 0, false, false) \ + +#else +#define C2_STUBS_DO(do_blob, do_stub, do_jvmti_stub) +#endif + +// generate a stub or blob id enum tag from a name + +#define STUB_ID_NAME(base) base##_id + +// generate a stub field name + +#define STUB_FIELD_NAME(base) _##base + +// generate a blob field name + +#define BLOB_FIELD_NAME(base) _##base##_blob + +#endif // SHARE_RUNTIME_STUBDECLARATIONS_HPP + diff --git a/src/hotspot/share/runtime/stubRoutines.cpp b/src/hotspot/share/runtime/stubRoutines.cpp index c13f64fca4b..c881b64b592 100644 --- a/src/hotspot/share/runtime/stubRoutines.cpp +++ b/src/hotspot/share/runtime/stubRoutines.cpp @@ -171,12 +171,13 @@ address StubRoutines::_dlibm_sin_cos_huge = nullptr; address StubRoutines::_dlibm_reduce_pi04l = nullptr; address StubRoutines::_dlibm_tan_cot_huge = nullptr; address StubRoutines::_dtan = nullptr; +address StubRoutines::_dtanh = nullptr; address StubRoutines::_f2hf = nullptr; address StubRoutines::_hf2f = nullptr; -address StubRoutines::_vector_f_math[VectorSupport::NUM_VEC_SIZES][VectorSupport::NUM_SVML_OP] = {{nullptr}, {nullptr}}; -address StubRoutines::_vector_d_math[VectorSupport::NUM_VEC_SIZES][VectorSupport::NUM_SVML_OP] = {{nullptr}, {nullptr}}; +address StubRoutines::_vector_f_math[VectorSupport::NUM_VEC_SIZES][VectorSupport::NUM_VECTOR_OP_MATH] = {{nullptr}, {nullptr}}; +address StubRoutines::_vector_d_math[VectorSupport::NUM_VEC_SIZES][VectorSupport::NUM_VECTOR_OP_MATH] = {{nullptr}, {nullptr}}; address StubRoutines::_method_entry_barrier = nullptr; address StubRoutines::_array_sort = nullptr; @@ -187,6 +188,7 @@ address StubRoutines::_cont_returnBarrier = nullptr; address StubRoutines::_cont_returnBarrierExc = nullptr; address StubRoutines::_upcall_stub_exception_handler = nullptr; +address StubRoutines::_upcall_stub_load_target = nullptr; address StubRoutines::_lookup_secondary_supers_table_slow_path_stub = nullptr; address StubRoutines::_lookup_secondary_supers_table_stubs[Klass::SECONDARY_SUPERS_TABLE_SIZE] = { nullptr }; diff --git a/src/hotspot/share/runtime/stubRoutines.hpp b/src/hotspot/share/runtime/stubRoutines.hpp index 206a5ec2e99..f025742b605 100644 --- a/src/hotspot/share/runtime/stubRoutines.hpp +++ b/src/hotspot/share/runtime/stubRoutines.hpp @@ -281,6 +281,7 @@ class StubRoutines: AllStatic { static address _dlibm_reduce_pi04l; static address _dlibm_tan_cot_huge; static address _dtan; + static address _dtanh; static address _fmod; static address _f2hf; @@ -293,10 +294,11 @@ class StubRoutines: AllStatic { static address _cont_returnBarrierExc; // Vector Math Routines - static address _vector_f_math[VectorSupport::NUM_VEC_SIZES][VectorSupport::NUM_SVML_OP]; - static address _vector_d_math[VectorSupport::NUM_VEC_SIZES][VectorSupport::NUM_SVML_OP]; + static address _vector_f_math[VectorSupport::NUM_VEC_SIZES][VectorSupport::NUM_VECTOR_OP_MATH]; + static address _vector_d_math[VectorSupport::NUM_VEC_SIZES][VectorSupport::NUM_VECTOR_OP_MATH]; static address _upcall_stub_exception_handler; + static address _upcall_stub_load_target; static address _lookup_secondary_supers_table_stubs[]; static address _lookup_secondary_supers_table_slow_path_stub; @@ -404,7 +406,7 @@ class StubRoutines: AllStatic { static address unsafe_setmemory() { return _unsafe_setmemory; } - typedef void (*UnsafeSetMemoryStub)(const void* src, size_t count, char byte); + typedef void (*UnsafeSetMemoryStub)(void* dst, size_t count, char byte); static UnsafeSetMemoryStub UnsafeSetMemory_stub() { return CAST_TO_FN_PTR(UnsafeSetMemoryStub, _unsafe_setmemory); } static address generic_arraycopy() { return _generic_arraycopy; } @@ -472,6 +474,7 @@ class StubRoutines: AllStatic { static address dlibm_sin_cos_huge() { return _dlibm_sin_cos_huge; } static address dlibm_tan_cot_huge() { return _dlibm_tan_cot_huge; } static address dtan() { return _dtan; } + static address dtanh() { return _dtanh; } // These are versions of the java.lang.Float::floatToFloat16() and float16ToFloat() // methods which perform the same operations as the intrinsic version. @@ -504,6 +507,11 @@ class StubRoutines: AllStatic { return _upcall_stub_exception_handler; } + static address upcall_stub_load_target() { + assert(_upcall_stub_load_target != nullptr, "not implemented"); + return _upcall_stub_load_target; + } + static address lookup_secondary_supers_table_stub(u1 slot) { assert(slot < Klass::SECONDARY_SUPERS_TABLE_SIZE, "out of bounds"); assert(_lookup_secondary_supers_table_stubs[slot] != nullptr, "not implemented"); diff --git a/src/hotspot/share/runtime/thread.cpp b/src/hotspot/share/runtime/thread.cpp index e72077adabf..df6a660a0aa 100644 --- a/src/hotspot/share/runtime/thread.cpp +++ b/src/hotspot/share/runtime/thread.cpp @@ -64,7 +64,7 @@ THREAD_LOCAL Thread* Thread::_thr_current = nullptr; DEBUG_ONLY(Thread* Thread::_starting_thread = nullptr;) -Thread::Thread(MEMFLAGS flags) { +Thread::Thread(MemTag mem_tag) { DEBUG_ONLY(_run_state = PRE_CALL_RUN;) @@ -78,12 +78,11 @@ Thread::Thread(MEMFLAGS flags) { // allocated data structures set_osthread(nullptr); - set_resource_area(new (flags) ResourceArea(flags)); + set_resource_area(new (mem_tag) ResourceArea(mem_tag)); DEBUG_ONLY(_current_resource_mark = nullptr;) - set_handle_area(new (flags) HandleArea(flags, nullptr)); + set_handle_area(new (mem_tag) HandleArea(mem_tag, nullptr)); set_metadata_handles(new (mtClass) GrowableArray(30, mtClass)); set_last_handle_mark(nullptr); - DEBUG_ONLY(_missed_ic_stub_refill_verifier = nullptr); // Initial value of zero ==> never claimed. _threads_do_token = 0; @@ -145,6 +144,16 @@ Thread::Thread(MEMFLAGS flags) { MACOS_AARCH64_ONLY(DEBUG_ONLY(_wx_init = false)); } +#ifdef ASSERT +address Thread::stack_base() const { + // Note: can't report Thread::name() here as that can require a ResourceMark which we + // can't use because this gets called too early in the thread initialization. + assert(_stack_base != nullptr, "Stack base not yet set for thread id:%d (0 if not set)", + osthread() != nullptr ? osthread()->thread_id() : 0); + return _stack_base; +} +#endif + void Thread::initialize_tlab() { if (UseTLAB) { tlab().initialize(); diff --git a/src/hotspot/share/runtime/thread.hpp b/src/hotspot/share/runtime/thread.hpp index e9fee4d113a..e2dfce7b255 100644 --- a/src/hotspot/share/runtime/thread.hpp +++ b/src/hotspot/share/runtime/thread.hpp @@ -33,6 +33,7 @@ #include "runtime/atomic.hpp" #include "runtime/globals.hpp" #include "runtime/os.hpp" +#include "runtime/safepointMechanism.hpp" #include "runtime/threadHeapSampler.hpp" #include "runtime/threadLocalStorage.hpp" #include "runtime/threadStatisticalInfo.hpp" @@ -46,7 +47,6 @@ class CompilerThread; class HandleArea; class HandleMark; -class ICRefillVerifier; class JvmtiRawMonitor; class NMethodClosure; class Metadata; @@ -110,6 +110,7 @@ class Thread: public ThreadShadow { friend class VMErrorCallbackMark; friend class VMStructs; friend class JVMCIVMStructs; + friend class JavaThread; private: #ifndef USE_LIBRARY_BASED_TLS_ONLY @@ -136,6 +137,11 @@ class Thread: public ThreadShadow { } private: + // Poll data is used in generated code for safepoint polls. + // It is important for performance to put this at lower offset + // in Thread. The accessors are in JavaThread. + SafepointMechanism::ThreadData _poll_data; + // Thread local data area available to the GC. The internal // structure and contents of this data area is GC-specific. // Only GC and GC barrier code should access this data area. @@ -242,20 +248,6 @@ class Thread: public ThreadShadow { public: void set_last_handle_mark(HandleMark* mark) { _last_handle_mark = mark; } HandleMark* last_handle_mark() const { return _last_handle_mark; } - private: - -#ifdef ASSERT - ICRefillVerifier* _missed_ic_stub_refill_verifier; - - public: - ICRefillVerifier* missed_ic_stub_refill_verifier() { - return _missed_ic_stub_refill_verifier; - } - - void set_missed_ic_stub_refill_verifier(ICRefillVerifier* verifier) { - _missed_ic_stub_refill_verifier = verifier; - } -#endif // ASSERT private: // Used by SkipGCALot class. @@ -277,7 +269,7 @@ class Thread: public ThreadShadow { // is waiting to lock public: // Constructor - Thread(MEMFLAGS flag = mtThread); + Thread(MemTag mem_tag = mtThread); virtual ~Thread() = 0; // Thread is abstract. // Manage Thread::current() @@ -532,7 +524,7 @@ protected: public: // Stack overflow support - address stack_base() const { assert(_stack_base != nullptr,"Sanity check"); return _stack_base; } + address stack_base() const DEBUG_ONLY(;) NOT_DEBUG({ return _stack_base; }) void set_stack_base(address base) { _stack_base = base; } size_t stack_size() const { return _stack_size; } void set_stack_size(size_t size) { _stack_size = size; } diff --git a/src/hotspot/share/runtime/threads.cpp b/src/hotspot/share/runtime/threads.cpp index af904bdcfcd..45aaa769856 100644 --- a/src/hotspot/share/runtime/threads.cpp +++ b/src/hotspot/share/runtime/threads.cpp @@ -393,6 +393,7 @@ void Threads::initialize_java_lang_classes(JavaThread* main_thread, TRAPS) { initialize_class(vmSymbols::java_lang_ClassCastException(), CHECK); initialize_class(vmSymbols::java_lang_ArrayStoreException(), CHECK); initialize_class(vmSymbols::java_lang_ArithmeticException(), CHECK); + initialize_class(vmSymbols::java_lang_ArrayIndexOutOfBoundsException(), CHECK); initialize_class(vmSymbols::java_lang_StackOverflowError(), CHECK); initialize_class(vmSymbols::java_lang_IllegalMonitorStateException(), CHECK); initialize_class(vmSymbols::java_lang_IllegalArgumentException(), CHECK); @@ -1027,7 +1028,9 @@ void Threads::add(JavaThread* p, bool force_daemon) { void Threads::remove(JavaThread* p, bool is_daemon) { // Extra scope needed for Thread_lock, so we can check // that we do not remove thread without safepoint code notice - { MonitorLocker ml(Threads_lock); + { + ConditionalMutexLocker throttle_ml(ThreadsLockThrottle_lock, UseThreadsLockThrottleLock); + MonitorLocker ml(Threads_lock); if (ThreadIdTable::is_initialized()) { // This cleanup must be done before the current thread's GC barrier @@ -1075,7 +1078,7 @@ void Threads::remove(JavaThread* p, bool is_daemon) { // Notify threads waiting in EscapeBarriers EscapeBarrier::thread_removed(p); - } // unlock Threads_lock + } // unlock Threads_lock and ThreadsLockThrottle_lock // Reduce the ObjectMonitor ceiling for the exiting thread. ObjectSynchronizer::dec_in_use_list_ceiling(); diff --git a/src/hotspot/share/runtime/vmOperation.hpp b/src/hotspot/share/runtime/vmOperation.hpp index 532a9231b70..eede52f00d5 100644 --- a/src/hotspot/share/runtime/vmOperation.hpp +++ b/src/hotspot/share/runtime/vmOperation.hpp @@ -109,7 +109,6 @@ template(PrintCompileQueue) \ template(PrintClassHierarchy) \ template(PrintClasses) \ - template(ICBufferFull) \ template(PrintMetadata) \ template(GTestExecuteAtSafepoint) \ template(GTestStopSafepoint) \ diff --git a/src/hotspot/share/runtime/vmOperations.hpp b/src/hotspot/share/runtime/vmOperations.hpp index 5ccf689eaf3..ea7f62df37d 100644 --- a/src/hotspot/share/runtime/vmOperations.hpp +++ b/src/hotspot/share/runtime/vmOperations.hpp @@ -60,12 +60,6 @@ class VM_ForceSafepoint: public VM_EmptyOperation { VMOp_Type type() const { return VMOp_ForceSafepoint; } }; -// empty vm op, when forcing a safepoint due to inline cache buffers being full -class VM_ICBufferFull: public VM_EmptyOperation { - public: - VMOp_Type type() const { return VMOp_ICBufferFull; } -}; - class VM_ClearICs: public VM_Operation { private: bool _preserve_static_stubs; diff --git a/src/hotspot/share/runtime/vmStructs.cpp b/src/hotspot/share/runtime/vmStructs.cpp index fe9620586be..3060e225427 100644 --- a/src/hotspot/share/runtime/vmStructs.cpp +++ b/src/hotspot/share/runtime/vmStructs.cpp @@ -373,9 +373,9 @@ /* CompressedOops */ \ /******************/ \ \ - static_field(CompressedOops, _narrow_oop._base, address) \ - static_field(CompressedOops, _narrow_oop._shift, int) \ - static_field(CompressedOops, _narrow_oop._use_implicit_null_checks, bool) \ + static_field(CompressedOops, _base, address) \ + static_field(CompressedOops, _shift, int) \ + static_field(CompressedOops, _use_implicit_null_checks, bool) \ \ /***************************/ \ /* CompressedKlassPointers */ \ @@ -563,6 +563,12 @@ \ nonstatic_field(DeoptimizationBlob, _unpack_offset, int) \ \ + /*****************************************************/ \ + /* UpcallStubs (NOTE: incomplete, but only a little) */ \ + /*****************************************************/ \ + \ + nonstatic_field(UpcallStub, _frame_data_offset, ByteSize) \ + \ /**************************************************/ \ /* NMethods (NOTE: incomplete, but only a little) */ \ /**************************************************/ \ @@ -1012,7 +1018,9 @@ nonstatic_field(AccessFlags, _flags, jint) \ nonstatic_field(elapsedTimer, _counter, jlong) \ nonstatic_field(elapsedTimer, _active, bool) \ - nonstatic_field(InvocationCounter, _counter, unsigned int) + nonstatic_field(InvocationCounter, _counter, unsigned int) \ + \ + nonstatic_field(UpcallStub::FrameData, jfa, JavaFrameAnchor) //-------------------------------------------------------------------------------- // VM_TYPES @@ -1306,6 +1314,7 @@ declare_type(nmethod, CodeBlob) \ declare_type(RuntimeStub, RuntimeBlob) \ declare_type(SingletonBlob, RuntimeBlob) \ + declare_type(UpcallStub, RuntimeBlob) \ declare_type(SafepointBlob, SingletonBlob) \ declare_type(DeoptimizationBlob, SingletonBlob) \ declare_c2_type(ExceptionBlob, SingletonBlob) \ @@ -1581,7 +1590,6 @@ declare_c2_type(StorePNode, StoreNode) \ declare_c2_type(StoreNNode, StoreNode) \ declare_c2_type(StoreNKlassNode, StoreNode) \ - declare_c2_type(StoreCMNode, StoreNode) \ declare_c2_type(SCMemProjNode, ProjNode) \ declare_c2_type(LoadStoreNode, Node) \ declare_c2_type(CompareAndSwapNode, LoadStoreConditionalNode) \ @@ -1900,6 +1908,7 @@ declare_integer_type(BasicType) /* FIXME: wrong type (not integer) */ \ \ declare_integer_type(CompLevel) \ + declare_integer_type(ByteSize) \ JVMTI_ONLY(declare_toplevel_type(BreakpointInfo)) \ JVMTI_ONLY(declare_toplevel_type(BreakpointInfo*)) \ declare_toplevel_type(CodeBlob*) \ @@ -1948,6 +1957,7 @@ declare_type(FileMapInfo, CHeapObj) \ declare_toplevel_type(FileMapHeader) \ declare_toplevel_type(CDSFileMapRegion) \ + declare_toplevel_type(UpcallStub::FrameData) \ \ /************/ \ /* GC types */ \ @@ -2015,8 +2025,6 @@ /************************************************************/ \ \ declare_constant(JVM_ACC_WRITTEN_FLAGS) \ - declare_constant(JVM_ACC_HAS_FINALIZER) \ - declare_constant(JVM_ACC_IS_CLONEABLE_FAST) \ \ declare_constant(JVM_CONSTANT_Utf8) \ declare_constant(JVM_CONSTANT_Unicode) \ diff --git a/src/hotspot/share/services/diagnosticCommand.cpp b/src/hotspot/share/services/diagnosticCommand.cpp index 7a2c0838146..78c655a43fc 100644 --- a/src/hotspot/share/services/diagnosticCommand.cpp +++ b/src/hotspot/share/services/diagnosticCommand.cpp @@ -138,9 +138,11 @@ void DCmd::register_dcmds(){ DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl(full_export, true, false)); DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl(full_export, true, false)); DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl(full_export, true, false)); +#endif // LINUX +#if defined(LINUX) || defined(_WIN64) DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl(full_export, true,false)); DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl(full_export, true,false)); -#endif // LINUX +#endif // LINUX or WINDOWS DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl(full_export, true, false)); DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl(full_export, true, false)); @@ -899,7 +901,6 @@ void EventLogDCmd::execute(DCmdSource source, TRAPS) { int max = -1; if (max_value != nullptr) { char* endptr = nullptr; - int max; if (!parse_integer(max_value, &max)) { output()->print_cr("Invalid max option: \"%s\".", max_value); return; @@ -1173,7 +1174,7 @@ void CompilationMemoryStatisticDCmd::execute(DCmdSource source, TRAPS) { CompilationMemoryStatistic::print_all_by_size(output(), human_readable, minsize); } -#ifdef LINUX +#if defined(LINUX) || defined(_WIN64) SystemMapDCmd::SystemMapDCmd(outputStream* output, bool heap) : DCmd(output, heap) {} @@ -1191,16 +1192,22 @@ SystemDumpMapDCmd::SystemDumpMapDCmd(outputStream* output, bool heap) : void SystemDumpMapDCmd::execute(DCmdSource source, TRAPS) { const char* name = _filename.value(); + if (name == nullptr || name[0] == 0) { + output()->print_cr("filename is empty or not specified. No file written"); + return; + } fileStream fs(name); if (fs.is_open()) { if (!MemTracker::enabled()) { output()->print_cr("(NMT is disabled, will not annotate mappings)."); } MemMapPrinter::print_all_mappings(&fs); +#ifndef _WIN64 // For the readers convenience, resolve path name. char tmp[JVM_MAXPATHLEN]; const char* absname = os::Posix::realpath(name, tmp, sizeof(tmp)); name = absname != nullptr ? absname : name; +#endif output()->print_cr("Memory map dumped to \"%s\".", name); } else { output()->print_cr("Failed to open \"%s\" for writing (%s).", name, os::strerror(errno)); diff --git a/src/hotspot/share/services/diagnosticCommand.hpp b/src/hotspot/share/services/diagnosticCommand.hpp index ec3469c8d15..99b5a351064 100644 --- a/src/hotspot/share/services/diagnosticCommand.hpp +++ b/src/hotspot/share/services/diagnosticCommand.hpp @@ -981,14 +981,14 @@ public: virtual void execute(DCmdSource source, TRAPS); }; -#ifdef LINUX +#if defined(LINUX) || defined(_WIN64) class SystemMapDCmd : public DCmd { public: SystemMapDCmd(outputStream* output, bool heap); static const char* name() { return "System.map"; } static const char* description() { - return "Prints an annotated process memory map of the VM process (linux only)."; + return "Prints an annotated process memory map of the VM process (linux and Windows only)."; } static const char* impact() { return "Medium; can be high for very large java heaps."; } static const JavaPermission permission() { @@ -1006,7 +1006,7 @@ public: SystemDumpMapDCmd(outputStream* output, bool heap); static const char* name() { return "System.dump_map"; } static const char* description() { - return "Dumps an annotated process memory map to an output file (linux only)."; + return "Dumps an annotated process memory map to an output file (linux and Windows only)."; } static const char* impact() { return "Medium; can be high for very large java heaps."; } static const JavaPermission permission() { @@ -1017,6 +1017,6 @@ public: virtual void execute(DCmdSource source, TRAPS); }; -#endif // LINUX +#endif // LINUX or WINDOWS #endif // SHARE_SERVICES_DIAGNOSTICCOMMAND_HPP diff --git a/src/hotspot/share/services/heapDumper.cpp b/src/hotspot/share/services/heapDumper.cpp index 5b3749381a0..10e1a804ad2 100644 --- a/src/hotspot/share/services/heapDumper.cpp +++ b/src/hotspot/share/services/heapDumper.cpp @@ -1512,6 +1512,38 @@ class ClassDumper : public KlassClosure { } }; +// Support class used to generate HPROF_LOAD_CLASS records + +class LoadedClassDumper : public LockedClassesDo { + private: + AbstractDumpWriter* _writer; + GrowableArray* _klass_map; + u4 _class_serial_num; + AbstractDumpWriter* writer() const { return _writer; } + void add_class_serial_number(Klass* k, int serial_num) { + _klass_map->at_put_grow(serial_num, k); + } + public: + LoadedClassDumper(AbstractDumpWriter* writer, GrowableArray* klass_map) + : _writer(writer), _klass_map(klass_map), _class_serial_num(0) {} + + void do_klass(Klass* k) { + // len of HPROF_LOAD_CLASS record + u4 remaining = 2 * oopSize + 2 * sizeof(u4); + DumperSupport::write_header(writer(), HPROF_LOAD_CLASS, remaining); + // class serial number is just a number + writer()->write_u4(++_class_serial_num); + // class ID + writer()->write_classID(k); + // add the Klass* and class serial number pair + add_class_serial_number(k, _class_serial_num); + writer()->write_u4(STACK_TRACE_ID); + // class name ID + Symbol* name = k->name(); + writer()->write_symbolID(name); + } +}; + // Support class used to generate HPROF_GC_ROOT_JNI_LOCAL records class JNILocalsDumper : public OopClosure { @@ -2190,9 +2222,7 @@ void DumpMerger::do_merge() { // The VM operation that performs the heap dump class VM_HeapDumper : public VM_GC_Operation, public WorkerTask, public UnmountedVThreadDumper { private: - static VM_HeapDumper* _global_dumper; - static DumpWriter* _global_writer; - DumpWriter* _local_writer; + DumpWriter* _writer; JavaThread* _oome_thread; Method* _oome_constructor; bool _gc_before_heap_dump; @@ -2218,33 +2248,13 @@ class VM_HeapDumper : public VM_GC_Operation, public WorkerTask, public Unmounte return Atomic::fetch_then_add(&_dump_seq, 1); } - // accessors and setters - static VM_HeapDumper* dumper() { assert(_global_dumper != nullptr, "Error"); return _global_dumper; } - static DumpWriter* writer() { assert(_global_writer != nullptr, "Error"); return _global_writer; } - - void set_global_dumper() { - assert(_global_dumper == nullptr, "Error"); - _global_dumper = this; - } - void set_global_writer() { - assert(_global_writer == nullptr, "Error"); - _global_writer = _local_writer; - } - void clear_global_dumper() { _global_dumper = nullptr; } - void clear_global_writer() { _global_writer = nullptr; } + DumpWriter* writer() const { return _writer; } bool skip_operation() const; - // writes a HPROF_LOAD_CLASS record to global writer - static void do_load_class(Klass* k); - // HPROF_GC_ROOT_THREAD_OBJ records for platform and mounted virtual threads void dump_threads(AbstractDumpWriter* writer); - void add_class_serial_number(Klass* k, int serial_num) { - _klass_map->at_put_grow(serial_num, k); - } - bool is_oom_thread(JavaThread* thread) const { return thread == _oome_thread && _oome_constructor != nullptr; } @@ -2259,7 +2269,7 @@ class VM_HeapDumper : public VM_GC_Operation, public WorkerTask, public Unmounte 0 /* total full collections, dummy, ignored */, gc_before_heap_dump), WorkerTask("dump heap") { - _local_writer = writer; + _writer = writer; _gc_before_heap_dump = gc_before_heap_dump; _klass_map = new (mtServiceability) GrowableArray(INITIAL_CLASS_COUNT, mtServiceability); @@ -2313,9 +2323,6 @@ class VM_HeapDumper : public VM_GC_Operation, public WorkerTask, public Unmounte void dump_vthread(oop vt, AbstractDumpWriter* segment_writer); }; -VM_HeapDumper* VM_HeapDumper::_global_dumper = nullptr; -DumpWriter* VM_HeapDumper::_global_writer = nullptr; - bool VM_HeapDumper::skip_operation() const { return false; } @@ -2329,31 +2336,6 @@ void DumperSupport::end_of_dump(AbstractDumpWriter* writer) { writer->write_u4(0); } -// writes a HPROF_LOAD_CLASS record for the class -void VM_HeapDumper::do_load_class(Klass* k) { - static u4 class_serial_num = 0; - - // len of HPROF_LOAD_CLASS record - u4 remaining = 2*oopSize + 2*sizeof(u4); - - DumperSupport::write_header(writer(), HPROF_LOAD_CLASS, remaining); - - // class serial number is just a number - writer()->write_u4(++class_serial_num); - - // class ID - writer()->write_classID(k); - - // add the Klass* and class serial number pair - dumper()->add_class_serial_number(k, class_serial_num); - - writer()->write_u4(STACK_TRACE_ID); - - // class name ID - Symbol* name = k->name(); - writer()->write_symbolID(name); -} - // Write a HPROF_GC_ROOT_THREAD_OBJ record for platform/carrier and mounted virtual threads. // Then walk the stack so that locals and JNI locals are dumped. void VM_HeapDumper::dump_threads(AbstractDumpWriter* writer) { @@ -2430,11 +2412,6 @@ void VM_HeapDumper::doit() { } } - // At this point we should be the only dumper active, so - // the following should be safe. - set_global_dumper(); - set_global_writer(); - WorkerThreads* workers = ch->safepoint_workers(); prepare_parallel_dump(workers); @@ -2446,10 +2423,6 @@ void VM_HeapDumper::doit() { workers->run_task(this, _num_dumper_threads); _poi = nullptr; } - - // Now we clear the global variables, so that a future dumper can run. - clear_global_dumper(); - clear_global_writer(); } void VM_HeapDumper::work(uint worker_id) { @@ -2480,8 +2453,8 @@ void VM_HeapDumper::work(uint worker_id) { // write HPROF_LOAD_CLASS records { - LockedClassesDo locked_load_classes(&do_load_class); - ClassLoaderDataGraph::classes_do(&locked_load_classes); + LoadedClassDumper loaded_class_dumper(writer(), _klass_map); + ClassLoaderDataGraph::classes_do(&loaded_class_dumper); } // write HPROF_FRAME and HPROF_TRACE records diff --git a/src/hotspot/share/services/threadService.cpp b/src/hotspot/share/services/threadService.cpp index 09cb7ffb25a..a1ad0a910f6 100644 --- a/src/hotspot/share/services/threadService.cpp +++ b/src/hotspot/share/services/threadService.cpp @@ -32,7 +32,7 @@ #include "memory/oopFactory.hpp" #include "memory/resourceArea.hpp" #include "memory/universe.hpp" -#include "nmt/memflags.hpp" +#include "nmt/memTag.hpp" #include "oops/instanceKlass.hpp" #include "oops/klass.inline.hpp" #include "oops/objArrayKlass.hpp" diff --git a/src/hotspot/share/utilities/accessFlags.hpp b/src/hotspot/share/utilities/accessFlags.hpp index 78bf179e03a..74ccbd20ac1 100644 --- a/src/hotspot/share/utilities/accessFlags.hpp +++ b/src/hotspot/share/utilities/accessFlags.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,14 +40,7 @@ enum { // flags actually put in .class file JVM_ACC_WRITTEN_FLAGS = 0x00007FFF, - // HotSpot-specific access flags - // These Klass flags should be migrated, to a field such as InstanceKlass::_misc_flags, - // or to a similar flags field in Klass itself. // Do not add new ACC flags here. - JVM_ACC_HAS_FINALIZER = 0x40000000, // True if klass has a non-empty finalize() method - JVM_ACC_IS_CLONEABLE_FAST = (int)0x80000000,// True if klass implements the Cloneable interface and can be optimized in generated code - JVM_ACC_IS_HIDDEN_CLASS = 0x04000000, // True if klass is hidden - JVM_ACC_IS_VALUE_BASED_CLASS = 0x08000000, // True if klass is marked as a ValueBased class }; @@ -77,12 +70,6 @@ class AccessFlags { // Attribute flags bool is_synthetic () const { return (_flags & JVM_ACC_SYNTHETIC ) != 0; } - // Klass* flags - bool has_finalizer () const { return (_flags & JVM_ACC_HAS_FINALIZER ) != 0; } - bool is_cloneable_fast () const { return (_flags & JVM_ACC_IS_CLONEABLE_FAST ) != 0; } - bool is_hidden_class () const { return (_flags & JVM_ACC_IS_HIDDEN_CLASS ) != 0; } - bool is_value_based_class () const { return (_flags & JVM_ACC_IS_VALUE_BASED_CLASS ) != 0; } - // get .class file flags jint get_flags () const { return (_flags & JVM_ACC_WRITTEN_FLAGS); } @@ -102,13 +89,6 @@ class AccessFlags { // attribute flags void set_is_synthetic() { _flags |= JVM_ACC_SYNTHETIC; } - // Klass* flags - // These are set at classfile parsing time so do not require atomic access. - void set_has_finalizer() { _flags |= JVM_ACC_HAS_FINALIZER; } - void set_is_cloneable_fast() { _flags |= JVM_ACC_IS_CLONEABLE_FAST; } - void set_is_hidden_class() { _flags |= JVM_ACC_IS_HIDDEN_CLASS; } - void set_is_value_based_class() { _flags |= JVM_ACC_IS_VALUE_BASED_CLASS; } - public: // Conversion jshort as_short() const { return (jshort)_flags; } diff --git a/src/hotspot/share/utilities/bitMap.cpp b/src/hotspot/share/utilities/bitMap.cpp index a0780707091..423bc22cd9d 100644 --- a/src/hotspot/share/utilities/bitMap.cpp +++ b/src/hotspot/share/utilities/bitMap.cpp @@ -173,8 +173,8 @@ bm_word_t* ResourceBitMap::reallocate(bm_word_t* old_map, size_t old_size_in_wor return pseudo_reallocate(*this, old_map, old_size_in_words, new_size_in_words); } -CHeapBitMap::CHeapBitMap(idx_t size_in_bits, MEMFLAGS flags, bool clear) - : GrowableBitMap(), _flags(flags) { +CHeapBitMap::CHeapBitMap(idx_t size_in_bits, MemTag mem_tag, bool clear) + : GrowableBitMap(), _mem_tag(mem_tag) { initialize(size_in_bits, clear); } @@ -183,7 +183,7 @@ CHeapBitMap::~CHeapBitMap() { } bm_word_t* CHeapBitMap::allocate(idx_t size_in_words) const { - return MallocArrayAllocator::allocate(size_in_words, _flags); + return MallocArrayAllocator::allocate(size_in_words, _mem_tag); } // GrowableBitMap::resize uses free(ptr, size) for T as CHeapBitMap, ArenaBitMap and ResourceBitMap allocators. @@ -193,7 +193,7 @@ void CHeapBitMap::free(bm_word_t* map, idx_t size_in_words) const { } bm_word_t* CHeapBitMap::reallocate(bm_word_t* map, size_t old_size_in_words, size_t new_size_in_words) const { - return MallocArrayAllocator::reallocate(map, new_size_in_words, _flags); + return MallocArrayAllocator::reallocate(map, new_size_in_words, _mem_tag); } #ifdef ASSERT @@ -705,8 +705,6 @@ void BitMap::IteratorImpl::assert_not_empty() const { } #endif -#ifndef PRODUCT - void BitMap::print_on(outputStream* st) const { st->print("Bitmap (" SIZE_FORMAT " bits):", size()); for (idx_t index = 0; index < size(); index++) { @@ -722,8 +720,6 @@ void BitMap::print_on(outputStream* st) const { st->cr(); } -#endif - template class GrowableBitMap; template class GrowableBitMap; template class GrowableBitMap; diff --git a/src/hotspot/share/utilities/bitMap.hpp b/src/hotspot/share/utilities/bitMap.hpp index 5db12badbc9..1c69a0d43f8 100644 --- a/src/hotspot/share/utilities/bitMap.hpp +++ b/src/hotspot/share/utilities/bitMap.hpp @@ -25,7 +25,7 @@ #ifndef SHARE_UTILITIES_BITMAP_HPP #define SHARE_UTILITIES_BITMAP_HPP -#include "nmt/memflags.hpp" +#include "nmt/memTag.hpp" #include "runtime/atomic.hpp" #include "utilities/globalDefinitions.hpp" @@ -391,13 +391,10 @@ class BitMap { bool is_empty() const; void write_to(bm_word_t* buffer, size_t buffer_size_in_bytes) const; - void print_on_error(outputStream* st, const char* prefix) const; -#ifndef PRODUCT - public: // Printing + void print_on_error(outputStream* st, const char* prefix) const; void print_on(outputStream* st) const; -#endif }; // Implementation support for bitmap iteration. While it could be used to @@ -641,16 +638,16 @@ class ResourceBitMap : public GrowableBitMap { // A BitMap with storage in the CHeap. class CHeapBitMap : public GrowableBitMap { - // NMT memory type - const MEMFLAGS _flags; + // NMT memory tag + const MemTag _mem_tag; // Don't allow copy or assignment, to prevent the // allocated memory from leaking out to other instances. NONCOPYABLE(CHeapBitMap); public: - explicit CHeapBitMap(MEMFLAGS flags) : GrowableBitMap(), _flags(flags) {} - CHeapBitMap(idx_t size_in_bits, MEMFLAGS flags, bool clear = true); + explicit CHeapBitMap(MemTag mem_tag) : GrowableBitMap(), _mem_tag(mem_tag) {} + CHeapBitMap(idx_t size_in_bits, MemTag mem_tag, bool clear = true); ~CHeapBitMap(); bm_word_t* allocate(idx_t size_in_words) const; diff --git a/src/hotspot/share/utilities/chunkedList.hpp b/src/hotspot/share/utilities/chunkedList.hpp index 9a600e4ce1b..3269c305e78 100644 --- a/src/hotspot/share/utilities/chunkedList.hpp +++ b/src/hotspot/share/utilities/chunkedList.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,7 +28,7 @@ #include "memory/allocation.hpp" #include "utilities/debug.hpp" -template class ChunkedList : public CHeapObj { +template class ChunkedList : public CHeapObj { template friend class TestChunkedList; static const size_t BufferSize = 64; @@ -36,8 +36,8 @@ template class ChunkedList : public CHeapObj { T _values[BufferSize]; T* _top; - ChunkedList* _next_used; - ChunkedList* _next_free; + ChunkedList* _next_used; + ChunkedList* _next_free; T const * end() const { return &_values[BufferSize]; @@ -62,11 +62,11 @@ template class ChunkedList : public CHeapObj { _top++; } - void set_next_used(ChunkedList* buffer) { _next_used = buffer; } - void set_next_free(ChunkedList* buffer) { _next_free = buffer; } + void set_next_used(ChunkedList* buffer) { _next_used = buffer; } + void set_next_free(ChunkedList* buffer) { _next_free = buffer; } - ChunkedList* next_used() const { return _next_used; } - ChunkedList* next_free() const { return _next_free; } + ChunkedList* next_used() const { return _next_used; } + ChunkedList* next_free() const { return _next_free; } size_t size() const { return pointer_delta(_top, _values, sizeof(T)); diff --git a/src/hotspot/share/utilities/concurrentHashTable.hpp b/src/hotspot/share/utilities/concurrentHashTable.hpp index 4e506d5fe84..402a767c0b8 100644 --- a/src/hotspot/share/utilities/concurrentHashTable.hpp +++ b/src/hotspot/share/utilities/concurrentHashTable.hpp @@ -40,8 +40,8 @@ class Thread; class Mutex; -template -class ConcurrentHashTable : public CHeapObj { +template +class ConcurrentHashTable : public CHeapObj { typedef typename CONFIG::Value VALUE; private: // _stats_rate is null if statistics are not enabled. @@ -61,7 +61,7 @@ class ConcurrentHashTable : public CHeapObj { TableStatistics statistics_calculate(Thread* thread, VALUE_SIZE_FUNC& vs_f); // This is the internal node structure. - // Only constructed with placement new from memory allocated with MEMFLAGS of + // Only constructed with placement new from memory allocated with MemTag of // the InternalTable or user-defined memory. class Node { private: @@ -105,7 +105,7 @@ class ConcurrentHashTable : public CHeapObj { } }; - // Only constructed with placement new from an array allocated with MEMFLAGS + // Only constructed with placement new from an array allocated with MemTag // of InternalTable. class Bucket { private: @@ -202,7 +202,7 @@ class ConcurrentHashTable : public CHeapObj { // - Re-size can only change the size into half or double // (any pow 2 would also be possible). // - Use masking of hash for bucket index. - class InternalTable : public CHeapObj { + class InternalTable : public CHeapObj { private: Bucket* _buckets; // Bucket array. public: @@ -277,10 +277,10 @@ class ConcurrentHashTable : public CHeapObj { class ScopedCS: public StackObj { protected: Thread* _thread; - ConcurrentHashTable* _cht; + ConcurrentHashTable* _cht; GlobalCounter::CSContext _cs_context; public: - ScopedCS(Thread* thread, ConcurrentHashTable* cht); + ScopedCS(Thread* thread, ConcurrentHashTable* cht); ~ScopedCS(); }; @@ -372,7 +372,7 @@ class ConcurrentHashTable : public CHeapObj { // Check for dead items in a bucket. template size_t delete_check_nodes(Bucket* bucket, EVALUATE_FUNC& eval_f, - size_t num_del, Node** ndel, GrowableArrayCHeap& ndel_heap); + size_t num_del, Node** ndel, GrowableArrayCHeap& ndel_heap); // Check for dead items in this table. During shrink/grow we cannot guarantee // that we only visit nodes once. To keep it simple caller will have locked @@ -539,12 +539,12 @@ class ConcurrentHashTable : public CHeapObj { // Moves all nodes from this table to to_cht with new hash code. // Must be done at a safepoint. - void rehash_nodes_to(Thread* thread, ConcurrentHashTable* to_cht); + void rehash_nodes_to(Thread* thread, ConcurrentHashTable* to_cht); // Scoped multi getter. class MultiGetHandle : private ScopedCS { public: - MultiGetHandle(Thread* thread, ConcurrentHashTable* cht) + MultiGetHandle(Thread* thread, ConcurrentHashTable* cht) : ScopedCS(thread, cht) {} // In the MultiGetHandle scope you can lookup items matching LOOKUP_FUNC. // The VALUEs are safe as long as you never save the VALUEs outside the diff --git a/src/hotspot/share/utilities/concurrentHashTable.inline.hpp b/src/hotspot/share/utilities/concurrentHashTable.inline.hpp index f035aeae448..5656655275a 100644 --- a/src/hotspot/share/utilities/concurrentHashTable.inline.hpp +++ b/src/hotspot/share/utilities/concurrentHashTable.inline.hpp @@ -58,28 +58,28 @@ static void* const POISON_PTR = (void*)0xffbadbac; #endif // Node -template -inline typename ConcurrentHashTable::Node* -ConcurrentHashTable:: +template +inline typename ConcurrentHashTable::Node* +ConcurrentHashTable:: Node::next() const { return Atomic::load_acquire(&_next); } // Bucket -template -inline typename ConcurrentHashTable::Node* -ConcurrentHashTable:: +template +inline typename ConcurrentHashTable::Node* +ConcurrentHashTable:: Bucket::first_raw() const { return Atomic::load_acquire(&_first); } -template -inline void ConcurrentHashTable:: +template +inline void ConcurrentHashTable:: Bucket::release_assign_node_ptr( - typename ConcurrentHashTable::Node* const volatile * dst, - typename ConcurrentHashTable::Node* node) const + typename ConcurrentHashTable::Node* const volatile * dst, + typename ConcurrentHashTable::Node* node) const { // Due to this assert this methods is not static. assert(is_locked(), "Must be locked."); @@ -87,31 +87,31 @@ inline void ConcurrentHashTable:: Atomic::release_store(tmp, clear_set_state(node, *dst)); } -template -inline typename ConcurrentHashTable::Node* -ConcurrentHashTable:: +template +inline typename ConcurrentHashTable::Node* +ConcurrentHashTable:: Bucket::first() const { // We strip the states bit before returning the ptr. return clear_state(Atomic::load_acquire(&_first)); } -template -inline bool ConcurrentHashTable:: +template +inline bool ConcurrentHashTable:: Bucket::have_redirect() const { return is_state(first_raw(), STATE_REDIRECT_BIT); } -template -inline bool ConcurrentHashTable:: +template +inline bool ConcurrentHashTable:: Bucket::is_locked() const { return is_state(first_raw(), STATE_LOCK_BIT); } -template -inline void ConcurrentHashTable:: +template +inline void ConcurrentHashTable:: Bucket::lock() { int i = 0; @@ -128,10 +128,10 @@ inline void ConcurrentHashTable:: } } -template -inline void ConcurrentHashTable:: +template +inline void ConcurrentHashTable:: Bucket::release_assign_last_node_next( - typename ConcurrentHashTable::Node* node) + typename ConcurrentHashTable::Node* node) { assert(is_locked(), "Must be locked."); Node* const volatile * ret = first_ptr(); @@ -141,10 +141,10 @@ inline void ConcurrentHashTable:: release_assign_node_ptr(ret, node); } -template -inline bool ConcurrentHashTable:: - Bucket::cas_first(typename ConcurrentHashTable::Node* node, - typename ConcurrentHashTable::Node* expect +template +inline bool ConcurrentHashTable:: + Bucket::cas_first(typename ConcurrentHashTable::Node* node, + typename ConcurrentHashTable::Node* expect ) { if (is_locked()) { @@ -156,8 +156,8 @@ inline bool ConcurrentHashTable:: return false; } -template -inline bool ConcurrentHashTable:: +template +inline bool ConcurrentHashTable:: Bucket::trylock() { if (is_locked()) { @@ -171,8 +171,8 @@ inline bool ConcurrentHashTable:: return false; } -template -inline void ConcurrentHashTable:: +template +inline void ConcurrentHashTable:: Bucket::unlock() { assert(is_locked(), "Must be locked."); @@ -181,8 +181,8 @@ inline void ConcurrentHashTable:: Atomic::release_store(&_first, clear_state(first())); } -template -inline void ConcurrentHashTable:: +template +inline void ConcurrentHashTable:: Bucket::redirect() { assert(is_locked(), "Must be locked."); @@ -190,15 +190,15 @@ inline void ConcurrentHashTable:: } // InternalTable -template -inline ConcurrentHashTable:: +template +inline ConcurrentHashTable:: InternalTable::InternalTable(size_t log2_size) : _log2_size(log2_size), _size(((size_t)1ul) << _log2_size), _hash_mask(~(~((size_t)0) << _log2_size)) { assert(_log2_size >= SIZE_SMALL_LOG2 && _log2_size <= SIZE_BIG_LOG2, "Bad size"); - _buckets = NEW_C_HEAP_ARRAY(Bucket, _size, F); + _buckets = NEW_C_HEAP_ARRAY(Bucket, _size, MT); // Use placement new for each element instead of new[] which could use more // memory than allocated. for (size_t i = 0; i < _size; ++i) { @@ -206,17 +206,17 @@ inline ConcurrentHashTable:: } } -template -inline ConcurrentHashTable:: +template +inline ConcurrentHashTable:: InternalTable::~InternalTable() { FREE_C_HEAP_ARRAY(Bucket, _buckets); } // ScopedCS -template -inline ConcurrentHashTable:: - ScopedCS::ScopedCS(Thread* thread, ConcurrentHashTable* cht) +template +inline ConcurrentHashTable:: + ScopedCS::ScopedCS(Thread* thread, ConcurrentHashTable* cht) : _thread(thread), _cht(cht), _cs_context(GlobalCounter::critical_section_begin(_thread)) @@ -227,25 +227,25 @@ inline ConcurrentHashTable:: } } -template -inline ConcurrentHashTable:: +template +inline ConcurrentHashTable:: ScopedCS::~ScopedCS() { GlobalCounter::critical_section_end(_thread, _cs_context); } -template +template template -inline typename CONFIG::Value* ConcurrentHashTable:: +inline typename CONFIG::Value* ConcurrentHashTable:: MultiGetHandle::get(LOOKUP_FUNC& lookup_f, bool* grow_hint) { return ScopedCS::_cht->internal_get(ScopedCS::_thread, lookup_f, grow_hint); } // HaveDeletables -template +template template -inline bool ConcurrentHashTable:: +inline bool ConcurrentHashTable:: HaveDeletables::have_deletable(Bucket* bucket, EVALUATE_FUNC& eval_f, Bucket* prefetch_bucket) @@ -271,9 +271,9 @@ inline bool ConcurrentHashTable:: return false; } -template +template template -inline bool ConcurrentHashTable:: +inline bool ConcurrentHashTable:: HaveDeletables::have_deletable(Bucket* bucket, EVALUATE_FUNC& eval_f, Bucket* preb) @@ -287,8 +287,8 @@ inline bool ConcurrentHashTable:: } // ConcurrentHashTable -template -inline void ConcurrentHashTable:: +template +inline void ConcurrentHashTable:: write_synchonize_on_visible_epoch(Thread* thread) { assert(_resize_lock_owner == thread, "Re-size lock not held"); @@ -304,8 +304,8 @@ inline void ConcurrentHashTable:: GlobalCounter::write_synchronize(); } -template -inline bool ConcurrentHashTable:: +template +inline bool ConcurrentHashTable:: try_resize_lock(Thread* locker) { if (_resize_lock->try_lock()) { @@ -323,8 +323,8 @@ inline bool ConcurrentHashTable:: return true; } -template -inline void ConcurrentHashTable:: +template +inline void ConcurrentHashTable:: lock_resize_lock(Thread* locker) { size_t i = 0; @@ -348,8 +348,8 @@ inline void ConcurrentHashTable:: _invisible_epoch = nullptr; } -template -inline void ConcurrentHashTable:: +template +inline void ConcurrentHashTable:: unlock_resize_lock(Thread* locker) { _invisible_epoch = nullptr; @@ -358,8 +358,8 @@ inline void ConcurrentHashTable:: _resize_lock->unlock(); } -template -inline void ConcurrentHashTable:: +template +inline void ConcurrentHashTable:: free_nodes() { // We assume we are not MT during freeing. @@ -374,25 +374,25 @@ inline void ConcurrentHashTable:: } } -template -inline typename ConcurrentHashTable::InternalTable* -ConcurrentHashTable:: +template +inline typename ConcurrentHashTable::InternalTable* +ConcurrentHashTable:: get_table() const { return Atomic::load_acquire(&_table); } -template -inline typename ConcurrentHashTable::InternalTable* -ConcurrentHashTable:: +template +inline typename ConcurrentHashTable::InternalTable* +ConcurrentHashTable:: get_new_table() const { return Atomic::load_acquire(&_new_table); } -template -inline typename ConcurrentHashTable::InternalTable* -ConcurrentHashTable:: +template +inline typename ConcurrentHashTable::InternalTable* +ConcurrentHashTable:: set_table_from_new() { InternalTable* old_table = _table; @@ -406,8 +406,8 @@ ConcurrentHashTable:: return old_table; } -template -inline void ConcurrentHashTable:: +template +inline void ConcurrentHashTable:: internal_grow_range(Thread* thread, size_t start, size_t stop) { assert(stop <= _table->_size, "Outside backing array"); @@ -446,9 +446,9 @@ inline void ConcurrentHashTable:: } } -template +template template -inline bool ConcurrentHashTable:: +inline bool ConcurrentHashTable:: internal_remove(Thread* thread, LOOKUP_FUNC& lookup_f, DELETE_FUNC& delete_f) { Bucket* bucket = get_bucket_locked(thread, lookup_f.get_hash()); @@ -478,9 +478,9 @@ inline bool ConcurrentHashTable:: return true; } -template +template template -inline void ConcurrentHashTable:: +inline void ConcurrentHashTable:: do_bulk_delete_locked_for(Thread* thread, size_t start_idx, size_t stop_idx, EVALUATE_FUNC& eval_f, DELETE_FUNC& del_f, bool is_mt) { @@ -513,7 +513,7 @@ inline void ConcurrentHashTable:: // We left critical section but the bucket cannot be removed while we hold // the _resize_lock. bucket->lock(); - GrowableArrayCHeap extra(0); // use this buffer if StackBufferSize is not enough + GrowableArrayCHeap extra(0); // use this buffer if StackBufferSize is not enough size_t nd = delete_check_nodes(bucket, eval_f, StackBufferSize, ndel_stack, extra); bucket->unlock(); if (is_mt) { @@ -533,9 +533,9 @@ inline void ConcurrentHashTable:: GlobalCounter::critical_section_end(thread, cs_context); } -template +template template -inline void ConcurrentHashTable:: +inline void ConcurrentHashTable:: delete_in_bucket(Thread* thread, Bucket* bucket, LOOKUP_FUNC& lookup_f) { assert(bucket->is_locked(), "Must be locked."); @@ -568,9 +568,9 @@ inline void ConcurrentHashTable:: } } -template -inline typename ConcurrentHashTable::Bucket* -ConcurrentHashTable:: +template +inline typename ConcurrentHashTable::Bucket* +ConcurrentHashTable:: get_bucket(uintx hash) const { InternalTable* table = get_table(); @@ -582,9 +582,9 @@ ConcurrentHashTable:: return bucket; } -template -inline typename ConcurrentHashTable::Bucket* -ConcurrentHashTable:: +template +inline typename ConcurrentHashTable::Bucket* +ConcurrentHashTable:: get_bucket_locked(Thread* thread, const uintx hash) { Bucket* bucket; @@ -613,10 +613,10 @@ ConcurrentHashTable:: } // Always called within critical section -template +template template -typename ConcurrentHashTable::Node* -ConcurrentHashTable:: +typename ConcurrentHashTable::Node* +ConcurrentHashTable:: get_node(const Bucket* const bucket, LOOKUP_FUNC& lookup_f, bool* have_dead, size_t* loops) const { @@ -638,8 +638,8 @@ ConcurrentHashTable:: return node; } -template -inline bool ConcurrentHashTable:: +template +inline bool ConcurrentHashTable:: unzip_bucket(Thread* thread, InternalTable* old_table, InternalTable* new_table, size_t even_index, size_t odd_index) { @@ -698,8 +698,8 @@ inline bool ConcurrentHashTable:: return true; } -template -inline bool ConcurrentHashTable:: +template +inline bool ConcurrentHashTable:: internal_shrink_prolog(Thread* thread, size_t log2_size) { if (!try_resize_lock(thread)) { @@ -715,8 +715,8 @@ inline bool ConcurrentHashTable:: return true; } -template -inline void ConcurrentHashTable:: +template +inline void ConcurrentHashTable:: internal_shrink_epilog(Thread* thread) { assert(_resize_lock_owner == thread, "Re-size lock not held"); @@ -734,8 +734,8 @@ inline void ConcurrentHashTable:: delete old_table; } -template -inline void ConcurrentHashTable:: +template +inline void ConcurrentHashTable:: internal_shrink_range(Thread* thread, size_t start, size_t stop) { // The state is also copied here. @@ -771,8 +771,8 @@ inline void ConcurrentHashTable:: } } -template -inline bool ConcurrentHashTable:: +template +inline bool ConcurrentHashTable:: internal_shrink(Thread* thread, size_t log2_size) { if (!internal_shrink_prolog(thread, log2_size)) { @@ -786,8 +786,8 @@ inline bool ConcurrentHashTable:: return true; } -template -inline void ConcurrentHashTable:: +template +inline void ConcurrentHashTable:: internal_reset(size_t log2_size) { assert(_table != nullptr, "table failed"); @@ -800,8 +800,8 @@ inline void ConcurrentHashTable:: Atomic::release_store(&_table, table); } -template -inline bool ConcurrentHashTable:: +template +inline bool ConcurrentHashTable:: internal_grow_prolog(Thread* thread, size_t log2_size) { // This double checking of _size_limit_reached/is_max_size_reached() @@ -826,8 +826,8 @@ inline bool ConcurrentHashTable:: return true; } -template -inline void ConcurrentHashTable:: +template +inline void ConcurrentHashTable:: internal_grow_epilog(Thread* thread) { assert(_resize_lock_owner == thread, "Should be locked"); @@ -844,8 +844,8 @@ inline void ConcurrentHashTable:: delete old_table; } -template -inline bool ConcurrentHashTable:: +template +inline bool ConcurrentHashTable:: internal_grow(Thread* thread, size_t log2_size) { if (!internal_grow_prolog(thread, log2_size)) { @@ -860,9 +860,9 @@ inline bool ConcurrentHashTable:: } // Always called within critical section -template +template template -inline typename CONFIG::Value* ConcurrentHashTable:: +inline typename CONFIG::Value* ConcurrentHashTable:: internal_get(Thread* thread, LOOKUP_FUNC& lookup_f, bool* grow_hint) { bool clean = false; @@ -881,9 +881,9 @@ inline typename CONFIG::Value* ConcurrentHashTable:: return ret; } -template +template template -inline bool ConcurrentHashTable:: +inline bool ConcurrentHashTable:: internal_insert_get(Thread* thread, LOOKUP_FUNC& lookup_f, const VALUE& value, FOUND_FUNC& foundf, bool* grow_hint, bool* clean_hint) { @@ -949,9 +949,9 @@ inline bool ConcurrentHashTable:: return ret; } -template +template template -inline bool ConcurrentHashTable:: +inline bool ConcurrentHashTable:: visit_nodes(Bucket* bucket, FUNC& visitor_f) { Node* current_node = bucket->first(); @@ -965,9 +965,9 @@ inline bool ConcurrentHashTable:: return true; } -template +template template -inline void ConcurrentHashTable:: +inline void ConcurrentHashTable:: do_scan_locked(Thread* thread, FUNC& scan_f) { assert(_resize_lock_owner == thread, "Re-size lock not held"); @@ -982,11 +982,11 @@ inline void ConcurrentHashTable:: } /* ends critical section */ } -template +template template -inline size_t ConcurrentHashTable:: +inline size_t ConcurrentHashTable:: delete_check_nodes(Bucket* bucket, EVALUATE_FUNC& eval_f, - size_t num_del, Node** ndel, GrowableArrayCHeap& extra) + size_t num_del, Node** ndel, GrowableArrayCHeap& extra) { size_t dels = 0; Node* const volatile * rem_n_prev = bucket->first_ptr(); @@ -1013,8 +1013,8 @@ inline size_t ConcurrentHashTable:: } // Constructor -template -inline ConcurrentHashTable:: +template +inline ConcurrentHashTable:: ConcurrentHashTable(size_t log2size, size_t log2size_limit, size_t grow_hint, bool enable_statistics, Mutex::Rank rank, void* context) : _context(context), _new_table(nullptr), _log2_size_limit(log2size_limit), _log2_start_size(log2size), _grow_hint(grow_hint), @@ -1032,8 +1032,8 @@ ConcurrentHashTable(size_t log2size, size_t log2size_limit, size_t grow_hint, bo _size_limit_reached = _table->_log2_size == _log2_size_limit; } -template -inline ConcurrentHashTable:: +template +inline ConcurrentHashTable:: ~ConcurrentHashTable() { delete _resize_lock; @@ -1042,24 +1042,24 @@ inline ConcurrentHashTable:: delete _stats_rate; } -template -inline size_t ConcurrentHashTable:: +template +inline size_t ConcurrentHashTable:: get_mem_size(Thread* thread) { ScopedCS cs(thread, this); return sizeof(*this) + _table->get_mem_size(); } -template -inline size_t ConcurrentHashTable:: +template +inline size_t ConcurrentHashTable:: get_size_log2(Thread* thread) { ScopedCS cs(thread, this); return _table->_log2_size; } -template -inline size_t ConcurrentHashTable:: +template +inline size_t ConcurrentHashTable:: get_dynamic_node_size(size_t value_size) { assert(Node::is_dynamic_sized_value_compatible(), "VALUE must be compatible"); @@ -1067,8 +1067,8 @@ inline size_t ConcurrentHashTable:: return sizeof(Node) - sizeof(VALUE) + value_size; } -template -inline bool ConcurrentHashTable:: +template +inline bool ConcurrentHashTable:: shrink(Thread* thread, size_t size_limit_log2) { size_t tmp = size_limit_log2 == 0 ? _log2_start_size : size_limit_log2; @@ -1076,25 +1076,25 @@ inline bool ConcurrentHashTable:: return ret; } -template -inline void ConcurrentHashTable:: +template +inline void ConcurrentHashTable:: unsafe_reset(size_t size_log2) { size_t tmp = size_log2 == 0 ? _log2_start_size : size_log2; internal_reset(tmp); } -template -inline bool ConcurrentHashTable:: +template +inline bool ConcurrentHashTable:: grow(Thread* thread, size_t size_limit_log2) { size_t tmp = size_limit_log2 == 0 ? _log2_size_limit : size_limit_log2; return internal_grow(thread, tmp); } -template +template template -inline bool ConcurrentHashTable:: +inline bool ConcurrentHashTable:: get(Thread* thread, LOOKUP_FUNC& lookup_f, FOUND_FUNC& found_f, bool* grow_hint) { bool ret = false; @@ -1107,8 +1107,8 @@ inline bool ConcurrentHashTable:: return ret; } -template -inline bool ConcurrentHashTable:: +template +inline bool ConcurrentHashTable:: unsafe_insert(const VALUE& value) { bool dead_hash = false; size_t hash = CONFIG::get_hash(value, &dead_hash); @@ -1128,9 +1128,9 @@ inline bool ConcurrentHashTable:: return true; } -template +template template -inline bool ConcurrentHashTable:: +inline bool ConcurrentHashTable:: try_scan(Thread* thread, SCAN_FUNC& scan_f) { if (!try_resize_lock(thread)) { @@ -1141,9 +1141,9 @@ inline bool ConcurrentHashTable:: return true; } -template +template template -inline void ConcurrentHashTable:: +inline void ConcurrentHashTable:: do_scan(Thread* thread, SCAN_FUNC& scan_f) { assert(!SafepointSynchronize::is_at_safepoint(), @@ -1155,9 +1155,9 @@ inline void ConcurrentHashTable:: assert(_resize_lock_owner != thread, "Re-size lock held"); } -template +template template -inline void ConcurrentHashTable:: +inline void ConcurrentHashTable:: do_safepoint_scan(SCAN_FUNC& scan_f) { // We only allow this method to be used during a safepoint. @@ -1179,9 +1179,9 @@ inline void ConcurrentHashTable:: do_scan_for_range(scan_f, 0, table->_size, table); } -template +template template -inline bool ConcurrentHashTable:: +inline bool ConcurrentHashTable:: do_scan_for_range(FUNC& scan_f, size_t start_idx, size_t stop_idx, InternalTable* table) { assert(start_idx < stop_idx, "Must be"); @@ -1204,9 +1204,9 @@ inline bool ConcurrentHashTable:: return true; } -template +template template -inline bool ConcurrentHashTable:: +inline bool ConcurrentHashTable:: try_bulk_delete(Thread* thread, EVALUATE_FUNC& eval_f, DELETE_FUNC& del_f) { if (!try_resize_lock(thread)) { @@ -1218,9 +1218,9 @@ inline bool ConcurrentHashTable:: return true; } -template +template template -inline void ConcurrentHashTable:: +inline void ConcurrentHashTable:: bulk_delete(Thread* thread, EVALUATE_FUNC& eval_f, DELETE_FUNC& del_f) { assert(!SafepointSynchronize::is_at_safepoint(), @@ -1230,9 +1230,9 @@ inline void ConcurrentHashTable:: unlock_resize_lock(thread); } -template +template template -inline TableStatistics ConcurrentHashTable:: +inline TableStatistics ConcurrentHashTable:: statistics_calculate(Thread* thread, VALUE_SIZE_FUNC& vs_f) { constexpr size_t batch_size = 128; @@ -1268,9 +1268,9 @@ inline TableStatistics ConcurrentHashTable:: } } -template +template template -inline TableStatistics ConcurrentHashTable:: +inline TableStatistics ConcurrentHashTable:: statistics_get(Thread* thread, VALUE_SIZE_FUNC& vs_f, TableStatistics old) { if (!try_resize_lock(thread)) { @@ -1283,9 +1283,9 @@ inline TableStatistics ConcurrentHashTable:: return ts; } -template +template template -inline void ConcurrentHashTable:: +inline void ConcurrentHashTable:: statistics_to(Thread* thread, VALUE_SIZE_FUNC& vs_f, outputStream* st, const char* table_name) { @@ -1300,9 +1300,9 @@ inline void ConcurrentHashTable:: ts.print(st, table_name); } -template -inline void ConcurrentHashTable:: - rehash_nodes_to(Thread* thread, ConcurrentHashTable* to_cht) +template +inline void ConcurrentHashTable:: + rehash_nodes_to(Thread* thread, ConcurrentHashTable* to_cht) { assert(is_safepoint_safe(), "rehashing is at a safepoint - cannot be resizing"); assert(_new_table == nullptr || _new_table == POISON_PTR, "Must be null"); diff --git a/src/hotspot/share/utilities/concurrentHashTableTasks.inline.hpp b/src/hotspot/share/utilities/concurrentHashTableTasks.inline.hpp index db9dcae987c..44b2f91c3f2 100644 --- a/src/hotspot/share/utilities/concurrentHashTableTasks.inline.hpp +++ b/src/hotspot/share/utilities/concurrentHashTableTasks.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,10 +35,10 @@ // operations, which they are serialized with each other. // Base class for pause and/or parallel bulk operations. -template -class ConcurrentHashTable::BucketsOperation { +template +class ConcurrentHashTable::BucketsOperation { protected: - ConcurrentHashTable* _cht; + ConcurrentHashTable* _cht; class InternalTableClaimer { volatile size_t _next; @@ -88,7 +88,7 @@ public: InternalTableClaimer _table_claimer; bool _is_mt; - BucketsOperation(ConcurrentHashTable* cht, bool is_mt = false) + BucketsOperation(ConcurrentHashTable* cht, bool is_mt = false) : _cht(cht), _table_claimer(DEFAULT_TASK_SIZE_LOG2, _cht->_table), _is_mt(is_mt) {} // Returns true if you succeeded to claim the range start -> (stop-1). @@ -146,12 +146,12 @@ public: }; // For doing pausable/parallel bulk delete. -template -class ConcurrentHashTable::BulkDeleteTask : +template +class ConcurrentHashTable::BulkDeleteTask : public BucketsOperation { public: - BulkDeleteTask(ConcurrentHashTable* cht, bool is_mt = false) + BulkDeleteTask(ConcurrentHashTable* cht, bool is_mt = false) : BucketsOperation(cht, is_mt) { } // Before start prepare must be called. @@ -190,12 +190,12 @@ class ConcurrentHashTable::BulkDeleteTask : } }; -template -class ConcurrentHashTable::GrowTask : +template +class ConcurrentHashTable::GrowTask : public BucketsOperation { public: - GrowTask(ConcurrentHashTable* cht) : BucketsOperation(cht) { + GrowTask(ConcurrentHashTable* cht) : BucketsOperation(cht) { } // Before start prepare must be called. bool prepare(Thread* thread) { @@ -229,8 +229,8 @@ class ConcurrentHashTable::GrowTask : } }; -template -class ConcurrentHashTable::ScanTask : +template +class ConcurrentHashTable::ScanTask : public BucketsOperation { // If there is a paused resize, we need to scan items already @@ -255,11 +255,11 @@ class ConcurrentHashTable::ScanTask : } public: - ScanTask(ConcurrentHashTable* cht, size_t claim_size) : BucketsOperation(cht), _new_table_claimer() { + ScanTask(ConcurrentHashTable* cht, size_t claim_size) : BucketsOperation(cht), _new_table_claimer() { set(cht, claim_size); } - void set(ConcurrentHashTable* cht, size_t claim_size) { + void set(ConcurrentHashTable* cht, size_t claim_size) { this->_table_claimer.set(claim_size, cht->get_table()); InternalTable* new_table = cht->get_new_table(); diff --git a/src/hotspot/share/utilities/debug.cpp b/src/hotspot/share/utilities/debug.cpp index 9f839fc1a13..119d1cf17fd 100644 --- a/src/hotspot/share/utilities/debug.cpp +++ b/src/hotspot/share/utilities/debug.cpp @@ -711,7 +711,7 @@ static ucontext_t g_stored_assertion_context; void initialize_assert_poison() { char* page = os::reserve_memory(os::vm_page_size()); if (page) { - MemTracker::record_virtual_memory_type(page, mtInternal); + MemTracker::record_virtual_memory_tag(page, mtInternal); if (os::commit_memory(page, os::vm_page_size(), false) && os::protect_memory(page, os::vm_page_size(), os::MEM_PROT_NONE)) { g_assert_poison = page; diff --git a/src/hotspot/share/utilities/debug.hpp b/src/hotspot/share/utilities/debug.hpp index f4e97832a5d..567e72cda57 100644 --- a/src/hotspot/share/utilities/debug.hpp +++ b/src/hotspot/share/utilities/debug.hpp @@ -139,22 +139,25 @@ public: // assertions #ifndef ASSERT +#define vmassert_with_file_and_line(p, file, line, ...) #define vmassert(p, ...) #else // Note: message says "assert" rather than "vmassert" for backward // compatibility with tools that parse/match the message text. // Note: The signature is vmassert(p, format, ...), but the solaris // compiler can't handle an empty ellipsis in a macro without a warning. -#define vmassert(p, ...) \ -do { \ - if (! VMASSERT_CHECK_PASSED(p)) { \ - TOUCH_ASSERT_POISON; \ - report_vm_error(__FILE__, __LINE__, "assert(" #p ") failed", __VA_ARGS__); \ - } \ +#define vmassert_with_file_and_line(p, file, line, ...) \ +do { \ + if (! VMASSERT_CHECK_PASSED(p)) { \ + TOUCH_ASSERT_POISON; \ + report_vm_error(file, line, "assert(" #p ") failed", __VA_ARGS__); \ + } \ } while (0) +#define vmassert(p, ...) vmassert_with_file_and_line(p, __FILE__, __LINE__, __VA_ARGS__) #endif // For backward compatibility. +#define assert_with_file_and_line(p, file, line, ...) vmassert_with_file_and_line(p, file, line, __VA_ARGS__) #define assert(p, ...) vmassert(p, __VA_ARGS__) #define precond(p) assert(p, "precond") diff --git a/src/hotspot/share/utilities/exceptions.cpp b/src/hotspot/share/utilities/exceptions.cpp index f730b37b8ff..10405a06048 100644 --- a/src/hotspot/share/utilities/exceptions.cpp +++ b/src/hotspot/share/utilities/exceptions.cpp @@ -288,7 +288,7 @@ void Exceptions::fthrow(JavaThread* thread, const char* file, int line, Symbol* // parameter controls a check for a specific character appearing in the "name", which is only // allowed for classfile versions <= 47. We pass `true` so that we allow such strings as this code // know nothing about the actual string content. - assert(UTF8::is_legal_utf8((const unsigned char*)msg, (int)strlen(msg), true), "must be"); + assert(UTF8::is_legal_utf8((const unsigned char*)msg, strlen(msg), true), "must be"); _throw_msg(thread, file, line, h_name, msg); } diff --git a/src/hotspot/share/utilities/globalDefinitions.hpp b/src/hotspot/share/utilities/globalDefinitions.hpp index b7be6dc04bf..6d385165b8b 100644 --- a/src/hotspot/share/utilities/globalDefinitions.hpp +++ b/src/hotspot/share/utilities/globalDefinitions.hpp @@ -384,9 +384,14 @@ inline T byte_size_in_proper_unit(T s) { #define PROPERFMT SIZE_FORMAT "%s" #define PROPERFMTARGS(s) byte_size_in_proper_unit(s), proper_unit_for_byte_size(s) +// Printing a range, with start and bytes given #define RANGEFMT "[" PTR_FORMAT " - " PTR_FORMAT "), (" SIZE_FORMAT " bytes)" #define RANGEFMTARGS(p1, size) p2i(p1), p2i(p1 + size), size +// Printing a range, with start and end given +#define RANGE2FMT "[" PTR_FORMAT " - " PTR_FORMAT "), (" SIZE_FORMAT " bytes)" +#define RANGE2FMTARGS(p1, p2) p2i(p1), p2i(p2), ((uintptr_t)p2 - (uintptr_t)p1) + inline const char* exact_unit_for_byte_size(size_t s) { #ifdef _LP64 if (s >= G && (s % G) == 0) { diff --git a/src/hotspot/share/utilities/growableArray.cpp b/src/hotspot/share/utilities/growableArray.cpp index 8e1057dd9f8..60ed0a477e8 100644 --- a/src/hotspot/share/utilities/growableArray.cpp +++ b/src/hotspot/share/utilities/growableArray.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,13 +42,13 @@ void* GrowableArrayArenaAllocator::allocate(int max, int element_size, Arena* ar return arena->Amalloc(byte_size); } -void* GrowableArrayCHeapAllocator::allocate(int max, int element_size, MEMFLAGS memflags) { +void* GrowableArrayCHeapAllocator::allocate(int max, int element_size, MemTag mem_tag) { assert(max >= 0, "integer overflow"); size_t byte_size = element_size * (size_t) max; - // memory type has to be specified for C heap allocation - assert(memflags != mtNone, "memory type not specified for C heap object"); - return (void*)AllocateHeap(byte_size, memflags); + // memory tag has to be specified for C heap allocation + assert(mem_tag != mtNone, "memory tag not specified for C heap object"); + return (void*)AllocateHeap(byte_size, mem_tag); } void GrowableArrayCHeapAllocator::deallocate(void* elements) { diff --git a/src/hotspot/share/utilities/growableArray.hpp b/src/hotspot/share/utilities/growableArray.hpp index 79d03f58a9e..2eb8e6fd09e 100644 --- a/src/hotspot/share/utilities/growableArray.hpp +++ b/src/hotspot/share/utilities/growableArray.hpp @@ -595,7 +595,7 @@ public: // CHeap allocator class GrowableArrayCHeapAllocator { public: - static void* allocate(int max, int element_size, MEMFLAGS memflags); + static void* allocate(int max, int element_size, MemTag mem_tag); static void deallocate(void* mem); }; @@ -628,9 +628,9 @@ class GrowableArrayMetadata { } // CHeap allocation - static uintptr_t bits(MEMFLAGS memflags) { - assert(memflags != mtNone, "Must provide a proper MEMFLAGS"); - return (uintptr_t(memflags) << 1) | 1; + static uintptr_t bits(MemTag mem_tag) { + assert(mem_tag != mtNone, "Must provide a proper MemTag"); + return (uintptr_t(mem_tag) << 1) | 1; } // Arena allocation @@ -653,8 +653,8 @@ public: } // CHeap allocation - GrowableArrayMetadata(MEMFLAGS memflags) : - _bits(bits(memflags)) + GrowableArrayMetadata(MemTag mem_tag) : + _bits(bits(mem_tag)) debug_only(COMMA _nesting_check(false)) { } @@ -683,14 +683,14 @@ public: bool on_arena() const { return (_bits & 1) == 0 && _bits != 0; } Arena* arena() const { return (Arena*)_bits; } - MEMFLAGS memflags() const { return MEMFLAGS(_bits >> 1); } + MemTag mem_tag() const { return MemTag(_bits >> 1); } }; // THE GrowableArray. // // Supports multiple allocation strategies: // - Resource stack allocation: if no extra argument is provided -// - CHeap allocation: if memflags is provided +// - CHeap allocation: if mem_tag is provided // - Arena allocation: if an arena is provided // // There are some drawbacks of using GrowableArray, that are removed in some @@ -712,8 +712,8 @@ class GrowableArray : public GrowableArrayWithAllocator> { return (E*)GrowableArrayResourceAllocator::allocate(max, sizeof(E)); } - static E* allocate(int max, MEMFLAGS memflags) { - return (E*)GrowableArrayCHeapAllocator::allocate(max, sizeof(E), memflags); + static E* allocate(int max, MemTag mem_tag) { + return (E*)GrowableArrayCHeapAllocator::allocate(max, sizeof(E), mem_tag); } static E* allocate(int max, Arena* arena) { @@ -736,7 +736,7 @@ class GrowableArray : public GrowableArrayWithAllocator> { } if (on_C_heap()) { - return allocate(this->_capacity, _metadata.memflags()); + return allocate(this->_capacity, _metadata.mem_tag()); } assert(on_arena(), "Sanity"); @@ -760,11 +760,11 @@ public: init_checks(); } - GrowableArray(int initial_capacity, MEMFLAGS memflags) : + GrowableArray(int initial_capacity, MemTag mem_tag) : GrowableArrayWithAllocator( - allocate(initial_capacity, memflags), + allocate(initial_capacity, mem_tag), initial_capacity), - _metadata(memflags) { + _metadata(mem_tag) { init_checks(); } @@ -776,11 +776,11 @@ public: init_checks(); } - GrowableArray(int initial_capacity, int initial_len, const E& filler, MEMFLAGS memflags) : + GrowableArray(int initial_capacity, int initial_len, const E& filler, MemTag mem_tag) : GrowableArrayWithAllocator( - allocate(initial_capacity, memflags), + allocate(initial_capacity, mem_tag), initial_capacity, initial_len, filler), - _metadata(memflags) { + _metadata(mem_tag) { init_checks(); } @@ -799,25 +799,25 @@ public: } }; -// Leaner GrowableArray for CHeap backed data arrays, with compile-time decided MEMFLAGS. -template -class GrowableArrayCHeap : public GrowableArrayWithAllocator > { - friend class GrowableArrayWithAllocator >; +// Leaner GrowableArray for CHeap backed data arrays, with compile-time decided MemTag. +template +class GrowableArrayCHeap : public GrowableArrayWithAllocator > { + friend class GrowableArrayWithAllocator >; - STATIC_ASSERT(F != mtNone); + STATIC_ASSERT(MT != mtNone); - static E* allocate(int max, MEMFLAGS flags) { + static E* allocate(int max, MemTag mem_tag) { if (max == 0) { return nullptr; } - return (E*)GrowableArrayCHeapAllocator::allocate(max, sizeof(E), flags); + return (E*)GrowableArrayCHeapAllocator::allocate(max, sizeof(E), mem_tag); } NONCOPYABLE(GrowableArrayCHeap); E* allocate() { - return allocate(this->_capacity, F); + return allocate(this->_capacity, MT); } void deallocate(E* mem) { @@ -826,13 +826,13 @@ class GrowableArrayCHeap : public GrowableArrayWithAllocator >( - allocate(initial_capacity, F), + GrowableArrayWithAllocator >( + allocate(initial_capacity, MT), initial_capacity) {} GrowableArrayCHeap(int initial_capacity, int initial_len, const E& filler) : - GrowableArrayWithAllocator >( - allocate(initial_capacity, F), + GrowableArrayWithAllocator >( + allocate(initial_capacity, MT), initial_capacity, initial_len, filler) {} ~GrowableArrayCHeap() { @@ -840,11 +840,11 @@ public: } void* operator new(size_t size) { - return AnyObj::operator new(size, F); + return AnyObj::operator new(size, MT); } void* operator new(size_t size, const std::nothrow_t& nothrow_constant) throw() { - return AnyObj::operator new(size, nothrow_constant, F); + return AnyObj::operator new(size, nothrow_constant, MT); } void operator delete(void *p) { AnyObj::operator delete(p); diff --git a/src/hotspot/share/utilities/linkedlist.hpp b/src/hotspot/share/utilities/linkedlist.hpp index eec7ea1e48d..f0802b754ff 100644 --- a/src/hotspot/share/utilities/linkedlist.hpp +++ b/src/hotspot/share/utilities/linkedlist.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -138,7 +138,7 @@ template class LinkedList : public AnyObj { // A linked list implementation. // The linked list can be allocated in various type of memory: C heap, arena and resource area, etc. template + MemTag MT = mtNMT, AllocFailType alloc_failmode = AllocFailStrategy::RETURN_NULL> class LinkedListImpl : public LinkedList { protected: Arena* _arena; @@ -342,9 +342,9 @@ template (e); + return new(std::nothrow, MT) LinkedListNode(e); } else { - return new(F) LinkedListNode(e); + return new(MT) LinkedListNode(e); } } default: @@ -365,14 +365,14 @@ template - class SortedLinkedList : public LinkedListImpl { + MemTag MT = mtNMT, AllocFailType alloc_failmode = AllocFailStrategy::RETURN_NULL> + class SortedLinkedList : public LinkedListImpl { public: SortedLinkedList() { } - SortedLinkedList(Arena* a) : LinkedListImpl(a) { } + SortedLinkedList(Arena* a) : LinkedListImpl(a) { } virtual LinkedListNode* add(const E& e) { - return LinkedListImpl::add(e); + return LinkedListImpl::add(e); } virtual void move(LinkedList* list) { @@ -409,7 +409,7 @@ template * list) { - return LinkedListImpl::add(list); + return LinkedListImpl::add(list); } virtual LinkedListNode* find_node(const E& e) { diff --git a/src/hotspot/share/utilities/macros.hpp b/src/hotspot/share/utilities/macros.hpp index 1034dec0d9a..23094c9e8c4 100644 --- a/src/hotspot/share/utilities/macros.hpp +++ b/src/hotspot/share/utilities/macros.hpp @@ -338,6 +338,7 @@ #define NOT_PRODUCT_ARG(arg) #define PRODUCT_RETURN {} #define PRODUCT_RETURN0 { return 0; } +#define PRODUCT_RETURN_NULL { return nullptr; } #define PRODUCT_RETURN_(code) { code } #else // PRODUCT #define PRODUCT_ONLY(code) @@ -345,6 +346,7 @@ #define NOT_PRODUCT_ARG(arg) arg, #define PRODUCT_RETURN /*next token must be ;*/ #define PRODUCT_RETURN0 /*next token must be ;*/ +#define PRODUCT_RETURN_NULL /* next token must be ;*/ #define PRODUCT_RETURN_(code) /*next token must be ;*/ #endif // PRODUCT diff --git a/src/hotspot/share/utilities/objectBitSet.hpp b/src/hotspot/share/utilities/objectBitSet.hpp index 002e107972c..124188cd321 100644 --- a/src/hotspot/share/utilities/objectBitSet.hpp +++ b/src/hotspot/share/utilities/objectBitSet.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,8 +39,8 @@ class MemRegion; * allocated on-demand only, in fragments covering 64M heap ranges. Fragments are never deleted * during the lifetime of the ObjectBitSet. The underlying memory is allocated from C-Heap. */ -template -class ObjectBitSet : public CHeapObj { +template +class ObjectBitSet : public CHeapObj { const static size_t _bitmap_granularity_shift = 26; // 64M const static size_t _bitmap_granularity_size = (size_t)1 << _bitmap_granularity_shift; const static size_t _bitmap_granularity_mask = _bitmap_granularity_size - 1; @@ -52,7 +52,7 @@ class ObjectBitSet : public CHeapObj { return hash ^ (hash >> 3); } - typedef ResizeableResourceHashtable BitMapFragmentTable; CHeapBitMap* get_fragment_bits(uintptr_t addr); @@ -81,8 +81,8 @@ class ObjectBitSet : public CHeapObj { } }; -template -class ObjectBitSet::BitMapFragment : public CHeapObj { +template +class ObjectBitSet::BitMapFragment : public CHeapObj { CHeapBitMap _bits; BitMapFragment* _next; diff --git a/src/hotspot/share/utilities/objectBitSet.inline.hpp b/src/hotspot/share/utilities/objectBitSet.inline.hpp index 144f886cbd9..482a97bc2d1 100644 --- a/src/hotspot/share/utilities/objectBitSet.inline.hpp +++ b/src/hotspot/share/utilities/objectBitSet.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,22 +30,22 @@ #include "memory/memRegion.hpp" #include "utilities/bitMap.inline.hpp" -template -ObjectBitSet::BitMapFragment::BitMapFragment(uintptr_t granule, BitMapFragment* next) : - _bits(_bitmap_granularity_size >> LogMinObjAlignmentInBytes, F, true /* clear */), +template +ObjectBitSet::BitMapFragment::BitMapFragment(uintptr_t granule, BitMapFragment* next) : + _bits(_bitmap_granularity_size >> LogMinObjAlignmentInBytes, MT, true /* clear */), _next(next) { } -template -ObjectBitSet::ObjectBitSet() : +template +ObjectBitSet::ObjectBitSet() : _bitmap_fragments(32, 8*K), _fragment_list(nullptr), _last_fragment_bits(nullptr), _last_fragment_granule(UINTPTR_MAX) { } -template -ObjectBitSet::~ObjectBitSet() { +template +ObjectBitSet::~ObjectBitSet() { BitMapFragment* current = _fragment_list; while (current != nullptr) { BitMapFragment* next = current->next(); @@ -56,13 +56,13 @@ ObjectBitSet::~ObjectBitSet() { // ResizeableResourceHashtableStorage deletes the table. } -template -inline BitMap::idx_t ObjectBitSet::addr_to_bit(uintptr_t addr) const { +template +inline BitMap::idx_t ObjectBitSet::addr_to_bit(uintptr_t addr) const { return (addr & _bitmap_granularity_mask) >> LogMinObjAlignmentInBytes; } -template -inline CHeapBitMap* ObjectBitSet::get_fragment_bits(uintptr_t addr) { +template +inline CHeapBitMap* ObjectBitSet::get_fragment_bits(uintptr_t addr) { uintptr_t granule = addr >> _bitmap_granularity_shift; if (granule == _last_fragment_granule) { return _last_fragment_bits; @@ -86,15 +86,15 @@ inline CHeapBitMap* ObjectBitSet::get_fragment_bits(uintptr_t addr) { return bits; } -template -inline void ObjectBitSet::mark_obj(uintptr_t addr) { +template +inline void ObjectBitSet::mark_obj(uintptr_t addr) { CHeapBitMap* bits = get_fragment_bits(addr); const BitMap::idx_t bit = addr_to_bit(addr); bits->set_bit(bit); } -template -inline bool ObjectBitSet::is_marked(uintptr_t addr) { +template +inline bool ObjectBitSet::is_marked(uintptr_t addr) { CHeapBitMap* bits = get_fragment_bits(addr); const BitMap::idx_t bit = addr_to_bit(addr); return bits->at(bit); diff --git a/src/hotspot/share/utilities/resizeableResourceHash.hpp b/src/hotspot/share/utilities/resizeableResourceHash.hpp index 03ae8cec4c1..b0c992bf1ef 100644 --- a/src/hotspot/share/utilities/resizeableResourceHash.hpp +++ b/src/hotspot/share/utilities/resizeableResourceHash.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,7 +30,7 @@ template< typename K, typename V, AnyObj::allocation_type ALLOC_TYPE, - MEMFLAGS MEM_TYPE> + MemTag MEM_TAG> class ResizeableResourceHashtableStorage : public AnyObj { using Node = ResourceHashtableNode; @@ -52,7 +52,7 @@ protected: Node** alloc_table(unsigned table_size) { Node** table; if (ALLOC_TYPE == C_HEAP) { - table = NEW_C_HEAP_ARRAY(Node*, table_size, MEM_TYPE); + table = NEW_C_HEAP_ARRAY(Node*, table_size, MEM_TAG); } else { table = NEW_RESOURCE_ARRAY(Node*, table_size); } @@ -72,17 +72,17 @@ protected: template< typename K, typename V, AnyObj::allocation_type ALLOC_TYPE = AnyObj::RESOURCE_AREA, - MEMFLAGS MEM_TYPE = mtInternal, + MemTag MEM_TAG = mtInternal, unsigned (*HASH) (K const&) = primitive_hash, bool (*EQUALS)(K const&, K const&) = primitive_equals > class ResizeableResourceHashtable : public ResourceHashtableBase< - ResizeableResourceHashtableStorage, - K, V, ALLOC_TYPE, MEM_TYPE, HASH, EQUALS> { + ResizeableResourceHashtableStorage, + K, V, ALLOC_TYPE, MEM_TAG, HASH, EQUALS> { unsigned _max_size; - using BASE = ResourceHashtableBase, - K, V, ALLOC_TYPE, MEM_TYPE, HASH, EQUALS>; + using BASE = ResourceHashtableBase, + K, V, ALLOC_TYPE, MEM_TAG, HASH, EQUALS>; using Node = ResourceHashtableNode; NONCOPYABLE(ResizeableResourceHashtable); diff --git a/src/hotspot/share/utilities/resourceHash.hpp b/src/hotspot/share/utilities/resourceHash.hpp index b449dc6ea6c..a99239b21a0 100644 --- a/src/hotspot/share/utilities/resourceHash.hpp +++ b/src/hotspot/share/utilities/resourceHash.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -54,7 +54,7 @@ template< class STORAGE, typename K, typename V, AnyObj::allocation_type ALLOC_TYPE, - MEMFLAGS MEM_TYPE, + MemTag MEM_TAG, unsigned (*HASH) (K const&), bool (*EQUALS)(K const&, K const&) > @@ -153,7 +153,7 @@ class ResourceHashtableBase : public STORAGE { assert(*lookup_node(hv, key) == nullptr, "use put_if_absent"); Node** ptr = bucket_at(index); if (ALLOC_TYPE == AnyObj::C_HEAP) { - *ptr = new (MEM_TYPE) Node(hv, key, value, *ptr); + *ptr = new (MEM_TAG) Node(hv, key, value, *ptr); } else { *ptr = new Node(hv, key, value, *ptr); } @@ -174,7 +174,7 @@ class ResourceHashtableBase : public STORAGE { return false; } else { if (ALLOC_TYPE == AnyObj::C_HEAP) { - *ptr = new (MEM_TYPE) Node(hv, key, value); + *ptr = new (MEM_TAG) Node(hv, key, value); } else { *ptr = new Node(hv, key, value); } @@ -193,7 +193,7 @@ class ResourceHashtableBase : public STORAGE { Node** ptr = lookup_node(hv, key); if (*ptr == nullptr) { if (ALLOC_TYPE == AnyObj::C_HEAP) { - *ptr = new (MEM_TYPE) Node(hv, key); + *ptr = new (MEM_TAG) Node(hv, key); } else { *ptr = new Node(hv, key); } @@ -215,7 +215,7 @@ class ResourceHashtableBase : public STORAGE { Node** ptr = lookup_node(hv, key); if (*ptr == nullptr) { if (ALLOC_TYPE == AnyObj::C_HEAP) { - *ptr = new (MEM_TYPE) Node(hv, key, value); + *ptr = new (MEM_TAG) Node(hv, key, value); } else { *ptr = new Node(hv, key, value); } @@ -364,17 +364,17 @@ template< typename K, typename V, unsigned SIZE = 256, AnyObj::allocation_type ALLOC_TYPE = AnyObj::RESOURCE_AREA, - MEMFLAGS MEM_TYPE = mtInternal, + MemTag MEM_TAG = mtInternal, unsigned (*HASH) (K const&) = primitive_hash, bool (*EQUALS)(K const&, K const&) = primitive_equals > class ResourceHashtable : public ResourceHashtableBase< FixedResourceHashtableStorage, - K, V, ALLOC_TYPE, MEM_TYPE, HASH, EQUALS> { + K, V, ALLOC_TYPE, MEM_TAG, HASH, EQUALS> { NONCOPYABLE(ResourceHashtable); public: ResourceHashtable() : ResourceHashtableBase, - K, V, ALLOC_TYPE, MEM_TYPE, HASH, EQUALS>() {} + K, V, ALLOC_TYPE, MEM_TAG, HASH, EQUALS>() {} }; #endif // SHARE_UTILITIES_RESOURCEHASH_HPP diff --git a/src/hotspot/share/utilities/stack.hpp b/src/hotspot/share/utilities/stack.hpp index 8b2ce3802e0..1a9df130dff 100644 --- a/src/hotspot/share/utilities/stack.hpp +++ b/src/hotspot/share/utilities/stack.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -51,11 +51,11 @@ // implementation in class Stack assumes that alloc() will terminate the process // if the allocation fails. -template class StackIterator; +template class StackIterator; // StackBase holds common data/methods that don't depend on the element type, // factored out to reduce template code duplication. -template class StackBase +template class StackBase { public: size_t segment_size() const { return _seg_size; } // Elements per segment. @@ -85,11 +85,11 @@ protected: size_t _cache_size; // Number of segments in the cache. }; -template -class Stack: public StackBase +template +class Stack: public StackBase { public: - friend class StackIterator; + friend class StackIterator; // Number of elements that fit in 4K bytes minus the size of two pointers // (link field and malloc header). @@ -160,13 +160,13 @@ private: E* _cache; // Segment cache to avoid ping-ponging. }; -template +template class StackIterator: public StackObj { public: - StackIterator(Stack& stack): _stack(stack) { sync(); } + StackIterator(Stack& stack): _stack(stack) { sync(); } - Stack& stack() const { return _stack; } + Stack& stack() const { return _stack; } bool is_empty() const { return _cur_seg == nullptr; } @@ -176,7 +176,7 @@ public: void sync(); // Sync the iterator's state to the stack's current state. private: - Stack& _stack; + Stack& _stack; size_t _cur_seg_size; E* _cur_seg; size_t _full_seg_size; diff --git a/src/hotspot/share/utilities/stack.inline.hpp b/src/hotspot/share/utilities/stack.inline.hpp index bed33bd6652..49ccf416629 100644 --- a/src/hotspot/share/utilities/stack.inline.hpp +++ b/src/hotspot/share/utilities/stack.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,7 +31,7 @@ #include "utilities/align.hpp" #include "utilities/copy.hpp" -template StackBase::StackBase(size_t segment_size, size_t max_cache_size, +template StackBase::StackBase(size_t segment_size, size_t max_cache_size, size_t max_size): _seg_size(segment_size), _max_size(adjust_max_size(max_size, segment_size)), @@ -40,7 +40,7 @@ template StackBase::StackBase(size_t segment_size, size_t max_ca assert(_max_size % _seg_size == 0, "not a multiple"); } -template size_t StackBase::adjust_max_size(size_t max_size, size_t seg_size) +template size_t StackBase::adjust_max_size(size_t max_size, size_t seg_size) { assert(seg_size > 0, "cannot be 0"); assert(max_size >= seg_size || max_size == 0, "max_size too small"); @@ -51,15 +51,15 @@ template size_t StackBase::adjust_max_size(size_t max_size, size return (max_size + seg_size - 1) / seg_size * seg_size; } -template -Stack::Stack(size_t segment_size, size_t max_cache_size, size_t max_size): - StackBase(adjust_segment_size(segment_size), max_cache_size, max_size) +template +Stack::Stack(size_t segment_size, size_t max_cache_size, size_t max_size): + StackBase(adjust_segment_size(segment_size), max_cache_size, max_size) { reset(true); } -template -void Stack::push(E item) +template +void Stack::push(E item) { assert(!is_full(), "pushing onto a full stack"); size_t index = this->_cur_seg_size; @@ -71,8 +71,8 @@ void Stack::push(E item) this->_cur_seg_size = index + 1; } -template -E Stack::pop() +template +E Stack::pop() { assert(!is_empty(), "popping from an empty stack"); // _cur_seg_size is never 0 if not empty. pop that empties a @@ -85,16 +85,16 @@ E Stack::pop() return result; } -template -void Stack::clear(bool clear_cache) +template +void Stack::clear(bool clear_cache) { free_segments(_cur_seg); if (clear_cache) free_segments(_cache); reset(clear_cache); } -template -size_t Stack::adjust_segment_size(size_t seg_size) +template +size_t Stack::adjust_segment_size(size_t seg_size) { const size_t elem_sz = sizeof(E); const size_t ptr_sz = sizeof(E*); @@ -105,45 +105,45 @@ size_t Stack::adjust_segment_size(size_t seg_size) return seg_size; } -template -size_t Stack::link_offset() const +template +size_t Stack::link_offset() const { return align_up(this->_seg_size * sizeof(E), sizeof(E*)); } -template -size_t Stack::segment_bytes() const +template +size_t Stack::segment_bytes() const { return link_offset() + sizeof(E*); } -template -E** Stack::link_addr(E* seg) const +template +E** Stack::link_addr(E* seg) const { return (E**) ((char*)seg + link_offset()); } -template -E* Stack::get_link(E* seg) const +template +E* Stack::get_link(E* seg) const { return *link_addr(seg); } -template -E* Stack::set_link(E* new_seg, E* old_seg) +template +E* Stack::set_link(E* new_seg, E* old_seg) { *link_addr(new_seg) = old_seg; return new_seg; } -template -E* Stack::alloc(size_t bytes) +template +E* Stack::alloc(size_t bytes) { - return (E*) NEW_C_HEAP_ARRAY(char, bytes, F); + return (E*) NEW_C_HEAP_ARRAY(char, bytes, MT); } -template -void Stack::free(E* addr, size_t bytes) +template +void Stack::free(E* addr, size_t bytes) { FREE_C_HEAP_ARRAY(char, (char*) addr); } @@ -152,8 +152,8 @@ void Stack::free(E* addr, size_t bytes) // code gets inlined. This is generally good, but when too much code has // been inlined, further inlining in the caller might be inhibited. So // prevent infrequent slow path segment manipulation from being inlined. -template -NOINLINE void Stack::push_segment() +template +NOINLINE void Stack::push_segment() { assert(this->_cur_seg_size == this->_seg_size, "current segment is not full"); E* next; @@ -173,8 +173,8 @@ NOINLINE void Stack::push_segment() DEBUG_ONLY(verify(at_empty_transition);) } -template -NOINLINE void Stack::pop_segment() +template +NOINLINE void Stack::pop_segment() { assert(this->_cur_seg_size == 0, "current segment is not empty"); E* const prev = get_link(_cur_seg); @@ -194,8 +194,8 @@ NOINLINE void Stack::pop_segment() DEBUG_ONLY(verify(at_empty_transition);) } -template -void Stack::free_segments(E* seg) +template +void Stack::free_segments(E* seg) { const size_t bytes = segment_bytes(); while (seg != nullptr) { @@ -205,8 +205,8 @@ void Stack::free_segments(E* seg) } } -template -void Stack::reset(bool reset_cache) +template +void Stack::reset(bool reset_cache) { this->_cur_seg_size = this->_seg_size; // So push() will alloc a new segment. this->_full_seg_size = 0; @@ -218,8 +218,8 @@ void Stack::reset(bool reset_cache) } #ifdef ASSERT -template -void Stack::verify(bool at_empty_transition) const +template +void Stack::verify(bool at_empty_transition) const { assert(size() <= this->max_size(), "stack exceeded bounds"); assert(this->cache_size() <= this->max_cache_size(), "cache exceeded bounds"); @@ -234,8 +234,8 @@ void Stack::verify(bool at_empty_transition) const } } -template -void Stack::zap_segment(E* seg, bool zap_link_field) const +template +void Stack::zap_segment(E* seg, bool zap_link_field) const { if (!ZapStackSegments) return; const size_t zap_bytes = segment_bytes() - (zap_link_field ? 0 : sizeof(E*)); @@ -243,16 +243,16 @@ void Stack::zap_segment(E* seg, bool zap_link_field) const } #endif -template -void StackIterator::sync() +template +void StackIterator::sync() { _full_seg_size = _stack._full_seg_size; _cur_seg_size = _stack._cur_seg_size; _cur_seg = _stack._cur_seg; } -template -E* StackIterator::next_addr() +template +E* StackIterator::next_addr() { assert(!is_empty(), "no items left"); if (_cur_seg_size == 1) { diff --git a/src/java.base/aix/native/libnio/MappedMemoryUtils.c b/src/java.base/aix/native/libnio/MappedMemoryUtils.c index 5d0216cc251..e17ca2092af 100644 --- a/src/java.base/aix/native/libnio/MappedMemoryUtils.c +++ b/src/java.base/aix/native/libnio/MappedMemoryUtils.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,9 +46,8 @@ static long calculate_number_of_pages_in_range(void* address, size_t len, size_t return numPages; } -JNIEXPORT jboolean JNICALL -Java_java_nio_MappedMemoryUtils_isLoaded0(JNIEnv *env, jobject obj, jlong address, - jlong len, jlong numPages) +jboolean JNICALL MappedMemoryUtils_isLoaded0(JNIEnv *env, jobject obj, jlong address, + jlong len, jlong numPages) { jboolean loaded = JNI_TRUE; int result = 0; @@ -93,8 +92,7 @@ Java_java_nio_MappedMemoryUtils_isLoaded0(JNIEnv *env, jobject obj, jlong addres } -JNIEXPORT void JNICALL -Java_java_nio_MappedMemoryUtils_load0(JNIEnv *env, jobject obj, jlong address, +void JNICALL MappedMemoryUtils_load0(JNIEnv *env, jobject obj, jlong address, jlong len) { char *a = (char *)jlong_to_ptr(address); @@ -104,9 +102,8 @@ Java_java_nio_MappedMemoryUtils_load0(JNIEnv *env, jobject obj, jlong address, } } -JNIEXPORT void JNICALL -Java_java_nio_MappedMemoryUtils_unload0(JNIEnv *env, jobject obj, jlong address, - jlong len) +void JNICALL MappedMemoryUtils_unload0(JNIEnv *env, jobject obj, jlong address, + jlong len) { char *a = (char *)jlong_to_ptr(address); int result = madvise((caddr_t)a, (size_t)len, MADV_DONTNEED); @@ -198,8 +195,7 @@ static int validate_msync_address(size_t address) return 0; } -JNIEXPORT void JNICALL -Java_java_nio_MappedMemoryUtils_force0(JNIEnv *env, jobject obj, jobject fdo, +void JNICALL MappedMemoryUtils_force0(JNIEnv *env, jobject obj, jobject fdo, jlong address, jlong len) { void* a = (void *)jlong_to_ptr(address); @@ -218,3 +214,19 @@ Java_java_nio_MappedMemoryUtils_force0(JNIEnv *env, jobject obj, jobject fdo, JNU_ThrowIOExceptionWithMessageAndLastError(env, "msync with parameter MS_SYNC failed"); } } + +#define FD "Ljava/io/FileDescriptor;" + +static JNINativeMethod methods[] = { + {"isLoaded0", "(JJJ)Z", (void *)&MappedMemoryUtils_isLoaded0}, + {"load0", "(JJ)V", (void *)&MappedMemoryUtils_load0}, + {"unload0", "(JJ)V", (void *)&MappedMemoryUtils_unload0}, + {"force0", "(" FD "JJ)V", (void *)&MappedMemoryUtils_force0}, +}; + +JNIEXPORT void JNICALL +Java_java_nio_MappedMemoryUtils_registerNatives(JNIEnv *env, jclass cls) +{ + (*env)->RegisterNatives(env, cls, + methods, sizeof(methods)/sizeof(methods[0])); +} diff --git a/src/java.base/macosx/native/libjava/ProcessHandleImpl_macosx.c b/src/java.base/macosx/native/libjava/ProcessHandleImpl_macosx.c index e3d811cfca6..d1397fe4546 100644 --- a/src/java.base/macosx/native/libjava/ProcessHandleImpl_macosx.c +++ b/src/java.base/macosx/native/libjava/ProcessHandleImpl_macosx.c @@ -97,25 +97,35 @@ jint os_getChildren(JNIEnv *env, jlong jpid, jlongArray jarray, } } - // Get buffer size needed to read all processes - int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_ALL, 0}; - if (sysctl(mib, 4, NULL, &bufSize, NULL, 0) < 0) { - JNU_ThrowByNameWithLastError(env, - "java/lang/RuntimeException", "sysctl failed"); - return -1; - } + int errsysctl; + int maxRetries = 100; + void *buffer = NULL; + do { + int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_ALL, 0}; + if (buffer != NULL) free(buffer); + // Get buffer size needed to read all processes + if (sysctl(mib, 4, NULL, &bufSize, NULL, 0) < 0) { + JNU_ThrowByNameWithMessageAndLastError(env, + "java/lang/RuntimeException", "sysctl failed"); + return -1; + } - // Allocate buffer big enough for all processes - void *buffer = malloc(bufSize); - if (buffer == NULL) { - JNU_ThrowOutOfMemoryError(env, "malloc failed"); - return -1; - } + // Allocate buffer big enough for all processes; add a little + // bit of space to be able to hold a few more proc infos + // for processes started right after the first sysctl call + buffer = malloc(bufSize + 4 * sizeof(struct kinfo_proc)); + if (buffer == NULL) { + JNU_ThrowOutOfMemoryError(env, "malloc failed"); + return -1; + } - // Read process info for all processes - if (sysctl(mib, 4, buffer, &bufSize, NULL, 0) < 0) { - JNU_ThrowByNameWithLastError(env, - "java/lang/RuntimeException", "sysctl failed"); + // Read process info for all processes + errsysctl = sysctl(mib, 4, buffer, &bufSize, NULL, 0); + } while (errsysctl < 0 && errno == ENOMEM && maxRetries-- > 0); + + if (errsysctl < 0) { + JNU_ThrowByNameWithMessageAndLastError(env, + "java/lang/RuntimeException", "sysctl failed to get info about all processes"); free(buffer); return -1; } diff --git a/src/java.base/macosx/native/libjli/java_md_macosx.m b/src/java.base/macosx/native/libjli/java_md_macosx.m index 4ac2f2c10a2..7aeb32be859 100644 --- a/src/java.base/macosx/native/libjli/java_md_macosx.m +++ b/src/java.base/macosx/native/libjli/java_md_macosx.m @@ -60,115 +60,79 @@ struct NSAppArgs { #define LD_LIBRARY_PATH "DYLD_FALLBACK_LIBRARY_PATH" /* - * If a processor / os combination has the ability to run binaries of - * two data models and cohabitation of jre/jdk bits with both data - * models is supported, then DUAL_MODE is defined. MacOSX is a hybrid - * system in that, the universal library can contain all types of libraries - * 32/64 and client/server, thus the spawn is capable of linking with the - * appropriate library as requested. + * Following is the high level flow of the launcher + * code residing in the common java.c and this + * macosx specific java_md_macosx file: * - * Notes: - * 1. VM. DUAL_MODE is disabled, and not supported, however, it is left here in - * for experimentation and perhaps enable it in the future. - * 2. At the time of this writing, the universal library contains only - * a server 64-bit server JVM. - * 3. "-client" command line option is supported merely as a command line flag, - * for, compatibility reasons, however, a server VM will be launched. - */ - -/* - * Flowchart of launcher execs and options processing on unix + * - JLI_Launch function, which is the entry point + * to the launcher, calls CreateExecutionEnvironment. * - * The selection of the proper vm shared library to open depends on - * several classes of command line options, including vm "flavor" - * options (-client, -server) and the data model options, -d32 and - * -d64, as well as a version specification which may have come from - * the command line or from the manifest of an executable jar file. - * The vm selection options are not passed to the running - * virtual machine; they must be screened out by the launcher. + * - CreateExecutionEnvironment does the following + * (not necessarily in this order): + * - determines the relevant JVM type that needs + * to be ultimately created + * - determines the path and asserts the presence + * of libjava and relevant libjvm library + * - removes any JVM selection options from the + * arguments that were passed to the launcher * - * The version specification (if any) is processed first by the - * platform independent routine SelectVersion. This may result in - * the exec of the specified launcher version. + * - CreateExecutionEnvironment then creates a new + * thread, within the same process, to launch the + * application's main() Java method and parks the + * current thread, on which CreateExecutionEnvironment + * was invoked, in Apple's Cocoa event loop. Before + * doing so, CreateExecutionEnvironment maintains a + * state flag to keep note that a new thread has + * been spawned. * - * Now, in most cases,the launcher will dlopen the target libjvm.so. All - * required libraries are loaded by the runtime linker, using the known paths - * baked into the shared libraries at compile time. Therefore, - * in most cases, the launcher will only exec, if the data models are - * mismatched, and will not set any environment variables, regardless of the - * data models. + * - The newly created thread (in which the application's + * main() method will ultimately run) starts right from + * the beginning of the current process' main function, + * which effectively means that JLI_Launch is re-invoked + * on this new thread and the same above sequence of code + * flow repeats again. During this "recursive" call, when + * at the point of creating a new thread in + * CreateExecutionEnvironment, the CreateExecutionEnvironment + * will check for the state flag to see if a new thread + * has already been spawned and upon noticing that it + * has, it will skip spawning any more threads and will + * return back from CreateExecutionEnvironment. * + * - The control returns back from CreateExecutionEnvironment + * to JLI_Launch, and the thread on which the control + * returns is the thread on which the application's main() + * Java method will be invoked. * + * - JLI_Launch then invokes LoadJavaVM which dlopen()s the + * JVM library and asserts the presence of JNI Invocation + * Functions "JNI_CreateJavaVM", "JNI_GetDefaultJavaVMInitArgs" + * and "JNI_GetCreatedJavaVMs" in that library. It then sets + * internal function pointers in the launcher to point to + * those functions. * - * Main - * (incoming argv) - * | - * \|/ - * CreateExecutionEnvironment - * (determines desired data model) - * | - * | - * \|/ - * Have Desired Model ? --> NO --> Is Dual-Mode ? --> NO --> Exit(with error) - * | | - * | | - * | \|/ - * | YES - * | | - * | | - * | \|/ - * | CheckJvmType - * | (removes -client, -server etc.) - * | | - * | | - * \|/ \|/ - * YES Find the desired executable/library - * | | - * | | - * \|/ \|/ - * CheckJvmType POINT A - * (removes -client, -server, etc.) - * | - * | - * \|/ - * TranslateDashJArgs... - * (Prepare to pass args to vm) - * | - * | - * \|/ - * ParseArguments - * (processes version options, - * creates argument list for vm, - * etc.) - * | - * | - * \|/ - * POINT A - * | - * | - * \|/ - * Path is desired JRE ? YES --> Continue - * NO - * | - * | - * \|/ - * Paths have well known - * jvm paths ? --> NO --> Continue - * YES - * | - * | - * \|/ - * Does libjvm.so exist - * in any of them ? --> NO --> Continue - * YES - * | - * | - * \|/ - * Re-exec / Spawn - * | - * | - * \|/ - * Main + * - JLI_Launch then translates any -J options by invoking + * TranslateApplicationArgs. + * + * - JLI_Launch then invokes ParseArguments to parse/process + * the launcher arguments. + * + * - JLI_Launch then ultimately calls JVMInit. + * + * - JVMInit then invokes JavaMain. + * + * - JavaMain, before launching the application, invokes + * PostJVMInit. + * + * - PostJVMInit invokes ShowSplashScreen which displays + * a splash screen for the application, if applicable. + * + * - Control then returns back from PostJVMInit into + * JavaMain, which then loads the application's main + * class and invokes the relevant main() Java method. + * + * - JavaMain then returns back an integer result which + * then gets propagated as a return value all the way + * out of the JLI_Launch function. */ /* Store the name of the executable once computed */ @@ -333,6 +297,7 @@ static void ParkEventLoop() { static void MacOSXStartup(int argc, char *argv[]) { // Thread already started? static jboolean started = false; + int rc; if (started) { return; } @@ -345,12 +310,14 @@ static void MacOSXStartup(int argc, char *argv[]) { // Fire up the main thread pthread_t main_thr; - if (pthread_create(&main_thr, NULL, &apple_main, &args) != 0) { - JLI_ReportErrorMessageSys("Could not create main thread: %s\n", strerror(errno)); + rc = pthread_create(&main_thr, NULL, &apple_main, &args); + if (rc != 0) { + JLI_ReportErrorMessageSys("Could not create main thread, return code: %d\n", rc); exit(1); } - if (pthread_detach(main_thr)) { - JLI_ReportErrorMessageSys("pthread_detach() failed: %s\n", strerror(errno)); + rc = pthread_detach(main_thr); + if (rc != 0) { + JLI_ReportErrorMessage("pthread_detach() failed, return code: %d\n", rc); exit(1); } diff --git a/src/java.base/share/classes/com/sun/crypto/provider/GaloisCounterMode.java b/src/java.base/share/classes/com/sun/crypto/provider/GaloisCounterMode.java index 44cfb76d162..478593dfac1 100644 --- a/src/java.base/share/classes/com/sun/crypto/provider/GaloisCounterMode.java +++ b/src/java.base/share/classes/com/sun/crypto/provider/GaloisCounterMode.java @@ -72,7 +72,7 @@ abstract class GaloisCounterMode extends CipherSpi { // data size when buffer is divided up to aid in intrinsics private static final int TRIGGERLEN = 65536; // 64k // x86-64 parallel intrinsic data size - private static final int PARALLEL_LEN = 7680; + private static final int PARALLEL_LEN = 512; // max data size for x86-64 intrinsic private static final int SPLIT_LEN = 1048576; // 1MB diff --git a/src/java.base/share/classes/java/io/BufferedInputStream.java b/src/java.base/share/classes/java/io/BufferedInputStream.java index cfc2a3d2c75..c401873ce12 100644 --- a/src/java.base/share/classes/java/io/BufferedInputStream.java +++ b/src/java.base/share/classes/java/io/BufferedInputStream.java @@ -50,6 +50,11 @@ import jdk.internal.util.ArraysSupport; * reread before new bytes are taken from * the contained input stream. * + * @apiNote + * Once wrapped in a {@code BufferedInputStream}, the underlying + * {@code InputStream} should not be used directly nor wrapped with + * another stream. + * * @author Arthur van Hoff * @since 1.0 */ diff --git a/src/java.base/share/classes/java/io/BufferedOutputStream.java b/src/java.base/share/classes/java/io/BufferedOutputStream.java index ecc1e8a8a48..687f0c91bc4 100644 --- a/src/java.base/share/classes/java/io/BufferedOutputStream.java +++ b/src/java.base/share/classes/java/io/BufferedOutputStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1994, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1994, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,6 +35,11 @@ import jdk.internal.misc.VM; * output stream without necessarily causing a call to the underlying * system for each byte written. * + * @apiNote + * Once wrapped in a {@code BufferedOutputStream}, the underlying + * {@code OutputStream} should not be used directly nor wrapped with + * another stream. + * * @author Arthur van Hoff * @since 1.0 */ diff --git a/src/java.base/share/classes/java/io/BufferedReader.java b/src/java.base/share/classes/java/io/BufferedReader.java index 2cd027c8bd8..c2f6b89e086 100644 --- a/src/java.base/share/classes/java/io/BufferedReader.java +++ b/src/java.base/share/classes/java/io/BufferedReader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -43,8 +43,9 @@ import jdk.internal.misc.InternalLock; * *

In general, each read request made of a Reader causes a corresponding * read request to be made of the underlying character or byte stream. It is - * therefore advisable to wrap a BufferedReader around any Reader whose read() - * operations may be costly, such as FileReaders and InputStreamReaders. For + * therefore advisable to wrap a {@code BufferedReader} around any + * {@code Reader} whose {@code read()} operations may be costly, such as + * {@code FileReader}s and {@code InputStreamReader}s. For * example, * * {@snippet lang=java : @@ -52,12 +53,18 @@ import jdk.internal.misc.InternalLock; * } * * will buffer the input from the specified file. Without buffering, each - * invocation of read() or readLine() could cause bytes to be read from the - * file, converted into characters, and then returned, which can be very - * inefficient. + * invocation of {@code read()} or {@code readLine()} could cause bytes to be + * read from the file, converted into characters, and then returned, which can + * be very inefficient. * - *

Programs that use DataInputStreams for textual input can be localized by - * replacing each DataInputStream with an appropriate BufferedReader. + *

Programs that use {@code DataInputStream}s for textual input can be + * localized by replacing each {@code DataInputStream} with an appropriate + * {@code BufferedReader}. + * + * @apiNote + * Once wrapped in a {@code BufferedReader}, the underlying + * {@code Reader} should not be used directly nor wrapped with + * another reader. * * @see FileReader * @see InputStreamReader diff --git a/src/java.base/share/classes/java/io/BufferedWriter.java b/src/java.base/share/classes/java/io/BufferedWriter.java index 4904f718072..17862a265ae 100644 --- a/src/java.base/share/classes/java/io/BufferedWriter.java +++ b/src/java.base/share/classes/java/io/BufferedWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,25 +37,31 @@ import jdk.internal.misc.VM; *

The buffer size may be specified, or the default size may be accepted. * The default is large enough for most purposes. * - *

A newLine() method is provided, which uses the platform's own notion of - * line separator as defined by the system property {@code line.separator}. - * Not all platforms use the newline character ('\n') to terminate lines. - * Calling this method to terminate each output line is therefore preferred to - * writing a newline character directly. + *

A {@code newLine()} method is provided, which uses the platform's own + * notion of line separator as defined by the system property + * {@linkplain System#lineSeparator() line.separator}. Not all platforms use the newline character ('\n') + * to terminate lines. Calling this method to terminate each output line is + * therefore preferred to writing a newline character directly. * - *

In general, a Writer sends its output immediately to the underlying - * character or byte stream. Unless prompt output is required, it is advisable - * to wrap a BufferedWriter around any Writer whose write() operations may be - * costly, such as FileWriters and OutputStreamWriters. For example, + *

In general, a {@code Writer} sends its output immediately to the + * underlying character or byte stream. Unless prompt output is required, it + * is advisable to wrap a {@code BufferedWriter} around any {@code Writer} whose + * {@code write()} operations may be costly, such as {@code FileWriter}s and + * {@code OutputStreamWriter}s. For example, * * {@snippet lang=java : * PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("foo.out"))); * } * - * will buffer the PrintWriter's output to the file. Without buffering, each - * invocation of a print() method would cause characters to be converted into - * bytes that would then be written immediately to the file, which can be very - * inefficient. + * will buffer the {@code PrintWriter}'s output to the file. Without buffering, + * each invocation of a {@code print()} method would cause characters to be + * converted into bytes that would then be written immediately to the file, + * which can be very inefficient. + * + * @apiNote + * Once wrapped in a {@code BufferedWriter}, the underlying + * {@code Writer} should not be used directly nor wrapped with + * another writer. * * @see PrintWriter * @see FileWriter diff --git a/src/java.base/share/classes/java/io/DataInputStream.java b/src/java.base/share/classes/java/io/DataInputStream.java index eab7a6e2f18..59377aca429 100644 --- a/src/java.base/share/classes/java/io/DataInputStream.java +++ b/src/java.base/share/classes/java/io/DataInputStream.java @@ -1,5 +1,6 @@ /* * Copyright (c) 1994, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, Alibaba Group Holding Limited. 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 @@ -25,8 +26,11 @@ package java.io; +import jdk.internal.access.JavaLangAccess; +import jdk.internal.access.SharedSecrets; import jdk.internal.util.ByteArray; +import java.nio.charset.StandardCharsets; import java.util.Objects; /** @@ -45,6 +49,7 @@ import java.util.Objects; * @since 1.0 */ public class DataInputStream extends FilterInputStream implements DataInput { + private static final JavaLangAccess JLA = SharedSecrets.getJavaLangAccess(); private static final byte[] EMPTY_BYTE_ARRAY = new byte[0]; private static final char[] EMPTY_CHAR_ARRAY = new char[0]; @@ -573,18 +578,16 @@ loop: while (true) { */ public static final String readUTF(DataInput in) throws IOException { int utflen = in.readUnsignedShort(); - byte[] bytearr; - char[] chararr; + byte[] bytearr = null; if (in instanceof DataInputStream dis) { - if (dis.bytearr.length < utflen) { - dis.bytearr = new byte[utflen*2]; - dis.chararr = new char[utflen*2]; + if (dis.bytearr.length >= utflen) { + bytearr = dis.bytearr; } - chararr = dis.chararr; - bytearr = dis.bytearr; - } else { + } + boolean trusted = false; + if (bytearr == null) { bytearr = new byte[utflen]; - chararr = new char[utflen]; + trusted = true; } int c, char2, char3; @@ -592,12 +595,35 @@ loop: while (true) { int chararr_count=0; in.readFully(bytearr, 0, utflen); + int ascii = JLA.countPositives(bytearr, 0, utflen); + if (ascii == utflen) { + String str; + if (trusted) { + str = JLA.newStringNoRepl(bytearr, StandardCharsets.ISO_8859_1); + } else { + str = new String(bytearr, 0, utflen, StandardCharsets.ISO_8859_1); + } + return str; + } + if (trusted && in instanceof DataInputStream dis) { + dis.bytearr = bytearr; + trusted = false; + } - while (count < utflen) { - c = (int) bytearr[count] & 0xff; - if (c > 127) break; - count++; - chararr[chararr_count++]=(char)c; + char[] chararr; + if (in instanceof DataInputStream dis) { + if (dis.chararr.length < (utflen << 1)) { + dis.chararr = new char[utflen << 1]; + } + chararr = dis.chararr; + } else { + chararr = new char[utflen]; + } + + if (ascii != 0) { + JLA.inflateBytesToChars(bytearr, 0, chararr, 0, ascii); + count += ascii; + chararr_count += ascii; } while (count < utflen) { diff --git a/src/java.base/share/classes/java/io/DataOutputStream.java b/src/java.base/share/classes/java/io/DataOutputStream.java index d16ae73f913..4b22d65bd39 100644 --- a/src/java.base/share/classes/java/io/DataOutputStream.java +++ b/src/java.base/share/classes/java/io/DataOutputStream.java @@ -1,5 +1,6 @@ /* - * Copyright (c) 1994, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1994, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, Alibaba Group Holding Limited. 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 @@ -25,8 +26,13 @@ package java.io; +import jdk.internal.access.JavaLangAccess; +import jdk.internal.access.SharedSecrets; import jdk.internal.util.ByteArray; +import static jdk.internal.util.ModifiedUtf.putChar; +import static jdk.internal.util.ModifiedUtf.utfLen; + /** * A data output stream lets an application write primitive Java data * types to an output stream in a portable way. An application can @@ -44,6 +50,8 @@ import jdk.internal.util.ByteArray; * @since 1.0 */ public class DataOutputStream extends FilterOutputStream implements DataOutput { + private static final JavaLangAccess JLA = SharedSecrets.getJavaLangAccess(); + /** * The number of bytes written to the data output stream so far. * If this counter overflows, it will be wrapped to Integer.MAX_VALUE. @@ -352,15 +360,11 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput { * {@code str} would exceed 65535 bytes in length * @throws IOException if some other I/O error occurs. */ + @SuppressWarnings("deprecation") static int writeUTF(String str, DataOutput out) throws IOException { final int strlen = str.length(); - int utflen = strlen; // optimized for ASCII - - for (int i = 0; i < strlen; i++) { - int c = str.charAt(i); - if (c >= 0x80 || c == 0) - utflen += (c >= 0x800) ? 2 : 1; - } + int countNonZeroAscii = JLA.countNonZeroAscii(str); + int utflen = utfLen(str, countNonZeroAscii); if (utflen > 65535 || /* overflow */ utflen < strlen) throw new UTFDataFormatException(tooLongMsg(str, utflen)); @@ -377,25 +381,11 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput { int count = 0; ByteArray.setUnsignedShort(bytearr, count, utflen); count += 2; - int i = 0; - for (i = 0; i < strlen; i++) { // optimized for initial run of ASCII - int c = str.charAt(i); - if (c >= 0x80 || c == 0) break; - bytearr[count++] = (byte) c; - } + str.getBytes(0, countNonZeroAscii, bytearr, count); + count += countNonZeroAscii; - for (; i < strlen; i++) { - int c = str.charAt(i); - if (c < 0x80 && c != 0) { - bytearr[count++] = (byte) c; - } else if (c >= 0x800) { - bytearr[count++] = (byte) (0xE0 | ((c >> 12) & 0x0F)); - bytearr[count++] = (byte) (0x80 | ((c >> 6) & 0x3F)); - bytearr[count++] = (byte) (0x80 | ((c >> 0) & 0x3F)); - } else { - bytearr[count++] = (byte) (0xC0 | ((c >> 6) & 0x1F)); - bytearr[count++] = (byte) (0x80 | ((c >> 0) & 0x3F)); - } + for (int i = countNonZeroAscii; i < strlen;) { + count = putChar(bytearr, count, str.charAt(i++)); } out.write(bytearr, 0, utflen + 2); return utflen + 2; diff --git a/src/java.base/share/classes/java/io/File.java b/src/java.base/share/classes/java/io/File.java index b603e155513..61c15bdd15c 100644 --- a/src/java.base/share/classes/java/io/File.java +++ b/src/java.base/share/classes/java/io/File.java @@ -79,6 +79,10 @@ import jdk.internal.util.StaticProperty; * {@code user.dir}, and is typically the directory in which the Java * virtual machine was invoked. * + *

Unless otherwise noted, {@linkplain java.nio.file##links symbolic links} + * are automatically redirected to the target of the link, whether they + * are provided by a pathname string or via a {@code File} object. + * *

The parent of an abstract pathname may be obtained by invoking * the {@link #getParent} method of this class and consists of the pathname's * prefix and each name in the pathname's name sequence except for the last. @@ -904,8 +908,16 @@ public class File * Tests whether the file named by this abstract pathname is a hidden * file. The exact definition of hidden is system-dependent. On * UNIX systems, a file is considered to be hidden if its name begins with - * a period character ({@code '.'}). On Microsoft Windows systems, a file is - * considered to be hidden if it has been marked as such in the filesystem. + * a period character ({@code '.'}). On Microsoft Windows systems, a file + * is considered to be hidden if it has been marked as such in the + * filesystem. + * + * + * @implNote + * If the file is a symbolic link, then on UNIX system it is considered to + * be hidden if the name of the link itself, not that of its target, begins + * with a period character. On Windows systems, a symbolic link is + * considered hidden if its target is so marked in the filesystem. * * @return {@code true} if and only if the file denoted by this * abstract pathname is hidden according to the conventions of the @@ -1048,7 +1060,8 @@ public class File /** * Deletes the file or directory denoted by this abstract pathname. If * this pathname denotes a directory, then the directory must be empty in - * order to be deleted. + * order to be deleted. If this pathname denotes a symbolic link, then the + * link itself, not its target, will be deleted. * *

Note that the {@link java.nio.file.Files} class defines the {@link * java.nio.file.Files#delete(Path) delete} method to throw an {@link IOException} @@ -1078,6 +1091,8 @@ public class File /** * Requests that the file or directory denoted by this abstract * pathname be deleted when the virtual machine terminates. + * If this pathname denotes a symbolic link, then the + * link itself, not its target, will be deleted. * Files (or directories) are deleted in the reverse order that * they are registered. Invoking this method to delete a file or * directory that is already registered for deletion has no effect. @@ -1421,7 +1436,9 @@ public class File } /** - * Renames the file denoted by this abstract pathname. + * Renames the file denoted by this abstract pathname. If this pathname + * denotes a symbolic link, then the link itself, not its target, will be + * renamed. * *

Many aspects of the behavior of this method are inherently * platform-dependent: The rename operation might not be able to move a diff --git a/src/java.base/share/classes/java/io/FileInputStream.java b/src/java.base/share/classes/java/io/FileInputStream.java index 27507108237..180b2e416a9 100644 --- a/src/java.base/share/classes/java/io/FileInputStream.java +++ b/src/java.base/share/classes/java/io/FileInputStream.java @@ -82,10 +82,11 @@ public class FileInputStream extends InputStream private volatile boolean closed; /** - * Creates a {@code FileInputStream} by - * opening a connection to an actual file, - * the file named by the path name {@code name} - * in the file system. A new {@code FileDescriptor} + * Creates a {@code FileInputStream} to read from an existing file + * named by the path name {@code name}. + * {@linkplain java.nio.file##links Symbolic links} + * are automatically redirected to the target of the link. + * A new {@code FileDescriptor} * object is created to represent this file * connection. *

@@ -113,10 +114,10 @@ public class FileInputStream extends InputStream } /** - * Creates a {@code FileInputStream} by - * opening a connection to an actual file, - * the file named by the {@code File} - * object {@code file} in the file system. + * Creates a {@code FileInputStream} to read from an existing file + * represented by the {@code File} object {@code file}. + * {@linkplain java.nio.file##links Symbolic links} + * are automatically redirected to the target of the link. * A new {@code FileDescriptor} object * is created to represent this file connection. *

diff --git a/src/java.base/share/classes/java/io/FileOutputStream.java b/src/java.base/share/classes/java/io/FileOutputStream.java index b8c26f38143..ff15e831b95 100644 --- a/src/java.base/share/classes/java/io/FileOutputStream.java +++ b/src/java.base/share/classes/java/io/FileOutputStream.java @@ -97,7 +97,10 @@ public class FileOutputStream extends OutputStream /** * Creates a file output stream to write to the file with the - * specified name. A new {@code FileDescriptor} object is + * specified name. If the file exists, it is truncated, otherwise a + * new file is created. {@linkplain java.nio.file##links Symbolic links} + * are automatically redirected to the target of the link. + * A new {@code FileDescriptor} object is * created to represent this file connection. *

* First, if there is a security manager, its {@code checkWrite} @@ -126,8 +129,11 @@ public class FileOutputStream extends OutputStream /** * Creates a file output stream to write to the file with the specified - * name. If the second argument is {@code true}, then - * bytes will be written to the end of the file rather than the beginning. + * name. If the file exists, it is truncated unless the second + * argument is {@code true}, in which case bytes will be written to the + * end of the file rather than the beginning. If the file does not exist, + * it is created. {@linkplain java.nio.file##links Symbolic links} + * are automatically redirected to the target of the link. * A new {@code FileDescriptor} object is created to represent this * file connection. *

@@ -158,9 +164,12 @@ public class FileOutputStream extends OutputStream /** * Creates a file output stream to write to the file represented by - * the specified {@code File} object. A new - * {@code FileDescriptor} object is created to represent this - * file connection. + * the specified {@code File} object. + * If the file exists, it is truncated, otherwise a + * new file is created. {@linkplain java.nio.file##links Symbolic links} + * are automatically redirected to the target of the link. + * A new {@code FileDescriptor} object is + * created to represent this file connection. *

* First, if there is a security manager, its {@code checkWrite} * method is called with the path represented by the {@code file} @@ -187,10 +196,14 @@ public class FileOutputStream extends OutputStream /** * Creates a file output stream to write to the file represented by - * the specified {@code File} object. If the second argument is - * {@code true}, then bytes will be written to the end of the file - * rather than the beginning. A new {@code FileDescriptor} object is - * created to represent this file connection. + * the specified {@code File} object. + * If the file exists, it is truncated unless the second + * argument is {@code true}, in which case bytes will be written to the + * end of the file rather than the beginning. If the file does not exist, + * it is created. {@linkplain java.nio.file##links Symbolic links} + * are automatically redirected to the target of the link. + * A new {@code FileDescriptor} object is created to represent this + * file connection. *

* First, if there is a security manager, its {@code checkWrite} * method is called with the path represented by the {@code file} diff --git a/src/java.base/share/classes/java/io/InputStream.java b/src/java.base/share/classes/java/io/InputStream.java index 736b6ebd904..a87870bfce0 100644 --- a/src/java.base/share/classes/java/io/InputStream.java +++ b/src/java.base/share/classes/java/io/InputStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1994, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1994, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,8 @@ package java.io; +import jdk.internal.util.ArraysSupport; + import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -305,12 +307,9 @@ public abstract class InputStream implements Closeable { } /** - * The maximum size of array to allocate. - * Some VMs reserve some header words in an array. - * Attempts to allocate larger arrays may result in - * OutOfMemoryError: Requested array size exceeds VM limit + * The maximum size of array to allocate */ - private static final int MAX_BUFFER_SIZE = Integer.MAX_VALUE - 8; + private static final int MAX_BUFFER_SIZE = ArraysSupport.SOFT_MAX_ARRAY_LENGTH; /** * Reads all remaining bytes from the input stream. This method blocks until diff --git a/src/java.base/share/classes/java/io/ObjectInputFilter.java b/src/java.base/share/classes/java/io/ObjectInputFilter.java index e40a2407206..879820761c1 100644 --- a/src/java.base/share/classes/java/io/ObjectInputFilter.java +++ b/src/java.base/share/classes/java/io/ObjectInputFilter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1218,8 +1218,7 @@ public interface ObjectInputFilter { } /** - * Returns the pattern used to create this filter. - * @return the pattern used to create this filter + * {@return the pattern used to create this filter} */ @Override public String toString() { diff --git a/src/java.base/share/classes/java/io/ObjectInputStream.java b/src/java.base/share/classes/java/io/ObjectInputStream.java index 74c34d80a7b..983b80d2bc6 100644 --- a/src/java.base/share/classes/java/io/ObjectInputStream.java +++ b/src/java.base/share/classes/java/io/ObjectInputStream.java @@ -3859,8 +3859,7 @@ public class ObjectInputStream } /** - * Returns the number of bytes read from the input stream. - * @return the number of bytes read from the input stream + * {@return the number of bytes read from the input stream} */ long getBytesRead() { return in.getBytesRead(); diff --git a/src/java.base/share/classes/java/io/ObjectOutputStream.java b/src/java.base/share/classes/java/io/ObjectOutputStream.java index 3650b101353..bde069a1774 100644 --- a/src/java.base/share/classes/java/io/ObjectOutputStream.java +++ b/src/java.base/share/classes/java/io/ObjectOutputStream.java @@ -1,5 +1,6 @@ /* * Copyright (c) 1996, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, Alibaba Group Holding Limited. 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 @@ -34,8 +35,13 @@ import java.util.Objects; import java.util.StringJoiner; import jdk.internal.util.ByteArray; +import jdk.internal.access.JavaLangAccess; +import jdk.internal.access.SharedSecrets; import sun.reflect.misc.ReflectUtil; +import static jdk.internal.util.ModifiedUtf.putChar; +import static jdk.internal.util.ModifiedUtf.utfLen; + /** * An ObjectOutputStream writes primitive data types and graphs of Java objects * to an OutputStream. The objects can be read (reconstituted) using an @@ -169,6 +175,7 @@ import sun.reflect.misc.ReflectUtil; public class ObjectOutputStream extends OutputStream implements ObjectOutput, ObjectStreamConstants { + private static final JavaLangAccess JLA = SharedSecrets.getJavaLangAccess(); private static class Caches { /** cache of subclass security audit results */ @@ -885,7 +892,7 @@ public class ObjectOutputStream * stream */ public void writeUTF(String str) throws IOException { - bout.writeUTF(str); + bout.writeUTFInternal(str, false); } /** @@ -1317,14 +1324,7 @@ public class ObjectOutputStream */ private void writeString(String str, boolean unshared) throws IOException { handles.assign(unshared ? null : str); - long utflen = bout.getUTFLength(str); - if (utflen <= 0xFFFF) { - bout.writeByte(TC_STRING); - bout.writeUTF(str, utflen); - } else { - bout.writeByte(TC_LONGSTRING); - bout.writeLongUTF(str, utflen); - } + bout.writeUTFInternal(str, true); } /** @@ -1994,26 +1994,27 @@ public class ObjectOutputStream } } - public void writeBytes(String s) throws IOException { - int endoff = s.length(); - int cpos = 0; - int csize = 0; - for (int off = 0; off < endoff; ) { - if (cpos >= csize) { - cpos = 0; - csize = Math.min(endoff - off, CHAR_BUF_SIZE); - s.getChars(off, off + csize, cbuf, 0); - } - if (pos >= MAX_BLOCK_SIZE) { + @SuppressWarnings("deprecation") + void writeBytes(String s, int len) throws IOException { + int pos = this.pos; + for (int strpos = 0; strpos < len;) { + int rem = MAX_BLOCK_SIZE - pos; + int csize = Math.min(len - strpos, rem); + s.getBytes(strpos, strpos + csize, buf, pos); + pos += csize; + strpos += csize; + + if (pos == MAX_BLOCK_SIZE) { + this.pos = pos; drain(); + pos = 0; } - int n = Math.min(csize - cpos, MAX_BLOCK_SIZE - pos); - int stop = pos + n; - while (pos < stop) { - buf[pos++] = (byte) cbuf[cpos++]; - } - off += n; } + this.pos = pos; + } + + public void writeBytes(String s) throws IOException { + writeBytes(s, s.length()); } public void writeChars(String s) throws IOException { @@ -2026,8 +2027,47 @@ public class ObjectOutputStream } } - public void writeUTF(String s) throws IOException { - writeUTF(s, getUTFLength(s)); + public void writeUTF(String str) throws IOException { + writeUTFInternal(str, false); + } + + private void writeUTFInternal(String str, boolean writeHeader) throws IOException { + int strlen = str.length(); + int countNonZeroAscii = JLA.countNonZeroAscii(str); + int utflen = utfLen(str, countNonZeroAscii); + if (utflen <= 0xFFFF) { + if(writeHeader) { + writeByte(TC_STRING); + } + writeShort(utflen); + } else { + if(writeHeader) { + writeByte(TC_LONGSTRING); + } + writeLong(utflen); + } + + if (countNonZeroAscii != 0) { + writeBytes(str, countNonZeroAscii); + } + if (countNonZeroAscii != strlen) { + writeMoreUTF(str, countNonZeroAscii); + } + } + + private void writeMoreUTF(String str, int stroff) throws IOException { + int pos = this.pos; + for (int strlen = str.length(); stroff < strlen;) { + char c = str.charAt(stroff++); + int csize = c != 0 && c < 0x80 ? 1 : c >= 0x800 ? 3 : 2; + if (pos + csize >= MAX_BLOCK_SIZE) { + this.pos = pos; + drain(); + pos = 0; + } + pos = putChar(buf, pos, c); + } + this.pos = pos; } @@ -2153,112 +2193,6 @@ public class ObjectOutputStream } } } - - /** - * Returns the length in bytes of the UTF encoding of the given string. - */ - long getUTFLength(String s) { - int len = s.length(); - long utflen = 0; - for (int off = 0; off < len; ) { - int csize = Math.min(len - off, CHAR_BUF_SIZE); - s.getChars(off, off + csize, cbuf, 0); - for (int cpos = 0; cpos < csize; cpos++) { - char c = cbuf[cpos]; - if (c >= 0x0001 && c <= 0x007F) { - utflen++; - } else if (c > 0x07FF) { - utflen += 3; - } else { - utflen += 2; - } - } - off += csize; - } - return utflen; - } - - /** - * Writes the given string in UTF format. This method is used in - * situations where the UTF encoding length of the string is already - * known; specifying it explicitly avoids a prescan of the string to - * determine its UTF length. - */ - void writeUTF(String s, long utflen) throws IOException { - if (utflen > 0xFFFFL) { - throw new UTFDataFormatException(); - } - writeShort((int) utflen); - if (utflen == (long) s.length()) { - writeBytes(s); - } else { - writeUTFBody(s); - } - } - - /** - * Writes given string in "long" UTF format. "Long" UTF format is - * identical to standard UTF, except that it uses an 8 byte header - * (instead of the standard 2 bytes) to convey the UTF encoding length. - */ - void writeLongUTF(String s) throws IOException { - writeLongUTF(s, getUTFLength(s)); - } - - /** - * Writes given string in "long" UTF format, where the UTF encoding - * length of the string is already known. - */ - void writeLongUTF(String s, long utflen) throws IOException { - writeLong(utflen); - if (utflen == (long) s.length()) { - writeBytes(s); - } else { - writeUTFBody(s); - } - } - - /** - * Writes the "body" (i.e., the UTF representation minus the 2-byte or - * 8-byte length header) of the UTF encoding for the given string. - */ - private void writeUTFBody(String s) throws IOException { - int limit = MAX_BLOCK_SIZE - 3; - int len = s.length(); - for (int off = 0; off < len; ) { - int csize = Math.min(len - off, CHAR_BUF_SIZE); - s.getChars(off, off + csize, cbuf, 0); - for (int cpos = 0; cpos < csize; cpos++) { - char c = cbuf[cpos]; - if (pos <= limit) { - if (c <= 0x007F && c != 0) { - buf[pos++] = (byte) c; - } else if (c > 0x07FF) { - buf[pos + 2] = (byte) (0x80 | ((c >> 0) & 0x3F)); - buf[pos + 1] = (byte) (0x80 | ((c >> 6) & 0x3F)); - buf[pos + 0] = (byte) (0xE0 | ((c >> 12) & 0x0F)); - pos += 3; - } else { - buf[pos + 1] = (byte) (0x80 | ((c >> 0) & 0x3F)); - buf[pos + 0] = (byte) (0xC0 | ((c >> 6) & 0x1F)); - pos += 2; - } - } else { // write one byte at a time to normalize block - if (c <= 0x007F && c != 0) { - write(c); - } else if (c > 0x07FF) { - write(0xE0 | ((c >> 12) & 0x0F)); - write(0x80 | ((c >> 6) & 0x3F)); - write(0x80 | ((c >> 0) & 0x3F)); - } else { - write(0xC0 | ((c >> 6) & 0x1F)); - write(0x80 | ((c >> 0) & 0x3F)); - } - } - } - off += csize; - } - } } /** diff --git a/src/java.base/share/classes/java/io/RandomAccessFile.java b/src/java.base/share/classes/java/io/RandomAccessFile.java index d0dde87bdca..cf8ae43dc21 100644 --- a/src/java.base/share/classes/java/io/RandomAccessFile.java +++ b/src/java.base/share/classes/java/io/RandomAccessFile.java @@ -101,8 +101,12 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable { /** * Creates a random access file stream to read from, and optionally - * to write to, a file with the specified pathname. A new - * {@link FileDescriptor} object is created to represent the + * to write to, a file with the specified pathname. If the file exists + * it is opened; if it does not exist and write mode is specified, a + * new file is created. + * {@linkplain java.nio.file##links Symbolic links} + * are automatically redirected to the target of the link. + * A new {@link FileDescriptor} object is created to represent the * connection to the file. * *

The {@code mode} argument specifies the access mode with which the @@ -146,9 +150,14 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable { } /** - * Creates a random access file stream to read from, and optionally to - * write to, the file specified by the {@link File} argument. A new {@link - * FileDescriptor} object is created to represent this file connection. + * Creates a random access file stream to read from, and optionally + * to write to, the file specified by the {@link File} argument. If + * the file exists it is opened; if it does not exist and write mode + * is specified, a new file is created. + * {@linkplain java.nio.file##links Symbolic links} + * are automatically redirected to the target of the link. + * A new {@link FileDescriptor} object is created to represent the + * connection to the file. * *

The {@code mode} argument specifies the access mode * in which the file is to be opened. The permitted values and their diff --git a/src/java.base/share/classes/java/lang/Boolean.java b/src/java.base/share/classes/java/lang/Boolean.java index ba88157dc92..2c0925a9790 100644 --- a/src/java.base/share/classes/java/lang/Boolean.java +++ b/src/java.base/share/classes/java/lang/Boolean.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1994, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1994, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,10 +37,10 @@ import static java.lang.constant.ConstantDescs.BSM_GET_STATIC_FINAL; import static java.lang.constant.ConstantDescs.CD_Boolean; /** - * The Boolean class wraps a value of the primitive type - * {@code boolean} in an object. An object of type - * {@code Boolean} contains a single field whose type is - * {@code boolean}. + * The {@code Boolean} class is the {@linkplain + * java.lang##wrapperClass wrapper class} for values of the primitive + * type {@code boolean}. An object of type {@code Boolean} contains a + * single field whose type is {@code boolean}. * *

In addition, this class provides many methods for * converting a {@code boolean} to a {@code String} and a diff --git a/src/java.base/share/classes/java/lang/Byte.java b/src/java.base/share/classes/java/lang/Byte.java index 18502abf69c..ade75a7a99e 100644 --- a/src/java.base/share/classes/java/lang/Byte.java +++ b/src/java.base/share/classes/java/lang/Byte.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,10 +39,10 @@ import static java.lang.constant.ConstantDescs.CD_int; import static java.lang.constant.ConstantDescs.DEFAULT_NAME; /** - * - * The {@code Byte} class wraps a value of primitive type {@code byte} - * in an object. An object of type {@code Byte} contains a single - * field whose type is {@code byte}. + * The {@code Byte} class is the {@linkplain + * java.lang##wrapperClass wrapper class} for values of the primitive + * type {@code byte}. An object of type {@code Byte} contains a + * single field whose type is {@code byte}. * *

In addition, this class provides several methods for converting * a {@code byte} to a {@code String} and a {@code String} to a {@code diff --git a/src/java.base/share/classes/java/lang/Character.java b/src/java.base/share/classes/java/lang/Character.java index a829d71e113..84db550d7cc 100644 --- a/src/java.base/share/classes/java/lang/Character.java +++ b/src/java.base/share/classes/java/lang/Character.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -43,12 +43,12 @@ import static java.lang.constant.ConstantDescs.CD_char; import static java.lang.constant.ConstantDescs.DEFAULT_NAME; /** - * The {@code Character} class wraps a value of the primitive - * type {@code char} in an object. An object of class - * {@code Character} contains a single field whose type is - * {@code char}. - *

- * In addition, this class provides a large number of static methods for + * The {@code Character} class is the {@linkplain + * java.lang##wrapperClass wrapper class} for values of the primitive + * type {@code char}. An object of type {@code Character} contains a + * single field whose type is {@code char}. + * + *

In addition, this class provides a large number of static methods for * determining a character's category (lowercase letter, digit, etc.) * and for converting characters from uppercase to lowercase and vice * versa. diff --git a/src/java.base/share/classes/java/lang/Class.java b/src/java.base/share/classes/java/lang/Class.java index e2ec0909f45..79cd57011b0 100644 --- a/src/java.base/share/classes/java/lang/Class.java +++ b/src/java.base/share/classes/java/lang/Class.java @@ -140,22 +140,24 @@ import sun.reflect.misc.ReflectUtil; * }} * * It is also possible to get the {@code Class} object for a named - * class or interface (or for {@code void}) using a class literal. + * class or interface (or for {@code void}) using a class literal + * (JLS {@jls 15.8.2}). * For example: * * {@snippet lang="java" : - * System.out.println("The name of class Foo is: "+Foo.class.getName()); + * System.out.println("The name of class Foo is: " + Foo.class.getName()); // @highlight substring="Foo.class" * } * *

Some methods of class {@code Class} expose whether the declaration of * a class or interface in Java source code was enclosed within * another declaration. Other methods describe how a class or interface - * is situated in a nest. A nest is a set of + * is situated in a {@index "nest"}. A nest is a set of * classes and interfaces, in the same run-time package, that * allow mutual access to their {@code private} members. - * The classes and interfaces are known as nestmates. + * The classes and interfaces are known as {@index "nestmates"} + * (JVMS {@jvms 4.7.29}). * One nestmate acts as the - * nest host, and enumerates the other nestmates which + * nest host (JVMS {@jvms 4.7.28}), and enumerates the other nestmates which * belong to the nest; each of them in turn records it as the nest host. * The classes and interfaces which belong to a nest, including its host, are * determined when @@ -167,7 +169,7 @@ import sun.reflect.misc.ReflectUtil; *

Hidden Classes

* A class or interface created by the invocation of * {@link java.lang.invoke.MethodHandles.Lookup#defineHiddenClass(byte[], boolean, MethodHandles.Lookup.ClassOption...) - * Lookup::defineHiddenClass} is a {@linkplain Class#isHidden() hidden} + * Lookup::defineHiddenClass} is a {@linkplain Class#isHidden() hidden} * class or interface. * All kinds of class, including enum classes and record classes, may be * hidden classes; all kinds of interface, including annotation interfaces, @@ -216,7 +218,6 @@ import sun.reflect.misc.ReflectUtil; * * @see java.lang.ClassLoader#defineClass(byte[], int, int) * @since 1.0 - * @jls 15.8.2 Class Literals */ public final class Class implements java.io.Serializable, GenericDeclaration, @@ -1247,7 +1248,7 @@ public final class Class implements java.io.Serializable, * @return the fully qualified package name * * @since 9 - * @jls 6.7 Fully Qualified Names + * @jls 6.7 Fully Qualified Names and Canonical Names */ public String getPackageName() { String pn = this.packageName; @@ -1460,7 +1461,7 @@ public final class Class implements java.io.Serializable, * programming language and JVM modeling in core reflection * @since 1.1 * @jls 8.1.1 Class Modifiers - * @jls 9.1.1. Interface Modifiers + * @jls 9.1.1 Interface Modifiers * @jvms 4.1 The {@code ClassFile} Structure */ @IntrinsicCandidate @@ -1994,7 +1995,7 @@ public final class Class implements java.io.Serializable, * * @return {@code true} if and only if this class is a local class. * @since 1.5 - * @jls 14.3 Local Class Declarations + * @jls 14.3 Local Class and Interface Declarations */ public boolean isLocalClass() { return isLocalOrAnonymousClass() && @@ -2007,7 +2008,7 @@ public final class Class implements java.io.Serializable, * * @return {@code true} if and only if this class is a member class. * @since 1.5 - * @jls 8.5 Member Type Declarations + * @jls 8.5 Member Class and Interface Declarations */ public boolean isMemberClass() { return !isLocalOrAnonymousClass() && getDeclaringClass0() != null; @@ -2544,7 +2545,7 @@ public final class Class implements java.io.Serializable, * * * @since 1.1 - * @jls 8.5 Member Type Declarations + * @jls 8.5 Member Class and Interface Declarations */ @CallerSensitive public Class[] getDeclaredClasses() throws SecurityException { @@ -4647,7 +4648,7 @@ public final class Class implements java.io.Serializable, return Wrapper.forPrimitiveType(this).basicTypeString(); if (isArray()) { - return "[" + componentType.descriptorString(); + return "[".concat(componentType.descriptorString()); } else if (isHidden()) { String name = getName(); int index = name.indexOf('/'); @@ -4660,11 +4661,7 @@ public final class Class implements java.io.Serializable, .toString(); } else { String name = getName().replace('.', '/'); - return new StringBuilder(name.length() + 2) - .append('L') - .append(name) - .append(';') - .toString(); + return StringConcatHelper.concat("L", name, ";"); } } diff --git a/src/java.base/share/classes/java/lang/ClassLoader.java b/src/java.base/share/classes/java/lang/ClassLoader.java index 5817c37d6f6..fafa8895ee6 100644 --- a/src/java.base/share/classes/java/lang/ClassLoader.java +++ b/src/java.base/share/classes/java/lang/ClassLoader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2019, Azul Systems, Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -223,7 +223,7 @@ import sun.security.util.SecurityConstants; * or a fully qualified name as defined by * The Java Language Specification. * - * @jls 6.7 Fully Qualified Names + * @jls 6.7 Fully Qualified Names and Canonical Names * @jls 13.1 The Form of a Binary * @see #resolveClass(Class) * @since 1.0 @@ -2450,7 +2450,8 @@ public abstract class ClassLoader { * @param javaName the native method's declared name */ static long findNative(ClassLoader loader, Class clazz, String entryName, String javaName) { - long addr = findNativeInternal(loader, entryName); + NativeLibraries nativeLibraries = nativeLibrariesFor(loader); + long addr = nativeLibraries.find(entryName); if (addr != 0 && loader != null) { Reflection.ensureNativeAccess(clazz, clazz, javaName, true); } @@ -2462,11 +2463,11 @@ public abstract class ClassLoader { * to avoid a restricted check, as that check has already been performed when * obtaining the lookup. */ - static long findNativeInternal(ClassLoader loader, String entryName) { + static NativeLibraries nativeLibrariesFor(ClassLoader loader) { if (loader == null) { - return BootLoader.getNativeLibraries().find(entryName); + return BootLoader.getNativeLibraries(); } else { - return loader.libraries.find(entryName); + return loader.libraries; } } diff --git a/src/java.base/share/classes/java/lang/Double.java b/src/java.base/share/classes/java/lang/Double.java index 5f4c0b3f40f..68fff6a2fbd 100644 --- a/src/java.base/share/classes/java/lang/Double.java +++ b/src/java.base/share/classes/java/lang/Double.java @@ -36,10 +36,10 @@ import jdk.internal.math.DoubleToDecimal; import jdk.internal.vm.annotation.IntrinsicCandidate; /** - * The {@code Double} class wraps a value of the primitive type - * {@code double} in an object. An object of type - * {@code Double} contains a single field whose type is - * {@code double}. + * The {@code Double} class is the {@linkplain + * java.lang##wrapperClass wrapper class} for values of the primitive + * type {@code double}. An object of type {@code Double} contains a + * single field whose type is {@code double}. * *

In addition, this class provides several methods for converting a * {@code double} to a {@code String} and a @@ -148,7 +148,7 @@ import jdk.internal.vm.annotation.IntrinsicCandidate; * relations that can be defined over floating-point values: * *

- *
numerical equality ({@code ==} + *
{@index "numerical equality"} ({@code ==} * operator): (Not an equivalence relation)
*
Two floating-point values represent the same extended real * number. The extended real numbers are the real numbers augmented @@ -158,7 +158,7 @@ import jdk.internal.vm.annotation.IntrinsicCandidate; * number and is not equal to any value, including itself. *
* - *
bit-wise equivalence:
+ *
{@index "bit-wise equivalence"}:
*
The bits of the two floating-point values are the same. This * equivalence relation for {@code double} values {@code a} and {@code * b} is implemented by the expression @@ -168,7 +168,7 @@ import jdk.internal.vm.annotation.IntrinsicCandidate; * is distinguished from every other bit pattern encoding a NaN. *
* - *
representation equivalence:
+ *
{@index "representation equivalence"}:
*
The two floating-point values represent the same IEEE 754 * datum. In particular, for {@linkplain #isFinite(double) * finite} values, the sign, {@linkplain Math#getExponent(double) @@ -344,8 +344,8 @@ import jdk.internal.vm.annotation.IntrinsicCandidate; * 754 floating-point arithmetic follows a principled design and its * behavior is predictable on the Java platform. * - * @jls 4.2.3 Floating-Point Types, Formats, and Values - * @jls 4.2.4. Floating-Point Operations + * @jls 4.2.3 Floating-Point Types and Values + * @jls 4.2.4 Floating-Point Operations * @jls 15.21.1 Numerical Equality Operators == and != * @jls 15.20.1 Numerical Comparison Operators {@code <}, {@code <=}, {@code >}, and {@code >=} * diff --git a/src/java.base/share/classes/java/lang/Float.java b/src/java.base/share/classes/java/lang/Float.java index 02b66007773..470eb71cf70 100644 --- a/src/java.base/share/classes/java/lang/Float.java +++ b/src/java.base/share/classes/java/lang/Float.java @@ -36,10 +36,10 @@ import jdk.internal.math.FloatToDecimal; import jdk.internal.vm.annotation.IntrinsicCandidate; /** - * The {@code Float} class wraps a value of primitive type - * {@code float} in an object. An object of type - * {@code Float} contains a single field whose type is - * {@code float}. + * The {@code Float} class is the {@linkplain + * java.lang##wrapperClass wrapper class} for values of the primitive + * type {@code float}. An object of type {@code Float} contains a + * single field whose type is {@code float}. * *

In addition, this class provides several methods for converting a * {@code float} to a {@code String} and a diff --git a/src/java.base/share/classes/java/lang/Integer.java b/src/java.base/share/classes/java/lang/Integer.java index 7a65046181f..eab0a942d9a 100644 --- a/src/java.base/share/classes/java/lang/Integer.java +++ b/src/java.base/share/classes/java/lang/Integer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1994, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1994, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -45,9 +45,10 @@ import static java.lang.String.LATIN1; import static java.lang.String.UTF16; /** - * The {@code Integer} class wraps a value of the primitive type - * {@code int} in an object. An object of type {@code Integer} - * contains a single field whose type is {@code int}. + * The {@code Integer} class is the {@linkplain + * java.lang##wrapperClass wrapper class} for values of the primitive + * type {@code int}. An object of type {@code Integer} contains a + * single field whose type is {@code int}. * *

In addition, this class provides several methods for converting * an {@code int} to a {@code String} and a {@code String} to an @@ -63,8 +64,9 @@ import static java.lang.String.UTF16; *

Implementation note: The implementations of the "bit twiddling" * methods (such as {@link #highestOneBit(int) highestOneBit} and * {@link #numberOfTrailingZeros(int) numberOfTrailingZeros}) are - * based on material from Henry S. Warren, Jr.'s Hacker's - * Delight, (Addison Wesley, 2002). + * based on material from Henry S. Warren, Jr.'s Hacker's + * Delight, (Addison Wesley, 2002) and Hacker's + * Delight, Second Edition, (Pearson Education, 2013). * * @author Lee Boynton * @author Arthur van Hoff @@ -1736,7 +1738,7 @@ public final class Integer extends Number * compress(expand(x, m), m) == x & compress(m, m) * } *

- * The Sheep And Goats (SAG) operation (see Hacker's Delight, section 7.7) + * The Sheep And Goats (SAG) operation (see Hacker's Delight, Second Edition, section 7.7) * can be implemented as follows: * {@snippet lang="java" : * int compressLeft(int i, int mask) { diff --git a/src/java.base/share/classes/java/lang/Long.java b/src/java.base/share/classes/java/lang/Long.java index ee9533b29eb..f86e1622b38 100644 --- a/src/java.base/share/classes/java/lang/Long.java +++ b/src/java.base/share/classes/java/lang/Long.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1994, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1994, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -45,8 +45,9 @@ import static java.lang.String.LATIN1; import static java.lang.String.UTF16; /** - * The {@code Long} class wraps a value of the primitive type {@code - * long} in an object. An object of type {@code Long} contains a + * The {@code Long} class is the {@linkplain + * java.lang##wrapperClass wrapper class} for values of the primitive + * type {@code long}. An object of type {@code Long} contains a * single field whose type is {@code long}. * *

In addition, this class provides several methods for converting @@ -63,8 +64,9 @@ import static java.lang.String.UTF16; *

Implementation note: The implementations of the "bit twiddling" * methods (such as {@link #highestOneBit(long) highestOneBit} and * {@link #numberOfTrailingZeros(long) numberOfTrailingZeros}) are - * based on material from Henry S. Warren, Jr.'s Hacker's - * Delight, (Addison Wesley, 2002). + * based on material from Henry S. Warren, Jr.'s Hacker's + * Delight, (Addison Wesley, 2002) and Hacker's + * Delight, Second Edition, (Pearson Education, 2013). * * @author Lee Boynton * @author Arthur van Hoff @@ -1749,7 +1751,7 @@ public final class Long extends Number * compress(expand(x, m), m) == x & compress(m, m) * } *

- * The Sheep And Goats (SAG) operation (see Hacker's Delight, section 7.7) + * The Sheep And Goats (SAG) operation (see Hacker's Delight, Second Edition, section 7.7) * can be implemented as follows: * {@snippet lang="java" : * long compressLeft(long i, long mask) { diff --git a/src/java.base/share/classes/java/lang/Math.java b/src/java.base/share/classes/java/lang/Math.java index 61b59784e0e..6b576c88b47 100644 --- a/src/java.base/share/classes/java/lang/Math.java +++ b/src/java.base/share/classes/java/lang/Math.java @@ -31,6 +31,8 @@ import jdk.internal.math.FloatConsts; import jdk.internal.math.DoubleConsts; import jdk.internal.vm.annotation.IntrinsicCandidate; +import static java.lang.Double.*; + /** * The class {@code Math} contains methods for performing basic * numeric operations such as the elementary exponential, logarithm, @@ -2735,6 +2737,7 @@ public final class Math { * @return The hyperbolic tangent of {@code x}. * @since 1.5 */ + @IntrinsicCandidate public static double tanh(double x) { return StrictMath.tanh(x); } @@ -3283,6 +3286,9 @@ public final class Math { } } + private static final double F_UP = 0x1p1023; // normal, exact, 2^DoubleConsts.EXP_BIAS + private static final double F_DOWN = 0x1p-1023; // subnormal, exact, 2^-DoubleConsts.EXP_BIAS + /** * Returns {@code d} × 2{@code scaleFactor} * rounded as if performed by a single correctly rounded @@ -3314,60 +3320,25 @@ public final class Math { * @since 1.6 */ public static double scalb(double d, int scaleFactor) { - /* - * When scaling up, it does not matter what order the - * multiply-store operations are done; the result will be - * finite or overflow regardless of the operation ordering. - * However, to get the correct result when scaling down, a - * particular ordering must be used. - * - * When scaling down, the multiply-store operations are - * sequenced so that it is not possible for two consecutive - * multiply-stores to return subnormal results. If one - * multiply-store result is subnormal, the next multiply will - * round it away to zero. This is done by first multiplying - * by 2 ^ (scaleFactor % n) and then multiplying several - * times by 2^n as needed where n is the exponent of number - * that is a convenient power of two. In this way, at most one - * real rounding error occurs. - */ - - // magnitude of a power of two so large that scaling a finite - // nonzero value by it would be guaranteed to over or - // underflow; due to rounding, scaling down takes an - // additional power of two which is reflected here - final int MAX_SCALE = Double.MAX_EXPONENT + -Double.MIN_EXPONENT + - DoubleConsts.SIGNIFICAND_WIDTH + 1; - int exp_adjust = 0; - int scale_increment = 0; - double exp_delta = Double.NaN; - - // Make sure scaling factor is in a reasonable range - - if(scaleFactor < 0) { - scaleFactor = Math.max(scaleFactor, -MAX_SCALE); - scale_increment = -512; - exp_delta = 0x1p-512; + if (scaleFactor > -DoubleConsts.EXP_BIAS) { + if (scaleFactor <= DoubleConsts.EXP_BIAS) { + return d * primPowerOfTwoD(scaleFactor); + } + if (scaleFactor <= 2 * DoubleConsts.EXP_BIAS) { + return d * primPowerOfTwoD(scaleFactor - DoubleConsts.EXP_BIAS) * F_UP; + } + if (scaleFactor < 2 * DoubleConsts.EXP_BIAS + PRECISION - 1) { + return d * primPowerOfTwoD(scaleFactor - 2 * DoubleConsts.EXP_BIAS) * F_UP * F_UP; + } + return d * F_UP * F_UP * F_UP; } - else { - scaleFactor = Math.min(scaleFactor, MAX_SCALE); - scale_increment = 512; - exp_delta = 0x1p512; + if (scaleFactor > -2 * DoubleConsts.EXP_BIAS) { + return d * primPowerOfTwoD(scaleFactor + DoubleConsts.EXP_BIAS) * F_DOWN; } - - // Calculate (scaleFactor % +/-512), 512 = 2^9, using - // technique from "Hacker's Delight" section 10-2. - int t = (scaleFactor >> 9-1) >>> 32 - 9; - exp_adjust = ((scaleFactor + t) & (512 -1)) - t; - - d *= powerOfTwoD(exp_adjust); - scaleFactor -= exp_adjust; - - while(scaleFactor != 0) { - d *= exp_delta; - scaleFactor -= scale_increment; + if (scaleFactor > -2 * DoubleConsts.EXP_BIAS - PRECISION) { + return d * primPowerOfTwoD(scaleFactor + 2 * DoubleConsts.EXP_BIAS) * F_DOWN * F_DOWN; } - return d; + return d * MIN_VALUE * MIN_VALUE; } /** @@ -3426,9 +3397,15 @@ public final class Math { */ static double powerOfTwoD(int n) { assert(n >= Double.MIN_EXPONENT && n <= Double.MAX_EXPONENT); - return Double.longBitsToDouble((((long)n + (long)DoubleConsts.EXP_BIAS) << - (DoubleConsts.SIGNIFICAND_WIDTH-1)) - & DoubleConsts.EXP_BIT_MASK); + return primPowerOfTwoD(n); + } + + /** + * Returns a floating-point power of two in the normal range. + * No checks are performed on the argument. + */ + private static double primPowerOfTwoD(int n) { + return longBitsToDouble((long) (n + DoubleConsts.EXP_BIAS) << PRECISION - 1); } /** diff --git a/src/java.base/share/classes/java/lang/Object.java b/src/java.base/share/classes/java/lang/Object.java index d9813df57a4..7909f053042 100644 --- a/src/java.base/share/classes/java/lang/Object.java +++ b/src/java.base/share/classes/java/lang/Object.java @@ -109,7 +109,7 @@ public class Object { /** * Indicates whether some other object is "equal to" this one. *

- * The {@code equals} method implements an equivalence relation + * The {@code equals} method implements an {@index "equivalence relation"} * on non-null object references: *

    *
  • It is reflexive: for any non-null reference value diff --git a/src/java.base/share/classes/java/lang/Record.java b/src/java.base/share/classes/java/lang/Record.java index dba72c6ebfb..808bc7cc9cd 100644 --- a/src/java.base/share/classes/java/lang/Record.java +++ b/src/java.base/share/classes/java/lang/Record.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -84,7 +84,7 @@ package java.lang; * See {@link Class#isRecord()} and {@link Class#getRecordComponents()} for more details. * * @spec serialization/index.html Java Object Serialization Specification - * @jls 8.10 Record Types + * @jls 8.10 Record Classes * @since 16 */ public abstract class Record { diff --git a/src/java.base/share/classes/java/lang/Short.java b/src/java.base/share/classes/java/lang/Short.java index 6a148d1edac..ec792de47e2 100644 --- a/src/java.base/share/classes/java/lang/Short.java +++ b/src/java.base/share/classes/java/lang/Short.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,8 +39,9 @@ import static java.lang.constant.ConstantDescs.CD_short; import static java.lang.constant.ConstantDescs.DEFAULT_NAME; /** - * The {@code Short} class wraps a value of primitive type {@code - * short} in an object. An object of type {@code Short} contains a + * The {@code Short} class is the {@linkplain + * java.lang##wrapperClass wrapper class} for values of the primitive + * type {@code short}. An object of type {@code Short} contains a * single field whose type is {@code short}. * *

    In addition, this class provides several methods for converting diff --git a/src/java.base/share/classes/java/lang/StackWalker.java b/src/java.base/share/classes/java/lang/StackWalker.java index aab9c6c28d8..8a39c465c2b 100644 --- a/src/java.base/share/classes/java/lang/StackWalker.java +++ b/src/java.base/share/classes/java/lang/StackWalker.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -170,7 +170,7 @@ public final class StackWalker { * * @see MethodType#fromMethodDescriptorString(String, ClassLoader) * @see MethodType#toMethodDescriptorString() - * @jvms 4.3.3 Method Descriptor + * @jvms 4.3.3 Method Descriptors * * @since 10 */ diff --git a/src/java.base/share/classes/java/lang/StringCoding.java b/src/java.base/share/classes/java/lang/StringCoding.java index 293fbdb78dc..c02af28c37d 100644 --- a/src/java.base/share/classes/java/lang/StringCoding.java +++ b/src/java.base/share/classes/java/lang/StringCoding.java @@ -1,5 +1,6 @@ /* - * Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, Alibaba Group Holding Limited. 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 @@ -34,6 +35,45 @@ class StringCoding { private StringCoding() { } + /** + * Count the number of leading non-zero ascii chars in the range. + */ + public static int countNonZeroAscii(String s) { + byte[] value = s.value(); + if (s.isLatin1()) { + return countNonZeroAsciiLatin1(value, 0, value.length); + } else { + return countNonZeroAsciiUTF16(value, 0, s.length()); + } + } + + /** + * Count the number of non-zero ascii chars in the range. + */ + public static int countNonZeroAsciiLatin1(byte[] ba, int off, int len) { + int limit = off + len; + for (int i = off; i < limit; i++) { + if (ba[i] <= 0) { + return i - off; + } + } + return len; + } + + /** + * Count the number of leading non-zero ascii chars in the range. + */ + public static int countNonZeroAsciiUTF16(byte[] ba, int off, int strlen) { + int limit = off + strlen; + for (int i = off; i < limit; i++) { + char c = StringUTF16.charAt(ba, i); + if (c == 0 || c > 0x7F) { + return i - off; + } + } + return strlen; + } + public static boolean hasNegatives(byte[] ba, int off, int len) { return countPositives(ba, off, len) != len; } diff --git a/src/java.base/share/classes/java/lang/StringConcatHelper.java b/src/java.base/share/classes/java/lang/StringConcatHelper.java index ae2b9693409..d0c558ed93a 100644 --- a/src/java.base/share/classes/java/lang/StringConcatHelper.java +++ b/src/java.base/share/classes/java/lang/StringConcatHelper.java @@ -783,4 +783,20 @@ final class StringConcatHelper { } throw new OutOfMemoryError("Overflow: String length out of range"); } + + @ForceInline + private static String concat0(String prefix, String str, String suffix) { + byte coder = (byte) (prefix.coder() | str.coder() | suffix.coder()); + int len = prefix.length() + str.length(); + byte[] buf = newArrayWithSuffix(suffix, len, coder); + prepend(len, coder, buf, str, prefix); + return new String(buf, coder); + } + + @ForceInline + static String concat(String prefix, Object value, String suffix) { + if (prefix == null) prefix = "null"; + if (suffix == null) suffix = "null"; + return concat0(prefix, stringOf(value), suffix); + } } diff --git a/src/java.base/share/classes/java/lang/System.java b/src/java.base/share/classes/java/lang/System.java index 503167bc2dd..930b6b7f611 100644 --- a/src/java.base/share/classes/java/lang/System.java +++ b/src/java.base/share/classes/java/lang/System.java @@ -65,11 +65,13 @@ import java.util.PropertyPermission; import java.util.ResourceBundle; import java.util.Set; import java.util.WeakHashMap; +import java.util.concurrent.Executor; import java.util.function.Supplier; import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Stream; import jdk.internal.javac.Restricted; +import jdk.internal.loader.NativeLibraries; import jdk.internal.logger.LoggerFinderLoader.TemporaryLoggerFinder; import jdk.internal.misc.Blocker; import jdk.internal.misc.CarrierThreadLocal; @@ -2569,6 +2571,9 @@ public final class System { public int countPositives(byte[] bytes, int offset, int length) { return StringCoding.countPositives(bytes, offset, length); } + public int countNonZeroAscii(String s) { + return StringCoding.countNonZeroAscii(s); + } public String newStringNoRepl(byte[] bytes, Charset cs) throws CharacterCodingException { return String.newStringNoRepl(bytes, cs); } @@ -2638,6 +2643,14 @@ public final class System { return new StringConcatHelper.Concat1(constants); } + public byte stringInitCoder() { + return String.COMPACT_STRINGS ? String.LATIN1 : String.UTF16; + } + + public byte stringCoder(String str) { + return str.coder(); + } + public int getCharsLatin1(long i, int index, byte[] buf) { return StringLatin1.getChars(i, index, buf); } @@ -2650,13 +2663,17 @@ public final class System { return String.join(prefix, suffix, delimiter, elements, size); } + public String concat(String prefix, Object value, String suffix) { + return StringConcatHelper.concat(prefix, value, suffix); + } + public Object classData(Class c) { return c.getClassData(); } @Override - public long findNative(ClassLoader loader, String entry) { - return ClassLoader.findNativeInternal(loader, entry); + public NativeLibraries nativeLibrariesFor(ClassLoader loader) { + return ClassLoader.nativeLibrariesFor(loader); } @Override @@ -2754,6 +2771,10 @@ public final class System { } } + public Executor virtualThreadDefaultScheduler() { + return VirtualThread.defaultScheduler(); + } + public StackWalker newStackWalkerInstance(Set options, ContinuationScope contScope, Continuation continuation) { diff --git a/src/java.base/share/classes/java/lang/Thread.java b/src/java.base/share/classes/java/lang/Thread.java index 4dac486bee4..07b3c7c9bd2 100644 --- a/src/java.base/share/classes/java/lang/Thread.java +++ b/src/java.base/share/classes/java/lang/Thread.java @@ -457,19 +457,20 @@ public class Thread implements Runnable { * Called before sleeping to create a jdk.ThreadSleep event. */ private static ThreadSleepEvent beforeSleep(long nanos) { - ThreadSleepEvent event = null; - if (ThreadSleepEvent.isTurnedOn()) { - try { - event = new ThreadSleepEvent(); + try { + ThreadSleepEvent event = new ThreadSleepEvent(); + if (event.isEnabled()) { event.time = nanos; event.begin(); - } catch (OutOfMemoryError e) { - event = null; + return event; } + } catch (OutOfMemoryError e) { + // ignore } - return event; + return null; } + /** * Called after sleeping to commit the jdk.ThreadSleep event. */ diff --git a/src/java.base/share/classes/java/lang/ThreadBuilders.java b/src/java.base/share/classes/java/lang/ThreadBuilders.java index ca29dc4f535..234807d4cc2 100644 --- a/src/java.base/share/classes/java/lang/ThreadBuilders.java +++ b/src/java.base/share/classes/java/lang/ThreadBuilders.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,6 +34,7 @@ import java.util.Objects; import java.util.concurrent.Executor; import java.util.concurrent.ThreadFactory; import jdk.internal.misc.Unsafe; +import jdk.internal.invoke.MhUtil; import jdk.internal.vm.ContinuationSupport; /** @@ -273,15 +274,9 @@ class ThreadBuilders { * Base ThreadFactory implementation. */ private abstract static class BaseThreadFactory implements ThreadFactory { - private static final VarHandle COUNT; - static { - try { - MethodHandles.Lookup l = MethodHandles.lookup(); - COUNT = l.findVarHandle(BaseThreadFactory.class, "count", long.class); - } catch (Exception e) { - throw new InternalError(e); - } - } + private static final VarHandle COUNT = MhUtil.findVarHandle( + MethodHandles.lookup(), "count", long.class); + private final String name; private final int characteristics; private final UncaughtExceptionHandler uhe; diff --git a/src/java.base/share/classes/java/lang/TypeNotPresentException.java b/src/java.base/share/classes/java/lang/TypeNotPresentException.java index fdf42548c03..c5a899ef285 100644 --- a/src/java.base/share/classes/java/lang/TypeNotPresentException.java +++ b/src/java.base/share/classes/java/lang/TypeNotPresentException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,9 +28,9 @@ package java.lang; /** * Thrown when an application tries to access a type using a string * representing the type's name, but no definition for the type with - * the specified name can be found. This exception differs from - * {@link ClassNotFoundException} in that {@code ClassNotFoundException} is a - * checked exception, whereas this exception is unchecked. + * the specified name can be found. This exception differs from + * {@link ClassNotFoundException} in that {@code ClassNotFoundException} + * is a checked exception, whereas this exception is unchecked. * *

    Note that this exception may be used when undefined type variables * are accessed as well as when types (e.g., classes, interfaces or @@ -48,15 +48,15 @@ public class TypeNotPresentException extends RuntimeException { private static final long serialVersionUID = -5101214195716534496L; /** - * The type name. + * The type name or the name of a type variable. */ private String typeName; /** - * Constructs a {@code TypeNotPresentException} for the named type - * with the specified cause. + * Constructs a {@code TypeNotPresentException} for the named type or + * type variable with the specified cause. * - * @param typeName the fully qualified name of the unavailable type + * @param typeName the fully qualified name of the unavailable type or type variable * @param cause the exception that was thrown when the system attempted to * load the named type, or {@code null} if unavailable or inapplicable */ @@ -66,9 +66,9 @@ public class TypeNotPresentException extends RuntimeException { } /** - * Returns the fully qualified name of the unavailable type. + * Returns the fully qualified name of the unavailable type or type variable name. * - * @return the fully qualified name of the unavailable type + * @return the fully qualified name of the unavailable type or type variable name */ public String typeName() { return typeName;} } diff --git a/src/java.base/share/classes/java/lang/VirtualThread.java b/src/java.base/share/classes/java/lang/VirtualThread.java index da05e77f12b..6eb20fa9e2e 100644 --- a/src/java.base/share/classes/java/lang/VirtualThread.java +++ b/src/java.base/share/classes/java/lang/VirtualThread.java @@ -142,6 +142,14 @@ final class VirtualThread extends BaseVirtualThread { // termination object when joining, created lazily if needed private volatile CountDownLatch termination; + + /** + * Returns the default scheduler. + */ + static Executor defaultScheduler() { + return DEFAULT_SCHEDULER; + } + /** * Returns the continuation scope used for virtual threads. */ diff --git a/src/java.base/share/classes/java/lang/annotation/Retention.java b/src/java.base/share/classes/java/lang/annotation/Retention.java index daf5f6e9b23..a8afc76ac79 100644 --- a/src/java.base/share/classes/java/lang/annotation/Retention.java +++ b/src/java.base/share/classes/java/lang/annotation/Retention.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -45,8 +45,7 @@ package java.lang.annotation; @Target(ElementType.ANNOTATION_TYPE) public @interface Retention { /** - * Returns the retention policy. - * @return the retention policy + * {@return the retention policy} */ RetentionPolicy value(); } diff --git a/src/java.base/share/classes/java/lang/classfile/Annotation.java b/src/java.base/share/classes/java/lang/classfile/Annotation.java index 357a7cb77ee..009248ffd78 100644 --- a/src/java.base/share/classes/java/lang/classfile/Annotation.java +++ b/src/java.base/share/classes/java/lang/classfile/Annotation.java @@ -34,6 +34,8 @@ import jdk.internal.classfile.impl.TemporaryConstantPool; import java.lang.constant.ClassDesc; import java.util.List; + +import jdk.internal.classfile.impl.Util; import jdk.internal.javac.PreviewFeature; /** @@ -78,7 +80,7 @@ public sealed interface Annotation * {@return the annotation interface, as a symbolic descriptor} */ default ClassDesc classSymbol() { - return ClassDesc.ofDescriptor(className().stringValue()); + return Util.fieldTypeSymbol(className()); } /** @@ -115,7 +117,7 @@ public sealed interface Annotation */ static Annotation of(ClassDesc annotationClass, List elements) { - return of(TemporaryConstantPool.INSTANCE.utf8Entry(annotationClass.descriptorString()), elements); + return of(TemporaryConstantPool.INSTANCE.utf8Entry(annotationClass), elements); } /** @@ -125,6 +127,6 @@ public sealed interface Annotation */ static Annotation of(ClassDesc annotationClass, AnnotationElement... elements) { - return of(TemporaryConstantPool.INSTANCE.utf8Entry(annotationClass.descriptorString()), elements); + return of(TemporaryConstantPool.INSTANCE.utf8Entry(annotationClass), elements); } } diff --git a/src/java.base/share/classes/java/lang/classfile/AnnotationValue.java b/src/java.base/share/classes/java/lang/classfile/AnnotationValue.java index 61314207755..fe768e93b13 100644 --- a/src/java.base/share/classes/java/lang/classfile/AnnotationValue.java +++ b/src/java.base/share/classes/java/lang/classfile/AnnotationValue.java @@ -38,8 +38,12 @@ import java.lang.constant.ClassDesc; import java.lang.constant.Constable; import java.util.ArrayList; import java.util.List; + +import jdk.internal.classfile.impl.Util; import jdk.internal.javac.PreviewFeature; +import static java.util.Objects.requireNonNull; + /** * Models an {@code element_value} structure, or a value of an element-value * pair of an annotation, as defined in JVMS {@jvms 4.7.16.1}. @@ -58,7 +62,7 @@ public sealed interface AnnotationValue { /** * Models an annotation value of an element-value pair. - * The {@linkplain #tag tag} of this value is {@value ClassFile#AEV_ANNOTATION}. + * The {@linkplain #tag tag} of this value is {@value TAG_ANNOTATION}. * * @since 22 */ @@ -71,7 +75,7 @@ public sealed interface AnnotationValue { /** * Models an array value of an element-value pair. - * The {@linkplain #tag tag} of this value is {@value ClassFile#AEV_ARRAY}. + * The {@linkplain #tag tag} of this value is {@value TAG_ARRAY}. * * @since 22 */ @@ -129,7 +133,7 @@ public sealed interface AnnotationValue { /** * Models a string value of an element-value pair. - * The {@linkplain #tag tag} of this value is {@value ClassFile#AEV_STRING}. + * The {@linkplain #tag tag} of this value is {@value TAG_STRING}. * * @since 22 */ @@ -157,7 +161,7 @@ public sealed interface AnnotationValue { /** * Models a double value of an element-value pair. - * The {@linkplain #tag tag} of this value is {@value ClassFile#AEV_DOUBLE}. + * The {@linkplain #tag tag} of this value is {@value TAG_DOUBLE}. * * @since 22 */ @@ -185,7 +189,7 @@ public sealed interface AnnotationValue { /** * Models a float value of an element-value pair. - * The {@linkplain #tag tag} of this value is {@value ClassFile#AEV_FLOAT}. + * The {@linkplain #tag tag} of this value is {@value TAG_FLOAT}. * * @since 22 */ @@ -213,7 +217,7 @@ public sealed interface AnnotationValue { /** * Models a long value of an element-value pair. - * The {@linkplain #tag tag} of this value is {@value ClassFile#AEV_LONG}. + * The {@linkplain #tag tag} of this value is {@value TAG_LONG}. * * @since 22 */ @@ -241,7 +245,7 @@ public sealed interface AnnotationValue { /** * Models an int value of an element-value pair. - * The {@linkplain #tag tag} of this value is {@value ClassFile#AEV_INT}. + * The {@linkplain #tag tag} of this value is {@value TAG_INT}. * * @since 22 */ @@ -269,7 +273,7 @@ public sealed interface AnnotationValue { /** * Models a short value of an element-value pair. - * The {@linkplain #tag tag} of this value is {@value ClassFile#AEV_SHORT}. + * The {@linkplain #tag tag} of this value is {@value TAG_SHORT}. * * @since 22 */ @@ -300,7 +304,7 @@ public sealed interface AnnotationValue { /** * Models a char value of an element-value pair. - * The {@linkplain #tag tag} of this value is {@value ClassFile#AEV_CHAR}. + * The {@linkplain #tag tag} of this value is {@value TAG_CHAR}. * * @since 22 */ @@ -331,7 +335,7 @@ public sealed interface AnnotationValue { /** * Models a byte value of an element-value pair. - * The {@linkplain #tag tag} of this value is {@value ClassFile#AEV_BYTE}. + * The {@linkplain #tag tag} of this value is {@value TAG_BYTE}. * * @since 22 */ @@ -362,7 +366,7 @@ public sealed interface AnnotationValue { /** * Models a boolean value of an element-value pair. - * The {@linkplain #tag tag} of this value is {@value ClassFile#AEV_BOOLEAN}. + * The {@linkplain #tag tag} of this value is {@value TAG_BOOLEAN}. * * @since 22 */ @@ -393,7 +397,7 @@ public sealed interface AnnotationValue { /** * Models a class value of an element-value pair. - * The {@linkplain #tag tag} of this value is {@value ClassFile#AEV_CLASS}. + * The {@linkplain #tag tag} of this value is {@value TAG_CLASS}. * * @since 22 */ @@ -405,13 +409,13 @@ public sealed interface AnnotationValue { /** {@return the class descriptor} */ default ClassDesc classSymbol() { - return ClassDesc.ofDescriptor(className().stringValue()); + return Util.fieldTypeSymbol(className()); } } /** * Models an enum value of an element-value pair. - * The {@linkplain #tag tag} of this value is {@value ClassFile#AEV_ENUM}. + * The {@linkplain #tag tag} of this value is {@value TAG_ENUM}. * * @since 22 */ @@ -423,16 +427,59 @@ public sealed interface AnnotationValue { /** {@return the enum class descriptor} */ default ClassDesc classSymbol() { - return ClassDesc.ofDescriptor(className().stringValue()); + return Util.fieldTypeSymbol(className()); } /** {@return the enum constant name} */ Utf8Entry constantName(); } + /** The {@link #tag() tag} indicating the value of an element-value pair is {@link OfByte}. */ + int TAG_BYTE = 'B'; + + /** The {@link #tag() tag} indicating the value of an element-value pair is {@link OfChar}. */ + int TAG_CHAR = 'C'; + + /** The {@link #tag() tag} indicating the value of an element-value pair is {@link OfDouble}. */ + int TAG_DOUBLE = 'D'; + + /** The {@link #tag() tag} indicating the value of an element-value pair is {@link OfFloat}. */ + int TAG_FLOAT = 'F'; + + /** The {@link #tag() tag} indicating the value of an element-value pair is {@link OfInt}. */ + int TAG_INT = 'I'; + + /** The {@link #tag() tag} indicating the value of an element-value pair is {@link OfLong}. */ + int TAG_LONG = 'J'; + + /** The {@link #tag() tag} indicating the value of an element-value pair is {@link OfShort}. */ + int TAG_SHORT = 'S'; + + /** The {@link #tag() tag} indicating the value of an element-value pair is {@link OfBoolean}. */ + int TAG_BOOLEAN = 'Z'; + + /** The {@link #tag() tag} indicating the value of an element-value pair is {@link OfString}. */ + int TAG_STRING = 's'; + + /** The {@link #tag() tag} indicating the value of an element-value pair is {@link OfEnum}. */ + int TAG_ENUM = 'e'; + + /** The {@link #tag() tag} indicating the value of an element-value pair is {@link OfClass}. */ + int TAG_CLASS = 'c'; + + /** The {@link #tag() tag} indicating the value of an element-value pair is {@link OfAnnotation}. */ + int TAG_ANNOTATION = '@'; + + /** The {@link #tag() tag} indicating the value of an element-value pair is {@link OfArray}. */ + int TAG_ARRAY = '['; + /** * {@return the tag character for this value as per JVMS {@jvms 4.7.16.1}} * The tag characters have a one-to-one mapping to the types of annotation element values. + * + * @apiNote + * {@code TAG_}-prefixed constants in this class, such as {@link #TAG_INT}, + * describe the possible return values of this method. */ char tag(); @@ -443,6 +490,8 @@ public sealed interface AnnotationValue { */ static OfEnum ofEnum(Utf8Entry className, Utf8Entry constantName) { + requireNonNull(className); + requireNonNull(constantName); return new AnnotationImpl.OfEnumImpl(className, constantName); } @@ -452,7 +501,7 @@ public sealed interface AnnotationValue { * @param constantName the name of the enum constant */ static OfEnum ofEnum(ClassDesc className, String constantName) { - return ofEnum(TemporaryConstantPool.INSTANCE.utf8Entry(className.descriptorString()), + return ofEnum(TemporaryConstantPool.INSTANCE.utf8Entry(className), TemporaryConstantPool.INSTANCE.utf8Entry(constantName)); } @@ -461,6 +510,7 @@ public sealed interface AnnotationValue { * @param className the descriptor string of the class */ static OfClass ofClass(Utf8Entry className) { + requireNonNull(className); return new AnnotationImpl.OfClassImpl(className); } @@ -469,7 +519,7 @@ public sealed interface AnnotationValue { * @param className the descriptor of the class */ static OfClass ofClass(ClassDesc className) { - return ofClass(TemporaryConstantPool.INSTANCE.utf8Entry(className.descriptorString())); + return ofClass(TemporaryConstantPool.INSTANCE.utf8Entry(className)); } /** @@ -477,6 +527,7 @@ public sealed interface AnnotationValue { * @param value the string */ static OfString ofString(Utf8Entry value) { + requireNonNull(value); return new AnnotationImpl.OfStringImpl(value); } @@ -493,6 +544,7 @@ public sealed interface AnnotationValue { * @param value the double value */ static OfDouble ofDouble(DoubleEntry value) { + requireNonNull(value); return new AnnotationImpl.OfDoubleImpl(value); } @@ -509,6 +561,7 @@ public sealed interface AnnotationValue { * @param value the float value */ static OfFloat ofFloat(FloatEntry value) { + requireNonNull(value); return new AnnotationImpl.OfFloatImpl(value); } @@ -525,6 +578,7 @@ public sealed interface AnnotationValue { * @param value the long value */ static OfLong ofLong(LongEntry value) { + requireNonNull(value); return new AnnotationImpl.OfLongImpl(value); } @@ -541,6 +595,7 @@ public sealed interface AnnotationValue { * @param value the int value */ static OfInt ofInt(IntegerEntry value) { + requireNonNull(value); return new AnnotationImpl.OfIntImpl(value); } @@ -557,6 +612,7 @@ public sealed interface AnnotationValue { * @param value the short value */ static OfShort ofShort(IntegerEntry value) { + requireNonNull(value); return new AnnotationImpl.OfShortImpl(value); } @@ -573,6 +629,7 @@ public sealed interface AnnotationValue { * @param value the char value */ static OfChar ofChar(IntegerEntry value) { + requireNonNull(value); return new AnnotationImpl.OfCharImpl(value); } @@ -589,6 +646,7 @@ public sealed interface AnnotationValue { * @param value the byte value */ static OfByte ofByte(IntegerEntry value) { + requireNonNull(value); return new AnnotationImpl.OfByteImpl(value); } @@ -605,6 +663,7 @@ public sealed interface AnnotationValue { * @param value the boolean value */ static OfBoolean ofBoolean(IntegerEntry value) { + requireNonNull(value); return new AnnotationImpl.OfBooleanImpl(value); } @@ -622,6 +681,7 @@ public sealed interface AnnotationValue { * @param value the annotation */ static OfAnnotation ofAnnotation(Annotation value) { + requireNonNull(value); return new AnnotationImpl.OfAnnotationImpl(value); } @@ -739,6 +799,6 @@ public sealed interface AnnotationValue { } else if (value instanceof Enum e) { return ofEnum(ClassDesc.ofDescriptor(e.getDeclaringClass().descriptorString()), e.name()); } - throw new IllegalArgumentException("Illegal annotation constant value type " + (value == null ? null : value.getClass())); + throw new IllegalArgumentException("Illegal annotation constant value type " + requireNonNull(value).getClass()); } } diff --git a/src/java.base/share/classes/java/lang/classfile/AttributedElement.java b/src/java.base/share/classes/java/lang/classfile/AttributedElement.java index d66806ca93b..0caf231ec2a 100644 --- a/src/java.base/share/classes/java/lang/classfile/AttributedElement.java +++ b/src/java.base/share/classes/java/lang/classfile/AttributedElement.java @@ -33,6 +33,8 @@ import java.lang.classfile.attribute.RecordComponentInfo; import jdk.internal.classfile.impl.AbstractUnboundModel; import jdk.internal.javac.PreviewFeature; +import static java.util.Objects.requireNonNull; + /** * A {@link ClassFileElement} describing an entity that has attributes, such * as a class, field, method, code attribute, or record component. @@ -58,6 +60,7 @@ public sealed interface AttributedElement extends ClassFileElement * is not present */ default > Optional findAttribute(AttributeMapper attr) { + requireNonNull(attr); for (Attribute la : attributes()) { if (la.attributeMapper() == attr) { @SuppressWarnings("unchecked") @@ -76,6 +79,7 @@ public sealed interface AttributedElement extends ClassFileElement * is not present */ default > List findAttributes(AttributeMapper attr) { + requireNonNull(attr); var list = new ArrayList(); for (var a : attributes()) { if (a.attributeMapper() == attr) { diff --git a/src/java.base/share/classes/java/lang/classfile/ClassBuilder.java b/src/java.base/share/classes/java/lang/classfile/ClassBuilder.java index 1d5bb271dbe..905c7355c34 100644 --- a/src/java.base/share/classes/java/lang/classfile/ClassBuilder.java +++ b/src/java.base/share/classes/java/lang/classfile/ClassBuilder.java @@ -194,7 +194,9 @@ public sealed interface ClassBuilder default ClassBuilder withField(String name, ClassDesc descriptor, int flags) { - return withField(name, descriptor, Util.buildingFlags(flags)); + return withField(constantPool().utf8Entry(name), + constantPool().utf8Entry(descriptor), + flags); } /** diff --git a/src/java.base/share/classes/java/lang/classfile/ClassFile.java b/src/java.base/share/classes/java/lang/classfile/ClassFile.java index 08745f7e1ba..284503ee627 100644 --- a/src/java.base/share/classes/java/lang/classfile/ClassFile.java +++ b/src/java.base/share/classes/java/lang/classfile/ClassFile.java @@ -295,7 +295,7 @@ public sealed interface ClassFile DROP_UNKNOWN_ATTRIBUTES, /** Drop unknown and unstable original attributes during transformation */ - DROP_UNSTABLE_ATRIBUTES; + DROP_UNSTABLE_ATTRIBUTES } /** @@ -512,903 +512,75 @@ public sealed interface ClassFile /** 0xCAFEBABE */ int MAGIC_NUMBER = 0xCAFEBABE; - /** The integer value used to encode the NOP instruction. */ - int NOP = 0; - - /** The integer value used to encode the ACONST_NULL instruction. */ - int ACONST_NULL = 1; - - /** The integer value used to encode the ICONST_M1 instruction. */ - int ICONST_M1 = 2; - - /** The integer value used to encode the ICONST_0 instruction. */ - int ICONST_0 = 3; - - /** The integer value used to encode the ICONST_1 instruction. */ - int ICONST_1 = 4; - - /** The integer value used to encode the ICONST_2 instruction. */ - int ICONST_2 = 5; - - /** The integer value used to encode the ICONST_3 instruction. */ - int ICONST_3 = 6; - - /** The integer value used to encode the ICONST_4 instruction. */ - int ICONST_4 = 7; - - /** The integer value used to encode the ICONST_5 instruction. */ - int ICONST_5 = 8; - - /** The integer value used to encode the LCONST_0 instruction. */ - int LCONST_0 = 9; - - /** The integer value used to encode the LCONST_1 instruction. */ - int LCONST_1 = 10; - - /** The integer value used to encode the FCONST_0 instruction. */ - int FCONST_0 = 11; - - /** The integer value used to encode the FCONST_1 instruction. */ - int FCONST_1 = 12; - - /** The integer value used to encode the FCONST_2 instruction. */ - int FCONST_2 = 13; - - /** The integer value used to encode the DCONST_0 instruction. */ - int DCONST_0 = 14; - - /** The integer value used to encode the DCONST_1 instruction. */ - int DCONST_1 = 15; - - /** The integer value used to encode the BIPUSH instruction. */ - int BIPUSH = 16; - - /** The integer value used to encode the SIPUSH instruction. */ - int SIPUSH = 17; - - /** The integer value used to encode the LDC instruction. */ - int LDC = 18; - - /** The integer value used to encode the LDC_W instruction. */ - int LDC_W = 19; - - /** The integer value used to encode the LDC2_W instruction. */ - int LDC2_W = 20; - - /** The integer value used to encode the ILOAD instruction. */ - int ILOAD = 21; - - /** The integer value used to encode the LLOAD instruction. */ - int LLOAD = 22; - - /** The integer value used to encode the FLOAD instruction. */ - int FLOAD = 23; - - /** The integer value used to encode the DLOAD instruction. */ - int DLOAD = 24; - - /** The integer value used to encode the ALOAD instruction. */ - int ALOAD = 25; - - /** The integer value used to encode the ILOAD_0 instruction. */ - int ILOAD_0 = 26; - - /** The integer value used to encode the ILOAD_1 instruction. */ - int ILOAD_1 = 27; - - /** The integer value used to encode the ILOAD_2 instruction. */ - int ILOAD_2 = 28; - - /** The integer value used to encode the ILOAD_3 instruction. */ - int ILOAD_3 = 29; - - /** The integer value used to encode the LLOAD_0 instruction. */ - int LLOAD_0 = 30; - - /** The integer value used to encode the LLOAD_1 instruction. */ - int LLOAD_1 = 31; - - /** The integer value used to encode the LLOAD_2 instruction. */ - int LLOAD_2 = 32; - - /** The integer value used to encode the LLOAD_3 instruction. */ - int LLOAD_3 = 33; - - /** The integer value used to encode the FLOAD_0 instruction. */ - int FLOAD_0 = 34; - - /** The integer value used to encode the FLOAD_1 instruction. */ - int FLOAD_1 = 35; - - /** The integer value used to encode the FLOAD_2 instruction. */ - int FLOAD_2 = 36; - - /** The integer value used to encode the FLOAD_3 instruction. */ - int FLOAD_3 = 37; - - /** The integer value used to encode the DLOAD_0 instruction. */ - int DLOAD_0 = 38; - - /** The integer value used to encode the DLOAD_1 instruction. */ - int DLOAD_1 = 39; - - /** The integer value used to encode the DLOAD_2 instruction. */ - int DLOAD_2 = 40; - - /** The integer value used to encode the DLOAD_3 instruction. */ - int DLOAD_3 = 41; - - /** The integer value used to encode the ALOAD_0 instruction. */ - int ALOAD_0 = 42; - - /** The integer value used to encode the ALOAD_1 instruction. */ - int ALOAD_1 = 43; - - /** The integer value used to encode the ALOAD_2 instruction. */ - int ALOAD_2 = 44; - - /** The integer value used to encode the ALOAD_3 instruction. */ - int ALOAD_3 = 45; - - /** The integer value used to encode the IALOAD instruction. */ - int IALOAD = 46; - - /** The integer value used to encode the LALOAD instruction. */ - int LALOAD = 47; - - /** The integer value used to encode the FALOAD instruction. */ - int FALOAD = 48; - - /** The integer value used to encode the DALOAD instruction. */ - int DALOAD = 49; - - /** The integer value used to encode the AALOAD instruction. */ - int AALOAD = 50; - - /** The integer value used to encode the BALOAD instruction. */ - int BALOAD = 51; - - /** The integer value used to encode the CALOAD instruction. */ - int CALOAD = 52; - - /** The integer value used to encode the SALOAD instruction. */ - int SALOAD = 53; - - /** The integer value used to encode the ISTORE instruction. */ - int ISTORE = 54; - - /** The integer value used to encode the LSTORE instruction. */ - int LSTORE = 55; - - /** The integer value used to encode the FSTORE instruction. */ - int FSTORE = 56; - - /** The integer value used to encode the DSTORE instruction. */ - int DSTORE = 57; - - /** The integer value used to encode the ASTORE instruction. */ - int ASTORE = 58; - - /** The integer value used to encode the ISTORE_0 instruction. */ - int ISTORE_0 = 59; - - /** The integer value used to encode the ISTORE_1 instruction. */ - int ISTORE_1 = 60; - - /** The integer value used to encode the ISTORE_2 instruction. */ - int ISTORE_2 = 61; - - /** The integer value used to encode the ISTORE_3 instruction. */ - int ISTORE_3 = 62; - - /** The integer value used to encode the LSTORE_0 instruction. */ - int LSTORE_0 = 63; - - /** The integer value used to encode the LSTORE_1 instruction. */ - int LSTORE_1 = 64; - - /** The integer value used to encode the LSTORE_2 instruction. */ - int LSTORE_2 = 65; - - /** The integer value used to encode the LSTORE_3 instruction. */ - int LSTORE_3 = 66; - - /** The integer value used to encode the FSTORE_0 instruction. */ - int FSTORE_0 = 67; - - /** The integer value used to encode the FSTORE_1 instruction. */ - int FSTORE_1 = 68; - - /** The integer value used to encode the FSTORE_2 instruction. */ - int FSTORE_2 = 69; - - /** The integer value used to encode the FSTORE_3 instruction. */ - int FSTORE_3 = 70; - - /** The integer value used to encode the DSTORE_0 instruction. */ - int DSTORE_0 = 71; - - /** The integer value used to encode the DSTORE_1 instruction. */ - int DSTORE_1 = 72; - - /** The integer value used to encode the DSTORE_2 instruction. */ - int DSTORE_2 = 73; - - /** The integer value used to encode the DSTORE_3 instruction. */ - int DSTORE_3 = 74; - - /** The integer value used to encode the ASTORE_0 instruction. */ - int ASTORE_0 = 75; - - /** The integer value used to encode the ASTORE_1 instruction. */ - int ASTORE_1 = 76; - - /** The integer value used to encode the ASTORE_2 instruction. */ - int ASTORE_2 = 77; - - /** The integer value used to encode the ASTORE_3 instruction. */ - int ASTORE_3 = 78; - - /** The integer value used to encode the IASTORE instruction. */ - int IASTORE = 79; - - /** The integer value used to encode the LASTORE instruction. */ - int LASTORE = 80; - - /** The integer value used to encode the FASTORE instruction. */ - int FASTORE = 81; - - /** The integer value used to encode the DASTORE instruction. */ - int DASTORE = 82; - - /** The integer value used to encode the AASTORE instruction. */ - int AASTORE = 83; - - /** The integer value used to encode the BASTORE instruction. */ - int BASTORE = 84; - - /** The integer value used to encode the CASTORE instruction. */ - int CASTORE = 85; - - /** The integer value used to encode the SASTORE instruction. */ - int SASTORE = 86; - - /** The integer value used to encode the POP instruction. */ - int POP = 87; - - /** The integer value used to encode the POP2 instruction. */ - int POP2 = 88; - - /** The integer value used to encode the DUP instruction. */ - int DUP = 89; - - /** The integer value used to encode the DUP_X1 instruction. */ - int DUP_X1 = 90; - - /** The integer value used to encode the DUP_X2 instruction. */ - int DUP_X2 = 91; - - /** The integer value used to encode the DUP2 instruction. */ - int DUP2 = 92; - - /** The integer value used to encode the DUP2_X1 instruction. */ - int DUP2_X1 = 93; - - /** The integer value used to encode the DUP2_X2 instruction. */ - int DUP2_X2 = 94; - - /** The integer value used to encode the SWAP instruction. */ - int SWAP = 95; - - /** The integer value used to encode the IADD instruction. */ - int IADD = 96; - - /** The integer value used to encode the LADD instruction. */ - int LADD = 97; - - /** The integer value used to encode the FADD instruction. */ - int FADD = 98; - - /** The integer value used to encode the DADD instruction. */ - int DADD = 99; - - /** The integer value used to encode the ISUB instruction. */ - int ISUB = 100; - - /** The integer value used to encode the LSUB instruction. */ - int LSUB = 101; - - /** The integer value used to encode the FSUB instruction. */ - int FSUB = 102; - - /** The integer value used to encode the DSUB instruction. */ - int DSUB = 103; - - /** The integer value used to encode the IMUL instruction. */ - int IMUL = 104; - - /** The integer value used to encode the LMUL instruction. */ - int LMUL = 105; - - /** The integer value used to encode the FMUL instruction. */ - int FMUL = 106; - - /** The integer value used to encode the DMUL instruction. */ - int DMUL = 107; - - /** The integer value used to encode the IDIV instruction. */ - int IDIV = 108; - - /** The integer value used to encode the LDIV instruction. */ - int LDIV = 109; - - /** The integer value used to encode the FDIV instruction. */ - int FDIV = 110; - - /** The integer value used to encode the DDIV instruction. */ - int DDIV = 111; - - /** The integer value used to encode the IREM instruction. */ - int IREM = 112; - - /** The integer value used to encode the LREM instruction. */ - int LREM = 113; - - /** The integer value used to encode the FREM instruction. */ - int FREM = 114; - - /** The integer value used to encode the DREM instruction. */ - int DREM = 115; - - /** The integer value used to encode the INEG instruction. */ - int INEG = 116; - - /** The integer value used to encode the LNEG instruction. */ - int LNEG = 117; - - /** The integer value used to encode the FNEG instruction. */ - int FNEG = 118; - - /** The integer value used to encode the DNEG instruction. */ - int DNEG = 119; - - /** The integer value used to encode the ISHL instruction. */ - int ISHL = 120; - - /** The integer value used to encode the LSHL instruction. */ - int LSHL = 121; - - /** The integer value used to encode the ISHR instruction. */ - int ISHR = 122; - - /** The integer value used to encode the LSHR instruction. */ - int LSHR = 123; - - /** The integer value used to encode the IUSHR instruction. */ - int IUSHR = 124; - - /** The integer value used to encode the LUSHR instruction. */ - int LUSHR = 125; - - /** The integer value used to encode the IAND instruction. */ - int IAND = 126; - - /** The integer value used to encode the LAND instruction. */ - int LAND = 127; - - /** The integer value used to encode the IOR instruction. */ - int IOR = 128; - - /** The integer value used to encode the LOR instruction. */ - int LOR = 129; - - /** The integer value used to encode the IXOR instruction. */ - int IXOR = 130; - - /** The integer value used to encode the LXOR instruction. */ - int LXOR = 131; - - /** The integer value used to encode the IINC instruction. */ - int IINC = 132; - - /** The integer value used to encode the I2L instruction. */ - int I2L = 133; - - /** The integer value used to encode the I2F instruction. */ - int I2F = 134; - - /** The integer value used to encode the I2D instruction. */ - int I2D = 135; - - /** The integer value used to encode the L2I instruction. */ - int L2I = 136; - - /** The integer value used to encode the L2F instruction. */ - int L2F = 137; - - /** The integer value used to encode the L2D instruction. */ - int L2D = 138; - - /** The integer value used to encode the F2I instruction. */ - int F2I = 139; - - /** The integer value used to encode the F2L instruction. */ - int F2L = 140; - - /** The integer value used to encode the F2D instruction. */ - int F2D = 141; - - /** The integer value used to encode the D2I instruction. */ - int D2I = 142; - - /** The integer value used to encode the D2L instruction. */ - int D2L = 143; - - /** The integer value used to encode the D2F instruction. */ - int D2F = 144; - - /** The integer value used to encode the I2B instruction. */ - int I2B = 145; - - /** The integer value used to encode the I2C instruction. */ - int I2C = 146; - - /** The integer value used to encode the I2S instruction. */ - int I2S = 147; - - /** The integer value used to encode the LCMP instruction. */ - int LCMP = 148; - - /** The integer value used to encode the FCMPL instruction. */ - int FCMPL = 149; - - /** The integer value used to encode the FCMPG instruction. */ - int FCMPG = 150; - - /** The integer value used to encode the DCMPL instruction. */ - int DCMPL = 151; - - /** The integer value used to encode the DCMPG instruction. */ - int DCMPG = 152; - - /** The integer value used to encode the IFEQ instruction. */ - int IFEQ = 153; - - /** The integer value used to encode the IFNE instruction. */ - int IFNE = 154; - - /** The integer value used to encode the IFLT instruction. */ - int IFLT = 155; - - /** The integer value used to encode the IFGE instruction. */ - int IFGE = 156; - - /** The integer value used to encode the IFGT instruction. */ - int IFGT = 157; - - /** The integer value used to encode the IFLE instruction. */ - int IFLE = 158; - - /** The integer value used to encode the IF_ICMPEQ instruction. */ - int IF_ICMPEQ = 159; - - /** The integer value used to encode the IF_ICMPNE instruction. */ - int IF_ICMPNE = 160; - - /** The integer value used to encode the IF_ICMPLT instruction. */ - int IF_ICMPLT = 161; - - /** The integer value used to encode the IF_ICMPGE instruction. */ - int IF_ICMPGE = 162; - - /** The integer value used to encode the IF_ICMPGT instruction. */ - int IF_ICMPGT = 163; - - /** The integer value used to encode the IF_ICMPLE instruction. */ - int IF_ICMPLE = 164; - - /** The integer value used to encode the IF_ACMPEQ instruction. */ - int IF_ACMPEQ = 165; - - /** The integer value used to encode the IF_ACMPNE instruction. */ - int IF_ACMPNE = 166; - - /** The integer value used to encode the GOTO instruction. */ - int GOTO = 167; - - /** The integer value used to encode the JSR instruction. */ - int JSR = 168; - - /** The integer value used to encode the RET instruction. */ - int RET = 169; - - /** The integer value used to encode the TABLESWITCH instruction. */ - int TABLESWITCH = 170; - - /** The integer value used to encode the LOOKUPSWITCH instruction. */ - int LOOKUPSWITCH = 171; - - /** The integer value used to encode the IRETURN instruction. */ - int IRETURN = 172; - - /** The integer value used to encode the LRETURN instruction. */ - int LRETURN = 173; - - /** The integer value used to encode the FRETURN instruction. */ - int FRETURN = 174; - - /** The integer value used to encode the DRETURN instruction. */ - int DRETURN = 175; - - /** The integer value used to encode the ARETURN instruction. */ - int ARETURN = 176; - - /** The integer value used to encode the RETURN instruction. */ - int RETURN = 177; - - /** The integer value used to encode the GETSTATIC instruction. */ - int GETSTATIC = 178; - - /** The integer value used to encode the PUTSTATIC instruction. */ - int PUTSTATIC = 179; - - /** The integer value used to encode the GETFIELD instruction. */ - int GETFIELD = 180; - - /** The integer value used to encode the PUTFIELD instruction. */ - int PUTFIELD = 181; - - /** The integer value used to encode the INVOKEVIRTUAL instruction. */ - int INVOKEVIRTUAL = 182; - - /** The integer value used to encode the INVOKESPECIAL instruction. */ - int INVOKESPECIAL = 183; - - /** The integer value used to encode the INVOKESTATIC instruction. */ - int INVOKESTATIC = 184; - - /** The integer value used to encode the INVOKEINTERFACE instruction. */ - int INVOKEINTERFACE = 185; - - /** The integer value used to encode the INVOKEDYNAMIC instruction. */ - int INVOKEDYNAMIC = 186; - - /** The integer value used to encode the NEW instruction. */ - int NEW = 187; - - /** The integer value used to encode the NEWARRAY instruction. */ - int NEWARRAY = 188; - - /** The integer value used to encode the ANEWARRAY instruction. */ - int ANEWARRAY = 189; - - /** The integer value used to encode the ARRAYLENGTH instruction. */ - int ARRAYLENGTH = 190; - - /** The integer value used to encode the ATHROW instruction. */ - int ATHROW = 191; - - /** The integer value used to encode the CHECKCAST instruction. */ - int CHECKCAST = 192; - - /** The integer value used to encode the INSTANCEOF instruction. */ - int INSTANCEOF = 193; - - /** The integer value used to encode the MONITORENTER instruction. */ - int MONITORENTER = 194; - - /** The integer value used to encode the MONITOREXIT instruction. */ - int MONITOREXIT = 195; - - /** The integer value used to encode the WIDE instruction. */ - int WIDE = 196; - - /** The integer value used to encode the MULTIANEWARRAY instruction. */ - int MULTIANEWARRAY = 197; - - /** The integer value used to encode the IFNULL instruction. */ - int IFNULL = 198; - - /** The integer value used to encode the IFNONNULL instruction. */ - int IFNONNULL = 199; - - /** The integer value used to encode the GOTO_W instruction. */ - int GOTO_W = 200; - - /** The integer value used to encode the JSR_W instruction. */ - int JSR_W = 201; - - /** The value of PUBLIC access and property modifier. */ + /** The bit mask of PUBLIC access and property modifier. */ int ACC_PUBLIC = 0x0001; - /** The value of PROTECTED access and property modifier. */ + /** The bit mask of PROTECTED access and property modifier. */ int ACC_PROTECTED = 0x0004; - /** The value of PRIVATE access and property modifier. */ + /** The bit mask of PRIVATE access and property modifier. */ int ACC_PRIVATE = 0x0002; - /** The value of INTERFACE access and property modifier. */ + /** The bit mask of INTERFACE access and property modifier. */ int ACC_INTERFACE = 0x0200; - /** The value of ENUM access and property modifier. */ + /** The bit mask of ENUM access and property modifier. */ int ACC_ENUM = 0x4000; - /** The value of ANNOTATION access and property modifier. */ + /** The bit mask of ANNOTATION access and property modifier. */ int ACC_ANNOTATION = 0x2000; - /** The value of SUPER access and property modifier. */ + /** The bit mask of SUPER access and property modifier. */ int ACC_SUPER = 0x0020; - /** The value of ABSTRACT access and property modifier. */ + /** The bit mask of ABSTRACT access and property modifier. */ int ACC_ABSTRACT = 0x0400; - /** The value of VOLATILE access and property modifier. */ + /** The bit mask of VOLATILE access and property modifier. */ int ACC_VOLATILE = 0x0040; - /** The value of TRANSIENT access and property modifier. */ + /** The bit mask of TRANSIENT access and property modifier. */ int ACC_TRANSIENT = 0x0080; - /** The value of SYNTHETIC access and property modifier. */ + /** The bit mask of SYNTHETIC access and property modifier. */ int ACC_SYNTHETIC = 0x1000; - /** The value of STATIC access and property modifier. */ + /** The bit mask of STATIC access and property modifier. */ int ACC_STATIC = 0x0008; - /** The value of FINAL access and property modifier. */ + /** The bit mask of FINAL access and property modifier. */ int ACC_FINAL = 0x0010; - /** The value of SYNCHRONIZED access and property modifier. */ + /** The bit mask of SYNCHRONIZED access and property modifier. */ int ACC_SYNCHRONIZED = 0x0020; - /** The value of BRIDGE access and property modifier. */ + /** The bit mask of BRIDGE access and property modifier. */ int ACC_BRIDGE = 0x0040; - /** The value of VARARGS access and property modifier. */ + /** The bit mask of VARARGS access and property modifier. */ int ACC_VARARGS = 0x0080; - /** The value of NATIVE access and property modifier. */ + /** The bit mask of NATIVE access and property modifier. */ int ACC_NATIVE = 0x0100; - /** The value of STRICT access and property modifier. */ + /** The bit mask of STRICT access and property modifier. */ int ACC_STRICT = 0x0800; - /** The value of MODULE access and property modifier. */ + /** The bit mask of MODULE access and property modifier. */ int ACC_MODULE = 0x8000; - /** The value of OPEN access and property modifier. */ + /** The bit mask of OPEN access and property modifier. */ int ACC_OPEN = 0x20; - /** The value of MANDATED access and property modifier. */ + /** The bit mask of MANDATED access and property modifier. */ int ACC_MANDATED = 0x8000; - /** The value of TRANSITIVE access and property modifier. */ + /** The bit mask of TRANSITIVE access and property modifier. */ int ACC_TRANSITIVE = 0x20; - /** The value of STATIC_PHASE access and property modifier. */ + /** The bit mask of STATIC_PHASE access and property modifier. */ int ACC_STATIC_PHASE = 0x40; - /** The value of STATEMENT {@link CharacterRangeInfo} kind. */ - int CRT_STATEMENT = 0x0001; - - /** The value of BLOCK {@link CharacterRangeInfo} kind. */ - int CRT_BLOCK = 0x0002; - - /** The value of ASSIGNMENT {@link CharacterRangeInfo} kind. */ - int CRT_ASSIGNMENT = 0x0004; - - /** The value of FLOW_CONTROLLER {@link CharacterRangeInfo} kind. */ - int CRT_FLOW_CONTROLLER = 0x0008; - - /** The value of FLOW_TARGET {@link CharacterRangeInfo} kind. */ - int CRT_FLOW_TARGET = 0x0010; - - /** The value of INVOKE {@link CharacterRangeInfo} kind. */ - int CRT_INVOKE = 0x0020; - - /** The value of CREATE {@link CharacterRangeInfo} kind. */ - int CRT_CREATE = 0x0040; - - /** The value of BRANCH_TRUE {@link CharacterRangeInfo} kind. */ - int CRT_BRANCH_TRUE = 0x0080; - - /** The value of BRANCH_FALSE {@link CharacterRangeInfo} kind. */ - int CRT_BRANCH_FALSE = 0x0100; - - /** The value of constant pool tag CLASS. */ - int TAG_CLASS = 7; - - /** The value of constant pool tag CONSTANTDYNAMIC. */ - int TAG_CONSTANTDYNAMIC = 17; - - /** The value of constant pool tag DOUBLE. */ - int TAG_DOUBLE = 6; - - /** The value of constant pool tag FIELDREF. */ - int TAG_FIELDREF = 9; - - /** The value of constant pool tag FLOAT. */ - int TAG_FLOAT = 4; - - /** The value of constant pool tag INTEGER. */ - int TAG_INTEGER = 3; - - /** The value of constant pool tag INTERFACEMETHODREF. */ - int TAG_INTERFACEMETHODREF = 11; - - /** The value of constant pool tag INVOKEDYNAMIC. */ - int TAG_INVOKEDYNAMIC = 18; - - /** The value of constant pool tag LONG. */ - int TAG_LONG = 5; - - /** The value of constant pool tag METHODHANDLE. */ - int TAG_METHODHANDLE = 15; - - /** The value of constant pool tag METHODREF. */ - int TAG_METHODREF = 10; - - /** The value of constant pool tag METHODTYPE. */ - int TAG_METHODTYPE = 16; - - /** The value of constant pool tag MODULE. */ - int TAG_MODULE = 19; - - /** The value of constant pool tag NAMEANDTYPE. */ - int TAG_NAMEANDTYPE = 12; - - /** The value of constant pool tag PACKAGE. */ - int TAG_PACKAGE = 20; - - /** The value of constant pool tag STRING. */ - int TAG_STRING = 8; - - /** The value of constant pool tag UNICODE. */ - int TAG_UNICODE = 2; - - /** The value of constant pool tag UTF8. */ - int TAG_UTF8 = 1; - - // annotation element values - - /** The value of annotation element value type AEV_BYTE. */ - int AEV_BYTE = 'B'; - - /** The value of annotation element value type AEV_CHAR. */ - int AEV_CHAR = 'C'; - - /** The value of annotation element value type AEV_DOUBLE. */ - int AEV_DOUBLE = 'D'; - - /** The value of annotation element value type AEV_FLOAT. */ - int AEV_FLOAT = 'F'; - - /** The value of annotation element value type AEV_INT. */ - int AEV_INT = 'I'; - - /** The value of annotation element value type AEV_LONG. */ - int AEV_LONG = 'J'; - - /** The value of annotation element value type AEV_SHORT. */ - int AEV_SHORT = 'S'; - - /** The value of annotation element value type AEV_BOOLEAN. */ - int AEV_BOOLEAN = 'Z'; - - /** The value of annotation element value type AEV_STRING. */ - int AEV_STRING = 's'; - - /** The value of annotation element value type AEV_ENUM. */ - int AEV_ENUM = 'e'; - - /** The value of annotation element value type AEV_CLASS. */ - int AEV_CLASS = 'c'; - - /** The value of annotation element value type AEV_ANNOTATION. */ - int AEV_ANNOTATION = '@'; - - /** The value of annotation element value type AEV_ARRAY. */ - int AEV_ARRAY = '['; - - //type annotations - - /** The value of type annotation target type CLASS_TYPE_PARAMETER. */ - int TAT_CLASS_TYPE_PARAMETER = 0x00; - - /** The value of type annotation target type METHOD_TYPE_PARAMETER. */ - int TAT_METHOD_TYPE_PARAMETER = 0x01; - - /** The value of type annotation target type CLASS_EXTENDS. */ - int TAT_CLASS_EXTENDS = 0x10; - - /** The value of type annotation target type CLASS_TYPE_PARAMETER_BOUND. */ - int TAT_CLASS_TYPE_PARAMETER_BOUND = 0x11; - - /** The value of type annotation target type METHOD_TYPE_PARAMETER_BOUND. */ - int TAT_METHOD_TYPE_PARAMETER_BOUND = 0x12; - - /** The value of type annotation target type FIELD. */ - int TAT_FIELD = 0x13; - - /** The value of type annotation target type METHOD_RETURN. */ - int TAT_METHOD_RETURN = 0x14; - - /** The value of type annotation target type METHOD_RECEIVER. */ - int TAT_METHOD_RECEIVER = 0x15; - - /** The value of type annotation target type METHOD_FORMAL_PARAMETER. */ - int TAT_METHOD_FORMAL_PARAMETER = 0x16; - - /** The value of type annotation target type THROWS. */ - int TAT_THROWS = 0x17; - - /** The value of type annotation target type LOCAL_VARIABLE. */ - int TAT_LOCAL_VARIABLE = 0x40; - - /** The value of type annotation target type RESOURCE_VARIABLE. */ - int TAT_RESOURCE_VARIABLE = 0x41; - - /** The value of type annotation target type EXCEPTION_PARAMETER. */ - int TAT_EXCEPTION_PARAMETER = 0x42; - - /** The value of type annotation target type INSTANCEOF. */ - int TAT_INSTANCEOF = 0x43; - - /** The value of type annotation target type NEW. */ - int TAT_NEW = 0x44; - - /** The value of type annotation target type CONSTRUCTOR_REFERENCE. */ - int TAT_CONSTRUCTOR_REFERENCE = 0x45; - - /** The value of type annotation target type METHOD_REFERENCE. */ - int TAT_METHOD_REFERENCE = 0x46; - - /** The value of type annotation target type CAST. */ - int TAT_CAST = 0x47; - - /** The value of type annotation target type CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT. */ - int TAT_CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT = 0x48; - - /** The value of type annotation target type METHOD_INVOCATION_TYPE_ARGUMENT. */ - int TAT_METHOD_INVOCATION_TYPE_ARGUMENT = 0x49; - - /** The value of type annotation target type CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT. */ - int TAT_CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT = 0x4A; - - /** The value of type annotation target type METHOD_REFERENCE_TYPE_ARGUMENT. */ - int TAT_METHOD_REFERENCE_TYPE_ARGUMENT = 0x4B; - - //stackmap verification types - - /** The value of verification type TOP. */ - int VT_TOP = 0; - - /** The value of verification type INTEGER. */ - int VT_INTEGER = 1; - - /** The value of verification type FLOAT. */ - int VT_FLOAT = 2; - - /** The value of verification type DOUBLE. */ - int VT_DOUBLE = 3; - - /** The value of verification type LONG. */ - int VT_LONG = 4; - - /** The value of verification type NULL. */ - int VT_NULL = 5; - - /** The value of verification type UNINITIALIZED_THIS. */ - int VT_UNINITIALIZED_THIS = 6; - - /** The value of verification type OBJECT. */ - int VT_OBJECT = 7; - - /** The value of verification type UNINITIALIZED. */ - int VT_UNINITIALIZED = 8; - - /** The value of default class access flags */ - int DEFAULT_CLASS_FLAGS = ACC_PUBLIC; - /** The class major version of JAVA_1. */ int JAVA_1_VERSION = 45; diff --git a/src/java.base/share/classes/java/lang/classfile/ClassHierarchyResolver.java b/src/java.base/share/classes/java/lang/classfile/ClassHierarchyResolver.java index 589713c8e95..3f16ce84024 100644 --- a/src/java.base/share/classes/java/lang/classfile/ClassHierarchyResolver.java +++ b/src/java.base/share/classes/java/lang/classfile/ClassHierarchyResolver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,6 +39,8 @@ import jdk.internal.classfile.impl.ClassHierarchyImpl.StaticClassHierarchyResolv import jdk.internal.classfile.impl.Util; import static java.lang.constant.ConstantDescs.CD_Object; +import static java.util.Objects.requireNonNull; + import jdk.internal.javac.PreviewFeature; /** @@ -106,6 +108,7 @@ public interface ClassHierarchyResolver { * other resolver in cases where this resolver returns {@code null}. */ default ClassHierarchyResolver orElse(ClassHierarchyResolver other) { + requireNonNull(other); return new ClassHierarchyResolver() { @Override public ClassHierarchyInfo getClassInfo(ClassDesc classDesc) { @@ -170,7 +173,7 @@ public interface ClassHierarchyResolver { * @return the {@linkplain ClassHierarchyResolver} */ static ClassHierarchyResolver ofResourceParsing(Function classStreamResolver) { - return new ClassHierarchyImpl.ResourceParsingClassHierarchyResolver(classStreamResolver); + return new ClassHierarchyImpl.ResourceParsingClassHierarchyResolver(requireNonNull(classStreamResolver)); } /** @@ -181,6 +184,7 @@ public interface ClassHierarchyResolver { * @return the {@linkplain ClassHierarchyResolver} */ static ClassHierarchyResolver ofResourceParsing(ClassLoader loader) { + requireNonNull(loader); return ofResourceParsing(new Function<>() { @Override public InputStream apply(ClassDesc classDesc) { @@ -210,6 +214,7 @@ public interface ClassHierarchyResolver { * @return the class hierarchy resolver */ static ClassHierarchyResolver ofClassLoading(ClassLoader loader) { + requireNonNull(loader); return new ClassLoadingClassHierarchyResolver(new Function<>() { @Override public Class apply(ClassDesc cd) { @@ -232,6 +237,7 @@ public interface ClassHierarchyResolver { * @return the class hierarchy resolver */ static ClassHierarchyResolver ofClassLoading(MethodHandles.Lookup lookup) { + requireNonNull(lookup); return new ClassLoadingClassHierarchyResolver(new Function<>() { @Override public Class apply(ClassDesc cd) { diff --git a/src/java.base/share/classes/java/lang/classfile/ClassTransform.java b/src/java.base/share/classes/java/lang/classfile/ClassTransform.java index 743a3985114..230b436b138 100644 --- a/src/java.base/share/classes/java/lang/classfile/ClassTransform.java +++ b/src/java.base/share/classes/java/lang/classfile/ClassTransform.java @@ -32,6 +32,8 @@ import java.lang.classfile.attribute.CodeAttribute; import jdk.internal.classfile.impl.TransformImpl; import jdk.internal.javac.PreviewFeature; +import static java.util.Objects.requireNonNull; + /** * A transformation on streams of {@link ClassElement}. * @@ -63,7 +65,7 @@ public non-sealed interface ClassTransform * @return the stateful class transform */ static ClassTransform ofStateful(Supplier supplier) { - return new TransformImpl.SupplierClassTransform(supplier); + return new TransformImpl.SupplierClassTransform(requireNonNull(supplier)); } /** @@ -74,6 +76,7 @@ public non-sealed interface ClassTransform * @return the class transform */ static ClassTransform endHandler(Consumer finisher) { + requireNonNull(finisher); return new ClassTransform() { @Override public void accept(ClassBuilder builder, ClassElement element) { @@ -95,6 +98,7 @@ public non-sealed interface ClassTransform * @return the class transform */ static ClassTransform dropping(Predicate filter) { + requireNonNull(filter); return (b, e) -> { if (!filter.test(e)) b.with(e); @@ -111,7 +115,7 @@ public non-sealed interface ClassTransform */ static ClassTransform transformingMethods(Predicate filter, MethodTransform xform) { - return new TransformImpl.ClassMethodTransform(xform, filter); + return new TransformImpl.ClassMethodTransform(requireNonNull(xform), requireNonNull(filter)); } /** @@ -122,7 +126,7 @@ public non-sealed interface ClassTransform * @return the class transform */ static ClassTransform transformingMethods(MethodTransform xform) { - return transformingMethods(mm -> true, xform); + return transformingMethods(_ -> true, xform); } /** @@ -157,7 +161,7 @@ public non-sealed interface ClassTransform * @return the class transform */ static ClassTransform transformingFields(FieldTransform xform) { - return new TransformImpl.ClassFieldTransform(xform, f -> true); + return new TransformImpl.ClassFieldTransform(requireNonNull(xform), _ -> true); } /** @@ -169,6 +173,6 @@ public non-sealed interface ClassTransform */ @Override default ClassTransform andThen(ClassTransform t) { - return new TransformImpl.ChainedClassTransform(this, t); + return new TransformImpl.ChainedClassTransform(this, requireNonNull(t)); } } diff --git a/src/java.base/share/classes/java/lang/classfile/CodeBuilder.java b/src/java.base/share/classes/java/lang/classfile/CodeBuilder.java index 75413011731..7b27238bbdf 100644 --- a/src/java.base/share/classes/java/lang/classfile/CodeBuilder.java +++ b/src/java.base/share/classes/java/lang/classfile/CodeBuilder.java @@ -262,7 +262,7 @@ public sealed interface CodeBuilder */ default CodeBuilder ifThen(Opcode opcode, Consumer thenHandler) { - if (opcode.kind() != Opcode.Kind.BRANCH || opcode.primaryTypeKind() == TypeKind.VOID) { + if (opcode.kind() != Opcode.Kind.BRANCH || BytecodeHelpers.isUnconditionalBranch(opcode)) { throw new IllegalArgumentException("Illegal branch opcode: " + opcode); } @@ -312,7 +312,7 @@ public sealed interface CodeBuilder default CodeBuilder ifThenElse(Opcode opcode, Consumer thenHandler, Consumer elseHandler) { - if (opcode.kind() != Opcode.Kind.BRANCH || opcode.primaryTypeKind() == TypeKind.VOID) { + if (opcode.kind() != Opcode.Kind.BRANCH || BytecodeHelpers.isUnconditionalBranch(opcode)) { throw new IllegalArgumentException("Illegal branch opcode: " + opcode); } @@ -429,6 +429,8 @@ public sealed interface CodeBuilder * @param tk the load type * @param slot the local variable slot * @return this builder + * @throws IllegalArgumentException if {@code tk} is {@link TypeKind#VOID void} + * or {@code slot} is out of range * @since 23 */ default CodeBuilder loadLocal(TypeKind tk, int slot) { @@ -440,6 +442,8 @@ public sealed interface CodeBuilder * @param tk the store type * @param slot the local variable slot * @return this builder + * @throws IllegalArgumentException if {@code tk} is {@link TypeKind#VOID void} + * or {@code slot} is out of range * @since 23 */ default CodeBuilder storeLocal(TypeKind tk, int slot) { @@ -615,36 +619,77 @@ public sealed interface CodeBuilder if (value == null || value == ConstantDescs.NULL) return aconst_null(); if (value instanceof Number) { - if (value instanceof Integer iVal) - return switch (iVal) { - case -1 -> iconst_m1(); - case 0 -> iconst_0(); - case 1 -> iconst_1(); - case 2 -> iconst_2(); - case 3 -> iconst_3(); - case 4 -> iconst_4(); - case 5 -> iconst_5(); - default -> (iVal >= Byte.MIN_VALUE && iVal <= Byte.MAX_VALUE) ? bipush(iVal) - : (iVal >= Short.MIN_VALUE && iVal <= Short.MAX_VALUE) ? sipush(iVal) - : ldc(constantPool().intEntry(iVal)); - }; - if (value instanceof Long lVal) - return lVal == 0L ? lconst_0() - : lVal == 1L ? lconst_1() - : ldc(constantPool().longEntry(lVal)); - if (value instanceof Float fVal) - return Float.floatToRawIntBits(fVal) == 0 ? fconst_0() - : fVal == 1.0f ? fconst_1() - : fVal == 2.0f ? fconst_2() - : ldc(constantPool().floatEntry(fVal)); - if (value instanceof Double dVal) - return Double.doubleToRawLongBits(dVal) == 0L ? dconst_0() - : dVal == 1.0d ? dconst_1() - : ldc(constantPool().doubleEntry(dVal)); + if (value instanceof Integer) return loadConstant((int) value); + if (value instanceof Long ) return loadConstant((long) value); + if (value instanceof Float ) return loadConstant((float) value); + if (value instanceof Double ) return loadConstant((double) value); } return ldc(value); } + + /** + * Generate an instruction pushing a constant int value onto the operand stack. + * This is identical to {@link #loadConstant(ConstantDesc) loadConstant(Integer.valueOf(value))}. + * @param value the int value + * @return this builder + * @since 24 + */ + default CodeBuilder loadConstant(int value) { + return switch (value) { + case -1 -> iconst_m1(); + case 0 -> iconst_0(); + case 1 -> iconst_1(); + case 2 -> iconst_2(); + case 3 -> iconst_3(); + case 4 -> iconst_4(); + case 5 -> iconst_5(); + default -> (value >= Byte.MIN_VALUE && value <= Byte.MAX_VALUE ) ? bipush(value) + : (value >= Short.MIN_VALUE && value <= Short.MAX_VALUE) ? sipush(value) + : ldc(constantPool().intEntry(value)); + }; + } + + /** + * Generate an instruction pushing a constant long value onto the operand stack. + * This is identical to {@link #loadConstant(ConstantDesc) loadConstant(Long.valueOf(value))}. + * @param value the long value + * @return this builder + * @since 24 + */ + default CodeBuilder loadConstant(long value) { + return value == 0l ? lconst_0() + : value == 1l ? lconst_1() + : ldc(constantPool().longEntry(value)); + } + + /** + * Generate an instruction pushing a constant float value onto the operand stack. + * This is identical to {@link #loadConstant(ConstantDesc) loadConstant(Float.valueOf(value))}. + * @param value the float value + * @return this builder + * @since 24 + */ + default CodeBuilder loadConstant(float value) { + return Float.floatToRawIntBits(value) == 0 ? fconst_0() + : value == 1.0f ? fconst_1() + : value == 2.0f ? fconst_2() + : ldc(constantPool().floatEntry(value)); + } + + /** + * Generate an instruction pushing a constant double value onto the operand stack. + * This is identical to {@link #loadConstant(ConstantDesc) loadConstant(Double.valueOf(value))}. + * @param value the double value + * @return this builder + * @since 24 + */ + default CodeBuilder loadConstant(double value) { + return Double.doubleToRawLongBits(value) == 0l ? dconst_0() + : value == 1.0d ? dconst_1() + : ldc(constantPool().doubleEntry(value)); + } + /** * Generate a do nothing instruction * @return this builder @@ -752,6 +797,7 @@ public sealed interface CodeBuilder * @param startScope the start scope of the variable * @param endScope the end scope of the variable * @return this builder + * @throws IllegalArgumentException if {@code slot} is out of range */ default CodeBuilder localVariable(int slot, Utf8Entry nameEntry, Utf8Entry descriptorEntry, Label startScope, Label endScope) { return with(LocalVariable.of(slot, nameEntry, descriptorEntry, startScope, endScope)); @@ -765,11 +811,12 @@ public sealed interface CodeBuilder * @param startScope the start scope of the variable * @param endScope the end scope of the variable * @return this builder + * @throws IllegalArgumentException if {@code slot} is out of range */ default CodeBuilder localVariable(int slot, String name, ClassDesc descriptor, Label startScope, Label endScope) { return localVariable(slot, constantPool().utf8Entry(name), - constantPool().utf8Entry(descriptor.descriptorString()), + constantPool().utf8Entry(descriptor), startScope, endScope); } @@ -781,6 +828,7 @@ public sealed interface CodeBuilder * @param startScope the start scope of the variable * @param endScope the end scope of the variable * @return this builder + * @throws IllegalArgumentException if {@code slot} is out of range */ default CodeBuilder localVariableType(int slot, Utf8Entry nameEntry, Utf8Entry signatureEntry, Label startScope, Label endScope) { return with(LocalVariableType.of(slot, nameEntry, signatureEntry, startScope, endScope)); @@ -794,6 +842,7 @@ public sealed interface CodeBuilder * @param startScope the start scope of the variable * @param endScope the end scope of the variable * @return this builder + * @throws IllegalArgumentException if {@code slot} is out of range */ default CodeBuilder localVariableType(int slot, String name, Signature signature, Label startScope, Label endScope) { return localVariableType(slot, @@ -836,6 +885,7 @@ public sealed interface CodeBuilder * * @param slot the local variable slot * @return this builder + * @throws IllegalArgumentException if {@code slot} is out of range */ default CodeBuilder aload(int slot) { return loadLocal(TypeKind.REFERENCE, slot); @@ -884,6 +934,7 @@ public sealed interface CodeBuilder * * @param slot the local variable slot * @return this builder + * @throws IllegalArgumentException if {@code slot} is out of range */ default CodeBuilder astore(int slot) { return storeLocal(TypeKind.REFERENCE, slot); @@ -917,6 +968,7 @@ public sealed interface CodeBuilder * Generate an instruction pushing an int in the range of byte onto the operand stack. * @param b the int in the range of byte * @return this builder + * @throws IllegalArgumentException if {@code b} is out of range of byte */ default CodeBuilder bipush(int b) { return with(ConstantInstruction.ofArgument(Opcode.BIPUSH, b)); @@ -1053,6 +1105,7 @@ public sealed interface CodeBuilder * * @param slot the local variable slot * @return this builder + * @throws IllegalArgumentException if {@code slot} is out of range */ default CodeBuilder dload(int slot) { return loadLocal(TypeKind.DOUBLE, slot); @@ -1098,6 +1151,7 @@ public sealed interface CodeBuilder * * @param slot the local variable slot * @return this builder + * @throws IllegalArgumentException if {@code slot} is out of range */ default CodeBuilder dstore(int slot) { return storeLocal(TypeKind.DOUBLE, slot); @@ -1265,6 +1319,7 @@ public sealed interface CodeBuilder * * @param slot the local variable slot * @return this builder + * @throws IllegalArgumentException if {@code slot} is out of range */ default CodeBuilder fload(int slot) { return loadLocal(TypeKind.FLOAT, slot); @@ -1310,6 +1365,7 @@ public sealed interface CodeBuilder * * @param slot the local variable slot * @return this builder + * @throws IllegalArgumentException if {@code slot} is out of range */ default CodeBuilder fstore(int slot) { return storeLocal(TypeKind.FLOAT, slot); @@ -1685,6 +1741,7 @@ public sealed interface CodeBuilder * @param slot the local variable slot * @param val the increment value * @return this builder + * @throws IllegalArgumentException if {@code slot} or {@code val} is out of range */ default CodeBuilder iinc(int slot, int val) { return with(IncrementInstruction.of(slot, val)); @@ -1698,6 +1755,7 @@ public sealed interface CodeBuilder * * @param slot the local variable slot * @return this builder + * @throws IllegalArgumentException if {@code slot} is out of range */ default CodeBuilder iload(int slot) { return loadLocal(TypeKind.INT, slot); @@ -1956,6 +2014,7 @@ public sealed interface CodeBuilder * * @param slot the local variable slot * @return this builder + * @throws IllegalArgumentException if {@code slot} is out of range */ default CodeBuilder istore(int slot) { return storeLocal(TypeKind.INT, slot); @@ -2118,6 +2177,7 @@ public sealed interface CodeBuilder * * @param slot the local variable slot * @return this builder + * @throws IllegalArgumentException if {@code slot} is out of range */ default CodeBuilder lload(int slot) { return loadLocal(TypeKind.LONG, slot); @@ -2187,6 +2247,7 @@ public sealed interface CodeBuilder * * @param slot the local variable slot * @return this builder + * @throws IllegalArgumentException if {@code slot} is out of range */ default CodeBuilder lstore(int slot) { return storeLocal(TypeKind.LONG, slot); @@ -2237,6 +2298,7 @@ public sealed interface CodeBuilder * @param array the array type * @param dims the number of dimensions * @return this builder + * @throws IllegalArgumentException if {@code dims} is out of range */ default CodeBuilder multianewarray(ClassEntry array, int dims) { return with(NewMultiArrayInstruction.of(array, dims)); @@ -2248,6 +2310,7 @@ public sealed interface CodeBuilder * @param dims the number of dimensions * @return this builder * @throws IllegalArgumentException if {@code array} represents a primitive type + * or if {@code dims} is out of range */ default CodeBuilder multianewarray(ClassDesc array, int dims) { return multianewarray(constantPool().classEntry(array), dims); @@ -2286,6 +2349,8 @@ public sealed interface CodeBuilder * Generate an instruction to create a new array of a primitive type * @param typeKind the primitive array type * @return this builder + * @throws IllegalArgumentException when the {@code typeKind} is not a legal + * primitive array component type */ default CodeBuilder newarray(TypeKind typeKind) { return with(NewPrimitiveArrayInstruction.of(typeKind)); @@ -2382,6 +2447,7 @@ public sealed interface CodeBuilder * Generate an instruction pushing an int in the range of short onto the operand stack. * @param s the int in the range of short * @return this builder + * @throws IllegalArgumentException if {@code s} is out of range of short */ default CodeBuilder sipush(int s) { return with(ConstantInstruction.ofArgument(Opcode.SIPUSH, s)); diff --git a/src/java.base/share/classes/java/lang/classfile/CodeTransform.java b/src/java.base/share/classes/java/lang/classfile/CodeTransform.java index cdc7a3b1434..0474e0c9c67 100644 --- a/src/java.base/share/classes/java/lang/classfile/CodeTransform.java +++ b/src/java.base/share/classes/java/lang/classfile/CodeTransform.java @@ -30,6 +30,8 @@ import java.util.function.Supplier; import jdk.internal.classfile.impl.TransformImpl; import jdk.internal.javac.PreviewFeature; +import static java.util.Objects.requireNonNull; + /** * A transformation on streams of {@link CodeElement}. * @@ -61,7 +63,7 @@ public non-sealed interface CodeTransform * @return the stateful code transform */ static CodeTransform ofStateful(Supplier supplier) { - return new TransformImpl.SupplierCodeTransform(supplier); + return new TransformImpl.SupplierCodeTransform(requireNonNull(supplier)); } /** @@ -72,6 +74,7 @@ public non-sealed interface CodeTransform * @return the code transform */ static CodeTransform endHandler(Consumer finisher) { + requireNonNull(finisher); return new CodeTransform() { @Override public void accept(CodeBuilder builder, CodeElement element) { @@ -94,6 +97,6 @@ public non-sealed interface CodeTransform */ @Override default CodeTransform andThen(CodeTransform t) { - return new TransformImpl.ChainedCodeTransform(this, t); + return new TransformImpl.ChainedCodeTransform(this, requireNonNull(t)); } } diff --git a/src/java.base/share/classes/java/lang/classfile/FieldModel.java b/src/java.base/share/classes/java/lang/classfile/FieldModel.java index e14f264ca2a..006103d5f9c 100644 --- a/src/java.base/share/classes/java/lang/classfile/FieldModel.java +++ b/src/java.base/share/classes/java/lang/classfile/FieldModel.java @@ -31,6 +31,7 @@ import java.util.Optional; import java.lang.classfile.constantpool.Utf8Entry; import jdk.internal.classfile.impl.BufferedFieldBuilder; import jdk.internal.classfile.impl.FieldImpl; +import jdk.internal.classfile.impl.Util; import jdk.internal.javac.PreviewFeature; /** @@ -59,6 +60,6 @@ public sealed interface FieldModel /** {@return the field descriptor of this field, as a symbolic descriptor} */ default ClassDesc fieldTypeSymbol() { - return ClassDesc.ofDescriptor(fieldType().stringValue()); + return Util.fieldTypeSymbol(fieldType()); } } diff --git a/src/java.base/share/classes/java/lang/classfile/FieldTransform.java b/src/java.base/share/classes/java/lang/classfile/FieldTransform.java index 4e39f1e9c7f..78a6f5ead2f 100644 --- a/src/java.base/share/classes/java/lang/classfile/FieldTransform.java +++ b/src/java.base/share/classes/java/lang/classfile/FieldTransform.java @@ -31,6 +31,8 @@ import java.util.function.Supplier; import jdk.internal.classfile.impl.TransformImpl; import jdk.internal.javac.PreviewFeature; +import static java.util.Objects.requireNonNull; + /** * A transformation on streams of {@link FieldElement}. * @@ -62,7 +64,7 @@ public non-sealed interface FieldTransform * @return the stateful field transform */ static FieldTransform ofStateful(Supplier supplier) { - return new TransformImpl.SupplierFieldTransform(supplier); + return new TransformImpl.SupplierFieldTransform(requireNonNull(supplier)); } /** @@ -73,6 +75,7 @@ public non-sealed interface FieldTransform * @return the field transform */ static FieldTransform endHandler(Consumer finisher) { + requireNonNull(finisher); return new FieldTransform() { @Override public void accept(FieldBuilder builder, FieldElement element) { @@ -94,6 +97,7 @@ public non-sealed interface FieldTransform * @return the field transform */ static FieldTransform dropping(Predicate filter) { + requireNonNull(filter); return (b, e) -> { if (!filter.test(e)) b.with(e); @@ -109,6 +113,6 @@ public non-sealed interface FieldTransform */ @Override default FieldTransform andThen(FieldTransform t) { - return new TransformImpl.ChainedFieldTransform(this, t); + return new TransformImpl.ChainedFieldTransform(this, requireNonNull(t)); } } diff --git a/src/java.base/share/classes/java/lang/classfile/MethodModel.java b/src/java.base/share/classes/java/lang/classfile/MethodModel.java index 651bc194ee3..bd51f3c97d7 100644 --- a/src/java.base/share/classes/java/lang/classfile/MethodModel.java +++ b/src/java.base/share/classes/java/lang/classfile/MethodModel.java @@ -31,6 +31,7 @@ import java.util.Optional; import java.lang.classfile.constantpool.Utf8Entry; import jdk.internal.classfile.impl.BufferedMethodBuilder; import jdk.internal.classfile.impl.MethodImpl; +import jdk.internal.classfile.impl.Util; import jdk.internal.javac.PreviewFeature; /** @@ -59,7 +60,7 @@ public sealed interface MethodModel /** {@return the method descriptor of this method, as a symbolic descriptor} */ default MethodTypeDesc methodTypeSymbol() { - return MethodTypeDesc.ofDescriptor(methodType().stringValue()); + return Util.methodTypeSymbol(methodType()); } /** {@return the body of this method, if there is one} */ diff --git a/src/java.base/share/classes/java/lang/classfile/MethodTransform.java b/src/java.base/share/classes/java/lang/classfile/MethodTransform.java index e7e024ebc34..bf5786f3dc7 100644 --- a/src/java.base/share/classes/java/lang/classfile/MethodTransform.java +++ b/src/java.base/share/classes/java/lang/classfile/MethodTransform.java @@ -31,6 +31,8 @@ import java.util.function.Supplier; import jdk.internal.classfile.impl.TransformImpl; import jdk.internal.javac.PreviewFeature; +import static java.util.Objects.requireNonNull; + /** * A transformation on streams of {@link MethodElement}. * @@ -62,6 +64,7 @@ public non-sealed interface MethodTransform * @return the stateful method transform */ static MethodTransform ofStateful(Supplier supplier) { + requireNonNull(supplier); return new TransformImpl.SupplierMethodTransform(supplier); } @@ -73,6 +76,7 @@ public non-sealed interface MethodTransform * @return the method transform */ static MethodTransform endHandler(Consumer finisher) { + requireNonNull(finisher); return new MethodTransform() { @Override public void accept(MethodBuilder builder, MethodElement element) { @@ -94,6 +98,7 @@ public non-sealed interface MethodTransform * @return the method transform */ static MethodTransform dropping(Predicate filter) { + requireNonNull(filter); return (b, e) -> { if (!filter.test(e)) b.with(e); @@ -108,7 +113,7 @@ public non-sealed interface MethodTransform * @return the class transform */ static MethodTransform transformingCode(CodeTransform xform) { - return new TransformImpl.MethodCodeTransform(xform); + return new TransformImpl.MethodCodeTransform(requireNonNull(xform)); } /** @@ -120,6 +125,6 @@ public non-sealed interface MethodTransform */ @Override default MethodTransform andThen(MethodTransform t) { - return new TransformImpl.ChainedMethodTransform(this, t); + return new TransformImpl.ChainedMethodTransform(this, requireNonNull(t)); } } diff --git a/src/java.base/share/classes/java/lang/classfile/Opcode.java b/src/java.base/share/classes/java/lang/classfile/Opcode.java index 9e4c35276cf..735510dbcea 100644 --- a/src/java.base/share/classes/java/lang/classfile/Opcode.java +++ b/src/java.base/share/classes/java/lang/classfile/Opcode.java @@ -24,8 +24,7 @@ */ package java.lang.classfile; -import java.lang.constant.ConstantDesc; -import java.lang.constant.ConstantDescs; +import jdk.internal.classfile.impl.RawBytecodeHelper; import jdk.internal.javac.PreviewFeature; /** @@ -42,658 +41,658 @@ import jdk.internal.javac.PreviewFeature; public enum Opcode { /** Do nothing */ - NOP(ClassFile.NOP, 1, Kind.NOP), + NOP(RawBytecodeHelper.NOP, 1, Kind.NOP), /** Push null */ - ACONST_NULL(ClassFile.ACONST_NULL, 1, Kind.CONSTANT, TypeKind.REFERENCE, 0, ConstantDescs.NULL), + ACONST_NULL(RawBytecodeHelper.ACONST_NULL, 1, Kind.CONSTANT), /** Push int constant -1 */ - ICONST_M1(ClassFile.ICONST_M1, 1, Kind.CONSTANT, TypeKind.INT, 0, -1), + ICONST_M1(RawBytecodeHelper.ICONST_M1, 1, Kind.CONSTANT), /** Push int constant 0 */ - ICONST_0(ClassFile.ICONST_0, 1, Kind.CONSTANT, TypeKind.INT, 0, 0), + ICONST_0(RawBytecodeHelper.ICONST_0, 1, Kind.CONSTANT), /** Push int constant 1 */ - ICONST_1(ClassFile.ICONST_1, 1, Kind.CONSTANT, TypeKind.INT, 0, 1), + ICONST_1(RawBytecodeHelper.ICONST_1, 1, Kind.CONSTANT), /** Push int constant 2 */ - ICONST_2(ClassFile.ICONST_2, 1, Kind.CONSTANT, TypeKind.INT, 0, 2), + ICONST_2(RawBytecodeHelper.ICONST_2, 1, Kind.CONSTANT), /** Push int constant 3 */ - ICONST_3(ClassFile.ICONST_3, 1, Kind.CONSTANT, TypeKind.INT, 0, 3), + ICONST_3(RawBytecodeHelper.ICONST_3, 1, Kind.CONSTANT), /** Push int constant 4 */ - ICONST_4(ClassFile.ICONST_4, 1, Kind.CONSTANT, TypeKind.INT, 0, 4), + ICONST_4(RawBytecodeHelper.ICONST_4, 1, Kind.CONSTANT), /** Push int constant 5 */ - ICONST_5(ClassFile.ICONST_5, 1, Kind.CONSTANT, TypeKind.INT, 0, 5), + ICONST_5(RawBytecodeHelper.ICONST_5, 1, Kind.CONSTANT), /** Push long constant 0 */ - LCONST_0(ClassFile.LCONST_0, 1, Kind.CONSTANT, TypeKind.LONG, 0, 0L), + LCONST_0(RawBytecodeHelper.LCONST_0, 1, Kind.CONSTANT), /** Push long constant 1 */ - LCONST_1(ClassFile.LCONST_1, 1, Kind.CONSTANT, TypeKind.LONG, 0, 1L), + LCONST_1(RawBytecodeHelper.LCONST_1, 1, Kind.CONSTANT), /** Push float constant 0 */ - FCONST_0(ClassFile.FCONST_0, 1, Kind.CONSTANT, TypeKind.FLOAT, 0, 0.0f), + FCONST_0(RawBytecodeHelper.FCONST_0, 1, Kind.CONSTANT), /** Push float constant 1 */ - FCONST_1(ClassFile.FCONST_1, 1, Kind.CONSTANT, TypeKind.FLOAT, 0, 1.0f), + FCONST_1(RawBytecodeHelper.FCONST_1, 1, Kind.CONSTANT), /** Push float constant 2 */ - FCONST_2(ClassFile.FCONST_2, 1, Kind.CONSTANT, TypeKind.FLOAT, 0, 2.0f), + FCONST_2(RawBytecodeHelper.FCONST_2, 1, Kind.CONSTANT), /** Push double constant 0 */ - DCONST_0(ClassFile.DCONST_0, 1, Kind.CONSTANT, TypeKind.DOUBLE, 0, 0.0d), + DCONST_0(RawBytecodeHelper.DCONST_0, 1, Kind.CONSTANT), /** Push double constant 1 */ - DCONST_1(ClassFile.DCONST_1, 1, Kind.CONSTANT, TypeKind.DOUBLE, 0, 1.0d), + DCONST_1(RawBytecodeHelper.DCONST_1, 1, Kind.CONSTANT), /** Push byte */ - BIPUSH(ClassFile.BIPUSH, 2, Kind.CONSTANT, TypeKind.BYTE), + BIPUSH(RawBytecodeHelper.BIPUSH, 2, Kind.CONSTANT), /** Push short */ - SIPUSH(ClassFile.SIPUSH, 3, Kind.CONSTANT, TypeKind.SHORT), + SIPUSH(RawBytecodeHelper.SIPUSH, 3, Kind.CONSTANT), /** Push item from run-time constant pool */ - LDC(ClassFile.LDC, 2, Kind.CONSTANT), + LDC(RawBytecodeHelper.LDC, 2, Kind.CONSTANT), /** Push item from run-time constant pool (wide index) */ - LDC_W(ClassFile.LDC_W, 3, Kind.CONSTANT), + LDC_W(RawBytecodeHelper.LDC_W, 3, Kind.CONSTANT), /** Push long or double from run-time constant pool (wide index) */ - LDC2_W(ClassFile.LDC2_W, 3, Kind.CONSTANT), + LDC2_W(RawBytecodeHelper.LDC2_W, 3, Kind.CONSTANT), /** Load int from local variable */ - ILOAD(ClassFile.ILOAD, 2, Kind.LOAD, TypeKind.INT, -1), + ILOAD(RawBytecodeHelper.ILOAD, 2, Kind.LOAD), /** Load long from local variable */ - LLOAD(ClassFile.LLOAD, 2, Kind.LOAD, TypeKind.LONG, -1), + LLOAD(RawBytecodeHelper.LLOAD, 2, Kind.LOAD), /** Load float from local variable */ - FLOAD(ClassFile.FLOAD, 2, Kind.LOAD, TypeKind.FLOAT, -1), + FLOAD(RawBytecodeHelper.FLOAD, 2, Kind.LOAD), /** Load double from local variable */ - DLOAD(ClassFile.DLOAD, 2, Kind.LOAD, TypeKind.DOUBLE, -1), + DLOAD(RawBytecodeHelper.DLOAD, 2, Kind.LOAD), /** Load reference from local variable */ - ALOAD(ClassFile.ALOAD, 2, Kind.LOAD, TypeKind.REFERENCE, -1), + ALOAD(RawBytecodeHelper.ALOAD, 2, Kind.LOAD), /** Load int from local variable 0 */ - ILOAD_0(ClassFile.ILOAD_0, 1, Kind.LOAD, TypeKind.INT, 0), + ILOAD_0(RawBytecodeHelper.ILOAD_0, 1, Kind.LOAD), /** Load int from local variable 1 */ - ILOAD_1(ClassFile.ILOAD_1, 1, Kind.LOAD, TypeKind.INT, 1), + ILOAD_1(RawBytecodeHelper.ILOAD_1, 1, Kind.LOAD), /** Load int from local variable 2 */ - ILOAD_2(ClassFile.ILOAD_2, 1, Kind.LOAD, TypeKind.INT, 2), + ILOAD_2(RawBytecodeHelper.ILOAD_2, 1, Kind.LOAD), /** Load int from local variable3 */ - ILOAD_3(ClassFile.ILOAD_3, 1, Kind.LOAD, TypeKind.INT, 3), + ILOAD_3(RawBytecodeHelper.ILOAD_3, 1, Kind.LOAD), /** Load long from local variable 0 */ - LLOAD_0(ClassFile.LLOAD_0, 1, Kind.LOAD, TypeKind.LONG, 0), + LLOAD_0(RawBytecodeHelper.LLOAD_0, 1, Kind.LOAD), /** Load long from local variable 1 */ - LLOAD_1(ClassFile.LLOAD_1, 1, Kind.LOAD, TypeKind.LONG, 1), + LLOAD_1(RawBytecodeHelper.LLOAD_1, 1, Kind.LOAD), /** Load long from local variable 2 */ - LLOAD_2(ClassFile.LLOAD_2, 1, Kind.LOAD, TypeKind.LONG, 2), + LLOAD_2(RawBytecodeHelper.LLOAD_2, 1, Kind.LOAD), /** Load long from local variable 3 */ - LLOAD_3(ClassFile.LLOAD_3, 1, Kind.LOAD, TypeKind.LONG, 3), + LLOAD_3(RawBytecodeHelper.LLOAD_3, 1, Kind.LOAD), /** Load float from local variable 0 */ - FLOAD_0(ClassFile.FLOAD_0, 1, Kind.LOAD, TypeKind.FLOAT, 0), + FLOAD_0(RawBytecodeHelper.FLOAD_0, 1, Kind.LOAD), /** Load float from local variable 1 */ - FLOAD_1(ClassFile.FLOAD_1, 1, Kind.LOAD, TypeKind.FLOAT, 1), + FLOAD_1(RawBytecodeHelper.FLOAD_1, 1, Kind.LOAD), /** Load float from local variable 2 */ - FLOAD_2(ClassFile.FLOAD_2, 1, Kind.LOAD, TypeKind.FLOAT, 2), + FLOAD_2(RawBytecodeHelper.FLOAD_2, 1, Kind.LOAD), /** Load float from local variable 3 */ - FLOAD_3(ClassFile.FLOAD_3, 1, Kind.LOAD, TypeKind.FLOAT, 3), + FLOAD_3(RawBytecodeHelper.FLOAD_3, 1, Kind.LOAD), /** Load double from local variable 0 */ - DLOAD_0(ClassFile.DLOAD_0, 1, Kind.LOAD, TypeKind.DOUBLE, 0), + DLOAD_0(RawBytecodeHelper.DLOAD_0, 1, Kind.LOAD), /** Load double from local variable 1 */ - DLOAD_1(ClassFile.DLOAD_1, 1, Kind.LOAD, TypeKind.DOUBLE, 1), + DLOAD_1(RawBytecodeHelper.DLOAD_1, 1, Kind.LOAD), /** Load double from local variable 2 */ - DLOAD_2(ClassFile.DLOAD_2, 1, Kind.LOAD, TypeKind.DOUBLE, 2), + DLOAD_2(RawBytecodeHelper.DLOAD_2, 1, Kind.LOAD), /** Load double from local variable 3 */ - DLOAD_3(ClassFile.DLOAD_3, 1, Kind.LOAD, TypeKind.DOUBLE, 3), + DLOAD_3(RawBytecodeHelper.DLOAD_3, 1, Kind.LOAD), /** Load reference from local variable 0 */ - ALOAD_0(ClassFile.ALOAD_0, 1, Kind.LOAD, TypeKind.REFERENCE, 0), + ALOAD_0(RawBytecodeHelper.ALOAD_0, 1, Kind.LOAD), /** Load reference from local variable 1 */ - ALOAD_1(ClassFile.ALOAD_1, 1, Kind.LOAD, TypeKind.REFERENCE, 1), + ALOAD_1(RawBytecodeHelper.ALOAD_1, 1, Kind.LOAD), /** Load reference from local variable 2 */ - ALOAD_2(ClassFile.ALOAD_2, 1, Kind.LOAD, TypeKind.REFERENCE, 2), + ALOAD_2(RawBytecodeHelper.ALOAD_2, 1, Kind.LOAD), /** Load reference from local variable 3 */ - ALOAD_3(ClassFile.ALOAD_3, 1, Kind.LOAD, TypeKind.REFERENCE, 3), + ALOAD_3(RawBytecodeHelper.ALOAD_3, 1, Kind.LOAD), /** Load int from array */ - IALOAD(ClassFile.IALOAD, 1, Kind.ARRAY_LOAD, TypeKind.INT), + IALOAD(RawBytecodeHelper.IALOAD, 1, Kind.ARRAY_LOAD), /** Load long from array */ - LALOAD(ClassFile.LALOAD, 1, Kind.ARRAY_LOAD, TypeKind.LONG), + LALOAD(RawBytecodeHelper.LALOAD, 1, Kind.ARRAY_LOAD), /** Load float from array */ - FALOAD(ClassFile.FALOAD, 1, Kind.ARRAY_LOAD, TypeKind.FLOAT), + FALOAD(RawBytecodeHelper.FALOAD, 1, Kind.ARRAY_LOAD), /** Load double from array */ - DALOAD(ClassFile.DALOAD, 1, Kind.ARRAY_LOAD, TypeKind.DOUBLE), + DALOAD(RawBytecodeHelper.DALOAD, 1, Kind.ARRAY_LOAD), /** Load reference from array */ - AALOAD(ClassFile.AALOAD, 1, Kind.ARRAY_LOAD, TypeKind.REFERENCE), + AALOAD(RawBytecodeHelper.AALOAD, 1, Kind.ARRAY_LOAD), - /** Load byte or boolean from array */ - BALOAD(ClassFile.BALOAD, 1, Kind.ARRAY_LOAD, TypeKind.BYTE), + /** Load byte from array */ + BALOAD(RawBytecodeHelper.BALOAD, 1, Kind.ARRAY_LOAD), /** Load char from array */ - CALOAD(ClassFile.CALOAD, 1, Kind.ARRAY_LOAD, TypeKind.CHAR), + CALOAD(RawBytecodeHelper.CALOAD, 1, Kind.ARRAY_LOAD), /** Load short from array */ - SALOAD(ClassFile.SALOAD, 1, Kind.ARRAY_LOAD, TypeKind.SHORT), + SALOAD(RawBytecodeHelper.SALOAD, 1, Kind.ARRAY_LOAD), /** Store int into local variable */ - ISTORE(ClassFile.ISTORE, 2, Kind.STORE, TypeKind.INT, -1), + ISTORE(RawBytecodeHelper.ISTORE, 2, Kind.STORE), /** Store long into local variable */ - LSTORE(ClassFile.LSTORE, 2, Kind.STORE, TypeKind.LONG, -1), + LSTORE(RawBytecodeHelper.LSTORE, 2, Kind.STORE), /** Store float into local variable */ - FSTORE(ClassFile.FSTORE, 2, Kind.STORE, TypeKind.FLOAT, -1), + FSTORE(RawBytecodeHelper.FSTORE, 2, Kind.STORE), /** Store double into local variable */ - DSTORE(ClassFile.DSTORE, 2, Kind.STORE, TypeKind.DOUBLE, -1), + DSTORE(RawBytecodeHelper.DSTORE, 2, Kind.STORE), /** Store reference into local variable */ - ASTORE(ClassFile.ASTORE, 2, Kind.STORE, TypeKind.REFERENCE, -1), + ASTORE(RawBytecodeHelper.ASTORE, 2, Kind.STORE), /** Store int into local variable 0 */ - ISTORE_0(ClassFile.ISTORE_0, 1, Kind.STORE, TypeKind.INT, 0), + ISTORE_0(RawBytecodeHelper.ISTORE_0, 1, Kind.STORE), /** Store int into local variable 1 */ - ISTORE_1(ClassFile.ISTORE_1, 1, Kind.STORE, TypeKind.INT, 1), + ISTORE_1(RawBytecodeHelper.ISTORE_1, 1, Kind.STORE), /** Store int into local variable 2 */ - ISTORE_2(ClassFile.ISTORE_2, 1, Kind.STORE, TypeKind.INT, 2), + ISTORE_2(RawBytecodeHelper.ISTORE_2, 1, Kind.STORE), /** Store int into local variable 3 */ - ISTORE_3(ClassFile.ISTORE_3, 1, Kind.STORE, TypeKind.INT, 3), + ISTORE_3(RawBytecodeHelper.ISTORE_3, 1, Kind.STORE), /** Store long into local variable 0 */ - LSTORE_0(ClassFile.LSTORE_0, 1, Kind.STORE, TypeKind.LONG, 0), + LSTORE_0(RawBytecodeHelper.LSTORE_0, 1, Kind.STORE), /** Store long into local variable 1 */ - LSTORE_1(ClassFile.LSTORE_1, 1, Kind.STORE, TypeKind.LONG, 1), + LSTORE_1(RawBytecodeHelper.LSTORE_1, 1, Kind.STORE), /** Store long into local variable 2 */ - LSTORE_2(ClassFile.LSTORE_2, 1, Kind.STORE, TypeKind.LONG, 2), + LSTORE_2(RawBytecodeHelper.LSTORE_2, 1, Kind.STORE), /** Store long into local variable 3 */ - LSTORE_3(ClassFile.LSTORE_3, 1, Kind.STORE, TypeKind.LONG, 3), + LSTORE_3(RawBytecodeHelper.LSTORE_3, 1, Kind.STORE), /** Store float into local variable 0 */ - FSTORE_0(ClassFile.FSTORE_0, 1, Kind.STORE, TypeKind.FLOAT, 0), + FSTORE_0(RawBytecodeHelper.FSTORE_0, 1, Kind.STORE), /** Store float into local variable 1 */ - FSTORE_1(ClassFile.FSTORE_1, 1, Kind.STORE, TypeKind.FLOAT, 1), + FSTORE_1(RawBytecodeHelper.FSTORE_1, 1, Kind.STORE), /** Store float into local variable 2 */ - FSTORE_2(ClassFile.FSTORE_2, 1, Kind.STORE, TypeKind.FLOAT, 2), + FSTORE_2(RawBytecodeHelper.FSTORE_2, 1, Kind.STORE), /** Store float into local variable 3 */ - FSTORE_3(ClassFile.FSTORE_3, 1, Kind.STORE, TypeKind.FLOAT, 3), + FSTORE_3(RawBytecodeHelper.FSTORE_3, 1, Kind.STORE), /** Store double into local variable 0 */ - DSTORE_0(ClassFile.DSTORE_0, 1, Kind.STORE, TypeKind.DOUBLE, 0), + DSTORE_0(RawBytecodeHelper.DSTORE_0, 1, Kind.STORE), /** Store double into local variable 1 */ - DSTORE_1(ClassFile.DSTORE_1, 1, Kind.STORE, TypeKind.DOUBLE, 1), + DSTORE_1(RawBytecodeHelper.DSTORE_1, 1, Kind.STORE), /** Store double into local variable 2 */ - DSTORE_2(ClassFile.DSTORE_2, 1, Kind.STORE, TypeKind.DOUBLE, 2), + DSTORE_2(RawBytecodeHelper.DSTORE_2, 1, Kind.STORE), /** Store double into local variable 3 */ - DSTORE_3(ClassFile.DSTORE_3, 1, Kind.STORE, TypeKind.DOUBLE, 3), + DSTORE_3(RawBytecodeHelper.DSTORE_3, 1, Kind.STORE), /** Store reference into local variable 0 */ - ASTORE_0(ClassFile.ASTORE_0, 1, Kind.STORE, TypeKind.REFERENCE, 0), + ASTORE_0(RawBytecodeHelper.ASTORE_0, 1, Kind.STORE), /** Store reference into local variable 1 */ - ASTORE_1(ClassFile.ASTORE_1, 1, Kind.STORE, TypeKind.REFERENCE, 1), + ASTORE_1(RawBytecodeHelper.ASTORE_1, 1, Kind.STORE), /** Store reference into local variable 2 */ - ASTORE_2(ClassFile.ASTORE_2, 1, Kind.STORE, TypeKind.REFERENCE, 2), + ASTORE_2(RawBytecodeHelper.ASTORE_2, 1, Kind.STORE), /** Store reference into local variable 3 */ - ASTORE_3(ClassFile.ASTORE_3, 1, Kind.STORE, TypeKind.REFERENCE, 3), + ASTORE_3(RawBytecodeHelper.ASTORE_3, 1, Kind.STORE), /** Store into int array */ - IASTORE(ClassFile.IASTORE, 1, Kind.ARRAY_STORE, TypeKind.INT), + IASTORE(RawBytecodeHelper.IASTORE, 1, Kind.ARRAY_STORE), /** Store into long array */ - LASTORE(ClassFile.LASTORE, 1, Kind.ARRAY_STORE, TypeKind.LONG), + LASTORE(RawBytecodeHelper.LASTORE, 1, Kind.ARRAY_STORE), /** Store into float array */ - FASTORE(ClassFile.FASTORE, 1, Kind.ARRAY_STORE, TypeKind.FLOAT), + FASTORE(RawBytecodeHelper.FASTORE, 1, Kind.ARRAY_STORE), /** Store into double array */ - DASTORE(ClassFile.DASTORE, 1, Kind.ARRAY_STORE, TypeKind.DOUBLE), + DASTORE(RawBytecodeHelper.DASTORE, 1, Kind.ARRAY_STORE), /** Store into reference array */ - AASTORE(ClassFile.AASTORE, 1, Kind.ARRAY_STORE, TypeKind.REFERENCE), + AASTORE(RawBytecodeHelper.AASTORE, 1, Kind.ARRAY_STORE), - /** Store into byte or boolean array */ - BASTORE(ClassFile.BASTORE, 1, Kind.ARRAY_STORE, TypeKind.BYTE), + /** Store into byte array */ + BASTORE(RawBytecodeHelper.BASTORE, 1, Kind.ARRAY_STORE), /** Store into char array */ - CASTORE(ClassFile.CASTORE, 1, Kind.ARRAY_STORE, TypeKind.CHAR), + CASTORE(RawBytecodeHelper.CASTORE, 1, Kind.ARRAY_STORE), /** Store into short array */ - SASTORE(ClassFile.SASTORE, 1, Kind.ARRAY_STORE, TypeKind.SHORT), + SASTORE(RawBytecodeHelper.SASTORE, 1, Kind.ARRAY_STORE), /** Pop the top operand stack value */ - POP(ClassFile.POP, 1, Kind.STACK), + POP(RawBytecodeHelper.POP, 1, Kind.STACK), /** Pop the top one or two operand stack values */ - POP2(ClassFile.POP2, 1, Kind.STACK), + POP2(RawBytecodeHelper.POP2, 1, Kind.STACK), /** Duplicate the top operand stack value */ - DUP(ClassFile.DUP, 1, Kind.STACK), + DUP(RawBytecodeHelper.DUP, 1, Kind.STACK), /** Duplicate the top operand stack value and insert two values down */ - DUP_X1(ClassFile.DUP_X1, 1, Kind.STACK), + DUP_X1(RawBytecodeHelper.DUP_X1, 1, Kind.STACK), /** Duplicate the top operand stack value and insert two or three values down */ - DUP_X2(ClassFile.DUP_X2, 1, Kind.STACK), + DUP_X2(RawBytecodeHelper.DUP_X2, 1, Kind.STACK), /** Duplicate the top one or two operand stack values */ - DUP2(ClassFile.DUP2, 1, Kind.STACK), + DUP2(RawBytecodeHelper.DUP2, 1, Kind.STACK), /** Duplicate the top one or two operand stack values and insert two or three values down */ - DUP2_X1(ClassFile.DUP2_X1, 1, Kind.STACK), + DUP2_X1(RawBytecodeHelper.DUP2_X1, 1, Kind.STACK), /** Duplicate the top one or two operand stack values and insert two, three, or four values down */ - DUP2_X2(ClassFile.DUP2_X2, 1, Kind.STACK), + DUP2_X2(RawBytecodeHelper.DUP2_X2, 1, Kind.STACK), /** Swap the top two operand stack values */ - SWAP(ClassFile.SWAP, 1, Kind.STACK), + SWAP(RawBytecodeHelper.SWAP, 1, Kind.STACK), /** Add int */ - IADD(ClassFile.IADD, 1, Kind.OPERATOR, TypeKind.INT), + IADD(RawBytecodeHelper.IADD, 1, Kind.OPERATOR), /** Add long */ - LADD(ClassFile.LADD, 1, Kind.OPERATOR, TypeKind.LONG), + LADD(RawBytecodeHelper.LADD, 1, Kind.OPERATOR), /** Add float */ - FADD(ClassFile.FADD, 1, Kind.OPERATOR, TypeKind.FLOAT), + FADD(RawBytecodeHelper.FADD, 1, Kind.OPERATOR), /** Add double */ - DADD(ClassFile.DADD, 1, Kind.OPERATOR, TypeKind.DOUBLE), + DADD(RawBytecodeHelper.DADD, 1, Kind.OPERATOR), /** Subtract int */ - ISUB(ClassFile.ISUB, 1, Kind.OPERATOR, TypeKind.INT), + ISUB(RawBytecodeHelper.ISUB, 1, Kind.OPERATOR), /** Subtract long */ - LSUB(ClassFile.LSUB, 1, Kind.OPERATOR, TypeKind.LONG), + LSUB(RawBytecodeHelper.LSUB, 1, Kind.OPERATOR), /** Subtract float */ - FSUB(ClassFile.FSUB, 1, Kind.OPERATOR, TypeKind.FLOAT), + FSUB(RawBytecodeHelper.FSUB, 1, Kind.OPERATOR), /** Subtract double */ - DSUB(ClassFile.DSUB, 1, Kind.OPERATOR, TypeKind.DOUBLE), + DSUB(RawBytecodeHelper.DSUB, 1, Kind.OPERATOR), /** Multiply int */ - IMUL(ClassFile.IMUL, 1, Kind.OPERATOR, TypeKind.INT), + IMUL(RawBytecodeHelper.IMUL, 1, Kind.OPERATOR), /** Multiply long */ - LMUL(ClassFile.LMUL, 1, Kind.OPERATOR, TypeKind.LONG), + LMUL(RawBytecodeHelper.LMUL, 1, Kind.OPERATOR), /** Multiply float */ - FMUL(ClassFile.FMUL, 1, Kind.OPERATOR, TypeKind.FLOAT), + FMUL(RawBytecodeHelper.FMUL, 1, Kind.OPERATOR), /** Multiply double */ - DMUL(ClassFile.DMUL, 1, Kind.OPERATOR, TypeKind.DOUBLE), + DMUL(RawBytecodeHelper.DMUL, 1, Kind.OPERATOR), /** Divide int */ - IDIV(ClassFile.IDIV, 1, Kind.OPERATOR, TypeKind.INT), + IDIV(RawBytecodeHelper.IDIV, 1, Kind.OPERATOR), /** Divide long */ - LDIV(ClassFile.LDIV, 1, Kind.OPERATOR, TypeKind.LONG), + LDIV(RawBytecodeHelper.LDIV, 1, Kind.OPERATOR), /** Divide float */ - FDIV(ClassFile.FDIV, 1, Kind.OPERATOR, TypeKind.FLOAT), + FDIV(RawBytecodeHelper.FDIV, 1, Kind.OPERATOR), /** Divide double */ - DDIV(ClassFile.DDIV, 1, Kind.OPERATOR, TypeKind.DOUBLE), + DDIV(RawBytecodeHelper.DDIV, 1, Kind.OPERATOR), /** Remainder int */ - IREM(ClassFile.IREM, 1, Kind.OPERATOR, TypeKind.INT), + IREM(RawBytecodeHelper.IREM, 1, Kind.OPERATOR), /** Remainder long */ - LREM(ClassFile.LREM, 1, Kind.OPERATOR, TypeKind.LONG), + LREM(RawBytecodeHelper.LREM, 1, Kind.OPERATOR), /** Remainder float */ - FREM(ClassFile.FREM, 1, Kind.OPERATOR, TypeKind.FLOAT), + FREM(RawBytecodeHelper.FREM, 1, Kind.OPERATOR), /** Remainder double */ - DREM(ClassFile.DREM, 1, Kind.OPERATOR, TypeKind.DOUBLE), + DREM(RawBytecodeHelper.DREM, 1, Kind.OPERATOR), /** Negate int */ - INEG(ClassFile.INEG, 1, Kind.OPERATOR, TypeKind.INT), + INEG(RawBytecodeHelper.INEG, 1, Kind.OPERATOR), /** Negate long */ - LNEG(ClassFile.LNEG, 1, Kind.OPERATOR, TypeKind.LONG), + LNEG(RawBytecodeHelper.LNEG, 1, Kind.OPERATOR), /** Negate float */ - FNEG(ClassFile.FNEG, 1, Kind.OPERATOR, TypeKind.FLOAT), + FNEG(RawBytecodeHelper.FNEG, 1, Kind.OPERATOR), /** Negate double */ - DNEG(ClassFile.DNEG, 1, Kind.OPERATOR, TypeKind.DOUBLE), + DNEG(RawBytecodeHelper.DNEG, 1, Kind.OPERATOR), /** Shift left int */ - ISHL(ClassFile.ISHL, 1, Kind.OPERATOR, TypeKind.INT), + ISHL(RawBytecodeHelper.ISHL, 1, Kind.OPERATOR), /** Shift left long */ - LSHL(ClassFile.LSHL, 1, Kind.OPERATOR, TypeKind.LONG), + LSHL(RawBytecodeHelper.LSHL, 1, Kind.OPERATOR), /** Shift right int */ - ISHR(ClassFile.ISHR, 1, Kind.OPERATOR, TypeKind.INT), + ISHR(RawBytecodeHelper.ISHR, 1, Kind.OPERATOR), /** Shift right long */ - LSHR(ClassFile.LSHR, 1, Kind.OPERATOR, TypeKind.LONG), + LSHR(RawBytecodeHelper.LSHR, 1, Kind.OPERATOR), /** Logical shift right int */ - IUSHR(ClassFile.IUSHR, 1, Kind.OPERATOR, TypeKind.INT), + IUSHR(RawBytecodeHelper.IUSHR, 1, Kind.OPERATOR), /** Logical shift right long */ - LUSHR(ClassFile.LUSHR, 1, Kind.OPERATOR, TypeKind.LONG), + LUSHR(RawBytecodeHelper.LUSHR, 1, Kind.OPERATOR), /** Boolean AND int */ - IAND(ClassFile.IAND, 1, Kind.OPERATOR, TypeKind.INT), + IAND(RawBytecodeHelper.IAND, 1, Kind.OPERATOR), /** Boolean AND long */ - LAND(ClassFile.LAND, 1, Kind.OPERATOR, TypeKind.LONG), + LAND(RawBytecodeHelper.LAND, 1, Kind.OPERATOR), /** Boolean OR int */ - IOR(ClassFile.IOR, 1, Kind.OPERATOR, TypeKind.INT), + IOR(RawBytecodeHelper.IOR, 1, Kind.OPERATOR), /** Boolean OR long */ - LOR(ClassFile.LOR, 1, Kind.OPERATOR, TypeKind.LONG), + LOR(RawBytecodeHelper.LOR, 1, Kind.OPERATOR), /** Boolean XOR int */ - IXOR(ClassFile.IXOR, 1, Kind.OPERATOR, TypeKind.INT), + IXOR(RawBytecodeHelper.IXOR, 1, Kind.OPERATOR), /** Boolean XOR long */ - LXOR(ClassFile.LXOR, 1, Kind.OPERATOR, TypeKind.LONG), + LXOR(RawBytecodeHelper.LXOR, 1, Kind.OPERATOR), /** Increment local variable by constant */ - IINC(ClassFile.IINC, 3, Kind.INCREMENT, TypeKind.INT, -1), + IINC(RawBytecodeHelper.IINC, 3, Kind.INCREMENT), /** Convert int to long */ - I2L(ClassFile.I2L, 1, Kind.CONVERT, TypeKind.INT, TypeKind.LONG), + I2L(RawBytecodeHelper.I2L, 1, Kind.CONVERT), /** Convert int to float */ - I2F(ClassFile.I2F, 1, Kind.CONVERT, TypeKind.INT, TypeKind.FLOAT), + I2F(RawBytecodeHelper.I2F, 1, Kind.CONVERT), /** Convert int to double */ - I2D(ClassFile.I2D, 1, Kind.CONVERT, TypeKind.INT, TypeKind.DOUBLE), + I2D(RawBytecodeHelper.I2D, 1, Kind.CONVERT), /** Convert long to int */ - L2I(ClassFile.L2I, 1, Kind.CONVERT, TypeKind.LONG, TypeKind.INT), + L2I(RawBytecodeHelper.L2I, 1, Kind.CONVERT), /** Convert long to float */ - L2F(ClassFile.L2F, 1, Kind.CONVERT, TypeKind.LONG, TypeKind.FLOAT), + L2F(RawBytecodeHelper.L2F, 1, Kind.CONVERT), /** Convert long to double */ - L2D(ClassFile.L2D, 1, Kind.CONVERT, TypeKind.LONG, TypeKind.DOUBLE), + L2D(RawBytecodeHelper.L2D, 1, Kind.CONVERT), /** Convert float to int */ - F2I(ClassFile.F2I, 1, Kind.CONVERT, TypeKind.FLOAT, TypeKind.INT), + F2I(RawBytecodeHelper.F2I, 1, Kind.CONVERT), /** Convert float to long */ - F2L(ClassFile.F2L, 1, Kind.CONVERT, TypeKind.FLOAT, TypeKind.LONG), + F2L(RawBytecodeHelper.F2L, 1, Kind.CONVERT), /** Convert float to double */ - F2D(ClassFile.F2D, 1, Kind.CONVERT, TypeKind.FLOAT, TypeKind.DOUBLE), + F2D(RawBytecodeHelper.F2D, 1, Kind.CONVERT), /** Convert double to int */ - D2I(ClassFile.D2I, 1, Kind.CONVERT, TypeKind.DOUBLE, TypeKind.INT), + D2I(RawBytecodeHelper.D2I, 1, Kind.CONVERT), /** Convert double to long */ - D2L(ClassFile.D2L, 1, Kind.CONVERT, TypeKind.DOUBLE, TypeKind.LONG), + D2L(RawBytecodeHelper.D2L, 1, Kind.CONVERT), /** Convert double to float */ - D2F(ClassFile.D2F, 1, Kind.CONVERT, TypeKind.DOUBLE, TypeKind.FLOAT), + D2F(RawBytecodeHelper.D2F, 1, Kind.CONVERT), /** Convert int to byte */ - I2B(ClassFile.I2B, 1, Kind.CONVERT, TypeKind.INT, TypeKind.BYTE), + I2B(RawBytecodeHelper.I2B, 1, Kind.CONVERT), /** Convert int to char */ - I2C(ClassFile.I2C, 1, Kind.CONVERT, TypeKind.INT, TypeKind.CHAR), + I2C(RawBytecodeHelper.I2C, 1, Kind.CONVERT), /** Convert int to short */ - I2S(ClassFile.I2S, 1, Kind.CONVERT, TypeKind.INT, TypeKind.SHORT), + I2S(RawBytecodeHelper.I2S, 1, Kind.CONVERT), /** Compare long */ - LCMP(ClassFile.LCMP, 1, Kind.OPERATOR, TypeKind.LONG), + LCMP(RawBytecodeHelper.LCMP, 1, Kind.OPERATOR), /** Compare float */ - FCMPL(ClassFile.FCMPL, 1, Kind.OPERATOR, TypeKind.FLOAT), + FCMPL(RawBytecodeHelper.FCMPL, 1, Kind.OPERATOR), /** Compare float */ - FCMPG(ClassFile.FCMPG, 1, Kind.OPERATOR, TypeKind.FLOAT), + FCMPG(RawBytecodeHelper.FCMPG, 1, Kind.OPERATOR), /** Compare double */ - DCMPL(ClassFile.DCMPL, 1, Kind.OPERATOR, TypeKind.DOUBLE), + DCMPL(RawBytecodeHelper.DCMPL, 1, Kind.OPERATOR), /** Compare double */ - DCMPG(ClassFile.DCMPG, 1, Kind.OPERATOR, TypeKind.DOUBLE), + DCMPG(RawBytecodeHelper.DCMPG, 1, Kind.OPERATOR), /** Branch if int comparison with zero succeeds */ - IFEQ(ClassFile.IFEQ, 3, Kind.BRANCH, TypeKind.INT), + IFEQ(RawBytecodeHelper.IFEQ, 3, Kind.BRANCH), /** Branch if int comparison with zero succeeds */ - IFNE(ClassFile.IFNE, 3, Kind.BRANCH, TypeKind.INT), + IFNE(RawBytecodeHelper.IFNE, 3, Kind.BRANCH), /** Branch if int comparison with zero succeeds */ - IFLT(ClassFile.IFLT, 3, Kind.BRANCH, TypeKind.INT), + IFLT(RawBytecodeHelper.IFLT, 3, Kind.BRANCH), /** Branch if int comparison with zero succeeds */ - IFGE(ClassFile.IFGE, 3, Kind.BRANCH, TypeKind.INT), + IFGE(RawBytecodeHelper.IFGE, 3, Kind.BRANCH), /** Branch if int comparison with zero succeeds */ - IFGT(ClassFile.IFGT, 3, Kind.BRANCH, TypeKind.INT), + IFGT(RawBytecodeHelper.IFGT, 3, Kind.BRANCH), /** Branch if int comparison with zero succeeds */ - IFLE(ClassFile.IFLE, 3, Kind.BRANCH, TypeKind.INT), + IFLE(RawBytecodeHelper.IFLE, 3, Kind.BRANCH), /** Branch if int comparison succeeds */ - IF_ICMPEQ(ClassFile.IF_ICMPEQ, 3, Kind.BRANCH, TypeKind.INT), + IF_ICMPEQ(RawBytecodeHelper.IF_ICMPEQ, 3, Kind.BRANCH), /** Branch if int comparison succeeds */ - IF_ICMPNE(ClassFile.IF_ICMPNE, 3, Kind.BRANCH, TypeKind.INT), + IF_ICMPNE(RawBytecodeHelper.IF_ICMPNE, 3, Kind.BRANCH), /** Branch if int comparison succeeds */ - IF_ICMPLT(ClassFile.IF_ICMPLT, 3, Kind.BRANCH, TypeKind.INT), + IF_ICMPLT(RawBytecodeHelper.IF_ICMPLT, 3, Kind.BRANCH), /** Branch if int comparison succeeds */ - IF_ICMPGE(ClassFile.IF_ICMPGE, 3, Kind.BRANCH, TypeKind.INT), + IF_ICMPGE(RawBytecodeHelper.IF_ICMPGE, 3, Kind.BRANCH), /** Branch if int comparison succeeds */ - IF_ICMPGT(ClassFile.IF_ICMPGT, 3, Kind.BRANCH, TypeKind.INT), + IF_ICMPGT(RawBytecodeHelper.IF_ICMPGT, 3, Kind.BRANCH), /** Branch if int comparison succeeds */ - IF_ICMPLE(ClassFile.IF_ICMPLE, 3, Kind.BRANCH, TypeKind.INT), + IF_ICMPLE(RawBytecodeHelper.IF_ICMPLE, 3, Kind.BRANCH), /** Branch if reference comparison succeeds */ - IF_ACMPEQ(ClassFile.IF_ACMPEQ, 3, Kind.BRANCH, TypeKind.REFERENCE), + IF_ACMPEQ(RawBytecodeHelper.IF_ACMPEQ, 3, Kind.BRANCH), /** Branch if reference comparison succeeds */ - IF_ACMPNE(ClassFile.IF_ACMPNE, 3, Kind.BRANCH, TypeKind.REFERENCE), + IF_ACMPNE(RawBytecodeHelper.IF_ACMPNE, 3, Kind.BRANCH), /** Branch always */ - GOTO(ClassFile.GOTO, 3, Kind.BRANCH, TypeKind.VOID), + GOTO(RawBytecodeHelper.GOTO, 3, Kind.BRANCH), /** * Jump subroutine is discontinued opcode * @see java.lang.classfile.instruction.DiscontinuedInstruction */ - JSR(ClassFile.JSR, 3, Kind.DISCONTINUED_JSR), + JSR(RawBytecodeHelper.JSR, 3, Kind.DISCONTINUED_JSR), /** * Return from subroutine is discontinued opcode * @see java.lang.classfile.instruction.DiscontinuedInstruction */ - RET(ClassFile.RET, 2, Kind.DISCONTINUED_RET), + RET(RawBytecodeHelper.RET, 2, Kind.DISCONTINUED_RET), /** Access jump table by index and jump */ - TABLESWITCH(ClassFile.TABLESWITCH, -1, Kind.TABLE_SWITCH), + TABLESWITCH(RawBytecodeHelper.TABLESWITCH, -1, Kind.TABLE_SWITCH), /** Access jump table by key match and jump */ - LOOKUPSWITCH(ClassFile.LOOKUPSWITCH, -1, Kind.LOOKUP_SWITCH), + LOOKUPSWITCH(RawBytecodeHelper.LOOKUPSWITCH, -1, Kind.LOOKUP_SWITCH), /** Return int from method */ - IRETURN(ClassFile.IRETURN, 1, Kind.RETURN, TypeKind.INT), + IRETURN(RawBytecodeHelper.IRETURN, 1, Kind.RETURN), /** Return long from method */ - LRETURN(ClassFile.LRETURN, 1, Kind.RETURN, TypeKind.LONG), + LRETURN(RawBytecodeHelper.LRETURN, 1, Kind.RETURN), /** Return float from method */ - FRETURN(ClassFile.FRETURN, 1, Kind.RETURN, TypeKind.FLOAT), + FRETURN(RawBytecodeHelper.FRETURN, 1, Kind.RETURN), /** Return double from method */ - DRETURN(ClassFile.DRETURN, 1, Kind.RETURN, TypeKind.DOUBLE), + DRETURN(RawBytecodeHelper.DRETURN, 1, Kind.RETURN), /** Return reference from method */ - ARETURN(ClassFile.ARETURN, 1, Kind.RETURN, TypeKind.REFERENCE), + ARETURN(RawBytecodeHelper.ARETURN, 1, Kind.RETURN), /** Return void from method */ - RETURN(ClassFile.RETURN, 1, Kind.RETURN, TypeKind.VOID), + RETURN(RawBytecodeHelper.RETURN, 1, Kind.RETURN), /** Get static field from class */ - GETSTATIC(ClassFile.GETSTATIC, 3, Kind.FIELD_ACCESS), + GETSTATIC(RawBytecodeHelper.GETSTATIC, 3, Kind.FIELD_ACCESS), /** Set static field in class */ - PUTSTATIC(ClassFile.PUTSTATIC, 3, Kind.FIELD_ACCESS), + PUTSTATIC(RawBytecodeHelper.PUTSTATIC, 3, Kind.FIELD_ACCESS), /** Fetch field from object */ - GETFIELD(ClassFile.GETFIELD, 3, Kind.FIELD_ACCESS), + GETFIELD(RawBytecodeHelper.GETFIELD, 3, Kind.FIELD_ACCESS), /** Set field in object */ - PUTFIELD(ClassFile.PUTFIELD, 3, Kind.FIELD_ACCESS), + PUTFIELD(RawBytecodeHelper.PUTFIELD, 3, Kind.FIELD_ACCESS), /** Invoke instance method; dispatch based on class */ - INVOKEVIRTUAL(ClassFile.INVOKEVIRTUAL, 3, Kind.INVOKE), + INVOKEVIRTUAL(RawBytecodeHelper.INVOKEVIRTUAL, 3, Kind.INVOKE), /** * Invoke instance method; direct invocation of instance initialization * methods and methods of the current class and its supertypes */ - INVOKESPECIAL(ClassFile.INVOKESPECIAL, 3, Kind.INVOKE), + INVOKESPECIAL(RawBytecodeHelper.INVOKESPECIAL, 3, Kind.INVOKE), /** Invoke a class (static) method */ - INVOKESTATIC(ClassFile.INVOKESTATIC, 3, Kind.INVOKE), + INVOKESTATIC(RawBytecodeHelper.INVOKESTATIC, 3, Kind.INVOKE), /** Invoke interface method */ - INVOKEINTERFACE(ClassFile.INVOKEINTERFACE, 5, Kind.INVOKE), + INVOKEINTERFACE(RawBytecodeHelper.INVOKEINTERFACE, 5, Kind.INVOKE), /** Invoke a dynamically-computed call site */ - INVOKEDYNAMIC(ClassFile.INVOKEDYNAMIC, 5, Kind.INVOKE_DYNAMIC), + INVOKEDYNAMIC(RawBytecodeHelper.INVOKEDYNAMIC, 5, Kind.INVOKE_DYNAMIC), /** Create new object */ - NEW(ClassFile.NEW, 3, Kind.NEW_OBJECT), + NEW(RawBytecodeHelper.NEW, 3, Kind.NEW_OBJECT), /** Create new array */ - NEWARRAY(ClassFile.NEWARRAY, 2, Kind.NEW_PRIMITIVE_ARRAY), + NEWARRAY(RawBytecodeHelper.NEWARRAY, 2, Kind.NEW_PRIMITIVE_ARRAY), /** Create new array of reference */ - ANEWARRAY(ClassFile.ANEWARRAY, 3, Kind.NEW_REF_ARRAY), + ANEWARRAY(RawBytecodeHelper.ANEWARRAY, 3, Kind.NEW_REF_ARRAY), /** Get length of array */ - ARRAYLENGTH(ClassFile.ARRAYLENGTH, 1, Kind.OPERATOR, TypeKind.INT), + ARRAYLENGTH(RawBytecodeHelper.ARRAYLENGTH, 1, Kind.OPERATOR), /** Throw exception or error */ - ATHROW(ClassFile.ATHROW, 1, Kind.THROW_EXCEPTION), + ATHROW(RawBytecodeHelper.ATHROW, 1, Kind.THROW_EXCEPTION), /** Check whether object is of given type */ - CHECKCAST(ClassFile.CHECKCAST, 3, Kind.TYPE_CHECK), + CHECKCAST(RawBytecodeHelper.CHECKCAST, 3, Kind.TYPE_CHECK), /** Determine if object is of given type */ - INSTANCEOF(ClassFile.INSTANCEOF, 3, Kind.TYPE_CHECK), + INSTANCEOF(RawBytecodeHelper.INSTANCEOF, 3, Kind.TYPE_CHECK), /** Enter monitor for object */ - MONITORENTER(ClassFile.MONITORENTER, 1, Kind.MONITOR), + MONITORENTER(RawBytecodeHelper.MONITORENTER, 1, Kind.MONITOR), /** Exit monitor for object */ - MONITOREXIT(ClassFile.MONITOREXIT, 1, Kind.MONITOR), + MONITOREXIT(RawBytecodeHelper.MONITOREXIT, 1, Kind.MONITOR), /** Create new multidimensional array */ - MULTIANEWARRAY(ClassFile.MULTIANEWARRAY, 4, Kind.NEW_MULTI_ARRAY), + MULTIANEWARRAY(RawBytecodeHelper.MULTIANEWARRAY, 4, Kind.NEW_MULTI_ARRAY), /** Branch if reference is null */ - IFNULL(ClassFile.IFNULL, 3, Kind.BRANCH, TypeKind.REFERENCE), + IFNULL(RawBytecodeHelper.IFNULL, 3, Kind.BRANCH), /** Branch if reference not null */ - IFNONNULL(ClassFile.IFNONNULL, 3, Kind.BRANCH, TypeKind.REFERENCE), + IFNONNULL(RawBytecodeHelper.IFNONNULL, 3, Kind.BRANCH), /** Branch always (wide index) */ - GOTO_W(ClassFile.GOTO_W, 5, Kind.BRANCH, TypeKind.VOID), + GOTO_W(RawBytecodeHelper.GOTO_W, 5, Kind.BRANCH), /** * Jump subroutine (wide index) is discontinued opcode * @see java.lang.classfile.instruction.DiscontinuedInstruction */ - JSR_W(ClassFile.JSR_W, 5, Kind.DISCONTINUED_JSR), + JSR_W(RawBytecodeHelper.JSR_W, 5, Kind.DISCONTINUED_JSR), /** Load int from local variable (wide index) */ - ILOAD_W((ClassFile.WIDE << 8) | ClassFile.ILOAD, 4, Kind.LOAD, TypeKind.INT, -1), + ILOAD_W((RawBytecodeHelper.WIDE << 8) | RawBytecodeHelper.ILOAD, 4, Kind.LOAD), /** Load long from local variable (wide index) */ - LLOAD_W((ClassFile.WIDE << 8) | ClassFile.LLOAD, 4, Kind.LOAD, TypeKind.LONG, -1), + LLOAD_W((RawBytecodeHelper.WIDE << 8) | RawBytecodeHelper.LLOAD, 4, Kind.LOAD), /** Load float from local variable (wide index) */ - FLOAD_W((ClassFile.WIDE << 8) | ClassFile.FLOAD, 4, Kind.LOAD, TypeKind.FLOAT, -1), + FLOAD_W((RawBytecodeHelper.WIDE << 8) | RawBytecodeHelper.FLOAD, 4, Kind.LOAD), /** Load double from local variable (wide index) */ - DLOAD_W((ClassFile.WIDE << 8) | ClassFile.DLOAD, 4, Kind.LOAD, TypeKind.DOUBLE, -1), + DLOAD_W((RawBytecodeHelper.WIDE << 8) | RawBytecodeHelper.DLOAD, 4, Kind.LOAD), /** Load reference from local variable (wide index) */ - ALOAD_W((ClassFile.WIDE << 8) | ClassFile.ALOAD, 4, Kind.LOAD, TypeKind.REFERENCE, -1), + ALOAD_W((RawBytecodeHelper.WIDE << 8) | RawBytecodeHelper.ALOAD, 4, Kind.LOAD), /** Store int into local variable (wide index) */ - ISTORE_W((ClassFile.WIDE << 8) | ClassFile.ISTORE, 4, Kind.STORE, TypeKind.INT, -1), + ISTORE_W((RawBytecodeHelper.WIDE << 8) | RawBytecodeHelper.ISTORE, 4, Kind.STORE), /** Store long into local variable (wide index) */ - LSTORE_W((ClassFile.WIDE << 8) | ClassFile.LSTORE, 4, Kind.STORE, TypeKind.LONG, -1), + LSTORE_W((RawBytecodeHelper.WIDE << 8) | RawBytecodeHelper.LSTORE, 4, Kind.STORE), /** Store float into local variable (wide index) */ - FSTORE_W((ClassFile.WIDE << 8) | ClassFile.FSTORE, 4, Kind.STORE, TypeKind.FLOAT, -1), + FSTORE_W((RawBytecodeHelper.WIDE << 8) | RawBytecodeHelper.FSTORE, 4, Kind.STORE), /** Store double into local variable (wide index) */ - DSTORE_W((ClassFile.WIDE << 8) | ClassFile.DSTORE, 4, Kind.STORE, TypeKind.DOUBLE, -1), + DSTORE_W((RawBytecodeHelper.WIDE << 8) | RawBytecodeHelper.DSTORE, 4, Kind.STORE), /** Store reference into local variable (wide index) */ - ASTORE_W((ClassFile.WIDE << 8) | ClassFile.ASTORE, 4, Kind.STORE, TypeKind.REFERENCE, -1), + ASTORE_W((RawBytecodeHelper.WIDE << 8) | RawBytecodeHelper.ASTORE, 4, Kind.STORE), /** * Return from subroutine (wide index) is discontinued opcode * @see java.lang.classfile.instruction.DiscontinuedInstruction */ - RET_W((ClassFile.WIDE << 8) | ClassFile.RET, 4, Kind.DISCONTINUED_RET), + RET_W((RawBytecodeHelper.WIDE << 8) | RawBytecodeHelper.RET, 4, Kind.DISCONTINUED_RET), /** Increment local variable by constant (wide index) */ - IINC_W((ClassFile.WIDE << 8) | ClassFile.IINC, 6, Kind.INCREMENT, TypeKind.INT, -1); + IINC_W((RawBytecodeHelper.WIDE << 8) | RawBytecodeHelper.IINC, 6, Kind.INCREMENT); /** * Kinds of opcodes. @@ -1078,59 +1077,41 @@ public enum Opcode { private final int bytecode; private final int sizeIfFixed; private final Kind kind; - private final TypeKind primaryTypeKind; - private final TypeKind secondaryTypeKind; - private final int slot; - private final ConstantDesc constantValue; Opcode(int bytecode, int sizeIfFixed, Kind kind) { - this(bytecode, sizeIfFixed, kind, null, null, -1, null); - } - - Opcode(int bytecode, int sizeIfFixed, Kind kind, TypeKind typeKind) { - this(bytecode, sizeIfFixed, kind, typeKind, null, -1, null); - } - - Opcode(int bytecode, int sizeIfFixed, Kind kind, TypeKind typeKind, int slot) { - this(bytecode, sizeIfFixed, kind, typeKind, null, slot, null); - } - - Opcode(int bytecode, int sizeIfFixed, Kind kind, TypeKind typeKind, int slot, ConstantDesc constantValue) { - this(bytecode, sizeIfFixed, kind, typeKind, null, slot, constantValue); - } - - Opcode(int bytecode, int sizeIfFixed, Kind kind, TypeKind primaryTypeKind, TypeKind secondaryTypeKind) { - this(bytecode, sizeIfFixed, kind, primaryTypeKind, secondaryTypeKind, 0, null); - } - - Opcode(int bytecode, - int sizeIfFixed, - Kind kind, - TypeKind primaryTypeKind, - TypeKind secondaryTypeKind, - int slot, - ConstantDesc constantValue) { this.bytecode = bytecode; this.sizeIfFixed = sizeIfFixed; this.kind = kind; - this.primaryTypeKind = primaryTypeKind; - this.secondaryTypeKind = secondaryTypeKind; - this.slot = slot; - this.constantValue = constantValue; } /** - * {@return bytecode} + * {@return the opcode value} For {@linkplain #isWide() wide} pseudo-opcodes, returns the + * first 2 bytes of the instruction, which are the wide opcode {@code 196} ({@code 0xC4}) + * and the functional opcode, as a U2 value. */ public int bytecode() { return bytecode; } /** - * {@return true if the instruction has extended local variable index by additional bytes} + * {@return true if this is a pseudo-opcode modified by wide opcode} + * + * @see #ILOAD_W + * @see #LLOAD_W + * @see #FLOAD_W + * @see #DLOAD_W + * @see #ALOAD_W + * @see #ISTORE_W + * @see #LSTORE_W + * @see #FSTORE_W + * @see #DSTORE_W + * @see #ASTORE_W + * @see #RET_W + * @see #IINC_W */ public boolean isWide() { return bytecode > 255; } /** - * {@return size of the instruction if fixed, or -1 otherwise} + * {@return size of the instruction in bytes if fixed, or -1 otherwise} This size includes + * the opcode itself. */ public int sizeIfFixed() { return sizeIfFixed; } @@ -1138,42 +1119,4 @@ public enum Opcode { * {@return instruction kind} */ public Kind kind() { return kind; } - - /** - * {@return primary type kind for instructions operating with at least one type, or null otherwise} - */ - public TypeKind primaryTypeKind() { - return primaryTypeKind; - } - - /** - * {@return secondary type kind for instructions operating with two types, or null otherwise} - */ - public TypeKind secondaryTypeKind() { - return secondaryTypeKind; - } - - /** - * {@return local variable slot for instructions operating with local variable, or -1 otherwise} - */ - public int slot() { - return slot; - } - - /** - * {@return constant value for constant instructions, or null otherwise} - */ - public ConstantDesc constantValue() { - return constantValue; - } - - /** - * {@return true if the instruction represents an unconditional branch} - */ - public boolean isUnconditionalBranch() { - return switch (this) { - case GOTO, ATHROW, GOTO_W, LOOKUPSWITCH, TABLESWITCH -> true; - default -> kind() == Kind.RETURN; - }; - } } diff --git a/src/java.base/share/classes/java/lang/classfile/TypeAnnotation.java b/src/java.base/share/classes/java/lang/classfile/TypeAnnotation.java index b6c9aec76a1..139c8eef835 100644 --- a/src/java.base/share/classes/java/lang/classfile/TypeAnnotation.java +++ b/src/java.base/share/classes/java/lang/classfile/TypeAnnotation.java @@ -31,31 +31,10 @@ import java.lang.classfile.attribute.RuntimeInvisibleTypeAnnotationsAttribute; import java.lang.classfile.attribute.RuntimeVisibleTypeAnnotationsAttribute; import jdk.internal.classfile.impl.TargetInfoImpl; import jdk.internal.classfile.impl.UnboundAttribute; - -import static java.lang.classfile.ClassFile.TAT_CAST; -import static java.lang.classfile.ClassFile.TAT_CLASS_EXTENDS; -import static java.lang.classfile.ClassFile.TAT_CLASS_TYPE_PARAMETER; -import static java.lang.classfile.ClassFile.TAT_CLASS_TYPE_PARAMETER_BOUND; -import static java.lang.classfile.ClassFile.TAT_CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT; -import static java.lang.classfile.ClassFile.TAT_CONSTRUCTOR_REFERENCE; -import static java.lang.classfile.ClassFile.TAT_CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT; -import static java.lang.classfile.ClassFile.TAT_EXCEPTION_PARAMETER; -import static java.lang.classfile.ClassFile.TAT_FIELD; -import static java.lang.classfile.ClassFile.TAT_INSTANCEOF; -import static java.lang.classfile.ClassFile.TAT_LOCAL_VARIABLE; -import static java.lang.classfile.ClassFile.TAT_METHOD_FORMAL_PARAMETER; -import static java.lang.classfile.ClassFile.TAT_METHOD_INVOCATION_TYPE_ARGUMENT; -import static java.lang.classfile.ClassFile.TAT_METHOD_RECEIVER; -import static java.lang.classfile.ClassFile.TAT_METHOD_REFERENCE; -import static java.lang.classfile.ClassFile.TAT_METHOD_REFERENCE_TYPE_ARGUMENT; -import static java.lang.classfile.ClassFile.TAT_METHOD_RETURN; -import static java.lang.classfile.ClassFile.TAT_METHOD_TYPE_PARAMETER; -import static java.lang.classfile.ClassFile.TAT_METHOD_TYPE_PARAMETER_BOUND; -import static java.lang.classfile.ClassFile.TAT_NEW; -import static java.lang.classfile.ClassFile.TAT_RESOURCE_VARIABLE; -import static java.lang.classfile.ClassFile.TAT_THROWS; import jdk.internal.javac.PreviewFeature; +import static java.lang.classfile.TypeAnnotation.TargetInfo.*; + /** * Models a {@code type_annotation} structure (JVMS {@jvms 4.7.20}). This model * indicates the annotated type within a declaration or expression and the part @@ -87,70 +66,70 @@ public sealed interface TypeAnnotation @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) public enum TargetType { /** For annotations on a class type parameter declaration. */ - CLASS_TYPE_PARAMETER(TAT_CLASS_TYPE_PARAMETER, 1), + CLASS_TYPE_PARAMETER(TARGET_CLASS_TYPE_PARAMETER, 1), /** For annotations on a method type parameter declaration. */ - METHOD_TYPE_PARAMETER(TAT_METHOD_TYPE_PARAMETER, 1), + METHOD_TYPE_PARAMETER(TARGET_METHOD_TYPE_PARAMETER, 1), /** For annotations on the type of an "extends" or "implements" clause. */ - CLASS_EXTENDS(TAT_CLASS_EXTENDS, 2), + CLASS_EXTENDS(TARGET_CLASS_EXTENDS, 2), /** For annotations on a bound of a type parameter of a class. */ - CLASS_TYPE_PARAMETER_BOUND(TAT_CLASS_TYPE_PARAMETER_BOUND, 2), + CLASS_TYPE_PARAMETER_BOUND(TARGET_CLASS_TYPE_PARAMETER_BOUND, 2), /** For annotations on a bound of a type parameter of a method. */ - METHOD_TYPE_PARAMETER_BOUND(TAT_METHOD_TYPE_PARAMETER_BOUND, 2), + METHOD_TYPE_PARAMETER_BOUND(TARGET_METHOD_TYPE_PARAMETER_BOUND, 2), /** For annotations on a field. */ - FIELD(TAT_FIELD, 0), + FIELD(TARGET_FIELD, 0), /** For annotations on a method return type. */ - METHOD_RETURN(TAT_METHOD_RETURN, 0), + METHOD_RETURN(TARGET_METHOD_RETURN, 0), /** For annotations on the method receiver. */ - METHOD_RECEIVER(TAT_METHOD_RECEIVER, 0), + METHOD_RECEIVER(TARGET_METHOD_RECEIVER, 0), /** For annotations on a method parameter. */ - METHOD_FORMAL_PARAMETER(TAT_METHOD_FORMAL_PARAMETER, 1), + METHOD_FORMAL_PARAMETER(TARGET_METHOD_FORMAL_PARAMETER, 1), /** For annotations on a throws clause in a method declaration. */ - THROWS(TAT_THROWS, 2), + THROWS(TARGET_THROWS, 2), /** For annotations on a local variable. */ - LOCAL_VARIABLE(TAT_LOCAL_VARIABLE, -1), + LOCAL_VARIABLE(TARGET_LOCAL_VARIABLE, -1), /** For annotations on a resource variable. */ - RESOURCE_VARIABLE(TAT_RESOURCE_VARIABLE, -1), + RESOURCE_VARIABLE(TARGET_RESOURCE_VARIABLE, -1), /** For annotations on an exception parameter. */ - EXCEPTION_PARAMETER(TAT_EXCEPTION_PARAMETER, 2), + EXCEPTION_PARAMETER(TARGET_EXCEPTION_PARAMETER, 2), /** For annotations on a type test. */ - INSTANCEOF(TAT_INSTANCEOF, 2), + INSTANCEOF(TARGET_INSTANCEOF, 2), /** For annotations on an object creation expression. */ - NEW(TAT_NEW, 2), + NEW(TARGET_NEW, 2), /** For annotations on a constructor reference receiver. */ - CONSTRUCTOR_REFERENCE(TAT_CONSTRUCTOR_REFERENCE, 2), + CONSTRUCTOR_REFERENCE(TARGET_CONSTRUCTOR_REFERENCE, 2), /** For annotations on a method reference receiver. */ - METHOD_REFERENCE(TAT_METHOD_REFERENCE, 2), + METHOD_REFERENCE(TARGET_METHOD_REFERENCE, 2), /** For annotations on a typecast. */ - CAST(TAT_CAST, 3), + CAST(TARGET_CAST, 3), /** For annotations on a type argument of an object creation expression. */ - CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT(TAT_CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT, 3), + CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT(TARGET_CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT, 3), /** For annotations on a type argument of a method call. */ - METHOD_INVOCATION_TYPE_ARGUMENT(TAT_METHOD_INVOCATION_TYPE_ARGUMENT, 3), + METHOD_INVOCATION_TYPE_ARGUMENT(TARGET_METHOD_INVOCATION_TYPE_ARGUMENT, 3), /** For annotations on a type argument of a constructor reference. */ - CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT(TAT_CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT, 3), + CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT(TARGET_CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT, 3), /** For annotations on a type argument of a method reference. */ - METHOD_REFERENCE_TYPE_ARGUMENT(TAT_METHOD_REFERENCE_TYPE_ARGUMENT, 3); + METHOD_REFERENCE_TYPE_ARGUMENT(TARGET_METHOD_REFERENCE_TYPE_ARGUMENT, 3); private final int targetTypeValue; private final int sizeIfFixed; @@ -162,6 +141,11 @@ public sealed interface TypeAnnotation /** * {@return the target type value} + * + * @apiNote + * {@code TARGET_}-prefixed constants in {@link TargetInfo}, such as {@link + * TargetInfo#TARGET_CLASS_TYPE_PARAMETER}, describe the possible return + * values of this method. */ public int targetTypeValue() { return targetTypeValue; @@ -214,6 +198,146 @@ public sealed interface TypeAnnotation @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) sealed interface TargetInfo { + /** + * The {@linkplain TargetType#targetTypeValue() value} of type annotation {@linkplain + * #targetType target type} {@link TargetType#CLASS_TYPE_PARAMETER CLASS_TYPE_PARAMETER}. + */ + int TARGET_CLASS_TYPE_PARAMETER = 0x00; + + /** + * The {@linkplain TargetType#targetTypeValue() value} of type annotation {@linkplain + * #targetType target type} {@link TargetType#METHOD_TYPE_PARAMETER METHOD_TYPE_PARAMETER}. + */ + int TARGET_METHOD_TYPE_PARAMETER = 0x01; + + /** + * The {@linkplain TargetType#targetTypeValue() value} of type annotation {@linkplain + * #targetType target type} {@link TargetType#CLASS_EXTENDS CLASS_EXTENDS}. + */ + int TARGET_CLASS_EXTENDS = 0x10; + + /** + * The {@linkplain TargetType#targetTypeValue() value} of type annotation {@linkplain + * #targetType target type} {@link TargetType#CLASS_TYPE_PARAMETER_BOUND + * CLASS_TYPE_PARAMETER_BOUND}. + */ + int TARGET_CLASS_TYPE_PARAMETER_BOUND = 0x11; + + /** + * The {@linkplain TargetType#targetTypeValue() value} of type annotation {@linkplain + * #targetType target type} {@link TargetType#METHOD_TYPE_PARAMETER_BOUND + * METHOD_TYPE_PARAMETER_BOUND}. + */ + int TARGET_METHOD_TYPE_PARAMETER_BOUND = 0x12; + + /** + * The {@linkplain TargetType#targetTypeValue() value} of type annotation {@linkplain + * #targetType target type} {@link TargetType#FIELD FIELD}. + */ + int TARGET_FIELD = 0x13; + + /** + * The {@linkplain TargetType#targetTypeValue() value} of type annotation {@linkplain + * #targetType target type} {@link TargetType#METHOD_RETURN METHOD_RETURN}. + */ + int TARGET_METHOD_RETURN = 0x14; + + /** + * The {@linkplain TargetType#targetTypeValue() value} of type annotation {@linkplain + * #targetType target type} {@link TargetType#METHOD_RECEIVER METHOD_RECEIVER}. + */ + int TARGET_METHOD_RECEIVER = 0x15; + + /** + * The {@linkplain TargetType#targetTypeValue() value} of type annotation {@linkplain + * #targetType target type} {@link TargetType#METHOD_FORMAL_PARAMETER + * METHOD_FORMAL_PARAMETER}. + */ + int TARGET_METHOD_FORMAL_PARAMETER = 0x16; + + /** + * The {@linkplain TargetType#targetTypeValue() value} of type annotation {@linkplain + * #targetType target type} {@link TargetType#THROWS THROWS}. + */ + int TARGET_THROWS = 0x17; + + /** + * The {@linkplain TargetType#targetTypeValue() value} of type annotation {@linkplain + * #targetType target type} {@link TargetType#LOCAL_VARIABLE LOCAL_VARIABLE}. + */ + int TARGET_LOCAL_VARIABLE = 0x40; + + /** + * The {@linkplain TargetType#targetTypeValue() value} of type annotation {@linkplain + * #targetType target type} {@link TargetType#RESOURCE_VARIABLE RESOURCE_VARIABLE}. + */ + int TARGET_RESOURCE_VARIABLE = 0x41; + + /** + * The {@linkplain TargetType#targetTypeValue() value} of type annotation {@linkplain + * #targetType target type} {@link TargetType#EXCEPTION_PARAMETER EXCEPTION_PARAMETER}. + */ + int TARGET_EXCEPTION_PARAMETER = 0x42; + + /** + * The {@linkplain TargetType#targetTypeValue() value} of type annotation {@linkplain + * #targetType target type} {@link TargetType#INSTANCEOF INSTANCEOF}. + */ + int TARGET_INSTANCEOF = 0x43; + + /** + * The {@linkplain TargetType#targetTypeValue() value} of type annotation {@linkplain + * #targetType target type} {@link TargetType#NEW NEW}. + */ + int TARGET_NEW = 0x44; + + /** + * The {@linkplain TargetType#targetTypeValue() value} of type annotation {@linkplain + * #targetType target type} {@link TargetType#CONSTRUCTOR_REFERENCE + * CONSTRUCTOR_REFERENCE}. + */ + int TARGET_CONSTRUCTOR_REFERENCE = 0x45; + + /** + * The {@linkplain TargetType#targetTypeValue() value} of type annotation {@linkplain + * #targetType target type} {@link TargetType#METHOD_REFERENCE METHOD_REFERENCE}. + */ + int TARGET_METHOD_REFERENCE = 0x46; + + /** + * The {@linkplain TargetType#targetTypeValue() value} of type annotation {@linkplain + * #targetType target type} {@link TargetType#CAST CAST}. + */ + int TARGET_CAST = 0x47; + + /** + * The {@linkplain TargetType#targetTypeValue() value} of type annotation {@linkplain + * #targetType target type} {@link TargetType#CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT + * CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT}. + */ + int TARGET_CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT = 0x48; + + /** + * The {@linkplain TargetType#targetTypeValue() value} of type annotation {@linkplain + * #targetType target type} {@link TargetType#METHOD_INVOCATION_TYPE_ARGUMENT + * METHOD_INVOCATION_TYPE_ARGUMENT}. + */ + int TARGET_METHOD_INVOCATION_TYPE_ARGUMENT = 0x49; + + /** + * The {@linkplain TargetType#targetTypeValue() value} of type annotation {@linkplain + * #targetType target type} {@link TargetType#CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT + * CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT}. + */ + int TARGET_CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT = 0x4A; + + /** + * The {@linkplain TargetType#targetTypeValue() value} of type annotation {@linkplain + * #targetType target type} {@link TargetType#METHOD_REFERENCE_TYPE_ARGUMENT + * METHOD_REFERENCE_TYPE_ARGUMENT}. + */ + int TARGET_METHOD_REFERENCE_TYPE_ARGUMENT = 0x4B; + /** * {@return the type of the target} */ diff --git a/src/java.base/share/classes/java/lang/classfile/attribute/CharacterRangeInfo.java b/src/java.base/share/classes/java/lang/classfile/attribute/CharacterRangeInfo.java index 37abcb02713..126ba1037ce 100644 --- a/src/java.base/share/classes/java/lang/classfile/attribute/CharacterRangeInfo.java +++ b/src/java.base/share/classes/java/lang/classfile/attribute/CharacterRangeInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,8 @@ */ package java.lang.classfile.attribute; +import java.lang.classfile.instruction.CharacterRange; + import jdk.internal.classfile.impl.UnboundAttribute; import jdk.internal.javac.PreviewFeature; @@ -70,17 +72,17 @@ public sealed interface CharacterRangeInfo * The value of the flags item describes the kind of range. Multiple flags * may be set within flags. *

      - *
    • {@link java.lang.classfile.ClassFile#CRT_STATEMENT} Range is a Statement + *
    • {@link CharacterRange#FLAG_STATEMENT} Range is a Statement * (except ExpressionStatement), StatementExpression {@jls 14.8}, as well as each * VariableDeclaratorId = VariableInitializer of * LocalVariableDeclarationStatement {@jls 14.4} or FieldDeclaration {@jls 8.3} in the * grammar. - *
    • {@link java.lang.classfile.ClassFile#CRT_BLOCK} Range is a Block in the + *
    • {@link CharacterRange#FLAG_BLOCK} Range is a Block in the * grammar. - *
    • {@link java.lang.classfile.ClassFile#CRT_ASSIGNMENT} Range is an assignment + *
    • {@link CharacterRange#FLAG_ASSIGNMENT} Range is an assignment * expression - Expression1 AssignmentOperator Expression1 in the grammar as * well as increment and decrement expressions (both prefix and postfix). - *
    • {@link java.lang.classfile.ClassFile#CRT_FLOW_CONTROLLER} An expression + *
    • {@link CharacterRange#FLAG_FLOW_CONTROLLER} An expression * whose value will effect control flow. {@code Flowcon} in the following: *
            * if ( Flowcon ) Statement [else Statement]
      @@ -92,7 +94,7 @@ public sealed interface CharacterRangeInfo
            * Flowcon && Expression3
            * Flowcon ? Expression : Expression1
            * 
      - *
    • {@link java.lang.classfile.ClassFile#CRT_FLOW_TARGET} Statement or + *
    • {@link CharacterRange#FLAG_FLOW_TARGET} Statement or * expression effected by a CRT_FLOW_CONTROLLER. {@code Flowtarg} in the following: *
            * if ( Flowcon ) Flowtarg [else Flowtarg]
      @@ -103,11 +105,11 @@ public sealed interface CharacterRangeInfo
            * Flowcon && Flowtarg
            * Flowcon ? Flowtarg : Flowtarg
            * 
      - *
    • {@link java.lang.classfile.ClassFile#CRT_INVOKE} Method invocation. For + *
    • {@link CharacterRange#FLAG_INVOKE} Method invocation. For * example: Identifier Arguments. - *
    • {@link java.lang.classfile.ClassFile#CRT_CREATE} New object creation. For + *
    • {@link CharacterRange#FLAG_CREATE} New object creation. For * example: new Creator. - *
    • {@link java.lang.classfile.ClassFile#CRT_BRANCH_TRUE} A condition encoded + *
    • {@link CharacterRange#FLAG_BRANCH_TRUE} A condition encoded * in the branch instruction immediately contained in the code range for * this item is not inverted towards the corresponding branch condition in * the source code. I.e. actual jump occurs if and only if the the source @@ -119,7 +121,7 @@ public sealed interface CharacterRangeInfo * if<cond>, ifnonull, ifnull or goto. CRT_BRANCH_TRUE and * CRT_BRANCH_FALSE are special kinds of entries that can be used to * determine what branch of a condition was chosen during the runtime. - *
    • {@link java.lang.classfile.ClassFile#CRT_BRANCH_FALSE} A condition encoded + *
    • {@link CharacterRange#FLAG_BRANCH_FALSE} A condition encoded * in the branch instruction immediately contained in the code range for * this item is inverted towards the corresponding branch condition in the * source code. I.e. actual jump occurs if and only if the the source code @@ -134,6 +136,7 @@ public sealed interface CharacterRangeInfo * All bits of the flags item not assigned above are reserved for future use. They should be set to zero in generated class files and should be ignored by Java virtual machine implementations. * * @return the flags + * @see CharacterRange#flags() */ int flags(); diff --git a/src/java.base/share/classes/java/lang/classfile/attribute/EnclosingMethodAttribute.java b/src/java.base/share/classes/java/lang/classfile/attribute/EnclosingMethodAttribute.java index 768019fa1d3..2c919008501 100644 --- a/src/java.base/share/classes/java/lang/classfile/attribute/EnclosingMethodAttribute.java +++ b/src/java.base/share/classes/java/lang/classfile/attribute/EnclosingMethodAttribute.java @@ -92,7 +92,7 @@ public sealed interface EnclosingMethodAttribute * immediately enclosed by a method or constructor} */ default Optional enclosingMethodTypeSymbol() { - return enclosingMethod().map(Util::methodTypeSymbol); + return enclosingMethodType().map(Util::methodTypeSymbol); } /** diff --git a/src/java.base/share/classes/java/lang/classfile/attribute/LocalVariableInfo.java b/src/java.base/share/classes/java/lang/classfile/attribute/LocalVariableInfo.java index 954682f665d..0ef8542e05c 100644 --- a/src/java.base/share/classes/java/lang/classfile/attribute/LocalVariableInfo.java +++ b/src/java.base/share/classes/java/lang/classfile/attribute/LocalVariableInfo.java @@ -28,6 +28,7 @@ import java.lang.constant.ClassDesc; import java.lang.classfile.constantpool.Utf8Entry; import jdk.internal.classfile.impl.BoundLocalVariable; import jdk.internal.classfile.impl.UnboundAttribute; +import jdk.internal.classfile.impl.Util; import jdk.internal.javac.PreviewFeature; /** @@ -65,7 +66,7 @@ public sealed interface LocalVariableInfo * {@return the field descriptor of the local variable} */ default ClassDesc typeSymbol() { - return ClassDesc.ofDescriptor(type().stringValue()); + return Util.fieldTypeSymbol(type()); } /** diff --git a/src/java.base/share/classes/java/lang/classfile/attribute/RecordComponentInfo.java b/src/java.base/share/classes/java/lang/classfile/attribute/RecordComponentInfo.java index ab7df7a5db2..5a4c0d87b83 100644 --- a/src/java.base/share/classes/java/lang/classfile/attribute/RecordComponentInfo.java +++ b/src/java.base/share/classes/java/lang/classfile/attribute/RecordComponentInfo.java @@ -33,6 +33,7 @@ import java.lang.classfile.constantpool.Utf8Entry; import jdk.internal.classfile.impl.BoundRecordComponentInfo; import jdk.internal.classfile.impl.TemporaryConstantPool; import jdk.internal.classfile.impl.UnboundAttribute; +import jdk.internal.classfile.impl.Util; import jdk.internal.javac.PreviewFeature; /** @@ -58,7 +59,7 @@ public sealed interface RecordComponentInfo * {@return the field descriptor of this component, as a {@linkplain ClassDesc}} */ default ClassDesc descriptorSymbol() { - return ClassDesc.ofDescriptor(descriptor().stringValue()); + return Util.fieldTypeSymbol(descriptor()); } /** @@ -95,7 +96,7 @@ public sealed interface RecordComponentInfo ClassDesc descriptor, List> attributes) { return new UnboundAttribute.UnboundRecordComponentInfo(TemporaryConstantPool.INSTANCE.utf8Entry(name), - TemporaryConstantPool.INSTANCE.utf8Entry(descriptor.descriptorString()), + TemporaryConstantPool.INSTANCE.utf8Entry(descriptor), attributes); } diff --git a/src/java.base/share/classes/java/lang/classfile/attribute/StackMapFrameInfo.java b/src/java.base/share/classes/java/lang/classfile/attribute/StackMapFrameInfo.java index 46caa66ef9a..3415c89174a 100644 --- a/src/java.base/share/classes/java/lang/classfile/attribute/StackMapFrameInfo.java +++ b/src/java.base/share/classes/java/lang/classfile/attribute/StackMapFrameInfo.java @@ -32,7 +32,6 @@ import java.lang.classfile.Label; import java.lang.classfile.constantpool.ClassEntry; import jdk.internal.classfile.impl.StackMapDecoder; import jdk.internal.classfile.impl.TemporaryConstantPool; -import static java.lang.classfile.ClassFile.*; import jdk.internal.javac.PreviewFeature; /** @@ -85,8 +84,39 @@ public sealed interface StackMapFrameInfo @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) sealed interface VerificationTypeInfo { + /** The {@link #tag() tag} for verification type info {@link SimpleVerificationTypeInfo#TOP TOP}. */ + int ITEM_TOP = 0; + + /** The {@link #tag() tag} for verification type info {@link SimpleVerificationTypeInfo#INTEGER INTEGER}. */ + int ITEM_INTEGER = 1; + + /** The {@link #tag() tag} for verification type info {@link SimpleVerificationTypeInfo#FLOAT FLOAT}. */ + int ITEM_FLOAT = 2; + + /** The {@link #tag() tag} for verification type info {@link SimpleVerificationTypeInfo#DOUBLE DOUBLE}. */ + int ITEM_DOUBLE = 3; + + /** The {@link #tag() tag} for verification type info {@link SimpleVerificationTypeInfo#LONG LONG}. */ + int ITEM_LONG = 4; + + /** The {@link #tag() tag} for verification type info {@link SimpleVerificationTypeInfo#NULL NULL}. */ + int ITEM_NULL = 5; + + /** The {@link #tag() tag} for verification type info {@link SimpleVerificationTypeInfo#UNINITIALIZED_THIS UNINITIALIZED_THIS}. */ + int ITEM_UNINITIALIZED_THIS = 6; + + /** The {@link #tag() tag} for verification type info {@link ObjectVerificationTypeInfo OBJECT}. */ + int ITEM_OBJECT = 7; + + /** The {@link #tag() tag} for verification type info {@link UninitializedVerificationTypeInfo UNINITIALIZED}. */ + int ITEM_UNINITIALIZED = 8; + /** * {@return the tag of the type info} + * + * @apiNote + * {@code ITEM_}-prefixed constants in this class, such as {@link #ITEM_TOP}, describe the + * possible return values of this method. */ int tag(); } @@ -100,25 +130,25 @@ public sealed interface StackMapFrameInfo public enum SimpleVerificationTypeInfo implements VerificationTypeInfo { /** verification type top */ - ITEM_TOP(VT_TOP), + TOP(ITEM_TOP), /** verification type int */ - ITEM_INTEGER(VT_INTEGER), + INTEGER(ITEM_INTEGER), /** verification type float */ - ITEM_FLOAT(VT_FLOAT), + FLOAT(ITEM_FLOAT), /** verification type double */ - ITEM_DOUBLE(VT_DOUBLE), + DOUBLE(ITEM_DOUBLE), /** verification type long */ - ITEM_LONG(VT_LONG), + LONG(ITEM_LONG), /** verification type null */ - ITEM_NULL(VT_NULL), + NULL(ITEM_NULL), /** verification type uninitializedThis */ - ITEM_UNINITIALIZED_THIS(VT_UNINITIALIZED_THIS); + UNINITIALIZED_THIS(ITEM_UNINITIALIZED_THIS); private final int tag; @@ -134,7 +164,7 @@ public sealed interface StackMapFrameInfo } /** - * A stack value for an object type. + * A stack value for an object type. Its {@link #tag() tag} is {@value #ITEM_OBJECT}. * * @since 22 */ @@ -173,7 +203,7 @@ public sealed interface StackMapFrameInfo } /** - * An uninitialized stack value. + * An uninitialized stack value. Its {@link #tag() tag} is {@value #ITEM_UNINITIALIZED}. * * @since 22 */ diff --git a/src/java.base/share/classes/java/lang/classfile/components/ClassRemapper.java b/src/java.base/share/classes/java/lang/classfile/components/ClassRemapper.java index d3ae180dde5..bcda3635587 100644 --- a/src/java.base/share/classes/java/lang/classfile/components/ClassRemapper.java +++ b/src/java.base/share/classes/java/lang/classfile/components/ClassRemapper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,6 +36,8 @@ import java.lang.classfile.MethodTransform; import jdk.internal.classfile.impl.ClassRemapperImpl; import jdk.internal.javac.PreviewFeature; +import static java.util.Objects.requireNonNull; + /** * {@code ClassRemapper} is a {@link ClassTransform}, {@link FieldTransform}, * {@link MethodTransform} and {@link CodeTransform} @@ -64,6 +66,7 @@ public sealed interface ClassRemapper extends ClassTransform permits ClassRemapp * @return new instance of {@code ClassRemapper} */ static ClassRemapper of(Map classMap) { + requireNonNull(classMap); return of(desc -> classMap.getOrDefault(desc, desc)); } @@ -75,7 +78,7 @@ public sealed interface ClassRemapper extends ClassTransform permits ClassRemapp * @return new instance of {@code ClassRemapper} */ static ClassRemapper of(Function mapFunction) { - return new ClassRemapperImpl(mapFunction); + return new ClassRemapperImpl(requireNonNull(mapFunction)); } /** diff --git a/src/java.base/share/classes/java/lang/classfile/components/CodeRelabeler.java b/src/java.base/share/classes/java/lang/classfile/components/CodeRelabeler.java index ca5ad90389c..6ec3f9f792b 100644 --- a/src/java.base/share/classes/java/lang/classfile/components/CodeRelabeler.java +++ b/src/java.base/share/classes/java/lang/classfile/components/CodeRelabeler.java @@ -33,6 +33,8 @@ import java.lang.classfile.Label; import jdk.internal.classfile.impl.CodeRelabelerImpl; import jdk.internal.javac.PreviewFeature; +import static java.util.Objects.requireNonNull; + /** * A code relabeler is a {@link CodeTransform} replacing all occurrences * of {@link java.lang.classfile.Label} in the transformed code with new instances. @@ -62,6 +64,7 @@ public sealed interface CodeRelabeler extends CodeTransform permits CodeRelabele * @return a new instance of CodeRelabeler */ static CodeRelabeler of(Map map) { + requireNonNull(map); return of((l, cob) -> map.computeIfAbsent(l, ll -> cob.newLabel())); } @@ -72,6 +75,6 @@ public sealed interface CodeRelabeler extends CodeTransform permits CodeRelabele * @return a new instance of CodeRelabeler */ static CodeRelabeler of(BiFunction mapFunction) { - return new CodeRelabelerImpl(mapFunction); + return new CodeRelabelerImpl(requireNonNull(mapFunction)); } } diff --git a/src/java.base/share/classes/java/lang/classfile/constantpool/ConstantDynamicEntry.java b/src/java.base/share/classes/java/lang/classfile/constantpool/ConstantDynamicEntry.java index 144c8a539d7..507ff906274 100644 --- a/src/java.base/share/classes/java/lang/classfile/constantpool/ConstantDynamicEntry.java +++ b/src/java.base/share/classes/java/lang/classfile/constantpool/ConstantDynamicEntry.java @@ -50,7 +50,7 @@ public sealed interface ConstantDynamicEntry * {@return a symbolic descriptor for the dynamic constant's type} */ default ClassDesc typeSymbol() { - return Util.fieldTypeSymbol(nameAndType()); + return Util.fieldTypeSymbol(type()); } @Override diff --git a/src/java.base/share/classes/java/lang/classfile/constantpool/ConstantPoolBuilder.java b/src/java.base/share/classes/java/lang/classfile/constantpool/ConstantPoolBuilder.java index 7334d8e5460..12c9789133b 100644 --- a/src/java.base/share/classes/java/lang/classfile/constantpool/ConstantPoolBuilder.java +++ b/src/java.base/share/classes/java/lang/classfile/constantpool/ConstantPoolBuilder.java @@ -223,9 +223,7 @@ public sealed interface ConstantPoolBuilder * @param type the symbolic descriptor for a field type */ default NameAndTypeEntry nameAndTypeEntry(String name, ClassDesc type) { - var ret = (NameAndTypeEntryImpl)nameAndTypeEntry(utf8Entry(name), utf8Entry(type.descriptorString())); - ret.typeSym = type; - return ret; + return nameAndTypeEntry(utf8Entry(name), utf8Entry(type)); } /** @@ -238,9 +236,7 @@ public sealed interface ConstantPoolBuilder * @param type the symbolic descriptor for a method type */ default NameAndTypeEntry nameAndTypeEntry(String name, MethodTypeDesc type) { - var ret = (NameAndTypeEntryImpl)nameAndTypeEntry(utf8Entry(name), utf8Entry(type.descriptorString())); - ret.typeSym = type; - return ret; + return nameAndTypeEntry(utf8Entry(name), utf8Entry(type)); } /** @@ -474,10 +470,11 @@ public sealed interface ConstantPoolBuilder } /** - * {@return A {@link ConstantValueEntry} descripbing the provided + * {@return A {@link ConstantValueEntry} describing the provided * Integer, Long, Float, Double, or String constant} * * @param c the constant + * @see ConstantValueEntry#constantValue() */ default ConstantValueEntry constantValueEntry(ConstantDesc c) { if (c instanceof Integer i) return intEntry(i); diff --git a/src/java.base/share/classes/java/lang/classfile/constantpool/ConstantValueEntry.java b/src/java.base/share/classes/java/lang/classfile/constantpool/ConstantValueEntry.java index 340baeb905f..720e3fd5d5c 100644 --- a/src/java.base/share/classes/java/lang/classfile/constantpool/ConstantValueEntry.java +++ b/src/java.base/share/classes/java/lang/classfile/constantpool/ConstantValueEntry.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,13 +24,14 @@ */ package java.lang.classfile.constantpool; +import java.lang.classfile.Attributes; import java.lang.constant.ConstantDesc; import jdk.internal.javac.PreviewFeature; /** * Models a constant pool entry that can be used as the constant in a - * {@code ConstantValue} attribute; this includes the four primitive constant - * types and {@linkplain String} constants. + * {@link Attributes#constantValue() ConstantValue} attribute; this includes the four + * primitive constant types and {@linkplain String} constants. * * @sealedGraph * @since 22 @@ -42,6 +43,8 @@ public sealed interface ConstantValueEntry extends LoadableConstantEntry /** * {@return the constant value} The constant value will be an {@link Integer}, * {@link Long}, {@link Float}, {@link Double}, or {@link String}. + * + * @see ConstantPoolBuilder#constantValueEntry(ConstantDesc) */ @Override ConstantDesc constantValue(); diff --git a/src/java.base/share/classes/java/lang/classfile/constantpool/FieldRefEntry.java b/src/java.base/share/classes/java/lang/classfile/constantpool/FieldRefEntry.java index 628abdac6fe..75533770b35 100644 --- a/src/java.base/share/classes/java/lang/classfile/constantpool/FieldRefEntry.java +++ b/src/java.base/share/classes/java/lang/classfile/constantpool/FieldRefEntry.java @@ -44,6 +44,6 @@ public sealed interface FieldRefEntry extends MemberRefEntry * {@return a symbolic descriptor for the field's type} */ default ClassDesc typeSymbol() { - return Util.fieldTypeSymbol(nameAndType()); + return Util.fieldTypeSymbol(type()); } } diff --git a/src/java.base/share/classes/java/lang/classfile/constantpool/InterfaceMethodRefEntry.java b/src/java.base/share/classes/java/lang/classfile/constantpool/InterfaceMethodRefEntry.java index 43faa488bb9..b97defdc1e1 100644 --- a/src/java.base/share/classes/java/lang/classfile/constantpool/InterfaceMethodRefEntry.java +++ b/src/java.base/share/classes/java/lang/classfile/constantpool/InterfaceMethodRefEntry.java @@ -45,6 +45,6 @@ public sealed interface InterfaceMethodRefEntry * {@return a symbolic descriptor for the interface method's type} */ default MethodTypeDesc typeSymbol() { - return Util.methodTypeSymbol(nameAndType()); + return Util.methodTypeSymbol(type()); } } diff --git a/src/java.base/share/classes/java/lang/classfile/constantpool/InvokeDynamicEntry.java b/src/java.base/share/classes/java/lang/classfile/constantpool/InvokeDynamicEntry.java index d9a1c299972..f06c3d4c782 100644 --- a/src/java.base/share/classes/java/lang/classfile/constantpool/InvokeDynamicEntry.java +++ b/src/java.base/share/classes/java/lang/classfile/constantpool/InvokeDynamicEntry.java @@ -47,7 +47,7 @@ public sealed interface InvokeDynamicEntry * {@return a symbolic descriptor for the call site's invocation type} */ default MethodTypeDesc typeSymbol() { - return Util.methodTypeSymbol(nameAndType()); + return Util.methodTypeSymbol(type()); } /** diff --git a/src/java.base/share/classes/java/lang/classfile/constantpool/MethodRefEntry.java b/src/java.base/share/classes/java/lang/classfile/constantpool/MethodRefEntry.java index 39684db4621..3ff8dfdc0f4 100644 --- a/src/java.base/share/classes/java/lang/classfile/constantpool/MethodRefEntry.java +++ b/src/java.base/share/classes/java/lang/classfile/constantpool/MethodRefEntry.java @@ -44,6 +44,6 @@ public sealed interface MethodRefEntry extends MemberRefEntry * {@return a symbolic descriptor for the method's type} */ default MethodTypeDesc typeSymbol() { - return Util.methodTypeSymbol(nameAndType()); + return Util.methodTypeSymbol(type()); } } diff --git a/src/java.base/share/classes/java/lang/classfile/constantpool/PoolEntry.java b/src/java.base/share/classes/java/lang/classfile/constantpool/PoolEntry.java index c8b74a13928..d2af4c7c11a 100644 --- a/src/java.base/share/classes/java/lang/classfile/constantpool/PoolEntry.java +++ b/src/java.base/share/classes/java/lang/classfile/constantpool/PoolEntry.java @@ -38,6 +38,57 @@ public sealed interface PoolEntry LoadableConstantEntry, MemberRefEntry, ModuleEntry, NameAndTypeEntry, PackageEntry { + /** The {@linkplain #tag tag} for {@link ClassEntry CONSTANT_Class} constant kind. */ + int TAG_CLASS = 7; + + /** The {@linkplain #tag tag} for {@link DoubleEntry CONSTANT_Double} constant kind. */ + int TAG_DOUBLE = 6; + + /** The {@linkplain #tag tag} for {@link ConstantDynamicEntry CONSTANT_Dynamic} constant kind. */ + int TAG_DYNAMIC = 17; + + /** The {@linkplain #tag tag} for {@link FieldRefEntry CONSTANT_Fieldref} constant kind. */ + int TAG_FIELDREF = 9; + + /** The {@linkplain #tag tag} for {@link FloatEntry CONSTANT_Float} constant kind. */ + int TAG_FLOAT = 4; + + /** The {@linkplain #tag tag} for {@link IntegerEntry CONSTANT_Integer} constant kind. */ + int TAG_INTEGER = 3; + + /** The {@linkplain #tag tag} for {@link InterfaceMethodRefEntry CONSTANT_InterfaceMethodref} constant kind. */ + int TAG_INTERFACE_METHODREF = 11; + + /** The {@linkplain #tag tag} for {@link InvokeDynamicEntry CONSTANT_InvokeDynamic} constant kind. */ + int TAG_INVOKE_DYNAMIC = 18; + + /** The {@linkplain #tag tag} for {@link LongEntry CONSTANT_Long} constant kind. */ + int TAG_LONG = 5; + + /** The {@linkplain #tag tag} for {@link MethodHandleEntry CONSTANT_MethodHandle} constant kind. */ + int TAG_METHOD_HANDLE = 15; + + /** The {@linkplain #tag tag} for {@link MethodRefEntry CONSTANT_Methodref} constant kind. */ + int TAG_METHODREF = 10; + + /** The {@linkplain #tag tag} for {@link MethodTypeEntry CONSTANT_MethodType} constant kind. */ + int TAG_METHOD_TYPE = 16; + + /** The {@linkplain #tag tag} for {@link ModuleEntry CONSTANT_Module} constant kind. */ + int TAG_MODULE = 19; + + /** The {@linkplain #tag tag} for {@link NameAndTypeEntry CONSTANT_NameAndType} constant kind. */ + int TAG_NAME_AND_TYPE = 12; + + /** The {@linkplain #tag tag} for {@link PackageEntry CONSTANT_Package} constant kind. */ + int TAG_PACKAGE = 20; + + /** The {@linkplain #tag tag} for {@link StringEntry CONSTANT_String} constant kind. */ + int TAG_STRING = 8; + + /** The {@linkplain #tag tag} for {@link Utf8Entry CONSTANT_Utf8} constant kind. */ + int TAG_UTF8 = 1; + /** * {@return the constant pool this entry is from} */ @@ -45,6 +96,10 @@ public sealed interface PoolEntry /** * {@return the constant pool tag that describes the type of this entry} + * + * @apiNote + * {@code TAG_}-prefixed constants in this class, such as {@link #TAG_UTF8}, + * describe the possible return values of this method. */ byte tag(); diff --git a/src/java.base/share/classes/java/lang/classfile/instruction/CharacterRange.java b/src/java.base/share/classes/java/lang/classfile/instruction/CharacterRange.java index 89a54caeaf2..fca3279cd22 100644 --- a/src/java.base/share/classes/java/lang/classfile/instruction/CharacterRange.java +++ b/src/java.base/share/classes/java/lang/classfile/instruction/CharacterRange.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,6 +29,7 @@ import java.lang.classfile.CodeElement; import java.lang.classfile.CodeModel; import java.lang.classfile.Label; import java.lang.classfile.PseudoInstruction; +import java.lang.classfile.attribute.CharacterRangeInfo; import java.lang.classfile.attribute.CharacterRangeTableAttribute; import jdk.internal.classfile.impl.AbstractPseudoInstruction; import jdk.internal.classfile.impl.BoundCharacterRange; @@ -45,6 +46,34 @@ import jdk.internal.javac.PreviewFeature; @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) public sealed interface CharacterRange extends PseudoInstruction permits AbstractPseudoInstruction.UnboundCharacterRange, BoundCharacterRange { + + /** The bit mask of STATEMENT {@link CharacterRangeInfo} kind. */ + int FLAG_STATEMENT = 0x0001; + + /** The bit mask of BLOCK {@link CharacterRangeInfo} kind. */ + int FLAG_BLOCK = 0x0002; + + /** The bit mask of ASSIGNMENT {@link CharacterRangeInfo} kind. */ + int FLAG_ASSIGNMENT = 0x0004; + + /** The bit mask of FLOW_CONTROLLER {@link CharacterRangeInfo} kind. */ + int FLAG_FLOW_CONTROLLER = 0x0008; + + /** The bit mask of FLOW_TARGET {@link CharacterRangeInfo} kind. */ + int FLAG_FLOW_TARGET = 0x0010; + + /** The bit mask of INVOKE {@link CharacterRangeInfo} kind. */ + int FLAG_INVOKE = 0x0020; + + /** The bit mask of CREATE {@link CharacterRangeInfo} kind. */ + int FLAG_CREATE = 0x0040; + + /** The bit mask of BRANCH_TRUE {@link CharacterRangeInfo} kind. */ + int FLAG_BRANCH_TRUE = 0x0080; + + /** The bit mask of BRANCH_FALSE {@link CharacterRangeInfo} kind. */ + int FLAG_BRANCH_FALSE = 0x0100; + /** * {@return the start of the instruction range} */ @@ -75,15 +104,15 @@ public sealed interface CharacterRange extends PseudoInstruction * A flags word, indicating the kind of range. Multiple flag bits * may be set. Valid flags include: *
        - *
      • {@link java.lang.classfile.ClassFile#CRT_STATEMENT} - *
      • {@link java.lang.classfile.ClassFile#CRT_BLOCK} - *
      • {@link java.lang.classfile.ClassFile#CRT_ASSIGNMENT} - *
      • {@link java.lang.classfile.ClassFile#CRT_FLOW_CONTROLLER} - *
      • {@link java.lang.classfile.ClassFile#CRT_FLOW_TARGET} - *
      • {@link java.lang.classfile.ClassFile#CRT_INVOKE} - *
      • {@link java.lang.classfile.ClassFile#CRT_CREATE} - *
      • {@link java.lang.classfile.ClassFile#CRT_BRANCH_TRUE} - *
      • {@link java.lang.classfile.ClassFile#CRT_BRANCH_FALSE} + *
      • {@link #FLAG_STATEMENT} + *
      • {@link #FLAG_BLOCK} + *
      • {@link #FLAG_ASSIGNMENT} + *
      • {@link #FLAG_FLOW_CONTROLLER} + *
      • {@link #FLAG_FLOW_TARGET} + *
      • {@link #FLAG_INVOKE} + *
      • {@link #FLAG_CREATE} + *
      • {@link #FLAG_BRANCH_TRUE} + *
      • {@link #FLAG_BRANCH_FALSE} *
      * * @see java.lang.classfile.attribute.CharacterRangeInfo#flags() diff --git a/src/java.base/share/classes/java/lang/classfile/instruction/ConstantInstruction.java b/src/java.base/share/classes/java/lang/classfile/instruction/ConstantInstruction.java index 022c45fdeef..6f07805a1e8 100644 --- a/src/java.base/share/classes/java/lang/classfile/instruction/ConstantInstruction.java +++ b/src/java.base/share/classes/java/lang/classfile/instruction/ConstantInstruction.java @@ -75,7 +75,7 @@ public sealed interface ConstantInstruction extends Instruction { */ @Override default TypeKind typeKind() { - return opcode().primaryTypeKind(); + return BytecodeHelpers.intrinsicConstantType(opcode()); } } @@ -98,7 +98,7 @@ public sealed interface ConstantInstruction extends Instruction { */ @Override default TypeKind typeKind() { - return opcode().primaryTypeKind(); + return TypeKind.INT; } } @@ -137,7 +137,7 @@ public sealed interface ConstantInstruction extends Instruction { */ static IntrinsicConstantInstruction ofIntrinsic(Opcode op) { Util.checkKind(op, Opcode.Kind.CONSTANT); - if (op.constantValue() == null) + if (op.sizeIfFixed() != 1) throw new IllegalArgumentException(String.format("Wrong opcode specified; found %s, expected xCONST_val", op)); return new AbstractInstruction.UnboundIntrinsicConstantInstruction(op); } diff --git a/src/java.base/share/classes/java/lang/classfile/instruction/DiscontinuedInstruction.java b/src/java.base/share/classes/java/lang/classfile/instruction/DiscontinuedInstruction.java index 61ea14c4598..fc87dd274d3 100644 --- a/src/java.base/share/classes/java/lang/classfile/instruction/DiscontinuedInstruction.java +++ b/src/java.base/share/classes/java/lang/classfile/instruction/DiscontinuedInstruction.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,6 +30,7 @@ import java.lang.classfile.Instruction; import java.lang.classfile.Label; import java.lang.classfile.Opcode; import jdk.internal.classfile.impl.AbstractInstruction; +import jdk.internal.classfile.impl.BytecodeHelpers; import jdk.internal.classfile.impl.Util; import jdk.internal.javac.PreviewFeature; @@ -112,10 +113,10 @@ public sealed interface DiscontinuedInstruction extends Instruction { * which must be of kind {@link Opcode.Kind#DISCONTINUED_RET} * @param slot the local variable slot to load return address from * @throws IllegalArgumentException if the opcode kind is not - * {@link Opcode.Kind#DISCONTINUED_RET}. + * {@link Opcode.Kind#DISCONTINUED_RET} or if {@code slot} is out of range */ static RetInstruction of(Opcode op, int slot) { - Util.checkKind(op, Opcode.Kind.DISCONTINUED_RET); + BytecodeHelpers.validateRet(op, slot); return new AbstractInstruction.UnboundRetInstruction(op, slot); } @@ -123,6 +124,7 @@ public sealed interface DiscontinuedInstruction extends Instruction { * {@return a RET instruction} * * @param slot the local variable slot to load return address from + * @throws IllegalArgumentException if {@code slot} is out of range */ static RetInstruction of(int slot) { return of(slot < 256 ? Opcode.RET : Opcode.RET_W, slot); diff --git a/src/java.base/share/classes/java/lang/classfile/instruction/IncrementInstruction.java b/src/java.base/share/classes/java/lang/classfile/instruction/IncrementInstruction.java index 3bde87ee48d..bebb101d7f3 100644 --- a/src/java.base/share/classes/java/lang/classfile/instruction/IncrementInstruction.java +++ b/src/java.base/share/classes/java/lang/classfile/instruction/IncrementInstruction.java @@ -58,6 +58,7 @@ public sealed interface IncrementInstruction extends Instruction * * @param slot the local variable slot to increment * @param constant the value to increment by + * @throws IllegalArgumentException if {@code slot} or {@code constant} is out of range */ static IncrementInstruction of(int slot, int constant) { return new AbstractInstruction.UnboundIncrementInstruction(slot, constant); diff --git a/src/java.base/share/classes/java/lang/classfile/instruction/InvokeInstruction.java b/src/java.base/share/classes/java/lang/classfile/instruction/InvokeInstruction.java index ff68abce3d2..74b8dc942a2 100644 --- a/src/java.base/share/classes/java/lang/classfile/instruction/InvokeInstruction.java +++ b/src/java.base/share/classes/java/lang/classfile/instruction/InvokeInstruction.java @@ -94,7 +94,7 @@ public sealed interface InvokeInstruction extends Instruction * {@return a symbolic descriptor for the method type} */ default MethodTypeDesc typeSymbol() { - return Util.methodTypeSymbol(method().nameAndType()); + return Util.methodTypeSymbol(method().type()); } diff --git a/src/java.base/share/classes/java/lang/classfile/instruction/LoadInstruction.java b/src/java.base/share/classes/java/lang/classfile/instruction/LoadInstruction.java index f4cc8bab794..ea10ba6a0d0 100644 --- a/src/java.base/share/classes/java/lang/classfile/instruction/LoadInstruction.java +++ b/src/java.base/share/classes/java/lang/classfile/instruction/LoadInstruction.java @@ -62,9 +62,12 @@ public sealed interface LoadInstruction extends Instruction * * @param kind the type of the value to be loaded * @param slot the local variable slot to load from + * @throws IllegalArgumentException if {@code kind} is + * {@link TypeKind#VOID void} or {@code slot} is out of range */ static LoadInstruction of(TypeKind kind, int slot) { - return of(BytecodeHelpers.loadOpcode(kind, slot), slot); + var opcode = BytecodeHelpers.loadOpcode(kind, slot); // validates slot, trusted + return new AbstractInstruction.UnboundLoadInstruction(opcode, slot); } /** @@ -74,10 +77,11 @@ public sealed interface LoadInstruction extends Instruction * which must be of kind {@link Opcode.Kind#LOAD} * @param slot the local variable slot to load from * @throws IllegalArgumentException if the opcode kind is not - * {@link Opcode.Kind#LOAD}. + * {@link Opcode.Kind#LOAD} or {@code slot} is out of range */ static LoadInstruction of(Opcode op, int slot) { Util.checkKind(op, Opcode.Kind.LOAD); + BytecodeHelpers.validateSlot(op, slot, true); return new AbstractInstruction.UnboundLoadInstruction(op, slot); } } diff --git a/src/java.base/share/classes/java/lang/classfile/instruction/LocalVariable.java b/src/java.base/share/classes/java/lang/classfile/instruction/LocalVariable.java index 4d3d7553867..390034bd666 100644 --- a/src/java.base/share/classes/java/lang/classfile/instruction/LocalVariable.java +++ b/src/java.base/share/classes/java/lang/classfile/instruction/LocalVariable.java @@ -36,6 +36,7 @@ import java.lang.constant.ClassDesc; import jdk.internal.classfile.impl.AbstractPseudoInstruction; import jdk.internal.classfile.impl.BoundLocalVariable; import jdk.internal.classfile.impl.TemporaryConstantPool; +import jdk.internal.classfile.impl.Util; import jdk.internal.javac.PreviewFeature; /** @@ -70,7 +71,7 @@ public sealed interface LocalVariable extends PseudoInstruction * {@return the local variable type, as a symbolic descriptor} */ default ClassDesc typeSymbol() { - return ClassDesc.ofDescriptor(type().stringValue()); + return Util.fieldTypeSymbol(type()); } /** @@ -91,6 +92,7 @@ public sealed interface LocalVariable extends PseudoInstruction * @param descriptorEntry the local variable descriptor * @param startScope the start range of the local variable scope * @param endScope the end range of the local variable scope + * @throws IllegalArgumentException if {@code slot} is out of range */ static LocalVariable of(int slot, Utf8Entry nameEntry, Utf8Entry descriptorEntry, Label startScope, Label endScope) { return new AbstractPseudoInstruction.UnboundLocalVariable(slot, nameEntry, descriptorEntry, @@ -105,11 +107,12 @@ public sealed interface LocalVariable extends PseudoInstruction * @param descriptor the local variable descriptor * @param startScope the start range of the local variable scope * @param endScope the end range of the local variable scope + * @throws IllegalArgumentException if {@code slot} is out of range */ static LocalVariable of(int slot, String name, ClassDesc descriptor, Label startScope, Label endScope) { return of(slot, TemporaryConstantPool.INSTANCE.utf8Entry(name), - TemporaryConstantPool.INSTANCE.utf8Entry(descriptor.descriptorString()), + TemporaryConstantPool.INSTANCE.utf8Entry(descriptor), startScope, endScope); } } diff --git a/src/java.base/share/classes/java/lang/classfile/instruction/LocalVariableType.java b/src/java.base/share/classes/java/lang/classfile/instruction/LocalVariableType.java index 4409abe6db2..d0d2cd1581f 100644 --- a/src/java.base/share/classes/java/lang/classfile/instruction/LocalVariableType.java +++ b/src/java.base/share/classes/java/lang/classfile/instruction/LocalVariableType.java @@ -89,6 +89,7 @@ public sealed interface LocalVariableType extends PseudoInstruction * @param signatureEntry the local variable signature * @param startScope the start range of the local variable scope * @param endScope the end range of the local variable scope + * @throws IllegalArgumentException if {@code slot} is out of range */ static LocalVariableType of(int slot, Utf8Entry nameEntry, Utf8Entry signatureEntry, Label startScope, Label endScope) { return new AbstractPseudoInstruction.UnboundLocalVariableType(slot, nameEntry, signatureEntry, @@ -103,6 +104,7 @@ public sealed interface LocalVariableType extends PseudoInstruction * @param signature the local variable signature * @param startScope the start range of the local variable scope * @param endScope the end range of the local variable scope + * @throws IllegalArgumentException if {@code slot} is out of range */ static LocalVariableType of(int slot, String name, Signature signature, Label startScope, Label endScope) { return of(slot, diff --git a/src/java.base/share/classes/java/lang/classfile/instruction/NewMultiArrayInstruction.java b/src/java.base/share/classes/java/lang/classfile/instruction/NewMultiArrayInstruction.java index 2f45b967603..2c572c607b4 100644 --- a/src/java.base/share/classes/java/lang/classfile/instruction/NewMultiArrayInstruction.java +++ b/src/java.base/share/classes/java/lang/classfile/instruction/NewMultiArrayInstruction.java @@ -29,6 +29,7 @@ import java.lang.classfile.CodeModel; import java.lang.classfile.constantpool.ClassEntry; import java.lang.classfile.Instruction; import jdk.internal.classfile.impl.AbstractInstruction; +import jdk.internal.classfile.impl.BytecodeHelpers; import jdk.internal.javac.PreviewFeature; /** @@ -58,9 +59,11 @@ public sealed interface NewMultiArrayInstruction extends Instruction * * @param arrayTypeEntry the type of the array * @param dimensions the number of dimensions of the array + * @throws IllegalArgumentException if {@code dimensions} is out of range */ static NewMultiArrayInstruction of(ClassEntry arrayTypeEntry, int dimensions) { + BytecodeHelpers.validateMultiArrayDimensions(dimensions); return new AbstractInstruction.UnboundNewMultidimensionalArrayInstruction(arrayTypeEntry, dimensions); } } diff --git a/src/java.base/share/classes/java/lang/classfile/instruction/StoreInstruction.java b/src/java.base/share/classes/java/lang/classfile/instruction/StoreInstruction.java index 278bf8c0ec3..5bfe13421da 100644 --- a/src/java.base/share/classes/java/lang/classfile/instruction/StoreInstruction.java +++ b/src/java.base/share/classes/java/lang/classfile/instruction/StoreInstruction.java @@ -61,9 +61,12 @@ public sealed interface StoreInstruction extends Instruction * * @param kind the type of the value to be stored * @param slot the local variable slot to store to + * @throws IllegalArgumentException if {@code kind} is {@link + * TypeKind#VOID void} or {@code slot} is out of range */ static StoreInstruction of(TypeKind kind, int slot) { - return of(BytecodeHelpers.storeOpcode(kind, slot), slot); + var opcode = BytecodeHelpers.storeOpcode(kind, slot); // validates slot + return new AbstractInstruction.UnboundStoreInstruction(opcode, slot); } /** @@ -73,10 +76,11 @@ public sealed interface StoreInstruction extends Instruction * which must be of kind {@link Opcode.Kind#STORE} * @param slot the local variable slot to store to * @throws IllegalArgumentException if the opcode kind is not - * {@link Opcode.Kind#STORE}. + * {@link Opcode.Kind#STORE} or {@code slot} is out of range */ static StoreInstruction of(Opcode op, int slot) { Util.checkKind(op, Opcode.Kind.STORE); + BytecodeHelpers.validateSlot(op, slot, false); return new AbstractInstruction.UnboundStoreInstruction(op, slot); } } diff --git a/src/java.base/share/classes/java/lang/constant/ClassDesc.java b/src/java.base/share/classes/java/lang/constant/ClassDesc.java index 0c714850a8f..b93d9522352 100644 --- a/src/java.base/share/classes/java/lang/constant/ClassDesc.java +++ b/src/java.base/share/classes/java/lang/constant/ClassDesc.java @@ -36,6 +36,7 @@ import static java.util.stream.Collectors.joining; import static jdk.internal.constant.ConstantUtils.MAX_ARRAY_TYPE_DESC_DIMENSIONS; import static jdk.internal.constant.ConstantUtils.arrayDepth; import static jdk.internal.constant.ConstantUtils.binaryToInternal; +import static jdk.internal.constant.ConstantUtils.concat; import static jdk.internal.constant.ConstantUtils.forPrimitiveType; import static jdk.internal.constant.ConstantUtils.internalToBinary; import static jdk.internal.constant.ConstantUtils.validateBinaryClassName; @@ -83,7 +84,7 @@ public sealed interface ClassDesc */ static ClassDesc of(String name) { validateBinaryClassName(name); - return ClassDesc.ofDescriptor("L" + binaryToInternal(name) + ";"); + return ClassDesc.ofDescriptor(concat("L", binaryToInternal(name), ";")); } /** @@ -109,7 +110,7 @@ public sealed interface ClassDesc */ static ClassDesc ofInternalName(String name) { validateInternalClassName(name); - return ClassDesc.ofDescriptor("L" + name + ";"); + return ClassDesc.ofDescriptor(concat("L", name, ";")); } /** @@ -132,8 +133,8 @@ public sealed interface ClassDesc return of(className); } validateMemberName(className, false); - return ofDescriptor("L" + binaryToInternal(packageName) + - "/" + className + ";"); + return ofDescriptor('L' + binaryToInternal(packageName) + + '/' + className + ';'); } /** @@ -361,7 +362,7 @@ public sealed interface ClassDesc ClassDesc c = this; for (int i=0; i + + + + Restricted methods + + +

      Restricted methods

      +

      Various methods in the Java SE API allow Java code to interoperate with resources outside the Java runtime + in such a way that the runtime cannot prove correct or safe use of the resources. These methods can, + when used incorrectly, violate the integrity of the Java Virtual Machine, but are conditionally made available + to users, as they provide essential functionality. They are known as restricted methods.

      +

      Given the potential danger of restricted methods, the Java runtime issues a warning on + the standard error stream every time a restricted method is invoked. Such warnings can + be disabled by granting access to restricted methods to selected modules. This can be + done either via implementation-specific command line options or programmatically, e.g. + by calling ModuleLayer.Controller.enableNativeAccess(java.lang.Module).

      +

      When a restricted method is invoked by JNI code, + or from an upcall stub + and there is no caller class on the stack, it is as if the restricted method call occurred in an unnamed module.

      +

      In the reference implementation, access to restricted methods can be granted to + specific modules using the command line option --enable-native-access=M1,M2, ... Mn, + where M1, M2, ... Mn are module names (for the unnamed module, + the special value ALL-UNNAMED can be used). Access to restricted methods + from modules not listed by that option is deemed illegal. Clients can + control how access to restricted methods is handled, using the command line + option --illegal-native-access. If this option is not specified, + illegal access to restricted methods will result in runtime warnings.

      + + diff --git a/src/java.base/share/classes/java/lang/doc-files/threadPrimitiveDeprecation.html b/src/java.base/share/classes/java/lang/doc-files/threadPrimitiveDeprecation.html index c680c0d2745..9f3ad156727 100644 --- a/src/java.base/share/classes/java/lang/doc-files/threadPrimitiveDeprecation.html +++ b/src/java.base/share/classes/java/lang/doc-files/threadPrimitiveDeprecation.html @@ -71,7 +71,7 @@ the variable indicates that it is to stop running. To ensure prompt communication of the stop-request, the variable must be volatile (or access to the variable must be synchronized).

      -

      For example, suppose your applet contains the following +

      For example, suppose your application contains the following start, stop and run methods:

      @@ -92,12 +92,12 @@ methods:

      Thread.sleep(interval); } catch (InterruptedException e){ } - repaint(); + blink(); } }
      You can avoid the use of Thread.stop by replacing the -applet's stop and run methods with: +application's stop and run methods with:
           private volatile Thread blinker;
       
      @@ -112,7 +112,7 @@ applet's stop and run methods with:
                       Thread.sleep(interval);
                   } catch (InterruptedException e){
                   }
      -            repaint();
      +            blink();
               }
           }
       
      diff --git a/src/java.base/share/classes/java/lang/foreign/MemorySegment.java b/src/java.base/share/classes/java/lang/foreign/MemorySegment.java index 8f171fd8bfb..9fadc2f0f56 100644 --- a/src/java.base/share/classes/java/lang/foreign/MemorySegment.java +++ b/src/java.base/share/classes/java/lang/foreign/MemorySegment.java @@ -43,6 +43,7 @@ import java.util.function.Consumer; import java.util.stream.Stream; import jdk.internal.foreign.AbstractMemorySegmentImpl; import jdk.internal.foreign.MemorySessionImpl; +import jdk.internal.foreign.SegmentBulkOperations; import jdk.internal.foreign.SegmentFactories; import jdk.internal.javac.Restricted; import jdk.internal.reflect.CallerSensitive; @@ -1284,6 +1285,14 @@ public sealed interface MemorySegment permits AbstractMemorySegmentImpl { * 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. + *

      + * Getting a string from a segment with a known byte offset and + * known byte length can be done like so: + * {@snippet lang=java : + * byte[] bytes = new byte[length]; + * MemorySegment.copy(segment, JAVA_BYTE, offset, bytes, 0, length); + * return new String(bytes, charset); + * } * * @param offset offset in bytes (relative to this segment address) at which this * access operation will occur @@ -1570,8 +1579,9 @@ public sealed interface MemorySegment permits AbstractMemorySegmentImpl { @ForceInline static void copy(MemorySegment srcSegment, long srcOffset, MemorySegment dstSegment, long dstOffset, long bytes) { - copy(srcSegment, ValueLayout.JAVA_BYTE, srcOffset, - dstSegment, ValueLayout.JAVA_BYTE, dstOffset, + + SegmentBulkOperations.copy((AbstractMemorySegmentImpl) srcSegment, srcOffset, + (AbstractMemorySegmentImpl) dstSegment, dstOffset, bytes); } @@ -2634,8 +2644,9 @@ public sealed interface MemorySegment permits AbstractMemorySegmentImpl { */ static long mismatch(MemorySegment srcSegment, long srcFromOffset, long srcToOffset, MemorySegment dstSegment, long dstFromOffset, long dstToOffset) { - return AbstractMemorySegmentImpl.mismatch(srcSegment, srcFromOffset, srcToOffset, - dstSegment, dstFromOffset, dstToOffset); + return SegmentBulkOperations.mismatch( + (AbstractMemorySegmentImpl)Objects.requireNonNull(srcSegment), srcFromOffset, srcToOffset, + (AbstractMemorySegmentImpl)Objects.requireNonNull(dstSegment), dstFromOffset, dstToOffset); } /** diff --git a/src/java.base/share/classes/java/lang/foreign/SymbolLookup.java b/src/java.base/share/classes/java/lang/foreign/SymbolLookup.java index c6e4443b570..d0dc60b3f77 100644 --- a/src/java.base/share/classes/java/lang/foreign/SymbolLookup.java +++ b/src/java.base/share/classes/java/lang/foreign/SymbolLookup.java @@ -31,6 +31,7 @@ import jdk.internal.foreign.MemorySessionImpl; import jdk.internal.foreign.Utils; import jdk.internal.javac.Restricted; import jdk.internal.loader.BuiltinClassLoader; +import jdk.internal.loader.NativeLibraries; import jdk.internal.loader.NativeLibrary; import jdk.internal.loader.RawNativeLibraries; import jdk.internal.reflect.CallerSensitive; @@ -256,7 +257,8 @@ public interface SymbolLookup { if (Utils.containsNullChars(name)) return Optional.empty(); JavaLangAccess javaLangAccess = SharedSecrets.getJavaLangAccess(); // note: ClassLoader::findNative supports a null loader - long addr = javaLangAccess.findNative(loader, name); + NativeLibraries nativeLibraries = javaLangAccess.nativeLibrariesFor(loader); + long addr = nativeLibraries.find(name); return addr == 0L ? Optional.empty() : Optional.of(MemorySegment.ofAddress(addr) diff --git a/src/java.base/share/classes/java/lang/foreign/package-info.java b/src/java.base/share/classes/java/lang/foreign/package-info.java index 1f31301638e..18419ba1877 100644 --- a/src/java.base/share/classes/java/lang/foreign/package-info.java +++ b/src/java.base/share/classes/java/lang/foreign/package-info.java @@ -128,49 +128,9 @@ * {@linkplain java.lang.foreign.SegmentAllocator#allocateFrom(java.lang.String) converting} * Java strings into zero-terminated, UTF-8 strings, as demonstrated in the above example. * - *

      Restricted methods

      - * - * Some methods in this package are considered restricted. Restricted methods - * are typically used to bind native foreign data and/or functions to first-class - * Java API elements which can then be used directly by clients. For instance the - * restricted method {@link java.lang.foreign.MemorySegment#reinterpret(long)} can be - * used to create a fresh segment with the same address and temporal bounds, but with - * the provided size. This can be useful to resize memory segments obtained when - * interacting with native functions. - *

      - * Binding foreign data and/or functions is generally unsafe and, if done incorrectly, - * can result in VM crashes, or memory corruption when the bound Java API element - * is accessed. For instance, incorrectly resizing a native memory segment using - * {@link java.lang.foreign.MemorySegment#reinterpret(long)} can lead to a JVM crash, or, - * worse, lead to silent memory corruption when attempting to access the resized segment. - * For these reasons, it is crucial for code that calls a restricted method to never pass - * arguments that might cause incorrect binding of foreign data and/or functions to - * a Java API. - *

      - * Given the potential danger of restricted methods, the Java runtime issues a warning on - * the standard error stream every time a restricted method is invoked. Such warnings can - * be disabled by granting access to restricted methods to selected modules. This can be - * done either via implementation-specific command line options or programmatically, e.g. - * by calling {@link java.lang.ModuleLayer.Controller#enableNativeAccess(java.lang.Module)}. - *

      - * For every class in this package, unless specified otherwise, any method arguments of - * reference type must not be {@code null}, and any null argument will elicit a - * {@code NullPointerException}. This fact is not individually documented for methods of - * this API. - * * @apiNote Usual memory model guarantees (see {@jls 17.4}) do not apply when accessing * native memory segments as these segments are backed by off-heap regions of memory. * - * @implNote - * In the reference implementation, access to restricted methods can be granted to - * specific modules using the command line option {@code --enable-native-access=M1,M2, ... Mn}, - * where {@code M1}, {@code M2}, {@code ... Mn} are module names (for the unnamed module, - * the special value {@code ALL-UNNAMED} can be used). Access to restricted methods - * from modules not listed by that option is deemed illegal. Clients can - * control how access to restricted methods is handled, using the command line - * option {@code --illegal-native-access}. If this option is not specified, - * illegal access to restricted methods will result in runtime warnings. - * * @spec jni/index.html Java Native Interface Specification * * @since 22 diff --git a/src/java.base/share/classes/java/lang/invoke/BootstrapMethodInvoker.java b/src/java.base/share/classes/java/lang/invoke/BootstrapMethodInvoker.java index 11e9b720421..6e0cc994481 100644 --- a/src/java.base/share/classes/java/lang/invoke/BootstrapMethodInvoker.java +++ b/src/java.base/share/classes/java/lang/invoke/BootstrapMethodInvoker.java @@ -99,7 +99,7 @@ final class BootstrapMethodInvoker { // with empty constant arguments? if (isStringConcatFactoryBSM(bootstrapMethod.type())) { result = (CallSite)bootstrapMethod - .invokeExact(caller, name, (MethodType)type, + .invokeBasic(caller, name, (MethodType)type, (String)info, new Object[0]); } else { info = maybeReBox(info); @@ -131,23 +131,19 @@ final class BootstrapMethodInvoker { MethodType bsmType = bootstrapMethod.type(); if (isLambdaMetafactoryIndyBSM(bsmType) && argv.length == 3) { result = (CallSite)bootstrapMethod - .invokeExact(caller, name, (MethodType)type, (MethodType)argv[0], - (MethodHandle)argv[1], (MethodType)argv[2]); - } else if (isLambdaMetafactoryCondyBSM(bsmType) && argv.length == 3) { - result = bootstrapMethod - .invokeExact(caller, name, (Class)type, (MethodType)argv[0], + .invokeBasic(caller, name, (MethodType)type, (MethodType)argv[0], (MethodHandle)argv[1], (MethodType)argv[2]); } else if (isStringConcatFactoryBSM(bsmType) && argv.length >= 1) { String recipe = (String)argv[0]; Object[] shiftedArgs = Arrays.copyOfRange(argv, 1, argv.length); maybeReBoxElements(shiftedArgs); - result = (CallSite)bootstrapMethod.invokeExact(caller, name, (MethodType)type, recipe, shiftedArgs); + result = (CallSite)bootstrapMethod.invokeBasic(caller, name, (MethodType)type, recipe, shiftedArgs); } else if (isLambdaMetafactoryAltMetafactoryBSM(bsmType)) { maybeReBoxElements(argv); - result = (CallSite)bootstrapMethod.invokeExact(caller, name, (MethodType)type, argv); + result = (CallSite)bootstrapMethod.invokeBasic(caller, name, (MethodType)type, argv); } else if (isObjectMethodsBootstrapBSM(bsmType)) { MethodHandle[] mhs = Arrays.copyOfRange(argv, 2, argv.length, MethodHandle[].class); - result = bootstrapMethod.invokeExact(caller, name, (TypeDescriptor)type, (Class)argv[0], (String)argv[1], mhs); + result = bootstrapMethod.invokeBasic(caller, name, (TypeDescriptor)type, (Class)argv[0], (String)argv[1], mhs); } else { maybeReBoxElements(argv); if (type instanceof Class c) { @@ -252,9 +248,6 @@ final class BootstrapMethodInvoker { private static final MethodType OBJECT_METHODS_MT = MethodType.methodType(Object.class, Lookup.class, String.class, TypeDescriptor.class, Class.class, String.class, MethodHandle[].class); - private static final MethodType LMF_CONDY_MT = MethodType.methodType(Object.class, - Lookup.class, String.class, Class.class, MethodType.class, MethodHandle.class, MethodType.class); - private static final MethodType SCF_MT = MethodType.methodType(CallSite.class, Lookup.class, String.class, MethodType.class, String.class, Object[].class); @@ -267,15 +260,6 @@ final class BootstrapMethodInvoker { return bsmType == SCF_MT; } - /** - * @return true iff the BSM method type exactly matches - * {@link java.lang.invoke.LambdaMetafactory#metafactory( - * MethodHandles.Lookup,String,Class,MethodType,MethodHandle,MethodType)} - */ - private static boolean isLambdaMetafactoryCondyBSM(MethodType bsmType) { - return bsmType == LMF_CONDY_MT; - } - /** * @return true iff the BSM method type exactly matches * {@link java.lang.invoke.LambdaMetafactory#metafactory( diff --git a/src/java.base/share/classes/java/lang/invoke/DelegatingMethodHandle.java b/src/java.base/share/classes/java/lang/invoke/DelegatingMethodHandle.java index 44bca025b8b..90da523dec8 100644 --- a/src/java.base/share/classes/java/lang/invoke/DelegatingMethodHandle.java +++ b/src/java.base/share/classes/java/lang/invoke/DelegatingMethodHandle.java @@ -143,7 +143,7 @@ abstract sealed class DelegatingMethodHandle extends MethodHandle final int PRE_ACTION = hasPreAction ? nameCursor++ : -1; final int NEXT_MH = customized ? -1 : nameCursor++; final int REINVOKE = nameCursor++; - LambdaForm.Name[] names = LambdaForm.arguments(nameCursor - ARG_LIMIT, mtype.invokerType()); + LambdaForm.Name[] names = LambdaForm.invokeArguments(nameCursor - ARG_LIMIT, mtype); assert(names.length == nameCursor); names[THIS_DMH] = names[THIS_DMH].withConstraint(constraint); Object[] targetArgs; diff --git a/src/java.base/share/classes/java/lang/invoke/DirectMethodHandle.java b/src/java.base/share/classes/java/lang/invoke/DirectMethodHandle.java index 850ed2f53f9..8316c867dc2 100644 --- a/src/java.base/share/classes/java/lang/invoke/DirectMethodHandle.java +++ b/src/java.base/share/classes/java/lang/invoke/DirectMethodHandle.java @@ -250,11 +250,17 @@ sealed class DirectMethodHandle extends MethodHandle { default: throw new InternalError("which="+which); } - MethodType mtypeWithArg = mtype.appendParameterTypes(MemberName.class); - if (doesAlloc) - mtypeWithArg = mtypeWithArg - .insertParameterTypes(0, Object.class) // insert newly allocated obj - .changeReturnType(void.class); // returns void + MethodType mtypeWithArg; + if (doesAlloc) { + var ptypes = mtype.ptypes(); + var newPtypes = new Class[ptypes.length + 2]; + newPtypes[0] = Object.class; // insert newly allocated obj + System.arraycopy(ptypes, 0, newPtypes, 1, ptypes.length); + newPtypes[newPtypes.length - 1] = MemberName.class; + mtypeWithArg = MethodType.methodType(void.class, newPtypes, true); + } else { + mtypeWithArg = mtype.appendParameterTypes(MemberName.class); + } MemberName linker = new MemberName(MethodHandle.class, linkerName, mtypeWithArg, REF_invokeStatic); try { linker = IMPL_NAMES.resolveOrFail(REF_invokeStatic, linker, null, LM_TRUSTED, @@ -270,7 +276,7 @@ sealed class DirectMethodHandle extends MethodHandle { final int GET_MEMBER = nameCursor++; final int CHECK_RECEIVER = (needsReceiverCheck ? nameCursor++ : -1); final int LINKER_CALL = nameCursor++; - Name[] names = arguments(nameCursor - ARG_LIMIT, mtype.invokerType()); + Name[] names = invokeArguments(nameCursor - ARG_LIMIT, mtype); assert(names.length == nameCursor); if (doesAlloc) { // names = { argx,y,z,... new C, init method } @@ -786,7 +792,7 @@ sealed class DirectMethodHandle extends MethodHandle { final int LINKER_CALL = nameCursor++; final int POST_CAST = (needsCast && isGetter ? nameCursor++ : -1); final int RESULT = nameCursor-1; // either the call or the cast - Name[] names = arguments(nameCursor - ARG_LIMIT, mtype.invokerType()); + Name[] names = invokeArguments(nameCursor - ARG_LIMIT, mtype); if (needsInit) names[INIT_BAR] = new Name(getFunction(NF_ensureInitialized), names[DMH_THIS]); if (needsCast && !isGetter) diff --git a/src/java.base/share/classes/java/lang/invoke/GenerateJLIClassesHelper.java b/src/java.base/share/classes/java/lang/invoke/GenerateJLIClassesHelper.java index 1e3f465f97d..a9497502ec6 100644 --- a/src/java.base/share/classes/java/lang/invoke/GenerateJLIClassesHelper.java +++ b/src/java.base/share/classes/java/lang/invoke/GenerateJLIClassesHelper.java @@ -563,7 +563,7 @@ class GenerateJLIClassesHelper { .withSuperclass(InvokerBytecodeGenerator.INVOKER_SUPER_DESC) .with(SourceFileAttribute.of(className.substring(className.lastIndexOf('/') + 1))); for (int i = 0; i < forms.length; i++) { - new InvokerBytecodeGenerator(className, names[i], forms[i], forms[i].methodType()).addMethod(clb); + new InvokerBytecodeGenerator(className, names[i], forms[i], forms[i].methodType()).addMethod(clb, false); } }); } diff --git a/src/java.base/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java b/src/java.base/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java index 24c97d7f7dc..10f282065fd 100644 --- a/src/java.base/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java +++ b/src/java.base/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java @@ -34,12 +34,10 @@ import java.io.Serializable; import java.lang.classfile.ClassBuilder; import java.lang.classfile.ClassFile; import java.lang.classfile.CodeBuilder; -import java.lang.classfile.FieldBuilder; import java.lang.classfile.MethodBuilder; import java.lang.classfile.Opcode; import java.lang.classfile.TypeKind; import java.lang.constant.ClassDesc; -import java.lang.constant.DynamicConstantDesc; import java.lang.constant.MethodTypeDesc; import java.lang.reflect.Modifier; import java.util.LinkedHashSet; @@ -51,14 +49,15 @@ import static java.lang.classfile.ClassFile.*; import java.lang.classfile.attribute.ExceptionsAttribute; import java.lang.classfile.constantpool.ClassEntry; import java.lang.classfile.constantpool.ConstantPoolBuilder; -import java.lang.classfile.constantpool.MethodRefEntry; + import static java.lang.constant.ConstantDescs.*; -import static java.lang.invoke.MethodHandles.Lookup.ClassOption.NESTMATE; -import static java.lang.invoke.MethodHandles.Lookup.ClassOption.STRONG; +import static java.lang.invoke.MethodHandleNatives.Constants.NESTMATE_CLASS; +import static java.lang.invoke.MethodHandleNatives.Constants.STRONG_LOADER_LINK; import static java.lang.invoke.MethodType.methodType; import jdk.internal.constant.ConstantUtils; import jdk.internal.constant.MethodTypeDescImpl; import jdk.internal.constant.ReferenceClassDescImpl; +import jdk.internal.vm.annotation.Stable; import sun.invoke.util.Wrapper; /** @@ -69,7 +68,7 @@ import sun.invoke.util.Wrapper; */ /* package */ final class InnerClassLambdaMetafactory extends AbstractValidatingLambdaMetafactory { private static final String LAMBDA_INSTANCE_FIELD = "LAMBDA_INSTANCE$"; - private static final String[] EMPTY_STRING_ARRAY = new String[0]; + private static final @Stable String[] ARG_NAME_CACHE = {"arg$1", "arg$2", "arg$3", "arg$4", "arg$5", "arg$6", "arg$7", "arg$8"}; private static final ClassDesc[] EMPTY_CLASSDESC_ARRAY = ConstantUtils.EMPTY_CLASSDESC; // For dumping generated classes to disk, for debugging purposes @@ -94,10 +93,10 @@ import sun.invoke.util.Wrapper; private final MethodTypeDesc implMethodDesc; // Type descriptor for implementation methods "(I)Ljava/lang/String;" private final MethodType constructorType; // Generated class constructor type "(CC)void" private final MethodTypeDesc constructorTypeDesc;// Type descriptor for the generated class constructor type "(CC)void" - private final String[] argNames; // Generated names for the constructor arguments private final ClassDesc[] argDescs; // Type descriptors for the constructor arguments private final String lambdaClassName; // Generated name for the generated class "X$$Lambda$1" - private final ClassDesc lambdaClassDesc; // Type descriptor for the generated class "X$$Lambda$1" + private final ConstantPoolBuilder pool = ConstantPoolBuilder.of(); + private final ClassEntry lambdaClassEntry; // Class entry for the generated class "X$$Lambda$1" private final boolean useImplMethodHandle; // use MethodHandle invocation instead of symbolic bytecode invocation /** @@ -157,9 +156,8 @@ import sun.invoke.util.Wrapper; implMethodName = implInfo.getName(); implMethodDesc = methodDesc(implInfo.getMethodType()); constructorType = factoryType.changeReturnType(Void.TYPE); - constructorTypeDesc = methodDesc(constructorType); lambdaClassName = lambdaClassName(targetClass); - lambdaClassDesc = ClassDesc.ofInternalName(lambdaClassName); + lambdaClassEntry = pool.classEntry(ReferenceClassDescImpl.ofValidated(ConstantUtils.concat("L", lambdaClassName, ";"))); // If the target class invokes a protected method inherited from a // superclass in a different package, or does 'invokespecial', the // lambda class has no access to the resolved method, or does @@ -172,17 +170,24 @@ import sun.invoke.util.Wrapper; implKind == MethodHandleInfo.REF_invokeSpecial || implKind == MethodHandleInfo.REF_invokeStatic && implClass.isHidden(); int parameterCount = factoryType.parameterCount(); + ClassDesc[] argDescs; + MethodTypeDesc constructorTypeDesc; if (parameterCount > 0) { - argNames = new String[parameterCount]; argDescs = new ClassDesc[parameterCount]; for (int i = 0; i < parameterCount; i++) { - argNames[i] = "arg$" + (i + 1); argDescs[i] = classDesc(factoryType.parameterType(i)); } + constructorTypeDesc = MethodTypeDescImpl.ofValidated(CD_void, argDescs); } else { - argNames = EMPTY_STRING_ARRAY; argDescs = EMPTY_CLASSDESC_ARRAY; + constructorTypeDesc = MTD_void; } + this.argDescs = argDescs; + this.constructorTypeDesc = constructorTypeDesc; + } + + private static String argName(int i) { + return i < ARG_NAME_CACHE.length ? ARG_NAME_CACHE[i] : "arg$" + (i + 1); } private static String lambdaClassName(Class targetClass) { @@ -191,7 +196,7 @@ import sun.invoke.util.Wrapper; // use the original class name name = name.replace('/', '_'); } - return name.replace('.', '/') + "$$Lambda"; + return name.replace('.', '/').concat("$$Lambda"); } /** @@ -221,7 +226,7 @@ import sun.invoke.util.Wrapper; MethodHandle mh = caller.findConstructor(innerClass, constructorType); if (factoryType.parameterCount() == 0) { // In the case of a non-capturing lambda, we optimize linkage by pre-computing a single instance - Object inst = mh.asType(methodType(Object.class)).invokeExact(); + Object inst = mh.invokeBasic(); return new ConstantCallSite(MethodHandles.constant(interfaceClass, inst)); } else { return new ConstantCallSite(mh.asType(factoryType)); @@ -303,14 +308,14 @@ import sun.invoke.util.Wrapper; interfaces = List.copyOf(itfs); } final boolean finalAccidentallySerializable = accidentallySerializable; - final byte[] classBytes = ClassFile.of().build(lambdaClassDesc, new Consumer() { + final byte[] classBytes = ClassFile.of().build(lambdaClassEntry, pool, new Consumer() { @Override public void accept(ClassBuilder clb) { clb.withFlags(ACC_SUPER | ACC_FINAL | ACC_SYNTHETIC) .withInterfaceSymbols(interfaces); // Generate final fields to be filled in by constructor for (int i = 0; i < argDescs.length; i++) { - clb.withField(argNames[i], argDescs[i], ACC_PRIVATE | ACC_FINAL); + clb.withField(argName(i), argDescs[i], ACC_PRIVATE | ACC_FINAL); } generateConstructor(clb); @@ -347,7 +352,7 @@ import sun.invoke.util.Wrapper; try { // this class is linked at the indy callsite; so define a hidden nestmate var classdata = useImplMethodHandle? implementation : null; - return caller.makeHiddenClassDefiner(lambdaClassName, classBytes, Set.of(NESTMATE, STRONG), lambdaProxyClassFileDumper) + return caller.makeHiddenClassDefiner(lambdaClassName, classBytes, lambdaProxyClassFileDumper, NESTMATE_CLASS | STRONG_LOADER_LINK) .defineClass(!disableEagerInitialization, classdata); } catch (Throwable t) { @@ -369,10 +374,10 @@ import sun.invoke.util.Wrapper; @Override public void accept(CodeBuilder cob) { assert factoryType.parameterCount() == 0; - cob.new_(lambdaClassDesc) + cob.new_(lambdaClassEntry) .dup() - .invokespecial(lambdaClassDesc, INIT_NAME, constructorTypeDesc) - .putstatic(lambdaClassDesc, LAMBDA_INSTANCE_FIELD, lambdaTypeDescriptor) + .invokespecial(pool.methodRefEntry(lambdaClassEntry, pool.nameAndTypeEntry(INIT_NAME, constructorTypeDesc))) + .putstatic(pool.fieldRefEntry(lambdaClassEntry, pool.nameAndTypeEntry(LAMBDA_INSTANCE_FIELD, lambdaTypeDescriptor))) .return_(); } }); @@ -391,10 +396,9 @@ import sun.invoke.util.Wrapper; .invokespecial(CD_Object, INIT_NAME, MTD_void); int parameterCount = factoryType.parameterCount(); for (int i = 0; i < parameterCount; i++) { - cob.aload(0); - Class argType = factoryType.parameterType(i); - cob.loadLocal(TypeKind.from(argType), cob.parameterSlot(i)); - cob.putfield(lambdaClassDesc, argNames[i], argDescs[i]); + cob.aload(0) + .loadLocal(TypeKind.from(factoryType.parameterType(i)), cob.parameterSlot(i)) + .putfield(pool.fieldRefEntry(lambdaClassEntry, pool.nameAndTypeEntry(argName(i), argDescs[i]))); } cob.return_(); } @@ -446,7 +450,7 @@ import sun.invoke.util.Wrapper; cob.dup() .loadConstant(i) .aload(0) - .getfield(lambdaClassDesc, argNames[i], argDescs[i]); + .getfield(pool.fieldRefEntry(lambdaClassEntry, pool.nameAndTypeEntry(argName(i), argDescs[i]))); TypeConvertingMethodAdapter.boxIfTypePrimitive(cob, TypeKind.from(argDescs[i])); cob.aastore(); } @@ -503,9 +507,9 @@ import sun.invoke.util.Wrapper; cob.ldc(cp.constantDynamicEntry(cp.bsmEntry(cp.methodHandleEntry(BSM_CLASS_DATA), List.of()), cp.nameAndTypeEntry(DEFAULT_NAME, CD_MethodHandle))); } - for (int i = 0; i < argNames.length; i++) { + for (int i = 0; i < argDescs.length; i++) { cob.aload(0) - .getfield(lambdaClassDesc, argNames[i], argDescs[i]); + .getfield(pool.fieldRefEntry(lambdaClassEntry, pool.nameAndTypeEntry(argName(i), argDescs[i]))); } convertArgumentTypes(cob, methodType); diff --git a/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java b/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java index 0636c2ddea5..5d307a9ff04 100644 --- a/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java +++ b/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java @@ -32,6 +32,9 @@ import sun.invoke.util.Wrapper; import java.lang.classfile.*; import java.lang.classfile.attribute.RuntimeVisibleAnnotationsAttribute; import java.lang.classfile.attribute.SourceFileAttribute; +import java.lang.classfile.constantpool.ClassEntry; +import java.lang.classfile.constantpool.ConstantPoolBuilder; +import java.lang.classfile.constantpool.FieldRefEntry; import java.lang.classfile.instruction.SwitchCase; import java.lang.constant.ClassDesc; import java.lang.constant.ConstantDesc; @@ -44,7 +47,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; -import java.util.Set; import java.util.function.Consumer; import java.util.stream.Stream; import jdk.internal.constant.MethodTypeDescImpl; @@ -57,6 +59,8 @@ import static java.lang.invoke.LambdaForm.BasicType.*; import static java.lang.invoke.MethodHandleNatives.Constants.*; import static java.lang.invoke.MethodHandleStatics.*; import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP; +import static jdk.internal.constant.ConstantUtils.concat; +import static jdk.internal.constant.ConstantUtils.validateInternalClassName; /** * Code generation backend for LambdaForm. @@ -67,6 +71,7 @@ class InvokerBytecodeGenerator { /** Define class names for convenience. */ private static final ClassDesc CD_CasesHolder = ReferenceClassDescImpl.ofValidated("Ljava/lang/invoke/MethodHandleImpl$CasesHolder;"); private static final ClassDesc CD_DirectMethodHandle = ReferenceClassDescImpl.ofValidated("Ljava/lang/invoke/DirectMethodHandle;"); + private static final ClassDesc CD_MemberName = ReferenceClassDescImpl.ofValidated("Ljava/lang/invoke/MemberName;"); private static final ClassDesc CD_MethodHandleImpl = ReferenceClassDescImpl.ofValidated("Ljava/lang/invoke/MethodHandleImpl;"); private static final ClassDesc CD_LambdaForm = ReferenceClassDescImpl.ofValidated("Ljava/lang/invoke/LambdaForm;"); private static final ClassDesc CD_LambdaForm_Name = ReferenceClassDescImpl.ofValidated("Ljava/lang/invoke/LambdaForm$Name;"); @@ -89,7 +94,8 @@ class InvokerBytecodeGenerator { /** Name of new class */ private final String name; private final String className; - private final ClassDesc classDesc; + private final ConstantPoolBuilder pool = ConstantPoolBuilder.of(); + private final ClassEntry classEntry; private final LambdaForm lambdaForm; private final String invokerName; @@ -125,8 +131,9 @@ class InvokerBytecodeGenerator { name = makeDumpableClassName(name); } this.name = name; - this.className = CLASS_PREFIX + name; - this.classDesc = ClassDesc.ofInternalName(className); + this.className = CLASS_PREFIX.concat(name); + validateInternalClassName(name); + this.classEntry = pool.classEntry(ReferenceClassDescImpl.ofValidated(concat("L", className, ";"))); this.lambdaForm = lambdaForm; this.invokerName = invokerName; this.invokerType = invokerType; @@ -142,8 +149,8 @@ class InvokerBytecodeGenerator { // Create an array to map name indexes to locals indexes. localsMap[0] = 0; // localsMap has at least one element for (int i = 1, index = 0; i < localsMap.length; i++) { - Wrapper w = Wrapper.forBasicType(mt.parameterType(i - 1)); - index += w.stackSlots(); + Class cl = mt.parameterType(i - 1); + index += (cl == long.class || cl == double.class) ? 2 : 1; localsMap[i] = index; } } @@ -180,44 +187,24 @@ class InvokerBytecodeGenerator { if (ctr == null) ctr = 0; DUMP_CLASS_FILES_COUNTERS.put(className, ctr+1); } - String sfx = ctr.toString(); - while (sfx.length() < 3) - sfx = "0" + sfx; - className += sfx; - return className; + + var buf = new StringBuilder(className.length() + 3).append(className); + int ctrVal = ctr; + if (ctrVal < 10) { + buf.repeat('0', 2); + } else if (ctrVal < 100) { + buf.append('0'); + } + buf.append(ctrVal); + return buf.toString(); } - static class ClassData { - final String name; - final ClassDesc desc; - final Object value; - - ClassData(String name, ClassDesc desc, Object value) { - this.name = name; - this.desc = desc; - this.value = value; - } - - public String name() { return name; } - public String toString() { - return name + ",value="+value; - } - } - - String classData(Object arg) { - ClassDesc desc; - if (arg instanceof Class) { - desc = CD_Class; - } else if (arg instanceof MethodHandle) { - desc = CD_MethodHandle; - } else if (arg instanceof LambdaForm) { - desc = CD_LambdaForm; - } else { - desc = CD_Object; - } + record ClassData(FieldRefEntry field, Object value) {} + FieldRefEntry classData(ClassFileBuilder cfb, Object arg, ClassDesc desc) { // unique static variable name String name; + List classData = this.classData; if (dumper().isEnabled()) { Class c = arg.getClass(); while (c.isArray()) { @@ -227,16 +214,16 @@ class InvokerBytecodeGenerator { } else { name = "_D_" + classData.size(); } - ClassData cd = new ClassData(name, desc, arg); - classData.add(cd); - return name; + var field = pool.fieldRefEntry(classEntry, pool.nameAndTypeEntry(name, desc)); + classData.add(new ClassData(field, arg)); + return field; } /** * Extract the MemberName of a newly-defined method. */ private MemberName loadMethod(byte[] classFile) { - Class invokerClass = LOOKUP.makeHiddenClassDefiner(className, classFile, Set.of(), dumper()) + Class invokerClass = LOOKUP.makeHiddenClassDefiner(className, classFile, dumper()) .defineClass(true, classDataValues()); return resolveInvokerMember(invokerClass, invokerName, invokerType); } @@ -258,10 +245,10 @@ class InvokerBytecodeGenerator { */ private byte[] classFileSetup(Consumer config) { try { - return ClassFile.of().build(classDesc, new Consumer<>() { + return ClassFile.of().build(classEntry, pool, new Consumer<>() { @Override public void accept(ClassBuilder clb) { - clb.withFlags(ACC_FINAL | ACC_SUPER) + clb.withFlags(ACC_ABSTRACT | ACC_SUPER) .withSuperclass(INVOKER_SUPER_DESC) .with(SourceFileAttribute.of(clb.constantPool().utf8Entry(SOURCE_PREFIX + name))); config.accept(clb); @@ -287,15 +274,16 @@ class InvokerBytecodeGenerator { */ private Object classDataValues() { final List cd = classData; - return switch (cd.size()) { + int size = cd.size(); + return switch (size) { case 0 -> null; // special case (classData is not used by ) case 1 -> cd.get(0).value; // special case (single object) case 2 -> List.of(cd.get(0).value, cd.get(1).value); case 3 -> List.of(cd.get(0).value, cd.get(1).value, cd.get(2).value); case 4 -> List.of(cd.get(0).value, cd.get(1).value, cd.get(2).value, cd.get(3).value); default -> { - Object[] data = new Object[classData.size()]; - for (int i = 0; i < classData.size(); i++) { + Object[] data = new Object[size]; + for (int i = 0; i < size; i++) { data[i] = classData.get(i).value; } yield List.of(data); @@ -307,36 +295,42 @@ class InvokerBytecodeGenerator { * to initialize the static final fields with the live class data * LambdaForms can't use condy due to bootstrapping issue. */ - static void clinit(ClassBuilder clb, ClassDesc classDesc, List classData) { + static void clinit(ClassBuilder clb, ClassEntry classEntry, List classData) { if (classData.isEmpty()) return; - for (ClassData p : classData) { - // add the static field - clb.withField(p.name, p.desc, ACC_STATIC | ACC_FINAL); - } - clb.withMethodBody(CLASS_INIT_NAME, MTD_void, ACC_STATIC, new Consumer<>() { @Override public void accept(CodeBuilder cob) { - cob.loadConstant(classDesc) + cob.ldc(classEntry) .invokestatic(CD_MethodHandles, "classData", MTD_Object_Class); - if (classData.size() == 1) { - ClassData p = classData.get(0); - cob.checkcast(p.desc) - .putstatic(classDesc, p.name, p.desc); + int size = classData.size(); + if (size == 1) { + var field = classData.getFirst().field; + // add the static field + clb.withField(field.name(), field.type(), ACC_STATIC | ACC_FINAL); + + var ft = field.typeSymbol(); + if (ft != CD_Object) + cob.checkcast(ft); + cob.putstatic(field); } else { cob.checkcast(CD_List) .astore(0); int index = 0; var listGet = cob.constantPool().interfaceMethodRefEntry(CD_List, "get", MTD_Object_int); - for (ClassData p : classData) { + for (int i = 0; i < size; i++) { + var field = classData.get(i).field; + // add the static field + clb.withField(field.name(), field.type(), ACC_STATIC | ACC_FINAL); // initialize the static field cob.aload(0) .loadConstant(index++) - .invokeinterface(listGet) - .checkcast(p.desc) - .putstatic(classDesc, p.name, p.desc); + .invokeinterface(listGet); + var ft = field.typeSymbol(); + if (ft != CD_Object) + cob.checkcast(ft); + cob.putstatic(field); } } cob.return_(); @@ -354,8 +348,6 @@ class InvokerBytecodeGenerator { /** * Emit a boxing call. - * - * @param wrapper primitive type class to box. */ private void emitBoxing(CodeBuilder cob, TypeKind tk) { TypeConvertingMethodAdapter.box(cob, tk); @@ -363,8 +355,6 @@ class InvokerBytecodeGenerator { /** * Emit an unboxing call (plus preceding checkcast). - * - * @param wrapper wrapper type class to unbox. */ private void emitUnboxing(CodeBuilder cob, TypeKind target) { switch (target) { @@ -433,7 +423,7 @@ class InvokerBytecodeGenerator { ClassDesc sig = classDesc(cls); cob.checkcast(sig); } else { - cob.getstatic(classDesc, classData(cls), CD_Class) + cob.getstatic(classData(cob, cls, CD_Class)) .swap() .invokevirtual(CD_Class, "cast", MTD_Object_Object); if (Object[].class.isAssignableFrom(cls)) @@ -533,45 +523,42 @@ class InvokerBytecodeGenerator { static final Annotation INJECTEDPROFILE = Annotation.of(ReferenceClassDescImpl.ofValidated("Ljava/lang/invoke/InjectedProfile;")); static final Annotation LF_COMPILED = Annotation.of(ReferenceClassDescImpl.ofValidated("Ljava/lang/invoke/LambdaForm$Compiled;")); + // Suppress method in backtraces displayed to the user, mark this method as + // a compiled LambdaForm, then either force or prohibit inlining. + public static final RuntimeVisibleAnnotationsAttribute LF_DONTINLINE_ANNOTATIONS = RuntimeVisibleAnnotationsAttribute.of(HIDDEN, LF_COMPILED, DONTINLINE); + public static final RuntimeVisibleAnnotationsAttribute LF_FORCEINLINE_ANNOTATIONS = RuntimeVisibleAnnotationsAttribute.of(HIDDEN, LF_COMPILED, FORCEINLINE); + /** * Generate an invoker method for the passed {@link LambdaForm}. */ private byte[] generateCustomizedCodeBytes() { - final byte[] classFile = classFileSetup(new Consumer() { + final byte[] classFile = classFileSetup(new Consumer<>() { @Override public void accept(ClassBuilder clb) { - addMethod(clb); - clinit(clb, classDesc, classData); + addMethod(clb, true); + clinit(clb, classEntry, classData); bogusMethod(clb, lambdaForm); } }); return classFile; } - void addMethod(ClassBuilder clb) { - methodSetup(clb, new Consumer() { + void addMethod(ClassBuilder clb, boolean alive) { + methodSetup(clb, new Consumer<>() { @Override public void accept(MethodBuilder mb) { - List annotations = new ArrayList<>(3); - - // Suppress this method in backtraces displayed to the user. - annotations.add(HIDDEN); - - // Mark this method as a compiled LambdaForm - annotations.add(LF_COMPILED); - if (lambdaForm.forceInline) { - // Force inlining of this invoker method. - annotations.add(FORCEINLINE); + mb.accept(LF_FORCEINLINE_ANNOTATIONS); } else { - annotations.add(DONTINLINE); + mb.accept(LF_DONTINLINE_ANNOTATIONS); } - mb.accept(RuntimeVisibleAnnotationsAttribute.of(annotations)); - classData(lambdaForm); // keep LambdaForm instance & its compiled form lifetime tightly coupled. + if (alive) { + classData(mb, lambdaForm, CD_LambdaForm); // keep LambdaForm instance & its compiled form lifetime tightly coupled. + } - mb.withCode(new Consumer() { + mb.withCode(new Consumer<>() { @Override public void accept(CodeBuilder cob) { if (lambdaForm.customized != null) { @@ -579,8 +566,7 @@ class InvokerBytecodeGenerator { // receiver MethodHandle (at slot #0) with an embedded constant and use it instead. // It enables more efficient code generation in some situations, since embedded constants // are compile-time constants for JIT compiler. - cob.getstatic(classDesc, classData(lambdaForm.customized), CD_MethodHandle) - .checkcast(CD_MethodHandle); + cob.getstatic(classData(cob, lambdaForm.customized, CD_MethodHandle)); assert(checkActualReceiver(cob)); // expects MethodHandle on top of the stack cob.astore(0); } @@ -713,7 +699,7 @@ class InvokerBytecodeGenerator { // push receiver MethodHandle target = name.function.resolvedHandle(); assert(target != null) : name.exprString(); - cob.getstatic(classDesc, classData(target), CD_MethodHandle); + cob.getstatic(classData(cob, target, CD_MethodHandle)); emitReferenceCast(cob, MethodHandle.class, target); } else { // load receiver @@ -905,10 +891,9 @@ class InvokerBytecodeGenerator { emitStaticInvoke(cob, invokeBasicName); // goto L_done - cob.goto_w(L_done); - - // L_fallback: - cob.labelBinding(L_fallback); + cob.goto_w(L_done) + // L_fallback: + .labelBinding(L_fallback); // invoke selectAlternativeName.arguments[2] System.arraycopy(preForkClasses, 0, localClasses, 0, preForkClasses.length); @@ -959,26 +944,23 @@ class InvokerBytecodeGenerator { .dropParameterTypes(0,1) .changeReturnType(returnType); - cob.exceptionCatch(L_startBlock, L_endBlock, L_handler, CD_Throwable); - - // Normal case - cob.labelBinding(L_startBlock); + cob.exceptionCatch(L_startBlock, L_endBlock, L_handler, CD_Throwable) + // Normal case + .labelBinding(L_startBlock); // load target emitPushArgument(cob, invoker, 0); emitPushArguments(cob, args, 1); // skip 1st argument: method handle - cob.invokevirtual(CD_MethodHandle, "invokeBasic", methodDesc(type.basicType())); - cob.labelBinding(L_endBlock); - cob.goto_w(L_done); - - // Exceptional case - cob.labelBinding(L_handler); - - // Check exception's type - cob.dup(); + cob.invokevirtual(CD_MethodHandle, "invokeBasic", methodDesc(type.basicType())) + .labelBinding(L_endBlock) + .goto_w(L_done) + // Exceptional case + .labelBinding(L_handler) + // Check exception's type + .dup(); // load exception class emitPushArgument(cob, invoker, 1); - cob.swap(); - cob.invokevirtual(CD_Class, "isInstance", MTD_boolean_Object); + cob.swap() + .invokevirtual(CD_Class, "isInstance", MTD_boolean_Object); Label L_rethrow = cob.newLabel(); cob.ifeq(L_rethrow); @@ -988,13 +970,11 @@ class InvokerBytecodeGenerator { cob.swap(); emitPushArguments(cob, args, 1); // skip 1st argument: method handle MethodType catcherType = type.insertParameterTypes(0, Throwable.class); - cob.invokevirtual(CD_MethodHandle, "invokeBasic", methodDesc(catcherType.basicType())); - cob.goto_w(L_done); - - cob.labelBinding(L_rethrow); - cob.athrow(); - - cob.labelBinding(L_done); + cob.invokevirtual(CD_MethodHandle, "invokeBasic", methodDesc(catcherType.basicType())) + .goto_w(L_done) + .labelBinding(L_rethrow) + .athrow() + .labelBinding(L_done); return result; } @@ -1089,8 +1069,8 @@ class InvokerBytecodeGenerator { cob.labelBinding(lFrom); emitPushArgument(cob, invoker, 0); // load target emitPushArguments(cob, args, 1); // load args (skip 0: method handle) - cob.invokevirtual(CD_MethodHandle, "invokeBasic", methodDesc(type.basicType())); - cob.labelBinding(lTo); + cob.invokevirtual(CD_MethodHandle, "invokeBasic", methodDesc(type.basicType())) + .labelBinding(lTo); // FINALLY_NORMAL: int index = extendLocalsMap(new Class[]{ returnType }); @@ -1098,17 +1078,16 @@ class InvokerBytecodeGenerator { emitStoreInsn(cob, basicReturnType.basicTypeKind(), index); } emitPushArgument(cob, invoker, 1); // load cleanup - cob.loadConstant(null); + cob.aconst_null(); if (isNonVoid) { emitLoadInsn(cob, basicReturnType.basicTypeKind(), index); } emitPushArguments(cob, args, 1); // load args (skip 0: method handle) - cob.invokevirtual(CD_MethodHandle, "invokeBasic", cleanupDesc); - cob.goto_w(lDone); - - // CATCH: - cob.labelBinding(lCatch); - cob.dup(); + cob.invokevirtual(CD_MethodHandle, "invokeBasic", cleanupDesc) + .goto_w(lDone) + // CATCH: + .labelBinding(lCatch) + .dup(); // FINALLY_EXCEPTIONAL: emitPushArgument(cob, invoker, 1); // load cleanup @@ -1121,10 +1100,9 @@ class InvokerBytecodeGenerator { if (isNonVoid) { emitPopInsn(cob, basicReturnType); } - cob.athrow(); - - // DONE: - cob.labelBinding(lDone); + cob.athrow() + // DONE: + .labelBinding(lDone); return result; } @@ -1161,26 +1139,24 @@ class InvokerBytecodeGenerator { } emitPushArgument(cob, invoker, 0); // push switch input - cob.tableswitch(0, numCases - 1, defaultLabel, cases); - - cob.labelBinding(defaultLabel); + cob.tableswitch(0, numCases - 1, defaultLabel, cases) + .labelBinding(defaultLabel); emitPushArgument(cob, invoker, 1); // push default handle emitPushArguments(cob, args, 1); // again, skip collector - cob.invokevirtual(CD_MethodHandle, "invokeBasic", caseDescriptor); - cob.goto_(endLabel); + cob.invokevirtual(CD_MethodHandle, "invokeBasic", caseDescriptor) + .goto_(endLabel); for (int i = 0; i < numCases; i++) { cob.labelBinding(cases.get(i).target()); // Load the particular case: emitLoadInsn(cob, TypeKind.REFERENCE, casesLocal); - cob.loadConstant(i); - cob.aaload(); + cob.loadConstant(i) + .aaload(); // invoke it: emitPushArguments(cob, args, 1); // again, skip collector - cob.invokevirtual(CD_MethodHandle, "invokeBasic", caseDescriptor); - - cob.goto_(endLabel); + cob.invokevirtual(CD_MethodHandle, "invokeBasic", caseDescriptor) + .goto_(endLabel); } cob.labelBinding(endLabel); @@ -1349,16 +1325,14 @@ class InvokerBytecodeGenerator { // invoke fini emitLoopHandleInvoke(cob, invoker, finis, c, args, true, finiType, loopLocalStateTypes, clauseDataIndex, firstLoopStateIndex); - cob.goto_w(lDone); - - // this is the beginning of the next loop clause - cob.labelBinding(lNext); + cob.goto_w(lDone) + // this is the beginning of the next loop clause + .labelBinding(lNext); } - cob.goto_w(lLoop); - - // DONE: - cob.labelBinding(lDone); + cob.goto_w(lLoop) + // DONE: + .labelBinding(lDone); return result; } @@ -1384,8 +1358,8 @@ class InvokerBytecodeGenerator { int firstLoopStateSlot) { // load handle for clause emitPushClauseArray(cob, clauseDataSlot, handles); - cob.loadConstant(clause); - cob.aaload(); + cob.loadConstant(clause) + .aaload(); // load loop state (preceding the other arguments) if (pushLocalState) { for (int s = 0; s < loopLocalStateTypes.length; ++s) { @@ -1399,8 +1373,8 @@ class InvokerBytecodeGenerator { private void emitPushClauseArray(CodeBuilder cob, int clauseDataSlot, int which) { emitLoadInsn(cob, TypeKind.REFERENCE, clauseDataSlot); - cob.loadConstant(which - 1); - cob.aaload(); + cob.loadConstant(which - 1) + .aaload(); } private void emitZero(CodeBuilder cob, BasicType type) { @@ -1438,7 +1412,7 @@ class InvokerBytecodeGenerator { if (Wrapper.isWrapperType(arg.getClass()) && bptype != L_TYPE) { cob.loadConstant((ConstantDesc)arg); } else { - cob.getstatic(classDesc, classData(arg), CD_Object); + cob.getstatic(classData(cob, arg, CD_Object)); emitImplicitConversion(cob, L_TYPE, ptype, arg); } } @@ -1517,10 +1491,10 @@ class InvokerBytecodeGenerator { } private byte[] generateLambdaFormInterpreterEntryPointBytes() { - final byte[] classFile = classFileSetup(new Consumer() { + final byte[] classFile = classFileSetup(new Consumer<>() { @Override public void accept(ClassBuilder clb) { - methodSetup(clb, new Consumer() { + methodSetup(clb, new Consumer<>() { @Override public void accept(MethodBuilder mb) { @@ -1529,18 +1503,18 @@ class InvokerBytecodeGenerator { DONTINLINE // Don't inline the interpreter entry. ))); - mb.withCode(new Consumer() { + mb.withCode(new Consumer<>() { @Override public void accept(CodeBuilder cob) { // create parameter array - cob.loadConstant(invokerType.parameterCount()); - cob.anewarray(CD_Object); + cob.loadConstant(invokerType.parameterCount()) + .anewarray(CD_Object); // fill parameter array for (int i = 0; i < invokerType.parameterCount(); i++) { Class ptype = invokerType.parameterType(i); - cob.dup(); - cob.loadConstant(i); + cob.dup() + .loadConstant(i); emitLoadInsn(cob, basicType(ptype).basicTypeKind(), i); // box if primitive type if (ptype.isPrimitive()) { @@ -1549,10 +1523,10 @@ class InvokerBytecodeGenerator { cob.aastore(); } // invoke - cob.aload(0); - cob.getfield(CD_MethodHandle, "form", CD_LambdaForm); - cob.swap(); // swap form and array; avoid local variable - cob.invokevirtual(CD_LambdaForm, "interpretWithArguments", MethodTypeDescImpl.ofValidated(CD_Object, CD_Object_array)); + cob.aload(0) + .getfield(CD_MethodHandle, "form", CD_LambdaForm) + .swap() // swap form and array; avoid local variable + .invokevirtual(CD_LambdaForm, "interpretWithArguments", MethodTypeDescImpl.ofValidated(CD_Object, CD_Object_array)); // maybe unbox Class rtype = invokerType.returnType(); @@ -1567,7 +1541,7 @@ class InvokerBytecodeGenerator { }); } }); - clinit(clb, classDesc, classData); + clinit(clb, classEntry, classData); bogusMethod(clb, invokerType); } }); @@ -1586,10 +1560,10 @@ class InvokerBytecodeGenerator { private byte[] generateNamedFunctionInvokerImpl(MethodTypeForm typeForm) { MethodType dstType = typeForm.erasedType(); - final byte[] classFile = classFileSetup(new Consumer() { + final byte[] classFile = classFileSetup(new Consumer<>() { @Override public void accept(ClassBuilder clb) { - methodSetup(clb, new Consumer() { + methodSetup(clb, new Consumer<>() { @Override public void accept(MethodBuilder mb) { @@ -1598,7 +1572,7 @@ class InvokerBytecodeGenerator { FORCEINLINE // Force inlining of this invoker method. ))); - mb.withCode(new Consumer() { + mb.withCode(new Consumer<>() { @Override public void accept(CodeBuilder cob) { // Load receiver @@ -1606,9 +1580,9 @@ class InvokerBytecodeGenerator { // Load arguments from array for (int i = 0; i < dstType.parameterCount(); i++) { - cob.aload(1); - cob.loadConstant(i); - cob.aaload(); + cob.aload(1) + .loadConstant(i) + .aaload(); // Maybe unbox Class dptype = dstType.parameterType(i); @@ -1643,7 +1617,7 @@ class InvokerBytecodeGenerator { }); } }); - clinit(clb, classDesc, classData); + clinit(clb, classEntry, classData); bogusMethod(clb, dstType); } }); @@ -1659,9 +1633,9 @@ class InvokerBytecodeGenerator { clb.withMethodBody("dummy", MTD_void, ACC_STATIC, new Consumer<>() { @Override public void accept(CodeBuilder cob) { - cob.loadConstant(os.toString()); - cob.pop(); - cob.return_(); + cob.ldc(os.toString()) + .pop() + .return_(); } }); } @@ -1669,10 +1643,12 @@ class InvokerBytecodeGenerator { static ClassDesc classDesc(Class cls) { // assert(VerifyAccess.isTypeVisible(cls, Object.class)) : cls.getName(); - return cls.isPrimitive() ? Wrapper.forPrimitiveType(cls).basicClassDescriptor() - : cls == MethodHandle.class ? CD_MethodHandle + return cls == MethodHandle.class ? CD_MethodHandle : cls == DirectMethodHandle.class ? CD_DirectMethodHandle : cls == Object.class ? CD_Object + : cls == MemberName.class ? CD_MemberName + : cls == MethodType.class ? CD_MethodType + : cls.isPrimitive() ? Wrapper.forPrimitiveType(cls).basicClassDescriptor() : ReferenceClassDescImpl.ofValidated(cls.descriptorString()); } diff --git a/src/java.base/share/classes/java/lang/invoke/Invokers.java b/src/java.base/share/classes/java/lang/invoke/Invokers.java index 6c383dd3f2c..9990370ae25 100644 --- a/src/java.base/share/classes/java/lang/invoke/Invokers.java +++ b/src/java.base/share/classes/java/lang/invoke/Invokers.java @@ -25,6 +25,7 @@ package java.lang.invoke; +import jdk.internal.invoke.MhUtil; import jdk.internal.vm.annotation.DontInline; import jdk.internal.vm.annotation.ForceInline; import jdk.internal.vm.annotation.Hidden; @@ -314,14 +315,14 @@ class Invokers { final int CHECK_TYPE = nameCursor++; final int CHECK_CUSTOM = (CUSTOMIZE_THRESHOLD >= 0) ? nameCursor++ : -1; final int LINKER_CALL = nameCursor++; - MethodType invokerFormType = mtype.invokerType(); + MethodType invokerFormType = mtype; if (isLinker) { if (!customized) invokerFormType = invokerFormType.appendParameterTypes(MemberName.class); } else { invokerFormType = invokerFormType.invokerType(); } - Name[] names = arguments(nameCursor - INARG_LIMIT, invokerFormType); + Name[] names = invokeArguments(nameCursor - INARG_LIMIT, invokerFormType); assert(names.length == nameCursor) : Arrays.asList(mtype, customized, which, nameCursor, names.length); if (MTYPE_ARG >= INARG_LIMIT) { @@ -390,11 +391,11 @@ class Invokers { final int LINKER_CALL = nameCursor++; Name[] names = new Name[LINKER_CALL + 1]; - names[THIS_VH] = argument(THIS_VH, BasicType.basicType(Object.class)); + names[THIS_VH] = argument(THIS_VH, BasicType.L_TYPE); for (int i = 0; i < mtype.parameterCount(); i++) { names[ARG_BASE + i] = argument(ARG_BASE + i, BasicType.basicType(mtype.parameterType(i))); } - names[VAD_ARG] = new Name(ARG_LIMIT, BasicType.basicType(Object.class)); + names[VAD_ARG] = new Name(ARG_LIMIT, BasicType.L_TYPE); names[UNBOUND_VH] = new Name(getFunction(NF_directVarHandleTarget), names[THIS_VH]); @@ -446,8 +447,8 @@ class Invokers { final int LINKER_CALL = nameCursor++; Name[] names = new Name[LINKER_CALL + 1]; - names[THIS_MH] = argument(THIS_MH, BasicType.basicType(Object.class)); - names[CALL_VH] = argument(CALL_VH, BasicType.basicType(Object.class)); + names[THIS_MH] = argument(THIS_MH, BasicType.L_TYPE); + names[CALL_VH] = argument(CALL_VH, BasicType.L_TYPE); for (int i = 0; i < mtype.parameterCount(); i++) { names[ARG_BASE + i] = argument(ARG_BASE + i, BasicType.basicType(mtype.parameterType(i))); } @@ -589,17 +590,16 @@ class Invokers { final int CSITE_ARG = skipCallSite ? -1 : APPENDIX_ARG; final int CALL_MH = skipCallSite ? APPENDIX_ARG : nameCursor++; // result of getTarget final int LINKER_CALL = nameCursor++; - MethodType invokerFormType = mtype.appendParameterTypes(skipCallSite ? MethodHandle.class : CallSite.class); - Name[] names = arguments(nameCursor - INARG_LIMIT, invokerFormType); - assert(names.length == nameCursor); - assert(names[APPENDIX_ARG] != null); + Name[] names = arguments(nameCursor - INARG_LIMIT + 1, mtype); + assert(names.length == nameCursor && names[APPENDIX_ARG] == null); + names[APPENDIX_ARG] = argument(APPENDIX_ARG, BasicType.L_TYPE); if (!skipCallSite) names[CALL_MH] = new Name(getFunction(NF_getCallSiteTarget), names[CSITE_ARG]); // (site.)invokedynamic(a*):R => mh = site.getTarget(); mh.invokeBasic(a*) final int PREPEND_MH = 0, PREPEND_COUNT = 1; - Object[] outArgs = Arrays.copyOfRange(names, ARG_BASE, OUTARG_LIMIT + PREPEND_COUNT, Object[].class); + Object[] outArgs = new Object[OUTARG_LIMIT + PREPEND_COUNT]; + System.arraycopy(names, 0, outArgs, PREPEND_COUNT, outArgs.length - PREPEND_COUNT); // prepend MH argument: - System.arraycopy(outArgs, 0, outArgs, PREPEND_COUNT, outArgs.length - PREPEND_COUNT); outArgs[PREPEND_MH] = names[CALL_MH]; names[LINKER_CALL] = new Name(mtype, outArgs); lform = LambdaForm.create(INARG_LIMIT, names, @@ -682,16 +682,9 @@ class Invokers { } private static class Lazy { - private static final MethodHandle MH_asSpreader; - - static { - try { - MH_asSpreader = IMPL_LOOKUP.findVirtual(MethodHandle.class, "asSpreader", - MethodType.methodType(MethodHandle.class, Class.class, int.class)); - } catch (ReflectiveOperationException ex) { - throw newInternalError(ex); - } - } + private static final MethodHandle MH_asSpreader = MhUtil.findVirtual( + IMPL_LOOKUP, MethodHandle.class, "asSpreader", + MethodType.methodType(MethodHandle.class, Class.class, int.class)); } static { diff --git a/src/java.base/share/classes/java/lang/invoke/LambdaForm.java b/src/java.base/share/classes/java/lang/invoke/LambdaForm.java index 342cbbe77e5..7109f35f069 100644 --- a/src/java.base/share/classes/java/lang/invoke/LambdaForm.java +++ b/src/java.base/share/classes/java/lang/invoke/LambdaForm.java @@ -1555,6 +1555,7 @@ class LambdaForm { * Return -1 if the name is not used. */ int lastUseIndex(Name n) { + Object[] arguments = this.arguments; if (arguments == null) return -1; for (int i = arguments.length; --i >= 0; ) { if (arguments[i] == n) return i; @@ -1562,21 +1563,6 @@ class LambdaForm { return -1; } - /** Return the number of occurrences of n in the argument array. - * Return 0 if the name is not used. - */ - int useCount(Name n) { - int count = 0; - if (arguments != null) { - for (Object argument : arguments) { - if (argument == n) { - count++; - } - } - } - return count; - } - public boolean equals(Name that) { if (this == that) return true; if (isParam()) @@ -1618,8 +1604,16 @@ class LambdaForm { int useCount(Name n) { int count = (result == n.index) ? 1 : 0; int i = Math.max(n.index + 1, arity); + Name[] names = this.names; while (i < names.length) { - count += names[i++].useCount(n); + Object[] arguments = names[i++].arguments; + if (arguments != null) { + for (Object argument : arguments) { + if (argument == n) { + count++; + } + } + } } return count; } @@ -1642,6 +1636,16 @@ class LambdaForm { names[i] = argument(i, basicType(types.parameterType(i))); return names; } + + static Name[] invokeArguments(int extra, MethodType types) { + int length = types.parameterCount(); + Name[] names = new Name[length + extra + 1]; + names[0] = argument(0, L_TYPE); + for (int i = 0; i < length; i++) + names[i + 1] = argument(i + 1, basicType(types.parameterType(i))); + return names; + } + static final int INTERNED_ARGUMENT_LIMIT = 10; private static final Name[][] INTERNED_ARGUMENTS = new Name[ARG_TYPE_LIMIT][INTERNED_ARGUMENT_LIMIT]; diff --git a/src/java.base/share/classes/java/lang/invoke/MethodHandle.java b/src/java.base/share/classes/java/lang/invoke/MethodHandle.java index edcecce37e0..d3270600707 100644 --- a/src/java.base/share/classes/java/lang/invoke/MethodHandle.java +++ b/src/java.base/share/classes/java/lang/invoke/MethodHandle.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,8 @@ package java.lang.invoke; import jdk.internal.loader.ClassLoaders; +import jdk.internal.vm.annotation.DontInline; +import jdk.internal.vm.annotation.ForceInline; import jdk.internal.vm.annotation.IntrinsicCandidate; import java.lang.constant.ClassDesc; @@ -856,6 +858,7 @@ public abstract sealed class MethodHandle implements Constable * @throws WrongMethodTypeException if the conversion cannot be made * @see MethodHandles#explicitCastArguments */ + @ForceInline public final MethodHandle asType(MethodType newType) { // Fast path alternative to a heavyweight {@code asType} call. // Return 'this' if the conversion will be a no-op. @@ -867,7 +870,7 @@ public abstract sealed class MethodHandle implements Constable if (at != null) { return at; } - return setAsTypeCache(asTypeUncached(newType)); + return setAsTypeCache(newType); } private MethodHandle asTypeCached(MethodType newType) { @@ -885,7 +888,16 @@ public abstract sealed class MethodHandle implements Constable return null; } - private MethodHandle setAsTypeCache(MethodHandle at) { + /* + * We disable inlining here to prevent complex code in the slow path + * of MethodHandle::asType from being inlined into that method. + * Excessive inlining into MethodHandle::asType can cause that method + * to become too big, which will then cause performance issues during + * var handle and method handle calls. + */ + @DontInline + private MethodHandle setAsTypeCache(MethodType newType) { + MethodHandle at = asTypeUncached(newType); // Don't introduce a strong reference in the cache if newType depends on any class loader other than // current method handle already does to avoid class loader leaks. if (isSafeToCache(at.type)) { @@ -1879,8 +1891,7 @@ assertEquals("[three, thee, tee]", asListFix.invoke((Object)argv).toString()); if (oldForm != newForm) { assert (newForm.customized == null || newForm.customized == this); newForm.prepare(); // as in MethodHandle. - UNSAFE.putReference(this, FORM_OFFSET, newForm); - UNSAFE.fullFence(); + UNSAFE.putReferenceRelease(this, FORM_OFFSET, newForm); // properly publish newForm } } finally { updateInProgress = false; diff --git a/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java b/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java index 57446c9b2fd..992ef387684 100644 --- a/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java +++ b/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java @@ -64,6 +64,7 @@ import static java.lang.constant.ConstantDescs.*; import static java.lang.invoke.LambdaForm.*; import static java.lang.invoke.MethodHandleNatives.Constants.MN_CALLER_SENSITIVE; import static java.lang.invoke.MethodHandleNatives.Constants.MN_HIDDEN_MEMBER; +import static java.lang.invoke.MethodHandleNatives.Constants.NESTMATE_CLASS; import static java.lang.invoke.MethodHandleStatics.*; import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP; import static java.lang.invoke.MethodHandles.Lookup.ClassOption.NESTMATE; @@ -809,8 +810,7 @@ abstract class MethodHandleImpl { final int CALL_TARGET = nameCursor++; assert(CALL_TARGET == SELECT_ALT+1); // must be true to trigger IBG.emitSelectAlternative - MethodType lambdaType = basicType.invokerType(); - Name[] names = arguments(nameCursor - ARG_LIMIT, lambdaType); + Name[] names = invokeArguments(nameCursor - ARG_LIMIT, basicType); BoundMethodHandle.SpeciesData data = (GET_COUNTERS != -1) ? BoundMethodHandle.speciesData_LLLL() @@ -842,7 +842,7 @@ abstract class MethodHandleImpl { invokeArgs[0] = names[SELECT_ALT]; names[CALL_TARGET] = new Name(basicType, invokeArgs); - lform = LambdaForm.create(lambdaType.parameterCount(), names, /*forceInline=*/true, Kind.GUARD); + lform = LambdaForm.create(basicType.parameterCount() + 1, names, /*forceInline=*/true, Kind.GUARD); return basicType.form().setCachedLambdaForm(MethodTypeForm.LF_GWT, lform); } @@ -869,8 +869,6 @@ abstract class MethodHandleImpl { * among catchException combinators with the same basic type. */ private static LambdaForm makeGuardWithCatchForm(MethodType basicType) { - MethodType lambdaType = basicType.invokerType(); - LambdaForm lform = basicType.form().cachedLambdaForm(MethodTypeForm.LF_GWC); if (lform != null) { return lform; @@ -889,7 +887,7 @@ abstract class MethodHandleImpl { final int TRY_CATCH = nameCursor++; final int UNBOX_RESULT = nameCursor++; - Name[] names = arguments(nameCursor - ARG_LIMIT, lambdaType); + Name[] names = invokeArguments(nameCursor - ARG_LIMIT, basicType); BoundMethodHandle.SpeciesData data = BoundMethodHandle.speciesData_LLLLL(); names[THIS_MH] = names[THIS_MH].withConstraint(data); @@ -918,7 +916,7 @@ abstract class MethodHandleImpl { Object[] unboxArgs = new Object[] {names[GET_UNBOX_RESULT], names[TRY_CATCH]}; names[UNBOX_RESULT] = new Name(invokeBasicUnbox, unboxArgs); - lform = LambdaForm.create(lambdaType.parameterCount(), names, Kind.GUARD_WITH_CATCH); + lform = LambdaForm.create(basicType.parameterCount() + 1, names, Kind.GUARD_WITH_CATCH); return basicType.form().setCachedLambdaForm(MethodTypeForm.LF_GWC, lform); } @@ -1111,7 +1109,7 @@ abstract class MethodHandleImpl { } name = name.replace('.', '/'); Class invokerClass = new Lookup(targetClass) - .makeHiddenClassDefiner(name, INJECTED_INVOKER_TEMPLATE, Set.of(NESTMATE), dumper()) + .makeHiddenClassDefiner(name, INJECTED_INVOKER_TEMPLATE, dumper(), NESTMATE_CLASS) .defineClass(true, targetClass); assert checkInjectedInvoker(targetClass, invokerClass); return invokerClass; @@ -1732,8 +1730,6 @@ abstract class MethodHandleImpl { * bytecode generation}. */ private static LambdaForm makeLoopForm(MethodType basicType, BasicType[] localVarTypes) { - MethodType lambdaType = basicType.invokerType(); - final int THIS_MH = 0; // the BMH_LLL final int ARG_BASE = 1; // start of incoming arguments final int ARG_LIMIT = ARG_BASE + basicType.parameterCount(); @@ -1748,7 +1744,7 @@ abstract class MethodHandleImpl { LambdaForm lform = basicType.form().cachedLambdaForm(MethodTypeForm.LF_LOOP); if (lform == null) { - Name[] names = arguments(nameCursor - ARG_LIMIT, lambdaType); + Name[] names = invokeArguments(nameCursor - ARG_LIMIT, basicType); BoundMethodHandle.SpeciesData data = BoundMethodHandle.speciesData_LLL(); names[THIS_MH] = names[THIS_MH].withConstraint(data); @@ -1776,7 +1772,7 @@ abstract class MethodHandleImpl { names[UNBOX_RESULT] = new Name(invokeBasicUnbox, unboxArgs); lform = basicType.form().setCachedLambdaForm(MethodTypeForm.LF_LOOP, - LambdaForm.create(lambdaType.parameterCount(), names, Kind.LOOP)); + LambdaForm.create(basicType.parameterCount() + 1, names, Kind.LOOP)); } // BOXED_ARGS is the index into the names array where the loop idiom starts @@ -1965,8 +1961,6 @@ abstract class MethodHandleImpl { * forms among tryFinally combinators with the same basic type. */ private static LambdaForm makeTryFinallyForm(MethodType basicType) { - MethodType lambdaType = basicType.invokerType(); - LambdaForm lform = basicType.form().cachedLambdaForm(MethodTypeForm.LF_TF); if (lform != null) { return lform; @@ -1984,7 +1978,7 @@ abstract class MethodHandleImpl { final int TRY_FINALLY = nameCursor++; final int UNBOX_RESULT = nameCursor++; - Name[] names = arguments(nameCursor - ARG_LIMIT, lambdaType); + Name[] names = invokeArguments(nameCursor - ARG_LIMIT, basicType); BoundMethodHandle.SpeciesData data = BoundMethodHandle.speciesData_LLLL(); names[THIS_MH] = names[THIS_MH].withConstraint(data); @@ -2010,7 +2004,7 @@ abstract class MethodHandleImpl { Object[] unboxArgs = new Object[] {names[GET_UNBOX_RESULT], names[TRY_FINALLY]}; names[UNBOX_RESULT] = new Name(invokeBasicUnbox, unboxArgs); - lform = LambdaForm.create(lambdaType.parameterCount(), names, Kind.TRY_FINALLY); + lform = LambdaForm.create(basicType.parameterCount() + 1, names, Kind.TRY_FINALLY); return basicType.form().setCachedLambdaForm(MethodTypeForm.LF_TF, lform); } @@ -2054,7 +2048,6 @@ abstract class MethodHandleImpl { } private static LambdaForm makeCollectorForm(MethodType basicType, Class arrayType) { - MethodType lambdaType = basicType.invokerType(); int parameterCount = basicType.parameterCount(); // Only share the lambda form for empty arrays and reference types. @@ -2087,7 +2080,7 @@ abstract class MethodHandleImpl { final int STORE_ELEMENT_LIMIT = STORE_ELEMENT_BASE + parameterCount; nameCursor = STORE_ELEMENT_LIMIT; - Name[] names = arguments(nameCursor - ARG_LIMIT, lambdaType); + Name[] names = invokeArguments(nameCursor - ARG_LIMIT, basicType); BoundMethodHandle.SpeciesData data = BoundMethodHandle.speciesData_L(); names[THIS_MH] = names[THIS_MH].withConstraint(data); @@ -2105,7 +2098,7 @@ abstract class MethodHandleImpl { names[CALL_NEW_ARRAY], storeIndex, names[argCursor]); } - LambdaForm lform = LambdaForm.create(lambdaType.parameterCount(), names, CALL_NEW_ARRAY, Kind.COLLECTOR); + LambdaForm lform = LambdaForm.create(basicType.parameterCount() + 1, names, CALL_NEW_ARRAY, Kind.COLLECTOR); if (isSharedLambdaForm) { lform = basicType.form().setCachedLambdaForm(MethodTypeForm.LF_COLLECTOR, lform); } @@ -2168,8 +2161,6 @@ abstract class MethodHandleImpl { private static LambdaForm makeTableSwitchForm(MethodType basicType, BoundMethodHandle.SpeciesData data, int numCases) { - MethodType lambdaType = basicType.invokerType(); - // We need to cache based on the basic type X number of cases, // since the number of cases is used when generating bytecode. // This also means that we can't use the cache in MethodTypeForm, @@ -2201,7 +2192,7 @@ abstract class MethodHandleImpl { final int FIELD_UNBOX_RESULT = fieldCursor++; final int FIELD_CASES = fieldCursor++; - Name[] names = arguments(nameCursor - ARG_LIMIT, lambdaType); + Name[] names = invokeArguments(nameCursor - ARG_LIMIT, basicType); names[THIS_MH] = names[THIS_MH].withConstraint(data); names[GET_DEFAULT_CASE] = new Name(data.getterFunction(FIELD_DEFAULT_CASE), names[THIS_MH]); @@ -2230,7 +2221,7 @@ abstract class MethodHandleImpl { names[UNBOXED_RESULT] = new Name(invokeBasic, unboxArgs); } - lform = LambdaForm.create(lambdaType.parameterCount(), names, Kind.TABLE_SWITCH); + lform = LambdaForm.create(basicType.parameterCount() + 1, names, Kind.TABLE_SWITCH); LambdaForm prev = TableSwitchCacheKey.CACHE.putIfAbsent(key, lform); return prev != null ? prev : lform; } diff --git a/src/java.base/share/classes/java/lang/invoke/MethodHandleProxies.java b/src/java.base/share/classes/java/lang/invoke/MethodHandleProxies.java index 8f0f355a980..9709c881863 100644 --- a/src/java.base/share/classes/java/lang/invoke/MethodHandleProxies.java +++ b/src/java.base/share/classes/java/lang/invoke/MethodHandleProxies.java @@ -54,6 +54,7 @@ import java.lang.classfile.CodeBuilder; import java.lang.classfile.TypeKind; import jdk.internal.constant.ConstantUtils; +import jdk.internal.loader.ClassLoaders; import jdk.internal.module.Modules; import jdk.internal.reflect.CallerSensitive; import jdk.internal.reflect.Reflection; @@ -285,7 +286,7 @@ public class MethodHandleProxies { byte[] template = createTemplate(loader, binaryNameToDesc(className), referenceClassDesc(intfc), uniqueName, methods); // define the dynamic module to the class loader of the interface - var definer = new Lookup(intfc).makeHiddenClassDefiner(className, template, Set.of(), DUMPER); + var definer = new Lookup(intfc).makeHiddenClassDefiner(className, template, DUMPER); @SuppressWarnings("removal") var sm = System.getSecurityManager(); @@ -371,48 +372,46 @@ public class MethodHandleProxies { */ private static byte[] createTemplate(ClassLoader loader, ClassDesc proxyDesc, ClassDesc ifaceDesc, String methodName, List methods) { - return ClassFile.of(ClassHierarchyResolverOption.of(ClassHierarchyResolver.ofClassLoading(loader))) + return ClassFile.of(ClassHierarchyResolverOption.of(ClassHierarchyResolver.ofClassLoading(loader == null ? + ClassLoaders.platformClassLoader() : loader))) .build(proxyDesc, clb -> { - clb.withSuperclass(CD_Object); - clb.withFlags(ACC_FINAL | ACC_SYNTHETIC); - clb.withInterfaceSymbols(ifaceDesc); - - // static and instance fields - clb.withField(TYPE_NAME, CD_Class, ACC_PRIVATE | ACC_STATIC | ACC_FINAL); - clb.withField(TARGET_NAME, CD_MethodHandle, ACC_PRIVATE | ACC_FINAL); + clb.withSuperclass(CD_Object) + .withFlags(ACC_FINAL | ACC_SYNTHETIC) + .withInterfaceSymbols(ifaceDesc) + // static and instance fields + .withField(TYPE_NAME, CD_Class, ACC_PRIVATE | ACC_STATIC | ACC_FINAL) + .withField(TARGET_NAME, CD_MethodHandle, ACC_PRIVATE | ACC_FINAL); for (var mi : methods) { clb.withField(mi.fieldName, CD_MethodHandle, ACC_PRIVATE | ACC_FINAL); } // clb.withMethodBody(CLASS_INIT_NAME, MTD_void, ACC_STATIC, cob -> { - cob.loadConstant(ifaceDesc); - cob.putstatic(proxyDesc, TYPE_NAME, CD_Class); - cob.return_(); + cob.loadConstant(ifaceDesc) + .putstatic(proxyDesc, TYPE_NAME, CD_Class) + .return_(); }); // (Lookup, MethodHandle target, MethodHandle callerBoundTarget) clb.withMethodBody(INIT_NAME, MTD_void_Lookup_MethodHandle_MethodHandle, 0, cob -> { - cob.aload(0); - cob.invokespecial(CD_Object, INIT_NAME, MTD_void); - - // call ensureOriginalLookup to verify the given Lookup has access - cob.aload(1); - cob.invokestatic(proxyDesc, "ensureOriginalLookup", MTD_void_Lookup); - - // this.target = target; - cob.aload(0); - cob.aload(2); - cob.putfield(proxyDesc, TARGET_NAME, CD_MethodHandle); + cob.aload(0) + .invokespecial(CD_Object, INIT_NAME, MTD_void) + // call ensureOriginalLookup to verify the given Lookup has access + .aload(1) + .invokestatic(proxyDesc, ENSURE_ORIGINAL_LOOKUP, MTD_void_Lookup) + // this.target = target; + .aload(0) + .aload(2) + .putfield(proxyDesc, TARGET_NAME, CD_MethodHandle); // method handles adjusted to the method type of each method for (var mi : methods) { // this.m = callerBoundTarget.asType(xxType); - cob.aload(0); - cob.aload(3); - cob.loadConstant(mi.desc); - cob.invokevirtual(CD_MethodHandle, "asType", MTD_MethodHandle_MethodType); - cob.putfield(proxyDesc, mi.fieldName, CD_MethodHandle); + cob.aload(0) + .aload(3) + .loadConstant(mi.desc) + .invokevirtual(CD_MethodHandle, "asType", MTD_MethodHandle_MethodType) + .putfield(proxyDesc, mi.fieldName, CD_MethodHandle); } // complete @@ -425,26 +424,26 @@ public class MethodHandleProxies { clb.withMethodBody(ENSURE_ORIGINAL_LOOKUP, MTD_void_Lookup, ACC_PRIVATE | ACC_STATIC, cob -> { var failLabel = cob.newLabel(); // check lookupClass - cob.aload(0); - cob.invokevirtual(CD_MethodHandles_Lookup, "lookupClass", MTD_Class); - cob.loadConstant(proxyDesc); - cob.if_acmpne(failLabel); - // check original access - cob.aload(0); - cob.invokevirtual(CD_MethodHandles_Lookup, "lookupModes", MTD_int); - cob.loadConstant(Lookup.ORIGINAL); - cob.iand(); - cob.ifeq(failLabel); - // success - cob.return_(); - // throw exception - cob.labelBinding(failLabel); - cob.new_(CD_IllegalAccessException); - cob.dup(); - cob.aload(0); // lookup - cob.invokevirtual(CD_Object, "toString", MTD_String); - cob.invokespecial(CD_IllegalAccessException, INIT_NAME, MTD_void_String); - cob.athrow(); + cob.aload(0) + .invokevirtual(CD_MethodHandles_Lookup, "lookupClass", MTD_Class) + .loadConstant(proxyDesc) + .if_acmpne(failLabel) + // check original access + .aload(0) + .invokevirtual(CD_MethodHandles_Lookup, "lookupModes", MTD_int) + .loadConstant(Lookup.ORIGINAL) + .iand() + .ifeq(failLabel) + // success + .return_() + // throw exception + .labelBinding(failLabel) + .new_(CD_IllegalAccessException) + .dup() + .aload(0) // lookup + .invokevirtual(CD_Object, "toString", MTD_String) + .invokespecial(CD_IllegalAccessException, INIT_NAME, MTD_void_String) + .athrow(); }); // implementation methods @@ -453,14 +452,14 @@ public class MethodHandleProxies { clb.withMethodBody(methodName, mi.desc, ACC_PUBLIC, cob -> cob .trying(bcb -> { // return this.handleField.invokeExact(arguments...); - bcb.aload(0); - bcb.getfield(proxyDesc, mi.fieldName, CD_MethodHandle); + bcb.aload(0) + .getfield(proxyDesc, mi.fieldName, CD_MethodHandle); for (int j = 0; j < mi.desc.parameterCount(); j++) { bcb.loadLocal(TypeKind.from(mi.desc.parameterType(j)), bcb.parameterSlot(j)); } - bcb.invokevirtual(CD_MethodHandle, "invokeExact", mi.desc); - bcb.return_(TypeKind.from(mi.desc.returnType())); + bcb.invokevirtual(CD_MethodHandle, "invokeExact", mi.desc) + .return_(TypeKind.from(mi.desc.returnType())); }, ctb -> ctb // catch (Error | RuntimeException | Declared ex) { throw ex; } .catchingMulti(mi.thrown, CodeBuilder::athrow) diff --git a/src/java.base/share/classes/java/lang/invoke/MethodHandles.java b/src/java.base/share/classes/java/lang/invoke/MethodHandles.java index 0cb77f632b3..9e292373f9c 100644 --- a/src/java.base/share/classes/java/lang/invoke/MethodHandles.java +++ b/src/java.base/share/classes/java/lang/invoke/MethodHandles.java @@ -39,7 +39,9 @@ import sun.invoke.util.Wrapper; import sun.reflect.misc.ReflectUtil; import sun.security.util.SecurityConstants; +import java.lang.classfile.ClassFile; import java.lang.classfile.ClassModel; +import java.lang.constant.ClassDesc; import java.lang.constant.ConstantDescs; import java.lang.invoke.LambdaForm.BasicType; import java.lang.invoke.MethodHandleImpl.Intrinsic; @@ -1906,9 +1908,12 @@ public class MethodHandles { this.flag = flag; } - static int optionsToFlag(Set options) { + static int optionsToFlag(ClassOption[] options) { int flags = 0; for (ClassOption cp : options) { + if ((flags & cp.flag) != 0) { + throw new IllegalArgumentException("Duplicate ClassOption " + cp); + } flags |= cp.flag; } return flags; @@ -2126,14 +2131,13 @@ public class MethodHandles { throws IllegalAccessException { Objects.requireNonNull(bytes); - Objects.requireNonNull(options); - + int flags = ClassOption.optionsToFlag(options); ensureDefineClassPermission(); if (!hasFullPrivilegeAccess()) { throw new IllegalAccessException(this + " does not have full privilege access"); } - return makeHiddenClassDefiner(bytes.clone(), Set.of(options), false).defineClassAsLookup(initialize); + return makeHiddenClassDefiner(bytes.clone(), false, flags).defineClassAsLookup(initialize); } /** @@ -2206,21 +2210,22 @@ public class MethodHandles { * @jvms 5.3.5 Deriving a {@code Class} from a {@code class} File Representation * @jvms 5.4 Linking * @jvms 5.5 Initialization - * @jls 12.7 Unloading of Classes and Interface + * @jls 12.7 Unloading of Classes and Interfaces */ public Lookup defineHiddenClassWithClassData(byte[] bytes, Object classData, boolean initialize, ClassOption... options) throws IllegalAccessException { Objects.requireNonNull(bytes); Objects.requireNonNull(classData); - Objects.requireNonNull(options); + + int flags = ClassOption.optionsToFlag(options); ensureDefineClassPermission(); if (!hasFullPrivilegeAccess()) { throw new IllegalAccessException(this + " does not have full privilege access"); } - return makeHiddenClassDefiner(bytes.clone(), Set.of(options), false) + return makeHiddenClassDefiner(bytes.clone(), false, flags) .defineClassAsLookup(initialize, classData); } @@ -2239,85 +2244,70 @@ public class MethodHandles { private static final ClassFileDumper DEFAULT_DUMPER = ClassFileDumper.getInstance( "jdk.invoke.MethodHandle.dumpClassFiles", "DUMP_CLASS_FILES"); - static class ClassFile { - final String name; // internal name - final int accessFlags; - final byte[] bytes; - ClassFile(String name, int accessFlags, byte[] bytes) { - this.name = name; - this.accessFlags = accessFlags; - this.bytes = bytes; + /** + * This method checks the class file version and the structure of `this_class`. + * and checks if the bytes is a class or interface (ACC_MODULE flag not set) + * that is in the named package. + * + * @throws IllegalArgumentException if ACC_MODULE flag is set in access flags + * or the class is not in the given package name. + */ + static String validateAndFindInternalName(byte[] bytes, String pkgName) { + int magic = readInt(bytes, 0); + if (magic != ClassFile.MAGIC_NUMBER) { + throw new ClassFormatError("Incompatible magic value: " + magic); + } + // We have to read major and minor this way as ClassFile API throws IAE + // yet we want distinct ClassFormatError and UnsupportedClassVersionError + int minor = readUnsignedShort(bytes, 4); + int major = readUnsignedShort(bytes, 6); + + if (!VM.isSupportedClassFileVersion(major, minor)) { + throw new UnsupportedClassVersionError("Unsupported class file version " + major + "." + minor); } - static ClassFile newInstanceNoCheck(String name, byte[] bytes) { - return new ClassFile(name, 0, bytes); + String name; + ClassDesc sym; + int accessFlags; + try { + ClassModel cm = ClassFile.of().parse(bytes); + var thisClass = cm.thisClass(); + name = thisClass.asInternalName(); + sym = thisClass.asSymbol(); + accessFlags = cm.flags().flagsMask(); + } catch (IllegalArgumentException e) { + ClassFormatError cfe = new ClassFormatError(); + cfe.initCause(e); + throw cfe; + } + // must be a class or interface + if ((accessFlags & ACC_MODULE) != 0) { + throw newIllegalArgumentException("Not a class or interface: ACC_MODULE flag is set"); } - /** - * This method checks the class file version and the structure of `this_class`. - * and checks if the bytes is a class or interface (ACC_MODULE flag not set) - * that is in the named package. - * - * @throws IllegalArgumentException if ACC_MODULE flag is set in access flags - * or the class is not in the given package name. - */ - static ClassFile newInstance(byte[] bytes, String pkgName) { - var cf = readClassFile(bytes); - - // check if it's in the named package - int index = cf.name.lastIndexOf('/'); - String pn = (index == -1) ? "" : cf.name.substring(0, index).replace('/', '.'); - if (!pn.equals(pkgName)) { - throw newIllegalArgumentException(cf.name + " not in same package as lookup class"); - } - return cf; + String pn = sym.packageName(); + if (!pn.equals(pkgName)) { + throw newIllegalArgumentException(name + " not in same package as lookup class"); } - private static ClassFile readClassFile(byte[] bytes) { - int magic = readInt(bytes, 0); - if (magic != 0xCAFEBABE) { - throw new ClassFormatError("Incompatible magic value: " + magic); - } - int minor = readUnsignedShort(bytes, 4); - int major = readUnsignedShort(bytes, 6); - if (!VM.isSupportedClassFileVersion(major, minor)) { - throw new UnsupportedClassVersionError("Unsupported class file version " + major + "." + minor); - } + return name; + } - String name; - int accessFlags; - try { - ClassModel cm = java.lang.classfile.ClassFile.of().parse(bytes); - name = cm.thisClass().asInternalName(); - accessFlags = cm.flags().flagsMask(); - } catch (IllegalArgumentException e) { - ClassFormatError cfe = new ClassFormatError(); - cfe.initCause(e); - throw cfe; - } - // must be a class or interface - if ((accessFlags & ACC_MODULE) != 0) { - throw newIllegalArgumentException("Not a class or interface: ACC_MODULE flag is set"); - } - return new ClassFile(name, accessFlags, bytes); + private static int readInt(byte[] bytes, int offset) { + if ((offset + 4) > bytes.length) { + throw new ClassFormatError("Invalid ClassFile structure"); } + return ((bytes[offset] & 0xFF) << 24) + | ((bytes[offset + 1] & 0xFF) << 16) + | ((bytes[offset + 2] & 0xFF) << 8) + | (bytes[offset + 3] & 0xFF); + } - private static int readInt(byte[] bytes, int offset) { - if ((offset+4) > bytes.length) { - throw new ClassFormatError("Invalid ClassFile structure"); - } - return ((bytes[offset] & 0xFF) << 24) - | ((bytes[offset + 1] & 0xFF) << 16) - | ((bytes[offset + 2] & 0xFF) << 8) - | (bytes[offset + 3] & 0xFF); - } - - private static int readUnsignedShort(byte[] bytes, int offset) { - if ((offset+2) > bytes.length) { - throw new ClassFormatError("Invalid ClassFile structure"); - } - return ((bytes[offset] & 0xFF) << 8) | (bytes[offset + 1] & 0xFF); + private static int readUnsignedShort(byte[] bytes, int offset) { + if ((offset+2) > bytes.length) { + throw new ClassFormatError("Invalid ClassFile structure"); } + return ((bytes[offset] & 0xFF) << 8) | (bytes[offset + 1] & 0xFF); } /* @@ -2331,23 +2321,22 @@ public class MethodHandles { * {@code bytes} denotes a class in a different package than the lookup class */ private ClassDefiner makeClassDefiner(byte[] bytes) { - ClassFile cf = ClassFile.newInstance(bytes, lookupClass().getPackageName()); - return new ClassDefiner(this, cf, STRONG_LOADER_LINK, defaultDumper()); + var internalName = validateAndFindInternalName(bytes, lookupClass().getPackageName()); + return new ClassDefiner(this, internalName, bytes, STRONG_LOADER_LINK, defaultDumper()); } /** * Returns a ClassDefiner that creates a {@code Class} object of a normal class * from the given bytes. No package name check on the given bytes. * - * @param name internal name + * @param internalName internal name * @param bytes class bytes * @param dumper dumper to write the given bytes to the dumper's output directory * @return ClassDefiner that defines a normal class of the given bytes. */ - ClassDefiner makeClassDefiner(String name, byte[] bytes, ClassFileDumper dumper) { + ClassDefiner makeClassDefiner(String internalName, byte[] bytes, ClassFileDumper dumper) { // skip package name validation - ClassFile cf = ClassFile.newInstanceNoCheck(name, bytes); - return new ClassDefiner(this, cf, STRONG_LOADER_LINK, dumper); + return new ClassDefiner(this, internalName, bytes, STRONG_LOADER_LINK, dumper); } /** @@ -2365,8 +2354,8 @@ public class MethodHandles { * {@code bytes} denotes a class in a different package than the lookup class */ ClassDefiner makeHiddenClassDefiner(byte[] bytes, ClassFileDumper dumper) { - ClassFile cf = ClassFile.newInstance(bytes, lookupClass().getPackageName()); - return makeHiddenClassDefiner(cf, Set.of(), false, dumper); + var internalName = validateAndFindInternalName(bytes, lookupClass().getPackageName()); + return makeHiddenClassDefiner(internalName, bytes, false, dumper, 0); } /** @@ -2378,7 +2367,7 @@ public class MethodHandles { * before calling this factory method. * * @param bytes class bytes - * @param options class options + * @param flags class option flag mask * @param accessVmAnnotations true to give the hidden class access to VM annotations * @return ClassDefiner that defines a hidden class of the given bytes and options * @@ -2386,69 +2375,71 @@ public class MethodHandles { * {@code bytes} denotes a class in a different package than the lookup class */ private ClassDefiner makeHiddenClassDefiner(byte[] bytes, - Set options, - boolean accessVmAnnotations) { - ClassFile cf = ClassFile.newInstance(bytes, lookupClass().getPackageName()); - return makeHiddenClassDefiner(cf, options, accessVmAnnotations, defaultDumper()); + boolean accessVmAnnotations, + int flags) { + var internalName = validateAndFindInternalName(bytes, lookupClass().getPackageName()); + return makeHiddenClassDefiner(internalName, bytes, accessVmAnnotations, defaultDumper(), flags); } /** * Returns a ClassDefiner that creates a {@code Class} object of a hidden class * from the given bytes and the given options. No package name check on the given bytes. * - * @param name internal name that specifies the prefix of the hidden class + * @param internalName internal name that specifies the prefix of the hidden class * @param bytes class bytes - * @param options class options * @param dumper dumper to write the given bytes to the dumper's output directory * @return ClassDefiner that defines a hidden class of the given bytes and options. */ - ClassDefiner makeHiddenClassDefiner(String name, byte[] bytes, Set options, ClassFileDumper dumper) { + ClassDefiner makeHiddenClassDefiner(String internalName, byte[] bytes, ClassFileDumper dumper) { Objects.requireNonNull(dumper); // skip name and access flags validation - return makeHiddenClassDefiner(ClassFile.newInstanceNoCheck(name, bytes), options, false, dumper); + return makeHiddenClassDefiner(internalName, bytes, false, dumper, 0); + } + + /** + * Returns a ClassDefiner that creates a {@code Class} object of a hidden class + * from the given bytes and the given options. No package name check on the given bytes. + * + * @param internalName internal name that specifies the prefix of the hidden class + * @param bytes class bytes + * @param flags class options flag mask + * @param dumper dumper to write the given bytes to the dumper's output directory + * @return ClassDefiner that defines a hidden class of the given bytes and options. + */ + ClassDefiner makeHiddenClassDefiner(String internalName, byte[] bytes, ClassFileDumper dumper, int flags) { + Objects.requireNonNull(dumper); + // skip name and access flags validation + return makeHiddenClassDefiner(internalName, bytes, false, dumper, flags); } /** * Returns a ClassDefiner that creates a {@code Class} object of a hidden class * from the given class file and options. * - * @param cf ClassFile - * @param options class options + * @param internalName internal name + * @param bytes Class byte array + * @param flags class option flag mask * @param accessVmAnnotations true to give the hidden class access to VM annotations * @param dumper dumper to write the given bytes to the dumper's output directory */ - private ClassDefiner makeHiddenClassDefiner(ClassFile cf, - Set options, + private ClassDefiner makeHiddenClassDefiner(String internalName, + byte[] bytes, boolean accessVmAnnotations, - ClassFileDumper dumper) { - int flags = HIDDEN_CLASS | ClassOption.optionsToFlag(options); + ClassFileDumper dumper, + int flags) { + flags |= HIDDEN_CLASS; if (accessVmAnnotations | VM.isSystemDomainLoader(lookupClass.getClassLoader())) { // jdk.internal.vm.annotations are permitted for classes // defined to boot loader and platform loader flags |= ACCESS_VM_ANNOTATIONS; } - return new ClassDefiner(this, cf, flags, dumper); + return new ClassDefiner(this, internalName, bytes, flags, dumper); } - static class ClassDefiner { - private final Lookup lookup; - private final String name; // internal name - private final byte[] bytes; - private final int classFlags; - private final ClassFileDumper dumper; - - private ClassDefiner(Lookup lookup, ClassFile cf, int flags, ClassFileDumper dumper) { - assert ((flags & HIDDEN_CLASS) != 0 || (flags & STRONG_LOADER_LINK) == STRONG_LOADER_LINK); - this.lookup = lookup; - this.bytes = cf.bytes; - this.name = cf.name; - this.classFlags = flags; - this.dumper = dumper; - } - - String internalName() { - return name; + record ClassDefiner(Lookup lookup, String internalName, byte[] bytes, int classFlags, ClassFileDumper dumper) { + ClassDefiner { + assert ((classFlags & HIDDEN_CLASS) != 0 || (classFlags & STRONG_LOADER_LINK) == STRONG_LOADER_LINK); } Class defineClass(boolean initialize) { @@ -2477,7 +2468,7 @@ public class MethodHandles { Class c = null; try { c = SharedSecrets.getJavaLangAccess() - .defineClass(loader, lookupClass, name, bytes, pd, initialize, classFlags, classData); + .defineClass(loader, lookupClass, internalName, bytes, pd, initialize, classFlags, classData); assert !isNestmate() || c.getNestHost() == lookupClass.getNestHost(); return c; } finally { diff --git a/src/java.base/share/classes/java/lang/invoke/MutableCallSite.java b/src/java.base/share/classes/java/lang/invoke/MutableCallSite.java index 50ba77d8f96..65872e360a7 100644 --- a/src/java.base/share/classes/java/lang/invoke/MutableCallSite.java +++ b/src/java.base/share/classes/java/lang/invoke/MutableCallSite.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,8 @@ package java.lang.invoke; import java.util.Objects; -import java.util.concurrent.atomic.AtomicInteger; + +import static java.lang.invoke.MethodHandleStatics.UNSAFE; /** * A {@code MutableCallSite} is a {@link CallSite} whose target variable @@ -274,11 +275,10 @@ public non-sealed class MutableCallSite extends CallSite { */ public static void syncAll(MutableCallSite[] sites) { if (sites.length == 0) return; - STORE_BARRIER.lazySet(0); + UNSAFE.storeFence(); for (MutableCallSite site : sites) { Objects.requireNonNull(site); // trigger NPE on first null } // FIXME: NYI } - private static final AtomicInteger STORE_BARRIER = new AtomicInteger(); } diff --git a/src/java.base/share/classes/java/lang/invoke/NativeMethodHandle.java b/src/java.base/share/classes/java/lang/invoke/NativeMethodHandle.java index 4d09b96775d..35cc610dad1 100644 --- a/src/java.base/share/classes/java/lang/invoke/NativeMethodHandle.java +++ b/src/java.base/share/classes/java/lang/invoke/NativeMethodHandle.java @@ -108,7 +108,7 @@ import static java.lang.invoke.MethodHandleStatics.newInternalError; final int GET_NEP = nameCursor++; final int LINKER_CALL = nameCursor++; - LambdaForm.Name[] names = arguments(nameCursor - ARG_LIMIT, mtype.invokerType()); + LambdaForm.Name[] names = invokeArguments(nameCursor - ARG_LIMIT, mtype); assert (names.length == nameCursor); names[GET_NEP] = new LambdaForm.Name(Lazy.NF_internalNativeEntryPoint, names[NMH_THIS]); diff --git a/src/java.base/share/classes/java/lang/invoke/StringConcatFactory.java b/src/java.base/share/classes/java/lang/invoke/StringConcatFactory.java index 44a4ef7b020..97848e1fcb3 100644 --- a/src/java.base/share/classes/java/lang/invoke/StringConcatFactory.java +++ b/src/java.base/share/classes/java/lang/invoke/StringConcatFactory.java @@ -51,7 +51,6 @@ import java.lang.invoke.MethodHandles.Lookup; import java.lang.ref.SoftReference; import java.util.Map; import java.util.Objects; -import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.function.Consumer; import java.util.function.Supplier; @@ -119,12 +118,16 @@ import static java.lang.invoke.MethodType.methodType; */ public final class StringConcatFactory { private static final int HIGH_ARITY_THRESHOLD; + private static final int CACHE_THRESHOLD; private static final int FORCE_INLINE_THRESHOLD; static { String highArity = VM.getSavedProperty("java.lang.invoke.StringConcat.highArityThreshold"); HIGH_ARITY_THRESHOLD = highArity != null ? Integer.parseInt(highArity) : 0; + String cacheThreshold = VM.getSavedProperty("java.lang.invoke.StringConcat.cacheThreshold"); + CACHE_THRESHOLD = cacheThreshold != null ? Integer.parseInt(cacheThreshold) : 256; + String inlineThreshold = VM.getSavedProperty("java.lang.invoke.StringConcat.inlineThreshold"); FORCE_INLINE_THRESHOLD = inlineThreshold != null ? Integer.parseInt(inlineThreshold) : 16; } @@ -1179,26 +1182,35 @@ public final class StringConcatFactory { * int arg0, long arg1, boolean arg2, char arg3, String arg5) * */ - private static MethodTypeDesc prependArgs(MethodType concatArgs) { + private static MethodTypeDesc prependArgs(MethodType concatArgs, boolean staticConcat) { int parameterCount = concatArgs.parameterCount(); - var paramTypes = new ClassDesc[parameterCount + 4]; + int prefixArgs = staticConcat ? 3 : 4; + var paramTypes = new ClassDesc[parameterCount + prefixArgs]; paramTypes[0] = CD_int; // length paramTypes[1] = CD_byte; // coder paramTypes[2] = CD_Array_byte; // buff - paramTypes[3] = CD_Array_String; // constants + + if (!staticConcat) { + paramTypes[3] = CD_Array_String; // constants + } for (int i = 0; i < parameterCount; i++) { var cl = concatArgs.parameterType(i); - paramTypes[i + 4] = needStringOf(cl) ? CD_String : ConstantUtils.classDesc(cl); + paramTypes[i + prefixArgs] = needStringOf(cl) ? CD_String : ConstantUtils.classDesc(cl); } return MethodTypeDescImpl.ofValidated(CD_int, paramTypes); } /** * Construct the MethodType of the coder method. The first parameter is the initialized coder. - * Only parameter types which can be UTF16 are added. Returns null if no such parameter exists. + * Only parameter types which can be UTF16 are added. + * Returns null if no such parameter exists or CompactStrings is off. */ private static MethodTypeDesc coderArgsIfMaybeUTF16(MethodType concatArgs) { + if (JLA.stringInitCoder() != 0) { + return null; + } + int parameterCount = concatArgs.parameterCount(); int maybeUTF16Count = 0; @@ -1242,39 +1254,49 @@ public final class StringConcatFactory { lookup = STR_LOOKUP; final MethodType concatArgs = erasedArgs(args); - // 1 argment use built-in method + // 1 argument use built-in method if (args.parameterCount() == 1) { Object concat1 = JLA.stringConcat1(constants); var handle = lookup.findVirtual(concat1.getClass(), METHOD_NAME, concatArgs); return handle.bindTo(concat1); } - var weakConstructorHandle = CACHE.get(concatArgs); - if (weakConstructorHandle != null) { - MethodHandlePair handlePair = weakConstructorHandle.get(); - if (handlePair != null) { - try { - var instance = handlePair.constructor.invoke(constants); - return handlePair.concatenator.bindTo(instance); - } catch (Throwable e) { - throw new StringConcatException("Exception while utilizing the hidden class", e); + boolean forceInline = concatArgs.parameterCount() < FORCE_INLINE_THRESHOLD; + boolean staticConcat = concatArgs.parameterCount() >= CACHE_THRESHOLD; + + if (!staticConcat) { + var weakConstructorHandle = CACHE.get(concatArgs); + if (weakConstructorHandle != null) { + MethodHandlePair handlePair = weakConstructorHandle.get(); + if (handlePair != null) { + try { + var instance = handlePair.constructor.invokeBasic((Object)constants); + return handlePair.concatenator.bindTo(instance); + } catch (Throwable e) { + throw new StringConcatException("Exception while utilizing the hidden class", e); + } } } } + MethodTypeDesc lengthArgs = lengthArgs(concatArgs), coderArgs = coderArgsIfMaybeUTF16(concatArgs), - prependArgs = prependArgs(concatArgs); + prependArgs = prependArgs(concatArgs, staticConcat); byte[] classBytes = ClassFile.of().build(CD_CONCAT, new Consumer() { - final boolean forceInline = concatArgs.parameterCount() < FORCE_INLINE_THRESHOLD; - @Override public void accept(ClassBuilder clb) { - clb.withSuperclass(CD_StringConcatBase) - .withFlags(ACC_FINAL | ACC_SUPER | ACC_SYNTHETIC) - .withMethodBody(INIT_NAME, MTD_INIT, 0, CONSTRUCTOR_BUILDER) - .withMethod("length", + if (staticConcat) { + clb.withSuperclass(CD_Object) + .withFlags(ACC_ABSTRACT | ACC_SUPER | ACC_SYNTHETIC); + } else { + clb.withSuperclass(CD_StringConcatBase) + .withFlags(ACC_FINAL | ACC_SUPER | ACC_SYNTHETIC) + .withMethodBody(INIT_NAME, MTD_INIT, 0, CONSTRUCTOR_BUILDER); + } + + clb.withMethod("length", lengthArgs, ACC_STATIC | ACC_PRIVATE, new Consumer() { @@ -1293,18 +1315,20 @@ public final class StringConcatFactory { if (forceInline) { mb.with(FORCE_INLINE); } - mb.withCode(generatePrependMethod(prependArgs)); + mb.withCode(generatePrependMethod(prependArgs, staticConcat, constants)); } }) .withMethod(METHOD_NAME, ConstantUtils.methodTypeDesc(concatArgs), - ACC_FINAL, + staticConcat ? ACC_STATIC | ACC_FINAL : ACC_FINAL, new Consumer() { public void accept(MethodBuilder mb) { if (forceInline) { mb.with(FORCE_INLINE); } mb.withCode(generateConcatMethod( + staticConcat, + constants, CD_CONCAT, concatArgs, lengthArgs, @@ -1328,13 +1352,18 @@ public final class StringConcatFactory { } }}); try { - var hiddenClass = lookup.makeHiddenClassDefiner(CLASS_NAME, classBytes, Set.of(), DUMPER) + var hiddenClass = lookup.makeHiddenClassDefiner(CLASS_NAME, classBytes, DUMPER) .defineClass(true, null); + + if (staticConcat) { + return lookup.findStatic(hiddenClass, METHOD_NAME, concatArgs); + } + var constructor = lookup.findConstructor(hiddenClass, CONSTRUCTOR_METHOD_TYPE); - var concat = lookup.findVirtual(hiddenClass, METHOD_NAME, concatArgs); - CACHE.put(concatArgs, new SoftReference<>(new MethodHandlePair(constructor, concat))); - var instance = hiddenClass.cast(constructor.invoke(constants)); - return concat.bindTo(instance); + var concatenator = lookup.findVirtual(hiddenClass, METHOD_NAME, concatArgs); + CACHE.put(concatArgs, new SoftReference<>(new MethodHandlePair(constructor, concatenator))); + var instance = constructor.invokeBasic((Object)constants); + return concatenator.bindTo(instance); } catch (Throwable e) { throw new StringConcatException("Exception while spinning the class", e); } @@ -1405,6 +1434,8 @@ public final class StringConcatFactory { * */ private static Consumer generateConcatMethod( + boolean staticConcat, + String[] constants, ClassDesc concatClass, MethodType concatArgs, MethodTypeDesc lengthArgs, @@ -1416,7 +1447,7 @@ public final class StringConcatFactory { public void accept(CodeBuilder cb) { // Compute parameter variable slots int paramCount = concatArgs.parameterCount(), - thisSlot = cb.receiverSlot(), + thisSlot = staticConcat ? 0 : cb.receiverSlot(), lengthSlot = cb.allocateLocal(TypeKind.INT), coderSlot = cb.allocateLocal(TypeKind.BYTE), bufSlot = cb.allocateLocal(TypeKind.REFERENCE), @@ -1452,11 +1483,30 @@ public final class StringConcatFactory { } } + int coder = JLA.stringInitCoder(), + length = 0; + if (staticConcat) { + for (var constant : constants) { + coder |= JLA.stringCoder(constant); + length += constant.length(); + } + } + /* * coder = coder(this.coder, arg0, arg1, ... argN); */ - cb.aload(thisSlot) - .getfield(concatClass, "coder", CD_byte); + if (staticConcat) { + // coder can only be 0 or 1 + if (coder == 0) { + cb.iconst_0(); + } else { + cb.iconst_1(); + } + } else { + cb.aload(thisSlot) + .getfield(concatClass, "coder", CD_byte); + } + if (coderArgs != null) { for (int i = 0; i < paramCount; i++) { var cl = concatArgs.parameterType(i); @@ -1475,8 +1525,13 @@ public final class StringConcatFactory { /* * length = length(this.length, arg0, arg1, ..., argN); */ - cb.aload(thisSlot) - .getfield(concatClass, "length", CD_int); + if (staticConcat) { + cb.loadConstant(length); + } else { + cb.aload(thisSlot) + .getfield(concatClass, "length", CD_int); + } + for (int i = 0; i < paramCount; i++) { var cl = concatArgs.parameterType(i); int paramSlot = cb.parameterSlot(i); @@ -1493,25 +1548,35 @@ public final class StringConcatFactory { * suffix = constants[paramCount]; * length -= suffix.length(); */ - cb.aload(thisSlot) - .getfield(concatClass, "constants", CD_Array_String) - .dup() - .astore(constantsSlot) - .ldc(paramCount) - .aaload() - .dup() - .astore(suffixSlot) - .invokevirtual(CD_String, "length", MTD_int) - .isub() - .istore(lengthSlot); + if (staticConcat) { + cb.loadConstant(constants[paramCount].length()) + .isub() + .istore(lengthSlot); + } else { + cb.aload(thisSlot) + .getfield(concatClass, "constants", CD_Array_String) + .dup() + .astore(constantsSlot) + .loadConstant(paramCount) + .aaload() + .dup() + .astore(suffixSlot) + .invokevirtual(CD_String, "length", MTD_int) + .isub() + .istore(lengthSlot); + } /* * Allocate buffer : * * buf = newArrayWithSuffix(suffix, length, coder) */ - cb.aload(suffixSlot) - .iload(lengthSlot) + if (staticConcat) { + cb.loadConstant(constants[paramCount]); + } else { + cb.aload(suffixSlot); + } + cb.iload(lengthSlot) .iload(coderSlot) .invokestatic(CD_StringConcatHelper, "newArrayWithSuffix", MTD_NEW_ARRAY_SUFFIX) .astore(bufSlot); @@ -1521,8 +1586,10 @@ public final class StringConcatFactory { */ cb.iload(lengthSlot) .iload(coderSlot) - .aload(bufSlot) - .aload(constantsSlot); + .aload(bufSlot); + if (!staticConcat) { + cb.aload(constantsSlot); + } for (int i = 0; i < paramCount; i++) { var cl = concatArgs.parameterType(i); int paramSlot = cb.parameterSlot(i); @@ -1646,7 +1713,10 @@ public final class StringConcatFactory { * } * */ - private static Consumer generatePrependMethod(MethodTypeDesc prependArgs) { + private static Consumer generatePrependMethod( + MethodTypeDesc prependArgs, + boolean staticConcat, String[] constants + ) { return new Consumer() { @Override public void accept(CodeBuilder cb) { @@ -1665,7 +1735,7 @@ public final class StringConcatFactory { * buf, arg1, constant[1]), buf, arg0, constant[0]); */ cb.iload(lengthSlot); - for (int i = prependArgs.parameterCount() - 1; i >= 4; i--) { + for (int i = prependArgs.parameterCount() - 1, end = staticConcat ? 3 : 4; i >= end; i--) { var cl = prependArgs.parameterType(i); var kind = TypeKind.from(cl); @@ -1686,11 +1756,17 @@ public final class StringConcatFactory { cb.iload(coderSlot) .aload(bufSlot) - .loadLocal(kind, cb.parameterSlot(i)) - .aload(constantsSlot) - .ldc(i - 4) - .aaload() - .invokestatic(CD_StringConcatHelper, "prepend", methodTypeDesc); + .loadLocal(kind, cb.parameterSlot(i)); + + if (staticConcat) { + cb.loadConstant(constants[i - 3]); + } else { + cb.aload(constantsSlot) + .loadConstant(i - 4) + .aaload(); + } + + cb.invokestatic(CD_StringConcatHelper, "prepend", methodTypeDesc); } cb.ireturn(); } diff --git a/src/java.base/share/classes/java/lang/package-info.java b/src/java.base/share/classes/java/lang/package-info.java index 882a610c1a0..9ca4482c819 100644 --- a/src/java.base/share/classes/java/lang/package-info.java +++ b/src/java.base/share/classes/java/lang/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,35 +25,42 @@ /** * Provides classes that are fundamental to the design of the Java - * programming language. The most important classes are {@code - * Object}, which is the root of the class hierarchy, and {@code + * programming language. The most important classes are {@link + * Object}, which is the root of the class hierarchy, and {@link * Class}, instances of which represent classes at run time. * - *

      Frequently it is necessary to represent a value of primitive - * type as if it were an object. The wrapper classes {@code Boolean}, - * {@code Character}, {@code Integer}, {@code Long}, {@code Float}, - * and {@code Double} serve this purpose. An object of type {@code - * Double}, for example, contains a field whose type is double, - * representing that value in such a way that a reference to it can be - * stored in a variable of reference type. These classes also provide - * a number of methods for converting among primitive values, as well - * as supporting such standard methods as equals and hashCode. The - * {@code Void} class is a non-instantiable class that holds a - * reference to a {@code Class} object representing the type void. + *

      Frequently it is necessary to represent a + * value of primitive type as if it were an object.The {@index + * "wrapper classes"} {@link Boolean}, {@link Byte}, {@link + * Character}, {@link Short}, {@link Integer}, {@link Long}, {@link + * Float}, and {@link Double} serve this purpose. An object of type + * {@code Double}, for example, contains a field whose type is {@code + * double}, representing that value in such a way that a reference to + * it can be stored in a variable of reference type. As discussed in + * The Java Language Specification, the wrapper classes + * are involved in boxing (JLS {@jls 5.1.7}) and unboxing (JLS {@jls + * 5.1.8}) conversions. These classes provide a number of methods for + * converting among primitive values, as well as methods supporting + * such standard functionality as {@code equals} and {@code hashCode}. + * The {@link Void} class is a non-instantiable class that holds a + * reference to a {@code Class} object representing the type {@code + * void}. * - *

      The class {@code Math} provides commonly used mathematical - * functions such as sine, cosine, and square root. The classes {@code - * String}, {@code StringBuffer}, and {@code StringBuilder} similarly - * provide commonly used operations on character strings. + *

      The class {@link Math} provides commonly used mathematical + * functions such as {@linkplain Math#sin(double) sine}, {@linkplain + * Math#cos(double) cosine}, and {@linkplain Math#sqrt(double) square + * root}. The classes {@link String}, {@link StringBuffer}, and {@link + * StringBuilder} similarly provide commonly used operations on + * character strings. * - *

      Classes {@code ClassLoader}, {@code Process}, {@code - * ProcessBuilder}, {@code Runtime}, {@code SecurityManager}, and - * {@code System} provide "system operations" that manage the dynamic + *

      Classes {@link ClassLoader}, {@link Process}, {@link + * ProcessBuilder}, {@link Runtime}, {@link SecurityManager}, and + * {@link System} provide "system operations" that manage the dynamic * loading of classes, creation of external processes, host * environment inquiries such as the time of day, and enforcement of * security policies. * - *

      Class {@code Throwable} encompasses objects that may be thrown + *

      Class {@link Throwable} encompasses objects that may be thrown * by the {@code throw} statement. Subclasses of {@code Throwable} * represent errors and exceptions. * diff --git a/src/java.base/share/classes/java/lang/reflect/AccessFlag.java b/src/java.base/share/classes/java/lang/reflect/AccessFlag.java index 92c6655552e..bc6b20be9a8 100644 --- a/src/java.base/share/classes/java/lang/reflect/AccessFlag.java +++ b/src/java.base/share/classes/java/lang/reflect/AccessFlag.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -528,7 +528,7 @@ public enum AccessFlag { /** * Method location. - * @jvms 4.6 Method + * @jvms 4.6 Methods */ METHOD, @@ -540,31 +540,31 @@ public enum AccessFlag { /** * Method parameter location. - * @jvms 4.7.24. The MethodParameters Attribute + * @jvms 4.7.24 The MethodParameters Attribute */ METHOD_PARAMETER, /** * Module location - * @jvms 4.7.25. The Module Attribute + * @jvms 4.7.25 The Module Attribute */ MODULE, /** * Module requires location - * @jvms 4.7.25. The Module Attribute + * @jvms 4.7.25 The Module Attribute */ MODULE_REQUIRES, /** * Module exports location - * @jvms 4.7.25. The Module Attribute + * @jvms 4.7.25 The Module Attribute */ MODULE_EXPORTS, /** * Module opens location - * @jvms 4.7.25. The Module Attribute + * @jvms 4.7.25 The Module Attribute */ MODULE_OPENS; diff --git a/src/java.base/share/classes/java/lang/reflect/AnnotatedElement.java b/src/java.base/share/classes/java/lang/reflect/AnnotatedElement.java index 52580a4b821..cc1bcd7dfdd 100644 --- a/src/java.base/share/classes/java/lang/reflect/AnnotatedElement.java +++ b/src/java.base/share/classes/java/lang/reflect/AnnotatedElement.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,8 +47,8 @@ import sun.reflect.annotation.AnnotationType; * * As defined by The Java Language Specification * section {@jls 9.7.4}, an annotation on an element is a - * declaration annotation and an annotation on a type is a - * type annotation. + * {@index "declaration annotation"} and an annotation on a type is a + * {@index "type annotation"}. * * Note that any annotations returned by methods on the {@link * AnnotatedType AnnotatedType} interface and its subinterfaces are @@ -78,21 +78,21 @@ import sun.reflect.annotation.AnnotationType; * *

        * - *
      • An annotation A is directly present on an + *
      • An annotation A is {@index "directly present"} on an * element E if E has a {@code * RuntimeVisibleAnnotations} or {@code * RuntimeVisibleParameterAnnotations} or {@code * RuntimeVisibleTypeAnnotations} attribute, and the attribute * contains A. * - *
      • An annotation A is indirectly present on an + *
      • An annotation A is {@index "indirectly present"} on an * element E if E has a {@code RuntimeVisibleAnnotations} or * {@code RuntimeVisibleParameterAnnotations} or {@code RuntimeVisibleTypeAnnotations} * attribute, and A 's type is repeatable, and the attribute contains * exactly one annotation whose value element contains A and whose * type is the containing annotation type of A 's type. * - *
      • An annotation A is present on an element E if either: + *
      • An annotation A is {@index "present"} on an element E if either: * *
          * @@ -104,7 +104,7 @@ import sun.reflect.annotation.AnnotationType; * *
        * - *
      • An annotation A is associated with an element E + *
      • An annotation A is {@index "associated"} with an element E * if either: * *
          diff --git a/src/java.base/share/classes/java/lang/reflect/InvocationHandler.java b/src/java.base/share/classes/java/lang/reflect/InvocationHandler.java index d5d00f34c86..47c6c410241 100644 --- a/src/java.base/share/classes/java/lang/reflect/InvocationHandler.java +++ b/src/java.base/share/classes/java/lang/reflect/InvocationHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -254,7 +254,7 @@ public interface InvocationHandler { * @throws Throwable anything thrown by the default method * @since 16 - * @jvms 5.4.3. Method Resolution + * @jvms 5.4.3 Resolution */ @CallerSensitive public static Object invokeDefault(Object proxy, Method method, Object... args) diff --git a/src/java.base/share/classes/java/lang/reflect/Method.java b/src/java.base/share/classes/java/lang/reflect/Method.java index 9b929509882..730b4b09757 100644 --- a/src/java.base/share/classes/java/lang/reflect/Method.java +++ b/src/java.base/share/classes/java/lang/reflect/Method.java @@ -755,7 +755,7 @@ public final class Method extends Executable { * {@link Class} and no definition can be found for the * default class value. * @since 1.5 - * @jls 9.6.2 Defaults for Annotation Type Elements + * @jls 9.6.2 Defaults for Annotation Interface Elements */ public Object getDefaultValue() { if (annotationDefault == null) diff --git a/src/java.base/share/classes/java/lang/reflect/ProxyGenerator.java b/src/java.base/share/classes/java/lang/reflect/ProxyGenerator.java index 2e56d03c6ad..abdcaf5ae1f 100644 --- a/src/java.base/share/classes/java/lang/reflect/ProxyGenerator.java +++ b/src/java.base/share/classes/java/lang/reflect/ProxyGenerator.java @@ -114,11 +114,18 @@ final class ProxyGenerator { private static final Method OBJECT_EQUALS_METHOD; private static final Method OBJECT_TO_STRING_METHOD; + private static final String OBJECT_HASH_CODE_SIG; + private static final String OBJECT_EQUALS_SIG; + private static final String OBJECT_TO_STRING_SIG; + static { try { OBJECT_HASH_CODE_METHOD = Object.class.getMethod("hashCode"); + OBJECT_HASH_CODE_SIG = OBJECT_HASH_CODE_METHOD.toShortSignature(); OBJECT_EQUALS_METHOD = Object.class.getMethod("equals", Object.class); + OBJECT_EQUALS_SIG = OBJECT_EQUALS_METHOD.toShortSignature(); OBJECT_TO_STRING_METHOD = Object.class.getMethod("toString"); + OBJECT_TO_STRING_SIG = OBJECT_TO_STRING_METHOD.toShortSignature(); } catch (NoSuchMethodException e) { throw new NoSuchMethodError(e.getMessage()); } @@ -446,9 +453,9 @@ final class ProxyGenerator { * java.lang.Object take precedence over duplicate methods in the * proxy interfaces. */ - addProxyMethod(new ProxyMethod(OBJECT_HASH_CODE_METHOD, "m0")); - addProxyMethod(new ProxyMethod(OBJECT_EQUALS_METHOD, "m1")); - addProxyMethod(new ProxyMethod(OBJECT_TO_STRING_METHOD, "m2")); + addProxyMethod(new ProxyMethod(OBJECT_HASH_CODE_METHOD, OBJECT_HASH_CODE_SIG, "m0")); + addProxyMethod(new ProxyMethod(OBJECT_EQUALS_METHOD, OBJECT_EQUALS_SIG, "m1")); + addProxyMethod(new ProxyMethod(OBJECT_TO_STRING_METHOD, OBJECT_TO_STRING_SIG, "m2")); /* * Accumulate all of the methods from the proxy interfaces. @@ -526,7 +533,7 @@ final class ProxyGenerator { return; } } - sigmethods.add(new ProxyMethod(m, sig, m.getSharedParameterTypes(), returnType, + sigmethods.add(new ProxyMethod(m, sig, returnType, exceptionTypes, fromClass, "m" + proxyMethodCount++)); } @@ -617,11 +624,11 @@ final class ProxyGenerator { Label failLabel = cob.newLabel(); ClassEntry mhl = cp.classEntry(CD_MethodHandles_Lookup); ClassEntry iae = cp.classEntry(CD_IllegalAccessException); - cob.aload(cob.parameterSlot(0)) + cob.aload(0) .invokevirtual(cp.methodRefEntry(mhl, cp.nameAndTypeEntry("lookupClass", MTD_Class))) .ldc(proxyCE) .if_acmpne(failLabel) - .aload(cob.parameterSlot(0)) + .aload(0) .invokevirtual(cp.methodRefEntry(mhl, cp.nameAndTypeEntry("hasFullPrivilegeAccess", MTD_boolean))) .ifeq(failLabel) .invokestatic(CD_MethodHandles, "lookup", MTD_MethodHandles$Lookup) @@ -629,7 +636,7 @@ final class ProxyGenerator { .labelBinding(failLabel) .new_(iae) .dup() - .aload(cob.parameterSlot(0)) + .aload(0) .invokevirtual(cp.methodRefEntry(mhl, cp.nameAndTypeEntry("toString", MTD_String))) .invokespecial(cp.methodRefEntry(iae, exInit)) .athrow() @@ -650,18 +657,16 @@ final class ProxyGenerator { private final Method method; private final String shortSignature; private final Class fromClass; - private final Class[] parameterTypes; private final Class returnType; private final String methodFieldName; private Class[] exceptionTypes; private final FieldRefEntry methodField; - private ProxyMethod(Method method, String sig, Class[] parameterTypes, + private ProxyMethod(Method method, String sig, Class returnType, Class[] exceptionTypes, Class fromClass, String methodFieldName) { this.method = method; this.shortSignature = sig; - this.parameterTypes = parameterTypes; this.returnType = returnType; this.exceptionTypes = exceptionTypes; this.fromClass = fromClass; @@ -670,14 +675,17 @@ final class ProxyGenerator { cp.nameAndTypeEntry(methodFieldName, CD_Method)); } + private Class[] parameterTypes() { + return method.getSharedParameterTypes(); + } + /** * Create a new specific ProxyMethod with a specific field name * * @param method The method for which to create a proxy */ - private ProxyMethod(Method method, String methodFieldName) { - this(method, method.toShortSignature(), - method.getSharedParameterTypes(), method.getReturnType(), + private ProxyMethod(Method method, String sig, String methodFieldName) { + this(method, sig, method.getReturnType(), method.getSharedExceptionTypes(), method.getDeclaringClass(), methodFieldName); } @@ -685,17 +693,18 @@ final class ProxyGenerator { * Generate this method, including the code and exception table entry. */ private void generateMethod(ClassBuilder clb) { - var desc = methodTypeDesc(returnType, parameterTypes); + var desc = methodTypeDesc(returnType, parameterTypes()); int accessFlags = (method.isVarArgs()) ? ACC_VARARGS | ACC_PUBLIC | ACC_FINAL : ACC_PUBLIC | ACC_FINAL; - var catchList = computeUniqueCatchList(exceptionTypes); clb.withMethod(method.getName(), desc, accessFlags, mb -> mb.with(ExceptionsAttribute.of(toClassEntries(cp, List.of(exceptionTypes)))) .withCode(cob -> { + var catchList = computeUniqueCatchList(exceptionTypes); cob.aload(cob.receiverSlot()) .getfield(handlerField) .aload(cob.receiverSlot()) .getstatic(methodField); + Class[] parameterTypes = parameterTypes(); if (parameterTypes.length > 0) { // Create an array and fill with the parameters converting primitives to wrappers cob.loadConstant(parameterTypes.length) @@ -784,6 +793,7 @@ final class ProxyGenerator { var cp = cob.constantPool(); codeClassForName(cob, fromClass); + Class[] parameterTypes = parameterTypes(); cob.ldc(method.getName()) .loadConstant(parameterTypes.length) .anewarray(classCE); @@ -817,10 +827,14 @@ final class ProxyGenerator { * loader is anticipated at local variable index 0. */ private void codeClassForName(CodeBuilder cob, Class cl) { - cob.ldc(cl.getName()) - .iconst_0() // false - .aload(0)// classLoader - .invokestatic(classForName); + if (cl == Object.class) { + cob.ldc(objectCE); + } else { + cob.ldc(cl.getName()) + .iconst_0() // false + .aload(0)// classLoader + .invokestatic(classForName); + } } @Override diff --git a/src/java.base/share/classes/java/lang/runtime/ObjectMethods.java b/src/java.base/share/classes/java/lang/runtime/ObjectMethods.java index 6cfd7f9bb44..51ee21e46b3 100644 --- a/src/java.base/share/classes/java/lang/runtime/ObjectMethods.java +++ b/src/java.base/share/classes/java/lang/runtime/ObjectMethods.java @@ -31,8 +31,6 @@ import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodType; import java.lang.invoke.StringConcatFactory; import java.lang.invoke.TypeDescriptor; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -56,20 +54,14 @@ public class ObjectMethods { private static final int MAX_STRING_CONCAT_SLOTS = 20; - private static final MethodType DESCRIPTOR_MT = MethodType.methodType(MethodType.class); - private static final MethodType NAMES_MT = MethodType.methodType(List.class); - private static final MethodHandle FALSE = MethodHandles.constant(boolean.class, false); + private static final MethodHandle FALSE = MethodHandles.zero(boolean.class); private static final MethodHandle TRUE = MethodHandles.constant(boolean.class, true); - private static final MethodHandle ZERO = MethodHandles.constant(int.class, 0); + private static final MethodHandle ZERO = MethodHandles.zero(int.class); private static final MethodHandle CLASS_IS_INSTANCE; - private static final MethodHandle OBJECT_EQUALS; private static final MethodHandle OBJECTS_EQUALS; private static final MethodHandle OBJECTS_HASHCODE; private static final MethodHandle OBJECTS_TOSTRING; private static final MethodHandle OBJECT_EQ; - private static final MethodHandle OBJECT_HASHCODE; - private static final MethodHandle OBJECT_TO_STRING; - private static final MethodHandle STRING_FORMAT; private static final MethodHandle HASH_COMBINER; private static final HashMap, MethodHandle> primitiveEquals = new HashMap<>(); @@ -82,21 +74,8 @@ public class ObjectMethods { MethodHandles.Lookup publicLookup = MethodHandles.publicLookup(); MethodHandles.Lookup lookup = MethodHandles.lookup(); - @SuppressWarnings("removal") - ClassLoader loader = AccessController.doPrivileged(new PrivilegedAction() { - @Override public ClassLoader run() { return ClassLoader.getPlatformClassLoader(); } - }); - CLASS_IS_INSTANCE = publicLookup.findVirtual(Class.class, "isInstance", MethodType.methodType(boolean.class, Object.class)); - OBJECT_EQUALS = publicLookup.findVirtual(Object.class, "equals", - MethodType.methodType(boolean.class, Object.class)); - OBJECT_HASHCODE = publicLookup.findVirtual(Object.class, "hashCode", - MethodType.fromMethodDescriptorString("()I", loader)); - OBJECT_TO_STRING = publicLookup.findVirtual(Object.class, "toString", - MethodType.methodType(String.class)); - STRING_FORMAT = publicLookup.findStatic(String.class, "format", - MethodType.methodType(String.class, String.class, Object[].class)); OBJECTS_EQUALS = publicLookup.findStatic(Objects.class, "equals", MethodType.methodType(boolean.class, Object.class, Object.class)); OBJECTS_HASHCODE = publicLookup.findStatic(Objects.class, "hashCode", @@ -107,41 +86,41 @@ public class ObjectMethods { OBJECT_EQ = lookup.findStatic(OBJECT_METHODS_CLASS, "eq", MethodType.methodType(boolean.class, Object.class, Object.class)); HASH_COMBINER = lookup.findStatic(OBJECT_METHODS_CLASS, "hashCombiner", - MethodType.fromMethodDescriptorString("(II)I", loader)); + MethodType.methodType(int.class, int.class, int.class)); primitiveEquals.put(byte.class, lookup.findStatic(OBJECT_METHODS_CLASS, "eq", - MethodType.fromMethodDescriptorString("(BB)Z", loader))); + MethodType.methodType(boolean.class, byte.class, byte.class))); primitiveEquals.put(short.class, lookup.findStatic(OBJECT_METHODS_CLASS, "eq", - MethodType.fromMethodDescriptorString("(SS)Z", loader))); + MethodType.methodType(boolean.class, short.class, short.class))); primitiveEquals.put(char.class, lookup.findStatic(OBJECT_METHODS_CLASS, "eq", - MethodType.fromMethodDescriptorString("(CC)Z", loader))); + MethodType.methodType(boolean.class, char.class, char.class))); primitiveEquals.put(int.class, lookup.findStatic(OBJECT_METHODS_CLASS, "eq", - MethodType.fromMethodDescriptorString("(II)Z", loader))); + MethodType.methodType(boolean.class, int.class, int.class))); primitiveEquals.put(long.class, lookup.findStatic(OBJECT_METHODS_CLASS, "eq", - MethodType.fromMethodDescriptorString("(JJ)Z", loader))); + MethodType.methodType(boolean.class, long.class, long.class))); primitiveEquals.put(float.class, lookup.findStatic(OBJECT_METHODS_CLASS, "eq", - MethodType.fromMethodDescriptorString("(FF)Z", loader))); + MethodType.methodType(boolean.class, float.class, float.class))); primitiveEquals.put(double.class, lookup.findStatic(OBJECT_METHODS_CLASS, "eq", - MethodType.fromMethodDescriptorString("(DD)Z", loader))); + MethodType.methodType(boolean.class, double.class, double.class))); primitiveEquals.put(boolean.class, lookup.findStatic(OBJECT_METHODS_CLASS, "eq", - MethodType.fromMethodDescriptorString("(ZZ)Z", loader))); + MethodType.methodType(boolean.class, boolean.class, boolean.class))); primitiveHashers.put(byte.class, lookup.findStatic(Byte.class, "hashCode", - MethodType.fromMethodDescriptorString("(B)I", loader))); + MethodType.methodType(int.class, byte.class))); primitiveHashers.put(short.class, lookup.findStatic(Short.class, "hashCode", - MethodType.fromMethodDescriptorString("(S)I", loader))); + MethodType.methodType(int.class, short.class))); primitiveHashers.put(char.class, lookup.findStatic(Character.class, "hashCode", - MethodType.fromMethodDescriptorString("(C)I", loader))); + MethodType.methodType(int.class, char.class))); primitiveHashers.put(int.class, lookup.findStatic(Integer.class, "hashCode", - MethodType.fromMethodDescriptorString("(I)I", loader))); + MethodType.methodType(int.class, int.class))); primitiveHashers.put(long.class, lookup.findStatic(Long.class, "hashCode", - MethodType.fromMethodDescriptorString("(J)I", loader))); + MethodType.methodType(int.class, long.class))); primitiveHashers.put(float.class, lookup.findStatic(Float.class, "hashCode", - MethodType.fromMethodDescriptorString("(F)I", loader))); + MethodType.methodType(int.class, float.class))); primitiveHashers.put(double.class, lookup.findStatic(Double.class, "hashCode", - MethodType.fromMethodDescriptorString("(D)I", loader))); + MethodType.methodType(int.class, double.class))); primitiveHashers.put(boolean.class, lookup.findStatic(Boolean.class, "hashCode", - MethodType.fromMethodDescriptorString("(Z)I", loader))); + MethodType.methodType(int.class, boolean.class))); primitiveToString.put(byte.class, lookup.findStatic(Byte.class, "toString", MethodType.methodType(String.class, byte.class))); diff --git a/src/java.base/share/classes/java/lang/runtime/SwitchBootstraps.java b/src/java.base/share/classes/java/lang/runtime/SwitchBootstraps.java index bfdb76e2ef1..0c0144b24db 100644 --- a/src/java.base/share/classes/java/lang/runtime/SwitchBootstraps.java +++ b/src/java.base/share/classes/java/lang/runtime/SwitchBootstraps.java @@ -29,7 +29,6 @@ import java.lang.Enum.EnumDesc; import java.lang.classfile.CodeBuilder; import java.lang.constant.ClassDesc; import java.lang.constant.ConstantDesc; -import java.lang.constant.ConstantDescs; import java.lang.constant.MethodTypeDesc; import java.lang.invoke.CallSite; import java.lang.invoke.ConstantCallSite; @@ -55,6 +54,7 @@ import jdk.internal.constant.ReferenceClassDescImpl; import jdk.internal.misc.PreviewFeatures; import jdk.internal.vm.annotation.Stable; +import static java.lang.constant.ConstantDescs.*; import static java.lang.invoke.MethodHandles.Lookup.ClassOption.NESTMATE; import static java.lang.invoke.MethodHandles.Lookup.ClassOption.STRONG; import java.util.Arrays; @@ -86,15 +86,15 @@ public class SwitchBootstraps { private static final ClassDesc CD_Objects = ReferenceClassDescImpl.ofValidated("Ljava/util/Objects;"); private static final MethodTypeDesc CHECK_INDEX_DESCRIPTOR = - MethodTypeDescImpl.ofValidated(ConstantDescs.CD_int, ConstantDescs.CD_int, ConstantDescs.CD_int); - private static final MethodTypeDesc MTD_TYPE_SWITCH = MethodTypeDescImpl.ofValidated(ConstantDescs.CD_int, - ConstantDescs.CD_Object, - ConstantDescs.CD_int); - private static final MethodTypeDesc MTD_TYPE_SWITCH_EXTRA = MethodTypeDescImpl.ofValidated(ConstantDescs.CD_int, - ConstantDescs.CD_Object, - ConstantDescs.CD_int, + MethodTypeDescImpl.ofValidated(CD_int, CD_int, CD_int); + private static final MethodTypeDesc MTD_TYPE_SWITCH = MethodTypeDescImpl.ofValidated(CD_int, + CD_Object, + CD_int); + private static final MethodTypeDesc MTD_TYPE_SWITCH_EXTRA = MethodTypeDescImpl.ofValidated(CD_int, + CD_Object, + CD_int, CD_BiPredicate, - ConstantDescs.CD_List); + CD_List); private static final MethodType MT_TYPE_SWITCH_EXTRA = MethodType.methodType(int.class, Object.class, int.class, @@ -484,19 +484,19 @@ public class SwitchBootstraps { return cb -> { // Objects.checkIndex(RESTART_IDX, labelConstants + 1) - cb.iload(RESTART_IDX); - cb.loadConstant(labelConstants.length + 1); - cb.invokestatic(CD_Objects, "checkIndex", CHECK_INDEX_DESCRIPTOR); - cb.pop(); - cb.aload(SELECTOR_OBJ); + cb.iload(RESTART_IDX) + .loadConstant(labelConstants.length + 1) + .invokestatic(CD_Objects, "checkIndex", CHECK_INDEX_DESCRIPTOR) + .pop() + .aload(SELECTOR_OBJ); Label nonNullLabel = cb.newLabel(); - cb.ifnonnull(nonNullLabel); - cb.iconst_m1(); - cb.ireturn(); - cb.labelBinding(nonNullLabel); + cb.ifnonnull(nonNullLabel) + .iconst_m1() + .ireturn() + .labelBinding(nonNullLabel); if (labelConstants.length == 0) { cb.loadConstant(0) - .ireturn(); + .ireturn(); return; } cb.iload(RESTART_IDX); @@ -535,132 +535,132 @@ public class SwitchBootstraps { if (!selectorType.isPrimitive() && !Wrapper.isWrapperNumericOrBooleanType(selectorType)) { // Object o = ... // o instanceof Wrapped(float) - cb.aload(SELECTOR_OBJ); - cb.instanceOf(Wrapper.forBasicType(classLabel).wrapperClassDescriptor()); - cb.ifeq(next); + cb.aload(SELECTOR_OBJ) + .instanceOf(Wrapper.forBasicType(classLabel).wrapperClassDescriptor()) + .ifeq(next); } else if (!unconditionalExactnessCheck(Wrapper.asPrimitiveType(selectorType), classLabel)) { // Integer i = ... or int i = ... // o instanceof float Label notNumber = cb.newLabel(); - cb.aload(SELECTOR_OBJ); - cb.instanceOf(ConstantDescs.CD_Number); + cb.aload(SELECTOR_OBJ) + .instanceOf(CD_Number); if (selectorType == long.class || selectorType == float.class || selectorType == double.class || selectorType == Long.class || selectorType == Float.class || selectorType == Double.class) { cb.ifeq(next); } else { cb.ifeq(notNumber); } - cb.aload(SELECTOR_OBJ); - cb.checkcast(ConstantDescs.CD_Number); + cb.aload(SELECTOR_OBJ) + .checkcast(CD_Number); if (selectorType == long.class || selectorType == Long.class) { - cb.invokevirtual(ConstantDescs.CD_Number, + cb.invokevirtual(CD_Number, "longValue", - MethodTypeDesc.of(ConstantDescs.CD_long)); + MethodTypeDesc.of(CD_long)); } else if (selectorType == float.class || selectorType == Float.class) { - cb.invokevirtual(ConstantDescs.CD_Number, + cb.invokevirtual(CD_Number, "floatValue", - MethodTypeDesc.of(ConstantDescs.CD_float)); + MethodTypeDesc.of(CD_float)); } else if (selectorType == double.class || selectorType == Double.class) { - cb.invokevirtual(ConstantDescs.CD_Number, + cb.invokevirtual(CD_Number, "doubleValue", - MethodTypeDesc.of(ConstantDescs.CD_double)); + MethodTypeDesc.of(CD_double)); } else { Label compare = cb.newLabel(); - cb.invokevirtual(ConstantDescs.CD_Number, + cb.invokevirtual(CD_Number, "intValue", - MethodTypeDesc.of(ConstantDescs.CD_int)); - cb.goto_(compare); - cb.labelBinding(notNumber); - cb.aload(SELECTOR_OBJ); - cb.instanceOf(ConstantDescs.CD_Character); - cb.ifeq(next); - cb.aload(SELECTOR_OBJ); - cb.checkcast(ConstantDescs.CD_Character); - cb.invokevirtual(ConstantDescs.CD_Character, + MethodTypeDesc.of(CD_int)) + .goto_(compare) + .labelBinding(notNumber) + .aload(SELECTOR_OBJ) + .instanceOf(CD_Character) + .ifeq(next) + .aload(SELECTOR_OBJ) + .checkcast(CD_Character) + .invokevirtual(CD_Character, "charValue", - MethodTypeDesc.of(ConstantDescs.CD_char)); - cb.labelBinding(compare); + MethodTypeDesc.of(CD_char)) + .labelBinding(compare); } TypePairs typePair = TypePairs.of(Wrapper.asPrimitiveType(selectorType), classLabel); String methodName = TypePairs.typePairToName.get(typePair); cb.invokestatic(referenceClassDesc(ExactConversionsSupport.class), methodName, - MethodTypeDesc.of(ConstantDescs.CD_boolean, classDesc(typePair.from))); - cb.ifeq(next); + MethodTypeDesc.of(CD_boolean, classDesc(typePair.from))) + .ifeq(next); } } else { Optional classLabelConstableOpt = classLabel.describeConstable(); if (classLabelConstableOpt.isPresent()) { - cb.aload(SELECTOR_OBJ); - cb.instanceOf(classLabelConstableOpt.orElseThrow()); - cb.ifeq(next); + cb.aload(SELECTOR_OBJ) + .instanceOf(classLabelConstableOpt.orElseThrow()) + .ifeq(next); } else { - cb.aload(EXTRA_CLASS_LABELS); - cb.loadConstant(extraClassLabels.size()); - cb.invokeinterface(ConstantDescs.CD_List, + cb.aload(EXTRA_CLASS_LABELS) + .loadConstant(extraClassLabels.size()) + .invokeinterface(CD_List, "get", - MethodTypeDesc.of(ConstantDescs.CD_Object, - ConstantDescs.CD_int)); - cb.checkcast(ConstantDescs.CD_Class); - cb.aload(SELECTOR_OBJ); - cb.invokevirtual(ConstantDescs.CD_Class, + MethodTypeDesc.of(CD_Object, + CD_int)) + .checkcast(CD_Class) + .aload(SELECTOR_OBJ) + .invokevirtual(CD_Class, "isInstance", - MethodTypeDesc.of(ConstantDescs.CD_boolean, - ConstantDescs.CD_Object)); - cb.ifeq(next); + MethodTypeDesc.of(CD_boolean, + CD_Object)) + .ifeq(next); extraClassLabels.add(classLabel); } } } else if (caseLabel instanceof EnumDesc enumLabel) { int enumIdx = enumDescs.size(); enumDescs.add(enumLabel); - cb.aload(ENUM_CACHE); - cb.loadConstant(enumIdx); - cb.invokestatic(ConstantDescs.CD_Integer, + cb.aload(ENUM_CACHE) + .loadConstant(enumIdx) + .invokestatic(CD_Integer, "valueOf", - MethodTypeDesc.of(ConstantDescs.CD_Integer, - ConstantDescs.CD_int)); - cb.aload(SELECTOR_OBJ); - cb.invokeinterface(CD_BiPredicate, + MethodTypeDesc.of(CD_Integer, + CD_int)) + .aload(SELECTOR_OBJ) + .invokeinterface(CD_BiPredicate, "test", - MethodTypeDesc.of(ConstantDescs.CD_boolean, - ConstantDescs.CD_Object, - ConstantDescs.CD_Object)); - cb.ifeq(next); + MethodTypeDesc.of(CD_boolean, + CD_Object, + CD_Object)) + .ifeq(next); } else if (caseLabel instanceof String stringLabel) { - cb.ldc(stringLabel); - cb.aload(SELECTOR_OBJ); - cb.invokevirtual(ConstantDescs.CD_Object, + cb.ldc(stringLabel) + .aload(SELECTOR_OBJ) + .invokevirtual(CD_Object, "equals", - MethodTypeDesc.of(ConstantDescs.CD_boolean, - ConstantDescs.CD_Object)); - cb.ifeq(next); + MethodTypeDesc.of(CD_boolean, + CD_Object)) + .ifeq(next); } else if (caseLabel instanceof Integer integerLabel) { Label compare = cb.newLabel(); Label notNumber = cb.newLabel(); - cb.aload(SELECTOR_OBJ); - cb.instanceOf(ConstantDescs.CD_Number); - cb.ifeq(notNumber); - cb.aload(SELECTOR_OBJ); - cb.checkcast(ConstantDescs.CD_Number); - cb.invokevirtual(ConstantDescs.CD_Number, + cb.aload(SELECTOR_OBJ) + .instanceOf(CD_Number) + .ifeq(notNumber) + .aload(SELECTOR_OBJ) + .checkcast(CD_Number) + .invokevirtual(CD_Number, "intValue", - MethodTypeDesc.of(ConstantDescs.CD_int)); - cb.goto_(compare); - cb.labelBinding(notNumber); - cb.aload(SELECTOR_OBJ); - cb.instanceOf(ConstantDescs.CD_Character); - cb.ifeq(next); - cb.aload(SELECTOR_OBJ); - cb.checkcast(ConstantDescs.CD_Character); - cb.invokevirtual(ConstantDescs.CD_Character, + MethodTypeDesc.of(CD_int)) + .goto_(compare) + .labelBinding(notNumber) + .aload(SELECTOR_OBJ) + .instanceOf(CD_Character) + .ifeq(next) + .aload(SELECTOR_OBJ) + .checkcast(CD_Character) + .invokevirtual(CD_Character, "charValue", - MethodTypeDesc.of(ConstantDescs.CD_char)); - cb.labelBinding(compare); + MethodTypeDesc.of(CD_char)) + .labelBinding(compare) - cb.ldc(integerLabel); - cb.if_icmpne(next); + .loadConstant(integerLabel) + .if_icmpne(next); } else if ((caseLabel instanceof Long || caseLabel instanceof Float || caseLabel instanceof Double || @@ -674,23 +674,23 @@ public class SwitchBootstraps { cb.invokestatic(caseLabelWrapper.wrapperClassDescriptor(), "valueOf", MethodTypeDesc.of(caseLabelWrapper.wrapperClassDescriptor(), - caseLabelWrapper.basicClassDescriptor())); - cb.aload(SELECTOR_OBJ); - cb.invokevirtual(ConstantDescs.CD_Object, + caseLabelWrapper.basicClassDescriptor())) + .aload(SELECTOR_OBJ) + .invokevirtual(CD_Object, "equals", - MethodTypeDesc.of(ConstantDescs.CD_boolean, - ConstantDescs.CD_Object)); - cb.ifeq(next); + MethodTypeDesc.of(CD_boolean, + CD_Object)) + .ifeq(next); } else { throw new InternalError("Unsupported label type: " + caseLabel.getClass()); } - cb.loadConstant(idx); - cb.ireturn(); + cb.loadConstant(idx) + .ireturn(); } - cb.labelBinding(dflt); - cb.loadConstant(labelConstants.length); - cb.ireturn(); + cb.labelBinding(dflt) + .loadConstant(labelConstants.length) + .ireturn(); }; } diff --git a/src/java.base/share/classes/java/math/MutableBigInteger.java b/src/java.base/share/classes/java/math/MutableBigInteger.java index b84e50f567e..6ff435ba1ed 100644 --- a/src/java.base/share/classes/java/math/MutableBigInteger.java +++ b/src/java.base/share/classes/java/math/MutableBigInteger.java @@ -597,44 +597,52 @@ class MutableBigInteger { */ if (intLen == 0) return; + int nInts = n >>> 5; - int nBits = n&0x1F; - int bitsInHighWord = BigInteger.bitLengthForInt(value[offset]); + int nBits = n & 0x1F; + int leadingZeros = Integer.numberOfLeadingZeros(value[offset]); // If shift can be done without moving words, do so - if (n <= (32-bitsInHighWord)) { + if (n <= leadingZeros) { primitiveLeftShift(nBits); return; } - int newLen = intLen + nInts +1; - if (nBits <= (32-bitsInHighWord)) - newLen--; - if (value.length < newLen) { - // The array must grow - int[] result = new int[newLen]; - for (int i=0; i < intLen; i++) - result[i] = value[offset+i]; - setValue(result, newLen); - } else if (value.length - offset >= newLen) { - // Use space on right - for(int i=0; i < newLen - intLen; i++) - value[offset+intLen+i] = 0; + int newLen = intLen + nInts; + if (nBits > leadingZeros) + newLen++; + + int[] result; + final int newOffset; + if (value.length < newLen) { // The array must grow + result = new int[newLen]; + newOffset = 0; } else { - // Must use space on left - for (int i=0; i < intLen; i++) - value[i] = value[offset+i]; - for (int i=intLen; i < newLen; i++) - value[i] = 0; - offset = 0; + result = value; + newOffset = value.length - offset >= newLen ? offset : 0; } + + int trailingZerosPos = newOffset + intLen; + if (nBits != 0) { + // Do primitive shift directly for speed + if (nBits <= leadingZeros) { + primitiveLeftShift(nBits, result, newOffset); // newOffset <= offset + } else { + int lastInt = value[offset + intLen - 1]; + primitiveRightShift(32 - nBits, result, newOffset); // newOffset <= offset + result[trailingZerosPos++] = lastInt << nBits; + } + } else if (result != value || newOffset != offset) { + System.arraycopy(value, offset, result, newOffset, intLen); + } + + // Add trailing zeros + if (result == value) + Arrays.fill(result, trailingZerosPos, newOffset + newLen, 0); + + value = result; intLen = newLen; - if (nBits == 0) - return; - if (nBits <= (32-bitsInHighWord)) - primitiveLeftShift(nBits); - else - primitiveRightShift(32 -nBits); + offset = newOffset; } /** @@ -698,15 +706,30 @@ class MutableBigInteger { * less than 32. * Assumes that intLen > 0, n > 0 for speed */ - private final void primitiveRightShift(int n) { + private void primitiveRightShift(int n) { + primitiveRightShift(n, value, offset); + } + + /** + * Right shift this MutableBigInteger n bits, where n is + * less than 32, placing the result in the specified array. + * Assumes that intLen > 0, n > 0 for speed. + * The result can be the value array of this MutableBigInteger, + * but for speed the copy is not performed safely, so, in that case + * the caller has to make sure that + * {@code (resFrom <= offset || resFrom >= offset + intLen)}. + */ + private void primitiveRightShift(int n, int[] result, int resFrom) { int[] val = value; int n2 = 32 - n; - for (int i=offset+intLen-1, c=val[i]; i > offset; i--) { - int b = c; - c = val[i-1]; - val[i] = (c << n2) | (b >>> n); + + int b = val[offset]; + result[resFrom] = b >>> n; + for (int i = 1; i < intLen; i++) { + int c = b; + b = val[offset + i]; + result[resFrom + i] = (c << n2) | (b >>> n); } - val[offset] >>>= n; } /** @@ -714,15 +737,30 @@ class MutableBigInteger { * less than 32. * Assumes that intLen > 0, n > 0 for speed */ - private final void primitiveLeftShift(int n) { + private void primitiveLeftShift(int n) { + primitiveLeftShift(n, value, offset); + } + + /** + * Left shift this MutableBigInteger n bits, where n is + * less than 32, placing the result in the specified array. + * Assumes that intLen > 0, n > 0 for speed. + * The result can be the value array of this MutableBigInteger, + * but for speed the copy is not performed safely, so, in that case + * the caller has to make sure that + * {@code (resFrom <= offset || resFrom >= offset + intLen)}. + */ + private void primitiveLeftShift(int n, int[] result, int resFrom) { int[] val = value; int n2 = 32 - n; - for (int i=offset, c=val[i], m=i+intLen-1; i < m; i++) { - int b = c; - c = val[i+1]; - val[i] = (b << n) | (c >>> n2); + final int m = intLen - 1; + int b = val[offset]; + for (int i = 0; i < m; i++) { + int c = val[offset + i + 1]; + result[resFrom + i] = (b << n) | (c >>> n2); + b = c; } - val[offset+intLen-1] <<= n; + result[resFrom + m] = b << n; } /** @@ -1511,17 +1549,6 @@ class MutableBigInteger { } } - private static void copyAndShift(int[] src, int srcFrom, int srcLen, int[] dst, int dstFrom, int shift) { - int n2 = 32 - shift; - int c=src[srcFrom]; - for (int i=0; i < srcLen-1; i++) { - int b = c; - c = src[++srcFrom]; - dst[dstFrom+i] = (b << shift) | (c >>> n2); - } - dst[dstFrom+srcLen-1] = c << shift; - } - /** * Divide this MutableBigInteger by the divisor. * The quotient will be placed into the provided quotient object & @@ -1539,13 +1566,13 @@ class MutableBigInteger { MutableBigInteger rem; // Remainder starts as dividend with space for a leading zero if (shift > 0) { divisor = new int[dlen]; - copyAndShift(div.value,div.offset,dlen,divisor,0,shift); + div.primitiveLeftShift(shift, divisor, 0); if (Integer.numberOfLeadingZeros(value[offset]) >= shift) { int[] remarr = new int[intLen + 1]; rem = new MutableBigInteger(remarr); rem.intLen = intLen; rem.offset = 1; - copyAndShift(value,offset,intLen,remarr,1,shift); + this.primitiveLeftShift(shift, remarr, 1); } else { int[] remarr = new int[intLen + 2]; rem = new MutableBigInteger(remarr); diff --git a/src/java.base/share/classes/java/net/HttpURLConnection.java b/src/java.base/share/classes/java/net/HttpURLConnection.java index b405fb10a16..625fd30424e 100644 --- a/src/java.base/share/classes/java/net/HttpURLConnection.java +++ b/src/java.base/share/classes/java/net/HttpURLConnection.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -373,8 +373,7 @@ public abstract class HttpURLConnection extends URLConnection { /** * Sets whether HTTP redirects (requests with response code 3xx) should - * be automatically followed by this class. True by default. Applets - * cannot change this variable. + * be automatically followed by this class. True by default. *

          * If there is a security manager, this method first calls * the security manager's {@code checkSetFactory} method diff --git a/src/java.base/share/classes/java/net/NetworkInterface.java b/src/java.base/share/classes/java/net/NetworkInterface.java index f2d039d2502..90e52527b63 100644 --- a/src/java.base/share/classes/java/net/NetworkInterface.java +++ b/src/java.base/share/classes/java/net/NetworkInterface.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,12 +35,43 @@ import java.util.stream.Stream; import java.util.stream.StreamSupport; /** - * This class represents a Network Interface made up of a name, - * and a list of IP addresses assigned to this interface. - * It is used to identify the local interface on which a multicast group - * is joined. + * This class represents a Network Interface. + *

          + * A Network Interface is an abstraction encapsulating + * the characteristics of a Network Interface Controller, or + * Virtual Network adapter, which is a system hardware/software + * component connecting a computer, or host system, to a computer + * network. A Network Interface can be physical or virtual. + * A Network Interface has a name, zero or more assigned + * {@linkplain InetAddress IP addresses}, zero or more {@linkplain + * InterfaceAddress MAC Addresses}, and may have an index. + * The name is highly platform specific but a name such as "le0" + * is typical; it may not be unique. The index is a highly platform + * specific number that identifies the interface. The network + * configuration may change during the lifetime of the JVM. + * For example, the set of IP addresses assigned to a network + * interface can be transient and dynamically allocated, and may + * change at any time. + *

          + * When obtaining a {@code NetworkInterface} instance, part of its + * configuration (such as its name and the list of assigned IP addresses), + * is reflective of its configuration at creation time. + * Obtaining an updated view of the network configuration may require + * looking up a network interface again in order to obtain a new instance. + *

          + * Network interface instances are typically used to identify the local + * interface on which a multicast group is joined. * - * Interfaces are normally known by names such as "le0". + * @apiNote Several static methods in this class are + * factory methods, returning a new instance of a {@code NetworkInterface}, + * reflecting the configuration at the time of instantiation. + * The network configuration may change at any time, and as such, + * these methods may need to be invoked again in order to obtain + * a more up-to-date view of the network interfaces. + * In particular, there is no guarantee that the same interface will be + * found at the same index, or that the same network addresses will be + * bound to the interface, if the network configuration of the system + * has changed. * * @since 1.4 */ @@ -87,7 +118,7 @@ public final class NetworkInterface { } /** - * Get an Enumeration with all or a subset of the InetAddresses bound to + * Get an Enumeration with all, or a subset, of the InetAddresses bound to * this network interface. *

          * If there is a security manager, its {@code checkConnect} @@ -97,7 +128,12 @@ public final class NetworkInterface { * {@link NetPermission}("getNetworkInformation") permission, then all * InetAddresses are returned. * - * @return an Enumeration object with all or a subset of the InetAddresses + * @implNote + * The returned enumeration contains all, or a subset, of the InetAddresses that were + * bound to the interface at the time the {@linkplain #getNetworkInterfaces() + * interface configuration was read} + * + * @return an Enumeration object with all, or a subset, of the InetAddresses * bound to this network interface * @see #inetAddresses() */ @@ -106,7 +142,7 @@ public final class NetworkInterface { } /** - * Get a Stream of all or a subset of the InetAddresses bound to this + * Get a Stream of all, or a subset, of the InetAddresses bound to this * network interface. *

          * If there is a security manager, its {@code checkConnect} @@ -116,7 +152,12 @@ public final class NetworkInterface { * {@link NetPermission}("getNetworkInformation") permission, then all * InetAddresses are returned. * - * @return a Stream object with all or a subset of the InetAddresses + * @implNote + * The stream contains all, or a subset, of the InetAddresses that were + * bound to the interface at the time the {@linkplain #getNetworkInterfaces() + * interface configuration was read} + * + * @return a Stream object with all, or a subset, of the InetAddresses * bound to this network interface * @since 9 */ @@ -150,7 +191,7 @@ public final class NetworkInterface { } /** - * Get a List of all or a subset of the {@code InterfaceAddresses} + * Get a List of all, or a subset, of the {@code InterfaceAddresses} * of this network interface. *

          * If there is a security manager, its {@code checkConnect} @@ -158,7 +199,7 @@ public final class NetworkInterface { * Only InterfaceAddresses where the {@code checkConnect} doesn't throw * a SecurityException will be returned in the List. * - * @return a {@code List} object with all or a subset of the + * @return a {@code List} object with all, or a subset, of the * InterfaceAddress of this network interface * @since 1.6 */ @@ -249,6 +290,12 @@ public final class NetworkInterface { /** * Searches for the network interface with the specified name. * + * @apiNote + * The returned interface instance may reflect a snapshot of the + * configuration taken at the time the instance is created. + * See the general discussion of {@linkplain NetworkInterface##lookup + * snapshots and configuration} for the semantics of the returned interface. + * * @param name * The name of the network interface. * @@ -271,6 +318,12 @@ public final class NetworkInterface { /** * Get a network interface given its index. * + * @apiNote + * The returned interface instance may reflect a snapshot of the + * configuration taken at the time the instance is created. + * See the general discussion of {@linkplain NetworkInterface##lookup + * snapshots and configuration} for the semantics of the returned interface. + * * @param index an integer, the index of the interface * @return the NetworkInterface obtained from its index, or {@code null} if * there is no interface with such an index on the system @@ -294,6 +347,12 @@ public final class NetworkInterface { * interfaces it is not defined which network interface is * returned. * + * @apiNote + * The returned interface instance may reflect a snapshot of the + * configuration taken at the time the instance is created. + * See the general discussion of {@linkplain NetworkInterface##lookup + * snapshots and configuration} for the semantics of the returned interface. + * * @param addr * The {@code InetAddress} to search with. * @@ -334,8 +393,14 @@ public final class NetworkInterface { * a loopback interface that only supports communication between entities on * this machine. * - * @apiNote this method can be used in combination with - * {@link #getInetAddresses()} to obtain all IP addresses for this node + * @apiNote + * This method can be used in combination with + * {@link #getInetAddresses()} to obtain all IP addresses for this node. + *

          + * The returned interface instances may reflect a snapshot of the + * configuration taken at the time the instance is created. + * See the general discussion of {@linkplain NetworkInterface##lookup + * snapshots and configuration} for the semantics of the returned interface. * * @return an Enumeration of NetworkInterfaces found on this machine * @throws SocketException if an I/O error occurs, @@ -359,13 +424,18 @@ public final class NetworkInterface { * loopback interface that only supports communication between entities on * this machine. * - * @apiNote this method can be used in combination with + * @apiNote This method can be used in combination with * {@link #inetAddresses()}} to obtain a stream of all IP addresses for * this node, for example: *

           {@code
                * Stream addrs = NetworkInterface.networkInterfaces()
                *     .flatMap(NetworkInterface::inetAddresses);
                * }
          + *

          + * The returned interface instances may reflect a snapshot of the + * configuration taken at the time the instance is created. + * See the general discussion of {@linkplain NetworkInterface##lookup + * snapshots and configuration} for the semantics of the returned interface. * * @return a Stream of NetworkInterfaces found on this machine * @throws SocketException if an I/O error occurs, diff --git a/src/java.base/share/classes/java/net/Socket.java b/src/java.base/share/classes/java/net/Socket.java index 23c225fbb2d..309fa7a80d0 100644 --- a/src/java.base/share/classes/java/net/Socket.java +++ b/src/java.base/share/classes/java/net/Socket.java @@ -27,6 +27,7 @@ package java.net; import jdk.internal.event.SocketReadEvent; import jdk.internal.event.SocketWriteEvent; +import jdk.internal.invoke.MhUtil; import sun.security.util.SecurityConstants; import java.io.InputStream; @@ -102,14 +103,10 @@ import java.util.Collections; public class Socket implements java.io.Closeable { private static final VarHandle STATE, IN, OUT; static { - try { - MethodHandles.Lookup l = MethodHandles.lookup(); - STATE = l.findVarHandle(Socket.class, "state", int.class); - IN = l.findVarHandle(Socket.class, "in", InputStream.class); - OUT = l.findVarHandle(Socket.class, "out", OutputStream.class); - } catch (Exception e) { - throw new InternalError(e); - } + MethodHandles.Lookup l = MethodHandles.lookup(); + STATE = MhUtil.findVarHandle(l, "state", int.class); + IN = MhUtil.findVarHandle(l, "in", InputStream.class); + OUT = MhUtil.findVarHandle(l, "out", OutputStream.class); } // the underlying SocketImpl, may be null, may be swapped when connecting diff --git a/src/java.base/share/classes/java/nio/Buffer.java b/src/java.base/share/classes/java/nio/Buffer.java index 7bfcbea9639..828ae417f79 100644 --- a/src/java.base/share/classes/java/nio/Buffer.java +++ b/src/java.base/share/classes/java/nio/Buffer.java @@ -27,6 +27,7 @@ package java.nio; import jdk.internal.access.JavaNioAccess; import jdk.internal.access.SharedSecrets; +import jdk.internal.access.foreign.MappedMemoryUtilsProxy; import jdk.internal.access.foreign.UnmapperProxy; import jdk.internal.foreign.AbstractMemorySegmentImpl; import jdk.internal.foreign.MemorySessionImpl; @@ -804,6 +805,7 @@ public abstract sealed class Buffer } static { + // setup access to this package in SharedSecrets SharedSecrets.setJavaNioAccess( new JavaNioAccess() { @@ -886,23 +888,8 @@ public abstract sealed class Buffer } @Override - public void force(FileDescriptor fd, long address, boolean isSync, long offset, long size) { - MappedMemoryUtils.force(fd, address, isSync, offset, size); - } - - @Override - public void load(long address, boolean isSync, long size) { - MappedMemoryUtils.load(address, isSync, size); - } - - @Override - public void unload(long address, boolean isSync, long size) { - MappedMemoryUtils.unload(address, isSync, size); - } - - @Override - public boolean isLoaded(long address, boolean isSync, long size) { - return MappedMemoryUtils.isLoaded(address, isSync, size); + public MappedMemoryUtilsProxy mappedMemoryUtils() { + return MappedMemoryUtils.PROXY; } @Override diff --git a/src/java.base/share/classes/java/nio/MappedByteBuffer.java b/src/java.base/share/classes/java/nio/MappedByteBuffer.java index d560d3843d2..9c1f21c7370 100644 --- a/src/java.base/share/classes/java/nio/MappedByteBuffer.java +++ b/src/java.base/share/classes/java/nio/MappedByteBuffer.java @@ -31,6 +31,7 @@ import java.lang.foreign.MemorySegment; import java.lang.ref.Reference; import java.util.Objects; +import jdk.internal.access.foreign.MappedMemoryUtilsProxy; import jdk.internal.access.foreign.UnmapperProxy; import jdk.internal.misc.ScopedMemoryAccess; import jdk.internal.misc.Unsafe; @@ -194,7 +195,7 @@ public abstract sealed class MappedByteBuffer if (fd == null) { return true; } - return SCOPED_MEMORY_ACCESS.isLoaded(session(), address, isSync, capacity()); + return SCOPED_MEMORY_ACCESS.isLoaded(session(), MappedMemoryUtils.PROXY, address, isSync, capacity()); } /** @@ -212,7 +213,7 @@ public abstract sealed class MappedByteBuffer return this; } try { - SCOPED_MEMORY_ACCESS.load(session(), address, isSync, capacity()); + SCOPED_MEMORY_ACCESS.load(session(), MappedMemoryUtils.PROXY, address, isSync, capacity()); } finally { Reference.reachabilityFence(this); } @@ -312,7 +313,7 @@ public abstract sealed class MappedByteBuffer if ((address != 0) && (capacity != 0)) { // check inputs Objects.checkFromIndexSize(index, length, capacity); - SCOPED_MEMORY_ACCESS.force(session(), fd, address, isSync, index, length); + SCOPED_MEMORY_ACCESS.force(session(), MappedMemoryUtils.PROXY, fd, address, isSync, index, length); } return this; } diff --git a/src/java.base/share/classes/java/nio/MappedMemoryUtils.java b/src/java.base/share/classes/java/nio/MappedMemoryUtils.java index cf6f953d8b2..d0ec627f817 100644 --- a/src/java.base/share/classes/java/nio/MappedMemoryUtils.java +++ b/src/java.base/share/classes/java/nio/MappedMemoryUtils.java @@ -28,6 +28,8 @@ package java.nio; import java.io.FileDescriptor; import java.io.IOException; import java.io.UncheckedIOException; + +import jdk.internal.access.foreign.MappedMemoryUtilsProxy; import jdk.internal.misc.Blocker; import jdk.internal.misc.Unsafe; @@ -116,6 +118,17 @@ import jdk.internal.misc.Unsafe; private static native void unload0(long address, long length); private static native void force0(FileDescriptor fd, long address, long length) throws IOException; + /* Register the natives via the static initializer. + * + * This is required, as these native methods are "scoped methods" (see ScopedMemoryAccess). + * As such, it's better not to end up doing a full JNI lookup while in a scoped method context, + * as that will make the stack trace too deep. + */ + private static native void registerNatives(); + static { + registerNatives(); + } + // utility methods // Returns the distance (in bytes) of the buffer start from the @@ -164,4 +177,26 @@ import jdk.internal.misc.Unsafe; // pageSize must be a power of 2 return address & ~(pageSize - 1); } + + static final MappedMemoryUtilsProxy PROXY = new MappedMemoryUtilsProxy() { + @Override + public boolean isLoaded(long address, boolean isSync, long size) { + return MappedMemoryUtils.isLoaded(address, isSync, size); + } + + @Override + public void load(long address, boolean isSync, long size) { + MappedMemoryUtils.load(address, isSync, size); + } + + @Override + public void unload(long address, boolean isSync, long size) { + MappedMemoryUtils.unload(address, isSync, size); + } + + @Override + public void force(FileDescriptor fd, long address, boolean isSync, long index, long length) { + MappedMemoryUtils.force(fd, address, isSync, index, length); + } + }; } diff --git a/src/java.base/share/classes/java/nio/channels/SelectionKey.java b/src/java.base/share/classes/java/nio/channels/SelectionKey.java index ca6df2a7aa0..79029e63653 100644 --- a/src/java.base/share/classes/java/nio/channels/SelectionKey.java +++ b/src/java.base/share/classes/java/nio/channels/SelectionKey.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,8 @@ package java.nio.channels; +import jdk.internal.invoke.MhUtil; + import java.lang.invoke.MethodHandles; import java.lang.invoke.VarHandle; @@ -429,15 +431,9 @@ public abstract class SelectionKey { // -- Attachments -- - private static final VarHandle ATTACHMENT; - static { - try { - MethodHandles.Lookup l = MethodHandles.lookup(); - ATTACHMENT = l.findVarHandle(SelectionKey.class, "attachment", Object.class); - } catch (Exception e) { - throw new InternalError(e); - } - } + private static final VarHandle ATTACHMENT = MhUtil.findVarHandle( + MethodHandles.lookup(), "attachment", Object.class); + private volatile Object attachment; /** diff --git a/src/java.base/share/classes/java/nio/channels/spi/AbstractSelectionKey.java b/src/java.base/share/classes/java/nio/channels/spi/AbstractSelectionKey.java index 0a79ca321dd..3005fc9522c 100644 --- a/src/java.base/share/classes/java/nio/channels/spi/AbstractSelectionKey.java +++ b/src/java.base/share/classes/java/nio/channels/spi/AbstractSelectionKey.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,6 +30,7 @@ import java.lang.invoke.VarHandle; import java.nio.channels.SelectionKey; import java.nio.channels.Selector; +import jdk.internal.invoke.MhUtil; import sun.nio.ch.SelectionKeyImpl; import sun.nio.ch.SelectorImpl; @@ -46,15 +47,8 @@ import sun.nio.ch.SelectorImpl; public abstract class AbstractSelectionKey extends SelectionKey { - private static final VarHandle INVALID; - static { - try { - MethodHandles.Lookup l = MethodHandles.lookup(); - INVALID = l.findVarHandle(AbstractSelectionKey.class, "invalid", boolean.class); - } catch (Exception e) { - throw new InternalError(e); - } - } + private static final VarHandle INVALID = MhUtil.findVarHandle( + MethodHandles.lookup(), "invalid", boolean.class); /** * Initializes a new instance of this class. diff --git a/src/java.base/share/classes/java/nio/channels/spi/AbstractSelector.java b/src/java.base/share/classes/java/nio/channels/spi/AbstractSelector.java index 7ea5f892218..71dc8620eb8 100644 --- a/src/java.base/share/classes/java/nio/channels/spi/AbstractSelector.java +++ b/src/java.base/share/classes/java/nio/channels/spi/AbstractSelector.java @@ -32,6 +32,8 @@ import java.nio.channels.SelectionKey; import java.nio.channels.Selector; import java.util.HashSet; import java.util.Set; + +import jdk.internal.invoke.MhUtil; import sun.nio.ch.Interruptible; import sun.nio.ch.SelectorImpl; @@ -72,15 +74,9 @@ import sun.nio.ch.SelectorImpl; public abstract class AbstractSelector extends Selector { - private static final VarHandle CLOSED; - static { - try { - MethodHandles.Lookup l = MethodHandles.lookup(); - CLOSED = l.findVarHandle(AbstractSelector.class, "closed", boolean.class); - } catch (Exception e) { - throw new InternalError(e); - } - } + private static final VarHandle CLOSED = MhUtil.findVarHandle( + MethodHandles.lookup(), "closed", boolean.class); + private volatile boolean closed; // The provider that created this selector diff --git a/src/java.base/share/classes/java/nio/charset/MalformedInputException.java b/src/java.base/share/classes/java/nio/charset/MalformedInputException.java index 37e20040dd5..c36f81f9153 100644 --- a/src/java.base/share/classes/java/nio/charset/MalformedInputException.java +++ b/src/java.base/share/classes/java/nio/charset/MalformedInputException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -56,16 +56,14 @@ public class MalformedInputException } /** - * Returns the length of the input. - * @return the length of the input + * {@return the length of the input} */ public int getInputLength() { return inputLength; } /** - * Returns the message. - * @return the message + * {@return the message} */ public String getMessage() { return "Input length = " + inputLength; diff --git a/src/java.base/share/classes/java/nio/charset/UnmappableCharacterException.java b/src/java.base/share/classes/java/nio/charset/UnmappableCharacterException.java index c5fddd1684f..857c519974d 100644 --- a/src/java.base/share/classes/java/nio/charset/UnmappableCharacterException.java +++ b/src/java.base/share/classes/java/nio/charset/UnmappableCharacterException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -56,16 +56,14 @@ public class UnmappableCharacterException } /** - * Returns the length of the input. - * @return the length of the input + * {@return the length of the input} */ public int getInputLength() { return inputLength; } /** - * Returns the message. - * @return the message + * {@return the message} */ public String getMessage() { return "Input length = " + inputLength; diff --git a/src/java.base/share/classes/java/nio/charset/spi/CharsetProvider.java b/src/java.base/share/classes/java/nio/charset/spi/CharsetProvider.java index 87ff0d07854..114558d9392 100644 --- a/src/java.base/share/classes/java/nio/charset/spi/CharsetProvider.java +++ b/src/java.base/share/classes/java/nio/charset/spi/CharsetProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,17 +33,29 @@ import java.util.Iterator; * Charset service-provider class. * *

          A charset provider is a concrete subclass of this class that has a - * zero-argument constructor and some number of associated charset - * implementation classes. Charset providers may be installed in an instance - * of the Java platform as extensions. Providers may also be made available by - * adding them to the applet or application class path or by some other - * platform-specific means. Charset providers are looked up via the current - * thread's {@link java.lang.Thread#getContextClassLoader() context class - * loader}. + * zero-argument constructor and some number of associated {@code Charset} + * implementation classes. Charset providers are deployed on the application + * module path or the application class path. In order to be looked up, charset + * providers must be visible to the {@link ClassLoader#getSystemClassLoader() system + * class loader}. See {@link java.util.ServiceLoader##developing-service-providers + * Deploying Service Providers} for further detail on deploying a charset + * provider as a module or on the class path. * - *

          A charset provider identifies itself with a provider-configuration file - * named {@code java.nio.charset.spi.CharsetProvider} in the resource - * directory {@code META-INF/services}. The file should contain a list of + *

          For a charset provider deployed in a module, the provides + * directive must be specified in the module declaration. The provides directive + * specifies both the service and the service provider. In this case, the service + * is {@code java.nio.charset.spi.CharsetProvider}. + * + *

          As an example, a charset provider deployed as a module might specify the + * following directive: + *

          {@code
          + *     provides java.nio.charset.spi.CharsetProvider with com.example.ExternalCharsetProvider;
          + * }
          + * + *

          For a charset provider deployed on the class path, it identifies itself + * with a provider-configuration file named {@code + * java.nio.charset.spi.CharsetProvider} in the resource directory + * {@code META-INF/services}. The file should contain a list of * fully-qualified concrete charset-provider class names, one per line. A line * is terminated by any one of a line feed ({@code '\n'}), a carriage return * ({@code '\r'}), or a carriage return followed immediately by a line feed. diff --git a/src/java.base/share/classes/java/nio/file/Path.java b/src/java.base/share/classes/java/nio/file/Path.java index 6a47e1ba82b..a461152803b 100644 --- a/src/java.base/share/classes/java/nio/file/Path.java +++ b/src/java.base/share/classes/java/nio/file/Path.java @@ -803,8 +803,8 @@ public interface Path * "{@code ..}" (or equivalent) is preceded by a non-"{@code ..}" name then * an implementation will typically cause both names to be removed. When * not resolving symbolic links and the preceding name is a symbolic link - * then the names are only removed if it guaranteed that the resulting path - * will locate the same file as this path. + * then the names are only removed if it is guaranteed that the resulting + * path will locate the same file as this path. * * @param options * options indicating how symbolic links are handled diff --git a/src/java.base/share/classes/java/security/Policy.java b/src/java.base/share/classes/java/security/Policy.java index 838366b7e38..37f7cc3d9a6 100644 --- a/src/java.base/share/classes/java/security/Policy.java +++ b/src/java.base/share/classes/java/security/Policy.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -896,5 +896,15 @@ public abstract class Policy { @Override public Enumeration elements() { return perms.elements(); } + + /** + * If this object is readonly, no new objects can be added to it using {@code add}. + * + * @return {@code true} if this object is marked as readonly, {@code false} otherwise. + */ + @Override + public boolean isReadOnly() { + return perms.isReadOnly(); + } } } diff --git a/src/java.base/share/classes/java/security/SecureRandom.java b/src/java.base/share/classes/java/security/SecureRandom.java index 4242b5da04a..fac7f6b9383 100644 --- a/src/java.base/share/classes/java/security/SecureRandom.java +++ b/src/java.base/share/classes/java/security/SecureRandom.java @@ -225,8 +225,8 @@ public class SecureRandom extends java.util.Random { if (provider == null || algorithm == null) { return false; } else { - return Boolean.parseBoolean(provider.getProperty( - "SecureRandom." + algorithm + " ThreadSafe", "false")); + Service service = provider.getService("SecureRandom", algorithm); + return Boolean.parseBoolean(service.getAttribute("ThreadSafe")); } } diff --git a/src/java.base/share/classes/java/security/Security.java b/src/java.base/share/classes/java/security/Security.java index 0cdd22340df..6628b717eb0 100644 --- a/src/java.base/share/classes/java/security/Security.java +++ b/src/java.base/share/classes/java/security/Security.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,22 +25,39 @@ package java.security; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; import java.net.MalformedURLException; -import java.util.*; -import java.util.concurrent.ConcurrentHashMap; -import java.io.*; +import java.net.URI; import java.net.URL; +import java.nio.file.Files; +import java.nio.file.InvalidPathException; +import java.nio.file.Path; +import java.util.Arrays; +import java.util.Collections; +import java.util.Enumeration; +import java.util.HashSet; +import java.util.Hashtable; +import java.util.LinkedList; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Properties; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; import jdk.internal.access.JavaSecurityPropertiesAccess; +import jdk.internal.access.SharedSecrets; import jdk.internal.event.EventHelper; import jdk.internal.event.SecurityPropertyModificationEvent; -import jdk.internal.access.SharedSecrets; import jdk.internal.util.StaticProperty; +import sun.security.jca.GetInstance; +import sun.security.jca.ProviderList; +import sun.security.jca.Providers; import sun.security.util.Debug; import sun.security.util.PropertyExpander; -import sun.security.jca.*; - /** *

          This class centralizes all security properties and common security * methods. One of its primary uses is to manage providers. @@ -63,7 +80,17 @@ public final class Security { Debug.getInstance("properties"); /* The java.security properties */ - private static Properties props; + private static final Properties props = new Properties() { + @Override + public synchronized Object put(Object key, Object val) { + if (key instanceof String strKey && val instanceof String strVal && + SecPropLoader.isInclude(strKey)) { + SecPropLoader.loadInclude(strVal); + return null; + } + return super.put(key, val); + } + }; /* cache a copy for recording purposes */ private static Properties initialSecurityProperties; @@ -74,11 +101,220 @@ public final class Security { Provider provider; } + private static final class SecPropLoader { + private enum LoadingMode {OVERRIDE, APPEND} + + private static final String OVERRIDE_SEC_PROP = + "security.overridePropertiesFile"; + + private static final String EXTRA_SYS_PROP = + "java.security.properties"; + + private static Path currentPath; + + private static final Set activePaths = new HashSet<>(); + + static void loadAll() { + // first load the master properties file to + // determine the value of OVERRIDE_SEC_PROP + loadMaster(); + loadExtra(); + } + + static boolean isInclude(String key) { + return "include".equals(key); + } + + static void checkReservedKey(String key) + throws IllegalArgumentException { + if (isInclude(key)) { + throw new IllegalArgumentException("Key '" + key + + "' is reserved and cannot be used as a " + + "Security property name."); + } + } + + private static void loadMaster() { + try { + loadFromPath(Path.of(StaticProperty.javaHome(), "conf", + "security", "java.security"), LoadingMode.APPEND); + } catch (IOException e) { + throw new InternalError("Error loading java.security file", e); + } + } + + private static void loadExtra() { + if ("true".equalsIgnoreCase(props.getProperty(OVERRIDE_SEC_PROP))) { + String propFile = System.getProperty(EXTRA_SYS_PROP); + if (propFile != null) { + LoadingMode mode = LoadingMode.APPEND; + if (propFile.startsWith("=")) { + mode = LoadingMode.OVERRIDE; + propFile = propFile.substring(1); + } + try { + loadExtraHelper(propFile, mode); + } catch (Exception e) { + if (sdebug != null) { + sdebug.println("unable to load security " + + "properties from " + propFile); + e.printStackTrace(); + } + } + } + } + } + + private static void loadExtraHelper(String propFile, LoadingMode mode) + throws Exception { + propFile = PropertyExpander.expand(propFile); + if (propFile.isEmpty()) { + throw new IOException("Empty extra properties file path"); + } + + // Try to interpret propFile as a path + Exception error; + if ((error = loadExtraFromPath(propFile, mode)) == null) { + return; + } + + // Try to interpret propFile as a file URL + URI uri = null; + try { + uri = new URI(propFile); + } catch (Exception ignore) {} + if (uri != null && "file".equalsIgnoreCase(uri.getScheme()) && + (error = loadExtraFromFileUrl(uri, mode)) == null) { + return; + } + + // Try to interpret propFile as a URL + URL url; + try { + url = newURL(propFile); + } catch (MalformedURLException ignore) { + // URL has no scheme: previous error is more accurate + throw error; + } + loadFromUrl(url, mode); + } + + private static Exception loadExtraFromPath(String propFile, + LoadingMode mode) throws Exception { + Path path; + try { + path = Path.of(propFile); + if (!Files.exists(path)) { + return new FileNotFoundException(propFile); + } + } catch (InvalidPathException e) { + return e; + } + loadFromPath(path, mode); + return null; + } + + + private static Exception loadExtraFromFileUrl(URI uri, LoadingMode mode) + throws Exception { + Path path; + try { + path = Path.of(uri); + } catch (Exception e) { + return e; + } + loadFromPath(path, mode); + return null; + } + + private static void reset(LoadingMode mode) { + if (mode == LoadingMode.OVERRIDE) { + if (sdebug != null) { + sdebug.println( + "overriding other security properties files!"); + } + props.clear(); + } + } + + static void loadInclude(String propFile) { + String expPropFile = PropertyExpander.expandNonStrict(propFile); + if (sdebug != null) { + sdebug.println("processing include: '" + propFile + "'" + + (propFile.equals(expPropFile) ? "" : + " (expanded to '" + expPropFile + "')")); + } + try { + Path path = Path.of(expPropFile); + if (!path.isAbsolute()) { + if (currentPath == null) { + throw new InternalError("Cannot resolve '" + + expPropFile + "' relative path when included " + + "from a non-regular properties file " + + "(e.g. HTTP served file)"); + } + path = currentPath.resolveSibling(path); + } + loadFromPath(path, LoadingMode.APPEND); + } catch (IOException | InvalidPathException e) { + throw new InternalError("Unable to include '" + expPropFile + + "'", e); + } + } + + private static void loadFromPath(Path path, LoadingMode mode) + throws IOException { + boolean isRegularFile = Files.isRegularFile(path); + if (isRegularFile) { + path = path.toRealPath(); + } else if (Files.isDirectory(path)) { + throw new IOException("Is a directory"); + } else { + path = path.toAbsolutePath(); + } + if (activePaths.contains(path)) { + throw new InternalError("Cyclic include of '" + path + "'"); + } + try (InputStream is = Files.newInputStream(path)) { + reset(mode); + Path previousPath = currentPath; + currentPath = isRegularFile ? path : null; + activePaths.add(path); + try { + debugLoad(true, path); + props.load(is); + debugLoad(false, path); + } finally { + activePaths.remove(path); + currentPath = previousPath; + } + } + } + + private static void loadFromUrl(URL url, LoadingMode mode) + throws IOException { + try (InputStream is = url.openStream()) { + reset(mode); + debugLoad(true, url); + props.load(is); + debugLoad(false, url); + } + } + + private static void debugLoad(boolean start, Object source) { + if (sdebug != null) { + int level = activePaths.isEmpty() ? 1 : activePaths.size(); + sdebug.println((start ? + ">".repeat(level) + " starting to process " : + "<".repeat(level) + " finished processing ") + source); + } + } + } + static { // doPrivileged here because there are multiple // things in initialize that might require privs. - // (the FileInputStream call and the File.exists call, - // the securityPropFile call, etc) + // (the FileInputStream call and the File.exists call, etc) @SuppressWarnings("removal") var dummy = AccessController.doPrivileged((PrivilegedAction) () -> { initialize(); @@ -94,28 +330,7 @@ public final class Security { } private static void initialize() { - props = new Properties(); - boolean overrideAll = false; - - // first load the system properties file - // to determine the value of security.overridePropertiesFile - File propFile = securityPropFile("java.security"); - boolean success = loadProps(propFile, null, false); - if (!success) { - throw new InternalError("Error loading java.security file"); - } - - if ("true".equalsIgnoreCase(props.getProperty - ("security.overridePropertiesFile"))) { - - String extraPropFile = System.getProperty - ("java.security.properties"); - if (extraPropFile != null && extraPropFile.startsWith("=")) { - overrideAll = true; - extraPropFile = extraPropFile.substring(1); - } - loadProps(null, extraPropFile, overrideAll); - } + SecPropLoader.loadAll(); initialSecurityProperties = (Properties) props.clone(); if (sdebug != null) { for (String key : props.stringPropertyNames()) { @@ -123,63 +338,6 @@ public final class Security { props.getProperty(key)); } } - - } - - private static boolean loadProps(File masterFile, String extraPropFile, boolean overrideAll) { - InputStream is = null; - try { - if (masterFile != null && masterFile.exists()) { - is = new FileInputStream(masterFile); - } else if (extraPropFile != null) { - extraPropFile = PropertyExpander.expand(extraPropFile); - File propFile = new File(extraPropFile); - URL propURL; - if (propFile.exists()) { - propURL = newURL - ("file:" + propFile.getCanonicalPath()); - } else { - propURL = newURL(extraPropFile); - } - - is = propURL.openStream(); - if (overrideAll) { - props = new Properties(); - if (sdebug != null) { - sdebug.println - ("overriding other security properties files!"); - } - } - } else { - // unexpected - return false; - } - props.load(is); - if (sdebug != null) { - // ExceptionInInitializerError if masterFile.getName() is - // called here (NPE!). Leave as is (and few lines down) - sdebug.println("reading security properties file: " + - masterFile == null ? extraPropFile : "java.security"); - } - return true; - } catch (IOException | PropertyExpander.ExpandException e) { - if (sdebug != null) { - sdebug.println("unable to load security properties from " + - masterFile == null ? extraPropFile : "java.security"); - e.printStackTrace(); - } - return false; - } finally { - if (is != null) { - try { - is.close(); - } catch (IOException ioe) { - if (sdebug != null) { - sdebug.println("unable to close input stream"); - } - } - } - } } /** @@ -188,14 +346,6 @@ public final class Security { private Security() { } - private static File securityPropFile(String filename) { - // maybe check for a system property which will specify where to - // look. Someday. - String sep = File.separator; - return new File(StaticProperty.javaHome() + sep + "conf" + sep + - "security" + sep + filename); - } - /** * Looks up providers, and returns the property (and its associated * provider) mapping the key, if any. @@ -714,17 +864,16 @@ public final class Security { * denies * access to retrieve the specified security property value * @throws NullPointerException if key is {@code null} + * @throws IllegalArgumentException if key is reserved and cannot be + * used as a Security property name. Reserved keys are: + * "include". * * @see #setProperty * @see java.security.SecurityPermission */ public static String getProperty(String key) { - @SuppressWarnings("removal") - SecurityManager sm = System.getSecurityManager(); - if (sm != null) { - sm.checkPermission(new SecurityPermission("getProperty."+ - key)); - } + SecPropLoader.checkReservedKey(key); + check("getProperty." + key); String name = props.getProperty(key); if (name != null) name = name.trim(); // could be a class name with trailing ws @@ -749,11 +898,15 @@ public final class Security { * java.lang.SecurityManager#checkPermission} method * denies access to set the specified security property value * @throws NullPointerException if key or datum is {@code null} + * @throws IllegalArgumentException if key is reserved and cannot be + * used as a Security property name. Reserved keys are: + * "include". * * @see #getProperty * @see java.security.SecurityPermission */ public static void setProperty(String key, String datum) { + SecPropLoader.checkReservedKey(key); check("setProperty." + key); props.put(key, datum); invalidateSMCache(key); /* See below. */ diff --git a/src/java.base/share/classes/java/time/format/TextStyle.java b/src/java.base/share/classes/java/time/format/TextStyle.java index ec49da271ad..2a1f8b896ca 100644 --- a/src/java.base/share/classes/java/time/format/TextStyle.java +++ b/src/java.base/share/classes/java/time/format/TextStyle.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -137,8 +137,7 @@ public enum TextStyle { } /** - * Returns the stand-alone style with the same size. - * @return the stand-alone style with the same size + * {@return the stand-alone style with the same size} */ public TextStyle asStandalone() { return TextStyle.values()[ordinal() | 1]; diff --git a/src/java.base/share/classes/java/util/ArrayDeque.java b/src/java.base/share/classes/java/util/ArrayDeque.java index 9997110b658..60bb3ed4a45 100644 --- a/src/java.base/share/classes/java/util/ArrayDeque.java +++ b/src/java.base/share/classes/java/util/ArrayDeque.java @@ -38,6 +38,7 @@ import java.io.Serializable; import java.util.function.Consumer; import java.util.function.Predicate; import jdk.internal.access.SharedSecrets; +import jdk.internal.util.ArraysSupport; /** * Resizable-array implementation of the {@link Deque} interface. Array @@ -124,12 +125,9 @@ public class ArrayDeque extends AbstractCollection transient int tail; /** - * The maximum size of array to allocate. - * Some VMs reserve some header words in an array. - * Attempts to allocate larger arrays may result in - * OutOfMemoryError: Requested array size exceeds VM limit + * The maximum size of array to allocate */ - private static final int MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8; + private static final int MAX_ARRAY_SIZE = ArraysSupport.SOFT_MAX_ARRAY_LENGTH; /** * Increases the capacity of this deque by at least the given amount. diff --git a/src/java.base/share/classes/java/util/ArrayList.java b/src/java.base/share/classes/java/util/ArrayList.java index 5fcf79e95c3..c00b130a553 100644 --- a/src/java.base/share/classes/java/util/ArrayList.java +++ b/src/java.base/share/classes/java/util/ArrayList.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1582,6 +1582,13 @@ public class ArrayList extends AbstractList } }; } + + @Override + public void sort(Comparator c) { + checkForComodification(); + root.sortRange(c, offset, offset + size); + updateSizeAndModCount(0); + } } /** @@ -1799,13 +1806,17 @@ public class ArrayList extends AbstractList } @Override - @SuppressWarnings("unchecked") public void sort(Comparator c) { + sortRange(c, 0, size); + modCount++; + } + + @SuppressWarnings("unchecked") + private void sortRange(Comparator c, int fromIndex, int toIndex) { final int expectedModCount = modCount; - Arrays.sort((E[]) elementData, 0, size, c); + Arrays.sort((E[]) elementData, fromIndex, toIndex, c); if (modCount != expectedModCount) throw new ConcurrentModificationException(); - modCount++; } void checkInvariants() { diff --git a/src/java.base/share/classes/java/util/BitSet.java b/src/java.base/share/classes/java/util/BitSet.java index fea9693d7ed..de4910b20c6 100644 --- a/src/java.base/share/classes/java/util/BitSet.java +++ b/src/java.base/share/classes/java/util/BitSet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1184,7 +1184,7 @@ public class BitSet implements Cloneable, java.io.Serializable { public String toString() { checkInvariants(); - final int MAX_INITIAL_CAPACITY = Integer.MAX_VALUE - 8; + final int MAX_INITIAL_CAPACITY = ArraysSupport.SOFT_MAX_ARRAY_LENGTH; int numBits = (wordsInUse > 128) ? cardinality() : wordsInUse * BITS_PER_WORD; // Avoid overflow in the case of a humongous numBits diff --git a/src/java.base/share/classes/java/util/Currency.java b/src/java.base/share/classes/java/util/Currency.java index 14d1cf4351d..b11b774e614 100644 --- a/src/java.base/share/classes/java/util/Currency.java +++ b/src/java.base/share/classes/java/util/Currency.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -108,7 +108,7 @@ import sun.util.logging.PlatformLogger; * with {@code Currency} or monetary values as it provides better handling of floating * point numbers and their operations. * - * @spec http://www.iso.org/iso/home/standards/currency_codes.htm ISO - ISO 4217 - Currency codes + * @spec https://www.iso.org/iso-4217-currency-codes.html ISO - ISO 4217 - Currency codes * @see java.math.BigDecimal * @since 1.4 */ diff --git a/src/java.base/share/classes/java/util/Hashtable.java b/src/java.base/share/classes/java/util/Hashtable.java index 1fd56d5a258..ddff8f7a0ab 100644 --- a/src/java.base/share/classes/java/util/Hashtable.java +++ b/src/java.base/share/classes/java/util/Hashtable.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1994, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1994, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,6 +30,7 @@ import java.util.function.BiConsumer; import java.util.function.Function; import java.util.function.BiFunction; import jdk.internal.access.SharedSecrets; +import jdk.internal.util.ArraysSupport; /** * This class implements a hash table, which maps keys to values. Any @@ -390,12 +391,9 @@ public class Hashtable } /** - * The maximum size of array to allocate. - * Some VMs reserve some header words in an array. - * Attempts to allocate larger arrays may result in - * OutOfMemoryError: Requested array size exceeds VM limit + * The maximum size of array to allocate */ - private static final int MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8; + private static final int MAX_ARRAY_SIZE = ArraysSupport.SOFT_MAX_ARRAY_LENGTH; /** * Increases the capacity of and internally reorganizes this diff --git a/src/java.base/share/classes/java/util/Locale.java b/src/java.base/share/classes/java/util/Locale.java index 73132b81c09..5550d399a7f 100644 --- a/src/java.base/share/classes/java/util/Locale.java +++ b/src/java.base/share/classes/java/util/Locale.java @@ -2324,12 +2324,11 @@ public final class Locale implements Cloneable, Serializable { // If we cannot get the message format pattern, then we use a simple // hard-coded pattern. This should not occur in practice unless the // installation is missing some core files (FormatData etc.). - StringBuilder result = new StringBuilder(); - result.append((String)displayNames[1]); - if (displayNames.length > 2) { - result.append(" ("); - result.append((String)displayNames[2]); - result.append(')'); + StringBuilder result = new StringBuilder((String) displayNames[1]); + if (displayNames[2] != null) { + result.append(" (") + .append((String) displayNames[2]) + .append(')'); } return result.toString(); } diff --git a/src/java.base/share/classes/java/util/SplittableRandom.java b/src/java.base/share/classes/java/util/SplittableRandom.java index cb1801f5680..686fe66da2f 100644 --- a/src/java.base/share/classes/java/util/SplittableRandom.java +++ b/src/java.base/share/classes/java/util/SplittableRandom.java @@ -47,7 +47,7 @@ import jdk.internal.util.random.RandomSupport.AbstractSplittableGenerator; *
        • Series of generated values pass the DieHarder suite testing * independence and uniformity properties of random number generators. * (Most recently validated with version + * href="https://webhome.phy.duke.edu/~rgb/General/dieharder.php"> version * 3.31.1.) These tests validate only the methods for certain * types and ranges, but similar properties are expected to hold, at * least approximately, for others as well. The period diff --git a/src/java.base/share/classes/java/util/concurrent/CompletableFuture.java b/src/java.base/share/classes/java/util/concurrent/CompletableFuture.java index 8adfd106eeb..d6904944050 100644 --- a/src/java.base/share/classes/java/util/concurrent/CompletableFuture.java +++ b/src/java.base/share/classes/java/util/concurrent/CompletableFuture.java @@ -35,6 +35,8 @@ package java.util.concurrent; +import jdk.internal.invoke.MhUtil; + import java.lang.invoke.MethodHandles; import java.lang.invoke.VarHandle; import java.util.concurrent.locks.LockSupport; @@ -3079,14 +3081,10 @@ public class CompletableFuture implements Future, CompletionStage { private static final VarHandle STACK; private static final VarHandle NEXT; static { - try { - MethodHandles.Lookup l = MethodHandles.lookup(); - RESULT = l.findVarHandle(CompletableFuture.class, "result", Object.class); - STACK = l.findVarHandle(CompletableFuture.class, "stack", Completion.class); - NEXT = l.findVarHandle(Completion.class, "next", Completion.class); - } catch (ReflectiveOperationException e) { - throw new ExceptionInInitializerError(e); - } + MethodHandles.Lookup l = MethodHandles.lookup(); + RESULT = MhUtil.findVarHandle(l, "result", Object.class); + STACK = MhUtil.findVarHandle(l, "stack", Completion.class); + NEXT = MhUtil.findVarHandle(l, Completion.class, "next", Completion.class); // Reduce the risk of rare disastrous classloading in first call to // LockSupport.park: https://bugs.openjdk.org/browse/JDK-8074773 diff --git a/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java b/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java index 4df4f73695f..5a23fdb05a6 100644 --- a/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java +++ b/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java @@ -69,6 +69,7 @@ import java.util.function.ToLongBiFunction; import java.util.function.ToLongFunction; import java.util.stream.Stream; import jdk.internal.misc.Unsafe; +import jdk.internal.util.ArraysSupport; /** * A hash table supporting full concurrency of retrievals and @@ -517,7 +518,7 @@ public class ConcurrentHashMap extends AbstractMap * The largest possible (non-power of two) array size. * Needed by toArray and related methods. */ - static final int MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8; + static final int MAX_ARRAY_SIZE = ArraysSupport.SOFT_MAX_ARRAY_LENGTH; /** * The default concurrency level for this table. Unused but diff --git a/src/java.base/share/classes/java/util/concurrent/Exchanger.java b/src/java.base/share/classes/java/util/concurrent/Exchanger.java index 8674ea9af39..75de69b3e52 100644 --- a/src/java.base/share/classes/java/util/concurrent/Exchanger.java +++ b/src/java.base/share/classes/java/util/concurrent/Exchanger.java @@ -36,6 +36,8 @@ package java.util.concurrent; +import jdk.internal.invoke.MhUtil; + import java.lang.invoke.MethodHandles; import java.lang.invoke.VarHandle; import java.util.concurrent.locks.LockSupport; @@ -530,15 +532,11 @@ public class Exchanger { private static final VarHandle ENTRY; private static final VarHandle AA; static { - try { - MethodHandles.Lookup l = MethodHandles.lookup(); - BOUND = l.findVarHandle(Exchanger.class, "bound", int.class); - MATCH = l.findVarHandle(Node.class, "match", Object.class); - ENTRY = l.findVarHandle(Slot.class, "entry", Node.class); - AA = MethodHandles.arrayElementVarHandle(Slot[].class); - } catch (ReflectiveOperationException e) { - throw new ExceptionInInitializerError(e); - } + MethodHandles.Lookup l = MethodHandles.lookup(); + BOUND = MhUtil.findVarHandle(l, "bound", int.class); + MATCH = MhUtil.findVarHandle(l, Node.class, "match", Object.class); + ENTRY = MhUtil.findVarHandle(l, Slot.class, "entry", Node.class); + AA = MethodHandles.arrayElementVarHandle(Slot[].class); } } diff --git a/src/java.base/share/classes/java/util/concurrent/FutureTask.java b/src/java.base/share/classes/java/util/concurrent/FutureTask.java index 627e69559c8..b905e71aeef 100644 --- a/src/java.base/share/classes/java/util/concurrent/FutureTask.java +++ b/src/java.base/share/classes/java/util/concurrent/FutureTask.java @@ -35,6 +35,8 @@ package java.util.concurrent; +import jdk.internal.invoke.MhUtil; + import java.lang.invoke.MethodHandles; import java.lang.invoke.VarHandle; import java.util.concurrent.locks.LockSupport; @@ -582,14 +584,10 @@ public class FutureTask implements RunnableFuture { private static final VarHandle RUNNER; private static final VarHandle WAITERS; static { - try { - MethodHandles.Lookup l = MethodHandles.lookup(); - STATE = l.findVarHandle(FutureTask.class, "state", int.class); - RUNNER = l.findVarHandle(FutureTask.class, "runner", Thread.class); - WAITERS = l.findVarHandle(FutureTask.class, "waiters", WaitNode.class); - } catch (ReflectiveOperationException e) { - throw new ExceptionInInitializerError(e); - } + MethodHandles.Lookup l = MethodHandles.lookup(); + STATE = MhUtil.findVarHandle(l, "state", int.class); + RUNNER = MhUtil.findVarHandle(l, "runner", Thread.class); + WAITERS = MhUtil.findVarHandle(l, "waiters", WaitNode.class); // Reduce the risk of rare disastrous classloading in first call to // LockSupport.park: https://bugs.openjdk.org/browse/JDK-8074773 diff --git a/src/java.base/share/classes/java/util/concurrent/Phaser.java b/src/java.base/share/classes/java/util/concurrent/Phaser.java index 22e2f663cb9..9cd2376d847 100644 --- a/src/java.base/share/classes/java/util/concurrent/Phaser.java +++ b/src/java.base/share/classes/java/util/concurrent/Phaser.java @@ -35,6 +35,8 @@ package java.util.concurrent; +import jdk.internal.invoke.MhUtil; + import java.lang.invoke.MethodHandles; import java.lang.invoke.VarHandle; import java.util.concurrent.atomic.AtomicReference; @@ -1137,15 +1139,9 @@ public class Phaser { } // VarHandle mechanics - private static final VarHandle STATE; + private static final VarHandle STATE = MhUtil.findVarHandle( + MethodHandles.lookup(), "state", long.class); static { - try { - MethodHandles.Lookup l = MethodHandles.lookup(); - STATE = l.findVarHandle(Phaser.class, "state", long.class); - } catch (ReflectiveOperationException e) { - throw new ExceptionInInitializerError(e); - } - // Reduce the risk of rare disastrous classloading in first call to // LockSupport.park: https://bugs.openjdk.org/browse/JDK-8074773 Class ensureLoaded = LockSupport.class; diff --git a/src/java.base/share/classes/java/util/concurrent/PriorityBlockingQueue.java b/src/java.base/share/classes/java/util/concurrent/PriorityBlockingQueue.java index fdb0128b7a7..f51e356736d 100644 --- a/src/java.base/share/classes/java/util/concurrent/PriorityBlockingQueue.java +++ b/src/java.base/share/classes/java/util/concurrent/PriorityBlockingQueue.java @@ -53,6 +53,7 @@ import java.util.concurrent.locks.ReentrantLock; import java.util.function.Consumer; import java.util.function.Predicate; import jdk.internal.access.SharedSecrets; +import jdk.internal.invoke.MhUtil; import jdk.internal.util.ArraysSupport; /** @@ -1093,15 +1094,8 @@ public class PriorityBlockingQueue extends AbstractQueue } // VarHandle mechanics - private static final VarHandle ALLOCATIONSPINLOCK; - static { - try { - MethodHandles.Lookup l = MethodHandles.lookup(); - ALLOCATIONSPINLOCK = l.findVarHandle(PriorityBlockingQueue.class, - "allocationSpinLock", - int.class); - } catch (ReflectiveOperationException e) { - throw new ExceptionInInitializerError(e); - } - } + private static final VarHandle ALLOCATIONSPINLOCK = + MhUtil.findVarHandle( + MethodHandles.lookup(), "allocationSpinLock", int.class); + } diff --git a/src/java.base/share/classes/java/util/concurrent/StructuredTaskScope.java b/src/java.base/share/classes/java/util/concurrent/StructuredTaskScope.java index 31b4cd6c6a6..edb2708934d 100644 --- a/src/java.base/share/classes/java/util/concurrent/StructuredTaskScope.java +++ b/src/java.base/share/classes/java/util/concurrent/StructuredTaskScope.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,6 +37,7 @@ import java.util.function.Function; import java.util.function.Supplier; import jdk.internal.javac.PreviewFeature; import jdk.internal.misc.ThreadFlock; +import jdk.internal.invoke.MhUtil; /** * A basic API for structured concurrency. {@code StructuredTaskScope} supports @@ -990,13 +991,9 @@ public class StructuredTaskScope implements AutoCloseable { private static final VarHandle FIRST_RESULT; private static final VarHandle FIRST_EXCEPTION; static { - try { - MethodHandles.Lookup l = MethodHandles.lookup(); - FIRST_RESULT = l.findVarHandle(ShutdownOnSuccess.class, "firstResult", Object.class); - FIRST_EXCEPTION = l.findVarHandle(ShutdownOnSuccess.class, "firstException", Throwable.class); - } catch (Exception e) { - throw new ExceptionInInitializerError(e); - } + MethodHandles.Lookup l = MethodHandles.lookup(); + FIRST_RESULT = MhUtil.findVarHandle(l, "firstResult", Object.class); + FIRST_EXCEPTION = MhUtil.findVarHandle(l, "firstException", Throwable.class); } private volatile Object firstResult; private volatile Throwable firstException; @@ -1177,15 +1174,8 @@ public class StructuredTaskScope implements AutoCloseable { */ @PreviewFeature(feature = PreviewFeature.Feature.STRUCTURED_CONCURRENCY) public static final class ShutdownOnFailure extends StructuredTaskScope { - private static final VarHandle FIRST_EXCEPTION; - static { - try { - MethodHandles.Lookup l = MethodHandles.lookup(); - FIRST_EXCEPTION = l.findVarHandle(ShutdownOnFailure.class, "firstException", Throwable.class); - } catch (Exception e) { - throw new ExceptionInInitializerError(e); - } - } + private static final VarHandle FIRST_EXCEPTION = + MhUtil.findVarHandle(MethodHandles.lookup(), "firstException", Throwable.class); private volatile Throwable firstException; /** diff --git a/src/java.base/share/classes/java/util/concurrent/SubmissionPublisher.java b/src/java.base/share/classes/java/util/concurrent/SubmissionPublisher.java index b27c57114d6..a2fc3ac92bd 100644 --- a/src/java.base/share/classes/java/util/concurrent/SubmissionPublisher.java +++ b/src/java.base/share/classes/java/util/concurrent/SubmissionPublisher.java @@ -35,6 +35,8 @@ package java.util.concurrent; +import jdk.internal.invoke.MhUtil; + import java.lang.invoke.MethodHandles; import java.lang.invoke.VarHandle; import java.util.ArrayList; @@ -1505,16 +1507,10 @@ public class SubmissionPublisher implements Publisher, static final VarHandle QA; static { - try { - MethodHandles.Lookup l = MethodHandles.lookup(); - CTL = l.findVarHandle(BufferedSubscription.class, "ctl", - int.class); - DEMAND = l.findVarHandle(BufferedSubscription.class, "demand", - long.class); - QA = MethodHandles.arrayElementVarHandle(Object[].class); - } catch (ReflectiveOperationException e) { - throw new ExceptionInInitializerError(e); - } + MethodHandles.Lookup l = MethodHandles.lookup(); + CTL = MhUtil.findVarHandle(l, "ctl", int.class); + DEMAND = MhUtil.findVarHandle(l, "demand", long.class); + QA = MethodHandles.arrayElementVarHandle(Object[].class); // Reduce the risk of rare disastrous classloading in first call to // LockSupport.park: https://bugs.openjdk.org/browse/JDK-8074773 diff --git a/src/java.base/share/classes/java/util/concurrent/SynchronousQueue.java b/src/java.base/share/classes/java/util/concurrent/SynchronousQueue.java index 6d6d9efad03..f5a2ce4d9b4 100644 --- a/src/java.base/share/classes/java/util/concurrent/SynchronousQueue.java +++ b/src/java.base/share/classes/java/util/concurrent/SynchronousQueue.java @@ -477,8 +477,7 @@ public class SynchronousQueue extends AbstractQueue } /** - * Returns a zero-length array. - * @return a zero-length array + * {@return a zero-length array} */ public Object[] toArray() { return new Object[0]; diff --git a/src/java.base/share/classes/java/util/concurrent/ThreadPerTaskExecutor.java b/src/java.base/share/classes/java/util/concurrent/ThreadPerTaskExecutor.java index ca9ce08db74..e98ece084c0 100644 --- a/src/java.base/share/classes/java/util/concurrent/ThreadPerTaskExecutor.java +++ b/src/java.base/share/classes/java/util/concurrent/ThreadPerTaskExecutor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,6 +38,7 @@ import java.util.stream.Stream; import static java.util.concurrent.TimeUnit.NANOSECONDS; import jdk.internal.access.JavaLangAccess; import jdk.internal.access.SharedSecrets; +import jdk.internal.invoke.MhUtil; import jdk.internal.vm.ThreadContainer; import jdk.internal.vm.ThreadContainers; @@ -48,15 +49,8 @@ import jdk.internal.vm.ThreadContainers; class ThreadPerTaskExecutor extends ThreadContainer implements ExecutorService { private static final JavaLangAccess JLA = SharedSecrets.getJavaLangAccess(); private static final Permission MODIFY_THREAD = new RuntimePermission("modifyThread"); - private static final VarHandle STATE; - static { - try { - MethodHandles.Lookup l = MethodHandles.lookup(); - STATE = l.findVarHandle(ThreadPerTaskExecutor.class, "state", int.class); - } catch (Exception e) { - throw new ExceptionInInitializerError(e); - } - } + private static final VarHandle STATE = MhUtil.findVarHandle( + MethodHandles.lookup(), "state", int.class); private final ThreadFactory factory; private final Set threads = ConcurrentHashMap.newKeySet(); @@ -506,14 +500,10 @@ class ThreadPerTaskExecutor extends ThreadContainer implements ExecutorService { private static final VarHandle EXCEPTION; private static final VarHandle EXCEPTION_COUNT; static { - try { - MethodHandles.Lookup l = MethodHandles.lookup(); - RESULT = l.findVarHandle(AnyResultHolder.class, "result", Object.class); - EXCEPTION = l.findVarHandle(AnyResultHolder.class, "exception", Throwable.class); - EXCEPTION_COUNT = l.findVarHandle(AnyResultHolder.class, "exceptionCount", int.class); - } catch (Exception e) { - throw new InternalError(e); - } + MethodHandles.Lookup l = MethodHandles.lookup(); + RESULT = MhUtil.findVarHandle(l, "result", Object.class); + EXCEPTION = MhUtil.findVarHandle(l, "exception", Throwable.class); + EXCEPTION_COUNT = MhUtil.findVarHandle(l, "exceptionCount", int.class); } private static final Object NULL = new Object(); diff --git a/src/java.base/share/classes/java/util/concurrent/atomic/AtomicBoolean.java b/src/java.base/share/classes/java/util/concurrent/atomic/AtomicBoolean.java index d8cb9869afe..fb171e9c1d9 100644 --- a/src/java.base/share/classes/java/util/concurrent/atomic/AtomicBoolean.java +++ b/src/java.base/share/classes/java/util/concurrent/atomic/AtomicBoolean.java @@ -35,6 +35,8 @@ package java.util.concurrent.atomic; +import jdk.internal.invoke.MhUtil; + import java.lang.invoke.MethodHandles; import java.lang.invoke.VarHandle; @@ -50,15 +52,8 @@ import java.lang.invoke.VarHandle; */ public class AtomicBoolean implements java.io.Serializable { private static final long serialVersionUID = 4654671469794556979L; - private static final VarHandle VALUE; - static { - try { - MethodHandles.Lookup l = MethodHandles.lookup(); - VALUE = l.findVarHandle(AtomicBoolean.class, "value", int.class); - } catch (ReflectiveOperationException e) { - throw new ExceptionInInitializerError(e); - } - } + private static final VarHandle VALUE = MhUtil.findVarHandle( + MethodHandles.lookup(), "value", int.class); private volatile int value; @@ -176,8 +171,7 @@ public class AtomicBoolean implements java.io.Serializable { } /** - * Returns the String representation of the current value. - * @return the String representation of the current value + * {@return the String representation of the current value} */ public String toString() { return Boolean.toString(get()); diff --git a/src/java.base/share/classes/java/util/concurrent/atomic/AtomicInteger.java b/src/java.base/share/classes/java/util/concurrent/atomic/AtomicInteger.java index 4f08ed3f64b..4ebd758ccc7 100644 --- a/src/java.base/share/classes/java/util/concurrent/atomic/AtomicInteger.java +++ b/src/java.base/share/classes/java/util/concurrent/atomic/AtomicInteger.java @@ -340,8 +340,7 @@ public class AtomicInteger extends Number implements java.io.Serializable { } /** - * Returns the String representation of the current value. - * @return the String representation of the current value + * {@return the String representation of the current value} */ public String toString() { return Integer.toString(get()); diff --git a/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerArray.java b/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerArray.java index 676788e4204..7e253ead335 100644 --- a/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerArray.java +++ b/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerArray.java @@ -366,8 +366,7 @@ public class AtomicIntegerArray implements java.io.Serializable { } /** - * Returns the String representation of the current values of array. - * @return the String representation of the current values of array + * {@return the String representation of the current values of array} */ public String toString() { int iMax = array.length - 1; diff --git a/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLong.java b/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLong.java index e446df8fd3e..d0e50b0fda8 100644 --- a/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLong.java +++ b/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLong.java @@ -341,8 +341,7 @@ public class AtomicLong extends Number implements java.io.Serializable { } /** - * Returns the String representation of the current value. - * @return the String representation of the current value + * {@return the String representation of the current value} */ public String toString() { return Long.toString(get()); diff --git a/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongArray.java b/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongArray.java index af2ff6729fd..2145c795799 100644 --- a/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongArray.java +++ b/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongArray.java @@ -366,8 +366,7 @@ public class AtomicLongArray implements java.io.Serializable { } /** - * Returns the String representation of the current values of array. - * @return the String representation of the current values of array + * {@return the String representation of the current values of array} */ public String toString() { int iMax = array.length - 1; diff --git a/src/java.base/share/classes/java/util/concurrent/atomic/AtomicMarkableReference.java b/src/java.base/share/classes/java/util/concurrent/atomic/AtomicMarkableReference.java index 8e1727c8f19..d74c3f2ef4f 100644 --- a/src/java.base/share/classes/java/util/concurrent/atomic/AtomicMarkableReference.java +++ b/src/java.base/share/classes/java/util/concurrent/atomic/AtomicMarkableReference.java @@ -35,6 +35,8 @@ package java.util.concurrent.atomic; +import jdk.internal.invoke.MhUtil; + import java.lang.invoke.MethodHandles; import java.lang.invoke.VarHandle; @@ -190,16 +192,8 @@ public class AtomicMarkableReference { } // VarHandle mechanics - private static final VarHandle PAIR; - static { - try { - MethodHandles.Lookup l = MethodHandles.lookup(); - PAIR = l.findVarHandle(AtomicMarkableReference.class, "pair", - Pair.class); - } catch (ReflectiveOperationException e) { - throw new ExceptionInInitializerError(e); - } - } + private static final VarHandle PAIR = MhUtil.findVarHandle( + MethodHandles.lookup(), "pair", Pair.class); private boolean casPair(Pair cmp, Pair val) { return PAIR.compareAndSet(this, cmp, val); diff --git a/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReference.java b/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReference.java index b2c692df5e7..e512c91f2df 100644 --- a/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReference.java +++ b/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReference.java @@ -35,6 +35,8 @@ package java.util.concurrent.atomic; +import jdk.internal.invoke.MhUtil; + import java.lang.invoke.MethodHandles; import java.lang.invoke.VarHandle; import java.util.function.BinaryOperator; @@ -50,15 +52,8 @@ import java.util.function.UnaryOperator; */ public class AtomicReference implements java.io.Serializable { private static final long serialVersionUID = -1848883965231344442L; - private static final VarHandle VALUE; - static { - try { - MethodHandles.Lookup l = MethodHandles.lookup(); - VALUE = l.findVarHandle(AtomicReference.class, "value", Object.class); - } catch (ReflectiveOperationException e) { - throw new ExceptionInInitializerError(e); - } - } + private static final VarHandle VALUE = MhUtil.findVarHandle( + MethodHandles.lookup(), "value", Object.class); @SuppressWarnings("serial") // Conditionally serializable private volatile V value; @@ -269,8 +264,7 @@ public class AtomicReference implements java.io.Serializable { } /** - * Returns the String representation of the current value. - * @return the String representation of the current value + * {@return the String representation of the current value} */ public String toString() { return String.valueOf(get()); diff --git a/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceArray.java b/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceArray.java index f85fb9376ad..e8238320e21 100644 --- a/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceArray.java +++ b/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceArray.java @@ -297,8 +297,7 @@ public class AtomicReferenceArray implements java.io.Serializable { } /** - * Returns the String representation of the current values of array. - * @return the String representation of the current values of array + * {@return the String representation of the current values of array} */ public String toString() { int iMax = array.length - 1; diff --git a/src/java.base/share/classes/java/util/concurrent/atomic/AtomicStampedReference.java b/src/java.base/share/classes/java/util/concurrent/atomic/AtomicStampedReference.java index b4152c50855..bac164b874a 100644 --- a/src/java.base/share/classes/java/util/concurrent/atomic/AtomicStampedReference.java +++ b/src/java.base/share/classes/java/util/concurrent/atomic/AtomicStampedReference.java @@ -35,6 +35,8 @@ package java.util.concurrent.atomic; +import jdk.internal.invoke.MhUtil; + import java.lang.invoke.MethodHandles; import java.lang.invoke.VarHandle; @@ -190,16 +192,8 @@ public class AtomicStampedReference { } // VarHandle mechanics - private static final VarHandle PAIR; - static { - try { - MethodHandles.Lookup l = MethodHandles.lookup(); - PAIR = l.findVarHandle(AtomicStampedReference.class, "pair", - Pair.class); - } catch (ReflectiveOperationException e) { - throw new ExceptionInInitializerError(e); - } - } + private static final VarHandle PAIR = MhUtil.findVarHandle( + MethodHandles.lookup(), "pair", Pair.class); private boolean casPair(Pair cmp, Pair val) { return PAIR.compareAndSet(this, cmp, val); diff --git a/src/java.base/share/classes/java/util/concurrent/atomic/DoubleAccumulator.java b/src/java.base/share/classes/java/util/concurrent/atomic/DoubleAccumulator.java index d04b8253ee7..eb837a0fd29 100644 --- a/src/java.base/share/classes/java/util/concurrent/atomic/DoubleAccumulator.java +++ b/src/java.base/share/classes/java/util/concurrent/atomic/DoubleAccumulator.java @@ -189,8 +189,7 @@ public class DoubleAccumulator extends Striped64 implements Serializable { } /** - * Returns the String representation of the current value. - * @return the String representation of the current value + * {@return the String representation of the current value} */ public String toString() { return Double.toString(get()); diff --git a/src/java.base/share/classes/java/util/concurrent/atomic/LongAccumulator.java b/src/java.base/share/classes/java/util/concurrent/atomic/LongAccumulator.java index be96853ce09..0d48a686cf2 100644 --- a/src/java.base/share/classes/java/util/concurrent/atomic/LongAccumulator.java +++ b/src/java.base/share/classes/java/util/concurrent/atomic/LongAccumulator.java @@ -183,8 +183,7 @@ public class LongAccumulator extends Striped64 implements Serializable { } /** - * Returns the String representation of the current value. - * @return the String representation of the current value + * {@return the String representation of the current value} */ public String toString() { return Long.toString(get()); diff --git a/src/java.base/share/classes/java/util/concurrent/atomic/Striped64.java b/src/java.base/share/classes/java/util/concurrent/atomic/Striped64.java index 61a9f4d79e9..04ae2b45158 100644 --- a/src/java.base/share/classes/java/util/concurrent/atomic/Striped64.java +++ b/src/java.base/share/classes/java/util/concurrent/atomic/Striped64.java @@ -35,6 +35,8 @@ package java.util.concurrent.atomic; +import jdk.internal.invoke.MhUtil; + import java.lang.invoke.MethodHandles; import java.lang.invoke.VarHandle; import java.util.Arrays; @@ -138,15 +140,8 @@ abstract class Striped64 extends Number { } // VarHandle mechanics - private static final VarHandle VALUE; - static { - try { - MethodHandles.Lookup l = MethodHandles.lookup(); - VALUE = l.findVarHandle(Cell.class, "value", long.class); - } catch (ReflectiveOperationException e) { - throw new ExceptionInInitializerError(e); - } - } + private static final VarHandle VALUE = MhUtil.findVarHandle( + MethodHandles.lookup(), "value", long.class); } /** Number of CPUS, to place bound on table size */ @@ -381,14 +376,12 @@ abstract class Striped64 extends Number { private static final VarHandle CELLSBUSY; private static final VarHandle THREAD_PROBE; static { - try { - MethodHandles.Lookup l1 = MethodHandles.lookup(); - BASE = l1.findVarHandle(Striped64.class, - "base", long.class); - CELLSBUSY = l1.findVarHandle(Striped64.class, - "cellsBusy", int.class); + MethodHandles.Lookup l1 = MethodHandles.lookup(); + + BASE = MhUtil.findVarHandle(l1, "base", long.class); + CELLSBUSY = MhUtil.findVarHandle(l1, "cellsBusy", int.class); @SuppressWarnings("removal") - MethodHandles.Lookup l2 = java.security.AccessController.doPrivileged( + MethodHandles.Lookup l2 = java.security.AccessController.doPrivileged( new java.security.PrivilegedAction<>() { public MethodHandles.Lookup run() { try { @@ -397,11 +390,7 @@ abstract class Striped64 extends Number { throw new ExceptionInInitializerError(e); } }}); - THREAD_PROBE = l2.findVarHandle(Thread.class, - "threadLocalRandomProbe", int.class); - } catch (ReflectiveOperationException e) { - throw new ExceptionInInitializerError(e); - } + THREAD_PROBE = MhUtil.findVarHandle(l2, "threadLocalRandomProbe", int.class); } } diff --git a/src/java.base/share/classes/java/util/jar/JarFile.java b/src/java.base/share/classes/java/util/jar/JarFile.java index 77dfed3b84f..3dc3a49dc77 100644 --- a/src/java.base/share/classes/java/util/jar/JarFile.java +++ b/src/java.base/share/classes/java/util/jar/JarFile.java @@ -90,7 +90,7 @@ import java.util.zip.ZipFile; *

          If the {@code verify} flag is on when opening a signed jar file, the content * of the jar entry is verified against the signature embedded inside the manifest * that is associated with its {@link JarEntry#getRealName() path name}. For a - * multi-release jar file, the content of a versioned entry is verfieid against + * multi-release jar file, the content of a versioned entry is verified against * its own signature and {@link JarEntry#getCodeSigners()} returns its own signers. * * Please note that the verification process does not include validating the diff --git a/src/java.base/share/classes/java/util/jar/Manifest.java b/src/java.base/share/classes/java/util/jar/Manifest.java index c0e30707a35..d5845033293 100644 --- a/src/java.base/share/classes/java/util/jar/Manifest.java +++ b/src/java.base/share/classes/java/util/jar/Manifest.java @@ -119,8 +119,7 @@ public class Manifest implements Cloneable { } /** - * Returns the main Attributes for the Manifest. - * @return the main Attributes for the Manifest + * {@return the main Attributes for the Manifest} */ public Attributes getMainAttributes() { return attr; diff --git a/src/java.base/share/classes/java/util/regex/Pattern.java b/src/java.base/share/classes/java/util/regex/Pattern.java index 0e87bebdcbf..654adb5376f 100644 --- a/src/java.base/share/classes/java/util/regex/Pattern.java +++ b/src/java.base/share/classes/java/util/regex/Pattern.java @@ -1502,8 +1502,8 @@ public final class Pattern return "\\Q" + s + "\\E"; int lenHint = s.length(); - lenHint = (lenHint < Integer.MAX_VALUE - 8 - lenHint) ? - (lenHint << 1) : (Integer.MAX_VALUE - 8); + lenHint = (lenHint < ArraysSupport.SOFT_MAX_ARRAY_LENGTH - lenHint) ? + (lenHint << 1) : ArraysSupport.SOFT_MAX_ARRAY_LENGTH; StringBuilder sb = new StringBuilder(lenHint); sb.append("\\Q"); diff --git a/src/java.base/share/classes/java/util/stream/ForEachOps.java b/src/java.base/share/classes/java/util/stream/ForEachOps.java index 0c6b8aa665a..1ba59709152 100644 --- a/src/java.base/share/classes/java/util/stream/ForEachOps.java +++ b/src/java.base/share/classes/java/util/stream/ForEachOps.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,8 @@ */ package java.util.stream; +import jdk.internal.invoke.MhUtil; + import java.util.Objects; import java.util.Spliterator; import java.util.concurrent.CountedCompleter; @@ -370,15 +372,8 @@ final class ForEachOps { private Node node; private ForEachOrderedTask next; - private static final VarHandle NEXT; - static { - try { - MethodHandles.Lookup l = MethodHandles.lookup(); - NEXT = l.findVarHandle(ForEachOrderedTask.class, "next", ForEachOrderedTask.class); - } catch (Exception e) { - throw new InternalError(e); - } - } + private static final VarHandle NEXT = MhUtil.findVarHandle( + MethodHandles.lookup(), "next", ForEachOrderedTask.class); protected ForEachOrderedTask(PipelineHelper helper, Spliterator spliterator, diff --git a/src/java.base/share/classes/java/util/stream/GathererOp.java b/src/java.base/share/classes/java/util/stream/GathererOp.java index 8a7073f63ef..37f01901201 100644 --- a/src/java.base/share/classes/java/util/stream/GathererOp.java +++ b/src/java.base/share/classes/java/util/stream/GathererOp.java @@ -24,6 +24,7 @@ */ package java.util.stream; +import jdk.internal.invoke.MhUtil; import jdk.internal.vm.annotation.ForceInline; import java.lang.invoke.MethodHandles; @@ -453,16 +454,8 @@ final class GathererOp extends ReferencePipeline { private Spliterator spliterator; private Hybrid next; - private static final VarHandle NEXT; - - static { - try { - MethodHandles.Lookup l = MethodHandles.lookup(); - NEXT = l.findVarHandle(Hybrid.class, "next", Hybrid.class); - } catch (Exception e) { - throw new InternalError(e); - } - } + private static final VarHandle NEXT = MhUtil.findVarHandle( + MethodHandles.lookup(), "next", Hybrid.class); protected Hybrid(Spliterator spliterator) { super(null); diff --git a/src/java.base/share/classes/java/util/stream/Nodes.java b/src/java.base/share/classes/java/util/stream/Nodes.java index 7c06823b925..77d70091717 100644 --- a/src/java.base/share/classes/java/util/stream/Nodes.java +++ b/src/java.base/share/classes/java/util/stream/Nodes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,8 @@ */ package java.util.stream; +import jdk.internal.util.ArraysSupport; + import java.util.ArrayDeque; import java.util.Arrays; import java.util.Collection; @@ -57,7 +59,7 @@ final class Nodes { /** * The maximum size of an array that can be allocated. */ - static final long MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8; + static final long MAX_ARRAY_SIZE = ArraysSupport.SOFT_MAX_ARRAY_LENGTH; // IllegalArgumentException messages static final String BAD_SIZE = "Stream size exceeds max array size"; diff --git a/src/java.base/share/classes/java/util/zip/Deflater.java b/src/java.base/share/classes/java/util/zip/Deflater.java index 56d0978dbc0..a23f8395c21 100644 --- a/src/java.base/share/classes/java/util/zip/Deflater.java +++ b/src/java.base/share/classes/java/util/zip/Deflater.java @@ -782,8 +782,7 @@ public class Deflater { } /** - * Returns the ADLER-32 value of the uncompressed data. - * @return the ADLER-32 value of the uncompressed data + * {@return the ADLER-32 value of the uncompressed data} */ public int getAdler() { synchronized (zsRef) { diff --git a/src/java.base/share/classes/java/util/zip/Inflater.java b/src/java.base/share/classes/java/util/zip/Inflater.java index 22ab21d88c0..109208bd9ad 100644 --- a/src/java.base/share/classes/java/util/zip/Inflater.java +++ b/src/java.base/share/classes/java/util/zip/Inflater.java @@ -282,8 +282,7 @@ public class Inflater { } /** - * Returns true if a preset dictionary is needed for decompression. - * @return true if a preset dictionary is needed for decompression + * {@return true if a preset dictionary is needed for decompression} * @see Inflater#setDictionary */ public boolean needsDictionary() { @@ -293,10 +292,8 @@ public class Inflater { } /** - * Returns true if the end of the compressed data stream has been - * reached. - * @return true if the end of the compressed data stream has been - * reached + * {@return true if the end of the compressed data stream has been + * reached} */ public boolean finished() { synchronized (zsRef) { @@ -602,8 +599,7 @@ public class Inflater { } /** - * Returns the ADLER-32 value of the uncompressed data. - * @return the ADLER-32 value of the uncompressed data + * {@return the ADLER-32 value of the uncompressed data} */ public int getAdler() { synchronized (zsRef) { diff --git a/src/java.base/share/classes/java/util/zip/ZipCoder.java b/src/java.base/share/classes/java/util/zip/ZipCoder.java index 25c6e3a2e4a..8d4a05389ee 100644 --- a/src/java.base/share/classes/java/util/zip/ZipCoder.java +++ b/src/java.base/share/classes/java/util/zip/ZipCoder.java @@ -56,28 +56,27 @@ class ZipCoder { } /** - * This enum represents the three possible return values for + * Constants representing the three possible return values for * {@link #compare(String, byte[], int, int, boolean)} when * this method compares a lookup name to a string encoded in the * CEN byte array. */ - enum Comparison { - /** + static final byte + /* * The lookup string is exactly equal * to the encoded string. - */ - EXACT_MATCH, - /** + */ + EXACT_MATCH = 0, + /* * The lookup string and the encoded string differs only * by the encoded string having a trailing '/' character. */ - DIRECTORY_MATCH, - /** + DIRECTORY_MATCH = 1, + /* * The lookup string and the encoded string do not match. * (They are neither an exact match or a directory match.) */ - NO_MATCH - } + NO_MATCH = 2; String toString(byte[] ba, int off, int length) { try { @@ -158,13 +157,6 @@ class ZipCoder { return hsh; } - boolean hasTrailingSlash(byte[] a, int end) { - byte[] slashBytes = slashBytes(); - return end >= slashBytes.length && - Arrays.mismatch(a, end - slashBytes.length, end, slashBytes, 0, slashBytes.length) == -1; - } - - private byte[] slashBytes; private final Charset cs; protected CharsetDecoder dec; private CharsetEncoder enc; @@ -191,23 +183,6 @@ class ZipCoder { return enc; } - // This method produces an array with the bytes that will correspond to a - // trailing '/' in the chosen character encoding. - // - // While in most charsets a trailing slash will be encoded as the byte - // value of '/', this does not hold in the general case. E.g., in charsets - // such as UTF-16 and UTF-32 it will be represented by a sequence of 2 or 4 - // bytes, respectively. - private byte[] slashBytes() { - if (slashBytes == null) { - // Take into account charsets that produce a BOM, e.g., UTF-16 - byte[] slash = "/".getBytes(cs); - byte[] doubleSlash = "//".getBytes(cs); - slashBytes = Arrays.copyOfRange(doubleSlash, slash.length, doubleSlash.length); - } - return slashBytes; - } - /** * This method is used by ZipFile.Source.getEntryPos when comparing the * name being looked up to candidate names encoded in the CEN byte @@ -221,13 +196,13 @@ class ZipCoder { * The return values of this method are as follows: * * If the lookup name is exactly equal to the encoded string, return - * {@link Comparison#EXACT_MATCH}. + * {@link EXACT_MATCH}. * * If the parameter {@code matchDirectory} is {@code true} and the * two strings differ only by the encoded string having an extra - * trailing '/' character, then return {@link Comparison#DIRECTORY_MATCH}. + * trailing '/' character, then return {@link DIRECTORY_MATCH}. * - * Otherwise, return {@link Comparison#NO_MATCH} + * Otherwise, return {@link NO_MATCH} * * While a general implementation will need to decode bytes into a * String for comparison, this can be avoided if the String coder @@ -241,18 +216,18 @@ class ZipCoder { * a directory match will also be tested * */ - Comparison compare(String str, byte[] b, int off, int len, boolean matchDirectory) { + byte compare(String str, byte[] b, int off, int len, boolean matchDirectory) { String decoded = toString(b, off, len); if (decoded.startsWith(str)) { if (decoded.length() == str.length()) { - return Comparison.EXACT_MATCH; + return EXACT_MATCH; } else if (matchDirectory && decoded.length() == str.length() + 1 && decoded.endsWith("/") ) { - return Comparison.DIRECTORY_MATCH; + return DIRECTORY_MATCH; } } - return Comparison.NO_MATCH; + return NO_MATCH; } static final class UTF8ZipCoder extends ZipCoder { @@ -297,25 +272,24 @@ class ZipCoder { return h; } - @Override - boolean hasTrailingSlash(byte[] a, int end) { + private boolean hasTrailingSlash(byte[] a, int end) { return end > 0 && a[end - 1] == '/'; } @Override - Comparison compare(String str, byte[] b, int off, int len, boolean matchDirectory) { + byte compare(String str, byte[] b, int off, int len, boolean matchDirectory) { try { byte[] encoded = JLA.getBytesNoRepl(str, UTF_8.INSTANCE); int mismatch = Arrays.mismatch(encoded, 0, encoded.length, b, off, off+len); if (mismatch == -1) { - return Comparison.EXACT_MATCH; + return EXACT_MATCH; } else if (matchDirectory && len == mismatch + 1 && hasTrailingSlash(b, off + len)) { - return Comparison.DIRECTORY_MATCH; + return DIRECTORY_MATCH; } else { - return Comparison.NO_MATCH; + return NO_MATCH; } } catch (CharacterCodingException e) { - return Comparison.NO_MATCH; + return NO_MATCH; } } } diff --git a/src/java.base/share/classes/java/util/zip/ZipEntry.java b/src/java.base/share/classes/java/util/zip/ZipEntry.java index d97760d950a..b7ecd1bea8f 100644 --- a/src/java.base/share/classes/java/util/zip/ZipEntry.java +++ b/src/java.base/share/classes/java/util/zip/ZipEntry.java @@ -78,7 +78,7 @@ public class ZipEntry implements ZipConstants, Cloneable { /** * Approximately 128 years, in milliseconds (ignoring leap years etc). * - * This establish an approximate high-bound value for DOS times in + * This establishes an approximate high-bound value for DOS times in * milliseconds since epoch, used to enable an efficient but * sufficient bounds check to avoid generating extended last modified * time entries. @@ -138,8 +138,7 @@ public class ZipEntry implements ZipConstants, Cloneable { } /** - * Returns the name of the entry. - * @return the name of the entry + * {@return the name of the entry} */ public String getName() { return name; @@ -565,20 +564,20 @@ public class ZipEntry implements ZipConstants, Cloneable { // be the magic value and it "accidentally" has some // bytes in extra match the id. if (sz >= 16) { - size = get64(extra, off); - csize = get64(extra, off + 8); + size = get64S(extra, off); + csize = get64S(extra, off + 8); } } else { // CEN extra zip64 if (size == ZIP64_MAGICVAL) { if (off + 8 > len) // invalid zip64 extra break; // fields, just skip - size = get64(extra, off); + size = get64S(extra, off); } if (csize == ZIP64_MAGICVAL) { if (off + 16 > len) // invalid zip64 extra break; // fields, just skip - csize = get64(extra, off + 8); + csize = get64S(extra, off + 8); } } } @@ -589,15 +588,15 @@ public class ZipEntry implements ZipConstants, Cloneable { int pos = off + 4; // reserved 4 bytes if (get16(extra, pos) != 0x0001 || get16(extra, pos + 2) != 24) break; - long wtime = get64(extra, pos + 4); + long wtime = get64S(extra, pos + 4); if (wtime != WINDOWS_TIME_NOT_AVAILABLE) { mtime = winTimeToFileTime(wtime); } - wtime = get64(extra, pos + 12); + wtime = get64S(extra, pos + 12); if (wtime != WINDOWS_TIME_NOT_AVAILABLE) { atime = winTimeToFileTime(wtime); } - wtime = get64(extra, pos + 20); + wtime = get64S(extra, pos + 20); if (wtime != WINDOWS_TIME_NOT_AVAILABLE) { ctime = winTimeToFileTime(wtime); } diff --git a/src/java.base/share/classes/java/util/zip/ZipError.java b/src/java.base/share/classes/java/util/zip/ZipError.java index 2aa37bef010..933cc447091 100644 --- a/src/java.base/share/classes/java/util/zip/ZipError.java +++ b/src/java.base/share/classes/java/util/zip/ZipError.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,9 +28,12 @@ package java.util.zip; /** * Signals that an unrecoverable error has occurred. * + * @deprecated ZipError is no longer used and is obsolete. + * {@link ZipException} should be used instead. * @author Dave Bristor * @since 1.6 */ +@Deprecated(since="24", forRemoval = true) public class ZipError extends InternalError { @java.io.Serial private static final long serialVersionUID = 853973422266861979L; diff --git a/src/java.base/share/classes/java/util/zip/ZipFile.java b/src/java.base/share/classes/java/util/zip/ZipFile.java index 6ab70d4bdb8..21b9593c017 100644 --- a/src/java.base/share/classes/java/util/zip/ZipFile.java +++ b/src/java.base/share/classes/java/util/zip/ZipFile.java @@ -63,6 +63,7 @@ import java.util.stream.StreamSupport; import jdk.internal.access.JavaUtilZipFileAccess; import jdk.internal.access.JavaUtilJarAccess; import jdk.internal.access.SharedSecrets; +import jdk.internal.util.ArraysSupport; import jdk.internal.util.OperatingSystem; import jdk.internal.perf.PerfCounter; import jdk.internal.ref.CleanerFactory; @@ -347,9 +348,12 @@ public class ZipFile implements ZipConstants, Closeable { ZipEntry entry = null; synchronized (this) { ensureOpen(); - int pos = res.zsrc.getEntryPos(name, true); - if (pos != -1) { - entry = getZipEntry(name, pos); + // Look up the name and CEN header position of the entry. + // The resolved name may include a trailing slash. + // See Source::getEntryPos for details. + EntryPos pos = res.zsrc.getEntryPos(name, true); + if (pos != null) { + entry = getZipEntry(pos.name, pos.pos); } } return entry; @@ -387,7 +391,12 @@ public class ZipFile implements ZipConstants, Closeable { if (Objects.equals(lastEntryName, entry.name)) { pos = lastEntryPos; } else { - pos = zsrc.getEntryPos(entry.name, false); + EntryPos entryPos = zsrc.getEntryPos(entry.name, false); + if (entryPos != null) { + pos = entryPos.pos; + } else { + pos = -1; + } } if (pos == -1) { return null; @@ -402,13 +411,10 @@ public class ZipFile implements ZipConstants, Closeable { case DEFLATED: // Inflater likes a bit of slack // MORE: Compute good size for inflater stream: - long size = CENLEN(zsrc.cen, pos) + 2; + long size = CENSIZ(zsrc.cen, pos); if (size > 65536) { size = 8192; } - if (size <= 0) { - size = 4096; - } InputStream is = new ZipFileInflaterInputStream(in, res, (int) size); synchronized (istreams) { istreams.add(is); @@ -490,8 +496,7 @@ public class ZipFile implements ZipConstants, Closeable { } /** - * Returns the path name of the ZIP file. - * @return the path name of the ZIP file + * {@return the path name of the ZIP file} */ public String getName() { return filePath; @@ -540,7 +545,8 @@ public class ZipFile implements ZipConstants, Closeable { throw new NoSuchElementException(); } // each "entry" has 3 ints in table entries - return (T)getZipEntry(null, res.zsrc.getEntryPos(i++ * 3)); + int pos = res.zsrc.getEntryPos(i++ * 3); + return (T)getZipEntry(getEntryName(pos), pos); } } @@ -551,8 +557,7 @@ public class ZipFile implements ZipConstants, Closeable { } /** - * Returns an enumeration of the ZIP file entries. - * @return an enumeration of the ZIP file entries + * {@return an enumeration of the ZIP file entries} * @throws IllegalStateException if the ZIP file has been closed */ public Enumeration entries() { @@ -612,7 +617,7 @@ public class ZipFile implements ZipConstants, Closeable { synchronized (this) { ensureOpen(); return StreamSupport.stream(new EntrySpliterator<>(0, res.zsrc.total, - pos -> getZipEntry(null, pos)), false); + pos -> getZipEntry(getEntryName(pos), pos)), false); } } @@ -655,7 +660,7 @@ public class ZipFile implements ZipConstants, Closeable { synchronized (this) { ensureOpen(); return StreamSupport.stream(new EntrySpliterator<>(0, res.zsrc.total, - pos -> (JarEntry)getZipEntry(null, pos)), false); + pos -> (JarEntry)getZipEntry(getEntryName(pos), pos)), false); } } @@ -665,30 +670,10 @@ public class ZipFile implements ZipConstants, Closeable { /* Check ensureOpen() before invoking this method */ private ZipEntry getZipEntry(String name, int pos) { byte[] cen = res.zsrc.cen; - int nlen = CENNAM(cen, pos); - int elen = CENEXT(cen, pos); - int clen = CENCOM(cen, pos); + ZipEntry e = this instanceof JarFile jarFile + ? Source.JUJA.entryFor(jarFile, name) + : new ZipEntry(name); - ZipCoder zc = res.zsrc.zipCoderForPos(pos); - if (name != null) { - // only need to check for mismatch of trailing slash - if (nlen > 0 && - !name.isEmpty() && - zc.hasTrailingSlash(cen, pos + CENHDR + nlen) && - !name.endsWith("/")) - { - name += '/'; - } - } else { - // invoked from iterator, use the entry name stored in cen - name = zc.toString(cen, pos + CENHDR, nlen); - } - ZipEntry e; - if (this instanceof JarFile) { - e = Source.JUJA.entryFor((JarFile)this, name); - } else { - e = new ZipEntry(name); - } e.flag = CENFLG(cen, pos); e.xdostime = CENTIM(cen, pos); e.crc = CENCRC(cen, pos); @@ -700,12 +685,17 @@ public class ZipFile implements ZipConstants, Closeable { e.externalFileAttributes = CENATX_PERMS(cen, pos) & 0xFFFF; } + int nlen = CENNAM(cen, pos); + int elen = CENEXT(cen, pos); + int clen = CENCOM(cen, pos); + if (elen != 0) { int start = pos + CENHDR + nlen; e.setExtra0(Arrays.copyOfRange(cen, start, start + elen), true, false); } if (clen != 0) { int start = pos + CENHDR + nlen + elen; + ZipCoder zc = res.zsrc.zipCoderForPos(pos); e.comment = zc.toString(cen, start, clen); } lastEntryName = e.name; @@ -913,21 +903,21 @@ public class ZipFile implements ZipConstants, Closeable { if (size == ZIP64_MAGICVAL) { if (sz < 8 || (off + 8) > end) break; - size = get64(cen, off); + size = get64S(cen, off); sz -= 8; off += 8; } if (rem == ZIP64_MAGICVAL) { if (sz < 8 || (off + 8) > end) break; - rem = get64(cen, off); + rem = get64S(cen, off); sz -= 8; off += 8; } if (pos == ZIP64_MAGICVAL) { if (sz < 8 || (off + 8) > end) break; - pos = get64(cen, off); + pos = get64S(cen, off); sz -= 8; off += 8; } @@ -1176,6 +1166,8 @@ public class ZipFile implements ZipConstants, Closeable { } ); } + // Represents the resolved name and position of a CEN record + static record EntryPos(String name, int pos) {} private static class Source { // While this is only used from ZipFile, defining it there would cause @@ -1184,6 +1176,8 @@ public class ZipFile implements ZipConstants, Closeable { // "META-INF/".length() private static final int META_INF_LEN = 9; private static final int[] EMPTY_META_VERSIONS = new int[0]; + // CEN size is limited to the maximum array size in the JDK + private static final int MAX_CEN_SIZE = ArraysSupport.SOFT_MAX_ARRAY_LENGTH; private final Key key; // the key in files private final @Stable ZipCoder zc; // ZIP coder used to decode/encode @@ -1191,7 +1185,7 @@ public class ZipFile implements ZipConstants, Closeable { private int refs = 1; private RandomAccessFile zfile; // zfile of the underlying ZIP file - private byte[] cen; // CEN & ENDHDR + private byte[] cen; // CEN private long locpos; // position of first LOC header (usually 0) private byte[] comment; // ZIP file comment // list of meta entries in META-INF dir @@ -1242,12 +1236,12 @@ public class ZipFile implements ZipConstants, Closeable { int nlen = CENNAM(cen, pos); int elen = CENEXT(cen, pos); int clen = CENCOM(cen, pos); - long headerSize = (long)CENHDR + nlen + clen + elen; + int headerSize = CENHDR + nlen + clen + elen; // CEN header size + name length + comment length + extra length // should not exceed 65,535 bytes per the PKWare APP.NOTE // 4.4.10, 4.4.11, & 4.4.12. Also check that current CEN header will // not exceed the length of the CEN array - if (headerSize > 0xFFFF || pos + headerSize > cen.length - ENDHDR) { + if (headerSize > 0xFFFF || pos > cen.length - headerSize) { zerror("invalid CEN header (bad header size)"); } @@ -1300,7 +1294,7 @@ public class ZipFile implements ZipConstants, Closeable { } // CEN Offset where this Extra field ends int extraEndOffset = startingOffset + extraFieldLen; - if (extraEndOffset > cen.length - ENDHDR) { + if (extraEndOffset > cen.length) { zerror("Invalid CEN header (extra data field size too long)"); } int currentOffset = startingOffset; @@ -1379,7 +1373,7 @@ public class ZipFile implements ZipConstants, Closeable { // Check the uncompressed size is not negative if (size == ZIP64_MAGICVAL) { if ( blockSize >= Long.BYTES) { - if (get64(cen, off) < 0) { + if (get64S(cen, off) < 0) { zerror("Invalid zip64 extra block size value"); } off += Long.BYTES; @@ -1391,7 +1385,7 @@ public class ZipFile implements ZipConstants, Closeable { // Check the compressed size is not negative if (csize == ZIP64_MAGICVAL) { if (blockSize >= Long.BYTES) { - if (get64(cen, off) < 0) { + if (get64S(cen, off) < 0) { zerror("Invalid zip64 extra block compressed size value"); } off += Long.BYTES; @@ -1403,7 +1397,7 @@ public class ZipFile implements ZipConstants, Closeable { // Check the LOC offset is not negative if (locoff == ZIP64_MAGICVAL) { if (blockSize >= Long.BYTES) { - if (get64(cen, off) < 0) { + if (get64S(cen, off) < 0) { zerror("Invalid zip64 extra block LOC OFFSET value"); } // Note: We do not need to adjust the following fields as @@ -1611,7 +1605,7 @@ public class ZipFile implements ZipConstants, Closeable { private static class End { - int centot; // 4 bytes + long centot; // 4 bytes long cenlen; // 4 bytes long cenoff; // 4 bytes long endpos; // 4 bytes @@ -1644,10 +1638,7 @@ public class ZipFile implements ZipConstants, Closeable { } // Now scan the block backwards for END header signature for (int i = buf.length - ENDHDR; i >= 0; i--) { - if (buf[i+0] == (byte)'P' && - buf[i+1] == (byte)'K' && - buf[i+2] == (byte)'\005' && - buf[i+3] == (byte)'\006') { + if (get32(buf, i) == ENDSIG) { // Found ENDSIG header byte[] endbuf = Arrays.copyOfRange(buf, i, i + ENDHDR); end.centot = ENDTOT(endbuf); @@ -1667,9 +1658,9 @@ public class ZipFile implements ZipConstants, Closeable { if (cenpos < 0 || locpos < 0 || readFullyAt(sbuf, 0, sbuf.length, cenpos) != 4 || - GETSIG(sbuf) != CENSIG || + get32(sbuf, 0) != CENSIG || readFullyAt(sbuf, 0, sbuf.length, locpos) != 4 || - GETSIG(sbuf) != LOCSIG) { + get32(sbuf, 0) != LOCSIG) { continue; } } @@ -1684,13 +1675,13 @@ public class ZipFile implements ZipConstants, Closeable { byte[] loc64 = new byte[ZIP64_LOCHDR]; if (end.endpos < ZIP64_LOCHDR || readFullyAt(loc64, 0, loc64.length, end.endpos - ZIP64_LOCHDR) - != loc64.length || GETSIG(loc64) != ZIP64_LOCSIG) { + != loc64.length || get32(loc64, 0) != ZIP64_LOCSIG) { return end; } long end64pos = ZIP64_LOCOFF(loc64); byte[] end64buf = new byte[ZIP64_ENDHDR]; if (readFullyAt(end64buf, 0, end64buf.length, end64pos) - != end64buf.length || GETSIG(end64buf) != ZIP64_ENDSIG) { + != end64buf.length || get32(end64buf, 0) != ZIP64_ENDSIG) { return end; } // end64 candidate found, @@ -1706,7 +1697,7 @@ public class ZipFile implements ZipConstants, Closeable { // to use the end64 values end.cenlen = cenlen64; end.cenoff = cenoff64; - end.centot = (int)centot64; // assume total < 2g + end.centot = centot64; end.endpos = end64pos; } catch (IOException x) {} // no ZIP64 loc/end return end; @@ -1738,15 +1729,18 @@ public class ZipFile implements ZipConstants, Closeable { if (locpos < 0) { zerror("invalid END header (bad central directory offset)"); } - // read in the CEN and END - if (end.cenlen + ENDHDR >= Integer.MAX_VALUE) { + // read in the CEN + if (end.cenlen > MAX_CEN_SIZE) { zerror("invalid END header (central directory size too large)"); } - cen = this.cen = new byte[(int)(end.cenlen + ENDHDR)]; - if (readFullyAt(cen, 0, cen.length, cenpos) != end.cenlen + ENDHDR) { + if (end.centot < 0 || end.centot > end.cenlen / CENHDR) { + zerror("invalid END header (total entries count too large)"); + } + cen = this.cen = new byte[(int)end.cenlen]; + if (readFullyAt(cen, 0, cen.length, cenpos) != end.cenlen) { zerror("read CEN tables failed"); } - this.total = end.centot; + this.total = Math.toIntExact(end.centot); } else { cen = this.cen; this.total = knownTotal; @@ -1771,18 +1765,18 @@ public class ZipFile implements ZipConstants, Closeable { // Iterate through the entries in the central directory int idx = 0; // Index into the entries array int pos = 0; - int entryPos = CENHDR; - int limit = cen.length - ENDHDR; manifestNum = 0; - while (entryPos <= limit) { + int limit = cen.length - CENHDR; + while (pos <= limit) { if (idx >= entriesLength) { // This will only happen if the ZIP file has an incorrect // ENDTOT field, which usually means it contains more than // 65535 entries. - initCEN(countCENHeaders(cen, limit)); + initCEN(countCENHeaders(cen)); return; } + int entryPos = pos + CENHDR; // Checks the entry and adds values to entries[idx ... idx+2] int nlen = checkAndAddEntry(pos, idx); idx += 3; @@ -1813,7 +1807,6 @@ public class ZipFile implements ZipConstants, Closeable { } // skip to the start of the next entry pos = nextEntryPos(pos, entryPos, nlen); - entryPos = pos + CENHDR; } // Adjust the total entries @@ -1835,7 +1828,7 @@ public class ZipFile implements ZipConstants, Closeable { } else { metaVersions = EMPTY_META_VERSIONS; } - if (pos + ENDHDR != cen.length) { + if (pos != cen.length) { zerror("invalid CEN header (bad header size)"); } } @@ -1849,12 +1842,12 @@ public class ZipFile implements ZipConstants, Closeable { } /* - * Returns the {@code pos} of the ZIP cen entry corresponding to the - * specified entry name, or -1 if not found. + * Returns the resolved name and position of the ZIP cen entry corresponding + * to the specified entry name, or {@code null} if not found. */ - private int getEntryPos(String name, boolean addSlash) { + private EntryPos getEntryPos(String name, boolean addSlash) { if (total == 0) { - return -1; + return null; } int hsh = ZipCoder.hash(name); @@ -1875,15 +1868,15 @@ public class ZipFile implements ZipConstants, Closeable { // Compare the lookup name with the name encoded in the CEN switch (zc.compare(name, cen, noff, nlen, addSlash)) { - case EXACT_MATCH: + case ZipCoder.EXACT_MATCH: // We found an exact match for "name" - return pos; - case DIRECTORY_MATCH: + return new EntryPos(name, pos); + case ZipCoder.DIRECTORY_MATCH: // We found the directory "name/" // Track its position, then continue the search for "name" dirPos = pos; break; - case NO_MATCH: + case ZipCoder.NO_MATCH: // Hash collision, continue searching } } @@ -1892,10 +1885,10 @@ public class ZipFile implements ZipConstants, Closeable { // Reaching this point means we did not find "name". // Return the position of "name/" if we found it if (dirPos != -1) { - return dirPos; + return new EntryPos(name + "/", dirPos); } // No entry found - return -1; + return null; } private ZipCoder zipCoderForPos(int pos) { @@ -2037,17 +2030,20 @@ public class ZipFile implements ZipConstants, Closeable { /** * Returns the number of CEN headers in a central directory. - * Will not throw, even if the ZIP file is corrupt. * * @param cen copy of the bytes in a ZIP file's central directory - * @param size number of bytes in central directory + * @throws ZipException if a CEN header exceeds the length of the CEN array */ - private static int countCENHeaders(byte[] cen, int size) { + private static int countCENHeaders(byte[] cen) throws ZipException { int count = 0; - for (int p = 0; - p + CENHDR <= size; - p += CENHDR + CENNAM(cen, p) + CENEXT(cen, p) + CENCOM(cen, p)) + for (int p = 0; p <= cen.length - CENHDR;) { + int headerSize = CENHDR + CENNAM(cen, p) + CENEXT(cen, p) + CENCOM(cen, p); + if (p > cen.length - headerSize) { + zerror("invalid CEN header (bad header size)"); + } + p += headerSize; count++; + } return count; } } diff --git a/src/java.base/share/classes/java/util/zip/ZipInputStream.java b/src/java.base/share/classes/java/util/zip/ZipInputStream.java index 5302cf75160..3a433cf5c6d 100644 --- a/src/java.base/share/classes/java/util/zip/ZipInputStream.java +++ b/src/java.base/share/classes/java/util/zip/ZipInputStream.java @@ -603,14 +603,14 @@ public class ZipInputStream extends InflaterInputStream implements ZipConstants long sig = get32(tmpbuf, 0); if (sig != EXTSIG) { // no EXTSIG present e.crc = sig; - e.csize = get64(tmpbuf, ZIP64_EXTSIZ - ZIP64_EXTCRC); - e.size = get64(tmpbuf, ZIP64_EXTLEN - ZIP64_EXTCRC); + e.csize = get64S(tmpbuf, ZIP64_EXTSIZ - ZIP64_EXTCRC); + e.size = get64S(tmpbuf, ZIP64_EXTLEN - ZIP64_EXTCRC); ((PushbackInputStream)in).unread( tmpbuf, ZIP64_EXTHDR - ZIP64_EXTCRC, ZIP64_EXTCRC); } else { e.crc = get32(tmpbuf, ZIP64_EXTCRC); - e.csize = get64(tmpbuf, ZIP64_EXTSIZ); - e.size = get64(tmpbuf, ZIP64_EXTLEN); + e.csize = get64S(tmpbuf, ZIP64_EXTSIZ); + e.size = get64S(tmpbuf, ZIP64_EXTLEN); } } else { readFully(tmpbuf, 0, EXTHDR); diff --git a/src/java.base/share/classes/java/util/zip/ZipOutputStream.java b/src/java.base/share/classes/java/util/zip/ZipOutputStream.java index f68c27b265e..f9712731a08 100644 --- a/src/java.base/share/classes/java/util/zip/ZipOutputStream.java +++ b/src/java.base/share/classes/java/util/zip/ZipOutputStream.java @@ -378,6 +378,10 @@ public class ZipOutputStream extends DeflaterOutputStream implements ZipConstant * Finishes writing the contents of the ZIP output stream without closing * the underlying stream. Use this method when applying multiple filters * in succession to the same output stream. + *

          + * A ZipException will be thrown if the combined length, after encoding, + * of the entry name, the extra field data, the entry comment and + * {@linkplain #CENHDR CEN Header size}, exceeds 65,535 bytes. * @throws ZipException if a ZIP file error has occurred * @throws IOException if an I/O exception has occurred */ @@ -398,7 +402,9 @@ public class ZipOutputStream extends DeflaterOutputStream implements ZipConstant } /** - * Closes the ZIP output stream as well as the stream being filtered. + * Closes the underlying stream and the stream being filtered after + * the contents of the ZIP output stream are fully written. + * * @throws ZipException if a ZIP file error has occurred * @throws IOException if an I/O error has occurred */ @@ -589,7 +595,8 @@ public class ZipOutputStream extends DeflaterOutputStream implements ZipConstant writeInt(csize); // compressed size writeInt(size); // uncompressed size byte[] nameBytes = zc.getBytes(e.name); - writeShort(nameBytes.length); + int nlen = nameBytes.length; + writeShort(nlen); int elen = getExtraLen(e.extra); if (hasZip64) { @@ -626,20 +633,19 @@ public class ZipOutputStream extends DeflaterOutputStream implements ZipConstant } } writeShort(elen); - byte[] commentBytes; + byte[] commentBytes = null; + int clen = 0; if (e.comment != null) { commentBytes = zc.getBytes(e.comment); - writeShort(Math.min(commentBytes.length, 0xffff)); - } else { - commentBytes = null; - writeShort(0); + clen = Math.min(commentBytes.length, 0xffff); } + writeShort(clen); // file comment length writeShort(0); // starting disk number writeShort(0); // internal file attributes (unused) // extra file attributes, used for storing posix permissions etc. writeInt(e.externalFileAttributes > 0 ? e.externalFileAttributes << 16 : 0); writeInt(offset); // relative offset of local header - writeBytes(nameBytes, 0, nameBytes.length); + writeBytes(nameBytes, 0, nlen); // take care of EXTID_ZIP64 and EXTID_EXTT if (hasZip64) { @@ -679,9 +685,17 @@ public class ZipOutputStream extends DeflaterOutputStream implements ZipConstant } } } + + // CEN header size + name length + comment length + extra length + // should not exceed 65,535 bytes per the PKWare APP.NOTE + // 4.4.10, 4.4.11, & 4.4.12. + long headerSize = (long)CENHDR + nlen + clen + elen; + if (headerSize > 0xFFFF ) { + throw new ZipException("invalid CEN header (bad header size)"); + } writeExtra(e.extra); if (commentBytes != null) { - writeBytes(commentBytes, 0, Math.min(commentBytes.length, 0xffff)); + writeBytes(commentBytes, 0, clen); } } diff --git a/src/java.base/share/classes/java/util/zip/ZipUtils.java b/src/java.base/share/classes/java/util/zip/ZipUtils.java index ab37fc03a56..5b1d896f420 100644 --- a/src/java.base/share/classes/java/util/zip/ZipUtils.java +++ b/src/java.base/share/classes/java/util/zip/ZipUtils.java @@ -39,6 +39,7 @@ import static java.util.zip.ZipConstants.ENDHDR; import jdk.internal.access.JavaNioAccess; import jdk.internal.access.SharedSecrets; import jdk.internal.misc.Unsafe; +import jdk.internal.util.Preconditions; class ZipUtils { @@ -170,7 +171,10 @@ class ZipUtils { * The bytes are assumed to be in Intel (little-endian) byte order. */ public static final int get16(byte[] b, int off) { - return (b[off] & 0xff) | ((b[off + 1] & 0xff) << 8); + Preconditions.checkIndex(off, b.length, Preconditions.AIOOBE_FORMATTER); + Preconditions.checkIndex(off + 1, b.length, Preconditions.AIOOBE_FORMATTER); + return Short.toUnsignedInt( + UNSAFE.getShortUnaligned(b, off + Unsafe.ARRAY_BYTE_BASE_OFFSET, false)); } /** @@ -178,15 +182,20 @@ class ZipUtils { * The bytes are assumed to be in Intel (little-endian) byte order. */ public static final long get32(byte[] b, int off) { - return (get16(b, off) | ((long)get16(b, off+2) << 16)) & 0xffffffffL; + Preconditions.checkIndex(off, b.length, Preconditions.AIOOBE_FORMATTER); + Preconditions.checkIndex(off + 3, b.length, Preconditions.AIOOBE_FORMATTER); + return Integer.toUnsignedLong( + UNSAFE.getIntUnaligned(b, off + Unsafe.ARRAY_BYTE_BASE_OFFSET, false)); } /** * Fetches signed 64-bit value from byte array at specified offset. * The bytes are assumed to be in Intel (little-endian) byte order. */ - public static final long get64(byte[] b, int off) { - return get32(b, off) | (get32(b, off+4) << 32); + public static final long get64S(byte[] b, int off) { + Preconditions.checkIndex(off, b.length, Preconditions.AIOOBE_FORMATTER); + Preconditions.checkIndex(off + 7, b.length, Preconditions.AIOOBE_FORMATTER); + return UNSAFE.getLongUnaligned(b, off + Unsafe.ARRAY_BYTE_BASE_OFFSET, false); } /** @@ -195,28 +204,9 @@ class ZipUtils { * */ public static final int get32S(byte[] b, int off) { - return (get16(b, off) | (get16(b, off+2) << 16)); - } - - // fields access methods - static final int CH(byte[] b, int n) { - return b[n] & 0xff ; - } - - static final int SH(byte[] b, int n) { - return (b[n] & 0xff) | ((b[n + 1] & 0xff) << 8); - } - - static final long LG(byte[] b, int n) { - return ((SH(b, n)) | (SH(b, n + 2) << 16)) & 0xffffffffL; - } - - static final long LL(byte[] b, int n) { - return (LG(b, n)) | (LG(b, n + 4) << 32); - } - - static final long GETSIG(byte[] b) { - return LG(b, 0); + Preconditions.checkIndex(off, b.length, Preconditions.AIOOBE_FORMATTER); + Preconditions.checkIndex(off + 3, b.length, Preconditions.AIOOBE_FORMATTER); + return UNSAFE.getIntUnaligned(b, off + Unsafe.ARRAY_BYTE_BASE_OFFSET, false); } /* @@ -231,56 +221,56 @@ class ZipUtils { // local file (LOC) header fields - static final long LOCSIG(byte[] b) { return LG(b, 0); } // signature - static final int LOCVER(byte[] b) { return SH(b, 4); } // version needed to extract - static final int LOCFLG(byte[] b) { return SH(b, 6); } // general purpose bit flags - static final int LOCHOW(byte[] b) { return SH(b, 8); } // compression method - static final long LOCTIM(byte[] b) { return LG(b, 10);} // modification time - static final long LOCCRC(byte[] b) { return LG(b, 14);} // crc of uncompressed data - static final long LOCSIZ(byte[] b) { return LG(b, 18);} // compressed data size - static final long LOCLEN(byte[] b) { return LG(b, 22);} // uncompressed data size - static final int LOCNAM(byte[] b) { return SH(b, 26);} // filename length - static final int LOCEXT(byte[] b) { return SH(b, 28);} // extra field length + static final long LOCSIG(byte[] b) { return get32(b, 0); } // signature + static final int LOCVER(byte[] b) { return get16(b, 4); } // version needed to extract + static final int LOCFLG(byte[] b) { return get16(b, 6); } // general purpose bit flags + static final int LOCHOW(byte[] b) { return get16(b, 8); } // compression method + static final long LOCTIM(byte[] b) { return get32(b, 10);} // modification time + static final long LOCCRC(byte[] b) { return get32(b, 14);} // crc of uncompressed data + static final long LOCSIZ(byte[] b) { return get32(b, 18);} // compressed data size + static final long LOCLEN(byte[] b) { return get32(b, 22);} // uncompressed data size + static final int LOCNAM(byte[] b) { return get16(b, 26);} // filename length + static final int LOCEXT(byte[] b) { return get16(b, 28);} // extra field length // extra local (EXT) header fields - static final long EXTCRC(byte[] b) { return LG(b, 4);} // crc of uncompressed data - static final long EXTSIZ(byte[] b) { return LG(b, 8);} // compressed size - static final long EXTLEN(byte[] b) { return LG(b, 12);} // uncompressed size + static final long EXTCRC(byte[] b) { return get32(b, 4);} // crc of uncompressed data + static final long EXTSIZ(byte[] b) { return get32(b, 8);} // compressed size + static final long EXTLEN(byte[] b) { return get32(b, 12);} // uncompressed size // end of central directory header (END) fields - static final int ENDSUB(byte[] b) { return SH(b, 8); } // number of entries on this disk - static final int ENDTOT(byte[] b) { return SH(b, 10);} // total number of entries - static final long ENDSIZ(byte[] b) { return LG(b, 12);} // central directory size - static final long ENDOFF(byte[] b) { return LG(b, 16);} // central directory offset - static final int ENDCOM(byte[] b) { return SH(b, 20);} // size of ZIP file comment - static final int ENDCOM(byte[] b, int off) { return SH(b, off + 20);} + static final int ENDSUB(byte[] b) { return get16(b, 8); } // number of entries on this disk + static final int ENDTOT(byte[] b) { return get16(b, 10);} // total number of entries + static final long ENDSIZ(byte[] b) { return get32(b, 12);} // central directory size + static final long ENDOFF(byte[] b) { return get32(b, 16);} // central directory offset + static final int ENDCOM(byte[] b) { return get16(b, 20);} // size of ZIP file comment + static final int ENDCOM(byte[] b, int off) { return get16(b, off + 20);} - // zip64 end of central directory recoder fields - static final long ZIP64_ENDTOD(byte[] b) { return LL(b, 24);} // total number of entries on disk - static final long ZIP64_ENDTOT(byte[] b) { return LL(b, 32);} // total number of entries - static final long ZIP64_ENDSIZ(byte[] b) { return LL(b, 40);} // central directory size - static final long ZIP64_ENDOFF(byte[] b) { return LL(b, 48);} // central directory offset - static final long ZIP64_LOCOFF(byte[] b) { return LL(b, 8);} // zip64 end offset + // zip64 end of central directory record fields + static final long ZIP64_ENDTOD(byte[] b) { return get64S(b, 24);} // total number of entries on disk + static final long ZIP64_ENDTOT(byte[] b) { return get64S(b, 32);} // total number of entries + static final long ZIP64_ENDSIZ(byte[] b) { return get64S(b, 40);} // central directory size + static final long ZIP64_ENDOFF(byte[] b) { return get64S(b, 48);} // central directory offset + static final long ZIP64_LOCOFF(byte[] b) { return get64S(b, 8);} // zip64 end offset // central directory header (CEN) fields - static final long CENSIG(byte[] b, int pos) { return LG(b, pos + 0); } - static final int CENVEM(byte[] b, int pos) { return SH(b, pos + 4); } - static final int CENVEM_FA(byte[] b, int pos) { return CH(b, pos + 5); } // file attribute compatibility - static final int CENVER(byte[] b, int pos) { return SH(b, pos + 6); } - static final int CENFLG(byte[] b, int pos) { return SH(b, pos + 8); } - static final int CENHOW(byte[] b, int pos) { return SH(b, pos + 10);} - static final long CENTIM(byte[] b, int pos) { return LG(b, pos + 12);} - static final long CENCRC(byte[] b, int pos) { return LG(b, pos + 16);} - static final long CENSIZ(byte[] b, int pos) { return LG(b, pos + 20);} - static final long CENLEN(byte[] b, int pos) { return LG(b, pos + 24);} - static final int CENNAM(byte[] b, int pos) { return SH(b, pos + 28);} - static final int CENEXT(byte[] b, int pos) { return SH(b, pos + 30);} - static final int CENCOM(byte[] b, int pos) { return SH(b, pos + 32);} - static final int CENDSK(byte[] b, int pos) { return SH(b, pos + 34);} - static final int CENATT(byte[] b, int pos) { return SH(b, pos + 36);} - static final long CENATX(byte[] b, int pos) { return LG(b, pos + 38);} - static final int CENATX_PERMS(byte[] b, int pos) { return SH(b, pos + 40);} // posix permission data - static final long CENOFF(byte[] b, int pos) { return LG(b, pos + 42);} + static final long CENSIG(byte[] b, int pos) { return get32(b, pos + 0); } + static final int CENVEM(byte[] b, int pos) { return get16(b, pos + 4); } + static final int CENVEM_FA(byte[] b, int pos) { return Byte.toUnsignedInt(b[pos + 5]); } // file attribute compatibility + static final int CENVER(byte[] b, int pos) { return get16(b, pos + 6); } + static final int CENFLG(byte[] b, int pos) { return get16(b, pos + 8); } + static final int CENHOW(byte[] b, int pos) { return get16(b, pos + 10);} + static final long CENTIM(byte[] b, int pos) { return get32(b, pos + 12);} + static final long CENCRC(byte[] b, int pos) { return get32(b, pos + 16);} + static final long CENSIZ(byte[] b, int pos) { return get32(b, pos + 20);} + static final long CENLEN(byte[] b, int pos) { return get32(b, pos + 24);} + static final int CENNAM(byte[] b, int pos) { return get16(b, pos + 28);} + static final int CENEXT(byte[] b, int pos) { return get16(b, pos + 30);} + static final int CENCOM(byte[] b, int pos) { return get16(b, pos + 32);} + static final int CENDSK(byte[] b, int pos) { return get16(b, pos + 34);} + static final int CENATT(byte[] b, int pos) { return get16(b, pos + 36);} + static final long CENATX(byte[] b, int pos) { return get32(b, pos + 38);} + static final int CENATX_PERMS(byte[] b, int pos) { return get16(b, pos + 40);} // posix permission data + static final long CENOFF(byte[] b, int pos) { return get32(b, pos + 42);} // The END header is followed by a variable length comment of size < 64k. static final long END_MAXLEN = 0xFFFF + ENDHDR; @@ -293,16 +283,16 @@ class ZipUtils { jdk.internal.loader.BootLoader.loadLibrary("zip"); } - private static final Unsafe unsafe = Unsafe.getUnsafe(); + private static final Unsafe UNSAFE = Unsafe.getUnsafe(); - private static final long byteBufferArrayOffset = unsafe.objectFieldOffset(ByteBuffer.class, "hb"); - private static final long byteBufferOffsetOffset = unsafe.objectFieldOffset(ByteBuffer.class, "offset"); + private static final long byteBufferArrayOffset = UNSAFE.objectFieldOffset(ByteBuffer.class, "hb"); + private static final long byteBufferOffsetOffset = UNSAFE.objectFieldOffset(ByteBuffer.class, "offset"); static byte[] getBufferArray(ByteBuffer byteBuffer) { - return (byte[]) unsafe.getReference(byteBuffer, byteBufferArrayOffset); + return (byte[]) UNSAFE.getReference(byteBuffer, byteBufferArrayOffset); } static int getBufferOffset(ByteBuffer byteBuffer) { - return unsafe.getInt(byteBuffer, byteBufferOffsetOffset); + return UNSAFE.getInt(byteBuffer, byteBufferOffsetOffset); } } diff --git a/src/java.base/share/classes/javax/crypto/CryptoPermission.java b/src/java.base/share/classes/javax/crypto/CryptoPermission.java index f13eec7a1d9..46b5b5fdef6 100644 --- a/src/java.base/share/classes/javax/crypto/CryptoPermission.java +++ b/src/java.base/share/classes/javax/crypto/CryptoPermission.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,7 @@ import javax.crypto.spec.*; * The {@code CryptoPermission} class extends the * {@code java.security.Permission} class. A * {@code CryptoPermission} object is used to represent - * the ability of an application/applet to use certain + * the ability of an application to use certain * algorithms with certain key sizes and other * restrictions in certain environments. * diff --git a/src/java.base/share/classes/javax/crypto/ExemptionMechanism.java b/src/java.base/share/classes/javax/crypto/ExemptionMechanism.java index c08187d88a6..d360b3577a0 100644 --- a/src/java.base/share/classes/javax/crypto/ExemptionMechanism.java +++ b/src/java.base/share/classes/javax/crypto/ExemptionMechanism.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -43,7 +43,7 @@ import sun.security.jca.GetInstance.Instance; * of which are key recovery, key weakening, and * key escrow. * - *

          Applications or applets that use an exemption mechanism may be granted + *

          Applications that use an exemption mechanism may be granted * stronger encryption capabilities than those which don't. * * @since 1.4 diff --git a/src/java.base/share/classes/javax/crypto/JceSecurityManager.java b/src/java.base/share/classes/javax/crypto/JceSecurityManager.java index e9c408a2a56..b178c8bfb02 100644 --- a/src/java.base/share/classes/javax/crypto/JceSecurityManager.java +++ b/src/java.base/share/classes/javax/crypto/JceSecurityManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,9 +36,9 @@ import java.lang.StackWalker.*; * The JCE security manager. * *

          The JCE security manager is responsible for determining the maximum - * allowable cryptographic strength for a given applet/application, for a given + * allowable cryptographic strength for a given application, for a given * algorithm, by consulting the configured jurisdiction policy files and - * the cryptographic permissions bundled with the applet/application. + * the cryptographic permissions bundled with the application. * * @author Jan Luehe * @@ -85,7 +85,7 @@ final class JceSecurityManager { /** * Returns the maximum allowable crypto strength for the given - * applet/application, for the given algorithm. + * application, for the given algorithm. */ CryptoPermission getCryptoPermission(String theAlg) { diff --git a/src/java.base/share/classes/javax/net/SocketFactory.java b/src/java.base/share/classes/javax/net/SocketFactory.java index dd351e92758..9ef82caf3f9 100644 --- a/src/java.base/share/classes/javax/net/SocketFactory.java +++ b/src/java.base/share/classes/javax/net/SocketFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -60,7 +60,7 @@ import java.net.UnknownHostException; * *

          Factory classes are specified by environment-specific configuration * mechanisms. For example, the getDefault method could return - * a factory that was appropriate for a particular user or applet, and a + * a factory that was appropriate for a particular application, and a * framework could use a factory customized to its own purposes. * * @since 1.4 diff --git a/src/java.base/share/classes/jdk/internal/access/JavaLangAccess.java b/src/java.base/share/classes/jdk/internal/access/JavaLangAccess.java index 2a89386f742..0436cbb314f 100644 --- a/src/java.base/share/classes/jdk/internal/access/JavaLangAccess.java +++ b/src/java.base/share/classes/jdk/internal/access/JavaLangAccess.java @@ -29,6 +29,7 @@ import java.io.InputStream; import java.io.PrintStream; import java.lang.annotation.Annotation; import java.lang.foreign.MemorySegment; +import java.lang.foreign.SymbolLookup; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodType; import java.lang.module.ModuleDescriptor; @@ -43,9 +44,11 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.Executor; import java.util.concurrent.RejectedExecutionException; import java.util.stream.Stream; +import jdk.internal.loader.NativeLibraries; import jdk.internal.misc.CarrierThreadLocal; import jdk.internal.module.ServicesCatalog; import jdk.internal.reflect.ConstantPool; @@ -318,6 +321,11 @@ public interface JavaLangAccess { */ int countPositives(byte[] ba, int off, int len); + /** + * Count the number of leading non-zero ascii chars in the String. + */ + int countNonZeroAscii(String s); + /** * Constructs a new {@code String} by decoding the specified subarray of * bytes using the specified {@linkplain java.nio.charset.Charset charset}. @@ -452,11 +460,26 @@ public interface JavaLangAccess { Object stringConcat1(String[] constants); + /** + * Get the string initial coder, When COMPACT_STRINGS is on, it returns 0, and when it is off, it returns 1. + */ + byte stringInitCoder(); + + /** + * Get the Coder of String, which is used by StringConcatFactory to calculate the initCoder of constants + */ + byte stringCoder(String str); + /** * Join strings */ String join(String prefix, String suffix, String delimiter, String[] elements, int size); + /** + * Concatenation of prefix and suffix characters to a String for early bootstrap + */ + String concat(String prefix, Object value, String suffix); + /* * Get the class data associated with the given class. * @param c the class @@ -468,7 +491,11 @@ public interface JavaLangAccess { int getCharsUTF16(long i, int index, byte[] buf); - long findNative(ClassLoader loader, String entry); + /** + * Returns the {@link NativeLibraries} object associated with the provided class loader. + * This is used by {@link SymbolLookup#loaderLookup()}. + */ + NativeLibraries nativeLibrariesFor(ClassLoader loader); /** * Direct access to Shutdown.exit to avoid security manager checks @@ -580,6 +607,11 @@ public interface JavaLangAccess { */ void unparkVirtualThread(Thread thread); + /** + * Returns the virtual thread default scheduler. + */ + Executor virtualThreadDefaultScheduler(); + /** * Creates a new StackWalker */ diff --git a/src/java.base/share/classes/jdk/internal/access/JavaNioAccess.java b/src/java.base/share/classes/jdk/internal/access/JavaNioAccess.java index b34a0d42085..a5d7c843998 100644 --- a/src/java.base/share/classes/jdk/internal/access/JavaNioAccess.java +++ b/src/java.base/share/classes/jdk/internal/access/JavaNioAccess.java @@ -25,6 +25,7 @@ package jdk.internal.access; +import jdk.internal.access.foreign.MappedMemoryUtilsProxy; import jdk.internal.access.foreign.UnmapperProxy; import jdk.internal.misc.VM.BufferPool; @@ -107,25 +108,10 @@ public interface JavaNioAccess { boolean hasSession(Buffer buffer); - /** - * Used by {@code jdk.internal.foreign.MappedMemorySegmentImpl} and byte buffer var handle views. - */ - void force(FileDescriptor fd, long address, boolean isSync, long offset, long size); - - /** - * Used by {@code jdk.internal.foreign.MappedMemorySegmentImpl} and byte buffer var handle views. - */ - void load(long address, boolean isSync, long size); - /** * Used by {@code jdk.internal.foreign.MappedMemorySegmentImpl}. */ - void unload(long address, boolean isSync, long size); - - /** - * Used by {@code jdk.internal.foreign.MappedMemorySegmentImpl} and byte buffer var handle views. - */ - boolean isLoaded(long address, boolean isSync, long size); + MappedMemoryUtilsProxy mappedMemoryUtils(); /** * Used by {@code jdk.internal.foreign.NativeMemorySegmentImpl}. diff --git a/src/java.base/share/classes/sun/security/provider/SHAKE256.java b/src/java.base/share/classes/jdk/internal/access/foreign/MappedMemoryUtilsProxy.java similarity index 62% rename from src/java.base/share/classes/sun/security/provider/SHAKE256.java rename to src/java.base/share/classes/jdk/internal/access/foreign/MappedMemoryUtilsProxy.java index 5dab92fdd78..eb5cf388470 100644 --- a/src/java.base/share/classes/sun/security/provider/SHAKE256.java +++ b/src/java.base/share/classes/jdk/internal/access/foreign/MappedMemoryUtilsProxy.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,28 +22,18 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package sun.security.provider; -/* - * The SHAKE256 extendable output function. +package jdk.internal.access.foreign; + +import java.io.FileDescriptor; + +/** + * This proxy interface is required to allow access to @{code MappedMemoryUtils} methods from {@code ScopedMemoryAccess}. + * This allows to avoid pesky initialization issues in the middle of memory mapped scoped methods. */ -public final class SHAKE256 extends SHA3 { - public SHAKE256(int d) { - super("SHAKE256", d, (byte) 0x1F, 64); - } - - public void update(byte in) { - engineUpdate(in); - } - public void update(byte[] in, int off, int len) { - engineUpdate(in, off, len); - } - - public byte[] digest() { - return engineDigest(); - } - - public void reset() { - engineReset(); - } +public interface MappedMemoryUtilsProxy { + boolean isLoaded(long address, boolean isSync, long size); + void load(long address, boolean isSync, long size); + void unload(long address, boolean isSync, long size); + void force(FileDescriptor fd, long address, boolean isSync, long index, long length); } diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/AbstractAttributeMapper.java b/src/java.base/share/classes/jdk/internal/classfile/impl/AbstractAttributeMapper.java index 8be167cd119..b29b9f6f955 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/impl/AbstractAttributeMapper.java +++ b/src/java.base/share/classes/jdk/internal/classfile/impl/AbstractAttributeMapper.java @@ -62,13 +62,13 @@ public sealed abstract class AbstractAttributeMapper> } @Override - public final void writeAttribute(BufWriter buf, T attr) { + public final void writeAttribute(BufWriter writer, T attr) { + BufWriterImpl buf = (BufWriterImpl) writer; buf.writeIndex(buf.constantPool().utf8Entry(name)); - buf.writeInt(0); - int start = buf.size(); + int lengthIndex = buf.skip(4); writeBody(buf, attr); - int written = buf.size() - start; - buf.patchInt(start - 4, 4, written); + int written = buf.size() - lengthIndex - 4; + buf.patchInt(lengthIndex, written); } @Override @@ -140,14 +140,13 @@ public sealed abstract class AbstractAttributeMapper> } @Override - protected void writeBody(BufWriter buf, CharacterRangeTableAttribute attr) { + protected void writeBody(BufWriter bufWriter, CharacterRangeTableAttribute attr) { List ranges = attr.characterRangeTable(); + BufWriterImpl buf = (BufWriterImpl) bufWriter; buf.writeU2(ranges.size()); for (CharacterRangeInfo info : ranges) { - buf.writeU2(info.startPc()); - buf.writeU2(info.endPc()); - buf.writeInt(info.characterRangeStart()); - buf.writeInt(info.characterRangeEnd()); + buf.writeU2U2(info.startPc(), info.endPc()); + buf.writeIntInt(info.characterRangeStart(), info.characterRangeEnd()); buf.writeU2(info.flags()); } } @@ -238,9 +237,10 @@ public sealed abstract class AbstractAttributeMapper> } @Override - protected void writeBody(BufWriter buf, EnclosingMethodAttribute attr) { - buf.writeIndex(attr.enclosingClass()); - buf.writeIndexOrZero(attr.enclosingMethod().orElse(null)); + protected void writeBody(BufWriter bufWriter, EnclosingMethodAttribute attr) { + BufWriterImpl buf = (BufWriterImpl) bufWriter; + buf.writeU2U2(buf.cpIndex(attr.enclosingClass()), + buf.cpIndexOrZero(attr.enclosingMethod().orElse(null))); } } @@ -275,13 +275,14 @@ public sealed abstract class AbstractAttributeMapper> } @Override - protected void writeBody(BufWriter buf, InnerClassesAttribute attr) { + protected void writeBody(BufWriter bufWriter, InnerClassesAttribute attr) { List classes = attr.classes(); + BufWriterImpl buf = (BufWriterImpl) bufWriter; buf.writeU2(classes.size()); for (InnerClassInfo ic : classes) { - buf.writeIndex(ic.innerClass()); - buf.writeIndexOrZero(ic.outerClass().orElse(null)); - buf.writeIndexOrZero(ic.innerName().orElse(null)); + buf.writeU2U2U2(buf.cpIndex(ic.innerClass()), + buf.cpIndexOrZero(ic.outerClass().orElse(null)), + buf.cpIndexOrZero(ic.innerName().orElse(null))); buf.writeU2(ic.flagsMask()); } } @@ -300,12 +301,12 @@ public sealed abstract class AbstractAttributeMapper> } @Override - protected void writeBody(BufWriter buf, LineNumberTableAttribute attr) { + protected void writeBody(BufWriter bufWriter, LineNumberTableAttribute attr) { List lines = attr.lineNumbers(); + BufWriterImpl buf = (BufWriterImpl) bufWriter; buf.writeU2(lines.size()); for (LineNumberInfo line : lines) { - buf.writeU2(line.startPc()); - buf.writeU2(line.lineNumber()); + buf.writeU2U2(line.startPc(), line.lineNumber()); } } } @@ -323,15 +324,13 @@ public sealed abstract class AbstractAttributeMapper> } @Override - protected void writeBody(BufWriter buf, LocalVariableTableAttribute attr) { + protected void writeBody(BufWriter bufWriter, LocalVariableTableAttribute attr) { List infos = attr.localVariables(); + BufWriterImpl buf = (BufWriterImpl) bufWriter; buf.writeU2(infos.size()); for (LocalVariableInfo info : infos) { - buf.writeU2(info.startPc()); - buf.writeU2(info.length()); - buf.writeIndex(info.name()); - buf.writeIndex(info.type()); - buf.writeU2(info.slot()); + buf.writeU2U2(info.startPc(), info.length()); + buf.writeU2U2U2(buf.cpIndex(info.name()), buf.cpIndex(info.type()), info.slot()); } } } @@ -349,15 +348,13 @@ public sealed abstract class AbstractAttributeMapper> } @Override - protected void writeBody(BufWriter buf, LocalVariableTypeTableAttribute attr) { + protected void writeBody(BufWriter bufWriter, LocalVariableTypeTableAttribute attr) { List infos = attr.localVariableTypes(); + BufWriterImpl buf = (BufWriterImpl) bufWriter; buf.writeU2(infos.size()); for (LocalVariableTypeInfo info : infos) { - buf.writeU2(info.startPc()); - buf.writeU2(info.length()); - buf.writeIndex(info.name()); - buf.writeIndex(info.signature()); - buf.writeU2(info.slot()); + buf.writeU2U2(info.startPc(), info.length()); + buf.writeU2U2U2(buf.cpIndex(info.name()), buf.cpIndex(info.signature()), info.slot()); } } } @@ -375,12 +372,13 @@ public sealed abstract class AbstractAttributeMapper> } @Override - protected void writeBody(BufWriter buf, MethodParametersAttribute attr) { + protected void writeBody(BufWriter bufWriter, MethodParametersAttribute attr) { List parameters = attr.parameters(); + BufWriterImpl buf = (BufWriterImpl) bufWriter; buf.writeU1(parameters.size()); for (MethodParameterInfo info : parameters) { - buf.writeIndexOrZero(info.name().orElse(null)); - buf.writeU2(info.flagsMask()); + buf.writeU2U2(buf.cpIndexOrZero(info.name().orElse(null)), + info.flagsMask()); } } } @@ -398,26 +396,27 @@ public sealed abstract class AbstractAttributeMapper> } @Override - protected void writeBody(BufWriter buf, ModuleAttribute attr) { - buf.writeIndex(attr.moduleName()); - buf.writeU2(attr.moduleFlagsMask()); - buf.writeIndexOrZero(attr.moduleVersion().orElse(null)); + protected void writeBody(BufWriter bufWriter, ModuleAttribute attr) { + BufWriterImpl buf = (BufWriterImpl) bufWriter; + buf.writeU2U2U2(buf.cpIndex(attr.moduleName()), + attr.moduleFlagsMask(), + buf.cpIndexOrZero(attr.moduleVersion().orElse(null))); buf.writeU2(attr.requires().size()); for (ModuleRequireInfo require : attr.requires()) { - buf.writeIndex(require.requires()); - buf.writeU2(require.requiresFlagsMask()); - buf.writeIndexOrZero(require.requiresVersion().orElse(null)); + buf.writeU2U2U2(buf.cpIndex(require.requires()), + require.requiresFlagsMask(), + buf.cpIndexOrZero(require.requiresVersion().orElse(null))); } buf.writeU2(attr.exports().size()); for (ModuleExportInfo export : attr.exports()) { - buf.writeIndex(export.exportedPackage()); - buf.writeU2(export.exportsFlagsMask()); + buf.writeU2U2(buf.cpIndex(export.exportedPackage()), + export.exportsFlagsMask()); Util.writeListIndices(buf, export.exportsTo()); } buf.writeU2(attr.opens().size()); for (ModuleOpenInfo open : attr.opens()) { - buf.writeIndex(open.openedPackage()); - buf.writeU2(open.opensFlagsMask()); + buf.writeU2U2(buf.cpIndex(open.openedPackage()), + open.opensFlagsMask()); Util.writeListIndices(buf, open.opensTo()); } Util.writeListIndices(buf, attr.uses()); @@ -442,13 +441,13 @@ public sealed abstract class AbstractAttributeMapper> } @Override - protected void writeBody(BufWriter buf, ModuleHashesAttribute attr) { - buf.writeIndex(attr.algorithm()); + protected void writeBody(BufWriter bufWriter, ModuleHashesAttribute attr) { List hashes = attr.hashes(); - buf.writeU2(hashes.size()); + BufWriterImpl buf = (BufWriterImpl) bufWriter; + buf.writeU2U2(buf.cpIndex(attr.algorithm()), hashes.size()); for (ModuleHashInfo hash : hashes) { - buf.writeIndex(hash.moduleName()); - buf.writeU2(hash.hash().length); + buf.writeU2U2(buf.cpIndex(hash.moduleName()), + hash.hash().length); buf.writeBytes(hash.hash()); } } @@ -593,13 +592,14 @@ public sealed abstract class AbstractAttributeMapper> } @Override - protected void writeBody(BufWriter buf, RecordAttribute attr) { + protected void writeBody(BufWriter bufWriter, RecordAttribute attr) { List components = attr.components(); + BufWriterImpl buf = (BufWriterImpl) bufWriter; buf.writeU2(components.size()); for (RecordComponentInfo info : components) { - buf.writeIndex(info.name()); - buf.writeIndex(info.descriptor()); - Util.writeAttributes((BufWriterImpl) buf, info.attributes()); + buf.writeU2U2(buf.cpIndex(info.name()), + buf.cpIndex(info.descriptor())); + Util.writeAttributes(buf, info.attributes()); } } } diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/AbstractBoundLocalVariable.java b/src/java.base/share/classes/jdk/internal/classfile/impl/AbstractBoundLocalVariable.java index dcbd8c8fee8..71b08c1915f 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/impl/AbstractBoundLocalVariable.java +++ b/src/java.base/share/classes/jdk/internal/classfile/impl/AbstractBoundLocalVariable.java @@ -88,15 +88,12 @@ public class AbstractBoundLocalVariable return false; } int length = endBci - startBci; - b.writeU2(startBci); - b.writeU2(length); + b.writeU2U2(startBci, length); if (b.canWriteDirect(code.constantPool())) { - b.writeU2(nameIndex()); - b.writeU2(secondaryIndex()); + b.writeU2U2(nameIndex(), secondaryIndex()); } else { - b.writeIndex(name()); - b.writeIndex(secondaryEntry()); + b.writeU2U2(b.cpIndex(name()), b.cpIndex(secondaryEntry())); } b.writeU2(slot()); return true; diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/AbstractDirectBuilder.java b/src/java.base/share/classes/jdk/internal/classfile/impl/AbstractDirectBuilder.java index f574627491f..6b75a44a6bf 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/impl/AbstractDirectBuilder.java +++ b/src/java.base/share/classes/jdk/internal/classfile/impl/AbstractDirectBuilder.java @@ -51,7 +51,7 @@ public class AbstractDirectBuilder { } public void writeAttribute(Attribute a) { - if (Util.isAttributeAllowed(a, context.attributesProcessingOption())) { + if (Util.isAttributeAllowed(a, context)) { attributes.withAttribute(a); } } diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/AbstractInstruction.java b/src/java.base/share/classes/jdk/internal/classfile/impl/AbstractInstruction.java index 463668dcb00..23dad36b1b1 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/impl/AbstractInstruction.java +++ b/src/java.base/share/classes/jdk/internal/classfile/impl/AbstractInstruction.java @@ -24,11 +24,11 @@ */ package jdk.internal.classfile.impl; +import java.lang.classfile.constantpool.PoolEntry; import java.lang.constant.ConstantDesc; import java.util.ArrayList; import java.util.Collections; import java.util.List; -import java.lang.classfile.ClassFile; import java.lang.classfile.Instruction; import java.lang.classfile.constantpool.ClassEntry; import java.lang.classfile.instruction.SwitchCase; @@ -66,6 +66,8 @@ import java.lang.classfile.Label; import java.lang.classfile.Opcode; import java.lang.classfile.TypeKind; +import static java.util.Objects.requireNonNull; + public abstract sealed class AbstractInstruction extends AbstractElement implements Instruction { @@ -94,7 +96,6 @@ public abstract sealed class AbstractInstruction FMT_Discontinued = "Discontinued[OP=%s]"; final Opcode op; - final int size; @Override public Opcode opcode() { @@ -103,12 +104,12 @@ public abstract sealed class AbstractInstruction @Override public int sizeInBytes() { - return size; + // Note: only lookupswitch and tableswitch have variable sizes + return op.sizeIfFixed(); } - public AbstractInstruction(Opcode op, int size) { + AbstractInstruction(Opcode op) { this.op = op; - this.size = size; } @Override @@ -118,8 +119,8 @@ public abstract sealed class AbstractInstruction final CodeImpl code; final int pos; - protected BoundInstruction(Opcode op, int size, CodeImpl code, int pos) { - super(op, size); + protected BoundInstruction(Opcode op, CodeImpl code, int pos) { + super(op); this.code = code; this.pos = pos; } @@ -131,7 +132,7 @@ public abstract sealed class AbstractInstruction @Override public void writeTo(DirectCodeBuilder writer) { // Override this if the instruction has any CP references or labels! - code.classReader.copyBytesTo(writer.bytecodesBufWriter, pos, size); + code.classReader.copyBytesTo(writer.bytecodesBufWriter, pos, op.sizeIfFixed()); } } @@ -139,13 +140,13 @@ public abstract sealed class AbstractInstruction extends BoundInstruction implements LoadInstruction { public BoundLoadInstruction(Opcode op, CodeImpl code, int pos) { - super(op, op.sizeIfFixed(), code, pos); + super(op, code, pos); } @Override public TypeKind typeKind() { - return op.primaryTypeKind(); + return BytecodeHelpers.loadType(op); } @Override @@ -155,7 +156,7 @@ public abstract sealed class AbstractInstruction @Override public int slot() { - return switch (size) { + return switch (sizeInBytes()) { case 2 -> code.classReader.readU1(pos + 1); case 4 -> code.classReader.readU2(pos + 2); default -> throw new IllegalArgumentException("Unexpected op size: " + op.sizeIfFixed() + " -- " + op); @@ -168,12 +169,12 @@ public abstract sealed class AbstractInstruction extends BoundInstruction implements StoreInstruction { public BoundStoreInstruction(Opcode op, CodeImpl code, int pos) { - super(op, op.sizeIfFixed(), code, pos); + super(op, code, pos); } @Override public TypeKind typeKind() { - return op.primaryTypeKind(); + return BytecodeHelpers.storeType(op); } @Override @@ -183,10 +184,10 @@ public abstract sealed class AbstractInstruction @Override public int slot() { - return switch (size) { + return switch (sizeInBytes()) { case 2 -> code.classReader.readU1(pos + 1); case 4 -> code.classReader.readU2(pos + 2); - default -> throw new IllegalArgumentException("Unexpected op size: " + size + " -- " + op); + default -> throw new IllegalArgumentException("Unexpected op size: " + sizeInBytes() + " -- " + op); }; } @@ -196,17 +197,17 @@ public abstract sealed class AbstractInstruction extends BoundInstruction implements IncrementInstruction { public BoundIncrementInstruction(Opcode op, CodeImpl code, int pos) { - super(op, op.sizeIfFixed(), code, pos); + super(op, code, pos); } @Override public int slot() { - return size == 6 ? code.classReader.readU2(pos + 2) : code.classReader.readU1(pos + 1); + return sizeInBytes() == 6 ? code.classReader.readU2(pos + 2) : code.classReader.readU1(pos + 1); } @Override public int constant() { - return size == 6 ? code.classReader.readS2(pos + 4) : (byte) code.classReader.readS1(pos + 2); + return sizeInBytes() == 6 ? code.classReader.readS2(pos + 4) : code.classReader.readS1(pos + 2); } @Override @@ -220,7 +221,7 @@ public abstract sealed class AbstractInstruction extends BoundInstruction implements BranchInstruction { public BoundBranchInstruction(Opcode op, CodeImpl code, int pos) { - super(op, op.sizeIfFixed(), code, pos); + super(op, code, pos); } @Override @@ -229,8 +230,8 @@ public abstract sealed class AbstractInstruction } public int branchByteOffset() { - return size == 3 - ? (int) (short) code.classReader.readU2(pos + 1) + return sizeInBytes() == 3 + ? code.classReader.readS2(pos + 1) : code.classReader.readInt(pos + 1); } @@ -248,6 +249,9 @@ public abstract sealed class AbstractInstruction public record SwitchCaseImpl(int caseValue, Label target) implements SwitchCase { + public SwitchCaseImpl { + requireNonNull(target); + } } public static final class BoundLookupSwitchInstruction @@ -256,33 +260,31 @@ public abstract sealed class AbstractInstruction // will always need size, cache everything to there private final int afterPad; private final int npairs; + private final int size; BoundLookupSwitchInstruction(Opcode op, CodeImpl code, int pos) { - super(op, size(code, code.codeStart, pos), code, pos); - - this.afterPad = pos + 1 + ((4 - ((pos + 1 - code.codeStart) & 3)) & 3); + super(op, code, pos); + this.afterPad = code.codeStart + RawBytecodeHelper.align(pos + 1 - code.codeStart); this.npairs = code.classReader.readInt(afterPad + 4); if (npairs < 0 || npairs > code.codeLength >> 3) { throw new IllegalArgumentException("Invalid lookupswitch npairs value: " + npairs); } - } - - static int size(CodeImpl code, int codeStart, int pos) { - int afterPad = pos + 1 + ((4 - ((pos + 1 - codeStart) & 3)) & 3); - int pad = afterPad - (pos + 1); - int npairs = code.classReader.readInt(afterPad + 4); - return 1 + pad + 8 + npairs * 8; + this.size = afterPad + 8 + npairs * 8 - pos; } private int defaultOffset() { return code.classReader.readInt(afterPad); } + @Override + public int sizeInBytes() { + return size; + } + @Override public List cases() { var cases = new SwitchCase[npairs]; - for (int i = 0; i < npairs; ++i) { - int z = afterPad + 8 + 8 * i; + for (int i = 0, z = afterPad + 8; i < npairs; ++i, z += 8) { cases[i] = SwitchCase.of(code.classReader.readInt(z), offsetToLabel(code.classReader.readInt(z + 4))); } return List.of(cases); @@ -308,25 +310,26 @@ public abstract sealed class AbstractInstruction public static final class BoundTableSwitchInstruction extends BoundInstruction implements TableSwitchInstruction { - BoundTableSwitchInstruction(Opcode op, CodeImpl code, int pos) { - super(op, size(code, code.codeStart, pos), code, pos); - } + private final int afterPad; + private final int low; + private final int high; + private final int size; - static int size(CodeImpl code, int codeStart, int pos) { - int ap = pos + 1 + ((4 - ((pos + 1 - codeStart) & 3)) & 3); - int pad = ap - (pos + 1); - int low = code.classReader.readInt(ap + 4); - int high = code.classReader.readInt(ap + 8); + BoundTableSwitchInstruction(Opcode op, CodeImpl code, int pos) { + super(op, code, pos); + afterPad = code.codeStart + RawBytecodeHelper.align(pos + 1 - code.codeStart); + low = code.classReader.readInt(afterPad + 4); + high = code.classReader.readInt(afterPad + 8); if (high < low || (long)high - low > code.codeLength >> 2) { throw new IllegalArgumentException("Invalid tableswitch values low: " + low + " high: " + high); } int cnt = high - low + 1; - return 1 + pad + 12 + cnt * 4; + size = afterPad + 12 + cnt * 4 - pos; } - private int afterPadding() { - int p = pos; - return p + 1 + ((4 - ((p + 1 - code.codeStart) & 3)) & 3); + @Override + public int sizeInBytes() { + return size; } @Override @@ -336,12 +339,12 @@ public abstract sealed class AbstractInstruction @Override public int lowValue() { - return code.classReader.readInt(afterPadding() + 4); + return low; } @Override public int highValue() { - return code.classReader.readInt(afterPadding() + 8); + return high; } @Override @@ -350,19 +353,17 @@ public abstract sealed class AbstractInstruction int high = highValue(); int defOff = defaultOffset(); var cases = new ArrayList(high - low + 1); - int z = afterPadding() + 12; - for (int i = lowValue(); i <= high; ++i) { + for (int i = low, z = afterPad + 12; i <= high; ++i, z += 4) { int off = code.classReader.readInt(z); if (defOff != off) { cases.add(SwitchCase.of(i, offsetToLabel(off))); } - z += 4; } return Collections.unmodifiableList(cases); } private int defaultOffset() { - return code.classReader.readInt(afterPadding()); + return code.classReader.readInt(afterPad); } @Override @@ -383,7 +384,7 @@ public abstract sealed class AbstractInstruction private FieldRefEntry fieldEntry; public BoundFieldInstruction(Opcode op, CodeImpl code, int pos) { - super(op, op.sizeIfFixed(), code, pos); + super(op, code, pos); } @Override @@ -413,7 +414,7 @@ public abstract sealed class AbstractInstruction MemberRefEntry methodEntry; public BoundInvokeInstruction(Opcode op, CodeImpl code, int pos) { - super(op, op.sizeIfFixed(), code, pos); + super(op, code, pos); } @Override @@ -425,7 +426,7 @@ public abstract sealed class AbstractInstruction @Override public boolean isInterface() { - return method().tag() == ClassFile.TAG_INTERFACEMETHODREF; + return method().tag() == PoolEntry.TAG_INTERFACE_METHODREF; } @Override @@ -453,7 +454,7 @@ public abstract sealed class AbstractInstruction InterfaceMethodRefEntry methodEntry; public BoundInvokeInterfaceInstruction(Opcode op, CodeImpl code, int pos) { - super(op, op.sizeIfFixed(), code, pos); + super(op, code, pos); } @Override @@ -493,7 +494,7 @@ public abstract sealed class AbstractInstruction InvokeDynamicEntry indyEntry; BoundInvokeDynamicInstruction(Opcode op, CodeImpl code, int pos) { - super(op, op.sizeIfFixed(), code, pos); + super(op, code, pos); } @Override @@ -523,7 +524,7 @@ public abstract sealed class AbstractInstruction ClassEntry classEntry; BoundNewObjectInstruction(CodeImpl code, int pos) { - super(Opcode.NEW, Opcode.NEW.sizeIfFixed(), code, pos); + super(Opcode.NEW, code, pos); } @Override @@ -552,7 +553,7 @@ public abstract sealed class AbstractInstruction extends BoundInstruction implements NewPrimitiveArrayInstruction { public BoundNewPrimitiveArrayInstruction(Opcode op, CodeImpl code, int pos) { - super(op, op.sizeIfFixed(), code, pos); + super(op, code, pos); } @Override @@ -571,7 +572,7 @@ public abstract sealed class AbstractInstruction extends BoundInstruction implements NewReferenceArrayInstruction { public BoundNewReferenceArrayInstruction(Opcode op, CodeImpl code, int pos) { - super(op, op.sizeIfFixed(), code, pos); + super(op, code, pos); } @Override @@ -597,7 +598,7 @@ public abstract sealed class AbstractInstruction extends BoundInstruction implements NewMultiArrayInstruction { public BoundNewMultidimensionalArrayInstruction(Opcode op, CodeImpl code, int pos) { - super(op, op.sizeIfFixed(), code, pos); + super(op, code, pos); } @Override @@ -630,7 +631,7 @@ public abstract sealed class AbstractInstruction ClassEntry typeEntry; public BoundTypeCheckInstruction(Opcode op, CodeImpl code, int pos) { - super(op, op.sizeIfFixed(), code, pos); + super(op, code, pos); } @Override @@ -659,7 +660,7 @@ public abstract sealed class AbstractInstruction extends BoundInstruction implements ConstantInstruction.ArgumentConstantInstruction { public BoundArgumentConstantInstruction(Opcode op, CodeImpl code, int pos) { - super(op, op.sizeIfFixed(), code, pos); + super(op, code, pos); } @Override @@ -668,7 +669,7 @@ public abstract sealed class AbstractInstruction } public int constantInt() { - return size == 3 ? code.classReader.readS2(pos + 1) : code.classReader.readS1(pos + 1); + return sizeInBytes() == 3 ? code.classReader.readS2(pos + 1) : code.classReader.readS1(pos + 1); } @Override @@ -682,7 +683,7 @@ public abstract sealed class AbstractInstruction extends BoundInstruction implements ConstantInstruction.LoadConstantInstruction { public BoundLoadConstantInstruction(Opcode op, CodeImpl code, int pos) { - super(op, op.sizeIfFixed(), code, pos); + super(op, code, pos); } @Override @@ -717,7 +718,7 @@ public abstract sealed class AbstractInstruction extends BoundInstruction implements DiscontinuedInstruction.JsrInstruction { public BoundJsrInstruction(Opcode op, CodeImpl code, int pos) { - super(op, op.sizeIfFixed(), code, pos); + super(op, code, pos); } @Override @@ -726,7 +727,7 @@ public abstract sealed class AbstractInstruction } public int branchByteOffset() { - return size == 3 + return sizeInBytes() == 3 ? code.classReader.readS2(pos + 1) : code.classReader.readInt(pos + 1); } @@ -747,7 +748,7 @@ public abstract sealed class AbstractInstruction extends BoundInstruction implements DiscontinuedInstruction.RetInstruction { public BoundRetInstruction(Opcode op, CodeImpl code, int pos) { - super(op, op.sizeIfFixed(), code, pos); + super(op, code, pos); } @Override @@ -757,7 +758,7 @@ public abstract sealed class AbstractInstruction @Override public int slot() { - return switch (size) { + return switch (sizeInBytes()) { case 2 -> code.classReader.readU1(pos + 1); case 4 -> code.classReader.readU2(pos + 2); default -> throw new IllegalArgumentException("Unexpected op size: " + op.sizeIfFixed() + " -- " + op); @@ -769,7 +770,7 @@ public abstract sealed class AbstractInstruction public abstract static sealed class UnboundInstruction extends AbstractInstruction { UnboundInstruction(Opcode op) { - super(op, op.sizeIfFixed()); + super(op); } @Override @@ -800,12 +801,17 @@ public abstract sealed class AbstractInstruction @Override public TypeKind typeKind() { - return op.primaryTypeKind(); + return BytecodeHelpers.loadType(op); } @Override public void writeTo(DirectCodeBuilder writer) { - writer.writeLocalVar(op, slot); + var op = this.op; + if (op.sizeIfFixed() == 1) { + writer.writeBytecode(op); + } else { + writer.writeLocalVar(op, slot); + } } @Override @@ -831,12 +837,17 @@ public abstract sealed class AbstractInstruction @Override public TypeKind typeKind() { - return op.primaryTypeKind(); + return BytecodeHelpers.storeType(op); } @Override public void writeTo(DirectCodeBuilder writer) { - writer.writeLocalVar(op, slot); + var op = this.op; + if (op.sizeIfFixed() == 1) { + writer.writeBytecode(op); + } else { + writer.writeLocalVar(op, slot); + } } @Override @@ -852,9 +863,9 @@ public abstract sealed class AbstractInstruction final int constant; public UnboundIncrementInstruction(int slot, int constant) { - super(slot <= 255 && constant < 128 && constant > -127 - ? Opcode.IINC - : Opcode.IINC_W); + super(BytecodeHelpers.validateAndIsWideIinc(slot, constant) + ? Opcode.IINC_W + : Opcode.IINC); this.slot = slot; this.constant = constant; } @@ -871,7 +882,7 @@ public abstract sealed class AbstractInstruction @Override public void writeTo(DirectCodeBuilder writer) { - writer.writeIncrement(slot, constant); + writer.writeIncrement(op == Opcode.IINC_W, slot, constant); } @Override @@ -886,7 +897,7 @@ public abstract sealed class AbstractInstruction public UnboundBranchInstruction(Opcode op, Label target) { super(op); - this.target = target; + this.target = requireNonNull(target); } @Override @@ -913,7 +924,7 @@ public abstract sealed class AbstractInstruction public UnboundLookupSwitchInstruction(Label defaultTarget, List cases) { super(Opcode.LOOKUPSWITCH); - this.defaultTarget = defaultTarget; + this.defaultTarget = requireNonNull(defaultTarget); this.cases = List.copyOf(cases); } @@ -949,7 +960,7 @@ public abstract sealed class AbstractInstruction super(Opcode.TABLESWITCH); this.lowValue = lowValue; this.highValue = highValue; - this.defaultTarget = defaultTarget; + this.defaultTarget = requireNonNull(defaultTarget); this.cases = List.copyOf(cases); } @@ -993,7 +1004,7 @@ public abstract sealed class AbstractInstruction @Override public TypeKind typeKind() { - return op.primaryTypeKind(); + return BytecodeHelpers.returnType(op); } @Override @@ -1024,7 +1035,7 @@ public abstract sealed class AbstractInstruction public UnboundFieldInstruction(Opcode op, FieldRefEntry fieldEntry) { super(op); - this.fieldEntry = fieldEntry; + this.fieldEntry = requireNonNull(fieldEntry); } @Override @@ -1049,7 +1060,7 @@ public abstract sealed class AbstractInstruction public UnboundInvokeInstruction(Opcode op, MemberRefEntry methodEntry) { super(op); - this.methodEntry = methodEntry; + this.methodEntry = requireNonNull(methodEntry); } @Override @@ -1065,7 +1076,7 @@ public abstract sealed class AbstractInstruction @Override public int count() { return op == Opcode.INVOKEINTERFACE - ? Util.parameterSlots(Util.methodTypeSymbol(methodEntry.nameAndType())) + 1 + ? Util.parameterSlots(Util.methodTypeSymbol(methodEntry.type())) + 1 : 0; } @@ -1089,7 +1100,7 @@ public abstract sealed class AbstractInstruction public UnboundInvokeDynamicInstruction(InvokeDynamicEntry indyEntry) { super(Opcode.INVOKEDYNAMIC); - this.indyEntry = indyEntry; + this.indyEntry = requireNonNull(indyEntry); } @Override @@ -1114,7 +1125,7 @@ public abstract sealed class AbstractInstruction public UnboundNewObjectInstruction(ClassEntry classEntry) { super(Opcode.NEW); - this.classEntry = classEntry; + this.classEntry = requireNonNull(classEntry); } @Override @@ -1139,7 +1150,7 @@ public abstract sealed class AbstractInstruction public UnboundNewPrimitiveArrayInstruction(TypeKind typeKind) { super(Opcode.NEWARRAY); - this.typeKind = typeKind; + this.typeKind = requireNonNull(typeKind); } @Override @@ -1164,7 +1175,7 @@ public abstract sealed class AbstractInstruction public UnboundNewReferenceArrayInstruction(ClassEntry componentTypeEntry) { super(Opcode.ANEWARRAY); - this.componentTypeEntry = componentTypeEntry; + this.componentTypeEntry = requireNonNull(componentTypeEntry); } @Override @@ -1191,7 +1202,7 @@ public abstract sealed class AbstractInstruction public UnboundNewMultidimensionalArrayInstruction(ClassEntry arrayTypeEntry, int dimensions) { super(Opcode.MULTIANEWARRAY); - this.arrayTypeEntry = arrayTypeEntry; + this.arrayTypeEntry = requireNonNull(arrayTypeEntry); this.dimensions = dimensions; } @@ -1226,7 +1237,7 @@ public abstract sealed class AbstractInstruction @Override public TypeKind typeKind() { - return op.primaryTypeKind(); + return BytecodeHelpers.arrayLoadType(op); } } @@ -1239,7 +1250,7 @@ public abstract sealed class AbstractInstruction @Override public TypeKind typeKind() { - return op.primaryTypeKind(); + return BytecodeHelpers.arrayStoreType(op); } } @@ -1249,7 +1260,7 @@ public abstract sealed class AbstractInstruction public UnboundTypeCheckInstruction(Opcode op, ClassEntry typeEntry) { super(op); - this.typeEntry = typeEntry; + this.typeEntry = requireNonNull(typeEntry); } @Override @@ -1286,12 +1297,12 @@ public abstract sealed class AbstractInstruction @Override public TypeKind fromType() { - return op.primaryTypeKind(); + return BytecodeHelpers.convertFromType(op); } @Override public TypeKind toType() { - return op.secondaryTypeKind(); + return BytecodeHelpers.convertToType(op); } } @@ -1304,22 +1315,19 @@ public abstract sealed class AbstractInstruction @Override public TypeKind typeKind() { - return op.primaryTypeKind(); + return BytecodeHelpers.operatorOperandType(op); } } public static final class UnboundIntrinsicConstantInstruction extends UnboundInstruction implements ConstantInstruction.IntrinsicConstantInstruction { - final ConstantDesc constant; - public UnboundIntrinsicConstantInstruction(Opcode op) { super(op); - constant = op.constantValue(); } @Override public ConstantDesc constantValue() { - return constant; + return BytecodeHelpers.intrinsicConstantValue(op); } } @@ -1354,7 +1362,7 @@ public abstract sealed class AbstractInstruction public UnboundLoadConstantInstruction(Opcode op, LoadableConstantEntry constant) { super(op); - this.constant = constant; + this.constant = requireNonNull(constant); } @Override @@ -1402,7 +1410,7 @@ public abstract sealed class AbstractInstruction public UnboundJsrInstruction(Opcode op, Label target) { super(op); - this.target = target; + this.target = requireNonNull(target); } @Override diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/AbstractPoolEntry.java b/src/java.base/share/classes/jdk/internal/classfile/impl/AbstractPoolEntry.java index bc885291b44..15b52621764 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/impl/AbstractPoolEntry.java +++ b/src/java.base/share/classes/jdk/internal/classfile/impl/AbstractPoolEntry.java @@ -24,12 +24,12 @@ */ package jdk.internal.classfile.impl; +import java.lang.classfile.constantpool.ConstantPoolException; import java.lang.constant.*; import java.lang.invoke.TypeDescriptor; import java.nio.charset.StandardCharsets; import java.util.Arrays; -import java.lang.classfile.ClassFile; import java.lang.classfile.constantpool.ClassEntry; import java.lang.classfile.constantpool.ConstantDynamicEntry; import java.lang.classfile.constantpool.ConstantPool; @@ -54,6 +54,9 @@ import java.lang.classfile.constantpool.Utf8Entry; import jdk.internal.access.JavaLangAccess; import jdk.internal.access.SharedSecrets; import jdk.internal.util.ArraysSupport; +import jdk.internal.vm.annotation.Stable; + +import static java.util.Objects.requireNonNull; public abstract sealed class AbstractPoolEntry { /* @@ -82,24 +85,32 @@ public abstract sealed class AbstractPoolEntry { return stringHash | NON_ZERO; } - public static Utf8Entry rawUtf8EntryFromStandardAttributeName(String name) { - //assuming standard attribute names are all US_ASCII - var raw = name.getBytes(StandardCharsets.US_ASCII); - return new Utf8EntryImpl(null, 0, raw, 0, raw.length); + static int hashClassFromUtf8(boolean isArray, Utf8EntryImpl content) { + int hash = content.contentHash(); + return hashClassFromDescriptor(isArray ? hash : Util.descriptorStringHash(content.length(), hash)); + } + + static int hashClassFromDescriptor(int descriptorHash) { + return hash1(PoolEntry.TAG_CLASS, descriptorHash); + } + + static boolean isArrayDescriptor(Utf8EntryImpl cs) { + // Do not throw out-of-bounds for empty strings + return !cs.isEmpty() && cs.charAt(0) == '['; } @SuppressWarnings("unchecked") public static T maybeClone(ConstantPoolBuilder cp, T entry) { + if (cp.canWriteDirect(entry.constantPool())) + return entry; return (T)((AbstractPoolEntry)entry).clone(cp); } final ConstantPool constantPool; - public final byte tag; private final int index; private final int hash; - private AbstractPoolEntry(ConstantPool constantPool, int tag, int index, int hash) { - this.tag = (byte) tag; + private AbstractPoolEntry(ConstantPool constantPool, int index, int hash) { this.index = index; this.hash = hash; this.constantPool = constantPool; @@ -114,12 +125,10 @@ public abstract sealed class AbstractPoolEntry { return hash; } - public byte tag() { - return tag; - } + public abstract byte tag(); public int width() { - return (tag == ClassFile.TAG_LONG || tag == ClassFile.TAG_DOUBLE) ? 2 : 1; + return 1; } abstract void writeTo(BufWriterImpl buf); @@ -146,16 +155,18 @@ public abstract sealed class AbstractPoolEntry { private final int offset; private final int rawLen; // Set in any state other than RAW - private int hash; - private int charLen; + private @Stable int contentHash; + private @Stable int charLen; // Set in CHAR state - private char[] chars; + private @Stable char[] chars; // Only set in STRING state - private String stringValue; + private @Stable String stringValue; + // The descriptor symbol, if this is a descriptor + @Stable TypeDescriptor typeSym; Utf8EntryImpl(ConstantPool cpm, int index, byte[] rawBytes, int offset, int rawLen) { - super(cpm, ClassFile.TAG_UTF8, index, 0); + super(cpm, index, 0); this.rawBytes = rawBytes; this.offset = offset; this.rawLen = rawLen; @@ -163,30 +174,36 @@ public abstract sealed class AbstractPoolEntry { } Utf8EntryImpl(ConstantPool cpm, int index, String s) { - this(cpm, index, s, hashString(s.hashCode())); + this(cpm, index, s, s.hashCode()); } - Utf8EntryImpl(ConstantPool cpm, int index, String s, int hash) { - super(cpm, ClassFile.TAG_UTF8, index, 0); + Utf8EntryImpl(ConstantPool cpm, int index, String s, int contentHash) { + super(cpm, index, 0); this.rawBytes = null; this.offset = 0; this.rawLen = 0; this.state = State.STRING; this.stringValue = s; this.charLen = s.length(); - this.hash = hash; + this.contentHash = contentHash; } Utf8EntryImpl(ConstantPool cpm, int index, Utf8EntryImpl u) { - super(cpm, ClassFile.TAG_UTF8, index, 0); + super(cpm, index, 0); this.rawBytes = u.rawBytes; this.offset = u.offset; this.rawLen = u.rawLen; this.state = u.state; - this.hash = u.hash; + this.contentHash = u.contentHash; this.charLen = u.charLen; this.chars = u.chars; this.stringValue = u.stringValue; + this.typeSym = u.typeSym; + } + + @Override + public byte tag() { + return TAG_UTF8; } /** @@ -228,76 +245,80 @@ public abstract sealed class AbstractPoolEntry { int singleBytes = JLA.countPositives(rawBytes, offset, rawLen); int hash = ArraysSupport.hashCodeOfUnsigned(rawBytes, offset, singleBytes, 0); if (singleBytes == rawLen) { - this.hash = hashString(hash); + this.contentHash = hash; charLen = rawLen; state = State.BYTE; + } else { + inflateNonAscii(singleBytes, hash); } - else { - char[] chararr = new char[rawLen]; - int chararr_count = singleBytes; - // Inflate prefix of bytes to characters - JLA.inflateBytesToChars(rawBytes, offset, chararr, 0, singleBytes); + } - int px = offset + singleBytes; - int utfend = offset + rawLen; - while (px < utfend) { - int c = (int) rawBytes[px] & 0xff; - switch (c >> 4) { - case 0, 1, 2, 3, 4, 5, 6, 7: { - // 0xxx xxxx - px++; - chararr[chararr_count++] = (char) c; - hash = 31 * hash + c; - break; - } - case 12, 13: { - // 110x xxxx 10xx xxxx - px += 2; - if (px > utfend) { - throw new CpException("malformed input: partial character at end"); - } - int char2 = rawBytes[px - 1]; - if ((char2 & 0xC0) != 0x80) { - throw new CpException("malformed input around byte " + px); - } - char v = (char) (((c & 0x1F) << 6) | (char2 & 0x3F)); - chararr[chararr_count++] = v; - hash = 31 * hash + v; - break; - } - case 14: { - // 1110 xxxx 10xx xxxx 10xx xxxx - px += 3; - if (px > utfend) { - throw new CpException("malformed input: partial character at end"); - } - int char2 = rawBytes[px - 2]; - int char3 = rawBytes[px - 1]; - if (((char2 & 0xC0) != 0x80) || ((char3 & 0xC0) != 0x80)) { - throw new CpException("malformed input around byte " + (px - 1)); - } - char v = (char) (((c & 0x0F) << 12) | ((char2 & 0x3F) << 6) | (char3 & 0x3F)); - chararr[chararr_count++] = v; - hash = 31 * hash + v; - break; - } - default: - // 10xx xxxx, 1111 xxxx - throw new CpException("malformed input around byte " + px); + private void inflateNonAscii(int singleBytes, int hash) { + char[] chararr = new char[rawLen]; + int chararr_count = singleBytes; + // Inflate prefix of bytes to characters + JLA.inflateBytesToChars(rawBytes, offset, chararr, 0, singleBytes); + + int px = offset + singleBytes; + int utfend = offset + rawLen; + while (px < utfend) { + int c = (int) rawBytes[px] & 0xff; + switch (c >> 4) { + case 0, 1, 2, 3, 4, 5, 6, 7: { + // 0xxx xxxx + px++; + chararr[chararr_count++] = (char) c; + hash = 31 * hash + c; + break; } + case 12, 13: { + // 110x xxxx 10xx xxxx + px += 2; + if (px > utfend) { + throw malformedInput(utfend); + } + int char2 = rawBytes[px - 1]; + if ((char2 & 0xC0) != 0x80) { + throw malformedInput(px); + } + char v = (char) (((c & 0x1F) << 6) | (char2 & 0x3F)); + chararr[chararr_count++] = v; + hash = 31 * hash + v; + break; + } + case 14: { + // 1110 xxxx 10xx xxxx 10xx xxxx + px += 3; + if (px > utfend) { + throw malformedInput(utfend); + } + int char2 = rawBytes[px - 2]; + int char3 = rawBytes[px - 1]; + if (((char2 & 0xC0) != 0x80) || ((char3 & 0xC0) != 0x80)) { + throw malformedInput(px - 1); + } + char v = (char) (((c & 0x0F) << 12) | ((char2 & 0x3F) << 6) | (char3 & 0x3F)); + chararr[chararr_count++] = v; + hash = 31 * hash + v; + break; + } + default: + // 10xx xxxx, 1111 xxxx + throw malformedInput(px); } - this.hash = hashString(hash); - charLen = chararr_count; - this.chars = chararr; - state = State.CHAR; } + this.contentHash = hash; + charLen = chararr_count; + this.chars = chararr; + state = State.CHAR; + } + private ConstantPoolException malformedInput(int px) { + return new ConstantPoolException("#%d: malformed modified UTF8 around byte %d".formatted(index(), px)); } @Override public Utf8EntryImpl clone(ConstantPoolBuilder cp) { - if (cp.canWriteDirect(constantPool)) - return this; return (state == State.STRING && rawBytes == null) ? (Utf8EntryImpl) cp.utf8Entry(stringValue) : ((SplitConstantPool) cp).maybeCloneUtf8Entry(this); @@ -305,9 +326,13 @@ public abstract sealed class AbstractPoolEntry { @Override public int hashCode() { + return hashString(contentHash()); + } + + int contentHash() { if (state == State.RAW) inflate(); - return hash; + return contentHash; } @Override @@ -378,15 +403,47 @@ public abstract sealed class AbstractPoolEntry { return stringValue().equals(u.stringValue()); } + /** + * Returns if this utf8 entry's content equals a substring + * of {@code s} obtained as {@code s.substring(start, end - start)}. + * This check avoids a substring allocation. + */ + public boolean equalsRegion(String s, int start, int end) { + // start and end values trusted + if (state == State.RAW) + inflate(); + int len = charLen; + if (len != end - start) + return false; + + var sv = stringValue; + if (sv != null) { + return sv.regionMatches(0, s, start, len); + } + + var chars = this.chars; + if (chars != null) { + for (int i = 0; i < len; i++) + if (chars[i] != s.charAt(start + i)) + return false; + } else { + var bytes = this.rawBytes; + for (int i = 0; i < len; i++) + if (bytes[offset + i] != s.charAt(start + i)) + return false; + } + return true; + } + @Override public boolean equalsString(String s) { if (state == State.RAW) inflate(); switch (state) { case STRING: - return stringValue.equals(s); + return stringValue.equals(requireNonNull(s)); case CHAR: - if (charLen != s.length() || hash != hashString(s.hashCode())) + if (charLen != s.length() || contentHash != s.hashCode()) return false; for (int i=0; i 65535) { - throw new IllegalArgumentException("string too long"); - } - pool.writeU1(tag); - pool.writeU2(charLen); - for (int i = 0; i < charLen; ++i) { - char c = stringValue.charAt(i); - if (c >= '\001' && c <= '\177') { - // Optimistic writing -- hope everything is bytes - // If not, we bail out, and alternate path patches the length - pool.writeU1((byte) c); - } - else { - int charLength = stringValue.length(); - int byteLength = i; - char c1; - for (int j = i; j < charLength; ++j) { - c1 = (stringValue).charAt(j); - if (c1 >= '\001' && c1 <= '\177') { - byteLength++; - } else if (c1 > '\u07FF') { - byteLength += 3; - } else { - byteLength += 2; - } - } - if (byteLength > 65535) { - throw new IllegalArgumentException(); - } - int byteLengthFinal = byteLength; - pool.patchInt(pool.size() - i - 2, 2, byteLengthFinal); - for (int j = i; j < charLength; ++j) { - c1 = (stringValue).charAt(j); - if (c1 >= '\001' && c1 <= '\177') { - pool.writeU1((byte) c1); - } else if (c1 > '\u07FF') { - pool.writeU1((byte) (0xE0 | c1 >> 12 & 0xF)); - pool.writeU1((byte) (0x80 | c1 >> 6 & 0x3F)); - pool.writeU1((byte) (0x80 | c1 & 0x3F)); - } else { - pool.writeU1((byte) (0xC0 | c1 >> 6 & 0x1F)); - pool.writeU1((byte) (0x80 | c1 & 0x3F)); - } - } - break; - } - } + pool.writeUtfEntry(stringValue); } } + + public ClassDesc fieldTypeSymbol() { + if (typeSym instanceof ClassDesc cd) + return cd; + var ret = ClassDesc.ofDescriptor(stringValue()); + typeSym = ret; + return ret; + } + + public MethodTypeDesc methodTypeSymbol() { + if (typeSym instanceof MethodTypeDesc mtd) + return mtd; + var ret = MethodTypeDesc.ofDescriptor(stringValue()); + typeSym = ret; + return ret; + } } abstract static sealed class AbstractRefEntry extends AbstractPoolEntry { protected final T ref1; public AbstractRefEntry(ConstantPool constantPool, int tag, int index, T ref1) { - super(constantPool, tag, index, hash1(tag, ref1.index())); + super(constantPool, index, hash1(tag, ref1.index())); this.ref1 = ref1; } @@ -480,8 +506,7 @@ public abstract sealed class AbstractPoolEntry { } void writeTo(BufWriterImpl pool) { - pool.writeU1(tag); - pool.writeU2(ref1.index()); + pool.writeU1U2(tag(), ref1.index()); } @Override @@ -496,7 +521,7 @@ public abstract sealed class AbstractPoolEntry { protected final U ref2; public AbstractRefsEntry(ConstantPool constantPool, int tag, int index, T ref1, U ref2) { - super(constantPool, tag, index, hash2(tag, ref1.index(), ref2.index())); + super(constantPool, index, hash2(tag, ref1.index(), ref2.index())); this.ref1 = ref1; this.ref2 = ref2; } @@ -510,9 +535,7 @@ public abstract sealed class AbstractPoolEntry { } void writeTo(BufWriterImpl pool) { - pool.writeU1(tag); - pool.writeU2(ref1.index()); - pool.writeU2(ref2.index()); + pool.writeU1U2U2(tag(), ref1.index(), ref2.index()); } @Override @@ -538,21 +561,27 @@ public abstract sealed class AbstractPoolEntry { public static final class ClassEntryImpl extends AbstractNamedEntry implements ClassEntry { - public ClassDesc sym = null; + public @Stable ClassDesc sym; + private @Stable int hash; ClassEntryImpl(ConstantPool cpm, int index, Utf8EntryImpl name) { - super(cpm, ClassFile.TAG_CLASS, index, name); + super(cpm, TAG_CLASS, index, name); + } + + ClassEntryImpl(ConstantPool cpm, int index, Utf8EntryImpl name, int hash, ClassDesc sym) { + super(cpm, TAG_CLASS, index, name); + this.hash = hash; + this.sym = sym; + } + + @Override + public byte tag() { + return TAG_CLASS; } @Override public ClassEntry clone(ConstantPoolBuilder cp) { - if (cp.canWriteDirect(constantPool)) { - return this; - } else { - ClassEntryImpl ret = (ClassEntryImpl)cp.classEntry(ref1); - ret.sym = sym; - return ret; - } + return ((SplitConstantPool) cp).cloneClassEntry(this); } @Override @@ -561,30 +590,58 @@ public abstract sealed class AbstractPoolEntry { if (sym != null) { return sym; } - return this.sym = Util.toClassDesc(asInternalName()); + + if (isArrayDescriptor(ref1)) { + sym = ref1.fieldTypeSymbol(); // array, symbol already available + } else { + sym = ClassDesc.ofInternalName(asInternalName()); // class or interface + } + return this.sym = sym; } @Override public boolean equals(Object o) { if (o == this) return true; - if (o instanceof ClassEntryImpl cce) { - return cce.name().equals(this.name()); - } else if (o instanceof ClassEntry c) { - return c.asSymbol().equals(this.asSymbol()); + if (o instanceof ClassEntryImpl other) { + return equalsEntry(other); } return false; } + + boolean equalsEntry(ClassEntryImpl other) { + var tsym = this.sym; + var osym = other.sym; + if (tsym != null && osym != null) { + return tsym.equals(osym); + } + + return ref1.equalsUtf8(other.ref1); + } + + @Override + public int hashCode() { + var hash = this.hash; + if (hash != 0) + return hash; + + return this.hash = hashClassFromUtf8(isArrayDescriptor(ref1), ref1); + } } public static final class PackageEntryImpl extends AbstractNamedEntry implements PackageEntry { PackageEntryImpl(ConstantPool cpm, int index, Utf8EntryImpl name) { - super(cpm, ClassFile.TAG_PACKAGE, index, name); + super(cpm, TAG_PACKAGE, index, name); + } + + @Override + public byte tag() { + return TAG_PACKAGE; } @Override public PackageEntry clone(ConstantPoolBuilder cp) { - return cp.canWriteDirect(constantPool) ? this : cp.packageEntry(ref1); + return cp.packageEntry(ref1); } @Override @@ -605,12 +662,17 @@ public abstract sealed class AbstractPoolEntry { public static final class ModuleEntryImpl extends AbstractNamedEntry implements ModuleEntry { ModuleEntryImpl(ConstantPool cpm, int index, Utf8EntryImpl name) { - super(cpm, ClassFile.TAG_MODULE, index, name); + super(cpm, TAG_MODULE, index, name); + } + + @Override + public byte tag() { + return TAG_MODULE; } @Override public ModuleEntry clone(ConstantPoolBuilder cp) { - return cp.canWriteDirect(constantPool) ? this : cp.moduleEntry(ref1); + return cp.moduleEntry(ref1); } @Override @@ -631,10 +693,13 @@ public abstract sealed class AbstractPoolEntry { public static final class NameAndTypeEntryImpl extends AbstractRefsEntry implements NameAndTypeEntry { - public TypeDescriptor typeSym = null; - NameAndTypeEntryImpl(ConstantPool cpm, int index, Utf8EntryImpl name, Utf8EntryImpl type) { - super(cpm, ClassFile.TAG_NAMEANDTYPE, index, name, type); + super(cpm, TAG_NAME_AND_TYPE, index, name, type); + } + + @Override + public byte tag() { + return TAG_NAME_AND_TYPE; } @Override @@ -647,31 +712,9 @@ public abstract sealed class AbstractPoolEntry { return ref2; } - public ClassDesc fieldTypeSymbol() { - if (typeSym instanceof ClassDesc cd) { - return cd; - } else { - return (ClassDesc)(typeSym = ClassDesc.ofDescriptor(ref2.stringValue())); - } - } - - public MethodTypeDesc methodTypeSymbol() { - if (typeSym instanceof MethodTypeDesc mtd) { - return mtd; - } else { - return (MethodTypeDesc)(typeSym = MethodTypeDesc.ofDescriptor(ref2.stringValue())); - } - } - @Override public NameAndTypeEntry clone(ConstantPoolBuilder cp) { - if (cp.canWriteDirect(constantPool)) { - return this; - } else { - var ret = (NameAndTypeEntryImpl)cp.nameAndTypeEntry(ref1, ref2); - ret.typeSym = typeSym; - return ret; - } + return cp.nameAndTypeEntry(ref1, ref2); } @Override @@ -713,7 +756,7 @@ public abstract sealed class AbstractPoolEntry { public boolean equals(Object o) { if (this == o) return true; if (o instanceof AbstractMemberRefEntry m) { - return tag == m.tag() + return tag() == m.tag() && owner().equals(m.owner()) && nameAndType().equals(m.nameAndType()); } @@ -725,12 +768,17 @@ public abstract sealed class AbstractPoolEntry { FieldRefEntryImpl(ConstantPool cpm, int index, ClassEntryImpl owner, NameAndTypeEntryImpl nameAndType) { - super(cpm, ClassFile.TAG_FIELDREF, index, owner, nameAndType); + super(cpm, TAG_FIELDREF, index, owner, nameAndType); + } + + @Override + public byte tag() { + return TAG_FIELDREF; } @Override public FieldRefEntry clone(ConstantPoolBuilder cp) { - return cp.canWriteDirect(constantPool) ? this : cp.fieldRefEntry(ref1, ref2); + return cp.fieldRefEntry(ref1, ref2); } } @@ -738,12 +786,17 @@ public abstract sealed class AbstractPoolEntry { MethodRefEntryImpl(ConstantPool cpm, int index, ClassEntryImpl owner, NameAndTypeEntryImpl nameAndType) { - super(cpm, ClassFile.TAG_METHODREF, index, owner, nameAndType); + super(cpm, TAG_METHODREF, index, owner, nameAndType); + } + + @Override + public byte tag() { + return TAG_METHODREF; } @Override public MethodRefEntry clone(ConstantPoolBuilder cp) { - return cp.canWriteDirect(constantPool) ? this : cp.methodRefEntry(ref1, ref2); + return cp.methodRefEntry(ref1, ref2); } } @@ -751,12 +804,17 @@ public abstract sealed class AbstractPoolEntry { InterfaceMethodRefEntryImpl(ConstantPool cpm, int index, ClassEntryImpl owner, NameAndTypeEntryImpl nameAndType) { - super(cpm, ClassFile.TAG_INTERFACEMETHODREF, index, owner, nameAndType); + super(cpm, TAG_INTERFACE_METHODREF, index, owner, nameAndType); + } + + @Override + public byte tag() { + return TAG_INTERFACE_METHODREF; } @Override public InterfaceMethodRefEntry clone(ConstantPoolBuilder cp) { - return cp.canWriteDirect(constantPool) ? this : cp.interfaceMethodRefEntry(ref1, ref2); + return cp.interfaceMethodRefEntry(ref1, ref2); } } @@ -766,17 +824,17 @@ public abstract sealed class AbstractPoolEntry { private BootstrapMethodEntryImpl bootstrapMethod; private final NameAndTypeEntryImpl nameAndType; - AbstractDynamicConstantPoolEntry(ConstantPool cpm, int tag, int index, int hash, BootstrapMethodEntryImpl bootstrapMethod, + AbstractDynamicConstantPoolEntry(ConstantPool cpm, int index, int hash, BootstrapMethodEntryImpl bootstrapMethod, NameAndTypeEntryImpl nameAndType) { - super(cpm, tag, index, hash); + super(cpm, index, hash); this.bsmIndex = bootstrapMethod.bsmIndex(); this.bootstrapMethod = bootstrapMethod; this.nameAndType = nameAndType; } - AbstractDynamicConstantPoolEntry(ConstantPool cpm, int tag, int index, int hash, int bsmIndex, + AbstractDynamicConstantPoolEntry(ConstantPool cpm, int index, int hash, int bsmIndex, NameAndTypeEntryImpl nameAndType) { - super(cpm, tag, index, hash); + super(cpm, index, hash); this.bsmIndex = bsmIndex; this.bootstrapMethod = null; this.nameAndType = nameAndType; @@ -807,9 +865,7 @@ public abstract sealed class AbstractPoolEntry { } void writeTo(BufWriterImpl pool) { - pool.writeU1(tag); - pool.writeU2(bsmIndex); - pool.writeU2(nameAndType.index()); + pool.writeU1U2U2(tag(), bsmIndex, nameAndType.index()); } @Override @@ -836,18 +892,23 @@ public abstract sealed class AbstractPoolEntry { InvokeDynamicEntryImpl(ConstantPool cpm, int index, int hash, BootstrapMethodEntryImpl bootstrapMethod, NameAndTypeEntryImpl nameAndType) { - super(cpm, ClassFile.TAG_INVOKEDYNAMIC, index, hash, bootstrapMethod, nameAndType); + super(cpm, index, hash, bootstrapMethod, nameAndType); } InvokeDynamicEntryImpl(ConstantPool cpm, int index, int bsmIndex, NameAndTypeEntryImpl nameAndType) { - super(cpm, ClassFile.TAG_INVOKEDYNAMIC, index, hash2(ClassFile.TAG_INVOKEDYNAMIC, bsmIndex, nameAndType.index()), + super(cpm, index, hash2(TAG_INVOKE_DYNAMIC, bsmIndex, nameAndType.index()), bsmIndex, nameAndType); } + @Override + public byte tag() { + return TAG_INVOKE_DYNAMIC; + } + @Override public InvokeDynamicEntry clone(ConstantPoolBuilder cp) { - return cp.canWriteDirect(constantPool) ? this : cp.invokeDynamicEntry(bootstrap(), nameAndType()); + return cp.invokeDynamicEntry(bootstrap(), nameAndType()); } } @@ -856,18 +917,23 @@ public abstract sealed class AbstractPoolEntry { ConstantDynamicEntryImpl(ConstantPool cpm, int index, int hash, BootstrapMethodEntryImpl bootstrapMethod, NameAndTypeEntryImpl nameAndType) { - super(cpm, ClassFile.TAG_CONSTANTDYNAMIC, index, hash, bootstrapMethod, nameAndType); + super(cpm, index, hash, bootstrapMethod, nameAndType); } ConstantDynamicEntryImpl(ConstantPool cpm, int index, int bsmIndex, NameAndTypeEntryImpl nameAndType) { - super(cpm, ClassFile.TAG_CONSTANTDYNAMIC, index, hash2(ClassFile.TAG_CONSTANTDYNAMIC, bsmIndex, nameAndType.index()), + super(cpm, index, hash2(TAG_DYNAMIC, bsmIndex, nameAndType.index()), bsmIndex, nameAndType); } + @Override + public byte tag() { + return TAG_DYNAMIC; + } + @Override public ConstantDynamicEntry clone(ConstantPoolBuilder cp) { - return cp.canWriteDirect(constantPool) ? this : cp.constantDynamicEntry(bootstrap(), nameAndType()); + return cp.constantDynamicEntry(bootstrap(), nameAndType()); } } @@ -879,18 +945,23 @@ public abstract sealed class AbstractPoolEntry { MethodHandleEntryImpl(ConstantPool cpm, int index, int hash, int refKind, AbstractPoolEntry.AbstractMemberRefEntry reference) { - super(cpm, ClassFile.TAG_METHODHANDLE, index, hash); + super(cpm, index, hash); this.refKind = refKind; this.reference = reference; } MethodHandleEntryImpl(ConstantPool cpm, int index, int refKind, AbstractPoolEntry.AbstractMemberRefEntry reference) { - super(cpm, ClassFile.TAG_METHODHANDLE, index, hash2(ClassFile.TAG_METHODHANDLE, refKind, reference.index())); + super(cpm, index, hash2(TAG_METHOD_HANDLE, refKind, reference.index())); this.refKind = refKind; this.reference = reference; } + @Override + public byte tag() { + return TAG_METHOD_HANDLE; + } + @Override public int kind() { return refKind; @@ -912,14 +983,12 @@ public abstract sealed class AbstractPoolEntry { @Override void writeTo(BufWriterImpl pool) { - pool.writeU1(tag); - pool.writeU1(refKind); - pool.writeU2(reference.index()); + pool.writeU1U1U2(TAG_METHOD_HANDLE, refKind, reference.index()); } @Override public MethodHandleEntry clone(ConstantPoolBuilder cp) { - return cp.canWriteDirect(constantPool) ? this : cp.methodHandleEntry(refKind, reference); + return cp.methodHandleEntry(refKind, reference); } @Override @@ -943,10 +1012,13 @@ public abstract sealed class AbstractPoolEntry { extends AbstractRefEntry implements MethodTypeEntry { - public MethodTypeDesc sym = null; - MethodTypeEntryImpl(ConstantPool cpm, int index, Utf8EntryImpl descriptor) { - super(cpm, ClassFile.TAG_METHODTYPE, index, descriptor); + super(cpm, TAG_METHOD_TYPE, index, descriptor); + } + + @Override + public byte tag() { + return TAG_METHOD_TYPE; } @Override @@ -956,22 +1028,12 @@ public abstract sealed class AbstractPoolEntry { @Override public MethodTypeEntry clone(ConstantPoolBuilder cp) { - if (cp.canWriteDirect(constantPool)) { - return this; - } else { - var ret = (MethodTypeEntryImpl)cp.methodTypeEntry(ref1); - ret.sym = sym; - return ret; - } + return cp.methodTypeEntry(ref1); } @Override public MethodTypeDesc asSymbol() { - var sym = this.sym; - if (sym != null) { - return sym; - } - return this.sym = MethodTypeDesc.ofDescriptor(descriptor().stringValue()); + return ref1.methodTypeSymbol(); } @Override @@ -989,7 +1051,12 @@ public abstract sealed class AbstractPoolEntry { implements StringEntry { StringEntryImpl(ConstantPool cpm, int index, Utf8EntryImpl utf8) { - super(cpm, ClassFile.TAG_STRING, index, utf8); + super(cpm, TAG_STRING, index, utf8); + } + + @Override + public byte tag() { + return TAG_STRING; } @Override @@ -1009,7 +1076,7 @@ public abstract sealed class AbstractPoolEntry { @Override public StringEntry clone(ConstantPoolBuilder cp) { - return cp.canWriteDirect(constantPool) ? this : cp.stringEntry(ref1); + return cp.stringEntry(ref1); } @Override @@ -1035,19 +1102,24 @@ public abstract sealed class AbstractPoolEntry { private final int val; IntegerEntryImpl(ConstantPool cpm, int index, int i) { - super(cpm, ClassFile.TAG_INTEGER, index, hash1(ClassFile.TAG_INTEGER, Integer.hashCode(i))); + super(cpm, index, hash1(TAG_INTEGER, Integer.hashCode(i))); val = i; } + @Override + public byte tag() { + return TAG_INTEGER; + } + @Override void writeTo(BufWriterImpl pool) { - pool.writeU1(tag); + pool.writeU1(TAG_INTEGER); pool.writeInt(val); } @Override public IntegerEntry clone(ConstantPoolBuilder cp) { - return cp.canWriteDirect(constantPool) ? this : cp.intEntry(val); + return cp.intEntry(val); } @Override @@ -1076,19 +1148,24 @@ public abstract sealed class AbstractPoolEntry { private final float val; FloatEntryImpl(ConstantPool cpm, int index, float f) { - super(cpm, ClassFile.TAG_FLOAT, index, hash1(ClassFile.TAG_FLOAT, Float.hashCode(f))); + super(cpm, index, hash1(TAG_FLOAT, Float.hashCode(f))); val = f; } + @Override + public byte tag() { + return TAG_FLOAT; + } + @Override void writeTo(BufWriterImpl pool) { - pool.writeU1(tag); + pool.writeU1(TAG_FLOAT); pool.writeFloat(val); } @Override public FloatEntry clone(ConstantPoolBuilder cp) { - return cp.canWriteDirect(constantPool) ? this : cp.floatEntry(val); + return cp.floatEntry(val); } @Override @@ -1116,19 +1193,29 @@ public abstract sealed class AbstractPoolEntry { private final long val; LongEntryImpl(ConstantPool cpm, int index, long l) { - super(cpm, ClassFile.TAG_LONG, index, hash1(ClassFile.TAG_LONG, Long.hashCode(l))); + super(cpm, index, hash1(TAG_LONG, Long.hashCode(l))); val = l; } + @Override + public byte tag() { + return TAG_LONG; + } + + @Override + public int width() { + return 2; + } + @Override void writeTo(BufWriterImpl pool) { - pool.writeU1(tag); + pool.writeU1(TAG_LONG); pool.writeLong(val); } @Override public LongEntry clone(ConstantPoolBuilder cp) { - return cp.canWriteDirect(constantPool) ? this : cp.longEntry(val); + return cp.longEntry(val); } @Override @@ -1156,19 +1243,29 @@ public abstract sealed class AbstractPoolEntry { private final double val; DoubleEntryImpl(ConstantPool cpm, int index, double d) { - super(cpm, ClassFile.TAG_DOUBLE, index, hash1(ClassFile.TAG_DOUBLE, Double.hashCode(d))); + super(cpm, index, hash1(TAG_DOUBLE, Double.hashCode(d))); val = d; } + @Override + public byte tag() { + return TAG_DOUBLE; + } + + @Override + public int width() { + return 2; + } + @Override void writeTo(BufWriterImpl pool) { - pool.writeU1(tag); + pool.writeU1(TAG_DOUBLE); pool.writeDouble(val); } @Override public DoubleEntry clone(ConstantPoolBuilder cp) { - return cp.canWriteDirect(constantPool) ? this : cp.doubleEntry(val); + return cp.doubleEntry(val); } @Override @@ -1190,12 +1287,4 @@ public abstract sealed class AbstractPoolEntry { return false; } } - - static class CpException extends RuntimeException { - static final long serialVersionUID = 32L; - - CpException(String s) { - super(s); - } - } } diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/AbstractPseudoInstruction.java b/src/java.base/share/classes/jdk/internal/classfile/impl/AbstractPseudoInstruction.java index 00d817b8cb0..596379305a9 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/impl/AbstractPseudoInstruction.java +++ b/src/java.base/share/classes/jdk/internal/classfile/impl/AbstractPseudoInstruction.java @@ -36,6 +36,8 @@ import java.lang.classfile.instruction.LocalVariableType; import java.lang.classfile.Label; import java.lang.classfile.PseudoInstruction; +import static java.util.Objects.requireNonNull; + public abstract sealed class AbstractPseudoInstruction extends AbstractElement implements PseudoInstruction { @@ -55,17 +57,14 @@ public abstract sealed class AbstractPseudoInstruction public ExceptionCatchImpl(Label handler, Label tryStart, Label tryEnd, ClassEntry catchTypeEntry) { this.catchTypeEntry = catchTypeEntry; - this.handler = handler; - this.tryStart = tryStart; - this.tryEnd = tryEnd; + this.handler = requireNonNull(handler); + this.tryStart = requireNonNull(tryStart); + this.tryEnd = requireNonNull(tryEnd); } public ExceptionCatchImpl(Label handler, Label tryStart, Label tryEnd, Optional catchTypeEntry) { - this.catchTypeEntry = catchTypeEntry.orElse(null); - this.handler = handler; - this.tryStart = tryStart; - this.tryEnd = tryEnd; + this(handler, tryStart, tryEnd, catchTypeEntry.orElse(null)); } @Override @@ -115,8 +114,8 @@ public abstract sealed class AbstractPseudoInstruction public UnboundCharacterRange(Label startScope, Label endScope, int characterRangeStart, int characterRangeEnd, int flags) { - this.startScope = startScope; - this.endScope = endScope; + this.startScope = requireNonNull(startScope); + this.endScope = requireNonNull(endScope); this.characterRangeStart = characterRangeStart; this.characterRangeEnd = characterRangeEnd; this.flags = flags; @@ -163,11 +162,12 @@ public abstract sealed class AbstractPseudoInstruction protected final Label endScope; public AbstractLocalPseudo(int slot, Utf8Entry name, Utf8Entry descriptor, Label startScope, Label endScope) { + BytecodeHelpers.validateSlot(slot); this.slot = slot; - this.name = name; - this.descriptor = descriptor; - this.startScope = startScope; - this.endScope = endScope; + this.name = requireNonNull(name); + this.descriptor = requireNonNull(descriptor); + this.startScope = requireNonNull(startScope); + this.endScope = requireNonNull(endScope); } public int slot() { @@ -199,11 +199,8 @@ public abstract sealed class AbstractPseudoInstruction return false; } int length = endBci - startBci; - b.writeU2(startBci); - b.writeU2(length); - b.writeIndex(name); - b.writeIndex(descriptor); - b.writeU2(slot()); + b.writeU2U2(startBci, length); + b.writeU2U2U2(b.cpIndex(name), b.cpIndex(descriptor), slot()); return true; } } diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/AnnotationImpl.java b/src/java.base/share/classes/jdk/internal/classfile/impl/AnnotationImpl.java index b2c67795fc4..f1c7e6aaf65 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/impl/AnnotationImpl.java +++ b/src/java.base/share/classes/jdk/internal/classfile/impl/AnnotationImpl.java @@ -29,11 +29,12 @@ import java.lang.classfile.constantpool.*; import java.util.List; -import static java.lang.classfile.ClassFile.*; +import static java.util.Objects.requireNonNull; public record AnnotationImpl(Utf8Entry className, List elements) implements Annotation { public AnnotationImpl { + requireNonNull(className); elements = List.copyOf(elements); } @@ -52,6 +53,11 @@ public record AnnotationImpl(Utf8Entry className, List elemen public record AnnotationElementImpl(Utf8Entry name, AnnotationValue value) implements AnnotationElement { + public AnnotationElementImpl { + requireNonNull(name); + requireNonNull(value); + } + @Override public String toString() { return name + "=" + value; @@ -62,7 +68,7 @@ public record AnnotationImpl(Utf8Entry className, List elemen implements AnnotationValue.OfString { @Override public char tag() { - return AEV_STRING; + return TAG_STRING; } @Override @@ -75,7 +81,7 @@ public record AnnotationImpl(Utf8Entry className, List elemen implements AnnotationValue.OfDouble { @Override public char tag() { - return AEV_DOUBLE; + return TAG_DOUBLE; } @Override @@ -88,7 +94,7 @@ public record AnnotationImpl(Utf8Entry className, List elemen implements AnnotationValue.OfFloat { @Override public char tag() { - return AEV_FLOAT; + return TAG_FLOAT; } @Override @@ -101,7 +107,7 @@ public record AnnotationImpl(Utf8Entry className, List elemen implements AnnotationValue.OfLong { @Override public char tag() { - return AEV_LONG; + return TAG_LONG; } @Override @@ -114,7 +120,7 @@ public record AnnotationImpl(Utf8Entry className, List elemen implements AnnotationValue.OfInt { @Override public char tag() { - return AEV_INT; + return TAG_INT; } @Override @@ -127,7 +133,7 @@ public record AnnotationImpl(Utf8Entry className, List elemen implements AnnotationValue.OfShort { @Override public char tag() { - return AEV_SHORT; + return TAG_SHORT; } @Override @@ -140,7 +146,7 @@ public record AnnotationImpl(Utf8Entry className, List elemen implements AnnotationValue.OfChar { @Override public char tag() { - return AEV_CHAR; + return TAG_CHAR; } @Override @@ -153,7 +159,7 @@ public record AnnotationImpl(Utf8Entry className, List elemen implements AnnotationValue.OfByte { @Override public char tag() { - return AEV_BYTE; + return TAG_BYTE; } @Override @@ -166,7 +172,7 @@ public record AnnotationImpl(Utf8Entry className, List elemen implements AnnotationValue.OfBoolean { @Override public char tag() { - return AEV_BOOLEAN; + return TAG_BOOLEAN; } @Override @@ -183,7 +189,7 @@ public record AnnotationImpl(Utf8Entry className, List elemen @Override public char tag() { - return AEV_ARRAY; + return TAG_ARRAY; } } @@ -191,7 +197,7 @@ public record AnnotationImpl(Utf8Entry className, List elemen implements AnnotationValue.OfEnum { @Override public char tag() { - return AEV_ENUM; + return TAG_ENUM; } } @@ -199,7 +205,7 @@ public record AnnotationImpl(Utf8Entry className, List elemen implements AnnotationValue.OfAnnotation { @Override public char tag() { - return AEV_ANNOTATION; + return TAG_ANNOTATION; } } @@ -207,7 +213,7 @@ public record AnnotationImpl(Utf8Entry className, List elemen implements AnnotationValue.OfClass { @Override public char tag() { - return AEV_CLASS; + return TAG_CLASS; } } } diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/AnnotationReader.java b/src/java.base/share/classes/jdk/internal/classfile/impl/AnnotationReader.java index 69511131b37..9724cff35ad 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/impl/AnnotationReader.java +++ b/src/java.base/share/classes/jdk/internal/classfile/impl/AnnotationReader.java @@ -32,7 +32,8 @@ import java.lang.classfile.BufWriter; import java.lang.classfile.ClassReader; import java.lang.classfile.constantpool.*; import java.lang.classfile.TypeAnnotation; -import static java.lang.classfile.ClassFile.*; + +import static java.lang.classfile.AnnotationValue.*; import static java.lang.classfile.TypeAnnotation.TargetInfo.*; import java.util.List; @@ -59,20 +60,20 @@ public final class AnnotationReader { char tag = (char) classReader.readU1(p); ++p; return switch (tag) { - case AEV_BYTE -> new AnnotationImpl.OfByteImpl(classReader.readEntry(p, IntegerEntry.class)); - case AEV_CHAR -> new AnnotationImpl.OfCharImpl(classReader.readEntry(p, IntegerEntry.class)); - case AEV_DOUBLE -> new AnnotationImpl.OfDoubleImpl(classReader.readEntry(p, DoubleEntry.class)); - case AEV_FLOAT -> new AnnotationImpl.OfFloatImpl(classReader.readEntry(p, FloatEntry.class)); - case AEV_INT -> new AnnotationImpl.OfIntImpl(classReader.readEntry(p, IntegerEntry.class)); - case AEV_LONG -> new AnnotationImpl.OfLongImpl(classReader.readEntry(p, LongEntry.class)); - case AEV_SHORT -> new AnnotationImpl.OfShortImpl(classReader.readEntry(p, IntegerEntry.class)); - case AEV_BOOLEAN -> new AnnotationImpl.OfBooleanImpl(classReader.readEntry(p, IntegerEntry.class)); - case AEV_STRING -> new AnnotationImpl.OfStringImpl(classReader.readEntry(p, Utf8Entry.class)); - case AEV_ENUM -> new AnnotationImpl.OfEnumImpl(classReader.readEntry(p, Utf8Entry.class), + case TAG_BYTE -> new AnnotationImpl.OfByteImpl(classReader.readEntry(p, IntegerEntry.class)); + case TAG_CHAR -> new AnnotationImpl.OfCharImpl(classReader.readEntry(p, IntegerEntry.class)); + case TAG_DOUBLE -> new AnnotationImpl.OfDoubleImpl(classReader.readEntry(p, DoubleEntry.class)); + case TAG_FLOAT -> new AnnotationImpl.OfFloatImpl(classReader.readEntry(p, FloatEntry.class)); + case TAG_INT -> new AnnotationImpl.OfIntImpl(classReader.readEntry(p, IntegerEntry.class)); + case TAG_LONG -> new AnnotationImpl.OfLongImpl(classReader.readEntry(p, LongEntry.class)); + case TAG_SHORT -> new AnnotationImpl.OfShortImpl(classReader.readEntry(p, IntegerEntry.class)); + case TAG_BOOLEAN -> new AnnotationImpl.OfBooleanImpl(classReader.readEntry(p, IntegerEntry.class)); + case TAG_STRING -> new AnnotationImpl.OfStringImpl(classReader.readEntry(p, Utf8Entry.class)); + case TAG_ENUM -> new AnnotationImpl.OfEnumImpl(classReader.readEntry(p, Utf8Entry.class), classReader.readEntry(p + 2, Utf8Entry.class)); - case AEV_CLASS -> new AnnotationImpl.OfClassImpl(classReader.readEntry(p, Utf8Entry.class)); - case AEV_ANNOTATION -> new AnnotationImpl.OfAnnotationImpl(readAnnotation(classReader, p)); - case AEV_ARRAY -> { + case TAG_CLASS -> new AnnotationImpl.OfClassImpl(classReader.readEntry(p, Utf8Entry.class)); + case TAG_ANNOTATION -> new AnnotationImpl.OfAnnotationImpl(readAnnotation(classReader, p)); + case TAG_ARRAY -> { int numValues = classReader.readU2(p); p += 2; var values = new Object[numValues]; @@ -179,49 +180,49 @@ public final class AnnotationReader { private static TypeAnnotation readTypeAnnotation(ClassReader classReader, int p, LabelContext lc) { int targetType = classReader.readU1(p++); var targetInfo = switch (targetType) { - case TAT_CLASS_TYPE_PARAMETER -> + case TARGET_CLASS_TYPE_PARAMETER -> ofClassTypeParameter(classReader.readU1(p)); - case TAT_METHOD_TYPE_PARAMETER -> + case TARGET_METHOD_TYPE_PARAMETER -> ofMethodTypeParameter(classReader.readU1(p)); - case TAT_CLASS_EXTENDS -> + case TARGET_CLASS_EXTENDS -> ofClassExtends(classReader.readU2(p)); - case TAT_CLASS_TYPE_PARAMETER_BOUND -> + case TARGET_CLASS_TYPE_PARAMETER_BOUND -> ofClassTypeParameterBound(classReader.readU1(p), classReader.readU1(p + 1)); - case TAT_METHOD_TYPE_PARAMETER_BOUND -> + case TARGET_METHOD_TYPE_PARAMETER_BOUND -> ofMethodTypeParameterBound(classReader.readU1(p), classReader.readU1(p + 1)); - case TAT_FIELD -> + case TARGET_FIELD -> ofField(); - case TAT_METHOD_RETURN -> + case TARGET_METHOD_RETURN -> ofMethodReturn(); - case TAT_METHOD_RECEIVER -> + case TARGET_METHOD_RECEIVER -> ofMethodReceiver(); - case TAT_METHOD_FORMAL_PARAMETER -> + case TARGET_METHOD_FORMAL_PARAMETER -> ofMethodFormalParameter(classReader.readU1(p)); - case TAT_THROWS -> + case TARGET_THROWS -> ofThrows(classReader.readU2(p)); - case TAT_LOCAL_VARIABLE -> + case TARGET_LOCAL_VARIABLE -> ofLocalVariable(readLocalVarEntries(classReader, p, lc, targetType)); - case TAT_RESOURCE_VARIABLE -> + case TARGET_RESOURCE_VARIABLE -> ofResourceVariable(readLocalVarEntries(classReader, p, lc, targetType)); - case TAT_EXCEPTION_PARAMETER -> + case TARGET_EXCEPTION_PARAMETER -> ofExceptionParameter(classReader.readU2(p)); - case TAT_INSTANCEOF -> + case TARGET_INSTANCEOF -> ofInstanceofExpr(getLabel(lc, classReader.readU2(p), targetType, p)); - case TAT_NEW -> + case TARGET_NEW -> ofNewExpr(getLabel(lc, classReader.readU2(p), targetType, p)); - case TAT_CONSTRUCTOR_REFERENCE -> + case TARGET_CONSTRUCTOR_REFERENCE -> ofConstructorReference(getLabel(lc, classReader.readU2(p), targetType, p)); - case TAT_METHOD_REFERENCE -> + case TARGET_METHOD_REFERENCE -> ofMethodReference(getLabel(lc, classReader.readU2(p), targetType, p)); - case TAT_CAST -> + case TARGET_CAST -> ofCastExpr(getLabel(lc, classReader.readU2(p), targetType, p), classReader.readU1(p + 2)); - case TAT_CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT -> + case TARGET_CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT -> ofConstructorInvocationTypeArgument(getLabel(lc, classReader.readU2(p), targetType, p), classReader.readU1(p + 2)); - case TAT_METHOD_INVOCATION_TYPE_ARGUMENT -> + case TARGET_METHOD_INVOCATION_TYPE_ARGUMENT -> ofMethodInvocationTypeArgument(getLabel(lc, classReader.readU2(p), targetType, p), classReader.readU1(p + 2)); - case TAT_CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT -> + case TARGET_CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT -> ofConstructorReferenceTypeArgument(getLabel(lc, classReader.readU2(p), targetType, p), classReader.readU1(p + 2)); - case TAT_METHOD_REFERENCE_TYPE_ARGUMENT -> + case TARGET_METHOD_REFERENCE_TYPE_ARGUMENT -> ofMethodReferenceTypeArgument(getLabel(lc, classReader.readU2(p), targetType, p), classReader.readU1(p + 2)); default -> throw new IllegalArgumentException("Unexpected targetType '%d' in TypeAnnotation, pos = %d".formatted(targetType, p - 1)); @@ -281,9 +282,8 @@ public final class AnnotationReader { } public static void writeAnnotation(BufWriterImpl buf, Annotation annotation) { - buf.writeIndex(annotation.className()); var elements = annotation.elements(); - buf.writeU2(elements.size()); + buf.writeU2U2(buf.cpIndex(annotation.className()), elements.size()); for (var e : elements) { buf.writeIndex(e.name()); AnnotationReader.writeAnnotationValue(buf, e.value()); @@ -314,8 +314,7 @@ public final class AnnotationReader { case TypeAnnotation.TypeParameterTarget tpt -> buf.writeU1(tpt.typeParameterIndex()); case TypeAnnotation.SupertypeTarget st -> buf.writeU2(st.supertypeIndex()); case TypeAnnotation.TypeParameterBoundTarget tpbt -> { - buf.writeU1(tpbt.typeParameterIndex()); - buf.writeU1(tpbt.boundIndex()); + buf.writeU1U1(tpbt.typeParameterIndex(), tpbt.boundIndex()); } case TypeAnnotation.EmptyTarget _ -> { // nothing to write @@ -326,24 +325,21 @@ public final class AnnotationReader { buf.writeU2(lvt.table().size()); for (var e : lvt.table()) { int startPc = labelToBci(lr, e.startLabel(), ta); - buf.writeU2(startPc); - buf.writeU2(labelToBci(lr, e.endLabel(), ta) - startPc); - buf.writeU2(e.index()); + buf.writeU2U2U2(startPc, labelToBci(lr, e.endLabel(), ta) - startPc, e.index()); } } case TypeAnnotation.CatchTarget ct -> buf.writeU2(ct.exceptionTableIndex()); case TypeAnnotation.OffsetTarget ot -> buf.writeU2(labelToBci(lr, ot.target(), ta)); case TypeAnnotation.TypeArgumentTarget tat -> { - buf.writeU2(labelToBci(lr, tat.target(), ta)); - buf.writeU1(tat.typeArgumentIndex()); + buf.writeU2U1(labelToBci(lr, tat.target(), ta), + tat.typeArgumentIndex()); } } // target_path buf.writeU1(ta.targetPath().size()); for (TypeAnnotation.TypePathComponent component : ta.targetPath()) { - buf.writeU1(component.typePathKind().tag()); - buf.writeU1(component.typeArgumentIndex()); + buf.writeU1U1(component.typePathKind().tag(), component.typeArgumentIndex()); } // annotation data @@ -362,16 +358,16 @@ public final class AnnotationReader { var tag = value.tag(); buf.writeU1(tag); switch (value.tag()) { - case AEV_BOOLEAN, AEV_BYTE, AEV_CHAR, AEV_DOUBLE, AEV_FLOAT, AEV_INT, AEV_LONG, AEV_SHORT, AEV_STRING -> + case TAG_BOOLEAN, TAG_BYTE, TAG_CHAR, TAG_DOUBLE, TAG_FLOAT, TAG_INT, TAG_LONG, TAG_SHORT, TAG_STRING -> buf.writeIndex(((AnnotationValue.OfConstant) value).constant()); - case AEV_CLASS -> buf.writeIndex(((AnnotationValue.OfClass) value).className()); - case AEV_ENUM -> { + case TAG_CLASS -> buf.writeIndex(((AnnotationValue.OfClass) value).className()); + case TAG_ENUM -> { var enumValue = (AnnotationValue.OfEnum) value; buf.writeIndex(enumValue.className()); buf.writeIndex(enumValue.constantName()); } - case AEV_ANNOTATION -> writeAnnotation(buf, ((AnnotationValue.OfAnnotation) value).annotation()); - case AEV_ARRAY -> { + case TAG_ANNOTATION -> writeAnnotation(buf, ((AnnotationValue.OfAnnotation) value).annotation()); + case TAG_ARRAY -> { var array = ((AnnotationValue.OfArray) value).values(); buf.writeU2(array.size()); for (var e : array) { diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/AttributeHolder.java b/src/java.base/share/classes/jdk/internal/classfile/impl/AttributeHolder.java index fb9ecc98902..6060170a8d1 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/impl/AttributeHolder.java +++ b/src/java.base/share/classes/jdk/internal/classfile/impl/AttributeHolder.java @@ -24,14 +24,15 @@ */ package jdk.internal.classfile.impl; -import java.util.ArrayList; -import java.util.List; +import java.util.Arrays; import java.lang.classfile.Attribute; import java.lang.classfile.AttributeMapper; public class AttributeHolder { - private final List> attributes = new ArrayList<>(); + private static final Attribute[] EMPTY_ATTRIBUTE_ARRAY = {}; + private int attributesCount = 0; + private Attribute[] attributes = EMPTY_ATTRIBUTE_ARRAY; public > void withAttribute(Attribute a) { if (a == null) @@ -39,36 +40,54 @@ public class AttributeHolder { @SuppressWarnings("unchecked") AttributeMapper am = (AttributeMapper) a.attributeMapper(); - if (!am.allowMultiple() && isPresent(am)) { - remove(am); + int attributesCount = this.attributesCount; + var attributes = this.attributes; + if (!am.allowMultiple()) { + // remove if + for (int i = attributesCount - 1; i >= 0; i--) { + if (attributes[i].attributeMapper() == am) { + attributesCount--; + System.arraycopy(attributes, i + 1, attributes, i, attributesCount - i); + } + } } - attributes.add(a); + + // add attribute + if (attributesCount >= attributes.length) { + int newCapacity = attributesCount + 4; + this.attributes = attributes = Arrays.copyOf(attributes, newCapacity); + } + attributes[attributesCount] = a; + this.attributesCount = attributesCount + 1; } public int size() { - return attributes.size(); + return attributesCount; } public void writeTo(BufWriterImpl buf) { - Util.writeAttributes(buf, attributes); + int attributesCount = this.attributesCount; + buf.writeU2(attributesCount); + for (int i = 0; i < attributesCount; i++) { + Util.writeAttribute(buf, attributes[i]); + } } @SuppressWarnings("unchecked") > A get(AttributeMapper am) { - for (Attribute a : attributes) + for (int i = 0; i < attributesCount; i++) { + Attribute a = attributes[i]; if (a.attributeMapper() == am) - return (A)a; + return (A) a; + } return null; } boolean isPresent(AttributeMapper am) { - for (Attribute a : attributes) - if (a.attributeMapper() == am) + for (int i = 0; i < attributesCount; i++) { + if (attributes[i].attributeMapper() == am) return true; + } return false; } - - private void remove(AttributeMapper am) { - attributes.removeIf(a -> a.attributeMapper() == am); - } } diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/BlockCodeBuilderImpl.java b/src/java.base/share/classes/jdk/internal/classfile/impl/BlockCodeBuilderImpl.java index 66e974b4a51..2fdc9f36426 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/impl/BlockCodeBuilderImpl.java +++ b/src/java.base/share/classes/jdk/internal/classfile/impl/BlockCodeBuilderImpl.java @@ -33,6 +33,8 @@ import java.lang.classfile.instruction.LabelTarget; import java.util.Objects; import java.lang.classfile.Instruction; +import static java.util.Objects.requireNonNull; + public final class BlockCodeBuilderImpl extends NonterminalCodeBuilder implements CodeBuilder.BlockCodeBuilder { @@ -80,12 +82,12 @@ public final class BlockCodeBuilderImpl @Override public CodeBuilder with(CodeElement element) { - parent.with(element); + parent.with(requireNonNull(element)); hasInstructions |= element instanceof Instruction; if (reachable) { - if (element instanceof Instruction i && i.opcode().isUnconditionalBranch()) + if (element instanceof Instruction i && BytecodeHelpers.isUnconditionalBranch(i.opcode())) reachable = false; } else if (element instanceof LabelTarget) { diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/BoundLocalVariable.java b/src/java.base/share/classes/jdk/internal/classfile/impl/BoundLocalVariable.java index a5953c86f5d..3bbcd243cc1 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/impl/BoundLocalVariable.java +++ b/src/java.base/share/classes/jdk/internal/classfile/impl/BoundLocalVariable.java @@ -46,7 +46,7 @@ public final class BoundLocalVariable @Override public ClassDesc typeSymbol() { - return ClassDesc.ofDescriptor(type().stringValue()); + return Util.fieldTypeSymbol(type()); } @Override diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/BufWriterImpl.java b/src/java.base/share/classes/jdk/internal/classfile/impl/BufWriterImpl.java index 255e5e21cf0..91b3b32190b 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/impl/BufWriterImpl.java +++ b/src/java.base/share/classes/jdk/internal/classfile/impl/BufWriterImpl.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, Alibaba Group Holding Limited. 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 @@ -25,7 +26,6 @@ package jdk.internal.classfile.impl; -import java.nio.ByteBuffer; import java.util.Arrays; import java.lang.classfile.BufWriter; @@ -34,7 +34,16 @@ import java.lang.classfile.constantpool.ConstantPool; import java.lang.classfile.constantpool.ConstantPoolBuilder; import java.lang.classfile.constantpool.PoolEntry; +import jdk.internal.access.JavaLangAccess; +import jdk.internal.access.SharedSecrets; +import jdk.internal.vm.annotation.ForceInline; + +import static java.lang.classfile.constantpool.PoolEntry.TAG_UTF8; +import static jdk.internal.util.ModifiedUtf.putChar; +import static jdk.internal.util.ModifiedUtf.utfLen; + public final class BufWriterImpl implements BufWriter { + private static final JavaLangAccess JLA = SharedSecrets.getJavaLangAccess(); private final ConstantPoolBuilder constantPool; private final ClassFileImpl context; @@ -95,6 +104,7 @@ public final class BufWriterImpl implements BufWriter { elems[offset++] = (byte) x; } + @ForceInline @Override public void writeU2(int x) { reserveSpace(2); @@ -105,6 +115,93 @@ public final class BufWriterImpl implements BufWriter { this.offset = offset + 2; } + @ForceInline + public void writeU1U1(int x1, int x2) { + reserveSpace(2); + byte[] elems = this.elems; + int offset = this.offset; + elems[offset ] = (byte) x1; + elems[offset + 1] = (byte) x2; + this.offset = offset + 2; + } + + public void writeU1U2(int u1, int u2) { + reserveSpace(3); + byte[] elems = this.elems; + int offset = this.offset; + elems[offset ] = (byte) u1; + elems[offset + 1] = (byte) (u2 >> 8); + elems[offset + 2] = (byte) u2; + this.offset = offset + 3; + } + + public void writeU1U1U1(int x1, int x2, int x3) { + reserveSpace(3); + byte[] elems = this.elems; + int offset = this.offset; + elems[offset ] = (byte) x1; + elems[offset + 1] = (byte) x2; + elems[offset + 2] = (byte) x3; + this.offset = offset + 3; + } + + public void writeU1U1U2(int x1, int x2, int x3) { + reserveSpace(4); + byte[] elems = this.elems; + int offset = this.offset; + elems[offset ] = (byte) x1; + elems[offset + 1] = (byte) x2; + elems[offset + 2] = (byte) (x3 >> 8); + elems[offset + 3] = (byte) x3; + this.offset = offset + 4; + } + + public void writeU1U2U2(int x1, int x2, int x3) { + reserveSpace(5); + byte[] elems = this.elems; + int offset = this.offset; + elems[offset ] = (byte) x1; + elems[offset + 1] = (byte) (x2 >> 8); + elems[offset + 2] = (byte) x2; + elems[offset + 3] = (byte) (x3 >> 8); + elems[offset + 4] = (byte) x3; + this.offset = offset + 5; + } + + public void writeU2U1(int x1, int x2) { + reserveSpace(3); + byte[] elems = this.elems; + int offset = this.offset; + elems[offset ] = (byte) (x1 >> 8); + elems[offset + 1] = (byte) x1; + elems[offset + 2] = (byte) x2; + this.offset = offset + 3; + } + + public void writeU2U2(int x1, int x2) { + reserveSpace(4); + byte[] elems = this.elems; + int offset = this.offset; + elems[offset ] = (byte) (x1 >> 8); + elems[offset + 1] = (byte) x1; + elems[offset + 2] = (byte) (x2 >> 8); + elems[offset + 3] = (byte) x2; + this.offset = offset + 4; + } + + public void writeU2U2U2(int x1, int x2, int x3) { + reserveSpace(6); + byte[] elems = this.elems; + int offset = this.offset; + elems[offset ] = (byte) (x1 >> 8); + elems[offset + 1] = (byte) x1; + elems[offset + 2] = (byte) (x2 >> 8); + elems[offset + 3] = (byte) x2; + elems[offset + 4] = (byte) (x3 >> 8); + elems[offset + 5] = (byte) x3; + this.offset = offset + 6; + } + @Override public void writeInt(int x) { reserveSpace(4); @@ -117,6 +214,21 @@ public final class BufWriterImpl implements BufWriter { this.offset = offset + 4; } + public void writeIntInt(int x1, int x2) { + reserveSpace(8); + byte[] elems = this.elems; + int offset = this.offset; + elems[offset ] = (byte) (x1 >> 24); + elems[offset + 1] = (byte) (x1 >> 16); + elems[offset + 2] = (byte) (x1 >> 8); + elems[offset + 3] = (byte) x1; + elems[offset + 4] = (byte) (x2 >> 24); + elems[offset + 5] = (byte) (x2 >> 16); + elems[offset + 6] = (byte) (x2 >> 8); + elems[offset + 7] = (byte) x2; + this.offset = offset + 8; + } + @Override public void writeFloat(float x) { writeInt(Float.floatToIntBits(x)); @@ -152,6 +264,34 @@ public final class BufWriterImpl implements BufWriter { writeBytes(other.elems, 0, other.offset); } + @SuppressWarnings("deprecation") + void writeUtfEntry(String str) { + int strlen = str.length(); + int countNonZeroAscii = JLA.countNonZeroAscii(str); + int utflen = utfLen(str, countNonZeroAscii); + if (utflen > 65535) { + throw new IllegalArgumentException("string too long"); + } + reserveSpace(utflen + 3); + + int offset = this.offset; + byte[] elems = this.elems; + + elems[offset ] = (byte) TAG_UTF8; + elems[offset + 1] = (byte) (utflen >> 8); + elems[offset + 2] = (byte) utflen; + offset += 3; + + str.getBytes(0, countNonZeroAscii, elems, offset); + offset += countNonZeroAscii; + + for (int i = countNonZeroAscii; i < strlen; i++) { + offset = putChar(elems, offset, str.charAt(i)); + } + + this.offset = offset; + } + @Override public void writeBytes(byte[] arr, int start, int length) { reserveSpace(length); @@ -167,6 +307,20 @@ public final class BufWriterImpl implements BufWriter { this.offset = prevOffset; } + public void patchU2(int offset, int x) { + byte[] elems = this.elems; + elems[offset ] = (byte) (x >> 8); + elems[offset + 1] = (byte) x; + } + + public void patchInt(int offset, int x) { + byte[] elems = this.elems; + elems[offset ] = (byte) (x >> 24); + elems[offset + 1] = (byte) (x >> 16); + elems[offset + 2] = (byte) (x >> 8); + elems[offset + 3] = (byte) x; + } + @Override public void writeIntBytes(int intSize, long intValue) { reserveSpace(intSize); @@ -175,6 +329,18 @@ public final class BufWriterImpl implements BufWriter { } } + /** + * Skip a few bytes in the output buffer. The skipped area has undefined value. + * @param bytes number of bytes to skip + * @return the index, for later patching + */ + public int skip(int bytes) { + int now = offset; + reserveSpace(bytes); + offset += bytes; + return now; + } + @Override public void reserveSpace(int freeBytes) { int minCapacity = offset + freeBytes; @@ -196,8 +362,8 @@ public final class BufWriterImpl implements BufWriter { return offset; } - public ByteBuffer asByteBuffer() { - return ByteBuffer.wrap(elems, 0, offset).slice(); + public RawBytecodeHelper.CodeRange bytecodeView() { + return RawBytecodeHelper.of(elems, offset); } public void copyTo(byte[] array, int bufferOffset) { @@ -207,19 +373,45 @@ public final class BufWriterImpl implements BufWriter { // writeIndex methods ensure that any CP info written // is relative to the correct constant pool - @Override - public void writeIndex(PoolEntry entry) { + public int cpIndex(PoolEntry entry) { int idx = AbstractPoolEntry.maybeClone(constantPool, entry).index(); if (idx < 1 || idx > Character.MAX_VALUE) - throw new IllegalArgumentException(idx + " is not a valid index. Entry: " + entry); - writeU2(idx); + throw invalidIndex(idx, entry); + return idx; + } + + public int cpIndexOrZero(PoolEntry entry) { + if (entry == null || entry.index() == 0) + return 0; + return cpIndex(entry); + } + + @ForceInline + @Override + public void writeIndex(PoolEntry entry) { + writeU2(cpIndex(entry)); + } + + public void writeIndex(int bytecode, PoolEntry entry) { + writeU1U2(bytecode, cpIndex(entry)); + } + + static IllegalArgumentException invalidIndex(int idx, PoolEntry entry) { + return new IllegalArgumentException(idx + " is not a valid index. Entry: " + entry); } @Override public void writeIndexOrZero(PoolEntry entry) { - if (entry == null || entry.index() == 0) - writeU2(0); - else - writeIndex(entry); + writeU2(cpIndexOrZero(entry)); + } + + /** + * Join head and tail into an exact-size buffer + */ + static byte[] join(BufWriterImpl head, BufWriterImpl tail) { + byte[] result = new byte[head.size() + tail.size()]; + head.copyTo(result, 0); + tail.copyTo(result, head.size()); + return result; } } diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/BufferedCodeBuilder.java b/src/java.base/share/classes/jdk/internal/classfile/impl/BufferedCodeBuilder.java index c506d265f68..4ed458c3983 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/impl/BufferedCodeBuilder.java +++ b/src/java.base/share/classes/jdk/internal/classfile/impl/BufferedCodeBuilder.java @@ -38,6 +38,8 @@ import java.util.List; import java.util.Optional; import java.util.function.Consumer; +import static java.util.Objects.requireNonNull; + public final class BufferedCodeBuilder implements TerminalCodeBuilder { private final SplitConstantPool constantPool; @@ -121,7 +123,7 @@ public final class BufferedCodeBuilder public CodeBuilder with(CodeElement element) { if (finished) throw new IllegalStateException("Can't add elements after traversal"); - elements.add(element); + elements.add(requireNonNull(element)); return this; } diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/BufferedFieldBuilder.java b/src/java.base/share/classes/jdk/internal/classfile/impl/BufferedFieldBuilder.java index 8cf274d746c..0578cf85c4c 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/impl/BufferedFieldBuilder.java +++ b/src/java.base/share/classes/jdk/internal/classfile/impl/BufferedFieldBuilder.java @@ -34,6 +34,8 @@ import java.lang.classfile.*; import java.lang.classfile.constantpool.ConstantPoolBuilder; import java.lang.classfile.constantpool.Utf8Entry; +import static java.util.Objects.requireNonNull; + public final class BufferedFieldBuilder implements TerminalFieldBuilder { private final SplitConstantPool constantPool; @@ -49,8 +51,8 @@ public final class BufferedFieldBuilder Utf8Entry type) { this.constantPool = constantPool; this.context = context; - this.name = name; - this.desc = type; + this.name = requireNonNull(name); + this.desc = requireNonNull(type); this.flags = new AccessFlagsImpl(AccessFlag.Location.FIELD); } @@ -61,7 +63,7 @@ public final class BufferedFieldBuilder @Override public FieldBuilder with(FieldElement element) { - elements.add(element); + elements.add(requireNonNull(element)); if (element instanceof AccessFlags f) this.flags = f; return this; } diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/BufferedMethodBuilder.java b/src/java.base/share/classes/jdk/internal/classfile/impl/BufferedMethodBuilder.java index 84ddd09b990..8f511218d1e 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/impl/BufferedMethodBuilder.java +++ b/src/java.base/share/classes/jdk/internal/classfile/impl/BufferedMethodBuilder.java @@ -43,6 +43,8 @@ import java.lang.classfile.MethodElement; import java.lang.classfile.MethodModel; import java.lang.classfile.constantpool.Utf8Entry; +import static java.util.Objects.requireNonNull; + public final class BufferedMethodBuilder implements TerminalMethodBuilder { private final List elements; @@ -53,7 +55,6 @@ public final class BufferedMethodBuilder private AccessFlags flags; private final MethodModel original; private int[] parameterSlots; - MethodTypeDesc mDesc; public BufferedMethodBuilder(SplitConstantPool constantPool, ClassFileImpl context, @@ -64,15 +65,15 @@ public final class BufferedMethodBuilder this.elements = new ArrayList<>(); this.constantPool = constantPool; this.context = context; - this.name = nameInfo; - this.desc = typeInfo; + this.name = requireNonNull(nameInfo); + this.desc = requireNonNull(typeInfo); this.flags = new AccessFlagsImpl(AccessFlag.Location.METHOD, flags); this.original = original; } @Override public MethodBuilder with(MethodElement element) { - elements.add(element); + elements.add(requireNonNull(element)); if (element instanceof AccessFlags f) this.flags = checkFlags(f); return this; } @@ -102,14 +103,7 @@ public final class BufferedMethodBuilder @Override public MethodTypeDesc methodTypeSymbol() { - if (mDesc == null) { - if (original instanceof MethodInfo mi) { - mDesc = mi.methodTypeSymbol(); - } else { - mDesc = MethodTypeDesc.ofDescriptor(methodType().stringValue()); - } - } - return mDesc; + return Util.methodTypeSymbol(methodType()); } @Override diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/BytecodeHelpers.java b/src/java.base/share/classes/jdk/internal/classfile/impl/BytecodeHelpers.java index e52d198e1f4..fde8905abc1 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/impl/BytecodeHelpers.java +++ b/src/java.base/share/classes/jdk/internal/classfile/impl/BytecodeHelpers.java @@ -45,7 +45,14 @@ import java.lang.classfile.constantpool.LoadableConstantEntry; import java.lang.classfile.constantpool.MemberRefEntry; import java.lang.classfile.constantpool.MethodHandleEntry; import java.lang.classfile.constantpool.NameAndTypeEntry; +import java.util.Objects; +import static java.util.Objects.requireNonNull; +import static jdk.internal.classfile.impl.RawBytecodeHelper.*; + +/** + * Note: This class switches on opcode.bytecode for code size + */ public class BytecodeHelpers { private BytecodeHelpers() { @@ -55,6 +62,14 @@ public class BytecodeHelpers { return new IllegalArgumentException(String.format("convert %s -> %s", from, to)); } + public static IllegalArgumentException slotOutOfBounds(int slot) { + return new IllegalArgumentException("Invalid slot index :".concat(Integer.toString(slot))); + } + + public static IllegalArgumentException slotOutOfBounds(Opcode opcode, int slot) { + return new IllegalArgumentException("Invalid slot index %d for %s".formatted(slot, opcode)); + } + public static Opcode loadOpcode(TypeKind tk, int slot) { return switch (tk) { case INT, SHORT, BYTE, CHAR, BOOLEAN @@ -73,7 +88,13 @@ public class BytecodeHelpers { case 1 -> Opcode.ALOAD_1; case 2 -> Opcode.ALOAD_2; case 3 -> Opcode.ALOAD_3; - default -> (slot < 256) ? Opcode.ALOAD : Opcode.ALOAD_W; + default -> { + if ((slot & ~0xFF) == 0) + yield Opcode.ALOAD; + if ((slot & ~0xFFFF) == 0) + yield Opcode.ALOAD_W; + throw slotOutOfBounds(slot); + } }; } @@ -83,7 +104,13 @@ public class BytecodeHelpers { case 1 -> Opcode.FLOAD_1; case 2 -> Opcode.FLOAD_2; case 3 -> Opcode.FLOAD_3; - default -> (slot < 256) ? Opcode.FLOAD : Opcode.FLOAD_W; + default -> { + if ((slot & ~0xFF) == 0) + yield Opcode.FLOAD; + if ((slot & ~0xFFFF) == 0) + yield Opcode.FLOAD_W; + throw slotOutOfBounds(slot); + } }; } @@ -93,7 +120,13 @@ public class BytecodeHelpers { case 1 -> Opcode.DLOAD_1; case 2 -> Opcode.DLOAD_2; case 3 -> Opcode.DLOAD_3; - default -> (slot < 256) ? Opcode.DLOAD : Opcode.DLOAD_W; + default -> { + if ((slot & ~0xFF) == 0) + yield Opcode.DLOAD; + if ((slot & ~0xFFFF) == 0) + yield Opcode.DLOAD_W; + throw slotOutOfBounds(slot); + } }; } @@ -103,7 +136,13 @@ public class BytecodeHelpers { case 1 -> Opcode.LLOAD_1; case 2 -> Opcode.LLOAD_2; case 3 -> Opcode.LLOAD_3; - default -> (slot < 256) ? Opcode.LLOAD : Opcode.LLOAD_W; + default -> { + if ((slot & ~0xFF) == 0) + yield Opcode.LLOAD; + if ((slot & ~0xFFFF) == 0) + yield Opcode.LLOAD_W; + throw slotOutOfBounds(slot); + } }; } @@ -113,7 +152,13 @@ public class BytecodeHelpers { case 1 -> Opcode.ILOAD_1; case 2 -> Opcode.ILOAD_2; case 3 -> Opcode.ILOAD_3; - default -> (slot < 256) ? Opcode.ILOAD : Opcode.ILOAD_W; + default -> { + if ((slot & ~0xFF) == 0) + yield Opcode.ILOAD; + if ((slot & ~0xFFFF) == 0) + yield Opcode.ILOAD_W; + throw slotOutOfBounds(slot); + } }; } @@ -135,7 +180,13 @@ public class BytecodeHelpers { case 1 -> Opcode.ASTORE_1; case 2 -> Opcode.ASTORE_2; case 3 -> Opcode.ASTORE_3; - default -> (slot < 256) ? Opcode.ASTORE : Opcode.ASTORE_W; + default -> { + if ((slot & ~0xFF) == 0) + yield Opcode.ASTORE; + if ((slot & ~0xFFFF) == 0) + yield Opcode.ASTORE_W; + throw slotOutOfBounds(slot); + } }; } @@ -145,7 +196,13 @@ public class BytecodeHelpers { case 1 -> Opcode.FSTORE_1; case 2 -> Opcode.FSTORE_2; case 3 -> Opcode.FSTORE_3; - default -> (slot < 256) ? Opcode.FSTORE : Opcode.FSTORE_W; + default -> { + if ((slot & ~0xFF) == 0) + yield Opcode.FSTORE; + if ((slot & ~0xFFFF) == 0) + yield Opcode.FSTORE_W; + throw slotOutOfBounds(slot); + } }; } @@ -155,7 +212,13 @@ public class BytecodeHelpers { case 1 -> Opcode.DSTORE_1; case 2 -> Opcode.DSTORE_2; case 3 -> Opcode.DSTORE_3; - default -> (slot < 256) ? Opcode.DSTORE : Opcode.DSTORE_W; + default -> { + if ((slot & ~0xFF) == 0) + yield Opcode.DSTORE; + if ((slot & ~0xFFFF) == 0) + yield Opcode.DSTORE_W; + throw slotOutOfBounds(slot); + } }; } @@ -165,7 +228,13 @@ public class BytecodeHelpers { case 1 -> Opcode.LSTORE_1; case 2 -> Opcode.LSTORE_2; case 3 -> Opcode.LSTORE_3; - default -> (slot < 256) ? Opcode.LSTORE : Opcode.LSTORE_W; + default -> { + if ((slot & ~0xFF) == 0) + yield Opcode.LSTORE; + if ((slot & ~0xFFFF) == 0) + yield Opcode.LSTORE_W; + throw slotOutOfBounds(slot); + } }; } @@ -175,7 +244,13 @@ public class BytecodeHelpers { case 1 -> Opcode.ISTORE_1; case 2 -> Opcode.ISTORE_2; case 3 -> Opcode.ISTORE_3; - default -> (slot < 256) ? Opcode.ISTORE : Opcode.ISTORE_W; + default -> { + if ((slot & ~0xFF) == 0) + yield Opcode.ISTORE; + if ((slot & ~0xFFFF) == 0) + yield Opcode.ISTORE_W; + throw slotOutOfBounds(slot); + } }; } @@ -190,6 +265,11 @@ public class BytecodeHelpers { }; } + public static int returnBytecode(TypeKind tk) { + int kind = Math.max(0, tk.ordinal() - 4); // BYTE, SHORT, CHAR, BOOLEAN becomes INT + return IRETURN + kind; + } + public static Opcode arrayLoadOpcode(TypeKind tk) { return switch (tk) { case BYTE, BOOLEAN -> Opcode.BALOAD; @@ -204,6 +284,20 @@ public class BytecodeHelpers { }; } + public static int arrayLoadBytecode(TypeKind tk) { + return switch (tk) { + case BYTE, BOOLEAN -> BALOAD; + case SHORT -> SALOAD; + case INT -> IALOAD; + case FLOAT -> FALOAD; + case LONG -> LALOAD; + case DOUBLE -> DALOAD; + case REFERENCE -> AALOAD; + case CHAR -> CALOAD; + case VOID -> throw new IllegalArgumentException("void not an allowable array type"); + }; + } + public static Opcode arrayStoreOpcode(TypeKind tk) { return switch (tk) { case BYTE, BOOLEAN -> Opcode.BASTORE; @@ -218,6 +312,20 @@ public class BytecodeHelpers { }; } + public static int arrayStoreBytecode(TypeKind tk) { + return switch (tk) { + case BYTE, BOOLEAN -> BASTORE; + case SHORT -> SASTORE; + case INT -> IASTORE; + case FLOAT -> FASTORE; + case LONG -> LASTORE; + case DOUBLE -> DASTORE; + case REFERENCE -> AASTORE; + case CHAR -> CASTORE; + case VOID -> throw new IllegalArgumentException("void not an allowable array type"); + }; + } + public static Opcode reverseBranchOpcode(Opcode op) { return switch (op) { case IFEQ -> Opcode.IFNE; @@ -236,7 +344,30 @@ public class BytecodeHelpers { case IF_ACMPNE -> Opcode.IF_ACMPEQ; case IFNULL -> Opcode.IFNONNULL; case IFNONNULL -> Opcode.IFNULL; - default -> throw new IllegalArgumentException("Unknown branch instruction: " + op); + default -> throw Util.badOpcodeKindException(op, Opcode.Kind.BRANCH); + }; + } + + public static int reverseBranchOpcode(int bytecode) { + return switch (bytecode) { + case IFEQ -> IFNE; + case IFNE -> IFEQ; + case IFLT -> IFGE; + case IFGE -> IFLT; + case IFGT -> IFLE; + case IFLE -> IFGT; + case IF_ICMPEQ -> IF_ICMPNE; + case IF_ICMPNE -> IF_ICMPEQ; + case IF_ICMPLT -> IF_ICMPGE; + case IF_ICMPGE -> IF_ICMPLT; + case IF_ICMPGT -> IF_ICMPLE; + case IF_ICMPLE -> IF_ICMPGT; + case IF_ACMPEQ -> IF_ACMPNE; + case IF_ACMPNE -> IF_ACMPEQ; + case IFNULL -> IFNONNULL; + case IFNONNULL -> IFNULL; + default -> throw new IllegalArgumentException( + String.format("Wrong opcode kind specified; found %d, expected %s", bytecode, Opcode.Kind.BRANCH)); }; } @@ -277,6 +408,71 @@ public class BytecodeHelpers { }; } + public static TypeKind convertFromType(Opcode opcode) { + return switch (opcode) { + case I2D, I2F, I2L, I2B, I2C, I2S -> TypeKind.INT; + case L2D, L2F, L2I -> TypeKind.LONG; + case F2D, F2I, F2L -> TypeKind.FLOAT; + case D2F, D2I, D2L -> TypeKind.DOUBLE; + default -> throw Util.badOpcodeKindException(opcode, Opcode.Kind.CONVERT); + }; + } + + public static TypeKind convertToType(Opcode opcode) { + return switch (opcode) { + case I2B -> TypeKind.BYTE; + case I2C -> TypeKind.CHAR; + case I2S -> TypeKind.SHORT; + case L2I, F2I, D2I -> TypeKind.INT; + case I2L, F2L, D2L -> TypeKind.LONG; + case I2F, L2F, D2F -> TypeKind.FLOAT; + case I2D, L2D, F2D -> TypeKind.DOUBLE; + default -> throw Util.badOpcodeKindException(opcode, Opcode.Kind.CONVERT); + }; + } + + public static void validateSlot(Opcode opcode, int slot, boolean load) { + int size = opcode.sizeIfFixed(); + if (size == 1 && slot == (load ? intrinsicLoadSlot(opcode) : intrinsicStoreSlot(opcode)) || + size == 2 && (slot & ~0xFF) == 0 || + size == 4 && (slot & ~0xFFFF) == 0) + return; + throw slotOutOfBounds(opcode, slot); + } + + public static void validateSlot(int slot) { + if ((slot & ~0xFFFF) != 0) + throw slotOutOfBounds(slot); + } + + public static boolean validateAndIsWideIinc(int slot, int val) { + var ret = false; + if ((slot & ~0xFF) != 0) { + validateSlot(slot); + ret = true; + } + if ((byte) val != val) { + if ((short) val != val) { + throw new IllegalArgumentException("cannot encode as S2: ".concat(String.valueOf(val))); + } + ret = true; + } + return ret; + } + + public static void validateRet(Opcode opcode, int slot) { + if (opcode == Opcode.RET && (slot & ~0xFF) == 0 || + opcode == Opcode.RET_W && (slot & ~0xFFFF) == 0) + return; + requireNonNull(opcode); + throw slotOutOfBounds(opcode, slot); + } + + public static void validateMultiArrayDimensions(int value) { + if (value < 1 || value > 0xFF) + throw new IllegalArgumentException("Not a valid array dimension: ".concat(String.valueOf(value))); + } + public static void validateSipush(int value) { if (value != (short) value) throw new IllegalArgumentException( @@ -356,6 +552,147 @@ public class BytecodeHelpers { } if (constantValue instanceof DynamicConstantDesc value) { return handleConstantDescToHandleInfo(constantPool, value); } - throw new UnsupportedOperationException("not yet: " + constantValue); + throw new UnsupportedOperationException("not yet: " + requireNonNull(constantValue)); + } + + public static ConstantDesc intrinsicConstantValue(Opcode opcode) { + return switch (opcode) { + case ACONST_NULL -> ConstantDescs.NULL; + case ICONST_M1 -> -1; + case ICONST_0 -> 0; + case ICONST_1 -> 1; + case ICONST_2 -> 2; + case ICONST_3 -> 3; + case ICONST_4 -> 4; + case ICONST_5 -> 5; + case LCONST_0 -> 0L; + case LCONST_1 -> 1L; + case FCONST_0 -> 0F; + case FCONST_1 -> 1F; + case FCONST_2 -> 2F; + case DCONST_0 -> 0D; + case DCONST_1 -> 1D; + default -> throw Util.badOpcodeKindException(opcode, Opcode.Kind.CONSTANT); + }; + } + + public static TypeKind intrinsicConstantType(Opcode opcode) { + return switch (opcode) { + case ACONST_NULL -> TypeKind.REFERENCE; + case ICONST_M1, ICONST_0, ICONST_1, ICONST_2, ICONST_3, ICONST_4, ICONST_5 -> TypeKind.INT; + case LCONST_0, LCONST_1 -> TypeKind.LONG; + case FCONST_0, FCONST_1, FCONST_2 -> TypeKind.FLOAT; + case DCONST_0, DCONST_1 -> TypeKind.DOUBLE; + default -> throw Util.badOpcodeKindException(opcode, Opcode.Kind.CONSTANT); + }; + } + + public static boolean isUnconditionalBranch(Opcode opcode) { + return switch (opcode) { + case GOTO, ATHROW, GOTO_W, LOOKUPSWITCH, TABLESWITCH -> true; + default -> opcode.kind() == Opcode.Kind.RETURN; + }; + } + + // Must check Opcode.sizeIfFixed() == 1 before call! + public static int intrinsicLoadSlot(Opcode loadOpcode) { + return switch (loadOpcode) { + case ILOAD_0, LLOAD_0, FLOAD_0, DLOAD_0, ALOAD_0 -> 0; + case ILOAD_1, LLOAD_1, FLOAD_1, DLOAD_1, ALOAD_1 -> 1; + case ILOAD_2, LLOAD_2, FLOAD_2, DLOAD_2, ALOAD_2 -> 2; + case ILOAD_3, LLOAD_3, FLOAD_3, DLOAD_3, ALOAD_3 -> 3; + default -> throw Util.badOpcodeKindException(loadOpcode, Opcode.Kind.LOAD); + }; + } + + // Must check Opcode.sizeIfFixed() == 1 before call! + public static int intrinsicStoreSlot(Opcode storeOpcode) { + return switch (storeOpcode) { + case ISTORE_0, LSTORE_0, FSTORE_0, DSTORE_0, ASTORE_0 -> 0; + case ISTORE_1, LSTORE_1, FSTORE_1, DSTORE_1, ASTORE_1 -> 1; + case ISTORE_2, LSTORE_2, FSTORE_2, DSTORE_2, ASTORE_2 -> 2; + case ISTORE_3, LSTORE_3, FSTORE_3, DSTORE_3, ASTORE_3 -> 3; + default -> throw Util.badOpcodeKindException(storeOpcode, Opcode.Kind.STORE); + }; + } + + public static TypeKind loadType(Opcode loadOpcode) { + // Note: 0xFF handles wide pseudo-opcodes + return switch (loadOpcode.bytecode() & 0xFF) { + case ILOAD, ILOAD_0, ILOAD_1, ILOAD_2, ILOAD_3 -> TypeKind.INT; + case LLOAD, LLOAD_0, LLOAD_1, LLOAD_2, LLOAD_3 -> TypeKind.LONG; + case FLOAD, FLOAD_0, FLOAD_1, FLOAD_2, FLOAD_3 -> TypeKind.FLOAT; + case DLOAD, DLOAD_0, DLOAD_1, DLOAD_2, DLOAD_3 -> TypeKind.DOUBLE; + case ALOAD, ALOAD_0, ALOAD_1, ALOAD_2, ALOAD_3 -> TypeKind.REFERENCE; + default -> throw Util.badOpcodeKindException(loadOpcode, Opcode.Kind.LOAD); + }; + } + + public static TypeKind storeType(Opcode storeOpcode) { + // Note: 0xFF handles wide pseudo-opcodes + return switch (storeOpcode.bytecode() & 0xFF) { + case ISTORE, ISTORE_0, ISTORE_1, ISTORE_2, ISTORE_3 -> TypeKind.INT; + case LSTORE, LSTORE_0, LSTORE_1, LSTORE_2, LSTORE_3 -> TypeKind.LONG; + case FSTORE, FSTORE_0, FSTORE_1, FSTORE_2, FSTORE_3 -> TypeKind.FLOAT; + case DSTORE, DSTORE_0, DSTORE_1, DSTORE_2, DSTORE_3 -> TypeKind.DOUBLE; + case ASTORE, ASTORE_0, ASTORE_1, ASTORE_2, ASTORE_3 -> TypeKind.REFERENCE; + default -> throw Util.badOpcodeKindException(storeOpcode, Opcode.Kind.STORE); + }; + } + + public static TypeKind arrayLoadType(Opcode arrayLoadOpcode) { + return switch (arrayLoadOpcode) { + case IALOAD -> TypeKind.INT; + case LALOAD -> TypeKind.LONG; + case FALOAD -> TypeKind.FLOAT; + case DALOAD -> TypeKind.DOUBLE; + case AALOAD -> TypeKind.REFERENCE; + case BALOAD -> TypeKind.BYTE; + case CALOAD -> TypeKind.CHAR; + case SALOAD -> TypeKind.SHORT; + default -> throw Util.badOpcodeKindException(arrayLoadOpcode, Opcode.Kind.ARRAY_LOAD); + }; + } + + public static TypeKind arrayStoreType(Opcode arrayStoreOpcode) { + return switch (arrayStoreOpcode) { + case IASTORE -> TypeKind.INT; + case LASTORE -> TypeKind.LONG; + case FASTORE -> TypeKind.FLOAT; + case DASTORE -> TypeKind.DOUBLE; + case AASTORE -> TypeKind.REFERENCE; + case BASTORE -> TypeKind.BYTE; + case CASTORE -> TypeKind.CHAR; + case SASTORE -> TypeKind.SHORT; + default -> throw Util.badOpcodeKindException(arrayStoreOpcode, Opcode.Kind.ARRAY_STORE); + }; + } + + public static TypeKind returnType(Opcode returnOpcode) { + return switch (returnOpcode) { + case IRETURN -> TypeKind.INT; + case LRETURN -> TypeKind.LONG; + case FRETURN -> TypeKind.FLOAT; + case DRETURN -> TypeKind.DOUBLE; + case ARETURN -> TypeKind.REFERENCE; + case RETURN -> TypeKind.VOID; + default -> throw Util.badOpcodeKindException(returnOpcode, Opcode.Kind.RETURN); + }; + } + + public static TypeKind operatorOperandType(Opcode operationOpcode) { + return switch (operationOpcode) { + case IADD, ISUB, IMUL, IDIV, IREM, INEG, + ISHL, ISHR, IUSHR, IAND, IOR, IXOR, + ARRAYLENGTH -> TypeKind.INT; + case LADD, LSUB, LMUL, LDIV, LREM, LNEG, + LSHL, LSHR, LUSHR, LAND, LOR, LXOR, + LCMP -> TypeKind.LONG; + case FADD, FSUB, FMUL, FDIV, FREM, FNEG, + FCMPL, FCMPG -> TypeKind.FLOAT; + case DADD, DSUB, DMUL, DDIV, DREM, DNEG, + DCMPL, DCMPG -> TypeKind.DOUBLE; + default -> throw Util.badOpcodeKindException(operationOpcode, Opcode.Kind.OPERATOR); + }; } } diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/ChainedClassBuilder.java b/src/java.base/share/classes/jdk/internal/classfile/impl/ChainedClassBuilder.java index 50c1590e8a2..ebf803f5f27 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/impl/ChainedClassBuilder.java +++ b/src/java.base/share/classes/jdk/internal/classfile/impl/ChainedClassBuilder.java @@ -31,6 +31,8 @@ import java.lang.classfile.*; import java.lang.classfile.constantpool.ConstantPoolBuilder; import java.lang.classfile.constantpool.Utf8Entry; +import static java.util.Objects.requireNonNull; + public final class ChainedClassBuilder implements ClassBuilder, Consumer { private final DirectClassBuilder terminal; @@ -47,7 +49,7 @@ public final class ChainedClassBuilder @Override public ClassBuilder with(ClassElement element) { - consumer.accept(element); + consumer.accept(requireNonNull(element)); return this; } @@ -79,15 +81,6 @@ public final class ChainedClassBuilder return this; } - @Override - public ClassBuilder withMethod(String name, MethodTypeDesc descriptor, int flags, Consumer handler) { - var mb = new BufferedMethodBuilder(terminal.constantPool, terminal.context, - constantPool().utf8Entry(name), constantPool().utf8Entry(descriptor), flags, null); - mb.mDesc = descriptor; - consumer.accept(mb.run(handler).toModel()); - return this; - } - @Override public ClassBuilder transformMethod(MethodModel method, MethodTransform transform) { BufferedMethodBuilder builder = new BufferedMethodBuilder(terminal.constantPool, terminal.context, diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/ChainedCodeBuilder.java b/src/java.base/share/classes/jdk/internal/classfile/impl/ChainedCodeBuilder.java index 8c6c80b3013..fa02a346fab 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/impl/ChainedCodeBuilder.java +++ b/src/java.base/share/classes/jdk/internal/classfile/impl/ChainedCodeBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,6 +31,8 @@ import java.lang.classfile.Label; import java.util.function.Consumer; +import static java.util.Objects.requireNonNull; + public final class ChainedCodeBuilder extends NonterminalCodeBuilder implements CodeBuilder { @@ -59,7 +61,7 @@ public final class ChainedCodeBuilder @Override public CodeBuilder with(CodeElement element) { - consumer.accept(element); + consumer.accept(requireNonNull(element)); return this; } } diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/ChainedFieldBuilder.java b/src/java.base/share/classes/jdk/internal/classfile/impl/ChainedFieldBuilder.java index b3a30b5351b..f9c2b50f414 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/impl/ChainedFieldBuilder.java +++ b/src/java.base/share/classes/jdk/internal/classfile/impl/ChainedFieldBuilder.java @@ -30,6 +30,8 @@ import java.lang.classfile.FieldBuilder; import java.lang.classfile.FieldElement; import java.lang.classfile.constantpool.ConstantPoolBuilder; +import static java.util.Objects.requireNonNull; + public final class ChainedFieldBuilder implements FieldBuilder { private final TerminalFieldBuilder terminal; private final Consumer consumer; @@ -50,7 +52,7 @@ public final class ChainedFieldBuilder implements FieldBuilder { @Override public FieldBuilder with(FieldElement element) { - consumer.accept(element); + consumer.accept(requireNonNull(element)); return this; } diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/ChainedMethodBuilder.java b/src/java.base/share/classes/jdk/internal/classfile/impl/ChainedMethodBuilder.java index a7084116b9b..5bab6806b71 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/impl/ChainedMethodBuilder.java +++ b/src/java.base/share/classes/jdk/internal/classfile/impl/ChainedMethodBuilder.java @@ -33,6 +33,8 @@ import java.lang.classfile.MethodBuilder; import java.lang.classfile.MethodElement; import java.lang.classfile.constantpool.ConstantPoolBuilder; +import static java.util.Objects.requireNonNull; + public final class ChainedMethodBuilder implements MethodBuilder { final TerminalMethodBuilder terminal; final Consumer consumer; @@ -48,7 +50,7 @@ public final class ChainedMethodBuilder implements MethodBuilder { @Override public MethodBuilder with(MethodElement element) { - consumer.accept(element); + consumer.accept(requireNonNull(element)); return this; } diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/ClassFileImpl.java b/src/java.base/share/classes/jdk/internal/classfile/impl/ClassFileImpl.java index 1fd4c5cb1a0..ed81bcea009 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/impl/ClassFileImpl.java +++ b/src/java.base/share/classes/jdk/internal/classfile/impl/ClassFileImpl.java @@ -31,7 +31,6 @@ import java.util.function.Consumer; import java.lang.classfile.AttributeMapper; import java.lang.classfile.ClassFile; -import java.lang.classfile.ClassFile.*; import java.lang.classfile.ClassBuilder; import java.lang.classfile.ClassHierarchyResolver; import java.lang.classfile.ClassModel; @@ -41,33 +40,55 @@ import java.lang.classfile.constantpool.ConstantPoolBuilder; import java.lang.classfile.constantpool.Utf8Entry; import jdk.internal.classfile.impl.verifier.VerifierImpl; -public record ClassFileImpl(StackMapsOption stackMapsOption, - DebugElementsOption debugElementsOption, - LineNumbersOption lineNumbersOption, - AttributesProcessingOption attributesProcessingOption, - ConstantPoolSharingOption constantPoolSharingOption, - ShortJumpsOption shortJumpsOption, - DeadCodeOption deadCodeOption, - DeadLabelsOption deadLabelsOption, - ClassHierarchyResolverOption classHierarchyResolverOption, - AttributeMapperOption attributeMapperOption) implements ClassFile { +import static java.util.Objects.requireNonNull; + +public final class ClassFileImpl implements ClassFile { + + private Option stackMapsOption; + private Option debugElementsOption; + private Option lineNumbersOption; + private Option attributesProcessingOption; + private Option constantPoolSharingOption; + private Option shortJumpsOption; + private Option deadCodeOption; + private Option deadLabelsOption; + private Option classHierarchyResolverOption; + private Option attributeMapperOption; + + private ClassFileImpl(Option stackMapsOption, + Option debugElementsOption, + Option lineNumbersOption, + Option attributesProcessingOption, + Option constantPoolSharingOption, + Option shortJumpsOption, + Option deadCodeOption, + Option deadLabelsOption, + Option classHierarchyResolverOption, + Option attributeMapperOption) { + this.stackMapsOption = stackMapsOption; + this.debugElementsOption = debugElementsOption; + this.lineNumbersOption = lineNumbersOption; + this.attributesProcessingOption = attributesProcessingOption; + this.constantPoolSharingOption = constantPoolSharingOption; + this.shortJumpsOption = shortJumpsOption; + this.deadCodeOption = deadCodeOption; + this.deadLabelsOption = deadLabelsOption; + this.classHierarchyResolverOption = classHierarchyResolverOption; + this.attributeMapperOption = attributeMapperOption; + } public static final ClassFileImpl DEFAULT_CONTEXT = new ClassFileImpl( - StackMapsOption.STACK_MAPS_WHEN_REQUIRED, - DebugElementsOption.PASS_DEBUG, - LineNumbersOption.PASS_LINE_NUMBERS, - AttributesProcessingOption.PASS_ALL_ATTRIBUTES, - ConstantPoolSharingOption.SHARED_POOL, - ShortJumpsOption.FIX_SHORT_JUMPS, - DeadCodeOption.PATCH_DEAD_CODE, - DeadLabelsOption.FAIL_ON_DEAD_LABELS, - new ClassHierarchyResolverOptionImpl(ClassHierarchyResolver.defaultResolver()), - new AttributeMapperOptionImpl(new Function<>() { - @Override - public AttributeMapper apply(Utf8Entry k) { - return null; - } - })); + null, // StackMapsOption.STACK_MAPS_WHEN_REQUIRED + null, // DebugElementsOption.PASS_DEBUG, + null, // LineNumbersOption.PASS_LINE_NUMBERS, + null, // AttributesProcessingOption.PASS_ALL_ATTRIBUTES, + null, // ConstantPoolSharingOption.SHARED_POOL, + null, // ShortJumpsOption.FIX_SHORT_JUMPS, + null, // DeadCodeOption.PATCH_DEAD_CODE, + null, // DeadLabelsOption.FAIL_ON_DEAD_LABELS, + null, // new ClassHierarchyResolverOptionImpl(ClassHierarchyResolver.defaultResolver()), + null // _ -> null + ); @SuppressWarnings("unchecked") @Override @@ -85,6 +106,8 @@ public record ClassFileImpl(StackMapsOption stackMapsOption, for (var o : options) { if (o instanceof StackMapsOption oo) { smo = oo; + } else if (o instanceof ClassHierarchyResolverOption oo) { + chro = oo; } else if (o instanceof DebugElementsOption oo) { deo = oo; } else if (o instanceof LineNumbersOption oo) { @@ -99,12 +122,10 @@ public record ClassFileImpl(StackMapsOption stackMapsOption, dco = oo; } else if (o instanceof DeadLabelsOption oo) { dlo = oo; - } else if (o instanceof ClassHierarchyResolverOption oo) { - chro = oo; } else if (o instanceof AttributeMapperOption oo) { amo = oo; } else { // null or unknown Option type - throw new IllegalArgumentException("Invalid option: " + o); + throw new IllegalArgumentException("Invalid option: " + requireNonNull(o)); } } return new ClassFileImpl(smo, deo, lno, apo, cpso, sjo, dco, dlo, chro, amo); @@ -127,9 +148,8 @@ public record ClassFileImpl(StackMapsOption stackMapsOption, @Override public byte[] transformClass(ClassModel model, ClassEntry newClassName, ClassTransform transform) { - ConstantPoolBuilder constantPool = constantPoolSharingOption() == ConstantPoolSharingOption.SHARED_POOL - ? ConstantPoolBuilder.of(model) - : ConstantPoolBuilder.of(); + ConstantPoolBuilder constantPool = sharedConstantPool() ? ConstantPoolBuilder.of(model) + : ConstantPoolBuilder.of(); return build(newClassName, constantPool, new Consumer() { @Override @@ -141,10 +161,14 @@ public record ClassFileImpl(StackMapsOption stackMapsOption, }); } + public boolean sharedConstantPool() { + return constantPoolSharingOption == null || constantPoolSharingOption == ConstantPoolSharingOption.SHARED_POOL; + } + @Override public List verify(ClassModel model) { try { - return VerifierImpl.verify(model, classHierarchyResolverOption().classHierarchyResolver(), null); + return VerifierImpl.verify(model, classHierarchyResolver(), null); } catch (IllegalArgumentException verifierInitializationError) { return List.of(new VerifyError(verifierInitializationError.getMessage())); } @@ -159,6 +183,58 @@ public record ClassFileImpl(StackMapsOption stackMapsOption, } } + public Function> attributeMapper() { + if (attributeMapperOption == null) { + return _ -> null; + } else { + return ((AttributeMapperOption)attributeMapperOption).attributeMapper(); + } + } + + public ClassHierarchyResolver classHierarchyResolver() { + if (classHierarchyResolverOption == null) { + return ClassHierarchyImpl.DEFAULT_RESOLVER; + } else { + return ((ClassHierarchyResolverOption)classHierarchyResolverOption).classHierarchyResolver(); + } + } + + public boolean dropDeadLabels() { + return (deadLabelsOption != null && deadLabelsOption == DeadLabelsOption.DROP_DEAD_LABELS); + } + + public boolean passDebugElements() { + return (debugElementsOption == null || debugElementsOption == DebugElementsOption.PASS_DEBUG); + } + + public boolean passLineNumbers() { + return (lineNumbersOption == null || lineNumbersOption == LineNumbersOption.PASS_LINE_NUMBERS); + } + + public AttributesProcessingOption attributesProcessingOption() { + return (attributesProcessingOption == null) ? AttributesProcessingOption.PASS_ALL_ATTRIBUTES : (AttributesProcessingOption)attributesProcessingOption; + } + + public boolean fixShortJumps() { + return (shortJumpsOption == null || shortJumpsOption == ShortJumpsOption.FIX_SHORT_JUMPS); + } + + public boolean stackMapsWhenRequired() { + return (stackMapsOption == null || stackMapsOption == StackMapsOption.STACK_MAPS_WHEN_REQUIRED); + } + + public boolean generateStackMaps() { + return (stackMapsOption == StackMapsOption.GENERATE_STACK_MAPS); + } + + public boolean dropStackMaps() { + return (stackMapsOption == StackMapsOption.DROP_STACK_MAPS); + } + + public boolean patchDeadCode() { + return (deadCodeOption == null || deadCodeOption == DeadCodeOption.PATCH_DEAD_CODE); + } + public record AttributeMapperOptionImpl(Function> attributeMapper) implements AttributeMapperOption { } diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/ClassHierarchyImpl.java b/src/java.base/share/classes/jdk/internal/classfile/impl/ClassHierarchyImpl.java index 6765bdee3bd..9c2dd895538 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/impl/ClassHierarchyImpl.java +++ b/src/java.base/share/classes/jdk/internal/classfile/impl/ClassHierarchyImpl.java @@ -40,6 +40,7 @@ import java.lang.classfile.ClassHierarchyResolver; import static java.lang.constant.ConstantDescs.CD_Object; import static java.lang.classfile.ClassFile.*; +import static java.lang.classfile.constantpool.PoolEntry.*; import static java.util.Objects.requireNonNull; import static jdk.internal.constant.ConstantUtils.referenceClassDesc; @@ -174,10 +175,10 @@ public final class ClassHierarchyImpl { switch (tag = in.readUnsignedByte()) { case TAG_UTF8 -> cpStrings[i] = in.readUTF(); case TAG_CLASS -> cpClasses[i] = in.readUnsignedShort(); - case TAG_STRING, TAG_METHODTYPE, TAG_MODULE, TAG_PACKAGE -> in.skipBytes(2); - case TAG_METHODHANDLE -> in.skipBytes(3); - case TAG_INTEGER, TAG_FLOAT, TAG_FIELDREF, TAG_METHODREF, TAG_INTERFACEMETHODREF, - TAG_NAMEANDTYPE, TAG_CONSTANTDYNAMIC, TAG_INVOKEDYNAMIC -> in.skipBytes(4); + case TAG_STRING, TAG_METHOD_TYPE, TAG_MODULE, TAG_PACKAGE -> in.skipBytes(2); + case TAG_METHOD_HANDLE -> in.skipBytes(3); + case TAG_INTEGER, TAG_FLOAT, TAG_FIELDREF, TAG_METHODREF, TAG_INTERFACE_METHODREF, + TAG_NAME_AND_TYPE, TAG_DYNAMIC, TAG_INVOKE_DYNAMIC -> in.skipBytes(4); case TAG_LONG, TAG_DOUBLE -> { in.skipBytes(8); i++; @@ -204,9 +205,9 @@ public final class ClassHierarchyImpl { map = HashMap.newHashMap(interfaceNames.size() + classToSuperClass.size() + 1); map.put(CD_Object, ClassHierarchyInfoImpl.OBJECT_INFO); for (var e : classToSuperClass.entrySet()) - map.put(e.getKey(), ClassHierarchyInfo.ofClass(e.getValue())); + map.put(requireNonNull(e.getKey()), ClassHierarchyInfo.ofClass(e.getValue())); for (var i : interfaceNames) - map.put(i, ClassHierarchyInfo.ofInterface()); + map.put(requireNonNull(i), ClassHierarchyInfo.ofInterface()); } @Override diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/ClassPrinterImpl.java b/src/java.base/share/classes/jdk/internal/classfile/impl/ClassPrinterImpl.java index 837cf3366be..9c42678428c 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/impl/ClassPrinterImpl.java +++ b/src/java.base/share/classes/jdk/internal/classfile/impl/ClassPrinterImpl.java @@ -58,9 +58,10 @@ import java.lang.classfile.attribute.StackMapFrameInfo.*; import java.lang.classfile.constantpool.*; import java.lang.classfile.instruction.*; -import static java.lang.classfile.ClassFile.*; import java.lang.classfile.CompoundElement; import java.lang.classfile.FieldModel; +import static java.lang.classfile.constantpool.PoolEntry.*; +import static java.util.Objects.requireNonNull; import static jdk.internal.classfile.impl.ClassPrinterImpl.Style.*; public final class ClassPrinterImpl { @@ -536,21 +537,21 @@ public final class ClassPrinterImpl { switch (vti) { case SimpleVerificationTypeInfo s -> { switch (s) { - case ITEM_DOUBLE -> { + case DOUBLE -> { ret.accept("double"); ret.accept("double2"); } - case ITEM_FLOAT -> + case FLOAT -> ret.accept("float"); - case ITEM_INTEGER -> + case INTEGER -> ret.accept("int"); - case ITEM_LONG -> { + case LONG -> { ret.accept("long"); ret.accept("long2"); } - case ITEM_NULL -> ret.accept("null"); - case ITEM_TOP -> ret.accept("?"); - case ITEM_UNINITIALIZED_THIS -> ret.accept("THIS"); + case NULL -> ret.accept("null"); + case TOP -> ret.accept("?"); + case UNINITIALIZED_THIS -> ret.accept("THIS"); } } case ObjectVerificationTypeInfo o -> @@ -564,6 +565,7 @@ public final class ClassPrinterImpl { private record ExceptionHandler(int start, int end, int handler, String catchType) {} public static MapNode modelToTree(CompoundElement model, Verbosity verbosity) { + requireNonNull(verbosity); // we are using == checks in implementations return switch(model) { case ClassModel cm -> classToTree(cm, verbosity); case FieldModel fm -> fieldToTree(fm, verbosity); @@ -603,12 +605,12 @@ public final class ClassPrinterImpl { case TAG_STRING -> "String"; case TAG_FIELDREF -> "Fieldref"; case TAG_METHODREF -> "Methodref"; - case TAG_INTERFACEMETHODREF -> "InterfaceMethodref"; - case TAG_NAMEANDTYPE -> "NameAndType"; - case TAG_METHODHANDLE -> "MethodHandle"; - case TAG_METHODTYPE -> "MethodType"; - case TAG_CONSTANTDYNAMIC -> "Dynamic"; - case TAG_INVOKEDYNAMIC -> "InvokeDynamic"; + case TAG_INTERFACE_METHODREF -> "InterfaceMethodref"; + case TAG_NAME_AND_TYPE -> "NameAndType"; + case TAG_METHOD_HANDLE -> "MethodHandle"; + case TAG_METHOD_TYPE -> "MethodType"; + case TAG_DYNAMIC -> "Dynamic"; + case TAG_INVOKE_DYNAMIC -> "InvokeDynamic"; case TAG_MODULE -> "Module"; case TAG_PACKAGE -> "Package"; default -> throw new AssertionError("Unknown CP tag: " + e.tag()); diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/ClassReaderImpl.java b/src/java.base/share/classes/jdk/internal/classfile/impl/ClassReaderImpl.java index 9695b16ad51..0f183ad427f 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/impl/ClassReaderImpl.java +++ b/src/java.base/share/classes/jdk/internal/classfile/impl/ClassReaderImpl.java @@ -36,23 +36,7 @@ import java.lang.classfile.*; import java.lang.classfile.attribute.BootstrapMethodsAttribute; import java.lang.classfile.constantpool.*; -import static java.lang.classfile.ClassFile.TAG_CLASS; -import static java.lang.classfile.ClassFile.TAG_CONSTANTDYNAMIC; -import static java.lang.classfile.ClassFile.TAG_DOUBLE; -import static java.lang.classfile.ClassFile.TAG_FIELDREF; -import static java.lang.classfile.ClassFile.TAG_FLOAT; -import static java.lang.classfile.ClassFile.TAG_INTEGER; -import static java.lang.classfile.ClassFile.TAG_INTERFACEMETHODREF; -import static java.lang.classfile.ClassFile.TAG_INVOKEDYNAMIC; -import static java.lang.classfile.ClassFile.TAG_LONG; -import static java.lang.classfile.ClassFile.TAG_METHODHANDLE; -import static java.lang.classfile.ClassFile.TAG_METHODREF; -import static java.lang.classfile.ClassFile.TAG_METHODTYPE; -import static java.lang.classfile.ClassFile.TAG_MODULE; -import static java.lang.classfile.ClassFile.TAG_NAMEANDTYPE; -import static java.lang.classfile.ClassFile.TAG_PACKAGE; -import static java.lang.classfile.ClassFile.TAG_STRING; -import static java.lang.classfile.ClassFile.TAG_UTF8; +import static java.lang.classfile.constantpool.PoolEntry.*; public final class ClassReaderImpl implements ClassReader { @@ -82,7 +66,7 @@ public final class ClassReaderImpl this.buffer = classfileBytes; this.classfileLength = classfileBytes.length; this.context = context; - this.attributeMapper = this.context.attributeMapperOption().attributeMapper(); + this.attributeMapper = this.context.attributeMapper(); if (classfileLength < 4 || readInt(0) != 0xCAFEBABE) { throw new IllegalArgumentException("Bad magic number"); } @@ -98,15 +82,15 @@ public final class ClassReaderImpl ++p; switch (tag) { // 2 - case TAG_CLASS, TAG_METHODTYPE, TAG_MODULE, TAG_STRING, TAG_PACKAGE -> p += 2; + case TAG_CLASS, TAG_METHOD_TYPE, TAG_MODULE, TAG_STRING, TAG_PACKAGE -> p += 2; // 3 - case TAG_METHODHANDLE -> p += 3; + case TAG_METHOD_HANDLE -> p += 3; // 4 - case TAG_CONSTANTDYNAMIC, TAG_FIELDREF, TAG_FLOAT, TAG_INTEGER, - TAG_INTERFACEMETHODREF, TAG_INVOKEDYNAMIC, TAG_METHODREF, - TAG_NAMEANDTYPE -> p += 4; + case TAG_DYNAMIC, TAG_FIELDREF, TAG_FLOAT, TAG_INTEGER, + TAG_INTERFACE_METHODREF, TAG_INVOKE_DYNAMIC, TAG_METHODREF, + TAG_NAME_AND_TYPE -> p += 4; // 8 case TAG_DOUBLE, TAG_LONG -> { @@ -354,12 +338,12 @@ public final class ClassReaderImpl case TAG_STRING -> AbstractPoolEntry.StringEntryImpl.class; case TAG_FIELDREF -> AbstractPoolEntry.FieldRefEntryImpl.class; case TAG_METHODREF -> AbstractPoolEntry.MethodRefEntryImpl.class; - case TAG_INTERFACEMETHODREF -> AbstractPoolEntry.InterfaceMethodRefEntryImpl.class; - case TAG_NAMEANDTYPE -> AbstractPoolEntry.NameAndTypeEntryImpl.class; - case TAG_METHODHANDLE -> AbstractPoolEntry.MethodHandleEntryImpl.class; - case TAG_METHODTYPE -> AbstractPoolEntry.MethodTypeEntryImpl.class; - case TAG_CONSTANTDYNAMIC -> AbstractPoolEntry.ConstantDynamicEntryImpl.class; - case TAG_INVOKEDYNAMIC -> AbstractPoolEntry.InvokeDynamicEntryImpl.class; + case TAG_INTERFACE_METHODREF -> AbstractPoolEntry.InterfaceMethodRefEntryImpl.class; + case TAG_NAME_AND_TYPE -> AbstractPoolEntry.NameAndTypeEntryImpl.class; + case TAG_METHOD_HANDLE -> AbstractPoolEntry.MethodHandleEntryImpl.class; + case TAG_METHOD_TYPE -> AbstractPoolEntry.MethodTypeEntryImpl.class; + case TAG_DYNAMIC -> AbstractPoolEntry.ConstantDynamicEntryImpl.class; + case TAG_INVOKE_DYNAMIC -> AbstractPoolEntry.InvokeDynamicEntryImpl.class; case TAG_MODULE -> AbstractPoolEntry.ModuleEntryImpl.class; case TAG_PACKAGE -> AbstractPoolEntry.PackageEntryImpl.class; default -> null; @@ -369,7 +353,11 @@ public final class ClassReaderImpl static T checkType(PoolEntry e, int index, Class cls) { if (cls.isInstance(e)) return cls.cast(e); - throw new ConstantPoolException("Not a " + cls.getSimpleName() + " at index: " + index); + throw checkTypeError(index, cls); + } + + private static ConstantPoolException checkTypeError(int index, Class cls) { + return new ConstantPoolException("Not a " + cls.getSimpleName() + " at index: " + index); } @Override @@ -402,15 +390,15 @@ public final class ClassReaderImpl readEntry(q + 2, AbstractPoolEntry.NameAndTypeEntryImpl.class)); case TAG_METHODREF -> new AbstractPoolEntry.MethodRefEntryImpl(this, index, readEntry(q, AbstractPoolEntry.ClassEntryImpl.class), readEntry(q + 2, AbstractPoolEntry.NameAndTypeEntryImpl.class)); - case TAG_INTERFACEMETHODREF -> new AbstractPoolEntry.InterfaceMethodRefEntryImpl(this, index, readEntry(q, AbstractPoolEntry.ClassEntryImpl.class), + case TAG_INTERFACE_METHODREF -> new AbstractPoolEntry.InterfaceMethodRefEntryImpl(this, index, readEntry(q, AbstractPoolEntry.ClassEntryImpl.class), readEntry(q + 2, AbstractPoolEntry.NameAndTypeEntryImpl.class)); - case TAG_NAMEANDTYPE -> new AbstractPoolEntry.NameAndTypeEntryImpl(this, index, readEntry(q, AbstractPoolEntry.Utf8EntryImpl.class), + case TAG_NAME_AND_TYPE -> new AbstractPoolEntry.NameAndTypeEntryImpl(this, index, readEntry(q, AbstractPoolEntry.Utf8EntryImpl.class), readEntry(q + 2, AbstractPoolEntry.Utf8EntryImpl.class)); - case TAG_METHODHANDLE -> new AbstractPoolEntry.MethodHandleEntryImpl(this, index, readU1(q), + case TAG_METHOD_HANDLE -> new AbstractPoolEntry.MethodHandleEntryImpl(this, index, readU1(q), readEntry(q + 1, AbstractPoolEntry.AbstractMemberRefEntry.class)); - case TAG_METHODTYPE -> new AbstractPoolEntry.MethodTypeEntryImpl(this, index, readEntry(q, AbstractPoolEntry.Utf8EntryImpl.class)); - case TAG_CONSTANTDYNAMIC -> new AbstractPoolEntry.ConstantDynamicEntryImpl(this, index, readU2(q), readEntry(q + 2, AbstractPoolEntry.NameAndTypeEntryImpl.class)); - case TAG_INVOKEDYNAMIC -> new AbstractPoolEntry.InvokeDynamicEntryImpl(this, index, readU2(q), readEntry(q + 2, AbstractPoolEntry.NameAndTypeEntryImpl.class)); + case TAG_METHOD_TYPE -> new AbstractPoolEntry.MethodTypeEntryImpl(this, index, readEntry(q, AbstractPoolEntry.Utf8EntryImpl.class)); + case TAG_DYNAMIC -> new AbstractPoolEntry.ConstantDynamicEntryImpl(this, index, readU2(q), readEntry(q + 2, AbstractPoolEntry.NameAndTypeEntryImpl.class)); + case TAG_INVOKE_DYNAMIC -> new AbstractPoolEntry.InvokeDynamicEntryImpl(this, index, readU2(q), readEntry(q + 2, AbstractPoolEntry.NameAndTypeEntryImpl.class)); case TAG_MODULE -> new AbstractPoolEntry.ModuleEntryImpl(this, index, readEntry(q, AbstractPoolEntry.Utf8EntryImpl.class)); case TAG_PACKAGE -> new AbstractPoolEntry.PackageEntryImpl(this, index, readEntry(q, AbstractPoolEntry.Utf8EntryImpl.class)); default -> throw new ConstantPoolException( diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/CodeImpl.java b/src/java.base/share/classes/jdk/internal/classfile/impl/CodeImpl.java index 8be7e92f5b6..aa9603b1508 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/impl/CodeImpl.java +++ b/src/java.base/share/classes/jdk/internal/classfile/impl/CodeImpl.java @@ -39,7 +39,7 @@ import java.lang.classfile.attribute.StackMapTableAttribute; import java.lang.classfile.constantpool.ClassEntry; import java.lang.classfile.instruction.*; -import static java.lang.classfile.ClassFile.*; +import static jdk.internal.classfile.impl.RawBytecodeHelper.*; public final class CodeImpl extends BoundAttribute.BoundCodeAttribute @@ -55,13 +55,13 @@ public final class CodeImpl case ARRAY_STORE -> ArrayStoreInstruction.of(o); case CONSTANT -> ConstantInstruction.ofIntrinsic(o); case CONVERT -> ConvertInstruction.of(o); - case LOAD -> LoadInstruction.of(o, o.slot()); + case LOAD -> new AbstractInstruction.UnboundLoadInstruction(o, BytecodeHelpers.intrinsicLoadSlot(o)); case MONITOR -> MonitorInstruction.of(o); case NOP -> NopInstruction.of(); case OPERATOR -> OperatorInstruction.of(o); case RETURN -> ReturnInstruction.of(o); case STACK -> StackInstruction.of(o); - case STORE -> StoreInstruction.of(o, o.slot()); + case STORE -> new AbstractInstruction.UnboundStoreInstruction(o, BytecodeHelpers.intrinsicStoreSlot(o)); case THROW_EXCEPTION -> ThrowInstruction.of(); default -> throw new AssertionError("invalid opcode: " + o); }; @@ -122,7 +122,7 @@ public final class CodeImpl if (!inflated) { if (labels == null) labels = new LabelImpl[codeLength + 1]; - if (classReader.context().lineNumbersOption() == ClassFile.LineNumbersOption.PASS_LINE_NUMBERS) + if (classReader.context().passLineNumbers()) inflateLineNumbers(); inflateJumpTargets(); inflateTypeAnnotations(); @@ -167,7 +167,7 @@ public final class CodeImpl inflateMetadata(); boolean doLineNumbers = (lineNumbers != null); generateCatchTargets(consumer); - if (classReader.context().debugElementsOption() == ClassFile.DebugElementsOption.PASS_DEBUG) + if (classReader.context().passDebugElements()) generateDebugElements(consumer); for (int pos=codeStart; pos br.target(); case DiscontinuedInstruction.JsrInstruction jsr -> jsr.target(); + case LookupSwitchInstruction ls -> { + ls.defaultTarget(); + ls.cases(); + } + case TableSwitchInstruction ts -> { + ts.defaultTarget(); + ts.cases(); + } default -> {} } pos += i.sizeInBytes(); diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/DirectClassBuilder.java b/src/java.base/share/classes/jdk/internal/classfile/impl/DirectClassBuilder.java index 0d61895fe9f..d1131d94db7 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/impl/DirectClassBuilder.java +++ b/src/java.base/share/classes/jdk/internal/classfile/impl/DirectClassBuilder.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, Alibaba Group Holding Limited. 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 @@ -26,8 +27,7 @@ package jdk.internal.classfile.impl; import java.lang.constant.ConstantDescs; -import java.lang.constant.MethodTypeDesc; -import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.function.Consumer; @@ -46,13 +46,21 @@ import java.lang.classfile.MethodModel; import java.lang.classfile.MethodTransform; import java.lang.classfile.constantpool.Utf8Entry; +import static java.util.Objects.requireNonNull; + public final class DirectClassBuilder extends AbstractDirectBuilder implements ClassBuilder { + /** The value of default class access flags */ + static final int DEFAULT_CLASS_FLAGS = ClassFile.ACC_PUBLIC; + static final Util.Writable[] EMPTY_WRITABLE_ARRAY = {}; + static final ClassEntry[] EMPTY_CLASS_ENTRY_ARRAY = {}; final ClassEntry thisClassEntry; - private final List fields = new ArrayList<>(); - private final List methods = new ArrayList<>(); + private Util.Writable[] fields = EMPTY_WRITABLE_ARRAY; + private Util.Writable[] methods = EMPTY_WRITABLE_ARRAY; + private int fieldsCount = 0; + private int methodsCount = 0; private ClassEntry superclassEntry; private List interfaceEntries; private int majorVersion; @@ -65,7 +73,7 @@ public final class DirectClassBuilder ClassEntry thisClass) { super(constantPool, context); this.thisClassEntry = AbstractPoolEntry.maybeClone(constantPool, thisClass); - this.flags = ClassFile.DEFAULT_CLASS_FLAGS; + this.flags = DEFAULT_CLASS_FLAGS; this.superclassEntry = null; this.interfaceEntries = Collections.emptyList(); this.majorVersion = ClassFile.latestMajorVersion(); @@ -77,23 +85,36 @@ public final class DirectClassBuilder if (element instanceof AbstractElement ae) { ae.writeTo(this); } else { - writeAttribute((CustomAttribute) element); + writeAttribute((CustomAttribute) requireNonNull(element)); } return this; } + @Override + public ClassBuilder withFlags(int flags) { + setFlags(flags); + return this; + } + + @Override + public ClassBuilder withField(Utf8Entry name, + Utf8Entry descriptor, + int flags) { + return withField(new DirectFieldBuilder(constantPool, context, name, descriptor, flags, null)); + } + @Override public ClassBuilder withField(Utf8Entry name, Utf8Entry descriptor, Consumer handler) { - return withField(new DirectFieldBuilder(constantPool, context, name, descriptor, null) + return withField(new DirectFieldBuilder(constantPool, context, name, descriptor, 0, null) .run(handler)); } @Override public ClassBuilder transformField(FieldModel field, FieldTransform transform) { DirectFieldBuilder builder = new DirectFieldBuilder(constantPool, context, field.fieldName(), - field.fieldType(), field); + field.fieldType(), 0, field); builder.transform(field, transform); return withField(builder); } @@ -107,13 +128,6 @@ public final class DirectClassBuilder .run(handler)); } - @Override - public ClassBuilder withMethod(String name, MethodTypeDesc descriptor, int flags, Consumer handler) { - var method = new DirectMethodBuilder(constantPool, context, constantPool.utf8Entry(name), constantPool.utf8Entry(descriptor), flags, null); - method.mDesc = descriptor; - return withMethod(method.run(handler)); - } - @Override public ClassBuilder transformMethod(MethodModel method, MethodTransform transform) { DirectMethodBuilder builder = new DirectMethodBuilder(constantPool, context, method.methodName(), @@ -127,12 +141,20 @@ public final class DirectClassBuilder // internal / for use by elements ClassBuilder withField(Util.Writable field) { - fields.add(field); + if (fieldsCount >= fields.length) { + int newCapacity = fieldsCount + 8; + this.fields = Arrays.copyOf(fields, newCapacity); + } + fields[fieldsCount++] = field; return this; } ClassBuilder withMethod(Util.Writable method) { - methods.add(method); + if (methodsCount >= methods.length) { + int newCapacity = methodsCount + 8; + this.methods = Arrays.copyOf(methods, newCapacity); + } + methods[methodsCount++] = method; return this; } @@ -167,14 +189,14 @@ public final class DirectClassBuilder // BSM writers until everything else is written. // Do this early because it might trigger CP activity + var constantPool = this.constantPool; ClassEntry superclass = superclassEntry; if (superclass != null) superclass = AbstractPoolEntry.maybeClone(constantPool, superclass); else if ((flags & ClassFile.ACC_MODULE) == 0 && !"java/lang/Object".equals(thisClassEntry.asInternalName())) superclass = constantPool.classEntry(ConstantDescs.CD_Object); - List ies = new ArrayList<>(interfaceEntries.size()); - for (ClassEntry ce : interfaceEntries) - ies.add(AbstractPoolEntry.maybeClone(constantPool, ce)); + int interfaceEntriesSize = interfaceEntries.size(); + ClassEntry[] ies = interfaceEntriesSize == 0 ? EMPTY_CLASS_ENTRY_ARRAY : buildInterfaceEnties(interfaceEntriesSize); // We maintain two writers, and then we join them at the end int size = sizeHint == 0 ? 256 : sizeHint; @@ -183,32 +205,35 @@ public final class DirectClassBuilder // The tail consists of fields and methods, and attributes // This should trigger all the CP/BSM mutation - Util.writeList(tail, fields); - Util.writeList(tail, methods); + Util.writeList(tail, fields, fieldsCount); + Util.writeList(tail, methods, methodsCount); int attributesOffset = tail.size(); attributes.writeTo(tail); // Now we have to append the BSM, if there is one - boolean written = constantPool.writeBootstrapMethods(tail); - if (written) { + if (constantPool.writeBootstrapMethods(tail)) { // Update attributes count - tail.patchInt(attributesOffset, 2, attributes.size() + 1); + tail.patchU2(attributesOffset, attributes.size() + 1); } // Now we can make the head head.writeInt(ClassFile.MAGIC_NUMBER); - head.writeU2(minorVersion); - head.writeU2(majorVersion); + head.writeU2U2(minorVersion, majorVersion); constantPool.writeTo(head); - head.writeU2(flags); - head.writeIndex(thisClassEntry); - head.writeIndexOrZero(superclass); - Util.writeListIndices(head, ies); + head.writeU2U2U2(flags, head.cpIndex(thisClassEntry), head.cpIndexOrZero(superclass)); + head.writeU2(interfaceEntriesSize); + for (int i = 0; i < interfaceEntriesSize; i++) { + head.writeIndex(ies[i]); + } // Join head and tail into an exact-size buffer - byte[] result = new byte[head.size() + tail.size()]; - head.copyTo(result, 0); - tail.copyTo(result, head.size()); - return result; + return BufWriterImpl.join(head, tail); + } + + private ClassEntry[] buildInterfaceEnties(int interfaceEntriesSize) { + var ies = new ClassEntry[interfaceEntriesSize]; + for (int i = 0; i < interfaceEntriesSize; i++) + ies[i] = AbstractPoolEntry.maybeClone(constantPool, interfaceEntries.get(i)); + return ies; } } diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/DirectCodeBuilder.java b/src/java.base/share/classes/jdk/internal/classfile/impl/DirectCodeBuilder.java index 1b950f28d00..c00025e2a7e 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/impl/DirectCodeBuilder.java +++ b/src/java.base/share/classes/jdk/internal/classfile/impl/DirectCodeBuilder.java @@ -25,6 +25,8 @@ */ package jdk.internal.classfile.impl; +import java.lang.constant.ClassDesc; +import java.lang.constant.MethodTypeDesc; import java.lang.classfile.Attribute; import java.lang.classfile.Attributes; import java.lang.classfile.ClassFile; @@ -52,8 +54,8 @@ import java.lang.classfile.instruction.ExceptionCatch; import java.lang.classfile.instruction.LocalVariable; import java.lang.classfile.instruction.LocalVariableType; import java.lang.classfile.instruction.SwitchCase; -import java.lang.constant.ConstantDesc; import java.util.ArrayList; +import java.util.Arrays; import java.util.Comparator; import java.util.HashMap; import java.util.IdentityHashMap; @@ -62,18 +64,28 @@ import java.util.Map; import java.util.function.Consumer; import java.util.function.Function; -import static java.lang.classfile.Opcode.*; - +import static java.util.Objects.requireNonNull; import static jdk.internal.classfile.impl.BytecodeHelpers.*; +import static jdk.internal.classfile.impl.RawBytecodeHelper.*; public final class DirectCodeBuilder extends AbstractDirectBuilder implements TerminalCodeBuilder { - private final List characterRanges = new ArrayList<>(); + private static final CharacterRange[] EMPTY_CHARACTER_RANGE = {}; + private static final DeferredLabel[] EMPTY_LABEL_ARRAY = {}; + private static final LocalVariable[] EMPTY_LOCAL_VARIABLE_ARRAY = {}; + private static final LocalVariableType[] EMPTY_LOCAL_VARIABLE_TYPE_ARRAY = {}; + private static final AbstractPseudoInstruction.ExceptionCatchImpl[] EMPTY_HANDLER_ARRAY = {}; + private static final DeferredLabel[] EMPTY_DEFERRED_LABEL_ARRAY = {}; + final List handlers = new ArrayList<>(); - private final List localVariables = new ArrayList<>(); - private final List localVariableTypes = new ArrayList<>(); - private final boolean transformFwdJumps, transformBackJumps; + private CharacterRange[] characterRanges = EMPTY_CHARACTER_RANGE; + private LocalVariable[] localVariables = EMPTY_LOCAL_VARIABLE_ARRAY; + private LocalVariableType[] localVariableTypes = EMPTY_LOCAL_VARIABLE_TYPE_ARRAY; + private int characterRangesCount = 0; + private int localVariablesCount = 0; + private int localVariableTypesCount = 0; + private final boolean transformDeferredJumps, transformKnownJumps; private final Label startLabel, endLabel; final MethodInfo methodInfo; final BufWriterImpl bytecodesBufWriter; @@ -83,7 +95,8 @@ public final class DirectCodeBuilder private DedupLineNumberTableAttribute lineNumberWriter; private int topLocal; - List deferredLabels; + private DeferredLabel[] deferredLabels = EMPTY_DEFERRED_LABEL_ARRAY; + private int deferredLabelsCount = 0; /* Locals management lazily computed maxLocal = -1 @@ -103,7 +116,7 @@ public final class DirectCodeBuilder handler.accept(cb = new DirectCodeBuilder(methodInfo, constantPool, context, original, false)); cb.buildContent(); } catch (LabelOverflowException loe) { - if (context.shortJumpsOption() == ClassFile.ShortJumpsOption.FIX_SHORT_JUMPS) { + if (context.fixShortJumps()) { handler.accept(cb = new DirectCodeBuilder(methodInfo, constantPool, context, original, true)); cb.buildContent(); } @@ -117,12 +130,12 @@ public final class DirectCodeBuilder SplitConstantPool constantPool, ClassFileImpl context, CodeModel original, - boolean transformFwdJumps) { + boolean transformDeferredJumps) { super(constantPool, context); setOriginal(original); this.methodInfo = methodInfo; - this.transformFwdJumps = transformFwdJumps; - this.transformBackJumps = context.shortJumpsOption() == ClassFile.ShortJumpsOption.FIX_SHORT_JUMPS; + this.transformDeferredJumps = transformDeferredJumps; + this.transformKnownJumps = context.fixShortJumps(); bytecodesBufWriter = (original instanceof CodeImpl cai) ? new BufWriterImpl(constantPool, context, cai.codeLength()) : new BufWriterImpl(constantPool, context); this.startLabel = new LabelImpl(this, 0); @@ -135,7 +148,7 @@ public final class DirectCodeBuilder if (element instanceof AbstractElement ae) { ae.writeTo(this); } else { - writeAttribute((CustomAttribute) element); + writeAttribute((CustomAttribute) requireNonNull(element)); } return this; } @@ -190,26 +203,31 @@ public final class DirectCodeBuilder int pos = buf.size(); int handlersSize = handlers.size(); buf.writeU2(handlersSize); + if (handlersSize > 0) { + writeExceptionHandlers(buf, pos); + } + } + + private void writeExceptionHandlers(BufWriterImpl buf, int pos) { + int handlersSize = handlers.size(); for (AbstractPseudoInstruction.ExceptionCatchImpl h : handlers) { int startPc = labelToBci(h.tryStart()); int endPc = labelToBci(h.tryEnd()); int handlerPc = labelToBci(h.handler()); if (startPc == -1 || endPc == -1 || handlerPc == -1) { - if (context.deadLabelsOption() == ClassFile.DeadLabelsOption.DROP_DEAD_LABELS) { + if (context.dropDeadLabels()) { handlersSize--; } else { throw new IllegalArgumentException("Unbound label in exception handler"); } } else { - buf.writeU2(startPc); - buf.writeU2(endPc); - buf.writeU2(handlerPc); + buf.writeU2U2U2(startPc, endPc, handlerPc); buf.writeIndexOrZero(h.catchTypeEntry()); handlersSize++; } } if (handlersSize < handlers.size()) - buf.patchInt(pos, 2, handlersSize); + buf.patchU2(pos, handlersSize); } private void buildContent() { @@ -219,80 +237,81 @@ public final class DirectCodeBuilder // Backfill branches for which Label didn't have position yet processDeferredLabels(); - if (context.debugElementsOption() == ClassFile.DebugElementsOption.PASS_DEBUG) { - if (!characterRanges.isEmpty()) { + if (context.passDebugElements()) { + if (characterRangesCount > 0) { Attribute a = new UnboundAttribute.AdHocAttribute<>(Attributes.characterRangeTable()) { @Override public void writeBody(BufWriterImpl b) { int pos = b.size(); - int crSize = characterRanges.size(); + int crSize = characterRangesCount; b.writeU2(crSize); - for (CharacterRange cr : characterRanges) { + for (int i = 0; i < characterRangesCount; i++) { + CharacterRange cr = characterRanges[i]; var start = labelToBci(cr.startScope()); var end = labelToBci(cr.endScope()); if (start == -1 || end == -1) { - if (context.deadLabelsOption() == ClassFile.DeadLabelsOption.DROP_DEAD_LABELS) { + if (context.dropDeadLabels()) { crSize--; } else { throw new IllegalArgumentException("Unbound label in character range"); } } else { - b.writeU2(start); - b.writeU2(end - 1); - b.writeInt(cr.characterRangeStart()); - b.writeInt(cr.characterRangeEnd()); + b.writeU2U2(start, end - 1); + b.writeIntInt(cr.characterRangeStart(), cr.characterRangeEnd()); b.writeU2(cr.flags()); } } - if (crSize < characterRanges.size()) - b.patchInt(pos, 2, crSize); + if (crSize < characterRangesCount) + b.patchU2(pos, crSize); } }; attributes.withAttribute(a); } - if (!localVariables.isEmpty()) { + if (localVariablesCount > 0) { Attribute a = new UnboundAttribute.AdHocAttribute<>(Attributes.localVariableTable()) { @Override public void writeBody(BufWriterImpl b) { int pos = b.size(); - int lvSize = localVariables.size(); + int lvSize = localVariablesCount; b.writeU2(lvSize); - for (LocalVariable l : localVariables) { + for (int i = 0; i < localVariablesCount; i++) { + LocalVariable l = localVariables[i]; if (!Util.writeLocalVariable(b, l)) { - if (context.deadLabelsOption() == ClassFile.DeadLabelsOption.DROP_DEAD_LABELS) { + if (context.dropDeadLabels()) { lvSize--; } else { throw new IllegalArgumentException("Unbound label in local variable type"); } } } - if (lvSize < localVariables.size()) - b.patchInt(pos, 2, lvSize); + if (lvSize < localVariablesCount) + b.patchU2(pos, lvSize); } }; attributes.withAttribute(a); } - if (!localVariableTypes.isEmpty()) { + if (localVariableTypesCount > 0) { Attribute a = new UnboundAttribute.AdHocAttribute<>(Attributes.localVariableTypeTable()) { @Override public void writeBody(BufWriterImpl b) { int pos = b.size(); - int lvtSize = localVariableTypes.size(); - b.writeU2(localVariableTypes.size()); - for (LocalVariableType l : localVariableTypes) { + int lvtSize = localVariableTypesCount; + b.writeU2(lvtSize); + for (int i = 0; i < localVariableTypesCount; i++) { + LocalVariableType l = localVariableTypes[i]; if (!Util.writeLocalVariable(b, l)) { - if (context.deadLabelsOption() == ClassFile.DeadLabelsOption.DROP_DEAD_LABELS) { + if (context.dropDeadLabels()) { lvtSize--; } else { throw new IllegalArgumentException("Unbound label in local variable type"); } } } - if (lvtSize < localVariableTypes.size()) - b.patchInt(pos, 2, lvtSize); + if (lvtSize < localVariableTypesCount) + b.patchU2(pos, lvtSize); } }; attributes.withAttribute(a); @@ -308,22 +327,20 @@ public final class DirectCodeBuilder private void writeCounters(boolean codeMatch, BufWriterImpl buf) { if (codeMatch) { var originalAttribute = (CodeImpl) original; - buf.writeU2(originalAttribute.maxStack()); - buf.writeU2(originalAttribute.maxLocals()); + buf.writeU2U2(originalAttribute.maxStack(), originalAttribute.maxLocals()); } else { StackCounter cntr = StackCounter.of(DirectCodeBuilder.this, buf); - buf.writeU2(cntr.maxStack()); - buf.writeU2(cntr.maxLocals()); + buf.writeU2U2(cntr.maxStack(), cntr.maxLocals()); } } private void generateStackMaps(BufWriterImpl buf) throws IllegalArgumentException { //new instance of generator immediately calculates maxStack, maxLocals, all frames, // patches dead bytecode blocks and removes them from exception table - StackMapGenerator gen = StackMapGenerator.of(DirectCodeBuilder.this, buf); - attributes.withAttribute(gen.stackMapTableAttribute()); - buf.writeU2(gen.maxStack()); - buf.writeU2(gen.maxLocals()); + var dcb = DirectCodeBuilder.this; + StackMapGenerator gen = StackMapGenerator.of(dcb, buf); + dcb.attributes.withAttribute(gen.stackMapTableAttribute()); + buf.writeU2U2(gen.maxStack(), gen.maxLocals()); } private void tryGenerateStackMaps(boolean codeMatch, BufWriterImpl buf) { @@ -345,43 +362,37 @@ public final class DirectCodeBuilder @Override public void writeBody(BufWriterImpl buf) { - buf.setLabelContext(DirectCodeBuilder.this); + DirectCodeBuilder dcb = DirectCodeBuilder.this; + buf.setLabelContext(dcb); int codeLength = curPc(); if (codeLength == 0 || codeLength >= 65536) { throw new IllegalArgumentException(String.format( "Code length %d is outside the allowed range in %s%s", codeLength, - methodInfo.methodName().stringValue(), - methodInfo.methodTypeSymbol().displayDescriptor())); + dcb.methodInfo.methodName().stringValue(), + dcb.methodInfo.methodTypeSymbol().displayDescriptor())); } - if (codeAndExceptionsMatch(codeLength)) { - switch (context.stackMapsOption()) { - case STACK_MAPS_WHEN_REQUIRED -> { - attributes.withAttribute(original.findAttribute(Attributes.stackMapTable()).orElse(null)); - writeCounters(true, buf); - } - case GENERATE_STACK_MAPS -> - generateStackMaps(buf); - case DROP_STACK_MAPS -> - writeCounters(true, buf); - } - } else { - switch (context.stackMapsOption()) { - case STACK_MAPS_WHEN_REQUIRED -> - tryGenerateStackMaps(false, buf); - case GENERATE_STACK_MAPS -> - generateStackMaps(buf); - case DROP_STACK_MAPS -> - writeCounters(false, buf); + boolean codeMatch = dcb.original != null && codeAndExceptionsMatch(codeLength); + var context = dcb.context; + if (context.stackMapsWhenRequired()) { + if (codeMatch) { + dcb.attributes.withAttribute(dcb.original.findAttribute(Attributes.stackMapTable()).orElse(null)); + writeCounters(true, buf); + } else { + tryGenerateStackMaps(false, buf); } + } else if (context.generateStackMaps()) { + generateStackMaps(buf); + } else if (context.dropStackMaps()) { + writeCounters(codeMatch, buf); } buf.writeInt(codeLength); - buf.writeBytes(bytecodesBufWriter); - writeExceptionHandlers(buf); - attributes.writeTo(buf); + buf.writeBytes(dcb.bytecodesBufWriter); + dcb.writeExceptionHandlers(buf); + dcb.attributes.writeTo(buf); buf.setLabelContext(null); } }; @@ -401,8 +412,7 @@ public final class DirectCodeBuilder private void push() { //subsequent identical line numbers are skipped if (lastPc >= 0 && lastLine != writtenLine) { - buf.writeU2(lastPc); - buf.writeU2(lastLine); + buf.writeU2U2(lastPc, lastLine); writtenLine = lastLine; } } @@ -452,28 +462,16 @@ public final class DirectCodeBuilder private record DeferredLabel(int labelPc, int size, int instructionPc, Label label) { } - private void writeLabelOffset(int nBytes, int instructionPc, Label label) { - int targetBci = labelToBci(label); - if (targetBci == -1) { - int pc = curPc(); - bytecodesBufWriter.writeIntBytes(nBytes, 0); - if (deferredLabels == null) - deferredLabels = new ArrayList<>(); - deferredLabels.add(new DeferredLabel(pc, nBytes, instructionPc, label)); - } - else { - int branchOffset = targetBci - instructionPc; - if (nBytes == 2 && (short)branchOffset != branchOffset) throw new LabelOverflowException(); - bytecodesBufWriter.writeIntBytes(nBytes, branchOffset); - } - } - private void processDeferredLabels() { - if (deferredLabels != null) { - for (DeferredLabel dl : deferredLabels) { - int branchOffset = labelToBci(dl.label) - dl.instructionPc; - if (dl.size == 2 && (short)branchOffset != branchOffset) throw new LabelOverflowException(); - bytecodesBufWriter.patchInt(dl.labelPc, dl.size, branchOffset); + for (int i = 0; i < deferredLabelsCount; i++) { + DeferredLabel dl = deferredLabels[i]; + int branchOffset = labelToBci(dl.label) - dl.instructionPc; + if (dl.size == 2) { + if ((short) branchOffset != branchOffset) throw new LabelOverflowException(); + bytecodesBufWriter.patchU2(dl.labelPc, branchOffset); + } else { + assert dl.size == 4; + bytecodesBufWriter.patchInt(dl.labelPc, branchOffset); } } } @@ -481,73 +479,143 @@ public final class DirectCodeBuilder // Instruction writing public void writeBytecode(Opcode opcode) { - if (opcode.isWide()) - bytecodesBufWriter.writeU1(ClassFile.WIDE); - bytecodesBufWriter.writeU1(opcode.bytecode() & 0xFF); + assert !opcode.isWide(); + bytecodesBufWriter.writeU1(opcode.bytecode()); } - public void writeLocalVar(Opcode opcode, int localVar) { - writeBytecode(opcode); - switch (opcode.sizeIfFixed()) { - case 1 -> { } - case 2 -> bytecodesBufWriter.writeU1(localVar); - case 4 -> bytecodesBufWriter.writeU2(localVar); - default -> throw new IllegalArgumentException("Unexpected instruction size: " + opcode); + // Instruction version, refer to opcode + public void writeLocalVar(Opcode opcode, int slot) { + if (opcode.isWide()) { + bytecodesBufWriter.writeU2U2(opcode.bytecode(), slot); + } else { + bytecodesBufWriter.writeU1U1(opcode.bytecode(), slot); } } - public void writeIncrement(int slot, int val) { - Opcode opcode = (slot < 256 && val < 128 && val > -127) - ? IINC - : IINC_W; - writeBytecode(opcode); - if (opcode.isWide()) { - bytecodesBufWriter.writeU2(slot); - bytecodesBufWriter.writeU2(val); + // Shortcut version, refer to and validate slot + private void writeLocalVar(int bytecode, int slot) { + // TODO validation like (slot & 0xFFFF) == slot + if (slot < 256) { + bytecodesBufWriter.writeU1U1(bytecode, slot); } else { - bytecodesBufWriter.writeU1(slot); - bytecodesBufWriter.writeU1(val); + bytecodesBufWriter.writeU1U1U2(WIDE, bytecode, slot); + } + } + + public void writeIncrement(boolean wide, int slot, int val) { + if (wide) { + bytecodesBufWriter.writeU2U2U2((WIDE << 8) | IINC, slot, val); + } else { + bytecodesBufWriter.writeU1U1U1(IINC, slot, val); } } public void writeBranch(Opcode op, Label target) { + if (op.sizeIfFixed() == 3) { + writeShortJump(op.bytecode(), target); + } else { + writeLongJump(op.bytecode(), target); + } + } + + private void writeLongLabelOffset(int instructionPc, Label label) { + int targetBci = labelToBci(label); + + // algebraic union of jump | (instructionPc, target), distinguished by null == target. + int jumpOrInstructionPc; + Label nullOrTarget; + if (targetBci == -1) { + jumpOrInstructionPc = instructionPc; + nullOrTarget = label; + } else { + jumpOrInstructionPc = targetBci - instructionPc; + nullOrTarget = null; + } + + writeParsedLongLabel(jumpOrInstructionPc, nullOrTarget); + } + + private void writeShortJump(int bytecode, Label target) { int instructionPc = curPc(); int targetBci = labelToBci(target); - //transform short-opcode forward jumps if enforced, and backward jumps if enabled and overflowing - if (op.sizeIfFixed() == 3 && (targetBci == -1 - ? transformFwdJumps - : (transformBackJumps - && targetBci - instructionPc < Short.MIN_VALUE))) { - if (op == GOTO) { - writeBytecode(GOTO_W); - writeLabelOffset(4, instructionPc, target); - } else if (op == JSR) { - writeBytecode(JSR_W); - writeLabelOffset(4, instructionPc, target); - } else { - writeBytecode(BytecodeHelpers.reverseBranchOpcode(op)); - Label bypassJump = newLabel(); - writeLabelOffset(2, instructionPc, bypassJump); - writeBytecode(GOTO_W); - writeLabelOffset(4, instructionPc + 3, target); - labelBinding(bypassJump); - } + + // algebraic union of jump | (instructionPc, target), distinguished by null == target. + int jumpOrInstructionPc; + Label nullOrTarget; + if (targetBci == -1) { + jumpOrInstructionPc = instructionPc; + nullOrTarget = target; } else { - writeBytecode(op); - writeLabelOffset(op.sizeIfFixed() == 3 ? 2 : 4, instructionPc, target); + jumpOrInstructionPc = targetBci - instructionPc; + nullOrTarget = null; + } + + //transform short-opcode forward jumps if enforced, and backward jumps if enabled and overflowing + if (transformDeferredJumps || transformKnownJumps && nullOrTarget == null && jumpOrInstructionPc < Short.MIN_VALUE) { + fixShortJump(bytecode, jumpOrInstructionPc, nullOrTarget); + } else { + bytecodesBufWriter.writeU1(bytecode); + writeParsedShortLabel(jumpOrInstructionPc, nullOrTarget); + } + } + + private void writeLongJump(int bytecode, Label target) { + int instructionPc = curPc(); + bytecodesBufWriter.writeU1(bytecode); + writeLongLabelOffset(instructionPc, target); + } + + private void fixShortJump(int bytecode, int jumpOrInstructionPc, Label nullOrTarget) { + if (bytecode == GOTO) { + bytecodesBufWriter.writeU1(GOTO_W); + writeParsedLongLabel(jumpOrInstructionPc, nullOrTarget); + } else if (bytecode == JSR) { + bytecodesBufWriter.writeU1(JSR_W); + writeParsedLongLabel(jumpOrInstructionPc, nullOrTarget); + } else { + bytecodesBufWriter.writeU1U2( + BytecodeHelpers.reverseBranchOpcode(bytecode), // u1 + 8); // u1 + s2 + u1 + s4 // s2 + bytecodesBufWriter.writeU1(GOTO_W); // u1 + if (nullOrTarget == null) { + jumpOrInstructionPc -= 3; // jump -= 3; + } else { + jumpOrInstructionPc += 3; // instructionPc += 3; + } + writeParsedLongLabel(jumpOrInstructionPc, nullOrTarget); // s4 + } + } + + private void writeParsedShortLabel(int jumpOrInstructionPc, Label nullOrTarget) { + if (nullOrTarget == null) { + if ((short) jumpOrInstructionPc != jumpOrInstructionPc) + throw new LabelOverflowException(); + bytecodesBufWriter.writeU2(jumpOrInstructionPc); + } else { + int pc = bytecodesBufWriter.skip(2); + addLabel(new DeferredLabel(pc, 2, jumpOrInstructionPc, nullOrTarget)); + } + } + + private void writeParsedLongLabel(int jumpOrInstructionPc, Label nullOrTarget) { + if (nullOrTarget == null) { + bytecodesBufWriter.writeInt(jumpOrInstructionPc); + } else { + int pc = bytecodesBufWriter.skip(4); + addLabel(new DeferredLabel(pc, 4, jumpOrInstructionPc, nullOrTarget)); } } public void writeLookupSwitch(Label defaultTarget, List cases) { int instructionPc = curPc(); - writeBytecode(LOOKUPSWITCH); + bytecodesBufWriter.writeU1(LOOKUPSWITCH); int pad = 4 - (curPc() % 4); if (pad != 4) - bytecodesBufWriter.writeIntBytes(pad, 0); - writeLabelOffset(4, instructionPc, defaultTarget); + bytecodesBufWriter.skip(pad); // padding content can be anything + writeLongLabelOffset(instructionPc, defaultTarget); bytecodesBufWriter.writeInt(cases.size()); cases = new ArrayList<>(cases); - cases.sort(new Comparator() { + cases.sort(new Comparator<>() { @Override public int compare(SwitchCase c1, SwitchCase c2) { return Integer.compare(c1.caseValue(), c2.caseValue()); @@ -555,103 +623,91 @@ public final class DirectCodeBuilder }); for (var c : cases) { bytecodesBufWriter.writeInt(c.caseValue()); - writeLabelOffset(4, instructionPc, c.target()); + var target = c.target(); + writeLongLabelOffset(instructionPc, target); } } public void writeTableSwitch(int low, int high, Label defaultTarget, List cases) { int instructionPc = curPc(); - writeBytecode(TABLESWITCH); + bytecodesBufWriter.writeU1(TABLESWITCH); int pad = 4 - (curPc() % 4); if (pad != 4) - bytecodesBufWriter.writeIntBytes(pad, 0); - writeLabelOffset(4, instructionPc, defaultTarget); - bytecodesBufWriter.writeInt(low); - bytecodesBufWriter.writeInt(high); + bytecodesBufWriter.skip(pad); // padding content can be anything + writeLongLabelOffset(instructionPc, defaultTarget); + bytecodesBufWriter.writeIntInt(low, high); var caseMap = new HashMap(cases.size()); for (var c : cases) { caseMap.put(c.caseValue(), c.target()); } for (long l = low; l<=high; l++) { - writeLabelOffset(4, instructionPc, caseMap.getOrDefault((int)l, defaultTarget)); + var target = caseMap.getOrDefault((int)l, defaultTarget); + writeLongLabelOffset(instructionPc, target); } } public void writeFieldAccess(Opcode opcode, FieldRefEntry ref) { - writeBytecode(opcode); - bytecodesBufWriter.writeIndex(ref); + bytecodesBufWriter.writeIndex(opcode.bytecode(), ref); } public void writeInvokeNormal(Opcode opcode, MemberRefEntry ref) { - writeBytecode(opcode); - bytecodesBufWriter.writeIndex(ref); + bytecodesBufWriter.writeIndex(opcode.bytecode(), ref); } public void writeInvokeInterface(Opcode opcode, InterfaceMethodRefEntry ref, int count) { - writeBytecode(opcode); - bytecodesBufWriter.writeIndex(ref); - bytecodesBufWriter.writeU1(count); - bytecodesBufWriter.writeU1(0); + bytecodesBufWriter.writeIndex(opcode.bytecode(), ref); + bytecodesBufWriter.writeU1U1(count, 0); } public void writeInvokeDynamic(InvokeDynamicEntry ref) { - writeBytecode(INVOKEDYNAMIC); - bytecodesBufWriter.writeIndex(ref); - bytecodesBufWriter.writeU2(0); + bytecodesBufWriter.writeU1U2U2(INVOKEDYNAMIC, bytecodesBufWriter.cpIndex(ref), 0); } public void writeNewObject(ClassEntry type) { - writeBytecode(NEW); - bytecodesBufWriter.writeIndex(type); + bytecodesBufWriter.writeIndex(NEW, type); } public void writeNewPrimitiveArray(int newArrayCode) { - writeBytecode(NEWARRAY); - bytecodesBufWriter.writeU1(newArrayCode); + bytecodesBufWriter.writeU1U1(NEWARRAY, newArrayCode); } public void writeNewReferenceArray(ClassEntry type) { - writeBytecode(ANEWARRAY); - bytecodesBufWriter.writeIndex(type); + bytecodesBufWriter.writeIndex(ANEWARRAY, type); } public void writeNewMultidimensionalArray(int dimensions, ClassEntry type) { - writeBytecode(MULTIANEWARRAY); - bytecodesBufWriter.writeIndex(type); + bytecodesBufWriter.writeIndex(MULTIANEWARRAY, type); bytecodesBufWriter.writeU1(dimensions); } public void writeTypeCheck(Opcode opcode, ClassEntry type) { - writeBytecode(opcode); - bytecodesBufWriter.writeIndex(type); + bytecodesBufWriter.writeIndex(opcode.bytecode(), type); } public void writeArgumentConstant(Opcode opcode, int value) { - writeBytecode(opcode); if (opcode.sizeIfFixed() == 3) { - bytecodesBufWriter.writeU2(value); + bytecodesBufWriter.writeU1U2(opcode.bytecode(), value); } else { - bytecodesBufWriter.writeU1(value); + bytecodesBufWriter.writeU1U1(opcode.bytecode(), value); } } public void writeLoadConstant(Opcode opcode, LoadableConstantEntry value) { // Make sure Long and Double have LDC2_W and - // rewrite to _W if index is > 256 + // rewrite to _W if index is >= 256 int index = AbstractPoolEntry.maybeClone(constantPool, value).index(); - Opcode op = opcode; if (value instanceof LongEntry || value instanceof DoubleEntry) { - op = LDC2_W; + opcode = Opcode.LDC2_W; } else if (index >= 256) - op = LDC_W; + opcode = Opcode.LDC_W; - writeBytecode(op); - if (op.sizeIfFixed() == 3) { - bytecodesBufWriter.writeU2(index); + assert !opcode.isWide(); + if (opcode.sizeIfFixed() == 3) { + bytecodesBufWriter.writeU1U2(opcode.bytecode(), index); } else { - bytecodesBufWriter.writeU1(index); + bytecodesBufWriter.writeU1U1(opcode.bytecode(), index); } } @@ -667,7 +723,11 @@ public final class DirectCodeBuilder if (context == this) { return lab.getBCI(); } - else if (context == mruParent) { + return labelToBci(context, lab); + } + + private int labelToBci(LabelContext context, LabelImpl lab) { + if (context == mruParent) { return mruParentTable[lab.getBCI()] - 1; } else if (context instanceof CodeAttribute parent) { @@ -707,14 +767,18 @@ public final class DirectCodeBuilder @Override public void setLabelTarget(Label label, int bci) { LabelImpl lab = (LabelImpl) label; - LabelContext context = lab.labelContext(); - - if (context == this) { + if (lab.labelContext() == this) { if (lab.getBCI() != -1) throw new IllegalArgumentException("Setting label target for already-set label"); lab.setBCI(bci); + } else { + setLabelTarget(lab, bci); } - else if (context == mruParent) { + } + + private void setLabelTarget(LabelImpl lab, int bci) { + LabelContext context = lab.labelContext(); + if (context == mruParent) { mruParentTable[lab.getBCI()] = bci + 1; } else if (context instanceof CodeAttribute parent) { @@ -729,7 +793,7 @@ public final class DirectCodeBuilder mruParent = parent; mruParentTable = table; - mruParentTable[lab.getBCI()] = bci + 1; + table[lab.getBCI()] = bci + 1; } else if (context instanceof BufferedCodeBuilder) { // Hijack the label @@ -741,7 +805,19 @@ public final class DirectCodeBuilder } public void addCharacterRange(CharacterRange element) { - characterRanges.add(element); + if (characterRangesCount >= characterRanges.length) { + int newCapacity = characterRangesCount + 8; + this.characterRanges = Arrays.copyOf(characterRanges, newCapacity); + } + characterRanges[characterRangesCount++] = element; + } + + public void addLabel(DeferredLabel label) { + if (deferredLabelsCount >= deferredLabels.length) { + int newCapacity = deferredLabelsCount + 8; + this.deferredLabels = Arrays.copyOf(deferredLabels, newCapacity); + } + deferredLabels[deferredLabelsCount++] = label; } public void addHandler(ExceptionCatch element) { @@ -753,11 +829,19 @@ public final class DirectCodeBuilder } public void addLocalVariable(LocalVariable element) { - localVariables.add(element); + if (localVariablesCount >= localVariables.length) { + int newCapacity = localVariablesCount + 8; + this.localVariables = Arrays.copyOf(localVariables, newCapacity); + } + localVariables[localVariablesCount++] = element; } public void addLocalVariableType(LocalVariableType element) { - localVariableTypes.add(element); + if (localVariableTypesCount >= localVariableTypes.length) { + int newCapacity = localVariableTypesCount + 8; + this.localVariableTypes = Arrays.copyOf(localVariableTypes, newCapacity); + } + localVariableTypes[localVariableTypesCount++] = element; } @Override @@ -778,28 +862,54 @@ public final class DirectCodeBuilder // Fast overrides to avoid intermediate instructions // These are helpful for direct class building + @Override + public CodeBuilder return_() { + bytecodesBufWriter.writeU1(RETURN); + return this; + } + @Override public CodeBuilder return_(TypeKind tk) { - writeBytecode(BytecodeHelpers.returnOpcode(tk)); + bytecodesBufWriter.writeU1(returnBytecode(tk)); return this; } @Override public CodeBuilder storeLocal(TypeKind tk, int slot) { - writeLocalVar(BytecodeHelpers.storeOpcode(tk, slot), slot); + return switch (tk) { + case INT, SHORT, BYTE, CHAR, BOOLEAN + -> istore(slot); + case LONG -> lstore(slot); + case DOUBLE -> dstore(slot); + case FLOAT -> fstore(slot); + case REFERENCE -> astore(slot); + case VOID -> throw new IllegalArgumentException("void"); + }; + } + + @Override + public CodeBuilder labelBinding(Label label) { + setLabelTarget(label, curPc()); return this; } @Override public CodeBuilder loadLocal(TypeKind tk, int slot) { - writeLocalVar(BytecodeHelpers.loadOpcode(tk, slot), slot); - return this; + return switch (tk) { + case INT, SHORT, BYTE, CHAR, BOOLEAN + -> iload(slot); + case LONG -> lload(slot); + case DOUBLE -> dload(slot); + case FLOAT -> fload(slot); + case REFERENCE -> aload(slot); + case VOID -> throw new IllegalArgumentException("void"); + }; } @Override public CodeBuilder invoke(Opcode opcode, MemberRefEntry ref) { - if (opcode == INVOKEINTERFACE) { - int slots = Util.parameterSlots(Util.methodTypeSymbol(ref.nameAndType())) + 1; + if (opcode == Opcode.INVOKEINTERFACE) { + int slots = Util.parameterSlots(Util.methodTypeSymbol(ref.type())) + 1; writeInvokeInterface(opcode, (InterfaceMethodRefEntry) ref, slots); } else { writeInvokeNormal(opcode, ref); @@ -807,21 +917,45 @@ public final class DirectCodeBuilder return this; } + @Override + public CodeBuilder invokespecial(ClassDesc owner, String name, MethodTypeDesc type) { + bytecodesBufWriter.writeIndex(INVOKESPECIAL, constantPool().methodRefEntry(owner, name, type)); + return this; + } + + @Override + public CodeBuilder invokestatic(ClassDesc owner, String name, MethodTypeDesc type) { + bytecodesBufWriter.writeIndex(INVOKESTATIC, constantPool().methodRefEntry(owner, name, type)); + return this; + } + + @Override + public CodeBuilder invokevirtual(ClassDesc owner, String name, MethodTypeDesc type) { + bytecodesBufWriter.writeIndex(INVOKEVIRTUAL, constantPool().methodRefEntry(owner, name, type)); + return this; + } + + @Override + public CodeBuilder getfield(ClassDesc owner, String name, ClassDesc type) { + bytecodesBufWriter.writeIndex(GETFIELD, constantPool().fieldRefEntry(owner, name, type)); + return this; + } + @Override public CodeBuilder fieldAccess(Opcode opcode, FieldRefEntry ref) { - writeFieldAccess(opcode, ref); + bytecodesBufWriter.writeIndex(opcode.bytecode(), ref); return this; } @Override public CodeBuilder arrayLoad(TypeKind tk) { - writeBytecode(BytecodeHelpers.arrayLoadOpcode(tk)); + bytecodesBufWriter.writeU1(BytecodeHelpers.arrayLoadBytecode(tk)); return this; } @Override public CodeBuilder arrayStore(TypeKind tk) { - writeBytecode(BytecodeHelpers.arrayStoreOpcode(tk)); + bytecodesBufWriter.writeU1(BytecodeHelpers.arrayStoreBytecode(tk)); return this; } @@ -833,19 +967,23 @@ public final class DirectCodeBuilder @Override public CodeBuilder nop() { - writeBytecode(NOP); + bytecodesBufWriter.writeU1(NOP); return this; } @Override public CodeBuilder aconst_null() { - writeBytecode(ACONST_NULL); + bytecodesBufWriter.writeU1(ACONST_NULL); return this; } @Override public CodeBuilder aload(int slot) { - writeLocalVar(BytecodeHelpers.aload(slot), slot); + if (slot >= 0 && slot <= 3) { + bytecodesBufWriter.writeU1(ALOAD_0 + slot); + } else { + writeLocalVar(ALOAD, slot); + } return this; } @@ -857,380 +995,530 @@ public final class DirectCodeBuilder @Override public CodeBuilder arraylength() { - writeBytecode(ARRAYLENGTH); + bytecodesBufWriter.writeU1(ARRAYLENGTH); + return this; + } + + @Override + public CodeBuilder areturn() { + bytecodesBufWriter.writeU1(ARETURN); return this; } @Override public CodeBuilder astore(int slot) { - writeLocalVar(BytecodeHelpers.astore(slot), slot); + if (slot >= 0 && slot <= 3) { + bytecodesBufWriter.writeU1(ASTORE_0 + slot); + } else { + writeLocalVar(ASTORE, slot); + } return this; } @Override public CodeBuilder athrow() { - writeBytecode(ATHROW); + bytecodesBufWriter.writeU1(ATHROW); return this; } @Override public CodeBuilder bipush(int b) { BytecodeHelpers.validateBipush(b); - writeArgumentConstant(BIPUSH, b); + bytecodesBufWriter.writeU1U1(BIPUSH, b); return this; } @Override public CodeBuilder checkcast(ClassEntry type) { - writeTypeCheck(CHECKCAST, type); + bytecodesBufWriter.writeIndex(CHECKCAST, type); return this; } @Override public CodeBuilder d2f() { - writeBytecode(D2F); + bytecodesBufWriter.writeU1(D2F); return this; } @Override public CodeBuilder d2i() { - writeBytecode(D2I); + bytecodesBufWriter.writeU1(D2I); return this; } @Override public CodeBuilder d2l() { - writeBytecode(D2L); + bytecodesBufWriter.writeU1(D2L); return this; } @Override public CodeBuilder dadd() { - writeBytecode(DADD); + bytecodesBufWriter.writeU1(DADD); return this; } @Override public CodeBuilder dcmpg() { - writeBytecode(DCMPG); + bytecodesBufWriter.writeU1(DCMPG); return this; } @Override public CodeBuilder dcmpl() { - writeBytecode(DCMPL); + bytecodesBufWriter.writeU1(DCMPL); return this; } @Override public CodeBuilder dconst_0() { - writeBytecode(DCONST_0); + bytecodesBufWriter.writeU1(DCONST_0); return this; } @Override public CodeBuilder dconst_1() { - writeBytecode(DCONST_1); + bytecodesBufWriter.writeU1(DCONST_1); return this; } @Override public CodeBuilder ddiv() { - writeBytecode(DDIV); + bytecodesBufWriter.writeU1(DDIV); return this; } @Override public CodeBuilder dload(int slot) { - writeLocalVar(BytecodeHelpers.dload(slot), slot); + if (slot >= 0 && slot <= 3) { + bytecodesBufWriter.writeU1(DLOAD_0 + slot); + } else { + writeLocalVar(DLOAD, slot); + } return this; } @Override public CodeBuilder dmul() { - writeBytecode(DMUL); + bytecodesBufWriter.writeU1(DMUL); return this; } @Override public CodeBuilder dneg() { - writeBytecode(DNEG); + bytecodesBufWriter.writeU1(DNEG); return this; } @Override public CodeBuilder drem() { - writeBytecode(DREM); + bytecodesBufWriter.writeU1(DREM); + return this; + } + + @Override + public CodeBuilder dreturn() { + bytecodesBufWriter.writeU1(DRETURN); return this; } @Override public CodeBuilder dstore(int slot) { - writeLocalVar(BytecodeHelpers.dstore(slot), slot); + if (slot >= 0 && slot <= 3) { + bytecodesBufWriter.writeU1(DSTORE_0 + slot); + } else { + writeLocalVar(DSTORE, slot); + } return this; } @Override public CodeBuilder dsub() { - writeBytecode(DSUB); + bytecodesBufWriter.writeU1(DSUB); return this; } @Override public CodeBuilder dup() { - writeBytecode(DUP); + bytecodesBufWriter.writeU1(DUP); return this; } @Override public CodeBuilder dup2() { - writeBytecode(DUP2); + bytecodesBufWriter.writeU1(DUP2); return this; } @Override public CodeBuilder dup2_x1() { - writeBytecode(DUP2_X1); + bytecodesBufWriter.writeU1(DUP2_X1); return this; } @Override public CodeBuilder dup2_x2() { - writeBytecode(DUP2_X2); + bytecodesBufWriter.writeU1(DUP2_X2); return this; } @Override public CodeBuilder dup_x1() { - writeBytecode(DUP_X1); + bytecodesBufWriter.writeU1(DUP_X1); return this; } @Override public CodeBuilder dup_x2() { - writeBytecode(DUP_X2); + bytecodesBufWriter.writeU1(DUP_X2); return this; } @Override public CodeBuilder f2d() { - writeBytecode(F2D); + bytecodesBufWriter.writeU1(F2D); return this; } @Override public CodeBuilder f2i() { - writeBytecode(F2I); + bytecodesBufWriter.writeU1(F2I); return this; } @Override public CodeBuilder f2l() { - writeBytecode(F2L); + bytecodesBufWriter.writeU1(F2L); return this; } @Override public CodeBuilder fadd() { - writeBytecode(FADD); + bytecodesBufWriter.writeU1(FADD); return this; } @Override public CodeBuilder fcmpg() { - writeBytecode(FCMPG); + bytecodesBufWriter.writeU1(FCMPG); return this; } @Override public CodeBuilder fcmpl() { - writeBytecode(FCMPL); + bytecodesBufWriter.writeU1(FCMPL); return this; } @Override public CodeBuilder fconst_0() { - writeBytecode(FCONST_0); + bytecodesBufWriter.writeU1(FCONST_0); return this; } @Override public CodeBuilder fconst_1() { - writeBytecode(FCONST_1); + bytecodesBufWriter.writeU1(FCONST_1); return this; } @Override public CodeBuilder fconst_2() { - writeBytecode(FCONST_2); + bytecodesBufWriter.writeU1(FCONST_2); return this; } @Override public CodeBuilder fdiv() { - writeBytecode(FDIV); + bytecodesBufWriter.writeU1(FDIV); return this; } @Override public CodeBuilder fload(int slot) { - writeLocalVar(BytecodeHelpers.fload(slot), slot); + if (slot >= 0 && slot <= 3) { + bytecodesBufWriter.writeU1(FLOAD_0 + slot); + } else { + writeLocalVar(FLOAD, slot); + } return this; } @Override public CodeBuilder fmul() { - writeBytecode(FMUL); + bytecodesBufWriter.writeU1(FMUL); return this; } @Override public CodeBuilder fneg() { - writeBytecode(FNEG); + bytecodesBufWriter.writeU1(FNEG); return this; } @Override public CodeBuilder frem() { - writeBytecode(FREM); + bytecodesBufWriter.writeU1(FREM); + return this; + } + + @Override + public CodeBuilder freturn() { + bytecodesBufWriter.writeU1(FRETURN); return this; } @Override public CodeBuilder fstore(int slot) { - writeLocalVar(BytecodeHelpers.fstore(slot), slot); + if (slot >= 0 && slot <= 3) { + bytecodesBufWriter.writeU1(FSTORE_0 + slot); + } else { + writeLocalVar(FSTORE, slot); + } return this; } @Override public CodeBuilder fsub() { - writeBytecode(FSUB); + bytecodesBufWriter.writeU1(FSUB); + return this; + } + + @Override + public CodeBuilder getstatic(ClassDesc owner, String name, ClassDesc type) { + bytecodesBufWriter.writeIndex(GETSTATIC, constantPool().fieldRefEntry(owner, name, type)); + return this; + } + + @Override + public CodeBuilder goto_(Label target) { + writeShortJump(GOTO, target); return this; } @Override public CodeBuilder i2b() { - writeBytecode(I2B); + bytecodesBufWriter.writeU1(I2B); return this; } @Override public CodeBuilder i2c() { - writeBytecode(I2C); + bytecodesBufWriter.writeU1(I2C); return this; } @Override public CodeBuilder i2d() { - writeBytecode(I2D); + bytecodesBufWriter.writeU1(I2D); return this; } @Override public CodeBuilder i2f() { - writeBytecode(I2F); + bytecodesBufWriter.writeU1(I2F); return this; } @Override public CodeBuilder i2l() { - writeBytecode(I2L); + bytecodesBufWriter.writeU1(I2L); return this; } @Override public CodeBuilder i2s() { - writeBytecode(I2S); + bytecodesBufWriter.writeU1(I2S); return this; } @Override public CodeBuilder iadd() { - writeBytecode(IADD); + bytecodesBufWriter.writeU1(IADD); return this; } @Override public CodeBuilder iand() { - writeBytecode(IAND); + bytecodesBufWriter.writeU1(IAND); return this; } @Override public CodeBuilder iconst_0() { - writeBytecode(ICONST_0); + bytecodesBufWriter.writeU1(ICONST_0); return this; } @Override public CodeBuilder iconst_1() { - writeBytecode(ICONST_1); + bytecodesBufWriter.writeU1(ICONST_1); return this; } @Override public CodeBuilder iconst_2() { - writeBytecode(ICONST_2); + bytecodesBufWriter.writeU1(ICONST_2); return this; } @Override public CodeBuilder iconst_3() { - writeBytecode(ICONST_3); + bytecodesBufWriter.writeU1(ICONST_3); return this; } @Override public CodeBuilder iconst_4() { - writeBytecode(ICONST_4); + bytecodesBufWriter.writeU1(ICONST_4); return this; } @Override public CodeBuilder iconst_5() { - writeBytecode(ICONST_5); + bytecodesBufWriter.writeU1(ICONST_5); return this; } @Override public CodeBuilder iconst_m1() { - writeBytecode(ICONST_M1); + bytecodesBufWriter.writeU1(ICONST_M1); return this; } @Override public CodeBuilder idiv() { - writeBytecode(IDIV); + bytecodesBufWriter.writeU1(IDIV); + return this; + } + + @Override + public CodeBuilder if_acmpeq(Label target) { + writeShortJump(IF_ACMPEQ, target); + return this; + } + + @Override + public CodeBuilder if_acmpne(Label target) { + writeShortJump(IF_ACMPNE, target); + return this; + } + + @Override + public CodeBuilder if_icmpeq(Label target) { + writeShortJump(IF_ICMPEQ, target); + return this; + } + + @Override + public CodeBuilder if_icmpge(Label target) { + writeShortJump(IF_ICMPGE, target); + return this; + } + + @Override + public CodeBuilder if_icmpgt(Label target) { + writeShortJump(IF_ICMPGT, target); + return this; + } + + @Override + public CodeBuilder if_icmple(Label target) { + writeShortJump(IF_ICMPLE, target); + return this; + } + + @Override + public CodeBuilder if_icmplt(Label target) { + writeShortJump(IF_ICMPLT, target); + return this; + } + + @Override + public CodeBuilder if_icmpne(Label target) { + writeShortJump(IF_ICMPNE, target); + return this; + } + + @Override + public CodeBuilder ifnonnull(Label target) { + writeShortJump(IFNONNULL, target); + return this; + } + + @Override + public CodeBuilder ifnull(Label target) { + writeShortJump(IFNULL, target); + return this; + } + + @Override + public CodeBuilder ifeq(Label target) { + writeShortJump(IFEQ, target); + return this; + } + + @Override + public CodeBuilder ifge(Label target) { + writeShortJump(IFGE, target); + return this; + } + + @Override + public CodeBuilder ifgt(Label target) { + writeShortJump(IFGT, target); + return this; + } + + @Override + public CodeBuilder ifle(Label target) { + writeShortJump(IFLE, target); + return this; + } + + @Override + public CodeBuilder iflt(Label target) { + writeShortJump(IFLT, target); + return this; + } + + @Override + public CodeBuilder ifne(Label target) { + writeShortJump(IFNE, target); return this; } @Override public CodeBuilder iinc(int slot, int val) { - writeIncrement(slot, val); + writeIncrement(validateAndIsWideIinc(slot, val), slot, val); return this; } @Override public CodeBuilder iload(int slot) { - writeLocalVar(BytecodeHelpers.iload(slot), slot); + if (slot >= 0 && slot <= 3) { + bytecodesBufWriter.writeU1(ILOAD_0 + slot); + } else { + writeLocalVar(ILOAD, slot); + } return this; } @Override public CodeBuilder imul() { - writeBytecode(IMUL); + bytecodesBufWriter.writeU1(IMUL); return this; } @Override public CodeBuilder ineg() { - writeBytecode(INEG); + bytecodesBufWriter.writeU1(INEG); return this; } @Override public CodeBuilder instanceOf(ClassEntry target) { - writeTypeCheck(INSTANCEOF, target); + bytecodesBufWriter.writeIndex(INSTANCEOF, target); return this; } @@ -1242,85 +1530,95 @@ public final class DirectCodeBuilder @Override public CodeBuilder invokeinterface(InterfaceMethodRefEntry ref) { - writeInvokeInterface(INVOKEINTERFACE, ref, Util.parameterSlots(ref.typeSymbol()) + 1); + writeInvokeInterface(Opcode.INVOKEINTERFACE, ref, Util.parameterSlots(ref.typeSymbol()) + 1); return this; } @Override public CodeBuilder invokespecial(InterfaceMethodRefEntry ref) { - writeInvokeNormal(INVOKESPECIAL, ref); + bytecodesBufWriter.writeIndex(INVOKESPECIAL, ref); return this; } @Override public CodeBuilder invokespecial(MethodRefEntry ref) { - writeInvokeNormal(INVOKESPECIAL, ref); + bytecodesBufWriter.writeIndex(INVOKESPECIAL, ref); return this; } @Override public CodeBuilder invokestatic(InterfaceMethodRefEntry ref) { - writeInvokeNormal(INVOKESTATIC, ref); + bytecodesBufWriter.writeIndex(INVOKESTATIC, ref); return this; } @Override public CodeBuilder invokestatic(MethodRefEntry ref) { - writeInvokeNormal(INVOKESTATIC, ref); + bytecodesBufWriter.writeIndex(INVOKESTATIC, ref); return this; } @Override public CodeBuilder invokevirtual(MethodRefEntry ref) { - writeInvokeNormal(INVOKEVIRTUAL, ref); + bytecodesBufWriter.writeIndex(INVOKEVIRTUAL, ref); return this; } @Override public CodeBuilder ior() { - writeBytecode(IOR); + bytecodesBufWriter.writeU1(IOR); return this; } @Override public CodeBuilder irem() { - writeBytecode(IREM); + bytecodesBufWriter.writeU1(IREM); + return this; + } + + @Override + public CodeBuilder ireturn() { + bytecodesBufWriter.writeU1(IRETURN); return this; } @Override public CodeBuilder ishl() { - writeBytecode(ISHL); + bytecodesBufWriter.writeU1(ISHL); return this; } @Override public CodeBuilder ishr() { - writeBytecode(ISHR); + bytecodesBufWriter.writeU1(ISHR); return this; } @Override public CodeBuilder istore(int slot) { - writeLocalVar(BytecodeHelpers.istore(slot), slot); + if (slot >= 0 && slot <= 3) { + bytecodesBufWriter.writeU1(ISTORE_0 + slot); + } else { + writeLocalVar(ISTORE, slot); + } return this; } @Override public CodeBuilder isub() { - writeBytecode(ISUB); + bytecodesBufWriter.writeU1(ISUB); return this; } @Override public CodeBuilder iushr() { - writeBytecode(IUSHR); + bytecodesBufWriter.writeU1(IUSHR); return this; } @Override public CodeBuilder ixor() { - writeBytecode(IXOR); + bytecodesBufWriter.writeU1(IXOR); return this; } @@ -1332,49 +1630,49 @@ public final class DirectCodeBuilder @Override public CodeBuilder l2d() { - writeBytecode(L2D); + bytecodesBufWriter.writeU1(L2D); return this; } @Override public CodeBuilder l2f() { - writeBytecode(L2F); + bytecodesBufWriter.writeU1(L2F); return this; } @Override public CodeBuilder l2i() { - writeBytecode(L2I); + bytecodesBufWriter.writeU1(L2I); return this; } @Override public CodeBuilder ladd() { - writeBytecode(LADD); + bytecodesBufWriter.writeU1(LADD); return this; } @Override public CodeBuilder land() { - writeBytecode(LAND); + bytecodesBufWriter.writeU1(LAND); return this; } @Override public CodeBuilder lcmp() { - writeBytecode(LCMP); + bytecodesBufWriter.writeU1(LCMP); return this; } @Override public CodeBuilder lconst_0() { - writeBytecode(LCONST_0); + bytecodesBufWriter.writeU1(LCONST_0); return this; } @Override public CodeBuilder lconst_1() { - writeBytecode(LCONST_1); + bytecodesBufWriter.writeU1(LCONST_1); return this; } @@ -1386,85 +1684,99 @@ public final class DirectCodeBuilder @Override public CodeBuilder ldiv() { - writeBytecode(LDIV); + bytecodesBufWriter.writeU1(LDIV); return this; } @Override public CodeBuilder lload(int slot) { - writeLocalVar(BytecodeHelpers.lload(slot), slot); + if (slot >= 0 && slot <= 3) { + bytecodesBufWriter.writeU1(LLOAD_0 + slot); + } else { + writeLocalVar(LLOAD, slot); + } return this; } @Override public CodeBuilder lmul() { - writeBytecode(LMUL); + bytecodesBufWriter.writeU1(LMUL); return this; } @Override public CodeBuilder lneg() { - writeBytecode(LNEG); + bytecodesBufWriter.writeU1(LNEG); return this; } @Override public CodeBuilder lor() { - writeBytecode(LOR); + bytecodesBufWriter.writeU1(LOR); return this; } @Override public CodeBuilder lrem() { - writeBytecode(LREM); + bytecodesBufWriter.writeU1(LREM); + return this; + } + + @Override + public CodeBuilder lreturn() { + bytecodesBufWriter.writeU1(LRETURN); return this; } @Override public CodeBuilder lshl() { - writeBytecode(LSHL); + bytecodesBufWriter.writeU1(LSHL); return this; } @Override public CodeBuilder lshr() { - writeBytecode(LSHR); + bytecodesBufWriter.writeU1(LSHR); return this; } @Override public CodeBuilder lstore(int slot) { - writeLocalVar(BytecodeHelpers.lstore(slot), slot); + if (slot >= 0 && slot <= 3) { + bytecodesBufWriter.writeU1(LSTORE_0 + slot); + } else { + writeLocalVar(LSTORE, slot); + } return this; } @Override public CodeBuilder lsub() { - writeBytecode(LSUB); + bytecodesBufWriter.writeU1(LSUB); return this; } @Override public CodeBuilder lushr() { - writeBytecode(LUSHR); + bytecodesBufWriter.writeU1(LUSHR); return this; } @Override public CodeBuilder lxor() { - writeBytecode(LXOR); + bytecodesBufWriter.writeU1(LXOR); return this; } @Override public CodeBuilder monitorenter() { - writeBytecode(MONITORENTER); + bytecodesBufWriter.writeU1(MONITORENTER); return this; } @Override public CodeBuilder monitorexit() { - writeBytecode(MONITOREXIT); + bytecodesBufWriter.writeU1(MONITOREXIT); return this; } @@ -1491,26 +1803,26 @@ public final class DirectCodeBuilder @Override public CodeBuilder pop() { - writeBytecode(POP); + bytecodesBufWriter.writeU1(POP); return this; } @Override public CodeBuilder pop2() { - writeBytecode(POP2); + bytecodesBufWriter.writeU1(POP2); return this; } @Override public CodeBuilder sipush(int s) { BytecodeHelpers.validateSipush(s); - writeArgumentConstant(SIPUSH, s); + bytecodesBufWriter.writeU1U2(SIPUSH, s); return this; } @Override public CodeBuilder swap() { - writeBytecode(SWAP); + bytecodesBufWriter.writeU1(SWAP); return this; } diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/DirectFieldBuilder.java b/src/java.base/share/classes/jdk/internal/classfile/impl/DirectFieldBuilder.java index ce51bb1d26b..222ed6b9792 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/impl/DirectFieldBuilder.java +++ b/src/java.base/share/classes/jdk/internal/classfile/impl/DirectFieldBuilder.java @@ -33,6 +33,8 @@ import java.lang.classfile.FieldElement; import java.lang.classfile.FieldModel; import java.lang.classfile.constantpool.Utf8Entry; +import static java.util.Objects.requireNonNull; + public final class DirectFieldBuilder extends AbstractDirectBuilder implements TerminalFieldBuilder, Util.Writable { @@ -44,12 +46,13 @@ public final class DirectFieldBuilder ClassFileImpl context, Utf8Entry name, Utf8Entry type, + int flags, FieldModel original) { super(constantPool, context); setOriginal(original); - this.name = name; - this.desc = type; - this.flags = 0; + this.name = requireNonNull(name); + this.desc = requireNonNull(type); + this.flags = flags; } @Override @@ -57,7 +60,7 @@ public final class DirectFieldBuilder if (element instanceof AbstractElement ae) { ae.writeTo(this); } else { - writeAttribute((CustomAttribute) element); + writeAttribute((CustomAttribute) requireNonNull(element)); } return this; } @@ -67,15 +70,19 @@ public final class DirectFieldBuilder return this; } + @Override + public FieldBuilder withFlags(int flags) { + setFlags(flags); + return this; + } + void setFlags(int flags) { this.flags = flags; } @Override public void writeTo(BufWriterImpl buf) { - buf.writeU2(flags); - buf.writeIndex(name); - buf.writeIndex(desc); + buf.writeU2U2U2(flags, buf.cpIndex(name), buf.cpIndex(desc)); attributes.writeTo(buf); } } diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/DirectMethodBuilder.java b/src/java.base/share/classes/jdk/internal/classfile/impl/DirectMethodBuilder.java index f79eb0af0cb..cdd5f8155e1 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/impl/DirectMethodBuilder.java +++ b/src/java.base/share/classes/jdk/internal/classfile/impl/DirectMethodBuilder.java @@ -38,6 +38,8 @@ import java.lang.classfile.MethodElement; import java.lang.classfile.MethodModel; import java.lang.classfile.constantpool.Utf8Entry; +import static java.util.Objects.requireNonNull; + public final class DirectMethodBuilder extends AbstractDirectBuilder implements TerminalMethodBuilder, Util.Writable { @@ -46,7 +48,6 @@ public final class DirectMethodBuilder final Utf8Entry desc; int flags; int[] parameterSlots; - MethodTypeDesc mDesc; public DirectMethodBuilder(SplitConstantPool constantPool, ClassFileImpl context, @@ -56,11 +57,17 @@ public final class DirectMethodBuilder MethodModel original) { super(constantPool, context); setOriginal(original); - this.name = nameInfo; - this.desc = typeInfo; + this.name = requireNonNull(nameInfo); + this.desc = requireNonNull(typeInfo); this.flags = flags; } + @Override + public MethodBuilder withFlags(int flags) { + setFlags(flags); + return this; + } + void setFlags(int flags) { boolean wasStatic = (this.flags & ClassFile.ACC_STATIC) != 0; boolean isStatic = (flags & ClassFile.ACC_STATIC) != 0; @@ -81,14 +88,7 @@ public final class DirectMethodBuilder @Override public MethodTypeDesc methodTypeSymbol() { - if (mDesc == null) { - if (original instanceof MethodInfo mi) { - mDesc = mi.methodTypeSymbol(); - } else { - mDesc = MethodTypeDesc.ofDescriptor(methodType().stringValue()); - } - } - return mDesc; + return Util.methodTypeSymbol(methodType()); } @Override @@ -98,6 +98,9 @@ public final class DirectMethodBuilder @Override public int parameterSlot(int paramNo) { + if (paramNo == 0) { + return ((flags & ClassFile.ACC_STATIC) != 0) ? 0 : 1; + } if (parameterSlots == null) parameterSlots = Util.parseParameterSlots(methodFlags(), methodTypeSymbol()); return parameterSlots[paramNo]; @@ -113,7 +116,7 @@ public final class DirectMethodBuilder if (element instanceof AbstractElement ae) { ae.writeTo(this); } else { - writeAttribute((CustomAttribute) element); + writeAttribute((CustomAttribute) requireNonNull(element)); } return this; } @@ -147,9 +150,7 @@ public final class DirectMethodBuilder @Override public void writeTo(BufWriterImpl buf) { - buf.writeU2(flags); - buf.writeIndex(name); - buf.writeIndex(desc); + buf.writeU2U2U2(flags, buf.cpIndex(name), buf.cpIndex(desc)); attributes.writeTo(buf); } } diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/EntryMap.java b/src/java.base/share/classes/jdk/internal/classfile/impl/EntryMap.java index 4270dbf79a3..be350cb5814 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/impl/EntryMap.java +++ b/src/java.base/share/classes/jdk/internal/classfile/impl/EntryMap.java @@ -33,10 +33,10 @@ package jdk.internal.classfile.impl; * element is the hash and the second is the mapped index. To look something up * in the map, provide a hash value and an index to map it to, and invoke * firstToken(hash). This returns an opaque token that can be provided to - * nextToken(hash, token) to get the next candidate, or to getElementByToken(token) - * or getIndexByToken to get the mapped element or index. + * nextToken(hash, token) to get the next candidate, or to getIndexByToken to + * get the mapped element or index. */ -public abstract class EntryMap { +public final class EntryMap { public static final int NO_VALUE = -1; /** @@ -77,8 +77,6 @@ public abstract class EntryMap { data = new int[capacity * 2]; } - protected abstract T fetchElement(int index); - public int firstToken(int hash) { if (hash == 0) throw new IllegalArgumentException("hash must be nonzero"); @@ -110,15 +108,12 @@ public abstract class EntryMap { return data[token + 1]; } - public T getElementByToken(int token) { - return fetchElement(data[token + 1]); - } - public void put(int hash, int index) { if (hash == 0) throw new IllegalArgumentException("hash must be nonzero"); int ptr = (hash & mask1) << 1; + var data = this.data; int k = data[ptr]; if (k == 0) { data[ptr] = hash; diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/FieldImpl.java b/src/java.base/share/classes/jdk/internal/classfile/impl/FieldImpl.java index 30bb8136e45..205e36588b4 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/impl/FieldImpl.java +++ b/src/java.base/share/classes/jdk/internal/classfile/impl/FieldImpl.java @@ -84,9 +84,9 @@ public final class FieldImpl reader.copyBytesTo(buf, startPos, endPos - startPos); } else { - buf.writeU2(flags().flagsMask()); - buf.writeIndex(fieldName()); - buf.writeIndex(fieldType()); + buf.writeU2U2U2(flags().flagsMask(), + buf.cpIndex(fieldName()), + buf.cpIndex(fieldType())); Util.writeAttributes(buf, attributes()); } } diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/LabelImpl.java b/src/java.base/share/classes/jdk/internal/classfile/impl/LabelImpl.java index 2aaf5f033c0..aac0fafaef1 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/impl/LabelImpl.java +++ b/src/java.base/share/classes/jdk/internal/classfile/impl/LabelImpl.java @@ -24,8 +24,6 @@ */ package jdk.internal.classfile.impl; -import java.util.Objects; - import java.lang.classfile.Label; import java.lang.classfile.instruction.LabelTarget; @@ -52,7 +50,7 @@ public final class LabelImpl private int bci; public LabelImpl(LabelContext labelContext, int bci) { - this.labelContext = Objects.requireNonNull(labelContext); + this.labelContext = labelContext; this.bci = bci; } diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/MethodImpl.java b/src/java.base/share/classes/jdk/internal/classfile/impl/MethodImpl.java index 05de881ba29..4f7799d1fa7 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/impl/MethodImpl.java +++ b/src/java.base/share/classes/jdk/internal/classfile/impl/MethodImpl.java @@ -41,7 +41,6 @@ public final class MethodImpl private final int startPos, endPos, attributesPos; private List> attributes; private int[] parameterSlots; - private MethodTypeDesc mDesc; public MethodImpl(ClassReader reader, int startPos, int endPos, int attrStart) { this.reader = reader; @@ -75,10 +74,7 @@ public final class MethodImpl @Override public MethodTypeDesc methodTypeSymbol() { - if (mDesc == null) { - mDesc = MethodTypeDesc.ofDescriptor(methodType().stringValue()); - } - return mDesc; + return Util.methodTypeSymbol(methodType()); } @Override @@ -107,9 +103,9 @@ public final class MethodImpl reader.copyBytesTo(buf, startPos, endPos - startPos); } else { - buf.writeU2(flags().flagsMask()); - buf.writeIndex(methodName()); - buf.writeIndex(methodType()); + buf.writeU2U2U2(flags().flagsMask(), + buf.cpIndex(methodName()), + buf.cpIndex(methodType())); Util.writeAttributes(buf, attributes()); } } diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/RawBytecodeHelper.java b/src/java.base/share/classes/jdk/internal/classfile/impl/RawBytecodeHelper.java index 3e5d66245f0..659f41f9699 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/impl/RawBytecodeHelper.java +++ b/src/java.base/share/classes/jdk/internal/classfile/impl/RawBytecodeHelper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,23 +24,266 @@ */ package jdk.internal.classfile.impl; -import java.nio.ByteBuffer; -import static java.lang.classfile.ClassFile.ASTORE_3; -import static java.lang.classfile.ClassFile.ISTORE; -import static java.lang.classfile.ClassFile.LOOKUPSWITCH; -import static java.lang.classfile.ClassFile.TABLESWITCH; -import static java.lang.classfile.ClassFile.WIDE; +import java.util.List; +import java.util.function.BiFunction; +import java.util.function.Function; + +import jdk.internal.misc.Unsafe; +import jdk.internal.util.Preconditions; +import jdk.internal.vm.annotation.Stable; public final class RawBytecodeHelper { - public static final int ILLEGAL = -1; + public static final BiFunction, IllegalArgumentException> + IAE_FORMATTER = Preconditions.outOfBoundsExceptionFormatter(new Function<>() { + @Override + public IllegalArgumentException apply(String s) { + return new IllegalArgumentException(s); + } + }); + public static final int + ILLEGAL = -1, + NOP = 0, + ACONST_NULL = 1, + ICONST_M1 = 2, + ICONST_0 = 3, + ICONST_1 = 4, + ICONST_2 = 5, + ICONST_3 = 6, + ICONST_4 = 7, + ICONST_5 = 8, + LCONST_0 = 9, + LCONST_1 = 10, + FCONST_0 = 11, + FCONST_1 = 12, + FCONST_2 = 13, + DCONST_0 = 14, + DCONST_1 = 15, + BIPUSH = 16, + SIPUSH = 17, + LDC = 18, + LDC_W = 19, + LDC2_W = 20, + ILOAD = 21, + LLOAD = 22, + FLOAD = 23, + DLOAD = 24, + ALOAD = 25, + ILOAD_0 = 26, + ILOAD_1 = 27, + ILOAD_2 = 28, + ILOAD_3 = 29, + LLOAD_0 = 30, + LLOAD_1 = 31, + LLOAD_2 = 32, + LLOAD_3 = 33, + FLOAD_0 = 34, + FLOAD_1 = 35, + FLOAD_2 = 36, + FLOAD_3 = 37, + DLOAD_0 = 38, + DLOAD_1 = 39, + DLOAD_2 = 40, + DLOAD_3 = 41, + ALOAD_0 = 42, + ALOAD_1 = 43, + ALOAD_2 = 44, + ALOAD_3 = 45, + IALOAD = 46, + LALOAD = 47, + FALOAD = 48, + DALOAD = 49, + AALOAD = 50, + BALOAD = 51, + CALOAD = 52, + SALOAD = 53, + ISTORE = 54, + LSTORE = 55, + FSTORE = 56, + DSTORE = 57, + ASTORE = 58, + ISTORE_0 = 59, + ISTORE_1 = 60, + ISTORE_2 = 61, + ISTORE_3 = 62, + LSTORE_0 = 63, + LSTORE_1 = 64, + LSTORE_2 = 65, + LSTORE_3 = 66, + FSTORE_0 = 67, + FSTORE_1 = 68, + FSTORE_2 = 69, + FSTORE_3 = 70, + DSTORE_0 = 71, + DSTORE_1 = 72, + DSTORE_2 = 73, + DSTORE_3 = 74, + ASTORE_0 = 75, + ASTORE_1 = 76, + ASTORE_2 = 77, + ASTORE_3 = 78, + IASTORE = 79, + LASTORE = 80, + FASTORE = 81, + DASTORE = 82, + AASTORE = 83, + BASTORE = 84, + CASTORE = 85, + SASTORE = 86, + POP = 87, + POP2 = 88, + DUP = 89, + DUP_X1 = 90, + DUP_X2 = 91, + DUP2 = 92, + DUP2_X1 = 93, + DUP2_X2 = 94, + SWAP = 95, + IADD = 96, + LADD = 97, + FADD = 98, + DADD = 99, + ISUB = 100, + LSUB = 101, + FSUB = 102, + DSUB = 103, + IMUL = 104, + LMUL = 105, + FMUL = 106, + DMUL = 107, + IDIV = 108, + LDIV = 109, + FDIV = 110, + DDIV = 111, + IREM = 112, + LREM = 113, + FREM = 114, + DREM = 115, + INEG = 116, + LNEG = 117, + FNEG = 118, + DNEG = 119, + ISHL = 120, + LSHL = 121, + ISHR = 122, + LSHR = 123, + IUSHR = 124, + LUSHR = 125, + IAND = 126, + LAND = 127, + IOR = 128, + LOR = 129, + IXOR = 130, + LXOR = 131, + IINC = 132, + I2L = 133, + I2F = 134, + I2D = 135, + L2I = 136, + L2F = 137, + L2D = 138, + F2I = 139, + F2L = 140, + F2D = 141, + D2I = 142, + D2L = 143, + D2F = 144, + I2B = 145, + I2C = 146, + I2S = 147, + LCMP = 148, + FCMPL = 149, + FCMPG = 150, + DCMPL = 151, + DCMPG = 152, + IFEQ = 153, + IFNE = 154, + IFLT = 155, + IFGE = 156, + IFGT = 157, + IFLE = 158, + IF_ICMPEQ = 159, + IF_ICMPNE = 160, + IF_ICMPLT = 161, + IF_ICMPGE = 162, + IF_ICMPGT = 163, + IF_ICMPLE = 164, + IF_ACMPEQ = 165, + IF_ACMPNE = 166, + GOTO = 167, + JSR = 168, + RET = 169, + TABLESWITCH = 170, + LOOKUPSWITCH = 171, + IRETURN = 172, + LRETURN = 173, + FRETURN = 174, + DRETURN = 175, + ARETURN = 176, + RETURN = 177, + GETSTATIC = 178, + PUTSTATIC = 179, + GETFIELD = 180, + PUTFIELD = 181, + INVOKEVIRTUAL = 182, + INVOKESPECIAL = 183, + INVOKESTATIC = 184, + INVOKEINTERFACE = 185, + INVOKEDYNAMIC = 186, + NEW = 187, + NEWARRAY = 188, + ANEWARRAY = 189, + ARRAYLENGTH = 190, + ATHROW = 191, + CHECKCAST = 192, + INSTANCEOF = 193, + MONITORENTER = 194, + MONITOREXIT = 195, + WIDE = 196, + MULTIANEWARRAY = 197, + IFNULL = 198, + IFNONNULL = 199, + GOTO_W = 200, + JSR_W = 201; - private static final byte[] LENGTHS = new byte[] { - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 2, 3, 3, 2 | (4 << 4), 2 | (4 << 4), 2 | (4 << 4), 2 | (4 << 4), 2 | (4 << 4), 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 2 | (4 << 4), 2 | (4 << 4), 2 | (4 << 4), 2 | (4 << 4), 2 | (4 << 4), 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3 | (6 << 4), 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2 | (4 << 4), 0, 0, 1, 1, 1, - 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 5, 5, 3, 2, 3, 1, 1, 3, 3, 1, 1, 0, 4, 3, 3, 5, 5, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 4, 4, 4, 2, 4, 3, 3, 0, 0, 1, 3, 2, 3, 3, 3, 1, 2, 1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 + public record CodeRange(byte[] array, int length) { + public RawBytecodeHelper start() { + return new RawBytecodeHelper(this); + } + } + + /** + * The length of opcodes, or -1 for no fixed length. + * This is generated as if: + * {@snippet lang=java : + * var lengths = new byte[0x100]; + * Arrays.fill(lengths, (byte) -1); + * for (var op : Opcode.values()) { + * if (!op.isWide()) { + * lengths[op.bytecode()] = (byte) op.sizeIfFixed(); + * } + * } + * } + * Tested in UtilTest::testOpcodeLengthTable. + */ + // Note: Consider distinguishing non-opcode and non-fixed-length opcode + public static final @Stable byte[] LENGTHS = new byte[] { + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 2, 3, 2, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, -1, -1, 1, 1, 1, 1, + 1, 1, 3, 3, 3, 3, 3, 3, 3, 5, 5, 3, 2, 3, 1, 1, + 3, 3, 1, 1, -1, 4, 3, 3, 5, 5, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, }; public static boolean isStoreIntoLocal(int code) { @@ -51,121 +294,195 @@ public final class RawBytecodeHelper { return (n + 3) & ~3; } - private final ByteBuffer bytecode; - public int bci, nextBci, endBci; - public int rawCode; - public boolean isWide; + private static final Unsafe UNSAFE = Unsafe.getUnsafe(); + public final CodeRange code; + private int nextBci; + private int bci; + private int opcode; - public RawBytecodeHelper(ByteBuffer bytecode) { - this.bytecode = bytecode; - this.bci = 0; - this.nextBci = 0; - this.endBci = bytecode.capacity(); + public static CodeRange of(byte[] array) { + return new CodeRange(array, array.length); } - public boolean isLastBytecode() { - return nextBci >= endBci; + public static CodeRange of(byte[] array, int limit) { + return new CodeRange(array, limit); + } + + private RawBytecodeHelper(CodeRange range) { + this.code = range; + } + + // immutable states + + /** {@return the end of the code array} */ + public int endBci() { + return code.length; + } + + // setup + + /** + * Sets the starting bci for bytecode reading. Can be set to + * {@link #endBci} to end scanning. Must be followed by a + * {@link #next} before getter access. + */ + public void reset(int nextBci) { + Preconditions.checkIndex(nextBci, endBci() + 1, IAE_FORMATTER); + this.nextBci = nextBci; + } + + // getters after transition + + /** + * Returns the current functional opcode, or {@link #ILLEGAL} if + * the next instruction is invalid in format. + * If this returns a valid opcode, that instruction's format must + * be valid and can be accessed unchecked. + */ + public int opcode() { + return opcode & 0xFF; + } + + /** + * Returns whether the current functional opcode is in wide. + */ + public boolean isWide() { + return (opcode & (WIDE << 8)) != 0; + } + + /** + * Returns the last validated instruction's index. + */ + public int bci() { + return bci; + } + + // general utilities + + public int getU1(int bci) { + Preconditions.checkIndex(bci, endBci(), IAE_FORMATTER); + return getU1Unchecked(bci); + } + + public int getU2(int bci) { + Preconditions.checkFromIndexSize(bci, 2, endBci(), IAE_FORMATTER); + return getU2Unchecked(bci); } public int getShort(int bci) { - return bytecode.getShort(bci); - } - - public int dest() { - return bci + getShort(bci + 1); + Preconditions.checkFromIndexSize(bci, 2, endBci(), IAE_FORMATTER); + return getShortUnchecked(bci); } public int getInt(int bci) { - return bytecode.getInt(bci); + Preconditions.checkFromIndexSize(bci, 4, endBci(), IAE_FORMATTER); + return getIntUnchecked(bci); } + // Unchecked accessors: only if opcode() is validated + + public int getU1Unchecked(int bci) { + return Byte.toUnsignedInt(code.array[bci]); + } + + public int getU2Unchecked(int bci) { + return UNSAFE.getCharUnaligned(code.array, (long) Unsafe.ARRAY_BYTE_BASE_OFFSET + bci, true); + } + + public int getShortUnchecked(int bci) { + return UNSAFE.getShortUnaligned(code.array, (long) Unsafe.ARRAY_BYTE_BASE_OFFSET + bci, true); + } + + // used after switch validation + public int getIntUnchecked(int bci) { + return UNSAFE.getIntUnaligned(code.array, (long) Unsafe.ARRAY_BYTE_BASE_OFFSET + bci, true); + } + + // non-wide branches + public int dest() { + return bci + getShortUnchecked(bci + 1); + } + + // goto_w and jsr_w public int destW() { - return bci + getInt(bci + 1); - } - - public int getIndexU1() { - return bytecode.get(bci + 1) & 0xff; - } - - public int getU1(int bci) { - return bytecode.get(bci) & 0xff; - } - - public int rawNext(int jumpTo) { - this.nextBci = jumpTo; - return rawNext(); - } - - public int rawNext() { - bci = nextBci; - int code = bytecode.get(bci) & 0xff; - int len = LENGTHS[code] & 0xf; - if (len > 0 && (bci <= endBci - len)) { - isWide = false; - nextBci += len; - if (nextBci <= bci) { - code = ILLEGAL; - } - rawCode = code; - return code; - } else { - len = switch (bytecode.get(bci) & 0xff) { - case WIDE -> { - if (bci + 1 >= endBci) { - yield -1; - } - yield LENGTHS[bytecode.get(bci + 1) & 0xff] >> 4; - } - case TABLESWITCH -> { - int aligned_bci = align(bci + 1); - if (aligned_bci + 3 * 4 >= endBci) { - yield -1; - } - int lo = bytecode.getInt(aligned_bci + 1 * 4); - int hi = bytecode.getInt(aligned_bci + 2 * 4); - int l = aligned_bci - bci + (3 + hi - lo + 1) * 4; - if (l > 0) yield l; else yield -1; - } - case LOOKUPSWITCH -> { - int aligned_bci = align(bci + 1); - if (aligned_bci + 2 * 4 >= endBci) { - yield -1; - } - int npairs = bytecode.getInt(aligned_bci + 4); - int l = aligned_bci - bci + (2 + 2 * npairs) * 4; - if (l > 0) yield l; else yield -1; - } - default -> - 0; - }; - if (len <= 0 || (bci > endBci - len) || (bci - len >= nextBci)) { - code = ILLEGAL; - } else { - nextBci += len; - isWide = false; - if (code == WIDE) { - if (bci + 1 >= endBci) { - code = ILLEGAL; - } else { - code = bytecode.get(bci + 1) & 0xff; - isWide = true; - } - } - } - rawCode = code; - return code; - } + return bci + getIntUnchecked(bci + 1); } + // *load, *store, iinc public int getIndex() { - return (isWide) ? getIndexU2Raw(bci + 2) : getIndexU1(); + return isWide() ? getU2Unchecked(bci + 2) : getIndexU1(); } + // ldc + public int getIndexU1() { + return getU1Unchecked(bci + 1); + } + + // usually cp entry index public int getIndexU2() { - return getIndexU2Raw(bci + 1); + return getU2Unchecked(bci + 1); } - public int getIndexU2Raw(int bci) { - return bytecode.getShort(bci) & 0xffff; + // Transition methods + + /** + * Transitions to the next instruction and returns whether scanning should + * continue. If the next instruction is malformed, {@link #opcode()} returns + * {@link #ILLEGAL}, so we can perform value access without bound checks if + * we have a valid opcode. + */ + public boolean next() { + var bci = nextBci; + var end = endBci(); + if (bci >= end) { + return false; + } + + int code = getU1Unchecked(bci); + int len = LENGTHS[code & 0xFF]; // & 0xFF eliminates bound check + this.bci = bci; + opcode = code; + if (len <= 0) { + len = checkSpecialInstruction(bci, end, code); // sets opcode + } + + if ((nextBci += len) > end) { + opcode = ILLEGAL; + } + + return true; + } + + // Put rarely used code in another method to reduce code size + private int checkSpecialInstruction(int bci, int end, int code) { + int len = -1; + if (code == WIDE) { + if (bci + 1 < end) { + opcode = (WIDE << 8) | (code = getIndexU1()); + // Validated in UtilTest.testOpcodeLengthTable + len = LENGTHS[code] * 2; + } + } else if (code == TABLESWITCH) { + int alignedBci = align(bci + 1); + if (alignedBci + 3 * 4 < end) { + int lo = getIntUnchecked(alignedBci + 1 * 4); + int hi = getIntUnchecked(alignedBci + 2 * 4); + long l = alignedBci - bci + (3L + (long) hi - lo + 1L) * 4L; + len = l > 0 && ((int) l == l) ? (int) l : -1; + } + } else if (code == LOOKUPSWITCH) { + int alignedBci = align(bci + 1); + if (alignedBci + 2 * 4 < end) { + int npairs = getIntUnchecked(alignedBci + 4); + if (npairs >= 0) { + long l = alignedBci - bci + (2L + 2L * npairs) * 4L; + len = l > 0 && ((int) l == l) ? (int) l : -1; + } + } + } + if (len <= 0) { + opcode = ILLEGAL; + } + return len; } } diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/SplitConstantPool.java b/src/java.base/share/classes/jdk/internal/classfile/impl/SplitConstantPool.java index 777da61c49d..4c760338857 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/impl/SplitConstantPool.java +++ b/src/java.base/share/classes/jdk/internal/classfile/impl/SplitConstantPool.java @@ -24,35 +24,21 @@ */ package jdk.internal.classfile.impl; -import java.lang.constant.ConstantDesc; +import java.lang.constant.ClassDesc; import java.lang.constant.MethodTypeDesc; import java.util.Arrays; import java.util.List; import java.lang.classfile.Attributes; import java.lang.classfile.ClassReader; -import java.lang.classfile.ClassFile; import java.lang.classfile.BootstrapMethodEntry; import java.lang.classfile.attribute.BootstrapMethodsAttribute; import java.lang.classfile.constantpool.*; -import java.util.Objects; -import static java.lang.classfile.ClassFile.TAG_CLASS; -import static java.lang.classfile.ClassFile.TAG_CONSTANTDYNAMIC; -import static java.lang.classfile.ClassFile.TAG_DOUBLE; -import static java.lang.classfile.ClassFile.TAG_FIELDREF; -import static java.lang.classfile.ClassFile.TAG_FLOAT; -import static java.lang.classfile.ClassFile.TAG_INTEGER; -import static java.lang.classfile.ClassFile.TAG_INTERFACEMETHODREF; -import static java.lang.classfile.ClassFile.TAG_INVOKEDYNAMIC; -import static java.lang.classfile.ClassFile.TAG_LONG; -import static java.lang.classfile.ClassFile.TAG_METHODHANDLE; -import static java.lang.classfile.ClassFile.TAG_METHODREF; -import static java.lang.classfile.ClassFile.TAG_METHODTYPE; -import static java.lang.classfile.ClassFile.TAG_MODULE; -import static java.lang.classfile.ClassFile.TAG_NAMEANDTYPE; -import static java.lang.classfile.ClassFile.TAG_PACKAGE; -import static java.lang.classfile.ClassFile.TAG_STRING; +import jdk.internal.constant.ConstantUtils; + +import static java.lang.classfile.constantpool.PoolEntry.*; +import static java.util.Objects.requireNonNull; public final class SplitConstantPool implements ConstantPoolBuilder { @@ -63,8 +49,8 @@ public final class SplitConstantPool implements ConstantPoolBuilder { private PoolEntry[] myEntries; private BootstrapMethodEntryImpl[] myBsmEntries; private boolean doneFullScan; - private EntryMap map; - private EntryMap bsmMap; + private EntryMap map; + private EntryMap bsmMap; public SplitConstantPool() { this.size = 1; @@ -101,20 +87,27 @@ public final class SplitConstantPool implements ConstantPoolBuilder { @Override public PoolEntry entryByIndex(int index) { if (index <= 0 || index >= size()) { - throw new ConstantPoolException("Bad CP index: " + index); + throw badCP(index); } PoolEntry pe = (index < parentSize) ? parent.entryByIndex(index) : myEntries[index - parentSize]; if (pe == null) { - throw new ConstantPoolException("Unusable CP index: " + index); + throw unusableCP(index); } return pe; } + private static ConstantPoolException badCP(int index) { + return new ConstantPoolException("Bad CP index: " + index); + } + + private static ConstantPoolException unusableCP(int index) { + return new ConstantPoolException("Unusable CP index: " + index); + } + @Override public T entryByIndex(int index, Class cls) { - Objects.requireNonNull(cls); return ClassReaderImpl.checkType(entryByIndex(index), index, cls); } @@ -130,6 +123,7 @@ public final class SplitConstantPool implements ConstantPoolBuilder { @Override public boolean canWriteDirect(ConstantPool other) { + requireNonNull(other); return this == other || parent == other; } @@ -142,8 +136,8 @@ public final class SplitConstantPool implements ConstantPoolBuilder { for (int i = parentBsmSize; i < bsmSize; i++) bootstrapMethodEntry(i).writeTo(buf); int attrLen = buf.size() - pos; - buf.patchInt(pos + 2, 4, attrLen - 6); - buf.patchInt(pos + 6, 2, bsmSize); + buf.patchInt(pos + 2, attrLen - 6); + buf.patchU2(pos + 6, bsmSize); } else { UnboundAttribute a @@ -178,14 +172,12 @@ public final class SplitConstantPool implements ConstantPoolBuilder { } } - private EntryMap map() { + private EntryMap map() { + int parentSize = this.parentSize; + var map = this.map; if (map == null) { - map = new EntryMap<>(Math.max(size, 1024), .75f) { - @Override - protected PoolEntry fetchElement(int index) { - return entryByIndex(index); - } - }; + this.map = map = new EntryMap(Math.max(size, 1024), .75f); + // Doing a full scan here yields fall-off-the-cliff performance results, // especially if we only need a few entries that are already // inflated (such as attribute names). @@ -220,14 +212,11 @@ public final class SplitConstantPool implements ConstantPoolBuilder { doneFullScan = true; } - private EntryMap bsmMap() { + private EntryMap bsmMap() { + int bsmSize = this.bsmSize; + var bsmMap = this.bsmMap; if (bsmMap == null) { - bsmMap = new EntryMap<>(Math.max(bsmSize, 16), .75f) { - @Override - protected BootstrapMethodEntryImpl fetchElement(int index) { - return bootstrapMethodEntry(index); - } - }; + this.bsmMap = bsmMap = new EntryMap(Math.max(bsmSize, 16), .75f); for (int i=0; i map = map(); + EntryMap map = map(); for (int token = map.firstToken(hash); token != -1; token = map.nextToken(hash, token)) { - PoolEntry e = map.getElementByToken(token); + PoolEntry e = entryByIndex(map.getIndexByToken(token)); if (e.tag() == TAG_INTEGER && e instanceof AbstractPoolEntry.IntegerEntryImpl ce && ce.intValue() == val) @@ -285,9 +274,9 @@ public final class SplitConstantPool implements ConstantPoolBuilder { private LongEntry findLongEntry(long val) { int hash = AbstractPoolEntry.hash1(TAG_LONG, Long.hashCode(val)); - EntryMap map = map(); + EntryMap map = map(); for (int token = map.firstToken(hash); token != -1; token = map.nextToken(hash, token)) { - PoolEntry e = map.getElementByToken(token); + PoolEntry e = entryByIndex(map.getIndexByToken(token)); if (e.tag() == TAG_LONG && e instanceof AbstractPoolEntry.LongEntryImpl ce && ce.longValue() == val) @@ -302,9 +291,9 @@ public final class SplitConstantPool implements ConstantPoolBuilder { private FloatEntry findFloatEntry(float val) { int hash = AbstractPoolEntry.hash1(TAG_FLOAT, Float.hashCode(val)); - EntryMap map = map(); + EntryMap map = map(); for (int token = map.firstToken(hash); token != -1; token = map.nextToken(hash, token)) { - PoolEntry e = map.getElementByToken(token); + PoolEntry e = entryByIndex(map.getIndexByToken(token)); if (e.tag() == TAG_FLOAT && e instanceof AbstractPoolEntry.FloatEntryImpl ce && ce.floatValue() == val) @@ -319,9 +308,9 @@ public final class SplitConstantPool implements ConstantPoolBuilder { private DoubleEntry findDoubleEntry(double val) { int hash = AbstractPoolEntry.hash1(TAG_DOUBLE, Double.hashCode(val)); - EntryMap map = map(); + EntryMap map = map(); for (int token = map.firstToken(hash); token != -1; token = map.nextToken(hash, token)) { - PoolEntry e = map.getElementByToken(token); + PoolEntry e = entryByIndex(map.getIndexByToken(token)); if (e.tag() == TAG_DOUBLE && e instanceof AbstractPoolEntry.DoubleEntryImpl ce && ce.doubleValue() == val) @@ -337,9 +326,9 @@ public final class SplitConstantPool implements ConstantPoolBuilder { private AbstractPoolEntry findEntry(int tag, T ref1) { // invariant: canWriteDirect(ref1.constantPool()) int hash = AbstractPoolEntry.hash1(tag, ref1.index()); - EntryMap map = map(); + EntryMap map = map(); for (int token = map.firstToken(hash); token != -1; token = map.nextToken(hash, token)) { - PoolEntry e = map.getElementByToken(token); + PoolEntry e = entryByIndex(map.getIndexByToken(token)); if (e.tag() == tag && e instanceof AbstractPoolEntry.AbstractRefEntry re && re.ref1 == ref1) @@ -356,9 +345,9 @@ public final class SplitConstantPool implements ConstantPoolBuilder { AbstractPoolEntry findEntry(int tag, T ref1, U ref2) { // invariant: canWriteDirect(ref1.constantPool()), canWriteDirect(ref2.constantPool()) int hash = AbstractPoolEntry.hash2(tag, ref1.index(), ref2.index()); - EntryMap map = map(); + EntryMap map = map(); for (int token = map.firstToken(hash); token != -1; token = map.nextToken(hash, token)) { - PoolEntry e = map.getElementByToken(token); + PoolEntry e = entryByIndex(map.getIndexByToken(token)); if (e.tag() == tag && e instanceof AbstractPoolEntry.AbstractRefsEntry re && re.ref1 == ref1 @@ -374,13 +363,12 @@ public final class SplitConstantPool implements ConstantPoolBuilder { } private AbstractPoolEntry.Utf8EntryImpl tryFindUtf8(int hash, String target) { - EntryMap map = map(); + EntryMap map = map(); for (int token = map.firstToken(hash); token != -1; token = map.nextToken(hash, token)) { - PoolEntry e = map.getElementByToken(token); - if (e.tag() == ClassFile.TAG_UTF8 + PoolEntry e = entryByIndex(map.getIndexByToken(token)); + if (e.tag() == TAG_UTF8 && e instanceof AbstractPoolEntry.Utf8EntryImpl ce - && ce.hashCode() == hash && target.equals(ce.stringValue())) return ce; } @@ -392,10 +380,10 @@ public final class SplitConstantPool implements ConstantPoolBuilder { } private AbstractPoolEntry.Utf8EntryImpl tryFindUtf8(int hash, AbstractPoolEntry.Utf8EntryImpl target) { - EntryMap map = map(); + EntryMap map = map(); for (int token = map.firstToken(hash); token != -1; token = map.nextToken(hash, token)) { - PoolEntry e = map.getElementByToken(token); - if (e.tag() == ClassFile.TAG_UTF8 + PoolEntry e = entryByIndex(map.getIndexByToken(token)); + if (e.tag() == TAG_UTF8 && e instanceof AbstractPoolEntry.Utf8EntryImpl ce && target.equalsUtf8(ce)) return ce; @@ -407,11 +395,111 @@ public final class SplitConstantPool implements ConstantPoolBuilder { return null; } + private AbstractPoolEntry.Utf8EntryImpl tryFindUtf8OfRegion(int hash, String target, int start, int end) { + EntryMap map = map(); + while (true) { + for (int token = map.firstToken(hash); token != -1; token = map.nextToken(hash, token)) { + PoolEntry e = entryByIndex(map.getIndexByToken(token)); + if (e.tag() == TAG_UTF8 + && e instanceof AbstractPoolEntry.Utf8EntryImpl ce + && ce.equalsRegion(target, start, end)) + return ce; + } + if (!doneFullScan) { + fullScan(); + continue; + } + return null; + } + } + + private AbstractPoolEntry.ClassEntryImpl tryFindClassOrInterface(int hash, ClassDesc cd) { + while (true) { + EntryMap map = map(); + for (int token = map.firstToken(hash); token != -1; token = map.nextToken(hash, token)) { + PoolEntry e = entryByIndex(map.getIndexByToken(token)); + if (e.tag() == TAG_CLASS + && e instanceof AbstractPoolEntry.ClassEntryImpl ce) { + var esym = ce.sym; + + if (esym != null) { + if (cd.equals(esym)) { + return ce; // definite match + } + continue; // definite mismatch + } + + // no symbol available + var desc = cd.descriptorString(); + if (ce.ref1.equalsRegion(desc, 1, desc.length() - 1)) { + // definite match, propagate symbol + ce.sym = cd; + return ce; + } + // definite mismatch + } + } + if (!doneFullScan) { + fullScan(); + continue; + } + return null; + } + } + + private AbstractPoolEntry.ClassEntryImpl classEntryForClassOrInterface(ClassDesc cd) { + var desc = cd.descriptorString(); + + int hash = AbstractPoolEntry.hashClassFromDescriptor(desc.hashCode()); + var ce = tryFindClassOrInterface(hash, cd); + if (ce != null) + return ce; + + var utfHash = Util.internalNameHash(desc); + var utf = tryFindUtf8OfRegion(AbstractPoolEntry.hashString(utfHash), desc, 1, desc.length() - 1); + if (utf == null) + utf = internalAdd(new AbstractPoolEntry.Utf8EntryImpl(this, size, ConstantUtils.dropFirstAndLastChar(desc), utfHash)); + + return internalAdd(new AbstractPoolEntry.ClassEntryImpl(this, size, utf, hash, cd)); + } + + private AbstractPoolEntry.ClassEntryImpl tryFindClassEntry(int hash, AbstractPoolEntry.Utf8EntryImpl utf8) { + EntryMap map = map(); + for (int token = map.firstToken(hash); token != -1; token = map.nextToken(hash, token)) { + PoolEntry e = entryByIndex(map.getIndexByToken(token)); + if (e.tag() == TAG_CLASS + && e instanceof AbstractPoolEntry.ClassEntryImpl ce + && ce.ref1.equalsUtf8(utf8)) + return ce; + } + if (!doneFullScan) { + fullScan(); + return tryFindClassEntry(hash, utf8); + } + return null; + } + + @Override + public AbstractPoolEntry.Utf8EntryImpl utf8Entry(ClassDesc desc) { + var utf8 = utf8Entry(desc.descriptorString()); + if (utf8.typeSym == null) + utf8.typeSym = desc; + return utf8; + } + + @Override + public Utf8Entry utf8Entry(MethodTypeDesc desc) { + var utf8 = utf8Entry(desc.descriptorString()); + if (utf8.typeSym == null) + utf8.typeSym = desc; + return utf8; + } + @Override public AbstractPoolEntry.Utf8EntryImpl utf8Entry(String s) { - int hash = AbstractPoolEntry.hashString(s.hashCode()); - var ce = tryFindUtf8(hash, s); - return ce == null ? internalAdd(new AbstractPoolEntry.Utf8EntryImpl(this, size, s, hash)) : ce; + int contentHash = s.hashCode(); + var ce = tryFindUtf8(AbstractPoolEntry.hashString(contentHash), s); + return ce == null ? internalAdd(new AbstractPoolEntry.Utf8EntryImpl(this, size, s, contentHash)) : ce; } AbstractPoolEntry.Utf8EntryImpl maybeCloneUtf8Entry(Utf8Entry entry) { @@ -424,9 +512,37 @@ public final class SplitConstantPool implements ConstantPoolBuilder { @Override public AbstractPoolEntry.ClassEntryImpl classEntry(Utf8Entry nameEntry) { - AbstractPoolEntry.Utf8EntryImpl ne = maybeCloneUtf8Entry(nameEntry); - var e = (AbstractPoolEntry.ClassEntryImpl) findEntry(TAG_CLASS, ne); - return e == null ? internalAdd(new AbstractPoolEntry.ClassEntryImpl(this, size, ne)) : e; + var ne = maybeCloneUtf8Entry(nameEntry); + return classEntry(ne, AbstractPoolEntry.isArrayDescriptor(ne)); + } + + AbstractPoolEntry.ClassEntryImpl classEntry(AbstractPoolEntry.Utf8EntryImpl ne, boolean isArray) { + int hash = AbstractPoolEntry.hashClassFromUtf8(isArray, ne); + var e = tryFindClassEntry(hash, ne); + return e == null ? internalAdd(new AbstractPoolEntry.ClassEntryImpl(this, size, ne, hash, + isArray && ne.typeSym instanceof ClassDesc cd ? cd : null)) : e; + } + + @Override + public ClassEntry classEntry(ClassDesc cd) { + if (cd.isClassOrInterface()) { // implicit null check + return classEntryForClassOrInterface(cd); + } + if (cd.isArray()) { + return classEntry(utf8Entry(cd), true); + } + throw new IllegalArgumentException("Cannot be encoded as ClassEntry: " + cd.displayName()); + } + + AbstractPoolEntry.ClassEntryImpl cloneClassEntry(AbstractPoolEntry.ClassEntryImpl e) { + var ce = tryFindClassEntry(e.hashCode(), e.ref1); + if (ce != null) { + return ce; + } + + var utf8 = maybeCloneUtf8Entry(e.ref1); // call order matters + return internalAdd(new AbstractPoolEntry.ClassEntryImpl(this, size, + utf8, e.hashCode(), e.sym)); } @Override @@ -447,76 +563,54 @@ public final class SplitConstantPool implements ConstantPoolBuilder { public AbstractPoolEntry.NameAndTypeEntryImpl nameAndTypeEntry(Utf8Entry nameEntry, Utf8Entry typeEntry) { AbstractPoolEntry.Utf8EntryImpl ne = maybeCloneUtf8Entry(nameEntry); AbstractPoolEntry.Utf8EntryImpl te = maybeCloneUtf8Entry(typeEntry); - var e = (AbstractPoolEntry.NameAndTypeEntryImpl) findEntry(TAG_NAMEANDTYPE, ne, te); + var e = (AbstractPoolEntry.NameAndTypeEntryImpl) findEntry(TAG_NAME_AND_TYPE, ne, te); return e == null ? internalAdd(new AbstractPoolEntry.NameAndTypeEntryImpl(this, size, ne, te)) : e; } @Override public FieldRefEntry fieldRefEntry(ClassEntry owner, NameAndTypeEntry nameAndType) { - AbstractPoolEntry.ClassEntryImpl oe = (AbstractPoolEntry.ClassEntryImpl) owner; - AbstractPoolEntry.NameAndTypeEntryImpl ne = (AbstractPoolEntry.NameAndTypeEntryImpl) nameAndType; - if (!canWriteDirect(oe.constantPool)) - oe = classEntry(owner.name()); - if (!canWriteDirect(ne.constantPool)) - ne = nameAndTypeEntry(nameAndType.name(), nameAndType.type()); + var oe = AbstractPoolEntry.maybeClone(this, (AbstractPoolEntry.ClassEntryImpl) owner); + var ne = AbstractPoolEntry.maybeClone(this, (AbstractPoolEntry.NameAndTypeEntryImpl) nameAndType); var e = (AbstractPoolEntry.FieldRefEntryImpl) findEntry(TAG_FIELDREF, oe, ne); return e == null ? internalAdd(new AbstractPoolEntry.FieldRefEntryImpl(this, size, oe, ne)) : e; } @Override public MethodRefEntry methodRefEntry(ClassEntry owner, NameAndTypeEntry nameAndType) { - AbstractPoolEntry.ClassEntryImpl oe = (AbstractPoolEntry.ClassEntryImpl) owner; - AbstractPoolEntry.NameAndTypeEntryImpl ne = (AbstractPoolEntry.NameAndTypeEntryImpl) nameAndType; - if (!canWriteDirect(oe.constantPool)) - oe = classEntry(owner.name()); - if (!canWriteDirect(ne.constantPool)) - ne = nameAndTypeEntry(nameAndType.name(), nameAndType.type()); + var oe = AbstractPoolEntry.maybeClone(this, (AbstractPoolEntry.ClassEntryImpl) owner); + var ne = AbstractPoolEntry.maybeClone(this, (AbstractPoolEntry.NameAndTypeEntryImpl) nameAndType); var e = (AbstractPoolEntry.MethodRefEntryImpl) findEntry(TAG_METHODREF, oe, ne); return e == null ? internalAdd(new AbstractPoolEntry.MethodRefEntryImpl(this, size, oe, ne)) : e; } @Override public InterfaceMethodRefEntry interfaceMethodRefEntry(ClassEntry owner, NameAndTypeEntry nameAndType) { - AbstractPoolEntry.ClassEntryImpl oe = (AbstractPoolEntry.ClassEntryImpl) owner; - AbstractPoolEntry.NameAndTypeEntryImpl ne = (AbstractPoolEntry.NameAndTypeEntryImpl) nameAndType; - if (!canWriteDirect(oe.constantPool)) - oe = classEntry(owner.name()); - if (!canWriteDirect(ne.constantPool)) - ne = nameAndTypeEntry(nameAndType.name(), nameAndType.type()); - var e = (AbstractPoolEntry.InterfaceMethodRefEntryImpl) findEntry(TAG_INTERFACEMETHODREF, oe, ne); + var oe = AbstractPoolEntry.maybeClone(this, (AbstractPoolEntry.ClassEntryImpl) owner); + var ne = AbstractPoolEntry.maybeClone(this, (AbstractPoolEntry.NameAndTypeEntryImpl) nameAndType); + var e = (AbstractPoolEntry.InterfaceMethodRefEntryImpl) findEntry(TAG_INTERFACE_METHODREF, oe, ne); return e == null ? internalAdd(new AbstractPoolEntry.InterfaceMethodRefEntryImpl(this, size, oe, ne)) : e; } @Override public MethodTypeEntry methodTypeEntry(MethodTypeDesc descriptor) { - var ret = (AbstractPoolEntry.MethodTypeEntryImpl)methodTypeEntry(utf8Entry(descriptor.descriptorString())); - ret.sym = descriptor; - return ret; + return methodTypeEntry(utf8Entry(descriptor)); } @Override public MethodTypeEntry methodTypeEntry(Utf8Entry descriptor) { AbstractPoolEntry.Utf8EntryImpl de = maybeCloneUtf8Entry(descriptor); - var e = (AbstractPoolEntry.MethodTypeEntryImpl) findEntry(TAG_METHODTYPE, de); + var e = (AbstractPoolEntry.MethodTypeEntryImpl) findEntry(TAG_METHOD_TYPE, de); return e == null ? internalAdd(new AbstractPoolEntry.MethodTypeEntryImpl(this, size, de)) : e; } @Override public MethodHandleEntry methodHandleEntry(int refKind, MemberRefEntry reference) { - if (!canWriteDirect(reference.constantPool())) { - reference = switch (reference.tag()) { - case TAG_FIELDREF -> fieldRefEntry(reference.owner(), reference.nameAndType()); - case TAG_METHODREF -> methodRefEntry(reference.owner(), reference.nameAndType()); - case TAG_INTERFACEMETHODREF -> interfaceMethodRefEntry(reference.owner(), reference.nameAndType()); - default -> throw new IllegalArgumentException(String.format("Bad tag %d", reference.tag())); - }; - } - - int hash = AbstractPoolEntry.hash2(TAG_METHODHANDLE, refKind, reference.index()); - EntryMap map1 = map(); + reference = AbstractPoolEntry.maybeClone(this, reference); + int hash = AbstractPoolEntry.hash2(TAG_METHOD_HANDLE, refKind, reference.index()); + EntryMap map1 = map(); for (int token = map1.firstToken(hash); token != -1; token = map1.nextToken(hash, token)) { - PoolEntry e = map1.getElementByToken(token); - if (e.tag() == TAG_METHODHANDLE + PoolEntry e = entryByIndex(map1.getIndexByToken(token)); + if (e.tag() == TAG_METHOD_HANDLE && e instanceof AbstractPoolEntry.MethodHandleEntryImpl ce && ce.kind() == refKind && ce.reference() == reference) return ce; @@ -535,14 +629,13 @@ public final class SplitConstantPool implements ConstantPoolBuilder { if (!canWriteDirect(bootstrapMethodEntry.constantPool())) bootstrapMethodEntry = bsmEntry(bootstrapMethodEntry.bootstrapMethod(), bootstrapMethodEntry.arguments()); - if (!canWriteDirect(nameAndType.constantPool())) - nameAndType = nameAndTypeEntry(nameAndType.name(), nameAndType.type()); - int hash = AbstractPoolEntry.hash2(TAG_INVOKEDYNAMIC, + nameAndType = AbstractPoolEntry.maybeClone(this, nameAndType); + int hash = AbstractPoolEntry.hash2(TAG_INVOKE_DYNAMIC, bootstrapMethodEntry.bsmIndex(), nameAndType.index()); - EntryMap map1 = map(); + EntryMap map1 = map(); for (int token = map1.firstToken(hash); token != -1; token = map1.nextToken(hash, token)) { - PoolEntry e = map1.getElementByToken(token); - if (e.tag() == TAG_INVOKEDYNAMIC + PoolEntry e = entryByIndex(map1.getIndexByToken(token)); + if (e.tag() == TAG_INVOKE_DYNAMIC && e instanceof AbstractPoolEntry.InvokeDynamicEntryImpl ce && ce.bootstrap() == bootstrapMethodEntry && ce.nameAndType() == nameAndType) return ce; @@ -566,14 +659,13 @@ public final class SplitConstantPool implements ConstantPoolBuilder { if (!canWriteDirect(bootstrapMethodEntry.constantPool())) bootstrapMethodEntry = bsmEntry(bootstrapMethodEntry.bootstrapMethod(), bootstrapMethodEntry.arguments()); - if (!canWriteDirect(nameAndType.constantPool())) - nameAndType = nameAndTypeEntry(nameAndType.name(), nameAndType.type()); - int hash = AbstractPoolEntry.hash2(TAG_CONSTANTDYNAMIC, + nameAndType = AbstractPoolEntry.maybeClone(this, nameAndType); + int hash = AbstractPoolEntry.hash2(TAG_DYNAMIC, bootstrapMethodEntry.bsmIndex(), nameAndType.index()); - EntryMap map1 = map(); + EntryMap map1 = map(); for (int token = map1.firstToken(hash); token != -1; token = map1.nextToken(hash, token)) { - PoolEntry e = map1.getElementByToken(token); - if (e.tag() == TAG_CONSTANTDYNAMIC + PoolEntry e = entryByIndex(map1.getIndexByToken(token)); + if (e.tag() == TAG_DYNAMIC && e instanceof AbstractPoolEntry.ConstantDynamicEntryImpl ce && ce.bootstrap() == bootstrapMethodEntry && ce.nameAndType() == nameAndType) return ce; @@ -625,8 +717,7 @@ public final class SplitConstantPool implements ConstantPoolBuilder { @Override public BootstrapMethodEntry bsmEntry(MethodHandleEntry methodReference, List arguments) { - if (!canWriteDirect(methodReference.constantPool())) - methodReference = methodHandleEntry(methodReference.kind(), methodReference.reference()); + methodReference = AbstractPoolEntry.maybeClone(this, methodReference); for (LoadableConstantEntry a : arguments) { if (!canWriteDirect(a.constantPool())) { // copy args list @@ -640,9 +731,9 @@ public final class SplitConstantPool implements ConstantPoolBuilder { } AbstractPoolEntry.MethodHandleEntryImpl mre = (AbstractPoolEntry.MethodHandleEntryImpl) methodReference; int hash = BootstrapMethodEntryImpl.computeHashCode(mre, arguments); - EntryMap map = bsmMap(); + EntryMap map = bsmMap(); for (int token = map.firstToken(hash); token != -1; token = map.nextToken(hash, token)) { - BootstrapMethodEntryImpl e = map.getElementByToken(token); + BootstrapMethodEntryImpl e = bootstrapMethodEntry(map.getIndexByToken(token)); if (e.bootstrapMethod() == mre && e.arguments().equals(arguments)) { return e; } diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/StackCounter.java b/src/java.base/share/classes/jdk/internal/classfile/impl/StackCounter.java index 861bb509420..843528df84b 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/impl/StackCounter.java +++ b/src/java.base/share/classes/jdk/internal/classfile/impl/StackCounter.java @@ -34,7 +34,6 @@ import java.lang.classfile.constantpool.DynamicConstantPoolEntry; import java.lang.classfile.constantpool.MemberRefEntry; import java.lang.constant.ClassDesc; import java.lang.constant.MethodTypeDesc; -import java.nio.ByteBuffer; import java.util.ArrayDeque; import java.util.BitSet; import java.util.List; @@ -42,6 +41,8 @@ import java.util.Queue; import java.util.stream.Collectors; import static java.lang.classfile.ClassFile.*; +import static java.lang.classfile.constantpool.PoolEntry.*; +import static jdk.internal.classfile.impl.RawBytecodeHelper.*; public final class StackCounter { @@ -55,7 +56,7 @@ public final class StackCounter { dcb.methodInfo.methodName().stringValue(), dcb.methodInfo.methodTypeSymbol(), (dcb.methodInfo.methodFlags() & ACC_STATIC) != 0, - dcb.bytecodesBufWriter.asByteBuffer(), + dcb.bytecodesBufWriter.bytecodeView(), dcb.constantPool, dcb.handlers); } @@ -67,7 +68,6 @@ public final class StackCounter { private final String methodName; private final MethodTypeDesc methodDesc; private final boolean isStatic; - private final ByteBuffer bytecode; private final SplitConstantPool cp; private final Queue targets; private final BitSet visited; @@ -91,12 +91,12 @@ public final class StackCounter { Target en; while ((en = targets.poll()) != null) { if (!visited.get(en.bci)) { - bcs.nextBci = en.bci; + bcs.reset(en.bci); stack = en.stack; return true; } } - bcs.nextBci = bcs.endBci; + bcs.reset(bcs.endBci()); return false; } @@ -106,14 +106,13 @@ public final class StackCounter { String methodName, MethodTypeDesc methodDesc, boolean isStatic, - ByteBuffer bytecode, + RawBytecodeHelper.CodeRange bytecode, SplitConstantPool cp, List handlers) { this.thisClass = thisClass; this.methodName = methodName; this.methodDesc = methodDesc; this.isStatic = isStatic; - this.bytecode = bytecode; this.cp = cp; targets = new ArrayDeque<>(); stack = rets = 0; @@ -123,8 +122,8 @@ public final class StackCounter { for (var smfi : smta.entries()) { int frameStack = smfi.stack().size(); for (var vti : smfi.stack()) { - if (vti == StackMapFrameInfo.SimpleVerificationTypeInfo.ITEM_LONG - || vti == StackMapFrameInfo.SimpleVerificationTypeInfo.ITEM_DOUBLE) frameStack++; + if (vti == StackMapFrameInfo.SimpleVerificationTypeInfo.LONG + || vti == StackMapFrameInfo.SimpleVerificationTypeInfo.DOUBLE) frameStack++; } if (maxStack < frameStack) maxStack = frameStack; targets.add(new Target(labelContext.labelToBci(smfi.target()), frameStack)); @@ -132,14 +131,13 @@ public final class StackCounter { } maxLocals = isStatic ? 0 : 1; maxLocals += Util.parameterSlots(methodDesc); - bcs = new RawBytecodeHelper(bytecode); - visited = new BitSet(bcs.endBci); + bcs = bytecode.start(); + visited = new BitSet(bcs.endBci()); targets.add(new Target(0, 0)); while (next()) { - while (!bcs.isLastBytecode()) { - bcs.rawNext(); - int opcode = bcs.rawCode; - int bci = bcs.bci; + while (bcs.next()) { + int opcode = bcs.opcode(); + int bci = bcs.bci(); visited.set(bci); switch (opcode) { case NOP, LALOAD, DALOAD, SWAP, INEG, ARRAYLENGTH, INSTANCEOF, LNEG, FNEG, DNEG, I2F, L2D, F2I, D2L, I2B, I2C, I2S, @@ -267,12 +265,12 @@ public final class StackCounter { } case TABLESWITCH, LOOKUPSWITCH -> { int alignedBci = RawBytecodeHelper.align(bci + 1); - int defaultOfset = bcs.getInt(alignedBci); + int defaultOffset = bcs.getIntUnchecked(alignedBci); int keys, delta; addStackSlot(-1); - if (bcs.rawCode == TABLESWITCH) { - int low = bcs.getInt(alignedBci + 4); - int high = bcs.getInt(alignedBci + 2 * 4); + if (bcs.opcode() == TABLESWITCH) { + int low = bcs.getIntUnchecked(alignedBci + 4); + int high = bcs.getIntUnchecked(alignedBci + 2 * 4); if (low > high) { throw error("low must be less than or equal to high in tableswitch"); } @@ -282,24 +280,23 @@ public final class StackCounter { } delta = 1; } else { - keys = bcs.getInt(alignedBci + 4); + keys = bcs.getIntUnchecked(alignedBci + 4); if (keys < 0) { throw error("number of keys in lookupswitch less than 0"); } delta = 2; for (int i = 0; i < (keys - 1); i++) { - int this_key = bcs.getInt(alignedBci + (2 + 2 * i) * 4); - int next_key = bcs.getInt(alignedBci + (2 + 2 * i + 2) * 4); + int this_key = bcs.getIntUnchecked(alignedBci + (2 + 2 * i) * 4); + int next_key = bcs.getIntUnchecked(alignedBci + (2 + 2 * i + 2) * 4); if (this_key >= next_key) { throw error("Bad lookupswitch instruction"); } } } - int target = bci + defaultOfset; + int target = bci + defaultOffset; jump(target); for (int i = 0; i < keys; i++) { - alignedBci = RawBytecodeHelper.align(bcs.bci + 1); - target = bci + bcs.getInt(alignedBci + (3 + i * delta) * 4); + target = bci + bcs.getIntUnchecked(alignedBci + (3 + i * delta) * 4); jump(target); } next(); @@ -314,7 +311,7 @@ public final class StackCounter { } case GETSTATIC, PUTSTATIC, GETFIELD, PUTFIELD -> { var tk = TypeKind.fromDescriptor(cp.entryByIndex(bcs.getIndexU2(), MemberRefEntry.class).nameAndType().type()); - switch (bcs.rawCode) { + switch (bcs.opcode()) { case GETSTATIC -> addStackSlot(tk.slotSize()); case PUTSTATIC -> @@ -329,7 +326,7 @@ public final class StackCounter { case INVOKEVIRTUAL, INVOKESPECIAL, INVOKESTATIC, INVOKEINTERFACE, INVOKEDYNAMIC -> { var cpe = cp.entryByIndex(bcs.getIndexU2()); var nameAndType = opcode == INVOKEDYNAMIC ? ((DynamicConstantPoolEntry)cpe).nameAndType() : ((MemberRefEntry)cpe).nameAndType(); - var mtd = Util.methodTypeSymbol(nameAndType); + var mtd = Util.methodTypeSymbol(nameAndType.type()); var delta = Util.slotSize(mtd.returnType()) - Util.parameterSlots(mtd); if (opcode != INVOKESTATIC && opcode != INVOKEDYNAMIC) { delta--; @@ -337,7 +334,7 @@ public final class StackCounter { addStackSlot(delta); } case MULTIANEWARRAY -> - addStackSlot(1 - bcs.getU1(bcs.bci + 3)); + addStackSlot(1 - bcs.getU1Unchecked(bcs.bci() + 3)); case JSR -> { addStackSlot(+1); jump(bcs.dest()); //here we lost track of the exact stack size after return from subroutine @@ -381,11 +378,11 @@ public final class StackCounter { private void processLdc(int index) { switch (cp.entryByIndex(index).tag()) { - case TAG_UTF8, TAG_STRING, TAG_CLASS, TAG_INTEGER, TAG_FLOAT, TAG_METHODHANDLE, TAG_METHODTYPE -> + case TAG_UTF8, TAG_STRING, TAG_CLASS, TAG_INTEGER, TAG_FLOAT, TAG_METHOD_HANDLE, TAG_METHOD_TYPE -> addStackSlot(+1); case TAG_DOUBLE, TAG_LONG -> addStackSlot(+2); - case TAG_CONSTANTDYNAMIC -> + case TAG_DYNAMIC -> addStackSlot(cp.entryByIndex(index, ConstantDynamicEntry.class).typeKind().slotSize()); default -> throw error("CP entry #%d %s is not loadable constant".formatted(index, cp.entryByIndex(index).tag())); @@ -395,10 +392,10 @@ public final class StackCounter { private IllegalArgumentException error(String msg) { var sb = new StringBuilder("%s at bytecode offset %d of method %s(%s)".formatted( msg, - bcs.bci, + bcs.bci(), methodName, methodDesc.parameterList().stream().map(ClassDesc::displayName).collect(Collectors.joining(",")))); - Util.dumpMethod(cp, thisClass, methodName, methodDesc, isStatic ? ACC_STATIC : 0, bytecode, sb::append); + Util.dumpMethod(cp, thisClass, methodName, methodDesc, isStatic ? ACC_STATIC : 0, bcs.code, sb::append); return new IllegalArgumentException(sb.toString()); } } diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/StackMapDecoder.java b/src/java.base/share/classes/jdk/internal/classfile/impl/StackMapDecoder.java index 609333048d0..28b877cd83c 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/impl/StackMapDecoder.java +++ b/src/java.base/share/classes/jdk/internal/classfile/impl/StackMapDecoder.java @@ -35,17 +35,21 @@ import java.lang.classfile.constantpool.ClassEntry; import java.lang.constant.ConstantDescs; import java.lang.constant.MethodTypeDesc; import java.lang.reflect.AccessFlag; +import java.util.Arrays; +import java.util.Comparator; import java.util.List; import java.util.Objects; -import java.util.TreeMap; import static java.lang.classfile.ClassFile.*; +import static java.lang.classfile.attribute.StackMapFrameInfo.VerificationTypeInfo.*; +import static java.util.Objects.requireNonNull; public class StackMapDecoder { private static final int SAME_LOCALS_1_STACK_ITEM_EXTENDED = 247, SAME_EXTENDED = 251; + private static final StackMapFrameInfo[] NO_STACK_FRAME_INFOS = {}; private final ClassReader classReader; private final int pos; @@ -73,7 +77,7 @@ public class StackMapDecoder { if (!isStatic) { vtis = new VerificationTypeInfo[methodType.parameterCount() + 1]; if ("".equals(methodName) && !ConstantDescs.CD_Object.equals(thisClass.asSymbol())) { - vtis[i++] = SimpleVerificationTypeInfo.ITEM_UNINITIALIZED_THIS; + vtis[i++] = SimpleVerificationTypeInfo.UNINITIALIZED_THIS; } else { vtis[i++] = new StackMapDecoder.ObjectVerificationTypeInfoImpl(thisClass); } @@ -83,10 +87,10 @@ public class StackMapDecoder { for (int pi = 0; pi < methodType.parameterCount(); pi++) { var arg = methodType.parameterType(pi); vtis[i++] = switch (arg.descriptorString().charAt(0)) { - case 'I', 'S', 'C' ,'B', 'Z' -> SimpleVerificationTypeInfo.ITEM_INTEGER; - case 'J' -> SimpleVerificationTypeInfo.ITEM_LONG; - case 'F' -> SimpleVerificationTypeInfo.ITEM_FLOAT; - case 'D' -> SimpleVerificationTypeInfo.ITEM_DOUBLE; + case 'I', 'S', 'C' ,'B', 'Z' -> SimpleVerificationTypeInfo.INTEGER; + case 'J' -> SimpleVerificationTypeInfo.LONG; + case 'F' -> SimpleVerificationTypeInfo.FLOAT; + case 'D' -> SimpleVerificationTypeInfo.DOUBLE; case 'V' -> throw new IllegalArgumentException("Illegal method argument type: " + arg); default -> new StackMapDecoder.ObjectVerificationTypeInfoImpl(TemporaryConstantPool.INSTANCE.classEntry(arg)); }; @@ -103,15 +107,20 @@ public class StackMapDecoder { mi.methodTypeSymbol(), (mi.methodFlags() & ACC_STATIC) != 0); int prevOffset = -1; - var map = new TreeMap(); + // avoid using method handles due to early bootstrap + StackMapFrameInfo[] infos = entries.toArray(NO_STACK_FRAME_INFOS); //sort by resolved label offsets first to allow unordered entries - for (var fr : entries) { - map.put(dcb.labelToBci(fr.target()), fr); - } - b.writeU2(map.size()); - for (var me : map.entrySet()) { - int offset = me.getKey(); - var fr = me.getValue(); + Arrays.sort(infos, new Comparator() { + public int compare(final StackMapFrameInfo o1, final StackMapFrameInfo o2) { + return Integer.compare(dcb.labelToBci(o1.target()), dcb.labelToBci(o2.target())); + } + }); + b.writeU2(infos.length); + for (var fr : infos) { + int offset = dcb.labelToBci(fr.target()); + if (offset == prevOffset) { + throw new IllegalArgumentException("Duplicated stack frame bytecode index: " + offset); + } writeFrame(buf, offset - prevOffset - 1, prevLocals, fr); prevOffset = offset; prevLocals = fr.locals(); @@ -127,8 +136,7 @@ public class StackMapDecoder { if (diffLocalsSize == 0 && offsetDelta < 64) { //same frame out.writeU1(offsetDelta); } else { //chop, same extended or append frame - out.writeU1(251 + diffLocalsSize); - out.writeU2(offsetDelta); + out.writeU1U2(251 + diffLocalsSize, offsetDelta); for (int i=commonLocalsSize; i - {} - case VT_OBJECT -> - bw.writeIndex(((ObjectVerificationTypeInfo)vti).className()); - case VT_UNINITIALIZED -> - bw.writeU2(bw.labelContext().labelToBci(((UninitializedVerificationTypeInfo)vti).newTarget())); + int tag = vti.tag(); + switch (tag) { + case ITEM_TOP, ITEM_INTEGER, ITEM_FLOAT, ITEM_DOUBLE, ITEM_LONG, ITEM_NULL, + ITEM_UNINITIALIZED_THIS -> + bw.writeU1(tag); + case ITEM_OBJECT -> + bw.writeU1U2(tag, bw.cpIndex(((ObjectVerificationTypeInfo)vti).className())); + case ITEM_UNINITIALIZED -> + bw.writeU1U2(tag, bw.labelContext().labelToBci(((UninitializedVerificationTypeInfo)vti).newTarget())); default -> throw new IllegalArgumentException("Invalid verification type tag: " + vti.tag()); } } @@ -225,24 +231,27 @@ public class StackMapDecoder { private VerificationTypeInfo readVerificationTypeInfo() { int tag = classReader.readU1(p++); return switch (tag) { - case VT_TOP -> SimpleVerificationTypeInfo.ITEM_TOP; - case VT_INTEGER -> SimpleVerificationTypeInfo.ITEM_INTEGER; - case VT_FLOAT -> SimpleVerificationTypeInfo.ITEM_FLOAT; - case VT_DOUBLE -> SimpleVerificationTypeInfo.ITEM_DOUBLE; - case VT_LONG -> SimpleVerificationTypeInfo.ITEM_LONG; - case VT_NULL -> SimpleVerificationTypeInfo.ITEM_NULL; - case VT_UNINITIALIZED_THIS -> SimpleVerificationTypeInfo.ITEM_UNINITIALIZED_THIS; - case VT_OBJECT -> new ObjectVerificationTypeInfoImpl(classReader.entryByIndex(u2(), ClassEntry.class)); - case VT_UNINITIALIZED -> new UninitializedVerificationTypeInfoImpl(ctx.getLabel(u2())); + case ITEM_TOP -> SimpleVerificationTypeInfo.TOP; + case ITEM_INTEGER -> SimpleVerificationTypeInfo.INTEGER; + case ITEM_FLOAT -> SimpleVerificationTypeInfo.FLOAT; + case ITEM_DOUBLE -> SimpleVerificationTypeInfo.DOUBLE; + case ITEM_LONG -> SimpleVerificationTypeInfo.LONG; + case ITEM_NULL -> SimpleVerificationTypeInfo.NULL; + case ITEM_UNINITIALIZED_THIS -> SimpleVerificationTypeInfo.UNINITIALIZED_THIS; + case ITEM_OBJECT -> new ObjectVerificationTypeInfoImpl(classReader.entryByIndex(u2(), ClassEntry.class)); + case ITEM_UNINITIALIZED -> new UninitializedVerificationTypeInfoImpl(ctx.getLabel(u2())); default -> throw new IllegalArgumentException("Invalid verification type tag: " + tag); }; } public static record ObjectVerificationTypeInfoImpl( ClassEntry className) implements ObjectVerificationTypeInfo { + public ObjectVerificationTypeInfoImpl { + requireNonNull(className); + } @Override - public int tag() { return VT_OBJECT; } + public int tag() { return ITEM_OBJECT; } @Override public boolean equals(Object o) { @@ -265,9 +274,12 @@ public class StackMapDecoder { } public static record UninitializedVerificationTypeInfoImpl(Label newTarget) implements UninitializedVerificationTypeInfo { + public UninitializedVerificationTypeInfoImpl { + requireNonNull(newTarget); + } @Override - public int tag() { return VT_UNINITIALIZED; } + public int tag() { return ITEM_UNINITIALIZED; } @Override public String toString() { @@ -287,6 +299,7 @@ public class StackMapDecoder { List stack) implements StackMapFrameInfo { public StackMapFrameImpl { + requireNonNull(target); locals = List.copyOf(locals); stack = List.copyOf(stack); } diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/StackMapGenerator.java b/src/java.base/share/classes/jdk/internal/classfile/impl/StackMapGenerator.java index 514c1d32f41..1af13267c80 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/impl/StackMapGenerator.java +++ b/src/java.base/share/classes/jdk/internal/classfile/impl/StackMapGenerator.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, Alibaba Group Holding Limited. 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 @@ -28,7 +29,6 @@ package jdk.internal.classfile.impl; import java.lang.classfile.Attribute; import java.lang.classfile.Attributes; import java.lang.classfile.BufWriter; -import java.lang.classfile.ClassFile; import java.lang.classfile.Label; import java.lang.classfile.attribute.StackMapTableAttribute; import java.lang.classfile.constantpool.ClassEntry; @@ -38,17 +38,19 @@ import java.lang.classfile.constantpool.InvokeDynamicEntry; import java.lang.classfile.constantpool.MemberRefEntry; import java.lang.constant.ClassDesc; import java.lang.constant.MethodTypeDesc; -import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.Arrays; -import java.util.BitSet; import java.util.List; import java.util.Objects; import java.util.stream.Collectors; import jdk.internal.constant.ReferenceClassDescImpl; +import jdk.internal.constant.PrimitiveClassDescImpl; +import jdk.internal.util.Preconditions; import static java.lang.classfile.ClassFile.*; +import static java.lang.classfile.constantpool.PoolEntry.*; import static java.lang.constant.ConstantDescs.*; +import static jdk.internal.classfile.impl.RawBytecodeHelper.*; /** * StackMapGenerator is responsible for stack map frames generation. @@ -57,8 +59,8 @@ import static java.lang.constant.ConstantDescs.*; *

          * The {@linkplain #generate() frames computation} consists of following steps: *

            - *
          1. {@linkplain #detectFrameOffsets() Detection} of mandatory stack map frames offsets:
              - *
            • Mandatory stack map frame offsets include all jump and switch instructions targets, + *
            • {@linkplain #detectFrames() Detection} of mandatory stack map frames:
                + *
              • Mandatory stack map frame include all jump and switch instructions targets, * offsets immediately following {@linkplain #noControlFlow(int) "no control flow"} * and all exception table handlers. *
              • Detection is performed in a single fast pass through the bytecode, @@ -152,7 +154,7 @@ public final class StackMapGenerator { dcb.methodInfo.methodName().stringValue(), dcb.methodInfo.methodTypeSymbol(), (dcb.methodInfo.methodFlags() & ACC_STATIC) != 0, - dcb.bytecodesBufWriter.asByteBuffer(), + dcb.bytecodesBufWriter.bytecodeView(), dcb.constantPool, dcb.context, dcb.handlers); @@ -162,6 +164,7 @@ public final class StackMapGenerator { private static final int FLAG_THIS_UNINIT = 0x01; private static final int FRAME_DEFAULT_CAPACITY = 10; private static final int T_BOOLEAN = 4, T_LONG = 11; + private static final Frame[] EMPTY_FRAME_ARRAY = {}; private static final int ITEM_TOP = 0, ITEM_INTEGER = 1, @@ -188,7 +191,7 @@ public final class StackMapGenerator { private final Type thisType; private final String methodName; private final MethodTypeDesc methodDesc; - private final ByteBuffer bytecode; + private final RawBytecodeHelper.CodeRange bytecode; private final SplitConstantPool cp; private final boolean isStatic; private final LabelContext labelContext; @@ -197,7 +200,8 @@ public final class StackMapGenerator { private final ClassHierarchyImpl classHierarchy; private final boolean patchDeadCode; private final boolean filterDeadLabels; - private List frames; + private Frame[] frames = EMPTY_FRAME_ARRAY; + private int framesCount = 0; private final Frame currentFrame; private int maxStack, maxLocals; @@ -222,7 +226,7 @@ public final class StackMapGenerator { String methodName, MethodTypeDesc methodDesc, boolean isStatic, - ByteBuffer bytecode, + RawBytecodeHelper.CodeRange bytecode, SplitConstantPool cp, ClassFileImpl context, List handlers) { @@ -235,9 +239,9 @@ public final class StackMapGenerator { this.labelContext = labelContext; this.handlers = handlers; this.rawHandlers = new ArrayList<>(handlers.size()); - this.classHierarchy = new ClassHierarchyImpl(context.classHierarchyResolverOption().classHierarchyResolver()); - this.patchDeadCode = context.deadCodeOption() == ClassFile.DeadCodeOption.PATCH_DEAD_CODE; - this.filterDeadLabels = context.deadLabelsOption() == ClassFile.DeadLabelsOption.DROP_DEAD_LABELS; + this.classHierarchy = new ClassHierarchyImpl(context.classHierarchyResolver()); + this.patchDeadCode = context.patchDeadCode(); + this.filterDeadLabels = context.dropDeadLabels(); this.currentFrame = new Frame(classHierarchy); generate(); } @@ -261,10 +265,10 @@ public final class StackMapGenerator { private Frame getFrame(int offset) { //binary search over frames ordered by offset int low = 0; - int high = frames.size() - 1; + int high = framesCount - 1; while (low <= high) { int mid = (low + high) >>> 1; - var f = frames.get(mid); + var f = frames[mid]; if (f.offset < offset) low = mid + 1; else if (f.offset > offset) @@ -282,16 +286,38 @@ public final class StackMapGenerator { private int exMin, exMax; private boolean isAnyFrameDirty() { - for (var f : frames) { - if (f.dirty) return true; + for (int i = 0; i < framesCount; i++) { + if (frames[i].dirty) return true; } return false; } private void generate() { - exMin = bytecode.capacity(); + exMin = bytecode.length(); exMax = -1; - for (var exhandler : handlers) { + if (!handlers.isEmpty()) { + generateHandlers(); + } + detectFrames(); + do { + processMethod(); + } while (isAnyFrameDirty()); + maxLocals = currentFrame.frameMaxLocals; + maxStack = currentFrame.frameMaxStack; + + //dead code patching + for (int i = 0; i < framesCount; i++) { + var frame = frames[i]; + if (frame.flags == -1) { + deadCodePatching(frame, i); + } + } + } + + private void generateHandlers() { + var labelContext = this.labelContext; + for (int i = 0; i < handlers.size(); i++) { + var exhandler = handlers.get(i); int start_pc = labelContext.labelToBci(exhandler.tryStart()); int end_pc = labelContext.labelToBci(exhandler.tryEnd()); int handler_pc = labelContext.labelToBci(exhandler.handler()); @@ -301,48 +327,30 @@ public final class StackMapGenerator { var catchType = exhandler.catchType(); rawHandlers.add(new RawExceptionCatch(start_pc, end_pc, handler_pc, catchType.isPresent() ? cpIndexToType(catchType.get().index(), cp) - : Type.THROWABLE_TYPE)); + : Type.THROWABLE_TYPE)); } } - BitSet frameOffsets = detectFrameOffsets(); - int framesCount = frameOffsets.cardinality(); - frames = new ArrayList<>(framesCount); - int offset = -1; - for (int i = 0; i < framesCount; i++) { - offset = frameOffsets.nextSetBit(offset + 1); - frames.add(new Frame(offset, classHierarchy)); - } - do { - processMethod(); - } while (isAnyFrameDirty()); - maxLocals = currentFrame.frameMaxLocals; - maxStack = currentFrame.frameMaxStack; + } - //dead code patching - for (int i = 0; i < framesCount; i++) { - var frame = frames.get(i); - if (frame.flags == -1) { - if (!patchDeadCode) throw generatorError("Unable to generate stack map frame for dead code", frame.offset); - //patch frame - frame.pushStack(Type.THROWABLE_TYPE); - if (maxStack < 1) maxStack = 1; - int blockSize = (i < framesCount - 1 ? frames.get(i + 1).offset : bytecode.limit()) - frame.offset; - //patch bytecode - bytecode.position(frame.offset); - for (int n=1; n= handlerEnd || rangeEnd <= handlerStart) { @@ -381,16 +389,18 @@ public final class StackMapGenerator { * @return StackMapTableAttribute or null if stack map is empty */ public Attribute stackMapTableAttribute() { - return frames.isEmpty() ? null : new UnboundAttribute.AdHocAttribute<>(Attributes.stackMapTable()) { + return framesCount == 0 ? null : new UnboundAttribute.AdHocAttribute<>(Attributes.stackMapTable()) { @Override public void writeBody(BufWriterImpl b) { - b.writeU2(frames.size()); - Frame prevFrame = new Frame(classHierarchy); - prevFrame.setLocalsFromArg(methodName, methodDesc, isStatic, thisType); + var gen = StackMapGenerator.this; + b.writeU2(gen.framesCount); + Frame prevFrame = gen.new Frame(gen.classHierarchy); + prevFrame.setLocalsFromArg(gen.methodName, gen.methodDesc, gen.isStatic, gen.thisType); prevFrame.trimAndCompress(); - for (var fr : frames) { + for (int i = 0; i < gen.framesCount; i++) { + var fr = gen.frames[i]; fr.trimAndCompress(); - fr.writeTo(b, prevFrame, cp); + fr.writeTo(b, prevFrame, gen.cp); prevFrame = fr; } } @@ -402,36 +412,38 @@ public final class StackMapGenerator { } private void processMethod() { + var frames = this.frames; + var currentFrame = this.currentFrame; currentFrame.setLocalsFromArg(methodName, methodDesc, isStatic, thisType); currentFrame.stackSize = 0; currentFrame.flags = 0; currentFrame.offset = -1; int stackmapIndex = 0; - RawBytecodeHelper bcs = new RawBytecodeHelper(bytecode); + var bcs = bytecode.start(); boolean ncf = false; - while (!bcs.isLastBytecode()) { - bcs.rawNext(); - currentFrame.offset = bcs.bci; - if (stackmapIndex < frames.size()) { - int thisOffset = frames.get(stackmapIndex).offset; - if (ncf && thisOffset > bcs.bci) { + while (bcs.next()) { + currentFrame.offset = bcs.bci(); + if (stackmapIndex < framesCount) { + int thisOffset = frames[stackmapIndex].offset; + if (ncf && thisOffset > bcs.bci()) { throw generatorError("Expecting a stack map frame"); } - if (thisOffset == bcs.bci) { + if (thisOffset == bcs.bci()) { + Frame nextFrame = frames[stackmapIndex++]; if (!ncf) { - currentFrame.checkAssignableTo(frames.get(stackmapIndex)); + currentFrame.checkAssignableTo(nextFrame); } - Frame nextFrame = frames.get(stackmapIndex++); while (!nextFrame.dirty) { //skip unmatched frames - if (stackmapIndex == frames.size()) return; //skip the rest of this round - nextFrame = frames.get(stackmapIndex++); + if (stackmapIndex == framesCount) return; //skip the rest of this round + nextFrame = frames[stackmapIndex++]; } - bcs.rawNext(nextFrame.offset); //skip code up-to the next frame - currentFrame.offset = bcs.bci; + bcs.reset(nextFrame.offset); //skip code up-to the next frame + bcs.next(); + currentFrame.offset = bcs.bci(); currentFrame.copyFrom(nextFrame); nextFrame.dirty = false; - } else if (thisOffset < bcs.bci) { - throw new ClassFormatError(String.format("Bad stack map offset %d", thisOffset)); + } else if (thisOffset < bcs.bci()) { + throw generatorError("Bad stack map offset"); } } else if (ncf) { throw generatorError("Expecting a stack map frame"); @@ -441,16 +453,17 @@ public final class StackMapGenerator { } private boolean processBlock(RawBytecodeHelper bcs) { - int opcode = bcs.rawCode; + int opcode = bcs.opcode(); boolean ncf = false; boolean this_uninit = false; boolean verified_exc_handlers = false; - int bci = bcs.bci; + int bci = bcs.bci(); Type type1, type2, type3, type4; if (RawBytecodeHelper.isStoreIntoLocal(opcode) && bci >= exMin && bci < exMax) { processExceptionHandlerTargets(bci, this_uninit); verified_exc_handlers = true; } + var currentFrame = this.currentFrame; switch (opcode) { case NOP -> {} case RETURN -> { @@ -491,27 +504,27 @@ public final class StackMapGenerator { case ALOAD_0, ALOAD_1, ALOAD_2, ALOAD_3 -> currentFrame.pushStack(currentFrame.getLocal(opcode - ALOAD_0)); case IALOAD, BALOAD, CALOAD, SALOAD -> - currentFrame.decStack(2).pushStack(Type.INTEGER_TYPE); + currentFrame.decStack2PushStack(Type.INTEGER_TYPE); case LALOAD -> - currentFrame.decStack(2).pushStack(Type.LONG_TYPE, Type.LONG2_TYPE); + currentFrame.decStack2PushStack(Type.LONG_TYPE, Type.LONG2_TYPE); case FALOAD -> - currentFrame.decStack(2).pushStack(Type.FLOAT_TYPE); + currentFrame.decStack2PushStack(Type.FLOAT_TYPE); case DALOAD -> - currentFrame.decStack(2).pushStack(Type.DOUBLE_TYPE, Type.DOUBLE2_TYPE); + currentFrame.decStack2PushStack(Type.DOUBLE_TYPE, Type.DOUBLE2_TYPE); case AALOAD -> - currentFrame.pushStack((type1 = currentFrame.decStack(1).popStack()) == Type.NULL_TYPE ? Type.NULL_TYPE : type1.getComponent()); + currentFrame.pushStack((type1 = currentFrame.decStack().popStack()) == Type.NULL_TYPE ? Type.NULL_TYPE : type1.getComponent()); case ISTORE -> - currentFrame.decStack(1).setLocal(bcs.getIndex(), Type.INTEGER_TYPE); + currentFrame.decStack().setLocal(bcs.getIndex(), Type.INTEGER_TYPE); case ISTORE_0, ISTORE_1, ISTORE_2, ISTORE_3 -> - currentFrame.decStack(1).setLocal(opcode - ISTORE_0, Type.INTEGER_TYPE); + currentFrame.decStack().setLocal(opcode - ISTORE_0, Type.INTEGER_TYPE); case LSTORE -> currentFrame.decStack(2).setLocal2(bcs.getIndex(), Type.LONG_TYPE, Type.LONG2_TYPE); case LSTORE_0, LSTORE_1, LSTORE_2, LSTORE_3 -> currentFrame.decStack(2).setLocal2(opcode - LSTORE_0, Type.LONG_TYPE, Type.LONG2_TYPE); case FSTORE -> - currentFrame.decStack(1).setLocal(bcs.getIndex(), Type.FLOAT_TYPE); + currentFrame.decStack().setLocal(bcs.getIndex(), Type.FLOAT_TYPE); case FSTORE_0, FSTORE_1, FSTORE_2, FSTORE_3 -> - currentFrame.decStack(1).setLocal(opcode - FSTORE_0, Type.FLOAT_TYPE); + currentFrame.decStack().setLocal(opcode - FSTORE_0, Type.FLOAT_TYPE); case DSTORE -> currentFrame.decStack(2).setLocal2(bcs.getIndex(), Type.DOUBLE_TYPE, Type.DOUBLE2_TYPE); case DSTORE_0, DSTORE_1, DSTORE_2, DSTORE_3 -> @@ -525,98 +538,75 @@ public final class StackMapGenerator { case IASTORE, BASTORE, CASTORE, SASTORE, FASTORE, AASTORE -> currentFrame.decStack(3); case POP, MONITORENTER, MONITOREXIT -> - currentFrame.decStack(1); + currentFrame.decStack(); case POP2 -> currentFrame.decStack(2); case DUP -> - currentFrame.pushStack(type1 = currentFrame.popStack()).pushStack(type1); - case DUP_X1 -> { - type1 = currentFrame.popStack(); - type2 = currentFrame.popStack(); - currentFrame.pushStack(type1).pushStack(type2).pushStack(type1); - } - case DUP_X2 -> { - type1 = currentFrame.popStack(); - type2 = currentFrame.popStack(); - type3 = currentFrame.popStack(); - currentFrame.pushStack(type1).pushStack(type3).pushStack(type2).pushStack(type1); - } - case DUP2 -> { - type1 = currentFrame.popStack(); - type2 = currentFrame.popStack(); - currentFrame.pushStack(type2).pushStack(type1).pushStack(type2).pushStack(type1); - } - case DUP2_X1 -> { - type1 = currentFrame.popStack(); - type2 = currentFrame.popStack(); - type3 = currentFrame.popStack(); - currentFrame.pushStack(type2).pushStack(type1).pushStack(type3).pushStack(type2).pushStack(type1); - } - case DUP2_X2 -> { - type1 = currentFrame.popStack(); - type2 = currentFrame.popStack(); - type3 = currentFrame.popStack(); - type4 = currentFrame.popStack(); - currentFrame.pushStack(type2).pushStack(type1).pushStack(type4).pushStack(type3).pushStack(type2).pushStack(type1); - } - case SWAP -> { - type1 = currentFrame.popStack(); - type2 = currentFrame.popStack(); - currentFrame.pushStack(type1); - currentFrame.pushStack(type2); - } + currentFrame.dup(); + case DUP_X1 -> + currentFrame.dup_x1(); + case DUP_X2 -> + currentFrame.dup_x2(); + case DUP2 -> + currentFrame.dup2(); + case DUP2_X1 -> + currentFrame.dup2_x1(); + case DUP2_X2 -> + currentFrame.dup2_x2(); + case SWAP -> + currentFrame.swap(); case IADD, ISUB, IMUL, IDIV, IREM, ISHL, ISHR, IUSHR, IOR, IXOR, IAND -> - currentFrame.decStack(2).pushStack(Type.INTEGER_TYPE); + currentFrame.decStack2PushStack(Type.INTEGER_TYPE); case INEG, ARRAYLENGTH, INSTANCEOF -> - currentFrame.decStack(1).pushStack(Type.INTEGER_TYPE); + currentFrame.decStack1PushStack(Type.INTEGER_TYPE); case LADD, LSUB, LMUL, LDIV, LREM, LAND, LOR, LXOR -> - currentFrame.decStack(4).pushStack(Type.LONG_TYPE, Type.LONG2_TYPE); + currentFrame.decStack4PushStack(Type.LONG_TYPE, Type.LONG2_TYPE); case LNEG -> - currentFrame.decStack(2).pushStack(Type.LONG_TYPE, Type.LONG2_TYPE); + currentFrame.decStack2PushStack(Type.LONG_TYPE, Type.LONG2_TYPE); case LSHL, LSHR, LUSHR -> - currentFrame.decStack(3).pushStack(Type.LONG_TYPE, Type.LONG2_TYPE); + currentFrame.decStack3PushStack(Type.LONG_TYPE, Type.LONG2_TYPE); case FADD, FSUB, FMUL, FDIV, FREM -> - currentFrame.decStack(2).pushStack(Type.FLOAT_TYPE); + currentFrame.decStack2PushStack(Type.FLOAT_TYPE); case FNEG -> - currentFrame.decStack(1).pushStack(Type.FLOAT_TYPE); + currentFrame.decStack1PushStack(Type.FLOAT_TYPE); case DADD, DSUB, DMUL, DDIV, DREM -> - currentFrame.decStack(4).pushStack(Type.DOUBLE_TYPE, Type.DOUBLE2_TYPE); + currentFrame.decStack4PushStack(Type.DOUBLE_TYPE, Type.DOUBLE2_TYPE); case DNEG -> - currentFrame.decStack(2).pushStack(Type.DOUBLE_TYPE, Type.DOUBLE2_TYPE); + currentFrame.decStack2PushStack(Type.DOUBLE_TYPE, Type.DOUBLE2_TYPE); case IINC -> currentFrame.checkLocal(bcs.getIndex()); case I2L -> - currentFrame.decStack(1).pushStack(Type.LONG_TYPE, Type.LONG2_TYPE); + currentFrame.decStack1PushStack(Type.LONG_TYPE, Type.LONG2_TYPE); case L2I -> - currentFrame.decStack(2).pushStack(Type.INTEGER_TYPE); + currentFrame.decStack2PushStack(Type.INTEGER_TYPE); case I2F -> - currentFrame.decStack(1).pushStack(Type.FLOAT_TYPE); + currentFrame.decStack1PushStack(Type.FLOAT_TYPE); case I2D -> - currentFrame.decStack(1).pushStack(Type.DOUBLE_TYPE, Type.DOUBLE2_TYPE); + currentFrame.decStack1PushStack(Type.DOUBLE_TYPE, Type.DOUBLE2_TYPE); case L2F -> - currentFrame.decStack(2).pushStack(Type.FLOAT_TYPE); + currentFrame.decStack2PushStack(Type.FLOAT_TYPE); case L2D -> - currentFrame.decStack(2).pushStack(Type.DOUBLE_TYPE, Type.DOUBLE2_TYPE); + currentFrame.decStack2PushStack(Type.DOUBLE_TYPE, Type.DOUBLE2_TYPE); case F2I -> - currentFrame.decStack(1).pushStack(Type.INTEGER_TYPE); + currentFrame.decStack1PushStack(Type.INTEGER_TYPE); case F2L -> - currentFrame.decStack(1).pushStack(Type.LONG_TYPE, Type.LONG2_TYPE); + currentFrame.decStack1PushStack(Type.LONG_TYPE, Type.LONG2_TYPE); case F2D -> - currentFrame.decStack(1).pushStack(Type.DOUBLE_TYPE, Type.DOUBLE2_TYPE); + currentFrame.decStack1PushStack(Type.DOUBLE_TYPE, Type.DOUBLE2_TYPE); case D2L -> - currentFrame.decStack(2).pushStack(Type.LONG_TYPE, Type.LONG2_TYPE); + currentFrame.decStack2PushStack(Type.LONG_TYPE, Type.LONG2_TYPE); case D2F -> - currentFrame.decStack(2).pushStack(Type.FLOAT_TYPE); + currentFrame.decStack2PushStack(Type.FLOAT_TYPE); case I2B, I2C, I2S -> - currentFrame.decStack(1).pushStack(Type.INTEGER_TYPE); + currentFrame.decStack1PushStack(Type.INTEGER_TYPE); case LCMP, DCMPL, DCMPG -> - currentFrame.decStack(4).pushStack(Type.INTEGER_TYPE); + currentFrame.decStack4PushStack(Type.INTEGER_TYPE); case FCMPL, FCMPG, D2I -> - currentFrame.decStack(2).pushStack(Type.INTEGER_TYPE); + currentFrame.decStack2PushStack(Type.INTEGER_TYPE); case IF_ICMPEQ, IF_ICMPNE, IF_ICMPLT, IF_ICMPGE, IF_ICMPGT, IF_ICMPLE, IF_ACMPEQ, IF_ACMPNE -> checkJumpTarget(currentFrame.decStack(2), bcs.dest()); case IFEQ, IFNE, IFLT, IFGE, IFGT, IFLE, IFNULL, IFNONNULL -> - checkJumpTarget(currentFrame.decStack(1), bcs.dest()); + checkJumpTarget(currentFrame.decStack(), bcs.dest()); case GOTO -> { checkJumpTarget(currentFrame, bcs.dest()); ncf = true; @@ -634,7 +624,7 @@ public final class StackMapGenerator { ncf = true; } case IRETURN, FRETURN, ARETURN, ATHROW -> { - currentFrame.decStack(1); + currentFrame.decStack(); ncf = true; } case GETSTATIC, PUTSTATIC, GETFIELD, PUTFIELD -> @@ -644,17 +634,16 @@ public final class StackMapGenerator { case NEW -> currentFrame.pushStack(Type.uninitializedType(bci)); case NEWARRAY -> - currentFrame.decStack(1).pushStack(getNewarrayType(bcs.getIndex())); + currentFrame.decStack1PushStack(getNewarrayType(bcs.getIndex())); case ANEWARRAY -> processAnewarray(bcs.getIndexU2()); case CHECKCAST -> - currentFrame.decStack(1).pushStack(cpIndexToType(bcs.getIndexU2(), cp)); + currentFrame.decStack1PushStack(cpIndexToType(bcs.getIndexU2(), cp)); case MULTIANEWARRAY -> { type1 = cpIndexToType(bcs.getIndexU2(), cp); - int dim = bcs.getU1(bcs.bci + 3); - for (int i = 0; i < dim; i++) { - currentFrame.popStack(); - } + currentFrame.decStack( + bcs.getU1Unchecked(bcs.bci() + 3) /* dim */ + ); currentFrame.pushStack(type1); } case JSR, JSR_W, RET -> @@ -669,6 +658,7 @@ public final class StackMapGenerator { } private void processExceptionHandlerTargets(int bci, boolean this_uninit) { + var currentFrame = this.currentFrame; for (var ex : rawHandlers) { if (bci == ex.start || (currentFrame.localsChanged && bci > ex.start && bci < ex.end)) { int flags = currentFrame.flags; @@ -681,7 +671,10 @@ public final class StackMapGenerator { } private void processLdc(int index) { - switch (cp.entryByIndex(index).tag()) { + var e = cp.entryByIndex(index); + byte tag = e.tag(); + var currentFrame = this.currentFrame; + switch (tag) { case TAG_UTF8 -> currentFrame.pushStack(Type.OBJECT_TYPE); case TAG_STRING -> @@ -696,26 +689,26 @@ public final class StackMapGenerator { currentFrame.pushStack(Type.DOUBLE_TYPE, Type.DOUBLE2_TYPE); case TAG_LONG -> currentFrame.pushStack(Type.LONG_TYPE, Type.LONG2_TYPE); - case TAG_METHODHANDLE -> + case TAG_METHOD_HANDLE -> currentFrame.pushStack(Type.METHOD_HANDLE_TYPE); - case TAG_METHODTYPE -> + case TAG_METHOD_TYPE -> currentFrame.pushStack(Type.METHOD_TYPE); - case TAG_CONSTANTDYNAMIC -> - currentFrame.pushStack(cp.entryByIndex(index, ConstantDynamicEntry.class).asSymbol().constantType()); + case TAG_DYNAMIC -> + currentFrame.pushStack(ClassReaderImpl.checkType(e, index, ConstantDynamicEntry.class).asSymbol().constantType()); default -> - throw generatorError("CP entry #%d %s is not loadable constant".formatted(index, cp.entryByIndex(index).tag())); + throw generatorError("CP entry #%d %s is not loadable constant".formatted(index, tag)); } } private void processSwitch(RawBytecodeHelper bcs) { - int bci = bcs.bci; + int bci = bcs.bci(); int alignedBci = RawBytecodeHelper.align(bci + 1); - int defaultOfset = bcs.getInt(alignedBci); + int defaultOffset = bcs.getIntUnchecked(alignedBci); int keys, delta; - currentFrame.popStack(); - if (bcs.rawCode == TABLESWITCH) { - int low = bcs.getInt(alignedBci + 4); - int high = bcs.getInt(alignedBci + 2 * 4); + currentFrame.decStack(); + if (bcs.opcode() == TABLESWITCH) { + int low = bcs.getIntUnchecked(alignedBci + 4); + int high = bcs.getIntUnchecked(alignedBci + 2 * 4); if (low > high) { throw generatorError("low must be less than or equal to high in tableswitch"); } @@ -725,45 +718,41 @@ public final class StackMapGenerator { } delta = 1; } else { - keys = bcs.getInt(alignedBci + 4); + keys = bcs.getIntUnchecked(alignedBci + 4); if (keys < 0) { throw generatorError("number of keys in lookupswitch less than 0"); } delta = 2; for (int i = 0; i < (keys - 1); i++) { - int this_key = bcs.getInt(alignedBci + (2 + 2 * i) * 4); - int next_key = bcs.getInt(alignedBci + (2 + 2 * i + 2) * 4); + int this_key = bcs.getIntUnchecked(alignedBci + (2 + 2 * i) * 4); + int next_key = bcs.getIntUnchecked(alignedBci + (2 + 2 * i + 2) * 4); if (this_key >= next_key) { throw generatorError("Bad lookupswitch instruction"); } } } - int target = bci + defaultOfset; + int target = bci + defaultOffset; checkJumpTarget(currentFrame, target); for (int i = 0; i < keys; i++) { - alignedBci = RawBytecodeHelper.align(bcs.bci + 1); - target = bci + bcs.getInt(alignedBci + (3 + i * delta) * 4); + target = bci + bcs.getIntUnchecked(alignedBci + (3 + i * delta) * 4); checkJumpTarget(currentFrame, target); } } private void processFieldInstructions(RawBytecodeHelper bcs) { - var desc = Util.fieldTypeSymbol(cp.entryByIndex(bcs.getIndexU2(), MemberRefEntry.class).nameAndType()); - switch (bcs.rawCode) { + var desc = Util.fieldTypeSymbol(cp.entryByIndex(bcs.getIndexU2(), MemberRefEntry.class).type()); + var currentFrame = this.currentFrame; + switch (bcs.opcode()) { case GETSTATIC -> currentFrame.pushStack(desc); case PUTSTATIC -> { - currentFrame.popStack(); - if (Util.isDoubleSlot(desc)) currentFrame.popStack(); + currentFrame.decStack(Util.isDoubleSlot(desc) ? 2 : 1); } case GETFIELD -> { - currentFrame.popStack(); - currentFrame.pushStack(desc); + currentFrame.dec1PushStack(desc); } case PUTFIELD -> { - currentFrame.popStack(); - currentFrame.popStack(); - if (Util.isDoubleSlot(desc)) currentFrame.popStack(); + currentFrame.decStack(Util.isDoubleSlot(desc) ? 3 : 2); } default -> throw new AssertionError("Should not reach here"); } @@ -771,16 +760,16 @@ public final class StackMapGenerator { private boolean processInvokeInstructions(RawBytecodeHelper bcs, boolean inTryBlock, boolean thisUninit) { int index = bcs.getIndexU2(); - int opcode = bcs.rawCode; + int opcode = bcs.opcode(); var nameAndType = opcode == INVOKEDYNAMIC ? cp.entryByIndex(index, InvokeDynamicEntry.class).nameAndType() : cp.entryByIndex(index, MemberRefEntry.class).nameAndType(); - String invokeMethodName = nameAndType.name().stringValue(); - var mDesc = Util.methodTypeSymbol(nameAndType); - int bci = bcs.bci; + var mDesc = Util.methodTypeSymbol(nameAndType.type()); + int bci = bcs.bci(); + var currentFrame = this.currentFrame; currentFrame.decStack(Util.parameterSlots(mDesc)); if (opcode != INVOKESTATIC && opcode != INVOKEDYNAMIC) { - if (OBJECT_INITIALIZER_NAME.equals(invokeMethodName)) { + if (nameAndType.name().equalsString(OBJECT_INITIALIZER_NAME)) { Type type = currentFrame.popStack(); if (type == Type.UNITIALIZED_THIS_TYPE) { if (inTryBlock) { @@ -789,9 +778,7 @@ public final class StackMapGenerator { currentFrame.initializeObject(type, thisType); thisUninit = true; } else if (type.tag == ITEM_UNINITIALIZED) { - int new_offset = type.bci; - int new_class_index = bcs.getIndexU2Raw(new_offset + 1); - Type new_class_type = cpIndexToType(new_class_index, cp); + Type new_class_type = cpIndexToType(bcs.getU2(type.bci + 1), cp); if (inTryBlock) { processExceptionHandlerTargets(bci, thisUninit); } @@ -800,7 +787,7 @@ public final class StackMapGenerator { throw generatorError("Bad operand type when invoking "); } } else { - currentFrame.popStack(); + currentFrame.decStack(); } } currentFrame.pushStack(mDesc.returnType()); @@ -813,10 +800,17 @@ public final class StackMapGenerator { } private void processAnewarray(int index) { - currentFrame.popStack(); + currentFrame.decStack(); currentFrame.pushStack(cpIndexToType(index, cp).toArray()); } + /** + * {@return the generator error with stack underflow} + */ + private IllegalArgumentException stackUnderflow() { + return generatorError("Operand stack underflow"); + } + /** * {@return the generator error with attached details} * @param msg error message @@ -841,59 +835,51 @@ public final class StackMapGenerator { } /** - * Performs detection of mandatory stack map frames offsets - * in a single bytecode traversing pass - * @return java.lang.BitSet of detected frames offsets + * Performs detection of mandatory stack map frames in a single bytecode traversing pass + * @return detected frames */ - private BitSet detectFrameOffsets() { - var offsets = new BitSet() { - @Override - public void set(int i) { - if (i < 0 || i >= bytecode.capacity()) throw new IllegalArgumentException(); - super.set(i); - } - }; - RawBytecodeHelper bcs = new RawBytecodeHelper(bytecode); + private void detectFrames() { + var bcs = bytecode.start(); boolean no_control_flow = false; int opcode, bci = 0; - while (!bcs.isLastBytecode()) try { - opcode = bcs.rawNext(); - bci = bcs.bci; + while (bcs.next()) try { + opcode = bcs.opcode(); + bci = bcs.bci(); if (no_control_flow) { - offsets.set(bci); + addFrame(bci); } no_control_flow = switch (opcode) { case GOTO -> { - offsets.set(bcs.dest()); + addFrame(bcs.dest()); yield true; } case GOTO_W -> { - offsets.set(bcs.destW()); + addFrame(bcs.destW()); yield true; } case IF_ICMPEQ, IF_ICMPNE, IF_ICMPLT, IF_ICMPGE, IF_ICMPGT, IF_ICMPLE, IFEQ, IFNE, IFLT, IFGE, IFGT, IFLE, IF_ACMPEQ, IF_ACMPNE , IFNULL , IFNONNULL -> { - offsets.set(bcs.dest()); + addFrame(bcs.dest()); yield false; } case TABLESWITCH, LOOKUPSWITCH -> { int aligned_bci = RawBytecodeHelper.align(bci + 1); - int default_ofset = bcs.getInt(aligned_bci); + int default_ofset = bcs.getIntUnchecked(aligned_bci); int keys, delta; - if (bcs.rawCode == TABLESWITCH) { - int low = bcs.getInt(aligned_bci + 4); - int high = bcs.getInt(aligned_bci + 2 * 4); + if (bcs.opcode() == TABLESWITCH) { + int low = bcs.getIntUnchecked(aligned_bci + 4); + int high = bcs.getIntUnchecked(aligned_bci + 2 * 4); keys = high - low + 1; delta = 1; } else { - keys = bcs.getInt(aligned_bci + 4); + keys = bcs.getIntUnchecked(aligned_bci + 4); delta = 2; } - offsets.set(bci + default_ofset); + addFrame(bci + default_ofset); for (int i = 0; i < keys; i++) { - offsets.set(bci + bcs.getInt(aligned_bci + (3 + i * delta) * 4)); + addFrame(bci + bcs.getIntUnchecked(aligned_bci + (3 + i * delta) * 4)); } yield true; } @@ -904,13 +890,37 @@ public final class StackMapGenerator { } catch (IllegalArgumentException iae) { throw generatorError("Detected branch target out of bytecode range", bci); } - for (var exhandler : rawHandlers) try { - offsets.set(exhandler.handler()); + + for (int i = 0; i < rawHandlers.size(); i++) try { + addFrame(rawHandlers.get(i).handler()); } catch (IllegalArgumentException iae) { if (!filterDeadLabels) throw generatorError("Detected exception handler out of bytecode range"); } - return offsets; + } + + private void addFrame(int offset) { + Preconditions.checkIndex(offset, bytecode.length(), RawBytecodeHelper.IAE_FORMATTER); + var frames = this.frames; + int i = 0, framesCount = this.framesCount; + for (; i < framesCount; i++) { + var frameOffset = frames[i].offset; + if (frameOffset == offset) { + return; + } + if (frameOffset > offset) { + break; + } + } + if (framesCount >= frames.length) { + int newCapacity = framesCount + 8; + this.frames = frames = framesCount == 0 ? new Frame[newCapacity] : Arrays.copyOf(frames, newCapacity); + } + if (i != framesCount) { + System.arraycopy(frames, i, frames, i + 1, framesCount - i); + } + frames[i] = new Frame(offset, classHierarchy); + this.framesCount = framesCount + 1; } private final class Frame { @@ -949,44 +959,214 @@ public final class StackMapGenerator { return (dirty ? "frame* @" : "frame @") + offset + " with locals " + (locals == null ? "[]" : Arrays.asList(locals).subList(0, localsSize)) + " and stack " + (stack == null ? "[]" : Arrays.asList(stack).subList(0, stackSize)); } + Frame dup() { + int stackSize = this.stackSize; + if (stackSize < 1) throw stackUnderflow(); + checkStack(stackSize + 1); + stack[stackSize] = stack[stackSize - 1]; + this.stackSize = stackSize + 1; + return this; + } + + Frame dup_x1() { + int stackSize = this.stackSize; + if (stackSize < 2) throw stackUnderflow(); + checkStack(stackSize + 1); + var stack = this.stack; + Type type0 = stack[stackSize - 2]; + Type type1 = stack[stackSize - 1]; + stack[stackSize - 2] = type1; + stack[stackSize - 1] = type0; + stack[stackSize ] = type1; + this.stackSize = stackSize + 1; + return this; + } + + Frame dup_x2() { + int stackSize = this.stackSize; + if (stackSize < 3) throw stackUnderflow(); + checkStack(stackSize + 1); + var stack = this.stack; + Type type0 = stack[stackSize - 3]; + Type type1 = stack[stackSize - 2]; + Type type2 = stack[stackSize - 1]; + stack[stackSize - 3] = type2; + stack[stackSize - 2] = type0; + stack[stackSize - 1] = type1; + stack[stackSize ] = type2; + this.stackSize = stackSize + 1; + return this; + } + + Frame dup2() { + int stackSize = this.stackSize; + if (stackSize < 2) throw stackUnderflow(); + checkStack(stackSize + 2); + stack[stackSize ] = stack[stackSize - 2]; + stack[stackSize + 1] = stack[stackSize - 1]; + this.stackSize = stackSize + 2; + return this; + } + + Frame dup2_x1() { + int stackSize = this.stackSize; + if (stackSize < 3) throw stackUnderflow(); + checkStack(stackSize + 2); + var stack = this.stack; + Type type0 = stack[stackSize - 3]; + Type type1 = stack[stackSize - 2]; + Type type2 = stack[stackSize - 1]; + stack[stackSize - 3] = type1; + stack[stackSize - 2] = type2; + stack[stackSize - 1] = type0; + stack[stackSize ] = type1; + stack[stackSize + 1] = type2; + this.stackSize = stackSize + 2; + return this; + } + + Frame dup2_x2() { + int stackSize = this.stackSize; + if (stackSize < 4) throw stackUnderflow(); + checkStack(stackSize + 2); + var stack = this.stack; + Type type0 = stack[stackSize - 4]; + Type type1 = stack[stackSize - 3]; + Type type2 = stack[stackSize - 2]; + Type type3 = stack[stackSize - 1]; + stack[stackSize - 4] = type2; + stack[stackSize - 3] = type3; + stack[stackSize - 2] = type0; + stack[stackSize - 1] = type1; + stack[stackSize ] = type2; + stack[stackSize + 1] = type3; + this.stackSize = stackSize + 4; + return this; + } + + Frame swap() { + int stackSize = this.stackSize - 2; + if (stackSize < 0) throw stackUnderflow(); + var stack = this.stack; + Type type = stack[stackSize]; + stack[stackSize] = stack[stackSize + 1]; + stack[stackSize + 1] = type; + return this; + } + Frame pushStack(ClassDesc desc) { - return switch (desc.descriptorString().charAt(0)) { - case 'J' -> - pushStack(Type.LONG_TYPE, Type.LONG2_TYPE); - case 'D' -> - pushStack(Type.DOUBLE_TYPE, Type.DOUBLE2_TYPE); - case 'I', 'Z', 'B', 'C', 'S' -> - pushStack(Type.INTEGER_TYPE); - case 'F' -> - pushStack(Type.FLOAT_TYPE); - case 'V' -> - this; - default -> - pushStack(Type.referenceType(desc)); - }; + if (desc == CD_long) return pushStack(Type.LONG_TYPE, Type.LONG2_TYPE); + if (desc == CD_double) return pushStack(Type.DOUBLE_TYPE, Type.DOUBLE2_TYPE); + return desc == CD_void ? this + : pushStack( + desc instanceof PrimitiveClassDescImpl + ? (desc == CD_float ? Type.FLOAT_TYPE : Type.INTEGER_TYPE) + : Type.referenceType(desc)); + } + + Frame dec1PushStack(ClassDesc desc) { + if (desc == CD_long) return decStack1PushStack(Type.LONG_TYPE, Type.LONG2_TYPE); + if (desc == CD_double) return decStack1PushStack(Type.DOUBLE_TYPE, Type.DOUBLE2_TYPE); + return desc == CD_void ? this + : decStack1PushStack( + desc instanceof PrimitiveClassDescImpl + ? (desc == CD_float ? Type.FLOAT_TYPE : Type.INTEGER_TYPE) + : Type.referenceType(desc)); } Frame pushStack(Type type) { + int stackSize = this.stackSize; checkStack(stackSize); - stack[stackSize++] = type; + stack[stackSize] = type; + this.stackSize = stackSize + 1; return this; } Frame pushStack(Type type1, Type type2) { + int stackSize = this.stackSize; checkStack(stackSize + 1); - stack[stackSize++] = type1; - stack[stackSize++] = type2; + stack[stackSize] = type1; + stack[stackSize + 1] = type2; + this.stackSize = stackSize + 2; return this; } Type popStack() { - if (stackSize < 1) throw generatorError("Operand stack underflow"); - return stack[--stackSize]; + int stackSize = this.stackSize - 1; + if (stackSize < 0) throw stackUnderflow(); + this.stackSize = stackSize; + return stack[stackSize]; + } + + Frame decStack() { + if (--stackSize < 0) throw stackUnderflow(); + return this; } Frame decStack(int size) { stackSize -= size; - if (stackSize < 0) throw generatorError("Operand stack underflow"); + if (stackSize < 0) throw stackUnderflow(); + return this; + } + + Frame decStack1PushStack(Type type1, Type type2) { + int stackSize = this.stackSize - 1; + if (stackSize < 0) throw stackUnderflow(); + checkStack(stackSize + 2); + stack[stackSize ] = type1; + stack[stackSize + 1] = type2; + this.stackSize = stackSize + 2; + return this; + } + + Frame decStack1PushStack(Type type) { + int stackSize = this.stackSize - 1; + if (stackSize < 0) throw stackUnderflow(); + stack[stackSize] = type; + return this; + } + + Frame decStack2PushStack(Type type) { + int stackSize = this.stackSize - 2; + if (stackSize < 0) throw stackUnderflow(); + stack[stackSize] = type; + this.stackSize = stackSize + 1; + return this; + } + + Frame decStack2PushStack(Type type1, Type type2) { + int stackSize = this.stackSize - 2; + if (stackSize < 0) throw stackUnderflow(); + var stack = this.stack; + stack[stackSize ] = type1; + stack[stackSize + 1] = type2; + return this; + } + + Frame decStack3PushStack(Type type1, Type type2) { + int stackSize = this.stackSize - 3; + if (stackSize < 0) throw stackUnderflow(); + stack[stackSize ] = type1; + stack[stackSize + 1] = type2; + this.stackSize = stackSize + 2; + return this; + } + + Frame decStack4PushStack(Type type) { + int stackSize = this.stackSize - 4; + if (stackSize < 0) throw stackUnderflow(); + stack[stackSize] = type; + this.stackSize = stackSize + 1; + return this; + } + + Frame decStack4PushStack(Type type1, Type type2) { + int stackSize = this.stackSize - 4; + if (stackSize < 0) throw stackUnderflow(); + var stack = this.stack; + stack[stackSize ] = type1; + stack[stackSize + 1] = type2; + this.stackSize = stackSize + 2; return this; } @@ -1015,65 +1195,93 @@ public final class StackMapGenerator { Frame checkLocal(int index) { if (index >= frameMaxLocals) frameMaxLocals = index + 1; if (locals == null) { - locals = new Type[index + FRAME_DEFAULT_CAPACITY]; - Arrays.fill(locals, Type.TOP_TYPE); + initLocals(index); } else if (index >= locals.length) { - int current = locals.length; - locals = Arrays.copyOf(locals, index + FRAME_DEFAULT_CAPACITY); - Arrays.fill(locals, current, locals.length, Type.TOP_TYPE); + growLocals(index); } return this; } + private void initLocals(int index) { + locals = new Type[index + FRAME_DEFAULT_CAPACITY]; + Arrays.fill(locals, Type.TOP_TYPE); + } + + private void growLocals(int index) { + int current = locals.length; + locals = Arrays.copyOf(locals, index + FRAME_DEFAULT_CAPACITY); + Arrays.fill(locals, current, locals.length, Type.TOP_TYPE); + } + private void checkStack(int index) { if (index >= frameMaxStack) frameMaxStack = index + 1; if (stack == null) { - stack = new Type[index + FRAME_DEFAULT_CAPACITY]; - Arrays.fill(stack, Type.TOP_TYPE); + initStack(index); } else if (index >= stack.length) { - int current = stack.length; - stack = Arrays.copyOf(stack, index + FRAME_DEFAULT_CAPACITY); - Arrays.fill(stack, current, stack.length, Type.TOP_TYPE); + growStack(index); } } + private void initStack(int index) { + stack = new Type[index + FRAME_DEFAULT_CAPACITY]; + Arrays.fill(stack, Type.TOP_TYPE); + } + + private void growStack(int index) { + int current = stack.length; + stack = Arrays.copyOf(stack, index + FRAME_DEFAULT_CAPACITY); + Arrays.fill(stack, current, stack.length, Type.TOP_TYPE); + } + private void setLocalRawInternal(int index, Type type) { checkLocal(index); + var locals = this.locals; localsChanged |= !type.equals(locals[index]); locals[index] = type; } + private void setLocalRawInternal(int index, Type type1, Type type2) { + checkLocal(index + 1); + var locals = this.locals; + localsChanged |= !type1.equals(locals[index]) || !type2.equals(locals[index + 1]); + locals[index ] = type1; + locals[index + 1] = type2; + } + void setLocalsFromArg(String name, MethodTypeDesc methodDesc, boolean isStatic, Type thisKlass) { int localsSize = 0; // Pre-emptively create a locals array that encompass all parameter slots - checkLocal(methodDesc.parameterCount() + (isStatic ? -1 : 0)); + checkLocal(Util.parameterSlots(methodDesc) + (isStatic ? -1 : 0)); + Type type; + Type[] locals = this.locals; if (!isStatic) { - localsSize++; if (OBJECT_INITIALIZER_NAME.equals(name) && !CD_Object.equals(thisKlass.sym)) { - setLocal(0, Type.UNITIALIZED_THIS_TYPE); + type = Type.UNITIALIZED_THIS_TYPE; flags |= FLAG_THIS_UNINIT; } else { - setLocalRawInternal(0, thisKlass); + type = thisKlass; } + locals[localsSize++] = type; } for (int i = 0; i < methodDesc.parameterCount(); i++) { var desc = methodDesc.parameterType(i); - if (!desc.isPrimitive()) { - setLocalRawInternal(localsSize++, Type.referenceType(desc)); - } else switch (desc.descriptorString().charAt(0)) { - case 'J' -> { - setLocalRawInternal(localsSize++, Type.LONG_TYPE); - setLocalRawInternal(localsSize++, Type.LONG2_TYPE); + if (desc == CD_long) { + locals[localsSize ] = Type.LONG_TYPE; + locals[localsSize + 1] = Type.LONG2_TYPE; + localsSize += 2; + } else if (desc == CD_double) { + locals[localsSize ] = Type.DOUBLE_TYPE; + locals[localsSize + 1] = Type.DOUBLE2_TYPE; + localsSize += 2; + } else { + if (desc instanceof ReferenceClassDescImpl) { + type = Type.referenceType(desc); + } else if (desc == CD_float) { + type = Type.FLOAT_TYPE; + } else { + type = Type.INTEGER_TYPE; } - case 'D' -> { - setLocalRawInternal(localsSize++, Type.DOUBLE_TYPE); - setLocalRawInternal(localsSize++, Type.DOUBLE2_TYPE); - } - case 'I', 'Z', 'B', 'C', 'S' -> - setLocalRawInternal(localsSize++, Type.INTEGER_TYPE); - case 'F' -> - setLocalRawInternal(localsSize++, Type.FLOAT_TYPE); - default -> throw new AssertionError("Should not reach here"); + locals[localsSize++] = type; } } this.localsSize = localsSize; @@ -1093,11 +1301,15 @@ public final class StackMapGenerator { } void checkAssignableTo(Frame target) { + int localsSize = this.localsSize; + int stackSize = this.stackSize; if (target.flags == -1) { - target.locals = locals == null ? null : Arrays.copyOf(locals, localsSize); + target.locals = locals == null ? null : locals.clone(); target.localsSize = localsSize; - target.stack = stack == null ? null : Arrays.copyOf(stack, stackSize); - target.stackSize = stackSize; + if (stackSize > 0) { + target.stack = stack.clone(); + target.stackSize = stackSize; + } target.flags = flags; target.dirty = true; } else { @@ -1136,8 +1348,7 @@ public final class StackMapGenerator { Type old = getLocalRawInternal(index); if (old == Type.DOUBLE_TYPE || old == Type.LONG_TYPE) { setLocalRawInternal(index + 1, Type.TOP_TYPE); - } - if (old == Type.DOUBLE2_TYPE || old == Type.LONG2_TYPE) { + } else if (old == Type.DOUBLE2_TYPE || old == Type.LONG2_TYPE) { setLocalRawInternal(index - 1, Type.TOP_TYPE); } setLocalRawInternal(index, type); @@ -1155,8 +1366,7 @@ public final class StackMapGenerator { if (old == Type.DOUBLE2_TYPE || old == Type.LONG2_TYPE) { setLocalRawInternal(index - 1, Type.TOP_TYPE); } - setLocalRawInternal(index, type1); - setLocalRawInternal(index + 1, type2); + setLocalRawInternal(index, type1, type2); if (index >= localsSize - 1) { localsSize = index + 2; } @@ -1177,7 +1387,10 @@ public final class StackMapGenerator { int compressed = 0; for (int i = 0; i < count; i++) { if (!types[i].isCategory2_2nd()) { - types[compressed++] = types[i]; + if (compressed != i) { + types[compressed] = types[i]; + } + compressed++; } } return compressed; @@ -1193,7 +1406,9 @@ public final class StackMapGenerator { return Arrays.equals(l1, 0, commonSize, l2, 0, commonSize); } - void writeTo(BufWriter out, Frame prevFrame, ConstantPoolBuilder cp) { + void writeTo(BufWriterImpl out, Frame prevFrame, ConstantPoolBuilder cp) { + int localsSize = this.localsSize; + int stackSize = this.stackSize; int offsetDelta = offset - prevFrame.offset - 1; if (stackSize == 0) { int commonLocalsSize = localsSize > prevFrame.localsSize ? prevFrame.localsSize : localsSize; @@ -1202,8 +1417,7 @@ public final class StackMapGenerator { if (diffLocalsSize == 0 && offsetDelta < 64) { //same frame out.writeU1(offsetDelta); } else { //chop, same extended or append frame - out.writeU1(251 + diffLocalsSize); - out.writeU2(offsetDelta); + out.writeU1U2(251 + diffLocalsSize, offsetDelta); for (int i=commonLocalsSize; i - bw.writeU2(cp.classEntry(sym).index()); + bw.writeU1U2(tag, cp.classEntry(sym).index()); case ITEM_UNINITIALIZED -> - bw.writeU2(bci); + bw.writeU1U2(tag, bci); + default -> + bw.writeU1(tag); } } } diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/TargetInfoImpl.java b/src/java.base/share/classes/jdk/internal/classfile/impl/TargetInfoImpl.java index 3377e3ebd13..f30597cb3c4 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/impl/TargetInfoImpl.java +++ b/src/java.base/share/classes/jdk/internal/classfile/impl/TargetInfoImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,10 +25,9 @@ package jdk.internal.classfile.impl; import java.util.List; -import java.util.Objects; import java.lang.classfile.Label; import java.lang.classfile.TypeAnnotation.*; -import static java.lang.classfile.ClassFile.*; + import static java.util.Objects.requireNonNull; public final class TargetInfoImpl { @@ -37,7 +36,6 @@ public final class TargetInfoImpl { } private static TargetType checkValid(TargetType targetType, int rangeFrom, int rangeTo) { - Objects.requireNonNull(targetType); if (targetType.targetTypeValue() < rangeFrom || targetType.targetTypeValue() > rangeTo) throw new IllegalArgumentException("Wrong target type specified " + targetType); return targetType; @@ -47,7 +45,7 @@ public final class TargetInfoImpl { implements TypeParameterTarget { public TypeParameterTargetImpl(TargetType targetType, int typeParameterIndex) { - this.targetType = checkValid(targetType, TAT_CLASS_TYPE_PARAMETER, TAT_METHOD_TYPE_PARAMETER); + this.targetType = checkValid(targetType, TARGET_CLASS_TYPE_PARAMETER, TARGET_METHOD_TYPE_PARAMETER); this.typeParameterIndex = typeParameterIndex; } } @@ -63,7 +61,7 @@ public final class TargetInfoImpl { implements TypeParameterBoundTarget { public TypeParameterBoundTargetImpl(TargetType targetType, int typeParameterIndex, int boundIndex) { - this.targetType = checkValid(targetType, TAT_CLASS_TYPE_PARAMETER_BOUND, TAT_METHOD_TYPE_PARAMETER_BOUND); + this.targetType = checkValid(targetType, TARGET_CLASS_TYPE_PARAMETER_BOUND, TARGET_METHOD_TYPE_PARAMETER_BOUND); this.typeParameterIndex = typeParameterIndex; this.boundIndex = boundIndex; } @@ -72,7 +70,7 @@ public final class TargetInfoImpl { public record EmptyTargetImpl(TargetType targetType) implements EmptyTarget { public EmptyTargetImpl(TargetType targetType) { - this.targetType = checkValid(targetType, TAT_FIELD, TAT_METHOD_RECEIVER); + this.targetType = checkValid(targetType, TARGET_FIELD, TARGET_METHOD_RECEIVER); } } @@ -94,7 +92,7 @@ public final class TargetInfoImpl { implements LocalVarTarget { public LocalVarTargetImpl(TargetType targetType, List table) { - this.targetType = checkValid(targetType, TAT_LOCAL_VARIABLE, TAT_RESOURCE_VARIABLE); + this.targetType = checkValid(targetType, TARGET_LOCAL_VARIABLE, TARGET_RESOURCE_VARIABLE); this.table = List.copyOf(table); } @Override @@ -122,7 +120,7 @@ public final class TargetInfoImpl { public record OffsetTargetImpl(TargetType targetType, Label target) implements OffsetTarget { public OffsetTargetImpl(TargetType targetType, Label target) { - this.targetType = checkValid(targetType, TAT_INSTANCEOF, TAT_METHOD_REFERENCE); + this.targetType = checkValid(targetType, TARGET_INSTANCEOF, TARGET_METHOD_REFERENCE); this.target = requireNonNull(target); } } @@ -131,7 +129,7 @@ public final class TargetInfoImpl { implements TypeArgumentTarget { public TypeArgumentTargetImpl(TargetType targetType, Label target, int typeArgumentIndex) { - this.targetType = checkValid(targetType, TAT_CAST, TAT_METHOD_REFERENCE_TYPE_ARGUMENT); + this.targetType = checkValid(targetType, TARGET_CAST, TARGET_METHOD_REFERENCE_TYPE_ARGUMENT); this.target = requireNonNull(target); this.typeArgumentIndex = typeArgumentIndex; } diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/TemporaryConstantPool.java b/src/java.base/share/classes/jdk/internal/classfile/impl/TemporaryConstantPool.java index 784e844b712..4fee9ba3d95 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/impl/TemporaryConstantPool.java +++ b/src/java.base/share/classes/jdk/internal/classfile/impl/TemporaryConstantPool.java @@ -50,6 +50,7 @@ import java.lang.classfile.constantpool.Utf8Entry; import java.lang.constant.MethodTypeDesc; import java.util.List; +import java.util.Objects; public final class TemporaryConstantPool implements ConstantPoolBuilder { @@ -187,6 +188,7 @@ public final class TemporaryConstantPool implements ConstantPoolBuilder { @Override public boolean canWriteDirect(ConstantPool constantPool) { + Objects.requireNonNull(constantPool); return false; } } diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/UnboundAttribute.java b/src/java.base/share/classes/jdk/internal/classfile/impl/UnboundAttribute.java index 5ee3759bba3..a979a31c593 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/impl/UnboundAttribute.java +++ b/src/java.base/share/classes/jdk/internal/classfile/impl/UnboundAttribute.java @@ -92,6 +92,8 @@ import java.lang.classfile.constantpool.Utf8Entry; import jdk.internal.access.SharedSecrets; +import static java.util.Objects.requireNonNull; + public abstract sealed class UnboundAttribute> extends AbstractElement implements Attribute, Util.Writable { @@ -149,7 +151,7 @@ public abstract sealed class UnboundAttribute> public UnboundConstantValueAttribute(ConstantValueEntry entry) { super(Attributes.constantValue()); - this.entry = entry; + this.entry = requireNonNull(entry); } @Override @@ -182,7 +184,7 @@ public abstract sealed class UnboundAttribute> public UnboundSignatureAttribute(Utf8Entry signature) { super(Attributes.signature()); - this.signature = signature; + this.signature = requireNonNull(signature); } @Override @@ -214,7 +216,7 @@ public abstract sealed class UnboundAttribute> public UnboundAnnotationDefaultAttribute(AnnotationValue annotationDefault) { super(Attributes.annotationDefault()); - this.annotationDefault = annotationDefault; + this.annotationDefault = requireNonNull(annotationDefault); } @Override @@ -229,7 +231,7 @@ public abstract sealed class UnboundAttribute> public UnboundSourceFileAttribute(Utf8Entry sourceFile) { super(Attributes.sourceFile()); - this.sourceFile = sourceFile; + this.sourceFile = requireNonNull(sourceFile); } @Override @@ -294,7 +296,7 @@ public abstract sealed class UnboundAttribute> public UnboundEnclosingMethodAttribute(ClassEntry classEntry, NameAndTypeEntry method) { super(Attributes.enclosingMethod()); - this.classEntry = classEntry; + this.classEntry = requireNonNull(classEntry); this.method = method; } @@ -332,7 +334,7 @@ public abstract sealed class UnboundAttribute> public UnboundModuleTargetAttribute(Utf8Entry moduleTarget) { super(Attributes.moduleTarget()); - this.moduleTarget = moduleTarget; + this.moduleTarget = requireNonNull(moduleTarget); } @Override @@ -348,7 +350,7 @@ public abstract sealed class UnboundAttribute> public UnboundModuleMainClassAttribute(ClassEntry mainClass) { super(Attributes.moduleMainClass()); - this.mainClass = mainClass; + this.mainClass = requireNonNull(mainClass); } @Override @@ -365,7 +367,7 @@ public abstract sealed class UnboundAttribute> public UnboundModuleHashesAttribute(Utf8Entry algorithm, List hashes) { super(Attributes.moduleHashes()); - this.algorithm = algorithm; + this.algorithm = requireNonNull(algorithm); this.hashes = List.copyOf(hashes); } @@ -451,7 +453,7 @@ public abstract sealed class UnboundAttribute> public UnboundNestHostAttribute(ClassEntry hostEntry) { super(Attributes.nestHost()); - this.hostEntry = hostEntry; + this.hostEntry = requireNonNull(hostEntry); } @Override @@ -467,7 +469,7 @@ public abstract sealed class UnboundAttribute> public UnboundCompilationIDAttribute(Utf8Entry idEntry) { super(Attributes.compilationId()); - this.idEntry = idEntry; + this.idEntry = requireNonNull(idEntry); } @Override @@ -483,7 +485,7 @@ public abstract sealed class UnboundAttribute> public UnboundSourceIDAttribute(Utf8Entry idEntry) { super(Attributes.sourceId()); - this.idEntry = idEntry; + this.idEntry = requireNonNull(idEntry); } @Override @@ -499,7 +501,7 @@ public abstract sealed class UnboundAttribute> public UnboundSourceDebugExtensionAttribute(byte[] contents) { super(Attributes.sourceDebugExtension()); - this.contents = contents; + this.contents = requireNonNull(contents); } @Override @@ -611,7 +613,13 @@ public abstract sealed class UnboundAttribute> public UnboundRuntimeVisibleParameterAnnotationsAttribute(List> elements) { super(Attributes.runtimeVisibleParameterAnnotations()); - this.elements = List.copyOf(elements); + // deep copy + var array = elements.toArray().clone(); + for (int i = 0; i < array.length; i++) { + array[i] = List.copyOf((List) array[i]); + } + + this.elements = SharedSecrets.getJavaUtilCollectionAccess().listFromTrustedArray(array); } @Override @@ -684,7 +692,13 @@ public abstract sealed class UnboundAttribute> Optional outerClass, Optional innerName, int flagsMask) - implements InnerClassInfo {} + implements InnerClassInfo { + public UnboundInnerClassInfo { + requireNonNull(innerClass); + requireNonNull(outerClass); + requireNonNull(innerName); + } + } public record UnboundLineNumberInfo(int startPc, int lineNumber) implements LineNumberInfo { } @@ -693,64 +707,84 @@ public abstract sealed class UnboundAttribute> Utf8Entry name, Utf8Entry type, int slot) - implements LocalVariableInfo { } + implements LocalVariableInfo { + public UnboundLocalVariableInfo { + requireNonNull(name); + requireNonNull(type); + } + } public record UnboundLocalVariableTypeInfo(int startPc, int length, Utf8Entry name, Utf8Entry signature, int slot) - implements LocalVariableTypeInfo { } + implements LocalVariableTypeInfo { + public UnboundLocalVariableTypeInfo { + requireNonNull(name); + requireNonNull(signature); + } + } public record UnboundMethodParameterInfo(Optional name, int flagsMask) - implements MethodParameterInfo {} + implements MethodParameterInfo { + public UnboundMethodParameterInfo { + requireNonNull(name); + } + } public record UnboundModuleExportInfo(PackageEntry exportedPackage, int exportsFlagsMask, List exportsTo) implements ModuleExportInfo { - public UnboundModuleExportInfo(PackageEntry exportedPackage, int exportsFlagsMask, - List exportsTo) { - this.exportedPackage = exportedPackage; - this.exportsFlagsMask = exportsFlagsMask; - this.exportsTo = List.copyOf(exportsTo); + public UnboundModuleExportInfo { + requireNonNull(exportedPackage); + exportsTo = List.copyOf(exportsTo); } } public record UnboundModuleHashInfo(ModuleEntry moduleName, - byte[] hash) implements ModuleHashInfo { } + byte[] hash) implements ModuleHashInfo { + public UnboundModuleHashInfo { + requireNonNull(moduleName); + requireNonNull(hash); + } + } public record UnboundModuleOpenInfo(PackageEntry openedPackage, int opensFlagsMask, List opensTo) implements ModuleOpenInfo { - public UnboundModuleOpenInfo(PackageEntry openedPackage, int opensFlagsMask, - List opensTo) { - this.openedPackage = openedPackage; - this.opensFlagsMask = opensFlagsMask; - this.opensTo = List.copyOf(opensTo); + public UnboundModuleOpenInfo { + requireNonNull(openedPackage); + opensTo = List.copyOf(opensTo); } } public record UnboundModuleProvideInfo(ClassEntry provides, List providesWith) implements ModuleProvideInfo { - public UnboundModuleProvideInfo(ClassEntry provides, List providesWith) { - this.provides = provides; - this.providesWith = List.copyOf(providesWith); + public UnboundModuleProvideInfo { + requireNonNull(provides); + providesWith = List.copyOf(providesWith); } } public record UnboundModuleRequiresInfo(ModuleEntry requires, int requiresFlagsMask, Optional requiresVersion) - implements ModuleRequireInfo {} + implements ModuleRequireInfo { + public UnboundModuleRequiresInfo { + requireNonNull(requires); + requireNonNull(requiresVersion); + } + } public record UnboundRecordComponentInfo(Utf8Entry name, Utf8Entry descriptor, List> attributes) implements RecordComponentInfo { - public UnboundRecordComponentInfo(Utf8Entry name, Utf8Entry descriptor, List> attributes) { - this.name = name; - this.descriptor = descriptor; - this.attributes = List.copyOf(attributes); + public UnboundRecordComponentInfo { + requireNonNull(name); + requireNonNull(descriptor); + attributes = List.copyOf(attributes); } } @@ -759,7 +793,9 @@ public abstract sealed class UnboundAttribute> Annotation annotation) implements TypeAnnotation { public UnboundTypeAnnotation { + requireNonNull(targetInfo); targetPath = List.copyOf(targetPath); + requireNonNull(annotation); } } @@ -786,7 +822,7 @@ public abstract sealed class UnboundAttribute> Collection provides) { super(Attributes.module()); - this.moduleName = moduleName; + this.moduleName = requireNonNull(moduleName); this.moduleFlags = moduleFlags; this.moduleVersion = moduleVersion; this.requires = List.copyOf(requires); @@ -849,11 +885,10 @@ public abstract sealed class UnboundAttribute> @Override public void writeTo(BufWriterImpl b) { b.writeIndex(b.constantPool().utf8Entry(mapper.name())); - b.writeInt(0); - int start = b.size(); + int lengthIndex = b.skip(4); writeBody(b); - int written = b.size() - start; - b.patchInt(start - 4, 4, written); + int written = b.size() - lengthIndex - 4; + b.patchInt(lengthIndex, written); } } diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/Util.java b/src/java.base/share/classes/jdk/internal/classfile/impl/Util.java index a064c40be30..0c4410bb5ea 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/impl/Util.java +++ b/src/java.base/share/classes/jdk/internal/classfile/impl/Util.java @@ -30,6 +30,7 @@ import java.lang.classfile.FieldBuilder; import java.lang.classfile.MethodBuilder; import java.lang.classfile.PseudoInstruction; import java.lang.classfile.constantpool.PoolEntry; +import java.lang.classfile.constantpool.Utf8Entry; import java.lang.constant.ClassDesc; import java.lang.constant.MethodTypeDesc; import java.util.AbstractList; @@ -49,13 +50,18 @@ import java.lang.classfile.constantpool.NameAndTypeEntry; import java.lang.constant.ModuleDesc; import java.lang.reflect.AccessFlag; import jdk.internal.access.SharedSecrets; +import jdk.internal.vm.annotation.ForceInline; +import jdk.internal.vm.annotation.Stable; import static java.lang.classfile.ClassFile.ACC_STATIC; import java.lang.classfile.attribute.CodeAttribute; import java.lang.classfile.components.ClassPrinter; -import java.nio.ByteBuffer; import java.util.function.Consumer; +import static jdk.internal.constant.PrimitiveClassDescImpl.CD_double; +import static jdk.internal.constant.PrimitiveClassDescImpl.CD_long; +import static jdk.internal.constant.PrimitiveClassDescImpl.CD_void; + /** * Helper to create and manipulate type descriptors, where type descriptors are * represented as JVM type descriptor strings and symbols are represented as @@ -99,16 +105,18 @@ public class Util { private static final int ATTRIBUTE_STABILITY_COUNT = AttributeMapper.AttributeStability.values().length; public static boolean isAttributeAllowed(final Attribute attr, - final ClassFile.AttributesProcessingOption processingOption) { + final ClassFileImpl context) { return attr instanceof BoundAttribute - ? ATTRIBUTE_STABILITY_COUNT - attr.attributeMapper().stability().ordinal() > processingOption.ordinal() + ? ATTRIBUTE_STABILITY_COUNT - attr.attributeMapper().stability().ordinal() > context.attributesProcessingOption().ordinal() : true; } public static int parameterSlots(MethodTypeDesc mDesc) { - int count = 0; - for (int i = 0; i < mDesc.parameterCount(); i++) { - count += slotSize(mDesc.parameterType(i)); + int count = mDesc.parameterCount(); + for (int i = count - 1; i >= 0; i--) { + if (isDoubleSlot(mDesc.parameterType(i))) { + count++; + } } return count; } @@ -118,17 +126,13 @@ public class Util { int count = ((flags & ACC_STATIC) != 0) ? 0 : 1; for (int i = 0; i < result.length; i++) { result[i] = count; - count += slotSize(mDesc.parameterType(i)); + count += paramSlotSize(mDesc.parameterType(i)); } return result; } public static int maxLocals(int flags, MethodTypeDesc mDesc) { - int count = ((flags & ACC_STATIC) != 0) ? 0 : 1; - for (int i = 0; i < mDesc.parameterCount(); i++) { - count += slotSize(mDesc.parameterType(i)); - } - return count; + return parameterSlots(mDesc) + ((flags & ACC_STATIC) == 0 ? 1 : 0) ; } /** @@ -185,8 +189,12 @@ public class Util { public static void checkKind(Opcode op, Opcode.Kind k) { if (op.kind() != k) - throw new IllegalArgumentException( - String.format("Wrong opcode kind specified; found %s(%s), expected %s", op, op.kind(), k)); + throw badOpcodeKindException(op, k); + } + + public static IllegalArgumentException badOpcodeKindException(Opcode op, Opcode.Kind k) { + return new IllegalArgumentException( + String.format("Wrong opcode kind specified; found %s(%s), expected %s", op, op.kind(), k)); } public static int flagsToBits(AccessFlag.Location location, Collection flags) { @@ -215,16 +223,16 @@ public class Util { return (flag.mask() & flagsMask) == flag.mask() && flag.locations().contains(location); } - public static ClassDesc fieldTypeSymbol(NameAndTypeEntry nat) { - return ((AbstractPoolEntry.NameAndTypeEntryImpl)nat).fieldTypeSymbol(); + public static ClassDesc fieldTypeSymbol(Utf8Entry utf8) { + return ((AbstractPoolEntry.Utf8EntryImpl) utf8).fieldTypeSymbol(); } - public static MethodTypeDesc methodTypeSymbol(NameAndTypeEntry nat) { - return ((AbstractPoolEntry.NameAndTypeEntryImpl)nat).methodTypeSymbol(); + public static MethodTypeDesc methodTypeSymbol(Utf8Entry utf8) { + return ((AbstractPoolEntry.Utf8EntryImpl) utf8).methodTypeSymbol(); } @SuppressWarnings("unchecked") - private static > void writeAttribute(BufWriterImpl writer, Attribute attr) { + public static > void writeAttribute(BufWriterImpl writer, Attribute attr) { if (attr instanceof CustomAttribute ca) { var mapper = (AttributeMapper) ca.attributeMapper(); mapper.writeAttribute(writer, (T) ca); @@ -234,31 +242,33 @@ public class Util { } } + @ForceInline public static void writeAttributes(BufWriterImpl buf, List> list) { - buf.writeU2(list.size()); - for (var e : list) { - writeAttribute(buf, e); + int size = list.size(); + buf.writeU2(size); + for (int i = 0; i < size; i++) { + writeAttribute(buf, list.get(i)); } } - static void writeList(BufWriterImpl buf, List list) { - buf.writeU2(list.size()); - for (var e : list) { - e.writeTo(buf); + @ForceInline + static void writeList(BufWriterImpl buf, Writable[] array, int size) { + buf.writeU2(size); + for (int i = 0; i < size; i++) { + array[i].writeTo(buf); } } public static int slotSize(ClassDesc desc) { - return switch (desc.descriptorString().charAt(0)) { - case 'V' -> 0; - case 'D','J' -> 2; - default -> 1; - }; + return desc == CD_void ? 0 : isDoubleSlot(desc) ? 2 : 1; + } + + public static int paramSlotSize(ClassDesc desc) { + return isDoubleSlot(desc) ? 2 : 1; } public static boolean isDoubleSlot(ClassDesc desc) { - char ch = desc.descriptorString().charAt(0); - return ch == 'D' || ch == 'J'; + return desc == CD_double || desc == CD_long; } public static void dumpMethod(SplitConstantPool cp, @@ -266,7 +276,7 @@ public class Util { String methodName, MethodTypeDesc methodDesc, int acc, - ByteBuffer bytecode, + RawBytecodeHelper.CodeRange bytecode, Consumer dump) { // try to dump debug info about corrupted bytecode @@ -277,24 +287,25 @@ public class Util { ((DirectMethodBuilder)mb).writeAttribute(new UnboundAttribute.AdHocAttribute(Attributes.code()) { @Override public void writeBody(BufWriterImpl b) { - b.writeU2(-1);//max stack - b.writeU2(-1);//max locals - b.writeInt(bytecode.limit()); - b.writeBytes(bytecode.array(), 0, bytecode.limit()); - b.writeU2(0);//exception handlers - b.writeU2(0);//attributes + b.writeU2U2(-1, -1);//max stack & locals + b.writeInt(bytecode.length()); + b.writeBytes(bytecode.array(), 0, bytecode.length()); + b.writeU2U2(0, 0);//exception handlers & attributes } })))); ClassPrinter.toYaml(clm.methods().get(0).code().get(), ClassPrinter.Verbosity.TRACE_ALL, dump); } catch (Error | Exception _) { // fallback to bytecode hex dump - bytecode.rewind(); - while (bytecode.position() < bytecode.limit()) { - dump.accept("%n%04x:".formatted(bytecode.position())); - for (int i = 0; i < 16 && bytecode.position() < bytecode.limit(); i++) { - dump.accept(" %02x".formatted(bytecode.get())); - } + dumpBytesHex(dump, bytecode.array(), bytecode.length()); + } + } + + public static void dumpBytesHex(Consumer dump, byte[] bytes, int length) { + for (int i = 0; i < length; i++) { + if (i % 16 == 0) { + dump.accept("%n%04x:".formatted(i)); } + dump.accept(" %02x".formatted(bytes[i])); } } @@ -321,4 +332,83 @@ public class Util { interface WritableLocalVariable { boolean writeLocalTo(BufWriterImpl buf); } + + /** + * Returns the hash code of an internal name given the class or interface L descriptor. + */ + public static int internalNameHash(String desc) { + if (desc.length() > 0xffff) + throw new IllegalArgumentException("String too long: ".concat(Integer.toString(desc.length()))); + return (desc.hashCode() - pow31(desc.length() - 1) * 'L' - ';') * INVERSE_31; + } + + /** + * Returns the hash code of a class or interface L descriptor given the internal name. + */ + public static int descriptorStringHash(int length, int hash) { + if (length > 0xffff) + throw new IllegalArgumentException("String too long: ".concat(Integer.toString(length))); + return 'L' * pow31(length + 1) + hash * 31 + ';'; + } + + // k is at most 65536, length of Utf8 entry + 1 + public static int pow31(int k) { + int r = 1; + // calculate the power contribution from index-th octal digit + // from least to most significant (right to left) + // e.g. decimal 26=octal 32, power(26)=powerOctal(2,0)*powerOctal(3,1) + for (int i = 0; i < SIGNIFICANT_OCTAL_DIGITS; i++) { + r *= powerOctal(k & 7, i); + k >>= 3; + } + return r; + } + + // The inverse of 31 in Z/2^32Z* modulo group, a * INVERSE_31 * 31 = a + static final int INVERSE_31 = 0xbdef7bdf; + + // k is at most 65536 = octal 200000, only consider 6 octal digits + // Note: 31 powers repeat beyond 1 << 27, only 9 octal digits matter + static final int SIGNIFICANT_OCTAL_DIGITS = 6; + + // for base k, storage is k * log_k(N)=k/ln(k) * ln(N) + // k = 2 or 4 is better for space at the cost of more multiplications + /** + * The code below is as if: + * {@snippet lang=java : + * int[] powers = new int[7 * SIGNIFICANT_OCTAL_DIGITS]; + * + * for (int i = 1, k = 31; i <= 7; i++, k *= 31) { + * int t = powers[powersIndex(i, 0)] = k; + * for (int j = 1; j < SIGNIFICANT_OCTAL_DIGITS; j++) { + * t *= t; + * t *= t; + * t *= t; + * powers[powersIndex(i, j)] = t; + * } + * } + * } + * This is converted to explicit initialization to avoid bootstrap overhead. + * Validated in UtilTest. + */ + static final @Stable int[] powers = new int[] { + 0x0000001f, 0x000003c1, 0x0000745f, 0x000e1781, 0x01b4d89f, 0x34e63b41, 0x67e12cdf, + 0x94446f01, 0x50a9de01, 0x84304d01, 0x7dd7bc01, 0x8ca02b01, 0xff899a01, 0x25940901, + 0x4dbf7801, 0xe3bef001, 0xc1fe6801, 0xe87de001, 0x573d5801, 0x0e3cd001, 0x0d7c4801, + 0x54fbc001, 0xb9f78001, 0x2ef34001, 0xb3ef0001, 0x48eac001, 0xede68001, 0xa2e24001, + 0x67de0001, 0xcfbc0001, 0x379a0001, 0x9f780001, 0x07560001, 0x6f340001, 0xd7120001, + 0x3ef00001, 0x7de00001, 0xbcd00001, 0xfbc00001, 0x3ab00001, 0x79a00001, 0xb8900001, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + }; + + static int powersIndex(int digit, int index) { + return (digit - 1) + index * 7; + } + + // (31 ^ digit) ^ (8 * index) = 31 ^ (digit * (8 ^ index)) + // digit: 0 - 7 + // index: 0 - SIGNIFICANT_OCTAL_DIGITS - 1 + private static int powerOctal(int digit, int index) { + return digit == 0 ? 1 : powers[powersIndex(digit, index) & 0x3F]; // & 0x3F eliminates bound check + } } diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/verifier/VerificationBytecodes.java b/src/java.base/share/classes/jdk/internal/classfile/impl/verifier/VerificationBytecodes.java index c9b076aa1f0..5aed968c6ae 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/impl/verifier/VerificationBytecodes.java +++ b/src/java.base/share/classes/jdk/internal/classfile/impl/verifier/VerificationBytecodes.java @@ -24,9 +24,8 @@ */ package jdk.internal.classfile.impl.verifier; -import java.nio.ByteBuffer; +import static jdk.internal.classfile.impl.RawBytecodeHelper.*; -import java.lang.classfile.ClassFile; import jdk.internal.classfile.impl.verifier.VerificationSignature.BasicType; import static jdk.internal.classfile.impl.verifier.VerificationSignature.BasicType.*; @@ -83,48 +82,12 @@ final class VerificationBytecodes { return 0 <= code && code < number_of_codes; } - static int wide_length_for(int code) { - return is_valid(code) ? _lengths[code] >> 4 : -1; - } - static boolean is_store_into_local(int code) { - return (ClassFile.ISTORE <= code && code <= ClassFile.ASTORE_3); + return (ISTORE <= code && code <= ASTORE_3); } static final int _lengths[] = new int[number_of_codes]; - static int special_length_at(int code, byte bytecode[], int bci, int end) { - switch (code) { - case ClassFile.WIDE: - if (bci + 1 >= end) { - return -1; - } - return wide_length_for(bytecode[bci + 1] & 0xff); - case ClassFile.TABLESWITCH: - int aligned_bci = align(bci + 1); - if (aligned_bci + 3 * 4 >= end) { - return -1; - } - ByteBuffer bb = ByteBuffer.wrap(bytecode, aligned_bci + 1 * 4, 2 * 4); - int lo = bb.getInt(); - int hi = bb.getInt(); - int len = aligned_bci - bci + (3 + hi - lo + 1) * 4; - return len > 0 ? len : -1; - case ClassFile.LOOKUPSWITCH: - case _fast_binaryswitch: - case _fast_linearswitch: - aligned_bci = align(bci + 1); - if (aligned_bci + 2 * 4 >= end) { - return -1; - } - int npairs = ByteBuffer.wrap(bytecode, aligned_bci + 4, 4).getInt(); - len = aligned_bci - bci + (2 + 2 * npairs) * 4; - return len > 0 ? len : -1; - default: - return 0; - } - } - static int align(int n) { return (n + 3) & ~3; } @@ -141,244 +104,244 @@ final class VerificationBytecodes { } static { - def(ClassFile.NOP, "nop", "b", null, T_VOID, 0); - def(ClassFile.ACONST_NULL, "aconst_null", "b", null, T_OBJECT, 1); - def(ClassFile.ICONST_M1, "iconst_m1", "b", null, T_INT, 1); - def(ClassFile.ICONST_0, "iconst_0", "b", null, T_INT, 1); - def(ClassFile.ICONST_1, "iconst_1", "b", null, T_INT, 1); - def(ClassFile.ICONST_2, "iconst_2", "b", null, T_INT, 1); - def(ClassFile.ICONST_3, "iconst_3", "b", null, T_INT, 1); - def(ClassFile.ICONST_4, "iconst_4", "b", null, T_INT, 1); - def(ClassFile.ICONST_5, "iconst_5", "b", null, T_INT, 1); - def(ClassFile.LCONST_0, "lconst_0", "b", null, T_LONG, 2); - def(ClassFile.LCONST_1, "lconst_1", "b", null, T_LONG, 2); - def(ClassFile.FCONST_0, "fconst_0", "b", null, T_FLOAT, 1); - def(ClassFile.FCONST_1, "fconst_1", "b", null, T_FLOAT, 1); - def(ClassFile.FCONST_2, "fconst_2", "b", null, T_FLOAT, 1); - def(ClassFile.DCONST_0, "dconst_0", "b", null, T_DOUBLE, 2); - def(ClassFile.DCONST_1, "dconst_1", "b", null, T_DOUBLE, 2); - def(ClassFile.BIPUSH, "bipush", "bc", null, T_INT, 1); - def(ClassFile.SIPUSH, "sipush", "bcc", null, T_INT, 1); - def(ClassFile.LDC, "ldc", "bk", null, T_ILLEGAL, 1); - def(ClassFile.LDC_W, "ldc_w", "bkk", null, T_ILLEGAL, 1); - def(ClassFile.LDC2_W, "ldc2_w", "bkk", null, T_ILLEGAL, 2); - def(ClassFile.ILOAD, "iload", "bi", "wbii", T_INT, 1); - def(ClassFile.LLOAD, "lload", "bi", "wbii", T_LONG, 2); - def(ClassFile.FLOAD, "fload", "bi", "wbii", T_FLOAT, 1); - def(ClassFile.DLOAD, "dload", "bi", "wbii", T_DOUBLE, 2); - def(ClassFile.ALOAD, "aload", "bi", "wbii", T_OBJECT, 1); - def(ClassFile.ILOAD_0, "iload_0", "b", null, T_INT, 1); - def(ClassFile.ILOAD_1, "iload_1", "b", null, T_INT, 1); - def(ClassFile.ILOAD_2, "iload_2", "b", null, T_INT, 1); - def(ClassFile.ILOAD_3, "iload_3", "b", null, T_INT, 1); - def(ClassFile.LLOAD_0, "lload_0", "b", null, T_LONG, 2); - def(ClassFile.LLOAD_1, "lload_1", "b", null, T_LONG, 2); - def(ClassFile.LLOAD_2, "lload_2", "b", null, T_LONG, 2); - def(ClassFile.LLOAD_3, "lload_3", "b", null, T_LONG, 2); - def(ClassFile.FLOAD_0, "fload_0", "b", null, T_FLOAT, 1); - def(ClassFile.FLOAD_1, "fload_1", "b", null, T_FLOAT, 1); - def(ClassFile.FLOAD_2, "fload_2", "b", null, T_FLOAT, 1); - def(ClassFile.FLOAD_3, "fload_3", "b", null, T_FLOAT, 1); - def(ClassFile.DLOAD_0, "dload_0", "b", null, T_DOUBLE, 2); - def(ClassFile.DLOAD_1, "dload_1", "b", null, T_DOUBLE, 2); - def(ClassFile.DLOAD_2, "dload_2", "b", null, T_DOUBLE, 2); - def(ClassFile.DLOAD_3, "dload_3", "b", null, T_DOUBLE, 2); - def(ClassFile.ALOAD_0, "aload_0", "b", null, T_OBJECT, 1); - def(ClassFile.ALOAD_1, "aload_1", "b", null, T_OBJECT, 1); - def(ClassFile.ALOAD_2, "aload_2", "b", null, T_OBJECT, 1); - def(ClassFile.ALOAD_3, "aload_3", "b", null, T_OBJECT, 1); - def(ClassFile.IALOAD, "iaload", "b", null, T_INT, -1); - def(ClassFile.LALOAD, "laload", "b", null, T_LONG, 0); - def(ClassFile.FALOAD, "faload", "b", null, T_FLOAT, -1); - def(ClassFile.DALOAD, "daload", "b", null, T_DOUBLE, 0); - def(ClassFile.AALOAD, "aaload", "b", null, T_OBJECT, -1); - def(ClassFile.BALOAD, "baload", "b", null, T_INT, -1); - def(ClassFile.CALOAD, "caload", "b", null, T_INT, -1); - def(ClassFile.SALOAD, "saload", "b", null, T_INT, -1); - def(ClassFile.ISTORE, "istore", "bi", "wbii", T_VOID, -1); - def(ClassFile.LSTORE, "lstore", "bi", "wbii", T_VOID, -2); - def(ClassFile.FSTORE, "fstore", "bi", "wbii", T_VOID, -1); - def(ClassFile.DSTORE, "dstore", "bi", "wbii", T_VOID, -2); - def(ClassFile.ASTORE, "astore", "bi", "wbii", T_VOID, -1); - def(ClassFile.ISTORE_0, "istore_0", "b", null, T_VOID, -1); - def(ClassFile.ISTORE_1, "istore_1", "b", null, T_VOID, -1); - def(ClassFile.ISTORE_2, "istore_2", "b", null, T_VOID, -1); - def(ClassFile.ISTORE_3, "istore_3", "b", null, T_VOID, -1); - def(ClassFile.LSTORE_0, "lstore_0", "b", null, T_VOID, -2); - def(ClassFile.LSTORE_1, "lstore_1", "b", null, T_VOID, -2); - def(ClassFile.LSTORE_2, "lstore_2", "b", null, T_VOID, -2); - def(ClassFile.LSTORE_3, "lstore_3", "b", null, T_VOID, -2); - def(ClassFile.FSTORE_0, "fstore_0", "b", null, T_VOID, -1); - def(ClassFile.FSTORE_1, "fstore_1", "b", null, T_VOID, -1); - def(ClassFile.FSTORE_2, "fstore_2", "b", null, T_VOID, -1); - def(ClassFile.FSTORE_3, "fstore_3", "b", null, T_VOID, -1); - def(ClassFile.DSTORE_0, "dstore_0", "b", null, T_VOID, -2); - def(ClassFile.DSTORE_1, "dstore_1", "b", null, T_VOID, -2); - def(ClassFile.DSTORE_2, "dstore_2", "b", null, T_VOID, -2); - def(ClassFile.DSTORE_3, "dstore_3", "b", null, T_VOID, -2); - def(ClassFile.ASTORE_0, "astore_0", "b", null, T_VOID, -1); - def(ClassFile.ASTORE_1, "astore_1", "b", null, T_VOID, -1); - def(ClassFile.ASTORE_2, "astore_2", "b", null, T_VOID, -1); - def(ClassFile.ASTORE_3, "astore_3", "b", null, T_VOID, -1); - def(ClassFile.IASTORE, "iastore", "b", null, T_VOID, -3); - def(ClassFile.LASTORE, "lastore", "b", null, T_VOID, -4); - def(ClassFile.FASTORE, "fastore", "b", null, T_VOID, -3); - def(ClassFile.DASTORE, "dastore", "b", null, T_VOID, -4); - def(ClassFile.AASTORE, "aastore", "b", null, T_VOID, -3); - def(ClassFile.BASTORE, "bastore", "b", null, T_VOID, -3); - def(ClassFile.CASTORE, "castore", "b", null, T_VOID, -3); - def(ClassFile.SASTORE, "sastore", "b", null, T_VOID, -3); - def(ClassFile.POP, "pop", "b", null, T_VOID, -1); - def(ClassFile.POP2, "pop2", "b", null, T_VOID, -2); - def(ClassFile.DUP, "dup", "b", null, T_VOID, 1); - def(ClassFile.DUP_X1, "dup_x1", "b", null, T_VOID, 1); - def(ClassFile.DUP_X2, "dup_x2", "b", null, T_VOID, 1); - def(ClassFile.DUP2, "dup2", "b", null, T_VOID, 2); - def(ClassFile.DUP2_X1, "dup2_x1", "b", null, T_VOID, 2); - def(ClassFile.DUP2_X2, "dup2_x2", "b", null, T_VOID, 2); - def(ClassFile.SWAP, "swap", "b", null, T_VOID, 0); - def(ClassFile.IADD, "iadd", "b", null, T_INT, -1); - def(ClassFile.LADD, "ladd", "b", null, T_LONG, -2); - def(ClassFile.FADD, "fadd", "b", null, T_FLOAT, -1); - def(ClassFile.DADD, "dadd", "b", null, T_DOUBLE, -2); - def(ClassFile.ISUB, "isub", "b", null, T_INT, -1); - def(ClassFile.LSUB, "lsub", "b", null, T_LONG, -2); - def(ClassFile.FSUB, "fsub", "b", null, T_FLOAT, -1); - def(ClassFile.DSUB, "dsub", "b", null, T_DOUBLE, -2); - def(ClassFile.IMUL, "imul", "b", null, T_INT, -1); - def(ClassFile.LMUL, "lmul", "b", null, T_LONG, -2); - def(ClassFile.FMUL, "fmul", "b", null, T_FLOAT, -1); - def(ClassFile.DMUL, "dmul", "b", null, T_DOUBLE, -2); - def(ClassFile.IDIV, "idiv", "b", null, T_INT, -1); - def(ClassFile.LDIV, "ldiv", "b", null, T_LONG, -2); - def(ClassFile.FDIV, "fdiv", "b", null, T_FLOAT, -1); - def(ClassFile.DDIV, "ddiv", "b", null, T_DOUBLE, -2); - def(ClassFile.IREM, "irem", "b", null, T_INT, -1); - def(ClassFile.LREM, "lrem", "b", null, T_LONG, -2); - def(ClassFile.FREM, "frem", "b", null, T_FLOAT, -1); - def(ClassFile.DREM, "drem", "b", null, T_DOUBLE, -2); - def(ClassFile.INEG, "ineg", "b", null, T_INT, 0); - def(ClassFile.LNEG, "lneg", "b", null, T_LONG, 0); - def(ClassFile.FNEG, "fneg", "b", null, T_FLOAT, 0); - def(ClassFile.DNEG, "dneg", "b", null, T_DOUBLE, 0); - def(ClassFile.ISHL, "ishl", "b", null, T_INT, -1); - def(ClassFile.LSHL, "lshl", "b", null, T_LONG, -1); - def(ClassFile.ISHR, "ishr", "b", null, T_INT, -1); - def(ClassFile.LSHR, "lshr", "b", null, T_LONG, -1); - def(ClassFile.IUSHR, "iushr", "b", null, T_INT, -1); - def(ClassFile.LUSHR, "lushr", "b", null, T_LONG, -1); - def(ClassFile.IAND, "iand", "b", null, T_INT, -1); - def(ClassFile.LAND, "land", "b", null, T_LONG, -2); - def(ClassFile.IOR, "ior", "b", null, T_INT, -1); - def(ClassFile.LOR, "lor", "b", null, T_LONG, -2); - def(ClassFile.IXOR, "ixor", "b", null, T_INT, -1); - def(ClassFile.LXOR, "lxor", "b", null, T_LONG, -2); - def(ClassFile.IINC, "iinc", "bic", "wbiicc", T_VOID, 0); - def(ClassFile.I2L, "i2l", "b", null, T_LONG, 1); - def(ClassFile.I2F, "i2f", "b", null, T_FLOAT, 0); - def(ClassFile.I2D, "i2d", "b", null, T_DOUBLE, 1); - def(ClassFile.L2I, "l2i", "b", null, T_INT, -1); - def(ClassFile.L2F, "l2f", "b", null, T_FLOAT, -1); - def(ClassFile.L2D, "l2d", "b", null, T_DOUBLE, 0); - def(ClassFile.F2I, "f2i", "b", null, T_INT, 0); - def(ClassFile.F2L, "f2l", "b", null, T_LONG, 1); - def(ClassFile.F2D, "f2d", "b", null, T_DOUBLE, 1); - def(ClassFile.D2I, "d2i", "b", null, T_INT, -1); - def(ClassFile.D2L, "d2l", "b", null, T_LONG, 0); - def(ClassFile.D2F, "d2f", "b", null, T_FLOAT, -1); - def(ClassFile.I2B, "i2b", "b", null, T_BYTE, 0); - def(ClassFile.I2C, "i2c", "b", null, T_CHAR, 0); - def(ClassFile.I2S, "i2s", "b", null, T_SHORT, 0); - def(ClassFile.LCMP, "lcmp", "b", null, T_VOID, -3); - def(ClassFile.FCMPL, "fcmpl", "b", null, T_VOID, -1); - def(ClassFile.FCMPG, "fcmpg", "b", null, T_VOID, -1); - def(ClassFile.DCMPL, "dcmpl", "b", null, T_VOID, -3); - def(ClassFile.DCMPG, "dcmpg", "b", null, T_VOID, -3); - def(ClassFile.IFEQ, "ifeq", "boo", null, T_VOID, -1); - def(ClassFile.IFNE, "ifne", "boo", null, T_VOID, -1); - def(ClassFile.IFLT, "iflt", "boo", null, T_VOID, -1); - def(ClassFile.IFGE, "ifge", "boo", null, T_VOID, -1); - def(ClassFile.IFGT, "ifgt", "boo", null, T_VOID, -1); - def(ClassFile.IFLE, "ifle", "boo", null, T_VOID, -1); - def(ClassFile.IF_ICMPEQ, "if_icmpeq", "boo", null, T_VOID, -2); - def(ClassFile.IF_ICMPNE, "if_icmpne", "boo", null, T_VOID, -2); - def(ClassFile.IF_ICMPLT, "if_icmplt", "boo", null, T_VOID, -2); - def(ClassFile.IF_ICMPGE, "if_icmpge", "boo", null, T_VOID, -2); - def(ClassFile.IF_ICMPGT, "if_icmpgt", "boo", null, T_VOID, -2); - def(ClassFile.IF_ICMPLE, "if_icmple", "boo", null, T_VOID, -2); - def(ClassFile.IF_ACMPEQ, "if_acmpeq", "boo", null, T_VOID, -2); - def(ClassFile.IF_ACMPNE, "if_acmpne", "boo", null, T_VOID, -2); - def(ClassFile.GOTO, "goto", "boo", null, T_VOID, 0); - def(ClassFile.JSR, "jsr", "boo", null, T_INT, 0); - def(ClassFile.RET, "ret", "bi", "wbii", T_VOID, 0); - def(ClassFile.TABLESWITCH, "tableswitch", "", null, T_VOID, -1); // may have backward branches - def(ClassFile.LOOKUPSWITCH, "lookupswitch", "", null, T_VOID, -1); // rewriting in interpreter - def(ClassFile.IRETURN, "ireturn", "b", null, T_INT, -1); - def(ClassFile.LRETURN, "lreturn", "b", null, T_LONG, -2); - def(ClassFile.FRETURN, "freturn", "b", null, T_FLOAT, -1); - def(ClassFile.DRETURN, "dreturn", "b", null, T_DOUBLE, -2); - def(ClassFile.ARETURN, "areturn", "b", null, T_OBJECT, -1); - def(ClassFile.RETURN, "return", "b", null, T_VOID, 0); - def(ClassFile.GETSTATIC, "getstatic", "bJJ", null, T_ILLEGAL, 1); - def(ClassFile.PUTSTATIC, "putstatic", "bJJ", null, T_ILLEGAL, -1); - def(ClassFile.GETFIELD, "getfield", "bJJ", null, T_ILLEGAL, 0); - def(ClassFile.PUTFIELD, "putfield", "bJJ", null, T_ILLEGAL, -2); - def(ClassFile.INVOKEVIRTUAL, "invokevirtual", "bJJ", null, T_ILLEGAL, -1); - def(ClassFile.INVOKESPECIAL, "invokespecial", "bJJ", null, T_ILLEGAL, -1); - def(ClassFile.INVOKESTATIC, "invokestatic", "bJJ", null, T_ILLEGAL, 0); - def(ClassFile.INVOKEINTERFACE, "invokeinterface", "bJJ__", null, T_ILLEGAL, -1); - def(ClassFile.INVOKEDYNAMIC, "invokedynamic", "bJJJJ", null, T_ILLEGAL, 0); - def(ClassFile.NEW, "new", "bkk", null, T_OBJECT, 1); - def(ClassFile.NEWARRAY, "newarray", "bc", null, T_OBJECT, 0); - def(ClassFile.ANEWARRAY, "anewarray", "bkk", null, T_OBJECT, 0); - def(ClassFile.ARRAYLENGTH, "arraylength", "b", null, T_VOID, 0); - def(ClassFile.ATHROW, "athrow", "b", null, T_VOID, -1); - def(ClassFile.CHECKCAST, "checkcast", "bkk", null, T_OBJECT, 0); - def(ClassFile.INSTANCEOF, "instanceof", "bkk", null, T_INT, 0); - def(ClassFile.MONITORENTER, "monitorenter", "b", null, T_VOID, -1); - def(ClassFile.MONITOREXIT, "monitorexit", "b", null, T_VOID, -1); - def(ClassFile.WIDE, "wide", "", null, T_VOID, 0); - def(ClassFile.MULTIANEWARRAY, "multianewarray", "bkkc", null, T_OBJECT, 1); - def(ClassFile.IFNULL, "ifnull", "boo", null, T_VOID, -1); - def(ClassFile.IFNONNULL, "ifnonnull", "boo", null, T_VOID, -1); - def(ClassFile.GOTO_W, "goto_w", "boooo", null, T_VOID, 0); - def(ClassFile.JSR_W, "jsr_w", "boooo", null, T_INT, 0); + def(NOP, "nop", "b", null, T_VOID, 0); + def(ACONST_NULL, "aconst_null", "b", null, T_OBJECT, 1); + def(ICONST_M1, "iconst_m1", "b", null, T_INT, 1); + def(ICONST_0, "iconst_0", "b", null, T_INT, 1); + def(ICONST_1, "iconst_1", "b", null, T_INT, 1); + def(ICONST_2, "iconst_2", "b", null, T_INT, 1); + def(ICONST_3, "iconst_3", "b", null, T_INT, 1); + def(ICONST_4, "iconst_4", "b", null, T_INT, 1); + def(ICONST_5, "iconst_5", "b", null, T_INT, 1); + def(LCONST_0, "lconst_0", "b", null, T_LONG, 2); + def(LCONST_1, "lconst_1", "b", null, T_LONG, 2); + def(FCONST_0, "fconst_0", "b", null, T_FLOAT, 1); + def(FCONST_1, "fconst_1", "b", null, T_FLOAT, 1); + def(FCONST_2, "fconst_2", "b", null, T_FLOAT, 1); + def(DCONST_0, "dconst_0", "b", null, T_DOUBLE, 2); + def(DCONST_1, "dconst_1", "b", null, T_DOUBLE, 2); + def(BIPUSH, "bipush", "bc", null, T_INT, 1); + def(SIPUSH, "sipush", "bcc", null, T_INT, 1); + def(LDC, "ldc", "bk", null, T_ILLEGAL, 1); + def(LDC_W, "ldc_w", "bkk", null, T_ILLEGAL, 1); + def(LDC2_W, "ldc2_w", "bkk", null, T_ILLEGAL, 2); + def(ILOAD, "iload", "bi", "wbii", T_INT, 1); + def(LLOAD, "lload", "bi", "wbii", T_LONG, 2); + def(FLOAD, "fload", "bi", "wbii", T_FLOAT, 1); + def(DLOAD, "dload", "bi", "wbii", T_DOUBLE, 2); + def(ALOAD, "aload", "bi", "wbii", T_OBJECT, 1); + def(ILOAD_0, "iload_0", "b", null, T_INT, 1); + def(ILOAD_1, "iload_1", "b", null, T_INT, 1); + def(ILOAD_2, "iload_2", "b", null, T_INT, 1); + def(ILOAD_3, "iload_3", "b", null, T_INT, 1); + def(LLOAD_0, "lload_0", "b", null, T_LONG, 2); + def(LLOAD_1, "lload_1", "b", null, T_LONG, 2); + def(LLOAD_2, "lload_2", "b", null, T_LONG, 2); + def(LLOAD_3, "lload_3", "b", null, T_LONG, 2); + def(FLOAD_0, "fload_0", "b", null, T_FLOAT, 1); + def(FLOAD_1, "fload_1", "b", null, T_FLOAT, 1); + def(FLOAD_2, "fload_2", "b", null, T_FLOAT, 1); + def(FLOAD_3, "fload_3", "b", null, T_FLOAT, 1); + def(DLOAD_0, "dload_0", "b", null, T_DOUBLE, 2); + def(DLOAD_1, "dload_1", "b", null, T_DOUBLE, 2); + def(DLOAD_2, "dload_2", "b", null, T_DOUBLE, 2); + def(DLOAD_3, "dload_3", "b", null, T_DOUBLE, 2); + def(ALOAD_0, "aload_0", "b", null, T_OBJECT, 1); + def(ALOAD_1, "aload_1", "b", null, T_OBJECT, 1); + def(ALOAD_2, "aload_2", "b", null, T_OBJECT, 1); + def(ALOAD_3, "aload_3", "b", null, T_OBJECT, 1); + def(IALOAD, "iaload", "b", null, T_INT, -1); + def(LALOAD, "laload", "b", null, T_LONG, 0); + def(FALOAD, "faload", "b", null, T_FLOAT, -1); + def(DALOAD, "daload", "b", null, T_DOUBLE, 0); + def(AALOAD, "aaload", "b", null, T_OBJECT, -1); + def(BALOAD, "baload", "b", null, T_INT, -1); + def(CALOAD, "caload", "b", null, T_INT, -1); + def(SALOAD, "saload", "b", null, T_INT, -1); + def(ISTORE, "istore", "bi", "wbii", T_VOID, -1); + def(LSTORE, "lstore", "bi", "wbii", T_VOID, -2); + def(FSTORE, "fstore", "bi", "wbii", T_VOID, -1); + def(DSTORE, "dstore", "bi", "wbii", T_VOID, -2); + def(ASTORE, "astore", "bi", "wbii", T_VOID, -1); + def(ISTORE_0, "istore_0", "b", null, T_VOID, -1); + def(ISTORE_1, "istore_1", "b", null, T_VOID, -1); + def(ISTORE_2, "istore_2", "b", null, T_VOID, -1); + def(ISTORE_3, "istore_3", "b", null, T_VOID, -1); + def(LSTORE_0, "lstore_0", "b", null, T_VOID, -2); + def(LSTORE_1, "lstore_1", "b", null, T_VOID, -2); + def(LSTORE_2, "lstore_2", "b", null, T_VOID, -2); + def(LSTORE_3, "lstore_3", "b", null, T_VOID, -2); + def(FSTORE_0, "fstore_0", "b", null, T_VOID, -1); + def(FSTORE_1, "fstore_1", "b", null, T_VOID, -1); + def(FSTORE_2, "fstore_2", "b", null, T_VOID, -1); + def(FSTORE_3, "fstore_3", "b", null, T_VOID, -1); + def(DSTORE_0, "dstore_0", "b", null, T_VOID, -2); + def(DSTORE_1, "dstore_1", "b", null, T_VOID, -2); + def(DSTORE_2, "dstore_2", "b", null, T_VOID, -2); + def(DSTORE_3, "dstore_3", "b", null, T_VOID, -2); + def(ASTORE_0, "astore_0", "b", null, T_VOID, -1); + def(ASTORE_1, "astore_1", "b", null, T_VOID, -1); + def(ASTORE_2, "astore_2", "b", null, T_VOID, -1); + def(ASTORE_3, "astore_3", "b", null, T_VOID, -1); + def(IASTORE, "iastore", "b", null, T_VOID, -3); + def(LASTORE, "lastore", "b", null, T_VOID, -4); + def(FASTORE, "fastore", "b", null, T_VOID, -3); + def(DASTORE, "dastore", "b", null, T_VOID, -4); + def(AASTORE, "aastore", "b", null, T_VOID, -3); + def(BASTORE, "bastore", "b", null, T_VOID, -3); + def(CASTORE, "castore", "b", null, T_VOID, -3); + def(SASTORE, "sastore", "b", null, T_VOID, -3); + def(POP, "pop", "b", null, T_VOID, -1); + def(POP2, "pop2", "b", null, T_VOID, -2); + def(DUP, "dup", "b", null, T_VOID, 1); + def(DUP_X1, "dup_x1", "b", null, T_VOID, 1); + def(DUP_X2, "dup_x2", "b", null, T_VOID, 1); + def(DUP2, "dup2", "b", null, T_VOID, 2); + def(DUP2_X1, "dup2_x1", "b", null, T_VOID, 2); + def(DUP2_X2, "dup2_x2", "b", null, T_VOID, 2); + def(SWAP, "swap", "b", null, T_VOID, 0); + def(IADD, "iadd", "b", null, T_INT, -1); + def(LADD, "ladd", "b", null, T_LONG, -2); + def(FADD, "fadd", "b", null, T_FLOAT, -1); + def(DADD, "dadd", "b", null, T_DOUBLE, -2); + def(ISUB, "isub", "b", null, T_INT, -1); + def(LSUB, "lsub", "b", null, T_LONG, -2); + def(FSUB, "fsub", "b", null, T_FLOAT, -1); + def(DSUB, "dsub", "b", null, T_DOUBLE, -2); + def(IMUL, "imul", "b", null, T_INT, -1); + def(LMUL, "lmul", "b", null, T_LONG, -2); + def(FMUL, "fmul", "b", null, T_FLOAT, -1); + def(DMUL, "dmul", "b", null, T_DOUBLE, -2); + def(IDIV, "idiv", "b", null, T_INT, -1); + def(LDIV, "ldiv", "b", null, T_LONG, -2); + def(FDIV, "fdiv", "b", null, T_FLOAT, -1); + def(DDIV, "ddiv", "b", null, T_DOUBLE, -2); + def(IREM, "irem", "b", null, T_INT, -1); + def(LREM, "lrem", "b", null, T_LONG, -2); + def(FREM, "frem", "b", null, T_FLOAT, -1); + def(DREM, "drem", "b", null, T_DOUBLE, -2); + def(INEG, "ineg", "b", null, T_INT, 0); + def(LNEG, "lneg", "b", null, T_LONG, 0); + def(FNEG, "fneg", "b", null, T_FLOAT, 0); + def(DNEG, "dneg", "b", null, T_DOUBLE, 0); + def(ISHL, "ishl", "b", null, T_INT, -1); + def(LSHL, "lshl", "b", null, T_LONG, -1); + def(ISHR, "ishr", "b", null, T_INT, -1); + def(LSHR, "lshr", "b", null, T_LONG, -1); + def(IUSHR, "iushr", "b", null, T_INT, -1); + def(LUSHR, "lushr", "b", null, T_LONG, -1); + def(IAND, "iand", "b", null, T_INT, -1); + def(LAND, "land", "b", null, T_LONG, -2); + def(IOR, "ior", "b", null, T_INT, -1); + def(LOR, "lor", "b", null, T_LONG, -2); + def(IXOR, "ixor", "b", null, T_INT, -1); + def(LXOR, "lxor", "b", null, T_LONG, -2); + def(IINC, "iinc", "bic", "wbiicc", T_VOID, 0); + def(I2L, "i2l", "b", null, T_LONG, 1); + def(I2F, "i2f", "b", null, T_FLOAT, 0); + def(I2D, "i2d", "b", null, T_DOUBLE, 1); + def(L2I, "l2i", "b", null, T_INT, -1); + def(L2F, "l2f", "b", null, T_FLOAT, -1); + def(L2D, "l2d", "b", null, T_DOUBLE, 0); + def(F2I, "f2i", "b", null, T_INT, 0); + def(F2L, "f2l", "b", null, T_LONG, 1); + def(F2D, "f2d", "b", null, T_DOUBLE, 1); + def(D2I, "d2i", "b", null, T_INT, -1); + def(D2L, "d2l", "b", null, T_LONG, 0); + def(D2F, "d2f", "b", null, T_FLOAT, -1); + def(I2B, "i2b", "b", null, T_BYTE, 0); + def(I2C, "i2c", "b", null, T_CHAR, 0); + def(I2S, "i2s", "b", null, T_SHORT, 0); + def(LCMP, "lcmp", "b", null, T_VOID, -3); + def(FCMPL, "fcmpl", "b", null, T_VOID, -1); + def(FCMPG, "fcmpg", "b", null, T_VOID, -1); + def(DCMPL, "dcmpl", "b", null, T_VOID, -3); + def(DCMPG, "dcmpg", "b", null, T_VOID, -3); + def(IFEQ, "ifeq", "boo", null, T_VOID, -1); + def(IFNE, "ifne", "boo", null, T_VOID, -1); + def(IFLT, "iflt", "boo", null, T_VOID, -1); + def(IFGE, "ifge", "boo", null, T_VOID, -1); + def(IFGT, "ifgt", "boo", null, T_VOID, -1); + def(IFLE, "ifle", "boo", null, T_VOID, -1); + def(IF_ICMPEQ, "if_icmpeq", "boo", null, T_VOID, -2); + def(IF_ICMPNE, "if_icmpne", "boo", null, T_VOID, -2); + def(IF_ICMPLT, "if_icmplt", "boo", null, T_VOID, -2); + def(IF_ICMPGE, "if_icmpge", "boo", null, T_VOID, -2); + def(IF_ICMPGT, "if_icmpgt", "boo", null, T_VOID, -2); + def(IF_ICMPLE, "if_icmple", "boo", null, T_VOID, -2); + def(IF_ACMPEQ, "if_acmpeq", "boo", null, T_VOID, -2); + def(IF_ACMPNE, "if_acmpne", "boo", null, T_VOID, -2); + def(GOTO, "goto", "boo", null, T_VOID, 0); + def(JSR, "jsr", "boo", null, T_INT, 0); + def(RET, "ret", "bi", "wbii", T_VOID, 0); + def(TABLESWITCH, "tableswitch", "", null, T_VOID, -1); // may have backward branches + def(LOOKUPSWITCH, "lookupswitch", "", null, T_VOID, -1); // rewriting in interpreter + def(IRETURN, "ireturn", "b", null, T_INT, -1); + def(LRETURN, "lreturn", "b", null, T_LONG, -2); + def(FRETURN, "freturn", "b", null, T_FLOAT, -1); + def(DRETURN, "dreturn", "b", null, T_DOUBLE, -2); + def(ARETURN, "areturn", "b", null, T_OBJECT, -1); + def(RETURN, "return", "b", null, T_VOID, 0); + def(GETSTATIC, "getstatic", "bJJ", null, T_ILLEGAL, 1); + def(PUTSTATIC, "putstatic", "bJJ", null, T_ILLEGAL, -1); + def(GETFIELD, "getfield", "bJJ", null, T_ILLEGAL, 0); + def(PUTFIELD, "putfield", "bJJ", null, T_ILLEGAL, -2); + def(INVOKEVIRTUAL, "invokevirtual", "bJJ", null, T_ILLEGAL, -1); + def(INVOKESPECIAL, "invokespecial", "bJJ", null, T_ILLEGAL, -1); + def(INVOKESTATIC, "invokestatic", "bJJ", null, T_ILLEGAL, 0); + def(INVOKEINTERFACE, "invokeinterface", "bJJ__", null, T_ILLEGAL, -1); + def(INVOKEDYNAMIC, "invokedynamic", "bJJJJ", null, T_ILLEGAL, 0); + def(NEW, "new", "bkk", null, T_OBJECT, 1); + def(NEWARRAY, "newarray", "bc", null, T_OBJECT, 0); + def(ANEWARRAY, "anewarray", "bkk", null, T_OBJECT, 0); + def(ARRAYLENGTH, "arraylength", "b", null, T_VOID, 0); + def(ATHROW, "athrow", "b", null, T_VOID, -1); + def(CHECKCAST, "checkcast", "bkk", null, T_OBJECT, 0); + def(INSTANCEOF, "instanceof", "bkk", null, T_INT, 0); + def(MONITORENTER, "monitorenter", "b", null, T_VOID, -1); + def(MONITOREXIT, "monitorexit", "b", null, T_VOID, -1); + def(WIDE, "wide", "", null, T_VOID, 0); + def(MULTIANEWARRAY, "multianewarray", "bkkc", null, T_OBJECT, 1); + def(IFNULL, "ifnull", "boo", null, T_VOID, -1); + def(IFNONNULL, "ifnonnull", "boo", null, T_VOID, -1); + def(GOTO_W, "goto_w", "boooo", null, T_VOID, 0); + def(JSR_W, "jsr_w", "boooo", null, T_INT, 0); def(_breakpoint, "breakpoint", "", null, T_VOID, 0); - def(_fast_agetfield, "fast_agetfield", "bJJ", null, T_OBJECT, 0, ClassFile.GETFIELD); - def(_fast_bgetfield, "fast_bgetfield", "bJJ", null, T_INT, 0, ClassFile.GETFIELD); - def(_fast_cgetfield, "fast_cgetfield", "bJJ", null, T_CHAR, 0, ClassFile.GETFIELD); - def(_fast_dgetfield, "fast_dgetfield", "bJJ", null, T_DOUBLE, 0, ClassFile.GETFIELD); - def(_fast_fgetfield, "fast_fgetfield", "bJJ", null, T_FLOAT, 0, ClassFile.GETFIELD); - def(_fast_igetfield, "fast_igetfield", "bJJ", null, T_INT, 0, ClassFile.GETFIELD); - def(_fast_lgetfield, "fast_lgetfield", "bJJ", null, T_LONG, 0, ClassFile.GETFIELD); - def(_fast_sgetfield, "fast_sgetfield", "bJJ", null, T_SHORT, 0, ClassFile.GETFIELD); - def(_fast_aputfield, "fast_aputfield", "bJJ", null, T_OBJECT, 0, ClassFile.PUTFIELD); - def(_fast_bputfield, "fast_bputfield", "bJJ", null, T_INT, 0, ClassFile.PUTFIELD); - def(_fast_zputfield, "fast_zputfield", "bJJ", null, T_INT, 0, ClassFile.PUTFIELD); - def(_fast_cputfield, "fast_cputfield", "bJJ", null, T_CHAR, 0, ClassFile.PUTFIELD); - def(_fast_dputfield, "fast_dputfield", "bJJ", null, T_DOUBLE, 0, ClassFile.PUTFIELD); - def(_fast_fputfield, "fast_fputfield", "bJJ", null, T_FLOAT, 0, ClassFile.PUTFIELD); - def(_fast_iputfield, "fast_iputfield", "bJJ", null, T_INT, 0, ClassFile.PUTFIELD); - def(_fast_lputfield, "fast_lputfield", "bJJ", null, T_LONG, 0, ClassFile.PUTFIELD); - def(_fast_sputfield, "fast_sputfield", "bJJ", null, T_SHORT, 0, ClassFile.PUTFIELD); - def(_fast_aload_0, "fast_aload_0", "b", null, T_OBJECT, 1, ClassFile.ALOAD_0); - def(_fast_iaccess_0, "fast_iaccess_0", "b_JJ", null, T_INT, 1, ClassFile.ALOAD_0); - def(_fast_aaccess_0, "fast_aaccess_0", "b_JJ", null, T_OBJECT, 1, ClassFile.ALOAD_0); - def(_fast_faccess_0, "fast_faccess_0", "b_JJ", null, T_OBJECT, 1, ClassFile.ALOAD_0); - def(_fast_iload, "fast_iload", "bi", null, T_INT, 1, ClassFile.ILOAD); - def(_fast_iload2, "fast_iload2", "bi_i", null, T_INT, 2, ClassFile.ILOAD); - def(_fast_icaload, "fast_icaload", "bi_", null, T_INT, 0, ClassFile.ILOAD); - def(_fast_invokevfinal, "fast_invokevfinal", "bJJ", null, T_ILLEGAL, -1, ClassFile.INVOKEVIRTUAL); - def(_fast_linearswitch, "fast_linearswitch", "", null, T_VOID, -1, ClassFile.LOOKUPSWITCH); - def(_fast_binaryswitch, "fast_binaryswitch", "", null, T_VOID, -1, ClassFile.LOOKUPSWITCH); - def(_return_register_finalizer, "return_register_finalizer", "b", null, T_VOID, 0, ClassFile.RETURN); - def(_invokehandle, "invokehandle", "bJJ", null, T_ILLEGAL, -1, ClassFile.INVOKEVIRTUAL); - def(_fast_aldc, "fast_aldc", "bj", null, T_OBJECT, 1, ClassFile.LDC); - def(_fast_aldc_w, "fast_aldc_w", "bJJ", null, T_OBJECT, 1, ClassFile.LDC_W); - def(_nofast_getfield, "nofast_getfield", "bJJ", null, T_ILLEGAL, 0, ClassFile.GETFIELD); - def(_nofast_putfield, "nofast PUTFIELD", "bJJ", null, T_ILLEGAL, -2, ClassFile.PUTFIELD); - def(_nofast_aload_0, "nofast_aload_0", "b", null, T_ILLEGAL, 1, ClassFile.ALOAD_0); - def(_nofast_iload, "nofast_iload", "bi", null, T_ILLEGAL, 1, ClassFile.ILOAD); + def(_fast_agetfield, "fast_agetfield", "bJJ", null, T_OBJECT, 0, GETFIELD); + def(_fast_bgetfield, "fast_bgetfield", "bJJ", null, T_INT, 0, GETFIELD); + def(_fast_cgetfield, "fast_cgetfield", "bJJ", null, T_CHAR, 0, GETFIELD); + def(_fast_dgetfield, "fast_dgetfield", "bJJ", null, T_DOUBLE, 0, GETFIELD); + def(_fast_fgetfield, "fast_fgetfield", "bJJ", null, T_FLOAT, 0, GETFIELD); + def(_fast_igetfield, "fast_igetfield", "bJJ", null, T_INT, 0, GETFIELD); + def(_fast_lgetfield, "fast_lgetfield", "bJJ", null, T_LONG, 0, GETFIELD); + def(_fast_sgetfield, "fast_sgetfield", "bJJ", null, T_SHORT, 0, GETFIELD); + def(_fast_aputfield, "fast_aputfield", "bJJ", null, T_OBJECT, 0, PUTFIELD); + def(_fast_bputfield, "fast_bputfield", "bJJ", null, T_INT, 0, PUTFIELD); + def(_fast_zputfield, "fast_zputfield", "bJJ", null, T_INT, 0, PUTFIELD); + def(_fast_cputfield, "fast_cputfield", "bJJ", null, T_CHAR, 0, PUTFIELD); + def(_fast_dputfield, "fast_dputfield", "bJJ", null, T_DOUBLE, 0, PUTFIELD); + def(_fast_fputfield, "fast_fputfield", "bJJ", null, T_FLOAT, 0, PUTFIELD); + def(_fast_iputfield, "fast_iputfield", "bJJ", null, T_INT, 0, PUTFIELD); + def(_fast_lputfield, "fast_lputfield", "bJJ", null, T_LONG, 0, PUTFIELD); + def(_fast_sputfield, "fast_sputfield", "bJJ", null, T_SHORT, 0, PUTFIELD); + def(_fast_aload_0, "fast_aload_0", "b", null, T_OBJECT, 1, ALOAD_0); + def(_fast_iaccess_0, "fast_iaccess_0", "b_JJ", null, T_INT, 1, ALOAD_0); + def(_fast_aaccess_0, "fast_aaccess_0", "b_JJ", null, T_OBJECT, 1, ALOAD_0); + def(_fast_faccess_0, "fast_faccess_0", "b_JJ", null, T_OBJECT, 1, ALOAD_0); + def(_fast_iload, "fast_iload", "bi", null, T_INT, 1, ILOAD); + def(_fast_iload2, "fast_iload2", "bi_i", null, T_INT, 2, ILOAD); + def(_fast_icaload, "fast_icaload", "bi_", null, T_INT, 0, ILOAD); + def(_fast_invokevfinal, "fast_invokevfinal", "bJJ", null, T_ILLEGAL, -1, INVOKEVIRTUAL); + def(_fast_linearswitch, "fast_linearswitch", "", null, T_VOID, -1, LOOKUPSWITCH); + def(_fast_binaryswitch, "fast_binaryswitch", "", null, T_VOID, -1, LOOKUPSWITCH); + def(_return_register_finalizer, "return_register_finalizer", "b", null, T_VOID, 0, RETURN); + def(_invokehandle, "invokehandle", "bJJ", null, T_ILLEGAL, -1, INVOKEVIRTUAL); + def(_fast_aldc, "fast_aldc", "bj", null, T_OBJECT, 1, LDC); + def(_fast_aldc_w, "fast_aldc_w", "bJJ", null, T_OBJECT, 1, LDC_W); + def(_nofast_getfield, "nofast_getfield", "bJJ", null, T_ILLEGAL, 0, GETFIELD); + def(_nofast_putfield, "nofast PUTFIELD", "bJJ", null, T_ILLEGAL, -2, PUTFIELD); + def(_nofast_aload_0, "nofast_aload_0", "b", null, T_ILLEGAL, 1, ALOAD_0); + def(_nofast_iload, "nofast_iload", "bi", null, T_ILLEGAL, 1, ILOAD); def(_shouldnotreachhere, "_shouldnotreachhere", "b", null, T_VOID, 0); } } diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/verifier/VerifierImpl.java b/src/java.base/share/classes/jdk/internal/classfile/impl/verifier/VerifierImpl.java index 74cdb881a74..f41647788a1 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/impl/verifier/VerifierImpl.java +++ b/src/java.base/share/classes/jdk/internal/classfile/impl/verifier/VerifierImpl.java @@ -24,7 +24,6 @@ */ package jdk.internal.classfile.impl.verifier; -import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -32,10 +31,9 @@ import java.util.function.Consumer; import java.lang.classfile.ClassHierarchyResolver; import java.lang.classfile.ClassModel; import java.lang.classfile.components.ClassPrinter; -import java.lang.classfile.ClassFile; import jdk.internal.classfile.impl.ClassHierarchyImpl; import jdk.internal.classfile.impl.RawBytecodeHelper; -import static jdk.internal.classfile.impl.RawBytecodeHelper.ILLEGAL; +import static jdk.internal.classfile.impl.RawBytecodeHelper.*; import jdk.internal.classfile.impl.verifier.VerificationWrapper.ConstantPoolWrapper; import static jdk.internal.classfile.impl.verifier.VerificationSignature.BasicType.*; import jdk.internal.classfile.impl.verifier.VerificationSignature.BasicType; @@ -316,20 +314,20 @@ public final class VerifierImpl { if (code_length < 1 || code_length > MAX_CODE_SIZE) { verifyError(String.format("Invalid method Code length %d", code_length)); } - var code = ByteBuffer.wrap(codeArray, 0, _method.codeLength()); - byte[] code_data = generate_code_data(code, code_length); + var code = RawBytecodeHelper.of(codeArray); + byte[] code_data = generate_code_data(code); int ex_minmax[] = new int[] {code_length, -1}; verify_exception_handler_table(code_length, code_data, ex_minmax); verify_local_variable_table(code_length, code_data); VerificationTable stackmap_table = new VerificationTable(stackmap_data, current_frame, max_locals, max_stack, code_data, code_length, cp, this); - var bcs = new RawBytecodeHelper(code); + var bcs = code.start(); boolean no_control_flow = false; int opcode; - while (!bcs.isLastBytecode()) { - opcode = bcs.rawNext(); - bci = bcs.bci; + while (bcs.next()) { + opcode = bcs.opcode(); + bci = bcs.bci(); current_frame.set_offset(bci); current_frame.set_mark(); stackmap_index = verify_stackmap_table(stackmap_index, bci, current_frame, stackmap_table, no_control_flow); @@ -340,13 +338,13 @@ public final class VerifierImpl { int target; VerificationType type, type2 = null; VerificationType atype; - if (bcs.isWide) { - if (opcode != ClassFile.IINC && opcode != ClassFile.ILOAD - && opcode != ClassFile.ALOAD && opcode != ClassFile.LLOAD - && opcode != ClassFile.ISTORE && opcode != ClassFile.ASTORE - && opcode != ClassFile.LSTORE && opcode != ClassFile.FLOAD - && opcode != ClassFile.DLOAD && opcode != ClassFile.FSTORE - && opcode != ClassFile.DSTORE) { + if (bcs.isWide()) { + if (opcode != IINC && opcode != ILOAD + && opcode != ALOAD && opcode != LLOAD + && opcode != ISTORE && opcode != ASTORE + && opcode != LSTORE && opcode != FLOAD + && opcode != DLOAD && opcode != FSTORE + && opcode != DSTORE) { verifyError("Bad wide instruction"); } } @@ -355,107 +353,107 @@ public final class VerifierImpl { verified_exc_handlers = true; } switch (opcode) { - case ClassFile.NOP : + case NOP : no_control_flow = false; break; - case ClassFile.ACONST_NULL : + case ACONST_NULL : current_frame.push_stack( VerificationType.null_type); no_control_flow = false; break; - case ClassFile.ICONST_M1 : - case ClassFile.ICONST_0 : - case ClassFile.ICONST_1 : - case ClassFile.ICONST_2 : - case ClassFile.ICONST_3 : - case ClassFile.ICONST_4 : - case ClassFile.ICONST_5 : + case ICONST_M1 : + case ICONST_0 : + case ICONST_1 : + case ICONST_2 : + case ICONST_3 : + case ICONST_4 : + case ICONST_5 : current_frame.push_stack( VerificationType.integer_type); no_control_flow = false; break; - case ClassFile.LCONST_0 : - case ClassFile.LCONST_1 : + case LCONST_0 : + case LCONST_1 : current_frame.push_stack_2( VerificationType.long_type, VerificationType.long2_type); no_control_flow = false; break; - case ClassFile.FCONST_0 : - case ClassFile.FCONST_1 : - case ClassFile.FCONST_2 : + case FCONST_0 : + case FCONST_1 : + case FCONST_2 : current_frame.push_stack( VerificationType.float_type); no_control_flow = false; break; - case ClassFile.DCONST_0 : - case ClassFile.DCONST_1 : + case DCONST_0 : + case DCONST_1 : current_frame.push_stack_2( VerificationType.double_type, VerificationType.double2_type); no_control_flow = false; break; - case ClassFile.SIPUSH : - case ClassFile.BIPUSH : + case SIPUSH : + case BIPUSH : current_frame.push_stack( VerificationType.integer_type); no_control_flow = false; break; - case ClassFile.LDC : + case LDC : verify_ldc( opcode, bcs.getIndexU1(), current_frame, cp, bci); no_control_flow = false; break; - case ClassFile.LDC_W : - case ClassFile.LDC2_W : + case LDC_W : + case LDC2_W : verify_ldc( opcode, bcs.getIndexU2(), current_frame, cp, bci); no_control_flow = false; break; - case ClassFile.ILOAD : + case ILOAD : verify_iload(bcs.getIndex(), current_frame); no_control_flow = false; break; - case ClassFile.ILOAD_0 : - case ClassFile.ILOAD_1 : - case ClassFile.ILOAD_2 : - case ClassFile.ILOAD_3 : - index = opcode - ClassFile.ILOAD_0; + case ILOAD_0 : + case ILOAD_1 : + case ILOAD_2 : + case ILOAD_3 : + index = opcode - ILOAD_0; verify_iload(index, current_frame); no_control_flow = false; break; - case ClassFile.LLOAD : + case LLOAD : verify_lload(bcs.getIndex(), current_frame); no_control_flow = false; break; - case ClassFile.LLOAD_0 : - case ClassFile.LLOAD_1 : - case ClassFile.LLOAD_2 : - case ClassFile.LLOAD_3 : - index = opcode - ClassFile.LLOAD_0; + case LLOAD_0 : + case LLOAD_1 : + case LLOAD_2 : + case LLOAD_3 : + index = opcode - LLOAD_0; verify_lload(index, current_frame); no_control_flow = false; break; - case ClassFile.FLOAD : + case FLOAD : verify_fload(bcs.getIndex(), current_frame); no_control_flow = false; break; - case ClassFile.FLOAD_0 : - case ClassFile.FLOAD_1 : - case ClassFile.FLOAD_2 : - case ClassFile.FLOAD_3 : - index = opcode - ClassFile.FLOAD_0; + case FLOAD_0 : + case FLOAD_1 : + case FLOAD_2 : + case FLOAD_3 : + index = opcode - FLOAD_0; verify_fload(index, current_frame); no_control_flow = false; break; - case ClassFile.DLOAD : + case DLOAD : verify_dload(bcs.getIndex(), current_frame); no_control_flow = false; break; - case ClassFile.DLOAD_0 : - case ClassFile.DLOAD_1 : - case ClassFile.DLOAD_2 : - case ClassFile.DLOAD_3 : - index = opcode - ClassFile.DLOAD_0; + case DLOAD_0 : + case DLOAD_1 : + case DLOAD_2 : + case DLOAD_3 : + index = opcode - DLOAD_0; verify_dload(index, current_frame); no_control_flow = false; break; - case ClassFile.ALOAD : + case ALOAD : verify_aload(bcs.getIndex(), current_frame); no_control_flow = false; break; - case ClassFile.ALOAD_0 : - case ClassFile.ALOAD_1 : - case ClassFile.ALOAD_2 : - case ClassFile.ALOAD_3 : - index = opcode - ClassFile.ALOAD_0; + case ALOAD_0 : + case ALOAD_1 : + case ALOAD_2 : + case ALOAD_3 : + index = opcode - ALOAD_0; verify_aload(index, current_frame); no_control_flow = false; break; - case ClassFile.IALOAD : + case IALOAD : type = current_frame.pop_stack( VerificationType.integer_type); atype = current_frame.pop_stack( @@ -466,7 +464,7 @@ public final class VerifierImpl { current_frame.push_stack( VerificationType.integer_type); no_control_flow = false; break; - case ClassFile.BALOAD : + case BALOAD : type = current_frame.pop_stack( VerificationType.integer_type); atype = current_frame.pop_stack( @@ -477,7 +475,7 @@ public final class VerifierImpl { current_frame.push_stack( VerificationType.integer_type); no_control_flow = false; break; - case ClassFile.CALOAD : + case CALOAD : type = current_frame.pop_stack( VerificationType.integer_type); atype = current_frame.pop_stack( @@ -488,7 +486,7 @@ public final class VerifierImpl { current_frame.push_stack( VerificationType.integer_type); no_control_flow = false; break; - case ClassFile.SALOAD : + case SALOAD : type = current_frame.pop_stack( VerificationType.integer_type); atype = current_frame.pop_stack( @@ -499,7 +497,7 @@ public final class VerifierImpl { current_frame.push_stack( VerificationType.integer_type); no_control_flow = false; break; - case ClassFile.LALOAD : + case LALOAD : type = current_frame.pop_stack( VerificationType.integer_type); atype = current_frame.pop_stack( @@ -511,7 +509,7 @@ public final class VerifierImpl { VerificationType.long_type, VerificationType.long2_type); no_control_flow = false; break; - case ClassFile.FALOAD : + case FALOAD : type = current_frame.pop_stack( VerificationType.integer_type); atype = current_frame.pop_stack( @@ -522,7 +520,7 @@ public final class VerifierImpl { current_frame.push_stack( VerificationType.float_type); no_control_flow = false; break; - case ClassFile.DALOAD : + case DALOAD : type = current_frame.pop_stack( VerificationType.integer_type); atype = current_frame.pop_stack( @@ -534,7 +532,7 @@ public final class VerifierImpl { VerificationType.double_type, VerificationType.double2_type); no_control_flow = false; break; - case ClassFile.AALOAD : { + case AALOAD : { type = current_frame.pop_stack( VerificationType.integer_type); atype = current_frame.pop_stack( @@ -552,57 +550,57 @@ public final class VerifierImpl { } no_control_flow = false; break; } - case ClassFile.ISTORE : + case ISTORE : verify_istore(bcs.getIndex(), current_frame); no_control_flow = false; break; - case ClassFile.ISTORE_0 : - case ClassFile.ISTORE_1 : - case ClassFile.ISTORE_2 : - case ClassFile.ISTORE_3 : - index = opcode - ClassFile.ISTORE_0; + case ISTORE_0 : + case ISTORE_1 : + case ISTORE_2 : + case ISTORE_3 : + index = opcode - ISTORE_0; verify_istore(index, current_frame); no_control_flow = false; break; - case ClassFile.LSTORE : + case LSTORE : verify_lstore(bcs.getIndex(), current_frame); no_control_flow = false; break; - case ClassFile.LSTORE_0 : - case ClassFile.LSTORE_1 : - case ClassFile.LSTORE_2 : - case ClassFile.LSTORE_3 : - index = opcode - ClassFile.LSTORE_0; + case LSTORE_0 : + case LSTORE_1 : + case LSTORE_2 : + case LSTORE_3 : + index = opcode - LSTORE_0; verify_lstore(index, current_frame); no_control_flow = false; break; - case ClassFile.FSTORE : + case FSTORE : verify_fstore(bcs.getIndex(), current_frame); no_control_flow = false; break; - case ClassFile.FSTORE_0 : - case ClassFile.FSTORE_1 : - case ClassFile.FSTORE_2 : - case ClassFile.FSTORE_3 : - index = opcode - ClassFile.FSTORE_0; + case FSTORE_0 : + case FSTORE_1 : + case FSTORE_2 : + case FSTORE_3 : + index = opcode - FSTORE_0; verify_fstore(index, current_frame); no_control_flow = false; break; - case ClassFile.DSTORE : + case DSTORE : verify_dstore(bcs.getIndex(), current_frame); no_control_flow = false; break; - case ClassFile.DSTORE_0 : - case ClassFile.DSTORE_1 : - case ClassFile.DSTORE_2 : - case ClassFile.DSTORE_3 : - index = opcode - ClassFile.DSTORE_0; + case DSTORE_0 : + case DSTORE_1 : + case DSTORE_2 : + case DSTORE_3 : + index = opcode - DSTORE_0; verify_dstore(index, current_frame); no_control_flow = false; break; - case ClassFile.ASTORE : + case ASTORE : verify_astore(bcs.getIndex(), current_frame); no_control_flow = false; break; - case ClassFile.ASTORE_0 : - case ClassFile.ASTORE_1 : - case ClassFile.ASTORE_2 : - case ClassFile.ASTORE_3 : - index = opcode - ClassFile.ASTORE_0; + case ASTORE_0 : + case ASTORE_1 : + case ASTORE_2 : + case ASTORE_3 : + index = opcode - ASTORE_0; verify_astore(index, current_frame); no_control_flow = false; break; - case ClassFile.IASTORE : + case IASTORE : type = current_frame.pop_stack( VerificationType.integer_type); type2 = current_frame.pop_stack( @@ -613,7 +611,7 @@ public final class VerifierImpl { verifyError("Bad type"); } no_control_flow = false; break; - case ClassFile.BASTORE : + case BASTORE : type = current_frame.pop_stack( VerificationType.integer_type); type2 = current_frame.pop_stack( @@ -624,7 +622,7 @@ public final class VerifierImpl { verifyError("Bad type"); } no_control_flow = false; break; - case ClassFile.CASTORE : + case CASTORE : current_frame.pop_stack( VerificationType.integer_type); current_frame.pop_stack( @@ -635,7 +633,7 @@ public final class VerifierImpl { verifyError("Bad type"); } no_control_flow = false; break; - case ClassFile.SASTORE : + case SASTORE : current_frame.pop_stack( VerificationType.integer_type); current_frame.pop_stack( @@ -646,7 +644,7 @@ public final class VerifierImpl { verifyError("Bad type"); } no_control_flow = false; break; - case ClassFile.LASTORE : + case LASTORE : current_frame.pop_stack_2( VerificationType.long2_type, VerificationType.long_type); @@ -658,7 +656,7 @@ public final class VerifierImpl { verifyError("Bad type"); } no_control_flow = false; break; - case ClassFile.FASTORE : + case FASTORE : current_frame.pop_stack( VerificationType.float_type); current_frame.pop_stack @@ -669,7 +667,7 @@ public final class VerifierImpl { verifyError("Bad type"); } no_control_flow = false; break; - case ClassFile.DASTORE : + case DASTORE : current_frame.pop_stack_2( VerificationType.double2_type, VerificationType.double_type); @@ -681,7 +679,7 @@ public final class VerifierImpl { verifyError("Bad type"); } no_control_flow = false; break; - case ClassFile.AASTORE : + case AASTORE : type = current_frame.pop_stack(object_type()); type2 = current_frame.pop_stack( VerificationType.integer_type); @@ -693,11 +691,11 @@ public final class VerifierImpl { } // 4938384: relaxed constraint in JVMS 3nd edition. no_control_flow = false; break; - case ClassFile.POP : + case POP : current_frame.pop_stack( VerificationType.category1_check); no_control_flow = false; break; - case ClassFile.POP2 : + case POP2 : type = current_frame.pop_stack(); if (type.is_category1(this)) { current_frame.pop_stack( @@ -709,13 +707,13 @@ public final class VerifierImpl { verifyError("Bad type"); } no_control_flow = false; break; - case ClassFile.DUP : + case DUP : type = current_frame.pop_stack( VerificationType.category1_check); current_frame.push_stack(type); current_frame.push_stack(type); no_control_flow = false; break; - case ClassFile.DUP_X1 : + case DUP_X1 : type = current_frame.pop_stack( VerificationType.category1_check); type2 = current_frame.pop_stack( @@ -724,7 +722,7 @@ public final class VerifierImpl { current_frame.push_stack(type2); current_frame.push_stack(type); no_control_flow = false; break; - case ClassFile.DUP_X2 : + case DUP_X2 : { VerificationType type3 = null; type = current_frame.pop_stack( @@ -745,7 +743,7 @@ public final class VerifierImpl { current_frame.push_stack(type); no_control_flow = false; break; } - case ClassFile.DUP2 : + case DUP2 : type = current_frame.pop_stack(); if (type.is_category1(this)) { type2 = current_frame.pop_stack( @@ -761,7 +759,7 @@ public final class VerifierImpl { current_frame.push_stack(type2); current_frame.push_stack(type); no_control_flow = false; break; - case ClassFile.DUP2_X1 : + case DUP2_X1 : { VerificationType type3; type = current_frame.pop_stack(); @@ -783,7 +781,7 @@ public final class VerifierImpl { current_frame.push_stack(type); no_control_flow = false; break; } - case ClassFile.DUP2_X2 : + case DUP2_X2 : VerificationType type3, type4 = null; type = current_frame.pop_stack(); if (type.is_category1(this)) { @@ -812,7 +810,7 @@ public final class VerifierImpl { current_frame.push_stack(type2); current_frame.push_stack(type); no_control_flow = false; break; - case ClassFile.SWAP : + case SWAP : type = current_frame.pop_stack( VerificationType.category1_check); type2 = current_frame.pop_stack( @@ -820,39 +818,39 @@ public final class VerifierImpl { current_frame.push_stack(type); current_frame.push_stack(type2); no_control_flow = false; break; - case ClassFile.IADD : - case ClassFile.ISUB : - case ClassFile.IMUL : - case ClassFile.IDIV : - case ClassFile.IREM : - case ClassFile.ISHL : - case ClassFile.ISHR : - case ClassFile.IUSHR : - case ClassFile.IOR : - case ClassFile.IXOR : - case ClassFile.IAND : + case IADD : + case ISUB : + case IMUL : + case IDIV : + case IREM : + case ISHL : + case ISHR : + case IUSHR : + case IOR : + case IXOR : + case IAND : current_frame.pop_stack( VerificationType.integer_type); // fall through - case ClassFile.INEG : + case INEG : current_frame.pop_stack( VerificationType.integer_type); current_frame.push_stack( VerificationType.integer_type); no_control_flow = false; break; - case ClassFile.LADD : - case ClassFile.LSUB : - case ClassFile.LMUL : - case ClassFile.LDIV : - case ClassFile.LREM : - case ClassFile.LAND : - case ClassFile.LOR : - case ClassFile.LXOR : + case LADD : + case LSUB : + case LMUL : + case LDIV : + case LREM : + case LAND : + case LOR : + case LXOR : current_frame.pop_stack_2( VerificationType.long2_type, VerificationType.long_type); // fall through - case ClassFile.LNEG : + case LNEG : current_frame.pop_stack_2( VerificationType.long2_type, VerificationType.long_type); @@ -860,9 +858,9 @@ public final class VerifierImpl { VerificationType.long_type, VerificationType.long2_type); no_control_flow = false; break; - case ClassFile.LSHL : - case ClassFile.LSHR : - case ClassFile.LUSHR : + case LSHL : + case LSHR : + case LUSHR : current_frame.pop_stack( VerificationType.integer_type); current_frame.pop_stack_2( @@ -872,30 +870,30 @@ public final class VerifierImpl { VerificationType.long_type, VerificationType.long2_type); no_control_flow = false; break; - case ClassFile.FADD : - case ClassFile.FSUB : - case ClassFile.FMUL : - case ClassFile.FDIV : - case ClassFile.FREM : + case FADD : + case FSUB : + case FMUL : + case FDIV : + case FREM : current_frame.pop_stack( VerificationType.float_type); // fall through - case ClassFile.FNEG : + case FNEG : current_frame.pop_stack( VerificationType.float_type); current_frame.push_stack( VerificationType.float_type); no_control_flow = false; break; - case ClassFile.DADD : - case ClassFile.DSUB : - case ClassFile.DMUL : - case ClassFile.DDIV : - case ClassFile.DREM : + case DADD : + case DSUB : + case DMUL : + case DDIV : + case DREM : current_frame.pop_stack_2( VerificationType.double2_type, VerificationType.double_type); // fall through - case ClassFile.DNEG : + case DNEG : current_frame.pop_stack_2( VerificationType.double2_type, VerificationType.double_type); @@ -903,44 +901,44 @@ public final class VerifierImpl { VerificationType.double_type, VerificationType.double2_type); no_control_flow = false; break; - case ClassFile.IINC : + case IINC : verify_iinc(bcs.getIndex(), current_frame); no_control_flow = false; break; - case ClassFile.I2L : + case I2L : type = current_frame.pop_stack( VerificationType.integer_type); current_frame.push_stack_2( VerificationType.long_type, VerificationType.long2_type); no_control_flow = false; break; - case ClassFile.L2I : + case L2I : current_frame.pop_stack_2( VerificationType.long2_type, VerificationType.long_type); current_frame.push_stack( VerificationType.integer_type); no_control_flow = false; break; - case ClassFile.I2F : + case I2F : current_frame.pop_stack( VerificationType.integer_type); current_frame.push_stack( VerificationType.float_type); no_control_flow = false; break; - case ClassFile.I2D : + case I2D : current_frame.pop_stack( VerificationType.integer_type); current_frame.push_stack_2( VerificationType.double_type, VerificationType.double2_type); no_control_flow = false; break; - case ClassFile.L2F : + case L2F : current_frame.pop_stack_2( VerificationType.long2_type, VerificationType.long_type); current_frame.push_stack( VerificationType.float_type); no_control_flow = false; break; - case ClassFile.L2D : + case L2D : current_frame.pop_stack_2( VerificationType.long2_type, VerificationType.long_type); @@ -948,34 +946,34 @@ public final class VerifierImpl { VerificationType.double_type, VerificationType.double2_type); no_control_flow = false; break; - case ClassFile.F2I : + case F2I : current_frame.pop_stack( VerificationType.float_type); current_frame.push_stack( VerificationType.integer_type); no_control_flow = false; break; - case ClassFile.F2L : + case F2L : current_frame.pop_stack( VerificationType.float_type); current_frame.push_stack_2( VerificationType.long_type, VerificationType.long2_type); no_control_flow = false; break; - case ClassFile.F2D : + case F2D : current_frame.pop_stack( VerificationType.float_type); current_frame.push_stack_2( VerificationType.double_type, VerificationType.double2_type); no_control_flow = false; break; - case ClassFile.D2I : + case D2I : current_frame.pop_stack_2( VerificationType.double2_type, VerificationType.double_type); current_frame.push_stack( VerificationType.integer_type); no_control_flow = false; break; - case ClassFile.D2L : + case D2L : current_frame.pop_stack_2( VerificationType.double2_type, VerificationType.double_type); @@ -983,22 +981,22 @@ public final class VerifierImpl { VerificationType.long_type, VerificationType.long2_type); no_control_flow = false; break; - case ClassFile.D2F : + case D2F : current_frame.pop_stack_2( VerificationType.double2_type, VerificationType.double_type); current_frame.push_stack( VerificationType.float_type); no_control_flow = false; break; - case ClassFile.I2B : - case ClassFile.I2C : - case ClassFile.I2S : + case I2B : + case I2C : + case I2S : current_frame.pop_stack( VerificationType.integer_type); current_frame.push_stack( VerificationType.integer_type); no_control_flow = false; break; - case ClassFile.LCMP : + case LCMP : current_frame.pop_stack_2( VerificationType.long2_type, VerificationType.long_type); @@ -1008,8 +1006,8 @@ public final class VerifierImpl { current_frame.push_stack( VerificationType.integer_type); no_control_flow = false; break; - case ClassFile.FCMPL : - case ClassFile.FCMPG : + case FCMPL : + case FCMPG : current_frame.pop_stack( VerificationType.float_type); current_frame.pop_stack( @@ -1017,8 +1015,8 @@ public final class VerifierImpl { current_frame.push_stack( VerificationType.integer_type); no_control_flow = false; break; - case ClassFile.DCMPL : - case ClassFile.DCMPG : + case DCMPL : + case DCMPG : current_frame.pop_stack_2( VerificationType.double2_type, VerificationType.double_type); @@ -1028,63 +1026,63 @@ public final class VerifierImpl { current_frame.push_stack( VerificationType.integer_type); no_control_flow = false; break; - case ClassFile.IF_ICMPEQ: - case ClassFile.IF_ICMPNE: - case ClassFile.IF_ICMPLT: - case ClassFile.IF_ICMPGE: - case ClassFile.IF_ICMPGT: - case ClassFile.IF_ICMPLE: + case IF_ICMPEQ: + case IF_ICMPNE: + case IF_ICMPLT: + case IF_ICMPGE: + case IF_ICMPGT: + case IF_ICMPLE: current_frame.pop_stack( VerificationType.integer_type); // fall through - case ClassFile.IFEQ: - case ClassFile.IFNE: - case ClassFile.IFLT: - case ClassFile.IFGE: - case ClassFile.IFGT: - case ClassFile.IFLE: + case IFEQ: + case IFNE: + case IFLT: + case IFGE: + case IFGT: + case IFLE: current_frame.pop_stack( VerificationType.integer_type); target = bcs.dest(); stackmap_table.check_jump_target( current_frame, target); no_control_flow = false; break; - case ClassFile.IF_ACMPEQ : - case ClassFile.IF_ACMPNE : + case IF_ACMPEQ : + case IF_ACMPNE : current_frame.pop_stack( VerificationType.reference_check); // fall through - case ClassFile.IFNULL : - case ClassFile.IFNONNULL : + case IFNULL : + case IFNONNULL : current_frame.pop_stack( VerificationType.reference_check); target = bcs.dest(); stackmap_table.check_jump_target (current_frame, target); no_control_flow = false; break; - case ClassFile.GOTO : + case GOTO : target = bcs.dest(); stackmap_table.check_jump_target( current_frame, target); no_control_flow = true; break; - case ClassFile.GOTO_W : + case GOTO_W : target = bcs.destW(); stackmap_table.check_jump_target( current_frame, target); no_control_flow = true; break; - case ClassFile.TABLESWITCH : - case ClassFile.LOOKUPSWITCH : + case TABLESWITCH : + case LOOKUPSWITCH : verify_switch( bcs, code_length, code_data, current_frame, stackmap_table); no_control_flow = true; break; - case ClassFile.IRETURN : + case IRETURN : type = current_frame.pop_stack( VerificationType.integer_type); verify_return_value(return_type, type, bci, current_frame); no_control_flow = true; break; - case ClassFile.LRETURN : + case LRETURN : type2 = current_frame.pop_stack( VerificationType.long2_type); type = current_frame.pop_stack( @@ -1092,13 +1090,13 @@ public final class VerifierImpl { verify_return_value(return_type, type, bci, current_frame); no_control_flow = true; break; - case ClassFile.FRETURN : + case FRETURN : type = current_frame.pop_stack( VerificationType.float_type); verify_return_value(return_type, type, bci, current_frame); no_control_flow = true; break; - case ClassFile.DRETURN : + case DRETURN : type2 = current_frame.pop_stack( VerificationType.double2_type); type = current_frame.pop_stack( @@ -1106,13 +1104,13 @@ public final class VerifierImpl { verify_return_value(return_type, type, bci, current_frame); no_control_flow = true; break; - case ClassFile.ARETURN : + case ARETURN : type = current_frame.pop_stack( VerificationType.reference_check); verify_return_value(return_type, type, bci, current_frame); no_control_flow = true; break; - case ClassFile.RETURN: + case RETURN: if (!return_type.is_bogus()) { verifyError("Method expects a return value"); } @@ -1121,24 +1119,24 @@ public final class VerifierImpl { verifyError("Constructor must call super() or this() before return"); } no_control_flow = true; break; - case ClassFile.GETSTATIC : - case ClassFile.PUTSTATIC : + case GETSTATIC : + case PUTSTATIC : verify_field_instructions(bcs, current_frame, cp, true); no_control_flow = false; break; - case ClassFile.GETFIELD : - case ClassFile.PUTFIELD : + case GETFIELD : + case PUTFIELD : verify_field_instructions(bcs, current_frame, cp, false); no_control_flow = false; break; - case ClassFile.INVOKEVIRTUAL : - case ClassFile.INVOKESPECIAL : - case ClassFile.INVOKESTATIC : + case INVOKEVIRTUAL : + case INVOKESPECIAL : + case INVOKESTATIC : this_uninit = verify_invoke_instructions(bcs, code_length, current_frame, (bci >= ex_minmax[0] && bci < ex_minmax[1]), this_uninit, return_type, cp, stackmap_table); no_control_flow = false; break; - case ClassFile.INVOKEINTERFACE : - case ClassFile.INVOKEDYNAMIC : + case INVOKEINTERFACE : + case INVOKEDYNAMIC : this_uninit = verify_invoke_instructions(bcs, code_length, current_frame, (bci >= ex_minmax[0] && bci < ex_minmax[1]), this_uninit, return_type, cp, stackmap_table); no_control_flow = false; break; - case ClassFile.NEW : + case NEW : { index = bcs.getIndexU2(); verify_cp_class_type(bci, index, cp); @@ -1151,16 +1149,16 @@ public final class VerifierImpl { current_frame.push_stack(type); no_control_flow = false; break; } - case ClassFile.NEWARRAY : + case NEWARRAY : type = get_newarray_type(bcs.getIndex(), bci); current_frame.pop_stack( VerificationType.integer_type); current_frame.push_stack(type); no_control_flow = false; break; - case ClassFile.ANEWARRAY : + case ANEWARRAY : verify_anewarray(bci, bcs.getIndexU2(), cp, current_frame); no_control_flow = false; break; - case ClassFile.ARRAYLENGTH : + case ARRAYLENGTH : type = current_frame.pop_stack( VerificationType.reference_check); if (!(type.is_null() || type.is_array())) { @@ -1169,7 +1167,7 @@ public final class VerifierImpl { current_frame.push_stack( VerificationType.integer_type); no_control_flow = false; break; - case ClassFile.CHECKCAST : + case CHECKCAST : { index = bcs.getIndexU2(); verify_cp_class_type(bci, index, cp); @@ -1179,7 +1177,7 @@ public final class VerifierImpl { current_frame.push_stack(klass_type); no_control_flow = false; break; } - case ClassFile.INSTANCEOF : { + case INSTANCEOF : { index = bcs.getIndexU2(); verify_cp_class_type(bci, index, cp); current_frame.pop_stack(object_type()); @@ -1187,15 +1185,15 @@ public final class VerifierImpl { VerificationType.integer_type); no_control_flow = false; break; } - case ClassFile.MONITORENTER : - case ClassFile.MONITOREXIT : + case MONITORENTER : + case MONITOREXIT : current_frame.pop_stack( VerificationType.reference_check); no_control_flow = false; break; - case ClassFile.MULTIANEWARRAY : + case MULTIANEWARRAY : { index = bcs.getIndexU2(); - int dim = _method.codeArray()[bcs.bci+3] & 0xff; + int dim = _method.codeArray()[bcs.bci() +3] & 0xff; verify_cp_class_type(bci, index, cp); VerificationType new_array_type = cp_index_to_type(index, cp); @@ -1212,7 +1210,7 @@ public final class VerifierImpl { current_frame.push_stack(new_array_type); no_control_flow = false; break; } - case ClassFile.ATHROW : + case ATHROW : type = VerificationType.reference_type(java_lang_Throwable); current_frame.pop_stack(type); no_control_flow = true; break; @@ -1230,13 +1228,13 @@ public final class VerifierImpl { } } - private byte[] generate_code_data(ByteBuffer code, int code_length) { - byte code_data[] = new byte[code_length]; - var bcs = new RawBytecodeHelper(code); - while (!bcs.isLastBytecode()) { - if (bcs.rawNext() != ILLEGAL) { - int bci = bcs.bci; - if (bcs.rawCode == ClassFile.NEW) { + private byte[] generate_code_data(RawBytecodeHelper.CodeRange code) { + byte[] code_data = new byte[code.length()]; + var bcs = code.start(); + while (bcs.next()) { + if (bcs.opcode() != ILLEGAL) { + int bci = bcs.bci(); + if (bcs.opcode() == NEW) { code_data[bci] = NEW_OFFSET; } else { code_data[bci] = BYTECODE_OFFSET; @@ -1369,14 +1367,14 @@ public final class VerifierImpl { verify_cp_index(bci, cp, index); int tag = cp.tagAt(index); int types = 0; - if (opcode == ClassFile.LDC || opcode == ClassFile.LDC_W) { + if (opcode == LDC || opcode == LDC_W) { types = (1 << JVM_CONSTANT_Integer) | (1 << JVM_CONSTANT_Float) | (1 << JVM_CONSTANT_String) | (1 << JVM_CONSTANT_Class) | (1 << JVM_CONSTANT_MethodHandle) | (1 << JVM_CONSTANT_MethodType) | (1 << JVM_CONSTANT_Dynamic); verify_cp_type(bci, index, cp, types); } else { - if (opcode != ClassFile.LDC2_W) verifyError("must be ldc2_w"); + if (opcode != LDC2_W) verifyError("must be ldc2_w"); types = (1 << JVM_CONSTANT_Double) | (1 << JVM_CONSTANT_Long) | (1 << JVM_CONSTANT_Dynamic); verify_cp_type(bci, index, cp, types); } @@ -1396,7 +1394,7 @@ public final class VerifierImpl { VerificationType[] v_constant_type = new VerificationType[2]; var sig_stream = new VerificationSignature(constant_type, false, this); int n = change_sig_to_verificationType(sig_stream, v_constant_type, 0); - int opcode_n = (opcode == ClassFile.LDC2_W ? 2 : 1); + int opcode_n = (opcode == LDC2_W ? 2 : 1); if (n != opcode_n) { types &= ~(1 << JVM_CONSTANT_Dynamic); verify_cp_type(bci, index, cp, types); @@ -1410,7 +1408,7 @@ public final class VerifierImpl { } void verify_switch(RawBytecodeHelper bcs, int code_length, byte[] code_data, VerificationFrame current_frame, VerificationTable stackmap_table) { - int bci = bcs.bci; + int bci = bcs.bci(); int aligned_bci = VerificationBytecodes.align(bci + 1); // 4639449 & 4647081: padding bytes must be 0 if (_klass.majorVersion() < NONZERO_PADDING_BYTES_IN_SWITCH_MAJOR_VERSION) { @@ -1422,12 +1420,12 @@ public final class VerifierImpl { padding_offset++; } } - int default_ofset = bcs.getInt(aligned_bci); + int default_offset = bcs.getIntUnchecked(aligned_bci); int keys, delta; current_frame.pop_stack(VerificationType.integer_type); - if (bcs.rawCode == ClassFile.TABLESWITCH) { - int low = bcs.getInt(aligned_bci + 4); - int high = bcs.getInt(aligned_bci + 2*4); + if (bcs.opcode() == TABLESWITCH) { + int low = bcs.getIntUnchecked(aligned_bci + 4); + int high = bcs.getIntUnchecked(aligned_bci + 2*4); if (low > high) { verifyError("low must be less than or equal to high in tableswitch"); } @@ -1438,31 +1436,31 @@ public final class VerifierImpl { delta = 1; } else { // Make sure that the lookupswitch items are sorted - keys = bcs.getInt(aligned_bci + 4); + keys = bcs.getIntUnchecked(aligned_bci + 4); if (keys < 0) { verifyError("number of keys in lookupswitch less than 0"); } delta = 2; for (int i = 0; i < (keys - 1); i++) { - int this_key = bcs.getInt(aligned_bci + (2+2*i)*4); - int next_key = bcs.getInt(aligned_bci + (2+2*i+2)*4); + int this_key = bcs.getIntUnchecked(aligned_bci + (2+2*i)*4); + int next_key = bcs.getIntUnchecked(aligned_bci + (2+2*i+2)*4); if (this_key >= next_key) { verifyError("Bad lookupswitch instruction"); } } } - int target = bci + default_ofset; + int target = bci + default_offset; stackmap_table.check_jump_target(current_frame, target); for (int i = 0; i < keys; i++) { - aligned_bci = VerificationBytecodes.align(bcs.bci + 1); - target = bci + bcs.getInt(aligned_bci + (3+i*delta)*4); + aligned_bci = VerificationBytecodes.align(bcs.bci() + 1); + target = bci + bcs.getIntUnchecked(aligned_bci + (3+i*delta)*4); stackmap_table.check_jump_target(current_frame, target); } } void verify_field_instructions(RawBytecodeHelper bcs, VerificationFrame current_frame, ConstantPoolWrapper cp, boolean allow_arrays) { int index = bcs.getIndexU2(); - verify_cp_type(bcs.bci, index, cp, 1 << JVM_CONSTANT_Fieldref); + verify_cp_type(bcs.bci(), index, cp, 1 << JVM_CONSTANT_Fieldref); String field_name = cp.refNameAt(index); String field_sig = cp.refSignatureAt(index); if (!VerificationSignature.isValidTypeSignature(field_sig)) verifyError("Invalid field signature"); @@ -1477,25 +1475,25 @@ public final class VerifierImpl { VerificationType stack_object_type = null; int n = change_sig_to_verificationType(sig_stream, field_type, 0); boolean is_assignable; - switch (bcs.rawCode) { - case ClassFile.GETSTATIC -> { + switch (bcs.opcode()) { + case GETSTATIC -> { for (int i = 0; i < n; i++) { current_frame.push_stack(field_type[i]); } } - case ClassFile.PUTSTATIC -> { + case PUTSTATIC -> { for (int i = n - 1; i >= 0; i--) { current_frame.pop_stack(field_type[i]); } } - case ClassFile.GETFIELD -> { + case GETFIELD -> { stack_object_type = current_frame.pop_stack( target_class_type); for (int i = 0; i < n; i++) { current_frame.push_stack(field_type[i]); } } - case ClassFile.PUTFIELD -> { + case PUTFIELD -> { for (int i = n - 1; i >= 0; i--) { current_frame.pop_stack(field_type[i]); } @@ -1524,7 +1522,7 @@ public final class VerifierImpl { boolean verify_invoke_init(RawBytecodeHelper bcs, int ref_class_index, VerificationType ref_class_type, VerificationFrame current_frame, int code_length, boolean in_try_block, boolean this_uninit, ConstantPoolWrapper cp, VerificationTable stackmap_table) { - int bci = bcs.bci; + int bci = bcs.bci(); VerificationType type = current_frame.pop_stack(VerificationType.reference_check); if (type.is_uninitialized_this(this)) { String superk_name = current_class().superclassName(); @@ -1549,10 +1547,10 @@ public final class VerifierImpl { this_uninit = true; } else if (type.is_uninitialized()) { int new_offset = type.bci(this); - if (new_offset > (code_length - 3) || (_method.codeArray()[new_offset] & 0xff) != ClassFile.NEW) { + if (new_offset > (code_length - 3) || (_method.codeArray()[new_offset] & 0xff) != NEW) { verifyError("Expecting new instruction"); } - int new_class_index = bcs.getIndexU2Raw(new_offset + 1); + int new_class_index = bcs.getU2(new_offset + 1); verify_cp_class_type(bci, new_class_index, cp); VerificationType new_class_type = cp_index_to_type( new_class_index, cp); @@ -1583,17 +1581,17 @@ public final class VerifierImpl { boolean verify_invoke_instructions(RawBytecodeHelper bcs, int code_length, VerificationFrame current_frame, boolean in_try_block, boolean this_uninit, VerificationType return_type, ConstantPoolWrapper cp, VerificationTable stackmap_table) { // Make sure the constant pool item is the right type int index = bcs.getIndexU2(); - int opcode = bcs.rawCode; + int opcode = bcs.opcode(); int types = 0; switch (opcode) { - case ClassFile.INVOKEINTERFACE: + case INVOKEINTERFACE: types = 1 << JVM_CONSTANT_InterfaceMethodref; break; - case ClassFile.INVOKEDYNAMIC: + case INVOKEDYNAMIC: types = 1 << JVM_CONSTANT_InvokeDynamic; break; - case ClassFile.INVOKESPECIAL: - case ClassFile.INVOKESTATIC: + case INVOKESPECIAL: + case INVOKESTATIC: types = (_klass.majorVersion() < STATIC_METHOD_IN_INTERFACE_MAJOR_VERSION) ? (1 << JVM_CONSTANT_Methodref) : ((1 << JVM_CONSTANT_InterfaceMethodref) | (1 << JVM_CONSTANT_Methodref)); @@ -1601,12 +1599,12 @@ public final class VerifierImpl { default: types = 1 << JVM_CONSTANT_Methodref; } - verify_cp_type(bcs.bci, index, cp, types); + verify_cp_type(bcs.bci(), index, cp, types); String method_name = cp.refNameAt(index); String method_sig = cp.refSignatureAt(index); if (!VerificationSignature.isValidMethodSignature(method_sig)) verifyError("Invalid method signature"); VerificationType ref_class_type = null; - if (opcode == ClassFile.INVOKEDYNAMIC) { + if (opcode == INVOKEDYNAMIC) { if (_klass.majorVersion() < INVOKEDYNAMIC_MAJOR_VERSION) { classError(String.format("invokedynamic instructions not supported by this class file version (%d), class %s", _klass.majorVersion(), _klass.thisClassName())); } @@ -1619,8 +1617,8 @@ public final class VerifierImpl { mth_sig_verif_types = new sig_as_verification_types(verif_types); create_method_sig_entry(mth_sig_verif_types, sig); int nargs = mth_sig_verif_types.num_args(); - int bci = bcs.bci; - if (opcode == ClassFile.INVOKEINTERFACE) { + int bci = bcs.bci(); + if (opcode == INVOKEINTERFACE) { if ((_method.codeArray()[bci+3] & 0xff) != (nargs+1)) { verifyError("Inconsistent args count operand in invokeinterface"); } @@ -1628,17 +1626,17 @@ public final class VerifierImpl { verifyError("Fourth operand byte of invokeinterface must be zero"); } } - if (opcode == ClassFile.INVOKEDYNAMIC) { + if (opcode == INVOKEDYNAMIC) { if ((_method.codeArray()[bci+3] & 0xff) != 0 || (_method.codeArray()[bci+4] & 0xff) != 0) { verifyError("Third and fourth operand bytes of invokedynamic must be zero"); } } if (method_name.charAt(0) == JVM_SIGNATURE_SPECIAL) { - if (opcode != ClassFile.INVOKESPECIAL || + if (opcode != INVOKESPECIAL || !object_initializer_name.equals(method_name)) { verifyError("Illegal call to internal method"); } - } else if (opcode == ClassFile.INVOKESPECIAL + } else if (opcode == INVOKESPECIAL && !is_same_or_direct_interface(current_class(), current_type(), ref_class_type) && !ref_class_type.equals(VerificationType.reference_type( current_class().superclassName()))) { @@ -1656,16 +1654,16 @@ public final class VerifierImpl { for (int i = nargs - 1; i >= 0; i--) { // Run backwards current_frame.pop_stack(sig_verif_types.get(i)); } - if (opcode != ClassFile.INVOKESTATIC && - opcode != ClassFile.INVOKEDYNAMIC) { + if (opcode != INVOKESTATIC && + opcode != INVOKEDYNAMIC) { if (object_initializer_name.equals(method_name)) { // method this_uninit = verify_invoke_init(bcs, index, ref_class_type, current_frame, code_length, in_try_block, this_uninit, cp, stackmap_table); } else { switch (opcode) { - case ClassFile.INVOKESPECIAL -> + case INVOKESPECIAL -> current_frame.pop_stack(current_type()); - case ClassFile.INVOKEVIRTUAL -> { + case INVOKEVIRTUAL -> { VerificationType stack_object_type = current_frame.pop_stack(ref_class_type); if (current_type() != stack_object_type) { @@ -1673,7 +1671,7 @@ public final class VerifierImpl { } } default -> { - if (opcode != ClassFile.INVOKEINTERFACE) + if (opcode != INVOKEINTERFACE) verifyError("Unexpected opcode encountered"); current_frame.pop_stack(ref_class_type); } diff --git a/src/java.base/share/classes/jdk/internal/constant/ConstantUtils.java b/src/java.base/share/classes/jdk/internal/constant/ConstantUtils.java index f58bead542f..5640f849ab6 100644 --- a/src/java.base/share/classes/jdk/internal/constant/ConstantUtils.java +++ b/src/java.base/share/classes/jdk/internal/constant/ConstantUtils.java @@ -35,12 +35,16 @@ import java.util.ArrayList; import java.util.List; import java.util.Set; +import jdk.internal.access.JavaLangAccess; +import jdk.internal.access.SharedSecrets; import static jdk.internal.constant.PrimitiveClassDescImpl.*; /** * Helper methods for the implementation of {@code java.lang.constant}. */ public final class ConstantUtils { + private static final JavaLangAccess JLA = SharedSecrets.getJavaLangAccess(); + /** an empty constant descriptor */ public static final ConstantDesc[] EMPTY_CONSTANTDESC = new ConstantDesc[0]; public static final ClassDesc[] EMPTY_CLASSDESC = new ClassDesc[0]; @@ -66,7 +70,7 @@ public final class ConstantUtils { * @param binaryName a binary name */ public static ClassDesc binaryNameToDesc(String binaryName) { - return ReferenceClassDescImpl.ofValidated("L" + binaryToInternal(binaryName) + ";"); + return ReferenceClassDescImpl.ofValidated(concat("L", binaryToInternal(binaryName), ";")); } /** @@ -378,4 +382,8 @@ public final class ConstantUtils { "Cannot create an array type descriptor with more than %d dimensions", ConstantUtils.MAX_ARRAY_TYPE_DESC_DIMENSIONS)); } + + public static String concat(String prefix, Object value, String suffix) { + return JLA.concat(prefix, value, suffix); + } } diff --git a/src/java.base/share/classes/jdk/internal/constant/MethodTypeDescImpl.java b/src/java.base/share/classes/jdk/internal/constant/MethodTypeDescImpl.java index 7d4442c255e..6f59c476a6b 100644 --- a/src/java.base/share/classes/jdk/internal/constant/MethodTypeDescImpl.java +++ b/src/java.base/share/classes/jdk/internal/constant/MethodTypeDescImpl.java @@ -287,15 +287,31 @@ public final class MethodTypeDescImpl implements MethodTypeDesc { if (desc != null) return desc; - int len = 2 + returnType.descriptorString().length(); - for (ClassDesc argType : argTypes) { - len += argType.descriptorString().length(); + return buildDescriptorString(); + } + + private String buildDescriptorString() { + var returnType = this.returnType; + var returnTypeDesc = returnType.descriptorString(); + var argTypes = this.argTypes; + String desc; + if (argTypes.length == 0) { + // getter + desc = "()".concat(returnTypeDesc); + } else if (argTypes.length == 1 && returnType == ConstantDescs.CD_void) { + // setter + desc = ConstantUtils.concat("(", argTypes[0].descriptorString(), ")V"); + } else { + int len = 2 + returnTypeDesc.length(); + for (ClassDesc argType : argTypes) { + len += argType.descriptorString().length(); + } + StringBuilder sb = new StringBuilder(len).append('('); + for (ClassDesc argType : argTypes) { + sb.append(argType.descriptorString()); + } + desc = sb.append(')').append(returnTypeDesc).toString(); } - StringBuilder sb = new StringBuilder(len).append('('); - for (ClassDesc argType : argTypes) { - sb.append(argType.descriptorString()); - } - desc = sb.append(')').append(returnType.descriptorString()).toString(); cachedDescriptorString = desc; return desc; } diff --git a/src/java.base/share/classes/jdk/internal/event/ThreadSleepEvent.java b/src/java.base/share/classes/jdk/internal/event/ThreadSleepEvent.java index ab9b377c0f3..283ba425977 100644 --- a/src/java.base/share/classes/jdk/internal/event/ThreadSleepEvent.java +++ b/src/java.base/share/classes/jdk/internal/event/ThreadSleepEvent.java @@ -30,14 +30,5 @@ package jdk.internal.event; */ public final class ThreadSleepEvent extends Event { - private static final ThreadSleepEvent EVENT = new ThreadSleepEvent(); - - /** - * Returns {@code true} if event is enabled, {@code false} otherwise. - */ - public static boolean isTurnedOn() { - return EVENT.isEnabled(); - } - public long time; } diff --git a/src/java.base/share/classes/jdk/internal/foreign/AbstractMemorySegmentImpl.java b/src/java.base/share/classes/jdk/internal/foreign/AbstractMemorySegmentImpl.java index 5d43c28a667..c3b6295853f 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/AbstractMemorySegmentImpl.java +++ b/src/java.base/share/classes/jdk/internal/foreign/AbstractMemorySegmentImpl.java @@ -72,8 +72,6 @@ public abstract sealed class AbstractMemorySegmentImpl implements MemorySegment, SegmentAllocator, BiFunction, RuntimeException> permits HeapMemorySegmentImpl, NativeMemorySegmentImpl { - private static final ScopedMemoryAccess SCOPED_MEMORY_ACCESS = ScopedMemoryAccess.getScopedMemoryAccess(); - static final JavaNioAccess NIO_ACCESS = SharedSecrets.getJavaNioAccess(); final long length; @@ -189,53 +187,10 @@ public abstract sealed class AbstractMemorySegmentImpl return StreamSupport.stream(spliterator(elementLayout), false); } - // FILL_NATIVE_THRESHOLD must be a power of two and should be greater than 2^3 - // Update the value for Aarch64 once 8338975 is fixed. - private static final long FILL_NATIVE_THRESHOLD = 1L << (Architecture.isAARCH64() ? 10 : 5); - - @Override @ForceInline + @Override public final MemorySegment fill(byte value) { - checkReadOnly(false); - if (length == 0) { - // Implicit state check - checkValidState(); - } else if (length < FILL_NATIVE_THRESHOLD) { - // 0 <= length < FILL_NATIVE_LIMIT : 0...0X...XXXX - - // Handle smaller segments directly without transitioning to native code - final long u = Byte.toUnsignedLong(value); - final long longValue = u << 56 | u << 48 | u << 40 | u << 32 | u << 24 | u << 16 | u << 8 | u; - - int offset = 0; - // 0...0X...X000 - final int limit = (int) (length & (FILL_NATIVE_THRESHOLD - 8)); - for (; offset < limit; offset += 8) { - SCOPED_MEMORY_ACCESS.putLong(sessionImpl(), unsafeGetBase(), unsafeGetOffset() + offset, longValue); - } - int remaining = (int) length - limit; - // 0...0X00 - if (remaining >= 4) { - SCOPED_MEMORY_ACCESS.putInt(sessionImpl(), unsafeGetBase(), unsafeGetOffset() + offset, (int) longValue); - offset += 4; - remaining -= 4; - } - // 0...00X0 - if (remaining >= 2) { - SCOPED_MEMORY_ACCESS.putShort(sessionImpl(), unsafeGetBase(), unsafeGetOffset() + offset, (short) longValue); - offset += 2; - remaining -= 2; - } - // 0...000X - if (remaining == 1) { - SCOPED_MEMORY_ACCESS.putByte(sessionImpl(), unsafeGetBase(), unsafeGetOffset() + offset, value); - } - // We have now fully handled 0...0X...XXXX - } else { - // Handle larger segments via native calls - SCOPED_MEMORY_ACCESS.setMemory(sessionImpl(), unsafeGetBase(), unsafeGetOffset(), length, value); - } - return this; + return SegmentBulkOperations.fill(this, value); } @Override @@ -244,38 +199,6 @@ public abstract sealed class AbstractMemorySegmentImpl return asSlice(0, byteSize, byteAlignment); } - /** - * Mismatch over long lengths. - */ - public static long vectorizedMismatchLargeForBytes(MemorySessionImpl aSession, MemorySessionImpl bSession, - Object a, long aOffset, - Object b, long bOffset, - long length) { - long off = 0; - long remaining = length; - int i, size; - boolean lastSubRange = false; - while (remaining > 7 && !lastSubRange) { - if (remaining > Integer.MAX_VALUE) { - size = Integer.MAX_VALUE; - } else { - size = (int) remaining; - lastSubRange = true; - } - i = SCOPED_MEMORY_ACCESS.vectorizedMismatch(aSession, bSession, - a, aOffset + off, - b, bOffset + off, - size, ArraysSupport.LOG2_ARRAY_BYTE_INDEX_SCALE); - if (i >= 0) - return off + i; - - i = size - ~i; - off += i; - remaining -= i; - } - return ~remaining; - } - @Override public final ByteBuffer asByteBuffer() { checkArraySize("ByteBuffer", 1); @@ -304,20 +227,25 @@ public abstract sealed class AbstractMemorySegmentImpl @Override public final Optional asOverlappingSlice(MemorySegment other) { - AbstractMemorySegmentImpl that = (AbstractMemorySegmentImpl)Objects.requireNonNull(other); - if (unsafeGetBase() == that.unsafeGetBase()) { // both either native or heap + final AbstractMemorySegmentImpl that = (AbstractMemorySegmentImpl)Objects.requireNonNull(other); + if (overlaps(that)) { + final long offsetToThat = that.address() - this.address(); + final long newOffset = offsetToThat >= 0 ? offsetToThat : 0; + return Optional.of(asSlice(newOffset, Math.min(this.byteSize() - newOffset, that.byteSize() + offsetToThat))); + } + return Optional.empty(); + } + + @ForceInline + boolean overlaps(AbstractMemorySegmentImpl that) { + if (unsafeGetBase() == that.unsafeGetBase()) { // both either native or the same heap segment final long thisStart = this.unsafeGetOffset(); final long thatStart = that.unsafeGetOffset(); final long thisEnd = thisStart + this.byteSize(); final long thatEnd = thatStart + that.byteSize(); - - if (thisStart < thatEnd && thisEnd > thatStart) { //overlap occurs - long offsetToThat = that.address() - this.address(); - long newOffset = offsetToThat >= 0 ? offsetToThat : 0; - return Optional.of(asSlice(newOffset, Math.min(this.byteSize() - newOffset, that.byteSize() + offsetToThat))); - } + return (thisStart < thatEnd && thisEnd > thatStart); //overlap occurs? } - return Optional.empty(); + return false; } @Override @@ -329,7 +257,8 @@ public abstract sealed class AbstractMemorySegmentImpl @Override public long mismatch(MemorySegment other) { Objects.requireNonNull(other); - return MemorySegment.mismatch(this, 0, byteSize(), other, 0, other.byteSize()); + return SegmentBulkOperations.mismatch(this, 0, byteSize(), + (AbstractMemorySegmentImpl) other, 0, other.byteSize()); } @Override @@ -450,7 +379,7 @@ public abstract sealed class AbstractMemorySegmentImpl throw new IllegalStateException(String.format("Segment size is not a multiple of %d. Size: %d", elemSize, length)); } long arraySize = length / elemSize; - if (arraySize > (Integer.MAX_VALUE - 8)) { //conservative check + if (arraySize > ArraysSupport.SOFT_MAX_ARRAY_LENGTH) { //conservative check throw new IllegalStateException(String.format("Segment is too large to wrap as %s. Size: %d", typeName, length)); } return (int)arraySize; @@ -731,40 +660,6 @@ public abstract sealed class AbstractMemorySegmentImpl } } - public static long mismatch(MemorySegment srcSegment, long srcFromOffset, long srcToOffset, - MemorySegment dstSegment, long dstFromOffset, long dstToOffset) { - AbstractMemorySegmentImpl srcImpl = (AbstractMemorySegmentImpl)Objects.requireNonNull(srcSegment); - AbstractMemorySegmentImpl dstImpl = (AbstractMemorySegmentImpl)Objects.requireNonNull(dstSegment); - long srcBytes = srcToOffset - srcFromOffset; - long dstBytes = dstToOffset - dstFromOffset; - srcImpl.checkAccess(srcFromOffset, srcBytes, true); - dstImpl.checkAccess(dstFromOffset, dstBytes, true); - - long bytes = Math.min(srcBytes, dstBytes); - long i = 0; - if (bytes > 7) { - if (srcImpl.get(JAVA_BYTE, srcFromOffset) != dstImpl.get(JAVA_BYTE, dstFromOffset)) { - return 0; - } - i = AbstractMemorySegmentImpl.vectorizedMismatchLargeForBytes(srcImpl.sessionImpl(), dstImpl.sessionImpl(), - srcImpl.unsafeGetBase(), srcImpl.unsafeGetOffset() + srcFromOffset, - dstImpl.unsafeGetBase(), dstImpl.unsafeGetOffset() + dstFromOffset, - bytes); - if (i >= 0) { - return i; - } - long remaining = ~i; - assert remaining < 8 : "remaining greater than 7: " + remaining; - i = bytes - remaining; - } - for (; i < bytes; i++) { - if (srcImpl.get(JAVA_BYTE, srcFromOffset + i) != dstImpl.get(JAVA_BYTE, dstFromOffset + i)) { - return i; - } - } - return srcBytes != dstBytes ? bytes : -1; - } - private static int getScaleFactor(Buffer buffer) { return switch (buffer) { case ByteBuffer _ -> 0; diff --git a/src/java.base/share/classes/jdk/internal/foreign/ConfinedSession.java b/src/java.base/share/classes/jdk/internal/foreign/ConfinedSession.java index 4ff0df787c5..432b324c1bd 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/ConfinedSession.java +++ b/src/java.base/share/classes/jdk/internal/foreign/ConfinedSession.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,6 +28,7 @@ package jdk.internal.foreign; import java.lang.invoke.MethodHandles; import java.lang.invoke.VarHandle; +import jdk.internal.invoke.MhUtil; import jdk.internal.vm.annotation.ForceInline; /** @@ -40,15 +41,8 @@ final class ConfinedSession extends MemorySessionImpl { private int asyncReleaseCount = 0; - static final VarHandle ASYNC_RELEASE_COUNT; - - static { - try { - ASYNC_RELEASE_COUNT = MethodHandles.lookup().findVarHandle(ConfinedSession.class, "asyncReleaseCount", int.class); - } catch (Throwable ex) { - throw new ExceptionInInitializerError(ex); - } - } + static final VarHandle ASYNC_RELEASE_COUNT= MhUtil.findVarHandle( + MethodHandles.lookup(), "asyncReleaseCount", int.class); public ConfinedSession(Thread owner) { super(owner, new ConfinedResourceList()); diff --git a/src/java.base/share/classes/jdk/internal/foreign/MappedMemorySegmentImpl.java b/src/java.base/share/classes/jdk/internal/foreign/MappedMemorySegmentImpl.java index e313780a348..181a560c5f0 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/MappedMemorySegmentImpl.java +++ b/src/java.base/share/classes/jdk/internal/foreign/MappedMemorySegmentImpl.java @@ -72,23 +72,28 @@ final class MappedMemorySegmentImpl extends NativeMemorySegmentImpl { public void load() { if (unmapper != null) { - SCOPED_MEMORY_ACCESS.load(sessionImpl(), min, unmapper.isSync(), length); + SCOPED_MEMORY_ACCESS.load(sessionImpl(), NIO_ACCESS.mappedMemoryUtils(), + min, unmapper.isSync(), length); } } public void unload() { if (unmapper != null) { - SCOPED_MEMORY_ACCESS.unload(sessionImpl(), min, unmapper.isSync(), length); + SCOPED_MEMORY_ACCESS.unload(sessionImpl(), NIO_ACCESS.mappedMemoryUtils(), + min, unmapper.isSync(), length); } } public boolean isLoaded() { - return unmapper == null || SCOPED_MEMORY_ACCESS.isLoaded(sessionImpl(), min, unmapper.isSync(), length); + return unmapper == null || + SCOPED_MEMORY_ACCESS.isLoaded(sessionImpl(), + NIO_ACCESS.mappedMemoryUtils(), min, unmapper.isSync(), length); } public void force() { if (unmapper != null) { - SCOPED_MEMORY_ACCESS.force(sessionImpl(), unmapper.fileDescriptor(), min, unmapper.isSync(), 0, length); + SCOPED_MEMORY_ACCESS.force(sessionImpl(), NIO_ACCESS.mappedMemoryUtils(), + unmapper.fileDescriptor(), min, unmapper.isSync(), 0, length); } } diff --git a/src/java.base/share/classes/jdk/internal/foreign/MemorySessionImpl.java b/src/java.base/share/classes/jdk/internal/foreign/MemorySessionImpl.java index aef62be8151..a12b16ca8b4 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/MemorySessionImpl.java +++ b/src/java.base/share/classes/jdk/internal/foreign/MemorySessionImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,6 +36,7 @@ import java.util.Objects; import jdk.internal.foreign.GlobalSession.HeapSession; import jdk.internal.misc.ScopedMemoryAccess; +import jdk.internal.invoke.MhUtil; import jdk.internal.vm.annotation.ForceInline; /** @@ -57,7 +58,9 @@ public abstract sealed class MemorySessionImpl static final int OPEN = 0; static final int CLOSED = -1; - static final VarHandle STATE; + static final VarHandle STATE = MhUtil.findVarHandle( + MethodHandles.lookup(), "state", int.class); + static final int MAX_FORKS = Integer.MAX_VALUE; static final ScopedMemoryAccess.ScopedAccessError ALREADY_CLOSED = new ScopedMemoryAccess.ScopedAccessError(MemorySessionImpl::alreadyClosed); @@ -69,14 +72,6 @@ public abstract sealed class MemorySessionImpl final Thread owner; int state = OPEN; - static { - try { - STATE = MethodHandles.lookup().findVarHandle(MemorySessionImpl.class, "state", int.class); - } catch (Exception ex) { - throw new ExceptionInInitializerError(ex); - } - } - public Arena asArena() { return new ArenaImpl(this); } diff --git a/src/java.base/share/classes/jdk/internal/foreign/SegmentBulkOperations.java b/src/java.base/share/classes/jdk/internal/foreign/SegmentBulkOperations.java new file mode 100644 index 00000000000..d5a5954fa0e --- /dev/null +++ b/src/java.base/share/classes/jdk/internal/foreign/SegmentBulkOperations.java @@ -0,0 +1,300 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +package jdk.internal.foreign; + +import jdk.internal.misc.ScopedMemoryAccess; +import jdk.internal.util.Architecture; +import jdk.internal.util.ArraysSupport; +import jdk.internal.vm.annotation.ForceInline; +import sun.security.action.GetIntegerAction; + +import java.lang.foreign.MemorySegment; + +/** + * This class contains optimized bulk operation methods that operate on one or several + * memory segments. + *

                + * Generally, the methods attempt to work with as-large-as-possible units of memory at + * a time. + *

                + * It should be noted that when invoking scoped memory access get/set operations, it + * is imperative from a performance perspective to convey the sharp types from the + * call site in order for the compiler to pick the correct Unsafe access variant. + */ +public final class SegmentBulkOperations { + + private SegmentBulkOperations() {} + + private static final ScopedMemoryAccess SCOPED_MEMORY_ACCESS = ScopedMemoryAccess.getScopedMemoryAccess(); + + // All the threshold values below MUST be a power of two and should preferably be + // greater or equal to 2^3. + + // Update the FILL value for Aarch64 once 8338975 is fixed. + private static final int NATIVE_THRESHOLD_FILL = powerOfPropertyOr("fill", Architecture.isAARCH64() ? 10 : 5); + private static final int NATIVE_THRESHOLD_MISMATCH = powerOfPropertyOr("mismatch", 6); + private static final int NATIVE_THRESHOLD_COPY = powerOfPropertyOr("copy", 6); + + @ForceInline + public static MemorySegment fill(AbstractMemorySegmentImpl dst, byte value) { + dst.checkReadOnly(false); + if (dst.length == 0) { + // Implicit state check + dst.checkValidState(); + } else if (dst.length < NATIVE_THRESHOLD_FILL) { + // 0 <= length < FILL_NATIVE_LIMIT : 0...0X...XXXX + + // Handle smaller segments directly without transitioning to native code + final long u = Byte.toUnsignedLong(value); + final long longValue = u << 56 | u << 48 | u << 40 | u << 32 | u << 24 | u << 16 | u << 8 | u; + + int offset = 0; + // 0...0X...X000 + final int limit = (int) (dst.length & (NATIVE_THRESHOLD_FILL - 8)); + for (; offset < limit; offset += 8) { + SCOPED_MEMORY_ACCESS.putLongUnaligned(dst.sessionImpl(), dst.unsafeGetBase(), dst.unsafeGetOffset() + offset, longValue, !Architecture.isLittleEndian()); + } + int remaining = (int) dst.length - limit; + // 0...0X00 + if (remaining >= 4) { + SCOPED_MEMORY_ACCESS.putIntUnaligned(dst.sessionImpl(), dst.unsafeGetBase(), dst.unsafeGetOffset() + offset, (int) longValue, !Architecture.isLittleEndian()); + offset += 4; + remaining -= 4; + } + // 0...00X0 + if (remaining >= 2) { + SCOPED_MEMORY_ACCESS.putShortUnaligned(dst.sessionImpl(), dst.unsafeGetBase(), dst.unsafeGetOffset() + offset, (short) longValue, !Architecture.isLittleEndian()); + offset += 2; + remaining -= 2; + } + // 0...000X + if (remaining == 1) { + SCOPED_MEMORY_ACCESS.putByte(dst.sessionImpl(), dst.unsafeGetBase(), dst.unsafeGetOffset() + offset, value); + } + // We have now fully handled 0...0X...XXXX + } else { + // Handle larger segments via native calls + SCOPED_MEMORY_ACCESS.setMemory(dst.sessionImpl(), dst.unsafeGetBase(), dst.unsafeGetOffset(), dst.length, value); + } + return dst; + } + + @ForceInline + public static void copy(AbstractMemorySegmentImpl src, long srcOffset, + AbstractMemorySegmentImpl dst, long dstOffset, + long size) { + + Utils.checkNonNegativeIndex(size, "size"); + // Implicit null check for src and dst + src.checkAccess(srcOffset, size, true); + dst.checkAccess(dstOffset, size, false); + + if (size <= 0) { + // Do nothing + } else if (size < NATIVE_THRESHOLD_COPY && !src.overlaps(dst)) { + // 0 < size < FILL_NATIVE_LIMIT : 0...0X...XXXX + // + // Strictly, we could check for !src.asSlice(srcOffset, size).overlaps(dst.asSlice(dstOffset, size) but + // this is a bit slower and it likely very unusual there is any difference in the outcome. Also, if there + // is an overlap, we could tolerate one particular direction of overlap (but not the other). + + // 0...0X...X000 + final int limit = (int) (size & (NATIVE_THRESHOLD_COPY - 8)); + int offset = 0; + for (; offset < limit; offset += 8) { + final long v = SCOPED_MEMORY_ACCESS.getLongUnaligned(src.sessionImpl(), src.unsafeGetBase(), src.unsafeGetOffset() + srcOffset + offset, !Architecture.isLittleEndian()); + SCOPED_MEMORY_ACCESS.putLongUnaligned(dst.sessionImpl(), dst.unsafeGetBase(), dst.unsafeGetOffset() + dstOffset + offset, v, !Architecture.isLittleEndian()); + } + int remaining = (int) size - offset; + // 0...0X00 + if (remaining >= 4) { + final int v = SCOPED_MEMORY_ACCESS.getIntUnaligned(src.sessionImpl(), src.unsafeGetBase(),src.unsafeGetOffset() + srcOffset + offset, !Architecture.isLittleEndian()); + SCOPED_MEMORY_ACCESS.putIntUnaligned(dst.sessionImpl(), dst.unsafeGetBase(), dst.unsafeGetOffset() + dstOffset + offset, v, !Architecture.isLittleEndian()); + offset += 4; + remaining -= 4; + } + // 0...00X0 + if (remaining >= 2) { + final short v = SCOPED_MEMORY_ACCESS.getShortUnaligned(src.sessionImpl(), src.unsafeGetBase(), src.unsafeGetOffset() + srcOffset + offset, !Architecture.isLittleEndian()); + SCOPED_MEMORY_ACCESS.putShortUnaligned(dst.sessionImpl(), dst.unsafeGetBase(), dst.unsafeGetOffset() + dstOffset + offset, v, !Architecture.isLittleEndian()); + offset += 2; + remaining -=2; + } + // 0...000X + if (remaining == 1) { + final byte v = SCOPED_MEMORY_ACCESS.getByte(src.sessionImpl(), src.unsafeGetBase(), src.unsafeGetOffset() + srcOffset + offset); + SCOPED_MEMORY_ACCESS.putByte(dst.sessionImpl(), dst.unsafeGetBase(), dst.unsafeGetOffset() + dstOffset + offset, v); + } + // We have now fully handled 0...0X...XXXX + } else { + // For larger sizes, the transition to native code pays off + SCOPED_MEMORY_ACCESS.copyMemory(src.sessionImpl(), dst.sessionImpl(), + src.unsafeGetBase(), src.unsafeGetOffset() + srcOffset, + dst.unsafeGetBase(), dst.unsafeGetOffset() + dstOffset, size); + } + } + + @ForceInline + public static long mismatch(AbstractMemorySegmentImpl src, long srcFromOffset, long srcToOffset, + AbstractMemorySegmentImpl dst, long dstFromOffset, long dstToOffset) { + final long srcBytes = srcToOffset - srcFromOffset; + final long dstBytes = dstToOffset - dstFromOffset; + src.checkAccess(srcFromOffset, srcBytes, true); + dst.checkAccess(dstFromOffset, dstBytes, true); + + final long length = Math.min(srcBytes, dstBytes); + final boolean srcAndDstBytesDiffer = srcBytes != dstBytes; + + if (length == 0) { + return srcAndDstBytesDiffer ? 0 : -1; + } else if (length < NATIVE_THRESHOLD_MISMATCH) { + return mismatch(src, srcFromOffset, dst, dstFromOffset, 0, (int) length, srcAndDstBytesDiffer); + } else { + long i; + if (SCOPED_MEMORY_ACCESS.getByte(src.sessionImpl(), src.unsafeGetBase(), src.unsafeGetOffset() + srcFromOffset) != + SCOPED_MEMORY_ACCESS.getByte(dst.sessionImpl(), dst.unsafeGetBase(), dst.unsafeGetOffset() + dstFromOffset)) { + return 0; + } + i = vectorizedMismatchLargeForBytes(src.sessionImpl(), dst.sessionImpl(), + src.unsafeGetBase(), src.unsafeGetOffset() + srcFromOffset, + dst.unsafeGetBase(), dst.unsafeGetOffset() + dstFromOffset, + length); + if (i >= 0) { + return i; + } + final long remaining = ~i; + assert remaining < 8 : "remaining greater than 7: " + remaining; + i = length - remaining; + return mismatch(src, srcFromOffset + i, dst, dstFromOffset + i, i, (int) remaining, srcAndDstBytesDiffer); + } + } + + // Mismatch is handled in chunks of 64 (unroll of eight 8s), 8, 4, 2, and 1 byte(s). + @ForceInline + private static long mismatch(AbstractMemorySegmentImpl src, long srcFromOffset, + AbstractMemorySegmentImpl dst, long dstFromOffset, + long start, int length, boolean srcAndDstBytesDiffer) { + int offset = 0; + final int limit = length & (NATIVE_THRESHOLD_MISMATCH - 8); + for (; offset < limit; offset += 8) { + final long s = SCOPED_MEMORY_ACCESS.getLongUnaligned(src.sessionImpl(), src.unsafeGetBase(), src.unsafeGetOffset() + srcFromOffset + offset, false); + final long d = SCOPED_MEMORY_ACCESS.getLongUnaligned(dst.sessionImpl(), dst.unsafeGetBase(), dst.unsafeGetOffset() + dstFromOffset + offset, false); + if (s != d) { + return start + offset + mismatch(s, d); + } + } + int remaining = length - offset; + + // 0...0X00 + if (remaining >= 4) { + final int s = SCOPED_MEMORY_ACCESS.getIntUnaligned(src.sessionImpl(), src.unsafeGetBase(), src.unsafeGetOffset() + srcFromOffset + offset, false); + final int d = SCOPED_MEMORY_ACCESS.getIntUnaligned(dst.sessionImpl(), dst.unsafeGetBase(), dst.unsafeGetOffset() + dstFromOffset + offset, false); + if (s != d) { + return start + offset + mismatch(s, d); + } + offset += 4; + remaining -= 4; + } + // 0...00X0 + if (remaining >= 2) { + final short s = SCOPED_MEMORY_ACCESS.getShortUnaligned(src.sessionImpl(), src.unsafeGetBase(), src.unsafeGetOffset() + srcFromOffset + offset, false); + final short d = SCOPED_MEMORY_ACCESS.getShortUnaligned(dst.sessionImpl(), dst.unsafeGetBase(), dst.unsafeGetOffset() + dstFromOffset + offset, false); + if (s != d) { + return start + offset + mismatch(s, d); + } + offset += 2; + remaining -= 2; + } + // 0...000X + if (remaining == 1) { + final byte s = SCOPED_MEMORY_ACCESS.getByte(src.sessionImpl(), src.unsafeGetBase(), src.unsafeGetOffset() + srcFromOffset + offset); + final byte d = SCOPED_MEMORY_ACCESS.getByte(dst.sessionImpl(), dst.unsafeGetBase(), dst.unsafeGetOffset() + dstFromOffset + offset); + if (s != d) { + return start + offset; + } + } + return srcAndDstBytesDiffer ? (start + length) : -1; + // We have now fully handled 0...0X...XXXX + } + + @ForceInline + private static int mismatch(long first, long second) { + final long x = first ^ second; + return Long.numberOfTrailingZeros(x) / 8; + } + + @ForceInline + private static int mismatch(int first, int second) { + final int x = first ^ second; + return Integer.numberOfTrailingZeros(x) / 8; + } + + @ForceInline + private static int mismatch(short first, short second) { + return ((0xff & first) == (0xff & second)) ? 1 : 0; + } + + /** + * Mismatch over long lengths. + */ + private static long vectorizedMismatchLargeForBytes(MemorySessionImpl aSession, MemorySessionImpl bSession, + Object a, long aOffset, + Object b, long bOffset, + long length) { + long off = 0; + long remaining = length; + int i, size; + boolean lastSubRange = false; + while (remaining > 7 && !lastSubRange) { + if (remaining > Integer.MAX_VALUE) { + size = Integer.MAX_VALUE; + } else { + size = (int) remaining; + lastSubRange = true; + } + i = SCOPED_MEMORY_ACCESS.vectorizedMismatch(aSession, bSession, + a, aOffset + off, + b, bOffset + off, + size, ArraysSupport.LOG2_ARRAY_BYTE_INDEX_SCALE); + if (i >= 0) + return off + i; + + i = size - ~i; + off += i; + remaining -= i; + } + return ~remaining; + } + + static final String PROPERTY_PATH = "java.lang.foreign.native.threshold.power."; + + // The returned value is in the interval [0, 2^30] + static int powerOfPropertyOr(String name, int defaultPower) { + final int power = GetIntegerAction.privilegedGetProperty(PROPERTY_PATH + name, defaultPower); + return 1 << Math.clamp(power, 0, Integer.SIZE - 2); + } + +} diff --git a/src/java.base/share/classes/jdk/internal/foreign/SharedSession.java b/src/java.base/share/classes/jdk/internal/foreign/SharedSession.java index 1569589ef9b..6c9666c2b58 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/SharedSession.java +++ b/src/java.base/share/classes/jdk/internal/foreign/SharedSession.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,6 +28,7 @@ package jdk.internal.foreign; import java.lang.invoke.MethodHandles; import java.lang.invoke.VarHandle; import jdk.internal.misc.ScopedMemoryAccess; +import jdk.internal.invoke.MhUtil; import jdk.internal.vm.annotation.ForceInline; /** @@ -91,15 +92,8 @@ sealed class SharedSession extends MemorySessionImpl permits ImplicitSession { */ static class SharedResourceList extends ResourceList { - static final VarHandle FST; - - static { - try { - FST = MethodHandles.lookup().findVarHandle(ResourceList.class, "fst", ResourceCleanup.class); - } catch (Throwable ex) { - throw new ExceptionInInitializerError(); - } - } + static final VarHandle FST = MhUtil.findVarHandle( + MethodHandles.lookup(), ResourceList.class, "fst", ResourceCleanup.class); @Override void add(ResourceCleanup cleanup) { diff --git a/src/java.base/share/classes/jdk/internal/foreign/abi/BindingSpecializer.java b/src/java.base/share/classes/jdk/internal/foreign/abi/BindingSpecializer.java index bc5f63fd50e..f1e1d1728d8 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/abi/BindingSpecializer.java +++ b/src/java.base/share/classes/jdk/internal/foreign/abi/BindingSpecializer.java @@ -193,11 +193,10 @@ public class BindingSpecializer { CallingSequence callingSequence, ABIDescriptor abi) { String className = callingSequence.forDowncall() ? CLASS_NAME_DOWNCALL : CLASS_NAME_UPCALL; byte[] bytes = ClassFile.of().build(ClassDesc.ofInternalName(className), clb -> { - clb.withFlags(ACC_PUBLIC + ACC_FINAL + ACC_SUPER); - clb.withSuperclass(CD_Object); - clb.withVersion(CLASSFILE_VERSION, 0); - - clb.withMethodBody(METHOD_NAME, methodTypeDesc(callerMethodType), ACC_PUBLIC | ACC_STATIC, + clb.withFlags(ACC_PUBLIC + ACC_FINAL + ACC_SUPER) + .withSuperclass(CD_Object) + .withVersion(CLASSFILE_VERSION, 0) + .withMethodBody(METHOD_NAME, methodTypeDesc(callerMethodType), ACC_PUBLIC | ACC_STATIC, cb -> new BindingSpecializer(cb, callerMethodType, callingSequence, abi, leafType).specialize()); }); @@ -275,8 +274,8 @@ public class BindingSpecializer { if (shouldAcquire(i)) { int scopeLocal = cb.allocateLocal(REFERENCE); initialScopeSlots[numScopes++] = scopeLocal; - cb.loadConstant(null); - cb.storeLocal(REFERENCE, scopeLocal); // need to initialize all scope locals here in case an exception occurs + cb.aconst_null() + .astore(scopeLocal); // need to initialize all scope locals here in case an exception occurs } } scopeSlots = Arrays.copyOf(initialScopeSlots, numScopes); // fit to size @@ -285,15 +284,15 @@ public class BindingSpecializer { // create a Binding.Context for this call if (callingSequence.allocationSize() != 0) { - cb.loadConstant(callingSequence.allocationSize()); - cb.invokestatic(CD_SharedUtils, "newBoundedArena", MTD_NEW_BOUNDED_ARENA); + cb.loadConstant(callingSequence.allocationSize()) + .invokestatic(CD_SharedUtils, "newBoundedArena", MTD_NEW_BOUNDED_ARENA); } else if (callingSequence.forUpcall() && needsSession()) { cb.invokestatic(CD_SharedUtils, "newEmptyArena", MTD_NEW_EMPTY_ARENA); } else { cb.getstatic(CD_SharedUtils, "DUMMY_ARENA", CD_Arena); } contextIdx = cb.allocateLocal(REFERENCE); - cb.storeLocal(REFERENCE, contextIdx); + cb.astore(contextIdx); // in case the call needs a return buffer, allocate it here. // for upcalls the VM wrapper stub allocates the buffer. @@ -301,7 +300,7 @@ public class BindingSpecializer { emitLoadInternalAllocator(); emitAllocateCall(callingSequence.returnBufferSize(), 1); returnBufferIdx = cb.allocateLocal(REFERENCE); - cb.storeLocal(REFERENCE, returnBufferIdx); + cb.astore(returnBufferIdx); } Label tryStart = cb.newLabel(); @@ -324,7 +323,7 @@ public class BindingSpecializer { // for downcalls, recipes have an input value, which we set up here if (callingSequence.needsReturnBuffer() && i == 0) { assert returnBufferIdx != -1; - cb.loadLocal(REFERENCE, returnBufferIdx); + cb.aload(returnBufferIdx); pushType(MemorySegment.class); } else { emitGetInput(); @@ -340,7 +339,7 @@ public class BindingSpecializer { // return buffer ptr is wrapped in a MemorySegment above, but not passed to the leaf handle popType(MemorySegment.class); returnBufferIdx = cb.allocateLocal(REFERENCE); - cb.storeLocal(REFERENCE, returnBufferIdx); + cb.astore(returnBufferIdx); } else { // for upcalls the recipe result is an argument to the leaf handle emitSetOutput(typeStack.pop()); @@ -355,7 +354,7 @@ public class BindingSpecializer { if (callingSequence.forDowncall()) { cb.loadConstant(CLASS_DATA_DESC); } else { - cb.loadLocal(REFERENCE, 0); // load target arg + cb.aload(0); // load target arg } cb.checkcast(CD_MethodHandle); // load all the leaf args @@ -496,8 +495,8 @@ public class BindingSpecializer { } private void emitAcquireScope() { - cb.checkcast(CD_AbstractMemorySegmentImpl); - cb.invokevirtual(CD_AbstractMemorySegmentImpl, "sessionImpl", MTD_SESSION_IMPL); + cb.checkcast(CD_AbstractMemorySegmentImpl) + .invokevirtual(CD_AbstractMemorySegmentImpl, "sessionImpl", MTD_SESSION_IMPL); Label skipAcquire = cb.newLabel(); Label end = cb.newLabel(); @@ -505,23 +504,22 @@ public class BindingSpecializer { assert curScopeLocalIdx != -1; boolean hasOtherScopes = curScopeLocalIdx != 0; for (int i = 0; i < curScopeLocalIdx; i++) { - cb.dup(); // dup for comparison - cb.loadLocal(REFERENCE, scopeSlots[i]); - cb.if_acmpeq(skipAcquire); + cb.dup() // dup for comparison + .aload(scopeSlots[i]) + .if_acmpeq(skipAcquire); } // 1 scope to acquire on the stack cb.dup(); int nextScopeLocal = scopeSlots[curScopeLocalIdx++]; // call acquire first here. So that if it fails, we don't call release - cb.invokevirtual(CD_MemorySessionImpl, "acquire0", MTD_ACQUIRE0); // call acquire on the other - cb.storeLocal(REFERENCE, nextScopeLocal); // store off one to release later + cb.invokevirtual(CD_MemorySessionImpl, "acquire0", MTD_ACQUIRE0) // call acquire on the other + .astore(nextScopeLocal); // store off one to release later if (hasOtherScopes) { // avoid ASM generating a bunch of nops for the dead code - cb.goto_(end); - - cb.labelBinding(skipAcquire); - cb.pop(); // drop scope + cb.goto_(end) + .labelBinding(skipAcquire) + .pop(); // drop scope } cb.labelBinding(end); @@ -529,10 +527,10 @@ public class BindingSpecializer { private void emitReleaseScopes() { for (int scopeLocal : scopeSlots) { - cb.loadLocal(REFERENCE, scopeLocal); - cb.ifThen(Opcode.IFNONNULL, ifCb -> { - ifCb.loadLocal(REFERENCE, scopeLocal); - ifCb.invokevirtual(CD_MemorySessionImpl, "release0", MTD_RELEASE0); + cb.aload(scopeLocal) + .ifThen(Opcode.IFNONNULL, ifCb -> { + ifCb.aload(scopeLocal) + .invokevirtual(CD_MemorySessionImpl, "release0", MTD_RELEASE0); }); } } @@ -551,28 +549,28 @@ public class BindingSpecializer { private void emitLoadInternalSession() { assert contextIdx != -1; - cb.loadLocal(REFERENCE, contextIdx); - cb.checkcast(CD_Arena); - cb.invokeinterface(CD_Arena, "scope", MTD_SCOPE); - cb.checkcast(CD_MemorySessionImpl); + cb.aload(contextIdx) + .checkcast(CD_Arena) + .invokeinterface(CD_Arena, "scope", MTD_SCOPE) + .checkcast(CD_MemorySessionImpl); } private void emitLoadInternalAllocator() { assert contextIdx != -1; - cb.loadLocal(REFERENCE, contextIdx); + cb.aload(contextIdx); } private void emitCloseContext() { assert contextIdx != -1; - cb.loadLocal(REFERENCE, contextIdx); - cb.checkcast(CD_Arena); - cb.invokeinterface(CD_Arena, "close", MTD_CLOSE); + cb.aload(contextIdx) + .checkcast(CD_Arena) + .invokeinterface(CD_Arena, "close", MTD_CLOSE); } private void emitBoxAddress(BoxAddress boxAddress) { popType(long.class); - cb.loadConstant(boxAddress.size()); - cb.loadConstant(boxAddress.align()); + cb.loadConstant(boxAddress.size()) + .loadConstant(boxAddress.align()); if (needsSession()) { emitLoadInternalSession(); cb.invokestatic(CD_Utils, "longToAddress", MTD_LONG_TO_ADDRESS_SCOPE); @@ -585,7 +583,7 @@ public class BindingSpecializer { private void emitAllocBuffer(Allocate binding) { if (callingSequence.forDowncall()) { assert returnAllocatorIdx != -1; - cb.loadLocal(REFERENCE, returnAllocatorIdx); + cb.aload(returnAllocatorIdx); } else { emitLoadInternalAllocator(); } @@ -607,8 +605,8 @@ public class BindingSpecializer { cb.storeLocal(storeTypeKind, valueIdx); ClassDesc valueLayoutType = emitLoadLayoutConstant(storeType); - cb.loadConstant(offset); - cb.loadLocal(storeTypeKind, valueIdx); + cb.loadConstant(offset) + .loadLocal(storeTypeKind, valueIdx); MethodTypeDesc descriptor = MethodTypeDesc.of(CD_void, valueLayoutType, CD_long, classDesc(storeType)); cb.invokeinterface(CD_MemorySegment, "set", descriptor); } else { @@ -619,9 +617,9 @@ public class BindingSpecializer { assert storeType == long.class; // chunking only for int and long } int longValueIdx = cb.allocateLocal(LONG); - cb.storeLocal(LONG, longValueIdx); + cb.lstore(longValueIdx); int writeAddrIdx = cb.allocateLocal(REFERENCE); - cb.storeLocal(REFERENCE, writeAddrIdx); + cb.astore(writeAddrIdx); int remaining = byteWidth; int chunkOffset = 0; @@ -648,25 +646,25 @@ public class BindingSpecializer { //int writeChunk = (int) (((0xFFFF_FFFFL << shiftAmount) & longValue) >>> shiftAmount); int shiftAmount = chunkOffset * Byte.SIZE; mask = mask << shiftAmount; - cb.loadLocal(LONG, longValueIdx); - cb.loadConstant(mask); - cb.land(); + cb.lload(longValueIdx) + .loadConstant(mask) + .land(); if (shiftAmount != 0) { - cb.loadConstant(shiftAmount); - cb.lushr(); + cb.loadConstant(shiftAmount) + .lushr(); } cb.l2i(); TypeKind chunkStoreTypeKind = TypeKind.from(chunkStoreType); int chunkIdx = cb.allocateLocal(chunkStoreTypeKind); - cb.storeLocal(chunkStoreTypeKind, chunkIdx); + cb.storeLocal(chunkStoreTypeKind, chunkIdx) // chunk done, now write it //writeAddress.set(JAVA_SHORT_UNALIGNED, offset, writeChunk); - cb.loadLocal(REFERENCE, writeAddrIdx); + .aload(writeAddrIdx); ClassDesc valueLayoutType = emitLoadLayoutConstant(chunkStoreType); long writeOffset = offset + SharedUtils.pickChunkOffset(chunkOffset, byteWidth, chunkSize); - cb.loadConstant(writeOffset); - cb.loadLocal(chunkStoreTypeKind, chunkIdx); + cb.loadConstant(writeOffset) + .loadLocal(chunkStoreTypeKind, chunkIdx); MethodTypeDesc descriptor = MethodTypeDesc.of(CD_void, valueLayoutType, CD_long, classDesc(chunkStoreType)); cb.invokeinterface(CD_MemorySegment, "set", descriptor); @@ -690,16 +688,16 @@ public class BindingSpecializer { if (!callingSequence.needsReturnBuffer()) { emitSaveReturnValue(storeType); } else { - int valueIdx = cb.allocateLocal(storeTypeKind); - cb.storeLocal(storeTypeKind, valueIdx); // store away the stored value, need it later - assert returnBufferIdx != -1; - cb.loadLocal(REFERENCE, returnBufferIdx); + int valueIdx = cb.allocateLocal(storeTypeKind); + cb.storeLocal(storeTypeKind, valueIdx) // store away the stored value, need it later + .aload(returnBufferIdx); ClassDesc valueLayoutType = emitLoadLayoutConstant(storeType); - cb.loadConstant(retBufOffset); - cb.loadLocal(storeTypeKind, valueIdx); - MethodTypeDesc descriptor = MethodTypeDesc.of(CD_void, valueLayoutType, CD_long, classDesc(storeType)); - cb.invokeinterface(CD_MemorySegment, "set", descriptor); + cb.loadConstant(retBufOffset) + .loadLocal(storeTypeKind, valueIdx) + .invokeinterface(CD_MemorySegment, + "set", + MethodTypeDesc.of(CD_void, valueLayoutType, CD_long, classDesc(storeType))); retBufOffset += abi.arch.typeSize(vmStore.storage().type()); } } @@ -714,11 +712,12 @@ public class BindingSpecializer { emitRestoreReturnValue(loadType); } else { assert returnBufferIdx != -1; - cb.loadLocal(REFERENCE, returnBufferIdx); + cb.aload(returnBufferIdx); ClassDesc valueLayoutType = emitLoadLayoutConstant(loadType); - cb.loadConstant(retBufOffset); - MethodTypeDesc descriptor = MethodTypeDesc.of(classDesc(loadType), valueLayoutType, CD_long); - cb.invokeinterface(CD_MemorySegment, "get", descriptor); + cb.loadConstant(retBufOffset) + .invokeinterface(CD_MemorySegment, + "get", + MethodTypeDesc.of(classDesc(loadType), valueLayoutType, CD_long)); retBufOffset += abi.arch.typeSize(vmLoad.storage().type()); pushType(loadType); } @@ -736,15 +735,15 @@ public class BindingSpecializer { private void emitShiftLeft(ShiftLeft shiftLeft) { popType(long.class); - cb.loadConstant(shiftLeft.shiftAmount() * Byte.SIZE); - cb.lshl(); + cb.loadConstant(shiftLeft.shiftAmount() * Byte.SIZE) + .lshl(); pushType(long.class); } private void emitShiftRight(ShiftRight shiftRight) { popType(long.class); - cb.loadConstant(shiftRight.shiftAmount() * Byte.SIZE); - cb.lushr(); + cb.loadConstant(shiftRight.shiftAmount() * Byte.SIZE) + .lushr(); pushType(long.class); } @@ -758,11 +757,10 @@ public class BindingSpecializer { // implement least significant byte non-zero test // select first byte - cb.loadConstant(0xFF); - cb.iand(); - - // convert to boolean - cb.invokestatic(CD_Utils, "byteToBoolean", MTD_BYTE_TO_BOOLEAN); + cb.loadConstant(0xFF) + .iand() + // convert to boolean + .invokestatic(CD_Utils, "byteToBoolean", MTD_BYTE_TO_BOOLEAN); } case INT_TO_BYTE -> cb.i2b(); case INT_TO_CHAR -> cb.i2c(); @@ -782,8 +780,8 @@ public class BindingSpecializer { private void emitSegmentBase() { popType(MemorySegment.class); - cb.checkcast(CD_AbstractMemorySegmentImpl); - cb.invokevirtual(CD_AbstractMemorySegmentImpl, "unsafeGetBase", MTD_UNSAFE_GET_BASE); + cb.checkcast(CD_AbstractMemorySegmentImpl) + .invokevirtual(CD_AbstractMemorySegmentImpl, "unsafeGetBase", MTD_UNSAFE_GET_BASE); pushType(Object.class); } @@ -791,11 +789,11 @@ public class BindingSpecializer { popType(MemorySegment.class); if (!segmentOffset.allowHeap()) { - cb.dup(); - cb.invokestatic(CD_SharedUtils, "checkNative", MTD_CHECK_NATIVE); + cb.dup() + .invokestatic(CD_SharedUtils, "checkNative", MTD_CHECK_NATIVE); } - cb.checkcast(CD_AbstractMemorySegmentImpl); - cb.invokevirtual(CD_AbstractMemorySegmentImpl, "unsafeGetOffset", MTD_UNSAFE_GET_OFFSET); + cb.checkcast(CD_AbstractMemorySegmentImpl) + .invokevirtual(CD_AbstractMemorySegmentImpl, "unsafeGetOffset", MTD_UNSAFE_GET_OFFSET); pushType(long.class); } @@ -809,17 +807,17 @@ public class BindingSpecializer { if (SharedUtils.isPowerOfTwo(byteWidth)) { ClassDesc valueLayoutType = emitLoadLayoutConstant(loadType); - cb.loadConstant(offset); - MethodTypeDesc descriptor = MethodTypeDesc.of(classDesc(loadType), valueLayoutType, CD_long); - cb.invokeinterface(CD_MemorySegment, "get", descriptor); + cb.loadConstant(offset) + .invokeinterface(CD_MemorySegment, + "get", + MethodTypeDesc.of(classDesc(loadType), valueLayoutType, CD_long)); } else { // chunked int readAddrIdx = cb.allocateLocal(REFERENCE); - cb.storeLocal(REFERENCE, readAddrIdx); - - cb.loadConstant(0L); // result + cb.astore(readAddrIdx) + .loadConstant(0L); // result int resultIdx = cb.allocateLocal(LONG); - cb.storeLocal(LONG, resultIdx); + cb.lstore(resultIdx); int remaining = byteWidth; int chunkOffset = 0; @@ -848,30 +846,30 @@ public class BindingSpecializer { throw new IllegalStateException("Unexpected chunk size for chunked write: " + chunkSize); } // read from segment - cb.loadLocal(REFERENCE, readAddrIdx); + cb.aload(readAddrIdx); ClassDesc valueLayoutType = emitLoadLayoutConstant(chunkType); MethodTypeDesc descriptor = MethodTypeDesc.of(classDesc(chunkType), valueLayoutType, CD_long); long readOffset = offset + SharedUtils.pickChunkOffset(chunkOffset, byteWidth, chunkSize); - cb.loadConstant(readOffset); - cb.invokeinterface(CD_MemorySegment, "get", descriptor); - cb.invokestatic(toULongHolder, "toUnsignedLong", toULongDescriptor); + cb.loadConstant(readOffset) + .invokeinterface(CD_MemorySegment, "get", descriptor) + .invokestatic(toULongHolder, "toUnsignedLong", toULongDescriptor); // shift to right offset int shiftAmount = chunkOffset * Byte.SIZE; if (shiftAmount != 0) { - cb.loadConstant(shiftAmount); - cb.lshl(); + cb.loadConstant(shiftAmount) + .lshl(); } // add to result - cb.loadLocal(LONG, resultIdx); - cb.lor(); - cb.storeLocal(LONG, resultIdx); + cb.lload(resultIdx) + .lor() + .lstore(resultIdx); remaining -= chunkSize; chunkOffset += chunkSize; } while (remaining != 0); - cb.loadLocal(LONG, resultIdx); + cb.lload(resultIdx); if (loadType == int.class) { cb.l2i(); } else { @@ -898,19 +896,18 @@ public class BindingSpecializer { emitAllocateCall(size, alignment); cb.dup(); int storeIdx = cb.allocateLocal(REFERENCE); - cb.storeLocal(REFERENCE, storeIdx); - cb.loadConstant(0L); - cb.loadConstant(size); - cb.invokestatic(CD_MemorySegment, "copy", MTD_COPY, true); - - cb.loadLocal(REFERENCE, storeIdx); + cb.astore(storeIdx) + .loadConstant(0L) + .loadConstant(size) + .invokestatic(CD_MemorySegment, "copy", MTD_COPY, true) + .aload(storeIdx); pushType(MemorySegment.class); } private void emitAllocateCall(long size, long alignment) { - cb.loadConstant(size); - cb.loadConstant(alignment); - cb.invokeinterface(CD_SegmentAllocator, "allocate", MTD_ALLOCATE); + cb.loadConstant(size) + .loadConstant(alignment) + .invokeinterface(CD_SegmentAllocator, "allocate", MTD_ALLOCATE); } private ClassDesc emitLoadLayoutConstant(Class type) { diff --git a/src/java.base/share/classes/jdk/internal/foreign/abi/DowncallLinker.java b/src/java.base/share/classes/jdk/internal/foreign/abi/DowncallLinker.java index 44fee62cb6f..c56cca30912 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/abi/DowncallLinker.java +++ b/src/java.base/share/classes/jdk/internal/foreign/abi/DowncallLinker.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ package jdk.internal.foreign.abi; import jdk.internal.access.JavaLangInvokeAccess; import jdk.internal.access.SharedSecrets; +import jdk.internal.invoke.MhUtil; import sun.security.action.GetPropertyAction; import java.lang.foreign.AddressLayout; @@ -38,7 +39,6 @@ import java.lang.invoke.MethodType; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import java.util.Map; import java.util.stream.Stream; import jdk.internal.foreign.AbstractMemorySegmentImpl; @@ -56,18 +56,11 @@ public class DowncallLinker { private static final JavaLangInvokeAccess JLIA = SharedSecrets.getJavaLangInvokeAccess(); - private static final MethodHandle MH_INVOKE_INTERP_BINDINGS; - private static final MethodHandle EMPTY_OBJECT_ARRAY_HANDLE = MethodHandles.constant(Object[].class, new Object[0]); + private static final MethodHandle MH_INVOKE_INTERP_BINDINGS = MhUtil.findVirtual( + MethodHandles.lookup(), DowncallLinker.class, "invokeInterpBindings", + methodType(Object.class, SegmentAllocator.class, Object[].class, InvocationData.class)); - static { - try { - MethodHandles.Lookup lookup = MethodHandles.lookup(); - MH_INVOKE_INTERP_BINDINGS = lookup.findVirtual(DowncallLinker.class, "invokeInterpBindings", - methodType(Object.class, SegmentAllocator.class, Object[].class, InvocationData.class)); - } catch (ReflectiveOperationException e) { - throw new RuntimeException(e); - } - } + private static final MethodHandle EMPTY_OBJECT_ARRAY_HANDLE = MethodHandles.constant(Object[].class, new Object[0]); private final ABIDescriptor abi; private final CallingSequence callingSequence; diff --git a/src/java.base/share/classes/jdk/internal/foreign/layout/AbstractLayout.java b/src/java.base/share/classes/jdk/internal/foreign/layout/AbstractLayout.java index 796f0027158..b1821ba1d1a 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/layout/AbstractLayout.java +++ b/src/java.base/share/classes/jdk/internal/foreign/layout/AbstractLayout.java @@ -27,6 +27,7 @@ package jdk.internal.foreign.layout; import jdk.internal.foreign.LayoutPath; import jdk.internal.foreign.Utils; +import jdk.internal.invoke.MhUtil; import java.lang.foreign.GroupLayout; import java.lang.foreign.MemoryLayout; @@ -157,15 +158,9 @@ public abstract sealed class AbstractLayout & Memory public MethodHandle scaleHandle() { class Holder { - static final MethodHandle MH_SCALE; - static { - try { - MH_SCALE = MethodHandles.lookup().findVirtual(MemoryLayout.class, "scale", - MethodType.methodType(long.class, long.class, long.class)); - } catch (ReflectiveOperationException e) { - throw new ExceptionInInitializerError(e); - } - } + static final MethodHandle MH_SCALE = MhUtil.findVirtual( + MethodHandles.lookup(), MemoryLayout.class, "scale", + MethodType.methodType(long.class, long.class, long.class)); } return Holder.MH_SCALE.bindTo(this); } diff --git a/src/java.base/share/classes/jdk/internal/invoke/MhUtil.java b/src/java.base/share/classes/jdk/internal/invoke/MhUtil.java new file mode 100644 index 00000000000..16a4e10221c --- /dev/null +++ b/src/java.base/share/classes/jdk/internal/invoke/MhUtil.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +package jdk.internal.invoke; + +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; +import java.lang.invoke.MethodType; +import java.lang.invoke.VarHandle; + +/** + * Static factories for certain VarHandle/MethodHandle variants. + *

                + * The methods will throw an {@link InternalError} if the lookup fails. + *

                + * Here is an example of how one of these methods could be used: + * {@snippet lang=java + * static MethodHandle BAR_HANDLE = + * MhUtil.findVirtual(MethodHandles.lookup(), + * Foo.class,"bar",MethodType.methodType(int.class)); + * } + */ +public final class MhUtil { + + private MhUtil() {} + + public static VarHandle findVarHandle(MethodHandles.Lookup lookup, + String name, + Class type) { + return findVarHandle(lookup, lookup.lookupClass(), name, type); + } + + public static VarHandle findVarHandle(MethodHandles.Lookup lookup, + Class recv, + String name, + Class type) { + try { + return lookup.findVarHandle(recv, name, type); + } catch (ReflectiveOperationException e) { + throw new InternalError(e); + } + } + + + public static MethodHandle findVirtual(MethodHandles.Lookup lookup, + Class refc, + String name, + MethodType type) { + try { + return lookup.findVirtual(refc, name, type); + } catch (ReflectiveOperationException e) { + throw new InternalError(e); + } + } + +} diff --git a/src/java.base/share/classes/jdk/internal/loader/BuiltinClassLoader.java b/src/java.base/share/classes/jdk/internal/loader/BuiltinClassLoader.java index 1f7df79009f..84e5c50672d 100644 --- a/src/java.base/share/classes/jdk/internal/loader/BuiltinClassLoader.java +++ b/src/java.base/share/classes/jdk/internal/loader/BuiltinClassLoader.java @@ -1084,5 +1084,8 @@ public class BuiltinClassLoader private void resetArchivedStates() { ucp = null; resourceCache = null; + if (!moduleToReader.isEmpty()) { + moduleToReader.clear(); + } } } diff --git a/src/java.base/share/classes/jdk/internal/loader/ClassLoaders.java b/src/java.base/share/classes/jdk/internal/loader/ClassLoaders.java index 7b0f4d13e40..ab4aa3fb907 100644 --- a/src/java.base/share/classes/jdk/internal/loader/ClassLoaders.java +++ b/src/java.base/share/classes/jdk/internal/loader/ClassLoaders.java @@ -210,13 +210,6 @@ public class ClassLoaders { protected Package defineOrCheckPackage(String pn, Manifest man, URL url) { return super.defineOrCheckPackage(pn, man, url); } - - /** - * Called by the VM, during -Xshare:dump - */ - private void resetArchivedStates() { - setClassPath(null); - } } /** diff --git a/src/java.base/share/classes/jdk/internal/misc/ThreadFlock.java b/src/java.base/share/classes/jdk/internal/misc/ThreadFlock.java index e9c75d4a3b2..8bf38b79734 100644 --- a/src/java.base/share/classes/jdk/internal/misc/ThreadFlock.java +++ b/src/java.base/share/classes/jdk/internal/misc/ThreadFlock.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,6 +36,7 @@ import java.util.concurrent.locks.LockSupport; import java.util.stream.Stream; import jdk.internal.access.JavaLangAccess; import jdk.internal.access.SharedSecrets; +import jdk.internal.invoke.MhUtil; import jdk.internal.vm.ScopedValueContainer; import jdk.internal.vm.ThreadContainer; import jdk.internal.vm.ThreadContainers; @@ -84,13 +85,9 @@ public class ThreadFlock implements AutoCloseable { private static final VarHandle THREAD_COUNT; private static final VarHandle PERMIT; static { - try { - MethodHandles.Lookup l = MethodHandles.lookup(); - THREAD_COUNT = l.findVarHandle(ThreadFlock.class, "threadCount", int.class); - PERMIT = l.findVarHandle(ThreadFlock.class, "permit", boolean.class); - } catch (Exception e) { - throw new InternalError(e); - } + MethodHandles.Lookup l = MethodHandles.lookup(); + THREAD_COUNT = MhUtil.findVarHandle(l, "threadCount", int.class); + PERMIT = MhUtil.findVarHandle(l, "permit", boolean.class); } private final Set threads = ConcurrentHashMap.newKeySet(); diff --git a/src/java.base/share/classes/jdk/internal/misc/VM.java b/src/java.base/share/classes/jdk/internal/misc/VM.java index de6f011fe8f..1c31ef5a184 100644 --- a/src/java.base/share/classes/jdk/internal/misc/VM.java +++ b/src/java.base/share/classes/jdk/internal/misc/VM.java @@ -28,6 +28,7 @@ package jdk.internal.misc; import static java.lang.Thread.State.*; import java.io.PrintStream; +import java.lang.classfile.ClassFile; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -158,10 +159,6 @@ public class VM { return pageAlignDirectMemory; } - private static int classFileMajorVersion; - private static int classFileMinorVersion; - private static final int PREVIEW_MINOR_VERSION = 65535; - /** * Tests if the given version is a supported {@code class} * file version. @@ -175,11 +172,11 @@ public class VM { * @jvms 4.1 Table 4.1-A. class file format major versions */ public static boolean isSupportedClassFileVersion(int major, int minor) { - if (major < 45 || major > classFileMajorVersion) return false; + if (major < ClassFile.JAVA_1_VERSION || major > ClassFile.latestMajorVersion()) return false; // for major version is between 45 and 55 inclusive, the minor version may be any value - if (major < 56) return true; + if (major < ClassFile.JAVA_12_VERSION) return true; // otherwise, the minor version must be 0 or 65535 - return minor == 0 || minor == PREVIEW_MINOR_VERSION; + return minor == 0 || (minor == ClassFile.PREVIEW_MINOR_VERSION && major == ClassFile.latestMajorVersion()); } /** @@ -189,12 +186,8 @@ public class VM { * major.minor version >= 53.0 */ public static boolean isSupportedModuleDescriptorVersion(int major, int minor) { - if (major < 53 || major > classFileMajorVersion) return false; - // for major version is between 45 and 55 inclusive, the minor version may be any value - if (major < 56) return true; - // otherwise, the minor version must be 0 or 65535 - // preview features do not apply to module-info.class but JVMS allows it - return minor == 0 || minor == PREVIEW_MINOR_VERSION; + if (major < ClassFile.JAVA_9_VERSION) return false; + return isSupportedClassFileVersion(major, minor); } /** @@ -271,15 +264,6 @@ public class VM { s = props.get("sun.nio.PageAlignDirectMemory"); if ("true".equals(s)) pageAlignDirectMemory = true; - - s = props.get("java.class.version"); - int index = s.indexOf('.'); - try { - classFileMajorVersion = Integer.parseInt(s.substring(0, index)); - classFileMinorVersion = Integer.parseInt(s.substring(index + 1)); - } catch (NumberFormatException e) { - throw new InternalError(e); - } } // Initialize any miscellaneous operating system settings that need to be diff --git a/src/java.base/share/classes/jdk/internal/misc/X-ScopedMemoryAccess.java.template b/src/java.base/share/classes/jdk/internal/misc/X-ScopedMemoryAccess.java.template index e3f8787e9e6..a1116e1df38 100644 --- a/src/java.base/share/classes/jdk/internal/misc/X-ScopedMemoryAccess.java.template +++ b/src/java.base/share/classes/jdk/internal/misc/X-ScopedMemoryAccess.java.template @@ -34,6 +34,7 @@ import java.lang.ref.Reference; import java.io.FileDescriptor; import java.util.function.Supplier; +import jdk.internal.access.foreign.MappedMemoryUtilsProxy; import jdk.internal.access.JavaNioAccess; import jdk.internal.access.SharedSecrets; import jdk.internal.foreign.AbstractMemorySegmentImpl; @@ -237,84 +238,84 @@ public class ScopedMemoryAccess { } @ForceInline - public boolean isLoaded(MemorySessionImpl session, long address, boolean isSync, long size) { + public boolean isLoaded(MemorySessionImpl session, MappedMemoryUtilsProxy mappedUtils, long address, boolean isSync, long size) { try { - return isLoadedInternal(session, address, isSync, size); + return isLoadedInternal(session, mappedUtils, address, isSync, size); } catch (ScopedAccessError ex) { throw ex.newRuntimeException(); } } @ForceInline @Scoped - public boolean isLoadedInternal(MemorySessionImpl session, long address, boolean isSync, long size) { + public boolean isLoadedInternal(MemorySessionImpl session, MappedMemoryUtilsProxy mappedUtils, long address, boolean isSync, long size) { try { if (session != null) { session.checkValidStateRaw(); } - return SharedSecrets.getJavaNioAccess().isLoaded(address, isSync, size); + return mappedUtils.isLoaded(address, isSync, size); } finally { Reference.reachabilityFence(session); } } @ForceInline - public void load(MemorySessionImpl session, long address, boolean isSync, long size) { + public void load(MemorySessionImpl session, MappedMemoryUtilsProxy mappedUtils, long address, boolean isSync, long size) { try { - loadInternal(session, address, isSync, size); + loadInternal(session, mappedUtils, address, isSync, size); } catch (ScopedAccessError ex) { throw ex.newRuntimeException(); } } @ForceInline @Scoped - public void loadInternal(MemorySessionImpl session, long address, boolean isSync, long size) { + public void loadInternal(MemorySessionImpl session, MappedMemoryUtilsProxy mappedUtils, long address, boolean isSync, long size) { try { if (session != null) { session.checkValidStateRaw(); } - SharedSecrets.getJavaNioAccess().load(address, isSync, size); + mappedUtils.load(address, isSync, size); } finally { Reference.reachabilityFence(session); } } @ForceInline - public void unload(MemorySessionImpl session, long address, boolean isSync, long size) { + public void unload(MemorySessionImpl session, MappedMemoryUtilsProxy mappedUtils, long address, boolean isSync, long size) { try { - unloadInternal(session, address, isSync, size); + unloadInternal(session, mappedUtils, address, isSync, size); } catch (ScopedAccessError ex) { throw ex.newRuntimeException(); } } @ForceInline @Scoped - public void unloadInternal(MemorySessionImpl session, long address, boolean isSync, long size) { + public void unloadInternal(MemorySessionImpl session, MappedMemoryUtilsProxy mappedUtils, long address, boolean isSync, long size) { try { if (session != null) { session.checkValidStateRaw(); } - SharedSecrets.getJavaNioAccess().unload(address, isSync, size); + mappedUtils.unload(address, isSync, size); } finally { Reference.reachabilityFence(session); } } @ForceInline - public void force(MemorySessionImpl session, FileDescriptor fd, long address, boolean isSync, long index, long length) { + public void force(MemorySessionImpl session, MappedMemoryUtilsProxy mappedUtils, FileDescriptor fd, long address, boolean isSync, long index, long length) { try { - forceInternal(session, fd, address, isSync, index, length); + forceInternal(session, mappedUtils, fd, address, isSync, index, length); } catch (ScopedAccessError ex) { throw ex.newRuntimeException(); } } @ForceInline @Scoped - public void forceInternal(MemorySessionImpl session, FileDescriptor fd, long address, boolean isSync, long index, long length) { + public void forceInternal(MemorySessionImpl session, MappedMemoryUtilsProxy mappedUtils, FileDescriptor fd, long address, boolean isSync, long index, long length) { try { if (session != null) { session.checkValidStateRaw(); } - SharedSecrets.getJavaNioAccess().force(fd, address, isSync, index, length); + mappedUtils.force(fd, address, isSync, index, length); } finally { Reference.reachabilityFence(session); } diff --git a/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java b/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java index facff0d6fdc..656104e2455 100644 --- a/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java +++ b/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java @@ -33,6 +33,7 @@ import java.lang.module.ModuleFinder; import java.lang.module.ModuleReference; import java.lang.module.ResolvedModule; import java.net.URI; +import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; import java.util.Collections; @@ -139,7 +140,6 @@ public final class ModuleBootstrap { */ private static boolean canUseArchivedBootLayer() { return getProperty("jdk.module.upgrade.path") == null && - getProperty("jdk.module.path") == null && getProperty("jdk.module.patch.0") == null && // --patch-module getProperty("jdk.module.addmods.0") == null && // --add-modules getProperty("jdk.module.limitmods") == null && // --limit-modules @@ -203,14 +203,14 @@ public final class ModuleBootstrap { SystemModules systemModules = null; ModuleFinder systemModuleFinder; - boolean haveModulePath = (appModulePath != null || upgradeModulePath != null); + boolean haveUpgradeModulePath = (upgradeModulePath != null); + boolean haveModulePath = (appModulePath != null || haveUpgradeModulePath); boolean needResolution = true; - boolean canArchive = false; - boolean hasSplitPackages; - boolean hasIncubatorModules; + boolean mayContainSplitPackages = true; + boolean mayContainIncubatorModules = true; - // If the java heap was archived at CDS dump time and the environment - // at dump time matches the current environment then use the archived + // If the java heap was archived at CDS dump time, and the environment + // at dump time matches the current environment, then use the archived // system modules and finder. ArchivedModuleGraph archivedModuleGraph = ArchivedModuleGraph.get(mainModule); if (archivedModuleGraph != null @@ -219,18 +219,20 @@ public final class ModuleBootstrap { && limitModules.isEmpty() && !isPatched) { systemModuleFinder = archivedModuleGraph.finder(); - hasSplitPackages = archivedModuleGraph.hasSplitPackages(); - hasIncubatorModules = archivedModuleGraph.hasIncubatorModules(); + mayContainSplitPackages = archivedModuleGraph.hasSplitPackages(); + mayContainIncubatorModules = archivedModuleGraph.hasIncubatorModules(); needResolution = (traceOutput != null); } else { if (!haveModulePath && addModules.isEmpty() && limitModules.isEmpty()) { systemModules = SystemModuleFinders.systemModules(mainModule); - if (systemModules != null && !isPatched) { - needResolution = (traceOutput != null); - if (CDS.isDumpingStaticArchive()) - canArchive = true; + if (systemModules != null && !isPatched && traceOutput == null) { + // use pre-generated configuration + needResolution = false; + mayContainSplitPackages = systemModules.hasSplitPackages(); + mayContainIncubatorModules = systemModules.hasIncubatorModules(); } } + if (systemModules == null) { // all system modules are observable systemModules = SystemModuleFinders.allSystemModules(); @@ -244,8 +246,6 @@ public final class ModuleBootstrap { systemModuleFinder = SystemModuleFinders.ofSystem(); } - hasSplitPackages = systemModules.hasSplitPackages(); - hasIncubatorModules = systemModules.hasIncubatorModules(); // not using the archived module graph - avoid accidental use archivedModuleGraph = null; } @@ -433,7 +433,7 @@ public final class ModuleBootstrap { } // check for split packages in the modules mapped to the built-in loaders - if (hasSplitPackages || isPatched || haveModulePath) { + if (mayContainSplitPackages) { checkSplitPackages(cf, clf); } @@ -449,7 +449,7 @@ public final class ModuleBootstrap { // Step 7: Miscellaneous // check incubating status - if (hasIncubatorModules || haveModulePath) { + if (mayContainIncubatorModules) { checkIncubatingStatus(cf); } @@ -462,31 +462,17 @@ public final class ModuleBootstrap { Counters.add("jdk.module.boot.7.adjustModulesTime"); - // save module finders for later use - if (savedModuleFinder != null) { - unlimitedFinder = new SafeModuleFinder(savedModuleFinder); - if (savedModuleFinder != finder) - limitedFinder = new SafeModuleFinder(finder); - } + // Step 8: CDS dump phase - // If -Xshare:dump and mainModule are specified, check if the mainModule - // is in the runtime image and not on the upgrade module path. If so, - // set canArchive to true so that the module graph can be archived. - if (CDS.isDumpingStaticArchive() && mainModule != null) { - String scheme = systemModuleFinder.find(mainModule) - .stream() - .map(ModuleReference::location) - .flatMap(Optional::stream) - .findAny() - .map(URI::getScheme) - .orElse(null); - if ("jrt".equalsIgnoreCase(scheme)) { - canArchive = true; - } - } + if (CDS.isDumpingStaticArchive() + && !haveUpgradeModulePath + && addModules.isEmpty() + && allJrtOrModularJar(cf)) { + assert !isPatched; - // Archive module graph and boot layer can be archived at CDS dump time. - if (canArchive) { + // Archive module graph and maybe boot layer + boolean hasSplitPackages = containsSplitPackages(cf); + boolean hasIncubatorModules = containsIncubatorModule(cf); ArchivedModuleGraph.archive(hasSplitPackages, hasIncubatorModules, systemModuleFinder, @@ -498,6 +484,13 @@ public final class ModuleBootstrap { } } + // save module finders for later use + if (savedModuleFinder != null) { + unlimitedFinder = new SafeModuleFinder(savedModuleFinder); + if (savedModuleFinder != finder) + limitedFinder = new SafeModuleFinder(finder); + } + return bootLayer; } @@ -522,8 +515,41 @@ public final class ModuleBootstrap { } /** - * Checks for split packages between modules defined to the built-in class - * loaders. + * Returns true if all modules in the configuration are in the run-time image or + * modular JAR files. + */ + private static boolean allJrtOrModularJar(Configuration cf) { + return !cf.modules().stream() + .map(m -> m.reference().location().orElseThrow()) + .anyMatch(uri -> !uri.getScheme().equalsIgnoreCase("jrt") + && !isJarFile(uri)); + } + + /** + * Returns true if the given URI locates a jar file on the file system. + */ + private static boolean isJarFile(URI uri) { + if ("file".equalsIgnoreCase(uri.getScheme())) { + Path path = Path.of(uri); + return path.toString().endsWith(".jar") && Files.isRegularFile(path); + } else { + return false; + } + } + + /** + * Returns true if the configuration contains modules with overlapping packages. + */ + private static boolean containsSplitPackages(Configuration cf) { + boolean found = cf.modules().stream() + .map(m -> m.reference().descriptor().packages()) + .flatMap(Set::stream) + .allMatch(new HashSet<>()::add); + return !found; + } + + /** + * Checks for split packages between modules defined to the built-in class loaders. */ private static void checkSplitPackages(Configuration cf, Function clf) { @@ -820,7 +846,9 @@ public final class ModuleBootstrap { * Grants native access for the given modules in the given layer. * Warns optionally about modules that were specified, but not present in the layer. */ - private static void addEnableNativeAccess(ModuleLayer layer, Set moduleNames, boolean shouldWarn) { + private static void addEnableNativeAccess(ModuleLayer layer, + Set moduleNames, + boolean shouldWarn) { for (String name : moduleNames) { if (name.equals("ALL-UNNAMED")) { JLA.addEnableNativeAccessToAllUnnamed(); @@ -951,6 +979,15 @@ public final class ModuleBootstrap { return (String) System.getProperties().remove(key); } + /** + * Returns true if the configuration contains an incubator module. + */ + private static boolean containsIncubatorModule(Configuration cf) { + return cf.modules().stream() + .map(ResolvedModule::reference) + .anyMatch(ModuleResolution::hasIncubatingWarning); + } + /** * Checks incubating status of modules in the configuration */ diff --git a/src/java.base/share/classes/jdk/internal/module/ModuleReferences.java b/src/java.base/share/classes/jdk/internal/module/ModuleReferences.java index 346838b47d9..a5ad79eb7c6 100644 --- a/src/java.base/share/classes/jdk/internal/module/ModuleReferences.java +++ b/src/java.base/share/classes/jdk/internal/module/ModuleReferences.java @@ -91,8 +91,19 @@ class ModuleReferences { ModulePatcher patcher, Path file) { URI uri = file.toUri(); - Supplier supplier = () -> new JarModuleReader(file, uri); - HashSupplier hasher = (a) -> ModuleHashes.computeHash(supplier, a); + String fileString = file.toString(); + Supplier supplier = new Supplier<>() { + @Override + public ModuleReader get() { + return new JarModuleReader(fileString, uri); + } + }; + HashSupplier hasher = new HashSupplier() { + @Override + public byte[] generate(String algorithm) { + return ModuleHashes.computeHash(supplier, algorithm); + } + }; return newModule(attrs, uri, supplier, patcher, hasher); } @@ -222,9 +233,9 @@ class ModuleReferences { private final JarFile jf; private final URI uri; - static JarFile newJarFile(Path path) { + static JarFile newJarFile(String path) { try { - return new JarFile(new File(path.toString()), + return new JarFile(new File(path), true, // verify ZipFile.OPEN_READ, JarFile.runtimeVersion()); @@ -233,7 +244,7 @@ class ModuleReferences { } } - JarModuleReader(Path path, URI uri) { + JarModuleReader(String path, URI uri) { this.jf = newJarFile(path); this.uri = uri; } diff --git a/src/java.base/share/classes/jdk/internal/reflect/DirectMethodHandleAccessor.java b/src/java.base/share/classes/jdk/internal/reflect/DirectMethodHandleAccessor.java index f345d4cdb71..54f0c7c563d 100644 --- a/src/java.base/share/classes/jdk/internal/reflect/DirectMethodHandleAccessor.java +++ b/src/java.base/share/classes/jdk/internal/reflect/DirectMethodHandleAccessor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,7 @@ package jdk.internal.reflect; import jdk.internal.access.JavaLangInvokeAccess; import jdk.internal.access.SharedSecrets; +import jdk.internal.invoke.MhUtil; import jdk.internal.misc.VM; import jdk.internal.vm.annotation.ForceInline; import jdk.internal.vm.annotation.Hidden; @@ -310,17 +311,10 @@ class DirectMethodHandleAccessor extends MethodAccessorImpl { } } - static final JavaLangInvokeAccess JLIA; - static final MethodHandle NATIVE_ACCESSOR_INVOKE; - static { - try { - JLIA = SharedSecrets.getJavaLangInvokeAccess(); - NATIVE_ACCESSOR_INVOKE = MethodHandles.lookup().findVirtual(NativeAccessor.class, "invoke", - genericMethodType(1, true)); - } catch (NoSuchMethodException|IllegalAccessException e) { - throw new InternalError(e); - } - } + static final JavaLangInvokeAccess JLIA = SharedSecrets.getJavaLangInvokeAccess(); + static final MethodHandle NATIVE_ACCESSOR_INVOKE = MhUtil.findVirtual( + MethodHandles.lookup(), NativeAccessor.class, "invoke", + genericMethodType(1, true)); } } diff --git a/src/java.base/share/classes/jdk/internal/util/ModifiedUtf.java b/src/java.base/share/classes/jdk/internal/util/ModifiedUtf.java new file mode 100644 index 00000000000..a8d2fe8bb74 --- /dev/null +++ b/src/java.base/share/classes/jdk/internal/util/ModifiedUtf.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2024, Alibaba Group Holding Limited. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +package jdk.internal.util; + +import jdk.internal.vm.annotation.ForceInline; + +/** + * Helper to JDK UTF putChar and Calculate length + * + * @since 24 + */ +public abstract class ModifiedUtf { + private ModifiedUtf() { + } + + @ForceInline + public static int putChar(byte[] buf, int offset, char c) { + if (c != 0 && c < 0x80) { + buf[offset++] = (byte) c; + } else if (c >= 0x800) { + buf[offset ] = (byte) (0xE0 | c >> 12 & 0x0F); + buf[offset + 1] = (byte) (0x80 | c >> 6 & 0x3F); + buf[offset + 2] = (byte) (0x80 | c & 0x3F); + offset += 3; + } else { + buf[offset ] = (byte) (0xC0 | c >> 6 & 0x1F); + buf[offset + 1] = (byte) (0x80 | c & 0x3F); + offset += 2; + } + return offset; + } + + /** + * Calculate the utf length of a string + * @param str input string + * @param countNonZeroAscii the number of non-zero ascii characters in the prefix calculated by JLA.countNonZeroAscii(str) + */ + @ForceInline + public static int utfLen(String str, int countNonZeroAscii) { + int utflen = str.length(); + for (int i = utflen - 1; i >= countNonZeroAscii; i--) { + int c = str.charAt(i); + if (c >= 0x80 || c == 0) + utflen += (c >= 0x800) ? 2 : 1; + } + return utflen; + } +} diff --git a/src/java.base/share/classes/jdk/internal/vm/SharedThreadContainer.java b/src/java.base/share/classes/jdk/internal/vm/SharedThreadContainer.java index 36933ad6769..ef9796b0c7d 100644 --- a/src/java.base/share/classes/jdk/internal/vm/SharedThreadContainer.java +++ b/src/java.base/share/classes/jdk/internal/vm/SharedThreadContainer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,6 +31,7 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Stream; import jdk.internal.access.JavaLangAccess; import jdk.internal.access.SharedSecrets; +import jdk.internal.invoke.MhUtil; /** * A "shared" thread container. A shared thread container doesn't have an owner @@ -41,15 +42,9 @@ public class SharedThreadContainer extends ThreadContainer implements AutoClosea private static final VarHandle CLOSED; private static final VarHandle VIRTUAL_THREADS; static { - try { - MethodHandles.Lookup l = MethodHandles.lookup(); - CLOSED = l.findVarHandle(SharedThreadContainer.class, - "closed", boolean.class); - VIRTUAL_THREADS = l.findVarHandle(SharedThreadContainer.class, - "virtualThreads", Set.class); - } catch (Exception e) { - throw new ExceptionInInitializerError(e); - } + MethodHandles.Lookup l = MethodHandles.lookup(); + CLOSED = MhUtil.findVarHandle(l, "closed", boolean.class); + VIRTUAL_THREADS = MhUtil.findVarHandle(l, "virtualThreads", Set.class); } // name of container, used by toString diff --git a/src/java.base/share/classes/jdk/internal/vm/vector/VectorSupport.java b/src/java.base/share/classes/jdk/internal/vm/vector/VectorSupport.java index ccfa006b102..5c4040d9128 100644 --- a/src/java.base/share/classes/jdk/internal/vm/vector/VectorSupport.java +++ b/src/java.base/share/classes/jdk/internal/vm/vector/VectorSupport.java @@ -263,6 +263,20 @@ public class VectorSupport { return defaultImpl.apply(sh); } + public interface WrapShuffleIndexesOperation> { + SH apply(SH sh); + } + + @IntrinsicCandidate + public static + > + SH wrapShuffleIndexes(Class eClass, Class shClass, SH sh, int length, + WrapShuffleIndexesOperation defaultImpl) { + assert isNonCapturingLambda(defaultImpl) : defaultImpl; + return defaultImpl.apply(sh); + } + /* ============================================================================ */ public interface IndexOperation, S extends VectorSpecies> { @@ -605,6 +619,23 @@ public class VectorSupport { return defaultImpl.apply(v, sh, m); } + public interface VectorSelectFromOp, + M extends VectorMask> { + V apply(V v1, V v2, M m); + } + + @IntrinsicCandidate + public static + , + M extends VectorMask, + E> + V selectFromOp(Class vClass, Class mClass, Class eClass, + int length, V v1, V v2, M m, + VectorSelectFromOp defaultImpl) { + assert isNonCapturingLambda(defaultImpl) : defaultImpl; + return defaultImpl.apply(v1, v2, m); + } + /* ============================================================================ */ public interface VectorBlendOp, diff --git a/src/java.base/share/classes/module-info.java b/src/java.base/share/classes/module-info.java index 74a7451582c..4e43245e520 100644 --- a/src/java.base/share/classes/module-info.java +++ b/src/java.base/share/classes/module-info.java @@ -172,6 +172,7 @@ module java.base { jdk.jartool, jdk.jlink, jdk.jfr, + jdk.management, jdk.net, jdk.sctp, jdk.crypto.cryptoki; diff --git a/src/java.base/share/classes/sun/launcher/resources/launcher.properties b/src/java.base/share/classes/sun/launcher/resources/launcher.properties index 71cdb161fc0..f493dfd36b6 100644 --- a/src/java.base/share/classes/sun/launcher/resources/launcher.properties +++ b/src/java.base/share/classes/sun/launcher/resources/launcher.properties @@ -141,9 +141,6 @@ java.launcher.X.usage=\n\ \ -Xcomp forces compilation of methods on first invocation\n\ \ -Xdebug does nothing; deprecated for removal in a future release.\n\ \ -Xdiag show additional diagnostic messages\n\ -\ -Xfuture enable strictest checks, anticipating future default.\n\ -\ This option is deprecated and may be removed in a\n\ -\ future release.\n\ \ -Xint interpreted mode execution only\n\ \ -Xinternalversion\n\ \ displays more detailed JVM version information than the\n\ diff --git a/src/java.base/share/classes/sun/nio/ch/DatagramChannelImpl.java b/src/java.base/share/classes/sun/nio/ch/DatagramChannelImpl.java index 5fac688b311..9f85aec7cd3 100644 --- a/src/java.base/share/classes/sun/nio/ch/DatagramChannelImpl.java +++ b/src/java.base/share/classes/sun/nio/ch/DatagramChannelImpl.java @@ -68,13 +68,13 @@ import java.util.HashSet; import java.util.Map; import java.util.Objects; import java.util.Set; -import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.ReentrantLock; import java.util.function.Consumer; import jdk.internal.access.JavaNioAccess; import jdk.internal.access.SharedSecrets; import jdk.internal.ref.CleanerFactory; +import jdk.internal.invoke.MhUtil; import sun.net.ResourceManager; import sun.net.ext.ExtendedSocketOptions; import sun.net.util.IPAddressUtil; @@ -149,15 +149,8 @@ class DatagramChannelImpl private InetSocketAddress initialLocalAddress; // Socket adaptor, created lazily - private static final VarHandle SOCKET; - static { - try { - MethodHandles.Lookup l = MethodHandles.lookup(); - SOCKET = l.findVarHandle(DatagramChannelImpl.class, "socket", DatagramSocket.class); - } catch (Exception e) { - throw new InternalError(e); - } - } + private static final VarHandle SOCKET = MhUtil.findVarHandle( + MethodHandles.lookup(), "socket", DatagramSocket.class); private volatile DatagramSocket socket; // Multicast support diff --git a/src/java.base/share/classes/sun/reflect/generics/factory/CoreReflectionFactory.java b/src/java.base/share/classes/sun/reflect/generics/factory/CoreReflectionFactory.java index 0759c83be78..bad68a07cea 100644 --- a/src/java.base/share/classes/sun/reflect/generics/factory/CoreReflectionFactory.java +++ b/src/java.base/share/classes/sun/reflect/generics/factory/CoreReflectionFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -106,7 +106,11 @@ public class CoreReflectionFactory implements GenericsFactory { } public TypeVariable findTypeVariable(String name){ - return getScope().lookup(name); + TypeVariable variable = getScope().lookup(name); + if (variable == null) { + throw new TypeNotPresentException(name, null); + } + return variable; } public Type makeNamedType(String name){ diff --git a/src/java.base/share/classes/sun/security/ec/ed/EdDSAParameters.java b/src/java.base/share/classes/sun/security/ec/ed/EdDSAParameters.java index 6e06a890bbd..ef6720dc033 100644 --- a/src/java.base/share/classes/sun/security/ec/ed/EdDSAParameters.java +++ b/src/java.base/share/classes/sun/security/ec/ed/EdDSAParameters.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,7 @@ package sun.security.ec.ed; import sun.security.ec.ParametersMap; -import sun.security.provider.SHAKE256; +import sun.security.provider.SHA3.SHAKE256; import sun.security.util.ObjectIdentifier; import sun.security.util.KnownOIDs; import sun.security.util.math.*; diff --git a/src/java.base/share/classes/sun/security/pkcs/NamedPKCS8Key.java b/src/java.base/share/classes/sun/security/pkcs/NamedPKCS8Key.java new file mode 100644 index 00000000000..88a2909cfac --- /dev/null +++ b/src/java.base/share/classes/sun/security/pkcs/NamedPKCS8Key.java @@ -0,0 +1,143 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +package sun.security.pkcs; + +import sun.security.util.DerInputStream; +import sun.security.util.DerValue; +import sun.security.x509.AlgorithmId; + +import javax.security.auth.DestroyFailedException; +import java.io.IOException; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; +import java.io.Serial; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; +import java.security.ProviderException; +import java.security.spec.NamedParameterSpec; +import java.util.Arrays; + +/// Represents a private key from an algorithm family that is specialized +/// with a named parameter set. +/// +/// This key is generated by either a [sun.security.provider.NamedKeyPairGenerator] +/// or [sun.security.provider.NamedKeyFactory]. Its [#getAlgorithm] method +/// returns the algorithm family name, while its [#getParams()] method returns +/// the parameter set name as a [NamedParameterSpec] object. The algorithm +/// identifier in the PKCS #8 encoding of the key is always a single OID derived +/// from the parameter set name. +/// +/// @see sun.security.provider.NamedKeyPairGenerator +public final class NamedPKCS8Key extends PKCS8Key { + @Serial + private static final long serialVersionUID = 1L; + + private final String fname; + private final transient NamedParameterSpec paramSpec; + private final byte[] rawBytes; + + private transient boolean destroyed = false; + + /// Ctor from family name, parameter set name, raw key bytes. + /// Key bytes won't be cloned, caller must relinquish ownership + public NamedPKCS8Key(String fname, String pname, byte[] rawBytes) { + this.fname = fname; + this.paramSpec = new NamedParameterSpec(pname); + try { + this.algid = AlgorithmId.get(pname); + } catch (NoSuchAlgorithmException e) { + throw new ProviderException(e); + } + this.rawBytes = rawBytes; + + DerValue val = new DerValue(DerValue.tag_OctetString, rawBytes); + try { + this.key = val.toByteArray(); + } finally { + val.clear(); + } + } + + /// Ctor from family name, and PKCS #8 bytes + public NamedPKCS8Key(String fname, byte[] encoded) throws InvalidKeyException { + super(encoded); + this.fname = fname; + try { + paramSpec = new NamedParameterSpec(algid.getName()); + if (algid.getEncodedParams() != null) { + throw new InvalidKeyException("algorithm identifier has params"); + } + rawBytes = new DerInputStream(key).getOctetString(); + } catch (IOException e) { + throw new InvalidKeyException("Cannot parse input", e); + } + } + + @Override + public String toString() { + // Do not modify: this can be used by earlier JDKs that + // do not have the getParams() method + return paramSpec.getName() + " private key"; + } + + /// Returns the reference to the internal key. Caller must not modify + /// the content or keep a reference. + public byte[] getRawBytes() { + return rawBytes; + } + + @Override + public NamedParameterSpec getParams() { + return paramSpec; + } + + @Override + public String getAlgorithm() { + return fname; + } + + @java.io.Serial + private void readObject(ObjectInputStream stream) + throws IOException, ClassNotFoundException { + throw new InvalidObjectException( + "NamedPKCS8Key keys are not directly deserializable"); + } + + @Override + public void destroy() throws DestroyFailedException { + Arrays.fill(rawBytes, (byte)0); + Arrays.fill(key, (byte)0); + if (encodedKey != null) { + Arrays.fill(encodedKey, (byte)0); + } + destroyed = true; + } + + @Override + public boolean isDestroyed() { + return destroyed; + } +} diff --git a/src/java.base/share/classes/sun/security/pkcs/PKCS7.java b/src/java.base/share/classes/sun/security/pkcs/PKCS7.java index 23925869b9f..324cc3e7cec 100644 --- a/src/java.base/share/classes/sun/security/pkcs/PKCS7.java +++ b/src/java.base/share/classes/sun/security/pkcs/PKCS7.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,7 +38,7 @@ import java.security.*; import java.util.function.Function; import sun.security.jca.JCAUtil; -import sun.security.provider.SHAKE256; +import sun.security.provider.SHA3.SHAKE256; import sun.security.timestamp.*; import sun.security.util.*; import sun.security.x509.*; diff --git a/src/java.base/share/classes/sun/security/pkcs/SignerInfo.java b/src/java.base/share/classes/sun/security/pkcs/SignerInfo.java index ed075354a16..699e68d053c 100644 --- a/src/java.base/share/classes/sun/security/pkcs/SignerInfo.java +++ b/src/java.base/share/classes/sun/security/pkcs/SignerInfo.java @@ -32,7 +32,7 @@ import java.security.cert.*; import java.security.spec.PSSParameterSpec; import java.util.*; -import sun.security.provider.SHAKE256; +import sun.security.provider.SHA3.SHAKE256; import sun.security.timestamp.TimestampToken; import sun.security.util.*; import sun.security.x509.AlgorithmId; diff --git a/src/java.base/share/classes/sun/security/provider/NamedKEM.java b/src/java.base/share/classes/sun/security/provider/NamedKEM.java new file mode 100644 index 00000000000..2731b3460af --- /dev/null +++ b/src/java.base/share/classes/sun/security/provider/NamedKEM.java @@ -0,0 +1,223 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +package sun.security.provider; + +import sun.security.pkcs.NamedPKCS8Key; +import sun.security.x509.NamedX509Key; + +import javax.crypto.DecapsulateException; +import javax.crypto.KEM; +import javax.crypto.KEMSpi; +import javax.crypto.SecretKey; +import javax.crypto.spec.SecretKeySpec; +import java.security.InvalidAlgorithmParameterException; +import java.security.InvalidKeyException; +import java.security.PrivateKey; +import java.security.ProviderException; +import java.security.PublicKey; +import java.security.SecureRandom; +import java.security.spec.AlgorithmParameterSpec; +import java.security.spec.NamedParameterSpec; +import java.util.Arrays; +import java.util.Objects; + +/// A base class for all `KEM` implementations that can be +/// configured with a named parameter set. See [NamedKeyPairGenerator] +/// for more details. +public abstract class NamedKEM implements KEMSpi { + + private final String fname; // family name + private final String[] pnames; // allowed parameter set name (at least one) + + /// Creates a new `NamedKEM` object. + /// + /// @param fname the family name + /// @param pnames the standard parameter set names, at least one is needed. + protected NamedKEM(String fname, String... pnames) { + if (fname == null) { + throw new AssertionError("fname cannot be null"); + } + if (pnames == null || pnames.length == 0) { + throw new AssertionError("pnames cannot be null or empty"); + } + this.fname = fname; + this.pnames = pnames; + } + + @Override + public EncapsulatorSpi engineNewEncapsulator(PublicKey publicKey, + AlgorithmParameterSpec spec, SecureRandom secureRandom) + throws InvalidAlgorithmParameterException, InvalidKeyException { + if (spec != null) { + throw new InvalidAlgorithmParameterException( + "The " + fname + " algorithm does not take any parameters"); + } + // translate also check the key + var nk = (NamedX509Key) new NamedKeyFactory(fname, pnames) + .engineTranslateKey(publicKey); + var pk = nk.getRawBytes(); + return getKeyConsumerImpl(this, nk.getParams(), pk, + implCheckPublicKey(nk.getParams().getName(), pk), secureRandom); + } + + @Override + public DecapsulatorSpi engineNewDecapsulator( + PrivateKey privateKey, AlgorithmParameterSpec spec) + throws InvalidAlgorithmParameterException, InvalidKeyException { + if (spec != null) { + throw new InvalidAlgorithmParameterException( + "The " + fname + " algorithm does not take any parameters"); + } + // translate also check the key + var nk = (NamedPKCS8Key) new NamedKeyFactory(fname, pnames) + .engineTranslateKey(privateKey); + var sk = nk.getRawBytes(); + return getKeyConsumerImpl(this, nk.getParams(), sk, + implCheckPrivateKey(nk.getParams().getName(), sk), null); + } + + // We don't have a flag on whether key is public key or private key. + // The correct method should always be called. + private record KeyConsumerImpl(NamedKEM kem, String name, int sslen, + int clen, byte[] key, Object k2, SecureRandom sr) + implements KEMSpi.EncapsulatorSpi, KEMSpi.DecapsulatorSpi { + @Override + public SecretKey engineDecapsulate(byte[] encapsulation, int from, int to, + String algorithm) throws DecapsulateException { + if (encapsulation.length != clen) { + throw new DecapsulateException("Invalid key encapsulation message length"); + } + var ss = kem.implDecapsulate(name, key, k2, encapsulation); + try { + return new SecretKeySpec(ss, + from, to - from, algorithm); + } finally { + Arrays.fill(ss, (byte)0); + } + } + + @Override + public KEM.Encapsulated engineEncapsulate(int from, int to, String algorithm) { + var enc = kem.implEncapsulate(name, key, k2, sr); + try { + return new KEM.Encapsulated( + new SecretKeySpec(enc[1], + from, to - from, algorithm), + enc[0], + null); + } finally { + Arrays.fill(enc[1], (byte)0); + } + } + + @Override + public int engineSecretSize() { + return sslen; + } + + @Override + public int engineEncapsulationSize() { + return clen; + } + } + + private static KeyConsumerImpl getKeyConsumerImpl(NamedKEM kem, + NamedParameterSpec nps, byte[] key, Object k2, SecureRandom sr) { + String name = nps.getName(); + return new KeyConsumerImpl(kem, name, kem.implSecretSize(name), kem.implEncapsulationSize(name), + key, k2, sr); + } + + /// User-defined encap function. + /// + /// @param name parameter name + /// @param pk public key in raw bytes + /// @param pk2 parsed public key, `null` if none. See [#implCheckPublicKey]. + /// @param sr SecureRandom object, `null` if not initialized + /// @return the key encapsulation message and the shared key (in this order) + /// @throws ProviderException if there is an internal error + protected abstract byte[][] implEncapsulate(String name, byte[] pk, Object pk2, SecureRandom sr); + + /// User-defined decap function. + /// + /// @param name parameter name + /// @param sk private key in raw bytes + /// @param sk2 parsed private key, `null` if none. See [#implCheckPrivateKey]. + /// @param encap the key encapsulation message + /// @return the shared key + /// @throws ProviderException if there is an internal error + /// @throws DecapsulateException if there is another error + protected abstract byte[] implDecapsulate(String name, byte[] sk, Object sk2, byte[] encap) + throws DecapsulateException; + + /// User-defined function returning shared secret key length. + /// + /// @param name parameter name + /// @return shared secret key length + /// @throws ProviderException if there is an internal error + protected abstract int implSecretSize(String name); + + /// User-defined function returning key encapsulation message length. + /// + /// @param name parameter name + /// @return key encapsulation message length + /// @throws ProviderException if there is an internal error + protected abstract int implEncapsulationSize(String name); + + /// User-defined function to validate a public key. + /// + /// This method will be called in `newEncapsulator`. This gives the provider a chance to + /// reject the key so an `InvalidKeyException` can be thrown earlier. + /// An implementation can optionally return a "parsed key" as an `Object` value. + /// This object will be passed into the [#implEncapsulate] method along with the raw key. + /// + /// The default implementation returns `null`. + /// + /// @param name parameter name + /// @param pk public key in raw bytes + /// @return a parsed key, `null` if none. + /// @throws InvalidKeyException if the key is invalid + protected Object implCheckPublicKey(String name, byte[] pk) throws InvalidKeyException { + return null; + } + + /// User-defined function to validate a private key. + /// + /// This method will be called in `newDecapsulator`. This gives the provider a chance to + /// reject the key so an `InvalidKeyException` can be thrown earlier. + /// An implementation can optionally return a "parsed key" as an `Object` value. + /// This object will be passed into the [#implDecapsulate] method along with the raw key. + /// + /// The default implementation returns `null`. + /// + /// @param name parameter name + /// @param sk private key in raw bytes + /// @return a parsed key, `null` if none. + /// @throws InvalidKeyException if the key is invalid + protected Object implCheckPrivateKey(String name, byte[] sk) throws InvalidKeyException { + return null; + } +} diff --git a/src/java.base/share/classes/sun/security/provider/NamedKeyFactory.java b/src/java.base/share/classes/sun/security/provider/NamedKeyFactory.java new file mode 100644 index 00000000000..727358dd074 --- /dev/null +++ b/src/java.base/share/classes/sun/security/provider/NamedKeyFactory.java @@ -0,0 +1,288 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +package sun.security.provider; + +import sun.security.pkcs.NamedPKCS8Key; +import sun.security.util.RawKeySpec; +import sun.security.x509.NamedX509Key; + +import java.security.AsymmetricKey; +import java.security.InvalidKeyException; +import java.security.Key; +import java.security.KeyFactorySpi; +import java.security.PrivateKey; +import java.security.PublicKey; +import java.security.spec.EncodedKeySpec; +import java.security.spec.InvalidKeySpecException; +import java.security.spec.KeySpec; +import java.security.spec.NamedParameterSpec; +import java.security.spec.PKCS8EncodedKeySpec; +import java.security.spec.X509EncodedKeySpec; +import java.util.Arrays; +import java.util.Objects; + +/// A base class for all `KeyFactory` implementations that can be +/// configured with a named parameter set. See [NamedKeyPairGenerator] +/// for more details. +/// +/// This factory supports reading and writing to RAW formats: +/// +/// 1. It reads from a RAW key using `translateKey` if `key.getFormat` is "RAW". +/// 2. It writes to a RAW [EncodedKeySpec] if `getKeySpec(key, EncodedKeySpec.class)` +/// is called. The format of the output is "RAW" and the algorithm is +/// intentionally left unspecified. +/// 3. It reads from and writes to the internal type [RawKeySpec]. +/// +/// When reading from a RAW format, it needs enough info to derive the +/// parameter set name. +public class NamedKeyFactory extends KeyFactorySpi { + + private final String fname; // family name + private final String[] pnames; // allowed parameter set name (at least one) + + /// Creates a new `NamedKeyFactory` object. + /// + /// @param fname the family name + /// @param pnames the standard parameter set names, at least one is needed. + protected NamedKeyFactory(String fname, String... pnames) { + if (fname == null) { + throw new AssertionError("fname cannot be null"); + } + if (pnames == null || pnames.length == 0) { + throw new AssertionError("pnames cannot be null or empty"); + } + this.fname = fname; + this.pnames = pnames; + } + + private String checkName(String name) throws InvalidKeyException { + for (var pname : pnames) { + if (pname.equalsIgnoreCase(name)) { + // return the stored standard name + return pname; + } + } + throw new InvalidKeyException("Unsupported parameter set name: " + name); + } + + @Override + protected PublicKey engineGeneratePublic(KeySpec keySpec) + throws InvalidKeySpecException { + if (keySpec instanceof X509EncodedKeySpec xspec) { + try { + return fromX509(xspec.getEncoded()); + } catch (InvalidKeyException e) { + throw new InvalidKeySpecException(e); + } + } else if (keySpec instanceof RawKeySpec rks) { + if (pnames.length == 1) { + return new NamedX509Key(fname, pnames[0], rks.getKeyArr()); + } else { + throw new InvalidKeySpecException("Parameter set name unavailable"); + } + } else if (keySpec instanceof EncodedKeySpec espec + && espec.getFormat().equalsIgnoreCase("RAW")) { + if (pnames.length == 1) { + return new NamedX509Key(fname, pnames[0], espec.getEncoded()); + } else { + throw new InvalidKeySpecException("Parameter set name unavailable"); + } + } else { + throw new InvalidKeySpecException("Unsupported keyspec: " + keySpec); + } + } + + @Override + protected PrivateKey engineGeneratePrivate(KeySpec keySpec) + throws InvalidKeySpecException { + if (keySpec instanceof PKCS8EncodedKeySpec pspec) { + var bytes = pspec.getEncoded(); + try { + return fromPKCS8(bytes); + } catch (InvalidKeyException e) { + throw new InvalidKeySpecException(e); + } finally { + Arrays.fill(bytes, (byte) 0); + } + } else if (keySpec instanceof RawKeySpec rks) { + if (pnames.length == 1) { + var bytes = rks.getKeyArr(); + try { + return new NamedPKCS8Key(fname, pnames[0], bytes); + } finally { + Arrays.fill(bytes, (byte) 0); + } + } else { + throw new InvalidKeySpecException("Parameter set name unavailable"); + } + } else if (keySpec instanceof EncodedKeySpec espec + && espec.getFormat().equalsIgnoreCase("RAW")) { + if (pnames.length == 1) { + var bytes = espec.getEncoded(); + try { + return new NamedPKCS8Key(fname, pnames[0], bytes); + } finally { + Arrays.fill(bytes, (byte) 0); + } + } else { + throw new InvalidKeySpecException("Parameter set name unavailable"); + } + } else { + throw new InvalidKeySpecException("Unsupported keyspec: " + keySpec); + } + } + + private PrivateKey fromPKCS8(byte[] bytes) + throws InvalidKeyException, InvalidKeySpecException { + var k = new NamedPKCS8Key(fname, bytes); + checkName(k.getParams().getName()); + return k; + } + + private PublicKey fromX509(byte[] bytes) + throws InvalidKeyException, InvalidKeySpecException { + var k = new NamedX509Key(fname, bytes); + checkName(k.getParams().getName()); + return k; + } + + private static class RawEncodedKeySpec extends EncodedKeySpec { + public RawEncodedKeySpec(byte[] encodedKey) { + super(encodedKey); + } + + @Override + public String getFormat() { + return "RAW"; + } + } + + @Override + protected T engineGetKeySpec(Key key, Class keySpec) + throws InvalidKeySpecException { + try { + key = engineTranslateKey(key); + } catch (InvalidKeyException e) { + throw new InvalidKeySpecException(e); + } + // key is now either NamedPKCS8Key or NamedX509Key of permitted param set + if (key instanceof NamedPKCS8Key nk) { + byte[] bytes = null; + try { + if (keySpec == PKCS8EncodedKeySpec.class) { + return keySpec.cast( + new PKCS8EncodedKeySpec(bytes = key.getEncoded())); + } else if (keySpec == RawKeySpec.class) { + return keySpec.cast(new RawKeySpec(nk.getRawBytes())); + } else if (keySpec.isAssignableFrom(EncodedKeySpec.class)) { + return keySpec.cast( + new RawEncodedKeySpec(nk.getRawBytes())); + } else { + throw new InvalidKeySpecException("Unsupported type: " + keySpec); + } + } finally { + if (bytes != null) { + Arrays.fill(bytes, (byte)0); + } + } + } else if (key instanceof NamedX509Key nk) { + if (keySpec == X509EncodedKeySpec.class + && key.getFormat().equalsIgnoreCase("X.509")) { + return keySpec.cast(new X509EncodedKeySpec(key.getEncoded())); + } else if (keySpec == RawKeySpec.class) { + return keySpec.cast(new RawKeySpec(nk.getRawBytes())); + } else if (keySpec.isAssignableFrom(EncodedKeySpec.class)) { + return keySpec.cast(new RawEncodedKeySpec(nk.getRawBytes())); + } else { + throw new InvalidKeySpecException("Unsupported type: " + keySpec); + } + } + throw new AssertionError("No " + keySpec.getName() + " for " + key.getClass()); + } + + @Override + protected Key engineTranslateKey(Key key) throws InvalidKeyException { + if (key == null) { + throw new InvalidKeyException("Key must not be null"); + } + if (key instanceof NamedX509Key nk) { + checkName(nk.getParams().getName()); + return key; + } + if (key instanceof NamedPKCS8Key nk) { + checkName(nk.getParams().getName()); + return key; + } + var format = key.getFormat(); + if (format == null) { + throw new InvalidKeyException("Unextractable key"); + } else if (format.equalsIgnoreCase("RAW")) { + var kAlg = key.getAlgorithm(); + if (key instanceof AsymmetricKey pk) { + String name; + // Three cases that we can find the parameter set name from a RAW key: + // 1. getParams() returns one + // 2. getAlgorithm() returns param set name (some provider does this) + // 3. getAlgorithm() returns family name but this KF is for param set name + if (pk.getParams() instanceof NamedParameterSpec nps) { + name = checkName(nps.getName()); + } else { + if (kAlg.equalsIgnoreCase(fname)) { + if (pnames.length == 1) { + name = pnames[0]; + } else { + throw new InvalidKeyException("No parameter set info"); + } + } else { + name = checkName(kAlg); + } + } + return key instanceof PrivateKey + ? new NamedPKCS8Key(fname, name, key.getEncoded()) + : new NamedX509Key(fname, name, key.getEncoded()); + } else { + throw new InvalidKeyException("Unsupported key type: " + key.getClass()); + } + } else if (format.equalsIgnoreCase("PKCS#8") && key instanceof PrivateKey) { + var bytes = key.getEncoded(); + try { + return fromPKCS8(bytes); + } catch (InvalidKeySpecException e) { + throw new InvalidKeyException("Invalid PKCS#8 key", e); + } finally { + Arrays.fill(bytes, (byte) 0); + } + } else if (format.equalsIgnoreCase("X.509") && key instanceof PublicKey) { + try { + return fromX509(key.getEncoded()); + } catch (InvalidKeySpecException e) { + throw new InvalidKeyException("Invalid X.509 key", e); + } + } else { + throw new InvalidKeyException("Unsupported key format: " + key.getFormat()); + } + } +} diff --git a/src/java.base/share/classes/sun/security/provider/NamedKeyPairGenerator.java b/src/java.base/share/classes/sun/security/provider/NamedKeyPairGenerator.java new file mode 100644 index 00000000000..5be2b2b2a08 --- /dev/null +++ b/src/java.base/share/classes/sun/security/provider/NamedKeyPairGenerator.java @@ -0,0 +1,177 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +package sun.security.provider; + +import sun.security.pkcs.NamedPKCS8Key; +import sun.security.x509.NamedX509Key; + +import java.security.InvalidAlgorithmParameterException; +import java.security.InvalidParameterException; +import java.security.KeyPair; +import java.security.KeyPairGeneratorSpi; +import java.security.ProviderException; +import java.security.SecureRandom; +import java.security.spec.AlgorithmParameterSpec; +import java.security.spec.NamedParameterSpec; +import java.util.Objects; + +/// A base class for all `KeyPairGenerator` implementations that can be +/// configured with a named parameter set. +/// +/// Together with [NamedKeyFactory], [NamedKEM], and [NamedSignature], these +/// classes form a compact framework designed to support any public key +/// algorithm standardized with named parameter sets. In this scenario, +/// the algorithm name is the "family name" and each standardized parameter +/// set has a "parameter set name". Implementations of these classes are able +/// to instantiate a `KeyPairGenerator`, `KeyFactory`, or `KEM` or `Signature` +/// object using either the family name or a parameter set name. All keys used +/// in this context will be of the type [NamedPKCS8Key] or [NamedX509Key], +/// with `getAlgorithm` returning the family name, and `getParams` returning +/// the parameter set name as a [NamedParameterSpec] object. +/// +/// An implementation must include a zero-argument public constructor that +/// calls `super(fname, pnames)`, where `fname` is the family name of the +/// algorithm and `pnames` are its supported parameter set names. `pnames` +/// must contain at least one element. For an implementation of +/// `NamedKeyPairGenerator`, the first element becomes its default parameter +/// set, i.e. the parameter set to be used in key pair generation unless +/// [#initialize(AlgorithmParameterSpec, java.security.SecureRandom)] +/// is called on a different parameter set. +/// +/// An implementation must implement all abstract methods. For all these +/// methods, the implementation must relinquish any "ownership" of any input +/// and output array argument. Precisely, the implementation must not retain +/// any reference to a returning array so that it won't be able to modify its +/// content later. Similarly, the implementation must not modify any input +/// array argument and must not retain any reference to an input array argument +/// after the call. +/// +/// Also, an implementation must not keep any extra copy of a private key. +/// For key generation, the only copy is the one returned in the +/// [#implGenerateKeyPair] call. For all other methods, it must not make +/// a copy of the input private key. A `KEM` implementation also must not +/// keep a copy of the shared secret key, no matter if it's an encapsulator +/// or a decapsulator. Only the code that owns these sensitive data can +/// choose to perform cleanup when it determines they are no longer needed. +/// +/// The `NamedSignature` and `NamedKEM` classes provide `implCheckPublicKey` +/// and `implCheckPrivateKey` methods that allow an implementation to validate +/// a key before using it. An implementation may return a parsed key in +/// a local type, and this parsed key will be passed to an operational method +/// (For example, `implSign`) later. An implementation must not retain +/// a reference of the parsed key. +/// +/// When constructing a [NamedX509Key] or [NamedPKCS8Key] object from raw key +/// bytes, the key bytes are directly referenced within the object, so the +/// caller must not modify them afterward. Similarly, the key's `getRawBytes` +/// method returns direct references to the underlying raw key bytes, meaning +/// the caller must not alter the contents of the returned value. +/// +/// Together, these measures ensure the classes are as efficient as possible, +/// preventing unnecessary array cloning and potential data leaks. While these +/// classes should not be considered immutable, strictly adhering to the rules +/// above will ensure data integrity is maintained. +/// +/// Note: A limitation of `NamedKeyPairGenerator` and `NamedKeyFactory` is +/// that the keys generated by their implementations will always be of type +/// `NamedX509Key` or `NamedPKCS8Key`. Existing implementations of algorithms +/// like EdDSA and XDH have been generating keys implementing `EdECKey` or +/// `XECKey` interfaces, and they are not rewritten with this framework. +/// `NamedParameterSpec` fields not implemented with this framework include +/// Ed25519, Ed448, X25519, and X448. +public abstract class NamedKeyPairGenerator extends KeyPairGeneratorSpi { + + private final String fname; // family name + private final String[] pnames; // allowed parameter set name (at least one) + + protected String name; // init as + private SecureRandom secureRandom; + + /// Creates a new `NamedKeyPairGenerator` object. + /// + /// @param fname the family name + /// @param pnames supported parameter set names, at least one is needed. + /// If multiple, the first one becomes the default parameter set name. + protected NamedKeyPairGenerator(String fname, String... pnames) { + if (fname == null) { + throw new AssertionError("fname cannot be null"); + } + if (pnames == null || pnames.length == 0) { + throw new AssertionError("pnames cannot be null or empty"); + } + this.fname = fname; + this.pnames = pnames; + } + + private String checkName(String name) throws InvalidAlgorithmParameterException { + for (var pname : pnames) { + if (pname.equalsIgnoreCase(name)) { + // return the stored standard name + return pname; + } + } + throw new InvalidAlgorithmParameterException( + "Unsupported parameter set name: " + name); + } + + @Override + public void initialize(AlgorithmParameterSpec params, SecureRandom random) + throws InvalidAlgorithmParameterException { + if (params instanceof NamedParameterSpec spec) { + name = checkName(spec.getName()); + } else { + throw new InvalidAlgorithmParameterException( + "Unsupported AlgorithmParameterSpec: " + params); + } + this.secureRandom = random; + } + + @Override + public void initialize(int keysize, SecureRandom random) { + if (keysize != -1) { + // User can call initialize(-1, sr) to provide a SecureRandom + // without touching the parameter set currently used + throw new InvalidParameterException("keysize not supported"); + } + this.secureRandom = random; + } + + @Override + public KeyPair generateKeyPair() { + String pname = name != null ? name : pnames[0]; + var keys = implGenerateKeyPair(pname, secureRandom); + return new KeyPair(new NamedX509Key(fname, pname, keys[0]), + new NamedPKCS8Key(fname, pname, keys[1])); + } + + /// User-defined key pair generator. + /// + /// @param pname parameter set name + /// @param sr `SecureRandom` object, `null` if not initialized + /// @return public key and private key (in this order) in raw bytes + /// @throws ProviderException if there is an internal error + protected abstract byte[][] implGenerateKeyPair(String pname, SecureRandom sr); +} diff --git a/src/java.base/share/classes/sun/security/provider/NamedSignature.java b/src/java.base/share/classes/sun/security/provider/NamedSignature.java new file mode 100644 index 00000000000..921a39cfc92 --- /dev/null +++ b/src/java.base/share/classes/sun/security/provider/NamedSignature.java @@ -0,0 +1,222 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +package sun.security.provider; + +import sun.security.pkcs.NamedPKCS8Key; +import sun.security.x509.NamedX509Key; + +import java.io.ByteArrayOutputStream; +import java.security.AlgorithmParameters; +import java.security.InvalidAlgorithmParameterException; +import java.security.InvalidKeyException; +import java.security.InvalidParameterException; +import java.security.PrivateKey; +import java.security.ProviderException; +import java.security.PublicKey; +import java.security.SecureRandom; +import java.security.SignatureException; +import java.security.SignatureSpi; +import java.security.spec.AlgorithmParameterSpec; +import java.util.Objects; + +/// A base class for all `Signature` implementations that can be +/// configured with a named parameter set. See [NamedKeyPairGenerator] +/// for more details. +/// +/// This class does not work with preHash signatures. +public abstract class NamedSignature extends SignatureSpi { + + private final String fname; // family name + private final String[] pnames; // allowed parameter set name (at least one) + + private final ByteArrayOutputStream bout = new ByteArrayOutputStream(); + + // init with... + private String name; + private byte[] secKey; + private byte[] pubKey; + + private Object sk2; + private Object pk2; + + /// Creates a new `NamedSignature` object. + /// + /// @param fname the family name + /// @param pnames the standard parameter set names, at least one is needed. + protected NamedSignature(String fname, String... pnames) { + if (fname == null) { + throw new AssertionError("fname cannot be null"); + } + if (pnames == null || pnames.length == 0) { + throw new AssertionError("pnames cannot be null or empty"); + } + this.fname = fname; + this.pnames = pnames; + } + + @Override + protected void engineInitVerify(PublicKey publicKey) throws InvalidKeyException { + // translate also check the key + var nk = (NamedX509Key) new NamedKeyFactory(fname, pnames) + .engineTranslateKey(publicKey); + name = nk.getParams().getName(); + pubKey = nk.getRawBytes(); + pk2 = implCheckPublicKey(name, pubKey); + secKey = null; + bout.reset(); + } + + @Override + protected void engineInitSign(PrivateKey privateKey) throws InvalidKeyException { + // translate also check the key + var nk = (NamedPKCS8Key) new NamedKeyFactory(fname, pnames) + .engineTranslateKey(privateKey); + name = nk.getParams().getName(); + secKey = nk.getRawBytes(); + sk2 = implCheckPrivateKey(name, secKey); + pubKey = null; + bout.reset(); + } + + @Override + protected void engineUpdate(byte b) throws SignatureException { + bout.write(b); + } + + @Override + protected void engineUpdate(byte[] b, int off, int len) throws SignatureException { + bout.write(b, off, len); + } + + @Override + protected byte[] engineSign() throws SignatureException { + if (secKey != null) { + var msg = bout.toByteArray(); + bout.reset(); + return implSign(name, secKey, sk2, msg, appRandom); + } else { + throw new SignatureException("No private key"); + } + } + + @Override + protected boolean engineVerify(byte[] sig) throws SignatureException { + if (pubKey != null) { + var msg = bout.toByteArray(); + bout.reset(); + return implVerify(name, pubKey, pk2, msg, sig); + } else { + throw new SignatureException("No public key"); + } + } + + @Override + @SuppressWarnings("deprecation") + protected void engineSetParameter(String param, Object value) + throws InvalidParameterException { + throw new InvalidParameterException("setParameter() not supported"); + } + + @Override + @SuppressWarnings("deprecation") + protected Object engineGetParameter(String param) throws InvalidParameterException { + throw new InvalidParameterException("getParameter() not supported"); + } + + @Override + protected void engineSetParameter(AlgorithmParameterSpec params) + throws InvalidAlgorithmParameterException { + if (params != null) { + throw new InvalidAlgorithmParameterException( + "The " + fname + " algorithm does not take any parameters"); + } + } + + @Override + protected AlgorithmParameters engineGetParameters() { + return null; + } + + /// User-defined sign function. + /// + /// @param name parameter name + /// @param sk private key in raw bytes + /// @param sk2 parsed private key, `null` if none. See [#implCheckPrivateKey]. + /// @param msg the message + /// @param sr SecureRandom object, `null` if not initialized + /// @return the signature + /// @throws ProviderException if there is an internal error + /// @throws SignatureException if there is another error + protected abstract byte[] implSign(String name, byte[] sk, Object sk2, + byte[] msg, SecureRandom sr) throws SignatureException; + + /// User-defined verify function. + /// + /// @param name parameter name + /// @param pk public key in raw bytes + /// @param pk2 parsed public key, `null` if none. See [#implCheckPublicKey]. + /// @param msg the message + /// @param sig the signature + /// @return true if verified + /// @throws ProviderException if there is an internal error + /// @throws SignatureException if there is another error + protected abstract boolean implVerify(String name, byte[] pk, Object pk2, + byte[] msg, byte[] sig) throws SignatureException; + + /// User-defined function to validate a public key. + /// + /// This method will be called in `initVerify`. This gives the provider a chance to + /// reject the key so an `InvalidKeyException` can be thrown earlier. + /// An implementation can optionally return a "parsed key" as an `Object` value. + /// This object will be passed into the [#implVerify] method along with the raw key. + /// + /// The default implementation returns `null`. + /// + /// @param name parameter name + /// @param pk public key in raw bytes + /// @return a parsed key, `null` if none. + /// @throws InvalidKeyException if the key is invalid + protected Object implCheckPublicKey(String name, byte[] pk) throws InvalidKeyException { + return null; + } + + /// User-defined function to validate a private key. + /// + /// This method will be called in `initSign`. This gives the provider a chance to + /// reject the key so an `InvalidKeyException` can be thrown earlier. + /// An implementation can optionally return a "parsed key" as an `Object` value. + /// This object will be passed into the [#implSign] method along with the raw key. + /// + /// The default implementation returns `null`. + /// + /// @param name parameter name + /// @param sk private key in raw bytes + /// @return a parsed key, `null` if none. + /// @throws InvalidKeyException if the key is invalid + protected Object implCheckPrivateKey(String name, byte[] sk) throws InvalidKeyException { + return null; + } +} diff --git a/src/java.base/share/classes/sun/security/provider/SHA3.java b/src/java.base/share/classes/sun/security/provider/SHA3.java index eaccf2a88e9..75430c63916 100644 --- a/src/java.base/share/classes/sun/security/provider/SHA3.java +++ b/src/java.base/share/classes/sun/security/provider/SHA3.java @@ -34,6 +34,8 @@ import java.util.Objects; import jdk.internal.vm.annotation.IntrinsicCandidate; +import static java.lang.Math.min; + /** * This class implements the Secure Hash Algorithm SHA-3 developed by * the National Institute of Standards and Technology along with the @@ -46,7 +48,7 @@ import jdk.internal.vm.annotation.IntrinsicCandidate; * @since 9 * @author Valerie Peng */ -abstract class SHA3 extends DigestBase { +public abstract class SHA3 extends DigestBase { private static final int WIDTH = 200; // in bytes, e.g. 1600 bits private static final int DM = 5; // dimension of state matrix @@ -65,9 +67,24 @@ abstract class SHA3 extends DigestBase { 0x8000000000008080L, 0x80000001L, 0x8000000080008008L, }; + // The starting byte combining the 2 or 4-bit domain separator and + // leading bits of the 10*1 padding, see Table 6 in B.2 of FIPS PUB 202 + // for examples private final byte suffix; + + // the state matrix flattened into an array private long[] state = new long[DM*DM]; + // The byte offset in the state where the next squeeze() will start. + // -1 indicates that either we are in the absorbing phase (only + // update() calls were made so far) in an extendable-output function (XOF) + // or the class was initialized as a hash. + // The first squeeze() call (after a possibly empty sequence of update() + // calls) will set it to 0 at its start. + // When a squeeze() call uses up all available bytes from this state + // and so a new keccak() call is made, squeezeOffset is reset to 0. + protected int squeezeOffset = -1; + static final VarHandle asLittleEndian = MethodHandles.byteArrayViewVarHandle(long[].class, ByteOrder.LITTLE_ENDIAN).withInvokeExactBehavior(); @@ -75,7 +92,7 @@ abstract class SHA3 extends DigestBase { /** * Creates a new SHA-3 object. */ - SHA3(String name, int digestLength, byte suffix, int c) { + private SHA3(String name, int digestLength, byte suffix, int c) { super(name, digestLength, (WIDTH - c)); this.suffix = suffix; } @@ -103,54 +120,141 @@ abstract class SHA3 extends DigestBase { keccak(); } + void finishAbsorb() { + int numOfPadding = + setPaddingBytes(suffix, buffer, (int)(bytesProcessed % blockSize)); + if (numOfPadding < 1) { + throw new ProviderException("Incorrect pad size: " + numOfPadding); + } + implCompress(buffer, 0); + } + /** * Return the digest. Subclasses do not need to reset() themselves, * DigestBase calls implReset() when necessary. */ void implDigest(byte[] out, int ofs) { + // Moving this allocation to the block where it is used causes a little + // performance drop, that is why it is here. byte[] byteState = new byte[8]; - int numOfPadding = - setPaddingBytes(suffix, buffer, (int)(bytesProcessed % blockSize)); - if (numOfPadding < 1) { - throw new ProviderException("Incorrect pad size: " + numOfPadding); + if (engineGetDigestLength() == 0) { + // This is an XOF, so the digest() call is illegal. + throw new ProviderException("Calling digest() is not allowed in an XOF"); } - implCompress(buffer, 0); - int availableBytes = blockSize; // i.e. buffer.length + + finishAbsorb(); + + int availableBytes = blockSize; int numBytes = engineGetDigestLength(); + while (numBytes > availableBytes) { - for (int i = 0; i < availableBytes / 8 ; i++) { + for (int i = 0; i < availableBytes / 8; i++) { asLittleEndian.set(out, ofs, state[i]); ofs += 8; } numBytes -= availableBytes; keccak(); } - int numLongs = (numBytes + 7) / 8; + int numLongs = numBytes / 8; - for (int i = 0; i < numLongs - 1; i++) { + for (int i = 0; i < numLongs; i++) { asLittleEndian.set(out, ofs, state[i]); ofs += 8; } - if (numBytes == numLongs * 8) { - asLittleEndian.set(out, ofs, state[numLongs - 1]); - } else { - asLittleEndian.set(byteState, 0, state[numLongs - 1]); - System.arraycopy(byteState, 0, - out, ofs, numBytes - (numLongs - 1) * 8); + if (numBytes % 8 != 0) { + asLittleEndian.set(byteState, 0, state[numLongs]); + System.arraycopy(byteState, 0, out, ofs, numBytes % 8); } } + void implSqueeze(byte[] output, int offset, int numBytes) { + // Moving this allocation to the block where it is used causes a little + // performance drop, that is why it is here. + byte[] byteState = new byte[8]; + if (engineGetDigestLength() != 0) { + // This is not an XOF, so the squeeze() call is illegal. + throw new ProviderException("Squeezing is only allowed in XOF mode."); + } + + if (squeezeOffset == -1) { + finishAbsorb(); + squeezeOffset = 0; + } + + int availableBytes = blockSize - squeezeOffset; + + while (numBytes > availableBytes) { + int longOffset = squeezeOffset / 8; + int bytesToCopy = 0; + + if (longOffset * 8 < squeezeOffset) { + asLittleEndian.set(byteState, 0, state[longOffset]); + longOffset++; + bytesToCopy = longOffset * 8 - squeezeOffset; + System.arraycopy(byteState, 8 - bytesToCopy, + output, offset, bytesToCopy); + offset += bytesToCopy; + } + for (int i = longOffset; i < blockSize / 8; i++) { + asLittleEndian.set(output, offset, state[i]); + offset += 8; + } + keccak(); + squeezeOffset = 0; + numBytes -= availableBytes; + availableBytes = blockSize; + } + // now numBytes <= availableBytes + int longOffset = squeezeOffset / 8; + + if (longOffset * 8 < squeezeOffset) { + asLittleEndian.set(byteState, 0, state[longOffset]); + int bytesToCopy = min((longOffset + 1) * 8 - squeezeOffset, numBytes); + System.arraycopy(byteState, squeezeOffset - 8 * longOffset, + output, offset, bytesToCopy); + longOffset++; + numBytes -= bytesToCopy; + offset += bytesToCopy; + squeezeOffset += bytesToCopy; + + if (numBytes == 0) return; + } + + int numLongs = numBytes / 8; + + for (int i = longOffset; i < longOffset + numLongs; i++) { + asLittleEndian.set(output, offset, state[i]); + offset += 8; + numBytes -= 8; + squeezeOffset += 8; + } + + if (numBytes > 0) { + asLittleEndian.set(byteState, 0, state[squeezeOffset / 8]); + System.arraycopy(byteState, 0, output, offset, numBytes); + squeezeOffset += numBytes; + } + } + + byte[] implSqueeze(int numBytes) { + byte[] result = new byte[numBytes]; + implSqueeze(result, 0, numBytes); + return result; + } + /** * Resets the internal state to start a new hash. */ void implReset() { Arrays.fill(state, 0L); + squeezeOffset = -1; } /** * Utility function for padding the specified data based on the - * pad10*1 algorithm (section 5.1) and the 2-bit suffix "01" required - * for SHA-3 hash (section 6.1). + * pad10*1 algorithm (section 5.1) and the 2-bit suffix "01" or 4-bit + * suffix "1111" required for SHA-3 hash functions (section 6.1) and + * extendable-output functions (section 6.1) respectively. */ private static int setPaddingBytes(byte suffix, byte[] in, int len) { if (len != in.length) { @@ -169,16 +273,20 @@ abstract class SHA3 extends DigestBase { * rate r = 1600 and capacity c. */ private void keccak() { + keccak(state); + } + + public static void keccak(long[] stateArr) { long a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12; long a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24; // move data into local variables - a0 = state[0]; a1 = state[1]; a2 = state[2]; a3 = state[3]; a4 = state[4]; - a5 = state[5]; a6 = state[6]; a7 = state[7]; a8 = state[8]; a9 = state[9]; - a10 = state[10]; a11 = state[11]; a12 = state[12]; a13 = state[13]; a14 = state[14]; - a15 = state[15]; a16 = state[16]; a17 = state[17]; a18 = state[18]; a19 = state[19]; - a20 = state[20]; a21 = state[21]; a22 = state[22]; a23 = state[23]; a24 = state[24]; + a0 = stateArr[0]; a1 = stateArr[1]; a2 = stateArr[2]; a3 = stateArr[3]; a4 = stateArr[4]; + a5 = stateArr[5]; a6 = stateArr[6]; a7 = stateArr[7]; a8 = stateArr[8]; a9 = stateArr[9]; + a10 = stateArr[10]; a11 = stateArr[11]; a12 = stateArr[12]; a13 = stateArr[13]; a14 = stateArr[14]; + a15 = stateArr[15]; a16 = stateArr[16]; a17 = stateArr[17]; a18 = stateArr[18]; a19 = stateArr[19]; + a20 = stateArr[20]; a21 = stateArr[21]; a22 = stateArr[22]; a23 = stateArr[23]; a24 = stateArr[24]; - // process the lanes through step mappings + // process the stateArr through step mappings for (int ir = 0; ir < NR; ir++) { // Step mapping Theta as defined in section 3.2.1. long c0 = a0^a5^a10^a15^a20; @@ -280,11 +388,11 @@ abstract class SHA3 extends DigestBase { a0 ^= RC_CONSTANTS[ir]; } - state[0] = a0; state[1] = a1; state[2] = a2; state[3] = a3; state[4] = a4; - state[5] = a5; state[6] = a6; state[7] = a7; state[8] = a8; state[9] = a9; - state[10] = a10; state[11] = a11; state[12] = a12; state[13] = a13; state[14] = a14; - state[15] = a15; state[16] = a16; state[17] = a17; state[18] = a18; state[19] = a19; - state[20] = a20; state[21] = a21; state[22] = a22; state[23] = a23; state[24] = a24; + stateArr[0] = a0; stateArr[1] = a1; stateArr[2] = a2; stateArr[3] = a3; stateArr[4] = a4; + stateArr[5] = a5; stateArr[6] = a6; stateArr[7] = a7; stateArr[8] = a8; stateArr[9] = a9; + stateArr[10] = a10; stateArr[11] = a11; stateArr[12] = a12; stateArr[13] = a13; stateArr[14] = a14; + stateArr[15] = a15; stateArr[16] = a16; stateArr[17] = a17; stateArr[18] = a18; stateArr[19] = a19; + stateArr[20] = a20; stateArr[21] = a21; stateArr[22] = a22; stateArr[23] = a23; stateArr[24] = a24; } public Object clone() throws CloneNotSupportedException { @@ -328,4 +436,85 @@ abstract class SHA3 extends DigestBase { super("SHA3-512", 64, (byte)0x06, 128); } } + + public abstract static class SHA3XOF extends SHA3 { + public SHA3XOF(String name, int digestLength, byte offset, int c) { + super(name, digestLength, offset, c); + } + public void update(byte in) { + if (squeezeOffset != -1) { + throw new ProviderException("update() after squeeze() is not allowed."); + } + engineUpdate(in); + } + public void update(byte[] in, int off, int len) { + if (squeezeOffset != -1) { + throw new ProviderException("update() after squeeze() is not allowed."); + } + engineUpdate(in, off, len); + } + + public void update(byte[] in) { + if (squeezeOffset != -1) { + throw new ProviderException("update() after squeeze() is not allowed."); + } + engineUpdate(in, 0, in.length); + } + + public byte[] digest() { + return engineDigest(); + } + + public void squeeze(byte[] output, int offset, int numBytes) { + implSqueeze(output, offset, numBytes); + } + public byte[] squeeze(int numBytes) { + return implSqueeze(numBytes); + } + + public void reset() { + engineReset(); + } + } + + /* + * The SHAKE128 extendable output function. + */ + public static final class SHAKE128 extends SHA3XOF { + // d is the required number of output bytes. + // If this constructor is used with d > 0, the squeezing methods + // will throw a ProviderException. + public SHAKE128(int d) { + super("SHAKE128", d, (byte) 0x1F, 32); + } + + // If this constructor is used to get an instance of the class, then, + // after the last update, one can get the generated bytes using the + // squeezing methods. + // Calling digest method will throw a ProviderException. + public SHAKE128() { + super("SHAKE128", 0, (byte) 0x1F, 32); + } + } + + /* + * The SHAKE256 extendable output function. + */ + public static final class SHAKE256 extends SHA3XOF { + // d is the required number of output bytes. + // If this constructor is used with d > 0, the squeezing methods will + // throw a ProviderException. + public SHAKE256(int d) { + super("SHAKE256", d, (byte) 0x1F, 64); + } + + // If this constructor is used to get an instance of the class, then, + // after the last update, one can get the generated bytes using the + // squeezing methods. + // Calling a digest method will throw a ProviderException. + public SHAKE256() { + super("SHAKE256", 0, (byte) 0x1F, 64); + } + } + } diff --git a/src/java.base/share/classes/sun/security/ssl/StatusResponseManager.java b/src/java.base/share/classes/sun/security/ssl/StatusResponseManager.java index 569a114b2a1..317b948e61a 100644 --- a/src/java.base/share/classes/sun/security/ssl/StatusResponseManager.java +++ b/src/java.base/share/classes/sun/security/ssl/StatusResponseManager.java @@ -257,7 +257,20 @@ final class StatusResponseManager { } if (!task.isCancelled()) { - StatusInfo info = task.get(); + StatusInfo info; + try { + info = task.get(); + } catch (ExecutionException exc) { + // Check for an underlying cause available and log + // that, otherwise just log the ExecutionException + Throwable cause = Optional.ofNullable( + exc.getCause()).orElse(exc); + if (SSLLogger.isOn && SSLLogger.isOn("ssl,respmgr")) { + SSLLogger.fine("Exception during OCSP fetch: " + + cause); + } + continue; + } if (info != null && info.responseData != null) { responseMap.put(info.cert, info.responseData.ocspBytes); @@ -272,10 +285,12 @@ final class StatusResponseManager { } } } - } catch (InterruptedException | ExecutionException exc) { - // Not sure what else to do here + } catch (InterruptedException intex) { + // Log and reset the interrupt state + Thread.currentThread().interrupt(); if (SSLLogger.isOn && SSLLogger.isOn("ssl,respmgr")) { - SSLLogger.fine("Exception when getting data: ", exc); + SSLLogger.fine("Interrupt occurred while fetching: " + + intex); } } } @@ -582,8 +597,7 @@ final class StatusResponseManager { } - static final StaplingParameters processStapling( - ServerHandshakeContext shc) { + static StaplingParameters processStapling(ServerHandshakeContext shc) { StaplingParameters params = null; SSLExtension ext = null; CertStatusRequestType type = null; diff --git a/src/java.base/share/classes/sun/security/tools/keytool/Main.java b/src/java.base/share/classes/sun/security/tools/keytool/Main.java index b2527a7fc2c..3afd5b2142a 100644 --- a/src/java.base/share/classes/sun/security/tools/keytool/Main.java +++ b/src/java.base/share/classes/sun/security/tools/keytool/Main.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1132,7 +1132,6 @@ public final class Main { } } - KeyStore cakstore = buildTrustedCerts(); // -trustcacerts can be specified on -importcert, -printcert or -printcrl. // Reset it so that warnings on CA cert will remain for other command. if (command != IMPORTCERT && command != PRINTCERT @@ -1141,6 +1140,7 @@ public final class Main { } if (trustcacerts) { + KeyStore cakstore = buildTrustedCerts(); if (cakstore != null) { caks = cakstore; } else { @@ -1789,7 +1789,8 @@ public final class Main { */ private char[] promptForCredential() throws Exception { // Handle password supplied via stdin - if (System.console() == null) { + Console console = System.console(); + if (console == null || !console.isTerminal()) { char[] importPass = Password.readPassword(System.in); passwords.add(importPass); return importPass; diff --git a/src/java.base/share/classes/sun/security/util/Cache.java b/src/java.base/share/classes/sun/security/util/Cache.java index 3d8350c1ecd..a8449f0fc27 100644 --- a/src/java.base/share/classes/sun/security/util/Cache.java +++ b/src/java.base/share/classes/sun/security/util/Cache.java @@ -59,7 +59,7 @@ import java.util.concurrent.atomic.AtomicInteger; * However, note that because of the way SoftReferences are implemented in * HotSpot at the moment, this may not work perfectly as it clears them fairly * eagerly. Performance may be improved if the Java heap size is set to larger - * value using e.g. java -ms64M -mx128M foo.Test + * value using e.g. java -Xms64M -Xmx128M foo.Test * * Cache sizing: the memory cache is implemented on top of a LinkedHashMap. * In its current implementation, the number of buckets (NOT entries) in diff --git a/src/java.base/share/classes/sun/security/util/KeyUtil.java b/src/java.base/share/classes/sun/security/util/KeyUtil.java index 6884b9b201a..d057bb689e9 100644 --- a/src/java.base/share/classes/sun/security/util/KeyUtil.java +++ b/src/java.base/share/classes/sun/security/util/KeyUtil.java @@ -184,13 +184,13 @@ public final class KeyUtil { */ public static final String fullDisplayAlgName(Key key) { String result = key.getAlgorithm(); - if (key instanceof ECKey) { - ECParameterSpec paramSpec = ((ECKey) key).getParams(); + if (key instanceof AsymmetricKey ak) { + AlgorithmParameterSpec paramSpec = ak.getParams(); if (paramSpec instanceof NamedCurve nc) { result += " (" + nc.getNameAndAliases()[0] + ")"; + } else if (paramSpec instanceof NamedParameterSpec nps) { + result = nps.getName(); } - } else if (key instanceof EdECKey) { - result = ((EdECKey) key).getParams().getName(); } return result; } diff --git a/src/java.base/share/classes/sun/security/util/PropertyExpander.java b/src/java.base/share/classes/sun/security/util/PropertyExpander.java index 2cc4929e04b..e92d57bfee2 100644 --- a/src/java.base/share/classes/sun/security/util/PropertyExpander.java +++ b/src/java.base/share/classes/sun/security/util/PropertyExpander.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,6 +28,7 @@ package sun.security.util; import java.net.URI; import java.net.URISyntaxException; import java.security.GeneralSecurityException; +import java.util.function.UnaryOperator; /** * A utility class to expand properties embedded in a string. @@ -51,15 +52,31 @@ public class PropertyExpander { } } - public static String expand(String value) - throws ExpandException - { + public static String expand(String value) throws ExpandException { return expand(value, false); } - public static String expand(String value, boolean encodeURL) - throws ExpandException - { + public static String expand(String value, boolean encodeURL) + throws ExpandException { + return expand(value, encodeURL, System::getProperty); + } + + /* + * In non-strict mode an undefined property is replaced by an empty string. + */ + public static String expandNonStrict(String value) { + try { + return expand(value, false, key -> System.getProperty(key, "")); + } catch (ExpandException e) { + // should not happen + throw new AssertionError("unexpected expansion error: when " + + "expansion is non-strict, undefined properties should " + + "be replaced by an empty string", e); + } + } + + private static String expand(String value, boolean encodeURL, + UnaryOperator propertiesGetter) throws ExpandException { if (value == null) return null; @@ -105,7 +122,7 @@ public class PropertyExpander { if (prop.equals("/")) { sb.append(java.io.File.separatorChar); } else { - String val = System.getProperty(prop); + String val = propertiesGetter.apply(prop); if (val != null) { if (encodeURL) { // encode 'val' unless it's an absolute URI diff --git a/src/java.base/share/classes/sun/security/util/SignatureFileVerifier.java b/src/java.base/share/classes/sun/security/util/SignatureFileVerifier.java index 1e204816bd6..1576388b653 100644 --- a/src/java.base/share/classes/sun/security/util/SignatureFileVerifier.java +++ b/src/java.base/share/classes/sun/security/util/SignatureFileVerifier.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,6 +36,7 @@ import java.util.*; import java.util.jar.Attributes; import java.util.jar.Manifest; +import jdk.internal.util.ArraysSupport; import sun.security.action.GetIntegerAction; import sun.security.jca.Providers; import sun.security.pkcs.PKCS7; @@ -87,8 +88,8 @@ public class SignatureFileVerifier { // the maximum allowed size in bytes for the signature-related files public static final int MAX_SIG_FILE_SIZE = initializeMaxSigFileSize(); - // The maximum size of array to allocate. Some VMs reserve some header words in an array. - private static final int MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8; + // The maximum size of array to allocate + private static final int MAX_ARRAY_SIZE = ArraysSupport.SOFT_MAX_ARRAY_LENGTH; /** * Create the named SignatureFileVerifier. diff --git a/src/java.base/share/classes/sun/security/util/SignatureUtil.java b/src/java.base/share/classes/sun/security/util/SignatureUtil.java index 155adc198d0..c1ffd248f2a 100644 --- a/src/java.base/share/classes/sun/security/util/SignatureUtil.java +++ b/src/java.base/share/classes/sun/security/util/SignatureUtil.java @@ -33,6 +33,7 @@ import java.security.interfaces.RSAKey; import java.security.spec.*; import java.util.Locale; +import sun.security.pkcs.NamedPKCS8Key; import sun.security.rsa.RSAUtil; import jdk.internal.access.SharedSecrets; import sun.security.x509.AlgorithmId; @@ -274,7 +275,7 @@ public class SignatureUtil { return signatureAlgorithm.substring(0, with); } else { throw new IllegalArgumentException( - "Unknown algorithm: " + signatureAlgorithm); + "Cannot extract digest algorithm from " + signatureAlgorithm); } } @@ -390,8 +391,8 @@ public class SignatureUtil { public static AlgorithmId fromSignature(Signature sigEngine, PrivateKey key) throws SignatureException { try { - if (key instanceof EdECKey) { - return AlgorithmId.get(((EdECKey) key).getParams().getName()); + if (key.getParams() instanceof NamedParameterSpec nps) { + return AlgorithmId.get(nps.getName()); } AlgorithmParameters params = null; @@ -431,6 +432,14 @@ public class SignatureUtil { public static void checkKeyAndSigAlgMatch(PrivateKey key, String sAlg) { String kAlg = key.getAlgorithm().toUpperCase(Locale.ENGLISH); sAlg = checkName(sAlg); + if (key instanceof NamedPKCS8Key n8k) { + if (!sAlg.equalsIgnoreCase(n8k.getAlgorithm()) + && !sAlg.equalsIgnoreCase(n8k.getParams().getName())) { + throw new IllegalArgumentException( + "key algorithm not compatible with signature algorithm"); + } + return; + } switch (sAlg) { case "RSASSA-PSS" -> { if (!kAlg.equals("RSASSA-PSS") @@ -495,8 +504,10 @@ public class SignatureUtil { case "EDDSA" -> k instanceof EdECPrivateKey ? ((EdECPrivateKey) k).getParams().getName() : kAlg; - default -> kAlg; // All modern signature algorithms, - // RSASSA-PSS, ED25519, ED448, HSS/LMS, etc + default -> kAlg.contains("KEM") ? null : kAlg; + // All modern signature algorithms use the same name across + // key algorithms and signature algorithms, for example, + // RSASSA-PSS, ED25519, ED448, HSS/LMS, etc }; } diff --git a/src/java.base/share/classes/sun/security/validator/CADistrustPolicy.java b/src/java.base/share/classes/sun/security/validator/CADistrustPolicy.java index 0b27a13e17f..17b9e7248c0 100644 --- a/src/java.base/share/classes/sun/security/validator/CADistrustPolicy.java +++ b/src/java.base/share/classes/sun/security/validator/CADistrustPolicy.java @@ -57,7 +57,7 @@ enum CADistrustPolicy { /** * Distrust TLS Server certificates anchored by an Entrust root CA and - * issued after October 31, 2024. If enabled, this policy is currently + * issued after November 11, 2024. If enabled, this policy is currently * enforced by the PKIX and SunX509 TrustManager implementations * of the SunJSSE provider implementation. */ diff --git a/src/java.base/share/classes/sun/security/validator/EntrustTLSPolicy.java b/src/java.base/share/classes/sun/security/validator/EntrustTLSPolicy.java index 49b75627fd8..4c4906d8eb3 100644 --- a/src/java.base/share/classes/sun/security/validator/EntrustTLSPolicy.java +++ b/src/java.base/share/classes/sun/security/validator/EntrustTLSPolicy.java @@ -88,8 +88,8 @@ final class EntrustTLSPolicy { // Any TLS Server certificate that is anchored by one of the Entrust // roots above and is issued after this date will be distrusted. - private static final LocalDate OCTOBER_31_2024 = - LocalDate.of(2024, Month.OCTOBER, 31); + private static final LocalDate NOVEMBER_11_2024 = + LocalDate.of(2024, Month.NOVEMBER, 11); /** * This method assumes the eeCert is a TLS Server Cert and chains back to @@ -111,8 +111,8 @@ final class EntrustTLSPolicy { Date notBefore = chain[0].getNotBefore(); LocalDate ldNotBefore = LocalDate.ofInstant(notBefore.toInstant(), ZoneOffset.UTC); - // reject if certificate is issued after October 31, 2024 - checkNotBefore(ldNotBefore, OCTOBER_31_2024, anchor); + // reject if certificate is issued after November 11, 2024 + checkNotBefore(ldNotBefore, NOVEMBER_11_2024, anchor); } } diff --git a/src/java.base/share/classes/sun/security/x509/NamedX509Key.java b/src/java.base/share/classes/sun/security/x509/NamedX509Key.java new file mode 100644 index 00000000000..dc36bd3b9b3 --- /dev/null +++ b/src/java.base/share/classes/sun/security/x509/NamedX509Key.java @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +package sun.security.x509; + +import sun.security.util.BitArray; + +import java.io.IOException; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; +import java.io.Serial; +import java.security.InvalidKeyException; +import java.security.KeyRep; +import java.security.NoSuchAlgorithmException; +import java.security.ProviderException; +import java.security.spec.NamedParameterSpec; + +/// Represents a public key from an algorithm family that is specialized +/// with a named parameter set. +/// +/// This key is generated by either a [sun.security.provider.NamedKeyPairGenerator] +/// or [sun.security.provider.NamedKeyFactory]. Its [#getAlgorithm] method +/// returns the algorithm family name, while its [#getParams()] method returns +/// the parameter set name as a [NamedParameterSpec] object. The algorithm +/// identifier in the X.509 encoding of the key is always a single OID derived +/// from the parameter set name. +/// +/// @see sun.security.provider.NamedKeyPairGenerator +public final class NamedX509Key extends X509Key { + @Serial + private static final long serialVersionUID = 1L; + + private final String fname; + private final transient NamedParameterSpec paramSpec; + private final byte[] rawBytes; + + /// Ctor from family name, parameter set name, raw key bytes. + /// Key bytes won't be cloned, caller must relinquish ownership + public NamedX509Key(String fname, String pname, byte[] rawBytes) { + this.fname = fname; + this.paramSpec = new NamedParameterSpec(pname); + try { + this.algid = AlgorithmId.get(pname); + } catch (NoSuchAlgorithmException e) { + throw new ProviderException(e); + } + this.rawBytes = rawBytes; + + setKey(new BitArray(rawBytes.length * 8, rawBytes)); + } + + /// Ctor from family name, and X.509 bytes + public NamedX509Key(String fname, byte[] encoded) throws InvalidKeyException { + this.fname = fname; + decode(encoded); + this.paramSpec = new NamedParameterSpec(algid.getName()); + if (algid.encodedParams != null) { + throw new InvalidKeyException("algorithm identifier has params"); + } + this.rawBytes = getKey().toByteArray(); + } + + @Override + public String toString() { + // Do not modify: this can be used by earlier JDKs that + // do not have the getParams() method + return paramSpec.getName() + " public key"; + } + + /// Returns the reference to the internal key. Caller must not modify + /// the content or keep a reference. + public byte[] getRawBytes() { + return rawBytes; + } + + @Override + public NamedParameterSpec getParams() { + return paramSpec; + } + + @Override + public String getAlgorithm() { + return fname; + } + + @java.io.Serial + private Object writeReplace() throws java.io.ObjectStreamException { + return new KeyRep(KeyRep.Type.PUBLIC, getAlgorithm(), getFormat(), + getEncoded()); + } + + @java.io.Serial + private void readObject(ObjectInputStream stream) + throws IOException, ClassNotFoundException { + throw new InvalidObjectException( + "NamedX509Key keys are not directly deserializable"); + } +} diff --git a/src/java.base/share/classes/sun/util/cldr/CLDRTimeZoneNameProviderImpl.java b/src/java.base/share/classes/sun/util/cldr/CLDRTimeZoneNameProviderImpl.java index 3373d3e7a96..af24b68e004 100644 --- a/src/java.base/share/classes/sun/util/cldr/CLDRTimeZoneNameProviderImpl.java +++ b/src/java.base/share/classes/sun/util/cldr/CLDRTimeZoneNameProviderImpl.java @@ -264,7 +264,13 @@ public class CLDRTimeZoneNameProviderImpl extends TimeZoneNameProviderImpl { } private String toGMTFormat(String id, boolean daylight, Locale l) { - var zr = ZoneInfoFile.getZoneInfo(id).toZoneId().getRules(); + LocaleResources lr = LocaleProviderAdapter.forType(Type.CLDR).getLocaleResources(l); + ResourceBundle fd = lr.getJavaTimeFormatData(); + var zi = ZoneInfoFile.getZoneInfo(id); + if (zi == null) { + return fd.getString("timezone.gmtZeroFormat"); + } + var zr = zi.toZoneId().getRules(); var now = Instant.now(); var saving = zr.getTransitions().reversed().stream() .dropWhile(zot -> zot.getInstant().isAfter(now)) @@ -276,8 +282,6 @@ public class CLDRTimeZoneNameProviderImpl extends TimeZoneNameProviderImpl { .orElse(0); int offset = (zr.getStandardOffset(now).getTotalSeconds() + (daylight ? saving : 0)) / 60; - LocaleResources lr = LocaleProviderAdapter.forType(Type.CLDR).getLocaleResources(l); - ResourceBundle fd = lr.getJavaTimeFormatData(); if (offset == 0) { return fd.getString("timezone.gmtZeroFormat"); diff --git a/src/java.base/share/conf/security/java.security b/src/java.base/share/conf/security/java.security index c537a30960e..9d07cb85a47 100644 --- a/src/java.base/share/conf/security/java.security +++ b/src/java.base/share/conf/security/java.security @@ -28,6 +28,33 @@ # Properties in this file are typically parsed only once. If any of the # properties are modified, applications should be restarted to ensure the # changes are properly reflected. +# +# The special "include" property can be defined one or multiple times with +# a filesystem path value. The effect of each definition is to include a +# referred security properties file inline, adding all its properties. +# Security properties defined before an include statement may be overridden +# by properties in the included file, if their names match. Conversely, +# properties defined after an include statement may override properties in +# the included file. +# +# Included files, as well as files pointed to by java.security.properties, +# can include other files recursively. Paths may be absolute or relative. +# Each relative path is resolved against the base file containing its +# "include" definition, if local. Paths may contain system properties for +# expansion in the form of ${system.property}. If a system property does +# not have a value, it expands to the empty string. +# +# An error will be thrown if a file cannot be included. This may happen +# if the file cannot be resolved, does not exist, is a directory, there are +# insufficient permissions to read it, it is recursively included more than +# once, or for any other reason. For a secure JDK configuration, it is +# important to review OS write permissions assigned to any file included. +# +# Examples: +# 1) include ${java.home}/conf/security/extra.security +# 2) include extra.security +# 3) include ${java.home}/conf/security/profile${SecurityProfile}.security +# # In this file, various security properties are set for use by # java.security classes. This is where users can statically register @@ -1331,7 +1358,7 @@ jdk.sasl.disabledMechanisms= # Distrust after December 31, 2019. # # ENTRUST_TLS : Distrust TLS Server certificates anchored by -# an Entrust root CA and issued after October 31, 2024. +# an Entrust root CA and issued after November 11, 2024. # # Leading and trailing whitespace surrounding each value are ignored. # Unknown values are ignored. If the property is commented out or set to the diff --git a/src/java.base/share/data/cacerts/ssltlsrootecc2022 b/src/java.base/share/data/cacerts/ssltlsrootecc2022 new file mode 100644 index 00000000000..706e6aefb4e --- /dev/null +++ b/src/java.base/share/data/cacerts/ssltlsrootecc2022 @@ -0,0 +1,21 @@ +Owner: CN=SSL.com TLS ECC Root CA 2022, O=SSL Corporation, C=US +Issuer: CN=SSL.com TLS ECC Root CA 2022, O=SSL Corporation, C=US +Serial number: 1403f5abfb378b17405be243b2a5d1c4 +Valid from: Thu Aug 25 16:33:48 GMT 2022 until: Sun Aug 19 16:33:47 GMT 2046 +Signature algorithm name: SHA384withECDSA +Subject Public Key Algorithm: 384-bit EC (secp384r1) key +Version: 3 +-----BEGIN CERTIFICATE----- +MIICOjCCAcCgAwIBAgIQFAP1q/s3ixdAW+JDsqXRxDAKBggqhkjOPQQDAzBOMQsw +CQYDVQQGEwJVUzEYMBYGA1UECgwPU1NMIENvcnBvcmF0aW9uMSUwIwYDVQQDDBxT +U0wuY29tIFRMUyBFQ0MgUm9vdCBDQSAyMDIyMB4XDTIyMDgyNTE2MzM0OFoXDTQ2 +MDgxOTE2MzM0N1owTjELMAkGA1UEBhMCVVMxGDAWBgNVBAoMD1NTTCBDb3Jwb3Jh +dGlvbjElMCMGA1UEAwwcU1NMLmNvbSBUTFMgRUNDIFJvb3QgQ0EgMjAyMjB2MBAG +ByqGSM49AgEGBSuBBAAiA2IABEUpNXP6wrgjzhR9qLFNoFs27iosU8NgCTWyJGYm +acCzldZdkkAZDsalE3D07xJRKF3nzL35PIXBz5SQySvOkkJYWWf9lCcQZIxPBLFN +SeR7T5v15wj4A4j3p8OSSxlUgaNjMGEwDwYDVR0TAQH/BAUwAwEB/zAfBgNVHSME +GDAWgBSJjy+j6CugFFR781a4Jl9nOAuc0DAdBgNVHQ4EFgQUiY8vo+groBRUe/NW +uCZfZzgLnNAwDgYDVR0PAQH/BAQDAgGGMAoGCCqGSM49BAMDA2gAMGUCMFXjIlbp +15IkWE8elDIPDAI2wv2sdDJO4fscgIijzPvX6yv/N33w7deedWo1dlJF4AIxAMeN +b0Igj762TVntd00pxCAgRWSGOlDGxK0tk/UYfXLtqc/ErFc2KAhl3zx5Zn6g6g== +-----END CERTIFICATE----- diff --git a/src/java.base/share/data/cacerts/ssltlsrootrsa2022 b/src/java.base/share/data/cacerts/ssltlsrootrsa2022 new file mode 100644 index 00000000000..ad456b0b5f4 --- /dev/null +++ b/src/java.base/share/data/cacerts/ssltlsrootrsa2022 @@ -0,0 +1,39 @@ +Owner: CN=SSL.com TLS RSA Root CA 2022, O=SSL Corporation, C=US +Issuer: CN=SSL.com TLS RSA Root CA 2022, O=SSL Corporation, C=US +Serial number: 6fbedaad73bd0840e28b4dbed4f75b91 +Valid from: Thu Aug 25 16:34:22 GMT 2022 until: Sun Aug 19 16:34:21 GMT 2046 +Signature algorithm name: SHA256withRSA +Subject Public Key Algorithm: 4096-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIFiTCCA3GgAwIBAgIQb77arXO9CEDii02+1PdbkTANBgkqhkiG9w0BAQsFADBO +MQswCQYDVQQGEwJVUzEYMBYGA1UECgwPU1NMIENvcnBvcmF0aW9uMSUwIwYDVQQD +DBxTU0wuY29tIFRMUyBSU0EgUm9vdCBDQSAyMDIyMB4XDTIyMDgyNTE2MzQyMloX +DTQ2MDgxOTE2MzQyMVowTjELMAkGA1UEBhMCVVMxGDAWBgNVBAoMD1NTTCBDb3Jw +b3JhdGlvbjElMCMGA1UEAwwcU1NMLmNvbSBUTFMgUlNBIFJvb3QgQ0EgMjAyMjCC +AiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBANCkCXJPQIgSYT41I57u9nTP +L3tYPc48DRAokC+X94xI2KDYJbFMsBFMF3NQ0CJKY7uB0ylu1bUJPiYYf7ISf5OY +t6/wNr/y7hienDtSxUcZXXTzZGbVXcdotL8bHAajvI9AI7YexoS9UcQbOcGV0ins +S657Lb85/bRi3pZ7QcacoOAGcvvwB5cJOYF0r/c0WRFXCsJbwST0MXMwgsadugL3 +PnxEX4MN8/HdIGkWCVDi1FW24IBydm5MR7d1VVm0U3TZlMZBrViKMWYPHqIbKUBO +L9975hYsLfy/7PO0+r4Y9ptJ1O4Fbtk085zx7AGL0SDGD6C1vBdOSHtRwvzpXGk3 +R2azaPgVKPC506QVzFpPulJwoxJF3ca6TvvC0PeoUidtbnm1jPx7jMEWTO6Af77w +dr5BUxIzrlo4QqvXDz5BjXYHMtWrifZOZ9mxQnUjbvPNQrL8VfVThxc7wDNY8VLS ++YCk8OjwO4s4zKTGkH8PnP2L0aPP2oOnaclQNtVcBdIKQXTbYxE3waWglksejBYS +d66UNHsef8JmAOSqg+qKkK3ONkRN0VHpvB/zagX9wHQfJRlAUW7qglFA35u5CCoG +AtUjHBPW6dvbxrB6y3snm/vg1UYk7RBLY0ulBY+6uB0rpvqR4pJSvezrZ5dtmi2f +gTIFZzL7SAg/2SW4BCUvAgMBAAGjYzBhMA8GA1UdEwEB/wQFMAMBAf8wHwYDVR0j +BBgwFoAU+y437uOEeicuzRk1sTN8/9REQrkwHQYDVR0OBBYEFPsuN+7jhHonLs0Z +NbEzfP/UREK5MA4GA1UdDwEB/wQEAwIBhjANBgkqhkiG9w0BAQsFAAOCAgEAjYlt +hEUY8U+zoO9opMAdrDC8Z2awms22qyIZZtM7QbUQnRC6cm4pJCAcAZli05bg4vsM +QtfhWsSWTVTNj8pDU/0quOr4ZcoBwq1gaAafORpR2eCNJvkLTqVTJXojpBzOCBvf +R4iyrT7gJ4eLSYwfqUdYe5byiB0YrrPRpgqU+tvT5TgKa3kSM/tKWTcWQA673vWJ +DPFs0/dRa1419dvAJuoSc06pkZCmF8NsLzjUo3KUQyxi4U5cMj29TH0ZR6LDSeeW +P4+a0zvkEdiLA9z2tmBVGKaBUfPhqBVq6+AL8BQx1rmMRTqoENjwuSfr98t67wVy +lrXEj5ZzxOhWc5y8aVFjvO9nHEMaX3cZHxj4HCUp+UmZKbaSPaKDN7EgkaibMOlq +bLQjk2UEqxHzDh1TJElTHaE/nUiSEeJ9DU/1172iWD54nR4fK/4huxoTtrEoZP2w +AgDHbICivRZQIA9ygV/MlP+7mea6kMvq+cYMwq7FGc4zoWtcu358NFcXrfA/rs3q +r5nsLFR+jM4uElZI7xc7P0peYNLcdDa8pUNjyw9bowJWCZ4kLOGGgYz+qxcs+sji +Mho6/4UIyYOf8kpIEFR3N+2ivEC+5BB09+Rbu7nzifmPQdjH5FCQNYA+HLhNkNPU +98OwoX6EyneSMSy4kLGCenROmxMmtNVQZlR4rmA= +-----END CERTIFICATE----- diff --git a/src/java.base/share/man/java.1 b/src/java.base/share/man/java.1 index 5896a073043..da7fb86099f 100644 --- a/src/java.base/share/man/java.1 +++ b/src/java.base/share/man/java.1 @@ -3749,12 +3749,6 @@ future JDK release. They\[aq]re still accepted and acted upon, but a warning is issued when they\[aq]re used. .TP -\f[V]-Xfuture\f[R] -Enables strict class-file format checks that enforce close conformance -to the class-file format specification. -Developers should use this flag when developing new code. -Stricter checks may become the default in future releases. -.TP \f[V]-Xloggc:\f[R]\f[I]filename\f[R] Sets the file to which verbose GC events information should be redirected for logging. @@ -3920,6 +3914,16 @@ of objects reachable from the old generation space into the young generation space. To disable GC of the young generation before each full GC, specify the option \f[V]-XX:-ScavengeBeforeFullGC\f[R]. +.TP +\f[V]-Xfuture\f[R] +Enables strict class-file format checks that enforce close conformance +to the class-file format specification. +Developers should use this flag when developing new code. +Stricter checks may become the default in future releases. +.RS +.PP +Use the option \f[V]-Xverify:all\f[R] instead. +.RE .PP For the lists and descriptions of options removed in previous releases see the \f[I]Removed Java Options\f[R] section in: @@ -4825,7 +4829,7 @@ level to a file called \f[V]gc.txt\f[R] with no decorations. The default configuration for all other messages at level \f[V]warning\f[R] is still in effect. .TP -\f[V]-Xlog:gc=trace:file=gctrace.txt:uptimemillis,pids:filecount=5,filesize=1024\f[R] +\f[V]-Xlog:gc=trace:file=gctrace.txt:uptimemillis,pid:filecount=5,filesize=1024\f[R] Logs messages tagged with the \f[V]gc\f[R] tag using the \f[V]trace\f[R] level to a rotating file set with 5 files with size 1 MB with the base name \f[V]gctrace.txt\f[R] and uses decorations \f[V]uptimemillis\f[R] diff --git a/src/java.base/share/native/libjava/ClassLoader.c b/src/java.base/share/native/libjava/ClassLoader.c index 927432d1509..4519a4777f8 100644 --- a/src/java.base/share/native/libjava/ClassLoader.c +++ b/src/java.base/share/native/libjava/ClassLoader.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -114,7 +114,7 @@ Java_java_lang_ClassLoader_defineClass1(JNIEnv *env, (*env)->GetByteArrayRegion(env, data, offset, length, body); - if ((*env)->ExceptionOccurred(env)) { + if ((*env)->ExceptionCheck(env)) { goto free_body; } @@ -259,7 +259,7 @@ Java_java_lang_ClassLoader_defineClass0(JNIEnv *env, (*env)->GetByteArrayRegion(env, data, offset, length, body); - if ((*env)->ExceptionOccurred(env)) + if ((*env)->ExceptionCheck(env)) goto free_body; if (name != NULL) { diff --git a/src/java.base/share/native/libjava/System.c b/src/java.base/share/native/libjava/System.c index 098b943cc40..7b038a6a9d5 100644 --- a/src/java.base/share/native/libjava/System.c +++ b/src/java.base/share/native/libjava/System.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1994, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1994, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -70,7 +70,7 @@ Java_java_lang_System_identityHashCode(JNIEnv *env, jobject this, jobject x) if (jval == NULL) \ return NULL; \ (*env)->SetObjectArrayElement(env, array, jdk_internal_util_SystemProps_Raw_##prop_index, jval); \ - if ((*env)->ExceptionOccurred(env)) \ + if ((*env)->ExceptionCheck(env)) \ return NULL; \ (*env)->DeleteLocalRef(env, jval); \ } @@ -86,7 +86,7 @@ Java_java_lang_System_identityHashCode(JNIEnv *env, jobject this, jobject x) if (jval == NULL) \ return NULL; \ (*env)->SetObjectArrayElement(env, array, jdk_internal_util_SystemProps_Raw_##prop_index, jval); \ - if ((*env)->ExceptionOccurred(env)) \ + if ((*env)->ExceptionCheck(env)) \ return NULL; \ (*env)->DeleteLocalRef(env, jval); \ } diff --git a/src/java.base/share/native/libjava/io_util.c b/src/java.base/share/native/libjava/io_util.c index 3fb7675d277..76ff58ec632 100644 --- a/src/java.base/share/native/libjava/io_util.c +++ b/src/java.base/share/native/libjava/io_util.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1994, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1994, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -175,7 +175,7 @@ writeBytes(JNIEnv *env, jobject this, jbyteArray bytes, (*env)->GetByteArrayRegion(env, bytes, off, len, (jbyte *)buf); - if (!(*env)->ExceptionOccurred(env)) { + if (!(*env)->ExceptionCheck(env)) { off = 0; while (len > 0) { fd = getFD(env, this, fid); diff --git a/src/java.base/share/native/libjava/jni_util.c b/src/java.base/share/native/libjava/jni_util.c index 3d9004d969c..ce23d160430 100644 --- a/src/java.base/share/native/libjava/jni_util.c +++ b/src/java.base/share/native/libjava/jni_util.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -117,7 +117,7 @@ JNU_ThrowByNameWithLastError(JNIEnv *env, const char *name, (*env)->Throw(env, x); } } - if (!(*env)->ExceptionOccurred(env)) { + if (!(*env)->ExceptionCheck(env)) { JNU_ThrowByName(env, name, defaultDetail); } } @@ -166,7 +166,7 @@ JNU_ThrowByNameWithMessageAndLastError } } - if (!(*env)->ExceptionOccurred(env)) { + if (!(*env)->ExceptionCheck(env)) { if (messagelen > 0) { JNU_ThrowByName(env, name, message); } else { diff --git a/src/java.base/share/native/libjli/emessages.h b/src/java.base/share/native/libjli/emessages.h index c74fae7a77b..342b116bfc7 100644 --- a/src/java.base/share/native/libjli/emessages.h +++ b/src/java.base/share/native/libjli/emessages.h @@ -103,9 +103,6 @@ #define JRE_ERROR12 "Error: Exec of %s failed" #define JRE_ERROR13 "Error: String processing operation failed" -#define SPC_ERROR1 "Error: Specifying an alternate JDK/JRE version is no longer supported.\n The use of the flag '-version:' is no longer valid.\n Please download and execute the appropriate version." -#define SPC_ERROR2 "Error: Specifying an alternate JDK/JRE is no longer supported.\n The related flags -jre-restrict-search | -jre-no-restrict-search are also no longer valid." - #define DLL_ERROR1 "Error: dl failure on line %d" #define DLL_ERROR2 "Error: failed %s, because %s" #define DLL_ERROR3 "Error: could not find executable %s" diff --git a/src/java.base/share/native/libjli/java.c b/src/java.base/share/native/libjli/java.c index 1b4ece834d6..355ac4b9e28 100644 --- a/src/java.base/share/native/libjli/java.c +++ b/src/java.base/share/native/libjli/java.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,20 +34,15 @@ /* * One job of the launcher is to remove command line options which the - * vm does not understand and will not process. These options include + * vm does not understand and will not process. These options include * options which select which style of vm is run (e.g. -client and - * -server) as well as options which select the data model to use. + * -server). * Additionally, for tools which invoke an underlying vm "-J-foo" * options are turned into "-foo" options to the vm. This option * filtering is handled in a number of places in the launcher, some of * it in machine-dependent code. In this file, the function * CheckJvmType removes vm style options and TranslateApplicationArgs - * removes "-J" prefixes. The CreateExecutionEnvironment function processes - * and removes -d options. On unix, there is a possibility that the running - * data model may not match to the desired data model, in this case an exec is - * required to start the desired model. If the data models match, then - * ParseArguments will remove the -d flags. If the data models do not match - * the CreateExecutionEnviroment will remove the -d flags. + * removes "-J" prefixes. */ @@ -55,11 +50,12 @@ #include "java.h" #include "jni.h" +#include "stdbool.h" /* * A NOTE TO DEVELOPERS: For performance reasons it is important that - * the program image remain relatively small until after SelectVersion - * CreateExecutionEnvironment have finished their possibly recursive + * the program image remain relatively small until after + * CreateExecutionEnvironment has finished its possibly recursive * processing. Watch everything, but resist all temptations to use Java * interfaces. */ @@ -88,10 +84,10 @@ static jboolean _wc_enabled = JNI_FALSE; static jboolean dumpSharedSpaces = JNI_FALSE; /* -Xshare:dump */ /* - * Entries for splash screen environment variables. - * putenv is performed in SelectVersion. We need - * them in memory until UnsetEnv, so they are made static - * global instead of auto local. + * Values that will be stored into splash screen environment variables. + * putenv is performed to set _JAVA_SPLASH_FILE and _JAVA_SPLASH_JAR + * with these values. We need them in memory until UnsetEnv in + * ShowSplashScreen, so they are made static global instead of auto local. */ static char* splash_file_entry = NULL; static char* splash_jar_entry = NULL; @@ -110,19 +106,18 @@ static jboolean IsJavaArgs(); static void SetJavaLauncherProp(); static void SetClassPath(const char *s); static void SetMainModule(const char *s); -static void SelectVersion(int argc, char **argv, char **main_class); static jboolean ParseArguments(int *pargc, char ***pargv, int *pmode, char **pwhat, - int *pret, const char *jrepath); + int *pret); static jboolean InitializeJVM(JavaVM **pvm, JNIEnv **penv, InvocationFunctions *ifn); static jstring NewPlatformString(JNIEnv *env, char *s); static jclass LoadMainClass(JNIEnv *env, int mode, char *name); +static void SetupSplashScreenEnvVars(const char *splash_file_path, char *jar_path); static jclass GetApplicationClass(JNIEnv *env); static void TranslateApplicationArgs(int jargc, const char **jargv, int *pargc, char ***pargv); static jboolean AddApplicationOptions(int cpathc, const char **cpathv); -static void SetApplicationClassPath(const char**); static void PrintJavaVersion(JNIEnv *env); static void PrintUsage(JNIEnv* env, jboolean doXUsage); @@ -130,9 +125,6 @@ static void ShowSettings(JNIEnv* env, char *optString); static void ShowResolvedModules(JNIEnv* env); static void ListModules(JNIEnv* env); static void DescribeModule(JNIEnv* env, char* optString); -static jboolean ValidateModules(JNIEnv* env); - -static void SetPaths(int argc, char **argv); static void DumpState(); @@ -240,7 +232,6 @@ JLI_Launch(int argc, char ** argv, /* main argc, argv */ { int mode = LM_UNKNOWN; char *what = NULL; - char *main_class = NULL; int ret; InvocationFunctions ifn; jlong start = 0, end = 0; @@ -257,6 +248,10 @@ JLI_Launch(int argc, char ** argv, /* main argc, argv */ InitLauncher(javaw); DumpState(); if (JLI_IsTraceLauncher()) { + char *env_in; + if ((env_in = getenv(MAIN_CLASS_ENV_ENTRY)) != NULL) { + printf("Launched through Multiple JRE (mJRE) support\n"); + } int i; printf("Java args:\n"); for (i = 0; i < jargc ; i++) { @@ -269,18 +264,6 @@ JLI_Launch(int argc, char ** argv, /* main argc, argv */ AddOption("-Dsun.java.launcher.diag=true", NULL); } - /* - * SelectVersion() has several responsibilities: - * - * 1) Disallow specification of another JRE. With 1.9, another - * version of the JRE cannot be invoked. - * 2) Allow for a JRE version to invoke JDK 1.9 or later. Since - * all mJRE directives have been stripped from the request but - * the pre 1.9 JRE [ 1.6 thru 1.8 ], it is as if 1.9+ has been - * invoked from the command line. - */ - SelectVersion(argc, argv, &main_class); - CreateExecutionEnvironment(&argc, &argv, jrepath, sizeof(jrepath), jvmpath, sizeof(jvmpath), @@ -323,7 +306,7 @@ JLI_Launch(int argc, char ** argv, /* main argc, argv */ /* Parse command line options; if the return value of * ParseArguments is false, the program should exit. */ - if (!ParseArguments(&argc, &argv, &mode, &what, &ret, jrepath)) { + if (!ParseArguments(&argc, &argv, &mode, &what, &ret)) { return(ret); } @@ -368,7 +351,7 @@ JLI_Launch(int argc, char ** argv, /* main argc, argv */ #define CHECK_EXCEPTION_NULL_LEAVE(CENL_exception) \ do { \ - if ((*env)->ExceptionOccurred(env)) { \ + if ((*env)->ExceptionCheck(env)) { \ JLI_ReportExceptionDescription(env); \ LEAVE(); \ } \ @@ -380,7 +363,7 @@ JLI_Launch(int argc, char ** argv, /* main argc, argv */ #define CHECK_EXCEPTION_LEAVE(CEL_return_value) \ do { \ - if ((*env)->ExceptionOccurred(env)) { \ + if ((*env)->ExceptionCheck(env)) { \ JLI_ReportExceptionDescription(env); \ ret = (CEL_return_value); \ LEAVE(); \ @@ -1078,167 +1061,6 @@ SetMainModule(const char *s) AddOption(def, NULL); } -/* - * The SelectVersion() routine ensures that an appropriate version of - * the JRE is running. The specification for the appropriate version - * is obtained from either the manifest of a jar file (preferred) or - * from command line options. - * The routine also parses splash screen command line options and - * passes on their values in private environment variables. - */ -static void -SelectVersion(int argc, char **argv, char **main_class) -{ - char *arg; - char *operand; - int jarflag = 0; - int headlessflag = 0; - manifest_info info; - char *splash_file_name = NULL; - char *splash_jar_name = NULL; - char *env_in; - int res; - jboolean has_arg; - - /* - * If the version has already been selected, set *main_class - * with the value passed through the environment (if any) and - * simply return. - */ - - /* - * This environmental variable can be set by mJRE capable JREs - * [ 1.5 thru 1.8 ]. All other aspects of mJRE processing have been - * stripped by those JREs. This environmental variable allows 1.9+ - * JREs to be started by these mJRE capable JREs. - * Note that mJRE directives in the jar manifest file would have been - * ignored for a JRE started by another JRE... - * .. skipped for JRE 1.5 and beyond. - * .. not even checked for pre 1.5. - */ - if ((env_in = getenv(ENV_ENTRY)) != NULL) { - if (*env_in != '\0') - *main_class = JLI_StringDup(env_in); - return; - } - - /* - * Scan through the arguments for options relevant to multiple JRE - * support. Multiple JRE support existed in JRE versions 1.5 thru 1.8. - * - * This capability is no longer available with JRE versions 1.9 and later. - * These command line options are reported as errors. - */ - - argc--; - argv++; - while (argc > 0 && *(arg = *argv) == '-') { - has_arg = IsOptionWithArgument(argc, argv); - if (JLI_StrCCmp(arg, "-version:") == 0) { - JLI_ReportErrorMessage(SPC_ERROR1); - } else if (JLI_StrCmp(arg, "-jre-restrict-search") == 0) { - JLI_ReportErrorMessage(SPC_ERROR2); - } else if (JLI_StrCmp(arg, "-jre-no-restrict-search") == 0) { - JLI_ReportErrorMessage(SPC_ERROR2); - } else { - if (JLI_StrCmp(arg, "-jar") == 0) - jarflag = 1; - if (IsWhiteSpaceOption(arg)) { - if (has_arg) { - argc--; - argv++; - arg = *argv; - } - } - - /* - * Checking for headless toolkit option in the some way as AWT does: - * "true" means true and any other value means false - */ - if (JLI_StrCmp(arg, "-Djava.awt.headless=true") == 0) { - headlessflag = 1; - } else if (JLI_StrCCmp(arg, "-Djava.awt.headless=") == 0) { - headlessflag = 0; - } else if (JLI_StrCCmp(arg, "-splash:") == 0) { - splash_file_name = arg+8; - } - } - argc--; - argv++; - } - if (argc <= 0) { /* No operand? Possibly legit with -[full]version */ - operand = NULL; - } else { - argc--; - operand = *argv++; - } - - /* - * If there is a jar file, read the manifest. If the jarfile can't be - * read, the manifest can't be read from the jar file, or the manifest - * is corrupt, issue the appropriate error messages and exit. - * - * Even if there isn't a jar file, construct a manifest_info structure - * containing the command line information. It's a convenient way to carry - * this data around. - */ - if (jarflag && operand) { - if ((res = JLI_ParseManifest(operand, &info)) != 0) { - if (res == -1) - JLI_ReportErrorMessage(JAR_ERROR2, operand); - else - JLI_ReportErrorMessage(JAR_ERROR3, operand); - exit(1); - } - - /* - * Command line splash screen option should have precedence - * over the manifest, so the manifest data is used only if - * splash_file_name has not been initialized above during command - * line parsing - */ - if (!headlessflag && !splash_file_name && info.splashscreen_image_file_name) { - splash_file_name = info.splashscreen_image_file_name; - splash_jar_name = operand; - } - } else { - info.manifest_version = NULL; - info.main_class = NULL; - info.jre_version = NULL; - info.jre_restrict_search = 0; - } - - /* - * Passing on splash screen info in environment variables - */ - if (splash_file_name && !headlessflag) { - splash_file_entry = JLI_MemAlloc(JLI_StrLen(SPLASH_FILE_ENV_ENTRY "=")+JLI_StrLen(splash_file_name)+1); - JLI_StrCpy(splash_file_entry, SPLASH_FILE_ENV_ENTRY "="); - JLI_StrCat(splash_file_entry, splash_file_name); - putenv(splash_file_entry); - } - if (splash_jar_name && !headlessflag) { - splash_jar_entry = JLI_MemAlloc(JLI_StrLen(SPLASH_JAR_ENV_ENTRY "=")+JLI_StrLen(splash_jar_name)+1); - JLI_StrCpy(splash_jar_entry, SPLASH_JAR_ENV_ENTRY "="); - JLI_StrCat(splash_jar_entry, splash_jar_name); - putenv(splash_jar_entry); - } - - - /* - * "Valid" returns (other than unrecoverable errors) follow. Set - * main_class as a side-effect of this routine. - */ - if (info.main_class != NULL) - *main_class = JLI_StringDup(info.main_class); - - if (info.jre_version == NULL) { - JLI_FreeManifest(); - return; - } - -} - /* * Test if the current argv is an option, i.e. with a leading `-` * and followed with an argument without a leading `-`. @@ -1325,12 +1147,14 @@ GetOpt(int *pargc, char ***pargv, char **poption, char **pvalue) { static jboolean ParseArguments(int *pargc, char ***pargv, int *pmode, char **pwhat, - int *pret, const char *jrepath) + int *pret) { int argc = *pargc; char **argv = *pargv; int mode = LM_UNKNOWN; char *arg = NULL; + bool headless = false; + char *splash_file_path = NULL; // value of "-splash:" option *pret = 0; @@ -1463,21 +1287,18 @@ ParseArguments(int *pargc, char ***pargv, JLI_ShowMessage("%s %s", _launcher_name, GetFullVersion()); return JNI_FALSE; } else if (JLI_StrCmp(arg, "-verbosegc") == 0) { + JLI_ReportErrorMessage(ARG_DEPRECATED, "-verbosegc"); AddOption("-verbose:gc", NULL); - } else if (JLI_StrCmp(arg, "-t") == 0) { - AddOption("-Xt", NULL); - } else if (JLI_StrCmp(arg, "-tm") == 0) { - AddOption("-Xtm", NULL); } else if (JLI_StrCmp(arg, "-debug") == 0) { JLI_ReportErrorMessage(ARG_DEPRECATED, "-debug"); } else if (JLI_StrCmp(arg, "-noclassgc") == 0) { + JLI_ReportErrorMessage(ARG_DEPRECATED, "-noclassgc"); AddOption("-Xnoclassgc", NULL); - } else if (JLI_StrCmp(arg, "-Xfuture") == 0) { - JLI_ReportErrorMessage(ARG_DEPRECATED, "-Xfuture"); - AddOption("-Xverify:all", NULL); } else if (JLI_StrCmp(arg, "-verify") == 0) { + JLI_ReportErrorMessage(ARG_DEPRECATED, "-verify"); AddOption("-Xverify:all", NULL); } else if (JLI_StrCmp(arg, "-verifyremote") == 0) { + JLI_ReportErrorMessage(ARG_DEPRECATED, "-verifyremote"); AddOption("-Xverify:remote", NULL); } else if (JLI_StrCmp(arg, "-noverify") == 0) { /* @@ -1486,20 +1307,16 @@ ParseArguments(int *pargc, char ***pargv, */ AddOption("-Xverify:none", NULL); } else if (JLI_StrCCmp(arg, "-ss") == 0 || - JLI_StrCCmp(arg, "-oss") == 0 || JLI_StrCCmp(arg, "-ms") == 0 || JLI_StrCCmp(arg, "-mx") == 0) { + JLI_ReportErrorMessage("Warning: %.3s option is deprecated" + " and may be removed in a future release.", arg); size_t tmpSize = JLI_StrLen(arg) + 6; char *tmp = JLI_MemAlloc(tmpSize); snprintf(tmp, tmpSize, "-X%s", arg + 1); /* skip '-' */ AddOption(tmp, NULL); - } else if (JLI_StrCmp(arg, "-checksource") == 0 || - JLI_StrCmp(arg, "-cs") == 0 || - JLI_StrCmp(arg, "-noasyncgc") == 0) { - /* No longer supported */ - JLI_ReportErrorMessage(ARG_WARN, arg); } else if (JLI_StrCCmp(arg, "-splash:") == 0) { - ; /* Ignore machine independent options already handled */ + splash_file_path = arg + 8; } else if (JLI_StrCmp(arg, "--disable-@files") == 0) { ; /* Ignore --disable-@files option already handled */ } else if (ProcessPlatformOption(arg)) { @@ -1508,6 +1325,14 @@ ParseArguments(int *pargc, char ***pargv, /* java.class.path set on the command line */ if (JLI_StrCCmp(arg, "-Djava.class.path=") == 0) { _have_classpath = JNI_TRUE; + } else if (JLI_StrCmp(arg, "-Djava.awt.headless=true") == 0) { + /* + * Checking for headless toolkit option in the same way as AWT does: + * "true" means true and any other value means false + */ + headless = true; + } else if (JLI_StrCCmp(arg, "-Djava.awt.headless=") == 0) { + headless = false; } AddOption(arg, NULL); } @@ -1558,9 +1383,82 @@ ParseArguments(int *pargc, char ***pargv, *pmode = mode; + if (!headless) { + char *jar_path = NULL; + if (mode == LM_JAR) { + jar_path = *pwhat; + } + // Not in headless mode. We now set a couple of env variables that + // will be used later by ShowSplashScreen(). + SetupSplashScreenEnvVars(splash_file_path, jar_path); + } + return JNI_TRUE; } +/* + * Sets the relevant environment variables that are subsequently used by + * the ShowSplashScreen() function. The splash_file_path and jar_path parameters + * are used to determine which environment variables to set. + * The splash_file_path is the value that was provided to the "-splash:" option + * when launching java. It may be null, which implies the "-splash:" option wasn't used. + * The jar_path is the value that was provided to the "-jar" option when launching java. + * It too may be null, which implies the "-jar" option wasn't used. + */ +static void +SetupSplashScreenEnvVars(const char *splash_file_path, char *jar_path) { + // Command line specified "-splash:" takes priority over manifest one. + if (splash_file_path) { + // We set up the splash file name as a env variable which then gets + // used when showing the splash screen in ShowSplashScreen(). + + // create the string of the form _JAVA_SPLASH_FILE= + splash_file_entry = JLI_MemAlloc(JLI_StrLen(SPLASH_FILE_ENV_ENTRY "=") + + JLI_StrLen(splash_file_path) + 1); + JLI_StrCpy(splash_file_entry, SPLASH_FILE_ENV_ENTRY "="); + JLI_StrCat(splash_file_entry, splash_file_path); + putenv(splash_file_entry); + return; + } + if (!jar_path) { + // no jar to look into for "SplashScreen-Image" manifest attribute + return; + } + // parse the jar's manifest to find any "SplashScreen-Image" + int res = 0; + manifest_info info; + if ((res = JLI_ParseManifest(jar_path, &info)) != 0) { + JLI_FreeManifest(); // cleanup any manifest structure + if (res == -1) { + JLI_ReportErrorMessage(JAR_ERROR2, jar_path); + } else { + JLI_ReportErrorMessage(JAR_ERROR3, jar_path); + } + exit(1); + } + if (!info.splashscreen_image_file_name) { + JLI_FreeManifest(); // cleanup the manifest structure + // no "SplashScreen-Image" in jar's manifest + return; + } + // The jar's manifest had a "Splashscreen-Image" specified. We set up the jar entry name + // and the jar file name as env variables which then get used when showing the splash screen + // in ShowSplashScreen(). + + // create the string of the form _JAVA_SPLASH_FILE= + splash_file_entry = JLI_MemAlloc(JLI_StrLen(SPLASH_FILE_ENV_ENTRY "=") + + JLI_StrLen(info.splashscreen_image_file_name) + 1); + JLI_StrCpy(splash_file_entry, SPLASH_FILE_ENV_ENTRY "="); + JLI_StrCat(splash_file_entry, info.splashscreen_image_file_name); + putenv(splash_file_entry); + // create the string of the form _JAVA_SPLASH_JAR= + splash_jar_entry = JLI_MemAlloc(JLI_StrLen(SPLASH_JAR_ENV_ENTRY "=") + JLI_StrLen(jar_path) + 1); + JLI_StrCpy(splash_jar_entry, SPLASH_JAR_ENV_ENTRY "="); + JLI_StrCat(splash_jar_entry, jar_path); + putenv(splash_jar_entry); + JLI_FreeManifest(); // cleanup the manifest structure +} + /* * Initializes the Java Virtual Machine. Also frees options array when * finished. @@ -1624,7 +1522,7 @@ NewPlatformString(JNIEnv *env, char *s) if (ary != 0) { jstring str = 0; (*env)->SetByteArrayRegion(env, ary, 0, len, (jbyte *)s); - if (!(*env)->ExceptionOccurred(env)) { + if (!(*env)->ExceptionCheck(env)) { if (makePlatformStringMID == NULL) { NULL_CHECK0(makePlatformStringMID = (*env)->GetStaticMethodID(env, cls, "makePlatformString", "(Z[B)Ljava/lang/String;")); @@ -2347,7 +2245,7 @@ ShowSplashScreen() * Done with all command line processing and potential re-execs so * clean up the environment. */ - (void)UnsetEnv(ENV_ENTRY); + (void)UnsetEnv(MAIN_CLASS_ENV_ENTRY); (void)UnsetEnv(SPLASH_FILE_ENV_ENTRY); (void)UnsetEnv(SPLASH_JAR_ENV_ENTRY); diff --git a/src/java.base/share/native/libjli/java.h b/src/java.base/share/native/libjli/java.h index f768b58a001..19493fedaae 100644 --- a/src/java.base/share/native/libjli/java.h +++ b/src/java.base/share/native/libjli/java.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -48,26 +48,20 @@ # define MB (1024UL * KB) # define GB (1024UL * MB) -#define CURRENT_DATA_MODEL (CHAR_BIT * sizeof(void*)) - /* - * The following environment variable is used to influence the behavior - * of the jre exec'd through the SelectVersion routine. The command line - * options which specify the version are not passed to the exec'd version, - * because that jre may be an older version which wouldn't recognize them. - * This environment variable is known to this (and later) version and serves - * to suppress the version selection code. This is not only for efficiency, - * but also for correctness, since any command line options have been - * removed which would cause any value found in the manifest to be used. - * This would be incorrect because the command line options are defined - * to take precedence. - * - * The value associated with this environment variable is the MainClass - * name from within the executable jar file (if any). This is strictly a - * performance enhancement to avoid re-reading the jar file manifest. - * + * Older versions of java launcher used to support JRE version selection - specifically, + * the java launcher in JDK 1.8 can be used to launch a java application using a different + * java runtime (older, newer or same version JRE installed at a different location) than + * the one the launcher belongs to. + * That support was discontinued starting JDK 9. However, the JDK 8 launcher can still + * be started with JRE version selection options to launch Java runtimes greater than JDK 8. + * In such cases, the JDK 8 launcher when exec()ing the JDK N launcher, will set and propagate + * the _JAVA_VERSION_SET environment variable. The value of this environment variable is the + * Main-Class name from within the executable jar file (if any). + * The java launcher in the current version of the JDK doesn't use this environment variable + * in any way other than merely using it in debug logging. */ -#define ENV_ENTRY "_JAVA_VERSION_SET" +#define MAIN_CLASS_ENV_ENTRY "_JAVA_VERSION_SET" #define SPLASH_FILE_ENV_ENTRY "_JAVA_SPLASH_FILE" #define SPLASH_JAR_ENV_ENTRY "_JAVA_SPLASH_JAR" @@ -107,17 +101,12 @@ JLI_Launch(int argc, char ** argv, /* main argc, argc */ jboolean LoadJavaVM(const char *jvmpath, InvocationFunctions *ifn); -void -GetXUsagePath(char *buf, jint bufsize); - jboolean GetApplicationHome(char *buf, jint bufsize); jboolean GetApplicationHomeFromDll(char *buf, jint bufsize); -#define GetArch() GetArchPath(CURRENT_DATA_MODEL) - /* * Different platforms will implement this, here * pargc is a pointer to the original argc, @@ -153,7 +142,6 @@ void JLI_ShowMessage(const char * message, ...); */ JNIEXPORT void JNICALL JLI_ReportExceptionDescription(JNIEnv * env); -void PrintMachineDependentOptions(); /* * Block current thread and continue execution in new thread. @@ -258,14 +246,14 @@ typedef struct { #define CHECK_EXCEPTION_RETURN_VALUE(CER_value) \ do { \ - if ((*env)->ExceptionOccurred(env)) { \ + if ((*env)->ExceptionCheck(env)) { \ return CER_value; \ } \ } while (JNI_FALSE) #define CHECK_EXCEPTION_RETURN() \ do { \ - if ((*env)->ExceptionOccurred(env)) { \ + if ((*env)->ExceptionCheck(env)) { \ return; \ } \ } while (JNI_FALSE) diff --git a/src/java.base/share/native/libjli/manifest_info.h b/src/java.base/share/native/libjli/manifest_info.h index ce18d27ebde..b3596f43e82 100644 --- a/src/java.base/share/native/libjli/manifest_info.h +++ b/src/java.base/share/native/libjli/manifest_info.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -167,10 +167,6 @@ typedef struct zentry { /* Zip file entry */ * Java launcher). */ typedef struct manifest_info { /* Interesting fields from the Manifest */ - char *manifest_version; /* Manifest-Version string */ - char *main_class; /* Main-Class entry */ - char *jre_version; /* Appropriate J2SE release spec */ - char jre_restrict_search; /* Restricted JRE search */ char *splashscreen_image_file_name; /* splashscreen image file */ } manifest_info; diff --git a/src/java.base/share/native/libjli/parse_manifest.c b/src/java.base/share/native/libjli/parse_manifest.c index c351ae8abc1..274825a4af5 100644 --- a/src/java.base/share/native/libjli/parse_manifest.c +++ b/src/java.base/share/native/libjli/parse_manifest.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -594,10 +594,6 @@ JLI_ParseManifest(char *jarfile, manifest_info *info) )) == -1) { return (-1); } - info->manifest_version = NULL; - info->main_class = NULL; - info->jre_version = NULL; - info->jre_restrict_search = 0; info->splashscreen_image_file_name = NULL; if ((rc = find_file(fd, &entry, manifest_name)) != 0) { close(fd); @@ -610,17 +606,7 @@ JLI_ParseManifest(char *jarfile, manifest_info *info) } lp = manifest; while ((rc = parse_nv_pair(&lp, &name, &value)) > 0) { - if (JLI_StrCaseCmp(name, "Manifest-Version") == 0) { - info->manifest_version = value; - } else if (JLI_StrCaseCmp(name, "Main-Class") == 0) { - info->main_class = value; - } else if (JLI_StrCaseCmp(name, "JRE-Version") == 0) { - /* - * Manifest specification overridden by command line option - * so we will silently override there with no specification. - */ - info->jre_version = 0; - } else if (JLI_StrCaseCmp(name, "Splashscreen-Image") == 0) { + if (JLI_StrCaseCmp(name, "Splashscreen-Image") == 0) { info->splashscreen_image_file_name = value; } } diff --git a/src/java.base/unix/classes/sun/nio/fs/UnixFileAttributes.java b/src/java.base/unix/classes/sun/nio/fs/UnixFileAttributes.java index 3b09bd259ce..2a036d22aed 100644 --- a/src/java.base/unix/classes/sun/nio/fs/UnixFileAttributes.java +++ b/src/java.base/unix/classes/sun/nio/fs/UnixFileAttributes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -58,6 +58,7 @@ class UnixFileAttributes private long st_ctime_nsec; private long st_birthtime_sec; private long st_birthtime_nsec; + private boolean birthtime_available; // created lazily private volatile UserPrincipal owner; @@ -163,10 +164,10 @@ class UnixFileAttributes @Override public FileTime creationTime() { - if (UnixNativeDispatcher.birthtimeSupported()) { + if (UnixNativeDispatcher.birthtimeSupported() && birthtime_available) { return toFileTime(st_birthtime_sec, st_birthtime_nsec); } else { - // return last modified when birth time not supported + // return last modified when birth time unsupported or unavailable return lastModifiedTime(); } } diff --git a/src/java.base/unix/native/libjava/ProcessHandleImpl_unix.c b/src/java.base/unix/native/libjava/ProcessHandleImpl_unix.c index acc7f0c73c9..c8c948e7767 100644 --- a/src/java.base/unix/native/libjava/ProcessHandleImpl_unix.c +++ b/src/java.base/unix/native/libjava/ProcessHandleImpl_unix.c @@ -528,7 +528,7 @@ jint unix_getChildren(JNIEnv *env, jlong jpid, jlongArray jarray, * position integer as a filename. */ if ((dir = opendir("/proc")) == NULL) { - JNU_ThrowByNameWithLastError(env, + JNU_ThrowByNameWithMessageAndLastError(env, "java/lang/RuntimeException", "Unable to open /proc"); return -1; } diff --git a/src/java.base/unix/native/libjava/io_util_md.c b/src/java.base/unix/native/libjava/io_util_md.c index 28659b3a1c2..9895ac3b73f 100644 --- a/src/java.base/unix/native/libjava/io_util_md.c +++ b/src/java.base/unix/native/libjava/io_util_md.c @@ -135,7 +135,7 @@ void fileDescriptorClose(JNIEnv *env, jobject this) { FD fd = (*env)->GetIntField(env, this, IO_fd_fdID); - if ((*env)->ExceptionOccurred(env)) { + if ((*env)->ExceptionCheck(env)) { return; } @@ -150,7 +150,7 @@ fileDescriptorClose(JNIEnv *env, jobject this) * taking extra precaution over here. */ (*env)->SetIntField(env, this, IO_fd_fdID, -1); - if ((*env)->ExceptionOccurred(env)) { + if ((*env)->ExceptionCheck(env)) { return; } /* diff --git a/src/java.base/unix/native/libjava/java_props_md.c b/src/java.base/unix/native/libjava/java_props_md.c index 4766a883472..4a6d0f7f5a4 100644 --- a/src/java.base/unix/native/libjava/java_props_md.c +++ b/src/java.base/unix/native/libjava/java_props_md.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -521,11 +521,14 @@ GetJavaProperties(JNIEnv *env) { char buf[MAXPATHLEN]; errno = 0; - if (getcwd(buf, sizeof(buf)) == NULL) + if (getcwd(buf, sizeof(buf)) == NULL) { JNU_ThrowByName(env, "java/lang/Error", - "Properties init: Could not determine current working directory."); - else + "Properties init: Could not determine current working directory."); + return NULL; + } + else { sprops.user_dir = strdup(buf); + } } sprops.file_separator = "/"; diff --git a/src/java.base/unix/native/libjli/java_md.c b/src/java.base/unix/native/libjli/java_md.c index 2a1a4e7795a..7f2f5638a6b 100644 --- a/src/java.base/unix/native/libjli/java_md.c +++ b/src/java.base/unix/native/libjli/java_md.c @@ -52,102 +52,86 @@ #endif /* - * Flowchart of launcher execs and options processing on unix + * Following is the high level flow of the launcher + * code residing in the common java.c and this + * unix specific java_md file: * - * The selection of the proper vm shared library to open depends on - * several classes of command line options, including vm "flavor" - * options (-client, -server). - * The vm selection options are not passed to the running - * virtual machine; they must be screened out by the launcher. + * - JLI_Launch function, which is the entry point + * to the launcher, calls CreateExecutionEnvironment. * - * The version specification (if any) is processed first by the - * platform independent routine SelectVersion. This may result in - * the exec of the specified launcher version. + * - CreateExecutionEnvironment does the following + * (not necessarily in this order): + * - determines the relevant JVM type that + * needs to be ultimately created + * - determines the path and asserts the presence + * of libjava and relevant libjvm library + * - removes any JVM selection options from the + * arguments that were passed to the launcher * - * Previously the launcher modified the LD_LIBRARY_PATH appropriately for the - * desired data model path, regardless if data models matched or not. The - * launcher subsequently exec'ed the desired executable, in order to make the - * LD_LIBRARY_PATH path available, for the runtime linker. + * - CreateExecutionEnvironment then determines (by calling + * RequiresSetenv function) if LD_LIBRARY_PATH environment + * variable needs to be set/updated. + * - If LD_LIBRARY_PATH needs to be set/updated, + * then CreateExecutionEnvironment exec()s + * the current process with the appropriate value + * for LD_LIBRARY_PATH. + * - Else if LD_LIBRARY_PATH need not be set or + * updated, then CreateExecutionEnvironment + * returns back. * - * Now, in most cases,the launcher will dlopen the target libjvm.so. All - * required libraries are loaded by the runtime linker, using the - * $RPATH/$ORIGIN baked into the shared libraries at compile time. Therefore, - * in most cases, the launcher will only exec, if the data models are - * mismatched, and will not set any environment variables, regardless of the - * data models. + * - If CreateExecutionEnvironment exec()ed the process + * in the previous step, then the code control for the + * process will again start from the process' entry + * point and JLI_Launch is thus re-invoked and the + * same above sequence of code flow repeats again. + * During this "recursive" call into CreateExecutionEnvironment, + * the implementation of the check for LD_LIBRARY_PATH + * will realize that no further exec() is required and + * the control will return back from CreateExecutionEnvironment. * - * However, if the environment contains a LD_LIBRARY_PATH, this will cause the - * launcher to inspect the LD_LIBRARY_PATH. The launcher will check - * a. if the LD_LIBRARY_PATH's first component is the path to the desired - * libjvm.so - * b. if any other libjvm.so is found in any of the paths. - * If case b is true, then the launcher will set the LD_LIBRARY_PATH to the - * desired JRE and reexec, in order to propagate the environment. + * - The control returns back from CreateExecutionEnvironment + * to JLI_Launch. * - * Main - * (incoming argv) - * | - * \|/ - * CreateExecutionEnvironment - * (determines desired data model) - * | - * | - * \|/ - * Have Desired Model ? --> NO --> Exit(with error) - * | - * | - * \|/ - * YES - * | - * | - * \|/ - * CheckJvmType - * (removes -client, -server, etc.) - * | - * | - * \|/ - * TranslateDashJArgs... - * (Prepare to pass args to vm) - * | - * | - * \|/ - * ParseArguments - * | - * | - * \|/ - * RequiresSetenv - * Is LD_LIBRARY_PATH - * and friends set ? --> NO --> Continue - * YES - * | - * | - * \|/ - * Path is desired JRE ? YES --> Continue - * NO - * | - * | - * \|/ - * Paths have well known - * jvm paths ? --> NO --> Error/Exit - * YES - * | - * | - * \|/ - * Does libjvm.so exist - * in any of them ? --> NO --> Continue - * YES - * | - * | - * \|/ - * Set the LD_LIBRARY_PATH - * | - * | - * \|/ - * Re-exec - * | - * | - * \|/ - * Main + * - JLI_Launch then invokes LoadJavaVM which dlopen()s + * the JVM library and asserts the presence of + * JNI Invocation Functions "JNI_CreateJavaVM", + * "JNI_GetDefaultJavaVMInitArgs" and + * "JNI_GetCreatedJavaVMs" in that library. It then + * sets internal function pointers in the launcher to + * point to those functions. + * + * - JLI_Launch then translates any -J options by + * invoking TranslateApplicationArgs. + * + * - JLI_Launch then invokes ParseArguments to + * parse/process the launcher arguments. + * + * - JLI_Launch then ultimately calls JVMInit. + * + * - JVMInit invokes ShowSplashScreen which displays + * a splash screen for the application, if applicable. + * + * - JVMInit then creates a new thread (T2), in the + * current process, and invokes JavaMain function + * in that new thread. The current thread (T1) then + * waits for the newly launched thread (T2) to complete. + * + * - JavaMain function, in thread T2, before launching + * the application, invokes PostJVMInit. + * + * - PostJVMInit is a no-op and returns back. + * + * - Control then returns back from PostJVMInit into JavaMain, + * which then loads the application's main class and invokes + * the relevant main() Java method. + * + * - JavaMain, in thread T2, then returns back an integer + * result and thread T2 execution ends here. + * + * - The thread T1 in JVMInit, which is waiting on T2 to + * complete, receives the integer result and then propagates + * it as a return value all the way out of the + * JLI_Launch function. */ /* Store the name of the executable once computed */ @@ -221,13 +205,12 @@ ContainsLibJVM(const char *env) { } /* - * Test whether the environment variable needs to be set, see flowchart. + * Test whether the LD_LIBRARY_PATH environment variable needs to be set. */ static jboolean RequiresSetenv(const char *jvmpath) { char jpath[PATH_MAX + 1]; char *llp; - char *dmllp = NULL; char *p; /* a utility pointer */ #ifdef MUSL_LIBC @@ -245,7 +228,7 @@ RequiresSetenv(const char *jvmpath) { llp = getenv("LD_LIBRARY_PATH"); /* no environment variable is a good environment variable */ - if (llp == NULL && dmllp == NULL) { + if (llp == NULL) { return JNI_FALSE; } #ifdef __linux @@ -284,9 +267,6 @@ RequiresSetenv(const char *jvmpath) { if (llp != NULL && ContainsLibJVM(llp)) { return JNI_TRUE; } - if (dmllp != NULL && ContainsLibJVM(dmllp)) { - return JNI_TRUE; - } return JNI_FALSE; } #endif /* SETENV_REQUIRED */ diff --git a/src/java.base/unix/native/libjli/java_md_common.c b/src/java.base/unix/native/libjli/java_md_common.c index 511519ae362..453d605f710 100644 --- a/src/java.base/unix/native/libjli/java_md_common.c +++ b/src/java.base/unix/native/libjli/java_md_common.c @@ -243,13 +243,7 @@ JLI_ReportErrorMessage(const char* fmt, ...) { JNIEXPORT void JNICALL JLI_ReportErrorMessageSys(const char* fmt, ...) { va_list vl; - char *emsg; - - /* - * TODO: its safer to use strerror_r but is not available on - * Solaris 8. Until then.... - */ - emsg = strerror(errno); + char *emsg = strerror(errno); if (emsg != NULL) { fprintf(stderr, "%s\n", emsg); } diff --git a/src/java.base/unix/native/libjsig/jsig.c b/src/java.base/unix/native/libjsig/jsig.c index 1a0a6bec892..180dd583393 100644 --- a/src/java.base/unix/native/libjsig/jsig.c +++ b/src/java.base/unix/native/libjsig/jsig.c @@ -42,14 +42,7 @@ #include #include #include - -#if (__STDC_VERSION__ >= 199901L) - #include -#else - #define bool int - #define true 1 - #define false 0 -#endif +#include #define MAX_SIGNALS NSIG diff --git a/src/java.base/unix/native/libnet/NetworkInterface.c b/src/java.base/unix/native/libnet/NetworkInterface.c index 0cd69399d91..61267ec13d5 100644 --- a/src/java.base/unix/native/libnet/NetworkInterface.c +++ b/src/java.base/unix/native/libnet/NetworkInterface.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -374,7 +374,7 @@ JNIEXPORT jboolean JNICALL Java_java_net_NetworkInterface_boundInetAddress0 if (family == AF_INET) { sock = openSocket(env, AF_INET); - if (sock < 0 && (*env)->ExceptionOccurred(env)) { + if (sock < 0 && (*env)->ExceptionCheck(env)) { return JNI_FALSE; } @@ -383,7 +383,7 @@ JNIEXPORT jboolean JNICALL Java_java_net_NetworkInterface_boundInetAddress0 ifs = enumIPv4Interfaces(env, sock, ifs); close(sock); - if ((*env)->ExceptionOccurred(env)) { + if ((*env)->ExceptionCheck(env)) { goto cleanup; } } @@ -401,7 +401,7 @@ JNIEXPORT jboolean JNICALL Java_java_net_NetworkInterface_boundInetAddress0 ifs = enumIPv6Interfaces(env, sock, ifs); close(sock); - if ((*env)->ExceptionOccurred(env)) { + if ((*env)->ExceptionCheck(env)) { goto cleanup; } @@ -856,7 +856,7 @@ static netif *enumInterfaces(JNIEnv *env) { int sock; sock = openSocket(env, AF_INET); - if (sock < 0 && (*env)->ExceptionOccurred(env)) { + if (sock < 0 && (*env)->ExceptionCheck(env)) { return NULL; } @@ -865,7 +865,7 @@ static netif *enumInterfaces(JNIEnv *env) { ifs = enumIPv4Interfaces(env, sock, ifs); close(sock); - if ((*env)->ExceptionOccurred(env)) { + if ((*env)->ExceptionCheck(env)) { freeif(ifs); return NULL; } @@ -884,7 +884,7 @@ static netif *enumInterfaces(JNIEnv *env) { ifs = enumIPv6Interfaces(env, sock, ifs); close(sock); - if ((*env)->ExceptionOccurred(env)) { + if ((*env)->ExceptionCheck(env)) { freeif(ifs); return NULL; } @@ -1237,7 +1237,7 @@ static netif *enumIPv4Interfaces(JNIEnv *env, int sock, netif *ifs) { &addr, broadaddrP, AF_INET, prefix); // in case of exception, free interface list and buffer and return NULL - if ((*env)->ExceptionOccurred(env)) { + if ((*env)->ExceptionCheck(env)) { free(buf); freeif(ifs); return NULL; @@ -1281,7 +1281,7 @@ static netif *enumIPv6Interfaces(JNIEnv *env, int sock, netif *ifs) { NULL, AF_INET6, (short)prefix); // if an exception occurred then return the list as is - if ((*env)->ExceptionOccurred(env)) { + if ((*env)->ExceptionCheck(env)) { break; } } @@ -1478,7 +1478,7 @@ static netif *enumIPv4Interfaces(JNIEnv *env, int sock, netif *ifs) { &addr, broadaddrP, AF_INET, prefix); // in case of exception, free interface list and buffer and return NULL - if ((*env)->ExceptionOccurred(env)) { + if ((*env)->ExceptionCheck(env)) { free(buf); freeif(ifs); return NULL; @@ -1552,7 +1552,7 @@ static netif *enumIPv6Interfaces(JNIEnv *env, int sock, netif *ifs) { NULL, AF_INET6, prefix); // if an exception occurred then free the list - if ((*env)->ExceptionOccurred(env)) { + if ((*env)->ExceptionCheck(env)) { free(buf); freeif(ifs); return NULL; @@ -1717,7 +1717,7 @@ static netif *enumIPv4Interfaces(JNIEnv *env, int sock, netif *ifs) { ifa->ifa_netmask)); // if an exception occurred then free the list - if ((*env)->ExceptionOccurred(env)) { + if ((*env)->ExceptionCheck(env)) { freeifaddrs(origifa); freeif(ifs); return NULL; @@ -1757,7 +1757,7 @@ static netif *enumIPv6Interfaces(JNIEnv *env, int sock, netif *ifs) { ifa->ifa_netmask)); // if an exception occurred then free the list - if ((*env)->ExceptionOccurred(env)) { + if ((*env)->ExceptionCheck(env)) { freeifaddrs(origifa); freeif(ifs); return NULL; diff --git a/src/java.base/unix/native/libnet/SdpSupport.c b/src/java.base/unix/native/libnet/SdpSupport.c index 6729170efb4..b56f16905fa 100644 --- a/src/java.base/unix/native/libnet/SdpSupport.c +++ b/src/java.base/unix/native/libnet/SdpSupport.c @@ -106,7 +106,7 @@ Java_sun_net_sdp_SdpSupport_convert0(JNIEnv *env, jclass cls, int fd) if (res < 0) JNU_ThrowIOExceptionWithLastError(env, "dup2"); res = close(s); - if (res < 0 && !(*env)->ExceptionOccurred(env)) + if (res < 0 && !(*env)->ExceptionCheck(env)) JNU_ThrowIOExceptionWithLastError(env, "close"); } } diff --git a/src/java.base/unix/native/libnio/MappedMemoryUtils.c b/src/java.base/unix/native/libnio/MappedMemoryUtils.c index cdd8edff22a..6cfa3b47f84 100644 --- a/src/java.base/unix/native/libnio/MappedMemoryUtils.c +++ b/src/java.base/unix/native/libnio/MappedMemoryUtils.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,9 +40,8 @@ typedef unsigned char mincore_vec_t; typedef char mincore_vec_t; #endif -JNIEXPORT jboolean JNICALL -Java_java_nio_MappedMemoryUtils_isLoaded0(JNIEnv *env, jobject obj, jlong address, - jlong len, jlong numPages) +jboolean JNICALL MappedMemoryUtils_isLoaded0(JNIEnv *env, jobject obj, jlong address, + jlong len, jlong numPages) { jboolean loaded = JNI_TRUE; int result = 0; @@ -80,8 +79,7 @@ Java_java_nio_MappedMemoryUtils_isLoaded0(JNIEnv *env, jobject obj, jlong addres } -JNIEXPORT void JNICALL -Java_java_nio_MappedMemoryUtils_load0(JNIEnv *env, jobject obj, jlong address, +void JNICALL MappedMemoryUtils_load0(JNIEnv *env, jobject obj, jlong address, jlong len) { char *a = (char *)jlong_to_ptr(address); @@ -91,9 +89,8 @@ Java_java_nio_MappedMemoryUtils_load0(JNIEnv *env, jobject obj, jlong address, } } -JNIEXPORT void JNICALL -Java_java_nio_MappedMemoryUtils_unload0(JNIEnv *env, jobject obj, jlong address, - jlong len) +void JNICALL MappedMemoryUtils_unload0(JNIEnv *env, jobject obj, jlong address, + jlong len) { char *a = (char *)jlong_to_ptr(address); int result = madvise((caddr_t)a, (size_t)len, MADV_DONTNEED); @@ -102,8 +99,7 @@ Java_java_nio_MappedMemoryUtils_unload0(JNIEnv *env, jobject obj, jlong address, } } -JNIEXPORT void JNICALL -Java_java_nio_MappedMemoryUtils_force0(JNIEnv *env, jobject obj, jobject fdo, +void JNICALL MappedMemoryUtils_force0(JNIEnv *env, jobject obj, jobject fdo, jlong address, jlong len) { void* a = (void *)jlong_to_ptr(address); @@ -112,3 +108,19 @@ Java_java_nio_MappedMemoryUtils_force0(JNIEnv *env, jobject obj, jobject fdo, JNU_ThrowIOExceptionWithMessageAndLastError(env, "msync with parameter MS_SYNC failed"); } } + +#define FD "Ljava/io/FileDescriptor;" + +static JNINativeMethod methods[] = { + {"isLoaded0", "(JJJ)Z", (void *)&MappedMemoryUtils_isLoaded0}, + {"load0", "(JJ)V", (void *)&MappedMemoryUtils_load0}, + {"unload0", "(JJ)V", (void *)&MappedMemoryUtils_unload0}, + {"force0", "(" FD "JJ)V", (void *)&MappedMemoryUtils_force0}, +}; + +JNIEXPORT void JNICALL +Java_java_nio_MappedMemoryUtils_registerNatives(JNIEnv *env, jclass cls) +{ + (*env)->RegisterNatives(env, cls, + methods, sizeof(methods)/sizeof(methods[0])); +} diff --git a/src/java.base/unix/native/libnio/ch/UnixDomainSockets.c b/src/java.base/unix/native/libnio/ch/UnixDomainSockets.c index 73db22a9176..c43c3b90695 100644 --- a/src/java.base/unix/native/libnio/ch/UnixDomainSockets.c +++ b/src/java.base/unix/native/libnio/ch/UnixDomainSockets.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -62,7 +62,7 @@ jbyteArray sockaddrToUnixAddressBytes(JNIEnv *env, struct sockaddr_un *sa, sockl jbyteArray name = (*env)->NewByteArray(env, namelen); if (namelen != 0) { (*env)->SetByteArrayRegion(env, name, 0, namelen, (jbyte*)sa->sun_path); - if ((*env)->ExceptionOccurred(env)) { + if ((*env)->ExceptionCheck(env)) { return NULL; } } diff --git a/src/java.base/unix/native/libnio/fs/UnixNativeDispatcher.c b/src/java.base/unix/native/libnio/fs/UnixNativeDispatcher.c index b91ab6f0cab..61e9215471a 100644 --- a/src/java.base/unix/native/libnio/fs/UnixNativeDispatcher.c +++ b/src/java.base/unix/native/libnio/fs/UnixNativeDispatcher.c @@ -184,6 +184,7 @@ static jfieldID attrs_st_birthtime_sec; #if defined(__linux__) // Linux has nsec granularity if supported static jfieldID attrs_st_birthtime_nsec; #endif +static jfieldID attrs_birthtime_available; static jfieldID attrs_f_frsize; static jfieldID attrs_f_blocks; @@ -332,6 +333,8 @@ Java_sun_nio_fs_UnixNativeDispatcher_init(JNIEnv* env, jclass this) attrs_st_birthtime_nsec = (*env)->GetFieldID(env, clazz, "st_birthtime_nsec", "J"); CHECK_NULL_RETURN(attrs_st_birthtime_nsec, 0); #endif + attrs_birthtime_available = (*env)->GetFieldID(env, clazz, "birthtime_available", "Z"); + CHECK_NULL_RETURN(attrs_birthtime_available, 0); clazz = (*env)->FindClass(env, "sun/nio/fs/UnixFileStoreAttributes"); CHECK_NULL_RETURN(clazz, 0); @@ -620,19 +623,19 @@ static void copy_statx_attributes(JNIEnv* env, struct my_statx* buf, jobject att (*env)->SetLongField(env, attrs, attrs_st_atime_sec, (jlong)buf->stx_atime.tv_sec); (*env)->SetLongField(env, attrs, attrs_st_mtime_sec, (jlong)buf->stx_mtime.tv_sec); (*env)->SetLongField(env, attrs, attrs_st_ctime_sec, (jlong)buf->stx_ctime.tv_sec); + + // Check mask for birth time and set flag accordingly. The birth time is + // filled in if and only if the STATX_BTIME bit is set in the mask. + // Although the statx system call might be supported by the operating + // system, the birth time is not necessarily supported by the file system. if ((buf->stx_mask & STATX_BTIME) != 0) { - // Birth time was filled in so use it - (*env)->SetLongField(env, attrs, attrs_st_birthtime_sec, - (jlong)buf->stx_btime.tv_sec); - (*env)->SetLongField(env, attrs, attrs_st_birthtime_nsec, - (jlong)buf->stx_btime.tv_nsec); + (*env)->SetBooleanField(env, attrs, attrs_birthtime_available, (jboolean)JNI_TRUE); + (*env)->SetLongField(env, attrs, attrs_st_birthtime_sec, (jlong)buf->stx_btime.tv_sec); + (*env)->SetLongField(env, attrs, attrs_st_birthtime_nsec, (jlong)buf->stx_btime.tv_nsec); } else { - // Birth time was not filled in: fall back to last modification time - (*env)->SetLongField(env, attrs, attrs_st_birthtime_sec, - (jlong)buf->stx_mtime.tv_sec); - (*env)->SetLongField(env, attrs, attrs_st_birthtime_nsec, - (jlong)buf->stx_mtime.tv_nsec); + (*env)->SetBooleanField(env, attrs, attrs_birthtime_available, (jboolean)JNI_FALSE); } + (*env)->SetLongField(env, attrs, attrs_st_atime_nsec, (jlong)buf->stx_atime.tv_nsec); (*env)->SetLongField(env, attrs, attrs_st_mtime_nsec, (jlong)buf->stx_mtime.tv_nsec); (*env)->SetLongField(env, attrs, attrs_st_ctime_nsec, (jlong)buf->stx_ctime.tv_nsec); @@ -661,7 +664,9 @@ static void copy_stat_attributes(JNIEnv* env, struct stat* buf, jobject attrs) { (*env)->SetLongField(env, attrs, attrs_st_ctime_sec, (jlong)buf->st_ctime); #ifdef _DARWIN_FEATURE_64_BIT_INODE + // birthtime_available defaults to 'false'; on Darwin, it is always true (*env)->SetLongField(env, attrs, attrs_st_birthtime_sec, (jlong)buf->st_birthtime); + (*env)->SetBooleanField(env, attrs, attrs_birthtime_available, (jboolean)JNI_TRUE); // rely on default value of 0 for st_birthtime_nsec field on Darwin #endif diff --git a/src/java.base/windows/classes/java/io/WinNTFileSystem.java b/src/java.base/windows/classes/java/io/WinNTFileSystem.java index cf58d980bbe..10e02b4ba72 100644 --- a/src/java.base/windows/classes/java/io/WinNTFileSystem.java +++ b/src/java.base/windows/classes/java/io/WinNTFileSystem.java @@ -490,12 +490,26 @@ final class WinNTFileSystem extends FileSystem { return path; return "" + ((char) (c-32)) + ':' + '\\'; } - return canonicalize0(path); + String canonicalPath = canonicalize0(path); + String finalPath = null; + try { + finalPath = getFinalPath(canonicalPath); + } catch (IOException ignored) { + finalPath = canonicalPath; + } + return finalPath; } private native String canonicalize0(String path) throws IOException; + private String getFinalPath(String path) throws IOException { + return getFinalPath0(path); + } + + private native String getFinalPath0(String path) + throws IOException; + /* -- Attribute accessors -- */ diff --git a/src/java.base/windows/classes/sun/nio/fs/WindowsLinkSupport.java b/src/java.base/windows/classes/sun/nio/fs/WindowsLinkSupport.java index 4e844df03f8..4ccd1d702bd 100644 --- a/src/java.base/windows/classes/sun/nio/fs/WindowsLinkSupport.java +++ b/src/java.base/windows/classes/sun/nio/fs/WindowsLinkSupport.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -86,7 +86,7 @@ class WindowsLinkSupport { x.rethrowAsIOException(path); } try { - return readLinkImpl(handle); + return readLinkImpl(path, handle); } finally { CloseHandle(handle); } @@ -297,16 +297,18 @@ class WindowsLinkSupport { * Returns target of a symbolic link given the handle of an open file * (that should be a link). */ - private static String readLinkImpl(long handle) throws IOException { + private static String readLinkImpl(WindowsPath path, long handle) + throws IOException + { int size = MAXIMUM_REPARSE_DATA_BUFFER_SIZE; try (NativeBuffer buffer = NativeBuffers.getNativeBuffer(size)) { try { DeviceIoControlGetReparsePoint(handle, buffer.address(), size); } catch (WindowsException x) { - // FIXME: exception doesn't have file name + String pathname = path.getPathForExceptionMessage(); if (x.lastError() == ERROR_NOT_A_REPARSE_POINT) - throw new NotLinkException(null, null, x.errorString()); - x.rethrowAsIOException((String)null); + throw new NotLinkException(pathname, null, x.errorString()); + x.rethrowAsIOException(pathname + ": " + x.errorString()); } /* @@ -342,8 +344,8 @@ class WindowsLinkSupport { int tag = (int)unsafe.getLong(buffer.address() + OFFSETOF_REPARSETAG); if (tag != IO_REPARSE_TAG_SYMLINK) { - // FIXME: exception doesn't have file name - throw new NotLinkException(null, null, "Reparse point is not a symbolic link"); + String pathname = path.getPathForExceptionMessage(); + throw new NotLinkException(pathname, null, "Reparse point is not a symbolic link"); } // get offset and length of target diff --git a/src/java.base/windows/native/libjava/WinNTFileSystem_md.c b/src/java.base/windows/native/libjava/WinNTFileSystem_md.c index 43ce9216271..2598eaa6fec 100644 --- a/src/java.base/windows/native/libjava/WinNTFileSystem_md.c +++ b/src/java.base/windows/native/libjava/WinNTFileSystem_md.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,31 +46,15 @@ static struct { jfieldID path; } ids; -/** - * GetFinalPathNameByHandle is available on Windows Vista and newer - */ -typedef BOOL (WINAPI* GetFinalPathNameByHandleProc) (HANDLE, LPWSTR, DWORD, DWORD); -static GetFinalPathNameByHandleProc GetFinalPathNameByHandle_func; - JNIEXPORT void JNICALL Java_java_io_WinNTFileSystem_initIDs(JNIEnv *env, jclass cls) { - HMODULE handle; jclass fileClass; fileClass = (*env)->FindClass(env, "java/io/File"); CHECK_NULL(fileClass); ids.path = (*env)->GetFieldID(env, fileClass, "path", "Ljava/lang/String;"); CHECK_NULL(ids.path); - - // GetFinalPathNameByHandle requires Windows Vista or newer - if (GetModuleHandleExW((GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | - GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT), - (LPCWSTR)&CreateFileW, &handle) != 0) - { - GetFinalPathNameByHandle_func = (GetFinalPathNameByHandleProc) - GetProcAddress(handle, "GetFinalPathNameByHandleW"); - } } /* -- Path operations -- */ @@ -88,10 +72,6 @@ static WCHAR* getFinalPath(JNIEnv *env, const WCHAR *path) WCHAR *result; DWORD error; - /* Need Windows Vista or newer to get the final path */ - if (GetFinalPathNameByHandle_func == NULL) - return NULL; - h = CreateFileW(path, FILE_READ_ATTRIBUTES, FILE_SHARE_DELETE | @@ -109,13 +89,13 @@ static WCHAR* getFinalPath(JNIEnv *env, const WCHAR *path) */ result = (WCHAR*)malloc(MAX_PATH * sizeof(WCHAR)); if (result != NULL) { - DWORD len = (*GetFinalPathNameByHandle_func)(h, result, MAX_PATH, 0); + DWORD len = GetFinalPathNameByHandleW(h, result, MAX_PATH, 0); if (len >= MAX_PATH) { /* retry with a buffer of the right size */ WCHAR* newResult = (WCHAR*)realloc(result, (len+1) * sizeof(WCHAR)); if (newResult != NULL) { result = newResult; - len = (*GetFinalPathNameByHandle_func)(h, result, len, 0); + len = GetFinalPathNameByHandleW(h, result, len, 0); } else { len = 0; JNU_ThrowOutOfMemoryError(env, "native memory allocation failed"); @@ -351,6 +331,25 @@ Java_java_io_WinNTFileSystem_canonicalizeWithPrefix0(JNIEnv *env, jobject this, return rv; } +JNIEXPORT jstring JNICALL +Java_java_io_WinNTFileSystem_getFinalPath0(JNIEnv* env, jobject this, jstring pathname) { + jstring rv = NULL; + + WITH_UNICODE_STRING(env, pathname, path) { + WCHAR* finalPath = getFinalPath(env, path); + if (finalPath != NULL) { + rv = (*env)->NewString(env, finalPath, (jsize)wcslen(finalPath)); + free(finalPath); + } + } END_UNICODE_STRING(env, path); + + if (rv == NULL && !(*env)->ExceptionCheck(env)) { + JNU_ThrowIOExceptionWithLastError(env, "Bad pathname"); + } + + return rv; +} + /* -- Attribute accessors -- */ /* Check whether or not the file name in "path" is a Windows reserved diff --git a/src/java.base/windows/native/libjava/java_props_md.c b/src/java.base/windows/native/libjava/java_props_md.c index 5eefb6a9fc9..d26d6df1aff 100644 --- a/src/java.base/windows/native/libjava/java_props_md.c +++ b/src/java.base/windows/native/libjava/java_props_md.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -233,9 +233,6 @@ cpu_isalist(void) SYSTEM_INFO info; GetSystemInfo(&info); switch (info.wProcessorArchitecture) { -#ifdef PROCESSOR_ARCHITECTURE_IA64 - case PROCESSOR_ARCHITECTURE_IA64: return "ia64"; -#endif #ifdef PROCESSOR_ARCHITECTURE_AMD64 case PROCESSOR_ARCHITECTURE_AMD64: return "amd64"; #endif @@ -444,6 +441,8 @@ GetJavaProperties(JNIEnv* env) * where (buildNumber > 17762) * Windows Server 2022 10 0 (!VER_NT_WORKSTATION) * where (buildNumber > 20347) + * Windows Server 2025 10 0 (!VER_NT_WORKSTATION) + * where (buildNumber > 26039) * * This mapping will presumably be augmented as new Windows * versions are released. @@ -527,7 +526,10 @@ GetJavaProperties(JNIEnv* env) case 0: /* Windows server 2019 GA 10/2018 build number is 17763 */ /* Windows server 2022 build number is 20348 */ - if (buildNumber > 20347) { + /* Windows server 2025 Preview build is 26040 */ + if (buildNumber > 26039) { + sprops.os_name = "Windows Server 2025"; + } else if (buildNumber > 20347) { sprops.os_name = "Windows Server 2022"; } else if (buildNumber > 17762) { sprops.os_name = "Windows Server 2019"; diff --git a/src/java.base/windows/native/libnio/MappedMemoryUtils.c b/src/java.base/windows/native/libnio/MappedMemoryUtils.c index 5017ca63a92..6e43dfb505f 100644 --- a/src/java.base/windows/native/libnio/MappedMemoryUtils.c +++ b/src/java.base/windows/native/libnio/MappedMemoryUtils.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,9 +30,8 @@ #include "java_nio_MappedMemoryUtils.h" #include -JNIEXPORT jboolean JNICALL -Java_java_nio_MappedMemoryUtils_isLoaded0(JNIEnv *env, jobject obj, jlong address, - jlong len, jlong numPages) +jboolean JNICALL MappedMemoryUtils_isLoaded0(JNIEnv *env, jobject obj, jlong address, + jlong len, jlong numPages) { jboolean loaded = JNI_FALSE; /* Information not available? @@ -43,22 +42,19 @@ Java_java_nio_MappedMemoryUtils_isLoaded0(JNIEnv *env, jobject obj, jlong addres return loaded; } -JNIEXPORT void JNICALL -Java_java_nio_MappedMemoryUtils_load0(JNIEnv *env, jobject obj, jlong address, +void JNICALL MappedMemoryUtils_load0(JNIEnv *env, jobject obj, jlong address, jlong len) { // no madvise available } -JNIEXPORT void JNICALL -Java_java_nio_MappedMemoryUtils_unload0(JNIEnv *env, jobject obj, jlong address, - jlong len) +void JNICALL MappedMemoryUtils_unload0(JNIEnv *env, jobject obj, jlong address, + jlong len) { // no madvise available } -JNIEXPORT void JNICALL -Java_java_nio_MappedMemoryUtils_force0(JNIEnv *env, jobject obj, jobject fdo, +void JNICALL MappedMemoryUtils_force0(JNIEnv *env, jobject obj, jobject fdo, jlong address, jlong len) { void *a = (void *) jlong_to_ptr(address); @@ -106,3 +102,19 @@ Java_java_nio_MappedMemoryUtils_force0(JNIEnv *env, jobject obj, jobject fdo, JNU_ThrowIOExceptionWithLastError(env, "Flush failed"); } } + +#define FD "Ljava/io/FileDescriptor;" + +static JNINativeMethod methods[] = { + {"isLoaded0", "(JJJ)Z", (void *)&MappedMemoryUtils_isLoaded0}, + {"load0", "(JJ)V", (void *)&MappedMemoryUtils_load0}, + {"unload0", "(JJ)V", (void *)&MappedMemoryUtils_unload0}, + {"force0", "(" FD "JJ)V", (void *)&MappedMemoryUtils_force0}, +}; + +JNIEXPORT void JNICALL +Java_java_nio_MappedMemoryUtils_registerNatives(JNIEnv *env, jclass cls) +{ + (*env)->RegisterNatives(env, cls, + methods, sizeof(methods)/sizeof(methods[0])); +} diff --git a/src/java.compiler/share/classes/javax/annotation/processing/AbstractProcessor.java b/src/java.compiler/share/classes/javax/annotation/processing/AbstractProcessor.java index 3d65d200c0d..108e3789d28 100644 --- a/src/java.compiler/share/classes/javax/annotation/processing/AbstractProcessor.java +++ b/src/java.compiler/share/classes/javax/annotation/processing/AbstractProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -157,7 +157,7 @@ public abstract class AbstractProcessor implements Processor { * * @implSpec * Initializes the processor with the processing environment by - * setting the {@code processingEnv} field to the value of the + * setting the {@link #processingEnv} field to the value of the * {@code processingEnv} argument. An {@code * IllegalStateException} will be thrown if this method is called * more than once on the same object. diff --git a/src/java.compiler/share/classes/javax/annotation/processing/Processor.java b/src/java.compiler/share/classes/javax/annotation/processing/Processor.java index 01de039d2c2..4be159868fa 100644 --- a/src/java.compiler/share/classes/javax/annotation/processing/Processor.java +++ b/src/java.compiler/share/classes/javax/annotation/processing/Processor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,14 +32,15 @@ import javax.lang.model.element.*; import javax.lang.model.SourceVersion; /** - * The interface for an annotation processor. + * The interface for an {@index "annotation processor"}. * - *

                Annotation processing happens in a sequence of {@linkplain - * javax.annotation.processing.RoundEnvironment rounds}. On each - * round, a processor may be asked to {@linkplain #process process} a - * subset of the annotations found on the source and class files - * produced by a prior round. The inputs to the first round of - * processing are the initial inputs to a run of the tool; these + *

                Annotation processing happens in a sequence of rounds. + * On each + * {@linkplain RoundEnvironment round}, a processor may be asked to {@linkplain #process process} a + * subset of the annotations found on the + * {@linkplain RoundEnvironment#getRootElements() source and class files + * produced by a prior round}. The inputs to the first round of + * processing are the {@index "initial inputs"} to a run of the tool; these * initial inputs can be regarded as the output of a virtual zeroth * round of processing. If a processor was asked to process on a * given round, it will be asked to process on subsequent rounds, @@ -77,7 +78,7 @@ import javax.lang.model.SourceVersion; * protocol being followed, then the processor's behavior is not * defined by this interface specification. * - *

                The tool uses a discovery process to find annotation + *

                The tool uses a {@index "discovery process"} to find annotation * processors and decide whether or not they should be run. By * configuring the tool, the set of potential processors can be * controlled. For example, for a {@link javax.tools.JavaCompiler diff --git a/src/java.compiler/share/classes/javax/annotation/processing/RoundEnvironment.java b/src/java.compiler/share/classes/javax/annotation/processing/RoundEnvironment.java index 49e94faf179..d0c43d929c8 100644 --- a/src/java.compiler/share/classes/javax/annotation/processing/RoundEnvironment.java +++ b/src/java.compiler/share/classes/javax/annotation/processing/RoundEnvironment.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -146,7 +146,7 @@ public interface RoundEnvironment { * processing. The set of annotation interfaces present in the runtime * context may differ from the set of annotation interfaces present in * the context of annotation processing in a particular - * environmental configuration. If an runtime annotation interface is + * environmental configuration. If a runtime annotation interface is * not present in the annotation processing context, the situation * is not treated as an error and no elements are found for that * annotation interface. @@ -173,7 +173,7 @@ public interface RoundEnvironment { * processing. The set of annotation interfaces present in the runtime * context may differ from the set of annotation interfaces present in * the context of annotation processing in a particular - * environmental configuration. If an runtime annotation interface is + * environmental configuration. If a runtime annotation interface is * not present in the annotation processing context, the situation * is not treated as an error and no elements are found for that * annotation interface. diff --git a/src/java.compiler/share/classes/javax/lang/model/AnnotatedConstruct.java b/src/java.compiler/share/classes/javax/lang/model/AnnotatedConstruct.java index 10363b5a618..2bb275a046b 100644 --- a/src/java.compiler/share/classes/javax/lang/model/AnnotatedConstruct.java +++ b/src/java.compiler/share/classes/javax/lang/model/AnnotatedConstruct.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,20 +41,20 @@ import javax.lang.model.type.*; * * As defined by The Java Language Specification * section {@jls 9.7.4}, an annotation on an element is a - * declaration annotation and an annotation on a type is a - * type annotation. + * {@index "declaration annotation"} and an annotation on a type is a + * {@index "type annotation"}. * * The terms directly present, present, - * indirectly present, and associated are used + * indirectly present, and associated are used * throughout this interface to describe precisely which annotations, * either declaration annotations or type annotations, are returned by * the methods in this interface. * *

                In the definitions below, an annotation A has an * annotation interface AI. If AI is a repeatable annotation - * interface, the type of the containing annotation is AIC. + * interface, the type of the container annotation is AIC. * - *

                Annotation A is directly present on a construct + *

                Annotation A is {@index "directly present"} on a construct * C if either: * *

                  @@ -78,7 +78,7 @@ import javax.lang.model.type.*; * Specification (JLS {@jls 8.10.1}). * * If there are multiple annotations of type AI present on - * C, then if AI is repeatable annotation interface, an + * C, then if AI is a repeatable annotation interface, an * annotation of type AIC is {@linkplain javax.lang.model.util.Elements#getOrigin(AnnotatedConstruct, AnnotationMirror) implicitly declared} on C. *
                • A representation of A appears in the executable output * for C, such as the {@code RuntimeVisibleAnnotations} (JVMS {@jvms 4.7.16}) or @@ -87,7 +87,7 @@ import javax.lang.model.type.*; * *
                * - *

                An annotation A is present on a + *

                An annotation A is {@index "present"} on a * construct C if either: *

                  * @@ -99,7 +99,7 @@ import javax.lang.model.type.*; * *
                * - * An annotation A is indirectly present on a construct + * An annotation A is {@index "indirectly present"} on a construct * C if both: * *
                  @@ -114,7 +114,7 @@ import javax.lang.model.type.*; * *
                * - * An annotation A is associated with a construct + * An annotation A is {@index "associated"} with a construct * C if either: * *
                  @@ -189,10 +189,11 @@ public interface AnnotatedConstruct { A getAnnotation(Class annotationType); /** - * Returns annotations that are associated with this construct. + * Returns annotations of the specified type that are associated + * with this construct. * - * If there are no annotations associated with this construct, the - * return value is an array of length 0. + * If there are no annotations of the specified type associated with this + * construct, the return value is an array of length 0. * * The order of annotations which are directly or indirectly * present on a construct C is computed as if indirectly present diff --git a/src/java.compiler/share/classes/javax/lang/model/SourceVersion.java b/src/java.compiler/share/classes/javax/lang/model/SourceVersion.java index 4e32f0cdcd8..231a5e34c62 100644 --- a/src/java.compiler/share/classes/javax/lang/model/SourceVersion.java +++ b/src/java.compiler/share/classes/javax/lang/model/SourceVersion.java @@ -70,8 +70,14 @@ public enum SourceVersion { * 21: pattern matching for switch and record patterns (string * templates in preview, unnamed patterns and variables in * preview, unnamed classes and instance main methods in preview) - * 22: Unnamed Variables & Patterns (Statements before super(...) - * in Preview) + * 22: unnamed variables & patterns (statements before super(...) + * in preview, string templates in second preview, implicitly + * declared classes and instance main methods in second preview) + * 23: no changes (primitive Types in Patterns, instanceof, and + * switch in preview, module Import Declarations in preview, + * implicitly declared classes and instance main in third + * preview, flexible constructor bodies in second preview) + * 24: tbd */ /** @@ -202,7 +208,7 @@ public enum SourceVersion { * @see * JEP 213: Milling Project Coin */ - RELEASE_9, + RELEASE_9, /** * The version introduced by the Java Platform, Standard Edition @@ -470,7 +476,7 @@ public enum SourceVersion { * * @apiNote This method is included alongside {@link latest} to * allow identification of situations where the language model API - * is running on a platform version different than the latest + * is running on a platform version different from the latest * version modeled by the API. One way that sort of situation can * occur is if an IDE or similar tool is using the API to model * source version N while running on platform version @@ -496,8 +502,7 @@ public enum SourceVersion { * followed only by characters for which {@link * Character#isJavaIdentifierPart(int)} returns {@code true}. * This pattern matches regular identifiers, keywords, contextual - * keywords, and the literals {@code "true"}, - * {@code "false"}, {@code "null"}. + * keywords, boolean literals, and the null literal. * * The method returns {@code false} for all other strings. * @@ -590,14 +595,14 @@ public enum SourceVersion { } /** - * Returns whether or not {@code s} is a keyword, boolean literal, - * or null literal in the latest source version. + * Returns whether or not {@code s} is a keyword, a boolean literal, + * or the null literal in the latest source version. * This method returns {@code false} for contextual * keywords. * * @param s the string to check - * @return {@code true} if {@code s} is a keyword, or boolean - * literal, or null literal, {@code false} otherwise. + * @return {@code true} if {@code s} is a keyword, a boolean + * literal, or the null literal, {@code false} otherwise. * @jls 3.9 Keywords * @jls 3.10.3 Boolean Literals * @jls 3.10.8 The Null Literal @@ -607,15 +612,15 @@ public enum SourceVersion { } /** - * Returns whether or not {@code s} is a keyword, boolean literal, - * or null literal in the given source version. + * Returns whether or not {@code s} is a keyword, a boolean literal, + * or the null literal in the given source version. * This method returns {@code false} for contextual * keywords. * * @param s the string to check * @param version the version to use - * @return {@code true} if {@code s} is a keyword, or boolean - * literal, or null literal, {@code false} otherwise. + * @return {@code true} if {@code s} is a keyword, a boolean + * literal, or the null literal, {@code false} otherwise. * @jls 3.9 Keywords * @jls 3.10.3 Boolean Literals * @jls 3.10.8 The Null Literal diff --git a/src/java.compiler/share/classes/javax/lang/model/element/AnnotationMirror.java b/src/java.compiler/share/classes/javax/lang/model/element/AnnotationMirror.java index 908d171e9c7..2d92504edb6 100644 --- a/src/java.compiler/share/classes/javax/lang/model/element/AnnotationMirror.java +++ b/src/java.compiler/share/classes/javax/lang/model/element/AnnotationMirror.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,7 +47,7 @@ public interface AnnotationMirror { /** * Returns the values of this annotation's elements. - * This is returned in the form of a map that associates elements + * These are returned in the form of a map that associates elements * with their corresponding values. * Only those elements with values explicitly present in the * annotation are included, not those that are implicitly assuming diff --git a/src/java.compiler/share/classes/javax/lang/model/element/ExecutableElement.java b/src/java.compiler/share/classes/javax/lang/model/element/ExecutableElement.java index 8bff3748394..18923463248 100644 --- a/src/java.compiler/share/classes/javax/lang/model/element/ExecutableElement.java +++ b/src/java.compiler/share/classes/javax/lang/model/element/ExecutableElement.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,7 @@ import javax.lang.model.type.*; * elements. * Annotation interface elements are methods restricted to have no * formal parameters, no type parameters, and no {@code throws} - * clause, among other restrictions; see JLS {@jls 9.6.1} for details + * clause, among other restrictions; see JLS {@jls 9.6.1} for details. * * @see ExecutableType * @since 1.6 diff --git a/src/java.compiler/share/classes/javax/lang/model/element/NestingKind.java b/src/java.compiler/share/classes/javax/lang/model/element/NestingKind.java index 7f8cee373f7..1faae30df57 100644 --- a/src/java.compiler/share/classes/javax/lang/model/element/NestingKind.java +++ b/src/java.compiler/share/classes/javax/lang/model/element/NestingKind.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,7 @@ package javax.lang.model.element; /** - * The nesting kind of a type element. + * The nesting kind of a type element. * Type elements come in four varieties: * top-level, member, local, and anonymous. * Nesting kind is a non-standard term used here to denote this @@ -95,7 +95,7 @@ public enum NestingKind { /** * A named class or interface declared within a construct other * than a class or interface. - * @jls 14.3 Local Class Declarations + * @jls 14.3 Local Class and Interface Declarations */ LOCAL, @@ -107,11 +107,11 @@ public enum NestingKind { /** * Does this constant correspond to a nested type element? - * A nested type element is any that is not top-level. + * A nested type element is any that is not top-level. * More specifically, an inner type element is any nested type element that * is not {@linkplain Modifier#STATIC static}. * @return whether or not the constant is nested - * @jls 14.3 Local Class Declarations + * @jls 14.3 Local Class and Interface Declarations */ public boolean isNested() { return this != TOP_LEVEL; diff --git a/src/java.compiler/share/classes/javax/lang/model/element/TypeElement.java b/src/java.compiler/share/classes/javax/lang/model/element/TypeElement.java index 3f34b179992..abf95bcefad 100644 --- a/src/java.compiler/share/classes/javax/lang/model/element/TypeElement.java +++ b/src/java.compiler/share/classes/javax/lang/model/element/TypeElement.java @@ -58,14 +58,14 @@ import javax.lang.model.util.*; * javax.lang.model.util.Elements#getFileObjectOf(Element) reference * representation} (either source code or executable output). Multiple * classes and interfaces can share the same reference representation - * backing construct. For example, multiple classes and interface can - * be declared in the same source file, including, but are not limited + * backing construct. For example, multiple classes and interfaces can + * be declared in the same source file, including, but not limited * to: *
                    *
                  • a {@linkplain NestingKind#TOP_LEVEL top-level} class or * interface and auxiliary classes and interfaces *
                  • a top-level class or interface and {@linkplain - * NestingKind#isNested() nested class and interfaces} within it + * NestingKind#isNested() nested classes and interfaces} within it *
                  *

                  In the context of annotation processing, a type element can * be: diff --git a/src/java.compiler/share/classes/javax/lang/model/element/package-info.java b/src/java.compiler/share/classes/javax/lang/model/element/package-info.java index 4bb7444cb39..ab4eeb1e747 100644 --- a/src/java.compiler/share/classes/javax/lang/model/element/package-info.java +++ b/src/java.compiler/share/classes/javax/lang/model/element/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,11 +30,17 @@ * elements, the declared entities that make up a program. Elements * include classes, interfaces, methods, constructors, and fields. * The interfaces in this package do not model the structure of a - * program inside a method body; for example there is no + * program inside a method body; for example, there is no * representation of a {@code for} loop or {@code try}-{@code finally} - * block. However, the interfaces can model some structures only - * appearing inside method bodies, such as local variables and - * anonymous classes. + * block. Concretely, there is no model of any abstract syntax tree + * (AST) structure of a Java program. However, the interfaces can + * model some structures only appearing inside method bodies, such as + * {@linkplain ElementKind#LOCAL_VARIABLE local variables}, + * {@linkplain NestingKind#ANONYMOUS anonymous classes}, and + * {@linkplain ElementKind#EXCEPTION_PARAMETER exception parameters}. + * Therefore, these interfaces can be used by an AST API to model the + * declarations found in the method bodies of Java compilation units + * (JLS {@jls 7.3}). * *

                  When used in the context of annotation * processing, an accurate model of the element being represented must @@ -78,7 +84,7 @@ * javax.lang.model.util.Elements#isBridge(ExecutableElement) * bridge methods} used in implementing covariant returns, are * translation artifacts strictly outside of this model. However, when - * operating on class files, it is helpful be able to operate on such + * operating on class files, it is helpful to be able to operate on such * elements, screening them out when appropriate. * *

                  During annotation processing, operating on incomplete or diff --git a/src/java.compiler/share/classes/javax/lang/model/type/NullType.java b/src/java.compiler/share/classes/javax/lang/model/type/NullType.java index 92feb514aab..3b82269b55a 100644 --- a/src/java.compiler/share/classes/javax/lang/model/type/NullType.java +++ b/src/java.compiler/share/classes/javax/lang/model/type/NullType.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,7 +30,7 @@ package javax.lang.model.type; * Represents the null type. * This is the type of the expression {@code null}. * - * @jls 3.10.7 The Null Literal + * @jls 3.10.8 The Null Literal * @jls 4.1 The Kinds of Types and Values * @see javax.lang.model.util.Types#getNullType() * @since 1.6 diff --git a/src/java.compiler/share/classes/javax/lang/model/type/TypeVariable.java b/src/java.compiler/share/classes/javax/lang/model/type/TypeVariable.java index abea88fb6f2..0cac48775f5 100644 --- a/src/java.compiler/share/classes/javax/lang/model/type/TypeVariable.java +++ b/src/java.compiler/share/classes/javax/lang/model/type/TypeVariable.java @@ -71,7 +71,7 @@ public interface TypeVariable extends ReferenceType { * non-trivial lower bound. Type variables otherwise have a * lower bound of {@link NullType}. * - * @jls 18.1.3. Bounds + * @jls 18.1.3 Bounds */ TypeMirror getLowerBound(); } diff --git a/src/java.compiler/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor7.java b/src/java.compiler/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor7.java index 0ca2bb13766..dbdeb3a9506 100644 --- a/src/java.compiler/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor7.java +++ b/src/java.compiler/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor7.java @@ -37,7 +37,7 @@ import javax.annotation.processing.SupportedSourceVersion; * @param the return type of this visitor's methods * @param

                  the type of the additional parameter to this visitor's methods. * - * @see AbstractAnnotationValueVisitor6##note_for_subclasses" + * @see AbstractAnnotationValueVisitor6##note_for_subclasses * Compatibility note for subclasses * @see AbstractAnnotationValueVisitor6 * @see AbstractAnnotationValueVisitor8 diff --git a/src/java.compiler/share/classes/javax/lang/model/util/Elements.java b/src/java.compiler/share/classes/javax/lang/model/util/Elements.java index 2faf3f5ec32..5159ac26e3b 100644 --- a/src/java.compiler/share/classes/javax/lang/model/util/Elements.java +++ b/src/java.compiler/share/classes/javax/lang/model/util/Elements.java @@ -56,11 +56,11 @@ public interface Elements { *

                    *
                  • find non-empty packages with the given name returned by * {@link #getPackageElement(ModuleElement, CharSequence)}, - * where the provided ModuleSymbol is any + * where the provided ModuleElement is any * {@linkplain java.lang.module##root-modules root module}, *
                  • *
                  • if the above yields an empty list, search - * {@link #getAllModuleElements() all modules} for observable + * {@linkplain #getAllModuleElements() all modules} for observable * packages with the given name *
                  • *
                  @@ -143,11 +143,11 @@ public interface Elements { *
                    *
                  • find type elements with the given name returned by * {@link #getTypeElement(ModuleElement, CharSequence)}, - * where the provided ModuleSymbol is any + * where the provided ModuleElement is any * {@linkplain java.lang.module##root-modules root module}, *
                  • *
                  • if the above yields an empty list, search - * {@link #getAllModuleElements() all modules} for observable + * {@linkplain #getAllModuleElements() all modules} for observable * type elements with the given name *
                  • *
                  @@ -617,7 +617,7 @@ public interface Elements { /** * Returns all members of a type element, whether inherited or - * declared directly. For a class the result also includes its + * declared directly. For a class, the result also includes its * constructors, but not local or anonymous classes. * * @apiNote Elements of certain kinds can be isolated using @@ -878,10 +878,10 @@ public interface Elements { * accessor. * * @implSpec The default implementation of this method checks if the element - * enclosing the accessor has kind {@link ElementKind#RECORD RECORD} if that is - * the case, then all the record components on the accessor's enclosing element - * are retrieved by invoking {@link ElementFilter#recordComponentsIn(Iterable)}. - * If the accessor of at least one of the record components retrieved happen to + * enclosing the accessor has kind {@link ElementKind#RECORD RECORD}, if that is + * the case, then all the record components of the accessor's enclosing element + * are isolated by invoking {@link ElementFilter#recordComponentsIn(Iterable)}. + * If the accessor of at least one of the record components retrieved happens to * be equal to the accessor passed as a parameter to this method, then that * record component is returned, in any other case {@code null} is returned. * diff --git a/src/java.compiler/share/classes/javax/lang/model/util/Types.java b/src/java.compiler/share/classes/javax/lang/model/util/Types.java index 0cea2734e21..951b56ed214 100644 --- a/src/java.compiler/share/classes/javax/lang/model/util/Types.java +++ b/src/java.compiler/share/classes/javax/lang/model/util/Types.java @@ -40,7 +40,7 @@ import javax.lang.model.type.*; * ExecutableType Executable types} and the pseudo-types for * {@linkplain TypeKind#PACKAGE packages} and {@linkplain * TypeKind#MODULE modules} are generally out of scope for these - * methods. One or more out of scope arguments will typically result + * methods. One or more out-of-scope arguments will typically result * in a method throwing an {@link IllegalArgumentException}. * *

                  Where a method returns a type mirror or a collection of type @@ -50,6 +50,11 @@ import javax.lang.model.type.*; *

                  Compatibility Note: Methods may be added to this interface * in future releases of the platform. * + * @apiNote + * In the reference implementation, handling {@linkplain ErrorType + * error types} generally does not cause an {@code + * IllegalArgumentException} from the methods in this interface. + * * @see javax.annotation.processing.ProcessingEnvironment#getTypeUtils * @since 1.6 */ @@ -165,7 +170,7 @@ public interface Types { * the direct supertypes of a type mirror representing {@code * java.lang.Object}. * - * Annotations on the direct super types are preserved. + * Annotations on the direct supertypes are preserved. * * @param t the type being examined * @return the direct supertypes, or an empty list if none @@ -185,7 +190,7 @@ public interface Types { /** * {@return the class of a boxed value of the primitive type argument} - * That is, boxing conversion is applied. + * That is, boxing conversion is applied. * * @param p the primitive type to be converted * @jls 5.1.7 Boxing Conversion @@ -198,8 +203,11 @@ public interface Types { * * @param t the type to be unboxed * @return the type of an unboxed value of type {@code t} + * * @throws IllegalArgumentException if the given type has no - * unboxing conversion + * unboxing conversion. Only types for the {@linkplain + * java.lang##wrapperClass wrapper classes} have an + * unboxing conversion. * @jls 5.1.8 Unboxing Conversion */ PrimitiveType unboxedType(TypeMirror t); @@ -255,7 +263,10 @@ public interface Types { * * @param componentType the component type * @throws IllegalArgumentException if the component type is not valid for - * an array, including executable, package, module, and wildcard types + * an array. All valid types are {@linkplain ReferenceType + * reference types} or {@linkplain PrimitiveType primitive types}. + * Invalid types include {@linkplain NullType null}, executable, package, + * module, and wildcard types. * @jls 10.1 Array Types */ ArrayType getArrayType(TypeMirror componentType); @@ -268,7 +279,10 @@ public interface Types { * * @param extendsBound the extends (upper) bound, or {@code null} if none * @param superBound the super (lower) bound, or {@code null} if none - * @throws IllegalArgumentException if bounds are not valid + * + * @throws IllegalArgumentException if bounds are not valid. Invalid bounds + * include all types that are not {@linkplain ReferenceType + * reference types}. * @jls 4.5.1 Type Arguments of Parameterized Types */ WildcardType getWildcardType(TypeMirror extendsBound, @@ -318,7 +332,7 @@ public interface Types { * Annotations on the type arguments are preserved. * *

                  If the containing type is a parameterized type, - * the number of type arguments must equal the + * the number of type arguments must be equal to the * number of {@code typeElem}'s formal type parameters. * If it is not parameterized or if it is {@code null}, this method is * equivalent to {@code getDeclaredType(typeElem, typeArgs)}. @@ -354,7 +368,7 @@ public interface Types { /** * {@return a type mirror equivalent to the argument, but with no annotations} * If the type mirror is a composite type, such as an array type - * or a wildcard type, any constitute types, such as the + * or a wildcard type, any constituent types, such as the * component type of an array and the type of the bounds of a * wildcard type, also have no annotations, recursively. * diff --git a/src/java.compiler/share/classes/javax/tools/ForwardingFileObject.java b/src/java.compiler/share/classes/javax/tools/ForwardingFileObject.java index 98bb5a650a4..d61198c6aef 100644 --- a/src/java.compiler/share/classes/javax/tools/ForwardingFileObject.java +++ b/src/java.compiler/share/classes/javax/tools/ForwardingFileObject.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,7 @@ import java.util.Objects; * additional fields and methods. * *

                  Unless stated otherwise, references in this class to "this file object" - * should be interpreted as referring indirectly to the {@link #fileObject delegate file object}. + * should be interpreted as referring indirectly to the {@linkplain #fileObject delegate file object}. * * @param the kind of file object forwarded to by this object * @since 1.6 diff --git a/src/java.compiler/share/classes/javax/tools/ForwardingJavaFileManager.java b/src/java.compiler/share/classes/javax/tools/ForwardingJavaFileManager.java index 40224abbd50..9db757f05a2 100644 --- a/src/java.compiler/share/classes/javax/tools/ForwardingJavaFileManager.java +++ b/src/java.compiler/share/classes/javax/tools/ForwardingJavaFileManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,7 @@ import javax.tools.JavaFileObject.Kind; * additional fields and methods. * *

                  Unless stated otherwise, references in this class to "this file manager" - * should be interpreted as referring indirectly to the {@link #fileManager delegate file manager}. + * should be interpreted as referring indirectly to the {@linkplain #fileManager delegate file manager}. * * @param the kind of file manager forwarded to by this object * @since 1.6 diff --git a/src/java.compiler/share/classes/javax/tools/ForwardingJavaFileObject.java b/src/java.compiler/share/classes/javax/tools/ForwardingJavaFileObject.java index a940b23009d..e8db8919750 100644 --- a/src/java.compiler/share/classes/javax/tools/ForwardingJavaFileObject.java +++ b/src/java.compiler/share/classes/javax/tools/ForwardingJavaFileObject.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,7 @@ import javax.lang.model.element.NestingKind; * additional fields and methods. * *

                  Unless stated otherwise, references in this class to "this file object" - * should be interpreted as referring indirectly to the {@link #fileObject delegate file object}. + * should be interpreted as referring indirectly to the {@linkplain #fileObject delegate file object}. * * @param the kind of file object forwarded to by this object * @since 1.6 diff --git a/src/java.compiler/share/classes/javax/tools/JavaFileManager.java b/src/java.compiler/share/classes/javax/tools/JavaFileManager.java index 327064b5a52..da2a3b534ac 100644 --- a/src/java.compiler/share/classes/javax/tools/JavaFileManager.java +++ b/src/java.compiler/share/classes/javax/tools/JavaFileManager.java @@ -52,7 +52,7 @@ import static javax.tools.JavaFileObject.Kind; * *

                  Some methods in this interface use class names. Such class * names must be given in the Java Virtual Machine internal form of - * fully qualified class and interface names. For convenience '.' + * fully qualified class and interface names. For convenience, '.' * and '/' are interchangeable. The internal form is defined in * chapter four of * The Java Virtual Machine Specification. @@ -239,7 +239,7 @@ public interface JavaFileManager extends Closeable, Flushable, OptionChecker { String inferBinaryName(Location location, JavaFileObject file); /** - * Compares two file objects and return true if they represent the + * Compares two file objects and returns true if they represent the * same underlying object. * * @param a a file object @@ -255,7 +255,7 @@ public interface JavaFileManager extends Closeable, Flushable, OptionChecker { /** * Handles one option. If {@code current} is an option to this - * file manager it will consume any arguments to that option from + * file manager, it will consume any arguments to that option from * {@code remaining} and return true, otherwise return false. * * @param current current option diff --git a/src/java.compiler/share/classes/javax/tools/StandardJavaFileManager.java b/src/java.compiler/share/classes/javax/tools/StandardJavaFileManager.java index 769856535ac..277f6d57b0e 100644 --- a/src/java.compiler/share/classes/javax/tools/StandardJavaFileManager.java +++ b/src/java.compiler/share/classes/javax/tools/StandardJavaFileManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -142,7 +142,7 @@ import java.util.List; *

                * *

                All implementations of this interface must support Path objects representing - * files in the {@linkplain java.nio.file.FileSystems#getDefault() default file system.} + * files in the {@linkplain java.nio.file.FileSystems#getDefault() default file system}. * It is recommended that implementations should support Path objects from any filesystem.

                * * diff --git a/src/java.compiler/share/classes/javax/tools/ToolProvider.java b/src/java.compiler/share/classes/javax/tools/ToolProvider.java index d05b65b0ffe..8cdfd63b17d 100644 --- a/src/java.compiler/share/classes/javax/tools/ToolProvider.java +++ b/src/java.compiler/share/classes/javax/tools/ToolProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -90,8 +90,8 @@ public class ToolProvider { * @implSpec This implementation always returns {@code null}. * @deprecated This method is subject to removal in a future version of * Java SE. - * Use the {@link java.util.spi.ToolProvider system tool provider} or - * {@link java.util.ServiceLoader service loader} mechanisms to + * Use the {@linkplain java.util.spi.ToolProvider system tool provider} or + * {@linkplain java.util.ServiceLoader service loader} mechanisms to * locate system tools as well as user-installed tools. * @return a class loader, or {@code null} */ diff --git a/src/java.desktop/macosx/native/libsplashscreen/splashscreen_sys.m b/src/java.desktop/macosx/native/libsplashscreen/splashscreen_sys.m index 66e0c362318..e74f8ee50fb 100644 --- a/src/java.desktop/macosx/native/libsplashscreen/splashscreen_sys.m +++ b/src/java.desktop/macosx/native/libsplashscreen/splashscreen_sys.m @@ -271,11 +271,13 @@ void SplashCreateThread(Splash * splash) { pthread_t thr; pthread_attr_t attr; - int rc; int rslt = pthread_attr_init(&attr); if (rslt != 0) return; - rc = pthread_create(&thr, &attr, SplashScreenThread, (void *) splash); + rslt = pthread_create(&thr, &attr, SplashScreenThread, (void *) splash); + if (rslt != 0) { + fprintf(stderr, "Could not create SplashScreen thread, error number:%d\n", rslt); + } pthread_attr_destroy(&attr); } diff --git a/src/java.desktop/share/classes/java/awt/color/ICC_ColorSpace.java b/src/java.desktop/share/classes/java/awt/color/ICC_ColorSpace.java index a20eca94a3f..56ea5c573d8 100644 --- a/src/java.desktop/share/classes/java/awt/color/ICC_ColorSpace.java +++ b/src/java.desktop/share/classes/java/awt/color/ICC_ColorSpace.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -48,7 +48,7 @@ import sun.java2d.cmm.PCMM; * {@code ColorSpace} class. This representation of device independent and * device dependent color spaces is based on the International Color Consortium * Specification ICC.1:2001-12, File Format for Color Profiles (see - * http://www.color.org). + * https://www.color.org). *

                * Typically, a {@code Color} or {@code ColorModel} would be associated with an * ICC Profile which is either an input, display, or output profile (see the ICC diff --git a/src/java.desktop/share/classes/java/awt/color/ICC_Profile.java b/src/java.desktop/share/classes/java/awt/color/ICC_Profile.java index 0cf836b449a..b7faab518f9 100644 --- a/src/java.desktop/share/classes/java/awt/color/ICC_Profile.java +++ b/src/java.desktop/share/classes/java/awt/color/ICC_Profile.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -64,7 +64,7 @@ import sun.java2d.cmm.ProfileDeferralInfo; * A representation of color profile data for device independent and device * dependent color spaces based on the International Color Consortium * Specification ICC.1:2001-12, File Format for Color Profiles, (see - * http://www.color.org). + * https://www.color.org). *

                * An {@code ICC_ColorSpace} object can be constructed from an appropriate * {@code ICC_Profile}. Typically, an {@code ICC_ColorSpace} would be associated diff --git a/src/java.desktop/share/classes/java/awt/font/TextLayout.java b/src/java.desktop/share/classes/java/awt/font/TextLayout.java index 352d3c81df2..855097b6a26 100644 --- a/src/java.desktop/share/classes/java/awt/font/TextLayout.java +++ b/src/java.desktop/share/classes/java/awt/font/TextLayout.java @@ -2663,11 +2663,20 @@ public final class TextLayout implements Cloneable { */ public Shape getOutline(AffineTransform tx) { ensureCache(); - Shape result = textLine.getOutline(tx); + Shape result = textLine.getOutline(); LayoutPathImpl lp = textLine.getLayoutPath(); if (lp != null) { result = lp.mapShape(result); } + if (tx != null) { + if (result instanceof GeneralPath gp) { + // transform in place + gp.transform(tx); + } else { + // create a transformed copy + result = tx.createTransformedShape(result); + } + } return result; } diff --git a/src/java.desktop/share/classes/java/awt/font/TextLine.java b/src/java.desktop/share/classes/java/awt/font/TextLine.java index 9d5da23bfe7..1e4b9c784a6 100644 --- a/src/java.desktop/share/classes/java/awt/font/TextLine.java +++ b/src/java.desktop/share/classes/java/awt/font/TextLine.java @@ -864,19 +864,15 @@ final class TextLine { return new Rectangle2D.Float(left, top, right-left, bottom-top); } - public Shape getOutline(AffineTransform tx) { + public Shape getOutline() { GeneralPath dstShape = new GeneralPath(GeneralPath.WIND_NON_ZERO); for (int i=0, n = 0; i < fComponents.length; i++, n += 2) { TextLineComponent tlc = fComponents[getComponentLogicalIndex(i)]; - dstShape.append(tlc.getOutline(locs[n], locs[n+1]), false); } - if (tx != null) { - dstShape.transform(tx); - } return dstShape; } diff --git a/src/java.desktop/share/classes/java/awt/image/ColorConvertOp.java b/src/java.desktop/share/classes/java/awt/image/ColorConvertOp.java index 1e7176e4b39..3202d2d690d 100644 --- a/src/java.desktop/share/classes/java/awt/image/ColorConvertOp.java +++ b/src/java.desktop/share/classes/java/awt/image/ColorConvertOp.java @@ -690,7 +690,7 @@ public class ColorConvertOp implements BufferedImageOp, RasterOp { * shall be set to zero. Thus, we are ignoring two most significant * bytes here. * - * See http://www.color.org/ICC1v42_2006-05.pdf, section 7.2.15. + * See https://www.color.org/ICC1v42_2006-05.pdf, section 7.2.15. */ return ((header[index+2] & 0xff) << 8) | (header[index+3] & 0xff); diff --git a/src/java.desktop/share/classes/javax/imageio/package-info.java b/src/java.desktop/share/classes/javax/imageio/package-info.java index 24f86b3967f..8d170e32992 100644 --- a/src/java.desktop/share/classes/javax/imageio/package-info.java +++ b/src/java.desktop/share/classes/javax/imageio/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -101,7 +101,7 @@ * * * - * + * * WBMP * yes * yes diff --git a/src/java.desktop/share/classes/javax/imageio/plugins/tiff/BaselineTIFFTagSet.java b/src/java.desktop/share/classes/javax/imageio/plugins/tiff/BaselineTIFFTagSet.java index be2cbf88c06..ebeb456b164 100644 --- a/src/java.desktop/share/classes/javax/imageio/plugins/tiff/BaselineTIFFTagSet.java +++ b/src/java.desktop/share/classes/javax/imageio/plugins/tiff/BaselineTIFFTagSet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1008,7 +1008,7 @@ public final class BaselineTIFFTagSet extends TIFFTagSet { /** * Constant specifying the "ICC Profile" tag. * - * @see ICC Specification, section B.4: Embedding ICC profiles in TIFF files + * @see ICC Specification, section B.4: Embedding ICC profiles in TIFF files */ public static final int TAG_ICC_PROFILE = 34675; diff --git a/src/java.desktop/share/classes/javax/swing/SortingFocusTraversalPolicy.java b/src/java.desktop/share/classes/javax/swing/SortingFocusTraversalPolicy.java index 384a8059962..92f98fdfc99 100644 --- a/src/java.desktop/share/classes/javax/swing/SortingFocusTraversalPolicy.java +++ b/src/java.desktop/share/classes/javax/swing/SortingFocusTraversalPolicy.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -87,8 +87,8 @@ public class SortingFocusTraversalPolicy private static final SwingContainerOrderFocusTraversalPolicy fitnessTestPolicy = new SwingContainerOrderFocusTraversalPolicy(); - private final int FORWARD_TRAVERSAL = 0; - private final int BACKWARD_TRAVERSAL = 1; + private static final int FORWARD_TRAVERSAL = 0; + private static final int BACKWARD_TRAVERSAL = 1; /* * When true (by default), the legacy merge-sort algo is used to sort an FTP cycle. diff --git a/src/java.desktop/share/classes/javax/swing/text/html/default.css b/src/java.desktop/share/classes/javax/swing/text/html/default.css index eb37a12b6d8..32f54231f46 100644 --- a/src/java.desktop/share/classes/javax/swing/text/html/default.css +++ b/src/java.desktop/share/classes/javax/swing/text/html/default.css @@ -102,7 +102,7 @@ dd {margin-left-ltr: 40; margin-bottom: 0} dd p {margin-left: 0; - margin-rigth: 0; + margin-right: 0; margin-top: 0; margin-bottom: 0} diff --git a/src/java.desktop/share/legal/giflib.md b/src/java.desktop/share/legal/giflib.md index 8b8fde8706d..5697dc7ca9a 100644 --- a/src/java.desktop/share/legal/giflib.md +++ b/src/java.desktop/share/legal/giflib.md @@ -23,8 +23,13 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +--------------------------------- +The below applies to the following file(s): +giflib/openbsd-reallocarray.c + +Copyright (C) 2008 Otto Moerbeek +SPDX-License-Identifier: MIT -tree/README == Authors == @@ -38,13 +43,4 @@ former maintainer Eric Raymond current as well as long time former maintainer of giflib code -There have been many other contributors; see the attributions in the -version-control history to learn more. - - -tree/openbsd-reallocarray.c - -Copyright (C) 2008 Otto Moerbeek -SPDX-License-Identifier: MIT - ``` diff --git a/src/java.desktop/unix/native/libsplashscreen/splashscreen_sys.c b/src/java.desktop/unix/native/libsplashscreen/splashscreen_sys.c index 5a008d10a48..e89d813fff4 100644 --- a/src/java.desktop/unix/native/libsplashscreen/splashscreen_sys.c +++ b/src/java.desktop/unix/native/libsplashscreen/splashscreen_sys.c @@ -741,7 +741,10 @@ SplashCreateThread(Splash * splash) { int rslt = pthread_attr_init(&attr); if (rslt != 0) return; - pthread_create(&thr, &attr, SplashScreenThread, (void *) splash); + rslt = pthread_create(&thr, &attr, SplashScreenThread, (void *) splash); + if (rslt != 0) { + fprintf(stderr, "Could not create SplashScreen thread, error number:%d\n", rslt); + } pthread_attr_destroy(&attr); } diff --git a/src/java.management/share/classes/javax/management/ClassAttributeValueExp.java b/src/java.management/share/classes/javax/management/ClassAttributeValueExp.java index 06c488f90fa..f7c40691e39 100644 --- a/src/java.management/share/classes/javax/management/ClassAttributeValueExp.java +++ b/src/java.management/share/classes/javax/management/ClassAttributeValueExp.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,37 +39,9 @@ import com.sun.jmx.mbeanserver.GetPropertyAction; * * @since 1.5 */ -@SuppressWarnings("serial") // serialVersionUID is not constant class ClassAttributeValueExp extends AttributeValueExp { - // Serialization compatibility stuff: - // Two serial forms are supported in this class. The selected form depends - // on system property "jmx.serial.form": - // - "1.0" for JMX 1.0 - // - any other value for JMX 1.1 and higher - // - // Serial version for old serial form - private static final long oldSerialVersionUID = -2212731951078526753L; - // - // Serial version for new serial form - private static final long newSerialVersionUID = -1081892073854801359L; - - private static final long serialVersionUID; - static { - boolean compat = false; - try { - GetPropertyAction act = new GetPropertyAction("jmx.serial.form"); - @SuppressWarnings("removal") - String form = AccessController.doPrivileged(act); - compat = (form != null && form.equals("1.0")); - } catch (Exception e) { - // OK: exception means no compat with 1.0, too bad - } - if (compat) - serialVersionUID = oldSerialVersionUID; - else - serialVersionUID = newSerialVersionUID; - } + private static final long serialVersionUID = -1081892073854801359L; /** * @serial The name of the attribute diff --git a/src/java.management/share/classes/javax/management/MBeanAttributeInfo.java b/src/java.management/share/classes/javax/management/MBeanAttributeInfo.java index 6d31becbb73..6551e9ba81b 100644 --- a/src/java.management/share/classes/javax/management/MBeanAttributeInfo.java +++ b/src/java.management/share/classes/javax/management/MBeanAttributeInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,33 +40,9 @@ import java.util.Objects; * * @since 1.5 */ -@SuppressWarnings("serial") // serialVersionUID not constant public class MBeanAttributeInfo extends MBeanFeatureInfo implements Cloneable { - /* Serial version */ - private static final long serialVersionUID; - static { - /* For complicated reasons, the serialVersionUID changed - between JMX 1.0 and JMX 1.1, even though JMX 1.1 did not - have compatibility code for this class. So the - serialization produced by this class with JMX 1.2 and - jmx.serial.form=1.0 is not the same as that produced by - this class with JMX 1.1 and jmx.serial.form=1.0. However, - the serialization without that property is the same, and - that is the only form required by JMX 1.2. - */ - long uid = 8644704819898565848L; - try { - GetPropertyAction act = new GetPropertyAction("jmx.serial.form"); - @SuppressWarnings("removal") - String form = AccessController.doPrivileged(act); - if ("1.0".equals(form)) - uid = 7043855487133450673L; - } catch (Exception e) { - // OK: exception means no compat with 1.0, too bad - } - serialVersionUID = uid; - } + private static final long serialVersionUID = 8644704819898565848L; static final MBeanAttributeInfo[] NO_ATTRIBUTES = new MBeanAttributeInfo[0]; diff --git a/src/java.management/share/classes/javax/management/Notification.java b/src/java.management/share/classes/javax/management/Notification.java index 9455264fa04..80cf4b464d2 100644 --- a/src/java.management/share/classes/javax/management/Notification.java +++ b/src/java.management/share/classes/javax/management/Notification.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -53,46 +53,9 @@ import com.sun.jmx.mbeanserver.GetPropertyAction; * * @since 1.5 */ -@SuppressWarnings("serial") // serialVersionUID is not constant public class Notification extends EventObject { - // Serialization compatibility stuff: - // Two serial forms are supported in this class. The selected form depends - // on system property "jmx.serial.form": - // - "1.0" for JMX 1.0 - // - any other value for JMX 1.1 and higher - // - // Serial version for old serial form - private static final long oldSerialVersionUID = 1716977971058914352L; - // - // Serial version for new serial form - private static final long newSerialVersionUID = -7516092053498031989L; - // - // Serializable fields in old serial form - private static final ObjectStreamField[] oldSerialPersistentFields = - { - new ObjectStreamField("message", String.class), - new ObjectStreamField("sequenceNumber", Long.TYPE), - new ObjectStreamField("source", Object.class), - new ObjectStreamField("sourceObjectName", ObjectName.class), - new ObjectStreamField("timeStamp", Long.TYPE), - new ObjectStreamField("type", String.class), - new ObjectStreamField("userData", Object.class) - }; - // - // Serializable fields in new serial form - private static final ObjectStreamField[] newSerialPersistentFields = - { - new ObjectStreamField("message", String.class), - new ObjectStreamField("sequenceNumber", Long.TYPE), - new ObjectStreamField("source", Object.class), - new ObjectStreamField("timeStamp", Long.TYPE), - new ObjectStreamField("type", String.class), - new ObjectStreamField("userData", Object.class) - }; - // - // Actual serial version and serial form - private static final long serialVersionUID; + private static final long serialVersionUID = -7516092053498031989L; /** * @serialField type String The notification type. * A string expressed in a dot notation similar to Java properties. @@ -108,28 +71,15 @@ public class Notification extends EventObject { * @serialField message String The notification message. * @serialField source Object The object on which the notification initially occurred. */ - private static final ObjectStreamField[] serialPersistentFields; - private static boolean compat = false; - static { - try { - GetPropertyAction act = new GetPropertyAction("jmx.serial.form"); - @SuppressWarnings("removal") - String form = AccessController.doPrivileged(act); - compat = (form != null && form.equals("1.0")); - } catch (Exception e) { - // OK: exception means no compat with 1.0, too bad - } - if (compat) { - serialPersistentFields = oldSerialPersistentFields; - serialVersionUID = oldSerialVersionUID; - } else { - serialPersistentFields = newSerialPersistentFields; - serialVersionUID = newSerialVersionUID; - } - } - // - // END Serialization compatibility stuff - + private static final ObjectStreamField[] serialPersistentFields = + { + new ObjectStreamField("message", String.class), + new ObjectStreamField("sequenceNumber", Long.TYPE), + new ObjectStreamField("source", Object.class), + new ObjectStreamField("timeStamp", Long.TYPE), + new ObjectStreamField("type", String.class), + new ObjectStreamField("userData", Object.class) + }; /** * @serial The notification type. * A string expressed in a dot notation similar to Java properties. @@ -378,21 +328,6 @@ public class Notification extends EventObject { */ private void writeObject(ObjectOutputStream out) throws IOException { - if (compat) { - // Serializes this instance in the old serial form - // - ObjectOutputStream.PutField fields = out.putFields(); - fields.put("type", type); - fields.put("sequenceNumber", sequenceNumber); - fields.put("timeStamp", timeStamp); - fields.put("userData", userData); - fields.put("message", message); - fields.put("source", source); - out.writeFields(); - } else { - // Serializes this instance in the new serial form - // - out.defaultWriteObject(); - } + out.defaultWriteObject(); } } diff --git a/src/java.management/share/classes/javax/management/NumericValueExp.java b/src/java.management/share/classes/javax/management/NumericValueExp.java index 959375a2f50..bae84019d2e 100644 --- a/src/java.management/share/classes/javax/management/NumericValueExp.java +++ b/src/java.management/share/classes/javax/management/NumericValueExp.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -45,68 +45,19 @@ import java.security.AccessController; * * @since 1.5 */ -@SuppressWarnings("serial") // serialVersionUID not constant class NumericValueExp extends QueryEval implements ValueExp { - // Serialization compatibility stuff: - // Two serial forms are supported in this class. The selected form depends - // on system property "jmx.serial.form": - // - "1.0" for JMX 1.0 - // - any other value for JMX 1.1 and higher - // - // Serial version for old serial form - private static final long oldSerialVersionUID = -6227876276058904000L; - // - // Serial version for new serial form - private static final long newSerialVersionUID = -4679739485102359104L; - // - // Serializable fields in old serial form - private static final ObjectStreamField[] oldSerialPersistentFields = - { - new ObjectStreamField("longVal", Long.TYPE), - new ObjectStreamField("doubleVal", Double.TYPE), - new ObjectStreamField("valIsLong", Boolean.TYPE) - }; - // - // Serializable fields in new serial form - private static final ObjectStreamField[] newSerialPersistentFields = - { - new ObjectStreamField("val", Number.class) - }; - // - // Actual serial version and serial form - private static final long serialVersionUID; - + private static final long serialVersionUID = -4679739485102359104L; /** * @serialField val Number The numeric value * *

                The serialVersionUID of this class is -4679739485102359104L. */ - private static final ObjectStreamField[] serialPersistentFields; + private static final ObjectStreamField[] serialPersistentFields = { + new ObjectStreamField("val", Number.class) + }; private Number val = 0.0; - private static boolean compat = false; - static { - try { - GetPropertyAction act = new GetPropertyAction("jmx.serial.form"); - @SuppressWarnings("removal") - String form = AccessController.doPrivileged(act); - compat = (form != null && form.equals("1.0")); - } catch (Exception e) { - // OK: exception means no compat with 1.0, too bad - } - if (compat) { - serialPersistentFields = oldSerialPersistentFields; - serialVersionUID = oldSerialVersionUID; - } else { - serialPersistentFields = newSerialPersistentFields; - serialVersionUID = newSerialVersionUID; - } - } - // - // END Serialization compatibility stuff - - /** * Basic constructor. */ @@ -189,44 +140,7 @@ class NumericValueExp extends QueryEval implements ValueExp { */ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { - if (compat) - { - // Read an object serialized in the old serial form - // - double doubleVal; - long longVal; - boolean isLong; - ObjectInputStream.GetField fields = in.readFields(); - doubleVal = fields.get("doubleVal", (double)0); - if (fields.defaulted("doubleVal")) - { - throw new NullPointerException("doubleVal"); - } - longVal = fields.get("longVal", (long)0); - if (fields.defaulted("longVal")) - { - throw new NullPointerException("longVal"); - } - isLong = fields.get("valIsLong", false); - if (fields.defaulted("valIsLong")) - { - throw new NullPointerException("valIsLong"); - } - if (isLong) - { - this.val = longVal; - } - else - { - this.val = doubleVal; - } - } - else - { - // Read an object serialized in the new serial form - // - in.defaultReadObject(); - } + in.defaultReadObject(); } @@ -235,22 +149,7 @@ class NumericValueExp extends QueryEval implements ValueExp { */ private void writeObject(ObjectOutputStream out) throws IOException { - if (compat) - { - // Serializes this instance in the old serial form - // - ObjectOutputStream.PutField fields = out.putFields(); - fields.put("doubleVal", doubleValue()); - fields.put("longVal", longValue()); - fields.put("valIsLong", isLong()); - out.writeFields(); - } - else - { - // Serializes this instance in the new serial form - // - out.defaultWriteObject(); - } + out.defaultWriteObject(); } @Deprecated diff --git a/src/java.management/share/classes/javax/management/ObjectName.java b/src/java.management/share/classes/javax/management/ObjectName.java index 00d5cc6930d..f20750c9d8a 100644 --- a/src/java.management/share/classes/javax/management/ObjectName.java +++ b/src/java.management/share/classes/javax/management/ObjectName.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -222,7 +222,6 @@ import java.util.Map; * @implNote The maximum allowed length of the domain name in this implementation * is {@code Integer.MAX_VALUE/4} */ -@SuppressWarnings("serial") // don't complain serialVersionUID not constant public class ObjectName implements Comparable, QueryExp { private static final int DOMAIN_PATTERN = 0x8000_0000; private static final int PROPLIST_PATTERN = 0x4000_0000; @@ -294,57 +293,7 @@ public class ObjectName implements Comparable, QueryExp { // Private fields ----------------------------------------> - // Serialization compatibility stuff --------------------> - - // Two serial forms are supported in this class. The selected form depends - // on system property "jmx.serial.form": - // - "1.0" for JMX 1.0 - // - any other value for JMX 1.1 and higher - // - // Serial version for old serial form - private static final long oldSerialVersionUID = -5467795090068647408L; - // - // Serial version for new serial form - private static final long newSerialVersionUID = 1081892073854801359L; - // - // Serializable fields in old serial form - private static final ObjectStreamField[] oldSerialPersistentFields = - { - new ObjectStreamField("domain", String.class), - new ObjectStreamField("propertyList", Hashtable.class), - new ObjectStreamField("propertyListString", String.class), - new ObjectStreamField("canonicalName", String.class), - new ObjectStreamField("pattern", Boolean.TYPE), - new ObjectStreamField("propertyPattern", Boolean.TYPE) - }; - // - // Serializable fields in new serial form - private static final ObjectStreamField[] newSerialPersistentFields = { }; - // - // Actual serial version and serial form - private static final long serialVersionUID; - private static final ObjectStreamField[] serialPersistentFields; - private static boolean compat = false; - static { - try { - GetPropertyAction act = new GetPropertyAction("jmx.serial.form"); - @SuppressWarnings("removal") - String form = AccessController.doPrivileged(act); - compat = (form != null && form.equals("1.0")); - } catch (Exception e) { - // OK: exception means no compat with 1.0, too bad - } - if (compat) { - serialPersistentFields = oldSerialPersistentFields; - serialVersionUID = oldSerialVersionUID; - } else { - serialPersistentFields = newSerialPersistentFields; - serialVersionUID = newSerialVersionUID; - } - } - - // - // Serialization compatibility stuff <============================== + private static final long serialVersionUID = 1081892073854801359L; // Class private fields -----------------------------------> @@ -1088,90 +1037,32 @@ public class ObjectName implements Comparable, QueryExp { /** * Deserializes an {@link ObjectName} from an {@link ObjectInputStream}. - * @serialData

                  - *
                • In the current serial form (value of property - * jmx.serial.form differs from - * 1.0): the string - * "<domain>:<properties><wild>", - * where:
                    - *
                  • <domain> represents the domain part - * of the {@link ObjectName}
                  • - *
                  • <properties> represents the list of - * properties, as returned by - * {@link #getKeyPropertyListString} - *
                  • <wild> is empty if not - * isPropertyPattern, or - * is the character "*" if - * isPropertyPattern - * and <properties> is empty, or - * is ",*" if - * isPropertyPattern and - * <properties> is not empty. - *
                  • - *
                  - * The intent is that this string could be supplied - * to the {@link #ObjectName(String)} constructor to - * produce an equivalent {@link ObjectName}. - *
                • - *
                • In the old serial form (value of property - * jmx.serial.form is - * 1.0): <domain> <propertyList> - * <propertyListString> <canonicalName> - * <pattern> <propertyPattern>, - * where:
                    - *
                  • <domain> represents the domain part - * of the {@link ObjectName}
                  • - *
                  • <propertyList> is the - * {@link Hashtable} that contains all the - * pairs (key,value) for this - * {@link ObjectName}
                  • - *
                  • <propertyListString> is the - * {@link String} representation of the - * list of properties in any order (not - * mandatorily a canonical representation) - *
                  • - *
                  • <canonicalName> is the - * {@link String} containing this - * {@link ObjectName}'s canonical name
                  • - *
                  • <pattern> is a boolean which is - * true if this - * {@link ObjectName} contains a pattern
                  • - *
                  • <propertyPattern> is a boolean which - * is true if this - * {@link ObjectName} contains a pattern in - * the list of properties
                  • - *
                  - *
                • + * @serialData The string "<domain>:<properties><wild>", where: + *
                    + *
                  • <domain> represents the domain part + * of the {@link ObjectName}
                  • + *
                  • <properties> represents the list of + * properties, as returned by + * {@link #getKeyPropertyListString}
                  • + *
                  • <wild> is empty if not + * isPropertyPattern, or + * is the character "*" if + * isPropertyPattern + * and <properties> is empty, or + * is ",*" if + * isPropertyPattern and + * <properties> is not empty.
                  • *
                  + * The intent is that this string could be supplied + * to the {@link #ObjectName(String)} constructor to + * produce an equivalent {@link ObjectName}. */ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { String cn; - if (compat) { - // Read an object serialized in the old serial form - // - //in.defaultReadObject(); - final ObjectInputStream.GetField fields = in.readFields(); - String propListString = - (String)fields.get("propertyListString", ""); - - // 6616825: take care of property patterns - final boolean propPattern = - fields.get("propertyPattern" , false); - if (propPattern) { - propListString = - (propListString.length()==0?"*":(propListString+",*")); - } - - cn = (String)fields.get("domain", "default")+ - ":"+ propListString; - } else { - // Read an object serialized in the new serial form - // - in.defaultReadObject(); - cn = (String)in.readObject(); - } + in.defaultReadObject(); + cn = (String)in.readObject(); try { construct(cn); @@ -1183,85 +1074,31 @@ public class ObjectName implements Comparable, QueryExp { /** * Serializes an {@link ObjectName} to an {@link ObjectOutputStream}. - * @serialData
                    - *
                  • In the current serial form (value of property - * jmx.serial.form differs from - * 1.0): the string - * "<domain>:<properties><wild>", - * where:
                      - *
                    • <domain> represents the domain part - * of the {@link ObjectName}
                    • - *
                    • <properties> represents the list of - * properties, as returned by - * {@link #getKeyPropertyListString} - *
                    • <wild> is empty if not - * isPropertyPattern, or - * is the character "*" if - * this isPropertyPattern - * and <properties> is empty, or - * is ",*" if - * isPropertyPattern and - * <properties> is not empty. - *
                    • - *
                    - * The intent is that this string could be supplied - * to the {@link #ObjectName(String)} constructor to - * produce an equivalent {@link ObjectName}. - *
                  • - *
                  • In the old serial form (value of property - * jmx.serial.form is - * 1.0): <domain> <propertyList> - * <propertyListString> <canonicalName> - * <pattern> <propertyPattern>, - * where:
                      - *
                    • <domain> represents the domain part - * of the {@link ObjectName}
                    • - *
                    • <propertyList> is the - * {@link Hashtable} that contains all the - * pairs (key,value) for this - * {@link ObjectName}
                    • - *
                    • <propertyListString> is the - * {@link String} representation of the - * list of properties in any order (not - * mandatorily a canonical representation) - *
                    • - *
                    • <canonicalName> is the - * {@link String} containing this - * {@link ObjectName}'s canonical name
                    • - *
                    • <pattern> is a boolean which is - * true if this - * {@link ObjectName} contains a pattern
                    • - *
                    • <propertyPattern> is a boolean which - * is true if this - * {@link ObjectName} contains a pattern in - * the list of properties
                    • - *
                    - *
                  • + * @serialData The string "<domain>:<properties><wild>", where: + *
                      + *
                    • <domain> represents the domain part + * of the {@link ObjectName}
                    • + *
                    • <properties> represents the list of + * properties, as returned by + * {@link #getKeyPropertyListString}
                    • + *
                    • <wild> is empty if not + * isPropertyPattern, or + * is the character "*" if + * this isPropertyPattern + * and <properties> is empty, or + * is ",*" if + * isPropertyPattern and + * <properties> is not empty.
                    • *
                    + * The intent is that this string could be supplied + * to the {@link #ObjectName(String)} constructor to + * produce an equivalent {@link ObjectName}. */ private void writeObject(ObjectOutputStream out) throws IOException { - if (compat) - { - // Serializes this instance in the old serial form - // Read CR 6441274 before making any changes to this code - ObjectOutputStream.PutField fields = out.putFields(); - fields.put("domain", _canonicalName.substring(0, getDomainLength())); - fields.put("propertyList", getKeyPropertyList()); - fields.put("propertyListString", getKeyPropertyListString()); - fields.put("canonicalName", _canonicalName); - fields.put("pattern", (_compressed_storage & (DOMAIN_PATTERN | PROPLIST_PATTERN)) != 0); - fields.put("propertyPattern", isPropertyListPattern()); - out.writeFields(); - } - else - { - // Serializes this instance in the new serial form - // - out.defaultWriteObject(); - out.writeObject(getSerializedNameString()); - } + out.defaultWriteObject(); + out.writeObject(getSerializedNameString()); } // Category : Serialization <=================================== diff --git a/src/java.management/share/classes/javax/management/modelmbean/DescriptorSupport.java b/src/java.management/share/classes/javax/management/modelmbean/DescriptorSupport.java index 00aa6ab7eb7..bea7ad92d0c 100644 --- a/src/java.management/share/classes/javax/management/modelmbean/DescriptorSupport.java +++ b/src/java.management/share/classes/javax/management/modelmbean/DescriptorSupport.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -81,69 +81,18 @@ import sun.reflect.misc.ReflectUtil; * * @since 1.5 */ -@SuppressWarnings("serial") // serialVersionUID not constant public class DescriptorSupport implements javax.management.Descriptor { - // Serialization compatibility stuff: - // Two serial forms are supported in this class. The selected form depends - // on system property "jmx.serial.form": - // - "1.0" for JMX 1.0 - // - any other value for JMX 1.1 and higher - // - // Serial version for old serial form - private static final long oldSerialVersionUID = 8071560848919417985L; - // - // Serial version for new serial form - private static final long newSerialVersionUID = -6292969195866300415L; - // - // Serializable fields in old serial form - private static final ObjectStreamField[] oldSerialPersistentFields = - { - new ObjectStreamField("descriptor", HashMap.class), - new ObjectStreamField("currClass", String.class) - }; - // - // Serializable fields in new serial form - private static final ObjectStreamField[] newSerialPersistentFields = - { - new ObjectStreamField("descriptor", HashMap.class) - }; - // - // Actual serial version and serial form - private static final long serialVersionUID; + private static final long serialVersionUID = -6292969195866300415L; /** * @serialField descriptor HashMap The collection of fields representing this descriptor */ - private static final ObjectStreamField[] serialPersistentFields; - private static final String serialForm; - static { - serialForm = getForm(); - boolean compat = "1.0".equals(serialForm); // serialForm may be null - if (compat) { - serialPersistentFields = oldSerialPersistentFields; - serialVersionUID = oldSerialVersionUID; - } else { - serialPersistentFields = newSerialPersistentFields; - serialVersionUID = newSerialVersionUID; - } - } - - @SuppressWarnings("removal") - private static String getForm() { - String form = null; - try { - GetPropertyAction act = new GetPropertyAction("jmx.serial.form"); - return AccessController.doPrivileged(act); - } catch (Exception e) { - // OK: No compat with 1.0 - return null; - } - } - - // - // END Serialization compatibility stuff + private static final ObjectStreamField[] serialPersistentFields = + { + new ObjectStreamField("descriptor", HashMap.class) + }; /* Spec says that field names are case-insensitive, but that case is preserved. This means that we need to be able to map from a @@ -1286,22 +1235,8 @@ public class DescriptorSupport /** * Serializes a {@link DescriptorSupport} to an {@link ObjectOutputStream}. */ - /* If you set jmx.serial.form to "1.2.0" or "1.2.1", then we are - bug-compatible with those versions. Specifically, field names - are forced to lower-case before being written. This - contradicts the spec, which, though it does not mention - serialization explicitly, does say that the case of field names - is preserved. But in 1.2.0 and 1.2.1, this requirement was not - met. Instead, field names in the descriptor map were forced to - lower case. Those versions expect this to have happened to a - descriptor they deserialize and e.g. getFieldValue will not - find a field whose name is spelt with a different case. - */ private void writeObject(ObjectOutputStream out) throws IOException { ObjectOutputStream.PutField fields = out.putFields(); - boolean compat = "1.0".equals(serialForm); - if (compat) - fields.put("currClass", currClass); /* Purge the field "targetObject" from the DescriptorSupport before * serializing since the referenced object is typically not @@ -1315,15 +1250,7 @@ public class DescriptorSupport startMap.remove("targetObject"); } - final HashMap descriptor; - if (compat || "1.2.0".equals(serialForm) || - "1.2.1".equals(serialForm)) { - descriptor = new HashMap<>(); - for (Map.Entry entry : startMap.entrySet()) - descriptor.put(entry.getKey().toLowerCase(), entry.getValue()); - } else - descriptor = new HashMap<>(startMap); - + final HashMap descriptor = new HashMap<>(startMap); fields.put("descriptor", descriptor); out.writeFields(); } diff --git a/src/java.management/share/classes/javax/management/modelmbean/InvalidTargetObjectTypeException.java b/src/java.management/share/classes/javax/management/modelmbean/InvalidTargetObjectTypeException.java index 2c90dcaa209..d7d3bed055c 100644 --- a/src/java.management/share/classes/javax/management/modelmbean/InvalidTargetObjectTypeException.java +++ b/src/java.management/share/classes/javax/management/modelmbean/InvalidTargetObjectTypeException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,61 +46,16 @@ import java.security.AccessController; * * @since 1.5 */ -@SuppressWarnings("serial") // serialVersionUID not constant public class InvalidTargetObjectTypeException extends Exception { - - // Serialization compatibility stuff: - // Two serial forms are supported in this class. The selected form depends - // on system property "jmx.serial.form": - // - "1.0" for JMX 1.0 - // - any other value for JMX 1.1 and higher - // - // Serial version for old serial form - private static final long oldSerialVersionUID = 3711724570458346634L; - // - // Serial version for new serial form - private static final long newSerialVersionUID = 1190536278266811217L; - // - // Serializable fields in old serial form - private static final ObjectStreamField[] oldSerialPersistentFields = - { - new ObjectStreamField("msgStr", String.class), - new ObjectStreamField("relatedExcept", Exception.class) - }; - // - // Serializable fields in new serial form - private static final ObjectStreamField[] newSerialPersistentFields = - { - new ObjectStreamField("exception", Exception.class) - }; - // - // Actual serial version and serial form - private static final long serialVersionUID; + private static final long serialVersionUID = 1190536278266811217L; /** * @serialField exception Exception Encapsulated {@link Exception} */ - private static final ObjectStreamField[] serialPersistentFields; - private static boolean compat = false; - static { - try { - GetPropertyAction act = new GetPropertyAction("jmx.serial.form"); - @SuppressWarnings("removal") - String form = AccessController.doPrivileged(act); - compat = (form != null && form.equals("1.0")); - } catch (Exception e) { - // OK: No compat with 1.0 - } - if (compat) { - serialPersistentFields = oldSerialPersistentFields; - serialVersionUID = oldSerialVersionUID; - } else { - serialPersistentFields = newSerialPersistentFields; - serialVersionUID = newSerialVersionUID; - } - } - // - // END Serialization compatibility stuff + private static final ObjectStreamField[] serialPersistentFields = + { + new ObjectStreamField("exception", Exception.class) + }; /** * @serial Encapsulated {@link Exception} @@ -156,23 +111,7 @@ public class InvalidTargetObjectTypeException extends Exception */ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { - if (compat) - { - // Read an object serialized in the old serial form - // - ObjectInputStream.GetField fields = in.readFields(); - exception = (Exception) fields.get("relatedExcept", null); - if (fields.defaulted("relatedExcept")) - { - throw new NullPointerException("relatedExcept"); - } - } - else - { - // Read an object serialized in the new serial form - // - in.defaultReadObject(); - } + in.defaultReadObject(); } @@ -181,20 +120,6 @@ public class InvalidTargetObjectTypeException extends Exception */ private void writeObject(ObjectOutputStream out) throws IOException { - if (compat) - { - // Serializes this instance in the old serial form - // - ObjectOutputStream.PutField fields = out.putFields(); - fields.put("relatedExcept", exception); - fields.put("msgStr", ((exception != null)?exception.getMessage():"")); - out.writeFields(); - } - else - { - // Serializes this instance in the new serial form - // - out.defaultWriteObject(); - } + out.defaultWriteObject(); } } diff --git a/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanAttributeInfo.java b/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanAttributeInfo.java index b4e7ecfd1e7..d30bd368a63 100644 --- a/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanAttributeInfo.java +++ b/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanAttributeInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -116,63 +116,19 @@ import javax.management.RuntimeOperationsException; * @since 1.5 */ -@SuppressWarnings("serial") // serialVersionUID is not constant public class ModelMBeanAttributeInfo extends MBeanAttributeInfo implements DescriptorAccess { - // Serialization compatibility stuff: - // Two serial forms are supported in this class. The selected form depends - // on system property "jmx.serial.form": - // - "1.0" for JMX 1.0 - // - any other value for JMX 1.1 and higher - // - // Serial version for old serial form - private static final long oldSerialVersionUID = 7098036920755973145L; - // - // Serial version for new serial form - private static final long newSerialVersionUID = 6181543027787327345L; - // - // Serializable fields in old serial form - private static final ObjectStreamField[] oldSerialPersistentFields = - { - new ObjectStreamField("attrDescriptor", Descriptor.class), - new ObjectStreamField("currClass", String.class) - }; - // - // Serializable fields in new serial form - private static final ObjectStreamField[] newSerialPersistentFields = - { - new ObjectStreamField("attrDescriptor", Descriptor.class) - }; - // - // Actual serial version and serial form - private static final long serialVersionUID; - /** - * @serialField attrDescriptor Descriptor The {@link Descriptor} - * containing the metadata corresponding to this attribute - */ - private static final ObjectStreamField[] serialPersistentFields; - private static boolean compat = false; - static { - try { - GetPropertyAction act = new GetPropertyAction("jmx.serial.form"); - @SuppressWarnings("removal") - String form = AccessController.doPrivileged(act); - compat = (form != null && form.equals("1.0")); - } catch (Exception e) { - // OK: No compat with 1.0 - } - if (compat) { - serialPersistentFields = oldSerialPersistentFields; - serialVersionUID = oldSerialVersionUID; - } else { - serialPersistentFields = newSerialPersistentFields; - serialVersionUID = newSerialVersionUID; - } - } - // - // END Serialization compatibility stuff + private static final long serialVersionUID = 6181543027787327345L; + /** + * @serialField attrDescriptor Descriptor The {@link Descriptor} + * containing the metadata corresponding to this attribute + */ + private static final ObjectStreamField[] serialPersistentFields = + { + new ObjectStreamField("attrDescriptor", Descriptor.class) + }; /** * @serial The {@link Descriptor} containing the metadata corresponding to @@ -508,21 +464,7 @@ public class ModelMBeanAttributeInfo */ private void writeObject(ObjectOutputStream out) throws IOException { - if (compat) - { - // Serializes this instance in the old serial form - // - ObjectOutputStream.PutField fields = out.putFields(); - fields.put("attrDescriptor", attrDescriptor); - fields.put("currClass", currClass); - out.writeFields(); - } - else - { - // Serializes this instance in the new serial form - // - out.defaultWriteObject(); - } + out.defaultWriteObject(); } } diff --git a/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanConstructorInfo.java b/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanConstructorInfo.java index 3b5863007a6..0b8413083ac 100644 --- a/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanConstructorInfo.java +++ b/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanConstructorInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -89,63 +89,18 @@ import javax.management.RuntimeOperationsException; * * @since 1.5 */ - -@SuppressWarnings("serial") // serialVersionUID is not constant public class ModelMBeanConstructorInfo extends MBeanConstructorInfo implements DescriptorAccess { - // Serialization compatibility stuff: - // Two serial forms are supported in this class. The selected form depends - // on system property "jmx.serial.form": - // - "1.0" for JMX 1.0 - // - any other value for JMX 1.1 and higher - // - // Serial version for old serial form - private static final long oldSerialVersionUID = -4440125391095574518L; - // - // Serial version for new serial form - private static final long newSerialVersionUID = 3862947819818064362L; - // - // Serializable fields in old serial form - private static final ObjectStreamField[] oldSerialPersistentFields = - { - new ObjectStreamField("consDescriptor", Descriptor.class), - new ObjectStreamField("currClass", String.class) - }; - // - // Serializable fields in new serial form - private static final ObjectStreamField[] newSerialPersistentFields = - { - new ObjectStreamField("consDescriptor", Descriptor.class) - }; - // - // Actual serial version and serial form - private static final long serialVersionUID; - /** - * @serialField consDescriptor Descriptor The {@link Descriptor} containing the metadata for this instance - */ - private static final ObjectStreamField[] serialPersistentFields; - private static boolean compat = false; - static { - try { - GetPropertyAction act = new GetPropertyAction("jmx.serial.form"); - @SuppressWarnings("removal") - String form = AccessController.doPrivileged(act); - compat = (form != null && form.equals("1.0")); - } catch (Exception e) { - // OK: No compat with 1.0 - } - if (compat) { - serialPersistentFields = oldSerialPersistentFields; - serialVersionUID = oldSerialVersionUID; - } else { - serialPersistentFields = newSerialPersistentFields; - serialVersionUID = newSerialVersionUID; - } - } - // - // END Serialization compatibility stuff + private static final long serialVersionUID = 3862947819818064362L; + /** + * @serialField consDescriptor Descriptor The {@link Descriptor} containing the metadata for this instance + */ + private static final ObjectStreamField[] serialPersistentFields = + { + new ObjectStreamField("consDescriptor", Descriptor.class) + }; /** * @serial The {@link Descriptor} containing the metadata for this instance @@ -464,21 +419,7 @@ public class ModelMBeanConstructorInfo */ private void writeObject(ObjectOutputStream out) throws IOException { - if (compat) - { - // Serializes this instance in the old serial form - // - ObjectOutputStream.PutField fields = out.putFields(); - fields.put("consDescriptor", consDescriptor); - fields.put("currClass", currClass); - out.writeFields(); - } - else - { - // Serializes this instance in the new serial form - // - out.defaultWriteObject(); - } + out.defaultWriteObject(); } } diff --git a/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanInfoSupport.java b/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanInfoSupport.java index bf164b678cc..a209c2c7f42 100644 --- a/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanInfoSupport.java +++ b/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanInfoSupport.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -81,44 +81,9 @@ import javax.management.RuntimeOperationsException; * * @since 1.5 */ -@SuppressWarnings("serial") public class ModelMBeanInfoSupport extends MBeanInfo implements ModelMBeanInfo { - // Serialization compatibility stuff: - // Two serial forms are supported in this class. The selected form depends - // on system property "jmx.serial.form": - // - "1.0" for JMX 1.0 - // - any other value for JMX 1.1 and higher - // - // Serial version for old serial form - private static final long oldSerialVersionUID = -3944083498453227709L; - // - // Serial version for new serial form - private static final long newSerialVersionUID = -1935722590756516193L; - // - // Serializable fields in old serial form - private static final ObjectStreamField[] oldSerialPersistentFields = - { - new ObjectStreamField("modelMBeanDescriptor", Descriptor.class), - new ObjectStreamField("mmbAttributes", MBeanAttributeInfo[].class), - new ObjectStreamField("mmbConstructors", MBeanConstructorInfo[].class), - new ObjectStreamField("mmbNotifications", MBeanNotificationInfo[].class), - new ObjectStreamField("mmbOperations", MBeanOperationInfo[].class), - new ObjectStreamField("currClass", String.class) - }; - // - // Serializable fields in new serial form - private static final ObjectStreamField[] newSerialPersistentFields = - { - new ObjectStreamField("modelMBeanDescriptor", Descriptor.class), - new ObjectStreamField("modelMBeanAttributes", MBeanAttributeInfo[].class), - new ObjectStreamField("modelMBeanConstructors", MBeanConstructorInfo[].class), - new ObjectStreamField("modelMBeanNotifications", MBeanNotificationInfo[].class), - new ObjectStreamField("modelMBeanOperations", MBeanOperationInfo[].class) - }; - // - // Actual serial version and serial form - private static final long serialVersionUID; + private static final long serialVersionUID = -1935722590756516193L; /** * @serialField modelMBeanDescriptor Descriptor The descriptor containing * MBean wide policy @@ -135,27 +100,14 @@ public class ModelMBeanInfoSupport extends MBeanInfo implements ModelMBeanInfo { * {@link ModelMBeanOperationInfo} objects which * have descriptors */ - private static final ObjectStreamField[] serialPersistentFields; - private static boolean compat = false; - static { - try { - GetPropertyAction act = new GetPropertyAction("jmx.serial.form"); - @SuppressWarnings("removal") - String form = AccessController.doPrivileged(act); - compat = (form != null && form.equals("1.0")); - } catch (Exception e) { - // OK: No compat with 1.0 - } - if (compat) { - serialPersistentFields = oldSerialPersistentFields; - serialVersionUID = oldSerialVersionUID; - } else { - serialPersistentFields = newSerialPersistentFields; - serialVersionUID = newSerialVersionUID; - } - } - // - // END Serialization compatibility stuff + private static final ObjectStreamField[] serialPersistentFields = + { + new ObjectStreamField("modelMBeanDescriptor", Descriptor.class), + new ObjectStreamField("modelMBeanAttributes", MBeanAttributeInfo[].class), + new ObjectStreamField("modelMBeanConstructors", MBeanConstructorInfo[].class), + new ObjectStreamField("modelMBeanNotifications", MBeanNotificationInfo[].class), + new ObjectStreamField("modelMBeanOperations", MBeanOperationInfo[].class) + }; /** * @serial The descriptor containing MBean wide policy @@ -957,40 +909,8 @@ public class ModelMBeanInfoSupport extends MBeanInfo implements ModelMBeanInfo { */ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { - if (compat) { - // Read an object serialized in the old serial form - // - ObjectInputStream.GetField fields = in.readFields(); - modelMBeanDescriptor = - (Descriptor) fields.get("modelMBeanDescriptor", null); - if (fields.defaulted("modelMBeanDescriptor")) { - throw new NullPointerException("modelMBeanDescriptor"); - } - modelMBeanAttributes = - (MBeanAttributeInfo[]) fields.get("mmbAttributes", null); - if (fields.defaulted("mmbAttributes")) { - throw new NullPointerException("mmbAttributes"); - } - modelMBeanConstructors = - (MBeanConstructorInfo[]) fields.get("mmbConstructors", null); - if (fields.defaulted("mmbConstructors")) { - throw new NullPointerException("mmbConstructors"); - } - modelMBeanNotifications = - (MBeanNotificationInfo[]) fields.get("mmbNotifications", null); - if (fields.defaulted("mmbNotifications")) { - throw new NullPointerException("mmbNotifications"); - } - modelMBeanOperations = - (MBeanOperationInfo[]) fields.get("mmbOperations", null); - if (fields.defaulted("mmbOperations")) { - throw new NullPointerException("mmbOperations"); - } - } else { - // Read an object serialized in the new serial form - // - in.defaultReadObject(); - } + + in.defaultReadObject(); } @@ -999,22 +919,7 @@ public class ModelMBeanInfoSupport extends MBeanInfo implements ModelMBeanInfo { */ private void writeObject(ObjectOutputStream out) throws IOException { - if (compat) { - // Serializes this instance in the old serial form - // - ObjectOutputStream.PutField fields = out.putFields(); - fields.put("modelMBeanDescriptor", modelMBeanDescriptor); - fields.put("mmbAttributes", modelMBeanAttributes); - fields.put("mmbConstructors", modelMBeanConstructors); - fields.put("mmbNotifications", modelMBeanNotifications); - fields.put("mmbOperations", modelMBeanOperations); - fields.put("currClass", currClass); - out.writeFields(); - } else { - // Serializes this instance in the new serial form - // - out.defaultWriteObject(); - } + out.defaultWriteObject(); } diff --git a/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanNotificationInfo.java b/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanNotificationInfo.java index 1f6cf566ba3..c0bce84a5d9 100644 --- a/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanNotificationInfo.java +++ b/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanNotificationInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -96,64 +96,19 @@ import javax.management.RuntimeOperationsException; * * @since 1.5 */ - -@SuppressWarnings("serial") // serialVersionUID is not constant public class ModelMBeanNotificationInfo extends MBeanNotificationInfo implements DescriptorAccess { - // Serialization compatibility stuff: - // Two serial forms are supported in this class. The selected form - // depends on system property "jmx.serial.form": - // - "1.0" for JMX 1.0 - // - any other value for JMX 1.1 and higher - // - // Serial version for old serial form - private static final long oldSerialVersionUID = -5211564525059047097L; - // - // Serial version for new serial form - private static final long newSerialVersionUID = -7445681389570207141L; - // - // Serializable fields in old serial form - private static final ObjectStreamField[] oldSerialPersistentFields = - { - new ObjectStreamField("notificationDescriptor", Descriptor.class), - new ObjectStreamField("currClass", String.class) - }; - // - // Serializable fields in new serial form - private static final ObjectStreamField[] newSerialPersistentFields = - { - new ObjectStreamField("notificationDescriptor", Descriptor.class) - }; - // - // Actual serial version and serial form - private static final long serialVersionUID; + private static final long serialVersionUID = -7445681389570207141L; /** * @serialField notificationDescriptor Descriptor The descriptor * containing the appropriate metadata for this instance */ - private static final ObjectStreamField[] serialPersistentFields; - private static boolean compat = false; - static { - try { - GetPropertyAction act = new GetPropertyAction("jmx.serial.form"); - @SuppressWarnings("removal") - String form = AccessController.doPrivileged(act); - compat = (form != null && form.equals("1.0")); - } catch (Exception e) { - // OK: No compat with 1.0 - } - if (compat) { - serialPersistentFields = oldSerialPersistentFields; - serialVersionUID = oldSerialVersionUID; - } else { - serialPersistentFields = newSerialPersistentFields; - serialVersionUID = newSerialVersionUID; - } - } - // - // END Serialization compatibility stuff + private static final ObjectStreamField[] serialPersistentFields = + { + new ObjectStreamField("notificationDescriptor", Descriptor.class) + }; /** * @serial The descriptor containing the appropriate metadata for @@ -398,18 +353,7 @@ public class ModelMBeanNotificationInfo **/ private void writeObject(ObjectOutputStream out) throws IOException { - if (compat) { - // Serializes this instance in the old serial form - // - ObjectOutputStream.PutField fields = out.putFields(); - fields.put("notificationDescriptor", notificationDescriptor); - fields.put("currClass", currClass); - out.writeFields(); - } else { - // Serializes this instance in the new serial form - // - out.defaultWriteObject(); - } + out.defaultWriteObject(); } } diff --git a/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanOperationInfo.java b/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanOperationInfo.java index 5550be20d6f..1d22b41b1e8 100644 --- a/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanOperationInfo.java +++ b/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanOperationInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -108,64 +108,19 @@ import javax.management.RuntimeOperationsException; * * @since 1.5 */ - -@SuppressWarnings("serial") // serialVersionUID is not constant public class ModelMBeanOperationInfo extends MBeanOperationInfo implements DescriptorAccess { - // Serialization compatibility stuff: - // Two serial forms are supported in this class. The selected form depends - // on system property "jmx.serial.form": - // - "1.0" for JMX 1.0 - // - any other value for JMX 1.1 and higher - // - // Serial version for old serial form - private static final long oldSerialVersionUID = 9087646304346171239L; - // - // Serial version for new serial form - private static final long newSerialVersionUID = 6532732096650090465L; - // - // Serializable fields in old serial form - private static final ObjectStreamField[] oldSerialPersistentFields = - { - new ObjectStreamField("operationDescriptor", Descriptor.class), - new ObjectStreamField("currClass", String.class) - }; - // - // Serializable fields in new serial form - private static final ObjectStreamField[] newSerialPersistentFields = - { - new ObjectStreamField("operationDescriptor", Descriptor.class) - }; - // - // Actual serial version and serial form - private static final long serialVersionUID; - /** - * @serialField operationDescriptor Descriptor The descriptor - * containing the appropriate metadata for this instance - */ - private static final ObjectStreamField[] serialPersistentFields; - private static boolean compat = false; - static { - try { - GetPropertyAction act = new GetPropertyAction("jmx.serial.form"); - @SuppressWarnings("removal") - String form = AccessController.doPrivileged(act); - compat = (form != null && form.equals("1.0")); - } catch (Exception e) { - // OK: No compat with 1.0 - } - if (compat) { - serialPersistentFields = oldSerialPersistentFields; - serialVersionUID = oldSerialVersionUID; - } else { - serialPersistentFields = newSerialPersistentFields; - serialVersionUID = newSerialVersionUID; - } - } - // - // END Serialization compatibility stuff + private static final long serialVersionUID = 6532732096650090465L; + /** + * @serialField operationDescriptor Descriptor The descriptor + * containing the appropriate metadata for this instance + */ + private static final ObjectStreamField[] serialPersistentFields = + { + new ObjectStreamField("operationDescriptor", Descriptor.class) + }; /** * @serial The descriptor containing the appropriate metadata for this instance @@ -515,21 +470,7 @@ public class ModelMBeanOperationInfo extends MBeanOperationInfo */ private void writeObject(ObjectOutputStream out) throws IOException { - if (compat) - { - // Serializes this instance in the old serial form - // - ObjectOutputStream.PutField fields = out.putFields(); - fields.put("operationDescriptor", operationDescriptor); - fields.put("currClass", currClass); - out.writeFields(); - } - else - { - // Serializes this instance in the new serial form - // out.defaultWriteObject(); - } } } diff --git a/src/java.management/share/classes/javax/management/modelmbean/XMLParseException.java b/src/java.management/share/classes/javax/management/modelmbean/XMLParseException.java index 2be6f37bf3b..daa1abf039e 100644 --- a/src/java.management/share/classes/javax/management/modelmbean/XMLParseException.java +++ b/src/java.management/share/classes/javax/management/modelmbean/XMLParseException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -49,54 +49,10 @@ import java.security.AccessController; * * @since 1.5 */ -@SuppressWarnings("serial") // serialVersionUID not constant public class XMLParseException extends Exception { - // Serialization compatibility stuff: - // Two serial forms are supported in this class. The selected form depends - // on system property "jmx.serial.form": - // - "1.0" for JMX 1.0 - // - any other value for JMX 1.1 and higher - // - // Serial version for old serial form - private static final long oldSerialVersionUID = -7780049316655891976L; - // - // Serial version for new serial form - private static final long newSerialVersionUID = 3176664577895105181L; - // - // Serializable fields in old serial form - private static final ObjectStreamField[] oldSerialPersistentFields = - { - new ObjectStreamField("msgStr", String.class) - }; - // - // Serializable fields in new serial form - private static final ObjectStreamField[] newSerialPersistentFields = { }; - // - // Actual serial version and serial form - private static final long serialVersionUID; - private static final ObjectStreamField[] serialPersistentFields; - private static boolean compat = false; - static { - try { - GetPropertyAction act = new GetPropertyAction("jmx.serial.form"); - @SuppressWarnings("removal") - String form = AccessController.doPrivileged(act); - compat = (form != null && form.equals("1.0")); - } catch (Exception e) { - // OK: No compat with 1.0 - } - if (compat) { - serialPersistentFields = oldSerialPersistentFields; - serialVersionUID = oldSerialVersionUID; - } else { - serialPersistentFields = newSerialPersistentFields; - serialVersionUID = newSerialVersionUID; - } - } - // - // END Serialization compatibility stuff + private static final long serialVersionUID = 3176664577895105181L; /** * Default constructor . @@ -141,19 +97,6 @@ extends Exception */ private void writeObject(ObjectOutputStream out) throws IOException { - if (compat) - { - // Serializes this instance in the old serial form - // - ObjectOutputStream.PutField fields = out.putFields(); - fields.put("msgStr", getMessage()); - out.writeFields(); - } - else - { - // Serializes this instance in the new serial form - // - out.defaultWriteObject(); - } + out.defaultWriteObject(); } } diff --git a/src/java.management/share/classes/javax/management/relation/MBeanServerNotificationFilter.java b/src/java.management/share/classes/javax/management/relation/MBeanServerNotificationFilter.java index d02d15cb1e5..7579e416e36 100644 --- a/src/java.management/share/classes/javax/management/relation/MBeanServerNotificationFilter.java +++ b/src/java.management/share/classes/javax/management/relation/MBeanServerNotificationFilter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -57,37 +57,9 @@ import java.lang.System.Logger.Level; * * @since 1.5 */ -@SuppressWarnings("serial") // serialVersionUID must be constant public class MBeanServerNotificationFilter extends NotificationFilterSupport { - // Serialization compatibility stuff: - // Two serial forms are supported in this class. The selected form depends - // on system property "jmx.serial.form": - // - "1.0" for JMX 1.0 - // - any other value for JMX 1.1 and higher - // - // Serial version for old serial form - private static final long oldSerialVersionUID = 6001782699077323605L; - // - // Serial version for new serial form - private static final long newSerialVersionUID = 2605900539589789736L; - // - // Serializable fields in old serial form - private static final ObjectStreamField[] oldSerialPersistentFields = - { - new ObjectStreamField("mySelectObjNameList", Vector.class), - new ObjectStreamField("myDeselectObjNameList", Vector.class) - }; - // - // Serializable fields in new serial form - private static final ObjectStreamField[] newSerialPersistentFields = - { - new ObjectStreamField("selectedNames", List.class), - new ObjectStreamField("deselectedNames", List.class) - }; - // - // Actual serial version and serial form - private static final long serialVersionUID; + private static final long serialVersionUID = 2605900539589789736L; /** * @serialField selectedNames List List of {@link ObjectName}s of interest *
                      @@ -102,27 +74,11 @@ public class MBeanServerNotificationFilter extends NotificationFilterSupport { *
                    • Empty vector means that no {@link ObjectName} is explicitly deselected
                    • *
                    */ - private static final ObjectStreamField[] serialPersistentFields; - private static boolean compat = false; - static { - try { - GetPropertyAction act = new GetPropertyAction("jmx.serial.form"); - @SuppressWarnings("removal") - String form = AccessController.doPrivileged(act); - compat = (form != null && form.equals("1.0")); - } catch (Exception e) { - // OK : Too bad, no compat with 1.0 - } - if (compat) { - serialPersistentFields = oldSerialPersistentFields; - serialVersionUID = oldSerialVersionUID; - } else { - serialPersistentFields = newSerialPersistentFields; - serialVersionUID = newSerialVersionUID; - } - } - // - // END Serialization compatibility stuff + private static final ObjectStreamField[] serialPersistentFields = + { + new ObjectStreamField("selectedNames", List.class), + new ObjectStreamField("deselectedNames", List.class) + }; // // Private members @@ -405,28 +361,7 @@ public class MBeanServerNotificationFilter extends NotificationFilterSupport { */ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { - if (compat) - { - // Read an object serialized in the old serial form - // - ObjectInputStream.GetField fields = in.readFields(); - selectedNames = cast(fields.get("mySelectObjNameList", null)); - if (fields.defaulted("mySelectObjNameList")) - { - throw new NullPointerException("mySelectObjNameList"); - } - deselectedNames = cast(fields.get("myDeselectObjNameList", null)); - if (fields.defaulted("myDeselectObjNameList")) - { - throw new NullPointerException("myDeselectObjNameList"); - } - } - else - { - // Read an object serialized in the new serial form - // - in.defaultReadObject(); - } + in.defaultReadObject(); } @@ -435,20 +370,6 @@ public class MBeanServerNotificationFilter extends NotificationFilterSupport { */ private void writeObject(ObjectOutputStream out) throws IOException { - if (compat) - { - // Serializes this instance in the old serial form - // - ObjectOutputStream.PutField fields = out.putFields(); - fields.put("mySelectObjNameList", selectedNames); - fields.put("myDeselectObjNameList", deselectedNames); - out.writeFields(); - } - else - { - // Serializes this instance in the new serial form - // - out.defaultWriteObject(); - } + out.defaultWriteObject(); } } diff --git a/src/java.management/share/classes/javax/management/relation/RelationNotification.java b/src/java.management/share/classes/javax/management/relation/RelationNotification.java index 11c2fab163e..16d660bc07f 100644 --- a/src/java.management/share/classes/javax/management/relation/RelationNotification.java +++ b/src/java.management/share/classes/javax/management/relation/RelationNotification.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -57,47 +57,9 @@ import static com.sun.jmx.mbeanserver.Util.cast; * * @since 1.5 */ -@SuppressWarnings("serial") // serialVersionUID not constant public class RelationNotification extends Notification { - // Serialization compatibility stuff: - // Two serial forms are supported in this class. The selected form depends - // on system property "jmx.serial.form": - // - "1.0" for JMX 1.0 - // - any other value for JMX 1.1 and higher - // - // Serial version for old serial form - private static final long oldSerialVersionUID = -2126464566505527147L; - // - // Serial version for new serial form - private static final long newSerialVersionUID = -6871117877523310399L; - // - // Serializable fields in old serial form - private static final ObjectStreamField[] oldSerialPersistentFields = - { - new ObjectStreamField("myNewRoleValue", ArrayList.class), - new ObjectStreamField("myOldRoleValue", ArrayList.class), - new ObjectStreamField("myRelId", String.class), - new ObjectStreamField("myRelObjName", ObjectName.class), - new ObjectStreamField("myRelTypeName", String.class), - new ObjectStreamField("myRoleName", String.class), - new ObjectStreamField("myUnregMBeanList", ArrayList.class) - }; - // - // Serializable fields in new serial form - private static final ObjectStreamField[] newSerialPersistentFields = - { - new ObjectStreamField("newRoleValue", List.class), - new ObjectStreamField("oldRoleValue", List.class), - new ObjectStreamField("relationId", String.class), - new ObjectStreamField("relationObjName", ObjectName.class), - new ObjectStreamField("relationTypeName", String.class), - new ObjectStreamField("roleName", String.class), - new ObjectStreamField("unregisterMBeanList", List.class) - }; - // - // Actual serial version and serial form - private static final long serialVersionUID; + private static final long serialVersionUID = -6871117877523310399L; /** * @serialField relationId String Relation identifier of * created/removed/updated relation @@ -115,27 +77,16 @@ public class RelationNotification extends Notification { * @serialField newRoleValue List New role value ({@link * ArrayList} of {@link ObjectName}s) (only for role update) */ - private static final ObjectStreamField[] serialPersistentFields; - private static boolean compat = false; - static { - try { - GetPropertyAction act = new GetPropertyAction("jmx.serial.form"); - @SuppressWarnings("removal") - String form = AccessController.doPrivileged(act); - compat = (form != null && form.equals("1.0")); - } catch (Exception e) { - // OK : Too bad, no compat with 1.0 - } - if (compat) { - serialPersistentFields = oldSerialPersistentFields; - serialVersionUID = oldSerialVersionUID; - } else { - serialPersistentFields = newSerialPersistentFields; - serialVersionUID = newSerialVersionUID; - } - } - // - // END Serialization compatibility stuff + private static final ObjectStreamField[] serialPersistentFields = + { + new ObjectStreamField("newRoleValue", List.class), + new ObjectStreamField("oldRoleValue", List.class), + new ObjectStreamField("relationId", String.class), + new ObjectStreamField("relationObjName", ObjectName.class), + new ObjectStreamField("relationTypeName", String.class), + new ObjectStreamField("roleName", String.class), + new ObjectStreamField("unregisterMBeanList", List.class) + }; // // Notification types @@ -541,26 +492,14 @@ public class RelationNotification extends Notification { ObjectInputStream.GetField fields = in.readFields(); - if (compat) { - tmpRelationId = (String)fields.get("myRelId", null); - tmpRelationTypeName = (String)fields.get("myRelTypeName", null); - tmpRoleName = (String)fields.get("myRoleName", null); + tmpRelationId = (String)fields.get("relationId", null); + tmpRelationTypeName = (String)fields.get("relationTypeName", null); + tmpRoleName = (String)fields.get("roleName", null); - tmpRelationObjName = (ObjectName)fields.get("myRelObjName", null); - tmpNewRoleValue = cast(fields.get("myNewRoleValue", null)); - tmpOldRoleValue = cast(fields.get("myOldRoleValue", null)); - tmpUnregMBeanList = cast(fields.get("myUnregMBeanList", null)); - } - else { - tmpRelationId = (String)fields.get("relationId", null); - tmpRelationTypeName = (String)fields.get("relationTypeName", null); - tmpRoleName = (String)fields.get("roleName", null); - - tmpRelationObjName = (ObjectName)fields.get("relationObjName", null); - tmpNewRoleValue = cast(fields.get("newRoleValue", null)); - tmpOldRoleValue = cast(fields.get("oldRoleValue", null)); - tmpUnregMBeanList = cast(fields.get("unregisterMBeanList", null)); - } + tmpRelationObjName = (ObjectName)fields.get("relationObjName", null); + tmpNewRoleValue = cast(fields.get("newRoleValue", null)); + tmpOldRoleValue = cast(fields.get("oldRoleValue", null)); + tmpUnregMBeanList = cast(fields.get("unregisterMBeanList", null)); // Validate fields we just read, throw InvalidObjectException // if something goes wrong @@ -591,25 +530,6 @@ public class RelationNotification extends Notification { */ private void writeObject(ObjectOutputStream out) throws IOException { - if (compat) - { - // Serializes this instance in the old serial form - // - ObjectOutputStream.PutField fields = out.putFields(); - fields.put("myNewRoleValue", newRoleValue); - fields.put("myOldRoleValue", oldRoleValue); - fields.put("myRelId", relationId); - fields.put("myRelObjName", relationObjName); - fields.put("myRelTypeName", relationTypeName); - fields.put("myRoleName",roleName); - fields.put("myUnregMBeanList", unregisterMBeanList); - out.writeFields(); - } - else - { - // Serializes this instance in the new serial form - // - out.defaultWriteObject(); - } + out.defaultWriteObject(); } } diff --git a/src/java.management/share/classes/javax/management/relation/RelationTypeSupport.java b/src/java.management/share/classes/javax/management/relation/RelationTypeSupport.java index 5038fed2cfe..766c42ca780 100644 --- a/src/java.management/share/classes/javax/management/relation/RelationTypeSupport.java +++ b/src/java.management/share/classes/javax/management/relation/RelationTypeSupport.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -63,39 +63,9 @@ import java.lang.System.Logger.Level; * * @since 1.5 */ -@SuppressWarnings("serial") // serialVersionUID not constant public class RelationTypeSupport implements RelationType { - // Serialization compatibility stuff: - // Two serial forms are supported in this class. The selected form depends - // on system property "jmx.serial.form": - // - "1.0" for JMX 1.0 - // - any other value for JMX 1.1 and higher - // - // Serial version for old serial form - private static final long oldSerialVersionUID = -8179019472410837190L; - // - // Serial version for new serial form - private static final long newSerialVersionUID = 4611072955724144607L; - // - // Serializable fields in old serial form - private static final ObjectStreamField[] oldSerialPersistentFields = - { - new ObjectStreamField("myTypeName", String.class), - new ObjectStreamField("myRoleName2InfoMap", HashMap.class), - new ObjectStreamField("myIsInRelServFlg", boolean.class) - }; - // - // Serializable fields in new serial form - private static final ObjectStreamField[] newSerialPersistentFields = - { - new ObjectStreamField("typeName", String.class), - new ObjectStreamField("roleName2InfoMap", Map.class), - new ObjectStreamField("isInRelationService", boolean.class) - }; - // - // Actual serial version and serial form - private static final long serialVersionUID; + private static final long serialVersionUID = 4611072955724144607L; /** * @serialField typeName String Relation type name * @serialField roleName2InfoMap Map {@link Map} holding the mapping: @@ -103,27 +73,12 @@ public class RelationTypeSupport implements RelationType { * @serialField isInRelationService boolean Flag specifying whether the relation type has been declared in the * Relation Service (so can no longer be updated) */ - private static final ObjectStreamField[] serialPersistentFields; - private static boolean compat = false; - static { - try { - GetPropertyAction act = new GetPropertyAction("jmx.serial.form"); - @SuppressWarnings("removal") - String form = AccessController.doPrivileged(act); - compat = (form != null && form.equals("1.0")); - } catch (Exception e) { - // OK : Too bad, no compat with 1.0 - } - if (compat) { - serialPersistentFields = oldSerialPersistentFields; - serialVersionUID = oldSerialVersionUID; - } else { - serialPersistentFields = newSerialPersistentFields; - serialVersionUID = newSerialVersionUID; - } - } - // - // END Serialization compatibility stuff + private static final ObjectStreamField[] serialPersistentFields = + { + new ObjectStreamField("typeName", String.class), + new ObjectStreamField("roleName2InfoMap", Map.class), + new ObjectStreamField("isInRelationService", boolean.class) + }; // // Private members @@ -421,33 +376,7 @@ public class RelationTypeSupport implements RelationType { */ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { - if (compat) - { - // Read an object serialized in the old serial form - // - ObjectInputStream.GetField fields = in.readFields(); - typeName = (String) fields.get("myTypeName", null); - if (fields.defaulted("myTypeName")) - { - throw new NullPointerException("myTypeName"); - } - roleName2InfoMap = cast(fields.get("myRoleName2InfoMap", null)); - if (fields.defaulted("myRoleName2InfoMap")) - { - throw new NullPointerException("myRoleName2InfoMap"); - } - isInRelationService = fields.get("myIsInRelServFlg", false); - if (fields.defaulted("myIsInRelServFlg")) - { - throw new NullPointerException("myIsInRelServFlg"); - } - } - else - { - // Read an object serialized in the new serial form - // - in.defaultReadObject(); - } + in.defaultReadObject(); } @@ -456,21 +385,6 @@ public class RelationTypeSupport implements RelationType { */ private void writeObject(ObjectOutputStream out) throws IOException { - if (compat) - { - // Serializes this instance in the old serial form - // - ObjectOutputStream.PutField fields = out.putFields(); - fields.put("myTypeName", typeName); - fields.put("myRoleName2InfoMap", roleName2InfoMap); - fields.put("myIsInRelServFlg", isInRelationService); - out.writeFields(); - } - else - { - // Serializes this instance in the new serial form - // - out.defaultWriteObject(); - } + out.defaultWriteObject(); } } diff --git a/src/java.management/share/classes/javax/management/relation/Role.java b/src/java.management/share/classes/javax/management/relation/Role.java index 60accb2e007..431092a3b48 100644 --- a/src/java.management/share/classes/javax/management/relation/Role.java +++ b/src/java.management/share/classes/javax/management/relation/Role.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -51,62 +51,18 @@ import javax.management.ObjectName; * * @since 1.5 */ -@SuppressWarnings("serial") // serialVersionUID not constant public class Role implements Serializable { - // Serialization compatibility stuff: - // Two serial forms are supported in this class. The selected form depends - // on system property "jmx.serial.form": - // - "1.0" for JMX 1.0 - // - any other value for JMX 1.1 and higher - // - // Serial version for old serial form - private static final long oldSerialVersionUID = -1959486389343113026L; - // - // Serial version for new serial form - private static final long newSerialVersionUID = -279985518429862552L; - // - // Serializable fields in old serial form - private static final ObjectStreamField[] oldSerialPersistentFields = - { - new ObjectStreamField("myName", String.class), - new ObjectStreamField("myObjNameList", ArrayList.class) - }; - // - // Serializable fields in new serial form - private static final ObjectStreamField[] newSerialPersistentFields = - { - new ObjectStreamField("name", String.class), - new ObjectStreamField("objectNameList", List.class) - }; - // - // Actual serial version and serial form - private static final long serialVersionUID; + private static final long serialVersionUID = -279985518429862552L; /** * @serialField name String Role name * @serialField objectNameList List {@link List} of {@link ObjectName}s of referenced MBeans */ - private static final ObjectStreamField[] serialPersistentFields; - private static boolean compat = false; - static { - try { - GetPropertyAction act = new GetPropertyAction("jmx.serial.form"); - @SuppressWarnings("removal") - String form = AccessController.doPrivileged(act); - compat = (form != null && form.equals("1.0")); - } catch (Exception e) { - // OK : Too bad, no compat with 1.0 - } - if (compat) { - serialPersistentFields = oldSerialPersistentFields; - serialVersionUID = oldSerialVersionUID; - } else { - serialPersistentFields = newSerialPersistentFields; - serialVersionUID = newSerialVersionUID; - } - } - // - // END Serialization compatibility stuff + private static final ObjectStreamField[] serialPersistentFields = + { + new ObjectStreamField("name", String.class), + new ObjectStreamField("objectNameList", List.class) + }; // // Private members @@ -290,28 +246,7 @@ public class Role implements Serializable { */ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { - if (compat) - { - // Read an object serialized in the old serial form - // - ObjectInputStream.GetField fields = in.readFields(); - name = (String) fields.get("myName", null); - if (fields.defaulted("myName")) - { - throw new NullPointerException("myName"); - } - objectNameList = cast(fields.get("myObjNameList", null)); - if (fields.defaulted("myObjNameList")) - { - throw new NullPointerException("myObjNameList"); - } - } - else - { - // Read an object serialized in the new serial form - // - in.defaultReadObject(); - } + in.defaultReadObject(); } @@ -320,20 +255,6 @@ public class Role implements Serializable { */ private void writeObject(ObjectOutputStream out) throws IOException { - if (compat) - { - // Serializes this instance in the old serial form - // - ObjectOutputStream.PutField fields = out.putFields(); - fields.put("myName", name); - fields.put("myObjNameList", objectNameList); - out.writeFields(); - } - else - { - // Serializes this instance in the new serial form - // - out.defaultWriteObject(); - } + out.defaultWriteObject(); } } diff --git a/src/java.management/share/classes/javax/management/relation/RoleInfo.java b/src/java.management/share/classes/javax/management/relation/RoleInfo.java index 23258ce8c72..6f2926005e9 100644 --- a/src/java.management/share/classes/javax/management/relation/RoleInfo.java +++ b/src/java.management/share/classes/javax/management/relation/RoleInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,47 +46,9 @@ import javax.management.NotCompliantMBeanException; * * @since 1.5 */ -@SuppressWarnings("serial") // serialVersionUID not constant public class RoleInfo implements Serializable { - // Serialization compatibility stuff: - // Two serial forms are supported in this class. The selected form depends - // on system property "jmx.serial.form": - // - "1.0" for JMX 1.0 - // - any other value for JMX 1.1 and higher - // - // Serial version for old serial form - private static final long oldSerialVersionUID = 7227256952085334351L; - // - // Serial version for new serial form - private static final long newSerialVersionUID = 2504952983494636987L; - // - // Serializable fields in old serial form - private static final ObjectStreamField[] oldSerialPersistentFields = - { - new ObjectStreamField("myName", String.class), - new ObjectStreamField("myIsReadableFlg", boolean.class), - new ObjectStreamField("myIsWritableFlg", boolean.class), - new ObjectStreamField("myDescription", String.class), - new ObjectStreamField("myMinDegree", int.class), - new ObjectStreamField("myMaxDegree", int.class), - new ObjectStreamField("myRefMBeanClassName", String.class) - }; - // - // Serializable fields in new serial form - private static final ObjectStreamField[] newSerialPersistentFields = - { - new ObjectStreamField("name", String.class), - new ObjectStreamField("isReadable", boolean.class), - new ObjectStreamField("isWritable", boolean.class), - new ObjectStreamField("description", String.class), - new ObjectStreamField("minDegree", int.class), - new ObjectStreamField("maxDegree", int.class), - new ObjectStreamField("referencedMBeanClassName", String.class) - }; - // - // Actual serial version and serial form - private static final long serialVersionUID; + private static final long serialVersionUID = 2504952983494636987L; /** * @serialField name String Role name * @serialField isReadable boolean Read access mode: {@code true} if role is readable @@ -96,27 +58,16 @@ public class RoleInfo implements Serializable { * @serialField maxDegree int Maximum degree (i.e. maximum number of referenced MBeans in corresponding role) * @serialField referencedMBeanClassName String Name of class of MBean(s) expected to be referenced in corresponding role */ - private static final ObjectStreamField[] serialPersistentFields; - private static boolean compat = false; - static { - try { - GetPropertyAction act = new GetPropertyAction("jmx.serial.form"); - @SuppressWarnings("removal") - String form = AccessController.doPrivileged(act); - compat = (form != null && form.equals("1.0")); - } catch (Exception e) { - // OK : Too bad, no compat with 1.0 - } - if (compat) { - serialPersistentFields = oldSerialPersistentFields; - serialVersionUID = oldSerialVersionUID; - } else { - serialPersistentFields = newSerialPersistentFields; - serialVersionUID = newSerialVersionUID; - } - } - // - // END Serialization compatibility stuff + private static final ObjectStreamField[] serialPersistentFields = + { + new ObjectStreamField("name", String.class), + new ObjectStreamField("isReadable", boolean.class), + new ObjectStreamField("isWritable", boolean.class), + new ObjectStreamField("description", String.class), + new ObjectStreamField("minDegree", int.class), + new ObjectStreamField("maxDegree", int.class), + new ObjectStreamField("referencedMBeanClassName", String.class) + }; // // Public constants @@ -530,53 +481,7 @@ public class RoleInfo implements Serializable { */ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { - if (compat) - { - // Read an object serialized in the old serial form - // - ObjectInputStream.GetField fields = in.readFields(); - name = (String) fields.get("myName", null); - if (fields.defaulted("myName")) - { - throw new NullPointerException("myName"); - } - isReadable = fields.get("myIsReadableFlg", false); - if (fields.defaulted("myIsReadableFlg")) - { - throw new NullPointerException("myIsReadableFlg"); - } - isWritable = fields.get("myIsWritableFlg", false); - if (fields.defaulted("myIsWritableFlg")) - { - throw new NullPointerException("myIsWritableFlg"); - } - description = (String) fields.get("myDescription", null); - if (fields.defaulted("myDescription")) - { - throw new NullPointerException("myDescription"); - } - minDegree = fields.get("myMinDegree", 0); - if (fields.defaulted("myMinDegree")) - { - throw new NullPointerException("myMinDegree"); - } - maxDegree = fields.get("myMaxDegree", 0); - if (fields.defaulted("myMaxDegree")) - { - throw new NullPointerException("myMaxDegree"); - } - referencedMBeanClassName = (String) fields.get("myRefMBeanClassName", null); - if (fields.defaulted("myRefMBeanClassName")) - { - throw new NullPointerException("myRefMBeanClassName"); - } - } - else - { - // Read an object serialized in the new serial form - // - in.defaultReadObject(); - } + in.defaultReadObject(); } @@ -585,26 +490,7 @@ public class RoleInfo implements Serializable { */ private void writeObject(ObjectOutputStream out) throws IOException { - if (compat) - { - // Serializes this instance in the old serial form - // - ObjectOutputStream.PutField fields = out.putFields(); - fields.put("myName", name); - fields.put("myIsReadableFlg", isReadable); - fields.put("myIsWritableFlg", isWritable); - fields.put("myDescription", description); - fields.put("myMinDegree", minDegree); - fields.put("myMaxDegree", maxDegree); - fields.put("myRefMBeanClassName", referencedMBeanClassName); - out.writeFields(); - } - else - { - // Serializes this instance in the new serial form - // - out.defaultWriteObject(); - } + out.defaultWriteObject(); } } diff --git a/src/java.management/share/classes/javax/management/relation/RoleResult.java b/src/java.management/share/classes/javax/management/relation/RoleResult.java index 60836c897e5..7f98a7f7a24 100644 --- a/src/java.management/share/classes/javax/management/relation/RoleResult.java +++ b/src/java.management/share/classes/javax/management/relation/RoleResult.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,62 +44,18 @@ import java.security.AccessController; * * @since 1.5 */ -@SuppressWarnings("serial") public class RoleResult implements Serializable { - // Serialization compatibility stuff: - // Two serial forms are supported in this class. The selected form depends - // on system property "jmx.serial.form": - // - "1.0" for JMX 1.0 - // - any other value for JMX 1.1 and higher - // - // Serial version for old serial form - private static final long oldSerialVersionUID = 3786616013762091099L; - // - // Serial version for new serial form - private static final long newSerialVersionUID = -6304063118040985512L; - // - // Serializable fields in old serial form - private static final ObjectStreamField[] oldSerialPersistentFields = - { - new ObjectStreamField("myRoleList", RoleList.class), - new ObjectStreamField("myRoleUnresList", RoleUnresolvedList.class) - }; - // - // Serializable fields in new serial form - private static final ObjectStreamField[] newSerialPersistentFields = - { - new ObjectStreamField("roleList", RoleList.class), - new ObjectStreamField("unresolvedRoleList", RoleUnresolvedList.class) - }; - // - // Actual serial version and serial form - private static final long serialVersionUID; + private static final long serialVersionUID = -6304063118040985512L; /** * @serialField roleList RoleList List of roles successfully accessed * @serialField unresolvedRoleList RoleUnresolvedList List of roles unsuccessfully accessed */ - private static final ObjectStreamField[] serialPersistentFields; - private static boolean compat = false; - static { - try { - GetPropertyAction act = new GetPropertyAction("jmx.serial.form"); - @SuppressWarnings("removal") - String form = AccessController.doPrivileged(act); - compat = (form != null && form.equals("1.0")); - } catch (Exception e) { - // OK : Too bad, no compat with 1.0 - } - if (compat) { - serialPersistentFields = oldSerialPersistentFields; - serialVersionUID = oldSerialVersionUID; - } else { - serialPersistentFields = newSerialPersistentFields; - serialVersionUID = newSerialVersionUID; - } - } - // - // END Serialization compatibility stuff + private static final ObjectStreamField[] serialPersistentFields = + { + new ObjectStreamField("roleList", RoleList.class), + new ObjectStreamField("unresolvedRoleList", RoleUnresolvedList.class) + }; // // Private members @@ -206,28 +162,7 @@ public class RoleResult implements Serializable { */ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { - if (compat) - { - // Read an object serialized in the old serial form - // - ObjectInputStream.GetField fields = in.readFields(); - roleList = (RoleList) fields.get("myRoleList", null); - if (fields.defaulted("myRoleList")) - { - throw new NullPointerException("myRoleList"); - } - unresolvedRoleList = (RoleUnresolvedList) fields.get("myRoleUnresList", null); - if (fields.defaulted("myRoleUnresList")) - { - throw new NullPointerException("myRoleUnresList"); - } - } - else - { - // Read an object serialized in the new serial form - // - in.defaultReadObject(); - } + in.defaultReadObject(); } @@ -236,20 +171,6 @@ public class RoleResult implements Serializable { */ private void writeObject(ObjectOutputStream out) throws IOException { - if (compat) - { - // Serializes this instance in the old serial form - // - ObjectOutputStream.PutField fields = out.putFields(); - fields.put("myRoleList", roleList); - fields.put("myRoleUnresList", unresolvedRoleList); - out.writeFields(); - } - else - { - // Serializes this instance in the new serial form - // - out.defaultWriteObject(); - } + out.defaultWriteObject(); } } diff --git a/src/java.management/share/classes/javax/management/relation/RoleUnresolved.java b/src/java.management/share/classes/javax/management/relation/RoleUnresolved.java index 169b1263fdb..36b6dff9d71 100644 --- a/src/java.management/share/classes/javax/management/relation/RoleUnresolved.java +++ b/src/java.management/share/classes/javax/management/relation/RoleUnresolved.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -52,64 +52,19 @@ import javax.management.ObjectName; * * @since 1.5 */ -@SuppressWarnings("serial") // serialVersionUID not constant public class RoleUnresolved implements Serializable { - // Serialization compatibility stuff: - // Two serial forms are supported in this class. The selected form depends - // on system property "jmx.serial.form": - // - "1.0" for JMX 1.0 - // - any other value for JMX 1.1 and higher - // - // Serial version for old serial form - private static final long oldSerialVersionUID = -9026457686611660144L; - // - // Serial version for new serial form - private static final long newSerialVersionUID = -48350262537070138L; - // - // Serializable fields in old serial form - private static final ObjectStreamField[] oldSerialPersistentFields = - { - new ObjectStreamField("myRoleName", String.class), - new ObjectStreamField("myRoleValue", ArrayList.class), - new ObjectStreamField("myPbType", int.class) - }; - // - // Serializable fields in new serial form - private static final ObjectStreamField[] newSerialPersistentFields = + private static final long serialVersionUID = -48350262537070138L; + /** @serialField roleName String Role name + * @serialField roleValue List Role value ({@link List} of {@link ObjectName} objects) + * @serialField problemType int Problem type + */ + private static final ObjectStreamField[] serialPersistentFields = { new ObjectStreamField("roleName", String.class), new ObjectStreamField("roleValue", List.class), new ObjectStreamField("problemType", int.class) }; - // - // Actual serial version and serial form - private static final long serialVersionUID; - /** @serialField roleName String Role name - * @serialField roleValue List Role value ({@link List} of {@link ObjectName} objects) - * @serialField problemType int Problem type - */ - private static final ObjectStreamField[] serialPersistentFields; - private static boolean compat = false; - static { - try { - GetPropertyAction act = new GetPropertyAction("jmx.serial.form"); - @SuppressWarnings("removal") - String form = AccessController.doPrivileged(act); - compat = (form != null && form.equals("1.0")); - } catch (Exception e) { - // OK : Too bad, no compat with 1.0 - } - if (compat) { - serialPersistentFields = oldSerialPersistentFields; - serialVersionUID = oldSerialVersionUID; - } else { - serialPersistentFields = newSerialPersistentFields; - serialVersionUID = newSerialVersionUID; - } - } - // - // END Serialization compatibility stuff // // Private members @@ -304,33 +259,7 @@ public class RoleUnresolved implements Serializable { */ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { - if (compat) - { - // Read an object serialized in the old serial form - // - ObjectInputStream.GetField fields = in.readFields(); - roleName = (String) fields.get("myRoleName", null); - if (fields.defaulted("myRoleName")) - { - throw new NullPointerException("myRoleName"); - } - roleValue = cast(fields.get("myRoleValue", null)); - if (fields.defaulted("myRoleValue")) - { - throw new NullPointerException("myRoleValue"); - } - problemType = fields.get("myPbType", 0); - if (fields.defaulted("myPbType")) - { - throw new NullPointerException("myPbType"); - } - } - else - { - // Read an object serialized in the new serial form - // - in.defaultReadObject(); - } + in.defaultReadObject(); } @@ -339,21 +268,6 @@ public class RoleUnresolved implements Serializable { */ private void writeObject(ObjectOutputStream out) throws IOException { - if (compat) - { - // Serializes this instance in the old serial form - // - ObjectOutputStream.PutField fields = out.putFields(); - fields.put("myRoleName", roleName); - fields.put("myRoleValue", roleValue); - fields.put("myPbType", problemType); - out.writeFields(); - } - else - { - // Serializes this instance in the new serial form - // - out.defaultWriteObject(); - } + out.defaultWriteObject(); } } diff --git a/src/java.prefs/macosx/native/libprefs/MacOSXPreferencesFile.m b/src/java.prefs/macosx/native/libprefs/MacOSXPreferencesFile.m index eb2338ca944..bc3d9aaf682 100644 --- a/src/java.prefs/macosx/native/libprefs/MacOSXPreferencesFile.m +++ b/src/java.prefs/macosx/native/libprefs/MacOSXPreferencesFile.m @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -83,7 +83,7 @@ static void throwOutOfMemoryError(JNIEnv *env, const char *msg) c = exceptionClass; } else { c = (*env)->FindClass(env, "java/lang/OutOfMemoryError"); - if ((*env)->ExceptionOccurred(env)) return; + if ((*env)->ExceptionCheck(env)) return; exceptionClass = (*env)->NewGlobalRef(env, c); } @@ -211,7 +211,7 @@ static jarray createJavaStringArray(JNIEnv *env, CFIndex count) c = stringClass; } else { c = (*env)->FindClass(env, "java/lang/String"); - if ((*env)->ExceptionOccurred(env)) return NULL; + if ((*env)->ExceptionCheck(env)) return NULL; stringClass = (*env)->NewGlobalRef(env, c); } @@ -892,7 +892,7 @@ Java_java_util_prefs_MacOSXPreferencesFile_getKeyFromNode result = NULL; } else { CFStringRef cfString = copyToCFString(env, value); - if ((*env)->ExceptionOccurred(env)) { + if ((*env)->ExceptionCheck(env)) { // memory error in copyToCFString result = NULL; } else if (cfString == NULL) { @@ -940,10 +940,10 @@ static void BuildJavaArrayFn(const void *key, const void *value, void *context) CFStringRef cfString = NULL; JNIEnv *env = args->env; - if ((*env)->ExceptionOccurred(env)) return; // already failed + if ((*env)->ExceptionCheck(env)) return; // already failed cfString = copyToCFString(env, propkey); - if ((*env)->ExceptionOccurred(env)) { + if ((*env)->ExceptionCheck(env)) { // memory error in copyToCFString } else if (!cfString) { // bogus value type in prefs file - no Java errors available @@ -960,9 +960,9 @@ static void BuildJavaArrayFn(const void *key, const void *value, void *context) } if (CFStringGetLength(cfString) <= 0) goto bad; // ignore empty javaString = toJavaString(env, cfString); - if ((*env)->ExceptionOccurred(env)) goto bad; + if ((*env)->ExceptionCheck(env)) goto bad; (*env)->SetObjectArrayElement(env, args->result,args->used,javaString); - if ((*env)->ExceptionOccurred(env)) goto bad; + if ((*env)->ExceptionCheck(env)) goto bad; args->used++; } @@ -1003,7 +1003,7 @@ static jarray getStringsForNode(JNIEnv *env, jobject klass, jobject jpath, args.used = 0; args.allowSlash = allowSlash; CFDictionaryApplyFunction(node, BuildJavaArrayFn, &args); - if (!(*env)->ExceptionOccurred(env)) { + if (!(*env)->ExceptionCheck(env)) { // array construction succeeded if (args.used < count) { // finished array is smaller than expected. diff --git a/src/java.prefs/unix/classes/java/util/prefs/FileSystemPreferences.java b/src/java.prefs/unix/classes/java/util/prefs/FileSystemPreferences.java index ed76ce57f94..5f0531c0ff7 100644 --- a/src/java.prefs/unix/classes/java/util/prefs/FileSystemPreferences.java +++ b/src/java.prefs/unix/classes/java/util/prefs/FileSystemPreferences.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -957,6 +957,8 @@ class FileSystemPreferences extends AbstractPreferences { try { Thread.sleep(sleepTime); } catch(InterruptedException e) { + // Don't lose the interrupt. + Thread.currentThread().interrupt(); checkLockFile0ErrorCode(errorCode); return false; } diff --git a/src/java.security.jgss/macosx/native/libosxkrb5/SCDynamicStoreConfig.m b/src/java.security.jgss/macosx/native/libosxkrb5/SCDynamicStoreConfig.m index 11645d152cd..43cab418e17 100644 --- a/src/java.security.jgss/macosx/native/libosxkrb5/SCDynamicStoreConfig.m +++ b/src/java.security.jgss/macosx/native/libosxkrb5/SCDynamicStoreConfig.m @@ -51,7 +51,7 @@ void _SCDynamicStoreCallBack(SCDynamicStoreRef store, CFArrayRef changedKeys, vo jmethodID jm_Config_refresh = (*env)->GetStaticMethodID(env, jc_Config, "refresh", "()V"); CHECK_NULL(jm_Config_refresh); (*env)->CallStaticVoidMethod(env, jc_Config, jm_Config_refresh); - if ((*env)->ExceptionOccurred(env) != NULL) { + if ((*env)->ExceptionCheck(env)) { (*env)->ExceptionClear(env); } if (createdFromAttach) { diff --git a/src/java.security.jgss/windows/native/libw2k_lsa_auth/NativeCreds.c b/src/java.security.jgss/windows/native/libw2k_lsa_auth/NativeCreds.c index 221aaccbf2b..fe71f334617 100644 --- a/src/java.security.jgss/windows/native/libw2k_lsa_auth/NativeCreds.c +++ b/src/java.security.jgss/windows/native/libw2k_lsa_auth/NativeCreds.c @@ -877,13 +877,13 @@ jobject BuildTicket(JNIEnv *env, PUCHAR encodedTicket, ULONG encodedTicketSize) (*env)->SetByteArrayRegion(env, ary, (jsize) 0, encodedTicketSize, (jbyte *)encodedTicket); - if ((*env)->ExceptionOccurred(env)) { + if ((*env)->ExceptionCheck(env)) { (*env)->DeleteLocalRef(env, ary); return (jobject) NULL; } ticket = (*env)->NewObject(env, ticketClass, ticketConstructor, ary); - if ((*env)->ExceptionOccurred(env)) { + if ((*env)->ExceptionCheck(env)) { (*env)->DeleteLocalRef(env, ary); return (jobject) NULL; } @@ -993,7 +993,7 @@ jobject BuildEncryptionKey(JNIEnv *env, PKERB_CRYPTO_KEY cryptoKey) { } (*env)->SetByteArrayRegion(env, ary, (jsize) 0, cryptoKey->Length, (jbyte *)cryptoKey->Value); - if ((*env)->ExceptionOccurred(env)) { + if ((*env)->ExceptionCheck(env)) { (*env)->DeleteLocalRef(env, ary); } else { encryptionKey = (*env)->NewObject(env, encryptionKeyClass, @@ -1018,7 +1018,7 @@ jobject BuildTicketFlags(JNIEnv *env, PULONG flags) { } (*env)->SetByteArrayRegion(env, ary, (jsize) 0, sizeof(*flags), (jbyte *)&nlflags); - if ((*env)->ExceptionOccurred(env)) { + if ((*env)->ExceptionCheck(env)) { (*env)->DeleteLocalRef(env, ary); } else { ticketFlags = (*env)->NewObject(env, ticketFlagsClass, diff --git a/src/java.security.sasl/share/classes/com/sun/security/sasl/digest/DigestMD5Client.java b/src/java.security.sasl/share/classes/com/sun/security/sasl/digest/DigestMD5Client.java index 544c1945701..5535fdd41c9 100644 --- a/src/java.security.sasl/share/classes/com/sun/security/sasl/digest/DigestMD5Client.java +++ b/src/java.security.sasl/share/classes/com/sun/security/sasl/digest/DigestMD5Client.java @@ -144,7 +144,7 @@ final class DigestMD5Client extends DigestMD5Base implements SaslClient { * combined protocol and host being used for authentication. * @param props The possibly null properties to be used by the SASL * mechanism to configure the authentication exchange. - * @param cbh The non-null CallbackHanlder object for callbacks + * @param cbh The non-null CallbackHandler object for callbacks * @throws SaslException if no authentication ID or password is supplied */ DigestMD5Client(String authzid, String protocol, String serverName, diff --git a/src/jdk.attach/linux/classes/sun/tools/attach/VirtualMachineImpl.java b/src/jdk.attach/linux/classes/sun/tools/attach/VirtualMachineImpl.java index 4eb29482e29..35ce808c187 100644 --- a/src/jdk.attach/linux/classes/sun/tools/attach/VirtualMachineImpl.java +++ b/src/jdk.attach/linux/classes/sun/tools/attach/VirtualMachineImpl.java @@ -28,12 +28,13 @@ import com.sun.tools.attach.AgentLoadException; import com.sun.tools.attach.AttachNotSupportedException; import com.sun.tools.attach.spi.AttachProvider; -import java.io.InputStream; -import java.io.IOException; import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; -import java.nio.file.Files; +import java.util.Optional; import static java.nio.charset.StandardCharsets.UTF_8; @@ -47,13 +48,35 @@ public class VirtualMachineImpl extends HotSpotVirtualMachine { // location is the same for all processes, otherwise the tools // will not be able to find all Hotspot processes. // Any changes to this needs to be synchronized with HotSpot. - private static final String tmpdir = "/tmp"; + private static final Path TMPDIR = Path.of("/tmp"); + + private static final Path PROC = Path.of("/proc"); + private static final Path NS_MNT = Path.of("ns/mnt"); + private static final Path NS_PID = Path.of("ns/pid"); + private static final Path SELF = PROC.resolve("self"); + private static final Path STATUS = Path.of("status"); + private static final Path ROOT_TMP = Path.of("root/tmp"); + + private static final Optional SELF_MNT_NS; + + static { + Path nsPath = null; + + try { + nsPath = Files.readSymbolicLink(SELF.resolve(NS_MNT)); + } catch (IOException _) { + // do nothing + } finally { + SELF_MNT_NS = Optional.ofNullable(nsPath); + } + } + String socket_path; + /** * Attaches to the target VM */ - VirtualMachineImpl(AttachProvider provider, String vmid) - throws AttachNotSupportedException, IOException + VirtualMachineImpl(AttachProvider provider, String vmid) throws AttachNotSupportedException, IOException { super(provider, vmid); @@ -64,12 +87,12 @@ public class VirtualMachineImpl extends HotSpotVirtualMachine { } // Try to resolve to the "inner most" pid namespace - int ns_pid = getNamespacePid(pid); + final long ns_pid = getNamespacePid(pid); // Find the socket file. If not found then we attempt to start the // attach mechanism in the target VM by sending it a QUIT signal. // Then we attempt to find the socket file again. - File socket_file = findSocketFile(pid, ns_pid); + final File socket_file = findSocketFile(pid, ns_pid); socket_path = socket_file.getPath(); if (!socket_file.exists()) { // Keep canonical version of File, to delete, in case target process ends and /proc link has gone: @@ -211,49 +234,102 @@ public class VirtualMachineImpl extends HotSpotVirtualMachine { } // Return the socket file for the given process. - private File findSocketFile(int pid, int ns_pid) throws IOException { - String root = findTargetProcessTmpDirectory(pid, ns_pid); - return new File(root, ".java_pid" + ns_pid); + private File findSocketFile(long pid, long ns_pid) throws AttachNotSupportedException, IOException { + return new File(findTargetProcessTmpDirectory(pid, ns_pid), ".java_pid" + ns_pid); } // On Linux a simple handshake is used to start the attach mechanism // if not already started. The client creates a .attach_pid file in the // target VM's working directory (or temp directory), and the SIGQUIT handler // checks for the file. - private File createAttachFile(int pid, int ns_pid) throws IOException { - String fn = ".attach_pid" + ns_pid; - String path = "/proc/" + pid + "/cwd/" + fn; - File f = new File(path); + private File createAttachFile(long pid, long ns_pid) throws AttachNotSupportedException, IOException { + Path fn = Path.of(".attach_pid" + ns_pid); + Path path = PROC.resolve(Path.of(Long.toString(pid), "cwd")).resolve(fn); + File f = new File(path.toString()); try { // Do not canonicalize the file path, or we will fail to attach to a VM in a container. f.createNewFile(); - } catch (IOException x) { - String root = findTargetProcessTmpDirectory(pid, ns_pid); - f = new File(root, fn); + } catch (IOException _) { + f = new File(findTargetProcessTmpDirectory(pid, ns_pid), fn.toString()); f.createNewFile(); } return f; } - private String findTargetProcessTmpDirectory(int pid, int ns_pid) throws IOException { - String root; - if (pid != ns_pid) { - // A process may not exist in the same mount namespace as the caller, e.g. - // if we are trying to attach to a JVM process inside a container. - // Instead, attach relative to the target root filesystem as exposed by - // procfs regardless of namespaces. - String procRootDirectory = "/proc/" + pid + "/root"; - if (!Files.isReadable(Path.of(procRootDirectory))) { - throw new IOException( - String.format("Unable to access root directory %s " + - "of target process %d", procRootDirectory, pid)); + private String findTargetProcessTmpDirectory(long pid, long ns_pid) throws AttachNotSupportedException, IOException { + // We need to handle at least 4 different cases: + // 1. Caller and target processes share PID namespace and root filesystem (host to host or container to + // container with both /tmp mounted between containers). + // 2. Caller and target processes share PID namespace and root filesystem but the target process has elevated + // privileges (host to host). + // 3. Caller and target processes share PID namespace but NOT root filesystem (container to container). + // 4. Caller and target processes share neither PID namespace nor root filesystem (host to container). + + Optional target = ProcessHandle.of(pid); + Optional ph = target; + long nsPid = ns_pid; + Optional prevPidNS = Optional.empty(); + + while (ph.isPresent()) { + final var curPid = ph.get().pid(); + final var procPidPath = PROC.resolve(Long.toString(curPid)); + Optional targetMountNS = Optional.empty(); + + try { + // attempt to read the target's mnt ns id + targetMountNS = Optional.ofNullable(Files.readSymbolicLink(procPidPath.resolve(NS_MNT))); + } catch (IOException _) { + // if we fail to read the target's mnt ns id then we either don't have access or it no longer exists! + if (!Files.exists(procPidPath)) { + throw new IOException(String.format("unable to attach, %s non-existent! process: %d terminated", procPidPath, pid)); + } + // the process still exists, but we don't have privileges to read its procfs } - root = procRootDirectory + "/" + tmpdir; - } else { - root = tmpdir; + final var sameMountNS = SELF_MNT_NS.isPresent() && SELF_MNT_NS.equals(targetMountNS); + + if (sameMountNS) { + return TMPDIR.toString(); // we share TMPDIR in common! + } else { + // we could not read the target's mnt ns + final var procPidRootTmp = procPidPath.resolve(ROOT_TMP); + if (Files.isReadable(procPidRootTmp)) { + return procPidRootTmp.toString(); // not in the same mnt ns but tmp is accessible via /proc + } + } + + // let's attempt to obtain the pid ns, best efforts to avoid crossing pid ns boundaries (as with a container) + Optional curPidNS = Optional.empty(); + + try { + // attempt to read the target's pid ns id + curPidNS = Optional.ofNullable(Files.readSymbolicLink(procPidPath.resolve(NS_PID))); + } catch (IOException _) { + // if we fail to read the target's pid ns id then we either don't have access or it no longer exists! + if (!Files.exists(procPidPath)) { + throw new IOException(String.format("unable to attach, %s non-existent! process: %d terminated", procPidPath, pid)); + } + // the process still exists, but we don't have privileges to read its procfs + } + + // recurse "up" the process hierarchy if appropriate. PID 1 cannot have a parent in the same namespace + final var havePidNSes = prevPidNS.isPresent() && curPidNS.isPresent(); + final var ppid = ph.get().parent(); + + if (ppid.isPresent() && (havePidNSes && curPidNS.equals(prevPidNS)) || (!havePidNSes && nsPid > 1)) { + ph = ppid; + nsPid = getNamespacePid(ph.get().pid()); // get the ns pid of the parent + prevPidNS = curPidNS; + } else { + ph = Optional.empty(); + } + } + + if (target.orElseThrow(AttachNotSupportedException::new).isAlive()) { + return TMPDIR.toString(); // fallback... + } else { + throw new IOException(String.format("unable to attach, process: %d terminated", pid)); } - return root; } /* @@ -270,13 +346,12 @@ public class VirtualMachineImpl extends HotSpotVirtualMachine { write(fd, b, 0, 1); } - // Return the inner most namespaced PID if there is one, // otherwise return the original PID. - private int getNamespacePid(int pid) throws AttachNotSupportedException, IOException { + private long getNamespacePid(long pid) throws AttachNotSupportedException, IOException { // Assuming a real procfs sits beneath, reading this doesn't block // nor will it consume a lot of memory. - String statusFile = "/proc/" + pid + "/status"; + final var statusFile = PROC.resolve(Long.toString(pid)).resolve(STATUS).toString(); File f = new File(statusFile); if (!f.exists()) { return pid; // Likely a bad pid, but this is properly handled later. @@ -292,8 +367,7 @@ public class VirtualMachineImpl extends HotSpotVirtualMachine { // The last entry represents the PID the JVM "thinks" it is. // Even in non-namespaced pids these entries should be // valid. You could refer to it as the inner most pid. - int ns_pid = Integer.parseInt(parts[parts.length - 1]); - return ns_pid; + return Long.parseLong(parts[parts.length - 1]); } } // Old kernels may not have NSpid field (i.e. 3.10). diff --git a/src/jdk.attach/windows/native/libattach/VirtualMachineImpl.c b/src/jdk.attach/windows/native/libattach/VirtualMachineImpl.c index a8b17c22d83..74d0e7bf7d5 100644 --- a/src/jdk.attach/windows/native/libattach/VirtualMachineImpl.c +++ b/src/jdk.attach/windows/native/libattach/VirtualMachineImpl.c @@ -432,7 +432,7 @@ JNIEXPORT void JNICALL Java_sun_tools_attach_VirtualMachineImpl_enqueue return; } } - if ((*env)->ExceptionOccurred(env)) return; + if ((*env)->ExceptionCheck(env)) return; } } for (i = argsLen; i < MAX_ARGS; i++) { @@ -463,7 +463,7 @@ JNIEXPORT void JNICALL Java_sun_tools_attach_VirtualMachineImpl_enqueue stubLen = (DWORD)(*env)->GetArrayLength(env, stub); stubCode = (*env)->GetByteArrayElements(env, stub, &isCopy); - if ((*env)->ExceptionOccurred(env)) return; + if ((*env)->ExceptionCheck(env)) return; pCode = (PDWORD) VirtualAllocEx( hProcess, 0, stubLen, MEM_COMMIT, PAGE_EXECUTE_READWRITE ); if (pCode == NULL) { @@ -636,7 +636,7 @@ static jboolean jstring_to_cstring(JNIEnv* env, jstring jstr, char* cstr, size_t cstr[0] = '\0'; } else { str = JNU_GetStringPlatformChars(env, jstr, &isCopy); - if ((*env)->ExceptionOccurred(env)) { + if ((*env)->ExceptionCheck(env)) { return result; } if (strlen(str) >= cstr_buf_size) { diff --git a/src/jdk.compiler/share/classes/com/sun/source/tree/ClassTree.java b/src/jdk.compiler/share/classes/com/sun/source/tree/ClassTree.java index ee1f40dc196..ada07bb1bae 100644 --- a/src/jdk.compiler/share/classes/com/sun/source/tree/ClassTree.java +++ b/src/jdk.compiler/share/classes/com/sun/source/tree/ClassTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -43,10 +43,10 @@ import javax.lang.model.element.Name; * * * @jls 8.1 Class Declarations - * @jls 8.9 Enum Types - * @jls 8.10 Record Types + * @jls 8.9 Enum Classes + * @jls 8.10 Record Classes * @jls 9.1 Interface Declarations - * @jls 9.6 Annotation Types + * @jls 9.6 Annotation Interfaces * * @author Peter von der Ahé * @author Jonathan Gibbons diff --git a/src/jdk.compiler/share/classes/com/sun/source/tree/InstanceOfTree.java b/src/jdk.compiler/share/classes/com/sun/source/tree/InstanceOfTree.java index f5bede70539..f752f7f3191 100644 --- a/src/jdk.compiler/share/classes/com/sun/source/tree/InstanceOfTree.java +++ b/src/jdk.compiler/share/classes/com/sun/source/tree/InstanceOfTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ package com.sun.source.tree; * expression instanceof type * * - * @jls 15.20.2 Type Comparison Operator instanceof + * @jls 15.20.2 The instanceof Operator * * @author Peter von der Ahé * @author Jonathan Gibbons diff --git a/src/jdk.compiler/share/classes/com/sun/source/tree/LiteralTree.java b/src/jdk.compiler/share/classes/com/sun/source/tree/LiteralTree.java index 622e4588703..8899e3699b6 100644 --- a/src/jdk.compiler/share/classes/com/sun/source/tree/LiteralTree.java +++ b/src/jdk.compiler/share/classes/com/sun/source/tree/LiteralTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,7 @@ package com.sun.source.tree; * value * * - * @jls 15.28 Constant Expressions + * @jls 15.29 Constant Expressions * * @author Peter von der Ahé * @author Jonathan Gibbons diff --git a/src/jdk.compiler/share/classes/com/sun/source/tree/MethodTree.java b/src/jdk.compiler/share/classes/com/sun/source/tree/MethodTree.java index f6dae4c3ced..9215da58772 100644 --- a/src/jdk.compiler/share/classes/com/sun/source/tree/MethodTree.java +++ b/src/jdk.compiler/share/classes/com/sun/source/tree/MethodTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,7 +44,7 @@ import javax.lang.model.element.Name; * @jls 8.6 Instance Initializers * @jls 8.7 Static Initializers * @jls 9.4 Method Declarations - * @jls 9.6.1 Annotation Type Elements + * @jls 9.6.1 Annotation Interface Elements * * @author Peter von der Ahé * @author Jonathan Gibbons diff --git a/src/jdk.compiler/share/classes/com/sun/source/tree/ModifiersTree.java b/src/jdk.compiler/share/classes/com/sun/source/tree/ModifiersTree.java index a193d4516e3..dbb2e5e2183 100644 --- a/src/jdk.compiler/share/classes/com/sun/source/tree/ModifiersTree.java +++ b/src/jdk.compiler/share/classes/com/sun/source/tree/ModifiersTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,9 +40,9 @@ import javax.lang.model.element.Modifier; * * * @jls 8.1.1 Class Modifiers + * @jls 8.1.3 Inner Classes and Enclosing Instances * @jls 8.3.1 Field Modifiers * @jls 8.4.3 Method Modifiers - * @jls 8.5.1 Static Member Type Declarations * @jls 8.8.3 Constructor Modifiers * @jls 9.1.1 Interface Modifiers * @jls 9.7 Annotations diff --git a/src/jdk.compiler/share/classes/com/sun/source/tree/StatementTree.java b/src/jdk.compiler/share/classes/com/sun/source/tree/StatementTree.java index d3c4b252473..9c103505fba 100644 --- a/src/jdk.compiler/share/classes/com/sun/source/tree/StatementTree.java +++ b/src/jdk.compiler/share/classes/com/sun/source/tree/StatementTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,7 +29,7 @@ package com.sun.source.tree; * A tree node used as the base class for the different kinds of * statements. * - * @jls 14 Blocks and Statements + * @jls 14 Blocks, Statements, and Patterns * * @author Peter von der Ahé * @author Jonathan Gibbons diff --git a/src/jdk.compiler/share/classes/com/sun/source/tree/SwitchExpressionTree.java b/src/jdk.compiler/share/classes/com/sun/source/tree/SwitchExpressionTree.java index 2327c7a3f49..35129667946 100644 --- a/src/jdk.compiler/share/classes/com/sun/source/tree/SwitchExpressionTree.java +++ b/src/jdk.compiler/share/classes/com/sun/source/tree/SwitchExpressionTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,7 @@ import java.util.List; * } * * - * @jls 15.29 Switch Expressions + * @jls 15.28 {@code switch} Expressions * * @since 14 */ diff --git a/src/jdk.compiler/share/classes/com/sun/source/tree/VariableTree.java b/src/jdk.compiler/share/classes/com/sun/source/tree/VariableTree.java index d63fa308e3b..a1191b2f8e6 100644 --- a/src/jdk.compiler/share/classes/com/sun/source/tree/VariableTree.java +++ b/src/jdk.compiler/share/classes/com/sun/source/tree/VariableTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,7 @@ import javax.lang.model.element.Name; * * * @jls 8.3 Field Declarations - * @jls 14.4 Local Variable Declaration Statements + * @jls 14.4 Local Variable Declarations * * @author Peter von der Ahé * @author Jonathan Gibbons diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Flags.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Flags.java index 346aab18a60..a2937b73a14 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Flags.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Flags.java @@ -285,7 +285,12 @@ public class Flags { /** * Flag that marks a synthetic method body for a lambda expression */ - public static final long LAMBDA_METHOD = 1L<<49; + public static final long LAMBDA_METHOD = 1L<<49; //MethodSymbols only + + /** + * Flag that marks a synthetic local capture field in a local/anon class + */ + public static final long LOCAL_CAPTURE_FIELD = 1L<<49; //VarSymbols only /** * Flag to control recursion in TransTypes diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java index 4e62828c426..cee6a16a10f 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java @@ -420,6 +420,23 @@ public class Symtab { missingInfoHandler, target.runtimeUseNestAccess()); + noModule = new ModuleSymbol(names.empty, null) { + @Override public boolean isNoModule() { + return true; + } + }; + addRootPackageFor(noModule); + + Source source = Source.instance(context); + if (Feature.MODULES.allowedInSource(source)) { + java_base = enterModule(names.java_base); + //avoid completing java.base during the Symtab initialization + java_base.completer = Completer.NULL_COMPLETER; + java_base.visiblePackages = Collections.emptyMap(); + } else { + java_base = noModule; + } + // create the basic builtin symbols unnamedModule = new ModuleSymbol(names.empty, null) { { @@ -427,7 +444,6 @@ public class Symtab { exports = List.nil(); provides = List.nil(); uses = List.nil(); - ModuleSymbol java_base = enterModule(names.java_base); com.sun.tools.javac.code.Directive.RequiresDirective d = new com.sun.tools.javac.code.Directive.RequiresDirective(java_base, EnumSet.of(com.sun.tools.javac.code.Directive.RequiresFlag.MANDATED)); @@ -447,7 +463,6 @@ public class Symtab { exports = List.nil(); provides = List.nil(); uses = List.nil(); - ModuleSymbol java_base = enterModule(names.java_base); com.sun.tools.javac.code.Directive.RequiresDirective d = new com.sun.tools.javac.code.Directive.RequiresDirective(java_base, EnumSet.of(com.sun.tools.javac.code.Directive.RequiresFlag.MANDATED)); @@ -456,13 +471,6 @@ public class Symtab { }; addRootPackageFor(errModule); - noModule = new ModuleSymbol(names.empty, null) { - @Override public boolean isNoModule() { - return true; - } - }; - addRootPackageFor(noModule); - noSymbol = new TypeSymbol(NIL, 0, names.empty, Type.noType, rootPackage) { @Override @DefinedBy(Api.LANGUAGE_MODEL) public R accept(ElementVisitor v, P p) { @@ -526,16 +534,6 @@ public class Symtab { // Enter symbol for the errSymbol scope.enter(errSymbol); - Source source = Source.instance(context); - if (Feature.MODULES.allowedInSource(source)) { - java_base = enterModule(names.java_base); - //avoid completing java.base during the Symtab initialization - java_base.completer = Completer.NULL_COMPLETER; - java_base.visiblePackages = Collections.emptyMap(); - } else { - java_base = noModule; - } - // Get the initial completer for ModuleSymbols from Modules moduleCompleter = Modules.instance(context).getCompleter(); diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java index 44ccbade4a9..07a136c1700 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java @@ -182,6 +182,7 @@ public class Attr extends JCTree.Visitor { unknownTypeInfo = new ResultInfo(KindSelector.TYP, Type.noType); unknownTypeExprInfo = new ResultInfo(KindSelector.VAL_TYP, Type.noType); recoveryInfo = new RecoveryInfo(deferredAttr.emptyDeferredAttrContext); + initBlockType = new MethodType(List.nil(), syms.voidType, List.nil(), syms.methodClass); } /** Switch: reifiable types in instanceof enabled? @@ -628,6 +629,7 @@ public class Attr extends JCTree.Visitor { final ResultInfo unknownTypeInfo; final ResultInfo unknownTypeExprInfo; final ResultInfo recoveryInfo; + final MethodType initBlockType; Type pt() { return resultInfo.pt; @@ -1421,7 +1423,7 @@ public class Attr extends JCTree.Visitor { // created BLOCK-method. Symbol fakeOwner = new MethodSymbol(tree.flags | BLOCK | - env.info.scope.owner.flags() & STRICTFP, names.empty, null, + env.info.scope.owner.flags() & STRICTFP, names.empty, initBlockType, env.info.scope.owner); final Env localEnv = env.dup(tree, env.info.dup(env.info.scope.dupUnshared(fakeOwner))); @@ -3524,62 +3526,26 @@ public class Attr extends JCTree.Visitor { } } - /* Map to hold 'fake' clinit methods. If a lambda is used to initialize a - * static field and that lambda has type annotations, these annotations will - * also be stored at these fake clinit methods. - * - * LambdaToMethod also use fake clinit methods so they can be reused. - * Also as LTM is a phase subsequent to attribution, the methods from - * clinits can be safely removed by LTM to save memory. - */ - private Map clinits = new HashMap<>(); - - public MethodSymbol removeClinit(ClassSymbol sym) { - return clinits.remove(sym); - } - /* This method returns an environment to be used to attribute a lambda * expression. * * The owner of this environment is a method symbol. If the current owner - * is not a method, for example if the lambda is used to initialize - * a field, then if the field is: - * - * - an instance field, we use the first constructor. - * - a static field, we create a fake clinit method. + * is not a method (e.g. if the lambda occurs in a field initializer), then + * a synthetic method symbol owner is created. */ public Env lambdaEnv(JCLambda that, Env env) { Env lambdaEnv; Symbol owner = env.info.scope.owner; if (owner.kind == VAR && owner.owner.kind == TYP) { - //field initializer + // If the lambda is nested in a field initializer, we need to create a fake init method. + // Uniqueness of this symbol is not important (as e.g. annotations will be added on the + // init symbol's owner). ClassSymbol enclClass = owner.enclClass(); - Symbol newScopeOwner = env.info.scope.owner; - /* if the field isn't static, then we can get the first constructor - * and use it as the owner of the environment. This is what - * LTM code is doing to look for type annotations so we are fine. - */ - if ((owner.flags() & STATIC) == 0) { - for (Symbol s : enclClass.members_field.getSymbolsByName(names.init)) { - newScopeOwner = s; - break; - } - } else { - /* if the field is static then we need to create a fake clinit - * method, this method can later be reused by LTM. - */ - MethodSymbol clinit = clinits.get(enclClass); - if (clinit == null) { - Type clinitType = new MethodType(List.nil(), - syms.voidType, List.nil(), syms.methodClass); - clinit = new MethodSymbol(STATIC | SYNTHETIC | PRIVATE, - names.clinit, clinitType, enclClass); - clinit.params = List.nil(); - clinits.put(enclClass, clinit); - } - newScopeOwner = clinit; - } - lambdaEnv = env.dup(that, env.info.dup(env.info.scope.dupUnshared(newScopeOwner))); + Name initName = owner.isStatic() ? names.clinit : names.init; + MethodSymbol initSym = new MethodSymbol(BLOCK | (owner.isStatic() ? STATIC : 0) | SYNTHETIC | PRIVATE, + initName, initBlockType, enclClass); + initSym.params = List.nil(); + lambdaEnv = env.dup(that, env.info.dup(env.info.scope.dupUnshared(initSym))); } else { lambdaEnv = env.dup(that, env.info.dup(env.info.scope.dup())); } @@ -3936,6 +3902,7 @@ public class Attr extends JCTree.Visitor { inferenceContext -> setFunctionalInfo(env, fExpr, pt, inferenceContext.asInstType(descriptorType), inferenceContext.asInstType(primaryTarget), checkContext)); } else { + fExpr.owner = env.info.scope.owner; if (pt.hasTag(CLASS)) { fExpr.target = primaryTarget; } diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/CaptureScanner.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/CaptureScanner.java new file mode 100644 index 00000000000..ef8a3ff584d --- /dev/null +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/CaptureScanner.java @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +package com.sun.tools.javac.comp; + +import com.sun.tools.javac.code.Symbol; +import com.sun.tools.javac.code.Symbol.VarSymbol; +import com.sun.tools.javac.tree.JCTree; +import com.sun.tools.javac.tree.TreeScanner; +import com.sun.tools.javac.util.List; + +import java.util.HashSet; +import java.util.LinkedHashSet; +import java.util.SequencedSet; +import java.util.Set; + +import static com.sun.tools.javac.code.Kinds.Kind.MTH; +import static com.sun.tools.javac.code.Kinds.Kind.VAR; + +/** + * A visitor which collects the set of local variables "captured" by a given tree. + */ +public class CaptureScanner extends TreeScanner { + + /** + * The tree under analysis. + */ + private final JCTree tree; + + /** + * The set of local variable declarations encountered in the tree under analysis. + */ + private final Set seenVars = new HashSet<>(); + + /** + * The set of captured local variables accessed from within the tree under analysis. + */ + private final SequencedSet fvs = new LinkedHashSet<>(); + + public CaptureScanner(JCTree ownerTree) { + this.tree = ownerTree; + } + + @Override + public void visitIdent(JCTree.JCIdent tree) { + Symbol sym = tree.sym; + if (sym.kind == VAR && sym.owner.kind == MTH) { + Symbol.VarSymbol vsym = (Symbol.VarSymbol) sym; + if (vsym.getConstValue() == null && !seenVars.contains(vsym)) { + addFreeVar(vsym); + } + } + } + + /** + * Add free variable to fvs list unless it is already there. + */ + protected void addFreeVar(Symbol.VarSymbol v) { + fvs.add(v); + } + + @Override + public void visitVarDef(JCTree.JCVariableDecl tree) { + if (tree.sym.owner.kind == MTH) { + seenVars.add(tree.sym); + } + super.visitVarDef(tree); + } + + /** + * Obtains the list of captured local variables in the tree under analysis. + */ + List analyzeCaptures() { + scan(tree); + return List.from(fvs); + } +} diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java index 792b5ca2346..29ab8435ada 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java @@ -827,30 +827,33 @@ public class Flow { } } Set patterns = patternSet; - boolean genericPatternsExpanded = false; + boolean useHashes = true; try { boolean repeat = true; while (repeat) { Set updatedPatterns; updatedPatterns = reduceBindingPatterns(selector.type, patterns); - updatedPatterns = reduceNestedPatterns(updatedPatterns); + updatedPatterns = reduceNestedPatterns(updatedPatterns, useHashes); updatedPatterns = reduceRecordPatterns(updatedPatterns); updatedPatterns = removeCoveredRecordPatterns(updatedPatterns); repeat = !updatedPatterns.equals(patterns); if (checkCovered(selector.type, patterns)) { return true; } - if (!repeat && !genericPatternsExpanded) { + if (!repeat) { //there may be situation like: - //class B extends S1, S2 + //class B permits S1, S2 //patterns: R(S1, B), R(S2, S2) - //this should be joined to R(B, S2), + //this might be joined to R(B, S2), as B could be rewritten to S2 //but hashing in reduceNestedPatterns will not allow that - //attempt to once expand all types to their transitive permitted types, - //on all depth of nesting: - updatedPatterns = expandGenericPatterns(updatedPatterns); - genericPatternsExpanded = true; - repeat = !updatedPatterns.equals(patterns); + //disable the use of hashing, and use subtyping in + //reduceNestedPatterns to handle situations like this: + repeat = useHashes; + useHashes = false; + } else { + //if a reduction happened, make sure hashing in reduceNestedPatterns + //is enabled, as the hashing speeds up the process significantly: + useHashes = true; } patterns = updatedPatterns; } @@ -1023,8 +1026,15 @@ public class Flow { * simplify the pattern. If that succeeds, the original found sub-set * of patterns is replaced with a new set of patterns of the form: * $record($prefix$, $resultOfReduction, $suffix$) + * + * useHashes: when true, patterns will be subject to exact equivalence; + * when false, two binding patterns will be considered equivalent + * if one of them is more generic than the other one; + * when false, the processing will be significantly slower, + * as pattern hashes cannot be used to speed up the matching process */ - private Set reduceNestedPatterns(Set patterns) { + private Set reduceNestedPatterns(Set patterns, + boolean useHashes) { /* implementation note: * finding a sub-set of patterns that only differ in a single * column is time-consuming task, so this method speeds it up by: @@ -1049,13 +1059,13 @@ public class Flow { mismatchingCandidate < nestedPatternsCount; mismatchingCandidate++) { int mismatchingCandidateFin = mismatchingCandidate; - var groupByHashes = + var groupEquivalenceCandidates = current .stream() //error recovery, ignore patterns with incorrect number of nested patterns: .filter(pd -> pd.nested.length == nestedPatternsCount) - .collect(groupingBy(pd -> pd.hashCode(mismatchingCandidateFin))); - for (var candidates : groupByHashes.values()) { + .collect(groupingBy(pd -> useHashes ? pd.hashCode(mismatchingCandidateFin) : 0)); + for (var candidates : groupEquivalenceCandidates.values()) { var candidatesArr = candidates.toArray(RecordPattern[]::new); for (int firstCandidate = 0; @@ -1076,9 +1086,18 @@ public class Flow { RecordPattern rpOther = candidatesArr[nextCandidate]; if (rpOne.recordType.tsym == rpOther.recordType.tsym) { for (int i = 0; i < rpOne.nested.length; i++) { - if (i != mismatchingCandidate && - !rpOne.nested[i].equals(rpOther.nested[i])) { - continue NEXT_PATTERN; + if (i != mismatchingCandidate) { + if (!rpOne.nested[i].equals(rpOther.nested[i])) { + if (useHashes || + //when not using hashes, + //check if rpOne.nested[i] is + //a subtype of rpOther.nested[i]: + !(rpOne.nested[i] instanceof BindingPattern bpOne) || + !(rpOther.nested[i] instanceof BindingPattern bpOther) || + !types.isSubtype(types.erasure(bpOne.type), types.erasure(bpOther.type))) { + continue NEXT_PATTERN; + } + } } } join.append(rpOther); @@ -1086,14 +1105,16 @@ public class Flow { } var nestedPatterns = join.stream().map(rp -> rp.nested[mismatchingCandidateFin]).collect(Collectors.toSet()); - var updatedPatterns = reduceNestedPatterns(nestedPatterns); + var updatedPatterns = reduceNestedPatterns(nestedPatterns, useHashes); updatedPatterns = reduceRecordPatterns(updatedPatterns); updatedPatterns = removeCoveredRecordPatterns(updatedPatterns); updatedPatterns = reduceBindingPatterns(rpOne.fullComponentTypes()[mismatchingCandidateFin], updatedPatterns); if (!nestedPatterns.equals(updatedPatterns)) { - current.removeAll(join); + if (useHashes) { + current.removeAll(join); + } for (PatternDescription nested : updatedPatterns) { PatternDescription[] newNested = @@ -1169,40 +1190,6 @@ public class Flow { return pattern; } - private Set expandGenericPatterns(Set patterns) { - var newPatterns = new HashSet(patterns); - boolean modified; - do { - modified = false; - for (PatternDescription pd : patterns) { - if (pd instanceof RecordPattern rpOne) { - for (int i = 0; i < rpOne.nested.length; i++) { - Set toExpand = Set.of(rpOne.nested[i]); - Set expanded = expandGenericPatterns(toExpand); - if (expanded != toExpand) { - expanded.removeAll(toExpand); - for (PatternDescription exp : expanded) { - PatternDescription[] newNested = Arrays.copyOf(rpOne.nested, rpOne.nested.length); - newNested[i] = exp; - modified |= newPatterns.add(new RecordPattern(rpOne.recordType(), rpOne.fullComponentTypes(), newNested)); - } - } - } - } else if (pd instanceof BindingPattern bp) { - Set permittedSymbols = allPermittedSubTypes(bp.type.tsym, cs -> true); - - if (!permittedSymbols.isEmpty()) { - for (Symbol permitted : permittedSymbols) { - //TODO infer.instantiatePatternType(selectorType, csym); (?) - modified |= newPatterns.add(new BindingPattern(permitted.type)); - } - } - } - } - } while (modified); - return newPatterns; - } - private Set removeCoveredRecordPatterns(Set patterns) { Set existingBindings = patterns.stream() .filter(pd -> pd instanceof BindingPattern) diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java index 2c3d79c0ab6..adfc3ceaa0d 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java @@ -25,50 +25,87 @@ package com.sun.tools.javac.comp; -import com.sun.tools.javac.code.Symbol.MethodHandleSymbol; -import com.sun.tools.javac.code.Types.SignatureGenerator.InvalidSignatureException; -import com.sun.tools.javac.jvm.PoolConstant.LoadableConstant; -import com.sun.tools.javac.resources.CompilerProperties.Errors; -import com.sun.tools.javac.resources.CompilerProperties.Fragments; -import com.sun.tools.javac.tree.*; -import com.sun.tools.javac.tree.JCTree.*; -import com.sun.tools.javac.tree.JCTree.JCMemberReference.ReferenceKind; -import com.sun.tools.javac.tree.TreeMaker; -import com.sun.tools.javac.tree.TreeTranslator; import com.sun.tools.javac.code.Attribute; +import com.sun.tools.javac.code.Flags; import com.sun.tools.javac.code.Symbol; import com.sun.tools.javac.code.Symbol.ClassSymbol; import com.sun.tools.javac.code.Symbol.DynamicMethodSymbol; +import com.sun.tools.javac.code.Symbol.MethodHandleSymbol; import com.sun.tools.javac.code.Symbol.MethodSymbol; import com.sun.tools.javac.code.Symbol.VarSymbol; import com.sun.tools.javac.code.Symtab; import com.sun.tools.javac.code.Type; import com.sun.tools.javac.code.Type.MethodType; import com.sun.tools.javac.code.Types; -import com.sun.tools.javac.comp.LambdaToMethod.LambdaAnalyzerPreprocessor.*; +import com.sun.tools.javac.code.Types.SignatureGenerator.InvalidSignatureException; +import com.sun.tools.javac.jvm.PoolConstant.LoadableConstant; +import com.sun.tools.javac.main.Option; +import com.sun.tools.javac.resources.CompilerProperties.Errors; +import com.sun.tools.javac.resources.CompilerProperties.Fragments; import com.sun.tools.javac.resources.CompilerProperties.Notes; -import com.sun.tools.javac.util.*; +import com.sun.tools.javac.tree.JCTree; +import com.sun.tools.javac.tree.JCTree.JCAnnotation; +import com.sun.tools.javac.tree.JCTree.JCBinary; +import com.sun.tools.javac.tree.JCTree.JCBlock; +import com.sun.tools.javac.tree.JCTree.JCBreak; +import com.sun.tools.javac.tree.JCTree.JCCase; +import com.sun.tools.javac.tree.JCTree.JCClassDecl; +import com.sun.tools.javac.tree.JCTree.JCExpression; +import com.sun.tools.javac.tree.JCTree.JCFieldAccess; +import com.sun.tools.javac.tree.JCTree.JCFunctionalExpression; +import com.sun.tools.javac.tree.JCTree.JCIdent; +import com.sun.tools.javac.tree.JCTree.JCLambda; +import com.sun.tools.javac.tree.JCTree.JCMemberReference; +import com.sun.tools.javac.tree.JCTree.JCMethodDecl; +import com.sun.tools.javac.tree.JCTree.JCMethodInvocation; +import com.sun.tools.javac.tree.JCTree.JCNewClass; +import com.sun.tools.javac.tree.JCTree.JCReturn; +import com.sun.tools.javac.tree.JCTree.JCStatement; +import com.sun.tools.javac.tree.JCTree.JCSwitch; +import com.sun.tools.javac.tree.JCTree.JCVariableDecl; +import com.sun.tools.javac.tree.JCTree.Tag; +import com.sun.tools.javac.tree.TreeInfo; +import com.sun.tools.javac.tree.TreeMaker; +import com.sun.tools.javac.tree.TreeTranslator; +import com.sun.tools.javac.util.Assert; +import com.sun.tools.javac.util.Context; +import com.sun.tools.javac.util.DiagnosticSource; +import com.sun.tools.javac.util.InvalidUtfException; +import com.sun.tools.javac.util.JCDiagnostic; import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; +import com.sun.tools.javac.util.List; +import com.sun.tools.javac.util.ListBuffer; +import com.sun.tools.javac.util.Log; +import com.sun.tools.javac.util.Name; +import com.sun.tools.javac.util.Names; +import com.sun.tools.javac.util.Options; -import java.util.EnumMap; +import javax.lang.model.element.ElementKind; +import java.lang.invoke.LambdaMetafactory; import java.util.HashMap; import java.util.HashSet; -import java.util.LinkedHashMap; import java.util.Map; -import java.util.Optional; import java.util.Set; import java.util.function.Consumer; import java.util.function.Supplier; -import static com.sun.tools.javac.comp.LambdaToMethod.LambdaSymbolKind.*; -import static com.sun.tools.javac.code.Flags.*; -import static com.sun.tools.javac.code.Kinds.Kind.*; -import static com.sun.tools.javac.code.TypeTag.*; -import static com.sun.tools.javac.tree.JCTree.Tag.*; - -import javax.lang.model.element.ElementKind; - -import com.sun.tools.javac.main.Option; +import static com.sun.tools.javac.code.Flags.ABSTRACT; +import static com.sun.tools.javac.code.Flags.BLOCK; +import static com.sun.tools.javac.code.Flags.DEFAULT; +import static com.sun.tools.javac.code.Flags.FINAL; +import static com.sun.tools.javac.code.Flags.INTERFACE; +import static com.sun.tools.javac.code.Flags.LAMBDA_METHOD; +import static com.sun.tools.javac.code.Flags.LOCAL_CAPTURE_FIELD; +import static com.sun.tools.javac.code.Flags.PARAMETER; +import static com.sun.tools.javac.code.Flags.PRIVATE; +import static com.sun.tools.javac.code.Flags.STATIC; +import static com.sun.tools.javac.code.Flags.STRICTFP; +import static com.sun.tools.javac.code.Flags.SYNTHETIC; +import static com.sun.tools.javac.code.Kinds.Kind.MTH; +import static com.sun.tools.javac.code.Kinds.Kind.TYP; +import static com.sun.tools.javac.code.Kinds.Kind.VAR; +import static com.sun.tools.javac.code.TypeTag.BOT; +import static com.sun.tools.javac.code.TypeTag.VOID; /** * This pass desugars lambda expressions into static methods @@ -80,31 +117,28 @@ import com.sun.tools.javac.main.Option; */ public class LambdaToMethod extends TreeTranslator { - private Attr attr; - private JCDiagnostic.Factory diags; - private Log log; - private Lower lower; - private Names names; - private Symtab syms; - private Resolve rs; - private Operators operators; + private final Attr attr; + private final JCDiagnostic.Factory diags; + private final Log log; + private final Lower lower; + private final Names names; + private final Symtab syms; + private final Resolve rs; + private final Operators operators; private TreeMaker make; - private Types types; - private TransTypes transTypes; + private final Types types; + private final TransTypes transTypes; private Env attrEnv; - /** the analyzer scanner */ - private LambdaAnalyzerPreprocessor analyzer; - - /** map from lambda trees to translation contexts */ - private Map> contextMap; - - /** current translation context (visitor argument) */ - private TranslationContext context; - /** info about the current class being processed */ private KlassInfo kInfo; + /** translation context of the current lambda expression */ + private LambdaTranslationContext lambdaContext; + + /** the variable whose initializer is pending */ + private VarSymbol pendingVar; + /** dump statistics about lambda code generation */ private final boolean dumpLambdaToMethodStats; @@ -121,13 +155,13 @@ public class LambdaToMethod extends TreeTranslator { private final boolean deduplicateLambdas; /** Flag for alternate metafactories indicating the lambda object is intended to be serializable */ - public static final int FLAG_SERIALIZABLE = 1 << 0; + public static final int FLAG_SERIALIZABLE = LambdaMetafactory.FLAG_SERIALIZABLE; /** Flag for alternate metafactories indicating the lambda object has multiple targets */ - public static final int FLAG_MARKERS = 1 << 1; + public static final int FLAG_MARKERS = LambdaMetafactory.FLAG_MARKERS; /** Flag for alternate metafactories indicating the lambda object requires multiple bridges */ - public static final int FLAG_BRIDGES = 1 << 2; + public static final int FLAG_BRIDGES = LambdaMetafactory.FLAG_BRIDGES; // protected static final Context.Key unlambdaKey = new Context.Key<>(); @@ -151,18 +185,17 @@ public class LambdaToMethod extends TreeTranslator { make = TreeMaker.instance(context); types = Types.instance(context); transTypes = TransTypes.instance(context); - analyzer = new LambdaAnalyzerPreprocessor(); Options options = Options.instance(context); dumpLambdaToMethodStats = options.isSet("debug.dumpLambdaToMethodStats"); attr = Attr.instance(context); forceSerializable = options.isSet("forceSerializable"); boolean lineDebugInfo = - options.isUnset(Option.G_CUSTOM) || - options.isSet(Option.G_CUSTOM, "lines"); + options.isUnset(Option.G_CUSTOM) || + options.isSet(Option.G_CUSTOM, "lines"); boolean varDebugInfo = - options.isUnset(Option.G_CUSTOM) - ? options.isSet(Option.G) - : options.isSet(Option.G_CUSTOM, "vars"); + options.isUnset(Option.G_CUSTOM) + ? options.isSet(Option.G) + : options.isSet(Option.G_CUSTOM, "vars"); debugLinesOrVars = lineDebugInfo || varDebugInfo; verboseDeduplication = options.isSet("debug.dumpLambdaToMethodDeduplication"); deduplicateLambdas = options.getBoolean("deduplicateLambdas", true); @@ -180,7 +213,6 @@ public class LambdaToMethod extends TreeTranslator { this.tree = tree; } - @Override public int hashCode() { int hashCode = this.hashCode; @@ -203,18 +235,18 @@ public class LambdaToMethod extends TreeTranslator { /** * list of methods to append */ - private ListBuffer appendedMethodList; + private ListBuffer appendedMethodList = new ListBuffer<>(); - private Map dedupedLambdas; + private final Map dedupedLambdas = new HashMap<>(); - private Map dynMethSyms = new HashMap<>(); + private final Map dynMethSyms = new HashMap<>(); /** * list of deserialization cases */ - private final Map> deserializeCases; + private final Map> deserializeCases = new HashMap<>(); - /** + /** * deserialize method symbol */ private final MethodSymbol deserMethodSym; @@ -226,11 +258,10 @@ public class LambdaToMethod extends TreeTranslator { private final JCClassDecl clazz; + private final Map syntheticNames = new HashMap<>(); + private KlassInfo(JCClassDecl clazz) { this.clazz = clazz; - appendedMethodList = new ListBuffer<>(); - dedupedLambdas = new HashMap<>(); - deserializeCases = new HashMap<>(); MethodType type = new MethodType(List.of(syms.serializedLambdaType), syms.objectType, List.nil(), syms.methodClass); deserMethodSym = makePrivateSyntheticMethod(STATIC, names.deserializeLambda, type, clazz.sym); @@ -241,62 +272,50 @@ public class LambdaToMethod extends TreeTranslator { private void addMethod(JCTree decl) { appendedMethodList = appendedMethodList.prepend(decl); } - } - // - @Override - public T translate(T tree) { - TranslationContext newContext = contextMap.get(tree); - return translate(tree, newContext != null ? newContext : context); - } - - T translate(T tree, TranslationContext newContext) { - TranslationContext prevContext = context; - try { - context = newContext; - return super.translate(tree); - } - finally { - context = prevContext; + int syntheticNameIndex(StringBuilder buf, int start) { + String temp = buf.toString(); + Integer count = syntheticNames.get(temp); + if (count == null) { + count = start; + } + syntheticNames.put(temp, count + 1); + return count; } } - List translate(List trees, TranslationContext newContext) { - ListBuffer buf = new ListBuffer<>(); - for (T tree : trees) { - buf.append(translate(tree, newContext)); - } - return buf.toList(); - } - + // public JCTree translateTopLevelClass(Env env, JCTree cdef, TreeMaker make) { this.make = make; this.attrEnv = env; - this.context = null; - this.contextMap = new HashMap<>(); - cdef = analyzer.analyzeAndPreprocessClass((JCClassDecl) cdef); return translate(cdef); } - // - // /** * Visit a class. * Maintain the translatedMethodList across nested classes. * Append the translatedMethodList to the class after it is translated. - * @param tree */ @Override public void visitClassDef(JCClassDecl tree) { KlassInfo prevKlassInfo = kInfo; + DiagnosticSource prevSource = log.currentSource(); + LambdaTranslationContext prevLambdaContext = lambdaContext; + VarSymbol prevPendingVar = pendingVar; try { kInfo = new KlassInfo(tree); + log.useSource(tree.sym.sourcefile); + lambdaContext = null; + pendingVar = null; super.visitClassDef(tree); + if (prevLambdaContext != null) { + tree.sym.owner = prevLambdaContext.translatedSym; + } if (!kInfo.deserializeCases.isEmpty()) { int prevPos = make.pos; try { make.at(tree); - kInfo.addMethod(makeDeserializeMethod(tree.sym)); + kInfo.addMethod(makeDeserializeMethod()); } finally { make.at(prevPos); } @@ -310,6 +329,9 @@ public class LambdaToMethod extends TreeTranslator { result = tree; } finally { kInfo = prevKlassInfo; + log.useSource(prevSource.getFile()); + lambdaContext = prevLambdaContext; + pendingVar = prevPendingVar; } } @@ -317,11 +339,10 @@ public class LambdaToMethod extends TreeTranslator { * Translate a lambda into a method to be inserted into the class. * Then replace the lambda site with an invokedynamic call of to lambda * meta-factory, which will use the lambda method. - * @param tree */ @Override public void visitLambda(JCLambda tree) { - LambdaTranslationContext localContext = (LambdaTranslationContext)context; + LambdaTranslationContext localContext = new LambdaTranslationContext(tree); MethodSymbol sym = localContext.translatedSym; MethodType lambdaType = (MethodType) sym.type; @@ -332,26 +353,26 @@ public class LambdaToMethod extends TreeTranslator { lambda and attach it to the implementation method. */ - Symbol owner = localContext.owner; + Symbol owner = tree.owner; apportionTypeAnnotations(tree, owner::getRawTypeAttributes, owner::setTypeAttributes, sym::setTypeAttributes); - - boolean init; - if ((init = (owner.name == names.init)) || owner.name == names.clinit) { - owner = owner.owner; + final long ownerFlags = owner.flags(); + if ((ownerFlags & Flags.BLOCK) != 0) { + ClassSymbol cs = (ClassSymbol) owner.owner; + boolean isStaticInit = (ownerFlags & Flags.STATIC) != 0; apportionTypeAnnotations(tree, - init ? owner::getInitTypeAttributes : owner::getClassInitTypeAttributes, - init ? owner::setInitTypeAttributes : owner::setClassInitTypeAttributes, + isStaticInit ? cs::getClassInitTypeAttributes : cs::getInitTypeAttributes, + isStaticInit ? cs::setClassInitTypeAttributes : cs::setInitTypeAttributes, sym::appendUniqueTypeAttributes); } - if (localContext.self != null && localContext.self.getKind() == ElementKind.FIELD) { - owner = localContext.self; + + if (pendingVar != null && pendingVar.getKind() == ElementKind.FIELD) { apportionTypeAnnotations(tree, - owner::getRawTypeAttributes, - owner::setTypeAttributes, + pendingVar::getRawTypeAttributes, + pendingVar::setTypeAttributes, sym::appendUniqueTypeAttributes); } } @@ -363,35 +384,13 @@ public class LambdaToMethod extends TreeTranslator { List.nil(), localContext.syntheticParams, lambdaType.getThrownTypes() == null ? - List.nil() : - make.Types(lambdaType.getThrownTypes()), + List.nil() : + make.Types(lambdaType.getThrownTypes()), null, null); lambdaDecl.sym = sym; lambdaDecl.type = lambdaType; - //translate lambda body - //As the lambda body is translated, all references to lambda locals, - //captured variables, enclosing members are adjusted accordingly - //to refer to the static method parameters (rather than i.e. accessing - //captured members directly). - lambdaDecl.body = translate(makeLambdaBody(tree, lambdaDecl)); - - boolean dedupe = false; - if (deduplicateLambdas && !debugLinesOrVars && !localContext.isSerializable()) { - DedupedLambda dedupedLambda = new DedupedLambda(lambdaDecl.sym, lambdaDecl.body); - DedupedLambda existing = kInfo.dedupedLambdas.putIfAbsent(dedupedLambda, dedupedLambda); - if (existing != null) { - sym = existing.symbol; - dedupe = true; - if (verboseDeduplication) log.note(tree, Notes.VerboseL2mDeduplicate(sym)); - } - } - if (!dedupe) { - //Add the method to the list of methods to be added to this class. - kInfo.addMethod(lambdaDecl); - } - //now that we have generated a method for the lambda expression, //we can translate the lambda into a method reference pointing to the newly //created method. @@ -408,46 +407,72 @@ public class LambdaToMethod extends TreeTranslator { if (!sym.isStatic()) { syntheticInits.append(makeThis( sym.owner.enclClass().asType(), - localContext.owner.enclClass())); + tree.owner.enclClass())); } //add captured locals - for (Symbol fv : localContext.getSymbolMap(CAPTURED_VAR).keySet()) { - if (fv != localContext.self) { - JCExpression captured_local = make.Ident(fv).setType(fv.type); - syntheticInits.append(captured_local); - } + for (Symbol fv : localContext.capturedVars) { + JCExpression captured_local = make.Ident(fv).setType(fv.type); + syntheticInits.append(captured_local); } //then, determine the arguments to the indy call - List indy_args = translate(syntheticInits.toList(), localContext.prev); + List indy_args = translate(syntheticInits.toList()); + + LambdaTranslationContext prevLambdaContext = lambdaContext; + try { + lambdaContext = localContext; + //translate lambda body + //As the lambda body is translated, all references to lambda locals, + //captured variables, enclosing members are adjusted accordingly + //to refer to the static method parameters (rather than i.e. accessing + //captured members directly). + lambdaDecl.body = translate(makeLambdaBody(tree, lambdaDecl)); + } finally { + lambdaContext = prevLambdaContext; + } + + boolean dedupe = false; + if (deduplicateLambdas && !debugLinesOrVars && !isSerializable(tree)) { + DedupedLambda dedupedLambda = new DedupedLambda(lambdaDecl.sym, lambdaDecl.body); + DedupedLambda existing = kInfo.dedupedLambdas.putIfAbsent(dedupedLambda, dedupedLambda); + if (existing != null) { + sym = existing.symbol; + dedupe = true; + if (verboseDeduplication) log.note(tree, Notes.VerboseL2mDeduplicate(sym)); + } + } + if (!dedupe) { + //Add the method to the list of methods to be added to this class. + kInfo.addMethod(lambdaDecl); + } //convert to an invokedynamic call - result = makeMetafactoryIndyCall(context, sym.asHandle(), indy_args); + result = makeMetafactoryIndyCall(tree, sym.asHandle(), localContext.translatedSym, indy_args); } // where - // Reassign type annotations from the source that should really belong to the lambda - private void apportionTypeAnnotations(JCLambda tree, - Supplier> source, - Consumer> owner, - Consumer> lambda) { + // Reassign type annotations from the source that should really belong to the lambda + private void apportionTypeAnnotations(JCLambda tree, + Supplier> source, + Consumer> owner, + Consumer> lambda) { - ListBuffer ownerTypeAnnos = new ListBuffer<>(); - ListBuffer lambdaTypeAnnos = new ListBuffer<>(); + ListBuffer ownerTypeAnnos = new ListBuffer<>(); + ListBuffer lambdaTypeAnnos = new ListBuffer<>(); - for (Attribute.TypeCompound tc : source.get()) { - if (tc.position.onLambda == tree) { - lambdaTypeAnnos.append(tc); - } else { - ownerTypeAnnos.append(tc); - } - } - if (lambdaTypeAnnos.nonEmpty()) { - owner.accept(ownerTypeAnnos.toList()); - lambda.accept(lambdaTypeAnnos.toList()); + for (Attribute.TypeCompound tc : source.get()) { + if (tc.position.onLambda == tree) { + lambdaTypeAnnos.append(tc); + } else { + ownerTypeAnnos.append(tc); } } + if (lambdaTypeAnnos.nonEmpty()) { + owner.accept(ownerTypeAnnos.toList()); + lambda.accept(lambdaTypeAnnos.toList()); + } + } private JCIdent makeThis(Type type, Symbol owner) { VarSymbol _this = new VarSymbol(PARAMETER | FINAL | SYNTHETIC, @@ -460,65 +485,46 @@ public class LambdaToMethod extends TreeTranslator { /** * Translate a method reference into an invokedynamic call to the * meta-factory. - * @param tree */ @Override public void visitReference(JCMemberReference tree) { - ReferenceTranslationContext localContext = (ReferenceTranslationContext)context; - //first determine the method symbol to be used to generate the sam instance //this is either the method reference symbol, or the bridged reference symbol MethodSymbol refSym = (MethodSymbol)tree.sym; //the qualifying expression is treated as a special captured arg - JCExpression init; - switch(tree.kind) { - - case IMPLICIT_INNER: /** Inner :: new */ - case SUPER: /** super :: instMethod */ - init = makeThis( - localContext.owner.enclClass().asType(), - localContext.owner.enclClass()); - break; - - case BOUND: /** Expr :: instMethod */ - init = transTypes.coerce(attrEnv, tree.getQualifierExpression(), - types.erasure(tree.sym.owner.type)); - init = attr.makeNullCheck(init); - break; - - case UNBOUND: /** Type :: instMethod */ - case STATIC: /** Type :: staticMethod */ - case TOPLEVEL: /** Top level :: new */ - case ARRAY_CTOR: /** ArrayType :: new */ - init = null; - break; - - default: - throw new InternalError("Should not have an invalid kind"); - } - - List indy_args = init==null? List.nil() : translate(List.of(init), localContext.prev); + JCExpression init = switch (tree.kind) { + case IMPLICIT_INNER, /* Inner :: new */ + SUPER -> /* super :: instMethod */ + makeThis(tree.owner.enclClass().asType(), tree.owner.enclClass()); + case BOUND -> /* Expr :: instMethod */ + attr.makeNullCheck(transTypes.coerce(attrEnv, tree.getQualifierExpression(), + types.erasure(tree.sym.owner.type))); + case UNBOUND, /* Type :: instMethod */ + STATIC, /* Type :: staticMethod */ + TOPLEVEL, /* Top level :: new */ + ARRAY_CTOR -> /* ArrayType :: new */ + null; + }; + List indy_args = (init == null) ? + List.nil() : translate(List.of(init)); //build a sam instance using an indy call to the meta-factory - result = makeMetafactoryIndyCall(localContext, refSym.asHandle(), indy_args); + result = makeMetafactoryIndyCall(tree, refSym.asHandle(), refSym, indy_args); } /** * Translate identifiers within a lambda to the mapped identifier - * @param tree */ @Override public void visitIdent(JCIdent tree) { - if (context == null || !analyzer.lambdaIdentSymbolFilter(tree.sym)) { + if (lambdaContext == null) { super.visitIdent(tree); } else { int prevPos = make.pos; try { make.at(tree); - - LambdaTranslationContext lambdaContext = (LambdaTranslationContext) context; JCTree ltree = lambdaContext.translate(tree); if (ltree != null) { result = ltree; @@ -535,13 +541,18 @@ public class LambdaToMethod extends TreeTranslator { @Override public void visitVarDef(JCVariableDecl tree) { - LambdaTranslationContext lambdaContext = (LambdaTranslationContext)context; - if (context != null && lambdaContext.getSymbolMap(LOCAL_VAR).containsKey(tree.sym)) { - tree.init = translate(tree.init); - tree.sym = (VarSymbol) lambdaContext.getSymbolMap(LOCAL_VAR).get(tree.sym); - result = tree; - } else { - super.visitVarDef(tree); + VarSymbol prevPendingVar = pendingVar; + try { + pendingVar = tree.sym; + if (lambdaContext != null) { + tree.sym = lambdaContext.addLocal(tree.sym); + tree.init = translate(tree.init); + result = tree; + } else { + super.visitVarDef(tree); + } + } finally { + pendingVar = prevPendingVar; } } @@ -609,7 +620,7 @@ public class LambdaToMethod extends TreeTranslator { if (isTarget_void && !isLambda_void) { //Void to void conversion: // { TYPE $loc = RET-EXPR; return; } - VarSymbol loc = makeSyntheticVar(0, names.fromString("$loc"), tree.expr.type, lambdaMethodDecl.sym); + VarSymbol loc = new VarSymbol(SYNTHETIC, names.fromString("$loc"), tree.expr.type, lambdaMethodDecl.sym); JCVariableDecl varDef = make.VarDef(loc, tree.expr); result = make.Block(0, List.of(varDef, make.Return(null))); } else { @@ -628,7 +639,7 @@ public class LambdaToMethod extends TreeTranslator { return trans_block; } - private JCMethodDecl makeDeserializeMethod(Symbol kSym) { + private JCMethodDecl makeDeserializeMethod() { ListBuffer cases = new ListBuffer<>(); ListBuffer breaks = new ListBuffer<>(); for (Map.Entry> entry : kInfo.deserializeCases.entrySet()) { @@ -644,16 +655,16 @@ public class LambdaToMethod extends TreeTranslator { JCBlock body = make.Block(0L, List.of( sw, make.Throw(makeNewClass( - syms.illegalArgumentExceptionType, - List.of(make.Literal("Invalid lambda deserialization")))))); + syms.illegalArgumentExceptionType, + List.of(make.Literal("Invalid lambda deserialization")))))); JCMethodDecl deser = make.MethodDef(make.Modifiers(kInfo.deserMethodSym.flags()), - names.deserializeLambda, - make.QualIdent(kInfo.deserMethodSym.getReturnType().tsym), - List.nil(), - List.of(make.VarDef(kInfo.deserParamSym, null)), - List.nil(), - body, - null); + names.deserializeLambda, + make.QualIdent(kInfo.deserMethodSym.getReturnType().tsym), + List.nil(), + List.of(make.VarDef(kInfo.deserParamSym, null)), + List.nil(), + body, + null); deser.sym = kInfo.deserMethodSym; deser.type = kInfo.deserMethodSym.type; //System.err.printf("DESER: '%s'\n", deser); @@ -667,7 +678,7 @@ public class LambdaToMethod extends TreeTranslator { */ JCNewClass makeNewClass(Type ctype, List args, Symbol cons) { JCNewClass tree = make.NewClass(null, - null, make.QualIdent(ctype.tsym), args, null); + null, make.QualIdent(ctype.tsym), args, null); tree.constructor = cons; tree.type = ctype; return tree; @@ -680,7 +691,7 @@ public class LambdaToMethod extends TreeTranslator { JCNewClass makeNewClass(Type ctype, List args) { return makeNewClass(ctype, args, rs.resolveConstructor(null, attrEnv, ctype, TreeInfo.types(args), List.nil())); - } + } private void addDeserializationCase(MethodHandleSymbol refSym, Type targetType, MethodSymbol samSym, DiagnosticPosition pos, List staticArgs, MethodType indyType) { @@ -711,17 +722,17 @@ public class LambdaToMethod extends TreeTranslator { } JCStatement stmt = make.If( deserTest(deserTest(deserTest(deserTest(deserTest( - kindTest, - "getFunctionalInterfaceClass", functionalInterfaceClass), - "getFunctionalInterfaceMethodName", functionalInterfaceMethodName), - "getFunctionalInterfaceMethodSignature", functionalInterfaceMethodSignature), - "getImplClass", implClass), - "getImplMethodSignature", implMethodSignature), + kindTest, + "getFunctionalInterfaceClass", functionalInterfaceClass), + "getFunctionalInterfaceMethodName", functionalInterfaceMethodName), + "getFunctionalInterfaceMethodSignature", functionalInterfaceMethodSignature), + "getImplClass", implClass), + "getImplMethodSignature", implMethodSignature), make.Return(makeIndyCall( - pos, - syms.lambdaMetafactory, - names.altMetafactory, - staticArgs, indyType, serArgs.toList(), samSym.name)), + pos, + syms.lambdaMetafactory, + names.altMetafactory, + staticArgs, indyType, serArgs.toList(), samSym.name)), null); ListBuffer stmts = kInfo.deserializeCases.get(implMethodName); if (stmts == null) { @@ -742,8 +753,8 @@ public class LambdaToMethod extends TreeTranslator { } private JCExpression eqTest(Type argType, JCExpression arg1, JCExpression arg2) { - JCBinary testExpr = make.Binary(JCTree.Tag.EQ, arg1, arg2); - testExpr.operator = operators.resolveBinary(testExpr, JCTree.Tag.EQ, argType, argType); + JCBinary testExpr = make.Binary(Tag.EQ, arg1, arg2); + testExpr.operator = operators.resolveBinary(testExpr, Tag.EQ, argType, argType); testExpr.setType(syms.booleanType); return testExpr; } @@ -756,8 +767,8 @@ public class LambdaToMethod extends TreeTranslator { make.Select(deserGetter(func, syms.stringType), eqsym).setType(eqmt), List.of(make.Literal(lit))); eqtest.setType(syms.booleanType); - JCBinary compound = make.Binary(JCTree.Tag.AND, prev, eqtest); - compound.operator = operators.resolveBinary(compound, JCTree.Tag.AND, syms.booleanType, syms.booleanType); + JCBinary compound = make.Binary(Tag.AND, prev, eqtest); + compound.operator = operators.resolveBinary(compound, Tag.AND, syms.booleanType, syms.booleanType); compound.setType(syms.booleanType); return compound; } @@ -770,9 +781,9 @@ public class LambdaToMethod extends TreeTranslator { MethodType getmt = new MethodType(argTypes, type, List.nil(), syms.methodClass); Symbol getsym = rs.resolveQualifiedMethod(null, attrEnv, syms.serializedLambdaType, names.fromString(func), argTypes, List.nil()); return make.Apply( - List.nil(), - make.Select(make.Ident(kInfo.deserParamSym).setType(syms.serializedLambdaType), getsym).setType(getmt), - args).setType(type); + List.nil(), + make.Select(make.Ident(kInfo.deserParamSym).setType(syms.serializedLambdaType), getsym).setType(getmt), + args).setType(type); } /** @@ -782,29 +793,20 @@ public class LambdaToMethod extends TreeTranslator { return new MethodSymbol(flags | SYNTHETIC | PRIVATE, name, type, owner); } - /** - * Create new synthetic variable with given flags, name, type, owner - */ - private VarSymbol makeSyntheticVar(long flags, Name name, Type type, Symbol owner) { - return new VarSymbol(flags | SYNTHETIC, name, type, owner); - } - - // - private MethodType typeToMethodType(Type mt) { Type type = types.erasure(mt); return new MethodType(type.getParameterTypes(), - type.getReturnType(), - type.getThrownTypes(), - syms.methodClass); + type.getReturnType(), + type.getThrownTypes(), + syms.methodClass); } /** * Generate an indy method call to the meta factory */ - private JCExpression makeMetafactoryIndyCall(TranslationContext context, - MethodHandleSymbol refSym, List indy_args) { - JCFunctionalExpression tree = context.tree; + private JCExpression makeMetafactoryIndyCall(JCFunctionalExpression tree, + MethodHandleSymbol refSym, MethodSymbol nonDedupedRefSym, + List indy_args) { //determine the static bsm args MethodSymbol samSym = (MethodSymbol) types.findDescriptorSymbol(tree.target.tsym); List staticArgs = List.of( @@ -824,10 +826,17 @@ public class LambdaToMethod extends TreeTranslator { List.nil(), syms.methodClass); - Name metafactoryName = context.needsAltMetafactory() ? + List bridges = bridges(tree); + boolean isSerializable = isSerializable(tree); + boolean needsAltMetafactory = tree.target.isIntersection() || + isSerializable || bridges.length() > 1; + + dumpStats(tree, needsAltMetafactory, nonDedupedRefSym); + + Name metafactoryName = needsAltMetafactory ? names.altMetafactory : names.metafactory; - if (context.needsAltMetafactory()) { + if (needsAltMetafactory) { ListBuffer markers = new ListBuffer<>(); List targets = tree.target.isIntersection() ? types.directSupertypes(tree.target) : @@ -835,14 +844,14 @@ public class LambdaToMethod extends TreeTranslator { for (Type t : targets) { t = types.erasure(t); if (t.tsym != syms.serializableType.tsym && - t.tsym != tree.type.tsym && - t.tsym != syms.objectType.tsym) { + t.tsym != tree.type.tsym && + t.tsym != syms.objectType.tsym) { markers.append(t); } } - int flags = context.isSerializable() ? FLAG_SERIALIZABLE : 0; + int flags = isSerializable ? FLAG_SERIALIZABLE : 0; boolean hasMarkers = markers.nonEmpty(); - boolean hasBridges = context.bridges.nonEmpty(); + boolean hasBridges = bridges.nonEmpty(); if (hasMarkers) { flags |= FLAG_MARKERS; } @@ -855,15 +864,15 @@ public class LambdaToMethod extends TreeTranslator { staticArgs = staticArgs.appendList(List.convert(LoadableConstant.class, markers.toList())); } if (hasBridges) { - staticArgs = staticArgs.append(LoadableConstant.Int(context.bridges.length() - 1)); - for (Symbol s : context.bridges) { + staticArgs = staticArgs.append(LoadableConstant.Int(bridges.length() - 1)); + for (Symbol s : bridges) { Type s_erasure = s.erasure(types); if (!types.isSameType(s_erasure, samSym.erasure(types))) { staticArgs = staticArgs.append(((MethodType)s.erasure(types))); } } } - if (context.isSerializable()) { + if (isSerializable) { int prevPos = make.pos; try { make.at(kInfo.clazz); @@ -889,18 +898,18 @@ public class LambdaToMethod extends TreeTranslator { try { make.at(pos); List bsm_staticArgs = List.of(syms.methodHandleLookupType, - syms.stringType, - syms.methodTypeType).appendList(staticArgs.map(types::constantType)); + syms.stringType, + syms.methodTypeType).appendList(staticArgs.map(types::constantType)); MethodSymbol bsm = rs.resolveInternalMethod(pos, attrEnv, site, bsmName, bsm_staticArgs, List.nil()); DynamicMethodSymbol dynSym = new DynamicMethodSymbol(methName, - syms.noSymbol, - bsm.asHandle(), - indyType, - staticArgs.toArray(new LoadableConstant[staticArgs.length()])); + syms.noSymbol, + bsm.asHandle(), + indyType, + staticArgs.toArray(new LoadableConstant[staticArgs.length()])); JCFieldAccess qualifier = make.Select(make.QualIdent(site.tsym), bsmName); DynamicMethodSymbol existing = kInfo.dynMethSyms.putIfAbsent( dynSym.poolKey(types), dynSym); @@ -915,833 +924,337 @@ public class LambdaToMethod extends TreeTranslator { } } - // - /** - * This visitor collects information about translation of a lambda expression. - * More specifically, it keeps track of the enclosing contexts and captured locals - * accessed by the lambda being translated (as well as other useful info). - * It also translates away problems for LambdaToMethod. - */ - class LambdaAnalyzerPreprocessor extends TreeTranslator { + List bridges(JCFunctionalExpression tree) { + ClassSymbol csym = + types.makeFunctionalInterfaceClass(attrEnv, names.empty, tree.target, ABSTRACT | INTERFACE); + return types.functionalInterfaceBridges(csym); + } - /** the frame stack - used to reconstruct translation info about enclosing scopes */ - private List frameStack; - - /** - * keep the count of lambda expression (used to generate unambiguous - * names) - */ - private int lambdaCount = 0; - - /** - * keep the count of lambda expression defined in given context (used to - * generate unambiguous names for serializable lambdas) - */ - private class SyntheticMethodNameCounter { - private Map map = new HashMap<>(); - int getIndex(StringBuilder buf) { - String temp = buf.toString(); - Integer count = map.get(temp); - if (count == null) { - count = 0; - } - ++count; - map.put(temp, count); - return count; - } + /** does this functional expression require serialization support? */ + boolean isSerializable(JCFunctionalExpression tree) { + if (forceSerializable) { + return true; } - private SyntheticMethodNameCounter syntheticMethodNameCounts = - new SyntheticMethodNameCounter(); - - private Map localClassDefs; - - /** - * maps for fake clinit symbols to be used as owners of lambda occurring in - * a static var init context - */ - private Map clinits = new HashMap<>(); - - private JCClassDecl analyzeAndPreprocessClass(JCClassDecl tree) { - frameStack = List.nil(); - localClassDefs = new HashMap<>(); - return translate(tree); - } - - @Override - public void visitBlock(JCBlock tree) { - List prevStack = frameStack; - try { - if (frameStack.nonEmpty() && frameStack.head.tree.hasTag(CLASSDEF)) { - frameStack = frameStack.prepend(new Frame(tree)); - } - super.visitBlock(tree); - } - finally { - frameStack = prevStack; - } - } - - @Override - public void visitClassDef(JCClassDecl tree) { - List prevStack = frameStack; - int prevLambdaCount = lambdaCount; - SyntheticMethodNameCounter prevSyntheticMethodNameCounts = - syntheticMethodNameCounts; - Map prevClinits = clinits; - DiagnosticSource prevSource = log.currentSource(); - try { - log.useSource(tree.sym.sourcefile); - lambdaCount = 0; - syntheticMethodNameCounts = new SyntheticMethodNameCounter(); - prevClinits = new HashMap<>(); - if (tree.sym.owner.kind == MTH) { - localClassDefs.put(tree.sym, tree); - } - if (directlyEnclosingLambda() != null) { - tree.sym.owner = owner(); - } - frameStack = frameStack.prepend(new Frame(tree)); - super.visitClassDef(tree); - } - finally { - log.useSource(prevSource.getFile()); - frameStack = prevStack; - lambdaCount = prevLambdaCount; - syntheticMethodNameCounts = prevSyntheticMethodNameCounts; - clinits = prevClinits; - } - } - - @Override - public void visitIdent(JCIdent tree) { - if (context() != null && lambdaIdentSymbolFilter(tree.sym)) { - if (tree.sym.kind == VAR && - tree.sym.owner.kind == MTH && - tree.type.constValue() == null) { - TranslationContext localContext = context(); - while (localContext != null) { - if (localContext.tree.getTag() == LAMBDA) { - JCTree block = capturedDecl(localContext.depth, tree.sym); - if (block == null) break; - ((LambdaTranslationContext)localContext) - .addSymbol(tree.sym, CAPTURED_VAR); - } - localContext = localContext.prev; - } - } else if (tree.sym.owner.kind == TYP) { - TranslationContext localContext = context(); - while (localContext != null && !localContext.owner.isStatic()) { - if (localContext.tree.hasTag(LAMBDA)) { - JCTree block = capturedDecl(localContext.depth, tree.sym); - if (block == null) break; - switch (block.getTag()) { - case CLASSDEF: - JCClassDecl cdecl = (JCClassDecl)block; - ((LambdaTranslationContext)localContext) - .addSymbol(cdecl.sym, CAPTURED_THIS); - break; - default: - Assert.error("bad block kind"); - } - } - localContext = localContext.prev; - } - } - } - super.visitIdent(tree); - } - - @Override - public void visitLambda(JCLambda tree) { - analyzeLambda(tree, tree.wasMethodReference ? "mref.stat.1" : "lambda.stat"); - } - - private LambdaTranslationContext analyzeLambda(JCLambda tree, String statKey) { - List prevStack = frameStack; - try { - LambdaTranslationContext context = new LambdaTranslationContext(tree); - frameStack = frameStack.prepend(new Frame(tree)); - for (JCVariableDecl param : tree.params) { - context.addSymbol(param.sym, PARAM); - frameStack.head.addLocal(param.sym); - } - contextMap.put(tree, context); - super.visitLambda(tree); - context.complete(); - if (dumpLambdaToMethodStats) { - log.note(tree, diags.noteKey(statKey, context.needsAltMetafactory(), context.translatedSym)); - } - return context; - } - finally { - frameStack = prevStack; - } - } - - @Override - public void visitMethodDef(JCMethodDecl tree) { - List prevStack = frameStack; - try { - frameStack = frameStack.prepend(new Frame(tree)); - super.visitMethodDef(tree); - } - finally { - frameStack = prevStack; - } - } - - /** - * Method references to local class constructors, may, if the local - * class references local variables, have implicit constructor - * parameters added in Lower; As a result, the invokedynamic bootstrap - * information added in the LambdaToMethod pass will have the wrong - * signature. Hooks between Lower and LambdaToMethod have been added to - * handle normal "new" in this case. This visitor converts potentially - * affected method references into a lambda containing a normal - * expression. - * - * @param tree - */ - @Override - public void visitReference(JCMemberReference tree) { - ReferenceTranslationContext rcontext = new ReferenceTranslationContext(tree); - contextMap.put(tree, rcontext); - super.visitReference(tree); - if (dumpLambdaToMethodStats) { - log.note(tree, Notes.MrefStat(rcontext.needsAltMetafactory(), null)); - } - } - - @Override - public void visitSelect(JCFieldAccess tree) { - if (context() != null && tree.sym.kind == VAR && - (tree.sym.name == names._this || - tree.sym.name == names._super)) { - // A select of this or super means, if we are in a lambda, - // we much have an instance context - TranslationContext localContext = context(); - while (localContext != null && !localContext.owner.isStatic()) { - if (localContext.tree.hasTag(LAMBDA)) { - JCClassDecl clazz = (JCClassDecl)capturedDecl(localContext.depth, tree.sym); - if (clazz == null) break; - ((LambdaTranslationContext)localContext).addSymbol(clazz.sym, CAPTURED_THIS); - } - localContext = localContext.prev; - } - } - super.visitSelect(tree); - } - - @Override - public void visitVarDef(JCVariableDecl tree) { - TranslationContext context = context(); - if (context != null && context instanceof LambdaTranslationContext lambdaContext) { - for (Frame frame : frameStack) { - if (frame.tree.hasTag(VARDEF)) { - //skip variable frames inside a lambda: - continue; - } else if (frame.tree.hasTag(LAMBDA)) { - lambdaContext.addSymbol(tree.sym, LOCAL_VAR); - } else { - break; - } - } - // Check for type variables (including as type arguments). - // If they occur within class nested in a lambda, mark for erasure - Type type = tree.sym.asType(); - } - - List prevStack = frameStack; - try { - if (tree.sym.owner.kind == MTH) { - frameStack.head.addLocal(tree.sym); - } - frameStack = frameStack.prepend(new Frame(tree)); - super.visitVarDef(tree); - } - finally { - frameStack = prevStack; - } - } - - /** - * Return a valid owner given the current declaration stack - * (required to skip synthetic lambda symbols) - */ - private Symbol owner() { - return owner(false); - } - - @SuppressWarnings("fallthrough") - private Symbol owner(boolean skipLambda) { - List frameStack2 = frameStack; - while (frameStack2.nonEmpty()) { - switch (frameStack2.head.tree.getTag()) { - case VARDEF: - if (((JCVariableDecl)frameStack2.head.tree).sym.isDirectlyOrIndirectlyLocal()) { - frameStack2 = frameStack2.tail; - break; - } - JCClassDecl cdecl = (JCClassDecl)frameStack2.tail.head.tree; - return initSym(cdecl.sym, - ((JCVariableDecl)frameStack2.head.tree).sym.flags() & STATIC); - case BLOCK: - JCClassDecl cdecl2 = (JCClassDecl)frameStack2.tail.head.tree; - return initSym(cdecl2.sym, - ((JCBlock)frameStack2.head.tree).flags & STATIC); - case CLASSDEF: - return ((JCClassDecl)frameStack2.head.tree).sym; - case METHODDEF: - return ((JCMethodDecl)frameStack2.head.tree).sym; - case LAMBDA: - if (!skipLambda) - return ((LambdaTranslationContext)contextMap - .get(frameStack2.head.tree)).translatedSym; - default: - frameStack2 = frameStack2.tail; - } - } - Assert.error(); - return null; - } - - private Symbol initSym(ClassSymbol csym, long flags) { - boolean isStatic = (flags & STATIC) != 0; - if (isStatic) { - /* static clinits are generated in Gen, so we need to use a fake - * one. Attr creates a fake clinit method while attributing - * lambda expressions used as initializers of static fields, so - * let's use that one. - */ - MethodSymbol clinit = attr.removeClinit(csym); - if (clinit != null) { - clinits.put(csym, clinit); - return clinit; - } - - /* if no clinit is found at Attr, then let's try at clinits. - */ - clinit = (MethodSymbol)clinits.get(csym); - if (clinit == null) { - /* no luck, let's create a new one - */ - clinit = makePrivateSyntheticMethod(STATIC, - names.clinit, - new MethodType(List.nil(), syms.voidType, - List.nil(), syms.methodClass), - csym); - clinits.put(csym, clinit); - } - return clinit; - } else { - //get the first constructor and treat it as the instance init sym - for (Symbol s : csym.members_field.getSymbolsByName(names.init)) { - return s; - } - } - Assert.error("init not found"); - return null; - } - - private JCTree directlyEnclosingLambda() { - if (frameStack.isEmpty()) { - return null; - } - List frameStack2 = frameStack; - while (frameStack2.nonEmpty()) { - switch (frameStack2.head.tree.getTag()) { - case CLASSDEF: - case METHODDEF: - return null; - case LAMBDA: - return frameStack2.head.tree; - default: - frameStack2 = frameStack2.tail; - } - } - Assert.error(); - return null; - } - - private boolean inClassWithinLambda() { - if (frameStack.isEmpty()) { - return false; - } - List frameStack2 = frameStack; - boolean classFound = false; - while (frameStack2.nonEmpty()) { - switch (frameStack2.head.tree.getTag()) { - case LAMBDA: - return classFound; - case CLASSDEF: - classFound = true; - frameStack2 = frameStack2.tail; - break; - default: - frameStack2 = frameStack2.tail; - } - } - // No lambda - return false; - } - - /** - * Return the declaration corresponding to a symbol in the enclosing - * scope; the depth parameter is used to filter out symbols defined - * in nested scopes (which do not need to undergo capture). - */ - private JCTree capturedDecl(int depth, Symbol sym) { - Assert.check(sym.kind != TYP); - int currentDepth = frameStack.size() - 1; - for (Frame block : frameStack) { - switch (block.tree.getTag()) { - case CLASSDEF: - ClassSymbol clazz = ((JCClassDecl)block.tree).sym; - if (clazz.isSubClass(sym.enclClass(), types)) { - return currentDepth > depth ? null : block.tree; - } - break; - case VARDEF: - if ((((JCVariableDecl)block.tree).sym == sym && - sym.owner.kind == MTH) || //only locals are captured - (block.locals != null && block.locals.contains(sym))) { - return currentDepth > depth ? null : block.tree; - } - break; - case BLOCK: - case METHODDEF: - case LAMBDA: - if (block.locals != null && block.locals.contains(sym)) { - return currentDepth > depth ? null : block.tree; - } - break; - default: - Assert.error("bad decl kind " + block.tree.getTag()); - } - currentDepth--; - } - return null; - } - - private TranslationContext context() { - for (Frame frame : frameStack) { - TranslationContext context = contextMap.get(frame.tree); - if (context != null) { - return context; - } - } - return null; - } - - /** - * This is used to filter out those identifiers that needs to be adjusted - * when translating away lambda expressions - */ - private boolean lambdaIdentSymbolFilter(Symbol sym) { - return (sym.kind == VAR || sym.kind == MTH) - && !sym.isStatic() - && sym.name != names.init; - } - - private class Frame { - final JCTree tree; - List locals; - - public Frame(JCTree tree) { - this.tree = tree; - } - - void addLocal(Symbol sym) { - if (locals == null) { - locals = List.nil(); - } - locals = locals.prepend(sym); - } - } - - /** - * This class is used to store important information regarding translation of - * lambda expression/method references (see subclasses). - */ - abstract class TranslationContext { - - /** the underlying (untranslated) tree */ - final T tree; - - /** points to the adjusted enclosing scope in which this lambda/mref expression occurs */ - final Symbol owner; - - /** the depth of this lambda expression in the frame stack */ - final int depth; - - /** the enclosing translation context (set for nested lambdas/mref) */ - final TranslationContext prev; - - /** list of methods to be bridged by the meta-factory */ - final List bridges; - - TranslationContext(T tree) { - this.tree = tree; - this.owner = owner(true); - this.depth = frameStack.size() - 1; - this.prev = context(); - ClassSymbol csym = - types.makeFunctionalInterfaceClass(attrEnv, names.empty, tree.target, ABSTRACT | INTERFACE); - this.bridges = types.functionalInterfaceBridges(csym); - } - - /** does this functional expression need to be created using alternate metafactory? */ - boolean needsAltMetafactory() { - return tree.target.isIntersection() || - isSerializable() || - bridges.length() > 1; - } - - /** does this functional expression require serialization support? */ - boolean isSerializable() { - if (forceSerializable) { - return true; - } - return types.asSuper(tree.target, syms.serializableType.tsym) != null; - } - - /** - * @return Name of the enclosing method to be folded into synthetic - * method name - */ - String enclosingMethodName() { - return syntheticMethodNameComponent(owner.name); - } - - /** - * @return Method name in a form that can be folded into a - * component of a synthetic method name - */ - String syntheticMethodNameComponent(Name name) { - if (name == null) { - return "null"; - } - String methodName = name.toString(); - if (methodName.equals("")) { - methodName = "static"; - } else if (methodName.equals("")) { - methodName = "new"; - } - return methodName; - } - } - - /** - * This class retains all the useful information about a lambda expression; - * the contents of this class are filled by the LambdaAnalyzer visitor, - * and the used by the main translation routines in order to adjust references - * to captured locals/members, etc. - */ - class LambdaTranslationContext extends TranslationContext { - - /** variable in the enclosing context to which this lambda is assigned */ - final Symbol self; - - /** variable in the enclosing context to which this lambda is assigned */ - final Symbol assignedTo; - - Map> translatedSymbols; - - /** the synthetic symbol for the method hoisting the translated lambda */ - MethodSymbol translatedSym; - - List syntheticParams; - - LambdaTranslationContext(JCLambda tree) { - super(tree); - Frame frame = frameStack.head; - switch (frame.tree.getTag()) { - case VARDEF: - assignedTo = self = ((JCVariableDecl) frame.tree).sym; - break; - case ASSIGN: - self = null; - assignedTo = TreeInfo.symbol(((JCAssign) frame.tree).getVariable()); - break; - default: - assignedTo = self = null; - break; - } - - // This symbol will be filled-in in complete - if (owner.kind == MTH) { - final MethodSymbol originalOwner = (MethodSymbol)owner.clone(owner.owner); - this.translatedSym = new MethodSymbol(SYNTHETIC | PRIVATE, null, null, owner.enclClass()) { - @Override - public MethodSymbol originalEnclosingMethod() { - return originalOwner; - } - }; - } else { - this.translatedSym = makePrivateSyntheticMethod(0, null, null, owner.enclClass()); - } - translatedSymbols = new EnumMap<>(LambdaSymbolKind.class); - - translatedSymbols.put(PARAM, new LinkedHashMap<>()); - translatedSymbols.put(LOCAL_VAR, new LinkedHashMap<>()); - translatedSymbols.put(CAPTURED_VAR, new LinkedHashMap<>()); - translatedSymbols.put(CAPTURED_THIS, new LinkedHashMap<>()); - } - - /** - * For a serializable lambda, generate a disambiguating string - * which maximizes stability across deserialization. - * - * @return String to differentiate synthetic lambda method names - */ - private String serializedLambdaDisambiguation() { - StringBuilder buf = new StringBuilder(); - // Append the enclosing method signature to differentiate - // overloaded enclosing methods. For lambdas enclosed in - // lambdas, the generated lambda method will not have type yet, - // but the enclosing method's name will have been generated - // with this same method, so it will be unique and never be - // overloaded. - Assert.check( - owner.type != null || - directlyEnclosingLambda() != null); - if (owner.type != null) { - buf.append(typeSig(owner.type, true)); - buf.append(":"); - } - - // Add target type info - buf.append(types.findDescriptorSymbol(tree.type.tsym).owner.flatName()); - buf.append(" "); - - // Add variable assigned to - if (assignedTo != null) { - buf.append(assignedTo.flatName()); - buf.append("="); - } - //add captured locals info: type, name, order - for (Symbol fv : getSymbolMap(CAPTURED_VAR).keySet()) { - if (fv != self) { - buf.append(typeSig(fv.type, true)); - buf.append(" "); - buf.append(fv.flatName()); - buf.append(","); - } - } - - return buf.toString(); - } - - /** - * For a non-serializable lambda, generate a simple method. - * - * @return Name to use for the synthetic lambda method name - */ - private Name lambdaName() { - return names.lambda.append(names.fromString(enclosingMethodName() + "$" + lambdaCount++)); - } - - /** - * For a serializable lambda, generate a method name which maximizes - * name stability across deserialization. - * - * @return Name to use for the synthetic lambda method name - */ - private Name serializedLambdaName() { - StringBuilder buf = new StringBuilder(); - buf.append(names.lambda); - // Append the name of the method enclosing the lambda. - buf.append(enclosingMethodName()); - buf.append('$'); - // Append a hash of the disambiguating string : enclosing method - // signature, etc. - String disam = serializedLambdaDisambiguation(); - buf.append(Integer.toHexString(disam.hashCode())); - buf.append('$'); - // The above appended name components may not be unique, append - // a count based on the above name components. - buf.append(syntheticMethodNameCounts.getIndex(buf)); - String result = buf.toString(); - //System.err.printf("serializedLambdaName: %s -- %s\n", result, disam); - return names.fromString(result); - } - - /** - * Translate a symbol of a given kind into something suitable for the - * synthetic lambda body - */ - Symbol translate(final Symbol sym, LambdaSymbolKind skind) { - Symbol ret; - switch (skind) { - case CAPTURED_THIS: - ret = sym; // self represented - break; - case CAPTURED_VAR: - ret = new VarSymbol(SYNTHETIC | FINAL | PARAMETER, sym.name, types.erasure(sym.type), translatedSym) { - @Override - public Symbol baseSymbol() { - //keep mapping with original captured symbol - return sym; - } - }; - break; - case LOCAL_VAR: - ret = new VarSymbol(sym.flags() & FINAL, sym.name, sym.type, translatedSym) { - @Override - public Symbol baseSymbol() { - //keep mapping with original symbol - return sym; - } - }; - ((VarSymbol) ret).pos = ((VarSymbol) sym).pos; - // If sym.data == ElementKind.EXCEPTION_PARAMETER, - // set ret.data = ElementKind.EXCEPTION_PARAMETER too. - // Because method com.sun.tools.javac.jvm.Code.fillExceptionParameterPositions and - // com.sun.tools.javac.jvm.Code.fillLocalVarPosition would use it. - // See JDK-8257740 for more information. - if (((VarSymbol) sym).isExceptionParameter()) { - ((VarSymbol) ret).setData(ElementKind.EXCEPTION_PARAMETER); - } - break; - case PARAM: - ret = new VarSymbol((sym.flags() & FINAL) | PARAMETER, sym.name, types.erasure(sym.type), translatedSym); - ((VarSymbol) ret).pos = ((VarSymbol) sym).pos; - // Set ret.data. Same as case LOCAL_VAR above. - if (((VarSymbol) sym).isExceptionParameter()) { - ((VarSymbol) ret).setData(ElementKind.EXCEPTION_PARAMETER); - } - break; - default: - Assert.error(skind.name()); - throw new AssertionError(); - } - if (ret != sym && skind.propagateAnnotations()) { - ret.setDeclarationAttributes(sym.getRawAttributes()); - ret.setTypeAttributes(sym.getRawTypeAttributes()); - } - return ret; - } - - void addSymbol(Symbol sym, LambdaSymbolKind skind) { - Map transMap = getSymbolMap(skind); - if (!transMap.containsKey(sym)) { - transMap.put(sym, translate(sym, skind)); - } - } - - Map getSymbolMap(LambdaSymbolKind skind) { - Map m = translatedSymbols.get(skind); - Assert.checkNonNull(m); - return m; - } - - JCTree translate(JCIdent lambdaIdent) { - for (LambdaSymbolKind kind : LambdaSymbolKind.values()) { - Map m = getSymbolMap(kind); - switch(kind) { - default: - if (m.containsKey(lambdaIdent.sym)) { - Symbol tSym = m.get(lambdaIdent.sym); - JCTree t = make.Ident(tSym).setType(lambdaIdent.type); - return t; - } - break; - } - } - return null; - } - - /** - * The translatedSym is not complete/accurate until the analysis is - * finished. Once the analysis is finished, the translatedSym is - * "completed" -- updated with type information, access modifiers, - * and full parameter list. - */ - void complete() { - if (syntheticParams != null) { - return; - } - boolean inInterface = translatedSym.owner.isInterface(); - boolean thisReferenced = !getSymbolMap(CAPTURED_THIS).isEmpty(); - - // If instance access isn't needed, make it static. - // Interface instance methods must be default methods. - // Lambda methods are private synthetic. - // Inherit ACC_STRICT from the enclosing method, or, for clinit, - // from the class. - translatedSym.flags_field = SYNTHETIC | LAMBDA_METHOD | - owner.flags_field & STRICTFP | - owner.owner.flags_field & STRICTFP | - PRIVATE | - (thisReferenced? (inInterface? DEFAULT : 0) : STATIC); - - //compute synthetic params - ListBuffer params = new ListBuffer<>(); - ListBuffer parameterSymbols = new ListBuffer<>(); - - // The signature of the method is augmented with the following - // synthetic parameters: - // - // 1) reference to enclosing contexts captured by the lambda expression - // 2) enclosing locals captured by the lambda expression - for (Symbol thisSym : getSymbolMap(CAPTURED_VAR).values()) { - params.append(make.VarDef((VarSymbol) thisSym, null)); - parameterSymbols.append((VarSymbol) thisSym); - } - for (Symbol thisSym : getSymbolMap(PARAM).values()) { - params.append(make.VarDef((VarSymbol) thisSym, null)); - parameterSymbols.append((VarSymbol) thisSym); - } - syntheticParams = params.toList(); - - translatedSym.params = parameterSymbols.toList(); - - // Compute and set the lambda name - translatedSym.name = isSerializable() - ? serializedLambdaName() - : lambdaName(); - - //prepend synthetic args to translated lambda method signature - translatedSym.type = types.createMethodTypeWithParameters( - generatedLambdaSig(), - TreeInfo.types(syntheticParams)); - } - - Type generatedLambdaSig() { - return types.erasure(tree.getDescriptorType(types)); - } - } - - /** - * Simple subclass modelling the translation context of a method reference. - */ - final class ReferenceTranslationContext extends TranslationContext { - - ReferenceTranslationContext(JCMemberReference tree) { - super(tree); + return types.asSuper(tree.target, syms.serializableType.tsym) != null; + } + + void dumpStats(JCFunctionalExpression tree, boolean needsAltMetafactory, Symbol sym) { + if (dumpLambdaToMethodStats) { + if (tree instanceof JCLambda lambda) { + log.note(tree, diags.noteKey(lambda.wasMethodReference ? "mref.stat.1" : "lambda.stat", + needsAltMetafactory, sym)); + } else if (tree instanceof JCMemberReference) { + log.note(tree, Notes.MrefStat(needsAltMetafactory, null)); } } } - // - /* - * These keys provide mappings for various translated lambda symbols - * and the prevailing order must be maintained. + /** + * This class retains all the useful information about a lambda expression, + * and acts as a translation map that is used by the main translation routines + * in order to adjust references to captured locals/members, etc. */ - enum LambdaSymbolKind { - PARAM, // original to translated lambda parameters - LOCAL_VAR, // original to translated lambda locals - CAPTURED_VAR, // variables in enclosing scope to translated synthetic parameters - CAPTURED_THIS; // class symbols to translated synthetic parameters (for captured member access) + class LambdaTranslationContext { - boolean propagateAnnotations() { - switch (this) { + /** the underlying (untranslated) tree */ + final JCFunctionalExpression tree; + + /** a translation map from source symbols to translated symbols */ + final Map lambdaProxies = new HashMap<>(); + + /** the list of symbols captured by this lambda expression */ + final List capturedVars; + + /** the synthetic symbol for the method hoisting the translated lambda */ + final MethodSymbol translatedSym; + + /** the list of parameter declarations of the translated lambda method */ + final List syntheticParams; + + LambdaTranslationContext(JCLambda tree) { + this.tree = tree; + // This symbol will be filled-in in complete + Symbol owner = tree.owner; + if (owner.kind == MTH) { + final MethodSymbol originalOwner = (MethodSymbol)owner.clone(owner.owner); + this.translatedSym = new MethodSymbol(0, null, null, owner.enclClass()) { + @Override + public MethodSymbol originalEnclosingMethod() { + return originalOwner; + } + }; + } else { + this.translatedSym = makePrivateSyntheticMethod(0, null, null, owner.enclClass()); + } + ListBuffer params = new ListBuffer<>(); + ListBuffer parameterSymbols = new ListBuffer<>(); + LambdaCaptureScanner captureScanner = new LambdaCaptureScanner(tree); + capturedVars = captureScanner.analyzeCaptures(); + for (VarSymbol captured : capturedVars) { + VarSymbol trans = addSymbol(captured, LambdaSymbolKind.CAPTURED_VAR); + params.append(make.VarDef(trans, null)); + parameterSymbols.add(trans); + } + for (JCVariableDecl param : tree.params) { + VarSymbol trans = addSymbol(param.sym, LambdaSymbolKind.PARAM); + params.append(make.VarDef(trans, null)); + parameterSymbols.add(trans); + } + syntheticParams = params.toList(); + completeLambdaMethodSymbol(owner, captureScanner.capturesThis); + translatedSym.params = parameterSymbols.toList(); + } + + void completeLambdaMethodSymbol(Symbol owner, boolean thisReferenced) { + boolean inInterface = owner.enclClass().isInterface(); + + // Compute and set the lambda name + Name name = isSerializable(tree) + ? serializedLambdaName(owner) + : lambdaName(owner); + + //prepend synthetic args to translated lambda method signature + Type type = types.createMethodTypeWithParameters( + generatedLambdaSig(), + TreeInfo.types(syntheticParams)); + + // If instance access isn't needed, make it static. + // Interface instance methods must be default methods. + // Lambda methods are private synthetic. + // Inherit ACC_STRICT from the enclosing method, or, for clinit, + // from the class. + long flags = SYNTHETIC | LAMBDA_METHOD | + owner.flags_field & STRICTFP | + owner.owner.flags_field & STRICTFP | + PRIVATE | + (thisReferenced? (inInterface? DEFAULT : 0) : STATIC); + + translatedSym.type = type; + translatedSym.name = name; + translatedSym.flags_field = flags; + } + + /** + * For a serializable lambda, generate a disambiguating string + * which maximizes stability across deserialization. + * + * @return String to differentiate synthetic lambda method names + */ + private String serializedLambdaDisambiguation(Symbol owner) { + StringBuilder buf = new StringBuilder(); + // Append the enclosing method signature to differentiate + // overloaded enclosing methods. For lambdas enclosed in + // lambdas, the generated lambda method will not have type yet, + // but the enclosing method's name will have been generated + // with this same method, so it will be unique and never be + // overloaded. + Assert.check( + owner.type != null || + lambdaContext != null); + if (owner.type != null) { + buf.append(typeSig(owner.type, true)); + buf.append(":"); + } + + // Add target type info + buf.append(types.findDescriptorSymbol(tree.type.tsym).owner.flatName()); + buf.append(" "); + + // Add variable assigned to + if (pendingVar != null) { + buf.append(pendingVar.flatName()); + buf.append("="); + } + //add captured locals info: type, name, order + for (Symbol fv : capturedVars) { + if (fv != owner) { + buf.append(typeSig(fv.type, true)); + buf.append(" "); + buf.append(fv.flatName()); + buf.append(","); + } + } + + return buf.toString(); + } + + /** + * For a non-serializable lambda, generate a simple method. + * + * @return Name to use for the synthetic lambda method name + */ + private Name lambdaName(Symbol owner) { + StringBuilder buf = new StringBuilder(); + buf.append(names.lambda); + buf.append(syntheticMethodNameComponent(owner)); + buf.append("$"); + buf.append(kInfo.syntheticNameIndex(buf, 0)); + return names.fromString(buf.toString()); + } + + /** + * @return Method name in a form that can be folded into a + * component of a synthetic method name + */ + String syntheticMethodNameComponent(Symbol owner) { + long ownerFlags = owner.flags(); + if ((ownerFlags & BLOCK) != 0) { + return (ownerFlags & STATIC) != 0 ? + "static" : "new"; + } else if (owner.isConstructor()) { + return "new"; + } else { + return owner.name.toString(); + } + } + + /** + * For a serializable lambda, generate a method name which maximizes + * name stability across deserialization. + * + * @return Name to use for the synthetic lambda method name + */ + private Name serializedLambdaName(Symbol owner) { + StringBuilder buf = new StringBuilder(); + buf.append(names.lambda); + // Append the name of the method enclosing the lambda. + buf.append(syntheticMethodNameComponent(owner)); + buf.append('$'); + // Append a hash of the disambiguating string : enclosing method + // signature, etc. + String disam = serializedLambdaDisambiguation(owner); + buf.append(Integer.toHexString(disam.hashCode())); + buf.append('$'); + // The above appended name components may not be unique, append + // a count based on the above name components. + buf.append(kInfo.syntheticNameIndex(buf, 1)); + String result = buf.toString(); + //System.err.printf("serializedLambdaName: %s -- %s\n", result, disam); + return names.fromString(result); + } + + /** + * Translate a symbol of a given kind into something suitable for the + * synthetic lambda body + */ + VarSymbol translate(final VarSymbol sym, LambdaSymbolKind skind) { + VarSymbol ret; + boolean propagateAnnos = true; + switch (skind) { case CAPTURED_VAR: - case CAPTURED_THIS: - return false; + Name name = (sym.flags() & LOCAL_CAPTURE_FIELD) != 0 ? + sym.baseSymbol().name : sym.name; + ret = new VarSymbol(SYNTHETIC | FINAL | PARAMETER, name, types.erasure(sym.type), translatedSym); + propagateAnnos = false; + break; + case LOCAL_VAR: + ret = new VarSymbol(sym.flags() & FINAL, sym.name, sym.type, translatedSym); + ret.pos = sym.pos; + // If sym.data == ElementKind.EXCEPTION_PARAMETER, + // set ret.data = ElementKind.EXCEPTION_PARAMETER too. + // Because method com.sun.tools.javac.jvm.Code.fillExceptionParameterPositions and + // com.sun.tools.javac.jvm.Code.fillLocalVarPosition would use it. + // See JDK-8257740 for more information. + if (sym.isExceptionParameter()) { + ret.setData(ElementKind.EXCEPTION_PARAMETER); + } + break; + case PARAM: + ret = new VarSymbol((sym.flags() & FINAL) | PARAMETER, sym.name, types.erasure(sym.type), translatedSym); + ret.pos = sym.pos; + break; default: - return true; - } + Assert.error(skind.name()); + throw new AssertionError(); + } + if (ret != sym && propagateAnnos) { + ret.setDeclarationAttributes(sym.getRawAttributes()); + ret.setTypeAttributes(sym.getRawTypeAttributes()); + } + return ret; + } + + VarSymbol addLocal(VarSymbol sym) { + return addSymbol(sym, LambdaSymbolKind.LOCAL_VAR); + } + + private VarSymbol addSymbol(VarSymbol sym, LambdaSymbolKind skind) { + return lambdaProxies.computeIfAbsent(sym, s -> translate(s, skind)); + } + + JCTree translate(JCIdent lambdaIdent) { + Symbol tSym = lambdaProxies.get(lambdaIdent.sym); + return tSym != null ? + make.Ident(tSym).setType(lambdaIdent.type) : + null; + } + + Type generatedLambdaSig() { + return types.erasure(tree.getDescriptorType(types)); + } + + /** + * Compute the set of local variables captured by this lambda expression. + * Also determines whether this lambda expression captures the enclosing 'this'. + */ + class LambdaCaptureScanner extends CaptureScanner { + boolean capturesThis; + Set seenClasses = new HashSet<>(); + + LambdaCaptureScanner(JCLambda ownerTree) { + super(ownerTree); + } + + @Override + public void visitClassDef(JCClassDecl tree) { + seenClasses.add(tree.sym); + super.visitClassDef(tree); + } + + @Override + public void visitIdent(JCIdent tree) { + if (!tree.sym.isStatic() && + tree.sym.owner.kind == TYP && + (tree.sym.kind == VAR || tree.sym.kind == MTH) && + !seenClasses.contains(tree.sym.owner)) { + if ((tree.sym.flags() & LOCAL_CAPTURE_FIELD) != 0) { + // a local, captured by Lower - re-capture! + addFreeVar((VarSymbol) tree.sym); + } else { + // a reference to an enclosing field or method, we need to capture 'this' + capturesThis = true; + } + } else { + // might be a local capture + super.visitIdent(tree); + } + } + + @Override + public void visitSelect(JCFieldAccess tree) { + if (tree.sym.kind == VAR && + (tree.sym.name == names._this || + tree.sym.name == names._super) && + !seenClasses.contains(tree.sym.type.tsym)) { + capturesThis = true; + } + super.visitSelect(tree); + } + + @Override + public void visitAnnotation(JCAnnotation tree) { + // do nothing (annotation values look like captured instance fields) + } + } + + /* + * These keys provide mappings for various translated lambda symbols + * and the prevailing order must be maintained. + */ + enum LambdaSymbolKind { + PARAM, // original to translated lambda parameters + LOCAL_VAR, // original to translated lambda locals + CAPTURED_VAR; // variables in enclosing scope to translated synthetic parameters } } @@ -1791,7 +1304,7 @@ public class LambdaToMethod extends TreeTranslator { /** * Are signatures incompatible with JVM spec allowed? - * Used by {@link LambdaTranslationContext#serializedLambdaDisambiguation()}. + * Used by {@link LambdaTranslationContext#serializedLambdaDisambiguation(Symbol)}}. */ boolean allowIllegalSignatures; diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java index c5fd2177d49..62117583a96 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java @@ -267,26 +267,22 @@ public class Lower extends TreeTranslator { Map> freevarCache; /** A navigator class for collecting the free variables accessed - * from a local class. There is only one case; all other cases simply - * traverse down the tree. This class doesn't deal with the specific - * of Lower - it's an abstract visitor that is meant to be reused in - * order to share the local variable capture logic. + * from a local class. */ - abstract class BasicFreeVarCollector extends TreeScanner { + class FreeVarCollector extends CaptureScanner { - /** Add all free variables of class c to fvs list - * unless they are already there. - */ - abstract void addFreeVars(ClassSymbol c); - - /** If tree refers to a variable in owner of local class, add it to - * free variables list. - */ - public void visitIdent(JCIdent tree) { - visitSymbol(tree.sym); + FreeVarCollector(JCTree ownerTree) { + super(ownerTree); + } + + void addFreeVars(ClassSymbol c) { + List fvs = freevarCache.get(c); + if (fvs != null) { + for (List l = fvs; l.nonEmpty(); l = l.tail) { + addFreeVar(l.head); + } + } } - // where - abstract void visitSymbol(Symbol _sym); /** If tree refers to a class instance creation expression * add all free variables of the freshly created class. @@ -306,84 +302,6 @@ public class Lower extends TreeTranslator { } super.visitApply(tree); } - - @Override - public void visitYield(JCYield tree) { - scan(tree.value); - } - - } - - /** - * Lower-specific subclass of {@code BasicFreeVarCollector}. - */ - class FreeVarCollector extends BasicFreeVarCollector { - - /** The owner of the local class. - */ - Symbol owner; - - /** The local class. - */ - ClassSymbol clazz; - - /** The list of owner's variables accessed from within the local class, - * without any duplicates. - */ - List fvs; - - FreeVarCollector(ClassSymbol clazz) { - this.clazz = clazz; - this.owner = clazz.owner; - this.fvs = List.nil(); - } - - /** Add free variable to fvs list unless it is already there. - */ - private void addFreeVar(VarSymbol v) { - for (List l = fvs; l.nonEmpty(); l = l.tail) - if (l.head == v) return; - fvs = fvs.prepend(v); - } - - @Override - void addFreeVars(ClassSymbol c) { - List fvs = freevarCache.get(c); - if (fvs != null) { - for (List l = fvs; l.nonEmpty(); l = l.tail) { - addFreeVar(l.head); - } - } - } - - @Override - void visitSymbol(Symbol _sym) { - Symbol sym = _sym; - if (sym.kind == VAR || sym.kind == MTH) { - if (sym != null && sym.owner != owner) - sym = proxies.get(sym); - if (sym != null && sym.owner == owner) { - VarSymbol v = (VarSymbol)sym; - if (v.getConstValue() == null) { - addFreeVar(v); - } - } - } - } - } - - ClassSymbol ownerToCopyFreeVarsFrom(ClassSymbol c) { - if (!c.isDirectlyOrIndirectlyLocal()) { - return null; - } - Symbol currentOwner = c.owner; - while (currentOwner.owner.kind.matches(KindSelector.TYP) && currentOwner.isDirectlyOrIndirectlyLocal()) { - currentOwner = currentOwner.owner; - } - if (currentOwner.owner.kind.matches(KindSelector.VAL_MTH) && c.isSubClass(currentOwner, types)) { - return (ClassSymbol)currentOwner; - } - return null; } /** Return the variables accessed from within a local class, which @@ -395,22 +313,10 @@ public class Lower extends TreeTranslator { if (fvs != null) { return fvs; } - if (c.owner.kind.matches(KindSelector.VAL_MTH) && !c.isStatic()) { - FreeVarCollector collector = new FreeVarCollector(c); - collector.scan(classDef(c)); - fvs = collector.fvs; - freevarCache.put(c, fvs); - return fvs; - } else { - ClassSymbol owner = ownerToCopyFreeVarsFrom(c); - if (owner != null) { - fvs = freevarCache.get(owner); - freevarCache.put(c, fvs); - return fvs; - } else { - return List.nil(); - } - } + FreeVarCollector collector = new FreeVarCollector(classDef(c)); + fvs = collector.analyzeCaptures().reverse(); + freevarCache.put(c, fvs); + return fvs; } Map enumSwitchMap = new LinkedHashMap<>(); @@ -1501,7 +1407,7 @@ public class Lower extends TreeTranslator { * @param owner The class in which the definitions go. */ List freevarDefs(int pos, List freevars, Symbol owner) { - return freevarDefs(pos, freevars, owner, 0); + return freevarDefs(pos, freevars, owner, LOCAL_CAPTURE_FIELD); } List freevarDefs(int pos, List freevars, Symbol owner, @@ -1517,7 +1423,12 @@ public class Lower extends TreeTranslator { proxyName = proxyName(v.name, index++); } while (!proxyNames.add(proxyName)); VarSymbol proxy = new VarSymbol( - flags, proxyName, v.erasure(types), owner); + flags, proxyName, v.erasure(types), owner) { + @Override + public Symbol baseSymbol() { + return v; + } + }; proxies.put(v, proxy); JCVariableDecl vd = make.at(pos).VarDef(proxy, null); vd.vartype = access(vd.vartype); diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java index 5bf1bc0ead1..55293535ff8 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java @@ -1853,6 +1853,10 @@ public class Resolve { bestSoFar, allowBoxing, useVarargs); + if (bestSoFar.kind == AMBIGUOUS) { + AmbiguityError a_err = (AmbiguityError)bestSoFar.baseSymbol(); + bestSoFar = a_err.mergeAbstracts(site); + } return bestSoFar; } // where @@ -2757,7 +2761,7 @@ public class Resolve { return lookupMethod(env, pos, env.enclClass.sym, resolveMethodCheck, new BasicLookupHelper(name, env.enclClass.sym.type, argtypes, typeargtypes) { @Override - Symbol doLookup(Env env, MethodResolutionPhase phase) { + Symbol lookup(Env env, MethodResolutionPhase phase) { return findFun(env, name, argtypes, typeargtypes, phase.isBoxingRequired(), phase.isVarargsRequired()); @@ -2789,7 +2793,7 @@ public class Resolve { List typeargtypes) { return lookupMethod(env, pos, location, resolveContext, new BasicLookupHelper(name, site, argtypes, typeargtypes) { @Override - Symbol doLookup(Env env, MethodResolutionPhase phase) { + Symbol lookup(Env env, MethodResolutionPhase phase) { return findMethod(env, site, name, argtypes, typeargtypes, phase.isBoxingRequired(), phase.isVarargsRequired()); @@ -2913,7 +2917,7 @@ public class Resolve { List typeargtypes) { return lookupMethod(env, pos, site.tsym, resolveContext, new BasicLookupHelper(names.init, site, argtypes, typeargtypes) { @Override - Symbol doLookup(Env env, MethodResolutionPhase phase) { + Symbol lookup(Env env, MethodResolutionPhase phase) { return findConstructor(pos, env, site, argtypes, typeargtypes, phase.isBoxingRequired(), phase.isVarargsRequired()); @@ -2972,7 +2976,7 @@ public class Resolve { return lookupMethod(env, pos, site.tsym, resolveMethodCheck, new BasicLookupHelper(names.init, site, argtypes, typeargtypes) { @Override - Symbol doLookup(Env env, MethodResolutionPhase phase) { + Symbol lookup(Env env, MethodResolutionPhase phase) { return findDiamond(pos, env, site, argtypes, typeargtypes, phase.isBoxingRequired(), phase.isVarargsRequired()); @@ -3503,18 +3507,6 @@ public class Resolve { super(name, site, argtypes, typeargtypes, maxPhase); } - @Override - final Symbol lookup(Env env, MethodResolutionPhase phase) { - Symbol sym = doLookup(env, phase); - if (sym.kind == AMBIGUOUS) { - AmbiguityError a_err = (AmbiguityError)sym.baseSymbol(); - sym = a_err.mergeAbstracts(site); - } - return sym; - } - - abstract Symbol doLookup(Env env, MethodResolutionPhase phase); - @Override Symbol access(Env env, DiagnosticPosition pos, Symbol location, Symbol sym) { if (sym.kind.isResolutionError()) { @@ -3561,10 +3553,6 @@ public class Resolve { abstract JCMemberReference.ReferenceKind referenceKind(Symbol sym); Symbol access(Env env, DiagnosticPosition pos, Symbol location, Symbol sym) { - if (sym.kind == AMBIGUOUS) { - AmbiguityError a_err = (AmbiguityError)sym.baseSymbol(); - sym = a_err.mergeAbstracts(site); - } //skip error reporting return sym; } diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransTypes.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransTypes.java index bfe35dbec9c..d232f2e6d9f 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransTypes.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransTypes.java @@ -679,6 +679,7 @@ public class TransTypes extends TreeTranslator { JCLambda slam = make.Lambda(params.toList(), expr); slam.target = tree.target; + slam.owner = tree.owner; slam.type = tree.type; slam.pos = tree.pos; slam.wasMethodReference = true; diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java index bd05cf91e91..6abf9f057b0 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java @@ -218,6 +218,12 @@ public class ClassReader { */ int[] parameterAccessFlags; + /** + * A table to hold the access flags of the method parameters, + * for all parameters including synthetic and mandated ones. + */ + int[] allParameterAccessFlags; + /** * A table to hold annotations for method parameters. */ @@ -1146,12 +1152,15 @@ public class ClassReader { int newbp = bp + attrlen; if (saveParameterNames) { int numEntries = nextByte(); + allParameterAccessFlags = new int[numEntries]; parameterNameIndicesMp = new int[numEntries]; parameterAccessFlags = new int[numEntries]; + int allParamIndex = 0; int index = 0; for (int i = 0; i < numEntries; i++) { int nameIndex = nextChar(); int flags = nextChar(); + allParameterAccessFlags[allParamIndex++] = flags; if ((flags & (Flags.MANDATED | Flags.SYNTHETIC)) != 0) { continue; } @@ -1593,7 +1602,16 @@ public class ClassReader { if (parameterAnnotations == null) { parameterAnnotations = new ParameterAnnotations[numParameters]; } else if (parameterAnnotations.length != numParameters) { - throw badClassFile("bad.runtime.invisible.param.annotations", meth); + //the RuntimeVisibleParameterAnnotations and RuntimeInvisibleParameterAnnotations + //provide annotations for a different number of parameters, ignore: + if (lintClassfile) { + log.warning(LintCategory.CLASSFILE, Warnings.RuntimeVisibleInvisibleParamAnnotationsMismatch(currentClassFile)); + } + for (int pnum = 0; pnum < numParameters; pnum++) { + readAnnotations(); + } + parameterAnnotations = null; + return ; } for (int pnum = 0; pnum < numParameters; pnum++) { if (parameterAnnotations[pnum] == null) { @@ -2334,6 +2352,12 @@ public class ClassReader { this.attributes = attributes; } + /** + * A supertype_index value of 65535 specifies that the annotation appears on the superclass + * in an extends clause of a class declaration, see JVMS 4.7.20.1 + */ + public static final int SUPERCLASS_INDEX = 65535; + @Override public Void visitClassSymbol(Symbol.ClassSymbol s, Void unused) { ClassType t = (ClassType) s.type; @@ -2343,7 +2367,7 @@ public class ClassReader { interfaces.add(addTypeAnnotations(itf, classExtends(i++))); } t.interfaces_field = interfaces.toList(); - t.supertype_field = addTypeAnnotations(t.supertype_field, classExtends(65535)); + t.supertype_field = addTypeAnnotations(t.supertype_field, classExtends(SUPERCLASS_INDEX)); if (t.typarams_field != null) { t.typarams_field = rewriteTypeParameters( @@ -2623,7 +2647,8 @@ public class ClassReader { char rawFlags = nextChar(); long flags = adjustMethodFlags(rawFlags); Name name = poolReader.getName(nextChar()); - Type type = poolReader.getType(nextChar()); + Type descriptorType = poolReader.getType(nextChar()); + Type type = descriptorType; if (currentOwner.isInterface() && (flags & ABSTRACT) == 0 && !name.equals(names.clinit)) { if (majorVersion > Version.V52.major || @@ -2640,6 +2665,7 @@ public class ClassReader { } } validateMethodType(name, type); + boolean forceLocal = false; if (name == names.init && currentOwner.hasOuterInstance()) { // Sometimes anonymous classes don't have an outer // instance, however, there is no reliable way to tell so @@ -2647,7 +2673,8 @@ public class ClassReader { // ditto for local classes. Local classes that have an enclosing method set // won't pass the "hasOuterInstance" check above, but those that don't have an // enclosing method (i.e. from initializers) will pass that check. - boolean local = !currentOwner.owner.members().includes(currentOwner, LookupKind.NON_RECURSIVE); + boolean local = forceLocal = + !currentOwner.owner.members().includes(currentOwner, LookupKind.NON_RECURSIVE); if (!currentOwner.name.isEmpty() && !local) type = new MethodType(adjustMethodParams(flags, type.getParameterTypes()), type.getReturnType(), @@ -2668,6 +2695,7 @@ public class ClassReader { currentOwner = prevOwner; } validateMethodType(name, m.type); + adjustParameterAnnotations(m, descriptorType, forceLocal); setParameters(m, type); if (Integer.bitCount(rawFlags & (PUBLIC | PRIVATE | PROTECTED)) > 1) @@ -2795,17 +2823,141 @@ public class ClassReader { nameIndexMp++; annotationIndex++; } - if (parameterAnnotations != null && parameterAnnotations.length != annotationIndex) { - throw badClassFile("bad.runtime.invisible.param.annotations", sym); - } + Assert.check(parameterAnnotations == null || + parameterAnnotations.length == annotationIndex); Assert.checkNull(sym.params); sym.params = params.toList(); parameterAnnotations = null; parameterNameIndicesLvt = null; parameterNameIndicesMp = null; + allParameterAccessFlags = null; parameterAccessFlags = null; } + void adjustParameterAnnotations(MethodSymbol sym, Type methodDescriptor, + boolean forceLocal) { + if (parameterAnnotations == null) { + return ; + } + + //the specification for Runtime(In)VisibleParameterAnnotations does not + //enforce any mapping between the method parameters and the recorded + //parameter annotation. Attempt a number of heuristics to adjust the + //adjust parameterAnnotations to the percieved number of parameters: + + int methodParameterCount = sym.type.getParameterTypes().size(); + + if (methodParameterCount == parameterAnnotations.length) { + //we've got exactly as many parameter annotations as are parameters + //of the method (after considering a possible Signature attribute), + //no need to do anything. the parameter creation code will use + //the 1-1 mapping to restore the annotations: + return ; + } + + if (allParameterAccessFlags != null) { + //MethodParameters attribute present, use it: + + //count the number of non-synthetic and non-mandatory parameters: + int realParameters = 0; + + for (int i = 0; i < allParameterAccessFlags.length; i++) { + if ((allParameterAccessFlags[i] & (SYNTHETIC | MANDATED)) == 0) { + realParameters++; + } + } + + int methodDescriptorParameterCount = methodDescriptor.getParameterTypes().size(); + + if (realParameters == parameterAnnotations.length && + allParameterAccessFlags.length == methodDescriptorParameterCount) { + //if we have parameter annotations for each non-synthetic/mandatory parameter, + //and if Signature was not present, expand the parameterAnnotations to cover + //all the method descriptor's parameters: + if (sym.type == methodDescriptor) { + ParameterAnnotations[] newParameterAnnotations = + new ParameterAnnotations[methodParameterCount]; + int srcIndex = 0; + + for (int i = 0; i < methodParameterCount; i++) { + if ((allParameterAccessFlags[i] & (SYNTHETIC | MANDATED)) == 0) { + newParameterAnnotations[i] = parameterAnnotations[srcIndex++]; + } + } + + parameterAnnotations = newParameterAnnotations; + } else { + dropParameterAnnotations(); + } + } else if (realParameters == methodParameterCount && + methodDescriptorParameterCount == parameterAnnotations.length && + allParameterAccessFlags.length == methodDescriptorParameterCount) { + //if there are as many parameter annotations as parameters in + //the method descriptor, and as many real parameters as parameters + //in the method's type (after accounting for Signature), shrink + //the parameterAnnotations to only cover the parameters from + //the method's type: + ParameterAnnotations[] newParameterAnnotations = + new ParameterAnnotations[methodParameterCount]; + int targetIndex = 0; + + for (int i = 0; i < parameterAnnotations.length; i++) { + if ((allParameterAccessFlags[i] & (SYNTHETIC | MANDATED)) == 0) { + newParameterAnnotations[targetIndex++] = parameterAnnotations[i]; + } + } + + parameterAnnotations = newParameterAnnotations; + } else { + dropParameterAnnotations(); + } + return ; + } + + if (!sym.isConstructor()) { + //if the number of parameter annotations and the number of parameters + //don't match, we don't have any heuristics to map one to the other + //unless the method is a constructor: + dropParameterAnnotations(); + return ; + } + + if (sym.owner.isEnum()) { + if (methodParameterCount == parameterAnnotations.length + 2 && + sym.type == methodDescriptor) { + //handle constructors of enum types without the Signature attribute - + //there are the two synthetic parameters (name and ordinal) in the + //constructor, but there may be only parameter annotations for the + //real non-synthetic parameters: + ParameterAnnotations[] newParameterAnnotations = new ParameterAnnotations[parameterAnnotations.length + 2]; + System.arraycopy(parameterAnnotations, 0, newParameterAnnotations, 2, parameterAnnotations.length); + parameterAnnotations = newParameterAnnotations; + return ; + } + } else if (sym.owner.isDirectlyOrIndirectlyLocal() || forceLocal) { + //local class may capture the enclosing instance (as the first parameter), + //and local variables (as trailing parameters) + //if there are less parameter annotations than parameters, put the existing + //ones starting with offset: + if (methodParameterCount > parameterAnnotations.length && + sym.type == methodDescriptor) { + ParameterAnnotations[] newParameterAnnotations = new ParameterAnnotations[methodParameterCount]; + System.arraycopy(parameterAnnotations, 0, newParameterAnnotations, 1, parameterAnnotations.length); + parameterAnnotations = newParameterAnnotations; + return ; + } + } + + //no heuristics worked, drop the annotations: + dropParameterAnnotations(); + } + + private void dropParameterAnnotations() { + parameterAnnotations = null; + if (lintClassfile) { + log.warning(LintCategory.CLASSFILE, Warnings.RuntimeInvisibleParameterAnnotations(currentClassFile)); + } + } /** * Creates the parameter at the position {@code mpIndex} in the parameter list of the owning method. * Flags are optionally read from the MethodParameters attribute. diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassWriter.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassWriter.java index dfa92efae74..6679bb43fb8 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassWriter.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassWriter.java @@ -329,7 +329,7 @@ public class ClassWriter extends ClassFile { int alenIdx = writeAttr(attributeName); ClassSymbol enclClass = c.owner.enclClass(); MethodSymbol enclMethod = - (c.owner.type == null // local to init block + ((c.owner.flags() & BLOCK) != 0 // local to init block || c.owner.kind != MTH) // or member init ? null : ((MethodSymbol)c.owner).originalEnclosingMethod(); diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/model/JavacTypes.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/model/JavacTypes.java index 1bc5de7f73a..71e39a6a408 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/model/JavacTypes.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/model/JavacTypes.java @@ -193,10 +193,14 @@ public class JavacTypes implements javax.lang.model.util.Types { public ArrayType getArrayType(TypeMirror componentType) { switch (componentType.getKind()) { case VOID: + case NONE: + case NULL: case EXECUTABLE: case WILDCARD: // heh! case PACKAGE: case MODULE: + case UNION: + case INTERSECTION: throw new IllegalArgumentException(componentType.toString()); } return new Type.ArrayType((Type) componentType, syms.arrayClass); diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/DocCommentParser.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/DocCommentParser.java index acd79c69bd4..be311bb3ab8 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/DocCommentParser.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/DocCommentParser.java @@ -286,16 +286,17 @@ public class DocCommentParser { int depth = 1; // only used when phase is INLINE int pos = bp; // only used when phase is INLINE + if (textKind == DocTree.Kind.MARKDOWN) { + initMarkdownLine(); + } + loop: while (bp < buflen) { switch (ch) { case '\n', '\r' -> { nextChar(); if (textKind == DocTree.Kind.MARKDOWN) { - markdown.update(); - if (markdown.isIndentedCodeBlock()) { - markdown.skipLine(); - } + initMarkdownLine(); } } @@ -488,6 +489,17 @@ public class DocCommentParser { nextChar(); } + void initMarkdownLine() { + if (textStart == -1) { + textStart = bp; + } + markdown.update(); + if (markdown.isIndentedCodeBlock()) { + markdown.skipLine(); + lastNonWhite = bp - 1; // do not include newline or EOF + } + } + private IllegalStateException unknownTextKind(DocTree.Kind textKind) { return new IllegalStateException(textKind.toString()); } diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties index 7e41f43aeb2..a991ae60601 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties @@ -2547,8 +2547,17 @@ compiler.misc.bad.enclosing.class=\ compiler.misc.bad.enclosing.method=\ bad enclosing method attribute for class {0} -compiler.misc.bad.runtime.invisible.param.annotations=\ - bad RuntimeInvisibleParameterAnnotations attribute: {0} +# 0: file name +compiler.warn.runtime.visible.invisible.param.annotations.mismatch=\ + the length of parameters in RuntimeVisibleParameterAnnotations attribute and \ + RuntimeInvisibleParameterAnnotations attribute in: {0} \ + do not match, ignoring both attributes + +# 0: file name +compiler.warn.runtime.invisible.parameter.annotations=\ + the RuntimeVisibleParameterAnnotations and RuntimeInvisibleParameterAnnotations attributes \ + in: {0} \ + cannot be mapped to the method''s parameters compiler.misc.bad.const.pool.tag=\ bad constant pool tag: {0} diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/DocTreeMaker.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/DocTreeMaker.java index 77f6eefc073..9e0767b6e21 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/DocTreeMaker.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/DocTreeMaker.java @@ -592,27 +592,33 @@ public class DocTreeMaker implements DocTreeFactory { case TEXT, MARKDOWN -> { var peekedNext = iter.hasNext() ? alist.get(iter.nextIndex()) : null; var content = getContent(dt); - int breakOffset = getSentenceBreak(dt.getKind(), content, peekedNext); - if (breakOffset > 0) { - // the end of sentence is within the current node; - // split it, skipping whitespace in between the two parts - var fsPart = newNode(dt.getKind(), dt.pos, content.substring(0, breakOffset).stripTrailing()); - fs.add(fsPart); - int wsOffset = skipWhiteSpace(content, breakOffset); - if (wsOffset > 0) { - var bodyPart = newNode(dt.getKind(), dt.pos + wsOffset, content.substring(wsOffset)); - body.add(bodyPart); - } - foundFirstSentence = true; - } else if (peekedNext != null && isSentenceBreak(peekedNext, false)) { - // the next node is a sentence break, so this is the end of the first sentence; - // remove trailing spaces - var fsPart = newNode(dt.getKind(), dt.pos, content.stripTrailing()); - fs.add(fsPart); + if (isFirst && dt.getKind() == Kind.MARKDOWN && isIndented(content)) { + // begins with an indented code block (unusual), so no first sentence + body.add(dt); foundFirstSentence = true; } else { - // no sentence break found; keep scanning - fs.add(dt); + int breakOffset = getSentenceBreak(dt.getKind(), content, peekedNext); + if (breakOffset > 0) { + // the end of sentence is within the current node; + // split it, skipping whitespace in between the two parts + var fsPart = newNode(dt.getKind(), dt.pos, content.substring(0, breakOffset).stripTrailing()); + fs.add(fsPart); + int wsOffset = skipWhiteSpace(content, breakOffset); + if (wsOffset > 0) { + var bodyPart = newNode(dt.getKind(), dt.pos + wsOffset, content.substring(wsOffset)); + body.add(bodyPart); + } + foundFirstSentence = true; + } else if (peekedNext != null && isSentenceBreak(peekedNext, false)) { + // the next node is a sentence break, so this is the end of the first sentence; + // remove trailing spaces + var fsPart = newNode(dt.getKind(), dt.pos, content.stripTrailing()); + fs.add(fsPart); + foundFirstSentence = true; + } else { + // no sentence break found; keep scanning + fs.add(dt); + } } } @@ -651,6 +657,11 @@ public class DocTreeMaker implements DocTreeFactory { }; } + private static final Pattern INDENT = Pattern.compile(" {4}| {0,3}\t"); + private boolean isIndented(String s) { + return INDENT.matcher(s).lookingAt(); + } + private DCTree newNode(DocTree.Kind kind, int pos, String text) { return switch (kind) { case TEXT -> m.at(pos).newTextTree(text); diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/JCTree.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/JCTree.java index 6f3b8b5d8aa..6041da6723a 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/JCTree.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/JCTree.java @@ -807,6 +807,8 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition { /** list of target types inferred for this functional expression. */ public Type target; + /** The owner of this functional expression. */ + public Symbol owner; public Type getDescriptorType(Types types) { return target != null ? types.findDescriptorType(target) : types.createErrorType(null); diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/Pretty.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/Pretty.java index e97d07b1d2b..919b2325ef6 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/Pretty.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/Pretty.java @@ -1467,7 +1467,7 @@ public class Pretty extends JCTree.Visitor { break; case CHAR: print('\''); - print(Convert.quote(String.valueOf((char)((Number)tree.value).intValue()))); + print(Convert.quote((char)((Number)tree.value).intValue(), true)); print('\''); break; case BOOLEAN: diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeScanner.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeScanner.java index 0336f3c4191..b9ae35da9df 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeScanner.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeScanner.java @@ -273,8 +273,8 @@ public class TreeScanner extends Visitor { } public void visitLambda(JCLambda tree) { - scan(tree.body); scan(tree.params); + scan(tree.body); } public void visitParens(JCParens tree) { diff --git a/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/SunPKCS11.java b/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/SunPKCS11.java index 4d10584fa09..44a2c4efb06 100644 --- a/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/SunPKCS11.java +++ b/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/SunPKCS11.java @@ -27,7 +27,7 @@ package sun.security.pkcs11; import java.io.*; import java.util.*; - +import java.util.stream.Collectors; import java.security.*; import java.security.interfaces.*; @@ -1272,7 +1272,11 @@ public final class SunPKCS11 extends AuthProvider { CKM_SHA3_512_RSA_PKCS_PSS); } } + long[] supportedMechanisms = p11.C_GetMechanismList(slotID); + Set supportedMechSet = + Arrays.stream(supportedMechanisms).boxed().collect + (Collectors.toCollection(HashSet::new)); // Create a map from the various Descriptors to the "most // preferred" mechanism that was defined during the @@ -1281,10 +1285,9 @@ public final class SunPKCS11 extends AuthProvider { // the earliest entry. When asked for "DES/CBC/PKCS5Padding", we // return a CKM_DES_CBC_PAD. final Map supportedAlgs = - new HashMap(); + new HashMap(); - for (int i = 0; i < supportedMechanisms.length; i++) { - long longMech = supportedMechanisms[i]; + for (long longMech : supportedMechanisms) { CK_MECHANISM_INFO mechInfo = token.getMechanismInfo(longMech); if (showInfo) { System.out.println("Mechanism " + @@ -1331,13 +1334,19 @@ public final class SunPKCS11 extends AuthProvider { for (Descriptor d : ds) { Integer oldMech = supportedAlgs.get(d); if (oldMech == null) { + // check all required mechs are supported if (d.requiredMechs != null) { - // Check that other mechanisms required for the - // service are supported before listing it as - // available for the first time. - for (int requiredMech : d.requiredMechs) { - if (token.getMechanismInfo( - requiredMech & 0xFFFFFFFFL) == null) { + for (int reqMech : d.requiredMechs) { + long longReqMech = reqMech & 0xFFFFFFFFL; + if (!config.isEnabled(longReqMech) || + !supportedMechSet.contains(longReqMech) || + brokenMechanisms.contains(longReqMech)) { + if (showInfo) { + System.out.println("DISABLED " + d.type + + " " + d.algorithm + + " due to no support for req'd mech " + + Functions.getMechanismName(longReqMech)); + } continue descLoop; } } @@ -1350,7 +1359,7 @@ public final class SunPKCS11 extends AuthProvider { (d.type == SIG && (mechInfo.flags & CKF_SIGN) == 0)) { if (showInfo) { - System.out.println("DISABLED " + d.type + + System.out.println("DISABLED " + d.type + " " + d.algorithm + " due to partial support"); } @@ -1374,7 +1383,6 @@ public final class SunPKCS11 extends AuthProvider { } } } - } // register algorithms in provider diff --git a/src/jdk.hotspot.agent/doc/index.html b/src/jdk.hotspot.agent/doc/index.html index 9a67ad1bf77..2e3ba38e4b8 100644 --- a/src/jdk.hotspot.agent/doc/index.html +++ b/src/jdk.hotspot.agent/doc/index.html @@ -21,8 +21,9 @@ There are three modes for the SA debugger:
                    • attaching to a local process
                    • opening a core file -
                    • attaching to a remote "debug server" +
                    • attaching to a remote "debug server" (deprecated)
                    +

                    WARNING: jhsdb debugd is deprecated and will be removed in a future release.

                    The remote case requires running the debug server on the remote machine. This is done by running "jhsdb debugd", and also adding arguments specifying the core diff --git a/src/jdk.hotspot.agent/doc/transported_core.html b/src/jdk.hotspot.agent/doc/transported_core.html index 7d8b2804d0a..9f932d9827f 100644 --- a/src/jdk.hotspot.agent/doc/transported_core.html +++ b/src/jdk.hotspot.agent/doc/transported_core.html @@ -21,6 +21,7 @@ debugging the core dump rather than transporting it to a different machine: it was produced on. This is done by first running jhsdb debugd on the machine with the core dump, and then attaching to it from another machine by using the jhsdb --connect argument. See the jhsdb man page for details. +

                    WARNING: jhsdb debugd is deprecated and will be removed in a future release.

                  diff --git a/src/jdk.hotspot.agent/linux/native/libsaproc/LinuxDebuggerLocal.cpp b/src/jdk.hotspot.agent/linux/native/libsaproc/LinuxDebuggerLocal.cpp index 962b1ae5172..0ad95d0eac7 100644 --- a/src/jdk.hotspot.agent/linux/native/libsaproc/LinuxDebuggerLocal.cpp +++ b/src/jdk.hotspot.agent/linux/native/libsaproc/LinuxDebuggerLocal.cpp @@ -420,7 +420,6 @@ JNIEXPORT jlongArray JNICALL Java_sun_jvm_hotspot_debugger_linux_LinuxDebuggerLo jboolean isCopy; jlongArray array; jlong *regs; - int i; struct ps_prochandle* ph = get_proc_handle(env, this_obj); if (get_lwp_regs(ph, lwp_id, &gregs) != true) { diff --git a/src/jdk.hotspot.agent/linux/native/libsaproc/symtab.c b/src/jdk.hotspot.agent/linux/native/libsaproc/symtab.c index d3b4d3d1af9..4cb791111bc 100644 --- a/src/jdk.hotspot.agent/linux/native/libsaproc/symtab.c +++ b/src/jdk.hotspot.agent/linux/native/libsaproc/symtab.c @@ -356,7 +356,6 @@ static struct symtab* build_symtab_internal(int fd, const char *filename, bool t if (shdr->sh_type == sym_section) { ELF_SYM *syms; - int rslt; size_t size, n, j, htab_sz; // FIXME: there could be multiple data buffers associated with the @@ -390,8 +389,9 @@ static struct symtab* build_symtab_internal(int fd, const char *filename, bool t goto bad; } - rslt = hcreate_r(htab_sz, symtab->hash_table); - // guarantee(rslt, "unexpected failure: hcreate_r"); + if (hcreate_r(htab_sz, symtab->hash_table) == 0) { + goto bad; + } // shdr->sh_link points to the section that contains the actual strings // for symbol names. the st_name field in ELF_SYM is just the diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/DebugServer.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/DebugServer.java index 220267acf90..2813a58c94d 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/DebugServer.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/DebugServer.java @@ -28,6 +28,7 @@ import sun.jvm.hotspot.debugger.*; import sun.jvm.hotspot.runtime.*; import sun.jvm.hotspot.oops.*; +@Deprecated(since="24", forRemoval=true) public class DebugServer { private void usage() { System.out.println("usage: java " + getClass().getName() + " [server id]"); @@ -42,9 +43,11 @@ public class DebugServer { } public static void main(String[] args) { + System.err.println("WARNING: DebugServer is deprecated and will be removed in a future release."); new DebugServer().run(args); } + @SuppressWarnings("removal") private void run(String[] args) { if ((args.length < 1) || (args.length > 3)) { usage(); diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/HotSpotAgent.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/HotSpotAgent.java index 71ed978199c..b9990828624 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/HotSpotAgent.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/HotSpotAgent.java @@ -204,6 +204,7 @@ public class HotSpotAgent { specific debuggee on the server. Allows to specify the port number to which the RMI connector is bound. If not specified a random available port is used. */ + @Deprecated(since="24", forRemoval=true) public synchronized void startServer(int processID, String serverID, String serverName, @@ -224,6 +225,7 @@ public class HotSpotAgent { starts a debug server, allowing remote machines to connect and examine this process. Uses specified name to uniquely identify a specific debuggee on the server */ + @Deprecated(since="24", forRemoval=true) public synchronized void startServer(int processID, String serverID, String serverName) { startServer(processID, serverID, serverName, 0); } @@ -231,6 +233,7 @@ public class HotSpotAgent { /** This attaches to a process running on the local machine and starts a debug server, allowing remote machines to connect and examine this process. */ + @Deprecated(since="24", forRemoval=true) public synchronized void startServer(int processID) throws DebuggerException { startServer(processID, null, null); @@ -241,6 +244,7 @@ public class HotSpotAgent { core file. Uses supplied uniqueID to uniquely identify a specific debuggee. Allows to specify the port number to which the RMI connector is bound. If not specified a random available port is used. */ + @Deprecated(since="24", forRemoval=true) public synchronized void startServer(String javaExecutableName, String coreFileName, String serverID, @@ -266,6 +270,7 @@ public class HotSpotAgent { server, allowing remote machines to connect and examine this core file. Uses supplied uniqueID to uniquely identify a specific debuggee */ + @Deprecated(since="24", forRemoval=true) public synchronized void startServer(String javaExecutableName, String coreFileName, String serverID, @@ -276,6 +281,7 @@ public class HotSpotAgent { /** This opens a core file on the local machine and starts a debug server, allowing remote machines to connect and examine this core file. */ + @Deprecated(since="24", forRemoval=true) public synchronized void startServer(String javaExecutableName, String coreFileName) throws DebuggerException { startServer(javaExecutableName, coreFileName, null, null); @@ -283,6 +289,7 @@ public class HotSpotAgent { /** This may only be called on the server side after startServer() has been called */ + @Deprecated(since="24", forRemoval=true) public synchronized boolean shutdownServer() throws DebuggerException { if (!isServer) { throw new DebuggerException("Should not call shutdownServer() for client configuration"); diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/SALauncher.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/SALauncher.java index b884058a3a2..cac3f0a1f61 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/SALauncher.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/SALauncher.java @@ -43,7 +43,7 @@ public class SALauncher { private static boolean launcherHelp() { System.out.println(" clhsdb \tcommand line debugger"); System.out.println(" hsdb \tui debugger"); - System.out.println(" debugd --help\tto get more information"); + System.out.println(" debugd --help\tto get more information (deprecated)"); System.out.println(" jstack --help\tto get more information"); System.out.println(" jmap --help\tto get more information"); System.out.println(" jinfo --help\tto get more information"); @@ -71,12 +71,14 @@ public class SALauncher { System.out.println(" --connect [@][:registryport][/servername] To connect to a remote debug server (debugd)."); } System.out.println(); + if (canConnectToRemote) { + System.out.println(" The --connect option is deprecated and will be removed in a future release."); + } System.out.println(" The --core and --exe options must be set together to give the core"); System.out.println(" file, and associated executable, to operate on. They can use"); System.out.println(" absolute or relative paths."); System.out.println(" The --pid option can be set to operate on a live process."); if (canConnectToRemote) { - System.out.println(" The --connect option can be set to connect to a debug server (debugd)."); System.out.println(" --core, --pid, and --connect are mutually exclusive."); } else { System.out.println(" --core and --pid are mutually exclusive."); @@ -91,6 +93,7 @@ public class SALauncher { } private static boolean debugdHelp() { + System.out.println("WARNING: debugd is deprecated and will be removed in a future release."); System.out.println(" --serverid A unique identifier for this debugd server."); System.out.println(" --servername Instance name of debugd server."); System.out.println(" --rmiport Sets the port number to which the RMI connector is bound." + @@ -213,6 +216,7 @@ public class SALauncher { newArgs.add(core); } else if (connect != NO_REMOTE) { + System.err.println("WARNING: --connect is deprecated and will be removed in a future release."); newArgs.add(connect); } @@ -361,7 +365,10 @@ public class SALauncher { JSnap.main(buildAttachArgs(newArgMap, false)); } + @SuppressWarnings("removal") private static void runDEBUGD(String[] args) { + System.err.println("WARNING: debugd is deprecated and will be removed in a future release."); + // By default SA agent classes prefer Windows process debugger // to windbg debugger. SA expects special properties to be set // to choose other debuggers. We will set those here before diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/CodeBlob.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/CodeBlob.java index 67e799b2712..90e4b5b98b4 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/CodeBlob.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/CodeBlob.java @@ -143,6 +143,8 @@ public class CodeBlob extends VMObject { public boolean isRuntimeStub() { return false; } + public boolean isUpcallStub() { return false; } + public boolean isDeoptimizationStub() { return false; } public boolean isUncommonTrapStub() { return false; } diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/CodeCache.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/CodeCache.java index 448372e2a36..e2eac930e02 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/CodeCache.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/CodeCache.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -60,6 +60,7 @@ public class CodeCache { virtualConstructor.addMapping("AdapterBlob", AdapterBlob.class); virtualConstructor.addMapping("MethodHandlesAdapterBlob", MethodHandlesAdapterBlob.class); virtualConstructor.addMapping("VtableBlob", VtableBlob.class); + virtualConstructor.addMapping("UpcallStub", UpcallStub.class); virtualConstructor.addMapping("SafepointBlob", SafepointBlob.class); virtualConstructor.addMapping("DeoptimizationBlob", DeoptimizationBlob.class); if (VM.getVM().isServerCompiler()) { diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/StubQueue.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/StubQueue.java index d59971b33ec..8d06a257e62 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/StubQueue.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/StubQueue.java @@ -52,8 +52,8 @@ public class StubQueue extends VMObject { private static CIntegerField queueEndField; private static CIntegerField numberOfStubsField; - // The type of the contained stubs (i.e., InterpreterCodelet, - // ICStub). Must be a subclass of type Stub. + // The type of the contained stubs (i.e., InterpreterCodelet). + // Must be a subclass of type Stub. private Class stubType; static { diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/UpcallStub.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/UpcallStub.java new file mode 100644 index 00000000000..4e324ba38e4 --- /dev/null +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/UpcallStub.java @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +package sun.jvm.hotspot.code; + +import java.util.*; +import sun.jvm.hotspot.debugger.*; +import sun.jvm.hotspot.runtime.*; +import sun.jvm.hotspot.types.*; +import sun.jvm.hotspot.utilities.Observable; +import sun.jvm.hotspot.utilities.Observer; + +public class UpcallStub extends RuntimeBlob { + + private static CIntegerField frameDataOffsetField; + private static AddressField lastJavaFPField; + private static AddressField lastJavaSPField; + private static AddressField lastJavaPCField; + + static { + VM.registerVMInitializedObserver(new Observer() { + public void update(Observable o, Object data) { + initialize(VM.getVM().getTypeDataBase()); + } + }); + } + + private static void initialize(TypeDataBase db) { + Type type = db.lookupType("UpcallStub"); + frameDataOffsetField = type.getCIntegerField("_frame_data_offset"); + + Type anchorType = db.lookupType("JavaFrameAnchor"); + lastJavaSPField = anchorType.getAddressField("_last_Java_sp"); + lastJavaPCField = anchorType.getAddressField("_last_Java_pc"); + + try { + lastJavaFPField = anchorType.getAddressField("_last_Java_fp"); + } catch (Exception e) { + // Some platforms (e.g. PPC64) does not have this field. + lastJavaFPField = null; + } + } + + public UpcallStub(Address addr) { + super(addr); + } + + protected Address getJavaFrameAnchor(Frame frame) { + var frameDataOffset = frameDataOffsetField.getValue(addr); + var frameDataAddr = frame.getUnextendedSP().addOffsetTo(frameDataOffset); + var frameData = VMObjectFactory.newObject(FrameData.class, frameDataAddr); + return frameData.getJavaFrameAnchor(); + } + + public Address getLastJavaSP(Frame frame) { + return lastJavaSPField.getValue(getJavaFrameAnchor(frame)); + } + + public Address getLastJavaFP(Frame frame) { + return lastJavaFPField == null ? null : lastJavaFPField.getValue(getJavaFrameAnchor(frame)); + } + + public Address getLastJavaPC(Frame frame) { + return lastJavaPCField.getValue(getJavaFrameAnchor(frame)); + } + + public boolean isUpcallStub() { + return true; + } + + public static class FrameData extends VMObject { + + private static AddressField jfaField; + + static { + VM.registerVMInitializedObserver(new Observer() { + public void update(Observable o, Object data) { + initialize(VM.getVM().getTypeDataBase()); + } + }); + } + + private static void initialize(TypeDataBase db) { + Type type = db.lookupType("UpcallStub::FrameData"); + jfaField = type.getAddressField("jfa"); + } + + public FrameData(Address addr) { + super(addr); + } + + public Address getJavaFrameAnchor() { + return addr.addOffsetTo(jfaField.getOffset()); + } + + } + +} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/AccessFlags.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/AccessFlags.java index e3335dfb3c6..2f310effc87 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/AccessFlags.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/AccessFlags.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -56,10 +56,6 @@ public class AccessFlags implements /* imports */ ClassConstants { public long getValue () { return flags; } - // Klass* flags - public boolean hasFinalizer () { return (flags & JVM_ACC_HAS_FINALIZER ) != 0; } - public boolean isCloneable () { return (flags & JVM_ACC_IS_CLONEABLE ) != 0; } - public void printOn(PrintStream tty) { // prints only .class flags and not the hotspot internal flags if (isPublic ()) tty.print("public " ); diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/CompressedOops.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/CompressedOops.java index 056d7519957..01c99741533 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/CompressedOops.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/CompressedOops.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -64,8 +64,8 @@ public class CompressedOops { private static synchronized void initialize(TypeDataBase db) { Type type = db.lookupType("CompressedOops"); - baseField = type.getAddressField("_narrow_oop._base"); - shiftField = type.getCIntegerField("_narrow_oop._shift"); + baseField = type.getAddressField("_base"); + shiftField = type.getCIntegerField("_shift"); } public CompressedOops() { diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Klass.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Klass.java index ce869afad8a..5947e32861e 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Klass.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Klass.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -230,6 +230,4 @@ public class Klass extends Metadata implements ClassConstants { public boolean isAbstract() { return getAccessFlagsObj().isAbstract(); } public boolean isSuper() { return getAccessFlagsObj().isSuper(); } public boolean isSynthetic() { return getAccessFlagsObj().isSynthetic(); } - public boolean hasFinalizer() { return getAccessFlagsObj().hasFinalizer(); } - public boolean isCloneable() { return getAccessFlagsObj().isCloneable(); } } diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/ClassConstants.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/ClassConstants.java index 21fca913a3e..25f40ec443f 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/ClassConstants.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/ClassConstants.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -103,12 +103,6 @@ public interface ClassConstants // flags actually put in .class file public static final long JVM_ACC_WRITTEN_FLAGS = 0x00007FFF; - // Klass* flags - // True if klass has a non-empty finalize() method - public static final long JVM_ACC_HAS_FINALIZER = 0x40000000; - // True if klass supports the Clonable interface - public static final long JVM_ACC_IS_CLONEABLE = 0x80000000; - // flags accepted by set_field_flags public static final long JVM_ACC_FIELD_FLAGS = 0x00008000 | JVM_ACC_WRITTEN_FLAGS; diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/aarch64/AARCH64Frame.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/aarch64/AARCH64Frame.java index 5d8712002f8..dca5f2efa3b 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/aarch64/AARCH64Frame.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/aarch64/AARCH64Frame.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2019, Red Hat Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -292,7 +292,7 @@ public class AARCH64Frame extends Frame { } if (cb != null) { - return senderForCompiledFrame(map, cb); + return cb.isUpcallStub() ? senderForUpcallStub(map, (UpcallStub)cb) : senderForCompiledFrame(map, cb); } // Must be native-compiled frame, i.e. the marshaling code for native @@ -327,6 +327,34 @@ public class AARCH64Frame extends Frame { return fr; } + private Frame senderForUpcallStub(AARCH64RegisterMap map, UpcallStub stub) { + if (DEBUG) { + System.out.println("senderForUpcallStub"); + } + if (Assert.ASSERTS_ENABLED) { + Assert.that(map != null, "map must be set"); + } + + var lastJavaFP = stub.getLastJavaFP(this); + var lastJavaSP = stub.getLastJavaSP(this); + var lastJavaPC = stub.getLastJavaPC(this); + + if (Assert.ASSERTS_ENABLED) { + Assert.that(lastJavaSP.greaterThan(getSP()), "must be above this frame on stack"); + } + AARCH64Frame fr; + if (lastJavaPC != null) { + fr = new AARCH64Frame(lastJavaSP, lastJavaFP, lastJavaPC); + } else { + fr = new AARCH64Frame(lastJavaSP, lastJavaFP); + } + map.clear(); + if (Assert.ASSERTS_ENABLED) { + Assert.that(map.getIncludeArgumentOops(), "should be set by clear"); + } + return fr; + } + //------------------------------------------------------------------------------ // frame::adjust_unextended_sp private void adjustUnextendedSP() { diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/ppc64/PPC64Frame.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/ppc64/PPC64Frame.java index 710f30f19f2..a47a632c286 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/ppc64/PPC64Frame.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/ppc64/PPC64Frame.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -279,7 +279,7 @@ public class PPC64Frame extends Frame { } if (cb != null) { - return senderForCompiledFrame(map, cb); + return cb.isUpcallStub() ? senderForUpcallStub(map, (UpcallStub)cb) : senderForCompiledFrame(map, cb); } // Must be native-compiled frame, i.e. the marshaling code for native @@ -314,11 +314,40 @@ public class PPC64Frame extends Frame { return fr; } + private Frame senderForUpcallStub(PPC64RegisterMap map, UpcallStub stub) { + if (DEBUG) { + System.out.println("senderForUpcallStub"); + } + if (Assert.ASSERTS_ENABLED) { + Assert.that(map != null, "map must be set"); + } + + var lastJavaFP = stub.getLastJavaFP(this); // This will be null + var lastJavaSP = stub.getLastJavaSP(this); + var lastJavaPC = stub.getLastJavaPC(this); + + if (Assert.ASSERTS_ENABLED) { + Assert.that(lastJavaSP.greaterThan(getSP()), "must be above this frame on stack"); + } + PPC64Frame fr; + if (lastJavaPC != null) { + fr = new PPC64Frame(lastJavaSP, lastJavaFP, lastJavaPC); + } else { + fr = new PPC64Frame(lastJavaSP, lastJavaFP); + } + map.clear(); + if (Assert.ASSERTS_ENABLED) { + Assert.that(map.getIncludeArgumentOops(), "should be set by clear"); + } + return fr; + } + //------------------------------------------------------------------------------ // frame::adjust_unextended_sp private void adjustUnextendedSP() { - raw_unextendedSP = getFP(); + // Nothing to do. senderForInterpreterFrame finds the correct unextendedSP. } + private Frame senderForInterpreterFrame(PPC64RegisterMap map) { if (DEBUG) { System.out.println("senderForInterpreterFrame"); diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/riscv64/RISCV64Frame.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/riscv64/RISCV64Frame.java index c8e503db93b..948a3008016 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/riscv64/RISCV64Frame.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/riscv64/RISCV64Frame.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2019, Red Hat Inc. * Copyright (c) 2021, 2023, Huawei Technologies Co., Ltd. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -284,7 +284,7 @@ public class RISCV64Frame extends Frame { } if (cb != null) { - return senderForCompiledFrame(map, cb); + return cb.isUpcallStub() ? senderForUpcallStub(map, (UpcallStub)cb) : senderForCompiledFrame(map, cb); } // Must be native-compiled frame, i.e. the marshaling code for native @@ -319,6 +319,34 @@ public class RISCV64Frame extends Frame { return fr; } + private Frame senderForUpcallStub(RISCV64RegisterMap map, UpcallStub stub) { + if (DEBUG) { + System.out.println("senderForUpcallStub"); + } + if (Assert.ASSERTS_ENABLED) { + Assert.that(map != null, "map must be set"); + } + + var lastJavaFP = stub.getLastJavaFP(this); + var lastJavaSP = stub.getLastJavaSP(this); + var lastJavaPC = stub.getLastJavaPC(this); + + if (Assert.ASSERTS_ENABLED) { + Assert.that(lastJavaSP.greaterThan(getSP()), "must be above this frame on stack"); + } + RISCV64Frame fr; + if (lastJavaPC != null) { + fr = new RISCV64Frame(lastJavaSP, lastJavaFP, lastJavaPC); + } else { + fr = new RISCV64Frame(lastJavaSP, lastJavaFP); + } + map.clear(); + if (Assert.ASSERTS_ENABLED) { + Assert.that(map.getIncludeArgumentOops(), "should be set by clear"); + } + return fr; + } + //------------------------------------------------------------------------------ // frame::adjust_unextended_sp private void adjustUnextendedSP() { diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/x86/X86Frame.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/x86/X86Frame.java index 1ffc9761a33..169ecea1565 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/x86/X86Frame.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/x86/X86Frame.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -289,7 +289,7 @@ public class X86Frame extends Frame { } if (cb != null) { - return senderForCompiledFrame(map, cb); + return cb.isUpcallStub() ? senderForUpcallStub(map, (UpcallStub)cb) : senderForCompiledFrame(map, cb); } // Must be native-compiled frame, i.e. the marshaling code for native @@ -324,6 +324,34 @@ public class X86Frame extends Frame { return fr; } + private Frame senderForUpcallStub(X86RegisterMap map, UpcallStub stub) { + if (DEBUG) { + System.out.println("senderForUpcallStub"); + } + if (Assert.ASSERTS_ENABLED) { + Assert.that(map != null, "map must be set"); + } + + var lastJavaFP = stub.getLastJavaFP(this); + var lastJavaSP = stub.getLastJavaSP(this); + var lastJavaPC = stub.getLastJavaPC(this); + + if (Assert.ASSERTS_ENABLED) { + Assert.that(lastJavaSP.greaterThan(getSP()), "must be above this frame on stack"); + } + X86Frame fr; + if (lastJavaPC != null) { + fr = new X86Frame(lastJavaSP, lastJavaFP, lastJavaPC); + } else { + fr = new X86Frame(lastJavaSP, lastJavaFP); + } + map.clear(); + if (Assert.ASSERTS_ENABLED) { + Assert.that(map.getIncludeArgumentOops(), "should be set by clear"); + } + return fr; + } + //------------------------------------------------------------------------------ // frame::adjust_unextended_sp private void adjustUnextendedSP() { diff --git a/src/jdk.hotspot.agent/share/man/jhsdb.1 b/src/jdk.hotspot.agent/share/man/jhsdb.1 index 5b65f7eafb4..93cc1fedb15 100644 --- a/src/jdk.hotspot.agent/share/man/jhsdb.1 +++ b/src/jdk.hotspot.agent/share/man/jhsdb.1 @@ -1,4 +1,4 @@ -.\" Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. +.\" Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. .\" DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. .\" .\" This code is free software; you can redistribute it and/or modify it @@ -44,6 +44,10 @@ analyze the content of a core dump from a crashed Java Virtual Machine (JVM) .SH SYNOPSIS .PP +\f[B]WARNING:\f[R] The \f[V]debugd\f[R] subcommand and +\f[V]--connect\f[R] options are deprecated. +They will be removed in a future release. +.PP \f[V]jhsdb\f[R] \f[V]clhsdb\f[R] [\f[V]--pid\f[R] \f[I]pid\f[R] | \f[V]--exe\f[R] \f[I]executable\f[R] \f[V]--core\f[R] \f[I]coredump\f[R]] diff --git a/src/jdk.incubator.vector/linux/legal/sleef.md b/src/jdk.incubator.vector/linux/legal/sleef.md new file mode 100644 index 00000000000..ad4c4cba790 --- /dev/null +++ b/src/jdk.incubator.vector/linux/legal/sleef.md @@ -0,0 +1,439 @@ +## SLEEF v3.6.1 + +### Notice +``` +Copyright © 2010-2024 SLEEF Project, Naoki Shibata and contributors + +------- +src/arch/helpersve.h has the following copyright: +Copyright ARM Ltd. 2010 - 2024. +------- +src/gencoef/{dp.h, gencoef.c, ld.h, qp.h, simplexfr.c, sp.h} have no copyright but has the following license text: +// The code is distributed under the Creative Commons Attribution 4.0 International License. +// https://creativecommons.org/licenses/by/4.0/ +Attribution 4.0 International +``` + +### LICENSE Boost v1.0 +``` + +Boost Software License - Version 1.0 - August 17th, 2003 + +Permission is hereby granted, free of charge, to any person or organization +obtaining a copy of the software and accompanying documentation covered by +this license (the "Software") to use, reproduce, display, distribute, +execute, and transmit the Software, and to prepare derivative works of the +Software, and to permit third-parties to whom the Software is furnished to +do so, all subject to the following: + +The copyright notices in the Software and this entire statement, including +the above license grant, this restriction and the following disclaimer, +must be included in all copies of the Software, in whole or in part, and +all derivative works of the Software, unless such copies or derivative +works are solely in the form of machine-executable object code generated by +a source language processor. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +``` + +### LICENSE Creative Commons Attribution 4.0 International License + +``` +Creative Commons Corporation ("Creative Commons") is not a law firm and +does not provide legal services or legal advice. Distribution of +Creative Commons public licenses does not create a lawyer-client or +other relationship. Creative Commons makes its licenses and related +information available on an "as-is" basis. Creative Commons gives no +warranties regarding its licenses, any material licensed under their +terms and conditions, or any related information. Creative Commons +disclaims all liability for damages resulting from their use to the +fullest extent possible. + +Using Creative Commons Public Licenses + +Creative Commons public licenses provide a standard set of terms and +conditions that creators and other rights holders may use to share +original works of authorship and other material subject to copyright +and certain other rights specified in the public license below. The +following considerations are for informational purposes only, are not +exhaustive, and do not form part of our licenses. + + Considerations for licensors: Our public licenses are + intended for use by those authorized to give the public + permission to use material in ways otherwise restricted by + copyright and certain other rights. Our licenses are + irrevocable. Licensors should read and understand the terms + and conditions of the license they choose before applying it. + Licensors should also secure all rights necessary before + applying our licenses so that the public can reuse the + material as expected. Licensors should clearly mark any + material not subject to the license. This includes other CC- + licensed material, or material used under an exception or + limitation to copyright. More considerations for licensors: + wiki.creativecommons.org/Considerations_for_licensors + + Considerations for the public: By using one of our public + licenses, a licensor grants the public permission to use the + licensed material under specified terms and conditions. If + the licensor's permission is not necessary for any reason--for + example, because of any applicable exception or limitation to + copyright--then that use is not regulated by the license. Our + licenses grant only permissions under copyright and certain + other rights that a licensor has authority to grant. Use of + the licensed material may still be restricted for other + reasons, including because others have copyright or other + rights in the material. A licensor may make special requests, + such as asking that all changes be marked or described. + Although not required by our licenses, you are encouraged to + respect those requests where reasonable. More considerations + for the public: + wiki.creativecommons.org/Considerations_for_licensees + +======================================================================= + +Creative Commons Attribution 4.0 International Public License + +By exercising the Licensed Rights (defined below), You accept and agree +to be bound by the terms and conditions of this Creative Commons +Attribution 4.0 International Public License ("Public License"). To the +extent this Public License may be interpreted as a contract, You are +granted the Licensed Rights in consideration of Your acceptance of +these terms and conditions, and the Licensor grants You such rights in +consideration of benefits the Licensor receives from making the +Licensed Material available under these terms and conditions. + + +Section 1 -- Definitions. + + a. Adapted Material means material subject to Copyright and Similar + Rights that is derived from or based upon the Licensed Material + and in which the Licensed Material is translated, altered, + arranged, transformed, or otherwise modified in a manner requiring + permission under the Copyright and Similar Rights held by the + Licensor. For purposes of this Public License, where the Licensed + Material is a musical work, performance, or sound recording, + Adapted Material is always produced where the Licensed Material is + synched in timed relation with a moving image. + + b. Adapter's License means the license You apply to Your Copyright + and Similar Rights in Your contributions to Adapted Material in + accordance with the terms and conditions of this Public License. + + c. Copyright and Similar Rights means copyright and/or similar rights + closely related to copyright including, without limitation, + performance, broadcast, sound recording, and Sui Generis Database + Rights, without regard to how the rights are labeled or + categorized. For purposes of this Public License, the rights + specified in Section 2(b)(1)-(2) are not Copyright and Similar + Rights. + + d. Effective Technological Measures means those measures that, in the + absence of proper authority, may not be circumvented under laws + fulfilling obligations under Article 11 of the WIPO Copyright + Treaty adopted on December 20, 1996, and/or similar international + agreements. + + e. Exceptions and Limitations means fair use, fair dealing, and/or + any other exception or limitation to Copyright and Similar Rights + that applies to Your use of the Licensed Material. + + f. Licensed Material means the artistic or literary work, database, + or other material to which the Licensor applied this Public + License. + + g. Licensed Rights means the rights granted to You subject to the + terms and conditions of this Public License, which are limited to + all Copyright and Similar Rights that apply to Your use of the + Licensed Material and that the Licensor has authority to license. + + h. Licensor means the individual(s) or entity(ies) granting rights + under this Public License. + + i. Share means to provide material to the public by any means or + process that requires permission under the Licensed Rights, such + as reproduction, public display, public performance, distribution, + dissemination, communication, or importation, and to make material + available to the public including in ways that members of the + public may access the material from a place and at a time + individually chosen by them. + + j. Sui Generis Database Rights means rights other than copyright + resulting from Directive 96/9/EC of the European Parliament and of + the Council of 11 March 1996 on the legal protection of databases, + as amended and/or succeeded, as well as other essentially + equivalent rights anywhere in the world. + + k. You means the individual or entity exercising the Licensed Rights + under this Public License. Your has a corresponding meaning. + + +Section 2 -- Scope. + + a. License grant. + + 1. Subject to the terms and conditions of this Public License, + the Licensor hereby grants You a worldwide, royalty-free, + non-sublicensable, non-exclusive, irrevocable license to + exercise the Licensed Rights in the Licensed Material to: + + a. reproduce and Share the Licensed Material, in whole or + in part; and + + b. produce, reproduce, and Share Adapted Material. + + 2. Exceptions and Limitations. For the avoidance of doubt, where + Exceptions and Limitations apply to Your use, this Public + License does not apply, and You do not need to comply with + its terms and conditions. + + 3. Term. The term of this Public License is specified in Section + 6(a). + + 4. Media and formats; technical modifications allowed. The + Licensor authorizes You to exercise the Licensed Rights in + all media and formats whether now known or hereafter created, + and to make technical modifications necessary to do so. The + Licensor waives and/or agrees not to assert any right or + authority to forbid You from making technical modifications + necessary to exercise the Licensed Rights, including + technical modifications necessary to circumvent Effective + Technological Measures. For purposes of this Public License, + simply making modifications authorized by this Section 2(a) + (4) never produces Adapted Material. + + 5. Downstream recipients. + + a. Offer from the Licensor -- Licensed Material. Every + recipient of the Licensed Material automatically + receives an offer from the Licensor to exercise the + Licensed Rights under the terms and conditions of this + Public License. + + b. No downstream restrictions. You may not offer or impose + any additional or different terms or conditions on, or + apply any Effective Technological Measures to, the + Licensed Material if doing so restricts exercise of the + Licensed Rights by any recipient of the Licensed + Material. + + 6. No endorsement. Nothing in this Public License constitutes or + may be construed as permission to assert or imply that You + are, or that Your use of the Licensed Material is, connected + with, or sponsored, endorsed, or granted official status by, + the Licensor or others designated to receive attribution as + provided in Section 3(a)(1)(A)(i). + + b. Other rights. + + 1. Moral rights, such as the right of integrity, are not + licensed under this Public License, nor are publicity, + privacy, and/or other similar personality rights; however, to + the extent possible, the Licensor waives and/or agrees not to + assert any such rights held by the Licensor to the limited + extent necessary to allow You to exercise the Licensed + Rights, but not otherwise. + + 2. Patent and trademark rights are not licensed under this + Public License. + + 3. To the extent possible, the Licensor waives any right to + collect royalties from You for the exercise of the Licensed + Rights, whether directly or through a collecting society + under any voluntary or waivable statutory or compulsory + licensing scheme. In all other cases the Licensor expressly + reserves any right to collect such royalties. + + +Section 3 -- License Conditions. + +Your exercise of the Licensed Rights is expressly made subject to the +following conditions. + + a. Attribution. + + 1. If You Share the Licensed Material (including in modified + form), You must: + + a. retain the following if it is supplied by the Licensor + with the Licensed Material: + + i. identification of the creator(s) of the Licensed + Material and any others designated to receive + attribution, in any reasonable manner requested by + the Licensor (including by pseudonym if + designated); + + ii. a copyright notice; + + iii. a notice that refers to this Public License; + + iv. a notice that refers to the disclaimer of + warranties; + + v. a URI or hyperlink to the Licensed Material to the + extent reasonably practicable; + + b. indicate if You modified the Licensed Material and + retain an indication of any previous modifications; and + + c. indicate the Licensed Material is licensed under this + Public License, and include the text of, or the URI or + hyperlink to, this Public License. + + 2. You may satisfy the conditions in Section 3(a)(1) in any + reasonable manner based on the medium, means, and context in + which You Share the Licensed Material. For example, it may be + reasonable to satisfy the conditions by providing a URI or + hyperlink to a resource that includes the required + information. + + 3. If requested by the Licensor, You must remove any of the + information required by Section 3(a)(1)(A) to the extent + reasonably practicable. + + 4. If You Share Adapted Material You produce, the Adapter's + License You apply must not prevent recipients of the Adapted + Material from complying with this Public License. + + +Section 4 -- Sui Generis Database Rights. + +Where the Licensed Rights include Sui Generis Database Rights that +apply to Your use of the Licensed Material: + + a. for the avoidance of doubt, Section 2(a)(1) grants You the right + to extract, reuse, reproduce, and Share all or a substantial + portion of the contents of the database; + + b. if You include all or a substantial portion of the database + contents in a database in which You have Sui Generis Database + Rights, then the database in which You have Sui Generis Database + Rights (but not its individual contents) is Adapted Material; and + + c. You must comply with the conditions in Section 3(a) if You Share + all or a substantial portion of the contents of the database. + +For the avoidance of doubt, this Section 4 supplements and does not +replace Your obligations under this Public License where the Licensed +Rights include other Copyright and Similar Rights. + + +Section 5 -- Disclaimer of Warranties and Limitation of Liability. + + a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE + EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS + AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF + ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, + IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, + WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR + PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS, + ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT + KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT + ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU. + + b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE + TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, + NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, + INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES, + COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR + USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN + ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR + DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR + IN PART, THIS LIMITATION MAY NOT APPLY TO YOU. + + c. The disclaimer of warranties and limitation of liability provided + above shall be interpreted in a manner that, to the extent + possible, most closely approximates an absolute disclaimer and + waiver of all liability. + + +Section 6 -- Term and Termination. + + a. This Public License applies for the term of the Copyright and + Similar Rights licensed here. However, if You fail to comply with + this Public License, then Your rights under this Public License + terminate automatically. + + b. Where Your right to use the Licensed Material has terminated under + Section 6(a), it reinstates: + + 1. automatically as of the date the violation is cured, provided + it is cured within 30 days of Your discovery of the + violation; or + + 2. upon express reinstatement by the Licensor. + + For the avoidance of doubt, this Section 6(b) does not affect any + right the Licensor may have to seek remedies for Your violations + of this Public License. + + c. For the avoidance of doubt, the Licensor may also offer the + Licensed Material under separate terms or conditions or stop + distributing the Licensed Material at any time; however, doing so + will not terminate this Public License. + + d. Sections 1, 5, 6, 7, and 8 survive termination of this Public + License. + + +Section 7 -- Other Terms and Conditions. + + a. The Licensor shall not be bound by any additional or different + terms or conditions communicated by You unless expressly agreed. + + b. Any arrangements, understandings, or agreements regarding the + Licensed Material not stated herein are separate from and + independent of the terms and conditions of this Public License. + + +Section 8 -- Interpretation. + + a. For the avoidance of doubt, this Public License does not, and + shall not be interpreted to, reduce, limit, restrict, or impose + conditions on any use of the Licensed Material that could lawfully + be made without permission under this Public License. + + b. To the extent possible, if any provision of this Public License is + deemed unenforceable, it shall be automatically reformed to the + minimum extent necessary to make it enforceable. If the provision + cannot be reformed, it shall be severed from this Public License + without affecting the enforceability of the remaining terms and + conditions. + + c. No term or condition of this Public License will be waived and no + failure to comply consented to unless expressly agreed to by the + Licensor. + + d. Nothing in this Public License constitutes or may be interpreted + as a limitation upon, or waiver of, any privileges and immunities + that apply to the Licensor or You, including from the legal + processes of any jurisdiction or authority. + + +======================================================================= + +Creative Commons is not a party to its public +licenses. Notwithstanding, Creative Commons may elect to apply one of +its public licenses to material it publishes and in those instances +will be considered the “Licensor.” The text of the Creative Commons +public licenses is dedicated to the public domain under the CC0 Public +Domain Dedication. Except for the limited purpose of indicating that +material is shared under a Creative Commons public license or as +otherwise permitted by the Creative Commons policies published at +creativecommons.org/policies, Creative Commons does not authorize the +use of the trademark "Creative Commons" or any other trademark or logo +of Creative Commons without its prior written consent including, +without limitation, in connection with any unauthorized modifications +to any of its public licenses or any other arrangements, +understandings, or agreements concerning use of licensed material. For +the avoidance of doubt, this paragraph does not form part of the +public licenses. + +Creative Commons may be contacted at creativecommons.org. +``` diff --git a/src/jdk.incubator.vector/linux/native/libsleef/README.md b/src/jdk.incubator.vector/linux/native/libsleef/README.md new file mode 100644 index 00000000000..1f20f3dda10 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/README.md @@ -0,0 +1,54 @@ +# About SLEEF + +This directory contains the source code for the SLEEF library, the +**SIMD Library for Evaluating Elementary Functions**. For more information on +SLEEF, see https://sleef.org/. + +The currently imported libsleef sources is version 3.6.1, which has +git tag `3.6.1` and git commit hash `6ee14bcae5fe92c2ff8b000d5a01102dab08d774`. + +# About the libsleef integration in the JDK + +The upstream original source code is available in +`src/jdk.incubator.vector/linux/native/libsleef/upstream`. However, this code is +not directly usable in the JDK build system, but is instead used as the base for +the generation of additional souce code files. This generation is done by +the libsleef CMake files. If this should have been done at build time, it would +have meant adding CMake as a required dependency to build the JDK. + +Instead, we create these generated files only once, when we import a new +version of the libsleef source code, and check in the generated files into +the JDK source tree. The generated files reside in +`src/jdk.incubator.vector/linux/native/libsleef/generated`. + +# Import instructions + +To update the version of libsleef that is used in the JDK, clone +`https://github.com/shibatch/sleef.git`, and copy all files, except the `docs`, +`.github` and `.git` directories, into +`src/jdk.incubator.vector/linux/native/libsleef/upstream`. + +The libsleef source code does not follow the JDK whitespace rules as enforced by +jcheck. You will need to remove trailing whitespace, and expand tabs to 8 +spaces in the imported source code. + +Update the note above with information about what version you import. + +You will need to repeat the process below for each of the platforms in the JDK +that uses libsleef; currently this is aarch64 and riscv64. The rest of this +instruction assumes you are doing this on linux/x64; at this point, any other +setup is not supported. Also, make sure you have CMake installed. + +First, run configure for cross-compiling to your selected target platform +(e.g. aarch64). + +Run `make update-sleef-source` to process the upstream source code and +store the generated files in the `generated` directory. + +Now, you can repeat this for the next platform. For instance, you can +create a separate configuration using `configure --with-conf-name=riscv64` and +then generate the updated libsleef source code by +`make update-sleef-source CONF=riscv64`. + +Finally, verify with git that the local changes made to the files in +`src/jdk.incubator.vector/linux/native/libsleef/generated` look okay. diff --git a/src/jdk.incubator.vector/linux/native/libsleef/generated/misc.h b/src/jdk.incubator.vector/linux/native/libsleef/generated/misc.h new file mode 100644 index 00000000000..472cae68bd5 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/generated/misc.h @@ -0,0 +1,332 @@ +// Copyright Naoki Shibata and contributors 2010 - 2024. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// + +#ifndef __MISC_H__ +#define __MISC_H__ + +#if !defined(SLEEF_GENHEADER) +#include +#include +#endif + +#ifndef M_PI +#define M_PI 3.141592653589793238462643383279502884 +#endif + +#ifndef M_PIl +#define M_PIl 3.141592653589793238462643383279502884L +#endif + +#ifndef M_1_PI +#define M_1_PI 0.318309886183790671537767526745028724 +#endif + +#ifndef M_1_PIl +#define M_1_PIl 0.318309886183790671537767526745028724L +#endif + +#ifndef M_2_PI +#define M_2_PI 0.636619772367581343075535053490057448 +#endif + +#ifndef M_2_PIl +#define M_2_PIl 0.636619772367581343075535053490057448L +#endif + +#if !defined(SLEEF_GENHEADER) + +#ifndef SLEEF_FP_ILOGB0 +#define SLEEF_FP_ILOGB0 ((int)0x80000000) +#endif + +#ifndef SLEEF_FP_ILOGBNAN +#define SLEEF_FP_ILOGBNAN ((int)2147483647) +#endif + +#endif + +#define SLEEF_SNAN (((union { long long int i; double d; }) { .i = INT64_C(0x7ff0000000000001) }).d) +#define SLEEF_SNANf (((union { long int i; float f; }) { .i = 0xff800001 }).f) + +#define SLEEF_FLT_MIN 0x1p-126 +#define SLEEF_DBL_MIN 0x1p-1022 +#define SLEEF_INT_MAX 2147483647 +#define SLEEF_DBL_DENORM_MIN 4.9406564584124654e-324 +#define SLEEF_FLT_DENORM_MIN 1.40129846e-45F + +// + +/* + PI_A to PI_D are constants that satisfy the following two conditions. + + * For PI_A, PI_B and PI_C, the last 28 bits are zero. + * PI_A + PI_B + PI_C + PI_D is close to PI as much as possible. + + The argument of a trig function is multiplied by 1/PI, and the + integral part is divided into two parts, each has at most 28 + bits. So, the maximum argument that could be correctly reduced + should be 2^(28*2-1) PI = 1.1e+17. However, due to internal + double precision calculation, the actual maximum argument that can + be correctly reduced is around 2^47. + */ + +#define PI_A 3.1415926218032836914 +#define PI_B 3.1786509424591713469e-08 +#define PI_C 1.2246467864107188502e-16 +#define PI_D 1.2736634327021899816e-24 +#define TRIGRANGEMAX 1e+14 + +/* + PI_A2 and PI_B2 are constants that satisfy the following two conditions. + + * The last 3 bits of PI_A2 are zero. + * PI_A2 + PI_B2 is close to PI as much as possible. + + The argument of a trig function is multiplied by 1/PI, and the + integral part is multiplied by PI_A2. So, the maximum argument that + could be correctly reduced should be 2^(3-1) PI = 12.6. By testing, + we confirmed that it correctly reduces the argument up to around 15. + */ + +#define PI_A2 3.141592653589793116 +#define PI_B2 1.2246467991473532072e-16 +#define TRIGRANGEMAX2 15 + +#define M_2_PI_H 0.63661977236758138243 +#define M_2_PI_L -3.9357353350364971764e-17 + +#define SQRT_DBL_MAX 1.3407807929942596355e+154 + +#define TRIGRANGEMAX3 1e+9 + +#define M_4_PI 1.273239544735162542821171882678754627704620361328125 + +#define L2U .69314718055966295651160180568695068359375 +#define L2L .28235290563031577122588448175013436025525412068e-12 +#define R_LN2 1.442695040888963407359924681001892137426645954152985934135449406931 + +#define L10U 0.30102999566383914498 // log 2 / log 10 +#define L10L 1.4205023227266099418e-13 +#define LOG10_2 3.3219280948873623478703194294893901758648313930 + +#define L10Uf 0.3010253906f +#define L10Lf 4.605038981e-06f + +// + +#define PI_Af 3.140625f +#define PI_Bf 0.0009670257568359375f +#define PI_Cf 6.2771141529083251953e-07f +#define PI_Df 1.2154201256553420762e-10f +#define TRIGRANGEMAXf 39000 + +#define PI_A2f 3.1414794921875f +#define PI_B2f 0.00011315941810607910156f +#define PI_C2f 1.9841872589410058936e-09f +#define TRIGRANGEMAX2f 125.0f + +#define TRIGRANGEMAX4f 8e+6f + +#define SQRT_FLT_MAX 18446743523953729536.0 + +#define L2Uf 0.693145751953125f +#define L2Lf 1.428606765330187045e-06f + +#define R_LN2f 1.442695040888963407359924681001892137426645954152985934135449406931f +#ifndef M_PIf +# define M_PIf ((float)M_PI) +#endif + +// + +#ifndef MIN +#define MIN(x, y) ((x) < (y) ? (x) : (y)) +#endif + +#ifndef MAX +#define MAX(x, y) ((x) > (y) ? (x) : (y)) +#endif + +#ifndef ABS +#define ABS(x) ((x) < 0 ? -(x) : (x)) +#endif + +#define stringify(s) stringify_(s) +#define stringify_(s) #s + +#if !defined(SLEEF_GENHEADER) +typedef long double longdouble; +#endif + +#if !defined(Sleef_double2_DEFINED) && !defined(SLEEF_GENHEADER) +#define Sleef_double2_DEFINED +typedef struct { + double x, y; +} Sleef_double2; +#endif + +#if !defined(Sleef_float2_DEFINED) && !defined(SLEEF_GENHEADER) +#define Sleef_float2_DEFINED +typedef struct { + float x, y; +} Sleef_float2; +#endif + +#if !defined(Sleef_longdouble2_DEFINED) && !defined(SLEEF_GENHEADER) +#define Sleef_longdouble2_DEFINED +typedef struct { + long double x, y; +} Sleef_longdouble2; +#endif + +#if (defined (__GNUC__) || defined (__clang__) || defined(__INTEL_COMPILER)) && !defined(_MSC_VER) + +#define LIKELY(condition) __builtin_expect(!!(condition), 1) +#define UNLIKELY(condition) __builtin_expect(!!(condition), 0) +#define RESTRICT __restrict__ + +#ifndef __arm__ +#define ALIGNED(x) __attribute__((aligned(x))) +#else +#define ALIGNED(x) +#endif + +#if defined(SLEEF_GENHEADER) + +#define INLINE SLEEF_ALWAYS_INLINE +#define EXPORT SLEEF_INLINE +#define CONST SLEEF_CONST +#define NOEXPORT + +#else // #if defined(SLEEF_GENHEADER) + +#define CONST __attribute__((const)) +#define INLINE __attribute__((always_inline)) + +#if defined(__MINGW32__) || defined(__MINGW64__) || defined(__CYGWIN__) +#ifndef SLEEF_STATIC_LIBS +#define EXPORT __stdcall __declspec(dllexport) +#define NOEXPORT +#else // #ifndef SLEEF_STATIC_LIBS +#define EXPORT +#define NOEXPORT +#endif // #ifndef SLEEF_STATIC_LIBS +#else // #if defined(__MINGW32__) || defined(__MINGW64__) || defined(__CYGWIN__) +#define EXPORT __attribute__((visibility("default"))) +#define NOEXPORT __attribute__ ((visibility ("hidden"))) +#endif // #if defined(__MINGW32__) || defined(__MINGW64__) || defined(__CYGWIN__) + +#endif // #if defined(SLEEF_GENHEADER) + +#define SLEEF_NAN __builtin_nan("") +#define SLEEF_NANf __builtin_nanf("") +#define SLEEF_NANl __builtin_nanl("") +#define SLEEF_INFINITY __builtin_inf() +#define SLEEF_INFINITYf __builtin_inff() +#define SLEEF_INFINITYl __builtin_infl() + +#if defined(__INTEL_COMPILER) || defined (__clang__) +#define SLEEF_INFINITYq __builtin_inf() +#define SLEEF_NANq __builtin_nan("") +#else +#define SLEEF_INFINITYq __builtin_infq() +#define SLEEF_NANq (SLEEF_INFINITYq - SLEEF_INFINITYq) +#endif + +#elif defined(_MSC_VER) // #if (defined (__GNUC__) || defined (__clang__) || defined(__INTEL_COMPILER)) && !defined(_MSC_VER) + +#if defined(SLEEF_GENHEADER) + +#define INLINE SLEEF_ALWAYS_INLINE +#define CONST SLEEF_CONST +#define EXPORT SLEEF_INLINE +#define NOEXPORT + +#else // #if defined(SLEEF_GENHEADER) + +#define INLINE __forceinline +#define CONST +#ifndef SLEEF_STATIC_LIBS +#define EXPORT __declspec(dllexport) +#define NOEXPORT +#else +#define EXPORT +#define NOEXPORT +#endif + +#endif // #if defined(SLEEF_GENHEADER) + +#define RESTRICT +#define ALIGNED(x) +#define LIKELY(condition) (condition) +#define UNLIKELY(condition) (condition) + +#if (defined(__GNUC__) || defined(__CLANG__)) && (defined(__i386__) || defined(__x86_64__)) && !defined(SLEEF_GENHEADER) +#include +#endif + +#define SLEEF_INFINITY (1e+300 * 1e+300) +#define SLEEF_NAN (SLEEF_INFINITY - SLEEF_INFINITY) +#define SLEEF_INFINITYf ((float)SLEEF_INFINITY) +#define SLEEF_NANf ((float)SLEEF_NAN) +#define SLEEF_INFINITYl ((long double)SLEEF_INFINITY) +#define SLEEF_NANl ((long double)SLEEF_NAN) + +#if (defined(_M_AMD64) || defined(_M_X64)) +#ifndef __SSE2__ +#define __SSE2__ +#define __SSE3__ +#define __SSE4_1__ +#endif +#elif _M_IX86_FP == 2 +#ifndef __SSE2__ +#define __SSE2__ +#define __SSE3__ +#define __SSE4_1__ +#endif +#elif _M_IX86_FP == 1 +#ifndef __SSE__ +#define __SSE__ +#endif +#endif + +#endif // #elif defined(_MSC_VER) // #if (defined (__GNUC__) || defined (__clang__) || defined(__INTEL_COMPILER)) && !defined(_MSC_VER) + +#if !defined(__linux__) +#define isinff(x) ((x) == SLEEF_INFINITYf || (x) == -SLEEF_INFINITYf) +#define isinfl(x) ((x) == SLEEF_INFINITYl || (x) == -SLEEF_INFINITYl) +#define isnanf(x) ((x) != (x)) +#define isnanl(x) ((x) != (x)) +#endif + +#endif // #ifndef __MISC_H__ + +#ifdef ENABLE_AAVPCS +#define VECTOR_CC __attribute__((aarch64_vector_pcs)) +#else +#define VECTOR_CC +#endif + +// + +#if defined (__GNUC__) && !defined(__INTEL_COMPILER) +#pragma GCC diagnostic ignored "-Wpragmas" +#pragma GCC diagnostic ignored "-Wunknown-pragmas" +#if !defined (__clang__) +#pragma GCC diagnostic ignored "-Wattribute-alias" +#pragma GCC diagnostic ignored "-Wlto-type-mismatch" +#pragma GCC diagnostic ignored "-Wstringop-overflow" +#endif +#endif + +#if defined(_MSC_VER) +#pragma warning(disable:4101) // warning C4101: 'v': unreferenced local variable +#pragma warning(disable:4116) // warning C4116: unnamed type definition in parentheses +#pragma warning(disable:4244) // warning C4244: 'function': conversion from 'vopmask' to '__mmask8', possible loss of data +#pragma warning(disable:4267) // warning C4267: 'initializing': conversion from 'size_t' to 'const int', possible loss of data +#pragma warning(disable:4305) // warning C4305: 'function': truncation from 'double' to 'float' +#endif diff --git a/src/jdk.incubator.vector/linux/native/libsleef/generated/sleefinline_advsimd.h b/src/jdk.incubator.vector/linux/native/libsleef/generated/sleefinline_advsimd.h new file mode 100644 index 00000000000..7e02768cf1e --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/generated/sleefinline_advsimd.h @@ -0,0 +1,6907 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See http://www.boost.org/LICENSE_1_0.txt) + +// This file is generated by SLEEF 3.6.1 + +#ifndef SLEEF_ALWAYS_INLINE +#if defined (__GNUC__) || defined (__clang__) || defined(__INTEL_COMPILER) +#define SLEEF_ALWAYS_INLINE inline __attribute__((always_inline)) +#elif defined(_MSC_VER) +#define SLEEF_ALWAYS_INLINE inline __forceinline +#else +#define SLEEF_ALWAYS_INLINE inline +#endif +#endif + +#ifndef SLEEF_INLINE +#define SLEEF_INLINE static inline +#endif + +#ifndef SLEEF_CONST +#define SLEEF_CONST +#endif + +#if defined(_MSC_VER) && !defined (__clang__) +#pragma fp_contract (off) +#else +#pragma STDC FP_CONTRACT OFF +#endif + +#ifndef SLEEF_FP_ILOGB0 +#define SLEEF_FP_ILOGB0 ((int)0x80000000) +#endif + +#ifndef SLEEF_FP_ILOGBNAN +#define SLEEF_FP_ILOGBNAN ((int)2147483647) +#endif + +#define SLEEFINLINE_ADVSIMD_H_INCLUDED + +#ifndef __SLEEF_REMPITAB__ +#define __SLEEF_REMPITAB__ +static const double Sleef_rempitabdp[] = { + 0.15915494309189531785, 1.7916237278037667488e-17, 2.5454160968749269937e-33, 2.1132476107887107169e-49, + 0.03415494309189533173, 4.0384494702232122736e-18, 1.0046721413651383112e-33, 2.1132476107887107169e-49, + 0.03415494309189533173, 4.0384494702232122736e-18, 1.0046721413651383112e-33, 2.1132476107887107169e-49, + 0.0029049430918953351999, 5.6900251826959904774e-19, 4.1707169171520598517e-35, -2.496415728504571394e-51, + 0.0029049430918953351999, 5.6900251826959904774e-19, 4.1707169171520598517e-35, -2.496415728504571394e-51, + 0.0029049430918953351999, 5.6900251826959904774e-19, 4.1707169171520598517e-35, -2.496415728504571394e-51, + 0.0029049430918953351999, 5.6900251826959904774e-19, 4.1707169171520598517e-35, -2.496415728504571394e-51, + 0.00095181809189533563356, 1.3532164927539732229e-19, -6.4410794381603004826e-36, 1.7634898158762436344e-52, + 0.00095181809189533563356, 1.3532164927539732229e-19, -6.4410794381603004826e-36, 1.7634898158762436344e-52, + 0.00046353684189533574198, 2.6901432026846872871e-20, -4.2254836195018827479e-37, 9.301187206862134399e-54, + 0.00021939621689533574198, 2.6901432026846872871e-20, -4.2254836195018827479e-37, 9.301187206862134399e-54, + 9.7325904395335769087e-05, -2.0362228529073840241e-22, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 3.6290748145335769087e-05, -2.0362228529073840241e-22, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 5.7731700203357690874e-06, -2.0362228529073840241e-22, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 5.7731700203357690874e-06, -2.0362228529073840241e-22, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 5.7731700203357690874e-06, -2.0362228529073840241e-22, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 1.9584727547107690874e-06, -2.0362228529073840241e-22, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 5.1124121898268875627e-08, 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 5.1124121898268875627e-08, 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 5.1124121898268875627e-08, 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 5.1124121898268875627e-08, 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 5.1124121898268875627e-08, 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 5.1124121898268875627e-08, 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 2.1321799510573569745e-08, 1.5185066224124613304e-24, 2.6226236120327253511e-40, 2.6283399642369025999e-57, + 6.4206383167259151492e-09, -1.3585460269359374382e-25, -1.3244127270701094468e-41, -2.4695541513869446866e-57, + 6.4206383167259151492e-09, -1.3585460269359374382e-25, -1.3244127270701094468e-41, -2.4695541513869446866e-57, + 2.6953480182640010867e-09, -1.3585460269359374382e-25, -1.3244127270701094468e-41, -2.4695541513869446866e-57, + 8.3270286903304384868e-10, 7.0940550444663151936e-26, 9.7147467687967058732e-42, 7.9392906424978921242e-59, + 8.3270286903304384868e-10, 7.0940550444663151936e-26, 9.7147467687967058732e-42, 7.9392906424978921242e-59, + 3.6704158172530459087e-10, 7.0940550444663151936e-26, 9.7147467687967058732e-42, 7.9392906424978921242e-59, + 1.3421093807143501366e-10, 1.9241762160098927996e-26, 3.9750282589222551507e-42, 7.9392906424978921242e-59, + 1.7795616244500218596e-11, -1.452834466126541428e-28, -1.5869767474823787636e-44, -2.6168913164368963837e-61, + 1.7795616244500218596e-11, -1.452834466126541428e-28, -1.5869767474823787636e-44, -2.6168913164368963837e-61, + 1.7795616244500218596e-11, -1.452834466126541428e-28, -1.5869767474823787636e-44, -2.6168913164368963837e-61, + 3.2437010161333667893e-12, -1.452834466126541428e-28, -1.5869767474823787636e-44, -2.6168913164368963837e-61, + 3.2437010161333667893e-12, -1.452834466126541428e-28, -1.5869767474823787636e-44, -2.6168913164368963837e-61, + 3.2437010161333667893e-12, -1.452834466126541428e-28, -1.5869767474823787636e-44, -2.6168913164368963837e-61, + 1.4247116125875099096e-12, 2.5861333686050385673e-28, 2.8971783383570358633e-44, -2.6168913164368963837e-61, + 5.1521691081458187359e-13, 5.6664945123924856962e-29, 6.5510079543732854985e-45, -2.6168913164368963837e-61, + 6.0469559928117805118e-14, 6.1778471897801070206e-30, 9.4581409707401690366e-46, 4.9461632249367446986e-62, + 6.0469559928117805118e-14, 6.1778471897801070206e-30, 9.4581409707401690366e-46, 4.9461632249367446986e-62, + 6.0469559928117805118e-14, 6.1778471897801070206e-30, 9.4581409707401690366e-46, 4.9461632249367446986e-62, + 3.6261410673097965595e-15, -1.3304005198798645927e-31, -1.7578597149294783985e-47, 8.4432539107728104262e-64, + 3.6261410673097965595e-15, -1.3304005198798645927e-31, -1.7578597149294783985e-47, 8.4432539107728104262e-64, + 3.6261410673097965595e-15, -1.3304005198798645927e-31, -1.7578597149294783985e-47, 8.4432539107728104262e-64, + 3.6261410673097965595e-15, -1.3304005198798645927e-31, -1.7578597149294783985e-47, 8.4432539107728104262e-64, + 7.3427388509295482183e-17, 1.4871367740953237822e-32, -1.1571307704883330232e-48, -6.7249112515659578102e-65, + 7.3427388509295482183e-17, 1.4871367740953237822e-32, -1.1571307704883330232e-48, -6.7249112515659578102e-65, + 7.3427388509295482183e-17, 1.4871367740953237822e-32, -1.1571307704883330232e-48, -6.7249112515659578102e-65, + 7.3427388509295482183e-17, 1.4871367740953237822e-32, -1.1571307704883330232e-48, -6.7249112515659578102e-65, + 7.3427388509295482183e-17, 1.4871367740953237822e-32, -1.1571307704883330232e-48, -6.7249112515659578102e-65, + 7.3427388509295482183e-17, 1.4871367740953237822e-32, -1.1571307704883330232e-48, -6.7249112515659578102e-65, + 1.7916237278037667488e-17, 2.5454160968749269937e-33, 2.1132476107887107169e-49, 8.7154294504188129325e-66, + 1.7916237278037667488e-17, 2.5454160968749269937e-33, 2.1132476107887107169e-49, 8.7154294504188129325e-66, + 4.0384494702232122736e-18, 1.0046721413651383112e-33, 2.1132476107887107169e-49, 8.7154294504188129325e-66, + 4.0384494702232122736e-18, 1.0046721413651383112e-33, 2.1132476107887107169e-49, 8.7154294504188129325e-66, + 5.6900251826959904774e-19, 4.1707169171520598517e-35, -2.4964157285045710972e-51, -1.866653112309982615e-67, + 5.6900251826959904774e-19, 4.1707169171520598517e-35, -2.4964157285045710972e-51, -1.866653112309982615e-67, + 5.6900251826959904774e-19, 4.1707169171520598517e-35, -2.4964157285045710972e-51, -1.866653112309982615e-67, + 1.3532164927539732229e-19, -6.4410794381603004826e-36, 1.7634898158762432635e-52, 3.5887057810247033998e-68, + 1.3532164927539732229e-19, -6.4410794381603004826e-36, 1.7634898158762432635e-52, 3.5887057810247033998e-68, + 2.6901432026846872871e-20, -4.2254836195018827479e-37, 9.3011872068621332399e-54, 1.113250147552460308e-69, + 2.6901432026846872871e-20, -4.2254836195018827479e-37, 9.3011872068621332399e-54, 1.113250147552460308e-69, + 2.6901432026846872871e-20, -4.2254836195018827479e-37, 9.3011872068621332399e-54, 1.113250147552460308e-69, + 1.3348904870778067446e-20, -4.2254836195018827479e-37, 9.3011872068621332399e-54, 1.113250147552460308e-69, + 6.5726412927436632287e-21, 1.0820844071023395684e-36, 1.7634898158762432635e-52, 3.5887057810247033998e-68, + 3.1845095037264626247e-21, 3.2976802257607573031e-37, 9.3011872068621332399e-54, 1.113250147552460308e-69, + 1.4904436092178623228e-21, -4.6390169687056261795e-38, -1.1392999419355048437e-54, -4.587677453735884283e-71, + 6.4341066196356198368e-22, -4.6390169687056261795e-38, -1.1392999419355048437e-54, -4.587677453735884283e-71, + 2.1989418833641172011e-22, 4.7649378378726728402e-38, 9.3011872068621332399e-54, 1.113250147552460308e-69, + 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, + 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, + 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, + 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, + 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, + 1.5185066224124613304e-24, 2.6226236120327253511e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, + 1.5185066224124613304e-24, 2.6226236120327253511e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, + 1.5185066224124613304e-24, 2.6226236120327253511e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, + 6.9132600985943383921e-25, 7.8591368887290111994e-41, 2.6283399642369020339e-57, 5.3358074162805516304e-73, + 2.7773570358292009361e-25, -1.3244127270701094468e-41, -2.4695541513869446866e-57, -3.2399200798614356002e-74, + 7.0940550444663151936e-26, 9.7147467687967058732e-42, 7.9392906424978921242e-59, 2.9745456030524896742e-75, + 7.0940550444663151936e-26, 9.7147467687967058732e-42, 7.9392906424978921242e-59, 2.9745456030524896742e-75, + 1.9241762160098927996e-26, 3.9750282589222551507e-42, 7.9392906424978921242e-59, 2.9745456030524896742e-75, + 1.9241762160098927996e-26, 3.9750282589222551507e-42, 7.9392906424978921242e-59, 2.9745456030524896742e-75, + 6.317065088957874881e-27, -3.2976062348358281152e-43, -2.6168913164368963837e-61, 3.7036201000008290615e-78, + 6.317065088957874881e-27, -3.2976062348358281152e-43, -2.6168913164368963837e-61, 3.7036201000008290615e-78, + 3.0858908211726098086e-27, 3.8770419025072344914e-43, 7.9392906424978921242e-59, 2.9745456030524896742e-75, + 1.4703036872799779898e-27, 2.8971783383570358633e-44, -2.6168913164368963837e-61, 3.7036201000008290615e-78, + 6.625101203336619011e-28, 2.8971783383570358633e-44, -2.6168913164368963837e-61, 3.7036201000008290615e-78, + 2.5861333686050385673e-28, 2.8971783383570358633e-44, -2.6168913164368963837e-61, 3.7036201000008290615e-78, + 5.6664945123924856962e-29, 6.5510079543732854985e-45, -2.6168913164368963837e-61, 3.7036201000008290615e-78, + 5.6664945123924856962e-29, 6.5510079543732854985e-45, -2.6168913164368963837e-61, 3.7036201000008290615e-78, + 6.1778471897801070206e-30, 9.4581409707401690366e-46, 4.9461632249367446986e-62, 3.7036201000008290615e-78, + 6.1778471897801070206e-30, 9.4581409707401690366e-46, 4.9461632249367446986e-62, 3.7036201000008290615e-78, + 6.1778471897801070206e-30, 9.4581409707401690366e-46, 4.9461632249367446986e-62, 3.7036201000008290615e-78, + 6.1778471897801070206e-30, 9.4581409707401690366e-46, 4.9461632249367446986e-62, 3.7036201000008290615e-78, + 3.0224035688960604996e-30, 2.451648649116083682e-46, 4.9461632249367446986e-62, 3.7036201000008290615e-78, + 1.4446817584540368888e-30, 2.451648649116083682e-46, 4.9461632249367446986e-62, 3.7036201000008290615e-78, + 6.5582085323302525856e-31, 7.0002556871006273225e-47, 1.0567786762735315635e-62, -6.1446417754639313137e-79, + 2.6139040062251944343e-31, -1.7578597149294783985e-47, 8.4432539107728090768e-64, 1.9517662449371102229e-79, + 6.4175174317266470186e-32, 4.3166913557804827486e-48, 8.4432539107728090768e-64, 1.9517662449371102229e-79, + 6.4175174317266470186e-32, 4.3166913557804827486e-48, 8.4432539107728090768e-64, 1.9517662449371102229e-79, + 1.4871367740953237822e-32, -1.1571307704883330232e-48, -6.7249112515659569668e-65, -7.2335760163150273591e-81, + 1.4871367740953237822e-32, -1.1571307704883330232e-48, -6.7249112515659569668e-65, -7.2335760163150273591e-81, + 2.5454160968749269937e-33, 2.1132476107887107169e-49, 8.7154294504188118783e-66, 1.2001823382693912203e-81, + 2.5454160968749269937e-33, 2.1132476107887107169e-49, 8.7154294504188118783e-66, 1.2001823382693912203e-81, + 2.5454160968749269937e-33, 2.1132476107887107169e-49, 8.7154294504188118783e-66, 1.2001823382693912203e-81, + 1.0046721413651383112e-33, 2.1132476107887107169e-49, 8.7154294504188118783e-66, 1.2001823382693912203e-81, + 2.3430016361024414106e-34, 4.0267819632970559834e-50, -7.8013829534098555144e-67, -1.1759240463442418271e-82, + 2.3430016361024414106e-34, 4.0267819632970559834e-50, -7.8013829534098555144e-67, -1.1759240463442418271e-82, + 4.1707169171520598517e-35, -2.4964157285045710972e-51, -1.866653112309982615e-67, 1.4185069655957361252e-83, + 4.1707169171520598517e-35, -2.4964157285045710972e-51, -1.866653112309982615e-67, 1.4185069655957361252e-83, + 4.1707169171520598517e-35, -2.4964157285045710972e-51, -1.866653112309982615e-67, 1.4185069655957361252e-83, + 1.7633044866680145008e-35, 2.8491136916798196016e-51, 4.0680767287898916022e-67, 1.4185069655957361252e-83, + 5.595982714259923599e-36, 1.7634898158762432635e-52, 3.588705781024702988e-68, 5.9489775128085140685e-84, + 5.595982714259923599e-36, 1.7634898158762432635e-52, 3.588705781024702988e-68, 5.9489775128085140685e-84, + 2.5867171761548675786e-36, 1.7634898158762432635e-52, 3.588705781024702988e-68, 5.9489775128085140685e-84, + 1.0820844071023395684e-36, 1.7634898158762432635e-52, 3.588705781024702988e-68, 5.9489775128085140685e-84, + 3.2976802257607573031e-37, 9.3011872068621332399e-54, 1.113250147552460308e-69, 2.9286284920280944778e-86, + 3.2976802257607573031e-37, 9.3011872068621332399e-54, 1.113250147552460308e-69, 2.9286284920280944778e-86, + 1.4168892644450972904e-37, 9.3011872068621332399e-54, 1.113250147552460308e-69, 2.9286284920280944778e-86, + 4.7649378378726728402e-38, 9.3011872068621332399e-54, 1.113250147552460308e-69, 2.9286284920280944778e-86, + 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 2.6226236120327253511e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 7.8591368887290111994e-41, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 7.8591368887290111994e-41, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 3.2673620808294506214e-41, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 9.7147467687967058732e-42, 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257943935e-91, + 9.7147467687967058732e-42, 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257943935e-91, + 3.9750282589222551507e-42, 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257943935e-91, + 1.1051690039850297894e-42, 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257943935e-91, + 1.1051690039850297894e-42, 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257943935e-91, + 3.8770419025072344914e-43, 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257943935e-91, + 2.8971783383570358633e-44, -2.6168913164368963837e-61, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 2.8971783383570358633e-44, -2.6168913164368963837e-61, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 2.8971783383570358633e-44, -2.6168913164368963837e-61, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 2.8971783383570358633e-44, -2.6168913164368963837e-61, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 6.5510079543732854985e-45, -2.6168913164368963837e-61, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 6.5510079543732854985e-45, -2.6168913164368963837e-61, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 9.4581409707401690366e-46, 4.9461632249367446986e-62, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 9.4581409707401690366e-46, 4.9461632249367446986e-62, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 9.4581409707401690366e-46, 4.9461632249367446986e-62, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 2.451648649116083682e-46, 4.9461632249367446986e-62, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 2.451648649116083682e-46, 4.9461632249367446986e-62, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 7.0002556871006273225e-47, 1.0567786762735315635e-62, -6.1446417754639301152e-79, -1.5355611056488084652e-94, + 7.0002556871006273225e-47, 1.0567786762735315635e-62, -6.1446417754639301152e-79, -1.5355611056488084652e-94, + 2.6211979860855749482e-47, 8.4432539107728090768e-64, 1.9517662449371099233e-79, 2.62202614552995759e-95, + 4.3166913557804827486e-48, 8.4432539107728090768e-64, 1.9517662449371099233e-79, 2.62202614552995759e-95, + 4.3166913557804827486e-48, 8.4432539107728090768e-64, 1.9517662449371099233e-79, 2.62202614552995759e-95, + 4.3166913557804827486e-48, 8.4432539107728090768e-64, 1.9517662449371099233e-79, 2.62202614552995759e-95, + 1.5797802926460750146e-48, 2.3660905534865399025e-64, -7.2335760163150273591e-81, 2.8738690232659205689e-99, + 2.1132476107887107169e-49, 8.7154294504188118783e-66, 1.2001823382693912203e-81, 2.8738690232659205689e-99, + 2.1132476107887107169e-49, 8.7154294504188118783e-66, 1.2001823382693912203e-81, 2.8738690232659205689e-99, + 2.1132476107887107169e-49, 8.7154294504188118783e-66, 1.2001823382693912203e-81, 2.8738690232659205689e-99, + 4.0267819632970559834e-50, -7.8013829534098555144e-67, -1.1759240463442418271e-82, 2.8738690232659205689e-99, + 4.0267819632970559834e-50, -7.8013829534098555144e-67, -1.1759240463442418271e-82, 2.8738690232659205689e-99, + 4.0267819632970559834e-50, -7.8013829534098555144e-67, -1.1759240463442418271e-82, 2.8738690232659205689e-99, + 1.8885701952232994665e-50, -7.8013829534098555144e-67, -1.1759240463442418271e-82, 2.8738690232659205689e-99, + 8.1946431118642097069e-51, 1.5937536410989638719e-66, 1.459625439463388979e-82, 2.8738690232659205689e-99, + 2.8491136916798196016e-51, 4.0680767287898916022e-67, 1.4185069655957361252e-83, -7.8369062883735917115e-100, + 1.7634898158762432635e-52, 3.588705781024702988e-68, 5.9489775128085131541e-84, 1.0450891972142808004e-99, + 1.7634898158762432635e-52, 3.588705781024702988e-68, 5.9489775128085131541e-84, 1.0450891972142808004e-99, + 1.7634898158762432635e-52, 3.588705781024702988e-68, 5.9489775128085131541e-84, 1.0450891972142808004e-99, + 1.7634898158762432635e-52, 3.588705781024702988e-68, 5.9489775128085131541e-84, 1.0450891972142808004e-99, + 9.3011872068621332399e-54, 1.113250147552460308e-69, 2.9286284920280941206e-86, 2.1132026692048600853e-102, + 9.3011872068621332399e-54, 1.113250147552460308e-69, 2.9286284920280941206e-86, 2.1132026692048600853e-102, + 9.3011872068621332399e-54, 1.113250147552460308e-69, 2.9286284920280941206e-86, 2.1132026692048600853e-102, + 9.3011872068621332399e-54, 1.113250147552460308e-69, 2.9286284920280941206e-86, 2.1132026692048600853e-102, + 9.3011872068621332399e-54, 1.113250147552460308e-69, 2.9286284920280941206e-86, 2.1132026692048600853e-102, + 4.0809436324633147776e-54, -4.587677453735884283e-71, -2.8859500138942368532e-87, -5.6567402911297190423e-103, + 1.470821845263904967e-54, -4.587677453735884283e-71, -2.8859500138942368532e-87, -5.6567402911297190423e-103, + 1.6576095166419998917e-55, 2.6568658093254848067e-71, 5.1571087196495574384e-87, 3.2728487032630537605e-103, + 1.6576095166419998917e-55, 2.6568658093254848067e-71, 5.1571087196495574384e-87, 3.2728487032630537605e-103, + 1.6576095166419998917e-55, 2.6568658093254848067e-71, 5.1571087196495574384e-87, 3.2728487032630537605e-103, + 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.5242184730639744369e-90, 1.145584788913072936e-105, + 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.5242184730639744369e-90, 1.145584788913072936e-105, + 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.5242184730639744369e-90, 1.145584788913072936e-105, + 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.5242184730639744369e-90, 1.145584788913072936e-105, + 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.5242184730639744369e-90, 1.145584788913072936e-105, + 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.5242184730639744369e-90, 1.145584788913072936e-105, + 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.554706987098633963e-107, + 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.554706987098633963e-107, + 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.554706987098633963e-107, + 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.554706987098633963e-107, + 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.554706987098633963e-107, + 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.554706987098633963e-107, + 3.9565608646667614317e-59, 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.554706987098633963e-107, + 1.9651959757511960854e-59, 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.554706987098633963e-107, + 9.6951353129341363331e-60, 7.6368645294831185015e-76, 1.0603435429602168369e-91, 1.0451839188820145747e-108, + 4.7167230906452229674e-60, 7.6368645294831185015e-76, 1.0603435429602168369e-91, 1.0451839188820145747e-108, + 2.2275169795007668372e-60, 2.1097166542226745549e-76, 4.4670685979800101779e-92, 1.0451839188820145747e-108, + 9.8291392392853877215e-61, -6.5385728340754726503e-77, -1.3520652573660833788e-93, -2.3220403312043059402e-109, + 3.6061239614242446325e-61, 7.2792968540756372162e-77, 1.3988851821689310822e-92, 1.0451839188820145747e-108, + 4.9461632249367446986e-62, 3.7036201000008285821e-78, 5.6554937751584084315e-94, -1.9306041120023063932e-110, + 4.9461632249367446986e-62, 3.7036201000008285821e-78, 5.6554937751584084315e-94, -1.9306041120023063932e-110, + 4.9461632249367446986e-62, 3.7036201000008285821e-78, 5.6554937751584084315e-94, -1.9306041120023063932e-110, + 1.0567786762735315635e-62, -6.1446417754639301152e-79, -1.535561105648808199e-94, -1.9306041120023063932e-110, + 1.0567786762735315635e-62, -6.1446417754639301152e-79, -1.535561105648808199e-94, -1.9306041120023063932e-110, + 8.4432539107728090768e-64, 1.9517662449371099233e-79, 2.62202614552995759e-95, 6.5314563001514358328e-112, + 8.4432539107728090768e-64, 1.9517662449371099233e-79, 2.62202614552995759e-95, 6.5314563001514358328e-112, + 8.4432539107728090768e-64, 1.9517662449371099233e-79, 2.62202614552995759e-95, 6.5314563001514358328e-112, + 8.4432539107728090768e-64, 1.9517662449371099233e-79, 2.62202614552995759e-95, 6.5314563001514358328e-112, + 2.3660905534865399025e-64, -7.2335760163150273591e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, + 2.3660905534865399025e-64, -7.2335760163150273591e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, + 8.4679971416497210292e-65, -7.2335760163150273591e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, + 8.7154294504188118783e-66, 1.2001823382693912203e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, + 8.7154294504188118783e-66, 1.2001823382693912203e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, + 8.7154294504188118783e-66, 1.2001823382693912203e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, + 8.7154294504188118783e-66, 1.2001823382693912203e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, + 3.9676455775389135587e-66, 1.459625439463388979e-82, 2.8738690232659205689e-99, 1.8395411057335783574e-115, + 1.5937536410989638719e-66, 1.459625439463388979e-82, 2.8738690232659205689e-99, 1.8395411057335783574e-115, + 4.0680767287898916022e-67, 1.4185069655957361252e-83, -7.8369062883735917115e-100, -1.9081236411894110579e-116, + 4.0680767287898916022e-67, 1.4185069655957361252e-83, -7.8369062883735917115e-100, -1.9081236411894110579e-116, + 1.1007118082399544936e-67, 1.4185069655957361252e-83, -7.8369062883735917115e-100, -1.9081236411894110579e-116, + 1.1007118082399544936e-67, 1.4185069655957361252e-83, -7.8369062883735917115e-100, -1.9081236411894110579e-116, + 3.588705781024702988e-68, 5.9489775128085131541e-84, 1.0450891972142805974e-99, 1.8395411057335783574e-115, + 3.588705781024702988e-68, 5.9489775128085131541e-84, 1.0450891972142805974e-99, 1.8395411057335783574e-115, + 1.7341027056809927069e-68, 1.830931441234090934e-84, 1.3069928418846076386e-100, 3.1677600334418876704e-116, + 8.0680116800913756637e-69, -2.2809159455312046184e-85, -4.0748824503880445403e-101, -6.3915272253158644628e-117, + 3.4315039917320989315e-69, -2.2809159455312046184e-85, -4.0748824503880445403e-101, -6.3915272253158644628e-117, + 1.113250147552460308e-69, 2.9286284920280941206e-86, 2.1132026692048600853e-102, -4.6672632026740766185e-119, + 1.113250147552460308e-69, 2.9286284920280941206e-86, 2.1132026692048600853e-102, -4.6672632026740766185e-119, + 5.3368668650755071652e-70, 2.9286284920280941206e-86, 2.1132026692048600853e-102, -4.6672632026740766185e-119, + 2.4390495598509592076e-70, 2.9286284920280941206e-86, 2.1132026692048600853e-102, -4.6672632026740766185e-119, + 9.901409072386855505e-71, -2.8859500138942368532e-87, -5.6567402911297190423e-103, -4.6672632026740766185e-119, + 2.6568658093254848067e-71, 5.1571087196495574384e-87, 3.2728487032630532648e-103, 5.2465720993401781599e-119, + 2.6568658093254848067e-71, 5.1571087196495574384e-87, 3.2728487032630532648e-103, 5.2465720993401781599e-119, + 8.4572999356014273536e-72, 1.1355793528776598461e-87, 3.2728487032630532648e-103, 5.2465720993401781599e-119, + 8.4572999356014273536e-72, 1.1355793528776598461e-87, 3.2728487032630532648e-103, 5.2465720993401781599e-119, + 3.9294603961880721752e-72, 1.3019701118468578292e-88, -7.5747169634236195447e-105, -2.0152904854894729832e-121, + 1.6655406264813940833e-72, 1.3019701118468578292e-88, -7.5747169634236195447e-105, -2.0152904854894729832e-121, + 5.3358074162805516304e-73, 4.5242184730639744369e-90, 1.1455847889130727424e-105, 1.8573014293598455046e-121, + 5.3358074162805516304e-73, 4.5242184730639744369e-90, 1.1455847889130727424e-105, 1.8573014293598455046e-121, + 2.5059077041472040156e-73, 4.5242184730639744369e-90, 1.1455847889130727424e-105, 1.8573014293598455046e-121, + 1.0909578480805302081e-73, 4.5242184730639744369e-90, 1.1455847889130727424e-105, 1.8573014293598455046e-121, + 3.8348292004719330442e-74, 4.5242184730639744369e-90, 1.1455847889130727424e-105, 1.8573014293598455046e-121, + 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.5547069870986327528e-107, 1.6304246661326865276e-122, + 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.5547069870986327528e-107, 1.6304246661326865276e-122, + 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.5547069870986327528e-107, 1.6304246661326865276e-122, + 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.5547069870986327528e-107, 1.6304246661326865276e-122, + 7.6368645294831185015e-76, 1.0603435429602168369e-91, 1.0451839188820145747e-108, 4.2386081393205242443e-125, + 7.6368645294831185015e-76, 1.0603435429602168369e-91, 1.0451839188820145747e-108, 4.2386081393205242443e-125, + 2.1097166542226745549e-76, 4.4670685979800101779e-92, 1.0451839188820145747e-108, 4.2386081393205242443e-125, + 2.1097166542226745549e-76, 4.4670685979800101779e-92, 1.0451839188820145747e-108, 4.2386081393205242443e-125, + 7.2792968540756372162e-77, 1.3988851821689310822e-92, 1.0451839188820145747e-108, 4.2386081393205242443e-125, + 3.7036201000008285821e-78, 5.6554937751584084315e-94, -1.9306041120023063932e-110, 1.0223371855251472933e-126, + 3.7036201000008285821e-78, 5.6554937751584084315e-94, -1.9306041120023063932e-110, 1.0223371855251472933e-126, + 3.7036201000008285821e-78, 5.6554937751584084315e-94, -1.9306041120023063932e-110, 1.0223371855251472933e-126, + 3.7036201000008285821e-78, 5.6554937751584084315e-94, -1.9306041120023063932e-110, 1.0223371855251472933e-126, + 3.7036201000008285821e-78, 5.6554937751584084315e-94, -1.9306041120023063932e-110, 1.0223371855251472933e-126, + 1.5445779612272179051e-78, 8.6145718795359707834e-95, 7.3062078800278780675e-111, 1.0223371855251472933e-126, + 4.6505689184041232695e-79, 8.6145718795359707834e-95, 7.3062078800278780675e-111, 1.0223371855251472933e-126, + 4.6505689184041232695e-79, 8.6145718795359707834e-95, 7.3062078800278780675e-111, 1.0223371855251472933e-126, + 1.9517662449371099233e-79, 2.62202614552995759e-95, 6.5314563001514349095e-112, 9.9039323746573674262e-128, + 6.0236490820360325022e-80, -3.7424672147304925625e-96, -1.784871512364483542e-112, 6.7095375687163151728e-129, + 6.0236490820360325022e-80, -3.7424672147304925625e-96, -1.784871512364483542e-112, 6.7095375687163151728e-129, + 2.6501457402022643213e-80, 3.7482149527770239293e-96, 6.5314563001514349095e-112, 9.9039323746573674262e-128, + 9.6339406928538097998e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, + 1.2001823382693912203e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, + 1.2001823382693912203e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, + 1.2001823382693912203e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, + 1.459625439463388979e-82, 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, + 1.459625439463388979e-82, 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, + 1.459625439463388979e-82, 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, + 1.4185069655957361252e-83, -7.8369062883735917115e-100, -1.9081236411894107761e-116, -2.1796760241698337334e-132, + 1.4185069655957361252e-83, -7.8369062883735917115e-100, -1.9081236411894107761e-116, -2.1796760241698337334e-132, + 1.4185069655957361252e-83, -7.8369062883735917115e-100, -1.9081236411894107761e-116, -2.1796760241698337334e-132, + 1.4185069655957361252e-83, -7.8369062883735917115e-100, -1.9081236411894107761e-116, -2.1796760241698337334e-132, + 5.9489775128085131541e-84, 1.0450891972142805974e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, + 1.830931441234090934e-84, 1.3069928418846076386e-100, 3.1677600334418871069e-116, 3.4556869017247800778e-132, + 1.830931441234090934e-84, 1.3069928418846076386e-100, 3.1677600334418871069e-116, 3.4556869017247800778e-132, + 8.0141992334048515034e-85, 1.3069928418846076386e-100, 3.1677600334418871069e-116, 3.4556869017247800778e-132, + 2.8666416439368237283e-85, 1.6400545060233297363e-101, -4.6672632026740766185e-119, -3.755176715260116501e-136, + 2.9286284920280941206e-86, 2.1132026692048600853e-102, -4.6672632026740766185e-119, -3.755176715260116501e-136, + 2.9286284920280941206e-86, 2.1132026692048600853e-102, -4.6672632026740766185e-119, -3.755176715260116501e-136, + 2.9286284920280941206e-86, 2.1132026692048600853e-102, -4.6672632026740766185e-119, -3.755176715260116501e-136, + 2.9286284920280941206e-86, 2.1132026692048600853e-102, -4.6672632026740766185e-119, -3.755176715260116501e-136, + 1.3200167453193350837e-86, 2.1132026692048600853e-102, -4.6672632026740766185e-119, -3.755176715260116501e-136, + 5.1571087196495574384e-87, 3.2728487032630532648e-103, 5.2465720993401781599e-119, -3.755176715260116501e-136, + 1.1355793528776598461e-87, 3.2728487032630532648e-103, 5.2465720993401781599e-119, -3.755176715260116501e-136, + 1.1355793528776598461e-87, 3.2728487032630532648e-103, 5.2465720993401781599e-119, -3.755176715260116501e-136, + 1.3019701118468578292e-88, -7.5747169634236195447e-105, -2.0152904854894725532e-121, -3.1562414818576682143e-137, + 1.3019701118468578292e-88, -7.5747169634236195447e-105, -2.0152904854894725532e-121, -3.1562414818576682143e-137, + 1.3019701118468578292e-88, -7.5747169634236195447e-105, -2.0152904854894725532e-121, -3.1562414818576682143e-137, + 4.5242184730639744369e-90, 1.1455847889130727424e-105, 1.8573014293598452896e-121, 1.1431992269852683481e-137, + 4.5242184730639744369e-90, 1.1455847889130727424e-105, 1.8573014293598452896e-121, 1.1431992269852683481e-137, + 4.5242184730639744369e-90, 1.1455847889130727424e-105, 1.8573014293598452896e-121, 1.1431992269852683481e-137, + 4.5242184730639744369e-90, 1.1455847889130727424e-105, 1.8573014293598452896e-121, 1.1431992269852683481e-137, + 4.5242184730639744369e-90, 1.1455847889130727424e-105, 1.8573014293598452896e-121, 1.1431992269852683481e-137, + 5.969437008257942845e-91, 5.5547069870986327528e-107, 1.6304246661326865276e-122, 6.8339049774534162772e-139, + 5.969437008257942845e-91, 5.5547069870986327528e-107, 1.6304246661326865276e-122, 6.8339049774534162772e-139, + 5.969437008257942845e-91, 5.5547069870986327528e-107, 1.6304246661326865276e-122, 6.8339049774534162772e-139, + 1.0603435429602168369e-91, 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591188256e-141, + 1.0603435429602168369e-91, 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591188256e-141, + 1.0603435429602168369e-91, 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591188256e-141, + 4.4670685979800101779e-92, 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591188256e-141, + 1.3988851821689310822e-92, 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591188256e-141, + 1.3988851821689310822e-92, 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591188256e-141, + 6.3183932821616130831e-93, 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591188256e-141, + 2.4831640123977650651e-93, 1.9359195088038447797e-109, -4.8867691298577234423e-126, -2.0587960670007823264e-142, + 5.6554937751584084315e-94, -1.9306041120023063932e-110, 1.0223371855251471293e-126, 1.2214168761472102282e-142, + 5.6554937751584084315e-94, -1.9306041120023063932e-110, 1.0223371855251471293e-126, 1.2214168761472102282e-142, + 8.6145718795359707834e-95, 7.3062078800278780675e-111, 1.0223371855251471293e-126, 1.2214168761472102282e-142, + 8.6145718795359707834e-95, 7.3062078800278780675e-111, 1.0223371855251471293e-126, 1.2214168761472102282e-142, + 8.6145718795359707834e-95, 7.3062078800278780675e-111, 1.0223371855251471293e-126, 1.2214168761472102282e-142, + 2.62202614552995759e-95, 6.5314563001514349095e-112, 9.9039323746573674262e-128, -8.6629775332868987041e-145, + 2.62202614552995759e-95, 6.5314563001514349095e-112, 9.9039323746573674262e-128, -8.6629775332868987041e-145, + 1.1238897120284541253e-95, 6.5314563001514349095e-112, 9.9039323746573674262e-128, -8.6629775332868987041e-145, + 3.7482149527770239293e-96, 6.5314563001514349095e-112, 9.9039323746573674262e-128, -8.6629775332868987041e-145, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 1.0450891972142805974e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 1.3069928418846076386e-100, 3.1677600334418871069e-116, 3.4556869017247794521e-132, 8.5448727249069983612e-148, + 1.3069928418846076386e-100, 3.1677600334418871069e-116, 3.4556869017247794521e-132, 8.5448727249069983612e-148, + 1.3069928418846076386e-100, 3.1677600334418871069e-116, 3.4556869017247794521e-132, 8.5448727249069983612e-148, + 1.6400545060233297363e-101, -4.6672632026740766185e-119, -3.755176715260116501e-136, 2.1571619860435652883e-152, + 1.6400545060233297363e-101, -4.6672632026740766185e-119, -3.755176715260116501e-136, 2.1571619860435652883e-152, + 1.6400545060233297363e-101, -4.6672632026740766185e-119, -3.755176715260116501e-136, 2.1571619860435652883e-152, + 2.1132026692048600853e-102, -4.6672632026740766185e-119, -3.755176715260116501e-136, 2.1571619860435652883e-152, + 2.1132026692048600853e-102, -4.6672632026740766185e-119, -3.755176715260116501e-136, 2.1571619860435652883e-152, + 2.1132026692048600853e-102, -4.6672632026740766185e-119, -3.755176715260116501e-136, 2.1571619860435652883e-152, + 3.2728487032630532648e-103, 5.2465720993401781599e-119, -3.755176715260116501e-136, 2.1571619860435652883e-152, + 3.2728487032630532648e-103, 5.2465720993401781599e-119, -3.755176715260116501e-136, 2.1571619860435652883e-152, + 3.2728487032630532648e-103, 5.2465720993401781599e-119, -3.755176715260116501e-136, 2.1571619860435652883e-152, + 1.0404514546648604359e-103, 2.896544483330507019e-120, 3.1239284188885823808e-136, 2.1571619860435652883e-152, + 1.0404514546648604359e-103, 2.896544483330507019e-120, 3.1239284188885823808e-136, 2.1571619860435652883e-152, + 4.8235214251531210473e-104, 2.896544483330507019e-120, 3.1239284188885823808e-136, 2.1571619860435652883e-152, + 2.0330248644053793915e-104, 2.896544483330507019e-120, 3.1239284188885823808e-136, 2.1571619860435652883e-152, + 6.3777658403150887343e-105, -2.0152904854894725532e-121, -3.156241481857667737e-137, -7.0684085473731388916e-153, + 6.3777658403150887343e-105, -2.0152904854894725532e-121, -3.156241481857667737e-137, -7.0684085473731388916e-153, + 2.88964513938041089e-105, 5.7298933442091639924e-121, -3.156241481857667737e-137, -7.0684085473731388916e-153, + 1.1455847889130727424e-105, 1.8573014293598452896e-121, 1.1431992269852681095e-137, 2.4782675885631257398e-153, + 2.7355461367940366859e-106, -7.8994528064813712419e-123, -2.0037599452814940222e-138, 9.1598554579059548847e-155, + 2.7355461367940366859e-106, -7.8994528064813712419e-123, -2.0037599452814940222e-138, 9.1598554579059548847e-155, + 5.5547069870986327528e-107, 1.6304246661326865276e-122, 6.8339049774534147855e-139, 9.1598554579059548847e-155, + 5.5547069870986327528e-107, 1.6304246661326865276e-122, 6.8339049774534147855e-139, 9.1598554579059548847e-155, + 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, + 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, + 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, + 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, + 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, + 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, + 1.9359195088038447797e-109, -4.8867691298577234423e-126, -2.0587960670007819622e-142, -2.8326669474241479263e-158, + 1.9359195088038447797e-109, -4.8867691298577234423e-126, -2.0587960670007819622e-142, -2.8326669474241479263e-158, + 1.9359195088038447797e-109, -4.8867691298577234423e-126, -2.0587960670007819622e-142, -2.8326669474241479263e-158, + 8.7142954880180709975e-110, -4.8867691298577234423e-126, -2.0587960670007819622e-142, -2.8326669474241479263e-158, + 3.3918456880078814158e-110, 6.931443500908017045e-126, 1.1062055705591186799e-141, 1.1734404793201255869e-157, + 7.3062078800278780675e-111, 1.0223371855251471293e-126, 1.2214168761472102282e-142, 8.0910098773220312367e-159, + 7.3062078800278780675e-111, 1.0223371855251471293e-126, 1.2214168761472102282e-142, 8.0910098773220312367e-159, + 6.5314563001514349095e-112, 9.9039323746573674262e-128, -8.6629775332868972816e-145, -1.5987060076657616072e-160, + 6.5314563001514349095e-112, 9.9039323746573674262e-128, -8.6629775332868972816e-145, -1.5987060076657616072e-160, + 6.5314563001514349095e-112, 9.9039323746573674262e-128, -8.6629775332868972816e-145, -1.5987060076657616072e-160, + 6.5314563001514349095e-112, 9.9039323746573674262e-128, -8.6629775332868972816e-145, -1.5987060076657616072e-160, + 2.3732923938934761454e-112, 6.7095375687163138915e-129, 1.6963686085056791706e-144, 1.2464251916751375716e-160, + 2.9421044076449630171e-113, 6.7095375687163138915e-129, 1.6963686085056791706e-144, 1.2464251916751375716e-160, + 2.9421044076449630171e-113, 6.7095375687163138915e-129, 1.6963686085056791706e-144, 1.2464251916751375716e-160, + 2.9421044076449630171e-113, 6.7095375687163138915e-129, 1.6963686085056791706e-144, 1.2464251916751375716e-160, + 3.4325196623373878948e-114, 9.3892593260023063019e-130, 9.4702132359198537748e-146, 1.7950099192230045857e-161, + 3.4325196623373878948e-114, 9.3892593260023063019e-130, 9.4702132359198537748e-146, 1.7950099192230045857e-161, + 3.4325196623373878948e-114, 9.3892593260023063019e-130, 9.4702132359198537748e-146, 1.7950099192230045857e-161, + 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, 2.9106774506606945839e-164, + 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, 2.9106774506606945839e-164, + 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, 2.9106774506606945839e-164, + 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, 2.9106774506606945839e-164, + 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, 2.9106774506606945839e-164, + 8.2436437080731844263e-116, 1.4726412753514008951e-131, -3.9681466199873824165e-148, 2.9106774506606945839e-164, + 3.1677600334418871069e-116, 3.4556869017247794521e-132, 8.544872724906996972e-148, 1.6802919634942429241e-163, + 6.2981819612623816536e-117, 6.3800543877747317218e-133, 7.2423563434801054878e-149, 1.1741471776254779927e-164, + 6.2981819612623816536e-117, 6.3800543877747317218e-133, 7.2423563434801054878e-149, 1.1741471776254779927e-164, + 6.2981819612623816536e-117, 6.3800543877747317218e-133, 7.2423563434801054878e-149, 1.1741471776254779927e-164, + 3.1257546646178208289e-117, -6.6414926959353515111e-134, -5.7828074707888119584e-150, -1.2825052715093464343e-165, + 1.5395410162955400644e-117, -6.6414926959353515111e-134, -5.7828074707888119584e-150, -1.2825052715093464343e-165, + 7.4643419213439950602e-118, 1.0969016447485317626e-133, -5.7828074707888119584e-150, -1.2825052715093464343e-165, + 3.4988078005382940294e-118, 2.1637618757749825688e-134, -8.9490928918944555247e-151, -1.9717385086233606481e-166, + 1.5160407401354430737e-118, 2.1637618757749825688e-134, -8.9490928918944555247e-151, -1.9717385086233606481e-166, + 5.2465720993401781599e-119, -3.755176715260116501e-136, 2.1571619860435648643e-152, 6.3257905089784152346e-168, + 2.896544483330507019e-120, 3.1239284188885823808e-136, 2.1571619860435648643e-152, 6.3257905089784152346e-168, + 2.896544483330507019e-120, 3.1239284188885823808e-136, 2.1571619860435648643e-152, 6.3257905089784152346e-168, + 2.896544483330507019e-120, 3.1239284188885823808e-136, 2.1571619860435648643e-152, 6.3257905089784152346e-168, + 2.896544483330507019e-120, 3.1239284188885823808e-136, 2.1571619860435648643e-152, 6.3257905089784152346e-168, + 2.896544483330507019e-120, 3.1239284188885823808e-136, 2.1571619860435648643e-152, 6.3257905089784152346e-168, + 1.3475077173907800538e-120, -3.156241481857667737e-137, -7.0684085473731388916e-153, -3.3573283875161501977e-170, + 5.7298933442091639924e-121, -3.156241481857667737e-137, -7.0684085473731388916e-153, -3.3573283875161501977e-170, + 1.8573014293598452896e-121, 1.1431992269852681095e-137, 2.4782675885631257398e-153, -3.3573283875161501977e-170, + 1.8573014293598452896e-121, 1.1431992269852681095e-137, 2.4782675885631257398e-153, -3.3573283875161501977e-170, + 8.8915345064751572143e-122, 1.1431992269852681095e-137, 2.4782675885631257398e-153, -3.3573283875161501977e-170, + 4.0507946129135104481e-122, 6.8339049774534147855e-139, 9.1598554579059548847e-155, -4.5159745404911825673e-172, + 1.6304246661326865276e-122, 6.8339049774534147855e-139, 9.1598554579059548847e-155, -4.5159745404911825673e-172, + 4.2023969274227456735e-123, 6.8339049774534147855e-139, 9.1598554579059548847e-155, -4.5159745404911825673e-172, + 4.2023969274227456735e-123, 6.8339049774534147855e-139, 9.1598554579059548847e-155, -4.5159745404911825673e-172, + 1.1769344939467164447e-123, 1.1602886988632691941e-140, 3.0307583960570927356e-156, 5.8345524661064369683e-172, + 1.1769344939467164447e-123, 1.1602886988632691941e-140, 3.0307583960570927356e-156, 5.8345524661064369683e-172, + 4.2056888557770896953e-124, 1.1602886988632691941e-140, 3.0307583960570927356e-156, 5.8345524661064369683e-172, + 4.2386081393205242443e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, 1.2381024895275844856e-174, + 4.2386081393205242443e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, 1.2381024895275844856e-174, + 4.2386081393205242443e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, 1.2381024895275844856e-174, + 4.2386081393205242443e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, 1.2381024895275844856e-174, + 1.8749656131673758844e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, 1.2381024895275844856e-174, + 6.931443500908017045e-126, 1.1062055705591186799e-141, 1.1734404793201255869e-157, 1.2381024895275844856e-174, + 1.0223371855251471293e-126, 1.2214168761472102282e-142, 8.0910098773220302259e-159, 1.2381024895275844856e-174, + 1.0223371855251471293e-126, 1.2214168761472102282e-142, 8.0910098773220302259e-159, 1.2381024895275844856e-174, + 1.0223371855251471293e-126, 1.2214168761472102282e-142, 8.0910098773220302259e-159, 1.2381024895275844856e-174, + 2.8369889610228834887e-127, 4.0136364036021218058e-143, -1.0134099605688458828e-159, -2.5389576707476506925e-176, + 2.8369889610228834887e-127, 4.0136364036021218058e-143, -1.0134099605688458828e-159, -2.5389576707476506925e-176, + 9.9039323746573674262e-128, -8.6629775332868972816e-145, -1.5987060076657612913e-160, -2.5389576707476506925e-176, + 6.7095375687163138915e-129, 1.6963686085056791706e-144, 1.2464251916751375716e-160, 6.197724948400014906e-177, + 6.7095375687163138915e-129, 1.6963686085056791706e-144, 1.2464251916751375716e-160, 6.197724948400014906e-177, + 6.7095375687163138915e-129, 1.6963686085056791706e-144, 1.2464251916751375716e-160, 6.197724948400014906e-177, + 6.7095375687163138915e-129, 1.6963686085056791706e-144, 1.2464251916751375716e-160, 6.197724948400014906e-177, + 9.3892593260023063019e-130, 9.4702132359198537748e-146, 1.7950099192230045857e-161, -1.6991004655691155518e-177, + 9.3892593260023063019e-130, 9.4702132359198537748e-146, 1.7950099192230045857e-161, -1.6991004655691155518e-177, + 9.3892593260023063019e-130, 9.4702132359198537748e-146, 1.7950099192230045857e-161, -1.6991004655691155518e-177, + 2.175994780857201024e-130, 1.4618808551874518553e-146, 1.6802919634942426156e-163, 2.8330093736631818036e-179, + 2.175994780857201024e-130, 1.4618808551874518553e-146, 1.6802919634942426156e-163, 2.8330093736631818036e-179, + 3.7267864457092460442e-131, 4.6083930759590139305e-147, 1.6802919634942426156e-163, 2.8330093736631818036e-179, + 3.7267864457092460442e-131, 4.6083930759590139305e-147, 1.6802919634942426156e-163, 2.8330093736631818036e-179, + 3.7267864457092460442e-131, 4.6083930759590139305e-147, 1.6802919634942426156e-163, 2.8330093736631818036e-179, + 1.4726412753514008951e-131, -3.9681466199873824165e-148, 2.9106774506606941983e-164, 5.1948630316441296498e-180, + 3.4556869017247794521e-132, 8.544872724906996972e-148, 1.6802919634942426156e-163, 2.8330093736631818036e-179, + 3.4556869017247794521e-132, 8.544872724906996972e-148, 1.6802919634942426156e-163, 2.8330093736631818036e-179, + 6.3800543877747317218e-133, 7.2423563434801054878e-149, 1.1741471776254777999e-164, 1.3389912474795152755e-180, + 6.3800543877747317218e-133, 7.2423563434801054878e-149, 1.1741471776254777999e-164, 1.3389912474795152755e-180, + 6.3800543877747317218e-133, 7.2423563434801054878e-149, 1.1741471776254777999e-164, 1.3389912474795152755e-180, + 2.8579525590905986764e-133, -5.7828074707888119584e-150, -1.2825052715093464343e-165, -1.0696067158221530218e-181, + 1.0969016447485317626e-133, -5.7828074707888119584e-150, -1.2825052715093464343e-165, -1.0696067158221530218e-181, + 2.1637618757749825688e-134, -8.9490928918944555247e-151, -1.9717385086233606481e-166, 1.3535321672928907047e-182, + 2.1637618757749825688e-134, -8.9490928918944555247e-151, -1.9717385086233606481e-166, 1.3535321672928907047e-182, + 2.1637618757749825688e-134, -8.9490928918944555247e-151, -1.9717385086233606481e-166, 1.3535321672928907047e-182, + 1.0631050543111905033e-134, 1.5490398016102376505e-150, 3.4549185946116918017e-166, 1.3535321672928907047e-182, + 5.1277664357929471499e-135, 3.2706525621039604902e-151, 7.4159004299416557678e-167, 1.3535321672928907047e-182, + 2.3761243821334675971e-135, 3.2706525621039604902e-151, 7.4159004299416557678e-167, 1.3535321672928907047e-182, + 1.0003033553037281263e-135, 2.1571619860435648643e-152, 6.3257905089784152346e-168, 3.5607241064750984115e-184, + 3.1239284188885823808e-136, 2.1571619860435648643e-152, 6.3257905089784152346e-168, 3.5607241064750984115e-184, + 3.1239284188885823808e-136, 2.1571619860435648643e-152, 6.3257905089784152346e-168, 3.5607241064750984115e-184, + 1.4041521353514076604e-136, 2.1571619860435648643e-152, 6.3257905089784152346e-168, 3.5607241064750984115e-184, + 5.4426399358282049106e-137, 2.4782675885631257398e-153, -3.3573283875161501977e-170, 3.0568054078295488291e-186, + 1.1431992269852681095e-137, 2.4782675885631257398e-153, -3.3573283875161501977e-170, 3.0568054078295488291e-186, + 1.1431992269852681095e-137, 2.4782675885631257398e-153, -3.3573283875161501977e-170, 3.0568054078295488291e-186, + 6.8339049774534147855e-139, 9.1598554579059548847e-155, -4.5159745404911819927e-172, -4.5870810097328578981e-188, + 6.8339049774534147855e-139, 9.1598554579059548847e-155, -4.5159745404911819927e-172, -4.5870810097328578981e-188, + 6.8339049774534147855e-139, 9.1598554579059548847e-155, -4.5159745404911819927e-172, -4.5870810097328578981e-188, + 6.8339049774534147855e-139, 9.1598554579059548847e-155, -4.5159745404911819927e-172, -4.5870810097328578981e-188, + 1.1602886988632691941e-140, 3.0307583960570927356e-156, 5.8345524661064358191e-172, 6.9043123899963188689e-188, + 1.1602886988632691941e-140, 3.0307583960570927356e-156, 5.8345524661064358191e-172, 6.9043123899963188689e-188, + 1.1602886988632691941e-140, 3.0307583960570927356e-156, 5.8345524661064358191e-172, 6.9043123899963188689e-188, + 1.1602886988632691941e-140, 3.0307583960570927356e-156, 5.8345524661064358191e-172, 6.9043123899963188689e-188, + 1.1602886988632691941e-140, 3.0307583960570927356e-156, 5.8345524661064358191e-172, 6.9043123899963188689e-188, + 1.1602886988632691941e-140, 3.0307583960570927356e-156, 5.8345524661064358191e-172, 6.9043123899963188689e-188, + 1.1062055705591186799e-141, 1.1734404793201255869e-157, 1.2381024895275844856e-174, -8.4789520282639751913e-191, + 1.1062055705591186799e-141, 1.1734404793201255869e-157, 1.2381024895275844856e-174, -8.4789520282639751913e-191, + 1.1062055705591186799e-141, 1.1734404793201255869e-157, 1.2381024895275844856e-174, -8.4789520282639751913e-191, + 1.1062055705591186799e-141, 1.1734404793201255869e-157, 1.2381024895275844856e-174, -8.4789520282639751913e-191, + 4.5016298192952031469e-142, -2.8326669474241479263e-158, 1.2381024895275844856e-174, -8.4789520282639751913e-191, + 1.2214168761472102282e-142, 8.0910098773220302259e-159, 1.2381024895275844856e-174, -8.4789520282639751913e-191, + 1.2214168761472102282e-142, 8.0910098773220302259e-159, 1.2381024895275844856e-174, -8.4789520282639751913e-191, + 4.0136364036021218058e-143, -1.0134099605688458828e-159, -2.5389576707476506925e-176, -6.2404128071707654958e-193, + 4.0136364036021218058e-143, -1.0134099605688458828e-159, -2.5389576707476506925e-176, -6.2404128071707654958e-193, + 1.9635033141346264592e-143, -1.0134099605688458828e-159, -2.5389576707476506925e-176, -6.2404128071707654958e-193, + 9.3843676940087855824e-144, 1.2626949989038732076e-159, 2.2730883653953564668e-175, 2.7431118386590483722e-191, + 4.2590349703400483539e-144, 1.2464251916751375716e-160, 6.1977249484000140293e-177, 1.1294061984896458822e-192, + 1.6963686085056791706e-144, 1.2464251916751375716e-160, 6.1977249484000140293e-177, 1.1294061984896458822e-192, + 4.1503542758849472122e-145, -1.7614040799531193879e-161, -1.6991004655691153326e-177, -1.856794109153959173e-193, + 4.1503542758849472122e-145, -1.7614040799531193879e-161, -1.6991004655691153326e-177, -1.856794109153959173e-193, + 9.4702132359198537748e-146, 1.7950099192230045857e-161, -1.6991004655691153326e-177, -1.856794109153959173e-193, + 9.4702132359198537748e-146, 1.7950099192230045857e-161, -1.6991004655691153326e-177, -1.856794109153959173e-193, + 1.4618808551874518553e-146, 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, + 1.4618808551874518553e-146, 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, + 1.4618808551874518553e-146, 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, + 4.6083930759590139305e-147, 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, + 4.6083930759590139305e-147, 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, + 2.105789206980137775e-147, 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, + 8.544872724906996972e-148, 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, + 2.2883630524598079723e-148, 2.9106774506606941983e-164, 5.1948630316441287936e-180, 9.6685396110091032843e-196, + 2.2883630524598079723e-148, 2.9106774506606941983e-164, 5.1948630316441287936e-180, 9.6685396110091032843e-196, + 7.2423563434801054878e-149, 1.1741471776254777999e-164, 1.3389912474795150614e-180, 1.1067843414450286726e-196, + 7.2423563434801054878e-149, 1.1741471776254777999e-164, 1.3389912474795150614e-180, 1.1067843414450286726e-196, + 3.3320377982006123631e-149, 3.0588204110786950436e-165, 3.7502330143836152136e-181, 3.6564932749519464998e-198, + 1.3768785255608653665e-149, 3.0588204110786950436e-165, 3.7502330143836152136e-181, 3.6564932749519464998e-198, + 3.9929888924099219388e-150, -1.9717385086233606481e-166, 1.3535321672928907047e-182, 3.1205762277848031878e-199, + 3.9929888924099219388e-150, -1.9717385086233606481e-166, 1.3535321672928907047e-182, 3.1205762277848031878e-199, + 1.5490398016102376505e-150, 3.4549185946116918017e-166, 1.3535321672928907047e-182, 3.1205762277848031878e-199, + 3.2706525621039604902e-151, 7.4159004299416557678e-167, 1.3535321672928907047e-182, 3.1205762277848031878e-199, + 3.2706525621039604902e-151, 7.4159004299416557678e-167, 1.3535321672928907047e-182, 3.1205762277848031878e-199, + 2.1571619860435648643e-152, 6.3257905089784152346e-168, 3.5607241064750984115e-184, -1.4832196127821708615e-201, + 2.1571619860435648643e-152, 6.3257905089784152346e-168, 3.5607241064750984115e-184, -1.4832196127821708615e-201, + 2.1571619860435648643e-152, 6.3257905089784152346e-168, 3.5607241064750984115e-184, -1.4832196127821708615e-201, + 2.1571619860435648643e-152, 6.3257905089784152346e-168, 3.5607241064750984115e-184, -1.4832196127821708615e-201, + 2.4782675885631257398e-153, -3.3573283875161501977e-170, 3.0568054078295488291e-186, 1.4980560800565462618e-202, + 2.4782675885631257398e-153, -3.3573283875161501977e-170, 3.0568054078295488291e-186, 1.4980560800565462618e-202, + 2.4782675885631257398e-153, -3.3573283875161501977e-170, 3.0568054078295488291e-186, 1.4980560800565462618e-202, + 9.1598554579059548847e-155, -4.5159745404911819927e-172, -4.5870810097328572602e-188, -3.2905064432040069127e-204, + 9.1598554579059548847e-155, -4.5159745404911819927e-172, -4.5870810097328572602e-188, -3.2905064432040069127e-204, + 9.1598554579059548847e-155, -4.5159745404911819927e-172, -4.5870810097328572602e-188, -3.2905064432040069127e-204, + 9.1598554579059548847e-155, -4.5159745404911819927e-172, -4.5870810097328572602e-188, -3.2905064432040069127e-204, + 9.1598554579059548847e-155, -4.5159745404911819927e-172, -4.5870810097328572602e-188, -3.2905064432040069127e-204, + 1.7015147267057481414e-155, -4.5159745404911819927e-172, -4.5870810097328572602e-188, -3.2905064432040069127e-204, + 1.7015147267057481414e-155, -4.5159745404911819927e-172, -4.5870810097328572602e-188, -3.2905064432040069127e-204, + 1.7015147267057481414e-155, -4.5159745404911819927e-172, -4.5870810097328572602e-188, -3.2905064432040069127e-204, + 7.6922213530572229852e-156, -4.5159745404911819927e-172, -4.5870810097328572602e-188, -3.2905064432040069127e-204, + 3.0307583960570927356e-156, 5.8345524661064358191e-172, 6.9043123899963188689e-188, -3.2905064432040069127e-204, + 7.0002691755702864582e-157, 6.5928896280762691321e-173, 1.1586156901317304854e-188, -1.0100405885278530137e-205, + 7.0002691755702864582e-157, 6.5928896280762691321e-173, 1.1586156901317304854e-188, -1.0100405885278530137e-205, + 1.1734404793201255869e-157, 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.3321093418096261919e-207, + 1.1734404793201255869e-157, 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.3321093418096261919e-207, + 1.1734404793201255869e-157, 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.3321093418096261919e-207, + 4.4508689228885539715e-158, 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.3321093418096261919e-207, + 8.0910098773220302259e-159, 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.3321093418096261919e-207, + 8.0910098773220302259e-159, 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.3321093418096261919e-207, + 8.0910098773220302259e-159, 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.3321093418096261919e-207, + 3.5387999583765925506e-159, 2.2730883653953564668e-175, 2.7431118386590483722e-191, -1.3321093418096261919e-207, + 1.2626949989038732076e-159, 2.2730883653953564668e-175, 2.7431118386590483722e-191, -1.3321093418096261919e-207, + 1.2464251916751375716e-160, 6.1977249484000140293e-177, 1.1294061984896456875e-192, 2.2526486929936882202e-208, + 1.2464251916751375716e-160, 6.1977249484000140293e-177, 1.1294061984896456875e-192, 2.2526486929936882202e-208, + 1.2464251916751375716e-160, 6.1977249484000140293e-177, 1.1294061984896456875e-192, 2.2526486929936882202e-208, + 1.2464251916751375716e-160, 6.1977249484000140293e-177, 1.1294061984896456875e-192, 2.2526486929936882202e-208, + 5.3514239183991277695e-161, 6.1977249484000140293e-177, 1.1294061984896456875e-192, 2.2526486929936882202e-208, + 1.7950099192230045857e-161, -1.6991004655691153326e-177, -1.8567941091539589297e-193, -1.8074851186411640793e-209, + 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, + 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, + 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, + 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, + 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, + 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, + 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, + 2.9106774506606941983e-164, 5.1948630316441287936e-180, 9.6685396110091013832e-196, 1.7562785002189357559e-211, + 2.9106774506606941983e-164, 5.1948630316441287936e-180, 9.6685396110091013832e-196, 1.7562785002189357559e-211, + 2.9106774506606941983e-164, 5.1948630316441287936e-180, 9.6685396110091013832e-196, 1.7562785002189357559e-211, + 1.1741471776254777999e-164, 1.3389912474795150614e-180, 1.106784341445028435e-196, 3.3045982549756583552e-212, + 3.0588204110786950436e-165, 3.7502330143836152136e-181, 3.6564932749519464998e-198, 3.7097125405852507464e-214, + 3.0588204110786950436e-165, 3.7502330143836152136e-181, 3.6564932749519464998e-198, 3.7097125405852507464e-214, + 8.8815756978467430465e-166, 1.3403131492807310959e-181, 3.6564932749519464998e-198, 3.7097125405852507464e-214, + 8.8815756978467430465e-166, 1.3403131492807310959e-181, 3.6564932749519464998e-198, 3.7097125405852507464e-214, + 3.4549185946116918017e-166, 1.3535321672928907047e-182, 3.1205762277848031878e-199, -3.3569248349832580936e-217, + 7.4159004299416557678e-167, 1.3535321672928907047e-182, 3.1205762277848031878e-199, -3.3569248349832580936e-217, + 7.4159004299416557678e-167, 1.3535321672928907047e-182, 3.1205762277848031878e-199, -3.3569248349832580936e-217, + 6.3257905089784152346e-168, 3.5607241064750984115e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, + 6.3257905089784152346e-168, 3.5607241064750984115e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, + 6.3257905089784152346e-168, 3.5607241064750984115e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, + 6.3257905089784152346e-168, 3.5607241064750984115e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, + 2.0862146470760309789e-168, -1.146150630053972131e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, + 2.0862146470760309789e-168, -1.146150630053972131e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, + 1.026320681600434562e-168, 1.2072867382105631402e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, + 4.9637369886263658882e-169, 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, + 2.3140020749373754342e-169, 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, + 9.8913461809288020723e-170, 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, + 3.2670088967063259373e-170, 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, + 3.2670088967063259373e-170, 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, + 1.6109245756507072713e-170, -6.2044048008378732802e-187, -5.4322544592823556944e-203, 4.2491789852161138683e-219, + 7.8288241512289757055e-171, 1.2181824638728806485e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, + 3.6886133485899290404e-171, 2.9887099189454666024e-187, 4.774153170641553462e-203, 4.2491789852161138683e-219, + 1.6185079472704052482e-171, 2.9887099189454666024e-187, 4.774153170641553462e-203, 4.2491789852161138683e-219, + 5.8345524661064358191e-172, 6.9043123899963188689e-188, -3.2905064432040069127e-204, -9.1795828160190082842e-224, + 6.5928896280762691321e-173, 1.1586156901317304854e-188, -1.0100405885278530137e-205, -9.1795828160190082842e-224, + 6.5928896280762691321e-173, 1.1586156901317304854e-188, -1.0100405885278530137e-205, -9.1795828160190082842e-224, + 6.5928896280762691321e-173, 1.1586156901317304854e-188, -1.0100405885278530137e-205, -9.1795828160190082842e-224, + 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.332109341809626019e-207, -9.1795828160190082842e-224, + 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.332109341809626019e-207, -9.1795828160190082842e-224, + 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.332109341809626019e-207, -9.1795828160190082842e-224, + 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.332109341809626019e-207, -9.1795828160190082842e-224, + 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.332109341809626019e-207, -9.1795828160190082842e-224, + 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.332109341809626019e-207, -9.1795828160190082842e-224, + 2.2730883653953564668e-175, 2.7431118386590483722e-191, -1.332109341809626019e-207, -9.1795828160190082842e-224, + 2.2730883653953564668e-175, 2.7431118386590483722e-191, -1.332109341809626019e-207, -9.1795828160190082842e-224, + 2.2730883653953564668e-175, 2.7431118386590483722e-191, -1.332109341809626019e-207, -9.1795828160190082842e-224, + 1.0095962991602958391e-175, -6.2404128071707654958e-193, 3.0593092910744445285e-209, 5.4622616159087170031e-225, + 3.7785026604276538491e-176, -6.2404128071707654958e-193, 3.0593092910744445285e-209, 5.4622616159087170031e-225, + 6.1977249484000140293e-177, 1.1294061984896456875e-192, 2.2526486929936882202e-208, -5.3441928036578162463e-225, + 6.1977249484000140293e-177, 1.1294061984896456875e-192, 2.2526486929936882202e-208, -5.3441928036578162463e-225, + 6.1977249484000140293e-177, 1.1294061984896456875e-192, 2.2526486929936882202e-208, -5.3441928036578162463e-225, + 2.2493122414154495675e-177, 2.5268245888628466632e-193, 3.0593092910744445285e-209, 5.4622616159087170031e-225, + 2.7510588792316711745e-178, 3.3501523985444386676e-194, 6.2591208621664049475e-210, 5.9034406125450500218e-227, + 2.7510588792316711745e-178, 3.3501523985444386676e-194, 6.2591208621664049475e-210, 5.9034406125450500218e-227, + 2.7510588792316711745e-178, 3.3501523985444386676e-194, 6.2591208621664049475e-210, 5.9034406125450500218e-227, + 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, 9.9192633285681635836e-229, + 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, 9.9192633285681635836e-229, + 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, 9.9192633285681635836e-229, + 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, 9.9192633285681635836e-229, + 1.2906606599973359683e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, 9.9192633285681635836e-229, + 5.1948630316441287936e-180, 9.6685396110091013832e-196, 1.7562785002189355449e-211, 1.6821693549018732055e-227, + 1.3389912474795150614e-180, 1.106784341445028435e-196, 3.3045982549756578275e-212, 6.2685154049107876715e-228, + 1.3389912474795150614e-180, 1.106784341445028435e-196, 3.3045982549756578275e-212, 6.2685154049107876715e-228, + 3.7502330143836152136e-181, 3.6564932749519464998e-198, 3.7097125405852507464e-214, 2.5658818466966882188e-231, + 3.7502330143836152136e-181, 3.6564932749519464998e-198, 3.7097125405852507464e-214, 2.5658818466966882188e-231, + 1.3403131492807310959e-181, 3.6564932749519464998e-198, 3.7097125405852507464e-214, 2.5658818466966882188e-231, + 1.3535321672928907047e-182, 3.1205762277848031878e-199, -3.3569248349832580936e-217, -1.0577661142165146927e-233, + 1.3535321672928907047e-182, 3.1205762277848031878e-199, -3.3569248349832580936e-217, -1.0577661142165146927e-233, + 1.3535321672928907047e-182, 3.1205762277848031878e-199, -3.3569248349832580936e-217, -1.0577661142165146927e-233, + 1.3535321672928907047e-182, 3.1205762277848031878e-199, -3.3569248349832580936e-217, -1.0577661142165146927e-233, + 6.0043220944823941786e-183, 3.1205762277848031878e-199, -3.3569248349832580936e-217, -1.0577661142165146927e-233, + 2.2388223052591377446e-183, 3.1205762277848031878e-199, -3.3569248349832580936e-217, -1.0577661142165146927e-233, + 3.5607241064750984115e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 3.5607241064750984115e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 3.5607241064750984115e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 1.2072867382105631402e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 1.2181824638728806485e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 2.9887099189454666024e-187, 4.774153170641553462e-203, 4.2491789852161132393e-219, 7.4467067939231424594e-235, + 2.9887099189454666024e-187, 4.774153170641553462e-203, 4.2491789852161132393e-219, 7.4467067939231424594e-235, + 6.9043123899963188689e-188, -3.2905064432040069127e-204, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 6.9043123899963188689e-188, -3.2905064432040069127e-204, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 1.1586156901317304854e-188, -1.0100405885278530137e-205, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 1.1586156901317304854e-188, -1.0100405885278530137e-205, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 1.1586156901317304854e-188, -1.0100405885278530137e-205, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 4.4040360264865697732e-189, -1.0100405885278530137e-205, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 8.129755890712020335e-190, 9.8339840169166049336e-206, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 8.129755890712020335e-190, 9.8339840169166049336e-206, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 8.129755890712020335e-190, 9.8339840169166049336e-206, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 3.6409303439428119063e-190, -1.332109341809626019e-207, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 1.3965175705582071936e-190, -1.332109341809626019e-207, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 2.7431118386590483722e-191, -1.332109341809626019e-207, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 2.7431118386590483722e-191, -1.332109341809626019e-207, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 2.7431118386590483722e-191, -1.332109341809626019e-207, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 1.3403538552936701153e-191, 1.7826390804083638359e-207, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 6.389748636109812983e-192, 2.2526486929936882202e-208, -5.3441928036578156465e-225, -7.741539335184153052e-241, + 2.8828536776963681193e-192, 2.2526486929936882202e-208, -5.3441928036578156465e-225, -7.741539335184153052e-241, + 1.1294061984896456875e-192, 2.2526486929936882202e-208, -5.3441928036578156465e-225, -7.741539335184153052e-241, + 2.5268245888628466632e-193, 3.0593092910744445285e-209, 5.4622616159087170031e-225, 4.2560351759808952526e-241, + 2.5268245888628466632e-193, 3.0593092910744445285e-209, 5.4622616159087170031e-225, 4.2560351759808952526e-241, + 3.3501523985444386676e-194, 6.2591208621664049475e-210, 5.9034406125450490845e-227, 1.3186893776791012681e-242, + 3.3501523985444386676e-194, 6.2591208621664049475e-210, 5.9034406125450490845e-227, 1.3186893776791012681e-242, + 3.3501523985444386676e-194, 6.2591208621664049475e-210, 5.9034406125450490845e-227, 1.3186893776791012681e-242, + 6.1039071228393547627e-195, 1.7562785002189355449e-211, 1.6821693549018732055e-227, -8.7276385348052817035e-244, + 6.1039071228393547627e-195, 1.7562785002189355449e-211, 1.6821693549018732055e-227, -8.7276385348052817035e-244, + 6.1039071228393547627e-195, 1.7562785002189355449e-211, 1.6821693549018732055e-227, -8.7276385348052817035e-244, + 2.6792050150137250131e-195, 1.7562785002189355449e-211, 1.6821693549018732055e-227, -8.7276385348052817035e-244, + 9.6685396110091013832e-196, 1.7562785002189355449e-211, 1.6821693549018732055e-227, -8.7276385348052817035e-244, + 2.0416567491425607157e-177, 6.0959078275963141821e-193, 1.156336993964950812e-208, 2.7126166236326293347e-224, + 2.0416567491425607157e-177, 6.0959078275963141821e-193, 1.156336993964950812e-208, 2.7126166236326293347e-224, + 2.0416567491425607157e-177, 6.0959078275963141821e-193, 1.156336993964950812e-208, 2.7126166236326293347e-224, + 6.7450395650278649168e-179, 6.8432117823206978686e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, + 6.7450395650278649168e-179, 6.8432117823206978686e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, + 6.7450395650278649168e-179, 6.8432117823206978686e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, + 6.7450395650278649168e-179, 6.8432117823206978686e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, + 6.7450395650278649168e-179, 6.8432117823206978686e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, + 5.756447103644822603e-180, -6.1924333305615830735e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 5.756447103644822603e-180, -6.1924333305615830735e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 5.756447103644822603e-180, -6.1924333305615830735e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 5.756447103644822603e-180, -6.1924333305615830735e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 1.9005753194802080146e-180, -6.1924333305615830735e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 1.9005753194802080146e-180, -6.1924333305615830735e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 9.3660737343905436753e-181, -6.1924333305615830735e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 4.5462340041847754398e-181, -6.1924333305615830735e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 2.1363141390818913221e-181, -6.1924333305615830735e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 9.3135420653044926323e-182, -6.1924333305615830735e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 3.2887424025472810002e-182, 7.185309278132283136e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 2.7634257116867652192e-183, 4.9643797378534984559e-199, -9.4699347169310243473e-216, -9.2331809177749095611e-233, + 2.7634257116867652192e-183, 4.9643797378534984559e-199, -9.4699347169310243473e-216, -9.2331809177749095611e-233, + 2.7634257116867652192e-183, 4.9643797378534984559e-199, -9.4699347169310243473e-216, -9.2331809177749095611e-233, + 2.7634257116867652192e-183, 4.9643797378534984559e-199, -9.4699347169310243473e-216, -9.2331809177749095611e-233, + 8.806758170751374203e-184, 7.8383517263666503337e-200, 1.3736749441945438342e-215, -9.2331809177749095611e-233, + 8.806758170751374203e-184, 7.8383517263666503337e-200, 1.3736749441945438342e-215, -9.2331809177749095611e-233, + 4.0998834342223036605e-184, 7.8383517263666503337e-200, 1.3736749441945438342e-215, -9.2331809177749095611e-233, + 1.7464460659577689118e-184, 2.612671019845610006e-200, 2.1334073625072069974e-216, -9.2331809177749095611e-233, + 5.697273818255015375e-185, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 5.697273818255015375e-185, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 2.755477107924346286e-185, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 1.2845787527590117414e-185, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 5.4912957517634446918e-186, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 1.8140498638501083305e-186, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 1.8140498638501083305e-186, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 8.9473839187177424013e-187, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 4.3508265588260719497e-187, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 2.0525478788802367239e-187, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 9.0340853890731911095e-188, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 3.288388689208603045e-188, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 4.1554033927630885323e-189, -9.8582956929636044137e-206, -1.4280619485269765742e-221, 1.2171222696290252021e-237, + 4.1554033927630885323e-189, -9.8582956929636044137e-206, -1.4280619485269765742e-221, 1.2171222696290252021e-237, + 4.1554033927630885323e-189, -9.8582956929636044137e-206, -1.4280619485269765742e-221, 1.2171222696290252021e-237, + 5.643429553477207926e-190, 1.0076094209231528444e-205, 7.8509991660024955813e-222, 1.2171222696290252021e-237, + 5.643429553477207926e-190, 1.0076094209231528444e-205, 7.8509991660024955813e-222, 1.2171222696290252021e-237, + 5.643429553477207926e-190, 1.0076094209231528444e-205, 7.8509991660024955813e-222, 1.2171222696290252021e-237, + 1.1546040067079994973e-190, 1.0889925813396166947e-207, 2.4325525462765697993e-223, -1.1429360314275701698e-239, + 1.1546040067079994973e-190, 1.0889925813396166947e-207, 2.4325525462765697993e-223, -1.1429360314275701698e-239, + 3.2397620015697148712e-192, 3.1030547578511949035e-208, -1.609965144193984205e-224, -1.8313007053436627876e-240, + 3.2397620015697148712e-192, 3.1030547578511949035e-208, -1.609965144193984205e-224, -1.8313007053436627876e-240, + 3.2397620015697148712e-192, 3.1030547578511949035e-208, -1.609965144193984205e-224, -1.8313007053436627876e-240, + 3.2397620015697148712e-192, 3.1030547578511949035e-208, -1.609965144193984205e-224, -1.8313007053436627876e-240, + 3.2397620015697148712e-192, 3.1030547578511949035e-208, -1.609965144193984205e-224, -1.8313007053436627876e-240, + 3.2397620015697148712e-192, 3.1030547578511949035e-208, -1.609965144193984205e-224, -1.8313007053436627876e-240, + 1.4863145223629928288e-192, -7.9038076992129241506e-209, -1.609965144193984205e-224, -1.8313007053436627876e-240, + 6.0959078275963141821e-193, 1.156336993964950812e-208, 2.7126166236326293347e-224, -1.8313007053436627876e-240, + 1.712289129579509076e-193, 1.8297811202182925249e-209, 1.1003018740995688645e-226, 5.827891678485165325e-243, + 1.712289129579509076e-193, 1.8297811202182925249e-209, 1.1003018740995688645e-226, 5.827891678485165325e-243, + 6.1638445507530779946e-194, -6.0361608463951204924e-210, 1.1003018740995688645e-226, 5.827891678485165325e-243, + 6.8432117823206978686e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.029900079464340522e-245, + 6.8432117823206978686e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.029900079464340522e-245, + 6.8432117823206978686e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.029900079464340522e-245, + 6.8432117823206978686e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.029900079464340522e-245, + 3.418509674495068119e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.029900079464340522e-245, + 1.7061586205822532442e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.029900079464340522e-245, + 8.499830936258458068e-196, 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.029900079464340522e-245, + 4.218953301476420881e-196, 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.029900079464340522e-245, + 2.0785144840854027628e-196, -1.9512340798794268979e-214, -3.6162764918921692779e-230, -2.8387319855193022476e-246, + 1.008295075389893466e-196, -1.9512340798794268979e-214, -3.6162764918921692779e-230, -2.8387319855193022476e-246, + 4.7318537104213881764e-197, -1.9512340798794268979e-214, -3.6162764918921692779e-230, -2.8387319855193022476e-246, + 2.0563051886826149345e-197, -1.9512340798794268979e-214, -3.6162764918921692779e-230, -2.8387319855193022476e-246, + 7.185309278132283136e-198, -1.9512340798794268979e-214, -3.6162764918921692779e-230, -2.8387319855193022476e-246, + 4.9643797378534984559e-199, -9.4699347169310243473e-216, -9.2331809177749077733e-233, -1.4042876247421728101e-248, + 4.9643797378534984559e-199, -9.4699347169310243473e-216, -9.2331809177749077733e-233, -1.4042876247421728101e-248, + 4.9643797378534984559e-199, -9.4699347169310243473e-216, -9.2331809177749077733e-233, -1.4042876247421728101e-248, + 4.9643797378534984559e-199, -9.4699347169310243473e-216, -9.2331809177749077733e-233, -1.4042876247421728101e-248, + 7.8383517263666503337e-200, 1.3736749441945438342e-215, -9.2331809177749077733e-233, -1.4042876247421728101e-248, + 7.8383517263666503337e-200, 1.3736749441945438342e-215, -9.2331809177749077733e-233, -1.4042876247421728101e-248, + 7.8383517263666503337e-200, 1.3736749441945438342e-215, -9.2331809177749077733e-233, -1.4042876247421728101e-248, + 2.612671019845610006e-200, 2.1334073625072069974e-216, -9.2331809177749077733e-233, -1.4042876247421728101e-248, + 2.612671019845610006e-200, 2.1334073625072069974e-216, -9.2331809177749077733e-233, -1.4042876247421728101e-248, + 1.306250843215349634e-200, 2.1334073625072069974e-216, -9.2331809177749077733e-233, -1.4042876247421728101e-248, + 6.5304075490021959302e-201, 6.8298960257742791824e-217, 6.8696910062179237095e-233, 3.8349029251851101018e-249, + 3.2643571074265457254e-201, -4.2219277387461470355e-218, -1.753154605289404553e-234, -7.5861268822635538093e-251, + 1.6313318866387202604e-201, -4.2219277387461470355e-218, -1.753154605289404553e-234, -7.5861268822635538093e-251, + 8.1481927624480752786e-202, -4.2219277387461470355e-218, -1.753154605289404553e-234, -7.5861268822635538093e-251, + 4.0656297104785107096e-202, 4.8431832608149701961e-218, 8.3111403472061145651e-234, 1.6001805286092554504e-249, + 2.0243481844937293316e-202, 3.1062776103441183191e-219, 7.6291913283447536617e-235, 2.0347903074934629333e-250, + 1.0037074215013384159e-202, 3.1062776103441183191e-219, 7.6291913283447536617e-235, 2.0347903074934629333e-250, + 4.9338704000514295811e-203, 3.1062776103441183191e-219, 7.6291913283447536617e-235, 2.0347903074934629333e-250, + 2.3822684925704522921e-203, 3.1062776103441183191e-219, 7.6291913283447536617e-235, 2.0347903074934629333e-250, + 1.1064675388299639308e-203, 2.7343042298126957741e-220, 5.5273393987134252385e-236, 1.1432574793608782288e-251, + 4.6856706195971960852e-204, 2.7343042298126957741e-220, 5.5273393987134252385e-236, 1.1432574793608782288e-251, + 1.4961682352459748279e-204, -8.0675475439086544798e-221, -3.6970842501441777651e-237, -5.7032870362481275794e-253, + 1.4961682352459748279e-204, -8.0675475439086544798e-221, -3.6970842501441777651e-237, -5.7032870362481275794e-253, + 6.9879263915816924805e-205, 9.6377473771091526132e-221, 1.5959741828948633012e-236, 2.7031904319843495713e-252, + 3.0010484111426663515e-205, 7.8509991660024955813e-222, 1.2171222696290252021e-237, -2.4742181023285720738e-254, + 1.0076094209231528444e-205, 7.8509991660024955813e-222, 1.2171222696290252021e-237, -2.4742181023285720738e-254, + 1.0889925813396166947e-207, 2.4325525462765697993e-223, -1.1429360314275701698e-239, 8.3218722366085688343e-256, + 1.0889925813396166947e-207, 2.4325525462765697993e-223, -1.1429360314275701698e-239, 8.3218722366085688343e-256, + 1.0889925813396166947e-207, 2.4325525462765697993e-223, -1.1429360314275701698e-239, 8.3218722366085688343e-256, + 1.0889925813396166947e-207, 2.4325525462765697993e-223, -1.1429360314275701698e-239, 8.3218722366085688343e-256, + 1.0889925813396166947e-207, 2.4325525462765697993e-223, -1.1429360314275701698e-239, 8.3218722366085688343e-256, + 1.0889925813396166947e-207, 2.4325525462765697993e-223, -1.1429360314275701698e-239, 8.3218722366085688343e-256, + 1.0889925813396166947e-207, 2.4325525462765697993e-223, -1.1429360314275701698e-239, 8.3218722366085688343e-256, + 3.1030547578511949035e-208, -1.609965144193984205e-224, -1.8313007053436625212e-240, -2.3341145329525059632e-256, + 3.1030547578511949035e-208, -1.609965144193984205e-224, -1.8313007053436625212e-240, -2.3341145329525059632e-256, + 1.156336993964950812e-208, 2.7126166236326293347e-224, -1.8313007053436625212e-240, -2.3341145329525059632e-256, + 1.8297811202182925249e-209, 1.1003018740995688645e-226, 5.827891678485165325e-243, -3.1174271110208206547e-259, + 1.8297811202182925249e-209, 1.1003018740995688645e-226, 5.827891678485165325e-243, -3.1174271110208206547e-259, + 1.8297811202182925249e-209, 1.1003018740995688645e-226, 5.827891678485165325e-243, -3.1174271110208206547e-259, + 6.1308251778939023781e-210, 1.1003018740995688645e-226, 5.827891678485165325e-243, -3.1174271110208206547e-259, + 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 2.3568521170701555846e-212, -7.7818310317651142243e-229, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 1.1686698881356804311e-212, 1.8601114328504743806e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 5.7457877366844311816e-213, 5.409641648369814791e-229, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 2.7753321643482446169e-213, -1.1860946916976500828e-229, 6.3146909508553973881e-246, 1.2573885592501532045e-261, + 1.290104378180150675e-213, 2.1117734783360818049e-229, 4.2928382696354204061e-245, -2.8075477999879273582e-261, + 5.4749048509610403382e-214, 4.6283939331921604413e-230, 6.3146909508553973881e-246, 1.2573885592501532045e-261, + 1.7618353855408067201e-214, 5.060587206499956961e-231, 5.9380161562121075096e-247, -1.2904053011746964278e-263, + 1.7618353855408067201e-214, 5.060587206499956961e-231, 5.9380161562121075096e-247, -1.2904053011746964278e-263, + 8.3356801918574821257e-215, 5.060587206499956961e-231, 5.9380161562121075096e-247, -1.2904053011746964278e-263, + 3.6943433600821895879e-215, 5.060587206499956961e-231, 5.9380161562121075096e-247, -1.2904053011746964278e-263, + 1.3736749441945438342e-215, -9.2331809177749077733e-233, -1.4042876247421726117e-248, -9.9505977179164858712e-265, + 2.1334073625072069974e-216, -9.2331809177749077733e-233, -1.4042876247421726117e-248, -9.9505977179164858712e-265, + 2.1334073625072069974e-216, -9.2331809177749077733e-233, -1.4042876247421726117e-248, -9.9505977179164858712e-265, + 2.1334073625072069974e-216, -9.2331809177749077733e-233, -1.4042876247421726117e-248, -9.9505977179164858712e-265, + 6.8298960257742791824e-217, 6.8696910062179237095e-233, 3.8349029251851101018e-249, -2.6436684620390282645e-267, + 6.8298960257742791824e-217, 6.8696910062179237095e-233, 3.8349029251851101018e-249, -2.6436684620390282645e-267, + 3.2038516259498326923e-217, -1.1817449557784924788e-233, -6.3454186796659920093e-250, -2.6436684620390282645e-267, + 1.3908294260376086421e-217, 2.8439730252197153919e-233, 3.8349029251851101018e-249, -2.6436684620390282645e-267, + 4.8431832608149701961e-218, 8.3111403472061145651e-234, 1.6001805286092554504e-249, -2.6436684620390282645e-267, + 3.1062776103441183191e-219, 7.6291913283447536617e-235, 2.0347903074934629333e-250, -2.6436684620390282645e-267, + 3.1062776103441183191e-219, 7.6291913283447536617e-235, 2.0347903074934629333e-250, -2.6436684620390282645e-267, + 3.1062776103441183191e-219, 7.6291913283447536617e-235, 2.0347903074934629333e-250, -2.6436684620390282645e-267, + 3.1062776103441183191e-219, 7.6291913283447536617e-235, 2.0347903074934629333e-250, -2.6436684620390282645e-267, + 2.7343042298126957741e-220, 5.5273393987134252385e-236, 1.1432574793608780349e-251, 1.2329569415922591084e-267, + 2.7343042298126957741e-220, 5.5273393987134252385e-236, 1.1432574793608780349e-251, 1.2329569415922591084e-267, + 2.7343042298126957741e-220, 5.5273393987134252385e-236, 1.1432574793608780349e-251, 1.2329569415922591084e-267, + 2.7343042298126957741e-220, 5.5273393987134252385e-236, 1.1432574793608780349e-251, 1.2329569415922591084e-267, + 9.6377473771091526132e-221, 1.5959741828948633012e-236, 2.7031904319843490867e-252, 2.638005906844372114e-268, + 7.8509991660024955813e-222, 1.2171222696290252021e-237, -2.4742181023285720738e-254, -1.2030990169203137715e-270, + 7.8509991660024955813e-222, 1.2171222696290252021e-237, -2.4742181023285720738e-254, -1.2030990169203137715e-270, + 7.8509991660024955813e-222, 1.2171222696290252021e-237, -2.4742181023285720738e-254, -1.2030990169203137715e-270, + 7.8509991660024955813e-222, 1.2171222696290252021e-237, -2.4742181023285720738e-254, -1.2030990169203137715e-270, + 2.318094503184431479e-222, -1.1429360314275701698e-239, 8.3218722366085688343e-256, -2.0046830753539155726e-272, + 2.318094503184431479e-222, -1.1429360314275701698e-239, 8.3218722366085688343e-256, -2.0046830753539155726e-272, + 9.3486833747991514629e-223, -1.1429360314275701698e-239, 8.3218722366085688343e-256, -2.0046830753539155726e-272, + 2.4325525462765697993e-223, -1.1429360314275701698e-239, 8.3218722366085688343e-256, -2.0046830753539155726e-272, + 2.4325525462765697993e-223, -1.1429360314275701698e-239, 8.3218722366085688343e-256, -2.0046830753539155726e-272, + 7.0351983914592419146e-224, 7.766758903588374524e-240, 8.3218722366085688343e-256, -2.0046830753539155726e-272, + 7.0351983914592419146e-224, 7.766758903588374524e-240, 8.3218722366085688343e-256, -2.0046830753539155726e-272, + 2.7126166236326293347e-224, -1.8313007053436625212e-240, -2.3341145329525056675e-256, -2.0046830753539155726e-272, + 5.5132573971932232487e-225, 5.6821419688934674008e-241, 3.2988215943776273615e-257, 2.1353977370878701046e-273, + 5.5132573971932232487e-225, 5.6821419688934674008e-241, 3.2988215943776273615e-257, 2.1353977370878701046e-273, + 1.1003018740995688645e-226, 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, + 1.1003018740995688645e-226, 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, + 1.1003018740995688645e-226, 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, + 1.1003018740995688645e-226, 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, + 1.1003018740995688645e-226, 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, + 1.1003018740995688645e-226, 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, + 2.560476225709334075e-227, 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, + 2.560476225709334075e-227, 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, + 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, -1.472095602234059958e-277, + 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, -1.472095602234059958e-277, + 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, -1.472095602234059958e-277, + 1.8601114328504743806e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, -1.472095602234059958e-277, + 5.409641648369814791e-229, -3.0299000794643401155e-245, -2.8075477999879273582e-261, -1.472095602234059958e-277, + 5.409641648369814791e-229, -3.0299000794643401155e-245, -2.8075477999879273582e-261, -1.472095602234059958e-277, + 2.1117734783360818049e-229, 4.2928382696354204061e-245, -2.8075477999879273582e-261, -1.472095602234059958e-277, + 4.6283939331921604413e-230, 6.3146909508553973881e-246, 1.2573885592501529789e-261, 3.0408903374280139822e-277, + 4.6283939331921604413e-230, 6.3146909508553973881e-246, 1.2573885592501529789e-261, 3.0408903374280139822e-277, + 5.060587206499956961e-231, 5.9380161562121075096e-247, -1.2904053011746964278e-263, 8.7279092175580820317e-280, + 5.060587206499956961e-231, 5.9380161562121075096e-247, -1.2904053011746964278e-263, 8.7279092175580820317e-280, + 5.060587206499956961e-231, 5.9380161562121075096e-247, -1.2904053011746964278e-263, 8.7279092175580820317e-280, + 5.060587206499956961e-231, 5.9380161562121075096e-247, -1.2904053011746964278e-263, 8.7279092175580820317e-280, + 2.4841276986611042098e-231, 2.1712682097791944335e-248, 2.9746046415267896827e-264, -8.6516445844406224413e-282, + 1.1958979447416775482e-231, 2.1712682097791944335e-248, 2.9746046415267896827e-264, -8.6516445844406224413e-282, + 5.5178306778196421733e-232, 2.1712682097791944335e-248, 2.9746046415267896827e-264, -8.6516445844406224413e-282, + 2.2972562930210755192e-232, 2.1712682097791944335e-248, 2.9746046415267896827e-264, -8.6516445844406224413e-282, + 6.8696910062179237095e-233, 3.8349029251851101018e-249, -2.6436684620390282645e-267, -4.3807022524130141006e-284, + 6.8696910062179237095e-233, 3.8349029251851101018e-249, -2.6436684620390282645e-267, -4.3807022524130141006e-284, + 2.8439730252197153919e-233, 3.8349029251851101018e-249, -2.6436684620390282645e-267, -4.3807022524130141006e-284, + 8.3111403472061145651e-234, 1.6001805286092554504e-249, -2.6436684620390282645e-267, -4.3807022524130141006e-284, + 8.3111403472061145651e-234, 1.6001805286092554504e-249, -2.6436684620390282645e-267, -4.3807022524130141006e-284, + 3.2789928709583552854e-234, 4.8281933032132812475e-250, -2.6436684620390282645e-267, -4.3807022524130141006e-284, + 7.6291913283447536617e-235, 2.0347903074934629333e-250, -2.6436684620390282645e-267, -4.3807022524130141006e-284, + 7.6291913283447536617e-235, 2.0347903074934629333e-250, -2.6436684620390282645e-267, -4.3807022524130141006e-284, + 1.3390069830350552605e-235, -6.026193929640082176e-252, -7.0535576022338457803e-268, -4.3807022524130141006e-284, + 1.3390069830350552605e-235, -6.026193929640082176e-252, -7.0535576022338457803e-268, -4.3807022524130141006e-284, + 1.3390069830350552605e-235, -6.026193929640082176e-252, -7.0535576022338457803e-268, -4.3807022524130141006e-284, + 5.5273393987134252385e-236, 1.1432574793608780349e-251, 1.2329569415922591084e-267, -4.3807022524130141006e-284, + 1.5959741828948633012e-236, 2.7031904319843490867e-252, 2.638005906844371576e-268, 6.3790946999826013345e-284, + 1.5959741828948633012e-236, 2.7031904319843490867e-252, 2.638005906844371576e-268, 6.3790946999826013345e-284, + 6.1313287894022281692e-237, 5.2084434157824127104e-253, 2.1511502957481757317e-269, 3.2670891426006739096e-285, + 1.2171222696290252021e-237, -2.4742181023285720738e-254, -1.2030990169203137715e-270, -9.5347405022956042207e-287, + 1.2171222696290252021e-237, -2.4742181023285720738e-254, -1.2030990169203137715e-270, -9.5347405022956042207e-287, + 1.2171222696290252021e-237, -2.4742181023285720738e-254, -1.2030990169203137715e-270, -9.5347405022956042207e-287, + 6.0284645465737476297e-238, -2.4742181023285720738e-254, -1.2030990169203137715e-270, -9.5347405022956042207e-287, + 2.9570854717154947523e-238, 4.3456134301905148502e-254, 6.3684349745470443788e-270, -9.5347405022956042207e-287, + 1.4213959342863689955e-238, 9.3569766393097138822e-255, 2.5826679788133653036e-270, -9.5347405022956042207e-287, + 6.5355116557180594664e-239, 9.3569766393097138822e-255, 2.5826679788133653036e-270, -9.5347405022956042207e-287, + 2.6962878121452450746e-239, 8.3218722366085688343e-256, -2.0046830753539152442e-272, -3.4057806738724185961e-288, + 7.766758903588374524e-240, 8.3218722366085688343e-256, -2.0046830753539152442e-272, -3.4057806738724185961e-288, + 7.766758903588374524e-240, 8.3218722366085688343e-256, -2.0046830753539152442e-272, -3.4057806738724185961e-288, + 2.9677290991223565342e-240, -2.3341145329525056675e-256, -2.0046830753539152442e-272, -3.4057806738724185961e-288, + 5.6821419688934674008e-241, 3.2988215943776273615e-257, 2.1353977370878701046e-273, -1.2215123283371736879e-289, + 5.6821419688934674008e-241, 3.2988215943776273615e-257, 2.1353977370878701046e-273, -1.2215123283371736879e-289, + 5.6821419688934674008e-241, 3.2988215943776273615e-257, 2.1353977370878701046e-273, -1.2215123283371736879e-289, + 2.6827483411022054912e-241, 3.2988215943776273615e-257, 2.1353977370878701046e-273, -1.2215123283371736879e-289, + 1.1830515272065748694e-241, -3.117427111020820077e-259, -5.9718623963762788119e-275, 6.1155422068568954053e-291, + 4.3320312025875939195e-242, -3.117427111020820077e-259, -5.9718623963762788119e-275, 6.1155422068568954053e-291, + 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, 6.1155422068568954053e-291, + 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, 6.1155422068568954053e-291, + 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, 6.1155422068568954053e-291, + 1.1413391350613183311e-243, -5.1586784110844895013e-260, -1.9524039360882352712e-276, -2.9779654517181717279e-292, + 1.1413391350613183311e-243, -5.1586784110844895013e-260, -1.9524039360882352712e-276, -2.9779654517181717279e-292, + 1.1413391350613183311e-243, -5.1586784110844895013e-260, -1.9524039360882352712e-276, -2.9779654517181717279e-292, + 5.5552006713333735927e-244, 7.8491179384773690214e-260, -1.9524039360882352712e-276, -2.9779654517181717279e-292, + 2.6261053316934700345e-244, 1.345219763696439399e-260, 1.6579848156414234801e-276, 1.0303712682997740506e-292, + 1.1615576618735179302e-244, 1.345219763696439399e-260, 1.6579848156414234801e-276, 1.0303712682997740506e-292, + 4.2928382696354204061e-245, -2.8075477999879273582e-261, -1.472095602234059958e-277, 2.8287088295287585094e-294, + 6.3146909508553973881e-246, 1.2573885592501529789e-261, 3.0408903374280139822e-277, 2.8287088295287585094e-294, + 6.3146909508553973881e-246, 1.2573885592501529789e-261, 3.0408903374280139822e-277, 2.8287088295287585094e-294, + 6.3146909508553973881e-246, 1.2573885592501529789e-261, 3.0408903374280139822e-277, 2.8287088295287585094e-294, + 1.7379794826680480784e-246, 2.4115446944063306384e-262, 2.202741251392177696e-278, 2.8287088295287585094e-294, + 1.7379794826680480784e-246, 2.4115446944063306384e-262, 2.202741251392177696e-278, 2.8287088295287585094e-294, + 5.9380161562121075096e-247, -1.2904053011746964278e-263, 8.7279092175580810531e-280, 8.8634899828990930877e-296, + 2.1712682097791944335e-248, 2.9746046415267896827e-264, -8.6516445844406224413e-282, -5.0528699238150276549e-299, + 2.1712682097791944335e-248, 2.9746046415267896827e-264, -8.6516445844406224413e-282, -5.0528699238150276549e-299, + 2.1712682097791944335e-248, 2.9746046415267896827e-264, -8.6516445844406224413e-282, -5.0528699238150276549e-299, + 2.1712682097791944335e-248, 2.9746046415267896827e-264, -8.6516445844406224413e-282, -5.0528699238150276549e-299, + 2.1712682097791944335e-248, 2.9746046415267896827e-264, -8.6516445844406224413e-282, -5.0528699238150276549e-299, + 3.8349029251851101018e-249, -2.6436684620390282645e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 3.8349029251851101018e-249, -2.6436684620390282645e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 3.8349029251851101018e-249, -2.6436684620390282645e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 1.6001805286092554504e-249, -2.6436684620390282645e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 4.8281933032132812475e-250, -2.6436684620390282645e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 4.8281933032132812475e-250, -2.6436684620390282645e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 2.0347903074934629333e-250, -2.6436684620390282645e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 6.3808880963355377617e-251, -2.6436684620390282645e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 6.3808880963355377617e-251, -2.6436684620390282645e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 2.8891343516857640937e-251, 5.1095823452235464813e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 1.1432574793608780349e-251, 1.2329569415922591084e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 2.7031904319843490867e-252, 2.638005906844371576e-268, 6.3790946999826013345e-284, -2.7456019707854725967e-300, + 2.7031904319843490867e-252, 2.638005906844371576e-268, 6.3790946999826013345e-284, -2.7456019707854725967e-300, + 5.2084434157824127104e-253, 2.1511502957481757317e-269, 3.2670891426006735363e-285, 2.4084160842482777461e-301, + 5.2084434157824127104e-253, 2.1511502957481757317e-269, 3.2670891426006735363e-285, 2.4084160842482777461e-301, + 5.2084434157824127104e-253, 2.1511502957481757317e-269, 3.2670891426006735363e-285, 2.4084160842482777461e-301, + 2.4805108027747776379e-253, 2.1511502957481757317e-269, 3.2670891426006735363e-285, 2.4084160842482777461e-301, + 1.1165444962709601017e-253, 2.1511502957481757317e-269, 3.2670891426006735363e-285, 2.4084160842482777461e-301, + 4.3456134301905148502e-254, 6.3684349745470443788e-270, -9.5347405022956030541e-287, -1.5805886663557401565e-302, + 9.3569766393097138822e-255, 2.5826679788133653036e-270, -9.5347405022956030541e-287, -1.5805886663557401565e-302, + 9.3569766393097138822e-255, 2.5826679788133653036e-270, -9.5347405022956030541e-287, -1.5805886663557401565e-302, + 8.3218722366085688343e-256, -2.0046830753539152442e-272, -3.4057806738724185961e-288, 2.3458177946667328156e-304, + 8.3218722366085688343e-256, -2.0046830753539152442e-272, -3.4057806738724185961e-288, 2.3458177946667328156e-304, + 8.3218722366085688343e-256, -2.0046830753539152442e-272, -3.4057806738724185961e-288, 2.3458177946667328156e-304, + 8.3218722366085688343e-256, -2.0046830753539152442e-272, -3.4057806738724185961e-288, 2.3458177946667328156e-304, + 2.9938788518280315834e-256, -2.0046830753539152442e-272, -3.4057806738724185961e-288, 2.3458177946667328156e-304, + 3.2988215943776273615e-257, 2.1353977370878701046e-273, -1.2215123283371736879e-289, 6.7342163555358599277e-306, + 3.2988215943776273615e-257, 2.1353977370878701046e-273, -1.2215123283371736879e-289, 6.7342163555358599277e-306, + 3.2988215943776273615e-257, 2.1353977370878701046e-273, -1.2215123283371736879e-289, 6.7342163555358599277e-306, + 3.2988215943776273615e-257, 2.1353977370878701046e-273, -1.2215123283371736879e-289, 6.7342163555358599277e-306, + 1.6338236616337094706e-257, 2.1353977370878701046e-273, -1.2215123283371736879e-289, 6.7342163555358599277e-306, + 8.0132469526175071002e-258, 2.8687869620228451614e-274, -1.9537812801257956865e-290, 1.0380272777574237546e-306, + 3.850752120757712373e-258, 2.8687869620228451614e-274, -1.9537812801257956865e-290, 1.0380272777574237546e-306, + 1.7695047048278150093e-258, 2.8687869620228451614e-274, -1.9537812801257956865e-290, 1.0380272777574237546e-306, + 7.2888099686286655858e-259, 5.581381609158630475e-275, 6.1155422068568946933e-291, 1.0380272777574237546e-306, + 2.0856914288039227544e-259, -1.9524039360882352712e-276, -2.9779654517181712829e-292, -3.000817432603284506e-308, + 2.0856914288039227544e-259, -1.9524039360882352712e-276, -2.9779654517181712829e-292, -3.000817432603284506e-308, + 7.8491179384773690214e-260, -1.9524039360882352712e-276, -2.9779654517181712829e-292, -3.000817432603284506e-308, + 1.345219763696439399e-260, 1.6579848156414234801e-276, 1.0303712682997738281e-292, 1.4493302844111182601e-308, + 1.345219763696439399e-260, 1.6579848156414234801e-276, 1.0303712682997738281e-292, 1.4493302844111182601e-308, + 1.345219763696439399e-260, 1.6579848156414234801e-276, 1.0303712682997738281e-292, 1.4493302844111182601e-308, + 5.3223249184882342185e-261, -1.472095602234059958e-277, 2.8287088295287585094e-294, -1.0874435234232647519e-310, + 1.2573885592501529789e-261, 3.0408903374280139822e-277, 2.8287088295287585094e-294, -1.0874435234232647519e-310, + 1.2573885592501529789e-261, 3.0408903374280139822e-277, 2.8287088295287585094e-294, -1.0874435234232647519e-310, + 2.4115446944063306384e-262, 2.202741251392177696e-278, 2.8287088295287585094e-294, -1.0874435234232647519e-310, + 2.4115446944063306384e-262, 2.202741251392177696e-278, 2.8287088295287585094e-294, -1.0874435234232647519e-310, + 2.4115446944063306384e-262, 2.202741251392177696e-278, 2.8287088295287585094e-294, -1.0874435234232647519e-310, + 1.1412520821444306741e-262, -6.1787496089661820348e-279, -3.028042329852615431e-295, -2.182740474438892116e-311, + 5.0610577601348040988e-263, 7.9243314524777990283e-279, -3.028042329852615431e-295, -2.182740474438892116e-311, + 1.8853262294800541881e-263, 8.7279092175580810531e-280, 8.8634899828990930877e-296, -9.8167844904532653004e-314, + 2.9746046415267896827e-264, -8.6516445844406224413e-282, -5.0528699238150265939e-299, -1.3288013265921760399e-314, + 2.9746046415267896827e-264, -8.6516445844406224413e-282, -5.0528699238150265939e-299, -1.3288013265921760399e-314, + 2.9746046415267896827e-264, -8.6516445844406224413e-282, -5.0528699238150265939e-299, -1.3288013265921760399e-314, + 9.8977243486757054781e-265, -8.6516445844406224413e-282, -5.0528699238150265939e-299, -1.3288013265921760399e-314, + 9.8977243486757054781e-265, -8.6516445844406224413e-282, -5.0528699238150265939e-299, -1.3288013265921760399e-314, + 4.9356438320276576408e-265, -8.6516445844406224413e-282, -5.0528699238150265939e-299, -1.3288013265921760399e-314, + 2.4546035737036337221e-265, -8.6516445844406224413e-282, -5.0528699238150265939e-299, -1.3288013265921760399e-314, + 1.2140834445416214873e-265, 1.8893435613692150014e-281, 3.0075895258731974416e-297, -9.8167844904532653004e-314, + 5.9382337996061564537e-266, 5.1208955146257653156e-282, -5.0528699238150265939e-299, -1.3288013265921760399e-314, + 2.8369334767011265554e-266, 5.1208955146257653156e-282, -5.0528699238150265939e-299, -1.3288013265921760399e-314, + 1.2862833152486119506e-266, 1.6777604898591683764e-282, -5.0528699238150265939e-299, -1.3288013265921760399e-314, + 5.1095823452235464813e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, -2.5539572388808429997e-317, + 1.2329569415922591084e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, -2.5539572388808429997e-317, + 1.2329569415922591084e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, -2.5539572388808429997e-317, + 2.638005906844371576e-268, 6.3790946999826013345e-284, -2.7456019707854725967e-300, -2.5539572388808429997e-317, + 2.638005906844371576e-268, 6.3790946999826013345e-284, -2.7456019707854725967e-300, -2.5539572388808429997e-317, + 2.1511502957481757317e-269, 3.2670891426006735363e-285, 2.4084160842482773317e-301, 5.7350888195772519812e-317, + 2.1511502957481757317e-269, 3.2670891426006735363e-285, 2.4084160842482773317e-301, 5.7350888195772519812e-317, + 2.1511502957481757317e-269, 3.2670891426006735363e-285, 2.4084160842482773317e-301, 5.7350888195772519812e-317, + 2.1511502957481757317e-269, 3.2670891426006735363e-285, 2.4084160842482773317e-301, 5.7350888195772519812e-317, + 6.3684349745470443788e-270, -9.5347405022956030541e-287, -1.5805886663557401565e-302, 3.6369654387311681856e-319, + 6.3684349745470443788e-270, -9.5347405022956030541e-287, -1.5805886663557401565e-302, 3.6369654387311681856e-319, + 2.5826679788133653036e-270, -9.5347405022956030541e-287, -1.5805886663557401565e-302, 3.6369654387311681856e-319, + 6.8978448094652555593e-271, 1.1480487920352081009e-286, 7.5257037990230704094e-303, 3.6369654387311681856e-319, + 6.8978448094652555593e-271, 1.1480487920352081009e-286, 7.5257037990230704094e-303, 3.6369654387311681856e-319, + 2.1656360647981577662e-271, 9.7287370902823839435e-288, 1.6928061833779524157e-303, 3.6369654387311681856e-319, + 2.1656360647981577662e-271, 9.7287370902823839435e-288, 1.6928061833779524157e-303, 3.6369654387311681856e-319, + 9.825838786313830552e-272, 9.7287370902823839435e-288, 1.6928061833779524157e-303, 3.6369654387311681856e-319, + 3.9105778554799569972e-272, 9.7287370902823839435e-288, 1.6928061833779524157e-303, 3.6369654387311681856e-319, + 9.5294739006302120482e-273, -1.2215123283371736879e-289, 6.7342163555358599277e-306, -5.681754927174335258e-322, + 9.5294739006302120482e-273, -1.2215123283371736879e-289, 6.7342163555358599277e-306, -5.681754927174335258e-322, + 2.1353977370878701046e-273, -1.2215123283371736879e-289, 6.7342163555358599277e-306, -5.681754927174335258e-322, + 2.1353977370878701046e-273, -1.2215123283371736879e-289, 6.7342163555358599277e-306, -5.681754927174335258e-322, + 2.8687869620228451614e-274, -1.9537812801257956865e-290, 1.0380272777574237546e-306, 6.4228533959362050743e-323, +}; + +static const float Sleef_rempitabsp[] = { + 0.159154892, 5.112411827e-08, 3.626141271e-15, -2.036222915e-22, + 0.03415493667, 6.420638243e-09, 7.342738037e-17, 8.135951656e-24, + 0.03415493667, 6.420638243e-09, 7.342738037e-17, 8.135951656e-24, + 0.002904943191, -9.861969574e-11, -9.839336547e-18, -1.790215892e-24, + 0.002904943191, -9.861969574e-11, -9.839336547e-18, -1.790215892e-24, + 0.002904943191, -9.861969574e-11, -9.839336547e-18, -1.790215892e-24, + 0.002904943191, -9.861969574e-11, -9.839336547e-18, -1.790215892e-24, + 0.0009518179577, 1.342109202e-10, 1.791623576e-17, 1.518506657e-24, + 0.0009518179577, 1.342109202e-10, 1.791623576e-17, 1.518506657e-24, + 0.0004635368241, 1.779561221e-11, 4.038449606e-18, -1.358546052e-25, + 0.0002193961991, 1.779561221e-11, 4.038449606e-18, -1.358546052e-25, + 9.73258866e-05, 1.779561221e-11, 4.038449606e-18, -1.358546052e-25, + 3.62907449e-05, 3.243700447e-12, 5.690024473e-19, 7.09405479e-26, + 5.773168596e-06, 1.424711477e-12, 1.3532163e-19, 1.92417627e-26, + 5.773168596e-06, 1.424711477e-12, 1.3532163e-19, 1.92417627e-26, + 5.773168596e-06, 1.424711477e-12, 1.3532163e-19, 1.92417627e-26, + 1.958472239e-06, 5.152167755e-13, 1.3532163e-19, 1.92417627e-26, + 5.112411827e-08, 3.626141271e-15, -2.036222915e-22, 6.177847236e-30, + 5.112411827e-08, 3.626141271e-15, -2.036222915e-22, 6.177847236e-30, + 5.112411827e-08, 3.626141271e-15, -2.036222915e-22, 6.177847236e-30, + 5.112411827e-08, 3.626141271e-15, -2.036222915e-22, 6.177847236e-30, + 5.112411827e-08, 3.626141271e-15, -2.036222915e-22, 6.177847236e-30, + 5.112411827e-08, 3.626141271e-15, -2.036222915e-22, 6.177847236e-30, + 2.132179588e-08, 3.626141271e-15, -2.036222915e-22, 6.177847236e-30, + 6.420638243e-09, 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, + 6.420638243e-09, 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, + 2.695347945e-09, 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, + 8.327027956e-10, 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, + 8.327027956e-10, 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, + 3.670415083e-10, 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, + 1.342109202e-10, 1.791623576e-17, 1.518506361e-24, 2.613904e-31, + 1.779561221e-11, 4.038449606e-18, -1.358545683e-25, -3.443243946e-32, + 1.779561221e-11, 4.038449606e-18, -1.358545683e-25, -3.443243946e-32, + 1.779561221e-11, 4.038449606e-18, -1.358545683e-25, -3.443243946e-32, + 3.243700447e-12, 5.690024473e-19, 7.094053557e-26, 1.487136711e-32, + 3.243700447e-12, 5.690024473e-19, 7.094053557e-26, 1.487136711e-32, + 3.243700447e-12, 5.690024473e-19, 7.094053557e-26, 1.487136711e-32, + 1.424711477e-12, 1.3532163e-19, 1.924175961e-26, 2.545416018e-33, + 5.152167755e-13, 1.3532163e-19, 1.924175961e-26, 2.545416018e-33, + 6.046956013e-14, -2.036222915e-22, 6.177846108e-30, 1.082084378e-36, + 6.046956013e-14, -2.036222915e-22, 6.177846108e-30, 1.082084378e-36, + 6.046956013e-14, -2.036222915e-22, 6.177846108e-30, 1.082084378e-36, + 3.626141271e-15, -2.036222915e-22, 6.177846108e-30, 1.082084378e-36, + 3.626141271e-15, -2.036222915e-22, 6.177846108e-30, 1.082084378e-36, + 3.626141271e-15, -2.036222915e-22, 6.177846108e-30, 1.082084378e-36, + 3.626141271e-15, -2.036222915e-22, 6.177846108e-30, 1.082084378e-36, + 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, 6.296048013e-40, + 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, 6.296048013e-40, + 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, 6.296048013e-40, + 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, 6.296048013e-40, + 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, 6.296048013e-40, + 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, 6.296048013e-40, + 1.791623576e-17, 1.518506361e-24, 2.61390353e-31, 4.764937743e-38, + 1.791623576e-17, 1.518506361e-24, 2.61390353e-31, 4.764937743e-38, + 4.038449606e-18, -1.358545683e-25, -3.443243946e-32, 6.296048013e-40, + 4.038449606e-18, -1.358545683e-25, -3.443243946e-32, 6.296048013e-40, + 5.690024473e-19, 7.094053557e-26, 1.487136711e-32, 6.296048013e-40, + 5.690024473e-19, 7.094053557e-26, 1.487136711e-32, 6.296048013e-40, + 5.690024473e-19, 7.094053557e-26, 1.487136711e-32, 6.296048013e-40, + 1.3532163e-19, 1.924175961e-26, 2.545415467e-33, 6.296048013e-40, + 1.3532163e-19, 1.924175961e-26, 2.545415467e-33, 6.296048013e-40, + 2.690143217e-20, -1.452834402e-28, -6.441077673e-36, -1.764234767e-42, + 2.690143217e-20, -1.452834402e-28, -6.441077673e-36, -1.764234767e-42, + 2.690143217e-20, -1.452834402e-28, -6.441077673e-36, -1.764234767e-42, + 1.334890502e-20, -1.452834402e-28, -6.441077673e-36, -1.764234767e-42, + 6.572641438e-21, -1.452834402e-28, -6.441077673e-36, -1.764234767e-42, + 0.05874381959, 1.222115387e-08, 7.693612965e-16, 1.792054435e-22, + 0.02749382704, 4.77057327e-09, 7.693612965e-16, 1.792054435e-22, + 0.01186883077, 1.045283415e-09, 3.252721926e-16, 7.332633139e-23, + 0.00405633077, 1.045283415e-09, 3.252721926e-16, 7.332633139e-23, + 0.000150081818, -2.454155802e-12, 1.161414894e-20, 1.291319272e-27, + 0.000150081818, -2.454155802e-12, 1.161414894e-20, 1.291319272e-27, + 0.000150081818, -2.454155802e-12, 1.161414894e-20, 1.291319272e-27, + 0.000150081818, -2.454155802e-12, 1.161414894e-20, 1.291319272e-27, + 0.000150081818, -2.454155802e-12, 1.161414894e-20, 1.291319272e-27, + 2.801149822e-05, 4.821800945e-12, 8.789757674e-19, 1.208447639e-25, + 2.801149822e-05, 4.821800945e-12, 8.789757674e-19, 1.208447639e-25, + 2.801149822e-05, 4.821800945e-12, 8.789757674e-19, 1.208447639e-25, + 1.275271279e-05, 1.183823005e-12, 1.161414894e-20, 1.291319272e-27, + 5.12331826e-06, 1.183823005e-12, 1.161414894e-20, 1.291319272e-27, + 1.308621904e-06, 2.743283031e-13, 1.161414894e-20, 1.291319272e-27, + 1.308621904e-06, 2.743283031e-13, 1.161414894e-20, 1.291319272e-27, + 3.549478151e-07, 4.695462769e-14, 1.161414894e-20, 1.291319272e-27, + 3.549478151e-07, 4.695462769e-14, 1.161414894e-20, 1.291319272e-27, + 1.165292645e-07, 1.853292503e-14, 4.837885366e-21, 1.291319272e-27, + 1.165292645e-07, 1.853292503e-14, 4.837885366e-21, 1.291319272e-27, + 5.69246339e-08, 4.322073705e-15, 1.449754789e-21, 7.962890365e-29, + 2.712231151e-08, 4.322073705e-15, 1.449754789e-21, 7.962890365e-29, + 1.222115387e-08, 7.693612965e-16, 1.792054182e-22, 2.91418027e-29, + 4.77057327e-09, 7.693612965e-16, 1.792054182e-22, 2.91418027e-29, + 1.045283415e-09, 3.252721926e-16, 7.332632508e-23, 3.898253736e-30, + 1.045283415e-09, 3.252721926e-16, 7.332632508e-23, 3.898253736e-30, + 1.139611461e-10, 1.996093359e-17, 5.344349223e-25, 1.511644828e-31, + 1.139611461e-10, 1.996093359e-17, 5.344349223e-25, 1.511644828e-31, + 1.139611461e-10, 1.996093359e-17, 5.344349223e-25, 1.511644828e-31, + 1.139611461e-10, 1.996093359e-17, 5.344349223e-25, 1.511644828e-31, + 5.575349904e-11, 6.083145782e-18, 5.344349223e-25, 1.511644828e-31, + 2.664967552e-11, -8.557475018e-19, -8.595036458e-26, -2.139883875e-32, + 1.209775682e-11, 2.61369883e-18, 5.344349223e-25, 1.511644828e-31, + 4.821800945e-12, 8.789757674e-19, 1.208447639e-25, 3.253064536e-33, + 1.183823005e-12, 1.161414894e-20, 1.29131908e-27, 1.715766248e-34, + 1.183823005e-12, 1.161414894e-20, 1.29131908e-27, 1.715766248e-34, + 2.743283031e-13, 1.161414894e-20, 1.29131908e-27, 1.715766248e-34, +}; +#endif // #ifndef __SLEEF_REMPITAB__ + +#if !defined(__NVCC__) && ((defined(__SIZEOF_FLOAT128__) && __SIZEOF_FLOAT128__ == 16) || (defined(__linux__) && defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))) || (defined(__PPC64__) && defined(__GNUC__) && !defined(__clang__) && __GNUC__ >= 8)) +#define SLEEF_FLOAT128_IS_IEEEQP +#endif + +#if !defined(SLEEF_FLOAT128_IS_IEEEQP) && !defined(__NVCC__) && defined(__SIZEOF_LONG_DOUBLE__) && __SIZEOF_LONG_DOUBLE__ == 16 && (defined(__aarch64__) || defined(__zarch__)) +#define SLEEF_LONGDOUBLE_IS_IEEEQP +#endif + +#if !defined(Sleef_quad_DEFINED) +#define Sleef_quad_DEFINED +typedef struct { uint64_t x, y; } Sleef_uint64_2t; +#if defined(SLEEF_FLOAT128_IS_IEEEQP) +typedef __float128 Sleef_quad; +#define SLEEF_QUAD_C(x) (x ## Q) +#elif defined(SLEEF_LONGDOUBLE_IS_IEEEQP) +typedef long double Sleef_quad; +#define SLEEF_QUAD_C(x) (x ## L) +#else +typedef Sleef_uint64_2t Sleef_quad; +#endif +#endif + +extern const double Sleef_rempitabdp[]; + +typedef uint32x4_t vmask_advsimd_sleef; +typedef uint32x4_t vopmask_advsimd_sleef; + +typedef float32x4_t vfloat_advsimd_sleef; +typedef int32x4_t vint2_advsimd_sleef; + +typedef float64x2_t vdouble_advsimd_sleef; +typedef int32x2_t vint_advsimd_sleef; + +typedef int64x2_t vint64_advsimd_sleef; +typedef uint64x2_t vuint64_advsimd_sleef; + +typedef struct { + vmask_advsimd_sleef x, y; +} vquad_advsimd_sleef; + +typedef vquad_advsimd_sleef vargquad_advsimd_sleef; + +static SLEEF_ALWAYS_INLINE int vavailability_i_advsimd_sleef(int name) { return 3; } +static SLEEF_ALWAYS_INLINE void vprefetch_v_p_advsimd_sleef(const void *ptr) { } + +static SLEEF_ALWAYS_INLINE int vtestallones_i_vo32_advsimd_sleef(vopmask_advsimd_sleef g) { + uint32x2_t x0 = vand_u32(vget_low_u32(g), vget_high_u32(g)); + uint32x2_t x1 = vpmin_u32(x0, x0); + return vget_lane_u32(x1, 0); +} + +static SLEEF_ALWAYS_INLINE int vtestallones_i_vo64_advsimd_sleef(vopmask_advsimd_sleef g) { + uint32x2_t x0 = vand_u32(vget_low_u32(g), vget_high_u32(g)); + uint32x2_t x1 = vpmin_u32(x0, x0); + return vget_lane_u32(x1, 0); +} + +static SLEEF_ALWAYS_INLINE vdouble_advsimd_sleef vload_vd_p_advsimd_sleef(const double *ptr) { return vld1q_f64(ptr); } +static SLEEF_ALWAYS_INLINE vdouble_advsimd_sleef vloadu_vd_p_advsimd_sleef(const double *ptr) { return vld1q_f64(ptr); } +static SLEEF_ALWAYS_INLINE void vstore_v_p_vd_advsimd_sleef(double *ptr, vdouble_advsimd_sleef v) { vst1q_f64(ptr, v); } +static SLEEF_ALWAYS_INLINE void vstoreu_v_p_vd_advsimd_sleef(double *ptr, vdouble_advsimd_sleef v) { vst1q_f64(ptr, v); } +static SLEEF_ALWAYS_INLINE vfloat_advsimd_sleef vload_vf_p_advsimd_sleef(const float *ptr) { return vld1q_f32(ptr); } +static SLEEF_ALWAYS_INLINE vfloat_advsimd_sleef vloadu_vf_p_advsimd_sleef(const float *ptr) { return vld1q_f32(ptr); } +static SLEEF_ALWAYS_INLINE void vstore_v_p_vf_advsimd_sleef(float *ptr, vfloat_advsimd_sleef v) { vst1q_f32(ptr, v); } +static SLEEF_ALWAYS_INLINE void vstoreu_v_p_vf_advsimd_sleef(float *ptr, vfloat_advsimd_sleef v) { vst1q_f32(ptr, v); } +static SLEEF_ALWAYS_INLINE vint2_advsimd_sleef vloadu_vi2_p_advsimd_sleef(int32_t *p) { return vld1q_s32(p); } +static SLEEF_ALWAYS_INLINE void vstoreu_v_p_vi2_advsimd_sleef(int32_t *p, vint2_advsimd_sleef v) { vst1q_s32(p, v); } +static SLEEF_ALWAYS_INLINE vint_advsimd_sleef vloadu_vi_p_advsimd_sleef(int32_t *p) { return vld1_s32(p); } +static SLEEF_ALWAYS_INLINE void vstoreu_v_p_vi_advsimd_sleef(int32_t *p, vint_advsimd_sleef v) { vst1_s32(p, v); } + +static SLEEF_ALWAYS_INLINE vdouble_advsimd_sleef vgather_vd_p_vi_advsimd_sleef(const double *ptr, vint_advsimd_sleef vi) { + return ((vdouble_advsimd_sleef) { ptr[vget_lane_s32(vi, 0)], ptr[vget_lane_s32(vi, 1)]} ); +} + +static SLEEF_ALWAYS_INLINE vfloat_advsimd_sleef vgather_vf_p_vi2_advsimd_sleef(const float *ptr, vint2_advsimd_sleef vi2) { + return ((vfloat_advsimd_sleef) { + ptr[vgetq_lane_s32(vi2, 0)], + ptr[vgetq_lane_s32(vi2, 1)], + ptr[vgetq_lane_s32(vi2, 2)], + ptr[vgetq_lane_s32(vi2, 3)] + }); +} + +static SLEEF_ALWAYS_INLINE vmask_advsimd_sleef vand_vm_vm_vm_advsimd_sleef(vmask_advsimd_sleef x, vmask_advsimd_sleef y) { return vandq_u32(x, y); } +static SLEEF_ALWAYS_INLINE vmask_advsimd_sleef vandnot_vm_vm_vm_advsimd_sleef(vmask_advsimd_sleef x, vmask_advsimd_sleef y) { + return vbicq_u32(y, x); +} +static SLEEF_ALWAYS_INLINE vmask_advsimd_sleef vor_vm_vm_vm_advsimd_sleef(vmask_advsimd_sleef x, vmask_advsimd_sleef y) { return vorrq_u32(x, y); } +static SLEEF_ALWAYS_INLINE vmask_advsimd_sleef vxor_vm_vm_vm_advsimd_sleef(vmask_advsimd_sleef x, vmask_advsimd_sleef y) { return veorq_u32(x, y); } + +static SLEEF_ALWAYS_INLINE vmask_advsimd_sleef vreinterpret_vm_vf_advsimd_sleef(vfloat_advsimd_sleef vf) { + return vreinterpretq_u32_f32(vf); +} +static SLEEF_ALWAYS_INLINE vfloat_advsimd_sleef vreinterpret_vf_vm_advsimd_sleef(vmask_advsimd_sleef vm) { + return vreinterpretq_f32_u32(vm); +} +static SLEEF_ALWAYS_INLINE vint2_advsimd_sleef vcast_vi2_vm_advsimd_sleef(vmask_advsimd_sleef vm) { return vreinterpretq_s32_u32(vm); } +static SLEEF_ALWAYS_INLINE vmask_advsimd_sleef vcast_vm_vi2_advsimd_sleef(vint2_advsimd_sleef vi) { return vreinterpretq_u32_s32(vi); } + +static SLEEF_ALWAYS_INLINE vmask_advsimd_sleef vreinterpret_vm_vd_advsimd_sleef(vdouble_advsimd_sleef vd_advsimd_sleef) { + return vreinterpretq_u32_f64(vd_advsimd_sleef); +} +static SLEEF_ALWAYS_INLINE vdouble_advsimd_sleef vreinterpret_vd_vm_advsimd_sleef(vmask_advsimd_sleef vm) { + return vreinterpretq_f64_u32(vm); +} +static SLEEF_ALWAYS_INLINE vfloat_advsimd_sleef vreinterpret_vf_vi2_advsimd_sleef(vint2_advsimd_sleef vm) { + return vreinterpretq_f32_s32(vm); +} +static SLEEF_ALWAYS_INLINE vint2_advsimd_sleef vreinterpret_vi2_vf_advsimd_sleef(vfloat_advsimd_sleef vf) { + return vreinterpretq_s32_f32(vf); +} + +static SLEEF_ALWAYS_INLINE vfloat_advsimd_sleef vcast_vf_f_advsimd_sleef(float f) { return vdupq_n_f32(f); } + +static SLEEF_ALWAYS_INLINE vfloat_advsimd_sleef vadd_vf_vf_vf_advsimd_sleef(vfloat_advsimd_sleef x, vfloat_advsimd_sleef y) { + return vaddq_f32(x, y); +} +static SLEEF_ALWAYS_INLINE vfloat_advsimd_sleef vsub_vf_vf_vf_advsimd_sleef(vfloat_advsimd_sleef x, vfloat_advsimd_sleef y) { + return vsubq_f32(x, y); +} +static SLEEF_ALWAYS_INLINE vfloat_advsimd_sleef vmul_vf_vf_vf_advsimd_sleef(vfloat_advsimd_sleef x, vfloat_advsimd_sleef y) { + return vmulq_f32(x, y); +} + +static SLEEF_ALWAYS_INLINE vfloat_advsimd_sleef vabs_vf_vf_advsimd_sleef(vfloat_advsimd_sleef f) { return vabsq_f32(f); } +static SLEEF_ALWAYS_INLINE vfloat_advsimd_sleef vneg_vf_vf_advsimd_sleef(vfloat_advsimd_sleef f) { return vnegq_f32(f); } + +static SLEEF_ALWAYS_INLINE vfloat_advsimd_sleef vmla_vf_vf_vf_vf_advsimd_sleef(vfloat_advsimd_sleef x, vfloat_advsimd_sleef y, vfloat_advsimd_sleef z) { + return vfmaq_f32(z, x, y); +} + +static SLEEF_ALWAYS_INLINE vfloat_advsimd_sleef vmlanp_vf_vf_vf_vf_advsimd_sleef(vfloat_advsimd_sleef x, vfloat_advsimd_sleef y, vfloat_advsimd_sleef z) { + return vfmsq_f32(z, x, y); +} + +static SLEEF_ALWAYS_INLINE vfloat_advsimd_sleef vmlapn_vf_vf_vf_vf_advsimd_sleef(vfloat_advsimd_sleef x, vfloat_advsimd_sleef y, vfloat_advsimd_sleef z) { + return vneg_vf_vf_advsimd_sleef(vfmsq_f32(z, x, y)); +} + +static SLEEF_ALWAYS_INLINE vfloat_advsimd_sleef vfma_vf_vf_vf_vf_advsimd_sleef(vfloat_advsimd_sleef x, vfloat_advsimd_sleef y, vfloat_advsimd_sleef z) { + return vfmaq_f32(z, x, y); +} + +static SLEEF_ALWAYS_INLINE vfloat_advsimd_sleef vfmanp_vf_vf_vf_vf_advsimd_sleef(vfloat_advsimd_sleef x, vfloat_advsimd_sleef y, vfloat_advsimd_sleef z) { + return vfmsq_f32(z, x, y); +} + +static SLEEF_ALWAYS_INLINE vfloat_advsimd_sleef vfmapn_vf_vf_vf_vf_advsimd_sleef(vfloat_advsimd_sleef x, vfloat_advsimd_sleef y, vfloat_advsimd_sleef z) { + return vfma_vf_vf_vf_vf_advsimd_sleef(x, y, vneg_vf_vf_advsimd_sleef(z)); +} + +static SLEEF_ALWAYS_INLINE vfloat_advsimd_sleef vdiv_vf_vf_vf_advsimd_sleef(vfloat_advsimd_sleef n, vfloat_advsimd_sleef d) { + + return vdivq_f32(n, d); + +} +static SLEEF_ALWAYS_INLINE vfloat_advsimd_sleef vrec_vf_vf_advsimd_sleef(vfloat_advsimd_sleef d) { + + return vdiv_vf_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(1.0f), d); + +} + +static SLEEF_ALWAYS_INLINE vfloat_advsimd_sleef vsqrt_vf_vf_advsimd_sleef(vfloat_advsimd_sleef d) { + + return vsqrtq_f32(d); + +} + +static SLEEF_ALWAYS_INLINE vfloat_advsimd_sleef vmax_vf_vf_vf_advsimd_sleef(vfloat_advsimd_sleef x, vfloat_advsimd_sleef y) { + return vmaxq_f32(x, y); +} +static SLEEF_ALWAYS_INLINE vfloat_advsimd_sleef vmin_vf_vf_vf_advsimd_sleef(vfloat_advsimd_sleef x, vfloat_advsimd_sleef y) { + return vminq_f32(x, y); +} + +static SLEEF_ALWAYS_INLINE vmask_advsimd_sleef veq_vm_vf_vf(vfloat_advsimd_sleef x, vfloat_advsimd_sleef y) { return vceqq_f32(x, y); } +static SLEEF_ALWAYS_INLINE vmask_advsimd_sleef vneq_vm_vf_vf(vfloat_advsimd_sleef x, vfloat_advsimd_sleef y) { + return vmvnq_u32(vceqq_f32(x, y)); +} +static SLEEF_ALWAYS_INLINE vmask_advsimd_sleef vlt_vm_vf_vf(vfloat_advsimd_sleef x, vfloat_advsimd_sleef y) { return vcltq_f32(x, y); } +static SLEEF_ALWAYS_INLINE vmask_advsimd_sleef vle_vm_vf_vf(vfloat_advsimd_sleef x, vfloat_advsimd_sleef y) { return vcleq_f32(x, y); } +static SLEEF_ALWAYS_INLINE vmask_advsimd_sleef vgt_vm_vf_vf(vfloat_advsimd_sleef x, vfloat_advsimd_sleef y) { return vcgtq_f32(x, y); } +static SLEEF_ALWAYS_INLINE vmask_advsimd_sleef vge_vm_vf_vf(vfloat_advsimd_sleef x, vfloat_advsimd_sleef y) { return vcgeq_f32(x, y); } + +static SLEEF_ALWAYS_INLINE vfloat_advsimd_sleef vsel_vf_vm_vf_vf(vmask_advsimd_sleef mask, vfloat_advsimd_sleef x, vfloat_advsimd_sleef y) { + return vbslq_f32(mask, x, y); +} + +static SLEEF_ALWAYS_INLINE vint2_advsimd_sleef vtruncate_vi2_vf_advsimd_sleef(vfloat_advsimd_sleef vf) { return vcvtq_s32_f32(vf); } +static SLEEF_ALWAYS_INLINE vfloat_advsimd_sleef vcast_vf_vi2_advsimd_sleef(vint2_advsimd_sleef vi) { return vcvtq_f32_s32(vi); } +static SLEEF_ALWAYS_INLINE vint2_advsimd_sleef vcast_vi2_i_advsimd_sleef(int i) { return vdupq_n_s32(i); } +static SLEEF_ALWAYS_INLINE vint2_advsimd_sleef vrint_vi2_vf_advsimd_sleef(vfloat_advsimd_sleef d) { + return vcvtq_s32_f32(vrndnq_f32(d)); +} + +static SLEEF_ALWAYS_INLINE vint2_advsimd_sleef vadd_vi2_vi2_vi2_advsimd_sleef(vint2_advsimd_sleef x, vint2_advsimd_sleef y) { + return vaddq_s32(x, y); +} +static SLEEF_ALWAYS_INLINE vint2_advsimd_sleef vsub_vi2_vi2_vi2_advsimd_sleef(vint2_advsimd_sleef x, vint2_advsimd_sleef y) { + return vsubq_s32(x, y); +} +static SLEEF_ALWAYS_INLINE vint2_advsimd_sleef vneg_vi2_vi2_advsimd_sleef(vint2_advsimd_sleef e) { return vnegq_s32(e); } + +static SLEEF_ALWAYS_INLINE vint2_advsimd_sleef vand_vi2_vi2_vi2_advsimd_sleef(vint2_advsimd_sleef x, vint2_advsimd_sleef y) { + return vandq_s32(x, y); +} +static SLEEF_ALWAYS_INLINE vint2_advsimd_sleef vandnot_vi2_vi2_vi2_advsimd_sleef(vint2_advsimd_sleef x, vint2_advsimd_sleef y) { + return vbicq_s32(y, x); +} +static SLEEF_ALWAYS_INLINE vint2_advsimd_sleef vor_vi2_vi2_vi2_advsimd_sleef(vint2_advsimd_sleef x, vint2_advsimd_sleef y) { + return vorrq_s32(x, y); +} +static SLEEF_ALWAYS_INLINE vint2_advsimd_sleef vxor_vi2_vi2_vi2_advsimd_sleef(vint2_advsimd_sleef x, vint2_advsimd_sleef y) { + return veorq_s32(x, y); +} + +static SLEEF_ALWAYS_INLINE vmask_advsimd_sleef veq_vm_vi2_vi2(vint2_advsimd_sleef x, vint2_advsimd_sleef y) { return vceqq_s32(x, y); } +static SLEEF_ALWAYS_INLINE vmask_advsimd_sleef vgt_vm_vi2_vi2(vint2_advsimd_sleef x, vint2_advsimd_sleef y) { return vcgeq_s32(x, y); } + +static SLEEF_ALWAYS_INLINE vint2_advsimd_sleef vgt_vi2_vi2_vi2_advsimd_sleef(vint2_advsimd_sleef x, vint2_advsimd_sleef y) { + return vreinterpretq_s32_u32(vcgtq_s32(x, y)); +} +static SLEEF_ALWAYS_INLINE vint2_advsimd_sleef veq_vi2_vi2_vi2_advsimd_sleef(vint2_advsimd_sleef x, vint2_advsimd_sleef y) { + return vreinterpretq_s32_u32(vceqq_s32(x, y)); +} + +static SLEEF_ALWAYS_INLINE vint2_advsimd_sleef vsel_vi2_vm_vi2_vi2(vmask_advsimd_sleef m, vint2_advsimd_sleef x, vint2_advsimd_sleef y) { + return vbslq_s32(m, x, y); +} + +static SLEEF_ALWAYS_INLINE vdouble_advsimd_sleef vcast_vd_d_advsimd_sleef(double f) { return vdupq_n_f64(f); } + +static SLEEF_ALWAYS_INLINE vdouble_advsimd_sleef vadd_vd_vd_vd_advsimd_sleef(vdouble_advsimd_sleef x, vdouble_advsimd_sleef y) { + return vaddq_f64(x, y); +} +static SLEEF_ALWAYS_INLINE vdouble_advsimd_sleef vsub_vd_vd_vd_advsimd_sleef(vdouble_advsimd_sleef x, vdouble_advsimd_sleef y) { + return vsubq_f64(x, y); +} +static SLEEF_ALWAYS_INLINE vdouble_advsimd_sleef vmul_vd_vd_vd_advsimd_sleef(vdouble_advsimd_sleef x, vdouble_advsimd_sleef y) { + return vmulq_f64(x, y); +} + +static SLEEF_ALWAYS_INLINE vdouble_advsimd_sleef vabs_vd_vd_advsimd_sleef(vdouble_advsimd_sleef f) { return vabsq_f64(f); } +static SLEEF_ALWAYS_INLINE vdouble_advsimd_sleef vneg_vd_vd_advsimd_sleef(vdouble_advsimd_sleef f) { return vnegq_f64(f); } + +static SLEEF_ALWAYS_INLINE vdouble_advsimd_sleef vmax_vd_vd_vd_advsimd_sleef(vdouble_advsimd_sleef x, vdouble_advsimd_sleef y) { + return vmaxq_f64(x, y); +} +static SLEEF_ALWAYS_INLINE vdouble_advsimd_sleef vmin_vd_vd_vd_advsimd_sleef(vdouble_advsimd_sleef x, vdouble_advsimd_sleef y) { + return vminq_f64(x, y); +} + +static SLEEF_ALWAYS_INLINE vdouble_advsimd_sleef vmla_vd_vd_vd_vd_advsimd_sleef(vdouble_advsimd_sleef x, vdouble_advsimd_sleef y, vdouble_advsimd_sleef z) { + return vfmaq_f64(z, x, y); +} + +static SLEEF_ALWAYS_INLINE vdouble_advsimd_sleef vmlanp_vd_vd_vd_vd_advsimd_sleef(vdouble_advsimd_sleef x, vdouble_advsimd_sleef y, vdouble_advsimd_sleef z) { + return vfmsq_f64(z, x, y); +} + +static SLEEF_ALWAYS_INLINE vdouble_advsimd_sleef vmlapn_vd_vd_vd_vd_advsimd_sleef(vdouble_advsimd_sleef x, vdouble_advsimd_sleef y, vdouble_advsimd_sleef z) { + return vneg_vd_vd_advsimd_sleef(vfmsq_f64(z, x, y)); +} + +static SLEEF_ALWAYS_INLINE vdouble_advsimd_sleef vfma_vd_vd_vd_vd_advsimd_sleef(vdouble_advsimd_sleef x, vdouble_advsimd_sleef y, vdouble_advsimd_sleef z) { + return vfmaq_f64(z, x, y); +} + +static SLEEF_ALWAYS_INLINE vdouble_advsimd_sleef vfmanp_vd_vd_vd_vd_advsimd_sleef(vdouble_advsimd_sleef x, vdouble_advsimd_sleef y, vdouble_advsimd_sleef z) { + return vfmsq_f64(z, x, y); +} + +static SLEEF_ALWAYS_INLINE vdouble_advsimd_sleef vfmapn_vd_vd_vd_vd_advsimd_sleef(vdouble_advsimd_sleef x, vdouble_advsimd_sleef y, vdouble_advsimd_sleef z) { + return vfma_vd_vd_vd_vd_advsimd_sleef(x, y, vneg_vd_vd_advsimd_sleef(z)); +} + +static SLEEF_ALWAYS_INLINE vdouble_advsimd_sleef vdiv_vd_vd_vd_advsimd_sleef(vdouble_advsimd_sleef n, vdouble_advsimd_sleef d) { + + return vdivq_f64(n, d); + +} +static SLEEF_ALWAYS_INLINE vdouble_advsimd_sleef vrec_vd_vd_advsimd_sleef(vdouble_advsimd_sleef d) { + + return vdiv_vd_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(1.0f), d); + +} + +static SLEEF_ALWAYS_INLINE vdouble_advsimd_sleef vsqrt_vd_vd_advsimd_sleef(vdouble_advsimd_sleef d) { + + return vsqrtq_f64(d); + +} + +static SLEEF_ALWAYS_INLINE vopmask_advsimd_sleef veq_vo_vd_vd_advsimd_sleef(vdouble_advsimd_sleef x, vdouble_advsimd_sleef y) { + return vreinterpretq_u32_u64(vceqq_f64(x, y)); +} +static SLEEF_ALWAYS_INLINE vopmask_advsimd_sleef vneq_vo_vd_vd_advsimd_sleef(vdouble_advsimd_sleef x, vdouble_advsimd_sleef y) { + return vmvnq_u32(vreinterpretq_u32_u64(vceqq_f64(x, y))); +} +static SLEEF_ALWAYS_INLINE vopmask_advsimd_sleef vlt_vo_vd_vd_advsimd_sleef(vdouble_advsimd_sleef x, vdouble_advsimd_sleef y) { + return vreinterpretq_u32_u64(vcltq_f64(x, y)); +} +static SLEEF_ALWAYS_INLINE vopmask_advsimd_sleef vgt_vo_vd_vd_advsimd_sleef(vdouble_advsimd_sleef x, vdouble_advsimd_sleef y) { + return vreinterpretq_u32_u64(vcgtq_f64(x, y)); +} +static SLEEF_ALWAYS_INLINE vopmask_advsimd_sleef vle_vo_vd_vd_advsimd_sleef(vdouble_advsimd_sleef x, vdouble_advsimd_sleef y) { + return vreinterpretq_u32_u64(vcleq_f64(x, y)); +} +static SLEEF_ALWAYS_INLINE vopmask_advsimd_sleef vge_vo_vd_vd_advsimd_sleef(vdouble_advsimd_sleef x, vdouble_advsimd_sleef y) { + return vreinterpretq_u32_u64(vcgeq_f64(x, y)); +} + +static SLEEF_ALWAYS_INLINE vdouble_advsimd_sleef vsel_vd_vo_vd_vd_advsimd_sleef(vopmask_advsimd_sleef mask, vdouble_advsimd_sleef x, vdouble_advsimd_sleef y) { + return vbslq_f64(vreinterpretq_u64_u32(mask), x, y); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_advsimd_sleef vsel_vd_vo_d_d_advsimd_sleef(vopmask_advsimd_sleef o, double v1, double v0) { + return vsel_vd_vo_vd_vd_advsimd_sleef(o, vcast_vd_d_advsimd_sleef(v1), vcast_vd_d_advsimd_sleef(v0)); +} + +static SLEEF_ALWAYS_INLINE vdouble_advsimd_sleef vsel_vd_vo_vo_d_d_d_advsimd_sleef(vopmask_advsimd_sleef o0, vopmask_advsimd_sleef o1, double d0, double d1, double d2) { + return vsel_vd_vo_vd_vd_advsimd_sleef(o0, vcast_vd_d_advsimd_sleef(d0), vsel_vd_vo_d_d_advsimd_sleef(o1, d1, d2)); +} + +static SLEEF_ALWAYS_INLINE vdouble_advsimd_sleef vsel_vd_vo_vo_vo_d_d_d_d_advsimd_sleef(vopmask_advsimd_sleef o0, vopmask_advsimd_sleef o1, vopmask_advsimd_sleef o2, double d0, double d1, double d2, double d3) { + return vsel_vd_vo_vd_vd_advsimd_sleef(o0, vcast_vd_d_advsimd_sleef(d0), vsel_vd_vo_vd_vd_advsimd_sleef(o1, vcast_vd_d_advsimd_sleef(d1), vsel_vd_vo_d_d_advsimd_sleef(o2, d2, d3))); +} + +static SLEEF_ALWAYS_INLINE vdouble_advsimd_sleef vrint_vd_vd_advsimd_sleef(vdouble_advsimd_sleef d) { return vrndnq_f64(d); } +static SLEEF_ALWAYS_INLINE vfloat_advsimd_sleef vrint_vf_vf_advsimd_sleef(vfloat_advsimd_sleef d) { return vrndnq_f32(d); } + +static SLEEF_ALWAYS_INLINE vint_advsimd_sleef vtruncate_vi_vd_advsimd_sleef(vdouble_advsimd_sleef vf) { + return vmovn_s64(vcvtq_s64_f64(vf)); +} +static SLEEF_ALWAYS_INLINE vdouble_advsimd_sleef vcast_vd_vi_advsimd_sleef(vint_advsimd_sleef vi) { + return vcvtq_f64_s64(vmovl_s32(vi)); +} +static SLEEF_ALWAYS_INLINE vint_advsimd_sleef vcast_vi_i_advsimd_sleef(int i) { return vdup_n_s32(i); } +static SLEEF_ALWAYS_INLINE vint_advsimd_sleef vrint_vi_vd_advsimd_sleef(vdouble_advsimd_sleef d) { + return vqmovn_s64(vcvtq_s64_f64(vrndnq_f64(d))); +} + +static SLEEF_ALWAYS_INLINE vint_advsimd_sleef vadd_vi_vi_vi_advsimd_sleef(vint_advsimd_sleef x, vint_advsimd_sleef y) { return vadd_s32(x, y); } +static SLEEF_ALWAYS_INLINE vint_advsimd_sleef vsub_vi_vi_vi_advsimd_sleef(vint_advsimd_sleef x, vint_advsimd_sleef y) { return vsub_s32(x, y); } +static SLEEF_ALWAYS_INLINE vint_advsimd_sleef vneg_vi_vi_advsimd_sleef(vint_advsimd_sleef e) { return vneg_s32(e); } + +static SLEEF_ALWAYS_INLINE vint_advsimd_sleef vand_vi_vi_vi_advsimd_sleef(vint_advsimd_sleef x, vint_advsimd_sleef y) { return vand_s32(x, y); } +static SLEEF_ALWAYS_INLINE vint_advsimd_sleef vandnot_vi_vi_vi_advsimd_sleef(vint_advsimd_sleef x, vint_advsimd_sleef y) { return vbic_s32(y, x); } +static SLEEF_ALWAYS_INLINE vint_advsimd_sleef vor_vi_vi_vi_advsimd_sleef(vint_advsimd_sleef x, vint_advsimd_sleef y) { return vorr_s32(x, y); } +static SLEEF_ALWAYS_INLINE vint_advsimd_sleef vxor_vi_vi_vi_advsimd_sleef(vint_advsimd_sleef x, vint_advsimd_sleef y) { return veor_s32(x, y); } + +static SLEEF_ALWAYS_INLINE vopmask_advsimd_sleef veq_vo_vi_vi_advsimd_sleef(vint_advsimd_sleef x, vint_advsimd_sleef y) { + return vcombine_u32(vceq_s32(x, y), vdup_n_u32(0)); +} + +static SLEEF_ALWAYS_INLINE vint_advsimd_sleef vsel_vi_vm_vi_vi(vmask_advsimd_sleef m, vint_advsimd_sleef x, vint_advsimd_sleef y) { + return vbsl_s32(vget_low_u32(m), x, y); +} + +static SLEEF_ALWAYS_INLINE vopmask_advsimd_sleef visinf_vo_vd_advsimd_sleef(vdouble_advsimd_sleef d) { + const float64x2_t inf = vdupq_n_f64(__builtin_inf()); + const float64x2_t neg_inf = vdupq_n_f64(-__builtin_inf()); + uint64x2_t cmp = vorrq_u64(vceqq_f64(d, inf), vceqq_f64(d, neg_inf)); + return vreinterpretq_u32_u64(cmp); +} + +static SLEEF_ALWAYS_INLINE vopmask_advsimd_sleef visnan_vo_vd_advsimd_sleef(vdouble_advsimd_sleef d) { + return vmvnq_u32(vreinterpretq_u32_u64(vceqq_f64(d, d))); +} + +static SLEEF_ALWAYS_INLINE vopmask_advsimd_sleef vispinf_vo_vd_advsimd_sleef(vdouble_advsimd_sleef d) { + return vreinterpretq_u32_u64(vceqq_f64(d, vdupq_n_f64(__builtin_inf()))); +} + +static SLEEF_ALWAYS_INLINE vopmask_advsimd_sleef visminf_vo_vd_advsimd_sleef(vdouble_advsimd_sleef d) { + return vreinterpretq_u32_u64(vceqq_f64(d, vdupq_n_f64(-__builtin_inf()))); +} + +static SLEEF_ALWAYS_INLINE vfloat_advsimd_sleef vsel_vf_vo_vf_vf_advsimd_sleef(vopmask_advsimd_sleef mask, vfloat_advsimd_sleef x, vfloat_advsimd_sleef y) { + return vbslq_f32(mask, x, y); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_advsimd_sleef vsel_vf_vo_f_f_advsimd_sleef(vopmask_advsimd_sleef o, float v1, float v0) { + return vsel_vf_vo_vf_vf_advsimd_sleef(o, vcast_vf_f_advsimd_sleef(v1), vcast_vf_f_advsimd_sleef(v0)); +} + +static SLEEF_ALWAYS_INLINE vfloat_advsimd_sleef vsel_vf_vo_vo_f_f_f_advsimd_sleef(vopmask_advsimd_sleef o0, vopmask_advsimd_sleef o1, float d0, float d1, float d2) { + return vsel_vf_vo_vf_vf_advsimd_sleef(o0, vcast_vf_f_advsimd_sleef(d0), vsel_vf_vo_f_f_advsimd_sleef(o1, d1, d2)); +} + +static SLEEF_ALWAYS_INLINE vfloat_advsimd_sleef vsel_vf_vo_vo_vo_f_f_f_f_advsimd_sleef(vopmask_advsimd_sleef o0, vopmask_advsimd_sleef o1, vopmask_advsimd_sleef o2, float d0, float d1, float d2, float d3) { + return vsel_vf_vo_vf_vf_advsimd_sleef(o0, vcast_vf_f_advsimd_sleef(d0), vsel_vf_vo_vf_vf_advsimd_sleef(o1, vcast_vf_f_advsimd_sleef(d1), vsel_vf_vo_f_f_advsimd_sleef(o2, d2, d3))); +} + +static SLEEF_ALWAYS_INLINE vopmask_advsimd_sleef veq_vo_vf_vf_advsimd_sleef(vfloat_advsimd_sleef x, vfloat_advsimd_sleef y) { + return vceqq_f32(x, y); +} +static SLEEF_ALWAYS_INLINE vopmask_advsimd_sleef vneq_vo_vf_vf_advsimd_sleef(vfloat_advsimd_sleef x, vfloat_advsimd_sleef y) { + return vmvnq_u32(vceqq_f32(x, y)); +} +static SLEEF_ALWAYS_INLINE vopmask_advsimd_sleef vlt_vo_vf_vf_advsimd_sleef(vfloat_advsimd_sleef x, vfloat_advsimd_sleef y) { + return vcltq_f32(x, y); +} +static SLEEF_ALWAYS_INLINE vopmask_advsimd_sleef vle_vo_vf_vf_advsimd_sleef(vfloat_advsimd_sleef x, vfloat_advsimd_sleef y) { + return vcleq_f32(x, y); +} +static SLEEF_ALWAYS_INLINE vopmask_advsimd_sleef vgt_vo_vf_vf_advsimd_sleef(vfloat_advsimd_sleef x, vfloat_advsimd_sleef y) { + return vcgtq_f32(x, y); +} +static SLEEF_ALWAYS_INLINE vopmask_advsimd_sleef vge_vo_vf_vf_advsimd_sleef(vfloat_advsimd_sleef x, vfloat_advsimd_sleef y) { + return vcgeq_f32(x, y); +} + +static SLEEF_ALWAYS_INLINE vopmask_advsimd_sleef veq_vo_vi2_vi2_advsimd_sleef(vint2_advsimd_sleef x, vint2_advsimd_sleef y) { + return vceqq_s32(x, y); +} +static SLEEF_ALWAYS_INLINE vopmask_advsimd_sleef vgt_vo_vi2_vi2_advsimd_sleef(vint2_advsimd_sleef x, vint2_advsimd_sleef y) { + return vcgtq_s32(x, y); +} +static SLEEF_ALWAYS_INLINE vopmask_advsimd_sleef vgt_vo_vi_vi_advsimd_sleef(vint_advsimd_sleef x, vint_advsimd_sleef y) { + return vcombine_u32(vcgt_s32(x, y), vdup_n_u32(0)); +} +static SLEEF_ALWAYS_INLINE vopmask_advsimd_sleef visinf_vo_vf_advsimd_sleef(vfloat_advsimd_sleef d) { + return veq_vo_vf_vf_advsimd_sleef(vabs_vf_vf_advsimd_sleef(d), vcast_vf_f_advsimd_sleef(__builtin_inff())); +} +static SLEEF_ALWAYS_INLINE vopmask_advsimd_sleef vispinf_vo_vf_advsimd_sleef(vfloat_advsimd_sleef d) { + return veq_vo_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(__builtin_inff())); +} +static SLEEF_ALWAYS_INLINE vopmask_advsimd_sleef visminf_vo_vf_advsimd_sleef(vfloat_advsimd_sleef d) { + return veq_vo_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(-__builtin_inff())); +} +static SLEEF_ALWAYS_INLINE vopmask_advsimd_sleef visnan_vo_vf_advsimd_sleef(vfloat_advsimd_sleef d) { return vneq_vo_vf_vf_advsimd_sleef(d, d); } + +static SLEEF_ALWAYS_INLINE vopmask_advsimd_sleef vcast_vo32_vo64_advsimd_sleef(vopmask_advsimd_sleef m) { + return vuzpq_u32(m, m).val[0]; +} +static SLEEF_ALWAYS_INLINE vopmask_advsimd_sleef vcast_vo64_vo32_advsimd_sleef(vopmask_advsimd_sleef m) { + return vzipq_u32(m, m).val[0]; +} +static SLEEF_ALWAYS_INLINE vopmask_advsimd_sleef vcast_vo_i_advsimd_sleef(int i) { + return vreinterpretq_u32_u64(vdupq_n_u64((uint64_t)(i ? -1 : 0))); +} + +static SLEEF_ALWAYS_INLINE vopmask_advsimd_sleef vand_vo_vo_vo_advsimd_sleef(vopmask_advsimd_sleef x, vopmask_advsimd_sleef y) { + return vandq_u32(x, y); +} +static SLEEF_ALWAYS_INLINE vopmask_advsimd_sleef vandnot_vo_vo_vo_advsimd_sleef(vopmask_advsimd_sleef x, vopmask_advsimd_sleef y) { + return vbicq_u32(y, x); +} +static SLEEF_ALWAYS_INLINE vopmask_advsimd_sleef vor_vo_vo_vo_advsimd_sleef(vopmask_advsimd_sleef x, vopmask_advsimd_sleef y) { + return vorrq_u32(x, y); +} +static SLEEF_ALWAYS_INLINE vopmask_advsimd_sleef vxor_vo_vo_vo_advsimd_sleef(vopmask_advsimd_sleef x, vopmask_advsimd_sleef y) { + return veorq_u32(x, y); +} + +static SLEEF_ALWAYS_INLINE vint2_advsimd_sleef vsel_vi2_vo_vi2_vi2_advsimd_sleef(vopmask_advsimd_sleef m, vint2_advsimd_sleef x, vint2_advsimd_sleef y) { + return vbslq_s32(m, x, y); +} +static SLEEF_ALWAYS_INLINE vint2_advsimd_sleef vand_vi2_vo_vi2_advsimd_sleef(vopmask_advsimd_sleef x, vint2_advsimd_sleef y) { + return vandq_s32(vreinterpretq_s32_u32(x), y); +} +static SLEEF_ALWAYS_INLINE vint2_advsimd_sleef vandnot_vi2_vo_vi2_advsimd_sleef(vopmask_advsimd_sleef x, vint2_advsimd_sleef y) { + return vbicq_s32(y, vreinterpretq_s32_u32(x)); +} +static SLEEF_ALWAYS_INLINE vint_advsimd_sleef vandnot_vi_vo_vi_advsimd_sleef(vopmask_advsimd_sleef x, vint_advsimd_sleef y) { + return vbic_s32(y, vget_low_s32(vreinterpretq_s32_u32(x))); +} +static SLEEF_ALWAYS_INLINE vmask_advsimd_sleef vand_vm_vo32_vm_advsimd_sleef(vopmask_advsimd_sleef x, vmask_advsimd_sleef y) { + return vandq_u32(x, y); +} +static SLEEF_ALWAYS_INLINE vmask_advsimd_sleef vand_vm_vo64_vm_advsimd_sleef(vopmask_advsimd_sleef x, vmask_advsimd_sleef y) { + return vandq_u32(x, y); +} +static SLEEF_ALWAYS_INLINE vmask_advsimd_sleef vandnot_vm_vo32_vm_advsimd_sleef(vopmask_advsimd_sleef x, vmask_advsimd_sleef y) { + return vbicq_u32(y, x); +} +static SLEEF_ALWAYS_INLINE vmask_advsimd_sleef vandnot_vm_vo64_vm_advsimd_sleef(vopmask_advsimd_sleef x, vmask_advsimd_sleef y) { + return vbicq_u32(y, x); +} +static SLEEF_ALWAYS_INLINE vmask_advsimd_sleef vor_vm_vo32_vm_advsimd_sleef(vopmask_advsimd_sleef x, vmask_advsimd_sleef y) { + return vorrq_u32(x, y); +} +static SLEEF_ALWAYS_INLINE vmask_advsimd_sleef vor_vm_vo64_vm_advsimd_sleef(vopmask_advsimd_sleef x, vmask_advsimd_sleef y) { + return vorrq_u32(x, y); +} +static SLEEF_ALWAYS_INLINE vmask_advsimd_sleef vxor_vm_vo32_vm_advsimd_sleef(vopmask_advsimd_sleef x, vmask_advsimd_sleef y) { + return veorq_u32(x, y); +} + +static SLEEF_ALWAYS_INLINE vfloat_advsimd_sleef vtruncate_vf_vf_advsimd_sleef(vfloat_advsimd_sleef vd_advsimd_sleef) { return vrndq_f32(vd_advsimd_sleef); } + +static SLEEF_ALWAYS_INLINE vmask_advsimd_sleef vcast_vm_i_i_advsimd_sleef(int i0, int i1) { + return vreinterpretq_u32_u64(vdupq_n_u64((0xffffffff & (uint64_t)i1) | (((uint64_t)i0) << 32))); +} + +static SLEEF_ALWAYS_INLINE vmask_advsimd_sleef vcast_vm_i64_advsimd_sleef(int64_t i) { + return vreinterpretq_u32_u64(vdupq_n_u64((uint64_t)i)); +} +static SLEEF_ALWAYS_INLINE vmask_advsimd_sleef vcast_vm_u64_advsimd_sleef(uint64_t i) { + return vreinterpretq_u32_u64(vdupq_n_u64(i)); +} + +static SLEEF_ALWAYS_INLINE vopmask_advsimd_sleef veq64_vo_vm_vm_advsimd_sleef(vmask_advsimd_sleef x, vmask_advsimd_sleef y) { + return vreinterpretq_u32_u64(vceqq_s64(vreinterpretq_s64_u32(x), vreinterpretq_s64_u32(y))); +} + +static SLEEF_ALWAYS_INLINE vmask_advsimd_sleef vadd64_vm_vm_vm_advsimd_sleef(vmask_advsimd_sleef x, vmask_advsimd_sleef y) { + return vreinterpretq_u32_s64(vaddq_s64(vreinterpretq_s64_u32(x), vreinterpretq_s64_u32(y))); +} + +static SLEEF_ALWAYS_INLINE vint_advsimd_sleef vsel_vi_vo_vi_vi_advsimd_sleef(vopmask_advsimd_sleef m, vint_advsimd_sleef x, vint_advsimd_sleef y) { + return vbsl_s32(vget_low_u32(m), x, y); +} + +static SLEEF_ALWAYS_INLINE vint_advsimd_sleef vand_vi_vo_vi_advsimd_sleef(vopmask_advsimd_sleef x, vint_advsimd_sleef y) { + return vand_s32(vreinterpret_s32_u32(vget_low_u32(x)), y); +} + +static SLEEF_ALWAYS_INLINE vmask_advsimd_sleef vcastu_vm_vi_advsimd_sleef(vint_advsimd_sleef vi) { + return vrev64q_u32(vreinterpretq_u32_u64(vmovl_u32(vreinterpret_u32_s32(vi)))); +} +static SLEEF_ALWAYS_INLINE vint_advsimd_sleef vcastu_vi_vm_advsimd_sleef(vmask_advsimd_sleef vi2) { + return vreinterpret_s32_u32(vmovn_u64(vreinterpretq_u64_u32(vrev64q_u32(vi2)))); +} +static SLEEF_ALWAYS_INLINE vdouble_advsimd_sleef vtruncate_vd_vd_advsimd_sleef(vdouble_advsimd_sleef vd_advsimd_sleef) { return vrndq_f64(vd_advsimd_sleef); } + +static SLEEF_ALWAYS_INLINE vdouble_advsimd_sleef vposneg_vd_vd_advsimd_sleef(vdouble_advsimd_sleef d) { return vreinterpret_vd_vm_advsimd_sleef(vxor_vm_vm_vm_advsimd_sleef(vreinterpret_vm_vd_advsimd_sleef(d), vreinterpret_vm_vd_advsimd_sleef(((vdouble_advsimd_sleef) { +0.0, -0.0 })))); } +static SLEEF_ALWAYS_INLINE vdouble_advsimd_sleef vnegpos_vd_vd_advsimd_sleef(vdouble_advsimd_sleef d) { return vreinterpret_vd_vm_advsimd_sleef(vxor_vm_vm_vm_advsimd_sleef(vreinterpret_vm_vd_advsimd_sleef(d), vreinterpret_vm_vd_advsimd_sleef(((vdouble_advsimd_sleef) { -0.0, +0.0 })))); } +static SLEEF_ALWAYS_INLINE vfloat_advsimd_sleef vposneg_vf_vf_advsimd_sleef(vfloat_advsimd_sleef d) { return (vfloat_advsimd_sleef)vxor_vm_vm_vm_advsimd_sleef((vmask_advsimd_sleef)d, (vmask_advsimd_sleef)((vfloat_advsimd_sleef) { +0.0f, -0.0f, +0.0f, -0.0f })); } +static SLEEF_ALWAYS_INLINE vfloat_advsimd_sleef vnegpos_vf_vf_advsimd_sleef(vfloat_advsimd_sleef d) { return (vfloat_advsimd_sleef)vxor_vm_vm_vm_advsimd_sleef((vmask_advsimd_sleef)d, (vmask_advsimd_sleef)((vfloat_advsimd_sleef) { -0.0f, +0.0f, -0.0f, +0.0f })); } + +static SLEEF_ALWAYS_INLINE vdouble_advsimd_sleef vsubadd_vd_vd_vd_advsimd_sleef(vdouble_advsimd_sleef x, vdouble_advsimd_sleef y) { return vadd_vd_vd_vd_advsimd_sleef(x, vnegpos_vd_vd_advsimd_sleef(y)); } +static SLEEF_ALWAYS_INLINE vfloat_advsimd_sleef vsubadd_vf_vf_vf_advsimd_sleef(vfloat_advsimd_sleef d0, vfloat_advsimd_sleef d1) { return vadd_vf_vf_vf_advsimd_sleef(d0, vnegpos_vf_vf_advsimd_sleef(d1)); } +static SLEEF_ALWAYS_INLINE vdouble_advsimd_sleef vmlsubadd_vd_vd_vd_vd_advsimd_sleef(vdouble_advsimd_sleef x, vdouble_advsimd_sleef y, vdouble_advsimd_sleef z) { return vsubadd_vd_vd_vd_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(x, y), z); } +static SLEEF_ALWAYS_INLINE vfloat_advsimd_sleef vmlsubadd_vf_vf_vf_vf_advsimd_sleef(vfloat_advsimd_sleef x, vfloat_advsimd_sleef y, vfloat_advsimd_sleef z) { return vsubadd_vf_vf_vf_advsimd_sleef(vmul_vf_vf_vf_advsimd_sleef(x, y), z); } + +static SLEEF_ALWAYS_INLINE vdouble_advsimd_sleef vrev21_vd_vd_advsimd_sleef(vdouble_advsimd_sleef d0) { return (float64x2_t)vcombine_u64(vget_high_u64((uint64x2_t)d0), vget_low_u64((uint64x2_t)d0)); } +static SLEEF_ALWAYS_INLINE vdouble_advsimd_sleef vreva2_vd_vd_advsimd_sleef(vdouble_advsimd_sleef vd_advsimd_sleef) { return vd_advsimd_sleef; } + +static SLEEF_ALWAYS_INLINE void vstream_v_p_vd_advsimd_sleef(double *ptr, vdouble_advsimd_sleef v) { vstore_v_p_vd_advsimd_sleef(ptr, v); } +static SLEEF_ALWAYS_INLINE void vscatter2_v_p_i_i_vd_advsimd_sleef(double *ptr, int offset, int step, vdouble_advsimd_sleef v) { vstore_v_p_vd_advsimd_sleef((double *)(&ptr[2*offset]), v); } +static SLEEF_ALWAYS_INLINE void vsscatter2_v_p_i_i_vd_advsimd_sleef(double *ptr, int offset, int step, vdouble_advsimd_sleef v) { vstore_v_p_vd_advsimd_sleef((double *)(&ptr[2*offset]), v); } + +static SLEEF_ALWAYS_INLINE vfloat_advsimd_sleef vrev21_vf_vf_advsimd_sleef(vfloat_advsimd_sleef d0) { return vrev64q_f32(d0); } +static SLEEF_ALWAYS_INLINE vfloat_advsimd_sleef vreva2_vf_vf_advsimd_sleef(vfloat_advsimd_sleef d0) { return vcombine_f32(vget_high_f32(d0), vget_low_f32(d0)); } + +static SLEEF_ALWAYS_INLINE void vstream_v_p_vf_advsimd_sleef(float *ptr, vfloat_advsimd_sleef v) { vstore_v_p_vf_advsimd_sleef(ptr, v); } + +static SLEEF_ALWAYS_INLINE void vscatter2_v_p_i_i_vf_advsimd_sleef(float *ptr, int offset, int step, vfloat_advsimd_sleef v) { + vst1_f32((float *)(ptr+(offset + step * 0)*2), vget_low_f32(v)); + vst1_f32((float *)(ptr+(offset + step * 1)*2), vget_high_f32(v)); +} + +static SLEEF_ALWAYS_INLINE void vsscatter2_v_p_i_i_vf_advsimd_sleef(float *ptr, int offset, int step, vfloat_advsimd_sleef v) { + vst1_f32((float *)(ptr+(offset + step * 0)*2), vget_low_f32(v)); + vst1_f32((float *)(ptr+(offset + step * 1)*2), vget_high_f32(v)); +} + +static vquad_advsimd_sleef loadu_vq_p_advsimd_sleef(void *p) { + vquad_advsimd_sleef vq; + memcpy(&vq, p, (1 << 1) * 16); + return vq; +} + +static SLEEF_ALWAYS_INLINE vquad_advsimd_sleef cast_vq_aq_advsimd_sleef(vargquad_advsimd_sleef aq) { + vquad_advsimd_sleef vq; + memcpy(&vq, &aq, (1 << 1) * 16); + return vq; +} + +static SLEEF_ALWAYS_INLINE vargquad_advsimd_sleef cast_aq_vq_advsimd_sleef(vquad_advsimd_sleef vq) { + vargquad_advsimd_sleef aq; + memcpy(&aq, &vq, (1 << 1) * 16); + return aq; +} + +static SLEEF_ALWAYS_INLINE int vtestallzeros_i_vo64_advsimd_sleef(vopmask_advsimd_sleef g) { + uint32x2_t x0 = vorr_u32(vget_low_u32(g), vget_high_u32(g)); + uint32x2_t x1 = vpmax_u32(x0, x0); + return ~vget_lane_u32(x1, 0); +} + +static SLEEF_ALWAYS_INLINE vmask_advsimd_sleef vsel_vm_vo64_vm_vm_advsimd_sleef(vopmask_advsimd_sleef m, vmask_advsimd_sleef x, vmask_advsimd_sleef y) { return vbslq_u32(m, x, y); } + +static SLEEF_ALWAYS_INLINE vmask_advsimd_sleef vsub64_vm_vm_vm_advsimd_sleef(vmask_advsimd_sleef x, vmask_advsimd_sleef y) { + return vreinterpretq_u32_s64(vsubq_s64(vreinterpretq_s64_u32(x), vreinterpretq_s64_u32(y))); +} + +static SLEEF_ALWAYS_INLINE vmask_advsimd_sleef vneg64_vm_vm_advsimd_sleef(vmask_advsimd_sleef x) { + return vreinterpretq_u32_s64(vnegq_s64(vreinterpretq_s64_u32(x))); +} + +static SLEEF_ALWAYS_INLINE vopmask_advsimd_sleef vgt64_vo_vm_vm_advsimd_sleef(vmask_advsimd_sleef x, vmask_advsimd_sleef y) { + return vreinterpretq_u32_u64(vcgtq_s64(vreinterpretq_s64_u32(x), vreinterpretq_s64_u32(y))); +} + +static SLEEF_ALWAYS_INLINE vmask_advsimd_sleef vcast_vm_vi_advsimd_sleef(vint_advsimd_sleef vi) { + vmask_advsimd_sleef m = vreinterpretq_u32_u64(vmovl_u32(vreinterpret_u32_s32(vi))); + return vor_vm_vm_vm_advsimd_sleef(vcastu_vm_vi_advsimd_sleef(vreinterpret_s32_u32(vget_low_u32(vgt_vo_vi_vi_advsimd_sleef(vcast_vi_i_advsimd_sleef(0), vi)))), m); +} +static SLEEF_ALWAYS_INLINE vint_advsimd_sleef vcast_vi_vm_advsimd_sleef(vmask_advsimd_sleef vm) { return vreinterpret_s32_u32(vmovn_u64(vreinterpretq_u64_u32(vm))); } + +static SLEEF_ALWAYS_INLINE vmask_advsimd_sleef vreinterpret_vm_vi64_advsimd_sleef(vint64_advsimd_sleef v) { return vreinterpretq_u32_s64(v); } +static SLEEF_ALWAYS_INLINE vint64_advsimd_sleef vreinterpret_vi64_vm_advsimd_sleef(vmask_advsimd_sleef m) { return vreinterpretq_s64_u32(m); } +static SLEEF_ALWAYS_INLINE vmask_advsimd_sleef vreinterpret_vm_vu64_advsimd_sleef(vuint64_advsimd_sleef v) { return vreinterpretq_u32_u64(v); } +static SLEEF_ALWAYS_INLINE vuint64_advsimd_sleef vreinterpret_vu64_vm_advsimd_sleef(vmask_advsimd_sleef m) { return vreinterpretq_u64_u32(m); } + +typedef struct { + vdouble_advsimd_sleef x, y; +} vdouble2_advsimd_sleef; + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_advsimd_sleef vd2getx_vd_vd2_advsimd_sleef(vdouble2_advsimd_sleef v) { return v.x; } +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_advsimd_sleef vd2gety_vd_vd2_advsimd_sleef(vdouble2_advsimd_sleef v) { return v.y; } +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_advsimd_sleef vd2setxy_vd2_vd_vd_advsimd_sleef(vdouble_advsimd_sleef x, vdouble_advsimd_sleef y) { vdouble2_advsimd_sleef v; v.x = x; v.y = y; return v; } +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_advsimd_sleef vd2setx_vd2_vd2_vd_advsimd_sleef(vdouble2_advsimd_sleef v, vdouble_advsimd_sleef d) { v.x = d; return v; } +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_advsimd_sleef vd2sety_vd2_vd2_vd_advsimd_sleef(vdouble2_advsimd_sleef v, vdouble_advsimd_sleef d) { v.y = d; return v; } + +typedef struct { + double x, y; +} double2_advsimd_sleef; + +static SLEEF_ALWAYS_INLINE SLEEF_CONST double2_advsimd_sleef dd_advsimd_sleef(double h, double l) { + double2_advsimd_sleef ret = { h, l }; + return ret; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_advsimd_sleef vupper_vd_vd_advsimd_sleef(vdouble_advsimd_sleef d) { + return vreinterpret_vd_vm_advsimd_sleef(vand_vm_vm_vm_advsimd_sleef(vreinterpret_vm_vd_advsimd_sleef(d), vcast_vm_i_i_advsimd_sleef(0xffffffff, 0xf8000000))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_advsimd_sleef vcast_vd2_vd_vd_advsimd_sleef(vdouble_advsimd_sleef h, vdouble_advsimd_sleef l) { + return vd2setxy_vd2_vd_vd_advsimd_sleef(h, l); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_advsimd_sleef vcast_vd2_d_d_advsimd_sleef(double h, double l) { + return vd2setxy_vd2_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(h), vcast_vd_d_advsimd_sleef(l)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_advsimd_sleef vcast_vd2_d2_advsimd_sleef(double2_advsimd_sleef dd_advsimd_sleef) { + return vd2setxy_vd2_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(dd_advsimd_sleef.x), vcast_vd_d_advsimd_sleef(dd_advsimd_sleef.y)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_advsimd_sleef vsel_vd2_vo_vd2_vd2_advsimd_sleef(vopmask_advsimd_sleef m, vdouble2_advsimd_sleef x, vdouble2_advsimd_sleef y) { + return vd2setxy_vd2_vd_vd_advsimd_sleef(vsel_vd_vo_vd_vd_advsimd_sleef(m, vd2getx_vd_vd2_advsimd_sleef(x), vd2getx_vd_vd2_advsimd_sleef(y)), + vsel_vd_vo_vd_vd_advsimd_sleef(m, vd2gety_vd_vd2_advsimd_sleef(x), vd2gety_vd_vd2_advsimd_sleef(y))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_advsimd_sleef vsel_vd2_vo_d_d_d_d_advsimd_sleef(vopmask_advsimd_sleef o, double x1, double y1, double x0, double y0) { + return vd2setxy_vd2_vd_vd_advsimd_sleef(vsel_vd_vo_d_d_advsimd_sleef(o, x1, x0), + vsel_vd_vo_d_d_advsimd_sleef(o, y1, y0)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_advsimd_sleef vadd_vd_3vd_advsimd_sleef(vdouble_advsimd_sleef v0, vdouble_advsimd_sleef v1, vdouble_advsimd_sleef v2) { + return vadd_vd_vd_vd_advsimd_sleef(vadd_vd_vd_vd_advsimd_sleef(v0, v1), v2); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_advsimd_sleef vadd_vd_4vd_advsimd_sleef(vdouble_advsimd_sleef v0, vdouble_advsimd_sleef v1, vdouble_advsimd_sleef v2, vdouble_advsimd_sleef v3) { + return vadd_vd_3vd_advsimd_sleef(vadd_vd_vd_vd_advsimd_sleef(v0, v1), v2, v3); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_advsimd_sleef vadd_vd_5vd_advsimd_sleef(vdouble_advsimd_sleef v0, vdouble_advsimd_sleef v1, vdouble_advsimd_sleef v2, vdouble_advsimd_sleef v3, vdouble_advsimd_sleef v4) { + return vadd_vd_4vd_advsimd_sleef(vadd_vd_vd_vd_advsimd_sleef(v0, v1), v2, v3, v4); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_advsimd_sleef vadd_vd_6vd_advsimd_sleef(vdouble_advsimd_sleef v0, vdouble_advsimd_sleef v1, vdouble_advsimd_sleef v2, vdouble_advsimd_sleef v3, vdouble_advsimd_sleef v4, vdouble_advsimd_sleef v5) { + return vadd_vd_5vd_advsimd_sleef(vadd_vd_vd_vd_advsimd_sleef(v0, v1), v2, v3, v4, v5); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_advsimd_sleef vadd_vd_7vd_advsimd_sleef(vdouble_advsimd_sleef v0, vdouble_advsimd_sleef v1, vdouble_advsimd_sleef v2, vdouble_advsimd_sleef v3, vdouble_advsimd_sleef v4, vdouble_advsimd_sleef v5, vdouble_advsimd_sleef v6) { + return vadd_vd_6vd_advsimd_sleef(vadd_vd_vd_vd_advsimd_sleef(v0, v1), v2, v3, v4, v5, v6); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_advsimd_sleef vsub_vd_3vd_advsimd_sleef(vdouble_advsimd_sleef v0, vdouble_advsimd_sleef v1, vdouble_advsimd_sleef v2) { + return vsub_vd_vd_vd_advsimd_sleef(vsub_vd_vd_vd_advsimd_sleef(v0, v1), v2); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_advsimd_sleef vsub_vd_4vd_advsimd_sleef(vdouble_advsimd_sleef v0, vdouble_advsimd_sleef v1, vdouble_advsimd_sleef v2, vdouble_advsimd_sleef v3) { + return vsub_vd_3vd_advsimd_sleef(vsub_vd_vd_vd_advsimd_sleef(v0, v1), v2, v3); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_advsimd_sleef vsub_vd_5vd_advsimd_sleef(vdouble_advsimd_sleef v0, vdouble_advsimd_sleef v1, vdouble_advsimd_sleef v2, vdouble_advsimd_sleef v3, vdouble_advsimd_sleef v4) { + return vsub_vd_4vd_advsimd_sleef(vsub_vd_vd_vd_advsimd_sleef(v0, v1), v2, v3, v4); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_advsimd_sleef vsub_vd_6vd_advsimd_sleef(vdouble_advsimd_sleef v0, vdouble_advsimd_sleef v1, vdouble_advsimd_sleef v2, vdouble_advsimd_sleef v3, vdouble_advsimd_sleef v4, vdouble_advsimd_sleef v5) { + return vsub_vd_5vd_advsimd_sleef(vsub_vd_vd_vd_advsimd_sleef(v0, v1), v2, v3, v4, v5); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_advsimd_sleef ddneg_vd2_vd2_advsimd_sleef(vdouble2_advsimd_sleef x) { + return vcast_vd2_vd_vd_advsimd_sleef(vneg_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(x)), vneg_vd_vd_advsimd_sleef(vd2gety_vd_vd2_advsimd_sleef(x))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_advsimd_sleef ddabs_vd2_vd2_advsimd_sleef(vdouble2_advsimd_sleef x) { + return vcast_vd2_vd_vd_advsimd_sleef(vabs_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(x)), + vreinterpret_vd_vm_advsimd_sleef(vxor_vm_vm_vm_advsimd_sleef(vreinterpret_vm_vd_advsimd_sleef(vd2gety_vd_vd2_advsimd_sleef(x)), + vand_vm_vm_vm_advsimd_sleef(vreinterpret_vm_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(x)), + vreinterpret_vm_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(-0.0)))))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_advsimd_sleef ddnormalize_vd2_vd2_advsimd_sleef(vdouble2_advsimd_sleef t) { + vdouble_advsimd_sleef s = vadd_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(t), vd2gety_vd_vd2_advsimd_sleef(t)); + return vd2setxy_vd2_vd_vd_advsimd_sleef(s, vadd_vd_vd_vd_advsimd_sleef(vsub_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(t), s), vd2gety_vd_vd2_advsimd_sleef(t))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_advsimd_sleef ddscale_vd2_vd2_vd_advsimd_sleef(vdouble2_advsimd_sleef d, vdouble_advsimd_sleef s) { + return vd2setxy_vd2_vd_vd_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(d), s), vmul_vd_vd_vd_advsimd_sleef(vd2gety_vd_vd2_advsimd_sleef(d), s)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_advsimd_sleef ddscale_vd2_vd2_d_advsimd_sleef(vdouble2_advsimd_sleef d, double s) { return ddscale_vd2_vd2_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(s)); } + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_advsimd_sleef ddadd_vd2_vd_vd_advsimd_sleef(vdouble_advsimd_sleef x, vdouble_advsimd_sleef y) { + vdouble_advsimd_sleef s = vadd_vd_vd_vd_advsimd_sleef(x, y); + return vd2setxy_vd2_vd_vd_advsimd_sleef(s, vadd_vd_vd_vd_advsimd_sleef(vsub_vd_vd_vd_advsimd_sleef(x, s), y)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_advsimd_sleef ddadd2_vd2_vd_vd_advsimd_sleef(vdouble_advsimd_sleef x, vdouble_advsimd_sleef y) { + vdouble_advsimd_sleef s = vadd_vd_vd_vd_advsimd_sleef(x, y); + vdouble_advsimd_sleef v = vsub_vd_vd_vd_advsimd_sleef(s, x); + return vd2setxy_vd2_vd_vd_advsimd_sleef(s, vadd_vd_vd_vd_advsimd_sleef(vsub_vd_vd_vd_advsimd_sleef(x, vsub_vd_vd_vd_advsimd_sleef(s, v)), vsub_vd_vd_vd_advsimd_sleef(y, v))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_advsimd_sleef ddadd_vd2_vd2_vd_advsimd_sleef(vdouble2_advsimd_sleef x, vdouble_advsimd_sleef y) { + vdouble_advsimd_sleef s = vadd_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(x), y); + return vd2setxy_vd2_vd_vd_advsimd_sleef(s, vadd_vd_3vd_advsimd_sleef(vsub_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(x), s), y, vd2gety_vd_vd2_advsimd_sleef(x))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_advsimd_sleef ddsub_vd2_vd2_vd_advsimd_sleef(vdouble2_advsimd_sleef x, vdouble_advsimd_sleef y) { + vdouble_advsimd_sleef s = vsub_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(x), y); + return vd2setxy_vd2_vd_vd_advsimd_sleef(s, vadd_vd_vd_vd_advsimd_sleef(vsub_vd_vd_vd_advsimd_sleef(vsub_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(x), s), y), vd2gety_vd_vd2_advsimd_sleef(x))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_advsimd_sleef ddadd2_vd2_vd2_vd_advsimd_sleef(vdouble2_advsimd_sleef x, vdouble_advsimd_sleef y) { + vdouble_advsimd_sleef s = vadd_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(x), y); + vdouble_advsimd_sleef v = vsub_vd_vd_vd_advsimd_sleef(s, vd2getx_vd_vd2_advsimd_sleef(x)); + vdouble_advsimd_sleef w = vadd_vd_vd_vd_advsimd_sleef(vsub_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(x), vsub_vd_vd_vd_advsimd_sleef(s, v)), vsub_vd_vd_vd_advsimd_sleef(y, v)); + return vd2setxy_vd2_vd_vd_advsimd_sleef(s, vadd_vd_vd_vd_advsimd_sleef(w, vd2gety_vd_vd2_advsimd_sleef(x))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_advsimd_sleef ddadd_vd2_vd_vd2_advsimd_sleef(vdouble_advsimd_sleef x, vdouble2_advsimd_sleef y) { + vdouble_advsimd_sleef s = vadd_vd_vd_vd_advsimd_sleef(x, vd2getx_vd_vd2_advsimd_sleef(y)); + return vd2setxy_vd2_vd_vd_advsimd_sleef(s, vadd_vd_3vd_advsimd_sleef(vsub_vd_vd_vd_advsimd_sleef(x, s), vd2getx_vd_vd2_advsimd_sleef(y), vd2gety_vd_vd2_advsimd_sleef(y))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_advsimd_sleef ddadd2_vd2_vd_vd2_advsimd_sleef(vdouble_advsimd_sleef x, vdouble2_advsimd_sleef y) { + vdouble_advsimd_sleef s = vadd_vd_vd_vd_advsimd_sleef(x, vd2getx_vd_vd2_advsimd_sleef(y)); + vdouble_advsimd_sleef v = vsub_vd_vd_vd_advsimd_sleef(s, x); + return vd2setxy_vd2_vd_vd_advsimd_sleef(s, vadd_vd_vd_vd_advsimd_sleef(vadd_vd_vd_vd_advsimd_sleef(vsub_vd_vd_vd_advsimd_sleef(x, vsub_vd_vd_vd_advsimd_sleef(s, v)), + vsub_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(y), v)), vd2gety_vd_vd2_advsimd_sleef(y))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_advsimd_sleef ddadd_vd2_vd2_vd2_advsimd_sleef(vdouble2_advsimd_sleef x, vdouble2_advsimd_sleef y) { + + vdouble_advsimd_sleef s = vadd_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(x), vd2getx_vd_vd2_advsimd_sleef(y)); + return vd2setxy_vd2_vd_vd_advsimd_sleef(s, vadd_vd_4vd_advsimd_sleef(vsub_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(x), s), vd2getx_vd_vd2_advsimd_sleef(y), vd2gety_vd_vd2_advsimd_sleef(x), vd2gety_vd_vd2_advsimd_sleef(y))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_advsimd_sleef ddadd2_vd2_vd2_vd2_advsimd_sleef(vdouble2_advsimd_sleef x, vdouble2_advsimd_sleef y) { + vdouble_advsimd_sleef s = vadd_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(x), vd2getx_vd_vd2_advsimd_sleef(y)); + vdouble_advsimd_sleef v = vsub_vd_vd_vd_advsimd_sleef(s, vd2getx_vd_vd2_advsimd_sleef(x)); + vdouble_advsimd_sleef t = vadd_vd_vd_vd_advsimd_sleef(vsub_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(x), vsub_vd_vd_vd_advsimd_sleef(s, v)), vsub_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(y), v)); + return vd2setxy_vd2_vd_vd_advsimd_sleef(s, vadd_vd_vd_vd_advsimd_sleef(t, vadd_vd_vd_vd_advsimd_sleef(vd2gety_vd_vd2_advsimd_sleef(x), vd2gety_vd_vd2_advsimd_sleef(y)))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_advsimd_sleef ddsub_vd2_vd_vd_advsimd_sleef(vdouble_advsimd_sleef x, vdouble_advsimd_sleef y) { + + vdouble_advsimd_sleef s = vsub_vd_vd_vd_advsimd_sleef(x, y); + return vd2setxy_vd2_vd_vd_advsimd_sleef(s, vsub_vd_vd_vd_advsimd_sleef(vsub_vd_vd_vd_advsimd_sleef(x, s), y)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_advsimd_sleef ddsub_vd2_vd2_vd2_advsimd_sleef(vdouble2_advsimd_sleef x, vdouble2_advsimd_sleef y) { + + vdouble_advsimd_sleef s = vsub_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(x), vd2getx_vd_vd2_advsimd_sleef(y)); + vdouble_advsimd_sleef t = vsub_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(x), s); + t = vsub_vd_vd_vd_advsimd_sleef(t, vd2getx_vd_vd2_advsimd_sleef(y)); + t = vadd_vd_vd_vd_advsimd_sleef(t, vd2gety_vd_vd2_advsimd_sleef(x)); + return vd2setxy_vd2_vd_vd_advsimd_sleef(s, vsub_vd_vd_vd_advsimd_sleef(t, vd2gety_vd_vd2_advsimd_sleef(y))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_advsimd_sleef dddiv_vd2_vd2_vd2_advsimd_sleef(vdouble2_advsimd_sleef n, vdouble2_advsimd_sleef d) { + vdouble_advsimd_sleef t = vrec_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(d)); + vdouble_advsimd_sleef s = vmul_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(n), t); + vdouble_advsimd_sleef u = vfmapn_vd_vd_vd_vd_advsimd_sleef(t, vd2getx_vd_vd2_advsimd_sleef(n), s); + vdouble_advsimd_sleef v = vfmanp_vd_vd_vd_vd_advsimd_sleef(vd2gety_vd_vd2_advsimd_sleef(d), t, vfmanp_vd_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(d), t, vcast_vd_d_advsimd_sleef(1))); + return vd2setxy_vd2_vd_vd_advsimd_sleef(s, vfma_vd_vd_vd_vd_advsimd_sleef(s, v, vfma_vd_vd_vd_vd_advsimd_sleef(vd2gety_vd_vd2_advsimd_sleef(n), t, u))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_advsimd_sleef ddmul_vd2_vd_vd_advsimd_sleef(vdouble_advsimd_sleef x, vdouble_advsimd_sleef y) { + vdouble_advsimd_sleef s = vmul_vd_vd_vd_advsimd_sleef(x, y); + return vd2setxy_vd2_vd_vd_advsimd_sleef(s, vfmapn_vd_vd_vd_vd_advsimd_sleef(x, y, s)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_advsimd_sleef ddsqu_vd2_vd2_advsimd_sleef(vdouble2_advsimd_sleef x) { + vdouble_advsimd_sleef s = vmul_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(x), vd2getx_vd_vd2_advsimd_sleef(x)); + return vd2setxy_vd2_vd_vd_advsimd_sleef(s, vfma_vd_vd_vd_vd_advsimd_sleef(vadd_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(x), vd2getx_vd_vd2_advsimd_sleef(x)), vd2gety_vd_vd2_advsimd_sleef(x), vfmapn_vd_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(x), vd2getx_vd_vd2_advsimd_sleef(x), s))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_advsimd_sleef ddmul_vd2_vd2_vd2_advsimd_sleef(vdouble2_advsimd_sleef x, vdouble2_advsimd_sleef y) { + vdouble_advsimd_sleef s = vmul_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(x), vd2getx_vd_vd2_advsimd_sleef(y)); + return vd2setxy_vd2_vd_vd_advsimd_sleef(s, vfma_vd_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(x), vd2gety_vd_vd2_advsimd_sleef(y), vfma_vd_vd_vd_vd_advsimd_sleef(vd2gety_vd_vd2_advsimd_sleef(x), vd2getx_vd_vd2_advsimd_sleef(y), vfmapn_vd_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(x), vd2getx_vd_vd2_advsimd_sleef(y), s)))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_advsimd_sleef ddmul_vd_vd2_vd2_advsimd_sleef(vdouble2_advsimd_sleef x, vdouble2_advsimd_sleef y) { + return vfma_vd_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(x), vd2getx_vd_vd2_advsimd_sleef(y), vfma_vd_vd_vd_vd_advsimd_sleef(vd2gety_vd_vd2_advsimd_sleef(x), vd2getx_vd_vd2_advsimd_sleef(y), vmul_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(x), vd2gety_vd_vd2_advsimd_sleef(y)))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_advsimd_sleef ddsqu_vd_vd2_advsimd_sleef(vdouble2_advsimd_sleef x) { + return vfma_vd_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(x), vd2getx_vd_vd2_advsimd_sleef(x), vadd_vd_vd_vd_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(x), vd2gety_vd_vd2_advsimd_sleef(x)), vmul_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(x), vd2gety_vd_vd2_advsimd_sleef(x)))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_advsimd_sleef ddmul_vd2_vd2_vd_advsimd_sleef(vdouble2_advsimd_sleef x, vdouble_advsimd_sleef y) { + vdouble_advsimd_sleef s = vmul_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(x), y); + return vd2setxy_vd2_vd_vd_advsimd_sleef(s, vfma_vd_vd_vd_vd_advsimd_sleef(vd2gety_vd_vd2_advsimd_sleef(x), y, vfmapn_vd_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(x), y, s))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_advsimd_sleef ddrec_vd2_vd_advsimd_sleef(vdouble_advsimd_sleef d) { + vdouble_advsimd_sleef s = vrec_vd_vd_advsimd_sleef(d); + return vd2setxy_vd2_vd_vd_advsimd_sleef(s, vmul_vd_vd_vd_advsimd_sleef(s, vfmanp_vd_vd_vd_vd_advsimd_sleef(d, s, vcast_vd_d_advsimd_sleef(1)))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_advsimd_sleef ddrec_vd2_vd2_advsimd_sleef(vdouble2_advsimd_sleef d) { + vdouble_advsimd_sleef s = vrec_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(d)); + return vd2setxy_vd2_vd_vd_advsimd_sleef(s, vmul_vd_vd_vd_advsimd_sleef(s, vfmanp_vd_vd_vd_vd_advsimd_sleef(vd2gety_vd_vd2_advsimd_sleef(d), s, vfmanp_vd_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(d), s, vcast_vd_d_advsimd_sleef(1))))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_advsimd_sleef ddsqrt_vd2_vd2_advsimd_sleef(vdouble2_advsimd_sleef d) { + vdouble_advsimd_sleef t = vsqrt_vd_vd_advsimd_sleef(vadd_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(d), vd2gety_vd_vd2_advsimd_sleef(d))); + return ddscale_vd2_vd2_vd_advsimd_sleef(ddmul_vd2_vd2_vd2_advsimd_sleef(ddadd2_vd2_vd2_vd2_advsimd_sleef(d, ddmul_vd2_vd_vd_advsimd_sleef(t, t)), ddrec_vd2_vd_advsimd_sleef(t)), vcast_vd_d_advsimd_sleef(0.5)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_advsimd_sleef ddsqrt_vd2_vd_advsimd_sleef(vdouble_advsimd_sleef d) { + vdouble_advsimd_sleef t = vsqrt_vd_vd_advsimd_sleef(d); + return ddscale_vd2_vd2_vd_advsimd_sleef(ddmul_vd2_vd2_vd2_advsimd_sleef(ddadd2_vd2_vd_vd2_advsimd_sleef(d, ddmul_vd2_vd_vd_advsimd_sleef(t, t)), ddrec_vd2_vd_advsimd_sleef(t)), vcast_vd_d_advsimd_sleef(0.5)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_advsimd_sleef ddmla_vd2_vd2_vd2_vd2_advsimd_sleef(vdouble2_advsimd_sleef x, vdouble2_advsimd_sleef y, vdouble2_advsimd_sleef z) { + return ddadd_vd2_vd2_vd2_advsimd_sleef(z, ddmul_vd2_vd2_vd2_advsimd_sleef(x, y)); +} + +typedef struct { + vdouble_advsimd_sleef x, y, z; +} vdouble3_advsimd_sleef; + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_advsimd_sleef vd3getx_vd_vd3_advsimd_sleef(vdouble3_advsimd_sleef v) { return v.x; } +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_advsimd_sleef vd3gety_vd_vd3_advsimd_sleef(vdouble3_advsimd_sleef v) { return v.y; } +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_advsimd_sleef vd3getz_vd_vd3_advsimd_sleef(vdouble3_advsimd_sleef v) { return v.z; } +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble3_advsimd_sleef vd3setxyz_vd3_vd_vd_vd_advsimd_sleef(vdouble_advsimd_sleef x, vdouble_advsimd_sleef y, vdouble_advsimd_sleef z) { + vdouble3_advsimd_sleef v = { x, y, z }; + return v; +} +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble3_advsimd_sleef vd3setx_vd3_vd3_vd_advsimd_sleef(vdouble3_advsimd_sleef v, vdouble_advsimd_sleef d) { v.x = d; return v; } +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble3_advsimd_sleef vd3sety_vd3_vd3_vd_advsimd_sleef(vdouble3_advsimd_sleef v, vdouble_advsimd_sleef d) { v.y = d; return v; } +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble3_advsimd_sleef vd3setz_vd3_vd3_vd_advsimd_sleef(vdouble3_advsimd_sleef v, vdouble_advsimd_sleef d) { v.z = d; return v; } + +typedef struct { + vdouble2_advsimd_sleef a, b; +} dd2_advsimd_sleef; + +static dd2_advsimd_sleef dd2setab_dd2_vd2_vd2_advsimd_sleef(vdouble2_advsimd_sleef a, vdouble2_advsimd_sleef b) { + dd2_advsimd_sleef r = { a, b }; + return r; +} +static vdouble2_advsimd_sleef dd2geta_vd2_dd2_advsimd_sleef(dd2_advsimd_sleef d) { return d.a; } +static vdouble2_advsimd_sleef dd2getb_vd2_dd2_advsimd_sleef(dd2_advsimd_sleef d) { return d.b; } + +typedef struct { + vmask_advsimd_sleef e; + vdouble3_advsimd_sleef d3; +} tdx_advsimd_sleef; + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vmask_advsimd_sleef tdxgete_vm_tdx_advsimd_sleef(tdx_advsimd_sleef t) { return t.e; } +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble3_advsimd_sleef tdxgetd3_vd3_tdx_advsimd_sleef(tdx_advsimd_sleef t) { return t.d3; } +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_advsimd_sleef tdxgetd3x_vd_tdx_advsimd_sleef(tdx_advsimd_sleef t) { return t.d3.x; } +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_advsimd_sleef tdxgetd3y_vd_tdx_advsimd_sleef(tdx_advsimd_sleef t) { return t.d3.y; } +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_advsimd_sleef tdxgetd3z_vd_tdx_advsimd_sleef(tdx_advsimd_sleef t) { return t.d3.z; } +static SLEEF_ALWAYS_INLINE SLEEF_CONST tdx_advsimd_sleef tdxsete_tdx_tdx_vm_advsimd_sleef(tdx_advsimd_sleef t, vmask_advsimd_sleef e) { t.e = e; return t; } +static SLEEF_ALWAYS_INLINE SLEEF_CONST tdx_advsimd_sleef tdxsetd3_tdx_tdx_vd3_advsimd_sleef(tdx_advsimd_sleef t, vdouble3_advsimd_sleef d3) { t.d3 = d3; return t; } +static SLEEF_ALWAYS_INLINE SLEEF_CONST tdx_advsimd_sleef tdxsetx_tdx_tdx_vd_advsimd_sleef(tdx_advsimd_sleef t, vdouble_advsimd_sleef x) { t.d3.x = x; return t; } +static SLEEF_ALWAYS_INLINE SLEEF_CONST tdx_advsimd_sleef tdxsety_tdx_tdx_vd_advsimd_sleef(tdx_advsimd_sleef t, vdouble_advsimd_sleef y) { t.d3.y = y; return t; } +static SLEEF_ALWAYS_INLINE SLEEF_CONST tdx_advsimd_sleef tdxsetz_tdx_tdx_vd_advsimd_sleef(tdx_advsimd_sleef t, vdouble_advsimd_sleef z) { t.d3.z = z; return t; } +static SLEEF_ALWAYS_INLINE SLEEF_CONST tdx_advsimd_sleef tdxsetxyz_tdx_tdx_vd_vd_vd_advsimd_sleef(tdx_advsimd_sleef t, vdouble_advsimd_sleef x, vdouble_advsimd_sleef y, vdouble_advsimd_sleef z) { + t.d3 = (vdouble3_advsimd_sleef) { x, y, z }; + return t; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST tdx_advsimd_sleef tdxseted3_tdx_vm_vd3_advsimd_sleef(vmask_advsimd_sleef e, vdouble3_advsimd_sleef d3) { return (tdx_advsimd_sleef) { e, d3 }; } +static SLEEF_ALWAYS_INLINE SLEEF_CONST tdx_advsimd_sleef tdxsetexyz_tdx_vm_vd_vd_vd_advsimd_sleef(vmask_advsimd_sleef e, vdouble_advsimd_sleef x, vdouble_advsimd_sleef y, vdouble_advsimd_sleef z) { + return (tdx_advsimd_sleef) { e, (vdouble3_advsimd_sleef) { x, y, z } }; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vmask_advsimd_sleef vqgetx_vm_vq_advsimd_sleef(vquad_advsimd_sleef v) { return v.x; } +static SLEEF_ALWAYS_INLINE SLEEF_CONST vmask_advsimd_sleef vqgety_vm_vq_advsimd_sleef(vquad_advsimd_sleef v) { return v.y; } +static SLEEF_ALWAYS_INLINE SLEEF_CONST vquad_advsimd_sleef vqsetxy_vq_vm_vm_advsimd_sleef(vmask_advsimd_sleef x, vmask_advsimd_sleef y) { return (vquad_advsimd_sleef) { x, y }; } +static SLEEF_ALWAYS_INLINE SLEEF_CONST vquad_advsimd_sleef vqsetx_vq_vq_vm_advsimd_sleef(vquad_advsimd_sleef v, vmask_advsimd_sleef x) { v.x = x; return v; } +static SLEEF_ALWAYS_INLINE SLEEF_CONST vquad_advsimd_sleef vqsety_vq_vq_vm_advsimd_sleef(vquad_advsimd_sleef v, vmask_advsimd_sleef y) { v.y = y; return v; } + +typedef struct { + vdouble_advsimd_sleef d; + vint_advsimd_sleef i; +} di_t_advsimd_sleef; + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_advsimd_sleef digetd_vd_di_advsimd_sleef(di_t_advsimd_sleef d) { return d.d; } +static SLEEF_ALWAYS_INLINE SLEEF_CONST vint_advsimd_sleef digeti_vi_di_advsimd_sleef(di_t_advsimd_sleef d) { return d.i; } +static SLEEF_ALWAYS_INLINE SLEEF_CONST di_t_advsimd_sleef disetdi_di_vd_vi_advsimd_sleef(vdouble_advsimd_sleef d, vint_advsimd_sleef i) { + di_t_advsimd_sleef r = { d, i }; + return r; +} + +typedef struct { + vdouble2_advsimd_sleef dd_advsimd_sleef; + vint_advsimd_sleef i; +} ddi_t_advsimd_sleef; + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_advsimd_sleef ddigetdd_vd2_ddi_advsimd_sleef(ddi_t_advsimd_sleef d) { return d.dd_advsimd_sleef; } +static SLEEF_ALWAYS_INLINE SLEEF_CONST vint_advsimd_sleef ddigeti_vi_ddi_advsimd_sleef(ddi_t_advsimd_sleef d) { return d.i; } +static SLEEF_ALWAYS_INLINE SLEEF_CONST ddi_t_advsimd_sleef ddisetddi_ddi_vd2_vi_advsimd_sleef(vdouble2_advsimd_sleef v, vint_advsimd_sleef i) { + ddi_t_advsimd_sleef r = { v, i }; + return r; +} +static SLEEF_ALWAYS_INLINE SLEEF_CONST ddi_t_advsimd_sleef ddisetdd_ddi_ddi_vd2_advsimd_sleef(ddi_t_advsimd_sleef ddi_advsimd_sleef, vdouble2_advsimd_sleef v) { + ddi_advsimd_sleef.dd_advsimd_sleef = v; + return ddi_advsimd_sleef; +} + +typedef struct { + vdouble3_advsimd_sleef td_advsimd_sleef; + vint_advsimd_sleef i; +} tdi_t_advsimd_sleef; + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble3_advsimd_sleef tdigettd_vd3_tdi_advsimd_sleef(tdi_t_advsimd_sleef d) { return d.td_advsimd_sleef; } +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_advsimd_sleef tdigetx_vd_tdi_advsimd_sleef(tdi_t_advsimd_sleef d) { return d.td_advsimd_sleef.x; } +static SLEEF_ALWAYS_INLINE SLEEF_CONST vint_advsimd_sleef tdigeti_vi_tdi_advsimd_sleef(tdi_t_advsimd_sleef d) { return d.i; } +static SLEEF_ALWAYS_INLINE SLEEF_CONST tdi_t_advsimd_sleef tdisettdi_tdi_vd3_vi_advsimd_sleef(vdouble3_advsimd_sleef v, vint_advsimd_sleef i) { + tdi_t_advsimd_sleef r = { v, i }; + return r; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vopmask_advsimd_sleef visnegzero_vo_vd_advsimd_sleef(vdouble_advsimd_sleef d) { + return veq64_vo_vm_vm_advsimd_sleef(vreinterpret_vm_vd_advsimd_sleef(d), vreinterpret_vm_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(-0.0))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vopmask_advsimd_sleef visnumber_vo_vd_advsimd_sleef(vdouble_advsimd_sleef x) { + return vandnot_vo_vo_vo_advsimd_sleef(visinf_vo_vd_advsimd_sleef(x), veq_vo_vd_vd_advsimd_sleef(x, x)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vopmask_advsimd_sleef visnonfinite_vo_vd_advsimd_sleef(vdouble_advsimd_sleef x) { + return veq64_vo_vm_vm_advsimd_sleef(vand_vm_vm_vm_advsimd_sleef(vreinterpret_vm_vd_advsimd_sleef(x), vcast_vm_i64_advsimd_sleef(INT64_C(0x7ff0000000000000))), vcast_vm_i64_advsimd_sleef(INT64_C(0x7ff0000000000000))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vmask_advsimd_sleef vsignbit_vm_vd_advsimd_sleef(vdouble_advsimd_sleef d) { + return vand_vm_vm_vm_advsimd_sleef(vreinterpret_vm_vd_advsimd_sleef(d), vreinterpret_vm_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(-0.0))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vopmask_advsimd_sleef vsignbit_vo_vd_advsimd_sleef(vdouble_advsimd_sleef d) { + return veq64_vo_vm_vm_advsimd_sleef(vand_vm_vm_vm_advsimd_sleef(vreinterpret_vm_vd_advsimd_sleef(d), vreinterpret_vm_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(-0.0))), vreinterpret_vm_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(-0.0))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_advsimd_sleef vclearlsb_vd_vd_i_advsimd_sleef(vdouble_advsimd_sleef d, int n) { + return vreinterpret_vd_vm_advsimd_sleef(vand_vm_vm_vm_advsimd_sleef(vreinterpret_vm_vd_advsimd_sleef(d), vcast_vm_u64_advsimd_sleef((~UINT64_C(0)) << n))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_advsimd_sleef vtoward0_vd_vd_advsimd_sleef(vdouble_advsimd_sleef x) { + vdouble_advsimd_sleef t = vreinterpret_vd_vm_advsimd_sleef(vadd64_vm_vm_vm_advsimd_sleef(vreinterpret_vm_vd_advsimd_sleef(x), vcast_vm_i64_advsimd_sleef(-1))); + return vsel_vd_vo_vd_vd_advsimd_sleef(veq_vo_vd_vd_advsimd_sleef(x, vcast_vd_d_advsimd_sleef(0)), vcast_vd_d_advsimd_sleef(0), t); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_advsimd_sleef vmulsign_vd_vd_vd_advsimd_sleef(vdouble_advsimd_sleef x, vdouble_advsimd_sleef y) { + return vreinterpret_vd_vm_advsimd_sleef(vxor_vm_vm_vm_advsimd_sleef(vreinterpret_vm_vd_advsimd_sleef(x), vsignbit_vm_vd_advsimd_sleef(y))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_advsimd_sleef vsign_vd_vd_advsimd_sleef(vdouble_advsimd_sleef d) { + return vmulsign_vd_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(1.0), d); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_advsimd_sleef vorsign_vd_vd_vd_advsimd_sleef(vdouble_advsimd_sleef x, vdouble_advsimd_sleef y) { + return vreinterpret_vd_vm_advsimd_sleef(vor_vm_vm_vm_advsimd_sleef(vreinterpret_vm_vd_advsimd_sleef(x), vsignbit_vm_vd_advsimd_sleef(y))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_advsimd_sleef vcopysign_vd_vd_vd_advsimd_sleef(vdouble_advsimd_sleef x, vdouble_advsimd_sleef y) { + return vreinterpret_vd_vm_advsimd_sleef(vxor_vm_vm_vm_advsimd_sleef(vandnot_vm_vm_vm_advsimd_sleef(vreinterpret_vm_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(-0.0)), vreinterpret_vm_vd_advsimd_sleef(x)), + vand_vm_vm_vm_advsimd_sleef (vreinterpret_vm_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(-0.0)), vreinterpret_vm_vd_advsimd_sleef(y)))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_advsimd_sleef vtruncate2_vd_vd_advsimd_sleef_advsimd_sleef(vdouble_advsimd_sleef x) { + + return vtruncate_vd_vd_advsimd_sleef(x); + +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_advsimd_sleef vfloor2_vd_vd_advsimd_sleef(vdouble_advsimd_sleef x) { + vdouble_advsimd_sleef fr = vsub_vd_vd_vd_advsimd_sleef(x, vmul_vd_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(INT64_C(1) << 31), vcast_vd_vi_advsimd_sleef(vtruncate_vi_vd_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(x, vcast_vd_d_advsimd_sleef(1.0 / (INT64_C(1) << 31))))))); + fr = vsub_vd_vd_vd_advsimd_sleef(fr, vcast_vd_vi_advsimd_sleef(vtruncate_vi_vd_advsimd_sleef(fr))); + fr = vsel_vd_vo_vd_vd_advsimd_sleef(vlt_vo_vd_vd_advsimd_sleef(fr, vcast_vd_d_advsimd_sleef(0)), vadd_vd_vd_vd_advsimd_sleef(fr, vcast_vd_d_advsimd_sleef(1.0)), fr); + return vsel_vd_vo_vd_vd_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(visinf_vo_vd_advsimd_sleef(x), vge_vo_vd_vd_advsimd_sleef(vabs_vd_vd_advsimd_sleef(x), vcast_vd_d_advsimd_sleef(INT64_C(1) << 52))), x, vcopysign_vd_vd_vd_advsimd_sleef(vsub_vd_vd_vd_advsimd_sleef(x, fr), x)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_advsimd_sleef vceil2_vd_vd_advsimd_sleef(vdouble_advsimd_sleef x) { + vdouble_advsimd_sleef fr = vsub_vd_vd_vd_advsimd_sleef(x, vmul_vd_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(INT64_C(1) << 31), vcast_vd_vi_advsimd_sleef(vtruncate_vi_vd_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(x, vcast_vd_d_advsimd_sleef(1.0 / (INT64_C(1) << 31))))))); + fr = vsub_vd_vd_vd_advsimd_sleef(fr, vcast_vd_vi_advsimd_sleef(vtruncate_vi_vd_advsimd_sleef(fr))); + fr = vsel_vd_vo_vd_vd_advsimd_sleef(vle_vo_vd_vd_advsimd_sleef(fr, vcast_vd_d_advsimd_sleef(0)), fr, vsub_vd_vd_vd_advsimd_sleef(fr, vcast_vd_d_advsimd_sleef(1.0))); + return vsel_vd_vo_vd_vd_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(visinf_vo_vd_advsimd_sleef(x), vge_vo_vd_vd_advsimd_sleef(vabs_vd_vd_advsimd_sleef(x), vcast_vd_d_advsimd_sleef(INT64_C(1) << 52))), x, vcopysign_vd_vd_vd_advsimd_sleef(vsub_vd_vd_vd_advsimd_sleef(x, fr), x)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_advsimd_sleef vround2_vd_vd_advsimd_sleef(vdouble_advsimd_sleef d) { + vdouble_advsimd_sleef x = vadd_vd_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(0.5)); + vdouble_advsimd_sleef fr = vsub_vd_vd_vd_advsimd_sleef(x, vmul_vd_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(INT64_C(1) << 31), vcast_vd_vi_advsimd_sleef(vtruncate_vi_vd_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(x, vcast_vd_d_advsimd_sleef(1.0 / (INT64_C(1) << 31))))))); + fr = vsub_vd_vd_vd_advsimd_sleef(fr, vcast_vd_vi_advsimd_sleef(vtruncate_vi_vd_advsimd_sleef(fr))); + x = vsel_vd_vo_vd_vd_advsimd_sleef(vand_vo_vo_vo_advsimd_sleef(vle_vo_vd_vd_advsimd_sleef(x, vcast_vd_d_advsimd_sleef(0)), veq_vo_vd_vd_advsimd_sleef(fr, vcast_vd_d_advsimd_sleef(0))), vsub_vd_vd_vd_advsimd_sleef(x, vcast_vd_d_advsimd_sleef(1.0)), x); + fr = vsel_vd_vo_vd_vd_advsimd_sleef(vlt_vo_vd_vd_advsimd_sleef(fr, vcast_vd_d_advsimd_sleef(0)), vadd_vd_vd_vd_advsimd_sleef(fr, vcast_vd_d_advsimd_sleef(1.0)), fr); + x = vsel_vd_vo_vd_vd_advsimd_sleef(veq_vo_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(0.49999999999999994449)), vcast_vd_d_advsimd_sleef(0), x); + return vsel_vd_vo_vd_vd_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(visinf_vo_vd_advsimd_sleef(d), vge_vo_vd_vd_advsimd_sleef(vabs_vd_vd_advsimd_sleef(d), vcast_vd_d_advsimd_sleef(INT64_C(1) << 52))), d, vcopysign_vd_vd_vd_advsimd_sleef(vsub_vd_vd_vd_advsimd_sleef(x, fr), d)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_advsimd_sleef vrint2_vd_vd_advsimd_sleef(vdouble_advsimd_sleef d) { + + return vrint_vd_vd_advsimd_sleef(d); + +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vopmask_advsimd_sleef visint_vo_vd_advsimd_sleef(vdouble_advsimd_sleef d) { + return veq_vo_vd_vd_advsimd_sleef(vrint2_vd_vd_advsimd_sleef(d), d); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vopmask_advsimd_sleef visodd_vo_vd_advsimd_sleef(vdouble_advsimd_sleef d) { + vdouble_advsimd_sleef x = vmul_vd_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(0.5)); + return vneq_vo_vd_vd_advsimd_sleef(vrint2_vd_vd_advsimd_sleef(x), x); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vint_advsimd_sleef vilogbk_vi_vd_advsimd_sleef(vdouble_advsimd_sleef d) { + vopmask_advsimd_sleef o = vlt_vo_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(4.9090934652977266E-91)); + d = vsel_vd_vo_vd_vd_advsimd_sleef(o, vmul_vd_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(2.037035976334486E90), d), d); + vint_advsimd_sleef q = vcastu_vi_vm_advsimd_sleef(vreinterpret_vm_vd_advsimd_sleef(d)); + q = vand_vi_vi_vi_advsimd_sleef(q, vcast_vi_i_advsimd_sleef((int)(((1U << 12) - 1) << 20))); + q = vreinterpret_s32_u32(vshr_n_u32(vreinterpret_u32_s32(q), 20)); + q = vsub_vi_vi_vi_advsimd_sleef(q, vsel_vi_vo_vi_vi_advsimd_sleef(vcast_vo32_vo64_advsimd_sleef(o), vcast_vi_i_advsimd_sleef(300 + 0x3ff), vcast_vi_i_advsimd_sleef(0x3ff))); + return q; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vint_advsimd_sleef vilogb2k_vi_vd_advsimd_sleef(vdouble_advsimd_sleef d) { + vint_advsimd_sleef q = vcastu_vi_vm_advsimd_sleef(vreinterpret_vm_vd_advsimd_sleef(d)); + q = vreinterpret_s32_u32(vshr_n_u32(vreinterpret_u32_s32(q), 20)); + q = vand_vi_vi_vi_advsimd_sleef(q, vcast_vi_i_advsimd_sleef(0x7ff)); + q = vsub_vi_vi_vi_advsimd_sleef(q, vcast_vi_i_advsimd_sleef(0x3ff)); + return q; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vmask_advsimd_sleef vilogb2k_vm_vd_advsimd_sleef(vdouble_advsimd_sleef d) { + vmask_advsimd_sleef m = vreinterpret_vm_vd_advsimd_sleef(d); + m = vreinterpretq_u32_u64(vshrq_n_u64(vreinterpretq_u64_u32(m), 20 + 32)); + m = vand_vm_vm_vm_advsimd_sleef(m, vcast_vm_i64_advsimd_sleef(0x7ff)); + m = vsub64_vm_vm_vm_advsimd_sleef(m, vcast_vm_i64_advsimd_sleef(0x3ff)); + return m; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vmask_advsimd_sleef vilogb3k_vm_vd_advsimd_sleef(vdouble_advsimd_sleef d) { + vmask_advsimd_sleef m = vreinterpret_vm_vd_advsimd_sleef(d); + m = vreinterpretq_u32_u64(vshrq_n_u64(vreinterpretq_u64_u32(m), 20 + 32)); + m = vand_vm_vm_vm_advsimd_sleef(m, vcast_vm_i64_advsimd_sleef(0x7ff)); + return m; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_advsimd_sleef vpow2i_vd_vi_advsimd_sleef(vint_advsimd_sleef q) { + q = vadd_vi_vi_vi_advsimd_sleef(vcast_vi_i_advsimd_sleef(0x3ff), q); + vmask_advsimd_sleef r = vcastu_vm_vi_advsimd_sleef(vshl_n_s32(q, 20)); + return vreinterpret_vd_vm_advsimd_sleef(r); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_advsimd_sleef vpow2i_vd_vm_advsimd_sleef(vmask_advsimd_sleef q) { + q = vadd64_vm_vm_vm_advsimd_sleef(vcast_vm_i64_advsimd_sleef(0x3ff), q); + return vreinterpret_vd_vm_advsimd_sleef(vreinterpretq_u32_u64(vshlq_n_u64(vreinterpretq_u64_u32(q), 52))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_advsimd_sleef vldexp_vd_vd_vi_advsimd_sleef(vdouble_advsimd_sleef x, vint_advsimd_sleef q) { + vint_advsimd_sleef m = vshr_n_s32(q, 31); + m = vshl_n_s32(vsub_vi_vi_vi_advsimd_sleef(vshr_n_s32(vadd_vi_vi_vi_advsimd_sleef(m, q), 9), m), 7); + q = vsub_vi_vi_vi_advsimd_sleef(q, vshl_n_s32(m, 2)); + m = vadd_vi_vi_vi_advsimd_sleef(vcast_vi_i_advsimd_sleef(0x3ff), m); + m = vandnot_vi_vo_vi_advsimd_sleef(vgt_vo_vi_vi_advsimd_sleef(vcast_vi_i_advsimd_sleef(0), m), m); + m = vsel_vi_vo_vi_vi_advsimd_sleef(vgt_vo_vi_vi_advsimd_sleef(m, vcast_vi_i_advsimd_sleef(0x7ff)), vcast_vi_i_advsimd_sleef(0x7ff), m); + vmask_advsimd_sleef r = vcastu_vm_vi_advsimd_sleef(vshl_n_s32(m, 20)); + vdouble_advsimd_sleef y = vreinterpret_vd_vm_advsimd_sleef(r); + return vmul_vd_vd_vd_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(x, y), y), y), y), vpow2i_vd_vi_advsimd_sleef(q)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_advsimd_sleef vldexp2_vd_vd_vi_advsimd_sleef(vdouble_advsimd_sleef d, vint_advsimd_sleef e) { + return vmul_vd_vd_vd_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(d, vpow2i_vd_vi_advsimd_sleef(vshr_n_s32(e, 1))), vpow2i_vd_vi_advsimd_sleef(vsub_vi_vi_vi_advsimd_sleef(e, vshr_n_s32(e, 1)))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_advsimd_sleef vldexp3_vd_vd_vi_advsimd_sleef(vdouble_advsimd_sleef d, vint_advsimd_sleef q) { + return vreinterpret_vd_vm_advsimd_sleef(vadd64_vm_vm_vm_advsimd_sleef(vreinterpret_vm_vd_advsimd_sleef(d), vcastu_vm_vi_advsimd_sleef(vshl_n_s32(q, 20)))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_advsimd_sleef vldexp1_vd_vd_vm_advsimd_sleef(vdouble_advsimd_sleef d, vmask_advsimd_sleef e) { + vmask_advsimd_sleef m = vreinterpretq_u32_u64(vshrq_n_u64(vreinterpretq_u64_u32(e), 2)); + e = vsub64_vm_vm_vm_advsimd_sleef(vsub64_vm_vm_vm_advsimd_sleef(vsub64_vm_vm_vm_advsimd_sleef(e, m), m), m); + d = vmul_vd_vd_vd_advsimd_sleef(d, vpow2i_vd_vm_advsimd_sleef(m)); + d = vmul_vd_vd_vd_advsimd_sleef(d, vpow2i_vd_vm_advsimd_sleef(m)); + d = vmul_vd_vd_vd_advsimd_sleef(d, vpow2i_vd_vm_advsimd_sleef(m)); + d = vmul_vd_vd_vd_advsimd_sleef(d, vpow2i_vd_vm_advsimd_sleef(e)); + return d; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_advsimd_sleef vldexp2_vd_vd_vm_advsimd_sleef(vdouble_advsimd_sleef d, vmask_advsimd_sleef e) { + return vmul_vd_vd_vd_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(d, vpow2i_vd_vm_advsimd_sleef(vreinterpretq_u32_u64(vshrq_n_u64(vreinterpretq_u64_u32(e), 1)))), vpow2i_vd_vm_advsimd_sleef(vsub64_vm_vm_vm_advsimd_sleef(e, vreinterpretq_u32_u64(vshrq_n_u64(vreinterpretq_u64_u32(e), 1))))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_advsimd_sleef vldexp3_vd_vd_vm_advsimd_sleef(vdouble_advsimd_sleef d, vmask_advsimd_sleef q) { + return vreinterpret_vd_vm_advsimd_sleef(vadd64_vm_vm_vm_advsimd_sleef(vreinterpret_vm_vd_advsimd_sleef(d), vreinterpretq_u32_u64(vshlq_n_u64(vreinterpretq_u64_u32(q), 52)))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_advsimd_sleef vcast_vd_vm_advsimd_sleef(vmask_advsimd_sleef m) { return vcast_vd_vi_advsimd_sleef(vcast_vi_vm_advsimd_sleef(m)); } +static SLEEF_ALWAYS_INLINE SLEEF_CONST vmask_advsimd_sleef vtruncate_vm_vd_advsimd_sleef(vdouble_advsimd_sleef d) { return vcast_vm_vi_advsimd_sleef(vtruncate_vi_vd_advsimd_sleef(d)); } + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vopmask_advsimd_sleef vlt64_vo_vm_vm_advsimd_sleef(vmask_advsimd_sleef x, vmask_advsimd_sleef y) { return vgt64_vo_vm_vm_advsimd_sleef(y, x); } + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vopmask_advsimd_sleef vnot_vo64_vo64_advsimd_sleef(vopmask_advsimd_sleef x) { + return vxor_vo_vo_vo_advsimd_sleef(x, veq64_vo_vm_vm_advsimd_sleef(vcast_vm_i64_advsimd_sleef(0), vcast_vm_i64_advsimd_sleef(0))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vopmask_advsimd_sleef vugt64_vo_vm_vm_advsimd_sleef(vmask_advsimd_sleef x, vmask_advsimd_sleef y) { + x = vxor_vm_vm_vm_advsimd_sleef(vcast_vm_u64_advsimd_sleef(UINT64_C(0x8000000000000000)), x); + y = vxor_vm_vm_vm_advsimd_sleef(vcast_vm_u64_advsimd_sleef(UINT64_C(0x8000000000000000)), y); + return vgt64_vo_vm_vm_advsimd_sleef(x, y); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vmask_advsimd_sleef vilogbk_vm_vd_advsimd_sleef(vdouble_advsimd_sleef d) { + vopmask_advsimd_sleef o = vlt_vo_vd_vd_advsimd_sleef(vabs_vd_vd_advsimd_sleef(d), vcast_vd_d_advsimd_sleef(4.9090934652977266E-91)); + d = vsel_vd_vo_vd_vd_advsimd_sleef(o, vmul_vd_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(2.037035976334486E90), d), d); + vmask_advsimd_sleef q = vreinterpret_vm_vd_advsimd_sleef(d); + q = vreinterpretq_u32_u64(vshrq_n_u64(vreinterpretq_u64_u32(q), 20 + 32)); + q = vand_vm_vm_vm_advsimd_sleef(q, vcast_vm_i64_advsimd_sleef(0x7ff)); + q = vsub64_vm_vm_vm_advsimd_sleef(q, vsel_vm_vo64_vm_vm_advsimd_sleef(o, vcast_vm_i64_advsimd_sleef(300 + 0x3ff), vcast_vm_i64_advsimd_sleef(0x3ff))); + return q; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vquad_advsimd_sleef sel_vq_vo_vq_vq_advsimd_sleef(vopmask_advsimd_sleef o, vquad_advsimd_sleef x, vquad_advsimd_sleef y) { + return vqsetxy_vq_vm_vm_advsimd_sleef(vsel_vm_vo64_vm_vm_advsimd_sleef(o, vqgetx_vm_vq_advsimd_sleef(x), vqgetx_vm_vq_advsimd_sleef(y)), vsel_vm_vo64_vm_vm_advsimd_sleef(o, vqgety_vm_vq_advsimd_sleef(x), vqgety_vm_vq_advsimd_sleef(y))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vquad_advsimd_sleef add128_vq_vq_vq_advsimd_sleef(vquad_advsimd_sleef x, vquad_advsimd_sleef y) { + vquad_advsimd_sleef r = vqsetxy_vq_vm_vm_advsimd_sleef(vadd64_vm_vm_vm_advsimd_sleef(vqgetx_vm_vq_advsimd_sleef(x), vqgetx_vm_vq_advsimd_sleef(y)), vadd64_vm_vm_vm_advsimd_sleef(vqgety_vm_vq_advsimd_sleef(x), vqgety_vm_vq_advsimd_sleef(y))); + r = vqsety_vq_vq_vm_advsimd_sleef(r, vadd64_vm_vm_vm_advsimd_sleef(vqgety_vm_vq_advsimd_sleef(r), vand_vm_vo64_vm_advsimd_sleef(vugt64_vo_vm_vm_advsimd_sleef(vqgetx_vm_vq_advsimd_sleef(x), vqgetx_vm_vq_advsimd_sleef(r)), vcast_vm_i64_advsimd_sleef(1)))); + return r; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vquad_advsimd_sleef imdvq_vq_vm_vm_advsimd_sleef(vmask_advsimd_sleef x, vmask_advsimd_sleef y) { vquad_advsimd_sleef r = vqsetxy_vq_vm_vm_advsimd_sleef(x, y); return r; } + +static SLEEF_ALWAYS_INLINE SLEEF_CONST di_t_advsimd_sleef rempisub_advsimd_sleef(vdouble_advsimd_sleef x) { + + vdouble_advsimd_sleef y = vrint_vd_vd_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(x, vcast_vd_d_advsimd_sleef(4))); + vint_advsimd_sleef vi = vtruncate_vi_vd_advsimd_sleef(vsub_vd_vd_vd_advsimd_sleef(y, vmul_vd_vd_vd_advsimd_sleef(vrint_vd_vd_advsimd_sleef(x), vcast_vd_d_advsimd_sleef(4)))); + return disetdi_di_vd_vi_advsimd_sleef(vsub_vd_vd_vd_advsimd_sleef(x, vmul_vd_vd_vd_advsimd_sleef(y, vcast_vd_d_advsimd_sleef(0.25))), vi); + +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vint_advsimd_sleef vsel_vi_vd_vd_vi_vi_advsimd_sleef(vdouble_advsimd_sleef d0, vdouble_advsimd_sleef d1, vint_advsimd_sleef x, vint_advsimd_sleef y) { return vsel_vi_vo_vi_vi_advsimd_sleef(vcast_vo32_vo64_advsimd_sleef(vlt_vo_vd_vd_advsimd_sleef(d0, d1)), x, y); } + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vint_advsimd_sleef vsel_vi_vd_vi_advsimd_sleef(vdouble_advsimd_sleef d, vint_advsimd_sleef x) { return vand_vi_vo_vi_advsimd_sleef(vcast_vo32_vo64_advsimd_sleef(vsignbit_vo_vd_advsimd_sleef(d)), x); } + +SLEEF_INLINE SLEEF_CONST vdouble_advsimd_sleef Sleef_ldexpd2_advsimd(vdouble_advsimd_sleef x, vint_advsimd_sleef q) { return vldexp_vd_vd_vi_advsimd_sleef(x, q); } + +SLEEF_INLINE SLEEF_CONST vint_advsimd_sleef Sleef_ilogbd2_advsimd(vdouble_advsimd_sleef d) { + vdouble_advsimd_sleef e = vcast_vd_vi_advsimd_sleef(vilogbk_vi_vd_advsimd_sleef(vabs_vd_vd_advsimd_sleef(d))); + e = vsel_vd_vo_vd_vd_advsimd_sleef(veq_vo_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(0)), vcast_vd_d_advsimd_sleef(SLEEF_FP_ILOGB0), e); + e = vsel_vd_vo_vd_vd_advsimd_sleef(visnan_vo_vd_advsimd_sleef(d), vcast_vd_d_advsimd_sleef(SLEEF_FP_ILOGBNAN), e); + e = vsel_vd_vo_vd_vd_advsimd_sleef(visinf_vo_vd_advsimd_sleef(d), vcast_vd_d_advsimd_sleef(2147483647), e); + return vrint_vi_vd_advsimd_sleef(e); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST ddi_t_advsimd_sleef rempi_advsimd_sleef(vdouble_advsimd_sleef a) { + vdouble2_advsimd_sleef x, y; + vint_advsimd_sleef ex = vilogb2k_vi_vd_advsimd_sleef(a); + + ex = vsub_vi_vi_vi_advsimd_sleef(ex, vcast_vi_i_advsimd_sleef(55)); + vint_advsimd_sleef q = vand_vi_vo_vi_advsimd_sleef(vgt_vo_vi_vi_advsimd_sleef(ex, vcast_vi_i_advsimd_sleef(700-55)), vcast_vi_i_advsimd_sleef(-64)); + a = vldexp3_vd_vd_vi_advsimd_sleef(a, q); + ex = vandnot_vi_vi_vi_advsimd_sleef(vshr_n_s32(ex, 31), ex); + ex = vshl_n_s32(ex, 2); + x = ddmul_vd2_vd_vd_advsimd_sleef(a, vgather_vd_p_vi_advsimd_sleef(Sleef_rempitabdp, ex)); + di_t_advsimd_sleef di = rempisub_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(x)); + q = digeti_vi_di_advsimd_sleef(di); + x = vd2setx_vd2_vd2_vd_advsimd_sleef(x, digetd_vd_di_advsimd_sleef(di)); + x = ddnormalize_vd2_vd2_advsimd_sleef(x); + y = ddmul_vd2_vd_vd_advsimd_sleef(a, vgather_vd_p_vi_advsimd_sleef(Sleef_rempitabdp+1, ex)); + x = ddadd2_vd2_vd2_vd2_advsimd_sleef(x, y); + di = rempisub_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(x)); + q = vadd_vi_vi_vi_advsimd_sleef(q, digeti_vi_di_advsimd_sleef(di)); + x = vd2setx_vd2_vd2_vd_advsimd_sleef(x, digetd_vd_di_advsimd_sleef(di)); + x = ddnormalize_vd2_vd2_advsimd_sleef(x); + y = vcast_vd2_vd_vd_advsimd_sleef(vgather_vd_p_vi_advsimd_sleef(Sleef_rempitabdp+2, ex), vgather_vd_p_vi_advsimd_sleef(Sleef_rempitabdp+3, ex)); + y = ddmul_vd2_vd2_vd_advsimd_sleef(y, a); + x = ddadd2_vd2_vd2_vd2_advsimd_sleef(x, y); + x = ddnormalize_vd2_vd2_advsimd_sleef(x); + x = ddmul_vd2_vd2_vd2_advsimd_sleef(x, vcast_vd2_d_d_advsimd_sleef(3.141592653589793116*2, 1.2246467991473532072e-16*2)); + vopmask_advsimd_sleef o = vlt_vo_vd_vd_advsimd_sleef(vabs_vd_vd_advsimd_sleef(a), vcast_vd_d_advsimd_sleef(0.7)); + x = vd2setx_vd2_vd2_vd_advsimd_sleef(x, vsel_vd_vo_vd_vd_advsimd_sleef(o, a, vd2getx_vd_vd2_advsimd_sleef(x))); + x = vd2sety_vd2_vd2_vd_advsimd_sleef(x, vreinterpret_vd_vm_advsimd_sleef(vandnot_vm_vo64_vm_advsimd_sleef(o, vreinterpret_vm_vd_advsimd_sleef(vd2gety_vd_vd2_advsimd_sleef(x))))); + return ddisetddi_ddi_vd2_vi_advsimd_sleef(x, q); +} + +SLEEF_INLINE SLEEF_CONST vdouble_advsimd_sleef Sleef_sind2_u35advsimd(vdouble_advsimd_sleef d) { + + vdouble_advsimd_sleef u, s, r = d; + vint_advsimd_sleef ql; + + if (__builtin_expect(!!(vtestallones_i_vo64_advsimd_sleef(vlt_vo_vd_vd_advsimd_sleef(vabs_vd_vd_advsimd_sleef(d), vcast_vd_d_advsimd_sleef(15)))), 1)) { + vdouble_advsimd_sleef dql = vrint_vd_vd_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(0.318309886183790671537767526745028724))); + ql = vrint_vi_vd_advsimd_sleef(dql); + d = vmla_vd_vd_vd_vd_advsimd_sleef(dql, vcast_vd_d_advsimd_sleef(-3.141592653589793116), d); + d = vmla_vd_vd_vd_vd_advsimd_sleef(dql, vcast_vd_d_advsimd_sleef(-1.2246467991473532072e-16), d); + } else if (__builtin_expect(!!(vtestallones_i_vo64_advsimd_sleef(vlt_vo_vd_vd_advsimd_sleef(vabs_vd_vd_advsimd_sleef(d), vcast_vd_d_advsimd_sleef(1e+14)))), 1)) { + vdouble_advsimd_sleef dqh = vtruncate_vd_vd_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(0.318309886183790671537767526745028724 / (1 << 24)))); + dqh = vmul_vd_vd_vd_advsimd_sleef(dqh, vcast_vd_d_advsimd_sleef(1 << 24)); + vdouble_advsimd_sleef dql = vrint_vd_vd_advsimd_sleef(vmlapn_vd_vd_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(0.318309886183790671537767526745028724), dqh)); + ql = vrint_vi_vd_advsimd_sleef(dql); + + d = vmla_vd_vd_vd_vd_advsimd_sleef(dqh, vcast_vd_d_advsimd_sleef(-3.1415926218032836914), d); + d = vmla_vd_vd_vd_vd_advsimd_sleef(dql, vcast_vd_d_advsimd_sleef(-3.1415926218032836914), d); + d = vmla_vd_vd_vd_vd_advsimd_sleef(dqh, vcast_vd_d_advsimd_sleef(-3.1786509424591713469e-08), d); + d = vmla_vd_vd_vd_vd_advsimd_sleef(dql, vcast_vd_d_advsimd_sleef(-3.1786509424591713469e-08), d); + d = vmla_vd_vd_vd_vd_advsimd_sleef(dqh, vcast_vd_d_advsimd_sleef(-1.2246467864107188502e-16), d); + d = vmla_vd_vd_vd_vd_advsimd_sleef(dql, vcast_vd_d_advsimd_sleef(-1.2246467864107188502e-16), d); + d = vmla_vd_vd_vd_vd_advsimd_sleef(vadd_vd_vd_vd_advsimd_sleef(dqh, dql), vcast_vd_d_advsimd_sleef(-1.2736634327021899816e-24), d); + } else { + ddi_t_advsimd_sleef ddi_advsimd_sleef = rempi_advsimd_sleef(d); + ql = vand_vi_vi_vi_advsimd_sleef(ddigeti_vi_ddi_advsimd_sleef(ddi_advsimd_sleef), vcast_vi_i_advsimd_sleef(3)); + ql = vadd_vi_vi_vi_advsimd_sleef(vadd_vi_vi_vi_advsimd_sleef(ql, ql), vsel_vi_vo_vi_vi_advsimd_sleef(vcast_vo32_vo64_advsimd_sleef(vgt_vo_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(ddigetdd_vd2_ddi_advsimd_sleef(ddi_advsimd_sleef)), vcast_vd_d_advsimd_sleef(0))), vcast_vi_i_advsimd_sleef(2), vcast_vi_i_advsimd_sleef(1))); + ql = vshr_n_s32(ql, 2); + vopmask_advsimd_sleef o = veq_vo_vi_vi_advsimd_sleef(vand_vi_vi_vi_advsimd_sleef(ddigeti_vi_ddi_advsimd_sleef(ddi_advsimd_sleef), vcast_vi_i_advsimd_sleef(1)), vcast_vi_i_advsimd_sleef(1)); + vdouble2_advsimd_sleef x = vcast_vd2_vd_vd_advsimd_sleef(vmulsign_vd_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(-3.141592653589793116 * 0.5), vd2getx_vd_vd2_advsimd_sleef(ddigetdd_vd2_ddi_advsimd_sleef(ddi_advsimd_sleef))), + vmulsign_vd_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(-1.2246467991473532072e-16 * 0.5), vd2getx_vd_vd2_advsimd_sleef(ddigetdd_vd2_ddi_advsimd_sleef(ddi_advsimd_sleef)))); + x = ddadd2_vd2_vd2_vd2_advsimd_sleef(ddigetdd_vd2_ddi_advsimd_sleef(ddi_advsimd_sleef), x); + ddi_advsimd_sleef = ddisetdd_ddi_ddi_vd2_advsimd_sleef(ddi_advsimd_sleef, vsel_vd2_vo_vd2_vd2_advsimd_sleef(vcast_vo64_vo32_advsimd_sleef(o), x, ddigetdd_vd2_ddi_advsimd_sleef(ddi_advsimd_sleef))); + d = vadd_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(ddigetdd_vd2_ddi_advsimd_sleef(ddi_advsimd_sleef)), vd2gety_vd_vd2_advsimd_sleef(ddigetdd_vd2_ddi_advsimd_sleef(ddi_advsimd_sleef))); + d = vreinterpret_vd_vm_advsimd_sleef(vor_vm_vo64_vm_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(visinf_vo_vd_advsimd_sleef(r), visnan_vo_vd_advsimd_sleef(r)), vreinterpret_vm_vd_advsimd_sleef(d))); + } + + s = vmul_vd_vd_vd_advsimd_sleef(d, d); + + d = vreinterpret_vd_vm_advsimd_sleef(vxor_vm_vm_vm_advsimd_sleef(vand_vm_vo64_vm_advsimd_sleef(vcast_vo64_vo32_advsimd_sleef(veq_vo_vi_vi_advsimd_sleef(vand_vi_vi_vi_advsimd_sleef(ql, vcast_vi_i_advsimd_sleef(1)), vcast_vi_i_advsimd_sleef(1))), vreinterpret_vm_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(-0.0))), vreinterpret_vm_vd_advsimd_sleef(d))); + + vdouble_advsimd_sleef s2 = vmul_vd_vd_vd_advsimd_sleef(s, s), s4 = vmul_vd_vd_vd_advsimd_sleef(s2, s2); + u = vmla_vd_vd_vd_vd_advsimd_sleef((s4), (vmla_vd_vd_vd_vd_advsimd_sleef((s2), (vmla_vd_vd_vd_vd_advsimd_sleef((s), (vcast_vd_d_advsimd_sleef(-7.97255955009037868891952e-18)), (vcast_vd_d_advsimd_sleef(2.81009972710863200091251e-15)))), (vmla_vd_vd_vd_vd_advsimd_sleef((s), (vcast_vd_d_advsimd_sleef(-7.64712219118158833288484e-13)), (vcast_vd_d_advsimd_sleef(1.60590430605664501629054e-10)))))), (vmla_vd_vd_vd_vd_advsimd_sleef((s2), (vmla_vd_vd_vd_vd_advsimd_sleef((s), (vcast_vd_d_advsimd_sleef(-2.50521083763502045810755e-08)), (vcast_vd_d_advsimd_sleef(2.75573192239198747630416e-06)))), (vmla_vd_vd_vd_vd_advsimd_sleef((s), (vcast_vd_d_advsimd_sleef(-0.000198412698412696162806809)), (vcast_vd_d_advsimd_sleef(0.00833333333333332974823815))))))) + + ; + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, s, vcast_vd_d_advsimd_sleef(-0.166666666666666657414808)); + + u = vadd_vd_vd_vd_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(s, vmul_vd_vd_vd_advsimd_sleef(u, d)), d); + + u = vsel_vd_vo_vd_vd_advsimd_sleef(visnegzero_vo_vd_advsimd_sleef(r), r, u); + + return u; + +} + +SLEEF_INLINE SLEEF_CONST vdouble_advsimd_sleef Sleef_sind2_u10advsimd(vdouble_advsimd_sleef d) { + + vdouble_advsimd_sleef u; + vdouble2_advsimd_sleef s, t, x; + vint_advsimd_sleef ql; + + if (__builtin_expect(!!(vtestallones_i_vo64_advsimd_sleef(vlt_vo_vd_vd_advsimd_sleef(vabs_vd_vd_advsimd_sleef(d), vcast_vd_d_advsimd_sleef(15)))), 1)) { + const vdouble_advsimd_sleef dql = vrint_vd_vd_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(0.318309886183790671537767526745028724))); + ql = vrint_vi_vd_advsimd_sleef(dql); + u = vmla_vd_vd_vd_vd_advsimd_sleef(dql, vcast_vd_d_advsimd_sleef(-3.141592653589793116), d); + s = ddadd_vd2_vd_vd_advsimd_sleef (u, vmul_vd_vd_vd_advsimd_sleef(dql, vcast_vd_d_advsimd_sleef(-1.2246467991473532072e-16))); + } else if (__builtin_expect(!!(vtestallones_i_vo64_advsimd_sleef(vlt_vo_vd_vd_advsimd_sleef(vabs_vd_vd_advsimd_sleef(d), vcast_vd_d_advsimd_sleef(1e+14)))), 1)) { + vdouble_advsimd_sleef dqh = vtruncate_vd_vd_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(0.318309886183790671537767526745028724 / (1 << 24)))); + dqh = vmul_vd_vd_vd_advsimd_sleef(dqh, vcast_vd_d_advsimd_sleef(1 << 24)); + const vdouble_advsimd_sleef dql = vrint_vd_vd_advsimd_sleef(vmlapn_vd_vd_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(0.318309886183790671537767526745028724), dqh)); + ql = vrint_vi_vd_advsimd_sleef(dql); + + u = vmla_vd_vd_vd_vd_advsimd_sleef(dqh, vcast_vd_d_advsimd_sleef(-3.1415926218032836914), d); + s = ddadd_vd2_vd_vd_advsimd_sleef (u, vmul_vd_vd_vd_advsimd_sleef(dql, vcast_vd_d_advsimd_sleef(-3.1415926218032836914))); + s = ddadd2_vd2_vd2_vd_advsimd_sleef(s, vmul_vd_vd_vd_advsimd_sleef(dqh, vcast_vd_d_advsimd_sleef(-3.1786509424591713469e-08))); + s = ddadd2_vd2_vd2_vd_advsimd_sleef(s, vmul_vd_vd_vd_advsimd_sleef(dql, vcast_vd_d_advsimd_sleef(-3.1786509424591713469e-08))); + s = ddadd2_vd2_vd2_vd_advsimd_sleef(s, vmul_vd_vd_vd_advsimd_sleef(dqh, vcast_vd_d_advsimd_sleef(-1.2246467864107188502e-16))); + s = ddadd2_vd2_vd2_vd_advsimd_sleef(s, vmul_vd_vd_vd_advsimd_sleef(dql, vcast_vd_d_advsimd_sleef(-1.2246467864107188502e-16))); + s = ddadd_vd2_vd2_vd_advsimd_sleef(s, vmul_vd_vd_vd_advsimd_sleef(vadd_vd_vd_vd_advsimd_sleef(dqh, dql), vcast_vd_d_advsimd_sleef(-1.2736634327021899816e-24))); + } else { + ddi_t_advsimd_sleef ddi_advsimd_sleef = rempi_advsimd_sleef(d); + ql = vand_vi_vi_vi_advsimd_sleef(ddigeti_vi_ddi_advsimd_sleef(ddi_advsimd_sleef), vcast_vi_i_advsimd_sleef(3)); + ql = vadd_vi_vi_vi_advsimd_sleef(vadd_vi_vi_vi_advsimd_sleef(ql, ql), vsel_vi_vo_vi_vi_advsimd_sleef(vcast_vo32_vo64_advsimd_sleef(vgt_vo_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(ddigetdd_vd2_ddi_advsimd_sleef(ddi_advsimd_sleef)), vcast_vd_d_advsimd_sleef(0))), vcast_vi_i_advsimd_sleef(2), vcast_vi_i_advsimd_sleef(1))); + ql = vshr_n_s32(ql, 2); + vopmask_advsimd_sleef o = veq_vo_vi_vi_advsimd_sleef(vand_vi_vi_vi_advsimd_sleef(ddigeti_vi_ddi_advsimd_sleef(ddi_advsimd_sleef), vcast_vi_i_advsimd_sleef(1)), vcast_vi_i_advsimd_sleef(1)); + vdouble2_advsimd_sleef x = vcast_vd2_vd_vd_advsimd_sleef(vmulsign_vd_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(-3.141592653589793116 * 0.5), vd2getx_vd_vd2_advsimd_sleef(ddigetdd_vd2_ddi_advsimd_sleef(ddi_advsimd_sleef))), + vmulsign_vd_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(-1.2246467991473532072e-16 * 0.5), vd2getx_vd_vd2_advsimd_sleef(ddigetdd_vd2_ddi_advsimd_sleef(ddi_advsimd_sleef)))); + x = ddadd2_vd2_vd2_vd2_advsimd_sleef(ddigetdd_vd2_ddi_advsimd_sleef(ddi_advsimd_sleef), x); + ddi_advsimd_sleef = ddisetdd_ddi_ddi_vd2_advsimd_sleef(ddi_advsimd_sleef, vsel_vd2_vo_vd2_vd2_advsimd_sleef(vcast_vo64_vo32_advsimd_sleef(o), x, ddigetdd_vd2_ddi_advsimd_sleef(ddi_advsimd_sleef))); + s = ddnormalize_vd2_vd2_advsimd_sleef(ddigetdd_vd2_ddi_advsimd_sleef(ddi_advsimd_sleef)); + s = vd2setx_vd2_vd2_vd_advsimd_sleef(s, vreinterpret_vd_vm_advsimd_sleef(vor_vm_vo64_vm_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(visinf_vo_vd_advsimd_sleef(d), visnan_vo_vd_advsimd_sleef(d)), vreinterpret_vm_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(s))))); + } + + t = s; + s = ddsqu_vd2_vd2_advsimd_sleef(s); + + vdouble_advsimd_sleef s2 = vmul_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(s), vd2getx_vd_vd2_advsimd_sleef(s)), s4 = vmul_vd_vd_vd_advsimd_sleef(s2, s2); + u = vmla_vd_vd_vd_vd_advsimd_sleef((s4), (vmla_vd_vd_vd_vd_advsimd_sleef((vd2getx_vd_vd2_advsimd_sleef(s)), (vcast_vd_d_advsimd_sleef(2.72052416138529567917983e-15)), (vcast_vd_d_advsimd_sleef(-7.6429259411395447190023e-13)))), (vmla_vd_vd_vd_vd_advsimd_sleef((s2), (vmla_vd_vd_vd_vd_advsimd_sleef((vd2getx_vd_vd2_advsimd_sleef(s)), (vcast_vd_d_advsimd_sleef(1.60589370117277896211623e-10)), (vcast_vd_d_advsimd_sleef(-2.5052106814843123359368e-08)))), (vmla_vd_vd_vd_vd_advsimd_sleef((vd2getx_vd_vd2_advsimd_sleef(s)), (vcast_vd_d_advsimd_sleef(2.75573192104428224777379e-06)), (vcast_vd_d_advsimd_sleef(-0.000198412698412046454654947))))))) + + ; + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, vd2getx_vd_vd2_advsimd_sleef(s), vcast_vd_d_advsimd_sleef(0.00833333333333318056201922)); + + x = ddadd_vd2_vd_vd2_advsimd_sleef(vcast_vd_d_advsimd_sleef(1), ddmul_vd2_vd2_vd2_advsimd_sleef(ddadd_vd2_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(-0.166666666666666657414808), vmul_vd_vd_vd_advsimd_sleef(u, vd2getx_vd_vd2_advsimd_sleef(s))), s)); + u = ddmul_vd_vd2_vd2_advsimd_sleef(t, x); + + u = vreinterpret_vd_vm_advsimd_sleef(vxor_vm_vm_vm_advsimd_sleef(vand_vm_vo64_vm_advsimd_sleef(vcast_vo64_vo32_advsimd_sleef(veq_vo_vi_vi_advsimd_sleef(vand_vi_vi_vi_advsimd_sleef(ql, vcast_vi_i_advsimd_sleef(1)), vcast_vi_i_advsimd_sleef(1))), + vreinterpret_vm_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(-0.0))), vreinterpret_vm_vd_advsimd_sleef(u))); + u = vsel_vd_vo_vd_vd_advsimd_sleef(veq_vo_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(0)), d, u); + + return u; + +} + +SLEEF_INLINE SLEEF_CONST vdouble_advsimd_sleef Sleef_cosd2_u35advsimd(vdouble_advsimd_sleef d) { + + vdouble_advsimd_sleef u, s, r = d; + vint_advsimd_sleef ql; + + if (__builtin_expect(!!(vtestallones_i_vo64_advsimd_sleef(vlt_vo_vd_vd_advsimd_sleef(vabs_vd_vd_advsimd_sleef(d), vcast_vd_d_advsimd_sleef(15)))), 1)) { + vdouble_advsimd_sleef dql = vmla_vd_vd_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(2), + vrint_vd_vd_advsimd_sleef(vmla_vd_vd_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(0.318309886183790671537767526745028724), vcast_vd_d_advsimd_sleef(-0.5))), + vcast_vd_d_advsimd_sleef(1)); + ql = vrint_vi_vd_advsimd_sleef(dql); + d = vmla_vd_vd_vd_vd_advsimd_sleef(dql, vcast_vd_d_advsimd_sleef(-3.141592653589793116 * 0.5), d); + d = vmla_vd_vd_vd_vd_advsimd_sleef(dql, vcast_vd_d_advsimd_sleef(-1.2246467991473532072e-16 * 0.5), d); + } else if (__builtin_expect(!!(vtestallones_i_vo64_advsimd_sleef(vlt_vo_vd_vd_advsimd_sleef(vabs_vd_vd_advsimd_sleef(d), vcast_vd_d_advsimd_sleef(1e+14)))), 1)) { + vdouble_advsimd_sleef dqh = vtruncate_vd_vd_advsimd_sleef(vmla_vd_vd_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(0.318309886183790671537767526745028724 / (1 << 23)), vcast_vd_d_advsimd_sleef(-0.318309886183790671537767526745028724 / (1 << 24)))); + ql = vrint_vi_vd_advsimd_sleef(vadd_vd_vd_vd_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(0.318309886183790671537767526745028724)), + vmla_vd_vd_vd_vd_advsimd_sleef(dqh, vcast_vd_d_advsimd_sleef(-(1 << 23)), vcast_vd_d_advsimd_sleef(-0.5)))); + dqh = vmul_vd_vd_vd_advsimd_sleef(dqh, vcast_vd_d_advsimd_sleef(1 << 24)); + ql = vadd_vi_vi_vi_advsimd_sleef(vadd_vi_vi_vi_advsimd_sleef(ql, ql), vcast_vi_i_advsimd_sleef(1)); + vdouble_advsimd_sleef dql = vcast_vd_vi_advsimd_sleef(ql); + + d = vmla_vd_vd_vd_vd_advsimd_sleef(dqh, vcast_vd_d_advsimd_sleef(-3.1415926218032836914 * 0.5), d); + d = vmla_vd_vd_vd_vd_advsimd_sleef(dql, vcast_vd_d_advsimd_sleef(-3.1415926218032836914 * 0.5), d); + d = vmla_vd_vd_vd_vd_advsimd_sleef(dqh, vcast_vd_d_advsimd_sleef(-3.1786509424591713469e-08 * 0.5), d); + d = vmla_vd_vd_vd_vd_advsimd_sleef(dql, vcast_vd_d_advsimd_sleef(-3.1786509424591713469e-08 * 0.5), d); + d = vmla_vd_vd_vd_vd_advsimd_sleef(dqh, vcast_vd_d_advsimd_sleef(-1.2246467864107188502e-16 * 0.5), d); + d = vmla_vd_vd_vd_vd_advsimd_sleef(dql, vcast_vd_d_advsimd_sleef(-1.2246467864107188502e-16 * 0.5), d); + d = vmla_vd_vd_vd_vd_advsimd_sleef(vadd_vd_vd_vd_advsimd_sleef(dqh, dql), vcast_vd_d_advsimd_sleef(-1.2736634327021899816e-24 * 0.5), d); + } else { + ddi_t_advsimd_sleef ddi_advsimd_sleef = rempi_advsimd_sleef(d); + ql = vand_vi_vi_vi_advsimd_sleef(ddigeti_vi_ddi_advsimd_sleef(ddi_advsimd_sleef), vcast_vi_i_advsimd_sleef(3)); + ql = vadd_vi_vi_vi_advsimd_sleef(vadd_vi_vi_vi_advsimd_sleef(ql, ql), vsel_vi_vo_vi_vi_advsimd_sleef(vcast_vo32_vo64_advsimd_sleef(vgt_vo_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(ddigetdd_vd2_ddi_advsimd_sleef(ddi_advsimd_sleef)), vcast_vd_d_advsimd_sleef(0))), vcast_vi_i_advsimd_sleef(8), vcast_vi_i_advsimd_sleef(7))); + ql = vshr_n_s32(ql, 1); + vopmask_advsimd_sleef o = veq_vo_vi_vi_advsimd_sleef(vand_vi_vi_vi_advsimd_sleef(ddigeti_vi_ddi_advsimd_sleef(ddi_advsimd_sleef), vcast_vi_i_advsimd_sleef(1)), vcast_vi_i_advsimd_sleef(0)); + vdouble_advsimd_sleef y = vsel_vd_vo_vd_vd_advsimd_sleef(vgt_vo_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(ddigetdd_vd2_ddi_advsimd_sleef(ddi_advsimd_sleef)), vcast_vd_d_advsimd_sleef(0)), vcast_vd_d_advsimd_sleef(0), vcast_vd_d_advsimd_sleef(-1)); + vdouble2_advsimd_sleef x = vcast_vd2_vd_vd_advsimd_sleef(vmulsign_vd_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(-3.141592653589793116 * 0.5), y), + vmulsign_vd_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(-1.2246467991473532072e-16 * 0.5), y)); + x = ddadd2_vd2_vd2_vd2_advsimd_sleef(ddigetdd_vd2_ddi_advsimd_sleef(ddi_advsimd_sleef), x); + ddi_advsimd_sleef = ddisetdd_ddi_ddi_vd2_advsimd_sleef(ddi_advsimd_sleef, vsel_vd2_vo_vd2_vd2_advsimd_sleef(vcast_vo64_vo32_advsimd_sleef(o), x, ddigetdd_vd2_ddi_advsimd_sleef(ddi_advsimd_sleef))); + d = vadd_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(ddigetdd_vd2_ddi_advsimd_sleef(ddi_advsimd_sleef)), vd2gety_vd_vd2_advsimd_sleef(ddigetdd_vd2_ddi_advsimd_sleef(ddi_advsimd_sleef))); + d = vreinterpret_vd_vm_advsimd_sleef(vor_vm_vo64_vm_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(visinf_vo_vd_advsimd_sleef(r), visnan_vo_vd_advsimd_sleef(r)), vreinterpret_vm_vd_advsimd_sleef(d))); + } + + s = vmul_vd_vd_vd_advsimd_sleef(d, d); + + d = vreinterpret_vd_vm_advsimd_sleef(vxor_vm_vm_vm_advsimd_sleef(vand_vm_vo64_vm_advsimd_sleef(vcast_vo64_vo32_advsimd_sleef(veq_vo_vi_vi_advsimd_sleef(vand_vi_vi_vi_advsimd_sleef(ql, vcast_vi_i_advsimd_sleef(2)), vcast_vi_i_advsimd_sleef(0))), vreinterpret_vm_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(-0.0))), vreinterpret_vm_vd_advsimd_sleef(d))); + + vdouble_advsimd_sleef s2 = vmul_vd_vd_vd_advsimd_sleef(s, s), s4 = vmul_vd_vd_vd_advsimd_sleef(s2, s2); + u = vmla_vd_vd_vd_vd_advsimd_sleef((s4), (vmla_vd_vd_vd_vd_advsimd_sleef((s2), (vmla_vd_vd_vd_vd_advsimd_sleef((s), (vcast_vd_d_advsimd_sleef(-7.97255955009037868891952e-18)), (vcast_vd_d_advsimd_sleef(2.81009972710863200091251e-15)))), (vmla_vd_vd_vd_vd_advsimd_sleef((s), (vcast_vd_d_advsimd_sleef(-7.64712219118158833288484e-13)), (vcast_vd_d_advsimd_sleef(1.60590430605664501629054e-10)))))), (vmla_vd_vd_vd_vd_advsimd_sleef((s2), (vmla_vd_vd_vd_vd_advsimd_sleef((s), (vcast_vd_d_advsimd_sleef(-2.50521083763502045810755e-08)), (vcast_vd_d_advsimd_sleef(2.75573192239198747630416e-06)))), (vmla_vd_vd_vd_vd_advsimd_sleef((s), (vcast_vd_d_advsimd_sleef(-0.000198412698412696162806809)), (vcast_vd_d_advsimd_sleef(0.00833333333333332974823815))))))) + + ; + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, s, vcast_vd_d_advsimd_sleef(-0.166666666666666657414808)); + + u = vadd_vd_vd_vd_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(s, vmul_vd_vd_vd_advsimd_sleef(u, d)), d); + + return u; + +} + +SLEEF_INLINE SLEEF_CONST vdouble_advsimd_sleef Sleef_cosd2_u10advsimd(vdouble_advsimd_sleef d) { + + vdouble_advsimd_sleef u; + vdouble2_advsimd_sleef s, t, x; + vint_advsimd_sleef ql; + + if (__builtin_expect(!!(vtestallones_i_vo64_advsimd_sleef(vlt_vo_vd_vd_advsimd_sleef(vabs_vd_vd_advsimd_sleef(d), vcast_vd_d_advsimd_sleef(15)))), 1)) { + vdouble_advsimd_sleef dql = vrint_vd_vd_advsimd_sleef(vmla_vd_vd_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(0.318309886183790671537767526745028724), vcast_vd_d_advsimd_sleef(-0.5))); + dql = vmla_vd_vd_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(2), dql, vcast_vd_d_advsimd_sleef(1)); + ql = vrint_vi_vd_advsimd_sleef(dql); + s = ddadd2_vd2_vd_vd_advsimd_sleef(d, vmul_vd_vd_vd_advsimd_sleef(dql, vcast_vd_d_advsimd_sleef(-3.141592653589793116*0.5))); + s = ddadd_vd2_vd2_vd_advsimd_sleef(s, vmul_vd_vd_vd_advsimd_sleef(dql, vcast_vd_d_advsimd_sleef(-1.2246467991473532072e-16*0.5))); + } else if (__builtin_expect(!!(vtestallones_i_vo64_advsimd_sleef(vlt_vo_vd_vd_advsimd_sleef(vabs_vd_vd_advsimd_sleef(d), vcast_vd_d_advsimd_sleef(1e+14)))), 1)) { + vdouble_advsimd_sleef dqh = vtruncate_vd_vd_advsimd_sleef(vmla_vd_vd_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(0.318309886183790671537767526745028724 / (1 << 23)), vcast_vd_d_advsimd_sleef(-0.318309886183790671537767526745028724 / (1 << 24)))); + ql = vrint_vi_vd_advsimd_sleef(vadd_vd_vd_vd_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(0.318309886183790671537767526745028724)), + vmla_vd_vd_vd_vd_advsimd_sleef(dqh, vcast_vd_d_advsimd_sleef(-(1 << 23)), vcast_vd_d_advsimd_sleef(-0.5)))); + dqh = vmul_vd_vd_vd_advsimd_sleef(dqh, vcast_vd_d_advsimd_sleef(1 << 24)); + ql = vadd_vi_vi_vi_advsimd_sleef(vadd_vi_vi_vi_advsimd_sleef(ql, ql), vcast_vi_i_advsimd_sleef(1)); + const vdouble_advsimd_sleef dql = vcast_vd_vi_advsimd_sleef(ql); + + u = vmla_vd_vd_vd_vd_advsimd_sleef(dqh, vcast_vd_d_advsimd_sleef(-3.1415926218032836914 * 0.5), d); + s = ddadd2_vd2_vd_vd_advsimd_sleef(u, vmul_vd_vd_vd_advsimd_sleef(dql, vcast_vd_d_advsimd_sleef(-3.1415926218032836914*0.5))); + s = ddadd2_vd2_vd2_vd_advsimd_sleef(s, vmul_vd_vd_vd_advsimd_sleef(dqh, vcast_vd_d_advsimd_sleef(-3.1786509424591713469e-08*0.5))); + s = ddadd2_vd2_vd2_vd_advsimd_sleef(s, vmul_vd_vd_vd_advsimd_sleef(dql, vcast_vd_d_advsimd_sleef(-3.1786509424591713469e-08*0.5))); + s = ddadd2_vd2_vd2_vd_advsimd_sleef(s, vmul_vd_vd_vd_advsimd_sleef(dqh, vcast_vd_d_advsimd_sleef(-1.2246467864107188502e-16*0.5))); + s = ddadd2_vd2_vd2_vd_advsimd_sleef(s, vmul_vd_vd_vd_advsimd_sleef(dql, vcast_vd_d_advsimd_sleef(-1.2246467864107188502e-16*0.5))); + s = ddadd_vd2_vd2_vd_advsimd_sleef(s, vmul_vd_vd_vd_advsimd_sleef(vadd_vd_vd_vd_advsimd_sleef(dqh, dql), vcast_vd_d_advsimd_sleef(-1.2736634327021899816e-24*0.5))); + } else { + ddi_t_advsimd_sleef ddi_advsimd_sleef = rempi_advsimd_sleef(d); + ql = vand_vi_vi_vi_advsimd_sleef(ddigeti_vi_ddi_advsimd_sleef(ddi_advsimd_sleef), vcast_vi_i_advsimd_sleef(3)); + ql = vadd_vi_vi_vi_advsimd_sleef(vadd_vi_vi_vi_advsimd_sleef(ql, ql), vsel_vi_vo_vi_vi_advsimd_sleef(vcast_vo32_vo64_advsimd_sleef(vgt_vo_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(ddigetdd_vd2_ddi_advsimd_sleef(ddi_advsimd_sleef)), vcast_vd_d_advsimd_sleef(0))), vcast_vi_i_advsimd_sleef(8), vcast_vi_i_advsimd_sleef(7))); + ql = vshr_n_s32(ql, 1); + vopmask_advsimd_sleef o = veq_vo_vi_vi_advsimd_sleef(vand_vi_vi_vi_advsimd_sleef(ddigeti_vi_ddi_advsimd_sleef(ddi_advsimd_sleef), vcast_vi_i_advsimd_sleef(1)), vcast_vi_i_advsimd_sleef(0)); + vdouble_advsimd_sleef y = vsel_vd_vo_vd_vd_advsimd_sleef(vgt_vo_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(ddigetdd_vd2_ddi_advsimd_sleef(ddi_advsimd_sleef)), vcast_vd_d_advsimd_sleef(0)), vcast_vd_d_advsimd_sleef(0), vcast_vd_d_advsimd_sleef(-1)); + vdouble2_advsimd_sleef x = vcast_vd2_vd_vd_advsimd_sleef(vmulsign_vd_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(-3.141592653589793116 * 0.5), y), + vmulsign_vd_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(-1.2246467991473532072e-16 * 0.5), y)); + x = ddadd2_vd2_vd2_vd2_advsimd_sleef(ddigetdd_vd2_ddi_advsimd_sleef(ddi_advsimd_sleef), x); + ddi_advsimd_sleef = ddisetdd_ddi_ddi_vd2_advsimd_sleef(ddi_advsimd_sleef, vsel_vd2_vo_vd2_vd2_advsimd_sleef(vcast_vo64_vo32_advsimd_sleef(o), x, ddigetdd_vd2_ddi_advsimd_sleef(ddi_advsimd_sleef))); + s = ddnormalize_vd2_vd2_advsimd_sleef(ddigetdd_vd2_ddi_advsimd_sleef(ddi_advsimd_sleef)); + s = vd2setx_vd2_vd2_vd_advsimd_sleef(s, vreinterpret_vd_vm_advsimd_sleef(vor_vm_vo64_vm_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(visinf_vo_vd_advsimd_sleef(d), visnan_vo_vd_advsimd_sleef(d)), vreinterpret_vm_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(s))))); + } + + t = s; + s = ddsqu_vd2_vd2_advsimd_sleef(s); + + vdouble_advsimd_sleef s2 = vmul_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(s), vd2getx_vd_vd2_advsimd_sleef(s)), s4 = vmul_vd_vd_vd_advsimd_sleef(s2, s2); + u = vmla_vd_vd_vd_vd_advsimd_sleef((s4), (vmla_vd_vd_vd_vd_advsimd_sleef((vd2getx_vd_vd2_advsimd_sleef(s)), (vcast_vd_d_advsimd_sleef(2.72052416138529567917983e-15)), (vcast_vd_d_advsimd_sleef(-7.6429259411395447190023e-13)))), (vmla_vd_vd_vd_vd_advsimd_sleef((s2), (vmla_vd_vd_vd_vd_advsimd_sleef((vd2getx_vd_vd2_advsimd_sleef(s)), (vcast_vd_d_advsimd_sleef(1.60589370117277896211623e-10)), (vcast_vd_d_advsimd_sleef(-2.5052106814843123359368e-08)))), (vmla_vd_vd_vd_vd_advsimd_sleef((vd2getx_vd_vd2_advsimd_sleef(s)), (vcast_vd_d_advsimd_sleef(2.75573192104428224777379e-06)), (vcast_vd_d_advsimd_sleef(-0.000198412698412046454654947))))))) + + ; + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, vd2getx_vd_vd2_advsimd_sleef(s), vcast_vd_d_advsimd_sleef(0.00833333333333318056201922)); + + x = ddadd_vd2_vd_vd2_advsimd_sleef(vcast_vd_d_advsimd_sleef(1), ddmul_vd2_vd2_vd2_advsimd_sleef(ddadd_vd2_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(-0.166666666666666657414808), vmul_vd_vd_vd_advsimd_sleef(u, vd2getx_vd_vd2_advsimd_sleef(s))), s)); + u = ddmul_vd_vd2_vd2_advsimd_sleef(t, x); + + u = vreinterpret_vd_vm_advsimd_sleef(vxor_vm_vm_vm_advsimd_sleef(vand_vm_vo64_vm_advsimd_sleef(vcast_vo64_vo32_advsimd_sleef(veq_vo_vi_vi_advsimd_sleef(vand_vi_vi_vi_advsimd_sleef(ql, vcast_vi_i_advsimd_sleef(2)), vcast_vi_i_advsimd_sleef(0))), vreinterpret_vm_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(-0.0))), vreinterpret_vm_vd_advsimd_sleef(u))); + + return u; + +} + +SLEEF_INLINE vdouble2_advsimd_sleef Sleef_sincosd2_u35advsimd(vdouble_advsimd_sleef d) { + + vopmask_advsimd_sleef o; + vdouble_advsimd_sleef u, t, rx, ry, s; + vdouble2_advsimd_sleef r; + vint_advsimd_sleef ql; + + if (__builtin_expect(!!(vtestallones_i_vo64_advsimd_sleef(vlt_vo_vd_vd_advsimd_sleef(vabs_vd_vd_advsimd_sleef(d), vcast_vd_d_advsimd_sleef(15)))), 1)) { + vdouble_advsimd_sleef dql = vrint_vd_vd_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(2 * 0.318309886183790671537767526745028724))); + ql = vrint_vi_vd_advsimd_sleef(dql); + s = vmla_vd_vd_vd_vd_advsimd_sleef(dql, vcast_vd_d_advsimd_sleef(-3.141592653589793116 * 0.5), d); + s = vmla_vd_vd_vd_vd_advsimd_sleef(dql, vcast_vd_d_advsimd_sleef(-1.2246467991473532072e-16 * 0.5), s); + } else if (__builtin_expect(!!(vtestallones_i_vo64_advsimd_sleef(vlt_vo_vd_vd_advsimd_sleef(vabs_vd_vd_advsimd_sleef(d), vcast_vd_d_advsimd_sleef(1e+14)))), 1)) { + vdouble_advsimd_sleef dqh = vtruncate_vd_vd_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(2*0.318309886183790671537767526745028724 / (1 << 24)))); + dqh = vmul_vd_vd_vd_advsimd_sleef(dqh, vcast_vd_d_advsimd_sleef(1 << 24)); + vdouble_advsimd_sleef dql = vrint_vd_vd_advsimd_sleef(vsub_vd_vd_vd_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(2*0.318309886183790671537767526745028724)), dqh)); + ql = vrint_vi_vd_advsimd_sleef(dql); + + s = vmla_vd_vd_vd_vd_advsimd_sleef(dqh, vcast_vd_d_advsimd_sleef(-3.1415926218032836914 * 0.5), d); + s = vmla_vd_vd_vd_vd_advsimd_sleef(dql, vcast_vd_d_advsimd_sleef(-3.1415926218032836914 * 0.5), s); + s = vmla_vd_vd_vd_vd_advsimd_sleef(dqh, vcast_vd_d_advsimd_sleef(-3.1786509424591713469e-08 * 0.5), s); + s = vmla_vd_vd_vd_vd_advsimd_sleef(dql, vcast_vd_d_advsimd_sleef(-3.1786509424591713469e-08 * 0.5), s); + s = vmla_vd_vd_vd_vd_advsimd_sleef(dqh, vcast_vd_d_advsimd_sleef(-1.2246467864107188502e-16 * 0.5), s); + s = vmla_vd_vd_vd_vd_advsimd_sleef(dql, vcast_vd_d_advsimd_sleef(-1.2246467864107188502e-16 * 0.5), s); + s = vmla_vd_vd_vd_vd_advsimd_sleef(vadd_vd_vd_vd_advsimd_sleef(dqh, dql), vcast_vd_d_advsimd_sleef(-1.2736634327021899816e-24 * 0.5), s); + } else { + ddi_t_advsimd_sleef ddi_advsimd_sleef = rempi_advsimd_sleef(d); + ql = ddigeti_vi_ddi_advsimd_sleef(ddi_advsimd_sleef); + s = vadd_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(ddigetdd_vd2_ddi_advsimd_sleef(ddi_advsimd_sleef)), vd2gety_vd_vd2_advsimd_sleef(ddigetdd_vd2_ddi_advsimd_sleef(ddi_advsimd_sleef))); + s = vreinterpret_vd_vm_advsimd_sleef(vor_vm_vo64_vm_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(visinf_vo_vd_advsimd_sleef(d), visnan_vo_vd_advsimd_sleef(d)), vreinterpret_vm_vd_advsimd_sleef(s))); + } + + t = s; + + s = vmul_vd_vd_vd_advsimd_sleef(s, s); + + u = vcast_vd_d_advsimd_sleef(1.58938307283228937328511e-10); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, s, vcast_vd_d_advsimd_sleef(-2.50506943502539773349318e-08)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, s, vcast_vd_d_advsimd_sleef(2.75573131776846360512547e-06)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, s, vcast_vd_d_advsimd_sleef(-0.000198412698278911770864914)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, s, vcast_vd_d_advsimd_sleef(0.0083333333333191845961746)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, s, vcast_vd_d_advsimd_sleef(-0.166666666666666130709393)); + + rx = vmla_vd_vd_vd_vd_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(u, s), t, t); + rx = vsel_vd_vo_vd_vd_advsimd_sleef(visnegzero_vo_vd_advsimd_sleef(d), vcast_vd_d_advsimd_sleef(-0.0), rx); + + u = vcast_vd_d_advsimd_sleef(-1.13615350239097429531523e-11); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, s, vcast_vd_d_advsimd_sleef(2.08757471207040055479366e-09)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, s, vcast_vd_d_advsimd_sleef(-2.75573144028847567498567e-07)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, s, vcast_vd_d_advsimd_sleef(2.48015872890001867311915e-05)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, s, vcast_vd_d_advsimd_sleef(-0.00138888888888714019282329)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, s, vcast_vd_d_advsimd_sleef(0.0416666666666665519592062)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, s, vcast_vd_d_advsimd_sleef(-0.5)); + + ry = vmla_vd_vd_vd_vd_advsimd_sleef(s, u, vcast_vd_d_advsimd_sleef(1)); + + o = vcast_vo64_vo32_advsimd_sleef(veq_vo_vi_vi_advsimd_sleef(vand_vi_vi_vi_advsimd_sleef(ql, vcast_vi_i_advsimd_sleef(1)), vcast_vi_i_advsimd_sleef(0))); + r = vd2setxy_vd2_vd_vd_advsimd_sleef(vsel_vd_vo_vd_vd_advsimd_sleef(o, rx, ry), vsel_vd_vo_vd_vd_advsimd_sleef(o, ry, rx)); + + o = vcast_vo64_vo32_advsimd_sleef(veq_vo_vi_vi_advsimd_sleef(vand_vi_vi_vi_advsimd_sleef(ql, vcast_vi_i_advsimd_sleef(2)), vcast_vi_i_advsimd_sleef(2))); + r = vd2setx_vd2_vd2_vd_advsimd_sleef(r, vreinterpret_vd_vm_advsimd_sleef(vxor_vm_vm_vm_advsimd_sleef(vand_vm_vo64_vm_advsimd_sleef(o, vreinterpret_vm_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(-0.0))), vreinterpret_vm_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(r))))); + + o = vcast_vo64_vo32_advsimd_sleef(veq_vo_vi_vi_advsimd_sleef(vand_vi_vi_vi_advsimd_sleef(vadd_vi_vi_vi_advsimd_sleef(ql, vcast_vi_i_advsimd_sleef(1)), vcast_vi_i_advsimd_sleef(2)), vcast_vi_i_advsimd_sleef(2))); + r = vd2sety_vd2_vd2_vd_advsimd_sleef(r, vreinterpret_vd_vm_advsimd_sleef(vxor_vm_vm_vm_advsimd_sleef(vand_vm_vo64_vm_advsimd_sleef(o, vreinterpret_vm_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(-0.0))), vreinterpret_vm_vd_advsimd_sleef(vd2gety_vd_vd2_advsimd_sleef(r))))); + + return r; + +} + +SLEEF_INLINE vdouble2_advsimd_sleef Sleef_sincosd2_u10advsimd(vdouble_advsimd_sleef d) { + + vopmask_advsimd_sleef o; + vdouble_advsimd_sleef u, rx, ry; + vdouble2_advsimd_sleef r, s, t, x; + vint_advsimd_sleef ql; + + if (__builtin_expect(!!(vtestallones_i_vo64_advsimd_sleef(vlt_vo_vd_vd_advsimd_sleef(vabs_vd_vd_advsimd_sleef(d), vcast_vd_d_advsimd_sleef(15)))), 1)) { + const vdouble_advsimd_sleef dql = vrint_vd_vd_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(2 * 0.318309886183790671537767526745028724))); + ql = vrint_vi_vd_advsimd_sleef(dql); + u = vmla_vd_vd_vd_vd_advsimd_sleef(dql, vcast_vd_d_advsimd_sleef(-3.141592653589793116*0.5), d); + s = ddadd_vd2_vd_vd_advsimd_sleef (u, vmul_vd_vd_vd_advsimd_sleef(dql, vcast_vd_d_advsimd_sleef(-1.2246467991473532072e-16*0.5))); + } else if (__builtin_expect(!!(vtestallones_i_vo64_advsimd_sleef(vlt_vo_vd_vd_advsimd_sleef(vabs_vd_vd_advsimd_sleef(d), vcast_vd_d_advsimd_sleef(1e+14)))), 1)) { + vdouble_advsimd_sleef dqh = vtruncate_vd_vd_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(2*0.318309886183790671537767526745028724 / (1 << 24)))); + dqh = vmul_vd_vd_vd_advsimd_sleef(dqh, vcast_vd_d_advsimd_sleef(1 << 24)); + const vdouble_advsimd_sleef dql = vrint_vd_vd_advsimd_sleef(vsub_vd_vd_vd_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(2*0.318309886183790671537767526745028724)), dqh)); + ql = vrint_vi_vd_advsimd_sleef(dql); + + u = vmla_vd_vd_vd_vd_advsimd_sleef(dqh, vcast_vd_d_advsimd_sleef(-3.1415926218032836914 * 0.5), d); + s = ddadd_vd2_vd_vd_advsimd_sleef(u, vmul_vd_vd_vd_advsimd_sleef(dql, vcast_vd_d_advsimd_sleef(-3.1415926218032836914*0.5))); + s = ddadd2_vd2_vd2_vd_advsimd_sleef(s, vmul_vd_vd_vd_advsimd_sleef(dqh, vcast_vd_d_advsimd_sleef(-3.1786509424591713469e-08*0.5))); + s = ddadd2_vd2_vd2_vd_advsimd_sleef(s, vmul_vd_vd_vd_advsimd_sleef(dql, vcast_vd_d_advsimd_sleef(-3.1786509424591713469e-08*0.5))); + s = ddadd2_vd2_vd2_vd_advsimd_sleef(s, vmul_vd_vd_vd_advsimd_sleef(dqh, vcast_vd_d_advsimd_sleef(-1.2246467864107188502e-16*0.5))); + s = ddadd2_vd2_vd2_vd_advsimd_sleef(s, vmul_vd_vd_vd_advsimd_sleef(dql, vcast_vd_d_advsimd_sleef(-1.2246467864107188502e-16*0.5))); + s = ddadd_vd2_vd2_vd_advsimd_sleef(s, vmul_vd_vd_vd_advsimd_sleef(vadd_vd_vd_vd_advsimd_sleef(dqh, dql), vcast_vd_d_advsimd_sleef(-1.2736634327021899816e-24*0.5))); + } else { + ddi_t_advsimd_sleef ddi_advsimd_sleef = rempi_advsimd_sleef(d); + ql = ddigeti_vi_ddi_advsimd_sleef(ddi_advsimd_sleef); + s = ddigetdd_vd2_ddi_advsimd_sleef(ddi_advsimd_sleef); + o = vor_vo_vo_vo_advsimd_sleef(visinf_vo_vd_advsimd_sleef(d), visnan_vo_vd_advsimd_sleef(d)); + s = vd2setxy_vd2_vd_vd_advsimd_sleef(vreinterpret_vd_vm_advsimd_sleef(vor_vm_vo64_vm_advsimd_sleef(o, vreinterpret_vm_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(s)))), + vreinterpret_vd_vm_advsimd_sleef(vor_vm_vo64_vm_advsimd_sleef(o, vreinterpret_vm_vd_advsimd_sleef(vd2gety_vd_vd2_advsimd_sleef(s))))); + } + + t = s; + + s = vd2setx_vd2_vd2_vd_advsimd_sleef(s, ddsqu_vd_vd2_advsimd_sleef(s)); + + u = vcast_vd_d_advsimd_sleef(1.58938307283228937328511e-10); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, vd2getx_vd_vd2_advsimd_sleef(s), vcast_vd_d_advsimd_sleef(-2.50506943502539773349318e-08)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, vd2getx_vd_vd2_advsimd_sleef(s), vcast_vd_d_advsimd_sleef(2.75573131776846360512547e-06)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, vd2getx_vd_vd2_advsimd_sleef(s), vcast_vd_d_advsimd_sleef(-0.000198412698278911770864914)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, vd2getx_vd_vd2_advsimd_sleef(s), vcast_vd_d_advsimd_sleef(0.0083333333333191845961746)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, vd2getx_vd_vd2_advsimd_sleef(s), vcast_vd_d_advsimd_sleef(-0.166666666666666130709393)); + + u = vmul_vd_vd_vd_advsimd_sleef(u, vmul_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(s), vd2getx_vd_vd2_advsimd_sleef(t))); + + x = ddadd_vd2_vd2_vd_advsimd_sleef(t, u); + rx = vadd_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(x), vd2gety_vd_vd2_advsimd_sleef(x)); + + rx = vsel_vd_vo_vd_vd_advsimd_sleef(visnegzero_vo_vd_advsimd_sleef(d), vcast_vd_d_advsimd_sleef(-0.0), rx); + + u = vcast_vd_d_advsimd_sleef(-1.13615350239097429531523e-11); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, vd2getx_vd_vd2_advsimd_sleef(s), vcast_vd_d_advsimd_sleef(2.08757471207040055479366e-09)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, vd2getx_vd_vd2_advsimd_sleef(s), vcast_vd_d_advsimd_sleef(-2.75573144028847567498567e-07)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, vd2getx_vd_vd2_advsimd_sleef(s), vcast_vd_d_advsimd_sleef(2.48015872890001867311915e-05)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, vd2getx_vd_vd2_advsimd_sleef(s), vcast_vd_d_advsimd_sleef(-0.00138888888888714019282329)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, vd2getx_vd_vd2_advsimd_sleef(s), vcast_vd_d_advsimd_sleef(0.0416666666666665519592062)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, vd2getx_vd_vd2_advsimd_sleef(s), vcast_vd_d_advsimd_sleef(-0.5)); + + x = ddadd_vd2_vd_vd2_advsimd_sleef(vcast_vd_d_advsimd_sleef(1), ddmul_vd2_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(s), u)); + ry = vadd_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(x), vd2gety_vd_vd2_advsimd_sleef(x)); + + o = vcast_vo64_vo32_advsimd_sleef(veq_vo_vi_vi_advsimd_sleef(vand_vi_vi_vi_advsimd_sleef(ql, vcast_vi_i_advsimd_sleef(1)), vcast_vi_i_advsimd_sleef(0))); + r = vd2setxy_vd2_vd_vd_advsimd_sleef(vsel_vd_vo_vd_vd_advsimd_sleef(o, rx, ry), vsel_vd_vo_vd_vd_advsimd_sleef(o, ry, rx)); + + o = vcast_vo64_vo32_advsimd_sleef(veq_vo_vi_vi_advsimd_sleef(vand_vi_vi_vi_advsimd_sleef(ql, vcast_vi_i_advsimd_sleef(2)), vcast_vi_i_advsimd_sleef(2))); + r = vd2setx_vd2_vd2_vd_advsimd_sleef(r, vreinterpret_vd_vm_advsimd_sleef(vxor_vm_vm_vm_advsimd_sleef(vand_vm_vo64_vm_advsimd_sleef(o, vreinterpret_vm_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(-0.0))), vreinterpret_vm_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(r))))); + + o = vcast_vo64_vo32_advsimd_sleef(veq_vo_vi_vi_advsimd_sleef(vand_vi_vi_vi_advsimd_sleef(vadd_vi_vi_vi_advsimd_sleef(ql, vcast_vi_i_advsimd_sleef(1)), vcast_vi_i_advsimd_sleef(2)), vcast_vi_i_advsimd_sleef(2))); + r = vd2sety_vd2_vd2_vd_advsimd_sleef(r, vreinterpret_vd_vm_advsimd_sleef(vxor_vm_vm_vm_advsimd_sleef(vand_vm_vo64_vm_advsimd_sleef(o, vreinterpret_vm_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(-0.0))), vreinterpret_vm_vd_advsimd_sleef(vd2gety_vd_vd2_advsimd_sleef(r))))); + + return r; + +} + +SLEEF_INLINE vdouble2_advsimd_sleef Sleef_sincospid2_u05advsimd(vdouble_advsimd_sleef d) { + vopmask_advsimd_sleef o; + vdouble_advsimd_sleef u, s, t, rx, ry; + vdouble2_advsimd_sleef r, x, s2; + + u = vmul_vd_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(4.0)); + vint_advsimd_sleef q = vtruncate_vi_vd_advsimd_sleef(u); + q = vand_vi_vi_vi_advsimd_sleef(vadd_vi_vi_vi_advsimd_sleef(q, vxor_vi_vi_vi_advsimd_sleef(vreinterpret_s32_u32(vshr_n_u32(vreinterpret_u32_s32(q), 31)), vcast_vi_i_advsimd_sleef(1))), vcast_vi_i_advsimd_sleef(~1)); + s = vsub_vd_vd_vd_advsimd_sleef(u, vcast_vd_vi_advsimd_sleef(q)); + + t = s; + s = vmul_vd_vd_vd_advsimd_sleef(s, s); + s2 = ddmul_vd2_vd_vd_advsimd_sleef(t, t); + + u = vcast_vd_d_advsimd_sleef(-2.02461120785182399295868e-14); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, s, vcast_vd_d_advsimd_sleef(6.94821830580179461327784e-12)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, s, vcast_vd_d_advsimd_sleef(-1.75724749952853179952664e-09)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, s, vcast_vd_d_advsimd_sleef(3.13361688966868392878422e-07)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, s, vcast_vd_d_advsimd_sleef(-3.6576204182161551920361e-05)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, s, vcast_vd_d_advsimd_sleef(0.00249039457019271850274356)); + x = ddadd2_vd2_vd_vd2_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(u, s), vcast_vd2_d_d_advsimd_sleef(-0.0807455121882807852484731, 3.61852475067037104849987e-18)); + x = ddadd2_vd2_vd2_vd2_advsimd_sleef(ddmul_vd2_vd2_vd2_advsimd_sleef(s2, x), vcast_vd2_d_d_advsimd_sleef(0.785398163397448278999491, 3.06287113727155002607105e-17)); + + x = ddmul_vd2_vd2_vd_advsimd_sleef(x, t); + rx = vadd_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(x), vd2gety_vd_vd2_advsimd_sleef(x)); + + rx = vsel_vd_vo_vd_vd_advsimd_sleef(visnegzero_vo_vd_advsimd_sleef(d), vcast_vd_d_advsimd_sleef(-0.0), rx); + + u = vcast_vd_d_advsimd_sleef(9.94480387626843774090208e-16); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, s, vcast_vd_d_advsimd_sleef(-3.89796226062932799164047e-13)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, s, vcast_vd_d_advsimd_sleef(1.15011582539996035266901e-10)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, s, vcast_vd_d_advsimd_sleef(-2.4611369501044697495359e-08)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, s, vcast_vd_d_advsimd_sleef(3.59086044859052754005062e-06)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, s, vcast_vd_d_advsimd_sleef(-0.000325991886927389905997954)); + x = ddadd2_vd2_vd_vd2_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(u, s), vcast_vd2_d_d_advsimd_sleef(0.0158543442438155018914259, -1.04693272280631521908845e-18)); + x = ddadd2_vd2_vd2_vd2_advsimd_sleef(ddmul_vd2_vd2_vd2_advsimd_sleef(s2, x), vcast_vd2_d_d_advsimd_sleef(-0.308425137534042437259529, -1.95698492133633550338345e-17)); + + x = ddadd2_vd2_vd2_vd_advsimd_sleef(ddmul_vd2_vd2_vd2_advsimd_sleef(x, s2), vcast_vd_d_advsimd_sleef(1)); + ry = vadd_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(x), vd2gety_vd_vd2_advsimd_sleef(x)); + + o = vcast_vo64_vo32_advsimd_sleef(veq_vo_vi_vi_advsimd_sleef(vand_vi_vi_vi_advsimd_sleef(q, vcast_vi_i_advsimd_sleef(2)), vcast_vi_i_advsimd_sleef(0))); + r = vd2setxy_vd2_vd_vd_advsimd_sleef(vsel_vd_vo_vd_vd_advsimd_sleef(o, rx, ry), vsel_vd_vo_vd_vd_advsimd_sleef(o, ry, rx)); + + o = vcast_vo64_vo32_advsimd_sleef(veq_vo_vi_vi_advsimd_sleef(vand_vi_vi_vi_advsimd_sleef(q, vcast_vi_i_advsimd_sleef(4)), vcast_vi_i_advsimd_sleef(4))); + r = vd2setx_vd2_vd2_vd_advsimd_sleef(r, vreinterpret_vd_vm_advsimd_sleef(vxor_vm_vm_vm_advsimd_sleef(vand_vm_vo64_vm_advsimd_sleef(o, vreinterpret_vm_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(-0.0))), vreinterpret_vm_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(r))))); + + o = vcast_vo64_vo32_advsimd_sleef(veq_vo_vi_vi_advsimd_sleef(vand_vi_vi_vi_advsimd_sleef(vadd_vi_vi_vi_advsimd_sleef(q, vcast_vi_i_advsimd_sleef(2)), vcast_vi_i_advsimd_sleef(4)), vcast_vi_i_advsimd_sleef(4))); + r = vd2sety_vd2_vd2_vd_advsimd_sleef(r, vreinterpret_vd_vm_advsimd_sleef(vxor_vm_vm_vm_advsimd_sleef(vand_vm_vo64_vm_advsimd_sleef(o, vreinterpret_vm_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(-0.0))), vreinterpret_vm_vd_advsimd_sleef(vd2gety_vd_vd2_advsimd_sleef(r))))); + + o = vgt_vo_vd_vd_advsimd_sleef(vabs_vd_vd_advsimd_sleef(d), vcast_vd_d_advsimd_sleef(1e+9/4)); + r = vd2setx_vd2_vd2_vd_advsimd_sleef(r, vreinterpret_vd_vm_advsimd_sleef(vandnot_vm_vo64_vm_advsimd_sleef(o, vreinterpret_vm_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(r))))); + r = vd2sety_vd2_vd2_vd_advsimd_sleef(r, vsel_vd_vo_vd_vd_advsimd_sleef(o, vcast_vd_d_advsimd_sleef(1), vd2gety_vd_vd2_advsimd_sleef(r))); + + o = visinf_vo_vd_advsimd_sleef(d); + r = vd2setx_vd2_vd2_vd_advsimd_sleef(r, vreinterpret_vd_vm_advsimd_sleef(vor_vm_vo64_vm_advsimd_sleef(o, vreinterpret_vm_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(r))))); + r = vd2sety_vd2_vd2_vd_advsimd_sleef(r, vreinterpret_vd_vm_advsimd_sleef(vor_vm_vo64_vm_advsimd_sleef(o, vreinterpret_vm_vd_advsimd_sleef(vd2gety_vd_vd2_advsimd_sleef(r))))); + + return r; +} + +SLEEF_INLINE vdouble2_advsimd_sleef Sleef_sincospid2_u35advsimd(vdouble_advsimd_sleef d) { + vopmask_advsimd_sleef o; + vdouble_advsimd_sleef u, s, t, rx, ry; + vdouble2_advsimd_sleef r; + + u = vmul_vd_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(4.0)); + vint_advsimd_sleef q = vtruncate_vi_vd_advsimd_sleef(u); + q = vand_vi_vi_vi_advsimd_sleef(vadd_vi_vi_vi_advsimd_sleef(q, vxor_vi_vi_vi_advsimd_sleef(vreinterpret_s32_u32(vshr_n_u32(vreinterpret_u32_s32(q), 31)), vcast_vi_i_advsimd_sleef(1))), vcast_vi_i_advsimd_sleef(~1)); + s = vsub_vd_vd_vd_advsimd_sleef(u, vcast_vd_vi_advsimd_sleef(q)); + + t = s; + s = vmul_vd_vd_vd_advsimd_sleef(s, s); + + u = vcast_vd_d_advsimd_sleef(+0.6880638894766060136e-11); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, s, vcast_vd_d_advsimd_sleef(-0.1757159564542310199e-8)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, s, vcast_vd_d_advsimd_sleef(+0.3133616327257867311e-6)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, s, vcast_vd_d_advsimd_sleef(-0.3657620416388486452e-4)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, s, vcast_vd_d_advsimd_sleef(+0.2490394570189932103e-2)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, s, vcast_vd_d_advsimd_sleef(-0.8074551218828056320e-1)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, s, vcast_vd_d_advsimd_sleef(+0.7853981633974482790e+0)); + + rx = vmul_vd_vd_vd_advsimd_sleef(u, t); + + u = vcast_vd_d_advsimd_sleef(-0.3860141213683794352e-12); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, s, vcast_vd_d_advsimd_sleef(+0.1150057888029681415e-9)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, s, vcast_vd_d_advsimd_sleef(-0.2461136493006663553e-7)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, s, vcast_vd_d_advsimd_sleef(+0.3590860446623516713e-5)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, s, vcast_vd_d_advsimd_sleef(-0.3259918869269435942e-3)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, s, vcast_vd_d_advsimd_sleef(+0.1585434424381541169e-1)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, s, vcast_vd_d_advsimd_sleef(-0.3084251375340424373e+0)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, s, vcast_vd_d_advsimd_sleef(1)); + + ry = u; + + o = vcast_vo64_vo32_advsimd_sleef(veq_vo_vi_vi_advsimd_sleef(vand_vi_vi_vi_advsimd_sleef(q, vcast_vi_i_advsimd_sleef(2)), vcast_vi_i_advsimd_sleef(0))); + r = vd2setxy_vd2_vd_vd_advsimd_sleef(vsel_vd_vo_vd_vd_advsimd_sleef(o, rx, ry), vsel_vd_vo_vd_vd_advsimd_sleef(o, ry, rx)); + + o = vcast_vo64_vo32_advsimd_sleef(veq_vo_vi_vi_advsimd_sleef(vand_vi_vi_vi_advsimd_sleef(q, vcast_vi_i_advsimd_sleef(4)), vcast_vi_i_advsimd_sleef(4))); + r = vd2setx_vd2_vd2_vd_advsimd_sleef(r, vreinterpret_vd_vm_advsimd_sleef(vxor_vm_vm_vm_advsimd_sleef(vand_vm_vo64_vm_advsimd_sleef(o, vreinterpret_vm_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(-0.0))), vreinterpret_vm_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(r))))); + + o = vcast_vo64_vo32_advsimd_sleef(veq_vo_vi_vi_advsimd_sleef(vand_vi_vi_vi_advsimd_sleef(vadd_vi_vi_vi_advsimd_sleef(q, vcast_vi_i_advsimd_sleef(2)), vcast_vi_i_advsimd_sleef(4)), vcast_vi_i_advsimd_sleef(4))); + r = vd2sety_vd2_vd2_vd_advsimd_sleef(r, vreinterpret_vd_vm_advsimd_sleef(vxor_vm_vm_vm_advsimd_sleef(vand_vm_vo64_vm_advsimd_sleef(o, vreinterpret_vm_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(-0.0))), vreinterpret_vm_vd_advsimd_sleef(vd2gety_vd_vd2_advsimd_sleef(r))))); + + o = vgt_vo_vd_vd_advsimd_sleef(vabs_vd_vd_advsimd_sleef(d), vcast_vd_d_advsimd_sleef(1e+9/4)); + r = vd2setx_vd2_vd2_vd_advsimd_sleef(r, vreinterpret_vd_vm_advsimd_sleef(vandnot_vm_vo64_vm_advsimd_sleef(o, vreinterpret_vm_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(r))))); + r = vd2sety_vd2_vd2_vd_advsimd_sleef(r, vreinterpret_vd_vm_advsimd_sleef(vandnot_vm_vo64_vm_advsimd_sleef(o, vreinterpret_vm_vd_advsimd_sleef(vd2gety_vd_vd2_advsimd_sleef(r))))); + + o = visinf_vo_vd_advsimd_sleef(d); + r = vd2setx_vd2_vd2_vd_advsimd_sleef(r, vreinterpret_vd_vm_advsimd_sleef(vor_vm_vo64_vm_advsimd_sleef(o, vreinterpret_vm_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(r))))); + r = vd2sety_vd2_vd2_vd_advsimd_sleef(r, vreinterpret_vd_vm_advsimd_sleef(vor_vm_vo64_vm_advsimd_sleef(o, vreinterpret_vm_vd_advsimd_sleef(vd2gety_vd_vd2_advsimd_sleef(r))))); + + return r; +} + +SLEEF_INLINE SLEEF_CONST vdouble2_advsimd_sleef Sleef_modfd2_advsimd(vdouble_advsimd_sleef x) { + vdouble_advsimd_sleef fr = vsub_vd_vd_vd_advsimd_sleef(x, vmul_vd_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(INT64_C(1) << 31), vcast_vd_vi_advsimd_sleef(vtruncate_vi_vd_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(x, vcast_vd_d_advsimd_sleef(1.0 / (INT64_C(1) << 31))))))); + fr = vsub_vd_vd_vd_advsimd_sleef(fr, vcast_vd_vi_advsimd_sleef(vtruncate_vi_vd_advsimd_sleef(fr))); + fr = vsel_vd_vo_vd_vd_advsimd_sleef(vgt_vo_vd_vd_advsimd_sleef(vabs_vd_vd_advsimd_sleef(x), vcast_vd_d_advsimd_sleef(INT64_C(1) << 52)), vcast_vd_d_advsimd_sleef(0), fr); + + vdouble2_advsimd_sleef ret; + + ret = vd2setxy_vd2_vd_vd_advsimd_sleef(vcopysign_vd_vd_vd_advsimd_sleef(fr, x), vcopysign_vd_vd_vd_advsimd_sleef(vsub_vd_vd_vd_advsimd_sleef(x, fr), x)); + + return ret; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_advsimd_sleef sinpik_advsimd_sleef(vdouble_advsimd_sleef d) { + vopmask_advsimd_sleef o; + vdouble_advsimd_sleef u, s, t; + vdouble2_advsimd_sleef x, s2; + + u = vmul_vd_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(4.0)); + vint_advsimd_sleef q = vtruncate_vi_vd_advsimd_sleef(u); + q = vand_vi_vi_vi_advsimd_sleef(vadd_vi_vi_vi_advsimd_sleef(q, vxor_vi_vi_vi_advsimd_sleef(vreinterpret_s32_u32(vshr_n_u32(vreinterpret_u32_s32(q), 31)), vcast_vi_i_advsimd_sleef(1))), vcast_vi_i_advsimd_sleef(~1)); + o = vcast_vo64_vo32_advsimd_sleef(veq_vo_vi_vi_advsimd_sleef(vand_vi_vi_vi_advsimd_sleef(q, vcast_vi_i_advsimd_sleef(2)), vcast_vi_i_advsimd_sleef(2))); + + s = vsub_vd_vd_vd_advsimd_sleef(u, vcast_vd_vi_advsimd_sleef(q)); + t = s; + s = vmul_vd_vd_vd_advsimd_sleef(s, s); + s2 = ddmul_vd2_vd_vd_advsimd_sleef(t, t); + + u = vsel_vd_vo_d_d_advsimd_sleef(o, 9.94480387626843774090208e-16, -2.02461120785182399295868e-14); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, s, vsel_vd_vo_d_d_advsimd_sleef(o, -3.89796226062932799164047e-13, 6.948218305801794613277840e-12)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, s, vsel_vd_vo_d_d_advsimd_sleef(o, 1.150115825399960352669010e-10, -1.75724749952853179952664e-09)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, s, vsel_vd_vo_d_d_advsimd_sleef(o, -2.46113695010446974953590e-08, 3.133616889668683928784220e-07)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, s, vsel_vd_vo_d_d_advsimd_sleef(o, 3.590860448590527540050620e-06, -3.65762041821615519203610e-05)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, s, vsel_vd_vo_d_d_advsimd_sleef(o, -0.000325991886927389905997954, 0.0024903945701927185027435600)); + x = ddadd2_vd2_vd_vd2_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(u, s), + vsel_vd2_vo_d_d_d_d_advsimd_sleef(o, 0.0158543442438155018914259, -1.04693272280631521908845e-18, + -0.0807455121882807852484731, 3.61852475067037104849987e-18)); + x = ddadd2_vd2_vd2_vd2_advsimd_sleef(ddmul_vd2_vd2_vd2_advsimd_sleef(s2, x), + vsel_vd2_vo_d_d_d_d_advsimd_sleef(o, -0.308425137534042437259529, -1.95698492133633550338345e-17, + 0.785398163397448278999491, 3.06287113727155002607105e-17)); + + x = ddmul_vd2_vd2_vd2_advsimd_sleef(x, vsel_vd2_vo_vd2_vd2_advsimd_sleef(o, s2, vcast_vd2_vd_vd_advsimd_sleef(t, vcast_vd_d_advsimd_sleef(0)))); + x = vsel_vd2_vo_vd2_vd2_advsimd_sleef(o, ddadd2_vd2_vd2_vd_advsimd_sleef(x, vcast_vd_d_advsimd_sleef(1)), x); + + o = vcast_vo64_vo32_advsimd_sleef(veq_vo_vi_vi_advsimd_sleef(vand_vi_vi_vi_advsimd_sleef(q, vcast_vi_i_advsimd_sleef(4)), vcast_vi_i_advsimd_sleef(4))); + x = vd2setx_vd2_vd2_vd_advsimd_sleef(x, vreinterpret_vd_vm_advsimd_sleef(vxor_vm_vm_vm_advsimd_sleef(vand_vm_vo64_vm_advsimd_sleef(o, vreinterpret_vm_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(-0.0))), vreinterpret_vm_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(x))))); + x = vd2sety_vd2_vd2_vd_advsimd_sleef(x, vreinterpret_vd_vm_advsimd_sleef(vxor_vm_vm_vm_advsimd_sleef(vand_vm_vo64_vm_advsimd_sleef(o, vreinterpret_vm_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(-0.0))), vreinterpret_vm_vd_advsimd_sleef(vd2gety_vd_vd2_advsimd_sleef(x))))); + + return x; +} + +SLEEF_INLINE SLEEF_CONST vdouble_advsimd_sleef Sleef_sinpid2_u05advsimd(vdouble_advsimd_sleef d) { + vdouble2_advsimd_sleef x = sinpik_advsimd_sleef(d); + vdouble_advsimd_sleef r = vadd_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(x), vd2gety_vd_vd2_advsimd_sleef(x)); + + r = vsel_vd_vo_vd_vd_advsimd_sleef(visnegzero_vo_vd_advsimd_sleef(d), vcast_vd_d_advsimd_sleef(-0.0), r); + r = vreinterpret_vd_vm_advsimd_sleef(vandnot_vm_vo64_vm_advsimd_sleef(vgt_vo_vd_vd_advsimd_sleef(vabs_vd_vd_advsimd_sleef(d), vcast_vd_d_advsimd_sleef(1e+9/4)), vreinterpret_vm_vd_advsimd_sleef(r))); + r = vreinterpret_vd_vm_advsimd_sleef(vor_vm_vo64_vm_advsimd_sleef(visinf_vo_vd_advsimd_sleef(d), vreinterpret_vm_vd_advsimd_sleef(r))); + + return r; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_advsimd_sleef cospik_advsimd_sleef(vdouble_advsimd_sleef d) { + vopmask_advsimd_sleef o; + vdouble_advsimd_sleef u, s, t; + vdouble2_advsimd_sleef x, s2; + + u = vmul_vd_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(4.0)); + vint_advsimd_sleef q = vtruncate_vi_vd_advsimd_sleef(u); + q = vand_vi_vi_vi_advsimd_sleef(vadd_vi_vi_vi_advsimd_sleef(q, vxor_vi_vi_vi_advsimd_sleef(vreinterpret_s32_u32(vshr_n_u32(vreinterpret_u32_s32(q), 31)), vcast_vi_i_advsimd_sleef(1))), vcast_vi_i_advsimd_sleef(~1)); + o = vcast_vo64_vo32_advsimd_sleef(veq_vo_vi_vi_advsimd_sleef(vand_vi_vi_vi_advsimd_sleef(q, vcast_vi_i_advsimd_sleef(2)), vcast_vi_i_advsimd_sleef(0))); + + s = vsub_vd_vd_vd_advsimd_sleef(u, vcast_vd_vi_advsimd_sleef(q)); + t = s; + s = vmul_vd_vd_vd_advsimd_sleef(s, s); + s2 = ddmul_vd2_vd_vd_advsimd_sleef(t, t); + + u = vsel_vd_vo_d_d_advsimd_sleef(o, 9.94480387626843774090208e-16, -2.02461120785182399295868e-14); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, s, vsel_vd_vo_d_d_advsimd_sleef(o, -3.89796226062932799164047e-13, 6.948218305801794613277840e-12)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, s, vsel_vd_vo_d_d_advsimd_sleef(o, 1.150115825399960352669010e-10, -1.75724749952853179952664e-09)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, s, vsel_vd_vo_d_d_advsimd_sleef(o, -2.46113695010446974953590e-08, 3.133616889668683928784220e-07)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, s, vsel_vd_vo_d_d_advsimd_sleef(o, 3.590860448590527540050620e-06, -3.65762041821615519203610e-05)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, s, vsel_vd_vo_d_d_advsimd_sleef(o, -0.000325991886927389905997954, 0.0024903945701927185027435600)); + x = ddadd2_vd2_vd_vd2_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(u, s), + vsel_vd2_vo_d_d_d_d_advsimd_sleef(o, 0.0158543442438155018914259, -1.04693272280631521908845e-18, + -0.0807455121882807852484731, 3.61852475067037104849987e-18)); + x = ddadd2_vd2_vd2_vd2_advsimd_sleef(ddmul_vd2_vd2_vd2_advsimd_sleef(s2, x), + vsel_vd2_vo_d_d_d_d_advsimd_sleef(o, -0.308425137534042437259529, -1.95698492133633550338345e-17, + 0.785398163397448278999491, 3.06287113727155002607105e-17)); + + x = ddmul_vd2_vd2_vd2_advsimd_sleef(x, vsel_vd2_vo_vd2_vd2_advsimd_sleef(o, s2, vcast_vd2_vd_vd_advsimd_sleef(t, vcast_vd_d_advsimd_sleef(0)))); + x = vsel_vd2_vo_vd2_vd2_advsimd_sleef(o, ddadd2_vd2_vd2_vd_advsimd_sleef(x, vcast_vd_d_advsimd_sleef(1)), x); + + o = vcast_vo64_vo32_advsimd_sleef(veq_vo_vi_vi_advsimd_sleef(vand_vi_vi_vi_advsimd_sleef(vadd_vi_vi_vi_advsimd_sleef(q, vcast_vi_i_advsimd_sleef(2)), vcast_vi_i_advsimd_sleef(4)), vcast_vi_i_advsimd_sleef(4))); + x = vd2setx_vd2_vd2_vd_advsimd_sleef(x, vreinterpret_vd_vm_advsimd_sleef(vxor_vm_vm_vm_advsimd_sleef(vand_vm_vo64_vm_advsimd_sleef(o, vreinterpret_vm_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(-0.0))), vreinterpret_vm_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(x))))); + x = vd2sety_vd2_vd2_vd_advsimd_sleef(x, vreinterpret_vd_vm_advsimd_sleef(vxor_vm_vm_vm_advsimd_sleef(vand_vm_vo64_vm_advsimd_sleef(o, vreinterpret_vm_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(-0.0))), vreinterpret_vm_vd_advsimd_sleef(vd2gety_vd_vd2_advsimd_sleef(x))))); + + return x; +} + +SLEEF_INLINE SLEEF_CONST vdouble_advsimd_sleef Sleef_cospid2_u05advsimd(vdouble_advsimd_sleef d) { + vdouble2_advsimd_sleef x = cospik_advsimd_sleef(d); + vdouble_advsimd_sleef r = vadd_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(x), vd2gety_vd_vd2_advsimd_sleef(x)); + + r = vsel_vd_vo_vd_vd_advsimd_sleef(vgt_vo_vd_vd_advsimd_sleef(vabs_vd_vd_advsimd_sleef(d), vcast_vd_d_advsimd_sleef(1e+9/4)), vcast_vd_d_advsimd_sleef(1), r); + r = vreinterpret_vd_vm_advsimd_sleef(vor_vm_vo64_vm_advsimd_sleef(visinf_vo_vd_advsimd_sleef(d), vreinterpret_vm_vd_advsimd_sleef(r))); + + return r; +} + +SLEEF_INLINE SLEEF_CONST vdouble_advsimd_sleef Sleef_tand2_u35advsimd(vdouble_advsimd_sleef d) { + + vdouble_advsimd_sleef u, s, x, y; + vopmask_advsimd_sleef o; + vint_advsimd_sleef ql; + + if (__builtin_expect(!!(vtestallones_i_vo64_advsimd_sleef(vlt_vo_vd_vd_advsimd_sleef(vabs_vd_vd_advsimd_sleef(d), vcast_vd_d_advsimd_sleef(15)))), 1)) { + vdouble_advsimd_sleef dql = vrint_vd_vd_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(2 * 0.318309886183790671537767526745028724))); + ql = vrint_vi_vd_advsimd_sleef(dql); + x = vmla_vd_vd_vd_vd_advsimd_sleef(dql, vcast_vd_d_advsimd_sleef(-3.141592653589793116 * 0.5), d); + x = vmla_vd_vd_vd_vd_advsimd_sleef(dql, vcast_vd_d_advsimd_sleef(-1.2246467991473532072e-16 * 0.5), x); + } else if (__builtin_expect(!!(vtestallones_i_vo64_advsimd_sleef(vlt_vo_vd_vd_advsimd_sleef(vabs_vd_vd_advsimd_sleef(d), vcast_vd_d_advsimd_sleef(1e+6)))), 1)) { + vdouble_advsimd_sleef dqh = vtruncate_vd_vd_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(2*0.318309886183790671537767526745028724 / (1 << 24)))); + dqh = vmul_vd_vd_vd_advsimd_sleef(dqh, vcast_vd_d_advsimd_sleef(1 << 24)); + vdouble_advsimd_sleef dql = vrint_vd_vd_advsimd_sleef(vsub_vd_vd_vd_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(2*0.318309886183790671537767526745028724)), dqh)); + ql = vrint_vi_vd_advsimd_sleef(dql); + + x = vmla_vd_vd_vd_vd_advsimd_sleef(dqh, vcast_vd_d_advsimd_sleef(-3.1415926218032836914 * 0.5), d); + x = vmla_vd_vd_vd_vd_advsimd_sleef(dql, vcast_vd_d_advsimd_sleef(-3.1415926218032836914 * 0.5), x); + x = vmla_vd_vd_vd_vd_advsimd_sleef(dqh, vcast_vd_d_advsimd_sleef(-3.1786509424591713469e-08 * 0.5), x); + x = vmla_vd_vd_vd_vd_advsimd_sleef(dql, vcast_vd_d_advsimd_sleef(-3.1786509424591713469e-08 * 0.5), x); + x = vmla_vd_vd_vd_vd_advsimd_sleef(dqh, vcast_vd_d_advsimd_sleef(-1.2246467864107188502e-16 * 0.5), x); + x = vmla_vd_vd_vd_vd_advsimd_sleef(dql, vcast_vd_d_advsimd_sleef(-1.2246467864107188502e-16 * 0.5), x); + x = vmla_vd_vd_vd_vd_advsimd_sleef(vadd_vd_vd_vd_advsimd_sleef(dqh, dql), vcast_vd_d_advsimd_sleef(-1.2736634327021899816e-24 * 0.5), x); + } else { + ddi_t_advsimd_sleef ddi_advsimd_sleef = rempi_advsimd_sleef(d); + ql = ddigeti_vi_ddi_advsimd_sleef(ddi_advsimd_sleef); + x = vadd_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(ddigetdd_vd2_ddi_advsimd_sleef(ddi_advsimd_sleef)), vd2gety_vd_vd2_advsimd_sleef(ddigetdd_vd2_ddi_advsimd_sleef(ddi_advsimd_sleef))); + x = vreinterpret_vd_vm_advsimd_sleef(vor_vm_vo64_vm_advsimd_sleef(visinf_vo_vd_advsimd_sleef(d), vreinterpret_vm_vd_advsimd_sleef(x))); + x = vreinterpret_vd_vm_advsimd_sleef(vor_vm_vo64_vm_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(visinf_vo_vd_advsimd_sleef(d), visnan_vo_vd_advsimd_sleef(d)), vreinterpret_vm_vd_advsimd_sleef(x))); + } + + x = vmul_vd_vd_vd_advsimd_sleef(x, vcast_vd_d_advsimd_sleef(0.5)); + s = vmul_vd_vd_vd_advsimd_sleef(x, x); + + vdouble_advsimd_sleef s2 = vmul_vd_vd_vd_advsimd_sleef(s, s), s4 = vmul_vd_vd_vd_advsimd_sleef(s2, s2); + u = vmla_vd_vd_vd_vd_advsimd_sleef((s4), (vmla_vd_vd_vd_vd_advsimd_sleef((s2), (vmla_vd_vd_vd_vd_advsimd_sleef((s), (vcast_vd_d_advsimd_sleef(+0.3245098826639276316e-3)), (vcast_vd_d_advsimd_sleef(+0.5619219738114323735e-3)))), (vmla_vd_vd_vd_vd_advsimd_sleef((s), (vcast_vd_d_advsimd_sleef(+0.1460781502402784494e-2)), (vcast_vd_d_advsimd_sleef(+0.3591611540792499519e-2)))))), (vmla_vd_vd_vd_vd_advsimd_sleef((s2), (vmla_vd_vd_vd_vd_advsimd_sleef((s), (vcast_vd_d_advsimd_sleef(+0.8863268409563113126e-2)), (vcast_vd_d_advsimd_sleef(+0.2186948728185535498e-1)))), (vmla_vd_vd_vd_vd_advsimd_sleef((s), (vcast_vd_d_advsimd_sleef(+0.5396825399517272970e-1)), (vcast_vd_d_advsimd_sleef(+0.1333333333330500581e+0))))))) + + ; + + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, s, vcast_vd_d_advsimd_sleef(+0.3333333333333343695e+0)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(s, vmul_vd_vd_vd_advsimd_sleef(u, x), x); + + y = vmla_vd_vd_vd_vd_advsimd_sleef(u, u, vcast_vd_d_advsimd_sleef(-1)); + x = vmul_vd_vd_vd_advsimd_sleef(u, vcast_vd_d_advsimd_sleef(-2)); + + o = vcast_vo64_vo32_advsimd_sleef(veq_vo_vi_vi_advsimd_sleef(vand_vi_vi_vi_advsimd_sleef(ql, vcast_vi_i_advsimd_sleef(1)), vcast_vi_i_advsimd_sleef(1))); + u = vdiv_vd_vd_vd_advsimd_sleef(vsel_vd_vo_vd_vd_advsimd_sleef(o, vneg_vd_vd_advsimd_sleef(y), x), + vsel_vd_vo_vd_vd_advsimd_sleef(o, x, y)); + u = vsel_vd_vo_vd_vd_advsimd_sleef(veq_vo_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(0)), d, u); + + return u; + +} + +SLEEF_INLINE SLEEF_CONST vdouble_advsimd_sleef Sleef_tand2_u10advsimd(vdouble_advsimd_sleef d) { + + vdouble_advsimd_sleef u; + vdouble2_advsimd_sleef s, t, x, y; + vopmask_advsimd_sleef o; + vint_advsimd_sleef ql; + + if (__builtin_expect(!!(vtestallones_i_vo64_advsimd_sleef(vlt_vo_vd_vd_advsimd_sleef(vabs_vd_vd_advsimd_sleef(d), vcast_vd_d_advsimd_sleef(15)))), 1)) { + vdouble_advsimd_sleef dql = vrint_vd_vd_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(2 * 0.318309886183790671537767526745028724))); + ql = vrint_vi_vd_advsimd_sleef(dql); + u = vmla_vd_vd_vd_vd_advsimd_sleef(dql, vcast_vd_d_advsimd_sleef(-3.141592653589793116*0.5), d); + s = ddadd_vd2_vd_vd_advsimd_sleef (u, vmul_vd_vd_vd_advsimd_sleef(dql, vcast_vd_d_advsimd_sleef(-1.2246467991473532072e-16*0.5))); + } else if (__builtin_expect(!!(vtestallones_i_vo64_advsimd_sleef(vlt_vo_vd_vd_advsimd_sleef(vabs_vd_vd_advsimd_sleef(d), vcast_vd_d_advsimd_sleef(1e+14)))), 1)) { + vdouble_advsimd_sleef dqh = vtruncate_vd_vd_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(2*0.318309886183790671537767526745028724 / (1 << 24)))); + dqh = vmul_vd_vd_vd_advsimd_sleef(dqh, vcast_vd_d_advsimd_sleef(1 << 24)); + s = ddadd2_vd2_vd2_vd_advsimd_sleef(ddmul_vd2_vd2_vd_advsimd_sleef(vcast_vd2_d_d_advsimd_sleef(0.63661977236758138243, -3.9357353350364971764e-17), d), + vsub_vd_vd_vd_advsimd_sleef(vsel_vd_vo_vd_vd_advsimd_sleef(vlt_vo_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(0)), + vcast_vd_d_advsimd_sleef(-0.5), vcast_vd_d_advsimd_sleef(0.5)), dqh)); + const vdouble_advsimd_sleef dql = vtruncate_vd_vd_advsimd_sleef(vadd_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(s), vd2gety_vd_vd2_advsimd_sleef(s))); + ql = vrint_vi_vd_advsimd_sleef(dql); + + u = vmla_vd_vd_vd_vd_advsimd_sleef(dqh, vcast_vd_d_advsimd_sleef(-3.1415926218032836914 * 0.5), d); + s = ddadd_vd2_vd_vd_advsimd_sleef(u, vmul_vd_vd_vd_advsimd_sleef(dql, vcast_vd_d_advsimd_sleef(-3.1415926218032836914*0.5 ))); + s = ddadd2_vd2_vd2_vd_advsimd_sleef(s, vmul_vd_vd_vd_advsimd_sleef(dqh, vcast_vd_d_advsimd_sleef(-3.1786509424591713469e-08*0.5))); + s = ddadd2_vd2_vd2_vd_advsimd_sleef(s, vmul_vd_vd_vd_advsimd_sleef(dql, vcast_vd_d_advsimd_sleef(-3.1786509424591713469e-08*0.5 ))); + s = ddadd2_vd2_vd2_vd_advsimd_sleef(s, vmul_vd_vd_vd_advsimd_sleef(dqh, vcast_vd_d_advsimd_sleef(-1.2246467864107188502e-16*0.5))); + s = ddadd2_vd2_vd2_vd_advsimd_sleef(s, vmul_vd_vd_vd_advsimd_sleef(dql, vcast_vd_d_advsimd_sleef(-1.2246467864107188502e-16*0.5 ))); + s = ddadd_vd2_vd2_vd_advsimd_sleef(s, vmul_vd_vd_vd_advsimd_sleef(vadd_vd_vd_vd_advsimd_sleef(dqh, dql), vcast_vd_d_advsimd_sleef(-1.2736634327021899816e-24*0.5))); + } else { + ddi_t_advsimd_sleef ddi_advsimd_sleef = rempi_advsimd_sleef(d); + ql = ddigeti_vi_ddi_advsimd_sleef(ddi_advsimd_sleef); + s = ddigetdd_vd2_ddi_advsimd_sleef(ddi_advsimd_sleef); + o = vor_vo_vo_vo_advsimd_sleef(visinf_vo_vd_advsimd_sleef(d), visnan_vo_vd_advsimd_sleef(d)); + s = vd2setx_vd2_vd2_vd_advsimd_sleef(s, vreinterpret_vd_vm_advsimd_sleef(vor_vm_vo64_vm_advsimd_sleef(o, vreinterpret_vm_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(s))))); + s = vd2sety_vd2_vd2_vd_advsimd_sleef(s, vreinterpret_vd_vm_advsimd_sleef(vor_vm_vo64_vm_advsimd_sleef(o, vreinterpret_vm_vd_advsimd_sleef(vd2gety_vd_vd2_advsimd_sleef(s))))); + } + + t = ddscale_vd2_vd2_vd_advsimd_sleef(s, vcast_vd_d_advsimd_sleef(0.5)); + s = ddsqu_vd2_vd2_advsimd_sleef(t); + + vdouble_advsimd_sleef s2 = vmul_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(s), vd2getx_vd_vd2_advsimd_sleef(s)), s4 = vmul_vd_vd_vd_advsimd_sleef(s2, s2); + u = vmla_vd_vd_vd_vd_advsimd_sleef((s4), (vmla_vd_vd_vd_vd_advsimd_sleef((s2), (vmla_vd_vd_vd_vd_advsimd_sleef((vd2getx_vd_vd2_advsimd_sleef(s)), (vcast_vd_d_advsimd_sleef(+0.3245098826639276316e-3)), (vcast_vd_d_advsimd_sleef(+0.5619219738114323735e-3)))), (vmla_vd_vd_vd_vd_advsimd_sleef((vd2getx_vd_vd2_advsimd_sleef(s)), (vcast_vd_d_advsimd_sleef(+0.1460781502402784494e-2)), (vcast_vd_d_advsimd_sleef(+0.3591611540792499519e-2)))))), (vmla_vd_vd_vd_vd_advsimd_sleef((s2), (vmla_vd_vd_vd_vd_advsimd_sleef((vd2getx_vd_vd2_advsimd_sleef(s)), (vcast_vd_d_advsimd_sleef(+0.8863268409563113126e-2)), (vcast_vd_d_advsimd_sleef(+0.2186948728185535498e-1)))), (vmla_vd_vd_vd_vd_advsimd_sleef((vd2getx_vd_vd2_advsimd_sleef(s)), (vcast_vd_d_advsimd_sleef(+0.5396825399517272970e-1)), (vcast_vd_d_advsimd_sleef(+0.1333333333330500581e+0))))))) + + ; + + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, vd2getx_vd_vd2_advsimd_sleef(s), vcast_vd_d_advsimd_sleef(+0.3333333333333343695e+0)); + x = ddadd_vd2_vd2_vd2_advsimd_sleef(t, ddmul_vd2_vd2_vd_advsimd_sleef(ddmul_vd2_vd2_vd2_advsimd_sleef(s, t), u)); + + y = ddadd_vd2_vd_vd2_advsimd_sleef(vcast_vd_d_advsimd_sleef(-1), ddsqu_vd2_vd2_advsimd_sleef(x)); + x = ddscale_vd2_vd2_vd_advsimd_sleef(x, vcast_vd_d_advsimd_sleef(-2)); + + o = vcast_vo64_vo32_advsimd_sleef(veq_vo_vi_vi_advsimd_sleef(vand_vi_vi_vi_advsimd_sleef(ql, vcast_vi_i_advsimd_sleef(1)), vcast_vi_i_advsimd_sleef(1))); + + x = dddiv_vd2_vd2_vd2_advsimd_sleef(vsel_vd2_vo_vd2_vd2_advsimd_sleef(o, ddneg_vd2_vd2_advsimd_sleef(y), x), + vsel_vd2_vo_vd2_vd2_advsimd_sleef(o, x, y)); + + u = vadd_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(x), vd2gety_vd_vd2_advsimd_sleef(x)); + + u = vsel_vd_vo_vd_vd_advsimd_sleef(veq_vo_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(0)), d, u); + + return u; + +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_advsimd_sleef atan2k_advsimd_sleef(vdouble_advsimd_sleef y, vdouble_advsimd_sleef x) { + vdouble_advsimd_sleef s, t, u; + vint_advsimd_sleef q; + vopmask_advsimd_sleef p; + + q = vsel_vi_vd_vi_advsimd_sleef(x, vcast_vi_i_advsimd_sleef(-2)); + x = vabs_vd_vd_advsimd_sleef(x); + + q = vsel_vi_vd_vd_vi_vi_advsimd_sleef(x, y, vadd_vi_vi_vi_advsimd_sleef(q, vcast_vi_i_advsimd_sleef(1)), q); + p = vlt_vo_vd_vd_advsimd_sleef(x, y); + s = vsel_vd_vo_vd_vd_advsimd_sleef(p, vneg_vd_vd_advsimd_sleef(x), y); + t = vmax_vd_vd_vd_advsimd_sleef(x, y); + + s = vdiv_vd_vd_vd_advsimd_sleef(s, t); + t = vmul_vd_vd_vd_advsimd_sleef(s, s); + + vdouble_advsimd_sleef t2 = vmul_vd_vd_vd_advsimd_sleef(t, t), t4 = vmul_vd_vd_vd_advsimd_sleef(t2, t2), t8 = vmul_vd_vd_vd_advsimd_sleef(t4, t4), t16 = vmul_vd_vd_vd_advsimd_sleef(t8, t8); + u = vmla_vd_vd_vd_vd_advsimd_sleef((t16), (vmla_vd_vd_vd_vd_advsimd_sleef((t2), (vcast_vd_d_advsimd_sleef(-1.88796008463073496563746e-05)), (vmla_vd_vd_vd_vd_advsimd_sleef((t), (vcast_vd_d_advsimd_sleef(0.000209850076645816976906797)), (vcast_vd_d_advsimd_sleef(-0.00110611831486672482563471)))))), (vmla_vd_vd_vd_vd_advsimd_sleef((t8), (vmla_vd_vd_vd_vd_advsimd_sleef((t4), (vmla_vd_vd_vd_vd_advsimd_sleef((t2), (vmla_vd_vd_vd_vd_advsimd_sleef((t), (vcast_vd_d_advsimd_sleef(0.00370026744188713119232403)), (vcast_vd_d_advsimd_sleef(-0.00889896195887655491740809)))), (vmla_vd_vd_vd_vd_advsimd_sleef((t), (vcast_vd_d_advsimd_sleef(0.016599329773529201970117)), (vcast_vd_d_advsimd_sleef(-0.0254517624932312641616861)))))), (vmla_vd_vd_vd_vd_advsimd_sleef((t2), (vmla_vd_vd_vd_vd_advsimd_sleef((t), (vcast_vd_d_advsimd_sleef(0.0337852580001353069993897)), (vcast_vd_d_advsimd_sleef(-0.0407629191276836500001934)))), (vmla_vd_vd_vd_vd_advsimd_sleef((t), (vcast_vd_d_advsimd_sleef(0.0466667150077840625632675)), (vcast_vd_d_advsimd_sleef(-0.0523674852303482457616113)))))))), (vmla_vd_vd_vd_vd_advsimd_sleef((t4), (vmla_vd_vd_vd_vd_advsimd_sleef((t2), (vmla_vd_vd_vd_vd_advsimd_sleef((t), (vcast_vd_d_advsimd_sleef(0.0587666392926673580854313)), (vcast_vd_d_advsimd_sleef(-0.0666573579361080525984562)))), (vmla_vd_vd_vd_vd_advsimd_sleef((t), (vcast_vd_d_advsimd_sleef(0.0769219538311769618355029)), (vcast_vd_d_advsimd_sleef(-0.090908995008245008229153)))))), (vmla_vd_vd_vd_vd_advsimd_sleef((t2), (vmla_vd_vd_vd_vd_advsimd_sleef((t), (vcast_vd_d_advsimd_sleef(0.111111105648261418443745)), (vcast_vd_d_advsimd_sleef(-0.14285714266771329383765)))), (vmla_vd_vd_vd_vd_advsimd_sleef((t), (vcast_vd_d_advsimd_sleef(0.199999999996591265594148)), (vcast_vd_d_advsimd_sleef(-0.333333333333311110369124))))))))))) + + ; + + t = vmla_vd_vd_vd_vd_advsimd_sleef(s, vmul_vd_vd_vd_advsimd_sleef(t, u), s); + t = vmla_vd_vd_vd_vd_advsimd_sleef(vcast_vd_vi_advsimd_sleef(q), vcast_vd_d_advsimd_sleef(3.141592653589793238462643383279502884/2), t); + + return t; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_advsimd_sleef atan2k_u1_advsimd_sleef(vdouble2_advsimd_sleef y, vdouble2_advsimd_sleef x) { + vdouble_advsimd_sleef u; + vdouble2_advsimd_sleef s, t; + vint_advsimd_sleef q; + vopmask_advsimd_sleef p; + + q = vsel_vi_vd_vi_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(x), vcast_vi_i_advsimd_sleef(-2)); + p = vlt_vo_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(x), vcast_vd_d_advsimd_sleef(0)); + vmask_advsimd_sleef b = vand_vm_vo64_vm_advsimd_sleef(p, vreinterpret_vm_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(-0.0))); + x = vd2setx_vd2_vd2_vd_advsimd_sleef(x, vreinterpret_vd_vm_advsimd_sleef(vxor_vm_vm_vm_advsimd_sleef(b, vreinterpret_vm_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(x))))); + x = vd2sety_vd2_vd2_vd_advsimd_sleef(x, vreinterpret_vd_vm_advsimd_sleef(vxor_vm_vm_vm_advsimd_sleef(b, vreinterpret_vm_vd_advsimd_sleef(vd2gety_vd_vd2_advsimd_sleef(x))))); + + q = vsel_vi_vd_vd_vi_vi_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(x), vd2getx_vd_vd2_advsimd_sleef(y), vadd_vi_vi_vi_advsimd_sleef(q, vcast_vi_i_advsimd_sleef(1)), q); + p = vlt_vo_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(x), vd2getx_vd_vd2_advsimd_sleef(y)); + s = vsel_vd2_vo_vd2_vd2_advsimd_sleef(p, ddneg_vd2_vd2_advsimd_sleef(x), y); + t = vsel_vd2_vo_vd2_vd2_advsimd_sleef(p, y, x); + + s = dddiv_vd2_vd2_vd2_advsimd_sleef(s, t); + t = ddsqu_vd2_vd2_advsimd_sleef(s); + t = ddnormalize_vd2_vd2_advsimd_sleef(t); + + vdouble_advsimd_sleef t2 = vmul_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(t), vd2getx_vd_vd2_advsimd_sleef(t)), t4 = vmul_vd_vd_vd_advsimd_sleef(t2, t2), t8 = vmul_vd_vd_vd_advsimd_sleef(t4, t4); + u = vmla_vd_vd_vd_vd_advsimd_sleef((t8), (vmla_vd_vd_vd_vd_advsimd_sleef((t4), (vmla_vd_vd_vd_vd_advsimd_sleef((t2), (vmla_vd_vd_vd_vd_advsimd_sleef((vd2getx_vd_vd2_advsimd_sleef(t)), (vcast_vd_d_advsimd_sleef(1.06298484191448746607415e-05)), (vcast_vd_d_advsimd_sleef(-0.000125620649967286867384336)))), (vmla_vd_vd_vd_vd_advsimd_sleef((vd2getx_vd_vd2_advsimd_sleef(t)), (vcast_vd_d_advsimd_sleef(0.00070557664296393412389774)), (vcast_vd_d_advsimd_sleef(-0.00251865614498713360352999)))))), (vmla_vd_vd_vd_vd_advsimd_sleef((t2), (vmla_vd_vd_vd_vd_advsimd_sleef((vd2getx_vd_vd2_advsimd_sleef(t)), (vcast_vd_d_advsimd_sleef(0.00646262899036991172313504)), (vcast_vd_d_advsimd_sleef(-0.0128281333663399031014274)))), (vmla_vd_vd_vd_vd_advsimd_sleef((vd2getx_vd_vd2_advsimd_sleef(t)), (vcast_vd_d_advsimd_sleef(0.0208024799924145797902497)), (vcast_vd_d_advsimd_sleef(-0.0289002344784740315686289)))))))), (vmla_vd_vd_vd_vd_advsimd_sleef((t4), (vmla_vd_vd_vd_vd_advsimd_sleef((t2), (vmla_vd_vd_vd_vd_advsimd_sleef((vd2getx_vd_vd2_advsimd_sleef(t)), (vcast_vd_d_advsimd_sleef(0.0359785005035104590853656)), (vcast_vd_d_advsimd_sleef(-0.041848579703592507506027)))), (vmla_vd_vd_vd_vd_advsimd_sleef((vd2getx_vd_vd2_advsimd_sleef(t)), (vcast_vd_d_advsimd_sleef(0.0470843011653283988193763)), (vcast_vd_d_advsimd_sleef(-0.0524914210588448421068719)))))), (vmla_vd_vd_vd_vd_advsimd_sleef((t2), (vmla_vd_vd_vd_vd_advsimd_sleef((vd2getx_vd_vd2_advsimd_sleef(t)), (vcast_vd_d_advsimd_sleef(0.0587946590969581003860434)), (vcast_vd_d_advsimd_sleef(-0.0666620884778795497194182)))), (vmla_vd_vd_vd_vd_advsimd_sleef((vd2getx_vd_vd2_advsimd_sleef(t)), (vcast_vd_d_advsimd_sleef(0.0769225330296203768654095)), (vcast_vd_d_advsimd_sleef(-0.0909090442773387574781907))))))))) + + ; + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, vd2getx_vd_vd2_advsimd_sleef(t), vcast_vd_d_advsimd_sleef(0.111111108376896236538123)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, vd2getx_vd_vd2_advsimd_sleef(t), vcast_vd_d_advsimd_sleef(-0.142857142756268568062339)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, vd2getx_vd_vd2_advsimd_sleef(t), vcast_vd_d_advsimd_sleef(0.199999999997977351284817)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, vd2getx_vd_vd2_advsimd_sleef(t), vcast_vd_d_advsimd_sleef(-0.333333333333317605173818)); + + t = ddadd_vd2_vd2_vd2_advsimd_sleef(s, ddmul_vd2_vd2_vd_advsimd_sleef(ddmul_vd2_vd2_vd2_advsimd_sleef(s, t), u)); + + t = ddadd_vd2_vd2_vd2_advsimd_sleef(ddmul_vd2_vd2_vd_advsimd_sleef(vcast_vd2_d_d_advsimd_sleef(1.570796326794896557998982, 6.12323399573676603586882e-17), vcast_vd_vi_advsimd_sleef(q)), t); + + return t; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_advsimd_sleef visinf2_vd_vd_vd_advsimd_sleef(vdouble_advsimd_sleef d, vdouble_advsimd_sleef m) { + return vreinterpret_vd_vm_advsimd_sleef(vand_vm_vo64_vm_advsimd_sleef(visinf_vo_vd_advsimd_sleef(d), vor_vm_vm_vm_advsimd_sleef(vand_vm_vm_vm_advsimd_sleef(vreinterpret_vm_vd_advsimd_sleef(d), vreinterpret_vm_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(-0.0))), vreinterpret_vm_vd_advsimd_sleef(m)))); +} + +SLEEF_INLINE SLEEF_CONST vdouble_advsimd_sleef Sleef_atan2d2_u35advsimd(vdouble_advsimd_sleef y, vdouble_advsimd_sleef x) { + vdouble_advsimd_sleef r = atan2k_advsimd_sleef(vabs_vd_vd_advsimd_sleef(y), x); + + r = vmulsign_vd_vd_vd_advsimd_sleef(r, x); + r = vsel_vd_vo_vd_vd_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(visinf_vo_vd_advsimd_sleef(x), veq_vo_vd_vd_advsimd_sleef(x, vcast_vd_d_advsimd_sleef(0))), vsub_vd_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(3.141592653589793238462643383279502884/2), visinf2_vd_vd_vd_advsimd_sleef(x, vmulsign_vd_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(3.141592653589793238462643383279502884/2), x))), r); + r = vsel_vd_vo_vd_vd_advsimd_sleef(visinf_vo_vd_advsimd_sleef(y), vsub_vd_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(3.141592653589793238462643383279502884/2), visinf2_vd_vd_vd_advsimd_sleef(x, vmulsign_vd_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(3.141592653589793238462643383279502884/4), x))), r); + r = vsel_vd_vo_vd_vd_advsimd_sleef(veq_vo_vd_vd_advsimd_sleef(y, vcast_vd_d_advsimd_sleef(0.0)), vreinterpret_vd_vm_advsimd_sleef(vand_vm_vo64_vm_advsimd_sleef(vsignbit_vo_vd_advsimd_sleef(x), vreinterpret_vm_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(3.141592653589793238462643383279502884)))), r); + + r = vreinterpret_vd_vm_advsimd_sleef(vor_vm_vo64_vm_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(visnan_vo_vd_advsimd_sleef(x), visnan_vo_vd_advsimd_sleef(y)), vreinterpret_vm_vd_advsimd_sleef(vmulsign_vd_vd_vd_advsimd_sleef(r, y)))); + return r; +} + +SLEEF_INLINE SLEEF_CONST vdouble_advsimd_sleef Sleef_atan2d2_u10advsimd(vdouble_advsimd_sleef y, vdouble_advsimd_sleef x) { + vopmask_advsimd_sleef o = vlt_vo_vd_vd_advsimd_sleef(vabs_vd_vd_advsimd_sleef(x), vcast_vd_d_advsimd_sleef(5.5626846462680083984e-309)); + x = vsel_vd_vo_vd_vd_advsimd_sleef(o, vmul_vd_vd_vd_advsimd_sleef(x, vcast_vd_d_advsimd_sleef(UINT64_C(1) << 53)), x); + y = vsel_vd_vo_vd_vd_advsimd_sleef(o, vmul_vd_vd_vd_advsimd_sleef(y, vcast_vd_d_advsimd_sleef(UINT64_C(1) << 53)), y); + + vdouble2_advsimd_sleef d = atan2k_u1_advsimd_sleef(vcast_vd2_vd_vd_advsimd_sleef(vabs_vd_vd_advsimd_sleef(y), vcast_vd_d_advsimd_sleef(0)), vcast_vd2_vd_vd_advsimd_sleef(x, vcast_vd_d_advsimd_sleef(0))); + vdouble_advsimd_sleef r = vadd_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(d), vd2gety_vd_vd2_advsimd_sleef(d)); + + r = vmulsign_vd_vd_vd_advsimd_sleef(r, x); + r = vsel_vd_vo_vd_vd_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(visinf_vo_vd_advsimd_sleef(x), veq_vo_vd_vd_advsimd_sleef(x, vcast_vd_d_advsimd_sleef(0))), vsub_vd_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(3.141592653589793238462643383279502884/2), visinf2_vd_vd_vd_advsimd_sleef(x, vmulsign_vd_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(3.141592653589793238462643383279502884/2), x))), r); + r = vsel_vd_vo_vd_vd_advsimd_sleef(visinf_vo_vd_advsimd_sleef(y), vsub_vd_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(3.141592653589793238462643383279502884/2), visinf2_vd_vd_vd_advsimd_sleef(x, vmulsign_vd_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(3.141592653589793238462643383279502884/4), x))), r); + r = vsel_vd_vo_vd_vd_advsimd_sleef(veq_vo_vd_vd_advsimd_sleef(y, vcast_vd_d_advsimd_sleef(0.0)), vreinterpret_vd_vm_advsimd_sleef(vand_vm_vo64_vm_advsimd_sleef(vsignbit_vo_vd_advsimd_sleef(x), vreinterpret_vm_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(3.141592653589793238462643383279502884)))), r); + + r = vreinterpret_vd_vm_advsimd_sleef(vor_vm_vo64_vm_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(visnan_vo_vd_advsimd_sleef(x), visnan_vo_vd_advsimd_sleef(y)), vreinterpret_vm_vd_advsimd_sleef(vmulsign_vd_vd_vd_advsimd_sleef(r, y)))); + return r; +} + +SLEEF_INLINE SLEEF_CONST vdouble_advsimd_sleef Sleef_asind2_u35advsimd(vdouble_advsimd_sleef d) { + vopmask_advsimd_sleef o = vlt_vo_vd_vd_advsimd_sleef(vabs_vd_vd_advsimd_sleef(d), vcast_vd_d_advsimd_sleef(0.5)); + vdouble_advsimd_sleef x2 = vsel_vd_vo_vd_vd_advsimd_sleef(o, vmul_vd_vd_vd_advsimd_sleef(d, d), vmul_vd_vd_vd_advsimd_sleef(vsub_vd_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(1), vabs_vd_vd_advsimd_sleef(d)), vcast_vd_d_advsimd_sleef(0.5))); + vdouble_advsimd_sleef x = vsel_vd_vo_vd_vd_advsimd_sleef(o, vabs_vd_vd_advsimd_sleef(d), vsqrt_vd_vd_advsimd_sleef(x2)), u; + + vdouble_advsimd_sleef x4 = vmul_vd_vd_vd_advsimd_sleef(x2, x2), x8 = vmul_vd_vd_vd_advsimd_sleef(x4, x4), x16 = vmul_vd_vd_vd_advsimd_sleef(x8, x8); + u = vmla_vd_vd_vd_vd_advsimd_sleef((x16), (vmla_vd_vd_vd_vd_advsimd_sleef((x4), (vmla_vd_vd_vd_vd_advsimd_sleef((x2), (vcast_vd_d_advsimd_sleef(+0.3161587650653934628e-1)), (vcast_vd_d_advsimd_sleef(-0.1581918243329996643e-1)))), (vmla_vd_vd_vd_vd_advsimd_sleef((x2), (vcast_vd_d_advsimd_sleef(+0.1929045477267910674e-1)), (vcast_vd_d_advsimd_sleef(+0.6606077476277170610e-2)))))), (vmla_vd_vd_vd_vd_advsimd_sleef((x8), (vmla_vd_vd_vd_vd_advsimd_sleef((x4), (vmla_vd_vd_vd_vd_advsimd_sleef((x2), (vcast_vd_d_advsimd_sleef(+0.1215360525577377331e-1)), (vcast_vd_d_advsimd_sleef(+0.1388715184501609218e-1)))), (vmla_vd_vd_vd_vd_advsimd_sleef((x2), (vcast_vd_d_advsimd_sleef(+0.1735956991223614604e-1)), (vcast_vd_d_advsimd_sleef(+0.2237176181932048341e-1)))))), (vmla_vd_vd_vd_vd_advsimd_sleef((x4), (vmla_vd_vd_vd_vd_advsimd_sleef((x2), (vcast_vd_d_advsimd_sleef(+0.3038195928038132237e-1)), (vcast_vd_d_advsimd_sleef(+0.4464285681377102438e-1)))), (vmla_vd_vd_vd_vd_advsimd_sleef((x2), (vcast_vd_d_advsimd_sleef(+0.7500000000378581611e-1)), (vcast_vd_d_advsimd_sleef(+0.1666666666666497543e+0))))))))) + + ; + + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, vmul_vd_vd_vd_advsimd_sleef(x, x2), x); + + vdouble_advsimd_sleef r = vsel_vd_vo_vd_vd_advsimd_sleef(o, u, vmla_vd_vd_vd_vd_advsimd_sleef(u, vcast_vd_d_advsimd_sleef(-2), vcast_vd_d_advsimd_sleef(3.141592653589793238462643383279502884/2))); + return vmulsign_vd_vd_vd_advsimd_sleef(r, d); +} + +SLEEF_INLINE SLEEF_CONST vdouble_advsimd_sleef Sleef_asind2_u10advsimd(vdouble_advsimd_sleef d) { + vopmask_advsimd_sleef o = vlt_vo_vd_vd_advsimd_sleef(vabs_vd_vd_advsimd_sleef(d), vcast_vd_d_advsimd_sleef(0.5)); + vdouble_advsimd_sleef x2 = vsel_vd_vo_vd_vd_advsimd_sleef(o, vmul_vd_vd_vd_advsimd_sleef(d, d), vmul_vd_vd_vd_advsimd_sleef(vsub_vd_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(1), vabs_vd_vd_advsimd_sleef(d)), vcast_vd_d_advsimd_sleef(0.5))), u; + vdouble2_advsimd_sleef x = vsel_vd2_vo_vd2_vd2_advsimd_sleef(o, vcast_vd2_vd_vd_advsimd_sleef(vabs_vd_vd_advsimd_sleef(d), vcast_vd_d_advsimd_sleef(0)), ddsqrt_vd2_vd_advsimd_sleef(x2)); + x = vsel_vd2_vo_vd2_vd2_advsimd_sleef(veq_vo_vd_vd_advsimd_sleef(vabs_vd_vd_advsimd_sleef(d), vcast_vd_d_advsimd_sleef(1.0)), vcast_vd2_d_d_advsimd_sleef(0, 0), x); + + vdouble_advsimd_sleef x4 = vmul_vd_vd_vd_advsimd_sleef(x2, x2), x8 = vmul_vd_vd_vd_advsimd_sleef(x4, x4), x16 = vmul_vd_vd_vd_advsimd_sleef(x8, x8); + u = vmla_vd_vd_vd_vd_advsimd_sleef((x16), (vmla_vd_vd_vd_vd_advsimd_sleef((x4), (vmla_vd_vd_vd_vd_advsimd_sleef((x2), (vcast_vd_d_advsimd_sleef(+0.3161587650653934628e-1)), (vcast_vd_d_advsimd_sleef(-0.1581918243329996643e-1)))), (vmla_vd_vd_vd_vd_advsimd_sleef((x2), (vcast_vd_d_advsimd_sleef(+0.1929045477267910674e-1)), (vcast_vd_d_advsimd_sleef(+0.6606077476277170610e-2)))))), (vmla_vd_vd_vd_vd_advsimd_sleef((x8), (vmla_vd_vd_vd_vd_advsimd_sleef((x4), (vmla_vd_vd_vd_vd_advsimd_sleef((x2), (vcast_vd_d_advsimd_sleef(+0.1215360525577377331e-1)), (vcast_vd_d_advsimd_sleef(+0.1388715184501609218e-1)))), (vmla_vd_vd_vd_vd_advsimd_sleef((x2), (vcast_vd_d_advsimd_sleef(+0.1735956991223614604e-1)), (vcast_vd_d_advsimd_sleef(+0.2237176181932048341e-1)))))), (vmla_vd_vd_vd_vd_advsimd_sleef((x4), (vmla_vd_vd_vd_vd_advsimd_sleef((x2), (vcast_vd_d_advsimd_sleef(+0.3038195928038132237e-1)), (vcast_vd_d_advsimd_sleef(+0.4464285681377102438e-1)))), (vmla_vd_vd_vd_vd_advsimd_sleef((x2), (vcast_vd_d_advsimd_sleef(+0.7500000000378581611e-1)), (vcast_vd_d_advsimd_sleef(+0.1666666666666497543e+0))))))))) + + ; + + u = vmul_vd_vd_vd_advsimd_sleef(u, vmul_vd_vd_vd_advsimd_sleef(x2, vd2getx_vd_vd2_advsimd_sleef(x))); + + vdouble2_advsimd_sleef y = ddsub_vd2_vd2_vd_advsimd_sleef(ddsub_vd2_vd2_vd2_advsimd_sleef(vcast_vd2_d_d_advsimd_sleef(3.141592653589793116/4, 1.2246467991473532072e-16/4), x), u); + + vdouble_advsimd_sleef r = vsel_vd_vo_vd_vd_advsimd_sleef(o, vadd_vd_vd_vd_advsimd_sleef(u, vd2getx_vd_vd2_advsimd_sleef(x)), + vmul_vd_vd_vd_advsimd_sleef(vadd_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(y), vd2gety_vd_vd2_advsimd_sleef(y)), vcast_vd_d_advsimd_sleef(2))); + return vmulsign_vd_vd_vd_advsimd_sleef(r, d); +} + +SLEEF_INLINE SLEEF_CONST vdouble_advsimd_sleef Sleef_acosd2_u35advsimd(vdouble_advsimd_sleef d) { + vopmask_advsimd_sleef o = vlt_vo_vd_vd_advsimd_sleef(vabs_vd_vd_advsimd_sleef(d), vcast_vd_d_advsimd_sleef(0.5)); + vdouble_advsimd_sleef x2 = vsel_vd_vo_vd_vd_advsimd_sleef(o, vmul_vd_vd_vd_advsimd_sleef(d, d), + vmul_vd_vd_vd_advsimd_sleef(vsub_vd_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(1), vabs_vd_vd_advsimd_sleef(d)), vcast_vd_d_advsimd_sleef(0.5))), u; + vdouble_advsimd_sleef x = vsel_vd_vo_vd_vd_advsimd_sleef(o, vabs_vd_vd_advsimd_sleef(d), vsqrt_vd_vd_advsimd_sleef(x2)); + x = vsel_vd_vo_vd_vd_advsimd_sleef(veq_vo_vd_vd_advsimd_sleef(vabs_vd_vd_advsimd_sleef(d), vcast_vd_d_advsimd_sleef(1.0)), vcast_vd_d_advsimd_sleef(0), x); + + vdouble_advsimd_sleef x4 = vmul_vd_vd_vd_advsimd_sleef(x2, x2), x8 = vmul_vd_vd_vd_advsimd_sleef(x4, x4), x16 = vmul_vd_vd_vd_advsimd_sleef(x8, x8); + u = vmla_vd_vd_vd_vd_advsimd_sleef((x16), (vmla_vd_vd_vd_vd_advsimd_sleef((x4), (vmla_vd_vd_vd_vd_advsimd_sleef((x2), (vcast_vd_d_advsimd_sleef(+0.3161587650653934628e-1)), (vcast_vd_d_advsimd_sleef(-0.1581918243329996643e-1)))), (vmla_vd_vd_vd_vd_advsimd_sleef((x2), (vcast_vd_d_advsimd_sleef(+0.1929045477267910674e-1)), (vcast_vd_d_advsimd_sleef(+0.6606077476277170610e-2)))))), (vmla_vd_vd_vd_vd_advsimd_sleef((x8), (vmla_vd_vd_vd_vd_advsimd_sleef((x4), (vmla_vd_vd_vd_vd_advsimd_sleef((x2), (vcast_vd_d_advsimd_sleef(+0.1215360525577377331e-1)), (vcast_vd_d_advsimd_sleef(+0.1388715184501609218e-1)))), (vmla_vd_vd_vd_vd_advsimd_sleef((x2), (vcast_vd_d_advsimd_sleef(+0.1735956991223614604e-1)), (vcast_vd_d_advsimd_sleef(+0.2237176181932048341e-1)))))), (vmla_vd_vd_vd_vd_advsimd_sleef((x4), (vmla_vd_vd_vd_vd_advsimd_sleef((x2), (vcast_vd_d_advsimd_sleef(+0.3038195928038132237e-1)), (vcast_vd_d_advsimd_sleef(+0.4464285681377102438e-1)))), (vmla_vd_vd_vd_vd_advsimd_sleef((x2), (vcast_vd_d_advsimd_sleef(+0.7500000000378581611e-1)), (vcast_vd_d_advsimd_sleef(+0.1666666666666497543e+0))))))))) + + ; + + u = vmul_vd_vd_vd_advsimd_sleef(u, vmul_vd_vd_vd_advsimd_sleef(x2, x)); + + vdouble_advsimd_sleef y = vsub_vd_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(3.141592653589793238462643383279502884/2), vadd_vd_vd_vd_advsimd_sleef(vmulsign_vd_vd_vd_advsimd_sleef(x, d), vmulsign_vd_vd_vd_advsimd_sleef(u, d))); + x = vadd_vd_vd_vd_advsimd_sleef(x, u); + vdouble_advsimd_sleef r = vsel_vd_vo_vd_vd_advsimd_sleef(o, y, vmul_vd_vd_vd_advsimd_sleef(x, vcast_vd_d_advsimd_sleef(2))); + return vsel_vd_vo_vd_vd_advsimd_sleef(vandnot_vo_vo_vo_advsimd_sleef(o, vlt_vo_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(0))), + vd2getx_vd_vd2_advsimd_sleef(ddadd_vd2_vd2_vd_advsimd_sleef(vcast_vd2_d_d_advsimd_sleef(3.141592653589793116, 1.2246467991473532072e-16), + vneg_vd_vd_advsimd_sleef(r))), r); +} + +SLEEF_INLINE SLEEF_CONST vdouble_advsimd_sleef Sleef_acosd2_u10advsimd(vdouble_advsimd_sleef d) { + vopmask_advsimd_sleef o = vlt_vo_vd_vd_advsimd_sleef(vabs_vd_vd_advsimd_sleef(d), vcast_vd_d_advsimd_sleef(0.5)); + vdouble_advsimd_sleef x2 = vsel_vd_vo_vd_vd_advsimd_sleef(o, vmul_vd_vd_vd_advsimd_sleef(d, d), vmul_vd_vd_vd_advsimd_sleef(vsub_vd_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(1), vabs_vd_vd_advsimd_sleef(d)), vcast_vd_d_advsimd_sleef(0.5))), u; + vdouble2_advsimd_sleef x = vsel_vd2_vo_vd2_vd2_advsimd_sleef(o, vcast_vd2_vd_vd_advsimd_sleef(vabs_vd_vd_advsimd_sleef(d), vcast_vd_d_advsimd_sleef(0)), ddsqrt_vd2_vd_advsimd_sleef(x2)); + x = vsel_vd2_vo_vd2_vd2_advsimd_sleef(veq_vo_vd_vd_advsimd_sleef(vabs_vd_vd_advsimd_sleef(d), vcast_vd_d_advsimd_sleef(1.0)), vcast_vd2_d_d_advsimd_sleef(0, 0), x); + + vdouble_advsimd_sleef x4 = vmul_vd_vd_vd_advsimd_sleef(x2, x2), x8 = vmul_vd_vd_vd_advsimd_sleef(x4, x4), x16 = vmul_vd_vd_vd_advsimd_sleef(x8, x8); + u = vmla_vd_vd_vd_vd_advsimd_sleef((x16), (vmla_vd_vd_vd_vd_advsimd_sleef((x4), (vmla_vd_vd_vd_vd_advsimd_sleef((x2), (vcast_vd_d_advsimd_sleef(+0.3161587650653934628e-1)), (vcast_vd_d_advsimd_sleef(-0.1581918243329996643e-1)))), (vmla_vd_vd_vd_vd_advsimd_sleef((x2), (vcast_vd_d_advsimd_sleef(+0.1929045477267910674e-1)), (vcast_vd_d_advsimd_sleef(+0.6606077476277170610e-2)))))), (vmla_vd_vd_vd_vd_advsimd_sleef((x8), (vmla_vd_vd_vd_vd_advsimd_sleef((x4), (vmla_vd_vd_vd_vd_advsimd_sleef((x2), (vcast_vd_d_advsimd_sleef(+0.1215360525577377331e-1)), (vcast_vd_d_advsimd_sleef(+0.1388715184501609218e-1)))), (vmla_vd_vd_vd_vd_advsimd_sleef((x2), (vcast_vd_d_advsimd_sleef(+0.1735956991223614604e-1)), (vcast_vd_d_advsimd_sleef(+0.2237176181932048341e-1)))))), (vmla_vd_vd_vd_vd_advsimd_sleef((x4), (vmla_vd_vd_vd_vd_advsimd_sleef((x2), (vcast_vd_d_advsimd_sleef(+0.3038195928038132237e-1)), (vcast_vd_d_advsimd_sleef(+0.4464285681377102438e-1)))), (vmla_vd_vd_vd_vd_advsimd_sleef((x2), (vcast_vd_d_advsimd_sleef(+0.7500000000378581611e-1)), (vcast_vd_d_advsimd_sleef(+0.1666666666666497543e+0))))))))) + + ; + + u = vmul_vd_vd_vd_advsimd_sleef(u, vmul_vd_vd_vd_advsimd_sleef(x2, vd2getx_vd_vd2_advsimd_sleef(x))); + + vdouble2_advsimd_sleef y = ddsub_vd2_vd2_vd2_advsimd_sleef(vcast_vd2_d_d_advsimd_sleef(3.141592653589793116/2, 1.2246467991473532072e-16/2), + ddadd_vd2_vd_vd_advsimd_sleef(vmulsign_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(x), d), vmulsign_vd_vd_vd_advsimd_sleef(u, d))); + x = ddadd_vd2_vd2_vd_advsimd_sleef(x, u); + + y = vsel_vd2_vo_vd2_vd2_advsimd_sleef(o, y, ddscale_vd2_vd2_vd_advsimd_sleef(x, vcast_vd_d_advsimd_sleef(2))); + + y = vsel_vd2_vo_vd2_vd2_advsimd_sleef(vandnot_vo_vo_vo_advsimd_sleef(o, vlt_vo_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(0))), + ddsub_vd2_vd2_vd2_advsimd_sleef(vcast_vd2_d_d_advsimd_sleef(3.141592653589793116, 1.2246467991473532072e-16), y), y); + + return vadd_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(y), vd2gety_vd_vd2_advsimd_sleef(y)); +} + +SLEEF_INLINE SLEEF_CONST vdouble_advsimd_sleef Sleef_atand2_u10advsimd(vdouble_advsimd_sleef d) { + vdouble2_advsimd_sleef d2 = atan2k_u1_advsimd_sleef(vcast_vd2_vd_vd_advsimd_sleef(vabs_vd_vd_advsimd_sleef(d), vcast_vd_d_advsimd_sleef(0)), vcast_vd2_d_d_advsimd_sleef(1, 0)); + vdouble_advsimd_sleef r = vadd_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(d2), vd2gety_vd_vd2_advsimd_sleef(d2)); + r = vsel_vd_vo_vd_vd_advsimd_sleef(visinf_vo_vd_advsimd_sleef(d), vcast_vd_d_advsimd_sleef(1.570796326794896557998982), r); + return vmulsign_vd_vd_vd_advsimd_sleef(r, d); +} + +SLEEF_INLINE SLEEF_CONST vdouble_advsimd_sleef Sleef_atand2_u35advsimd(vdouble_advsimd_sleef s) { + vdouble_advsimd_sleef t, u; + vint_advsimd_sleef q; + + q = vsel_vi_vd_vi_advsimd_sleef(s, vcast_vi_i_advsimd_sleef(2)); + s = vabs_vd_vd_advsimd_sleef(s); + + q = vsel_vi_vd_vd_vi_vi_advsimd_sleef(vcast_vd_d_advsimd_sleef(1), s, vadd_vi_vi_vi_advsimd_sleef(q, vcast_vi_i_advsimd_sleef(1)), q); + s = vsel_vd_vo_vd_vd_advsimd_sleef(vlt_vo_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(1), s), vrec_vd_vd_advsimd_sleef(s), s); + + t = vmul_vd_vd_vd_advsimd_sleef(s, s); + + vdouble_advsimd_sleef t2 = vmul_vd_vd_vd_advsimd_sleef(t, t), t4 = vmul_vd_vd_vd_advsimd_sleef(t2, t2), t8 = vmul_vd_vd_vd_advsimd_sleef(t4, t4), t16 = vmul_vd_vd_vd_advsimd_sleef(t8, t8); + u = vmla_vd_vd_vd_vd_advsimd_sleef((t16), (vmla_vd_vd_vd_vd_advsimd_sleef((t2), (vcast_vd_d_advsimd_sleef(-1.88796008463073496563746e-05)), (vmla_vd_vd_vd_vd_advsimd_sleef((t), (vcast_vd_d_advsimd_sleef(0.000209850076645816976906797)), (vcast_vd_d_advsimd_sleef(-0.00110611831486672482563471)))))), (vmla_vd_vd_vd_vd_advsimd_sleef((t8), (vmla_vd_vd_vd_vd_advsimd_sleef((t4), (vmla_vd_vd_vd_vd_advsimd_sleef((t2), (vmla_vd_vd_vd_vd_advsimd_sleef((t), (vcast_vd_d_advsimd_sleef(0.00370026744188713119232403)), (vcast_vd_d_advsimd_sleef(-0.00889896195887655491740809)))), (vmla_vd_vd_vd_vd_advsimd_sleef((t), (vcast_vd_d_advsimd_sleef(0.016599329773529201970117)), (vcast_vd_d_advsimd_sleef(-0.0254517624932312641616861)))))), (vmla_vd_vd_vd_vd_advsimd_sleef((t2), (vmla_vd_vd_vd_vd_advsimd_sleef((t), (vcast_vd_d_advsimd_sleef(0.0337852580001353069993897)), (vcast_vd_d_advsimd_sleef(-0.0407629191276836500001934)))), (vmla_vd_vd_vd_vd_advsimd_sleef((t), (vcast_vd_d_advsimd_sleef(0.0466667150077840625632675)), (vcast_vd_d_advsimd_sleef(-0.0523674852303482457616113)))))))), (vmla_vd_vd_vd_vd_advsimd_sleef((t4), (vmla_vd_vd_vd_vd_advsimd_sleef((t2), (vmla_vd_vd_vd_vd_advsimd_sleef((t), (vcast_vd_d_advsimd_sleef(0.0587666392926673580854313)), (vcast_vd_d_advsimd_sleef(-0.0666573579361080525984562)))), (vmla_vd_vd_vd_vd_advsimd_sleef((t), (vcast_vd_d_advsimd_sleef(0.0769219538311769618355029)), (vcast_vd_d_advsimd_sleef(-0.090908995008245008229153)))))), (vmla_vd_vd_vd_vd_advsimd_sleef((t2), (vmla_vd_vd_vd_vd_advsimd_sleef((t), (vcast_vd_d_advsimd_sleef(0.111111105648261418443745)), (vcast_vd_d_advsimd_sleef(-0.14285714266771329383765)))), (vmla_vd_vd_vd_vd_advsimd_sleef((t), (vcast_vd_d_advsimd_sleef(0.199999999996591265594148)), (vcast_vd_d_advsimd_sleef(-0.333333333333311110369124))))))))))) + + ; + + t = vmla_vd_vd_vd_vd_advsimd_sleef(s, vmul_vd_vd_vd_advsimd_sleef(t, u), s); + + t = vsel_vd_vo_vd_vd_advsimd_sleef(vcast_vo64_vo32_advsimd_sleef(veq_vo_vi_vi_advsimd_sleef(vand_vi_vi_vi_advsimd_sleef(q, vcast_vi_i_advsimd_sleef(1)), vcast_vi_i_advsimd_sleef(1))), vsub_vd_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(3.141592653589793238462643383279502884/2), t), t); + t = vreinterpret_vd_vm_advsimd_sleef(vxor_vm_vm_vm_advsimd_sleef(vand_vm_vo64_vm_advsimd_sleef(vcast_vo64_vo32_advsimd_sleef(veq_vo_vi_vi_advsimd_sleef(vand_vi_vi_vi_advsimd_sleef(q, vcast_vi_i_advsimd_sleef(2)), vcast_vi_i_advsimd_sleef(2))), vreinterpret_vm_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(-0.0))), vreinterpret_vm_vd_advsimd_sleef(t))); + + return t; +} + +SLEEF_INLINE SLEEF_CONST vdouble_advsimd_sleef Sleef_logd2_u35advsimd(vdouble_advsimd_sleef d) { + vdouble_advsimd_sleef x, x2; + vdouble_advsimd_sleef t, m; + + vopmask_advsimd_sleef o = vlt_vo_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(0x1p-1022)); + d = vsel_vd_vo_vd_vd_advsimd_sleef(o, vmul_vd_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef((double)(INT64_C(1) << 32) * (double)(INT64_C(1) << 32))), d); + vint_advsimd_sleef e = vilogb2k_vi_vd_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(1.0/0.75))); + m = vldexp3_vd_vd_vi_advsimd_sleef(d, vneg_vi_vi_advsimd_sleef(e)); + e = vsel_vi_vo_vi_vi_advsimd_sleef(vcast_vo32_vo64_advsimd_sleef(o), vsub_vi_vi_vi_advsimd_sleef(e, vcast_vi_i_advsimd_sleef(64)), e); + + x = vdiv_vd_vd_vd_advsimd_sleef(vsub_vd_vd_vd_advsimd_sleef(m, vcast_vd_d_advsimd_sleef(1)), vadd_vd_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(1), m)); + x2 = vmul_vd_vd_vd_advsimd_sleef(x, x); + + vdouble_advsimd_sleef x4 = vmul_vd_vd_vd_advsimd_sleef(x2, x2), x8 = vmul_vd_vd_vd_advsimd_sleef(x4, x4), x3 = vmul_vd_vd_vd_advsimd_sleef(x, x2); + t = vmla_vd_vd_vd_vd_advsimd_sleef((x8), (vmla_vd_vd_vd_vd_advsimd_sleef((x4), (vcast_vd_d_advsimd_sleef(0.153487338491425068243146)), (vmla_vd_vd_vd_vd_advsimd_sleef((x2), (vcast_vd_d_advsimd_sleef(0.152519917006351951593857)), (vcast_vd_d_advsimd_sleef(0.181863266251982985677316)))))), (vmla_vd_vd_vd_vd_advsimd_sleef((x4), (vmla_vd_vd_vd_vd_advsimd_sleef((x2), (vcast_vd_d_advsimd_sleef(0.222221366518767365905163)), (vcast_vd_d_advsimd_sleef(0.285714294746548025383248)))), (vmla_vd_vd_vd_vd_advsimd_sleef((x2), (vcast_vd_d_advsimd_sleef(0.399999999950799600689777)), (vcast_vd_d_advsimd_sleef(0.6666666666667778740063))))))) + + ; + + x = vmla_vd_vd_vd_vd_advsimd_sleef(x, vcast_vd_d_advsimd_sleef(2), vmul_vd_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(0.693147180559945286226764), vcast_vd_vi_advsimd_sleef(e))); + x = vmla_vd_vd_vd_vd_advsimd_sleef(x3, t, x); + + x = vsel_vd_vo_vd_vd_advsimd_sleef(vispinf_vo_vd_advsimd_sleef(d), vcast_vd_d_advsimd_sleef(__builtin_inf()), x); + x = vsel_vd_vo_vd_vd_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(vlt_vo_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(0)), visnan_vo_vd_advsimd_sleef(d)), vcast_vd_d_advsimd_sleef(__builtin_nan("")), x); + x = vsel_vd_vo_vd_vd_advsimd_sleef(veq_vo_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(0)), vcast_vd_d_advsimd_sleef(-__builtin_inf()), x); + + return x; +} + +SLEEF_INLINE SLEEF_CONST vdouble_advsimd_sleef Sleef_expd2_u10advsimd(vdouble_advsimd_sleef d) { + vdouble_advsimd_sleef u = vrint_vd_vd_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(1.442695040888963407359924681001892137426645954152985934135449406931))), s; + vint_advsimd_sleef q = vrint_vi_vd_advsimd_sleef(u); + + s = vmla_vd_vd_vd_vd_advsimd_sleef(u, vcast_vd_d_advsimd_sleef(-.69314718055966295651160180568695068359375), d); + s = vmla_vd_vd_vd_vd_advsimd_sleef(u, vcast_vd_d_advsimd_sleef(-.28235290563031577122588448175013436025525412068e-12), s); + + vdouble_advsimd_sleef s2 = vmul_vd_vd_vd_advsimd_sleef(s, s), s4 = vmul_vd_vd_vd_advsimd_sleef(s2, s2), s8 = vmul_vd_vd_vd_advsimd_sleef(s4, s4); + u = vmla_vd_vd_vd_vd_advsimd_sleef((s8), (vmla_vd_vd_vd_vd_advsimd_sleef((s), (vcast_vd_d_advsimd_sleef(+0.2081276378237164457e-8)), (vcast_vd_d_advsimd_sleef(+0.2511210703042288022e-7)))), (vmla_vd_vd_vd_vd_advsimd_sleef((s4), (vmla_vd_vd_vd_vd_advsimd_sleef((s2), (vmla_vd_vd_vd_vd_advsimd_sleef((s), (vcast_vd_d_advsimd_sleef(+0.2755762628169491192e-6)), (vcast_vd_d_advsimd_sleef(+0.2755723402025388239e-5)))), (vmla_vd_vd_vd_vd_advsimd_sleef((s), (vcast_vd_d_advsimd_sleef(+0.2480158687479686264e-4)), (vcast_vd_d_advsimd_sleef(+0.1984126989855865850e-3)))))), (vmla_vd_vd_vd_vd_advsimd_sleef((s2), (vmla_vd_vd_vd_vd_advsimd_sleef((s), (vcast_vd_d_advsimd_sleef(+0.1388888888914497797e-2)), (vcast_vd_d_advsimd_sleef(+0.8333333333314938210e-2)))), (vmla_vd_vd_vd_vd_advsimd_sleef((s), (vcast_vd_d_advsimd_sleef(+0.4166666666666602598e-1)), (vcast_vd_d_advsimd_sleef(+0.1666666666666669072e+0))))))))) + + ; + u = vfma_vd_vd_vd_vd_advsimd_sleef(u, s, vcast_vd_d_advsimd_sleef(+0.5000000000000000000e+0)); + u = vfma_vd_vd_vd_vd_advsimd_sleef(u, s, vcast_vd_d_advsimd_sleef(+0.1000000000000000000e+1)); + u = vfma_vd_vd_vd_vd_advsimd_sleef(u, s, vcast_vd_d_advsimd_sleef(+0.1000000000000000000e+1)); + + u = vldexp2_vd_vd_vi_advsimd_sleef(u, q); + + u = vsel_vd_vo_vd_vd_advsimd_sleef(vgt_vo_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(709.78271114955742909217217426)), vcast_vd_d_advsimd_sleef(__builtin_inf()), u); + u = vreinterpret_vd_vm_advsimd_sleef(vandnot_vm_vo64_vm_advsimd_sleef(vlt_vo_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(-1000)), vreinterpret_vm_vd_advsimd_sleef(u))); + + return u; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_advsimd_sleef expm1k_advsimd_sleef(vdouble_advsimd_sleef d) { + vdouble_advsimd_sleef u = vrint_vd_vd_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(1.442695040888963407359924681001892137426645954152985934135449406931))), s; + vint_advsimd_sleef q = vrint_vi_vd_advsimd_sleef(u); + + s = vmla_vd_vd_vd_vd_advsimd_sleef(u, vcast_vd_d_advsimd_sleef(-.69314718055966295651160180568695068359375), d); + s = vmla_vd_vd_vd_vd_advsimd_sleef(u, vcast_vd_d_advsimd_sleef(-.28235290563031577122588448175013436025525412068e-12), s); + + vdouble_advsimd_sleef s2 = vmul_vd_vd_vd_advsimd_sleef(s, s), s4 = vmul_vd_vd_vd_advsimd_sleef(s2, s2), s8 = vmul_vd_vd_vd_advsimd_sleef(s4, s4); + u = vmla_vd_vd_vd_vd_advsimd_sleef((s8), (vmla_vd_vd_vd_vd_advsimd_sleef((s), (vcast_vd_d_advsimd_sleef(2.08860621107283687536341e-09)), (vcast_vd_d_advsimd_sleef(2.51112930892876518610661e-08)))), (vmla_vd_vd_vd_vd_advsimd_sleef((s4), (vmla_vd_vd_vd_vd_advsimd_sleef((s2), (vmla_vd_vd_vd_vd_advsimd_sleef((s), (vcast_vd_d_advsimd_sleef(2.75573911234900471893338e-07)), (vcast_vd_d_advsimd_sleef(2.75572362911928827629423e-06)))), (vmla_vd_vd_vd_vd_advsimd_sleef((s), (vcast_vd_d_advsimd_sleef(2.4801587159235472998791e-05)), (vcast_vd_d_advsimd_sleef(0.000198412698960509205564975)))))), (vmla_vd_vd_vd_vd_advsimd_sleef((s2), (vmla_vd_vd_vd_vd_advsimd_sleef((s), (vcast_vd_d_advsimd_sleef(0.00138888888889774492207962)), (vcast_vd_d_advsimd_sleef(0.00833333333331652721664984)))), (vmla_vd_vd_vd_vd_advsimd_sleef((s), (vcast_vd_d_advsimd_sleef(0.0416666666666665047591422)), (vcast_vd_d_advsimd_sleef(0.166666666666666851703837))))))))) + + ; + + u = vadd_vd_vd_vd_advsimd_sleef(vmla_vd_vd_vd_vd_advsimd_sleef(s2, vcast_vd_d_advsimd_sleef(0.5), vmul_vd_vd_vd_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(s2, s), u)), s); + + u = vsel_vd_vo_vd_vd_advsimd_sleef(vcast_vo64_vo32_advsimd_sleef(veq_vo_vi_vi_advsimd_sleef(q, vcast_vi_i_advsimd_sleef(0))), u, + vsub_vd_vd_vd_advsimd_sleef(vldexp2_vd_vd_vi_advsimd_sleef(vadd_vd_vd_vd_advsimd_sleef(u, vcast_vd_d_advsimd_sleef(1)), q), vcast_vd_d_advsimd_sleef(1))); + + return u; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_advsimd_sleef logk_advsimd_sleef(vdouble_advsimd_sleef d) { + vdouble2_advsimd_sleef x, x2, s; + vdouble_advsimd_sleef t, m; + + vopmask_advsimd_sleef o = vlt_vo_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(0x1p-1022)); + d = vsel_vd_vo_vd_vd_advsimd_sleef(o, vmul_vd_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef((double)(INT64_C(1) << 32) * (double)(INT64_C(1) << 32))), d); + vint_advsimd_sleef e = vilogb2k_vi_vd_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(1.0/0.75))); + m = vldexp3_vd_vd_vi_advsimd_sleef(d, vneg_vi_vi_advsimd_sleef(e)); + e = vsel_vi_vo_vi_vi_advsimd_sleef(vcast_vo32_vo64_advsimd_sleef(o), vsub_vi_vi_vi_advsimd_sleef(e, vcast_vi_i_advsimd_sleef(64)), e); + + x = dddiv_vd2_vd2_vd2_advsimd_sleef(ddadd2_vd2_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(-1), m), ddadd2_vd2_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(1), m)); + x2 = ddsqu_vd2_vd2_advsimd_sleef(x); + + vdouble_advsimd_sleef x4 = vmul_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(x2), vd2getx_vd_vd2_advsimd_sleef(x2)), x8 = vmul_vd_vd_vd_advsimd_sleef(x4, x4), x16 = vmul_vd_vd_vd_advsimd_sleef(x8, x8); + t = vmla_vd_vd_vd_vd_advsimd_sleef((x16), (vcast_vd_d_advsimd_sleef(0.116255524079935043668677)), (vmla_vd_vd_vd_vd_advsimd_sleef((x8), (vmla_vd_vd_vd_vd_advsimd_sleef((x4), (vmla_vd_vd_vd_vd_advsimd_sleef((vd2getx_vd_vd2_advsimd_sleef(x2)), (vcast_vd_d_advsimd_sleef(0.103239680901072952701192)), (vcast_vd_d_advsimd_sleef(0.117754809412463995466069)))), (vmla_vd_vd_vd_vd_advsimd_sleef((vd2getx_vd_vd2_advsimd_sleef(x2)), (vcast_vd_d_advsimd_sleef(0.13332981086846273921509)), (vcast_vd_d_advsimd_sleef(0.153846227114512262845736)))))), (vmla_vd_vd_vd_vd_advsimd_sleef((x4), (vmla_vd_vd_vd_vd_advsimd_sleef((vd2getx_vd_vd2_advsimd_sleef(x2)), (vcast_vd_d_advsimd_sleef(0.181818180850050775676507)), (vcast_vd_d_advsimd_sleef(0.222222222230083560345903)))), (vmla_vd_vd_vd_vd_advsimd_sleef((vd2getx_vd_vd2_advsimd_sleef(x2)), (vcast_vd_d_advsimd_sleef(0.285714285714249172087875)), (vcast_vd_d_advsimd_sleef(0.400000000000000077715612))))))))) + + ; + + vdouble2_advsimd_sleef c = vcast_vd2_d_d_advsimd_sleef(0.666666666666666629659233, 3.80554962542412056336616e-17); + + s = ddmul_vd2_vd2_vd_advsimd_sleef(vcast_vd2_d_d_advsimd_sleef(0.693147180559945286226764, 2.319046813846299558417771e-17), vcast_vd_vi_advsimd_sleef(e)); + + s = ddadd_vd2_vd2_vd2_advsimd_sleef(s, ddscale_vd2_vd2_vd_advsimd_sleef(x, vcast_vd_d_advsimd_sleef(2))); + x = ddmul_vd2_vd2_vd2_advsimd_sleef(x2, x); + s = ddadd_vd2_vd2_vd2_advsimd_sleef(s, ddmul_vd2_vd2_vd2_advsimd_sleef(x, c)); + x = ddmul_vd2_vd2_vd2_advsimd_sleef(x2, x); + s = ddadd_vd2_vd2_vd2_advsimd_sleef(s, ddmul_vd2_vd2_vd_advsimd_sleef(x, t)); + + return s; +} + +SLEEF_INLINE SLEEF_CONST vdouble_advsimd_sleef Sleef_logd2_u10advsimd(vdouble_advsimd_sleef d) { + vdouble2_advsimd_sleef x; + vdouble_advsimd_sleef t, m, x2; + + vopmask_advsimd_sleef o = vlt_vo_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(0x1p-1022)); + d = vsel_vd_vo_vd_vd_advsimd_sleef(o, vmul_vd_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef((double)(INT64_C(1) << 32) * (double)(INT64_C(1) << 32))), d); + vint_advsimd_sleef e = vilogb2k_vi_vd_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(1.0/0.75))); + m = vldexp3_vd_vd_vi_advsimd_sleef(d, vneg_vi_vi_advsimd_sleef(e)); + e = vsel_vi_vo_vi_vi_advsimd_sleef(vcast_vo32_vo64_advsimd_sleef(o), vsub_vi_vi_vi_advsimd_sleef(e, vcast_vi_i_advsimd_sleef(64)), e); + + x = dddiv_vd2_vd2_vd2_advsimd_sleef(ddadd2_vd2_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(-1), m), ddadd2_vd2_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(1), m)); + x2 = vmul_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(x), vd2getx_vd_vd2_advsimd_sleef(x)); + + vdouble_advsimd_sleef x4 = vmul_vd_vd_vd_advsimd_sleef(x2, x2), x8 = vmul_vd_vd_vd_advsimd_sleef(x4, x4); + t = vmla_vd_vd_vd_vd_advsimd_sleef((x8), (vmla_vd_vd_vd_vd_advsimd_sleef((x4), (vcast_vd_d_advsimd_sleef(0.1532076988502701353e+0)), (vmla_vd_vd_vd_vd_advsimd_sleef((x2), (vcast_vd_d_advsimd_sleef(0.1525629051003428716e+0)), (vcast_vd_d_advsimd_sleef(0.1818605932937785996e+0)))))), (vmla_vd_vd_vd_vd_advsimd_sleef((x4), (vmla_vd_vd_vd_vd_advsimd_sleef((x2), (vcast_vd_d_advsimd_sleef(0.2222214519839380009e+0)), (vcast_vd_d_advsimd_sleef(0.2857142932794299317e+0)))), (vmla_vd_vd_vd_vd_advsimd_sleef((x2), (vcast_vd_d_advsimd_sleef(0.3999999999635251990e+0)), (vcast_vd_d_advsimd_sleef(0.6666666666667333541e+0))))))) + + ; + + vdouble2_advsimd_sleef s = ddmul_vd2_vd2_vd_advsimd_sleef(vcast_vd2_d_d_advsimd_sleef(0.693147180559945286226764, 2.319046813846299558417771e-17), vcast_vd_vi_advsimd_sleef(e)); + + s = ddadd_vd2_vd2_vd2_advsimd_sleef(s, ddscale_vd2_vd2_vd_advsimd_sleef(x, vcast_vd_d_advsimd_sleef(2))); + s = ddadd_vd2_vd2_vd_advsimd_sleef(s, vmul_vd_vd_vd_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(x2, vd2getx_vd_vd2_advsimd_sleef(x)), t)); + + vdouble_advsimd_sleef r = vadd_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(s), vd2gety_vd_vd2_advsimd_sleef(s)); + + r = vsel_vd_vo_vd_vd_advsimd_sleef(vispinf_vo_vd_advsimd_sleef(d), vcast_vd_d_advsimd_sleef(__builtin_inf()), r); + r = vsel_vd_vo_vd_vd_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(vlt_vo_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(0)), visnan_vo_vd_advsimd_sleef(d)), vcast_vd_d_advsimd_sleef(__builtin_nan("")), r); + r = vsel_vd_vo_vd_vd_advsimd_sleef(veq_vo_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(0)), vcast_vd_d_advsimd_sleef(-__builtin_inf()), r); + + return r; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_advsimd_sleef expk_advsimd_sleef(vdouble2_advsimd_sleef d) { + vdouble_advsimd_sleef u = vmul_vd_vd_vd_advsimd_sleef(vadd_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(d), vd2gety_vd_vd2_advsimd_sleef(d)), vcast_vd_d_advsimd_sleef(1.442695040888963407359924681001892137426645954152985934135449406931)); + vdouble_advsimd_sleef dq = vrint_vd_vd_advsimd_sleef(u); + vint_advsimd_sleef q = vrint_vi_vd_advsimd_sleef(dq); + vdouble2_advsimd_sleef s, t; + + s = ddadd2_vd2_vd2_vd_advsimd_sleef(d, vmul_vd_vd_vd_advsimd_sleef(dq, vcast_vd_d_advsimd_sleef(-.69314718055966295651160180568695068359375))); + s = ddadd2_vd2_vd2_vd_advsimd_sleef(s, vmul_vd_vd_vd_advsimd_sleef(dq, vcast_vd_d_advsimd_sleef(-.28235290563031577122588448175013436025525412068e-12))); + + s = ddnormalize_vd2_vd2_advsimd_sleef(s); + + vdouble_advsimd_sleef s2 = vmul_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(s), vd2getx_vd_vd2_advsimd_sleef(s)), s4 = vmul_vd_vd_vd_advsimd_sleef(s2, s2), s8 = vmul_vd_vd_vd_advsimd_sleef(s4, s4); + u = vmla_vd_vd_vd_vd_advsimd_sleef((s8), (vmla_vd_vd_vd_vd_advsimd_sleef((vd2getx_vd_vd2_advsimd_sleef(s)), (vcast_vd_d_advsimd_sleef(2.51069683420950419527139e-08)), (vcast_vd_d_advsimd_sleef(2.76286166770270649116855e-07)))), (vmla_vd_vd_vd_vd_advsimd_sleef((s4), (vmla_vd_vd_vd_vd_advsimd_sleef((s2), (vmla_vd_vd_vd_vd_advsimd_sleef((vd2getx_vd_vd2_advsimd_sleef(s)), (vcast_vd_d_advsimd_sleef(2.75572496725023574143864e-06)), (vcast_vd_d_advsimd_sleef(2.48014973989819794114153e-05)))), (vmla_vd_vd_vd_vd_advsimd_sleef((vd2getx_vd_vd2_advsimd_sleef(s)), (vcast_vd_d_advsimd_sleef(0.000198412698809069797676111)), (vcast_vd_d_advsimd_sleef(0.0013888888939977128960529)))))), (vmla_vd_vd_vd_vd_advsimd_sleef((s2), (vmla_vd_vd_vd_vd_advsimd_sleef((vd2getx_vd_vd2_advsimd_sleef(s)), (vcast_vd_d_advsimd_sleef(0.00833333333332371417601081)), (vcast_vd_d_advsimd_sleef(0.0416666666665409524128449)))), (vmla_vd_vd_vd_vd_advsimd_sleef((vd2getx_vd_vd2_advsimd_sleef(s)), (vcast_vd_d_advsimd_sleef(0.166666666666666740681535)), (vcast_vd_d_advsimd_sleef(0.500000000000000999200722))))))))) + + ; + + t = ddadd_vd2_vd_vd2_advsimd_sleef(vcast_vd_d_advsimd_sleef(1), s); + t = ddadd_vd2_vd2_vd2_advsimd_sleef(t, ddmul_vd2_vd2_vd_advsimd_sleef(ddsqu_vd2_vd2_advsimd_sleef(s), u)); + + u = vadd_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(t), vd2gety_vd_vd2_advsimd_sleef(t)); + u = vldexp2_vd_vd_vi_advsimd_sleef(u, q); + + u = vreinterpret_vd_vm_advsimd_sleef(vandnot_vm_vo64_vm_advsimd_sleef(vlt_vo_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(d), vcast_vd_d_advsimd_sleef(-1000)), vreinterpret_vm_vd_advsimd_sleef(u))); + + return u; +} + +SLEEF_INLINE SLEEF_CONST vdouble_advsimd_sleef Sleef_powd2_u10advsimd(vdouble_advsimd_sleef x, vdouble_advsimd_sleef y) { + + vopmask_advsimd_sleef yisint = visint_vo_vd_advsimd_sleef(y); + vopmask_advsimd_sleef yisodd = vand_vo_vo_vo_advsimd_sleef(visodd_vo_vd_advsimd_sleef(y), yisint); + + vdouble2_advsimd_sleef d = ddmul_vd2_vd2_vd_advsimd_sleef(logk_advsimd_sleef(vabs_vd_vd_advsimd_sleef(x)), y); + vdouble_advsimd_sleef result = expk_advsimd_sleef(d); + result = vsel_vd_vo_vd_vd_advsimd_sleef(vgt_vo_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(d), vcast_vd_d_advsimd_sleef(709.78271114955742909217217426)), vcast_vd_d_advsimd_sleef(__builtin_inf()), result); + + result = vmul_vd_vd_vd_advsimd_sleef(result, + vsel_vd_vo_vd_vd_advsimd_sleef(vgt_vo_vd_vd_advsimd_sleef(x, vcast_vd_d_advsimd_sleef(0)), + vcast_vd_d_advsimd_sleef(1), + vsel_vd_vo_vd_vd_advsimd_sleef(yisint, vsel_vd_vo_vd_vd_advsimd_sleef(yisodd, vcast_vd_d_advsimd_sleef(-1.0), vcast_vd_d_advsimd_sleef(1)), vcast_vd_d_advsimd_sleef(__builtin_nan(""))))); + + vdouble_advsimd_sleef efx = vmulsign_vd_vd_vd_advsimd_sleef(vsub_vd_vd_vd_advsimd_sleef(vabs_vd_vd_advsimd_sleef(x), vcast_vd_d_advsimd_sleef(1)), y); + + result = vsel_vd_vo_vd_vd_advsimd_sleef(visinf_vo_vd_advsimd_sleef(y), + vreinterpret_vd_vm_advsimd_sleef(vandnot_vm_vo64_vm_advsimd_sleef(vlt_vo_vd_vd_advsimd_sleef(efx, vcast_vd_d_advsimd_sleef(0.0)), + vreinterpret_vm_vd_advsimd_sleef(vsel_vd_vo_vd_vd_advsimd_sleef(veq_vo_vd_vd_advsimd_sleef(efx, vcast_vd_d_advsimd_sleef(0.0)), + vcast_vd_d_advsimd_sleef(1.0), + vcast_vd_d_advsimd_sleef(__builtin_inf()))))), + result); + + result = vsel_vd_vo_vd_vd_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(visinf_vo_vd_advsimd_sleef(x), veq_vo_vd_vd_advsimd_sleef(x, vcast_vd_d_advsimd_sleef(0.0))), + vmulsign_vd_vd_vd_advsimd_sleef(vsel_vd_vo_vd_vd_advsimd_sleef(vxor_vo_vo_vo_advsimd_sleef(vsignbit_vo_vd_advsimd_sleef(y), veq_vo_vd_vd_advsimd_sleef(x, vcast_vd_d_advsimd_sleef(0.0))), + vcast_vd_d_advsimd_sleef(0), vcast_vd_d_advsimd_sleef(__builtin_inf())), + vsel_vd_vo_vd_vd_advsimd_sleef(yisodd, x, vcast_vd_d_advsimd_sleef(1))), result); + + result = vreinterpret_vd_vm_advsimd_sleef(vor_vm_vo64_vm_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(visnan_vo_vd_advsimd_sleef(x), visnan_vo_vd_advsimd_sleef(y)), vreinterpret_vm_vd_advsimd_sleef(result))); + + result = vsel_vd_vo_vd_vd_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(veq_vo_vd_vd_advsimd_sleef(y, vcast_vd_d_advsimd_sleef(0)), veq_vo_vd_vd_advsimd_sleef(x, vcast_vd_d_advsimd_sleef(1))), vcast_vd_d_advsimd_sleef(1), result); + + return result; + +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_advsimd_sleef expk2_advsimd_sleef(vdouble2_advsimd_sleef d) { + vdouble_advsimd_sleef u = vmul_vd_vd_vd_advsimd_sleef(vadd_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(d), vd2gety_vd_vd2_advsimd_sleef(d)), vcast_vd_d_advsimd_sleef(1.442695040888963407359924681001892137426645954152985934135449406931)); + vdouble_advsimd_sleef dq = vrint_vd_vd_advsimd_sleef(u); + vint_advsimd_sleef q = vrint_vi_vd_advsimd_sleef(dq); + vdouble2_advsimd_sleef s, t; + + s = ddadd2_vd2_vd2_vd_advsimd_sleef(d, vmul_vd_vd_vd_advsimd_sleef(dq, vcast_vd_d_advsimd_sleef(-.69314718055966295651160180568695068359375))); + s = ddadd2_vd2_vd2_vd_advsimd_sleef(s, vmul_vd_vd_vd_advsimd_sleef(dq, vcast_vd_d_advsimd_sleef(-.28235290563031577122588448175013436025525412068e-12))); + + vdouble2_advsimd_sleef s2 = ddsqu_vd2_vd2_advsimd_sleef(s), s4 = ddsqu_vd2_vd2_advsimd_sleef(s2); + vdouble_advsimd_sleef s8 = vmul_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(s4), vd2getx_vd_vd2_advsimd_sleef(s4)); + u = vmla_vd_vd_vd_vd_advsimd_sleef((s8), (vmla_vd_vd_vd_vd_advsimd_sleef((vd2getx_vd_vd2_advsimd_sleef(s)), (vcast_vd_d_advsimd_sleef(+0.1602472219709932072e-9)), (vcast_vd_d_advsimd_sleef(+0.2092255183563157007e-8)))), (vmla_vd_vd_vd_vd_advsimd_sleef((vd2getx_vd_vd2_advsimd_sleef(s4)), (vmla_vd_vd_vd_vd_advsimd_sleef((vd2getx_vd_vd2_advsimd_sleef(s2)), (vmla_vd_vd_vd_vd_advsimd_sleef((vd2getx_vd_vd2_advsimd_sleef(s)), (vcast_vd_d_advsimd_sleef(+0.2505230023782644465e-7)), (vcast_vd_d_advsimd_sleef(+0.2755724800902135303e-6)))), (vmla_vd_vd_vd_vd_advsimd_sleef((vd2getx_vd_vd2_advsimd_sleef(s)), (vcast_vd_d_advsimd_sleef(+0.2755731892386044373e-5)), (vcast_vd_d_advsimd_sleef(+0.2480158735605815065e-4)))))), (vmla_vd_vd_vd_vd_advsimd_sleef((vd2getx_vd_vd2_advsimd_sleef(s2)), (vmla_vd_vd_vd_vd_advsimd_sleef((vd2getx_vd_vd2_advsimd_sleef(s)), (vcast_vd_d_advsimd_sleef(+0.1984126984148071858e-3)), (vcast_vd_d_advsimd_sleef(+0.1388888888886763255e-2)))), (vmla_vd_vd_vd_vd_advsimd_sleef((vd2getx_vd_vd2_advsimd_sleef(s)), (vcast_vd_d_advsimd_sleef(+0.8333333333333347095e-2)), (vcast_vd_d_advsimd_sleef(+0.4166666666666669905e-1))))))))) + + ; + + t = ddadd_vd2_vd_vd2_advsimd_sleef(vcast_vd_d_advsimd_sleef(0.5), ddmul_vd2_vd2_vd_advsimd_sleef(s, vcast_vd_d_advsimd_sleef(+0.1666666666666666574e+0))); + t = ddadd_vd2_vd_vd2_advsimd_sleef(vcast_vd_d_advsimd_sleef(1.0), ddmul_vd2_vd2_vd2_advsimd_sleef(t, s)); + t = ddadd_vd2_vd_vd2_advsimd_sleef(vcast_vd_d_advsimd_sleef(1.0), ddmul_vd2_vd2_vd2_advsimd_sleef(t, s)); + t = ddadd_vd2_vd2_vd2_advsimd_sleef(t, ddmul_vd2_vd2_vd_advsimd_sleef(s4, u)); + + t = vd2setx_vd2_vd2_vd_advsimd_sleef(t, vldexp2_vd_vd_vi_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(t), q)); + t = vd2sety_vd2_vd2_vd_advsimd_sleef(t, vldexp2_vd_vd_vi_advsimd_sleef(vd2gety_vd_vd2_advsimd_sleef(t), q)); + + t = vd2setx_vd2_vd2_vd_advsimd_sleef(t, vreinterpret_vd_vm_advsimd_sleef(vandnot_vm_vo64_vm_advsimd_sleef(vlt_vo_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(d), vcast_vd_d_advsimd_sleef(-1000)), vreinterpret_vm_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(t))))); + t = vd2sety_vd2_vd2_vd_advsimd_sleef(t, vreinterpret_vd_vm_advsimd_sleef(vandnot_vm_vo64_vm_advsimd_sleef(vlt_vo_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(d), vcast_vd_d_advsimd_sleef(-1000)), vreinterpret_vm_vd_advsimd_sleef(vd2gety_vd_vd2_advsimd_sleef(t))))); + + return t; +} + +SLEEF_INLINE SLEEF_CONST vdouble_advsimd_sleef Sleef_sinhd2_u10advsimd(vdouble_advsimd_sleef x) { + vdouble_advsimd_sleef y = vabs_vd_vd_advsimd_sleef(x); + vdouble2_advsimd_sleef d = expk2_advsimd_sleef(vcast_vd2_vd_vd_advsimd_sleef(y, vcast_vd_d_advsimd_sleef(0))); + d = ddsub_vd2_vd2_vd2_advsimd_sleef(d, ddrec_vd2_vd2_advsimd_sleef(d)); + y = vmul_vd_vd_vd_advsimd_sleef(vadd_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(d), vd2gety_vd_vd2_advsimd_sleef(d)), vcast_vd_d_advsimd_sleef(0.5)); + + y = vsel_vd_vo_vd_vd_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(vgt_vo_vd_vd_advsimd_sleef(vabs_vd_vd_advsimd_sleef(x), vcast_vd_d_advsimd_sleef(710)), visnan_vo_vd_advsimd_sleef(y)), vcast_vd_d_advsimd_sleef(__builtin_inf()), y); + y = vmulsign_vd_vd_vd_advsimd_sleef(y, x); + y = vreinterpret_vd_vm_advsimd_sleef(vor_vm_vo64_vm_advsimd_sleef(visnan_vo_vd_advsimd_sleef(x), vreinterpret_vm_vd_advsimd_sleef(y))); + + return y; +} + +SLEEF_INLINE SLEEF_CONST vdouble_advsimd_sleef Sleef_coshd2_u10advsimd(vdouble_advsimd_sleef x) { + vdouble_advsimd_sleef y = vabs_vd_vd_advsimd_sleef(x); + vdouble2_advsimd_sleef d = expk2_advsimd_sleef(vcast_vd2_vd_vd_advsimd_sleef(y, vcast_vd_d_advsimd_sleef(0))); + d = ddadd_vd2_vd2_vd2_advsimd_sleef(d, ddrec_vd2_vd2_advsimd_sleef(d)); + y = vmul_vd_vd_vd_advsimd_sleef(vadd_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(d), vd2gety_vd_vd2_advsimd_sleef(d)), vcast_vd_d_advsimd_sleef(0.5)); + + y = vsel_vd_vo_vd_vd_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(vgt_vo_vd_vd_advsimd_sleef(vabs_vd_vd_advsimd_sleef(x), vcast_vd_d_advsimd_sleef(710)), visnan_vo_vd_advsimd_sleef(y)), vcast_vd_d_advsimd_sleef(__builtin_inf()), y); + y = vreinterpret_vd_vm_advsimd_sleef(vor_vm_vo64_vm_advsimd_sleef(visnan_vo_vd_advsimd_sleef(x), vreinterpret_vm_vd_advsimd_sleef(y))); + + return y; +} + +SLEEF_INLINE SLEEF_CONST vdouble_advsimd_sleef Sleef_tanhd2_u10advsimd(vdouble_advsimd_sleef x) { + vdouble_advsimd_sleef y = vabs_vd_vd_advsimd_sleef(x); + vdouble2_advsimd_sleef d = expk2_advsimd_sleef(vcast_vd2_vd_vd_advsimd_sleef(y, vcast_vd_d_advsimd_sleef(0))); + vdouble2_advsimd_sleef e = ddrec_vd2_vd2_advsimd_sleef(d); + d = dddiv_vd2_vd2_vd2_advsimd_sleef(ddadd2_vd2_vd2_vd2_advsimd_sleef(d, ddneg_vd2_vd2_advsimd_sleef(e)), ddadd2_vd2_vd2_vd2_advsimd_sleef(d, e)); + y = vadd_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(d), vd2gety_vd_vd2_advsimd_sleef(d)); + + y = vsel_vd_vo_vd_vd_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(vgt_vo_vd_vd_advsimd_sleef(vabs_vd_vd_advsimd_sleef(x), vcast_vd_d_advsimd_sleef(18.714973875)), visnan_vo_vd_advsimd_sleef(y)), vcast_vd_d_advsimd_sleef(1.0), y); + y = vmulsign_vd_vd_vd_advsimd_sleef(y, x); + y = vreinterpret_vd_vm_advsimd_sleef(vor_vm_vo64_vm_advsimd_sleef(visnan_vo_vd_advsimd_sleef(x), vreinterpret_vm_vd_advsimd_sleef(y))); + + return y; +} + +SLEEF_INLINE SLEEF_CONST vdouble_advsimd_sleef Sleef_sinhd2_u35advsimd(vdouble_advsimd_sleef x) { + vdouble_advsimd_sleef e = expm1k_advsimd_sleef(vabs_vd_vd_advsimd_sleef(x)); + + vdouble_advsimd_sleef y = vdiv_vd_vd_vd_advsimd_sleef(vadd_vd_vd_vd_advsimd_sleef(e, vcast_vd_d_advsimd_sleef(2)), vadd_vd_vd_vd_advsimd_sleef(e, vcast_vd_d_advsimd_sleef(1))); + y = vmul_vd_vd_vd_advsimd_sleef(y, vmul_vd_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(0.5), e)); + + y = vsel_vd_vo_vd_vd_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(vgt_vo_vd_vd_advsimd_sleef(vabs_vd_vd_advsimd_sleef(x), vcast_vd_d_advsimd_sleef(709)), visnan_vo_vd_advsimd_sleef(y)), vcast_vd_d_advsimd_sleef(__builtin_inf()), y); + y = vmulsign_vd_vd_vd_advsimd_sleef(y, x); + y = vreinterpret_vd_vm_advsimd_sleef(vor_vm_vo64_vm_advsimd_sleef(visnan_vo_vd_advsimd_sleef(x), vreinterpret_vm_vd_advsimd_sleef(y))); + + return y; +} + +SLEEF_INLINE SLEEF_CONST vdouble_advsimd_sleef Sleef_coshd2_u35advsimd(vdouble_advsimd_sleef x) { + vdouble_advsimd_sleef e = Sleef_expd2_u10advsimd(vabs_vd_vd_advsimd_sleef(x)); + vdouble_advsimd_sleef y = vmla_vd_vd_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(0.5), e, vdiv_vd_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(0.5), e)); + + y = vsel_vd_vo_vd_vd_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(vgt_vo_vd_vd_advsimd_sleef(vabs_vd_vd_advsimd_sleef(x), vcast_vd_d_advsimd_sleef(709)), visnan_vo_vd_advsimd_sleef(y)), vcast_vd_d_advsimd_sleef(__builtin_inf()), y); + y = vreinterpret_vd_vm_advsimd_sleef(vor_vm_vo64_vm_advsimd_sleef(visnan_vo_vd_advsimd_sleef(x), vreinterpret_vm_vd_advsimd_sleef(y))); + + return y; +} + +SLEEF_INLINE SLEEF_CONST vdouble_advsimd_sleef Sleef_tanhd2_u35advsimd(vdouble_advsimd_sleef x) { + vdouble_advsimd_sleef d = expm1k_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(2), vabs_vd_vd_advsimd_sleef(x))); + vdouble_advsimd_sleef y = vdiv_vd_vd_vd_advsimd_sleef(d, vadd_vd_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(2), d)); + + y = vsel_vd_vo_vd_vd_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(vgt_vo_vd_vd_advsimd_sleef(vabs_vd_vd_advsimd_sleef(x), vcast_vd_d_advsimd_sleef(18.714973875)), visnan_vo_vd_advsimd_sleef(y)), vcast_vd_d_advsimd_sleef(1.0), y); + y = vmulsign_vd_vd_vd_advsimd_sleef(y, x); + y = vreinterpret_vd_vm_advsimd_sleef(vor_vm_vo64_vm_advsimd_sleef(visnan_vo_vd_advsimd_sleef(x), vreinterpret_vm_vd_advsimd_sleef(y))); + + return y; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_advsimd_sleef logk2_advsimd_sleef(vdouble2_advsimd_sleef d) { + vdouble2_advsimd_sleef x, x2, m, s; + vdouble_advsimd_sleef t; + vint_advsimd_sleef e; + + e = vilogbk_vi_vd_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(d), vcast_vd_d_advsimd_sleef(1.0/0.75))); + + m = vd2setxy_vd2_vd_vd_advsimd_sleef(vldexp2_vd_vd_vi_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(d), vneg_vi_vi_advsimd_sleef(e)), + vldexp2_vd_vd_vi_advsimd_sleef(vd2gety_vd_vd2_advsimd_sleef(d), vneg_vi_vi_advsimd_sleef(e))); + + x = dddiv_vd2_vd2_vd2_advsimd_sleef(ddadd2_vd2_vd2_vd_advsimd_sleef(m, vcast_vd_d_advsimd_sleef(-1)), ddadd2_vd2_vd2_vd_advsimd_sleef(m, vcast_vd_d_advsimd_sleef(1))); + x2 = ddsqu_vd2_vd2_advsimd_sleef(x); + + vdouble_advsimd_sleef x4 = vmul_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(x2), vd2getx_vd_vd2_advsimd_sleef(x2)), x8 = vmul_vd_vd_vd_advsimd_sleef(x4, x4); + t = vmla_vd_vd_vd_vd_advsimd_sleef((x8), (vmla_vd_vd_vd_vd_advsimd_sleef((x4), (vcast_vd_d_advsimd_sleef(0.13860436390467167910856)), (vmla_vd_vd_vd_vd_advsimd_sleef((vd2getx_vd_vd2_advsimd_sleef(x2)), (vcast_vd_d_advsimd_sleef(0.131699838841615374240845)), (vcast_vd_d_advsimd_sleef(0.153914168346271945653214)))))), (vmla_vd_vd_vd_vd_advsimd_sleef((x4), (vmla_vd_vd_vd_vd_advsimd_sleef((vd2getx_vd_vd2_advsimd_sleef(x2)), (vcast_vd_d_advsimd_sleef(0.181816523941564611721589)), (vcast_vd_d_advsimd_sleef(0.22222224632662035403996)))), (vmla_vd_vd_vd_vd_advsimd_sleef((vd2getx_vd_vd2_advsimd_sleef(x2)), (vcast_vd_d_advsimd_sleef(0.285714285511134091777308)), (vcast_vd_d_advsimd_sleef(0.400000000000914013309483))))))) + + ; + t = vmla_vd_vd_vd_vd_advsimd_sleef(t, vd2getx_vd_vd2_advsimd_sleef(x2), vcast_vd_d_advsimd_sleef(0.666666666666664853302393)); + + s = ddmul_vd2_vd2_vd_advsimd_sleef(vcast_vd2_d_d_advsimd_sleef(0.693147180559945286226764, 2.319046813846299558417771e-17), vcast_vd_vi_advsimd_sleef(e)); + s = ddadd_vd2_vd2_vd2_advsimd_sleef(s, ddscale_vd2_vd2_vd_advsimd_sleef(x, vcast_vd_d_advsimd_sleef(2))); + s = ddadd_vd2_vd2_vd2_advsimd_sleef(s, ddmul_vd2_vd2_vd_advsimd_sleef(ddmul_vd2_vd2_vd2_advsimd_sleef(x2, x), t)); + + return s; +} + +SLEEF_INLINE SLEEF_CONST vdouble_advsimd_sleef Sleef_asinhd2_u10advsimd(vdouble_advsimd_sleef x) { + vdouble_advsimd_sleef y = vabs_vd_vd_advsimd_sleef(x); + vopmask_advsimd_sleef o = vgt_vo_vd_vd_advsimd_sleef(y, vcast_vd_d_advsimd_sleef(1)); + vdouble2_advsimd_sleef d; + + d = vsel_vd2_vo_vd2_vd2_advsimd_sleef(o, ddrec_vd2_vd_advsimd_sleef(x), vcast_vd2_vd_vd_advsimd_sleef(y, vcast_vd_d_advsimd_sleef(0))); + d = ddsqrt_vd2_vd2_advsimd_sleef(ddadd2_vd2_vd2_vd_advsimd_sleef(ddsqu_vd2_vd2_advsimd_sleef(d), vcast_vd_d_advsimd_sleef(1))); + d = vsel_vd2_vo_vd2_vd2_advsimd_sleef(o, ddmul_vd2_vd2_vd_advsimd_sleef(d, y), d); + + d = logk2_advsimd_sleef(ddnormalize_vd2_vd2_advsimd_sleef(ddadd2_vd2_vd2_vd_advsimd_sleef(d, x))); + y = vadd_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(d), vd2gety_vd_vd2_advsimd_sleef(d)); + + y = vsel_vd_vo_vd_vd_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(vgt_vo_vd_vd_advsimd_sleef(vabs_vd_vd_advsimd_sleef(x), vcast_vd_d_advsimd_sleef(1.3407807929942596355e+154)), + visnan_vo_vd_advsimd_sleef(y)), + vmulsign_vd_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(__builtin_inf()), x), y); + + y = vreinterpret_vd_vm_advsimd_sleef(vor_vm_vo64_vm_advsimd_sleef(visnan_vo_vd_advsimd_sleef(x), vreinterpret_vm_vd_advsimd_sleef(y))); + y = vsel_vd_vo_vd_vd_advsimd_sleef(visnegzero_vo_vd_advsimd_sleef(x), vcast_vd_d_advsimd_sleef(-0.0), y); + + return y; +} + +SLEEF_INLINE SLEEF_CONST vdouble_advsimd_sleef Sleef_acoshd2_u10advsimd(vdouble_advsimd_sleef x) { + vdouble2_advsimd_sleef d = logk2_advsimd_sleef(ddadd2_vd2_vd2_vd_advsimd_sleef(ddmul_vd2_vd2_vd2_advsimd_sleef(ddsqrt_vd2_vd2_advsimd_sleef(ddadd2_vd2_vd_vd_advsimd_sleef(x, vcast_vd_d_advsimd_sleef(1))), ddsqrt_vd2_vd2_advsimd_sleef(ddadd2_vd2_vd_vd_advsimd_sleef(x, vcast_vd_d_advsimd_sleef(-1)))), x)); + vdouble_advsimd_sleef y = vadd_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(d), vd2gety_vd_vd2_advsimd_sleef(d)); + + y = vsel_vd_vo_vd_vd_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(vgt_vo_vd_vd_advsimd_sleef(vabs_vd_vd_advsimd_sleef(x), vcast_vd_d_advsimd_sleef(1.3407807929942596355e+154)), + visnan_vo_vd_advsimd_sleef(y)), + vcast_vd_d_advsimd_sleef(__builtin_inf()), y); + y = vreinterpret_vd_vm_advsimd_sleef(vandnot_vm_vo64_vm_advsimd_sleef(veq_vo_vd_vd_advsimd_sleef(x, vcast_vd_d_advsimd_sleef(1.0)), vreinterpret_vm_vd_advsimd_sleef(y))); + + y = vreinterpret_vd_vm_advsimd_sleef(vor_vm_vo64_vm_advsimd_sleef(vlt_vo_vd_vd_advsimd_sleef(x, vcast_vd_d_advsimd_sleef(1.0)), vreinterpret_vm_vd_advsimd_sleef(y))); + y = vreinterpret_vd_vm_advsimd_sleef(vor_vm_vo64_vm_advsimd_sleef(visnan_vo_vd_advsimd_sleef(x), vreinterpret_vm_vd_advsimd_sleef(y))); + + return y; +} + +SLEEF_INLINE SLEEF_CONST vdouble_advsimd_sleef Sleef_atanhd2_u10advsimd(vdouble_advsimd_sleef x) { + vdouble_advsimd_sleef y = vabs_vd_vd_advsimd_sleef(x); + vdouble2_advsimd_sleef d = logk2_advsimd_sleef(dddiv_vd2_vd2_vd2_advsimd_sleef(ddadd2_vd2_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(1), y), ddadd2_vd2_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(1), vneg_vd_vd_advsimd_sleef(y)))); + y = vreinterpret_vd_vm_advsimd_sleef(vor_vm_vo64_vm_advsimd_sleef(vgt_vo_vd_vd_advsimd_sleef(y, vcast_vd_d_advsimd_sleef(1.0)), vreinterpret_vm_vd_advsimd_sleef(vsel_vd_vo_vd_vd_advsimd_sleef(veq_vo_vd_vd_advsimd_sleef(y, vcast_vd_d_advsimd_sleef(1.0)), vcast_vd_d_advsimd_sleef(__builtin_inf()), vmul_vd_vd_vd_advsimd_sleef(vadd_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(d), vd2gety_vd_vd2_advsimd_sleef(d)), vcast_vd_d_advsimd_sleef(0.5)))))); + + y = vmulsign_vd_vd_vd_advsimd_sleef(y, x); + y = vreinterpret_vd_vm_advsimd_sleef(vor_vm_vo64_vm_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(visinf_vo_vd_advsimd_sleef(x), visnan_vo_vd_advsimd_sleef(y)), vreinterpret_vm_vd_advsimd_sleef(y))); + y = vreinterpret_vd_vm_advsimd_sleef(vor_vm_vo64_vm_advsimd_sleef(visnan_vo_vd_advsimd_sleef(x), vreinterpret_vm_vd_advsimd_sleef(y))); + + return y; +} + +SLEEF_INLINE SLEEF_CONST vdouble_advsimd_sleef Sleef_cbrtd2_u35advsimd(vdouble_advsimd_sleef d) { + vdouble_advsimd_sleef x, y, q = vcast_vd_d_advsimd_sleef(1.0); + vint_advsimd_sleef e, qu, re; + vdouble_advsimd_sleef t; + + e = vadd_vi_vi_vi_advsimd_sleef(vilogbk_vi_vd_advsimd_sleef(vabs_vd_vd_advsimd_sleef(d)), vcast_vi_i_advsimd_sleef(1)); + d = vldexp2_vd_vd_vi_advsimd_sleef(d, vneg_vi_vi_advsimd_sleef(e)); + + t = vadd_vd_vd_vd_advsimd_sleef(vcast_vd_vi_advsimd_sleef(e), vcast_vd_d_advsimd_sleef(6144)); + qu = vtruncate_vi_vd_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(t, vcast_vd_d_advsimd_sleef(1.0/3.0))); + re = vtruncate_vi_vd_advsimd_sleef(vsub_vd_vd_vd_advsimd_sleef(t, vmul_vd_vd_vd_advsimd_sleef(vcast_vd_vi_advsimd_sleef(qu), vcast_vd_d_advsimd_sleef(3)))); + + q = vsel_vd_vo_vd_vd_advsimd_sleef(vcast_vo64_vo32_advsimd_sleef(veq_vo_vi_vi_advsimd_sleef(re, vcast_vi_i_advsimd_sleef(1))), vcast_vd_d_advsimd_sleef(1.2599210498948731647672106), q); + q = vsel_vd_vo_vd_vd_advsimd_sleef(vcast_vo64_vo32_advsimd_sleef(veq_vo_vi_vi_advsimd_sleef(re, vcast_vi_i_advsimd_sleef(2))), vcast_vd_d_advsimd_sleef(1.5874010519681994747517056), q); + q = vldexp2_vd_vd_vi_advsimd_sleef(q, vsub_vi_vi_vi_advsimd_sleef(qu, vcast_vi_i_advsimd_sleef(2048))); + + q = vmulsign_vd_vd_vd_advsimd_sleef(q, d); + + d = vabs_vd_vd_advsimd_sleef(d); + + x = vcast_vd_d_advsimd_sleef(-0.640245898480692909870982); + x = vmla_vd_vd_vd_vd_advsimd_sleef(x, d, vcast_vd_d_advsimd_sleef(2.96155103020039511818595)); + x = vmla_vd_vd_vd_vd_advsimd_sleef(x, d, vcast_vd_d_advsimd_sleef(-5.73353060922947843636166)); + x = vmla_vd_vd_vd_vd_advsimd_sleef(x, d, vcast_vd_d_advsimd_sleef(6.03990368989458747961407)); + x = vmla_vd_vd_vd_vd_advsimd_sleef(x, d, vcast_vd_d_advsimd_sleef(-3.85841935510444988821632)); + x = vmla_vd_vd_vd_vd_advsimd_sleef(x, d, vcast_vd_d_advsimd_sleef(2.2307275302496609725722)); + + y = vmul_vd_vd_vd_advsimd_sleef(x, x); y = vmul_vd_vd_vd_advsimd_sleef(y, y); x = vsub_vd_vd_vd_advsimd_sleef(x, vmul_vd_vd_vd_advsimd_sleef(vmlapn_vd_vd_vd_vd_advsimd_sleef(d, y, x), vcast_vd_d_advsimd_sleef(1.0 / 3.0))); + y = vmul_vd_vd_vd_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(d, x), x); + y = vmul_vd_vd_vd_advsimd_sleef(vsub_vd_vd_vd_advsimd_sleef(y, vmul_vd_vd_vd_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(2.0 / 3.0), y), vmla_vd_vd_vd_vd_advsimd_sleef(y, x, vcast_vd_d_advsimd_sleef(-1.0)))), q); + + return y; +} + +SLEEF_INLINE SLEEF_CONST vdouble_advsimd_sleef Sleef_cbrtd2_u10advsimd(vdouble_advsimd_sleef d) { + vdouble_advsimd_sleef x, y, z, t; + vdouble2_advsimd_sleef q2 = vcast_vd2_d_d_advsimd_sleef(1, 0), u, v; + vint_advsimd_sleef e, qu, re; + + e = vadd_vi_vi_vi_advsimd_sleef(vilogbk_vi_vd_advsimd_sleef(vabs_vd_vd_advsimd_sleef(d)), vcast_vi_i_advsimd_sleef(1)); + d = vldexp2_vd_vd_vi_advsimd_sleef(d, vneg_vi_vi_advsimd_sleef(e)); + + t = vadd_vd_vd_vd_advsimd_sleef(vcast_vd_vi_advsimd_sleef(e), vcast_vd_d_advsimd_sleef(6144)); + qu = vtruncate_vi_vd_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(t, vcast_vd_d_advsimd_sleef(1.0/3.0))); + re = vtruncate_vi_vd_advsimd_sleef(vsub_vd_vd_vd_advsimd_sleef(t, vmul_vd_vd_vd_advsimd_sleef(vcast_vd_vi_advsimd_sleef(qu), vcast_vd_d_advsimd_sleef(3)))); + + q2 = vsel_vd2_vo_vd2_vd2_advsimd_sleef(vcast_vo64_vo32_advsimd_sleef(veq_vo_vi_vi_advsimd_sleef(re, vcast_vi_i_advsimd_sleef(1))), vcast_vd2_d_d_advsimd_sleef(1.2599210498948731907, -2.5899333753005069177e-17), q2); + q2 = vsel_vd2_vo_vd2_vd2_advsimd_sleef(vcast_vo64_vo32_advsimd_sleef(veq_vo_vi_vi_advsimd_sleef(re, vcast_vi_i_advsimd_sleef(2))), vcast_vd2_d_d_advsimd_sleef(1.5874010519681995834, -1.0869008194197822986e-16), q2); + + q2 = vd2setxy_vd2_vd_vd_advsimd_sleef(vmulsign_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(q2), d), vmulsign_vd_vd_vd_advsimd_sleef(vd2gety_vd_vd2_advsimd_sleef(q2), d)); + d = vabs_vd_vd_advsimd_sleef(d); + + x = vcast_vd_d_advsimd_sleef(-0.640245898480692909870982); + x = vmla_vd_vd_vd_vd_advsimd_sleef(x, d, vcast_vd_d_advsimd_sleef(2.96155103020039511818595)); + x = vmla_vd_vd_vd_vd_advsimd_sleef(x, d, vcast_vd_d_advsimd_sleef(-5.73353060922947843636166)); + x = vmla_vd_vd_vd_vd_advsimd_sleef(x, d, vcast_vd_d_advsimd_sleef(6.03990368989458747961407)); + x = vmla_vd_vd_vd_vd_advsimd_sleef(x, d, vcast_vd_d_advsimd_sleef(-3.85841935510444988821632)); + x = vmla_vd_vd_vd_vd_advsimd_sleef(x, d, vcast_vd_d_advsimd_sleef(2.2307275302496609725722)); + + y = vmul_vd_vd_vd_advsimd_sleef(x, x); y = vmul_vd_vd_vd_advsimd_sleef(y, y); x = vsub_vd_vd_vd_advsimd_sleef(x, vmul_vd_vd_vd_advsimd_sleef(vmlapn_vd_vd_vd_vd_advsimd_sleef(d, y, x), vcast_vd_d_advsimd_sleef(1.0 / 3.0))); + + z = x; + + u = ddmul_vd2_vd_vd_advsimd_sleef(x, x); + u = ddmul_vd2_vd2_vd2_advsimd_sleef(u, u); + u = ddmul_vd2_vd2_vd_advsimd_sleef(u, d); + u = ddadd2_vd2_vd2_vd_advsimd_sleef(u, vneg_vd_vd_advsimd_sleef(x)); + y = vadd_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(u), vd2gety_vd_vd2_advsimd_sleef(u)); + + y = vmul_vd_vd_vd_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(-2.0 / 3.0), y), z); + v = ddadd2_vd2_vd2_vd_advsimd_sleef(ddmul_vd2_vd_vd_advsimd_sleef(z, z), y); + v = ddmul_vd2_vd2_vd_advsimd_sleef(v, d); + v = ddmul_vd2_vd2_vd2_advsimd_sleef(v, q2); + z = vldexp2_vd_vd_vi_advsimd_sleef(vadd_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(v), vd2gety_vd_vd2_advsimd_sleef(v)), vsub_vi_vi_vi_advsimd_sleef(qu, vcast_vi_i_advsimd_sleef(2048))); + + z = vsel_vd_vo_vd_vd_advsimd_sleef(visinf_vo_vd_advsimd_sleef(d), vmulsign_vd_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(__builtin_inf()), vd2getx_vd_vd2_advsimd_sleef(q2)), z); + z = vsel_vd_vo_vd_vd_advsimd_sleef(veq_vo_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(0)), vreinterpret_vd_vm_advsimd_sleef(vsignbit_vm_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(q2))), z); + + return z; +} + +SLEEF_INLINE SLEEF_CONST vdouble_advsimd_sleef Sleef_exp2d2_u10advsimd(vdouble_advsimd_sleef d) { + vdouble_advsimd_sleef u = vrint_vd_vd_advsimd_sleef(d), s; + vint_advsimd_sleef q = vrint_vi_vd_advsimd_sleef(u); + + s = vsub_vd_vd_vd_advsimd_sleef(d, u); + + vdouble_advsimd_sleef s2 = vmul_vd_vd_vd_advsimd_sleef(s, s), s4 = vmul_vd_vd_vd_advsimd_sleef(s2, s2), s8 = vmul_vd_vd_vd_advsimd_sleef(s4, s4); + u = vmla_vd_vd_vd_vd_advsimd_sleef((s8), (vmla_vd_vd_vd_vd_advsimd_sleef((s), (vcast_vd_d_advsimd_sleef(+0.4434359082926529454e-9)), (vcast_vd_d_advsimd_sleef(+0.7073164598085707425e-8)))), (vmla_vd_vd_vd_vd_advsimd_sleef((s4), (vmla_vd_vd_vd_vd_advsimd_sleef((s2), (vmla_vd_vd_vd_vd_advsimd_sleef((s), (vcast_vd_d_advsimd_sleef(+0.1017819260921760451e-6)), (vcast_vd_d_advsimd_sleef(+0.1321543872511327615e-5)))), (vmla_vd_vd_vd_vd_advsimd_sleef((s), (vcast_vd_d_advsimd_sleef(+0.1525273353517584730e-4)), (vcast_vd_d_advsimd_sleef(+0.1540353045101147808e-3)))))), (vmla_vd_vd_vd_vd_advsimd_sleef((s2), (vmla_vd_vd_vd_vd_advsimd_sleef((s), (vcast_vd_d_advsimd_sleef(+0.1333355814670499073e-2)), (vcast_vd_d_advsimd_sleef(+0.9618129107597600536e-2)))), (vmla_vd_vd_vd_vd_advsimd_sleef((s), (vcast_vd_d_advsimd_sleef(+0.5550410866482046596e-1)), (vcast_vd_d_advsimd_sleef(+0.2402265069591012214e+0))))))))) + + ; + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, s, vcast_vd_d_advsimd_sleef(+0.6931471805599452862e+0)); + + u = vfma_vd_vd_vd_vd_advsimd_sleef(u, s, vcast_vd_d_advsimd_sleef(1)); + + u = vldexp2_vd_vd_vi_advsimd_sleef(u, q); + + u = vsel_vd_vo_vd_vd_advsimd_sleef(vge_vo_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(1024)), vcast_vd_d_advsimd_sleef(__builtin_inf()), u); + u = vreinterpret_vd_vm_advsimd_sleef(vandnot_vm_vo64_vm_advsimd_sleef(vlt_vo_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(-2000)), vreinterpret_vm_vd_advsimd_sleef(u))); + + return u; +} + +SLEEF_INLINE SLEEF_CONST vdouble_advsimd_sleef Sleef_exp2d2_u35advsimd(vdouble_advsimd_sleef d) { + vdouble_advsimd_sleef u = vrint_vd_vd_advsimd_sleef(d), s; + vint_advsimd_sleef q = vrint_vi_vd_advsimd_sleef(u); + + s = vsub_vd_vd_vd_advsimd_sleef(d, u); + + vdouble_advsimd_sleef s2 = vmul_vd_vd_vd_advsimd_sleef(s, s), s4 = vmul_vd_vd_vd_advsimd_sleef(s2, s2), s8 = vmul_vd_vd_vd_advsimd_sleef(s4, s4); + u = vmla_vd_vd_vd_vd_advsimd_sleef((s8), (vmla_vd_vd_vd_vd_advsimd_sleef((s), (vcast_vd_d_advsimd_sleef(+0.4434359082926529454e-9)), (vcast_vd_d_advsimd_sleef(+0.7073164598085707425e-8)))), (vmla_vd_vd_vd_vd_advsimd_sleef((s4), (vmla_vd_vd_vd_vd_advsimd_sleef((s2), (vmla_vd_vd_vd_vd_advsimd_sleef((s), (vcast_vd_d_advsimd_sleef(+0.1017819260921760451e-6)), (vcast_vd_d_advsimd_sleef(+0.1321543872511327615e-5)))), (vmla_vd_vd_vd_vd_advsimd_sleef((s), (vcast_vd_d_advsimd_sleef(+0.1525273353517584730e-4)), (vcast_vd_d_advsimd_sleef(+0.1540353045101147808e-3)))))), (vmla_vd_vd_vd_vd_advsimd_sleef((s2), (vmla_vd_vd_vd_vd_advsimd_sleef((s), (vcast_vd_d_advsimd_sleef(+0.1333355814670499073e-2)), (vcast_vd_d_advsimd_sleef(+0.9618129107597600536e-2)))), (vmla_vd_vd_vd_vd_advsimd_sleef((s), (vcast_vd_d_advsimd_sleef(+0.5550410866482046596e-1)), (vcast_vd_d_advsimd_sleef(+0.2402265069591012214e+0))))))))) + + ; + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, s, vcast_vd_d_advsimd_sleef(+0.6931471805599452862e+0)); + + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, s, vcast_vd_d_advsimd_sleef(1)); + + u = vldexp2_vd_vd_vi_advsimd_sleef(u, q); + + u = vsel_vd_vo_vd_vd_advsimd_sleef(vge_vo_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(1024)), vcast_vd_d_advsimd_sleef(__builtin_inf()), u); + u = vreinterpret_vd_vm_advsimd_sleef(vandnot_vm_vo64_vm_advsimd_sleef(vlt_vo_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(-2000)), vreinterpret_vm_vd_advsimd_sleef(u))); + + return u; +} + +SLEEF_INLINE SLEEF_CONST vdouble_advsimd_sleef Sleef_exp10d2_u10advsimd(vdouble_advsimd_sleef d) { + vdouble_advsimd_sleef u = vrint_vd_vd_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(3.3219280948873623478703194294893901758648313930))), s; + vint_advsimd_sleef q = vrint_vi_vd_advsimd_sleef(u); + + s = vmla_vd_vd_vd_vd_advsimd_sleef(u, vcast_vd_d_advsimd_sleef(-0.30102999566383914498), d); + s = vmla_vd_vd_vd_vd_advsimd_sleef(u, vcast_vd_d_advsimd_sleef(-1.4205023227266099418e-13), s); + + u = vcast_vd_d_advsimd_sleef(+0.2411463498334267652e-3); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, s, vcast_vd_d_advsimd_sleef(+0.1157488415217187375e-2)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, s, vcast_vd_d_advsimd_sleef(+0.5013975546789733659e-2)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, s, vcast_vd_d_advsimd_sleef(+0.1959762320720533080e-1)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, s, vcast_vd_d_advsimd_sleef(+0.6808936399446784138e-1)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, s, vcast_vd_d_advsimd_sleef(+0.2069958494722676234e+0)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, s, vcast_vd_d_advsimd_sleef(+0.5393829292058536229e+0)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, s, vcast_vd_d_advsimd_sleef(+0.1171255148908541655e+1)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, s, vcast_vd_d_advsimd_sleef(+0.2034678592293432953e+1)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, s, vcast_vd_d_advsimd_sleef(+0.2650949055239205876e+1)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, s, vcast_vd_d_advsimd_sleef(+0.2302585092994045901e+1)); + + u = vfma_vd_vd_vd_vd_advsimd_sleef(u, s, vcast_vd_d_advsimd_sleef(1)); + + u = vldexp2_vd_vd_vi_advsimd_sleef(u, q); + + u = vsel_vd_vo_vd_vd_advsimd_sleef(vgt_vo_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(308.25471555991671)), vcast_vd_d_advsimd_sleef(__builtin_inf()), u); + u = vreinterpret_vd_vm_advsimd_sleef(vandnot_vm_vo64_vm_advsimd_sleef(vlt_vo_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(-350)), vreinterpret_vm_vd_advsimd_sleef(u))); + + return u; +} + +SLEEF_INLINE SLEEF_CONST vdouble_advsimd_sleef Sleef_exp10d2_u35advsimd(vdouble_advsimd_sleef d) { + vdouble_advsimd_sleef u = vrint_vd_vd_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(3.3219280948873623478703194294893901758648313930))), s; + vint_advsimd_sleef q = vrint_vi_vd_advsimd_sleef(u); + + s = vmla_vd_vd_vd_vd_advsimd_sleef(u, vcast_vd_d_advsimd_sleef(-0.30102999566383914498), d); + s = vmla_vd_vd_vd_vd_advsimd_sleef(u, vcast_vd_d_advsimd_sleef(-1.4205023227266099418e-13), s); + + vdouble_advsimd_sleef s2 = vmul_vd_vd_vd_advsimd_sleef(s, s), s4 = vmul_vd_vd_vd_advsimd_sleef(s2, s2), s8 = vmul_vd_vd_vd_advsimd_sleef(s4, s4); + u = vmla_vd_vd_vd_vd_advsimd_sleef((s8), (vmla_vd_vd_vd_vd_advsimd_sleef((s2), (vcast_vd_d_advsimd_sleef(+0.2411463498334267652e-3)), (vmla_vd_vd_vd_vd_advsimd_sleef((s), (vcast_vd_d_advsimd_sleef(+0.1157488415217187375e-2)), (vcast_vd_d_advsimd_sleef(+0.5013975546789733659e-2)))))), (vmla_vd_vd_vd_vd_advsimd_sleef((s4), (vmla_vd_vd_vd_vd_advsimd_sleef((s2), (vmla_vd_vd_vd_vd_advsimd_sleef((s), (vcast_vd_d_advsimd_sleef(+0.1959762320720533080e-1)), (vcast_vd_d_advsimd_sleef(+0.6808936399446784138e-1)))), (vmla_vd_vd_vd_vd_advsimd_sleef((s), (vcast_vd_d_advsimd_sleef(+0.2069958494722676234e+0)), (vcast_vd_d_advsimd_sleef(+0.5393829292058536229e+0)))))), (vmla_vd_vd_vd_vd_advsimd_sleef((s2), (vmla_vd_vd_vd_vd_advsimd_sleef((s), (vcast_vd_d_advsimd_sleef(+0.1171255148908541655e+1)), (vcast_vd_d_advsimd_sleef(+0.2034678592293432953e+1)))), (vmla_vd_vd_vd_vd_advsimd_sleef((s), (vcast_vd_d_advsimd_sleef(+0.2650949055239205876e+1)), (vcast_vd_d_advsimd_sleef(+0.2302585092994045901e+1))))))))) + + ; + + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, s, vcast_vd_d_advsimd_sleef(1)); + + u = vldexp2_vd_vd_vi_advsimd_sleef(u, q); + + u = vsel_vd_vo_vd_vd_advsimd_sleef(vgt_vo_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(308.25471555991671)), vcast_vd_d_advsimd_sleef(__builtin_inf()), u); + u = vreinterpret_vd_vm_advsimd_sleef(vandnot_vm_vo64_vm_advsimd_sleef(vlt_vo_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(-350)), vreinterpret_vm_vd_advsimd_sleef(u))); + + return u; +} + +SLEEF_INLINE SLEEF_CONST vdouble_advsimd_sleef Sleef_expm1d2_u10advsimd(vdouble_advsimd_sleef a) { + vdouble2_advsimd_sleef d = ddadd2_vd2_vd2_vd_advsimd_sleef(expk2_advsimd_sleef(vcast_vd2_vd_vd_advsimd_sleef(a, vcast_vd_d_advsimd_sleef(0))), vcast_vd_d_advsimd_sleef(-1.0)); + vdouble_advsimd_sleef x = vadd_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(d), vd2gety_vd_vd2_advsimd_sleef(d)); + x = vsel_vd_vo_vd_vd_advsimd_sleef(vgt_vo_vd_vd_advsimd_sleef(a, vcast_vd_d_advsimd_sleef(709.782712893383996732223)), vcast_vd_d_advsimd_sleef(__builtin_inf()), x); + x = vsel_vd_vo_vd_vd_advsimd_sleef(vlt_vo_vd_vd_advsimd_sleef(a, vcast_vd_d_advsimd_sleef(-36.736800569677101399113302437)), vcast_vd_d_advsimd_sleef(-1), x); + x = vsel_vd_vo_vd_vd_advsimd_sleef(visnegzero_vo_vd_advsimd_sleef(a), vcast_vd_d_advsimd_sleef(-0.0), x); + return x; +} + +SLEEF_INLINE SLEEF_CONST vdouble_advsimd_sleef Sleef_log10d2_u10advsimd(vdouble_advsimd_sleef d) { + vdouble2_advsimd_sleef x; + vdouble_advsimd_sleef t, m, x2; + + vopmask_advsimd_sleef o = vlt_vo_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(0x1p-1022)); + d = vsel_vd_vo_vd_vd_advsimd_sleef(o, vmul_vd_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef((double)(INT64_C(1) << 32) * (double)(INT64_C(1) << 32))), d); + vint_advsimd_sleef e = vilogb2k_vi_vd_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(1.0/0.75))); + m = vldexp3_vd_vd_vi_advsimd_sleef(d, vneg_vi_vi_advsimd_sleef(e)); + e = vsel_vi_vo_vi_vi_advsimd_sleef(vcast_vo32_vo64_advsimd_sleef(o), vsub_vi_vi_vi_advsimd_sleef(e, vcast_vi_i_advsimd_sleef(64)), e); + + x = dddiv_vd2_vd2_vd2_advsimd_sleef(ddadd2_vd2_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(-1), m), ddadd2_vd2_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(1), m)); + x2 = vmul_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(x), vd2getx_vd_vd2_advsimd_sleef(x)); + + vdouble_advsimd_sleef x4 = vmul_vd_vd_vd_advsimd_sleef(x2, x2), x8 = vmul_vd_vd_vd_advsimd_sleef(x4, x4); + t = vmla_vd_vd_vd_vd_advsimd_sleef((x8), (vmla_vd_vd_vd_vd_advsimd_sleef((x4), (vcast_vd_d_advsimd_sleef(+0.6653725819576758460e-1)), (vmla_vd_vd_vd_vd_advsimd_sleef((x2), (vcast_vd_d_advsimd_sleef(+0.6625722782820833712e-1)), (vcast_vd_d_advsimd_sleef(+0.7898105214313944078e-1)))))), (vmla_vd_vd_vd_vd_advsimd_sleef((x4), (vmla_vd_vd_vd_vd_advsimd_sleef((x2), (vcast_vd_d_advsimd_sleef(+0.9650955035715275132e-1)), (vcast_vd_d_advsimd_sleef(+0.1240841409721444993e+0)))), (vmla_vd_vd_vd_vd_advsimd_sleef((x2), (vcast_vd_d_advsimd_sleef(+0.1737177927454605086e+0)), (vcast_vd_d_advsimd_sleef(+0.2895296546021972617e+0))))))) + + ; + + vdouble2_advsimd_sleef s = ddmul_vd2_vd2_vd_advsimd_sleef(vcast_vd2_d_d_advsimd_sleef(0.30102999566398119802, -2.803728127785170339e-18), vcast_vd_vi_advsimd_sleef(e)); + + s = ddadd_vd2_vd2_vd2_advsimd_sleef(s, ddmul_vd2_vd2_vd2_advsimd_sleef(x, vcast_vd2_d_d_advsimd_sleef(0.86858896380650363334, 1.1430059694096389311e-17))); + s = ddadd_vd2_vd2_vd_advsimd_sleef(s, vmul_vd_vd_vd_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(x2, vd2getx_vd_vd2_advsimd_sleef(x)), t)); + + vdouble_advsimd_sleef r = vadd_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(s), vd2gety_vd_vd2_advsimd_sleef(s)); + + r = vsel_vd_vo_vd_vd_advsimd_sleef(vispinf_vo_vd_advsimd_sleef(d), vcast_vd_d_advsimd_sleef(__builtin_inf()), r); + r = vsel_vd_vo_vd_vd_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(vlt_vo_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(0)), visnan_vo_vd_advsimd_sleef(d)), vcast_vd_d_advsimd_sleef(__builtin_nan("")), r); + r = vsel_vd_vo_vd_vd_advsimd_sleef(veq_vo_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(0)), vcast_vd_d_advsimd_sleef(-__builtin_inf()), r); + + return r; +} + +SLEEF_INLINE SLEEF_CONST vdouble_advsimd_sleef Sleef_log2d2_u10advsimd(vdouble_advsimd_sleef d) { + vdouble2_advsimd_sleef x; + vdouble_advsimd_sleef t, m, x2; + + vopmask_advsimd_sleef o = vlt_vo_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(0x1p-1022)); + d = vsel_vd_vo_vd_vd_advsimd_sleef(o, vmul_vd_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef((double)(INT64_C(1) << 32) * (double)(INT64_C(1) << 32))), d); + vint_advsimd_sleef e = vilogb2k_vi_vd_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(1.0/0.75))); + m = vldexp3_vd_vd_vi_advsimd_sleef(d, vneg_vi_vi_advsimd_sleef(e)); + e = vsel_vi_vo_vi_vi_advsimd_sleef(vcast_vo32_vo64_advsimd_sleef(o), vsub_vi_vi_vi_advsimd_sleef(e, vcast_vi_i_advsimd_sleef(64)), e); + + x = dddiv_vd2_vd2_vd2_advsimd_sleef(ddadd2_vd2_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(-1), m), ddadd2_vd2_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(1), m)); + x2 = vmul_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(x), vd2getx_vd_vd2_advsimd_sleef(x)); + + vdouble_advsimd_sleef x4 = vmul_vd_vd_vd_advsimd_sleef(x2, x2), x8 = vmul_vd_vd_vd_advsimd_sleef(x4, x4); + t = vmla_vd_vd_vd_vd_advsimd_sleef((x8), (vmla_vd_vd_vd_vd_advsimd_sleef((x4), (vcast_vd_d_advsimd_sleef(+0.2211941750456081490e+0)), (vmla_vd_vd_vd_vd_advsimd_sleef((x2), (vcast_vd_d_advsimd_sleef(+0.2200768693152277689e+0)), (vcast_vd_d_advsimd_sleef(+0.2623708057488514656e+0)))))), (vmla_vd_vd_vd_vd_advsimd_sleef((x4), (vmla_vd_vd_vd_vd_advsimd_sleef((x2), (vcast_vd_d_advsimd_sleef(+0.3205977477944495502e+0)), (vcast_vd_d_advsimd_sleef(+0.4121985945485324709e+0)))), (vmla_vd_vd_vd_vd_advsimd_sleef((x2), (vcast_vd_d_advsimd_sleef(+0.5770780162997058982e+0)), (vcast_vd_d_advsimd_sleef(+0.96179669392608091449))))))) + + ; + + vdouble2_advsimd_sleef s = ddadd2_vd2_vd_vd2_advsimd_sleef(vcast_vd_vi_advsimd_sleef(e), + ddmul_vd2_vd2_vd2_advsimd_sleef(x, vcast_vd2_d_d_advsimd_sleef(2.885390081777926774, 6.0561604995516736434e-18))); + + s = ddadd2_vd2_vd2_vd_advsimd_sleef(s, vmul_vd_vd_vd_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(x2, vd2getx_vd_vd2_advsimd_sleef(x)), t)); + + vdouble_advsimd_sleef r = vadd_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(s), vd2gety_vd_vd2_advsimd_sleef(s)); + + r = vsel_vd_vo_vd_vd_advsimd_sleef(vispinf_vo_vd_advsimd_sleef(d), vcast_vd_d_advsimd_sleef(__builtin_inf()), r); + r = vsel_vd_vo_vd_vd_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(vlt_vo_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(0)), visnan_vo_vd_advsimd_sleef(d)), vcast_vd_d_advsimd_sleef(__builtin_nan("")), r); + r = vsel_vd_vo_vd_vd_advsimd_sleef(veq_vo_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(0)), vcast_vd_d_advsimd_sleef(-__builtin_inf()), r); + + return r; +} + +SLEEF_INLINE SLEEF_CONST vdouble_advsimd_sleef Sleef_log2d2_u35advsimd(vdouble_advsimd_sleef d) { + vdouble_advsimd_sleef m, t, x, x2; + + vopmask_advsimd_sleef o = vlt_vo_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(0x1p-1022)); + d = vsel_vd_vo_vd_vd_advsimd_sleef(o, vmul_vd_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef((double)(INT64_C(1) << 32) * (double)(INT64_C(1) << 32))), d); + vint_advsimd_sleef e = vilogb2k_vi_vd_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(1.0/0.75))); + m = vldexp3_vd_vd_vi_advsimd_sleef(d, vneg_vi_vi_advsimd_sleef(e)); + e = vsel_vi_vo_vi_vi_advsimd_sleef(vcast_vo32_vo64_advsimd_sleef(o), vsub_vi_vi_vi_advsimd_sleef(e, vcast_vi_i_advsimd_sleef(64)), e); + + x = vdiv_vd_vd_vd_advsimd_sleef(vsub_vd_vd_vd_advsimd_sleef(m, vcast_vd_d_advsimd_sleef(1)), vadd_vd_vd_vd_advsimd_sleef(m, vcast_vd_d_advsimd_sleef(1))); + x2 = vmul_vd_vd_vd_advsimd_sleef(x, x); + + t = vcast_vd_d_advsimd_sleef(+0.2211941750456081490e+0); + t = vmla_vd_vd_vd_vd_advsimd_sleef(t, x2, vcast_vd_d_advsimd_sleef(+0.2200768693152277689e+0)); + t = vmla_vd_vd_vd_vd_advsimd_sleef(t, x2, vcast_vd_d_advsimd_sleef(+0.2623708057488514656e+0)); + t = vmla_vd_vd_vd_vd_advsimd_sleef(t, x2, vcast_vd_d_advsimd_sleef(+0.3205977477944495502e+0)); + t = vmla_vd_vd_vd_vd_advsimd_sleef(t, x2, vcast_vd_d_advsimd_sleef(+0.4121985945485324709e+0)); + t = vmla_vd_vd_vd_vd_advsimd_sleef(t, x2, vcast_vd_d_advsimd_sleef(+0.5770780162997058982e+0)); + t = vmla_vd_vd_vd_vd_advsimd_sleef(t, x2, vcast_vd_d_advsimd_sleef(+0.96179669392608091449 )); + + vdouble2_advsimd_sleef s = ddadd_vd2_vd_vd2_advsimd_sleef(vcast_vd_vi_advsimd_sleef(e), + ddmul_vd2_vd_vd_advsimd_sleef(x, vcast_vd_d_advsimd_sleef(2.885390081777926774))); + + vdouble_advsimd_sleef r = vmla_vd_vd_vd_vd_advsimd_sleef(t, vmul_vd_vd_vd_advsimd_sleef(x, x2), vadd_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(s), vd2gety_vd_vd2_advsimd_sleef(s))); + + r = vsel_vd_vo_vd_vd_advsimd_sleef(vispinf_vo_vd_advsimd_sleef(d), vcast_vd_d_advsimd_sleef(__builtin_inf()), r); + r = vsel_vd_vo_vd_vd_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(vlt_vo_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(0)), visnan_vo_vd_advsimd_sleef(d)), vcast_vd_d_advsimd_sleef(__builtin_nan("")), r); + r = vsel_vd_vo_vd_vd_advsimd_sleef(veq_vo_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(0)), vcast_vd_d_advsimd_sleef(-__builtin_inf()), r); + + return r; +} + +SLEEF_INLINE SLEEF_CONST vdouble_advsimd_sleef Sleef_log1pd2_u10advsimd(vdouble_advsimd_sleef d) { + vdouble2_advsimd_sleef x; + vdouble_advsimd_sleef t, m, x2; + + vdouble_advsimd_sleef dp1 = vadd_vd_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(1)); + + vopmask_advsimd_sleef o = vlt_vo_vd_vd_advsimd_sleef(dp1, vcast_vd_d_advsimd_sleef(0x1p-1022)); + dp1 = vsel_vd_vo_vd_vd_advsimd_sleef(o, vmul_vd_vd_vd_advsimd_sleef(dp1, vcast_vd_d_advsimd_sleef((double)(INT64_C(1) << 32) * (double)(INT64_C(1) << 32))), dp1); + vint_advsimd_sleef e = vilogb2k_vi_vd_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(dp1, vcast_vd_d_advsimd_sleef(1.0/0.75))); + t = vldexp3_vd_vd_vi_advsimd_sleef(vcast_vd_d_advsimd_sleef(1), vneg_vi_vi_advsimd_sleef(e)); + m = vmla_vd_vd_vd_vd_advsimd_sleef(d, t, vsub_vd_vd_vd_advsimd_sleef(t, vcast_vd_d_advsimd_sleef(1))); + e = vsel_vi_vo_vi_vi_advsimd_sleef(vcast_vo32_vo64_advsimd_sleef(o), vsub_vi_vi_vi_advsimd_sleef(e, vcast_vi_i_advsimd_sleef(64)), e); + vdouble2_advsimd_sleef s = ddmul_vd2_vd2_vd_advsimd_sleef(vcast_vd2_d_d_advsimd_sleef(0.693147180559945286226764, 2.319046813846299558417771e-17), vcast_vd_vi_advsimd_sleef(e)); + + x = dddiv_vd2_vd2_vd2_advsimd_sleef(vcast_vd2_vd_vd_advsimd_sleef(m, vcast_vd_d_advsimd_sleef(0)), ddadd_vd2_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(2), m)); + x2 = vmul_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(x), vd2getx_vd_vd2_advsimd_sleef(x)); + + vdouble_advsimd_sleef x4 = vmul_vd_vd_vd_advsimd_sleef(x2, x2), x8 = vmul_vd_vd_vd_advsimd_sleef(x4, x4); + t = vmla_vd_vd_vd_vd_advsimd_sleef((x8), (vmla_vd_vd_vd_vd_advsimd_sleef((x4), (vcast_vd_d_advsimd_sleef(0.1532076988502701353e+0)), (vmla_vd_vd_vd_vd_advsimd_sleef((x2), (vcast_vd_d_advsimd_sleef(0.1525629051003428716e+0)), (vcast_vd_d_advsimd_sleef(0.1818605932937785996e+0)))))), (vmla_vd_vd_vd_vd_advsimd_sleef((x4), (vmla_vd_vd_vd_vd_advsimd_sleef((x2), (vcast_vd_d_advsimd_sleef(0.2222214519839380009e+0)), (vcast_vd_d_advsimd_sleef(0.2857142932794299317e+0)))), (vmla_vd_vd_vd_vd_advsimd_sleef((x2), (vcast_vd_d_advsimd_sleef(0.3999999999635251990e+0)), (vcast_vd_d_advsimd_sleef(0.6666666666667333541e+0))))))) + + ; + + s = ddadd_vd2_vd2_vd2_advsimd_sleef(s, ddscale_vd2_vd2_vd_advsimd_sleef(x, vcast_vd_d_advsimd_sleef(2))); + s = ddadd_vd2_vd2_vd_advsimd_sleef(s, vmul_vd_vd_vd_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(x2, vd2getx_vd_vd2_advsimd_sleef(x)), t)); + + vdouble_advsimd_sleef r = vadd_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(s), vd2gety_vd_vd2_advsimd_sleef(s)); + + r = vsel_vd_vo_vd_vd_advsimd_sleef(vgt_vo_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(1e+307)), vcast_vd_d_advsimd_sleef(__builtin_inf()), r); + r = vsel_vd_vo_vd_vd_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(vlt_vo_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(-1)), visnan_vo_vd_advsimd_sleef(d)), vcast_vd_d_advsimd_sleef(__builtin_nan("")), r); + r = vsel_vd_vo_vd_vd_advsimd_sleef(veq_vo_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(-1)), vcast_vd_d_advsimd_sleef(-__builtin_inf()), r); + r = vsel_vd_vo_vd_vd_advsimd_sleef(visnegzero_vo_vd_advsimd_sleef(d), vcast_vd_d_advsimd_sleef(-0.0), r); + + return r; +} + +SLEEF_INLINE SLEEF_CONST vdouble_advsimd_sleef Sleef_fabsd2_advsimd(vdouble_advsimd_sleef x) { return vabs_vd_vd_advsimd_sleef(x); } + +SLEEF_INLINE SLEEF_CONST vdouble_advsimd_sleef Sleef_copysignd2_advsimd(vdouble_advsimd_sleef x, vdouble_advsimd_sleef y) { return vcopysign_vd_vd_vd_advsimd_sleef(x, y); } + +SLEEF_INLINE SLEEF_CONST vdouble_advsimd_sleef Sleef_fmaxd2_advsimd(vdouble_advsimd_sleef x, vdouble_advsimd_sleef y) { + + return vsel_vd_vo_vd_vd_advsimd_sleef(visnan_vo_vd_advsimd_sleef(y), x, vsel_vd_vo_vd_vd_advsimd_sleef(vgt_vo_vd_vd_advsimd_sleef(x, y), x, y)); + +} + +SLEEF_INLINE SLEEF_CONST vdouble_advsimd_sleef Sleef_fmind2_advsimd(vdouble_advsimd_sleef x, vdouble_advsimd_sleef y) { + + return vsel_vd_vo_vd_vd_advsimd_sleef(visnan_vo_vd_advsimd_sleef(y), x, vsel_vd_vo_vd_vd_advsimd_sleef(vgt_vo_vd_vd_advsimd_sleef(y, x), x, y)); + +} + +SLEEF_INLINE SLEEF_CONST vdouble_advsimd_sleef Sleef_fdimd2_advsimd(vdouble_advsimd_sleef x, vdouble_advsimd_sleef y) { + vdouble_advsimd_sleef ret = vsub_vd_vd_vd_advsimd_sleef(x, y); + ret = vsel_vd_vo_vd_vd_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(vlt_vo_vd_vd_advsimd_sleef(ret, vcast_vd_d_advsimd_sleef(0)), veq_vo_vd_vd_advsimd_sleef(x, y)), vcast_vd_d_advsimd_sleef(0), ret); + return ret; +} + +SLEEF_INLINE SLEEF_CONST vdouble_advsimd_sleef Sleef_truncd2_advsimd(vdouble_advsimd_sleef x) { return vtruncate2_vd_vd_advsimd_sleef_advsimd_sleef(x); } +SLEEF_INLINE SLEEF_CONST vdouble_advsimd_sleef Sleef_floord2_advsimd(vdouble_advsimd_sleef x) { return vfloor2_vd_vd_advsimd_sleef(x); } +SLEEF_INLINE SLEEF_CONST vdouble_advsimd_sleef Sleef_ceild2_advsimd(vdouble_advsimd_sleef x) { return vceil2_vd_vd_advsimd_sleef(x); } +SLEEF_INLINE SLEEF_CONST vdouble_advsimd_sleef Sleef_roundd2_advsimd(vdouble_advsimd_sleef x) { return vround2_vd_vd_advsimd_sleef(x); } +SLEEF_INLINE SLEEF_CONST vdouble_advsimd_sleef Sleef_rintd2_advsimd(vdouble_advsimd_sleef x) { return vrint2_vd_vd_advsimd_sleef(x); } + +SLEEF_INLINE SLEEF_CONST vdouble_advsimd_sleef Sleef_nextafterd2_advsimd(vdouble_advsimd_sleef x, vdouble_advsimd_sleef y) { + x = vsel_vd_vo_vd_vd_advsimd_sleef(veq_vo_vd_vd_advsimd_sleef(x, vcast_vd_d_advsimd_sleef(0)), vmulsign_vd_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(0), y), x); + vmask_advsimd_sleef xi2 = vreinterpret_vm_vd_advsimd_sleef(x); + vopmask_advsimd_sleef c = vxor_vo_vo_vo_advsimd_sleef(vsignbit_vo_vd_advsimd_sleef(x), vge_vo_vd_vd_advsimd_sleef(y, x)); + + xi2 = vsel_vm_vo64_vm_vm_advsimd_sleef(c, vneg64_vm_vm_advsimd_sleef(vxor_vm_vm_vm_advsimd_sleef(xi2, vcast_vm_i_i_advsimd_sleef((int)(1U << 31), 0))), xi2); + + xi2 = vsel_vm_vo64_vm_vm_advsimd_sleef(vneq_vo_vd_vd_advsimd_sleef(x, y), vsub64_vm_vm_vm_advsimd_sleef(xi2, vcast_vm_i_i_advsimd_sleef(0, 1)), xi2); + + xi2 = vsel_vm_vo64_vm_vm_advsimd_sleef(c, vneg64_vm_vm_advsimd_sleef(vxor_vm_vm_vm_advsimd_sleef(xi2, vcast_vm_i_i_advsimd_sleef((int)(1U << 31), 0))), xi2); + + vdouble_advsimd_sleef ret = vreinterpret_vd_vm_advsimd_sleef(xi2); + + ret = vsel_vd_vo_vd_vd_advsimd_sleef(vand_vo_vo_vo_advsimd_sleef(veq_vo_vd_vd_advsimd_sleef(ret, vcast_vd_d_advsimd_sleef(0)), vneq_vo_vd_vd_advsimd_sleef(x, vcast_vd_d_advsimd_sleef(0))), + vmulsign_vd_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(0), x), ret); + + ret = vsel_vd_vo_vd_vd_advsimd_sleef(vand_vo_vo_vo_advsimd_sleef(veq_vo_vd_vd_advsimd_sleef(x, vcast_vd_d_advsimd_sleef(0)), veq_vo_vd_vd_advsimd_sleef(y, vcast_vd_d_advsimd_sleef(0))), y, ret); + + ret = vsel_vd_vo_vd_vd_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(visnan_vo_vd_advsimd_sleef(x), visnan_vo_vd_advsimd_sleef(y)), vcast_vd_d_advsimd_sleef(__builtin_nan("")), ret); + + return ret; +} + +SLEEF_INLINE SLEEF_CONST vdouble_advsimd_sleef Sleef_frfrexpd2_advsimd(vdouble_advsimd_sleef x) { + x = vsel_vd_vo_vd_vd_advsimd_sleef(vlt_vo_vd_vd_advsimd_sleef(vabs_vd_vd_advsimd_sleef(x), vcast_vd_d_advsimd_sleef(0x1p-1022)), vmul_vd_vd_vd_advsimd_sleef(x, vcast_vd_d_advsimd_sleef(UINT64_C(1) << 63)), x); + + vmask_advsimd_sleef xm = vreinterpret_vm_vd_advsimd_sleef(x); + xm = vand_vm_vm_vm_advsimd_sleef(xm, vcast_vm_i64_advsimd_sleef(~INT64_C(0x7ff0000000000000))); + xm = vor_vm_vm_vm_advsimd_sleef (xm, vcast_vm_i64_advsimd_sleef( INT64_C(0x3fe0000000000000))); + + vdouble_advsimd_sleef ret = vreinterpret_vd_vm_advsimd_sleef(xm); + + ret = vsel_vd_vo_vd_vd_advsimd_sleef(visinf_vo_vd_advsimd_sleef(x), vmulsign_vd_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(__builtin_inf()), x), ret); + ret = vsel_vd_vo_vd_vd_advsimd_sleef(veq_vo_vd_vd_advsimd_sleef(x, vcast_vd_d_advsimd_sleef(0)), x, ret); + + return ret; +} + +SLEEF_INLINE SLEEF_CONST vint_advsimd_sleef Sleef_expfrexpd2_advsimd(vdouble_advsimd_sleef x) { + x = vsel_vd_vo_vd_vd_advsimd_sleef(vlt_vo_vd_vd_advsimd_sleef(vabs_vd_vd_advsimd_sleef(x), vcast_vd_d_advsimd_sleef(0x1p-1022)), vmul_vd_vd_vd_advsimd_sleef(x, vcast_vd_d_advsimd_sleef(UINT64_C(1) << 63)), x); + + vint_advsimd_sleef ret = vcastu_vi_vm_advsimd_sleef(vreinterpret_vm_vd_advsimd_sleef(x)); + ret = vsub_vi_vi_vi_advsimd_sleef(vand_vi_vi_vi_advsimd_sleef(vreinterpret_s32_u32(vshr_n_u32(vreinterpret_u32_s32(ret), 20)), vcast_vi_i_advsimd_sleef(0x7ff)), vcast_vi_i_advsimd_sleef(0x3fe)); + + ret = vsel_vi_vo_vi_vi_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(veq_vo_vd_vd_advsimd_sleef(x, vcast_vd_d_advsimd_sleef(0)), visnan_vo_vd_advsimd_sleef(x)), visinf_vo_vd_advsimd_sleef(x)), vcast_vi_i_advsimd_sleef(0), ret); + + return ret; +} + +SLEEF_INLINE SLEEF_CONST vdouble_advsimd_sleef Sleef_fmad2_advsimd(vdouble_advsimd_sleef x, vdouble_advsimd_sleef y, vdouble_advsimd_sleef z) { + + return vfma_vd_vd_vd_vd_advsimd_sleef(x, y, z); + +} + +SLEEF_INLINE SLEEF_CONST vdouble_advsimd_sleef Sleef_sqrtd2_u05advsimd(vdouble_advsimd_sleef d) { + + vdouble_advsimd_sleef q, w, x, y, z; + + d = vsel_vd_vo_vd_vd_advsimd_sleef(vlt_vo_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(0)), vcast_vd_d_advsimd_sleef(__builtin_nan("")), d); + + vopmask_advsimd_sleef o = vlt_vo_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(8.636168555094445E-78)); + d = vsel_vd_vo_vd_vd_advsimd_sleef(o, vmul_vd_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(1.157920892373162E77)), d); + q = vsel_vd_vo_vd_vd_advsimd_sleef(o, vcast_vd_d_advsimd_sleef(2.9387358770557188E-39), vcast_vd_d_advsimd_sleef(1)); + + y = vreinterpret_vd_vm_advsimd_sleef(vsub64_vm_vm_vm_advsimd_sleef(vcast_vm_i_i_advsimd_sleef(0x5fe6ec85, 0xe7de30da), vreinterpretq_u32_u64(vshrq_n_u64(vreinterpretq_u64_u32(vreinterpret_vm_vd_advsimd_sleef(d)), 1)))); + + x = vmul_vd_vd_vd_advsimd_sleef(d, y); w = vmul_vd_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(0.5), y); + y = vfmanp_vd_vd_vd_vd_advsimd_sleef(x, w, vcast_vd_d_advsimd_sleef(0.5)); + x = vfma_vd_vd_vd_vd_advsimd_sleef(x, y, x); w = vfma_vd_vd_vd_vd_advsimd_sleef(w, y, w); + y = vfmanp_vd_vd_vd_vd_advsimd_sleef(x, w, vcast_vd_d_advsimd_sleef(0.5)); + x = vfma_vd_vd_vd_vd_advsimd_sleef(x, y, x); w = vfma_vd_vd_vd_vd_advsimd_sleef(w, y, w); + y = vfmanp_vd_vd_vd_vd_advsimd_sleef(x, w, vcast_vd_d_advsimd_sleef(0.5)); + x = vfma_vd_vd_vd_vd_advsimd_sleef(x, y, x); w = vfma_vd_vd_vd_vd_advsimd_sleef(w, y, w); + + y = vfmanp_vd_vd_vd_vd_advsimd_sleef(x, w, vcast_vd_d_advsimd_sleef(1.5)); w = vadd_vd_vd_vd_advsimd_sleef(w, w); + w = vmul_vd_vd_vd_advsimd_sleef(w, y); + x = vmul_vd_vd_vd_advsimd_sleef(w, d); + y = vfmapn_vd_vd_vd_vd_advsimd_sleef(w, d, x); z = vfmanp_vd_vd_vd_vd_advsimd_sleef(w, x, vcast_vd_d_advsimd_sleef(1)); + + z = vfmanp_vd_vd_vd_vd_advsimd_sleef(w, y, z); w = vmul_vd_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(0.5), x); + w = vfma_vd_vd_vd_vd_advsimd_sleef(w, z, y); + w = vadd_vd_vd_vd_advsimd_sleef(w, x); + + w = vmul_vd_vd_vd_advsimd_sleef(w, q); + + w = vsel_vd_vo_vd_vd_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(veq_vo_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(0)), + veq_vo_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(__builtin_inf()))), d, w); + + w = vsel_vd_vo_vd_vd_advsimd_sleef(vlt_vo_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(0)), vcast_vd_d_advsimd_sleef(__builtin_nan("")), w); + + return w; + +} + +SLEEF_INLINE SLEEF_CONST vdouble_advsimd_sleef Sleef_sqrtd2_advsimd(vdouble_advsimd_sleef d) { + + return vsqrt_vd_vd_advsimd_sleef(d); + +} + +SLEEF_INLINE SLEEF_CONST vdouble_advsimd_sleef Sleef_sqrtd2_u35advsimd(vdouble_advsimd_sleef d) { return Sleef_sqrtd2_u05advsimd(d); } + +SLEEF_INLINE SLEEF_CONST vdouble_advsimd_sleef Sleef_hypotd2_u05advsimd(vdouble_advsimd_sleef x, vdouble_advsimd_sleef y) { + x = vabs_vd_vd_advsimd_sleef(x); + y = vabs_vd_vd_advsimd_sleef(y); + vdouble_advsimd_sleef min = vmin_vd_vd_vd_advsimd_sleef(x, y), n = min; + vdouble_advsimd_sleef max = vmax_vd_vd_vd_advsimd_sleef(x, y), d = max; + + vopmask_advsimd_sleef o = vlt_vo_vd_vd_advsimd_sleef(max, vcast_vd_d_advsimd_sleef(0x1p-1022)); + n = vsel_vd_vo_vd_vd_advsimd_sleef(o, vmul_vd_vd_vd_advsimd_sleef(n, vcast_vd_d_advsimd_sleef(UINT64_C(1) << 54)), n); + d = vsel_vd_vo_vd_vd_advsimd_sleef(o, vmul_vd_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(UINT64_C(1) << 54)), d); + + vdouble2_advsimd_sleef t = dddiv_vd2_vd2_vd2_advsimd_sleef(vcast_vd2_vd_vd_advsimd_sleef(n, vcast_vd_d_advsimd_sleef(0)), vcast_vd2_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(0))); + t = ddmul_vd2_vd2_vd_advsimd_sleef(ddsqrt_vd2_vd2_advsimd_sleef(ddadd2_vd2_vd2_vd_advsimd_sleef(ddsqu_vd2_vd2_advsimd_sleef(t), vcast_vd_d_advsimd_sleef(1))), max); + vdouble_advsimd_sleef ret = vadd_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(t), vd2gety_vd_vd2_advsimd_sleef(t)); + ret = vsel_vd_vo_vd_vd_advsimd_sleef(visnan_vo_vd_advsimd_sleef(ret), vcast_vd_d_advsimd_sleef(__builtin_inf()), ret); + ret = vsel_vd_vo_vd_vd_advsimd_sleef(veq_vo_vd_vd_advsimd_sleef(min, vcast_vd_d_advsimd_sleef(0)), max, ret); + ret = vsel_vd_vo_vd_vd_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(visnan_vo_vd_advsimd_sleef(x), visnan_vo_vd_advsimd_sleef(y)), vcast_vd_d_advsimd_sleef(__builtin_nan("")), ret); + ret = vsel_vd_vo_vd_vd_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(veq_vo_vd_vd_advsimd_sleef(x, vcast_vd_d_advsimd_sleef(__builtin_inf())), veq_vo_vd_vd_advsimd_sleef(y, vcast_vd_d_advsimd_sleef(__builtin_inf()))), vcast_vd_d_advsimd_sleef(__builtin_inf()), ret); + + return ret; +} + +SLEEF_INLINE SLEEF_CONST vdouble_advsimd_sleef Sleef_hypotd2_u35advsimd(vdouble_advsimd_sleef x, vdouble_advsimd_sleef y) { + x = vabs_vd_vd_advsimd_sleef(x); + y = vabs_vd_vd_advsimd_sleef(y); + vdouble_advsimd_sleef min = vmin_vd_vd_vd_advsimd_sleef(x, y); + vdouble_advsimd_sleef max = vmax_vd_vd_vd_advsimd_sleef(x, y); + + vdouble_advsimd_sleef t = vdiv_vd_vd_vd_advsimd_sleef(min, max); + vdouble_advsimd_sleef ret = vmul_vd_vd_vd_advsimd_sleef(max, vsqrt_vd_vd_advsimd_sleef(vmla_vd_vd_vd_vd_advsimd_sleef(t, t, vcast_vd_d_advsimd_sleef(1)))); + ret = vsel_vd_vo_vd_vd_advsimd_sleef(veq_vo_vd_vd_advsimd_sleef(min, vcast_vd_d_advsimd_sleef(0)), max, ret); + ret = vsel_vd_vo_vd_vd_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(visnan_vo_vd_advsimd_sleef(x), visnan_vo_vd_advsimd_sleef(y)), vcast_vd_d_advsimd_sleef(__builtin_nan("")), ret); + ret = vsel_vd_vo_vd_vd_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(veq_vo_vd_vd_advsimd_sleef(x, vcast_vd_d_advsimd_sleef(__builtin_inf())), veq_vo_vd_vd_advsimd_sleef(y, vcast_vd_d_advsimd_sleef(__builtin_inf()))), vcast_vd_d_advsimd_sleef(__builtin_inf()), ret); + + return ret; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_advsimd_sleef vptrunc_vd_vd_advsimd_sleef(vdouble_advsimd_sleef x) { + + return vtruncate_vd_vd_advsimd_sleef(x); + +} + +SLEEF_INLINE SLEEF_CONST vdouble_advsimd_sleef Sleef_fmodd2_advsimd(vdouble_advsimd_sleef x, vdouble_advsimd_sleef y) { + vdouble_advsimd_sleef n = vabs_vd_vd_advsimd_sleef(x), d = vabs_vd_vd_advsimd_sleef(y), s = vcast_vd_d_advsimd_sleef(1), q; + vopmask_advsimd_sleef o = vlt_vo_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(0x1p-1022)); + n = vsel_vd_vo_vd_vd_advsimd_sleef(o, vmul_vd_vd_vd_advsimd_sleef(n, vcast_vd_d_advsimd_sleef(UINT64_C(1) << 54)), n); + d = vsel_vd_vo_vd_vd_advsimd_sleef(o, vmul_vd_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(UINT64_C(1) << 54)), d); + s = vsel_vd_vo_vd_vd_advsimd_sleef(o, vmul_vd_vd_vd_advsimd_sleef(s , vcast_vd_d_advsimd_sleef(1.0 / (UINT64_C(1) << 54))), s); + vdouble2_advsimd_sleef r = vcast_vd2_vd_vd_advsimd_sleef(n, vcast_vd_d_advsimd_sleef(0)); + vdouble_advsimd_sleef rd = vtoward0_vd_vd_advsimd_sleef(vrec_vd_vd_advsimd_sleef(d)); + + for(int i=0;i<21;i++) { + q = vptrunc_vd_vd_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(vtoward0_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(r)), rd)); + + q = vsel_vd_vo_vd_vd_advsimd_sleef(vand_vo_vo_vo_advsimd_sleef(vgt_vo_vd_vd_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(3), d), vd2getx_vd_vd2_advsimd_sleef(r)), + vge_vo_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(r), d)), + vcast_vd_d_advsimd_sleef(2), q); + q = vsel_vd_vo_vd_vd_advsimd_sleef(vand_vo_vo_vo_advsimd_sleef(vgt_vo_vd_vd_advsimd_sleef(vadd_vd_vd_vd_advsimd_sleef(d, d), vd2getx_vd_vd2_advsimd_sleef(r)), + vge_vo_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(r), d)), + vcast_vd_d_advsimd_sleef(1), q); + r = ddnormalize_vd2_vd2_advsimd_sleef(ddadd2_vd2_vd2_vd2_advsimd_sleef(r, ddmul_vd2_vd_vd_advsimd_sleef(q, vneg_vd_vd_advsimd_sleef(d)))); + if (vtestallones_i_vo64_advsimd_sleef(vlt_vo_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(r), d))) break; + } + + vdouble_advsimd_sleef ret = vmul_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(r), s); + ret = vsel_vd_vo_vd_vd_advsimd_sleef(veq_vo_vd_vd_advsimd_sleef(vadd_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(r), vd2gety_vd_vd2_advsimd_sleef(r)), d), vcast_vd_d_advsimd_sleef(0), ret); + + ret = vmulsign_vd_vd_vd_advsimd_sleef(ret, x); + + ret = vsel_vd_vo_vd_vd_advsimd_sleef(vlt_vo_vd_vd_advsimd_sleef(n, d), x, ret); + ret = vsel_vd_vo_vd_vd_advsimd_sleef(veq_vo_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(0)), vcast_vd_d_advsimd_sleef(__builtin_nan("")), ret); + + return ret; +} + +static SLEEF_ALWAYS_INLINE vdouble_advsimd_sleef vrintk2_vd_vd_advsimd_sleef(vdouble_advsimd_sleef d) { + + return vrint_vd_vd_advsimd_sleef(d); + +} + +SLEEF_INLINE SLEEF_CONST vdouble_advsimd_sleef Sleef_remainderd2_advsimd(vdouble_advsimd_sleef x, vdouble_advsimd_sleef y) { + vdouble_advsimd_sleef n = vabs_vd_vd_advsimd_sleef(x), d = vabs_vd_vd_advsimd_sleef(y), s = vcast_vd_d_advsimd_sleef(1), q; + vopmask_advsimd_sleef o = vlt_vo_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(0x1p-1022*2)); + n = vsel_vd_vo_vd_vd_advsimd_sleef(o, vmul_vd_vd_vd_advsimd_sleef(n, vcast_vd_d_advsimd_sleef(UINT64_C(1) << 54)), n); + d = vsel_vd_vo_vd_vd_advsimd_sleef(o, vmul_vd_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(UINT64_C(1) << 54)), d); + s = vsel_vd_vo_vd_vd_advsimd_sleef(o, vmul_vd_vd_vd_advsimd_sleef(s , vcast_vd_d_advsimd_sleef(1.0 / (UINT64_C(1) << 54))), s); + vdouble_advsimd_sleef rd = vrec_vd_vd_advsimd_sleef(d); + vdouble2_advsimd_sleef r = vcast_vd2_vd_vd_advsimd_sleef(n, vcast_vd_d_advsimd_sleef(0)); + vopmask_advsimd_sleef qisodd = vneq_vo_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(0), vcast_vd_d_advsimd_sleef(0)); + + for(int i=0;i<21;i++) { + q = vrintk2_vd_vd_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(r), rd)); + + q = vsel_vd_vo_vd_vd_advsimd_sleef(vlt_vo_vd_vd_advsimd_sleef(vabs_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(r)), vmul_vd_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(1.5))), vmulsign_vd_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(1.0), vd2getx_vd_vd2_advsimd_sleef(r)), q); + q = vsel_vd_vo_vd_vd_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(vlt_vo_vd_vd_advsimd_sleef(vabs_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(r)), vmul_vd_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(0.5))), + vandnot_vo_vo_vo_advsimd_sleef(qisodd, veq_vo_vd_vd_advsimd_sleef(vabs_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(r)), vmul_vd_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(0.5))))), + vcast_vd_d_advsimd_sleef(0.0), q); + if (vtestallones_i_vo64_advsimd_sleef(veq_vo_vd_vd_advsimd_sleef(q, vcast_vd_d_advsimd_sleef(0)))) break; + q = vsel_vd_vo_vd_vd_advsimd_sleef(visinf_vo_vd_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(q, vneg_vd_vd_advsimd_sleef(d))), vadd_vd_vd_vd_advsimd_sleef(q, vmulsign_vd_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(-1), vd2getx_vd_vd2_advsimd_sleef(r))), q); + qisodd = vxor_vo_vo_vo_advsimd_sleef(qisodd, visodd_vo_vd_advsimd_sleef(q)); + r = ddnormalize_vd2_vd2_advsimd_sleef(ddadd2_vd2_vd2_vd2_advsimd_sleef(r, ddmul_vd2_vd_vd_advsimd_sleef(q, vneg_vd_vd_advsimd_sleef(d)))); + } + + vdouble_advsimd_sleef ret = vmul_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(r), s); + ret = vmulsign_vd_vd_vd_advsimd_sleef(ret, x); + ret = vsel_vd_vo_vd_vd_advsimd_sleef(visinf_vo_vd_advsimd_sleef(y), vsel_vd_vo_vd_vd_advsimd_sleef(visinf_vo_vd_advsimd_sleef(x), vcast_vd_d_advsimd_sleef(__builtin_nan("")), x), ret); + ret = vsel_vd_vo_vd_vd_advsimd_sleef(veq_vo_vd_vd_advsimd_sleef(d, vcast_vd_d_advsimd_sleef(0)), vcast_vd_d_advsimd_sleef(__builtin_nan("")), ret); + return ret; +} + +static SLEEF_CONST dd2_advsimd_sleef gammak_advsimd_sleef(vdouble_advsimd_sleef a) { + vdouble2_advsimd_sleef clc = vcast_vd2_d_d_advsimd_sleef(0, 0), clln = vcast_vd2_d_d_advsimd_sleef(1, 0), clld = vcast_vd2_d_d_advsimd_sleef(1, 0); + vdouble2_advsimd_sleef x, y, z; + vdouble_advsimd_sleef t, u; + + vopmask_advsimd_sleef otiny = vlt_vo_vd_vd_advsimd_sleef(vabs_vd_vd_advsimd_sleef(a), vcast_vd_d_advsimd_sleef(1e-306)), oref = vlt_vo_vd_vd_advsimd_sleef(a, vcast_vd_d_advsimd_sleef(0.5)); + + x = vsel_vd2_vo_vd2_vd2_advsimd_sleef(otiny, vcast_vd2_d_d_advsimd_sleef(0, 0), + vsel_vd2_vo_vd2_vd2_advsimd_sleef(oref, ddadd2_vd2_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(1), vneg_vd_vd_advsimd_sleef(a)), + vcast_vd2_vd_vd_advsimd_sleef(a, vcast_vd_d_advsimd_sleef(0)))); + + vopmask_advsimd_sleef o0 = vand_vo_vo_vo_advsimd_sleef(vle_vo_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(0.5), vd2getx_vd_vd2_advsimd_sleef(x)), vle_vo_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(x), vcast_vd_d_advsimd_sleef(1.1))); + vopmask_advsimd_sleef o2 = vle_vo_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(2.3), vd2getx_vd_vd2_advsimd_sleef(x)); + + y = ddnormalize_vd2_vd2_advsimd_sleef(ddmul_vd2_vd2_vd2_advsimd_sleef(ddadd2_vd2_vd2_vd_advsimd_sleef(x, vcast_vd_d_advsimd_sleef(1)), x)); + y = ddnormalize_vd2_vd2_advsimd_sleef(ddmul_vd2_vd2_vd2_advsimd_sleef(ddadd2_vd2_vd2_vd_advsimd_sleef(x, vcast_vd_d_advsimd_sleef(2)), y)); + y = ddnormalize_vd2_vd2_advsimd_sleef(ddmul_vd2_vd2_vd2_advsimd_sleef(ddadd2_vd2_vd2_vd_advsimd_sleef(x, vcast_vd_d_advsimd_sleef(3)), y)); + y = ddnormalize_vd2_vd2_advsimd_sleef(ddmul_vd2_vd2_vd2_advsimd_sleef(ddadd2_vd2_vd2_vd_advsimd_sleef(x, vcast_vd_d_advsimd_sleef(4)), y)); + + vopmask_advsimd_sleef o = vand_vo_vo_vo_advsimd_sleef(o2, vle_vo_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(x), vcast_vd_d_advsimd_sleef(7))); + clln = vsel_vd2_vo_vd2_vd2_advsimd_sleef(o, y, clln); + + x = vsel_vd2_vo_vd2_vd2_advsimd_sleef(o, ddadd2_vd2_vd2_vd_advsimd_sleef(x, vcast_vd_d_advsimd_sleef(5)), x); + + t = vsel_vd_vo_vd_vd_advsimd_sleef(o2, vrec_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(x)), vd2getx_vd_vd2_advsimd_sleef(ddnormalize_vd2_vd2_advsimd_sleef(ddadd2_vd2_vd2_vd_advsimd_sleef(x, vsel_vd_vo_d_d_advsimd_sleef(o0, -1, -2))))); + + u = vsel_vd_vo_vo_d_d_d_advsimd_sleef(o2, o0, -156.801412704022726379848862, +0.2947916772827614196e+2, +0.7074816000864609279e-7); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, t, vsel_vd_vo_vo_d_d_d_advsimd_sleef(o2, o0, +1.120804464289911606838558160000, +0.1281459691827820109e+3, +0.4009244333008730443e-6)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, t, vsel_vd_vo_vo_d_d_d_advsimd_sleef(o2, o0, +13.39798545514258921833306020000, +0.2617544025784515043e+3, +0.1040114641628246946e-5)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, t, vsel_vd_vo_vo_d_d_d_advsimd_sleef(o2, o0, -0.116546276599463200848033357000, +0.3287022855685790432e+3, +0.1508349150733329167e-5)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, t, vsel_vd_vo_vo_d_d_d_advsimd_sleef(o2, o0, -1.391801093265337481495562410000, +0.2818145867730348186e+3, +0.1288143074933901020e-5)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, t, vsel_vd_vo_vo_d_d_d_advsimd_sleef(o2, o0, +0.015056113040026424412918973400, +0.1728670414673559605e+3, +0.4744167749884993937e-6)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, t, vsel_vd_vo_vo_d_d_d_advsimd_sleef(o2, o0, +0.179540117061234856098844714000, +0.7748735764030416817e+2, -0.6554816306542489902e-7)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, t, vsel_vd_vo_vo_d_d_d_advsimd_sleef(o2, o0, -0.002481743600264997730942489280, +0.2512856643080930752e+2, -0.3189252471452599844e-6)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, t, vsel_vd_vo_vo_d_d_d_advsimd_sleef(o2, o0, -0.029527880945699120504851034100, +0.5766792106140076868e+1, +0.1358883821470355377e-6)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, t, vsel_vd_vo_vo_d_d_d_advsimd_sleef(o2, o0, +0.000540164767892604515196325186, +0.7270275473996180571e+0, -0.4343931277157336040e-6)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, t, vsel_vd_vo_vo_d_d_d_advsimd_sleef(o2, o0, +0.006403362833808069794787256200, +0.8396709124579147809e-1, +0.9724785897406779555e-6)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, t, vsel_vd_vo_vo_d_d_d_advsimd_sleef(o2, o0, -0.000162516262783915816896611252, -0.8211558669746804595e-1, -0.2036886057225966011e-5)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, t, vsel_vd_vo_vo_d_d_d_advsimd_sleef(o2, o0, -0.001914438498565477526465972390, +0.6828831828341884458e-1, +0.4373363141819725815e-5)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, t, vsel_vd_vo_vo_d_d_d_advsimd_sleef(o2, o0, +7.20489541602001055898311517e-05, -0.7712481339961671511e-1, -0.9439951268304008677e-5)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, t, vsel_vd_vo_vo_d_d_d_advsimd_sleef(o2, o0, +0.000839498720672087279971000786, +0.8337492023017314957e-1, +0.2050727030376389804e-4)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, t, vsel_vd_vo_vo_d_d_d_advsimd_sleef(o2, o0, -5.17179090826059219329394422e-05, -0.9094964931456242518e-1, -0.4492620183431184018e-4)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, t, vsel_vd_vo_vo_d_d_d_advsimd_sleef(o2, o0, -0.000592166437353693882857342347, +0.1000996313575929358e+0, +0.9945751236071875931e-4)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, t, vsel_vd_vo_vo_d_d_d_advsimd_sleef(o2, o0, +6.97281375836585777403743539e-05, -0.1113342861544207724e+0, -0.2231547599034983196e-3)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, t, vsel_vd_vo_vo_d_d_d_advsimd_sleef(o2, o0, +0.000784039221720066627493314301, +0.1255096673213020875e+0, +0.5096695247101967622e-3)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, t, vsel_vd_vo_vo_d_d_d_advsimd_sleef(o2, o0, -0.000229472093621399176949318732, -0.1440498967843054368e+0, -0.1192753911667886971e-2)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, t, vsel_vd_vo_vo_d_d_d_advsimd_sleef(o2, o0, -0.002681327160493827160473958490, +0.1695571770041949811e+0, +0.2890510330742210310e-2)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, t, vsel_vd_vo_vo_d_d_d_advsimd_sleef(o2, o0, +0.003472222222222222222175164840, -0.2073855510284092762e+0, -0.7385551028674461858e-2)); + u = vmla_vd_vd_vd_vd_advsimd_sleef(u, t, vsel_vd_vo_vo_d_d_d_advsimd_sleef(o2, o0, +0.083333333333333333335592087900, +0.2705808084277815939e+0, +0.2058080842778455335e-1)); + + y = ddmul_vd2_vd2_vd2_advsimd_sleef(ddadd2_vd2_vd2_vd_advsimd_sleef(x, vcast_vd_d_advsimd_sleef(-0.5)), logk2_advsimd_sleef(x)); + y = ddadd2_vd2_vd2_vd2_advsimd_sleef(y, ddneg_vd2_vd2_advsimd_sleef(x)); + y = ddadd2_vd2_vd2_vd2_advsimd_sleef(y, vcast_vd2_d_d_advsimd_sleef(0.91893853320467278056, -3.8782941580672414498e-17)); + + z = ddadd2_vd2_vd2_vd_advsimd_sleef(ddmul_vd2_vd_vd_advsimd_sleef (u, t), vsel_vd_vo_d_d_advsimd_sleef(o0, -0.4006856343865314862e+0, -0.6735230105319810201e-1)); + z = ddadd2_vd2_vd2_vd_advsimd_sleef(ddmul_vd2_vd2_vd_advsimd_sleef(z, t), vsel_vd_vo_d_d_advsimd_sleef(o0, +0.8224670334241132030e+0, +0.3224670334241132030e+0)); + z = ddadd2_vd2_vd2_vd_advsimd_sleef(ddmul_vd2_vd2_vd_advsimd_sleef(z, t), vsel_vd_vo_d_d_advsimd_sleef(o0, -0.5772156649015328655e+0, +0.4227843350984671345e+0)); + z = ddmul_vd2_vd2_vd_advsimd_sleef(z, t); + + clc = vsel_vd2_vo_vd2_vd2_advsimd_sleef(o2, y, z); + + clld = vsel_vd2_vo_vd2_vd2_advsimd_sleef(o2, ddadd2_vd2_vd2_vd_advsimd_sleef(ddmul_vd2_vd_vd_advsimd_sleef(u, t), vcast_vd_d_advsimd_sleef(1)), clld); + + y = clln; + + clc = vsel_vd2_vo_vd2_vd2_advsimd_sleef(otiny, vcast_vd2_d_d_advsimd_sleef(83.1776616671934334590333, 3.67103459631568507221878e-15), + vsel_vd2_vo_vd2_vd2_advsimd_sleef(oref, ddadd2_vd2_vd2_vd2_advsimd_sleef(vcast_vd2_d_d_advsimd_sleef(1.1447298858494001639, 1.026595116270782638e-17), ddneg_vd2_vd2_advsimd_sleef(clc)), clc)); + clln = vsel_vd2_vo_vd2_vd2_advsimd_sleef(otiny, vcast_vd2_d_d_advsimd_sleef(1, 0), vsel_vd2_vo_vd2_vd2_advsimd_sleef(oref, clln, clld)); + + if (!vtestallones_i_vo64_advsimd_sleef(vnot_vo64_vo64_advsimd_sleef(oref))) { + t = vsub_vd_vd_vd_advsimd_sleef(a, vmul_vd_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(INT64_C(1) << 28), vcast_vd_vi_advsimd_sleef(vtruncate_vi_vd_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(a, vcast_vd_d_advsimd_sleef(1.0 / (INT64_C(1) << 28))))))); + x = ddmul_vd2_vd2_vd2_advsimd_sleef(clld, sinpik_advsimd_sleef(t)); + } + + clld = vsel_vd2_vo_vd2_vd2_advsimd_sleef(otiny, vcast_vd2_vd_vd_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(a, vcast_vd_d_advsimd_sleef((INT64_C(1) << 60)*(double)(INT64_C(1) << 60))), vcast_vd_d_advsimd_sleef(0)), + vsel_vd2_vo_vd2_vd2_advsimd_sleef(oref, x, y)); + + return dd2setab_dd2_vd2_vd2_advsimd_sleef(clc, dddiv_vd2_vd2_vd2_advsimd_sleef(clln, clld)); +} + +SLEEF_INLINE SLEEF_CONST vdouble_advsimd_sleef Sleef_tgammad2_u10advsimd(vdouble_advsimd_sleef a) { + dd2_advsimd_sleef d = gammak_advsimd_sleef(a); + vdouble2_advsimd_sleef y = ddmul_vd2_vd2_vd2_advsimd_sleef(expk2_advsimd_sleef(dd2geta_vd2_dd2_advsimd_sleef(d)), dd2getb_vd2_dd2_advsimd_sleef(d)); + vdouble_advsimd_sleef r = vadd_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(y), vd2gety_vd_vd2_advsimd_sleef(y)); + vopmask_advsimd_sleef o; + + o = vor_vo_vo_vo_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(veq_vo_vd_vd_advsimd_sleef(a, vcast_vd_d_advsimd_sleef(-__builtin_inf())), + vand_vo_vo_vo_advsimd_sleef(vlt_vo_vd_vd_advsimd_sleef(a, vcast_vd_d_advsimd_sleef(0)), visint_vo_vd_advsimd_sleef(a))), + vand_vo_vo_vo_advsimd_sleef(vand_vo_vo_vo_advsimd_sleef(visnumber_vo_vd_advsimd_sleef(a), vlt_vo_vd_vd_advsimd_sleef(a, vcast_vd_d_advsimd_sleef(0))), visnan_vo_vd_advsimd_sleef(r))); + r = vsel_vd_vo_vd_vd_advsimd_sleef(o, vcast_vd_d_advsimd_sleef(__builtin_nan("")), r); + + o = vand_vo_vo_vo_advsimd_sleef(vand_vo_vo_vo_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(veq_vo_vd_vd_advsimd_sleef(a, vcast_vd_d_advsimd_sleef(__builtin_inf())), visnumber_vo_vd_advsimd_sleef(a)), + vge_vo_vd_vd_advsimd_sleef(a, vcast_vd_d_advsimd_sleef(-0x1p-1022))), + vor_vo_vo_vo_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(veq_vo_vd_vd_advsimd_sleef(a, vcast_vd_d_advsimd_sleef(0)), vgt_vo_vd_vd_advsimd_sleef(a, vcast_vd_d_advsimd_sleef(200))), visnan_vo_vd_advsimd_sleef(r))); + r = vsel_vd_vo_vd_vd_advsimd_sleef(o, vmulsign_vd_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(__builtin_inf()), a), r); + + return r; +} + +SLEEF_INLINE SLEEF_CONST vdouble_advsimd_sleef Sleef_lgammad2_u10advsimd(vdouble_advsimd_sleef a) { + dd2_advsimd_sleef d = gammak_advsimd_sleef(a); + vdouble2_advsimd_sleef y = ddadd2_vd2_vd2_vd2_advsimd_sleef(dd2geta_vd2_dd2_advsimd_sleef(d), logk2_advsimd_sleef(ddabs_vd2_vd2_advsimd_sleef(dd2getb_vd2_dd2_advsimd_sleef(d)))); + vdouble_advsimd_sleef r = vadd_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(y), vd2gety_vd_vd2_advsimd_sleef(y)); + vopmask_advsimd_sleef o; + + o = vor_vo_vo_vo_advsimd_sleef(visinf_vo_vd_advsimd_sleef(a), + vor_vo_vo_vo_advsimd_sleef(vand_vo_vo_vo_advsimd_sleef(vle_vo_vd_vd_advsimd_sleef(a, vcast_vd_d_advsimd_sleef(0)), visint_vo_vd_advsimd_sleef(a)), + vand_vo_vo_vo_advsimd_sleef(visnumber_vo_vd_advsimd_sleef(a), visnan_vo_vd_advsimd_sleef(r)))); + r = vsel_vd_vo_vd_vd_advsimd_sleef(o, vcast_vd_d_advsimd_sleef(__builtin_inf()), r); + + return r; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_advsimd_sleef ddmla_vd2_vd_vd2_vd2_advsimd_sleef(vdouble_advsimd_sleef x, vdouble2_advsimd_sleef y, vdouble2_advsimd_sleef z) { + return ddadd_vd2_vd2_vd2_advsimd_sleef(z, ddmul_vd2_vd2_vd_advsimd_sleef(y, x)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_advsimd_sleef poly2dd_b_advsimd_sleef(vdouble_advsimd_sleef x, vdouble2_advsimd_sleef c1, vdouble2_advsimd_sleef c0) { return ddmla_vd2_vd_vd2_vd2_advsimd_sleef(x, c1, c0); } +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_advsimd_sleef poly2dd_advsimd_sleef(vdouble_advsimd_sleef x, vdouble_advsimd_sleef c1, vdouble2_advsimd_sleef c0) { return ddmla_vd2_vd_vd2_vd2_advsimd_sleef(x, vcast_vd2_vd_vd_advsimd_sleef(c1, vcast_vd_d_advsimd_sleef(0)), c0); } +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_advsimd_sleef poly4dd_advsimd_sleef(vdouble_advsimd_sleef x, vdouble_advsimd_sleef c3, vdouble2_advsimd_sleef c2, vdouble2_advsimd_sleef c1, vdouble2_advsimd_sleef c0) { + return ddmla_vd2_vd_vd2_vd2_advsimd_sleef(vmul_vd_vd_vd_advsimd_sleef(x, x), poly2dd_advsimd_sleef(x, c3, c2), poly2dd_b_advsimd_sleef(x, c1, c0)); +} + +SLEEF_INLINE SLEEF_CONST vdouble_advsimd_sleef Sleef_erfd2_u10advsimd(vdouble_advsimd_sleef a) { + vdouble_advsimd_sleef t, x = vabs_vd_vd_advsimd_sleef(a); + vdouble2_advsimd_sleef t2; + vdouble_advsimd_sleef x2 = vmul_vd_vd_vd_advsimd_sleef(x, x), x4 = vmul_vd_vd_vd_advsimd_sleef(x2, x2); + vdouble_advsimd_sleef x8 = vmul_vd_vd_vd_advsimd_sleef(x4, x4), x16 = vmul_vd_vd_vd_advsimd_sleef(x8, x8); + vopmask_advsimd_sleef o25 = vle_vo_vd_vd_advsimd_sleef(x, vcast_vd_d_advsimd_sleef(2.5)); + + if (__builtin_expect(!!(vtestallones_i_vo64_advsimd_sleef(o25)), 1)) { + + t = vmla_vd_vd_vd_vd_advsimd_sleef((x16), (vmla_vd_vd_vd_vd_advsimd_sleef((x4), (vcast_vd_d_advsimd_sleef(-0.2083271002525222097e-14)), (vmla_vd_vd_vd_vd_advsimd_sleef((x2), (vmla_vd_vd_vd_vd_advsimd_sleef((x), (vcast_vd_d_advsimd_sleef(+0.7151909970790897009e-13)), (vcast_vd_d_advsimd_sleef(-0.1162238220110999364e-11)))), (vmla_vd_vd_vd_vd_advsimd_sleef((x), (vcast_vd_d_advsimd_sleef(+0.1186474230821585259e-10)), (vcast_vd_d_advsimd_sleef(-0.8499973178354613440e-10)))))))), (vmla_vd_vd_vd_vd_advsimd_sleef((x8), (vmla_vd_vd_vd_vd_advsimd_sleef((x4), (vmla_vd_vd_vd_vd_advsimd_sleef((x2), (vmla_vd_vd_vd_vd_advsimd_sleef((x), (vcast_vd_d_advsimd_sleef(+0.4507647462598841629e-9)), (vcast_vd_d_advsimd_sleef(-0.1808044474288848915e-8)))), (vmla_vd_vd_vd_vd_advsimd_sleef((x), (vcast_vd_d_advsimd_sleef(+0.5435081826716212389e-8)), (vcast_vd_d_advsimd_sleef(-0.1143939895758628484e-7)))))), (vmla_vd_vd_vd_vd_advsimd_sleef((x2), (vmla_vd_vd_vd_vd_advsimd_sleef((x), (vcast_vd_d_advsimd_sleef(+0.1215442362680889243e-7)), (vcast_vd_d_advsimd_sleef(+0.1669878756181250355e-7)))), (vmla_vd_vd_vd_vd_advsimd_sleef((x), (vcast_vd_d_advsimd_sleef(-0.9808074602255194288e-7)), (vcast_vd_d_advsimd_sleef(+0.1389000557865837204e-6)))))))), (vmla_vd_vd_vd_vd_advsimd_sleef((x4), (vmla_vd_vd_vd_vd_advsimd_sleef((x2), (vmla_vd_vd_vd_vd_advsimd_sleef((x), (vcast_vd_d_advsimd_sleef(+0.2945514529987331866e-6)), (vcast_vd_d_advsimd_sleef(-0.1842918273003998283e-5)))), (vmla_vd_vd_vd_vd_advsimd_sleef((x), (vcast_vd_d_advsimd_sleef(+0.3417987836115362136e-5)), (vcast_vd_d_advsimd_sleef(+0.3860236356493129101e-5)))))), (vmla_vd_vd_vd_vd_advsimd_sleef((x2), (vmla_vd_vd_vd_vd_advsimd_sleef((x), (vcast_vd_d_advsimd_sleef(-0.3309403072749947546e-4)), (vcast_vd_d_advsimd_sleef(+0.1060862922597579532e-3)))), (vmla_vd_vd_vd_vd_advsimd_sleef((x), (vcast_vd_d_advsimd_sleef(+0.2323253155213076174e-3)), (vcast_vd_d_advsimd_sleef(+0.1490149719145544729e-3))))))))))) + + ; + t2 = poly4dd_advsimd_sleef(x, t, + vcast_vd2_d_d_advsimd_sleef(0.0092877958392275604405, 7.9287559463961107493e-19), + vcast_vd2_d_d_advsimd_sleef(0.042275531758784692937, 1.3785226620501016138e-19), + vcast_vd2_d_d_advsimd_sleef(0.07052369794346953491, 9.5846628070792092842e-19)); + t2 = ddadd_vd2_vd_vd2_advsimd_sleef(vcast_vd_d_advsimd_sleef(1), ddmul_vd2_vd2_vd_advsimd_sleef(t2, x)); + t2 = ddsqu_vd2_vd2_advsimd_sleef(t2); + t2 = ddsqu_vd2_vd2_advsimd_sleef(t2); + t2 = ddsqu_vd2_vd2_advsimd_sleef(t2); + t2 = ddsqu_vd2_vd2_advsimd_sleef(t2); + t2 = ddrec_vd2_vd2_advsimd_sleef(t2); + } else { + + t = vmla_vd_vd_vd_vd_advsimd_sleef((x16), (vmla_vd_vd_vd_vd_advsimd_sleef((x4), ((vsel_vd_vo_d_d_advsimd_sleef(o25, -0.2083271002525222097e-14, -0.4024015130752621932e-18))), (vmla_vd_vd_vd_vd_advsimd_sleef((x2), (vmla_vd_vd_vd_vd_advsimd_sleef((x), ((vsel_vd_vo_d_d_advsimd_sleef(o25, +0.7151909970790897009e-13, +0.3847193332817048172e-16))), ((vsel_vd_vo_d_d_advsimd_sleef(o25, -0.1162238220110999364e-11, -0.1749316241455644088e-14))))), (vmla_vd_vd_vd_vd_advsimd_sleef((x), ((vsel_vd_vo_d_d_advsimd_sleef(o25, +0.1186474230821585259e-10, +0.5029618322872872715e-13))), ((vsel_vd_vo_d_d_advsimd_sleef(o25, -0.8499973178354613440e-10, -0.1025221466851463164e-11))))))))), (vmla_vd_vd_vd_vd_advsimd_sleef((x8), (vmla_vd_vd_vd_vd_advsimd_sleef((x4), (vmla_vd_vd_vd_vd_advsimd_sleef((x2), (vmla_vd_vd_vd_vd_advsimd_sleef((x), ((vsel_vd_vo_d_d_advsimd_sleef(o25, +0.4507647462598841629e-9, +0.1573695559331945583e-10))), ((vsel_vd_vo_d_d_advsimd_sleef(o25, -0.1808044474288848915e-8, -0.1884658558040203709e-9))))), (vmla_vd_vd_vd_vd_advsimd_sleef((x), ((vsel_vd_vo_d_d_advsimd_sleef(o25, +0.5435081826716212389e-8, +0.1798167853032159309e-8))), ((vsel_vd_vo_d_d_advsimd_sleef(o25, -0.1143939895758628484e-7, -0.1380745342355033142e-7))))))), (vmla_vd_vd_vd_vd_advsimd_sleef((x2), (vmla_vd_vd_vd_vd_advsimd_sleef((x), ((vsel_vd_vo_d_d_advsimd_sleef(o25, +0.1215442362680889243e-7, +0.8525705726469103499e-7))), ((vsel_vd_vo_d_d_advsimd_sleef(o25, +0.1669878756181250355e-7, -0.4160448058101303405e-6))))), (vmla_vd_vd_vd_vd_advsimd_sleef((x), ((vsel_vd_vo_d_d_advsimd_sleef(o25, -0.9808074602255194288e-7, +0.1517272660008588485e-5))), ((vsel_vd_vo_d_d_advsimd_sleef(o25, +0.1389000557865837204e-6, -0.3341634127317201697e-5))))))))), (vmla_vd_vd_vd_vd_advsimd_sleef((x4), (vmla_vd_vd_vd_vd_advsimd_sleef((x2), (vmla_vd_vd_vd_vd_advsimd_sleef((x), ((vsel_vd_vo_d_d_advsimd_sleef(o25, +0.2945514529987331866e-6, -0.2515023395879724513e-5))), ((vsel_vd_vo_d_d_advsimd_sleef(o25, -0.1842918273003998283e-5, +0.6539731269664907554e-4))))), (vmla_vd_vd_vd_vd_advsimd_sleef((x), ((vsel_vd_vo_d_d_advsimd_sleef(o25, +0.3417987836115362136e-5, -0.3551065097428388658e-3))), ((vsel_vd_vo_d_d_advsimd_sleef(o25, +0.3860236356493129101e-5, +0.1210736097958368864e-2))))))), (vmla_vd_vd_vd_vd_advsimd_sleef((x2), (vmla_vd_vd_vd_vd_advsimd_sleef((x), ((vsel_vd_vo_d_d_advsimd_sleef(o25, -0.3309403072749947546e-4, -0.2605566912579998680e-2))), ((vsel_vd_vo_d_d_advsimd_sleef(o25, +0.1060862922597579532e-3, +0.1252823202436093193e-2))))), (vmla_vd_vd_vd_vd_advsimd_sleef((x), ((vsel_vd_vo_d_d_advsimd_sleef(o25, +0.2323253155213076174e-3, +0.1820191395263313222e-1))), ((vsel_vd_vo_d_d_advsimd_sleef(o25, +0.1490149719145544729e-3, -0.1021557155453465954e+0)))))))))))) + + ; + t2 = poly4dd_advsimd_sleef(x, t, + vsel_vd2_vo_vd2_vd2_advsimd_sleef(o25, vcast_vd2_d_d_advsimd_sleef(0.0092877958392275604405, 7.9287559463961107493e-19), + vcast_vd2_d_d_advsimd_sleef(-0.63691044383641748361, -2.4249477526539431839e-17)), + vsel_vd2_vo_vd2_vd2_advsimd_sleef(o25, vcast_vd2_d_d_advsimd_sleef(0.042275531758784692937, 1.3785226620501016138e-19), + vcast_vd2_d_d_advsimd_sleef(-1.1282926061803961737, -6.2970338860410996505e-17)), + vsel_vd2_vo_vd2_vd2_advsimd_sleef(o25, vcast_vd2_d_d_advsimd_sleef(0.07052369794346953491, 9.5846628070792092842e-19), + vcast_vd2_d_d_advsimd_sleef(-1.2261313785184804967e-05, -5.5329707514490107044e-22))); + vdouble2_advsimd_sleef s2 = ddadd_vd2_vd_vd2_advsimd_sleef(vcast_vd_d_advsimd_sleef(1), ddmul_vd2_vd2_vd_advsimd_sleef(t2, x)); + s2 = ddsqu_vd2_vd2_advsimd_sleef(s2); + s2 = ddsqu_vd2_vd2_advsimd_sleef(s2); + s2 = ddsqu_vd2_vd2_advsimd_sleef(s2); + s2 = ddsqu_vd2_vd2_advsimd_sleef(s2); + s2 = ddrec_vd2_vd2_advsimd_sleef(s2); + t2 = vsel_vd2_vo_vd2_vd2_advsimd_sleef(o25, s2, vcast_vd2_vd_vd_advsimd_sleef(expk_advsimd_sleef(t2), vcast_vd_d_advsimd_sleef(0))); + } + + t2 = ddadd2_vd2_vd2_vd_advsimd_sleef(t2, vcast_vd_d_advsimd_sleef(-1)); + + vdouble_advsimd_sleef z = vneg_vd_vd_advsimd_sleef(vadd_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(t2), vd2gety_vd_vd2_advsimd_sleef(t2))); + z = vsel_vd_vo_vd_vd_advsimd_sleef(vlt_vo_vd_vd_advsimd_sleef(x, vcast_vd_d_advsimd_sleef(1e-8)), vmul_vd_vd_vd_advsimd_sleef(x, vcast_vd_d_advsimd_sleef(1.12837916709551262756245475959)), z); + z = vsel_vd_vo_vd_vd_advsimd_sleef(vge_vo_vd_vd_advsimd_sleef(x, vcast_vd_d_advsimd_sleef(6)), vcast_vd_d_advsimd_sleef(1), z); + z = vsel_vd_vo_vd_vd_advsimd_sleef(visinf_vo_vd_advsimd_sleef(a), vcast_vd_d_advsimd_sleef(1), z); + z = vsel_vd_vo_vd_vd_advsimd_sleef(veq_vo_vd_vd_advsimd_sleef(a, vcast_vd_d_advsimd_sleef(0)), vcast_vd_d_advsimd_sleef(0), z); + z = vmulsign_vd_vd_vd_advsimd_sleef(z, a); + + return z; +} + +SLEEF_INLINE SLEEF_CONST vdouble_advsimd_sleef Sleef_erfcd2_u15advsimd(vdouble_advsimd_sleef a) { + vdouble_advsimd_sleef s = a, r = vcast_vd_d_advsimd_sleef(0), t; + vdouble2_advsimd_sleef u, d, x; + a = vabs_vd_vd_advsimd_sleef(a); + vopmask_advsimd_sleef o0 = vlt_vo_vd_vd_advsimd_sleef(a, vcast_vd_d_advsimd_sleef(1.0)); + vopmask_advsimd_sleef o1 = vlt_vo_vd_vd_advsimd_sleef(a, vcast_vd_d_advsimd_sleef(2.2)); + vopmask_advsimd_sleef o2 = vlt_vo_vd_vd_advsimd_sleef(a, vcast_vd_d_advsimd_sleef(4.2)); + vopmask_advsimd_sleef o3 = vlt_vo_vd_vd_advsimd_sleef(a, vcast_vd_d_advsimd_sleef(27.3)); + + u = vsel_vd2_vo_vd2_vd2_advsimd_sleef(o0, ddmul_vd2_vd_vd_advsimd_sleef(a, a), vsel_vd2_vo_vd2_vd2_advsimd_sleef(o1, vcast_vd2_vd_vd_advsimd_sleef(a, vcast_vd_d_advsimd_sleef(0)), dddiv_vd2_vd2_vd2_advsimd_sleef(vcast_vd2_d_d_advsimd_sleef(1, 0), vcast_vd2_vd_vd_advsimd_sleef(a, vcast_vd_d_advsimd_sleef(0))))); + + t = vsel_vd_vo_vo_vo_d_d_d_d_advsimd_sleef(o0, o1, o2, +0.6801072401395386139e-20, +0.3438010341362585303e-12, -0.5757819536420710449e+2, +0.2334249729638701319e+5); + t = vmla_vd_vd_vd_vd_advsimd_sleef(t, vd2getx_vd_vd2_advsimd_sleef(u), vsel_vd_vo_vo_vo_d_d_d_d_advsimd_sleef(o0, o1, o2, -0.2161766247570055669e-18, -0.1237021188160598264e-10, +0.4669289654498104483e+3, -0.4695661044933107769e+5)); + t = vmla_vd_vd_vd_vd_advsimd_sleef(t, vd2getx_vd_vd2_advsimd_sleef(u), vsel_vd_vo_vo_vo_d_d_d_d_advsimd_sleef(o0, o1, o2, +0.4695919173301595670e-17, +0.2117985839877627852e-09, -0.1796329879461355858e+4, +0.3173403108748643353e+5)); + t = vmla_vd_vd_vd_vd_advsimd_sleef(t, vd2getx_vd_vd2_advsimd_sleef(u), vsel_vd_vo_vo_vo_d_d_d_d_advsimd_sleef(o0, o1, o2, -0.9049140419888007122e-16, -0.2290560929177369506e-08, +0.4355892193699575728e+4, +0.3242982786959573787e+4)); + t = vmla_vd_vd_vd_vd_advsimd_sleef(t, vd2getx_vd_vd2_advsimd_sleef(u), vsel_vd_vo_vo_vo_d_d_d_d_advsimd_sleef(o0, o1, o2, +0.1634018903557410728e-14, +0.1748931621698149538e-07, -0.7456258884965764992e+4, -0.2014717999760347811e+5)); + t = vmla_vd_vd_vd_vd_advsimd_sleef(t, vd2getx_vd_vd2_advsimd_sleef(u), vsel_vd_vo_vo_vo_d_d_d_d_advsimd_sleef(o0, o1, o2, -0.2783485786333451745e-13, -0.9956602606623249195e-07, +0.9553977358167021521e+4, +0.1554006970967118286e+5)); + t = vmla_vd_vd_vd_vd_advsimd_sleef(t, vd2getx_vd_vd2_advsimd_sleef(u), vsel_vd_vo_vo_vo_d_d_d_d_advsimd_sleef(o0, o1, o2, +0.4463221276786415752e-12, +0.4330010240640327080e-06, -0.9470019905444229153e+4, -0.6150874190563554293e+4)); + t = vmla_vd_vd_vd_vd_advsimd_sleef(t, vd2getx_vd_vd2_advsimd_sleef(u), vsel_vd_vo_vo_vo_d_d_d_d_advsimd_sleef(o0, o1, o2, -0.6711366622850136563e-11, -0.1435050600991763331e-05, +0.7387344321849855078e+4, +0.1240047765634815732e+4)); + t = vmla_vd_vd_vd_vd_advsimd_sleef(t, vd2getx_vd_vd2_advsimd_sleef(u), vsel_vd_vo_vo_vo_d_d_d_d_advsimd_sleef(o0, o1, o2, +0.9422759050232662223e-10, +0.3460139479650695662e-05, -0.4557713054166382790e+4, -0.8210325475752699731e+2)); + t = vmla_vd_vd_vd_vd_advsimd_sleef(t, vd2getx_vd_vd2_advsimd_sleef(u), vsel_vd_vo_vo_vo_d_d_d_d_advsimd_sleef(o0, o1, o2, -0.1229055530100229098e-08, -0.4988908180632898173e-05, +0.2207866967354055305e+4, +0.3242443880839930870e+2)); + t = vmla_vd_vd_vd_vd_advsimd_sleef(t, vd2getx_vd_vd2_advsimd_sleef(u), vsel_vd_vo_vo_vo_d_d_d_d_advsimd_sleef(o0, o1, o2, +0.1480719281585086512e-07, -0.1308775976326352012e-05, -0.8217975658621754746e+3, -0.2923418863833160586e+2)); + t = vmla_vd_vd_vd_vd_advsimd_sleef(t, vd2getx_vd_vd2_advsimd_sleef(u), vsel_vd_vo_vo_vo_d_d_d_d_advsimd_sleef(o0, o1, o2, -0.1636584469123399803e-06, +0.2825086540850310103e-04, +0.2268659483507917400e+3, +0.3457461732814383071e+0)); + t = vmla_vd_vd_vd_vd_advsimd_sleef(t, vd2getx_vd_vd2_advsimd_sleef(u), vsel_vd_vo_vo_vo_d_d_d_d_advsimd_sleef(o0, o1, o2, +0.1646211436588923575e-05, -0.6393913713069986071e-04, -0.4633361260318560682e+2, +0.5489730155952392998e+1)); + t = vmla_vd_vd_vd_vd_advsimd_sleef(t, vd2getx_vd_vd2_advsimd_sleef(u), vsel_vd_vo_vo_vo_d_d_d_d_advsimd_sleef(o0, o1, o2, -0.1492565035840623511e-04, -0.2566436514695078926e-04, +0.9557380123733945965e+1, +0.1559934132251294134e-2)); + t = vmla_vd_vd_vd_vd_advsimd_sleef(t, vd2getx_vd_vd2_advsimd_sleef(u), vsel_vd_vo_vo_vo_d_d_d_d_advsimd_sleef(o0, o1, o2, +0.1205533298178967851e-03, +0.5895792375659440364e-03, -0.2958429331939661289e+1, -0.1541741566831520638e+1)); + t = vmla_vd_vd_vd_vd_advsimd_sleef(t, vd2getx_vd_vd2_advsimd_sleef(u), vsel_vd_vo_vo_vo_d_d_d_d_advsimd_sleef(o0, o1, o2, -0.8548327023450850081e-03, -0.1695715579163588598e-02, +0.1670329508092765480e+0, +0.2823152230558364186e-5)); + t = vmla_vd_vd_vd_vd_advsimd_sleef(t, vd2getx_vd_vd2_advsimd_sleef(u), vsel_vd_vo_vo_vo_d_d_d_d_advsimd_sleef(o0, o1, o2, +0.5223977625442187932e-02, +0.2089116434918055149e-03, +0.6096615680115419211e+0, +0.6249999184195342838e+0)); + t = vmla_vd_vd_vd_vd_advsimd_sleef(t, vd2getx_vd_vd2_advsimd_sleef(u), vsel_vd_vo_vo_vo_d_d_d_d_advsimd_sleef(o0, o1, o2, -0.2686617064513125222e-01, +0.1912855949584917753e-01, +0.1059212443193543585e-2, +0.1741749416408701288e-8)); + + d = ddmul_vd2_vd2_vd_advsimd_sleef(u, t); + d = ddadd2_vd2_vd2_vd2_advsimd_sleef(d, vcast_vd2_vd_vd_advsimd_sleef(vsel_vd_vo_vo_vo_d_d_d_d_advsimd_sleef(o0, o1, o2, 0.11283791670955126141, -0.10277263343147646779, -0.50005180473999022439, -0.5000000000258444377), + vsel_vd_vo_vo_vo_d_d_d_d_advsimd_sleef(o0, o1, o2, -4.0175691625932118483e-18, -6.2338714083404900225e-18, 2.6362140569041995803e-17, -4.0074044712386992281e-17))); + d = ddmul_vd2_vd2_vd2_advsimd_sleef(d, u); + d = ddadd2_vd2_vd2_vd2_advsimd_sleef(d, vcast_vd2_vd_vd_advsimd_sleef(vsel_vd_vo_vo_vo_d_d_d_d_advsimd_sleef(o0, o1, o2, -0.37612638903183753802, -0.63661976742916359662, 1.601106273924963368e-06, 2.3761973137523364792e-13), + vsel_vd_vo_vo_vo_d_d_d_d_advsimd_sleef(o0, o1, o2, 1.3391897206042552387e-17, 7.6321019159085724662e-18, 1.1974001857764476775e-23, -1.1670076950531026582e-29))); + d = ddmul_vd2_vd2_vd2_advsimd_sleef(d, u); + d = ddadd2_vd2_vd2_vd2_advsimd_sleef(d, vcast_vd2_vd_vd_advsimd_sleef(vsel_vd_vo_vo_vo_d_d_d_d_advsimd_sleef(o0, o1, o2, 1.1283791670955125586, -1.1283791674717296161, -0.57236496645145429341, -0.57236494292470108114), + vsel_vd_vo_vo_vo_d_d_d_d_advsimd_sleef(o0, o1, o2, 1.5335459613165822674e-17, 8.0896847755965377194e-17, 3.0704553245872027258e-17, -2.3984352208056898003e-17))); + + x = ddmul_vd2_vd2_vd_advsimd_sleef(vsel_vd2_vo_vd2_vd2_advsimd_sleef(o1, d, vcast_vd2_vd_vd_advsimd_sleef(vneg_vd_vd_advsimd_sleef(a), vcast_vd_d_advsimd_sleef(0))), a); + x = vsel_vd2_vo_vd2_vd2_advsimd_sleef(o1, x, ddadd2_vd2_vd2_vd2_advsimd_sleef(x, d)); + x = vsel_vd2_vo_vd2_vd2_advsimd_sleef(o0, ddsub_vd2_vd2_vd2_advsimd_sleef(vcast_vd2_d_d_advsimd_sleef(1, 0), x), expk2_advsimd_sleef(x)); + x = vsel_vd2_vo_vd2_vd2_advsimd_sleef(o1, x, ddmul_vd2_vd2_vd2_advsimd_sleef(x, u)); + + r = vsel_vd_vo_vd_vd_advsimd_sleef(o3, vadd_vd_vd_vd_advsimd_sleef(vd2getx_vd_vd2_advsimd_sleef(x), vd2gety_vd_vd2_advsimd_sleef(x)), vcast_vd_d_advsimd_sleef(0)); + r = vsel_vd_vo_vd_vd_advsimd_sleef(vsignbit_vo_vd_advsimd_sleef(s), vsub_vd_vd_vd_advsimd_sleef(vcast_vd_d_advsimd_sleef(2), r), r); + r = vsel_vd_vo_vd_vd_advsimd_sleef(visnan_vo_vd_advsimd_sleef(s), vcast_vd_d_advsimd_sleef(__builtin_nan("")), r); + return r; +} + +#if !defined(__NVCC__) && ((defined(__SIZEOF_FLOAT128__) && __SIZEOF_FLOAT128__ == 16) || (defined(__linux__) && defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))) || (defined(__PPC64__) && defined(__GNUC__) && !defined(__clang__) && __GNUC__ >= 8)) +#define SLEEF_FLOAT128_IS_IEEEQP +#endif + +#if !defined(SLEEF_FLOAT128_IS_IEEEQP) && !defined(__NVCC__) && defined(__SIZEOF_LONG_DOUBLE__) && __SIZEOF_LONG_DOUBLE__ == 16 && (defined(__aarch64__) || defined(__zarch__)) +#define SLEEF_LONGDOUBLE_IS_IEEEQP +#endif + +#if !defined(Sleef_quad_DEFINED) +#define Sleef_quad_DEFINED +typedef struct { uint64_t x, y; } Sleef_uint64_2t; +#if defined(SLEEF_FLOAT128_IS_IEEEQP) +typedef __float128 Sleef_quad; +#define SLEEF_QUAD_C(x) (x ## Q) +#elif defined(SLEEF_LONGDOUBLE_IS_IEEEQP) +typedef long double Sleef_quad; +#define SLEEF_QUAD_C(x) (x ## L) +#else +typedef Sleef_uint64_2t Sleef_quad; +#endif +#endif + +extern const float Sleef_rempitabsp[]; + +typedef struct { + vfloat_advsimd_sleef x, y; +} vfloat2_advsimd_sleef; + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_advsimd_sleef vf2getx_vf_vf2_advsimd_sleef(vfloat2_advsimd_sleef v) { return v.x; } +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_advsimd_sleef vf2gety_vf_vf2_advsimd_sleef(vfloat2_advsimd_sleef v) { return v.y; } +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_advsimd_sleef vf2setxy_vf2_vf_vf_advsimd_sleef(vfloat_advsimd_sleef x, vfloat_advsimd_sleef y) { vfloat2_advsimd_sleef v; v.x = x; v.y = y; return v; } +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_advsimd_sleef vf2setx_vf2_vf2_vf_advsimd_sleef(vfloat2_advsimd_sleef v, vfloat_advsimd_sleef d) { v.x = d; return v; } +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_advsimd_sleef vf2sety_vf2_vf2_vf_advsimd_sleef(vfloat2_advsimd_sleef v, vfloat_advsimd_sleef d) { v.y = d; return v; } + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_advsimd_sleef vupper_vf_vf_advsimd_sleef(vfloat_advsimd_sleef d) { + return vreinterpret_vf_vi2_advsimd_sleef(vand_vi2_vi2_vi2_advsimd_sleef(vreinterpret_vi2_vf_advsimd_sleef(d), vcast_vi2_i_advsimd_sleef(0xfffff000))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_advsimd_sleef vcast_vf2_vf_vf_advsimd_sleef(vfloat_advsimd_sleef h, vfloat_advsimd_sleef l) { + return vf2setxy_vf2_vf_vf_advsimd_sleef(h, l); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_advsimd_sleef vcast_vf2_f_f_advsimd_sleef(float h, float l) { + return vf2setxy_vf2_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(h), vcast_vf_f_advsimd_sleef(l)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_advsimd_sleef vcast_vf2_d_advsimd_sleef(double d) { + return vf2setxy_vf2_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(d), vcast_vf_f_advsimd_sleef(d - (float)d)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_advsimd_sleef vsel_vf2_vo_vf2_vf2_advsimd_sleef(vopmask_advsimd_sleef m, vfloat2_advsimd_sleef x, vfloat2_advsimd_sleef y) { + return vf2setxy_vf2_vf_vf_advsimd_sleef(vsel_vf_vo_vf_vf_advsimd_sleef(m, vf2getx_vf_vf2_advsimd_sleef(x), vf2getx_vf_vf2_advsimd_sleef(y)), vsel_vf_vo_vf_vf_advsimd_sleef(m, vf2gety_vf_vf2_advsimd_sleef(x), vf2gety_vf_vf2_advsimd_sleef(y))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_advsimd_sleef vsel_vf2_vo_f_f_f_f_advsimd_sleef(vopmask_advsimd_sleef o, float x1, float y1, float x0, float y0) { + return vf2setxy_vf2_vf_vf_advsimd_sleef(vsel_vf_vo_f_f_advsimd_sleef(o, x1, x0), vsel_vf_vo_f_f_advsimd_sleef(o, y1, y0)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_advsimd_sleef vsel_vf2_vo_vo_d_d_d_advsimd_sleef(vopmask_advsimd_sleef o0, vopmask_advsimd_sleef o1, double d0, double d1, double d2) { + return vsel_vf2_vo_vf2_vf2_advsimd_sleef(o0, vcast_vf2_d_advsimd_sleef(d0), vsel_vf2_vo_vf2_vf2_advsimd_sleef(o1, vcast_vf2_d_advsimd_sleef(d1), vcast_vf2_d_advsimd_sleef(d2))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_advsimd_sleef vsel_vf2_vo_vo_vo_d_d_d_d_advsimd_sleef(vopmask_advsimd_sleef o0, vopmask_advsimd_sleef o1, vopmask_advsimd_sleef o2, double d0, double d1, double d2, double d3) { + return vsel_vf2_vo_vf2_vf2_advsimd_sleef(o0, vcast_vf2_d_advsimd_sleef(d0), vsel_vf2_vo_vf2_vf2_advsimd_sleef(o1, vcast_vf2_d_advsimd_sleef(d1), vsel_vf2_vo_vf2_vf2_advsimd_sleef(o2, vcast_vf2_d_advsimd_sleef(d2), vcast_vf2_d_advsimd_sleef(d3)))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_advsimd_sleef vabs_vf2_vf2_advsimd_sleef(vfloat2_advsimd_sleef x) { + return vcast_vf2_vf_vf_advsimd_sleef(vreinterpret_vf_vm_advsimd_sleef(vxor_vm_vm_vm_advsimd_sleef(vand_vm_vm_vm_advsimd_sleef(vreinterpret_vm_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(-0.0)), vreinterpret_vm_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(x))), vreinterpret_vm_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(x)))), + vreinterpret_vf_vm_advsimd_sleef(vxor_vm_vm_vm_advsimd_sleef(vand_vm_vm_vm_advsimd_sleef(vreinterpret_vm_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(-0.0)), vreinterpret_vm_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(x))), vreinterpret_vm_vf_advsimd_sleef(vf2gety_vf_vf2_advsimd_sleef(x))))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_advsimd_sleef vadd_vf_3vf_advsimd_sleef(vfloat_advsimd_sleef v0, vfloat_advsimd_sleef v1, vfloat_advsimd_sleef v2) { + return vadd_vf_vf_vf_advsimd_sleef(vadd_vf_vf_vf_advsimd_sleef(v0, v1), v2); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_advsimd_sleef vadd_vf_4vf_advsimd_sleef(vfloat_advsimd_sleef v0, vfloat_advsimd_sleef v1, vfloat_advsimd_sleef v2, vfloat_advsimd_sleef v3) { + return vadd_vf_3vf_advsimd_sleef(vadd_vf_vf_vf_advsimd_sleef(v0, v1), v2, v3); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_advsimd_sleef vadd_vf_5vf_advsimd_sleef(vfloat_advsimd_sleef v0, vfloat_advsimd_sleef v1, vfloat_advsimd_sleef v2, vfloat_advsimd_sleef v3, vfloat_advsimd_sleef v4) { + return vadd_vf_4vf_advsimd_sleef(vadd_vf_vf_vf_advsimd_sleef(v0, v1), v2, v3, v4); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_advsimd_sleef vadd_vf_6vf_advsimd_sleef(vfloat_advsimd_sleef v0, vfloat_advsimd_sleef v1, vfloat_advsimd_sleef v2, vfloat_advsimd_sleef v3, vfloat_advsimd_sleef v4, vfloat_advsimd_sleef v5) { + return vadd_vf_5vf_advsimd_sleef(vadd_vf_vf_vf_advsimd_sleef(v0, v1), v2, v3, v4, v5); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_advsimd_sleef vadd_vf_7vf_advsimd_sleef(vfloat_advsimd_sleef v0, vfloat_advsimd_sleef v1, vfloat_advsimd_sleef v2, vfloat_advsimd_sleef v3, vfloat_advsimd_sleef v4, vfloat_advsimd_sleef v5, vfloat_advsimd_sleef v6) { + return vadd_vf_6vf_advsimd_sleef(vadd_vf_vf_vf_advsimd_sleef(v0, v1), v2, v3, v4, v5, v6); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_advsimd_sleef vsub_vf_3vf_advsimd_sleef(vfloat_advsimd_sleef v0, vfloat_advsimd_sleef v1, vfloat_advsimd_sleef v2) { + return vsub_vf_vf_vf_advsimd_sleef(vsub_vf_vf_vf_advsimd_sleef(v0, v1), v2); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_advsimd_sleef vsub_vf_4vf_advsimd_sleef(vfloat_advsimd_sleef v0, vfloat_advsimd_sleef v1, vfloat_advsimd_sleef v2, vfloat_advsimd_sleef v3) { + return vsub_vf_3vf_advsimd_sleef(vsub_vf_vf_vf_advsimd_sleef(v0, v1), v2, v3); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_advsimd_sleef vsub_vf_5vf_advsimd_sleef(vfloat_advsimd_sleef v0, vfloat_advsimd_sleef v1, vfloat_advsimd_sleef v2, vfloat_advsimd_sleef v3, vfloat_advsimd_sleef v4) { + return vsub_vf_4vf_advsimd_sleef(vsub_vf_vf_vf_advsimd_sleef(v0, v1), v2, v3, v4); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_advsimd_sleef dfneg_vf2_vf2_advsimd_sleef(vfloat2_advsimd_sleef x) { + return vcast_vf2_vf_vf_advsimd_sleef(vneg_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(x)), vneg_vf_vf_advsimd_sleef(vf2gety_vf_vf2_advsimd_sleef(x))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_advsimd_sleef dfabs_vf2_vf2_advsimd_sleef(vfloat2_advsimd_sleef x) { + return vcast_vf2_vf_vf_advsimd_sleef(vabs_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(x)), + vreinterpret_vf_vm_advsimd_sleef(vxor_vm_vm_vm_advsimd_sleef(vreinterpret_vm_vf_advsimd_sleef(vf2gety_vf_vf2_advsimd_sleef(x)), vand_vm_vm_vm_advsimd_sleef(vreinterpret_vm_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(x)), vreinterpret_vm_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(-0.0f)))))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_advsimd_sleef dfnormalize_vf2_vf2_advsimd_sleef(vfloat2_advsimd_sleef t) { + vfloat_advsimd_sleef s = vadd_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(t), vf2gety_vf_vf2_advsimd_sleef(t)); + return vf2setxy_vf2_vf_vf_advsimd_sleef(s, vadd_vf_vf_vf_advsimd_sleef(vsub_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(t), s), vf2gety_vf_vf2_advsimd_sleef(t))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_advsimd_sleef dfscale_vf2_vf2_vf_advsimd_sleef(vfloat2_advsimd_sleef d, vfloat_advsimd_sleef s) { + return vf2setxy_vf2_vf_vf_advsimd_sleef(vmul_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(d), s), vmul_vf_vf_vf_advsimd_sleef(vf2gety_vf_vf2_advsimd_sleef(d), s)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_advsimd_sleef dfadd_vf2_vf_vf_advsimd_sleef(vfloat_advsimd_sleef x, vfloat_advsimd_sleef y) { + vfloat_advsimd_sleef s = vadd_vf_vf_vf_advsimd_sleef(x, y); + return vf2setxy_vf2_vf_vf_advsimd_sleef(s, vadd_vf_vf_vf_advsimd_sleef(vsub_vf_vf_vf_advsimd_sleef(x, s), y)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_advsimd_sleef dfadd2_vf2_vf_vf_advsimd_sleef(vfloat_advsimd_sleef x, vfloat_advsimd_sleef y) { + vfloat_advsimd_sleef s = vadd_vf_vf_vf_advsimd_sleef(x, y); + vfloat_advsimd_sleef v = vsub_vf_vf_vf_advsimd_sleef(s, x); + return vf2setxy_vf2_vf_vf_advsimd_sleef(s, vadd_vf_vf_vf_advsimd_sleef(vsub_vf_vf_vf_advsimd_sleef(x, vsub_vf_vf_vf_advsimd_sleef(s, v)), vsub_vf_vf_vf_advsimd_sleef(y, v))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_advsimd_sleef dfadd2_vf2_vf_vf2_advsimd_sleef(vfloat_advsimd_sleef x, vfloat2_advsimd_sleef y) { + vfloat_advsimd_sleef s = vadd_vf_vf_vf_advsimd_sleef(x, vf2getx_vf_vf2_advsimd_sleef(y)); + vfloat_advsimd_sleef v = vsub_vf_vf_vf_advsimd_sleef(s, x); + return vf2setxy_vf2_vf_vf_advsimd_sleef(s, vadd_vf_vf_vf_advsimd_sleef(vadd_vf_vf_vf_advsimd_sleef(vsub_vf_vf_vf_advsimd_sleef(x, vsub_vf_vf_vf_advsimd_sleef(s, v)), vsub_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(y), v)), vf2gety_vf_vf2_advsimd_sleef(y))); + +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_advsimd_sleef dfadd_vf2_vf2_vf_advsimd_sleef(vfloat2_advsimd_sleef x, vfloat_advsimd_sleef y) { + vfloat_advsimd_sleef s = vadd_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(x), y); + return vf2setxy_vf2_vf_vf_advsimd_sleef(s, vadd_vf_3vf_advsimd_sleef(vsub_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(x), s), y, vf2gety_vf_vf2_advsimd_sleef(x))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_advsimd_sleef dfsub_vf2_vf2_vf_advsimd_sleef(vfloat2_advsimd_sleef x, vfloat_advsimd_sleef y) { + vfloat_advsimd_sleef s = vsub_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(x), y); + return vf2setxy_vf2_vf_vf_advsimd_sleef(s, vadd_vf_vf_vf_advsimd_sleef(vsub_vf_vf_vf_advsimd_sleef(vsub_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(x), s), y), vf2gety_vf_vf2_advsimd_sleef(x))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_advsimd_sleef dfadd2_vf2_vf2_vf_advsimd_sleef(vfloat2_advsimd_sleef x, vfloat_advsimd_sleef y) { + vfloat_advsimd_sleef s = vadd_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(x), y); + vfloat_advsimd_sleef v = vsub_vf_vf_vf_advsimd_sleef(s, vf2getx_vf_vf2_advsimd_sleef(x)); + vfloat_advsimd_sleef t = vadd_vf_vf_vf_advsimd_sleef(vsub_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(x), vsub_vf_vf_vf_advsimd_sleef(s, v)), vsub_vf_vf_vf_advsimd_sleef(y, v)); + return vf2setxy_vf2_vf_vf_advsimd_sleef(s, vadd_vf_vf_vf_advsimd_sleef(t, vf2gety_vf_vf2_advsimd_sleef(x))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_advsimd_sleef dfadd_vf2_vf_vf2_advsimd_sleef(vfloat_advsimd_sleef x, vfloat2_advsimd_sleef y) { + vfloat_advsimd_sleef s = vadd_vf_vf_vf_advsimd_sleef(x, vf2getx_vf_vf2_advsimd_sleef(y)); + return vf2setxy_vf2_vf_vf_advsimd_sleef(s, vadd_vf_3vf_advsimd_sleef(vsub_vf_vf_vf_advsimd_sleef(x, s), vf2getx_vf_vf2_advsimd_sleef(y), vf2gety_vf_vf2_advsimd_sleef(y))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_advsimd_sleef dfadd_vf2_vf2_vf2_advsimd_sleef(vfloat2_advsimd_sleef x, vfloat2_advsimd_sleef y) { + + vfloat_advsimd_sleef s = vadd_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(x), vf2getx_vf_vf2_advsimd_sleef(y)); + return vf2setxy_vf2_vf_vf_advsimd_sleef(s, vadd_vf_4vf_advsimd_sleef(vsub_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(x), s), vf2getx_vf_vf2_advsimd_sleef(y), vf2gety_vf_vf2_advsimd_sleef(x), vf2gety_vf_vf2_advsimd_sleef(y))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_advsimd_sleef dfadd2_vf2_vf2_vf2_advsimd_sleef(vfloat2_advsimd_sleef x, vfloat2_advsimd_sleef y) { + vfloat_advsimd_sleef s = vadd_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(x), vf2getx_vf_vf2_advsimd_sleef(y)); + vfloat_advsimd_sleef v = vsub_vf_vf_vf_advsimd_sleef(s, vf2getx_vf_vf2_advsimd_sleef(x)); + vfloat_advsimd_sleef t = vadd_vf_vf_vf_advsimd_sleef(vsub_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(x), vsub_vf_vf_vf_advsimd_sleef(s, v)), vsub_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(y), v)); + return vf2setxy_vf2_vf_vf_advsimd_sleef(s, vadd_vf_vf_vf_advsimd_sleef(t, vadd_vf_vf_vf_advsimd_sleef(vf2gety_vf_vf2_advsimd_sleef(x), vf2gety_vf_vf2_advsimd_sleef(y)))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_advsimd_sleef dfsub_vf2_vf_vf_advsimd_sleef(vfloat_advsimd_sleef x, vfloat_advsimd_sleef y) { + + vfloat_advsimd_sleef s = vsub_vf_vf_vf_advsimd_sleef(x, y); + return vf2setxy_vf2_vf_vf_advsimd_sleef(s, vsub_vf_vf_vf_advsimd_sleef(vsub_vf_vf_vf_advsimd_sleef(x, s), y)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_advsimd_sleef dfsub_vf2_vf2_vf2_advsimd_sleef(vfloat2_advsimd_sleef x, vfloat2_advsimd_sleef y) { + + vfloat_advsimd_sleef s = vsub_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(x), vf2getx_vf_vf2_advsimd_sleef(y)); + vfloat_advsimd_sleef t = vsub_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(x), s); + t = vsub_vf_vf_vf_advsimd_sleef(t, vf2getx_vf_vf2_advsimd_sleef(y)); + t = vadd_vf_vf_vf_advsimd_sleef(t, vf2gety_vf_vf2_advsimd_sleef(x)); + return vf2setxy_vf2_vf_vf_advsimd_sleef(s, vsub_vf_vf_vf_advsimd_sleef(t, vf2gety_vf_vf2_advsimd_sleef(y))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_advsimd_sleef dfdiv_vf2_vf2_vf2_advsimd_sleef(vfloat2_advsimd_sleef n, vfloat2_advsimd_sleef d) { + vfloat_advsimd_sleef t = vrec_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(d)); + vfloat_advsimd_sleef s = vmul_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(n), t); + vfloat_advsimd_sleef u = vfmapn_vf_vf_vf_vf_advsimd_sleef(t, vf2getx_vf_vf2_advsimd_sleef(n), s); + vfloat_advsimd_sleef v = vfmanp_vf_vf_vf_vf_advsimd_sleef(vf2gety_vf_vf2_advsimd_sleef(d), t, vfmanp_vf_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(d), t, vcast_vf_f_advsimd_sleef(1))); + return vf2setxy_vf2_vf_vf_advsimd_sleef(s, vfma_vf_vf_vf_vf_advsimd_sleef(s, v, vfma_vf_vf_vf_vf_advsimd_sleef(vf2gety_vf_vf2_advsimd_sleef(n), t, u))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_advsimd_sleef dfmul_vf2_vf_vf_advsimd_sleef(vfloat_advsimd_sleef x, vfloat_advsimd_sleef y) { + vfloat_advsimd_sleef s = vmul_vf_vf_vf_advsimd_sleef(x, y); + return vf2setxy_vf2_vf_vf_advsimd_sleef(s, vfmapn_vf_vf_vf_vf_advsimd_sleef(x, y, s)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_advsimd_sleef dfsqu_vf2_vf2_advsimd_sleef(vfloat2_advsimd_sleef x) { + vfloat_advsimd_sleef s = vmul_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(x), vf2getx_vf_vf2_advsimd_sleef(x)); + return vf2setxy_vf2_vf_vf_advsimd_sleef(s, vfma_vf_vf_vf_vf_advsimd_sleef(vadd_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(x), vf2getx_vf_vf2_advsimd_sleef(x)), vf2gety_vf_vf2_advsimd_sleef(x), vfmapn_vf_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(x), vf2getx_vf_vf2_advsimd_sleef(x), s))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_advsimd_sleef dfsqu_vf_vf2_advsimd_sleef(vfloat2_advsimd_sleef x) { + return vfma_vf_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(x), vf2getx_vf_vf2_advsimd_sleef(x), vadd_vf_vf_vf_advsimd_sleef(vmul_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(x), vf2gety_vf_vf2_advsimd_sleef(x)), vmul_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(x), vf2gety_vf_vf2_advsimd_sleef(x)))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_advsimd_sleef dfmul_vf2_vf2_vf2_advsimd_sleef(vfloat2_advsimd_sleef x, vfloat2_advsimd_sleef y) { + vfloat_advsimd_sleef s = vmul_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(x), vf2getx_vf_vf2_advsimd_sleef(y)); + return vf2setxy_vf2_vf_vf_advsimd_sleef(s, vfma_vf_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(x), vf2gety_vf_vf2_advsimd_sleef(y), vfma_vf_vf_vf_vf_advsimd_sleef(vf2gety_vf_vf2_advsimd_sleef(x), vf2getx_vf_vf2_advsimd_sleef(y), vfmapn_vf_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(x), vf2getx_vf_vf2_advsimd_sleef(y), s)))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_advsimd_sleef dfmul_vf_vf2_vf2_advsimd_sleef(vfloat2_advsimd_sleef x, vfloat2_advsimd_sleef y) { + return vfma_vf_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(x), vf2getx_vf_vf2_advsimd_sleef(y), vfma_vf_vf_vf_vf_advsimd_sleef(vf2gety_vf_vf2_advsimd_sleef(x), vf2getx_vf_vf2_advsimd_sleef(y), vmul_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(x), vf2gety_vf_vf2_advsimd_sleef(y)))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_advsimd_sleef dfmul_vf2_vf2_vf_advsimd_sleef(vfloat2_advsimd_sleef x, vfloat_advsimd_sleef y) { + vfloat_advsimd_sleef s = vmul_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(x), y); + return vf2setxy_vf2_vf_vf_advsimd_sleef(s, vfma_vf_vf_vf_vf_advsimd_sleef(vf2gety_vf_vf2_advsimd_sleef(x), y, vfmapn_vf_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(x), y, s))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_advsimd_sleef dfrec_vf2_vf_advsimd_sleef(vfloat_advsimd_sleef d) { + vfloat_advsimd_sleef s = vrec_vf_vf_advsimd_sleef(d); + return vf2setxy_vf2_vf_vf_advsimd_sleef(s, vmul_vf_vf_vf_advsimd_sleef(s, vfmanp_vf_vf_vf_vf_advsimd_sleef(d, s, vcast_vf_f_advsimd_sleef(1)))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_advsimd_sleef dfrec_vf2_vf2_advsimd_sleef(vfloat2_advsimd_sleef d) { + vfloat_advsimd_sleef s = vrec_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(d)); + return vf2setxy_vf2_vf_vf_advsimd_sleef(s, vmul_vf_vf_vf_advsimd_sleef(s, vfmanp_vf_vf_vf_vf_advsimd_sleef(vf2gety_vf_vf2_advsimd_sleef(d), s, vfmanp_vf_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(d), s, vcast_vf_f_advsimd_sleef(1))))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_advsimd_sleef dfsqrt_vf2_vf2_advsimd_sleef(vfloat2_advsimd_sleef d) { + + vfloat_advsimd_sleef t = vsqrt_vf_vf_advsimd_sleef(vadd_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(d), vf2gety_vf_vf2_advsimd_sleef(d))); + return dfscale_vf2_vf2_vf_advsimd_sleef(dfmul_vf2_vf2_vf2_advsimd_sleef(dfadd2_vf2_vf2_vf2_advsimd_sleef(d, dfmul_vf2_vf_vf_advsimd_sleef(t, t)), dfrec_vf2_vf_advsimd_sleef(t)), vcast_vf_f_advsimd_sleef(0.5)); + +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_advsimd_sleef dfsqrt_vf2_vf_advsimd_sleef(vfloat_advsimd_sleef d) { + vfloat_advsimd_sleef t = vsqrt_vf_vf_advsimd_sleef(d); + return dfscale_vf2_vf2_vf_advsimd_sleef(dfmul_vf2_vf2_vf2_advsimd_sleef(dfadd2_vf2_vf_vf2_advsimd_sleef(d, dfmul_vf2_vf_vf_advsimd_sleef(t, t)), dfrec_vf2_vf_advsimd_sleef(t)), vcast_vf_f_advsimd_sleef(0.5f)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vopmask_advsimd_sleef visnegzero_vo_vf_advsimd_sleef(vfloat_advsimd_sleef d) { + return veq_vo_vi2_vi2_advsimd_sleef(vreinterpret_vi2_vf_advsimd_sleef(d), vreinterpret_vi2_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(-0.0))); +} + +static SLEEF_ALWAYS_INLINE vopmask_advsimd_sleef vnot_vo32_vo32_advsimd_sleef(vopmask_advsimd_sleef x) { + return vxor_vo_vo_vo_advsimd_sleef(x, veq_vo_vi2_vi2_advsimd_sleef(vcast_vi2_i_advsimd_sleef(0), vcast_vi2_i_advsimd_sleef(0))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vmask_advsimd_sleef vsignbit_vm_vf_advsimd_sleef(vfloat_advsimd_sleef f) { + return vand_vm_vm_vm_advsimd_sleef(vreinterpret_vm_vf_advsimd_sleef(f), vreinterpret_vm_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(-0.0f))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_advsimd_sleef vmulsign_vf_vf_vf_advsimd_sleef(vfloat_advsimd_sleef x, vfloat_advsimd_sleef y) { + return vreinterpret_vf_vm_advsimd_sleef(vxor_vm_vm_vm_advsimd_sleef(vreinterpret_vm_vf_advsimd_sleef(x), vsignbit_vm_vf_advsimd_sleef(y))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_advsimd_sleef vcopysign_vf_vf_vf_advsimd_sleef(vfloat_advsimd_sleef x, vfloat_advsimd_sleef y) { + return vreinterpret_vf_vm_advsimd_sleef(vxor_vm_vm_vm_advsimd_sleef(vandnot_vm_vm_vm_advsimd_sleef(vreinterpret_vm_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(-0.0f)), vreinterpret_vm_vf_advsimd_sleef(x)), + vand_vm_vm_vm_advsimd_sleef (vreinterpret_vm_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(-0.0f)), vreinterpret_vm_vf_advsimd_sleef(y)))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_advsimd_sleef vsign_vf_vf_advsimd_sleef(vfloat_advsimd_sleef f) { + return vreinterpret_vf_vm_advsimd_sleef(vor_vm_vm_vm_advsimd_sleef(vreinterpret_vm_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(1.0f)), vand_vm_vm_vm_advsimd_sleef(vreinterpret_vm_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(-0.0f)), vreinterpret_vm_vf_advsimd_sleef(f)))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vopmask_advsimd_sleef vsignbit_vo_vf_advsimd_sleef(vfloat_advsimd_sleef d) { + return veq_vo_vi2_vi2_advsimd_sleef(vand_vi2_vi2_vi2_advsimd_sleef(vreinterpret_vi2_vf_advsimd_sleef(d), vcast_vi2_i_advsimd_sleef(0x80000000)), vcast_vi2_i_advsimd_sleef(0x80000000)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vint2_advsimd_sleef vsel_vi2_vf_vf_vi2_vi2_advsimd_sleef(vfloat_advsimd_sleef f0, vfloat_advsimd_sleef f1, vint2_advsimd_sleef x, vint2_advsimd_sleef y) { + return vsel_vi2_vo_vi2_vi2_advsimd_sleef(vlt_vo_vf_vf_advsimd_sleef(f0, f1), x, y); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vint2_advsimd_sleef vsel_vi2_vf_vi2_advsimd_sleef(vfloat_advsimd_sleef d, vint2_advsimd_sleef x) { + return vand_vi2_vo_vi2_advsimd_sleef(vsignbit_vo_vf_advsimd_sleef(d), x); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vopmask_advsimd_sleef visint_vo_vf_advsimd_sleef(vfloat_advsimd_sleef y) { return veq_vo_vf_vf_advsimd_sleef(vtruncate_vf_vf_advsimd_sleef(y), y); } + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vopmask_advsimd_sleef visnumber_vo_vf_advsimd_sleef(vfloat_advsimd_sleef x) { return vnot_vo32_vo32_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(visinf_vo_vf_advsimd_sleef(x), visnan_vo_vf_advsimd_sleef(x))); } + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vint2_advsimd_sleef vilogbk_vi2_vf_advsimd_sleef(vfloat_advsimd_sleef d) { + vopmask_advsimd_sleef o = vlt_vo_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(5.421010862427522E-20f)); + d = vsel_vf_vo_vf_vf_advsimd_sleef(o, vmul_vf_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(1.8446744073709552E19f), d), d); + vint2_advsimd_sleef q = vand_vi2_vi2_vi2_advsimd_sleef(vreinterpretq_s32_u32(vshrq_n_u32(vreinterpretq_u32_s32(vreinterpret_vi2_vf_advsimd_sleef(d)), 23)), vcast_vi2_i_advsimd_sleef(0xff)); + q = vsub_vi2_vi2_vi2_advsimd_sleef(q, vsel_vi2_vo_vi2_vi2_advsimd_sleef(o, vcast_vi2_i_advsimd_sleef(64 + 0x7f), vcast_vi2_i_advsimd_sleef(0x7f))); + return q; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vint2_advsimd_sleef vilogb2k_vi2_vf_advsimd_sleef(vfloat_advsimd_sleef d) { + vint2_advsimd_sleef q = vreinterpret_vi2_vf_advsimd_sleef(d); + q = vreinterpretq_s32_u32(vshrq_n_u32(vreinterpretq_u32_s32(q), 23)); + q = vand_vi2_vi2_vi2_advsimd_sleef(q, vcast_vi2_i_advsimd_sleef(0xff)); + q = vsub_vi2_vi2_vi2_advsimd_sleef(q, vcast_vi2_i_advsimd_sleef(0x7f)); + return q; +} + +SLEEF_INLINE SLEEF_CONST vint2_advsimd_sleef Sleef_ilogbf4_advsimd(vfloat_advsimd_sleef d) { + vint2_advsimd_sleef e = vilogbk_vi2_vf_advsimd_sleef(vabs_vf_vf_advsimd_sleef(d)); + e = vsel_vi2_vo_vi2_vi2_advsimd_sleef(veq_vo_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(0.0f)), vcast_vi2_i_advsimd_sleef(SLEEF_FP_ILOGB0), e); + e = vsel_vi2_vo_vi2_vi2_advsimd_sleef(visnan_vo_vf_advsimd_sleef(d), vcast_vi2_i_advsimd_sleef(SLEEF_FP_ILOGBNAN), e); + e = vsel_vi2_vo_vi2_vi2_advsimd_sleef(visinf_vo_vf_advsimd_sleef(d), vcast_vi2_i_advsimd_sleef(2147483647), e); + return e; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_advsimd_sleef vpow2i_vf_vi2_advsimd_sleef(vint2_advsimd_sleef q) { + return vreinterpret_vf_vi2_advsimd_sleef(vshlq_n_s32(vadd_vi2_vi2_vi2_advsimd_sleef(q, vcast_vi2_i_advsimd_sleef(0x7f)), 23)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_advsimd_sleef vldexp_vf_vf_vi2_advsimd_sleef(vfloat_advsimd_sleef x, vint2_advsimd_sleef q) { + vfloat_advsimd_sleef u; + vint2_advsimd_sleef m = vshrq_n_s32(q, 31); + m = vshlq_n_s32(vsub_vi2_vi2_vi2_advsimd_sleef(vshrq_n_s32(vadd_vi2_vi2_vi2_advsimd_sleef(m, q), 6), m), 4); + q = vsub_vi2_vi2_vi2_advsimd_sleef(q, vshlq_n_s32(m, 2)); + m = vadd_vi2_vi2_vi2_advsimd_sleef(m, vcast_vi2_i_advsimd_sleef(0x7f)); + m = vand_vi2_vi2_vi2_advsimd_sleef(vgt_vi2_vi2_vi2_advsimd_sleef(m, vcast_vi2_i_advsimd_sleef(0)), m); + vint2_advsimd_sleef n = vgt_vi2_vi2_vi2_advsimd_sleef(m, vcast_vi2_i_advsimd_sleef(0xff)); + m = vor_vi2_vi2_vi2_advsimd_sleef(vandnot_vi2_vi2_vi2_advsimd_sleef(n, m), vand_vi2_vi2_vi2_advsimd_sleef(n, vcast_vi2_i_advsimd_sleef(0xff))); + u = vreinterpret_vf_vi2_advsimd_sleef(vshlq_n_s32(m, 23)); + x = vmul_vf_vf_vf_advsimd_sleef(vmul_vf_vf_vf_advsimd_sleef(vmul_vf_vf_vf_advsimd_sleef(vmul_vf_vf_vf_advsimd_sleef(x, u), u), u), u); + u = vreinterpret_vf_vi2_advsimd_sleef(vshlq_n_s32(vadd_vi2_vi2_vi2_advsimd_sleef(q, vcast_vi2_i_advsimd_sleef(0x7f)), 23)); + return vmul_vf_vf_vf_advsimd_sleef(x, u); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_advsimd_sleef vldexp2_vf_vf_vi2_advsimd_sleef(vfloat_advsimd_sleef d, vint2_advsimd_sleef e) { + return vmul_vf_vf_vf_advsimd_sleef(vmul_vf_vf_vf_advsimd_sleef(d, vpow2i_vf_vi2_advsimd_sleef(vshrq_n_s32(e, 1))), vpow2i_vf_vi2_advsimd_sleef(vsub_vi2_vi2_vi2_advsimd_sleef(e, vshrq_n_s32(e, 1)))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_advsimd_sleef vldexp3_vf_vf_vi2_advsimd_sleef(vfloat_advsimd_sleef d, vint2_advsimd_sleef q) { + return vreinterpret_vf_vi2_advsimd_sleef(vadd_vi2_vi2_vi2_advsimd_sleef(vreinterpret_vi2_vf_advsimd_sleef(d), vshlq_n_s32(q, 23))); +} + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_ldexpf4_advsimd(vfloat_advsimd_sleef x, vint2_advsimd_sleef q) { return vldexp_vf_vf_vi2_advsimd_sleef(x, q); } + +typedef struct { + vfloat_advsimd_sleef d; + vint2_advsimd_sleef i; +} fi_t_advsimd_sleef; + +static vfloat_advsimd_sleef figetd_vf_di_advsimd_sleef(fi_t_advsimd_sleef d) { return d.d; } +static vint2_advsimd_sleef figeti_vi2_di_advsimd_sleef(fi_t_advsimd_sleef d) { return d.i; } +static fi_t_advsimd_sleef fisetdi_fi_vf_vi2_advsimd_sleef(vfloat_advsimd_sleef d, vint2_advsimd_sleef i) { + fi_t_advsimd_sleef r = { d, i }; + return r; +} + +typedef struct { + vfloat2_advsimd_sleef df_advsimd_sleef; + vint2_advsimd_sleef i; +} dfi_t_advsimd_sleef; + +static vfloat2_advsimd_sleef dfigetdf_vf2_dfi_advsimd_sleef(dfi_t_advsimd_sleef d) { return d.df_advsimd_sleef; } +static vint2_advsimd_sleef dfigeti_vi2_dfi_advsimd_sleef(dfi_t_advsimd_sleef d) { return d.i; } +static dfi_t_advsimd_sleef dfisetdfi_dfi_vf2_vi2_advsimd_sleef(vfloat2_advsimd_sleef v, vint2_advsimd_sleef i) { + dfi_t_advsimd_sleef r = { v, i }; + return r; +} +static dfi_t_advsimd_sleef dfisetdf_dfi_dfi_vf2_advsimd_sleef(dfi_t_advsimd_sleef dfi_advsimd_sleef, vfloat2_advsimd_sleef v) { + dfi_advsimd_sleef.df_advsimd_sleef = v; + return dfi_advsimd_sleef; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_advsimd_sleef vorsign_vf_vf_vf_advsimd_sleef(vfloat_advsimd_sleef x, vfloat_advsimd_sleef y) { + return vreinterpret_vf_vm_advsimd_sleef(vor_vm_vm_vm_advsimd_sleef(vreinterpret_vm_vf_advsimd_sleef(x), vsignbit_vm_vf_advsimd_sleef(y))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST fi_t_advsimd_sleef rempisubf_advsimd_sleef(vfloat_advsimd_sleef x) { + + vfloat_advsimd_sleef y = vrint_vf_vf_advsimd_sleef(vmul_vf_vf_vf_advsimd_sleef(x, vcast_vf_f_advsimd_sleef(4))); + vint2_advsimd_sleef vi = vtruncate_vi2_vf_advsimd_sleef(vsub_vf_vf_vf_advsimd_sleef(y, vmul_vf_vf_vf_advsimd_sleef(vrint_vf_vf_advsimd_sleef(x), vcast_vf_f_advsimd_sleef(4)))); + return fisetdi_fi_vf_vi2_advsimd_sleef(vsub_vf_vf_vf_advsimd_sleef(x, vmul_vf_vf_vf_advsimd_sleef(y, vcast_vf_f_advsimd_sleef(0.25))), vi); + +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST dfi_t_advsimd_sleef rempif_advsimd_sleef(vfloat_advsimd_sleef a) { + vfloat2_advsimd_sleef x, y; + vint2_advsimd_sleef ex = vilogb2k_vi2_vf_advsimd_sleef(a); + + ex = vsub_vi2_vi2_vi2_advsimd_sleef(ex, vcast_vi2_i_advsimd_sleef(25)); + vint2_advsimd_sleef q = vand_vi2_vo_vi2_advsimd_sleef(vgt_vo_vi2_vi2_advsimd_sleef(ex, vcast_vi2_i_advsimd_sleef(90-25)), vcast_vi2_i_advsimd_sleef(-64)); + a = vldexp3_vf_vf_vi2_advsimd_sleef(a, q); + ex = vandnot_vi2_vi2_vi2_advsimd_sleef(vshrq_n_s32(ex, 31), ex); + ex = vshlq_n_s32(ex, 2); + x = dfmul_vf2_vf_vf_advsimd_sleef(a, vgather_vf_p_vi2_advsimd_sleef(Sleef_rempitabsp, ex)); + fi_t_advsimd_sleef di = rempisubf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(x)); + q = figeti_vi2_di_advsimd_sleef(di); + x = vf2setx_vf2_vf2_vf_advsimd_sleef(x, figetd_vf_di_advsimd_sleef(di)); + x = dfnormalize_vf2_vf2_advsimd_sleef(x); + y = dfmul_vf2_vf_vf_advsimd_sleef(a, vgather_vf_p_vi2_advsimd_sleef(Sleef_rempitabsp+1, ex)); + x = dfadd2_vf2_vf2_vf2_advsimd_sleef(x, y); + di = rempisubf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(x)); + q = vadd_vi2_vi2_vi2_advsimd_sleef(q, figeti_vi2_di_advsimd_sleef(di)); + x = vf2setx_vf2_vf2_vf_advsimd_sleef(x, figetd_vf_di_advsimd_sleef(di)); + x = dfnormalize_vf2_vf2_advsimd_sleef(x); + y = vcast_vf2_vf_vf_advsimd_sleef(vgather_vf_p_vi2_advsimd_sleef(Sleef_rempitabsp+2, ex), vgather_vf_p_vi2_advsimd_sleef(Sleef_rempitabsp+3, ex)); + y = dfmul_vf2_vf2_vf_advsimd_sleef(y, a); + x = dfadd2_vf2_vf2_vf2_advsimd_sleef(x, y); + x = dfnormalize_vf2_vf2_advsimd_sleef(x); + x = dfmul_vf2_vf2_vf2_advsimd_sleef(x, vcast_vf2_f_f_advsimd_sleef(3.1415927410125732422f*2, -8.7422776573475857731e-08f*2)); + x = vsel_vf2_vo_vf2_vf2_advsimd_sleef(vlt_vo_vf_vf_advsimd_sleef(vabs_vf_vf_advsimd_sleef(a), vcast_vf_f_advsimd_sleef(0.7f)), vcast_vf2_vf_vf_advsimd_sleef(a, vcast_vf_f_advsimd_sleef(0)), x); + return dfisetdfi_dfi_vf2_vi2_advsimd_sleef(x, q); +} + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_sinf4_u35advsimd(vfloat_advsimd_sleef d) { + + vint2_advsimd_sleef q; + vfloat_advsimd_sleef u, s, r = d; + + if (__builtin_expect(!!(vtestallones_i_vo32_advsimd_sleef(vlt_vo_vf_vf_advsimd_sleef(vabs_vf_vf_advsimd_sleef(d), vcast_vf_f_advsimd_sleef(125.0f)))), 1)) { + q = vrint_vi2_vf_advsimd_sleef(vmul_vf_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef((float)0.318309886183790671537767526745028724))); + u = vcast_vf_vi2_advsimd_sleef(q); + d = vmla_vf_vf_vf_vf_advsimd_sleef(u, vcast_vf_f_advsimd_sleef(-3.1414794921875f), d); + d = vmla_vf_vf_vf_vf_advsimd_sleef(u, vcast_vf_f_advsimd_sleef(-0.00011315941810607910156f), d); + d = vmla_vf_vf_vf_vf_advsimd_sleef(u, vcast_vf_f_advsimd_sleef(-1.9841872589410058936e-09f), d); + } else if (__builtin_expect(!!(vtestallones_i_vo32_advsimd_sleef(vlt_vo_vf_vf_advsimd_sleef(vabs_vf_vf_advsimd_sleef(d), vcast_vf_f_advsimd_sleef(39000)))), 1)) { + q = vrint_vi2_vf_advsimd_sleef(vmul_vf_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef((float)0.318309886183790671537767526745028724))); + u = vcast_vf_vi2_advsimd_sleef(q); + d = vmla_vf_vf_vf_vf_advsimd_sleef(u, vcast_vf_f_advsimd_sleef(-3.140625f), d); + d = vmla_vf_vf_vf_vf_advsimd_sleef(u, vcast_vf_f_advsimd_sleef(-0.0009670257568359375f), d); + d = vmla_vf_vf_vf_vf_advsimd_sleef(u, vcast_vf_f_advsimd_sleef(-6.2771141529083251953e-07f), d); + d = vmla_vf_vf_vf_vf_advsimd_sleef(u, vcast_vf_f_advsimd_sleef(-1.2154201256553420762e-10f), d); + } else { + dfi_t_advsimd_sleef dfi_advsimd_sleef = rempif_advsimd_sleef(d); + q = vand_vi2_vi2_vi2_advsimd_sleef(dfigeti_vi2_dfi_advsimd_sleef(dfi_advsimd_sleef), vcast_vi2_i_advsimd_sleef(3)); + q = vadd_vi2_vi2_vi2_advsimd_sleef(vadd_vi2_vi2_vi2_advsimd_sleef(q, q), vsel_vi2_vo_vi2_vi2_advsimd_sleef(vgt_vo_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(dfigetdf_vf2_dfi_advsimd_sleef(dfi_advsimd_sleef)), vcast_vf_f_advsimd_sleef(0)), vcast_vi2_i_advsimd_sleef(2), vcast_vi2_i_advsimd_sleef(1))); + q = vshrq_n_s32(q, 2); + vopmask_advsimd_sleef o = veq_vo_vi2_vi2_advsimd_sleef(vand_vi2_vi2_vi2_advsimd_sleef(dfigeti_vi2_dfi_advsimd_sleef(dfi_advsimd_sleef), vcast_vi2_i_advsimd_sleef(1)), vcast_vi2_i_advsimd_sleef(1)); + vfloat2_advsimd_sleef x = vcast_vf2_vf_vf_advsimd_sleef(vmulsign_vf_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(3.1415927410125732422f*-0.5), vf2getx_vf_vf2_advsimd_sleef(dfigetdf_vf2_dfi_advsimd_sleef(dfi_advsimd_sleef))), + vmulsign_vf_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(-8.7422776573475857731e-08f*-0.5), vf2getx_vf_vf2_advsimd_sleef(dfigetdf_vf2_dfi_advsimd_sleef(dfi_advsimd_sleef)))); + x = dfadd2_vf2_vf2_vf2_advsimd_sleef(dfigetdf_vf2_dfi_advsimd_sleef(dfi_advsimd_sleef), x); + dfi_advsimd_sleef = dfisetdf_dfi_dfi_vf2_advsimd_sleef(dfi_advsimd_sleef, vsel_vf2_vo_vf2_vf2_advsimd_sleef(o, x, dfigetdf_vf2_dfi_advsimd_sleef(dfi_advsimd_sleef))); + d = vadd_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(dfigetdf_vf2_dfi_advsimd_sleef(dfi_advsimd_sleef)), vf2gety_vf_vf2_advsimd_sleef(dfigetdf_vf2_dfi_advsimd_sleef(dfi_advsimd_sleef))); + + d = vreinterpret_vf_vm_advsimd_sleef(vor_vm_vo32_vm_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(visinf_vo_vf_advsimd_sleef(r), visnan_vo_vf_advsimd_sleef(r)), vreinterpret_vm_vf_advsimd_sleef(d))); + } + + s = vmul_vf_vf_vf_advsimd_sleef(d, d); + + d = vreinterpret_vf_vm_advsimd_sleef(vxor_vm_vm_vm_advsimd_sleef(vand_vm_vo32_vm_advsimd_sleef(veq_vo_vi2_vi2_advsimd_sleef(vand_vi2_vi2_vi2_advsimd_sleef(q, vcast_vi2_i_advsimd_sleef(1)), vcast_vi2_i_advsimd_sleef(1)), vreinterpret_vm_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(-0.0f))), vreinterpret_vm_vf_advsimd_sleef(d))); + + u = vcast_vf_f_advsimd_sleef(2.6083159809786593541503e-06f); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, s, vcast_vf_f_advsimd_sleef(-0.0001981069071916863322258f)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, s, vcast_vf_f_advsimd_sleef(0.00833307858556509017944336f)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, s, vcast_vf_f_advsimd_sleef(-0.166666597127914428710938f)); + + u = vadd_vf_vf_vf_advsimd_sleef(vmul_vf_vf_vf_advsimd_sleef(s, vmul_vf_vf_vf_advsimd_sleef(u, d)), d); + + u = vsel_vf_vo_vf_vf_advsimd_sleef(visnegzero_vo_vf_advsimd_sleef(r), r, u); + + return u; + +} + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_cosf4_u35advsimd(vfloat_advsimd_sleef d) { + + vint2_advsimd_sleef q; + vfloat_advsimd_sleef u, s, r = d; + + if (__builtin_expect(!!(vtestallones_i_vo32_advsimd_sleef(vlt_vo_vf_vf_advsimd_sleef(vabs_vf_vf_advsimd_sleef(d), vcast_vf_f_advsimd_sleef(125.0f)))), 1)) { + q = vrint_vi2_vf_advsimd_sleef(vsub_vf_vf_vf_advsimd_sleef(vmul_vf_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef((float)0.318309886183790671537767526745028724)), vcast_vf_f_advsimd_sleef(0.5f))); + q = vadd_vi2_vi2_vi2_advsimd_sleef(vadd_vi2_vi2_vi2_advsimd_sleef(q, q), vcast_vi2_i_advsimd_sleef(1)); + + u = vcast_vf_vi2_advsimd_sleef(q); + d = vmla_vf_vf_vf_vf_advsimd_sleef(u, vcast_vf_f_advsimd_sleef(-3.1414794921875f*0.5f), d); + d = vmla_vf_vf_vf_vf_advsimd_sleef(u, vcast_vf_f_advsimd_sleef(-0.00011315941810607910156f*0.5f), d); + d = vmla_vf_vf_vf_vf_advsimd_sleef(u, vcast_vf_f_advsimd_sleef(-1.9841872589410058936e-09f*0.5f), d); + } else if (__builtin_expect(!!(vtestallones_i_vo32_advsimd_sleef(vlt_vo_vf_vf_advsimd_sleef(vabs_vf_vf_advsimd_sleef(d), vcast_vf_f_advsimd_sleef(39000)))), 1)) { + q = vrint_vi2_vf_advsimd_sleef(vsub_vf_vf_vf_advsimd_sleef(vmul_vf_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef((float)0.318309886183790671537767526745028724)), vcast_vf_f_advsimd_sleef(0.5f))); + q = vadd_vi2_vi2_vi2_advsimd_sleef(vadd_vi2_vi2_vi2_advsimd_sleef(q, q), vcast_vi2_i_advsimd_sleef(1)); + + u = vcast_vf_vi2_advsimd_sleef(q); + d = vmla_vf_vf_vf_vf_advsimd_sleef(u, vcast_vf_f_advsimd_sleef(-3.140625f*0.5f), d); + d = vmla_vf_vf_vf_vf_advsimd_sleef(u, vcast_vf_f_advsimd_sleef(-0.0009670257568359375f*0.5f), d); + d = vmla_vf_vf_vf_vf_advsimd_sleef(u, vcast_vf_f_advsimd_sleef(-6.2771141529083251953e-07f*0.5f), d); + d = vmla_vf_vf_vf_vf_advsimd_sleef(u, vcast_vf_f_advsimd_sleef(-1.2154201256553420762e-10f*0.5f), d); + } else { + dfi_t_advsimd_sleef dfi_advsimd_sleef = rempif_advsimd_sleef(d); + q = vand_vi2_vi2_vi2_advsimd_sleef(dfigeti_vi2_dfi_advsimd_sleef(dfi_advsimd_sleef), vcast_vi2_i_advsimd_sleef(3)); + q = vadd_vi2_vi2_vi2_advsimd_sleef(vadd_vi2_vi2_vi2_advsimd_sleef(q, q), vsel_vi2_vo_vi2_vi2_advsimd_sleef(vgt_vo_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(dfigetdf_vf2_dfi_advsimd_sleef(dfi_advsimd_sleef)), vcast_vf_f_advsimd_sleef(0)), vcast_vi2_i_advsimd_sleef(8), vcast_vi2_i_advsimd_sleef(7))); + q = vshrq_n_s32(q, 1); + vopmask_advsimd_sleef o = veq_vo_vi2_vi2_advsimd_sleef(vand_vi2_vi2_vi2_advsimd_sleef(dfigeti_vi2_dfi_advsimd_sleef(dfi_advsimd_sleef), vcast_vi2_i_advsimd_sleef(1)), vcast_vi2_i_advsimd_sleef(0)); + vfloat_advsimd_sleef y = vsel_vf_vo_vf_vf_advsimd_sleef(vgt_vo_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(dfigetdf_vf2_dfi_advsimd_sleef(dfi_advsimd_sleef)), vcast_vf_f_advsimd_sleef(0)), vcast_vf_f_advsimd_sleef(0), vcast_vf_f_advsimd_sleef(-1)); + vfloat2_advsimd_sleef x = vcast_vf2_vf_vf_advsimd_sleef(vmulsign_vf_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(3.1415927410125732422f*-0.5), y), + vmulsign_vf_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(-8.7422776573475857731e-08f*-0.5), y)); + x = dfadd2_vf2_vf2_vf2_advsimd_sleef(dfigetdf_vf2_dfi_advsimd_sleef(dfi_advsimd_sleef), x); + dfi_advsimd_sleef = dfisetdf_dfi_dfi_vf2_advsimd_sleef(dfi_advsimd_sleef, vsel_vf2_vo_vf2_vf2_advsimd_sleef(o, x, dfigetdf_vf2_dfi_advsimd_sleef(dfi_advsimd_sleef))); + d = vadd_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(dfigetdf_vf2_dfi_advsimd_sleef(dfi_advsimd_sleef)), vf2gety_vf_vf2_advsimd_sleef(dfigetdf_vf2_dfi_advsimd_sleef(dfi_advsimd_sleef))); + + d = vreinterpret_vf_vm_advsimd_sleef(vor_vm_vo32_vm_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(visinf_vo_vf_advsimd_sleef(r), visnan_vo_vf_advsimd_sleef(r)), vreinterpret_vm_vf_advsimd_sleef(d))); + } + + s = vmul_vf_vf_vf_advsimd_sleef(d, d); + + d = vreinterpret_vf_vm_advsimd_sleef(vxor_vm_vm_vm_advsimd_sleef(vand_vm_vo32_vm_advsimd_sleef(veq_vo_vi2_vi2_advsimd_sleef(vand_vi2_vi2_vi2_advsimd_sleef(q, vcast_vi2_i_advsimd_sleef(2)), vcast_vi2_i_advsimd_sleef(0)), vreinterpret_vm_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(-0.0f))), vreinterpret_vm_vf_advsimd_sleef(d))); + + u = vcast_vf_f_advsimd_sleef(2.6083159809786593541503e-06f); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, s, vcast_vf_f_advsimd_sleef(-0.0001981069071916863322258f)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, s, vcast_vf_f_advsimd_sleef(0.00833307858556509017944336f)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, s, vcast_vf_f_advsimd_sleef(-0.166666597127914428710938f)); + + u = vadd_vf_vf_vf_advsimd_sleef(vmul_vf_vf_vf_advsimd_sleef(s, vmul_vf_vf_vf_advsimd_sleef(u, d)), d); + + return u; + +} + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_tanf4_u35advsimd(vfloat_advsimd_sleef d) { + + vint2_advsimd_sleef q; + vopmask_advsimd_sleef o; + vfloat_advsimd_sleef u, s, x; + + x = d; + + if (__builtin_expect(!!(vtestallones_i_vo32_advsimd_sleef(vlt_vo_vf_vf_advsimd_sleef(vabs_vf_vf_advsimd_sleef(d), vcast_vf_f_advsimd_sleef(125.0f*0.5f)))), 1)) { + q = vrint_vi2_vf_advsimd_sleef(vmul_vf_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef((float)(2 * 0.318309886183790671537767526745028724)))); + u = vcast_vf_vi2_advsimd_sleef(q); + x = vmla_vf_vf_vf_vf_advsimd_sleef(u, vcast_vf_f_advsimd_sleef(-3.1414794921875f*0.5f), x); + x = vmla_vf_vf_vf_vf_advsimd_sleef(u, vcast_vf_f_advsimd_sleef(-0.00011315941810607910156f*0.5f), x); + x = vmla_vf_vf_vf_vf_advsimd_sleef(u, vcast_vf_f_advsimd_sleef(-1.9841872589410058936e-09f*0.5f), x); + } else if (__builtin_expect(!!(vtestallones_i_vo32_advsimd_sleef(vlt_vo_vf_vf_advsimd_sleef(vabs_vf_vf_advsimd_sleef(d), vcast_vf_f_advsimd_sleef(39000)))), 1)) { + q = vrint_vi2_vf_advsimd_sleef(vmul_vf_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef((float)(2 * 0.318309886183790671537767526745028724)))); + u = vcast_vf_vi2_advsimd_sleef(q); + x = vmla_vf_vf_vf_vf_advsimd_sleef(u, vcast_vf_f_advsimd_sleef(-3.140625f*0.5f), x); + x = vmla_vf_vf_vf_vf_advsimd_sleef(u, vcast_vf_f_advsimd_sleef(-0.0009670257568359375f*0.5f), x); + x = vmla_vf_vf_vf_vf_advsimd_sleef(u, vcast_vf_f_advsimd_sleef(-6.2771141529083251953e-07f*0.5f), x); + x = vmla_vf_vf_vf_vf_advsimd_sleef(u, vcast_vf_f_advsimd_sleef(-1.2154201256553420762e-10f*0.5f), x); + } else { + dfi_t_advsimd_sleef dfi_advsimd_sleef = rempif_advsimd_sleef(d); + q = dfigeti_vi2_dfi_advsimd_sleef(dfi_advsimd_sleef); + x = vadd_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(dfigetdf_vf2_dfi_advsimd_sleef(dfi_advsimd_sleef)), vf2gety_vf_vf2_advsimd_sleef(dfigetdf_vf2_dfi_advsimd_sleef(dfi_advsimd_sleef))); + x = vreinterpret_vf_vm_advsimd_sleef(vor_vm_vo32_vm_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(visinf_vo_vf_advsimd_sleef(d), visnan_vo_vf_advsimd_sleef(d)), vreinterpret_vm_vf_advsimd_sleef(x))); + x = vsel_vf_vo_vf_vf_advsimd_sleef(visnegzero_vo_vf_advsimd_sleef(d), d, x); + } + + s = vmul_vf_vf_vf_advsimd_sleef(x, x); + + o = veq_vo_vi2_vi2_advsimd_sleef(vand_vi2_vi2_vi2_advsimd_sleef(q, vcast_vi2_i_advsimd_sleef(1)), vcast_vi2_i_advsimd_sleef(1)); + x = vreinterpret_vf_vm_advsimd_sleef(vxor_vm_vm_vm_advsimd_sleef(vand_vm_vo32_vm_advsimd_sleef(o, vreinterpret_vm_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(-0.0f))), vreinterpret_vm_vf_advsimd_sleef(x))); + + vfloat_advsimd_sleef s2 = vmul_vf_vf_vf_advsimd_sleef(s, s), s4 = vmul_vf_vf_vf_advsimd_sleef(s2, s2); + u = vmla_vf_vf_vf_vf_advsimd_sleef((s4), (vmla_vf_vf_vf_vf_advsimd_sleef((s), (vcast_vf_f_advsimd_sleef(0.00927245803177356719970703f)), (vcast_vf_f_advsimd_sleef(0.00331984995864331722259521f)))), (vmla_vf_vf_vf_vf_advsimd_sleef((s2), (vmla_vf_vf_vf_vf_advsimd_sleef((s), (vcast_vf_f_advsimd_sleef(0.0242998078465461730957031f)), (vcast_vf_f_advsimd_sleef(0.0534495301544666290283203f)))), (vmla_vf_vf_vf_vf_advsimd_sleef((s), (vcast_vf_f_advsimd_sleef(0.133383005857467651367188f)), (vcast_vf_f_advsimd_sleef(0.333331853151321411132812f))))))) + + ; + + u = vmla_vf_vf_vf_vf_advsimd_sleef(s, vmul_vf_vf_vf_advsimd_sleef(u, x), x); + + u = vsel_vf_vo_vf_vf_advsimd_sleef(o, vrec_vf_vf_advsimd_sleef(u), u); + + return u; + +} + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_sinf4_u10advsimd(vfloat_advsimd_sleef d) { + + vint2_advsimd_sleef q; + vfloat_advsimd_sleef u, v; + vfloat2_advsimd_sleef s, t, x; + + if (__builtin_expect(!!(vtestallones_i_vo32_advsimd_sleef(vlt_vo_vf_vf_advsimd_sleef(vabs_vf_vf_advsimd_sleef(d), vcast_vf_f_advsimd_sleef(125.0f)))), 1)) { + u = vrint_vf_vf_advsimd_sleef(vmul_vf_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(0.318309886183790671537767526745028724))); + q = vrint_vi2_vf_advsimd_sleef(u); + v = vmla_vf_vf_vf_vf_advsimd_sleef(u, vcast_vf_f_advsimd_sleef(-3.1414794921875f), d); + s = dfadd2_vf2_vf_vf_advsimd_sleef(v, vmul_vf_vf_vf_advsimd_sleef(u, vcast_vf_f_advsimd_sleef(-0.00011315941810607910156f))); + s = dfadd_vf2_vf2_vf_advsimd_sleef(s, vmul_vf_vf_vf_advsimd_sleef(u, vcast_vf_f_advsimd_sleef(-1.9841872589410058936e-09f))); + } else { + dfi_t_advsimd_sleef dfi_advsimd_sleef = rempif_advsimd_sleef(d); + q = vand_vi2_vi2_vi2_advsimd_sleef(dfigeti_vi2_dfi_advsimd_sleef(dfi_advsimd_sleef), vcast_vi2_i_advsimd_sleef(3)); + q = vadd_vi2_vi2_vi2_advsimd_sleef(vadd_vi2_vi2_vi2_advsimd_sleef(q, q), vsel_vi2_vo_vi2_vi2_advsimd_sleef(vgt_vo_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(dfigetdf_vf2_dfi_advsimd_sleef(dfi_advsimd_sleef)), vcast_vf_f_advsimd_sleef(0)), vcast_vi2_i_advsimd_sleef(2), vcast_vi2_i_advsimd_sleef(1))); + q = vshrq_n_s32(q, 2); + vopmask_advsimd_sleef o = veq_vo_vi2_vi2_advsimd_sleef(vand_vi2_vi2_vi2_advsimd_sleef(dfigeti_vi2_dfi_advsimd_sleef(dfi_advsimd_sleef), vcast_vi2_i_advsimd_sleef(1)), vcast_vi2_i_advsimd_sleef(1)); + vfloat2_advsimd_sleef x = vcast_vf2_vf_vf_advsimd_sleef(vmulsign_vf_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(3.1415927410125732422f*-0.5), vf2getx_vf_vf2_advsimd_sleef(dfigetdf_vf2_dfi_advsimd_sleef(dfi_advsimd_sleef))), + vmulsign_vf_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(-8.7422776573475857731e-08f*-0.5), vf2getx_vf_vf2_advsimd_sleef(dfigetdf_vf2_dfi_advsimd_sleef(dfi_advsimd_sleef)))); + x = dfadd2_vf2_vf2_vf2_advsimd_sleef(dfigetdf_vf2_dfi_advsimd_sleef(dfi_advsimd_sleef), x); + dfi_advsimd_sleef = dfisetdf_dfi_dfi_vf2_advsimd_sleef(dfi_advsimd_sleef, vsel_vf2_vo_vf2_vf2_advsimd_sleef(o, x, dfigetdf_vf2_dfi_advsimd_sleef(dfi_advsimd_sleef))); + s = dfnormalize_vf2_vf2_advsimd_sleef(dfigetdf_vf2_dfi_advsimd_sleef(dfi_advsimd_sleef)); + + s = vf2setx_vf2_vf2_vf_advsimd_sleef(s, vreinterpret_vf_vm_advsimd_sleef(vor_vm_vo32_vm_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(visinf_vo_vf_advsimd_sleef(d), visnan_vo_vf_advsimd_sleef(d)), vreinterpret_vm_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(s))))); + + } + + t = s; + s = dfsqu_vf2_vf2_advsimd_sleef(s); + + u = vcast_vf_f_advsimd_sleef(2.6083159809786593541503e-06f); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, vf2getx_vf_vf2_advsimd_sleef(s), vcast_vf_f_advsimd_sleef(-0.0001981069071916863322258f)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, vf2getx_vf_vf2_advsimd_sleef(s), vcast_vf_f_advsimd_sleef(0.00833307858556509017944336f)); + + x = dfadd_vf2_vf_vf2_advsimd_sleef(vcast_vf_f_advsimd_sleef(1), dfmul_vf2_vf2_vf2_advsimd_sleef(dfadd_vf2_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(-0.166666597127914428710938f), vmul_vf_vf_vf_advsimd_sleef(u, vf2getx_vf_vf2_advsimd_sleef(s))), s)); + + u = dfmul_vf_vf2_vf2_advsimd_sleef(t, x); + + u = vreinterpret_vf_vm_advsimd_sleef(vxor_vm_vm_vm_advsimd_sleef(vand_vm_vo32_vm_advsimd_sleef(veq_vo_vi2_vi2_advsimd_sleef(vand_vi2_vi2_vi2_advsimd_sleef(q, vcast_vi2_i_advsimd_sleef(1)), vcast_vi2_i_advsimd_sleef(1)), vreinterpret_vm_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(-0.0))), vreinterpret_vm_vf_advsimd_sleef(u))); + + u = vsel_vf_vo_vf_vf_advsimd_sleef(visnegzero_vo_vf_advsimd_sleef(d), d, u); + + return u; + +} + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_cosf4_u10advsimd(vfloat_advsimd_sleef d) { + + vint2_advsimd_sleef q; + vfloat_advsimd_sleef u; + vfloat2_advsimd_sleef s, t, x; + + if (__builtin_expect(!!(vtestallones_i_vo32_advsimd_sleef(vlt_vo_vf_vf_advsimd_sleef(vabs_vf_vf_advsimd_sleef(d), vcast_vf_f_advsimd_sleef(125.0f)))), 1)) { + vfloat_advsimd_sleef dq = vmla_vf_vf_vf_vf_advsimd_sleef(vrint_vf_vf_advsimd_sleef(vmla_vf_vf_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(0.318309886183790671537767526745028724), vcast_vf_f_advsimd_sleef(-0.5f))), + vcast_vf_f_advsimd_sleef(2), vcast_vf_f_advsimd_sleef(1)); + q = vrint_vi2_vf_advsimd_sleef(dq); + s = dfadd2_vf2_vf_vf_advsimd_sleef (d, vmul_vf_vf_vf_advsimd_sleef(dq, vcast_vf_f_advsimd_sleef(-3.1414794921875f*0.5f))); + s = dfadd2_vf2_vf2_vf_advsimd_sleef(s, vmul_vf_vf_vf_advsimd_sleef(dq, vcast_vf_f_advsimd_sleef(-0.00011315941810607910156f*0.5f))); + s = dfadd2_vf2_vf2_vf_advsimd_sleef(s, vmul_vf_vf_vf_advsimd_sleef(dq, vcast_vf_f_advsimd_sleef(-1.9841872589410058936e-09f*0.5f))); + } else { + dfi_t_advsimd_sleef dfi_advsimd_sleef = rempif_advsimd_sleef(d); + q = vand_vi2_vi2_vi2_advsimd_sleef(dfigeti_vi2_dfi_advsimd_sleef(dfi_advsimd_sleef), vcast_vi2_i_advsimd_sleef(3)); + q = vadd_vi2_vi2_vi2_advsimd_sleef(vadd_vi2_vi2_vi2_advsimd_sleef(q, q), vsel_vi2_vo_vi2_vi2_advsimd_sleef(vgt_vo_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(dfigetdf_vf2_dfi_advsimd_sleef(dfi_advsimd_sleef)), vcast_vf_f_advsimd_sleef(0)), vcast_vi2_i_advsimd_sleef(8), vcast_vi2_i_advsimd_sleef(7))); + q = vshrq_n_s32(q, 1); + vopmask_advsimd_sleef o = veq_vo_vi2_vi2_advsimd_sleef(vand_vi2_vi2_vi2_advsimd_sleef(dfigeti_vi2_dfi_advsimd_sleef(dfi_advsimd_sleef), vcast_vi2_i_advsimd_sleef(1)), vcast_vi2_i_advsimd_sleef(0)); + vfloat_advsimd_sleef y = vsel_vf_vo_vf_vf_advsimd_sleef(vgt_vo_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(dfigetdf_vf2_dfi_advsimd_sleef(dfi_advsimd_sleef)), vcast_vf_f_advsimd_sleef(0)), vcast_vf_f_advsimd_sleef(0), vcast_vf_f_advsimd_sleef(-1)); + vfloat2_advsimd_sleef x = vcast_vf2_vf_vf_advsimd_sleef(vmulsign_vf_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(3.1415927410125732422f*-0.5), y), + vmulsign_vf_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(-8.7422776573475857731e-08f*-0.5), y)); + x = dfadd2_vf2_vf2_vf2_advsimd_sleef(dfigetdf_vf2_dfi_advsimd_sleef(dfi_advsimd_sleef), x); + dfi_advsimd_sleef = dfisetdf_dfi_dfi_vf2_advsimd_sleef(dfi_advsimd_sleef, vsel_vf2_vo_vf2_vf2_advsimd_sleef(o, x, dfigetdf_vf2_dfi_advsimd_sleef(dfi_advsimd_sleef))); + s = dfnormalize_vf2_vf2_advsimd_sleef(dfigetdf_vf2_dfi_advsimd_sleef(dfi_advsimd_sleef)); + + s = vf2setx_vf2_vf2_vf_advsimd_sleef(s, vreinterpret_vf_vm_advsimd_sleef(vor_vm_vo32_vm_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(visinf_vo_vf_advsimd_sleef(d), visnan_vo_vf_advsimd_sleef(d)), vreinterpret_vm_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(s))))); + + } + + t = s; + s = dfsqu_vf2_vf2_advsimd_sleef(s); + + u = vcast_vf_f_advsimd_sleef(2.6083159809786593541503e-06f); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, vf2getx_vf_vf2_advsimd_sleef(s), vcast_vf_f_advsimd_sleef(-0.0001981069071916863322258f)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, vf2getx_vf_vf2_advsimd_sleef(s), vcast_vf_f_advsimd_sleef(0.00833307858556509017944336f)); + + x = dfadd_vf2_vf_vf2_advsimd_sleef(vcast_vf_f_advsimd_sleef(1), dfmul_vf2_vf2_vf2_advsimd_sleef(dfadd_vf2_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(-0.166666597127914428710938f), vmul_vf_vf_vf_advsimd_sleef(u, vf2getx_vf_vf2_advsimd_sleef(s))), s)); + + u = dfmul_vf_vf2_vf2_advsimd_sleef(t, x); + + u = vreinterpret_vf_vm_advsimd_sleef(vxor_vm_vm_vm_advsimd_sleef(vand_vm_vo32_vm_advsimd_sleef(veq_vo_vi2_vi2_advsimd_sleef(vand_vi2_vi2_vi2_advsimd_sleef(q, vcast_vi2_i_advsimd_sleef(2)), vcast_vi2_i_advsimd_sleef(0)), vreinterpret_vm_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(-0.0))), vreinterpret_vm_vf_advsimd_sleef(u))); + + return u; + +} + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_fastsinf4_u3500advsimd(vfloat_advsimd_sleef d) { + vint2_advsimd_sleef q; + vfloat_advsimd_sleef u, s, t = d; + + s = vmul_vf_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef((float)0.318309886183790671537767526745028724)); + u = vrint_vf_vf_advsimd_sleef(s); + q = vrint_vi2_vf_advsimd_sleef(s); + d = vmla_vf_vf_vf_vf_advsimd_sleef(u, vcast_vf_f_advsimd_sleef(-(float)3.141592653589793238462643383279502884), d); + + s = vmul_vf_vf_vf_advsimd_sleef(d, d); + + u = vcast_vf_f_advsimd_sleef(-0.1881748176e-3); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, s, vcast_vf_f_advsimd_sleef(+0.8323502727e-2)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, s, vcast_vf_f_advsimd_sleef(-0.1666651368e+0)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(vmul_vf_vf_vf_advsimd_sleef(s, d), u, d); + + u = vreinterpret_vf_vm_advsimd_sleef(vxor_vm_vm_vm_advsimd_sleef(vand_vm_vo32_vm_advsimd_sleef(veq_vo_vi2_vi2_advsimd_sleef(vand_vi2_vi2_vi2_advsimd_sleef(q, vcast_vi2_i_advsimd_sleef(1)), vcast_vi2_i_advsimd_sleef(1)), vreinterpret_vm_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(-0.0f))), vreinterpret_vm_vf_advsimd_sleef(u))); + + vopmask_advsimd_sleef g = vlt_vo_vf_vf_advsimd_sleef(vabs_vf_vf_advsimd_sleef(t), vcast_vf_f_advsimd_sleef(30.0f)); + if (!__builtin_expect(!!(vtestallones_i_vo32_advsimd_sleef(g)), 1)) return vsel_vf_vo_vf_vf_advsimd_sleef(g, u, Sleef_sinf4_u35advsimd(t)); + + return u; +} + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_fastcosf4_u3500advsimd(vfloat_advsimd_sleef d) { + vint2_advsimd_sleef q; + vfloat_advsimd_sleef u, s, t = d; + + s = vmla_vf_vf_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef((float)0.318309886183790671537767526745028724), vcast_vf_f_advsimd_sleef(-0.5f)); + u = vrint_vf_vf_advsimd_sleef(s); + q = vrint_vi2_vf_advsimd_sleef(s); + d = vmla_vf_vf_vf_vf_advsimd_sleef(u, vcast_vf_f_advsimd_sleef(-(float)3.141592653589793238462643383279502884), vsub_vf_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef((float)3.141592653589793238462643383279502884 * 0.5f))); + + s = vmul_vf_vf_vf_advsimd_sleef(d, d); + + u = vcast_vf_f_advsimd_sleef(-0.1881748176e-3); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, s, vcast_vf_f_advsimd_sleef(+0.8323502727e-2)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, s, vcast_vf_f_advsimd_sleef(-0.1666651368e+0)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(vmul_vf_vf_vf_advsimd_sleef(s, d), u, d); + + u = vreinterpret_vf_vm_advsimd_sleef(vxor_vm_vm_vm_advsimd_sleef(vand_vm_vo32_vm_advsimd_sleef(veq_vo_vi2_vi2_advsimd_sleef(vand_vi2_vi2_vi2_advsimd_sleef(q, vcast_vi2_i_advsimd_sleef(1)), vcast_vi2_i_advsimd_sleef(0)), vreinterpret_vm_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(-0.0f))), vreinterpret_vm_vf_advsimd_sleef(u))); + + vopmask_advsimd_sleef g = vlt_vo_vf_vf_advsimd_sleef(vabs_vf_vf_advsimd_sleef(t), vcast_vf_f_advsimd_sleef(30.0f)); + if (!__builtin_expect(!!(vtestallones_i_vo32_advsimd_sleef(g)), 1)) return vsel_vf_vo_vf_vf_advsimd_sleef(g, u, Sleef_cosf4_u35advsimd(t)); + + return u; +} + +SLEEF_INLINE SLEEF_CONST vfloat2_advsimd_sleef Sleef_sincosf4_u35advsimd(vfloat_advsimd_sleef d) { + + vint2_advsimd_sleef q; + vopmask_advsimd_sleef o; + vfloat_advsimd_sleef u, s, t, rx, ry; + vfloat2_advsimd_sleef r; + + s = d; + + if (__builtin_expect(!!(vtestallones_i_vo32_advsimd_sleef(vlt_vo_vf_vf_advsimd_sleef(vabs_vf_vf_advsimd_sleef(d), vcast_vf_f_advsimd_sleef(125.0f)))), 1)) { + q = vrint_vi2_vf_advsimd_sleef(vmul_vf_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef((float)0.636619772367581343075535053490057448))); + u = vcast_vf_vi2_advsimd_sleef(q); + s = vmla_vf_vf_vf_vf_advsimd_sleef(u, vcast_vf_f_advsimd_sleef(-3.1414794921875f*0.5f), s); + s = vmla_vf_vf_vf_vf_advsimd_sleef(u, vcast_vf_f_advsimd_sleef(-0.00011315941810607910156f*0.5f), s); + s = vmla_vf_vf_vf_vf_advsimd_sleef(u, vcast_vf_f_advsimd_sleef(-1.9841872589410058936e-09f*0.5f), s); + } else if (__builtin_expect(!!(vtestallones_i_vo32_advsimd_sleef(vlt_vo_vf_vf_advsimd_sleef(vabs_vf_vf_advsimd_sleef(d), vcast_vf_f_advsimd_sleef(39000)))), 1)) { + q = vrint_vi2_vf_advsimd_sleef(vmul_vf_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef((float)0.636619772367581343075535053490057448))); + u = vcast_vf_vi2_advsimd_sleef(q); + s = vmla_vf_vf_vf_vf_advsimd_sleef(u, vcast_vf_f_advsimd_sleef(-3.140625f*0.5f), s); + s = vmla_vf_vf_vf_vf_advsimd_sleef(u, vcast_vf_f_advsimd_sleef(-0.0009670257568359375f*0.5f), s); + s = vmla_vf_vf_vf_vf_advsimd_sleef(u, vcast_vf_f_advsimd_sleef(-6.2771141529083251953e-07f*0.5f), s); + s = vmla_vf_vf_vf_vf_advsimd_sleef(u, vcast_vf_f_advsimd_sleef(-1.2154201256553420762e-10f*0.5f), s); + } else { + dfi_t_advsimd_sleef dfi_advsimd_sleef = rempif_advsimd_sleef(d); + q = dfigeti_vi2_dfi_advsimd_sleef(dfi_advsimd_sleef); + s = vadd_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(dfigetdf_vf2_dfi_advsimd_sleef(dfi_advsimd_sleef)), vf2gety_vf_vf2_advsimd_sleef(dfigetdf_vf2_dfi_advsimd_sleef(dfi_advsimd_sleef))); + s = vreinterpret_vf_vm_advsimd_sleef(vor_vm_vo32_vm_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(visinf_vo_vf_advsimd_sleef(d), visnan_vo_vf_advsimd_sleef(d)), vreinterpret_vm_vf_advsimd_sleef(s))); + } + + t = s; + + s = vmul_vf_vf_vf_advsimd_sleef(s, s); + + u = vcast_vf_f_advsimd_sleef(-0.000195169282960705459117889f); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, s, vcast_vf_f_advsimd_sleef(0.00833215750753879547119141f)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, s, vcast_vf_f_advsimd_sleef(-0.166666537523269653320312f)); + + rx = vmla_vf_vf_vf_vf_advsimd_sleef(vmul_vf_vf_vf_advsimd_sleef(u, s), t, t); + rx = vsel_vf_vo_vf_vf_advsimd_sleef(visnegzero_vo_vf_advsimd_sleef(d), vcast_vf_f_advsimd_sleef(-0.0f), rx); + + u = vcast_vf_f_advsimd_sleef(-2.71811842367242206819355e-07f); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, s, vcast_vf_f_advsimd_sleef(2.47990446951007470488548e-05f)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, s, vcast_vf_f_advsimd_sleef(-0.00138888787478208541870117f)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, s, vcast_vf_f_advsimd_sleef(0.0416666641831398010253906f)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, s, vcast_vf_f_advsimd_sleef(-0.5)); + + ry = vmla_vf_vf_vf_vf_advsimd_sleef(s, u, vcast_vf_f_advsimd_sleef(1)); + + o = veq_vo_vi2_vi2_advsimd_sleef(vand_vi2_vi2_vi2_advsimd_sleef(q, vcast_vi2_i_advsimd_sleef(1)), vcast_vi2_i_advsimd_sleef(0)); + r = vf2setxy_vf2_vf_vf_advsimd_sleef(vsel_vf_vo_vf_vf_advsimd_sleef(o, rx, ry), vsel_vf_vo_vf_vf_advsimd_sleef(o, ry, rx)); + + o = veq_vo_vi2_vi2_advsimd_sleef(vand_vi2_vi2_vi2_advsimd_sleef(q, vcast_vi2_i_advsimd_sleef(2)), vcast_vi2_i_advsimd_sleef(2)); + r = vf2setx_vf2_vf2_vf_advsimd_sleef(r, vreinterpret_vf_vm_advsimd_sleef(vxor_vm_vm_vm_advsimd_sleef(vand_vm_vo32_vm_advsimd_sleef(o, vreinterpret_vm_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(-0.0))), vreinterpret_vm_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(r))))); + + o = veq_vo_vi2_vi2_advsimd_sleef(vand_vi2_vi2_vi2_advsimd_sleef(vadd_vi2_vi2_vi2_advsimd_sleef(q, vcast_vi2_i_advsimd_sleef(1)), vcast_vi2_i_advsimd_sleef(2)), vcast_vi2_i_advsimd_sleef(2)); + r = vf2sety_vf2_vf2_vf_advsimd_sleef(r, vreinterpret_vf_vm_advsimd_sleef(vxor_vm_vm_vm_advsimd_sleef(vand_vm_vo32_vm_advsimd_sleef(o, vreinterpret_vm_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(-0.0))), vreinterpret_vm_vf_advsimd_sleef(vf2gety_vf_vf2_advsimd_sleef(r))))); + + return r; + +} + +SLEEF_INLINE SLEEF_CONST vfloat2_advsimd_sleef Sleef_sincosf4_u10advsimd(vfloat_advsimd_sleef d) { + + vint2_advsimd_sleef q; + vopmask_advsimd_sleef o; + vfloat_advsimd_sleef u, v, rx, ry; + vfloat2_advsimd_sleef r, s, t, x; + + if (__builtin_expect(!!(vtestallones_i_vo32_advsimd_sleef(vlt_vo_vf_vf_advsimd_sleef(vabs_vf_vf_advsimd_sleef(d), vcast_vf_f_advsimd_sleef(125.0f)))), 1)) { + u = vrint_vf_vf_advsimd_sleef(vmul_vf_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(2 * 0.318309886183790671537767526745028724))); + q = vrint_vi2_vf_advsimd_sleef(u); + v = vmla_vf_vf_vf_vf_advsimd_sleef(u, vcast_vf_f_advsimd_sleef(-3.1414794921875f*0.5f), d); + s = dfadd2_vf2_vf_vf_advsimd_sleef(v, vmul_vf_vf_vf_advsimd_sleef(u, vcast_vf_f_advsimd_sleef(-0.00011315941810607910156f*0.5f))); + s = dfadd_vf2_vf2_vf_advsimd_sleef(s, vmul_vf_vf_vf_advsimd_sleef(u, vcast_vf_f_advsimd_sleef(-1.9841872589410058936e-09f*0.5f))); + } else { + dfi_t_advsimd_sleef dfi_advsimd_sleef = rempif_advsimd_sleef(d); + q = dfigeti_vi2_dfi_advsimd_sleef(dfi_advsimd_sleef); + s = dfigetdf_vf2_dfi_advsimd_sleef(dfi_advsimd_sleef); + o = vor_vo_vo_vo_advsimd_sleef(visinf_vo_vf_advsimd_sleef(d), visnan_vo_vf_advsimd_sleef(d)); + s = vf2setx_vf2_vf2_vf_advsimd_sleef(s, vreinterpret_vf_vm_advsimd_sleef(vor_vm_vo32_vm_advsimd_sleef(o, vreinterpret_vm_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(s))))); + } + + t = s; + + s = vf2setx_vf2_vf2_vf_advsimd_sleef(s, dfsqu_vf_vf2_advsimd_sleef(s)); + + u = vcast_vf_f_advsimd_sleef(-0.000195169282960705459117889f); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, vf2getx_vf_vf2_advsimd_sleef(s), vcast_vf_f_advsimd_sleef(0.00833215750753879547119141f)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, vf2getx_vf_vf2_advsimd_sleef(s), vcast_vf_f_advsimd_sleef(-0.166666537523269653320312f)); + + u = vmul_vf_vf_vf_advsimd_sleef(u, vmul_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(s), vf2getx_vf_vf2_advsimd_sleef(t))); + + x = dfadd_vf2_vf2_vf_advsimd_sleef(t, u); + rx = vadd_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(x), vf2gety_vf_vf2_advsimd_sleef(x)); + + rx = vsel_vf_vo_vf_vf_advsimd_sleef(visnegzero_vo_vf_advsimd_sleef(d), vcast_vf_f_advsimd_sleef(-0.0f), rx); + + u = vcast_vf_f_advsimd_sleef(-2.71811842367242206819355e-07f); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, vf2getx_vf_vf2_advsimd_sleef(s), vcast_vf_f_advsimd_sleef(2.47990446951007470488548e-05f)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, vf2getx_vf_vf2_advsimd_sleef(s), vcast_vf_f_advsimd_sleef(-0.00138888787478208541870117f)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, vf2getx_vf_vf2_advsimd_sleef(s), vcast_vf_f_advsimd_sleef(0.0416666641831398010253906f)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, vf2getx_vf_vf2_advsimd_sleef(s), vcast_vf_f_advsimd_sleef(-0.5)); + + x = dfadd_vf2_vf_vf2_advsimd_sleef(vcast_vf_f_advsimd_sleef(1), dfmul_vf2_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(s), u)); + ry = vadd_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(x), vf2gety_vf_vf2_advsimd_sleef(x)); + + o = veq_vo_vi2_vi2_advsimd_sleef(vand_vi2_vi2_vi2_advsimd_sleef(q, vcast_vi2_i_advsimd_sleef(1)), vcast_vi2_i_advsimd_sleef(0)); + r = vf2setxy_vf2_vf_vf_advsimd_sleef(vsel_vf_vo_vf_vf_advsimd_sleef(o, rx, ry), vsel_vf_vo_vf_vf_advsimd_sleef(o, ry, rx)); + + o = veq_vo_vi2_vi2_advsimd_sleef(vand_vi2_vi2_vi2_advsimd_sleef(q, vcast_vi2_i_advsimd_sleef(2)), vcast_vi2_i_advsimd_sleef(2)); + r = vf2setx_vf2_vf2_vf_advsimd_sleef(r, vreinterpret_vf_vm_advsimd_sleef(vxor_vm_vm_vm_advsimd_sleef(vand_vm_vo32_vm_advsimd_sleef(o, vreinterpret_vm_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(-0.0))), vreinterpret_vm_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(r))))); + + o = veq_vo_vi2_vi2_advsimd_sleef(vand_vi2_vi2_vi2_advsimd_sleef(vadd_vi2_vi2_vi2_advsimd_sleef(q, vcast_vi2_i_advsimd_sleef(1)), vcast_vi2_i_advsimd_sleef(2)), vcast_vi2_i_advsimd_sleef(2)); + r = vf2sety_vf2_vf2_vf_advsimd_sleef(r, vreinterpret_vf_vm_advsimd_sleef(vxor_vm_vm_vm_advsimd_sleef(vand_vm_vo32_vm_advsimd_sleef(o, vreinterpret_vm_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(-0.0))), vreinterpret_vm_vf_advsimd_sleef(vf2gety_vf_vf2_advsimd_sleef(r))))); + + return r; + +} + +SLEEF_INLINE SLEEF_CONST vfloat2_advsimd_sleef Sleef_sincospif4_u05advsimd(vfloat_advsimd_sleef d) { + vopmask_advsimd_sleef o; + vfloat_advsimd_sleef u, s, t, rx, ry; + vfloat2_advsimd_sleef r, x, s2; + + u = vmul_vf_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(4)); + vint2_advsimd_sleef q = vtruncate_vi2_vf_advsimd_sleef(u); + q = vand_vi2_vi2_vi2_advsimd_sleef(vadd_vi2_vi2_vi2_advsimd_sleef(q, vxor_vi2_vi2_vi2_advsimd_sleef(vreinterpretq_s32_u32(vshrq_n_u32(vreinterpretq_u32_s32(q), 31)), vcast_vi2_i_advsimd_sleef(1))), vcast_vi2_i_advsimd_sleef(~1)); + s = vsub_vf_vf_vf_advsimd_sleef(u, vcast_vf_vi2_advsimd_sleef(q)); + + t = s; + s = vmul_vf_vf_vf_advsimd_sleef(s, s); + s2 = dfmul_vf2_vf_vf_advsimd_sleef(t, t); + + u = vcast_vf_f_advsimd_sleef(+0.3093842054e-6); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, s, vcast_vf_f_advsimd_sleef(-0.3657307388e-4)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, s, vcast_vf_f_advsimd_sleef(+0.2490393585e-2)); + x = dfadd2_vf2_vf_vf2_advsimd_sleef(vmul_vf_vf_vf_advsimd_sleef(u, s), vcast_vf2_f_f_advsimd_sleef(-0.080745510756969451904, -1.3373665339076936258e-09)); + x = dfadd2_vf2_vf2_vf2_advsimd_sleef(dfmul_vf2_vf2_vf2_advsimd_sleef(s2, x), vcast_vf2_f_f_advsimd_sleef(0.78539818525314331055, -2.1857338617566484855e-08)); + + x = dfmul_vf2_vf2_vf_advsimd_sleef(x, t); + rx = vadd_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(x), vf2gety_vf_vf2_advsimd_sleef(x)); + + rx = vsel_vf_vo_vf_vf_advsimd_sleef(visnegzero_vo_vf_advsimd_sleef(d), vcast_vf_f_advsimd_sleef(-0.0f), rx); + + u = vcast_vf_f_advsimd_sleef(-0.2430611801e-7); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, s, vcast_vf_f_advsimd_sleef(+0.3590577080e-5)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, s, vcast_vf_f_advsimd_sleef(-0.3259917721e-3)); + x = dfadd2_vf2_vf_vf2_advsimd_sleef(vmul_vf_vf_vf_advsimd_sleef(u, s), vcast_vf2_f_f_advsimd_sleef(0.015854343771934509277, 4.4940051354032242811e-10)); + x = dfadd2_vf2_vf2_vf2_advsimd_sleef(dfmul_vf2_vf2_vf2_advsimd_sleef(s2, x), vcast_vf2_f_f_advsimd_sleef(-0.30842512845993041992, -9.0728339030733922277e-09)); + + x = dfadd2_vf2_vf2_vf_advsimd_sleef(dfmul_vf2_vf2_vf2_advsimd_sleef(x, s2), vcast_vf_f_advsimd_sleef(1)); + ry = vadd_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(x), vf2gety_vf_vf2_advsimd_sleef(x)); + + o = veq_vo_vi2_vi2_advsimd_sleef(vand_vi2_vi2_vi2_advsimd_sleef(q, vcast_vi2_i_advsimd_sleef(2)), vcast_vi2_i_advsimd_sleef(0)); + r = vf2setxy_vf2_vf_vf_advsimd_sleef(vsel_vf_vo_vf_vf_advsimd_sleef(o, rx, ry), vsel_vf_vo_vf_vf_advsimd_sleef(o, ry, rx)); + + o = veq_vo_vi2_vi2_advsimd_sleef(vand_vi2_vi2_vi2_advsimd_sleef(q, vcast_vi2_i_advsimd_sleef(4)), vcast_vi2_i_advsimd_sleef(4)); + r = vf2setx_vf2_vf2_vf_advsimd_sleef(r, vreinterpret_vf_vm_advsimd_sleef(vxor_vm_vm_vm_advsimd_sleef(vand_vm_vo32_vm_advsimd_sleef(o, vreinterpret_vm_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(-0.0))), vreinterpret_vm_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(r))))); + + o = veq_vo_vi2_vi2_advsimd_sleef(vand_vi2_vi2_vi2_advsimd_sleef(vadd_vi2_vi2_vi2_advsimd_sleef(q, vcast_vi2_i_advsimd_sleef(2)), vcast_vi2_i_advsimd_sleef(4)), vcast_vi2_i_advsimd_sleef(4)); + r = vf2sety_vf2_vf2_vf_advsimd_sleef(r, vreinterpret_vf_vm_advsimd_sleef(vxor_vm_vm_vm_advsimd_sleef(vand_vm_vo32_vm_advsimd_sleef(o, vreinterpret_vm_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(-0.0))), vreinterpret_vm_vf_advsimd_sleef(vf2gety_vf_vf2_advsimd_sleef(r))))); + + o = vgt_vo_vf_vf_advsimd_sleef(vabs_vf_vf_advsimd_sleef(d), vcast_vf_f_advsimd_sleef(1e+7f)); + r = vf2setx_vf2_vf2_vf_advsimd_sleef(r, vreinterpret_vf_vm_advsimd_sleef(vandnot_vm_vo32_vm_advsimd_sleef(o, vreinterpret_vm_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(r))))); + r = vf2sety_vf2_vf2_vf_advsimd_sleef(r, vreinterpret_vf_vm_advsimd_sleef(vandnot_vm_vo32_vm_advsimd_sleef(o, vreinterpret_vm_vf_advsimd_sleef(vf2gety_vf_vf2_advsimd_sleef(r))))); + + o = visinf_vo_vf_advsimd_sleef(d); + r = vf2setx_vf2_vf2_vf_advsimd_sleef(r, vreinterpret_vf_vm_advsimd_sleef(vor_vm_vo32_vm_advsimd_sleef(o, vreinterpret_vm_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(r))))); + r = vf2sety_vf2_vf2_vf_advsimd_sleef(r, vreinterpret_vf_vm_advsimd_sleef(vor_vm_vo32_vm_advsimd_sleef(o, vreinterpret_vm_vf_advsimd_sleef(vf2gety_vf_vf2_advsimd_sleef(r))))); + + return r; +} + +SLEEF_INLINE SLEEF_CONST vfloat2_advsimd_sleef Sleef_sincospif4_u35advsimd(vfloat_advsimd_sleef d) { + vopmask_advsimd_sleef o; + vfloat_advsimd_sleef u, s, t, rx, ry; + vfloat2_advsimd_sleef r; + + u = vmul_vf_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(4)); + vint2_advsimd_sleef q = vtruncate_vi2_vf_advsimd_sleef(u); + q = vand_vi2_vi2_vi2_advsimd_sleef(vadd_vi2_vi2_vi2_advsimd_sleef(q, vxor_vi2_vi2_vi2_advsimd_sleef(vreinterpretq_s32_u32(vshrq_n_u32(vreinterpretq_u32_s32(q), 31)), vcast_vi2_i_advsimd_sleef(1))), vcast_vi2_i_advsimd_sleef(~1)); + s = vsub_vf_vf_vf_advsimd_sleef(u, vcast_vf_vi2_advsimd_sleef(q)); + + t = s; + s = vmul_vf_vf_vf_advsimd_sleef(s, s); + + u = vcast_vf_f_advsimd_sleef(-0.3600925265e-4); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, s, vcast_vf_f_advsimd_sleef(+0.2490088111e-2)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, s, vcast_vf_f_advsimd_sleef(-0.8074551076e-1)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, s, vcast_vf_f_advsimd_sleef(+0.7853981853e+0)); + + rx = vmul_vf_vf_vf_advsimd_sleef(u, t); + + u = vcast_vf_f_advsimd_sleef(+0.3539815225e-5); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, s, vcast_vf_f_advsimd_sleef(-0.3259574005e-3)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, s, vcast_vf_f_advsimd_sleef(+0.1585431583e-1)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, s, vcast_vf_f_advsimd_sleef(-0.3084251285e+0)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, s, vcast_vf_f_advsimd_sleef(1)); + + ry = u; + + o = veq_vo_vi2_vi2_advsimd_sleef(vand_vi2_vi2_vi2_advsimd_sleef(q, vcast_vi2_i_advsimd_sleef(2)), vcast_vi2_i_advsimd_sleef(0)); + r = vf2setxy_vf2_vf_vf_advsimd_sleef(vsel_vf_vo_vf_vf_advsimd_sleef(o, rx, ry), vsel_vf_vo_vf_vf_advsimd_sleef(o, ry, rx)); + + o = veq_vo_vi2_vi2_advsimd_sleef(vand_vi2_vi2_vi2_advsimd_sleef(q, vcast_vi2_i_advsimd_sleef(4)), vcast_vi2_i_advsimd_sleef(4)); + r = vf2setx_vf2_vf2_vf_advsimd_sleef(r, vreinterpret_vf_vm_advsimd_sleef(vxor_vm_vm_vm_advsimd_sleef(vand_vm_vo32_vm_advsimd_sleef(o, vreinterpret_vm_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(-0.0))), vreinterpret_vm_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(r))))); + + o = veq_vo_vi2_vi2_advsimd_sleef(vand_vi2_vi2_vi2_advsimd_sleef(vadd_vi2_vi2_vi2_advsimd_sleef(q, vcast_vi2_i_advsimd_sleef(2)), vcast_vi2_i_advsimd_sleef(4)), vcast_vi2_i_advsimd_sleef(4)); + r = vf2sety_vf2_vf2_vf_advsimd_sleef(r, vreinterpret_vf_vm_advsimd_sleef(vxor_vm_vm_vm_advsimd_sleef(vand_vm_vo32_vm_advsimd_sleef(o, vreinterpret_vm_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(-0.0))), vreinterpret_vm_vf_advsimd_sleef(vf2gety_vf_vf2_advsimd_sleef(r))))); + + o = vgt_vo_vf_vf_advsimd_sleef(vabs_vf_vf_advsimd_sleef(d), vcast_vf_f_advsimd_sleef(1e+7f)); + r = vf2setx_vf2_vf2_vf_advsimd_sleef(r, vreinterpret_vf_vm_advsimd_sleef(vandnot_vm_vo32_vm_advsimd_sleef(o, vreinterpret_vm_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(r))))); + r = vf2sety_vf2_vf2_vf_advsimd_sleef(r, vreinterpret_vf_vm_advsimd_sleef(vandnot_vm_vo32_vm_advsimd_sleef(o, vreinterpret_vm_vf_advsimd_sleef(vf2gety_vf_vf2_advsimd_sleef(r))))); + + o = visinf_vo_vf_advsimd_sleef(d); + r = vf2setx_vf2_vf2_vf_advsimd_sleef(r, vreinterpret_vf_vm_advsimd_sleef(vor_vm_vo32_vm_advsimd_sleef(o, vreinterpret_vm_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(r))))); + r = vf2sety_vf2_vf2_vf_advsimd_sleef(r, vreinterpret_vf_vm_advsimd_sleef(vor_vm_vo32_vm_advsimd_sleef(o, vreinterpret_vm_vf_advsimd_sleef(vf2gety_vf_vf2_advsimd_sleef(r))))); + + return r; +} + +SLEEF_INLINE vfloat2_advsimd_sleef Sleef_modff4_advsimd(vfloat_advsimd_sleef x) { + vfloat_advsimd_sleef fr = vsub_vf_vf_vf_advsimd_sleef(x, vcast_vf_vi2_advsimd_sleef(vtruncate_vi2_vf_advsimd_sleef(x))); + fr = vsel_vf_vo_vf_vf_advsimd_sleef(vgt_vo_vf_vf_advsimd_sleef(vabs_vf_vf_advsimd_sleef(x), vcast_vf_f_advsimd_sleef(INT64_C(1) << 23)), vcast_vf_f_advsimd_sleef(0), fr); + + vfloat2_advsimd_sleef ret; + + ret = vf2setxy_vf2_vf_vf_advsimd_sleef(vcopysign_vf_vf_vf_advsimd_sleef(fr, x), vcopysign_vf_vf_vf_advsimd_sleef(vsub_vf_vf_vf_advsimd_sleef(x, fr), x)); + + return ret; +} + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_tanf4_u10advsimd(vfloat_advsimd_sleef d) { + + vint2_advsimd_sleef q; + vfloat_advsimd_sleef u, v; + vfloat2_advsimd_sleef s, t, x; + vopmask_advsimd_sleef o; + + if (__builtin_expect(!!(vtestallones_i_vo32_advsimd_sleef(vlt_vo_vf_vf_advsimd_sleef(vabs_vf_vf_advsimd_sleef(d), vcast_vf_f_advsimd_sleef(125.0f)))), 1)) { + u = vrint_vf_vf_advsimd_sleef(vmul_vf_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(2 * 0.318309886183790671537767526745028724))); + q = vrint_vi2_vf_advsimd_sleef(u); + v = vmla_vf_vf_vf_vf_advsimd_sleef(u, vcast_vf_f_advsimd_sleef(-3.1414794921875f*0.5f), d); + s = dfadd2_vf2_vf_vf_advsimd_sleef(v, vmul_vf_vf_vf_advsimd_sleef(u, vcast_vf_f_advsimd_sleef(-0.00011315941810607910156f*0.5f))); + s = dfadd_vf2_vf2_vf_advsimd_sleef(s, vmul_vf_vf_vf_advsimd_sleef(u, vcast_vf_f_advsimd_sleef(-1.9841872589410058936e-09f*0.5f))); + } else { + dfi_t_advsimd_sleef dfi_advsimd_sleef = rempif_advsimd_sleef(d); + q = dfigeti_vi2_dfi_advsimd_sleef(dfi_advsimd_sleef); + s = dfigetdf_vf2_dfi_advsimd_sleef(dfi_advsimd_sleef); + o = vor_vo_vo_vo_advsimd_sleef(visinf_vo_vf_advsimd_sleef(d), visnan_vo_vf_advsimd_sleef(d)); + s = vf2setx_vf2_vf2_vf_advsimd_sleef(s, vreinterpret_vf_vm_advsimd_sleef(vor_vm_vo32_vm_advsimd_sleef(o, vreinterpret_vm_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(s))))); + s = vf2sety_vf2_vf2_vf_advsimd_sleef(s, vreinterpret_vf_vm_advsimd_sleef(vor_vm_vo32_vm_advsimd_sleef(o, vreinterpret_vm_vf_advsimd_sleef(vf2gety_vf_vf2_advsimd_sleef(s))))); + } + + o = veq_vo_vi2_vi2_advsimd_sleef(vand_vi2_vi2_vi2_advsimd_sleef(q, vcast_vi2_i_advsimd_sleef(1)), vcast_vi2_i_advsimd_sleef(1)); + vmask_advsimd_sleef n = vand_vm_vo32_vm_advsimd_sleef(o, vreinterpret_vm_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(-0.0))); + + s = vf2setx_vf2_vf2_vf_advsimd_sleef(s, vreinterpret_vf_vm_advsimd_sleef(vxor_vm_vm_vm_advsimd_sleef(vreinterpret_vm_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(s)), n))); + s = vf2sety_vf2_vf2_vf_advsimd_sleef(s, vreinterpret_vf_vm_advsimd_sleef(vxor_vm_vm_vm_advsimd_sleef(vreinterpret_vm_vf_advsimd_sleef(vf2gety_vf_vf2_advsimd_sleef(s)), n))); + + t = s; + s = dfsqu_vf2_vf2_advsimd_sleef(s); + s = dfnormalize_vf2_vf2_advsimd_sleef(s); + + u = vcast_vf_f_advsimd_sleef(0.00446636462584137916564941f); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, vf2getx_vf_vf2_advsimd_sleef(s), vcast_vf_f_advsimd_sleef(-8.3920182078145444393158e-05f)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, vf2getx_vf_vf2_advsimd_sleef(s), vcast_vf_f_advsimd_sleef(0.0109639242291450500488281f)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, vf2getx_vf_vf2_advsimd_sleef(s), vcast_vf_f_advsimd_sleef(0.0212360303848981857299805f)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, vf2getx_vf_vf2_advsimd_sleef(s), vcast_vf_f_advsimd_sleef(0.0540687143802642822265625f)); + + x = dfadd_vf2_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(0.133325666189193725585938f), vmul_vf_vf_vf_advsimd_sleef(u, vf2getx_vf_vf2_advsimd_sleef(s))); + x = dfadd_vf2_vf_vf2_advsimd_sleef(vcast_vf_f_advsimd_sleef(1), dfmul_vf2_vf2_vf2_advsimd_sleef(dfadd_vf2_vf_vf2_advsimd_sleef(vcast_vf_f_advsimd_sleef(0.33333361148834228515625f), dfmul_vf2_vf2_vf2_advsimd_sleef(s, x)), s)); + x = dfmul_vf2_vf2_vf2_advsimd_sleef(t, x); + + x = vsel_vf2_vo_vf2_vf2_advsimd_sleef(o, dfrec_vf2_vf2_advsimd_sleef(x), x); + + u = vadd_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(x), vf2gety_vf_vf2_advsimd_sleef(x)); + + u = vsel_vf_vo_vf_vf_advsimd_sleef(visnegzero_vo_vf_advsimd_sleef(d), d, u); + + return u; + +} + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_atanf4_u35advsimd(vfloat_advsimd_sleef d) { + vfloat_advsimd_sleef s, t, u; + vint2_advsimd_sleef q; + + q = vsel_vi2_vf_vi2_advsimd_sleef(d, vcast_vi2_i_advsimd_sleef(2)); + s = vabs_vf_vf_advsimd_sleef(d); + + q = vsel_vi2_vf_vf_vi2_vi2_advsimd_sleef(vcast_vf_f_advsimd_sleef(1.0f), s, vadd_vi2_vi2_vi2_advsimd_sleef(q, vcast_vi2_i_advsimd_sleef(1)), q); + s = vsel_vf_vo_vf_vf_advsimd_sleef(vlt_vo_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(1.0f), s), vrec_vf_vf_advsimd_sleef(s), s); + + t = vmul_vf_vf_vf_advsimd_sleef(s, s); + + vfloat_advsimd_sleef t2 = vmul_vf_vf_vf_advsimd_sleef(t, t), t4 = vmul_vf_vf_vf_advsimd_sleef(t2, t2); + u = vmla_vf_vf_vf_vf_advsimd_sleef((t4), (vmla_vf_vf_vf_vf_advsimd_sleef((t2), (vmla_vf_vf_vf_vf_advsimd_sleef((t), (vcast_vf_f_advsimd_sleef(0.00282363896258175373077393f)), (vcast_vf_f_advsimd_sleef(-0.0159569028764963150024414f)))), (vmla_vf_vf_vf_vf_advsimd_sleef((t), (vcast_vf_f_advsimd_sleef(0.0425049886107444763183594f)), (vcast_vf_f_advsimd_sleef(-0.0748900920152664184570312f)))))), (vmla_vf_vf_vf_vf_advsimd_sleef((t2), (vmla_vf_vf_vf_vf_advsimd_sleef((t), (vcast_vf_f_advsimd_sleef(0.106347933411598205566406f)), (vcast_vf_f_advsimd_sleef(-0.142027363181114196777344f)))), (vmla_vf_vf_vf_vf_advsimd_sleef((t), (vcast_vf_f_advsimd_sleef(0.199926957488059997558594f)), (vcast_vf_f_advsimd_sleef(-0.333331018686294555664062f))))))) + + ; + + t = vmla_vf_vf_vf_vf_advsimd_sleef(s, vmul_vf_vf_vf_advsimd_sleef(t, u), s); + + t = vsel_vf_vo_vf_vf_advsimd_sleef(veq_vo_vi2_vi2_advsimd_sleef(vand_vi2_vi2_vi2_advsimd_sleef(q, vcast_vi2_i_advsimd_sleef(1)), vcast_vi2_i_advsimd_sleef(1)), vsub_vf_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef((float)(3.141592653589793238462643383279502884/2)), t), t); + + t = vreinterpret_vf_vm_advsimd_sleef(vxor_vm_vm_vm_advsimd_sleef(vand_vm_vo32_vm_advsimd_sleef(veq_vo_vi2_vi2_advsimd_sleef(vand_vi2_vi2_vi2_advsimd_sleef(q, vcast_vi2_i_advsimd_sleef(2)), vcast_vi2_i_advsimd_sleef(2)), vreinterpret_vm_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(-0.0f))), vreinterpret_vm_vf_advsimd_sleef(t))); + + return t; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_advsimd_sleef atan2kf_advsimd_sleef(vfloat_advsimd_sleef y, vfloat_advsimd_sleef x) { + vfloat_advsimd_sleef s, t, u; + vint2_advsimd_sleef q; + vopmask_advsimd_sleef p; + + q = vsel_vi2_vf_vi2_advsimd_sleef(x, vcast_vi2_i_advsimd_sleef(-2)); + x = vabs_vf_vf_advsimd_sleef(x); + + q = vsel_vi2_vf_vf_vi2_vi2_advsimd_sleef(x, y, vadd_vi2_vi2_vi2_advsimd_sleef(q, vcast_vi2_i_advsimd_sleef(1)), q); + p = vlt_vo_vf_vf_advsimd_sleef(x, y); + s = vsel_vf_vo_vf_vf_advsimd_sleef(p, vneg_vf_vf_advsimd_sleef(x), y); + t = vmax_vf_vf_vf_advsimd_sleef(x, y); + + s = vdiv_vf_vf_vf_advsimd_sleef(s, t); + t = vmul_vf_vf_vf_advsimd_sleef(s, s); + + vfloat_advsimd_sleef t2 = vmul_vf_vf_vf_advsimd_sleef(t, t), t4 = vmul_vf_vf_vf_advsimd_sleef(t2, t2); + u = vmla_vf_vf_vf_vf_advsimd_sleef((t4), (vmla_vf_vf_vf_vf_advsimd_sleef((t2), (vmla_vf_vf_vf_vf_advsimd_sleef((t), (vcast_vf_f_advsimd_sleef(0.00282363896258175373077393f)), (vcast_vf_f_advsimd_sleef(-0.0159569028764963150024414f)))), (vmla_vf_vf_vf_vf_advsimd_sleef((t), (vcast_vf_f_advsimd_sleef(0.0425049886107444763183594f)), (vcast_vf_f_advsimd_sleef(-0.0748900920152664184570312f)))))), (vmla_vf_vf_vf_vf_advsimd_sleef((t2), (vmla_vf_vf_vf_vf_advsimd_sleef((t), (vcast_vf_f_advsimd_sleef(0.106347933411598205566406f)), (vcast_vf_f_advsimd_sleef(-0.142027363181114196777344f)))), (vmla_vf_vf_vf_vf_advsimd_sleef((t), (vcast_vf_f_advsimd_sleef(0.199926957488059997558594f)), (vcast_vf_f_advsimd_sleef(-0.333331018686294555664062f))))))) + + ; + + t = vmla_vf_vf_vf_vf_advsimd_sleef(s, vmul_vf_vf_vf_advsimd_sleef(t, u), s); + t = vmla_vf_vf_vf_vf_advsimd_sleef(vcast_vf_vi2_advsimd_sleef(q), vcast_vf_f_advsimd_sleef((float)(3.141592653589793238462643383279502884/2)), t); + + return t; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_advsimd_sleef visinf2_vf_vf_vf_advsimd_sleef(vfloat_advsimd_sleef d, vfloat_advsimd_sleef m) { + return vreinterpret_vf_vm_advsimd_sleef(vand_vm_vo32_vm_advsimd_sleef(visinf_vo_vf_advsimd_sleef(d), vor_vm_vm_vm_advsimd_sleef(vsignbit_vm_vf_advsimd_sleef(d), vreinterpret_vm_vf_advsimd_sleef(m)))); +} + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_atan2f4_u35advsimd(vfloat_advsimd_sleef y, vfloat_advsimd_sleef x) { + vfloat_advsimd_sleef r = atan2kf_advsimd_sleef(vabs_vf_vf_advsimd_sleef(y), x); + + r = vmulsign_vf_vf_vf_advsimd_sleef(r, x); + r = vsel_vf_vo_vf_vf_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(visinf_vo_vf_advsimd_sleef(x), veq_vo_vf_vf_advsimd_sleef(x, vcast_vf_f_advsimd_sleef(0.0f))), vsub_vf_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef((float)(3.141592653589793238462643383279502884/2)), visinf2_vf_vf_vf_advsimd_sleef(x, vmulsign_vf_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef((float)(3.141592653589793238462643383279502884/2)), x))), r); + r = vsel_vf_vo_vf_vf_advsimd_sleef(visinf_vo_vf_advsimd_sleef(y), vsub_vf_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef((float)(3.141592653589793238462643383279502884/2)), visinf2_vf_vf_vf_advsimd_sleef(x, vmulsign_vf_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef((float)(3.141592653589793238462643383279502884/4)), x))), r); + + r = vsel_vf_vo_vf_vf_advsimd_sleef(veq_vo_vf_vf_advsimd_sleef(y, vcast_vf_f_advsimd_sleef(0.0f)), vreinterpret_vf_vm_advsimd_sleef(vand_vm_vo32_vm_advsimd_sleef(vsignbit_vo_vf_advsimd_sleef(x), vreinterpret_vm_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef((float)3.141592653589793238462643383279502884)))), r); + + r = vreinterpret_vf_vm_advsimd_sleef(vor_vm_vo32_vm_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(visnan_vo_vf_advsimd_sleef(x), visnan_vo_vf_advsimd_sleef(y)), vreinterpret_vm_vf_advsimd_sleef(vmulsign_vf_vf_vf_advsimd_sleef(r, y)))); + return r; +} + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_asinf4_u35advsimd(vfloat_advsimd_sleef d) { + vopmask_advsimd_sleef o = vlt_vo_vf_vf_advsimd_sleef(vabs_vf_vf_advsimd_sleef(d), vcast_vf_f_advsimd_sleef(0.5f)); + vfloat_advsimd_sleef x2 = vsel_vf_vo_vf_vf_advsimd_sleef(o, vmul_vf_vf_vf_advsimd_sleef(d, d), vmul_vf_vf_vf_advsimd_sleef(vsub_vf_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(1), vabs_vf_vf_advsimd_sleef(d)), vcast_vf_f_advsimd_sleef(0.5f))); + vfloat_advsimd_sleef x = vsel_vf_vo_vf_vf_advsimd_sleef(o, vabs_vf_vf_advsimd_sleef(d), vsqrt_vf_vf_advsimd_sleef(x2)), u; + + u = vcast_vf_f_advsimd_sleef(+0.4197454825e-1); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, x2, vcast_vf_f_advsimd_sleef(+0.2424046025e-1)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, x2, vcast_vf_f_advsimd_sleef(+0.4547423869e-1)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, x2, vcast_vf_f_advsimd_sleef(+0.7495029271e-1)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, x2, vcast_vf_f_advsimd_sleef(+0.1666677296e+0)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, vmul_vf_vf_vf_advsimd_sleef(x, x2), x); + + vfloat_advsimd_sleef r = vsel_vf_vo_vf_vf_advsimd_sleef(o, u, vmla_vf_vf_vf_vf_advsimd_sleef(u, vcast_vf_f_advsimd_sleef(-2), vcast_vf_f_advsimd_sleef(((float)3.141592653589793238462643383279502884)/2))); + return vmulsign_vf_vf_vf_advsimd_sleef(r, d); +} + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_acosf4_u35advsimd(vfloat_advsimd_sleef d) { + vopmask_advsimd_sleef o = vlt_vo_vf_vf_advsimd_sleef(vabs_vf_vf_advsimd_sleef(d), vcast_vf_f_advsimd_sleef(0.5f)); + vfloat_advsimd_sleef x2 = vsel_vf_vo_vf_vf_advsimd_sleef(o, vmul_vf_vf_vf_advsimd_sleef(d, d), + vmul_vf_vf_vf_advsimd_sleef(vsub_vf_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(1), vabs_vf_vf_advsimd_sleef(d)), vcast_vf_f_advsimd_sleef(0.5f))), u; + vfloat_advsimd_sleef x = vsel_vf_vo_vf_vf_advsimd_sleef(o, vabs_vf_vf_advsimd_sleef(d), vsqrt_vf_vf_advsimd_sleef(x2)); + x = vsel_vf_vo_vf_vf_advsimd_sleef(veq_vo_vf_vf_advsimd_sleef(vabs_vf_vf_advsimd_sleef(d), vcast_vf_f_advsimd_sleef(1.0f)), vcast_vf_f_advsimd_sleef(0), x); + + u = vcast_vf_f_advsimd_sleef(+0.4197454825e-1); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, x2, vcast_vf_f_advsimd_sleef(+0.2424046025e-1)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, x2, vcast_vf_f_advsimd_sleef(+0.4547423869e-1)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, x2, vcast_vf_f_advsimd_sleef(+0.7495029271e-1)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, x2, vcast_vf_f_advsimd_sleef(+0.1666677296e+0)); + u = vmul_vf_vf_vf_advsimd_sleef(u, vmul_vf_vf_vf_advsimd_sleef(x2, x)); + + vfloat_advsimd_sleef y = vsub_vf_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(3.1415926535897932f/2), vadd_vf_vf_vf_advsimd_sleef(vmulsign_vf_vf_vf_advsimd_sleef(x, d), vmulsign_vf_vf_vf_advsimd_sleef(u, d))); + x = vadd_vf_vf_vf_advsimd_sleef(x, u); + vfloat_advsimd_sleef r = vsel_vf_vo_vf_vf_advsimd_sleef(o, y, vmul_vf_vf_vf_advsimd_sleef(x, vcast_vf_f_advsimd_sleef(2))); + return vsel_vf_vo_vf_vf_advsimd_sleef(vandnot_vo_vo_vo_advsimd_sleef(o, vlt_vo_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(0))), + vf2getx_vf_vf2_advsimd_sleef(dfadd_vf2_vf2_vf_advsimd_sleef(vcast_vf2_f_f_advsimd_sleef(3.1415927410125732422f,-8.7422776573475857731e-08f), + vneg_vf_vf_advsimd_sleef(r))), r); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_advsimd_sleef atan2kf_u1_advsimd_sleef(vfloat2_advsimd_sleef y, vfloat2_advsimd_sleef x) { + vfloat_advsimd_sleef u; + vfloat2_advsimd_sleef s, t; + vint2_advsimd_sleef q; + vopmask_advsimd_sleef p; + vmask_advsimd_sleef r; + + q = vsel_vi2_vf_vf_vi2_vi2_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(x), vcast_vf_f_advsimd_sleef(0), vcast_vi2_i_advsimd_sleef(-2), vcast_vi2_i_advsimd_sleef(0)); + p = vlt_vo_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(x), vcast_vf_f_advsimd_sleef(0)); + r = vand_vm_vo32_vm_advsimd_sleef(p, vreinterpret_vm_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(-0.0))); + x = vf2setx_vf2_vf2_vf_advsimd_sleef(x, vreinterpret_vf_vm_advsimd_sleef(vxor_vm_vm_vm_advsimd_sleef(vreinterpret_vm_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(x)), r))); + x = vf2sety_vf2_vf2_vf_advsimd_sleef(x, vreinterpret_vf_vm_advsimd_sleef(vxor_vm_vm_vm_advsimd_sleef(vreinterpret_vm_vf_advsimd_sleef(vf2gety_vf_vf2_advsimd_sleef(x)), r))); + + q = vsel_vi2_vf_vf_vi2_vi2_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(x), vf2getx_vf_vf2_advsimd_sleef(y), vadd_vi2_vi2_vi2_advsimd_sleef(q, vcast_vi2_i_advsimd_sleef(1)), q); + p = vlt_vo_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(x), vf2getx_vf_vf2_advsimd_sleef(y)); + s = vsel_vf2_vo_vf2_vf2_advsimd_sleef(p, dfneg_vf2_vf2_advsimd_sleef(x), y); + t = vsel_vf2_vo_vf2_vf2_advsimd_sleef(p, y, x); + + s = dfdiv_vf2_vf2_vf2_advsimd_sleef(s, t); + t = dfsqu_vf2_vf2_advsimd_sleef(s); + t = dfnormalize_vf2_vf2_advsimd_sleef(t); + + u = vcast_vf_f_advsimd_sleef(-0.00176397908944636583328247f); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, vf2getx_vf_vf2_advsimd_sleef(t), vcast_vf_f_advsimd_sleef(0.0107900900766253471374512f)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, vf2getx_vf_vf2_advsimd_sleef(t), vcast_vf_f_advsimd_sleef(-0.0309564601629972457885742f)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, vf2getx_vf_vf2_advsimd_sleef(t), vcast_vf_f_advsimd_sleef(0.0577365085482597351074219f)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, vf2getx_vf_vf2_advsimd_sleef(t), vcast_vf_f_advsimd_sleef(-0.0838950723409652709960938f)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, vf2getx_vf_vf2_advsimd_sleef(t), vcast_vf_f_advsimd_sleef(0.109463557600975036621094f)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, vf2getx_vf_vf2_advsimd_sleef(t), vcast_vf_f_advsimd_sleef(-0.142626821994781494140625f)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, vf2getx_vf_vf2_advsimd_sleef(t), vcast_vf_f_advsimd_sleef(0.199983194470405578613281f)); + + t = dfmul_vf2_vf2_vf2_advsimd_sleef(t, dfadd_vf2_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(-0.333332866430282592773438f), vmul_vf_vf_vf_advsimd_sleef(u, vf2getx_vf_vf2_advsimd_sleef(t)))); + t = dfmul_vf2_vf2_vf2_advsimd_sleef(s, dfadd_vf2_vf_vf2_advsimd_sleef(vcast_vf_f_advsimd_sleef(1), t)); + t = dfadd_vf2_vf2_vf2_advsimd_sleef(dfmul_vf2_vf2_vf_advsimd_sleef(vcast_vf2_f_f_advsimd_sleef(1.5707963705062866211f, -4.3711388286737928865e-08f), vcast_vf_vi2_advsimd_sleef(q)), t); + + return t; +} + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_atan2f4_u10advsimd(vfloat_advsimd_sleef y, vfloat_advsimd_sleef x) { + vopmask_advsimd_sleef o = vlt_vo_vf_vf_advsimd_sleef(vabs_vf_vf_advsimd_sleef(x), vcast_vf_f_advsimd_sleef(2.9387372783541830947e-39f)); + x = vsel_vf_vo_vf_vf_advsimd_sleef(o, vmul_vf_vf_vf_advsimd_sleef(x, vcast_vf_f_advsimd_sleef(1 << 24)), x); + y = vsel_vf_vo_vf_vf_advsimd_sleef(o, vmul_vf_vf_vf_advsimd_sleef(y, vcast_vf_f_advsimd_sleef(1 << 24)), y); + + vfloat2_advsimd_sleef d = atan2kf_u1_advsimd_sleef(vcast_vf2_vf_vf_advsimd_sleef(vabs_vf_vf_advsimd_sleef(y), vcast_vf_f_advsimd_sleef(0)), vcast_vf2_vf_vf_advsimd_sleef(x, vcast_vf_f_advsimd_sleef(0))); + vfloat_advsimd_sleef r = vadd_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(d), vf2gety_vf_vf2_advsimd_sleef(d)); + + r = vmulsign_vf_vf_vf_advsimd_sleef(r, x); + r = vsel_vf_vo_vf_vf_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(visinf_vo_vf_advsimd_sleef(x), veq_vo_vf_vf_advsimd_sleef(x, vcast_vf_f_advsimd_sleef(0))), vsub_vf_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(3.141592653589793238462643383279502884/2), visinf2_vf_vf_vf_advsimd_sleef(x, vmulsign_vf_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(3.141592653589793238462643383279502884/2), x))), r); + r = vsel_vf_vo_vf_vf_advsimd_sleef(visinf_vo_vf_advsimd_sleef(y), vsub_vf_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(3.141592653589793238462643383279502884/2), visinf2_vf_vf_vf_advsimd_sleef(x, vmulsign_vf_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(3.141592653589793238462643383279502884/4), x))), r); + r = vsel_vf_vo_vf_vf_advsimd_sleef(veq_vo_vf_vf_advsimd_sleef(y, vcast_vf_f_advsimd_sleef(0.0f)), vreinterpret_vf_vm_advsimd_sleef(vand_vm_vo32_vm_advsimd_sleef(vsignbit_vo_vf_advsimd_sleef(x), vreinterpret_vm_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef((float)3.141592653589793238462643383279502884)))), r); + + r = vreinterpret_vf_vm_advsimd_sleef(vor_vm_vo32_vm_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(visnan_vo_vf_advsimd_sleef(x), visnan_vo_vf_advsimd_sleef(y)), vreinterpret_vm_vf_advsimd_sleef(vmulsign_vf_vf_vf_advsimd_sleef(r, y)))); + return r; +} + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_asinf4_u10advsimd(vfloat_advsimd_sleef d) { + vopmask_advsimd_sleef o = vlt_vo_vf_vf_advsimd_sleef(vabs_vf_vf_advsimd_sleef(d), vcast_vf_f_advsimd_sleef(0.5f)); + vfloat_advsimd_sleef x2 = vsel_vf_vo_vf_vf_advsimd_sleef(o, vmul_vf_vf_vf_advsimd_sleef(d, d), vmul_vf_vf_vf_advsimd_sleef(vsub_vf_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(1), vabs_vf_vf_advsimd_sleef(d)), vcast_vf_f_advsimd_sleef(0.5f))), u; + vfloat2_advsimd_sleef x = vsel_vf2_vo_vf2_vf2_advsimd_sleef(o, vcast_vf2_vf_vf_advsimd_sleef(vabs_vf_vf_advsimd_sleef(d), vcast_vf_f_advsimd_sleef(0)), dfsqrt_vf2_vf_advsimd_sleef(x2)); + x = vsel_vf2_vo_vf2_vf2_advsimd_sleef(veq_vo_vf_vf_advsimd_sleef(vabs_vf_vf_advsimd_sleef(d), vcast_vf_f_advsimd_sleef(1.0f)), vcast_vf2_f_f_advsimd_sleef(0, 0), x); + + u = vcast_vf_f_advsimd_sleef(+0.4197454825e-1); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, x2, vcast_vf_f_advsimd_sleef(+0.2424046025e-1)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, x2, vcast_vf_f_advsimd_sleef(+0.4547423869e-1)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, x2, vcast_vf_f_advsimd_sleef(+0.7495029271e-1)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, x2, vcast_vf_f_advsimd_sleef(+0.1666677296e+0)); + u = vmul_vf_vf_vf_advsimd_sleef(u, vmul_vf_vf_vf_advsimd_sleef(x2, vf2getx_vf_vf2_advsimd_sleef(x))); + + vfloat2_advsimd_sleef y = dfsub_vf2_vf2_vf_advsimd_sleef(dfsub_vf2_vf2_vf2_advsimd_sleef(vcast_vf2_f_f_advsimd_sleef(3.1415927410125732422f/4,-8.7422776573475857731e-08f/4), x), u); + + vfloat_advsimd_sleef r = vsel_vf_vo_vf_vf_advsimd_sleef(o, vadd_vf_vf_vf_advsimd_sleef(u, vf2getx_vf_vf2_advsimd_sleef(x)), + vmul_vf_vf_vf_advsimd_sleef(vadd_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(y), vf2gety_vf_vf2_advsimd_sleef(y)), vcast_vf_f_advsimd_sleef(2))); + return vmulsign_vf_vf_vf_advsimd_sleef(r, d); +} + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_acosf4_u10advsimd(vfloat_advsimd_sleef d) { + vopmask_advsimd_sleef o = vlt_vo_vf_vf_advsimd_sleef(vabs_vf_vf_advsimd_sleef(d), vcast_vf_f_advsimd_sleef(0.5f)); + vfloat_advsimd_sleef x2 = vsel_vf_vo_vf_vf_advsimd_sleef(o, vmul_vf_vf_vf_advsimd_sleef(d, d), vmul_vf_vf_vf_advsimd_sleef(vsub_vf_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(1), vabs_vf_vf_advsimd_sleef(d)), vcast_vf_f_advsimd_sleef(0.5f))), u; + vfloat2_advsimd_sleef x = vsel_vf2_vo_vf2_vf2_advsimd_sleef(o, vcast_vf2_vf_vf_advsimd_sleef(vabs_vf_vf_advsimd_sleef(d), vcast_vf_f_advsimd_sleef(0)), dfsqrt_vf2_vf_advsimd_sleef(x2)); + x = vsel_vf2_vo_vf2_vf2_advsimd_sleef(veq_vo_vf_vf_advsimd_sleef(vabs_vf_vf_advsimd_sleef(d), vcast_vf_f_advsimd_sleef(1.0f)), vcast_vf2_f_f_advsimd_sleef(0, 0), x); + + u = vcast_vf_f_advsimd_sleef(+0.4197454825e-1); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, x2, vcast_vf_f_advsimd_sleef(+0.2424046025e-1)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, x2, vcast_vf_f_advsimd_sleef(+0.4547423869e-1)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, x2, vcast_vf_f_advsimd_sleef(+0.7495029271e-1)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, x2, vcast_vf_f_advsimd_sleef(+0.1666677296e+0)); + u = vmul_vf_vf_vf_advsimd_sleef(u, vmul_vf_vf_vf_advsimd_sleef(x2, vf2getx_vf_vf2_advsimd_sleef(x))); + + vfloat2_advsimd_sleef y = dfsub_vf2_vf2_vf2_advsimd_sleef(vcast_vf2_f_f_advsimd_sleef(3.1415927410125732422f/2, -8.7422776573475857731e-08f/2), + dfadd_vf2_vf_vf_advsimd_sleef(vmulsign_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(x), d), vmulsign_vf_vf_vf_advsimd_sleef(u, d))); + x = dfadd_vf2_vf2_vf_advsimd_sleef(x, u); + + y = vsel_vf2_vo_vf2_vf2_advsimd_sleef(o, y, dfscale_vf2_vf2_vf_advsimd_sleef(x, vcast_vf_f_advsimd_sleef(2))); + + y = vsel_vf2_vo_vf2_vf2_advsimd_sleef(vandnot_vo_vo_vo_advsimd_sleef(o, vlt_vo_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(0))), + dfsub_vf2_vf2_vf2_advsimd_sleef(vcast_vf2_f_f_advsimd_sleef(3.1415927410125732422f, -8.7422776573475857731e-08f), y), y); + + return vadd_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(y), vf2gety_vf_vf2_advsimd_sleef(y)); +} + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_atanf4_u10advsimd(vfloat_advsimd_sleef d) { + vfloat2_advsimd_sleef d2 = atan2kf_u1_advsimd_sleef(vcast_vf2_vf_vf_advsimd_sleef(vabs_vf_vf_advsimd_sleef(d), vcast_vf_f_advsimd_sleef(0)), vcast_vf2_f_f_advsimd_sleef(1, 0)); + vfloat_advsimd_sleef r = vadd_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(d2), vf2gety_vf_vf2_advsimd_sleef(d2)); + r = vsel_vf_vo_vf_vf_advsimd_sleef(visinf_vo_vf_advsimd_sleef(d), vcast_vf_f_advsimd_sleef(1.570796326794896557998982), r); + return vmulsign_vf_vf_vf_advsimd_sleef(r, d); +} + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_logf4_u35advsimd(vfloat_advsimd_sleef d) { + vfloat_advsimd_sleef x, x2, t, m; + + vopmask_advsimd_sleef o = vlt_vo_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(0x1p-126)); + d = vsel_vf_vo_vf_vf_advsimd_sleef(o, vmul_vf_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef((float)(INT64_C(1) << 32) * (float)(INT64_C(1) << 32))), d); + vint2_advsimd_sleef e = vilogb2k_vi2_vf_advsimd_sleef(vmul_vf_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(1.0f/0.75f))); + m = vldexp3_vf_vf_vi2_advsimd_sleef(d, vneg_vi2_vi2_advsimd_sleef(e)); + e = vsel_vi2_vo_vi2_vi2_advsimd_sleef(o, vsub_vi2_vi2_vi2_advsimd_sleef(e, vcast_vi2_i_advsimd_sleef(64)), e); + + x = vdiv_vf_vf_vf_advsimd_sleef(vsub_vf_vf_vf_advsimd_sleef(m, vcast_vf_f_advsimd_sleef(1.0f)), vadd_vf_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(1.0f), m)); + x2 = vmul_vf_vf_vf_advsimd_sleef(x, x); + + t = vcast_vf_f_advsimd_sleef(0.2392828464508056640625f); + t = vmla_vf_vf_vf_vf_advsimd_sleef(t, x2, vcast_vf_f_advsimd_sleef(0.28518211841583251953125f)); + t = vmla_vf_vf_vf_vf_advsimd_sleef(t, x2, vcast_vf_f_advsimd_sleef(0.400005877017974853515625f)); + t = vmla_vf_vf_vf_vf_advsimd_sleef(t, x2, vcast_vf_f_advsimd_sleef(0.666666686534881591796875f)); + t = vmla_vf_vf_vf_vf_advsimd_sleef(t, x2, vcast_vf_f_advsimd_sleef(2.0f)); + + x = vmla_vf_vf_vf_vf_advsimd_sleef(x, t, vmul_vf_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(0.693147180559945286226764f), vcast_vf_vi2_advsimd_sleef(e))); + x = vsel_vf_vo_vf_vf_advsimd_sleef(vispinf_vo_vf_advsimd_sleef(d), vcast_vf_f_advsimd_sleef(__builtin_inff()), x); + x = vsel_vf_vo_vf_vf_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(vlt_vo_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(0)), visnan_vo_vf_advsimd_sleef(d)), vcast_vf_f_advsimd_sleef(__builtin_nanf("")), x); + x = vsel_vf_vo_vf_vf_advsimd_sleef(veq_vo_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(0)), vcast_vf_f_advsimd_sleef(-__builtin_inff()), x); + + return x; +} + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_expf4_u10advsimd(vfloat_advsimd_sleef d) { + vint2_advsimd_sleef q = vrint_vi2_vf_advsimd_sleef(vmul_vf_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(1.442695040888963407359924681001892137426645954152985934135449406931f))); + vfloat_advsimd_sleef s, u; + + s = vmla_vf_vf_vf_vf_advsimd_sleef(vcast_vf_vi2_advsimd_sleef(q), vcast_vf_f_advsimd_sleef(-0.693145751953125f), d); + s = vmla_vf_vf_vf_vf_advsimd_sleef(vcast_vf_vi2_advsimd_sleef(q), vcast_vf_f_advsimd_sleef(-1.428606765330187045e-06f), s); + + u = vcast_vf_f_advsimd_sleef(0.000198527617612853646278381); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, s, vcast_vf_f_advsimd_sleef(0.00139304355252534151077271)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, s, vcast_vf_f_advsimd_sleef(0.00833336077630519866943359)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, s, vcast_vf_f_advsimd_sleef(0.0416664853692054748535156)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, s, vcast_vf_f_advsimd_sleef(0.166666671633720397949219)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, s, vcast_vf_f_advsimd_sleef(0.5)); + + u = vadd_vf_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(1.0f), vmla_vf_vf_vf_vf_advsimd_sleef(vmul_vf_vf_vf_advsimd_sleef(s, s), u, s)); + + u = vldexp2_vf_vf_vi2_advsimd_sleef(u, q); + + u = vreinterpret_vf_vm_advsimd_sleef(vandnot_vm_vo32_vm_advsimd_sleef(vlt_vo_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(-104)), vreinterpret_vm_vf_advsimd_sleef(u))); + u = vsel_vf_vo_vf_vf_advsimd_sleef(vlt_vo_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(100), d), vcast_vf_f_advsimd_sleef(__builtin_inff()), u); + + return u; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_advsimd_sleef expm1fk_advsimd_sleef(vfloat_advsimd_sleef d) { + vint2_advsimd_sleef q = vrint_vi2_vf_advsimd_sleef(vmul_vf_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(1.442695040888963407359924681001892137426645954152985934135449406931f))); + vfloat_advsimd_sleef s, u; + + s = vmla_vf_vf_vf_vf_advsimd_sleef(vcast_vf_vi2_advsimd_sleef(q), vcast_vf_f_advsimd_sleef(-0.693145751953125f), d); + s = vmla_vf_vf_vf_vf_advsimd_sleef(vcast_vf_vi2_advsimd_sleef(q), vcast_vf_f_advsimd_sleef(-1.428606765330187045e-06f), s); + + vfloat_advsimd_sleef s2 = vmul_vf_vf_vf_advsimd_sleef(s, s), s4 = vmul_vf_vf_vf_advsimd_sleef(s2, s2); + u = vmla_vf_vf_vf_vf_advsimd_sleef((s4), (vmla_vf_vf_vf_vf_advsimd_sleef((s), (vcast_vf_f_advsimd_sleef(0.000198527617612853646278381)), (vcast_vf_f_advsimd_sleef(0.00139304355252534151077271)))), (vmla_vf_vf_vf_vf_advsimd_sleef((s2), (vmla_vf_vf_vf_vf_advsimd_sleef((s), (vcast_vf_f_advsimd_sleef(0.00833336077630519866943359)), (vcast_vf_f_advsimd_sleef(0.0416664853692054748535156)))), (vmla_vf_vf_vf_vf_advsimd_sleef((s), (vcast_vf_f_advsimd_sleef(0.166666671633720397949219)), (vcast_vf_f_advsimd_sleef(0.5))))))) + + ; + + u = vmla_vf_vf_vf_vf_advsimd_sleef(vmul_vf_vf_vf_advsimd_sleef(s, s), u, s); + + u = vsel_vf_vo_vf_vf_advsimd_sleef(veq_vo_vi2_vi2_advsimd_sleef(q, vcast_vi2_i_advsimd_sleef(0)), u, + vsub_vf_vf_vf_advsimd_sleef(vldexp2_vf_vf_vi2_advsimd_sleef(vadd_vf_vf_vf_advsimd_sleef(u, vcast_vf_f_advsimd_sleef(1)), q), vcast_vf_f_advsimd_sleef(1))); + + return u; +} + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_sqrtf4_u35advsimd(vfloat_advsimd_sleef d) { return vsqrt_vf_vf_advsimd_sleef(d); } + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_cbrtf4_u35advsimd(vfloat_advsimd_sleef d) { + vfloat_advsimd_sleef x, y, q = vcast_vf_f_advsimd_sleef(1.0), t; + vint2_advsimd_sleef e, qu, re; + + e = vadd_vi2_vi2_vi2_advsimd_sleef(vilogbk_vi2_vf_advsimd_sleef(vabs_vf_vf_advsimd_sleef(d)), vcast_vi2_i_advsimd_sleef(1)); + d = vldexp2_vf_vf_vi2_advsimd_sleef(d, vneg_vi2_vi2_advsimd_sleef(e)); + + t = vadd_vf_vf_vf_advsimd_sleef(vcast_vf_vi2_advsimd_sleef(e), vcast_vf_f_advsimd_sleef(6144)); + qu = vtruncate_vi2_vf_advsimd_sleef(vmul_vf_vf_vf_advsimd_sleef(t, vcast_vf_f_advsimd_sleef(1.0f/3.0f))); + re = vtruncate_vi2_vf_advsimd_sleef(vsub_vf_vf_vf_advsimd_sleef(t, vmul_vf_vf_vf_advsimd_sleef(vcast_vf_vi2_advsimd_sleef(qu), vcast_vf_f_advsimd_sleef(3)))); + + q = vsel_vf_vo_vf_vf_advsimd_sleef(veq_vo_vi2_vi2_advsimd_sleef(re, vcast_vi2_i_advsimd_sleef(1)), vcast_vf_f_advsimd_sleef(1.2599210498948731647672106f), q); + q = vsel_vf_vo_vf_vf_advsimd_sleef(veq_vo_vi2_vi2_advsimd_sleef(re, vcast_vi2_i_advsimd_sleef(2)), vcast_vf_f_advsimd_sleef(1.5874010519681994747517056f), q); + q = vldexp2_vf_vf_vi2_advsimd_sleef(q, vsub_vi2_vi2_vi2_advsimd_sleef(qu, vcast_vi2_i_advsimd_sleef(2048))); + + q = vmulsign_vf_vf_vf_advsimd_sleef(q, d); + d = vabs_vf_vf_advsimd_sleef(d); + + x = vcast_vf_f_advsimd_sleef(-0.601564466953277587890625f); + x = vmla_vf_vf_vf_vf_advsimd_sleef(x, d, vcast_vf_f_advsimd_sleef(2.8208892345428466796875f)); + x = vmla_vf_vf_vf_vf_advsimd_sleef(x, d, vcast_vf_f_advsimd_sleef(-5.532182216644287109375f)); + x = vmla_vf_vf_vf_vf_advsimd_sleef(x, d, vcast_vf_f_advsimd_sleef(5.898262500762939453125f)); + x = vmla_vf_vf_vf_vf_advsimd_sleef(x, d, vcast_vf_f_advsimd_sleef(-3.8095417022705078125f)); + x = vmla_vf_vf_vf_vf_advsimd_sleef(x, d, vcast_vf_f_advsimd_sleef(2.2241256237030029296875f)); + + y = vmul_vf_vf_vf_advsimd_sleef(vmul_vf_vf_vf_advsimd_sleef(d, x), x); + y = vmul_vf_vf_vf_advsimd_sleef(vsub_vf_vf_vf_advsimd_sleef(y, vmul_vf_vf_vf_advsimd_sleef(vmul_vf_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(2.0f / 3.0f), y), vmla_vf_vf_vf_vf_advsimd_sleef(y, x, vcast_vf_f_advsimd_sleef(-1.0f)))), q); + + return y; +} + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_cbrtf4_u10advsimd(vfloat_advsimd_sleef d) { + vfloat_advsimd_sleef x, y, z, t; + vfloat2_advsimd_sleef q2 = vcast_vf2_f_f_advsimd_sleef(1, 0), u, v; + vint2_advsimd_sleef e, qu, re; + + e = vadd_vi2_vi2_vi2_advsimd_sleef(vilogbk_vi2_vf_advsimd_sleef(vabs_vf_vf_advsimd_sleef(d)), vcast_vi2_i_advsimd_sleef(1)); + d = vldexp2_vf_vf_vi2_advsimd_sleef(d, vneg_vi2_vi2_advsimd_sleef(e)); + + t = vadd_vf_vf_vf_advsimd_sleef(vcast_vf_vi2_advsimd_sleef(e), vcast_vf_f_advsimd_sleef(6144)); + qu = vtruncate_vi2_vf_advsimd_sleef(vmul_vf_vf_vf_advsimd_sleef(t, vcast_vf_f_advsimd_sleef(1.0/3.0))); + re = vtruncate_vi2_vf_advsimd_sleef(vsub_vf_vf_vf_advsimd_sleef(t, vmul_vf_vf_vf_advsimd_sleef(vcast_vf_vi2_advsimd_sleef(qu), vcast_vf_f_advsimd_sleef(3)))); + + q2 = vsel_vf2_vo_vf2_vf2_advsimd_sleef(veq_vo_vi2_vi2_advsimd_sleef(re, vcast_vi2_i_advsimd_sleef(1)), vcast_vf2_f_f_advsimd_sleef(1.2599210739135742188f, -2.4018701694217270415e-08), q2); + q2 = vsel_vf2_vo_vf2_vf2_advsimd_sleef(veq_vo_vi2_vi2_advsimd_sleef(re, vcast_vi2_i_advsimd_sleef(2)), vcast_vf2_f_f_advsimd_sleef(1.5874010324478149414f, 1.9520385308169352356e-08), q2); + + q2 = vf2setx_vf2_vf2_vf_advsimd_sleef(q2, vmulsign_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(q2), d)); + q2 = vf2sety_vf2_vf2_vf_advsimd_sleef(q2, vmulsign_vf_vf_vf_advsimd_sleef(vf2gety_vf_vf2_advsimd_sleef(q2), d)); + d = vabs_vf_vf_advsimd_sleef(d); + + x = vcast_vf_f_advsimd_sleef(-0.601564466953277587890625f); + x = vmla_vf_vf_vf_vf_advsimd_sleef(x, d, vcast_vf_f_advsimd_sleef(2.8208892345428466796875f)); + x = vmla_vf_vf_vf_vf_advsimd_sleef(x, d, vcast_vf_f_advsimd_sleef(-5.532182216644287109375f)); + x = vmla_vf_vf_vf_vf_advsimd_sleef(x, d, vcast_vf_f_advsimd_sleef(5.898262500762939453125f)); + x = vmla_vf_vf_vf_vf_advsimd_sleef(x, d, vcast_vf_f_advsimd_sleef(-3.8095417022705078125f)); + x = vmla_vf_vf_vf_vf_advsimd_sleef(x, d, vcast_vf_f_advsimd_sleef(2.2241256237030029296875f)); + + y = vmul_vf_vf_vf_advsimd_sleef(x, x); y = vmul_vf_vf_vf_advsimd_sleef(y, y); x = vsub_vf_vf_vf_advsimd_sleef(x, vmul_vf_vf_vf_advsimd_sleef(vmlanp_vf_vf_vf_vf_advsimd_sleef(d, y, x), vcast_vf_f_advsimd_sleef(-1.0 / 3.0))); + + z = x; + + u = dfmul_vf2_vf_vf_advsimd_sleef(x, x); + u = dfmul_vf2_vf2_vf2_advsimd_sleef(u, u); + u = dfmul_vf2_vf2_vf_advsimd_sleef(u, d); + u = dfadd2_vf2_vf2_vf_advsimd_sleef(u, vneg_vf_vf_advsimd_sleef(x)); + y = vadd_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(u), vf2gety_vf_vf2_advsimd_sleef(u)); + + y = vmul_vf_vf_vf_advsimd_sleef(vmul_vf_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(-2.0 / 3.0), y), z); + v = dfadd2_vf2_vf2_vf_advsimd_sleef(dfmul_vf2_vf_vf_advsimd_sleef(z, z), y); + v = dfmul_vf2_vf2_vf_advsimd_sleef(v, d); + v = dfmul_vf2_vf2_vf2_advsimd_sleef(v, q2); + z = vldexp2_vf_vf_vi2_advsimd_sleef(vadd_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(v), vf2gety_vf_vf2_advsimd_sleef(v)), vsub_vi2_vi2_vi2_advsimd_sleef(qu, vcast_vi2_i_advsimd_sleef(2048))); + + z = vsel_vf_vo_vf_vf_advsimd_sleef(visinf_vo_vf_advsimd_sleef(d), vmulsign_vf_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(__builtin_inff()), vf2getx_vf_vf2_advsimd_sleef(q2)), z); + z = vsel_vf_vo_vf_vf_advsimd_sleef(veq_vo_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(0)), vreinterpret_vf_vm_advsimd_sleef(vsignbit_vm_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(q2))), z); + + return z; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_advsimd_sleef logkf_advsimd_sleef(vfloat_advsimd_sleef d) { + vfloat2_advsimd_sleef x, x2; + vfloat_advsimd_sleef t, m; + + vopmask_advsimd_sleef o = vlt_vo_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(0x1p-126)); + d = vsel_vf_vo_vf_vf_advsimd_sleef(o, vmul_vf_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef((float)(INT64_C(1) << 32) * (float)(INT64_C(1) << 32))), d); + vint2_advsimd_sleef e = vilogb2k_vi2_vf_advsimd_sleef(vmul_vf_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(1.0f/0.75f))); + m = vldexp3_vf_vf_vi2_advsimd_sleef(d, vneg_vi2_vi2_advsimd_sleef(e)); + e = vsel_vi2_vo_vi2_vi2_advsimd_sleef(o, vsub_vi2_vi2_vi2_advsimd_sleef(e, vcast_vi2_i_advsimd_sleef(64)), e); + + x = dfdiv_vf2_vf2_vf2_advsimd_sleef(dfadd2_vf2_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(-1), m), dfadd2_vf2_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(1), m)); + x2 = dfsqu_vf2_vf2_advsimd_sleef(x); + + t = vcast_vf_f_advsimd_sleef(0.240320354700088500976562); + t = vmla_vf_vf_vf_vf_advsimd_sleef(t, vf2getx_vf_vf2_advsimd_sleef(x2), vcast_vf_f_advsimd_sleef(0.285112679004669189453125)); + t = vmla_vf_vf_vf_vf_advsimd_sleef(t, vf2getx_vf_vf2_advsimd_sleef(x2), vcast_vf_f_advsimd_sleef(0.400007992982864379882812)); + vfloat2_advsimd_sleef c = vcast_vf2_f_f_advsimd_sleef(0.66666662693023681640625f, 3.69183861259614332084311e-09f); + + vfloat2_advsimd_sleef s = dfmul_vf2_vf2_vf_advsimd_sleef(vcast_vf2_f_f_advsimd_sleef(0.69314718246459960938f, -1.904654323148236017e-09f), vcast_vf_vi2_advsimd_sleef(e)); + + s = dfadd_vf2_vf2_vf2_advsimd_sleef(s, dfscale_vf2_vf2_vf_advsimd_sleef(x, vcast_vf_f_advsimd_sleef(2))); + s = dfadd_vf2_vf2_vf2_advsimd_sleef(s, dfmul_vf2_vf2_vf2_advsimd_sleef(dfmul_vf2_vf2_vf2_advsimd_sleef(x2, x), + dfadd2_vf2_vf2_vf2_advsimd_sleef(dfmul_vf2_vf2_vf_advsimd_sleef(x2, t), c))); + return s; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_advsimd_sleef logk3f_advsimd_sleef(vfloat_advsimd_sleef d) { + vfloat_advsimd_sleef x, x2, t, m; + + vopmask_advsimd_sleef o = vlt_vo_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(0x1p-126)); + d = vsel_vf_vo_vf_vf_advsimd_sleef(o, vmul_vf_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef((float)(INT64_C(1) << 32) * (float)(INT64_C(1) << 32))), d); + vint2_advsimd_sleef e = vilogb2k_vi2_vf_advsimd_sleef(vmul_vf_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(1.0f/0.75f))); + m = vldexp3_vf_vf_vi2_advsimd_sleef(d, vneg_vi2_vi2_advsimd_sleef(e)); + e = vsel_vi2_vo_vi2_vi2_advsimd_sleef(o, vsub_vi2_vi2_vi2_advsimd_sleef(e, vcast_vi2_i_advsimd_sleef(64)), e); + + x = vdiv_vf_vf_vf_advsimd_sleef(vsub_vf_vf_vf_advsimd_sleef(m, vcast_vf_f_advsimd_sleef(1.0f)), vadd_vf_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(1.0f), m)); + x2 = vmul_vf_vf_vf_advsimd_sleef(x, x); + + t = vcast_vf_f_advsimd_sleef(0.2392828464508056640625f); + t = vmla_vf_vf_vf_vf_advsimd_sleef(t, x2, vcast_vf_f_advsimd_sleef(0.28518211841583251953125f)); + t = vmla_vf_vf_vf_vf_advsimd_sleef(t, x2, vcast_vf_f_advsimd_sleef(0.400005877017974853515625f)); + t = vmla_vf_vf_vf_vf_advsimd_sleef(t, x2, vcast_vf_f_advsimd_sleef(0.666666686534881591796875f)); + t = vmla_vf_vf_vf_vf_advsimd_sleef(t, x2, vcast_vf_f_advsimd_sleef(2.0f)); + + x = vmla_vf_vf_vf_vf_advsimd_sleef(x, t, vmul_vf_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(0.693147180559945286226764f), vcast_vf_vi2_advsimd_sleef(e))); + + return x; +} + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_logf4_u10advsimd(vfloat_advsimd_sleef d) { + vfloat2_advsimd_sleef x; + vfloat_advsimd_sleef t, m, x2; + + vopmask_advsimd_sleef o = vlt_vo_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(0x1p-126)); + d = vsel_vf_vo_vf_vf_advsimd_sleef(o, vmul_vf_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef((float)(INT64_C(1) << 32) * (float)(INT64_C(1) << 32))), d); + vint2_advsimd_sleef e = vilogb2k_vi2_vf_advsimd_sleef(vmul_vf_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(1.0f/0.75f))); + m = vldexp3_vf_vf_vi2_advsimd_sleef(d, vneg_vi2_vi2_advsimd_sleef(e)); + e = vsel_vi2_vo_vi2_vi2_advsimd_sleef(o, vsub_vi2_vi2_vi2_advsimd_sleef(e, vcast_vi2_i_advsimd_sleef(64)), e); + vfloat2_advsimd_sleef s = dfmul_vf2_vf2_vf_advsimd_sleef(vcast_vf2_f_f_advsimd_sleef(0.69314718246459960938f, -1.904654323148236017e-09f), vcast_vf_vi2_advsimd_sleef(e)); + + x = dfdiv_vf2_vf2_vf2_advsimd_sleef(dfadd2_vf2_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(-1), m), dfadd2_vf2_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(1), m)); + x2 = vmul_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(x), vf2getx_vf_vf2_advsimd_sleef(x)); + + t = vcast_vf_f_advsimd_sleef(+0.3027294874e+0f); + t = vmla_vf_vf_vf_vf_advsimd_sleef(t, x2, vcast_vf_f_advsimd_sleef(+0.3996108174e+0f)); + t = vmla_vf_vf_vf_vf_advsimd_sleef(t, x2, vcast_vf_f_advsimd_sleef(+0.6666694880e+0f)); + + s = dfadd_vf2_vf2_vf2_advsimd_sleef(s, dfscale_vf2_vf2_vf_advsimd_sleef(x, vcast_vf_f_advsimd_sleef(2))); + s = dfadd_vf2_vf2_vf_advsimd_sleef(s, vmul_vf_vf_vf_advsimd_sleef(vmul_vf_vf_vf_advsimd_sleef(x2, vf2getx_vf_vf2_advsimd_sleef(x)), t)); + + vfloat_advsimd_sleef r = vadd_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(s), vf2gety_vf_vf2_advsimd_sleef(s)); + + r = vsel_vf_vo_vf_vf_advsimd_sleef(vispinf_vo_vf_advsimd_sleef(d), vcast_vf_f_advsimd_sleef(__builtin_inff()), r); + r = vsel_vf_vo_vf_vf_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(vlt_vo_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(0)), visnan_vo_vf_advsimd_sleef(d)), vcast_vf_f_advsimd_sleef(__builtin_nanf("")), r); + r = vsel_vf_vo_vf_vf_advsimd_sleef(veq_vo_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(0)), vcast_vf_f_advsimd_sleef(-__builtin_inff()), r); + + return r; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_advsimd_sleef expkf_advsimd_sleef(vfloat2_advsimd_sleef d) { + vfloat_advsimd_sleef u = vmul_vf_vf_vf_advsimd_sleef(vadd_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(d), vf2gety_vf_vf2_advsimd_sleef(d)), vcast_vf_f_advsimd_sleef(1.442695040888963407359924681001892137426645954152985934135449406931f)); + vint2_advsimd_sleef q = vrint_vi2_vf_advsimd_sleef(u); + vfloat2_advsimd_sleef s, t; + + s = dfadd2_vf2_vf2_vf_advsimd_sleef(d, vmul_vf_vf_vf_advsimd_sleef(vcast_vf_vi2_advsimd_sleef(q), vcast_vf_f_advsimd_sleef(-0.693145751953125f))); + s = dfadd2_vf2_vf2_vf_advsimd_sleef(s, vmul_vf_vf_vf_advsimd_sleef(vcast_vf_vi2_advsimd_sleef(q), vcast_vf_f_advsimd_sleef(-1.428606765330187045e-06f))); + + s = dfnormalize_vf2_vf2_advsimd_sleef(s); + + u = vcast_vf_f_advsimd_sleef(0.00136324646882712841033936f); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, vf2getx_vf_vf2_advsimd_sleef(s), vcast_vf_f_advsimd_sleef(0.00836596917361021041870117f)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, vf2getx_vf_vf2_advsimd_sleef(s), vcast_vf_f_advsimd_sleef(0.0416710823774337768554688f)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, vf2getx_vf_vf2_advsimd_sleef(s), vcast_vf_f_advsimd_sleef(0.166665524244308471679688f)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, vf2getx_vf_vf2_advsimd_sleef(s), vcast_vf_f_advsimd_sleef(0.499999850988388061523438f)); + + t = dfadd_vf2_vf2_vf2_advsimd_sleef(s, dfmul_vf2_vf2_vf_advsimd_sleef(dfsqu_vf2_vf2_advsimd_sleef(s), u)); + + t = dfadd_vf2_vf_vf2_advsimd_sleef(vcast_vf_f_advsimd_sleef(1), t); + u = vadd_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(t), vf2gety_vf_vf2_advsimd_sleef(t)); + u = vldexp_vf_vf_vi2_advsimd_sleef(u, q); + + u = vreinterpret_vf_vm_advsimd_sleef(vandnot_vm_vo32_vm_advsimd_sleef(vlt_vo_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(d), vcast_vf_f_advsimd_sleef(-104)), vreinterpret_vm_vf_advsimd_sleef(u))); + + return u; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_advsimd_sleef expk3f_advsimd_sleef(vfloat_advsimd_sleef d) { + vint2_advsimd_sleef q = vrint_vi2_vf_advsimd_sleef(vmul_vf_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(1.442695040888963407359924681001892137426645954152985934135449406931f))); + vfloat_advsimd_sleef s, u; + + s = vmla_vf_vf_vf_vf_advsimd_sleef(vcast_vf_vi2_advsimd_sleef(q), vcast_vf_f_advsimd_sleef(-0.693145751953125f), d); + s = vmla_vf_vf_vf_vf_advsimd_sleef(vcast_vf_vi2_advsimd_sleef(q), vcast_vf_f_advsimd_sleef(-1.428606765330187045e-06f), s); + + u = vcast_vf_f_advsimd_sleef(0.000198527617612853646278381); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, s, vcast_vf_f_advsimd_sleef(0.00139304355252534151077271)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, s, vcast_vf_f_advsimd_sleef(0.00833336077630519866943359)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, s, vcast_vf_f_advsimd_sleef(0.0416664853692054748535156)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, s, vcast_vf_f_advsimd_sleef(0.166666671633720397949219)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, s, vcast_vf_f_advsimd_sleef(0.5)); + + u = vmla_vf_vf_vf_vf_advsimd_sleef(vmul_vf_vf_vf_advsimd_sleef(s, s), u, vadd_vf_vf_vf_advsimd_sleef(s, vcast_vf_f_advsimd_sleef(1.0f))); + u = vldexp2_vf_vf_vi2_advsimd_sleef(u, q); + + u = vreinterpret_vf_vm_advsimd_sleef(vandnot_vm_vo32_vm_advsimd_sleef(vlt_vo_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(-104)), vreinterpret_vm_vf_advsimd_sleef(u))); + + return u; +} + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_powf4_u10advsimd(vfloat_advsimd_sleef x, vfloat_advsimd_sleef y) { + + vopmask_advsimd_sleef yisint = vor_vo_vo_vo_advsimd_sleef(veq_vo_vf_vf_advsimd_sleef(vtruncate_vf_vf_advsimd_sleef(y), y), vgt_vo_vf_vf_advsimd_sleef(vabs_vf_vf_advsimd_sleef(y), vcast_vf_f_advsimd_sleef(1 << 24))); + vopmask_advsimd_sleef yisodd = vand_vo_vo_vo_advsimd_sleef(vand_vo_vo_vo_advsimd_sleef(veq_vo_vi2_vi2_advsimd_sleef(vand_vi2_vi2_vi2_advsimd_sleef(vtruncate_vi2_vf_advsimd_sleef(y), vcast_vi2_i_advsimd_sleef(1)), vcast_vi2_i_advsimd_sleef(1)), yisint), + vlt_vo_vf_vf_advsimd_sleef(vabs_vf_vf_advsimd_sleef(y), vcast_vf_f_advsimd_sleef(1 << 24))); + + vfloat_advsimd_sleef result = expkf_advsimd_sleef(dfmul_vf2_vf2_vf_advsimd_sleef(logkf_advsimd_sleef(vabs_vf_vf_advsimd_sleef(x)), y)); + + result = vsel_vf_vo_vf_vf_advsimd_sleef(visnan_vo_vf_advsimd_sleef(result), vcast_vf_f_advsimd_sleef(__builtin_inff()), result); + + result = vmul_vf_vf_vf_advsimd_sleef(result, + vsel_vf_vo_vf_vf_advsimd_sleef(vgt_vo_vf_vf_advsimd_sleef(x, vcast_vf_f_advsimd_sleef(0)), + vcast_vf_f_advsimd_sleef(1), + vsel_vf_vo_vf_vf_advsimd_sleef(yisint, vsel_vf_vo_vf_vf_advsimd_sleef(yisodd, vcast_vf_f_advsimd_sleef(-1.0f), vcast_vf_f_advsimd_sleef(1)), vcast_vf_f_advsimd_sleef(__builtin_nanf(""))))); + + vfloat_advsimd_sleef efx = vmulsign_vf_vf_vf_advsimd_sleef(vsub_vf_vf_vf_advsimd_sleef(vabs_vf_vf_advsimd_sleef(x), vcast_vf_f_advsimd_sleef(1)), y); + + result = vsel_vf_vo_vf_vf_advsimd_sleef(visinf_vo_vf_advsimd_sleef(y), + vreinterpret_vf_vm_advsimd_sleef(vandnot_vm_vo32_vm_advsimd_sleef(vlt_vo_vf_vf_advsimd_sleef(efx, vcast_vf_f_advsimd_sleef(0.0f)), + vreinterpret_vm_vf_advsimd_sleef(vsel_vf_vo_vf_vf_advsimd_sleef(veq_vo_vf_vf_advsimd_sleef(efx, vcast_vf_f_advsimd_sleef(0.0f)), + vcast_vf_f_advsimd_sleef(1.0f), + vcast_vf_f_advsimd_sleef(__builtin_inff()))))), + result); + + result = vsel_vf_vo_vf_vf_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(visinf_vo_vf_advsimd_sleef(x), veq_vo_vf_vf_advsimd_sleef(x, vcast_vf_f_advsimd_sleef(0.0))), + vmulsign_vf_vf_vf_advsimd_sleef(vsel_vf_vo_vf_vf_advsimd_sleef(vxor_vo_vo_vo_advsimd_sleef(vsignbit_vo_vf_advsimd_sleef(y), veq_vo_vf_vf_advsimd_sleef(x, vcast_vf_f_advsimd_sleef(0.0f))), + vcast_vf_f_advsimd_sleef(0), vcast_vf_f_advsimd_sleef(__builtin_inff())), + vsel_vf_vo_vf_vf_advsimd_sleef(yisodd, x, vcast_vf_f_advsimd_sleef(1))), result); + + result = vreinterpret_vf_vm_advsimd_sleef(vor_vm_vo32_vm_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(visnan_vo_vf_advsimd_sleef(x), visnan_vo_vf_advsimd_sleef(y)), vreinterpret_vm_vf_advsimd_sleef(result))); + + result = vsel_vf_vo_vf_vf_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(veq_vo_vf_vf_advsimd_sleef(y, vcast_vf_f_advsimd_sleef(0)), veq_vo_vf_vf_advsimd_sleef(x, vcast_vf_f_advsimd_sleef(1))), vcast_vf_f_advsimd_sleef(1), result); + + return result; + +} + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_fastpowf4_u3500advsimd(vfloat_advsimd_sleef x, vfloat_advsimd_sleef y) { + vfloat_advsimd_sleef result = expk3f_advsimd_sleef(vmul_vf_vf_vf_advsimd_sleef(logk3f_advsimd_sleef(vabs_vf_vf_advsimd_sleef(x)), y)); + vopmask_advsimd_sleef yisint = vor_vo_vo_vo_advsimd_sleef(veq_vo_vf_vf_advsimd_sleef(vtruncate_vf_vf_advsimd_sleef(y), y), vgt_vo_vf_vf_advsimd_sleef(vabs_vf_vf_advsimd_sleef(y), vcast_vf_f_advsimd_sleef(1 << 24))); + vopmask_advsimd_sleef yisodd = vand_vo_vo_vo_advsimd_sleef(vand_vo_vo_vo_advsimd_sleef(veq_vo_vi2_vi2_advsimd_sleef(vand_vi2_vi2_vi2_advsimd_sleef(vtruncate_vi2_vf_advsimd_sleef(y), vcast_vi2_i_advsimd_sleef(1)), vcast_vi2_i_advsimd_sleef(1)), yisint), + vlt_vo_vf_vf_advsimd_sleef(vabs_vf_vf_advsimd_sleef(y), vcast_vf_f_advsimd_sleef(1 << 24))); + + result = vsel_vf_vo_vf_vf_advsimd_sleef(vand_vo_vo_vo_advsimd_sleef(vsignbit_vo_vf_advsimd_sleef(x), yisodd), vneg_vf_vf_advsimd_sleef(result), result); + + result = vsel_vf_vo_vf_vf_advsimd_sleef(veq_vo_vf_vf_advsimd_sleef(x, vcast_vf_f_advsimd_sleef(0)), vcast_vf_f_advsimd_sleef(0), result); + result = vsel_vf_vo_vf_vf_advsimd_sleef(veq_vo_vf_vf_advsimd_sleef(y, vcast_vf_f_advsimd_sleef(0)), vcast_vf_f_advsimd_sleef(1), result); + + return result; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_advsimd_sleef expk2f_advsimd_sleef(vfloat2_advsimd_sleef d) { + vfloat_advsimd_sleef u = vmul_vf_vf_vf_advsimd_sleef(vadd_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(d), vf2gety_vf_vf2_advsimd_sleef(d)), vcast_vf_f_advsimd_sleef(1.442695040888963407359924681001892137426645954152985934135449406931f)); + vint2_advsimd_sleef q = vrint_vi2_vf_advsimd_sleef(u); + vfloat2_advsimd_sleef s, t; + + s = dfadd2_vf2_vf2_vf_advsimd_sleef(d, vmul_vf_vf_vf_advsimd_sleef(vcast_vf_vi2_advsimd_sleef(q), vcast_vf_f_advsimd_sleef(-0.693145751953125f))); + s = dfadd2_vf2_vf2_vf_advsimd_sleef(s, vmul_vf_vf_vf_advsimd_sleef(vcast_vf_vi2_advsimd_sleef(q), vcast_vf_f_advsimd_sleef(-1.428606765330187045e-06f))); + + u = vcast_vf_f_advsimd_sleef(+0.1980960224e-3f); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, vf2getx_vf_vf2_advsimd_sleef(s), vcast_vf_f_advsimd_sleef(+0.1394256484e-2f)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, vf2getx_vf_vf2_advsimd_sleef(s), vcast_vf_f_advsimd_sleef(+0.8333456703e-2f)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, vf2getx_vf_vf2_advsimd_sleef(s), vcast_vf_f_advsimd_sleef(+0.4166637361e-1f)); + + t = dfadd2_vf2_vf2_vf_advsimd_sleef(dfmul_vf2_vf2_vf_advsimd_sleef(s, u), vcast_vf_f_advsimd_sleef(+0.166666659414234244790680580464e+0f)); + t = dfadd2_vf2_vf2_vf_advsimd_sleef(dfmul_vf2_vf2_vf2_advsimd_sleef(s, t), vcast_vf_f_advsimd_sleef(0.5)); + t = dfadd2_vf2_vf2_vf2_advsimd_sleef(s, dfmul_vf2_vf2_vf2_advsimd_sleef(dfsqu_vf2_vf2_advsimd_sleef(s), t)); + + t = dfadd_vf2_vf_vf2_advsimd_sleef(vcast_vf_f_advsimd_sleef(1), t); + + t = vf2setx_vf2_vf2_vf_advsimd_sleef(t, vldexp2_vf_vf_vi2_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(t), q)); + t = vf2sety_vf2_vf2_vf_advsimd_sleef(t, vldexp2_vf_vf_vi2_advsimd_sleef(vf2gety_vf_vf2_advsimd_sleef(t), q)); + + t = vf2setx_vf2_vf2_vf_advsimd_sleef(t, vreinterpret_vf_vm_advsimd_sleef(vandnot_vm_vo32_vm_advsimd_sleef(vlt_vo_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(d), vcast_vf_f_advsimd_sleef(-104)), vreinterpret_vm_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(t))))); + t = vf2sety_vf2_vf2_vf_advsimd_sleef(t, vreinterpret_vf_vm_advsimd_sleef(vandnot_vm_vo32_vm_advsimd_sleef(vlt_vo_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(d), vcast_vf_f_advsimd_sleef(-104)), vreinterpret_vm_vf_advsimd_sleef(vf2gety_vf_vf2_advsimd_sleef(t))))); + + return t; +} + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_sinhf4_u10advsimd(vfloat_advsimd_sleef x) { + vfloat_advsimd_sleef y = vabs_vf_vf_advsimd_sleef(x); + vfloat2_advsimd_sleef d = expk2f_advsimd_sleef(vcast_vf2_vf_vf_advsimd_sleef(y, vcast_vf_f_advsimd_sleef(0))); + d = dfsub_vf2_vf2_vf2_advsimd_sleef(d, dfrec_vf2_vf2_advsimd_sleef(d)); + y = vmul_vf_vf_vf_advsimd_sleef(vadd_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(d), vf2gety_vf_vf2_advsimd_sleef(d)), vcast_vf_f_advsimd_sleef(0.5)); + + y = vsel_vf_vo_vf_vf_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(vgt_vo_vf_vf_advsimd_sleef(vabs_vf_vf_advsimd_sleef(x), vcast_vf_f_advsimd_sleef(89)), + visnan_vo_vf_advsimd_sleef(y)), vcast_vf_f_advsimd_sleef(__builtin_inff()), y); + y = vmulsign_vf_vf_vf_advsimd_sleef(y, x); + y = vreinterpret_vf_vm_advsimd_sleef(vor_vm_vo32_vm_advsimd_sleef(visnan_vo_vf_advsimd_sleef(x), vreinterpret_vm_vf_advsimd_sleef(y))); + + return y; +} + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_coshf4_u10advsimd(vfloat_advsimd_sleef x) { + vfloat_advsimd_sleef y = vabs_vf_vf_advsimd_sleef(x); + vfloat2_advsimd_sleef d = expk2f_advsimd_sleef(vcast_vf2_vf_vf_advsimd_sleef(y, vcast_vf_f_advsimd_sleef(0))); + d = dfadd_vf2_vf2_vf2_advsimd_sleef(d, dfrec_vf2_vf2_advsimd_sleef(d)); + y = vmul_vf_vf_vf_advsimd_sleef(vadd_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(d), vf2gety_vf_vf2_advsimd_sleef(d)), vcast_vf_f_advsimd_sleef(0.5)); + + y = vsel_vf_vo_vf_vf_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(vgt_vo_vf_vf_advsimd_sleef(vabs_vf_vf_advsimd_sleef(x), vcast_vf_f_advsimd_sleef(89)), + visnan_vo_vf_advsimd_sleef(y)), vcast_vf_f_advsimd_sleef(__builtin_inff()), y); + y = vreinterpret_vf_vm_advsimd_sleef(vor_vm_vo32_vm_advsimd_sleef(visnan_vo_vf_advsimd_sleef(x), vreinterpret_vm_vf_advsimd_sleef(y))); + + return y; +} + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_tanhf4_u10advsimd(vfloat_advsimd_sleef x) { + vfloat_advsimd_sleef y = vabs_vf_vf_advsimd_sleef(x); + vfloat2_advsimd_sleef d = expk2f_advsimd_sleef(vcast_vf2_vf_vf_advsimd_sleef(y, vcast_vf_f_advsimd_sleef(0))); + vfloat2_advsimd_sleef e = dfrec_vf2_vf2_advsimd_sleef(d); + d = dfdiv_vf2_vf2_vf2_advsimd_sleef(dfadd_vf2_vf2_vf2_advsimd_sleef(d, dfneg_vf2_vf2_advsimd_sleef(e)), dfadd_vf2_vf2_vf2_advsimd_sleef(d, e)); + y = vadd_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(d), vf2gety_vf_vf2_advsimd_sleef(d)); + + y = vsel_vf_vo_vf_vf_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(vgt_vo_vf_vf_advsimd_sleef(vabs_vf_vf_advsimd_sleef(x), vcast_vf_f_advsimd_sleef(8.664339742f)), + visnan_vo_vf_advsimd_sleef(y)), vcast_vf_f_advsimd_sleef(1.0f), y); + y = vmulsign_vf_vf_vf_advsimd_sleef(y, x); + y = vreinterpret_vf_vm_advsimd_sleef(vor_vm_vo32_vm_advsimd_sleef(visnan_vo_vf_advsimd_sleef(x), vreinterpret_vm_vf_advsimd_sleef(y))); + + return y; +} + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_sinhf4_u35advsimd(vfloat_advsimd_sleef x) { + vfloat_advsimd_sleef e = expm1fk_advsimd_sleef(vabs_vf_vf_advsimd_sleef(x)); + vfloat_advsimd_sleef y = vdiv_vf_vf_vf_advsimd_sleef(vadd_vf_vf_vf_advsimd_sleef(e, vcast_vf_f_advsimd_sleef(2)), vadd_vf_vf_vf_advsimd_sleef(e, vcast_vf_f_advsimd_sleef(1))); + y = vmul_vf_vf_vf_advsimd_sleef(y, vmul_vf_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(0.5f), e)); + + y = vsel_vf_vo_vf_vf_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(vgt_vo_vf_vf_advsimd_sleef(vabs_vf_vf_advsimd_sleef(x), vcast_vf_f_advsimd_sleef(88)), + visnan_vo_vf_advsimd_sleef(y)), vcast_vf_f_advsimd_sleef(__builtin_inff()), y); + y = vmulsign_vf_vf_vf_advsimd_sleef(y, x); + y = vreinterpret_vf_vm_advsimd_sleef(vor_vm_vo32_vm_advsimd_sleef(visnan_vo_vf_advsimd_sleef(x), vreinterpret_vm_vf_advsimd_sleef(y))); + + return y; +} + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_coshf4_u35advsimd(vfloat_advsimd_sleef x) { + vfloat_advsimd_sleef e = Sleef_expf4_u10advsimd(vabs_vf_vf_advsimd_sleef(x)); + vfloat_advsimd_sleef y = vmla_vf_vf_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(0.5f), e, vdiv_vf_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(0.5), e)); + + y = vsel_vf_vo_vf_vf_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(vgt_vo_vf_vf_advsimd_sleef(vabs_vf_vf_advsimd_sleef(x), vcast_vf_f_advsimd_sleef(88)), + visnan_vo_vf_advsimd_sleef(y)), vcast_vf_f_advsimd_sleef(__builtin_inff()), y); + y = vreinterpret_vf_vm_advsimd_sleef(vor_vm_vo32_vm_advsimd_sleef(visnan_vo_vf_advsimd_sleef(x), vreinterpret_vm_vf_advsimd_sleef(y))); + + return y; +} + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_tanhf4_u35advsimd(vfloat_advsimd_sleef x) { + vfloat_advsimd_sleef d = expm1fk_advsimd_sleef(vmul_vf_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(2), vabs_vf_vf_advsimd_sleef(x))); + vfloat_advsimd_sleef y = vdiv_vf_vf_vf_advsimd_sleef(d, vadd_vf_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(2), d)); + + y = vsel_vf_vo_vf_vf_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(vgt_vo_vf_vf_advsimd_sleef(vabs_vf_vf_advsimd_sleef(x), vcast_vf_f_advsimd_sleef(8.664339742f)), + visnan_vo_vf_advsimd_sleef(y)), vcast_vf_f_advsimd_sleef(1.0f), y); + y = vmulsign_vf_vf_vf_advsimd_sleef(y, x); + y = vreinterpret_vf_vm_advsimd_sleef(vor_vm_vo32_vm_advsimd_sleef(visnan_vo_vf_advsimd_sleef(x), vreinterpret_vm_vf_advsimd_sleef(y))); + + return y; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_advsimd_sleef logk2f_advsimd_sleef(vfloat2_advsimd_sleef d) { + vfloat2_advsimd_sleef x, x2, m, s; + vfloat_advsimd_sleef t; + vint2_advsimd_sleef e; + + e = vilogbk_vi2_vf_advsimd_sleef(vmul_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(d), vcast_vf_f_advsimd_sleef(1.0f/0.75f))); + + m = dfscale_vf2_vf2_vf_advsimd_sleef(d, vpow2i_vf_vi2_advsimd_sleef(vneg_vi2_vi2_advsimd_sleef(e))); + + x = dfdiv_vf2_vf2_vf2_advsimd_sleef(dfadd2_vf2_vf2_vf_advsimd_sleef(m, vcast_vf_f_advsimd_sleef(-1)), dfadd2_vf2_vf2_vf_advsimd_sleef(m, vcast_vf_f_advsimd_sleef(1))); + x2 = dfsqu_vf2_vf2_advsimd_sleef(x); + + t = vcast_vf_f_advsimd_sleef(0.2392828464508056640625f); + t = vmla_vf_vf_vf_vf_advsimd_sleef(t, vf2getx_vf_vf2_advsimd_sleef(x2), vcast_vf_f_advsimd_sleef(0.28518211841583251953125f)); + t = vmla_vf_vf_vf_vf_advsimd_sleef(t, vf2getx_vf_vf2_advsimd_sleef(x2), vcast_vf_f_advsimd_sleef(0.400005877017974853515625f)); + t = vmla_vf_vf_vf_vf_advsimd_sleef(t, vf2getx_vf_vf2_advsimd_sleef(x2), vcast_vf_f_advsimd_sleef(0.666666686534881591796875f)); + + s = dfmul_vf2_vf2_vf_advsimd_sleef(vcast_vf2_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(0.69314718246459960938f), vcast_vf_f_advsimd_sleef(-1.904654323148236017e-09f)), vcast_vf_vi2_advsimd_sleef(e)); + s = dfadd_vf2_vf2_vf2_advsimd_sleef(s, dfscale_vf2_vf2_vf_advsimd_sleef(x, vcast_vf_f_advsimd_sleef(2))); + s = dfadd_vf2_vf2_vf2_advsimd_sleef(s, dfmul_vf2_vf2_vf_advsimd_sleef(dfmul_vf2_vf2_vf2_advsimd_sleef(x2, x), t)); + + return s; +} + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_asinhf4_u10advsimd(vfloat_advsimd_sleef x) { + vfloat_advsimd_sleef y = vabs_vf_vf_advsimd_sleef(x); + vopmask_advsimd_sleef o = vgt_vo_vf_vf_advsimd_sleef(y, vcast_vf_f_advsimd_sleef(1)); + vfloat2_advsimd_sleef d; + + d = vsel_vf2_vo_vf2_vf2_advsimd_sleef(o, dfrec_vf2_vf_advsimd_sleef(x), vcast_vf2_vf_vf_advsimd_sleef(y, vcast_vf_f_advsimd_sleef(0))); + d = dfsqrt_vf2_vf2_advsimd_sleef(dfadd2_vf2_vf2_vf_advsimd_sleef(dfsqu_vf2_vf2_advsimd_sleef(d), vcast_vf_f_advsimd_sleef(1))); + d = vsel_vf2_vo_vf2_vf2_advsimd_sleef(o, dfmul_vf2_vf2_vf_advsimd_sleef(d, y), d); + + d = logk2f_advsimd_sleef(dfnormalize_vf2_vf2_advsimd_sleef(dfadd2_vf2_vf2_vf_advsimd_sleef(d, x))); + y = vadd_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(d), vf2gety_vf_vf2_advsimd_sleef(d)); + + y = vsel_vf_vo_vf_vf_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(vgt_vo_vf_vf_advsimd_sleef(vabs_vf_vf_advsimd_sleef(x), vcast_vf_f_advsimd_sleef(18446743523953729536.0)), + visnan_vo_vf_advsimd_sleef(y)), + vmulsign_vf_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(__builtin_inff()), x), y); + y = vreinterpret_vf_vm_advsimd_sleef(vor_vm_vo32_vm_advsimd_sleef(visnan_vo_vf_advsimd_sleef(x), vreinterpret_vm_vf_advsimd_sleef(y))); + y = vsel_vf_vo_vf_vf_advsimd_sleef(visnegzero_vo_vf_advsimd_sleef(x), vcast_vf_f_advsimd_sleef(-0.0), y); + + return y; +} + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_acoshf4_u10advsimd(vfloat_advsimd_sleef x) { + vfloat2_advsimd_sleef d = logk2f_advsimd_sleef(dfadd2_vf2_vf2_vf_advsimd_sleef(dfmul_vf2_vf2_vf2_advsimd_sleef(dfsqrt_vf2_vf2_advsimd_sleef(dfadd2_vf2_vf_vf_advsimd_sleef(x, vcast_vf_f_advsimd_sleef(1))), dfsqrt_vf2_vf2_advsimd_sleef(dfadd2_vf2_vf_vf_advsimd_sleef(x, vcast_vf_f_advsimd_sleef(-1)))), x)); + vfloat_advsimd_sleef y = vadd_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(d), vf2gety_vf_vf2_advsimd_sleef(d)); + + y = vsel_vf_vo_vf_vf_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(vgt_vo_vf_vf_advsimd_sleef(vabs_vf_vf_advsimd_sleef(x), vcast_vf_f_advsimd_sleef(18446743523953729536.0)), + visnan_vo_vf_advsimd_sleef(y)), + vcast_vf_f_advsimd_sleef(__builtin_inff()), y); + + y = vreinterpret_vf_vm_advsimd_sleef(vandnot_vm_vo32_vm_advsimd_sleef(veq_vo_vf_vf_advsimd_sleef(x, vcast_vf_f_advsimd_sleef(1.0f)), vreinterpret_vm_vf_advsimd_sleef(y))); + + y = vreinterpret_vf_vm_advsimd_sleef(vor_vm_vo32_vm_advsimd_sleef(vlt_vo_vf_vf_advsimd_sleef(x, vcast_vf_f_advsimd_sleef(1.0f)), vreinterpret_vm_vf_advsimd_sleef(y))); + y = vreinterpret_vf_vm_advsimd_sleef(vor_vm_vo32_vm_advsimd_sleef(visnan_vo_vf_advsimd_sleef(x), vreinterpret_vm_vf_advsimd_sleef(y))); + + return y; +} + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_atanhf4_u10advsimd(vfloat_advsimd_sleef x) { + vfloat_advsimd_sleef y = vabs_vf_vf_advsimd_sleef(x); + vfloat2_advsimd_sleef d = logk2f_advsimd_sleef(dfdiv_vf2_vf2_vf2_advsimd_sleef(dfadd2_vf2_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(1), y), dfadd2_vf2_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(1), vneg_vf_vf_advsimd_sleef(y)))); + y = vreinterpret_vf_vm_advsimd_sleef(vor_vm_vo32_vm_advsimd_sleef(vgt_vo_vf_vf_advsimd_sleef(y, vcast_vf_f_advsimd_sleef(1.0)), vreinterpret_vm_vf_advsimd_sleef(vsel_vf_vo_vf_vf_advsimd_sleef(veq_vo_vf_vf_advsimd_sleef(y, vcast_vf_f_advsimd_sleef(1.0)), vcast_vf_f_advsimd_sleef(__builtin_inff()), vmul_vf_vf_vf_advsimd_sleef(vadd_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(d), vf2gety_vf_vf2_advsimd_sleef(d)), vcast_vf_f_advsimd_sleef(0.5)))))); + + y = vreinterpret_vf_vm_advsimd_sleef(vor_vm_vo32_vm_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(visinf_vo_vf_advsimd_sleef(x), visnan_vo_vf_advsimd_sleef(y)), vreinterpret_vm_vf_advsimd_sleef(y))); + y = vmulsign_vf_vf_vf_advsimd_sleef(y, x); + y = vreinterpret_vf_vm_advsimd_sleef(vor_vm_vo32_vm_advsimd_sleef(visnan_vo_vf_advsimd_sleef(x), vreinterpret_vm_vf_advsimd_sleef(y))); + + return y; +} + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_exp2f4_u10advsimd(vfloat_advsimd_sleef d) { + vfloat_advsimd_sleef u = vrint_vf_vf_advsimd_sleef(d), s; + vint2_advsimd_sleef q = vrint_vi2_vf_advsimd_sleef(u); + + s = vsub_vf_vf_vf_advsimd_sleef(d, u); + + u = vcast_vf_f_advsimd_sleef(+0.1535920892e-3); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, s, vcast_vf_f_advsimd_sleef(+0.1339262701e-2)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, s, vcast_vf_f_advsimd_sleef(+0.9618384764e-2)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, s, vcast_vf_f_advsimd_sleef(+0.5550347269e-1)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, s, vcast_vf_f_advsimd_sleef(+0.2402264476e+0)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, s, vcast_vf_f_advsimd_sleef(+0.6931471825e+0)); + + u = vfma_vf_vf_vf_vf_advsimd_sleef(u, s, vcast_vf_f_advsimd_sleef(1)); + + u = vldexp2_vf_vf_vi2_advsimd_sleef(u, q); + + u = vsel_vf_vo_vf_vf_advsimd_sleef(vge_vo_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(128)), vcast_vf_f_advsimd_sleef(__builtin_inf()), u); + u = vreinterpret_vf_vm_advsimd_sleef(vandnot_vm_vo32_vm_advsimd_sleef(vlt_vo_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(-150)), vreinterpret_vm_vf_advsimd_sleef(u))); + + return u; +} + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_exp2f4_u35advsimd(vfloat_advsimd_sleef d) { + vfloat_advsimd_sleef u = vrint_vf_vf_advsimd_sleef(d), s; + vint2_advsimd_sleef q = vrint_vi2_vf_advsimd_sleef(u); + + s = vsub_vf_vf_vf_advsimd_sleef(d, u); + + u = vcast_vf_f_advsimd_sleef(+0.1535920892e-3); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, s, vcast_vf_f_advsimd_sleef(+0.1339262701e-2)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, s, vcast_vf_f_advsimd_sleef(+0.9618384764e-2)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, s, vcast_vf_f_advsimd_sleef(+0.5550347269e-1)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, s, vcast_vf_f_advsimd_sleef(+0.2402264476e+0)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, s, vcast_vf_f_advsimd_sleef(+0.6931471825e+0)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, s, vcast_vf_f_advsimd_sleef(+0.1000000000e+1)); + + u = vldexp2_vf_vf_vi2_advsimd_sleef(u, q); + + u = vsel_vf_vo_vf_vf_advsimd_sleef(vge_vo_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(128)), vcast_vf_f_advsimd_sleef(__builtin_inf()), u); + u = vreinterpret_vf_vm_advsimd_sleef(vandnot_vm_vo32_vm_advsimd_sleef(vlt_vo_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(-150)), vreinterpret_vm_vf_advsimd_sleef(u))); + + return u; +} + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_exp10f4_u10advsimd(vfloat_advsimd_sleef d) { + vfloat_advsimd_sleef u = vrint_vf_vf_advsimd_sleef(vmul_vf_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(3.3219280948873623478703194294893901758648313930))), s; + vint2_advsimd_sleef q = vrint_vi2_vf_advsimd_sleef(u); + + s = vmla_vf_vf_vf_vf_advsimd_sleef(u, vcast_vf_f_advsimd_sleef(-0.3010253906f), d); + s = vmla_vf_vf_vf_vf_advsimd_sleef(u, vcast_vf_f_advsimd_sleef(-4.605038981e-06f), s); + + u = vcast_vf_f_advsimd_sleef(+0.6802555919e-1); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, s, vcast_vf_f_advsimd_sleef(+0.2078080326e+0)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, s, vcast_vf_f_advsimd_sleef(+0.5393903852e+0)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, s, vcast_vf_f_advsimd_sleef(+0.1171245337e+1)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, s, vcast_vf_f_advsimd_sleef(+0.2034678698e+1)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, s, vcast_vf_f_advsimd_sleef(+0.2650949001e+1)); + vfloat2_advsimd_sleef x = dfadd_vf2_vf2_vf_advsimd_sleef(vcast_vf2_f_f_advsimd_sleef(2.3025851249694824219, -3.1705172516493593157e-08), vmul_vf_vf_vf_advsimd_sleef(u, s)); + u = vf2getx_vf_vf2_advsimd_sleef(dfnormalize_vf2_vf2_advsimd_sleef(dfadd_vf2_vf_vf2_advsimd_sleef(vcast_vf_f_advsimd_sleef(1), dfmul_vf2_vf2_vf_advsimd_sleef(x, s)))); + + u = vldexp2_vf_vf_vi2_advsimd_sleef(u, q); + + u = vsel_vf_vo_vf_vf_advsimd_sleef(vgt_vo_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(38.5318394191036238941387f)), vcast_vf_f_advsimd_sleef(__builtin_inff()), u); + u = vreinterpret_vf_vm_advsimd_sleef(vandnot_vm_vo32_vm_advsimd_sleef(vlt_vo_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(-50)), vreinterpret_vm_vf_advsimd_sleef(u))); + + return u; +} + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_exp10f4_u35advsimd(vfloat_advsimd_sleef d) { + vfloat_advsimd_sleef u = vrint_vf_vf_advsimd_sleef(vmul_vf_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(3.3219280948873623478703194294893901758648313930))), s; + vint2_advsimd_sleef q = vrint_vi2_vf_advsimd_sleef(u); + + s = vmla_vf_vf_vf_vf_advsimd_sleef(u, vcast_vf_f_advsimd_sleef(-0.3010253906f), d); + s = vmla_vf_vf_vf_vf_advsimd_sleef(u, vcast_vf_f_advsimd_sleef(-4.605038981e-06f), s); + + u = vcast_vf_f_advsimd_sleef(+0.2064004987e+0); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, s, vcast_vf_f_advsimd_sleef(+0.5417877436e+0)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, s, vcast_vf_f_advsimd_sleef(+0.1171286821e+1)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, s, vcast_vf_f_advsimd_sleef(+0.2034656048e+1)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, s, vcast_vf_f_advsimd_sleef(+0.2650948763e+1)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, s, vcast_vf_f_advsimd_sleef(+0.2302585125e+1)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, s, vcast_vf_f_advsimd_sleef(+0.1000000000e+1)); + + u = vldexp2_vf_vf_vi2_advsimd_sleef(u, q); + + u = vsel_vf_vo_vf_vf_advsimd_sleef(vgt_vo_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(38.5318394191036238941387f)), vcast_vf_f_advsimd_sleef(__builtin_inff()), u); + u = vreinterpret_vf_vm_advsimd_sleef(vandnot_vm_vo32_vm_advsimd_sleef(vlt_vo_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(-50)), vreinterpret_vm_vf_advsimd_sleef(u))); + + return u; +} + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_expm1f4_u10advsimd(vfloat_advsimd_sleef a) { + vfloat2_advsimd_sleef d = dfadd2_vf2_vf2_vf_advsimd_sleef(expk2f_advsimd_sleef(vcast_vf2_vf_vf_advsimd_sleef(a, vcast_vf_f_advsimd_sleef(0))), vcast_vf_f_advsimd_sleef(-1.0)); + vfloat_advsimd_sleef x = vadd_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(d), vf2gety_vf_vf2_advsimd_sleef(d)); + x = vsel_vf_vo_vf_vf_advsimd_sleef(vgt_vo_vf_vf_advsimd_sleef(a, vcast_vf_f_advsimd_sleef(88.72283172607421875f)), vcast_vf_f_advsimd_sleef(__builtin_inff()), x); + x = vsel_vf_vo_vf_vf_advsimd_sleef(vlt_vo_vf_vf_advsimd_sleef(a, vcast_vf_f_advsimd_sleef(-16.635532333438687426013570f)), vcast_vf_f_advsimd_sleef(-1), x); + x = vsel_vf_vo_vf_vf_advsimd_sleef(visnegzero_vo_vf_advsimd_sleef(a), vcast_vf_f_advsimd_sleef(-0.0f), x); + return x; +} + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_log10f4_u10advsimd(vfloat_advsimd_sleef d) { + vfloat2_advsimd_sleef x; + vfloat_advsimd_sleef t, m, x2; + + vopmask_advsimd_sleef o = vlt_vo_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(0x1p-126)); + d = vsel_vf_vo_vf_vf_advsimd_sleef(o, vmul_vf_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef((float)(INT64_C(1) << 32) * (float)(INT64_C(1) << 32))), d); + vint2_advsimd_sleef e = vilogb2k_vi2_vf_advsimd_sleef(vmul_vf_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(1.0/0.75))); + m = vldexp3_vf_vf_vi2_advsimd_sleef(d, vneg_vi2_vi2_advsimd_sleef(e)); + e = vsel_vi2_vo_vi2_vi2_advsimd_sleef(o, vsub_vi2_vi2_vi2_advsimd_sleef(e, vcast_vi2_i_advsimd_sleef(64)), e); + + x = dfdiv_vf2_vf2_vf2_advsimd_sleef(dfadd2_vf2_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(-1), m), dfadd2_vf2_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(1), m)); + x2 = vmul_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(x), vf2getx_vf_vf2_advsimd_sleef(x)); + + t = vcast_vf_f_advsimd_sleef(+0.1314289868e+0); + t = vmla_vf_vf_vf_vf_advsimd_sleef(t, x2, vcast_vf_f_advsimd_sleef( +0.1735493541e+0)); + t = vmla_vf_vf_vf_vf_advsimd_sleef(t, x2, vcast_vf_f_advsimd_sleef( +0.2895309627e+0)); + + vfloat2_advsimd_sleef s = dfmul_vf2_vf2_vf_advsimd_sleef(vcast_vf2_f_f_advsimd_sleef(0.30103001, -1.432098889e-08), vcast_vf_vi2_advsimd_sleef(e)); + + s = dfadd_vf2_vf2_vf2_advsimd_sleef(s, dfmul_vf2_vf2_vf2_advsimd_sleef(x, vcast_vf2_f_f_advsimd_sleef(0.868588984, -2.170757285e-08))); + s = dfadd_vf2_vf2_vf_advsimd_sleef(s, vmul_vf_vf_vf_advsimd_sleef(vmul_vf_vf_vf_advsimd_sleef(x2, vf2getx_vf_vf2_advsimd_sleef(x)), t)); + + vfloat_advsimd_sleef r = vadd_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(s), vf2gety_vf_vf2_advsimd_sleef(s)); + + r = vsel_vf_vo_vf_vf_advsimd_sleef(vispinf_vo_vf_advsimd_sleef(d), vcast_vf_f_advsimd_sleef(__builtin_inf()), r); + r = vsel_vf_vo_vf_vf_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(vlt_vo_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(0)), visnan_vo_vf_advsimd_sleef(d)), vcast_vf_f_advsimd_sleef(__builtin_nan("")), r); + r = vsel_vf_vo_vf_vf_advsimd_sleef(veq_vo_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(0)), vcast_vf_f_advsimd_sleef(-__builtin_inf()), r); + + return r; +} + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_log2f4_u10advsimd(vfloat_advsimd_sleef d) { + vfloat2_advsimd_sleef x; + vfloat_advsimd_sleef t, m, x2; + + vopmask_advsimd_sleef o = vlt_vo_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(0x1p-126)); + d = vsel_vf_vo_vf_vf_advsimd_sleef(o, vmul_vf_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef((float)(INT64_C(1) << 32) * (float)(INT64_C(1) << 32))), d); + vint2_advsimd_sleef e = vilogb2k_vi2_vf_advsimd_sleef(vmul_vf_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(1.0/0.75))); + m = vldexp3_vf_vf_vi2_advsimd_sleef(d, vneg_vi2_vi2_advsimd_sleef(e)); + e = vsel_vi2_vo_vi2_vi2_advsimd_sleef(o, vsub_vi2_vi2_vi2_advsimd_sleef(e, vcast_vi2_i_advsimd_sleef(64)), e); + + x = dfdiv_vf2_vf2_vf2_advsimd_sleef(dfadd2_vf2_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(-1), m), dfadd2_vf2_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(1), m)); + x2 = vmul_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(x), vf2getx_vf_vf2_advsimd_sleef(x)); + + t = vcast_vf_f_advsimd_sleef(+0.4374550283e+0f); + t = vmla_vf_vf_vf_vf_advsimd_sleef(t, x2, vcast_vf_f_advsimd_sleef(+0.5764790177e+0f)); + t = vmla_vf_vf_vf_vf_advsimd_sleef(t, x2, vcast_vf_f_advsimd_sleef(+0.9618012905120f)); + + vfloat2_advsimd_sleef s = dfadd2_vf2_vf_vf2_advsimd_sleef(vcast_vf_vi2_advsimd_sleef(e), + dfmul_vf2_vf2_vf2_advsimd_sleef(x, vcast_vf2_f_f_advsimd_sleef(2.8853900432586669922, 3.2734474483568488616e-08))); + + s = dfadd2_vf2_vf2_vf_advsimd_sleef(s, vmul_vf_vf_vf_advsimd_sleef(vmul_vf_vf_vf_advsimd_sleef(x2, vf2getx_vf_vf2_advsimd_sleef(x)), t)); + + vfloat_advsimd_sleef r = vadd_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(s), vf2gety_vf_vf2_advsimd_sleef(s)); + + r = vsel_vf_vo_vf_vf_advsimd_sleef(vispinf_vo_vf_advsimd_sleef(d), vcast_vf_f_advsimd_sleef(__builtin_inf()), r); + r = vsel_vf_vo_vf_vf_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(vlt_vo_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(0)), visnan_vo_vf_advsimd_sleef(d)), vcast_vf_f_advsimd_sleef(__builtin_nan("")), r); + r = vsel_vf_vo_vf_vf_advsimd_sleef(veq_vo_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(0)), vcast_vf_f_advsimd_sleef(-__builtin_inf()), r); + + return r; +} + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_log2f4_u35advsimd(vfloat_advsimd_sleef d) { + vfloat_advsimd_sleef m, t, x, x2; + + vopmask_advsimd_sleef o = vlt_vo_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(0x1p-126)); + d = vsel_vf_vo_vf_vf_advsimd_sleef(o, vmul_vf_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef((float)(INT64_C(1) << 32) * (float)(INT64_C(1) << 32))), d); + vint2_advsimd_sleef e = vilogb2k_vi2_vf_advsimd_sleef(vmul_vf_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(1.0/0.75))); + m = vldexp3_vf_vf_vi2_advsimd_sleef(d, vneg_vi2_vi2_advsimd_sleef(e)); + e = vsel_vi2_vo_vi2_vi2_advsimd_sleef(o, vsub_vi2_vi2_vi2_advsimd_sleef(e, vcast_vi2_i_advsimd_sleef(64)), e); + + x = vdiv_vf_vf_vf_advsimd_sleef(vsub_vf_vf_vf_advsimd_sleef(m, vcast_vf_f_advsimd_sleef(1)), vadd_vf_vf_vf_advsimd_sleef(m, vcast_vf_f_advsimd_sleef(1))); + x2 = vmul_vf_vf_vf_advsimd_sleef(x, x); + + t = vcast_vf_f_advsimd_sleef(+0.4374088347e+0); + t = vmla_vf_vf_vf_vf_advsimd_sleef(t, x2, vcast_vf_f_advsimd_sleef(+0.5764843822e+0)); + t = vmla_vf_vf_vf_vf_advsimd_sleef(t, x2, vcast_vf_f_advsimd_sleef(+0.9618024230e+0)); + + vfloat_advsimd_sleef r = vmla_vf_vf_vf_vf_advsimd_sleef(vmul_vf_vf_vf_advsimd_sleef(x2, x), t, + vmla_vf_vf_vf_vf_advsimd_sleef(x, vcast_vf_f_advsimd_sleef(+0.2885390043e+1), vcast_vf_vi2_advsimd_sleef(e))); + + r = vsel_vf_vo_vf_vf_advsimd_sleef(vispinf_vo_vf_advsimd_sleef(d), vcast_vf_f_advsimd_sleef(__builtin_inf()), r); + r = vsel_vf_vo_vf_vf_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(vlt_vo_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(0)), visnan_vo_vf_advsimd_sleef(d)), vcast_vf_f_advsimd_sleef(__builtin_nan("")), r); + r = vsel_vf_vo_vf_vf_advsimd_sleef(veq_vo_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(0)), vcast_vf_f_advsimd_sleef(-__builtin_inf()), r); + + return r; +} + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_log1pf4_u10advsimd(vfloat_advsimd_sleef d) { + vfloat2_advsimd_sleef x; + vfloat_advsimd_sleef t, m, x2; + + vfloat_advsimd_sleef dp1 = vadd_vf_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(1)); + + vopmask_advsimd_sleef o = vlt_vo_vf_vf_advsimd_sleef(dp1, vcast_vf_f_advsimd_sleef(0x1p-126)); + dp1 = vsel_vf_vo_vf_vf_advsimd_sleef(o, vmul_vf_vf_vf_advsimd_sleef(dp1, vcast_vf_f_advsimd_sleef((float)(INT64_C(1) << 32) * (float)(INT64_C(1) << 32))), dp1); + vint2_advsimd_sleef e = vilogb2k_vi2_vf_advsimd_sleef(vmul_vf_vf_vf_advsimd_sleef(dp1, vcast_vf_f_advsimd_sleef(1.0f/0.75f))); + t = vldexp3_vf_vf_vi2_advsimd_sleef(vcast_vf_f_advsimd_sleef(1), vneg_vi2_vi2_advsimd_sleef(e)); + m = vmla_vf_vf_vf_vf_advsimd_sleef(d, t, vsub_vf_vf_vf_advsimd_sleef(t, vcast_vf_f_advsimd_sleef(1))); + e = vsel_vi2_vo_vi2_vi2_advsimd_sleef(o, vsub_vi2_vi2_vi2_advsimd_sleef(e, vcast_vi2_i_advsimd_sleef(64)), e); + vfloat2_advsimd_sleef s = dfmul_vf2_vf2_vf_advsimd_sleef(vcast_vf2_f_f_advsimd_sleef(0.69314718246459960938f, -1.904654323148236017e-09f), vcast_vf_vi2_advsimd_sleef(e)); + + x = dfdiv_vf2_vf2_vf2_advsimd_sleef(vcast_vf2_vf_vf_advsimd_sleef(m, vcast_vf_f_advsimd_sleef(0)), dfadd_vf2_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(2), m)); + x2 = vmul_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(x), vf2getx_vf_vf2_advsimd_sleef(x)); + + t = vcast_vf_f_advsimd_sleef(+0.3027294874e+0f); + t = vmla_vf_vf_vf_vf_advsimd_sleef(t, x2, vcast_vf_f_advsimd_sleef(+0.3996108174e+0f)); + t = vmla_vf_vf_vf_vf_advsimd_sleef(t, x2, vcast_vf_f_advsimd_sleef(+0.6666694880e+0f)); + + s = dfadd_vf2_vf2_vf2_advsimd_sleef(s, dfscale_vf2_vf2_vf_advsimd_sleef(x, vcast_vf_f_advsimd_sleef(2))); + s = dfadd_vf2_vf2_vf_advsimd_sleef(s, vmul_vf_vf_vf_advsimd_sleef(vmul_vf_vf_vf_advsimd_sleef(x2, vf2getx_vf_vf2_advsimd_sleef(x)), t)); + + vfloat_advsimd_sleef r = vadd_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(s), vf2gety_vf_vf2_advsimd_sleef(s)); + + r = vsel_vf_vo_vf_vf_advsimd_sleef(vgt_vo_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(1e+38)), vcast_vf_f_advsimd_sleef(__builtin_inff()), r); + r = vreinterpret_vf_vm_advsimd_sleef(vor_vm_vo32_vm_advsimd_sleef(vgt_vo_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(-1), d), vreinterpret_vm_vf_advsimd_sleef(r))); + r = vsel_vf_vo_vf_vf_advsimd_sleef(veq_vo_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(-1)), vcast_vf_f_advsimd_sleef(-__builtin_inff()), r); + r = vsel_vf_vo_vf_vf_advsimd_sleef(visnegzero_vo_vf_advsimd_sleef(d), vcast_vf_f_advsimd_sleef(-0.0f), r); + + return r; +} + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_fabsf4_advsimd(vfloat_advsimd_sleef x) { return vabs_vf_vf_advsimd_sleef(x); } + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_copysignf4_advsimd(vfloat_advsimd_sleef x, vfloat_advsimd_sleef y) { return vcopysign_vf_vf_vf_advsimd_sleef(x, y); } + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_fmaxf4_advsimd(vfloat_advsimd_sleef x, vfloat_advsimd_sleef y) { + + return vsel_vf_vo_vf_vf_advsimd_sleef(visnan_vo_vf_advsimd_sleef(y), x, vsel_vf_vo_vf_vf_advsimd_sleef(vgt_vo_vf_vf_advsimd_sleef(x, y), x, y)); + +} + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_fminf4_advsimd(vfloat_advsimd_sleef x, vfloat_advsimd_sleef y) { + + return vsel_vf_vo_vf_vf_advsimd_sleef(visnan_vo_vf_advsimd_sleef(y), x, vsel_vf_vo_vf_vf_advsimd_sleef(vgt_vo_vf_vf_advsimd_sleef(y, x), x, y)); + +} + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_fdimf4_advsimd(vfloat_advsimd_sleef x, vfloat_advsimd_sleef y) { + vfloat_advsimd_sleef ret = vsub_vf_vf_vf_advsimd_sleef(x, y); + ret = vsel_vf_vo_vf_vf_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(vlt_vo_vf_vf_advsimd_sleef(ret, vcast_vf_f_advsimd_sleef(0)), veq_vo_vf_vf_advsimd_sleef(x, y)), vcast_vf_f_advsimd_sleef(0), ret); + return ret; +} + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_truncf4_advsimd(vfloat_advsimd_sleef x) { + + return vtruncate_vf_vf_advsimd_sleef(x); + +} + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_floorf4_advsimd(vfloat_advsimd_sleef x) { + vfloat_advsimd_sleef fr = vsub_vf_vf_vf_advsimd_sleef(x, vcast_vf_vi2_advsimd_sleef(vtruncate_vi2_vf_advsimd_sleef(x))); + fr = vsel_vf_vo_vf_vf_advsimd_sleef(vlt_vo_vf_vf_advsimd_sleef(fr, vcast_vf_f_advsimd_sleef(0)), vadd_vf_vf_vf_advsimd_sleef(fr, vcast_vf_f_advsimd_sleef(1.0f)), fr); + return vsel_vf_vo_vf_vf_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(visinf_vo_vf_advsimd_sleef(x), vge_vo_vf_vf_advsimd_sleef(vabs_vf_vf_advsimd_sleef(x), vcast_vf_f_advsimd_sleef(INT64_C(1) << 23))), x, vcopysign_vf_vf_vf_advsimd_sleef(vsub_vf_vf_vf_advsimd_sleef(x, fr), x)); +} + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_ceilf4_advsimd(vfloat_advsimd_sleef x) { + vfloat_advsimd_sleef fr = vsub_vf_vf_vf_advsimd_sleef(x, vcast_vf_vi2_advsimd_sleef(vtruncate_vi2_vf_advsimd_sleef(x))); + fr = vsel_vf_vo_vf_vf_advsimd_sleef(vle_vo_vf_vf_advsimd_sleef(fr, vcast_vf_f_advsimd_sleef(0)), fr, vsub_vf_vf_vf_advsimd_sleef(fr, vcast_vf_f_advsimd_sleef(1.0f))); + return vsel_vf_vo_vf_vf_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(visinf_vo_vf_advsimd_sleef(x), vge_vo_vf_vf_advsimd_sleef(vabs_vf_vf_advsimd_sleef(x), vcast_vf_f_advsimd_sleef(INT64_C(1) << 23))), x, vcopysign_vf_vf_vf_advsimd_sleef(vsub_vf_vf_vf_advsimd_sleef(x, fr), x)); +} + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_roundf4_advsimd(vfloat_advsimd_sleef d) { + vfloat_advsimd_sleef x = vadd_vf_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(0.5f)); + vfloat_advsimd_sleef fr = vsub_vf_vf_vf_advsimd_sleef(x, vcast_vf_vi2_advsimd_sleef(vtruncate_vi2_vf_advsimd_sleef(x))); + x = vsel_vf_vo_vf_vf_advsimd_sleef(vand_vo_vo_vo_advsimd_sleef(vle_vo_vf_vf_advsimd_sleef(x, vcast_vf_f_advsimd_sleef(0)), veq_vo_vf_vf_advsimd_sleef(fr, vcast_vf_f_advsimd_sleef(0))), vsub_vf_vf_vf_advsimd_sleef(x, vcast_vf_f_advsimd_sleef(1.0f)), x); + fr = vsel_vf_vo_vf_vf_advsimd_sleef(vlt_vo_vf_vf_advsimd_sleef(fr, vcast_vf_f_advsimd_sleef(0)), vadd_vf_vf_vf_advsimd_sleef(fr, vcast_vf_f_advsimd_sleef(1.0f)), fr); + x = vsel_vf_vo_vf_vf_advsimd_sleef(veq_vo_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(0.4999999701976776123f)), vcast_vf_f_advsimd_sleef(0), x); + return vsel_vf_vo_vf_vf_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(visinf_vo_vf_advsimd_sleef(d), vge_vo_vf_vf_advsimd_sleef(vabs_vf_vf_advsimd_sleef(d), vcast_vf_f_advsimd_sleef(INT64_C(1) << 23))), d, vcopysign_vf_vf_vf_advsimd_sleef(vsub_vf_vf_vf_advsimd_sleef(x, fr), d)); +} + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_rintf4_advsimd(vfloat_advsimd_sleef d) { + + return vrint_vf_vf_advsimd_sleef(d); + +} + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_fmaf4_advsimd(vfloat_advsimd_sleef x, vfloat_advsimd_sleef y, vfloat_advsimd_sleef z) { + + return vfma_vf_vf_vf_vf_advsimd_sleef(x, y, z); + +} + +SLEEF_INLINE vfloat_advsimd_sleef Sleef_sqrtf4_u05advsimd(vfloat_advsimd_sleef d) { + + vfloat_advsimd_sleef q, w, x, y, z; + + d = vsel_vf_vo_vf_vf_advsimd_sleef(vlt_vo_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(0)), vcast_vf_f_advsimd_sleef(__builtin_nanf("")), d); + + vopmask_advsimd_sleef o = vlt_vo_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(5.2939559203393770e-23f)); + d = vsel_vf_vo_vf_vf_advsimd_sleef(o, vmul_vf_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(1.8889465931478580e+22f)), d); + q = vsel_vf_vo_vf_vf_advsimd_sleef(o, vcast_vf_f_advsimd_sleef(7.2759576141834260e-12f), vcast_vf_f_advsimd_sleef(1.0f)); + + y = vreinterpret_vf_vi2_advsimd_sleef(vsub_vi2_vi2_vi2_advsimd_sleef(vcast_vi2_i_advsimd_sleef(0x5f3759df), vreinterpretq_s32_u32(vshrq_n_u32(vreinterpretq_u32_s32(vreinterpret_vi2_vf_advsimd_sleef(d)), 1)))); + + x = vmul_vf_vf_vf_advsimd_sleef(d, y); w = vmul_vf_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(0.5), y); + y = vfmanp_vf_vf_vf_vf_advsimd_sleef(x, w, vcast_vf_f_advsimd_sleef(0.5)); + x = vfma_vf_vf_vf_vf_advsimd_sleef(x, y, x); w = vfma_vf_vf_vf_vf_advsimd_sleef(w, y, w); + y = vfmanp_vf_vf_vf_vf_advsimd_sleef(x, w, vcast_vf_f_advsimd_sleef(0.5)); + x = vfma_vf_vf_vf_vf_advsimd_sleef(x, y, x); w = vfma_vf_vf_vf_vf_advsimd_sleef(w, y, w); + + y = vfmanp_vf_vf_vf_vf_advsimd_sleef(x, w, vcast_vf_f_advsimd_sleef(1.5)); w = vadd_vf_vf_vf_advsimd_sleef(w, w); + w = vmul_vf_vf_vf_advsimd_sleef(w, y); + x = vmul_vf_vf_vf_advsimd_sleef(w, d); + y = vfmapn_vf_vf_vf_vf_advsimd_sleef(w, d, x); z = vfmanp_vf_vf_vf_vf_advsimd_sleef(w, x, vcast_vf_f_advsimd_sleef(1)); + + z = vfmanp_vf_vf_vf_vf_advsimd_sleef(w, y, z); w = vmul_vf_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(0.5), x); + w = vfma_vf_vf_vf_vf_advsimd_sleef(w, z, y); + w = vadd_vf_vf_vf_advsimd_sleef(w, x); + + w = vmul_vf_vf_vf_advsimd_sleef(w, q); + + w = vsel_vf_vo_vf_vf_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(veq_vo_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(0)), + veq_vo_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(__builtin_inff()))), d, w); + + w = vsel_vf_vo_vf_vf_advsimd_sleef(vlt_vo_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(0)), vcast_vf_f_advsimd_sleef(__builtin_nanf("")), w); + + return w; + +} + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_sqrtf4_advsimd(vfloat_advsimd_sleef d) { + + return vsqrt_vf_vf_advsimd_sleef(d); + +} + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_hypotf4_u05advsimd(vfloat_advsimd_sleef x, vfloat_advsimd_sleef y) { + x = vabs_vf_vf_advsimd_sleef(x); + y = vabs_vf_vf_advsimd_sleef(y); + vfloat_advsimd_sleef min = vmin_vf_vf_vf_advsimd_sleef(x, y), n = min; + vfloat_advsimd_sleef max = vmax_vf_vf_vf_advsimd_sleef(x, y), d = max; + + vopmask_advsimd_sleef o = vlt_vo_vf_vf_advsimd_sleef(max, vcast_vf_f_advsimd_sleef(0x1p-126)); + n = vsel_vf_vo_vf_vf_advsimd_sleef(o, vmul_vf_vf_vf_advsimd_sleef(n, vcast_vf_f_advsimd_sleef(UINT64_C(1) << 24)), n); + d = vsel_vf_vo_vf_vf_advsimd_sleef(o, vmul_vf_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(UINT64_C(1) << 24)), d); + + vfloat2_advsimd_sleef t = dfdiv_vf2_vf2_vf2_advsimd_sleef(vcast_vf2_vf_vf_advsimd_sleef(n, vcast_vf_f_advsimd_sleef(0)), vcast_vf2_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(0))); + t = dfmul_vf2_vf2_vf_advsimd_sleef(dfsqrt_vf2_vf2_advsimd_sleef(dfadd2_vf2_vf2_vf_advsimd_sleef(dfsqu_vf2_vf2_advsimd_sleef(t), vcast_vf_f_advsimd_sleef(1))), max); + vfloat_advsimd_sleef ret = vadd_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(t), vf2gety_vf_vf2_advsimd_sleef(t)); + ret = vsel_vf_vo_vf_vf_advsimd_sleef(visnan_vo_vf_advsimd_sleef(ret), vcast_vf_f_advsimd_sleef(__builtin_inff()), ret); + ret = vsel_vf_vo_vf_vf_advsimd_sleef(veq_vo_vf_vf_advsimd_sleef(min, vcast_vf_f_advsimd_sleef(0)), max, ret); + ret = vsel_vf_vo_vf_vf_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(visnan_vo_vf_advsimd_sleef(x), visnan_vo_vf_advsimd_sleef(y)), vcast_vf_f_advsimd_sleef(__builtin_nanf("")), ret); + ret = vsel_vf_vo_vf_vf_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(veq_vo_vf_vf_advsimd_sleef(x, vcast_vf_f_advsimd_sleef(__builtin_inff())), veq_vo_vf_vf_advsimd_sleef(y, vcast_vf_f_advsimd_sleef(__builtin_inff()))), vcast_vf_f_advsimd_sleef(__builtin_inff()), ret); + + return ret; +} + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_hypotf4_u35advsimd(vfloat_advsimd_sleef x, vfloat_advsimd_sleef y) { + x = vabs_vf_vf_advsimd_sleef(x); + y = vabs_vf_vf_advsimd_sleef(y); + vfloat_advsimd_sleef min = vmin_vf_vf_vf_advsimd_sleef(x, y); + vfloat_advsimd_sleef max = vmax_vf_vf_vf_advsimd_sleef(x, y); + + vfloat_advsimd_sleef t = vdiv_vf_vf_vf_advsimd_sleef(min, max); + vfloat_advsimd_sleef ret = vmul_vf_vf_vf_advsimd_sleef(max, vsqrt_vf_vf_advsimd_sleef(vmla_vf_vf_vf_vf_advsimd_sleef(t, t, vcast_vf_f_advsimd_sleef(1)))); + ret = vsel_vf_vo_vf_vf_advsimd_sleef(veq_vo_vf_vf_advsimd_sleef(min, vcast_vf_f_advsimd_sleef(0)), max, ret); + ret = vsel_vf_vo_vf_vf_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(visnan_vo_vf_advsimd_sleef(x), visnan_vo_vf_advsimd_sleef(y)), vcast_vf_f_advsimd_sleef(__builtin_nanf("")), ret); + ret = vsel_vf_vo_vf_vf_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(veq_vo_vf_vf_advsimd_sleef(x, vcast_vf_f_advsimd_sleef(__builtin_inff())), veq_vo_vf_vf_advsimd_sleef(y, vcast_vf_f_advsimd_sleef(__builtin_inff()))), vcast_vf_f_advsimd_sleef(__builtin_inff()), ret); + + return ret; +} + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_nextafterf4_advsimd(vfloat_advsimd_sleef x, vfloat_advsimd_sleef y) { + x = vsel_vf_vo_vf_vf_advsimd_sleef(veq_vo_vf_vf_advsimd_sleef(x, vcast_vf_f_advsimd_sleef(0)), vmulsign_vf_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(0), y), x); + vint2_advsimd_sleef xi2 = vreinterpret_vi2_vf_advsimd_sleef(x); + vopmask_advsimd_sleef c = vxor_vo_vo_vo_advsimd_sleef(vsignbit_vo_vf_advsimd_sleef(x), vge_vo_vf_vf_advsimd_sleef(y, x)); + + xi2 = vsel_vi2_vo_vi2_vi2_advsimd_sleef(c, vsub_vi2_vi2_vi2_advsimd_sleef(vcast_vi2_i_advsimd_sleef(0), vxor_vi2_vi2_vi2_advsimd_sleef(xi2, vcast_vi2_i_advsimd_sleef((int)(1U << 31)))), xi2); + + xi2 = vsel_vi2_vo_vi2_vi2_advsimd_sleef(vneq_vo_vf_vf_advsimd_sleef(x, y), vsub_vi2_vi2_vi2_advsimd_sleef(xi2, vcast_vi2_i_advsimd_sleef(1)), xi2); + + xi2 = vsel_vi2_vo_vi2_vi2_advsimd_sleef(c, vsub_vi2_vi2_vi2_advsimd_sleef(vcast_vi2_i_advsimd_sleef(0), vxor_vi2_vi2_vi2_advsimd_sleef(xi2, vcast_vi2_i_advsimd_sleef((int)(1U << 31)))), xi2); + + vfloat_advsimd_sleef ret = vreinterpret_vf_vi2_advsimd_sleef(xi2); + + ret = vsel_vf_vo_vf_vf_advsimd_sleef(vand_vo_vo_vo_advsimd_sleef(veq_vo_vf_vf_advsimd_sleef(ret, vcast_vf_f_advsimd_sleef(0)), vneq_vo_vf_vf_advsimd_sleef(x, vcast_vf_f_advsimd_sleef(0))), + vmulsign_vf_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(0), x), ret); + + ret = vsel_vf_vo_vf_vf_advsimd_sleef(vand_vo_vo_vo_advsimd_sleef(veq_vo_vf_vf_advsimd_sleef(x, vcast_vf_f_advsimd_sleef(0)), veq_vo_vf_vf_advsimd_sleef(y, vcast_vf_f_advsimd_sleef(0))), y, ret); + + ret = vsel_vf_vo_vf_vf_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(visnan_vo_vf_advsimd_sleef(x), visnan_vo_vf_advsimd_sleef(y)), vcast_vf_f_advsimd_sleef(__builtin_nanf("")), ret); + + return ret; +} + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_frfrexpf4_advsimd(vfloat_advsimd_sleef x) { + x = vsel_vf_vo_vf_vf_advsimd_sleef(vlt_vo_vf_vf_advsimd_sleef(vabs_vf_vf_advsimd_sleef(x), vcast_vf_f_advsimd_sleef(0x1p-126)), vmul_vf_vf_vf_advsimd_sleef(x, vcast_vf_f_advsimd_sleef(UINT64_C(1) << 30)), x); + + vmask_advsimd_sleef xm = vreinterpret_vm_vf_advsimd_sleef(x); + xm = vand_vm_vm_vm_advsimd_sleef(xm, vcast_vm_i_i_advsimd_sleef(~0x7f800000U, ~0x7f800000U)); + xm = vor_vm_vm_vm_advsimd_sleef (xm, vcast_vm_i_i_advsimd_sleef( 0x3f000000U, 0x3f000000U)); + + vfloat_advsimd_sleef ret = vreinterpret_vf_vm_advsimd_sleef(xm); + + ret = vsel_vf_vo_vf_vf_advsimd_sleef(visinf_vo_vf_advsimd_sleef(x), vmulsign_vf_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(__builtin_inff()), x), ret); + ret = vsel_vf_vo_vf_vf_advsimd_sleef(veq_vo_vf_vf_advsimd_sleef(x, vcast_vf_f_advsimd_sleef(0)), x, ret); + + return ret; +} + +SLEEF_INLINE SLEEF_CONST vint2_advsimd_sleef Sleef_expfrexpf4_advsimd(vfloat_advsimd_sleef x) { + + return vcast_vi2_i_advsimd_sleef(0); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_advsimd_sleef vtoward0_vf_vf_advsimd_sleef(vfloat_advsimd_sleef x) { + vfloat_advsimd_sleef t = vreinterpret_vf_vi2_advsimd_sleef(vsub_vi2_vi2_vi2_advsimd_sleef(vreinterpret_vi2_vf_advsimd_sleef(x), vcast_vi2_i_advsimd_sleef(1))); + return vsel_vf_vo_vf_vf_advsimd_sleef(veq_vo_vf_vf_advsimd_sleef(x, vcast_vf_f_advsimd_sleef(0)), vcast_vf_f_advsimd_sleef(0), t); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_advsimd_sleef vptrunc_vf_vf_advsimd_sleef(vfloat_advsimd_sleef x) { + + return vtruncate_vf_vf_advsimd_sleef(x); + +} + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_fmodf4_advsimd(vfloat_advsimd_sleef x, vfloat_advsimd_sleef y) { + vfloat_advsimd_sleef nu = vabs_vf_vf_advsimd_sleef(x), de = vabs_vf_vf_advsimd_sleef(y), s = vcast_vf_f_advsimd_sleef(1), q; + vopmask_advsimd_sleef o = vlt_vo_vf_vf_advsimd_sleef(de, vcast_vf_f_advsimd_sleef(0x1p-126)); + nu = vsel_vf_vo_vf_vf_advsimd_sleef(o, vmul_vf_vf_vf_advsimd_sleef(nu, vcast_vf_f_advsimd_sleef(UINT64_C(1) << 25)), nu); + de = vsel_vf_vo_vf_vf_advsimd_sleef(o, vmul_vf_vf_vf_advsimd_sleef(de, vcast_vf_f_advsimd_sleef(UINT64_C(1) << 25)), de); + s = vsel_vf_vo_vf_vf_advsimd_sleef(o, vmul_vf_vf_vf_advsimd_sleef(s , vcast_vf_f_advsimd_sleef(1.0f / (UINT64_C(1) << 25))), s); + vfloat_advsimd_sleef rde = vtoward0_vf_vf_advsimd_sleef(vrec_vf_vf_advsimd_sleef(de)); + + vfloat2_advsimd_sleef r = vcast_vf2_vf_vf_advsimd_sleef(nu, vcast_vf_f_advsimd_sleef(0)); + + for(int i=0;i<8;i++) { + q = vptrunc_vf_vf_advsimd_sleef(vmul_vf_vf_vf_advsimd_sleef(vtoward0_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(r)), rde)); + q = vsel_vf_vo_vf_vf_advsimd_sleef(vand_vo_vo_vo_advsimd_sleef(vgt_vo_vf_vf_advsimd_sleef(vmul_vf_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(3), de), vf2getx_vf_vf2_advsimd_sleef(r)), + vge_vo_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(r), de)), + vcast_vf_f_advsimd_sleef(2), q); + q = vsel_vf_vo_vf_vf_advsimd_sleef(vand_vo_vo_vo_advsimd_sleef(vgt_vo_vf_vf_advsimd_sleef(vmul_vf_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(2), de), vf2getx_vf_vf2_advsimd_sleef(r)), + vge_vo_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(r), de)), + vcast_vf_f_advsimd_sleef(1), q); + r = dfnormalize_vf2_vf2_advsimd_sleef(dfadd2_vf2_vf2_vf2_advsimd_sleef(r, dfmul_vf2_vf_vf_advsimd_sleef(vptrunc_vf_vf_advsimd_sleef(q), vneg_vf_vf_advsimd_sleef(de)))); + if (vtestallones_i_vo32_advsimd_sleef(vlt_vo_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(r), de))) break; + } + + vfloat_advsimd_sleef ret = vmul_vf_vf_vf_advsimd_sleef(vadd_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(r), vf2gety_vf_vf2_advsimd_sleef(r)), s); + ret = vsel_vf_vo_vf_vf_advsimd_sleef(veq_vo_vf_vf_advsimd_sleef(vadd_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(r), vf2gety_vf_vf2_advsimd_sleef(r)), de), vcast_vf_f_advsimd_sleef(0), ret); + + ret = vmulsign_vf_vf_vf_advsimd_sleef(ret, x); + + ret = vsel_vf_vo_vf_vf_advsimd_sleef(vlt_vo_vf_vf_advsimd_sleef(nu, de), x, ret); + ret = vsel_vf_vo_vf_vf_advsimd_sleef(veq_vo_vf_vf_advsimd_sleef(de, vcast_vf_f_advsimd_sleef(0)), vcast_vf_f_advsimd_sleef(__builtin_nanf("")), ret); + + return ret; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_advsimd_sleef vrintfk2_vf_vf_advsimd_sleef(vfloat_advsimd_sleef d) { + + return vrint_vf_vf_advsimd_sleef(d); + +} + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_remainderf4_advsimd(vfloat_advsimd_sleef x, vfloat_advsimd_sleef y) { + vfloat_advsimd_sleef n = vabs_vf_vf_advsimd_sleef(x), d = vabs_vf_vf_advsimd_sleef(y), s = vcast_vf_f_advsimd_sleef(1), q; + vopmask_advsimd_sleef o = vlt_vo_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(0x1p-126*2)); + n = vsel_vf_vo_vf_vf_advsimd_sleef(o, vmul_vf_vf_vf_advsimd_sleef(n, vcast_vf_f_advsimd_sleef(UINT64_C(1) << 25)), n); + d = vsel_vf_vo_vf_vf_advsimd_sleef(o, vmul_vf_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(UINT64_C(1) << 25)), d); + s = vsel_vf_vo_vf_vf_advsimd_sleef(o, vmul_vf_vf_vf_advsimd_sleef(s , vcast_vf_f_advsimd_sleef(1.0f / (UINT64_C(1) << 25))), s); + vfloat2_advsimd_sleef r = vcast_vf2_vf_vf_advsimd_sleef(n, vcast_vf_f_advsimd_sleef(0)); + vfloat_advsimd_sleef rd = vrec_vf_vf_advsimd_sleef(d); + vopmask_advsimd_sleef qisodd = vneq_vo_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(0), vcast_vf_f_advsimd_sleef(0)); + + for(int i=0;i<8;i++) { + q = vrintfk2_vf_vf_advsimd_sleef(vmul_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(r), rd)); + q = vsel_vf_vo_vf_vf_advsimd_sleef(vlt_vo_vf_vf_advsimd_sleef(vabs_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(r)), vmul_vf_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(1.5f))), vmulsign_vf_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(1.0f), vf2getx_vf_vf2_advsimd_sleef(r)), q); + q = vsel_vf_vo_vf_vf_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(vlt_vo_vf_vf_advsimd_sleef(vabs_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(r)), vmul_vf_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(0.5f))), + vandnot_vo_vo_vo_advsimd_sleef(qisodd, veq_vo_vf_vf_advsimd_sleef(vabs_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(r)), vmul_vf_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(0.5f))))), + vcast_vf_f_advsimd_sleef(0.0), q); + if (vtestallones_i_vo32_advsimd_sleef(veq_vo_vf_vf_advsimd_sleef(q, vcast_vf_f_advsimd_sleef(0)))) break; + q = vsel_vf_vo_vf_vf_advsimd_sleef(visinf_vo_vf_advsimd_sleef(vmul_vf_vf_vf_advsimd_sleef(q, vneg_vf_vf_advsimd_sleef(d))), vadd_vf_vf_vf_advsimd_sleef(q, vmulsign_vf_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(-1), vf2getx_vf_vf2_advsimd_sleef(r))), q); + qisodd = vxor_vo_vo_vo_advsimd_sleef(qisodd, vand_vo_vo_vo_advsimd_sleef(veq_vo_vi2_vi2_advsimd_sleef(vand_vi2_vi2_vi2_advsimd_sleef(vtruncate_vi2_vf_advsimd_sleef(q), vcast_vi2_i_advsimd_sleef(1)), vcast_vi2_i_advsimd_sleef(1)), + vlt_vo_vf_vf_advsimd_sleef(vabs_vf_vf_advsimd_sleef(q), vcast_vf_f_advsimd_sleef(1 << 24)))); + r = dfnormalize_vf2_vf2_advsimd_sleef(dfadd2_vf2_vf2_vf2_advsimd_sleef(r, dfmul_vf2_vf_vf_advsimd_sleef(q, vneg_vf_vf_advsimd_sleef(d)))); + } + + vfloat_advsimd_sleef ret = vmul_vf_vf_vf_advsimd_sleef(vadd_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(r), vf2gety_vf_vf2_advsimd_sleef(r)), s); + ret = vmulsign_vf_vf_vf_advsimd_sleef(ret, x); + ret = vsel_vf_vo_vf_vf_advsimd_sleef(visinf_vo_vf_advsimd_sleef(y), vsel_vf_vo_vf_vf_advsimd_sleef(visinf_vo_vf_advsimd_sleef(x), vcast_vf_f_advsimd_sleef(__builtin_nanf("")), x), ret); + ret = vsel_vf_vo_vf_vf_advsimd_sleef(veq_vo_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(0)), vcast_vf_f_advsimd_sleef(__builtin_nanf("")), ret); + return ret; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_advsimd_sleef sinpifk_advsimd_sleef(vfloat_advsimd_sleef d) { + vopmask_advsimd_sleef o; + vfloat_advsimd_sleef u, s, t; + vfloat2_advsimd_sleef x, s2; + + u = vmul_vf_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(4.0)); + vint2_advsimd_sleef q = vtruncate_vi2_vf_advsimd_sleef(u); + q = vand_vi2_vi2_vi2_advsimd_sleef(vadd_vi2_vi2_vi2_advsimd_sleef(q, vxor_vi2_vi2_vi2_advsimd_sleef(vreinterpretq_s32_u32(vshrq_n_u32(vreinterpretq_u32_s32(q), 31)), vcast_vi2_i_advsimd_sleef(1))), vcast_vi2_i_advsimd_sleef(~1)); + o = veq_vo_vi2_vi2_advsimd_sleef(vand_vi2_vi2_vi2_advsimd_sleef(q, vcast_vi2_i_advsimd_sleef(2)), vcast_vi2_i_advsimd_sleef(2)); + + s = vsub_vf_vf_vf_advsimd_sleef(u, vcast_vf_vi2_advsimd_sleef(q)); + t = s; + s = vmul_vf_vf_vf_advsimd_sleef(s, s); + s2 = dfmul_vf2_vf_vf_advsimd_sleef(t, t); + + u = vsel_vf_vo_f_f_advsimd_sleef(o, -0.2430611801e-7f, +0.3093842054e-6f); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, s, vsel_vf_vo_f_f_advsimd_sleef(o, +0.3590577080e-5f, -0.3657307388e-4f)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, s, vsel_vf_vo_f_f_advsimd_sleef(o, -0.3259917721e-3f, +0.2490393585e-2f)); + x = dfadd2_vf2_vf_vf2_advsimd_sleef(vmul_vf_vf_vf_advsimd_sleef(u, s), + vsel_vf2_vo_f_f_f_f_advsimd_sleef(o, 0.015854343771934509277, 4.4940051354032242811e-10, + -0.080745510756969451904, -1.3373665339076936258e-09)); + x = dfadd2_vf2_vf2_vf2_advsimd_sleef(dfmul_vf2_vf2_vf2_advsimd_sleef(s2, x), + vsel_vf2_vo_f_f_f_f_advsimd_sleef(o, -0.30842512845993041992, -9.0728339030733922277e-09, + 0.78539818525314331055, -2.1857338617566484855e-08)); + + x = dfmul_vf2_vf2_vf2_advsimd_sleef(x, vsel_vf2_vo_vf2_vf2_advsimd_sleef(o, s2, vcast_vf2_vf_vf_advsimd_sleef(t, vcast_vf_f_advsimd_sleef(0)))); + x = vsel_vf2_vo_vf2_vf2_advsimd_sleef(o, dfadd2_vf2_vf2_vf_advsimd_sleef(x, vcast_vf_f_advsimd_sleef(1)), x); + + o = veq_vo_vi2_vi2_advsimd_sleef(vand_vi2_vi2_vi2_advsimd_sleef(q, vcast_vi2_i_advsimd_sleef(4)), vcast_vi2_i_advsimd_sleef(4)); + x = vf2setx_vf2_vf2_vf_advsimd_sleef(x, vreinterpret_vf_vm_advsimd_sleef(vxor_vm_vm_vm_advsimd_sleef(vand_vm_vo32_vm_advsimd_sleef(o, vreinterpret_vm_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(-0.0))), vreinterpret_vm_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(x))))); + x = vf2sety_vf2_vf2_vf_advsimd_sleef(x, vreinterpret_vf_vm_advsimd_sleef(vxor_vm_vm_vm_advsimd_sleef(vand_vm_vo32_vm_advsimd_sleef(o, vreinterpret_vm_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(-0.0))), vreinterpret_vm_vf_advsimd_sleef(vf2gety_vf_vf2_advsimd_sleef(x))))); + + return x; +} + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_sinpif4_u05advsimd(vfloat_advsimd_sleef d) { + vfloat2_advsimd_sleef x = sinpifk_advsimd_sleef(d); + vfloat_advsimd_sleef r = vadd_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(x), vf2gety_vf_vf2_advsimd_sleef(x)); + + r = vsel_vf_vo_vf_vf_advsimd_sleef(visnegzero_vo_vf_advsimd_sleef(d), vcast_vf_f_advsimd_sleef(-0.0), r); + r = vreinterpret_vf_vm_advsimd_sleef(vandnot_vm_vo32_vm_advsimd_sleef(vgt_vo_vf_vf_advsimd_sleef(vabs_vf_vf_advsimd_sleef(d), vcast_vf_f_advsimd_sleef(8e+6f)), vreinterpret_vm_vf_advsimd_sleef(r))); + r = vreinterpret_vf_vm_advsimd_sleef(vor_vm_vo32_vm_advsimd_sleef(visinf_vo_vf_advsimd_sleef(d), vreinterpret_vm_vf_advsimd_sleef(r))); + + return r; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_advsimd_sleef cospifk_advsimd_sleef(vfloat_advsimd_sleef d) { + vopmask_advsimd_sleef o; + vfloat_advsimd_sleef u, s, t; + vfloat2_advsimd_sleef x, s2; + + u = vmul_vf_vf_vf_advsimd_sleef(d, vcast_vf_f_advsimd_sleef(4.0)); + vint2_advsimd_sleef q = vtruncate_vi2_vf_advsimd_sleef(u); + q = vand_vi2_vi2_vi2_advsimd_sleef(vadd_vi2_vi2_vi2_advsimd_sleef(q, vxor_vi2_vi2_vi2_advsimd_sleef(vreinterpretq_s32_u32(vshrq_n_u32(vreinterpretq_u32_s32(q), 31)), vcast_vi2_i_advsimd_sleef(1))), vcast_vi2_i_advsimd_sleef(~1)); + o = veq_vo_vi2_vi2_advsimd_sleef(vand_vi2_vi2_vi2_advsimd_sleef(q, vcast_vi2_i_advsimd_sleef(2)), vcast_vi2_i_advsimd_sleef(0)); + + s = vsub_vf_vf_vf_advsimd_sleef(u, vcast_vf_vi2_advsimd_sleef(q)); + t = s; + s = vmul_vf_vf_vf_advsimd_sleef(s, s); + s2 = dfmul_vf2_vf_vf_advsimd_sleef(t, t); + + u = vsel_vf_vo_f_f_advsimd_sleef(o, -0.2430611801e-7f, +0.3093842054e-6f); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, s, vsel_vf_vo_f_f_advsimd_sleef(o, +0.3590577080e-5f, -0.3657307388e-4f)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, s, vsel_vf_vo_f_f_advsimd_sleef(o, -0.3259917721e-3f, +0.2490393585e-2f)); + x = dfadd2_vf2_vf_vf2_advsimd_sleef(vmul_vf_vf_vf_advsimd_sleef(u, s), + vsel_vf2_vo_f_f_f_f_advsimd_sleef(o, 0.015854343771934509277, 4.4940051354032242811e-10, + -0.080745510756969451904, -1.3373665339076936258e-09)); + x = dfadd2_vf2_vf2_vf2_advsimd_sleef(dfmul_vf2_vf2_vf2_advsimd_sleef(s2, x), + vsel_vf2_vo_f_f_f_f_advsimd_sleef(o, -0.30842512845993041992, -9.0728339030733922277e-09, + 0.78539818525314331055, -2.1857338617566484855e-08)); + + x = dfmul_vf2_vf2_vf2_advsimd_sleef(x, vsel_vf2_vo_vf2_vf2_advsimd_sleef(o, s2, vcast_vf2_vf_vf_advsimd_sleef(t, vcast_vf_f_advsimd_sleef(0)))); + x = vsel_vf2_vo_vf2_vf2_advsimd_sleef(o, dfadd2_vf2_vf2_vf_advsimd_sleef(x, vcast_vf_f_advsimd_sleef(1)), x); + + o = veq_vo_vi2_vi2_advsimd_sleef(vand_vi2_vi2_vi2_advsimd_sleef(vadd_vi2_vi2_vi2_advsimd_sleef(q, vcast_vi2_i_advsimd_sleef(2)), vcast_vi2_i_advsimd_sleef(4)), vcast_vi2_i_advsimd_sleef(4)); + x = vf2setx_vf2_vf2_vf_advsimd_sleef(x, vreinterpret_vf_vm_advsimd_sleef(vxor_vm_vm_vm_advsimd_sleef(vand_vm_vo32_vm_advsimd_sleef(o, vreinterpret_vm_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(-0.0))), vreinterpret_vm_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(x))))); + x = vf2sety_vf2_vf2_vf_advsimd_sleef(x, vreinterpret_vf_vm_advsimd_sleef(vxor_vm_vm_vm_advsimd_sleef(vand_vm_vo32_vm_advsimd_sleef(o, vreinterpret_vm_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(-0.0))), vreinterpret_vm_vf_advsimd_sleef(vf2gety_vf_vf2_advsimd_sleef(x))))); + + return x; +} + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_cospif4_u05advsimd(vfloat_advsimd_sleef d) { + vfloat2_advsimd_sleef x = cospifk_advsimd_sleef(d); + vfloat_advsimd_sleef r = vadd_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(x), vf2gety_vf_vf2_advsimd_sleef(x)); + + r = vsel_vf_vo_vf_vf_advsimd_sleef(vgt_vo_vf_vf_advsimd_sleef(vabs_vf_vf_advsimd_sleef(d), vcast_vf_f_advsimd_sleef(8e+6f)), vcast_vf_f_advsimd_sleef(1), r); + r = vreinterpret_vf_vm_advsimd_sleef(vor_vm_vo32_vm_advsimd_sleef(visinf_vo_vf_advsimd_sleef(d), vreinterpret_vm_vf_advsimd_sleef(r))); + + return r; +} + + typedef struct { + vfloat2_advsimd_sleef a, b; + } df2_advsimd_sleef; + +static df2_advsimd_sleef df2setab_df2_vf2_vf2_advsimd_sleef(vfloat2_advsimd_sleef a, vfloat2_advsimd_sleef b) { + df2_advsimd_sleef r = { a, b }; + return r; +} +static vfloat2_advsimd_sleef df2geta_vf2_df2_advsimd_sleef(df2_advsimd_sleef d) { return d.a; } +static vfloat2_advsimd_sleef df2getb_vf2_df2_advsimd_sleef(df2_advsimd_sleef d) { return d.b; } + +static SLEEF_CONST df2_advsimd_sleef gammafk_advsimd_sleef(vfloat_advsimd_sleef a) { + vfloat2_advsimd_sleef clc = vcast_vf2_f_f_advsimd_sleef(0, 0), clln = vcast_vf2_f_f_advsimd_sleef(1, 0), clld = vcast_vf2_f_f_advsimd_sleef(1, 0); + vfloat2_advsimd_sleef x, y, z; + vfloat_advsimd_sleef t, u; + + vopmask_advsimd_sleef otiny = vlt_vo_vf_vf_advsimd_sleef(vabs_vf_vf_advsimd_sleef(a), vcast_vf_f_advsimd_sleef(1e-30f)), oref = vlt_vo_vf_vf_advsimd_sleef(a, vcast_vf_f_advsimd_sleef(0.5)); + + x = vsel_vf2_vo_vf2_vf2_advsimd_sleef(otiny, vcast_vf2_f_f_advsimd_sleef(0, 0), + vsel_vf2_vo_vf2_vf2_advsimd_sleef(oref, dfadd2_vf2_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(1), vneg_vf_vf_advsimd_sleef(a)), + vcast_vf2_vf_vf_advsimd_sleef(a, vcast_vf_f_advsimd_sleef(0)))); + + vopmask_advsimd_sleef o0 = vand_vo_vo_vo_advsimd_sleef(vle_vo_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(0.5), vf2getx_vf_vf2_advsimd_sleef(x)), vle_vo_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(x), vcast_vf_f_advsimd_sleef(1.2))); + vopmask_advsimd_sleef o2 = vle_vo_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(2.3), vf2getx_vf_vf2_advsimd_sleef(x)); + + y = dfnormalize_vf2_vf2_advsimd_sleef(dfmul_vf2_vf2_vf2_advsimd_sleef(dfadd2_vf2_vf2_vf_advsimd_sleef(x, vcast_vf_f_advsimd_sleef(1)), x)); + y = dfnormalize_vf2_vf2_advsimd_sleef(dfmul_vf2_vf2_vf2_advsimd_sleef(dfadd2_vf2_vf2_vf_advsimd_sleef(x, vcast_vf_f_advsimd_sleef(2)), y)); + + vopmask_advsimd_sleef o = vand_vo_vo_vo_advsimd_sleef(o2, vle_vo_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(x), vcast_vf_f_advsimd_sleef(7))); + clln = vsel_vf2_vo_vf2_vf2_advsimd_sleef(o, y, clln); + + x = vsel_vf2_vo_vf2_vf2_advsimd_sleef(o, dfadd2_vf2_vf2_vf_advsimd_sleef(x, vcast_vf_f_advsimd_sleef(3)), x); + t = vsel_vf_vo_vf_vf_advsimd_sleef(o2, vrec_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(x)), vf2getx_vf_vf2_advsimd_sleef(dfnormalize_vf2_vf2_advsimd_sleef(dfadd2_vf2_vf2_vf_advsimd_sleef(x, vsel_vf_vo_f_f_advsimd_sleef(o0, -1, -2))))); + + u = vsel_vf_vo_vo_f_f_f_advsimd_sleef(o2, o0, +0.000839498720672087279971000786, +0.9435157776e+0f, +0.1102489550e-3f); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, t, vsel_vf_vo_vo_f_f_f_advsimd_sleef(o2, o0, -5.17179090826059219329394422e-05, +0.8670063615e+0f, +0.8160019934e-4f)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, t, vsel_vf_vo_vo_f_f_f_advsimd_sleef(o2, o0, -0.000592166437353693882857342347, +0.4826702476e+0f, +0.1528468856e-3f)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, t, vsel_vf_vo_vo_f_f_f_advsimd_sleef(o2, o0, +6.97281375836585777403743539e-05, -0.8855129778e-1f, -0.2355068718e-3f)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, t, vsel_vf_vo_vo_f_f_f_advsimd_sleef(o2, o0, +0.000784039221720066627493314301, +0.1013825238e+0f, +0.4962242092e-3f)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, t, vsel_vf_vo_vo_f_f_f_advsimd_sleef(o2, o0, -0.000229472093621399176949318732, -0.1493408978e+0f, -0.1193488017e-2f)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, t, vsel_vf_vo_vo_f_f_f_advsimd_sleef(o2, o0, -0.002681327160493827160473958490, +0.1697509140e+0f, +0.2891599433e-2f)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, t, vsel_vf_vo_vo_f_f_f_advsimd_sleef(o2, o0, +0.003472222222222222222175164840, -0.2072454542e+0f, -0.7385451812e-2f)); + u = vmla_vf_vf_vf_vf_advsimd_sleef(u, t, vsel_vf_vo_vo_f_f_f_advsimd_sleef(o2, o0, +0.083333333333333333335592087900, +0.2705872357e+0f, +0.2058077045e-1f)); + + y = dfmul_vf2_vf2_vf2_advsimd_sleef(dfadd2_vf2_vf2_vf_advsimd_sleef(x, vcast_vf_f_advsimd_sleef(-0.5)), logk2f_advsimd_sleef(x)); + y = dfadd2_vf2_vf2_vf2_advsimd_sleef(y, dfneg_vf2_vf2_advsimd_sleef(x)); + y = dfadd2_vf2_vf2_vf2_advsimd_sleef(y, vcast_vf2_d_advsimd_sleef(0.91893853320467278056)); + + z = dfadd2_vf2_vf2_vf_advsimd_sleef(dfmul_vf2_vf_vf_advsimd_sleef (u, t), vsel_vf_vo_f_f_advsimd_sleef(o0, -0.400686534596170958447352690395e+0f, -0.673523028297382446749257758235e-1f)); + z = dfadd2_vf2_vf2_vf_advsimd_sleef(dfmul_vf2_vf2_vf_advsimd_sleef(z, t), vsel_vf_vo_f_f_advsimd_sleef(o0, +0.822466960142643054450325495997e+0f, +0.322467033928981157743538726901e+0f)); + z = dfadd2_vf2_vf2_vf_advsimd_sleef(dfmul_vf2_vf2_vf_advsimd_sleef(z, t), vsel_vf_vo_f_f_advsimd_sleef(o0, -0.577215665946766039837398973297e+0f, +0.422784335087484338986941629852e+0f)); + z = dfmul_vf2_vf2_vf_advsimd_sleef(z, t); + + clc = vsel_vf2_vo_vf2_vf2_advsimd_sleef(o2, y, z); + + clld = vsel_vf2_vo_vf2_vf2_advsimd_sleef(o2, dfadd2_vf2_vf2_vf_advsimd_sleef(dfmul_vf2_vf_vf_advsimd_sleef(u, t), vcast_vf_f_advsimd_sleef(1)), clld); + + y = clln; + + clc = vsel_vf2_vo_vf2_vf2_advsimd_sleef(otiny, vcast_vf2_d_advsimd_sleef(41.58883083359671856503), + vsel_vf2_vo_vf2_vf2_advsimd_sleef(oref, dfadd2_vf2_vf2_vf2_advsimd_sleef(vcast_vf2_d_advsimd_sleef(1.1447298858494001639), dfneg_vf2_vf2_advsimd_sleef(clc)), clc)); + clln = vsel_vf2_vo_vf2_vf2_advsimd_sleef(otiny, vcast_vf2_f_f_advsimd_sleef(1, 0), vsel_vf2_vo_vf2_vf2_advsimd_sleef(oref, clln, clld)); + + if (!vtestallones_i_vo32_advsimd_sleef(vnot_vo32_vo32_advsimd_sleef(oref))) { + t = vsub_vf_vf_vf_advsimd_sleef(a, vmul_vf_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(INT64_C(1) << 12), vcast_vf_vi2_advsimd_sleef(vtruncate_vi2_vf_advsimd_sleef(vmul_vf_vf_vf_advsimd_sleef(a, vcast_vf_f_advsimd_sleef(1.0 / (INT64_C(1) << 12))))))); + x = dfmul_vf2_vf2_vf2_advsimd_sleef(clld, sinpifk_advsimd_sleef(t)); + } + + clld = vsel_vf2_vo_vf2_vf2_advsimd_sleef(otiny, vcast_vf2_vf_vf_advsimd_sleef(vmul_vf_vf_vf_advsimd_sleef(a, vcast_vf_f_advsimd_sleef((INT64_C(1) << 30)*(float)(INT64_C(1) << 30))), vcast_vf_f_advsimd_sleef(0)), + vsel_vf2_vo_vf2_vf2_advsimd_sleef(oref, x, y)); + + return df2setab_df2_vf2_vf2_advsimd_sleef(clc, dfdiv_vf2_vf2_vf2_advsimd_sleef(clln, clld)); +} + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_tgammaf4_u10advsimd(vfloat_advsimd_sleef a) { + df2_advsimd_sleef d = gammafk_advsimd_sleef(a); + vfloat2_advsimd_sleef y = dfmul_vf2_vf2_vf2_advsimd_sleef(expk2f_advsimd_sleef(df2geta_vf2_df2_advsimd_sleef(d)), df2getb_vf2_df2_advsimd_sleef(d)); + vfloat_advsimd_sleef r = vadd_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(y), vf2gety_vf_vf2_advsimd_sleef(y)); + vopmask_advsimd_sleef o; + + o = vor_vo_vo_vo_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(veq_vo_vf_vf_advsimd_sleef(a, vcast_vf_f_advsimd_sleef(-__builtin_inff())), + vand_vo_vo_vo_advsimd_sleef(vlt_vo_vf_vf_advsimd_sleef(a, vcast_vf_f_advsimd_sleef(0)), visint_vo_vf_advsimd_sleef(a))), + vand_vo_vo_vo_advsimd_sleef(vand_vo_vo_vo_advsimd_sleef(visnumber_vo_vf_advsimd_sleef(a), vlt_vo_vf_vf_advsimd_sleef(a, vcast_vf_f_advsimd_sleef(0))), visnan_vo_vf_advsimd_sleef(r))); + r = vsel_vf_vo_vf_vf_advsimd_sleef(o, vcast_vf_f_advsimd_sleef(__builtin_nanf("")), r); + + o = vand_vo_vo_vo_advsimd_sleef(vand_vo_vo_vo_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(veq_vo_vf_vf_advsimd_sleef(a, vcast_vf_f_advsimd_sleef(__builtin_inff())), visnumber_vo_vf_advsimd_sleef(a)), + vge_vo_vf_vf_advsimd_sleef(a, vcast_vf_f_advsimd_sleef(-0x1p-126))), + vor_vo_vo_vo_advsimd_sleef(vor_vo_vo_vo_advsimd_sleef(veq_vo_vf_vf_advsimd_sleef(a, vcast_vf_f_advsimd_sleef(0)), vgt_vo_vf_vf_advsimd_sleef(a, vcast_vf_f_advsimd_sleef(36))), visnan_vo_vf_advsimd_sleef(r))); + r = vsel_vf_vo_vf_vf_advsimd_sleef(o, vmulsign_vf_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(__builtin_inff()), a), r); + + return r; +} + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_lgammaf4_u10advsimd(vfloat_advsimd_sleef a) { + df2_advsimd_sleef d = gammafk_advsimd_sleef(a); + vfloat2_advsimd_sleef y = dfadd2_vf2_vf2_vf2_advsimd_sleef(df2geta_vf2_df2_advsimd_sleef(d), logk2f_advsimd_sleef(dfabs_vf2_vf2_advsimd_sleef(df2getb_vf2_df2_advsimd_sleef(d)))); + vfloat_advsimd_sleef r = vadd_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(y), vf2gety_vf_vf2_advsimd_sleef(y)); + vopmask_advsimd_sleef o; + + o = vor_vo_vo_vo_advsimd_sleef(visinf_vo_vf_advsimd_sleef(a), + vor_vo_vo_vo_advsimd_sleef(vand_vo_vo_vo_advsimd_sleef(vle_vo_vf_vf_advsimd_sleef(a, vcast_vf_f_advsimd_sleef(0)), visint_vo_vf_advsimd_sleef(a)), + vand_vo_vo_vo_advsimd_sleef(visnumber_vo_vf_advsimd_sleef(a), visnan_vo_vf_advsimd_sleef(r)))); + r = vsel_vf_vo_vf_vf_advsimd_sleef(o, vcast_vf_f_advsimd_sleef(__builtin_inff()), r); + + return r; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_advsimd_sleef dfmla_vf2_vf_vf2_vf2_advsimd_sleef(vfloat_advsimd_sleef x, vfloat2_advsimd_sleef y, vfloat2_advsimd_sleef z) { + return dfadd_vf2_vf2_vf2_advsimd_sleef(z, dfmul_vf2_vf2_vf_advsimd_sleef(y, x)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_advsimd_sleef poly2df_b_advsimd_sleef(vfloat_advsimd_sleef x, vfloat2_advsimd_sleef c1, vfloat2_advsimd_sleef c0) { return dfmla_vf2_vf_vf2_vf2_advsimd_sleef(x, c1, c0); } +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_advsimd_sleef poly2df_advsimd_sleef(vfloat_advsimd_sleef x, vfloat_advsimd_sleef c1, vfloat2_advsimd_sleef c0) { return dfmla_vf2_vf_vf2_vf2_advsimd_sleef(x, vcast_vf2_vf_vf_advsimd_sleef(c1, vcast_vf_f_advsimd_sleef(0)), c0); } +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_advsimd_sleef poly4df_advsimd_sleef(vfloat_advsimd_sleef x, vfloat_advsimd_sleef c3, vfloat2_advsimd_sleef c2, vfloat2_advsimd_sleef c1, vfloat2_advsimd_sleef c0) { + return dfmla_vf2_vf_vf2_vf2_advsimd_sleef(vmul_vf_vf_vf_advsimd_sleef(x, x), poly2df_advsimd_sleef(x, c3, c2), poly2df_b_advsimd_sleef(x, c1, c0)); +} + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_erff4_u10advsimd(vfloat_advsimd_sleef a) { + vfloat_advsimd_sleef t, x = vabs_vf_vf_advsimd_sleef(a); + vfloat2_advsimd_sleef t2; + vfloat_advsimd_sleef x2 = vmul_vf_vf_vf_advsimd_sleef(x, x), x4 = vmul_vf_vf_vf_advsimd_sleef(x2, x2); + vopmask_advsimd_sleef o25 = vle_vo_vf_vf_advsimd_sleef(x, vcast_vf_f_advsimd_sleef(2.5)); + + if (__builtin_expect(!!(vtestallones_i_vo32_advsimd_sleef(o25)), 1)) { + + t = vmla_vf_vf_vf_vf_advsimd_sleef((x4), (vmla_vf_vf_vf_vf_advsimd_sleef((x), (vcast_vf_f_advsimd_sleef(-0.4360447008e-6)), (vcast_vf_f_advsimd_sleef(+0.6867515367e-5)))), (vmla_vf_vf_vf_vf_advsimd_sleef((x2), (vmla_vf_vf_vf_vf_advsimd_sleef((x), (vcast_vf_f_advsimd_sleef(-0.3045156700e-4)), (vcast_vf_f_advsimd_sleef(+0.9808536561e-4)))), (vmla_vf_vf_vf_vf_advsimd_sleef((x), (vcast_vf_f_advsimd_sleef(+0.2395523916e-3)), (vcast_vf_f_advsimd_sleef(+0.1459901541e-3))))))) + + ; + t2 = poly4df_advsimd_sleef(x, t, + vcast_vf2_f_f_advsimd_sleef(0.0092883445322513580322, -2.7863745897025330755e-11), + vcast_vf2_f_f_advsimd_sleef(0.042275499552488327026, 1.3461399289988106057e-09), + vcast_vf2_f_f_advsimd_sleef(0.070523701608180999756, -3.6616309318707365163e-09)); + t2 = dfadd_vf2_vf_vf2_advsimd_sleef(vcast_vf_f_advsimd_sleef(1), dfmul_vf2_vf2_vf_advsimd_sleef(t2, x)); + t2 = dfsqu_vf2_vf2_advsimd_sleef(t2); + t2 = dfsqu_vf2_vf2_advsimd_sleef(t2); + t2 = dfsqu_vf2_vf2_advsimd_sleef(t2); + t2 = dfsqu_vf2_vf2_advsimd_sleef(t2); + t2 = dfrec_vf2_vf2_advsimd_sleef(t2); + } else { + + t = vmla_vf_vf_vf_vf_advsimd_sleef((x4), (vmla_vf_vf_vf_vf_advsimd_sleef((x), ((vsel_vf_vo_f_f_advsimd_sleef(o25, -0.4360447008e-6, -0.1130012848e-6))), ((vsel_vf_vo_f_f_advsimd_sleef(o25, +0.6867515367e-5, +0.4115272986e-5))))), (vmla_vf_vf_vf_vf_advsimd_sleef((x2), (vmla_vf_vf_vf_vf_advsimd_sleef((x), ((vsel_vf_vo_f_f_advsimd_sleef(o25, -0.3045156700e-4, -0.6928304356e-4))), ((vsel_vf_vo_f_f_advsimd_sleef(o25, +0.9808536561e-4, +0.7172692567e-3))))), (vmla_vf_vf_vf_vf_advsimd_sleef((x), ((vsel_vf_vo_f_f_advsimd_sleef(o25, +0.2395523916e-3, -0.5131045356e-2))), ((vsel_vf_vo_f_f_advsimd_sleef(o25, +0.1459901541e-3, +0.2708637156e-1)))))))) + + ; + t2 = poly4df_advsimd_sleef(x, t, + vsel_vf2_vo_vf2_vf2_advsimd_sleef(o25, vcast_vf2_f_f_advsimd_sleef(0.0092883445322513580322, -2.7863745897025330755e-11), + vcast_vf2_f_f_advsimd_sleef(-0.11064319312572479248, 3.7050452777225283007e-09)), + vsel_vf2_vo_vf2_vf2_advsimd_sleef(o25, vcast_vf2_f_f_advsimd_sleef(0.042275499552488327026, 1.3461399289988106057e-09), + vcast_vf2_f_f_advsimd_sleef(-0.63192230463027954102, -2.0200432585073177859e-08)), + vsel_vf2_vo_vf2_vf2_advsimd_sleef(o25, vcast_vf2_f_f_advsimd_sleef(0.070523701608180999756, -3.6616309318707365163e-09), + vcast_vf2_f_f_advsimd_sleef(-1.1296638250350952148, 2.5515120196453259252e-08))); + t2 = dfmul_vf2_vf2_vf_advsimd_sleef(t2, x); + vfloat2_advsimd_sleef s2 = dfadd_vf2_vf_vf2_advsimd_sleef(vcast_vf_f_advsimd_sleef(1), t2); + s2 = dfsqu_vf2_vf2_advsimd_sleef(s2); + s2 = dfsqu_vf2_vf2_advsimd_sleef(s2); + s2 = dfsqu_vf2_vf2_advsimd_sleef(s2); + s2 = dfsqu_vf2_vf2_advsimd_sleef(s2); + s2 = dfrec_vf2_vf2_advsimd_sleef(s2); + t2 = vsel_vf2_vo_vf2_vf2_advsimd_sleef(o25, s2, vcast_vf2_vf_vf_advsimd_sleef(expkf_advsimd_sleef(t2), vcast_vf_f_advsimd_sleef(0))); + } + + t2 = dfadd2_vf2_vf2_vf_advsimd_sleef(t2, vcast_vf_f_advsimd_sleef(-1)); + t2 = vsel_vf2_vo_vf2_vf2_advsimd_sleef(vlt_vo_vf_vf_advsimd_sleef(x, vcast_vf_f_advsimd_sleef(1e-4)), dfmul_vf2_vf2_vf_advsimd_sleef(vcast_vf2_f_f_advsimd_sleef(-1.1283792257308959961, 5.8635383422197591097e-08), x), t2); + + vfloat_advsimd_sleef z = vneg_vf_vf_advsimd_sleef(vadd_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(t2), vf2gety_vf_vf2_advsimd_sleef(t2))); + z = vsel_vf_vo_vf_vf_advsimd_sleef(vge_vo_vf_vf_advsimd_sleef(x, vcast_vf_f_advsimd_sleef(6)), vcast_vf_f_advsimd_sleef(1), z); + z = vsel_vf_vo_vf_vf_advsimd_sleef(visinf_vo_vf_advsimd_sleef(a), vcast_vf_f_advsimd_sleef(1), z); + z = vsel_vf_vo_vf_vf_advsimd_sleef(veq_vo_vf_vf_advsimd_sleef(a, vcast_vf_f_advsimd_sleef(0)), vcast_vf_f_advsimd_sleef(0), z); + z = vmulsign_vf_vf_vf_advsimd_sleef(z, a); + + return z; +} + +SLEEF_INLINE SLEEF_CONST vfloat_advsimd_sleef Sleef_erfcf4_u15advsimd(vfloat_advsimd_sleef a) { + vfloat_advsimd_sleef s = a, r = vcast_vf_f_advsimd_sleef(0), t; + vfloat2_advsimd_sleef u, d, x; + a = vabs_vf_vf_advsimd_sleef(a); + vopmask_advsimd_sleef o0 = vlt_vo_vf_vf_advsimd_sleef(a, vcast_vf_f_advsimd_sleef(1.0)); + vopmask_advsimd_sleef o1 = vlt_vo_vf_vf_advsimd_sleef(a, vcast_vf_f_advsimd_sleef(2.2)); + vopmask_advsimd_sleef o2 = vlt_vo_vf_vf_advsimd_sleef(a, vcast_vf_f_advsimd_sleef(4.3)); + vopmask_advsimd_sleef o3 = vlt_vo_vf_vf_advsimd_sleef(a, vcast_vf_f_advsimd_sleef(10.1)); + + u = vsel_vf2_vo_vf2_vf2_advsimd_sleef(o1, vcast_vf2_vf_vf_advsimd_sleef(a, vcast_vf_f_advsimd_sleef(0)), dfdiv_vf2_vf2_vf2_advsimd_sleef(vcast_vf2_f_f_advsimd_sleef(1, 0), vcast_vf2_vf_vf_advsimd_sleef(a, vcast_vf_f_advsimd_sleef(0)))); + + t = vsel_vf_vo_vo_vo_f_f_f_f_advsimd_sleef(o0, o1, o2, -0.8638041618e-4f, -0.6236977242e-5f, -0.3869504035e+0f, +0.1115344167e+1f); + t = vmla_vf_vf_vf_vf_advsimd_sleef(t, vf2getx_vf_vf2_advsimd_sleef(u), vsel_vf_vo_vo_vo_f_f_f_f_advsimd_sleef(o0, o1, o2, +0.6000166177e-3f, +0.5749821503e-4f, +0.1288077235e+1f, -0.9454904199e+0f)); + t = vmla_vf_vf_vf_vf_advsimd_sleef(t, vf2getx_vf_vf2_advsimd_sleef(u), vsel_vf_vo_vo_vo_f_f_f_f_advsimd_sleef(o0, o1, o2, -0.1665703603e-2f, +0.6002851478e-5f, -0.1816803217e+1f, -0.3667259514e+0f)); + t = vmla_vf_vf_vf_vf_advsimd_sleef(t, vf2getx_vf_vf2_advsimd_sleef(u), vsel_vf_vo_vo_vo_f_f_f_f_advsimd_sleef(o0, o1, o2, +0.1795156277e-3f, -0.2851036377e-2f, +0.1249150872e+1f, +0.7155663371e+0f)); + t = vmla_vf_vf_vf_vf_advsimd_sleef(t, vf2getx_vf_vf2_advsimd_sleef(u), vsel_vf_vo_vo_vo_f_f_f_f_advsimd_sleef(o0, o1, o2, +0.1914106123e-1f, +0.2260518074e-1f, -0.1328857988e+0f, -0.1262947265e-1f)); + + d = dfmul_vf2_vf2_vf_advsimd_sleef(u, t); + d = dfadd2_vf2_vf2_vf2_advsimd_sleef(d, vsel_vf2_vo_vo_vo_d_d_d_d_advsimd_sleef(o0, o1, o2, -0.102775359343930288081655368891e+0, -0.105247583459338632253369014063e+0, -0.482365310333045318680618892669e+0, -0.498961546254537647970305302739e+0)); + d = dfmul_vf2_vf2_vf2_advsimd_sleef(d, u); + d = dfadd2_vf2_vf2_vf2_advsimd_sleef(d, vsel_vf2_vo_vo_vo_d_d_d_d_advsimd_sleef(o0, o1, o2, -0.636619483208481931303752546439e+0, -0.635609463574589034216723775292e+0, -0.134450203224533979217859332703e-2, -0.471199543422848492080722832666e-4)); + d = dfmul_vf2_vf2_vf2_advsimd_sleef(d, u); + d = dfadd2_vf2_vf2_vf2_advsimd_sleef(d, vsel_vf2_vo_vo_vo_d_d_d_d_advsimd_sleef(o0, o1, o2, -0.112837917790537404939545770596e+1, -0.112855987376668622084547028949e+1, -0.572319781150472949561786101080e+0, -0.572364030327966044425932623525e+0)); + + x = dfmul_vf2_vf2_vf_advsimd_sleef(vsel_vf2_vo_vf2_vf2_advsimd_sleef(o1, d, vcast_vf2_vf_vf_advsimd_sleef(vneg_vf_vf_advsimd_sleef(a), vcast_vf_f_advsimd_sleef(0))), a); + x = vsel_vf2_vo_vf2_vf2_advsimd_sleef(o1, x, dfadd2_vf2_vf2_vf2_advsimd_sleef(x, d)); + + x = expk2f_advsimd_sleef(x); + x = vsel_vf2_vo_vf2_vf2_advsimd_sleef(o1, x, dfmul_vf2_vf2_vf2_advsimd_sleef(x, u)); + + r = vsel_vf_vo_vf_vf_advsimd_sleef(o3, vadd_vf_vf_vf_advsimd_sleef(vf2getx_vf_vf2_advsimd_sleef(x), vf2gety_vf_vf2_advsimd_sleef(x)), vcast_vf_f_advsimd_sleef(0)); + r = vsel_vf_vo_vf_vf_advsimd_sleef(vsignbit_vo_vf_advsimd_sleef(s), vsub_vf_vf_vf_advsimd_sleef(vcast_vf_f_advsimd_sleef(2), r), r); + r = vsel_vf_vo_vf_vf_advsimd_sleef(visnan_vo_vf_advsimd_sleef(s), vcast_vf_f_advsimd_sleef(__builtin_nanf("")), r); + return r; +} diff --git a/src/jdk.incubator.vector/linux/native/libsleef/generated/sleefinline_rvvm1.h b/src/jdk.incubator.vector/linux/native/libsleef/generated/sleefinline_rvvm1.h new file mode 100644 index 00000000000..a68f41d734d --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/generated/sleefinline_rvvm1.h @@ -0,0 +1,7073 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See http://www.boost.org/LICENSE_1_0.txt) + +// This file is generated by SLEEF 3.6.1 + +#ifndef SLEEF_ALWAYS_INLINE +#if defined (__GNUC__) || defined (__clang__) || defined(__INTEL_COMPILER) +#define SLEEF_ALWAYS_INLINE inline __attribute__((always_inline)) +#elif defined(_MSC_VER) +#define SLEEF_ALWAYS_INLINE inline __forceinline +#else +#define SLEEF_ALWAYS_INLINE inline +#endif +#endif + +#ifndef SLEEF_INLINE +#define SLEEF_INLINE static inline +#endif + +#ifndef SLEEF_CONST +#define SLEEF_CONST +#endif + +#if defined(_MSC_VER) && !defined (__clang__) +#pragma fp_contract (off) +#else +#pragma STDC FP_CONTRACT OFF +#endif + +#ifndef SLEEF_FP_ILOGB0 +#define SLEEF_FP_ILOGB0 ((int)0x80000000) +#endif + +#ifndef SLEEF_FP_ILOGBNAN +#define SLEEF_FP_ILOGBNAN ((int)2147483647) +#endif + +#define SLEEFINLINE_RVVM1_H_INCLUDED + +#ifndef __SLEEF_REMPITAB__ +#define __SLEEF_REMPITAB__ +static const double Sleef_rempitabdp[] = { + 0.15915494309189531785, 1.7916237278037667488e-17, 2.5454160968749269937e-33, 2.1132476107887107169e-49, + 0.03415494309189533173, 4.0384494702232122736e-18, 1.0046721413651383112e-33, 2.1132476107887107169e-49, + 0.03415494309189533173, 4.0384494702232122736e-18, 1.0046721413651383112e-33, 2.1132476107887107169e-49, + 0.0029049430918953351999, 5.6900251826959904774e-19, 4.1707169171520598517e-35, -2.496415728504571394e-51, + 0.0029049430918953351999, 5.6900251826959904774e-19, 4.1707169171520598517e-35, -2.496415728504571394e-51, + 0.0029049430918953351999, 5.6900251826959904774e-19, 4.1707169171520598517e-35, -2.496415728504571394e-51, + 0.0029049430918953351999, 5.6900251826959904774e-19, 4.1707169171520598517e-35, -2.496415728504571394e-51, + 0.00095181809189533563356, 1.3532164927539732229e-19, -6.4410794381603004826e-36, 1.7634898158762436344e-52, + 0.00095181809189533563356, 1.3532164927539732229e-19, -6.4410794381603004826e-36, 1.7634898158762436344e-52, + 0.00046353684189533574198, 2.6901432026846872871e-20, -4.2254836195018827479e-37, 9.301187206862134399e-54, + 0.00021939621689533574198, 2.6901432026846872871e-20, -4.2254836195018827479e-37, 9.301187206862134399e-54, + 9.7325904395335769087e-05, -2.0362228529073840241e-22, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 3.6290748145335769087e-05, -2.0362228529073840241e-22, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 5.7731700203357690874e-06, -2.0362228529073840241e-22, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 5.7731700203357690874e-06, -2.0362228529073840241e-22, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 5.7731700203357690874e-06, -2.0362228529073840241e-22, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 1.9584727547107690874e-06, -2.0362228529073840241e-22, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 5.1124121898268875627e-08, 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 5.1124121898268875627e-08, 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 5.1124121898268875627e-08, 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 5.1124121898268875627e-08, 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 5.1124121898268875627e-08, 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 5.1124121898268875627e-08, 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 2.1321799510573569745e-08, 1.5185066224124613304e-24, 2.6226236120327253511e-40, 2.6283399642369025999e-57, + 6.4206383167259151492e-09, -1.3585460269359374382e-25, -1.3244127270701094468e-41, -2.4695541513869446866e-57, + 6.4206383167259151492e-09, -1.3585460269359374382e-25, -1.3244127270701094468e-41, -2.4695541513869446866e-57, + 2.6953480182640010867e-09, -1.3585460269359374382e-25, -1.3244127270701094468e-41, -2.4695541513869446866e-57, + 8.3270286903304384868e-10, 7.0940550444663151936e-26, 9.7147467687967058732e-42, 7.9392906424978921242e-59, + 8.3270286903304384868e-10, 7.0940550444663151936e-26, 9.7147467687967058732e-42, 7.9392906424978921242e-59, + 3.6704158172530459087e-10, 7.0940550444663151936e-26, 9.7147467687967058732e-42, 7.9392906424978921242e-59, + 1.3421093807143501366e-10, 1.9241762160098927996e-26, 3.9750282589222551507e-42, 7.9392906424978921242e-59, + 1.7795616244500218596e-11, -1.452834466126541428e-28, -1.5869767474823787636e-44, -2.6168913164368963837e-61, + 1.7795616244500218596e-11, -1.452834466126541428e-28, -1.5869767474823787636e-44, -2.6168913164368963837e-61, + 1.7795616244500218596e-11, -1.452834466126541428e-28, -1.5869767474823787636e-44, -2.6168913164368963837e-61, + 3.2437010161333667893e-12, -1.452834466126541428e-28, -1.5869767474823787636e-44, -2.6168913164368963837e-61, + 3.2437010161333667893e-12, -1.452834466126541428e-28, -1.5869767474823787636e-44, -2.6168913164368963837e-61, + 3.2437010161333667893e-12, -1.452834466126541428e-28, -1.5869767474823787636e-44, -2.6168913164368963837e-61, + 1.4247116125875099096e-12, 2.5861333686050385673e-28, 2.8971783383570358633e-44, -2.6168913164368963837e-61, + 5.1521691081458187359e-13, 5.6664945123924856962e-29, 6.5510079543732854985e-45, -2.6168913164368963837e-61, + 6.0469559928117805118e-14, 6.1778471897801070206e-30, 9.4581409707401690366e-46, 4.9461632249367446986e-62, + 6.0469559928117805118e-14, 6.1778471897801070206e-30, 9.4581409707401690366e-46, 4.9461632249367446986e-62, + 6.0469559928117805118e-14, 6.1778471897801070206e-30, 9.4581409707401690366e-46, 4.9461632249367446986e-62, + 3.6261410673097965595e-15, -1.3304005198798645927e-31, -1.7578597149294783985e-47, 8.4432539107728104262e-64, + 3.6261410673097965595e-15, -1.3304005198798645927e-31, -1.7578597149294783985e-47, 8.4432539107728104262e-64, + 3.6261410673097965595e-15, -1.3304005198798645927e-31, -1.7578597149294783985e-47, 8.4432539107728104262e-64, + 3.6261410673097965595e-15, -1.3304005198798645927e-31, -1.7578597149294783985e-47, 8.4432539107728104262e-64, + 7.3427388509295482183e-17, 1.4871367740953237822e-32, -1.1571307704883330232e-48, -6.7249112515659578102e-65, + 7.3427388509295482183e-17, 1.4871367740953237822e-32, -1.1571307704883330232e-48, -6.7249112515659578102e-65, + 7.3427388509295482183e-17, 1.4871367740953237822e-32, -1.1571307704883330232e-48, -6.7249112515659578102e-65, + 7.3427388509295482183e-17, 1.4871367740953237822e-32, -1.1571307704883330232e-48, -6.7249112515659578102e-65, + 7.3427388509295482183e-17, 1.4871367740953237822e-32, -1.1571307704883330232e-48, -6.7249112515659578102e-65, + 7.3427388509295482183e-17, 1.4871367740953237822e-32, -1.1571307704883330232e-48, -6.7249112515659578102e-65, + 1.7916237278037667488e-17, 2.5454160968749269937e-33, 2.1132476107887107169e-49, 8.7154294504188129325e-66, + 1.7916237278037667488e-17, 2.5454160968749269937e-33, 2.1132476107887107169e-49, 8.7154294504188129325e-66, + 4.0384494702232122736e-18, 1.0046721413651383112e-33, 2.1132476107887107169e-49, 8.7154294504188129325e-66, + 4.0384494702232122736e-18, 1.0046721413651383112e-33, 2.1132476107887107169e-49, 8.7154294504188129325e-66, + 5.6900251826959904774e-19, 4.1707169171520598517e-35, -2.4964157285045710972e-51, -1.866653112309982615e-67, + 5.6900251826959904774e-19, 4.1707169171520598517e-35, -2.4964157285045710972e-51, -1.866653112309982615e-67, + 5.6900251826959904774e-19, 4.1707169171520598517e-35, -2.4964157285045710972e-51, -1.866653112309982615e-67, + 1.3532164927539732229e-19, -6.4410794381603004826e-36, 1.7634898158762432635e-52, 3.5887057810247033998e-68, + 1.3532164927539732229e-19, -6.4410794381603004826e-36, 1.7634898158762432635e-52, 3.5887057810247033998e-68, + 2.6901432026846872871e-20, -4.2254836195018827479e-37, 9.3011872068621332399e-54, 1.113250147552460308e-69, + 2.6901432026846872871e-20, -4.2254836195018827479e-37, 9.3011872068621332399e-54, 1.113250147552460308e-69, + 2.6901432026846872871e-20, -4.2254836195018827479e-37, 9.3011872068621332399e-54, 1.113250147552460308e-69, + 1.3348904870778067446e-20, -4.2254836195018827479e-37, 9.3011872068621332399e-54, 1.113250147552460308e-69, + 6.5726412927436632287e-21, 1.0820844071023395684e-36, 1.7634898158762432635e-52, 3.5887057810247033998e-68, + 3.1845095037264626247e-21, 3.2976802257607573031e-37, 9.3011872068621332399e-54, 1.113250147552460308e-69, + 1.4904436092178623228e-21, -4.6390169687056261795e-38, -1.1392999419355048437e-54, -4.587677453735884283e-71, + 6.4341066196356198368e-22, -4.6390169687056261795e-38, -1.1392999419355048437e-54, -4.587677453735884283e-71, + 2.1989418833641172011e-22, 4.7649378378726728402e-38, 9.3011872068621332399e-54, 1.113250147552460308e-69, + 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, + 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, + 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, + 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, + 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, + 1.5185066224124613304e-24, 2.6226236120327253511e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, + 1.5185066224124613304e-24, 2.6226236120327253511e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, + 1.5185066224124613304e-24, 2.6226236120327253511e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, + 6.9132600985943383921e-25, 7.8591368887290111994e-41, 2.6283399642369020339e-57, 5.3358074162805516304e-73, + 2.7773570358292009361e-25, -1.3244127270701094468e-41, -2.4695541513869446866e-57, -3.2399200798614356002e-74, + 7.0940550444663151936e-26, 9.7147467687967058732e-42, 7.9392906424978921242e-59, 2.9745456030524896742e-75, + 7.0940550444663151936e-26, 9.7147467687967058732e-42, 7.9392906424978921242e-59, 2.9745456030524896742e-75, + 1.9241762160098927996e-26, 3.9750282589222551507e-42, 7.9392906424978921242e-59, 2.9745456030524896742e-75, + 1.9241762160098927996e-26, 3.9750282589222551507e-42, 7.9392906424978921242e-59, 2.9745456030524896742e-75, + 6.317065088957874881e-27, -3.2976062348358281152e-43, -2.6168913164368963837e-61, 3.7036201000008290615e-78, + 6.317065088957874881e-27, -3.2976062348358281152e-43, -2.6168913164368963837e-61, 3.7036201000008290615e-78, + 3.0858908211726098086e-27, 3.8770419025072344914e-43, 7.9392906424978921242e-59, 2.9745456030524896742e-75, + 1.4703036872799779898e-27, 2.8971783383570358633e-44, -2.6168913164368963837e-61, 3.7036201000008290615e-78, + 6.625101203336619011e-28, 2.8971783383570358633e-44, -2.6168913164368963837e-61, 3.7036201000008290615e-78, + 2.5861333686050385673e-28, 2.8971783383570358633e-44, -2.6168913164368963837e-61, 3.7036201000008290615e-78, + 5.6664945123924856962e-29, 6.5510079543732854985e-45, -2.6168913164368963837e-61, 3.7036201000008290615e-78, + 5.6664945123924856962e-29, 6.5510079543732854985e-45, -2.6168913164368963837e-61, 3.7036201000008290615e-78, + 6.1778471897801070206e-30, 9.4581409707401690366e-46, 4.9461632249367446986e-62, 3.7036201000008290615e-78, + 6.1778471897801070206e-30, 9.4581409707401690366e-46, 4.9461632249367446986e-62, 3.7036201000008290615e-78, + 6.1778471897801070206e-30, 9.4581409707401690366e-46, 4.9461632249367446986e-62, 3.7036201000008290615e-78, + 6.1778471897801070206e-30, 9.4581409707401690366e-46, 4.9461632249367446986e-62, 3.7036201000008290615e-78, + 3.0224035688960604996e-30, 2.451648649116083682e-46, 4.9461632249367446986e-62, 3.7036201000008290615e-78, + 1.4446817584540368888e-30, 2.451648649116083682e-46, 4.9461632249367446986e-62, 3.7036201000008290615e-78, + 6.5582085323302525856e-31, 7.0002556871006273225e-47, 1.0567786762735315635e-62, -6.1446417754639313137e-79, + 2.6139040062251944343e-31, -1.7578597149294783985e-47, 8.4432539107728090768e-64, 1.9517662449371102229e-79, + 6.4175174317266470186e-32, 4.3166913557804827486e-48, 8.4432539107728090768e-64, 1.9517662449371102229e-79, + 6.4175174317266470186e-32, 4.3166913557804827486e-48, 8.4432539107728090768e-64, 1.9517662449371102229e-79, + 1.4871367740953237822e-32, -1.1571307704883330232e-48, -6.7249112515659569668e-65, -7.2335760163150273591e-81, + 1.4871367740953237822e-32, -1.1571307704883330232e-48, -6.7249112515659569668e-65, -7.2335760163150273591e-81, + 2.5454160968749269937e-33, 2.1132476107887107169e-49, 8.7154294504188118783e-66, 1.2001823382693912203e-81, + 2.5454160968749269937e-33, 2.1132476107887107169e-49, 8.7154294504188118783e-66, 1.2001823382693912203e-81, + 2.5454160968749269937e-33, 2.1132476107887107169e-49, 8.7154294504188118783e-66, 1.2001823382693912203e-81, + 1.0046721413651383112e-33, 2.1132476107887107169e-49, 8.7154294504188118783e-66, 1.2001823382693912203e-81, + 2.3430016361024414106e-34, 4.0267819632970559834e-50, -7.8013829534098555144e-67, -1.1759240463442418271e-82, + 2.3430016361024414106e-34, 4.0267819632970559834e-50, -7.8013829534098555144e-67, -1.1759240463442418271e-82, + 4.1707169171520598517e-35, -2.4964157285045710972e-51, -1.866653112309982615e-67, 1.4185069655957361252e-83, + 4.1707169171520598517e-35, -2.4964157285045710972e-51, -1.866653112309982615e-67, 1.4185069655957361252e-83, + 4.1707169171520598517e-35, -2.4964157285045710972e-51, -1.866653112309982615e-67, 1.4185069655957361252e-83, + 1.7633044866680145008e-35, 2.8491136916798196016e-51, 4.0680767287898916022e-67, 1.4185069655957361252e-83, + 5.595982714259923599e-36, 1.7634898158762432635e-52, 3.588705781024702988e-68, 5.9489775128085140685e-84, + 5.595982714259923599e-36, 1.7634898158762432635e-52, 3.588705781024702988e-68, 5.9489775128085140685e-84, + 2.5867171761548675786e-36, 1.7634898158762432635e-52, 3.588705781024702988e-68, 5.9489775128085140685e-84, + 1.0820844071023395684e-36, 1.7634898158762432635e-52, 3.588705781024702988e-68, 5.9489775128085140685e-84, + 3.2976802257607573031e-37, 9.3011872068621332399e-54, 1.113250147552460308e-69, 2.9286284920280944778e-86, + 3.2976802257607573031e-37, 9.3011872068621332399e-54, 1.113250147552460308e-69, 2.9286284920280944778e-86, + 1.4168892644450972904e-37, 9.3011872068621332399e-54, 1.113250147552460308e-69, 2.9286284920280944778e-86, + 4.7649378378726728402e-38, 9.3011872068621332399e-54, 1.113250147552460308e-69, 2.9286284920280944778e-86, + 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 2.6226236120327253511e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 7.8591368887290111994e-41, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 7.8591368887290111994e-41, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 3.2673620808294506214e-41, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 9.7147467687967058732e-42, 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257943935e-91, + 9.7147467687967058732e-42, 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257943935e-91, + 3.9750282589222551507e-42, 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257943935e-91, + 1.1051690039850297894e-42, 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257943935e-91, + 1.1051690039850297894e-42, 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257943935e-91, + 3.8770419025072344914e-43, 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257943935e-91, + 2.8971783383570358633e-44, -2.6168913164368963837e-61, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 2.8971783383570358633e-44, -2.6168913164368963837e-61, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 2.8971783383570358633e-44, -2.6168913164368963837e-61, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 2.8971783383570358633e-44, -2.6168913164368963837e-61, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 6.5510079543732854985e-45, -2.6168913164368963837e-61, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 6.5510079543732854985e-45, -2.6168913164368963837e-61, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 9.4581409707401690366e-46, 4.9461632249367446986e-62, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 9.4581409707401690366e-46, 4.9461632249367446986e-62, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 9.4581409707401690366e-46, 4.9461632249367446986e-62, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 2.451648649116083682e-46, 4.9461632249367446986e-62, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 2.451648649116083682e-46, 4.9461632249367446986e-62, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 7.0002556871006273225e-47, 1.0567786762735315635e-62, -6.1446417754639301152e-79, -1.5355611056488084652e-94, + 7.0002556871006273225e-47, 1.0567786762735315635e-62, -6.1446417754639301152e-79, -1.5355611056488084652e-94, + 2.6211979860855749482e-47, 8.4432539107728090768e-64, 1.9517662449371099233e-79, 2.62202614552995759e-95, + 4.3166913557804827486e-48, 8.4432539107728090768e-64, 1.9517662449371099233e-79, 2.62202614552995759e-95, + 4.3166913557804827486e-48, 8.4432539107728090768e-64, 1.9517662449371099233e-79, 2.62202614552995759e-95, + 4.3166913557804827486e-48, 8.4432539107728090768e-64, 1.9517662449371099233e-79, 2.62202614552995759e-95, + 1.5797802926460750146e-48, 2.3660905534865399025e-64, -7.2335760163150273591e-81, 2.8738690232659205689e-99, + 2.1132476107887107169e-49, 8.7154294504188118783e-66, 1.2001823382693912203e-81, 2.8738690232659205689e-99, + 2.1132476107887107169e-49, 8.7154294504188118783e-66, 1.2001823382693912203e-81, 2.8738690232659205689e-99, + 2.1132476107887107169e-49, 8.7154294504188118783e-66, 1.2001823382693912203e-81, 2.8738690232659205689e-99, + 4.0267819632970559834e-50, -7.8013829534098555144e-67, -1.1759240463442418271e-82, 2.8738690232659205689e-99, + 4.0267819632970559834e-50, -7.8013829534098555144e-67, -1.1759240463442418271e-82, 2.8738690232659205689e-99, + 4.0267819632970559834e-50, -7.8013829534098555144e-67, -1.1759240463442418271e-82, 2.8738690232659205689e-99, + 1.8885701952232994665e-50, -7.8013829534098555144e-67, -1.1759240463442418271e-82, 2.8738690232659205689e-99, + 8.1946431118642097069e-51, 1.5937536410989638719e-66, 1.459625439463388979e-82, 2.8738690232659205689e-99, + 2.8491136916798196016e-51, 4.0680767287898916022e-67, 1.4185069655957361252e-83, -7.8369062883735917115e-100, + 1.7634898158762432635e-52, 3.588705781024702988e-68, 5.9489775128085131541e-84, 1.0450891972142808004e-99, + 1.7634898158762432635e-52, 3.588705781024702988e-68, 5.9489775128085131541e-84, 1.0450891972142808004e-99, + 1.7634898158762432635e-52, 3.588705781024702988e-68, 5.9489775128085131541e-84, 1.0450891972142808004e-99, + 1.7634898158762432635e-52, 3.588705781024702988e-68, 5.9489775128085131541e-84, 1.0450891972142808004e-99, + 9.3011872068621332399e-54, 1.113250147552460308e-69, 2.9286284920280941206e-86, 2.1132026692048600853e-102, + 9.3011872068621332399e-54, 1.113250147552460308e-69, 2.9286284920280941206e-86, 2.1132026692048600853e-102, + 9.3011872068621332399e-54, 1.113250147552460308e-69, 2.9286284920280941206e-86, 2.1132026692048600853e-102, + 9.3011872068621332399e-54, 1.113250147552460308e-69, 2.9286284920280941206e-86, 2.1132026692048600853e-102, + 9.3011872068621332399e-54, 1.113250147552460308e-69, 2.9286284920280941206e-86, 2.1132026692048600853e-102, + 4.0809436324633147776e-54, -4.587677453735884283e-71, -2.8859500138942368532e-87, -5.6567402911297190423e-103, + 1.470821845263904967e-54, -4.587677453735884283e-71, -2.8859500138942368532e-87, -5.6567402911297190423e-103, + 1.6576095166419998917e-55, 2.6568658093254848067e-71, 5.1571087196495574384e-87, 3.2728487032630537605e-103, + 1.6576095166419998917e-55, 2.6568658093254848067e-71, 5.1571087196495574384e-87, 3.2728487032630537605e-103, + 1.6576095166419998917e-55, 2.6568658093254848067e-71, 5.1571087196495574384e-87, 3.2728487032630537605e-103, + 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.5242184730639744369e-90, 1.145584788913072936e-105, + 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.5242184730639744369e-90, 1.145584788913072936e-105, + 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.5242184730639744369e-90, 1.145584788913072936e-105, + 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.5242184730639744369e-90, 1.145584788913072936e-105, + 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.5242184730639744369e-90, 1.145584788913072936e-105, + 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.5242184730639744369e-90, 1.145584788913072936e-105, + 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.554706987098633963e-107, + 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.554706987098633963e-107, + 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.554706987098633963e-107, + 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.554706987098633963e-107, + 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.554706987098633963e-107, + 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.554706987098633963e-107, + 3.9565608646667614317e-59, 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.554706987098633963e-107, + 1.9651959757511960854e-59, 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.554706987098633963e-107, + 9.6951353129341363331e-60, 7.6368645294831185015e-76, 1.0603435429602168369e-91, 1.0451839188820145747e-108, + 4.7167230906452229674e-60, 7.6368645294831185015e-76, 1.0603435429602168369e-91, 1.0451839188820145747e-108, + 2.2275169795007668372e-60, 2.1097166542226745549e-76, 4.4670685979800101779e-92, 1.0451839188820145747e-108, + 9.8291392392853877215e-61, -6.5385728340754726503e-77, -1.3520652573660833788e-93, -2.3220403312043059402e-109, + 3.6061239614242446325e-61, 7.2792968540756372162e-77, 1.3988851821689310822e-92, 1.0451839188820145747e-108, + 4.9461632249367446986e-62, 3.7036201000008285821e-78, 5.6554937751584084315e-94, -1.9306041120023063932e-110, + 4.9461632249367446986e-62, 3.7036201000008285821e-78, 5.6554937751584084315e-94, -1.9306041120023063932e-110, + 4.9461632249367446986e-62, 3.7036201000008285821e-78, 5.6554937751584084315e-94, -1.9306041120023063932e-110, + 1.0567786762735315635e-62, -6.1446417754639301152e-79, -1.535561105648808199e-94, -1.9306041120023063932e-110, + 1.0567786762735315635e-62, -6.1446417754639301152e-79, -1.535561105648808199e-94, -1.9306041120023063932e-110, + 8.4432539107728090768e-64, 1.9517662449371099233e-79, 2.62202614552995759e-95, 6.5314563001514358328e-112, + 8.4432539107728090768e-64, 1.9517662449371099233e-79, 2.62202614552995759e-95, 6.5314563001514358328e-112, + 8.4432539107728090768e-64, 1.9517662449371099233e-79, 2.62202614552995759e-95, 6.5314563001514358328e-112, + 8.4432539107728090768e-64, 1.9517662449371099233e-79, 2.62202614552995759e-95, 6.5314563001514358328e-112, + 2.3660905534865399025e-64, -7.2335760163150273591e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, + 2.3660905534865399025e-64, -7.2335760163150273591e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, + 8.4679971416497210292e-65, -7.2335760163150273591e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, + 8.7154294504188118783e-66, 1.2001823382693912203e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, + 8.7154294504188118783e-66, 1.2001823382693912203e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, + 8.7154294504188118783e-66, 1.2001823382693912203e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, + 8.7154294504188118783e-66, 1.2001823382693912203e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, + 3.9676455775389135587e-66, 1.459625439463388979e-82, 2.8738690232659205689e-99, 1.8395411057335783574e-115, + 1.5937536410989638719e-66, 1.459625439463388979e-82, 2.8738690232659205689e-99, 1.8395411057335783574e-115, + 4.0680767287898916022e-67, 1.4185069655957361252e-83, -7.8369062883735917115e-100, -1.9081236411894110579e-116, + 4.0680767287898916022e-67, 1.4185069655957361252e-83, -7.8369062883735917115e-100, -1.9081236411894110579e-116, + 1.1007118082399544936e-67, 1.4185069655957361252e-83, -7.8369062883735917115e-100, -1.9081236411894110579e-116, + 1.1007118082399544936e-67, 1.4185069655957361252e-83, -7.8369062883735917115e-100, -1.9081236411894110579e-116, + 3.588705781024702988e-68, 5.9489775128085131541e-84, 1.0450891972142805974e-99, 1.8395411057335783574e-115, + 3.588705781024702988e-68, 5.9489775128085131541e-84, 1.0450891972142805974e-99, 1.8395411057335783574e-115, + 1.7341027056809927069e-68, 1.830931441234090934e-84, 1.3069928418846076386e-100, 3.1677600334418876704e-116, + 8.0680116800913756637e-69, -2.2809159455312046184e-85, -4.0748824503880445403e-101, -6.3915272253158644628e-117, + 3.4315039917320989315e-69, -2.2809159455312046184e-85, -4.0748824503880445403e-101, -6.3915272253158644628e-117, + 1.113250147552460308e-69, 2.9286284920280941206e-86, 2.1132026692048600853e-102, -4.6672632026740766185e-119, + 1.113250147552460308e-69, 2.9286284920280941206e-86, 2.1132026692048600853e-102, -4.6672632026740766185e-119, + 5.3368668650755071652e-70, 2.9286284920280941206e-86, 2.1132026692048600853e-102, -4.6672632026740766185e-119, + 2.4390495598509592076e-70, 2.9286284920280941206e-86, 2.1132026692048600853e-102, -4.6672632026740766185e-119, + 9.901409072386855505e-71, -2.8859500138942368532e-87, -5.6567402911297190423e-103, -4.6672632026740766185e-119, + 2.6568658093254848067e-71, 5.1571087196495574384e-87, 3.2728487032630532648e-103, 5.2465720993401781599e-119, + 2.6568658093254848067e-71, 5.1571087196495574384e-87, 3.2728487032630532648e-103, 5.2465720993401781599e-119, + 8.4572999356014273536e-72, 1.1355793528776598461e-87, 3.2728487032630532648e-103, 5.2465720993401781599e-119, + 8.4572999356014273536e-72, 1.1355793528776598461e-87, 3.2728487032630532648e-103, 5.2465720993401781599e-119, + 3.9294603961880721752e-72, 1.3019701118468578292e-88, -7.5747169634236195447e-105, -2.0152904854894729832e-121, + 1.6655406264813940833e-72, 1.3019701118468578292e-88, -7.5747169634236195447e-105, -2.0152904854894729832e-121, + 5.3358074162805516304e-73, 4.5242184730639744369e-90, 1.1455847889130727424e-105, 1.8573014293598455046e-121, + 5.3358074162805516304e-73, 4.5242184730639744369e-90, 1.1455847889130727424e-105, 1.8573014293598455046e-121, + 2.5059077041472040156e-73, 4.5242184730639744369e-90, 1.1455847889130727424e-105, 1.8573014293598455046e-121, + 1.0909578480805302081e-73, 4.5242184730639744369e-90, 1.1455847889130727424e-105, 1.8573014293598455046e-121, + 3.8348292004719330442e-74, 4.5242184730639744369e-90, 1.1455847889130727424e-105, 1.8573014293598455046e-121, + 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.5547069870986327528e-107, 1.6304246661326865276e-122, + 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.5547069870986327528e-107, 1.6304246661326865276e-122, + 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.5547069870986327528e-107, 1.6304246661326865276e-122, + 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.5547069870986327528e-107, 1.6304246661326865276e-122, + 7.6368645294831185015e-76, 1.0603435429602168369e-91, 1.0451839188820145747e-108, 4.2386081393205242443e-125, + 7.6368645294831185015e-76, 1.0603435429602168369e-91, 1.0451839188820145747e-108, 4.2386081393205242443e-125, + 2.1097166542226745549e-76, 4.4670685979800101779e-92, 1.0451839188820145747e-108, 4.2386081393205242443e-125, + 2.1097166542226745549e-76, 4.4670685979800101779e-92, 1.0451839188820145747e-108, 4.2386081393205242443e-125, + 7.2792968540756372162e-77, 1.3988851821689310822e-92, 1.0451839188820145747e-108, 4.2386081393205242443e-125, + 3.7036201000008285821e-78, 5.6554937751584084315e-94, -1.9306041120023063932e-110, 1.0223371855251472933e-126, + 3.7036201000008285821e-78, 5.6554937751584084315e-94, -1.9306041120023063932e-110, 1.0223371855251472933e-126, + 3.7036201000008285821e-78, 5.6554937751584084315e-94, -1.9306041120023063932e-110, 1.0223371855251472933e-126, + 3.7036201000008285821e-78, 5.6554937751584084315e-94, -1.9306041120023063932e-110, 1.0223371855251472933e-126, + 3.7036201000008285821e-78, 5.6554937751584084315e-94, -1.9306041120023063932e-110, 1.0223371855251472933e-126, + 1.5445779612272179051e-78, 8.6145718795359707834e-95, 7.3062078800278780675e-111, 1.0223371855251472933e-126, + 4.6505689184041232695e-79, 8.6145718795359707834e-95, 7.3062078800278780675e-111, 1.0223371855251472933e-126, + 4.6505689184041232695e-79, 8.6145718795359707834e-95, 7.3062078800278780675e-111, 1.0223371855251472933e-126, + 1.9517662449371099233e-79, 2.62202614552995759e-95, 6.5314563001514349095e-112, 9.9039323746573674262e-128, + 6.0236490820360325022e-80, -3.7424672147304925625e-96, -1.784871512364483542e-112, 6.7095375687163151728e-129, + 6.0236490820360325022e-80, -3.7424672147304925625e-96, -1.784871512364483542e-112, 6.7095375687163151728e-129, + 2.6501457402022643213e-80, 3.7482149527770239293e-96, 6.5314563001514349095e-112, 9.9039323746573674262e-128, + 9.6339406928538097998e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, + 1.2001823382693912203e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, + 1.2001823382693912203e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, + 1.2001823382693912203e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, + 1.459625439463388979e-82, 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, + 1.459625439463388979e-82, 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, + 1.459625439463388979e-82, 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, + 1.4185069655957361252e-83, -7.8369062883735917115e-100, -1.9081236411894107761e-116, -2.1796760241698337334e-132, + 1.4185069655957361252e-83, -7.8369062883735917115e-100, -1.9081236411894107761e-116, -2.1796760241698337334e-132, + 1.4185069655957361252e-83, -7.8369062883735917115e-100, -1.9081236411894107761e-116, -2.1796760241698337334e-132, + 1.4185069655957361252e-83, -7.8369062883735917115e-100, -1.9081236411894107761e-116, -2.1796760241698337334e-132, + 5.9489775128085131541e-84, 1.0450891972142805974e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, + 1.830931441234090934e-84, 1.3069928418846076386e-100, 3.1677600334418871069e-116, 3.4556869017247800778e-132, + 1.830931441234090934e-84, 1.3069928418846076386e-100, 3.1677600334418871069e-116, 3.4556869017247800778e-132, + 8.0141992334048515034e-85, 1.3069928418846076386e-100, 3.1677600334418871069e-116, 3.4556869017247800778e-132, + 2.8666416439368237283e-85, 1.6400545060233297363e-101, -4.6672632026740766185e-119, -3.755176715260116501e-136, + 2.9286284920280941206e-86, 2.1132026692048600853e-102, -4.6672632026740766185e-119, -3.755176715260116501e-136, + 2.9286284920280941206e-86, 2.1132026692048600853e-102, -4.6672632026740766185e-119, -3.755176715260116501e-136, + 2.9286284920280941206e-86, 2.1132026692048600853e-102, -4.6672632026740766185e-119, -3.755176715260116501e-136, + 2.9286284920280941206e-86, 2.1132026692048600853e-102, -4.6672632026740766185e-119, -3.755176715260116501e-136, + 1.3200167453193350837e-86, 2.1132026692048600853e-102, -4.6672632026740766185e-119, -3.755176715260116501e-136, + 5.1571087196495574384e-87, 3.2728487032630532648e-103, 5.2465720993401781599e-119, -3.755176715260116501e-136, + 1.1355793528776598461e-87, 3.2728487032630532648e-103, 5.2465720993401781599e-119, -3.755176715260116501e-136, + 1.1355793528776598461e-87, 3.2728487032630532648e-103, 5.2465720993401781599e-119, -3.755176715260116501e-136, + 1.3019701118468578292e-88, -7.5747169634236195447e-105, -2.0152904854894725532e-121, -3.1562414818576682143e-137, + 1.3019701118468578292e-88, -7.5747169634236195447e-105, -2.0152904854894725532e-121, -3.1562414818576682143e-137, + 1.3019701118468578292e-88, -7.5747169634236195447e-105, -2.0152904854894725532e-121, -3.1562414818576682143e-137, + 4.5242184730639744369e-90, 1.1455847889130727424e-105, 1.8573014293598452896e-121, 1.1431992269852683481e-137, + 4.5242184730639744369e-90, 1.1455847889130727424e-105, 1.8573014293598452896e-121, 1.1431992269852683481e-137, + 4.5242184730639744369e-90, 1.1455847889130727424e-105, 1.8573014293598452896e-121, 1.1431992269852683481e-137, + 4.5242184730639744369e-90, 1.1455847889130727424e-105, 1.8573014293598452896e-121, 1.1431992269852683481e-137, + 4.5242184730639744369e-90, 1.1455847889130727424e-105, 1.8573014293598452896e-121, 1.1431992269852683481e-137, + 5.969437008257942845e-91, 5.5547069870986327528e-107, 1.6304246661326865276e-122, 6.8339049774534162772e-139, + 5.969437008257942845e-91, 5.5547069870986327528e-107, 1.6304246661326865276e-122, 6.8339049774534162772e-139, + 5.969437008257942845e-91, 5.5547069870986327528e-107, 1.6304246661326865276e-122, 6.8339049774534162772e-139, + 1.0603435429602168369e-91, 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591188256e-141, + 1.0603435429602168369e-91, 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591188256e-141, + 1.0603435429602168369e-91, 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591188256e-141, + 4.4670685979800101779e-92, 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591188256e-141, + 1.3988851821689310822e-92, 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591188256e-141, + 1.3988851821689310822e-92, 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591188256e-141, + 6.3183932821616130831e-93, 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591188256e-141, + 2.4831640123977650651e-93, 1.9359195088038447797e-109, -4.8867691298577234423e-126, -2.0587960670007823264e-142, + 5.6554937751584084315e-94, -1.9306041120023063932e-110, 1.0223371855251471293e-126, 1.2214168761472102282e-142, + 5.6554937751584084315e-94, -1.9306041120023063932e-110, 1.0223371855251471293e-126, 1.2214168761472102282e-142, + 8.6145718795359707834e-95, 7.3062078800278780675e-111, 1.0223371855251471293e-126, 1.2214168761472102282e-142, + 8.6145718795359707834e-95, 7.3062078800278780675e-111, 1.0223371855251471293e-126, 1.2214168761472102282e-142, + 8.6145718795359707834e-95, 7.3062078800278780675e-111, 1.0223371855251471293e-126, 1.2214168761472102282e-142, + 2.62202614552995759e-95, 6.5314563001514349095e-112, 9.9039323746573674262e-128, -8.6629775332868987041e-145, + 2.62202614552995759e-95, 6.5314563001514349095e-112, 9.9039323746573674262e-128, -8.6629775332868987041e-145, + 1.1238897120284541253e-95, 6.5314563001514349095e-112, 9.9039323746573674262e-128, -8.6629775332868987041e-145, + 3.7482149527770239293e-96, 6.5314563001514349095e-112, 9.9039323746573674262e-128, -8.6629775332868987041e-145, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 1.0450891972142805974e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 1.3069928418846076386e-100, 3.1677600334418871069e-116, 3.4556869017247794521e-132, 8.5448727249069983612e-148, + 1.3069928418846076386e-100, 3.1677600334418871069e-116, 3.4556869017247794521e-132, 8.5448727249069983612e-148, + 1.3069928418846076386e-100, 3.1677600334418871069e-116, 3.4556869017247794521e-132, 8.5448727249069983612e-148, + 1.6400545060233297363e-101, -4.6672632026740766185e-119, -3.755176715260116501e-136, 2.1571619860435652883e-152, + 1.6400545060233297363e-101, -4.6672632026740766185e-119, -3.755176715260116501e-136, 2.1571619860435652883e-152, + 1.6400545060233297363e-101, -4.6672632026740766185e-119, -3.755176715260116501e-136, 2.1571619860435652883e-152, + 2.1132026692048600853e-102, -4.6672632026740766185e-119, -3.755176715260116501e-136, 2.1571619860435652883e-152, + 2.1132026692048600853e-102, -4.6672632026740766185e-119, -3.755176715260116501e-136, 2.1571619860435652883e-152, + 2.1132026692048600853e-102, -4.6672632026740766185e-119, -3.755176715260116501e-136, 2.1571619860435652883e-152, + 3.2728487032630532648e-103, 5.2465720993401781599e-119, -3.755176715260116501e-136, 2.1571619860435652883e-152, + 3.2728487032630532648e-103, 5.2465720993401781599e-119, -3.755176715260116501e-136, 2.1571619860435652883e-152, + 3.2728487032630532648e-103, 5.2465720993401781599e-119, -3.755176715260116501e-136, 2.1571619860435652883e-152, + 1.0404514546648604359e-103, 2.896544483330507019e-120, 3.1239284188885823808e-136, 2.1571619860435652883e-152, + 1.0404514546648604359e-103, 2.896544483330507019e-120, 3.1239284188885823808e-136, 2.1571619860435652883e-152, + 4.8235214251531210473e-104, 2.896544483330507019e-120, 3.1239284188885823808e-136, 2.1571619860435652883e-152, + 2.0330248644053793915e-104, 2.896544483330507019e-120, 3.1239284188885823808e-136, 2.1571619860435652883e-152, + 6.3777658403150887343e-105, -2.0152904854894725532e-121, -3.156241481857667737e-137, -7.0684085473731388916e-153, + 6.3777658403150887343e-105, -2.0152904854894725532e-121, -3.156241481857667737e-137, -7.0684085473731388916e-153, + 2.88964513938041089e-105, 5.7298933442091639924e-121, -3.156241481857667737e-137, -7.0684085473731388916e-153, + 1.1455847889130727424e-105, 1.8573014293598452896e-121, 1.1431992269852681095e-137, 2.4782675885631257398e-153, + 2.7355461367940366859e-106, -7.8994528064813712419e-123, -2.0037599452814940222e-138, 9.1598554579059548847e-155, + 2.7355461367940366859e-106, -7.8994528064813712419e-123, -2.0037599452814940222e-138, 9.1598554579059548847e-155, + 5.5547069870986327528e-107, 1.6304246661326865276e-122, 6.8339049774534147855e-139, 9.1598554579059548847e-155, + 5.5547069870986327528e-107, 1.6304246661326865276e-122, 6.8339049774534147855e-139, 9.1598554579059548847e-155, + 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, + 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, + 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, + 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, + 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, + 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, + 1.9359195088038447797e-109, -4.8867691298577234423e-126, -2.0587960670007819622e-142, -2.8326669474241479263e-158, + 1.9359195088038447797e-109, -4.8867691298577234423e-126, -2.0587960670007819622e-142, -2.8326669474241479263e-158, + 1.9359195088038447797e-109, -4.8867691298577234423e-126, -2.0587960670007819622e-142, -2.8326669474241479263e-158, + 8.7142954880180709975e-110, -4.8867691298577234423e-126, -2.0587960670007819622e-142, -2.8326669474241479263e-158, + 3.3918456880078814158e-110, 6.931443500908017045e-126, 1.1062055705591186799e-141, 1.1734404793201255869e-157, + 7.3062078800278780675e-111, 1.0223371855251471293e-126, 1.2214168761472102282e-142, 8.0910098773220312367e-159, + 7.3062078800278780675e-111, 1.0223371855251471293e-126, 1.2214168761472102282e-142, 8.0910098773220312367e-159, + 6.5314563001514349095e-112, 9.9039323746573674262e-128, -8.6629775332868972816e-145, -1.5987060076657616072e-160, + 6.5314563001514349095e-112, 9.9039323746573674262e-128, -8.6629775332868972816e-145, -1.5987060076657616072e-160, + 6.5314563001514349095e-112, 9.9039323746573674262e-128, -8.6629775332868972816e-145, -1.5987060076657616072e-160, + 6.5314563001514349095e-112, 9.9039323746573674262e-128, -8.6629775332868972816e-145, -1.5987060076657616072e-160, + 2.3732923938934761454e-112, 6.7095375687163138915e-129, 1.6963686085056791706e-144, 1.2464251916751375716e-160, + 2.9421044076449630171e-113, 6.7095375687163138915e-129, 1.6963686085056791706e-144, 1.2464251916751375716e-160, + 2.9421044076449630171e-113, 6.7095375687163138915e-129, 1.6963686085056791706e-144, 1.2464251916751375716e-160, + 2.9421044076449630171e-113, 6.7095375687163138915e-129, 1.6963686085056791706e-144, 1.2464251916751375716e-160, + 3.4325196623373878948e-114, 9.3892593260023063019e-130, 9.4702132359198537748e-146, 1.7950099192230045857e-161, + 3.4325196623373878948e-114, 9.3892593260023063019e-130, 9.4702132359198537748e-146, 1.7950099192230045857e-161, + 3.4325196623373878948e-114, 9.3892593260023063019e-130, 9.4702132359198537748e-146, 1.7950099192230045857e-161, + 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, 2.9106774506606945839e-164, + 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, 2.9106774506606945839e-164, + 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, 2.9106774506606945839e-164, + 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, 2.9106774506606945839e-164, + 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, 2.9106774506606945839e-164, + 8.2436437080731844263e-116, 1.4726412753514008951e-131, -3.9681466199873824165e-148, 2.9106774506606945839e-164, + 3.1677600334418871069e-116, 3.4556869017247794521e-132, 8.544872724906996972e-148, 1.6802919634942429241e-163, + 6.2981819612623816536e-117, 6.3800543877747317218e-133, 7.2423563434801054878e-149, 1.1741471776254779927e-164, + 6.2981819612623816536e-117, 6.3800543877747317218e-133, 7.2423563434801054878e-149, 1.1741471776254779927e-164, + 6.2981819612623816536e-117, 6.3800543877747317218e-133, 7.2423563434801054878e-149, 1.1741471776254779927e-164, + 3.1257546646178208289e-117, -6.6414926959353515111e-134, -5.7828074707888119584e-150, -1.2825052715093464343e-165, + 1.5395410162955400644e-117, -6.6414926959353515111e-134, -5.7828074707888119584e-150, -1.2825052715093464343e-165, + 7.4643419213439950602e-118, 1.0969016447485317626e-133, -5.7828074707888119584e-150, -1.2825052715093464343e-165, + 3.4988078005382940294e-118, 2.1637618757749825688e-134, -8.9490928918944555247e-151, -1.9717385086233606481e-166, + 1.5160407401354430737e-118, 2.1637618757749825688e-134, -8.9490928918944555247e-151, -1.9717385086233606481e-166, + 5.2465720993401781599e-119, -3.755176715260116501e-136, 2.1571619860435648643e-152, 6.3257905089784152346e-168, + 2.896544483330507019e-120, 3.1239284188885823808e-136, 2.1571619860435648643e-152, 6.3257905089784152346e-168, + 2.896544483330507019e-120, 3.1239284188885823808e-136, 2.1571619860435648643e-152, 6.3257905089784152346e-168, + 2.896544483330507019e-120, 3.1239284188885823808e-136, 2.1571619860435648643e-152, 6.3257905089784152346e-168, + 2.896544483330507019e-120, 3.1239284188885823808e-136, 2.1571619860435648643e-152, 6.3257905089784152346e-168, + 2.896544483330507019e-120, 3.1239284188885823808e-136, 2.1571619860435648643e-152, 6.3257905089784152346e-168, + 1.3475077173907800538e-120, -3.156241481857667737e-137, -7.0684085473731388916e-153, -3.3573283875161501977e-170, + 5.7298933442091639924e-121, -3.156241481857667737e-137, -7.0684085473731388916e-153, -3.3573283875161501977e-170, + 1.8573014293598452896e-121, 1.1431992269852681095e-137, 2.4782675885631257398e-153, -3.3573283875161501977e-170, + 1.8573014293598452896e-121, 1.1431992269852681095e-137, 2.4782675885631257398e-153, -3.3573283875161501977e-170, + 8.8915345064751572143e-122, 1.1431992269852681095e-137, 2.4782675885631257398e-153, -3.3573283875161501977e-170, + 4.0507946129135104481e-122, 6.8339049774534147855e-139, 9.1598554579059548847e-155, -4.5159745404911825673e-172, + 1.6304246661326865276e-122, 6.8339049774534147855e-139, 9.1598554579059548847e-155, -4.5159745404911825673e-172, + 4.2023969274227456735e-123, 6.8339049774534147855e-139, 9.1598554579059548847e-155, -4.5159745404911825673e-172, + 4.2023969274227456735e-123, 6.8339049774534147855e-139, 9.1598554579059548847e-155, -4.5159745404911825673e-172, + 1.1769344939467164447e-123, 1.1602886988632691941e-140, 3.0307583960570927356e-156, 5.8345524661064369683e-172, + 1.1769344939467164447e-123, 1.1602886988632691941e-140, 3.0307583960570927356e-156, 5.8345524661064369683e-172, + 4.2056888557770896953e-124, 1.1602886988632691941e-140, 3.0307583960570927356e-156, 5.8345524661064369683e-172, + 4.2386081393205242443e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, 1.2381024895275844856e-174, + 4.2386081393205242443e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, 1.2381024895275844856e-174, + 4.2386081393205242443e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, 1.2381024895275844856e-174, + 4.2386081393205242443e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, 1.2381024895275844856e-174, + 1.8749656131673758844e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, 1.2381024895275844856e-174, + 6.931443500908017045e-126, 1.1062055705591186799e-141, 1.1734404793201255869e-157, 1.2381024895275844856e-174, + 1.0223371855251471293e-126, 1.2214168761472102282e-142, 8.0910098773220302259e-159, 1.2381024895275844856e-174, + 1.0223371855251471293e-126, 1.2214168761472102282e-142, 8.0910098773220302259e-159, 1.2381024895275844856e-174, + 1.0223371855251471293e-126, 1.2214168761472102282e-142, 8.0910098773220302259e-159, 1.2381024895275844856e-174, + 2.8369889610228834887e-127, 4.0136364036021218058e-143, -1.0134099605688458828e-159, -2.5389576707476506925e-176, + 2.8369889610228834887e-127, 4.0136364036021218058e-143, -1.0134099605688458828e-159, -2.5389576707476506925e-176, + 9.9039323746573674262e-128, -8.6629775332868972816e-145, -1.5987060076657612913e-160, -2.5389576707476506925e-176, + 6.7095375687163138915e-129, 1.6963686085056791706e-144, 1.2464251916751375716e-160, 6.197724948400014906e-177, + 6.7095375687163138915e-129, 1.6963686085056791706e-144, 1.2464251916751375716e-160, 6.197724948400014906e-177, + 6.7095375687163138915e-129, 1.6963686085056791706e-144, 1.2464251916751375716e-160, 6.197724948400014906e-177, + 6.7095375687163138915e-129, 1.6963686085056791706e-144, 1.2464251916751375716e-160, 6.197724948400014906e-177, + 9.3892593260023063019e-130, 9.4702132359198537748e-146, 1.7950099192230045857e-161, -1.6991004655691155518e-177, + 9.3892593260023063019e-130, 9.4702132359198537748e-146, 1.7950099192230045857e-161, -1.6991004655691155518e-177, + 9.3892593260023063019e-130, 9.4702132359198537748e-146, 1.7950099192230045857e-161, -1.6991004655691155518e-177, + 2.175994780857201024e-130, 1.4618808551874518553e-146, 1.6802919634942426156e-163, 2.8330093736631818036e-179, + 2.175994780857201024e-130, 1.4618808551874518553e-146, 1.6802919634942426156e-163, 2.8330093736631818036e-179, + 3.7267864457092460442e-131, 4.6083930759590139305e-147, 1.6802919634942426156e-163, 2.8330093736631818036e-179, + 3.7267864457092460442e-131, 4.6083930759590139305e-147, 1.6802919634942426156e-163, 2.8330093736631818036e-179, + 3.7267864457092460442e-131, 4.6083930759590139305e-147, 1.6802919634942426156e-163, 2.8330093736631818036e-179, + 1.4726412753514008951e-131, -3.9681466199873824165e-148, 2.9106774506606941983e-164, 5.1948630316441296498e-180, + 3.4556869017247794521e-132, 8.544872724906996972e-148, 1.6802919634942426156e-163, 2.8330093736631818036e-179, + 3.4556869017247794521e-132, 8.544872724906996972e-148, 1.6802919634942426156e-163, 2.8330093736631818036e-179, + 6.3800543877747317218e-133, 7.2423563434801054878e-149, 1.1741471776254777999e-164, 1.3389912474795152755e-180, + 6.3800543877747317218e-133, 7.2423563434801054878e-149, 1.1741471776254777999e-164, 1.3389912474795152755e-180, + 6.3800543877747317218e-133, 7.2423563434801054878e-149, 1.1741471776254777999e-164, 1.3389912474795152755e-180, + 2.8579525590905986764e-133, -5.7828074707888119584e-150, -1.2825052715093464343e-165, -1.0696067158221530218e-181, + 1.0969016447485317626e-133, -5.7828074707888119584e-150, -1.2825052715093464343e-165, -1.0696067158221530218e-181, + 2.1637618757749825688e-134, -8.9490928918944555247e-151, -1.9717385086233606481e-166, 1.3535321672928907047e-182, + 2.1637618757749825688e-134, -8.9490928918944555247e-151, -1.9717385086233606481e-166, 1.3535321672928907047e-182, + 2.1637618757749825688e-134, -8.9490928918944555247e-151, -1.9717385086233606481e-166, 1.3535321672928907047e-182, + 1.0631050543111905033e-134, 1.5490398016102376505e-150, 3.4549185946116918017e-166, 1.3535321672928907047e-182, + 5.1277664357929471499e-135, 3.2706525621039604902e-151, 7.4159004299416557678e-167, 1.3535321672928907047e-182, + 2.3761243821334675971e-135, 3.2706525621039604902e-151, 7.4159004299416557678e-167, 1.3535321672928907047e-182, + 1.0003033553037281263e-135, 2.1571619860435648643e-152, 6.3257905089784152346e-168, 3.5607241064750984115e-184, + 3.1239284188885823808e-136, 2.1571619860435648643e-152, 6.3257905089784152346e-168, 3.5607241064750984115e-184, + 3.1239284188885823808e-136, 2.1571619860435648643e-152, 6.3257905089784152346e-168, 3.5607241064750984115e-184, + 1.4041521353514076604e-136, 2.1571619860435648643e-152, 6.3257905089784152346e-168, 3.5607241064750984115e-184, + 5.4426399358282049106e-137, 2.4782675885631257398e-153, -3.3573283875161501977e-170, 3.0568054078295488291e-186, + 1.1431992269852681095e-137, 2.4782675885631257398e-153, -3.3573283875161501977e-170, 3.0568054078295488291e-186, + 1.1431992269852681095e-137, 2.4782675885631257398e-153, -3.3573283875161501977e-170, 3.0568054078295488291e-186, + 6.8339049774534147855e-139, 9.1598554579059548847e-155, -4.5159745404911819927e-172, -4.5870810097328578981e-188, + 6.8339049774534147855e-139, 9.1598554579059548847e-155, -4.5159745404911819927e-172, -4.5870810097328578981e-188, + 6.8339049774534147855e-139, 9.1598554579059548847e-155, -4.5159745404911819927e-172, -4.5870810097328578981e-188, + 6.8339049774534147855e-139, 9.1598554579059548847e-155, -4.5159745404911819927e-172, -4.5870810097328578981e-188, + 1.1602886988632691941e-140, 3.0307583960570927356e-156, 5.8345524661064358191e-172, 6.9043123899963188689e-188, + 1.1602886988632691941e-140, 3.0307583960570927356e-156, 5.8345524661064358191e-172, 6.9043123899963188689e-188, + 1.1602886988632691941e-140, 3.0307583960570927356e-156, 5.8345524661064358191e-172, 6.9043123899963188689e-188, + 1.1602886988632691941e-140, 3.0307583960570927356e-156, 5.8345524661064358191e-172, 6.9043123899963188689e-188, + 1.1602886988632691941e-140, 3.0307583960570927356e-156, 5.8345524661064358191e-172, 6.9043123899963188689e-188, + 1.1602886988632691941e-140, 3.0307583960570927356e-156, 5.8345524661064358191e-172, 6.9043123899963188689e-188, + 1.1062055705591186799e-141, 1.1734404793201255869e-157, 1.2381024895275844856e-174, -8.4789520282639751913e-191, + 1.1062055705591186799e-141, 1.1734404793201255869e-157, 1.2381024895275844856e-174, -8.4789520282639751913e-191, + 1.1062055705591186799e-141, 1.1734404793201255869e-157, 1.2381024895275844856e-174, -8.4789520282639751913e-191, + 1.1062055705591186799e-141, 1.1734404793201255869e-157, 1.2381024895275844856e-174, -8.4789520282639751913e-191, + 4.5016298192952031469e-142, -2.8326669474241479263e-158, 1.2381024895275844856e-174, -8.4789520282639751913e-191, + 1.2214168761472102282e-142, 8.0910098773220302259e-159, 1.2381024895275844856e-174, -8.4789520282639751913e-191, + 1.2214168761472102282e-142, 8.0910098773220302259e-159, 1.2381024895275844856e-174, -8.4789520282639751913e-191, + 4.0136364036021218058e-143, -1.0134099605688458828e-159, -2.5389576707476506925e-176, -6.2404128071707654958e-193, + 4.0136364036021218058e-143, -1.0134099605688458828e-159, -2.5389576707476506925e-176, -6.2404128071707654958e-193, + 1.9635033141346264592e-143, -1.0134099605688458828e-159, -2.5389576707476506925e-176, -6.2404128071707654958e-193, + 9.3843676940087855824e-144, 1.2626949989038732076e-159, 2.2730883653953564668e-175, 2.7431118386590483722e-191, + 4.2590349703400483539e-144, 1.2464251916751375716e-160, 6.1977249484000140293e-177, 1.1294061984896458822e-192, + 1.6963686085056791706e-144, 1.2464251916751375716e-160, 6.1977249484000140293e-177, 1.1294061984896458822e-192, + 4.1503542758849472122e-145, -1.7614040799531193879e-161, -1.6991004655691153326e-177, -1.856794109153959173e-193, + 4.1503542758849472122e-145, -1.7614040799531193879e-161, -1.6991004655691153326e-177, -1.856794109153959173e-193, + 9.4702132359198537748e-146, 1.7950099192230045857e-161, -1.6991004655691153326e-177, -1.856794109153959173e-193, + 9.4702132359198537748e-146, 1.7950099192230045857e-161, -1.6991004655691153326e-177, -1.856794109153959173e-193, + 1.4618808551874518553e-146, 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, + 1.4618808551874518553e-146, 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, + 1.4618808551874518553e-146, 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, + 4.6083930759590139305e-147, 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, + 4.6083930759590139305e-147, 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, + 2.105789206980137775e-147, 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, + 8.544872724906996972e-148, 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, + 2.2883630524598079723e-148, 2.9106774506606941983e-164, 5.1948630316441287936e-180, 9.6685396110091032843e-196, + 2.2883630524598079723e-148, 2.9106774506606941983e-164, 5.1948630316441287936e-180, 9.6685396110091032843e-196, + 7.2423563434801054878e-149, 1.1741471776254777999e-164, 1.3389912474795150614e-180, 1.1067843414450286726e-196, + 7.2423563434801054878e-149, 1.1741471776254777999e-164, 1.3389912474795150614e-180, 1.1067843414450286726e-196, + 3.3320377982006123631e-149, 3.0588204110786950436e-165, 3.7502330143836152136e-181, 3.6564932749519464998e-198, + 1.3768785255608653665e-149, 3.0588204110786950436e-165, 3.7502330143836152136e-181, 3.6564932749519464998e-198, + 3.9929888924099219388e-150, -1.9717385086233606481e-166, 1.3535321672928907047e-182, 3.1205762277848031878e-199, + 3.9929888924099219388e-150, -1.9717385086233606481e-166, 1.3535321672928907047e-182, 3.1205762277848031878e-199, + 1.5490398016102376505e-150, 3.4549185946116918017e-166, 1.3535321672928907047e-182, 3.1205762277848031878e-199, + 3.2706525621039604902e-151, 7.4159004299416557678e-167, 1.3535321672928907047e-182, 3.1205762277848031878e-199, + 3.2706525621039604902e-151, 7.4159004299416557678e-167, 1.3535321672928907047e-182, 3.1205762277848031878e-199, + 2.1571619860435648643e-152, 6.3257905089784152346e-168, 3.5607241064750984115e-184, -1.4832196127821708615e-201, + 2.1571619860435648643e-152, 6.3257905089784152346e-168, 3.5607241064750984115e-184, -1.4832196127821708615e-201, + 2.1571619860435648643e-152, 6.3257905089784152346e-168, 3.5607241064750984115e-184, -1.4832196127821708615e-201, + 2.1571619860435648643e-152, 6.3257905089784152346e-168, 3.5607241064750984115e-184, -1.4832196127821708615e-201, + 2.4782675885631257398e-153, -3.3573283875161501977e-170, 3.0568054078295488291e-186, 1.4980560800565462618e-202, + 2.4782675885631257398e-153, -3.3573283875161501977e-170, 3.0568054078295488291e-186, 1.4980560800565462618e-202, + 2.4782675885631257398e-153, -3.3573283875161501977e-170, 3.0568054078295488291e-186, 1.4980560800565462618e-202, + 9.1598554579059548847e-155, -4.5159745404911819927e-172, -4.5870810097328572602e-188, -3.2905064432040069127e-204, + 9.1598554579059548847e-155, -4.5159745404911819927e-172, -4.5870810097328572602e-188, -3.2905064432040069127e-204, + 9.1598554579059548847e-155, -4.5159745404911819927e-172, -4.5870810097328572602e-188, -3.2905064432040069127e-204, + 9.1598554579059548847e-155, -4.5159745404911819927e-172, -4.5870810097328572602e-188, -3.2905064432040069127e-204, + 9.1598554579059548847e-155, -4.5159745404911819927e-172, -4.5870810097328572602e-188, -3.2905064432040069127e-204, + 1.7015147267057481414e-155, -4.5159745404911819927e-172, -4.5870810097328572602e-188, -3.2905064432040069127e-204, + 1.7015147267057481414e-155, -4.5159745404911819927e-172, -4.5870810097328572602e-188, -3.2905064432040069127e-204, + 1.7015147267057481414e-155, -4.5159745404911819927e-172, -4.5870810097328572602e-188, -3.2905064432040069127e-204, + 7.6922213530572229852e-156, -4.5159745404911819927e-172, -4.5870810097328572602e-188, -3.2905064432040069127e-204, + 3.0307583960570927356e-156, 5.8345524661064358191e-172, 6.9043123899963188689e-188, -3.2905064432040069127e-204, + 7.0002691755702864582e-157, 6.5928896280762691321e-173, 1.1586156901317304854e-188, -1.0100405885278530137e-205, + 7.0002691755702864582e-157, 6.5928896280762691321e-173, 1.1586156901317304854e-188, -1.0100405885278530137e-205, + 1.1734404793201255869e-157, 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.3321093418096261919e-207, + 1.1734404793201255869e-157, 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.3321093418096261919e-207, + 1.1734404793201255869e-157, 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.3321093418096261919e-207, + 4.4508689228885539715e-158, 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.3321093418096261919e-207, + 8.0910098773220302259e-159, 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.3321093418096261919e-207, + 8.0910098773220302259e-159, 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.3321093418096261919e-207, + 8.0910098773220302259e-159, 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.3321093418096261919e-207, + 3.5387999583765925506e-159, 2.2730883653953564668e-175, 2.7431118386590483722e-191, -1.3321093418096261919e-207, + 1.2626949989038732076e-159, 2.2730883653953564668e-175, 2.7431118386590483722e-191, -1.3321093418096261919e-207, + 1.2464251916751375716e-160, 6.1977249484000140293e-177, 1.1294061984896456875e-192, 2.2526486929936882202e-208, + 1.2464251916751375716e-160, 6.1977249484000140293e-177, 1.1294061984896456875e-192, 2.2526486929936882202e-208, + 1.2464251916751375716e-160, 6.1977249484000140293e-177, 1.1294061984896456875e-192, 2.2526486929936882202e-208, + 1.2464251916751375716e-160, 6.1977249484000140293e-177, 1.1294061984896456875e-192, 2.2526486929936882202e-208, + 5.3514239183991277695e-161, 6.1977249484000140293e-177, 1.1294061984896456875e-192, 2.2526486929936882202e-208, + 1.7950099192230045857e-161, -1.6991004655691153326e-177, -1.8567941091539589297e-193, -1.8074851186411640793e-209, + 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, + 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, + 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, + 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, + 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, + 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, + 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, + 2.9106774506606941983e-164, 5.1948630316441287936e-180, 9.6685396110091013832e-196, 1.7562785002189357559e-211, + 2.9106774506606941983e-164, 5.1948630316441287936e-180, 9.6685396110091013832e-196, 1.7562785002189357559e-211, + 2.9106774506606941983e-164, 5.1948630316441287936e-180, 9.6685396110091013832e-196, 1.7562785002189357559e-211, + 1.1741471776254777999e-164, 1.3389912474795150614e-180, 1.106784341445028435e-196, 3.3045982549756583552e-212, + 3.0588204110786950436e-165, 3.7502330143836152136e-181, 3.6564932749519464998e-198, 3.7097125405852507464e-214, + 3.0588204110786950436e-165, 3.7502330143836152136e-181, 3.6564932749519464998e-198, 3.7097125405852507464e-214, + 8.8815756978467430465e-166, 1.3403131492807310959e-181, 3.6564932749519464998e-198, 3.7097125405852507464e-214, + 8.8815756978467430465e-166, 1.3403131492807310959e-181, 3.6564932749519464998e-198, 3.7097125405852507464e-214, + 3.4549185946116918017e-166, 1.3535321672928907047e-182, 3.1205762277848031878e-199, -3.3569248349832580936e-217, + 7.4159004299416557678e-167, 1.3535321672928907047e-182, 3.1205762277848031878e-199, -3.3569248349832580936e-217, + 7.4159004299416557678e-167, 1.3535321672928907047e-182, 3.1205762277848031878e-199, -3.3569248349832580936e-217, + 6.3257905089784152346e-168, 3.5607241064750984115e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, + 6.3257905089784152346e-168, 3.5607241064750984115e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, + 6.3257905089784152346e-168, 3.5607241064750984115e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, + 6.3257905089784152346e-168, 3.5607241064750984115e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, + 2.0862146470760309789e-168, -1.146150630053972131e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, + 2.0862146470760309789e-168, -1.146150630053972131e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, + 1.026320681600434562e-168, 1.2072867382105631402e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, + 4.9637369886263658882e-169, 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, + 2.3140020749373754342e-169, 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, + 9.8913461809288020723e-170, 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, + 3.2670088967063259373e-170, 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, + 3.2670088967063259373e-170, 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, + 1.6109245756507072713e-170, -6.2044048008378732802e-187, -5.4322544592823556944e-203, 4.2491789852161138683e-219, + 7.8288241512289757055e-171, 1.2181824638728806485e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, + 3.6886133485899290404e-171, 2.9887099189454666024e-187, 4.774153170641553462e-203, 4.2491789852161138683e-219, + 1.6185079472704052482e-171, 2.9887099189454666024e-187, 4.774153170641553462e-203, 4.2491789852161138683e-219, + 5.8345524661064358191e-172, 6.9043123899963188689e-188, -3.2905064432040069127e-204, -9.1795828160190082842e-224, + 6.5928896280762691321e-173, 1.1586156901317304854e-188, -1.0100405885278530137e-205, -9.1795828160190082842e-224, + 6.5928896280762691321e-173, 1.1586156901317304854e-188, -1.0100405885278530137e-205, -9.1795828160190082842e-224, + 6.5928896280762691321e-173, 1.1586156901317304854e-188, -1.0100405885278530137e-205, -9.1795828160190082842e-224, + 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.332109341809626019e-207, -9.1795828160190082842e-224, + 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.332109341809626019e-207, -9.1795828160190082842e-224, + 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.332109341809626019e-207, -9.1795828160190082842e-224, + 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.332109341809626019e-207, -9.1795828160190082842e-224, + 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.332109341809626019e-207, -9.1795828160190082842e-224, + 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.332109341809626019e-207, -9.1795828160190082842e-224, + 2.2730883653953564668e-175, 2.7431118386590483722e-191, -1.332109341809626019e-207, -9.1795828160190082842e-224, + 2.2730883653953564668e-175, 2.7431118386590483722e-191, -1.332109341809626019e-207, -9.1795828160190082842e-224, + 2.2730883653953564668e-175, 2.7431118386590483722e-191, -1.332109341809626019e-207, -9.1795828160190082842e-224, + 1.0095962991602958391e-175, -6.2404128071707654958e-193, 3.0593092910744445285e-209, 5.4622616159087170031e-225, + 3.7785026604276538491e-176, -6.2404128071707654958e-193, 3.0593092910744445285e-209, 5.4622616159087170031e-225, + 6.1977249484000140293e-177, 1.1294061984896456875e-192, 2.2526486929936882202e-208, -5.3441928036578162463e-225, + 6.1977249484000140293e-177, 1.1294061984896456875e-192, 2.2526486929936882202e-208, -5.3441928036578162463e-225, + 6.1977249484000140293e-177, 1.1294061984896456875e-192, 2.2526486929936882202e-208, -5.3441928036578162463e-225, + 2.2493122414154495675e-177, 2.5268245888628466632e-193, 3.0593092910744445285e-209, 5.4622616159087170031e-225, + 2.7510588792316711745e-178, 3.3501523985444386676e-194, 6.2591208621664049475e-210, 5.9034406125450500218e-227, + 2.7510588792316711745e-178, 3.3501523985444386676e-194, 6.2591208621664049475e-210, 5.9034406125450500218e-227, + 2.7510588792316711745e-178, 3.3501523985444386676e-194, 6.2591208621664049475e-210, 5.9034406125450500218e-227, + 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, 9.9192633285681635836e-229, + 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, 9.9192633285681635836e-229, + 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, 9.9192633285681635836e-229, + 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, 9.9192633285681635836e-229, + 1.2906606599973359683e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, 9.9192633285681635836e-229, + 5.1948630316441287936e-180, 9.6685396110091013832e-196, 1.7562785002189355449e-211, 1.6821693549018732055e-227, + 1.3389912474795150614e-180, 1.106784341445028435e-196, 3.3045982549756578275e-212, 6.2685154049107876715e-228, + 1.3389912474795150614e-180, 1.106784341445028435e-196, 3.3045982549756578275e-212, 6.2685154049107876715e-228, + 3.7502330143836152136e-181, 3.6564932749519464998e-198, 3.7097125405852507464e-214, 2.5658818466966882188e-231, + 3.7502330143836152136e-181, 3.6564932749519464998e-198, 3.7097125405852507464e-214, 2.5658818466966882188e-231, + 1.3403131492807310959e-181, 3.6564932749519464998e-198, 3.7097125405852507464e-214, 2.5658818466966882188e-231, + 1.3535321672928907047e-182, 3.1205762277848031878e-199, -3.3569248349832580936e-217, -1.0577661142165146927e-233, + 1.3535321672928907047e-182, 3.1205762277848031878e-199, -3.3569248349832580936e-217, -1.0577661142165146927e-233, + 1.3535321672928907047e-182, 3.1205762277848031878e-199, -3.3569248349832580936e-217, -1.0577661142165146927e-233, + 1.3535321672928907047e-182, 3.1205762277848031878e-199, -3.3569248349832580936e-217, -1.0577661142165146927e-233, + 6.0043220944823941786e-183, 3.1205762277848031878e-199, -3.3569248349832580936e-217, -1.0577661142165146927e-233, + 2.2388223052591377446e-183, 3.1205762277848031878e-199, -3.3569248349832580936e-217, -1.0577661142165146927e-233, + 3.5607241064750984115e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 3.5607241064750984115e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 3.5607241064750984115e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 1.2072867382105631402e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 1.2181824638728806485e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 2.9887099189454666024e-187, 4.774153170641553462e-203, 4.2491789852161132393e-219, 7.4467067939231424594e-235, + 2.9887099189454666024e-187, 4.774153170641553462e-203, 4.2491789852161132393e-219, 7.4467067939231424594e-235, + 6.9043123899963188689e-188, -3.2905064432040069127e-204, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 6.9043123899963188689e-188, -3.2905064432040069127e-204, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 1.1586156901317304854e-188, -1.0100405885278530137e-205, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 1.1586156901317304854e-188, -1.0100405885278530137e-205, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 1.1586156901317304854e-188, -1.0100405885278530137e-205, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 4.4040360264865697732e-189, -1.0100405885278530137e-205, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 8.129755890712020335e-190, 9.8339840169166049336e-206, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 8.129755890712020335e-190, 9.8339840169166049336e-206, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 8.129755890712020335e-190, 9.8339840169166049336e-206, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 3.6409303439428119063e-190, -1.332109341809626019e-207, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 1.3965175705582071936e-190, -1.332109341809626019e-207, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 2.7431118386590483722e-191, -1.332109341809626019e-207, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 2.7431118386590483722e-191, -1.332109341809626019e-207, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 2.7431118386590483722e-191, -1.332109341809626019e-207, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 1.3403538552936701153e-191, 1.7826390804083638359e-207, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 6.389748636109812983e-192, 2.2526486929936882202e-208, -5.3441928036578156465e-225, -7.741539335184153052e-241, + 2.8828536776963681193e-192, 2.2526486929936882202e-208, -5.3441928036578156465e-225, -7.741539335184153052e-241, + 1.1294061984896456875e-192, 2.2526486929936882202e-208, -5.3441928036578156465e-225, -7.741539335184153052e-241, + 2.5268245888628466632e-193, 3.0593092910744445285e-209, 5.4622616159087170031e-225, 4.2560351759808952526e-241, + 2.5268245888628466632e-193, 3.0593092910744445285e-209, 5.4622616159087170031e-225, 4.2560351759808952526e-241, + 3.3501523985444386676e-194, 6.2591208621664049475e-210, 5.9034406125450490845e-227, 1.3186893776791012681e-242, + 3.3501523985444386676e-194, 6.2591208621664049475e-210, 5.9034406125450490845e-227, 1.3186893776791012681e-242, + 3.3501523985444386676e-194, 6.2591208621664049475e-210, 5.9034406125450490845e-227, 1.3186893776791012681e-242, + 6.1039071228393547627e-195, 1.7562785002189355449e-211, 1.6821693549018732055e-227, -8.7276385348052817035e-244, + 6.1039071228393547627e-195, 1.7562785002189355449e-211, 1.6821693549018732055e-227, -8.7276385348052817035e-244, + 6.1039071228393547627e-195, 1.7562785002189355449e-211, 1.6821693549018732055e-227, -8.7276385348052817035e-244, + 2.6792050150137250131e-195, 1.7562785002189355449e-211, 1.6821693549018732055e-227, -8.7276385348052817035e-244, + 9.6685396110091013832e-196, 1.7562785002189355449e-211, 1.6821693549018732055e-227, -8.7276385348052817035e-244, + 2.0416567491425607157e-177, 6.0959078275963141821e-193, 1.156336993964950812e-208, 2.7126166236326293347e-224, + 2.0416567491425607157e-177, 6.0959078275963141821e-193, 1.156336993964950812e-208, 2.7126166236326293347e-224, + 2.0416567491425607157e-177, 6.0959078275963141821e-193, 1.156336993964950812e-208, 2.7126166236326293347e-224, + 6.7450395650278649168e-179, 6.8432117823206978686e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, + 6.7450395650278649168e-179, 6.8432117823206978686e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, + 6.7450395650278649168e-179, 6.8432117823206978686e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, + 6.7450395650278649168e-179, 6.8432117823206978686e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, + 6.7450395650278649168e-179, 6.8432117823206978686e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, + 5.756447103644822603e-180, -6.1924333305615830735e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 5.756447103644822603e-180, -6.1924333305615830735e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 5.756447103644822603e-180, -6.1924333305615830735e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 5.756447103644822603e-180, -6.1924333305615830735e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 1.9005753194802080146e-180, -6.1924333305615830735e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 1.9005753194802080146e-180, -6.1924333305615830735e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 9.3660737343905436753e-181, -6.1924333305615830735e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 4.5462340041847754398e-181, -6.1924333305615830735e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 2.1363141390818913221e-181, -6.1924333305615830735e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 9.3135420653044926323e-182, -6.1924333305615830735e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 3.2887424025472810002e-182, 7.185309278132283136e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 2.7634257116867652192e-183, 4.9643797378534984559e-199, -9.4699347169310243473e-216, -9.2331809177749095611e-233, + 2.7634257116867652192e-183, 4.9643797378534984559e-199, -9.4699347169310243473e-216, -9.2331809177749095611e-233, + 2.7634257116867652192e-183, 4.9643797378534984559e-199, -9.4699347169310243473e-216, -9.2331809177749095611e-233, + 2.7634257116867652192e-183, 4.9643797378534984559e-199, -9.4699347169310243473e-216, -9.2331809177749095611e-233, + 8.806758170751374203e-184, 7.8383517263666503337e-200, 1.3736749441945438342e-215, -9.2331809177749095611e-233, + 8.806758170751374203e-184, 7.8383517263666503337e-200, 1.3736749441945438342e-215, -9.2331809177749095611e-233, + 4.0998834342223036605e-184, 7.8383517263666503337e-200, 1.3736749441945438342e-215, -9.2331809177749095611e-233, + 1.7464460659577689118e-184, 2.612671019845610006e-200, 2.1334073625072069974e-216, -9.2331809177749095611e-233, + 5.697273818255015375e-185, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 5.697273818255015375e-185, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 2.755477107924346286e-185, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 1.2845787527590117414e-185, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 5.4912957517634446918e-186, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 1.8140498638501083305e-186, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 1.8140498638501083305e-186, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 8.9473839187177424013e-187, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 4.3508265588260719497e-187, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 2.0525478788802367239e-187, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 9.0340853890731911095e-188, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 3.288388689208603045e-188, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 4.1554033927630885323e-189, -9.8582956929636044137e-206, -1.4280619485269765742e-221, 1.2171222696290252021e-237, + 4.1554033927630885323e-189, -9.8582956929636044137e-206, -1.4280619485269765742e-221, 1.2171222696290252021e-237, + 4.1554033927630885323e-189, -9.8582956929636044137e-206, -1.4280619485269765742e-221, 1.2171222696290252021e-237, + 5.643429553477207926e-190, 1.0076094209231528444e-205, 7.8509991660024955813e-222, 1.2171222696290252021e-237, + 5.643429553477207926e-190, 1.0076094209231528444e-205, 7.8509991660024955813e-222, 1.2171222696290252021e-237, + 5.643429553477207926e-190, 1.0076094209231528444e-205, 7.8509991660024955813e-222, 1.2171222696290252021e-237, + 1.1546040067079994973e-190, 1.0889925813396166947e-207, 2.4325525462765697993e-223, -1.1429360314275701698e-239, + 1.1546040067079994973e-190, 1.0889925813396166947e-207, 2.4325525462765697993e-223, -1.1429360314275701698e-239, + 3.2397620015697148712e-192, 3.1030547578511949035e-208, -1.609965144193984205e-224, -1.8313007053436627876e-240, + 3.2397620015697148712e-192, 3.1030547578511949035e-208, -1.609965144193984205e-224, -1.8313007053436627876e-240, + 3.2397620015697148712e-192, 3.1030547578511949035e-208, -1.609965144193984205e-224, -1.8313007053436627876e-240, + 3.2397620015697148712e-192, 3.1030547578511949035e-208, -1.609965144193984205e-224, -1.8313007053436627876e-240, + 3.2397620015697148712e-192, 3.1030547578511949035e-208, -1.609965144193984205e-224, -1.8313007053436627876e-240, + 3.2397620015697148712e-192, 3.1030547578511949035e-208, -1.609965144193984205e-224, -1.8313007053436627876e-240, + 1.4863145223629928288e-192, -7.9038076992129241506e-209, -1.609965144193984205e-224, -1.8313007053436627876e-240, + 6.0959078275963141821e-193, 1.156336993964950812e-208, 2.7126166236326293347e-224, -1.8313007053436627876e-240, + 1.712289129579509076e-193, 1.8297811202182925249e-209, 1.1003018740995688645e-226, 5.827891678485165325e-243, + 1.712289129579509076e-193, 1.8297811202182925249e-209, 1.1003018740995688645e-226, 5.827891678485165325e-243, + 6.1638445507530779946e-194, -6.0361608463951204924e-210, 1.1003018740995688645e-226, 5.827891678485165325e-243, + 6.8432117823206978686e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.029900079464340522e-245, + 6.8432117823206978686e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.029900079464340522e-245, + 6.8432117823206978686e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.029900079464340522e-245, + 6.8432117823206978686e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.029900079464340522e-245, + 3.418509674495068119e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.029900079464340522e-245, + 1.7061586205822532442e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.029900079464340522e-245, + 8.499830936258458068e-196, 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.029900079464340522e-245, + 4.218953301476420881e-196, 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.029900079464340522e-245, + 2.0785144840854027628e-196, -1.9512340798794268979e-214, -3.6162764918921692779e-230, -2.8387319855193022476e-246, + 1.008295075389893466e-196, -1.9512340798794268979e-214, -3.6162764918921692779e-230, -2.8387319855193022476e-246, + 4.7318537104213881764e-197, -1.9512340798794268979e-214, -3.6162764918921692779e-230, -2.8387319855193022476e-246, + 2.0563051886826149345e-197, -1.9512340798794268979e-214, -3.6162764918921692779e-230, -2.8387319855193022476e-246, + 7.185309278132283136e-198, -1.9512340798794268979e-214, -3.6162764918921692779e-230, -2.8387319855193022476e-246, + 4.9643797378534984559e-199, -9.4699347169310243473e-216, -9.2331809177749077733e-233, -1.4042876247421728101e-248, + 4.9643797378534984559e-199, -9.4699347169310243473e-216, -9.2331809177749077733e-233, -1.4042876247421728101e-248, + 4.9643797378534984559e-199, -9.4699347169310243473e-216, -9.2331809177749077733e-233, -1.4042876247421728101e-248, + 4.9643797378534984559e-199, -9.4699347169310243473e-216, -9.2331809177749077733e-233, -1.4042876247421728101e-248, + 7.8383517263666503337e-200, 1.3736749441945438342e-215, -9.2331809177749077733e-233, -1.4042876247421728101e-248, + 7.8383517263666503337e-200, 1.3736749441945438342e-215, -9.2331809177749077733e-233, -1.4042876247421728101e-248, + 7.8383517263666503337e-200, 1.3736749441945438342e-215, -9.2331809177749077733e-233, -1.4042876247421728101e-248, + 2.612671019845610006e-200, 2.1334073625072069974e-216, -9.2331809177749077733e-233, -1.4042876247421728101e-248, + 2.612671019845610006e-200, 2.1334073625072069974e-216, -9.2331809177749077733e-233, -1.4042876247421728101e-248, + 1.306250843215349634e-200, 2.1334073625072069974e-216, -9.2331809177749077733e-233, -1.4042876247421728101e-248, + 6.5304075490021959302e-201, 6.8298960257742791824e-217, 6.8696910062179237095e-233, 3.8349029251851101018e-249, + 3.2643571074265457254e-201, -4.2219277387461470355e-218, -1.753154605289404553e-234, -7.5861268822635538093e-251, + 1.6313318866387202604e-201, -4.2219277387461470355e-218, -1.753154605289404553e-234, -7.5861268822635538093e-251, + 8.1481927624480752786e-202, -4.2219277387461470355e-218, -1.753154605289404553e-234, -7.5861268822635538093e-251, + 4.0656297104785107096e-202, 4.8431832608149701961e-218, 8.3111403472061145651e-234, 1.6001805286092554504e-249, + 2.0243481844937293316e-202, 3.1062776103441183191e-219, 7.6291913283447536617e-235, 2.0347903074934629333e-250, + 1.0037074215013384159e-202, 3.1062776103441183191e-219, 7.6291913283447536617e-235, 2.0347903074934629333e-250, + 4.9338704000514295811e-203, 3.1062776103441183191e-219, 7.6291913283447536617e-235, 2.0347903074934629333e-250, + 2.3822684925704522921e-203, 3.1062776103441183191e-219, 7.6291913283447536617e-235, 2.0347903074934629333e-250, + 1.1064675388299639308e-203, 2.7343042298126957741e-220, 5.5273393987134252385e-236, 1.1432574793608782288e-251, + 4.6856706195971960852e-204, 2.7343042298126957741e-220, 5.5273393987134252385e-236, 1.1432574793608782288e-251, + 1.4961682352459748279e-204, -8.0675475439086544798e-221, -3.6970842501441777651e-237, -5.7032870362481275794e-253, + 1.4961682352459748279e-204, -8.0675475439086544798e-221, -3.6970842501441777651e-237, -5.7032870362481275794e-253, + 6.9879263915816924805e-205, 9.6377473771091526132e-221, 1.5959741828948633012e-236, 2.7031904319843495713e-252, + 3.0010484111426663515e-205, 7.8509991660024955813e-222, 1.2171222696290252021e-237, -2.4742181023285720738e-254, + 1.0076094209231528444e-205, 7.8509991660024955813e-222, 1.2171222696290252021e-237, -2.4742181023285720738e-254, + 1.0889925813396166947e-207, 2.4325525462765697993e-223, -1.1429360314275701698e-239, 8.3218722366085688343e-256, + 1.0889925813396166947e-207, 2.4325525462765697993e-223, -1.1429360314275701698e-239, 8.3218722366085688343e-256, + 1.0889925813396166947e-207, 2.4325525462765697993e-223, -1.1429360314275701698e-239, 8.3218722366085688343e-256, + 1.0889925813396166947e-207, 2.4325525462765697993e-223, -1.1429360314275701698e-239, 8.3218722366085688343e-256, + 1.0889925813396166947e-207, 2.4325525462765697993e-223, -1.1429360314275701698e-239, 8.3218722366085688343e-256, + 1.0889925813396166947e-207, 2.4325525462765697993e-223, -1.1429360314275701698e-239, 8.3218722366085688343e-256, + 1.0889925813396166947e-207, 2.4325525462765697993e-223, -1.1429360314275701698e-239, 8.3218722366085688343e-256, + 3.1030547578511949035e-208, -1.609965144193984205e-224, -1.8313007053436625212e-240, -2.3341145329525059632e-256, + 3.1030547578511949035e-208, -1.609965144193984205e-224, -1.8313007053436625212e-240, -2.3341145329525059632e-256, + 1.156336993964950812e-208, 2.7126166236326293347e-224, -1.8313007053436625212e-240, -2.3341145329525059632e-256, + 1.8297811202182925249e-209, 1.1003018740995688645e-226, 5.827891678485165325e-243, -3.1174271110208206547e-259, + 1.8297811202182925249e-209, 1.1003018740995688645e-226, 5.827891678485165325e-243, -3.1174271110208206547e-259, + 1.8297811202182925249e-209, 1.1003018740995688645e-226, 5.827891678485165325e-243, -3.1174271110208206547e-259, + 6.1308251778939023781e-210, 1.1003018740995688645e-226, 5.827891678485165325e-243, -3.1174271110208206547e-259, + 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 2.3568521170701555846e-212, -7.7818310317651142243e-229, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 1.1686698881356804311e-212, 1.8601114328504743806e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 5.7457877366844311816e-213, 5.409641648369814791e-229, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 2.7753321643482446169e-213, -1.1860946916976500828e-229, 6.3146909508553973881e-246, 1.2573885592501532045e-261, + 1.290104378180150675e-213, 2.1117734783360818049e-229, 4.2928382696354204061e-245, -2.8075477999879273582e-261, + 5.4749048509610403382e-214, 4.6283939331921604413e-230, 6.3146909508553973881e-246, 1.2573885592501532045e-261, + 1.7618353855408067201e-214, 5.060587206499956961e-231, 5.9380161562121075096e-247, -1.2904053011746964278e-263, + 1.7618353855408067201e-214, 5.060587206499956961e-231, 5.9380161562121075096e-247, -1.2904053011746964278e-263, + 8.3356801918574821257e-215, 5.060587206499956961e-231, 5.9380161562121075096e-247, -1.2904053011746964278e-263, + 3.6943433600821895879e-215, 5.060587206499956961e-231, 5.9380161562121075096e-247, -1.2904053011746964278e-263, + 1.3736749441945438342e-215, -9.2331809177749077733e-233, -1.4042876247421726117e-248, -9.9505977179164858712e-265, + 2.1334073625072069974e-216, -9.2331809177749077733e-233, -1.4042876247421726117e-248, -9.9505977179164858712e-265, + 2.1334073625072069974e-216, -9.2331809177749077733e-233, -1.4042876247421726117e-248, -9.9505977179164858712e-265, + 2.1334073625072069974e-216, -9.2331809177749077733e-233, -1.4042876247421726117e-248, -9.9505977179164858712e-265, + 6.8298960257742791824e-217, 6.8696910062179237095e-233, 3.8349029251851101018e-249, -2.6436684620390282645e-267, + 6.8298960257742791824e-217, 6.8696910062179237095e-233, 3.8349029251851101018e-249, -2.6436684620390282645e-267, + 3.2038516259498326923e-217, -1.1817449557784924788e-233, -6.3454186796659920093e-250, -2.6436684620390282645e-267, + 1.3908294260376086421e-217, 2.8439730252197153919e-233, 3.8349029251851101018e-249, -2.6436684620390282645e-267, + 4.8431832608149701961e-218, 8.3111403472061145651e-234, 1.6001805286092554504e-249, -2.6436684620390282645e-267, + 3.1062776103441183191e-219, 7.6291913283447536617e-235, 2.0347903074934629333e-250, -2.6436684620390282645e-267, + 3.1062776103441183191e-219, 7.6291913283447536617e-235, 2.0347903074934629333e-250, -2.6436684620390282645e-267, + 3.1062776103441183191e-219, 7.6291913283447536617e-235, 2.0347903074934629333e-250, -2.6436684620390282645e-267, + 3.1062776103441183191e-219, 7.6291913283447536617e-235, 2.0347903074934629333e-250, -2.6436684620390282645e-267, + 2.7343042298126957741e-220, 5.5273393987134252385e-236, 1.1432574793608780349e-251, 1.2329569415922591084e-267, + 2.7343042298126957741e-220, 5.5273393987134252385e-236, 1.1432574793608780349e-251, 1.2329569415922591084e-267, + 2.7343042298126957741e-220, 5.5273393987134252385e-236, 1.1432574793608780349e-251, 1.2329569415922591084e-267, + 2.7343042298126957741e-220, 5.5273393987134252385e-236, 1.1432574793608780349e-251, 1.2329569415922591084e-267, + 9.6377473771091526132e-221, 1.5959741828948633012e-236, 2.7031904319843490867e-252, 2.638005906844372114e-268, + 7.8509991660024955813e-222, 1.2171222696290252021e-237, -2.4742181023285720738e-254, -1.2030990169203137715e-270, + 7.8509991660024955813e-222, 1.2171222696290252021e-237, -2.4742181023285720738e-254, -1.2030990169203137715e-270, + 7.8509991660024955813e-222, 1.2171222696290252021e-237, -2.4742181023285720738e-254, -1.2030990169203137715e-270, + 7.8509991660024955813e-222, 1.2171222696290252021e-237, -2.4742181023285720738e-254, -1.2030990169203137715e-270, + 2.318094503184431479e-222, -1.1429360314275701698e-239, 8.3218722366085688343e-256, -2.0046830753539155726e-272, + 2.318094503184431479e-222, -1.1429360314275701698e-239, 8.3218722366085688343e-256, -2.0046830753539155726e-272, + 9.3486833747991514629e-223, -1.1429360314275701698e-239, 8.3218722366085688343e-256, -2.0046830753539155726e-272, + 2.4325525462765697993e-223, -1.1429360314275701698e-239, 8.3218722366085688343e-256, -2.0046830753539155726e-272, + 2.4325525462765697993e-223, -1.1429360314275701698e-239, 8.3218722366085688343e-256, -2.0046830753539155726e-272, + 7.0351983914592419146e-224, 7.766758903588374524e-240, 8.3218722366085688343e-256, -2.0046830753539155726e-272, + 7.0351983914592419146e-224, 7.766758903588374524e-240, 8.3218722366085688343e-256, -2.0046830753539155726e-272, + 2.7126166236326293347e-224, -1.8313007053436625212e-240, -2.3341145329525056675e-256, -2.0046830753539155726e-272, + 5.5132573971932232487e-225, 5.6821419688934674008e-241, 3.2988215943776273615e-257, 2.1353977370878701046e-273, + 5.5132573971932232487e-225, 5.6821419688934674008e-241, 3.2988215943776273615e-257, 2.1353977370878701046e-273, + 1.1003018740995688645e-226, 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, + 1.1003018740995688645e-226, 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, + 1.1003018740995688645e-226, 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, + 1.1003018740995688645e-226, 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, + 1.1003018740995688645e-226, 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, + 1.1003018740995688645e-226, 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, + 2.560476225709334075e-227, 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, + 2.560476225709334075e-227, 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, + 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, -1.472095602234059958e-277, + 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, -1.472095602234059958e-277, + 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, -1.472095602234059958e-277, + 1.8601114328504743806e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, -1.472095602234059958e-277, + 5.409641648369814791e-229, -3.0299000794643401155e-245, -2.8075477999879273582e-261, -1.472095602234059958e-277, + 5.409641648369814791e-229, -3.0299000794643401155e-245, -2.8075477999879273582e-261, -1.472095602234059958e-277, + 2.1117734783360818049e-229, 4.2928382696354204061e-245, -2.8075477999879273582e-261, -1.472095602234059958e-277, + 4.6283939331921604413e-230, 6.3146909508553973881e-246, 1.2573885592501529789e-261, 3.0408903374280139822e-277, + 4.6283939331921604413e-230, 6.3146909508553973881e-246, 1.2573885592501529789e-261, 3.0408903374280139822e-277, + 5.060587206499956961e-231, 5.9380161562121075096e-247, -1.2904053011746964278e-263, 8.7279092175580820317e-280, + 5.060587206499956961e-231, 5.9380161562121075096e-247, -1.2904053011746964278e-263, 8.7279092175580820317e-280, + 5.060587206499956961e-231, 5.9380161562121075096e-247, -1.2904053011746964278e-263, 8.7279092175580820317e-280, + 5.060587206499956961e-231, 5.9380161562121075096e-247, -1.2904053011746964278e-263, 8.7279092175580820317e-280, + 2.4841276986611042098e-231, 2.1712682097791944335e-248, 2.9746046415267896827e-264, -8.6516445844406224413e-282, + 1.1958979447416775482e-231, 2.1712682097791944335e-248, 2.9746046415267896827e-264, -8.6516445844406224413e-282, + 5.5178306778196421733e-232, 2.1712682097791944335e-248, 2.9746046415267896827e-264, -8.6516445844406224413e-282, + 2.2972562930210755192e-232, 2.1712682097791944335e-248, 2.9746046415267896827e-264, -8.6516445844406224413e-282, + 6.8696910062179237095e-233, 3.8349029251851101018e-249, -2.6436684620390282645e-267, -4.3807022524130141006e-284, + 6.8696910062179237095e-233, 3.8349029251851101018e-249, -2.6436684620390282645e-267, -4.3807022524130141006e-284, + 2.8439730252197153919e-233, 3.8349029251851101018e-249, -2.6436684620390282645e-267, -4.3807022524130141006e-284, + 8.3111403472061145651e-234, 1.6001805286092554504e-249, -2.6436684620390282645e-267, -4.3807022524130141006e-284, + 8.3111403472061145651e-234, 1.6001805286092554504e-249, -2.6436684620390282645e-267, -4.3807022524130141006e-284, + 3.2789928709583552854e-234, 4.8281933032132812475e-250, -2.6436684620390282645e-267, -4.3807022524130141006e-284, + 7.6291913283447536617e-235, 2.0347903074934629333e-250, -2.6436684620390282645e-267, -4.3807022524130141006e-284, + 7.6291913283447536617e-235, 2.0347903074934629333e-250, -2.6436684620390282645e-267, -4.3807022524130141006e-284, + 1.3390069830350552605e-235, -6.026193929640082176e-252, -7.0535576022338457803e-268, -4.3807022524130141006e-284, + 1.3390069830350552605e-235, -6.026193929640082176e-252, -7.0535576022338457803e-268, -4.3807022524130141006e-284, + 1.3390069830350552605e-235, -6.026193929640082176e-252, -7.0535576022338457803e-268, -4.3807022524130141006e-284, + 5.5273393987134252385e-236, 1.1432574793608780349e-251, 1.2329569415922591084e-267, -4.3807022524130141006e-284, + 1.5959741828948633012e-236, 2.7031904319843490867e-252, 2.638005906844371576e-268, 6.3790946999826013345e-284, + 1.5959741828948633012e-236, 2.7031904319843490867e-252, 2.638005906844371576e-268, 6.3790946999826013345e-284, + 6.1313287894022281692e-237, 5.2084434157824127104e-253, 2.1511502957481757317e-269, 3.2670891426006739096e-285, + 1.2171222696290252021e-237, -2.4742181023285720738e-254, -1.2030990169203137715e-270, -9.5347405022956042207e-287, + 1.2171222696290252021e-237, -2.4742181023285720738e-254, -1.2030990169203137715e-270, -9.5347405022956042207e-287, + 1.2171222696290252021e-237, -2.4742181023285720738e-254, -1.2030990169203137715e-270, -9.5347405022956042207e-287, + 6.0284645465737476297e-238, -2.4742181023285720738e-254, -1.2030990169203137715e-270, -9.5347405022956042207e-287, + 2.9570854717154947523e-238, 4.3456134301905148502e-254, 6.3684349745470443788e-270, -9.5347405022956042207e-287, + 1.4213959342863689955e-238, 9.3569766393097138822e-255, 2.5826679788133653036e-270, -9.5347405022956042207e-287, + 6.5355116557180594664e-239, 9.3569766393097138822e-255, 2.5826679788133653036e-270, -9.5347405022956042207e-287, + 2.6962878121452450746e-239, 8.3218722366085688343e-256, -2.0046830753539152442e-272, -3.4057806738724185961e-288, + 7.766758903588374524e-240, 8.3218722366085688343e-256, -2.0046830753539152442e-272, -3.4057806738724185961e-288, + 7.766758903588374524e-240, 8.3218722366085688343e-256, -2.0046830753539152442e-272, -3.4057806738724185961e-288, + 2.9677290991223565342e-240, -2.3341145329525056675e-256, -2.0046830753539152442e-272, -3.4057806738724185961e-288, + 5.6821419688934674008e-241, 3.2988215943776273615e-257, 2.1353977370878701046e-273, -1.2215123283371736879e-289, + 5.6821419688934674008e-241, 3.2988215943776273615e-257, 2.1353977370878701046e-273, -1.2215123283371736879e-289, + 5.6821419688934674008e-241, 3.2988215943776273615e-257, 2.1353977370878701046e-273, -1.2215123283371736879e-289, + 2.6827483411022054912e-241, 3.2988215943776273615e-257, 2.1353977370878701046e-273, -1.2215123283371736879e-289, + 1.1830515272065748694e-241, -3.117427111020820077e-259, -5.9718623963762788119e-275, 6.1155422068568954053e-291, + 4.3320312025875939195e-242, -3.117427111020820077e-259, -5.9718623963762788119e-275, 6.1155422068568954053e-291, + 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, 6.1155422068568954053e-291, + 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, 6.1155422068568954053e-291, + 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, 6.1155422068568954053e-291, + 1.1413391350613183311e-243, -5.1586784110844895013e-260, -1.9524039360882352712e-276, -2.9779654517181717279e-292, + 1.1413391350613183311e-243, -5.1586784110844895013e-260, -1.9524039360882352712e-276, -2.9779654517181717279e-292, + 1.1413391350613183311e-243, -5.1586784110844895013e-260, -1.9524039360882352712e-276, -2.9779654517181717279e-292, + 5.5552006713333735927e-244, 7.8491179384773690214e-260, -1.9524039360882352712e-276, -2.9779654517181717279e-292, + 2.6261053316934700345e-244, 1.345219763696439399e-260, 1.6579848156414234801e-276, 1.0303712682997740506e-292, + 1.1615576618735179302e-244, 1.345219763696439399e-260, 1.6579848156414234801e-276, 1.0303712682997740506e-292, + 4.2928382696354204061e-245, -2.8075477999879273582e-261, -1.472095602234059958e-277, 2.8287088295287585094e-294, + 6.3146909508553973881e-246, 1.2573885592501529789e-261, 3.0408903374280139822e-277, 2.8287088295287585094e-294, + 6.3146909508553973881e-246, 1.2573885592501529789e-261, 3.0408903374280139822e-277, 2.8287088295287585094e-294, + 6.3146909508553973881e-246, 1.2573885592501529789e-261, 3.0408903374280139822e-277, 2.8287088295287585094e-294, + 1.7379794826680480784e-246, 2.4115446944063306384e-262, 2.202741251392177696e-278, 2.8287088295287585094e-294, + 1.7379794826680480784e-246, 2.4115446944063306384e-262, 2.202741251392177696e-278, 2.8287088295287585094e-294, + 5.9380161562121075096e-247, -1.2904053011746964278e-263, 8.7279092175580810531e-280, 8.8634899828990930877e-296, + 2.1712682097791944335e-248, 2.9746046415267896827e-264, -8.6516445844406224413e-282, -5.0528699238150276549e-299, + 2.1712682097791944335e-248, 2.9746046415267896827e-264, -8.6516445844406224413e-282, -5.0528699238150276549e-299, + 2.1712682097791944335e-248, 2.9746046415267896827e-264, -8.6516445844406224413e-282, -5.0528699238150276549e-299, + 2.1712682097791944335e-248, 2.9746046415267896827e-264, -8.6516445844406224413e-282, -5.0528699238150276549e-299, + 2.1712682097791944335e-248, 2.9746046415267896827e-264, -8.6516445844406224413e-282, -5.0528699238150276549e-299, + 3.8349029251851101018e-249, -2.6436684620390282645e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 3.8349029251851101018e-249, -2.6436684620390282645e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 3.8349029251851101018e-249, -2.6436684620390282645e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 1.6001805286092554504e-249, -2.6436684620390282645e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 4.8281933032132812475e-250, -2.6436684620390282645e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 4.8281933032132812475e-250, -2.6436684620390282645e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 2.0347903074934629333e-250, -2.6436684620390282645e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 6.3808880963355377617e-251, -2.6436684620390282645e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 6.3808880963355377617e-251, -2.6436684620390282645e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 2.8891343516857640937e-251, 5.1095823452235464813e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 1.1432574793608780349e-251, 1.2329569415922591084e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 2.7031904319843490867e-252, 2.638005906844371576e-268, 6.3790946999826013345e-284, -2.7456019707854725967e-300, + 2.7031904319843490867e-252, 2.638005906844371576e-268, 6.3790946999826013345e-284, -2.7456019707854725967e-300, + 5.2084434157824127104e-253, 2.1511502957481757317e-269, 3.2670891426006735363e-285, 2.4084160842482777461e-301, + 5.2084434157824127104e-253, 2.1511502957481757317e-269, 3.2670891426006735363e-285, 2.4084160842482777461e-301, + 5.2084434157824127104e-253, 2.1511502957481757317e-269, 3.2670891426006735363e-285, 2.4084160842482777461e-301, + 2.4805108027747776379e-253, 2.1511502957481757317e-269, 3.2670891426006735363e-285, 2.4084160842482777461e-301, + 1.1165444962709601017e-253, 2.1511502957481757317e-269, 3.2670891426006735363e-285, 2.4084160842482777461e-301, + 4.3456134301905148502e-254, 6.3684349745470443788e-270, -9.5347405022956030541e-287, -1.5805886663557401565e-302, + 9.3569766393097138822e-255, 2.5826679788133653036e-270, -9.5347405022956030541e-287, -1.5805886663557401565e-302, + 9.3569766393097138822e-255, 2.5826679788133653036e-270, -9.5347405022956030541e-287, -1.5805886663557401565e-302, + 8.3218722366085688343e-256, -2.0046830753539152442e-272, -3.4057806738724185961e-288, 2.3458177946667328156e-304, + 8.3218722366085688343e-256, -2.0046830753539152442e-272, -3.4057806738724185961e-288, 2.3458177946667328156e-304, + 8.3218722366085688343e-256, -2.0046830753539152442e-272, -3.4057806738724185961e-288, 2.3458177946667328156e-304, + 8.3218722366085688343e-256, -2.0046830753539152442e-272, -3.4057806738724185961e-288, 2.3458177946667328156e-304, + 2.9938788518280315834e-256, -2.0046830753539152442e-272, -3.4057806738724185961e-288, 2.3458177946667328156e-304, + 3.2988215943776273615e-257, 2.1353977370878701046e-273, -1.2215123283371736879e-289, 6.7342163555358599277e-306, + 3.2988215943776273615e-257, 2.1353977370878701046e-273, -1.2215123283371736879e-289, 6.7342163555358599277e-306, + 3.2988215943776273615e-257, 2.1353977370878701046e-273, -1.2215123283371736879e-289, 6.7342163555358599277e-306, + 3.2988215943776273615e-257, 2.1353977370878701046e-273, -1.2215123283371736879e-289, 6.7342163555358599277e-306, + 1.6338236616337094706e-257, 2.1353977370878701046e-273, -1.2215123283371736879e-289, 6.7342163555358599277e-306, + 8.0132469526175071002e-258, 2.8687869620228451614e-274, -1.9537812801257956865e-290, 1.0380272777574237546e-306, + 3.850752120757712373e-258, 2.8687869620228451614e-274, -1.9537812801257956865e-290, 1.0380272777574237546e-306, + 1.7695047048278150093e-258, 2.8687869620228451614e-274, -1.9537812801257956865e-290, 1.0380272777574237546e-306, + 7.2888099686286655858e-259, 5.581381609158630475e-275, 6.1155422068568946933e-291, 1.0380272777574237546e-306, + 2.0856914288039227544e-259, -1.9524039360882352712e-276, -2.9779654517181712829e-292, -3.000817432603284506e-308, + 2.0856914288039227544e-259, -1.9524039360882352712e-276, -2.9779654517181712829e-292, -3.000817432603284506e-308, + 7.8491179384773690214e-260, -1.9524039360882352712e-276, -2.9779654517181712829e-292, -3.000817432603284506e-308, + 1.345219763696439399e-260, 1.6579848156414234801e-276, 1.0303712682997738281e-292, 1.4493302844111182601e-308, + 1.345219763696439399e-260, 1.6579848156414234801e-276, 1.0303712682997738281e-292, 1.4493302844111182601e-308, + 1.345219763696439399e-260, 1.6579848156414234801e-276, 1.0303712682997738281e-292, 1.4493302844111182601e-308, + 5.3223249184882342185e-261, -1.472095602234059958e-277, 2.8287088295287585094e-294, -1.0874435234232647519e-310, + 1.2573885592501529789e-261, 3.0408903374280139822e-277, 2.8287088295287585094e-294, -1.0874435234232647519e-310, + 1.2573885592501529789e-261, 3.0408903374280139822e-277, 2.8287088295287585094e-294, -1.0874435234232647519e-310, + 2.4115446944063306384e-262, 2.202741251392177696e-278, 2.8287088295287585094e-294, -1.0874435234232647519e-310, + 2.4115446944063306384e-262, 2.202741251392177696e-278, 2.8287088295287585094e-294, -1.0874435234232647519e-310, + 2.4115446944063306384e-262, 2.202741251392177696e-278, 2.8287088295287585094e-294, -1.0874435234232647519e-310, + 1.1412520821444306741e-262, -6.1787496089661820348e-279, -3.028042329852615431e-295, -2.182740474438892116e-311, + 5.0610577601348040988e-263, 7.9243314524777990283e-279, -3.028042329852615431e-295, -2.182740474438892116e-311, + 1.8853262294800541881e-263, 8.7279092175580810531e-280, 8.8634899828990930877e-296, -9.8167844904532653004e-314, + 2.9746046415267896827e-264, -8.6516445844406224413e-282, -5.0528699238150265939e-299, -1.3288013265921760399e-314, + 2.9746046415267896827e-264, -8.6516445844406224413e-282, -5.0528699238150265939e-299, -1.3288013265921760399e-314, + 2.9746046415267896827e-264, -8.6516445844406224413e-282, -5.0528699238150265939e-299, -1.3288013265921760399e-314, + 9.8977243486757054781e-265, -8.6516445844406224413e-282, -5.0528699238150265939e-299, -1.3288013265921760399e-314, + 9.8977243486757054781e-265, -8.6516445844406224413e-282, -5.0528699238150265939e-299, -1.3288013265921760399e-314, + 4.9356438320276576408e-265, -8.6516445844406224413e-282, -5.0528699238150265939e-299, -1.3288013265921760399e-314, + 2.4546035737036337221e-265, -8.6516445844406224413e-282, -5.0528699238150265939e-299, -1.3288013265921760399e-314, + 1.2140834445416214873e-265, 1.8893435613692150014e-281, 3.0075895258731974416e-297, -9.8167844904532653004e-314, + 5.9382337996061564537e-266, 5.1208955146257653156e-282, -5.0528699238150265939e-299, -1.3288013265921760399e-314, + 2.8369334767011265554e-266, 5.1208955146257653156e-282, -5.0528699238150265939e-299, -1.3288013265921760399e-314, + 1.2862833152486119506e-266, 1.6777604898591683764e-282, -5.0528699238150265939e-299, -1.3288013265921760399e-314, + 5.1095823452235464813e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, -2.5539572388808429997e-317, + 1.2329569415922591084e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, -2.5539572388808429997e-317, + 1.2329569415922591084e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, -2.5539572388808429997e-317, + 2.638005906844371576e-268, 6.3790946999826013345e-284, -2.7456019707854725967e-300, -2.5539572388808429997e-317, + 2.638005906844371576e-268, 6.3790946999826013345e-284, -2.7456019707854725967e-300, -2.5539572388808429997e-317, + 2.1511502957481757317e-269, 3.2670891426006735363e-285, 2.4084160842482773317e-301, 5.7350888195772519812e-317, + 2.1511502957481757317e-269, 3.2670891426006735363e-285, 2.4084160842482773317e-301, 5.7350888195772519812e-317, + 2.1511502957481757317e-269, 3.2670891426006735363e-285, 2.4084160842482773317e-301, 5.7350888195772519812e-317, + 2.1511502957481757317e-269, 3.2670891426006735363e-285, 2.4084160842482773317e-301, 5.7350888195772519812e-317, + 6.3684349745470443788e-270, -9.5347405022956030541e-287, -1.5805886663557401565e-302, 3.6369654387311681856e-319, + 6.3684349745470443788e-270, -9.5347405022956030541e-287, -1.5805886663557401565e-302, 3.6369654387311681856e-319, + 2.5826679788133653036e-270, -9.5347405022956030541e-287, -1.5805886663557401565e-302, 3.6369654387311681856e-319, + 6.8978448094652555593e-271, 1.1480487920352081009e-286, 7.5257037990230704094e-303, 3.6369654387311681856e-319, + 6.8978448094652555593e-271, 1.1480487920352081009e-286, 7.5257037990230704094e-303, 3.6369654387311681856e-319, + 2.1656360647981577662e-271, 9.7287370902823839435e-288, 1.6928061833779524157e-303, 3.6369654387311681856e-319, + 2.1656360647981577662e-271, 9.7287370902823839435e-288, 1.6928061833779524157e-303, 3.6369654387311681856e-319, + 9.825838786313830552e-272, 9.7287370902823839435e-288, 1.6928061833779524157e-303, 3.6369654387311681856e-319, + 3.9105778554799569972e-272, 9.7287370902823839435e-288, 1.6928061833779524157e-303, 3.6369654387311681856e-319, + 9.5294739006302120482e-273, -1.2215123283371736879e-289, 6.7342163555358599277e-306, -5.681754927174335258e-322, + 9.5294739006302120482e-273, -1.2215123283371736879e-289, 6.7342163555358599277e-306, -5.681754927174335258e-322, + 2.1353977370878701046e-273, -1.2215123283371736879e-289, 6.7342163555358599277e-306, -5.681754927174335258e-322, + 2.1353977370878701046e-273, -1.2215123283371736879e-289, 6.7342163555358599277e-306, -5.681754927174335258e-322, + 2.8687869620228451614e-274, -1.9537812801257956865e-290, 1.0380272777574237546e-306, 6.4228533959362050743e-323, +}; + +static const float Sleef_rempitabsp[] = { + 0.159154892, 5.112411827e-08, 3.626141271e-15, -2.036222915e-22, + 0.03415493667, 6.420638243e-09, 7.342738037e-17, 8.135951656e-24, + 0.03415493667, 6.420638243e-09, 7.342738037e-17, 8.135951656e-24, + 0.002904943191, -9.861969574e-11, -9.839336547e-18, -1.790215892e-24, + 0.002904943191, -9.861969574e-11, -9.839336547e-18, -1.790215892e-24, + 0.002904943191, -9.861969574e-11, -9.839336547e-18, -1.790215892e-24, + 0.002904943191, -9.861969574e-11, -9.839336547e-18, -1.790215892e-24, + 0.0009518179577, 1.342109202e-10, 1.791623576e-17, 1.518506657e-24, + 0.0009518179577, 1.342109202e-10, 1.791623576e-17, 1.518506657e-24, + 0.0004635368241, 1.779561221e-11, 4.038449606e-18, -1.358546052e-25, + 0.0002193961991, 1.779561221e-11, 4.038449606e-18, -1.358546052e-25, + 9.73258866e-05, 1.779561221e-11, 4.038449606e-18, -1.358546052e-25, + 3.62907449e-05, 3.243700447e-12, 5.690024473e-19, 7.09405479e-26, + 5.773168596e-06, 1.424711477e-12, 1.3532163e-19, 1.92417627e-26, + 5.773168596e-06, 1.424711477e-12, 1.3532163e-19, 1.92417627e-26, + 5.773168596e-06, 1.424711477e-12, 1.3532163e-19, 1.92417627e-26, + 1.958472239e-06, 5.152167755e-13, 1.3532163e-19, 1.92417627e-26, + 5.112411827e-08, 3.626141271e-15, -2.036222915e-22, 6.177847236e-30, + 5.112411827e-08, 3.626141271e-15, -2.036222915e-22, 6.177847236e-30, + 5.112411827e-08, 3.626141271e-15, -2.036222915e-22, 6.177847236e-30, + 5.112411827e-08, 3.626141271e-15, -2.036222915e-22, 6.177847236e-30, + 5.112411827e-08, 3.626141271e-15, -2.036222915e-22, 6.177847236e-30, + 5.112411827e-08, 3.626141271e-15, -2.036222915e-22, 6.177847236e-30, + 2.132179588e-08, 3.626141271e-15, -2.036222915e-22, 6.177847236e-30, + 6.420638243e-09, 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, + 6.420638243e-09, 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, + 2.695347945e-09, 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, + 8.327027956e-10, 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, + 8.327027956e-10, 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, + 3.670415083e-10, 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, + 1.342109202e-10, 1.791623576e-17, 1.518506361e-24, 2.613904e-31, + 1.779561221e-11, 4.038449606e-18, -1.358545683e-25, -3.443243946e-32, + 1.779561221e-11, 4.038449606e-18, -1.358545683e-25, -3.443243946e-32, + 1.779561221e-11, 4.038449606e-18, -1.358545683e-25, -3.443243946e-32, + 3.243700447e-12, 5.690024473e-19, 7.094053557e-26, 1.487136711e-32, + 3.243700447e-12, 5.690024473e-19, 7.094053557e-26, 1.487136711e-32, + 3.243700447e-12, 5.690024473e-19, 7.094053557e-26, 1.487136711e-32, + 1.424711477e-12, 1.3532163e-19, 1.924175961e-26, 2.545416018e-33, + 5.152167755e-13, 1.3532163e-19, 1.924175961e-26, 2.545416018e-33, + 6.046956013e-14, -2.036222915e-22, 6.177846108e-30, 1.082084378e-36, + 6.046956013e-14, -2.036222915e-22, 6.177846108e-30, 1.082084378e-36, + 6.046956013e-14, -2.036222915e-22, 6.177846108e-30, 1.082084378e-36, + 3.626141271e-15, -2.036222915e-22, 6.177846108e-30, 1.082084378e-36, + 3.626141271e-15, -2.036222915e-22, 6.177846108e-30, 1.082084378e-36, + 3.626141271e-15, -2.036222915e-22, 6.177846108e-30, 1.082084378e-36, + 3.626141271e-15, -2.036222915e-22, 6.177846108e-30, 1.082084378e-36, + 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, 6.296048013e-40, + 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, 6.296048013e-40, + 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, 6.296048013e-40, + 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, 6.296048013e-40, + 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, 6.296048013e-40, + 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, 6.296048013e-40, + 1.791623576e-17, 1.518506361e-24, 2.61390353e-31, 4.764937743e-38, + 1.791623576e-17, 1.518506361e-24, 2.61390353e-31, 4.764937743e-38, + 4.038449606e-18, -1.358545683e-25, -3.443243946e-32, 6.296048013e-40, + 4.038449606e-18, -1.358545683e-25, -3.443243946e-32, 6.296048013e-40, + 5.690024473e-19, 7.094053557e-26, 1.487136711e-32, 6.296048013e-40, + 5.690024473e-19, 7.094053557e-26, 1.487136711e-32, 6.296048013e-40, + 5.690024473e-19, 7.094053557e-26, 1.487136711e-32, 6.296048013e-40, + 1.3532163e-19, 1.924175961e-26, 2.545415467e-33, 6.296048013e-40, + 1.3532163e-19, 1.924175961e-26, 2.545415467e-33, 6.296048013e-40, + 2.690143217e-20, -1.452834402e-28, -6.441077673e-36, -1.764234767e-42, + 2.690143217e-20, -1.452834402e-28, -6.441077673e-36, -1.764234767e-42, + 2.690143217e-20, -1.452834402e-28, -6.441077673e-36, -1.764234767e-42, + 1.334890502e-20, -1.452834402e-28, -6.441077673e-36, -1.764234767e-42, + 6.572641438e-21, -1.452834402e-28, -6.441077673e-36, -1.764234767e-42, + 0.05874381959, 1.222115387e-08, 7.693612965e-16, 1.792054435e-22, + 0.02749382704, 4.77057327e-09, 7.693612965e-16, 1.792054435e-22, + 0.01186883077, 1.045283415e-09, 3.252721926e-16, 7.332633139e-23, + 0.00405633077, 1.045283415e-09, 3.252721926e-16, 7.332633139e-23, + 0.000150081818, -2.454155802e-12, 1.161414894e-20, 1.291319272e-27, + 0.000150081818, -2.454155802e-12, 1.161414894e-20, 1.291319272e-27, + 0.000150081818, -2.454155802e-12, 1.161414894e-20, 1.291319272e-27, + 0.000150081818, -2.454155802e-12, 1.161414894e-20, 1.291319272e-27, + 0.000150081818, -2.454155802e-12, 1.161414894e-20, 1.291319272e-27, + 2.801149822e-05, 4.821800945e-12, 8.789757674e-19, 1.208447639e-25, + 2.801149822e-05, 4.821800945e-12, 8.789757674e-19, 1.208447639e-25, + 2.801149822e-05, 4.821800945e-12, 8.789757674e-19, 1.208447639e-25, + 1.275271279e-05, 1.183823005e-12, 1.161414894e-20, 1.291319272e-27, + 5.12331826e-06, 1.183823005e-12, 1.161414894e-20, 1.291319272e-27, + 1.308621904e-06, 2.743283031e-13, 1.161414894e-20, 1.291319272e-27, + 1.308621904e-06, 2.743283031e-13, 1.161414894e-20, 1.291319272e-27, + 3.549478151e-07, 4.695462769e-14, 1.161414894e-20, 1.291319272e-27, + 3.549478151e-07, 4.695462769e-14, 1.161414894e-20, 1.291319272e-27, + 1.165292645e-07, 1.853292503e-14, 4.837885366e-21, 1.291319272e-27, + 1.165292645e-07, 1.853292503e-14, 4.837885366e-21, 1.291319272e-27, + 5.69246339e-08, 4.322073705e-15, 1.449754789e-21, 7.962890365e-29, + 2.712231151e-08, 4.322073705e-15, 1.449754789e-21, 7.962890365e-29, + 1.222115387e-08, 7.693612965e-16, 1.792054182e-22, 2.91418027e-29, + 4.77057327e-09, 7.693612965e-16, 1.792054182e-22, 2.91418027e-29, + 1.045283415e-09, 3.252721926e-16, 7.332632508e-23, 3.898253736e-30, + 1.045283415e-09, 3.252721926e-16, 7.332632508e-23, 3.898253736e-30, + 1.139611461e-10, 1.996093359e-17, 5.344349223e-25, 1.511644828e-31, + 1.139611461e-10, 1.996093359e-17, 5.344349223e-25, 1.511644828e-31, + 1.139611461e-10, 1.996093359e-17, 5.344349223e-25, 1.511644828e-31, + 1.139611461e-10, 1.996093359e-17, 5.344349223e-25, 1.511644828e-31, + 5.575349904e-11, 6.083145782e-18, 5.344349223e-25, 1.511644828e-31, + 2.664967552e-11, -8.557475018e-19, -8.595036458e-26, -2.139883875e-32, + 1.209775682e-11, 2.61369883e-18, 5.344349223e-25, 1.511644828e-31, + 4.821800945e-12, 8.789757674e-19, 1.208447639e-25, 3.253064536e-33, + 1.183823005e-12, 1.161414894e-20, 1.29131908e-27, 1.715766248e-34, + 1.183823005e-12, 1.161414894e-20, 1.29131908e-27, 1.715766248e-34, + 2.743283031e-13, 1.161414894e-20, 1.29131908e-27, 1.715766248e-34, +}; +#endif // #ifndef __SLEEF_REMPITAB__ + +#if !defined(__NVCC__) && ((defined(__SIZEOF_FLOAT128__) && __SIZEOF_FLOAT128__ == 16) || (defined(__linux__) && defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))) || (defined(__PPC64__) && defined(__GNUC__) && !defined(__clang__) && __GNUC__ >= 8)) +#define SLEEF_FLOAT128_IS_IEEEQP +#endif + +#if !defined(SLEEF_FLOAT128_IS_IEEEQP) && !defined(__NVCC__) && defined(__SIZEOF_LONG_DOUBLE__) && __SIZEOF_LONG_DOUBLE__ == 16 && (defined(__aarch64__) || defined(__zarch__)) +#define SLEEF_LONGDOUBLE_IS_IEEEQP +#endif + +#if !defined(Sleef_quad_DEFINED) +#define Sleef_quad_DEFINED +typedef struct { uint64_t x, y; } Sleef_uint64_2t; +#if defined(SLEEF_FLOAT128_IS_IEEEQP) +typedef __float128 Sleef_quad; +#define SLEEF_QUAD_C(x) (x ## Q) +#elif defined(SLEEF_LONGDOUBLE_IS_IEEEQP) +typedef long double Sleef_quad; +#define SLEEF_QUAD_C(x) (x ## L) +#else +typedef Sleef_uint64_2t Sleef_quad; +#endif +#endif + +extern const double Sleef_rempitabdp[]; + +static SLEEF_ALWAYS_INLINE vfloat64m1x4_t __riscv_vcreate_v_f64m1x4(vfloat64m1_t x, vfloat64m1_t y, vfloat64m1_t z, vfloat64m1_t w) { + vfloat64m1x4_t unused; + return __riscv_vset(__riscv_vset(__riscv_vset(__riscv_vset(unused, 0, x), 1, y), 2, z), 3, w); +} +static SLEEF_ALWAYS_INLINE vfloat64m2x4_t __riscv_vcreate_v_f64m2x4(vfloat64m2_t x, vfloat64m2_t y, vfloat64m2_t z, vfloat64m2_t w) { + vfloat64m2x4_t unused; + return __riscv_vset(__riscv_vset(__riscv_vset(__riscv_vset(unused, 0, x), 1, y), 2, z), 3, w); +} + +typedef vuint32m1_t rvv_vmask32; +typedef vuint64m1_t vmask_rvvm1_sleef; +typedef vbool32_t rvv_sp_vopmask_rvvm1_sleef; +typedef vbool64_t rvv_dp_vopmask_rvvm1_sleef; + +typedef vint32mf2_t vint_rvvm1_sleef; +typedef vint64m1_t vint64_rvvm1_sleef; +typedef vuint64m1_t vuint64_rvvm1_sleef; +typedef vfloat64m1_t vdouble_rvvm1_sleef; +typedef vfloat64m2_t vdouble2_rvvm1_sleef; +typedef vfloat64m4_t vdouble3_rvvm1_sleef; +typedef vfloat64m4_t dd2_rvvm1_sleef; +typedef vuint64m2_t vquad_rvvm1_sleef; +typedef vint32m2_t di_t_rvvm1_sleef; +typedef vint32m4_t ddi_t_rvvm1_sleef; +typedef vfloat32m1_t vfloat_rvvm1_sleef; +typedef vfloat32m2_t vfloat2_rvvm1_sleef; +typedef vfloat32m4_t df2_rvvm1_sleef; +typedef vint32m1_t vint2_rvvm1_sleef; +typedef vint32m2_t fi_t_rvvm1_sleef; +typedef vint32m4_t dfi_t_rvvm1_sleef; +typedef vuint64m1_t rvv_dp_vuint2; + +typedef vfloat64m1x4_t tdx_rvvm1_sleef; +typedef vfloat64m1x4_t tdi_t_rvvm1_sleef; + +typedef vquad_rvvm1_sleef vargquad_rvvm1_sleef; + +static SLEEF_ALWAYS_INLINE int vavailability_i_rvvm1_sleef(int name) { + + return (__riscv_vsetvlmax_e64m1() >= __riscv_vsetvlmax_e64m1()) ? 3 : 0; +} + +static SLEEF_ALWAYS_INLINE vfloat_rvvm1_sleef figetd_vf_di_rvvm1_sleef(fi_t_rvvm1_sleef d) { + return __riscv_vreinterpret_f32m1(__riscv_vget_i32m1(d, 0)); +} +static SLEEF_ALWAYS_INLINE vint2_rvvm1_sleef figeti_vi2_di_rvvm1_sleef(fi_t_rvvm1_sleef d) { + return __riscv_vget_i32m1(d, 1); +} +static SLEEF_ALWAYS_INLINE fi_t_rvvm1_sleef fisetdi_fi_vf_vi2_rvvm1_sleef(vfloat_rvvm1_sleef d, vint2_rvvm1_sleef i) { + vint2_rvvm1_sleef vdi = __riscv_vreinterpret_i32m1(d); + return __riscv_vset(__riscv_vlmul_ext_v_i32m1_i32m2(vdi), 1, i); +} +static SLEEF_ALWAYS_INLINE vfloat2_rvvm1_sleef dfigetdf_vf2_dfi_rvvm1_sleef(dfi_t_rvvm1_sleef d) { + return __riscv_vreinterpret_f32m2(__riscv_vget_i32m2(d, 0)); +} +static SLEEF_ALWAYS_INLINE vint2_rvvm1_sleef dfigeti_vi2_dfi_rvvm1_sleef(dfi_t_rvvm1_sleef d) { + return __riscv_vget_i32m1(d, 2); +} +static SLEEF_ALWAYS_INLINE dfi_t_rvvm1_sleef dfisetdfi_dfi_vf2_vi2_rvvm1_sleef(vfloat2_rvvm1_sleef v, vint2_rvvm1_sleef i) { + fi_t_rvvm1_sleef vi = __riscv_vreinterpret_i32m2(v); + fi_t_rvvm1_sleef ix = __riscv_vmv_v(__riscv_vlmul_ext_v_i32m1_i32m2(i), __riscv_vsetvlmax_e32m1()); + return __riscv_vset(__riscv_vlmul_ext_v_i32m2_i32m4(vi), 1, ix); +} +static SLEEF_ALWAYS_INLINE dfi_t_rvvm1_sleef dfisetdf_dfi_dfi_vf2_rvvm1_sleef(dfi_t_rvvm1_sleef dfi_rvvm1_sleef, vfloat2_rvvm1_sleef v) { + return __riscv_vset(dfi_rvvm1_sleef, 0, __riscv_vreinterpret_i32m2(v)); +} + +static SLEEF_ALWAYS_INLINE vfloat_rvvm1_sleef vf2getx_vf_vf2_rvvm1_sleef(vfloat2_rvvm1_sleef v) { + return __riscv_vget_f32m1(v, 0); +} +static SLEEF_ALWAYS_INLINE vfloat_rvvm1_sleef vf2gety_vf_vf2_rvvm1_sleef(vfloat2_rvvm1_sleef v) { + return __riscv_vget_f32m1(v, 1); +} +static SLEEF_ALWAYS_INLINE vfloat2_rvvm1_sleef vf2setxy_vf2_vf_vf_rvvm1_sleef(vfloat_rvvm1_sleef x, vfloat_rvvm1_sleef y) { + return __riscv_vset(__riscv_vlmul_ext_v_f32m1_f32m2(x), 1, y); +} +static SLEEF_ALWAYS_INLINE vfloat2_rvvm1_sleef vf2setx_vf2_vf2_vf_rvvm1_sleef(vfloat2_rvvm1_sleef v, vfloat_rvvm1_sleef d) { + return __riscv_vset(v, 0, d); +} +static SLEEF_ALWAYS_INLINE vfloat2_rvvm1_sleef vf2sety_vf2_vf2_vf_rvvm1_sleef(vfloat2_rvvm1_sleef v, vfloat_rvvm1_sleef d) { + return __riscv_vset(v, 1, d); +} + +static df2_rvvm1_sleef df2setab_df2_vf2_vf2_rvvm1_sleef(vfloat2_rvvm1_sleef a, vfloat2_rvvm1_sleef b) { + return __riscv_vset(__riscv_vlmul_ext_v_f32m2_f32m4(a), 1, b); +} +static vfloat2_rvvm1_sleef df2geta_vf2_df2_rvvm1_sleef(df2_rvvm1_sleef d) { return __riscv_vget_f32m2(d, 0); } +static vfloat2_rvvm1_sleef df2getb_vf2_df2_rvvm1_sleef(df2_rvvm1_sleef d) { return __riscv_vget_f32m2(d, 1); } +static SLEEF_ALWAYS_INLINE vint2_rvvm1_sleef vreinterpret_vi2_vf_rvvm1_sleef(vfloat_rvvm1_sleef vf) { + return __riscv_vreinterpret_i32m1(vf); +} +static SLEEF_ALWAYS_INLINE vfloat_rvvm1_sleef vreinterpret_vf_vi2_rvvm1_sleef(vint2_rvvm1_sleef vi) { + return __riscv_vreinterpret_f32m1(vi); +} + +static SLEEF_ALWAYS_INLINE vfloat_rvvm1_sleef vcast_vf_f_rvvm1_sleef(float f) { + return __riscv_vfmv_v_f_f32m1(f, (__riscv_vsetvlmax_e32m1())); +} +static SLEEF_ALWAYS_INLINE vfloat_rvvm1_sleef vrint_vf_vf_rvvm1_sleef(vfloat_rvvm1_sleef vd_rvvm1_sleef) { + return __riscv_vfcvt_f_x_v_f32m1(__riscv_vfcvt_x_f_v_i32m1_rm(vd_rvvm1_sleef, __RISCV_FRM_RNE, (__riscv_vsetvlmax_e32m1())), (__riscv_vsetvlmax_e32m1())); +} +static SLEEF_ALWAYS_INLINE vfloat_rvvm1_sleef vcast_vf_vi2_rvvm1_sleef(vint2_rvvm1_sleef vi) { + return __riscv_vfcvt_f(vi, (__riscv_vsetvlmax_e32m1())); +} +static SLEEF_ALWAYS_INLINE vint2_rvvm1_sleef vcast_vi2_i_rvvm1_sleef(int i) { + return __riscv_vmv_v_x_i32m1(i, (__riscv_vsetvlmax_e32m1())); +} +static SLEEF_ALWAYS_INLINE vint2_rvvm1_sleef vrint_vi2_vf_rvvm1_sleef(vfloat_rvvm1_sleef vf) { + return __riscv_vfcvt_x_f_v_i32m1_rm(vf, __RISCV_FRM_RNE, (__riscv_vsetvlmax_e32m1())); +} +static SLEEF_ALWAYS_INLINE vint2_rvvm1_sleef vtruncate_vi2_vf_rvvm1_sleef(vfloat_rvvm1_sleef vf) { + return __riscv_vfcvt_rtz_x(vf, (__riscv_vsetvlmax_e32m1())); +} +static SLEEF_ALWAYS_INLINE vfloat_rvvm1_sleef vtruncate_vf_vf_rvvm1_sleef(vfloat_rvvm1_sleef vf) { + return vcast_vf_vi2_rvvm1_sleef(vtruncate_vi2_vf_rvvm1_sleef(vf)); +} + +static SLEEF_ALWAYS_INLINE vfloat_rvvm1_sleef vload_vf_p_rvvm1_sleef(const float *ptr) { + return __riscv_vle32_v_f32m1(ptr, (__riscv_vsetvlmax_e32m1())); +} +static SLEEF_ALWAYS_INLINE vfloat_rvvm1_sleef vloadu_vf_p_rvvm1_sleef(const float *ptr) { + return __riscv_vle32_v_f32m1(ptr, (__riscv_vsetvlmax_e32m1())); +} +static SLEEF_ALWAYS_INLINE void vstore_v_p_vf_rvvm1_sleef(float *ptr, vfloat_rvvm1_sleef v) { + __riscv_vse32(ptr, v, (__riscv_vsetvlmax_e32m1())); +} +static SLEEF_ALWAYS_INLINE void vstoreu_v_p_vf_rvvm1_sleef(float *ptr, vfloat_rvvm1_sleef v) { + __riscv_vse32(ptr, v, (__riscv_vsetvlmax_e32m1())); +} +static SLEEF_ALWAYS_INLINE void vstoreu_v_p_vi2_rvvm1_sleef(int32_t *ptr, vint2_rvvm1_sleef v) { + __riscv_vse32(ptr, v, (__riscv_vsetvlmax_e32m1())); +} +static SLEEF_ALWAYS_INLINE vfloat_rvvm1_sleef vgather_vf_p_vi2_rvvm1_sleef(const float *ptr, vint2_rvvm1_sleef vi2) { + return __riscv_vluxei32(ptr, __riscv_vmul(__riscv_vreinterpret_u32m1(vi2), sizeof(float), (__riscv_vsetvlmax_e32m1())), (__riscv_vsetvlmax_e32m1())); +} + +static SLEEF_ALWAYS_INLINE vfloat_rvvm1_sleef vadd_vf_vf_vf_rvvm1_sleef(vfloat_rvvm1_sleef x, vfloat_rvvm1_sleef y) { + return __riscv_vfadd(x, y, (__riscv_vsetvlmax_e32m1())); +} +static SLEEF_ALWAYS_INLINE vfloat_rvvm1_sleef vsub_vf_vf_vf_rvvm1_sleef(vfloat_rvvm1_sleef x, vfloat_rvvm1_sleef y) { + return __riscv_vfsub(x, y, (__riscv_vsetvlmax_e32m1())); +} +static SLEEF_ALWAYS_INLINE vfloat_rvvm1_sleef vmul_vf_vf_vf_rvvm1_sleef(vfloat_rvvm1_sleef x, vfloat_rvvm1_sleef y) { + return __riscv_vfmul(x, y, (__riscv_vsetvlmax_e32m1())); +} +static SLEEF_ALWAYS_INLINE vfloat_rvvm1_sleef vdiv_vf_vf_vf_rvvm1_sleef(vfloat_rvvm1_sleef x, vfloat_rvvm1_sleef y) { + return __riscv_vfdiv(x, y, (__riscv_vsetvlmax_e32m1())); +} +static SLEEF_ALWAYS_INLINE vfloat_rvvm1_sleef vmax_vf_vf_vf_rvvm1_sleef(vfloat_rvvm1_sleef x, vfloat_rvvm1_sleef y) { + return __riscv_vfmax(x, y, (__riscv_vsetvlmax_e32m1())); +} +static SLEEF_ALWAYS_INLINE vfloat_rvvm1_sleef vmin_vf_vf_vf_rvvm1_sleef(vfloat_rvvm1_sleef x, vfloat_rvvm1_sleef y) { + return __riscv_vfmin(x, y, (__riscv_vsetvlmax_e32m1())); +} +static SLEEF_ALWAYS_INLINE vfloat_rvvm1_sleef vrec_vf_vf_rvvm1_sleef(vfloat_rvvm1_sleef d) { + return __riscv_vfdiv(vcast_vf_f_rvvm1_sleef(1.0f), d, (__riscv_vsetvlmax_e32m1())); +} +static SLEEF_ALWAYS_INLINE vfloat_rvvm1_sleef vsqrt_vf_vf_rvvm1_sleef(vfloat_rvvm1_sleef d) { + return __riscv_vfsqrt(d, (__riscv_vsetvlmax_e32m1())); +} + +static SLEEF_ALWAYS_INLINE vfloat_rvvm1_sleef vmla_vf_vf_vf_vf_rvvm1_sleef(vfloat_rvvm1_sleef x, vfloat_rvvm1_sleef y, vfloat_rvvm1_sleef z) { + return __riscv_vfmadd(x, y, z, (__riscv_vsetvlmax_e32m1())); +} + +static SLEEF_ALWAYS_INLINE vfloat_rvvm1_sleef vmlanp_vf_vf_vf_vf_rvvm1_sleef(vfloat_rvvm1_sleef x, vfloat_rvvm1_sleef y, vfloat_rvvm1_sleef z) { + return __riscv_vfnmsub(x, y, z, (__riscv_vsetvlmax_e32m1())); +} +static SLEEF_ALWAYS_INLINE vfloat_rvvm1_sleef vmlapn_vf_vf_vf_vf_rvvm1_sleef(vfloat_rvvm1_sleef x, vfloat_rvvm1_sleef y, vfloat_rvvm1_sleef z) { + return __riscv_vfmsub(x, y, z, (__riscv_vsetvlmax_e32m1())); +} + +static SLEEF_ALWAYS_INLINE vfloat_rvvm1_sleef vfma_vf_vf_vf_vf_rvvm1_sleef(vfloat_rvvm1_sleef x, vfloat_rvvm1_sleef y, vfloat_rvvm1_sleef z) { + return __riscv_vfmadd(x, y, z, (__riscv_vsetvlmax_e32m1())); +} +static SLEEF_ALWAYS_INLINE vfloat_rvvm1_sleef vfmanp_vf_vf_vf_vf_rvvm1_sleef(vfloat_rvvm1_sleef x, vfloat_rvvm1_sleef y, vfloat_rvvm1_sleef z) { + return __riscv_vfnmsub(x, y, z, (__riscv_vsetvlmax_e32m1())); +} +static SLEEF_ALWAYS_INLINE vfloat_rvvm1_sleef vfmapn_vf_vf_vf_vf_rvvm1_sleef(vfloat_rvvm1_sleef x, vfloat_rvvm1_sleef y, vfloat_rvvm1_sleef z) { + return __riscv_vfmsub(x, y, z, (__riscv_vsetvlmax_e32m1())); +} + +static SLEEF_ALWAYS_INLINE vfloat_rvvm1_sleef vmulsign_vf_vf_vf_rvvm1_sleef(vfloat_rvvm1_sleef x, vfloat_rvvm1_sleef y) { + return __riscv_vfsgnjx(x, y, (__riscv_vsetvlmax_e32m1())); +} +static SLEEF_ALWAYS_INLINE vfloat_rvvm1_sleef vcopysign_vf_vf_vf_rvvm1_sleef(vfloat_rvvm1_sleef x, vfloat_rvvm1_sleef y) { + return __riscv_vfsgnj(x, y, (__riscv_vsetvlmax_e32m1())); +} +static SLEEF_ALWAYS_INLINE vfloat_rvvm1_sleef vsign_vf_vf_rvvm1_sleef(vfloat_rvvm1_sleef f) { + return __riscv_vfsgnj(__riscv_vfmv_v_f_f32m1(1.0f, (__riscv_vsetvlmax_e32m1())), f, (__riscv_vsetvlmax_e32m1())); +} +static SLEEF_ALWAYS_INLINE vfloat_rvvm1_sleef vorsign_vf_vf_vf_rvvm1_sleef(vfloat_rvvm1_sleef x, vfloat_rvvm1_sleef y) { + vint2_rvvm1_sleef xi = __riscv_vreinterpret_i32m1(x); + vint2_rvvm1_sleef yi = __riscv_vreinterpret_i32m1(y); + vint2_rvvm1_sleef xioryi = __riscv_vor(xi, yi, (__riscv_vsetvlmax_e32m1())); + vfloat_rvvm1_sleef xory = __riscv_vreinterpret_f32m1(xioryi); + return __riscv_vfsgnj(x, xory, (__riscv_vsetvlmax_e32m1())); +} +static SLEEF_ALWAYS_INLINE vfloat_rvvm1_sleef vabs_vf_vf_rvvm1_sleef(vfloat_rvvm1_sleef f) { + return __riscv_vfabs(f, (__riscv_vsetvlmax_e32m1())); +} +static SLEEF_ALWAYS_INLINE vfloat_rvvm1_sleef vneg_vf_vf_rvvm1_sleef(vfloat_rvvm1_sleef f) { + return __riscv_vfneg(f, (__riscv_vsetvlmax_e32m1())); +} + +static SLEEF_ALWAYS_INLINE vint2_rvvm1_sleef vadd_vi2_vi2_vi2_rvvm1_sleef(vint2_rvvm1_sleef x, vint2_rvvm1_sleef y) { + return __riscv_vadd(x, y, (__riscv_vsetvlmax_e32m1())); +} +static SLEEF_ALWAYS_INLINE vint2_rvvm1_sleef vsub_vi2_vi2_vi2_rvvm1_sleef(vint2_rvvm1_sleef x, vint2_rvvm1_sleef y) { + return __riscv_vsub(x, y, (__riscv_vsetvlmax_e32m1())); +} +static SLEEF_ALWAYS_INLINE vint2_rvvm1_sleef vneg_vi2_vi2_rvvm1_sleef(vint2_rvvm1_sleef x) { + return __riscv_vneg(x, (__riscv_vsetvlmax_e32m1())); +} +static SLEEF_ALWAYS_INLINE vint2_rvvm1_sleef vand_vi2_vi2_vi2_rvvm1_sleef(vint2_rvvm1_sleef x, vint2_rvvm1_sleef y) { + return __riscv_vand(x, y, (__riscv_vsetvlmax_e32m1())); +} +static SLEEF_ALWAYS_INLINE vint2_rvvm1_sleef vandnot_vi2_vi2_vi2_rvvm1_sleef(vint2_rvvm1_sleef x, vint2_rvvm1_sleef y) { + return __riscv_vand(__riscv_vnot(x, (__riscv_vsetvlmax_e32m1())), y, (__riscv_vsetvlmax_e32m1())); +} +static SLEEF_ALWAYS_INLINE vint2_rvvm1_sleef vor_vi2_vi2_vi2_rvvm1_sleef(vint2_rvvm1_sleef x, vint2_rvvm1_sleef y) { + return __riscv_vor(x, y, (__riscv_vsetvlmax_e32m1())); +} +static SLEEF_ALWAYS_INLINE vint2_rvvm1_sleef vxor_vi2_vi2_vi2_rvvm1_sleef(vint2_rvvm1_sleef x, vint2_rvvm1_sleef y) { + return __riscv_vxor(x, y, (__riscv_vsetvlmax_e32m1())); +} +static SLEEF_ALWAYS_INLINE vint2_rvvm1_sleef vsll_vi2_vi2_i_rvvm1_sleef(vint2_rvvm1_sleef x, int c) { + return __riscv_vsll(x, c, (__riscv_vsetvlmax_e32m1())); +} +static SLEEF_ALWAYS_INLINE vint2_rvvm1_sleef vsra_vi2_vi2_i_rvvm1_sleef(vint2_rvvm1_sleef x, int c) { + return __riscv_vsra(x, c, (__riscv_vsetvlmax_e32m1())); +} +static SLEEF_ALWAYS_INLINE vint2_rvvm1_sleef vsrl_vi2_vi2_i_rvvm1_sleef(vint2_rvvm1_sleef x, int c) { + return __riscv_vreinterpret_i32m1(__riscv_vsrl(__riscv_vreinterpret_u32m1(x), c, (__riscv_vsetvlmax_e32m1()))); +} + +static SLEEF_ALWAYS_INLINE vfloat_rvvm1_sleef vreinterpret_vf_vm_rvvm1_sleef(vmask_rvvm1_sleef vm) { + return __riscv_vreinterpret_f32m1(__riscv_vreinterpret_u32m1(vm)); +} +static SLEEF_ALWAYS_INLINE vmask_rvvm1_sleef vreinterpret_vm_vf_rvvm1_sleef(vfloat_rvvm1_sleef vf) { + return __riscv_vreinterpret_u64m1(__riscv_vreinterpret_u32m1(vf)); +} + +static SLEEF_ALWAYS_INLINE int vtestallones_i_vo32_rvvm1_sleef(rvv_sp_vopmask_rvvm1_sleef g) { + return __riscv_vcpop(g, (__riscv_vsetvlmax_e32m1())) == (__riscv_vsetvlmax_e32m1()); +} +static SLEEF_ALWAYS_INLINE vmask_rvvm1_sleef vor_vm_vo32_vm_rvvm1_sleef(rvv_sp_vopmask_rvvm1_sleef x, vmask_rvvm1_sleef y) { + rvv_vmask32 y32 = __riscv_vreinterpret_u32m1(y); + return __riscv_vreinterpret_u64m1(__riscv_vmerge(y32, -1, x, (__riscv_vsetvlmax_e32m1()))); +} +static SLEEF_ALWAYS_INLINE vmask_rvvm1_sleef vand_vm_vo32_vm_rvvm1_sleef(rvv_sp_vopmask_rvvm1_sleef x, vmask_rvvm1_sleef y) { + rvv_vmask32 y32 = __riscv_vreinterpret_u32m1(y); + return __riscv_vreinterpret_u64m1(__riscv_vmerge(y32, 0, __riscv_vmnot(x, (__riscv_vsetvlmax_e32m1())), (__riscv_vsetvlmax_e32m1()))); +} +static SLEEF_ALWAYS_INLINE vmask_rvvm1_sleef vandnot_vm_vo32_vm_rvvm1_sleef(rvv_sp_vopmask_rvvm1_sleef x, vmask_rvvm1_sleef y) { + rvv_vmask32 y32 = __riscv_vreinterpret_u32m1(y); + return __riscv_vreinterpret_u64m1(__riscv_vmerge(y32, 0, x, (__riscv_vsetvlmax_e32m1()))); +} + +static SLEEF_ALWAYS_INLINE rvv_sp_vopmask_rvvm1_sleef rvv_sp_vand_vo_vo_vo(rvv_sp_vopmask_rvvm1_sleef x, rvv_sp_vopmask_rvvm1_sleef y) { + return __riscv_vmand(x, y, (__riscv_vsetvlmax_e32m1())); +} +static SLEEF_ALWAYS_INLINE rvv_sp_vopmask_rvvm1_sleef rvv_sp_vandnot_vo_vo_vo(rvv_sp_vopmask_rvvm1_sleef x, rvv_sp_vopmask_rvvm1_sleef y) { + return __riscv_vmandn(y, x, (__riscv_vsetvlmax_e32m1())); +} +static SLEEF_ALWAYS_INLINE rvv_sp_vopmask_rvvm1_sleef rvv_sp_vor_vo_vo_vo(rvv_sp_vopmask_rvvm1_sleef x, rvv_sp_vopmask_rvvm1_sleef y) { + return __riscv_vmor(x, y, (__riscv_vsetvlmax_e32m1())); +} +static SLEEF_ALWAYS_INLINE rvv_sp_vopmask_rvvm1_sleef rvv_sp_vxor_vo_vo_vo(rvv_sp_vopmask_rvvm1_sleef x, rvv_sp_vopmask_rvvm1_sleef y) { + return __riscv_vmxor(x, y, (__riscv_vsetvlmax_e32m1())); +} + +static SLEEF_ALWAYS_INLINE rvv_sp_vopmask_rvvm1_sleef veq_vo_vf_vf_rvvm1_sleef(vfloat_rvvm1_sleef x, vfloat_rvvm1_sleef y) { + return __riscv_vmfeq(x, y, (__riscv_vsetvlmax_e32m1())); +} +static SLEEF_ALWAYS_INLINE rvv_sp_vopmask_rvvm1_sleef vneq_vo_vf_vf_rvvm1_sleef(vfloat_rvvm1_sleef x, vfloat_rvvm1_sleef y) { + return __riscv_vmfne(x, y, (__riscv_vsetvlmax_e32m1())); +} +static SLEEF_ALWAYS_INLINE rvv_sp_vopmask_rvvm1_sleef vgt_vo_vf_vf_rvvm1_sleef(vfloat_rvvm1_sleef x, vfloat_rvvm1_sleef y) { + return __riscv_vmfgt(x, y, (__riscv_vsetvlmax_e32m1())); +} +static SLEEF_ALWAYS_INLINE rvv_sp_vopmask_rvvm1_sleef vge_vo_vf_vf_rvvm1_sleef(vfloat_rvvm1_sleef x, vfloat_rvvm1_sleef y) { + return __riscv_vmfge(x, y, (__riscv_vsetvlmax_e32m1())); +} +static SLEEF_ALWAYS_INLINE rvv_sp_vopmask_rvvm1_sleef vlt_vo_vf_vf_rvvm1_sleef(vfloat_rvvm1_sleef x, vfloat_rvvm1_sleef y) { + return __riscv_vmflt(x, y, (__riscv_vsetvlmax_e32m1())); +} +static SLEEF_ALWAYS_INLINE rvv_sp_vopmask_rvvm1_sleef vle_vo_vf_vf_rvvm1_sleef(vfloat_rvvm1_sleef x, vfloat_rvvm1_sleef y) { + return __riscv_vmfle(x, y, (__riscv_vsetvlmax_e32m1())); +} +static SLEEF_ALWAYS_INLINE rvv_sp_vopmask_rvvm1_sleef visnan_vo_vf_rvvm1_sleef(vfloat_rvvm1_sleef d) { + return __riscv_vmfne(d, d, (__riscv_vsetvlmax_e32m1())); +} +static SLEEF_ALWAYS_INLINE rvv_sp_vopmask_rvvm1_sleef visinf_vo_vf_rvvm1_sleef(vfloat_rvvm1_sleef d) { + return __riscv_vmfeq(__riscv_vfabs(d, (__riscv_vsetvlmax_e32m1())), __builtin_inff(), (__riscv_vsetvlmax_e32m1())); +} +static SLEEF_ALWAYS_INLINE rvv_sp_vopmask_rvvm1_sleef vispinf_vo_vf_rvvm1_sleef(vfloat_rvvm1_sleef d) { + return __riscv_vmfeq(d, __builtin_inff(), (__riscv_vsetvlmax_e32m1())); +} + +static SLEEF_ALWAYS_INLINE vfloat_rvvm1_sleef vsel_vf_vo_vf_vf_rvvm1_sleef(rvv_sp_vopmask_rvvm1_sleef mask, vfloat_rvvm1_sleef x, vfloat_rvvm1_sleef y) { + return __riscv_vmerge(y, x, mask, (__riscv_vsetvlmax_e32m1())); +} +static SLEEF_ALWAYS_INLINE vfloat_rvvm1_sleef vsel_vf_vo_f_f_rvvm1_sleef(rvv_sp_vopmask_rvvm1_sleef mask, float v1, float v0) { + return __riscv_vfmerge(vcast_vf_f_rvvm1_sleef(v0), v1, mask, (__riscv_vsetvlmax_e32m1())); +} +static SLEEF_ALWAYS_INLINE vfloat_rvvm1_sleef vsel_vf_vo_vo_f_f_f_rvvm1_sleef(rvv_sp_vopmask_rvvm1_sleef o0, rvv_sp_vopmask_rvvm1_sleef o1, float d0, float d1, float d2) { + return __riscv_vfmerge(__riscv_vfmerge(vcast_vf_f_rvvm1_sleef(d2), d1, o1, (__riscv_vsetvlmax_e32m1())), d0, o0, (__riscv_vsetvlmax_e32m1())); +} +static SLEEF_ALWAYS_INLINE vfloat_rvvm1_sleef vsel_vf_vo_vo_vo_f_f_f_f_rvvm1_sleef(rvv_sp_vopmask_rvvm1_sleef o0, rvv_sp_vopmask_rvvm1_sleef o1, rvv_sp_vopmask_rvvm1_sleef o2, float d0, float d1, float d2, float d3) { + return __riscv_vfmerge(__riscv_vfmerge(__riscv_vfmerge(vcast_vf_f_rvvm1_sleef(d3), d2, o2, (__riscv_vsetvlmax_e32m1())), d1, o1, (__riscv_vsetvlmax_e32m1())), d0, o0, (__riscv_vsetvlmax_e32m1())); +} + +static SLEEF_ALWAYS_INLINE rvv_sp_vopmask_rvvm1_sleef veq_vo_vi2_vi2_rvvm1_sleef(vint2_rvvm1_sleef x, vint2_rvvm1_sleef y) { + return __riscv_vmseq(x, y, (__riscv_vsetvlmax_e32m1())); +} +static SLEEF_ALWAYS_INLINE rvv_sp_vopmask_rvvm1_sleef vgt_vo_vi2_vi2_rvvm1_sleef(vint2_rvvm1_sleef x, vint2_rvvm1_sleef y) { + return __riscv_vmsgt(x, y, (__riscv_vsetvlmax_e32m1())); +} +static SLEEF_ALWAYS_INLINE vint2_rvvm1_sleef vgt_vi2_vi2_vi2_rvvm1_sleef(vint2_rvvm1_sleef x, vint2_rvvm1_sleef y) { + vint2_rvvm1_sleef zero = vcast_vi2_i_rvvm1_sleef(0); + return __riscv_vmerge(zero, -1, __riscv_vmsgt(x, y, (__riscv_vsetvlmax_e32m1())), (__riscv_vsetvlmax_e32m1())); +} + +static SLEEF_ALWAYS_INLINE vint2_rvvm1_sleef vsel_vi2_vo_vi2_vi2_rvvm1_sleef(rvv_sp_vopmask_rvvm1_sleef m, vint2_rvvm1_sleef x, vint2_rvvm1_sleef y) { + return __riscv_vmerge(y, x, m, (__riscv_vsetvlmax_e32m1())); +} +static SLEEF_ALWAYS_INLINE vint2_rvvm1_sleef vand_vi2_vo_vi2_rvvm1_sleef(rvv_sp_vopmask_rvvm1_sleef x, vint2_rvvm1_sleef y) { + return __riscv_vmerge(y, 0, __riscv_vmnot(x, (__riscv_vsetvlmax_e32m1())), (__riscv_vsetvlmax_e32m1())); +} + +static SLEEF_ALWAYS_INLINE const vdouble_rvvm1_sleef vd2getx_vd_vd2_rvvm1_sleef(vdouble2_rvvm1_sleef v) { + return __riscv_vget_f64m1(v, 0); +} +static SLEEF_ALWAYS_INLINE const vdouble_rvvm1_sleef vd2gety_vd_vd2_rvvm1_sleef(vdouble2_rvvm1_sleef v) { + return __riscv_vget_f64m1(v, 1); +} +static SLEEF_ALWAYS_INLINE const vdouble2_rvvm1_sleef vd2setxy_vd2_vd_vd_rvvm1_sleef(vdouble_rvvm1_sleef x, vdouble_rvvm1_sleef y) { + return __riscv_vset(__riscv_vlmul_ext_v_f64m1_f64m2(x), 1, y); +} +static SLEEF_ALWAYS_INLINE const vdouble2_rvvm1_sleef vd2setx_vd2_vd2_vd_rvvm1_sleef(vdouble2_rvvm1_sleef v, vdouble_rvvm1_sleef d) { + return __riscv_vset(v, 0, d); +} +static SLEEF_ALWAYS_INLINE const vdouble2_rvvm1_sleef vd2sety_vd2_vd2_vd_rvvm1_sleef(vdouble2_rvvm1_sleef v, vdouble_rvvm1_sleef d) { + return __riscv_vset(v, 1, d); +} + +static dd2_rvvm1_sleef dd2setab_dd2_vd2_vd2_rvvm1_sleef(vdouble2_rvvm1_sleef a, vdouble2_rvvm1_sleef b) { + return __riscv_vset(__riscv_vlmul_ext_v_f64m2_f64m4(a), 1, b); +} +static vdouble2_rvvm1_sleef dd2geta_vd2_dd2_rvvm1_sleef(dd2_rvvm1_sleef d) { return __riscv_vget_f64m2(d, 0); } +static vdouble2_rvvm1_sleef dd2getb_vd2_dd2_rvvm1_sleef(dd2_rvvm1_sleef d) { return __riscv_vget_f64m2(d, 1); } + +static SLEEF_ALWAYS_INLINE vdouble_rvvm1_sleef vd3getx_vd_vd3_rvvm1_sleef(vdouble3_rvvm1_sleef v) { return __riscv_vget_f64m1(v, 0); } +static SLEEF_ALWAYS_INLINE vdouble_rvvm1_sleef vd3gety_vd_vd3_rvvm1_sleef(vdouble3_rvvm1_sleef v) { return __riscv_vget_f64m1(v, 1); } +static SLEEF_ALWAYS_INLINE vdouble_rvvm1_sleef vd3getz_vd_vd3_rvvm1_sleef(vdouble3_rvvm1_sleef v) { return __riscv_vget_f64m1(v, 2); } +static SLEEF_ALWAYS_INLINE vdouble3_rvvm1_sleef vd3setxyz_vd3_vd_vd_vd_rvvm1_sleef(vdouble_rvvm1_sleef x, vdouble_rvvm1_sleef y, vdouble_rvvm1_sleef z) { + return __riscv_vset(__riscv_vlmul_ext_v_f64m2_f64m4(__riscv_vset(__riscv_vlmul_ext_v_f64m1_f64m2(x), 1, y)), 1, __riscv_vmv_v(__riscv_vlmul_ext_v_f64m1_f64m2(z), __riscv_vsetvlmax_e64m1())); +} +static SLEEF_ALWAYS_INLINE vdouble3_rvvm1_sleef vd3setx_vd3_vd3_vd_rvvm1_sleef(vdouble3_rvvm1_sleef v, vdouble_rvvm1_sleef d) { return __riscv_vset(v, 0, d); } +static SLEEF_ALWAYS_INLINE vdouble3_rvvm1_sleef vd3sety_vd3_vd3_vd_rvvm1_sleef(vdouble3_rvvm1_sleef v, vdouble_rvvm1_sleef d) { return __riscv_vset(v, 1, d); } +static SLEEF_ALWAYS_INLINE vdouble3_rvvm1_sleef vd3setz_vd3_vd3_vd_rvvm1_sleef(vdouble3_rvvm1_sleef v, vdouble_rvvm1_sleef d) { return __riscv_vset(v, 2, d); } + +static SLEEF_ALWAYS_INLINE vdouble_rvvm1_sleef digetd_vd_di_rvvm1_sleef(di_t_rvvm1_sleef d) { + vint2_rvvm1_sleef vi = __riscv_vget_i32m1(d, 0); + return __riscv_vreinterpret_f64m1(__riscv_vreinterpret_i64m1(vi)); +} +static SLEEF_ALWAYS_INLINE vint_rvvm1_sleef digeti_vi_di_rvvm1_sleef(di_t_rvvm1_sleef d) { + vint2_rvvm1_sleef vi = __riscv_vget_i32m1(d, 1); + return __riscv_vlmul_trunc_i32mf2(vi); +} +static SLEEF_ALWAYS_INLINE di_t_rvvm1_sleef disetdi_di_vd_vi_rvvm1_sleef(vdouble_rvvm1_sleef d, vint_rvvm1_sleef i) { + vint2_rvvm1_sleef vd_rvvm1_sleef = __riscv_vreinterpret_i32m1(__riscv_vreinterpret_i64m1(d)); + vint2_rvvm1_sleef vi = __riscv_vmv_v(__riscv_vlmul_ext_v_i32mf2_i32m1(i), __riscv_vsetvlmax_e32mf2()); + return __riscv_vset(__riscv_vlmul_ext_v_i32m1_i32m2(vd_rvvm1_sleef), 1, vi); +} + +static SLEEF_ALWAYS_INLINE vdouble2_rvvm1_sleef ddigetdd_vd2_ddi_rvvm1_sleef(ddi_t_rvvm1_sleef d) { + return __riscv_vget_f64m2(__riscv_vreinterpret_f64m4(__riscv_vreinterpret_v_i32m4_i64m4(d)), 0); +} +static SLEEF_ALWAYS_INLINE vint_rvvm1_sleef ddigeti_vi_ddi_rvvm1_sleef(ddi_t_rvvm1_sleef d) { + vint2_rvvm1_sleef vi2 = __riscv_vget_i32m1(d, 2); + return __riscv_vlmul_trunc_i32mf2(vi2); +} +static SLEEF_ALWAYS_INLINE ddi_t_rvvm1_sleef ddisetddi_ddi_vd2_vi_rvvm1_sleef(vdouble2_rvvm1_sleef v, vint_rvvm1_sleef i) { + di_t_rvvm1_sleef vdi = __riscv_vreinterpret_i32m2(__riscv_vreinterpret_i64m2(v)); + return __riscv_vset(__riscv_vlmul_ext_v_i32m2_i32m4(vdi), 1, __riscv_vmv_v(__riscv_vlmul_ext_v_i32mf2_i32m2(i), __riscv_vsetvlmax_e32mf2())); +} +static SLEEF_ALWAYS_INLINE ddi_t_rvvm1_sleef ddisetdd_ddi_ddi_vd2_rvvm1_sleef(ddi_t_rvvm1_sleef ddi_rvvm1_sleef, vdouble2_rvvm1_sleef v) { + di_t_rvvm1_sleef vdi = __riscv_vreinterpret_i32m2(__riscv_vreinterpret_i64m2(v)); + return __riscv_vset(ddi_rvvm1_sleef, 0, vdi); +} + +static SLEEF_ALWAYS_INLINE vdouble_rvvm1_sleef vcast_vd_d_rvvm1_sleef(double d) { + return __riscv_vfmv_v_f_f64m1(d, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE vdouble_rvvm1_sleef vcast_vd_vi_rvvm1_sleef(vint_rvvm1_sleef i) { + return __riscv_vfwcvt_f(i, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE vint_rvvm1_sleef vcast_vi_i_rvvm1_sleef(int32_t i) { + return __riscv_vmv_v_x_i32mf2(i, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE vint_rvvm1_sleef vrint_vi_vd_rvvm1_sleef(vdouble_rvvm1_sleef vd_rvvm1_sleef) { + return __riscv_vfncvt_x_f_w_i32mf2_rm(vd_rvvm1_sleef, __RISCV_FRM_RNE, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE vdouble_rvvm1_sleef vrint_vd_vd_rvvm1_sleef(vdouble_rvvm1_sleef vd_rvvm1_sleef) { + return __riscv_vfcvt_f_x_v_f64m1(__riscv_vfcvt_x_f_v_i64m1_rm(vd_rvvm1_sleef, __RISCV_FRM_RNE, __riscv_vsetvlmax_e64m1()), __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE vint_rvvm1_sleef vtruncate_vi_vd_rvvm1_sleef(vdouble_rvvm1_sleef vd_rvvm1_sleef) { + return __riscv_vfncvt_rtz_x(vd_rvvm1_sleef, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE vdouble_rvvm1_sleef vtruncate_vd_vd_rvvm1_sleef(vdouble_rvvm1_sleef vd_rvvm1_sleef) { + return vcast_vd_vi_rvvm1_sleef(vtruncate_vi_vd_rvvm1_sleef(vd_rvvm1_sleef)); +} + +static SLEEF_ALWAYS_INLINE vdouble_rvvm1_sleef vload_vd_p_rvvm1_sleef(const double *ptr) { + return __riscv_vle64_v_f64m1(ptr, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE vdouble_rvvm1_sleef vloadu_vd_p_rvvm1_sleef(const double *ptr) { + return __riscv_vle64_v_f64m1(ptr, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE vint_rvvm1_sleef vloadu_vi_p_rvvm1_sleef(int32_t *p) { + return __riscv_vle32_v_i32mf2(p, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE void vstore_v_p_vd_rvvm1_sleef(double *ptr, vdouble_rvvm1_sleef v) { + __riscv_vse64(ptr, v, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE void vstoreu_v_p_vd_rvvm1_sleef(double *ptr, vdouble_rvvm1_sleef v) { + __riscv_vse64(ptr, v, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE void vstoreu_v_p_vi_rvvm1_sleef(int32_t *ptr, vint_rvvm1_sleef v) { + __riscv_vse32(ptr, v, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE vdouble_rvvm1_sleef vgather_vd_p_vi_rvvm1_sleef(const double *ptr, vint_rvvm1_sleef vi) { + return __riscv_vluxei64(ptr, __riscv_vwmulu(__riscv_vreinterpret_u32mf2(vi), sizeof(double), __riscv_vsetvlmax_e64m1()), __riscv_vsetvlmax_e64m1()); +} + +static SLEEF_ALWAYS_INLINE vdouble_rvvm1_sleef vadd_vd_vd_vd_rvvm1_sleef(vdouble_rvvm1_sleef x, vdouble_rvvm1_sleef y) { + return __riscv_vfadd(x, y, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE vdouble_rvvm1_sleef vsub_vd_vd_vd_rvvm1_sleef(vdouble_rvvm1_sleef x, vdouble_rvvm1_sleef y) { + return __riscv_vfsub(x, y, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE vdouble_rvvm1_sleef vrec_vd_vd_rvvm1_sleef(vdouble_rvvm1_sleef d) { + return __riscv_vfdiv(vcast_vd_d_rvvm1_sleef(1.0), d, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE vdouble_rvvm1_sleef vabs_vd_vd_rvvm1_sleef(vdouble_rvvm1_sleef d) { + return __riscv_vfabs(d, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE vdouble_rvvm1_sleef vsqrt_vd_vd_rvvm1_sleef(vdouble_rvvm1_sleef d) { + return __riscv_vfsqrt(d, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE vdouble_rvvm1_sleef vmul_vd_vd_vd_rvvm1_sleef(vdouble_rvvm1_sleef x, vdouble_rvvm1_sleef y) { + return __riscv_vfmul(x, y, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE vdouble_rvvm1_sleef vdiv_vd_vd_vd_rvvm1_sleef(vdouble_rvvm1_sleef x, vdouble_rvvm1_sleef y) { + return __riscv_vfdiv(x, y, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE vdouble_rvvm1_sleef vmax_vd_vd_vd_rvvm1_sleef(vdouble_rvvm1_sleef x, vdouble_rvvm1_sleef y) { + return __riscv_vfmax(x, y, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE vdouble_rvvm1_sleef vmin_vd_vd_vd_rvvm1_sleef(vdouble_rvvm1_sleef x, vdouble_rvvm1_sleef y) { + return __riscv_vfmin(x, y, __riscv_vsetvlmax_e64m1()); +} + +static SLEEF_ALWAYS_INLINE vdouble_rvvm1_sleef vmla_vd_vd_vd_vd_rvvm1_sleef(vdouble_rvvm1_sleef x, vdouble_rvvm1_sleef y, vdouble_rvvm1_sleef z) { + return __riscv_vfmadd(x, y, z, __riscv_vsetvlmax_e64m1()); +} + +static SLEEF_ALWAYS_INLINE vdouble_rvvm1_sleef vmlapn_vd_vd_vd_vd_rvvm1_sleef(vdouble_rvvm1_sleef x, vdouble_rvvm1_sleef y, vdouble_rvvm1_sleef z) { + return __riscv_vfmsub(x, y, z, __riscv_vsetvlmax_e64m1()); +} + +static SLEEF_ALWAYS_INLINE vdouble_rvvm1_sleef vmlanp_vd_vd_vd_vd_rvvm1_sleef(vdouble_rvvm1_sleef x, vdouble_rvvm1_sleef y, vdouble_rvvm1_sleef z) { + return __riscv_vfnmsac(z, x, y, __riscv_vsetvlmax_e64m1()); +} + +static SLEEF_ALWAYS_INLINE vdouble_rvvm1_sleef vfma_vd_vd_vd_vd_rvvm1_sleef(vdouble_rvvm1_sleef x, vdouble_rvvm1_sleef y, vdouble_rvvm1_sleef z) { + return __riscv_vfmadd(x, y, z, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE vdouble_rvvm1_sleef vfmanp_vd_vd_vd_vd_rvvm1_sleef(vdouble_rvvm1_sleef x, vdouble_rvvm1_sleef y, vdouble_rvvm1_sleef z) { + return __riscv_vfnmsub(x, y, z, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE vdouble_rvvm1_sleef vfmapn_vd_vd_vd_vd_rvvm1_sleef(vdouble_rvvm1_sleef x, vdouble_rvvm1_sleef y, vdouble_rvvm1_sleef z) { + return __riscv_vfmsub(x, y, z, __riscv_vsetvlmax_e64m1()); +} + +static SLEEF_ALWAYS_INLINE vdouble_rvvm1_sleef vmulsign_vd_vd_vd_rvvm1_sleef(vdouble_rvvm1_sleef x, vdouble_rvvm1_sleef y) { + return __riscv_vfsgnjx(x, y, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE vdouble_rvvm1_sleef vcopysign_vd_vd_vd_rvvm1_sleef(vdouble_rvvm1_sleef x, vdouble_rvvm1_sleef y) { + return __riscv_vfsgnj(x, y, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE vdouble_rvvm1_sleef vorsign_vd_vd_vd_rvvm1_sleef(vdouble_rvvm1_sleef x, vdouble_rvvm1_sleef y) { + return __riscv_vfsgnj(x, __riscv_vreinterpret_f64m1(__riscv_vreinterpret_i64m1(__riscv_vor(__riscv_vreinterpret_u64m1(x), __riscv_vreinterpret_u64m1(y), __riscv_vsetvlmax_e64m1()))), __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE vdouble_rvvm1_sleef vneg_vd_vd_rvvm1_sleef(vdouble_rvvm1_sleef d) { + return __riscv_vfneg(d, __riscv_vsetvlmax_e64m1()); +} + +static SLEEF_ALWAYS_INLINE vint_rvvm1_sleef vadd_vi_vi_vi_rvvm1_sleef(vint_rvvm1_sleef x, vint_rvvm1_sleef y) { + return __riscv_vadd(x, y, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE vint_rvvm1_sleef vsub_vi_vi_vi_rvvm1_sleef(vint_rvvm1_sleef x, vint_rvvm1_sleef y) { + return __riscv_vsub(x, y, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE vint_rvvm1_sleef vneg_vi_vi_rvvm1_sleef(vint_rvvm1_sleef x) { + return __riscv_vneg(x, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE vint_rvvm1_sleef vand_vi_vi_vi_rvvm1_sleef(vint_rvvm1_sleef x, vint_rvvm1_sleef y) { + return __riscv_vand(x, y, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE vint_rvvm1_sleef vandnot_vi_vi_vi_rvvm1_sleef(vint_rvvm1_sleef x, vint_rvvm1_sleef y) { + return __riscv_vand(__riscv_vnot(x, __riscv_vsetvlmax_e64m1()), y, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE vint_rvvm1_sleef vor_vi_vi_vi_rvvm1_sleef(vint_rvvm1_sleef x, vint_rvvm1_sleef y) { + return __riscv_vor(x, y, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE vint_rvvm1_sleef vxor_vi_vi_vi_rvvm1_sleef(vint_rvvm1_sleef x, vint_rvvm1_sleef y) { + return __riscv_vxor(x, y, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE vint_rvvm1_sleef vsll_vi_vi_i_rvvm1_sleef(vint_rvvm1_sleef x, int c) { + return __riscv_vsll(x, c, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE vint_rvvm1_sleef vsra_vi_vi_i_rvvm1_sleef(vint_rvvm1_sleef x, int c) { + return __riscv_vsra(x, c, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE vint_rvvm1_sleef vsrl_vi_vi_i_rvvm1_sleef(vint_rvvm1_sleef x, int c) { + return __riscv_vreinterpret_i32mf2(__riscv_vsrl(__riscv_vreinterpret_u32mf2(x), c, __riscv_vsetvlmax_e64m1())); +} + +static SLEEF_ALWAYS_INLINE vmask_rvvm1_sleef vcast_vm_i64_rvvm1_sleef(int64_t c) { + return __riscv_vmv_v_x_u64m1(c, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE vmask_rvvm1_sleef vcast_vm_u64_rvvm1_sleef(uint64_t c) { + return __riscv_vmv_v_x_u64m1(c, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE vmask_rvvm1_sleef vcast_vm_i_i_rvvm1_sleef(int64_t h, int64_t l) { + return __riscv_vmv_v_x_u64m1((((uint64_t)h) << 32) | (uint32_t) l, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE vmask_rvvm1_sleef vcast_vm_vi_rvvm1_sleef(vint_rvvm1_sleef vi) { + return __riscv_vreinterpret_u64m1(__riscv_vwcvt_x(vi, __riscv_vsetvlmax_e64m1())); +} +static SLEEF_ALWAYS_INLINE vmask_rvvm1_sleef vcastu_vm_vi_rvvm1_sleef(vint_rvvm1_sleef vi) { + return __riscv_vsll(__riscv_vreinterpret_u64m1(__riscv_vwcvt_x(vi, __riscv_vsetvlmax_e64m1())), 32, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE vint_rvvm1_sleef vcastu_vi_vm_rvvm1_sleef(vmask_rvvm1_sleef vm) { + return __riscv_vreinterpret_i32mf2(__riscv_vnsrl(vm, 32, __riscv_vsetvlmax_e64m1())); +} +static SLEEF_ALWAYS_INLINE vint_rvvm1_sleef vcast_vi_vm_rvvm1_sleef(vmask_rvvm1_sleef vm) { + return __riscv_vreinterpret_i32mf2(__riscv_vncvt_x(vm, __riscv_vsetvlmax_e64m1())); +} + +static SLEEF_ALWAYS_INLINE vmask_rvvm1_sleef vand_vm_vo64_vm_rvvm1_sleef(rvv_dp_vopmask_rvvm1_sleef x, vmask_rvvm1_sleef y) { + return __riscv_vmerge(y, 0, __riscv_vmnot(x, __riscv_vsetvlmax_e64m1()), __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE vmask_rvvm1_sleef vand_vm_vm_vm_rvvm1_sleef(vmask_rvvm1_sleef x, vmask_rvvm1_sleef y) { + return __riscv_vand(x, y, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE vmask_rvvm1_sleef vor_vm_vm_vm_rvvm1_sleef(vmask_rvvm1_sleef x, vmask_rvvm1_sleef y) { + return __riscv_vor(x, y, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE vmask_rvvm1_sleef vxor_vm_vm_vm_rvvm1_sleef(vmask_rvvm1_sleef x, vmask_rvvm1_sleef y) { + return __riscv_vxor(x, y, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE vmask_rvvm1_sleef vandnot_vm_vm_vm_rvvm1_sleef(vmask_rvvm1_sleef x, vmask_rvvm1_sleef y) { + return __riscv_vand(__riscv_vnot(x, __riscv_vsetvlmax_e64m1()), y, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE vmask_rvvm1_sleef vandnot_vm_vo64_vm_rvvm1_sleef(rvv_dp_vopmask_rvvm1_sleef x, vmask_rvvm1_sleef y) { + return __riscv_vmerge(y, 0, x, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE vmask_rvvm1_sleef vsll64_vm_vm_i(vmask_rvvm1_sleef mask, int64_t c) { + return __riscv_vsll(mask, c, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE vmask_rvvm1_sleef vsub64_vm_vm_vm_rvvm1_sleef(vmask_rvvm1_sleef x, vmask_rvvm1_sleef y) { + return __riscv_vsub(x, y, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE vmask_rvvm1_sleef vsrl64_vm_vm_i(vmask_rvvm1_sleef mask, int64_t c) { + return __riscv_vsrl(mask, c, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE vmask_rvvm1_sleef vadd64_vm_vm_vm_rvvm1_sleef(vmask_rvvm1_sleef x, vmask_rvvm1_sleef y) { + return __riscv_vadd(x, y, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE vmask_rvvm1_sleef vor_vm_vo64_vm_rvvm1_sleef(rvv_dp_vopmask_rvvm1_sleef x, vmask_rvvm1_sleef y) { + return __riscv_vmerge(y, -1, x, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE vmask_rvvm1_sleef vsel_vm_vo64_vm_vm_rvvm1_sleef(rvv_dp_vopmask_rvvm1_sleef mask, vmask_rvvm1_sleef x, vmask_rvvm1_sleef y) { + return __riscv_vmerge(y, x, mask, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE vmask_rvvm1_sleef vneg64_vm_vm_rvvm1_sleef(vmask_rvvm1_sleef mask) { + return __riscv_vreinterpret_u64m1(__riscv_vneg(__riscv_vreinterpret_i64m1(mask), __riscv_vsetvlmax_e64m1())); +} +static SLEEF_ALWAYS_INLINE vdouble_rvvm1_sleef vreinterpret_vd_vm_rvvm1_sleef(vmask_rvvm1_sleef vm) { + return __riscv_vreinterpret_f64m1(__riscv_vreinterpret_i64m1(vm)); +} +static SLEEF_ALWAYS_INLINE vmask_rvvm1_sleef vreinterpret_vm_vd_rvvm1_sleef(vdouble_rvvm1_sleef vd_rvvm1_sleef) { + return __riscv_vreinterpret_u64m1(vd_rvvm1_sleef); +} + +static SLEEF_ALWAYS_INLINE const vmask_rvvm1_sleef vqgetx_vm_vq_rvvm1_sleef(vquad_rvvm1_sleef v) { return __riscv_vget_u64m1(v, 0); } +static SLEEF_ALWAYS_INLINE const vmask_rvvm1_sleef vqgety_vm_vq_rvvm1_sleef(vquad_rvvm1_sleef v) { return __riscv_vget_u64m1(v, 1); } +static SLEEF_ALWAYS_INLINE vquad_rvvm1_sleef vqsetxy_vq_vm_vm_rvvm1_sleef(vmask_rvvm1_sleef x, vmask_rvvm1_sleef y) { + return __riscv_vset(__riscv_vlmul_ext_v_u64m1_u64m2(x), 1, y); +} +static SLEEF_ALWAYS_INLINE vquad_rvvm1_sleef vqsetx_vq_vq_vm_rvvm1_sleef(vquad_rvvm1_sleef v, vmask_rvvm1_sleef x) { return __riscv_vset(v, 0, x); } +static SLEEF_ALWAYS_INLINE vquad_rvvm1_sleef vqsety_vq_vq_vm_rvvm1_sleef(vquad_rvvm1_sleef v, vmask_rvvm1_sleef y) { return __riscv_vset(v, 1, y); } + +static SLEEF_ALWAYS_INLINE rvv_dp_vopmask_rvvm1_sleef vcast_vo64_vo32_rvvm1_sleef(rvv_dp_vopmask_rvvm1_sleef vo) { + return vo; +} +static SLEEF_ALWAYS_INLINE rvv_dp_vopmask_rvvm1_sleef vcast_vo32_vo64_rvvm1_sleef(rvv_dp_vopmask_rvvm1_sleef vo) { + return vo; +} +static SLEEF_ALWAYS_INLINE rvv_dp_vopmask_rvvm1_sleef rvv_dp_vand_vo_vo_vo(rvv_dp_vopmask_rvvm1_sleef x, rvv_dp_vopmask_rvvm1_sleef y) { + return __riscv_vmand(x, y, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE rvv_dp_vopmask_rvvm1_sleef rvv_dp_vandnot_vo_vo_vo(rvv_dp_vopmask_rvvm1_sleef x, rvv_dp_vopmask_rvvm1_sleef y) { + return __riscv_vmandn(y, x, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE rvv_dp_vopmask_rvvm1_sleef rvv_dp_vor_vo_vo_vo(rvv_dp_vopmask_rvvm1_sleef x, rvv_dp_vopmask_rvvm1_sleef y) { + return __riscv_vmor(x, y, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE rvv_dp_vopmask_rvvm1_sleef rvv_dp_vxor_vo_vo_vo(rvv_dp_vopmask_rvvm1_sleef x, rvv_dp_vopmask_rvvm1_sleef y) { + return __riscv_vmxor(x, y, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE rvv_dp_vopmask_rvvm1_sleef veq64_vo_vm_vm_rvvm1_sleef(vmask_rvvm1_sleef x, vmask_rvvm1_sleef y) { + return __riscv_vmseq(x, y, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE rvv_dp_vopmask_rvvm1_sleef vgt64_vo_vm_vm_rvvm1_sleef(vmask_rvvm1_sleef x, vmask_rvvm1_sleef y) { + return __riscv_vmsgt(__riscv_vreinterpret_i64m1(x), __riscv_vreinterpret_i64m1(y), __riscv_vsetvlmax_e64m1()); +} + +static SLEEF_ALWAYS_INLINE rvv_dp_vopmask_rvvm1_sleef visinf_vo_vd_rvvm1_sleef(vdouble_rvvm1_sleef d) { + return __riscv_vmfeq(__riscv_vfabs(d, __riscv_vsetvlmax_e64m1()), __builtin_inf(), __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE rvv_dp_vopmask_rvvm1_sleef vispinf_vo_vd_rvvm1_sleef(vdouble_rvvm1_sleef d) { + return __riscv_vmfeq(d, __builtin_inf(), __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE rvv_dp_vopmask_rvvm1_sleef veq_vo_vd_vd_rvvm1_sleef(vdouble_rvvm1_sleef x, vdouble_rvvm1_sleef y) { + return __riscv_vmfeq(x, y, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE rvv_dp_vopmask_rvvm1_sleef vneq_vo_vd_vd_rvvm1_sleef(vdouble_rvvm1_sleef x, vdouble_rvvm1_sleef y) { + return __riscv_vmfne(x, y, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE rvv_dp_vopmask_rvvm1_sleef vlt_vo_vd_vd_rvvm1_sleef(vdouble_rvvm1_sleef x, vdouble_rvvm1_sleef y) { + return __riscv_vmflt(x, y, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE rvv_dp_vopmask_rvvm1_sleef vle_vo_vd_vd_rvvm1_sleef(vdouble_rvvm1_sleef x, vdouble_rvvm1_sleef y) { + return __riscv_vmfle(x, y, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE rvv_dp_vopmask_rvvm1_sleef vgt_vo_vd_vd_rvvm1_sleef(vdouble_rvvm1_sleef x, vdouble_rvvm1_sleef y) { + return __riscv_vmfgt(x, y, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE rvv_dp_vopmask_rvvm1_sleef vge_vo_vd_vd_rvvm1_sleef(vdouble_rvvm1_sleef x, vdouble_rvvm1_sleef y) { + return __riscv_vmfge(x, y, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE rvv_dp_vopmask_rvvm1_sleef visnan_vo_vd_rvvm1_sleef(vdouble_rvvm1_sleef d) { + return __riscv_vmfne(d, d, __riscv_vsetvlmax_e64m1()); +} + +static SLEEF_ALWAYS_INLINE vdouble_rvvm1_sleef vsel_vd_vo_vd_vd_rvvm1_sleef(rvv_dp_vopmask_rvvm1_sleef mask, vdouble_rvvm1_sleef x, vdouble_rvvm1_sleef y) { + return __riscv_vmerge(y, x, mask, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE vdouble_rvvm1_sleef vsel_vd_vo_d_d_rvvm1_sleef(rvv_dp_vopmask_rvvm1_sleef mask, double v0, double v1) { + return __riscv_vfmerge(vcast_vd_d_rvvm1_sleef(v1), v0, mask, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE vdouble_rvvm1_sleef vsel_vd_vo_vo_d_d_d_rvvm1_sleef(rvv_dp_vopmask_rvvm1_sleef o0, rvv_dp_vopmask_rvvm1_sleef o1, double d0, double d1, double d2) { + return __riscv_vfmerge(__riscv_vfmerge(vcast_vd_d_rvvm1_sleef(d2), d1, o1, __riscv_vsetvlmax_e64m1()), d0, o0, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE vdouble_rvvm1_sleef vsel_vd_vo_vo_vo_d_d_d_d_rvvm1_sleef(rvv_dp_vopmask_rvvm1_sleef o0, rvv_dp_vopmask_rvvm1_sleef o1, rvv_dp_vopmask_rvvm1_sleef o2, double d0, double d1, double d2, double d3) { + return __riscv_vfmerge(__riscv_vfmerge(__riscv_vfmerge(vcast_vd_d_rvvm1_sleef(d3), d2, o2, __riscv_vsetvlmax_e64m1()), d1, o1, __riscv_vsetvlmax_e64m1()), d0, o0, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE int vtestallones_i_vo64_rvvm1_sleef(rvv_dp_vopmask_rvvm1_sleef g) { + return __riscv_vcpop(g, __riscv_vsetvlmax_e64m1()) == __riscv_vsetvlmax_e64m1(); +} + +static SLEEF_ALWAYS_INLINE rvv_dp_vopmask_rvvm1_sleef veq_vo_vi_vi_rvvm1_sleef(vint_rvvm1_sleef x, vint_rvvm1_sleef y) { + return __riscv_vmseq(x, y, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE rvv_dp_vopmask_rvvm1_sleef vgt_vo_vi_vi_rvvm1_sleef(vint_rvvm1_sleef x, vint_rvvm1_sleef y) { + return __riscv_vmsgt(x, y, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE vint_rvvm1_sleef vgt_vi_vi_vi_rvvm1_sleef(vint_rvvm1_sleef x, vint_rvvm1_sleef y) { + vint_rvvm1_sleef zero = vcast_vi_i_rvvm1_sleef(0); + return __riscv_vmerge(zero, -1, __riscv_vmsgt(x, y, __riscv_vsetvlmax_e64m1()), __riscv_vsetvlmax_e64m1()); +} + +static SLEEF_ALWAYS_INLINE vint_rvvm1_sleef vsel_vi_vo_vi_vi_rvvm1_sleef(rvv_dp_vopmask_rvvm1_sleef m, vint_rvvm1_sleef x, vint_rvvm1_sleef y) { + return __riscv_vmerge(y, x, m, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE vint_rvvm1_sleef vandnot_vi_vo_vi_rvvm1_sleef(rvv_dp_vopmask_rvvm1_sleef mask, vint_rvvm1_sleef vi) { + return __riscv_vmerge(vi, 0, mask, __riscv_vsetvlmax_e64m1()); +} +static SLEEF_ALWAYS_INLINE vint_rvvm1_sleef vand_vi_vo_vi_rvvm1_sleef(rvv_dp_vopmask_rvvm1_sleef x, vint_rvvm1_sleef y) { + return __riscv_vmerge(y, 0, __riscv_vmnot(x, __riscv_vsetvlmax_e64m1()), __riscv_vsetvlmax_e64m1()); +} + +static SLEEF_ALWAYS_INLINE vdouble_rvvm1_sleef vposneg_vd_vd_rvvm1_sleef(vdouble_rvvm1_sleef d) { + rvv_dp_vopmask_rvvm1_sleef mask = __riscv_vreinterpret_b64(__riscv_vmv_v_x_u8m1(0x55, __riscv_vsetvlmax_e8m1())); + vdouble_rvvm1_sleef nd = __riscv_vfneg(d, __riscv_vsetvlmax_e64m1()); + return __riscv_vmerge(nd, d, mask, __riscv_vsetvlmax_e64m1()); +} + +static SLEEF_ALWAYS_INLINE vdouble_rvvm1_sleef vnegpos_vd_vd_rvvm1_sleef(vdouble_rvvm1_sleef d) { + rvv_dp_vopmask_rvvm1_sleef mask = __riscv_vreinterpret_b64(__riscv_vmv_v_x_u8m1(0xaa, __riscv_vsetvlmax_e8m1())); + vdouble_rvvm1_sleef nd = __riscv_vfneg(d, __riscv_vsetvlmax_e64m1()); + return __riscv_vmerge(nd, d, mask, __riscv_vsetvlmax_e64m1()); +} + +static SLEEF_ALWAYS_INLINE vfloat_rvvm1_sleef vposneg_vf_vf_rvvm1_sleef(vfloat_rvvm1_sleef d) { + rvv_sp_vopmask_rvvm1_sleef mask = __riscv_vreinterpret_b32(__riscv_vmv_v_x_u8m1(0x55, __riscv_vsetvlmax_e8m1())); + vfloat_rvvm1_sleef nd = __riscv_vfneg(d, (__riscv_vsetvlmax_e32m1())); + return __riscv_vmerge(nd, d, mask, (__riscv_vsetvlmax_e32m1())); +} + +static SLEEF_ALWAYS_INLINE vfloat_rvvm1_sleef vnegpos_vf_vf_rvvm1_sleef(vfloat_rvvm1_sleef d) { + rvv_sp_vopmask_rvvm1_sleef mask = __riscv_vreinterpret_b32(__riscv_vmv_v_x_u8m1(0xaa, __riscv_vsetvlmax_e8m1())); + vfloat_rvvm1_sleef nd = __riscv_vfneg(d, (__riscv_vsetvlmax_e32m1())); + return __riscv_vmerge(nd, d, mask, (__riscv_vsetvlmax_e32m1())); +} + +static SLEEF_ALWAYS_INLINE vdouble_rvvm1_sleef vsubadd_vd_vd_vd_rvvm1_sleef(vdouble_rvvm1_sleef x, vdouble_rvvm1_sleef y) { return vadd_vd_vd_vd_rvvm1_sleef(x, vnegpos_vd_vd_rvvm1_sleef(y)); } +static SLEEF_ALWAYS_INLINE vfloat_rvvm1_sleef vsubadd_vf_vf_vf_rvvm1_sleef(vfloat_rvvm1_sleef d0, vfloat_rvvm1_sleef d1) { return vadd_vf_vf_vf_rvvm1_sleef(d0, vnegpos_vf_vf_rvvm1_sleef(d1)); } +static SLEEF_ALWAYS_INLINE vdouble_rvvm1_sleef vmlsubadd_vd_vd_vd_vd_rvvm1_sleef(vdouble_rvvm1_sleef x, vdouble_rvvm1_sleef y, vdouble_rvvm1_sleef z) { return vfma_vd_vd_vd_vd_rvvm1_sleef(x, y, vnegpos_vd_vd_rvvm1_sleef(z)); } +static SLEEF_ALWAYS_INLINE vfloat_rvvm1_sleef vmlsubadd_vf_vf_vf_vf_rvvm1_sleef(vfloat_rvvm1_sleef x, vfloat_rvvm1_sleef y, vfloat_rvvm1_sleef z) { return vfma_vf_vf_vf_vf_rvvm1_sleef(x, y, vnegpos_vf_vf_rvvm1_sleef(z)); } + +static SLEEF_ALWAYS_INLINE vdouble_rvvm1_sleef vrev21_vd_vd_rvvm1_sleef(vdouble_rvvm1_sleef vd_rvvm1_sleef) { + rvv_dp_vuint2 id = __riscv_vid_v_u64m1(__riscv_vsetvlmax_e64m1()); + id = __riscv_vxor(id, 1, __riscv_vsetvlmax_e64m1()); + return __riscv_vrgather(vd_rvvm1_sleef, id, __riscv_vsetvlmax_e64m1()); +} + +static SLEEF_ALWAYS_INLINE vfloat_rvvm1_sleef vrev21_vf_vf_rvvm1_sleef(vfloat_rvvm1_sleef vf) { + vint2_rvvm1_sleef id = __riscv_vreinterpret_i32m1(__riscv_vid_v_u32m1((__riscv_vsetvlmax_e32m1()))); + id = __riscv_vxor(id, 1, (__riscv_vsetvlmax_e32m1())); + return __riscv_vrgather(vf, __riscv_vreinterpret_u32m1(id), (__riscv_vsetvlmax_e32m1())); +} + +static SLEEF_ALWAYS_INLINE vdouble_rvvm1_sleef vreva2_vd_vd_rvvm1_sleef(vdouble_rvvm1_sleef vd_rvvm1_sleef) { + rvv_dp_vuint2 id = __riscv_vid_v_u64m1(__riscv_vsetvlmax_e64m1()); + id = __riscv_vxor(id, __riscv_vsetvlmax_e64m1() - 2, __riscv_vsetvlmax_e64m1()); + return __riscv_vrgather(vd_rvvm1_sleef, id, __riscv_vsetvlmax_e64m1()); +} + +static SLEEF_ALWAYS_INLINE vfloat_rvvm1_sleef vreva2_vf_vf_rvvm1_sleef(vfloat_rvvm1_sleef vf) { + vint2_rvvm1_sleef id = __riscv_vreinterpret_i32m1(__riscv_vid_v_u32m1((__riscv_vsetvlmax_e32m1()))); + id = __riscv_vxor(id, (__riscv_vsetvlmax_e32m1()) - 2, (__riscv_vsetvlmax_e32m1())); + return __riscv_vrgather(vf, __riscv_vreinterpret_u32m1(id), (__riscv_vsetvlmax_e32m1())); +} + +static SLEEF_ALWAYS_INLINE void vscatter2_v_p_i_i_vd_rvvm1_sleef(double *ptr, int offset, int step, vdouble_rvvm1_sleef v) { + + ptr += offset * 2; + for (int i = 0; i < __riscv_vsetvlmax_e64m1(); i += 2) { + + vdouble_rvvm1_sleef vv = __riscv_vslidedown(v, i, 2); + __riscv_vse64(ptr, vv, 2); + ptr += step * 2; + } +} + +static SLEEF_ALWAYS_INLINE void vscatter2_v_p_i_i_vf_rvvm1_sleef(float *ptr, int offset, int step, vfloat_rvvm1_sleef v) { + + ptr += offset * 2; + for (int i = 0; i < (__riscv_vsetvlmax_e32m1()); i += 2) { + vfloat_rvvm1_sleef vv = __riscv_vslidedown(v, i, 2); + __riscv_vse32(ptr, vv, 2); + ptr += step * 2; + } +} + +static SLEEF_ALWAYS_INLINE vmask_rvvm1_sleef tdxgete_vm_tdx_rvvm1_sleef(tdx_rvvm1_sleef t) { + return __riscv_vreinterpret_u64m1(__riscv_vget_f64m1(t, 0)); +} +static SLEEF_ALWAYS_INLINE vdouble_rvvm1_sleef tdxgetd3x_vd_tdx_rvvm1_sleef(tdx_rvvm1_sleef t) { + return __riscv_vget_f64m1(t, 1); +} +static SLEEF_ALWAYS_INLINE vdouble_rvvm1_sleef tdxgetd3y_vd_tdx_rvvm1_sleef(tdx_rvvm1_sleef t) { + return __riscv_vget_f64m1(t, 2); +} +static SLEEF_ALWAYS_INLINE vdouble_rvvm1_sleef tdxgetd3z_vd_tdx_rvvm1_sleef(tdx_rvvm1_sleef t) { + return __riscv_vget_f64m1(t, 3); +} +static SLEEF_ALWAYS_INLINE tdx_rvvm1_sleef tdxsete_tdx_tdx_vm_rvvm1_sleef(tdx_rvvm1_sleef t, vmask_rvvm1_sleef e) { + return __riscv_vset(t, 0, __riscv_vreinterpret_f64m1(__riscv_vreinterpret_i64m1(e))); +} +static SLEEF_ALWAYS_INLINE tdx_rvvm1_sleef tdxsetx_tdx_tdx_vd_rvvm1_sleef(tdx_rvvm1_sleef t, vdouble_rvvm1_sleef x) { + return __riscv_vset(t, 1, x); +} +static SLEEF_ALWAYS_INLINE tdx_rvvm1_sleef tdxsety_tdx_tdx_vd_rvvm1_sleef(tdx_rvvm1_sleef t, vdouble_rvvm1_sleef y) { + return __riscv_vset(t, 2, y); +} +static SLEEF_ALWAYS_INLINE tdx_rvvm1_sleef tdxsetz_tdx_tdx_vd_rvvm1_sleef(tdx_rvvm1_sleef t, vdouble_rvvm1_sleef z) { + return __riscv_vset(t, 3, z); +} + +static SLEEF_ALWAYS_INLINE vdouble3_rvvm1_sleef tdxgetd3_vd3_tdx_rvvm1_sleef(tdx_rvvm1_sleef t) { + return vd3setxyz_vd3_vd_vd_vd_rvvm1_sleef(tdxgetd3x_vd_tdx_rvvm1_sleef(t), tdxgetd3y_vd_tdx_rvvm1_sleef(t), tdxgetd3z_vd_tdx_rvvm1_sleef(t)); +} + +static SLEEF_ALWAYS_INLINE tdx_rvvm1_sleef tdxsetxyz_tdx_tdx_vd_vd_vd_rvvm1_sleef(tdx_rvvm1_sleef t, vdouble_rvvm1_sleef x, vdouble_rvvm1_sleef y, vdouble_rvvm1_sleef z) { + t = tdxsetx_tdx_tdx_vd_rvvm1_sleef(t, x); + t = tdxsety_tdx_tdx_vd_rvvm1_sleef(t, y); + t = tdxsetz_tdx_tdx_vd_rvvm1_sleef(t, z); + return t; +} +static SLEEF_ALWAYS_INLINE tdx_rvvm1_sleef tdxsetd3_tdx_tdx_vd3_rvvm1_sleef(tdx_rvvm1_sleef t, vdouble3_rvvm1_sleef d3) { + return tdxsetxyz_tdx_tdx_vd_vd_vd_rvvm1_sleef(t, vd3getx_vd_vd3_rvvm1_sleef(d3), vd3gety_vd_vd3_rvvm1_sleef(d3), vd3getz_vd_vd3_rvvm1_sleef(d3)); +} + +static SLEEF_ALWAYS_INLINE tdx_rvvm1_sleef tdxseted3_tdx_vm_vd3_rvvm1_sleef(vmask_rvvm1_sleef e, vdouble3_rvvm1_sleef d3) { + return __riscv_vcreate_v_f64m1x4(__riscv_vreinterpret_f64m1(__riscv_vreinterpret_i64m1(e)), + vd3getx_vd_vd3_rvvm1_sleef(d3), vd3gety_vd_vd3_rvvm1_sleef(d3), vd3getz_vd_vd3_rvvm1_sleef(d3)); +} +static SLEEF_ALWAYS_INLINE tdx_rvvm1_sleef tdxsetexyz_tdx_vm_vd_vd_vd_rvvm1_sleef(vmask_rvvm1_sleef e, vdouble_rvvm1_sleef x, vdouble_rvvm1_sleef y, vdouble_rvvm1_sleef z) { + return __riscv_vcreate_v_f64m1x4(__riscv_vreinterpret_f64m1(__riscv_vreinterpret_i64m1(e)), x, y, z); +} + +static SLEEF_ALWAYS_INLINE vdouble_rvvm1_sleef tdigetx_vd_tdi_rvvm1_sleef(tdi_t_rvvm1_sleef d) { + return __riscv_vget_f64m1(d, 0); +} +static SLEEF_ALWAYS_INLINE vdouble_rvvm1_sleef tdigety_vd_tdi(tdi_t_rvvm1_sleef d) { + return __riscv_vget_f64m1(d, 1); +} +static SLEEF_ALWAYS_INLINE vdouble_rvvm1_sleef tdigetz_vd_tdi(tdi_t_rvvm1_sleef d) { + return __riscv_vget_f64m1(d, 2); +} + +static SLEEF_ALWAYS_INLINE vint_rvvm1_sleef tdigeti_vi_tdi_rvvm1_sleef(tdi_t_rvvm1_sleef d) { + vdouble_rvvm1_sleef vd_rvvm1_sleef = __riscv_vget_f64m1(d, 3); + vint2_rvvm1_sleef vi2 = __riscv_vreinterpret_i32m1(__riscv_vreinterpret_i64m1(vd_rvvm1_sleef)); + vint_rvvm1_sleef vi = __riscv_vlmul_trunc_i32mf2(vi2); + return vi; +} +static SLEEF_ALWAYS_INLINE tdi_t_rvvm1_sleef tdisetx_tdi_tdi_vd(tdi_t_rvvm1_sleef t, vdouble_rvvm1_sleef x) { + return __riscv_vset(t, 0, x); +} +static SLEEF_ALWAYS_INLINE tdi_t_rvvm1_sleef tdisety_tdi_tdi_vd(tdi_t_rvvm1_sleef t, vdouble_rvvm1_sleef y) { + return __riscv_vset(t, 1, y); +} +static SLEEF_ALWAYS_INLINE tdi_t_rvvm1_sleef tdisetz_tdi_tdi_vd(tdi_t_rvvm1_sleef t, vdouble_rvvm1_sleef z) { + return __riscv_vset(t, 2, z); +} +static SLEEF_ALWAYS_INLINE tdi_t_rvvm1_sleef tdiseti_tdi_tdi_vi(tdi_t_rvvm1_sleef t, vint_rvvm1_sleef i) { + vint2_rvvm1_sleef vi2 = __riscv_vmv_v(__riscv_vlmul_ext_v_i32mf2_i32m1(i), __riscv_vsetvlmax_e32mf2()); + vdouble_rvvm1_sleef vd_rvvm1_sleef = __riscv_vreinterpret_f64m1(__riscv_vreinterpret_i64m1(vi2)); + return __riscv_vset(t, 3, vd_rvvm1_sleef); +} + +static SLEEF_ALWAYS_INLINE vdouble3_rvvm1_sleef tdigettd_vd3_tdi_rvvm1_sleef(tdi_t_rvvm1_sleef d) { + return vd3setxyz_vd3_vd_vd_vd_rvvm1_sleef(tdigetx_vd_tdi_rvvm1_sleef(d), tdigety_vd_tdi(d), tdigetz_vd_tdi(d)); +} +static SLEEF_ALWAYS_INLINE tdi_t_rvvm1_sleef tdisettd_tdi_tdi_vd3(tdi_t_rvvm1_sleef tdi, vdouble3_rvvm1_sleef v) { + tdi = tdisetx_tdi_tdi_vd(tdi, vd3getx_vd_vd3_rvvm1_sleef(v)); + tdi = tdisety_tdi_tdi_vd(tdi, vd3gety_vd_vd3_rvvm1_sleef(v)); + tdi = tdisetz_tdi_tdi_vd(tdi, vd3getz_vd_vd3_rvvm1_sleef(v)); + return tdi; +} +static SLEEF_ALWAYS_INLINE tdi_t_rvvm1_sleef tdisettdi_tdi_vd3_vi_rvvm1_sleef(vdouble3_rvvm1_sleef v, vint_rvvm1_sleef i) { + tdi_t_rvvm1_sleef ret = __riscv_vcreate_v_f64m1x4(vd3getx_vd_vd3_rvvm1_sleef(v), vd3gety_vd_vd3_rvvm1_sleef(v), vd3getz_vd_vd3_rvvm1_sleef(v), vd3getz_vd_vd3_rvvm1_sleef(v)); + return tdiseti_tdi_tdi_vi(ret, i); +} + +static SLEEF_ALWAYS_INLINE rvv_dp_vopmask_rvvm1_sleef vcast_vo_i_rvvm1_sleef(int i) { + return __riscv_vreinterpret_b64(__riscv_vmv_v_x_u32m1(i, (__riscv_vsetvlmax_e32m1()))); +} +static SLEEF_ALWAYS_INLINE vmask_rvvm1_sleef vreinterpret_vm_vi64_rvvm1_sleef(vint64_rvvm1_sleef v) { + return __riscv_vreinterpret_u64m1(v); +} +static SLEEF_ALWAYS_INLINE vint64_rvvm1_sleef vreinterpret_vi64_vm_rvvm1_sleef(vmask_rvvm1_sleef m) { + return __riscv_vreinterpret_i64m1(m); +} +static SLEEF_ALWAYS_INLINE vmask_rvvm1_sleef vreinterpret_vm_vu64_rvvm1_sleef(vuint64_rvvm1_sleef v) { + return v; +} +static SLEEF_ALWAYS_INLINE vuint64_rvvm1_sleef vreinterpret_vu64_vm_rvvm1_sleef(vmask_rvvm1_sleef m) { + return m; +} +static SLEEF_ALWAYS_INLINE int vtestallzeros_i_vo64_rvvm1_sleef(rvv_dp_vopmask_rvvm1_sleef g) { + return __riscv_vcpop(g, __riscv_vsetvlmax_e64m1()) == 0; +} + +static SLEEF_ALWAYS_INLINE void vstream_v_p_vd_rvvm1_sleef(double *ptr, vdouble_rvvm1_sleef v) { vstore_v_p_vd_rvvm1_sleef(ptr, v); } +static SLEEF_ALWAYS_INLINE void vstream_v_p_vf_rvvm1_sleef(float *ptr, vfloat_rvvm1_sleef v) { vstore_v_p_vf_rvvm1_sleef(ptr, v); } +static SLEEF_ALWAYS_INLINE void vsscatter2_v_p_i_i_vd_rvvm1_sleef(double *ptr, int offset, int step, vdouble_rvvm1_sleef v) { vscatter2_v_p_i_i_vd_rvvm1_sleef(ptr, offset, step, v); } +static SLEEF_ALWAYS_INLINE void vsscatter2_v_p_i_i_vf_rvvm1_sleef(float *ptr, int offset, int step, vfloat_rvvm1_sleef v) { vscatter2_v_p_i_i_vf_rvvm1_sleef(ptr, offset, step, v); } + +static double vcast_d_vd_rvvm1_sleef(vdouble_rvvm1_sleef v) { + return __riscv_vfmv_f(v); +} + +static float vcast_f_vf_rvvm1_sleef(vfloat_rvvm1_sleef v) { + return __riscv_vfmv_f(v); +} + +static int vcast_i_vi(vint_rvvm1_sleef v) { + return __riscv_vmv_x(v); +} + +static int vcast_i_vi2(vint2_rvvm1_sleef v) { + return __riscv_vmv_x(v); +} + +static vquad_rvvm1_sleef loadu_vq_p_rvvm1_sleef(const int32_t *ptr) { + + return __riscv_vreinterpret_u64m2(__riscv_vreinterpret_u32m2(__riscv_vle32_v_i32m2(ptr, (__riscv_vsetvlmax_e32m1()) * 2))); +} + +static SLEEF_ALWAYS_INLINE vquad_rvvm1_sleef cast_vq_aq_rvvm1_sleef(vargquad_rvvm1_sleef aq) { return aq; } +static SLEEF_ALWAYS_INLINE vargquad_rvvm1_sleef cast_aq_vq_rvvm1_sleef(vquad_rvvm1_sleef vq) { return vq; } + +static SLEEF_ALWAYS_INLINE void vprefetch_v_p_rvvm1_sleef(const void *ptr) {} + +typedef struct { + double x, y; +} double2_rvvm1_sleef; + +static SLEEF_ALWAYS_INLINE SLEEF_CONST double2_rvvm1_sleef dd_rvvm1_sleef(double h, double l) { + double2_rvvm1_sleef ret = { h, l }; + return ret; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_rvvm1_sleef vupper_vd_vd_rvvm1_sleef(vdouble_rvvm1_sleef d) { + return vreinterpret_vd_vm_rvvm1_sleef(vand_vm_vm_vm_rvvm1_sleef(vreinterpret_vm_vd_rvvm1_sleef(d), vcast_vm_i_i_rvvm1_sleef(0xffffffff, 0xf8000000))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_rvvm1_sleef vcast_vd2_vd_vd_rvvm1_sleef(vdouble_rvvm1_sleef h, vdouble_rvvm1_sleef l) { + return vd2setxy_vd2_vd_vd_rvvm1_sleef(h, l); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_rvvm1_sleef vcast_vd2_d_d_rvvm1_sleef(double h, double l) { + return vd2setxy_vd2_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(h), vcast_vd_d_rvvm1_sleef(l)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_rvvm1_sleef vcast_vd2_d2_rvvm1_sleef(double2_rvvm1_sleef dd_rvvm1_sleef) { + return vd2setxy_vd2_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(dd_rvvm1_sleef.x), vcast_vd_d_rvvm1_sleef(dd_rvvm1_sleef.y)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_rvvm1_sleef vsel_vd2_vo_vd2_vd2_rvvm1_sleef(rvv_dp_vopmask_rvvm1_sleef m, vdouble2_rvvm1_sleef x, vdouble2_rvvm1_sleef y) { + return vd2setxy_vd2_vd_vd_rvvm1_sleef(vsel_vd_vo_vd_vd_rvvm1_sleef(m, vd2getx_vd_vd2_rvvm1_sleef(x), vd2getx_vd_vd2_rvvm1_sleef(y)), + vsel_vd_vo_vd_vd_rvvm1_sleef(m, vd2gety_vd_vd2_rvvm1_sleef(x), vd2gety_vd_vd2_rvvm1_sleef(y))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_rvvm1_sleef vsel_vd2_vo_d_d_d_d_rvvm1_sleef(rvv_dp_vopmask_rvvm1_sleef o, double x1, double y1, double x0, double y0) { + return vd2setxy_vd2_vd_vd_rvvm1_sleef(vsel_vd_vo_d_d_rvvm1_sleef(o, x1, x0), + vsel_vd_vo_d_d_rvvm1_sleef(o, y1, y0)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_rvvm1_sleef vadd_vd_3vd_rvvm1_sleef(vdouble_rvvm1_sleef v0, vdouble_rvvm1_sleef v1, vdouble_rvvm1_sleef v2) { + return vadd_vd_vd_vd_rvvm1_sleef(vadd_vd_vd_vd_rvvm1_sleef(v0, v1), v2); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_rvvm1_sleef vadd_vd_4vd_rvvm1_sleef(vdouble_rvvm1_sleef v0, vdouble_rvvm1_sleef v1, vdouble_rvvm1_sleef v2, vdouble_rvvm1_sleef v3) { + return vadd_vd_3vd_rvvm1_sleef(vadd_vd_vd_vd_rvvm1_sleef(v0, v1), v2, v3); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_rvvm1_sleef vadd_vd_5vd_rvvm1_sleef(vdouble_rvvm1_sleef v0, vdouble_rvvm1_sleef v1, vdouble_rvvm1_sleef v2, vdouble_rvvm1_sleef v3, vdouble_rvvm1_sleef v4) { + return vadd_vd_4vd_rvvm1_sleef(vadd_vd_vd_vd_rvvm1_sleef(v0, v1), v2, v3, v4); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_rvvm1_sleef vadd_vd_6vd_rvvm1_sleef(vdouble_rvvm1_sleef v0, vdouble_rvvm1_sleef v1, vdouble_rvvm1_sleef v2, vdouble_rvvm1_sleef v3, vdouble_rvvm1_sleef v4, vdouble_rvvm1_sleef v5) { + return vadd_vd_5vd_rvvm1_sleef(vadd_vd_vd_vd_rvvm1_sleef(v0, v1), v2, v3, v4, v5); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_rvvm1_sleef vadd_vd_7vd_rvvm1_sleef(vdouble_rvvm1_sleef v0, vdouble_rvvm1_sleef v1, vdouble_rvvm1_sleef v2, vdouble_rvvm1_sleef v3, vdouble_rvvm1_sleef v4, vdouble_rvvm1_sleef v5, vdouble_rvvm1_sleef v6) { + return vadd_vd_6vd_rvvm1_sleef(vadd_vd_vd_vd_rvvm1_sleef(v0, v1), v2, v3, v4, v5, v6); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_rvvm1_sleef vsub_vd_3vd_rvvm1_sleef(vdouble_rvvm1_sleef v0, vdouble_rvvm1_sleef v1, vdouble_rvvm1_sleef v2) { + return vsub_vd_vd_vd_rvvm1_sleef(vsub_vd_vd_vd_rvvm1_sleef(v0, v1), v2); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_rvvm1_sleef vsub_vd_4vd_rvvm1_sleef(vdouble_rvvm1_sleef v0, vdouble_rvvm1_sleef v1, vdouble_rvvm1_sleef v2, vdouble_rvvm1_sleef v3) { + return vsub_vd_3vd_rvvm1_sleef(vsub_vd_vd_vd_rvvm1_sleef(v0, v1), v2, v3); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_rvvm1_sleef vsub_vd_5vd_rvvm1_sleef(vdouble_rvvm1_sleef v0, vdouble_rvvm1_sleef v1, vdouble_rvvm1_sleef v2, vdouble_rvvm1_sleef v3, vdouble_rvvm1_sleef v4) { + return vsub_vd_4vd_rvvm1_sleef(vsub_vd_vd_vd_rvvm1_sleef(v0, v1), v2, v3, v4); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_rvvm1_sleef vsub_vd_6vd_rvvm1_sleef(vdouble_rvvm1_sleef v0, vdouble_rvvm1_sleef v1, vdouble_rvvm1_sleef v2, vdouble_rvvm1_sleef v3, vdouble_rvvm1_sleef v4, vdouble_rvvm1_sleef v5) { + return vsub_vd_5vd_rvvm1_sleef(vsub_vd_vd_vd_rvvm1_sleef(v0, v1), v2, v3, v4, v5); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_rvvm1_sleef ddneg_vd2_vd2_rvvm1_sleef(vdouble2_rvvm1_sleef x) { + return vcast_vd2_vd_vd_rvvm1_sleef(vneg_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(x)), vneg_vd_vd_rvvm1_sleef(vd2gety_vd_vd2_rvvm1_sleef(x))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_rvvm1_sleef ddabs_vd2_vd2_rvvm1_sleef(vdouble2_rvvm1_sleef x) { + return vcast_vd2_vd_vd_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(x)), + vreinterpret_vd_vm_rvvm1_sleef(vxor_vm_vm_vm_rvvm1_sleef(vreinterpret_vm_vd_rvvm1_sleef(vd2gety_vd_vd2_rvvm1_sleef(x)), + vand_vm_vm_vm_rvvm1_sleef(vreinterpret_vm_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(x)), + vreinterpret_vm_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(-0.0)))))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_rvvm1_sleef ddnormalize_vd2_vd2_rvvm1_sleef(vdouble2_rvvm1_sleef t) { + vdouble_rvvm1_sleef s = vadd_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(t), vd2gety_vd_vd2_rvvm1_sleef(t)); + return vd2setxy_vd2_vd_vd_rvvm1_sleef(s, vadd_vd_vd_vd_rvvm1_sleef(vsub_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(t), s), vd2gety_vd_vd2_rvvm1_sleef(t))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_rvvm1_sleef ddscale_vd2_vd2_vd_rvvm1_sleef(vdouble2_rvvm1_sleef d, vdouble_rvvm1_sleef s) { + return vd2setxy_vd2_vd_vd_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(d), s), vmul_vd_vd_vd_rvvm1_sleef(vd2gety_vd_vd2_rvvm1_sleef(d), s)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_rvvm1_sleef ddscale_vd2_vd2_d_rvvm1_sleef(vdouble2_rvvm1_sleef d, double s) { return ddscale_vd2_vd2_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(s)); } + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_rvvm1_sleef ddadd_vd2_vd_vd_rvvm1_sleef(vdouble_rvvm1_sleef x, vdouble_rvvm1_sleef y) { + vdouble_rvvm1_sleef s = vadd_vd_vd_vd_rvvm1_sleef(x, y); + return vd2setxy_vd2_vd_vd_rvvm1_sleef(s, vadd_vd_vd_vd_rvvm1_sleef(vsub_vd_vd_vd_rvvm1_sleef(x, s), y)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_rvvm1_sleef ddadd2_vd2_vd_vd_rvvm1_sleef(vdouble_rvvm1_sleef x, vdouble_rvvm1_sleef y) { + vdouble_rvvm1_sleef s = vadd_vd_vd_vd_rvvm1_sleef(x, y); + vdouble_rvvm1_sleef v = vsub_vd_vd_vd_rvvm1_sleef(s, x); + return vd2setxy_vd2_vd_vd_rvvm1_sleef(s, vadd_vd_vd_vd_rvvm1_sleef(vsub_vd_vd_vd_rvvm1_sleef(x, vsub_vd_vd_vd_rvvm1_sleef(s, v)), vsub_vd_vd_vd_rvvm1_sleef(y, v))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_rvvm1_sleef ddadd_vd2_vd2_vd_rvvm1_sleef(vdouble2_rvvm1_sleef x, vdouble_rvvm1_sleef y) { + vdouble_rvvm1_sleef s = vadd_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(x), y); + return vd2setxy_vd2_vd_vd_rvvm1_sleef(s, vadd_vd_3vd_rvvm1_sleef(vsub_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(x), s), y, vd2gety_vd_vd2_rvvm1_sleef(x))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_rvvm1_sleef ddsub_vd2_vd2_vd_rvvm1_sleef(vdouble2_rvvm1_sleef x, vdouble_rvvm1_sleef y) { + vdouble_rvvm1_sleef s = vsub_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(x), y); + return vd2setxy_vd2_vd_vd_rvvm1_sleef(s, vadd_vd_vd_vd_rvvm1_sleef(vsub_vd_vd_vd_rvvm1_sleef(vsub_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(x), s), y), vd2gety_vd_vd2_rvvm1_sleef(x))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_rvvm1_sleef ddadd2_vd2_vd2_vd_rvvm1_sleef(vdouble2_rvvm1_sleef x, vdouble_rvvm1_sleef y) { + vdouble_rvvm1_sleef s = vadd_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(x), y); + vdouble_rvvm1_sleef v = vsub_vd_vd_vd_rvvm1_sleef(s, vd2getx_vd_vd2_rvvm1_sleef(x)); + vdouble_rvvm1_sleef w = vadd_vd_vd_vd_rvvm1_sleef(vsub_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(x), vsub_vd_vd_vd_rvvm1_sleef(s, v)), vsub_vd_vd_vd_rvvm1_sleef(y, v)); + return vd2setxy_vd2_vd_vd_rvvm1_sleef(s, vadd_vd_vd_vd_rvvm1_sleef(w, vd2gety_vd_vd2_rvvm1_sleef(x))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_rvvm1_sleef ddadd_vd2_vd_vd2_rvvm1_sleef(vdouble_rvvm1_sleef x, vdouble2_rvvm1_sleef y) { + vdouble_rvvm1_sleef s = vadd_vd_vd_vd_rvvm1_sleef(x, vd2getx_vd_vd2_rvvm1_sleef(y)); + return vd2setxy_vd2_vd_vd_rvvm1_sleef(s, vadd_vd_3vd_rvvm1_sleef(vsub_vd_vd_vd_rvvm1_sleef(x, s), vd2getx_vd_vd2_rvvm1_sleef(y), vd2gety_vd_vd2_rvvm1_sleef(y))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_rvvm1_sleef ddadd2_vd2_vd_vd2_rvvm1_sleef(vdouble_rvvm1_sleef x, vdouble2_rvvm1_sleef y) { + vdouble_rvvm1_sleef s = vadd_vd_vd_vd_rvvm1_sleef(x, vd2getx_vd_vd2_rvvm1_sleef(y)); + vdouble_rvvm1_sleef v = vsub_vd_vd_vd_rvvm1_sleef(s, x); + return vd2setxy_vd2_vd_vd_rvvm1_sleef(s, vadd_vd_vd_vd_rvvm1_sleef(vadd_vd_vd_vd_rvvm1_sleef(vsub_vd_vd_vd_rvvm1_sleef(x, vsub_vd_vd_vd_rvvm1_sleef(s, v)), + vsub_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(y), v)), vd2gety_vd_vd2_rvvm1_sleef(y))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_rvvm1_sleef ddadd_vd2_vd2_vd2_rvvm1_sleef(vdouble2_rvvm1_sleef x, vdouble2_rvvm1_sleef y) { + + vdouble_rvvm1_sleef s = vadd_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(x), vd2getx_vd_vd2_rvvm1_sleef(y)); + return vd2setxy_vd2_vd_vd_rvvm1_sleef(s, vadd_vd_4vd_rvvm1_sleef(vsub_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(x), s), vd2getx_vd_vd2_rvvm1_sleef(y), vd2gety_vd_vd2_rvvm1_sleef(x), vd2gety_vd_vd2_rvvm1_sleef(y))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_rvvm1_sleef ddadd2_vd2_vd2_vd2_rvvm1_sleef(vdouble2_rvvm1_sleef x, vdouble2_rvvm1_sleef y) { + vdouble_rvvm1_sleef s = vadd_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(x), vd2getx_vd_vd2_rvvm1_sleef(y)); + vdouble_rvvm1_sleef v = vsub_vd_vd_vd_rvvm1_sleef(s, vd2getx_vd_vd2_rvvm1_sleef(x)); + vdouble_rvvm1_sleef t = vadd_vd_vd_vd_rvvm1_sleef(vsub_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(x), vsub_vd_vd_vd_rvvm1_sleef(s, v)), vsub_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(y), v)); + return vd2setxy_vd2_vd_vd_rvvm1_sleef(s, vadd_vd_vd_vd_rvvm1_sleef(t, vadd_vd_vd_vd_rvvm1_sleef(vd2gety_vd_vd2_rvvm1_sleef(x), vd2gety_vd_vd2_rvvm1_sleef(y)))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_rvvm1_sleef ddsub_vd2_vd_vd_rvvm1_sleef(vdouble_rvvm1_sleef x, vdouble_rvvm1_sleef y) { + + vdouble_rvvm1_sleef s = vsub_vd_vd_vd_rvvm1_sleef(x, y); + return vd2setxy_vd2_vd_vd_rvvm1_sleef(s, vsub_vd_vd_vd_rvvm1_sleef(vsub_vd_vd_vd_rvvm1_sleef(x, s), y)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_rvvm1_sleef ddsub_vd2_vd2_vd2_rvvm1_sleef(vdouble2_rvvm1_sleef x, vdouble2_rvvm1_sleef y) { + + vdouble_rvvm1_sleef s = vsub_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(x), vd2getx_vd_vd2_rvvm1_sleef(y)); + vdouble_rvvm1_sleef t = vsub_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(x), s); + t = vsub_vd_vd_vd_rvvm1_sleef(t, vd2getx_vd_vd2_rvvm1_sleef(y)); + t = vadd_vd_vd_vd_rvvm1_sleef(t, vd2gety_vd_vd2_rvvm1_sleef(x)); + return vd2setxy_vd2_vd_vd_rvvm1_sleef(s, vsub_vd_vd_vd_rvvm1_sleef(t, vd2gety_vd_vd2_rvvm1_sleef(y))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_rvvm1_sleef dddiv_vd2_vd2_vd2_rvvm1_sleef(vdouble2_rvvm1_sleef n, vdouble2_rvvm1_sleef d) { + vdouble_rvvm1_sleef t = vrec_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(d)); + vdouble_rvvm1_sleef s = vmul_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(n), t); + vdouble_rvvm1_sleef u = vfmapn_vd_vd_vd_vd_rvvm1_sleef(t, vd2getx_vd_vd2_rvvm1_sleef(n), s); + vdouble_rvvm1_sleef v = vfmanp_vd_vd_vd_vd_rvvm1_sleef(vd2gety_vd_vd2_rvvm1_sleef(d), t, vfmanp_vd_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(d), t, vcast_vd_d_rvvm1_sleef(1))); + return vd2setxy_vd2_vd_vd_rvvm1_sleef(s, vfma_vd_vd_vd_vd_rvvm1_sleef(s, v, vfma_vd_vd_vd_vd_rvvm1_sleef(vd2gety_vd_vd2_rvvm1_sleef(n), t, u))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_rvvm1_sleef ddmul_vd2_vd_vd_rvvm1_sleef(vdouble_rvvm1_sleef x, vdouble_rvvm1_sleef y) { + vdouble_rvvm1_sleef s = vmul_vd_vd_vd_rvvm1_sleef(x, y); + return vd2setxy_vd2_vd_vd_rvvm1_sleef(s, vfmapn_vd_vd_vd_vd_rvvm1_sleef(x, y, s)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_rvvm1_sleef ddsqu_vd2_vd2_rvvm1_sleef(vdouble2_rvvm1_sleef x) { + vdouble_rvvm1_sleef s = vmul_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(x), vd2getx_vd_vd2_rvvm1_sleef(x)); + return vd2setxy_vd2_vd_vd_rvvm1_sleef(s, vfma_vd_vd_vd_vd_rvvm1_sleef(vadd_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(x), vd2getx_vd_vd2_rvvm1_sleef(x)), vd2gety_vd_vd2_rvvm1_sleef(x), vfmapn_vd_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(x), vd2getx_vd_vd2_rvvm1_sleef(x), s))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_rvvm1_sleef ddmul_vd2_vd2_vd2_rvvm1_sleef(vdouble2_rvvm1_sleef x, vdouble2_rvvm1_sleef y) { + vdouble_rvvm1_sleef s = vmul_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(x), vd2getx_vd_vd2_rvvm1_sleef(y)); + return vd2setxy_vd2_vd_vd_rvvm1_sleef(s, vfma_vd_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(x), vd2gety_vd_vd2_rvvm1_sleef(y), vfma_vd_vd_vd_vd_rvvm1_sleef(vd2gety_vd_vd2_rvvm1_sleef(x), vd2getx_vd_vd2_rvvm1_sleef(y), vfmapn_vd_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(x), vd2getx_vd_vd2_rvvm1_sleef(y), s)))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_rvvm1_sleef ddmul_vd_vd2_vd2_rvvm1_sleef(vdouble2_rvvm1_sleef x, vdouble2_rvvm1_sleef y) { + return vfma_vd_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(x), vd2getx_vd_vd2_rvvm1_sleef(y), vfma_vd_vd_vd_vd_rvvm1_sleef(vd2gety_vd_vd2_rvvm1_sleef(x), vd2getx_vd_vd2_rvvm1_sleef(y), vmul_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(x), vd2gety_vd_vd2_rvvm1_sleef(y)))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_rvvm1_sleef ddsqu_vd_vd2_rvvm1_sleef(vdouble2_rvvm1_sleef x) { + return vfma_vd_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(x), vd2getx_vd_vd2_rvvm1_sleef(x), vadd_vd_vd_vd_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(x), vd2gety_vd_vd2_rvvm1_sleef(x)), vmul_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(x), vd2gety_vd_vd2_rvvm1_sleef(x)))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_rvvm1_sleef ddmul_vd2_vd2_vd_rvvm1_sleef(vdouble2_rvvm1_sleef x, vdouble_rvvm1_sleef y) { + vdouble_rvvm1_sleef s = vmul_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(x), y); + return vd2setxy_vd2_vd_vd_rvvm1_sleef(s, vfma_vd_vd_vd_vd_rvvm1_sleef(vd2gety_vd_vd2_rvvm1_sleef(x), y, vfmapn_vd_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(x), y, s))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_rvvm1_sleef ddrec_vd2_vd_rvvm1_sleef(vdouble_rvvm1_sleef d) { + vdouble_rvvm1_sleef s = vrec_vd_vd_rvvm1_sleef(d); + return vd2setxy_vd2_vd_vd_rvvm1_sleef(s, vmul_vd_vd_vd_rvvm1_sleef(s, vfmanp_vd_vd_vd_vd_rvvm1_sleef(d, s, vcast_vd_d_rvvm1_sleef(1)))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_rvvm1_sleef ddrec_vd2_vd2_rvvm1_sleef(vdouble2_rvvm1_sleef d) { + vdouble_rvvm1_sleef s = vrec_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(d)); + return vd2setxy_vd2_vd_vd_rvvm1_sleef(s, vmul_vd_vd_vd_rvvm1_sleef(s, vfmanp_vd_vd_vd_vd_rvvm1_sleef(vd2gety_vd_vd2_rvvm1_sleef(d), s, vfmanp_vd_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(d), s, vcast_vd_d_rvvm1_sleef(1))))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_rvvm1_sleef ddsqrt_vd2_vd2_rvvm1_sleef(vdouble2_rvvm1_sleef d) { + vdouble_rvvm1_sleef t = vsqrt_vd_vd_rvvm1_sleef(vadd_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(d), vd2gety_vd_vd2_rvvm1_sleef(d))); + return ddscale_vd2_vd2_vd_rvvm1_sleef(ddmul_vd2_vd2_vd2_rvvm1_sleef(ddadd2_vd2_vd2_vd2_rvvm1_sleef(d, ddmul_vd2_vd_vd_rvvm1_sleef(t, t)), ddrec_vd2_vd_rvvm1_sleef(t)), vcast_vd_d_rvvm1_sleef(0.5)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_rvvm1_sleef ddsqrt_vd2_vd_rvvm1_sleef(vdouble_rvvm1_sleef d) { + vdouble_rvvm1_sleef t = vsqrt_vd_vd_rvvm1_sleef(d); + return ddscale_vd2_vd2_vd_rvvm1_sleef(ddmul_vd2_vd2_vd2_rvvm1_sleef(ddadd2_vd2_vd_vd2_rvvm1_sleef(d, ddmul_vd2_vd_vd_rvvm1_sleef(t, t)), ddrec_vd2_vd_rvvm1_sleef(t)), vcast_vd_d_rvvm1_sleef(0.5)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_rvvm1_sleef ddmla_vd2_vd2_vd2_vd2_rvvm1_sleef(vdouble2_rvvm1_sleef x, vdouble2_rvvm1_sleef y, vdouble2_rvvm1_sleef z) { + return ddadd_vd2_vd2_vd2_rvvm1_sleef(z, ddmul_vd2_vd2_vd2_rvvm1_sleef(x, y)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST rvv_dp_vopmask_rvvm1_sleef visnegzero_vo_vd_rvvm1_sleef(vdouble_rvvm1_sleef d) { + return veq64_vo_vm_vm_rvvm1_sleef(vreinterpret_vm_vd_rvvm1_sleef(d), vreinterpret_vm_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(-0.0))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST rvv_dp_vopmask_rvvm1_sleef visnumber_vo_vd_rvvm1_sleef(vdouble_rvvm1_sleef x) { + return rvv_dp_vandnot_vo_vo_vo(visinf_vo_vd_rvvm1_sleef(x), veq_vo_vd_vd_rvvm1_sleef(x, x)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST rvv_dp_vopmask_rvvm1_sleef visnonfinite_vo_vd_rvvm1_sleef(vdouble_rvvm1_sleef x) { + return veq64_vo_vm_vm_rvvm1_sleef(vand_vm_vm_vm_rvvm1_sleef(vreinterpret_vm_vd_rvvm1_sleef(x), vcast_vm_i64_rvvm1_sleef(INT64_C(0x7ff0000000000000))), vcast_vm_i64_rvvm1_sleef(INT64_C(0x7ff0000000000000))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vmask_rvvm1_sleef vsignbit_vm_vd_rvvm1_sleef(vdouble_rvvm1_sleef d) { + return vand_vm_vm_vm_rvvm1_sleef(vreinterpret_vm_vd_rvvm1_sleef(d), vreinterpret_vm_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(-0.0))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST rvv_dp_vopmask_rvvm1_sleef vsignbit_vo_vd_rvvm1_sleef(vdouble_rvvm1_sleef d) { + return veq64_vo_vm_vm_rvvm1_sleef(vand_vm_vm_vm_rvvm1_sleef(vreinterpret_vm_vd_rvvm1_sleef(d), vreinterpret_vm_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(-0.0))), vreinterpret_vm_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(-0.0))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_rvvm1_sleef vclearlsb_vd_vd_i_rvvm1_sleef(vdouble_rvvm1_sleef d, int n) { + return vreinterpret_vd_vm_rvvm1_sleef(vand_vm_vm_vm_rvvm1_sleef(vreinterpret_vm_vd_rvvm1_sleef(d), vcast_vm_u64_rvvm1_sleef((~UINT64_C(0)) << n))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_rvvm1_sleef vtoward0_vd_vd_rvvm1_sleef(vdouble_rvvm1_sleef x) { + vdouble_rvvm1_sleef t = vreinterpret_vd_vm_rvvm1_sleef(vadd64_vm_vm_vm_rvvm1_sleef(vreinterpret_vm_vd_rvvm1_sleef(x), vcast_vm_i64_rvvm1_sleef(-1))); + return vsel_vd_vo_vd_vd_rvvm1_sleef(veq_vo_vd_vd_rvvm1_sleef(x, vcast_vd_d_rvvm1_sleef(0)), vcast_vd_d_rvvm1_sleef(0), t); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_rvvm1_sleef vsign_vd_vd_rvvm1_sleef(vdouble_rvvm1_sleef d) { + return vmulsign_vd_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(1.0), d); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_rvvm1_sleef vtruncate2_vd_vd_rvvm1_sleef_rvvm1_sleef(vdouble_rvvm1_sleef x) { + + vdouble_rvvm1_sleef fr = vsub_vd_vd_vd_rvvm1_sleef(x, vmul_vd_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(INT64_C(1) << 31), vcast_vd_vi_rvvm1_sleef(vtruncate_vi_vd_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(x, vcast_vd_d_rvvm1_sleef(1.0 / (INT64_C(1) << 31))))))); + fr = vsub_vd_vd_vd_rvvm1_sleef(fr, vcast_vd_vi_rvvm1_sleef(vtruncate_vi_vd_rvvm1_sleef(fr))); + return vsel_vd_vo_vd_vd_rvvm1_sleef(rvv_dp_vor_vo_vo_vo(visinf_vo_vd_rvvm1_sleef(x), vge_vo_vd_vd_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(x), vcast_vd_d_rvvm1_sleef(INT64_C(1) << 52))), x, vcopysign_vd_vd_vd_rvvm1_sleef(vsub_vd_vd_vd_rvvm1_sleef(x, fr), x)); + +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_rvvm1_sleef vfloor2_vd_vd_rvvm1_sleef(vdouble_rvvm1_sleef x) { + vdouble_rvvm1_sleef fr = vsub_vd_vd_vd_rvvm1_sleef(x, vmul_vd_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(INT64_C(1) << 31), vcast_vd_vi_rvvm1_sleef(vtruncate_vi_vd_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(x, vcast_vd_d_rvvm1_sleef(1.0 / (INT64_C(1) << 31))))))); + fr = vsub_vd_vd_vd_rvvm1_sleef(fr, vcast_vd_vi_rvvm1_sleef(vtruncate_vi_vd_rvvm1_sleef(fr))); + fr = vsel_vd_vo_vd_vd_rvvm1_sleef(vlt_vo_vd_vd_rvvm1_sleef(fr, vcast_vd_d_rvvm1_sleef(0)), vadd_vd_vd_vd_rvvm1_sleef(fr, vcast_vd_d_rvvm1_sleef(1.0)), fr); + return vsel_vd_vo_vd_vd_rvvm1_sleef(rvv_dp_vor_vo_vo_vo(visinf_vo_vd_rvvm1_sleef(x), vge_vo_vd_vd_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(x), vcast_vd_d_rvvm1_sleef(INT64_C(1) << 52))), x, vcopysign_vd_vd_vd_rvvm1_sleef(vsub_vd_vd_vd_rvvm1_sleef(x, fr), x)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_rvvm1_sleef vceil2_vd_vd_rvvm1_sleef(vdouble_rvvm1_sleef x) { + vdouble_rvvm1_sleef fr = vsub_vd_vd_vd_rvvm1_sleef(x, vmul_vd_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(INT64_C(1) << 31), vcast_vd_vi_rvvm1_sleef(vtruncate_vi_vd_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(x, vcast_vd_d_rvvm1_sleef(1.0 / (INT64_C(1) << 31))))))); + fr = vsub_vd_vd_vd_rvvm1_sleef(fr, vcast_vd_vi_rvvm1_sleef(vtruncate_vi_vd_rvvm1_sleef(fr))); + fr = vsel_vd_vo_vd_vd_rvvm1_sleef(vle_vo_vd_vd_rvvm1_sleef(fr, vcast_vd_d_rvvm1_sleef(0)), fr, vsub_vd_vd_vd_rvvm1_sleef(fr, vcast_vd_d_rvvm1_sleef(1.0))); + return vsel_vd_vo_vd_vd_rvvm1_sleef(rvv_dp_vor_vo_vo_vo(visinf_vo_vd_rvvm1_sleef(x), vge_vo_vd_vd_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(x), vcast_vd_d_rvvm1_sleef(INT64_C(1) << 52))), x, vcopysign_vd_vd_vd_rvvm1_sleef(vsub_vd_vd_vd_rvvm1_sleef(x, fr), x)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_rvvm1_sleef vround2_vd_vd_rvvm1_sleef(vdouble_rvvm1_sleef d) { + vdouble_rvvm1_sleef x = vadd_vd_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(0.5)); + vdouble_rvvm1_sleef fr = vsub_vd_vd_vd_rvvm1_sleef(x, vmul_vd_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(INT64_C(1) << 31), vcast_vd_vi_rvvm1_sleef(vtruncate_vi_vd_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(x, vcast_vd_d_rvvm1_sleef(1.0 / (INT64_C(1) << 31))))))); + fr = vsub_vd_vd_vd_rvvm1_sleef(fr, vcast_vd_vi_rvvm1_sleef(vtruncate_vi_vd_rvvm1_sleef(fr))); + x = vsel_vd_vo_vd_vd_rvvm1_sleef(rvv_dp_vand_vo_vo_vo(vle_vo_vd_vd_rvvm1_sleef(x, vcast_vd_d_rvvm1_sleef(0)), veq_vo_vd_vd_rvvm1_sleef(fr, vcast_vd_d_rvvm1_sleef(0))), vsub_vd_vd_vd_rvvm1_sleef(x, vcast_vd_d_rvvm1_sleef(1.0)), x); + fr = vsel_vd_vo_vd_vd_rvvm1_sleef(vlt_vo_vd_vd_rvvm1_sleef(fr, vcast_vd_d_rvvm1_sleef(0)), vadd_vd_vd_vd_rvvm1_sleef(fr, vcast_vd_d_rvvm1_sleef(1.0)), fr); + x = vsel_vd_vo_vd_vd_rvvm1_sleef(veq_vo_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(0.49999999999999994449)), vcast_vd_d_rvvm1_sleef(0), x); + return vsel_vd_vo_vd_vd_rvvm1_sleef(rvv_dp_vor_vo_vo_vo(visinf_vo_vd_rvvm1_sleef(d), vge_vo_vd_vd_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(d), vcast_vd_d_rvvm1_sleef(INT64_C(1) << 52))), d, vcopysign_vd_vd_vd_rvvm1_sleef(vsub_vd_vd_vd_rvvm1_sleef(x, fr), d)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_rvvm1_sleef vrint2_vd_vd_rvvm1_sleef(vdouble_rvvm1_sleef d) { + + vdouble_rvvm1_sleef c = vmulsign_vd_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(INT64_C(1) << 52), d); + return vsel_vd_vo_vd_vd_rvvm1_sleef(vgt_vo_vd_vd_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(d), vcast_vd_d_rvvm1_sleef(INT64_C(1) << 52)), + d, vorsign_vd_vd_vd_rvvm1_sleef(vsub_vd_vd_vd_rvvm1_sleef(vadd_vd_vd_vd_rvvm1_sleef(d, c), c), d)); + +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST rvv_dp_vopmask_rvvm1_sleef visint_vo_vd_rvvm1_sleef(vdouble_rvvm1_sleef d) { + return veq_vo_vd_vd_rvvm1_sleef(vrint2_vd_vd_rvvm1_sleef(d), d); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST rvv_dp_vopmask_rvvm1_sleef visodd_vo_vd_rvvm1_sleef(vdouble_rvvm1_sleef d) { + vdouble_rvvm1_sleef x = vmul_vd_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(0.5)); + return vneq_vo_vd_vd_rvvm1_sleef(vrint2_vd_vd_rvvm1_sleef(x), x); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vint_rvvm1_sleef vilogbk_vi_vd_rvvm1_sleef(vdouble_rvvm1_sleef d) { + rvv_dp_vopmask_rvvm1_sleef o = vlt_vo_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(4.9090934652977266E-91)); + d = vsel_vd_vo_vd_vd_rvvm1_sleef(o, vmul_vd_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(2.037035976334486E90), d), d); + vint_rvvm1_sleef q = vcastu_vi_vm_rvvm1_sleef(vreinterpret_vm_vd_rvvm1_sleef(d)); + q = vand_vi_vi_vi_rvvm1_sleef(q, vcast_vi_i_rvvm1_sleef((int)(((1U << 12) - 1) << 20))); + q = vsrl_vi_vi_i_rvvm1_sleef(q, 20); + q = vsub_vi_vi_vi_rvvm1_sleef(q, vsel_vi_vo_vi_vi_rvvm1_sleef(vcast_vo32_vo64_rvvm1_sleef(o), vcast_vi_i_rvvm1_sleef(300 + 0x3ff), vcast_vi_i_rvvm1_sleef(0x3ff))); + return q; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vint_rvvm1_sleef vilogb2k_vi_vd_rvvm1_sleef(vdouble_rvvm1_sleef d) { + vint_rvvm1_sleef q = vcastu_vi_vm_rvvm1_sleef(vreinterpret_vm_vd_rvvm1_sleef(d)); + q = vsrl_vi_vi_i_rvvm1_sleef(q, 20); + q = vand_vi_vi_vi_rvvm1_sleef(q, vcast_vi_i_rvvm1_sleef(0x7ff)); + q = vsub_vi_vi_vi_rvvm1_sleef(q, vcast_vi_i_rvvm1_sleef(0x3ff)); + return q; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vmask_rvvm1_sleef vilogb2k_vm_vd_rvvm1_sleef(vdouble_rvvm1_sleef d) { + vmask_rvvm1_sleef m = vreinterpret_vm_vd_rvvm1_sleef(d); + m = vsrl64_vm_vm_i(m, 20 + 32); + m = vand_vm_vm_vm_rvvm1_sleef(m, vcast_vm_i64_rvvm1_sleef(0x7ff)); + m = vsub64_vm_vm_vm_rvvm1_sleef(m, vcast_vm_i64_rvvm1_sleef(0x3ff)); + return m; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vmask_rvvm1_sleef vilogb3k_vm_vd_rvvm1_sleef(vdouble_rvvm1_sleef d) { + vmask_rvvm1_sleef m = vreinterpret_vm_vd_rvvm1_sleef(d); + m = vsrl64_vm_vm_i(m, 20 + 32); + m = vand_vm_vm_vm_rvvm1_sleef(m, vcast_vm_i64_rvvm1_sleef(0x7ff)); + return m; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_rvvm1_sleef vpow2i_vd_vi_rvvm1_sleef(vint_rvvm1_sleef q) { + q = vadd_vi_vi_vi_rvvm1_sleef(vcast_vi_i_rvvm1_sleef(0x3ff), q); + vmask_rvvm1_sleef r = vcastu_vm_vi_rvvm1_sleef(vsll_vi_vi_i_rvvm1_sleef(q, 20)); + return vreinterpret_vd_vm_rvvm1_sleef(r); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_rvvm1_sleef vpow2i_vd_vm_rvvm1_sleef(vmask_rvvm1_sleef q) { + q = vadd64_vm_vm_vm_rvvm1_sleef(vcast_vm_i64_rvvm1_sleef(0x3ff), q); + return vreinterpret_vd_vm_rvvm1_sleef(vsll64_vm_vm_i(q, 52)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_rvvm1_sleef vldexp_vd_vd_vi_rvvm1_sleef(vdouble_rvvm1_sleef x, vint_rvvm1_sleef q) { + vint_rvvm1_sleef m = vsra_vi_vi_i_rvvm1_sleef(q, 31); + m = vsll_vi_vi_i_rvvm1_sleef(vsub_vi_vi_vi_rvvm1_sleef(vsra_vi_vi_i_rvvm1_sleef(vadd_vi_vi_vi_rvvm1_sleef(m, q), 9), m), 7); + q = vsub_vi_vi_vi_rvvm1_sleef(q, vsll_vi_vi_i_rvvm1_sleef(m, 2)); + m = vadd_vi_vi_vi_rvvm1_sleef(vcast_vi_i_rvvm1_sleef(0x3ff), m); + m = vandnot_vi_vo_vi_rvvm1_sleef(vgt_vo_vi_vi_rvvm1_sleef(vcast_vi_i_rvvm1_sleef(0), m), m); + m = vsel_vi_vo_vi_vi_rvvm1_sleef(vgt_vo_vi_vi_rvvm1_sleef(m, vcast_vi_i_rvvm1_sleef(0x7ff)), vcast_vi_i_rvvm1_sleef(0x7ff), m); + vmask_rvvm1_sleef r = vcastu_vm_vi_rvvm1_sleef(vsll_vi_vi_i_rvvm1_sleef(m, 20)); + vdouble_rvvm1_sleef y = vreinterpret_vd_vm_rvvm1_sleef(r); + return vmul_vd_vd_vd_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(x, y), y), y), y), vpow2i_vd_vi_rvvm1_sleef(q)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_rvvm1_sleef vldexp2_vd_vd_vi_rvvm1_sleef(vdouble_rvvm1_sleef d, vint_rvvm1_sleef e) { + return vmul_vd_vd_vd_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(d, vpow2i_vd_vi_rvvm1_sleef(vsra_vi_vi_i_rvvm1_sleef(e, 1))), vpow2i_vd_vi_rvvm1_sleef(vsub_vi_vi_vi_rvvm1_sleef(e, vsra_vi_vi_i_rvvm1_sleef(e, 1)))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_rvvm1_sleef vldexp3_vd_vd_vi_rvvm1_sleef(vdouble_rvvm1_sleef d, vint_rvvm1_sleef q) { + return vreinterpret_vd_vm_rvvm1_sleef(vadd64_vm_vm_vm_rvvm1_sleef(vreinterpret_vm_vd_rvvm1_sleef(d), vcastu_vm_vi_rvvm1_sleef(vsll_vi_vi_i_rvvm1_sleef(q, 20)))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_rvvm1_sleef vldexp1_vd_vd_vm_rvvm1_sleef(vdouble_rvvm1_sleef d, vmask_rvvm1_sleef e) { + vmask_rvvm1_sleef m = vsrl64_vm_vm_i(e, 2); + e = vsub64_vm_vm_vm_rvvm1_sleef(vsub64_vm_vm_vm_rvvm1_sleef(vsub64_vm_vm_vm_rvvm1_sleef(e, m), m), m); + d = vmul_vd_vd_vd_rvvm1_sleef(d, vpow2i_vd_vm_rvvm1_sleef(m)); + d = vmul_vd_vd_vd_rvvm1_sleef(d, vpow2i_vd_vm_rvvm1_sleef(m)); + d = vmul_vd_vd_vd_rvvm1_sleef(d, vpow2i_vd_vm_rvvm1_sleef(m)); + d = vmul_vd_vd_vd_rvvm1_sleef(d, vpow2i_vd_vm_rvvm1_sleef(e)); + return d; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_rvvm1_sleef vldexp2_vd_vd_vm_rvvm1_sleef(vdouble_rvvm1_sleef d, vmask_rvvm1_sleef e) { + return vmul_vd_vd_vd_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(d, vpow2i_vd_vm_rvvm1_sleef(vsrl64_vm_vm_i(e, 1))), vpow2i_vd_vm_rvvm1_sleef(vsub64_vm_vm_vm_rvvm1_sleef(e, vsrl64_vm_vm_i(e, 1)))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_rvvm1_sleef vldexp3_vd_vd_vm_rvvm1_sleef(vdouble_rvvm1_sleef d, vmask_rvvm1_sleef q) { + return vreinterpret_vd_vm_rvvm1_sleef(vadd64_vm_vm_vm_rvvm1_sleef(vreinterpret_vm_vd_rvvm1_sleef(d), vsll64_vm_vm_i(q, 52))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_rvvm1_sleef vcast_vd_vm_rvvm1_sleef(vmask_rvvm1_sleef m) { return vcast_vd_vi_rvvm1_sleef(vcast_vi_vm_rvvm1_sleef(m)); } +static SLEEF_ALWAYS_INLINE SLEEF_CONST vmask_rvvm1_sleef vtruncate_vm_vd_rvvm1_sleef(vdouble_rvvm1_sleef d) { return vcast_vm_vi_rvvm1_sleef(vtruncate_vi_vd_rvvm1_sleef(d)); } + +static SLEEF_ALWAYS_INLINE SLEEF_CONST rvv_dp_vopmask_rvvm1_sleef vlt64_vo_vm_vm_rvvm1_sleef(vmask_rvvm1_sleef x, vmask_rvvm1_sleef y) { return vgt64_vo_vm_vm_rvvm1_sleef(y, x); } + +static SLEEF_ALWAYS_INLINE SLEEF_CONST rvv_dp_vopmask_rvvm1_sleef vnot_vo64_vo64_rvvm1_sleef(rvv_dp_vopmask_rvvm1_sleef x) { + return rvv_dp_vxor_vo_vo_vo(x, veq64_vo_vm_vm_rvvm1_sleef(vcast_vm_i64_rvvm1_sleef(0), vcast_vm_i64_rvvm1_sleef(0))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST rvv_dp_vopmask_rvvm1_sleef vugt64_vo_vm_vm_rvvm1_sleef(vmask_rvvm1_sleef x, vmask_rvvm1_sleef y) { + x = vxor_vm_vm_vm_rvvm1_sleef(vcast_vm_u64_rvvm1_sleef(UINT64_C(0x8000000000000000)), x); + y = vxor_vm_vm_vm_rvvm1_sleef(vcast_vm_u64_rvvm1_sleef(UINT64_C(0x8000000000000000)), y); + return vgt64_vo_vm_vm_rvvm1_sleef(x, y); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vmask_rvvm1_sleef vilogbk_vm_vd_rvvm1_sleef(vdouble_rvvm1_sleef d) { + rvv_dp_vopmask_rvvm1_sleef o = vlt_vo_vd_vd_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(d), vcast_vd_d_rvvm1_sleef(4.9090934652977266E-91)); + d = vsel_vd_vo_vd_vd_rvvm1_sleef(o, vmul_vd_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(2.037035976334486E90), d), d); + vmask_rvvm1_sleef q = vreinterpret_vm_vd_rvvm1_sleef(d); + q = vsrl64_vm_vm_i(q, 20 + 32); + q = vand_vm_vm_vm_rvvm1_sleef(q, vcast_vm_i64_rvvm1_sleef(0x7ff)); + q = vsub64_vm_vm_vm_rvvm1_sleef(q, vsel_vm_vo64_vm_vm_rvvm1_sleef(o, vcast_vm_i64_rvvm1_sleef(300 + 0x3ff), vcast_vm_i64_rvvm1_sleef(0x3ff))); + return q; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vquad_rvvm1_sleef sel_vq_vo_vq_vq_rvvm1_sleef(rvv_dp_vopmask_rvvm1_sleef o, vquad_rvvm1_sleef x, vquad_rvvm1_sleef y) { + return vqsetxy_vq_vm_vm_rvvm1_sleef(vsel_vm_vo64_vm_vm_rvvm1_sleef(o, vqgetx_vm_vq_rvvm1_sleef(x), vqgetx_vm_vq_rvvm1_sleef(y)), vsel_vm_vo64_vm_vm_rvvm1_sleef(o, vqgety_vm_vq_rvvm1_sleef(x), vqgety_vm_vq_rvvm1_sleef(y))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vquad_rvvm1_sleef add128_vq_vq_vq_rvvm1_sleef(vquad_rvvm1_sleef x, vquad_rvvm1_sleef y) { + vquad_rvvm1_sleef r = vqsetxy_vq_vm_vm_rvvm1_sleef(vadd64_vm_vm_vm_rvvm1_sleef(vqgetx_vm_vq_rvvm1_sleef(x), vqgetx_vm_vq_rvvm1_sleef(y)), vadd64_vm_vm_vm_rvvm1_sleef(vqgety_vm_vq_rvvm1_sleef(x), vqgety_vm_vq_rvvm1_sleef(y))); + r = vqsety_vq_vq_vm_rvvm1_sleef(r, vadd64_vm_vm_vm_rvvm1_sleef(vqgety_vm_vq_rvvm1_sleef(r), vand_vm_vo64_vm_rvvm1_sleef(vugt64_vo_vm_vm_rvvm1_sleef(vqgetx_vm_vq_rvvm1_sleef(x), vqgetx_vm_vq_rvvm1_sleef(r)), vcast_vm_i64_rvvm1_sleef(1)))); + return r; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vquad_rvvm1_sleef imdvq_vq_vm_vm_rvvm1_sleef(vmask_rvvm1_sleef x, vmask_rvvm1_sleef y) { vquad_rvvm1_sleef r = vqsetxy_vq_vm_vm_rvvm1_sleef(x, y); return r; } + +static SLEEF_ALWAYS_INLINE SLEEF_CONST di_t_rvvm1_sleef rempisub_rvvm1_sleef(vdouble_rvvm1_sleef x) { + + vdouble_rvvm1_sleef c = vmulsign_vd_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(INT64_C(1) << 52), x); + vdouble_rvvm1_sleef rint4x = vsel_vd_vo_vd_vd_rvvm1_sleef(vgt_vo_vd_vd_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(4), x)), vcast_vd_d_rvvm1_sleef(INT64_C(1) << 52)), + vmul_vd_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(4), x), + vorsign_vd_vd_vd_rvvm1_sleef(vsub_vd_vd_vd_rvvm1_sleef(vmla_vd_vd_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(4), x, c), c), x)); + vdouble_rvvm1_sleef rintx = vsel_vd_vo_vd_vd_rvvm1_sleef(vgt_vo_vd_vd_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(x), vcast_vd_d_rvvm1_sleef(INT64_C(1) << 52)), + x, vorsign_vd_vd_vd_rvvm1_sleef(vsub_vd_vd_vd_rvvm1_sleef(vadd_vd_vd_vd_rvvm1_sleef(x, c), c), x)); + return disetdi_di_vd_vi_rvvm1_sleef(vmla_vd_vd_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(-0.25), rint4x, x), + vtruncate_vi_vd_rvvm1_sleef(vmla_vd_vd_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(-4), rintx, rint4x))); + +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vint_rvvm1_sleef vsel_vi_vd_vd_vi_vi_rvvm1_sleef(vdouble_rvvm1_sleef d0, vdouble_rvvm1_sleef d1, vint_rvvm1_sleef x, vint_rvvm1_sleef y) { return vsel_vi_vo_vi_vi_rvvm1_sleef(vcast_vo32_vo64_rvvm1_sleef(vlt_vo_vd_vd_rvvm1_sleef(d0, d1)), x, y); } + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vint_rvvm1_sleef vsel_vi_vd_vi_rvvm1_sleef(vdouble_rvvm1_sleef d, vint_rvvm1_sleef x) { return vand_vi_vo_vi_rvvm1_sleef(vcast_vo32_vo64_rvvm1_sleef(vsignbit_vo_vd_rvvm1_sleef(d)), x); } + +SLEEF_INLINE SLEEF_CONST vdouble_rvvm1_sleef Sleef_ldexpdx_rvvm1(vdouble_rvvm1_sleef x, vint_rvvm1_sleef q) { return vldexp_vd_vd_vi_rvvm1_sleef(x, q); } + +SLEEF_INLINE SLEEF_CONST vint_rvvm1_sleef Sleef_ilogbdx_rvvm1(vdouble_rvvm1_sleef d) { + vdouble_rvvm1_sleef e = vcast_vd_vi_rvvm1_sleef(vilogbk_vi_vd_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(d))); + e = vsel_vd_vo_vd_vd_rvvm1_sleef(veq_vo_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(0)), vcast_vd_d_rvvm1_sleef(SLEEF_FP_ILOGB0), e); + e = vsel_vd_vo_vd_vd_rvvm1_sleef(visnan_vo_vd_rvvm1_sleef(d), vcast_vd_d_rvvm1_sleef(SLEEF_FP_ILOGBNAN), e); + e = vsel_vd_vo_vd_vd_rvvm1_sleef(visinf_vo_vd_rvvm1_sleef(d), vcast_vd_d_rvvm1_sleef(2147483647), e); + return vrint_vi_vd_rvvm1_sleef(e); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST ddi_t_rvvm1_sleef rempi_rvvm1_sleef(vdouble_rvvm1_sleef a) { + vdouble2_rvvm1_sleef x, y; + vint_rvvm1_sleef ex = vilogb2k_vi_vd_rvvm1_sleef(a); + + ex = vsub_vi_vi_vi_rvvm1_sleef(ex, vcast_vi_i_rvvm1_sleef(55)); + vint_rvvm1_sleef q = vand_vi_vo_vi_rvvm1_sleef(vgt_vo_vi_vi_rvvm1_sleef(ex, vcast_vi_i_rvvm1_sleef(700-55)), vcast_vi_i_rvvm1_sleef(-64)); + a = vldexp3_vd_vd_vi_rvvm1_sleef(a, q); + ex = vandnot_vi_vi_vi_rvvm1_sleef(vsra_vi_vi_i_rvvm1_sleef(ex, 31), ex); + ex = vsll_vi_vi_i_rvvm1_sleef(ex, 2); + x = ddmul_vd2_vd_vd_rvvm1_sleef(a, vgather_vd_p_vi_rvvm1_sleef(Sleef_rempitabdp, ex)); + di_t_rvvm1_sleef di = rempisub_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(x)); + q = digeti_vi_di_rvvm1_sleef(di); + x = vd2setx_vd2_vd2_vd_rvvm1_sleef(x, digetd_vd_di_rvvm1_sleef(di)); + x = ddnormalize_vd2_vd2_rvvm1_sleef(x); + y = ddmul_vd2_vd_vd_rvvm1_sleef(a, vgather_vd_p_vi_rvvm1_sleef(Sleef_rempitabdp+1, ex)); + x = ddadd2_vd2_vd2_vd2_rvvm1_sleef(x, y); + di = rempisub_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(x)); + q = vadd_vi_vi_vi_rvvm1_sleef(q, digeti_vi_di_rvvm1_sleef(di)); + x = vd2setx_vd2_vd2_vd_rvvm1_sleef(x, digetd_vd_di_rvvm1_sleef(di)); + x = ddnormalize_vd2_vd2_rvvm1_sleef(x); + y = vcast_vd2_vd_vd_rvvm1_sleef(vgather_vd_p_vi_rvvm1_sleef(Sleef_rempitabdp+2, ex), vgather_vd_p_vi_rvvm1_sleef(Sleef_rempitabdp+3, ex)); + y = ddmul_vd2_vd2_vd_rvvm1_sleef(y, a); + x = ddadd2_vd2_vd2_vd2_rvvm1_sleef(x, y); + x = ddnormalize_vd2_vd2_rvvm1_sleef(x); + x = ddmul_vd2_vd2_vd2_rvvm1_sleef(x, vcast_vd2_d_d_rvvm1_sleef(3.141592653589793116*2, 1.2246467991473532072e-16*2)); + rvv_dp_vopmask_rvvm1_sleef o = vlt_vo_vd_vd_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(a), vcast_vd_d_rvvm1_sleef(0.7)); + x = vd2setx_vd2_vd2_vd_rvvm1_sleef(x, vsel_vd_vo_vd_vd_rvvm1_sleef(o, a, vd2getx_vd_vd2_rvvm1_sleef(x))); + x = vd2sety_vd2_vd2_vd_rvvm1_sleef(x, vreinterpret_vd_vm_rvvm1_sleef(vandnot_vm_vo64_vm_rvvm1_sleef(o, vreinterpret_vm_vd_rvvm1_sleef(vd2gety_vd_vd2_rvvm1_sleef(x))))); + return ddisetddi_ddi_vd2_vi_rvvm1_sleef(x, q); +} + +SLEEF_INLINE SLEEF_CONST vdouble_rvvm1_sleef Sleef_sindx_u35rvvm1(vdouble_rvvm1_sleef d) { + + vdouble_rvvm1_sleef u, s, r = d; + vint_rvvm1_sleef ql; + + if (__builtin_expect(!!(vtestallones_i_vo64_rvvm1_sleef(vlt_vo_vd_vd_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(d), vcast_vd_d_rvvm1_sleef(15)))), 1)) { + vdouble_rvvm1_sleef dql = vrint_vd_vd_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(0.318309886183790671537767526745028724))); + ql = vrint_vi_vd_rvvm1_sleef(dql); + d = vmla_vd_vd_vd_vd_rvvm1_sleef(dql, vcast_vd_d_rvvm1_sleef(-3.141592653589793116), d); + d = vmla_vd_vd_vd_vd_rvvm1_sleef(dql, vcast_vd_d_rvvm1_sleef(-1.2246467991473532072e-16), d); + } else if (__builtin_expect(!!(vtestallones_i_vo64_rvvm1_sleef(vlt_vo_vd_vd_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(d), vcast_vd_d_rvvm1_sleef(1e+14)))), 1)) { + vdouble_rvvm1_sleef dqh = vtruncate_vd_vd_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(0.318309886183790671537767526745028724 / (1 << 24)))); + dqh = vmul_vd_vd_vd_rvvm1_sleef(dqh, vcast_vd_d_rvvm1_sleef(1 << 24)); + vdouble_rvvm1_sleef dql = vrint_vd_vd_rvvm1_sleef(vmlapn_vd_vd_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(0.318309886183790671537767526745028724), dqh)); + ql = vrint_vi_vd_rvvm1_sleef(dql); + + d = vmla_vd_vd_vd_vd_rvvm1_sleef(dqh, vcast_vd_d_rvvm1_sleef(-3.1415926218032836914), d); + d = vmla_vd_vd_vd_vd_rvvm1_sleef(dql, vcast_vd_d_rvvm1_sleef(-3.1415926218032836914), d); + d = vmla_vd_vd_vd_vd_rvvm1_sleef(dqh, vcast_vd_d_rvvm1_sleef(-3.1786509424591713469e-08), d); + d = vmla_vd_vd_vd_vd_rvvm1_sleef(dql, vcast_vd_d_rvvm1_sleef(-3.1786509424591713469e-08), d); + d = vmla_vd_vd_vd_vd_rvvm1_sleef(dqh, vcast_vd_d_rvvm1_sleef(-1.2246467864107188502e-16), d); + d = vmla_vd_vd_vd_vd_rvvm1_sleef(dql, vcast_vd_d_rvvm1_sleef(-1.2246467864107188502e-16), d); + d = vmla_vd_vd_vd_vd_rvvm1_sleef(vadd_vd_vd_vd_rvvm1_sleef(dqh, dql), vcast_vd_d_rvvm1_sleef(-1.2736634327021899816e-24), d); + } else { + ddi_t_rvvm1_sleef ddi_rvvm1_sleef = rempi_rvvm1_sleef(d); + ql = vand_vi_vi_vi_rvvm1_sleef(ddigeti_vi_ddi_rvvm1_sleef(ddi_rvvm1_sleef), vcast_vi_i_rvvm1_sleef(3)); + ql = vadd_vi_vi_vi_rvvm1_sleef(vadd_vi_vi_vi_rvvm1_sleef(ql, ql), vsel_vi_vo_vi_vi_rvvm1_sleef(vcast_vo32_vo64_rvvm1_sleef(vgt_vo_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(ddigetdd_vd2_ddi_rvvm1_sleef(ddi_rvvm1_sleef)), vcast_vd_d_rvvm1_sleef(0))), vcast_vi_i_rvvm1_sleef(2), vcast_vi_i_rvvm1_sleef(1))); + ql = vsra_vi_vi_i_rvvm1_sleef(ql, 2); + rvv_dp_vopmask_rvvm1_sleef o = veq_vo_vi_vi_rvvm1_sleef(vand_vi_vi_vi_rvvm1_sleef(ddigeti_vi_ddi_rvvm1_sleef(ddi_rvvm1_sleef), vcast_vi_i_rvvm1_sleef(1)), vcast_vi_i_rvvm1_sleef(1)); + vdouble2_rvvm1_sleef x = vcast_vd2_vd_vd_rvvm1_sleef(vmulsign_vd_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(-3.141592653589793116 * 0.5), vd2getx_vd_vd2_rvvm1_sleef(ddigetdd_vd2_ddi_rvvm1_sleef(ddi_rvvm1_sleef))), + vmulsign_vd_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(-1.2246467991473532072e-16 * 0.5), vd2getx_vd_vd2_rvvm1_sleef(ddigetdd_vd2_ddi_rvvm1_sleef(ddi_rvvm1_sleef)))); + x = ddadd2_vd2_vd2_vd2_rvvm1_sleef(ddigetdd_vd2_ddi_rvvm1_sleef(ddi_rvvm1_sleef), x); + ddi_rvvm1_sleef = ddisetdd_ddi_ddi_vd2_rvvm1_sleef(ddi_rvvm1_sleef, vsel_vd2_vo_vd2_vd2_rvvm1_sleef(vcast_vo64_vo32_rvvm1_sleef(o), x, ddigetdd_vd2_ddi_rvvm1_sleef(ddi_rvvm1_sleef))); + d = vadd_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(ddigetdd_vd2_ddi_rvvm1_sleef(ddi_rvvm1_sleef)), vd2gety_vd_vd2_rvvm1_sleef(ddigetdd_vd2_ddi_rvvm1_sleef(ddi_rvvm1_sleef))); + d = vreinterpret_vd_vm_rvvm1_sleef(vor_vm_vo64_vm_rvvm1_sleef(rvv_dp_vor_vo_vo_vo(visinf_vo_vd_rvvm1_sleef(r), visnan_vo_vd_rvvm1_sleef(r)), vreinterpret_vm_vd_rvvm1_sleef(d))); + } + + s = vmul_vd_vd_vd_rvvm1_sleef(d, d); + + d = vreinterpret_vd_vm_rvvm1_sleef(vxor_vm_vm_vm_rvvm1_sleef(vand_vm_vo64_vm_rvvm1_sleef(vcast_vo64_vo32_rvvm1_sleef(veq_vo_vi_vi_rvvm1_sleef(vand_vi_vi_vi_rvvm1_sleef(ql, vcast_vi_i_rvvm1_sleef(1)), vcast_vi_i_rvvm1_sleef(1))), vreinterpret_vm_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(-0.0))), vreinterpret_vm_vd_rvvm1_sleef(d))); + + vdouble_rvvm1_sleef s2 = vmul_vd_vd_vd_rvvm1_sleef(s, s), s4 = vmul_vd_vd_vd_rvvm1_sleef(s2, s2); + u = vmla_vd_vd_vd_vd_rvvm1_sleef((s4), (vmla_vd_vd_vd_vd_rvvm1_sleef((s2), (vmla_vd_vd_vd_vd_rvvm1_sleef((s), (vcast_vd_d_rvvm1_sleef(-7.97255955009037868891952e-18)), (vcast_vd_d_rvvm1_sleef(2.81009972710863200091251e-15)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((s), (vcast_vd_d_rvvm1_sleef(-7.64712219118158833288484e-13)), (vcast_vd_d_rvvm1_sleef(1.60590430605664501629054e-10)))))), (vmla_vd_vd_vd_vd_rvvm1_sleef((s2), (vmla_vd_vd_vd_vd_rvvm1_sleef((s), (vcast_vd_d_rvvm1_sleef(-2.50521083763502045810755e-08)), (vcast_vd_d_rvvm1_sleef(2.75573192239198747630416e-06)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((s), (vcast_vd_d_rvvm1_sleef(-0.000198412698412696162806809)), (vcast_vd_d_rvvm1_sleef(0.00833333333333332974823815))))))) + + ; + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, s, vcast_vd_d_rvvm1_sleef(-0.166666666666666657414808)); + + u = vadd_vd_vd_vd_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(s, vmul_vd_vd_vd_rvvm1_sleef(u, d)), d); + + u = vsel_vd_vo_vd_vd_rvvm1_sleef(visnegzero_vo_vd_rvvm1_sleef(r), r, u); + + return u; + +} + +SLEEF_INLINE SLEEF_CONST vdouble_rvvm1_sleef Sleef_sindx_u10rvvm1(vdouble_rvvm1_sleef d) { + + vdouble_rvvm1_sleef u; + vdouble2_rvvm1_sleef s, t, x; + vint_rvvm1_sleef ql; + + if (__builtin_expect(!!(vtestallones_i_vo64_rvvm1_sleef(vlt_vo_vd_vd_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(d), vcast_vd_d_rvvm1_sleef(15)))), 1)) { + const vdouble_rvvm1_sleef dql = vrint_vd_vd_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(0.318309886183790671537767526745028724))); + ql = vrint_vi_vd_rvvm1_sleef(dql); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(dql, vcast_vd_d_rvvm1_sleef(-3.141592653589793116), d); + s = ddadd_vd2_vd_vd_rvvm1_sleef (u, vmul_vd_vd_vd_rvvm1_sleef(dql, vcast_vd_d_rvvm1_sleef(-1.2246467991473532072e-16))); + } else if (__builtin_expect(!!(vtestallones_i_vo64_rvvm1_sleef(vlt_vo_vd_vd_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(d), vcast_vd_d_rvvm1_sleef(1e+14)))), 1)) { + vdouble_rvvm1_sleef dqh = vtruncate_vd_vd_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(0.318309886183790671537767526745028724 / (1 << 24)))); + dqh = vmul_vd_vd_vd_rvvm1_sleef(dqh, vcast_vd_d_rvvm1_sleef(1 << 24)); + const vdouble_rvvm1_sleef dql = vrint_vd_vd_rvvm1_sleef(vmlapn_vd_vd_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(0.318309886183790671537767526745028724), dqh)); + ql = vrint_vi_vd_rvvm1_sleef(dql); + + u = vmla_vd_vd_vd_vd_rvvm1_sleef(dqh, vcast_vd_d_rvvm1_sleef(-3.1415926218032836914), d); + s = ddadd_vd2_vd_vd_rvvm1_sleef (u, vmul_vd_vd_vd_rvvm1_sleef(dql, vcast_vd_d_rvvm1_sleef(-3.1415926218032836914))); + s = ddadd2_vd2_vd2_vd_rvvm1_sleef(s, vmul_vd_vd_vd_rvvm1_sleef(dqh, vcast_vd_d_rvvm1_sleef(-3.1786509424591713469e-08))); + s = ddadd2_vd2_vd2_vd_rvvm1_sleef(s, vmul_vd_vd_vd_rvvm1_sleef(dql, vcast_vd_d_rvvm1_sleef(-3.1786509424591713469e-08))); + s = ddadd2_vd2_vd2_vd_rvvm1_sleef(s, vmul_vd_vd_vd_rvvm1_sleef(dqh, vcast_vd_d_rvvm1_sleef(-1.2246467864107188502e-16))); + s = ddadd2_vd2_vd2_vd_rvvm1_sleef(s, vmul_vd_vd_vd_rvvm1_sleef(dql, vcast_vd_d_rvvm1_sleef(-1.2246467864107188502e-16))); + s = ddadd_vd2_vd2_vd_rvvm1_sleef(s, vmul_vd_vd_vd_rvvm1_sleef(vadd_vd_vd_vd_rvvm1_sleef(dqh, dql), vcast_vd_d_rvvm1_sleef(-1.2736634327021899816e-24))); + } else { + ddi_t_rvvm1_sleef ddi_rvvm1_sleef = rempi_rvvm1_sleef(d); + ql = vand_vi_vi_vi_rvvm1_sleef(ddigeti_vi_ddi_rvvm1_sleef(ddi_rvvm1_sleef), vcast_vi_i_rvvm1_sleef(3)); + ql = vadd_vi_vi_vi_rvvm1_sleef(vadd_vi_vi_vi_rvvm1_sleef(ql, ql), vsel_vi_vo_vi_vi_rvvm1_sleef(vcast_vo32_vo64_rvvm1_sleef(vgt_vo_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(ddigetdd_vd2_ddi_rvvm1_sleef(ddi_rvvm1_sleef)), vcast_vd_d_rvvm1_sleef(0))), vcast_vi_i_rvvm1_sleef(2), vcast_vi_i_rvvm1_sleef(1))); + ql = vsra_vi_vi_i_rvvm1_sleef(ql, 2); + rvv_dp_vopmask_rvvm1_sleef o = veq_vo_vi_vi_rvvm1_sleef(vand_vi_vi_vi_rvvm1_sleef(ddigeti_vi_ddi_rvvm1_sleef(ddi_rvvm1_sleef), vcast_vi_i_rvvm1_sleef(1)), vcast_vi_i_rvvm1_sleef(1)); + vdouble2_rvvm1_sleef x = vcast_vd2_vd_vd_rvvm1_sleef(vmulsign_vd_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(-3.141592653589793116 * 0.5), vd2getx_vd_vd2_rvvm1_sleef(ddigetdd_vd2_ddi_rvvm1_sleef(ddi_rvvm1_sleef))), + vmulsign_vd_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(-1.2246467991473532072e-16 * 0.5), vd2getx_vd_vd2_rvvm1_sleef(ddigetdd_vd2_ddi_rvvm1_sleef(ddi_rvvm1_sleef)))); + x = ddadd2_vd2_vd2_vd2_rvvm1_sleef(ddigetdd_vd2_ddi_rvvm1_sleef(ddi_rvvm1_sleef), x); + ddi_rvvm1_sleef = ddisetdd_ddi_ddi_vd2_rvvm1_sleef(ddi_rvvm1_sleef, vsel_vd2_vo_vd2_vd2_rvvm1_sleef(vcast_vo64_vo32_rvvm1_sleef(o), x, ddigetdd_vd2_ddi_rvvm1_sleef(ddi_rvvm1_sleef))); + s = ddnormalize_vd2_vd2_rvvm1_sleef(ddigetdd_vd2_ddi_rvvm1_sleef(ddi_rvvm1_sleef)); + s = vd2setx_vd2_vd2_vd_rvvm1_sleef(s, vreinterpret_vd_vm_rvvm1_sleef(vor_vm_vo64_vm_rvvm1_sleef(rvv_dp_vor_vo_vo_vo(visinf_vo_vd_rvvm1_sleef(d), visnan_vo_vd_rvvm1_sleef(d)), vreinterpret_vm_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(s))))); + } + + t = s; + s = ddsqu_vd2_vd2_rvvm1_sleef(s); + + vdouble_rvvm1_sleef s2 = vmul_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(s), vd2getx_vd_vd2_rvvm1_sleef(s)), s4 = vmul_vd_vd_vd_rvvm1_sleef(s2, s2); + u = vmla_vd_vd_vd_vd_rvvm1_sleef((s4), (vmla_vd_vd_vd_vd_rvvm1_sleef((vd2getx_vd_vd2_rvvm1_sleef(s)), (vcast_vd_d_rvvm1_sleef(2.72052416138529567917983e-15)), (vcast_vd_d_rvvm1_sleef(-7.6429259411395447190023e-13)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((s2), (vmla_vd_vd_vd_vd_rvvm1_sleef((vd2getx_vd_vd2_rvvm1_sleef(s)), (vcast_vd_d_rvvm1_sleef(1.60589370117277896211623e-10)), (vcast_vd_d_rvvm1_sleef(-2.5052106814843123359368e-08)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((vd2getx_vd_vd2_rvvm1_sleef(s)), (vcast_vd_d_rvvm1_sleef(2.75573192104428224777379e-06)), (vcast_vd_d_rvvm1_sleef(-0.000198412698412046454654947))))))) + + ; + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, vd2getx_vd_vd2_rvvm1_sleef(s), vcast_vd_d_rvvm1_sleef(0.00833333333333318056201922)); + + x = ddadd_vd2_vd_vd2_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(1), ddmul_vd2_vd2_vd2_rvvm1_sleef(ddadd_vd2_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(-0.166666666666666657414808), vmul_vd_vd_vd_rvvm1_sleef(u, vd2getx_vd_vd2_rvvm1_sleef(s))), s)); + u = ddmul_vd_vd2_vd2_rvvm1_sleef(t, x); + + u = vreinterpret_vd_vm_rvvm1_sleef(vxor_vm_vm_vm_rvvm1_sleef(vand_vm_vo64_vm_rvvm1_sleef(vcast_vo64_vo32_rvvm1_sleef(veq_vo_vi_vi_rvvm1_sleef(vand_vi_vi_vi_rvvm1_sleef(ql, vcast_vi_i_rvvm1_sleef(1)), vcast_vi_i_rvvm1_sleef(1))), + vreinterpret_vm_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(-0.0))), vreinterpret_vm_vd_rvvm1_sleef(u))); + u = vsel_vd_vo_vd_vd_rvvm1_sleef(veq_vo_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(0)), d, u); + + return u; + +} + +SLEEF_INLINE SLEEF_CONST vdouble_rvvm1_sleef Sleef_cosdx_u35rvvm1(vdouble_rvvm1_sleef d) { + + vdouble_rvvm1_sleef u, s, r = d; + vint_rvvm1_sleef ql; + + if (__builtin_expect(!!(vtestallones_i_vo64_rvvm1_sleef(vlt_vo_vd_vd_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(d), vcast_vd_d_rvvm1_sleef(15)))), 1)) { + vdouble_rvvm1_sleef dql = vmla_vd_vd_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(2), + vrint_vd_vd_rvvm1_sleef(vmla_vd_vd_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(0.318309886183790671537767526745028724), vcast_vd_d_rvvm1_sleef(-0.5))), + vcast_vd_d_rvvm1_sleef(1)); + ql = vrint_vi_vd_rvvm1_sleef(dql); + d = vmla_vd_vd_vd_vd_rvvm1_sleef(dql, vcast_vd_d_rvvm1_sleef(-3.141592653589793116 * 0.5), d); + d = vmla_vd_vd_vd_vd_rvvm1_sleef(dql, vcast_vd_d_rvvm1_sleef(-1.2246467991473532072e-16 * 0.5), d); + } else if (__builtin_expect(!!(vtestallones_i_vo64_rvvm1_sleef(vlt_vo_vd_vd_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(d), vcast_vd_d_rvvm1_sleef(1e+14)))), 1)) { + vdouble_rvvm1_sleef dqh = vtruncate_vd_vd_rvvm1_sleef(vmla_vd_vd_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(0.318309886183790671537767526745028724 / (1 << 23)), vcast_vd_d_rvvm1_sleef(-0.318309886183790671537767526745028724 / (1 << 24)))); + ql = vrint_vi_vd_rvvm1_sleef(vadd_vd_vd_vd_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(0.318309886183790671537767526745028724)), + vmla_vd_vd_vd_vd_rvvm1_sleef(dqh, vcast_vd_d_rvvm1_sleef(-(1 << 23)), vcast_vd_d_rvvm1_sleef(-0.5)))); + dqh = vmul_vd_vd_vd_rvvm1_sleef(dqh, vcast_vd_d_rvvm1_sleef(1 << 24)); + ql = vadd_vi_vi_vi_rvvm1_sleef(vadd_vi_vi_vi_rvvm1_sleef(ql, ql), vcast_vi_i_rvvm1_sleef(1)); + vdouble_rvvm1_sleef dql = vcast_vd_vi_rvvm1_sleef(ql); + + d = vmla_vd_vd_vd_vd_rvvm1_sleef(dqh, vcast_vd_d_rvvm1_sleef(-3.1415926218032836914 * 0.5), d); + d = vmla_vd_vd_vd_vd_rvvm1_sleef(dql, vcast_vd_d_rvvm1_sleef(-3.1415926218032836914 * 0.5), d); + d = vmla_vd_vd_vd_vd_rvvm1_sleef(dqh, vcast_vd_d_rvvm1_sleef(-3.1786509424591713469e-08 * 0.5), d); + d = vmla_vd_vd_vd_vd_rvvm1_sleef(dql, vcast_vd_d_rvvm1_sleef(-3.1786509424591713469e-08 * 0.5), d); + d = vmla_vd_vd_vd_vd_rvvm1_sleef(dqh, vcast_vd_d_rvvm1_sleef(-1.2246467864107188502e-16 * 0.5), d); + d = vmla_vd_vd_vd_vd_rvvm1_sleef(dql, vcast_vd_d_rvvm1_sleef(-1.2246467864107188502e-16 * 0.5), d); + d = vmla_vd_vd_vd_vd_rvvm1_sleef(vadd_vd_vd_vd_rvvm1_sleef(dqh, dql), vcast_vd_d_rvvm1_sleef(-1.2736634327021899816e-24 * 0.5), d); + } else { + ddi_t_rvvm1_sleef ddi_rvvm1_sleef = rempi_rvvm1_sleef(d); + ql = vand_vi_vi_vi_rvvm1_sleef(ddigeti_vi_ddi_rvvm1_sleef(ddi_rvvm1_sleef), vcast_vi_i_rvvm1_sleef(3)); + ql = vadd_vi_vi_vi_rvvm1_sleef(vadd_vi_vi_vi_rvvm1_sleef(ql, ql), vsel_vi_vo_vi_vi_rvvm1_sleef(vcast_vo32_vo64_rvvm1_sleef(vgt_vo_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(ddigetdd_vd2_ddi_rvvm1_sleef(ddi_rvvm1_sleef)), vcast_vd_d_rvvm1_sleef(0))), vcast_vi_i_rvvm1_sleef(8), vcast_vi_i_rvvm1_sleef(7))); + ql = vsra_vi_vi_i_rvvm1_sleef(ql, 1); + rvv_dp_vopmask_rvvm1_sleef o = veq_vo_vi_vi_rvvm1_sleef(vand_vi_vi_vi_rvvm1_sleef(ddigeti_vi_ddi_rvvm1_sleef(ddi_rvvm1_sleef), vcast_vi_i_rvvm1_sleef(1)), vcast_vi_i_rvvm1_sleef(0)); + vdouble_rvvm1_sleef y = vsel_vd_vo_vd_vd_rvvm1_sleef(vgt_vo_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(ddigetdd_vd2_ddi_rvvm1_sleef(ddi_rvvm1_sleef)), vcast_vd_d_rvvm1_sleef(0)), vcast_vd_d_rvvm1_sleef(0), vcast_vd_d_rvvm1_sleef(-1)); + vdouble2_rvvm1_sleef x = vcast_vd2_vd_vd_rvvm1_sleef(vmulsign_vd_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(-3.141592653589793116 * 0.5), y), + vmulsign_vd_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(-1.2246467991473532072e-16 * 0.5), y)); + x = ddadd2_vd2_vd2_vd2_rvvm1_sleef(ddigetdd_vd2_ddi_rvvm1_sleef(ddi_rvvm1_sleef), x); + ddi_rvvm1_sleef = ddisetdd_ddi_ddi_vd2_rvvm1_sleef(ddi_rvvm1_sleef, vsel_vd2_vo_vd2_vd2_rvvm1_sleef(vcast_vo64_vo32_rvvm1_sleef(o), x, ddigetdd_vd2_ddi_rvvm1_sleef(ddi_rvvm1_sleef))); + d = vadd_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(ddigetdd_vd2_ddi_rvvm1_sleef(ddi_rvvm1_sleef)), vd2gety_vd_vd2_rvvm1_sleef(ddigetdd_vd2_ddi_rvvm1_sleef(ddi_rvvm1_sleef))); + d = vreinterpret_vd_vm_rvvm1_sleef(vor_vm_vo64_vm_rvvm1_sleef(rvv_dp_vor_vo_vo_vo(visinf_vo_vd_rvvm1_sleef(r), visnan_vo_vd_rvvm1_sleef(r)), vreinterpret_vm_vd_rvvm1_sleef(d))); + } + + s = vmul_vd_vd_vd_rvvm1_sleef(d, d); + + d = vreinterpret_vd_vm_rvvm1_sleef(vxor_vm_vm_vm_rvvm1_sleef(vand_vm_vo64_vm_rvvm1_sleef(vcast_vo64_vo32_rvvm1_sleef(veq_vo_vi_vi_rvvm1_sleef(vand_vi_vi_vi_rvvm1_sleef(ql, vcast_vi_i_rvvm1_sleef(2)), vcast_vi_i_rvvm1_sleef(0))), vreinterpret_vm_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(-0.0))), vreinterpret_vm_vd_rvvm1_sleef(d))); + + vdouble_rvvm1_sleef s2 = vmul_vd_vd_vd_rvvm1_sleef(s, s), s4 = vmul_vd_vd_vd_rvvm1_sleef(s2, s2); + u = vmla_vd_vd_vd_vd_rvvm1_sleef((s4), (vmla_vd_vd_vd_vd_rvvm1_sleef((s2), (vmla_vd_vd_vd_vd_rvvm1_sleef((s), (vcast_vd_d_rvvm1_sleef(-7.97255955009037868891952e-18)), (vcast_vd_d_rvvm1_sleef(2.81009972710863200091251e-15)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((s), (vcast_vd_d_rvvm1_sleef(-7.64712219118158833288484e-13)), (vcast_vd_d_rvvm1_sleef(1.60590430605664501629054e-10)))))), (vmla_vd_vd_vd_vd_rvvm1_sleef((s2), (vmla_vd_vd_vd_vd_rvvm1_sleef((s), (vcast_vd_d_rvvm1_sleef(-2.50521083763502045810755e-08)), (vcast_vd_d_rvvm1_sleef(2.75573192239198747630416e-06)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((s), (vcast_vd_d_rvvm1_sleef(-0.000198412698412696162806809)), (vcast_vd_d_rvvm1_sleef(0.00833333333333332974823815))))))) + + ; + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, s, vcast_vd_d_rvvm1_sleef(-0.166666666666666657414808)); + + u = vadd_vd_vd_vd_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(s, vmul_vd_vd_vd_rvvm1_sleef(u, d)), d); + + return u; + +} + +SLEEF_INLINE SLEEF_CONST vdouble_rvvm1_sleef Sleef_cosdx_u10rvvm1(vdouble_rvvm1_sleef d) { + + vdouble_rvvm1_sleef u; + vdouble2_rvvm1_sleef s, t, x; + vint_rvvm1_sleef ql; + + if (__builtin_expect(!!(vtestallones_i_vo64_rvvm1_sleef(vlt_vo_vd_vd_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(d), vcast_vd_d_rvvm1_sleef(15)))), 1)) { + vdouble_rvvm1_sleef dql = vrint_vd_vd_rvvm1_sleef(vmla_vd_vd_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(0.318309886183790671537767526745028724), vcast_vd_d_rvvm1_sleef(-0.5))); + dql = vmla_vd_vd_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(2), dql, vcast_vd_d_rvvm1_sleef(1)); + ql = vrint_vi_vd_rvvm1_sleef(dql); + s = ddadd2_vd2_vd_vd_rvvm1_sleef(d, vmul_vd_vd_vd_rvvm1_sleef(dql, vcast_vd_d_rvvm1_sleef(-3.141592653589793116*0.5))); + s = ddadd_vd2_vd2_vd_rvvm1_sleef(s, vmul_vd_vd_vd_rvvm1_sleef(dql, vcast_vd_d_rvvm1_sleef(-1.2246467991473532072e-16*0.5))); + } else if (__builtin_expect(!!(vtestallones_i_vo64_rvvm1_sleef(vlt_vo_vd_vd_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(d), vcast_vd_d_rvvm1_sleef(1e+14)))), 1)) { + vdouble_rvvm1_sleef dqh = vtruncate_vd_vd_rvvm1_sleef(vmla_vd_vd_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(0.318309886183790671537767526745028724 / (1 << 23)), vcast_vd_d_rvvm1_sleef(-0.318309886183790671537767526745028724 / (1 << 24)))); + ql = vrint_vi_vd_rvvm1_sleef(vadd_vd_vd_vd_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(0.318309886183790671537767526745028724)), + vmla_vd_vd_vd_vd_rvvm1_sleef(dqh, vcast_vd_d_rvvm1_sleef(-(1 << 23)), vcast_vd_d_rvvm1_sleef(-0.5)))); + dqh = vmul_vd_vd_vd_rvvm1_sleef(dqh, vcast_vd_d_rvvm1_sleef(1 << 24)); + ql = vadd_vi_vi_vi_rvvm1_sleef(vadd_vi_vi_vi_rvvm1_sleef(ql, ql), vcast_vi_i_rvvm1_sleef(1)); + const vdouble_rvvm1_sleef dql = vcast_vd_vi_rvvm1_sleef(ql); + + u = vmla_vd_vd_vd_vd_rvvm1_sleef(dqh, vcast_vd_d_rvvm1_sleef(-3.1415926218032836914 * 0.5), d); + s = ddadd2_vd2_vd_vd_rvvm1_sleef(u, vmul_vd_vd_vd_rvvm1_sleef(dql, vcast_vd_d_rvvm1_sleef(-3.1415926218032836914*0.5))); + s = ddadd2_vd2_vd2_vd_rvvm1_sleef(s, vmul_vd_vd_vd_rvvm1_sleef(dqh, vcast_vd_d_rvvm1_sleef(-3.1786509424591713469e-08*0.5))); + s = ddadd2_vd2_vd2_vd_rvvm1_sleef(s, vmul_vd_vd_vd_rvvm1_sleef(dql, vcast_vd_d_rvvm1_sleef(-3.1786509424591713469e-08*0.5))); + s = ddadd2_vd2_vd2_vd_rvvm1_sleef(s, vmul_vd_vd_vd_rvvm1_sleef(dqh, vcast_vd_d_rvvm1_sleef(-1.2246467864107188502e-16*0.5))); + s = ddadd2_vd2_vd2_vd_rvvm1_sleef(s, vmul_vd_vd_vd_rvvm1_sleef(dql, vcast_vd_d_rvvm1_sleef(-1.2246467864107188502e-16*0.5))); + s = ddadd_vd2_vd2_vd_rvvm1_sleef(s, vmul_vd_vd_vd_rvvm1_sleef(vadd_vd_vd_vd_rvvm1_sleef(dqh, dql), vcast_vd_d_rvvm1_sleef(-1.2736634327021899816e-24*0.5))); + } else { + ddi_t_rvvm1_sleef ddi_rvvm1_sleef = rempi_rvvm1_sleef(d); + ql = vand_vi_vi_vi_rvvm1_sleef(ddigeti_vi_ddi_rvvm1_sleef(ddi_rvvm1_sleef), vcast_vi_i_rvvm1_sleef(3)); + ql = vadd_vi_vi_vi_rvvm1_sleef(vadd_vi_vi_vi_rvvm1_sleef(ql, ql), vsel_vi_vo_vi_vi_rvvm1_sleef(vcast_vo32_vo64_rvvm1_sleef(vgt_vo_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(ddigetdd_vd2_ddi_rvvm1_sleef(ddi_rvvm1_sleef)), vcast_vd_d_rvvm1_sleef(0))), vcast_vi_i_rvvm1_sleef(8), vcast_vi_i_rvvm1_sleef(7))); + ql = vsra_vi_vi_i_rvvm1_sleef(ql, 1); + rvv_dp_vopmask_rvvm1_sleef o = veq_vo_vi_vi_rvvm1_sleef(vand_vi_vi_vi_rvvm1_sleef(ddigeti_vi_ddi_rvvm1_sleef(ddi_rvvm1_sleef), vcast_vi_i_rvvm1_sleef(1)), vcast_vi_i_rvvm1_sleef(0)); + vdouble_rvvm1_sleef y = vsel_vd_vo_vd_vd_rvvm1_sleef(vgt_vo_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(ddigetdd_vd2_ddi_rvvm1_sleef(ddi_rvvm1_sleef)), vcast_vd_d_rvvm1_sleef(0)), vcast_vd_d_rvvm1_sleef(0), vcast_vd_d_rvvm1_sleef(-1)); + vdouble2_rvvm1_sleef x = vcast_vd2_vd_vd_rvvm1_sleef(vmulsign_vd_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(-3.141592653589793116 * 0.5), y), + vmulsign_vd_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(-1.2246467991473532072e-16 * 0.5), y)); + x = ddadd2_vd2_vd2_vd2_rvvm1_sleef(ddigetdd_vd2_ddi_rvvm1_sleef(ddi_rvvm1_sleef), x); + ddi_rvvm1_sleef = ddisetdd_ddi_ddi_vd2_rvvm1_sleef(ddi_rvvm1_sleef, vsel_vd2_vo_vd2_vd2_rvvm1_sleef(vcast_vo64_vo32_rvvm1_sleef(o), x, ddigetdd_vd2_ddi_rvvm1_sleef(ddi_rvvm1_sleef))); + s = ddnormalize_vd2_vd2_rvvm1_sleef(ddigetdd_vd2_ddi_rvvm1_sleef(ddi_rvvm1_sleef)); + s = vd2setx_vd2_vd2_vd_rvvm1_sleef(s, vreinterpret_vd_vm_rvvm1_sleef(vor_vm_vo64_vm_rvvm1_sleef(rvv_dp_vor_vo_vo_vo(visinf_vo_vd_rvvm1_sleef(d), visnan_vo_vd_rvvm1_sleef(d)), vreinterpret_vm_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(s))))); + } + + t = s; + s = ddsqu_vd2_vd2_rvvm1_sleef(s); + + vdouble_rvvm1_sleef s2 = vmul_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(s), vd2getx_vd_vd2_rvvm1_sleef(s)), s4 = vmul_vd_vd_vd_rvvm1_sleef(s2, s2); + u = vmla_vd_vd_vd_vd_rvvm1_sleef((s4), (vmla_vd_vd_vd_vd_rvvm1_sleef((vd2getx_vd_vd2_rvvm1_sleef(s)), (vcast_vd_d_rvvm1_sleef(2.72052416138529567917983e-15)), (vcast_vd_d_rvvm1_sleef(-7.6429259411395447190023e-13)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((s2), (vmla_vd_vd_vd_vd_rvvm1_sleef((vd2getx_vd_vd2_rvvm1_sleef(s)), (vcast_vd_d_rvvm1_sleef(1.60589370117277896211623e-10)), (vcast_vd_d_rvvm1_sleef(-2.5052106814843123359368e-08)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((vd2getx_vd_vd2_rvvm1_sleef(s)), (vcast_vd_d_rvvm1_sleef(2.75573192104428224777379e-06)), (vcast_vd_d_rvvm1_sleef(-0.000198412698412046454654947))))))) + + ; + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, vd2getx_vd_vd2_rvvm1_sleef(s), vcast_vd_d_rvvm1_sleef(0.00833333333333318056201922)); + + x = ddadd_vd2_vd_vd2_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(1), ddmul_vd2_vd2_vd2_rvvm1_sleef(ddadd_vd2_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(-0.166666666666666657414808), vmul_vd_vd_vd_rvvm1_sleef(u, vd2getx_vd_vd2_rvvm1_sleef(s))), s)); + u = ddmul_vd_vd2_vd2_rvvm1_sleef(t, x); + + u = vreinterpret_vd_vm_rvvm1_sleef(vxor_vm_vm_vm_rvvm1_sleef(vand_vm_vo64_vm_rvvm1_sleef(vcast_vo64_vo32_rvvm1_sleef(veq_vo_vi_vi_rvvm1_sleef(vand_vi_vi_vi_rvvm1_sleef(ql, vcast_vi_i_rvvm1_sleef(2)), vcast_vi_i_rvvm1_sleef(0))), vreinterpret_vm_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(-0.0))), vreinterpret_vm_vd_rvvm1_sleef(u))); + + return u; + +} + +SLEEF_INLINE vdouble2_rvvm1_sleef Sleef_sincosdx_u35rvvm1(vdouble_rvvm1_sleef d) { + + rvv_dp_vopmask_rvvm1_sleef o; + vdouble_rvvm1_sleef u, t, rx, ry, s; + vdouble2_rvvm1_sleef r; + vint_rvvm1_sleef ql; + + if (__builtin_expect(!!(vtestallones_i_vo64_rvvm1_sleef(vlt_vo_vd_vd_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(d), vcast_vd_d_rvvm1_sleef(15)))), 1)) { + vdouble_rvvm1_sleef dql = vrint_vd_vd_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(2 * 0.318309886183790671537767526745028724))); + ql = vrint_vi_vd_rvvm1_sleef(dql); + s = vmla_vd_vd_vd_vd_rvvm1_sleef(dql, vcast_vd_d_rvvm1_sleef(-3.141592653589793116 * 0.5), d); + s = vmla_vd_vd_vd_vd_rvvm1_sleef(dql, vcast_vd_d_rvvm1_sleef(-1.2246467991473532072e-16 * 0.5), s); + } else if (__builtin_expect(!!(vtestallones_i_vo64_rvvm1_sleef(vlt_vo_vd_vd_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(d), vcast_vd_d_rvvm1_sleef(1e+14)))), 1)) { + vdouble_rvvm1_sleef dqh = vtruncate_vd_vd_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(2*0.318309886183790671537767526745028724 / (1 << 24)))); + dqh = vmul_vd_vd_vd_rvvm1_sleef(dqh, vcast_vd_d_rvvm1_sleef(1 << 24)); + vdouble_rvvm1_sleef dql = vrint_vd_vd_rvvm1_sleef(vsub_vd_vd_vd_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(2*0.318309886183790671537767526745028724)), dqh)); + ql = vrint_vi_vd_rvvm1_sleef(dql); + + s = vmla_vd_vd_vd_vd_rvvm1_sleef(dqh, vcast_vd_d_rvvm1_sleef(-3.1415926218032836914 * 0.5), d); + s = vmla_vd_vd_vd_vd_rvvm1_sleef(dql, vcast_vd_d_rvvm1_sleef(-3.1415926218032836914 * 0.5), s); + s = vmla_vd_vd_vd_vd_rvvm1_sleef(dqh, vcast_vd_d_rvvm1_sleef(-3.1786509424591713469e-08 * 0.5), s); + s = vmla_vd_vd_vd_vd_rvvm1_sleef(dql, vcast_vd_d_rvvm1_sleef(-3.1786509424591713469e-08 * 0.5), s); + s = vmla_vd_vd_vd_vd_rvvm1_sleef(dqh, vcast_vd_d_rvvm1_sleef(-1.2246467864107188502e-16 * 0.5), s); + s = vmla_vd_vd_vd_vd_rvvm1_sleef(dql, vcast_vd_d_rvvm1_sleef(-1.2246467864107188502e-16 * 0.5), s); + s = vmla_vd_vd_vd_vd_rvvm1_sleef(vadd_vd_vd_vd_rvvm1_sleef(dqh, dql), vcast_vd_d_rvvm1_sleef(-1.2736634327021899816e-24 * 0.5), s); + } else { + ddi_t_rvvm1_sleef ddi_rvvm1_sleef = rempi_rvvm1_sleef(d); + ql = ddigeti_vi_ddi_rvvm1_sleef(ddi_rvvm1_sleef); + s = vadd_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(ddigetdd_vd2_ddi_rvvm1_sleef(ddi_rvvm1_sleef)), vd2gety_vd_vd2_rvvm1_sleef(ddigetdd_vd2_ddi_rvvm1_sleef(ddi_rvvm1_sleef))); + s = vreinterpret_vd_vm_rvvm1_sleef(vor_vm_vo64_vm_rvvm1_sleef(rvv_dp_vor_vo_vo_vo(visinf_vo_vd_rvvm1_sleef(d), visnan_vo_vd_rvvm1_sleef(d)), vreinterpret_vm_vd_rvvm1_sleef(s))); + } + + t = s; + + s = vmul_vd_vd_vd_rvvm1_sleef(s, s); + + u = vcast_vd_d_rvvm1_sleef(1.58938307283228937328511e-10); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, s, vcast_vd_d_rvvm1_sleef(-2.50506943502539773349318e-08)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, s, vcast_vd_d_rvvm1_sleef(2.75573131776846360512547e-06)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, s, vcast_vd_d_rvvm1_sleef(-0.000198412698278911770864914)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, s, vcast_vd_d_rvvm1_sleef(0.0083333333333191845961746)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, s, vcast_vd_d_rvvm1_sleef(-0.166666666666666130709393)); + + rx = vmla_vd_vd_vd_vd_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(u, s), t, t); + rx = vsel_vd_vo_vd_vd_rvvm1_sleef(visnegzero_vo_vd_rvvm1_sleef(d), vcast_vd_d_rvvm1_sleef(-0.0), rx); + + u = vcast_vd_d_rvvm1_sleef(-1.13615350239097429531523e-11); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, s, vcast_vd_d_rvvm1_sleef(2.08757471207040055479366e-09)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, s, vcast_vd_d_rvvm1_sleef(-2.75573144028847567498567e-07)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, s, vcast_vd_d_rvvm1_sleef(2.48015872890001867311915e-05)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, s, vcast_vd_d_rvvm1_sleef(-0.00138888888888714019282329)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, s, vcast_vd_d_rvvm1_sleef(0.0416666666666665519592062)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, s, vcast_vd_d_rvvm1_sleef(-0.5)); + + ry = vmla_vd_vd_vd_vd_rvvm1_sleef(s, u, vcast_vd_d_rvvm1_sleef(1)); + + o = vcast_vo64_vo32_rvvm1_sleef(veq_vo_vi_vi_rvvm1_sleef(vand_vi_vi_vi_rvvm1_sleef(ql, vcast_vi_i_rvvm1_sleef(1)), vcast_vi_i_rvvm1_sleef(0))); + r = vd2setxy_vd2_vd_vd_rvvm1_sleef(vsel_vd_vo_vd_vd_rvvm1_sleef(o, rx, ry), vsel_vd_vo_vd_vd_rvvm1_sleef(o, ry, rx)); + + o = vcast_vo64_vo32_rvvm1_sleef(veq_vo_vi_vi_rvvm1_sleef(vand_vi_vi_vi_rvvm1_sleef(ql, vcast_vi_i_rvvm1_sleef(2)), vcast_vi_i_rvvm1_sleef(2))); + r = vd2setx_vd2_vd2_vd_rvvm1_sleef(r, vreinterpret_vd_vm_rvvm1_sleef(vxor_vm_vm_vm_rvvm1_sleef(vand_vm_vo64_vm_rvvm1_sleef(o, vreinterpret_vm_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(-0.0))), vreinterpret_vm_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(r))))); + + o = vcast_vo64_vo32_rvvm1_sleef(veq_vo_vi_vi_rvvm1_sleef(vand_vi_vi_vi_rvvm1_sleef(vadd_vi_vi_vi_rvvm1_sleef(ql, vcast_vi_i_rvvm1_sleef(1)), vcast_vi_i_rvvm1_sleef(2)), vcast_vi_i_rvvm1_sleef(2))); + r = vd2sety_vd2_vd2_vd_rvvm1_sleef(r, vreinterpret_vd_vm_rvvm1_sleef(vxor_vm_vm_vm_rvvm1_sleef(vand_vm_vo64_vm_rvvm1_sleef(o, vreinterpret_vm_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(-0.0))), vreinterpret_vm_vd_rvvm1_sleef(vd2gety_vd_vd2_rvvm1_sleef(r))))); + + return r; + +} + +SLEEF_INLINE vdouble2_rvvm1_sleef Sleef_sincosdx_u10rvvm1(vdouble_rvvm1_sleef d) { + + rvv_dp_vopmask_rvvm1_sleef o; + vdouble_rvvm1_sleef u, rx, ry; + vdouble2_rvvm1_sleef r, s, t, x; + vint_rvvm1_sleef ql; + + if (__builtin_expect(!!(vtestallones_i_vo64_rvvm1_sleef(vlt_vo_vd_vd_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(d), vcast_vd_d_rvvm1_sleef(15)))), 1)) { + const vdouble_rvvm1_sleef dql = vrint_vd_vd_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(2 * 0.318309886183790671537767526745028724))); + ql = vrint_vi_vd_rvvm1_sleef(dql); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(dql, vcast_vd_d_rvvm1_sleef(-3.141592653589793116*0.5), d); + s = ddadd_vd2_vd_vd_rvvm1_sleef (u, vmul_vd_vd_vd_rvvm1_sleef(dql, vcast_vd_d_rvvm1_sleef(-1.2246467991473532072e-16*0.5))); + } else if (__builtin_expect(!!(vtestallones_i_vo64_rvvm1_sleef(vlt_vo_vd_vd_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(d), vcast_vd_d_rvvm1_sleef(1e+14)))), 1)) { + vdouble_rvvm1_sleef dqh = vtruncate_vd_vd_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(2*0.318309886183790671537767526745028724 / (1 << 24)))); + dqh = vmul_vd_vd_vd_rvvm1_sleef(dqh, vcast_vd_d_rvvm1_sleef(1 << 24)); + const vdouble_rvvm1_sleef dql = vrint_vd_vd_rvvm1_sleef(vsub_vd_vd_vd_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(2*0.318309886183790671537767526745028724)), dqh)); + ql = vrint_vi_vd_rvvm1_sleef(dql); + + u = vmla_vd_vd_vd_vd_rvvm1_sleef(dqh, vcast_vd_d_rvvm1_sleef(-3.1415926218032836914 * 0.5), d); + s = ddadd_vd2_vd_vd_rvvm1_sleef(u, vmul_vd_vd_vd_rvvm1_sleef(dql, vcast_vd_d_rvvm1_sleef(-3.1415926218032836914*0.5))); + s = ddadd2_vd2_vd2_vd_rvvm1_sleef(s, vmul_vd_vd_vd_rvvm1_sleef(dqh, vcast_vd_d_rvvm1_sleef(-3.1786509424591713469e-08*0.5))); + s = ddadd2_vd2_vd2_vd_rvvm1_sleef(s, vmul_vd_vd_vd_rvvm1_sleef(dql, vcast_vd_d_rvvm1_sleef(-3.1786509424591713469e-08*0.5))); + s = ddadd2_vd2_vd2_vd_rvvm1_sleef(s, vmul_vd_vd_vd_rvvm1_sleef(dqh, vcast_vd_d_rvvm1_sleef(-1.2246467864107188502e-16*0.5))); + s = ddadd2_vd2_vd2_vd_rvvm1_sleef(s, vmul_vd_vd_vd_rvvm1_sleef(dql, vcast_vd_d_rvvm1_sleef(-1.2246467864107188502e-16*0.5))); + s = ddadd_vd2_vd2_vd_rvvm1_sleef(s, vmul_vd_vd_vd_rvvm1_sleef(vadd_vd_vd_vd_rvvm1_sleef(dqh, dql), vcast_vd_d_rvvm1_sleef(-1.2736634327021899816e-24*0.5))); + } else { + ddi_t_rvvm1_sleef ddi_rvvm1_sleef = rempi_rvvm1_sleef(d); + ql = ddigeti_vi_ddi_rvvm1_sleef(ddi_rvvm1_sleef); + s = ddigetdd_vd2_ddi_rvvm1_sleef(ddi_rvvm1_sleef); + o = rvv_dp_vor_vo_vo_vo(visinf_vo_vd_rvvm1_sleef(d), visnan_vo_vd_rvvm1_sleef(d)); + s = vd2setxy_vd2_vd_vd_rvvm1_sleef(vreinterpret_vd_vm_rvvm1_sleef(vor_vm_vo64_vm_rvvm1_sleef(o, vreinterpret_vm_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(s)))), + vreinterpret_vd_vm_rvvm1_sleef(vor_vm_vo64_vm_rvvm1_sleef(o, vreinterpret_vm_vd_rvvm1_sleef(vd2gety_vd_vd2_rvvm1_sleef(s))))); + } + + t = s; + + s = vd2setx_vd2_vd2_vd_rvvm1_sleef(s, ddsqu_vd_vd2_rvvm1_sleef(s)); + + u = vcast_vd_d_rvvm1_sleef(1.58938307283228937328511e-10); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, vd2getx_vd_vd2_rvvm1_sleef(s), vcast_vd_d_rvvm1_sleef(-2.50506943502539773349318e-08)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, vd2getx_vd_vd2_rvvm1_sleef(s), vcast_vd_d_rvvm1_sleef(2.75573131776846360512547e-06)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, vd2getx_vd_vd2_rvvm1_sleef(s), vcast_vd_d_rvvm1_sleef(-0.000198412698278911770864914)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, vd2getx_vd_vd2_rvvm1_sleef(s), vcast_vd_d_rvvm1_sleef(0.0083333333333191845961746)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, vd2getx_vd_vd2_rvvm1_sleef(s), vcast_vd_d_rvvm1_sleef(-0.166666666666666130709393)); + + u = vmul_vd_vd_vd_rvvm1_sleef(u, vmul_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(s), vd2getx_vd_vd2_rvvm1_sleef(t))); + + x = ddadd_vd2_vd2_vd_rvvm1_sleef(t, u); + rx = vadd_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(x), vd2gety_vd_vd2_rvvm1_sleef(x)); + + rx = vsel_vd_vo_vd_vd_rvvm1_sleef(visnegzero_vo_vd_rvvm1_sleef(d), vcast_vd_d_rvvm1_sleef(-0.0), rx); + + u = vcast_vd_d_rvvm1_sleef(-1.13615350239097429531523e-11); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, vd2getx_vd_vd2_rvvm1_sleef(s), vcast_vd_d_rvvm1_sleef(2.08757471207040055479366e-09)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, vd2getx_vd_vd2_rvvm1_sleef(s), vcast_vd_d_rvvm1_sleef(-2.75573144028847567498567e-07)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, vd2getx_vd_vd2_rvvm1_sleef(s), vcast_vd_d_rvvm1_sleef(2.48015872890001867311915e-05)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, vd2getx_vd_vd2_rvvm1_sleef(s), vcast_vd_d_rvvm1_sleef(-0.00138888888888714019282329)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, vd2getx_vd_vd2_rvvm1_sleef(s), vcast_vd_d_rvvm1_sleef(0.0416666666666665519592062)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, vd2getx_vd_vd2_rvvm1_sleef(s), vcast_vd_d_rvvm1_sleef(-0.5)); + + x = ddadd_vd2_vd_vd2_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(1), ddmul_vd2_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(s), u)); + ry = vadd_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(x), vd2gety_vd_vd2_rvvm1_sleef(x)); + + o = vcast_vo64_vo32_rvvm1_sleef(veq_vo_vi_vi_rvvm1_sleef(vand_vi_vi_vi_rvvm1_sleef(ql, vcast_vi_i_rvvm1_sleef(1)), vcast_vi_i_rvvm1_sleef(0))); + r = vd2setxy_vd2_vd_vd_rvvm1_sleef(vsel_vd_vo_vd_vd_rvvm1_sleef(o, rx, ry), vsel_vd_vo_vd_vd_rvvm1_sleef(o, ry, rx)); + + o = vcast_vo64_vo32_rvvm1_sleef(veq_vo_vi_vi_rvvm1_sleef(vand_vi_vi_vi_rvvm1_sleef(ql, vcast_vi_i_rvvm1_sleef(2)), vcast_vi_i_rvvm1_sleef(2))); + r = vd2setx_vd2_vd2_vd_rvvm1_sleef(r, vreinterpret_vd_vm_rvvm1_sleef(vxor_vm_vm_vm_rvvm1_sleef(vand_vm_vo64_vm_rvvm1_sleef(o, vreinterpret_vm_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(-0.0))), vreinterpret_vm_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(r))))); + + o = vcast_vo64_vo32_rvvm1_sleef(veq_vo_vi_vi_rvvm1_sleef(vand_vi_vi_vi_rvvm1_sleef(vadd_vi_vi_vi_rvvm1_sleef(ql, vcast_vi_i_rvvm1_sleef(1)), vcast_vi_i_rvvm1_sleef(2)), vcast_vi_i_rvvm1_sleef(2))); + r = vd2sety_vd2_vd2_vd_rvvm1_sleef(r, vreinterpret_vd_vm_rvvm1_sleef(vxor_vm_vm_vm_rvvm1_sleef(vand_vm_vo64_vm_rvvm1_sleef(o, vreinterpret_vm_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(-0.0))), vreinterpret_vm_vd_rvvm1_sleef(vd2gety_vd_vd2_rvvm1_sleef(r))))); + + return r; + +} + +SLEEF_INLINE vdouble2_rvvm1_sleef Sleef_sincospidx_u05rvvm1(vdouble_rvvm1_sleef d) { + rvv_dp_vopmask_rvvm1_sleef o; + vdouble_rvvm1_sleef u, s, t, rx, ry; + vdouble2_rvvm1_sleef r, x, s2; + + u = vmul_vd_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(4.0)); + vint_rvvm1_sleef q = vtruncate_vi_vd_rvvm1_sleef(u); + q = vand_vi_vi_vi_rvvm1_sleef(vadd_vi_vi_vi_rvvm1_sleef(q, vxor_vi_vi_vi_rvvm1_sleef(vsrl_vi_vi_i_rvvm1_sleef(q, 31), vcast_vi_i_rvvm1_sleef(1))), vcast_vi_i_rvvm1_sleef(~1)); + s = vsub_vd_vd_vd_rvvm1_sleef(u, vcast_vd_vi_rvvm1_sleef(q)); + + t = s; + s = vmul_vd_vd_vd_rvvm1_sleef(s, s); + s2 = ddmul_vd2_vd_vd_rvvm1_sleef(t, t); + + u = vcast_vd_d_rvvm1_sleef(-2.02461120785182399295868e-14); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, s, vcast_vd_d_rvvm1_sleef(6.94821830580179461327784e-12)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, s, vcast_vd_d_rvvm1_sleef(-1.75724749952853179952664e-09)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, s, vcast_vd_d_rvvm1_sleef(3.13361688966868392878422e-07)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, s, vcast_vd_d_rvvm1_sleef(-3.6576204182161551920361e-05)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, s, vcast_vd_d_rvvm1_sleef(0.00249039457019271850274356)); + x = ddadd2_vd2_vd_vd2_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(u, s), vcast_vd2_d_d_rvvm1_sleef(-0.0807455121882807852484731, 3.61852475067037104849987e-18)); + x = ddadd2_vd2_vd2_vd2_rvvm1_sleef(ddmul_vd2_vd2_vd2_rvvm1_sleef(s2, x), vcast_vd2_d_d_rvvm1_sleef(0.785398163397448278999491, 3.06287113727155002607105e-17)); + + x = ddmul_vd2_vd2_vd_rvvm1_sleef(x, t); + rx = vadd_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(x), vd2gety_vd_vd2_rvvm1_sleef(x)); + + rx = vsel_vd_vo_vd_vd_rvvm1_sleef(visnegzero_vo_vd_rvvm1_sleef(d), vcast_vd_d_rvvm1_sleef(-0.0), rx); + + u = vcast_vd_d_rvvm1_sleef(9.94480387626843774090208e-16); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, s, vcast_vd_d_rvvm1_sleef(-3.89796226062932799164047e-13)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, s, vcast_vd_d_rvvm1_sleef(1.15011582539996035266901e-10)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, s, vcast_vd_d_rvvm1_sleef(-2.4611369501044697495359e-08)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, s, vcast_vd_d_rvvm1_sleef(3.59086044859052754005062e-06)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, s, vcast_vd_d_rvvm1_sleef(-0.000325991886927389905997954)); + x = ddadd2_vd2_vd_vd2_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(u, s), vcast_vd2_d_d_rvvm1_sleef(0.0158543442438155018914259, -1.04693272280631521908845e-18)); + x = ddadd2_vd2_vd2_vd2_rvvm1_sleef(ddmul_vd2_vd2_vd2_rvvm1_sleef(s2, x), vcast_vd2_d_d_rvvm1_sleef(-0.308425137534042437259529, -1.95698492133633550338345e-17)); + + x = ddadd2_vd2_vd2_vd_rvvm1_sleef(ddmul_vd2_vd2_vd2_rvvm1_sleef(x, s2), vcast_vd_d_rvvm1_sleef(1)); + ry = vadd_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(x), vd2gety_vd_vd2_rvvm1_sleef(x)); + + o = vcast_vo64_vo32_rvvm1_sleef(veq_vo_vi_vi_rvvm1_sleef(vand_vi_vi_vi_rvvm1_sleef(q, vcast_vi_i_rvvm1_sleef(2)), vcast_vi_i_rvvm1_sleef(0))); + r = vd2setxy_vd2_vd_vd_rvvm1_sleef(vsel_vd_vo_vd_vd_rvvm1_sleef(o, rx, ry), vsel_vd_vo_vd_vd_rvvm1_sleef(o, ry, rx)); + + o = vcast_vo64_vo32_rvvm1_sleef(veq_vo_vi_vi_rvvm1_sleef(vand_vi_vi_vi_rvvm1_sleef(q, vcast_vi_i_rvvm1_sleef(4)), vcast_vi_i_rvvm1_sleef(4))); + r = vd2setx_vd2_vd2_vd_rvvm1_sleef(r, vreinterpret_vd_vm_rvvm1_sleef(vxor_vm_vm_vm_rvvm1_sleef(vand_vm_vo64_vm_rvvm1_sleef(o, vreinterpret_vm_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(-0.0))), vreinterpret_vm_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(r))))); + + o = vcast_vo64_vo32_rvvm1_sleef(veq_vo_vi_vi_rvvm1_sleef(vand_vi_vi_vi_rvvm1_sleef(vadd_vi_vi_vi_rvvm1_sleef(q, vcast_vi_i_rvvm1_sleef(2)), vcast_vi_i_rvvm1_sleef(4)), vcast_vi_i_rvvm1_sleef(4))); + r = vd2sety_vd2_vd2_vd_rvvm1_sleef(r, vreinterpret_vd_vm_rvvm1_sleef(vxor_vm_vm_vm_rvvm1_sleef(vand_vm_vo64_vm_rvvm1_sleef(o, vreinterpret_vm_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(-0.0))), vreinterpret_vm_vd_rvvm1_sleef(vd2gety_vd_vd2_rvvm1_sleef(r))))); + + o = vgt_vo_vd_vd_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(d), vcast_vd_d_rvvm1_sleef(1e+9/4)); + r = vd2setx_vd2_vd2_vd_rvvm1_sleef(r, vreinterpret_vd_vm_rvvm1_sleef(vandnot_vm_vo64_vm_rvvm1_sleef(o, vreinterpret_vm_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(r))))); + r = vd2sety_vd2_vd2_vd_rvvm1_sleef(r, vsel_vd_vo_vd_vd_rvvm1_sleef(o, vcast_vd_d_rvvm1_sleef(1), vd2gety_vd_vd2_rvvm1_sleef(r))); + + o = visinf_vo_vd_rvvm1_sleef(d); + r = vd2setx_vd2_vd2_vd_rvvm1_sleef(r, vreinterpret_vd_vm_rvvm1_sleef(vor_vm_vo64_vm_rvvm1_sleef(o, vreinterpret_vm_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(r))))); + r = vd2sety_vd2_vd2_vd_rvvm1_sleef(r, vreinterpret_vd_vm_rvvm1_sleef(vor_vm_vo64_vm_rvvm1_sleef(o, vreinterpret_vm_vd_rvvm1_sleef(vd2gety_vd_vd2_rvvm1_sleef(r))))); + + return r; +} + +SLEEF_INLINE vdouble2_rvvm1_sleef Sleef_sincospidx_u35rvvm1(vdouble_rvvm1_sleef d) { + rvv_dp_vopmask_rvvm1_sleef o; + vdouble_rvvm1_sleef u, s, t, rx, ry; + vdouble2_rvvm1_sleef r; + + u = vmul_vd_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(4.0)); + vint_rvvm1_sleef q = vtruncate_vi_vd_rvvm1_sleef(u); + q = vand_vi_vi_vi_rvvm1_sleef(vadd_vi_vi_vi_rvvm1_sleef(q, vxor_vi_vi_vi_rvvm1_sleef(vsrl_vi_vi_i_rvvm1_sleef(q, 31), vcast_vi_i_rvvm1_sleef(1))), vcast_vi_i_rvvm1_sleef(~1)); + s = vsub_vd_vd_vd_rvvm1_sleef(u, vcast_vd_vi_rvvm1_sleef(q)); + + t = s; + s = vmul_vd_vd_vd_rvvm1_sleef(s, s); + + u = vcast_vd_d_rvvm1_sleef(+0.6880638894766060136e-11); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, s, vcast_vd_d_rvvm1_sleef(-0.1757159564542310199e-8)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, s, vcast_vd_d_rvvm1_sleef(+0.3133616327257867311e-6)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, s, vcast_vd_d_rvvm1_sleef(-0.3657620416388486452e-4)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, s, vcast_vd_d_rvvm1_sleef(+0.2490394570189932103e-2)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, s, vcast_vd_d_rvvm1_sleef(-0.8074551218828056320e-1)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, s, vcast_vd_d_rvvm1_sleef(+0.7853981633974482790e+0)); + + rx = vmul_vd_vd_vd_rvvm1_sleef(u, t); + + u = vcast_vd_d_rvvm1_sleef(-0.3860141213683794352e-12); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, s, vcast_vd_d_rvvm1_sleef(+0.1150057888029681415e-9)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, s, vcast_vd_d_rvvm1_sleef(-0.2461136493006663553e-7)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, s, vcast_vd_d_rvvm1_sleef(+0.3590860446623516713e-5)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, s, vcast_vd_d_rvvm1_sleef(-0.3259918869269435942e-3)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, s, vcast_vd_d_rvvm1_sleef(+0.1585434424381541169e-1)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, s, vcast_vd_d_rvvm1_sleef(-0.3084251375340424373e+0)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, s, vcast_vd_d_rvvm1_sleef(1)); + + ry = u; + + o = vcast_vo64_vo32_rvvm1_sleef(veq_vo_vi_vi_rvvm1_sleef(vand_vi_vi_vi_rvvm1_sleef(q, vcast_vi_i_rvvm1_sleef(2)), vcast_vi_i_rvvm1_sleef(0))); + r = vd2setxy_vd2_vd_vd_rvvm1_sleef(vsel_vd_vo_vd_vd_rvvm1_sleef(o, rx, ry), vsel_vd_vo_vd_vd_rvvm1_sleef(o, ry, rx)); + + o = vcast_vo64_vo32_rvvm1_sleef(veq_vo_vi_vi_rvvm1_sleef(vand_vi_vi_vi_rvvm1_sleef(q, vcast_vi_i_rvvm1_sleef(4)), vcast_vi_i_rvvm1_sleef(4))); + r = vd2setx_vd2_vd2_vd_rvvm1_sleef(r, vreinterpret_vd_vm_rvvm1_sleef(vxor_vm_vm_vm_rvvm1_sleef(vand_vm_vo64_vm_rvvm1_sleef(o, vreinterpret_vm_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(-0.0))), vreinterpret_vm_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(r))))); + + o = vcast_vo64_vo32_rvvm1_sleef(veq_vo_vi_vi_rvvm1_sleef(vand_vi_vi_vi_rvvm1_sleef(vadd_vi_vi_vi_rvvm1_sleef(q, vcast_vi_i_rvvm1_sleef(2)), vcast_vi_i_rvvm1_sleef(4)), vcast_vi_i_rvvm1_sleef(4))); + r = vd2sety_vd2_vd2_vd_rvvm1_sleef(r, vreinterpret_vd_vm_rvvm1_sleef(vxor_vm_vm_vm_rvvm1_sleef(vand_vm_vo64_vm_rvvm1_sleef(o, vreinterpret_vm_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(-0.0))), vreinterpret_vm_vd_rvvm1_sleef(vd2gety_vd_vd2_rvvm1_sleef(r))))); + + o = vgt_vo_vd_vd_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(d), vcast_vd_d_rvvm1_sleef(1e+9/4)); + r = vd2setx_vd2_vd2_vd_rvvm1_sleef(r, vreinterpret_vd_vm_rvvm1_sleef(vandnot_vm_vo64_vm_rvvm1_sleef(o, vreinterpret_vm_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(r))))); + r = vd2sety_vd2_vd2_vd_rvvm1_sleef(r, vreinterpret_vd_vm_rvvm1_sleef(vandnot_vm_vo64_vm_rvvm1_sleef(o, vreinterpret_vm_vd_rvvm1_sleef(vd2gety_vd_vd2_rvvm1_sleef(r))))); + + o = visinf_vo_vd_rvvm1_sleef(d); + r = vd2setx_vd2_vd2_vd_rvvm1_sleef(r, vreinterpret_vd_vm_rvvm1_sleef(vor_vm_vo64_vm_rvvm1_sleef(o, vreinterpret_vm_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(r))))); + r = vd2sety_vd2_vd2_vd_rvvm1_sleef(r, vreinterpret_vd_vm_rvvm1_sleef(vor_vm_vo64_vm_rvvm1_sleef(o, vreinterpret_vm_vd_rvvm1_sleef(vd2gety_vd_vd2_rvvm1_sleef(r))))); + + return r; +} + +SLEEF_INLINE SLEEF_CONST vdouble2_rvvm1_sleef Sleef_modfdx_rvvm1(vdouble_rvvm1_sleef x) { + vdouble_rvvm1_sleef fr = vsub_vd_vd_vd_rvvm1_sleef(x, vmul_vd_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(INT64_C(1) << 31), vcast_vd_vi_rvvm1_sleef(vtruncate_vi_vd_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(x, vcast_vd_d_rvvm1_sleef(1.0 / (INT64_C(1) << 31))))))); + fr = vsub_vd_vd_vd_rvvm1_sleef(fr, vcast_vd_vi_rvvm1_sleef(vtruncate_vi_vd_rvvm1_sleef(fr))); + fr = vsel_vd_vo_vd_vd_rvvm1_sleef(vgt_vo_vd_vd_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(x), vcast_vd_d_rvvm1_sleef(INT64_C(1) << 52)), vcast_vd_d_rvvm1_sleef(0), fr); + + vdouble2_rvvm1_sleef ret; + + ret = vd2setxy_vd2_vd_vd_rvvm1_sleef(vcopysign_vd_vd_vd_rvvm1_sleef(fr, x), vcopysign_vd_vd_vd_rvvm1_sleef(vsub_vd_vd_vd_rvvm1_sleef(x, fr), x)); + + return ret; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_rvvm1_sleef sinpik_rvvm1_sleef(vdouble_rvvm1_sleef d) { + rvv_dp_vopmask_rvvm1_sleef o; + vdouble_rvvm1_sleef u, s, t; + vdouble2_rvvm1_sleef x, s2; + + u = vmul_vd_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(4.0)); + vint_rvvm1_sleef q = vtruncate_vi_vd_rvvm1_sleef(u); + q = vand_vi_vi_vi_rvvm1_sleef(vadd_vi_vi_vi_rvvm1_sleef(q, vxor_vi_vi_vi_rvvm1_sleef(vsrl_vi_vi_i_rvvm1_sleef(q, 31), vcast_vi_i_rvvm1_sleef(1))), vcast_vi_i_rvvm1_sleef(~1)); + o = vcast_vo64_vo32_rvvm1_sleef(veq_vo_vi_vi_rvvm1_sleef(vand_vi_vi_vi_rvvm1_sleef(q, vcast_vi_i_rvvm1_sleef(2)), vcast_vi_i_rvvm1_sleef(2))); + + s = vsub_vd_vd_vd_rvvm1_sleef(u, vcast_vd_vi_rvvm1_sleef(q)); + t = s; + s = vmul_vd_vd_vd_rvvm1_sleef(s, s); + s2 = ddmul_vd2_vd_vd_rvvm1_sleef(t, t); + + u = vsel_vd_vo_d_d_rvvm1_sleef(o, 9.94480387626843774090208e-16, -2.02461120785182399295868e-14); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, s, vsel_vd_vo_d_d_rvvm1_sleef(o, -3.89796226062932799164047e-13, 6.948218305801794613277840e-12)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, s, vsel_vd_vo_d_d_rvvm1_sleef(o, 1.150115825399960352669010e-10, -1.75724749952853179952664e-09)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, s, vsel_vd_vo_d_d_rvvm1_sleef(o, -2.46113695010446974953590e-08, 3.133616889668683928784220e-07)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, s, vsel_vd_vo_d_d_rvvm1_sleef(o, 3.590860448590527540050620e-06, -3.65762041821615519203610e-05)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, s, vsel_vd_vo_d_d_rvvm1_sleef(o, -0.000325991886927389905997954, 0.0024903945701927185027435600)); + x = ddadd2_vd2_vd_vd2_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(u, s), + vsel_vd2_vo_d_d_d_d_rvvm1_sleef(o, 0.0158543442438155018914259, -1.04693272280631521908845e-18, + -0.0807455121882807852484731, 3.61852475067037104849987e-18)); + x = ddadd2_vd2_vd2_vd2_rvvm1_sleef(ddmul_vd2_vd2_vd2_rvvm1_sleef(s2, x), + vsel_vd2_vo_d_d_d_d_rvvm1_sleef(o, -0.308425137534042437259529, -1.95698492133633550338345e-17, + 0.785398163397448278999491, 3.06287113727155002607105e-17)); + + x = ddmul_vd2_vd2_vd2_rvvm1_sleef(x, vsel_vd2_vo_vd2_vd2_rvvm1_sleef(o, s2, vcast_vd2_vd_vd_rvvm1_sleef(t, vcast_vd_d_rvvm1_sleef(0)))); + x = vsel_vd2_vo_vd2_vd2_rvvm1_sleef(o, ddadd2_vd2_vd2_vd_rvvm1_sleef(x, vcast_vd_d_rvvm1_sleef(1)), x); + + o = vcast_vo64_vo32_rvvm1_sleef(veq_vo_vi_vi_rvvm1_sleef(vand_vi_vi_vi_rvvm1_sleef(q, vcast_vi_i_rvvm1_sleef(4)), vcast_vi_i_rvvm1_sleef(4))); + x = vd2setx_vd2_vd2_vd_rvvm1_sleef(x, vreinterpret_vd_vm_rvvm1_sleef(vxor_vm_vm_vm_rvvm1_sleef(vand_vm_vo64_vm_rvvm1_sleef(o, vreinterpret_vm_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(-0.0))), vreinterpret_vm_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(x))))); + x = vd2sety_vd2_vd2_vd_rvvm1_sleef(x, vreinterpret_vd_vm_rvvm1_sleef(vxor_vm_vm_vm_rvvm1_sleef(vand_vm_vo64_vm_rvvm1_sleef(o, vreinterpret_vm_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(-0.0))), vreinterpret_vm_vd_rvvm1_sleef(vd2gety_vd_vd2_rvvm1_sleef(x))))); + + return x; +} + +SLEEF_INLINE SLEEF_CONST vdouble_rvvm1_sleef Sleef_sinpidx_u05rvvm1(vdouble_rvvm1_sleef d) { + vdouble2_rvvm1_sleef x = sinpik_rvvm1_sleef(d); + vdouble_rvvm1_sleef r = vadd_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(x), vd2gety_vd_vd2_rvvm1_sleef(x)); + + r = vsel_vd_vo_vd_vd_rvvm1_sleef(visnegzero_vo_vd_rvvm1_sleef(d), vcast_vd_d_rvvm1_sleef(-0.0), r); + r = vreinterpret_vd_vm_rvvm1_sleef(vandnot_vm_vo64_vm_rvvm1_sleef(vgt_vo_vd_vd_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(d), vcast_vd_d_rvvm1_sleef(1e+9/4)), vreinterpret_vm_vd_rvvm1_sleef(r))); + r = vreinterpret_vd_vm_rvvm1_sleef(vor_vm_vo64_vm_rvvm1_sleef(visinf_vo_vd_rvvm1_sleef(d), vreinterpret_vm_vd_rvvm1_sleef(r))); + + return r; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_rvvm1_sleef cospik_rvvm1_sleef(vdouble_rvvm1_sleef d) { + rvv_dp_vopmask_rvvm1_sleef o; + vdouble_rvvm1_sleef u, s, t; + vdouble2_rvvm1_sleef x, s2; + + u = vmul_vd_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(4.0)); + vint_rvvm1_sleef q = vtruncate_vi_vd_rvvm1_sleef(u); + q = vand_vi_vi_vi_rvvm1_sleef(vadd_vi_vi_vi_rvvm1_sleef(q, vxor_vi_vi_vi_rvvm1_sleef(vsrl_vi_vi_i_rvvm1_sleef(q, 31), vcast_vi_i_rvvm1_sleef(1))), vcast_vi_i_rvvm1_sleef(~1)); + o = vcast_vo64_vo32_rvvm1_sleef(veq_vo_vi_vi_rvvm1_sleef(vand_vi_vi_vi_rvvm1_sleef(q, vcast_vi_i_rvvm1_sleef(2)), vcast_vi_i_rvvm1_sleef(0))); + + s = vsub_vd_vd_vd_rvvm1_sleef(u, vcast_vd_vi_rvvm1_sleef(q)); + t = s; + s = vmul_vd_vd_vd_rvvm1_sleef(s, s); + s2 = ddmul_vd2_vd_vd_rvvm1_sleef(t, t); + + u = vsel_vd_vo_d_d_rvvm1_sleef(o, 9.94480387626843774090208e-16, -2.02461120785182399295868e-14); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, s, vsel_vd_vo_d_d_rvvm1_sleef(o, -3.89796226062932799164047e-13, 6.948218305801794613277840e-12)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, s, vsel_vd_vo_d_d_rvvm1_sleef(o, 1.150115825399960352669010e-10, -1.75724749952853179952664e-09)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, s, vsel_vd_vo_d_d_rvvm1_sleef(o, -2.46113695010446974953590e-08, 3.133616889668683928784220e-07)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, s, vsel_vd_vo_d_d_rvvm1_sleef(o, 3.590860448590527540050620e-06, -3.65762041821615519203610e-05)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, s, vsel_vd_vo_d_d_rvvm1_sleef(o, -0.000325991886927389905997954, 0.0024903945701927185027435600)); + x = ddadd2_vd2_vd_vd2_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(u, s), + vsel_vd2_vo_d_d_d_d_rvvm1_sleef(o, 0.0158543442438155018914259, -1.04693272280631521908845e-18, + -0.0807455121882807852484731, 3.61852475067037104849987e-18)); + x = ddadd2_vd2_vd2_vd2_rvvm1_sleef(ddmul_vd2_vd2_vd2_rvvm1_sleef(s2, x), + vsel_vd2_vo_d_d_d_d_rvvm1_sleef(o, -0.308425137534042437259529, -1.95698492133633550338345e-17, + 0.785398163397448278999491, 3.06287113727155002607105e-17)); + + x = ddmul_vd2_vd2_vd2_rvvm1_sleef(x, vsel_vd2_vo_vd2_vd2_rvvm1_sleef(o, s2, vcast_vd2_vd_vd_rvvm1_sleef(t, vcast_vd_d_rvvm1_sleef(0)))); + x = vsel_vd2_vo_vd2_vd2_rvvm1_sleef(o, ddadd2_vd2_vd2_vd_rvvm1_sleef(x, vcast_vd_d_rvvm1_sleef(1)), x); + + o = vcast_vo64_vo32_rvvm1_sleef(veq_vo_vi_vi_rvvm1_sleef(vand_vi_vi_vi_rvvm1_sleef(vadd_vi_vi_vi_rvvm1_sleef(q, vcast_vi_i_rvvm1_sleef(2)), vcast_vi_i_rvvm1_sleef(4)), vcast_vi_i_rvvm1_sleef(4))); + x = vd2setx_vd2_vd2_vd_rvvm1_sleef(x, vreinterpret_vd_vm_rvvm1_sleef(vxor_vm_vm_vm_rvvm1_sleef(vand_vm_vo64_vm_rvvm1_sleef(o, vreinterpret_vm_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(-0.0))), vreinterpret_vm_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(x))))); + x = vd2sety_vd2_vd2_vd_rvvm1_sleef(x, vreinterpret_vd_vm_rvvm1_sleef(vxor_vm_vm_vm_rvvm1_sleef(vand_vm_vo64_vm_rvvm1_sleef(o, vreinterpret_vm_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(-0.0))), vreinterpret_vm_vd_rvvm1_sleef(vd2gety_vd_vd2_rvvm1_sleef(x))))); + + return x; +} + +SLEEF_INLINE SLEEF_CONST vdouble_rvvm1_sleef Sleef_cospidx_u05rvvm1(vdouble_rvvm1_sleef d) { + vdouble2_rvvm1_sleef x = cospik_rvvm1_sleef(d); + vdouble_rvvm1_sleef r = vadd_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(x), vd2gety_vd_vd2_rvvm1_sleef(x)); + + r = vsel_vd_vo_vd_vd_rvvm1_sleef(vgt_vo_vd_vd_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(d), vcast_vd_d_rvvm1_sleef(1e+9/4)), vcast_vd_d_rvvm1_sleef(1), r); + r = vreinterpret_vd_vm_rvvm1_sleef(vor_vm_vo64_vm_rvvm1_sleef(visinf_vo_vd_rvvm1_sleef(d), vreinterpret_vm_vd_rvvm1_sleef(r))); + + return r; +} + +SLEEF_INLINE SLEEF_CONST vdouble_rvvm1_sleef Sleef_tandx_u35rvvm1(vdouble_rvvm1_sleef d) { + + vdouble_rvvm1_sleef u, s, x, y; + rvv_dp_vopmask_rvvm1_sleef o; + vint_rvvm1_sleef ql; + + if (__builtin_expect(!!(vtestallones_i_vo64_rvvm1_sleef(vlt_vo_vd_vd_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(d), vcast_vd_d_rvvm1_sleef(15)))), 1)) { + vdouble_rvvm1_sleef dql = vrint_vd_vd_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(2 * 0.318309886183790671537767526745028724))); + ql = vrint_vi_vd_rvvm1_sleef(dql); + x = vmla_vd_vd_vd_vd_rvvm1_sleef(dql, vcast_vd_d_rvvm1_sleef(-3.141592653589793116 * 0.5), d); + x = vmla_vd_vd_vd_vd_rvvm1_sleef(dql, vcast_vd_d_rvvm1_sleef(-1.2246467991473532072e-16 * 0.5), x); + } else if (__builtin_expect(!!(vtestallones_i_vo64_rvvm1_sleef(vlt_vo_vd_vd_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(d), vcast_vd_d_rvvm1_sleef(1e+6)))), 1)) { + vdouble_rvvm1_sleef dqh = vtruncate_vd_vd_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(2*0.318309886183790671537767526745028724 / (1 << 24)))); + dqh = vmul_vd_vd_vd_rvvm1_sleef(dqh, vcast_vd_d_rvvm1_sleef(1 << 24)); + vdouble_rvvm1_sleef dql = vrint_vd_vd_rvvm1_sleef(vsub_vd_vd_vd_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(2*0.318309886183790671537767526745028724)), dqh)); + ql = vrint_vi_vd_rvvm1_sleef(dql); + + x = vmla_vd_vd_vd_vd_rvvm1_sleef(dqh, vcast_vd_d_rvvm1_sleef(-3.1415926218032836914 * 0.5), d); + x = vmla_vd_vd_vd_vd_rvvm1_sleef(dql, vcast_vd_d_rvvm1_sleef(-3.1415926218032836914 * 0.5), x); + x = vmla_vd_vd_vd_vd_rvvm1_sleef(dqh, vcast_vd_d_rvvm1_sleef(-3.1786509424591713469e-08 * 0.5), x); + x = vmla_vd_vd_vd_vd_rvvm1_sleef(dql, vcast_vd_d_rvvm1_sleef(-3.1786509424591713469e-08 * 0.5), x); + x = vmla_vd_vd_vd_vd_rvvm1_sleef(dqh, vcast_vd_d_rvvm1_sleef(-1.2246467864107188502e-16 * 0.5), x); + x = vmla_vd_vd_vd_vd_rvvm1_sleef(dql, vcast_vd_d_rvvm1_sleef(-1.2246467864107188502e-16 * 0.5), x); + x = vmla_vd_vd_vd_vd_rvvm1_sleef(vadd_vd_vd_vd_rvvm1_sleef(dqh, dql), vcast_vd_d_rvvm1_sleef(-1.2736634327021899816e-24 * 0.5), x); + } else { + ddi_t_rvvm1_sleef ddi_rvvm1_sleef = rempi_rvvm1_sleef(d); + ql = ddigeti_vi_ddi_rvvm1_sleef(ddi_rvvm1_sleef); + x = vadd_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(ddigetdd_vd2_ddi_rvvm1_sleef(ddi_rvvm1_sleef)), vd2gety_vd_vd2_rvvm1_sleef(ddigetdd_vd2_ddi_rvvm1_sleef(ddi_rvvm1_sleef))); + x = vreinterpret_vd_vm_rvvm1_sleef(vor_vm_vo64_vm_rvvm1_sleef(visinf_vo_vd_rvvm1_sleef(d), vreinterpret_vm_vd_rvvm1_sleef(x))); + x = vreinterpret_vd_vm_rvvm1_sleef(vor_vm_vo64_vm_rvvm1_sleef(rvv_dp_vor_vo_vo_vo(visinf_vo_vd_rvvm1_sleef(d), visnan_vo_vd_rvvm1_sleef(d)), vreinterpret_vm_vd_rvvm1_sleef(x))); + } + + x = vmul_vd_vd_vd_rvvm1_sleef(x, vcast_vd_d_rvvm1_sleef(0.5)); + s = vmul_vd_vd_vd_rvvm1_sleef(x, x); + + vdouble_rvvm1_sleef s2 = vmul_vd_vd_vd_rvvm1_sleef(s, s), s4 = vmul_vd_vd_vd_rvvm1_sleef(s2, s2); + u = vmla_vd_vd_vd_vd_rvvm1_sleef((s4), (vmla_vd_vd_vd_vd_rvvm1_sleef((s2), (vmla_vd_vd_vd_vd_rvvm1_sleef((s), (vcast_vd_d_rvvm1_sleef(+0.3245098826639276316e-3)), (vcast_vd_d_rvvm1_sleef(+0.5619219738114323735e-3)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((s), (vcast_vd_d_rvvm1_sleef(+0.1460781502402784494e-2)), (vcast_vd_d_rvvm1_sleef(+0.3591611540792499519e-2)))))), (vmla_vd_vd_vd_vd_rvvm1_sleef((s2), (vmla_vd_vd_vd_vd_rvvm1_sleef((s), (vcast_vd_d_rvvm1_sleef(+0.8863268409563113126e-2)), (vcast_vd_d_rvvm1_sleef(+0.2186948728185535498e-1)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((s), (vcast_vd_d_rvvm1_sleef(+0.5396825399517272970e-1)), (vcast_vd_d_rvvm1_sleef(+0.1333333333330500581e+0))))))) + + ; + + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, s, vcast_vd_d_rvvm1_sleef(+0.3333333333333343695e+0)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(s, vmul_vd_vd_vd_rvvm1_sleef(u, x), x); + + y = vmla_vd_vd_vd_vd_rvvm1_sleef(u, u, vcast_vd_d_rvvm1_sleef(-1)); + x = vmul_vd_vd_vd_rvvm1_sleef(u, vcast_vd_d_rvvm1_sleef(-2)); + + o = vcast_vo64_vo32_rvvm1_sleef(veq_vo_vi_vi_rvvm1_sleef(vand_vi_vi_vi_rvvm1_sleef(ql, vcast_vi_i_rvvm1_sleef(1)), vcast_vi_i_rvvm1_sleef(1))); + u = vdiv_vd_vd_vd_rvvm1_sleef(vsel_vd_vo_vd_vd_rvvm1_sleef(o, vneg_vd_vd_rvvm1_sleef(y), x), + vsel_vd_vo_vd_vd_rvvm1_sleef(o, x, y)); + u = vsel_vd_vo_vd_vd_rvvm1_sleef(veq_vo_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(0)), d, u); + + return u; + +} + +SLEEF_INLINE SLEEF_CONST vdouble_rvvm1_sleef Sleef_tandx_u10rvvm1(vdouble_rvvm1_sleef d) { + + vdouble_rvvm1_sleef u; + vdouble2_rvvm1_sleef s, t, x, y; + rvv_dp_vopmask_rvvm1_sleef o; + vint_rvvm1_sleef ql; + + if (__builtin_expect(!!(vtestallones_i_vo64_rvvm1_sleef(vlt_vo_vd_vd_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(d), vcast_vd_d_rvvm1_sleef(15)))), 1)) { + vdouble_rvvm1_sleef dql = vrint_vd_vd_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(2 * 0.318309886183790671537767526745028724))); + ql = vrint_vi_vd_rvvm1_sleef(dql); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(dql, vcast_vd_d_rvvm1_sleef(-3.141592653589793116*0.5), d); + s = ddadd_vd2_vd_vd_rvvm1_sleef (u, vmul_vd_vd_vd_rvvm1_sleef(dql, vcast_vd_d_rvvm1_sleef(-1.2246467991473532072e-16*0.5))); + } else if (__builtin_expect(!!(vtestallones_i_vo64_rvvm1_sleef(vlt_vo_vd_vd_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(d), vcast_vd_d_rvvm1_sleef(1e+14)))), 1)) { + vdouble_rvvm1_sleef dqh = vtruncate_vd_vd_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(2*0.318309886183790671537767526745028724 / (1 << 24)))); + dqh = vmul_vd_vd_vd_rvvm1_sleef(dqh, vcast_vd_d_rvvm1_sleef(1 << 24)); + s = ddadd2_vd2_vd2_vd_rvvm1_sleef(ddmul_vd2_vd2_vd_rvvm1_sleef(vcast_vd2_d_d_rvvm1_sleef(0.63661977236758138243, -3.9357353350364971764e-17), d), + vsub_vd_vd_vd_rvvm1_sleef(vsel_vd_vo_vd_vd_rvvm1_sleef(vlt_vo_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(0)), + vcast_vd_d_rvvm1_sleef(-0.5), vcast_vd_d_rvvm1_sleef(0.5)), dqh)); + const vdouble_rvvm1_sleef dql = vtruncate_vd_vd_rvvm1_sleef(vadd_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(s), vd2gety_vd_vd2_rvvm1_sleef(s))); + ql = vrint_vi_vd_rvvm1_sleef(dql); + + u = vmla_vd_vd_vd_vd_rvvm1_sleef(dqh, vcast_vd_d_rvvm1_sleef(-3.1415926218032836914 * 0.5), d); + s = ddadd_vd2_vd_vd_rvvm1_sleef(u, vmul_vd_vd_vd_rvvm1_sleef(dql, vcast_vd_d_rvvm1_sleef(-3.1415926218032836914*0.5 ))); + s = ddadd2_vd2_vd2_vd_rvvm1_sleef(s, vmul_vd_vd_vd_rvvm1_sleef(dqh, vcast_vd_d_rvvm1_sleef(-3.1786509424591713469e-08*0.5))); + s = ddadd2_vd2_vd2_vd_rvvm1_sleef(s, vmul_vd_vd_vd_rvvm1_sleef(dql, vcast_vd_d_rvvm1_sleef(-3.1786509424591713469e-08*0.5 ))); + s = ddadd2_vd2_vd2_vd_rvvm1_sleef(s, vmul_vd_vd_vd_rvvm1_sleef(dqh, vcast_vd_d_rvvm1_sleef(-1.2246467864107188502e-16*0.5))); + s = ddadd2_vd2_vd2_vd_rvvm1_sleef(s, vmul_vd_vd_vd_rvvm1_sleef(dql, vcast_vd_d_rvvm1_sleef(-1.2246467864107188502e-16*0.5 ))); + s = ddadd_vd2_vd2_vd_rvvm1_sleef(s, vmul_vd_vd_vd_rvvm1_sleef(vadd_vd_vd_vd_rvvm1_sleef(dqh, dql), vcast_vd_d_rvvm1_sleef(-1.2736634327021899816e-24*0.5))); + } else { + ddi_t_rvvm1_sleef ddi_rvvm1_sleef = rempi_rvvm1_sleef(d); + ql = ddigeti_vi_ddi_rvvm1_sleef(ddi_rvvm1_sleef); + s = ddigetdd_vd2_ddi_rvvm1_sleef(ddi_rvvm1_sleef); + o = rvv_dp_vor_vo_vo_vo(visinf_vo_vd_rvvm1_sleef(d), visnan_vo_vd_rvvm1_sleef(d)); + s = vd2setx_vd2_vd2_vd_rvvm1_sleef(s, vreinterpret_vd_vm_rvvm1_sleef(vor_vm_vo64_vm_rvvm1_sleef(o, vreinterpret_vm_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(s))))); + s = vd2sety_vd2_vd2_vd_rvvm1_sleef(s, vreinterpret_vd_vm_rvvm1_sleef(vor_vm_vo64_vm_rvvm1_sleef(o, vreinterpret_vm_vd_rvvm1_sleef(vd2gety_vd_vd2_rvvm1_sleef(s))))); + } + + t = ddscale_vd2_vd2_vd_rvvm1_sleef(s, vcast_vd_d_rvvm1_sleef(0.5)); + s = ddsqu_vd2_vd2_rvvm1_sleef(t); + + vdouble_rvvm1_sleef s2 = vmul_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(s), vd2getx_vd_vd2_rvvm1_sleef(s)), s4 = vmul_vd_vd_vd_rvvm1_sleef(s2, s2); + u = vmla_vd_vd_vd_vd_rvvm1_sleef((s4), (vmla_vd_vd_vd_vd_rvvm1_sleef((s2), (vmla_vd_vd_vd_vd_rvvm1_sleef((vd2getx_vd_vd2_rvvm1_sleef(s)), (vcast_vd_d_rvvm1_sleef(+0.3245098826639276316e-3)), (vcast_vd_d_rvvm1_sleef(+0.5619219738114323735e-3)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((vd2getx_vd_vd2_rvvm1_sleef(s)), (vcast_vd_d_rvvm1_sleef(+0.1460781502402784494e-2)), (vcast_vd_d_rvvm1_sleef(+0.3591611540792499519e-2)))))), (vmla_vd_vd_vd_vd_rvvm1_sleef((s2), (vmla_vd_vd_vd_vd_rvvm1_sleef((vd2getx_vd_vd2_rvvm1_sleef(s)), (vcast_vd_d_rvvm1_sleef(+0.8863268409563113126e-2)), (vcast_vd_d_rvvm1_sleef(+0.2186948728185535498e-1)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((vd2getx_vd_vd2_rvvm1_sleef(s)), (vcast_vd_d_rvvm1_sleef(+0.5396825399517272970e-1)), (vcast_vd_d_rvvm1_sleef(+0.1333333333330500581e+0))))))) + + ; + + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, vd2getx_vd_vd2_rvvm1_sleef(s), vcast_vd_d_rvvm1_sleef(+0.3333333333333343695e+0)); + x = ddadd_vd2_vd2_vd2_rvvm1_sleef(t, ddmul_vd2_vd2_vd_rvvm1_sleef(ddmul_vd2_vd2_vd2_rvvm1_sleef(s, t), u)); + + y = ddadd_vd2_vd_vd2_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(-1), ddsqu_vd2_vd2_rvvm1_sleef(x)); + x = ddscale_vd2_vd2_vd_rvvm1_sleef(x, vcast_vd_d_rvvm1_sleef(-2)); + + o = vcast_vo64_vo32_rvvm1_sleef(veq_vo_vi_vi_rvvm1_sleef(vand_vi_vi_vi_rvvm1_sleef(ql, vcast_vi_i_rvvm1_sleef(1)), vcast_vi_i_rvvm1_sleef(1))); + + x = dddiv_vd2_vd2_vd2_rvvm1_sleef(vsel_vd2_vo_vd2_vd2_rvvm1_sleef(o, ddneg_vd2_vd2_rvvm1_sleef(y), x), + vsel_vd2_vo_vd2_vd2_rvvm1_sleef(o, x, y)); + + u = vadd_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(x), vd2gety_vd_vd2_rvvm1_sleef(x)); + + u = vsel_vd_vo_vd_vd_rvvm1_sleef(veq_vo_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(0)), d, u); + + return u; + +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_rvvm1_sleef atan2k_rvvm1_sleef(vdouble_rvvm1_sleef y, vdouble_rvvm1_sleef x) { + vdouble_rvvm1_sleef s, t, u; + vint_rvvm1_sleef q; + rvv_dp_vopmask_rvvm1_sleef p; + + q = vsel_vi_vd_vi_rvvm1_sleef(x, vcast_vi_i_rvvm1_sleef(-2)); + x = vabs_vd_vd_rvvm1_sleef(x); + + q = vsel_vi_vd_vd_vi_vi_rvvm1_sleef(x, y, vadd_vi_vi_vi_rvvm1_sleef(q, vcast_vi_i_rvvm1_sleef(1)), q); + p = vlt_vo_vd_vd_rvvm1_sleef(x, y); + s = vsel_vd_vo_vd_vd_rvvm1_sleef(p, vneg_vd_vd_rvvm1_sleef(x), y); + t = vmax_vd_vd_vd_rvvm1_sleef(x, y); + + s = vdiv_vd_vd_vd_rvvm1_sleef(s, t); + t = vmul_vd_vd_vd_rvvm1_sleef(s, s); + + vdouble_rvvm1_sleef t2 = vmul_vd_vd_vd_rvvm1_sleef(t, t), t4 = vmul_vd_vd_vd_rvvm1_sleef(t2, t2), t8 = vmul_vd_vd_vd_rvvm1_sleef(t4, t4), t16 = vmul_vd_vd_vd_rvvm1_sleef(t8, t8); + u = vmla_vd_vd_vd_vd_rvvm1_sleef((t16), (vmla_vd_vd_vd_vd_rvvm1_sleef((t2), (vcast_vd_d_rvvm1_sleef(-1.88796008463073496563746e-05)), (vmla_vd_vd_vd_vd_rvvm1_sleef((t), (vcast_vd_d_rvvm1_sleef(0.000209850076645816976906797)), (vcast_vd_d_rvvm1_sleef(-0.00110611831486672482563471)))))), (vmla_vd_vd_vd_vd_rvvm1_sleef((t8), (vmla_vd_vd_vd_vd_rvvm1_sleef((t4), (vmla_vd_vd_vd_vd_rvvm1_sleef((t2), (vmla_vd_vd_vd_vd_rvvm1_sleef((t), (vcast_vd_d_rvvm1_sleef(0.00370026744188713119232403)), (vcast_vd_d_rvvm1_sleef(-0.00889896195887655491740809)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((t), (vcast_vd_d_rvvm1_sleef(0.016599329773529201970117)), (vcast_vd_d_rvvm1_sleef(-0.0254517624932312641616861)))))), (vmla_vd_vd_vd_vd_rvvm1_sleef((t2), (vmla_vd_vd_vd_vd_rvvm1_sleef((t), (vcast_vd_d_rvvm1_sleef(0.0337852580001353069993897)), (vcast_vd_d_rvvm1_sleef(-0.0407629191276836500001934)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((t), (vcast_vd_d_rvvm1_sleef(0.0466667150077840625632675)), (vcast_vd_d_rvvm1_sleef(-0.0523674852303482457616113)))))))), (vmla_vd_vd_vd_vd_rvvm1_sleef((t4), (vmla_vd_vd_vd_vd_rvvm1_sleef((t2), (vmla_vd_vd_vd_vd_rvvm1_sleef((t), (vcast_vd_d_rvvm1_sleef(0.0587666392926673580854313)), (vcast_vd_d_rvvm1_sleef(-0.0666573579361080525984562)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((t), (vcast_vd_d_rvvm1_sleef(0.0769219538311769618355029)), (vcast_vd_d_rvvm1_sleef(-0.090908995008245008229153)))))), (vmla_vd_vd_vd_vd_rvvm1_sleef((t2), (vmla_vd_vd_vd_vd_rvvm1_sleef((t), (vcast_vd_d_rvvm1_sleef(0.111111105648261418443745)), (vcast_vd_d_rvvm1_sleef(-0.14285714266771329383765)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((t), (vcast_vd_d_rvvm1_sleef(0.199999999996591265594148)), (vcast_vd_d_rvvm1_sleef(-0.333333333333311110369124))))))))))) + + ; + + t = vmla_vd_vd_vd_vd_rvvm1_sleef(s, vmul_vd_vd_vd_rvvm1_sleef(t, u), s); + t = vmla_vd_vd_vd_vd_rvvm1_sleef(vcast_vd_vi_rvvm1_sleef(q), vcast_vd_d_rvvm1_sleef(3.141592653589793238462643383279502884/2), t); + + return t; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_rvvm1_sleef atan2k_u1_rvvm1_sleef(vdouble2_rvvm1_sleef y, vdouble2_rvvm1_sleef x) { + vdouble_rvvm1_sleef u; + vdouble2_rvvm1_sleef s, t; + vint_rvvm1_sleef q; + rvv_dp_vopmask_rvvm1_sleef p; + + q = vsel_vi_vd_vi_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(x), vcast_vi_i_rvvm1_sleef(-2)); + p = vlt_vo_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(x), vcast_vd_d_rvvm1_sleef(0)); + vmask_rvvm1_sleef b = vand_vm_vo64_vm_rvvm1_sleef(p, vreinterpret_vm_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(-0.0))); + x = vd2setx_vd2_vd2_vd_rvvm1_sleef(x, vreinterpret_vd_vm_rvvm1_sleef(vxor_vm_vm_vm_rvvm1_sleef(b, vreinterpret_vm_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(x))))); + x = vd2sety_vd2_vd2_vd_rvvm1_sleef(x, vreinterpret_vd_vm_rvvm1_sleef(vxor_vm_vm_vm_rvvm1_sleef(b, vreinterpret_vm_vd_rvvm1_sleef(vd2gety_vd_vd2_rvvm1_sleef(x))))); + + q = vsel_vi_vd_vd_vi_vi_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(x), vd2getx_vd_vd2_rvvm1_sleef(y), vadd_vi_vi_vi_rvvm1_sleef(q, vcast_vi_i_rvvm1_sleef(1)), q); + p = vlt_vo_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(x), vd2getx_vd_vd2_rvvm1_sleef(y)); + s = vsel_vd2_vo_vd2_vd2_rvvm1_sleef(p, ddneg_vd2_vd2_rvvm1_sleef(x), y); + t = vsel_vd2_vo_vd2_vd2_rvvm1_sleef(p, y, x); + + s = dddiv_vd2_vd2_vd2_rvvm1_sleef(s, t); + t = ddsqu_vd2_vd2_rvvm1_sleef(s); + t = ddnormalize_vd2_vd2_rvvm1_sleef(t); + + vdouble_rvvm1_sleef t2 = vmul_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(t), vd2getx_vd_vd2_rvvm1_sleef(t)), t4 = vmul_vd_vd_vd_rvvm1_sleef(t2, t2), t8 = vmul_vd_vd_vd_rvvm1_sleef(t4, t4); + u = vmla_vd_vd_vd_vd_rvvm1_sleef((t8), (vmla_vd_vd_vd_vd_rvvm1_sleef((t4), (vmla_vd_vd_vd_vd_rvvm1_sleef((t2), (vmla_vd_vd_vd_vd_rvvm1_sleef((vd2getx_vd_vd2_rvvm1_sleef(t)), (vcast_vd_d_rvvm1_sleef(1.06298484191448746607415e-05)), (vcast_vd_d_rvvm1_sleef(-0.000125620649967286867384336)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((vd2getx_vd_vd2_rvvm1_sleef(t)), (vcast_vd_d_rvvm1_sleef(0.00070557664296393412389774)), (vcast_vd_d_rvvm1_sleef(-0.00251865614498713360352999)))))), (vmla_vd_vd_vd_vd_rvvm1_sleef((t2), (vmla_vd_vd_vd_vd_rvvm1_sleef((vd2getx_vd_vd2_rvvm1_sleef(t)), (vcast_vd_d_rvvm1_sleef(0.00646262899036991172313504)), (vcast_vd_d_rvvm1_sleef(-0.0128281333663399031014274)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((vd2getx_vd_vd2_rvvm1_sleef(t)), (vcast_vd_d_rvvm1_sleef(0.0208024799924145797902497)), (vcast_vd_d_rvvm1_sleef(-0.0289002344784740315686289)))))))), (vmla_vd_vd_vd_vd_rvvm1_sleef((t4), (vmla_vd_vd_vd_vd_rvvm1_sleef((t2), (vmla_vd_vd_vd_vd_rvvm1_sleef((vd2getx_vd_vd2_rvvm1_sleef(t)), (vcast_vd_d_rvvm1_sleef(0.0359785005035104590853656)), (vcast_vd_d_rvvm1_sleef(-0.041848579703592507506027)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((vd2getx_vd_vd2_rvvm1_sleef(t)), (vcast_vd_d_rvvm1_sleef(0.0470843011653283988193763)), (vcast_vd_d_rvvm1_sleef(-0.0524914210588448421068719)))))), (vmla_vd_vd_vd_vd_rvvm1_sleef((t2), (vmla_vd_vd_vd_vd_rvvm1_sleef((vd2getx_vd_vd2_rvvm1_sleef(t)), (vcast_vd_d_rvvm1_sleef(0.0587946590969581003860434)), (vcast_vd_d_rvvm1_sleef(-0.0666620884778795497194182)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((vd2getx_vd_vd2_rvvm1_sleef(t)), (vcast_vd_d_rvvm1_sleef(0.0769225330296203768654095)), (vcast_vd_d_rvvm1_sleef(-0.0909090442773387574781907))))))))) + + ; + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, vd2getx_vd_vd2_rvvm1_sleef(t), vcast_vd_d_rvvm1_sleef(0.111111108376896236538123)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, vd2getx_vd_vd2_rvvm1_sleef(t), vcast_vd_d_rvvm1_sleef(-0.142857142756268568062339)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, vd2getx_vd_vd2_rvvm1_sleef(t), vcast_vd_d_rvvm1_sleef(0.199999999997977351284817)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, vd2getx_vd_vd2_rvvm1_sleef(t), vcast_vd_d_rvvm1_sleef(-0.333333333333317605173818)); + + t = ddadd_vd2_vd2_vd2_rvvm1_sleef(s, ddmul_vd2_vd2_vd_rvvm1_sleef(ddmul_vd2_vd2_vd2_rvvm1_sleef(s, t), u)); + + t = ddadd_vd2_vd2_vd2_rvvm1_sleef(ddmul_vd2_vd2_vd_rvvm1_sleef(vcast_vd2_d_d_rvvm1_sleef(1.570796326794896557998982, 6.12323399573676603586882e-17), vcast_vd_vi_rvvm1_sleef(q)), t); + + return t; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_rvvm1_sleef visinf2_vd_vd_vd_rvvm1_sleef(vdouble_rvvm1_sleef d, vdouble_rvvm1_sleef m) { + return vreinterpret_vd_vm_rvvm1_sleef(vand_vm_vo64_vm_rvvm1_sleef(visinf_vo_vd_rvvm1_sleef(d), vor_vm_vm_vm_rvvm1_sleef(vand_vm_vm_vm_rvvm1_sleef(vreinterpret_vm_vd_rvvm1_sleef(d), vreinterpret_vm_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(-0.0))), vreinterpret_vm_vd_rvvm1_sleef(m)))); +} + +SLEEF_INLINE SLEEF_CONST vdouble_rvvm1_sleef Sleef_atan2dx_u35rvvm1(vdouble_rvvm1_sleef y, vdouble_rvvm1_sleef x) { + vdouble_rvvm1_sleef r = atan2k_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(y), x); + + r = vmulsign_vd_vd_vd_rvvm1_sleef(r, x); + r = vsel_vd_vo_vd_vd_rvvm1_sleef(rvv_dp_vor_vo_vo_vo(visinf_vo_vd_rvvm1_sleef(x), veq_vo_vd_vd_rvvm1_sleef(x, vcast_vd_d_rvvm1_sleef(0))), vsub_vd_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(3.141592653589793238462643383279502884/2), visinf2_vd_vd_vd_rvvm1_sleef(x, vmulsign_vd_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(3.141592653589793238462643383279502884/2), x))), r); + r = vsel_vd_vo_vd_vd_rvvm1_sleef(visinf_vo_vd_rvvm1_sleef(y), vsub_vd_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(3.141592653589793238462643383279502884/2), visinf2_vd_vd_vd_rvvm1_sleef(x, vmulsign_vd_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(3.141592653589793238462643383279502884/4), x))), r); + r = vsel_vd_vo_vd_vd_rvvm1_sleef(veq_vo_vd_vd_rvvm1_sleef(y, vcast_vd_d_rvvm1_sleef(0.0)), vreinterpret_vd_vm_rvvm1_sleef(vand_vm_vo64_vm_rvvm1_sleef(vsignbit_vo_vd_rvvm1_sleef(x), vreinterpret_vm_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(3.141592653589793238462643383279502884)))), r); + + r = vreinterpret_vd_vm_rvvm1_sleef(vor_vm_vo64_vm_rvvm1_sleef(rvv_dp_vor_vo_vo_vo(visnan_vo_vd_rvvm1_sleef(x), visnan_vo_vd_rvvm1_sleef(y)), vreinterpret_vm_vd_rvvm1_sleef(vmulsign_vd_vd_vd_rvvm1_sleef(r, y)))); + return r; +} + +SLEEF_INLINE SLEEF_CONST vdouble_rvvm1_sleef Sleef_atan2dx_u10rvvm1(vdouble_rvvm1_sleef y, vdouble_rvvm1_sleef x) { + rvv_dp_vopmask_rvvm1_sleef o = vlt_vo_vd_vd_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(x), vcast_vd_d_rvvm1_sleef(5.5626846462680083984e-309)); + x = vsel_vd_vo_vd_vd_rvvm1_sleef(o, vmul_vd_vd_vd_rvvm1_sleef(x, vcast_vd_d_rvvm1_sleef(UINT64_C(1) << 53)), x); + y = vsel_vd_vo_vd_vd_rvvm1_sleef(o, vmul_vd_vd_vd_rvvm1_sleef(y, vcast_vd_d_rvvm1_sleef(UINT64_C(1) << 53)), y); + + vdouble2_rvvm1_sleef d = atan2k_u1_rvvm1_sleef(vcast_vd2_vd_vd_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(y), vcast_vd_d_rvvm1_sleef(0)), vcast_vd2_vd_vd_rvvm1_sleef(x, vcast_vd_d_rvvm1_sleef(0))); + vdouble_rvvm1_sleef r = vadd_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(d), vd2gety_vd_vd2_rvvm1_sleef(d)); + + r = vmulsign_vd_vd_vd_rvvm1_sleef(r, x); + r = vsel_vd_vo_vd_vd_rvvm1_sleef(rvv_dp_vor_vo_vo_vo(visinf_vo_vd_rvvm1_sleef(x), veq_vo_vd_vd_rvvm1_sleef(x, vcast_vd_d_rvvm1_sleef(0))), vsub_vd_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(3.141592653589793238462643383279502884/2), visinf2_vd_vd_vd_rvvm1_sleef(x, vmulsign_vd_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(3.141592653589793238462643383279502884/2), x))), r); + r = vsel_vd_vo_vd_vd_rvvm1_sleef(visinf_vo_vd_rvvm1_sleef(y), vsub_vd_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(3.141592653589793238462643383279502884/2), visinf2_vd_vd_vd_rvvm1_sleef(x, vmulsign_vd_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(3.141592653589793238462643383279502884/4), x))), r); + r = vsel_vd_vo_vd_vd_rvvm1_sleef(veq_vo_vd_vd_rvvm1_sleef(y, vcast_vd_d_rvvm1_sleef(0.0)), vreinterpret_vd_vm_rvvm1_sleef(vand_vm_vo64_vm_rvvm1_sleef(vsignbit_vo_vd_rvvm1_sleef(x), vreinterpret_vm_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(3.141592653589793238462643383279502884)))), r); + + r = vreinterpret_vd_vm_rvvm1_sleef(vor_vm_vo64_vm_rvvm1_sleef(rvv_dp_vor_vo_vo_vo(visnan_vo_vd_rvvm1_sleef(x), visnan_vo_vd_rvvm1_sleef(y)), vreinterpret_vm_vd_rvvm1_sleef(vmulsign_vd_vd_vd_rvvm1_sleef(r, y)))); + return r; +} + +SLEEF_INLINE SLEEF_CONST vdouble_rvvm1_sleef Sleef_asindx_u35rvvm1(vdouble_rvvm1_sleef d) { + rvv_dp_vopmask_rvvm1_sleef o = vlt_vo_vd_vd_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(d), vcast_vd_d_rvvm1_sleef(0.5)); + vdouble_rvvm1_sleef x2 = vsel_vd_vo_vd_vd_rvvm1_sleef(o, vmul_vd_vd_vd_rvvm1_sleef(d, d), vmul_vd_vd_vd_rvvm1_sleef(vsub_vd_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(1), vabs_vd_vd_rvvm1_sleef(d)), vcast_vd_d_rvvm1_sleef(0.5))); + vdouble_rvvm1_sleef x = vsel_vd_vo_vd_vd_rvvm1_sleef(o, vabs_vd_vd_rvvm1_sleef(d), vsqrt_vd_vd_rvvm1_sleef(x2)), u; + + vdouble_rvvm1_sleef x4 = vmul_vd_vd_vd_rvvm1_sleef(x2, x2), x8 = vmul_vd_vd_vd_rvvm1_sleef(x4, x4), x16 = vmul_vd_vd_vd_rvvm1_sleef(x8, x8); + u = vmla_vd_vd_vd_vd_rvvm1_sleef((x16), (vmla_vd_vd_vd_vd_rvvm1_sleef((x4), (vmla_vd_vd_vd_vd_rvvm1_sleef((x2), (vcast_vd_d_rvvm1_sleef(+0.3161587650653934628e-1)), (vcast_vd_d_rvvm1_sleef(-0.1581918243329996643e-1)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((x2), (vcast_vd_d_rvvm1_sleef(+0.1929045477267910674e-1)), (vcast_vd_d_rvvm1_sleef(+0.6606077476277170610e-2)))))), (vmla_vd_vd_vd_vd_rvvm1_sleef((x8), (vmla_vd_vd_vd_vd_rvvm1_sleef((x4), (vmla_vd_vd_vd_vd_rvvm1_sleef((x2), (vcast_vd_d_rvvm1_sleef(+0.1215360525577377331e-1)), (vcast_vd_d_rvvm1_sleef(+0.1388715184501609218e-1)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((x2), (vcast_vd_d_rvvm1_sleef(+0.1735956991223614604e-1)), (vcast_vd_d_rvvm1_sleef(+0.2237176181932048341e-1)))))), (vmla_vd_vd_vd_vd_rvvm1_sleef((x4), (vmla_vd_vd_vd_vd_rvvm1_sleef((x2), (vcast_vd_d_rvvm1_sleef(+0.3038195928038132237e-1)), (vcast_vd_d_rvvm1_sleef(+0.4464285681377102438e-1)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((x2), (vcast_vd_d_rvvm1_sleef(+0.7500000000378581611e-1)), (vcast_vd_d_rvvm1_sleef(+0.1666666666666497543e+0))))))))) + + ; + + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, vmul_vd_vd_vd_rvvm1_sleef(x, x2), x); + + vdouble_rvvm1_sleef r = vsel_vd_vo_vd_vd_rvvm1_sleef(o, u, vmla_vd_vd_vd_vd_rvvm1_sleef(u, vcast_vd_d_rvvm1_sleef(-2), vcast_vd_d_rvvm1_sleef(3.141592653589793238462643383279502884/2))); + return vmulsign_vd_vd_vd_rvvm1_sleef(r, d); +} + +SLEEF_INLINE SLEEF_CONST vdouble_rvvm1_sleef Sleef_asindx_u10rvvm1(vdouble_rvvm1_sleef d) { + rvv_dp_vopmask_rvvm1_sleef o = vlt_vo_vd_vd_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(d), vcast_vd_d_rvvm1_sleef(0.5)); + vdouble_rvvm1_sleef x2 = vsel_vd_vo_vd_vd_rvvm1_sleef(o, vmul_vd_vd_vd_rvvm1_sleef(d, d), vmul_vd_vd_vd_rvvm1_sleef(vsub_vd_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(1), vabs_vd_vd_rvvm1_sleef(d)), vcast_vd_d_rvvm1_sleef(0.5))), u; + vdouble2_rvvm1_sleef x = vsel_vd2_vo_vd2_vd2_rvvm1_sleef(o, vcast_vd2_vd_vd_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(d), vcast_vd_d_rvvm1_sleef(0)), ddsqrt_vd2_vd_rvvm1_sleef(x2)); + x = vsel_vd2_vo_vd2_vd2_rvvm1_sleef(veq_vo_vd_vd_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(d), vcast_vd_d_rvvm1_sleef(1.0)), vcast_vd2_d_d_rvvm1_sleef(0, 0), x); + + vdouble_rvvm1_sleef x4 = vmul_vd_vd_vd_rvvm1_sleef(x2, x2), x8 = vmul_vd_vd_vd_rvvm1_sleef(x4, x4), x16 = vmul_vd_vd_vd_rvvm1_sleef(x8, x8); + u = vmla_vd_vd_vd_vd_rvvm1_sleef((x16), (vmla_vd_vd_vd_vd_rvvm1_sleef((x4), (vmla_vd_vd_vd_vd_rvvm1_sleef((x2), (vcast_vd_d_rvvm1_sleef(+0.3161587650653934628e-1)), (vcast_vd_d_rvvm1_sleef(-0.1581918243329996643e-1)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((x2), (vcast_vd_d_rvvm1_sleef(+0.1929045477267910674e-1)), (vcast_vd_d_rvvm1_sleef(+0.6606077476277170610e-2)))))), (vmla_vd_vd_vd_vd_rvvm1_sleef((x8), (vmla_vd_vd_vd_vd_rvvm1_sleef((x4), (vmla_vd_vd_vd_vd_rvvm1_sleef((x2), (vcast_vd_d_rvvm1_sleef(+0.1215360525577377331e-1)), (vcast_vd_d_rvvm1_sleef(+0.1388715184501609218e-1)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((x2), (vcast_vd_d_rvvm1_sleef(+0.1735956991223614604e-1)), (vcast_vd_d_rvvm1_sleef(+0.2237176181932048341e-1)))))), (vmla_vd_vd_vd_vd_rvvm1_sleef((x4), (vmla_vd_vd_vd_vd_rvvm1_sleef((x2), (vcast_vd_d_rvvm1_sleef(+0.3038195928038132237e-1)), (vcast_vd_d_rvvm1_sleef(+0.4464285681377102438e-1)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((x2), (vcast_vd_d_rvvm1_sleef(+0.7500000000378581611e-1)), (vcast_vd_d_rvvm1_sleef(+0.1666666666666497543e+0))))))))) + + ; + + u = vmul_vd_vd_vd_rvvm1_sleef(u, vmul_vd_vd_vd_rvvm1_sleef(x2, vd2getx_vd_vd2_rvvm1_sleef(x))); + + vdouble2_rvvm1_sleef y = ddsub_vd2_vd2_vd_rvvm1_sleef(ddsub_vd2_vd2_vd2_rvvm1_sleef(vcast_vd2_d_d_rvvm1_sleef(3.141592653589793116/4, 1.2246467991473532072e-16/4), x), u); + + vdouble_rvvm1_sleef r = vsel_vd_vo_vd_vd_rvvm1_sleef(o, vadd_vd_vd_vd_rvvm1_sleef(u, vd2getx_vd_vd2_rvvm1_sleef(x)), + vmul_vd_vd_vd_rvvm1_sleef(vadd_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(y), vd2gety_vd_vd2_rvvm1_sleef(y)), vcast_vd_d_rvvm1_sleef(2))); + return vmulsign_vd_vd_vd_rvvm1_sleef(r, d); +} + +SLEEF_INLINE SLEEF_CONST vdouble_rvvm1_sleef Sleef_acosdx_u35rvvm1(vdouble_rvvm1_sleef d) { + rvv_dp_vopmask_rvvm1_sleef o = vlt_vo_vd_vd_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(d), vcast_vd_d_rvvm1_sleef(0.5)); + vdouble_rvvm1_sleef x2 = vsel_vd_vo_vd_vd_rvvm1_sleef(o, vmul_vd_vd_vd_rvvm1_sleef(d, d), + vmul_vd_vd_vd_rvvm1_sleef(vsub_vd_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(1), vabs_vd_vd_rvvm1_sleef(d)), vcast_vd_d_rvvm1_sleef(0.5))), u; + vdouble_rvvm1_sleef x = vsel_vd_vo_vd_vd_rvvm1_sleef(o, vabs_vd_vd_rvvm1_sleef(d), vsqrt_vd_vd_rvvm1_sleef(x2)); + x = vsel_vd_vo_vd_vd_rvvm1_sleef(veq_vo_vd_vd_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(d), vcast_vd_d_rvvm1_sleef(1.0)), vcast_vd_d_rvvm1_sleef(0), x); + + vdouble_rvvm1_sleef x4 = vmul_vd_vd_vd_rvvm1_sleef(x2, x2), x8 = vmul_vd_vd_vd_rvvm1_sleef(x4, x4), x16 = vmul_vd_vd_vd_rvvm1_sleef(x8, x8); + u = vmla_vd_vd_vd_vd_rvvm1_sleef((x16), (vmla_vd_vd_vd_vd_rvvm1_sleef((x4), (vmla_vd_vd_vd_vd_rvvm1_sleef((x2), (vcast_vd_d_rvvm1_sleef(+0.3161587650653934628e-1)), (vcast_vd_d_rvvm1_sleef(-0.1581918243329996643e-1)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((x2), (vcast_vd_d_rvvm1_sleef(+0.1929045477267910674e-1)), (vcast_vd_d_rvvm1_sleef(+0.6606077476277170610e-2)))))), (vmla_vd_vd_vd_vd_rvvm1_sleef((x8), (vmla_vd_vd_vd_vd_rvvm1_sleef((x4), (vmla_vd_vd_vd_vd_rvvm1_sleef((x2), (vcast_vd_d_rvvm1_sleef(+0.1215360525577377331e-1)), (vcast_vd_d_rvvm1_sleef(+0.1388715184501609218e-1)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((x2), (vcast_vd_d_rvvm1_sleef(+0.1735956991223614604e-1)), (vcast_vd_d_rvvm1_sleef(+0.2237176181932048341e-1)))))), (vmla_vd_vd_vd_vd_rvvm1_sleef((x4), (vmla_vd_vd_vd_vd_rvvm1_sleef((x2), (vcast_vd_d_rvvm1_sleef(+0.3038195928038132237e-1)), (vcast_vd_d_rvvm1_sleef(+0.4464285681377102438e-1)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((x2), (vcast_vd_d_rvvm1_sleef(+0.7500000000378581611e-1)), (vcast_vd_d_rvvm1_sleef(+0.1666666666666497543e+0))))))))) + + ; + + u = vmul_vd_vd_vd_rvvm1_sleef(u, vmul_vd_vd_vd_rvvm1_sleef(x2, x)); + + vdouble_rvvm1_sleef y = vsub_vd_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(3.141592653589793238462643383279502884/2), vadd_vd_vd_vd_rvvm1_sleef(vmulsign_vd_vd_vd_rvvm1_sleef(x, d), vmulsign_vd_vd_vd_rvvm1_sleef(u, d))); + x = vadd_vd_vd_vd_rvvm1_sleef(x, u); + vdouble_rvvm1_sleef r = vsel_vd_vo_vd_vd_rvvm1_sleef(o, y, vmul_vd_vd_vd_rvvm1_sleef(x, vcast_vd_d_rvvm1_sleef(2))); + return vsel_vd_vo_vd_vd_rvvm1_sleef(rvv_dp_vandnot_vo_vo_vo(o, vlt_vo_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(0))), + vd2getx_vd_vd2_rvvm1_sleef(ddadd_vd2_vd2_vd_rvvm1_sleef(vcast_vd2_d_d_rvvm1_sleef(3.141592653589793116, 1.2246467991473532072e-16), + vneg_vd_vd_rvvm1_sleef(r))), r); +} + +SLEEF_INLINE SLEEF_CONST vdouble_rvvm1_sleef Sleef_acosdx_u10rvvm1(vdouble_rvvm1_sleef d) { + rvv_dp_vopmask_rvvm1_sleef o = vlt_vo_vd_vd_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(d), vcast_vd_d_rvvm1_sleef(0.5)); + vdouble_rvvm1_sleef x2 = vsel_vd_vo_vd_vd_rvvm1_sleef(o, vmul_vd_vd_vd_rvvm1_sleef(d, d), vmul_vd_vd_vd_rvvm1_sleef(vsub_vd_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(1), vabs_vd_vd_rvvm1_sleef(d)), vcast_vd_d_rvvm1_sleef(0.5))), u; + vdouble2_rvvm1_sleef x = vsel_vd2_vo_vd2_vd2_rvvm1_sleef(o, vcast_vd2_vd_vd_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(d), vcast_vd_d_rvvm1_sleef(0)), ddsqrt_vd2_vd_rvvm1_sleef(x2)); + x = vsel_vd2_vo_vd2_vd2_rvvm1_sleef(veq_vo_vd_vd_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(d), vcast_vd_d_rvvm1_sleef(1.0)), vcast_vd2_d_d_rvvm1_sleef(0, 0), x); + + vdouble_rvvm1_sleef x4 = vmul_vd_vd_vd_rvvm1_sleef(x2, x2), x8 = vmul_vd_vd_vd_rvvm1_sleef(x4, x4), x16 = vmul_vd_vd_vd_rvvm1_sleef(x8, x8); + u = vmla_vd_vd_vd_vd_rvvm1_sleef((x16), (vmla_vd_vd_vd_vd_rvvm1_sleef((x4), (vmla_vd_vd_vd_vd_rvvm1_sleef((x2), (vcast_vd_d_rvvm1_sleef(+0.3161587650653934628e-1)), (vcast_vd_d_rvvm1_sleef(-0.1581918243329996643e-1)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((x2), (vcast_vd_d_rvvm1_sleef(+0.1929045477267910674e-1)), (vcast_vd_d_rvvm1_sleef(+0.6606077476277170610e-2)))))), (vmla_vd_vd_vd_vd_rvvm1_sleef((x8), (vmla_vd_vd_vd_vd_rvvm1_sleef((x4), (vmla_vd_vd_vd_vd_rvvm1_sleef((x2), (vcast_vd_d_rvvm1_sleef(+0.1215360525577377331e-1)), (vcast_vd_d_rvvm1_sleef(+0.1388715184501609218e-1)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((x2), (vcast_vd_d_rvvm1_sleef(+0.1735956991223614604e-1)), (vcast_vd_d_rvvm1_sleef(+0.2237176181932048341e-1)))))), (vmla_vd_vd_vd_vd_rvvm1_sleef((x4), (vmla_vd_vd_vd_vd_rvvm1_sleef((x2), (vcast_vd_d_rvvm1_sleef(+0.3038195928038132237e-1)), (vcast_vd_d_rvvm1_sleef(+0.4464285681377102438e-1)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((x2), (vcast_vd_d_rvvm1_sleef(+0.7500000000378581611e-1)), (vcast_vd_d_rvvm1_sleef(+0.1666666666666497543e+0))))))))) + + ; + + u = vmul_vd_vd_vd_rvvm1_sleef(u, vmul_vd_vd_vd_rvvm1_sleef(x2, vd2getx_vd_vd2_rvvm1_sleef(x))); + + vdouble2_rvvm1_sleef y = ddsub_vd2_vd2_vd2_rvvm1_sleef(vcast_vd2_d_d_rvvm1_sleef(3.141592653589793116/2, 1.2246467991473532072e-16/2), + ddadd_vd2_vd_vd_rvvm1_sleef(vmulsign_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(x), d), vmulsign_vd_vd_vd_rvvm1_sleef(u, d))); + x = ddadd_vd2_vd2_vd_rvvm1_sleef(x, u); + + y = vsel_vd2_vo_vd2_vd2_rvvm1_sleef(o, y, ddscale_vd2_vd2_vd_rvvm1_sleef(x, vcast_vd_d_rvvm1_sleef(2))); + + y = vsel_vd2_vo_vd2_vd2_rvvm1_sleef(rvv_dp_vandnot_vo_vo_vo(o, vlt_vo_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(0))), + ddsub_vd2_vd2_vd2_rvvm1_sleef(vcast_vd2_d_d_rvvm1_sleef(3.141592653589793116, 1.2246467991473532072e-16), y), y); + + return vadd_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(y), vd2gety_vd_vd2_rvvm1_sleef(y)); +} + +SLEEF_INLINE SLEEF_CONST vdouble_rvvm1_sleef Sleef_atandx_u10rvvm1(vdouble_rvvm1_sleef d) { + vdouble2_rvvm1_sleef d2 = atan2k_u1_rvvm1_sleef(vcast_vd2_vd_vd_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(d), vcast_vd_d_rvvm1_sleef(0)), vcast_vd2_d_d_rvvm1_sleef(1, 0)); + vdouble_rvvm1_sleef r = vadd_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(d2), vd2gety_vd_vd2_rvvm1_sleef(d2)); + r = vsel_vd_vo_vd_vd_rvvm1_sleef(visinf_vo_vd_rvvm1_sleef(d), vcast_vd_d_rvvm1_sleef(1.570796326794896557998982), r); + return vmulsign_vd_vd_vd_rvvm1_sleef(r, d); +} + +SLEEF_INLINE SLEEF_CONST vdouble_rvvm1_sleef Sleef_atandx_u35rvvm1(vdouble_rvvm1_sleef s) { + vdouble_rvvm1_sleef t, u; + vint_rvvm1_sleef q; + + q = vsel_vi_vd_vi_rvvm1_sleef(s, vcast_vi_i_rvvm1_sleef(2)); + s = vabs_vd_vd_rvvm1_sleef(s); + + q = vsel_vi_vd_vd_vi_vi_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(1), s, vadd_vi_vi_vi_rvvm1_sleef(q, vcast_vi_i_rvvm1_sleef(1)), q); + s = vsel_vd_vo_vd_vd_rvvm1_sleef(vlt_vo_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(1), s), vrec_vd_vd_rvvm1_sleef(s), s); + + t = vmul_vd_vd_vd_rvvm1_sleef(s, s); + + vdouble_rvvm1_sleef t2 = vmul_vd_vd_vd_rvvm1_sleef(t, t), t4 = vmul_vd_vd_vd_rvvm1_sleef(t2, t2), t8 = vmul_vd_vd_vd_rvvm1_sleef(t4, t4), t16 = vmul_vd_vd_vd_rvvm1_sleef(t8, t8); + u = vmla_vd_vd_vd_vd_rvvm1_sleef((t16), (vmla_vd_vd_vd_vd_rvvm1_sleef((t2), (vcast_vd_d_rvvm1_sleef(-1.88796008463073496563746e-05)), (vmla_vd_vd_vd_vd_rvvm1_sleef((t), (vcast_vd_d_rvvm1_sleef(0.000209850076645816976906797)), (vcast_vd_d_rvvm1_sleef(-0.00110611831486672482563471)))))), (vmla_vd_vd_vd_vd_rvvm1_sleef((t8), (vmla_vd_vd_vd_vd_rvvm1_sleef((t4), (vmla_vd_vd_vd_vd_rvvm1_sleef((t2), (vmla_vd_vd_vd_vd_rvvm1_sleef((t), (vcast_vd_d_rvvm1_sleef(0.00370026744188713119232403)), (vcast_vd_d_rvvm1_sleef(-0.00889896195887655491740809)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((t), (vcast_vd_d_rvvm1_sleef(0.016599329773529201970117)), (vcast_vd_d_rvvm1_sleef(-0.0254517624932312641616861)))))), (vmla_vd_vd_vd_vd_rvvm1_sleef((t2), (vmla_vd_vd_vd_vd_rvvm1_sleef((t), (vcast_vd_d_rvvm1_sleef(0.0337852580001353069993897)), (vcast_vd_d_rvvm1_sleef(-0.0407629191276836500001934)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((t), (vcast_vd_d_rvvm1_sleef(0.0466667150077840625632675)), (vcast_vd_d_rvvm1_sleef(-0.0523674852303482457616113)))))))), (vmla_vd_vd_vd_vd_rvvm1_sleef((t4), (vmla_vd_vd_vd_vd_rvvm1_sleef((t2), (vmla_vd_vd_vd_vd_rvvm1_sleef((t), (vcast_vd_d_rvvm1_sleef(0.0587666392926673580854313)), (vcast_vd_d_rvvm1_sleef(-0.0666573579361080525984562)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((t), (vcast_vd_d_rvvm1_sleef(0.0769219538311769618355029)), (vcast_vd_d_rvvm1_sleef(-0.090908995008245008229153)))))), (vmla_vd_vd_vd_vd_rvvm1_sleef((t2), (vmla_vd_vd_vd_vd_rvvm1_sleef((t), (vcast_vd_d_rvvm1_sleef(0.111111105648261418443745)), (vcast_vd_d_rvvm1_sleef(-0.14285714266771329383765)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((t), (vcast_vd_d_rvvm1_sleef(0.199999999996591265594148)), (vcast_vd_d_rvvm1_sleef(-0.333333333333311110369124))))))))))) + + ; + + t = vmla_vd_vd_vd_vd_rvvm1_sleef(s, vmul_vd_vd_vd_rvvm1_sleef(t, u), s); + + t = vsel_vd_vo_vd_vd_rvvm1_sleef(vcast_vo64_vo32_rvvm1_sleef(veq_vo_vi_vi_rvvm1_sleef(vand_vi_vi_vi_rvvm1_sleef(q, vcast_vi_i_rvvm1_sleef(1)), vcast_vi_i_rvvm1_sleef(1))), vsub_vd_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(3.141592653589793238462643383279502884/2), t), t); + t = vreinterpret_vd_vm_rvvm1_sleef(vxor_vm_vm_vm_rvvm1_sleef(vand_vm_vo64_vm_rvvm1_sleef(vcast_vo64_vo32_rvvm1_sleef(veq_vo_vi_vi_rvvm1_sleef(vand_vi_vi_vi_rvvm1_sleef(q, vcast_vi_i_rvvm1_sleef(2)), vcast_vi_i_rvvm1_sleef(2))), vreinterpret_vm_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(-0.0))), vreinterpret_vm_vd_rvvm1_sleef(t))); + + return t; +} + +SLEEF_INLINE SLEEF_CONST vdouble_rvvm1_sleef Sleef_logdx_u35rvvm1(vdouble_rvvm1_sleef d) { + vdouble_rvvm1_sleef x, x2; + vdouble_rvvm1_sleef t, m; + + rvv_dp_vopmask_rvvm1_sleef o = vlt_vo_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(0x1p-1022)); + d = vsel_vd_vo_vd_vd_rvvm1_sleef(o, vmul_vd_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef((double)(INT64_C(1) << 32) * (double)(INT64_C(1) << 32))), d); + vint_rvvm1_sleef e = vilogb2k_vi_vd_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(1.0/0.75))); + m = vldexp3_vd_vd_vi_rvvm1_sleef(d, vneg_vi_vi_rvvm1_sleef(e)); + e = vsel_vi_vo_vi_vi_rvvm1_sleef(vcast_vo32_vo64_rvvm1_sleef(o), vsub_vi_vi_vi_rvvm1_sleef(e, vcast_vi_i_rvvm1_sleef(64)), e); + + x = vdiv_vd_vd_vd_rvvm1_sleef(vsub_vd_vd_vd_rvvm1_sleef(m, vcast_vd_d_rvvm1_sleef(1)), vadd_vd_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(1), m)); + x2 = vmul_vd_vd_vd_rvvm1_sleef(x, x); + + vdouble_rvvm1_sleef x4 = vmul_vd_vd_vd_rvvm1_sleef(x2, x2), x8 = vmul_vd_vd_vd_rvvm1_sleef(x4, x4), x3 = vmul_vd_vd_vd_rvvm1_sleef(x, x2); + t = vmla_vd_vd_vd_vd_rvvm1_sleef((x8), (vmla_vd_vd_vd_vd_rvvm1_sleef((x4), (vcast_vd_d_rvvm1_sleef(0.153487338491425068243146)), (vmla_vd_vd_vd_vd_rvvm1_sleef((x2), (vcast_vd_d_rvvm1_sleef(0.152519917006351951593857)), (vcast_vd_d_rvvm1_sleef(0.181863266251982985677316)))))), (vmla_vd_vd_vd_vd_rvvm1_sleef((x4), (vmla_vd_vd_vd_vd_rvvm1_sleef((x2), (vcast_vd_d_rvvm1_sleef(0.222221366518767365905163)), (vcast_vd_d_rvvm1_sleef(0.285714294746548025383248)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((x2), (vcast_vd_d_rvvm1_sleef(0.399999999950799600689777)), (vcast_vd_d_rvvm1_sleef(0.6666666666667778740063))))))) + + ; + + x = vmla_vd_vd_vd_vd_rvvm1_sleef(x, vcast_vd_d_rvvm1_sleef(2), vmul_vd_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(0.693147180559945286226764), vcast_vd_vi_rvvm1_sleef(e))); + x = vmla_vd_vd_vd_vd_rvvm1_sleef(x3, t, x); + + x = vsel_vd_vo_vd_vd_rvvm1_sleef(vispinf_vo_vd_rvvm1_sleef(d), vcast_vd_d_rvvm1_sleef(__builtin_inf()), x); + x = vsel_vd_vo_vd_vd_rvvm1_sleef(rvv_dp_vor_vo_vo_vo(vlt_vo_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(0)), visnan_vo_vd_rvvm1_sleef(d)), vcast_vd_d_rvvm1_sleef(__builtin_nan("")), x); + x = vsel_vd_vo_vd_vd_rvvm1_sleef(veq_vo_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(0)), vcast_vd_d_rvvm1_sleef(-__builtin_inf()), x); + + return x; +} + +SLEEF_INLINE SLEEF_CONST vdouble_rvvm1_sleef Sleef_expdx_u10rvvm1(vdouble_rvvm1_sleef d) { + vdouble_rvvm1_sleef u = vrint_vd_vd_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(1.442695040888963407359924681001892137426645954152985934135449406931))), s; + vint_rvvm1_sleef q = vrint_vi_vd_rvvm1_sleef(u); + + s = vmla_vd_vd_vd_vd_rvvm1_sleef(u, vcast_vd_d_rvvm1_sleef(-.69314718055966295651160180568695068359375), d); + s = vmla_vd_vd_vd_vd_rvvm1_sleef(u, vcast_vd_d_rvvm1_sleef(-.28235290563031577122588448175013436025525412068e-12), s); + + vdouble_rvvm1_sleef s2 = vmul_vd_vd_vd_rvvm1_sleef(s, s), s4 = vmul_vd_vd_vd_rvvm1_sleef(s2, s2), s8 = vmul_vd_vd_vd_rvvm1_sleef(s4, s4); + u = vmla_vd_vd_vd_vd_rvvm1_sleef((s8), (vmla_vd_vd_vd_vd_rvvm1_sleef((s), (vcast_vd_d_rvvm1_sleef(+0.2081276378237164457e-8)), (vcast_vd_d_rvvm1_sleef(+0.2511210703042288022e-7)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((s4), (vmla_vd_vd_vd_vd_rvvm1_sleef((s2), (vmla_vd_vd_vd_vd_rvvm1_sleef((s), (vcast_vd_d_rvvm1_sleef(+0.2755762628169491192e-6)), (vcast_vd_d_rvvm1_sleef(+0.2755723402025388239e-5)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((s), (vcast_vd_d_rvvm1_sleef(+0.2480158687479686264e-4)), (vcast_vd_d_rvvm1_sleef(+0.1984126989855865850e-3)))))), (vmla_vd_vd_vd_vd_rvvm1_sleef((s2), (vmla_vd_vd_vd_vd_rvvm1_sleef((s), (vcast_vd_d_rvvm1_sleef(+0.1388888888914497797e-2)), (vcast_vd_d_rvvm1_sleef(+0.8333333333314938210e-2)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((s), (vcast_vd_d_rvvm1_sleef(+0.4166666666666602598e-1)), (vcast_vd_d_rvvm1_sleef(+0.1666666666666669072e+0))))))))) + + ; + u = vfma_vd_vd_vd_vd_rvvm1_sleef(u, s, vcast_vd_d_rvvm1_sleef(+0.5000000000000000000e+0)); + u = vfma_vd_vd_vd_vd_rvvm1_sleef(u, s, vcast_vd_d_rvvm1_sleef(+0.1000000000000000000e+1)); + u = vfma_vd_vd_vd_vd_rvvm1_sleef(u, s, vcast_vd_d_rvvm1_sleef(+0.1000000000000000000e+1)); + + u = vldexp2_vd_vd_vi_rvvm1_sleef(u, q); + + u = vsel_vd_vo_vd_vd_rvvm1_sleef(vgt_vo_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(709.78271114955742909217217426)), vcast_vd_d_rvvm1_sleef(__builtin_inf()), u); + u = vreinterpret_vd_vm_rvvm1_sleef(vandnot_vm_vo64_vm_rvvm1_sleef(vlt_vo_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(-1000)), vreinterpret_vm_vd_rvvm1_sleef(u))); + + return u; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_rvvm1_sleef expm1k_rvvm1_sleef(vdouble_rvvm1_sleef d) { + vdouble_rvvm1_sleef u = vrint_vd_vd_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(1.442695040888963407359924681001892137426645954152985934135449406931))), s; + vint_rvvm1_sleef q = vrint_vi_vd_rvvm1_sleef(u); + + s = vmla_vd_vd_vd_vd_rvvm1_sleef(u, vcast_vd_d_rvvm1_sleef(-.69314718055966295651160180568695068359375), d); + s = vmla_vd_vd_vd_vd_rvvm1_sleef(u, vcast_vd_d_rvvm1_sleef(-.28235290563031577122588448175013436025525412068e-12), s); + + vdouble_rvvm1_sleef s2 = vmul_vd_vd_vd_rvvm1_sleef(s, s), s4 = vmul_vd_vd_vd_rvvm1_sleef(s2, s2), s8 = vmul_vd_vd_vd_rvvm1_sleef(s4, s4); + u = vmla_vd_vd_vd_vd_rvvm1_sleef((s8), (vmla_vd_vd_vd_vd_rvvm1_sleef((s), (vcast_vd_d_rvvm1_sleef(2.08860621107283687536341e-09)), (vcast_vd_d_rvvm1_sleef(2.51112930892876518610661e-08)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((s4), (vmla_vd_vd_vd_vd_rvvm1_sleef((s2), (vmla_vd_vd_vd_vd_rvvm1_sleef((s), (vcast_vd_d_rvvm1_sleef(2.75573911234900471893338e-07)), (vcast_vd_d_rvvm1_sleef(2.75572362911928827629423e-06)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((s), (vcast_vd_d_rvvm1_sleef(2.4801587159235472998791e-05)), (vcast_vd_d_rvvm1_sleef(0.000198412698960509205564975)))))), (vmla_vd_vd_vd_vd_rvvm1_sleef((s2), (vmla_vd_vd_vd_vd_rvvm1_sleef((s), (vcast_vd_d_rvvm1_sleef(0.00138888888889774492207962)), (vcast_vd_d_rvvm1_sleef(0.00833333333331652721664984)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((s), (vcast_vd_d_rvvm1_sleef(0.0416666666666665047591422)), (vcast_vd_d_rvvm1_sleef(0.166666666666666851703837))))))))) + + ; + + u = vadd_vd_vd_vd_rvvm1_sleef(vmla_vd_vd_vd_vd_rvvm1_sleef(s2, vcast_vd_d_rvvm1_sleef(0.5), vmul_vd_vd_vd_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(s2, s), u)), s); + + u = vsel_vd_vo_vd_vd_rvvm1_sleef(vcast_vo64_vo32_rvvm1_sleef(veq_vo_vi_vi_rvvm1_sleef(q, vcast_vi_i_rvvm1_sleef(0))), u, + vsub_vd_vd_vd_rvvm1_sleef(vldexp2_vd_vd_vi_rvvm1_sleef(vadd_vd_vd_vd_rvvm1_sleef(u, vcast_vd_d_rvvm1_sleef(1)), q), vcast_vd_d_rvvm1_sleef(1))); + + return u; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_rvvm1_sleef logk_rvvm1_sleef(vdouble_rvvm1_sleef d) { + vdouble2_rvvm1_sleef x, x2, s; + vdouble_rvvm1_sleef t, m; + + rvv_dp_vopmask_rvvm1_sleef o = vlt_vo_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(0x1p-1022)); + d = vsel_vd_vo_vd_vd_rvvm1_sleef(o, vmul_vd_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef((double)(INT64_C(1) << 32) * (double)(INT64_C(1) << 32))), d); + vint_rvvm1_sleef e = vilogb2k_vi_vd_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(1.0/0.75))); + m = vldexp3_vd_vd_vi_rvvm1_sleef(d, vneg_vi_vi_rvvm1_sleef(e)); + e = vsel_vi_vo_vi_vi_rvvm1_sleef(vcast_vo32_vo64_rvvm1_sleef(o), vsub_vi_vi_vi_rvvm1_sleef(e, vcast_vi_i_rvvm1_sleef(64)), e); + + x = dddiv_vd2_vd2_vd2_rvvm1_sleef(ddadd2_vd2_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(-1), m), ddadd2_vd2_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(1), m)); + x2 = ddsqu_vd2_vd2_rvvm1_sleef(x); + + vdouble_rvvm1_sleef x4 = vmul_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(x2), vd2getx_vd_vd2_rvvm1_sleef(x2)), x8 = vmul_vd_vd_vd_rvvm1_sleef(x4, x4), x16 = vmul_vd_vd_vd_rvvm1_sleef(x8, x8); + t = vmla_vd_vd_vd_vd_rvvm1_sleef((x16), (vcast_vd_d_rvvm1_sleef(0.116255524079935043668677)), (vmla_vd_vd_vd_vd_rvvm1_sleef((x8), (vmla_vd_vd_vd_vd_rvvm1_sleef((x4), (vmla_vd_vd_vd_vd_rvvm1_sleef((vd2getx_vd_vd2_rvvm1_sleef(x2)), (vcast_vd_d_rvvm1_sleef(0.103239680901072952701192)), (vcast_vd_d_rvvm1_sleef(0.117754809412463995466069)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((vd2getx_vd_vd2_rvvm1_sleef(x2)), (vcast_vd_d_rvvm1_sleef(0.13332981086846273921509)), (vcast_vd_d_rvvm1_sleef(0.153846227114512262845736)))))), (vmla_vd_vd_vd_vd_rvvm1_sleef((x4), (vmla_vd_vd_vd_vd_rvvm1_sleef((vd2getx_vd_vd2_rvvm1_sleef(x2)), (vcast_vd_d_rvvm1_sleef(0.181818180850050775676507)), (vcast_vd_d_rvvm1_sleef(0.222222222230083560345903)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((vd2getx_vd_vd2_rvvm1_sleef(x2)), (vcast_vd_d_rvvm1_sleef(0.285714285714249172087875)), (vcast_vd_d_rvvm1_sleef(0.400000000000000077715612))))))))) + + ; + + vdouble2_rvvm1_sleef c = vcast_vd2_d_d_rvvm1_sleef(0.666666666666666629659233, 3.80554962542412056336616e-17); + + s = ddmul_vd2_vd2_vd_rvvm1_sleef(vcast_vd2_d_d_rvvm1_sleef(0.693147180559945286226764, 2.319046813846299558417771e-17), vcast_vd_vi_rvvm1_sleef(e)); + + s = ddadd_vd2_vd2_vd2_rvvm1_sleef(s, ddscale_vd2_vd2_vd_rvvm1_sleef(x, vcast_vd_d_rvvm1_sleef(2))); + x = ddmul_vd2_vd2_vd2_rvvm1_sleef(x2, x); + s = ddadd_vd2_vd2_vd2_rvvm1_sleef(s, ddmul_vd2_vd2_vd2_rvvm1_sleef(x, c)); + x = ddmul_vd2_vd2_vd2_rvvm1_sleef(x2, x); + s = ddadd_vd2_vd2_vd2_rvvm1_sleef(s, ddmul_vd2_vd2_vd_rvvm1_sleef(x, t)); + + return s; +} + +SLEEF_INLINE SLEEF_CONST vdouble_rvvm1_sleef Sleef_logdx_u10rvvm1(vdouble_rvvm1_sleef d) { + vdouble2_rvvm1_sleef x; + vdouble_rvvm1_sleef t, m, x2; + + rvv_dp_vopmask_rvvm1_sleef o = vlt_vo_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(0x1p-1022)); + d = vsel_vd_vo_vd_vd_rvvm1_sleef(o, vmul_vd_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef((double)(INT64_C(1) << 32) * (double)(INT64_C(1) << 32))), d); + vint_rvvm1_sleef e = vilogb2k_vi_vd_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(1.0/0.75))); + m = vldexp3_vd_vd_vi_rvvm1_sleef(d, vneg_vi_vi_rvvm1_sleef(e)); + e = vsel_vi_vo_vi_vi_rvvm1_sleef(vcast_vo32_vo64_rvvm1_sleef(o), vsub_vi_vi_vi_rvvm1_sleef(e, vcast_vi_i_rvvm1_sleef(64)), e); + + x = dddiv_vd2_vd2_vd2_rvvm1_sleef(ddadd2_vd2_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(-1), m), ddadd2_vd2_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(1), m)); + x2 = vmul_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(x), vd2getx_vd_vd2_rvvm1_sleef(x)); + + vdouble_rvvm1_sleef x4 = vmul_vd_vd_vd_rvvm1_sleef(x2, x2), x8 = vmul_vd_vd_vd_rvvm1_sleef(x4, x4); + t = vmla_vd_vd_vd_vd_rvvm1_sleef((x8), (vmla_vd_vd_vd_vd_rvvm1_sleef((x4), (vcast_vd_d_rvvm1_sleef(0.1532076988502701353e+0)), (vmla_vd_vd_vd_vd_rvvm1_sleef((x2), (vcast_vd_d_rvvm1_sleef(0.1525629051003428716e+0)), (vcast_vd_d_rvvm1_sleef(0.1818605932937785996e+0)))))), (vmla_vd_vd_vd_vd_rvvm1_sleef((x4), (vmla_vd_vd_vd_vd_rvvm1_sleef((x2), (vcast_vd_d_rvvm1_sleef(0.2222214519839380009e+0)), (vcast_vd_d_rvvm1_sleef(0.2857142932794299317e+0)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((x2), (vcast_vd_d_rvvm1_sleef(0.3999999999635251990e+0)), (vcast_vd_d_rvvm1_sleef(0.6666666666667333541e+0))))))) + + ; + + vdouble2_rvvm1_sleef s = ddmul_vd2_vd2_vd_rvvm1_sleef(vcast_vd2_d_d_rvvm1_sleef(0.693147180559945286226764, 2.319046813846299558417771e-17), vcast_vd_vi_rvvm1_sleef(e)); + + s = ddadd_vd2_vd2_vd2_rvvm1_sleef(s, ddscale_vd2_vd2_vd_rvvm1_sleef(x, vcast_vd_d_rvvm1_sleef(2))); + s = ddadd_vd2_vd2_vd_rvvm1_sleef(s, vmul_vd_vd_vd_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(x2, vd2getx_vd_vd2_rvvm1_sleef(x)), t)); + + vdouble_rvvm1_sleef r = vadd_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(s), vd2gety_vd_vd2_rvvm1_sleef(s)); + + r = vsel_vd_vo_vd_vd_rvvm1_sleef(vispinf_vo_vd_rvvm1_sleef(d), vcast_vd_d_rvvm1_sleef(__builtin_inf()), r); + r = vsel_vd_vo_vd_vd_rvvm1_sleef(rvv_dp_vor_vo_vo_vo(vlt_vo_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(0)), visnan_vo_vd_rvvm1_sleef(d)), vcast_vd_d_rvvm1_sleef(__builtin_nan("")), r); + r = vsel_vd_vo_vd_vd_rvvm1_sleef(veq_vo_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(0)), vcast_vd_d_rvvm1_sleef(-__builtin_inf()), r); + + return r; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_rvvm1_sleef expk_rvvm1_sleef(vdouble2_rvvm1_sleef d) { + vdouble_rvvm1_sleef u = vmul_vd_vd_vd_rvvm1_sleef(vadd_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(d), vd2gety_vd_vd2_rvvm1_sleef(d)), vcast_vd_d_rvvm1_sleef(1.442695040888963407359924681001892137426645954152985934135449406931)); + vdouble_rvvm1_sleef dq = vrint_vd_vd_rvvm1_sleef(u); + vint_rvvm1_sleef q = vrint_vi_vd_rvvm1_sleef(dq); + vdouble2_rvvm1_sleef s, t; + + s = ddadd2_vd2_vd2_vd_rvvm1_sleef(d, vmul_vd_vd_vd_rvvm1_sleef(dq, vcast_vd_d_rvvm1_sleef(-.69314718055966295651160180568695068359375))); + s = ddadd2_vd2_vd2_vd_rvvm1_sleef(s, vmul_vd_vd_vd_rvvm1_sleef(dq, vcast_vd_d_rvvm1_sleef(-.28235290563031577122588448175013436025525412068e-12))); + + s = ddnormalize_vd2_vd2_rvvm1_sleef(s); + + vdouble_rvvm1_sleef s2 = vmul_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(s), vd2getx_vd_vd2_rvvm1_sleef(s)), s4 = vmul_vd_vd_vd_rvvm1_sleef(s2, s2), s8 = vmul_vd_vd_vd_rvvm1_sleef(s4, s4); + u = vmla_vd_vd_vd_vd_rvvm1_sleef((s8), (vmla_vd_vd_vd_vd_rvvm1_sleef((vd2getx_vd_vd2_rvvm1_sleef(s)), (vcast_vd_d_rvvm1_sleef(2.51069683420950419527139e-08)), (vcast_vd_d_rvvm1_sleef(2.76286166770270649116855e-07)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((s4), (vmla_vd_vd_vd_vd_rvvm1_sleef((s2), (vmla_vd_vd_vd_vd_rvvm1_sleef((vd2getx_vd_vd2_rvvm1_sleef(s)), (vcast_vd_d_rvvm1_sleef(2.75572496725023574143864e-06)), (vcast_vd_d_rvvm1_sleef(2.48014973989819794114153e-05)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((vd2getx_vd_vd2_rvvm1_sleef(s)), (vcast_vd_d_rvvm1_sleef(0.000198412698809069797676111)), (vcast_vd_d_rvvm1_sleef(0.0013888888939977128960529)))))), (vmla_vd_vd_vd_vd_rvvm1_sleef((s2), (vmla_vd_vd_vd_vd_rvvm1_sleef((vd2getx_vd_vd2_rvvm1_sleef(s)), (vcast_vd_d_rvvm1_sleef(0.00833333333332371417601081)), (vcast_vd_d_rvvm1_sleef(0.0416666666665409524128449)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((vd2getx_vd_vd2_rvvm1_sleef(s)), (vcast_vd_d_rvvm1_sleef(0.166666666666666740681535)), (vcast_vd_d_rvvm1_sleef(0.500000000000000999200722))))))))) + + ; + + t = ddadd_vd2_vd_vd2_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(1), s); + t = ddadd_vd2_vd2_vd2_rvvm1_sleef(t, ddmul_vd2_vd2_vd_rvvm1_sleef(ddsqu_vd2_vd2_rvvm1_sleef(s), u)); + + u = vadd_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(t), vd2gety_vd_vd2_rvvm1_sleef(t)); + u = vldexp2_vd_vd_vi_rvvm1_sleef(u, q); + + u = vreinterpret_vd_vm_rvvm1_sleef(vandnot_vm_vo64_vm_rvvm1_sleef(vlt_vo_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(d), vcast_vd_d_rvvm1_sleef(-1000)), vreinterpret_vm_vd_rvvm1_sleef(u))); + + return u; +} + +SLEEF_INLINE SLEEF_CONST vdouble_rvvm1_sleef Sleef_powdx_u10rvvm1(vdouble_rvvm1_sleef x, vdouble_rvvm1_sleef y) { + + rvv_dp_vopmask_rvvm1_sleef yisint = visint_vo_vd_rvvm1_sleef(y); + rvv_dp_vopmask_rvvm1_sleef yisodd = rvv_dp_vand_vo_vo_vo(visodd_vo_vd_rvvm1_sleef(y), yisint); + + vdouble2_rvvm1_sleef d = ddmul_vd2_vd2_vd_rvvm1_sleef(logk_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(x)), y); + vdouble_rvvm1_sleef result = expk_rvvm1_sleef(d); + result = vsel_vd_vo_vd_vd_rvvm1_sleef(vgt_vo_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(d), vcast_vd_d_rvvm1_sleef(709.78271114955742909217217426)), vcast_vd_d_rvvm1_sleef(__builtin_inf()), result); + + result = vmul_vd_vd_vd_rvvm1_sleef(result, + vsel_vd_vo_vd_vd_rvvm1_sleef(vgt_vo_vd_vd_rvvm1_sleef(x, vcast_vd_d_rvvm1_sleef(0)), + vcast_vd_d_rvvm1_sleef(1), + vsel_vd_vo_vd_vd_rvvm1_sleef(yisint, vsel_vd_vo_vd_vd_rvvm1_sleef(yisodd, vcast_vd_d_rvvm1_sleef(-1.0), vcast_vd_d_rvvm1_sleef(1)), vcast_vd_d_rvvm1_sleef(__builtin_nan(""))))); + + vdouble_rvvm1_sleef efx = vmulsign_vd_vd_vd_rvvm1_sleef(vsub_vd_vd_vd_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(x), vcast_vd_d_rvvm1_sleef(1)), y); + + result = vsel_vd_vo_vd_vd_rvvm1_sleef(visinf_vo_vd_rvvm1_sleef(y), + vreinterpret_vd_vm_rvvm1_sleef(vandnot_vm_vo64_vm_rvvm1_sleef(vlt_vo_vd_vd_rvvm1_sleef(efx, vcast_vd_d_rvvm1_sleef(0.0)), + vreinterpret_vm_vd_rvvm1_sleef(vsel_vd_vo_vd_vd_rvvm1_sleef(veq_vo_vd_vd_rvvm1_sleef(efx, vcast_vd_d_rvvm1_sleef(0.0)), + vcast_vd_d_rvvm1_sleef(1.0), + vcast_vd_d_rvvm1_sleef(__builtin_inf()))))), + result); + + result = vsel_vd_vo_vd_vd_rvvm1_sleef(rvv_dp_vor_vo_vo_vo(visinf_vo_vd_rvvm1_sleef(x), veq_vo_vd_vd_rvvm1_sleef(x, vcast_vd_d_rvvm1_sleef(0.0))), + vmulsign_vd_vd_vd_rvvm1_sleef(vsel_vd_vo_vd_vd_rvvm1_sleef(rvv_dp_vxor_vo_vo_vo(vsignbit_vo_vd_rvvm1_sleef(y), veq_vo_vd_vd_rvvm1_sleef(x, vcast_vd_d_rvvm1_sleef(0.0))), + vcast_vd_d_rvvm1_sleef(0), vcast_vd_d_rvvm1_sleef(__builtin_inf())), + vsel_vd_vo_vd_vd_rvvm1_sleef(yisodd, x, vcast_vd_d_rvvm1_sleef(1))), result); + + result = vreinterpret_vd_vm_rvvm1_sleef(vor_vm_vo64_vm_rvvm1_sleef(rvv_dp_vor_vo_vo_vo(visnan_vo_vd_rvvm1_sleef(x), visnan_vo_vd_rvvm1_sleef(y)), vreinterpret_vm_vd_rvvm1_sleef(result))); + + result = vsel_vd_vo_vd_vd_rvvm1_sleef(rvv_dp_vor_vo_vo_vo(veq_vo_vd_vd_rvvm1_sleef(y, vcast_vd_d_rvvm1_sleef(0)), veq_vo_vd_vd_rvvm1_sleef(x, vcast_vd_d_rvvm1_sleef(1))), vcast_vd_d_rvvm1_sleef(1), result); + + return result; + +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_rvvm1_sleef expk2_rvvm1_sleef(vdouble2_rvvm1_sleef d) { + vdouble_rvvm1_sleef u = vmul_vd_vd_vd_rvvm1_sleef(vadd_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(d), vd2gety_vd_vd2_rvvm1_sleef(d)), vcast_vd_d_rvvm1_sleef(1.442695040888963407359924681001892137426645954152985934135449406931)); + vdouble_rvvm1_sleef dq = vrint_vd_vd_rvvm1_sleef(u); + vint_rvvm1_sleef q = vrint_vi_vd_rvvm1_sleef(dq); + vdouble2_rvvm1_sleef s, t; + + s = ddadd2_vd2_vd2_vd_rvvm1_sleef(d, vmul_vd_vd_vd_rvvm1_sleef(dq, vcast_vd_d_rvvm1_sleef(-.69314718055966295651160180568695068359375))); + s = ddadd2_vd2_vd2_vd_rvvm1_sleef(s, vmul_vd_vd_vd_rvvm1_sleef(dq, vcast_vd_d_rvvm1_sleef(-.28235290563031577122588448175013436025525412068e-12))); + + vdouble2_rvvm1_sleef s2 = ddsqu_vd2_vd2_rvvm1_sleef(s), s4 = ddsqu_vd2_vd2_rvvm1_sleef(s2); + vdouble_rvvm1_sleef s8 = vmul_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(s4), vd2getx_vd_vd2_rvvm1_sleef(s4)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef((s8), (vmla_vd_vd_vd_vd_rvvm1_sleef((vd2getx_vd_vd2_rvvm1_sleef(s)), (vcast_vd_d_rvvm1_sleef(+0.1602472219709932072e-9)), (vcast_vd_d_rvvm1_sleef(+0.2092255183563157007e-8)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((vd2getx_vd_vd2_rvvm1_sleef(s4)), (vmla_vd_vd_vd_vd_rvvm1_sleef((vd2getx_vd_vd2_rvvm1_sleef(s2)), (vmla_vd_vd_vd_vd_rvvm1_sleef((vd2getx_vd_vd2_rvvm1_sleef(s)), (vcast_vd_d_rvvm1_sleef(+0.2505230023782644465e-7)), (vcast_vd_d_rvvm1_sleef(+0.2755724800902135303e-6)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((vd2getx_vd_vd2_rvvm1_sleef(s)), (vcast_vd_d_rvvm1_sleef(+0.2755731892386044373e-5)), (vcast_vd_d_rvvm1_sleef(+0.2480158735605815065e-4)))))), (vmla_vd_vd_vd_vd_rvvm1_sleef((vd2getx_vd_vd2_rvvm1_sleef(s2)), (vmla_vd_vd_vd_vd_rvvm1_sleef((vd2getx_vd_vd2_rvvm1_sleef(s)), (vcast_vd_d_rvvm1_sleef(+0.1984126984148071858e-3)), (vcast_vd_d_rvvm1_sleef(+0.1388888888886763255e-2)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((vd2getx_vd_vd2_rvvm1_sleef(s)), (vcast_vd_d_rvvm1_sleef(+0.8333333333333347095e-2)), (vcast_vd_d_rvvm1_sleef(+0.4166666666666669905e-1))))))))) + + ; + + t = ddadd_vd2_vd_vd2_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(0.5), ddmul_vd2_vd2_vd_rvvm1_sleef(s, vcast_vd_d_rvvm1_sleef(+0.1666666666666666574e+0))); + t = ddadd_vd2_vd_vd2_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(1.0), ddmul_vd2_vd2_vd2_rvvm1_sleef(t, s)); + t = ddadd_vd2_vd_vd2_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(1.0), ddmul_vd2_vd2_vd2_rvvm1_sleef(t, s)); + t = ddadd_vd2_vd2_vd2_rvvm1_sleef(t, ddmul_vd2_vd2_vd_rvvm1_sleef(s4, u)); + + t = vd2setx_vd2_vd2_vd_rvvm1_sleef(t, vldexp2_vd_vd_vi_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(t), q)); + t = vd2sety_vd2_vd2_vd_rvvm1_sleef(t, vldexp2_vd_vd_vi_rvvm1_sleef(vd2gety_vd_vd2_rvvm1_sleef(t), q)); + + t = vd2setx_vd2_vd2_vd_rvvm1_sleef(t, vreinterpret_vd_vm_rvvm1_sleef(vandnot_vm_vo64_vm_rvvm1_sleef(vlt_vo_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(d), vcast_vd_d_rvvm1_sleef(-1000)), vreinterpret_vm_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(t))))); + t = vd2sety_vd2_vd2_vd_rvvm1_sleef(t, vreinterpret_vd_vm_rvvm1_sleef(vandnot_vm_vo64_vm_rvvm1_sleef(vlt_vo_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(d), vcast_vd_d_rvvm1_sleef(-1000)), vreinterpret_vm_vd_rvvm1_sleef(vd2gety_vd_vd2_rvvm1_sleef(t))))); + + return t; +} + +SLEEF_INLINE SLEEF_CONST vdouble_rvvm1_sleef Sleef_sinhdx_u10rvvm1(vdouble_rvvm1_sleef x) { + vdouble_rvvm1_sleef y = vabs_vd_vd_rvvm1_sleef(x); + vdouble2_rvvm1_sleef d = expk2_rvvm1_sleef(vcast_vd2_vd_vd_rvvm1_sleef(y, vcast_vd_d_rvvm1_sleef(0))); + d = ddsub_vd2_vd2_vd2_rvvm1_sleef(d, ddrec_vd2_vd2_rvvm1_sleef(d)); + y = vmul_vd_vd_vd_rvvm1_sleef(vadd_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(d), vd2gety_vd_vd2_rvvm1_sleef(d)), vcast_vd_d_rvvm1_sleef(0.5)); + + y = vsel_vd_vo_vd_vd_rvvm1_sleef(rvv_dp_vor_vo_vo_vo(vgt_vo_vd_vd_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(x), vcast_vd_d_rvvm1_sleef(710)), visnan_vo_vd_rvvm1_sleef(y)), vcast_vd_d_rvvm1_sleef(__builtin_inf()), y); + y = vmulsign_vd_vd_vd_rvvm1_sleef(y, x); + y = vreinterpret_vd_vm_rvvm1_sleef(vor_vm_vo64_vm_rvvm1_sleef(visnan_vo_vd_rvvm1_sleef(x), vreinterpret_vm_vd_rvvm1_sleef(y))); + + return y; +} + +SLEEF_INLINE SLEEF_CONST vdouble_rvvm1_sleef Sleef_coshdx_u10rvvm1(vdouble_rvvm1_sleef x) { + vdouble_rvvm1_sleef y = vabs_vd_vd_rvvm1_sleef(x); + vdouble2_rvvm1_sleef d = expk2_rvvm1_sleef(vcast_vd2_vd_vd_rvvm1_sleef(y, vcast_vd_d_rvvm1_sleef(0))); + d = ddadd_vd2_vd2_vd2_rvvm1_sleef(d, ddrec_vd2_vd2_rvvm1_sleef(d)); + y = vmul_vd_vd_vd_rvvm1_sleef(vadd_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(d), vd2gety_vd_vd2_rvvm1_sleef(d)), vcast_vd_d_rvvm1_sleef(0.5)); + + y = vsel_vd_vo_vd_vd_rvvm1_sleef(rvv_dp_vor_vo_vo_vo(vgt_vo_vd_vd_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(x), vcast_vd_d_rvvm1_sleef(710)), visnan_vo_vd_rvvm1_sleef(y)), vcast_vd_d_rvvm1_sleef(__builtin_inf()), y); + y = vreinterpret_vd_vm_rvvm1_sleef(vor_vm_vo64_vm_rvvm1_sleef(visnan_vo_vd_rvvm1_sleef(x), vreinterpret_vm_vd_rvvm1_sleef(y))); + + return y; +} + +SLEEF_INLINE SLEEF_CONST vdouble_rvvm1_sleef Sleef_tanhdx_u10rvvm1(vdouble_rvvm1_sleef x) { + vdouble_rvvm1_sleef y = vabs_vd_vd_rvvm1_sleef(x); + vdouble2_rvvm1_sleef d = expk2_rvvm1_sleef(vcast_vd2_vd_vd_rvvm1_sleef(y, vcast_vd_d_rvvm1_sleef(0))); + vdouble2_rvvm1_sleef e = ddrec_vd2_vd2_rvvm1_sleef(d); + d = dddiv_vd2_vd2_vd2_rvvm1_sleef(ddadd2_vd2_vd2_vd2_rvvm1_sleef(d, ddneg_vd2_vd2_rvvm1_sleef(e)), ddadd2_vd2_vd2_vd2_rvvm1_sleef(d, e)); + y = vadd_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(d), vd2gety_vd_vd2_rvvm1_sleef(d)); + + y = vsel_vd_vo_vd_vd_rvvm1_sleef(rvv_dp_vor_vo_vo_vo(vgt_vo_vd_vd_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(x), vcast_vd_d_rvvm1_sleef(18.714973875)), visnan_vo_vd_rvvm1_sleef(y)), vcast_vd_d_rvvm1_sleef(1.0), y); + y = vmulsign_vd_vd_vd_rvvm1_sleef(y, x); + y = vreinterpret_vd_vm_rvvm1_sleef(vor_vm_vo64_vm_rvvm1_sleef(visnan_vo_vd_rvvm1_sleef(x), vreinterpret_vm_vd_rvvm1_sleef(y))); + + return y; +} + +SLEEF_INLINE SLEEF_CONST vdouble_rvvm1_sleef Sleef_sinhdx_u35rvvm1(vdouble_rvvm1_sleef x) { + vdouble_rvvm1_sleef e = expm1k_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(x)); + + vdouble_rvvm1_sleef y = vdiv_vd_vd_vd_rvvm1_sleef(vadd_vd_vd_vd_rvvm1_sleef(e, vcast_vd_d_rvvm1_sleef(2)), vadd_vd_vd_vd_rvvm1_sleef(e, vcast_vd_d_rvvm1_sleef(1))); + y = vmul_vd_vd_vd_rvvm1_sleef(y, vmul_vd_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(0.5), e)); + + y = vsel_vd_vo_vd_vd_rvvm1_sleef(rvv_dp_vor_vo_vo_vo(vgt_vo_vd_vd_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(x), vcast_vd_d_rvvm1_sleef(709)), visnan_vo_vd_rvvm1_sleef(y)), vcast_vd_d_rvvm1_sleef(__builtin_inf()), y); + y = vmulsign_vd_vd_vd_rvvm1_sleef(y, x); + y = vreinterpret_vd_vm_rvvm1_sleef(vor_vm_vo64_vm_rvvm1_sleef(visnan_vo_vd_rvvm1_sleef(x), vreinterpret_vm_vd_rvvm1_sleef(y))); + + return y; +} + +SLEEF_INLINE SLEEF_CONST vdouble_rvvm1_sleef Sleef_coshdx_u35rvvm1(vdouble_rvvm1_sleef x) { + vdouble_rvvm1_sleef e = Sleef_expdx_u10rvvm1(vabs_vd_vd_rvvm1_sleef(x)); + vdouble_rvvm1_sleef y = vmla_vd_vd_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(0.5), e, vdiv_vd_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(0.5), e)); + + y = vsel_vd_vo_vd_vd_rvvm1_sleef(rvv_dp_vor_vo_vo_vo(vgt_vo_vd_vd_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(x), vcast_vd_d_rvvm1_sleef(709)), visnan_vo_vd_rvvm1_sleef(y)), vcast_vd_d_rvvm1_sleef(__builtin_inf()), y); + y = vreinterpret_vd_vm_rvvm1_sleef(vor_vm_vo64_vm_rvvm1_sleef(visnan_vo_vd_rvvm1_sleef(x), vreinterpret_vm_vd_rvvm1_sleef(y))); + + return y; +} + +SLEEF_INLINE SLEEF_CONST vdouble_rvvm1_sleef Sleef_tanhdx_u35rvvm1(vdouble_rvvm1_sleef x) { + vdouble_rvvm1_sleef d = expm1k_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(2), vabs_vd_vd_rvvm1_sleef(x))); + vdouble_rvvm1_sleef y = vdiv_vd_vd_vd_rvvm1_sleef(d, vadd_vd_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(2), d)); + + y = vsel_vd_vo_vd_vd_rvvm1_sleef(rvv_dp_vor_vo_vo_vo(vgt_vo_vd_vd_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(x), vcast_vd_d_rvvm1_sleef(18.714973875)), visnan_vo_vd_rvvm1_sleef(y)), vcast_vd_d_rvvm1_sleef(1.0), y); + y = vmulsign_vd_vd_vd_rvvm1_sleef(y, x); + y = vreinterpret_vd_vm_rvvm1_sleef(vor_vm_vo64_vm_rvvm1_sleef(visnan_vo_vd_rvvm1_sleef(x), vreinterpret_vm_vd_rvvm1_sleef(y))); + + return y; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_rvvm1_sleef logk2_rvvm1_sleef(vdouble2_rvvm1_sleef d) { + vdouble2_rvvm1_sleef x, x2, m, s; + vdouble_rvvm1_sleef t; + vint_rvvm1_sleef e; + + e = vilogbk_vi_vd_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(d), vcast_vd_d_rvvm1_sleef(1.0/0.75))); + + m = vd2setxy_vd2_vd_vd_rvvm1_sleef(vldexp2_vd_vd_vi_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(d), vneg_vi_vi_rvvm1_sleef(e)), + vldexp2_vd_vd_vi_rvvm1_sleef(vd2gety_vd_vd2_rvvm1_sleef(d), vneg_vi_vi_rvvm1_sleef(e))); + + x = dddiv_vd2_vd2_vd2_rvvm1_sleef(ddadd2_vd2_vd2_vd_rvvm1_sleef(m, vcast_vd_d_rvvm1_sleef(-1)), ddadd2_vd2_vd2_vd_rvvm1_sleef(m, vcast_vd_d_rvvm1_sleef(1))); + x2 = ddsqu_vd2_vd2_rvvm1_sleef(x); + + vdouble_rvvm1_sleef x4 = vmul_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(x2), vd2getx_vd_vd2_rvvm1_sleef(x2)), x8 = vmul_vd_vd_vd_rvvm1_sleef(x4, x4); + t = vmla_vd_vd_vd_vd_rvvm1_sleef((x8), (vmla_vd_vd_vd_vd_rvvm1_sleef((x4), (vcast_vd_d_rvvm1_sleef(0.13860436390467167910856)), (vmla_vd_vd_vd_vd_rvvm1_sleef((vd2getx_vd_vd2_rvvm1_sleef(x2)), (vcast_vd_d_rvvm1_sleef(0.131699838841615374240845)), (vcast_vd_d_rvvm1_sleef(0.153914168346271945653214)))))), (vmla_vd_vd_vd_vd_rvvm1_sleef((x4), (vmla_vd_vd_vd_vd_rvvm1_sleef((vd2getx_vd_vd2_rvvm1_sleef(x2)), (vcast_vd_d_rvvm1_sleef(0.181816523941564611721589)), (vcast_vd_d_rvvm1_sleef(0.22222224632662035403996)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((vd2getx_vd_vd2_rvvm1_sleef(x2)), (vcast_vd_d_rvvm1_sleef(0.285714285511134091777308)), (vcast_vd_d_rvvm1_sleef(0.400000000000914013309483))))))) + + ; + t = vmla_vd_vd_vd_vd_rvvm1_sleef(t, vd2getx_vd_vd2_rvvm1_sleef(x2), vcast_vd_d_rvvm1_sleef(0.666666666666664853302393)); + + s = ddmul_vd2_vd2_vd_rvvm1_sleef(vcast_vd2_d_d_rvvm1_sleef(0.693147180559945286226764, 2.319046813846299558417771e-17), vcast_vd_vi_rvvm1_sleef(e)); + s = ddadd_vd2_vd2_vd2_rvvm1_sleef(s, ddscale_vd2_vd2_vd_rvvm1_sleef(x, vcast_vd_d_rvvm1_sleef(2))); + s = ddadd_vd2_vd2_vd2_rvvm1_sleef(s, ddmul_vd2_vd2_vd_rvvm1_sleef(ddmul_vd2_vd2_vd2_rvvm1_sleef(x2, x), t)); + + return s; +} + +SLEEF_INLINE SLEEF_CONST vdouble_rvvm1_sleef Sleef_asinhdx_u10rvvm1(vdouble_rvvm1_sleef x) { + vdouble_rvvm1_sleef y = vabs_vd_vd_rvvm1_sleef(x); + rvv_dp_vopmask_rvvm1_sleef o = vgt_vo_vd_vd_rvvm1_sleef(y, vcast_vd_d_rvvm1_sleef(1)); + vdouble2_rvvm1_sleef d; + + d = vsel_vd2_vo_vd2_vd2_rvvm1_sleef(o, ddrec_vd2_vd_rvvm1_sleef(x), vcast_vd2_vd_vd_rvvm1_sleef(y, vcast_vd_d_rvvm1_sleef(0))); + d = ddsqrt_vd2_vd2_rvvm1_sleef(ddadd2_vd2_vd2_vd_rvvm1_sleef(ddsqu_vd2_vd2_rvvm1_sleef(d), vcast_vd_d_rvvm1_sleef(1))); + d = vsel_vd2_vo_vd2_vd2_rvvm1_sleef(o, ddmul_vd2_vd2_vd_rvvm1_sleef(d, y), d); + + d = logk2_rvvm1_sleef(ddnormalize_vd2_vd2_rvvm1_sleef(ddadd2_vd2_vd2_vd_rvvm1_sleef(d, x))); + y = vadd_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(d), vd2gety_vd_vd2_rvvm1_sleef(d)); + + y = vsel_vd_vo_vd_vd_rvvm1_sleef(rvv_dp_vor_vo_vo_vo(vgt_vo_vd_vd_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(x), vcast_vd_d_rvvm1_sleef(1.3407807929942596355e+154)), + visnan_vo_vd_rvvm1_sleef(y)), + vmulsign_vd_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(__builtin_inf()), x), y); + + y = vreinterpret_vd_vm_rvvm1_sleef(vor_vm_vo64_vm_rvvm1_sleef(visnan_vo_vd_rvvm1_sleef(x), vreinterpret_vm_vd_rvvm1_sleef(y))); + y = vsel_vd_vo_vd_vd_rvvm1_sleef(visnegzero_vo_vd_rvvm1_sleef(x), vcast_vd_d_rvvm1_sleef(-0.0), y); + + return y; +} + +SLEEF_INLINE SLEEF_CONST vdouble_rvvm1_sleef Sleef_acoshdx_u10rvvm1(vdouble_rvvm1_sleef x) { + vdouble2_rvvm1_sleef d = logk2_rvvm1_sleef(ddadd2_vd2_vd2_vd_rvvm1_sleef(ddmul_vd2_vd2_vd2_rvvm1_sleef(ddsqrt_vd2_vd2_rvvm1_sleef(ddadd2_vd2_vd_vd_rvvm1_sleef(x, vcast_vd_d_rvvm1_sleef(1))), ddsqrt_vd2_vd2_rvvm1_sleef(ddadd2_vd2_vd_vd_rvvm1_sleef(x, vcast_vd_d_rvvm1_sleef(-1)))), x)); + vdouble_rvvm1_sleef y = vadd_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(d), vd2gety_vd_vd2_rvvm1_sleef(d)); + + y = vsel_vd_vo_vd_vd_rvvm1_sleef(rvv_dp_vor_vo_vo_vo(vgt_vo_vd_vd_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(x), vcast_vd_d_rvvm1_sleef(1.3407807929942596355e+154)), + visnan_vo_vd_rvvm1_sleef(y)), + vcast_vd_d_rvvm1_sleef(__builtin_inf()), y); + y = vreinterpret_vd_vm_rvvm1_sleef(vandnot_vm_vo64_vm_rvvm1_sleef(veq_vo_vd_vd_rvvm1_sleef(x, vcast_vd_d_rvvm1_sleef(1.0)), vreinterpret_vm_vd_rvvm1_sleef(y))); + + y = vreinterpret_vd_vm_rvvm1_sleef(vor_vm_vo64_vm_rvvm1_sleef(vlt_vo_vd_vd_rvvm1_sleef(x, vcast_vd_d_rvvm1_sleef(1.0)), vreinterpret_vm_vd_rvvm1_sleef(y))); + y = vreinterpret_vd_vm_rvvm1_sleef(vor_vm_vo64_vm_rvvm1_sleef(visnan_vo_vd_rvvm1_sleef(x), vreinterpret_vm_vd_rvvm1_sleef(y))); + + return y; +} + +SLEEF_INLINE SLEEF_CONST vdouble_rvvm1_sleef Sleef_atanhdx_u10rvvm1(vdouble_rvvm1_sleef x) { + vdouble_rvvm1_sleef y = vabs_vd_vd_rvvm1_sleef(x); + vdouble2_rvvm1_sleef d = logk2_rvvm1_sleef(dddiv_vd2_vd2_vd2_rvvm1_sleef(ddadd2_vd2_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(1), y), ddadd2_vd2_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(1), vneg_vd_vd_rvvm1_sleef(y)))); + y = vreinterpret_vd_vm_rvvm1_sleef(vor_vm_vo64_vm_rvvm1_sleef(vgt_vo_vd_vd_rvvm1_sleef(y, vcast_vd_d_rvvm1_sleef(1.0)), vreinterpret_vm_vd_rvvm1_sleef(vsel_vd_vo_vd_vd_rvvm1_sleef(veq_vo_vd_vd_rvvm1_sleef(y, vcast_vd_d_rvvm1_sleef(1.0)), vcast_vd_d_rvvm1_sleef(__builtin_inf()), vmul_vd_vd_vd_rvvm1_sleef(vadd_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(d), vd2gety_vd_vd2_rvvm1_sleef(d)), vcast_vd_d_rvvm1_sleef(0.5)))))); + + y = vmulsign_vd_vd_vd_rvvm1_sleef(y, x); + y = vreinterpret_vd_vm_rvvm1_sleef(vor_vm_vo64_vm_rvvm1_sleef(rvv_dp_vor_vo_vo_vo(visinf_vo_vd_rvvm1_sleef(x), visnan_vo_vd_rvvm1_sleef(y)), vreinterpret_vm_vd_rvvm1_sleef(y))); + y = vreinterpret_vd_vm_rvvm1_sleef(vor_vm_vo64_vm_rvvm1_sleef(visnan_vo_vd_rvvm1_sleef(x), vreinterpret_vm_vd_rvvm1_sleef(y))); + + return y; +} + +SLEEF_INLINE SLEEF_CONST vdouble_rvvm1_sleef Sleef_cbrtdx_u35rvvm1(vdouble_rvvm1_sleef d) { + vdouble_rvvm1_sleef x, y, q = vcast_vd_d_rvvm1_sleef(1.0); + vint_rvvm1_sleef e, qu, re; + vdouble_rvvm1_sleef t; + + e = vadd_vi_vi_vi_rvvm1_sleef(vilogbk_vi_vd_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(d)), vcast_vi_i_rvvm1_sleef(1)); + d = vldexp2_vd_vd_vi_rvvm1_sleef(d, vneg_vi_vi_rvvm1_sleef(e)); + + t = vadd_vd_vd_vd_rvvm1_sleef(vcast_vd_vi_rvvm1_sleef(e), vcast_vd_d_rvvm1_sleef(6144)); + qu = vtruncate_vi_vd_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(t, vcast_vd_d_rvvm1_sleef(1.0/3.0))); + re = vtruncate_vi_vd_rvvm1_sleef(vsub_vd_vd_vd_rvvm1_sleef(t, vmul_vd_vd_vd_rvvm1_sleef(vcast_vd_vi_rvvm1_sleef(qu), vcast_vd_d_rvvm1_sleef(3)))); + + q = vsel_vd_vo_vd_vd_rvvm1_sleef(vcast_vo64_vo32_rvvm1_sleef(veq_vo_vi_vi_rvvm1_sleef(re, vcast_vi_i_rvvm1_sleef(1))), vcast_vd_d_rvvm1_sleef(1.2599210498948731647672106), q); + q = vsel_vd_vo_vd_vd_rvvm1_sleef(vcast_vo64_vo32_rvvm1_sleef(veq_vo_vi_vi_rvvm1_sleef(re, vcast_vi_i_rvvm1_sleef(2))), vcast_vd_d_rvvm1_sleef(1.5874010519681994747517056), q); + q = vldexp2_vd_vd_vi_rvvm1_sleef(q, vsub_vi_vi_vi_rvvm1_sleef(qu, vcast_vi_i_rvvm1_sleef(2048))); + + q = vmulsign_vd_vd_vd_rvvm1_sleef(q, d); + + d = vabs_vd_vd_rvvm1_sleef(d); + + x = vcast_vd_d_rvvm1_sleef(-0.640245898480692909870982); + x = vmla_vd_vd_vd_vd_rvvm1_sleef(x, d, vcast_vd_d_rvvm1_sleef(2.96155103020039511818595)); + x = vmla_vd_vd_vd_vd_rvvm1_sleef(x, d, vcast_vd_d_rvvm1_sleef(-5.73353060922947843636166)); + x = vmla_vd_vd_vd_vd_rvvm1_sleef(x, d, vcast_vd_d_rvvm1_sleef(6.03990368989458747961407)); + x = vmla_vd_vd_vd_vd_rvvm1_sleef(x, d, vcast_vd_d_rvvm1_sleef(-3.85841935510444988821632)); + x = vmla_vd_vd_vd_vd_rvvm1_sleef(x, d, vcast_vd_d_rvvm1_sleef(2.2307275302496609725722)); + + y = vmul_vd_vd_vd_rvvm1_sleef(x, x); y = vmul_vd_vd_vd_rvvm1_sleef(y, y); x = vsub_vd_vd_vd_rvvm1_sleef(x, vmul_vd_vd_vd_rvvm1_sleef(vmlapn_vd_vd_vd_vd_rvvm1_sleef(d, y, x), vcast_vd_d_rvvm1_sleef(1.0 / 3.0))); + y = vmul_vd_vd_vd_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(d, x), x); + y = vmul_vd_vd_vd_rvvm1_sleef(vsub_vd_vd_vd_rvvm1_sleef(y, vmul_vd_vd_vd_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(2.0 / 3.0), y), vmla_vd_vd_vd_vd_rvvm1_sleef(y, x, vcast_vd_d_rvvm1_sleef(-1.0)))), q); + + return y; +} + +SLEEF_INLINE SLEEF_CONST vdouble_rvvm1_sleef Sleef_cbrtdx_u10rvvm1(vdouble_rvvm1_sleef d) { + vdouble_rvvm1_sleef x, y, z, t; + vdouble2_rvvm1_sleef q2 = vcast_vd2_d_d_rvvm1_sleef(1, 0), u, v; + vint_rvvm1_sleef e, qu, re; + + e = vadd_vi_vi_vi_rvvm1_sleef(vilogbk_vi_vd_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(d)), vcast_vi_i_rvvm1_sleef(1)); + d = vldexp2_vd_vd_vi_rvvm1_sleef(d, vneg_vi_vi_rvvm1_sleef(e)); + + t = vadd_vd_vd_vd_rvvm1_sleef(vcast_vd_vi_rvvm1_sleef(e), vcast_vd_d_rvvm1_sleef(6144)); + qu = vtruncate_vi_vd_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(t, vcast_vd_d_rvvm1_sleef(1.0/3.0))); + re = vtruncate_vi_vd_rvvm1_sleef(vsub_vd_vd_vd_rvvm1_sleef(t, vmul_vd_vd_vd_rvvm1_sleef(vcast_vd_vi_rvvm1_sleef(qu), vcast_vd_d_rvvm1_sleef(3)))); + + q2 = vsel_vd2_vo_vd2_vd2_rvvm1_sleef(vcast_vo64_vo32_rvvm1_sleef(veq_vo_vi_vi_rvvm1_sleef(re, vcast_vi_i_rvvm1_sleef(1))), vcast_vd2_d_d_rvvm1_sleef(1.2599210498948731907, -2.5899333753005069177e-17), q2); + q2 = vsel_vd2_vo_vd2_vd2_rvvm1_sleef(vcast_vo64_vo32_rvvm1_sleef(veq_vo_vi_vi_rvvm1_sleef(re, vcast_vi_i_rvvm1_sleef(2))), vcast_vd2_d_d_rvvm1_sleef(1.5874010519681995834, -1.0869008194197822986e-16), q2); + + q2 = vd2setxy_vd2_vd_vd_rvvm1_sleef(vmulsign_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(q2), d), vmulsign_vd_vd_vd_rvvm1_sleef(vd2gety_vd_vd2_rvvm1_sleef(q2), d)); + d = vabs_vd_vd_rvvm1_sleef(d); + + x = vcast_vd_d_rvvm1_sleef(-0.640245898480692909870982); + x = vmla_vd_vd_vd_vd_rvvm1_sleef(x, d, vcast_vd_d_rvvm1_sleef(2.96155103020039511818595)); + x = vmla_vd_vd_vd_vd_rvvm1_sleef(x, d, vcast_vd_d_rvvm1_sleef(-5.73353060922947843636166)); + x = vmla_vd_vd_vd_vd_rvvm1_sleef(x, d, vcast_vd_d_rvvm1_sleef(6.03990368989458747961407)); + x = vmla_vd_vd_vd_vd_rvvm1_sleef(x, d, vcast_vd_d_rvvm1_sleef(-3.85841935510444988821632)); + x = vmla_vd_vd_vd_vd_rvvm1_sleef(x, d, vcast_vd_d_rvvm1_sleef(2.2307275302496609725722)); + + y = vmul_vd_vd_vd_rvvm1_sleef(x, x); y = vmul_vd_vd_vd_rvvm1_sleef(y, y); x = vsub_vd_vd_vd_rvvm1_sleef(x, vmul_vd_vd_vd_rvvm1_sleef(vmlapn_vd_vd_vd_vd_rvvm1_sleef(d, y, x), vcast_vd_d_rvvm1_sleef(1.0 / 3.0))); + + z = x; + + u = ddmul_vd2_vd_vd_rvvm1_sleef(x, x); + u = ddmul_vd2_vd2_vd2_rvvm1_sleef(u, u); + u = ddmul_vd2_vd2_vd_rvvm1_sleef(u, d); + u = ddadd2_vd2_vd2_vd_rvvm1_sleef(u, vneg_vd_vd_rvvm1_sleef(x)); + y = vadd_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(u), vd2gety_vd_vd2_rvvm1_sleef(u)); + + y = vmul_vd_vd_vd_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(-2.0 / 3.0), y), z); + v = ddadd2_vd2_vd2_vd_rvvm1_sleef(ddmul_vd2_vd_vd_rvvm1_sleef(z, z), y); + v = ddmul_vd2_vd2_vd_rvvm1_sleef(v, d); + v = ddmul_vd2_vd2_vd2_rvvm1_sleef(v, q2); + z = vldexp2_vd_vd_vi_rvvm1_sleef(vadd_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(v), vd2gety_vd_vd2_rvvm1_sleef(v)), vsub_vi_vi_vi_rvvm1_sleef(qu, vcast_vi_i_rvvm1_sleef(2048))); + + z = vsel_vd_vo_vd_vd_rvvm1_sleef(visinf_vo_vd_rvvm1_sleef(d), vmulsign_vd_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(__builtin_inf()), vd2getx_vd_vd2_rvvm1_sleef(q2)), z); + z = vsel_vd_vo_vd_vd_rvvm1_sleef(veq_vo_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(0)), vreinterpret_vd_vm_rvvm1_sleef(vsignbit_vm_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(q2))), z); + + return z; +} + +SLEEF_INLINE SLEEF_CONST vdouble_rvvm1_sleef Sleef_exp2dx_u10rvvm1(vdouble_rvvm1_sleef d) { + vdouble_rvvm1_sleef u = vrint_vd_vd_rvvm1_sleef(d), s; + vint_rvvm1_sleef q = vrint_vi_vd_rvvm1_sleef(u); + + s = vsub_vd_vd_vd_rvvm1_sleef(d, u); + + vdouble_rvvm1_sleef s2 = vmul_vd_vd_vd_rvvm1_sleef(s, s), s4 = vmul_vd_vd_vd_rvvm1_sleef(s2, s2), s8 = vmul_vd_vd_vd_rvvm1_sleef(s4, s4); + u = vmla_vd_vd_vd_vd_rvvm1_sleef((s8), (vmla_vd_vd_vd_vd_rvvm1_sleef((s), (vcast_vd_d_rvvm1_sleef(+0.4434359082926529454e-9)), (vcast_vd_d_rvvm1_sleef(+0.7073164598085707425e-8)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((s4), (vmla_vd_vd_vd_vd_rvvm1_sleef((s2), (vmla_vd_vd_vd_vd_rvvm1_sleef((s), (vcast_vd_d_rvvm1_sleef(+0.1017819260921760451e-6)), (vcast_vd_d_rvvm1_sleef(+0.1321543872511327615e-5)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((s), (vcast_vd_d_rvvm1_sleef(+0.1525273353517584730e-4)), (vcast_vd_d_rvvm1_sleef(+0.1540353045101147808e-3)))))), (vmla_vd_vd_vd_vd_rvvm1_sleef((s2), (vmla_vd_vd_vd_vd_rvvm1_sleef((s), (vcast_vd_d_rvvm1_sleef(+0.1333355814670499073e-2)), (vcast_vd_d_rvvm1_sleef(+0.9618129107597600536e-2)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((s), (vcast_vd_d_rvvm1_sleef(+0.5550410866482046596e-1)), (vcast_vd_d_rvvm1_sleef(+0.2402265069591012214e+0))))))))) + + ; + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, s, vcast_vd_d_rvvm1_sleef(+0.6931471805599452862e+0)); + + u = vfma_vd_vd_vd_vd_rvvm1_sleef(u, s, vcast_vd_d_rvvm1_sleef(1)); + + u = vldexp2_vd_vd_vi_rvvm1_sleef(u, q); + + u = vsel_vd_vo_vd_vd_rvvm1_sleef(vge_vo_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(1024)), vcast_vd_d_rvvm1_sleef(__builtin_inf()), u); + u = vreinterpret_vd_vm_rvvm1_sleef(vandnot_vm_vo64_vm_rvvm1_sleef(vlt_vo_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(-2000)), vreinterpret_vm_vd_rvvm1_sleef(u))); + + return u; +} + +SLEEF_INLINE SLEEF_CONST vdouble_rvvm1_sleef Sleef_exp2dx_u35rvvm1(vdouble_rvvm1_sleef d) { + vdouble_rvvm1_sleef u = vrint_vd_vd_rvvm1_sleef(d), s; + vint_rvvm1_sleef q = vrint_vi_vd_rvvm1_sleef(u); + + s = vsub_vd_vd_vd_rvvm1_sleef(d, u); + + vdouble_rvvm1_sleef s2 = vmul_vd_vd_vd_rvvm1_sleef(s, s), s4 = vmul_vd_vd_vd_rvvm1_sleef(s2, s2), s8 = vmul_vd_vd_vd_rvvm1_sleef(s4, s4); + u = vmla_vd_vd_vd_vd_rvvm1_sleef((s8), (vmla_vd_vd_vd_vd_rvvm1_sleef((s), (vcast_vd_d_rvvm1_sleef(+0.4434359082926529454e-9)), (vcast_vd_d_rvvm1_sleef(+0.7073164598085707425e-8)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((s4), (vmla_vd_vd_vd_vd_rvvm1_sleef((s2), (vmla_vd_vd_vd_vd_rvvm1_sleef((s), (vcast_vd_d_rvvm1_sleef(+0.1017819260921760451e-6)), (vcast_vd_d_rvvm1_sleef(+0.1321543872511327615e-5)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((s), (vcast_vd_d_rvvm1_sleef(+0.1525273353517584730e-4)), (vcast_vd_d_rvvm1_sleef(+0.1540353045101147808e-3)))))), (vmla_vd_vd_vd_vd_rvvm1_sleef((s2), (vmla_vd_vd_vd_vd_rvvm1_sleef((s), (vcast_vd_d_rvvm1_sleef(+0.1333355814670499073e-2)), (vcast_vd_d_rvvm1_sleef(+0.9618129107597600536e-2)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((s), (vcast_vd_d_rvvm1_sleef(+0.5550410866482046596e-1)), (vcast_vd_d_rvvm1_sleef(+0.2402265069591012214e+0))))))))) + + ; + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, s, vcast_vd_d_rvvm1_sleef(+0.6931471805599452862e+0)); + + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, s, vcast_vd_d_rvvm1_sleef(1)); + + u = vldexp2_vd_vd_vi_rvvm1_sleef(u, q); + + u = vsel_vd_vo_vd_vd_rvvm1_sleef(vge_vo_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(1024)), vcast_vd_d_rvvm1_sleef(__builtin_inf()), u); + u = vreinterpret_vd_vm_rvvm1_sleef(vandnot_vm_vo64_vm_rvvm1_sleef(vlt_vo_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(-2000)), vreinterpret_vm_vd_rvvm1_sleef(u))); + + return u; +} + +SLEEF_INLINE SLEEF_CONST vdouble_rvvm1_sleef Sleef_exp10dx_u10rvvm1(vdouble_rvvm1_sleef d) { + vdouble_rvvm1_sleef u = vrint_vd_vd_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(3.3219280948873623478703194294893901758648313930))), s; + vint_rvvm1_sleef q = vrint_vi_vd_rvvm1_sleef(u); + + s = vmla_vd_vd_vd_vd_rvvm1_sleef(u, vcast_vd_d_rvvm1_sleef(-0.30102999566383914498), d); + s = vmla_vd_vd_vd_vd_rvvm1_sleef(u, vcast_vd_d_rvvm1_sleef(-1.4205023227266099418e-13), s); + + u = vcast_vd_d_rvvm1_sleef(+0.2411463498334267652e-3); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, s, vcast_vd_d_rvvm1_sleef(+0.1157488415217187375e-2)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, s, vcast_vd_d_rvvm1_sleef(+0.5013975546789733659e-2)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, s, vcast_vd_d_rvvm1_sleef(+0.1959762320720533080e-1)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, s, vcast_vd_d_rvvm1_sleef(+0.6808936399446784138e-1)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, s, vcast_vd_d_rvvm1_sleef(+0.2069958494722676234e+0)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, s, vcast_vd_d_rvvm1_sleef(+0.5393829292058536229e+0)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, s, vcast_vd_d_rvvm1_sleef(+0.1171255148908541655e+1)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, s, vcast_vd_d_rvvm1_sleef(+0.2034678592293432953e+1)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, s, vcast_vd_d_rvvm1_sleef(+0.2650949055239205876e+1)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, s, vcast_vd_d_rvvm1_sleef(+0.2302585092994045901e+1)); + + u = vfma_vd_vd_vd_vd_rvvm1_sleef(u, s, vcast_vd_d_rvvm1_sleef(1)); + + u = vldexp2_vd_vd_vi_rvvm1_sleef(u, q); + + u = vsel_vd_vo_vd_vd_rvvm1_sleef(vgt_vo_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(308.25471555991671)), vcast_vd_d_rvvm1_sleef(__builtin_inf()), u); + u = vreinterpret_vd_vm_rvvm1_sleef(vandnot_vm_vo64_vm_rvvm1_sleef(vlt_vo_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(-350)), vreinterpret_vm_vd_rvvm1_sleef(u))); + + return u; +} + +SLEEF_INLINE SLEEF_CONST vdouble_rvvm1_sleef Sleef_exp10dx_u35rvvm1(vdouble_rvvm1_sleef d) { + vdouble_rvvm1_sleef u = vrint_vd_vd_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(3.3219280948873623478703194294893901758648313930))), s; + vint_rvvm1_sleef q = vrint_vi_vd_rvvm1_sleef(u); + + s = vmla_vd_vd_vd_vd_rvvm1_sleef(u, vcast_vd_d_rvvm1_sleef(-0.30102999566383914498), d); + s = vmla_vd_vd_vd_vd_rvvm1_sleef(u, vcast_vd_d_rvvm1_sleef(-1.4205023227266099418e-13), s); + + vdouble_rvvm1_sleef s2 = vmul_vd_vd_vd_rvvm1_sleef(s, s), s4 = vmul_vd_vd_vd_rvvm1_sleef(s2, s2), s8 = vmul_vd_vd_vd_rvvm1_sleef(s4, s4); + u = vmla_vd_vd_vd_vd_rvvm1_sleef((s8), (vmla_vd_vd_vd_vd_rvvm1_sleef((s2), (vcast_vd_d_rvvm1_sleef(+0.2411463498334267652e-3)), (vmla_vd_vd_vd_vd_rvvm1_sleef((s), (vcast_vd_d_rvvm1_sleef(+0.1157488415217187375e-2)), (vcast_vd_d_rvvm1_sleef(+0.5013975546789733659e-2)))))), (vmla_vd_vd_vd_vd_rvvm1_sleef((s4), (vmla_vd_vd_vd_vd_rvvm1_sleef((s2), (vmla_vd_vd_vd_vd_rvvm1_sleef((s), (vcast_vd_d_rvvm1_sleef(+0.1959762320720533080e-1)), (vcast_vd_d_rvvm1_sleef(+0.6808936399446784138e-1)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((s), (vcast_vd_d_rvvm1_sleef(+0.2069958494722676234e+0)), (vcast_vd_d_rvvm1_sleef(+0.5393829292058536229e+0)))))), (vmla_vd_vd_vd_vd_rvvm1_sleef((s2), (vmla_vd_vd_vd_vd_rvvm1_sleef((s), (vcast_vd_d_rvvm1_sleef(+0.1171255148908541655e+1)), (vcast_vd_d_rvvm1_sleef(+0.2034678592293432953e+1)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((s), (vcast_vd_d_rvvm1_sleef(+0.2650949055239205876e+1)), (vcast_vd_d_rvvm1_sleef(+0.2302585092994045901e+1))))))))) + + ; + + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, s, vcast_vd_d_rvvm1_sleef(1)); + + u = vldexp2_vd_vd_vi_rvvm1_sleef(u, q); + + u = vsel_vd_vo_vd_vd_rvvm1_sleef(vgt_vo_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(308.25471555991671)), vcast_vd_d_rvvm1_sleef(__builtin_inf()), u); + u = vreinterpret_vd_vm_rvvm1_sleef(vandnot_vm_vo64_vm_rvvm1_sleef(vlt_vo_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(-350)), vreinterpret_vm_vd_rvvm1_sleef(u))); + + return u; +} + +SLEEF_INLINE SLEEF_CONST vdouble_rvvm1_sleef Sleef_expm1dx_u10rvvm1(vdouble_rvvm1_sleef a) { + vdouble2_rvvm1_sleef d = ddadd2_vd2_vd2_vd_rvvm1_sleef(expk2_rvvm1_sleef(vcast_vd2_vd_vd_rvvm1_sleef(a, vcast_vd_d_rvvm1_sleef(0))), vcast_vd_d_rvvm1_sleef(-1.0)); + vdouble_rvvm1_sleef x = vadd_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(d), vd2gety_vd_vd2_rvvm1_sleef(d)); + x = vsel_vd_vo_vd_vd_rvvm1_sleef(vgt_vo_vd_vd_rvvm1_sleef(a, vcast_vd_d_rvvm1_sleef(709.782712893383996732223)), vcast_vd_d_rvvm1_sleef(__builtin_inf()), x); + x = vsel_vd_vo_vd_vd_rvvm1_sleef(vlt_vo_vd_vd_rvvm1_sleef(a, vcast_vd_d_rvvm1_sleef(-36.736800569677101399113302437)), vcast_vd_d_rvvm1_sleef(-1), x); + x = vsel_vd_vo_vd_vd_rvvm1_sleef(visnegzero_vo_vd_rvvm1_sleef(a), vcast_vd_d_rvvm1_sleef(-0.0), x); + return x; +} + +SLEEF_INLINE SLEEF_CONST vdouble_rvvm1_sleef Sleef_log10dx_u10rvvm1(vdouble_rvvm1_sleef d) { + vdouble2_rvvm1_sleef x; + vdouble_rvvm1_sleef t, m, x2; + + rvv_dp_vopmask_rvvm1_sleef o = vlt_vo_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(0x1p-1022)); + d = vsel_vd_vo_vd_vd_rvvm1_sleef(o, vmul_vd_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef((double)(INT64_C(1) << 32) * (double)(INT64_C(1) << 32))), d); + vint_rvvm1_sleef e = vilogb2k_vi_vd_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(1.0/0.75))); + m = vldexp3_vd_vd_vi_rvvm1_sleef(d, vneg_vi_vi_rvvm1_sleef(e)); + e = vsel_vi_vo_vi_vi_rvvm1_sleef(vcast_vo32_vo64_rvvm1_sleef(o), vsub_vi_vi_vi_rvvm1_sleef(e, vcast_vi_i_rvvm1_sleef(64)), e); + + x = dddiv_vd2_vd2_vd2_rvvm1_sleef(ddadd2_vd2_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(-1), m), ddadd2_vd2_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(1), m)); + x2 = vmul_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(x), vd2getx_vd_vd2_rvvm1_sleef(x)); + + vdouble_rvvm1_sleef x4 = vmul_vd_vd_vd_rvvm1_sleef(x2, x2), x8 = vmul_vd_vd_vd_rvvm1_sleef(x4, x4); + t = vmla_vd_vd_vd_vd_rvvm1_sleef((x8), (vmla_vd_vd_vd_vd_rvvm1_sleef((x4), (vcast_vd_d_rvvm1_sleef(+0.6653725819576758460e-1)), (vmla_vd_vd_vd_vd_rvvm1_sleef((x2), (vcast_vd_d_rvvm1_sleef(+0.6625722782820833712e-1)), (vcast_vd_d_rvvm1_sleef(+0.7898105214313944078e-1)))))), (vmla_vd_vd_vd_vd_rvvm1_sleef((x4), (vmla_vd_vd_vd_vd_rvvm1_sleef((x2), (vcast_vd_d_rvvm1_sleef(+0.9650955035715275132e-1)), (vcast_vd_d_rvvm1_sleef(+0.1240841409721444993e+0)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((x2), (vcast_vd_d_rvvm1_sleef(+0.1737177927454605086e+0)), (vcast_vd_d_rvvm1_sleef(+0.2895296546021972617e+0))))))) + + ; + + vdouble2_rvvm1_sleef s = ddmul_vd2_vd2_vd_rvvm1_sleef(vcast_vd2_d_d_rvvm1_sleef(0.30102999566398119802, -2.803728127785170339e-18), vcast_vd_vi_rvvm1_sleef(e)); + + s = ddadd_vd2_vd2_vd2_rvvm1_sleef(s, ddmul_vd2_vd2_vd2_rvvm1_sleef(x, vcast_vd2_d_d_rvvm1_sleef(0.86858896380650363334, 1.1430059694096389311e-17))); + s = ddadd_vd2_vd2_vd_rvvm1_sleef(s, vmul_vd_vd_vd_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(x2, vd2getx_vd_vd2_rvvm1_sleef(x)), t)); + + vdouble_rvvm1_sleef r = vadd_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(s), vd2gety_vd_vd2_rvvm1_sleef(s)); + + r = vsel_vd_vo_vd_vd_rvvm1_sleef(vispinf_vo_vd_rvvm1_sleef(d), vcast_vd_d_rvvm1_sleef(__builtin_inf()), r); + r = vsel_vd_vo_vd_vd_rvvm1_sleef(rvv_dp_vor_vo_vo_vo(vlt_vo_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(0)), visnan_vo_vd_rvvm1_sleef(d)), vcast_vd_d_rvvm1_sleef(__builtin_nan("")), r); + r = vsel_vd_vo_vd_vd_rvvm1_sleef(veq_vo_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(0)), vcast_vd_d_rvvm1_sleef(-__builtin_inf()), r); + + return r; +} + +SLEEF_INLINE SLEEF_CONST vdouble_rvvm1_sleef Sleef_log2dx_u10rvvm1(vdouble_rvvm1_sleef d) { + vdouble2_rvvm1_sleef x; + vdouble_rvvm1_sleef t, m, x2; + + rvv_dp_vopmask_rvvm1_sleef o = vlt_vo_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(0x1p-1022)); + d = vsel_vd_vo_vd_vd_rvvm1_sleef(o, vmul_vd_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef((double)(INT64_C(1) << 32) * (double)(INT64_C(1) << 32))), d); + vint_rvvm1_sleef e = vilogb2k_vi_vd_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(1.0/0.75))); + m = vldexp3_vd_vd_vi_rvvm1_sleef(d, vneg_vi_vi_rvvm1_sleef(e)); + e = vsel_vi_vo_vi_vi_rvvm1_sleef(vcast_vo32_vo64_rvvm1_sleef(o), vsub_vi_vi_vi_rvvm1_sleef(e, vcast_vi_i_rvvm1_sleef(64)), e); + + x = dddiv_vd2_vd2_vd2_rvvm1_sleef(ddadd2_vd2_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(-1), m), ddadd2_vd2_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(1), m)); + x2 = vmul_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(x), vd2getx_vd_vd2_rvvm1_sleef(x)); + + vdouble_rvvm1_sleef x4 = vmul_vd_vd_vd_rvvm1_sleef(x2, x2), x8 = vmul_vd_vd_vd_rvvm1_sleef(x4, x4); + t = vmla_vd_vd_vd_vd_rvvm1_sleef((x8), (vmla_vd_vd_vd_vd_rvvm1_sleef((x4), (vcast_vd_d_rvvm1_sleef(+0.2211941750456081490e+0)), (vmla_vd_vd_vd_vd_rvvm1_sleef((x2), (vcast_vd_d_rvvm1_sleef(+0.2200768693152277689e+0)), (vcast_vd_d_rvvm1_sleef(+0.2623708057488514656e+0)))))), (vmla_vd_vd_vd_vd_rvvm1_sleef((x4), (vmla_vd_vd_vd_vd_rvvm1_sleef((x2), (vcast_vd_d_rvvm1_sleef(+0.3205977477944495502e+0)), (vcast_vd_d_rvvm1_sleef(+0.4121985945485324709e+0)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((x2), (vcast_vd_d_rvvm1_sleef(+0.5770780162997058982e+0)), (vcast_vd_d_rvvm1_sleef(+0.96179669392608091449))))))) + + ; + + vdouble2_rvvm1_sleef s = ddadd2_vd2_vd_vd2_rvvm1_sleef(vcast_vd_vi_rvvm1_sleef(e), + ddmul_vd2_vd2_vd2_rvvm1_sleef(x, vcast_vd2_d_d_rvvm1_sleef(2.885390081777926774, 6.0561604995516736434e-18))); + + s = ddadd2_vd2_vd2_vd_rvvm1_sleef(s, vmul_vd_vd_vd_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(x2, vd2getx_vd_vd2_rvvm1_sleef(x)), t)); + + vdouble_rvvm1_sleef r = vadd_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(s), vd2gety_vd_vd2_rvvm1_sleef(s)); + + r = vsel_vd_vo_vd_vd_rvvm1_sleef(vispinf_vo_vd_rvvm1_sleef(d), vcast_vd_d_rvvm1_sleef(__builtin_inf()), r); + r = vsel_vd_vo_vd_vd_rvvm1_sleef(rvv_dp_vor_vo_vo_vo(vlt_vo_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(0)), visnan_vo_vd_rvvm1_sleef(d)), vcast_vd_d_rvvm1_sleef(__builtin_nan("")), r); + r = vsel_vd_vo_vd_vd_rvvm1_sleef(veq_vo_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(0)), vcast_vd_d_rvvm1_sleef(-__builtin_inf()), r); + + return r; +} + +SLEEF_INLINE SLEEF_CONST vdouble_rvvm1_sleef Sleef_log2dx_u35rvvm1(vdouble_rvvm1_sleef d) { + vdouble_rvvm1_sleef m, t, x, x2; + + rvv_dp_vopmask_rvvm1_sleef o = vlt_vo_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(0x1p-1022)); + d = vsel_vd_vo_vd_vd_rvvm1_sleef(o, vmul_vd_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef((double)(INT64_C(1) << 32) * (double)(INT64_C(1) << 32))), d); + vint_rvvm1_sleef e = vilogb2k_vi_vd_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(1.0/0.75))); + m = vldexp3_vd_vd_vi_rvvm1_sleef(d, vneg_vi_vi_rvvm1_sleef(e)); + e = vsel_vi_vo_vi_vi_rvvm1_sleef(vcast_vo32_vo64_rvvm1_sleef(o), vsub_vi_vi_vi_rvvm1_sleef(e, vcast_vi_i_rvvm1_sleef(64)), e); + + x = vdiv_vd_vd_vd_rvvm1_sleef(vsub_vd_vd_vd_rvvm1_sleef(m, vcast_vd_d_rvvm1_sleef(1)), vadd_vd_vd_vd_rvvm1_sleef(m, vcast_vd_d_rvvm1_sleef(1))); + x2 = vmul_vd_vd_vd_rvvm1_sleef(x, x); + + t = vcast_vd_d_rvvm1_sleef(+0.2211941750456081490e+0); + t = vmla_vd_vd_vd_vd_rvvm1_sleef(t, x2, vcast_vd_d_rvvm1_sleef(+0.2200768693152277689e+0)); + t = vmla_vd_vd_vd_vd_rvvm1_sleef(t, x2, vcast_vd_d_rvvm1_sleef(+0.2623708057488514656e+0)); + t = vmla_vd_vd_vd_vd_rvvm1_sleef(t, x2, vcast_vd_d_rvvm1_sleef(+0.3205977477944495502e+0)); + t = vmla_vd_vd_vd_vd_rvvm1_sleef(t, x2, vcast_vd_d_rvvm1_sleef(+0.4121985945485324709e+0)); + t = vmla_vd_vd_vd_vd_rvvm1_sleef(t, x2, vcast_vd_d_rvvm1_sleef(+0.5770780162997058982e+0)); + t = vmla_vd_vd_vd_vd_rvvm1_sleef(t, x2, vcast_vd_d_rvvm1_sleef(+0.96179669392608091449 )); + + vdouble2_rvvm1_sleef s = ddadd_vd2_vd_vd2_rvvm1_sleef(vcast_vd_vi_rvvm1_sleef(e), + ddmul_vd2_vd_vd_rvvm1_sleef(x, vcast_vd_d_rvvm1_sleef(2.885390081777926774))); + + vdouble_rvvm1_sleef r = vmla_vd_vd_vd_vd_rvvm1_sleef(t, vmul_vd_vd_vd_rvvm1_sleef(x, x2), vadd_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(s), vd2gety_vd_vd2_rvvm1_sleef(s))); + + r = vsel_vd_vo_vd_vd_rvvm1_sleef(vispinf_vo_vd_rvvm1_sleef(d), vcast_vd_d_rvvm1_sleef(__builtin_inf()), r); + r = vsel_vd_vo_vd_vd_rvvm1_sleef(rvv_dp_vor_vo_vo_vo(vlt_vo_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(0)), visnan_vo_vd_rvvm1_sleef(d)), vcast_vd_d_rvvm1_sleef(__builtin_nan("")), r); + r = vsel_vd_vo_vd_vd_rvvm1_sleef(veq_vo_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(0)), vcast_vd_d_rvvm1_sleef(-__builtin_inf()), r); + + return r; +} + +SLEEF_INLINE SLEEF_CONST vdouble_rvvm1_sleef Sleef_log1pdx_u10rvvm1(vdouble_rvvm1_sleef d) { + vdouble2_rvvm1_sleef x; + vdouble_rvvm1_sleef t, m, x2; + + vdouble_rvvm1_sleef dp1 = vadd_vd_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(1)); + + rvv_dp_vopmask_rvvm1_sleef o = vlt_vo_vd_vd_rvvm1_sleef(dp1, vcast_vd_d_rvvm1_sleef(0x1p-1022)); + dp1 = vsel_vd_vo_vd_vd_rvvm1_sleef(o, vmul_vd_vd_vd_rvvm1_sleef(dp1, vcast_vd_d_rvvm1_sleef((double)(INT64_C(1) << 32) * (double)(INT64_C(1) << 32))), dp1); + vint_rvvm1_sleef e = vilogb2k_vi_vd_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(dp1, vcast_vd_d_rvvm1_sleef(1.0/0.75))); + t = vldexp3_vd_vd_vi_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(1), vneg_vi_vi_rvvm1_sleef(e)); + m = vmla_vd_vd_vd_vd_rvvm1_sleef(d, t, vsub_vd_vd_vd_rvvm1_sleef(t, vcast_vd_d_rvvm1_sleef(1))); + e = vsel_vi_vo_vi_vi_rvvm1_sleef(vcast_vo32_vo64_rvvm1_sleef(o), vsub_vi_vi_vi_rvvm1_sleef(e, vcast_vi_i_rvvm1_sleef(64)), e); + vdouble2_rvvm1_sleef s = ddmul_vd2_vd2_vd_rvvm1_sleef(vcast_vd2_d_d_rvvm1_sleef(0.693147180559945286226764, 2.319046813846299558417771e-17), vcast_vd_vi_rvvm1_sleef(e)); + + x = dddiv_vd2_vd2_vd2_rvvm1_sleef(vcast_vd2_vd_vd_rvvm1_sleef(m, vcast_vd_d_rvvm1_sleef(0)), ddadd_vd2_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(2), m)); + x2 = vmul_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(x), vd2getx_vd_vd2_rvvm1_sleef(x)); + + vdouble_rvvm1_sleef x4 = vmul_vd_vd_vd_rvvm1_sleef(x2, x2), x8 = vmul_vd_vd_vd_rvvm1_sleef(x4, x4); + t = vmla_vd_vd_vd_vd_rvvm1_sleef((x8), (vmla_vd_vd_vd_vd_rvvm1_sleef((x4), (vcast_vd_d_rvvm1_sleef(0.1532076988502701353e+0)), (vmla_vd_vd_vd_vd_rvvm1_sleef((x2), (vcast_vd_d_rvvm1_sleef(0.1525629051003428716e+0)), (vcast_vd_d_rvvm1_sleef(0.1818605932937785996e+0)))))), (vmla_vd_vd_vd_vd_rvvm1_sleef((x4), (vmla_vd_vd_vd_vd_rvvm1_sleef((x2), (vcast_vd_d_rvvm1_sleef(0.2222214519839380009e+0)), (vcast_vd_d_rvvm1_sleef(0.2857142932794299317e+0)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((x2), (vcast_vd_d_rvvm1_sleef(0.3999999999635251990e+0)), (vcast_vd_d_rvvm1_sleef(0.6666666666667333541e+0))))))) + + ; + + s = ddadd_vd2_vd2_vd2_rvvm1_sleef(s, ddscale_vd2_vd2_vd_rvvm1_sleef(x, vcast_vd_d_rvvm1_sleef(2))); + s = ddadd_vd2_vd2_vd_rvvm1_sleef(s, vmul_vd_vd_vd_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(x2, vd2getx_vd_vd2_rvvm1_sleef(x)), t)); + + vdouble_rvvm1_sleef r = vadd_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(s), vd2gety_vd_vd2_rvvm1_sleef(s)); + + r = vsel_vd_vo_vd_vd_rvvm1_sleef(vgt_vo_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(1e+307)), vcast_vd_d_rvvm1_sleef(__builtin_inf()), r); + r = vsel_vd_vo_vd_vd_rvvm1_sleef(rvv_dp_vor_vo_vo_vo(vlt_vo_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(-1)), visnan_vo_vd_rvvm1_sleef(d)), vcast_vd_d_rvvm1_sleef(__builtin_nan("")), r); + r = vsel_vd_vo_vd_vd_rvvm1_sleef(veq_vo_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(-1)), vcast_vd_d_rvvm1_sleef(-__builtin_inf()), r); + r = vsel_vd_vo_vd_vd_rvvm1_sleef(visnegzero_vo_vd_rvvm1_sleef(d), vcast_vd_d_rvvm1_sleef(-0.0), r); + + return r; +} + +SLEEF_INLINE SLEEF_CONST vdouble_rvvm1_sleef Sleef_fabsdx_rvvm1(vdouble_rvvm1_sleef x) { return vabs_vd_vd_rvvm1_sleef(x); } + +SLEEF_INLINE SLEEF_CONST vdouble_rvvm1_sleef Sleef_copysigndx_rvvm1(vdouble_rvvm1_sleef x, vdouble_rvvm1_sleef y) { return vcopysign_vd_vd_vd_rvvm1_sleef(x, y); } + +SLEEF_INLINE SLEEF_CONST vdouble_rvvm1_sleef Sleef_fmaxdx_rvvm1(vdouble_rvvm1_sleef x, vdouble_rvvm1_sleef y) { + + return vsel_vd_vo_vd_vd_rvvm1_sleef(visnan_vo_vd_rvvm1_sleef(y), x, vsel_vd_vo_vd_vd_rvvm1_sleef(vgt_vo_vd_vd_rvvm1_sleef(x, y), x, y)); + +} + +SLEEF_INLINE SLEEF_CONST vdouble_rvvm1_sleef Sleef_fmindx_rvvm1(vdouble_rvvm1_sleef x, vdouble_rvvm1_sleef y) { + + return vsel_vd_vo_vd_vd_rvvm1_sleef(visnan_vo_vd_rvvm1_sleef(y), x, vsel_vd_vo_vd_vd_rvvm1_sleef(vgt_vo_vd_vd_rvvm1_sleef(y, x), x, y)); + +} + +SLEEF_INLINE SLEEF_CONST vdouble_rvvm1_sleef Sleef_fdimdx_rvvm1(vdouble_rvvm1_sleef x, vdouble_rvvm1_sleef y) { + vdouble_rvvm1_sleef ret = vsub_vd_vd_vd_rvvm1_sleef(x, y); + ret = vsel_vd_vo_vd_vd_rvvm1_sleef(rvv_dp_vor_vo_vo_vo(vlt_vo_vd_vd_rvvm1_sleef(ret, vcast_vd_d_rvvm1_sleef(0)), veq_vo_vd_vd_rvvm1_sleef(x, y)), vcast_vd_d_rvvm1_sleef(0), ret); + return ret; +} + +SLEEF_INLINE SLEEF_CONST vdouble_rvvm1_sleef Sleef_truncdx_rvvm1(vdouble_rvvm1_sleef x) { return vtruncate2_vd_vd_rvvm1_sleef_rvvm1_sleef(x); } +SLEEF_INLINE SLEEF_CONST vdouble_rvvm1_sleef Sleef_floordx_rvvm1(vdouble_rvvm1_sleef x) { return vfloor2_vd_vd_rvvm1_sleef(x); } +SLEEF_INLINE SLEEF_CONST vdouble_rvvm1_sleef Sleef_ceildx_rvvm1(vdouble_rvvm1_sleef x) { return vceil2_vd_vd_rvvm1_sleef(x); } +SLEEF_INLINE SLEEF_CONST vdouble_rvvm1_sleef Sleef_rounddx_rvvm1(vdouble_rvvm1_sleef x) { return vround2_vd_vd_rvvm1_sleef(x); } +SLEEF_INLINE SLEEF_CONST vdouble_rvvm1_sleef Sleef_rintdx_rvvm1(vdouble_rvvm1_sleef x) { return vrint2_vd_vd_rvvm1_sleef(x); } + +SLEEF_INLINE SLEEF_CONST vdouble_rvvm1_sleef Sleef_nextafterdx_rvvm1(vdouble_rvvm1_sleef x, vdouble_rvvm1_sleef y) { + x = vsel_vd_vo_vd_vd_rvvm1_sleef(veq_vo_vd_vd_rvvm1_sleef(x, vcast_vd_d_rvvm1_sleef(0)), vmulsign_vd_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(0), y), x); + vmask_rvvm1_sleef xi2 = vreinterpret_vm_vd_rvvm1_sleef(x); + rvv_dp_vopmask_rvvm1_sleef c = rvv_dp_vxor_vo_vo_vo(vsignbit_vo_vd_rvvm1_sleef(x), vge_vo_vd_vd_rvvm1_sleef(y, x)); + + xi2 = vsel_vm_vo64_vm_vm_rvvm1_sleef(c, vneg64_vm_vm_rvvm1_sleef(vxor_vm_vm_vm_rvvm1_sleef(xi2, vcast_vm_i_i_rvvm1_sleef((int)(1U << 31), 0))), xi2); + + xi2 = vsel_vm_vo64_vm_vm_rvvm1_sleef(vneq_vo_vd_vd_rvvm1_sleef(x, y), vsub64_vm_vm_vm_rvvm1_sleef(xi2, vcast_vm_i_i_rvvm1_sleef(0, 1)), xi2); + + xi2 = vsel_vm_vo64_vm_vm_rvvm1_sleef(c, vneg64_vm_vm_rvvm1_sleef(vxor_vm_vm_vm_rvvm1_sleef(xi2, vcast_vm_i_i_rvvm1_sleef((int)(1U << 31), 0))), xi2); + + vdouble_rvvm1_sleef ret = vreinterpret_vd_vm_rvvm1_sleef(xi2); + + ret = vsel_vd_vo_vd_vd_rvvm1_sleef(rvv_dp_vand_vo_vo_vo(veq_vo_vd_vd_rvvm1_sleef(ret, vcast_vd_d_rvvm1_sleef(0)), vneq_vo_vd_vd_rvvm1_sleef(x, vcast_vd_d_rvvm1_sleef(0))), + vmulsign_vd_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(0), x), ret); + + ret = vsel_vd_vo_vd_vd_rvvm1_sleef(rvv_dp_vand_vo_vo_vo(veq_vo_vd_vd_rvvm1_sleef(x, vcast_vd_d_rvvm1_sleef(0)), veq_vo_vd_vd_rvvm1_sleef(y, vcast_vd_d_rvvm1_sleef(0))), y, ret); + + ret = vsel_vd_vo_vd_vd_rvvm1_sleef(rvv_dp_vor_vo_vo_vo(visnan_vo_vd_rvvm1_sleef(x), visnan_vo_vd_rvvm1_sleef(y)), vcast_vd_d_rvvm1_sleef(__builtin_nan("")), ret); + + return ret; +} + +SLEEF_INLINE SLEEF_CONST vdouble_rvvm1_sleef Sleef_frfrexpdx_rvvm1(vdouble_rvvm1_sleef x) { + x = vsel_vd_vo_vd_vd_rvvm1_sleef(vlt_vo_vd_vd_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(x), vcast_vd_d_rvvm1_sleef(0x1p-1022)), vmul_vd_vd_vd_rvvm1_sleef(x, vcast_vd_d_rvvm1_sleef(UINT64_C(1) << 63)), x); + + vmask_rvvm1_sleef xm = vreinterpret_vm_vd_rvvm1_sleef(x); + xm = vand_vm_vm_vm_rvvm1_sleef(xm, vcast_vm_i64_rvvm1_sleef(~INT64_C(0x7ff0000000000000))); + xm = vor_vm_vm_vm_rvvm1_sleef (xm, vcast_vm_i64_rvvm1_sleef( INT64_C(0x3fe0000000000000))); + + vdouble_rvvm1_sleef ret = vreinterpret_vd_vm_rvvm1_sleef(xm); + + ret = vsel_vd_vo_vd_vd_rvvm1_sleef(visinf_vo_vd_rvvm1_sleef(x), vmulsign_vd_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(__builtin_inf()), x), ret); + ret = vsel_vd_vo_vd_vd_rvvm1_sleef(veq_vo_vd_vd_rvvm1_sleef(x, vcast_vd_d_rvvm1_sleef(0)), x, ret); + + return ret; +} + +SLEEF_INLINE SLEEF_CONST vint_rvvm1_sleef Sleef_expfrexpdx_rvvm1(vdouble_rvvm1_sleef x) { + x = vsel_vd_vo_vd_vd_rvvm1_sleef(vlt_vo_vd_vd_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(x), vcast_vd_d_rvvm1_sleef(0x1p-1022)), vmul_vd_vd_vd_rvvm1_sleef(x, vcast_vd_d_rvvm1_sleef(UINT64_C(1) << 63)), x); + + vint_rvvm1_sleef ret = vcastu_vi_vm_rvvm1_sleef(vreinterpret_vm_vd_rvvm1_sleef(x)); + ret = vsub_vi_vi_vi_rvvm1_sleef(vand_vi_vi_vi_rvvm1_sleef(vsrl_vi_vi_i_rvvm1_sleef(ret, 20), vcast_vi_i_rvvm1_sleef(0x7ff)), vcast_vi_i_rvvm1_sleef(0x3fe)); + + ret = vsel_vi_vo_vi_vi_rvvm1_sleef(rvv_dp_vor_vo_vo_vo(rvv_dp_vor_vo_vo_vo(veq_vo_vd_vd_rvvm1_sleef(x, vcast_vd_d_rvvm1_sleef(0)), visnan_vo_vd_rvvm1_sleef(x)), visinf_vo_vd_rvvm1_sleef(x)), vcast_vi_i_rvvm1_sleef(0), ret); + + return ret; +} + +SLEEF_INLINE SLEEF_CONST vdouble_rvvm1_sleef Sleef_fmadx_rvvm1(vdouble_rvvm1_sleef x, vdouble_rvvm1_sleef y, vdouble_rvvm1_sleef z) { + + return vfma_vd_vd_vd_vd_rvvm1_sleef(x, y, z); + +} + +SLEEF_INLINE SLEEF_CONST vdouble_rvvm1_sleef Sleef_sqrtdx_u05rvvm1(vdouble_rvvm1_sleef d) { + + vdouble_rvvm1_sleef q, w, x, y, z; + + d = vsel_vd_vo_vd_vd_rvvm1_sleef(vlt_vo_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(0)), vcast_vd_d_rvvm1_sleef(__builtin_nan("")), d); + + rvv_dp_vopmask_rvvm1_sleef o = vlt_vo_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(8.636168555094445E-78)); + d = vsel_vd_vo_vd_vd_rvvm1_sleef(o, vmul_vd_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(1.157920892373162E77)), d); + q = vsel_vd_vo_vd_vd_rvvm1_sleef(o, vcast_vd_d_rvvm1_sleef(2.9387358770557188E-39), vcast_vd_d_rvvm1_sleef(1)); + + y = vreinterpret_vd_vm_rvvm1_sleef(vsub64_vm_vm_vm_rvvm1_sleef(vcast_vm_i_i_rvvm1_sleef(0x5fe6ec85, 0xe7de30da), vsrl64_vm_vm_i(vreinterpret_vm_vd_rvvm1_sleef(d), 1))); + + x = vmul_vd_vd_vd_rvvm1_sleef(d, y); w = vmul_vd_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(0.5), y); + y = vfmanp_vd_vd_vd_vd_rvvm1_sleef(x, w, vcast_vd_d_rvvm1_sleef(0.5)); + x = vfma_vd_vd_vd_vd_rvvm1_sleef(x, y, x); w = vfma_vd_vd_vd_vd_rvvm1_sleef(w, y, w); + y = vfmanp_vd_vd_vd_vd_rvvm1_sleef(x, w, vcast_vd_d_rvvm1_sleef(0.5)); + x = vfma_vd_vd_vd_vd_rvvm1_sleef(x, y, x); w = vfma_vd_vd_vd_vd_rvvm1_sleef(w, y, w); + y = vfmanp_vd_vd_vd_vd_rvvm1_sleef(x, w, vcast_vd_d_rvvm1_sleef(0.5)); + x = vfma_vd_vd_vd_vd_rvvm1_sleef(x, y, x); w = vfma_vd_vd_vd_vd_rvvm1_sleef(w, y, w); + + y = vfmanp_vd_vd_vd_vd_rvvm1_sleef(x, w, vcast_vd_d_rvvm1_sleef(1.5)); w = vadd_vd_vd_vd_rvvm1_sleef(w, w); + w = vmul_vd_vd_vd_rvvm1_sleef(w, y); + x = vmul_vd_vd_vd_rvvm1_sleef(w, d); + y = vfmapn_vd_vd_vd_vd_rvvm1_sleef(w, d, x); z = vfmanp_vd_vd_vd_vd_rvvm1_sleef(w, x, vcast_vd_d_rvvm1_sleef(1)); + + z = vfmanp_vd_vd_vd_vd_rvvm1_sleef(w, y, z); w = vmul_vd_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(0.5), x); + w = vfma_vd_vd_vd_vd_rvvm1_sleef(w, z, y); + w = vadd_vd_vd_vd_rvvm1_sleef(w, x); + + w = vmul_vd_vd_vd_rvvm1_sleef(w, q); + + w = vsel_vd_vo_vd_vd_rvvm1_sleef(rvv_dp_vor_vo_vo_vo(veq_vo_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(0)), + veq_vo_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(__builtin_inf()))), d, w); + + w = vsel_vd_vo_vd_vd_rvvm1_sleef(vlt_vo_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(0)), vcast_vd_d_rvvm1_sleef(__builtin_nan("")), w); + + return w; + +} + +SLEEF_INLINE SLEEF_CONST vdouble_rvvm1_sleef Sleef_sqrtdx_rvvm1(vdouble_rvvm1_sleef d) { + + return Sleef_sqrtdx_u05rvvm1(d); + +} + +SLEEF_INLINE SLEEF_CONST vdouble_rvvm1_sleef Sleef_sqrtdx_u35rvvm1(vdouble_rvvm1_sleef d) { return Sleef_sqrtdx_u05rvvm1(d); } + +SLEEF_INLINE SLEEF_CONST vdouble_rvvm1_sleef Sleef_hypotdx_u05rvvm1(vdouble_rvvm1_sleef x, vdouble_rvvm1_sleef y) { + x = vabs_vd_vd_rvvm1_sleef(x); + y = vabs_vd_vd_rvvm1_sleef(y); + vdouble_rvvm1_sleef min = vmin_vd_vd_vd_rvvm1_sleef(x, y), n = min; + vdouble_rvvm1_sleef max = vmax_vd_vd_vd_rvvm1_sleef(x, y), d = max; + + rvv_dp_vopmask_rvvm1_sleef o = vlt_vo_vd_vd_rvvm1_sleef(max, vcast_vd_d_rvvm1_sleef(0x1p-1022)); + n = vsel_vd_vo_vd_vd_rvvm1_sleef(o, vmul_vd_vd_vd_rvvm1_sleef(n, vcast_vd_d_rvvm1_sleef(UINT64_C(1) << 54)), n); + d = vsel_vd_vo_vd_vd_rvvm1_sleef(o, vmul_vd_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(UINT64_C(1) << 54)), d); + + vdouble2_rvvm1_sleef t = dddiv_vd2_vd2_vd2_rvvm1_sleef(vcast_vd2_vd_vd_rvvm1_sleef(n, vcast_vd_d_rvvm1_sleef(0)), vcast_vd2_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(0))); + t = ddmul_vd2_vd2_vd_rvvm1_sleef(ddsqrt_vd2_vd2_rvvm1_sleef(ddadd2_vd2_vd2_vd_rvvm1_sleef(ddsqu_vd2_vd2_rvvm1_sleef(t), vcast_vd_d_rvvm1_sleef(1))), max); + vdouble_rvvm1_sleef ret = vadd_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(t), vd2gety_vd_vd2_rvvm1_sleef(t)); + ret = vsel_vd_vo_vd_vd_rvvm1_sleef(visnan_vo_vd_rvvm1_sleef(ret), vcast_vd_d_rvvm1_sleef(__builtin_inf()), ret); + ret = vsel_vd_vo_vd_vd_rvvm1_sleef(veq_vo_vd_vd_rvvm1_sleef(min, vcast_vd_d_rvvm1_sleef(0)), max, ret); + ret = vsel_vd_vo_vd_vd_rvvm1_sleef(rvv_dp_vor_vo_vo_vo(visnan_vo_vd_rvvm1_sleef(x), visnan_vo_vd_rvvm1_sleef(y)), vcast_vd_d_rvvm1_sleef(__builtin_nan("")), ret); + ret = vsel_vd_vo_vd_vd_rvvm1_sleef(rvv_dp_vor_vo_vo_vo(veq_vo_vd_vd_rvvm1_sleef(x, vcast_vd_d_rvvm1_sleef(__builtin_inf())), veq_vo_vd_vd_rvvm1_sleef(y, vcast_vd_d_rvvm1_sleef(__builtin_inf()))), vcast_vd_d_rvvm1_sleef(__builtin_inf()), ret); + + return ret; +} + +SLEEF_INLINE SLEEF_CONST vdouble_rvvm1_sleef Sleef_hypotdx_u35rvvm1(vdouble_rvvm1_sleef x, vdouble_rvvm1_sleef y) { + x = vabs_vd_vd_rvvm1_sleef(x); + y = vabs_vd_vd_rvvm1_sleef(y); + vdouble_rvvm1_sleef min = vmin_vd_vd_vd_rvvm1_sleef(x, y); + vdouble_rvvm1_sleef max = vmax_vd_vd_vd_rvvm1_sleef(x, y); + + vdouble_rvvm1_sleef t = vdiv_vd_vd_vd_rvvm1_sleef(min, max); + vdouble_rvvm1_sleef ret = vmul_vd_vd_vd_rvvm1_sleef(max, vsqrt_vd_vd_rvvm1_sleef(vmla_vd_vd_vd_vd_rvvm1_sleef(t, t, vcast_vd_d_rvvm1_sleef(1)))); + ret = vsel_vd_vo_vd_vd_rvvm1_sleef(veq_vo_vd_vd_rvvm1_sleef(min, vcast_vd_d_rvvm1_sleef(0)), max, ret); + ret = vsel_vd_vo_vd_vd_rvvm1_sleef(rvv_dp_vor_vo_vo_vo(visnan_vo_vd_rvvm1_sleef(x), visnan_vo_vd_rvvm1_sleef(y)), vcast_vd_d_rvvm1_sleef(__builtin_nan("")), ret); + ret = vsel_vd_vo_vd_vd_rvvm1_sleef(rvv_dp_vor_vo_vo_vo(veq_vo_vd_vd_rvvm1_sleef(x, vcast_vd_d_rvvm1_sleef(__builtin_inf())), veq_vo_vd_vd_rvvm1_sleef(y, vcast_vd_d_rvvm1_sleef(__builtin_inf()))), vcast_vd_d_rvvm1_sleef(__builtin_inf()), ret); + + return ret; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_rvvm1_sleef vptrunc_vd_vd_rvvm1_sleef(vdouble_rvvm1_sleef x) { + + vdouble_rvvm1_sleef fr = vmla_vd_vd_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(-(double)(INT64_C(1) << 31)), vcast_vd_vi_rvvm1_sleef(vtruncate_vi_vd_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(x, vcast_vd_d_rvvm1_sleef(1.0 / (INT64_C(1) << 31))))), x); + fr = vsub_vd_vd_vd_rvvm1_sleef(fr, vcast_vd_vi_rvvm1_sleef(vtruncate_vi_vd_rvvm1_sleef(fr))); + return vsel_vd_vo_vd_vd_rvvm1_sleef(vge_vo_vd_vd_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(x), vcast_vd_d_rvvm1_sleef(INT64_C(1) << 52)), x, vsub_vd_vd_vd_rvvm1_sleef(x, fr)); + +} + +SLEEF_INLINE SLEEF_CONST vdouble_rvvm1_sleef Sleef_fmoddx_rvvm1(vdouble_rvvm1_sleef x, vdouble_rvvm1_sleef y) { + vdouble_rvvm1_sleef n = vabs_vd_vd_rvvm1_sleef(x), d = vabs_vd_vd_rvvm1_sleef(y), s = vcast_vd_d_rvvm1_sleef(1), q; + rvv_dp_vopmask_rvvm1_sleef o = vlt_vo_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(0x1p-1022)); + n = vsel_vd_vo_vd_vd_rvvm1_sleef(o, vmul_vd_vd_vd_rvvm1_sleef(n, vcast_vd_d_rvvm1_sleef(UINT64_C(1) << 54)), n); + d = vsel_vd_vo_vd_vd_rvvm1_sleef(o, vmul_vd_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(UINT64_C(1) << 54)), d); + s = vsel_vd_vo_vd_vd_rvvm1_sleef(o, vmul_vd_vd_vd_rvvm1_sleef(s , vcast_vd_d_rvvm1_sleef(1.0 / (UINT64_C(1) << 54))), s); + vdouble2_rvvm1_sleef r = vcast_vd2_vd_vd_rvvm1_sleef(n, vcast_vd_d_rvvm1_sleef(0)); + vdouble_rvvm1_sleef rd = vtoward0_vd_vd_rvvm1_sleef(vrec_vd_vd_rvvm1_sleef(d)); + + for(int i=0;i<21;i++) { + q = vptrunc_vd_vd_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(vtoward0_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(r)), rd)); + + q = vsel_vd_vo_vd_vd_rvvm1_sleef(rvv_dp_vand_vo_vo_vo(vgt_vo_vd_vd_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(3), d), vd2getx_vd_vd2_rvvm1_sleef(r)), + vge_vo_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(r), d)), + vcast_vd_d_rvvm1_sleef(2), q); + q = vsel_vd_vo_vd_vd_rvvm1_sleef(rvv_dp_vand_vo_vo_vo(vgt_vo_vd_vd_rvvm1_sleef(vadd_vd_vd_vd_rvvm1_sleef(d, d), vd2getx_vd_vd2_rvvm1_sleef(r)), + vge_vo_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(r), d)), + vcast_vd_d_rvvm1_sleef(1), q); + r = ddnormalize_vd2_vd2_rvvm1_sleef(ddadd2_vd2_vd2_vd2_rvvm1_sleef(r, ddmul_vd2_vd_vd_rvvm1_sleef(q, vneg_vd_vd_rvvm1_sleef(d)))); + if (vtestallones_i_vo64_rvvm1_sleef(vlt_vo_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(r), d))) break; + } + + vdouble_rvvm1_sleef ret = vmul_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(r), s); + ret = vsel_vd_vo_vd_vd_rvvm1_sleef(veq_vo_vd_vd_rvvm1_sleef(vadd_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(r), vd2gety_vd_vd2_rvvm1_sleef(r)), d), vcast_vd_d_rvvm1_sleef(0), ret); + + ret = vmulsign_vd_vd_vd_rvvm1_sleef(ret, x); + + ret = vsel_vd_vo_vd_vd_rvvm1_sleef(vlt_vo_vd_vd_rvvm1_sleef(n, d), x, ret); + ret = vsel_vd_vo_vd_vd_rvvm1_sleef(veq_vo_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(0)), vcast_vd_d_rvvm1_sleef(__builtin_nan("")), ret); + + return ret; +} + +static SLEEF_ALWAYS_INLINE vdouble_rvvm1_sleef vrintk2_vd_vd_rvvm1_sleef(vdouble_rvvm1_sleef d) { + + vdouble_rvvm1_sleef c = vmulsign_vd_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(INT64_C(1) << 52), d); + return vsel_vd_vo_vd_vd_rvvm1_sleef(vgt_vo_vd_vd_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(d), vcast_vd_d_rvvm1_sleef(INT64_C(1) << 52)), + d, vorsign_vd_vd_vd_rvvm1_sleef(vsub_vd_vd_vd_rvvm1_sleef(vadd_vd_vd_vd_rvvm1_sleef(d, c), c), d)); + +} + +SLEEF_INLINE SLEEF_CONST vdouble_rvvm1_sleef Sleef_remainderdx_rvvm1(vdouble_rvvm1_sleef x, vdouble_rvvm1_sleef y) { + vdouble_rvvm1_sleef n = vabs_vd_vd_rvvm1_sleef(x), d = vabs_vd_vd_rvvm1_sleef(y), s = vcast_vd_d_rvvm1_sleef(1), q; + rvv_dp_vopmask_rvvm1_sleef o = vlt_vo_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(0x1p-1022*2)); + n = vsel_vd_vo_vd_vd_rvvm1_sleef(o, vmul_vd_vd_vd_rvvm1_sleef(n, vcast_vd_d_rvvm1_sleef(UINT64_C(1) << 54)), n); + d = vsel_vd_vo_vd_vd_rvvm1_sleef(o, vmul_vd_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(UINT64_C(1) << 54)), d); + s = vsel_vd_vo_vd_vd_rvvm1_sleef(o, vmul_vd_vd_vd_rvvm1_sleef(s , vcast_vd_d_rvvm1_sleef(1.0 / (UINT64_C(1) << 54))), s); + vdouble_rvvm1_sleef rd = vrec_vd_vd_rvvm1_sleef(d); + vdouble2_rvvm1_sleef r = vcast_vd2_vd_vd_rvvm1_sleef(n, vcast_vd_d_rvvm1_sleef(0)); + rvv_dp_vopmask_rvvm1_sleef qisodd = vneq_vo_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(0), vcast_vd_d_rvvm1_sleef(0)); + + for(int i=0;i<21;i++) { + q = vrintk2_vd_vd_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(r), rd)); + + q = vsel_vd_vo_vd_vd_rvvm1_sleef(vlt_vo_vd_vd_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(r)), vmul_vd_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(1.5))), vmulsign_vd_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(1.0), vd2getx_vd_vd2_rvvm1_sleef(r)), q); + q = vsel_vd_vo_vd_vd_rvvm1_sleef(rvv_dp_vor_vo_vo_vo(vlt_vo_vd_vd_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(r)), vmul_vd_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(0.5))), + rvv_dp_vandnot_vo_vo_vo(qisodd, veq_vo_vd_vd_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(r)), vmul_vd_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(0.5))))), + vcast_vd_d_rvvm1_sleef(0.0), q); + if (vtestallones_i_vo64_rvvm1_sleef(veq_vo_vd_vd_rvvm1_sleef(q, vcast_vd_d_rvvm1_sleef(0)))) break; + q = vsel_vd_vo_vd_vd_rvvm1_sleef(visinf_vo_vd_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(q, vneg_vd_vd_rvvm1_sleef(d))), vadd_vd_vd_vd_rvvm1_sleef(q, vmulsign_vd_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(-1), vd2getx_vd_vd2_rvvm1_sleef(r))), q); + qisodd = rvv_dp_vxor_vo_vo_vo(qisodd, visodd_vo_vd_rvvm1_sleef(q)); + r = ddnormalize_vd2_vd2_rvvm1_sleef(ddadd2_vd2_vd2_vd2_rvvm1_sleef(r, ddmul_vd2_vd_vd_rvvm1_sleef(q, vneg_vd_vd_rvvm1_sleef(d)))); + } + + vdouble_rvvm1_sleef ret = vmul_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(r), s); + ret = vmulsign_vd_vd_vd_rvvm1_sleef(ret, x); + ret = vsel_vd_vo_vd_vd_rvvm1_sleef(visinf_vo_vd_rvvm1_sleef(y), vsel_vd_vo_vd_vd_rvvm1_sleef(visinf_vo_vd_rvvm1_sleef(x), vcast_vd_d_rvvm1_sleef(__builtin_nan("")), x), ret); + ret = vsel_vd_vo_vd_vd_rvvm1_sleef(veq_vo_vd_vd_rvvm1_sleef(d, vcast_vd_d_rvvm1_sleef(0)), vcast_vd_d_rvvm1_sleef(__builtin_nan("")), ret); + return ret; +} + +static SLEEF_CONST dd2_rvvm1_sleef gammak_rvvm1_sleef(vdouble_rvvm1_sleef a) { + vdouble2_rvvm1_sleef clc = vcast_vd2_d_d_rvvm1_sleef(0, 0), clln = vcast_vd2_d_d_rvvm1_sleef(1, 0), clld = vcast_vd2_d_d_rvvm1_sleef(1, 0); + vdouble2_rvvm1_sleef x, y, z; + vdouble_rvvm1_sleef t, u; + + rvv_dp_vopmask_rvvm1_sleef otiny = vlt_vo_vd_vd_rvvm1_sleef(vabs_vd_vd_rvvm1_sleef(a), vcast_vd_d_rvvm1_sleef(1e-306)), oref = vlt_vo_vd_vd_rvvm1_sleef(a, vcast_vd_d_rvvm1_sleef(0.5)); + + x = vsel_vd2_vo_vd2_vd2_rvvm1_sleef(otiny, vcast_vd2_d_d_rvvm1_sleef(0, 0), + vsel_vd2_vo_vd2_vd2_rvvm1_sleef(oref, ddadd2_vd2_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(1), vneg_vd_vd_rvvm1_sleef(a)), + vcast_vd2_vd_vd_rvvm1_sleef(a, vcast_vd_d_rvvm1_sleef(0)))); + + rvv_dp_vopmask_rvvm1_sleef o0 = rvv_dp_vand_vo_vo_vo(vle_vo_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(0.5), vd2getx_vd_vd2_rvvm1_sleef(x)), vle_vo_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(x), vcast_vd_d_rvvm1_sleef(1.1))); + rvv_dp_vopmask_rvvm1_sleef o2 = vle_vo_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(2.3), vd2getx_vd_vd2_rvvm1_sleef(x)); + + y = ddnormalize_vd2_vd2_rvvm1_sleef(ddmul_vd2_vd2_vd2_rvvm1_sleef(ddadd2_vd2_vd2_vd_rvvm1_sleef(x, vcast_vd_d_rvvm1_sleef(1)), x)); + y = ddnormalize_vd2_vd2_rvvm1_sleef(ddmul_vd2_vd2_vd2_rvvm1_sleef(ddadd2_vd2_vd2_vd_rvvm1_sleef(x, vcast_vd_d_rvvm1_sleef(2)), y)); + y = ddnormalize_vd2_vd2_rvvm1_sleef(ddmul_vd2_vd2_vd2_rvvm1_sleef(ddadd2_vd2_vd2_vd_rvvm1_sleef(x, vcast_vd_d_rvvm1_sleef(3)), y)); + y = ddnormalize_vd2_vd2_rvvm1_sleef(ddmul_vd2_vd2_vd2_rvvm1_sleef(ddadd2_vd2_vd2_vd_rvvm1_sleef(x, vcast_vd_d_rvvm1_sleef(4)), y)); + + rvv_dp_vopmask_rvvm1_sleef o = rvv_dp_vand_vo_vo_vo(o2, vle_vo_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(x), vcast_vd_d_rvvm1_sleef(7))); + clln = vsel_vd2_vo_vd2_vd2_rvvm1_sleef(o, y, clln); + + x = vsel_vd2_vo_vd2_vd2_rvvm1_sleef(o, ddadd2_vd2_vd2_vd_rvvm1_sleef(x, vcast_vd_d_rvvm1_sleef(5)), x); + + t = vsel_vd_vo_vd_vd_rvvm1_sleef(o2, vrec_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(x)), vd2getx_vd_vd2_rvvm1_sleef(ddnormalize_vd2_vd2_rvvm1_sleef(ddadd2_vd2_vd2_vd_rvvm1_sleef(x, vsel_vd_vo_d_d_rvvm1_sleef(o0, -1, -2))))); + + u = vsel_vd_vo_vo_d_d_d_rvvm1_sleef(o2, o0, -156.801412704022726379848862, +0.2947916772827614196e+2, +0.7074816000864609279e-7); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, t, vsel_vd_vo_vo_d_d_d_rvvm1_sleef(o2, o0, +1.120804464289911606838558160000, +0.1281459691827820109e+3, +0.4009244333008730443e-6)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, t, vsel_vd_vo_vo_d_d_d_rvvm1_sleef(o2, o0, +13.39798545514258921833306020000, +0.2617544025784515043e+3, +0.1040114641628246946e-5)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, t, vsel_vd_vo_vo_d_d_d_rvvm1_sleef(o2, o0, -0.116546276599463200848033357000, +0.3287022855685790432e+3, +0.1508349150733329167e-5)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, t, vsel_vd_vo_vo_d_d_d_rvvm1_sleef(o2, o0, -1.391801093265337481495562410000, +0.2818145867730348186e+3, +0.1288143074933901020e-5)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, t, vsel_vd_vo_vo_d_d_d_rvvm1_sleef(o2, o0, +0.015056113040026424412918973400, +0.1728670414673559605e+3, +0.4744167749884993937e-6)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, t, vsel_vd_vo_vo_d_d_d_rvvm1_sleef(o2, o0, +0.179540117061234856098844714000, +0.7748735764030416817e+2, -0.6554816306542489902e-7)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, t, vsel_vd_vo_vo_d_d_d_rvvm1_sleef(o2, o0, -0.002481743600264997730942489280, +0.2512856643080930752e+2, -0.3189252471452599844e-6)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, t, vsel_vd_vo_vo_d_d_d_rvvm1_sleef(o2, o0, -0.029527880945699120504851034100, +0.5766792106140076868e+1, +0.1358883821470355377e-6)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, t, vsel_vd_vo_vo_d_d_d_rvvm1_sleef(o2, o0, +0.000540164767892604515196325186, +0.7270275473996180571e+0, -0.4343931277157336040e-6)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, t, vsel_vd_vo_vo_d_d_d_rvvm1_sleef(o2, o0, +0.006403362833808069794787256200, +0.8396709124579147809e-1, +0.9724785897406779555e-6)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, t, vsel_vd_vo_vo_d_d_d_rvvm1_sleef(o2, o0, -0.000162516262783915816896611252, -0.8211558669746804595e-1, -0.2036886057225966011e-5)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, t, vsel_vd_vo_vo_d_d_d_rvvm1_sleef(o2, o0, -0.001914438498565477526465972390, +0.6828831828341884458e-1, +0.4373363141819725815e-5)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, t, vsel_vd_vo_vo_d_d_d_rvvm1_sleef(o2, o0, +7.20489541602001055898311517e-05, -0.7712481339961671511e-1, -0.9439951268304008677e-5)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, t, vsel_vd_vo_vo_d_d_d_rvvm1_sleef(o2, o0, +0.000839498720672087279971000786, +0.8337492023017314957e-1, +0.2050727030376389804e-4)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, t, vsel_vd_vo_vo_d_d_d_rvvm1_sleef(o2, o0, -5.17179090826059219329394422e-05, -0.9094964931456242518e-1, -0.4492620183431184018e-4)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, t, vsel_vd_vo_vo_d_d_d_rvvm1_sleef(o2, o0, -0.000592166437353693882857342347, +0.1000996313575929358e+0, +0.9945751236071875931e-4)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, t, vsel_vd_vo_vo_d_d_d_rvvm1_sleef(o2, o0, +6.97281375836585777403743539e-05, -0.1113342861544207724e+0, -0.2231547599034983196e-3)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, t, vsel_vd_vo_vo_d_d_d_rvvm1_sleef(o2, o0, +0.000784039221720066627493314301, +0.1255096673213020875e+0, +0.5096695247101967622e-3)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, t, vsel_vd_vo_vo_d_d_d_rvvm1_sleef(o2, o0, -0.000229472093621399176949318732, -0.1440498967843054368e+0, -0.1192753911667886971e-2)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, t, vsel_vd_vo_vo_d_d_d_rvvm1_sleef(o2, o0, -0.002681327160493827160473958490, +0.1695571770041949811e+0, +0.2890510330742210310e-2)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, t, vsel_vd_vo_vo_d_d_d_rvvm1_sleef(o2, o0, +0.003472222222222222222175164840, -0.2073855510284092762e+0, -0.7385551028674461858e-2)); + u = vmla_vd_vd_vd_vd_rvvm1_sleef(u, t, vsel_vd_vo_vo_d_d_d_rvvm1_sleef(o2, o0, +0.083333333333333333335592087900, +0.2705808084277815939e+0, +0.2058080842778455335e-1)); + + y = ddmul_vd2_vd2_vd2_rvvm1_sleef(ddadd2_vd2_vd2_vd_rvvm1_sleef(x, vcast_vd_d_rvvm1_sleef(-0.5)), logk2_rvvm1_sleef(x)); + y = ddadd2_vd2_vd2_vd2_rvvm1_sleef(y, ddneg_vd2_vd2_rvvm1_sleef(x)); + y = ddadd2_vd2_vd2_vd2_rvvm1_sleef(y, vcast_vd2_d_d_rvvm1_sleef(0.91893853320467278056, -3.8782941580672414498e-17)); + + z = ddadd2_vd2_vd2_vd_rvvm1_sleef(ddmul_vd2_vd_vd_rvvm1_sleef (u, t), vsel_vd_vo_d_d_rvvm1_sleef(o0, -0.4006856343865314862e+0, -0.6735230105319810201e-1)); + z = ddadd2_vd2_vd2_vd_rvvm1_sleef(ddmul_vd2_vd2_vd_rvvm1_sleef(z, t), vsel_vd_vo_d_d_rvvm1_sleef(o0, +0.8224670334241132030e+0, +0.3224670334241132030e+0)); + z = ddadd2_vd2_vd2_vd_rvvm1_sleef(ddmul_vd2_vd2_vd_rvvm1_sleef(z, t), vsel_vd_vo_d_d_rvvm1_sleef(o0, -0.5772156649015328655e+0, +0.4227843350984671345e+0)); + z = ddmul_vd2_vd2_vd_rvvm1_sleef(z, t); + + clc = vsel_vd2_vo_vd2_vd2_rvvm1_sleef(o2, y, z); + + clld = vsel_vd2_vo_vd2_vd2_rvvm1_sleef(o2, ddadd2_vd2_vd2_vd_rvvm1_sleef(ddmul_vd2_vd_vd_rvvm1_sleef(u, t), vcast_vd_d_rvvm1_sleef(1)), clld); + + y = clln; + + clc = vsel_vd2_vo_vd2_vd2_rvvm1_sleef(otiny, vcast_vd2_d_d_rvvm1_sleef(83.1776616671934334590333, 3.67103459631568507221878e-15), + vsel_vd2_vo_vd2_vd2_rvvm1_sleef(oref, ddadd2_vd2_vd2_vd2_rvvm1_sleef(vcast_vd2_d_d_rvvm1_sleef(1.1447298858494001639, 1.026595116270782638e-17), ddneg_vd2_vd2_rvvm1_sleef(clc)), clc)); + clln = vsel_vd2_vo_vd2_vd2_rvvm1_sleef(otiny, vcast_vd2_d_d_rvvm1_sleef(1, 0), vsel_vd2_vo_vd2_vd2_rvvm1_sleef(oref, clln, clld)); + + if (!vtestallones_i_vo64_rvvm1_sleef(vnot_vo64_vo64_rvvm1_sleef(oref))) { + t = vsub_vd_vd_vd_rvvm1_sleef(a, vmul_vd_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(INT64_C(1) << 28), vcast_vd_vi_rvvm1_sleef(vtruncate_vi_vd_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(a, vcast_vd_d_rvvm1_sleef(1.0 / (INT64_C(1) << 28))))))); + x = ddmul_vd2_vd2_vd2_rvvm1_sleef(clld, sinpik_rvvm1_sleef(t)); + } + + clld = vsel_vd2_vo_vd2_vd2_rvvm1_sleef(otiny, vcast_vd2_vd_vd_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(a, vcast_vd_d_rvvm1_sleef((INT64_C(1) << 60)*(double)(INT64_C(1) << 60))), vcast_vd_d_rvvm1_sleef(0)), + vsel_vd2_vo_vd2_vd2_rvvm1_sleef(oref, x, y)); + + return dd2setab_dd2_vd2_vd2_rvvm1_sleef(clc, dddiv_vd2_vd2_vd2_rvvm1_sleef(clln, clld)); +} + +SLEEF_INLINE SLEEF_CONST vdouble_rvvm1_sleef Sleef_tgammadx_u10rvvm1(vdouble_rvvm1_sleef a) { + dd2_rvvm1_sleef d = gammak_rvvm1_sleef(a); + vdouble2_rvvm1_sleef y = ddmul_vd2_vd2_vd2_rvvm1_sleef(expk2_rvvm1_sleef(dd2geta_vd2_dd2_rvvm1_sleef(d)), dd2getb_vd2_dd2_rvvm1_sleef(d)); + vdouble_rvvm1_sleef r = vadd_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(y), vd2gety_vd_vd2_rvvm1_sleef(y)); + rvv_dp_vopmask_rvvm1_sleef o; + + o = rvv_dp_vor_vo_vo_vo(rvv_dp_vor_vo_vo_vo(veq_vo_vd_vd_rvvm1_sleef(a, vcast_vd_d_rvvm1_sleef(-__builtin_inf())), + rvv_dp_vand_vo_vo_vo(vlt_vo_vd_vd_rvvm1_sleef(a, vcast_vd_d_rvvm1_sleef(0)), visint_vo_vd_rvvm1_sleef(a))), + rvv_dp_vand_vo_vo_vo(rvv_dp_vand_vo_vo_vo(visnumber_vo_vd_rvvm1_sleef(a), vlt_vo_vd_vd_rvvm1_sleef(a, vcast_vd_d_rvvm1_sleef(0))), visnan_vo_vd_rvvm1_sleef(r))); + r = vsel_vd_vo_vd_vd_rvvm1_sleef(o, vcast_vd_d_rvvm1_sleef(__builtin_nan("")), r); + + o = rvv_dp_vand_vo_vo_vo(rvv_dp_vand_vo_vo_vo(rvv_dp_vor_vo_vo_vo(veq_vo_vd_vd_rvvm1_sleef(a, vcast_vd_d_rvvm1_sleef(__builtin_inf())), visnumber_vo_vd_rvvm1_sleef(a)), + vge_vo_vd_vd_rvvm1_sleef(a, vcast_vd_d_rvvm1_sleef(-0x1p-1022))), + rvv_dp_vor_vo_vo_vo(rvv_dp_vor_vo_vo_vo(veq_vo_vd_vd_rvvm1_sleef(a, vcast_vd_d_rvvm1_sleef(0)), vgt_vo_vd_vd_rvvm1_sleef(a, vcast_vd_d_rvvm1_sleef(200))), visnan_vo_vd_rvvm1_sleef(r))); + r = vsel_vd_vo_vd_vd_rvvm1_sleef(o, vmulsign_vd_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(__builtin_inf()), a), r); + + return r; +} + +SLEEF_INLINE SLEEF_CONST vdouble_rvvm1_sleef Sleef_lgammadx_u10rvvm1(vdouble_rvvm1_sleef a) { + dd2_rvvm1_sleef d = gammak_rvvm1_sleef(a); + vdouble2_rvvm1_sleef y = ddadd2_vd2_vd2_vd2_rvvm1_sleef(dd2geta_vd2_dd2_rvvm1_sleef(d), logk2_rvvm1_sleef(ddabs_vd2_vd2_rvvm1_sleef(dd2getb_vd2_dd2_rvvm1_sleef(d)))); + vdouble_rvvm1_sleef r = vadd_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(y), vd2gety_vd_vd2_rvvm1_sleef(y)); + rvv_dp_vopmask_rvvm1_sleef o; + + o = rvv_dp_vor_vo_vo_vo(visinf_vo_vd_rvvm1_sleef(a), + rvv_dp_vor_vo_vo_vo(rvv_dp_vand_vo_vo_vo(vle_vo_vd_vd_rvvm1_sleef(a, vcast_vd_d_rvvm1_sleef(0)), visint_vo_vd_rvvm1_sleef(a)), + rvv_dp_vand_vo_vo_vo(visnumber_vo_vd_rvvm1_sleef(a), visnan_vo_vd_rvvm1_sleef(r)))); + r = vsel_vd_vo_vd_vd_rvvm1_sleef(o, vcast_vd_d_rvvm1_sleef(__builtin_inf()), r); + + return r; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_rvvm1_sleef ddmla_vd2_vd_vd2_vd2_rvvm1_sleef(vdouble_rvvm1_sleef x, vdouble2_rvvm1_sleef y, vdouble2_rvvm1_sleef z) { + return ddadd_vd2_vd2_vd2_rvvm1_sleef(z, ddmul_vd2_vd2_vd_rvvm1_sleef(y, x)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_rvvm1_sleef poly2dd_b_rvvm1_sleef(vdouble_rvvm1_sleef x, vdouble2_rvvm1_sleef c1, vdouble2_rvvm1_sleef c0) { return ddmla_vd2_vd_vd2_vd2_rvvm1_sleef(x, c1, c0); } +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_rvvm1_sleef poly2dd_rvvm1_sleef(vdouble_rvvm1_sleef x, vdouble_rvvm1_sleef c1, vdouble2_rvvm1_sleef c0) { return ddmla_vd2_vd_vd2_vd2_rvvm1_sleef(x, vcast_vd2_vd_vd_rvvm1_sleef(c1, vcast_vd_d_rvvm1_sleef(0)), c0); } +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_rvvm1_sleef poly4dd_rvvm1_sleef(vdouble_rvvm1_sleef x, vdouble_rvvm1_sleef c3, vdouble2_rvvm1_sleef c2, vdouble2_rvvm1_sleef c1, vdouble2_rvvm1_sleef c0) { + return ddmla_vd2_vd_vd2_vd2_rvvm1_sleef(vmul_vd_vd_vd_rvvm1_sleef(x, x), poly2dd_rvvm1_sleef(x, c3, c2), poly2dd_b_rvvm1_sleef(x, c1, c0)); +} + +SLEEF_INLINE SLEEF_CONST vdouble_rvvm1_sleef Sleef_erfdx_u10rvvm1(vdouble_rvvm1_sleef a) { + vdouble_rvvm1_sleef t, x = vabs_vd_vd_rvvm1_sleef(a); + vdouble2_rvvm1_sleef t2; + vdouble_rvvm1_sleef x2 = vmul_vd_vd_vd_rvvm1_sleef(x, x), x4 = vmul_vd_vd_vd_rvvm1_sleef(x2, x2); + vdouble_rvvm1_sleef x8 = vmul_vd_vd_vd_rvvm1_sleef(x4, x4), x16 = vmul_vd_vd_vd_rvvm1_sleef(x8, x8); + rvv_dp_vopmask_rvvm1_sleef o25 = vle_vo_vd_vd_rvvm1_sleef(x, vcast_vd_d_rvvm1_sleef(2.5)); + + if (__builtin_expect(!!(vtestallones_i_vo64_rvvm1_sleef(o25)), 1)) { + + t = vmla_vd_vd_vd_vd_rvvm1_sleef((x16), (vmla_vd_vd_vd_vd_rvvm1_sleef((x4), (vcast_vd_d_rvvm1_sleef(-0.2083271002525222097e-14)), (vmla_vd_vd_vd_vd_rvvm1_sleef((x2), (vmla_vd_vd_vd_vd_rvvm1_sleef((x), (vcast_vd_d_rvvm1_sleef(+0.7151909970790897009e-13)), (vcast_vd_d_rvvm1_sleef(-0.1162238220110999364e-11)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((x), (vcast_vd_d_rvvm1_sleef(+0.1186474230821585259e-10)), (vcast_vd_d_rvvm1_sleef(-0.8499973178354613440e-10)))))))), (vmla_vd_vd_vd_vd_rvvm1_sleef((x8), (vmla_vd_vd_vd_vd_rvvm1_sleef((x4), (vmla_vd_vd_vd_vd_rvvm1_sleef((x2), (vmla_vd_vd_vd_vd_rvvm1_sleef((x), (vcast_vd_d_rvvm1_sleef(+0.4507647462598841629e-9)), (vcast_vd_d_rvvm1_sleef(-0.1808044474288848915e-8)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((x), (vcast_vd_d_rvvm1_sleef(+0.5435081826716212389e-8)), (vcast_vd_d_rvvm1_sleef(-0.1143939895758628484e-7)))))), (vmla_vd_vd_vd_vd_rvvm1_sleef((x2), (vmla_vd_vd_vd_vd_rvvm1_sleef((x), (vcast_vd_d_rvvm1_sleef(+0.1215442362680889243e-7)), (vcast_vd_d_rvvm1_sleef(+0.1669878756181250355e-7)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((x), (vcast_vd_d_rvvm1_sleef(-0.9808074602255194288e-7)), (vcast_vd_d_rvvm1_sleef(+0.1389000557865837204e-6)))))))), (vmla_vd_vd_vd_vd_rvvm1_sleef((x4), (vmla_vd_vd_vd_vd_rvvm1_sleef((x2), (vmla_vd_vd_vd_vd_rvvm1_sleef((x), (vcast_vd_d_rvvm1_sleef(+0.2945514529987331866e-6)), (vcast_vd_d_rvvm1_sleef(-0.1842918273003998283e-5)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((x), (vcast_vd_d_rvvm1_sleef(+0.3417987836115362136e-5)), (vcast_vd_d_rvvm1_sleef(+0.3860236356493129101e-5)))))), (vmla_vd_vd_vd_vd_rvvm1_sleef((x2), (vmla_vd_vd_vd_vd_rvvm1_sleef((x), (vcast_vd_d_rvvm1_sleef(-0.3309403072749947546e-4)), (vcast_vd_d_rvvm1_sleef(+0.1060862922597579532e-3)))), (vmla_vd_vd_vd_vd_rvvm1_sleef((x), (vcast_vd_d_rvvm1_sleef(+0.2323253155213076174e-3)), (vcast_vd_d_rvvm1_sleef(+0.1490149719145544729e-3))))))))))) + + ; + t2 = poly4dd_rvvm1_sleef(x, t, + vcast_vd2_d_d_rvvm1_sleef(0.0092877958392275604405, 7.9287559463961107493e-19), + vcast_vd2_d_d_rvvm1_sleef(0.042275531758784692937, 1.3785226620501016138e-19), + vcast_vd2_d_d_rvvm1_sleef(0.07052369794346953491, 9.5846628070792092842e-19)); + t2 = ddadd_vd2_vd_vd2_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(1), ddmul_vd2_vd2_vd_rvvm1_sleef(t2, x)); + t2 = ddsqu_vd2_vd2_rvvm1_sleef(t2); + t2 = ddsqu_vd2_vd2_rvvm1_sleef(t2); + t2 = ddsqu_vd2_vd2_rvvm1_sleef(t2); + t2 = ddsqu_vd2_vd2_rvvm1_sleef(t2); + t2 = ddrec_vd2_vd2_rvvm1_sleef(t2); + } else { + + t = vmla_vd_vd_vd_vd_rvvm1_sleef((x16), (vmla_vd_vd_vd_vd_rvvm1_sleef((x4), ((vsel_vd_vo_d_d_rvvm1_sleef(o25, -0.2083271002525222097e-14, -0.4024015130752621932e-18))), (vmla_vd_vd_vd_vd_rvvm1_sleef((x2), (vmla_vd_vd_vd_vd_rvvm1_sleef((x), ((vsel_vd_vo_d_d_rvvm1_sleef(o25, +0.7151909970790897009e-13, +0.3847193332817048172e-16))), ((vsel_vd_vo_d_d_rvvm1_sleef(o25, -0.1162238220110999364e-11, -0.1749316241455644088e-14))))), (vmla_vd_vd_vd_vd_rvvm1_sleef((x), ((vsel_vd_vo_d_d_rvvm1_sleef(o25, +0.1186474230821585259e-10, +0.5029618322872872715e-13))), ((vsel_vd_vo_d_d_rvvm1_sleef(o25, -0.8499973178354613440e-10, -0.1025221466851463164e-11))))))))), (vmla_vd_vd_vd_vd_rvvm1_sleef((x8), (vmla_vd_vd_vd_vd_rvvm1_sleef((x4), (vmla_vd_vd_vd_vd_rvvm1_sleef((x2), (vmla_vd_vd_vd_vd_rvvm1_sleef((x), ((vsel_vd_vo_d_d_rvvm1_sleef(o25, +0.4507647462598841629e-9, +0.1573695559331945583e-10))), ((vsel_vd_vo_d_d_rvvm1_sleef(o25, -0.1808044474288848915e-8, -0.1884658558040203709e-9))))), (vmla_vd_vd_vd_vd_rvvm1_sleef((x), ((vsel_vd_vo_d_d_rvvm1_sleef(o25, +0.5435081826716212389e-8, +0.1798167853032159309e-8))), ((vsel_vd_vo_d_d_rvvm1_sleef(o25, -0.1143939895758628484e-7, -0.1380745342355033142e-7))))))), (vmla_vd_vd_vd_vd_rvvm1_sleef((x2), (vmla_vd_vd_vd_vd_rvvm1_sleef((x), ((vsel_vd_vo_d_d_rvvm1_sleef(o25, +0.1215442362680889243e-7, +0.8525705726469103499e-7))), ((vsel_vd_vo_d_d_rvvm1_sleef(o25, +0.1669878756181250355e-7, -0.4160448058101303405e-6))))), (vmla_vd_vd_vd_vd_rvvm1_sleef((x), ((vsel_vd_vo_d_d_rvvm1_sleef(o25, -0.9808074602255194288e-7, +0.1517272660008588485e-5))), ((vsel_vd_vo_d_d_rvvm1_sleef(o25, +0.1389000557865837204e-6, -0.3341634127317201697e-5))))))))), (vmla_vd_vd_vd_vd_rvvm1_sleef((x4), (vmla_vd_vd_vd_vd_rvvm1_sleef((x2), (vmla_vd_vd_vd_vd_rvvm1_sleef((x), ((vsel_vd_vo_d_d_rvvm1_sleef(o25, +0.2945514529987331866e-6, -0.2515023395879724513e-5))), ((vsel_vd_vo_d_d_rvvm1_sleef(o25, -0.1842918273003998283e-5, +0.6539731269664907554e-4))))), (vmla_vd_vd_vd_vd_rvvm1_sleef((x), ((vsel_vd_vo_d_d_rvvm1_sleef(o25, +0.3417987836115362136e-5, -0.3551065097428388658e-3))), ((vsel_vd_vo_d_d_rvvm1_sleef(o25, +0.3860236356493129101e-5, +0.1210736097958368864e-2))))))), (vmla_vd_vd_vd_vd_rvvm1_sleef((x2), (vmla_vd_vd_vd_vd_rvvm1_sleef((x), ((vsel_vd_vo_d_d_rvvm1_sleef(o25, -0.3309403072749947546e-4, -0.2605566912579998680e-2))), ((vsel_vd_vo_d_d_rvvm1_sleef(o25, +0.1060862922597579532e-3, +0.1252823202436093193e-2))))), (vmla_vd_vd_vd_vd_rvvm1_sleef((x), ((vsel_vd_vo_d_d_rvvm1_sleef(o25, +0.2323253155213076174e-3, +0.1820191395263313222e-1))), ((vsel_vd_vo_d_d_rvvm1_sleef(o25, +0.1490149719145544729e-3, -0.1021557155453465954e+0)))))))))))) + + ; + t2 = poly4dd_rvvm1_sleef(x, t, + vsel_vd2_vo_vd2_vd2_rvvm1_sleef(o25, vcast_vd2_d_d_rvvm1_sleef(0.0092877958392275604405, 7.9287559463961107493e-19), + vcast_vd2_d_d_rvvm1_sleef(-0.63691044383641748361, -2.4249477526539431839e-17)), + vsel_vd2_vo_vd2_vd2_rvvm1_sleef(o25, vcast_vd2_d_d_rvvm1_sleef(0.042275531758784692937, 1.3785226620501016138e-19), + vcast_vd2_d_d_rvvm1_sleef(-1.1282926061803961737, -6.2970338860410996505e-17)), + vsel_vd2_vo_vd2_vd2_rvvm1_sleef(o25, vcast_vd2_d_d_rvvm1_sleef(0.07052369794346953491, 9.5846628070792092842e-19), + vcast_vd2_d_d_rvvm1_sleef(-1.2261313785184804967e-05, -5.5329707514490107044e-22))); + vdouble2_rvvm1_sleef s2 = ddadd_vd2_vd_vd2_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(1), ddmul_vd2_vd2_vd_rvvm1_sleef(t2, x)); + s2 = ddsqu_vd2_vd2_rvvm1_sleef(s2); + s2 = ddsqu_vd2_vd2_rvvm1_sleef(s2); + s2 = ddsqu_vd2_vd2_rvvm1_sleef(s2); + s2 = ddsqu_vd2_vd2_rvvm1_sleef(s2); + s2 = ddrec_vd2_vd2_rvvm1_sleef(s2); + t2 = vsel_vd2_vo_vd2_vd2_rvvm1_sleef(o25, s2, vcast_vd2_vd_vd_rvvm1_sleef(expk_rvvm1_sleef(t2), vcast_vd_d_rvvm1_sleef(0))); + } + + t2 = ddadd2_vd2_vd2_vd_rvvm1_sleef(t2, vcast_vd_d_rvvm1_sleef(-1)); + + vdouble_rvvm1_sleef z = vneg_vd_vd_rvvm1_sleef(vadd_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(t2), vd2gety_vd_vd2_rvvm1_sleef(t2))); + z = vsel_vd_vo_vd_vd_rvvm1_sleef(vlt_vo_vd_vd_rvvm1_sleef(x, vcast_vd_d_rvvm1_sleef(1e-8)), vmul_vd_vd_vd_rvvm1_sleef(x, vcast_vd_d_rvvm1_sleef(1.12837916709551262756245475959)), z); + z = vsel_vd_vo_vd_vd_rvvm1_sleef(vge_vo_vd_vd_rvvm1_sleef(x, vcast_vd_d_rvvm1_sleef(6)), vcast_vd_d_rvvm1_sleef(1), z); + z = vsel_vd_vo_vd_vd_rvvm1_sleef(visinf_vo_vd_rvvm1_sleef(a), vcast_vd_d_rvvm1_sleef(1), z); + z = vsel_vd_vo_vd_vd_rvvm1_sleef(veq_vo_vd_vd_rvvm1_sleef(a, vcast_vd_d_rvvm1_sleef(0)), vcast_vd_d_rvvm1_sleef(0), z); + z = vmulsign_vd_vd_vd_rvvm1_sleef(z, a); + + return z; +} + +SLEEF_INLINE SLEEF_CONST vdouble_rvvm1_sleef Sleef_erfcdx_u15rvvm1(vdouble_rvvm1_sleef a) { + vdouble_rvvm1_sleef s = a, r = vcast_vd_d_rvvm1_sleef(0), t; + vdouble2_rvvm1_sleef u, d, x; + a = vabs_vd_vd_rvvm1_sleef(a); + rvv_dp_vopmask_rvvm1_sleef o0 = vlt_vo_vd_vd_rvvm1_sleef(a, vcast_vd_d_rvvm1_sleef(1.0)); + rvv_dp_vopmask_rvvm1_sleef o1 = vlt_vo_vd_vd_rvvm1_sleef(a, vcast_vd_d_rvvm1_sleef(2.2)); + rvv_dp_vopmask_rvvm1_sleef o2 = vlt_vo_vd_vd_rvvm1_sleef(a, vcast_vd_d_rvvm1_sleef(4.2)); + rvv_dp_vopmask_rvvm1_sleef o3 = vlt_vo_vd_vd_rvvm1_sleef(a, vcast_vd_d_rvvm1_sleef(27.3)); + + u = vsel_vd2_vo_vd2_vd2_rvvm1_sleef(o0, ddmul_vd2_vd_vd_rvvm1_sleef(a, a), vsel_vd2_vo_vd2_vd2_rvvm1_sleef(o1, vcast_vd2_vd_vd_rvvm1_sleef(a, vcast_vd_d_rvvm1_sleef(0)), dddiv_vd2_vd2_vd2_rvvm1_sleef(vcast_vd2_d_d_rvvm1_sleef(1, 0), vcast_vd2_vd_vd_rvvm1_sleef(a, vcast_vd_d_rvvm1_sleef(0))))); + + t = vsel_vd_vo_vo_vo_d_d_d_d_rvvm1_sleef(o0, o1, o2, +0.6801072401395386139e-20, +0.3438010341362585303e-12, -0.5757819536420710449e+2, +0.2334249729638701319e+5); + t = vmla_vd_vd_vd_vd_rvvm1_sleef(t, vd2getx_vd_vd2_rvvm1_sleef(u), vsel_vd_vo_vo_vo_d_d_d_d_rvvm1_sleef(o0, o1, o2, -0.2161766247570055669e-18, -0.1237021188160598264e-10, +0.4669289654498104483e+3, -0.4695661044933107769e+5)); + t = vmla_vd_vd_vd_vd_rvvm1_sleef(t, vd2getx_vd_vd2_rvvm1_sleef(u), vsel_vd_vo_vo_vo_d_d_d_d_rvvm1_sleef(o0, o1, o2, +0.4695919173301595670e-17, +0.2117985839877627852e-09, -0.1796329879461355858e+4, +0.3173403108748643353e+5)); + t = vmla_vd_vd_vd_vd_rvvm1_sleef(t, vd2getx_vd_vd2_rvvm1_sleef(u), vsel_vd_vo_vo_vo_d_d_d_d_rvvm1_sleef(o0, o1, o2, -0.9049140419888007122e-16, -0.2290560929177369506e-08, +0.4355892193699575728e+4, +0.3242982786959573787e+4)); + t = vmla_vd_vd_vd_vd_rvvm1_sleef(t, vd2getx_vd_vd2_rvvm1_sleef(u), vsel_vd_vo_vo_vo_d_d_d_d_rvvm1_sleef(o0, o1, o2, +0.1634018903557410728e-14, +0.1748931621698149538e-07, -0.7456258884965764992e+4, -0.2014717999760347811e+5)); + t = vmla_vd_vd_vd_vd_rvvm1_sleef(t, vd2getx_vd_vd2_rvvm1_sleef(u), vsel_vd_vo_vo_vo_d_d_d_d_rvvm1_sleef(o0, o1, o2, -0.2783485786333451745e-13, -0.9956602606623249195e-07, +0.9553977358167021521e+4, +0.1554006970967118286e+5)); + t = vmla_vd_vd_vd_vd_rvvm1_sleef(t, vd2getx_vd_vd2_rvvm1_sleef(u), vsel_vd_vo_vo_vo_d_d_d_d_rvvm1_sleef(o0, o1, o2, +0.4463221276786415752e-12, +0.4330010240640327080e-06, -0.9470019905444229153e+4, -0.6150874190563554293e+4)); + t = vmla_vd_vd_vd_vd_rvvm1_sleef(t, vd2getx_vd_vd2_rvvm1_sleef(u), vsel_vd_vo_vo_vo_d_d_d_d_rvvm1_sleef(o0, o1, o2, -0.6711366622850136563e-11, -0.1435050600991763331e-05, +0.7387344321849855078e+4, +0.1240047765634815732e+4)); + t = vmla_vd_vd_vd_vd_rvvm1_sleef(t, vd2getx_vd_vd2_rvvm1_sleef(u), vsel_vd_vo_vo_vo_d_d_d_d_rvvm1_sleef(o0, o1, o2, +0.9422759050232662223e-10, +0.3460139479650695662e-05, -0.4557713054166382790e+4, -0.8210325475752699731e+2)); + t = vmla_vd_vd_vd_vd_rvvm1_sleef(t, vd2getx_vd_vd2_rvvm1_sleef(u), vsel_vd_vo_vo_vo_d_d_d_d_rvvm1_sleef(o0, o1, o2, -0.1229055530100229098e-08, -0.4988908180632898173e-05, +0.2207866967354055305e+4, +0.3242443880839930870e+2)); + t = vmla_vd_vd_vd_vd_rvvm1_sleef(t, vd2getx_vd_vd2_rvvm1_sleef(u), vsel_vd_vo_vo_vo_d_d_d_d_rvvm1_sleef(o0, o1, o2, +0.1480719281585086512e-07, -0.1308775976326352012e-05, -0.8217975658621754746e+3, -0.2923418863833160586e+2)); + t = vmla_vd_vd_vd_vd_rvvm1_sleef(t, vd2getx_vd_vd2_rvvm1_sleef(u), vsel_vd_vo_vo_vo_d_d_d_d_rvvm1_sleef(o0, o1, o2, -0.1636584469123399803e-06, +0.2825086540850310103e-04, +0.2268659483507917400e+3, +0.3457461732814383071e+0)); + t = vmla_vd_vd_vd_vd_rvvm1_sleef(t, vd2getx_vd_vd2_rvvm1_sleef(u), vsel_vd_vo_vo_vo_d_d_d_d_rvvm1_sleef(o0, o1, o2, +0.1646211436588923575e-05, -0.6393913713069986071e-04, -0.4633361260318560682e+2, +0.5489730155952392998e+1)); + t = vmla_vd_vd_vd_vd_rvvm1_sleef(t, vd2getx_vd_vd2_rvvm1_sleef(u), vsel_vd_vo_vo_vo_d_d_d_d_rvvm1_sleef(o0, o1, o2, -0.1492565035840623511e-04, -0.2566436514695078926e-04, +0.9557380123733945965e+1, +0.1559934132251294134e-2)); + t = vmla_vd_vd_vd_vd_rvvm1_sleef(t, vd2getx_vd_vd2_rvvm1_sleef(u), vsel_vd_vo_vo_vo_d_d_d_d_rvvm1_sleef(o0, o1, o2, +0.1205533298178967851e-03, +0.5895792375659440364e-03, -0.2958429331939661289e+1, -0.1541741566831520638e+1)); + t = vmla_vd_vd_vd_vd_rvvm1_sleef(t, vd2getx_vd_vd2_rvvm1_sleef(u), vsel_vd_vo_vo_vo_d_d_d_d_rvvm1_sleef(o0, o1, o2, -0.8548327023450850081e-03, -0.1695715579163588598e-02, +0.1670329508092765480e+0, +0.2823152230558364186e-5)); + t = vmla_vd_vd_vd_vd_rvvm1_sleef(t, vd2getx_vd_vd2_rvvm1_sleef(u), vsel_vd_vo_vo_vo_d_d_d_d_rvvm1_sleef(o0, o1, o2, +0.5223977625442187932e-02, +0.2089116434918055149e-03, +0.6096615680115419211e+0, +0.6249999184195342838e+0)); + t = vmla_vd_vd_vd_vd_rvvm1_sleef(t, vd2getx_vd_vd2_rvvm1_sleef(u), vsel_vd_vo_vo_vo_d_d_d_d_rvvm1_sleef(o0, o1, o2, -0.2686617064513125222e-01, +0.1912855949584917753e-01, +0.1059212443193543585e-2, +0.1741749416408701288e-8)); + + d = ddmul_vd2_vd2_vd_rvvm1_sleef(u, t); + d = ddadd2_vd2_vd2_vd2_rvvm1_sleef(d, vcast_vd2_vd_vd_rvvm1_sleef(vsel_vd_vo_vo_vo_d_d_d_d_rvvm1_sleef(o0, o1, o2, 0.11283791670955126141, -0.10277263343147646779, -0.50005180473999022439, -0.5000000000258444377), + vsel_vd_vo_vo_vo_d_d_d_d_rvvm1_sleef(o0, o1, o2, -4.0175691625932118483e-18, -6.2338714083404900225e-18, 2.6362140569041995803e-17, -4.0074044712386992281e-17))); + d = ddmul_vd2_vd2_vd2_rvvm1_sleef(d, u); + d = ddadd2_vd2_vd2_vd2_rvvm1_sleef(d, vcast_vd2_vd_vd_rvvm1_sleef(vsel_vd_vo_vo_vo_d_d_d_d_rvvm1_sleef(o0, o1, o2, -0.37612638903183753802, -0.63661976742916359662, 1.601106273924963368e-06, 2.3761973137523364792e-13), + vsel_vd_vo_vo_vo_d_d_d_d_rvvm1_sleef(o0, o1, o2, 1.3391897206042552387e-17, 7.6321019159085724662e-18, 1.1974001857764476775e-23, -1.1670076950531026582e-29))); + d = ddmul_vd2_vd2_vd2_rvvm1_sleef(d, u); + d = ddadd2_vd2_vd2_vd2_rvvm1_sleef(d, vcast_vd2_vd_vd_rvvm1_sleef(vsel_vd_vo_vo_vo_d_d_d_d_rvvm1_sleef(o0, o1, o2, 1.1283791670955125586, -1.1283791674717296161, -0.57236496645145429341, -0.57236494292470108114), + vsel_vd_vo_vo_vo_d_d_d_d_rvvm1_sleef(o0, o1, o2, 1.5335459613165822674e-17, 8.0896847755965377194e-17, 3.0704553245872027258e-17, -2.3984352208056898003e-17))); + + x = ddmul_vd2_vd2_vd_rvvm1_sleef(vsel_vd2_vo_vd2_vd2_rvvm1_sleef(o1, d, vcast_vd2_vd_vd_rvvm1_sleef(vneg_vd_vd_rvvm1_sleef(a), vcast_vd_d_rvvm1_sleef(0))), a); + x = vsel_vd2_vo_vd2_vd2_rvvm1_sleef(o1, x, ddadd2_vd2_vd2_vd2_rvvm1_sleef(x, d)); + x = vsel_vd2_vo_vd2_vd2_rvvm1_sleef(o0, ddsub_vd2_vd2_vd2_rvvm1_sleef(vcast_vd2_d_d_rvvm1_sleef(1, 0), x), expk2_rvvm1_sleef(x)); + x = vsel_vd2_vo_vd2_vd2_rvvm1_sleef(o1, x, ddmul_vd2_vd2_vd2_rvvm1_sleef(x, u)); + + r = vsel_vd_vo_vd_vd_rvvm1_sleef(o3, vadd_vd_vd_vd_rvvm1_sleef(vd2getx_vd_vd2_rvvm1_sleef(x), vd2gety_vd_vd2_rvvm1_sleef(x)), vcast_vd_d_rvvm1_sleef(0)); + r = vsel_vd_vo_vd_vd_rvvm1_sleef(vsignbit_vo_vd_rvvm1_sleef(s), vsub_vd_vd_vd_rvvm1_sleef(vcast_vd_d_rvvm1_sleef(2), r), r); + r = vsel_vd_vo_vd_vd_rvvm1_sleef(visnan_vo_vd_rvvm1_sleef(s), vcast_vd_d_rvvm1_sleef(__builtin_nan("")), r); + return r; +} + +#if !defined(__NVCC__) && ((defined(__SIZEOF_FLOAT128__) && __SIZEOF_FLOAT128__ == 16) || (defined(__linux__) && defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))) || (defined(__PPC64__) && defined(__GNUC__) && !defined(__clang__) && __GNUC__ >= 8)) +#define SLEEF_FLOAT128_IS_IEEEQP +#endif + +#if !defined(SLEEF_FLOAT128_IS_IEEEQP) && !defined(__NVCC__) && defined(__SIZEOF_LONG_DOUBLE__) && __SIZEOF_LONG_DOUBLE__ == 16 && (defined(__aarch64__) || defined(__zarch__)) +#define SLEEF_LONGDOUBLE_IS_IEEEQP +#endif + +#if !defined(Sleef_quad_DEFINED) +#define Sleef_quad_DEFINED +typedef struct { uint64_t x, y; } Sleef_uint64_2t; +#if defined(SLEEF_FLOAT128_IS_IEEEQP) +typedef __float128 Sleef_quad; +#define SLEEF_QUAD_C(x) (x ## Q) +#elif defined(SLEEF_LONGDOUBLE_IS_IEEEQP) +typedef long double Sleef_quad; +#define SLEEF_QUAD_C(x) (x ## L) +#else +typedef Sleef_uint64_2t Sleef_quad; +#endif +#endif + +extern const float Sleef_rempitabsp[]; + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_rvvm1_sleef vupper_vf_vf_rvvm1_sleef(vfloat_rvvm1_sleef d) { + return vreinterpret_vf_vi2_rvvm1_sleef(vand_vi2_vi2_vi2_rvvm1_sleef(vreinterpret_vi2_vf_rvvm1_sleef(d), vcast_vi2_i_rvvm1_sleef(0xfffff000))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_rvvm1_sleef vcast_vf2_vf_vf_rvvm1_sleef(vfloat_rvvm1_sleef h, vfloat_rvvm1_sleef l) { + return vf2setxy_vf2_vf_vf_rvvm1_sleef(h, l); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_rvvm1_sleef vcast_vf2_f_f_rvvm1_sleef(float h, float l) { + return vf2setxy_vf2_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(h), vcast_vf_f_rvvm1_sleef(l)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_rvvm1_sleef vcast_vf2_d_rvvm1_sleef(double d) { + return vf2setxy_vf2_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(d), vcast_vf_f_rvvm1_sleef(d - (float)d)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_rvvm1_sleef vsel_vf2_vo_vf2_vf2_rvvm1_sleef(rvv_sp_vopmask_rvvm1_sleef m, vfloat2_rvvm1_sleef x, vfloat2_rvvm1_sleef y) { + return vf2setxy_vf2_vf_vf_rvvm1_sleef(vsel_vf_vo_vf_vf_rvvm1_sleef(m, vf2getx_vf_vf2_rvvm1_sleef(x), vf2getx_vf_vf2_rvvm1_sleef(y)), vsel_vf_vo_vf_vf_rvvm1_sleef(m, vf2gety_vf_vf2_rvvm1_sleef(x), vf2gety_vf_vf2_rvvm1_sleef(y))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_rvvm1_sleef vsel_vf2_vo_f_f_f_f_rvvm1_sleef(rvv_sp_vopmask_rvvm1_sleef o, float x1, float y1, float x0, float y0) { + return vf2setxy_vf2_vf_vf_rvvm1_sleef(vsel_vf_vo_f_f_rvvm1_sleef(o, x1, x0), vsel_vf_vo_f_f_rvvm1_sleef(o, y1, y0)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_rvvm1_sleef vsel_vf2_vo_vo_d_d_d_rvvm1_sleef(rvv_sp_vopmask_rvvm1_sleef o0, rvv_sp_vopmask_rvvm1_sleef o1, double d0, double d1, double d2) { + return vsel_vf2_vo_vf2_vf2_rvvm1_sleef(o0, vcast_vf2_d_rvvm1_sleef(d0), vsel_vf2_vo_vf2_vf2_rvvm1_sleef(o1, vcast_vf2_d_rvvm1_sleef(d1), vcast_vf2_d_rvvm1_sleef(d2))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_rvvm1_sleef vsel_vf2_vo_vo_vo_d_d_d_d_rvvm1_sleef(rvv_sp_vopmask_rvvm1_sleef o0, rvv_sp_vopmask_rvvm1_sleef o1, rvv_sp_vopmask_rvvm1_sleef o2, double d0, double d1, double d2, double d3) { + return vsel_vf2_vo_vf2_vf2_rvvm1_sleef(o0, vcast_vf2_d_rvvm1_sleef(d0), vsel_vf2_vo_vf2_vf2_rvvm1_sleef(o1, vcast_vf2_d_rvvm1_sleef(d1), vsel_vf2_vo_vf2_vf2_rvvm1_sleef(o2, vcast_vf2_d_rvvm1_sleef(d2), vcast_vf2_d_rvvm1_sleef(d3)))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_rvvm1_sleef vabs_vf2_vf2_rvvm1_sleef(vfloat2_rvvm1_sleef x) { + return vcast_vf2_vf_vf_rvvm1_sleef(vreinterpret_vf_vm_rvvm1_sleef(vxor_vm_vm_vm_rvvm1_sleef(vand_vm_vm_vm_rvvm1_sleef(vreinterpret_vm_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(-0.0)), vreinterpret_vm_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(x))), vreinterpret_vm_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(x)))), + vreinterpret_vf_vm_rvvm1_sleef(vxor_vm_vm_vm_rvvm1_sleef(vand_vm_vm_vm_rvvm1_sleef(vreinterpret_vm_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(-0.0)), vreinterpret_vm_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(x))), vreinterpret_vm_vf_rvvm1_sleef(vf2gety_vf_vf2_rvvm1_sleef(x))))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_rvvm1_sleef vadd_vf_3vf_rvvm1_sleef(vfloat_rvvm1_sleef v0, vfloat_rvvm1_sleef v1, vfloat_rvvm1_sleef v2) { + return vadd_vf_vf_vf_rvvm1_sleef(vadd_vf_vf_vf_rvvm1_sleef(v0, v1), v2); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_rvvm1_sleef vadd_vf_4vf_rvvm1_sleef(vfloat_rvvm1_sleef v0, vfloat_rvvm1_sleef v1, vfloat_rvvm1_sleef v2, vfloat_rvvm1_sleef v3) { + return vadd_vf_3vf_rvvm1_sleef(vadd_vf_vf_vf_rvvm1_sleef(v0, v1), v2, v3); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_rvvm1_sleef vadd_vf_5vf_rvvm1_sleef(vfloat_rvvm1_sleef v0, vfloat_rvvm1_sleef v1, vfloat_rvvm1_sleef v2, vfloat_rvvm1_sleef v3, vfloat_rvvm1_sleef v4) { + return vadd_vf_4vf_rvvm1_sleef(vadd_vf_vf_vf_rvvm1_sleef(v0, v1), v2, v3, v4); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_rvvm1_sleef vadd_vf_6vf_rvvm1_sleef(vfloat_rvvm1_sleef v0, vfloat_rvvm1_sleef v1, vfloat_rvvm1_sleef v2, vfloat_rvvm1_sleef v3, vfloat_rvvm1_sleef v4, vfloat_rvvm1_sleef v5) { + return vadd_vf_5vf_rvvm1_sleef(vadd_vf_vf_vf_rvvm1_sleef(v0, v1), v2, v3, v4, v5); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_rvvm1_sleef vadd_vf_7vf_rvvm1_sleef(vfloat_rvvm1_sleef v0, vfloat_rvvm1_sleef v1, vfloat_rvvm1_sleef v2, vfloat_rvvm1_sleef v3, vfloat_rvvm1_sleef v4, vfloat_rvvm1_sleef v5, vfloat_rvvm1_sleef v6) { + return vadd_vf_6vf_rvvm1_sleef(vadd_vf_vf_vf_rvvm1_sleef(v0, v1), v2, v3, v4, v5, v6); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_rvvm1_sleef vsub_vf_3vf_rvvm1_sleef(vfloat_rvvm1_sleef v0, vfloat_rvvm1_sleef v1, vfloat_rvvm1_sleef v2) { + return vsub_vf_vf_vf_rvvm1_sleef(vsub_vf_vf_vf_rvvm1_sleef(v0, v1), v2); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_rvvm1_sleef vsub_vf_4vf_rvvm1_sleef(vfloat_rvvm1_sleef v0, vfloat_rvvm1_sleef v1, vfloat_rvvm1_sleef v2, vfloat_rvvm1_sleef v3) { + return vsub_vf_3vf_rvvm1_sleef(vsub_vf_vf_vf_rvvm1_sleef(v0, v1), v2, v3); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_rvvm1_sleef vsub_vf_5vf_rvvm1_sleef(vfloat_rvvm1_sleef v0, vfloat_rvvm1_sleef v1, vfloat_rvvm1_sleef v2, vfloat_rvvm1_sleef v3, vfloat_rvvm1_sleef v4) { + return vsub_vf_4vf_rvvm1_sleef(vsub_vf_vf_vf_rvvm1_sleef(v0, v1), v2, v3, v4); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_rvvm1_sleef dfneg_vf2_vf2_rvvm1_sleef(vfloat2_rvvm1_sleef x) { + return vcast_vf2_vf_vf_rvvm1_sleef(vneg_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(x)), vneg_vf_vf_rvvm1_sleef(vf2gety_vf_vf2_rvvm1_sleef(x))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_rvvm1_sleef dfabs_vf2_vf2_rvvm1_sleef(vfloat2_rvvm1_sleef x) { + return vcast_vf2_vf_vf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(x)), + vreinterpret_vf_vm_rvvm1_sleef(vxor_vm_vm_vm_rvvm1_sleef(vreinterpret_vm_vf_rvvm1_sleef(vf2gety_vf_vf2_rvvm1_sleef(x)), vand_vm_vm_vm_rvvm1_sleef(vreinterpret_vm_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(x)), vreinterpret_vm_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(-0.0f)))))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_rvvm1_sleef dfnormalize_vf2_vf2_rvvm1_sleef(vfloat2_rvvm1_sleef t) { + vfloat_rvvm1_sleef s = vadd_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(t), vf2gety_vf_vf2_rvvm1_sleef(t)); + return vf2setxy_vf2_vf_vf_rvvm1_sleef(s, vadd_vf_vf_vf_rvvm1_sleef(vsub_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(t), s), vf2gety_vf_vf2_rvvm1_sleef(t))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_rvvm1_sleef dfscale_vf2_vf2_vf_rvvm1_sleef(vfloat2_rvvm1_sleef d, vfloat_rvvm1_sleef s) { + return vf2setxy_vf2_vf_vf_rvvm1_sleef(vmul_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(d), s), vmul_vf_vf_vf_rvvm1_sleef(vf2gety_vf_vf2_rvvm1_sleef(d), s)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_rvvm1_sleef dfadd_vf2_vf_vf_rvvm1_sleef(vfloat_rvvm1_sleef x, vfloat_rvvm1_sleef y) { + vfloat_rvvm1_sleef s = vadd_vf_vf_vf_rvvm1_sleef(x, y); + return vf2setxy_vf2_vf_vf_rvvm1_sleef(s, vadd_vf_vf_vf_rvvm1_sleef(vsub_vf_vf_vf_rvvm1_sleef(x, s), y)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_rvvm1_sleef dfadd2_vf2_vf_vf_rvvm1_sleef(vfloat_rvvm1_sleef x, vfloat_rvvm1_sleef y) { + vfloat_rvvm1_sleef s = vadd_vf_vf_vf_rvvm1_sleef(x, y); + vfloat_rvvm1_sleef v = vsub_vf_vf_vf_rvvm1_sleef(s, x); + return vf2setxy_vf2_vf_vf_rvvm1_sleef(s, vadd_vf_vf_vf_rvvm1_sleef(vsub_vf_vf_vf_rvvm1_sleef(x, vsub_vf_vf_vf_rvvm1_sleef(s, v)), vsub_vf_vf_vf_rvvm1_sleef(y, v))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_rvvm1_sleef dfadd2_vf2_vf_vf2_rvvm1_sleef(vfloat_rvvm1_sleef x, vfloat2_rvvm1_sleef y) { + vfloat_rvvm1_sleef s = vadd_vf_vf_vf_rvvm1_sleef(x, vf2getx_vf_vf2_rvvm1_sleef(y)); + vfloat_rvvm1_sleef v = vsub_vf_vf_vf_rvvm1_sleef(s, x); + return vf2setxy_vf2_vf_vf_rvvm1_sleef(s, vadd_vf_vf_vf_rvvm1_sleef(vadd_vf_vf_vf_rvvm1_sleef(vsub_vf_vf_vf_rvvm1_sleef(x, vsub_vf_vf_vf_rvvm1_sleef(s, v)), vsub_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(y), v)), vf2gety_vf_vf2_rvvm1_sleef(y))); + +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_rvvm1_sleef dfadd_vf2_vf2_vf_rvvm1_sleef(vfloat2_rvvm1_sleef x, vfloat_rvvm1_sleef y) { + vfloat_rvvm1_sleef s = vadd_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(x), y); + return vf2setxy_vf2_vf_vf_rvvm1_sleef(s, vadd_vf_3vf_rvvm1_sleef(vsub_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(x), s), y, vf2gety_vf_vf2_rvvm1_sleef(x))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_rvvm1_sleef dfsub_vf2_vf2_vf_rvvm1_sleef(vfloat2_rvvm1_sleef x, vfloat_rvvm1_sleef y) { + vfloat_rvvm1_sleef s = vsub_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(x), y); + return vf2setxy_vf2_vf_vf_rvvm1_sleef(s, vadd_vf_vf_vf_rvvm1_sleef(vsub_vf_vf_vf_rvvm1_sleef(vsub_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(x), s), y), vf2gety_vf_vf2_rvvm1_sleef(x))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_rvvm1_sleef dfadd2_vf2_vf2_vf_rvvm1_sleef(vfloat2_rvvm1_sleef x, vfloat_rvvm1_sleef y) { + vfloat_rvvm1_sleef s = vadd_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(x), y); + vfloat_rvvm1_sleef v = vsub_vf_vf_vf_rvvm1_sleef(s, vf2getx_vf_vf2_rvvm1_sleef(x)); + vfloat_rvvm1_sleef t = vadd_vf_vf_vf_rvvm1_sleef(vsub_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(x), vsub_vf_vf_vf_rvvm1_sleef(s, v)), vsub_vf_vf_vf_rvvm1_sleef(y, v)); + return vf2setxy_vf2_vf_vf_rvvm1_sleef(s, vadd_vf_vf_vf_rvvm1_sleef(t, vf2gety_vf_vf2_rvvm1_sleef(x))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_rvvm1_sleef dfadd_vf2_vf_vf2_rvvm1_sleef(vfloat_rvvm1_sleef x, vfloat2_rvvm1_sleef y) { + vfloat_rvvm1_sleef s = vadd_vf_vf_vf_rvvm1_sleef(x, vf2getx_vf_vf2_rvvm1_sleef(y)); + return vf2setxy_vf2_vf_vf_rvvm1_sleef(s, vadd_vf_3vf_rvvm1_sleef(vsub_vf_vf_vf_rvvm1_sleef(x, s), vf2getx_vf_vf2_rvvm1_sleef(y), vf2gety_vf_vf2_rvvm1_sleef(y))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_rvvm1_sleef dfadd_vf2_vf2_vf2_rvvm1_sleef(vfloat2_rvvm1_sleef x, vfloat2_rvvm1_sleef y) { + + vfloat_rvvm1_sleef s = vadd_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(x), vf2getx_vf_vf2_rvvm1_sleef(y)); + return vf2setxy_vf2_vf_vf_rvvm1_sleef(s, vadd_vf_4vf_rvvm1_sleef(vsub_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(x), s), vf2getx_vf_vf2_rvvm1_sleef(y), vf2gety_vf_vf2_rvvm1_sleef(x), vf2gety_vf_vf2_rvvm1_sleef(y))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_rvvm1_sleef dfadd2_vf2_vf2_vf2_rvvm1_sleef(vfloat2_rvvm1_sleef x, vfloat2_rvvm1_sleef y) { + vfloat_rvvm1_sleef s = vadd_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(x), vf2getx_vf_vf2_rvvm1_sleef(y)); + vfloat_rvvm1_sleef v = vsub_vf_vf_vf_rvvm1_sleef(s, vf2getx_vf_vf2_rvvm1_sleef(x)); + vfloat_rvvm1_sleef t = vadd_vf_vf_vf_rvvm1_sleef(vsub_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(x), vsub_vf_vf_vf_rvvm1_sleef(s, v)), vsub_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(y), v)); + return vf2setxy_vf2_vf_vf_rvvm1_sleef(s, vadd_vf_vf_vf_rvvm1_sleef(t, vadd_vf_vf_vf_rvvm1_sleef(vf2gety_vf_vf2_rvvm1_sleef(x), vf2gety_vf_vf2_rvvm1_sleef(y)))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_rvvm1_sleef dfsub_vf2_vf_vf_rvvm1_sleef(vfloat_rvvm1_sleef x, vfloat_rvvm1_sleef y) { + + vfloat_rvvm1_sleef s = vsub_vf_vf_vf_rvvm1_sleef(x, y); + return vf2setxy_vf2_vf_vf_rvvm1_sleef(s, vsub_vf_vf_vf_rvvm1_sleef(vsub_vf_vf_vf_rvvm1_sleef(x, s), y)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_rvvm1_sleef dfsub_vf2_vf2_vf2_rvvm1_sleef(vfloat2_rvvm1_sleef x, vfloat2_rvvm1_sleef y) { + + vfloat_rvvm1_sleef s = vsub_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(x), vf2getx_vf_vf2_rvvm1_sleef(y)); + vfloat_rvvm1_sleef t = vsub_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(x), s); + t = vsub_vf_vf_vf_rvvm1_sleef(t, vf2getx_vf_vf2_rvvm1_sleef(y)); + t = vadd_vf_vf_vf_rvvm1_sleef(t, vf2gety_vf_vf2_rvvm1_sleef(x)); + return vf2setxy_vf2_vf_vf_rvvm1_sleef(s, vsub_vf_vf_vf_rvvm1_sleef(t, vf2gety_vf_vf2_rvvm1_sleef(y))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_rvvm1_sleef dfdiv_vf2_vf2_vf2_rvvm1_sleef(vfloat2_rvvm1_sleef n, vfloat2_rvvm1_sleef d) { + vfloat_rvvm1_sleef t = vrec_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(d)); + vfloat_rvvm1_sleef s = vmul_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(n), t); + vfloat_rvvm1_sleef u = vfmapn_vf_vf_vf_vf_rvvm1_sleef(t, vf2getx_vf_vf2_rvvm1_sleef(n), s); + vfloat_rvvm1_sleef v = vfmanp_vf_vf_vf_vf_rvvm1_sleef(vf2gety_vf_vf2_rvvm1_sleef(d), t, vfmanp_vf_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(d), t, vcast_vf_f_rvvm1_sleef(1))); + return vf2setxy_vf2_vf_vf_rvvm1_sleef(s, vfma_vf_vf_vf_vf_rvvm1_sleef(s, v, vfma_vf_vf_vf_vf_rvvm1_sleef(vf2gety_vf_vf2_rvvm1_sleef(n), t, u))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_rvvm1_sleef dfmul_vf2_vf_vf_rvvm1_sleef(vfloat_rvvm1_sleef x, vfloat_rvvm1_sleef y) { + vfloat_rvvm1_sleef s = vmul_vf_vf_vf_rvvm1_sleef(x, y); + return vf2setxy_vf2_vf_vf_rvvm1_sleef(s, vfmapn_vf_vf_vf_vf_rvvm1_sleef(x, y, s)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_rvvm1_sleef dfsqu_vf2_vf2_rvvm1_sleef(vfloat2_rvvm1_sleef x) { + vfloat_rvvm1_sleef s = vmul_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(x), vf2getx_vf_vf2_rvvm1_sleef(x)); + return vf2setxy_vf2_vf_vf_rvvm1_sleef(s, vfma_vf_vf_vf_vf_rvvm1_sleef(vadd_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(x), vf2getx_vf_vf2_rvvm1_sleef(x)), vf2gety_vf_vf2_rvvm1_sleef(x), vfmapn_vf_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(x), vf2getx_vf_vf2_rvvm1_sleef(x), s))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_rvvm1_sleef dfsqu_vf_vf2_rvvm1_sleef(vfloat2_rvvm1_sleef x) { + return vfma_vf_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(x), vf2getx_vf_vf2_rvvm1_sleef(x), vadd_vf_vf_vf_rvvm1_sleef(vmul_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(x), vf2gety_vf_vf2_rvvm1_sleef(x)), vmul_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(x), vf2gety_vf_vf2_rvvm1_sleef(x)))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_rvvm1_sleef dfmul_vf2_vf2_vf2_rvvm1_sleef(vfloat2_rvvm1_sleef x, vfloat2_rvvm1_sleef y) { + vfloat_rvvm1_sleef s = vmul_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(x), vf2getx_vf_vf2_rvvm1_sleef(y)); + return vf2setxy_vf2_vf_vf_rvvm1_sleef(s, vfma_vf_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(x), vf2gety_vf_vf2_rvvm1_sleef(y), vfma_vf_vf_vf_vf_rvvm1_sleef(vf2gety_vf_vf2_rvvm1_sleef(x), vf2getx_vf_vf2_rvvm1_sleef(y), vfmapn_vf_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(x), vf2getx_vf_vf2_rvvm1_sleef(y), s)))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_rvvm1_sleef dfmul_vf_vf2_vf2_rvvm1_sleef(vfloat2_rvvm1_sleef x, vfloat2_rvvm1_sleef y) { + return vfma_vf_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(x), vf2getx_vf_vf2_rvvm1_sleef(y), vfma_vf_vf_vf_vf_rvvm1_sleef(vf2gety_vf_vf2_rvvm1_sleef(x), vf2getx_vf_vf2_rvvm1_sleef(y), vmul_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(x), vf2gety_vf_vf2_rvvm1_sleef(y)))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_rvvm1_sleef dfmul_vf2_vf2_vf_rvvm1_sleef(vfloat2_rvvm1_sleef x, vfloat_rvvm1_sleef y) { + vfloat_rvvm1_sleef s = vmul_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(x), y); + return vf2setxy_vf2_vf_vf_rvvm1_sleef(s, vfma_vf_vf_vf_vf_rvvm1_sleef(vf2gety_vf_vf2_rvvm1_sleef(x), y, vfmapn_vf_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(x), y, s))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_rvvm1_sleef dfrec_vf2_vf_rvvm1_sleef(vfloat_rvvm1_sleef d) { + vfloat_rvvm1_sleef s = vrec_vf_vf_rvvm1_sleef(d); + return vf2setxy_vf2_vf_vf_rvvm1_sleef(s, vmul_vf_vf_vf_rvvm1_sleef(s, vfmanp_vf_vf_vf_vf_rvvm1_sleef(d, s, vcast_vf_f_rvvm1_sleef(1)))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_rvvm1_sleef dfrec_vf2_vf2_rvvm1_sleef(vfloat2_rvvm1_sleef d) { + vfloat_rvvm1_sleef s = vrec_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(d)); + return vf2setxy_vf2_vf_vf_rvvm1_sleef(s, vmul_vf_vf_vf_rvvm1_sleef(s, vfmanp_vf_vf_vf_vf_rvvm1_sleef(vf2gety_vf_vf2_rvvm1_sleef(d), s, vfmanp_vf_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(d), s, vcast_vf_f_rvvm1_sleef(1))))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_rvvm1_sleef dfsqrt_vf2_vf2_rvvm1_sleef(vfloat2_rvvm1_sleef d) { + + vfloat_rvvm1_sleef t = vsqrt_vf_vf_rvvm1_sleef(vadd_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(d), vf2gety_vf_vf2_rvvm1_sleef(d))); + return dfscale_vf2_vf2_vf_rvvm1_sleef(dfmul_vf2_vf2_vf2_rvvm1_sleef(dfadd2_vf2_vf2_vf2_rvvm1_sleef(d, dfmul_vf2_vf_vf_rvvm1_sleef(t, t)), dfrec_vf2_vf_rvvm1_sleef(t)), vcast_vf_f_rvvm1_sleef(0.5)); + +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_rvvm1_sleef dfsqrt_vf2_vf_rvvm1_sleef(vfloat_rvvm1_sleef d) { + vfloat_rvvm1_sleef t = vsqrt_vf_vf_rvvm1_sleef(d); + return dfscale_vf2_vf2_vf_rvvm1_sleef(dfmul_vf2_vf2_vf2_rvvm1_sleef(dfadd2_vf2_vf_vf2_rvvm1_sleef(d, dfmul_vf2_vf_vf_rvvm1_sleef(t, t)), dfrec_vf2_vf_rvvm1_sleef(t)), vcast_vf_f_rvvm1_sleef(0.5f)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST rvv_sp_vopmask_rvvm1_sleef visnegzero_vo_vf_rvvm1_sleef(vfloat_rvvm1_sleef d) { + return veq_vo_vi2_vi2_rvvm1_sleef(vreinterpret_vi2_vf_rvvm1_sleef(d), vreinterpret_vi2_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(-0.0))); +} + +static SLEEF_ALWAYS_INLINE rvv_sp_vopmask_rvvm1_sleef vnot_vo32_vo32_rvvm1_sleef(rvv_sp_vopmask_rvvm1_sleef x) { + return rvv_sp_vxor_vo_vo_vo(x, veq_vo_vi2_vi2_rvvm1_sleef(vcast_vi2_i_rvvm1_sleef(0), vcast_vi2_i_rvvm1_sleef(0))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vmask_rvvm1_sleef vsignbit_vm_vf_rvvm1_sleef(vfloat_rvvm1_sleef f) { + return vand_vm_vm_vm_rvvm1_sleef(vreinterpret_vm_vf_rvvm1_sleef(f), vreinterpret_vm_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(-0.0f))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST rvv_sp_vopmask_rvvm1_sleef vsignbit_vo_vf_rvvm1_sleef(vfloat_rvvm1_sleef d) { + return veq_vo_vi2_vi2_rvvm1_sleef(vand_vi2_vi2_vi2_rvvm1_sleef(vreinterpret_vi2_vf_rvvm1_sleef(d), vcast_vi2_i_rvvm1_sleef(0x80000000)), vcast_vi2_i_rvvm1_sleef(0x80000000)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vint2_rvvm1_sleef vsel_vi2_vf_vf_vi2_vi2_rvvm1_sleef(vfloat_rvvm1_sleef f0, vfloat_rvvm1_sleef f1, vint2_rvvm1_sleef x, vint2_rvvm1_sleef y) { + return vsel_vi2_vo_vi2_vi2_rvvm1_sleef(vlt_vo_vf_vf_rvvm1_sleef(f0, f1), x, y); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vint2_rvvm1_sleef vsel_vi2_vf_vi2_rvvm1_sleef(vfloat_rvvm1_sleef d, vint2_rvvm1_sleef x) { + return vand_vi2_vo_vi2_rvvm1_sleef(vsignbit_vo_vf_rvvm1_sleef(d), x); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST rvv_sp_vopmask_rvvm1_sleef visint_vo_vf_rvvm1_sleef(vfloat_rvvm1_sleef y) { return veq_vo_vf_vf_rvvm1_sleef(vtruncate_vf_vf_rvvm1_sleef(y), y); } + +static SLEEF_ALWAYS_INLINE SLEEF_CONST rvv_sp_vopmask_rvvm1_sleef visnumber_vo_vf_rvvm1_sleef(vfloat_rvvm1_sleef x) { return vnot_vo32_vo32_rvvm1_sleef(rvv_sp_vor_vo_vo_vo(visinf_vo_vf_rvvm1_sleef(x), visnan_vo_vf_rvvm1_sleef(x))); } + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vint2_rvvm1_sleef vilogbk_vi2_vf_rvvm1_sleef(vfloat_rvvm1_sleef d) { + rvv_sp_vopmask_rvvm1_sleef o = vlt_vo_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(5.421010862427522E-20f)); + d = vsel_vf_vo_vf_vf_rvvm1_sleef(o, vmul_vf_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(1.8446744073709552E19f), d), d); + vint2_rvvm1_sleef q = vand_vi2_vi2_vi2_rvvm1_sleef(vsrl_vi2_vi2_i_rvvm1_sleef(vreinterpret_vi2_vf_rvvm1_sleef(d), 23), vcast_vi2_i_rvvm1_sleef(0xff)); + q = vsub_vi2_vi2_vi2_rvvm1_sleef(q, vsel_vi2_vo_vi2_vi2_rvvm1_sleef(o, vcast_vi2_i_rvvm1_sleef(64 + 0x7f), vcast_vi2_i_rvvm1_sleef(0x7f))); + return q; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vint2_rvvm1_sleef vilogb2k_vi2_vf_rvvm1_sleef(vfloat_rvvm1_sleef d) { + vint2_rvvm1_sleef q = vreinterpret_vi2_vf_rvvm1_sleef(d); + q = vsrl_vi2_vi2_i_rvvm1_sleef(q, 23); + q = vand_vi2_vi2_vi2_rvvm1_sleef(q, vcast_vi2_i_rvvm1_sleef(0xff)); + q = vsub_vi2_vi2_vi2_rvvm1_sleef(q, vcast_vi2_i_rvvm1_sleef(0x7f)); + return q; +} + +SLEEF_INLINE SLEEF_CONST vint2_rvvm1_sleef Sleef_ilogbfx_rvvm1(vfloat_rvvm1_sleef d) { + vint2_rvvm1_sleef e = vilogbk_vi2_vf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(d)); + e = vsel_vi2_vo_vi2_vi2_rvvm1_sleef(veq_vo_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(0.0f)), vcast_vi2_i_rvvm1_sleef(SLEEF_FP_ILOGB0), e); + e = vsel_vi2_vo_vi2_vi2_rvvm1_sleef(visnan_vo_vf_rvvm1_sleef(d), vcast_vi2_i_rvvm1_sleef(SLEEF_FP_ILOGBNAN), e); + e = vsel_vi2_vo_vi2_vi2_rvvm1_sleef(visinf_vo_vf_rvvm1_sleef(d), vcast_vi2_i_rvvm1_sleef(2147483647), e); + return e; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_rvvm1_sleef vpow2i_vf_vi2_rvvm1_sleef(vint2_rvvm1_sleef q) { + return vreinterpret_vf_vi2_rvvm1_sleef(vsll_vi2_vi2_i_rvvm1_sleef(vadd_vi2_vi2_vi2_rvvm1_sleef(q, vcast_vi2_i_rvvm1_sleef(0x7f)), 23)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_rvvm1_sleef vldexp_vf_vf_vi2_rvvm1_sleef(vfloat_rvvm1_sleef x, vint2_rvvm1_sleef q) { + vfloat_rvvm1_sleef u; + vint2_rvvm1_sleef m = vsra_vi2_vi2_i_rvvm1_sleef(q, 31); + m = vsll_vi2_vi2_i_rvvm1_sleef(vsub_vi2_vi2_vi2_rvvm1_sleef(vsra_vi2_vi2_i_rvvm1_sleef(vadd_vi2_vi2_vi2_rvvm1_sleef(m, q), 6), m), 4); + q = vsub_vi2_vi2_vi2_rvvm1_sleef(q, vsll_vi2_vi2_i_rvvm1_sleef(m, 2)); + m = vadd_vi2_vi2_vi2_rvvm1_sleef(m, vcast_vi2_i_rvvm1_sleef(0x7f)); + m = vand_vi2_vi2_vi2_rvvm1_sleef(vgt_vi2_vi2_vi2_rvvm1_sleef(m, vcast_vi2_i_rvvm1_sleef(0)), m); + vint2_rvvm1_sleef n = vgt_vi2_vi2_vi2_rvvm1_sleef(m, vcast_vi2_i_rvvm1_sleef(0xff)); + m = vor_vi2_vi2_vi2_rvvm1_sleef(vandnot_vi2_vi2_vi2_rvvm1_sleef(n, m), vand_vi2_vi2_vi2_rvvm1_sleef(n, vcast_vi2_i_rvvm1_sleef(0xff))); + u = vreinterpret_vf_vi2_rvvm1_sleef(vsll_vi2_vi2_i_rvvm1_sleef(m, 23)); + x = vmul_vf_vf_vf_rvvm1_sleef(vmul_vf_vf_vf_rvvm1_sleef(vmul_vf_vf_vf_rvvm1_sleef(vmul_vf_vf_vf_rvvm1_sleef(x, u), u), u), u); + u = vreinterpret_vf_vi2_rvvm1_sleef(vsll_vi2_vi2_i_rvvm1_sleef(vadd_vi2_vi2_vi2_rvvm1_sleef(q, vcast_vi2_i_rvvm1_sleef(0x7f)), 23)); + return vmul_vf_vf_vf_rvvm1_sleef(x, u); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_rvvm1_sleef vldexp2_vf_vf_vi2_rvvm1_sleef(vfloat_rvvm1_sleef d, vint2_rvvm1_sleef e) { + return vmul_vf_vf_vf_rvvm1_sleef(vmul_vf_vf_vf_rvvm1_sleef(d, vpow2i_vf_vi2_rvvm1_sleef(vsra_vi2_vi2_i_rvvm1_sleef(e, 1))), vpow2i_vf_vi2_rvvm1_sleef(vsub_vi2_vi2_vi2_rvvm1_sleef(e, vsra_vi2_vi2_i_rvvm1_sleef(e, 1)))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_rvvm1_sleef vldexp3_vf_vf_vi2_rvvm1_sleef(vfloat_rvvm1_sleef d, vint2_rvvm1_sleef q) { + return vreinterpret_vf_vi2_rvvm1_sleef(vadd_vi2_vi2_vi2_rvvm1_sleef(vreinterpret_vi2_vf_rvvm1_sleef(d), vsll_vi2_vi2_i_rvvm1_sleef(q, 23))); +} + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_ldexpfx_rvvm1(vfloat_rvvm1_sleef x, vint2_rvvm1_sleef q) { return vldexp_vf_vf_vi2_rvvm1_sleef(x, q); } + +static SLEEF_ALWAYS_INLINE SLEEF_CONST fi_t_rvvm1_sleef rempisubf_rvvm1_sleef(vfloat_rvvm1_sleef x) { + + vfloat_rvvm1_sleef c = vmulsign_vf_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(1 << 23), x); + vfloat_rvvm1_sleef rint4x = vsel_vf_vo_vf_vf_rvvm1_sleef(vgt_vo_vf_vf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(vmul_vf_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(4), x)), vcast_vf_f_rvvm1_sleef(1 << 23)), + vmul_vf_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(4), x), + vorsign_vf_vf_vf_rvvm1_sleef(vsub_vf_vf_vf_rvvm1_sleef(vmla_vf_vf_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(4), x, c), c), x)); + vfloat_rvvm1_sleef rintx = vsel_vf_vo_vf_vf_rvvm1_sleef(vgt_vo_vf_vf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(x), vcast_vf_f_rvvm1_sleef(1 << 23)), + x, vorsign_vf_vf_vf_rvvm1_sleef(vsub_vf_vf_vf_rvvm1_sleef(vadd_vf_vf_vf_rvvm1_sleef(x, c), c), x)); + return fisetdi_fi_vf_vi2_rvvm1_sleef(vmla_vf_vf_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(-0.25), rint4x, x), + vtruncate_vi2_vf_rvvm1_sleef(vmla_vf_vf_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(-4), rintx, rint4x))); + +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST dfi_t_rvvm1_sleef rempif_rvvm1_sleef(vfloat_rvvm1_sleef a) { + vfloat2_rvvm1_sleef x, y; + vint2_rvvm1_sleef ex = vilogb2k_vi2_vf_rvvm1_sleef(a); + + ex = vsub_vi2_vi2_vi2_rvvm1_sleef(ex, vcast_vi2_i_rvvm1_sleef(25)); + vint2_rvvm1_sleef q = vand_vi2_vo_vi2_rvvm1_sleef(vgt_vo_vi2_vi2_rvvm1_sleef(ex, vcast_vi2_i_rvvm1_sleef(90-25)), vcast_vi2_i_rvvm1_sleef(-64)); + a = vldexp3_vf_vf_vi2_rvvm1_sleef(a, q); + ex = vandnot_vi2_vi2_vi2_rvvm1_sleef(vsra_vi2_vi2_i_rvvm1_sleef(ex, 31), ex); + ex = vsll_vi2_vi2_i_rvvm1_sleef(ex, 2); + x = dfmul_vf2_vf_vf_rvvm1_sleef(a, vgather_vf_p_vi2_rvvm1_sleef(Sleef_rempitabsp, ex)); + fi_t_rvvm1_sleef di = rempisubf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(x)); + q = figeti_vi2_di_rvvm1_sleef(di); + x = vf2setx_vf2_vf2_vf_rvvm1_sleef(x, figetd_vf_di_rvvm1_sleef(di)); + x = dfnormalize_vf2_vf2_rvvm1_sleef(x); + y = dfmul_vf2_vf_vf_rvvm1_sleef(a, vgather_vf_p_vi2_rvvm1_sleef(Sleef_rempitabsp+1, ex)); + x = dfadd2_vf2_vf2_vf2_rvvm1_sleef(x, y); + di = rempisubf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(x)); + q = vadd_vi2_vi2_vi2_rvvm1_sleef(q, figeti_vi2_di_rvvm1_sleef(di)); + x = vf2setx_vf2_vf2_vf_rvvm1_sleef(x, figetd_vf_di_rvvm1_sleef(di)); + x = dfnormalize_vf2_vf2_rvvm1_sleef(x); + y = vcast_vf2_vf_vf_rvvm1_sleef(vgather_vf_p_vi2_rvvm1_sleef(Sleef_rempitabsp+2, ex), vgather_vf_p_vi2_rvvm1_sleef(Sleef_rempitabsp+3, ex)); + y = dfmul_vf2_vf2_vf_rvvm1_sleef(y, a); + x = dfadd2_vf2_vf2_vf2_rvvm1_sleef(x, y); + x = dfnormalize_vf2_vf2_rvvm1_sleef(x); + x = dfmul_vf2_vf2_vf2_rvvm1_sleef(x, vcast_vf2_f_f_rvvm1_sleef(3.1415927410125732422f*2, -8.7422776573475857731e-08f*2)); + x = vsel_vf2_vo_vf2_vf2_rvvm1_sleef(vlt_vo_vf_vf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(a), vcast_vf_f_rvvm1_sleef(0.7f)), vcast_vf2_vf_vf_rvvm1_sleef(a, vcast_vf_f_rvvm1_sleef(0)), x); + return dfisetdfi_dfi_vf2_vi2_rvvm1_sleef(x, q); +} + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_sinfx_u35rvvm1(vfloat_rvvm1_sleef d) { + + vint2_rvvm1_sleef q; + vfloat_rvvm1_sleef u, s, r = d; + + if (__builtin_expect(!!(vtestallones_i_vo32_rvvm1_sleef(vlt_vo_vf_vf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(d), vcast_vf_f_rvvm1_sleef(125.0f)))), 1)) { + q = vrint_vi2_vf_rvvm1_sleef(vmul_vf_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef((float)0.318309886183790671537767526745028724))); + u = vcast_vf_vi2_rvvm1_sleef(q); + d = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vcast_vf_f_rvvm1_sleef(-3.1414794921875f), d); + d = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vcast_vf_f_rvvm1_sleef(-0.00011315941810607910156f), d); + d = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vcast_vf_f_rvvm1_sleef(-1.9841872589410058936e-09f), d); + } else if (__builtin_expect(!!(vtestallones_i_vo32_rvvm1_sleef(vlt_vo_vf_vf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(d), vcast_vf_f_rvvm1_sleef(39000)))), 1)) { + q = vrint_vi2_vf_rvvm1_sleef(vmul_vf_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef((float)0.318309886183790671537767526745028724))); + u = vcast_vf_vi2_rvvm1_sleef(q); + d = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vcast_vf_f_rvvm1_sleef(-3.140625f), d); + d = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vcast_vf_f_rvvm1_sleef(-0.0009670257568359375f), d); + d = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vcast_vf_f_rvvm1_sleef(-6.2771141529083251953e-07f), d); + d = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vcast_vf_f_rvvm1_sleef(-1.2154201256553420762e-10f), d); + } else { + dfi_t_rvvm1_sleef dfi_rvvm1_sleef = rempif_rvvm1_sleef(d); + q = vand_vi2_vi2_vi2_rvvm1_sleef(dfigeti_vi2_dfi_rvvm1_sleef(dfi_rvvm1_sleef), vcast_vi2_i_rvvm1_sleef(3)); + q = vadd_vi2_vi2_vi2_rvvm1_sleef(vadd_vi2_vi2_vi2_rvvm1_sleef(q, q), vsel_vi2_vo_vi2_vi2_rvvm1_sleef(vgt_vo_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(dfigetdf_vf2_dfi_rvvm1_sleef(dfi_rvvm1_sleef)), vcast_vf_f_rvvm1_sleef(0)), vcast_vi2_i_rvvm1_sleef(2), vcast_vi2_i_rvvm1_sleef(1))); + q = vsra_vi2_vi2_i_rvvm1_sleef(q, 2); + rvv_sp_vopmask_rvvm1_sleef o = veq_vo_vi2_vi2_rvvm1_sleef(vand_vi2_vi2_vi2_rvvm1_sleef(dfigeti_vi2_dfi_rvvm1_sleef(dfi_rvvm1_sleef), vcast_vi2_i_rvvm1_sleef(1)), vcast_vi2_i_rvvm1_sleef(1)); + vfloat2_rvvm1_sleef x = vcast_vf2_vf_vf_rvvm1_sleef(vmulsign_vf_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(3.1415927410125732422f*-0.5), vf2getx_vf_vf2_rvvm1_sleef(dfigetdf_vf2_dfi_rvvm1_sleef(dfi_rvvm1_sleef))), + vmulsign_vf_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(-8.7422776573475857731e-08f*-0.5), vf2getx_vf_vf2_rvvm1_sleef(dfigetdf_vf2_dfi_rvvm1_sleef(dfi_rvvm1_sleef)))); + x = dfadd2_vf2_vf2_vf2_rvvm1_sleef(dfigetdf_vf2_dfi_rvvm1_sleef(dfi_rvvm1_sleef), x); + dfi_rvvm1_sleef = dfisetdf_dfi_dfi_vf2_rvvm1_sleef(dfi_rvvm1_sleef, vsel_vf2_vo_vf2_vf2_rvvm1_sleef(o, x, dfigetdf_vf2_dfi_rvvm1_sleef(dfi_rvvm1_sleef))); + d = vadd_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(dfigetdf_vf2_dfi_rvvm1_sleef(dfi_rvvm1_sleef)), vf2gety_vf_vf2_rvvm1_sleef(dfigetdf_vf2_dfi_rvvm1_sleef(dfi_rvvm1_sleef))); + + d = vreinterpret_vf_vm_rvvm1_sleef(vor_vm_vo32_vm_rvvm1_sleef(rvv_sp_vor_vo_vo_vo(visinf_vo_vf_rvvm1_sleef(r), visnan_vo_vf_rvvm1_sleef(r)), vreinterpret_vm_vf_rvvm1_sleef(d))); + } + + s = vmul_vf_vf_vf_rvvm1_sleef(d, d); + + d = vreinterpret_vf_vm_rvvm1_sleef(vxor_vm_vm_vm_rvvm1_sleef(vand_vm_vo32_vm_rvvm1_sleef(veq_vo_vi2_vi2_rvvm1_sleef(vand_vi2_vi2_vi2_rvvm1_sleef(q, vcast_vi2_i_rvvm1_sleef(1)), vcast_vi2_i_rvvm1_sleef(1)), vreinterpret_vm_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(-0.0f))), vreinterpret_vm_vf_rvvm1_sleef(d))); + + u = vcast_vf_f_rvvm1_sleef(2.6083159809786593541503e-06f); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, s, vcast_vf_f_rvvm1_sleef(-0.0001981069071916863322258f)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, s, vcast_vf_f_rvvm1_sleef(0.00833307858556509017944336f)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, s, vcast_vf_f_rvvm1_sleef(-0.166666597127914428710938f)); + + u = vadd_vf_vf_vf_rvvm1_sleef(vmul_vf_vf_vf_rvvm1_sleef(s, vmul_vf_vf_vf_rvvm1_sleef(u, d)), d); + + u = vsel_vf_vo_vf_vf_rvvm1_sleef(visnegzero_vo_vf_rvvm1_sleef(r), r, u); + + return u; + +} + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_cosfx_u35rvvm1(vfloat_rvvm1_sleef d) { + + vint2_rvvm1_sleef q; + vfloat_rvvm1_sleef u, s, r = d; + + if (__builtin_expect(!!(vtestallones_i_vo32_rvvm1_sleef(vlt_vo_vf_vf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(d), vcast_vf_f_rvvm1_sleef(125.0f)))), 1)) { + q = vrint_vi2_vf_rvvm1_sleef(vsub_vf_vf_vf_rvvm1_sleef(vmul_vf_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef((float)0.318309886183790671537767526745028724)), vcast_vf_f_rvvm1_sleef(0.5f))); + q = vadd_vi2_vi2_vi2_rvvm1_sleef(vadd_vi2_vi2_vi2_rvvm1_sleef(q, q), vcast_vi2_i_rvvm1_sleef(1)); + + u = vcast_vf_vi2_rvvm1_sleef(q); + d = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vcast_vf_f_rvvm1_sleef(-3.1414794921875f*0.5f), d); + d = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vcast_vf_f_rvvm1_sleef(-0.00011315941810607910156f*0.5f), d); + d = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vcast_vf_f_rvvm1_sleef(-1.9841872589410058936e-09f*0.5f), d); + } else if (__builtin_expect(!!(vtestallones_i_vo32_rvvm1_sleef(vlt_vo_vf_vf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(d), vcast_vf_f_rvvm1_sleef(39000)))), 1)) { + q = vrint_vi2_vf_rvvm1_sleef(vsub_vf_vf_vf_rvvm1_sleef(vmul_vf_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef((float)0.318309886183790671537767526745028724)), vcast_vf_f_rvvm1_sleef(0.5f))); + q = vadd_vi2_vi2_vi2_rvvm1_sleef(vadd_vi2_vi2_vi2_rvvm1_sleef(q, q), vcast_vi2_i_rvvm1_sleef(1)); + + u = vcast_vf_vi2_rvvm1_sleef(q); + d = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vcast_vf_f_rvvm1_sleef(-3.140625f*0.5f), d); + d = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vcast_vf_f_rvvm1_sleef(-0.0009670257568359375f*0.5f), d); + d = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vcast_vf_f_rvvm1_sleef(-6.2771141529083251953e-07f*0.5f), d); + d = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vcast_vf_f_rvvm1_sleef(-1.2154201256553420762e-10f*0.5f), d); + } else { + dfi_t_rvvm1_sleef dfi_rvvm1_sleef = rempif_rvvm1_sleef(d); + q = vand_vi2_vi2_vi2_rvvm1_sleef(dfigeti_vi2_dfi_rvvm1_sleef(dfi_rvvm1_sleef), vcast_vi2_i_rvvm1_sleef(3)); + q = vadd_vi2_vi2_vi2_rvvm1_sleef(vadd_vi2_vi2_vi2_rvvm1_sleef(q, q), vsel_vi2_vo_vi2_vi2_rvvm1_sleef(vgt_vo_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(dfigetdf_vf2_dfi_rvvm1_sleef(dfi_rvvm1_sleef)), vcast_vf_f_rvvm1_sleef(0)), vcast_vi2_i_rvvm1_sleef(8), vcast_vi2_i_rvvm1_sleef(7))); + q = vsra_vi2_vi2_i_rvvm1_sleef(q, 1); + rvv_sp_vopmask_rvvm1_sleef o = veq_vo_vi2_vi2_rvvm1_sleef(vand_vi2_vi2_vi2_rvvm1_sleef(dfigeti_vi2_dfi_rvvm1_sleef(dfi_rvvm1_sleef), vcast_vi2_i_rvvm1_sleef(1)), vcast_vi2_i_rvvm1_sleef(0)); + vfloat_rvvm1_sleef y = vsel_vf_vo_vf_vf_rvvm1_sleef(vgt_vo_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(dfigetdf_vf2_dfi_rvvm1_sleef(dfi_rvvm1_sleef)), vcast_vf_f_rvvm1_sleef(0)), vcast_vf_f_rvvm1_sleef(0), vcast_vf_f_rvvm1_sleef(-1)); + vfloat2_rvvm1_sleef x = vcast_vf2_vf_vf_rvvm1_sleef(vmulsign_vf_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(3.1415927410125732422f*-0.5), y), + vmulsign_vf_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(-8.7422776573475857731e-08f*-0.5), y)); + x = dfadd2_vf2_vf2_vf2_rvvm1_sleef(dfigetdf_vf2_dfi_rvvm1_sleef(dfi_rvvm1_sleef), x); + dfi_rvvm1_sleef = dfisetdf_dfi_dfi_vf2_rvvm1_sleef(dfi_rvvm1_sleef, vsel_vf2_vo_vf2_vf2_rvvm1_sleef(o, x, dfigetdf_vf2_dfi_rvvm1_sleef(dfi_rvvm1_sleef))); + d = vadd_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(dfigetdf_vf2_dfi_rvvm1_sleef(dfi_rvvm1_sleef)), vf2gety_vf_vf2_rvvm1_sleef(dfigetdf_vf2_dfi_rvvm1_sleef(dfi_rvvm1_sleef))); + + d = vreinterpret_vf_vm_rvvm1_sleef(vor_vm_vo32_vm_rvvm1_sleef(rvv_sp_vor_vo_vo_vo(visinf_vo_vf_rvvm1_sleef(r), visnan_vo_vf_rvvm1_sleef(r)), vreinterpret_vm_vf_rvvm1_sleef(d))); + } + + s = vmul_vf_vf_vf_rvvm1_sleef(d, d); + + d = vreinterpret_vf_vm_rvvm1_sleef(vxor_vm_vm_vm_rvvm1_sleef(vand_vm_vo32_vm_rvvm1_sleef(veq_vo_vi2_vi2_rvvm1_sleef(vand_vi2_vi2_vi2_rvvm1_sleef(q, vcast_vi2_i_rvvm1_sleef(2)), vcast_vi2_i_rvvm1_sleef(0)), vreinterpret_vm_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(-0.0f))), vreinterpret_vm_vf_rvvm1_sleef(d))); + + u = vcast_vf_f_rvvm1_sleef(2.6083159809786593541503e-06f); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, s, vcast_vf_f_rvvm1_sleef(-0.0001981069071916863322258f)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, s, vcast_vf_f_rvvm1_sleef(0.00833307858556509017944336f)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, s, vcast_vf_f_rvvm1_sleef(-0.166666597127914428710938f)); + + u = vadd_vf_vf_vf_rvvm1_sleef(vmul_vf_vf_vf_rvvm1_sleef(s, vmul_vf_vf_vf_rvvm1_sleef(u, d)), d); + + return u; + +} + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_tanfx_u35rvvm1(vfloat_rvvm1_sleef d) { + + vint2_rvvm1_sleef q; + rvv_sp_vopmask_rvvm1_sleef o; + vfloat_rvvm1_sleef u, s, x; + + x = d; + + if (__builtin_expect(!!(vtestallones_i_vo32_rvvm1_sleef(vlt_vo_vf_vf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(d), vcast_vf_f_rvvm1_sleef(125.0f*0.5f)))), 1)) { + q = vrint_vi2_vf_rvvm1_sleef(vmul_vf_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef((float)(2 * 0.318309886183790671537767526745028724)))); + u = vcast_vf_vi2_rvvm1_sleef(q); + x = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vcast_vf_f_rvvm1_sleef(-3.1414794921875f*0.5f), x); + x = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vcast_vf_f_rvvm1_sleef(-0.00011315941810607910156f*0.5f), x); + x = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vcast_vf_f_rvvm1_sleef(-1.9841872589410058936e-09f*0.5f), x); + } else if (__builtin_expect(!!(vtestallones_i_vo32_rvvm1_sleef(vlt_vo_vf_vf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(d), vcast_vf_f_rvvm1_sleef(39000)))), 1)) { + q = vrint_vi2_vf_rvvm1_sleef(vmul_vf_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef((float)(2 * 0.318309886183790671537767526745028724)))); + u = vcast_vf_vi2_rvvm1_sleef(q); + x = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vcast_vf_f_rvvm1_sleef(-3.140625f*0.5f), x); + x = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vcast_vf_f_rvvm1_sleef(-0.0009670257568359375f*0.5f), x); + x = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vcast_vf_f_rvvm1_sleef(-6.2771141529083251953e-07f*0.5f), x); + x = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vcast_vf_f_rvvm1_sleef(-1.2154201256553420762e-10f*0.5f), x); + } else { + dfi_t_rvvm1_sleef dfi_rvvm1_sleef = rempif_rvvm1_sleef(d); + q = dfigeti_vi2_dfi_rvvm1_sleef(dfi_rvvm1_sleef); + x = vadd_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(dfigetdf_vf2_dfi_rvvm1_sleef(dfi_rvvm1_sleef)), vf2gety_vf_vf2_rvvm1_sleef(dfigetdf_vf2_dfi_rvvm1_sleef(dfi_rvvm1_sleef))); + x = vreinterpret_vf_vm_rvvm1_sleef(vor_vm_vo32_vm_rvvm1_sleef(rvv_sp_vor_vo_vo_vo(visinf_vo_vf_rvvm1_sleef(d), visnan_vo_vf_rvvm1_sleef(d)), vreinterpret_vm_vf_rvvm1_sleef(x))); + x = vsel_vf_vo_vf_vf_rvvm1_sleef(visnegzero_vo_vf_rvvm1_sleef(d), d, x); + } + + s = vmul_vf_vf_vf_rvvm1_sleef(x, x); + + o = veq_vo_vi2_vi2_rvvm1_sleef(vand_vi2_vi2_vi2_rvvm1_sleef(q, vcast_vi2_i_rvvm1_sleef(1)), vcast_vi2_i_rvvm1_sleef(1)); + x = vreinterpret_vf_vm_rvvm1_sleef(vxor_vm_vm_vm_rvvm1_sleef(vand_vm_vo32_vm_rvvm1_sleef(o, vreinterpret_vm_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(-0.0f))), vreinterpret_vm_vf_rvvm1_sleef(x))); + + vfloat_rvvm1_sleef s2 = vmul_vf_vf_vf_rvvm1_sleef(s, s), s4 = vmul_vf_vf_vf_rvvm1_sleef(s2, s2); + u = vmla_vf_vf_vf_vf_rvvm1_sleef((s4), (vmla_vf_vf_vf_vf_rvvm1_sleef((s), (vcast_vf_f_rvvm1_sleef(0.00927245803177356719970703f)), (vcast_vf_f_rvvm1_sleef(0.00331984995864331722259521f)))), (vmla_vf_vf_vf_vf_rvvm1_sleef((s2), (vmla_vf_vf_vf_vf_rvvm1_sleef((s), (vcast_vf_f_rvvm1_sleef(0.0242998078465461730957031f)), (vcast_vf_f_rvvm1_sleef(0.0534495301544666290283203f)))), (vmla_vf_vf_vf_vf_rvvm1_sleef((s), (vcast_vf_f_rvvm1_sleef(0.133383005857467651367188f)), (vcast_vf_f_rvvm1_sleef(0.333331853151321411132812f))))))) + + ; + + u = vmla_vf_vf_vf_vf_rvvm1_sleef(s, vmul_vf_vf_vf_rvvm1_sleef(u, x), x); + + u = vsel_vf_vo_vf_vf_rvvm1_sleef(o, vrec_vf_vf_rvvm1_sleef(u), u); + + return u; + +} + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_sinfx_u10rvvm1(vfloat_rvvm1_sleef d) { + + vint2_rvvm1_sleef q; + vfloat_rvvm1_sleef u, v; + vfloat2_rvvm1_sleef s, t, x; + + if (__builtin_expect(!!(vtestallones_i_vo32_rvvm1_sleef(vlt_vo_vf_vf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(d), vcast_vf_f_rvvm1_sleef(125.0f)))), 1)) { + u = vrint_vf_vf_rvvm1_sleef(vmul_vf_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(0.318309886183790671537767526745028724))); + q = vrint_vi2_vf_rvvm1_sleef(u); + v = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vcast_vf_f_rvvm1_sleef(-3.1414794921875f), d); + s = dfadd2_vf2_vf_vf_rvvm1_sleef(v, vmul_vf_vf_vf_rvvm1_sleef(u, vcast_vf_f_rvvm1_sleef(-0.00011315941810607910156f))); + s = dfadd_vf2_vf2_vf_rvvm1_sleef(s, vmul_vf_vf_vf_rvvm1_sleef(u, vcast_vf_f_rvvm1_sleef(-1.9841872589410058936e-09f))); + } else { + dfi_t_rvvm1_sleef dfi_rvvm1_sleef = rempif_rvvm1_sleef(d); + q = vand_vi2_vi2_vi2_rvvm1_sleef(dfigeti_vi2_dfi_rvvm1_sleef(dfi_rvvm1_sleef), vcast_vi2_i_rvvm1_sleef(3)); + q = vadd_vi2_vi2_vi2_rvvm1_sleef(vadd_vi2_vi2_vi2_rvvm1_sleef(q, q), vsel_vi2_vo_vi2_vi2_rvvm1_sleef(vgt_vo_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(dfigetdf_vf2_dfi_rvvm1_sleef(dfi_rvvm1_sleef)), vcast_vf_f_rvvm1_sleef(0)), vcast_vi2_i_rvvm1_sleef(2), vcast_vi2_i_rvvm1_sleef(1))); + q = vsra_vi2_vi2_i_rvvm1_sleef(q, 2); + rvv_sp_vopmask_rvvm1_sleef o = veq_vo_vi2_vi2_rvvm1_sleef(vand_vi2_vi2_vi2_rvvm1_sleef(dfigeti_vi2_dfi_rvvm1_sleef(dfi_rvvm1_sleef), vcast_vi2_i_rvvm1_sleef(1)), vcast_vi2_i_rvvm1_sleef(1)); + vfloat2_rvvm1_sleef x = vcast_vf2_vf_vf_rvvm1_sleef(vmulsign_vf_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(3.1415927410125732422f*-0.5), vf2getx_vf_vf2_rvvm1_sleef(dfigetdf_vf2_dfi_rvvm1_sleef(dfi_rvvm1_sleef))), + vmulsign_vf_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(-8.7422776573475857731e-08f*-0.5), vf2getx_vf_vf2_rvvm1_sleef(dfigetdf_vf2_dfi_rvvm1_sleef(dfi_rvvm1_sleef)))); + x = dfadd2_vf2_vf2_vf2_rvvm1_sleef(dfigetdf_vf2_dfi_rvvm1_sleef(dfi_rvvm1_sleef), x); + dfi_rvvm1_sleef = dfisetdf_dfi_dfi_vf2_rvvm1_sleef(dfi_rvvm1_sleef, vsel_vf2_vo_vf2_vf2_rvvm1_sleef(o, x, dfigetdf_vf2_dfi_rvvm1_sleef(dfi_rvvm1_sleef))); + s = dfnormalize_vf2_vf2_rvvm1_sleef(dfigetdf_vf2_dfi_rvvm1_sleef(dfi_rvvm1_sleef)); + + s = vf2setx_vf2_vf2_vf_rvvm1_sleef(s, vreinterpret_vf_vm_rvvm1_sleef(vor_vm_vo32_vm_rvvm1_sleef(rvv_sp_vor_vo_vo_vo(visinf_vo_vf_rvvm1_sleef(d), visnan_vo_vf_rvvm1_sleef(d)), vreinterpret_vm_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(s))))); + + } + + t = s; + s = dfsqu_vf2_vf2_rvvm1_sleef(s); + + u = vcast_vf_f_rvvm1_sleef(2.6083159809786593541503e-06f); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vf2getx_vf_vf2_rvvm1_sleef(s), vcast_vf_f_rvvm1_sleef(-0.0001981069071916863322258f)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vf2getx_vf_vf2_rvvm1_sleef(s), vcast_vf_f_rvvm1_sleef(0.00833307858556509017944336f)); + + x = dfadd_vf2_vf_vf2_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(1), dfmul_vf2_vf2_vf2_rvvm1_sleef(dfadd_vf2_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(-0.166666597127914428710938f), vmul_vf_vf_vf_rvvm1_sleef(u, vf2getx_vf_vf2_rvvm1_sleef(s))), s)); + + u = dfmul_vf_vf2_vf2_rvvm1_sleef(t, x); + + u = vreinterpret_vf_vm_rvvm1_sleef(vxor_vm_vm_vm_rvvm1_sleef(vand_vm_vo32_vm_rvvm1_sleef(veq_vo_vi2_vi2_rvvm1_sleef(vand_vi2_vi2_vi2_rvvm1_sleef(q, vcast_vi2_i_rvvm1_sleef(1)), vcast_vi2_i_rvvm1_sleef(1)), vreinterpret_vm_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(-0.0))), vreinterpret_vm_vf_rvvm1_sleef(u))); + + u = vsel_vf_vo_vf_vf_rvvm1_sleef(visnegzero_vo_vf_rvvm1_sleef(d), d, u); + + return u; + +} + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_cosfx_u10rvvm1(vfloat_rvvm1_sleef d) { + + vint2_rvvm1_sleef q; + vfloat_rvvm1_sleef u; + vfloat2_rvvm1_sleef s, t, x; + + if (__builtin_expect(!!(vtestallones_i_vo32_rvvm1_sleef(vlt_vo_vf_vf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(d), vcast_vf_f_rvvm1_sleef(125.0f)))), 1)) { + vfloat_rvvm1_sleef dq = vmla_vf_vf_vf_vf_rvvm1_sleef(vrint_vf_vf_rvvm1_sleef(vmla_vf_vf_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(0.318309886183790671537767526745028724), vcast_vf_f_rvvm1_sleef(-0.5f))), + vcast_vf_f_rvvm1_sleef(2), vcast_vf_f_rvvm1_sleef(1)); + q = vrint_vi2_vf_rvvm1_sleef(dq); + s = dfadd2_vf2_vf_vf_rvvm1_sleef (d, vmul_vf_vf_vf_rvvm1_sleef(dq, vcast_vf_f_rvvm1_sleef(-3.1414794921875f*0.5f))); + s = dfadd2_vf2_vf2_vf_rvvm1_sleef(s, vmul_vf_vf_vf_rvvm1_sleef(dq, vcast_vf_f_rvvm1_sleef(-0.00011315941810607910156f*0.5f))); + s = dfadd2_vf2_vf2_vf_rvvm1_sleef(s, vmul_vf_vf_vf_rvvm1_sleef(dq, vcast_vf_f_rvvm1_sleef(-1.9841872589410058936e-09f*0.5f))); + } else { + dfi_t_rvvm1_sleef dfi_rvvm1_sleef = rempif_rvvm1_sleef(d); + q = vand_vi2_vi2_vi2_rvvm1_sleef(dfigeti_vi2_dfi_rvvm1_sleef(dfi_rvvm1_sleef), vcast_vi2_i_rvvm1_sleef(3)); + q = vadd_vi2_vi2_vi2_rvvm1_sleef(vadd_vi2_vi2_vi2_rvvm1_sleef(q, q), vsel_vi2_vo_vi2_vi2_rvvm1_sleef(vgt_vo_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(dfigetdf_vf2_dfi_rvvm1_sleef(dfi_rvvm1_sleef)), vcast_vf_f_rvvm1_sleef(0)), vcast_vi2_i_rvvm1_sleef(8), vcast_vi2_i_rvvm1_sleef(7))); + q = vsra_vi2_vi2_i_rvvm1_sleef(q, 1); + rvv_sp_vopmask_rvvm1_sleef o = veq_vo_vi2_vi2_rvvm1_sleef(vand_vi2_vi2_vi2_rvvm1_sleef(dfigeti_vi2_dfi_rvvm1_sleef(dfi_rvvm1_sleef), vcast_vi2_i_rvvm1_sleef(1)), vcast_vi2_i_rvvm1_sleef(0)); + vfloat_rvvm1_sleef y = vsel_vf_vo_vf_vf_rvvm1_sleef(vgt_vo_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(dfigetdf_vf2_dfi_rvvm1_sleef(dfi_rvvm1_sleef)), vcast_vf_f_rvvm1_sleef(0)), vcast_vf_f_rvvm1_sleef(0), vcast_vf_f_rvvm1_sleef(-1)); + vfloat2_rvvm1_sleef x = vcast_vf2_vf_vf_rvvm1_sleef(vmulsign_vf_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(3.1415927410125732422f*-0.5), y), + vmulsign_vf_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(-8.7422776573475857731e-08f*-0.5), y)); + x = dfadd2_vf2_vf2_vf2_rvvm1_sleef(dfigetdf_vf2_dfi_rvvm1_sleef(dfi_rvvm1_sleef), x); + dfi_rvvm1_sleef = dfisetdf_dfi_dfi_vf2_rvvm1_sleef(dfi_rvvm1_sleef, vsel_vf2_vo_vf2_vf2_rvvm1_sleef(o, x, dfigetdf_vf2_dfi_rvvm1_sleef(dfi_rvvm1_sleef))); + s = dfnormalize_vf2_vf2_rvvm1_sleef(dfigetdf_vf2_dfi_rvvm1_sleef(dfi_rvvm1_sleef)); + + s = vf2setx_vf2_vf2_vf_rvvm1_sleef(s, vreinterpret_vf_vm_rvvm1_sleef(vor_vm_vo32_vm_rvvm1_sleef(rvv_sp_vor_vo_vo_vo(visinf_vo_vf_rvvm1_sleef(d), visnan_vo_vf_rvvm1_sleef(d)), vreinterpret_vm_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(s))))); + + } + + t = s; + s = dfsqu_vf2_vf2_rvvm1_sleef(s); + + u = vcast_vf_f_rvvm1_sleef(2.6083159809786593541503e-06f); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vf2getx_vf_vf2_rvvm1_sleef(s), vcast_vf_f_rvvm1_sleef(-0.0001981069071916863322258f)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vf2getx_vf_vf2_rvvm1_sleef(s), vcast_vf_f_rvvm1_sleef(0.00833307858556509017944336f)); + + x = dfadd_vf2_vf_vf2_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(1), dfmul_vf2_vf2_vf2_rvvm1_sleef(dfadd_vf2_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(-0.166666597127914428710938f), vmul_vf_vf_vf_rvvm1_sleef(u, vf2getx_vf_vf2_rvvm1_sleef(s))), s)); + + u = dfmul_vf_vf2_vf2_rvvm1_sleef(t, x); + + u = vreinterpret_vf_vm_rvvm1_sleef(vxor_vm_vm_vm_rvvm1_sleef(vand_vm_vo32_vm_rvvm1_sleef(veq_vo_vi2_vi2_rvvm1_sleef(vand_vi2_vi2_vi2_rvvm1_sleef(q, vcast_vi2_i_rvvm1_sleef(2)), vcast_vi2_i_rvvm1_sleef(0)), vreinterpret_vm_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(-0.0))), vreinterpret_vm_vf_rvvm1_sleef(u))); + + return u; + +} + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_fastsinfx_u3500rvvm1(vfloat_rvvm1_sleef d) { + vint2_rvvm1_sleef q; + vfloat_rvvm1_sleef u, s, t = d; + + s = vmul_vf_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef((float)0.318309886183790671537767526745028724)); + u = vrint_vf_vf_rvvm1_sleef(s); + q = vrint_vi2_vf_rvvm1_sleef(s); + d = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vcast_vf_f_rvvm1_sleef(-(float)3.141592653589793238462643383279502884), d); + + s = vmul_vf_vf_vf_rvvm1_sleef(d, d); + + u = vcast_vf_f_rvvm1_sleef(-0.1881748176e-3); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, s, vcast_vf_f_rvvm1_sleef(+0.8323502727e-2)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, s, vcast_vf_f_rvvm1_sleef(-0.1666651368e+0)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(vmul_vf_vf_vf_rvvm1_sleef(s, d), u, d); + + u = vreinterpret_vf_vm_rvvm1_sleef(vxor_vm_vm_vm_rvvm1_sleef(vand_vm_vo32_vm_rvvm1_sleef(veq_vo_vi2_vi2_rvvm1_sleef(vand_vi2_vi2_vi2_rvvm1_sleef(q, vcast_vi2_i_rvvm1_sleef(1)), vcast_vi2_i_rvvm1_sleef(1)), vreinterpret_vm_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(-0.0f))), vreinterpret_vm_vf_rvvm1_sleef(u))); + + rvv_sp_vopmask_rvvm1_sleef g = vlt_vo_vf_vf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(t), vcast_vf_f_rvvm1_sleef(30.0f)); + if (!__builtin_expect(!!(vtestallones_i_vo32_rvvm1_sleef(g)), 1)) return vsel_vf_vo_vf_vf_rvvm1_sleef(g, u, Sleef_sinfx_u35rvvm1(t)); + + return u; +} + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_fastcosfx_u3500rvvm1(vfloat_rvvm1_sleef d) { + vint2_rvvm1_sleef q; + vfloat_rvvm1_sleef u, s, t = d; + + s = vmla_vf_vf_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef((float)0.318309886183790671537767526745028724), vcast_vf_f_rvvm1_sleef(-0.5f)); + u = vrint_vf_vf_rvvm1_sleef(s); + q = vrint_vi2_vf_rvvm1_sleef(s); + d = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vcast_vf_f_rvvm1_sleef(-(float)3.141592653589793238462643383279502884), vsub_vf_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef((float)3.141592653589793238462643383279502884 * 0.5f))); + + s = vmul_vf_vf_vf_rvvm1_sleef(d, d); + + u = vcast_vf_f_rvvm1_sleef(-0.1881748176e-3); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, s, vcast_vf_f_rvvm1_sleef(+0.8323502727e-2)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, s, vcast_vf_f_rvvm1_sleef(-0.1666651368e+0)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(vmul_vf_vf_vf_rvvm1_sleef(s, d), u, d); + + u = vreinterpret_vf_vm_rvvm1_sleef(vxor_vm_vm_vm_rvvm1_sleef(vand_vm_vo32_vm_rvvm1_sleef(veq_vo_vi2_vi2_rvvm1_sleef(vand_vi2_vi2_vi2_rvvm1_sleef(q, vcast_vi2_i_rvvm1_sleef(1)), vcast_vi2_i_rvvm1_sleef(0)), vreinterpret_vm_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(-0.0f))), vreinterpret_vm_vf_rvvm1_sleef(u))); + + rvv_sp_vopmask_rvvm1_sleef g = vlt_vo_vf_vf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(t), vcast_vf_f_rvvm1_sleef(30.0f)); + if (!__builtin_expect(!!(vtestallones_i_vo32_rvvm1_sleef(g)), 1)) return vsel_vf_vo_vf_vf_rvvm1_sleef(g, u, Sleef_cosfx_u35rvvm1(t)); + + return u; +} + +SLEEF_INLINE SLEEF_CONST vfloat2_rvvm1_sleef Sleef_sincosfx_u35rvvm1(vfloat_rvvm1_sleef d) { + + vint2_rvvm1_sleef q; + rvv_sp_vopmask_rvvm1_sleef o; + vfloat_rvvm1_sleef u, s, t, rx, ry; + vfloat2_rvvm1_sleef r; + + s = d; + + if (__builtin_expect(!!(vtestallones_i_vo32_rvvm1_sleef(vlt_vo_vf_vf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(d), vcast_vf_f_rvvm1_sleef(125.0f)))), 1)) { + q = vrint_vi2_vf_rvvm1_sleef(vmul_vf_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef((float)0.636619772367581343075535053490057448))); + u = vcast_vf_vi2_rvvm1_sleef(q); + s = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vcast_vf_f_rvvm1_sleef(-3.1414794921875f*0.5f), s); + s = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vcast_vf_f_rvvm1_sleef(-0.00011315941810607910156f*0.5f), s); + s = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vcast_vf_f_rvvm1_sleef(-1.9841872589410058936e-09f*0.5f), s); + } else if (__builtin_expect(!!(vtestallones_i_vo32_rvvm1_sleef(vlt_vo_vf_vf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(d), vcast_vf_f_rvvm1_sleef(39000)))), 1)) { + q = vrint_vi2_vf_rvvm1_sleef(vmul_vf_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef((float)0.636619772367581343075535053490057448))); + u = vcast_vf_vi2_rvvm1_sleef(q); + s = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vcast_vf_f_rvvm1_sleef(-3.140625f*0.5f), s); + s = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vcast_vf_f_rvvm1_sleef(-0.0009670257568359375f*0.5f), s); + s = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vcast_vf_f_rvvm1_sleef(-6.2771141529083251953e-07f*0.5f), s); + s = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vcast_vf_f_rvvm1_sleef(-1.2154201256553420762e-10f*0.5f), s); + } else { + dfi_t_rvvm1_sleef dfi_rvvm1_sleef = rempif_rvvm1_sleef(d); + q = dfigeti_vi2_dfi_rvvm1_sleef(dfi_rvvm1_sleef); + s = vadd_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(dfigetdf_vf2_dfi_rvvm1_sleef(dfi_rvvm1_sleef)), vf2gety_vf_vf2_rvvm1_sleef(dfigetdf_vf2_dfi_rvvm1_sleef(dfi_rvvm1_sleef))); + s = vreinterpret_vf_vm_rvvm1_sleef(vor_vm_vo32_vm_rvvm1_sleef(rvv_sp_vor_vo_vo_vo(visinf_vo_vf_rvvm1_sleef(d), visnan_vo_vf_rvvm1_sleef(d)), vreinterpret_vm_vf_rvvm1_sleef(s))); + } + + t = s; + + s = vmul_vf_vf_vf_rvvm1_sleef(s, s); + + u = vcast_vf_f_rvvm1_sleef(-0.000195169282960705459117889f); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, s, vcast_vf_f_rvvm1_sleef(0.00833215750753879547119141f)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, s, vcast_vf_f_rvvm1_sleef(-0.166666537523269653320312f)); + + rx = vmla_vf_vf_vf_vf_rvvm1_sleef(vmul_vf_vf_vf_rvvm1_sleef(u, s), t, t); + rx = vsel_vf_vo_vf_vf_rvvm1_sleef(visnegzero_vo_vf_rvvm1_sleef(d), vcast_vf_f_rvvm1_sleef(-0.0f), rx); + + u = vcast_vf_f_rvvm1_sleef(-2.71811842367242206819355e-07f); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, s, vcast_vf_f_rvvm1_sleef(2.47990446951007470488548e-05f)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, s, vcast_vf_f_rvvm1_sleef(-0.00138888787478208541870117f)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, s, vcast_vf_f_rvvm1_sleef(0.0416666641831398010253906f)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, s, vcast_vf_f_rvvm1_sleef(-0.5)); + + ry = vmla_vf_vf_vf_vf_rvvm1_sleef(s, u, vcast_vf_f_rvvm1_sleef(1)); + + o = veq_vo_vi2_vi2_rvvm1_sleef(vand_vi2_vi2_vi2_rvvm1_sleef(q, vcast_vi2_i_rvvm1_sleef(1)), vcast_vi2_i_rvvm1_sleef(0)); + r = vf2setxy_vf2_vf_vf_rvvm1_sleef(vsel_vf_vo_vf_vf_rvvm1_sleef(o, rx, ry), vsel_vf_vo_vf_vf_rvvm1_sleef(o, ry, rx)); + + o = veq_vo_vi2_vi2_rvvm1_sleef(vand_vi2_vi2_vi2_rvvm1_sleef(q, vcast_vi2_i_rvvm1_sleef(2)), vcast_vi2_i_rvvm1_sleef(2)); + r = vf2setx_vf2_vf2_vf_rvvm1_sleef(r, vreinterpret_vf_vm_rvvm1_sleef(vxor_vm_vm_vm_rvvm1_sleef(vand_vm_vo32_vm_rvvm1_sleef(o, vreinterpret_vm_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(-0.0))), vreinterpret_vm_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(r))))); + + o = veq_vo_vi2_vi2_rvvm1_sleef(vand_vi2_vi2_vi2_rvvm1_sleef(vadd_vi2_vi2_vi2_rvvm1_sleef(q, vcast_vi2_i_rvvm1_sleef(1)), vcast_vi2_i_rvvm1_sleef(2)), vcast_vi2_i_rvvm1_sleef(2)); + r = vf2sety_vf2_vf2_vf_rvvm1_sleef(r, vreinterpret_vf_vm_rvvm1_sleef(vxor_vm_vm_vm_rvvm1_sleef(vand_vm_vo32_vm_rvvm1_sleef(o, vreinterpret_vm_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(-0.0))), vreinterpret_vm_vf_rvvm1_sleef(vf2gety_vf_vf2_rvvm1_sleef(r))))); + + return r; + +} + +SLEEF_INLINE SLEEF_CONST vfloat2_rvvm1_sleef Sleef_sincosfx_u10rvvm1(vfloat_rvvm1_sleef d) { + + vint2_rvvm1_sleef q; + rvv_sp_vopmask_rvvm1_sleef o; + vfloat_rvvm1_sleef u, v, rx, ry; + vfloat2_rvvm1_sleef r, s, t, x; + + if (__builtin_expect(!!(vtestallones_i_vo32_rvvm1_sleef(vlt_vo_vf_vf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(d), vcast_vf_f_rvvm1_sleef(125.0f)))), 1)) { + u = vrint_vf_vf_rvvm1_sleef(vmul_vf_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(2 * 0.318309886183790671537767526745028724))); + q = vrint_vi2_vf_rvvm1_sleef(u); + v = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vcast_vf_f_rvvm1_sleef(-3.1414794921875f*0.5f), d); + s = dfadd2_vf2_vf_vf_rvvm1_sleef(v, vmul_vf_vf_vf_rvvm1_sleef(u, vcast_vf_f_rvvm1_sleef(-0.00011315941810607910156f*0.5f))); + s = dfadd_vf2_vf2_vf_rvvm1_sleef(s, vmul_vf_vf_vf_rvvm1_sleef(u, vcast_vf_f_rvvm1_sleef(-1.9841872589410058936e-09f*0.5f))); + } else { + dfi_t_rvvm1_sleef dfi_rvvm1_sleef = rempif_rvvm1_sleef(d); + q = dfigeti_vi2_dfi_rvvm1_sleef(dfi_rvvm1_sleef); + s = dfigetdf_vf2_dfi_rvvm1_sleef(dfi_rvvm1_sleef); + o = rvv_sp_vor_vo_vo_vo(visinf_vo_vf_rvvm1_sleef(d), visnan_vo_vf_rvvm1_sleef(d)); + s = vf2setx_vf2_vf2_vf_rvvm1_sleef(s, vreinterpret_vf_vm_rvvm1_sleef(vor_vm_vo32_vm_rvvm1_sleef(o, vreinterpret_vm_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(s))))); + } + + t = s; + + s = vf2setx_vf2_vf2_vf_rvvm1_sleef(s, dfsqu_vf_vf2_rvvm1_sleef(s)); + + u = vcast_vf_f_rvvm1_sleef(-0.000195169282960705459117889f); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vf2getx_vf_vf2_rvvm1_sleef(s), vcast_vf_f_rvvm1_sleef(0.00833215750753879547119141f)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vf2getx_vf_vf2_rvvm1_sleef(s), vcast_vf_f_rvvm1_sleef(-0.166666537523269653320312f)); + + u = vmul_vf_vf_vf_rvvm1_sleef(u, vmul_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(s), vf2getx_vf_vf2_rvvm1_sleef(t))); + + x = dfadd_vf2_vf2_vf_rvvm1_sleef(t, u); + rx = vadd_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(x), vf2gety_vf_vf2_rvvm1_sleef(x)); + + rx = vsel_vf_vo_vf_vf_rvvm1_sleef(visnegzero_vo_vf_rvvm1_sleef(d), vcast_vf_f_rvvm1_sleef(-0.0f), rx); + + u = vcast_vf_f_rvvm1_sleef(-2.71811842367242206819355e-07f); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vf2getx_vf_vf2_rvvm1_sleef(s), vcast_vf_f_rvvm1_sleef(2.47990446951007470488548e-05f)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vf2getx_vf_vf2_rvvm1_sleef(s), vcast_vf_f_rvvm1_sleef(-0.00138888787478208541870117f)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vf2getx_vf_vf2_rvvm1_sleef(s), vcast_vf_f_rvvm1_sleef(0.0416666641831398010253906f)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vf2getx_vf_vf2_rvvm1_sleef(s), vcast_vf_f_rvvm1_sleef(-0.5)); + + x = dfadd_vf2_vf_vf2_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(1), dfmul_vf2_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(s), u)); + ry = vadd_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(x), vf2gety_vf_vf2_rvvm1_sleef(x)); + + o = veq_vo_vi2_vi2_rvvm1_sleef(vand_vi2_vi2_vi2_rvvm1_sleef(q, vcast_vi2_i_rvvm1_sleef(1)), vcast_vi2_i_rvvm1_sleef(0)); + r = vf2setxy_vf2_vf_vf_rvvm1_sleef(vsel_vf_vo_vf_vf_rvvm1_sleef(o, rx, ry), vsel_vf_vo_vf_vf_rvvm1_sleef(o, ry, rx)); + + o = veq_vo_vi2_vi2_rvvm1_sleef(vand_vi2_vi2_vi2_rvvm1_sleef(q, vcast_vi2_i_rvvm1_sleef(2)), vcast_vi2_i_rvvm1_sleef(2)); + r = vf2setx_vf2_vf2_vf_rvvm1_sleef(r, vreinterpret_vf_vm_rvvm1_sleef(vxor_vm_vm_vm_rvvm1_sleef(vand_vm_vo32_vm_rvvm1_sleef(o, vreinterpret_vm_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(-0.0))), vreinterpret_vm_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(r))))); + + o = veq_vo_vi2_vi2_rvvm1_sleef(vand_vi2_vi2_vi2_rvvm1_sleef(vadd_vi2_vi2_vi2_rvvm1_sleef(q, vcast_vi2_i_rvvm1_sleef(1)), vcast_vi2_i_rvvm1_sleef(2)), vcast_vi2_i_rvvm1_sleef(2)); + r = vf2sety_vf2_vf2_vf_rvvm1_sleef(r, vreinterpret_vf_vm_rvvm1_sleef(vxor_vm_vm_vm_rvvm1_sleef(vand_vm_vo32_vm_rvvm1_sleef(o, vreinterpret_vm_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(-0.0))), vreinterpret_vm_vf_rvvm1_sleef(vf2gety_vf_vf2_rvvm1_sleef(r))))); + + return r; + +} + +SLEEF_INLINE SLEEF_CONST vfloat2_rvvm1_sleef Sleef_sincospifx_u05rvvm1(vfloat_rvvm1_sleef d) { + rvv_sp_vopmask_rvvm1_sleef o; + vfloat_rvvm1_sleef u, s, t, rx, ry; + vfloat2_rvvm1_sleef r, x, s2; + + u = vmul_vf_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(4)); + vint2_rvvm1_sleef q = vtruncate_vi2_vf_rvvm1_sleef(u); + q = vand_vi2_vi2_vi2_rvvm1_sleef(vadd_vi2_vi2_vi2_rvvm1_sleef(q, vxor_vi2_vi2_vi2_rvvm1_sleef(vsrl_vi2_vi2_i_rvvm1_sleef(q, 31), vcast_vi2_i_rvvm1_sleef(1))), vcast_vi2_i_rvvm1_sleef(~1)); + s = vsub_vf_vf_vf_rvvm1_sleef(u, vcast_vf_vi2_rvvm1_sleef(q)); + + t = s; + s = vmul_vf_vf_vf_rvvm1_sleef(s, s); + s2 = dfmul_vf2_vf_vf_rvvm1_sleef(t, t); + + u = vcast_vf_f_rvvm1_sleef(+0.3093842054e-6); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, s, vcast_vf_f_rvvm1_sleef(-0.3657307388e-4)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, s, vcast_vf_f_rvvm1_sleef(+0.2490393585e-2)); + x = dfadd2_vf2_vf_vf2_rvvm1_sleef(vmul_vf_vf_vf_rvvm1_sleef(u, s), vcast_vf2_f_f_rvvm1_sleef(-0.080745510756969451904, -1.3373665339076936258e-09)); + x = dfadd2_vf2_vf2_vf2_rvvm1_sleef(dfmul_vf2_vf2_vf2_rvvm1_sleef(s2, x), vcast_vf2_f_f_rvvm1_sleef(0.78539818525314331055, -2.1857338617566484855e-08)); + + x = dfmul_vf2_vf2_vf_rvvm1_sleef(x, t); + rx = vadd_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(x), vf2gety_vf_vf2_rvvm1_sleef(x)); + + rx = vsel_vf_vo_vf_vf_rvvm1_sleef(visnegzero_vo_vf_rvvm1_sleef(d), vcast_vf_f_rvvm1_sleef(-0.0f), rx); + + u = vcast_vf_f_rvvm1_sleef(-0.2430611801e-7); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, s, vcast_vf_f_rvvm1_sleef(+0.3590577080e-5)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, s, vcast_vf_f_rvvm1_sleef(-0.3259917721e-3)); + x = dfadd2_vf2_vf_vf2_rvvm1_sleef(vmul_vf_vf_vf_rvvm1_sleef(u, s), vcast_vf2_f_f_rvvm1_sleef(0.015854343771934509277, 4.4940051354032242811e-10)); + x = dfadd2_vf2_vf2_vf2_rvvm1_sleef(dfmul_vf2_vf2_vf2_rvvm1_sleef(s2, x), vcast_vf2_f_f_rvvm1_sleef(-0.30842512845993041992, -9.0728339030733922277e-09)); + + x = dfadd2_vf2_vf2_vf_rvvm1_sleef(dfmul_vf2_vf2_vf2_rvvm1_sleef(x, s2), vcast_vf_f_rvvm1_sleef(1)); + ry = vadd_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(x), vf2gety_vf_vf2_rvvm1_sleef(x)); + + o = veq_vo_vi2_vi2_rvvm1_sleef(vand_vi2_vi2_vi2_rvvm1_sleef(q, vcast_vi2_i_rvvm1_sleef(2)), vcast_vi2_i_rvvm1_sleef(0)); + r = vf2setxy_vf2_vf_vf_rvvm1_sleef(vsel_vf_vo_vf_vf_rvvm1_sleef(o, rx, ry), vsel_vf_vo_vf_vf_rvvm1_sleef(o, ry, rx)); + + o = veq_vo_vi2_vi2_rvvm1_sleef(vand_vi2_vi2_vi2_rvvm1_sleef(q, vcast_vi2_i_rvvm1_sleef(4)), vcast_vi2_i_rvvm1_sleef(4)); + r = vf2setx_vf2_vf2_vf_rvvm1_sleef(r, vreinterpret_vf_vm_rvvm1_sleef(vxor_vm_vm_vm_rvvm1_sleef(vand_vm_vo32_vm_rvvm1_sleef(o, vreinterpret_vm_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(-0.0))), vreinterpret_vm_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(r))))); + + o = veq_vo_vi2_vi2_rvvm1_sleef(vand_vi2_vi2_vi2_rvvm1_sleef(vadd_vi2_vi2_vi2_rvvm1_sleef(q, vcast_vi2_i_rvvm1_sleef(2)), vcast_vi2_i_rvvm1_sleef(4)), vcast_vi2_i_rvvm1_sleef(4)); + r = vf2sety_vf2_vf2_vf_rvvm1_sleef(r, vreinterpret_vf_vm_rvvm1_sleef(vxor_vm_vm_vm_rvvm1_sleef(vand_vm_vo32_vm_rvvm1_sleef(o, vreinterpret_vm_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(-0.0))), vreinterpret_vm_vf_rvvm1_sleef(vf2gety_vf_vf2_rvvm1_sleef(r))))); + + o = vgt_vo_vf_vf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(d), vcast_vf_f_rvvm1_sleef(1e+7f)); + r = vf2setx_vf2_vf2_vf_rvvm1_sleef(r, vreinterpret_vf_vm_rvvm1_sleef(vandnot_vm_vo32_vm_rvvm1_sleef(o, vreinterpret_vm_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(r))))); + r = vf2sety_vf2_vf2_vf_rvvm1_sleef(r, vreinterpret_vf_vm_rvvm1_sleef(vandnot_vm_vo32_vm_rvvm1_sleef(o, vreinterpret_vm_vf_rvvm1_sleef(vf2gety_vf_vf2_rvvm1_sleef(r))))); + + o = visinf_vo_vf_rvvm1_sleef(d); + r = vf2setx_vf2_vf2_vf_rvvm1_sleef(r, vreinterpret_vf_vm_rvvm1_sleef(vor_vm_vo32_vm_rvvm1_sleef(o, vreinterpret_vm_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(r))))); + r = vf2sety_vf2_vf2_vf_rvvm1_sleef(r, vreinterpret_vf_vm_rvvm1_sleef(vor_vm_vo32_vm_rvvm1_sleef(o, vreinterpret_vm_vf_rvvm1_sleef(vf2gety_vf_vf2_rvvm1_sleef(r))))); + + return r; +} + +SLEEF_INLINE SLEEF_CONST vfloat2_rvvm1_sleef Sleef_sincospifx_u35rvvm1(vfloat_rvvm1_sleef d) { + rvv_sp_vopmask_rvvm1_sleef o; + vfloat_rvvm1_sleef u, s, t, rx, ry; + vfloat2_rvvm1_sleef r; + + u = vmul_vf_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(4)); + vint2_rvvm1_sleef q = vtruncate_vi2_vf_rvvm1_sleef(u); + q = vand_vi2_vi2_vi2_rvvm1_sleef(vadd_vi2_vi2_vi2_rvvm1_sleef(q, vxor_vi2_vi2_vi2_rvvm1_sleef(vsrl_vi2_vi2_i_rvvm1_sleef(q, 31), vcast_vi2_i_rvvm1_sleef(1))), vcast_vi2_i_rvvm1_sleef(~1)); + s = vsub_vf_vf_vf_rvvm1_sleef(u, vcast_vf_vi2_rvvm1_sleef(q)); + + t = s; + s = vmul_vf_vf_vf_rvvm1_sleef(s, s); + + u = vcast_vf_f_rvvm1_sleef(-0.3600925265e-4); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, s, vcast_vf_f_rvvm1_sleef(+0.2490088111e-2)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, s, vcast_vf_f_rvvm1_sleef(-0.8074551076e-1)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, s, vcast_vf_f_rvvm1_sleef(+0.7853981853e+0)); + + rx = vmul_vf_vf_vf_rvvm1_sleef(u, t); + + u = vcast_vf_f_rvvm1_sleef(+0.3539815225e-5); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, s, vcast_vf_f_rvvm1_sleef(-0.3259574005e-3)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, s, vcast_vf_f_rvvm1_sleef(+0.1585431583e-1)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, s, vcast_vf_f_rvvm1_sleef(-0.3084251285e+0)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, s, vcast_vf_f_rvvm1_sleef(1)); + + ry = u; + + o = veq_vo_vi2_vi2_rvvm1_sleef(vand_vi2_vi2_vi2_rvvm1_sleef(q, vcast_vi2_i_rvvm1_sleef(2)), vcast_vi2_i_rvvm1_sleef(0)); + r = vf2setxy_vf2_vf_vf_rvvm1_sleef(vsel_vf_vo_vf_vf_rvvm1_sleef(o, rx, ry), vsel_vf_vo_vf_vf_rvvm1_sleef(o, ry, rx)); + + o = veq_vo_vi2_vi2_rvvm1_sleef(vand_vi2_vi2_vi2_rvvm1_sleef(q, vcast_vi2_i_rvvm1_sleef(4)), vcast_vi2_i_rvvm1_sleef(4)); + r = vf2setx_vf2_vf2_vf_rvvm1_sleef(r, vreinterpret_vf_vm_rvvm1_sleef(vxor_vm_vm_vm_rvvm1_sleef(vand_vm_vo32_vm_rvvm1_sleef(o, vreinterpret_vm_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(-0.0))), vreinterpret_vm_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(r))))); + + o = veq_vo_vi2_vi2_rvvm1_sleef(vand_vi2_vi2_vi2_rvvm1_sleef(vadd_vi2_vi2_vi2_rvvm1_sleef(q, vcast_vi2_i_rvvm1_sleef(2)), vcast_vi2_i_rvvm1_sleef(4)), vcast_vi2_i_rvvm1_sleef(4)); + r = vf2sety_vf2_vf2_vf_rvvm1_sleef(r, vreinterpret_vf_vm_rvvm1_sleef(vxor_vm_vm_vm_rvvm1_sleef(vand_vm_vo32_vm_rvvm1_sleef(o, vreinterpret_vm_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(-0.0))), vreinterpret_vm_vf_rvvm1_sleef(vf2gety_vf_vf2_rvvm1_sleef(r))))); + + o = vgt_vo_vf_vf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(d), vcast_vf_f_rvvm1_sleef(1e+7f)); + r = vf2setx_vf2_vf2_vf_rvvm1_sleef(r, vreinterpret_vf_vm_rvvm1_sleef(vandnot_vm_vo32_vm_rvvm1_sleef(o, vreinterpret_vm_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(r))))); + r = vf2sety_vf2_vf2_vf_rvvm1_sleef(r, vreinterpret_vf_vm_rvvm1_sleef(vandnot_vm_vo32_vm_rvvm1_sleef(o, vreinterpret_vm_vf_rvvm1_sleef(vf2gety_vf_vf2_rvvm1_sleef(r))))); + + o = visinf_vo_vf_rvvm1_sleef(d); + r = vf2setx_vf2_vf2_vf_rvvm1_sleef(r, vreinterpret_vf_vm_rvvm1_sleef(vor_vm_vo32_vm_rvvm1_sleef(o, vreinterpret_vm_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(r))))); + r = vf2sety_vf2_vf2_vf_rvvm1_sleef(r, vreinterpret_vf_vm_rvvm1_sleef(vor_vm_vo32_vm_rvvm1_sleef(o, vreinterpret_vm_vf_rvvm1_sleef(vf2gety_vf_vf2_rvvm1_sleef(r))))); + + return r; +} + +SLEEF_INLINE vfloat2_rvvm1_sleef Sleef_modffx_rvvm1(vfloat_rvvm1_sleef x) { + vfloat_rvvm1_sleef fr = vsub_vf_vf_vf_rvvm1_sleef(x, vcast_vf_vi2_rvvm1_sleef(vtruncate_vi2_vf_rvvm1_sleef(x))); + fr = vsel_vf_vo_vf_vf_rvvm1_sleef(vgt_vo_vf_vf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(x), vcast_vf_f_rvvm1_sleef(INT64_C(1) << 23)), vcast_vf_f_rvvm1_sleef(0), fr); + + vfloat2_rvvm1_sleef ret; + + ret = vf2setxy_vf2_vf_vf_rvvm1_sleef(vcopysign_vf_vf_vf_rvvm1_sleef(fr, x), vcopysign_vf_vf_vf_rvvm1_sleef(vsub_vf_vf_vf_rvvm1_sleef(x, fr), x)); + + return ret; +} + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_tanfx_u10rvvm1(vfloat_rvvm1_sleef d) { + + vint2_rvvm1_sleef q; + vfloat_rvvm1_sleef u, v; + vfloat2_rvvm1_sleef s, t, x; + rvv_sp_vopmask_rvvm1_sleef o; + + if (__builtin_expect(!!(vtestallones_i_vo32_rvvm1_sleef(vlt_vo_vf_vf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(d), vcast_vf_f_rvvm1_sleef(125.0f)))), 1)) { + u = vrint_vf_vf_rvvm1_sleef(vmul_vf_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(2 * 0.318309886183790671537767526745028724))); + q = vrint_vi2_vf_rvvm1_sleef(u); + v = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vcast_vf_f_rvvm1_sleef(-3.1414794921875f*0.5f), d); + s = dfadd2_vf2_vf_vf_rvvm1_sleef(v, vmul_vf_vf_vf_rvvm1_sleef(u, vcast_vf_f_rvvm1_sleef(-0.00011315941810607910156f*0.5f))); + s = dfadd_vf2_vf2_vf_rvvm1_sleef(s, vmul_vf_vf_vf_rvvm1_sleef(u, vcast_vf_f_rvvm1_sleef(-1.9841872589410058936e-09f*0.5f))); + } else { + dfi_t_rvvm1_sleef dfi_rvvm1_sleef = rempif_rvvm1_sleef(d); + q = dfigeti_vi2_dfi_rvvm1_sleef(dfi_rvvm1_sleef); + s = dfigetdf_vf2_dfi_rvvm1_sleef(dfi_rvvm1_sleef); + o = rvv_sp_vor_vo_vo_vo(visinf_vo_vf_rvvm1_sleef(d), visnan_vo_vf_rvvm1_sleef(d)); + s = vf2setx_vf2_vf2_vf_rvvm1_sleef(s, vreinterpret_vf_vm_rvvm1_sleef(vor_vm_vo32_vm_rvvm1_sleef(o, vreinterpret_vm_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(s))))); + s = vf2sety_vf2_vf2_vf_rvvm1_sleef(s, vreinterpret_vf_vm_rvvm1_sleef(vor_vm_vo32_vm_rvvm1_sleef(o, vreinterpret_vm_vf_rvvm1_sleef(vf2gety_vf_vf2_rvvm1_sleef(s))))); + } + + o = veq_vo_vi2_vi2_rvvm1_sleef(vand_vi2_vi2_vi2_rvvm1_sleef(q, vcast_vi2_i_rvvm1_sleef(1)), vcast_vi2_i_rvvm1_sleef(1)); + vmask_rvvm1_sleef n = vand_vm_vo32_vm_rvvm1_sleef(o, vreinterpret_vm_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(-0.0))); + + s = vf2setx_vf2_vf2_vf_rvvm1_sleef(s, vreinterpret_vf_vm_rvvm1_sleef(vxor_vm_vm_vm_rvvm1_sleef(vreinterpret_vm_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(s)), n))); + s = vf2sety_vf2_vf2_vf_rvvm1_sleef(s, vreinterpret_vf_vm_rvvm1_sleef(vxor_vm_vm_vm_rvvm1_sleef(vreinterpret_vm_vf_rvvm1_sleef(vf2gety_vf_vf2_rvvm1_sleef(s)), n))); + + t = s; + s = dfsqu_vf2_vf2_rvvm1_sleef(s); + s = dfnormalize_vf2_vf2_rvvm1_sleef(s); + + u = vcast_vf_f_rvvm1_sleef(0.00446636462584137916564941f); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vf2getx_vf_vf2_rvvm1_sleef(s), vcast_vf_f_rvvm1_sleef(-8.3920182078145444393158e-05f)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vf2getx_vf_vf2_rvvm1_sleef(s), vcast_vf_f_rvvm1_sleef(0.0109639242291450500488281f)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vf2getx_vf_vf2_rvvm1_sleef(s), vcast_vf_f_rvvm1_sleef(0.0212360303848981857299805f)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vf2getx_vf_vf2_rvvm1_sleef(s), vcast_vf_f_rvvm1_sleef(0.0540687143802642822265625f)); + + x = dfadd_vf2_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(0.133325666189193725585938f), vmul_vf_vf_vf_rvvm1_sleef(u, vf2getx_vf_vf2_rvvm1_sleef(s))); + x = dfadd_vf2_vf_vf2_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(1), dfmul_vf2_vf2_vf2_rvvm1_sleef(dfadd_vf2_vf_vf2_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(0.33333361148834228515625f), dfmul_vf2_vf2_vf2_rvvm1_sleef(s, x)), s)); + x = dfmul_vf2_vf2_vf2_rvvm1_sleef(t, x); + + x = vsel_vf2_vo_vf2_vf2_rvvm1_sleef(o, dfrec_vf2_vf2_rvvm1_sleef(x), x); + + u = vadd_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(x), vf2gety_vf_vf2_rvvm1_sleef(x)); + + u = vsel_vf_vo_vf_vf_rvvm1_sleef(visnegzero_vo_vf_rvvm1_sleef(d), d, u); + + return u; + +} + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_atanfx_u35rvvm1(vfloat_rvvm1_sleef d) { + vfloat_rvvm1_sleef s, t, u; + vint2_rvvm1_sleef q; + + q = vsel_vi2_vf_vi2_rvvm1_sleef(d, vcast_vi2_i_rvvm1_sleef(2)); + s = vabs_vf_vf_rvvm1_sleef(d); + + q = vsel_vi2_vf_vf_vi2_vi2_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(1.0f), s, vadd_vi2_vi2_vi2_rvvm1_sleef(q, vcast_vi2_i_rvvm1_sleef(1)), q); + s = vsel_vf_vo_vf_vf_rvvm1_sleef(vlt_vo_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(1.0f), s), vrec_vf_vf_rvvm1_sleef(s), s); + + t = vmul_vf_vf_vf_rvvm1_sleef(s, s); + + vfloat_rvvm1_sleef t2 = vmul_vf_vf_vf_rvvm1_sleef(t, t), t4 = vmul_vf_vf_vf_rvvm1_sleef(t2, t2); + u = vmla_vf_vf_vf_vf_rvvm1_sleef((t4), (vmla_vf_vf_vf_vf_rvvm1_sleef((t2), (vmla_vf_vf_vf_vf_rvvm1_sleef((t), (vcast_vf_f_rvvm1_sleef(0.00282363896258175373077393f)), (vcast_vf_f_rvvm1_sleef(-0.0159569028764963150024414f)))), (vmla_vf_vf_vf_vf_rvvm1_sleef((t), (vcast_vf_f_rvvm1_sleef(0.0425049886107444763183594f)), (vcast_vf_f_rvvm1_sleef(-0.0748900920152664184570312f)))))), (vmla_vf_vf_vf_vf_rvvm1_sleef((t2), (vmla_vf_vf_vf_vf_rvvm1_sleef((t), (vcast_vf_f_rvvm1_sleef(0.106347933411598205566406f)), (vcast_vf_f_rvvm1_sleef(-0.142027363181114196777344f)))), (vmla_vf_vf_vf_vf_rvvm1_sleef((t), (vcast_vf_f_rvvm1_sleef(0.199926957488059997558594f)), (vcast_vf_f_rvvm1_sleef(-0.333331018686294555664062f))))))) + + ; + + t = vmla_vf_vf_vf_vf_rvvm1_sleef(s, vmul_vf_vf_vf_rvvm1_sleef(t, u), s); + + t = vsel_vf_vo_vf_vf_rvvm1_sleef(veq_vo_vi2_vi2_rvvm1_sleef(vand_vi2_vi2_vi2_rvvm1_sleef(q, vcast_vi2_i_rvvm1_sleef(1)), vcast_vi2_i_rvvm1_sleef(1)), vsub_vf_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef((float)(3.141592653589793238462643383279502884/2)), t), t); + + t = vreinterpret_vf_vm_rvvm1_sleef(vxor_vm_vm_vm_rvvm1_sleef(vand_vm_vo32_vm_rvvm1_sleef(veq_vo_vi2_vi2_rvvm1_sleef(vand_vi2_vi2_vi2_rvvm1_sleef(q, vcast_vi2_i_rvvm1_sleef(2)), vcast_vi2_i_rvvm1_sleef(2)), vreinterpret_vm_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(-0.0f))), vreinterpret_vm_vf_rvvm1_sleef(t))); + + return t; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_rvvm1_sleef atan2kf_rvvm1_sleef(vfloat_rvvm1_sleef y, vfloat_rvvm1_sleef x) { + vfloat_rvvm1_sleef s, t, u; + vint2_rvvm1_sleef q; + rvv_sp_vopmask_rvvm1_sleef p; + + q = vsel_vi2_vf_vi2_rvvm1_sleef(x, vcast_vi2_i_rvvm1_sleef(-2)); + x = vabs_vf_vf_rvvm1_sleef(x); + + q = vsel_vi2_vf_vf_vi2_vi2_rvvm1_sleef(x, y, vadd_vi2_vi2_vi2_rvvm1_sleef(q, vcast_vi2_i_rvvm1_sleef(1)), q); + p = vlt_vo_vf_vf_rvvm1_sleef(x, y); + s = vsel_vf_vo_vf_vf_rvvm1_sleef(p, vneg_vf_vf_rvvm1_sleef(x), y); + t = vmax_vf_vf_vf_rvvm1_sleef(x, y); + + s = vdiv_vf_vf_vf_rvvm1_sleef(s, t); + t = vmul_vf_vf_vf_rvvm1_sleef(s, s); + + vfloat_rvvm1_sleef t2 = vmul_vf_vf_vf_rvvm1_sleef(t, t), t4 = vmul_vf_vf_vf_rvvm1_sleef(t2, t2); + u = vmla_vf_vf_vf_vf_rvvm1_sleef((t4), (vmla_vf_vf_vf_vf_rvvm1_sleef((t2), (vmla_vf_vf_vf_vf_rvvm1_sleef((t), (vcast_vf_f_rvvm1_sleef(0.00282363896258175373077393f)), (vcast_vf_f_rvvm1_sleef(-0.0159569028764963150024414f)))), (vmla_vf_vf_vf_vf_rvvm1_sleef((t), (vcast_vf_f_rvvm1_sleef(0.0425049886107444763183594f)), (vcast_vf_f_rvvm1_sleef(-0.0748900920152664184570312f)))))), (vmla_vf_vf_vf_vf_rvvm1_sleef((t2), (vmla_vf_vf_vf_vf_rvvm1_sleef((t), (vcast_vf_f_rvvm1_sleef(0.106347933411598205566406f)), (vcast_vf_f_rvvm1_sleef(-0.142027363181114196777344f)))), (vmla_vf_vf_vf_vf_rvvm1_sleef((t), (vcast_vf_f_rvvm1_sleef(0.199926957488059997558594f)), (vcast_vf_f_rvvm1_sleef(-0.333331018686294555664062f))))))) + + ; + + t = vmla_vf_vf_vf_vf_rvvm1_sleef(s, vmul_vf_vf_vf_rvvm1_sleef(t, u), s); + t = vmla_vf_vf_vf_vf_rvvm1_sleef(vcast_vf_vi2_rvvm1_sleef(q), vcast_vf_f_rvvm1_sleef((float)(3.141592653589793238462643383279502884/2)), t); + + return t; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_rvvm1_sleef visinf2_vf_vf_vf_rvvm1_sleef(vfloat_rvvm1_sleef d, vfloat_rvvm1_sleef m) { + return vreinterpret_vf_vm_rvvm1_sleef(vand_vm_vo32_vm_rvvm1_sleef(visinf_vo_vf_rvvm1_sleef(d), vor_vm_vm_vm_rvvm1_sleef(vsignbit_vm_vf_rvvm1_sleef(d), vreinterpret_vm_vf_rvvm1_sleef(m)))); +} + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_atan2fx_u35rvvm1(vfloat_rvvm1_sleef y, vfloat_rvvm1_sleef x) { + vfloat_rvvm1_sleef r = atan2kf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(y), x); + + r = vmulsign_vf_vf_vf_rvvm1_sleef(r, x); + r = vsel_vf_vo_vf_vf_rvvm1_sleef(rvv_sp_vor_vo_vo_vo(visinf_vo_vf_rvvm1_sleef(x), veq_vo_vf_vf_rvvm1_sleef(x, vcast_vf_f_rvvm1_sleef(0.0f))), vsub_vf_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef((float)(3.141592653589793238462643383279502884/2)), visinf2_vf_vf_vf_rvvm1_sleef(x, vmulsign_vf_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef((float)(3.141592653589793238462643383279502884/2)), x))), r); + r = vsel_vf_vo_vf_vf_rvvm1_sleef(visinf_vo_vf_rvvm1_sleef(y), vsub_vf_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef((float)(3.141592653589793238462643383279502884/2)), visinf2_vf_vf_vf_rvvm1_sleef(x, vmulsign_vf_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef((float)(3.141592653589793238462643383279502884/4)), x))), r); + + r = vsel_vf_vo_vf_vf_rvvm1_sleef(veq_vo_vf_vf_rvvm1_sleef(y, vcast_vf_f_rvvm1_sleef(0.0f)), vreinterpret_vf_vm_rvvm1_sleef(vand_vm_vo32_vm_rvvm1_sleef(vsignbit_vo_vf_rvvm1_sleef(x), vreinterpret_vm_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef((float)3.141592653589793238462643383279502884)))), r); + + r = vreinterpret_vf_vm_rvvm1_sleef(vor_vm_vo32_vm_rvvm1_sleef(rvv_sp_vor_vo_vo_vo(visnan_vo_vf_rvvm1_sleef(x), visnan_vo_vf_rvvm1_sleef(y)), vreinterpret_vm_vf_rvvm1_sleef(vmulsign_vf_vf_vf_rvvm1_sleef(r, y)))); + return r; +} + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_asinfx_u35rvvm1(vfloat_rvvm1_sleef d) { + rvv_sp_vopmask_rvvm1_sleef o = vlt_vo_vf_vf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(d), vcast_vf_f_rvvm1_sleef(0.5f)); + vfloat_rvvm1_sleef x2 = vsel_vf_vo_vf_vf_rvvm1_sleef(o, vmul_vf_vf_vf_rvvm1_sleef(d, d), vmul_vf_vf_vf_rvvm1_sleef(vsub_vf_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(1), vabs_vf_vf_rvvm1_sleef(d)), vcast_vf_f_rvvm1_sleef(0.5f))); + vfloat_rvvm1_sleef x = vsel_vf_vo_vf_vf_rvvm1_sleef(o, vabs_vf_vf_rvvm1_sleef(d), vsqrt_vf_vf_rvvm1_sleef(x2)), u; + + u = vcast_vf_f_rvvm1_sleef(+0.4197454825e-1); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, x2, vcast_vf_f_rvvm1_sleef(+0.2424046025e-1)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, x2, vcast_vf_f_rvvm1_sleef(+0.4547423869e-1)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, x2, vcast_vf_f_rvvm1_sleef(+0.7495029271e-1)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, x2, vcast_vf_f_rvvm1_sleef(+0.1666677296e+0)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vmul_vf_vf_vf_rvvm1_sleef(x, x2), x); + + vfloat_rvvm1_sleef r = vsel_vf_vo_vf_vf_rvvm1_sleef(o, u, vmla_vf_vf_vf_vf_rvvm1_sleef(u, vcast_vf_f_rvvm1_sleef(-2), vcast_vf_f_rvvm1_sleef(((float)3.141592653589793238462643383279502884)/2))); + return vmulsign_vf_vf_vf_rvvm1_sleef(r, d); +} + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_acosfx_u35rvvm1(vfloat_rvvm1_sleef d) { + rvv_sp_vopmask_rvvm1_sleef o = vlt_vo_vf_vf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(d), vcast_vf_f_rvvm1_sleef(0.5f)); + vfloat_rvvm1_sleef x2 = vsel_vf_vo_vf_vf_rvvm1_sleef(o, vmul_vf_vf_vf_rvvm1_sleef(d, d), + vmul_vf_vf_vf_rvvm1_sleef(vsub_vf_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(1), vabs_vf_vf_rvvm1_sleef(d)), vcast_vf_f_rvvm1_sleef(0.5f))), u; + vfloat_rvvm1_sleef x = vsel_vf_vo_vf_vf_rvvm1_sleef(o, vabs_vf_vf_rvvm1_sleef(d), vsqrt_vf_vf_rvvm1_sleef(x2)); + x = vsel_vf_vo_vf_vf_rvvm1_sleef(veq_vo_vf_vf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(d), vcast_vf_f_rvvm1_sleef(1.0f)), vcast_vf_f_rvvm1_sleef(0), x); + + u = vcast_vf_f_rvvm1_sleef(+0.4197454825e-1); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, x2, vcast_vf_f_rvvm1_sleef(+0.2424046025e-1)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, x2, vcast_vf_f_rvvm1_sleef(+0.4547423869e-1)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, x2, vcast_vf_f_rvvm1_sleef(+0.7495029271e-1)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, x2, vcast_vf_f_rvvm1_sleef(+0.1666677296e+0)); + u = vmul_vf_vf_vf_rvvm1_sleef(u, vmul_vf_vf_vf_rvvm1_sleef(x2, x)); + + vfloat_rvvm1_sleef y = vsub_vf_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(3.1415926535897932f/2), vadd_vf_vf_vf_rvvm1_sleef(vmulsign_vf_vf_vf_rvvm1_sleef(x, d), vmulsign_vf_vf_vf_rvvm1_sleef(u, d))); + x = vadd_vf_vf_vf_rvvm1_sleef(x, u); + vfloat_rvvm1_sleef r = vsel_vf_vo_vf_vf_rvvm1_sleef(o, y, vmul_vf_vf_vf_rvvm1_sleef(x, vcast_vf_f_rvvm1_sleef(2))); + return vsel_vf_vo_vf_vf_rvvm1_sleef(rvv_sp_vandnot_vo_vo_vo(o, vlt_vo_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(0))), + vf2getx_vf_vf2_rvvm1_sleef(dfadd_vf2_vf2_vf_rvvm1_sleef(vcast_vf2_f_f_rvvm1_sleef(3.1415927410125732422f,-8.7422776573475857731e-08f), + vneg_vf_vf_rvvm1_sleef(r))), r); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_rvvm1_sleef atan2kf_u1_rvvm1_sleef(vfloat2_rvvm1_sleef y, vfloat2_rvvm1_sleef x) { + vfloat_rvvm1_sleef u; + vfloat2_rvvm1_sleef s, t; + vint2_rvvm1_sleef q; + rvv_sp_vopmask_rvvm1_sleef p; + vmask_rvvm1_sleef r; + + q = vsel_vi2_vf_vf_vi2_vi2_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(x), vcast_vf_f_rvvm1_sleef(0), vcast_vi2_i_rvvm1_sleef(-2), vcast_vi2_i_rvvm1_sleef(0)); + p = vlt_vo_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(x), vcast_vf_f_rvvm1_sleef(0)); + r = vand_vm_vo32_vm_rvvm1_sleef(p, vreinterpret_vm_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(-0.0))); + x = vf2setx_vf2_vf2_vf_rvvm1_sleef(x, vreinterpret_vf_vm_rvvm1_sleef(vxor_vm_vm_vm_rvvm1_sleef(vreinterpret_vm_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(x)), r))); + x = vf2sety_vf2_vf2_vf_rvvm1_sleef(x, vreinterpret_vf_vm_rvvm1_sleef(vxor_vm_vm_vm_rvvm1_sleef(vreinterpret_vm_vf_rvvm1_sleef(vf2gety_vf_vf2_rvvm1_sleef(x)), r))); + + q = vsel_vi2_vf_vf_vi2_vi2_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(x), vf2getx_vf_vf2_rvvm1_sleef(y), vadd_vi2_vi2_vi2_rvvm1_sleef(q, vcast_vi2_i_rvvm1_sleef(1)), q); + p = vlt_vo_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(x), vf2getx_vf_vf2_rvvm1_sleef(y)); + s = vsel_vf2_vo_vf2_vf2_rvvm1_sleef(p, dfneg_vf2_vf2_rvvm1_sleef(x), y); + t = vsel_vf2_vo_vf2_vf2_rvvm1_sleef(p, y, x); + + s = dfdiv_vf2_vf2_vf2_rvvm1_sleef(s, t); + t = dfsqu_vf2_vf2_rvvm1_sleef(s); + t = dfnormalize_vf2_vf2_rvvm1_sleef(t); + + u = vcast_vf_f_rvvm1_sleef(-0.00176397908944636583328247f); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vf2getx_vf_vf2_rvvm1_sleef(t), vcast_vf_f_rvvm1_sleef(0.0107900900766253471374512f)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vf2getx_vf_vf2_rvvm1_sleef(t), vcast_vf_f_rvvm1_sleef(-0.0309564601629972457885742f)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vf2getx_vf_vf2_rvvm1_sleef(t), vcast_vf_f_rvvm1_sleef(0.0577365085482597351074219f)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vf2getx_vf_vf2_rvvm1_sleef(t), vcast_vf_f_rvvm1_sleef(-0.0838950723409652709960938f)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vf2getx_vf_vf2_rvvm1_sleef(t), vcast_vf_f_rvvm1_sleef(0.109463557600975036621094f)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vf2getx_vf_vf2_rvvm1_sleef(t), vcast_vf_f_rvvm1_sleef(-0.142626821994781494140625f)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vf2getx_vf_vf2_rvvm1_sleef(t), vcast_vf_f_rvvm1_sleef(0.199983194470405578613281f)); + + t = dfmul_vf2_vf2_vf2_rvvm1_sleef(t, dfadd_vf2_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(-0.333332866430282592773438f), vmul_vf_vf_vf_rvvm1_sleef(u, vf2getx_vf_vf2_rvvm1_sleef(t)))); + t = dfmul_vf2_vf2_vf2_rvvm1_sleef(s, dfadd_vf2_vf_vf2_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(1), t)); + t = dfadd_vf2_vf2_vf2_rvvm1_sleef(dfmul_vf2_vf2_vf_rvvm1_sleef(vcast_vf2_f_f_rvvm1_sleef(1.5707963705062866211f, -4.3711388286737928865e-08f), vcast_vf_vi2_rvvm1_sleef(q)), t); + + return t; +} + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_atan2fx_u10rvvm1(vfloat_rvvm1_sleef y, vfloat_rvvm1_sleef x) { + rvv_sp_vopmask_rvvm1_sleef o = vlt_vo_vf_vf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(x), vcast_vf_f_rvvm1_sleef(2.9387372783541830947e-39f)); + x = vsel_vf_vo_vf_vf_rvvm1_sleef(o, vmul_vf_vf_vf_rvvm1_sleef(x, vcast_vf_f_rvvm1_sleef(1 << 24)), x); + y = vsel_vf_vo_vf_vf_rvvm1_sleef(o, vmul_vf_vf_vf_rvvm1_sleef(y, vcast_vf_f_rvvm1_sleef(1 << 24)), y); + + vfloat2_rvvm1_sleef d = atan2kf_u1_rvvm1_sleef(vcast_vf2_vf_vf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(y), vcast_vf_f_rvvm1_sleef(0)), vcast_vf2_vf_vf_rvvm1_sleef(x, vcast_vf_f_rvvm1_sleef(0))); + vfloat_rvvm1_sleef r = vadd_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(d), vf2gety_vf_vf2_rvvm1_sleef(d)); + + r = vmulsign_vf_vf_vf_rvvm1_sleef(r, x); + r = vsel_vf_vo_vf_vf_rvvm1_sleef(rvv_sp_vor_vo_vo_vo(visinf_vo_vf_rvvm1_sleef(x), veq_vo_vf_vf_rvvm1_sleef(x, vcast_vf_f_rvvm1_sleef(0))), vsub_vf_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(3.141592653589793238462643383279502884/2), visinf2_vf_vf_vf_rvvm1_sleef(x, vmulsign_vf_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(3.141592653589793238462643383279502884/2), x))), r); + r = vsel_vf_vo_vf_vf_rvvm1_sleef(visinf_vo_vf_rvvm1_sleef(y), vsub_vf_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(3.141592653589793238462643383279502884/2), visinf2_vf_vf_vf_rvvm1_sleef(x, vmulsign_vf_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(3.141592653589793238462643383279502884/4), x))), r); + r = vsel_vf_vo_vf_vf_rvvm1_sleef(veq_vo_vf_vf_rvvm1_sleef(y, vcast_vf_f_rvvm1_sleef(0.0f)), vreinterpret_vf_vm_rvvm1_sleef(vand_vm_vo32_vm_rvvm1_sleef(vsignbit_vo_vf_rvvm1_sleef(x), vreinterpret_vm_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef((float)3.141592653589793238462643383279502884)))), r); + + r = vreinterpret_vf_vm_rvvm1_sleef(vor_vm_vo32_vm_rvvm1_sleef(rvv_sp_vor_vo_vo_vo(visnan_vo_vf_rvvm1_sleef(x), visnan_vo_vf_rvvm1_sleef(y)), vreinterpret_vm_vf_rvvm1_sleef(vmulsign_vf_vf_vf_rvvm1_sleef(r, y)))); + return r; +} + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_asinfx_u10rvvm1(vfloat_rvvm1_sleef d) { + rvv_sp_vopmask_rvvm1_sleef o = vlt_vo_vf_vf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(d), vcast_vf_f_rvvm1_sleef(0.5f)); + vfloat_rvvm1_sleef x2 = vsel_vf_vo_vf_vf_rvvm1_sleef(o, vmul_vf_vf_vf_rvvm1_sleef(d, d), vmul_vf_vf_vf_rvvm1_sleef(vsub_vf_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(1), vabs_vf_vf_rvvm1_sleef(d)), vcast_vf_f_rvvm1_sleef(0.5f))), u; + vfloat2_rvvm1_sleef x = vsel_vf2_vo_vf2_vf2_rvvm1_sleef(o, vcast_vf2_vf_vf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(d), vcast_vf_f_rvvm1_sleef(0)), dfsqrt_vf2_vf_rvvm1_sleef(x2)); + x = vsel_vf2_vo_vf2_vf2_rvvm1_sleef(veq_vo_vf_vf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(d), vcast_vf_f_rvvm1_sleef(1.0f)), vcast_vf2_f_f_rvvm1_sleef(0, 0), x); + + u = vcast_vf_f_rvvm1_sleef(+0.4197454825e-1); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, x2, vcast_vf_f_rvvm1_sleef(+0.2424046025e-1)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, x2, vcast_vf_f_rvvm1_sleef(+0.4547423869e-1)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, x2, vcast_vf_f_rvvm1_sleef(+0.7495029271e-1)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, x2, vcast_vf_f_rvvm1_sleef(+0.1666677296e+0)); + u = vmul_vf_vf_vf_rvvm1_sleef(u, vmul_vf_vf_vf_rvvm1_sleef(x2, vf2getx_vf_vf2_rvvm1_sleef(x))); + + vfloat2_rvvm1_sleef y = dfsub_vf2_vf2_vf_rvvm1_sleef(dfsub_vf2_vf2_vf2_rvvm1_sleef(vcast_vf2_f_f_rvvm1_sleef(3.1415927410125732422f/4,-8.7422776573475857731e-08f/4), x), u); + + vfloat_rvvm1_sleef r = vsel_vf_vo_vf_vf_rvvm1_sleef(o, vadd_vf_vf_vf_rvvm1_sleef(u, vf2getx_vf_vf2_rvvm1_sleef(x)), + vmul_vf_vf_vf_rvvm1_sleef(vadd_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(y), vf2gety_vf_vf2_rvvm1_sleef(y)), vcast_vf_f_rvvm1_sleef(2))); + return vmulsign_vf_vf_vf_rvvm1_sleef(r, d); +} + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_acosfx_u10rvvm1(vfloat_rvvm1_sleef d) { + rvv_sp_vopmask_rvvm1_sleef o = vlt_vo_vf_vf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(d), vcast_vf_f_rvvm1_sleef(0.5f)); + vfloat_rvvm1_sleef x2 = vsel_vf_vo_vf_vf_rvvm1_sleef(o, vmul_vf_vf_vf_rvvm1_sleef(d, d), vmul_vf_vf_vf_rvvm1_sleef(vsub_vf_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(1), vabs_vf_vf_rvvm1_sleef(d)), vcast_vf_f_rvvm1_sleef(0.5f))), u; + vfloat2_rvvm1_sleef x = vsel_vf2_vo_vf2_vf2_rvvm1_sleef(o, vcast_vf2_vf_vf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(d), vcast_vf_f_rvvm1_sleef(0)), dfsqrt_vf2_vf_rvvm1_sleef(x2)); + x = vsel_vf2_vo_vf2_vf2_rvvm1_sleef(veq_vo_vf_vf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(d), vcast_vf_f_rvvm1_sleef(1.0f)), vcast_vf2_f_f_rvvm1_sleef(0, 0), x); + + u = vcast_vf_f_rvvm1_sleef(+0.4197454825e-1); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, x2, vcast_vf_f_rvvm1_sleef(+0.2424046025e-1)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, x2, vcast_vf_f_rvvm1_sleef(+0.4547423869e-1)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, x2, vcast_vf_f_rvvm1_sleef(+0.7495029271e-1)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, x2, vcast_vf_f_rvvm1_sleef(+0.1666677296e+0)); + u = vmul_vf_vf_vf_rvvm1_sleef(u, vmul_vf_vf_vf_rvvm1_sleef(x2, vf2getx_vf_vf2_rvvm1_sleef(x))); + + vfloat2_rvvm1_sleef y = dfsub_vf2_vf2_vf2_rvvm1_sleef(vcast_vf2_f_f_rvvm1_sleef(3.1415927410125732422f/2, -8.7422776573475857731e-08f/2), + dfadd_vf2_vf_vf_rvvm1_sleef(vmulsign_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(x), d), vmulsign_vf_vf_vf_rvvm1_sleef(u, d))); + x = dfadd_vf2_vf2_vf_rvvm1_sleef(x, u); + + y = vsel_vf2_vo_vf2_vf2_rvvm1_sleef(o, y, dfscale_vf2_vf2_vf_rvvm1_sleef(x, vcast_vf_f_rvvm1_sleef(2))); + + y = vsel_vf2_vo_vf2_vf2_rvvm1_sleef(rvv_sp_vandnot_vo_vo_vo(o, vlt_vo_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(0))), + dfsub_vf2_vf2_vf2_rvvm1_sleef(vcast_vf2_f_f_rvvm1_sleef(3.1415927410125732422f, -8.7422776573475857731e-08f), y), y); + + return vadd_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(y), vf2gety_vf_vf2_rvvm1_sleef(y)); +} + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_atanfx_u10rvvm1(vfloat_rvvm1_sleef d) { + vfloat2_rvvm1_sleef d2 = atan2kf_u1_rvvm1_sleef(vcast_vf2_vf_vf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(d), vcast_vf_f_rvvm1_sleef(0)), vcast_vf2_f_f_rvvm1_sleef(1, 0)); + vfloat_rvvm1_sleef r = vadd_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(d2), vf2gety_vf_vf2_rvvm1_sleef(d2)); + r = vsel_vf_vo_vf_vf_rvvm1_sleef(visinf_vo_vf_rvvm1_sleef(d), vcast_vf_f_rvvm1_sleef(1.570796326794896557998982), r); + return vmulsign_vf_vf_vf_rvvm1_sleef(r, d); +} + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_logfx_u35rvvm1(vfloat_rvvm1_sleef d) { + vfloat_rvvm1_sleef x, x2, t, m; + + rvv_sp_vopmask_rvvm1_sleef o = vlt_vo_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(0x1p-126)); + d = vsel_vf_vo_vf_vf_rvvm1_sleef(o, vmul_vf_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef((float)(INT64_C(1) << 32) * (float)(INT64_C(1) << 32))), d); + vint2_rvvm1_sleef e = vilogb2k_vi2_vf_rvvm1_sleef(vmul_vf_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(1.0f/0.75f))); + m = vldexp3_vf_vf_vi2_rvvm1_sleef(d, vneg_vi2_vi2_rvvm1_sleef(e)); + e = vsel_vi2_vo_vi2_vi2_rvvm1_sleef(o, vsub_vi2_vi2_vi2_rvvm1_sleef(e, vcast_vi2_i_rvvm1_sleef(64)), e); + + x = vdiv_vf_vf_vf_rvvm1_sleef(vsub_vf_vf_vf_rvvm1_sleef(m, vcast_vf_f_rvvm1_sleef(1.0f)), vadd_vf_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(1.0f), m)); + x2 = vmul_vf_vf_vf_rvvm1_sleef(x, x); + + t = vcast_vf_f_rvvm1_sleef(0.2392828464508056640625f); + t = vmla_vf_vf_vf_vf_rvvm1_sleef(t, x2, vcast_vf_f_rvvm1_sleef(0.28518211841583251953125f)); + t = vmla_vf_vf_vf_vf_rvvm1_sleef(t, x2, vcast_vf_f_rvvm1_sleef(0.400005877017974853515625f)); + t = vmla_vf_vf_vf_vf_rvvm1_sleef(t, x2, vcast_vf_f_rvvm1_sleef(0.666666686534881591796875f)); + t = vmla_vf_vf_vf_vf_rvvm1_sleef(t, x2, vcast_vf_f_rvvm1_sleef(2.0f)); + + x = vmla_vf_vf_vf_vf_rvvm1_sleef(x, t, vmul_vf_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(0.693147180559945286226764f), vcast_vf_vi2_rvvm1_sleef(e))); + x = vsel_vf_vo_vf_vf_rvvm1_sleef(vispinf_vo_vf_rvvm1_sleef(d), vcast_vf_f_rvvm1_sleef(__builtin_inff()), x); + x = vsel_vf_vo_vf_vf_rvvm1_sleef(rvv_sp_vor_vo_vo_vo(vlt_vo_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(0)), visnan_vo_vf_rvvm1_sleef(d)), vcast_vf_f_rvvm1_sleef(__builtin_nanf("")), x); + x = vsel_vf_vo_vf_vf_rvvm1_sleef(veq_vo_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(0)), vcast_vf_f_rvvm1_sleef(-__builtin_inff()), x); + + return x; +} + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_expfx_u10rvvm1(vfloat_rvvm1_sleef d) { + vint2_rvvm1_sleef q = vrint_vi2_vf_rvvm1_sleef(vmul_vf_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(1.442695040888963407359924681001892137426645954152985934135449406931f))); + vfloat_rvvm1_sleef s, u; + + s = vmla_vf_vf_vf_vf_rvvm1_sleef(vcast_vf_vi2_rvvm1_sleef(q), vcast_vf_f_rvvm1_sleef(-0.693145751953125f), d); + s = vmla_vf_vf_vf_vf_rvvm1_sleef(vcast_vf_vi2_rvvm1_sleef(q), vcast_vf_f_rvvm1_sleef(-1.428606765330187045e-06f), s); + + u = vcast_vf_f_rvvm1_sleef(0.000198527617612853646278381); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, s, vcast_vf_f_rvvm1_sleef(0.00139304355252534151077271)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, s, vcast_vf_f_rvvm1_sleef(0.00833336077630519866943359)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, s, vcast_vf_f_rvvm1_sleef(0.0416664853692054748535156)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, s, vcast_vf_f_rvvm1_sleef(0.166666671633720397949219)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, s, vcast_vf_f_rvvm1_sleef(0.5)); + + u = vadd_vf_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(1.0f), vmla_vf_vf_vf_vf_rvvm1_sleef(vmul_vf_vf_vf_rvvm1_sleef(s, s), u, s)); + + u = vldexp2_vf_vf_vi2_rvvm1_sleef(u, q); + + u = vreinterpret_vf_vm_rvvm1_sleef(vandnot_vm_vo32_vm_rvvm1_sleef(vlt_vo_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(-104)), vreinterpret_vm_vf_rvvm1_sleef(u))); + u = vsel_vf_vo_vf_vf_rvvm1_sleef(vlt_vo_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(100), d), vcast_vf_f_rvvm1_sleef(__builtin_inff()), u); + + return u; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_rvvm1_sleef expm1fk_rvvm1_sleef(vfloat_rvvm1_sleef d) { + vint2_rvvm1_sleef q = vrint_vi2_vf_rvvm1_sleef(vmul_vf_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(1.442695040888963407359924681001892137426645954152985934135449406931f))); + vfloat_rvvm1_sleef s, u; + + s = vmla_vf_vf_vf_vf_rvvm1_sleef(vcast_vf_vi2_rvvm1_sleef(q), vcast_vf_f_rvvm1_sleef(-0.693145751953125f), d); + s = vmla_vf_vf_vf_vf_rvvm1_sleef(vcast_vf_vi2_rvvm1_sleef(q), vcast_vf_f_rvvm1_sleef(-1.428606765330187045e-06f), s); + + vfloat_rvvm1_sleef s2 = vmul_vf_vf_vf_rvvm1_sleef(s, s), s4 = vmul_vf_vf_vf_rvvm1_sleef(s2, s2); + u = vmla_vf_vf_vf_vf_rvvm1_sleef((s4), (vmla_vf_vf_vf_vf_rvvm1_sleef((s), (vcast_vf_f_rvvm1_sleef(0.000198527617612853646278381)), (vcast_vf_f_rvvm1_sleef(0.00139304355252534151077271)))), (vmla_vf_vf_vf_vf_rvvm1_sleef((s2), (vmla_vf_vf_vf_vf_rvvm1_sleef((s), (vcast_vf_f_rvvm1_sleef(0.00833336077630519866943359)), (vcast_vf_f_rvvm1_sleef(0.0416664853692054748535156)))), (vmla_vf_vf_vf_vf_rvvm1_sleef((s), (vcast_vf_f_rvvm1_sleef(0.166666671633720397949219)), (vcast_vf_f_rvvm1_sleef(0.5))))))) + + ; + + u = vmla_vf_vf_vf_vf_rvvm1_sleef(vmul_vf_vf_vf_rvvm1_sleef(s, s), u, s); + + u = vsel_vf_vo_vf_vf_rvvm1_sleef(veq_vo_vi2_vi2_rvvm1_sleef(q, vcast_vi2_i_rvvm1_sleef(0)), u, + vsub_vf_vf_vf_rvvm1_sleef(vldexp2_vf_vf_vi2_rvvm1_sleef(vadd_vf_vf_vf_rvvm1_sleef(u, vcast_vf_f_rvvm1_sleef(1)), q), vcast_vf_f_rvvm1_sleef(1))); + + return u; +} + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_sqrtfx_u35rvvm1(vfloat_rvvm1_sleef d) { return vsqrt_vf_vf_rvvm1_sleef(d); } + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_cbrtfx_u35rvvm1(vfloat_rvvm1_sleef d) { + vfloat_rvvm1_sleef x, y, q = vcast_vf_f_rvvm1_sleef(1.0), t; + vint2_rvvm1_sleef e, qu, re; + + e = vadd_vi2_vi2_vi2_rvvm1_sleef(vilogbk_vi2_vf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(d)), vcast_vi2_i_rvvm1_sleef(1)); + d = vldexp2_vf_vf_vi2_rvvm1_sleef(d, vneg_vi2_vi2_rvvm1_sleef(e)); + + t = vadd_vf_vf_vf_rvvm1_sleef(vcast_vf_vi2_rvvm1_sleef(e), vcast_vf_f_rvvm1_sleef(6144)); + qu = vtruncate_vi2_vf_rvvm1_sleef(vmul_vf_vf_vf_rvvm1_sleef(t, vcast_vf_f_rvvm1_sleef(1.0f/3.0f))); + re = vtruncate_vi2_vf_rvvm1_sleef(vsub_vf_vf_vf_rvvm1_sleef(t, vmul_vf_vf_vf_rvvm1_sleef(vcast_vf_vi2_rvvm1_sleef(qu), vcast_vf_f_rvvm1_sleef(3)))); + + q = vsel_vf_vo_vf_vf_rvvm1_sleef(veq_vo_vi2_vi2_rvvm1_sleef(re, vcast_vi2_i_rvvm1_sleef(1)), vcast_vf_f_rvvm1_sleef(1.2599210498948731647672106f), q); + q = vsel_vf_vo_vf_vf_rvvm1_sleef(veq_vo_vi2_vi2_rvvm1_sleef(re, vcast_vi2_i_rvvm1_sleef(2)), vcast_vf_f_rvvm1_sleef(1.5874010519681994747517056f), q); + q = vldexp2_vf_vf_vi2_rvvm1_sleef(q, vsub_vi2_vi2_vi2_rvvm1_sleef(qu, vcast_vi2_i_rvvm1_sleef(2048))); + + q = vmulsign_vf_vf_vf_rvvm1_sleef(q, d); + d = vabs_vf_vf_rvvm1_sleef(d); + + x = vcast_vf_f_rvvm1_sleef(-0.601564466953277587890625f); + x = vmla_vf_vf_vf_vf_rvvm1_sleef(x, d, vcast_vf_f_rvvm1_sleef(2.8208892345428466796875f)); + x = vmla_vf_vf_vf_vf_rvvm1_sleef(x, d, vcast_vf_f_rvvm1_sleef(-5.532182216644287109375f)); + x = vmla_vf_vf_vf_vf_rvvm1_sleef(x, d, vcast_vf_f_rvvm1_sleef(5.898262500762939453125f)); + x = vmla_vf_vf_vf_vf_rvvm1_sleef(x, d, vcast_vf_f_rvvm1_sleef(-3.8095417022705078125f)); + x = vmla_vf_vf_vf_vf_rvvm1_sleef(x, d, vcast_vf_f_rvvm1_sleef(2.2241256237030029296875f)); + + y = vmul_vf_vf_vf_rvvm1_sleef(vmul_vf_vf_vf_rvvm1_sleef(d, x), x); + y = vmul_vf_vf_vf_rvvm1_sleef(vsub_vf_vf_vf_rvvm1_sleef(y, vmul_vf_vf_vf_rvvm1_sleef(vmul_vf_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(2.0f / 3.0f), y), vmla_vf_vf_vf_vf_rvvm1_sleef(y, x, vcast_vf_f_rvvm1_sleef(-1.0f)))), q); + + return y; +} + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_cbrtfx_u10rvvm1(vfloat_rvvm1_sleef d) { + vfloat_rvvm1_sleef x, y, z, t; + vfloat2_rvvm1_sleef q2 = vcast_vf2_f_f_rvvm1_sleef(1, 0), u, v; + vint2_rvvm1_sleef e, qu, re; + + e = vadd_vi2_vi2_vi2_rvvm1_sleef(vilogbk_vi2_vf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(d)), vcast_vi2_i_rvvm1_sleef(1)); + d = vldexp2_vf_vf_vi2_rvvm1_sleef(d, vneg_vi2_vi2_rvvm1_sleef(e)); + + t = vadd_vf_vf_vf_rvvm1_sleef(vcast_vf_vi2_rvvm1_sleef(e), vcast_vf_f_rvvm1_sleef(6144)); + qu = vtruncate_vi2_vf_rvvm1_sleef(vmul_vf_vf_vf_rvvm1_sleef(t, vcast_vf_f_rvvm1_sleef(1.0/3.0))); + re = vtruncate_vi2_vf_rvvm1_sleef(vsub_vf_vf_vf_rvvm1_sleef(t, vmul_vf_vf_vf_rvvm1_sleef(vcast_vf_vi2_rvvm1_sleef(qu), vcast_vf_f_rvvm1_sleef(3)))); + + q2 = vsel_vf2_vo_vf2_vf2_rvvm1_sleef(veq_vo_vi2_vi2_rvvm1_sleef(re, vcast_vi2_i_rvvm1_sleef(1)), vcast_vf2_f_f_rvvm1_sleef(1.2599210739135742188f, -2.4018701694217270415e-08), q2); + q2 = vsel_vf2_vo_vf2_vf2_rvvm1_sleef(veq_vo_vi2_vi2_rvvm1_sleef(re, vcast_vi2_i_rvvm1_sleef(2)), vcast_vf2_f_f_rvvm1_sleef(1.5874010324478149414f, 1.9520385308169352356e-08), q2); + + q2 = vf2setx_vf2_vf2_vf_rvvm1_sleef(q2, vmulsign_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(q2), d)); + q2 = vf2sety_vf2_vf2_vf_rvvm1_sleef(q2, vmulsign_vf_vf_vf_rvvm1_sleef(vf2gety_vf_vf2_rvvm1_sleef(q2), d)); + d = vabs_vf_vf_rvvm1_sleef(d); + + x = vcast_vf_f_rvvm1_sleef(-0.601564466953277587890625f); + x = vmla_vf_vf_vf_vf_rvvm1_sleef(x, d, vcast_vf_f_rvvm1_sleef(2.8208892345428466796875f)); + x = vmla_vf_vf_vf_vf_rvvm1_sleef(x, d, vcast_vf_f_rvvm1_sleef(-5.532182216644287109375f)); + x = vmla_vf_vf_vf_vf_rvvm1_sleef(x, d, vcast_vf_f_rvvm1_sleef(5.898262500762939453125f)); + x = vmla_vf_vf_vf_vf_rvvm1_sleef(x, d, vcast_vf_f_rvvm1_sleef(-3.8095417022705078125f)); + x = vmla_vf_vf_vf_vf_rvvm1_sleef(x, d, vcast_vf_f_rvvm1_sleef(2.2241256237030029296875f)); + + y = vmul_vf_vf_vf_rvvm1_sleef(x, x); y = vmul_vf_vf_vf_rvvm1_sleef(y, y); x = vsub_vf_vf_vf_rvvm1_sleef(x, vmul_vf_vf_vf_rvvm1_sleef(vmlanp_vf_vf_vf_vf_rvvm1_sleef(d, y, x), vcast_vf_f_rvvm1_sleef(-1.0 / 3.0))); + + z = x; + + u = dfmul_vf2_vf_vf_rvvm1_sleef(x, x); + u = dfmul_vf2_vf2_vf2_rvvm1_sleef(u, u); + u = dfmul_vf2_vf2_vf_rvvm1_sleef(u, d); + u = dfadd2_vf2_vf2_vf_rvvm1_sleef(u, vneg_vf_vf_rvvm1_sleef(x)); + y = vadd_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(u), vf2gety_vf_vf2_rvvm1_sleef(u)); + + y = vmul_vf_vf_vf_rvvm1_sleef(vmul_vf_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(-2.0 / 3.0), y), z); + v = dfadd2_vf2_vf2_vf_rvvm1_sleef(dfmul_vf2_vf_vf_rvvm1_sleef(z, z), y); + v = dfmul_vf2_vf2_vf_rvvm1_sleef(v, d); + v = dfmul_vf2_vf2_vf2_rvvm1_sleef(v, q2); + z = vldexp2_vf_vf_vi2_rvvm1_sleef(vadd_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(v), vf2gety_vf_vf2_rvvm1_sleef(v)), vsub_vi2_vi2_vi2_rvvm1_sleef(qu, vcast_vi2_i_rvvm1_sleef(2048))); + + z = vsel_vf_vo_vf_vf_rvvm1_sleef(visinf_vo_vf_rvvm1_sleef(d), vmulsign_vf_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(__builtin_inff()), vf2getx_vf_vf2_rvvm1_sleef(q2)), z); + z = vsel_vf_vo_vf_vf_rvvm1_sleef(veq_vo_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(0)), vreinterpret_vf_vm_rvvm1_sleef(vsignbit_vm_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(q2))), z); + + return z; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_rvvm1_sleef logkf_rvvm1_sleef(vfloat_rvvm1_sleef d) { + vfloat2_rvvm1_sleef x, x2; + vfloat_rvvm1_sleef t, m; + + rvv_sp_vopmask_rvvm1_sleef o = vlt_vo_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(0x1p-126)); + d = vsel_vf_vo_vf_vf_rvvm1_sleef(o, vmul_vf_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef((float)(INT64_C(1) << 32) * (float)(INT64_C(1) << 32))), d); + vint2_rvvm1_sleef e = vilogb2k_vi2_vf_rvvm1_sleef(vmul_vf_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(1.0f/0.75f))); + m = vldexp3_vf_vf_vi2_rvvm1_sleef(d, vneg_vi2_vi2_rvvm1_sleef(e)); + e = vsel_vi2_vo_vi2_vi2_rvvm1_sleef(o, vsub_vi2_vi2_vi2_rvvm1_sleef(e, vcast_vi2_i_rvvm1_sleef(64)), e); + + x = dfdiv_vf2_vf2_vf2_rvvm1_sleef(dfadd2_vf2_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(-1), m), dfadd2_vf2_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(1), m)); + x2 = dfsqu_vf2_vf2_rvvm1_sleef(x); + + t = vcast_vf_f_rvvm1_sleef(0.240320354700088500976562); + t = vmla_vf_vf_vf_vf_rvvm1_sleef(t, vf2getx_vf_vf2_rvvm1_sleef(x2), vcast_vf_f_rvvm1_sleef(0.285112679004669189453125)); + t = vmla_vf_vf_vf_vf_rvvm1_sleef(t, vf2getx_vf_vf2_rvvm1_sleef(x2), vcast_vf_f_rvvm1_sleef(0.400007992982864379882812)); + vfloat2_rvvm1_sleef c = vcast_vf2_f_f_rvvm1_sleef(0.66666662693023681640625f, 3.69183861259614332084311e-09f); + + vfloat2_rvvm1_sleef s = dfmul_vf2_vf2_vf_rvvm1_sleef(vcast_vf2_f_f_rvvm1_sleef(0.69314718246459960938f, -1.904654323148236017e-09f), vcast_vf_vi2_rvvm1_sleef(e)); + + s = dfadd_vf2_vf2_vf2_rvvm1_sleef(s, dfscale_vf2_vf2_vf_rvvm1_sleef(x, vcast_vf_f_rvvm1_sleef(2))); + s = dfadd_vf2_vf2_vf2_rvvm1_sleef(s, dfmul_vf2_vf2_vf2_rvvm1_sleef(dfmul_vf2_vf2_vf2_rvvm1_sleef(x2, x), + dfadd2_vf2_vf2_vf2_rvvm1_sleef(dfmul_vf2_vf2_vf_rvvm1_sleef(x2, t), c))); + return s; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_rvvm1_sleef logk3f_rvvm1_sleef(vfloat_rvvm1_sleef d) { + vfloat_rvvm1_sleef x, x2, t, m; + + rvv_sp_vopmask_rvvm1_sleef o = vlt_vo_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(0x1p-126)); + d = vsel_vf_vo_vf_vf_rvvm1_sleef(o, vmul_vf_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef((float)(INT64_C(1) << 32) * (float)(INT64_C(1) << 32))), d); + vint2_rvvm1_sleef e = vilogb2k_vi2_vf_rvvm1_sleef(vmul_vf_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(1.0f/0.75f))); + m = vldexp3_vf_vf_vi2_rvvm1_sleef(d, vneg_vi2_vi2_rvvm1_sleef(e)); + e = vsel_vi2_vo_vi2_vi2_rvvm1_sleef(o, vsub_vi2_vi2_vi2_rvvm1_sleef(e, vcast_vi2_i_rvvm1_sleef(64)), e); + + x = vdiv_vf_vf_vf_rvvm1_sleef(vsub_vf_vf_vf_rvvm1_sleef(m, vcast_vf_f_rvvm1_sleef(1.0f)), vadd_vf_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(1.0f), m)); + x2 = vmul_vf_vf_vf_rvvm1_sleef(x, x); + + t = vcast_vf_f_rvvm1_sleef(0.2392828464508056640625f); + t = vmla_vf_vf_vf_vf_rvvm1_sleef(t, x2, vcast_vf_f_rvvm1_sleef(0.28518211841583251953125f)); + t = vmla_vf_vf_vf_vf_rvvm1_sleef(t, x2, vcast_vf_f_rvvm1_sleef(0.400005877017974853515625f)); + t = vmla_vf_vf_vf_vf_rvvm1_sleef(t, x2, vcast_vf_f_rvvm1_sleef(0.666666686534881591796875f)); + t = vmla_vf_vf_vf_vf_rvvm1_sleef(t, x2, vcast_vf_f_rvvm1_sleef(2.0f)); + + x = vmla_vf_vf_vf_vf_rvvm1_sleef(x, t, vmul_vf_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(0.693147180559945286226764f), vcast_vf_vi2_rvvm1_sleef(e))); + + return x; +} + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_logfx_u10rvvm1(vfloat_rvvm1_sleef d) { + vfloat2_rvvm1_sleef x; + vfloat_rvvm1_sleef t, m, x2; + + rvv_sp_vopmask_rvvm1_sleef o = vlt_vo_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(0x1p-126)); + d = vsel_vf_vo_vf_vf_rvvm1_sleef(o, vmul_vf_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef((float)(INT64_C(1) << 32) * (float)(INT64_C(1) << 32))), d); + vint2_rvvm1_sleef e = vilogb2k_vi2_vf_rvvm1_sleef(vmul_vf_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(1.0f/0.75f))); + m = vldexp3_vf_vf_vi2_rvvm1_sleef(d, vneg_vi2_vi2_rvvm1_sleef(e)); + e = vsel_vi2_vo_vi2_vi2_rvvm1_sleef(o, vsub_vi2_vi2_vi2_rvvm1_sleef(e, vcast_vi2_i_rvvm1_sleef(64)), e); + vfloat2_rvvm1_sleef s = dfmul_vf2_vf2_vf_rvvm1_sleef(vcast_vf2_f_f_rvvm1_sleef(0.69314718246459960938f, -1.904654323148236017e-09f), vcast_vf_vi2_rvvm1_sleef(e)); + + x = dfdiv_vf2_vf2_vf2_rvvm1_sleef(dfadd2_vf2_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(-1), m), dfadd2_vf2_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(1), m)); + x2 = vmul_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(x), vf2getx_vf_vf2_rvvm1_sleef(x)); + + t = vcast_vf_f_rvvm1_sleef(+0.3027294874e+0f); + t = vmla_vf_vf_vf_vf_rvvm1_sleef(t, x2, vcast_vf_f_rvvm1_sleef(+0.3996108174e+0f)); + t = vmla_vf_vf_vf_vf_rvvm1_sleef(t, x2, vcast_vf_f_rvvm1_sleef(+0.6666694880e+0f)); + + s = dfadd_vf2_vf2_vf2_rvvm1_sleef(s, dfscale_vf2_vf2_vf_rvvm1_sleef(x, vcast_vf_f_rvvm1_sleef(2))); + s = dfadd_vf2_vf2_vf_rvvm1_sleef(s, vmul_vf_vf_vf_rvvm1_sleef(vmul_vf_vf_vf_rvvm1_sleef(x2, vf2getx_vf_vf2_rvvm1_sleef(x)), t)); + + vfloat_rvvm1_sleef r = vadd_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(s), vf2gety_vf_vf2_rvvm1_sleef(s)); + + r = vsel_vf_vo_vf_vf_rvvm1_sleef(vispinf_vo_vf_rvvm1_sleef(d), vcast_vf_f_rvvm1_sleef(__builtin_inff()), r); + r = vsel_vf_vo_vf_vf_rvvm1_sleef(rvv_sp_vor_vo_vo_vo(vlt_vo_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(0)), visnan_vo_vf_rvvm1_sleef(d)), vcast_vf_f_rvvm1_sleef(__builtin_nanf("")), r); + r = vsel_vf_vo_vf_vf_rvvm1_sleef(veq_vo_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(0)), vcast_vf_f_rvvm1_sleef(-__builtin_inff()), r); + + return r; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_rvvm1_sleef expkf_rvvm1_sleef(vfloat2_rvvm1_sleef d) { + vfloat_rvvm1_sleef u = vmul_vf_vf_vf_rvvm1_sleef(vadd_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(d), vf2gety_vf_vf2_rvvm1_sleef(d)), vcast_vf_f_rvvm1_sleef(1.442695040888963407359924681001892137426645954152985934135449406931f)); + vint2_rvvm1_sleef q = vrint_vi2_vf_rvvm1_sleef(u); + vfloat2_rvvm1_sleef s, t; + + s = dfadd2_vf2_vf2_vf_rvvm1_sleef(d, vmul_vf_vf_vf_rvvm1_sleef(vcast_vf_vi2_rvvm1_sleef(q), vcast_vf_f_rvvm1_sleef(-0.693145751953125f))); + s = dfadd2_vf2_vf2_vf_rvvm1_sleef(s, vmul_vf_vf_vf_rvvm1_sleef(vcast_vf_vi2_rvvm1_sleef(q), vcast_vf_f_rvvm1_sleef(-1.428606765330187045e-06f))); + + s = dfnormalize_vf2_vf2_rvvm1_sleef(s); + + u = vcast_vf_f_rvvm1_sleef(0.00136324646882712841033936f); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vf2getx_vf_vf2_rvvm1_sleef(s), vcast_vf_f_rvvm1_sleef(0.00836596917361021041870117f)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vf2getx_vf_vf2_rvvm1_sleef(s), vcast_vf_f_rvvm1_sleef(0.0416710823774337768554688f)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vf2getx_vf_vf2_rvvm1_sleef(s), vcast_vf_f_rvvm1_sleef(0.166665524244308471679688f)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vf2getx_vf_vf2_rvvm1_sleef(s), vcast_vf_f_rvvm1_sleef(0.499999850988388061523438f)); + + t = dfadd_vf2_vf2_vf2_rvvm1_sleef(s, dfmul_vf2_vf2_vf_rvvm1_sleef(dfsqu_vf2_vf2_rvvm1_sleef(s), u)); + + t = dfadd_vf2_vf_vf2_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(1), t); + u = vadd_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(t), vf2gety_vf_vf2_rvvm1_sleef(t)); + u = vldexp_vf_vf_vi2_rvvm1_sleef(u, q); + + u = vreinterpret_vf_vm_rvvm1_sleef(vandnot_vm_vo32_vm_rvvm1_sleef(vlt_vo_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(d), vcast_vf_f_rvvm1_sleef(-104)), vreinterpret_vm_vf_rvvm1_sleef(u))); + + return u; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_rvvm1_sleef expk3f_rvvm1_sleef(vfloat_rvvm1_sleef d) { + vint2_rvvm1_sleef q = vrint_vi2_vf_rvvm1_sleef(vmul_vf_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(1.442695040888963407359924681001892137426645954152985934135449406931f))); + vfloat_rvvm1_sleef s, u; + + s = vmla_vf_vf_vf_vf_rvvm1_sleef(vcast_vf_vi2_rvvm1_sleef(q), vcast_vf_f_rvvm1_sleef(-0.693145751953125f), d); + s = vmla_vf_vf_vf_vf_rvvm1_sleef(vcast_vf_vi2_rvvm1_sleef(q), vcast_vf_f_rvvm1_sleef(-1.428606765330187045e-06f), s); + + u = vcast_vf_f_rvvm1_sleef(0.000198527617612853646278381); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, s, vcast_vf_f_rvvm1_sleef(0.00139304355252534151077271)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, s, vcast_vf_f_rvvm1_sleef(0.00833336077630519866943359)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, s, vcast_vf_f_rvvm1_sleef(0.0416664853692054748535156)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, s, vcast_vf_f_rvvm1_sleef(0.166666671633720397949219)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, s, vcast_vf_f_rvvm1_sleef(0.5)); + + u = vmla_vf_vf_vf_vf_rvvm1_sleef(vmul_vf_vf_vf_rvvm1_sleef(s, s), u, vadd_vf_vf_vf_rvvm1_sleef(s, vcast_vf_f_rvvm1_sleef(1.0f))); + u = vldexp2_vf_vf_vi2_rvvm1_sleef(u, q); + + u = vreinterpret_vf_vm_rvvm1_sleef(vandnot_vm_vo32_vm_rvvm1_sleef(vlt_vo_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(-104)), vreinterpret_vm_vf_rvvm1_sleef(u))); + + return u; +} + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_powfx_u10rvvm1(vfloat_rvvm1_sleef x, vfloat_rvvm1_sleef y) { + + rvv_sp_vopmask_rvvm1_sleef yisint = rvv_sp_vor_vo_vo_vo(veq_vo_vf_vf_rvvm1_sleef(vtruncate_vf_vf_rvvm1_sleef(y), y), vgt_vo_vf_vf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(y), vcast_vf_f_rvvm1_sleef(1 << 24))); + rvv_sp_vopmask_rvvm1_sleef yisodd = rvv_sp_vand_vo_vo_vo(rvv_sp_vand_vo_vo_vo(veq_vo_vi2_vi2_rvvm1_sleef(vand_vi2_vi2_vi2_rvvm1_sleef(vtruncate_vi2_vf_rvvm1_sleef(y), vcast_vi2_i_rvvm1_sleef(1)), vcast_vi2_i_rvvm1_sleef(1)), yisint), + vlt_vo_vf_vf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(y), vcast_vf_f_rvvm1_sleef(1 << 24))); + + vfloat_rvvm1_sleef result = expkf_rvvm1_sleef(dfmul_vf2_vf2_vf_rvvm1_sleef(logkf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(x)), y)); + + result = vsel_vf_vo_vf_vf_rvvm1_sleef(visnan_vo_vf_rvvm1_sleef(result), vcast_vf_f_rvvm1_sleef(__builtin_inff()), result); + + result = vmul_vf_vf_vf_rvvm1_sleef(result, + vsel_vf_vo_vf_vf_rvvm1_sleef(vgt_vo_vf_vf_rvvm1_sleef(x, vcast_vf_f_rvvm1_sleef(0)), + vcast_vf_f_rvvm1_sleef(1), + vsel_vf_vo_vf_vf_rvvm1_sleef(yisint, vsel_vf_vo_vf_vf_rvvm1_sleef(yisodd, vcast_vf_f_rvvm1_sleef(-1.0f), vcast_vf_f_rvvm1_sleef(1)), vcast_vf_f_rvvm1_sleef(__builtin_nanf(""))))); + + vfloat_rvvm1_sleef efx = vmulsign_vf_vf_vf_rvvm1_sleef(vsub_vf_vf_vf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(x), vcast_vf_f_rvvm1_sleef(1)), y); + + result = vsel_vf_vo_vf_vf_rvvm1_sleef(visinf_vo_vf_rvvm1_sleef(y), + vreinterpret_vf_vm_rvvm1_sleef(vandnot_vm_vo32_vm_rvvm1_sleef(vlt_vo_vf_vf_rvvm1_sleef(efx, vcast_vf_f_rvvm1_sleef(0.0f)), + vreinterpret_vm_vf_rvvm1_sleef(vsel_vf_vo_vf_vf_rvvm1_sleef(veq_vo_vf_vf_rvvm1_sleef(efx, vcast_vf_f_rvvm1_sleef(0.0f)), + vcast_vf_f_rvvm1_sleef(1.0f), + vcast_vf_f_rvvm1_sleef(__builtin_inff()))))), + result); + + result = vsel_vf_vo_vf_vf_rvvm1_sleef(rvv_sp_vor_vo_vo_vo(visinf_vo_vf_rvvm1_sleef(x), veq_vo_vf_vf_rvvm1_sleef(x, vcast_vf_f_rvvm1_sleef(0.0))), + vmulsign_vf_vf_vf_rvvm1_sleef(vsel_vf_vo_vf_vf_rvvm1_sleef(rvv_sp_vxor_vo_vo_vo(vsignbit_vo_vf_rvvm1_sleef(y), veq_vo_vf_vf_rvvm1_sleef(x, vcast_vf_f_rvvm1_sleef(0.0f))), + vcast_vf_f_rvvm1_sleef(0), vcast_vf_f_rvvm1_sleef(__builtin_inff())), + vsel_vf_vo_vf_vf_rvvm1_sleef(yisodd, x, vcast_vf_f_rvvm1_sleef(1))), result); + + result = vreinterpret_vf_vm_rvvm1_sleef(vor_vm_vo32_vm_rvvm1_sleef(rvv_sp_vor_vo_vo_vo(visnan_vo_vf_rvvm1_sleef(x), visnan_vo_vf_rvvm1_sleef(y)), vreinterpret_vm_vf_rvvm1_sleef(result))); + + result = vsel_vf_vo_vf_vf_rvvm1_sleef(rvv_sp_vor_vo_vo_vo(veq_vo_vf_vf_rvvm1_sleef(y, vcast_vf_f_rvvm1_sleef(0)), veq_vo_vf_vf_rvvm1_sleef(x, vcast_vf_f_rvvm1_sleef(1))), vcast_vf_f_rvvm1_sleef(1), result); + + return result; + +} + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_fastpowfx_u3500rvvm1(vfloat_rvvm1_sleef x, vfloat_rvvm1_sleef y) { + vfloat_rvvm1_sleef result = expk3f_rvvm1_sleef(vmul_vf_vf_vf_rvvm1_sleef(logk3f_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(x)), y)); + rvv_sp_vopmask_rvvm1_sleef yisint = rvv_sp_vor_vo_vo_vo(veq_vo_vf_vf_rvvm1_sleef(vtruncate_vf_vf_rvvm1_sleef(y), y), vgt_vo_vf_vf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(y), vcast_vf_f_rvvm1_sleef(1 << 24))); + rvv_sp_vopmask_rvvm1_sleef yisodd = rvv_sp_vand_vo_vo_vo(rvv_sp_vand_vo_vo_vo(veq_vo_vi2_vi2_rvvm1_sleef(vand_vi2_vi2_vi2_rvvm1_sleef(vtruncate_vi2_vf_rvvm1_sleef(y), vcast_vi2_i_rvvm1_sleef(1)), vcast_vi2_i_rvvm1_sleef(1)), yisint), + vlt_vo_vf_vf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(y), vcast_vf_f_rvvm1_sleef(1 << 24))); + + result = vsel_vf_vo_vf_vf_rvvm1_sleef(rvv_sp_vand_vo_vo_vo(vsignbit_vo_vf_rvvm1_sleef(x), yisodd), vneg_vf_vf_rvvm1_sleef(result), result); + + result = vsel_vf_vo_vf_vf_rvvm1_sleef(veq_vo_vf_vf_rvvm1_sleef(x, vcast_vf_f_rvvm1_sleef(0)), vcast_vf_f_rvvm1_sleef(0), result); + result = vsel_vf_vo_vf_vf_rvvm1_sleef(veq_vo_vf_vf_rvvm1_sleef(y, vcast_vf_f_rvvm1_sleef(0)), vcast_vf_f_rvvm1_sleef(1), result); + + return result; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_rvvm1_sleef expk2f_rvvm1_sleef(vfloat2_rvvm1_sleef d) { + vfloat_rvvm1_sleef u = vmul_vf_vf_vf_rvvm1_sleef(vadd_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(d), vf2gety_vf_vf2_rvvm1_sleef(d)), vcast_vf_f_rvvm1_sleef(1.442695040888963407359924681001892137426645954152985934135449406931f)); + vint2_rvvm1_sleef q = vrint_vi2_vf_rvvm1_sleef(u); + vfloat2_rvvm1_sleef s, t; + + s = dfadd2_vf2_vf2_vf_rvvm1_sleef(d, vmul_vf_vf_vf_rvvm1_sleef(vcast_vf_vi2_rvvm1_sleef(q), vcast_vf_f_rvvm1_sleef(-0.693145751953125f))); + s = dfadd2_vf2_vf2_vf_rvvm1_sleef(s, vmul_vf_vf_vf_rvvm1_sleef(vcast_vf_vi2_rvvm1_sleef(q), vcast_vf_f_rvvm1_sleef(-1.428606765330187045e-06f))); + + u = vcast_vf_f_rvvm1_sleef(+0.1980960224e-3f); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vf2getx_vf_vf2_rvvm1_sleef(s), vcast_vf_f_rvvm1_sleef(+0.1394256484e-2f)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vf2getx_vf_vf2_rvvm1_sleef(s), vcast_vf_f_rvvm1_sleef(+0.8333456703e-2f)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vf2getx_vf_vf2_rvvm1_sleef(s), vcast_vf_f_rvvm1_sleef(+0.4166637361e-1f)); + + t = dfadd2_vf2_vf2_vf_rvvm1_sleef(dfmul_vf2_vf2_vf_rvvm1_sleef(s, u), vcast_vf_f_rvvm1_sleef(+0.166666659414234244790680580464e+0f)); + t = dfadd2_vf2_vf2_vf_rvvm1_sleef(dfmul_vf2_vf2_vf2_rvvm1_sleef(s, t), vcast_vf_f_rvvm1_sleef(0.5)); + t = dfadd2_vf2_vf2_vf2_rvvm1_sleef(s, dfmul_vf2_vf2_vf2_rvvm1_sleef(dfsqu_vf2_vf2_rvvm1_sleef(s), t)); + + t = dfadd_vf2_vf_vf2_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(1), t); + + t = vf2setx_vf2_vf2_vf_rvvm1_sleef(t, vldexp2_vf_vf_vi2_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(t), q)); + t = vf2sety_vf2_vf2_vf_rvvm1_sleef(t, vldexp2_vf_vf_vi2_rvvm1_sleef(vf2gety_vf_vf2_rvvm1_sleef(t), q)); + + t = vf2setx_vf2_vf2_vf_rvvm1_sleef(t, vreinterpret_vf_vm_rvvm1_sleef(vandnot_vm_vo32_vm_rvvm1_sleef(vlt_vo_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(d), vcast_vf_f_rvvm1_sleef(-104)), vreinterpret_vm_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(t))))); + t = vf2sety_vf2_vf2_vf_rvvm1_sleef(t, vreinterpret_vf_vm_rvvm1_sleef(vandnot_vm_vo32_vm_rvvm1_sleef(vlt_vo_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(d), vcast_vf_f_rvvm1_sleef(-104)), vreinterpret_vm_vf_rvvm1_sleef(vf2gety_vf_vf2_rvvm1_sleef(t))))); + + return t; +} + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_sinhfx_u10rvvm1(vfloat_rvvm1_sleef x) { + vfloat_rvvm1_sleef y = vabs_vf_vf_rvvm1_sleef(x); + vfloat2_rvvm1_sleef d = expk2f_rvvm1_sleef(vcast_vf2_vf_vf_rvvm1_sleef(y, vcast_vf_f_rvvm1_sleef(0))); + d = dfsub_vf2_vf2_vf2_rvvm1_sleef(d, dfrec_vf2_vf2_rvvm1_sleef(d)); + y = vmul_vf_vf_vf_rvvm1_sleef(vadd_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(d), vf2gety_vf_vf2_rvvm1_sleef(d)), vcast_vf_f_rvvm1_sleef(0.5)); + + y = vsel_vf_vo_vf_vf_rvvm1_sleef(rvv_sp_vor_vo_vo_vo(vgt_vo_vf_vf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(x), vcast_vf_f_rvvm1_sleef(89)), + visnan_vo_vf_rvvm1_sleef(y)), vcast_vf_f_rvvm1_sleef(__builtin_inff()), y); + y = vmulsign_vf_vf_vf_rvvm1_sleef(y, x); + y = vreinterpret_vf_vm_rvvm1_sleef(vor_vm_vo32_vm_rvvm1_sleef(visnan_vo_vf_rvvm1_sleef(x), vreinterpret_vm_vf_rvvm1_sleef(y))); + + return y; +} + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_coshfx_u10rvvm1(vfloat_rvvm1_sleef x) { + vfloat_rvvm1_sleef y = vabs_vf_vf_rvvm1_sleef(x); + vfloat2_rvvm1_sleef d = expk2f_rvvm1_sleef(vcast_vf2_vf_vf_rvvm1_sleef(y, vcast_vf_f_rvvm1_sleef(0))); + d = dfadd_vf2_vf2_vf2_rvvm1_sleef(d, dfrec_vf2_vf2_rvvm1_sleef(d)); + y = vmul_vf_vf_vf_rvvm1_sleef(vadd_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(d), vf2gety_vf_vf2_rvvm1_sleef(d)), vcast_vf_f_rvvm1_sleef(0.5)); + + y = vsel_vf_vo_vf_vf_rvvm1_sleef(rvv_sp_vor_vo_vo_vo(vgt_vo_vf_vf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(x), vcast_vf_f_rvvm1_sleef(89)), + visnan_vo_vf_rvvm1_sleef(y)), vcast_vf_f_rvvm1_sleef(__builtin_inff()), y); + y = vreinterpret_vf_vm_rvvm1_sleef(vor_vm_vo32_vm_rvvm1_sleef(visnan_vo_vf_rvvm1_sleef(x), vreinterpret_vm_vf_rvvm1_sleef(y))); + + return y; +} + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_tanhfx_u10rvvm1(vfloat_rvvm1_sleef x) { + vfloat_rvvm1_sleef y = vabs_vf_vf_rvvm1_sleef(x); + vfloat2_rvvm1_sleef d = expk2f_rvvm1_sleef(vcast_vf2_vf_vf_rvvm1_sleef(y, vcast_vf_f_rvvm1_sleef(0))); + vfloat2_rvvm1_sleef e = dfrec_vf2_vf2_rvvm1_sleef(d); + d = dfdiv_vf2_vf2_vf2_rvvm1_sleef(dfadd_vf2_vf2_vf2_rvvm1_sleef(d, dfneg_vf2_vf2_rvvm1_sleef(e)), dfadd_vf2_vf2_vf2_rvvm1_sleef(d, e)); + y = vadd_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(d), vf2gety_vf_vf2_rvvm1_sleef(d)); + + y = vsel_vf_vo_vf_vf_rvvm1_sleef(rvv_sp_vor_vo_vo_vo(vgt_vo_vf_vf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(x), vcast_vf_f_rvvm1_sleef(8.664339742f)), + visnan_vo_vf_rvvm1_sleef(y)), vcast_vf_f_rvvm1_sleef(1.0f), y); + y = vmulsign_vf_vf_vf_rvvm1_sleef(y, x); + y = vreinterpret_vf_vm_rvvm1_sleef(vor_vm_vo32_vm_rvvm1_sleef(visnan_vo_vf_rvvm1_sleef(x), vreinterpret_vm_vf_rvvm1_sleef(y))); + + return y; +} + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_sinhfx_u35rvvm1(vfloat_rvvm1_sleef x) { + vfloat_rvvm1_sleef e = expm1fk_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(x)); + vfloat_rvvm1_sleef y = vdiv_vf_vf_vf_rvvm1_sleef(vadd_vf_vf_vf_rvvm1_sleef(e, vcast_vf_f_rvvm1_sleef(2)), vadd_vf_vf_vf_rvvm1_sleef(e, vcast_vf_f_rvvm1_sleef(1))); + y = vmul_vf_vf_vf_rvvm1_sleef(y, vmul_vf_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(0.5f), e)); + + y = vsel_vf_vo_vf_vf_rvvm1_sleef(rvv_sp_vor_vo_vo_vo(vgt_vo_vf_vf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(x), vcast_vf_f_rvvm1_sleef(88)), + visnan_vo_vf_rvvm1_sleef(y)), vcast_vf_f_rvvm1_sleef(__builtin_inff()), y); + y = vmulsign_vf_vf_vf_rvvm1_sleef(y, x); + y = vreinterpret_vf_vm_rvvm1_sleef(vor_vm_vo32_vm_rvvm1_sleef(visnan_vo_vf_rvvm1_sleef(x), vreinterpret_vm_vf_rvvm1_sleef(y))); + + return y; +} + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_coshfx_u35rvvm1(vfloat_rvvm1_sleef x) { + vfloat_rvvm1_sleef e = Sleef_expfx_u10rvvm1(vabs_vf_vf_rvvm1_sleef(x)); + vfloat_rvvm1_sleef y = vmla_vf_vf_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(0.5f), e, vdiv_vf_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(0.5), e)); + + y = vsel_vf_vo_vf_vf_rvvm1_sleef(rvv_sp_vor_vo_vo_vo(vgt_vo_vf_vf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(x), vcast_vf_f_rvvm1_sleef(88)), + visnan_vo_vf_rvvm1_sleef(y)), vcast_vf_f_rvvm1_sleef(__builtin_inff()), y); + y = vreinterpret_vf_vm_rvvm1_sleef(vor_vm_vo32_vm_rvvm1_sleef(visnan_vo_vf_rvvm1_sleef(x), vreinterpret_vm_vf_rvvm1_sleef(y))); + + return y; +} + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_tanhfx_u35rvvm1(vfloat_rvvm1_sleef x) { + vfloat_rvvm1_sleef d = expm1fk_rvvm1_sleef(vmul_vf_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(2), vabs_vf_vf_rvvm1_sleef(x))); + vfloat_rvvm1_sleef y = vdiv_vf_vf_vf_rvvm1_sleef(d, vadd_vf_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(2), d)); + + y = vsel_vf_vo_vf_vf_rvvm1_sleef(rvv_sp_vor_vo_vo_vo(vgt_vo_vf_vf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(x), vcast_vf_f_rvvm1_sleef(8.664339742f)), + visnan_vo_vf_rvvm1_sleef(y)), vcast_vf_f_rvvm1_sleef(1.0f), y); + y = vmulsign_vf_vf_vf_rvvm1_sleef(y, x); + y = vreinterpret_vf_vm_rvvm1_sleef(vor_vm_vo32_vm_rvvm1_sleef(visnan_vo_vf_rvvm1_sleef(x), vreinterpret_vm_vf_rvvm1_sleef(y))); + + return y; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_rvvm1_sleef logk2f_rvvm1_sleef(vfloat2_rvvm1_sleef d) { + vfloat2_rvvm1_sleef x, x2, m, s; + vfloat_rvvm1_sleef t; + vint2_rvvm1_sleef e; + + e = vilogbk_vi2_vf_rvvm1_sleef(vmul_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(d), vcast_vf_f_rvvm1_sleef(1.0f/0.75f))); + + m = dfscale_vf2_vf2_vf_rvvm1_sleef(d, vpow2i_vf_vi2_rvvm1_sleef(vneg_vi2_vi2_rvvm1_sleef(e))); + + x = dfdiv_vf2_vf2_vf2_rvvm1_sleef(dfadd2_vf2_vf2_vf_rvvm1_sleef(m, vcast_vf_f_rvvm1_sleef(-1)), dfadd2_vf2_vf2_vf_rvvm1_sleef(m, vcast_vf_f_rvvm1_sleef(1))); + x2 = dfsqu_vf2_vf2_rvvm1_sleef(x); + + t = vcast_vf_f_rvvm1_sleef(0.2392828464508056640625f); + t = vmla_vf_vf_vf_vf_rvvm1_sleef(t, vf2getx_vf_vf2_rvvm1_sleef(x2), vcast_vf_f_rvvm1_sleef(0.28518211841583251953125f)); + t = vmla_vf_vf_vf_vf_rvvm1_sleef(t, vf2getx_vf_vf2_rvvm1_sleef(x2), vcast_vf_f_rvvm1_sleef(0.400005877017974853515625f)); + t = vmla_vf_vf_vf_vf_rvvm1_sleef(t, vf2getx_vf_vf2_rvvm1_sleef(x2), vcast_vf_f_rvvm1_sleef(0.666666686534881591796875f)); + + s = dfmul_vf2_vf2_vf_rvvm1_sleef(vcast_vf2_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(0.69314718246459960938f), vcast_vf_f_rvvm1_sleef(-1.904654323148236017e-09f)), vcast_vf_vi2_rvvm1_sleef(e)); + s = dfadd_vf2_vf2_vf2_rvvm1_sleef(s, dfscale_vf2_vf2_vf_rvvm1_sleef(x, vcast_vf_f_rvvm1_sleef(2))); + s = dfadd_vf2_vf2_vf2_rvvm1_sleef(s, dfmul_vf2_vf2_vf_rvvm1_sleef(dfmul_vf2_vf2_vf2_rvvm1_sleef(x2, x), t)); + + return s; +} + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_asinhfx_u10rvvm1(vfloat_rvvm1_sleef x) { + vfloat_rvvm1_sleef y = vabs_vf_vf_rvvm1_sleef(x); + rvv_sp_vopmask_rvvm1_sleef o = vgt_vo_vf_vf_rvvm1_sleef(y, vcast_vf_f_rvvm1_sleef(1)); + vfloat2_rvvm1_sleef d; + + d = vsel_vf2_vo_vf2_vf2_rvvm1_sleef(o, dfrec_vf2_vf_rvvm1_sleef(x), vcast_vf2_vf_vf_rvvm1_sleef(y, vcast_vf_f_rvvm1_sleef(0))); + d = dfsqrt_vf2_vf2_rvvm1_sleef(dfadd2_vf2_vf2_vf_rvvm1_sleef(dfsqu_vf2_vf2_rvvm1_sleef(d), vcast_vf_f_rvvm1_sleef(1))); + d = vsel_vf2_vo_vf2_vf2_rvvm1_sleef(o, dfmul_vf2_vf2_vf_rvvm1_sleef(d, y), d); + + d = logk2f_rvvm1_sleef(dfnormalize_vf2_vf2_rvvm1_sleef(dfadd2_vf2_vf2_vf_rvvm1_sleef(d, x))); + y = vadd_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(d), vf2gety_vf_vf2_rvvm1_sleef(d)); + + y = vsel_vf_vo_vf_vf_rvvm1_sleef(rvv_sp_vor_vo_vo_vo(vgt_vo_vf_vf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(x), vcast_vf_f_rvvm1_sleef(18446743523953729536.0)), + visnan_vo_vf_rvvm1_sleef(y)), + vmulsign_vf_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(__builtin_inff()), x), y); + y = vreinterpret_vf_vm_rvvm1_sleef(vor_vm_vo32_vm_rvvm1_sleef(visnan_vo_vf_rvvm1_sleef(x), vreinterpret_vm_vf_rvvm1_sleef(y))); + y = vsel_vf_vo_vf_vf_rvvm1_sleef(visnegzero_vo_vf_rvvm1_sleef(x), vcast_vf_f_rvvm1_sleef(-0.0), y); + + return y; +} + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_acoshfx_u10rvvm1(vfloat_rvvm1_sleef x) { + vfloat2_rvvm1_sleef d = logk2f_rvvm1_sleef(dfadd2_vf2_vf2_vf_rvvm1_sleef(dfmul_vf2_vf2_vf2_rvvm1_sleef(dfsqrt_vf2_vf2_rvvm1_sleef(dfadd2_vf2_vf_vf_rvvm1_sleef(x, vcast_vf_f_rvvm1_sleef(1))), dfsqrt_vf2_vf2_rvvm1_sleef(dfadd2_vf2_vf_vf_rvvm1_sleef(x, vcast_vf_f_rvvm1_sleef(-1)))), x)); + vfloat_rvvm1_sleef y = vadd_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(d), vf2gety_vf_vf2_rvvm1_sleef(d)); + + y = vsel_vf_vo_vf_vf_rvvm1_sleef(rvv_sp_vor_vo_vo_vo(vgt_vo_vf_vf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(x), vcast_vf_f_rvvm1_sleef(18446743523953729536.0)), + visnan_vo_vf_rvvm1_sleef(y)), + vcast_vf_f_rvvm1_sleef(__builtin_inff()), y); + + y = vreinterpret_vf_vm_rvvm1_sleef(vandnot_vm_vo32_vm_rvvm1_sleef(veq_vo_vf_vf_rvvm1_sleef(x, vcast_vf_f_rvvm1_sleef(1.0f)), vreinterpret_vm_vf_rvvm1_sleef(y))); + + y = vreinterpret_vf_vm_rvvm1_sleef(vor_vm_vo32_vm_rvvm1_sleef(vlt_vo_vf_vf_rvvm1_sleef(x, vcast_vf_f_rvvm1_sleef(1.0f)), vreinterpret_vm_vf_rvvm1_sleef(y))); + y = vreinterpret_vf_vm_rvvm1_sleef(vor_vm_vo32_vm_rvvm1_sleef(visnan_vo_vf_rvvm1_sleef(x), vreinterpret_vm_vf_rvvm1_sleef(y))); + + return y; +} + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_atanhfx_u10rvvm1(vfloat_rvvm1_sleef x) { + vfloat_rvvm1_sleef y = vabs_vf_vf_rvvm1_sleef(x); + vfloat2_rvvm1_sleef d = logk2f_rvvm1_sleef(dfdiv_vf2_vf2_vf2_rvvm1_sleef(dfadd2_vf2_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(1), y), dfadd2_vf2_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(1), vneg_vf_vf_rvvm1_sleef(y)))); + y = vreinterpret_vf_vm_rvvm1_sleef(vor_vm_vo32_vm_rvvm1_sleef(vgt_vo_vf_vf_rvvm1_sleef(y, vcast_vf_f_rvvm1_sleef(1.0)), vreinterpret_vm_vf_rvvm1_sleef(vsel_vf_vo_vf_vf_rvvm1_sleef(veq_vo_vf_vf_rvvm1_sleef(y, vcast_vf_f_rvvm1_sleef(1.0)), vcast_vf_f_rvvm1_sleef(__builtin_inff()), vmul_vf_vf_vf_rvvm1_sleef(vadd_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(d), vf2gety_vf_vf2_rvvm1_sleef(d)), vcast_vf_f_rvvm1_sleef(0.5)))))); + + y = vreinterpret_vf_vm_rvvm1_sleef(vor_vm_vo32_vm_rvvm1_sleef(rvv_sp_vor_vo_vo_vo(visinf_vo_vf_rvvm1_sleef(x), visnan_vo_vf_rvvm1_sleef(y)), vreinterpret_vm_vf_rvvm1_sleef(y))); + y = vmulsign_vf_vf_vf_rvvm1_sleef(y, x); + y = vreinterpret_vf_vm_rvvm1_sleef(vor_vm_vo32_vm_rvvm1_sleef(visnan_vo_vf_rvvm1_sleef(x), vreinterpret_vm_vf_rvvm1_sleef(y))); + + return y; +} + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_exp2fx_u10rvvm1(vfloat_rvvm1_sleef d) { + vfloat_rvvm1_sleef u = vrint_vf_vf_rvvm1_sleef(d), s; + vint2_rvvm1_sleef q = vrint_vi2_vf_rvvm1_sleef(u); + + s = vsub_vf_vf_vf_rvvm1_sleef(d, u); + + u = vcast_vf_f_rvvm1_sleef(+0.1535920892e-3); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, s, vcast_vf_f_rvvm1_sleef(+0.1339262701e-2)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, s, vcast_vf_f_rvvm1_sleef(+0.9618384764e-2)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, s, vcast_vf_f_rvvm1_sleef(+0.5550347269e-1)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, s, vcast_vf_f_rvvm1_sleef(+0.2402264476e+0)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, s, vcast_vf_f_rvvm1_sleef(+0.6931471825e+0)); + + u = vfma_vf_vf_vf_vf_rvvm1_sleef(u, s, vcast_vf_f_rvvm1_sleef(1)); + + u = vldexp2_vf_vf_vi2_rvvm1_sleef(u, q); + + u = vsel_vf_vo_vf_vf_rvvm1_sleef(vge_vo_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(128)), vcast_vf_f_rvvm1_sleef(__builtin_inf()), u); + u = vreinterpret_vf_vm_rvvm1_sleef(vandnot_vm_vo32_vm_rvvm1_sleef(vlt_vo_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(-150)), vreinterpret_vm_vf_rvvm1_sleef(u))); + + return u; +} + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_exp2fx_u35rvvm1(vfloat_rvvm1_sleef d) { + vfloat_rvvm1_sleef u = vrint_vf_vf_rvvm1_sleef(d), s; + vint2_rvvm1_sleef q = vrint_vi2_vf_rvvm1_sleef(u); + + s = vsub_vf_vf_vf_rvvm1_sleef(d, u); + + u = vcast_vf_f_rvvm1_sleef(+0.1535920892e-3); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, s, vcast_vf_f_rvvm1_sleef(+0.1339262701e-2)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, s, vcast_vf_f_rvvm1_sleef(+0.9618384764e-2)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, s, vcast_vf_f_rvvm1_sleef(+0.5550347269e-1)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, s, vcast_vf_f_rvvm1_sleef(+0.2402264476e+0)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, s, vcast_vf_f_rvvm1_sleef(+0.6931471825e+0)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, s, vcast_vf_f_rvvm1_sleef(+0.1000000000e+1)); + + u = vldexp2_vf_vf_vi2_rvvm1_sleef(u, q); + + u = vsel_vf_vo_vf_vf_rvvm1_sleef(vge_vo_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(128)), vcast_vf_f_rvvm1_sleef(__builtin_inf()), u); + u = vreinterpret_vf_vm_rvvm1_sleef(vandnot_vm_vo32_vm_rvvm1_sleef(vlt_vo_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(-150)), vreinterpret_vm_vf_rvvm1_sleef(u))); + + return u; +} + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_exp10fx_u10rvvm1(vfloat_rvvm1_sleef d) { + vfloat_rvvm1_sleef u = vrint_vf_vf_rvvm1_sleef(vmul_vf_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(3.3219280948873623478703194294893901758648313930))), s; + vint2_rvvm1_sleef q = vrint_vi2_vf_rvvm1_sleef(u); + + s = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vcast_vf_f_rvvm1_sleef(-0.3010253906f), d); + s = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vcast_vf_f_rvvm1_sleef(-4.605038981e-06f), s); + + u = vcast_vf_f_rvvm1_sleef(+0.6802555919e-1); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, s, vcast_vf_f_rvvm1_sleef(+0.2078080326e+0)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, s, vcast_vf_f_rvvm1_sleef(+0.5393903852e+0)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, s, vcast_vf_f_rvvm1_sleef(+0.1171245337e+1)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, s, vcast_vf_f_rvvm1_sleef(+0.2034678698e+1)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, s, vcast_vf_f_rvvm1_sleef(+0.2650949001e+1)); + vfloat2_rvvm1_sleef x = dfadd_vf2_vf2_vf_rvvm1_sleef(vcast_vf2_f_f_rvvm1_sleef(2.3025851249694824219, -3.1705172516493593157e-08), vmul_vf_vf_vf_rvvm1_sleef(u, s)); + u = vf2getx_vf_vf2_rvvm1_sleef(dfnormalize_vf2_vf2_rvvm1_sleef(dfadd_vf2_vf_vf2_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(1), dfmul_vf2_vf2_vf_rvvm1_sleef(x, s)))); + + u = vldexp2_vf_vf_vi2_rvvm1_sleef(u, q); + + u = vsel_vf_vo_vf_vf_rvvm1_sleef(vgt_vo_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(38.5318394191036238941387f)), vcast_vf_f_rvvm1_sleef(__builtin_inff()), u); + u = vreinterpret_vf_vm_rvvm1_sleef(vandnot_vm_vo32_vm_rvvm1_sleef(vlt_vo_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(-50)), vreinterpret_vm_vf_rvvm1_sleef(u))); + + return u; +} + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_exp10fx_u35rvvm1(vfloat_rvvm1_sleef d) { + vfloat_rvvm1_sleef u = vrint_vf_vf_rvvm1_sleef(vmul_vf_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(3.3219280948873623478703194294893901758648313930))), s; + vint2_rvvm1_sleef q = vrint_vi2_vf_rvvm1_sleef(u); + + s = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vcast_vf_f_rvvm1_sleef(-0.3010253906f), d); + s = vmla_vf_vf_vf_vf_rvvm1_sleef(u, vcast_vf_f_rvvm1_sleef(-4.605038981e-06f), s); + + u = vcast_vf_f_rvvm1_sleef(+0.2064004987e+0); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, s, vcast_vf_f_rvvm1_sleef(+0.5417877436e+0)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, s, vcast_vf_f_rvvm1_sleef(+0.1171286821e+1)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, s, vcast_vf_f_rvvm1_sleef(+0.2034656048e+1)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, s, vcast_vf_f_rvvm1_sleef(+0.2650948763e+1)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, s, vcast_vf_f_rvvm1_sleef(+0.2302585125e+1)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, s, vcast_vf_f_rvvm1_sleef(+0.1000000000e+1)); + + u = vldexp2_vf_vf_vi2_rvvm1_sleef(u, q); + + u = vsel_vf_vo_vf_vf_rvvm1_sleef(vgt_vo_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(38.5318394191036238941387f)), vcast_vf_f_rvvm1_sleef(__builtin_inff()), u); + u = vreinterpret_vf_vm_rvvm1_sleef(vandnot_vm_vo32_vm_rvvm1_sleef(vlt_vo_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(-50)), vreinterpret_vm_vf_rvvm1_sleef(u))); + + return u; +} + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_expm1fx_u10rvvm1(vfloat_rvvm1_sleef a) { + vfloat2_rvvm1_sleef d = dfadd2_vf2_vf2_vf_rvvm1_sleef(expk2f_rvvm1_sleef(vcast_vf2_vf_vf_rvvm1_sleef(a, vcast_vf_f_rvvm1_sleef(0))), vcast_vf_f_rvvm1_sleef(-1.0)); + vfloat_rvvm1_sleef x = vadd_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(d), vf2gety_vf_vf2_rvvm1_sleef(d)); + x = vsel_vf_vo_vf_vf_rvvm1_sleef(vgt_vo_vf_vf_rvvm1_sleef(a, vcast_vf_f_rvvm1_sleef(88.72283172607421875f)), vcast_vf_f_rvvm1_sleef(__builtin_inff()), x); + x = vsel_vf_vo_vf_vf_rvvm1_sleef(vlt_vo_vf_vf_rvvm1_sleef(a, vcast_vf_f_rvvm1_sleef(-16.635532333438687426013570f)), vcast_vf_f_rvvm1_sleef(-1), x); + x = vsel_vf_vo_vf_vf_rvvm1_sleef(visnegzero_vo_vf_rvvm1_sleef(a), vcast_vf_f_rvvm1_sleef(-0.0f), x); + return x; +} + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_log10fx_u10rvvm1(vfloat_rvvm1_sleef d) { + vfloat2_rvvm1_sleef x; + vfloat_rvvm1_sleef t, m, x2; + + rvv_sp_vopmask_rvvm1_sleef o = vlt_vo_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(0x1p-126)); + d = vsel_vf_vo_vf_vf_rvvm1_sleef(o, vmul_vf_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef((float)(INT64_C(1) << 32) * (float)(INT64_C(1) << 32))), d); + vint2_rvvm1_sleef e = vilogb2k_vi2_vf_rvvm1_sleef(vmul_vf_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(1.0/0.75))); + m = vldexp3_vf_vf_vi2_rvvm1_sleef(d, vneg_vi2_vi2_rvvm1_sleef(e)); + e = vsel_vi2_vo_vi2_vi2_rvvm1_sleef(o, vsub_vi2_vi2_vi2_rvvm1_sleef(e, vcast_vi2_i_rvvm1_sleef(64)), e); + + x = dfdiv_vf2_vf2_vf2_rvvm1_sleef(dfadd2_vf2_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(-1), m), dfadd2_vf2_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(1), m)); + x2 = vmul_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(x), vf2getx_vf_vf2_rvvm1_sleef(x)); + + t = vcast_vf_f_rvvm1_sleef(+0.1314289868e+0); + t = vmla_vf_vf_vf_vf_rvvm1_sleef(t, x2, vcast_vf_f_rvvm1_sleef( +0.1735493541e+0)); + t = vmla_vf_vf_vf_vf_rvvm1_sleef(t, x2, vcast_vf_f_rvvm1_sleef( +0.2895309627e+0)); + + vfloat2_rvvm1_sleef s = dfmul_vf2_vf2_vf_rvvm1_sleef(vcast_vf2_f_f_rvvm1_sleef(0.30103001, -1.432098889e-08), vcast_vf_vi2_rvvm1_sleef(e)); + + s = dfadd_vf2_vf2_vf2_rvvm1_sleef(s, dfmul_vf2_vf2_vf2_rvvm1_sleef(x, vcast_vf2_f_f_rvvm1_sleef(0.868588984, -2.170757285e-08))); + s = dfadd_vf2_vf2_vf_rvvm1_sleef(s, vmul_vf_vf_vf_rvvm1_sleef(vmul_vf_vf_vf_rvvm1_sleef(x2, vf2getx_vf_vf2_rvvm1_sleef(x)), t)); + + vfloat_rvvm1_sleef r = vadd_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(s), vf2gety_vf_vf2_rvvm1_sleef(s)); + + r = vsel_vf_vo_vf_vf_rvvm1_sleef(vispinf_vo_vf_rvvm1_sleef(d), vcast_vf_f_rvvm1_sleef(__builtin_inf()), r); + r = vsel_vf_vo_vf_vf_rvvm1_sleef(rvv_sp_vor_vo_vo_vo(vlt_vo_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(0)), visnan_vo_vf_rvvm1_sleef(d)), vcast_vf_f_rvvm1_sleef(__builtin_nan("")), r); + r = vsel_vf_vo_vf_vf_rvvm1_sleef(veq_vo_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(0)), vcast_vf_f_rvvm1_sleef(-__builtin_inf()), r); + + return r; +} + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_log2fx_u10rvvm1(vfloat_rvvm1_sleef d) { + vfloat2_rvvm1_sleef x; + vfloat_rvvm1_sleef t, m, x2; + + rvv_sp_vopmask_rvvm1_sleef o = vlt_vo_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(0x1p-126)); + d = vsel_vf_vo_vf_vf_rvvm1_sleef(o, vmul_vf_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef((float)(INT64_C(1) << 32) * (float)(INT64_C(1) << 32))), d); + vint2_rvvm1_sleef e = vilogb2k_vi2_vf_rvvm1_sleef(vmul_vf_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(1.0/0.75))); + m = vldexp3_vf_vf_vi2_rvvm1_sleef(d, vneg_vi2_vi2_rvvm1_sleef(e)); + e = vsel_vi2_vo_vi2_vi2_rvvm1_sleef(o, vsub_vi2_vi2_vi2_rvvm1_sleef(e, vcast_vi2_i_rvvm1_sleef(64)), e); + + x = dfdiv_vf2_vf2_vf2_rvvm1_sleef(dfadd2_vf2_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(-1), m), dfadd2_vf2_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(1), m)); + x2 = vmul_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(x), vf2getx_vf_vf2_rvvm1_sleef(x)); + + t = vcast_vf_f_rvvm1_sleef(+0.4374550283e+0f); + t = vmla_vf_vf_vf_vf_rvvm1_sleef(t, x2, vcast_vf_f_rvvm1_sleef(+0.5764790177e+0f)); + t = vmla_vf_vf_vf_vf_rvvm1_sleef(t, x2, vcast_vf_f_rvvm1_sleef(+0.9618012905120f)); + + vfloat2_rvvm1_sleef s = dfadd2_vf2_vf_vf2_rvvm1_sleef(vcast_vf_vi2_rvvm1_sleef(e), + dfmul_vf2_vf2_vf2_rvvm1_sleef(x, vcast_vf2_f_f_rvvm1_sleef(2.8853900432586669922, 3.2734474483568488616e-08))); + + s = dfadd2_vf2_vf2_vf_rvvm1_sleef(s, vmul_vf_vf_vf_rvvm1_sleef(vmul_vf_vf_vf_rvvm1_sleef(x2, vf2getx_vf_vf2_rvvm1_sleef(x)), t)); + + vfloat_rvvm1_sleef r = vadd_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(s), vf2gety_vf_vf2_rvvm1_sleef(s)); + + r = vsel_vf_vo_vf_vf_rvvm1_sleef(vispinf_vo_vf_rvvm1_sleef(d), vcast_vf_f_rvvm1_sleef(__builtin_inf()), r); + r = vsel_vf_vo_vf_vf_rvvm1_sleef(rvv_sp_vor_vo_vo_vo(vlt_vo_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(0)), visnan_vo_vf_rvvm1_sleef(d)), vcast_vf_f_rvvm1_sleef(__builtin_nan("")), r); + r = vsel_vf_vo_vf_vf_rvvm1_sleef(veq_vo_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(0)), vcast_vf_f_rvvm1_sleef(-__builtin_inf()), r); + + return r; +} + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_log2fx_u35rvvm1(vfloat_rvvm1_sleef d) { + vfloat_rvvm1_sleef m, t, x, x2; + + rvv_sp_vopmask_rvvm1_sleef o = vlt_vo_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(0x1p-126)); + d = vsel_vf_vo_vf_vf_rvvm1_sleef(o, vmul_vf_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef((float)(INT64_C(1) << 32) * (float)(INT64_C(1) << 32))), d); + vint2_rvvm1_sleef e = vilogb2k_vi2_vf_rvvm1_sleef(vmul_vf_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(1.0/0.75))); + m = vldexp3_vf_vf_vi2_rvvm1_sleef(d, vneg_vi2_vi2_rvvm1_sleef(e)); + e = vsel_vi2_vo_vi2_vi2_rvvm1_sleef(o, vsub_vi2_vi2_vi2_rvvm1_sleef(e, vcast_vi2_i_rvvm1_sleef(64)), e); + + x = vdiv_vf_vf_vf_rvvm1_sleef(vsub_vf_vf_vf_rvvm1_sleef(m, vcast_vf_f_rvvm1_sleef(1)), vadd_vf_vf_vf_rvvm1_sleef(m, vcast_vf_f_rvvm1_sleef(1))); + x2 = vmul_vf_vf_vf_rvvm1_sleef(x, x); + + t = vcast_vf_f_rvvm1_sleef(+0.4374088347e+0); + t = vmla_vf_vf_vf_vf_rvvm1_sleef(t, x2, vcast_vf_f_rvvm1_sleef(+0.5764843822e+0)); + t = vmla_vf_vf_vf_vf_rvvm1_sleef(t, x2, vcast_vf_f_rvvm1_sleef(+0.9618024230e+0)); + + vfloat_rvvm1_sleef r = vmla_vf_vf_vf_vf_rvvm1_sleef(vmul_vf_vf_vf_rvvm1_sleef(x2, x), t, + vmla_vf_vf_vf_vf_rvvm1_sleef(x, vcast_vf_f_rvvm1_sleef(+0.2885390043e+1), vcast_vf_vi2_rvvm1_sleef(e))); + + r = vsel_vf_vo_vf_vf_rvvm1_sleef(vispinf_vo_vf_rvvm1_sleef(d), vcast_vf_f_rvvm1_sleef(__builtin_inf()), r); + r = vsel_vf_vo_vf_vf_rvvm1_sleef(rvv_sp_vor_vo_vo_vo(vlt_vo_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(0)), visnan_vo_vf_rvvm1_sleef(d)), vcast_vf_f_rvvm1_sleef(__builtin_nan("")), r); + r = vsel_vf_vo_vf_vf_rvvm1_sleef(veq_vo_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(0)), vcast_vf_f_rvvm1_sleef(-__builtin_inf()), r); + + return r; +} + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_log1pfx_u10rvvm1(vfloat_rvvm1_sleef d) { + vfloat2_rvvm1_sleef x; + vfloat_rvvm1_sleef t, m, x2; + + vfloat_rvvm1_sleef dp1 = vadd_vf_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(1)); + + rvv_sp_vopmask_rvvm1_sleef o = vlt_vo_vf_vf_rvvm1_sleef(dp1, vcast_vf_f_rvvm1_sleef(0x1p-126)); + dp1 = vsel_vf_vo_vf_vf_rvvm1_sleef(o, vmul_vf_vf_vf_rvvm1_sleef(dp1, vcast_vf_f_rvvm1_sleef((float)(INT64_C(1) << 32) * (float)(INT64_C(1) << 32))), dp1); + vint2_rvvm1_sleef e = vilogb2k_vi2_vf_rvvm1_sleef(vmul_vf_vf_vf_rvvm1_sleef(dp1, vcast_vf_f_rvvm1_sleef(1.0f/0.75f))); + t = vldexp3_vf_vf_vi2_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(1), vneg_vi2_vi2_rvvm1_sleef(e)); + m = vmla_vf_vf_vf_vf_rvvm1_sleef(d, t, vsub_vf_vf_vf_rvvm1_sleef(t, vcast_vf_f_rvvm1_sleef(1))); + e = vsel_vi2_vo_vi2_vi2_rvvm1_sleef(o, vsub_vi2_vi2_vi2_rvvm1_sleef(e, vcast_vi2_i_rvvm1_sleef(64)), e); + vfloat2_rvvm1_sleef s = dfmul_vf2_vf2_vf_rvvm1_sleef(vcast_vf2_f_f_rvvm1_sleef(0.69314718246459960938f, -1.904654323148236017e-09f), vcast_vf_vi2_rvvm1_sleef(e)); + + x = dfdiv_vf2_vf2_vf2_rvvm1_sleef(vcast_vf2_vf_vf_rvvm1_sleef(m, vcast_vf_f_rvvm1_sleef(0)), dfadd_vf2_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(2), m)); + x2 = vmul_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(x), vf2getx_vf_vf2_rvvm1_sleef(x)); + + t = vcast_vf_f_rvvm1_sleef(+0.3027294874e+0f); + t = vmla_vf_vf_vf_vf_rvvm1_sleef(t, x2, vcast_vf_f_rvvm1_sleef(+0.3996108174e+0f)); + t = vmla_vf_vf_vf_vf_rvvm1_sleef(t, x2, vcast_vf_f_rvvm1_sleef(+0.6666694880e+0f)); + + s = dfadd_vf2_vf2_vf2_rvvm1_sleef(s, dfscale_vf2_vf2_vf_rvvm1_sleef(x, vcast_vf_f_rvvm1_sleef(2))); + s = dfadd_vf2_vf2_vf_rvvm1_sleef(s, vmul_vf_vf_vf_rvvm1_sleef(vmul_vf_vf_vf_rvvm1_sleef(x2, vf2getx_vf_vf2_rvvm1_sleef(x)), t)); + + vfloat_rvvm1_sleef r = vadd_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(s), vf2gety_vf_vf2_rvvm1_sleef(s)); + + r = vsel_vf_vo_vf_vf_rvvm1_sleef(vgt_vo_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(1e+38)), vcast_vf_f_rvvm1_sleef(__builtin_inff()), r); + r = vreinterpret_vf_vm_rvvm1_sleef(vor_vm_vo32_vm_rvvm1_sleef(vgt_vo_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(-1), d), vreinterpret_vm_vf_rvvm1_sleef(r))); + r = vsel_vf_vo_vf_vf_rvvm1_sleef(veq_vo_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(-1)), vcast_vf_f_rvvm1_sleef(-__builtin_inff()), r); + r = vsel_vf_vo_vf_vf_rvvm1_sleef(visnegzero_vo_vf_rvvm1_sleef(d), vcast_vf_f_rvvm1_sleef(-0.0f), r); + + return r; +} + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_fabsfx_rvvm1(vfloat_rvvm1_sleef x) { return vabs_vf_vf_rvvm1_sleef(x); } + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_copysignfx_rvvm1(vfloat_rvvm1_sleef x, vfloat_rvvm1_sleef y) { return vcopysign_vf_vf_vf_rvvm1_sleef(x, y); } + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_fmaxfx_rvvm1(vfloat_rvvm1_sleef x, vfloat_rvvm1_sleef y) { + + return vsel_vf_vo_vf_vf_rvvm1_sleef(visnan_vo_vf_rvvm1_sleef(y), x, vsel_vf_vo_vf_vf_rvvm1_sleef(vgt_vo_vf_vf_rvvm1_sleef(x, y), x, y)); + +} + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_fminfx_rvvm1(vfloat_rvvm1_sleef x, vfloat_rvvm1_sleef y) { + + return vsel_vf_vo_vf_vf_rvvm1_sleef(visnan_vo_vf_rvvm1_sleef(y), x, vsel_vf_vo_vf_vf_rvvm1_sleef(vgt_vo_vf_vf_rvvm1_sleef(y, x), x, y)); + +} + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_fdimfx_rvvm1(vfloat_rvvm1_sleef x, vfloat_rvvm1_sleef y) { + vfloat_rvvm1_sleef ret = vsub_vf_vf_vf_rvvm1_sleef(x, y); + ret = vsel_vf_vo_vf_vf_rvvm1_sleef(rvv_sp_vor_vo_vo_vo(vlt_vo_vf_vf_rvvm1_sleef(ret, vcast_vf_f_rvvm1_sleef(0)), veq_vo_vf_vf_rvvm1_sleef(x, y)), vcast_vf_f_rvvm1_sleef(0), ret); + return ret; +} + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_truncfx_rvvm1(vfloat_rvvm1_sleef x) { + + vfloat_rvvm1_sleef fr = vsub_vf_vf_vf_rvvm1_sleef(x, vcast_vf_vi2_rvvm1_sleef(vtruncate_vi2_vf_rvvm1_sleef(x))); + return vsel_vf_vo_vf_vf_rvvm1_sleef(rvv_sp_vor_vo_vo_vo(visinf_vo_vf_rvvm1_sleef(x), vge_vo_vf_vf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(x), vcast_vf_f_rvvm1_sleef(INT64_C(1) << 23))), x, vcopysign_vf_vf_vf_rvvm1_sleef(vsub_vf_vf_vf_rvvm1_sleef(x, fr), x)); + +} + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_floorfx_rvvm1(vfloat_rvvm1_sleef x) { + vfloat_rvvm1_sleef fr = vsub_vf_vf_vf_rvvm1_sleef(x, vcast_vf_vi2_rvvm1_sleef(vtruncate_vi2_vf_rvvm1_sleef(x))); + fr = vsel_vf_vo_vf_vf_rvvm1_sleef(vlt_vo_vf_vf_rvvm1_sleef(fr, vcast_vf_f_rvvm1_sleef(0)), vadd_vf_vf_vf_rvvm1_sleef(fr, vcast_vf_f_rvvm1_sleef(1.0f)), fr); + return vsel_vf_vo_vf_vf_rvvm1_sleef(rvv_sp_vor_vo_vo_vo(visinf_vo_vf_rvvm1_sleef(x), vge_vo_vf_vf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(x), vcast_vf_f_rvvm1_sleef(INT64_C(1) << 23))), x, vcopysign_vf_vf_vf_rvvm1_sleef(vsub_vf_vf_vf_rvvm1_sleef(x, fr), x)); +} + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_ceilfx_rvvm1(vfloat_rvvm1_sleef x) { + vfloat_rvvm1_sleef fr = vsub_vf_vf_vf_rvvm1_sleef(x, vcast_vf_vi2_rvvm1_sleef(vtruncate_vi2_vf_rvvm1_sleef(x))); + fr = vsel_vf_vo_vf_vf_rvvm1_sleef(vle_vo_vf_vf_rvvm1_sleef(fr, vcast_vf_f_rvvm1_sleef(0)), fr, vsub_vf_vf_vf_rvvm1_sleef(fr, vcast_vf_f_rvvm1_sleef(1.0f))); + return vsel_vf_vo_vf_vf_rvvm1_sleef(rvv_sp_vor_vo_vo_vo(visinf_vo_vf_rvvm1_sleef(x), vge_vo_vf_vf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(x), vcast_vf_f_rvvm1_sleef(INT64_C(1) << 23))), x, vcopysign_vf_vf_vf_rvvm1_sleef(vsub_vf_vf_vf_rvvm1_sleef(x, fr), x)); +} + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_roundfx_rvvm1(vfloat_rvvm1_sleef d) { + vfloat_rvvm1_sleef x = vadd_vf_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(0.5f)); + vfloat_rvvm1_sleef fr = vsub_vf_vf_vf_rvvm1_sleef(x, vcast_vf_vi2_rvvm1_sleef(vtruncate_vi2_vf_rvvm1_sleef(x))); + x = vsel_vf_vo_vf_vf_rvvm1_sleef(rvv_sp_vand_vo_vo_vo(vle_vo_vf_vf_rvvm1_sleef(x, vcast_vf_f_rvvm1_sleef(0)), veq_vo_vf_vf_rvvm1_sleef(fr, vcast_vf_f_rvvm1_sleef(0))), vsub_vf_vf_vf_rvvm1_sleef(x, vcast_vf_f_rvvm1_sleef(1.0f)), x); + fr = vsel_vf_vo_vf_vf_rvvm1_sleef(vlt_vo_vf_vf_rvvm1_sleef(fr, vcast_vf_f_rvvm1_sleef(0)), vadd_vf_vf_vf_rvvm1_sleef(fr, vcast_vf_f_rvvm1_sleef(1.0f)), fr); + x = vsel_vf_vo_vf_vf_rvvm1_sleef(veq_vo_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(0.4999999701976776123f)), vcast_vf_f_rvvm1_sleef(0), x); + return vsel_vf_vo_vf_vf_rvvm1_sleef(rvv_sp_vor_vo_vo_vo(visinf_vo_vf_rvvm1_sleef(d), vge_vo_vf_vf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(d), vcast_vf_f_rvvm1_sleef(INT64_C(1) << 23))), d, vcopysign_vf_vf_vf_rvvm1_sleef(vsub_vf_vf_vf_rvvm1_sleef(x, fr), d)); +} + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_rintfx_rvvm1(vfloat_rvvm1_sleef d) { + + vfloat_rvvm1_sleef c = vmulsign_vf_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(1 << 23), d); + return vsel_vf_vo_vf_vf_rvvm1_sleef(vgt_vo_vf_vf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(d), vcast_vf_f_rvvm1_sleef(1 << 23)), + d, vorsign_vf_vf_vf_rvvm1_sleef(vsub_vf_vf_vf_rvvm1_sleef(vadd_vf_vf_vf_rvvm1_sleef(d, c), c), d)); + +} + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_fmafx_rvvm1(vfloat_rvvm1_sleef x, vfloat_rvvm1_sleef y, vfloat_rvvm1_sleef z) { + + return vfma_vf_vf_vf_vf_rvvm1_sleef(x, y, z); + +} + +SLEEF_INLINE vfloat_rvvm1_sleef Sleef_sqrtfx_u05rvvm1(vfloat_rvvm1_sleef d) { + + vfloat_rvvm1_sleef q, w, x, y, z; + + d = vsel_vf_vo_vf_vf_rvvm1_sleef(vlt_vo_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(0)), vcast_vf_f_rvvm1_sleef(__builtin_nanf("")), d); + + rvv_sp_vopmask_rvvm1_sleef o = vlt_vo_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(5.2939559203393770e-23f)); + d = vsel_vf_vo_vf_vf_rvvm1_sleef(o, vmul_vf_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(1.8889465931478580e+22f)), d); + q = vsel_vf_vo_vf_vf_rvvm1_sleef(o, vcast_vf_f_rvvm1_sleef(7.2759576141834260e-12f), vcast_vf_f_rvvm1_sleef(1.0f)); + + y = vreinterpret_vf_vi2_rvvm1_sleef(vsub_vi2_vi2_vi2_rvvm1_sleef(vcast_vi2_i_rvvm1_sleef(0x5f3759df), vsrl_vi2_vi2_i_rvvm1_sleef(vreinterpret_vi2_vf_rvvm1_sleef(d), 1))); + + x = vmul_vf_vf_vf_rvvm1_sleef(d, y); w = vmul_vf_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(0.5), y); + y = vfmanp_vf_vf_vf_vf_rvvm1_sleef(x, w, vcast_vf_f_rvvm1_sleef(0.5)); + x = vfma_vf_vf_vf_vf_rvvm1_sleef(x, y, x); w = vfma_vf_vf_vf_vf_rvvm1_sleef(w, y, w); + y = vfmanp_vf_vf_vf_vf_rvvm1_sleef(x, w, vcast_vf_f_rvvm1_sleef(0.5)); + x = vfma_vf_vf_vf_vf_rvvm1_sleef(x, y, x); w = vfma_vf_vf_vf_vf_rvvm1_sleef(w, y, w); + + y = vfmanp_vf_vf_vf_vf_rvvm1_sleef(x, w, vcast_vf_f_rvvm1_sleef(1.5)); w = vadd_vf_vf_vf_rvvm1_sleef(w, w); + w = vmul_vf_vf_vf_rvvm1_sleef(w, y); + x = vmul_vf_vf_vf_rvvm1_sleef(w, d); + y = vfmapn_vf_vf_vf_vf_rvvm1_sleef(w, d, x); z = vfmanp_vf_vf_vf_vf_rvvm1_sleef(w, x, vcast_vf_f_rvvm1_sleef(1)); + + z = vfmanp_vf_vf_vf_vf_rvvm1_sleef(w, y, z); w = vmul_vf_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(0.5), x); + w = vfma_vf_vf_vf_vf_rvvm1_sleef(w, z, y); + w = vadd_vf_vf_vf_rvvm1_sleef(w, x); + + w = vmul_vf_vf_vf_rvvm1_sleef(w, q); + + w = vsel_vf_vo_vf_vf_rvvm1_sleef(rvv_sp_vor_vo_vo_vo(veq_vo_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(0)), + veq_vo_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(__builtin_inff()))), d, w); + + w = vsel_vf_vo_vf_vf_rvvm1_sleef(vlt_vo_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(0)), vcast_vf_f_rvvm1_sleef(__builtin_nanf("")), w); + + return w; + +} + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_sqrtfx_rvvm1(vfloat_rvvm1_sleef d) { + + return Sleef_sqrtfx_u05rvvm1(d); + +} + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_hypotfx_u05rvvm1(vfloat_rvvm1_sleef x, vfloat_rvvm1_sleef y) { + x = vabs_vf_vf_rvvm1_sleef(x); + y = vabs_vf_vf_rvvm1_sleef(y); + vfloat_rvvm1_sleef min = vmin_vf_vf_vf_rvvm1_sleef(x, y), n = min; + vfloat_rvvm1_sleef max = vmax_vf_vf_vf_rvvm1_sleef(x, y), d = max; + + rvv_sp_vopmask_rvvm1_sleef o = vlt_vo_vf_vf_rvvm1_sleef(max, vcast_vf_f_rvvm1_sleef(0x1p-126)); + n = vsel_vf_vo_vf_vf_rvvm1_sleef(o, vmul_vf_vf_vf_rvvm1_sleef(n, vcast_vf_f_rvvm1_sleef(UINT64_C(1) << 24)), n); + d = vsel_vf_vo_vf_vf_rvvm1_sleef(o, vmul_vf_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(UINT64_C(1) << 24)), d); + + vfloat2_rvvm1_sleef t = dfdiv_vf2_vf2_vf2_rvvm1_sleef(vcast_vf2_vf_vf_rvvm1_sleef(n, vcast_vf_f_rvvm1_sleef(0)), vcast_vf2_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(0))); + t = dfmul_vf2_vf2_vf_rvvm1_sleef(dfsqrt_vf2_vf2_rvvm1_sleef(dfadd2_vf2_vf2_vf_rvvm1_sleef(dfsqu_vf2_vf2_rvvm1_sleef(t), vcast_vf_f_rvvm1_sleef(1))), max); + vfloat_rvvm1_sleef ret = vadd_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(t), vf2gety_vf_vf2_rvvm1_sleef(t)); + ret = vsel_vf_vo_vf_vf_rvvm1_sleef(visnan_vo_vf_rvvm1_sleef(ret), vcast_vf_f_rvvm1_sleef(__builtin_inff()), ret); + ret = vsel_vf_vo_vf_vf_rvvm1_sleef(veq_vo_vf_vf_rvvm1_sleef(min, vcast_vf_f_rvvm1_sleef(0)), max, ret); + ret = vsel_vf_vo_vf_vf_rvvm1_sleef(rvv_sp_vor_vo_vo_vo(visnan_vo_vf_rvvm1_sleef(x), visnan_vo_vf_rvvm1_sleef(y)), vcast_vf_f_rvvm1_sleef(__builtin_nanf("")), ret); + ret = vsel_vf_vo_vf_vf_rvvm1_sleef(rvv_sp_vor_vo_vo_vo(veq_vo_vf_vf_rvvm1_sleef(x, vcast_vf_f_rvvm1_sleef(__builtin_inff())), veq_vo_vf_vf_rvvm1_sleef(y, vcast_vf_f_rvvm1_sleef(__builtin_inff()))), vcast_vf_f_rvvm1_sleef(__builtin_inff()), ret); + + return ret; +} + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_hypotfx_u35rvvm1(vfloat_rvvm1_sleef x, vfloat_rvvm1_sleef y) { + x = vabs_vf_vf_rvvm1_sleef(x); + y = vabs_vf_vf_rvvm1_sleef(y); + vfloat_rvvm1_sleef min = vmin_vf_vf_vf_rvvm1_sleef(x, y); + vfloat_rvvm1_sleef max = vmax_vf_vf_vf_rvvm1_sleef(x, y); + + vfloat_rvvm1_sleef t = vdiv_vf_vf_vf_rvvm1_sleef(min, max); + vfloat_rvvm1_sleef ret = vmul_vf_vf_vf_rvvm1_sleef(max, vsqrt_vf_vf_rvvm1_sleef(vmla_vf_vf_vf_vf_rvvm1_sleef(t, t, vcast_vf_f_rvvm1_sleef(1)))); + ret = vsel_vf_vo_vf_vf_rvvm1_sleef(veq_vo_vf_vf_rvvm1_sleef(min, vcast_vf_f_rvvm1_sleef(0)), max, ret); + ret = vsel_vf_vo_vf_vf_rvvm1_sleef(rvv_sp_vor_vo_vo_vo(visnan_vo_vf_rvvm1_sleef(x), visnan_vo_vf_rvvm1_sleef(y)), vcast_vf_f_rvvm1_sleef(__builtin_nanf("")), ret); + ret = vsel_vf_vo_vf_vf_rvvm1_sleef(rvv_sp_vor_vo_vo_vo(veq_vo_vf_vf_rvvm1_sleef(x, vcast_vf_f_rvvm1_sleef(__builtin_inff())), veq_vo_vf_vf_rvvm1_sleef(y, vcast_vf_f_rvvm1_sleef(__builtin_inff()))), vcast_vf_f_rvvm1_sleef(__builtin_inff()), ret); + + return ret; +} + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_nextafterfx_rvvm1(vfloat_rvvm1_sleef x, vfloat_rvvm1_sleef y) { + x = vsel_vf_vo_vf_vf_rvvm1_sleef(veq_vo_vf_vf_rvvm1_sleef(x, vcast_vf_f_rvvm1_sleef(0)), vmulsign_vf_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(0), y), x); + vint2_rvvm1_sleef xi2 = vreinterpret_vi2_vf_rvvm1_sleef(x); + rvv_sp_vopmask_rvvm1_sleef c = rvv_sp_vxor_vo_vo_vo(vsignbit_vo_vf_rvvm1_sleef(x), vge_vo_vf_vf_rvvm1_sleef(y, x)); + + xi2 = vsel_vi2_vo_vi2_vi2_rvvm1_sleef(c, vsub_vi2_vi2_vi2_rvvm1_sleef(vcast_vi2_i_rvvm1_sleef(0), vxor_vi2_vi2_vi2_rvvm1_sleef(xi2, vcast_vi2_i_rvvm1_sleef((int)(1U << 31)))), xi2); + + xi2 = vsel_vi2_vo_vi2_vi2_rvvm1_sleef(vneq_vo_vf_vf_rvvm1_sleef(x, y), vsub_vi2_vi2_vi2_rvvm1_sleef(xi2, vcast_vi2_i_rvvm1_sleef(1)), xi2); + + xi2 = vsel_vi2_vo_vi2_vi2_rvvm1_sleef(c, vsub_vi2_vi2_vi2_rvvm1_sleef(vcast_vi2_i_rvvm1_sleef(0), vxor_vi2_vi2_vi2_rvvm1_sleef(xi2, vcast_vi2_i_rvvm1_sleef((int)(1U << 31)))), xi2); + + vfloat_rvvm1_sleef ret = vreinterpret_vf_vi2_rvvm1_sleef(xi2); + + ret = vsel_vf_vo_vf_vf_rvvm1_sleef(rvv_sp_vand_vo_vo_vo(veq_vo_vf_vf_rvvm1_sleef(ret, vcast_vf_f_rvvm1_sleef(0)), vneq_vo_vf_vf_rvvm1_sleef(x, vcast_vf_f_rvvm1_sleef(0))), + vmulsign_vf_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(0), x), ret); + + ret = vsel_vf_vo_vf_vf_rvvm1_sleef(rvv_sp_vand_vo_vo_vo(veq_vo_vf_vf_rvvm1_sleef(x, vcast_vf_f_rvvm1_sleef(0)), veq_vo_vf_vf_rvvm1_sleef(y, vcast_vf_f_rvvm1_sleef(0))), y, ret); + + ret = vsel_vf_vo_vf_vf_rvvm1_sleef(rvv_sp_vor_vo_vo_vo(visnan_vo_vf_rvvm1_sleef(x), visnan_vo_vf_rvvm1_sleef(y)), vcast_vf_f_rvvm1_sleef(__builtin_nanf("")), ret); + + return ret; +} + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_frfrexpfx_rvvm1(vfloat_rvvm1_sleef x) { + x = vsel_vf_vo_vf_vf_rvvm1_sleef(vlt_vo_vf_vf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(x), vcast_vf_f_rvvm1_sleef(0x1p-126)), vmul_vf_vf_vf_rvvm1_sleef(x, vcast_vf_f_rvvm1_sleef(UINT64_C(1) << 30)), x); + + vmask_rvvm1_sleef xm = vreinterpret_vm_vf_rvvm1_sleef(x); + xm = vand_vm_vm_vm_rvvm1_sleef(xm, vcast_vm_i_i_rvvm1_sleef(~0x7f800000U, ~0x7f800000U)); + xm = vor_vm_vm_vm_rvvm1_sleef (xm, vcast_vm_i_i_rvvm1_sleef( 0x3f000000U, 0x3f000000U)); + + vfloat_rvvm1_sleef ret = vreinterpret_vf_vm_rvvm1_sleef(xm); + + ret = vsel_vf_vo_vf_vf_rvvm1_sleef(visinf_vo_vf_rvvm1_sleef(x), vmulsign_vf_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(__builtin_inff()), x), ret); + ret = vsel_vf_vo_vf_vf_rvvm1_sleef(veq_vo_vf_vf_rvvm1_sleef(x, vcast_vf_f_rvvm1_sleef(0)), x, ret); + + return ret; +} + +SLEEF_INLINE SLEEF_CONST vint2_rvvm1_sleef Sleef_expfrexpfx_rvvm1(vfloat_rvvm1_sleef x) { + + return vcast_vi2_i_rvvm1_sleef(0); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_rvvm1_sleef vtoward0_vf_vf_rvvm1_sleef(vfloat_rvvm1_sleef x) { + vfloat_rvvm1_sleef t = vreinterpret_vf_vi2_rvvm1_sleef(vsub_vi2_vi2_vi2_rvvm1_sleef(vreinterpret_vi2_vf_rvvm1_sleef(x), vcast_vi2_i_rvvm1_sleef(1))); + return vsel_vf_vo_vf_vf_rvvm1_sleef(veq_vo_vf_vf_rvvm1_sleef(x, vcast_vf_f_rvvm1_sleef(0)), vcast_vf_f_rvvm1_sleef(0), t); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_rvvm1_sleef vptrunc_vf_vf_rvvm1_sleef(vfloat_rvvm1_sleef x) { + + vfloat_rvvm1_sleef fr = vsub_vf_vf_vf_rvvm1_sleef(x, vcast_vf_vi2_rvvm1_sleef(vtruncate_vi2_vf_rvvm1_sleef(x))); + return vsel_vf_vo_vf_vf_rvvm1_sleef(vge_vo_vf_vf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(x), vcast_vf_f_rvvm1_sleef(INT64_C(1) << 23)), x, vsub_vf_vf_vf_rvvm1_sleef(x, fr)); + +} + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_fmodfx_rvvm1(vfloat_rvvm1_sleef x, vfloat_rvvm1_sleef y) { + vfloat_rvvm1_sleef nu = vabs_vf_vf_rvvm1_sleef(x), de = vabs_vf_vf_rvvm1_sleef(y), s = vcast_vf_f_rvvm1_sleef(1), q; + rvv_sp_vopmask_rvvm1_sleef o = vlt_vo_vf_vf_rvvm1_sleef(de, vcast_vf_f_rvvm1_sleef(0x1p-126)); + nu = vsel_vf_vo_vf_vf_rvvm1_sleef(o, vmul_vf_vf_vf_rvvm1_sleef(nu, vcast_vf_f_rvvm1_sleef(UINT64_C(1) << 25)), nu); + de = vsel_vf_vo_vf_vf_rvvm1_sleef(o, vmul_vf_vf_vf_rvvm1_sleef(de, vcast_vf_f_rvvm1_sleef(UINT64_C(1) << 25)), de); + s = vsel_vf_vo_vf_vf_rvvm1_sleef(o, vmul_vf_vf_vf_rvvm1_sleef(s , vcast_vf_f_rvvm1_sleef(1.0f / (UINT64_C(1) << 25))), s); + vfloat_rvvm1_sleef rde = vtoward0_vf_vf_rvvm1_sleef(vrec_vf_vf_rvvm1_sleef(de)); + + vfloat2_rvvm1_sleef r = vcast_vf2_vf_vf_rvvm1_sleef(nu, vcast_vf_f_rvvm1_sleef(0)); + + for(int i=0;i<8;i++) { + q = vptrunc_vf_vf_rvvm1_sleef(vmul_vf_vf_vf_rvvm1_sleef(vtoward0_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(r)), rde)); + q = vsel_vf_vo_vf_vf_rvvm1_sleef(rvv_sp_vand_vo_vo_vo(vgt_vo_vf_vf_rvvm1_sleef(vmul_vf_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(3), de), vf2getx_vf_vf2_rvvm1_sleef(r)), + vge_vo_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(r), de)), + vcast_vf_f_rvvm1_sleef(2), q); + q = vsel_vf_vo_vf_vf_rvvm1_sleef(rvv_sp_vand_vo_vo_vo(vgt_vo_vf_vf_rvvm1_sleef(vmul_vf_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(2), de), vf2getx_vf_vf2_rvvm1_sleef(r)), + vge_vo_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(r), de)), + vcast_vf_f_rvvm1_sleef(1), q); + r = dfnormalize_vf2_vf2_rvvm1_sleef(dfadd2_vf2_vf2_vf2_rvvm1_sleef(r, dfmul_vf2_vf_vf_rvvm1_sleef(vptrunc_vf_vf_rvvm1_sleef(q), vneg_vf_vf_rvvm1_sleef(de)))); + if (vtestallones_i_vo32_rvvm1_sleef(vlt_vo_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(r), de))) break; + } + + vfloat_rvvm1_sleef ret = vmul_vf_vf_vf_rvvm1_sleef(vadd_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(r), vf2gety_vf_vf2_rvvm1_sleef(r)), s); + ret = vsel_vf_vo_vf_vf_rvvm1_sleef(veq_vo_vf_vf_rvvm1_sleef(vadd_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(r), vf2gety_vf_vf2_rvvm1_sleef(r)), de), vcast_vf_f_rvvm1_sleef(0), ret); + + ret = vmulsign_vf_vf_vf_rvvm1_sleef(ret, x); + + ret = vsel_vf_vo_vf_vf_rvvm1_sleef(vlt_vo_vf_vf_rvvm1_sleef(nu, de), x, ret); + ret = vsel_vf_vo_vf_vf_rvvm1_sleef(veq_vo_vf_vf_rvvm1_sleef(de, vcast_vf_f_rvvm1_sleef(0)), vcast_vf_f_rvvm1_sleef(__builtin_nanf("")), ret); + + return ret; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_rvvm1_sleef vrintfk2_vf_vf_rvvm1_sleef(vfloat_rvvm1_sleef d) { + + vfloat_rvvm1_sleef c = vmulsign_vf_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(1 << 23), d); + return vsel_vf_vo_vf_vf_rvvm1_sleef(vgt_vo_vf_vf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(d), vcast_vf_f_rvvm1_sleef(1 << 23)), + d, vorsign_vf_vf_vf_rvvm1_sleef(vsub_vf_vf_vf_rvvm1_sleef(vadd_vf_vf_vf_rvvm1_sleef(d, c), c), d)); + +} + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_remainderfx_rvvm1(vfloat_rvvm1_sleef x, vfloat_rvvm1_sleef y) { + vfloat_rvvm1_sleef n = vabs_vf_vf_rvvm1_sleef(x), d = vabs_vf_vf_rvvm1_sleef(y), s = vcast_vf_f_rvvm1_sleef(1), q; + rvv_sp_vopmask_rvvm1_sleef o = vlt_vo_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(0x1p-126*2)); + n = vsel_vf_vo_vf_vf_rvvm1_sleef(o, vmul_vf_vf_vf_rvvm1_sleef(n, vcast_vf_f_rvvm1_sleef(UINT64_C(1) << 25)), n); + d = vsel_vf_vo_vf_vf_rvvm1_sleef(o, vmul_vf_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(UINT64_C(1) << 25)), d); + s = vsel_vf_vo_vf_vf_rvvm1_sleef(o, vmul_vf_vf_vf_rvvm1_sleef(s , vcast_vf_f_rvvm1_sleef(1.0f / (UINT64_C(1) << 25))), s); + vfloat2_rvvm1_sleef r = vcast_vf2_vf_vf_rvvm1_sleef(n, vcast_vf_f_rvvm1_sleef(0)); + vfloat_rvvm1_sleef rd = vrec_vf_vf_rvvm1_sleef(d); + rvv_sp_vopmask_rvvm1_sleef qisodd = vneq_vo_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(0), vcast_vf_f_rvvm1_sleef(0)); + + for(int i=0;i<8;i++) { + q = vrintfk2_vf_vf_rvvm1_sleef(vmul_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(r), rd)); + q = vsel_vf_vo_vf_vf_rvvm1_sleef(vlt_vo_vf_vf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(r)), vmul_vf_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(1.5f))), vmulsign_vf_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(1.0f), vf2getx_vf_vf2_rvvm1_sleef(r)), q); + q = vsel_vf_vo_vf_vf_rvvm1_sleef(rvv_sp_vor_vo_vo_vo(vlt_vo_vf_vf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(r)), vmul_vf_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(0.5f))), + rvv_sp_vandnot_vo_vo_vo(qisodd, veq_vo_vf_vf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(r)), vmul_vf_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(0.5f))))), + vcast_vf_f_rvvm1_sleef(0.0), q); + if (vtestallones_i_vo32_rvvm1_sleef(veq_vo_vf_vf_rvvm1_sleef(q, vcast_vf_f_rvvm1_sleef(0)))) break; + q = vsel_vf_vo_vf_vf_rvvm1_sleef(visinf_vo_vf_rvvm1_sleef(vmul_vf_vf_vf_rvvm1_sleef(q, vneg_vf_vf_rvvm1_sleef(d))), vadd_vf_vf_vf_rvvm1_sleef(q, vmulsign_vf_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(-1), vf2getx_vf_vf2_rvvm1_sleef(r))), q); + qisodd = rvv_sp_vxor_vo_vo_vo(qisodd, rvv_sp_vand_vo_vo_vo(veq_vo_vi2_vi2_rvvm1_sleef(vand_vi2_vi2_vi2_rvvm1_sleef(vtruncate_vi2_vf_rvvm1_sleef(q), vcast_vi2_i_rvvm1_sleef(1)), vcast_vi2_i_rvvm1_sleef(1)), + vlt_vo_vf_vf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(q), vcast_vf_f_rvvm1_sleef(1 << 24)))); + r = dfnormalize_vf2_vf2_rvvm1_sleef(dfadd2_vf2_vf2_vf2_rvvm1_sleef(r, dfmul_vf2_vf_vf_rvvm1_sleef(q, vneg_vf_vf_rvvm1_sleef(d)))); + } + + vfloat_rvvm1_sleef ret = vmul_vf_vf_vf_rvvm1_sleef(vadd_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(r), vf2gety_vf_vf2_rvvm1_sleef(r)), s); + ret = vmulsign_vf_vf_vf_rvvm1_sleef(ret, x); + ret = vsel_vf_vo_vf_vf_rvvm1_sleef(visinf_vo_vf_rvvm1_sleef(y), vsel_vf_vo_vf_vf_rvvm1_sleef(visinf_vo_vf_rvvm1_sleef(x), vcast_vf_f_rvvm1_sleef(__builtin_nanf("")), x), ret); + ret = vsel_vf_vo_vf_vf_rvvm1_sleef(veq_vo_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(0)), vcast_vf_f_rvvm1_sleef(__builtin_nanf("")), ret); + return ret; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_rvvm1_sleef sinpifk_rvvm1_sleef(vfloat_rvvm1_sleef d) { + rvv_sp_vopmask_rvvm1_sleef o; + vfloat_rvvm1_sleef u, s, t; + vfloat2_rvvm1_sleef x, s2; + + u = vmul_vf_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(4.0)); + vint2_rvvm1_sleef q = vtruncate_vi2_vf_rvvm1_sleef(u); + q = vand_vi2_vi2_vi2_rvvm1_sleef(vadd_vi2_vi2_vi2_rvvm1_sleef(q, vxor_vi2_vi2_vi2_rvvm1_sleef(vsrl_vi2_vi2_i_rvvm1_sleef(q, 31), vcast_vi2_i_rvvm1_sleef(1))), vcast_vi2_i_rvvm1_sleef(~1)); + o = veq_vo_vi2_vi2_rvvm1_sleef(vand_vi2_vi2_vi2_rvvm1_sleef(q, vcast_vi2_i_rvvm1_sleef(2)), vcast_vi2_i_rvvm1_sleef(2)); + + s = vsub_vf_vf_vf_rvvm1_sleef(u, vcast_vf_vi2_rvvm1_sleef(q)); + t = s; + s = vmul_vf_vf_vf_rvvm1_sleef(s, s); + s2 = dfmul_vf2_vf_vf_rvvm1_sleef(t, t); + + u = vsel_vf_vo_f_f_rvvm1_sleef(o, -0.2430611801e-7f, +0.3093842054e-6f); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, s, vsel_vf_vo_f_f_rvvm1_sleef(o, +0.3590577080e-5f, -0.3657307388e-4f)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, s, vsel_vf_vo_f_f_rvvm1_sleef(o, -0.3259917721e-3f, +0.2490393585e-2f)); + x = dfadd2_vf2_vf_vf2_rvvm1_sleef(vmul_vf_vf_vf_rvvm1_sleef(u, s), + vsel_vf2_vo_f_f_f_f_rvvm1_sleef(o, 0.015854343771934509277, 4.4940051354032242811e-10, + -0.080745510756969451904, -1.3373665339076936258e-09)); + x = dfadd2_vf2_vf2_vf2_rvvm1_sleef(dfmul_vf2_vf2_vf2_rvvm1_sleef(s2, x), + vsel_vf2_vo_f_f_f_f_rvvm1_sleef(o, -0.30842512845993041992, -9.0728339030733922277e-09, + 0.78539818525314331055, -2.1857338617566484855e-08)); + + x = dfmul_vf2_vf2_vf2_rvvm1_sleef(x, vsel_vf2_vo_vf2_vf2_rvvm1_sleef(o, s2, vcast_vf2_vf_vf_rvvm1_sleef(t, vcast_vf_f_rvvm1_sleef(0)))); + x = vsel_vf2_vo_vf2_vf2_rvvm1_sleef(o, dfadd2_vf2_vf2_vf_rvvm1_sleef(x, vcast_vf_f_rvvm1_sleef(1)), x); + + o = veq_vo_vi2_vi2_rvvm1_sleef(vand_vi2_vi2_vi2_rvvm1_sleef(q, vcast_vi2_i_rvvm1_sleef(4)), vcast_vi2_i_rvvm1_sleef(4)); + x = vf2setx_vf2_vf2_vf_rvvm1_sleef(x, vreinterpret_vf_vm_rvvm1_sleef(vxor_vm_vm_vm_rvvm1_sleef(vand_vm_vo32_vm_rvvm1_sleef(o, vreinterpret_vm_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(-0.0))), vreinterpret_vm_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(x))))); + x = vf2sety_vf2_vf2_vf_rvvm1_sleef(x, vreinterpret_vf_vm_rvvm1_sleef(vxor_vm_vm_vm_rvvm1_sleef(vand_vm_vo32_vm_rvvm1_sleef(o, vreinterpret_vm_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(-0.0))), vreinterpret_vm_vf_rvvm1_sleef(vf2gety_vf_vf2_rvvm1_sleef(x))))); + + return x; +} + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_sinpifx_u05rvvm1(vfloat_rvvm1_sleef d) { + vfloat2_rvvm1_sleef x = sinpifk_rvvm1_sleef(d); + vfloat_rvvm1_sleef r = vadd_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(x), vf2gety_vf_vf2_rvvm1_sleef(x)); + + r = vsel_vf_vo_vf_vf_rvvm1_sleef(visnegzero_vo_vf_rvvm1_sleef(d), vcast_vf_f_rvvm1_sleef(-0.0), r); + r = vreinterpret_vf_vm_rvvm1_sleef(vandnot_vm_vo32_vm_rvvm1_sleef(vgt_vo_vf_vf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(d), vcast_vf_f_rvvm1_sleef(8e+6f)), vreinterpret_vm_vf_rvvm1_sleef(r))); + r = vreinterpret_vf_vm_rvvm1_sleef(vor_vm_vo32_vm_rvvm1_sleef(visinf_vo_vf_rvvm1_sleef(d), vreinterpret_vm_vf_rvvm1_sleef(r))); + + return r; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_rvvm1_sleef cospifk_rvvm1_sleef(vfloat_rvvm1_sleef d) { + rvv_sp_vopmask_rvvm1_sleef o; + vfloat_rvvm1_sleef u, s, t; + vfloat2_rvvm1_sleef x, s2; + + u = vmul_vf_vf_vf_rvvm1_sleef(d, vcast_vf_f_rvvm1_sleef(4.0)); + vint2_rvvm1_sleef q = vtruncate_vi2_vf_rvvm1_sleef(u); + q = vand_vi2_vi2_vi2_rvvm1_sleef(vadd_vi2_vi2_vi2_rvvm1_sleef(q, vxor_vi2_vi2_vi2_rvvm1_sleef(vsrl_vi2_vi2_i_rvvm1_sleef(q, 31), vcast_vi2_i_rvvm1_sleef(1))), vcast_vi2_i_rvvm1_sleef(~1)); + o = veq_vo_vi2_vi2_rvvm1_sleef(vand_vi2_vi2_vi2_rvvm1_sleef(q, vcast_vi2_i_rvvm1_sleef(2)), vcast_vi2_i_rvvm1_sleef(0)); + + s = vsub_vf_vf_vf_rvvm1_sleef(u, vcast_vf_vi2_rvvm1_sleef(q)); + t = s; + s = vmul_vf_vf_vf_rvvm1_sleef(s, s); + s2 = dfmul_vf2_vf_vf_rvvm1_sleef(t, t); + + u = vsel_vf_vo_f_f_rvvm1_sleef(o, -0.2430611801e-7f, +0.3093842054e-6f); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, s, vsel_vf_vo_f_f_rvvm1_sleef(o, +0.3590577080e-5f, -0.3657307388e-4f)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, s, vsel_vf_vo_f_f_rvvm1_sleef(o, -0.3259917721e-3f, +0.2490393585e-2f)); + x = dfadd2_vf2_vf_vf2_rvvm1_sleef(vmul_vf_vf_vf_rvvm1_sleef(u, s), + vsel_vf2_vo_f_f_f_f_rvvm1_sleef(o, 0.015854343771934509277, 4.4940051354032242811e-10, + -0.080745510756969451904, -1.3373665339076936258e-09)); + x = dfadd2_vf2_vf2_vf2_rvvm1_sleef(dfmul_vf2_vf2_vf2_rvvm1_sleef(s2, x), + vsel_vf2_vo_f_f_f_f_rvvm1_sleef(o, -0.30842512845993041992, -9.0728339030733922277e-09, + 0.78539818525314331055, -2.1857338617566484855e-08)); + + x = dfmul_vf2_vf2_vf2_rvvm1_sleef(x, vsel_vf2_vo_vf2_vf2_rvvm1_sleef(o, s2, vcast_vf2_vf_vf_rvvm1_sleef(t, vcast_vf_f_rvvm1_sleef(0)))); + x = vsel_vf2_vo_vf2_vf2_rvvm1_sleef(o, dfadd2_vf2_vf2_vf_rvvm1_sleef(x, vcast_vf_f_rvvm1_sleef(1)), x); + + o = veq_vo_vi2_vi2_rvvm1_sleef(vand_vi2_vi2_vi2_rvvm1_sleef(vadd_vi2_vi2_vi2_rvvm1_sleef(q, vcast_vi2_i_rvvm1_sleef(2)), vcast_vi2_i_rvvm1_sleef(4)), vcast_vi2_i_rvvm1_sleef(4)); + x = vf2setx_vf2_vf2_vf_rvvm1_sleef(x, vreinterpret_vf_vm_rvvm1_sleef(vxor_vm_vm_vm_rvvm1_sleef(vand_vm_vo32_vm_rvvm1_sleef(o, vreinterpret_vm_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(-0.0))), vreinterpret_vm_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(x))))); + x = vf2sety_vf2_vf2_vf_rvvm1_sleef(x, vreinterpret_vf_vm_rvvm1_sleef(vxor_vm_vm_vm_rvvm1_sleef(vand_vm_vo32_vm_rvvm1_sleef(o, vreinterpret_vm_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(-0.0))), vreinterpret_vm_vf_rvvm1_sleef(vf2gety_vf_vf2_rvvm1_sleef(x))))); + + return x; +} + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_cospifx_u05rvvm1(vfloat_rvvm1_sleef d) { + vfloat2_rvvm1_sleef x = cospifk_rvvm1_sleef(d); + vfloat_rvvm1_sleef r = vadd_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(x), vf2gety_vf_vf2_rvvm1_sleef(x)); + + r = vsel_vf_vo_vf_vf_rvvm1_sleef(vgt_vo_vf_vf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(d), vcast_vf_f_rvvm1_sleef(8e+6f)), vcast_vf_f_rvvm1_sleef(1), r); + r = vreinterpret_vf_vm_rvvm1_sleef(vor_vm_vo32_vm_rvvm1_sleef(visinf_vo_vf_rvvm1_sleef(d), vreinterpret_vm_vf_rvvm1_sleef(r))); + + return r; +} + +static SLEEF_CONST df2_rvvm1_sleef gammafk_rvvm1_sleef(vfloat_rvvm1_sleef a) { + vfloat2_rvvm1_sleef clc = vcast_vf2_f_f_rvvm1_sleef(0, 0), clln = vcast_vf2_f_f_rvvm1_sleef(1, 0), clld = vcast_vf2_f_f_rvvm1_sleef(1, 0); + vfloat2_rvvm1_sleef x, y, z; + vfloat_rvvm1_sleef t, u; + + rvv_sp_vopmask_rvvm1_sleef otiny = vlt_vo_vf_vf_rvvm1_sleef(vabs_vf_vf_rvvm1_sleef(a), vcast_vf_f_rvvm1_sleef(1e-30f)), oref = vlt_vo_vf_vf_rvvm1_sleef(a, vcast_vf_f_rvvm1_sleef(0.5)); + + x = vsel_vf2_vo_vf2_vf2_rvvm1_sleef(otiny, vcast_vf2_f_f_rvvm1_sleef(0, 0), + vsel_vf2_vo_vf2_vf2_rvvm1_sleef(oref, dfadd2_vf2_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(1), vneg_vf_vf_rvvm1_sleef(a)), + vcast_vf2_vf_vf_rvvm1_sleef(a, vcast_vf_f_rvvm1_sleef(0)))); + + rvv_sp_vopmask_rvvm1_sleef o0 = rvv_sp_vand_vo_vo_vo(vle_vo_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(0.5), vf2getx_vf_vf2_rvvm1_sleef(x)), vle_vo_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(x), vcast_vf_f_rvvm1_sleef(1.2))); + rvv_sp_vopmask_rvvm1_sleef o2 = vle_vo_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(2.3), vf2getx_vf_vf2_rvvm1_sleef(x)); + + y = dfnormalize_vf2_vf2_rvvm1_sleef(dfmul_vf2_vf2_vf2_rvvm1_sleef(dfadd2_vf2_vf2_vf_rvvm1_sleef(x, vcast_vf_f_rvvm1_sleef(1)), x)); + y = dfnormalize_vf2_vf2_rvvm1_sleef(dfmul_vf2_vf2_vf2_rvvm1_sleef(dfadd2_vf2_vf2_vf_rvvm1_sleef(x, vcast_vf_f_rvvm1_sleef(2)), y)); + + rvv_sp_vopmask_rvvm1_sleef o = rvv_sp_vand_vo_vo_vo(o2, vle_vo_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(x), vcast_vf_f_rvvm1_sleef(7))); + clln = vsel_vf2_vo_vf2_vf2_rvvm1_sleef(o, y, clln); + + x = vsel_vf2_vo_vf2_vf2_rvvm1_sleef(o, dfadd2_vf2_vf2_vf_rvvm1_sleef(x, vcast_vf_f_rvvm1_sleef(3)), x); + t = vsel_vf_vo_vf_vf_rvvm1_sleef(o2, vrec_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(x)), vf2getx_vf_vf2_rvvm1_sleef(dfnormalize_vf2_vf2_rvvm1_sleef(dfadd2_vf2_vf2_vf_rvvm1_sleef(x, vsel_vf_vo_f_f_rvvm1_sleef(o0, -1, -2))))); + + u = vsel_vf_vo_vo_f_f_f_rvvm1_sleef(o2, o0, +0.000839498720672087279971000786, +0.9435157776e+0f, +0.1102489550e-3f); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, t, vsel_vf_vo_vo_f_f_f_rvvm1_sleef(o2, o0, -5.17179090826059219329394422e-05, +0.8670063615e+0f, +0.8160019934e-4f)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, t, vsel_vf_vo_vo_f_f_f_rvvm1_sleef(o2, o0, -0.000592166437353693882857342347, +0.4826702476e+0f, +0.1528468856e-3f)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, t, vsel_vf_vo_vo_f_f_f_rvvm1_sleef(o2, o0, +6.97281375836585777403743539e-05, -0.8855129778e-1f, -0.2355068718e-3f)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, t, vsel_vf_vo_vo_f_f_f_rvvm1_sleef(o2, o0, +0.000784039221720066627493314301, +0.1013825238e+0f, +0.4962242092e-3f)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, t, vsel_vf_vo_vo_f_f_f_rvvm1_sleef(o2, o0, -0.000229472093621399176949318732, -0.1493408978e+0f, -0.1193488017e-2f)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, t, vsel_vf_vo_vo_f_f_f_rvvm1_sleef(o2, o0, -0.002681327160493827160473958490, +0.1697509140e+0f, +0.2891599433e-2f)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, t, vsel_vf_vo_vo_f_f_f_rvvm1_sleef(o2, o0, +0.003472222222222222222175164840, -0.2072454542e+0f, -0.7385451812e-2f)); + u = vmla_vf_vf_vf_vf_rvvm1_sleef(u, t, vsel_vf_vo_vo_f_f_f_rvvm1_sleef(o2, o0, +0.083333333333333333335592087900, +0.2705872357e+0f, +0.2058077045e-1f)); + + y = dfmul_vf2_vf2_vf2_rvvm1_sleef(dfadd2_vf2_vf2_vf_rvvm1_sleef(x, vcast_vf_f_rvvm1_sleef(-0.5)), logk2f_rvvm1_sleef(x)); + y = dfadd2_vf2_vf2_vf2_rvvm1_sleef(y, dfneg_vf2_vf2_rvvm1_sleef(x)); + y = dfadd2_vf2_vf2_vf2_rvvm1_sleef(y, vcast_vf2_d_rvvm1_sleef(0.91893853320467278056)); + + z = dfadd2_vf2_vf2_vf_rvvm1_sleef(dfmul_vf2_vf_vf_rvvm1_sleef (u, t), vsel_vf_vo_f_f_rvvm1_sleef(o0, -0.400686534596170958447352690395e+0f, -0.673523028297382446749257758235e-1f)); + z = dfadd2_vf2_vf2_vf_rvvm1_sleef(dfmul_vf2_vf2_vf_rvvm1_sleef(z, t), vsel_vf_vo_f_f_rvvm1_sleef(o0, +0.822466960142643054450325495997e+0f, +0.322467033928981157743538726901e+0f)); + z = dfadd2_vf2_vf2_vf_rvvm1_sleef(dfmul_vf2_vf2_vf_rvvm1_sleef(z, t), vsel_vf_vo_f_f_rvvm1_sleef(o0, -0.577215665946766039837398973297e+0f, +0.422784335087484338986941629852e+0f)); + z = dfmul_vf2_vf2_vf_rvvm1_sleef(z, t); + + clc = vsel_vf2_vo_vf2_vf2_rvvm1_sleef(o2, y, z); + + clld = vsel_vf2_vo_vf2_vf2_rvvm1_sleef(o2, dfadd2_vf2_vf2_vf_rvvm1_sleef(dfmul_vf2_vf_vf_rvvm1_sleef(u, t), vcast_vf_f_rvvm1_sleef(1)), clld); + + y = clln; + + clc = vsel_vf2_vo_vf2_vf2_rvvm1_sleef(otiny, vcast_vf2_d_rvvm1_sleef(41.58883083359671856503), + vsel_vf2_vo_vf2_vf2_rvvm1_sleef(oref, dfadd2_vf2_vf2_vf2_rvvm1_sleef(vcast_vf2_d_rvvm1_sleef(1.1447298858494001639), dfneg_vf2_vf2_rvvm1_sleef(clc)), clc)); + clln = vsel_vf2_vo_vf2_vf2_rvvm1_sleef(otiny, vcast_vf2_f_f_rvvm1_sleef(1, 0), vsel_vf2_vo_vf2_vf2_rvvm1_sleef(oref, clln, clld)); + + if (!vtestallones_i_vo32_rvvm1_sleef(vnot_vo32_vo32_rvvm1_sleef(oref))) { + t = vsub_vf_vf_vf_rvvm1_sleef(a, vmul_vf_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(INT64_C(1) << 12), vcast_vf_vi2_rvvm1_sleef(vtruncate_vi2_vf_rvvm1_sleef(vmul_vf_vf_vf_rvvm1_sleef(a, vcast_vf_f_rvvm1_sleef(1.0 / (INT64_C(1) << 12))))))); + x = dfmul_vf2_vf2_vf2_rvvm1_sleef(clld, sinpifk_rvvm1_sleef(t)); + } + + clld = vsel_vf2_vo_vf2_vf2_rvvm1_sleef(otiny, vcast_vf2_vf_vf_rvvm1_sleef(vmul_vf_vf_vf_rvvm1_sleef(a, vcast_vf_f_rvvm1_sleef((INT64_C(1) << 30)*(float)(INT64_C(1) << 30))), vcast_vf_f_rvvm1_sleef(0)), + vsel_vf2_vo_vf2_vf2_rvvm1_sleef(oref, x, y)); + + return df2setab_df2_vf2_vf2_rvvm1_sleef(clc, dfdiv_vf2_vf2_vf2_rvvm1_sleef(clln, clld)); +} + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_tgammafx_u10rvvm1(vfloat_rvvm1_sleef a) { + df2_rvvm1_sleef d = gammafk_rvvm1_sleef(a); + vfloat2_rvvm1_sleef y = dfmul_vf2_vf2_vf2_rvvm1_sleef(expk2f_rvvm1_sleef(df2geta_vf2_df2_rvvm1_sleef(d)), df2getb_vf2_df2_rvvm1_sleef(d)); + vfloat_rvvm1_sleef r = vadd_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(y), vf2gety_vf_vf2_rvvm1_sleef(y)); + rvv_sp_vopmask_rvvm1_sleef o; + + o = rvv_sp_vor_vo_vo_vo(rvv_sp_vor_vo_vo_vo(veq_vo_vf_vf_rvvm1_sleef(a, vcast_vf_f_rvvm1_sleef(-__builtin_inff())), + rvv_sp_vand_vo_vo_vo(vlt_vo_vf_vf_rvvm1_sleef(a, vcast_vf_f_rvvm1_sleef(0)), visint_vo_vf_rvvm1_sleef(a))), + rvv_sp_vand_vo_vo_vo(rvv_sp_vand_vo_vo_vo(visnumber_vo_vf_rvvm1_sleef(a), vlt_vo_vf_vf_rvvm1_sleef(a, vcast_vf_f_rvvm1_sleef(0))), visnan_vo_vf_rvvm1_sleef(r))); + r = vsel_vf_vo_vf_vf_rvvm1_sleef(o, vcast_vf_f_rvvm1_sleef(__builtin_nanf("")), r); + + o = rvv_sp_vand_vo_vo_vo(rvv_sp_vand_vo_vo_vo(rvv_sp_vor_vo_vo_vo(veq_vo_vf_vf_rvvm1_sleef(a, vcast_vf_f_rvvm1_sleef(__builtin_inff())), visnumber_vo_vf_rvvm1_sleef(a)), + vge_vo_vf_vf_rvvm1_sleef(a, vcast_vf_f_rvvm1_sleef(-0x1p-126))), + rvv_sp_vor_vo_vo_vo(rvv_sp_vor_vo_vo_vo(veq_vo_vf_vf_rvvm1_sleef(a, vcast_vf_f_rvvm1_sleef(0)), vgt_vo_vf_vf_rvvm1_sleef(a, vcast_vf_f_rvvm1_sleef(36))), visnan_vo_vf_rvvm1_sleef(r))); + r = vsel_vf_vo_vf_vf_rvvm1_sleef(o, vmulsign_vf_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(__builtin_inff()), a), r); + + return r; +} + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_lgammafx_u10rvvm1(vfloat_rvvm1_sleef a) { + df2_rvvm1_sleef d = gammafk_rvvm1_sleef(a); + vfloat2_rvvm1_sleef y = dfadd2_vf2_vf2_vf2_rvvm1_sleef(df2geta_vf2_df2_rvvm1_sleef(d), logk2f_rvvm1_sleef(dfabs_vf2_vf2_rvvm1_sleef(df2getb_vf2_df2_rvvm1_sleef(d)))); + vfloat_rvvm1_sleef r = vadd_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(y), vf2gety_vf_vf2_rvvm1_sleef(y)); + rvv_sp_vopmask_rvvm1_sleef o; + + o = rvv_sp_vor_vo_vo_vo(visinf_vo_vf_rvvm1_sleef(a), + rvv_sp_vor_vo_vo_vo(rvv_sp_vand_vo_vo_vo(vle_vo_vf_vf_rvvm1_sleef(a, vcast_vf_f_rvvm1_sleef(0)), visint_vo_vf_rvvm1_sleef(a)), + rvv_sp_vand_vo_vo_vo(visnumber_vo_vf_rvvm1_sleef(a), visnan_vo_vf_rvvm1_sleef(r)))); + r = vsel_vf_vo_vf_vf_rvvm1_sleef(o, vcast_vf_f_rvvm1_sleef(__builtin_inff()), r); + + return r; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_rvvm1_sleef dfmla_vf2_vf_vf2_vf2_rvvm1_sleef(vfloat_rvvm1_sleef x, vfloat2_rvvm1_sleef y, vfloat2_rvvm1_sleef z) { + return dfadd_vf2_vf2_vf2_rvvm1_sleef(z, dfmul_vf2_vf2_vf_rvvm1_sleef(y, x)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_rvvm1_sleef poly2df_b_rvvm1_sleef(vfloat_rvvm1_sleef x, vfloat2_rvvm1_sleef c1, vfloat2_rvvm1_sleef c0) { return dfmla_vf2_vf_vf2_vf2_rvvm1_sleef(x, c1, c0); } +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_rvvm1_sleef poly2df_rvvm1_sleef(vfloat_rvvm1_sleef x, vfloat_rvvm1_sleef c1, vfloat2_rvvm1_sleef c0) { return dfmla_vf2_vf_vf2_vf2_rvvm1_sleef(x, vcast_vf2_vf_vf_rvvm1_sleef(c1, vcast_vf_f_rvvm1_sleef(0)), c0); } +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_rvvm1_sleef poly4df_rvvm1_sleef(vfloat_rvvm1_sleef x, vfloat_rvvm1_sleef c3, vfloat2_rvvm1_sleef c2, vfloat2_rvvm1_sleef c1, vfloat2_rvvm1_sleef c0) { + return dfmla_vf2_vf_vf2_vf2_rvvm1_sleef(vmul_vf_vf_vf_rvvm1_sleef(x, x), poly2df_rvvm1_sleef(x, c3, c2), poly2df_b_rvvm1_sleef(x, c1, c0)); +} + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_erffx_u10rvvm1(vfloat_rvvm1_sleef a) { + vfloat_rvvm1_sleef t, x = vabs_vf_vf_rvvm1_sleef(a); + vfloat2_rvvm1_sleef t2; + vfloat_rvvm1_sleef x2 = vmul_vf_vf_vf_rvvm1_sleef(x, x), x4 = vmul_vf_vf_vf_rvvm1_sleef(x2, x2); + rvv_sp_vopmask_rvvm1_sleef o25 = vle_vo_vf_vf_rvvm1_sleef(x, vcast_vf_f_rvvm1_sleef(2.5)); + + if (__builtin_expect(!!(vtestallones_i_vo32_rvvm1_sleef(o25)), 1)) { + + t = vmla_vf_vf_vf_vf_rvvm1_sleef((x4), (vmla_vf_vf_vf_vf_rvvm1_sleef((x), (vcast_vf_f_rvvm1_sleef(-0.4360447008e-6)), (vcast_vf_f_rvvm1_sleef(+0.6867515367e-5)))), (vmla_vf_vf_vf_vf_rvvm1_sleef((x2), (vmla_vf_vf_vf_vf_rvvm1_sleef((x), (vcast_vf_f_rvvm1_sleef(-0.3045156700e-4)), (vcast_vf_f_rvvm1_sleef(+0.9808536561e-4)))), (vmla_vf_vf_vf_vf_rvvm1_sleef((x), (vcast_vf_f_rvvm1_sleef(+0.2395523916e-3)), (vcast_vf_f_rvvm1_sleef(+0.1459901541e-3))))))) + + ; + t2 = poly4df_rvvm1_sleef(x, t, + vcast_vf2_f_f_rvvm1_sleef(0.0092883445322513580322, -2.7863745897025330755e-11), + vcast_vf2_f_f_rvvm1_sleef(0.042275499552488327026, 1.3461399289988106057e-09), + vcast_vf2_f_f_rvvm1_sleef(0.070523701608180999756, -3.6616309318707365163e-09)); + t2 = dfadd_vf2_vf_vf2_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(1), dfmul_vf2_vf2_vf_rvvm1_sleef(t2, x)); + t2 = dfsqu_vf2_vf2_rvvm1_sleef(t2); + t2 = dfsqu_vf2_vf2_rvvm1_sleef(t2); + t2 = dfsqu_vf2_vf2_rvvm1_sleef(t2); + t2 = dfsqu_vf2_vf2_rvvm1_sleef(t2); + t2 = dfrec_vf2_vf2_rvvm1_sleef(t2); + } else { + + t = vmla_vf_vf_vf_vf_rvvm1_sleef((x4), (vmla_vf_vf_vf_vf_rvvm1_sleef((x), ((vsel_vf_vo_f_f_rvvm1_sleef(o25, -0.4360447008e-6, -0.1130012848e-6))), ((vsel_vf_vo_f_f_rvvm1_sleef(o25, +0.6867515367e-5, +0.4115272986e-5))))), (vmla_vf_vf_vf_vf_rvvm1_sleef((x2), (vmla_vf_vf_vf_vf_rvvm1_sleef((x), ((vsel_vf_vo_f_f_rvvm1_sleef(o25, -0.3045156700e-4, -0.6928304356e-4))), ((vsel_vf_vo_f_f_rvvm1_sleef(o25, +0.9808536561e-4, +0.7172692567e-3))))), (vmla_vf_vf_vf_vf_rvvm1_sleef((x), ((vsel_vf_vo_f_f_rvvm1_sleef(o25, +0.2395523916e-3, -0.5131045356e-2))), ((vsel_vf_vo_f_f_rvvm1_sleef(o25, +0.1459901541e-3, +0.2708637156e-1)))))))) + + ; + t2 = poly4df_rvvm1_sleef(x, t, + vsel_vf2_vo_vf2_vf2_rvvm1_sleef(o25, vcast_vf2_f_f_rvvm1_sleef(0.0092883445322513580322, -2.7863745897025330755e-11), + vcast_vf2_f_f_rvvm1_sleef(-0.11064319312572479248, 3.7050452777225283007e-09)), + vsel_vf2_vo_vf2_vf2_rvvm1_sleef(o25, vcast_vf2_f_f_rvvm1_sleef(0.042275499552488327026, 1.3461399289988106057e-09), + vcast_vf2_f_f_rvvm1_sleef(-0.63192230463027954102, -2.0200432585073177859e-08)), + vsel_vf2_vo_vf2_vf2_rvvm1_sleef(o25, vcast_vf2_f_f_rvvm1_sleef(0.070523701608180999756, -3.6616309318707365163e-09), + vcast_vf2_f_f_rvvm1_sleef(-1.1296638250350952148, 2.5515120196453259252e-08))); + t2 = dfmul_vf2_vf2_vf_rvvm1_sleef(t2, x); + vfloat2_rvvm1_sleef s2 = dfadd_vf2_vf_vf2_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(1), t2); + s2 = dfsqu_vf2_vf2_rvvm1_sleef(s2); + s2 = dfsqu_vf2_vf2_rvvm1_sleef(s2); + s2 = dfsqu_vf2_vf2_rvvm1_sleef(s2); + s2 = dfsqu_vf2_vf2_rvvm1_sleef(s2); + s2 = dfrec_vf2_vf2_rvvm1_sleef(s2); + t2 = vsel_vf2_vo_vf2_vf2_rvvm1_sleef(o25, s2, vcast_vf2_vf_vf_rvvm1_sleef(expkf_rvvm1_sleef(t2), vcast_vf_f_rvvm1_sleef(0))); + } + + t2 = dfadd2_vf2_vf2_vf_rvvm1_sleef(t2, vcast_vf_f_rvvm1_sleef(-1)); + t2 = vsel_vf2_vo_vf2_vf2_rvvm1_sleef(vlt_vo_vf_vf_rvvm1_sleef(x, vcast_vf_f_rvvm1_sleef(1e-4)), dfmul_vf2_vf2_vf_rvvm1_sleef(vcast_vf2_f_f_rvvm1_sleef(-1.1283792257308959961, 5.8635383422197591097e-08), x), t2); + + vfloat_rvvm1_sleef z = vneg_vf_vf_rvvm1_sleef(vadd_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(t2), vf2gety_vf_vf2_rvvm1_sleef(t2))); + z = vsel_vf_vo_vf_vf_rvvm1_sleef(vge_vo_vf_vf_rvvm1_sleef(x, vcast_vf_f_rvvm1_sleef(6)), vcast_vf_f_rvvm1_sleef(1), z); + z = vsel_vf_vo_vf_vf_rvvm1_sleef(visinf_vo_vf_rvvm1_sleef(a), vcast_vf_f_rvvm1_sleef(1), z); + z = vsel_vf_vo_vf_vf_rvvm1_sleef(veq_vo_vf_vf_rvvm1_sleef(a, vcast_vf_f_rvvm1_sleef(0)), vcast_vf_f_rvvm1_sleef(0), z); + z = vmulsign_vf_vf_vf_rvvm1_sleef(z, a); + + return z; +} + +SLEEF_INLINE SLEEF_CONST vfloat_rvvm1_sleef Sleef_erfcfx_u15rvvm1(vfloat_rvvm1_sleef a) { + vfloat_rvvm1_sleef s = a, r = vcast_vf_f_rvvm1_sleef(0), t; + vfloat2_rvvm1_sleef u, d, x; + a = vabs_vf_vf_rvvm1_sleef(a); + rvv_sp_vopmask_rvvm1_sleef o0 = vlt_vo_vf_vf_rvvm1_sleef(a, vcast_vf_f_rvvm1_sleef(1.0)); + rvv_sp_vopmask_rvvm1_sleef o1 = vlt_vo_vf_vf_rvvm1_sleef(a, vcast_vf_f_rvvm1_sleef(2.2)); + rvv_sp_vopmask_rvvm1_sleef o2 = vlt_vo_vf_vf_rvvm1_sleef(a, vcast_vf_f_rvvm1_sleef(4.3)); + rvv_sp_vopmask_rvvm1_sleef o3 = vlt_vo_vf_vf_rvvm1_sleef(a, vcast_vf_f_rvvm1_sleef(10.1)); + + u = vsel_vf2_vo_vf2_vf2_rvvm1_sleef(o1, vcast_vf2_vf_vf_rvvm1_sleef(a, vcast_vf_f_rvvm1_sleef(0)), dfdiv_vf2_vf2_vf2_rvvm1_sleef(vcast_vf2_f_f_rvvm1_sleef(1, 0), vcast_vf2_vf_vf_rvvm1_sleef(a, vcast_vf_f_rvvm1_sleef(0)))); + + t = vsel_vf_vo_vo_vo_f_f_f_f_rvvm1_sleef(o0, o1, o2, -0.8638041618e-4f, -0.6236977242e-5f, -0.3869504035e+0f, +0.1115344167e+1f); + t = vmla_vf_vf_vf_vf_rvvm1_sleef(t, vf2getx_vf_vf2_rvvm1_sleef(u), vsel_vf_vo_vo_vo_f_f_f_f_rvvm1_sleef(o0, o1, o2, +0.6000166177e-3f, +0.5749821503e-4f, +0.1288077235e+1f, -0.9454904199e+0f)); + t = vmla_vf_vf_vf_vf_rvvm1_sleef(t, vf2getx_vf_vf2_rvvm1_sleef(u), vsel_vf_vo_vo_vo_f_f_f_f_rvvm1_sleef(o0, o1, o2, -0.1665703603e-2f, +0.6002851478e-5f, -0.1816803217e+1f, -0.3667259514e+0f)); + t = vmla_vf_vf_vf_vf_rvvm1_sleef(t, vf2getx_vf_vf2_rvvm1_sleef(u), vsel_vf_vo_vo_vo_f_f_f_f_rvvm1_sleef(o0, o1, o2, +0.1795156277e-3f, -0.2851036377e-2f, +0.1249150872e+1f, +0.7155663371e+0f)); + t = vmla_vf_vf_vf_vf_rvvm1_sleef(t, vf2getx_vf_vf2_rvvm1_sleef(u), vsel_vf_vo_vo_vo_f_f_f_f_rvvm1_sleef(o0, o1, o2, +0.1914106123e-1f, +0.2260518074e-1f, -0.1328857988e+0f, -0.1262947265e-1f)); + + d = dfmul_vf2_vf2_vf_rvvm1_sleef(u, t); + d = dfadd2_vf2_vf2_vf2_rvvm1_sleef(d, vsel_vf2_vo_vo_vo_d_d_d_d_rvvm1_sleef(o0, o1, o2, -0.102775359343930288081655368891e+0, -0.105247583459338632253369014063e+0, -0.482365310333045318680618892669e+0, -0.498961546254537647970305302739e+0)); + d = dfmul_vf2_vf2_vf2_rvvm1_sleef(d, u); + d = dfadd2_vf2_vf2_vf2_rvvm1_sleef(d, vsel_vf2_vo_vo_vo_d_d_d_d_rvvm1_sleef(o0, o1, o2, -0.636619483208481931303752546439e+0, -0.635609463574589034216723775292e+0, -0.134450203224533979217859332703e-2, -0.471199543422848492080722832666e-4)); + d = dfmul_vf2_vf2_vf2_rvvm1_sleef(d, u); + d = dfadd2_vf2_vf2_vf2_rvvm1_sleef(d, vsel_vf2_vo_vo_vo_d_d_d_d_rvvm1_sleef(o0, o1, o2, -0.112837917790537404939545770596e+1, -0.112855987376668622084547028949e+1, -0.572319781150472949561786101080e+0, -0.572364030327966044425932623525e+0)); + + x = dfmul_vf2_vf2_vf_rvvm1_sleef(vsel_vf2_vo_vf2_vf2_rvvm1_sleef(o1, d, vcast_vf2_vf_vf_rvvm1_sleef(vneg_vf_vf_rvvm1_sleef(a), vcast_vf_f_rvvm1_sleef(0))), a); + x = vsel_vf2_vo_vf2_vf2_rvvm1_sleef(o1, x, dfadd2_vf2_vf2_vf2_rvvm1_sleef(x, d)); + + x = expk2f_rvvm1_sleef(x); + x = vsel_vf2_vo_vf2_vf2_rvvm1_sleef(o1, x, dfmul_vf2_vf2_vf2_rvvm1_sleef(x, u)); + + r = vsel_vf_vo_vf_vf_rvvm1_sleef(o3, vadd_vf_vf_vf_rvvm1_sleef(vf2getx_vf_vf2_rvvm1_sleef(x), vf2gety_vf_vf2_rvvm1_sleef(x)), vcast_vf_f_rvvm1_sleef(0)); + r = vsel_vf_vo_vf_vf_rvvm1_sleef(vsignbit_vo_vf_rvvm1_sleef(s), vsub_vf_vf_vf_rvvm1_sleef(vcast_vf_f_rvvm1_sleef(2), r), r); + r = vsel_vf_vo_vf_vf_rvvm1_sleef(visnan_vo_vf_rvvm1_sleef(s), vcast_vf_f_rvvm1_sleef(__builtin_nanf("")), r); + return r; +} diff --git a/src/jdk.incubator.vector/linux/native/libsleef/generated/sleefinline_sve.h b/src/jdk.incubator.vector/linux/native/libsleef/generated/sleefinline_sve.h new file mode 100644 index 00000000000..d4b15d0f218 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/generated/sleefinline_sve.h @@ -0,0 +1,6945 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See http://www.boost.org/LICENSE_1_0.txt) + +// This file is generated by SLEEF 3.6.1 + +#ifndef SLEEF_ALWAYS_INLINE +#if defined (__GNUC__) || defined (__clang__) || defined(__INTEL_COMPILER) +#define SLEEF_ALWAYS_INLINE inline __attribute__((always_inline)) +#elif defined(_MSC_VER) +#define SLEEF_ALWAYS_INLINE inline __forceinline +#else +#define SLEEF_ALWAYS_INLINE inline +#endif +#endif + +#ifndef SLEEF_INLINE +#define SLEEF_INLINE static inline +#endif + +#ifndef SLEEF_CONST +#define SLEEF_CONST +#endif + +#if defined(_MSC_VER) && !defined (__clang__) +#pragma fp_contract (off) +#else +#pragma STDC FP_CONTRACT OFF +#endif + +#ifndef SLEEF_FP_ILOGB0 +#define SLEEF_FP_ILOGB0 ((int)0x80000000) +#endif + +#ifndef SLEEF_FP_ILOGBNAN +#define SLEEF_FP_ILOGBNAN ((int)2147483647) +#endif + +#define SLEEFINLINE_SVE_H_INCLUDED + +#ifndef __SLEEF_REMPITAB__ +#define __SLEEF_REMPITAB__ +static const double Sleef_rempitabdp[] = { + 0.15915494309189531785, 1.7916237278037667488e-17, 2.5454160968749269937e-33, 2.1132476107887107169e-49, + 0.03415494309189533173, 4.0384494702232122736e-18, 1.0046721413651383112e-33, 2.1132476107887107169e-49, + 0.03415494309189533173, 4.0384494702232122736e-18, 1.0046721413651383112e-33, 2.1132476107887107169e-49, + 0.0029049430918953351999, 5.6900251826959904774e-19, 4.1707169171520598517e-35, -2.496415728504571394e-51, + 0.0029049430918953351999, 5.6900251826959904774e-19, 4.1707169171520598517e-35, -2.496415728504571394e-51, + 0.0029049430918953351999, 5.6900251826959904774e-19, 4.1707169171520598517e-35, -2.496415728504571394e-51, + 0.0029049430918953351999, 5.6900251826959904774e-19, 4.1707169171520598517e-35, -2.496415728504571394e-51, + 0.00095181809189533563356, 1.3532164927539732229e-19, -6.4410794381603004826e-36, 1.7634898158762436344e-52, + 0.00095181809189533563356, 1.3532164927539732229e-19, -6.4410794381603004826e-36, 1.7634898158762436344e-52, + 0.00046353684189533574198, 2.6901432026846872871e-20, -4.2254836195018827479e-37, 9.301187206862134399e-54, + 0.00021939621689533574198, 2.6901432026846872871e-20, -4.2254836195018827479e-37, 9.301187206862134399e-54, + 9.7325904395335769087e-05, -2.0362228529073840241e-22, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 3.6290748145335769087e-05, -2.0362228529073840241e-22, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 5.7731700203357690874e-06, -2.0362228529073840241e-22, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 5.7731700203357690874e-06, -2.0362228529073840241e-22, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 5.7731700203357690874e-06, -2.0362228529073840241e-22, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 1.9584727547107690874e-06, -2.0362228529073840241e-22, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 5.1124121898268875627e-08, 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 5.1124121898268875627e-08, 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 5.1124121898268875627e-08, 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 5.1124121898268875627e-08, 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 5.1124121898268875627e-08, 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 5.1124121898268875627e-08, 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 2.1321799510573569745e-08, 1.5185066224124613304e-24, 2.6226236120327253511e-40, 2.6283399642369025999e-57, + 6.4206383167259151492e-09, -1.3585460269359374382e-25, -1.3244127270701094468e-41, -2.4695541513869446866e-57, + 6.4206383167259151492e-09, -1.3585460269359374382e-25, -1.3244127270701094468e-41, -2.4695541513869446866e-57, + 2.6953480182640010867e-09, -1.3585460269359374382e-25, -1.3244127270701094468e-41, -2.4695541513869446866e-57, + 8.3270286903304384868e-10, 7.0940550444663151936e-26, 9.7147467687967058732e-42, 7.9392906424978921242e-59, + 8.3270286903304384868e-10, 7.0940550444663151936e-26, 9.7147467687967058732e-42, 7.9392906424978921242e-59, + 3.6704158172530459087e-10, 7.0940550444663151936e-26, 9.7147467687967058732e-42, 7.9392906424978921242e-59, + 1.3421093807143501366e-10, 1.9241762160098927996e-26, 3.9750282589222551507e-42, 7.9392906424978921242e-59, + 1.7795616244500218596e-11, -1.452834466126541428e-28, -1.5869767474823787636e-44, -2.6168913164368963837e-61, + 1.7795616244500218596e-11, -1.452834466126541428e-28, -1.5869767474823787636e-44, -2.6168913164368963837e-61, + 1.7795616244500218596e-11, -1.452834466126541428e-28, -1.5869767474823787636e-44, -2.6168913164368963837e-61, + 3.2437010161333667893e-12, -1.452834466126541428e-28, -1.5869767474823787636e-44, -2.6168913164368963837e-61, + 3.2437010161333667893e-12, -1.452834466126541428e-28, -1.5869767474823787636e-44, -2.6168913164368963837e-61, + 3.2437010161333667893e-12, -1.452834466126541428e-28, -1.5869767474823787636e-44, -2.6168913164368963837e-61, + 1.4247116125875099096e-12, 2.5861333686050385673e-28, 2.8971783383570358633e-44, -2.6168913164368963837e-61, + 5.1521691081458187359e-13, 5.6664945123924856962e-29, 6.5510079543732854985e-45, -2.6168913164368963837e-61, + 6.0469559928117805118e-14, 6.1778471897801070206e-30, 9.4581409707401690366e-46, 4.9461632249367446986e-62, + 6.0469559928117805118e-14, 6.1778471897801070206e-30, 9.4581409707401690366e-46, 4.9461632249367446986e-62, + 6.0469559928117805118e-14, 6.1778471897801070206e-30, 9.4581409707401690366e-46, 4.9461632249367446986e-62, + 3.6261410673097965595e-15, -1.3304005198798645927e-31, -1.7578597149294783985e-47, 8.4432539107728104262e-64, + 3.6261410673097965595e-15, -1.3304005198798645927e-31, -1.7578597149294783985e-47, 8.4432539107728104262e-64, + 3.6261410673097965595e-15, -1.3304005198798645927e-31, -1.7578597149294783985e-47, 8.4432539107728104262e-64, + 3.6261410673097965595e-15, -1.3304005198798645927e-31, -1.7578597149294783985e-47, 8.4432539107728104262e-64, + 7.3427388509295482183e-17, 1.4871367740953237822e-32, -1.1571307704883330232e-48, -6.7249112515659578102e-65, + 7.3427388509295482183e-17, 1.4871367740953237822e-32, -1.1571307704883330232e-48, -6.7249112515659578102e-65, + 7.3427388509295482183e-17, 1.4871367740953237822e-32, -1.1571307704883330232e-48, -6.7249112515659578102e-65, + 7.3427388509295482183e-17, 1.4871367740953237822e-32, -1.1571307704883330232e-48, -6.7249112515659578102e-65, + 7.3427388509295482183e-17, 1.4871367740953237822e-32, -1.1571307704883330232e-48, -6.7249112515659578102e-65, + 7.3427388509295482183e-17, 1.4871367740953237822e-32, -1.1571307704883330232e-48, -6.7249112515659578102e-65, + 1.7916237278037667488e-17, 2.5454160968749269937e-33, 2.1132476107887107169e-49, 8.7154294504188129325e-66, + 1.7916237278037667488e-17, 2.5454160968749269937e-33, 2.1132476107887107169e-49, 8.7154294504188129325e-66, + 4.0384494702232122736e-18, 1.0046721413651383112e-33, 2.1132476107887107169e-49, 8.7154294504188129325e-66, + 4.0384494702232122736e-18, 1.0046721413651383112e-33, 2.1132476107887107169e-49, 8.7154294504188129325e-66, + 5.6900251826959904774e-19, 4.1707169171520598517e-35, -2.4964157285045710972e-51, -1.866653112309982615e-67, + 5.6900251826959904774e-19, 4.1707169171520598517e-35, -2.4964157285045710972e-51, -1.866653112309982615e-67, + 5.6900251826959904774e-19, 4.1707169171520598517e-35, -2.4964157285045710972e-51, -1.866653112309982615e-67, + 1.3532164927539732229e-19, -6.4410794381603004826e-36, 1.7634898158762432635e-52, 3.5887057810247033998e-68, + 1.3532164927539732229e-19, -6.4410794381603004826e-36, 1.7634898158762432635e-52, 3.5887057810247033998e-68, + 2.6901432026846872871e-20, -4.2254836195018827479e-37, 9.3011872068621332399e-54, 1.113250147552460308e-69, + 2.6901432026846872871e-20, -4.2254836195018827479e-37, 9.3011872068621332399e-54, 1.113250147552460308e-69, + 2.6901432026846872871e-20, -4.2254836195018827479e-37, 9.3011872068621332399e-54, 1.113250147552460308e-69, + 1.3348904870778067446e-20, -4.2254836195018827479e-37, 9.3011872068621332399e-54, 1.113250147552460308e-69, + 6.5726412927436632287e-21, 1.0820844071023395684e-36, 1.7634898158762432635e-52, 3.5887057810247033998e-68, + 3.1845095037264626247e-21, 3.2976802257607573031e-37, 9.3011872068621332399e-54, 1.113250147552460308e-69, + 1.4904436092178623228e-21, -4.6390169687056261795e-38, -1.1392999419355048437e-54, -4.587677453735884283e-71, + 6.4341066196356198368e-22, -4.6390169687056261795e-38, -1.1392999419355048437e-54, -4.587677453735884283e-71, + 2.1989418833641172011e-22, 4.7649378378726728402e-38, 9.3011872068621332399e-54, 1.113250147552460308e-69, + 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, + 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, + 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, + 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, + 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, + 1.5185066224124613304e-24, 2.6226236120327253511e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, + 1.5185066224124613304e-24, 2.6226236120327253511e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, + 1.5185066224124613304e-24, 2.6226236120327253511e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, + 6.9132600985943383921e-25, 7.8591368887290111994e-41, 2.6283399642369020339e-57, 5.3358074162805516304e-73, + 2.7773570358292009361e-25, -1.3244127270701094468e-41, -2.4695541513869446866e-57, -3.2399200798614356002e-74, + 7.0940550444663151936e-26, 9.7147467687967058732e-42, 7.9392906424978921242e-59, 2.9745456030524896742e-75, + 7.0940550444663151936e-26, 9.7147467687967058732e-42, 7.9392906424978921242e-59, 2.9745456030524896742e-75, + 1.9241762160098927996e-26, 3.9750282589222551507e-42, 7.9392906424978921242e-59, 2.9745456030524896742e-75, + 1.9241762160098927996e-26, 3.9750282589222551507e-42, 7.9392906424978921242e-59, 2.9745456030524896742e-75, + 6.317065088957874881e-27, -3.2976062348358281152e-43, -2.6168913164368963837e-61, 3.7036201000008290615e-78, + 6.317065088957874881e-27, -3.2976062348358281152e-43, -2.6168913164368963837e-61, 3.7036201000008290615e-78, + 3.0858908211726098086e-27, 3.8770419025072344914e-43, 7.9392906424978921242e-59, 2.9745456030524896742e-75, + 1.4703036872799779898e-27, 2.8971783383570358633e-44, -2.6168913164368963837e-61, 3.7036201000008290615e-78, + 6.625101203336619011e-28, 2.8971783383570358633e-44, -2.6168913164368963837e-61, 3.7036201000008290615e-78, + 2.5861333686050385673e-28, 2.8971783383570358633e-44, -2.6168913164368963837e-61, 3.7036201000008290615e-78, + 5.6664945123924856962e-29, 6.5510079543732854985e-45, -2.6168913164368963837e-61, 3.7036201000008290615e-78, + 5.6664945123924856962e-29, 6.5510079543732854985e-45, -2.6168913164368963837e-61, 3.7036201000008290615e-78, + 6.1778471897801070206e-30, 9.4581409707401690366e-46, 4.9461632249367446986e-62, 3.7036201000008290615e-78, + 6.1778471897801070206e-30, 9.4581409707401690366e-46, 4.9461632249367446986e-62, 3.7036201000008290615e-78, + 6.1778471897801070206e-30, 9.4581409707401690366e-46, 4.9461632249367446986e-62, 3.7036201000008290615e-78, + 6.1778471897801070206e-30, 9.4581409707401690366e-46, 4.9461632249367446986e-62, 3.7036201000008290615e-78, + 3.0224035688960604996e-30, 2.451648649116083682e-46, 4.9461632249367446986e-62, 3.7036201000008290615e-78, + 1.4446817584540368888e-30, 2.451648649116083682e-46, 4.9461632249367446986e-62, 3.7036201000008290615e-78, + 6.5582085323302525856e-31, 7.0002556871006273225e-47, 1.0567786762735315635e-62, -6.1446417754639313137e-79, + 2.6139040062251944343e-31, -1.7578597149294783985e-47, 8.4432539107728090768e-64, 1.9517662449371102229e-79, + 6.4175174317266470186e-32, 4.3166913557804827486e-48, 8.4432539107728090768e-64, 1.9517662449371102229e-79, + 6.4175174317266470186e-32, 4.3166913557804827486e-48, 8.4432539107728090768e-64, 1.9517662449371102229e-79, + 1.4871367740953237822e-32, -1.1571307704883330232e-48, -6.7249112515659569668e-65, -7.2335760163150273591e-81, + 1.4871367740953237822e-32, -1.1571307704883330232e-48, -6.7249112515659569668e-65, -7.2335760163150273591e-81, + 2.5454160968749269937e-33, 2.1132476107887107169e-49, 8.7154294504188118783e-66, 1.2001823382693912203e-81, + 2.5454160968749269937e-33, 2.1132476107887107169e-49, 8.7154294504188118783e-66, 1.2001823382693912203e-81, + 2.5454160968749269937e-33, 2.1132476107887107169e-49, 8.7154294504188118783e-66, 1.2001823382693912203e-81, + 1.0046721413651383112e-33, 2.1132476107887107169e-49, 8.7154294504188118783e-66, 1.2001823382693912203e-81, + 2.3430016361024414106e-34, 4.0267819632970559834e-50, -7.8013829534098555144e-67, -1.1759240463442418271e-82, + 2.3430016361024414106e-34, 4.0267819632970559834e-50, -7.8013829534098555144e-67, -1.1759240463442418271e-82, + 4.1707169171520598517e-35, -2.4964157285045710972e-51, -1.866653112309982615e-67, 1.4185069655957361252e-83, + 4.1707169171520598517e-35, -2.4964157285045710972e-51, -1.866653112309982615e-67, 1.4185069655957361252e-83, + 4.1707169171520598517e-35, -2.4964157285045710972e-51, -1.866653112309982615e-67, 1.4185069655957361252e-83, + 1.7633044866680145008e-35, 2.8491136916798196016e-51, 4.0680767287898916022e-67, 1.4185069655957361252e-83, + 5.595982714259923599e-36, 1.7634898158762432635e-52, 3.588705781024702988e-68, 5.9489775128085140685e-84, + 5.595982714259923599e-36, 1.7634898158762432635e-52, 3.588705781024702988e-68, 5.9489775128085140685e-84, + 2.5867171761548675786e-36, 1.7634898158762432635e-52, 3.588705781024702988e-68, 5.9489775128085140685e-84, + 1.0820844071023395684e-36, 1.7634898158762432635e-52, 3.588705781024702988e-68, 5.9489775128085140685e-84, + 3.2976802257607573031e-37, 9.3011872068621332399e-54, 1.113250147552460308e-69, 2.9286284920280944778e-86, + 3.2976802257607573031e-37, 9.3011872068621332399e-54, 1.113250147552460308e-69, 2.9286284920280944778e-86, + 1.4168892644450972904e-37, 9.3011872068621332399e-54, 1.113250147552460308e-69, 2.9286284920280944778e-86, + 4.7649378378726728402e-38, 9.3011872068621332399e-54, 1.113250147552460308e-69, 2.9286284920280944778e-86, + 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 2.6226236120327253511e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 7.8591368887290111994e-41, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 7.8591368887290111994e-41, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 3.2673620808294506214e-41, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 9.7147467687967058732e-42, 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257943935e-91, + 9.7147467687967058732e-42, 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257943935e-91, + 3.9750282589222551507e-42, 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257943935e-91, + 1.1051690039850297894e-42, 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257943935e-91, + 1.1051690039850297894e-42, 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257943935e-91, + 3.8770419025072344914e-43, 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257943935e-91, + 2.8971783383570358633e-44, -2.6168913164368963837e-61, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 2.8971783383570358633e-44, -2.6168913164368963837e-61, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 2.8971783383570358633e-44, -2.6168913164368963837e-61, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 2.8971783383570358633e-44, -2.6168913164368963837e-61, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 6.5510079543732854985e-45, -2.6168913164368963837e-61, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 6.5510079543732854985e-45, -2.6168913164368963837e-61, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 9.4581409707401690366e-46, 4.9461632249367446986e-62, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 9.4581409707401690366e-46, 4.9461632249367446986e-62, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 9.4581409707401690366e-46, 4.9461632249367446986e-62, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 2.451648649116083682e-46, 4.9461632249367446986e-62, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 2.451648649116083682e-46, 4.9461632249367446986e-62, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 7.0002556871006273225e-47, 1.0567786762735315635e-62, -6.1446417754639301152e-79, -1.5355611056488084652e-94, + 7.0002556871006273225e-47, 1.0567786762735315635e-62, -6.1446417754639301152e-79, -1.5355611056488084652e-94, + 2.6211979860855749482e-47, 8.4432539107728090768e-64, 1.9517662449371099233e-79, 2.62202614552995759e-95, + 4.3166913557804827486e-48, 8.4432539107728090768e-64, 1.9517662449371099233e-79, 2.62202614552995759e-95, + 4.3166913557804827486e-48, 8.4432539107728090768e-64, 1.9517662449371099233e-79, 2.62202614552995759e-95, + 4.3166913557804827486e-48, 8.4432539107728090768e-64, 1.9517662449371099233e-79, 2.62202614552995759e-95, + 1.5797802926460750146e-48, 2.3660905534865399025e-64, -7.2335760163150273591e-81, 2.8738690232659205689e-99, + 2.1132476107887107169e-49, 8.7154294504188118783e-66, 1.2001823382693912203e-81, 2.8738690232659205689e-99, + 2.1132476107887107169e-49, 8.7154294504188118783e-66, 1.2001823382693912203e-81, 2.8738690232659205689e-99, + 2.1132476107887107169e-49, 8.7154294504188118783e-66, 1.2001823382693912203e-81, 2.8738690232659205689e-99, + 4.0267819632970559834e-50, -7.8013829534098555144e-67, -1.1759240463442418271e-82, 2.8738690232659205689e-99, + 4.0267819632970559834e-50, -7.8013829534098555144e-67, -1.1759240463442418271e-82, 2.8738690232659205689e-99, + 4.0267819632970559834e-50, -7.8013829534098555144e-67, -1.1759240463442418271e-82, 2.8738690232659205689e-99, + 1.8885701952232994665e-50, -7.8013829534098555144e-67, -1.1759240463442418271e-82, 2.8738690232659205689e-99, + 8.1946431118642097069e-51, 1.5937536410989638719e-66, 1.459625439463388979e-82, 2.8738690232659205689e-99, + 2.8491136916798196016e-51, 4.0680767287898916022e-67, 1.4185069655957361252e-83, -7.8369062883735917115e-100, + 1.7634898158762432635e-52, 3.588705781024702988e-68, 5.9489775128085131541e-84, 1.0450891972142808004e-99, + 1.7634898158762432635e-52, 3.588705781024702988e-68, 5.9489775128085131541e-84, 1.0450891972142808004e-99, + 1.7634898158762432635e-52, 3.588705781024702988e-68, 5.9489775128085131541e-84, 1.0450891972142808004e-99, + 1.7634898158762432635e-52, 3.588705781024702988e-68, 5.9489775128085131541e-84, 1.0450891972142808004e-99, + 9.3011872068621332399e-54, 1.113250147552460308e-69, 2.9286284920280941206e-86, 2.1132026692048600853e-102, + 9.3011872068621332399e-54, 1.113250147552460308e-69, 2.9286284920280941206e-86, 2.1132026692048600853e-102, + 9.3011872068621332399e-54, 1.113250147552460308e-69, 2.9286284920280941206e-86, 2.1132026692048600853e-102, + 9.3011872068621332399e-54, 1.113250147552460308e-69, 2.9286284920280941206e-86, 2.1132026692048600853e-102, + 9.3011872068621332399e-54, 1.113250147552460308e-69, 2.9286284920280941206e-86, 2.1132026692048600853e-102, + 4.0809436324633147776e-54, -4.587677453735884283e-71, -2.8859500138942368532e-87, -5.6567402911297190423e-103, + 1.470821845263904967e-54, -4.587677453735884283e-71, -2.8859500138942368532e-87, -5.6567402911297190423e-103, + 1.6576095166419998917e-55, 2.6568658093254848067e-71, 5.1571087196495574384e-87, 3.2728487032630537605e-103, + 1.6576095166419998917e-55, 2.6568658093254848067e-71, 5.1571087196495574384e-87, 3.2728487032630537605e-103, + 1.6576095166419998917e-55, 2.6568658093254848067e-71, 5.1571087196495574384e-87, 3.2728487032630537605e-103, + 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.5242184730639744369e-90, 1.145584788913072936e-105, + 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.5242184730639744369e-90, 1.145584788913072936e-105, + 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.5242184730639744369e-90, 1.145584788913072936e-105, + 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.5242184730639744369e-90, 1.145584788913072936e-105, + 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.5242184730639744369e-90, 1.145584788913072936e-105, + 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.5242184730639744369e-90, 1.145584788913072936e-105, + 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.554706987098633963e-107, + 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.554706987098633963e-107, + 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.554706987098633963e-107, + 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.554706987098633963e-107, + 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.554706987098633963e-107, + 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.554706987098633963e-107, + 3.9565608646667614317e-59, 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.554706987098633963e-107, + 1.9651959757511960854e-59, 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.554706987098633963e-107, + 9.6951353129341363331e-60, 7.6368645294831185015e-76, 1.0603435429602168369e-91, 1.0451839188820145747e-108, + 4.7167230906452229674e-60, 7.6368645294831185015e-76, 1.0603435429602168369e-91, 1.0451839188820145747e-108, + 2.2275169795007668372e-60, 2.1097166542226745549e-76, 4.4670685979800101779e-92, 1.0451839188820145747e-108, + 9.8291392392853877215e-61, -6.5385728340754726503e-77, -1.3520652573660833788e-93, -2.3220403312043059402e-109, + 3.6061239614242446325e-61, 7.2792968540756372162e-77, 1.3988851821689310822e-92, 1.0451839188820145747e-108, + 4.9461632249367446986e-62, 3.7036201000008285821e-78, 5.6554937751584084315e-94, -1.9306041120023063932e-110, + 4.9461632249367446986e-62, 3.7036201000008285821e-78, 5.6554937751584084315e-94, -1.9306041120023063932e-110, + 4.9461632249367446986e-62, 3.7036201000008285821e-78, 5.6554937751584084315e-94, -1.9306041120023063932e-110, + 1.0567786762735315635e-62, -6.1446417754639301152e-79, -1.535561105648808199e-94, -1.9306041120023063932e-110, + 1.0567786762735315635e-62, -6.1446417754639301152e-79, -1.535561105648808199e-94, -1.9306041120023063932e-110, + 8.4432539107728090768e-64, 1.9517662449371099233e-79, 2.62202614552995759e-95, 6.5314563001514358328e-112, + 8.4432539107728090768e-64, 1.9517662449371099233e-79, 2.62202614552995759e-95, 6.5314563001514358328e-112, + 8.4432539107728090768e-64, 1.9517662449371099233e-79, 2.62202614552995759e-95, 6.5314563001514358328e-112, + 8.4432539107728090768e-64, 1.9517662449371099233e-79, 2.62202614552995759e-95, 6.5314563001514358328e-112, + 2.3660905534865399025e-64, -7.2335760163150273591e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, + 2.3660905534865399025e-64, -7.2335760163150273591e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, + 8.4679971416497210292e-65, -7.2335760163150273591e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, + 8.7154294504188118783e-66, 1.2001823382693912203e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, + 8.7154294504188118783e-66, 1.2001823382693912203e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, + 8.7154294504188118783e-66, 1.2001823382693912203e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, + 8.7154294504188118783e-66, 1.2001823382693912203e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, + 3.9676455775389135587e-66, 1.459625439463388979e-82, 2.8738690232659205689e-99, 1.8395411057335783574e-115, + 1.5937536410989638719e-66, 1.459625439463388979e-82, 2.8738690232659205689e-99, 1.8395411057335783574e-115, + 4.0680767287898916022e-67, 1.4185069655957361252e-83, -7.8369062883735917115e-100, -1.9081236411894110579e-116, + 4.0680767287898916022e-67, 1.4185069655957361252e-83, -7.8369062883735917115e-100, -1.9081236411894110579e-116, + 1.1007118082399544936e-67, 1.4185069655957361252e-83, -7.8369062883735917115e-100, -1.9081236411894110579e-116, + 1.1007118082399544936e-67, 1.4185069655957361252e-83, -7.8369062883735917115e-100, -1.9081236411894110579e-116, + 3.588705781024702988e-68, 5.9489775128085131541e-84, 1.0450891972142805974e-99, 1.8395411057335783574e-115, + 3.588705781024702988e-68, 5.9489775128085131541e-84, 1.0450891972142805974e-99, 1.8395411057335783574e-115, + 1.7341027056809927069e-68, 1.830931441234090934e-84, 1.3069928418846076386e-100, 3.1677600334418876704e-116, + 8.0680116800913756637e-69, -2.2809159455312046184e-85, -4.0748824503880445403e-101, -6.3915272253158644628e-117, + 3.4315039917320989315e-69, -2.2809159455312046184e-85, -4.0748824503880445403e-101, -6.3915272253158644628e-117, + 1.113250147552460308e-69, 2.9286284920280941206e-86, 2.1132026692048600853e-102, -4.6672632026740766185e-119, + 1.113250147552460308e-69, 2.9286284920280941206e-86, 2.1132026692048600853e-102, -4.6672632026740766185e-119, + 5.3368668650755071652e-70, 2.9286284920280941206e-86, 2.1132026692048600853e-102, -4.6672632026740766185e-119, + 2.4390495598509592076e-70, 2.9286284920280941206e-86, 2.1132026692048600853e-102, -4.6672632026740766185e-119, + 9.901409072386855505e-71, -2.8859500138942368532e-87, -5.6567402911297190423e-103, -4.6672632026740766185e-119, + 2.6568658093254848067e-71, 5.1571087196495574384e-87, 3.2728487032630532648e-103, 5.2465720993401781599e-119, + 2.6568658093254848067e-71, 5.1571087196495574384e-87, 3.2728487032630532648e-103, 5.2465720993401781599e-119, + 8.4572999356014273536e-72, 1.1355793528776598461e-87, 3.2728487032630532648e-103, 5.2465720993401781599e-119, + 8.4572999356014273536e-72, 1.1355793528776598461e-87, 3.2728487032630532648e-103, 5.2465720993401781599e-119, + 3.9294603961880721752e-72, 1.3019701118468578292e-88, -7.5747169634236195447e-105, -2.0152904854894729832e-121, + 1.6655406264813940833e-72, 1.3019701118468578292e-88, -7.5747169634236195447e-105, -2.0152904854894729832e-121, + 5.3358074162805516304e-73, 4.5242184730639744369e-90, 1.1455847889130727424e-105, 1.8573014293598455046e-121, + 5.3358074162805516304e-73, 4.5242184730639744369e-90, 1.1455847889130727424e-105, 1.8573014293598455046e-121, + 2.5059077041472040156e-73, 4.5242184730639744369e-90, 1.1455847889130727424e-105, 1.8573014293598455046e-121, + 1.0909578480805302081e-73, 4.5242184730639744369e-90, 1.1455847889130727424e-105, 1.8573014293598455046e-121, + 3.8348292004719330442e-74, 4.5242184730639744369e-90, 1.1455847889130727424e-105, 1.8573014293598455046e-121, + 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.5547069870986327528e-107, 1.6304246661326865276e-122, + 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.5547069870986327528e-107, 1.6304246661326865276e-122, + 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.5547069870986327528e-107, 1.6304246661326865276e-122, + 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.5547069870986327528e-107, 1.6304246661326865276e-122, + 7.6368645294831185015e-76, 1.0603435429602168369e-91, 1.0451839188820145747e-108, 4.2386081393205242443e-125, + 7.6368645294831185015e-76, 1.0603435429602168369e-91, 1.0451839188820145747e-108, 4.2386081393205242443e-125, + 2.1097166542226745549e-76, 4.4670685979800101779e-92, 1.0451839188820145747e-108, 4.2386081393205242443e-125, + 2.1097166542226745549e-76, 4.4670685979800101779e-92, 1.0451839188820145747e-108, 4.2386081393205242443e-125, + 7.2792968540756372162e-77, 1.3988851821689310822e-92, 1.0451839188820145747e-108, 4.2386081393205242443e-125, + 3.7036201000008285821e-78, 5.6554937751584084315e-94, -1.9306041120023063932e-110, 1.0223371855251472933e-126, + 3.7036201000008285821e-78, 5.6554937751584084315e-94, -1.9306041120023063932e-110, 1.0223371855251472933e-126, + 3.7036201000008285821e-78, 5.6554937751584084315e-94, -1.9306041120023063932e-110, 1.0223371855251472933e-126, + 3.7036201000008285821e-78, 5.6554937751584084315e-94, -1.9306041120023063932e-110, 1.0223371855251472933e-126, + 3.7036201000008285821e-78, 5.6554937751584084315e-94, -1.9306041120023063932e-110, 1.0223371855251472933e-126, + 1.5445779612272179051e-78, 8.6145718795359707834e-95, 7.3062078800278780675e-111, 1.0223371855251472933e-126, + 4.6505689184041232695e-79, 8.6145718795359707834e-95, 7.3062078800278780675e-111, 1.0223371855251472933e-126, + 4.6505689184041232695e-79, 8.6145718795359707834e-95, 7.3062078800278780675e-111, 1.0223371855251472933e-126, + 1.9517662449371099233e-79, 2.62202614552995759e-95, 6.5314563001514349095e-112, 9.9039323746573674262e-128, + 6.0236490820360325022e-80, -3.7424672147304925625e-96, -1.784871512364483542e-112, 6.7095375687163151728e-129, + 6.0236490820360325022e-80, -3.7424672147304925625e-96, -1.784871512364483542e-112, 6.7095375687163151728e-129, + 2.6501457402022643213e-80, 3.7482149527770239293e-96, 6.5314563001514349095e-112, 9.9039323746573674262e-128, + 9.6339406928538097998e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, + 1.2001823382693912203e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, + 1.2001823382693912203e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, + 1.2001823382693912203e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, + 1.459625439463388979e-82, 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, + 1.459625439463388979e-82, 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, + 1.459625439463388979e-82, 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, + 1.4185069655957361252e-83, -7.8369062883735917115e-100, -1.9081236411894107761e-116, -2.1796760241698337334e-132, + 1.4185069655957361252e-83, -7.8369062883735917115e-100, -1.9081236411894107761e-116, -2.1796760241698337334e-132, + 1.4185069655957361252e-83, -7.8369062883735917115e-100, -1.9081236411894107761e-116, -2.1796760241698337334e-132, + 1.4185069655957361252e-83, -7.8369062883735917115e-100, -1.9081236411894107761e-116, -2.1796760241698337334e-132, + 5.9489775128085131541e-84, 1.0450891972142805974e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, + 1.830931441234090934e-84, 1.3069928418846076386e-100, 3.1677600334418871069e-116, 3.4556869017247800778e-132, + 1.830931441234090934e-84, 1.3069928418846076386e-100, 3.1677600334418871069e-116, 3.4556869017247800778e-132, + 8.0141992334048515034e-85, 1.3069928418846076386e-100, 3.1677600334418871069e-116, 3.4556869017247800778e-132, + 2.8666416439368237283e-85, 1.6400545060233297363e-101, -4.6672632026740766185e-119, -3.755176715260116501e-136, + 2.9286284920280941206e-86, 2.1132026692048600853e-102, -4.6672632026740766185e-119, -3.755176715260116501e-136, + 2.9286284920280941206e-86, 2.1132026692048600853e-102, -4.6672632026740766185e-119, -3.755176715260116501e-136, + 2.9286284920280941206e-86, 2.1132026692048600853e-102, -4.6672632026740766185e-119, -3.755176715260116501e-136, + 2.9286284920280941206e-86, 2.1132026692048600853e-102, -4.6672632026740766185e-119, -3.755176715260116501e-136, + 1.3200167453193350837e-86, 2.1132026692048600853e-102, -4.6672632026740766185e-119, -3.755176715260116501e-136, + 5.1571087196495574384e-87, 3.2728487032630532648e-103, 5.2465720993401781599e-119, -3.755176715260116501e-136, + 1.1355793528776598461e-87, 3.2728487032630532648e-103, 5.2465720993401781599e-119, -3.755176715260116501e-136, + 1.1355793528776598461e-87, 3.2728487032630532648e-103, 5.2465720993401781599e-119, -3.755176715260116501e-136, + 1.3019701118468578292e-88, -7.5747169634236195447e-105, -2.0152904854894725532e-121, -3.1562414818576682143e-137, + 1.3019701118468578292e-88, -7.5747169634236195447e-105, -2.0152904854894725532e-121, -3.1562414818576682143e-137, + 1.3019701118468578292e-88, -7.5747169634236195447e-105, -2.0152904854894725532e-121, -3.1562414818576682143e-137, + 4.5242184730639744369e-90, 1.1455847889130727424e-105, 1.8573014293598452896e-121, 1.1431992269852683481e-137, + 4.5242184730639744369e-90, 1.1455847889130727424e-105, 1.8573014293598452896e-121, 1.1431992269852683481e-137, + 4.5242184730639744369e-90, 1.1455847889130727424e-105, 1.8573014293598452896e-121, 1.1431992269852683481e-137, + 4.5242184730639744369e-90, 1.1455847889130727424e-105, 1.8573014293598452896e-121, 1.1431992269852683481e-137, + 4.5242184730639744369e-90, 1.1455847889130727424e-105, 1.8573014293598452896e-121, 1.1431992269852683481e-137, + 5.969437008257942845e-91, 5.5547069870986327528e-107, 1.6304246661326865276e-122, 6.8339049774534162772e-139, + 5.969437008257942845e-91, 5.5547069870986327528e-107, 1.6304246661326865276e-122, 6.8339049774534162772e-139, + 5.969437008257942845e-91, 5.5547069870986327528e-107, 1.6304246661326865276e-122, 6.8339049774534162772e-139, + 1.0603435429602168369e-91, 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591188256e-141, + 1.0603435429602168369e-91, 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591188256e-141, + 1.0603435429602168369e-91, 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591188256e-141, + 4.4670685979800101779e-92, 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591188256e-141, + 1.3988851821689310822e-92, 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591188256e-141, + 1.3988851821689310822e-92, 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591188256e-141, + 6.3183932821616130831e-93, 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591188256e-141, + 2.4831640123977650651e-93, 1.9359195088038447797e-109, -4.8867691298577234423e-126, -2.0587960670007823264e-142, + 5.6554937751584084315e-94, -1.9306041120023063932e-110, 1.0223371855251471293e-126, 1.2214168761472102282e-142, + 5.6554937751584084315e-94, -1.9306041120023063932e-110, 1.0223371855251471293e-126, 1.2214168761472102282e-142, + 8.6145718795359707834e-95, 7.3062078800278780675e-111, 1.0223371855251471293e-126, 1.2214168761472102282e-142, + 8.6145718795359707834e-95, 7.3062078800278780675e-111, 1.0223371855251471293e-126, 1.2214168761472102282e-142, + 8.6145718795359707834e-95, 7.3062078800278780675e-111, 1.0223371855251471293e-126, 1.2214168761472102282e-142, + 2.62202614552995759e-95, 6.5314563001514349095e-112, 9.9039323746573674262e-128, -8.6629775332868987041e-145, + 2.62202614552995759e-95, 6.5314563001514349095e-112, 9.9039323746573674262e-128, -8.6629775332868987041e-145, + 1.1238897120284541253e-95, 6.5314563001514349095e-112, 9.9039323746573674262e-128, -8.6629775332868987041e-145, + 3.7482149527770239293e-96, 6.5314563001514349095e-112, 9.9039323746573674262e-128, -8.6629775332868987041e-145, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 1.0450891972142805974e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 1.3069928418846076386e-100, 3.1677600334418871069e-116, 3.4556869017247794521e-132, 8.5448727249069983612e-148, + 1.3069928418846076386e-100, 3.1677600334418871069e-116, 3.4556869017247794521e-132, 8.5448727249069983612e-148, + 1.3069928418846076386e-100, 3.1677600334418871069e-116, 3.4556869017247794521e-132, 8.5448727249069983612e-148, + 1.6400545060233297363e-101, -4.6672632026740766185e-119, -3.755176715260116501e-136, 2.1571619860435652883e-152, + 1.6400545060233297363e-101, -4.6672632026740766185e-119, -3.755176715260116501e-136, 2.1571619860435652883e-152, + 1.6400545060233297363e-101, -4.6672632026740766185e-119, -3.755176715260116501e-136, 2.1571619860435652883e-152, + 2.1132026692048600853e-102, -4.6672632026740766185e-119, -3.755176715260116501e-136, 2.1571619860435652883e-152, + 2.1132026692048600853e-102, -4.6672632026740766185e-119, -3.755176715260116501e-136, 2.1571619860435652883e-152, + 2.1132026692048600853e-102, -4.6672632026740766185e-119, -3.755176715260116501e-136, 2.1571619860435652883e-152, + 3.2728487032630532648e-103, 5.2465720993401781599e-119, -3.755176715260116501e-136, 2.1571619860435652883e-152, + 3.2728487032630532648e-103, 5.2465720993401781599e-119, -3.755176715260116501e-136, 2.1571619860435652883e-152, + 3.2728487032630532648e-103, 5.2465720993401781599e-119, -3.755176715260116501e-136, 2.1571619860435652883e-152, + 1.0404514546648604359e-103, 2.896544483330507019e-120, 3.1239284188885823808e-136, 2.1571619860435652883e-152, + 1.0404514546648604359e-103, 2.896544483330507019e-120, 3.1239284188885823808e-136, 2.1571619860435652883e-152, + 4.8235214251531210473e-104, 2.896544483330507019e-120, 3.1239284188885823808e-136, 2.1571619860435652883e-152, + 2.0330248644053793915e-104, 2.896544483330507019e-120, 3.1239284188885823808e-136, 2.1571619860435652883e-152, + 6.3777658403150887343e-105, -2.0152904854894725532e-121, -3.156241481857667737e-137, -7.0684085473731388916e-153, + 6.3777658403150887343e-105, -2.0152904854894725532e-121, -3.156241481857667737e-137, -7.0684085473731388916e-153, + 2.88964513938041089e-105, 5.7298933442091639924e-121, -3.156241481857667737e-137, -7.0684085473731388916e-153, + 1.1455847889130727424e-105, 1.8573014293598452896e-121, 1.1431992269852681095e-137, 2.4782675885631257398e-153, + 2.7355461367940366859e-106, -7.8994528064813712419e-123, -2.0037599452814940222e-138, 9.1598554579059548847e-155, + 2.7355461367940366859e-106, -7.8994528064813712419e-123, -2.0037599452814940222e-138, 9.1598554579059548847e-155, + 5.5547069870986327528e-107, 1.6304246661326865276e-122, 6.8339049774534147855e-139, 9.1598554579059548847e-155, + 5.5547069870986327528e-107, 1.6304246661326865276e-122, 6.8339049774534147855e-139, 9.1598554579059548847e-155, + 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, + 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, + 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, + 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, + 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, + 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, + 1.9359195088038447797e-109, -4.8867691298577234423e-126, -2.0587960670007819622e-142, -2.8326669474241479263e-158, + 1.9359195088038447797e-109, -4.8867691298577234423e-126, -2.0587960670007819622e-142, -2.8326669474241479263e-158, + 1.9359195088038447797e-109, -4.8867691298577234423e-126, -2.0587960670007819622e-142, -2.8326669474241479263e-158, + 8.7142954880180709975e-110, -4.8867691298577234423e-126, -2.0587960670007819622e-142, -2.8326669474241479263e-158, + 3.3918456880078814158e-110, 6.931443500908017045e-126, 1.1062055705591186799e-141, 1.1734404793201255869e-157, + 7.3062078800278780675e-111, 1.0223371855251471293e-126, 1.2214168761472102282e-142, 8.0910098773220312367e-159, + 7.3062078800278780675e-111, 1.0223371855251471293e-126, 1.2214168761472102282e-142, 8.0910098773220312367e-159, + 6.5314563001514349095e-112, 9.9039323746573674262e-128, -8.6629775332868972816e-145, -1.5987060076657616072e-160, + 6.5314563001514349095e-112, 9.9039323746573674262e-128, -8.6629775332868972816e-145, -1.5987060076657616072e-160, + 6.5314563001514349095e-112, 9.9039323746573674262e-128, -8.6629775332868972816e-145, -1.5987060076657616072e-160, + 6.5314563001514349095e-112, 9.9039323746573674262e-128, -8.6629775332868972816e-145, -1.5987060076657616072e-160, + 2.3732923938934761454e-112, 6.7095375687163138915e-129, 1.6963686085056791706e-144, 1.2464251916751375716e-160, + 2.9421044076449630171e-113, 6.7095375687163138915e-129, 1.6963686085056791706e-144, 1.2464251916751375716e-160, + 2.9421044076449630171e-113, 6.7095375687163138915e-129, 1.6963686085056791706e-144, 1.2464251916751375716e-160, + 2.9421044076449630171e-113, 6.7095375687163138915e-129, 1.6963686085056791706e-144, 1.2464251916751375716e-160, + 3.4325196623373878948e-114, 9.3892593260023063019e-130, 9.4702132359198537748e-146, 1.7950099192230045857e-161, + 3.4325196623373878948e-114, 9.3892593260023063019e-130, 9.4702132359198537748e-146, 1.7950099192230045857e-161, + 3.4325196623373878948e-114, 9.3892593260023063019e-130, 9.4702132359198537748e-146, 1.7950099192230045857e-161, + 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, 2.9106774506606945839e-164, + 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, 2.9106774506606945839e-164, + 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, 2.9106774506606945839e-164, + 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, 2.9106774506606945839e-164, + 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, 2.9106774506606945839e-164, + 8.2436437080731844263e-116, 1.4726412753514008951e-131, -3.9681466199873824165e-148, 2.9106774506606945839e-164, + 3.1677600334418871069e-116, 3.4556869017247794521e-132, 8.544872724906996972e-148, 1.6802919634942429241e-163, + 6.2981819612623816536e-117, 6.3800543877747317218e-133, 7.2423563434801054878e-149, 1.1741471776254779927e-164, + 6.2981819612623816536e-117, 6.3800543877747317218e-133, 7.2423563434801054878e-149, 1.1741471776254779927e-164, + 6.2981819612623816536e-117, 6.3800543877747317218e-133, 7.2423563434801054878e-149, 1.1741471776254779927e-164, + 3.1257546646178208289e-117, -6.6414926959353515111e-134, -5.7828074707888119584e-150, -1.2825052715093464343e-165, + 1.5395410162955400644e-117, -6.6414926959353515111e-134, -5.7828074707888119584e-150, -1.2825052715093464343e-165, + 7.4643419213439950602e-118, 1.0969016447485317626e-133, -5.7828074707888119584e-150, -1.2825052715093464343e-165, + 3.4988078005382940294e-118, 2.1637618757749825688e-134, -8.9490928918944555247e-151, -1.9717385086233606481e-166, + 1.5160407401354430737e-118, 2.1637618757749825688e-134, -8.9490928918944555247e-151, -1.9717385086233606481e-166, + 5.2465720993401781599e-119, -3.755176715260116501e-136, 2.1571619860435648643e-152, 6.3257905089784152346e-168, + 2.896544483330507019e-120, 3.1239284188885823808e-136, 2.1571619860435648643e-152, 6.3257905089784152346e-168, + 2.896544483330507019e-120, 3.1239284188885823808e-136, 2.1571619860435648643e-152, 6.3257905089784152346e-168, + 2.896544483330507019e-120, 3.1239284188885823808e-136, 2.1571619860435648643e-152, 6.3257905089784152346e-168, + 2.896544483330507019e-120, 3.1239284188885823808e-136, 2.1571619860435648643e-152, 6.3257905089784152346e-168, + 2.896544483330507019e-120, 3.1239284188885823808e-136, 2.1571619860435648643e-152, 6.3257905089784152346e-168, + 1.3475077173907800538e-120, -3.156241481857667737e-137, -7.0684085473731388916e-153, -3.3573283875161501977e-170, + 5.7298933442091639924e-121, -3.156241481857667737e-137, -7.0684085473731388916e-153, -3.3573283875161501977e-170, + 1.8573014293598452896e-121, 1.1431992269852681095e-137, 2.4782675885631257398e-153, -3.3573283875161501977e-170, + 1.8573014293598452896e-121, 1.1431992269852681095e-137, 2.4782675885631257398e-153, -3.3573283875161501977e-170, + 8.8915345064751572143e-122, 1.1431992269852681095e-137, 2.4782675885631257398e-153, -3.3573283875161501977e-170, + 4.0507946129135104481e-122, 6.8339049774534147855e-139, 9.1598554579059548847e-155, -4.5159745404911825673e-172, + 1.6304246661326865276e-122, 6.8339049774534147855e-139, 9.1598554579059548847e-155, -4.5159745404911825673e-172, + 4.2023969274227456735e-123, 6.8339049774534147855e-139, 9.1598554579059548847e-155, -4.5159745404911825673e-172, + 4.2023969274227456735e-123, 6.8339049774534147855e-139, 9.1598554579059548847e-155, -4.5159745404911825673e-172, + 1.1769344939467164447e-123, 1.1602886988632691941e-140, 3.0307583960570927356e-156, 5.8345524661064369683e-172, + 1.1769344939467164447e-123, 1.1602886988632691941e-140, 3.0307583960570927356e-156, 5.8345524661064369683e-172, + 4.2056888557770896953e-124, 1.1602886988632691941e-140, 3.0307583960570927356e-156, 5.8345524661064369683e-172, + 4.2386081393205242443e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, 1.2381024895275844856e-174, + 4.2386081393205242443e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, 1.2381024895275844856e-174, + 4.2386081393205242443e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, 1.2381024895275844856e-174, + 4.2386081393205242443e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, 1.2381024895275844856e-174, + 1.8749656131673758844e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, 1.2381024895275844856e-174, + 6.931443500908017045e-126, 1.1062055705591186799e-141, 1.1734404793201255869e-157, 1.2381024895275844856e-174, + 1.0223371855251471293e-126, 1.2214168761472102282e-142, 8.0910098773220302259e-159, 1.2381024895275844856e-174, + 1.0223371855251471293e-126, 1.2214168761472102282e-142, 8.0910098773220302259e-159, 1.2381024895275844856e-174, + 1.0223371855251471293e-126, 1.2214168761472102282e-142, 8.0910098773220302259e-159, 1.2381024895275844856e-174, + 2.8369889610228834887e-127, 4.0136364036021218058e-143, -1.0134099605688458828e-159, -2.5389576707476506925e-176, + 2.8369889610228834887e-127, 4.0136364036021218058e-143, -1.0134099605688458828e-159, -2.5389576707476506925e-176, + 9.9039323746573674262e-128, -8.6629775332868972816e-145, -1.5987060076657612913e-160, -2.5389576707476506925e-176, + 6.7095375687163138915e-129, 1.6963686085056791706e-144, 1.2464251916751375716e-160, 6.197724948400014906e-177, + 6.7095375687163138915e-129, 1.6963686085056791706e-144, 1.2464251916751375716e-160, 6.197724948400014906e-177, + 6.7095375687163138915e-129, 1.6963686085056791706e-144, 1.2464251916751375716e-160, 6.197724948400014906e-177, + 6.7095375687163138915e-129, 1.6963686085056791706e-144, 1.2464251916751375716e-160, 6.197724948400014906e-177, + 9.3892593260023063019e-130, 9.4702132359198537748e-146, 1.7950099192230045857e-161, -1.6991004655691155518e-177, + 9.3892593260023063019e-130, 9.4702132359198537748e-146, 1.7950099192230045857e-161, -1.6991004655691155518e-177, + 9.3892593260023063019e-130, 9.4702132359198537748e-146, 1.7950099192230045857e-161, -1.6991004655691155518e-177, + 2.175994780857201024e-130, 1.4618808551874518553e-146, 1.6802919634942426156e-163, 2.8330093736631818036e-179, + 2.175994780857201024e-130, 1.4618808551874518553e-146, 1.6802919634942426156e-163, 2.8330093736631818036e-179, + 3.7267864457092460442e-131, 4.6083930759590139305e-147, 1.6802919634942426156e-163, 2.8330093736631818036e-179, + 3.7267864457092460442e-131, 4.6083930759590139305e-147, 1.6802919634942426156e-163, 2.8330093736631818036e-179, + 3.7267864457092460442e-131, 4.6083930759590139305e-147, 1.6802919634942426156e-163, 2.8330093736631818036e-179, + 1.4726412753514008951e-131, -3.9681466199873824165e-148, 2.9106774506606941983e-164, 5.1948630316441296498e-180, + 3.4556869017247794521e-132, 8.544872724906996972e-148, 1.6802919634942426156e-163, 2.8330093736631818036e-179, + 3.4556869017247794521e-132, 8.544872724906996972e-148, 1.6802919634942426156e-163, 2.8330093736631818036e-179, + 6.3800543877747317218e-133, 7.2423563434801054878e-149, 1.1741471776254777999e-164, 1.3389912474795152755e-180, + 6.3800543877747317218e-133, 7.2423563434801054878e-149, 1.1741471776254777999e-164, 1.3389912474795152755e-180, + 6.3800543877747317218e-133, 7.2423563434801054878e-149, 1.1741471776254777999e-164, 1.3389912474795152755e-180, + 2.8579525590905986764e-133, -5.7828074707888119584e-150, -1.2825052715093464343e-165, -1.0696067158221530218e-181, + 1.0969016447485317626e-133, -5.7828074707888119584e-150, -1.2825052715093464343e-165, -1.0696067158221530218e-181, + 2.1637618757749825688e-134, -8.9490928918944555247e-151, -1.9717385086233606481e-166, 1.3535321672928907047e-182, + 2.1637618757749825688e-134, -8.9490928918944555247e-151, -1.9717385086233606481e-166, 1.3535321672928907047e-182, + 2.1637618757749825688e-134, -8.9490928918944555247e-151, -1.9717385086233606481e-166, 1.3535321672928907047e-182, + 1.0631050543111905033e-134, 1.5490398016102376505e-150, 3.4549185946116918017e-166, 1.3535321672928907047e-182, + 5.1277664357929471499e-135, 3.2706525621039604902e-151, 7.4159004299416557678e-167, 1.3535321672928907047e-182, + 2.3761243821334675971e-135, 3.2706525621039604902e-151, 7.4159004299416557678e-167, 1.3535321672928907047e-182, + 1.0003033553037281263e-135, 2.1571619860435648643e-152, 6.3257905089784152346e-168, 3.5607241064750984115e-184, + 3.1239284188885823808e-136, 2.1571619860435648643e-152, 6.3257905089784152346e-168, 3.5607241064750984115e-184, + 3.1239284188885823808e-136, 2.1571619860435648643e-152, 6.3257905089784152346e-168, 3.5607241064750984115e-184, + 1.4041521353514076604e-136, 2.1571619860435648643e-152, 6.3257905089784152346e-168, 3.5607241064750984115e-184, + 5.4426399358282049106e-137, 2.4782675885631257398e-153, -3.3573283875161501977e-170, 3.0568054078295488291e-186, + 1.1431992269852681095e-137, 2.4782675885631257398e-153, -3.3573283875161501977e-170, 3.0568054078295488291e-186, + 1.1431992269852681095e-137, 2.4782675885631257398e-153, -3.3573283875161501977e-170, 3.0568054078295488291e-186, + 6.8339049774534147855e-139, 9.1598554579059548847e-155, -4.5159745404911819927e-172, -4.5870810097328578981e-188, + 6.8339049774534147855e-139, 9.1598554579059548847e-155, -4.5159745404911819927e-172, -4.5870810097328578981e-188, + 6.8339049774534147855e-139, 9.1598554579059548847e-155, -4.5159745404911819927e-172, -4.5870810097328578981e-188, + 6.8339049774534147855e-139, 9.1598554579059548847e-155, -4.5159745404911819927e-172, -4.5870810097328578981e-188, + 1.1602886988632691941e-140, 3.0307583960570927356e-156, 5.8345524661064358191e-172, 6.9043123899963188689e-188, + 1.1602886988632691941e-140, 3.0307583960570927356e-156, 5.8345524661064358191e-172, 6.9043123899963188689e-188, + 1.1602886988632691941e-140, 3.0307583960570927356e-156, 5.8345524661064358191e-172, 6.9043123899963188689e-188, + 1.1602886988632691941e-140, 3.0307583960570927356e-156, 5.8345524661064358191e-172, 6.9043123899963188689e-188, + 1.1602886988632691941e-140, 3.0307583960570927356e-156, 5.8345524661064358191e-172, 6.9043123899963188689e-188, + 1.1602886988632691941e-140, 3.0307583960570927356e-156, 5.8345524661064358191e-172, 6.9043123899963188689e-188, + 1.1062055705591186799e-141, 1.1734404793201255869e-157, 1.2381024895275844856e-174, -8.4789520282639751913e-191, + 1.1062055705591186799e-141, 1.1734404793201255869e-157, 1.2381024895275844856e-174, -8.4789520282639751913e-191, + 1.1062055705591186799e-141, 1.1734404793201255869e-157, 1.2381024895275844856e-174, -8.4789520282639751913e-191, + 1.1062055705591186799e-141, 1.1734404793201255869e-157, 1.2381024895275844856e-174, -8.4789520282639751913e-191, + 4.5016298192952031469e-142, -2.8326669474241479263e-158, 1.2381024895275844856e-174, -8.4789520282639751913e-191, + 1.2214168761472102282e-142, 8.0910098773220302259e-159, 1.2381024895275844856e-174, -8.4789520282639751913e-191, + 1.2214168761472102282e-142, 8.0910098773220302259e-159, 1.2381024895275844856e-174, -8.4789520282639751913e-191, + 4.0136364036021218058e-143, -1.0134099605688458828e-159, -2.5389576707476506925e-176, -6.2404128071707654958e-193, + 4.0136364036021218058e-143, -1.0134099605688458828e-159, -2.5389576707476506925e-176, -6.2404128071707654958e-193, + 1.9635033141346264592e-143, -1.0134099605688458828e-159, -2.5389576707476506925e-176, -6.2404128071707654958e-193, + 9.3843676940087855824e-144, 1.2626949989038732076e-159, 2.2730883653953564668e-175, 2.7431118386590483722e-191, + 4.2590349703400483539e-144, 1.2464251916751375716e-160, 6.1977249484000140293e-177, 1.1294061984896458822e-192, + 1.6963686085056791706e-144, 1.2464251916751375716e-160, 6.1977249484000140293e-177, 1.1294061984896458822e-192, + 4.1503542758849472122e-145, -1.7614040799531193879e-161, -1.6991004655691153326e-177, -1.856794109153959173e-193, + 4.1503542758849472122e-145, -1.7614040799531193879e-161, -1.6991004655691153326e-177, -1.856794109153959173e-193, + 9.4702132359198537748e-146, 1.7950099192230045857e-161, -1.6991004655691153326e-177, -1.856794109153959173e-193, + 9.4702132359198537748e-146, 1.7950099192230045857e-161, -1.6991004655691153326e-177, -1.856794109153959173e-193, + 1.4618808551874518553e-146, 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, + 1.4618808551874518553e-146, 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, + 1.4618808551874518553e-146, 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, + 4.6083930759590139305e-147, 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, + 4.6083930759590139305e-147, 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, + 2.105789206980137775e-147, 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, + 8.544872724906996972e-148, 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, + 2.2883630524598079723e-148, 2.9106774506606941983e-164, 5.1948630316441287936e-180, 9.6685396110091032843e-196, + 2.2883630524598079723e-148, 2.9106774506606941983e-164, 5.1948630316441287936e-180, 9.6685396110091032843e-196, + 7.2423563434801054878e-149, 1.1741471776254777999e-164, 1.3389912474795150614e-180, 1.1067843414450286726e-196, + 7.2423563434801054878e-149, 1.1741471776254777999e-164, 1.3389912474795150614e-180, 1.1067843414450286726e-196, + 3.3320377982006123631e-149, 3.0588204110786950436e-165, 3.7502330143836152136e-181, 3.6564932749519464998e-198, + 1.3768785255608653665e-149, 3.0588204110786950436e-165, 3.7502330143836152136e-181, 3.6564932749519464998e-198, + 3.9929888924099219388e-150, -1.9717385086233606481e-166, 1.3535321672928907047e-182, 3.1205762277848031878e-199, + 3.9929888924099219388e-150, -1.9717385086233606481e-166, 1.3535321672928907047e-182, 3.1205762277848031878e-199, + 1.5490398016102376505e-150, 3.4549185946116918017e-166, 1.3535321672928907047e-182, 3.1205762277848031878e-199, + 3.2706525621039604902e-151, 7.4159004299416557678e-167, 1.3535321672928907047e-182, 3.1205762277848031878e-199, + 3.2706525621039604902e-151, 7.4159004299416557678e-167, 1.3535321672928907047e-182, 3.1205762277848031878e-199, + 2.1571619860435648643e-152, 6.3257905089784152346e-168, 3.5607241064750984115e-184, -1.4832196127821708615e-201, + 2.1571619860435648643e-152, 6.3257905089784152346e-168, 3.5607241064750984115e-184, -1.4832196127821708615e-201, + 2.1571619860435648643e-152, 6.3257905089784152346e-168, 3.5607241064750984115e-184, -1.4832196127821708615e-201, + 2.1571619860435648643e-152, 6.3257905089784152346e-168, 3.5607241064750984115e-184, -1.4832196127821708615e-201, + 2.4782675885631257398e-153, -3.3573283875161501977e-170, 3.0568054078295488291e-186, 1.4980560800565462618e-202, + 2.4782675885631257398e-153, -3.3573283875161501977e-170, 3.0568054078295488291e-186, 1.4980560800565462618e-202, + 2.4782675885631257398e-153, -3.3573283875161501977e-170, 3.0568054078295488291e-186, 1.4980560800565462618e-202, + 9.1598554579059548847e-155, -4.5159745404911819927e-172, -4.5870810097328572602e-188, -3.2905064432040069127e-204, + 9.1598554579059548847e-155, -4.5159745404911819927e-172, -4.5870810097328572602e-188, -3.2905064432040069127e-204, + 9.1598554579059548847e-155, -4.5159745404911819927e-172, -4.5870810097328572602e-188, -3.2905064432040069127e-204, + 9.1598554579059548847e-155, -4.5159745404911819927e-172, -4.5870810097328572602e-188, -3.2905064432040069127e-204, + 9.1598554579059548847e-155, -4.5159745404911819927e-172, -4.5870810097328572602e-188, -3.2905064432040069127e-204, + 1.7015147267057481414e-155, -4.5159745404911819927e-172, -4.5870810097328572602e-188, -3.2905064432040069127e-204, + 1.7015147267057481414e-155, -4.5159745404911819927e-172, -4.5870810097328572602e-188, -3.2905064432040069127e-204, + 1.7015147267057481414e-155, -4.5159745404911819927e-172, -4.5870810097328572602e-188, -3.2905064432040069127e-204, + 7.6922213530572229852e-156, -4.5159745404911819927e-172, -4.5870810097328572602e-188, -3.2905064432040069127e-204, + 3.0307583960570927356e-156, 5.8345524661064358191e-172, 6.9043123899963188689e-188, -3.2905064432040069127e-204, + 7.0002691755702864582e-157, 6.5928896280762691321e-173, 1.1586156901317304854e-188, -1.0100405885278530137e-205, + 7.0002691755702864582e-157, 6.5928896280762691321e-173, 1.1586156901317304854e-188, -1.0100405885278530137e-205, + 1.1734404793201255869e-157, 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.3321093418096261919e-207, + 1.1734404793201255869e-157, 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.3321093418096261919e-207, + 1.1734404793201255869e-157, 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.3321093418096261919e-207, + 4.4508689228885539715e-158, 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.3321093418096261919e-207, + 8.0910098773220302259e-159, 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.3321093418096261919e-207, + 8.0910098773220302259e-159, 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.3321093418096261919e-207, + 8.0910098773220302259e-159, 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.3321093418096261919e-207, + 3.5387999583765925506e-159, 2.2730883653953564668e-175, 2.7431118386590483722e-191, -1.3321093418096261919e-207, + 1.2626949989038732076e-159, 2.2730883653953564668e-175, 2.7431118386590483722e-191, -1.3321093418096261919e-207, + 1.2464251916751375716e-160, 6.1977249484000140293e-177, 1.1294061984896456875e-192, 2.2526486929936882202e-208, + 1.2464251916751375716e-160, 6.1977249484000140293e-177, 1.1294061984896456875e-192, 2.2526486929936882202e-208, + 1.2464251916751375716e-160, 6.1977249484000140293e-177, 1.1294061984896456875e-192, 2.2526486929936882202e-208, + 1.2464251916751375716e-160, 6.1977249484000140293e-177, 1.1294061984896456875e-192, 2.2526486929936882202e-208, + 5.3514239183991277695e-161, 6.1977249484000140293e-177, 1.1294061984896456875e-192, 2.2526486929936882202e-208, + 1.7950099192230045857e-161, -1.6991004655691153326e-177, -1.8567941091539589297e-193, -1.8074851186411640793e-209, + 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, + 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, + 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, + 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, + 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, + 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, + 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, + 2.9106774506606941983e-164, 5.1948630316441287936e-180, 9.6685396110091013832e-196, 1.7562785002189357559e-211, + 2.9106774506606941983e-164, 5.1948630316441287936e-180, 9.6685396110091013832e-196, 1.7562785002189357559e-211, + 2.9106774506606941983e-164, 5.1948630316441287936e-180, 9.6685396110091013832e-196, 1.7562785002189357559e-211, + 1.1741471776254777999e-164, 1.3389912474795150614e-180, 1.106784341445028435e-196, 3.3045982549756583552e-212, + 3.0588204110786950436e-165, 3.7502330143836152136e-181, 3.6564932749519464998e-198, 3.7097125405852507464e-214, + 3.0588204110786950436e-165, 3.7502330143836152136e-181, 3.6564932749519464998e-198, 3.7097125405852507464e-214, + 8.8815756978467430465e-166, 1.3403131492807310959e-181, 3.6564932749519464998e-198, 3.7097125405852507464e-214, + 8.8815756978467430465e-166, 1.3403131492807310959e-181, 3.6564932749519464998e-198, 3.7097125405852507464e-214, + 3.4549185946116918017e-166, 1.3535321672928907047e-182, 3.1205762277848031878e-199, -3.3569248349832580936e-217, + 7.4159004299416557678e-167, 1.3535321672928907047e-182, 3.1205762277848031878e-199, -3.3569248349832580936e-217, + 7.4159004299416557678e-167, 1.3535321672928907047e-182, 3.1205762277848031878e-199, -3.3569248349832580936e-217, + 6.3257905089784152346e-168, 3.5607241064750984115e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, + 6.3257905089784152346e-168, 3.5607241064750984115e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, + 6.3257905089784152346e-168, 3.5607241064750984115e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, + 6.3257905089784152346e-168, 3.5607241064750984115e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, + 2.0862146470760309789e-168, -1.146150630053972131e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, + 2.0862146470760309789e-168, -1.146150630053972131e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, + 1.026320681600434562e-168, 1.2072867382105631402e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, + 4.9637369886263658882e-169, 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, + 2.3140020749373754342e-169, 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, + 9.8913461809288020723e-170, 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, + 3.2670088967063259373e-170, 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, + 3.2670088967063259373e-170, 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, + 1.6109245756507072713e-170, -6.2044048008378732802e-187, -5.4322544592823556944e-203, 4.2491789852161138683e-219, + 7.8288241512289757055e-171, 1.2181824638728806485e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, + 3.6886133485899290404e-171, 2.9887099189454666024e-187, 4.774153170641553462e-203, 4.2491789852161138683e-219, + 1.6185079472704052482e-171, 2.9887099189454666024e-187, 4.774153170641553462e-203, 4.2491789852161138683e-219, + 5.8345524661064358191e-172, 6.9043123899963188689e-188, -3.2905064432040069127e-204, -9.1795828160190082842e-224, + 6.5928896280762691321e-173, 1.1586156901317304854e-188, -1.0100405885278530137e-205, -9.1795828160190082842e-224, + 6.5928896280762691321e-173, 1.1586156901317304854e-188, -1.0100405885278530137e-205, -9.1795828160190082842e-224, + 6.5928896280762691321e-173, 1.1586156901317304854e-188, -1.0100405885278530137e-205, -9.1795828160190082842e-224, + 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.332109341809626019e-207, -9.1795828160190082842e-224, + 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.332109341809626019e-207, -9.1795828160190082842e-224, + 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.332109341809626019e-207, -9.1795828160190082842e-224, + 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.332109341809626019e-207, -9.1795828160190082842e-224, + 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.332109341809626019e-207, -9.1795828160190082842e-224, + 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.332109341809626019e-207, -9.1795828160190082842e-224, + 2.2730883653953564668e-175, 2.7431118386590483722e-191, -1.332109341809626019e-207, -9.1795828160190082842e-224, + 2.2730883653953564668e-175, 2.7431118386590483722e-191, -1.332109341809626019e-207, -9.1795828160190082842e-224, + 2.2730883653953564668e-175, 2.7431118386590483722e-191, -1.332109341809626019e-207, -9.1795828160190082842e-224, + 1.0095962991602958391e-175, -6.2404128071707654958e-193, 3.0593092910744445285e-209, 5.4622616159087170031e-225, + 3.7785026604276538491e-176, -6.2404128071707654958e-193, 3.0593092910744445285e-209, 5.4622616159087170031e-225, + 6.1977249484000140293e-177, 1.1294061984896456875e-192, 2.2526486929936882202e-208, -5.3441928036578162463e-225, + 6.1977249484000140293e-177, 1.1294061984896456875e-192, 2.2526486929936882202e-208, -5.3441928036578162463e-225, + 6.1977249484000140293e-177, 1.1294061984896456875e-192, 2.2526486929936882202e-208, -5.3441928036578162463e-225, + 2.2493122414154495675e-177, 2.5268245888628466632e-193, 3.0593092910744445285e-209, 5.4622616159087170031e-225, + 2.7510588792316711745e-178, 3.3501523985444386676e-194, 6.2591208621664049475e-210, 5.9034406125450500218e-227, + 2.7510588792316711745e-178, 3.3501523985444386676e-194, 6.2591208621664049475e-210, 5.9034406125450500218e-227, + 2.7510588792316711745e-178, 3.3501523985444386676e-194, 6.2591208621664049475e-210, 5.9034406125450500218e-227, + 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, 9.9192633285681635836e-229, + 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, 9.9192633285681635836e-229, + 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, 9.9192633285681635836e-229, + 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, 9.9192633285681635836e-229, + 1.2906606599973359683e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, 9.9192633285681635836e-229, + 5.1948630316441287936e-180, 9.6685396110091013832e-196, 1.7562785002189355449e-211, 1.6821693549018732055e-227, + 1.3389912474795150614e-180, 1.106784341445028435e-196, 3.3045982549756578275e-212, 6.2685154049107876715e-228, + 1.3389912474795150614e-180, 1.106784341445028435e-196, 3.3045982549756578275e-212, 6.2685154049107876715e-228, + 3.7502330143836152136e-181, 3.6564932749519464998e-198, 3.7097125405852507464e-214, 2.5658818466966882188e-231, + 3.7502330143836152136e-181, 3.6564932749519464998e-198, 3.7097125405852507464e-214, 2.5658818466966882188e-231, + 1.3403131492807310959e-181, 3.6564932749519464998e-198, 3.7097125405852507464e-214, 2.5658818466966882188e-231, + 1.3535321672928907047e-182, 3.1205762277848031878e-199, -3.3569248349832580936e-217, -1.0577661142165146927e-233, + 1.3535321672928907047e-182, 3.1205762277848031878e-199, -3.3569248349832580936e-217, -1.0577661142165146927e-233, + 1.3535321672928907047e-182, 3.1205762277848031878e-199, -3.3569248349832580936e-217, -1.0577661142165146927e-233, + 1.3535321672928907047e-182, 3.1205762277848031878e-199, -3.3569248349832580936e-217, -1.0577661142165146927e-233, + 6.0043220944823941786e-183, 3.1205762277848031878e-199, -3.3569248349832580936e-217, -1.0577661142165146927e-233, + 2.2388223052591377446e-183, 3.1205762277848031878e-199, -3.3569248349832580936e-217, -1.0577661142165146927e-233, + 3.5607241064750984115e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 3.5607241064750984115e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 3.5607241064750984115e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 1.2072867382105631402e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 1.2181824638728806485e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 2.9887099189454666024e-187, 4.774153170641553462e-203, 4.2491789852161132393e-219, 7.4467067939231424594e-235, + 2.9887099189454666024e-187, 4.774153170641553462e-203, 4.2491789852161132393e-219, 7.4467067939231424594e-235, + 6.9043123899963188689e-188, -3.2905064432040069127e-204, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 6.9043123899963188689e-188, -3.2905064432040069127e-204, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 1.1586156901317304854e-188, -1.0100405885278530137e-205, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 1.1586156901317304854e-188, -1.0100405885278530137e-205, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 1.1586156901317304854e-188, -1.0100405885278530137e-205, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 4.4040360264865697732e-189, -1.0100405885278530137e-205, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 8.129755890712020335e-190, 9.8339840169166049336e-206, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 8.129755890712020335e-190, 9.8339840169166049336e-206, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 8.129755890712020335e-190, 9.8339840169166049336e-206, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 3.6409303439428119063e-190, -1.332109341809626019e-207, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 1.3965175705582071936e-190, -1.332109341809626019e-207, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 2.7431118386590483722e-191, -1.332109341809626019e-207, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 2.7431118386590483722e-191, -1.332109341809626019e-207, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 2.7431118386590483722e-191, -1.332109341809626019e-207, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 1.3403538552936701153e-191, 1.7826390804083638359e-207, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 6.389748636109812983e-192, 2.2526486929936882202e-208, -5.3441928036578156465e-225, -7.741539335184153052e-241, + 2.8828536776963681193e-192, 2.2526486929936882202e-208, -5.3441928036578156465e-225, -7.741539335184153052e-241, + 1.1294061984896456875e-192, 2.2526486929936882202e-208, -5.3441928036578156465e-225, -7.741539335184153052e-241, + 2.5268245888628466632e-193, 3.0593092910744445285e-209, 5.4622616159087170031e-225, 4.2560351759808952526e-241, + 2.5268245888628466632e-193, 3.0593092910744445285e-209, 5.4622616159087170031e-225, 4.2560351759808952526e-241, + 3.3501523985444386676e-194, 6.2591208621664049475e-210, 5.9034406125450490845e-227, 1.3186893776791012681e-242, + 3.3501523985444386676e-194, 6.2591208621664049475e-210, 5.9034406125450490845e-227, 1.3186893776791012681e-242, + 3.3501523985444386676e-194, 6.2591208621664049475e-210, 5.9034406125450490845e-227, 1.3186893776791012681e-242, + 6.1039071228393547627e-195, 1.7562785002189355449e-211, 1.6821693549018732055e-227, -8.7276385348052817035e-244, + 6.1039071228393547627e-195, 1.7562785002189355449e-211, 1.6821693549018732055e-227, -8.7276385348052817035e-244, + 6.1039071228393547627e-195, 1.7562785002189355449e-211, 1.6821693549018732055e-227, -8.7276385348052817035e-244, + 2.6792050150137250131e-195, 1.7562785002189355449e-211, 1.6821693549018732055e-227, -8.7276385348052817035e-244, + 9.6685396110091013832e-196, 1.7562785002189355449e-211, 1.6821693549018732055e-227, -8.7276385348052817035e-244, + 2.0416567491425607157e-177, 6.0959078275963141821e-193, 1.156336993964950812e-208, 2.7126166236326293347e-224, + 2.0416567491425607157e-177, 6.0959078275963141821e-193, 1.156336993964950812e-208, 2.7126166236326293347e-224, + 2.0416567491425607157e-177, 6.0959078275963141821e-193, 1.156336993964950812e-208, 2.7126166236326293347e-224, + 6.7450395650278649168e-179, 6.8432117823206978686e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, + 6.7450395650278649168e-179, 6.8432117823206978686e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, + 6.7450395650278649168e-179, 6.8432117823206978686e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, + 6.7450395650278649168e-179, 6.8432117823206978686e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, + 6.7450395650278649168e-179, 6.8432117823206978686e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, + 5.756447103644822603e-180, -6.1924333305615830735e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 5.756447103644822603e-180, -6.1924333305615830735e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 5.756447103644822603e-180, -6.1924333305615830735e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 5.756447103644822603e-180, -6.1924333305615830735e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 1.9005753194802080146e-180, -6.1924333305615830735e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 1.9005753194802080146e-180, -6.1924333305615830735e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 9.3660737343905436753e-181, -6.1924333305615830735e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 4.5462340041847754398e-181, -6.1924333305615830735e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 2.1363141390818913221e-181, -6.1924333305615830735e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 9.3135420653044926323e-182, -6.1924333305615830735e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 3.2887424025472810002e-182, 7.185309278132283136e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 2.7634257116867652192e-183, 4.9643797378534984559e-199, -9.4699347169310243473e-216, -9.2331809177749095611e-233, + 2.7634257116867652192e-183, 4.9643797378534984559e-199, -9.4699347169310243473e-216, -9.2331809177749095611e-233, + 2.7634257116867652192e-183, 4.9643797378534984559e-199, -9.4699347169310243473e-216, -9.2331809177749095611e-233, + 2.7634257116867652192e-183, 4.9643797378534984559e-199, -9.4699347169310243473e-216, -9.2331809177749095611e-233, + 8.806758170751374203e-184, 7.8383517263666503337e-200, 1.3736749441945438342e-215, -9.2331809177749095611e-233, + 8.806758170751374203e-184, 7.8383517263666503337e-200, 1.3736749441945438342e-215, -9.2331809177749095611e-233, + 4.0998834342223036605e-184, 7.8383517263666503337e-200, 1.3736749441945438342e-215, -9.2331809177749095611e-233, + 1.7464460659577689118e-184, 2.612671019845610006e-200, 2.1334073625072069974e-216, -9.2331809177749095611e-233, + 5.697273818255015375e-185, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 5.697273818255015375e-185, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 2.755477107924346286e-185, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 1.2845787527590117414e-185, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 5.4912957517634446918e-186, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 1.8140498638501083305e-186, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 1.8140498638501083305e-186, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 8.9473839187177424013e-187, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 4.3508265588260719497e-187, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 2.0525478788802367239e-187, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 9.0340853890731911095e-188, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 3.288388689208603045e-188, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 4.1554033927630885323e-189, -9.8582956929636044137e-206, -1.4280619485269765742e-221, 1.2171222696290252021e-237, + 4.1554033927630885323e-189, -9.8582956929636044137e-206, -1.4280619485269765742e-221, 1.2171222696290252021e-237, + 4.1554033927630885323e-189, -9.8582956929636044137e-206, -1.4280619485269765742e-221, 1.2171222696290252021e-237, + 5.643429553477207926e-190, 1.0076094209231528444e-205, 7.8509991660024955813e-222, 1.2171222696290252021e-237, + 5.643429553477207926e-190, 1.0076094209231528444e-205, 7.8509991660024955813e-222, 1.2171222696290252021e-237, + 5.643429553477207926e-190, 1.0076094209231528444e-205, 7.8509991660024955813e-222, 1.2171222696290252021e-237, + 1.1546040067079994973e-190, 1.0889925813396166947e-207, 2.4325525462765697993e-223, -1.1429360314275701698e-239, + 1.1546040067079994973e-190, 1.0889925813396166947e-207, 2.4325525462765697993e-223, -1.1429360314275701698e-239, + 3.2397620015697148712e-192, 3.1030547578511949035e-208, -1.609965144193984205e-224, -1.8313007053436627876e-240, + 3.2397620015697148712e-192, 3.1030547578511949035e-208, -1.609965144193984205e-224, -1.8313007053436627876e-240, + 3.2397620015697148712e-192, 3.1030547578511949035e-208, -1.609965144193984205e-224, -1.8313007053436627876e-240, + 3.2397620015697148712e-192, 3.1030547578511949035e-208, -1.609965144193984205e-224, -1.8313007053436627876e-240, + 3.2397620015697148712e-192, 3.1030547578511949035e-208, -1.609965144193984205e-224, -1.8313007053436627876e-240, + 3.2397620015697148712e-192, 3.1030547578511949035e-208, -1.609965144193984205e-224, -1.8313007053436627876e-240, + 1.4863145223629928288e-192, -7.9038076992129241506e-209, -1.609965144193984205e-224, -1.8313007053436627876e-240, + 6.0959078275963141821e-193, 1.156336993964950812e-208, 2.7126166236326293347e-224, -1.8313007053436627876e-240, + 1.712289129579509076e-193, 1.8297811202182925249e-209, 1.1003018740995688645e-226, 5.827891678485165325e-243, + 1.712289129579509076e-193, 1.8297811202182925249e-209, 1.1003018740995688645e-226, 5.827891678485165325e-243, + 6.1638445507530779946e-194, -6.0361608463951204924e-210, 1.1003018740995688645e-226, 5.827891678485165325e-243, + 6.8432117823206978686e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.029900079464340522e-245, + 6.8432117823206978686e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.029900079464340522e-245, + 6.8432117823206978686e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.029900079464340522e-245, + 6.8432117823206978686e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.029900079464340522e-245, + 3.418509674495068119e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.029900079464340522e-245, + 1.7061586205822532442e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.029900079464340522e-245, + 8.499830936258458068e-196, 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.029900079464340522e-245, + 4.218953301476420881e-196, 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.029900079464340522e-245, + 2.0785144840854027628e-196, -1.9512340798794268979e-214, -3.6162764918921692779e-230, -2.8387319855193022476e-246, + 1.008295075389893466e-196, -1.9512340798794268979e-214, -3.6162764918921692779e-230, -2.8387319855193022476e-246, + 4.7318537104213881764e-197, -1.9512340798794268979e-214, -3.6162764918921692779e-230, -2.8387319855193022476e-246, + 2.0563051886826149345e-197, -1.9512340798794268979e-214, -3.6162764918921692779e-230, -2.8387319855193022476e-246, + 7.185309278132283136e-198, -1.9512340798794268979e-214, -3.6162764918921692779e-230, -2.8387319855193022476e-246, + 4.9643797378534984559e-199, -9.4699347169310243473e-216, -9.2331809177749077733e-233, -1.4042876247421728101e-248, + 4.9643797378534984559e-199, -9.4699347169310243473e-216, -9.2331809177749077733e-233, -1.4042876247421728101e-248, + 4.9643797378534984559e-199, -9.4699347169310243473e-216, -9.2331809177749077733e-233, -1.4042876247421728101e-248, + 4.9643797378534984559e-199, -9.4699347169310243473e-216, -9.2331809177749077733e-233, -1.4042876247421728101e-248, + 7.8383517263666503337e-200, 1.3736749441945438342e-215, -9.2331809177749077733e-233, -1.4042876247421728101e-248, + 7.8383517263666503337e-200, 1.3736749441945438342e-215, -9.2331809177749077733e-233, -1.4042876247421728101e-248, + 7.8383517263666503337e-200, 1.3736749441945438342e-215, -9.2331809177749077733e-233, -1.4042876247421728101e-248, + 2.612671019845610006e-200, 2.1334073625072069974e-216, -9.2331809177749077733e-233, -1.4042876247421728101e-248, + 2.612671019845610006e-200, 2.1334073625072069974e-216, -9.2331809177749077733e-233, -1.4042876247421728101e-248, + 1.306250843215349634e-200, 2.1334073625072069974e-216, -9.2331809177749077733e-233, -1.4042876247421728101e-248, + 6.5304075490021959302e-201, 6.8298960257742791824e-217, 6.8696910062179237095e-233, 3.8349029251851101018e-249, + 3.2643571074265457254e-201, -4.2219277387461470355e-218, -1.753154605289404553e-234, -7.5861268822635538093e-251, + 1.6313318866387202604e-201, -4.2219277387461470355e-218, -1.753154605289404553e-234, -7.5861268822635538093e-251, + 8.1481927624480752786e-202, -4.2219277387461470355e-218, -1.753154605289404553e-234, -7.5861268822635538093e-251, + 4.0656297104785107096e-202, 4.8431832608149701961e-218, 8.3111403472061145651e-234, 1.6001805286092554504e-249, + 2.0243481844937293316e-202, 3.1062776103441183191e-219, 7.6291913283447536617e-235, 2.0347903074934629333e-250, + 1.0037074215013384159e-202, 3.1062776103441183191e-219, 7.6291913283447536617e-235, 2.0347903074934629333e-250, + 4.9338704000514295811e-203, 3.1062776103441183191e-219, 7.6291913283447536617e-235, 2.0347903074934629333e-250, + 2.3822684925704522921e-203, 3.1062776103441183191e-219, 7.6291913283447536617e-235, 2.0347903074934629333e-250, + 1.1064675388299639308e-203, 2.7343042298126957741e-220, 5.5273393987134252385e-236, 1.1432574793608782288e-251, + 4.6856706195971960852e-204, 2.7343042298126957741e-220, 5.5273393987134252385e-236, 1.1432574793608782288e-251, + 1.4961682352459748279e-204, -8.0675475439086544798e-221, -3.6970842501441777651e-237, -5.7032870362481275794e-253, + 1.4961682352459748279e-204, -8.0675475439086544798e-221, -3.6970842501441777651e-237, -5.7032870362481275794e-253, + 6.9879263915816924805e-205, 9.6377473771091526132e-221, 1.5959741828948633012e-236, 2.7031904319843495713e-252, + 3.0010484111426663515e-205, 7.8509991660024955813e-222, 1.2171222696290252021e-237, -2.4742181023285720738e-254, + 1.0076094209231528444e-205, 7.8509991660024955813e-222, 1.2171222696290252021e-237, -2.4742181023285720738e-254, + 1.0889925813396166947e-207, 2.4325525462765697993e-223, -1.1429360314275701698e-239, 8.3218722366085688343e-256, + 1.0889925813396166947e-207, 2.4325525462765697993e-223, -1.1429360314275701698e-239, 8.3218722366085688343e-256, + 1.0889925813396166947e-207, 2.4325525462765697993e-223, -1.1429360314275701698e-239, 8.3218722366085688343e-256, + 1.0889925813396166947e-207, 2.4325525462765697993e-223, -1.1429360314275701698e-239, 8.3218722366085688343e-256, + 1.0889925813396166947e-207, 2.4325525462765697993e-223, -1.1429360314275701698e-239, 8.3218722366085688343e-256, + 1.0889925813396166947e-207, 2.4325525462765697993e-223, -1.1429360314275701698e-239, 8.3218722366085688343e-256, + 1.0889925813396166947e-207, 2.4325525462765697993e-223, -1.1429360314275701698e-239, 8.3218722366085688343e-256, + 3.1030547578511949035e-208, -1.609965144193984205e-224, -1.8313007053436625212e-240, -2.3341145329525059632e-256, + 3.1030547578511949035e-208, -1.609965144193984205e-224, -1.8313007053436625212e-240, -2.3341145329525059632e-256, + 1.156336993964950812e-208, 2.7126166236326293347e-224, -1.8313007053436625212e-240, -2.3341145329525059632e-256, + 1.8297811202182925249e-209, 1.1003018740995688645e-226, 5.827891678485165325e-243, -3.1174271110208206547e-259, + 1.8297811202182925249e-209, 1.1003018740995688645e-226, 5.827891678485165325e-243, -3.1174271110208206547e-259, + 1.8297811202182925249e-209, 1.1003018740995688645e-226, 5.827891678485165325e-243, -3.1174271110208206547e-259, + 6.1308251778939023781e-210, 1.1003018740995688645e-226, 5.827891678485165325e-243, -3.1174271110208206547e-259, + 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 2.3568521170701555846e-212, -7.7818310317651142243e-229, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 1.1686698881356804311e-212, 1.8601114328504743806e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 5.7457877366844311816e-213, 5.409641648369814791e-229, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 2.7753321643482446169e-213, -1.1860946916976500828e-229, 6.3146909508553973881e-246, 1.2573885592501532045e-261, + 1.290104378180150675e-213, 2.1117734783360818049e-229, 4.2928382696354204061e-245, -2.8075477999879273582e-261, + 5.4749048509610403382e-214, 4.6283939331921604413e-230, 6.3146909508553973881e-246, 1.2573885592501532045e-261, + 1.7618353855408067201e-214, 5.060587206499956961e-231, 5.9380161562121075096e-247, -1.2904053011746964278e-263, + 1.7618353855408067201e-214, 5.060587206499956961e-231, 5.9380161562121075096e-247, -1.2904053011746964278e-263, + 8.3356801918574821257e-215, 5.060587206499956961e-231, 5.9380161562121075096e-247, -1.2904053011746964278e-263, + 3.6943433600821895879e-215, 5.060587206499956961e-231, 5.9380161562121075096e-247, -1.2904053011746964278e-263, + 1.3736749441945438342e-215, -9.2331809177749077733e-233, -1.4042876247421726117e-248, -9.9505977179164858712e-265, + 2.1334073625072069974e-216, -9.2331809177749077733e-233, -1.4042876247421726117e-248, -9.9505977179164858712e-265, + 2.1334073625072069974e-216, -9.2331809177749077733e-233, -1.4042876247421726117e-248, -9.9505977179164858712e-265, + 2.1334073625072069974e-216, -9.2331809177749077733e-233, -1.4042876247421726117e-248, -9.9505977179164858712e-265, + 6.8298960257742791824e-217, 6.8696910062179237095e-233, 3.8349029251851101018e-249, -2.6436684620390282645e-267, + 6.8298960257742791824e-217, 6.8696910062179237095e-233, 3.8349029251851101018e-249, -2.6436684620390282645e-267, + 3.2038516259498326923e-217, -1.1817449557784924788e-233, -6.3454186796659920093e-250, -2.6436684620390282645e-267, + 1.3908294260376086421e-217, 2.8439730252197153919e-233, 3.8349029251851101018e-249, -2.6436684620390282645e-267, + 4.8431832608149701961e-218, 8.3111403472061145651e-234, 1.6001805286092554504e-249, -2.6436684620390282645e-267, + 3.1062776103441183191e-219, 7.6291913283447536617e-235, 2.0347903074934629333e-250, -2.6436684620390282645e-267, + 3.1062776103441183191e-219, 7.6291913283447536617e-235, 2.0347903074934629333e-250, -2.6436684620390282645e-267, + 3.1062776103441183191e-219, 7.6291913283447536617e-235, 2.0347903074934629333e-250, -2.6436684620390282645e-267, + 3.1062776103441183191e-219, 7.6291913283447536617e-235, 2.0347903074934629333e-250, -2.6436684620390282645e-267, + 2.7343042298126957741e-220, 5.5273393987134252385e-236, 1.1432574793608780349e-251, 1.2329569415922591084e-267, + 2.7343042298126957741e-220, 5.5273393987134252385e-236, 1.1432574793608780349e-251, 1.2329569415922591084e-267, + 2.7343042298126957741e-220, 5.5273393987134252385e-236, 1.1432574793608780349e-251, 1.2329569415922591084e-267, + 2.7343042298126957741e-220, 5.5273393987134252385e-236, 1.1432574793608780349e-251, 1.2329569415922591084e-267, + 9.6377473771091526132e-221, 1.5959741828948633012e-236, 2.7031904319843490867e-252, 2.638005906844372114e-268, + 7.8509991660024955813e-222, 1.2171222696290252021e-237, -2.4742181023285720738e-254, -1.2030990169203137715e-270, + 7.8509991660024955813e-222, 1.2171222696290252021e-237, -2.4742181023285720738e-254, -1.2030990169203137715e-270, + 7.8509991660024955813e-222, 1.2171222696290252021e-237, -2.4742181023285720738e-254, -1.2030990169203137715e-270, + 7.8509991660024955813e-222, 1.2171222696290252021e-237, -2.4742181023285720738e-254, -1.2030990169203137715e-270, + 2.318094503184431479e-222, -1.1429360314275701698e-239, 8.3218722366085688343e-256, -2.0046830753539155726e-272, + 2.318094503184431479e-222, -1.1429360314275701698e-239, 8.3218722366085688343e-256, -2.0046830753539155726e-272, + 9.3486833747991514629e-223, -1.1429360314275701698e-239, 8.3218722366085688343e-256, -2.0046830753539155726e-272, + 2.4325525462765697993e-223, -1.1429360314275701698e-239, 8.3218722366085688343e-256, -2.0046830753539155726e-272, + 2.4325525462765697993e-223, -1.1429360314275701698e-239, 8.3218722366085688343e-256, -2.0046830753539155726e-272, + 7.0351983914592419146e-224, 7.766758903588374524e-240, 8.3218722366085688343e-256, -2.0046830753539155726e-272, + 7.0351983914592419146e-224, 7.766758903588374524e-240, 8.3218722366085688343e-256, -2.0046830753539155726e-272, + 2.7126166236326293347e-224, -1.8313007053436625212e-240, -2.3341145329525056675e-256, -2.0046830753539155726e-272, + 5.5132573971932232487e-225, 5.6821419688934674008e-241, 3.2988215943776273615e-257, 2.1353977370878701046e-273, + 5.5132573971932232487e-225, 5.6821419688934674008e-241, 3.2988215943776273615e-257, 2.1353977370878701046e-273, + 1.1003018740995688645e-226, 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, + 1.1003018740995688645e-226, 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, + 1.1003018740995688645e-226, 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, + 1.1003018740995688645e-226, 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, + 1.1003018740995688645e-226, 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, + 1.1003018740995688645e-226, 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, + 2.560476225709334075e-227, 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, + 2.560476225709334075e-227, 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, + 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, -1.472095602234059958e-277, + 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, -1.472095602234059958e-277, + 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, -1.472095602234059958e-277, + 1.8601114328504743806e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, -1.472095602234059958e-277, + 5.409641648369814791e-229, -3.0299000794643401155e-245, -2.8075477999879273582e-261, -1.472095602234059958e-277, + 5.409641648369814791e-229, -3.0299000794643401155e-245, -2.8075477999879273582e-261, -1.472095602234059958e-277, + 2.1117734783360818049e-229, 4.2928382696354204061e-245, -2.8075477999879273582e-261, -1.472095602234059958e-277, + 4.6283939331921604413e-230, 6.3146909508553973881e-246, 1.2573885592501529789e-261, 3.0408903374280139822e-277, + 4.6283939331921604413e-230, 6.3146909508553973881e-246, 1.2573885592501529789e-261, 3.0408903374280139822e-277, + 5.060587206499956961e-231, 5.9380161562121075096e-247, -1.2904053011746964278e-263, 8.7279092175580820317e-280, + 5.060587206499956961e-231, 5.9380161562121075096e-247, -1.2904053011746964278e-263, 8.7279092175580820317e-280, + 5.060587206499956961e-231, 5.9380161562121075096e-247, -1.2904053011746964278e-263, 8.7279092175580820317e-280, + 5.060587206499956961e-231, 5.9380161562121075096e-247, -1.2904053011746964278e-263, 8.7279092175580820317e-280, + 2.4841276986611042098e-231, 2.1712682097791944335e-248, 2.9746046415267896827e-264, -8.6516445844406224413e-282, + 1.1958979447416775482e-231, 2.1712682097791944335e-248, 2.9746046415267896827e-264, -8.6516445844406224413e-282, + 5.5178306778196421733e-232, 2.1712682097791944335e-248, 2.9746046415267896827e-264, -8.6516445844406224413e-282, + 2.2972562930210755192e-232, 2.1712682097791944335e-248, 2.9746046415267896827e-264, -8.6516445844406224413e-282, + 6.8696910062179237095e-233, 3.8349029251851101018e-249, -2.6436684620390282645e-267, -4.3807022524130141006e-284, + 6.8696910062179237095e-233, 3.8349029251851101018e-249, -2.6436684620390282645e-267, -4.3807022524130141006e-284, + 2.8439730252197153919e-233, 3.8349029251851101018e-249, -2.6436684620390282645e-267, -4.3807022524130141006e-284, + 8.3111403472061145651e-234, 1.6001805286092554504e-249, -2.6436684620390282645e-267, -4.3807022524130141006e-284, + 8.3111403472061145651e-234, 1.6001805286092554504e-249, -2.6436684620390282645e-267, -4.3807022524130141006e-284, + 3.2789928709583552854e-234, 4.8281933032132812475e-250, -2.6436684620390282645e-267, -4.3807022524130141006e-284, + 7.6291913283447536617e-235, 2.0347903074934629333e-250, -2.6436684620390282645e-267, -4.3807022524130141006e-284, + 7.6291913283447536617e-235, 2.0347903074934629333e-250, -2.6436684620390282645e-267, -4.3807022524130141006e-284, + 1.3390069830350552605e-235, -6.026193929640082176e-252, -7.0535576022338457803e-268, -4.3807022524130141006e-284, + 1.3390069830350552605e-235, -6.026193929640082176e-252, -7.0535576022338457803e-268, -4.3807022524130141006e-284, + 1.3390069830350552605e-235, -6.026193929640082176e-252, -7.0535576022338457803e-268, -4.3807022524130141006e-284, + 5.5273393987134252385e-236, 1.1432574793608780349e-251, 1.2329569415922591084e-267, -4.3807022524130141006e-284, + 1.5959741828948633012e-236, 2.7031904319843490867e-252, 2.638005906844371576e-268, 6.3790946999826013345e-284, + 1.5959741828948633012e-236, 2.7031904319843490867e-252, 2.638005906844371576e-268, 6.3790946999826013345e-284, + 6.1313287894022281692e-237, 5.2084434157824127104e-253, 2.1511502957481757317e-269, 3.2670891426006739096e-285, + 1.2171222696290252021e-237, -2.4742181023285720738e-254, -1.2030990169203137715e-270, -9.5347405022956042207e-287, + 1.2171222696290252021e-237, -2.4742181023285720738e-254, -1.2030990169203137715e-270, -9.5347405022956042207e-287, + 1.2171222696290252021e-237, -2.4742181023285720738e-254, -1.2030990169203137715e-270, -9.5347405022956042207e-287, + 6.0284645465737476297e-238, -2.4742181023285720738e-254, -1.2030990169203137715e-270, -9.5347405022956042207e-287, + 2.9570854717154947523e-238, 4.3456134301905148502e-254, 6.3684349745470443788e-270, -9.5347405022956042207e-287, + 1.4213959342863689955e-238, 9.3569766393097138822e-255, 2.5826679788133653036e-270, -9.5347405022956042207e-287, + 6.5355116557180594664e-239, 9.3569766393097138822e-255, 2.5826679788133653036e-270, -9.5347405022956042207e-287, + 2.6962878121452450746e-239, 8.3218722366085688343e-256, -2.0046830753539152442e-272, -3.4057806738724185961e-288, + 7.766758903588374524e-240, 8.3218722366085688343e-256, -2.0046830753539152442e-272, -3.4057806738724185961e-288, + 7.766758903588374524e-240, 8.3218722366085688343e-256, -2.0046830753539152442e-272, -3.4057806738724185961e-288, + 2.9677290991223565342e-240, -2.3341145329525056675e-256, -2.0046830753539152442e-272, -3.4057806738724185961e-288, + 5.6821419688934674008e-241, 3.2988215943776273615e-257, 2.1353977370878701046e-273, -1.2215123283371736879e-289, + 5.6821419688934674008e-241, 3.2988215943776273615e-257, 2.1353977370878701046e-273, -1.2215123283371736879e-289, + 5.6821419688934674008e-241, 3.2988215943776273615e-257, 2.1353977370878701046e-273, -1.2215123283371736879e-289, + 2.6827483411022054912e-241, 3.2988215943776273615e-257, 2.1353977370878701046e-273, -1.2215123283371736879e-289, + 1.1830515272065748694e-241, -3.117427111020820077e-259, -5.9718623963762788119e-275, 6.1155422068568954053e-291, + 4.3320312025875939195e-242, -3.117427111020820077e-259, -5.9718623963762788119e-275, 6.1155422068568954053e-291, + 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, 6.1155422068568954053e-291, + 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, 6.1155422068568954053e-291, + 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, 6.1155422068568954053e-291, + 1.1413391350613183311e-243, -5.1586784110844895013e-260, -1.9524039360882352712e-276, -2.9779654517181717279e-292, + 1.1413391350613183311e-243, -5.1586784110844895013e-260, -1.9524039360882352712e-276, -2.9779654517181717279e-292, + 1.1413391350613183311e-243, -5.1586784110844895013e-260, -1.9524039360882352712e-276, -2.9779654517181717279e-292, + 5.5552006713333735927e-244, 7.8491179384773690214e-260, -1.9524039360882352712e-276, -2.9779654517181717279e-292, + 2.6261053316934700345e-244, 1.345219763696439399e-260, 1.6579848156414234801e-276, 1.0303712682997740506e-292, + 1.1615576618735179302e-244, 1.345219763696439399e-260, 1.6579848156414234801e-276, 1.0303712682997740506e-292, + 4.2928382696354204061e-245, -2.8075477999879273582e-261, -1.472095602234059958e-277, 2.8287088295287585094e-294, + 6.3146909508553973881e-246, 1.2573885592501529789e-261, 3.0408903374280139822e-277, 2.8287088295287585094e-294, + 6.3146909508553973881e-246, 1.2573885592501529789e-261, 3.0408903374280139822e-277, 2.8287088295287585094e-294, + 6.3146909508553973881e-246, 1.2573885592501529789e-261, 3.0408903374280139822e-277, 2.8287088295287585094e-294, + 1.7379794826680480784e-246, 2.4115446944063306384e-262, 2.202741251392177696e-278, 2.8287088295287585094e-294, + 1.7379794826680480784e-246, 2.4115446944063306384e-262, 2.202741251392177696e-278, 2.8287088295287585094e-294, + 5.9380161562121075096e-247, -1.2904053011746964278e-263, 8.7279092175580810531e-280, 8.8634899828990930877e-296, + 2.1712682097791944335e-248, 2.9746046415267896827e-264, -8.6516445844406224413e-282, -5.0528699238150276549e-299, + 2.1712682097791944335e-248, 2.9746046415267896827e-264, -8.6516445844406224413e-282, -5.0528699238150276549e-299, + 2.1712682097791944335e-248, 2.9746046415267896827e-264, -8.6516445844406224413e-282, -5.0528699238150276549e-299, + 2.1712682097791944335e-248, 2.9746046415267896827e-264, -8.6516445844406224413e-282, -5.0528699238150276549e-299, + 2.1712682097791944335e-248, 2.9746046415267896827e-264, -8.6516445844406224413e-282, -5.0528699238150276549e-299, + 3.8349029251851101018e-249, -2.6436684620390282645e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 3.8349029251851101018e-249, -2.6436684620390282645e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 3.8349029251851101018e-249, -2.6436684620390282645e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 1.6001805286092554504e-249, -2.6436684620390282645e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 4.8281933032132812475e-250, -2.6436684620390282645e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 4.8281933032132812475e-250, -2.6436684620390282645e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 2.0347903074934629333e-250, -2.6436684620390282645e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 6.3808880963355377617e-251, -2.6436684620390282645e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 6.3808880963355377617e-251, -2.6436684620390282645e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 2.8891343516857640937e-251, 5.1095823452235464813e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 1.1432574793608780349e-251, 1.2329569415922591084e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 2.7031904319843490867e-252, 2.638005906844371576e-268, 6.3790946999826013345e-284, -2.7456019707854725967e-300, + 2.7031904319843490867e-252, 2.638005906844371576e-268, 6.3790946999826013345e-284, -2.7456019707854725967e-300, + 5.2084434157824127104e-253, 2.1511502957481757317e-269, 3.2670891426006735363e-285, 2.4084160842482777461e-301, + 5.2084434157824127104e-253, 2.1511502957481757317e-269, 3.2670891426006735363e-285, 2.4084160842482777461e-301, + 5.2084434157824127104e-253, 2.1511502957481757317e-269, 3.2670891426006735363e-285, 2.4084160842482777461e-301, + 2.4805108027747776379e-253, 2.1511502957481757317e-269, 3.2670891426006735363e-285, 2.4084160842482777461e-301, + 1.1165444962709601017e-253, 2.1511502957481757317e-269, 3.2670891426006735363e-285, 2.4084160842482777461e-301, + 4.3456134301905148502e-254, 6.3684349745470443788e-270, -9.5347405022956030541e-287, -1.5805886663557401565e-302, + 9.3569766393097138822e-255, 2.5826679788133653036e-270, -9.5347405022956030541e-287, -1.5805886663557401565e-302, + 9.3569766393097138822e-255, 2.5826679788133653036e-270, -9.5347405022956030541e-287, -1.5805886663557401565e-302, + 8.3218722366085688343e-256, -2.0046830753539152442e-272, -3.4057806738724185961e-288, 2.3458177946667328156e-304, + 8.3218722366085688343e-256, -2.0046830753539152442e-272, -3.4057806738724185961e-288, 2.3458177946667328156e-304, + 8.3218722366085688343e-256, -2.0046830753539152442e-272, -3.4057806738724185961e-288, 2.3458177946667328156e-304, + 8.3218722366085688343e-256, -2.0046830753539152442e-272, -3.4057806738724185961e-288, 2.3458177946667328156e-304, + 2.9938788518280315834e-256, -2.0046830753539152442e-272, -3.4057806738724185961e-288, 2.3458177946667328156e-304, + 3.2988215943776273615e-257, 2.1353977370878701046e-273, -1.2215123283371736879e-289, 6.7342163555358599277e-306, + 3.2988215943776273615e-257, 2.1353977370878701046e-273, -1.2215123283371736879e-289, 6.7342163555358599277e-306, + 3.2988215943776273615e-257, 2.1353977370878701046e-273, -1.2215123283371736879e-289, 6.7342163555358599277e-306, + 3.2988215943776273615e-257, 2.1353977370878701046e-273, -1.2215123283371736879e-289, 6.7342163555358599277e-306, + 1.6338236616337094706e-257, 2.1353977370878701046e-273, -1.2215123283371736879e-289, 6.7342163555358599277e-306, + 8.0132469526175071002e-258, 2.8687869620228451614e-274, -1.9537812801257956865e-290, 1.0380272777574237546e-306, + 3.850752120757712373e-258, 2.8687869620228451614e-274, -1.9537812801257956865e-290, 1.0380272777574237546e-306, + 1.7695047048278150093e-258, 2.8687869620228451614e-274, -1.9537812801257956865e-290, 1.0380272777574237546e-306, + 7.2888099686286655858e-259, 5.581381609158630475e-275, 6.1155422068568946933e-291, 1.0380272777574237546e-306, + 2.0856914288039227544e-259, -1.9524039360882352712e-276, -2.9779654517181712829e-292, -3.000817432603284506e-308, + 2.0856914288039227544e-259, -1.9524039360882352712e-276, -2.9779654517181712829e-292, -3.000817432603284506e-308, + 7.8491179384773690214e-260, -1.9524039360882352712e-276, -2.9779654517181712829e-292, -3.000817432603284506e-308, + 1.345219763696439399e-260, 1.6579848156414234801e-276, 1.0303712682997738281e-292, 1.4493302844111182601e-308, + 1.345219763696439399e-260, 1.6579848156414234801e-276, 1.0303712682997738281e-292, 1.4493302844111182601e-308, + 1.345219763696439399e-260, 1.6579848156414234801e-276, 1.0303712682997738281e-292, 1.4493302844111182601e-308, + 5.3223249184882342185e-261, -1.472095602234059958e-277, 2.8287088295287585094e-294, -1.0874435234232647519e-310, + 1.2573885592501529789e-261, 3.0408903374280139822e-277, 2.8287088295287585094e-294, -1.0874435234232647519e-310, + 1.2573885592501529789e-261, 3.0408903374280139822e-277, 2.8287088295287585094e-294, -1.0874435234232647519e-310, + 2.4115446944063306384e-262, 2.202741251392177696e-278, 2.8287088295287585094e-294, -1.0874435234232647519e-310, + 2.4115446944063306384e-262, 2.202741251392177696e-278, 2.8287088295287585094e-294, -1.0874435234232647519e-310, + 2.4115446944063306384e-262, 2.202741251392177696e-278, 2.8287088295287585094e-294, -1.0874435234232647519e-310, + 1.1412520821444306741e-262, -6.1787496089661820348e-279, -3.028042329852615431e-295, -2.182740474438892116e-311, + 5.0610577601348040988e-263, 7.9243314524777990283e-279, -3.028042329852615431e-295, -2.182740474438892116e-311, + 1.8853262294800541881e-263, 8.7279092175580810531e-280, 8.8634899828990930877e-296, -9.8167844904532653004e-314, + 2.9746046415267896827e-264, -8.6516445844406224413e-282, -5.0528699238150265939e-299, -1.3288013265921760399e-314, + 2.9746046415267896827e-264, -8.6516445844406224413e-282, -5.0528699238150265939e-299, -1.3288013265921760399e-314, + 2.9746046415267896827e-264, -8.6516445844406224413e-282, -5.0528699238150265939e-299, -1.3288013265921760399e-314, + 9.8977243486757054781e-265, -8.6516445844406224413e-282, -5.0528699238150265939e-299, -1.3288013265921760399e-314, + 9.8977243486757054781e-265, -8.6516445844406224413e-282, -5.0528699238150265939e-299, -1.3288013265921760399e-314, + 4.9356438320276576408e-265, -8.6516445844406224413e-282, -5.0528699238150265939e-299, -1.3288013265921760399e-314, + 2.4546035737036337221e-265, -8.6516445844406224413e-282, -5.0528699238150265939e-299, -1.3288013265921760399e-314, + 1.2140834445416214873e-265, 1.8893435613692150014e-281, 3.0075895258731974416e-297, -9.8167844904532653004e-314, + 5.9382337996061564537e-266, 5.1208955146257653156e-282, -5.0528699238150265939e-299, -1.3288013265921760399e-314, + 2.8369334767011265554e-266, 5.1208955146257653156e-282, -5.0528699238150265939e-299, -1.3288013265921760399e-314, + 1.2862833152486119506e-266, 1.6777604898591683764e-282, -5.0528699238150265939e-299, -1.3288013265921760399e-314, + 5.1095823452235464813e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, -2.5539572388808429997e-317, + 1.2329569415922591084e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, -2.5539572388808429997e-317, + 1.2329569415922591084e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, -2.5539572388808429997e-317, + 2.638005906844371576e-268, 6.3790946999826013345e-284, -2.7456019707854725967e-300, -2.5539572388808429997e-317, + 2.638005906844371576e-268, 6.3790946999826013345e-284, -2.7456019707854725967e-300, -2.5539572388808429997e-317, + 2.1511502957481757317e-269, 3.2670891426006735363e-285, 2.4084160842482773317e-301, 5.7350888195772519812e-317, + 2.1511502957481757317e-269, 3.2670891426006735363e-285, 2.4084160842482773317e-301, 5.7350888195772519812e-317, + 2.1511502957481757317e-269, 3.2670891426006735363e-285, 2.4084160842482773317e-301, 5.7350888195772519812e-317, + 2.1511502957481757317e-269, 3.2670891426006735363e-285, 2.4084160842482773317e-301, 5.7350888195772519812e-317, + 6.3684349745470443788e-270, -9.5347405022956030541e-287, -1.5805886663557401565e-302, 3.6369654387311681856e-319, + 6.3684349745470443788e-270, -9.5347405022956030541e-287, -1.5805886663557401565e-302, 3.6369654387311681856e-319, + 2.5826679788133653036e-270, -9.5347405022956030541e-287, -1.5805886663557401565e-302, 3.6369654387311681856e-319, + 6.8978448094652555593e-271, 1.1480487920352081009e-286, 7.5257037990230704094e-303, 3.6369654387311681856e-319, + 6.8978448094652555593e-271, 1.1480487920352081009e-286, 7.5257037990230704094e-303, 3.6369654387311681856e-319, + 2.1656360647981577662e-271, 9.7287370902823839435e-288, 1.6928061833779524157e-303, 3.6369654387311681856e-319, + 2.1656360647981577662e-271, 9.7287370902823839435e-288, 1.6928061833779524157e-303, 3.6369654387311681856e-319, + 9.825838786313830552e-272, 9.7287370902823839435e-288, 1.6928061833779524157e-303, 3.6369654387311681856e-319, + 3.9105778554799569972e-272, 9.7287370902823839435e-288, 1.6928061833779524157e-303, 3.6369654387311681856e-319, + 9.5294739006302120482e-273, -1.2215123283371736879e-289, 6.7342163555358599277e-306, -5.681754927174335258e-322, + 9.5294739006302120482e-273, -1.2215123283371736879e-289, 6.7342163555358599277e-306, -5.681754927174335258e-322, + 2.1353977370878701046e-273, -1.2215123283371736879e-289, 6.7342163555358599277e-306, -5.681754927174335258e-322, + 2.1353977370878701046e-273, -1.2215123283371736879e-289, 6.7342163555358599277e-306, -5.681754927174335258e-322, + 2.8687869620228451614e-274, -1.9537812801257956865e-290, 1.0380272777574237546e-306, 6.4228533959362050743e-323, +}; + +static const float Sleef_rempitabsp[] = { + 0.159154892, 5.112411827e-08, 3.626141271e-15, -2.036222915e-22, + 0.03415493667, 6.420638243e-09, 7.342738037e-17, 8.135951656e-24, + 0.03415493667, 6.420638243e-09, 7.342738037e-17, 8.135951656e-24, + 0.002904943191, -9.861969574e-11, -9.839336547e-18, -1.790215892e-24, + 0.002904943191, -9.861969574e-11, -9.839336547e-18, -1.790215892e-24, + 0.002904943191, -9.861969574e-11, -9.839336547e-18, -1.790215892e-24, + 0.002904943191, -9.861969574e-11, -9.839336547e-18, -1.790215892e-24, + 0.0009518179577, 1.342109202e-10, 1.791623576e-17, 1.518506657e-24, + 0.0009518179577, 1.342109202e-10, 1.791623576e-17, 1.518506657e-24, + 0.0004635368241, 1.779561221e-11, 4.038449606e-18, -1.358546052e-25, + 0.0002193961991, 1.779561221e-11, 4.038449606e-18, -1.358546052e-25, + 9.73258866e-05, 1.779561221e-11, 4.038449606e-18, -1.358546052e-25, + 3.62907449e-05, 3.243700447e-12, 5.690024473e-19, 7.09405479e-26, + 5.773168596e-06, 1.424711477e-12, 1.3532163e-19, 1.92417627e-26, + 5.773168596e-06, 1.424711477e-12, 1.3532163e-19, 1.92417627e-26, + 5.773168596e-06, 1.424711477e-12, 1.3532163e-19, 1.92417627e-26, + 1.958472239e-06, 5.152167755e-13, 1.3532163e-19, 1.92417627e-26, + 5.112411827e-08, 3.626141271e-15, -2.036222915e-22, 6.177847236e-30, + 5.112411827e-08, 3.626141271e-15, -2.036222915e-22, 6.177847236e-30, + 5.112411827e-08, 3.626141271e-15, -2.036222915e-22, 6.177847236e-30, + 5.112411827e-08, 3.626141271e-15, -2.036222915e-22, 6.177847236e-30, + 5.112411827e-08, 3.626141271e-15, -2.036222915e-22, 6.177847236e-30, + 5.112411827e-08, 3.626141271e-15, -2.036222915e-22, 6.177847236e-30, + 2.132179588e-08, 3.626141271e-15, -2.036222915e-22, 6.177847236e-30, + 6.420638243e-09, 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, + 6.420638243e-09, 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, + 2.695347945e-09, 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, + 8.327027956e-10, 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, + 8.327027956e-10, 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, + 3.670415083e-10, 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, + 1.342109202e-10, 1.791623576e-17, 1.518506361e-24, 2.613904e-31, + 1.779561221e-11, 4.038449606e-18, -1.358545683e-25, -3.443243946e-32, + 1.779561221e-11, 4.038449606e-18, -1.358545683e-25, -3.443243946e-32, + 1.779561221e-11, 4.038449606e-18, -1.358545683e-25, -3.443243946e-32, + 3.243700447e-12, 5.690024473e-19, 7.094053557e-26, 1.487136711e-32, + 3.243700447e-12, 5.690024473e-19, 7.094053557e-26, 1.487136711e-32, + 3.243700447e-12, 5.690024473e-19, 7.094053557e-26, 1.487136711e-32, + 1.424711477e-12, 1.3532163e-19, 1.924175961e-26, 2.545416018e-33, + 5.152167755e-13, 1.3532163e-19, 1.924175961e-26, 2.545416018e-33, + 6.046956013e-14, -2.036222915e-22, 6.177846108e-30, 1.082084378e-36, + 6.046956013e-14, -2.036222915e-22, 6.177846108e-30, 1.082084378e-36, + 6.046956013e-14, -2.036222915e-22, 6.177846108e-30, 1.082084378e-36, + 3.626141271e-15, -2.036222915e-22, 6.177846108e-30, 1.082084378e-36, + 3.626141271e-15, -2.036222915e-22, 6.177846108e-30, 1.082084378e-36, + 3.626141271e-15, -2.036222915e-22, 6.177846108e-30, 1.082084378e-36, + 3.626141271e-15, -2.036222915e-22, 6.177846108e-30, 1.082084378e-36, + 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, 6.296048013e-40, + 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, 6.296048013e-40, + 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, 6.296048013e-40, + 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, 6.296048013e-40, + 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, 6.296048013e-40, + 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, 6.296048013e-40, + 1.791623576e-17, 1.518506361e-24, 2.61390353e-31, 4.764937743e-38, + 1.791623576e-17, 1.518506361e-24, 2.61390353e-31, 4.764937743e-38, + 4.038449606e-18, -1.358545683e-25, -3.443243946e-32, 6.296048013e-40, + 4.038449606e-18, -1.358545683e-25, -3.443243946e-32, 6.296048013e-40, + 5.690024473e-19, 7.094053557e-26, 1.487136711e-32, 6.296048013e-40, + 5.690024473e-19, 7.094053557e-26, 1.487136711e-32, 6.296048013e-40, + 5.690024473e-19, 7.094053557e-26, 1.487136711e-32, 6.296048013e-40, + 1.3532163e-19, 1.924175961e-26, 2.545415467e-33, 6.296048013e-40, + 1.3532163e-19, 1.924175961e-26, 2.545415467e-33, 6.296048013e-40, + 2.690143217e-20, -1.452834402e-28, -6.441077673e-36, -1.764234767e-42, + 2.690143217e-20, -1.452834402e-28, -6.441077673e-36, -1.764234767e-42, + 2.690143217e-20, -1.452834402e-28, -6.441077673e-36, -1.764234767e-42, + 1.334890502e-20, -1.452834402e-28, -6.441077673e-36, -1.764234767e-42, + 6.572641438e-21, -1.452834402e-28, -6.441077673e-36, -1.764234767e-42, + 0.05874381959, 1.222115387e-08, 7.693612965e-16, 1.792054435e-22, + 0.02749382704, 4.77057327e-09, 7.693612965e-16, 1.792054435e-22, + 0.01186883077, 1.045283415e-09, 3.252721926e-16, 7.332633139e-23, + 0.00405633077, 1.045283415e-09, 3.252721926e-16, 7.332633139e-23, + 0.000150081818, -2.454155802e-12, 1.161414894e-20, 1.291319272e-27, + 0.000150081818, -2.454155802e-12, 1.161414894e-20, 1.291319272e-27, + 0.000150081818, -2.454155802e-12, 1.161414894e-20, 1.291319272e-27, + 0.000150081818, -2.454155802e-12, 1.161414894e-20, 1.291319272e-27, + 0.000150081818, -2.454155802e-12, 1.161414894e-20, 1.291319272e-27, + 2.801149822e-05, 4.821800945e-12, 8.789757674e-19, 1.208447639e-25, + 2.801149822e-05, 4.821800945e-12, 8.789757674e-19, 1.208447639e-25, + 2.801149822e-05, 4.821800945e-12, 8.789757674e-19, 1.208447639e-25, + 1.275271279e-05, 1.183823005e-12, 1.161414894e-20, 1.291319272e-27, + 5.12331826e-06, 1.183823005e-12, 1.161414894e-20, 1.291319272e-27, + 1.308621904e-06, 2.743283031e-13, 1.161414894e-20, 1.291319272e-27, + 1.308621904e-06, 2.743283031e-13, 1.161414894e-20, 1.291319272e-27, + 3.549478151e-07, 4.695462769e-14, 1.161414894e-20, 1.291319272e-27, + 3.549478151e-07, 4.695462769e-14, 1.161414894e-20, 1.291319272e-27, + 1.165292645e-07, 1.853292503e-14, 4.837885366e-21, 1.291319272e-27, + 1.165292645e-07, 1.853292503e-14, 4.837885366e-21, 1.291319272e-27, + 5.69246339e-08, 4.322073705e-15, 1.449754789e-21, 7.962890365e-29, + 2.712231151e-08, 4.322073705e-15, 1.449754789e-21, 7.962890365e-29, + 1.222115387e-08, 7.693612965e-16, 1.792054182e-22, 2.91418027e-29, + 4.77057327e-09, 7.693612965e-16, 1.792054182e-22, 2.91418027e-29, + 1.045283415e-09, 3.252721926e-16, 7.332632508e-23, 3.898253736e-30, + 1.045283415e-09, 3.252721926e-16, 7.332632508e-23, 3.898253736e-30, + 1.139611461e-10, 1.996093359e-17, 5.344349223e-25, 1.511644828e-31, + 1.139611461e-10, 1.996093359e-17, 5.344349223e-25, 1.511644828e-31, + 1.139611461e-10, 1.996093359e-17, 5.344349223e-25, 1.511644828e-31, + 1.139611461e-10, 1.996093359e-17, 5.344349223e-25, 1.511644828e-31, + 5.575349904e-11, 6.083145782e-18, 5.344349223e-25, 1.511644828e-31, + 2.664967552e-11, -8.557475018e-19, -8.595036458e-26, -2.139883875e-32, + 1.209775682e-11, 2.61369883e-18, 5.344349223e-25, 1.511644828e-31, + 4.821800945e-12, 8.789757674e-19, 1.208447639e-25, 3.253064536e-33, + 1.183823005e-12, 1.161414894e-20, 1.29131908e-27, 1.715766248e-34, + 1.183823005e-12, 1.161414894e-20, 1.29131908e-27, 1.715766248e-34, + 2.743283031e-13, 1.161414894e-20, 1.29131908e-27, 1.715766248e-34, +}; +#endif // #ifndef __SLEEF_REMPITAB__ + +#if !defined(__NVCC__) && ((defined(__SIZEOF_FLOAT128__) && __SIZEOF_FLOAT128__ == 16) || (defined(__linux__) && defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))) || (defined(__PPC64__) && defined(__GNUC__) && !defined(__clang__) && __GNUC__ >= 8)) +#define SLEEF_FLOAT128_IS_IEEEQP +#endif + +#if !defined(SLEEF_FLOAT128_IS_IEEEQP) && !defined(__NVCC__) && defined(__SIZEOF_LONG_DOUBLE__) && __SIZEOF_LONG_DOUBLE__ == 16 && (defined(__aarch64__) || defined(__zarch__)) +#define SLEEF_LONGDOUBLE_IS_IEEEQP +#endif + +#if !defined(Sleef_quad_DEFINED) +#define Sleef_quad_DEFINED +typedef struct { uint64_t x, y; } Sleef_uint64_2t; +#if defined(SLEEF_FLOAT128_IS_IEEEQP) +typedef __float128 Sleef_quad; +#define SLEEF_QUAD_C(x) (x ## Q) +#elif defined(SLEEF_LONGDOUBLE_IS_IEEEQP) +typedef long double Sleef_quad; +#define SLEEF_QUAD_C(x) (x ## L) +#else +typedef Sleef_uint64_2t Sleef_quad; +#endif +#endif + +extern const double Sleef_rempitabdp[]; + +static SLEEF_ALWAYS_INLINE int vavailability_i_sve_sleef(int name) { return 3; } + +typedef svint32_t vmask_sve_sleef; +typedef svbool_t vopmask_sve_sleef; + +typedef svfloat32_t vfloat_sve_sleef; +typedef svint32_t vint2_sve_sleef; + +typedef svfloat64_t vdouble_sve_sleef; +typedef svint32_t vint_sve_sleef; + +typedef svint64_t vint64_sve_sleef; +typedef svuint64_t vuint64_sve_sleef; + +typedef svfloat64x2_t vdouble2_sve_sleef; +static SLEEF_ALWAYS_INLINE vdouble_sve_sleef vd2getx_vd_vd2_sve_sleef(vdouble2_sve_sleef v) { return svget2_f64(v, 0); } +static SLEEF_ALWAYS_INLINE vdouble_sve_sleef vd2gety_vd_vd2_sve_sleef(vdouble2_sve_sleef v) { return svget2_f64(v, 1); } +static SLEEF_ALWAYS_INLINE vdouble2_sve_sleef vd2setxy_vd2_vd_vd_sve_sleef(vdouble_sve_sleef x, vdouble_sve_sleef y) { return svcreate2_f64(x, y); } +static SLEEF_ALWAYS_INLINE vdouble2_sve_sleef vd2setx_vd2_vd2_vd_sve_sleef(vdouble2_sve_sleef v, vdouble_sve_sleef d) { return svset2_f64(v, 0, d); } +static SLEEF_ALWAYS_INLINE vdouble2_sve_sleef vd2sety_vd2_vd2_vd_sve_sleef(vdouble2_sve_sleef v, vdouble_sve_sleef d) { return svset2_f64(v, 1, d); } + +typedef svfloat32x2_t vfloat2_sve_sleef; +static SLEEF_ALWAYS_INLINE vfloat_sve_sleef vf2getx_vf_vf2_sve_sleef(vfloat2_sve_sleef v) { return svget2_f32(v, 0); } +static SLEEF_ALWAYS_INLINE vfloat_sve_sleef vf2gety_vf_vf2_sve_sleef(vfloat2_sve_sleef v) { return svget2_f32(v, 1); } +static SLEEF_ALWAYS_INLINE vfloat2_sve_sleef vf2setxy_vf2_vf_vf_sve_sleef(vfloat_sve_sleef x, vfloat_sve_sleef y) { return svcreate2_f32(x, y); } +static SLEEF_ALWAYS_INLINE vfloat2_sve_sleef vf2setx_vf2_vf2_vf_sve_sleef(vfloat2_sve_sleef v, vfloat_sve_sleef d) { return svset2_f32(v, 0, d); } +static SLEEF_ALWAYS_INLINE vfloat2_sve_sleef vf2sety_vf2_vf2_vf_sve_sleef(vfloat2_sve_sleef v, vfloat_sve_sleef d) { return svset2_f32(v, 1, d); } + +typedef svint32x2_t vquad_sve_sleef; +static SLEEF_ALWAYS_INLINE vmask_sve_sleef vqgetx_vm_vq_sve_sleef(vquad_sve_sleef v) { return svget2_s32(v, 0); } +static SLEEF_ALWAYS_INLINE vmask_sve_sleef vqgety_vm_vq_sve_sleef(vquad_sve_sleef v) { return svget2_s32(v, 1); } +static SLEEF_ALWAYS_INLINE vquad_sve_sleef vqsetxy_vq_vm_vm_sve_sleef(vmask_sve_sleef x, vmask_sve_sleef y) { return svcreate2_s32(x, y); } +static SLEEF_ALWAYS_INLINE vquad_sve_sleef vqsetx_vq_vq_vm_sve_sleef(vquad_sve_sleef v, vmask_sve_sleef x) { return svset2_s32(v, 0, x); } +static SLEEF_ALWAYS_INLINE vquad_sve_sleef vqsety_vq_vq_vm_sve_sleef(vquad_sve_sleef v, vmask_sve_sleef y) { return svset2_s32(v, 1, y); } + +typedef vquad_sve_sleef vargquad_sve_sleef; + +typedef svfloat64x2_t di_t_sve_sleef; + +static SLEEF_ALWAYS_INLINE vdouble_sve_sleef digetd_vd_di_sve_sleef(di_t_sve_sleef d) { return svget2_f64(d, 0); } +static SLEEF_ALWAYS_INLINE vint_sve_sleef digeti_vi_di_sve_sleef(di_t_sve_sleef d) { return svreinterpret_s32_f64(svget2_f64(d, 1)); } +static SLEEF_ALWAYS_INLINE di_t_sve_sleef disetdi_di_vd_vi_sve_sleef(vdouble_sve_sleef d, vint_sve_sleef i) { + return svcreate2_f64(d, svreinterpret_f64_s32(i)); +} + +typedef svfloat32x2_t fi_t_sve_sleef; + +static SLEEF_ALWAYS_INLINE vfloat_sve_sleef figetd_vf_di_sve_sleef(fi_t_sve_sleef d) { return svget2_f32(d, 0); } +static SLEEF_ALWAYS_INLINE vint2_sve_sleef figeti_vi2_di_sve_sleef(fi_t_sve_sleef d) { return svreinterpret_s32_f32(svget2_f32(d, 1)); } +static SLEEF_ALWAYS_INLINE fi_t_sve_sleef fisetdi_fi_vf_vi2_sve_sleef(vfloat_sve_sleef d, vint2_sve_sleef i) { + return svcreate2_f32(d, svreinterpret_f32_s32(i)); +} + +typedef svfloat64x3_t ddi_t_sve_sleef; + +static SLEEF_ALWAYS_INLINE vdouble2_sve_sleef ddigetdd_vd2_ddi_sve_sleef(ddi_t_sve_sleef d) { + return svcreate2_f64(svget3_f64(d, 0), svget3_f64(d, 1)); +} +static SLEEF_ALWAYS_INLINE vint_sve_sleef ddigeti_vi_ddi_sve_sleef(ddi_t_sve_sleef d) { return svreinterpret_s32_f64(svget3_f64(d, 2)); } +static SLEEF_ALWAYS_INLINE ddi_t_sve_sleef ddisetddi_ddi_vd2_vi_sve_sleef(vdouble2_sve_sleef v, vint_sve_sleef i) { + return svcreate3_f64(svget2_f64(v, 0), svget2_f64(v, 1), + svreinterpret_f64_s32(i)); +} +static SLEEF_ALWAYS_INLINE ddi_t_sve_sleef ddisetdd_ddi_ddi_vd2_sve_sleef(ddi_t_sve_sleef ddi_sve_sleef, vdouble2_sve_sleef v) { + return svcreate3_f64(svget2_f64(v, 0), svget2_f64(v, 1), svget3_f64(ddi_sve_sleef, 2)); +} + +typedef svfloat32x3_t dfi_t_sve_sleef; + +static SLEEF_ALWAYS_INLINE vfloat2_sve_sleef dfigetdf_vf2_dfi_sve_sleef(dfi_t_sve_sleef d) { + return svcreate2_f32(svget3_f32(d, 0), svget3_f32(d, 1)); +} +static SLEEF_ALWAYS_INLINE vint2_sve_sleef dfigeti_vi2_dfi_sve_sleef(dfi_t_sve_sleef d) { return svreinterpret_s32_f32(svget3_f32(d, 2)); } +static SLEEF_ALWAYS_INLINE dfi_t_sve_sleef dfisetdfi_dfi_vf2_vi2_sve_sleef(vfloat2_sve_sleef v, vint2_sve_sleef i) { + return svcreate3_f32(svget2_f32(v, 0), svget2_f32(v, 1), + svreinterpret_f32_s32(i)); +} +static SLEEF_ALWAYS_INLINE dfi_t_sve_sleef dfisetdf_dfi_dfi_vf2_sve_sleef(dfi_t_sve_sleef dfi_sve_sleef, vfloat2_sve_sleef v) { + return svcreate3_f32(svget2_f32(v, 0), svget2_f32(v, 1), svget3_f32(dfi_sve_sleef, 2)); +} + +typedef svfloat64x4_t dd2_sve_sleef; + +static SLEEF_ALWAYS_INLINE dd2_sve_sleef dd2setab_dd2_vd2_vd2_sve_sleef(vdouble2_sve_sleef a, vdouble2_sve_sleef b) { + return svcreate4_f64(svget2_f64(a, 0), svget2_f64(a, 1), + svget2_f64(b, 0), svget2_f64(b, 1)); +} +static SLEEF_ALWAYS_INLINE vdouble2_sve_sleef dd2geta_vd2_dd2_sve_sleef(dd2_sve_sleef d) { + return svcreate2_f64(svget4_f64(d, 0), svget4_f64(d, 1)); +} +static SLEEF_ALWAYS_INLINE vdouble2_sve_sleef dd2getb_vd2_dd2_sve_sleef(dd2_sve_sleef d) { + return svcreate2_f64(svget4_f64(d, 2), svget4_f64(d, 3)); +} + +typedef svfloat32x4_t df2_sve_sleef; + +static SLEEF_ALWAYS_INLINE df2_sve_sleef df2setab_df2_vf2_vf2_sve_sleef(vfloat2_sve_sleef a, vfloat2_sve_sleef b) { + return svcreate4_f32(svget2_f32(a, 0), svget2_f32(a, 1), + svget2_f32(b, 0), svget2_f32(b, 1)); +} +static SLEEF_ALWAYS_INLINE vfloat2_sve_sleef df2geta_vf2_df2_sve_sleef(df2_sve_sleef d) { + return svcreate2_f32(svget4_f32(d, 0), svget4_f32(d, 1)); +} +static SLEEF_ALWAYS_INLINE vfloat2_sve_sleef df2getb_vf2_df2_sve_sleef(df2_sve_sleef d) { + return svcreate2_f32(svget4_f32(d, 2), svget4_f32(d, 3)); +} + +typedef svfloat64x3_t vdouble3_sve_sleef; + +static SLEEF_ALWAYS_INLINE vdouble_sve_sleef vd3getx_vd_vd3_sve_sleef(vdouble3_sve_sleef v) { return svget3_f64(v, 0); } +static SLEEF_ALWAYS_INLINE vdouble_sve_sleef vd3gety_vd_vd3_sve_sleef(vdouble3_sve_sleef v) { return svget3_f64(v, 1); } +static SLEEF_ALWAYS_INLINE vdouble_sve_sleef vd3getz_vd_vd3_sve_sleef(vdouble3_sve_sleef v) { return svget3_f64(v, 2); } +static SLEEF_ALWAYS_INLINE vdouble3_sve_sleef vd3setxyz_vd3_vd_vd_vd_sve_sleef(vdouble_sve_sleef x, vdouble_sve_sleef y, vdouble_sve_sleef z) { return svcreate3_f64(x, y, z); } +static SLEEF_ALWAYS_INLINE vdouble3_sve_sleef vd3setx_vd3_vd3_vd_sve_sleef(vdouble3_sve_sleef v, vdouble_sve_sleef d) { return svset3_f64(v, 0, d); } +static SLEEF_ALWAYS_INLINE vdouble3_sve_sleef vd3sety_vd3_vd3_vd_sve_sleef(vdouble3_sve_sleef v, vdouble_sve_sleef d) { return svset3_f64(v, 1, d); } +static SLEEF_ALWAYS_INLINE vdouble3_sve_sleef vd3setz_vd3_vd3_vd_sve_sleef(vdouble3_sve_sleef v, vdouble_sve_sleef d) { return svset3_f64(v, 2, d); } + +typedef svfloat64x4_t tdx_sve_sleef; + +static SLEEF_ALWAYS_INLINE vmask_sve_sleef tdxgete_vm_tdx_sve_sleef(tdx_sve_sleef t) { + return svreinterpret_s32_f64(svget4_f64(t, 0)); +} +static SLEEF_ALWAYS_INLINE vdouble3_sve_sleef tdxgetd3_vd3_tdx_sve_sleef(tdx_sve_sleef t) { + return svcreate3_f64(svget4_f64(t, 1), svget4_f64(t, 2), svget4_f64(t, 3)); +} +static SLEEF_ALWAYS_INLINE vdouble_sve_sleef tdxgetd3x_vd_tdx_sve_sleef(tdx_sve_sleef t) { return svget4_f64(t, 1); } +static SLEEF_ALWAYS_INLINE vdouble_sve_sleef tdxgetd3y_vd_tdx_sve_sleef(tdx_sve_sleef t) { return svget4_f64(t, 2); } +static SLEEF_ALWAYS_INLINE vdouble_sve_sleef tdxgetd3z_vd_tdx_sve_sleef(tdx_sve_sleef t) { return svget4_f64(t, 3); } +static SLEEF_ALWAYS_INLINE tdx_sve_sleef tdxsete_tdx_tdx_vm_sve_sleef(tdx_sve_sleef t, vmask_sve_sleef e) { + return svset4_f64(t, 0, svreinterpret_f64_s32(e)); +} +static SLEEF_ALWAYS_INLINE tdx_sve_sleef tdxsetd3_tdx_tdx_vd3_sve_sleef(tdx_sve_sleef t, vdouble3_sve_sleef d3) { + return svcreate4_f64(svget4_f64(t, 0), svget3_f64(d3, 0), svget3_f64(d3, 1), svget3_f64(d3, 2)); +} +static SLEEF_ALWAYS_INLINE tdx_sve_sleef tdxsetx_tdx_tdx_vd_sve_sleef(tdx_sve_sleef t, vdouble_sve_sleef x) { return svset4_f64(t, 1, x); } +static SLEEF_ALWAYS_INLINE tdx_sve_sleef tdxsety_tdx_tdx_vd_sve_sleef(tdx_sve_sleef t, vdouble_sve_sleef y) { return svset4_f64(t, 2, y); } +static SLEEF_ALWAYS_INLINE tdx_sve_sleef tdxsetz_tdx_tdx_vd_sve_sleef(tdx_sve_sleef t, vdouble_sve_sleef z) { return svset4_f64(t, 3, z); } +static SLEEF_ALWAYS_INLINE tdx_sve_sleef tdxsetxyz_tdx_tdx_vd_vd_vd_sve_sleef(tdx_sve_sleef t, vdouble_sve_sleef x, vdouble_sve_sleef y, vdouble_sve_sleef z) { + return svcreate4_f64(svget4_f64(t, 0), x, y, z); +} + +static SLEEF_ALWAYS_INLINE tdx_sve_sleef tdxseted3_tdx_vm_vd3_sve_sleef(vmask_sve_sleef e, vdouble3_sve_sleef d3) { + return svcreate4_f64(svreinterpret_f64_s32(e), svget3_f64(d3, 0), svget3_f64(d3, 1), svget3_f64(d3, 2)); +} +static SLEEF_ALWAYS_INLINE tdx_sve_sleef tdxsetexyz_tdx_vm_vd_vd_vd_sve_sleef(vmask_sve_sleef e, vdouble_sve_sleef x, vdouble_sve_sleef y, vdouble_sve_sleef z) { + return svcreate4_f64(svreinterpret_f64_s32(e), x, y, z); +} + +typedef svfloat64x4_t tdi_t_sve_sleef; + +static SLEEF_ALWAYS_INLINE vdouble3_sve_sleef tdigettd_vd3_tdi_sve_sleef(tdi_t_sve_sleef d) { + return svcreate3_f64(svget4_f64(d, 0), svget4_f64(d, 1), svget4_f64(d, 2)); +} +static SLEEF_ALWAYS_INLINE vdouble_sve_sleef tdigetx_vd_tdi_sve_sleef(tdi_t_sve_sleef d) { return svget4_f64(d, 0); } +static SLEEF_ALWAYS_INLINE vint_sve_sleef tdigeti_vi_tdi_sve_sleef(tdi_t_sve_sleef d) { return svreinterpret_s32_f64(svget4_f64(d, 3)); } +static SLEEF_ALWAYS_INLINE tdi_t_sve_sleef tdisettdi_tdi_vd3_vi_sve_sleef(vdouble3_sve_sleef v, vint_sve_sleef i) { + return svcreate4_f64(svget3_f64(v, 0), svget3_f64(v, 1), svget3_f64(v, 2), + svreinterpret_f64_s32(i)); +} +static SLEEF_ALWAYS_INLINE tdi_t_sve_sleef tdisettd_tdi_tdi_vd3(tdi_t_sve_sleef tdi, vdouble3_sve_sleef v) { + return svcreate4_f64(svget3_f64(v, 0), svget3_f64(v, 1), svget3_f64(v, 2), svget4_f64(tdi, 3)); +} + +static SLEEF_ALWAYS_INLINE void vprefetch_v_p_sve_sleef(const void *ptr) {} + +static SLEEF_ALWAYS_INLINE int vtestallones_i_vo32_sve_sleef(vopmask_sve_sleef g) { + svbool_t pg = svptrue_b32(); + return (svcntp_b32(pg, g) == svcntw()); +} + +static SLEEF_ALWAYS_INLINE int vtestallones_i_vo64_sve_sleef(vopmask_sve_sleef g) { + svbool_t pg = svptrue_b64(); + return (svcntp_b64(pg, g) == svcntd()); +} + +static SLEEF_ALWAYS_INLINE void vstoreu_v_p_vi2_sve_sleef(int32_t *p, vint2_sve_sleef v) { svst1_s32(svptrue_b8(), p, v); } + +static SLEEF_ALWAYS_INLINE vfloat_sve_sleef vload_vf_p_sve_sleef(const float *ptr) { + return svld1_f32(svptrue_b8(), ptr); +} +static SLEEF_ALWAYS_INLINE vfloat_sve_sleef vloadu_vf_p_sve_sleef(const float *ptr) { + return svld1_f32(svptrue_b8(), ptr); +} +static SLEEF_ALWAYS_INLINE void vstoreu_v_p_vf_sve_sleef(float *ptr, vfloat_sve_sleef v) { + svst1_f32(svptrue_b8(), ptr, v); +} + +static SLEEF_ALWAYS_INLINE vmask_sve_sleef vand_vm_vm_vm_sve_sleef(vmask_sve_sleef x, vmask_sve_sleef y) { + return svand_s32_x(svptrue_b8(), x, y); +} +static SLEEF_ALWAYS_INLINE vmask_sve_sleef vandnot_vm_vm_vm_sve_sleef(vmask_sve_sleef x, vmask_sve_sleef y) { + return svbic_s32_x(svptrue_b8(), y, x); +} +static SLEEF_ALWAYS_INLINE vmask_sve_sleef vor_vm_vm_vm_sve_sleef(vmask_sve_sleef x, vmask_sve_sleef y) { + return svorr_s32_x(svptrue_b8(), x, y); +} +static SLEEF_ALWAYS_INLINE vmask_sve_sleef vxor_vm_vm_vm_sve_sleef(vmask_sve_sleef x, vmask_sve_sleef y) { + return sveor_s32_x(svptrue_b8(), x, y); +} + +static SLEEF_ALWAYS_INLINE vmask_sve_sleef vadd64_vm_vm_vm_sve_sleef(vmask_sve_sleef x, vmask_sve_sleef y) { + return svreinterpret_s32_s64( + svadd_s64_x(svptrue_b8(), svreinterpret_s64_s32(x), + svreinterpret_s64_s32(y))); +} + +static SLEEF_ALWAYS_INLINE vmask_sve_sleef vreinterpret_vm_vf_sve_sleef(vfloat_sve_sleef vf) { + return svreinterpret_s32_f32(vf); +} +static SLEEF_ALWAYS_INLINE vfloat_sve_sleef vreinterpret_vf_vm_sve_sleef(vmask_sve_sleef vm) { + return svreinterpret_f32_s32(vm); +} +static SLEEF_ALWAYS_INLINE vfloat_sve_sleef vreinterpret_vf_vi2_sve_sleef(vint2_sve_sleef vm) { + return svreinterpret_f32_s32(vm); +} +static SLEEF_ALWAYS_INLINE vint2_sve_sleef vreinterpret_vi2_vf_sve_sleef(vfloat_sve_sleef vf) { + return svreinterpret_s32_f32(vf); +} +static SLEEF_ALWAYS_INLINE vint2_sve_sleef vcast_vi2_vm_sve_sleef(vmask_sve_sleef vm) { return vm; } +static SLEEF_ALWAYS_INLINE vmask_sve_sleef vcast_vm_vi2_sve_sleef(vint2_sve_sleef vi) { return vi; } + +static SLEEF_ALWAYS_INLINE vint2_sve_sleef vsel_vi2_vm_vi2_vi2(vmask_sve_sleef m, vint2_sve_sleef x, vint2_sve_sleef y) { + return svsel_s32(svcmpeq_s32(svptrue_b8(), m, svdup_n_s32(0xffffffff)), x, y); +} + +static SLEEF_ALWAYS_INLINE vfloat_sve_sleef vcast_vf_f_sve_sleef(float f) { return svdup_n_f32(f); } + +static SLEEF_ALWAYS_INLINE vfloat_sve_sleef vadd_vf_vf_vf_sve_sleef(vfloat_sve_sleef x, vfloat_sve_sleef y) { + return svadd_f32_x(svptrue_b8(), x, y); +} +static SLEEF_ALWAYS_INLINE vfloat_sve_sleef vsub_vf_vf_vf_sve_sleef(vfloat_sve_sleef x, vfloat_sve_sleef y) { + return svsub_f32_x(svptrue_b8(), x, y); +} +static SLEEF_ALWAYS_INLINE vfloat_sve_sleef vmul_vf_vf_vf_sve_sleef(vfloat_sve_sleef x, vfloat_sve_sleef y) { + return svmul_f32_x(svptrue_b8(), x, y); +} + +static SLEEF_ALWAYS_INLINE vfloat_sve_sleef vabs_vf_vf_sve_sleef(vfloat_sve_sleef f) { return svabs_f32_x(svptrue_b8(), f); } +static SLEEF_ALWAYS_INLINE vfloat_sve_sleef vneg_vf_vf_sve_sleef(vfloat_sve_sleef f) { return svneg_f32_x(svptrue_b8(), f); } + +static SLEEF_ALWAYS_INLINE vfloat_sve_sleef vmax_vf_vf_vf_sve_sleef(vfloat_sve_sleef x, vfloat_sve_sleef y) { + return svmax_f32_x(svptrue_b8(), x, y); +} +static SLEEF_ALWAYS_INLINE vfloat_sve_sleef vmin_vf_vf_vf_sve_sleef(vfloat_sve_sleef x, vfloat_sve_sleef y) { + return svmin_f32_x(svptrue_b8(), x, y); +} + +static SLEEF_ALWAYS_INLINE vint2_sve_sleef vtruncate_vi2_vf_sve_sleef(vfloat_sve_sleef vf) { + return svcvt_s32_f32_x(svptrue_b8(), vf); +} +static SLEEF_ALWAYS_INLINE vfloat_sve_sleef vcast_vf_vi2_sve_sleef(vint2_sve_sleef vi) { + return svcvt_f32_s32_x(svptrue_b8(), vi); +} +static SLEEF_ALWAYS_INLINE vint2_sve_sleef vcast_vi2_i_sve_sleef(int i) { return svdup_n_s32(i); } +static SLEEF_ALWAYS_INLINE vint2_sve_sleef vrint_vi2_vf_sve_sleef(vfloat_sve_sleef d) { + return svcvt_s32_f32_x(svptrue_b8(), svrintn_f32_x(svptrue_b8(), d)); +} + +static SLEEF_ALWAYS_INLINE vfloat_sve_sleef vmla_vf_vf_vf_vf_sve_sleef(vfloat_sve_sleef x, vfloat_sve_sleef y, vfloat_sve_sleef z) { + return svmad_f32_x(svptrue_b8(), x, y, z); +} + +static SLEEF_ALWAYS_INLINE vfloat_sve_sleef vmlanp_vf_vf_vf_vf_sve_sleef(vfloat_sve_sleef x, vfloat_sve_sleef y, vfloat_sve_sleef z) { + return svmsb_f32_x(svptrue_b8(), x, y, z); +} +static SLEEF_ALWAYS_INLINE vfloat_sve_sleef vmlapn_vf_vf_vf_vf_sve_sleef(vfloat_sve_sleef x, vfloat_sve_sleef y, vfloat_sve_sleef z) { + return svnmsb_f32_x(svptrue_b8(), x, y, z); +} + +static SLEEF_ALWAYS_INLINE vfloat_sve_sleef vfma_vf_vf_vf_vf_sve_sleef(vfloat_sve_sleef x, vfloat_sve_sleef y, + vfloat_sve_sleef z) { + return svmad_f32_x(svptrue_b8(), x, y, z); +} +static SLEEF_ALWAYS_INLINE vfloat_sve_sleef vfmanp_vf_vf_vf_vf_sve_sleef(vfloat_sve_sleef x, vfloat_sve_sleef y, + vfloat_sve_sleef z) { + return svmsb_f32_x(svptrue_b8(), x, y, z); +} +static SLEEF_ALWAYS_INLINE vfloat_sve_sleef vfmapn_vf_vf_vf_vf_sve_sleef(vfloat_sve_sleef x, vfloat_sve_sleef y, + vfloat_sve_sleef z) { + return svnmsb_f32_x(svptrue_b8(), x, y, z); +} + +static SLEEF_ALWAYS_INLINE vfloat_sve_sleef vsel_vf_vo_vf_vf_sve_sleef(vopmask_sve_sleef mask, vfloat_sve_sleef x, vfloat_sve_sleef y) { + return svsel_f32(mask, x, y); +} + +static SLEEF_ALWAYS_INLINE vfloat_sve_sleef vdiv_vf_vf_vf_sve_sleef(vfloat_sve_sleef n, vfloat_sve_sleef d) { + + return svdiv_f32_x(svptrue_b8(), n, d); + +} +static SLEEF_ALWAYS_INLINE vfloat_sve_sleef vrec_vf_vf_sve_sleef(vfloat_sve_sleef d) { + + return svdivr_n_f32_x(svptrue_b8(), d, 1.0f); + +} +static SLEEF_ALWAYS_INLINE vfloat_sve_sleef vsqrt_vf_vf_sve_sleef(vfloat_sve_sleef d) { + + return svsqrt_f32_x(svptrue_b8(), d); + +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_sve_sleef vsel_vf_vo_f_f_sve_sleef(vopmask_sve_sleef o, float v1, float v0) { + return vsel_vf_vo_vf_vf_sve_sleef(o, vcast_vf_f_sve_sleef(v1), vcast_vf_f_sve_sleef(v0)); +} + +static SLEEF_ALWAYS_INLINE vfloat_sve_sleef vsel_vf_vo_vo_f_f_f_sve_sleef(vopmask_sve_sleef o0, vopmask_sve_sleef o1, float d0, float d1, float d2) { + return vsel_vf_vo_vf_vf_sve_sleef(o0, vcast_vf_f_sve_sleef(d0), vsel_vf_vo_f_f_sve_sleef(o1, d1, d2)); +} + +static SLEEF_ALWAYS_INLINE vfloat_sve_sleef vsel_vf_vo_vo_vo_f_f_f_f_sve_sleef(vopmask_sve_sleef o0, vopmask_sve_sleef o1, vopmask_sve_sleef o2, float d0, float d1, float d2, float d3) { + return vsel_vf_vo_vf_vf_sve_sleef(o0, vcast_vf_f_sve_sleef(d0), vsel_vf_vo_vf_vf_sve_sleef(o1, vcast_vf_f_sve_sleef(d1), vsel_vf_vo_f_f_sve_sleef(o2, d2, d3))); +} + +static SLEEF_ALWAYS_INLINE vfloat_sve_sleef vtruncate_vf_vf_sve_sleef(vfloat_sve_sleef vd_sve_sleef) { + return svrintz_f32_x(svptrue_b8(), vd_sve_sleef); +} + +static SLEEF_ALWAYS_INLINE vfloat_sve_sleef vrint_vf_vf_sve_sleef(vfloat_sve_sleef vf) { + return svrintn_f32_x(svptrue_b32(), vf); +} + +static SLEEF_ALWAYS_INLINE vint2_sve_sleef vadd_vi2_vi2_vi2_sve_sleef(vint2_sve_sleef x, vint2_sve_sleef y) { + return svadd_s32_x(svptrue_b8(), x, y); +} +static SLEEF_ALWAYS_INLINE vint2_sve_sleef vsub_vi2_vi2_vi2_sve_sleef(vint2_sve_sleef x, vint2_sve_sleef y) { + return svsub_s32_x(svptrue_b8(), x, y); +} +static SLEEF_ALWAYS_INLINE vint2_sve_sleef vneg_vi2_vi2_sve_sleef(vint2_sve_sleef e) { return svneg_s32_x(svptrue_b8(), e); } + +static SLEEF_ALWAYS_INLINE vint2_sve_sleef vand_vi2_vi2_vi2_sve_sleef(vint2_sve_sleef x, vint2_sve_sleef y) { + return svand_s32_x(svptrue_b8(), x, y); +} +static SLEEF_ALWAYS_INLINE vint2_sve_sleef vandnot_vi2_vi2_vi2_sve_sleef(vint2_sve_sleef x, vint2_sve_sleef y) { + return svbic_s32_x(svptrue_b8(), y, x); +} +static SLEEF_ALWAYS_INLINE vint2_sve_sleef vor_vi2_vi2_vi2_sve_sleef(vint2_sve_sleef x, vint2_sve_sleef y) { + return svorr_s32_x(svptrue_b8(), x, y); +} +static SLEEF_ALWAYS_INLINE vint2_sve_sleef vxor_vi2_vi2_vi2_sve_sleef(vint2_sve_sleef x, vint2_sve_sleef y) { + return sveor_s32_x(svptrue_b8(), x, y); +} + +static SLEEF_ALWAYS_INLINE vint2_sve_sleef vgt_vi2_vi2_vi2_sve_sleef(vint2_sve_sleef x, vint2_sve_sleef y) { + return svsel_s32(svcmpgt_s32(svptrue_b8(), x, y), svdup_n_s32(0xffffffff), svdup_n_s32(0x0)); +} + +static SLEEF_ALWAYS_INLINE vint2_sve_sleef vsel_vi2_vo_vi2_vi2_sve_sleef(vopmask_sve_sleef m, vint2_sve_sleef x, vint2_sve_sleef y) { + return svsel_s32(m, x, y); +} + +static SLEEF_ALWAYS_INLINE vopmask_sve_sleef veq_vo_vf_vf_sve_sleef(vfloat_sve_sleef x, vfloat_sve_sleef y) { + return svcmpeq_f32(svptrue_b8(), x, y); +} +static SLEEF_ALWAYS_INLINE vopmask_sve_sleef vneq_vo_vf_vf_sve_sleef(vfloat_sve_sleef x, vfloat_sve_sleef y) { + return svcmpne_f32(svptrue_b8(), x, y); +} +static SLEEF_ALWAYS_INLINE vopmask_sve_sleef vlt_vo_vf_vf_sve_sleef(vfloat_sve_sleef x, vfloat_sve_sleef y) { + return svcmplt_f32(svptrue_b8(), x, y); +} +static SLEEF_ALWAYS_INLINE vopmask_sve_sleef vle_vo_vf_vf_sve_sleef(vfloat_sve_sleef x, vfloat_sve_sleef y) { + return svcmple_f32(svptrue_b8(), x, y); +} +static SLEEF_ALWAYS_INLINE vopmask_sve_sleef vgt_vo_vf_vf_sve_sleef(vfloat_sve_sleef x, vfloat_sve_sleef y) { + return svcmpgt_f32(svptrue_b8(), x, y); +} +static SLEEF_ALWAYS_INLINE vopmask_sve_sleef vge_vo_vf_vf_sve_sleef(vfloat_sve_sleef x, vfloat_sve_sleef y) { + return svcmpge_f32(svptrue_b8(), x, y); +} +static SLEEF_ALWAYS_INLINE vopmask_sve_sleef visinf_vo_vf_sve_sleef(vfloat_sve_sleef d) { + return svcmpeq_n_f32(svptrue_b8(), vabs_vf_vf_sve_sleef(d), __builtin_inff()); +} +static SLEEF_ALWAYS_INLINE vopmask_sve_sleef vispinf_vo_vf_sve_sleef(vfloat_sve_sleef d) { + return svcmpeq_n_f32(svptrue_b8(), d, __builtin_inff()); +} +static SLEEF_ALWAYS_INLINE vopmask_sve_sleef visminf_vo_vf_sve_sleef(vfloat_sve_sleef d) { + return svcmpeq_n_f32(svptrue_b8(), d, -__builtin_inff()); +} +static SLEEF_ALWAYS_INLINE vopmask_sve_sleef visnan_vo_vf_sve_sleef(vfloat_sve_sleef d) { return vneq_vo_vf_vf_sve_sleef(d, d); } + +static SLEEF_ALWAYS_INLINE vopmask_sve_sleef veq_vo_vi2_vi2_sve_sleef(vint2_sve_sleef x, vint2_sve_sleef y) { + return svcmpeq_s32(svptrue_b8(), x, y); +} +static SLEEF_ALWAYS_INLINE vopmask_sve_sleef vgt_vo_vi2_vi2_sve_sleef(vint2_sve_sleef x, vint2_sve_sleef y) { + return svcmpgt_s32(svptrue_b8(), x, y); +} + +static SLEEF_ALWAYS_INLINE vopmask_sve_sleef vand_vo_vo_vo_sve_sleef(vopmask_sve_sleef x, vopmask_sve_sleef y) { + return svand_b_z(svptrue_b8(), x, y); +} +static SLEEF_ALWAYS_INLINE vopmask_sve_sleef vandnot_vo_vo_vo_sve_sleef(vopmask_sve_sleef x, vopmask_sve_sleef y) { + return svbic_b_z(svptrue_b8(), y, x); +} +static SLEEF_ALWAYS_INLINE vopmask_sve_sleef vor_vo_vo_vo_sve_sleef(vopmask_sve_sleef x, vopmask_sve_sleef y) { + return svorr_b_z(svptrue_b8(), x, y); +} +static SLEEF_ALWAYS_INLINE vopmask_sve_sleef vxor_vo_vo_vo_sve_sleef(vopmask_sve_sleef x, vopmask_sve_sleef y) { + return sveor_b_z(svptrue_b8(), x, y); +} + +static SLEEF_ALWAYS_INLINE vint2_sve_sleef vand_vi2_vo_vi2_sve_sleef(vopmask_sve_sleef x, vint2_sve_sleef y) { + + return svand_s32_z(x, y, y); +} + +static SLEEF_ALWAYS_INLINE vmask_sve_sleef vand_vm_vo32_vm_sve_sleef(vopmask_sve_sleef x, vmask_sve_sleef y) { + return svsel_s32(x, y, svdup_n_s32(0x0)); +} +static SLEEF_ALWAYS_INLINE vmask_sve_sleef vandnot_vm_vo32_vm_sve_sleef(vopmask_sve_sleef x, vmask_sve_sleef y) { + return svsel_s32(x, svdup_n_s32(0x0), y); +} +static SLEEF_ALWAYS_INLINE vmask_sve_sleef vor_vm_vo32_vm_sve_sleef(vopmask_sve_sleef x, vmask_sve_sleef y) { + return svsel_s32(x, svdup_n_s32(0xffffffff), y); +} + +static SLEEF_ALWAYS_INLINE vmask_sve_sleef vcast_vm_i_i_sve_sleef(int i0, int i1) { + return svreinterpret_s32_u64( + svdup_n_u64((0xffffffff & (uint64_t)i1) | (((uint64_t)i0) << 32))); +} + +static SLEEF_ALWAYS_INLINE vmask_sve_sleef vcast_vm_i64_sve_sleef(int64_t i) { + return svreinterpret_s32_u64(svdup_n_u64((uint64_t)i)); +} +static SLEEF_ALWAYS_INLINE vmask_sve_sleef vcast_vm_u64_sve_sleef(uint64_t i) { + return svreinterpret_s32_u64(svdup_n_u64(i)); +} + +static SLEEF_ALWAYS_INLINE vdouble_sve_sleef vload_vd_p_sve_sleef(const double *ptr) { + return svld1_f64(svptrue_b8(), ptr); +} +static SLEEF_ALWAYS_INLINE vdouble_sve_sleef vloadu_vd_p_sve_sleef(const double *ptr) { + return svld1_f64(svptrue_b8(), ptr); +} +static SLEEF_ALWAYS_INLINE void vstoreu_v_p_vd_sve_sleef(double *ptr, vdouble_sve_sleef v) { + svst1_f64(svptrue_b8(), ptr, v); +} + +static SLEEF_ALWAYS_INLINE void vstoreu_v_p_vi_sve_sleef(int *ptr, vint_sve_sleef v) { + svst1w_s64(svptrue_b8(), ptr, svreinterpret_s64_s32(v)); +} +static vint_sve_sleef vloadu_vi_p_sve_sleef(int32_t *p) { + return svreinterpret_s32_s64(svld1uw_s64(svptrue_b8(), (uint32_t *)p)); +} + +static SLEEF_ALWAYS_INLINE vdouble_sve_sleef vreinterpret_vd_vm_sve_sleef(vmask_sve_sleef vm) { + return svreinterpret_f64_s32(vm); +} +static SLEEF_ALWAYS_INLINE vmask_sve_sleef vreinterpret_vm_vd_sve_sleef(vdouble_sve_sleef vd_sve_sleef) { + return svreinterpret_s32_f64(vd_sve_sleef); +} +static SLEEF_ALWAYS_INLINE vint2_sve_sleef vcastu_vm_vi_sve_sleef(vint_sve_sleef x) { + return svreinterpret_s32_s64( + svlsl_n_s64_x(svptrue_b8(), svreinterpret_s64_s32(x), 32)); +} +static SLEEF_ALWAYS_INLINE vint_sve_sleef vcastu_vi_vm_sve_sleef(vint2_sve_sleef x) { + return svreinterpret_s32_u64( + svlsr_n_u64_x(svptrue_b8(), svreinterpret_u64_s32(x), 32)); +} +static SLEEF_ALWAYS_INLINE vdouble_sve_sleef vcast_vd_vi_sve_sleef(vint_sve_sleef vi) { + return svcvt_f64_s32_x(svptrue_b8(), vi); +} + +static SLEEF_ALWAYS_INLINE vdouble_sve_sleef vcast_vd_d_sve_sleef(double d) { return svdup_n_f64(d); } + +static SLEEF_ALWAYS_INLINE vdouble_sve_sleef vsel_vd_vo_vd_vd_sve_sleef(vopmask_sve_sleef o, vdouble_sve_sleef x, vdouble_sve_sleef y) { + return svsel_f64(o, x, y); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_sve_sleef vsel_vd_vo_d_d_sve_sleef(vopmask_sve_sleef o, double v1, double v0) { + return vsel_vd_vo_vd_vd_sve_sleef(o, vcast_vd_d_sve_sleef(v1), vcast_vd_d_sve_sleef(v0)); +} + +static SLEEF_ALWAYS_INLINE vdouble_sve_sleef vsel_vd_vo_vo_d_d_d_sve_sleef(vopmask_sve_sleef o0, vopmask_sve_sleef o1, double d0, double d1, double d2) { + return vsel_vd_vo_vd_vd_sve_sleef(o0, vcast_vd_d_sve_sleef(d0), vsel_vd_vo_d_d_sve_sleef(o1, d1, d2)); +} + +static SLEEF_ALWAYS_INLINE vdouble_sve_sleef vsel_vd_vo_vo_vo_d_d_d_d_sve_sleef(vopmask_sve_sleef o0, vopmask_sve_sleef o1, vopmask_sve_sleef o2, double d0, double d1, double d2, double d3) { + return vsel_vd_vo_vd_vd_sve_sleef(o0, vcast_vd_d_sve_sleef(d0), vsel_vd_vo_vd_vd_sve_sleef(o1, vcast_vd_d_sve_sleef(d1), vsel_vd_vo_d_d_sve_sleef(o2, d2, d3))); +} + +static SLEEF_ALWAYS_INLINE vint_sve_sleef vsel_vi_vo_vi_vi_sve_sleef(vopmask_sve_sleef o, vint_sve_sleef x, vint_sve_sleef y) { + return svsel_s32(o, x, y); +} + +static SLEEF_ALWAYS_INLINE vdouble_sve_sleef vtruncate_vd_vd_sve_sleef(vdouble_sve_sleef vd_sve_sleef) { + return svrintz_f64_x(svptrue_b8(), vd_sve_sleef); +} +static SLEEF_ALWAYS_INLINE vint_sve_sleef vtruncate_vi_vd_sve_sleef(vdouble_sve_sleef vd_sve_sleef) { + return svcvt_s32_f64_x(svptrue_b8(), vd_sve_sleef); +} +static SLEEF_ALWAYS_INLINE vint_sve_sleef vrint_vi_vd_sve_sleef(vdouble_sve_sleef vd_sve_sleef) { + return svcvt_s32_f64_x(svptrue_b8(), svrintn_f64_x(svptrue_b8(), vd_sve_sleef)); +} +static SLEEF_ALWAYS_INLINE vdouble_sve_sleef vrint_vd_vd_sve_sleef(vdouble_sve_sleef vd_sve_sleef) { + return svrintn_f64_x(svptrue_b8(), vd_sve_sleef); +} + +static SLEEF_ALWAYS_INLINE vdouble_sve_sleef vadd_vd_vd_vd_sve_sleef(vdouble_sve_sleef x, vdouble_sve_sleef y) { + return svadd_f64_x(svptrue_b8(), x, y); +} +static SLEEF_ALWAYS_INLINE vdouble_sve_sleef vsub_vd_vd_vd_sve_sleef(vdouble_sve_sleef x, vdouble_sve_sleef y) { + return svsub_f64_x(svptrue_b8(), x, y); +} +static SLEEF_ALWAYS_INLINE vdouble_sve_sleef vneg_vd_vd_sve_sleef(vdouble_sve_sleef x) { return svneg_f64_x(svptrue_b8(), x); } +static SLEEF_ALWAYS_INLINE vdouble_sve_sleef vmul_vd_vd_vd_sve_sleef(vdouble_sve_sleef x, vdouble_sve_sleef y) { + return svmul_f64_x(svptrue_b8(), x, y); +} +static SLEEF_ALWAYS_INLINE vdouble_sve_sleef vabs_vd_vd_sve_sleef(vdouble_sve_sleef x) { return svabs_f64_x(svptrue_b8(), x); } +static SLEEF_ALWAYS_INLINE vdouble_sve_sleef vmax_vd_vd_vd_sve_sleef(vdouble_sve_sleef x, vdouble_sve_sleef y) { + return svmax_f64_x(svptrue_b8(), x, y); +} +static SLEEF_ALWAYS_INLINE vdouble_sve_sleef vmin_vd_vd_vd_sve_sleef(vdouble_sve_sleef x, vdouble_sve_sleef y) { + return svmin_f64_x(svptrue_b8(), x, y); +} + +static SLEEF_ALWAYS_INLINE vdouble_sve_sleef vmla_vd_vd_vd_vd_sve_sleef(vdouble_sve_sleef x, vdouble_sve_sleef y, + vdouble_sve_sleef z) { + return svmad_f64_x(svptrue_b8(), x, y, z); +} +static SLEEF_ALWAYS_INLINE vdouble_sve_sleef vmlapn_vd_vd_vd_vd_sve_sleef(vdouble_sve_sleef x, vdouble_sve_sleef y, + vdouble_sve_sleef z) { + return svnmsb_f64_x(svptrue_b8(), x, y, z); +} +static SLEEF_ALWAYS_INLINE vdouble_sve_sleef vmlanp_vd_vd_vd_vd_sve_sleef(vdouble_sve_sleef x, vdouble_sve_sleef y, vdouble_sve_sleef z) { + return svmsb_f64_x(svptrue_b8(), x, y, z); +} + +static SLEEF_ALWAYS_INLINE vdouble_sve_sleef vfma_vd_vd_vd_vd_sve_sleef(vdouble_sve_sleef x, vdouble_sve_sleef y, + vdouble_sve_sleef z) { + return svmad_f64_x(svptrue_b8(), x, y, z); +} +static SLEEF_ALWAYS_INLINE vdouble_sve_sleef vfmanp_vd_vd_vd_vd_sve_sleef(vdouble_sve_sleef x, vdouble_sve_sleef y, + vdouble_sve_sleef z) { + return svmsb_f64_x(svptrue_b8(), x, y, z); +} +static SLEEF_ALWAYS_INLINE vdouble_sve_sleef vfmapn_vd_vd_vd_vd_sve_sleef(vdouble_sve_sleef x, vdouble_sve_sleef y, + vdouble_sve_sleef z) { + return svnmsb_f64_x(svptrue_b8(), x, y, z); +} + +static SLEEF_ALWAYS_INLINE vdouble_sve_sleef vdiv_vd_vd_vd_sve_sleef(vdouble_sve_sleef n, vdouble_sve_sleef d) { + + return svdiv_f64_x(svptrue_b8(), n, d); + +} +static SLEEF_ALWAYS_INLINE vdouble_sve_sleef vrec_vd_vd_sve_sleef(vdouble_sve_sleef d) { + + return svdivr_n_f64_x(svptrue_b8(), d, 1.0); + +} +static SLEEF_ALWAYS_INLINE vdouble_sve_sleef vsqrt_vd_vd_sve_sleef(vdouble_sve_sleef d) { + + return svsqrt_f64_x(svptrue_b8(), d); + +} + +static SLEEF_ALWAYS_INLINE vopmask_sve_sleef vlt_vo_vd_vd_sve_sleef(vdouble_sve_sleef x, vdouble_sve_sleef y) { + return svcmplt_f64(svptrue_b8(), x, y); +} +static SLEEF_ALWAYS_INLINE vopmask_sve_sleef veq_vo_vd_vd_sve_sleef(vdouble_sve_sleef x, vdouble_sve_sleef y) { + return svcmpeq_f64(svptrue_b8(), x, y); +} +static SLEEF_ALWAYS_INLINE vopmask_sve_sleef vgt_vo_vd_vd_sve_sleef(vdouble_sve_sleef x, vdouble_sve_sleef y) { + return svcmpgt_f64(svptrue_b8(), x, y); +} +static SLEEF_ALWAYS_INLINE vopmask_sve_sleef vge_vo_vd_vd_sve_sleef(vdouble_sve_sleef x, vdouble_sve_sleef y) { + return svcmpge_f64(svptrue_b8(), x, y); +} +static SLEEF_ALWAYS_INLINE vopmask_sve_sleef vneq_vo_vd_vd_sve_sleef(vdouble_sve_sleef x, vdouble_sve_sleef y) { + return svcmpne_f64(svptrue_b8(), x, y); +} +static SLEEF_ALWAYS_INLINE vopmask_sve_sleef vle_vo_vd_vd_sve_sleef(vdouble_sve_sleef x, vdouble_sve_sleef y) { + return svcmple_f64(svptrue_b8(), x, y); +} + +static SLEEF_ALWAYS_INLINE vopmask_sve_sleef visnan_vo_vd_sve_sleef(vdouble_sve_sleef vd_sve_sleef) { + return svcmpne_f64(svptrue_b8(), vd_sve_sleef, vd_sve_sleef); +} +static SLEEF_ALWAYS_INLINE vopmask_sve_sleef visinf_vo_vd_sve_sleef(vdouble_sve_sleef vd_sve_sleef) { + return svcmpeq_n_f64(svptrue_b8(), svabs_f64_x(svptrue_b8(), vd_sve_sleef), __builtin_inf()); +} +static SLEEF_ALWAYS_INLINE vopmask_sve_sleef vispinf_vo_vd_sve_sleef(vdouble_sve_sleef vd_sve_sleef) { + return svcmpeq_n_f64(svptrue_b8(), vd_sve_sleef, __builtin_inf()); +} +static SLEEF_ALWAYS_INLINE vopmask_sve_sleef visminf_vo_vd_sve_sleef(vdouble_sve_sleef vd_sve_sleef) { + return svcmpeq_n_f64(svptrue_b8(), vd_sve_sleef, -__builtin_inf()); +} + +static SLEEF_ALWAYS_INLINE vopmask_sve_sleef veq64_vo_vm_vm_sve_sleef(vmask_sve_sleef x, vmask_sve_sleef y) { + return svcmpeq_s64(svptrue_b8(), svreinterpret_s64_s32(x), svreinterpret_s64_s32(y)); +} + +static SLEEF_ALWAYS_INLINE vopmask_sve_sleef vcast_vo32_vo64_sve_sleef(vopmask_sve_sleef o) { return o; } +static SLEEF_ALWAYS_INLINE vopmask_sve_sleef vcast_vo64_vo32_sve_sleef(vopmask_sve_sleef o) { return o; } +static SLEEF_ALWAYS_INLINE vopmask_sve_sleef vcast_vo_i_sve_sleef(int i) { return svcmpne_s32(svptrue_b8(), svdup_n_s32(i), svdup_n_s32(0)); } + +static SLEEF_ALWAYS_INLINE vint_sve_sleef vand_vi_vo_vi_sve_sleef(vopmask_sve_sleef x, vint_sve_sleef y) { + + return svand_s32_z(x, y, y); +} + +static SLEEF_ALWAYS_INLINE vint_sve_sleef vandnot_vi_vo_vi_sve_sleef(vopmask_sve_sleef x, vint_sve_sleef y) { + return svsel_s32(x, svdup_n_s32(0x0), y); +} + +static SLEEF_ALWAYS_INLINE vint_sve_sleef vsrl_vi_vi_i_sve_sleef(vint_sve_sleef x, int c) { + return svreinterpret_s32_u32(svlsr_n_u32_x(svptrue_b8(), svreinterpret_u32_s32(x), c)); +} + +static SLEEF_ALWAYS_INLINE vint_sve_sleef vand_vi_vi_vi_sve_sleef(vint_sve_sleef x, vint_sve_sleef y) { + return svand_s32_x(svptrue_b8(), x, y); +} +static SLEEF_ALWAYS_INLINE vint_sve_sleef vandnot_vi_vi_vi_sve_sleef(vint_sve_sleef x, vint_sve_sleef y) { + return svbic_s32_x(svptrue_b8(), y, x); +} +static SLEEF_ALWAYS_INLINE vint_sve_sleef vxor_vi_vi_vi_sve_sleef(vint_sve_sleef x, vint_sve_sleef y) { + return sveor_s32_x(svptrue_b8(), x, y); +} + +static SLEEF_ALWAYS_INLINE vint_sve_sleef vadd_vi_vi_vi_sve_sleef(vint_sve_sleef x, vint_sve_sleef y) { + return svadd_s32_x(svptrue_b8(), x, y); +} +static SLEEF_ALWAYS_INLINE vint_sve_sleef vsub_vi_vi_vi_sve_sleef(vint_sve_sleef x, vint_sve_sleef y) { + return svsub_s32_x(svptrue_b8(), x, y); +} +static SLEEF_ALWAYS_INLINE vint_sve_sleef vneg_vi_vi_sve_sleef(vint_sve_sleef x) { return svneg_s32_x(svptrue_b8(), x); } + +static SLEEF_ALWAYS_INLINE vopmask_sve_sleef vgt_vo_vi_vi_sve_sleef(vint_sve_sleef x, vint_sve_sleef y) { + return svcmpgt_s32(svptrue_b8(), x, y); +} +static SLEEF_ALWAYS_INLINE vopmask_sve_sleef veq_vo_vi_vi_sve_sleef(vint_sve_sleef x, vint_sve_sleef y) { + return svcmpeq_s32(svptrue_b8(), x, y); +} + +static SLEEF_ALWAYS_INLINE vint_sve_sleef vcast_vi_i_sve_sleef(int i) { return svdup_n_s32(i); } + +static SLEEF_ALWAYS_INLINE vmask_sve_sleef vand_vm_vo64_vm_sve_sleef(vopmask_sve_sleef x, vmask_sve_sleef y) { + + return svreinterpret_s32_s64( + svand_s64_z(x, svreinterpret_s64_s32(y), svreinterpret_s64_s32(y))); +} +static SLEEF_ALWAYS_INLINE vmask_sve_sleef vandnot_vm_vo64_vm_sve_sleef(vopmask_sve_sleef x, vmask_sve_sleef y) { + return svreinterpret_s32_s64(svsel_s64( + x, svreinterpret_s64_s32(svdup_n_s32(0x0)), svreinterpret_s64_s32(y))); +} +static SLEEF_ALWAYS_INLINE vmask_sve_sleef vor_vm_vo64_vm_sve_sleef(vopmask_sve_sleef x, vmask_sve_sleef y) { + return svreinterpret_s32_s64(svsel_s64( + x, svreinterpret_s64_s32(svdup_n_s32(0xffffffff)), svreinterpret_s64_s32(y))); +} + +static SLEEF_ALWAYS_INLINE vfloat_sve_sleef vrev21_vf_vf_sve_sleef(vfloat_sve_sleef vf) { + return svreinterpret_f32_u64(svrevw_u64_x(svptrue_b8(), svreinterpret_u64_f32(vf))); +} + +static SLEEF_ALWAYS_INLINE vint2_sve_sleef veq_vi2_vi2_vi2_sve_sleef(vint2_sve_sleef x, vint2_sve_sleef y) { + return svsel_s32(svcmpeq_s32(svptrue_b8(), x, y), svdup_n_s32(0xffffffff), svdup_n_s32(0x0)); +} + +static SLEEF_ALWAYS_INLINE vdouble_sve_sleef vgather_vd_p_vi_sve_sleef(const double *ptr, vint_sve_sleef vi) { + return svld1_gather_s64index_f64(svptrue_b8(), ptr, svreinterpret_s64_s32(vi)); +} + +static SLEEF_ALWAYS_INLINE vfloat_sve_sleef vgather_vf_p_vi2_sve_sleef(const float *ptr, vint2_sve_sleef vi2) { + return svld1_gather_s32index_f32(svptrue_b8(), ptr, vi2); +} + +static SLEEF_ALWAYS_INLINE vdouble_sve_sleef vposneg_vd_vd_sve_sleef(vdouble_sve_sleef d) { + return svneg_f64_m(d, svdupq_n_b64(0, 1), d); +} + +static SLEEF_ALWAYS_INLINE vdouble_sve_sleef vnegpos_vd_vd_sve_sleef(vdouble_sve_sleef d) { + return svneg_f64_m(d, svdupq_n_b64(1, 0), d); +} + +static SLEEF_ALWAYS_INLINE vfloat_sve_sleef vposneg_vf_vf_sve_sleef(vfloat_sve_sleef d) { + return svneg_f32_m(d, svdupq_n_b32(0, 1, 0, 1), d); +} + +static SLEEF_ALWAYS_INLINE vfloat_sve_sleef vnegpos_vf_vf_sve_sleef(vfloat_sve_sleef d) { + return svneg_f32_m(d, svdupq_n_b32(1, 0, 1, 0), d); +} + +static SLEEF_ALWAYS_INLINE vdouble_sve_sleef vsubadd_vd_vd_vd_sve_sleef(vdouble_sve_sleef x, vdouble_sve_sleef y) { return vadd_vd_vd_vd_sve_sleef(x, vnegpos_vd_vd_sve_sleef(y)); } +static SLEEF_ALWAYS_INLINE vfloat_sve_sleef vsubadd_vf_vf_vf_sve_sleef(vfloat_sve_sleef d0, vfloat_sve_sleef d1) { return vadd_vf_vf_vf_sve_sleef(d0, vnegpos_vf_vf_sve_sleef(d1)); } +static SLEEF_ALWAYS_INLINE vdouble_sve_sleef vmlsubadd_vd_vd_vd_vd_sve_sleef(vdouble_sve_sleef x, vdouble_sve_sleef y, vdouble_sve_sleef z) { return vfma_vd_vd_vd_vd_sve_sleef(x, y, vnegpos_vd_vd_sve_sleef(z)); } +static SLEEF_ALWAYS_INLINE vfloat_sve_sleef vmlsubadd_vf_vf_vf_vf_sve_sleef(vfloat_sve_sleef x, vfloat_sve_sleef y, vfloat_sve_sleef z) { return vfma_vf_vf_vf_vf_sve_sleef(x, y, vnegpos_vf_vf_sve_sleef(z)); } + +static SLEEF_ALWAYS_INLINE vdouble_sve_sleef vrev21_vd_vd_sve_sleef(vdouble_sve_sleef x) { return svzip1_f64(svuzp2_f64(x, x), svuzp1_f64(x, x)); } + +static SLEEF_ALWAYS_INLINE vdouble_sve_sleef vreva2_vd_vd_sve_sleef(vdouble_sve_sleef vd_sve_sleef) { + svint64_t x = svindex_s64(((svcntd())-1), -1); + x = svzip1_s64(svuzp2_s64(x, x), svuzp1_s64(x, x)); + return svtbl_f64(vd_sve_sleef, svreinterpret_u64_s64(x)); +} + +static SLEEF_ALWAYS_INLINE vfloat_sve_sleef vreva2_vf_vf_sve_sleef(vfloat_sve_sleef vf) { + svint32_t x = svindex_s32(((svcntw())-1), -1); + x = svzip1_s32(svuzp2_s32(x, x), svuzp1_s32(x, x)); + return svtbl_f32(vf, svreinterpret_u32_s32(x)); +} + +static SLEEF_ALWAYS_INLINE void vscatter2_v_p_i_i_vd_sve_sleef(double *ptr, int offset, int step, vdouble_sve_sleef v) { + svst1_scatter_u64index_f64(svptrue_b8(), ptr + offset*2, svzip1_u64(svindex_u64(0, step*2), svindex_u64(1, step*2)), v); +} + +static SLEEF_ALWAYS_INLINE void vscatter2_v_p_i_i_vf_sve_sleef(float *ptr, int offset, int step, vfloat_sve_sleef v) { + svst1_scatter_u32index_f32(svptrue_b8(), ptr + offset*2, svzip1_u32(svindex_u32(0, step*2), svindex_u32(1, step*2)), v); +} + +static SLEEF_ALWAYS_INLINE void vstore_v_p_vd_sve_sleef(double *ptr, vdouble_sve_sleef v) { vstoreu_v_p_vd_sve_sleef(ptr, v); } +static SLEEF_ALWAYS_INLINE void vstream_v_p_vd_sve_sleef(double *ptr, vdouble_sve_sleef v) { vstore_v_p_vd_sve_sleef(ptr, v); } +static SLEEF_ALWAYS_INLINE void vstore_v_p_vf_sve_sleef(float *ptr, vfloat_sve_sleef v) { vstoreu_v_p_vf_sve_sleef(ptr, v); } +static SLEEF_ALWAYS_INLINE void vstream_v_p_vf_sve_sleef(float *ptr, vfloat_sve_sleef v) { vstore_v_p_vf_sve_sleef(ptr, v); } +static SLEEF_ALWAYS_INLINE void vsscatter2_v_p_i_i_vd_sve_sleef(double *ptr, int offset, int step, vdouble_sve_sleef v) { vscatter2_v_p_i_i_vd_sve_sleef(ptr, offset, step, v); } +static SLEEF_ALWAYS_INLINE void vsscatter2_v_p_i_i_vf_sve_sleef(float *ptr, int offset, int step, vfloat_sve_sleef v) { vscatter2_v_p_i_i_vf_sve_sleef(ptr, offset, step, v); } + +static double vcast_d_vd_sve_sleef(vdouble_sve_sleef v) { + double a[svcntd()]; + vstoreu_v_p_vd_sve_sleef(a, v); + return a[0]; +} + +static float vcast_f_vf_sve_sleef(vfloat_sve_sleef v) { + float a[svcntw()]; + vstoreu_v_p_vf_sve_sleef(a, v); + return a[0]; +} + +static int vcast_i_vi(vint_sve_sleef v) { + int a[svcntw()]; + vstoreu_v_p_vi_sve_sleef(a, v); + return a[0]; +} + +static int vcast_i_vi2(vint2_sve_sleef v) { + int a[svcntw()]; + vstoreu_v_p_vi2_sve_sleef(a, v); + return a[0]; +} + +static vquad_sve_sleef loadu_vq_p_sve_sleef(const int32_t *ptr) { + int32_t a[svcntw()*2]; + memcpy(a, ptr, svcntw()*8); + return svld2_s32(svptrue_b8(), a); +} + +static SLEEF_ALWAYS_INLINE vquad_sve_sleef cast_vq_aq_sve_sleef(vargquad_sve_sleef aq) { return aq; } +static SLEEF_ALWAYS_INLINE vargquad_sve_sleef cast_aq_vq_sve_sleef(vquad_sve_sleef vq) { return vq; } + +static SLEEF_ALWAYS_INLINE int vtestallzeros_i_vo64_sve_sleef(vopmask_sve_sleef g) { + return svcntp_b64(svptrue_b64(), g) == 0; +} + +static SLEEF_ALWAYS_INLINE vmask_sve_sleef vsel_vm_vo64_vm_vm_sve_sleef(vopmask_sve_sleef o, vmask_sve_sleef x, vmask_sve_sleef y) { + return svreinterpret_s32_s64(svsel_s64(o, svreinterpret_s64_s32(x), svreinterpret_s64_s32(y))); +} + +static SLEEF_ALWAYS_INLINE vmask_sve_sleef vsub64_vm_vm_vm_sve_sleef(vmask_sve_sleef x, vmask_sve_sleef y) { + return svreinterpret_s32_s64( + svsub_s64_x(svptrue_b8(), svreinterpret_s64_s32(x), + svreinterpret_s64_s32(y))); +} + +static SLEEF_ALWAYS_INLINE vmask_sve_sleef vneg64_vm_vm_sve_sleef(vmask_sve_sleef x) { + return svreinterpret_s32_s64(svneg_s64_x(svptrue_b8(), svreinterpret_s64_s32(x))); +} + +static SLEEF_ALWAYS_INLINE vopmask_sve_sleef vgt64_vo_vm_vm_sve_sleef(vmask_sve_sleef x, vmask_sve_sleef y) { + return svcmpgt_s64(svptrue_b8(), svreinterpret_s64_s32(x), svreinterpret_s64_s32(y)); +} + +static SLEEF_ALWAYS_INLINE vmask_sve_sleef vcast_vm_vi_sve_sleef(vint_sve_sleef vi) { return svreinterpret_s32_s64(svextw_s64_z(svptrue_b8(), svreinterpret_s64_s32(vi))); } +static SLEEF_ALWAYS_INLINE vint_sve_sleef vcast_vi_vm_sve_sleef(vmask_sve_sleef vm) { return vand_vm_vm_vm_sve_sleef(vm, vcast_vm_i_i_sve_sleef(0, 0xffffffff)); } + +static SLEEF_ALWAYS_INLINE vmask_sve_sleef vreinterpret_vm_vi64_sve_sleef(vint64_sve_sleef v) { return svreinterpret_s32_s64(v); } +static SLEEF_ALWAYS_INLINE vint64_sve_sleef vreinterpret_vi64_vm_sve_sleef(vmask_sve_sleef m) { return svreinterpret_s64_s32(m); } +static SLEEF_ALWAYS_INLINE vmask_sve_sleef vreinterpret_vm_vu64_sve_sleef(vuint64_sve_sleef v) { return svreinterpret_s32_u64(v); } +static SLEEF_ALWAYS_INLINE vuint64_sve_sleef vreinterpret_vu64_vm_sve_sleef(vmask_sve_sleef m) { return svreinterpret_u64_s32(m); } + +typedef struct { + double x, y; +} double2_sve_sleef; + +static SLEEF_ALWAYS_INLINE SLEEF_CONST double2_sve_sleef dd_sve_sleef(double h, double l) { + double2_sve_sleef ret = { h, l }; + return ret; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_sve_sleef vupper_vd_vd_sve_sleef(vdouble_sve_sleef d) { + return vreinterpret_vd_vm_sve_sleef(vand_vm_vm_vm_sve_sleef(vreinterpret_vm_vd_sve_sleef(d), vcast_vm_i_i_sve_sleef(0xffffffff, 0xf8000000))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_sve_sleef vcast_vd2_vd_vd_sve_sleef(vdouble_sve_sleef h, vdouble_sve_sleef l) { + return vd2setxy_vd2_vd_vd_sve_sleef(h, l); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_sve_sleef vcast_vd2_d_d_sve_sleef(double h, double l) { + return vd2setxy_vd2_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(h), vcast_vd_d_sve_sleef(l)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_sve_sleef vcast_vd2_d2_sve_sleef(double2_sve_sleef dd_sve_sleef) { + return vd2setxy_vd2_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(dd_sve_sleef.x), vcast_vd_d_sve_sleef(dd_sve_sleef.y)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_sve_sleef vsel_vd2_vo_vd2_vd2_sve_sleef(vopmask_sve_sleef m, vdouble2_sve_sleef x, vdouble2_sve_sleef y) { + return vd2setxy_vd2_vd_vd_sve_sleef(vsel_vd_vo_vd_vd_sve_sleef(m, vd2getx_vd_vd2_sve_sleef(x), vd2getx_vd_vd2_sve_sleef(y)), + vsel_vd_vo_vd_vd_sve_sleef(m, vd2gety_vd_vd2_sve_sleef(x), vd2gety_vd_vd2_sve_sleef(y))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_sve_sleef vsel_vd2_vo_d_d_d_d_sve_sleef(vopmask_sve_sleef o, double x1, double y1, double x0, double y0) { + return vd2setxy_vd2_vd_vd_sve_sleef(vsel_vd_vo_d_d_sve_sleef(o, x1, x0), + vsel_vd_vo_d_d_sve_sleef(o, y1, y0)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_sve_sleef vadd_vd_3vd_sve_sleef(vdouble_sve_sleef v0, vdouble_sve_sleef v1, vdouble_sve_sleef v2) { + return vadd_vd_vd_vd_sve_sleef(vadd_vd_vd_vd_sve_sleef(v0, v1), v2); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_sve_sleef vadd_vd_4vd_sve_sleef(vdouble_sve_sleef v0, vdouble_sve_sleef v1, vdouble_sve_sleef v2, vdouble_sve_sleef v3) { + return vadd_vd_3vd_sve_sleef(vadd_vd_vd_vd_sve_sleef(v0, v1), v2, v3); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_sve_sleef vadd_vd_5vd_sve_sleef(vdouble_sve_sleef v0, vdouble_sve_sleef v1, vdouble_sve_sleef v2, vdouble_sve_sleef v3, vdouble_sve_sleef v4) { + return vadd_vd_4vd_sve_sleef(vadd_vd_vd_vd_sve_sleef(v0, v1), v2, v3, v4); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_sve_sleef vadd_vd_6vd_sve_sleef(vdouble_sve_sleef v0, vdouble_sve_sleef v1, vdouble_sve_sleef v2, vdouble_sve_sleef v3, vdouble_sve_sleef v4, vdouble_sve_sleef v5) { + return vadd_vd_5vd_sve_sleef(vadd_vd_vd_vd_sve_sleef(v0, v1), v2, v3, v4, v5); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_sve_sleef vadd_vd_7vd_sve_sleef(vdouble_sve_sleef v0, vdouble_sve_sleef v1, vdouble_sve_sleef v2, vdouble_sve_sleef v3, vdouble_sve_sleef v4, vdouble_sve_sleef v5, vdouble_sve_sleef v6) { + return vadd_vd_6vd_sve_sleef(vadd_vd_vd_vd_sve_sleef(v0, v1), v2, v3, v4, v5, v6); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_sve_sleef vsub_vd_3vd_sve_sleef(vdouble_sve_sleef v0, vdouble_sve_sleef v1, vdouble_sve_sleef v2) { + return vsub_vd_vd_vd_sve_sleef(vsub_vd_vd_vd_sve_sleef(v0, v1), v2); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_sve_sleef vsub_vd_4vd_sve_sleef(vdouble_sve_sleef v0, vdouble_sve_sleef v1, vdouble_sve_sleef v2, vdouble_sve_sleef v3) { + return vsub_vd_3vd_sve_sleef(vsub_vd_vd_vd_sve_sleef(v0, v1), v2, v3); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_sve_sleef vsub_vd_5vd_sve_sleef(vdouble_sve_sleef v0, vdouble_sve_sleef v1, vdouble_sve_sleef v2, vdouble_sve_sleef v3, vdouble_sve_sleef v4) { + return vsub_vd_4vd_sve_sleef(vsub_vd_vd_vd_sve_sleef(v0, v1), v2, v3, v4); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_sve_sleef vsub_vd_6vd_sve_sleef(vdouble_sve_sleef v0, vdouble_sve_sleef v1, vdouble_sve_sleef v2, vdouble_sve_sleef v3, vdouble_sve_sleef v4, vdouble_sve_sleef v5) { + return vsub_vd_5vd_sve_sleef(vsub_vd_vd_vd_sve_sleef(v0, v1), v2, v3, v4, v5); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_sve_sleef ddneg_vd2_vd2_sve_sleef(vdouble2_sve_sleef x) { + return vcast_vd2_vd_vd_sve_sleef(vneg_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(x)), vneg_vd_vd_sve_sleef(vd2gety_vd_vd2_sve_sleef(x))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_sve_sleef ddabs_vd2_vd2_sve_sleef(vdouble2_sve_sleef x) { + return vcast_vd2_vd_vd_sve_sleef(vabs_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(x)), + vreinterpret_vd_vm_sve_sleef(vxor_vm_vm_vm_sve_sleef(vreinterpret_vm_vd_sve_sleef(vd2gety_vd_vd2_sve_sleef(x)), + vand_vm_vm_vm_sve_sleef(vreinterpret_vm_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(x)), + vreinterpret_vm_vd_sve_sleef(vcast_vd_d_sve_sleef(-0.0)))))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_sve_sleef ddnormalize_vd2_vd2_sve_sleef(vdouble2_sve_sleef t) { + vdouble_sve_sleef s = vadd_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(t), vd2gety_vd_vd2_sve_sleef(t)); + return vd2setxy_vd2_vd_vd_sve_sleef(s, vadd_vd_vd_vd_sve_sleef(vsub_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(t), s), vd2gety_vd_vd2_sve_sleef(t))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_sve_sleef ddscale_vd2_vd2_vd_sve_sleef(vdouble2_sve_sleef d, vdouble_sve_sleef s) { + return vd2setxy_vd2_vd_vd_sve_sleef(vmul_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(d), s), vmul_vd_vd_vd_sve_sleef(vd2gety_vd_vd2_sve_sleef(d), s)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_sve_sleef ddscale_vd2_vd2_d_sve_sleef(vdouble2_sve_sleef d, double s) { return ddscale_vd2_vd2_vd_sve_sleef(d, vcast_vd_d_sve_sleef(s)); } + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_sve_sleef ddadd_vd2_vd_vd_sve_sleef(vdouble_sve_sleef x, vdouble_sve_sleef y) { + vdouble_sve_sleef s = vadd_vd_vd_vd_sve_sleef(x, y); + return vd2setxy_vd2_vd_vd_sve_sleef(s, vadd_vd_vd_vd_sve_sleef(vsub_vd_vd_vd_sve_sleef(x, s), y)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_sve_sleef ddadd2_vd2_vd_vd_sve_sleef(vdouble_sve_sleef x, vdouble_sve_sleef y) { + vdouble_sve_sleef s = vadd_vd_vd_vd_sve_sleef(x, y); + vdouble_sve_sleef v = vsub_vd_vd_vd_sve_sleef(s, x); + return vd2setxy_vd2_vd_vd_sve_sleef(s, vadd_vd_vd_vd_sve_sleef(vsub_vd_vd_vd_sve_sleef(x, vsub_vd_vd_vd_sve_sleef(s, v)), vsub_vd_vd_vd_sve_sleef(y, v))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_sve_sleef ddadd_vd2_vd2_vd_sve_sleef(vdouble2_sve_sleef x, vdouble_sve_sleef y) { + vdouble_sve_sleef s = vadd_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(x), y); + return vd2setxy_vd2_vd_vd_sve_sleef(s, vadd_vd_3vd_sve_sleef(vsub_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(x), s), y, vd2gety_vd_vd2_sve_sleef(x))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_sve_sleef ddsub_vd2_vd2_vd_sve_sleef(vdouble2_sve_sleef x, vdouble_sve_sleef y) { + vdouble_sve_sleef s = vsub_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(x), y); + return vd2setxy_vd2_vd_vd_sve_sleef(s, vadd_vd_vd_vd_sve_sleef(vsub_vd_vd_vd_sve_sleef(vsub_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(x), s), y), vd2gety_vd_vd2_sve_sleef(x))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_sve_sleef ddadd2_vd2_vd2_vd_sve_sleef(vdouble2_sve_sleef x, vdouble_sve_sleef y) { + vdouble_sve_sleef s = vadd_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(x), y); + vdouble_sve_sleef v = vsub_vd_vd_vd_sve_sleef(s, vd2getx_vd_vd2_sve_sleef(x)); + vdouble_sve_sleef w = vadd_vd_vd_vd_sve_sleef(vsub_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(x), vsub_vd_vd_vd_sve_sleef(s, v)), vsub_vd_vd_vd_sve_sleef(y, v)); + return vd2setxy_vd2_vd_vd_sve_sleef(s, vadd_vd_vd_vd_sve_sleef(w, vd2gety_vd_vd2_sve_sleef(x))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_sve_sleef ddadd_vd2_vd_vd2_sve_sleef(vdouble_sve_sleef x, vdouble2_sve_sleef y) { + vdouble_sve_sleef s = vadd_vd_vd_vd_sve_sleef(x, vd2getx_vd_vd2_sve_sleef(y)); + return vd2setxy_vd2_vd_vd_sve_sleef(s, vadd_vd_3vd_sve_sleef(vsub_vd_vd_vd_sve_sleef(x, s), vd2getx_vd_vd2_sve_sleef(y), vd2gety_vd_vd2_sve_sleef(y))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_sve_sleef ddadd2_vd2_vd_vd2_sve_sleef(vdouble_sve_sleef x, vdouble2_sve_sleef y) { + vdouble_sve_sleef s = vadd_vd_vd_vd_sve_sleef(x, vd2getx_vd_vd2_sve_sleef(y)); + vdouble_sve_sleef v = vsub_vd_vd_vd_sve_sleef(s, x); + return vd2setxy_vd2_vd_vd_sve_sleef(s, vadd_vd_vd_vd_sve_sleef(vadd_vd_vd_vd_sve_sleef(vsub_vd_vd_vd_sve_sleef(x, vsub_vd_vd_vd_sve_sleef(s, v)), + vsub_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(y), v)), vd2gety_vd_vd2_sve_sleef(y))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_sve_sleef ddadd_vd2_vd2_vd2_sve_sleef(vdouble2_sve_sleef x, vdouble2_sve_sleef y) { + + vdouble_sve_sleef s = vadd_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(x), vd2getx_vd_vd2_sve_sleef(y)); + return vd2setxy_vd2_vd_vd_sve_sleef(s, vadd_vd_4vd_sve_sleef(vsub_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(x), s), vd2getx_vd_vd2_sve_sleef(y), vd2gety_vd_vd2_sve_sleef(x), vd2gety_vd_vd2_sve_sleef(y))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_sve_sleef ddadd2_vd2_vd2_vd2_sve_sleef(vdouble2_sve_sleef x, vdouble2_sve_sleef y) { + vdouble_sve_sleef s = vadd_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(x), vd2getx_vd_vd2_sve_sleef(y)); + vdouble_sve_sleef v = vsub_vd_vd_vd_sve_sleef(s, vd2getx_vd_vd2_sve_sleef(x)); + vdouble_sve_sleef t = vadd_vd_vd_vd_sve_sleef(vsub_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(x), vsub_vd_vd_vd_sve_sleef(s, v)), vsub_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(y), v)); + return vd2setxy_vd2_vd_vd_sve_sleef(s, vadd_vd_vd_vd_sve_sleef(t, vadd_vd_vd_vd_sve_sleef(vd2gety_vd_vd2_sve_sleef(x), vd2gety_vd_vd2_sve_sleef(y)))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_sve_sleef ddsub_vd2_vd_vd_sve_sleef(vdouble_sve_sleef x, vdouble_sve_sleef y) { + + vdouble_sve_sleef s = vsub_vd_vd_vd_sve_sleef(x, y); + return vd2setxy_vd2_vd_vd_sve_sleef(s, vsub_vd_vd_vd_sve_sleef(vsub_vd_vd_vd_sve_sleef(x, s), y)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_sve_sleef ddsub_vd2_vd2_vd2_sve_sleef(vdouble2_sve_sleef x, vdouble2_sve_sleef y) { + + vdouble_sve_sleef s = vsub_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(x), vd2getx_vd_vd2_sve_sleef(y)); + vdouble_sve_sleef t = vsub_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(x), s); + t = vsub_vd_vd_vd_sve_sleef(t, vd2getx_vd_vd2_sve_sleef(y)); + t = vadd_vd_vd_vd_sve_sleef(t, vd2gety_vd_vd2_sve_sleef(x)); + return vd2setxy_vd2_vd_vd_sve_sleef(s, vsub_vd_vd_vd_sve_sleef(t, vd2gety_vd_vd2_sve_sleef(y))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_sve_sleef dddiv_vd2_vd2_vd2_sve_sleef(vdouble2_sve_sleef n, vdouble2_sve_sleef d) { + vdouble_sve_sleef t = vrec_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(d)); + vdouble_sve_sleef s = vmul_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(n), t); + vdouble_sve_sleef u = vfmapn_vd_vd_vd_vd_sve_sleef(t, vd2getx_vd_vd2_sve_sleef(n), s); + vdouble_sve_sleef v = vfmanp_vd_vd_vd_vd_sve_sleef(vd2gety_vd_vd2_sve_sleef(d), t, vfmanp_vd_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(d), t, vcast_vd_d_sve_sleef(1))); + return vd2setxy_vd2_vd_vd_sve_sleef(s, vfma_vd_vd_vd_vd_sve_sleef(s, v, vfma_vd_vd_vd_vd_sve_sleef(vd2gety_vd_vd2_sve_sleef(n), t, u))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_sve_sleef ddmul_vd2_vd_vd_sve_sleef(vdouble_sve_sleef x, vdouble_sve_sleef y) { + vdouble_sve_sleef s = vmul_vd_vd_vd_sve_sleef(x, y); + return vd2setxy_vd2_vd_vd_sve_sleef(s, vfmapn_vd_vd_vd_vd_sve_sleef(x, y, s)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_sve_sleef ddsqu_vd2_vd2_sve_sleef(vdouble2_sve_sleef x) { + vdouble_sve_sleef s = vmul_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(x), vd2getx_vd_vd2_sve_sleef(x)); + return vd2setxy_vd2_vd_vd_sve_sleef(s, vfma_vd_vd_vd_vd_sve_sleef(vadd_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(x), vd2getx_vd_vd2_sve_sleef(x)), vd2gety_vd_vd2_sve_sleef(x), vfmapn_vd_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(x), vd2getx_vd_vd2_sve_sleef(x), s))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_sve_sleef ddmul_vd2_vd2_vd2_sve_sleef(vdouble2_sve_sleef x, vdouble2_sve_sleef y) { + vdouble_sve_sleef s = vmul_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(x), vd2getx_vd_vd2_sve_sleef(y)); + return vd2setxy_vd2_vd_vd_sve_sleef(s, vfma_vd_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(x), vd2gety_vd_vd2_sve_sleef(y), vfma_vd_vd_vd_vd_sve_sleef(vd2gety_vd_vd2_sve_sleef(x), vd2getx_vd_vd2_sve_sleef(y), vfmapn_vd_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(x), vd2getx_vd_vd2_sve_sleef(y), s)))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_sve_sleef ddmul_vd_vd2_vd2_sve_sleef(vdouble2_sve_sleef x, vdouble2_sve_sleef y) { + return vfma_vd_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(x), vd2getx_vd_vd2_sve_sleef(y), vfma_vd_vd_vd_vd_sve_sleef(vd2gety_vd_vd2_sve_sleef(x), vd2getx_vd_vd2_sve_sleef(y), vmul_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(x), vd2gety_vd_vd2_sve_sleef(y)))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_sve_sleef ddsqu_vd_vd2_sve_sleef(vdouble2_sve_sleef x) { + return vfma_vd_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(x), vd2getx_vd_vd2_sve_sleef(x), vadd_vd_vd_vd_sve_sleef(vmul_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(x), vd2gety_vd_vd2_sve_sleef(x)), vmul_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(x), vd2gety_vd_vd2_sve_sleef(x)))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_sve_sleef ddmul_vd2_vd2_vd_sve_sleef(vdouble2_sve_sleef x, vdouble_sve_sleef y) { + vdouble_sve_sleef s = vmul_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(x), y); + return vd2setxy_vd2_vd_vd_sve_sleef(s, vfma_vd_vd_vd_vd_sve_sleef(vd2gety_vd_vd2_sve_sleef(x), y, vfmapn_vd_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(x), y, s))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_sve_sleef ddrec_vd2_vd_sve_sleef(vdouble_sve_sleef d) { + vdouble_sve_sleef s = vrec_vd_vd_sve_sleef(d); + return vd2setxy_vd2_vd_vd_sve_sleef(s, vmul_vd_vd_vd_sve_sleef(s, vfmanp_vd_vd_vd_vd_sve_sleef(d, s, vcast_vd_d_sve_sleef(1)))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_sve_sleef ddrec_vd2_vd2_sve_sleef(vdouble2_sve_sleef d) { + vdouble_sve_sleef s = vrec_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(d)); + return vd2setxy_vd2_vd_vd_sve_sleef(s, vmul_vd_vd_vd_sve_sleef(s, vfmanp_vd_vd_vd_vd_sve_sleef(vd2gety_vd_vd2_sve_sleef(d), s, vfmanp_vd_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(d), s, vcast_vd_d_sve_sleef(1))))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_sve_sleef ddsqrt_vd2_vd2_sve_sleef(vdouble2_sve_sleef d) { + vdouble_sve_sleef t = vsqrt_vd_vd_sve_sleef(vadd_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(d), vd2gety_vd_vd2_sve_sleef(d))); + return ddscale_vd2_vd2_vd_sve_sleef(ddmul_vd2_vd2_vd2_sve_sleef(ddadd2_vd2_vd2_vd2_sve_sleef(d, ddmul_vd2_vd_vd_sve_sleef(t, t)), ddrec_vd2_vd_sve_sleef(t)), vcast_vd_d_sve_sleef(0.5)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_sve_sleef ddsqrt_vd2_vd_sve_sleef(vdouble_sve_sleef d) { + vdouble_sve_sleef t = vsqrt_vd_vd_sve_sleef(d); + return ddscale_vd2_vd2_vd_sve_sleef(ddmul_vd2_vd2_vd2_sve_sleef(ddadd2_vd2_vd_vd2_sve_sleef(d, ddmul_vd2_vd_vd_sve_sleef(t, t)), ddrec_vd2_vd_sve_sleef(t)), vcast_vd_d_sve_sleef(0.5)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_sve_sleef ddmla_vd2_vd2_vd2_vd2_sve_sleef(vdouble2_sve_sleef x, vdouble2_sve_sleef y, vdouble2_sve_sleef z) { + return ddadd_vd2_vd2_vd2_sve_sleef(z, ddmul_vd2_vd2_vd2_sve_sleef(x, y)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vopmask_sve_sleef visnegzero_vo_vd_sve_sleef(vdouble_sve_sleef d) { + return veq64_vo_vm_vm_sve_sleef(vreinterpret_vm_vd_sve_sleef(d), vreinterpret_vm_vd_sve_sleef(vcast_vd_d_sve_sleef(-0.0))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vopmask_sve_sleef visnumber_vo_vd_sve_sleef(vdouble_sve_sleef x) { + return vandnot_vo_vo_vo_sve_sleef(visinf_vo_vd_sve_sleef(x), veq_vo_vd_vd_sve_sleef(x, x)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vopmask_sve_sleef visnonfinite_vo_vd_sve_sleef(vdouble_sve_sleef x) { + return veq64_vo_vm_vm_sve_sleef(vand_vm_vm_vm_sve_sleef(vreinterpret_vm_vd_sve_sleef(x), vcast_vm_i64_sve_sleef(INT64_C(0x7ff0000000000000))), vcast_vm_i64_sve_sleef(INT64_C(0x7ff0000000000000))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vmask_sve_sleef vsignbit_vm_vd_sve_sleef(vdouble_sve_sleef d) { + return vand_vm_vm_vm_sve_sleef(vreinterpret_vm_vd_sve_sleef(d), vreinterpret_vm_vd_sve_sleef(vcast_vd_d_sve_sleef(-0.0))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vopmask_sve_sleef vsignbit_vo_vd_sve_sleef(vdouble_sve_sleef d) { + return veq64_vo_vm_vm_sve_sleef(vand_vm_vm_vm_sve_sleef(vreinterpret_vm_vd_sve_sleef(d), vreinterpret_vm_vd_sve_sleef(vcast_vd_d_sve_sleef(-0.0))), vreinterpret_vm_vd_sve_sleef(vcast_vd_d_sve_sleef(-0.0))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_sve_sleef vclearlsb_vd_vd_i_sve_sleef(vdouble_sve_sleef d, int n) { + return vreinterpret_vd_vm_sve_sleef(vand_vm_vm_vm_sve_sleef(vreinterpret_vm_vd_sve_sleef(d), vcast_vm_u64_sve_sleef((~UINT64_C(0)) << n))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_sve_sleef vtoward0_vd_vd_sve_sleef(vdouble_sve_sleef x) { + vdouble_sve_sleef t = vreinterpret_vd_vm_sve_sleef(vadd64_vm_vm_vm_sve_sleef(vreinterpret_vm_vd_sve_sleef(x), vcast_vm_i64_sve_sleef(-1))); + return vsel_vd_vo_vd_vd_sve_sleef(veq_vo_vd_vd_sve_sleef(x, vcast_vd_d_sve_sleef(0)), vcast_vd_d_sve_sleef(0), t); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_sve_sleef vmulsign_vd_vd_vd_sve_sleef(vdouble_sve_sleef x, vdouble_sve_sleef y) { + return vreinterpret_vd_vm_sve_sleef(vxor_vm_vm_vm_sve_sleef(vreinterpret_vm_vd_sve_sleef(x), vsignbit_vm_vd_sve_sleef(y))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_sve_sleef vsign_vd_vd_sve_sleef(vdouble_sve_sleef d) { + return vmulsign_vd_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(1.0), d); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_sve_sleef vorsign_vd_vd_vd_sve_sleef(vdouble_sve_sleef x, vdouble_sve_sleef y) { + return vreinterpret_vd_vm_sve_sleef(vor_vm_vm_vm_sve_sleef(vreinterpret_vm_vd_sve_sleef(x), vsignbit_vm_vd_sve_sleef(y))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_sve_sleef vcopysign_vd_vd_vd_sve_sleef(vdouble_sve_sleef x, vdouble_sve_sleef y) { + return vreinterpret_vd_vm_sve_sleef(vxor_vm_vm_vm_sve_sleef(vandnot_vm_vm_vm_sve_sleef(vreinterpret_vm_vd_sve_sleef(vcast_vd_d_sve_sleef(-0.0)), vreinterpret_vm_vd_sve_sleef(x)), + vand_vm_vm_vm_sve_sleef (vreinterpret_vm_vd_sve_sleef(vcast_vd_d_sve_sleef(-0.0)), vreinterpret_vm_vd_sve_sleef(y)))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_sve_sleef vtruncate2_vd_vd_sve_sleef_sve_sleef(vdouble_sve_sleef x) { + + return vtruncate_vd_vd_sve_sleef(x); + +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_sve_sleef vfloor2_vd_vd_sve_sleef(vdouble_sve_sleef x) { + vdouble_sve_sleef fr = vsub_vd_vd_vd_sve_sleef(x, vmul_vd_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(INT64_C(1) << 31), vcast_vd_vi_sve_sleef(vtruncate_vi_vd_sve_sleef(vmul_vd_vd_vd_sve_sleef(x, vcast_vd_d_sve_sleef(1.0 / (INT64_C(1) << 31))))))); + fr = vsub_vd_vd_vd_sve_sleef(fr, vcast_vd_vi_sve_sleef(vtruncate_vi_vd_sve_sleef(fr))); + fr = vsel_vd_vo_vd_vd_sve_sleef(vlt_vo_vd_vd_sve_sleef(fr, vcast_vd_d_sve_sleef(0)), vadd_vd_vd_vd_sve_sleef(fr, vcast_vd_d_sve_sleef(1.0)), fr); + return vsel_vd_vo_vd_vd_sve_sleef(vor_vo_vo_vo_sve_sleef(visinf_vo_vd_sve_sleef(x), vge_vo_vd_vd_sve_sleef(vabs_vd_vd_sve_sleef(x), vcast_vd_d_sve_sleef(INT64_C(1) << 52))), x, vcopysign_vd_vd_vd_sve_sleef(vsub_vd_vd_vd_sve_sleef(x, fr), x)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_sve_sleef vceil2_vd_vd_sve_sleef(vdouble_sve_sleef x) { + vdouble_sve_sleef fr = vsub_vd_vd_vd_sve_sleef(x, vmul_vd_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(INT64_C(1) << 31), vcast_vd_vi_sve_sleef(vtruncate_vi_vd_sve_sleef(vmul_vd_vd_vd_sve_sleef(x, vcast_vd_d_sve_sleef(1.0 / (INT64_C(1) << 31))))))); + fr = vsub_vd_vd_vd_sve_sleef(fr, vcast_vd_vi_sve_sleef(vtruncate_vi_vd_sve_sleef(fr))); + fr = vsel_vd_vo_vd_vd_sve_sleef(vle_vo_vd_vd_sve_sleef(fr, vcast_vd_d_sve_sleef(0)), fr, vsub_vd_vd_vd_sve_sleef(fr, vcast_vd_d_sve_sleef(1.0))); + return vsel_vd_vo_vd_vd_sve_sleef(vor_vo_vo_vo_sve_sleef(visinf_vo_vd_sve_sleef(x), vge_vo_vd_vd_sve_sleef(vabs_vd_vd_sve_sleef(x), vcast_vd_d_sve_sleef(INT64_C(1) << 52))), x, vcopysign_vd_vd_vd_sve_sleef(vsub_vd_vd_vd_sve_sleef(x, fr), x)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_sve_sleef vround2_vd_vd_sve_sleef(vdouble_sve_sleef d) { + vdouble_sve_sleef x = vadd_vd_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(0.5)); + vdouble_sve_sleef fr = vsub_vd_vd_vd_sve_sleef(x, vmul_vd_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(INT64_C(1) << 31), vcast_vd_vi_sve_sleef(vtruncate_vi_vd_sve_sleef(vmul_vd_vd_vd_sve_sleef(x, vcast_vd_d_sve_sleef(1.0 / (INT64_C(1) << 31))))))); + fr = vsub_vd_vd_vd_sve_sleef(fr, vcast_vd_vi_sve_sleef(vtruncate_vi_vd_sve_sleef(fr))); + x = vsel_vd_vo_vd_vd_sve_sleef(vand_vo_vo_vo_sve_sleef(vle_vo_vd_vd_sve_sleef(x, vcast_vd_d_sve_sleef(0)), veq_vo_vd_vd_sve_sleef(fr, vcast_vd_d_sve_sleef(0))), vsub_vd_vd_vd_sve_sleef(x, vcast_vd_d_sve_sleef(1.0)), x); + fr = vsel_vd_vo_vd_vd_sve_sleef(vlt_vo_vd_vd_sve_sleef(fr, vcast_vd_d_sve_sleef(0)), vadd_vd_vd_vd_sve_sleef(fr, vcast_vd_d_sve_sleef(1.0)), fr); + x = vsel_vd_vo_vd_vd_sve_sleef(veq_vo_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(0.49999999999999994449)), vcast_vd_d_sve_sleef(0), x); + return vsel_vd_vo_vd_vd_sve_sleef(vor_vo_vo_vo_sve_sleef(visinf_vo_vd_sve_sleef(d), vge_vo_vd_vd_sve_sleef(vabs_vd_vd_sve_sleef(d), vcast_vd_d_sve_sleef(INT64_C(1) << 52))), d, vcopysign_vd_vd_vd_sve_sleef(vsub_vd_vd_vd_sve_sleef(x, fr), d)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_sve_sleef vrint2_vd_vd_sve_sleef(vdouble_sve_sleef d) { + + return vrint_vd_vd_sve_sleef(d); + +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vopmask_sve_sleef visint_vo_vd_sve_sleef(vdouble_sve_sleef d) { + return veq_vo_vd_vd_sve_sleef(vrint2_vd_vd_sve_sleef(d), d); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vopmask_sve_sleef visodd_vo_vd_sve_sleef(vdouble_sve_sleef d) { + vdouble_sve_sleef x = vmul_vd_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(0.5)); + return vneq_vo_vd_vd_sve_sleef(vrint2_vd_vd_sve_sleef(x), x); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vint_sve_sleef vilogbk_vi_vd_sve_sleef(vdouble_sve_sleef d) { + vopmask_sve_sleef o = vlt_vo_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(4.9090934652977266E-91)); + d = vsel_vd_vo_vd_vd_sve_sleef(o, vmul_vd_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(2.037035976334486E90), d), d); + vint_sve_sleef q = vcastu_vi_vm_sve_sleef(vreinterpret_vm_vd_sve_sleef(d)); + q = vand_vi_vi_vi_sve_sleef(q, vcast_vi_i_sve_sleef((int)(((1U << 12) - 1) << 20))); + q = vsrl_vi_vi_i_sve_sleef(q, 20); + q = vsub_vi_vi_vi_sve_sleef(q, vsel_vi_vo_vi_vi_sve_sleef(vcast_vo32_vo64_sve_sleef(o), vcast_vi_i_sve_sleef(300 + 0x3ff), vcast_vi_i_sve_sleef(0x3ff))); + return q; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vint_sve_sleef vilogb2k_vi_vd_sve_sleef(vdouble_sve_sleef d) { + vint_sve_sleef q = vcastu_vi_vm_sve_sleef(vreinterpret_vm_vd_sve_sleef(d)); + q = vsrl_vi_vi_i_sve_sleef(q, 20); + q = vand_vi_vi_vi_sve_sleef(q, vcast_vi_i_sve_sleef(0x7ff)); + q = vsub_vi_vi_vi_sve_sleef(q, vcast_vi_i_sve_sleef(0x3ff)); + return q; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vmask_sve_sleef vilogb2k_vm_vd_sve_sleef(vdouble_sve_sleef d) { + vmask_sve_sleef m = vreinterpret_vm_vd_sve_sleef(d); + m = svreinterpret_s32_u64(svlsr_n_u64_x(svptrue_b8(), svreinterpret_u64_s32(m), 20 + 32)); + m = vand_vm_vm_vm_sve_sleef(m, vcast_vm_i64_sve_sleef(0x7ff)); + m = vsub64_vm_vm_vm_sve_sleef(m, vcast_vm_i64_sve_sleef(0x3ff)); + return m; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vmask_sve_sleef vilogb3k_vm_vd_sve_sleef(vdouble_sve_sleef d) { + vmask_sve_sleef m = vreinterpret_vm_vd_sve_sleef(d); + m = svreinterpret_s32_u64(svlsr_n_u64_x(svptrue_b8(), svreinterpret_u64_s32(m), 20 + 32)); + m = vand_vm_vm_vm_sve_sleef(m, vcast_vm_i64_sve_sleef(0x7ff)); + return m; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_sve_sleef vpow2i_vd_vi_sve_sleef(vint_sve_sleef q) { + q = vadd_vi_vi_vi_sve_sleef(vcast_vi_i_sve_sleef(0x3ff), q); + vmask_sve_sleef r = vcastu_vm_vi_sve_sleef(svlsl_n_s32_x(svptrue_b8(), q, 20)); + return vreinterpret_vd_vm_sve_sleef(r); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_sve_sleef vpow2i_vd_vm_sve_sleef(vmask_sve_sleef q) { + q = vadd64_vm_vm_vm_sve_sleef(vcast_vm_i64_sve_sleef(0x3ff), q); + return vreinterpret_vd_vm_sve_sleef(svreinterpret_s32_u64(svlsl_n_u64_x(svptrue_b8(), svreinterpret_u64_s32(q), 52))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_sve_sleef vldexp_vd_vd_vi_sve_sleef(vdouble_sve_sleef x, vint_sve_sleef q) { + vint_sve_sleef m = svasr_n_s32_x(svptrue_b8(), q, 31); + m = svlsl_n_s32_x(svptrue_b8(), vsub_vi_vi_vi_sve_sleef(svasr_n_s32_x(svptrue_b8(), vadd_vi_vi_vi_sve_sleef(m, q), 9), m), 7); + q = vsub_vi_vi_vi_sve_sleef(q, svlsl_n_s32_x(svptrue_b8(), m, 2)); + m = vadd_vi_vi_vi_sve_sleef(vcast_vi_i_sve_sleef(0x3ff), m); + m = vandnot_vi_vo_vi_sve_sleef(vgt_vo_vi_vi_sve_sleef(vcast_vi_i_sve_sleef(0), m), m); + m = vsel_vi_vo_vi_vi_sve_sleef(vgt_vo_vi_vi_sve_sleef(m, vcast_vi_i_sve_sleef(0x7ff)), vcast_vi_i_sve_sleef(0x7ff), m); + vmask_sve_sleef r = vcastu_vm_vi_sve_sleef(svlsl_n_s32_x(svptrue_b8(), m, 20)); + vdouble_sve_sleef y = vreinterpret_vd_vm_sve_sleef(r); + return vmul_vd_vd_vd_sve_sleef(vmul_vd_vd_vd_sve_sleef(vmul_vd_vd_vd_sve_sleef(vmul_vd_vd_vd_sve_sleef(vmul_vd_vd_vd_sve_sleef(x, y), y), y), y), vpow2i_vd_vi_sve_sleef(q)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_sve_sleef vldexp2_vd_vd_vi_sve_sleef(vdouble_sve_sleef d, vint_sve_sleef e) { + return vmul_vd_vd_vd_sve_sleef(vmul_vd_vd_vd_sve_sleef(d, vpow2i_vd_vi_sve_sleef(svasr_n_s32_x(svptrue_b8(), e, 1))), vpow2i_vd_vi_sve_sleef(vsub_vi_vi_vi_sve_sleef(e, svasr_n_s32_x(svptrue_b8(), e, 1)))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_sve_sleef vldexp3_vd_vd_vi_sve_sleef(vdouble_sve_sleef d, vint_sve_sleef q) { + return vreinterpret_vd_vm_sve_sleef(vadd64_vm_vm_vm_sve_sleef(vreinterpret_vm_vd_sve_sleef(d), vcastu_vm_vi_sve_sleef(svlsl_n_s32_x(svptrue_b8(), q, 20)))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_sve_sleef vldexp1_vd_vd_vm_sve_sleef(vdouble_sve_sleef d, vmask_sve_sleef e) { + vmask_sve_sleef m = svreinterpret_s32_u64(svlsr_n_u64_x(svptrue_b8(), svreinterpret_u64_s32(e), 2)); + e = vsub64_vm_vm_vm_sve_sleef(vsub64_vm_vm_vm_sve_sleef(vsub64_vm_vm_vm_sve_sleef(e, m), m), m); + d = vmul_vd_vd_vd_sve_sleef(d, vpow2i_vd_vm_sve_sleef(m)); + d = vmul_vd_vd_vd_sve_sleef(d, vpow2i_vd_vm_sve_sleef(m)); + d = vmul_vd_vd_vd_sve_sleef(d, vpow2i_vd_vm_sve_sleef(m)); + d = vmul_vd_vd_vd_sve_sleef(d, vpow2i_vd_vm_sve_sleef(e)); + return d; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_sve_sleef vldexp2_vd_vd_vm_sve_sleef(vdouble_sve_sleef d, vmask_sve_sleef e) { + return vmul_vd_vd_vd_sve_sleef(vmul_vd_vd_vd_sve_sleef(d, vpow2i_vd_vm_sve_sleef(svreinterpret_s32_u64(svlsr_n_u64_x(svptrue_b8(), svreinterpret_u64_s32(e), 1)))), vpow2i_vd_vm_sve_sleef(vsub64_vm_vm_vm_sve_sleef(e, svreinterpret_s32_u64(svlsr_n_u64_x(svptrue_b8(), svreinterpret_u64_s32(e), 1))))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_sve_sleef vldexp3_vd_vd_vm_sve_sleef(vdouble_sve_sleef d, vmask_sve_sleef q) { + return vreinterpret_vd_vm_sve_sleef(vadd64_vm_vm_vm_sve_sleef(vreinterpret_vm_vd_sve_sleef(d), svreinterpret_s32_u64(svlsl_n_u64_x(svptrue_b8(), svreinterpret_u64_s32(q), 52)))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_sve_sleef vcast_vd_vm_sve_sleef(vmask_sve_sleef m) { return vcast_vd_vi_sve_sleef(vcast_vi_vm_sve_sleef(m)); } +static SLEEF_ALWAYS_INLINE SLEEF_CONST vmask_sve_sleef vtruncate_vm_vd_sve_sleef(vdouble_sve_sleef d) { return vcast_vm_vi_sve_sleef(vtruncate_vi_vd_sve_sleef(d)); } + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vopmask_sve_sleef vlt64_vo_vm_vm_sve_sleef(vmask_sve_sleef x, vmask_sve_sleef y) { return vgt64_vo_vm_vm_sve_sleef(y, x); } + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vopmask_sve_sleef vnot_vo64_vo64_sve_sleef(vopmask_sve_sleef x) { + return vxor_vo_vo_vo_sve_sleef(x, veq64_vo_vm_vm_sve_sleef(vcast_vm_i64_sve_sleef(0), vcast_vm_i64_sve_sleef(0))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vopmask_sve_sleef vugt64_vo_vm_vm_sve_sleef(vmask_sve_sleef x, vmask_sve_sleef y) { + x = vxor_vm_vm_vm_sve_sleef(vcast_vm_u64_sve_sleef(UINT64_C(0x8000000000000000)), x); + y = vxor_vm_vm_vm_sve_sleef(vcast_vm_u64_sve_sleef(UINT64_C(0x8000000000000000)), y); + return vgt64_vo_vm_vm_sve_sleef(x, y); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vmask_sve_sleef vilogbk_vm_vd_sve_sleef(vdouble_sve_sleef d) { + vopmask_sve_sleef o = vlt_vo_vd_vd_sve_sleef(vabs_vd_vd_sve_sleef(d), vcast_vd_d_sve_sleef(4.9090934652977266E-91)); + d = vsel_vd_vo_vd_vd_sve_sleef(o, vmul_vd_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(2.037035976334486E90), d), d); + vmask_sve_sleef q = vreinterpret_vm_vd_sve_sleef(d); + q = svreinterpret_s32_u64(svlsr_n_u64_x(svptrue_b8(), svreinterpret_u64_s32(q), 20 + 32)); + q = vand_vm_vm_vm_sve_sleef(q, vcast_vm_i64_sve_sleef(0x7ff)); + q = vsub64_vm_vm_vm_sve_sleef(q, vsel_vm_vo64_vm_vm_sve_sleef(o, vcast_vm_i64_sve_sleef(300 + 0x3ff), vcast_vm_i64_sve_sleef(0x3ff))); + return q; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vquad_sve_sleef sel_vq_vo_vq_vq_sve_sleef(vopmask_sve_sleef o, vquad_sve_sleef x, vquad_sve_sleef y) { + return vqsetxy_vq_vm_vm_sve_sleef(vsel_vm_vo64_vm_vm_sve_sleef(o, vqgetx_vm_vq_sve_sleef(x), vqgetx_vm_vq_sve_sleef(y)), vsel_vm_vo64_vm_vm_sve_sleef(o, vqgety_vm_vq_sve_sleef(x), vqgety_vm_vq_sve_sleef(y))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vquad_sve_sleef add128_vq_vq_vq_sve_sleef(vquad_sve_sleef x, vquad_sve_sleef y) { + vquad_sve_sleef r = vqsetxy_vq_vm_vm_sve_sleef(vadd64_vm_vm_vm_sve_sleef(vqgetx_vm_vq_sve_sleef(x), vqgetx_vm_vq_sve_sleef(y)), vadd64_vm_vm_vm_sve_sleef(vqgety_vm_vq_sve_sleef(x), vqgety_vm_vq_sve_sleef(y))); + r = vqsety_vq_vq_vm_sve_sleef(r, vadd64_vm_vm_vm_sve_sleef(vqgety_vm_vq_sve_sleef(r), vand_vm_vo64_vm_sve_sleef(vugt64_vo_vm_vm_sve_sleef(vqgetx_vm_vq_sve_sleef(x), vqgetx_vm_vq_sve_sleef(r)), vcast_vm_i64_sve_sleef(1)))); + return r; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vquad_sve_sleef imdvq_vq_vm_vm_sve_sleef(vmask_sve_sleef x, vmask_sve_sleef y) { vquad_sve_sleef r = vqsetxy_vq_vm_vm_sve_sleef(x, y); return r; } + +static SLEEF_ALWAYS_INLINE SLEEF_CONST di_t_sve_sleef rempisub_sve_sleef(vdouble_sve_sleef x) { + + vdouble_sve_sleef y = vrint_vd_vd_sve_sleef(vmul_vd_vd_vd_sve_sleef(x, vcast_vd_d_sve_sleef(4))); + vint_sve_sleef vi = vtruncate_vi_vd_sve_sleef(vsub_vd_vd_vd_sve_sleef(y, vmul_vd_vd_vd_sve_sleef(vrint_vd_vd_sve_sleef(x), vcast_vd_d_sve_sleef(4)))); + return disetdi_di_vd_vi_sve_sleef(vsub_vd_vd_vd_sve_sleef(x, vmul_vd_vd_vd_sve_sleef(y, vcast_vd_d_sve_sleef(0.25))), vi); + +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vint_sve_sleef vsel_vi_vd_vd_vi_vi_sve_sleef(vdouble_sve_sleef d0, vdouble_sve_sleef d1, vint_sve_sleef x, vint_sve_sleef y) { return vsel_vi_vo_vi_vi_sve_sleef(vcast_vo32_vo64_sve_sleef(vlt_vo_vd_vd_sve_sleef(d0, d1)), x, y); } + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vint_sve_sleef vsel_vi_vd_vi_sve_sleef(vdouble_sve_sleef d, vint_sve_sleef x) { return vand_vi_vo_vi_sve_sleef(vcast_vo32_vo64_sve_sleef(vsignbit_vo_vd_sve_sleef(d)), x); } + +SLEEF_INLINE SLEEF_CONST vdouble_sve_sleef Sleef_ldexpdx_sve(vdouble_sve_sleef x, vint_sve_sleef q) { return vldexp_vd_vd_vi_sve_sleef(x, q); } + +SLEEF_INLINE SLEEF_CONST vint_sve_sleef Sleef_ilogbdx_sve(vdouble_sve_sleef d) { + vdouble_sve_sleef e = vcast_vd_vi_sve_sleef(vilogbk_vi_vd_sve_sleef(vabs_vd_vd_sve_sleef(d))); + e = vsel_vd_vo_vd_vd_sve_sleef(veq_vo_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(0)), vcast_vd_d_sve_sleef(SLEEF_FP_ILOGB0), e); + e = vsel_vd_vo_vd_vd_sve_sleef(visnan_vo_vd_sve_sleef(d), vcast_vd_d_sve_sleef(SLEEF_FP_ILOGBNAN), e); + e = vsel_vd_vo_vd_vd_sve_sleef(visinf_vo_vd_sve_sleef(d), vcast_vd_d_sve_sleef(2147483647), e); + return vrint_vi_vd_sve_sleef(e); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST ddi_t_sve_sleef rempi_sve_sleef(vdouble_sve_sleef a) { + vdouble2_sve_sleef x, y; + vint_sve_sleef ex = vilogb2k_vi_vd_sve_sleef(a); + + ex = vsub_vi_vi_vi_sve_sleef(ex, vcast_vi_i_sve_sleef(55)); + vint_sve_sleef q = vand_vi_vo_vi_sve_sleef(vgt_vo_vi_vi_sve_sleef(ex, vcast_vi_i_sve_sleef(700-55)), vcast_vi_i_sve_sleef(-64)); + a = vldexp3_vd_vd_vi_sve_sleef(a, q); + ex = vandnot_vi_vi_vi_sve_sleef(svasr_n_s32_x(svptrue_b8(), ex, 31), ex); + ex = svlsl_n_s32_x(svptrue_b8(), ex, 2); + x = ddmul_vd2_vd_vd_sve_sleef(a, vgather_vd_p_vi_sve_sleef(Sleef_rempitabdp, ex)); + di_t_sve_sleef di = rempisub_sve_sleef(vd2getx_vd_vd2_sve_sleef(x)); + q = digeti_vi_di_sve_sleef(di); + x = vd2setx_vd2_vd2_vd_sve_sleef(x, digetd_vd_di_sve_sleef(di)); + x = ddnormalize_vd2_vd2_sve_sleef(x); + y = ddmul_vd2_vd_vd_sve_sleef(a, vgather_vd_p_vi_sve_sleef(Sleef_rempitabdp+1, ex)); + x = ddadd2_vd2_vd2_vd2_sve_sleef(x, y); + di = rempisub_sve_sleef(vd2getx_vd_vd2_sve_sleef(x)); + q = vadd_vi_vi_vi_sve_sleef(q, digeti_vi_di_sve_sleef(di)); + x = vd2setx_vd2_vd2_vd_sve_sleef(x, digetd_vd_di_sve_sleef(di)); + x = ddnormalize_vd2_vd2_sve_sleef(x); + y = vcast_vd2_vd_vd_sve_sleef(vgather_vd_p_vi_sve_sleef(Sleef_rempitabdp+2, ex), vgather_vd_p_vi_sve_sleef(Sleef_rempitabdp+3, ex)); + y = ddmul_vd2_vd2_vd_sve_sleef(y, a); + x = ddadd2_vd2_vd2_vd2_sve_sleef(x, y); + x = ddnormalize_vd2_vd2_sve_sleef(x); + x = ddmul_vd2_vd2_vd2_sve_sleef(x, vcast_vd2_d_d_sve_sleef(3.141592653589793116*2, 1.2246467991473532072e-16*2)); + vopmask_sve_sleef o = vlt_vo_vd_vd_sve_sleef(vabs_vd_vd_sve_sleef(a), vcast_vd_d_sve_sleef(0.7)); + x = vd2setx_vd2_vd2_vd_sve_sleef(x, vsel_vd_vo_vd_vd_sve_sleef(o, a, vd2getx_vd_vd2_sve_sleef(x))); + x = vd2sety_vd2_vd2_vd_sve_sleef(x, vreinterpret_vd_vm_sve_sleef(vandnot_vm_vo64_vm_sve_sleef(o, vreinterpret_vm_vd_sve_sleef(vd2gety_vd_vd2_sve_sleef(x))))); + return ddisetddi_ddi_vd2_vi_sve_sleef(x, q); +} + +SLEEF_INLINE SLEEF_CONST vdouble_sve_sleef Sleef_sindx_u35sve(vdouble_sve_sleef d) { + + vdouble_sve_sleef u, s, r = d; + vint_sve_sleef ql; + + if (__builtin_expect(!!(vtestallones_i_vo64_sve_sleef(vlt_vo_vd_vd_sve_sleef(vabs_vd_vd_sve_sleef(d), vcast_vd_d_sve_sleef(15)))), 1)) { + vdouble_sve_sleef dql = vrint_vd_vd_sve_sleef(vmul_vd_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(0.318309886183790671537767526745028724))); + ql = vrint_vi_vd_sve_sleef(dql); + d = vmla_vd_vd_vd_vd_sve_sleef(dql, vcast_vd_d_sve_sleef(-3.141592653589793116), d); + d = vmla_vd_vd_vd_vd_sve_sleef(dql, vcast_vd_d_sve_sleef(-1.2246467991473532072e-16), d); + } else if (__builtin_expect(!!(vtestallones_i_vo64_sve_sleef(vlt_vo_vd_vd_sve_sleef(vabs_vd_vd_sve_sleef(d), vcast_vd_d_sve_sleef(1e+14)))), 1)) { + vdouble_sve_sleef dqh = vtruncate_vd_vd_sve_sleef(vmul_vd_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(0.318309886183790671537767526745028724 / (1 << 24)))); + dqh = vmul_vd_vd_vd_sve_sleef(dqh, vcast_vd_d_sve_sleef(1 << 24)); + vdouble_sve_sleef dql = vrint_vd_vd_sve_sleef(vmlapn_vd_vd_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(0.318309886183790671537767526745028724), dqh)); + ql = vrint_vi_vd_sve_sleef(dql); + + d = vmla_vd_vd_vd_vd_sve_sleef(dqh, vcast_vd_d_sve_sleef(-3.1415926218032836914), d); + d = vmla_vd_vd_vd_vd_sve_sleef(dql, vcast_vd_d_sve_sleef(-3.1415926218032836914), d); + d = vmla_vd_vd_vd_vd_sve_sleef(dqh, vcast_vd_d_sve_sleef(-3.1786509424591713469e-08), d); + d = vmla_vd_vd_vd_vd_sve_sleef(dql, vcast_vd_d_sve_sleef(-3.1786509424591713469e-08), d); + d = vmla_vd_vd_vd_vd_sve_sleef(dqh, vcast_vd_d_sve_sleef(-1.2246467864107188502e-16), d); + d = vmla_vd_vd_vd_vd_sve_sleef(dql, vcast_vd_d_sve_sleef(-1.2246467864107188502e-16), d); + d = vmla_vd_vd_vd_vd_sve_sleef(vadd_vd_vd_vd_sve_sleef(dqh, dql), vcast_vd_d_sve_sleef(-1.2736634327021899816e-24), d); + } else { + ddi_t_sve_sleef ddi_sve_sleef = rempi_sve_sleef(d); + ql = vand_vi_vi_vi_sve_sleef(ddigeti_vi_ddi_sve_sleef(ddi_sve_sleef), vcast_vi_i_sve_sleef(3)); + ql = vadd_vi_vi_vi_sve_sleef(vadd_vi_vi_vi_sve_sleef(ql, ql), vsel_vi_vo_vi_vi_sve_sleef(vcast_vo32_vo64_sve_sleef(vgt_vo_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(ddigetdd_vd2_ddi_sve_sleef(ddi_sve_sleef)), vcast_vd_d_sve_sleef(0))), vcast_vi_i_sve_sleef(2), vcast_vi_i_sve_sleef(1))); + ql = svasr_n_s32_x(svptrue_b8(), ql, 2); + vopmask_sve_sleef o = veq_vo_vi_vi_sve_sleef(vand_vi_vi_vi_sve_sleef(ddigeti_vi_ddi_sve_sleef(ddi_sve_sleef), vcast_vi_i_sve_sleef(1)), vcast_vi_i_sve_sleef(1)); + vdouble2_sve_sleef x = vcast_vd2_vd_vd_sve_sleef(vmulsign_vd_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(-3.141592653589793116 * 0.5), vd2getx_vd_vd2_sve_sleef(ddigetdd_vd2_ddi_sve_sleef(ddi_sve_sleef))), + vmulsign_vd_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(-1.2246467991473532072e-16 * 0.5), vd2getx_vd_vd2_sve_sleef(ddigetdd_vd2_ddi_sve_sleef(ddi_sve_sleef)))); + x = ddadd2_vd2_vd2_vd2_sve_sleef(ddigetdd_vd2_ddi_sve_sleef(ddi_sve_sleef), x); + ddi_sve_sleef = ddisetdd_ddi_ddi_vd2_sve_sleef(ddi_sve_sleef, vsel_vd2_vo_vd2_vd2_sve_sleef(vcast_vo64_vo32_sve_sleef(o), x, ddigetdd_vd2_ddi_sve_sleef(ddi_sve_sleef))); + d = vadd_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(ddigetdd_vd2_ddi_sve_sleef(ddi_sve_sleef)), vd2gety_vd_vd2_sve_sleef(ddigetdd_vd2_ddi_sve_sleef(ddi_sve_sleef))); + d = vreinterpret_vd_vm_sve_sleef(vor_vm_vo64_vm_sve_sleef(vor_vo_vo_vo_sve_sleef(visinf_vo_vd_sve_sleef(r), visnan_vo_vd_sve_sleef(r)), vreinterpret_vm_vd_sve_sleef(d))); + } + + s = vmul_vd_vd_vd_sve_sleef(d, d); + + d = vreinterpret_vd_vm_sve_sleef(vxor_vm_vm_vm_sve_sleef(vand_vm_vo64_vm_sve_sleef(vcast_vo64_vo32_sve_sleef(veq_vo_vi_vi_sve_sleef(vand_vi_vi_vi_sve_sleef(ql, vcast_vi_i_sve_sleef(1)), vcast_vi_i_sve_sleef(1))), vreinterpret_vm_vd_sve_sleef(vcast_vd_d_sve_sleef(-0.0))), vreinterpret_vm_vd_sve_sleef(d))); + + vdouble_sve_sleef s2 = vmul_vd_vd_vd_sve_sleef(s, s), s4 = vmul_vd_vd_vd_sve_sleef(s2, s2); + u = vmla_vd_vd_vd_vd_sve_sleef((s4), (vmla_vd_vd_vd_vd_sve_sleef((s2), (vmla_vd_vd_vd_vd_sve_sleef((s), (vcast_vd_d_sve_sleef(-7.97255955009037868891952e-18)), (vcast_vd_d_sve_sleef(2.81009972710863200091251e-15)))), (vmla_vd_vd_vd_vd_sve_sleef((s), (vcast_vd_d_sve_sleef(-7.64712219118158833288484e-13)), (vcast_vd_d_sve_sleef(1.60590430605664501629054e-10)))))), (vmla_vd_vd_vd_vd_sve_sleef((s2), (vmla_vd_vd_vd_vd_sve_sleef((s), (vcast_vd_d_sve_sleef(-2.50521083763502045810755e-08)), (vcast_vd_d_sve_sleef(2.75573192239198747630416e-06)))), (vmla_vd_vd_vd_vd_sve_sleef((s), (vcast_vd_d_sve_sleef(-0.000198412698412696162806809)), (vcast_vd_d_sve_sleef(0.00833333333333332974823815))))))) + + ; + u = vmla_vd_vd_vd_vd_sve_sleef(u, s, vcast_vd_d_sve_sleef(-0.166666666666666657414808)); + + u = vadd_vd_vd_vd_sve_sleef(vmul_vd_vd_vd_sve_sleef(s, vmul_vd_vd_vd_sve_sleef(u, d)), d); + + u = vsel_vd_vo_vd_vd_sve_sleef(visnegzero_vo_vd_sve_sleef(r), r, u); + + return u; + +} + +SLEEF_INLINE SLEEF_CONST vdouble_sve_sleef Sleef_sindx_u10sve(vdouble_sve_sleef d) { + + vdouble_sve_sleef u; + vdouble2_sve_sleef s, t, x; + vint_sve_sleef ql; + + if (__builtin_expect(!!(vtestallones_i_vo64_sve_sleef(vlt_vo_vd_vd_sve_sleef(vabs_vd_vd_sve_sleef(d), vcast_vd_d_sve_sleef(15)))), 1)) { + const vdouble_sve_sleef dql = vrint_vd_vd_sve_sleef(vmul_vd_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(0.318309886183790671537767526745028724))); + ql = vrint_vi_vd_sve_sleef(dql); + u = vmla_vd_vd_vd_vd_sve_sleef(dql, vcast_vd_d_sve_sleef(-3.141592653589793116), d); + s = ddadd_vd2_vd_vd_sve_sleef (u, vmul_vd_vd_vd_sve_sleef(dql, vcast_vd_d_sve_sleef(-1.2246467991473532072e-16))); + } else if (__builtin_expect(!!(vtestallones_i_vo64_sve_sleef(vlt_vo_vd_vd_sve_sleef(vabs_vd_vd_sve_sleef(d), vcast_vd_d_sve_sleef(1e+14)))), 1)) { + vdouble_sve_sleef dqh = vtruncate_vd_vd_sve_sleef(vmul_vd_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(0.318309886183790671537767526745028724 / (1 << 24)))); + dqh = vmul_vd_vd_vd_sve_sleef(dqh, vcast_vd_d_sve_sleef(1 << 24)); + const vdouble_sve_sleef dql = vrint_vd_vd_sve_sleef(vmlapn_vd_vd_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(0.318309886183790671537767526745028724), dqh)); + ql = vrint_vi_vd_sve_sleef(dql); + + u = vmla_vd_vd_vd_vd_sve_sleef(dqh, vcast_vd_d_sve_sleef(-3.1415926218032836914), d); + s = ddadd_vd2_vd_vd_sve_sleef (u, vmul_vd_vd_vd_sve_sleef(dql, vcast_vd_d_sve_sleef(-3.1415926218032836914))); + s = ddadd2_vd2_vd2_vd_sve_sleef(s, vmul_vd_vd_vd_sve_sleef(dqh, vcast_vd_d_sve_sleef(-3.1786509424591713469e-08))); + s = ddadd2_vd2_vd2_vd_sve_sleef(s, vmul_vd_vd_vd_sve_sleef(dql, vcast_vd_d_sve_sleef(-3.1786509424591713469e-08))); + s = ddadd2_vd2_vd2_vd_sve_sleef(s, vmul_vd_vd_vd_sve_sleef(dqh, vcast_vd_d_sve_sleef(-1.2246467864107188502e-16))); + s = ddadd2_vd2_vd2_vd_sve_sleef(s, vmul_vd_vd_vd_sve_sleef(dql, vcast_vd_d_sve_sleef(-1.2246467864107188502e-16))); + s = ddadd_vd2_vd2_vd_sve_sleef(s, vmul_vd_vd_vd_sve_sleef(vadd_vd_vd_vd_sve_sleef(dqh, dql), vcast_vd_d_sve_sleef(-1.2736634327021899816e-24))); + } else { + ddi_t_sve_sleef ddi_sve_sleef = rempi_sve_sleef(d); + ql = vand_vi_vi_vi_sve_sleef(ddigeti_vi_ddi_sve_sleef(ddi_sve_sleef), vcast_vi_i_sve_sleef(3)); + ql = vadd_vi_vi_vi_sve_sleef(vadd_vi_vi_vi_sve_sleef(ql, ql), vsel_vi_vo_vi_vi_sve_sleef(vcast_vo32_vo64_sve_sleef(vgt_vo_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(ddigetdd_vd2_ddi_sve_sleef(ddi_sve_sleef)), vcast_vd_d_sve_sleef(0))), vcast_vi_i_sve_sleef(2), vcast_vi_i_sve_sleef(1))); + ql = svasr_n_s32_x(svptrue_b8(), ql, 2); + vopmask_sve_sleef o = veq_vo_vi_vi_sve_sleef(vand_vi_vi_vi_sve_sleef(ddigeti_vi_ddi_sve_sleef(ddi_sve_sleef), vcast_vi_i_sve_sleef(1)), vcast_vi_i_sve_sleef(1)); + vdouble2_sve_sleef x = vcast_vd2_vd_vd_sve_sleef(vmulsign_vd_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(-3.141592653589793116 * 0.5), vd2getx_vd_vd2_sve_sleef(ddigetdd_vd2_ddi_sve_sleef(ddi_sve_sleef))), + vmulsign_vd_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(-1.2246467991473532072e-16 * 0.5), vd2getx_vd_vd2_sve_sleef(ddigetdd_vd2_ddi_sve_sleef(ddi_sve_sleef)))); + x = ddadd2_vd2_vd2_vd2_sve_sleef(ddigetdd_vd2_ddi_sve_sleef(ddi_sve_sleef), x); + ddi_sve_sleef = ddisetdd_ddi_ddi_vd2_sve_sleef(ddi_sve_sleef, vsel_vd2_vo_vd2_vd2_sve_sleef(vcast_vo64_vo32_sve_sleef(o), x, ddigetdd_vd2_ddi_sve_sleef(ddi_sve_sleef))); + s = ddnormalize_vd2_vd2_sve_sleef(ddigetdd_vd2_ddi_sve_sleef(ddi_sve_sleef)); + s = vd2setx_vd2_vd2_vd_sve_sleef(s, vreinterpret_vd_vm_sve_sleef(vor_vm_vo64_vm_sve_sleef(vor_vo_vo_vo_sve_sleef(visinf_vo_vd_sve_sleef(d), visnan_vo_vd_sve_sleef(d)), vreinterpret_vm_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(s))))); + } + + t = s; + s = ddsqu_vd2_vd2_sve_sleef(s); + + vdouble_sve_sleef s2 = vmul_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(s), vd2getx_vd_vd2_sve_sleef(s)), s4 = vmul_vd_vd_vd_sve_sleef(s2, s2); + u = vmla_vd_vd_vd_vd_sve_sleef((s4), (vmla_vd_vd_vd_vd_sve_sleef((vd2getx_vd_vd2_sve_sleef(s)), (vcast_vd_d_sve_sleef(2.72052416138529567917983e-15)), (vcast_vd_d_sve_sleef(-7.6429259411395447190023e-13)))), (vmla_vd_vd_vd_vd_sve_sleef((s2), (vmla_vd_vd_vd_vd_sve_sleef((vd2getx_vd_vd2_sve_sleef(s)), (vcast_vd_d_sve_sleef(1.60589370117277896211623e-10)), (vcast_vd_d_sve_sleef(-2.5052106814843123359368e-08)))), (vmla_vd_vd_vd_vd_sve_sleef((vd2getx_vd_vd2_sve_sleef(s)), (vcast_vd_d_sve_sleef(2.75573192104428224777379e-06)), (vcast_vd_d_sve_sleef(-0.000198412698412046454654947))))))) + + ; + u = vmla_vd_vd_vd_vd_sve_sleef(u, vd2getx_vd_vd2_sve_sleef(s), vcast_vd_d_sve_sleef(0.00833333333333318056201922)); + + x = ddadd_vd2_vd_vd2_sve_sleef(vcast_vd_d_sve_sleef(1), ddmul_vd2_vd2_vd2_sve_sleef(ddadd_vd2_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(-0.166666666666666657414808), vmul_vd_vd_vd_sve_sleef(u, vd2getx_vd_vd2_sve_sleef(s))), s)); + u = ddmul_vd_vd2_vd2_sve_sleef(t, x); + + u = vreinterpret_vd_vm_sve_sleef(vxor_vm_vm_vm_sve_sleef(vand_vm_vo64_vm_sve_sleef(vcast_vo64_vo32_sve_sleef(veq_vo_vi_vi_sve_sleef(vand_vi_vi_vi_sve_sleef(ql, vcast_vi_i_sve_sleef(1)), vcast_vi_i_sve_sleef(1))), + vreinterpret_vm_vd_sve_sleef(vcast_vd_d_sve_sleef(-0.0))), vreinterpret_vm_vd_sve_sleef(u))); + u = vsel_vd_vo_vd_vd_sve_sleef(veq_vo_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(0)), d, u); + + return u; + +} + +SLEEF_INLINE SLEEF_CONST vdouble_sve_sleef Sleef_cosdx_u35sve(vdouble_sve_sleef d) { + + vdouble_sve_sleef u, s, r = d; + vint_sve_sleef ql; + + if (__builtin_expect(!!(vtestallones_i_vo64_sve_sleef(vlt_vo_vd_vd_sve_sleef(vabs_vd_vd_sve_sleef(d), vcast_vd_d_sve_sleef(15)))), 1)) { + vdouble_sve_sleef dql = vmla_vd_vd_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(2), + vrint_vd_vd_sve_sleef(vmla_vd_vd_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(0.318309886183790671537767526745028724), vcast_vd_d_sve_sleef(-0.5))), + vcast_vd_d_sve_sleef(1)); + ql = vrint_vi_vd_sve_sleef(dql); + d = vmla_vd_vd_vd_vd_sve_sleef(dql, vcast_vd_d_sve_sleef(-3.141592653589793116 * 0.5), d); + d = vmla_vd_vd_vd_vd_sve_sleef(dql, vcast_vd_d_sve_sleef(-1.2246467991473532072e-16 * 0.5), d); + } else if (__builtin_expect(!!(vtestallones_i_vo64_sve_sleef(vlt_vo_vd_vd_sve_sleef(vabs_vd_vd_sve_sleef(d), vcast_vd_d_sve_sleef(1e+14)))), 1)) { + vdouble_sve_sleef dqh = vtruncate_vd_vd_sve_sleef(vmla_vd_vd_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(0.318309886183790671537767526745028724 / (1 << 23)), vcast_vd_d_sve_sleef(-0.318309886183790671537767526745028724 / (1 << 24)))); + ql = vrint_vi_vd_sve_sleef(vadd_vd_vd_vd_sve_sleef(vmul_vd_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(0.318309886183790671537767526745028724)), + vmla_vd_vd_vd_vd_sve_sleef(dqh, vcast_vd_d_sve_sleef(-(1 << 23)), vcast_vd_d_sve_sleef(-0.5)))); + dqh = vmul_vd_vd_vd_sve_sleef(dqh, vcast_vd_d_sve_sleef(1 << 24)); + ql = vadd_vi_vi_vi_sve_sleef(vadd_vi_vi_vi_sve_sleef(ql, ql), vcast_vi_i_sve_sleef(1)); + vdouble_sve_sleef dql = vcast_vd_vi_sve_sleef(ql); + + d = vmla_vd_vd_vd_vd_sve_sleef(dqh, vcast_vd_d_sve_sleef(-3.1415926218032836914 * 0.5), d); + d = vmla_vd_vd_vd_vd_sve_sleef(dql, vcast_vd_d_sve_sleef(-3.1415926218032836914 * 0.5), d); + d = vmla_vd_vd_vd_vd_sve_sleef(dqh, vcast_vd_d_sve_sleef(-3.1786509424591713469e-08 * 0.5), d); + d = vmla_vd_vd_vd_vd_sve_sleef(dql, vcast_vd_d_sve_sleef(-3.1786509424591713469e-08 * 0.5), d); + d = vmla_vd_vd_vd_vd_sve_sleef(dqh, vcast_vd_d_sve_sleef(-1.2246467864107188502e-16 * 0.5), d); + d = vmla_vd_vd_vd_vd_sve_sleef(dql, vcast_vd_d_sve_sleef(-1.2246467864107188502e-16 * 0.5), d); + d = vmla_vd_vd_vd_vd_sve_sleef(vadd_vd_vd_vd_sve_sleef(dqh, dql), vcast_vd_d_sve_sleef(-1.2736634327021899816e-24 * 0.5), d); + } else { + ddi_t_sve_sleef ddi_sve_sleef = rempi_sve_sleef(d); + ql = vand_vi_vi_vi_sve_sleef(ddigeti_vi_ddi_sve_sleef(ddi_sve_sleef), vcast_vi_i_sve_sleef(3)); + ql = vadd_vi_vi_vi_sve_sleef(vadd_vi_vi_vi_sve_sleef(ql, ql), vsel_vi_vo_vi_vi_sve_sleef(vcast_vo32_vo64_sve_sleef(vgt_vo_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(ddigetdd_vd2_ddi_sve_sleef(ddi_sve_sleef)), vcast_vd_d_sve_sleef(0))), vcast_vi_i_sve_sleef(8), vcast_vi_i_sve_sleef(7))); + ql = svasr_n_s32_x(svptrue_b8(), ql, 1); + vopmask_sve_sleef o = veq_vo_vi_vi_sve_sleef(vand_vi_vi_vi_sve_sleef(ddigeti_vi_ddi_sve_sleef(ddi_sve_sleef), vcast_vi_i_sve_sleef(1)), vcast_vi_i_sve_sleef(0)); + vdouble_sve_sleef y = vsel_vd_vo_vd_vd_sve_sleef(vgt_vo_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(ddigetdd_vd2_ddi_sve_sleef(ddi_sve_sleef)), vcast_vd_d_sve_sleef(0)), vcast_vd_d_sve_sleef(0), vcast_vd_d_sve_sleef(-1)); + vdouble2_sve_sleef x = vcast_vd2_vd_vd_sve_sleef(vmulsign_vd_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(-3.141592653589793116 * 0.5), y), + vmulsign_vd_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(-1.2246467991473532072e-16 * 0.5), y)); + x = ddadd2_vd2_vd2_vd2_sve_sleef(ddigetdd_vd2_ddi_sve_sleef(ddi_sve_sleef), x); + ddi_sve_sleef = ddisetdd_ddi_ddi_vd2_sve_sleef(ddi_sve_sleef, vsel_vd2_vo_vd2_vd2_sve_sleef(vcast_vo64_vo32_sve_sleef(o), x, ddigetdd_vd2_ddi_sve_sleef(ddi_sve_sleef))); + d = vadd_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(ddigetdd_vd2_ddi_sve_sleef(ddi_sve_sleef)), vd2gety_vd_vd2_sve_sleef(ddigetdd_vd2_ddi_sve_sleef(ddi_sve_sleef))); + d = vreinterpret_vd_vm_sve_sleef(vor_vm_vo64_vm_sve_sleef(vor_vo_vo_vo_sve_sleef(visinf_vo_vd_sve_sleef(r), visnan_vo_vd_sve_sleef(r)), vreinterpret_vm_vd_sve_sleef(d))); + } + + s = vmul_vd_vd_vd_sve_sleef(d, d); + + d = vreinterpret_vd_vm_sve_sleef(vxor_vm_vm_vm_sve_sleef(vand_vm_vo64_vm_sve_sleef(vcast_vo64_vo32_sve_sleef(veq_vo_vi_vi_sve_sleef(vand_vi_vi_vi_sve_sleef(ql, vcast_vi_i_sve_sleef(2)), vcast_vi_i_sve_sleef(0))), vreinterpret_vm_vd_sve_sleef(vcast_vd_d_sve_sleef(-0.0))), vreinterpret_vm_vd_sve_sleef(d))); + + vdouble_sve_sleef s2 = vmul_vd_vd_vd_sve_sleef(s, s), s4 = vmul_vd_vd_vd_sve_sleef(s2, s2); + u = vmla_vd_vd_vd_vd_sve_sleef((s4), (vmla_vd_vd_vd_vd_sve_sleef((s2), (vmla_vd_vd_vd_vd_sve_sleef((s), (vcast_vd_d_sve_sleef(-7.97255955009037868891952e-18)), (vcast_vd_d_sve_sleef(2.81009972710863200091251e-15)))), (vmla_vd_vd_vd_vd_sve_sleef((s), (vcast_vd_d_sve_sleef(-7.64712219118158833288484e-13)), (vcast_vd_d_sve_sleef(1.60590430605664501629054e-10)))))), (vmla_vd_vd_vd_vd_sve_sleef((s2), (vmla_vd_vd_vd_vd_sve_sleef((s), (vcast_vd_d_sve_sleef(-2.50521083763502045810755e-08)), (vcast_vd_d_sve_sleef(2.75573192239198747630416e-06)))), (vmla_vd_vd_vd_vd_sve_sleef((s), (vcast_vd_d_sve_sleef(-0.000198412698412696162806809)), (vcast_vd_d_sve_sleef(0.00833333333333332974823815))))))) + + ; + u = vmla_vd_vd_vd_vd_sve_sleef(u, s, vcast_vd_d_sve_sleef(-0.166666666666666657414808)); + + u = vadd_vd_vd_vd_sve_sleef(vmul_vd_vd_vd_sve_sleef(s, vmul_vd_vd_vd_sve_sleef(u, d)), d); + + return u; + +} + +SLEEF_INLINE SLEEF_CONST vdouble_sve_sleef Sleef_cosdx_u10sve(vdouble_sve_sleef d) { + + vdouble_sve_sleef u; + vdouble2_sve_sleef s, t, x; + vint_sve_sleef ql; + + if (__builtin_expect(!!(vtestallones_i_vo64_sve_sleef(vlt_vo_vd_vd_sve_sleef(vabs_vd_vd_sve_sleef(d), vcast_vd_d_sve_sleef(15)))), 1)) { + vdouble_sve_sleef dql = vrint_vd_vd_sve_sleef(vmla_vd_vd_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(0.318309886183790671537767526745028724), vcast_vd_d_sve_sleef(-0.5))); + dql = vmla_vd_vd_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(2), dql, vcast_vd_d_sve_sleef(1)); + ql = vrint_vi_vd_sve_sleef(dql); + s = ddadd2_vd2_vd_vd_sve_sleef(d, vmul_vd_vd_vd_sve_sleef(dql, vcast_vd_d_sve_sleef(-3.141592653589793116*0.5))); + s = ddadd_vd2_vd2_vd_sve_sleef(s, vmul_vd_vd_vd_sve_sleef(dql, vcast_vd_d_sve_sleef(-1.2246467991473532072e-16*0.5))); + } else if (__builtin_expect(!!(vtestallones_i_vo64_sve_sleef(vlt_vo_vd_vd_sve_sleef(vabs_vd_vd_sve_sleef(d), vcast_vd_d_sve_sleef(1e+14)))), 1)) { + vdouble_sve_sleef dqh = vtruncate_vd_vd_sve_sleef(vmla_vd_vd_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(0.318309886183790671537767526745028724 / (1 << 23)), vcast_vd_d_sve_sleef(-0.318309886183790671537767526745028724 / (1 << 24)))); + ql = vrint_vi_vd_sve_sleef(vadd_vd_vd_vd_sve_sleef(vmul_vd_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(0.318309886183790671537767526745028724)), + vmla_vd_vd_vd_vd_sve_sleef(dqh, vcast_vd_d_sve_sleef(-(1 << 23)), vcast_vd_d_sve_sleef(-0.5)))); + dqh = vmul_vd_vd_vd_sve_sleef(dqh, vcast_vd_d_sve_sleef(1 << 24)); + ql = vadd_vi_vi_vi_sve_sleef(vadd_vi_vi_vi_sve_sleef(ql, ql), vcast_vi_i_sve_sleef(1)); + const vdouble_sve_sleef dql = vcast_vd_vi_sve_sleef(ql); + + u = vmla_vd_vd_vd_vd_sve_sleef(dqh, vcast_vd_d_sve_sleef(-3.1415926218032836914 * 0.5), d); + s = ddadd2_vd2_vd_vd_sve_sleef(u, vmul_vd_vd_vd_sve_sleef(dql, vcast_vd_d_sve_sleef(-3.1415926218032836914*0.5))); + s = ddadd2_vd2_vd2_vd_sve_sleef(s, vmul_vd_vd_vd_sve_sleef(dqh, vcast_vd_d_sve_sleef(-3.1786509424591713469e-08*0.5))); + s = ddadd2_vd2_vd2_vd_sve_sleef(s, vmul_vd_vd_vd_sve_sleef(dql, vcast_vd_d_sve_sleef(-3.1786509424591713469e-08*0.5))); + s = ddadd2_vd2_vd2_vd_sve_sleef(s, vmul_vd_vd_vd_sve_sleef(dqh, vcast_vd_d_sve_sleef(-1.2246467864107188502e-16*0.5))); + s = ddadd2_vd2_vd2_vd_sve_sleef(s, vmul_vd_vd_vd_sve_sleef(dql, vcast_vd_d_sve_sleef(-1.2246467864107188502e-16*0.5))); + s = ddadd_vd2_vd2_vd_sve_sleef(s, vmul_vd_vd_vd_sve_sleef(vadd_vd_vd_vd_sve_sleef(dqh, dql), vcast_vd_d_sve_sleef(-1.2736634327021899816e-24*0.5))); + } else { + ddi_t_sve_sleef ddi_sve_sleef = rempi_sve_sleef(d); + ql = vand_vi_vi_vi_sve_sleef(ddigeti_vi_ddi_sve_sleef(ddi_sve_sleef), vcast_vi_i_sve_sleef(3)); + ql = vadd_vi_vi_vi_sve_sleef(vadd_vi_vi_vi_sve_sleef(ql, ql), vsel_vi_vo_vi_vi_sve_sleef(vcast_vo32_vo64_sve_sleef(vgt_vo_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(ddigetdd_vd2_ddi_sve_sleef(ddi_sve_sleef)), vcast_vd_d_sve_sleef(0))), vcast_vi_i_sve_sleef(8), vcast_vi_i_sve_sleef(7))); + ql = svasr_n_s32_x(svptrue_b8(), ql, 1); + vopmask_sve_sleef o = veq_vo_vi_vi_sve_sleef(vand_vi_vi_vi_sve_sleef(ddigeti_vi_ddi_sve_sleef(ddi_sve_sleef), vcast_vi_i_sve_sleef(1)), vcast_vi_i_sve_sleef(0)); + vdouble_sve_sleef y = vsel_vd_vo_vd_vd_sve_sleef(vgt_vo_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(ddigetdd_vd2_ddi_sve_sleef(ddi_sve_sleef)), vcast_vd_d_sve_sleef(0)), vcast_vd_d_sve_sleef(0), vcast_vd_d_sve_sleef(-1)); + vdouble2_sve_sleef x = vcast_vd2_vd_vd_sve_sleef(vmulsign_vd_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(-3.141592653589793116 * 0.5), y), + vmulsign_vd_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(-1.2246467991473532072e-16 * 0.5), y)); + x = ddadd2_vd2_vd2_vd2_sve_sleef(ddigetdd_vd2_ddi_sve_sleef(ddi_sve_sleef), x); + ddi_sve_sleef = ddisetdd_ddi_ddi_vd2_sve_sleef(ddi_sve_sleef, vsel_vd2_vo_vd2_vd2_sve_sleef(vcast_vo64_vo32_sve_sleef(o), x, ddigetdd_vd2_ddi_sve_sleef(ddi_sve_sleef))); + s = ddnormalize_vd2_vd2_sve_sleef(ddigetdd_vd2_ddi_sve_sleef(ddi_sve_sleef)); + s = vd2setx_vd2_vd2_vd_sve_sleef(s, vreinterpret_vd_vm_sve_sleef(vor_vm_vo64_vm_sve_sleef(vor_vo_vo_vo_sve_sleef(visinf_vo_vd_sve_sleef(d), visnan_vo_vd_sve_sleef(d)), vreinterpret_vm_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(s))))); + } + + t = s; + s = ddsqu_vd2_vd2_sve_sleef(s); + + vdouble_sve_sleef s2 = vmul_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(s), vd2getx_vd_vd2_sve_sleef(s)), s4 = vmul_vd_vd_vd_sve_sleef(s2, s2); + u = vmla_vd_vd_vd_vd_sve_sleef((s4), (vmla_vd_vd_vd_vd_sve_sleef((vd2getx_vd_vd2_sve_sleef(s)), (vcast_vd_d_sve_sleef(2.72052416138529567917983e-15)), (vcast_vd_d_sve_sleef(-7.6429259411395447190023e-13)))), (vmla_vd_vd_vd_vd_sve_sleef((s2), (vmla_vd_vd_vd_vd_sve_sleef((vd2getx_vd_vd2_sve_sleef(s)), (vcast_vd_d_sve_sleef(1.60589370117277896211623e-10)), (vcast_vd_d_sve_sleef(-2.5052106814843123359368e-08)))), (vmla_vd_vd_vd_vd_sve_sleef((vd2getx_vd_vd2_sve_sleef(s)), (vcast_vd_d_sve_sleef(2.75573192104428224777379e-06)), (vcast_vd_d_sve_sleef(-0.000198412698412046454654947))))))) + + ; + u = vmla_vd_vd_vd_vd_sve_sleef(u, vd2getx_vd_vd2_sve_sleef(s), vcast_vd_d_sve_sleef(0.00833333333333318056201922)); + + x = ddadd_vd2_vd_vd2_sve_sleef(vcast_vd_d_sve_sleef(1), ddmul_vd2_vd2_vd2_sve_sleef(ddadd_vd2_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(-0.166666666666666657414808), vmul_vd_vd_vd_sve_sleef(u, vd2getx_vd_vd2_sve_sleef(s))), s)); + u = ddmul_vd_vd2_vd2_sve_sleef(t, x); + + u = vreinterpret_vd_vm_sve_sleef(vxor_vm_vm_vm_sve_sleef(vand_vm_vo64_vm_sve_sleef(vcast_vo64_vo32_sve_sleef(veq_vo_vi_vi_sve_sleef(vand_vi_vi_vi_sve_sleef(ql, vcast_vi_i_sve_sleef(2)), vcast_vi_i_sve_sleef(0))), vreinterpret_vm_vd_sve_sleef(vcast_vd_d_sve_sleef(-0.0))), vreinterpret_vm_vd_sve_sleef(u))); + + return u; + +} + +SLEEF_INLINE vdouble2_sve_sleef Sleef_sincosdx_u35sve(vdouble_sve_sleef d) { + + vopmask_sve_sleef o; + vdouble_sve_sleef u, t, rx, ry, s; + vdouble2_sve_sleef r; + vint_sve_sleef ql; + + if (__builtin_expect(!!(vtestallones_i_vo64_sve_sleef(vlt_vo_vd_vd_sve_sleef(vabs_vd_vd_sve_sleef(d), vcast_vd_d_sve_sleef(15)))), 1)) { + vdouble_sve_sleef dql = vrint_vd_vd_sve_sleef(vmul_vd_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(2 * 0.318309886183790671537767526745028724))); + ql = vrint_vi_vd_sve_sleef(dql); + s = vmla_vd_vd_vd_vd_sve_sleef(dql, vcast_vd_d_sve_sleef(-3.141592653589793116 * 0.5), d); + s = vmla_vd_vd_vd_vd_sve_sleef(dql, vcast_vd_d_sve_sleef(-1.2246467991473532072e-16 * 0.5), s); + } else if (__builtin_expect(!!(vtestallones_i_vo64_sve_sleef(vlt_vo_vd_vd_sve_sleef(vabs_vd_vd_sve_sleef(d), vcast_vd_d_sve_sleef(1e+14)))), 1)) { + vdouble_sve_sleef dqh = vtruncate_vd_vd_sve_sleef(vmul_vd_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(2*0.318309886183790671537767526745028724 / (1 << 24)))); + dqh = vmul_vd_vd_vd_sve_sleef(dqh, vcast_vd_d_sve_sleef(1 << 24)); + vdouble_sve_sleef dql = vrint_vd_vd_sve_sleef(vsub_vd_vd_vd_sve_sleef(vmul_vd_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(2*0.318309886183790671537767526745028724)), dqh)); + ql = vrint_vi_vd_sve_sleef(dql); + + s = vmla_vd_vd_vd_vd_sve_sleef(dqh, vcast_vd_d_sve_sleef(-3.1415926218032836914 * 0.5), d); + s = vmla_vd_vd_vd_vd_sve_sleef(dql, vcast_vd_d_sve_sleef(-3.1415926218032836914 * 0.5), s); + s = vmla_vd_vd_vd_vd_sve_sleef(dqh, vcast_vd_d_sve_sleef(-3.1786509424591713469e-08 * 0.5), s); + s = vmla_vd_vd_vd_vd_sve_sleef(dql, vcast_vd_d_sve_sleef(-3.1786509424591713469e-08 * 0.5), s); + s = vmla_vd_vd_vd_vd_sve_sleef(dqh, vcast_vd_d_sve_sleef(-1.2246467864107188502e-16 * 0.5), s); + s = vmla_vd_vd_vd_vd_sve_sleef(dql, vcast_vd_d_sve_sleef(-1.2246467864107188502e-16 * 0.5), s); + s = vmla_vd_vd_vd_vd_sve_sleef(vadd_vd_vd_vd_sve_sleef(dqh, dql), vcast_vd_d_sve_sleef(-1.2736634327021899816e-24 * 0.5), s); + } else { + ddi_t_sve_sleef ddi_sve_sleef = rempi_sve_sleef(d); + ql = ddigeti_vi_ddi_sve_sleef(ddi_sve_sleef); + s = vadd_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(ddigetdd_vd2_ddi_sve_sleef(ddi_sve_sleef)), vd2gety_vd_vd2_sve_sleef(ddigetdd_vd2_ddi_sve_sleef(ddi_sve_sleef))); + s = vreinterpret_vd_vm_sve_sleef(vor_vm_vo64_vm_sve_sleef(vor_vo_vo_vo_sve_sleef(visinf_vo_vd_sve_sleef(d), visnan_vo_vd_sve_sleef(d)), vreinterpret_vm_vd_sve_sleef(s))); + } + + t = s; + + s = vmul_vd_vd_vd_sve_sleef(s, s); + + u = vcast_vd_d_sve_sleef(1.58938307283228937328511e-10); + u = vmla_vd_vd_vd_vd_sve_sleef(u, s, vcast_vd_d_sve_sleef(-2.50506943502539773349318e-08)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, s, vcast_vd_d_sve_sleef(2.75573131776846360512547e-06)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, s, vcast_vd_d_sve_sleef(-0.000198412698278911770864914)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, s, vcast_vd_d_sve_sleef(0.0083333333333191845961746)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, s, vcast_vd_d_sve_sleef(-0.166666666666666130709393)); + + rx = vmla_vd_vd_vd_vd_sve_sleef(vmul_vd_vd_vd_sve_sleef(u, s), t, t); + rx = vsel_vd_vo_vd_vd_sve_sleef(visnegzero_vo_vd_sve_sleef(d), vcast_vd_d_sve_sleef(-0.0), rx); + + u = vcast_vd_d_sve_sleef(-1.13615350239097429531523e-11); + u = vmla_vd_vd_vd_vd_sve_sleef(u, s, vcast_vd_d_sve_sleef(2.08757471207040055479366e-09)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, s, vcast_vd_d_sve_sleef(-2.75573144028847567498567e-07)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, s, vcast_vd_d_sve_sleef(2.48015872890001867311915e-05)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, s, vcast_vd_d_sve_sleef(-0.00138888888888714019282329)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, s, vcast_vd_d_sve_sleef(0.0416666666666665519592062)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, s, vcast_vd_d_sve_sleef(-0.5)); + + ry = vmla_vd_vd_vd_vd_sve_sleef(s, u, vcast_vd_d_sve_sleef(1)); + + o = vcast_vo64_vo32_sve_sleef(veq_vo_vi_vi_sve_sleef(vand_vi_vi_vi_sve_sleef(ql, vcast_vi_i_sve_sleef(1)), vcast_vi_i_sve_sleef(0))); + r = vd2setxy_vd2_vd_vd_sve_sleef(vsel_vd_vo_vd_vd_sve_sleef(o, rx, ry), vsel_vd_vo_vd_vd_sve_sleef(o, ry, rx)); + + o = vcast_vo64_vo32_sve_sleef(veq_vo_vi_vi_sve_sleef(vand_vi_vi_vi_sve_sleef(ql, vcast_vi_i_sve_sleef(2)), vcast_vi_i_sve_sleef(2))); + r = vd2setx_vd2_vd2_vd_sve_sleef(r, vreinterpret_vd_vm_sve_sleef(vxor_vm_vm_vm_sve_sleef(vand_vm_vo64_vm_sve_sleef(o, vreinterpret_vm_vd_sve_sleef(vcast_vd_d_sve_sleef(-0.0))), vreinterpret_vm_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(r))))); + + o = vcast_vo64_vo32_sve_sleef(veq_vo_vi_vi_sve_sleef(vand_vi_vi_vi_sve_sleef(vadd_vi_vi_vi_sve_sleef(ql, vcast_vi_i_sve_sleef(1)), vcast_vi_i_sve_sleef(2)), vcast_vi_i_sve_sleef(2))); + r = vd2sety_vd2_vd2_vd_sve_sleef(r, vreinterpret_vd_vm_sve_sleef(vxor_vm_vm_vm_sve_sleef(vand_vm_vo64_vm_sve_sleef(o, vreinterpret_vm_vd_sve_sleef(vcast_vd_d_sve_sleef(-0.0))), vreinterpret_vm_vd_sve_sleef(vd2gety_vd_vd2_sve_sleef(r))))); + + return r; + +} + +SLEEF_INLINE vdouble2_sve_sleef Sleef_sincosdx_u10sve(vdouble_sve_sleef d) { + + vopmask_sve_sleef o; + vdouble_sve_sleef u, rx, ry; + vdouble2_sve_sleef r, s, t, x; + vint_sve_sleef ql; + + if (__builtin_expect(!!(vtestallones_i_vo64_sve_sleef(vlt_vo_vd_vd_sve_sleef(vabs_vd_vd_sve_sleef(d), vcast_vd_d_sve_sleef(15)))), 1)) { + const vdouble_sve_sleef dql = vrint_vd_vd_sve_sleef(vmul_vd_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(2 * 0.318309886183790671537767526745028724))); + ql = vrint_vi_vd_sve_sleef(dql); + u = vmla_vd_vd_vd_vd_sve_sleef(dql, vcast_vd_d_sve_sleef(-3.141592653589793116*0.5), d); + s = ddadd_vd2_vd_vd_sve_sleef (u, vmul_vd_vd_vd_sve_sleef(dql, vcast_vd_d_sve_sleef(-1.2246467991473532072e-16*0.5))); + } else if (__builtin_expect(!!(vtestallones_i_vo64_sve_sleef(vlt_vo_vd_vd_sve_sleef(vabs_vd_vd_sve_sleef(d), vcast_vd_d_sve_sleef(1e+14)))), 1)) { + vdouble_sve_sleef dqh = vtruncate_vd_vd_sve_sleef(vmul_vd_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(2*0.318309886183790671537767526745028724 / (1 << 24)))); + dqh = vmul_vd_vd_vd_sve_sleef(dqh, vcast_vd_d_sve_sleef(1 << 24)); + const vdouble_sve_sleef dql = vrint_vd_vd_sve_sleef(vsub_vd_vd_vd_sve_sleef(vmul_vd_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(2*0.318309886183790671537767526745028724)), dqh)); + ql = vrint_vi_vd_sve_sleef(dql); + + u = vmla_vd_vd_vd_vd_sve_sleef(dqh, vcast_vd_d_sve_sleef(-3.1415926218032836914 * 0.5), d); + s = ddadd_vd2_vd_vd_sve_sleef(u, vmul_vd_vd_vd_sve_sleef(dql, vcast_vd_d_sve_sleef(-3.1415926218032836914*0.5))); + s = ddadd2_vd2_vd2_vd_sve_sleef(s, vmul_vd_vd_vd_sve_sleef(dqh, vcast_vd_d_sve_sleef(-3.1786509424591713469e-08*0.5))); + s = ddadd2_vd2_vd2_vd_sve_sleef(s, vmul_vd_vd_vd_sve_sleef(dql, vcast_vd_d_sve_sleef(-3.1786509424591713469e-08*0.5))); + s = ddadd2_vd2_vd2_vd_sve_sleef(s, vmul_vd_vd_vd_sve_sleef(dqh, vcast_vd_d_sve_sleef(-1.2246467864107188502e-16*0.5))); + s = ddadd2_vd2_vd2_vd_sve_sleef(s, vmul_vd_vd_vd_sve_sleef(dql, vcast_vd_d_sve_sleef(-1.2246467864107188502e-16*0.5))); + s = ddadd_vd2_vd2_vd_sve_sleef(s, vmul_vd_vd_vd_sve_sleef(vadd_vd_vd_vd_sve_sleef(dqh, dql), vcast_vd_d_sve_sleef(-1.2736634327021899816e-24*0.5))); + } else { + ddi_t_sve_sleef ddi_sve_sleef = rempi_sve_sleef(d); + ql = ddigeti_vi_ddi_sve_sleef(ddi_sve_sleef); + s = ddigetdd_vd2_ddi_sve_sleef(ddi_sve_sleef); + o = vor_vo_vo_vo_sve_sleef(visinf_vo_vd_sve_sleef(d), visnan_vo_vd_sve_sleef(d)); + s = vd2setxy_vd2_vd_vd_sve_sleef(vreinterpret_vd_vm_sve_sleef(vor_vm_vo64_vm_sve_sleef(o, vreinterpret_vm_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(s)))), + vreinterpret_vd_vm_sve_sleef(vor_vm_vo64_vm_sve_sleef(o, vreinterpret_vm_vd_sve_sleef(vd2gety_vd_vd2_sve_sleef(s))))); + } + + t = s; + + s = vd2setx_vd2_vd2_vd_sve_sleef(s, ddsqu_vd_vd2_sve_sleef(s)); + + u = vcast_vd_d_sve_sleef(1.58938307283228937328511e-10); + u = vmla_vd_vd_vd_vd_sve_sleef(u, vd2getx_vd_vd2_sve_sleef(s), vcast_vd_d_sve_sleef(-2.50506943502539773349318e-08)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, vd2getx_vd_vd2_sve_sleef(s), vcast_vd_d_sve_sleef(2.75573131776846360512547e-06)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, vd2getx_vd_vd2_sve_sleef(s), vcast_vd_d_sve_sleef(-0.000198412698278911770864914)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, vd2getx_vd_vd2_sve_sleef(s), vcast_vd_d_sve_sleef(0.0083333333333191845961746)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, vd2getx_vd_vd2_sve_sleef(s), vcast_vd_d_sve_sleef(-0.166666666666666130709393)); + + u = vmul_vd_vd_vd_sve_sleef(u, vmul_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(s), vd2getx_vd_vd2_sve_sleef(t))); + + x = ddadd_vd2_vd2_vd_sve_sleef(t, u); + rx = vadd_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(x), vd2gety_vd_vd2_sve_sleef(x)); + + rx = vsel_vd_vo_vd_vd_sve_sleef(visnegzero_vo_vd_sve_sleef(d), vcast_vd_d_sve_sleef(-0.0), rx); + + u = vcast_vd_d_sve_sleef(-1.13615350239097429531523e-11); + u = vmla_vd_vd_vd_vd_sve_sleef(u, vd2getx_vd_vd2_sve_sleef(s), vcast_vd_d_sve_sleef(2.08757471207040055479366e-09)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, vd2getx_vd_vd2_sve_sleef(s), vcast_vd_d_sve_sleef(-2.75573144028847567498567e-07)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, vd2getx_vd_vd2_sve_sleef(s), vcast_vd_d_sve_sleef(2.48015872890001867311915e-05)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, vd2getx_vd_vd2_sve_sleef(s), vcast_vd_d_sve_sleef(-0.00138888888888714019282329)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, vd2getx_vd_vd2_sve_sleef(s), vcast_vd_d_sve_sleef(0.0416666666666665519592062)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, vd2getx_vd_vd2_sve_sleef(s), vcast_vd_d_sve_sleef(-0.5)); + + x = ddadd_vd2_vd_vd2_sve_sleef(vcast_vd_d_sve_sleef(1), ddmul_vd2_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(s), u)); + ry = vadd_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(x), vd2gety_vd_vd2_sve_sleef(x)); + + o = vcast_vo64_vo32_sve_sleef(veq_vo_vi_vi_sve_sleef(vand_vi_vi_vi_sve_sleef(ql, vcast_vi_i_sve_sleef(1)), vcast_vi_i_sve_sleef(0))); + r = vd2setxy_vd2_vd_vd_sve_sleef(vsel_vd_vo_vd_vd_sve_sleef(o, rx, ry), vsel_vd_vo_vd_vd_sve_sleef(o, ry, rx)); + + o = vcast_vo64_vo32_sve_sleef(veq_vo_vi_vi_sve_sleef(vand_vi_vi_vi_sve_sleef(ql, vcast_vi_i_sve_sleef(2)), vcast_vi_i_sve_sleef(2))); + r = vd2setx_vd2_vd2_vd_sve_sleef(r, vreinterpret_vd_vm_sve_sleef(vxor_vm_vm_vm_sve_sleef(vand_vm_vo64_vm_sve_sleef(o, vreinterpret_vm_vd_sve_sleef(vcast_vd_d_sve_sleef(-0.0))), vreinterpret_vm_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(r))))); + + o = vcast_vo64_vo32_sve_sleef(veq_vo_vi_vi_sve_sleef(vand_vi_vi_vi_sve_sleef(vadd_vi_vi_vi_sve_sleef(ql, vcast_vi_i_sve_sleef(1)), vcast_vi_i_sve_sleef(2)), vcast_vi_i_sve_sleef(2))); + r = vd2sety_vd2_vd2_vd_sve_sleef(r, vreinterpret_vd_vm_sve_sleef(vxor_vm_vm_vm_sve_sleef(vand_vm_vo64_vm_sve_sleef(o, vreinterpret_vm_vd_sve_sleef(vcast_vd_d_sve_sleef(-0.0))), vreinterpret_vm_vd_sve_sleef(vd2gety_vd_vd2_sve_sleef(r))))); + + return r; + +} + +SLEEF_INLINE vdouble2_sve_sleef Sleef_sincospidx_u05sve(vdouble_sve_sleef d) { + vopmask_sve_sleef o; + vdouble_sve_sleef u, s, t, rx, ry; + vdouble2_sve_sleef r, x, s2; + + u = vmul_vd_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(4.0)); + vint_sve_sleef q = vtruncate_vi_vd_sve_sleef(u); + q = vand_vi_vi_vi_sve_sleef(vadd_vi_vi_vi_sve_sleef(q, vxor_vi_vi_vi_sve_sleef(vsrl_vi_vi_i_sve_sleef(q, 31), vcast_vi_i_sve_sleef(1))), vcast_vi_i_sve_sleef(~1)); + s = vsub_vd_vd_vd_sve_sleef(u, vcast_vd_vi_sve_sleef(q)); + + t = s; + s = vmul_vd_vd_vd_sve_sleef(s, s); + s2 = ddmul_vd2_vd_vd_sve_sleef(t, t); + + u = vcast_vd_d_sve_sleef(-2.02461120785182399295868e-14); + u = vmla_vd_vd_vd_vd_sve_sleef(u, s, vcast_vd_d_sve_sleef(6.94821830580179461327784e-12)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, s, vcast_vd_d_sve_sleef(-1.75724749952853179952664e-09)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, s, vcast_vd_d_sve_sleef(3.13361688966868392878422e-07)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, s, vcast_vd_d_sve_sleef(-3.6576204182161551920361e-05)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, s, vcast_vd_d_sve_sleef(0.00249039457019271850274356)); + x = ddadd2_vd2_vd_vd2_sve_sleef(vmul_vd_vd_vd_sve_sleef(u, s), vcast_vd2_d_d_sve_sleef(-0.0807455121882807852484731, 3.61852475067037104849987e-18)); + x = ddadd2_vd2_vd2_vd2_sve_sleef(ddmul_vd2_vd2_vd2_sve_sleef(s2, x), vcast_vd2_d_d_sve_sleef(0.785398163397448278999491, 3.06287113727155002607105e-17)); + + x = ddmul_vd2_vd2_vd_sve_sleef(x, t); + rx = vadd_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(x), vd2gety_vd_vd2_sve_sleef(x)); + + rx = vsel_vd_vo_vd_vd_sve_sleef(visnegzero_vo_vd_sve_sleef(d), vcast_vd_d_sve_sleef(-0.0), rx); + + u = vcast_vd_d_sve_sleef(9.94480387626843774090208e-16); + u = vmla_vd_vd_vd_vd_sve_sleef(u, s, vcast_vd_d_sve_sleef(-3.89796226062932799164047e-13)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, s, vcast_vd_d_sve_sleef(1.15011582539996035266901e-10)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, s, vcast_vd_d_sve_sleef(-2.4611369501044697495359e-08)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, s, vcast_vd_d_sve_sleef(3.59086044859052754005062e-06)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, s, vcast_vd_d_sve_sleef(-0.000325991886927389905997954)); + x = ddadd2_vd2_vd_vd2_sve_sleef(vmul_vd_vd_vd_sve_sleef(u, s), vcast_vd2_d_d_sve_sleef(0.0158543442438155018914259, -1.04693272280631521908845e-18)); + x = ddadd2_vd2_vd2_vd2_sve_sleef(ddmul_vd2_vd2_vd2_sve_sleef(s2, x), vcast_vd2_d_d_sve_sleef(-0.308425137534042437259529, -1.95698492133633550338345e-17)); + + x = ddadd2_vd2_vd2_vd_sve_sleef(ddmul_vd2_vd2_vd2_sve_sleef(x, s2), vcast_vd_d_sve_sleef(1)); + ry = vadd_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(x), vd2gety_vd_vd2_sve_sleef(x)); + + o = vcast_vo64_vo32_sve_sleef(veq_vo_vi_vi_sve_sleef(vand_vi_vi_vi_sve_sleef(q, vcast_vi_i_sve_sleef(2)), vcast_vi_i_sve_sleef(0))); + r = vd2setxy_vd2_vd_vd_sve_sleef(vsel_vd_vo_vd_vd_sve_sleef(o, rx, ry), vsel_vd_vo_vd_vd_sve_sleef(o, ry, rx)); + + o = vcast_vo64_vo32_sve_sleef(veq_vo_vi_vi_sve_sleef(vand_vi_vi_vi_sve_sleef(q, vcast_vi_i_sve_sleef(4)), vcast_vi_i_sve_sleef(4))); + r = vd2setx_vd2_vd2_vd_sve_sleef(r, vreinterpret_vd_vm_sve_sleef(vxor_vm_vm_vm_sve_sleef(vand_vm_vo64_vm_sve_sleef(o, vreinterpret_vm_vd_sve_sleef(vcast_vd_d_sve_sleef(-0.0))), vreinterpret_vm_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(r))))); + + o = vcast_vo64_vo32_sve_sleef(veq_vo_vi_vi_sve_sleef(vand_vi_vi_vi_sve_sleef(vadd_vi_vi_vi_sve_sleef(q, vcast_vi_i_sve_sleef(2)), vcast_vi_i_sve_sleef(4)), vcast_vi_i_sve_sleef(4))); + r = vd2sety_vd2_vd2_vd_sve_sleef(r, vreinterpret_vd_vm_sve_sleef(vxor_vm_vm_vm_sve_sleef(vand_vm_vo64_vm_sve_sleef(o, vreinterpret_vm_vd_sve_sleef(vcast_vd_d_sve_sleef(-0.0))), vreinterpret_vm_vd_sve_sleef(vd2gety_vd_vd2_sve_sleef(r))))); + + o = vgt_vo_vd_vd_sve_sleef(vabs_vd_vd_sve_sleef(d), vcast_vd_d_sve_sleef(1e+9/4)); + r = vd2setx_vd2_vd2_vd_sve_sleef(r, vreinterpret_vd_vm_sve_sleef(vandnot_vm_vo64_vm_sve_sleef(o, vreinterpret_vm_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(r))))); + r = vd2sety_vd2_vd2_vd_sve_sleef(r, vsel_vd_vo_vd_vd_sve_sleef(o, vcast_vd_d_sve_sleef(1), vd2gety_vd_vd2_sve_sleef(r))); + + o = visinf_vo_vd_sve_sleef(d); + r = vd2setx_vd2_vd2_vd_sve_sleef(r, vreinterpret_vd_vm_sve_sleef(vor_vm_vo64_vm_sve_sleef(o, vreinterpret_vm_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(r))))); + r = vd2sety_vd2_vd2_vd_sve_sleef(r, vreinterpret_vd_vm_sve_sleef(vor_vm_vo64_vm_sve_sleef(o, vreinterpret_vm_vd_sve_sleef(vd2gety_vd_vd2_sve_sleef(r))))); + + return r; +} + +SLEEF_INLINE vdouble2_sve_sleef Sleef_sincospidx_u35sve(vdouble_sve_sleef d) { + vopmask_sve_sleef o; + vdouble_sve_sleef u, s, t, rx, ry; + vdouble2_sve_sleef r; + + u = vmul_vd_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(4.0)); + vint_sve_sleef q = vtruncate_vi_vd_sve_sleef(u); + q = vand_vi_vi_vi_sve_sleef(vadd_vi_vi_vi_sve_sleef(q, vxor_vi_vi_vi_sve_sleef(vsrl_vi_vi_i_sve_sleef(q, 31), vcast_vi_i_sve_sleef(1))), vcast_vi_i_sve_sleef(~1)); + s = vsub_vd_vd_vd_sve_sleef(u, vcast_vd_vi_sve_sleef(q)); + + t = s; + s = vmul_vd_vd_vd_sve_sleef(s, s); + + u = vcast_vd_d_sve_sleef(+0.6880638894766060136e-11); + u = vmla_vd_vd_vd_vd_sve_sleef(u, s, vcast_vd_d_sve_sleef(-0.1757159564542310199e-8)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, s, vcast_vd_d_sve_sleef(+0.3133616327257867311e-6)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, s, vcast_vd_d_sve_sleef(-0.3657620416388486452e-4)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, s, vcast_vd_d_sve_sleef(+0.2490394570189932103e-2)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, s, vcast_vd_d_sve_sleef(-0.8074551218828056320e-1)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, s, vcast_vd_d_sve_sleef(+0.7853981633974482790e+0)); + + rx = vmul_vd_vd_vd_sve_sleef(u, t); + + u = vcast_vd_d_sve_sleef(-0.3860141213683794352e-12); + u = vmla_vd_vd_vd_vd_sve_sleef(u, s, vcast_vd_d_sve_sleef(+0.1150057888029681415e-9)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, s, vcast_vd_d_sve_sleef(-0.2461136493006663553e-7)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, s, vcast_vd_d_sve_sleef(+0.3590860446623516713e-5)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, s, vcast_vd_d_sve_sleef(-0.3259918869269435942e-3)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, s, vcast_vd_d_sve_sleef(+0.1585434424381541169e-1)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, s, vcast_vd_d_sve_sleef(-0.3084251375340424373e+0)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, s, vcast_vd_d_sve_sleef(1)); + + ry = u; + + o = vcast_vo64_vo32_sve_sleef(veq_vo_vi_vi_sve_sleef(vand_vi_vi_vi_sve_sleef(q, vcast_vi_i_sve_sleef(2)), vcast_vi_i_sve_sleef(0))); + r = vd2setxy_vd2_vd_vd_sve_sleef(vsel_vd_vo_vd_vd_sve_sleef(o, rx, ry), vsel_vd_vo_vd_vd_sve_sleef(o, ry, rx)); + + o = vcast_vo64_vo32_sve_sleef(veq_vo_vi_vi_sve_sleef(vand_vi_vi_vi_sve_sleef(q, vcast_vi_i_sve_sleef(4)), vcast_vi_i_sve_sleef(4))); + r = vd2setx_vd2_vd2_vd_sve_sleef(r, vreinterpret_vd_vm_sve_sleef(vxor_vm_vm_vm_sve_sleef(vand_vm_vo64_vm_sve_sleef(o, vreinterpret_vm_vd_sve_sleef(vcast_vd_d_sve_sleef(-0.0))), vreinterpret_vm_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(r))))); + + o = vcast_vo64_vo32_sve_sleef(veq_vo_vi_vi_sve_sleef(vand_vi_vi_vi_sve_sleef(vadd_vi_vi_vi_sve_sleef(q, vcast_vi_i_sve_sleef(2)), vcast_vi_i_sve_sleef(4)), vcast_vi_i_sve_sleef(4))); + r = vd2sety_vd2_vd2_vd_sve_sleef(r, vreinterpret_vd_vm_sve_sleef(vxor_vm_vm_vm_sve_sleef(vand_vm_vo64_vm_sve_sleef(o, vreinterpret_vm_vd_sve_sleef(vcast_vd_d_sve_sleef(-0.0))), vreinterpret_vm_vd_sve_sleef(vd2gety_vd_vd2_sve_sleef(r))))); + + o = vgt_vo_vd_vd_sve_sleef(vabs_vd_vd_sve_sleef(d), vcast_vd_d_sve_sleef(1e+9/4)); + r = vd2setx_vd2_vd2_vd_sve_sleef(r, vreinterpret_vd_vm_sve_sleef(vandnot_vm_vo64_vm_sve_sleef(o, vreinterpret_vm_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(r))))); + r = vd2sety_vd2_vd2_vd_sve_sleef(r, vreinterpret_vd_vm_sve_sleef(vandnot_vm_vo64_vm_sve_sleef(o, vreinterpret_vm_vd_sve_sleef(vd2gety_vd_vd2_sve_sleef(r))))); + + o = visinf_vo_vd_sve_sleef(d); + r = vd2setx_vd2_vd2_vd_sve_sleef(r, vreinterpret_vd_vm_sve_sleef(vor_vm_vo64_vm_sve_sleef(o, vreinterpret_vm_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(r))))); + r = vd2sety_vd2_vd2_vd_sve_sleef(r, vreinterpret_vd_vm_sve_sleef(vor_vm_vo64_vm_sve_sleef(o, vreinterpret_vm_vd_sve_sleef(vd2gety_vd_vd2_sve_sleef(r))))); + + return r; +} + +SLEEF_INLINE SLEEF_CONST vdouble2_sve_sleef Sleef_modfdx_sve(vdouble_sve_sleef x) { + vdouble_sve_sleef fr = vsub_vd_vd_vd_sve_sleef(x, vmul_vd_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(INT64_C(1) << 31), vcast_vd_vi_sve_sleef(vtruncate_vi_vd_sve_sleef(vmul_vd_vd_vd_sve_sleef(x, vcast_vd_d_sve_sleef(1.0 / (INT64_C(1) << 31))))))); + fr = vsub_vd_vd_vd_sve_sleef(fr, vcast_vd_vi_sve_sleef(vtruncate_vi_vd_sve_sleef(fr))); + fr = vsel_vd_vo_vd_vd_sve_sleef(vgt_vo_vd_vd_sve_sleef(vabs_vd_vd_sve_sleef(x), vcast_vd_d_sve_sleef(INT64_C(1) << 52)), vcast_vd_d_sve_sleef(0), fr); + + vdouble2_sve_sleef ret; + + ret = vd2setxy_vd2_vd_vd_sve_sleef(vcopysign_vd_vd_vd_sve_sleef(fr, x), vcopysign_vd_vd_vd_sve_sleef(vsub_vd_vd_vd_sve_sleef(x, fr), x)); + + return ret; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_sve_sleef sinpik_sve_sleef(vdouble_sve_sleef d) { + vopmask_sve_sleef o; + vdouble_sve_sleef u, s, t; + vdouble2_sve_sleef x, s2; + + u = vmul_vd_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(4.0)); + vint_sve_sleef q = vtruncate_vi_vd_sve_sleef(u); + q = vand_vi_vi_vi_sve_sleef(vadd_vi_vi_vi_sve_sleef(q, vxor_vi_vi_vi_sve_sleef(vsrl_vi_vi_i_sve_sleef(q, 31), vcast_vi_i_sve_sleef(1))), vcast_vi_i_sve_sleef(~1)); + o = vcast_vo64_vo32_sve_sleef(veq_vo_vi_vi_sve_sleef(vand_vi_vi_vi_sve_sleef(q, vcast_vi_i_sve_sleef(2)), vcast_vi_i_sve_sleef(2))); + + s = vsub_vd_vd_vd_sve_sleef(u, vcast_vd_vi_sve_sleef(q)); + t = s; + s = vmul_vd_vd_vd_sve_sleef(s, s); + s2 = ddmul_vd2_vd_vd_sve_sleef(t, t); + + u = vsel_vd_vo_d_d_sve_sleef(o, 9.94480387626843774090208e-16, -2.02461120785182399295868e-14); + u = vmla_vd_vd_vd_vd_sve_sleef(u, s, vsel_vd_vo_d_d_sve_sleef(o, -3.89796226062932799164047e-13, 6.948218305801794613277840e-12)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, s, vsel_vd_vo_d_d_sve_sleef(o, 1.150115825399960352669010e-10, -1.75724749952853179952664e-09)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, s, vsel_vd_vo_d_d_sve_sleef(o, -2.46113695010446974953590e-08, 3.133616889668683928784220e-07)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, s, vsel_vd_vo_d_d_sve_sleef(o, 3.590860448590527540050620e-06, -3.65762041821615519203610e-05)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, s, vsel_vd_vo_d_d_sve_sleef(o, -0.000325991886927389905997954, 0.0024903945701927185027435600)); + x = ddadd2_vd2_vd_vd2_sve_sleef(vmul_vd_vd_vd_sve_sleef(u, s), + vsel_vd2_vo_d_d_d_d_sve_sleef(o, 0.0158543442438155018914259, -1.04693272280631521908845e-18, + -0.0807455121882807852484731, 3.61852475067037104849987e-18)); + x = ddadd2_vd2_vd2_vd2_sve_sleef(ddmul_vd2_vd2_vd2_sve_sleef(s2, x), + vsel_vd2_vo_d_d_d_d_sve_sleef(o, -0.308425137534042437259529, -1.95698492133633550338345e-17, + 0.785398163397448278999491, 3.06287113727155002607105e-17)); + + x = ddmul_vd2_vd2_vd2_sve_sleef(x, vsel_vd2_vo_vd2_vd2_sve_sleef(o, s2, vcast_vd2_vd_vd_sve_sleef(t, vcast_vd_d_sve_sleef(0)))); + x = vsel_vd2_vo_vd2_vd2_sve_sleef(o, ddadd2_vd2_vd2_vd_sve_sleef(x, vcast_vd_d_sve_sleef(1)), x); + + o = vcast_vo64_vo32_sve_sleef(veq_vo_vi_vi_sve_sleef(vand_vi_vi_vi_sve_sleef(q, vcast_vi_i_sve_sleef(4)), vcast_vi_i_sve_sleef(4))); + x = vd2setx_vd2_vd2_vd_sve_sleef(x, vreinterpret_vd_vm_sve_sleef(vxor_vm_vm_vm_sve_sleef(vand_vm_vo64_vm_sve_sleef(o, vreinterpret_vm_vd_sve_sleef(vcast_vd_d_sve_sleef(-0.0))), vreinterpret_vm_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(x))))); + x = vd2sety_vd2_vd2_vd_sve_sleef(x, vreinterpret_vd_vm_sve_sleef(vxor_vm_vm_vm_sve_sleef(vand_vm_vo64_vm_sve_sleef(o, vreinterpret_vm_vd_sve_sleef(vcast_vd_d_sve_sleef(-0.0))), vreinterpret_vm_vd_sve_sleef(vd2gety_vd_vd2_sve_sleef(x))))); + + return x; +} + +SLEEF_INLINE SLEEF_CONST vdouble_sve_sleef Sleef_sinpidx_u05sve(vdouble_sve_sleef d) { + vdouble2_sve_sleef x = sinpik_sve_sleef(d); + vdouble_sve_sleef r = vadd_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(x), vd2gety_vd_vd2_sve_sleef(x)); + + r = vsel_vd_vo_vd_vd_sve_sleef(visnegzero_vo_vd_sve_sleef(d), vcast_vd_d_sve_sleef(-0.0), r); + r = vreinterpret_vd_vm_sve_sleef(vandnot_vm_vo64_vm_sve_sleef(vgt_vo_vd_vd_sve_sleef(vabs_vd_vd_sve_sleef(d), vcast_vd_d_sve_sleef(1e+9/4)), vreinterpret_vm_vd_sve_sleef(r))); + r = vreinterpret_vd_vm_sve_sleef(vor_vm_vo64_vm_sve_sleef(visinf_vo_vd_sve_sleef(d), vreinterpret_vm_vd_sve_sleef(r))); + + return r; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_sve_sleef cospik_sve_sleef(vdouble_sve_sleef d) { + vopmask_sve_sleef o; + vdouble_sve_sleef u, s, t; + vdouble2_sve_sleef x, s2; + + u = vmul_vd_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(4.0)); + vint_sve_sleef q = vtruncate_vi_vd_sve_sleef(u); + q = vand_vi_vi_vi_sve_sleef(vadd_vi_vi_vi_sve_sleef(q, vxor_vi_vi_vi_sve_sleef(vsrl_vi_vi_i_sve_sleef(q, 31), vcast_vi_i_sve_sleef(1))), vcast_vi_i_sve_sleef(~1)); + o = vcast_vo64_vo32_sve_sleef(veq_vo_vi_vi_sve_sleef(vand_vi_vi_vi_sve_sleef(q, vcast_vi_i_sve_sleef(2)), vcast_vi_i_sve_sleef(0))); + + s = vsub_vd_vd_vd_sve_sleef(u, vcast_vd_vi_sve_sleef(q)); + t = s; + s = vmul_vd_vd_vd_sve_sleef(s, s); + s2 = ddmul_vd2_vd_vd_sve_sleef(t, t); + + u = vsel_vd_vo_d_d_sve_sleef(o, 9.94480387626843774090208e-16, -2.02461120785182399295868e-14); + u = vmla_vd_vd_vd_vd_sve_sleef(u, s, vsel_vd_vo_d_d_sve_sleef(o, -3.89796226062932799164047e-13, 6.948218305801794613277840e-12)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, s, vsel_vd_vo_d_d_sve_sleef(o, 1.150115825399960352669010e-10, -1.75724749952853179952664e-09)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, s, vsel_vd_vo_d_d_sve_sleef(o, -2.46113695010446974953590e-08, 3.133616889668683928784220e-07)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, s, vsel_vd_vo_d_d_sve_sleef(o, 3.590860448590527540050620e-06, -3.65762041821615519203610e-05)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, s, vsel_vd_vo_d_d_sve_sleef(o, -0.000325991886927389905997954, 0.0024903945701927185027435600)); + x = ddadd2_vd2_vd_vd2_sve_sleef(vmul_vd_vd_vd_sve_sleef(u, s), + vsel_vd2_vo_d_d_d_d_sve_sleef(o, 0.0158543442438155018914259, -1.04693272280631521908845e-18, + -0.0807455121882807852484731, 3.61852475067037104849987e-18)); + x = ddadd2_vd2_vd2_vd2_sve_sleef(ddmul_vd2_vd2_vd2_sve_sleef(s2, x), + vsel_vd2_vo_d_d_d_d_sve_sleef(o, -0.308425137534042437259529, -1.95698492133633550338345e-17, + 0.785398163397448278999491, 3.06287113727155002607105e-17)); + + x = ddmul_vd2_vd2_vd2_sve_sleef(x, vsel_vd2_vo_vd2_vd2_sve_sleef(o, s2, vcast_vd2_vd_vd_sve_sleef(t, vcast_vd_d_sve_sleef(0)))); + x = vsel_vd2_vo_vd2_vd2_sve_sleef(o, ddadd2_vd2_vd2_vd_sve_sleef(x, vcast_vd_d_sve_sleef(1)), x); + + o = vcast_vo64_vo32_sve_sleef(veq_vo_vi_vi_sve_sleef(vand_vi_vi_vi_sve_sleef(vadd_vi_vi_vi_sve_sleef(q, vcast_vi_i_sve_sleef(2)), vcast_vi_i_sve_sleef(4)), vcast_vi_i_sve_sleef(4))); + x = vd2setx_vd2_vd2_vd_sve_sleef(x, vreinterpret_vd_vm_sve_sleef(vxor_vm_vm_vm_sve_sleef(vand_vm_vo64_vm_sve_sleef(o, vreinterpret_vm_vd_sve_sleef(vcast_vd_d_sve_sleef(-0.0))), vreinterpret_vm_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(x))))); + x = vd2sety_vd2_vd2_vd_sve_sleef(x, vreinterpret_vd_vm_sve_sleef(vxor_vm_vm_vm_sve_sleef(vand_vm_vo64_vm_sve_sleef(o, vreinterpret_vm_vd_sve_sleef(vcast_vd_d_sve_sleef(-0.0))), vreinterpret_vm_vd_sve_sleef(vd2gety_vd_vd2_sve_sleef(x))))); + + return x; +} + +SLEEF_INLINE SLEEF_CONST vdouble_sve_sleef Sleef_cospidx_u05sve(vdouble_sve_sleef d) { + vdouble2_sve_sleef x = cospik_sve_sleef(d); + vdouble_sve_sleef r = vadd_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(x), vd2gety_vd_vd2_sve_sleef(x)); + + r = vsel_vd_vo_vd_vd_sve_sleef(vgt_vo_vd_vd_sve_sleef(vabs_vd_vd_sve_sleef(d), vcast_vd_d_sve_sleef(1e+9/4)), vcast_vd_d_sve_sleef(1), r); + r = vreinterpret_vd_vm_sve_sleef(vor_vm_vo64_vm_sve_sleef(visinf_vo_vd_sve_sleef(d), vreinterpret_vm_vd_sve_sleef(r))); + + return r; +} + +SLEEF_INLINE SLEEF_CONST vdouble_sve_sleef Sleef_tandx_u35sve(vdouble_sve_sleef d) { + + vdouble_sve_sleef u, s, x, y; + vopmask_sve_sleef o; + vint_sve_sleef ql; + + if (__builtin_expect(!!(vtestallones_i_vo64_sve_sleef(vlt_vo_vd_vd_sve_sleef(vabs_vd_vd_sve_sleef(d), vcast_vd_d_sve_sleef(15)))), 1)) { + vdouble_sve_sleef dql = vrint_vd_vd_sve_sleef(vmul_vd_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(2 * 0.318309886183790671537767526745028724))); + ql = vrint_vi_vd_sve_sleef(dql); + x = vmla_vd_vd_vd_vd_sve_sleef(dql, vcast_vd_d_sve_sleef(-3.141592653589793116 * 0.5), d); + x = vmla_vd_vd_vd_vd_sve_sleef(dql, vcast_vd_d_sve_sleef(-1.2246467991473532072e-16 * 0.5), x); + } else if (__builtin_expect(!!(vtestallones_i_vo64_sve_sleef(vlt_vo_vd_vd_sve_sleef(vabs_vd_vd_sve_sleef(d), vcast_vd_d_sve_sleef(1e+6)))), 1)) { + vdouble_sve_sleef dqh = vtruncate_vd_vd_sve_sleef(vmul_vd_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(2*0.318309886183790671537767526745028724 / (1 << 24)))); + dqh = vmul_vd_vd_vd_sve_sleef(dqh, vcast_vd_d_sve_sleef(1 << 24)); + vdouble_sve_sleef dql = vrint_vd_vd_sve_sleef(vsub_vd_vd_vd_sve_sleef(vmul_vd_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(2*0.318309886183790671537767526745028724)), dqh)); + ql = vrint_vi_vd_sve_sleef(dql); + + x = vmla_vd_vd_vd_vd_sve_sleef(dqh, vcast_vd_d_sve_sleef(-3.1415926218032836914 * 0.5), d); + x = vmla_vd_vd_vd_vd_sve_sleef(dql, vcast_vd_d_sve_sleef(-3.1415926218032836914 * 0.5), x); + x = vmla_vd_vd_vd_vd_sve_sleef(dqh, vcast_vd_d_sve_sleef(-3.1786509424591713469e-08 * 0.5), x); + x = vmla_vd_vd_vd_vd_sve_sleef(dql, vcast_vd_d_sve_sleef(-3.1786509424591713469e-08 * 0.5), x); + x = vmla_vd_vd_vd_vd_sve_sleef(dqh, vcast_vd_d_sve_sleef(-1.2246467864107188502e-16 * 0.5), x); + x = vmla_vd_vd_vd_vd_sve_sleef(dql, vcast_vd_d_sve_sleef(-1.2246467864107188502e-16 * 0.5), x); + x = vmla_vd_vd_vd_vd_sve_sleef(vadd_vd_vd_vd_sve_sleef(dqh, dql), vcast_vd_d_sve_sleef(-1.2736634327021899816e-24 * 0.5), x); + } else { + ddi_t_sve_sleef ddi_sve_sleef = rempi_sve_sleef(d); + ql = ddigeti_vi_ddi_sve_sleef(ddi_sve_sleef); + x = vadd_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(ddigetdd_vd2_ddi_sve_sleef(ddi_sve_sleef)), vd2gety_vd_vd2_sve_sleef(ddigetdd_vd2_ddi_sve_sleef(ddi_sve_sleef))); + x = vreinterpret_vd_vm_sve_sleef(vor_vm_vo64_vm_sve_sleef(visinf_vo_vd_sve_sleef(d), vreinterpret_vm_vd_sve_sleef(x))); + x = vreinterpret_vd_vm_sve_sleef(vor_vm_vo64_vm_sve_sleef(vor_vo_vo_vo_sve_sleef(visinf_vo_vd_sve_sleef(d), visnan_vo_vd_sve_sleef(d)), vreinterpret_vm_vd_sve_sleef(x))); + } + + x = vmul_vd_vd_vd_sve_sleef(x, vcast_vd_d_sve_sleef(0.5)); + s = vmul_vd_vd_vd_sve_sleef(x, x); + + vdouble_sve_sleef s2 = vmul_vd_vd_vd_sve_sleef(s, s), s4 = vmul_vd_vd_vd_sve_sleef(s2, s2); + u = vmla_vd_vd_vd_vd_sve_sleef((s4), (vmla_vd_vd_vd_vd_sve_sleef((s2), (vmla_vd_vd_vd_vd_sve_sleef((s), (vcast_vd_d_sve_sleef(+0.3245098826639276316e-3)), (vcast_vd_d_sve_sleef(+0.5619219738114323735e-3)))), (vmla_vd_vd_vd_vd_sve_sleef((s), (vcast_vd_d_sve_sleef(+0.1460781502402784494e-2)), (vcast_vd_d_sve_sleef(+0.3591611540792499519e-2)))))), (vmla_vd_vd_vd_vd_sve_sleef((s2), (vmla_vd_vd_vd_vd_sve_sleef((s), (vcast_vd_d_sve_sleef(+0.8863268409563113126e-2)), (vcast_vd_d_sve_sleef(+0.2186948728185535498e-1)))), (vmla_vd_vd_vd_vd_sve_sleef((s), (vcast_vd_d_sve_sleef(+0.5396825399517272970e-1)), (vcast_vd_d_sve_sleef(+0.1333333333330500581e+0))))))) + + ; + + u = vmla_vd_vd_vd_vd_sve_sleef(u, s, vcast_vd_d_sve_sleef(+0.3333333333333343695e+0)); + u = vmla_vd_vd_vd_vd_sve_sleef(s, vmul_vd_vd_vd_sve_sleef(u, x), x); + + y = vmla_vd_vd_vd_vd_sve_sleef(u, u, vcast_vd_d_sve_sleef(-1)); + x = vmul_vd_vd_vd_sve_sleef(u, vcast_vd_d_sve_sleef(-2)); + + o = vcast_vo64_vo32_sve_sleef(veq_vo_vi_vi_sve_sleef(vand_vi_vi_vi_sve_sleef(ql, vcast_vi_i_sve_sleef(1)), vcast_vi_i_sve_sleef(1))); + u = vdiv_vd_vd_vd_sve_sleef(vsel_vd_vo_vd_vd_sve_sleef(o, vneg_vd_vd_sve_sleef(y), x), + vsel_vd_vo_vd_vd_sve_sleef(o, x, y)); + u = vsel_vd_vo_vd_vd_sve_sleef(veq_vo_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(0)), d, u); + + return u; + +} + +SLEEF_INLINE SLEEF_CONST vdouble_sve_sleef Sleef_tandx_u10sve(vdouble_sve_sleef d) { + + vdouble_sve_sleef u; + vdouble2_sve_sleef s, t, x, y; + vopmask_sve_sleef o; + vint_sve_sleef ql; + + if (__builtin_expect(!!(vtestallones_i_vo64_sve_sleef(vlt_vo_vd_vd_sve_sleef(vabs_vd_vd_sve_sleef(d), vcast_vd_d_sve_sleef(15)))), 1)) { + vdouble_sve_sleef dql = vrint_vd_vd_sve_sleef(vmul_vd_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(2 * 0.318309886183790671537767526745028724))); + ql = vrint_vi_vd_sve_sleef(dql); + u = vmla_vd_vd_vd_vd_sve_sleef(dql, vcast_vd_d_sve_sleef(-3.141592653589793116*0.5), d); + s = ddadd_vd2_vd_vd_sve_sleef (u, vmul_vd_vd_vd_sve_sleef(dql, vcast_vd_d_sve_sleef(-1.2246467991473532072e-16*0.5))); + } else if (__builtin_expect(!!(vtestallones_i_vo64_sve_sleef(vlt_vo_vd_vd_sve_sleef(vabs_vd_vd_sve_sleef(d), vcast_vd_d_sve_sleef(1e+14)))), 1)) { + vdouble_sve_sleef dqh = vtruncate_vd_vd_sve_sleef(vmul_vd_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(2*0.318309886183790671537767526745028724 / (1 << 24)))); + dqh = vmul_vd_vd_vd_sve_sleef(dqh, vcast_vd_d_sve_sleef(1 << 24)); + s = ddadd2_vd2_vd2_vd_sve_sleef(ddmul_vd2_vd2_vd_sve_sleef(vcast_vd2_d_d_sve_sleef(0.63661977236758138243, -3.9357353350364971764e-17), d), + vsub_vd_vd_vd_sve_sleef(vsel_vd_vo_vd_vd_sve_sleef(vlt_vo_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(0)), + vcast_vd_d_sve_sleef(-0.5), vcast_vd_d_sve_sleef(0.5)), dqh)); + const vdouble_sve_sleef dql = vtruncate_vd_vd_sve_sleef(vadd_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(s), vd2gety_vd_vd2_sve_sleef(s))); + ql = vrint_vi_vd_sve_sleef(dql); + + u = vmla_vd_vd_vd_vd_sve_sleef(dqh, vcast_vd_d_sve_sleef(-3.1415926218032836914 * 0.5), d); + s = ddadd_vd2_vd_vd_sve_sleef(u, vmul_vd_vd_vd_sve_sleef(dql, vcast_vd_d_sve_sleef(-3.1415926218032836914*0.5 ))); + s = ddadd2_vd2_vd2_vd_sve_sleef(s, vmul_vd_vd_vd_sve_sleef(dqh, vcast_vd_d_sve_sleef(-3.1786509424591713469e-08*0.5))); + s = ddadd2_vd2_vd2_vd_sve_sleef(s, vmul_vd_vd_vd_sve_sleef(dql, vcast_vd_d_sve_sleef(-3.1786509424591713469e-08*0.5 ))); + s = ddadd2_vd2_vd2_vd_sve_sleef(s, vmul_vd_vd_vd_sve_sleef(dqh, vcast_vd_d_sve_sleef(-1.2246467864107188502e-16*0.5))); + s = ddadd2_vd2_vd2_vd_sve_sleef(s, vmul_vd_vd_vd_sve_sleef(dql, vcast_vd_d_sve_sleef(-1.2246467864107188502e-16*0.5 ))); + s = ddadd_vd2_vd2_vd_sve_sleef(s, vmul_vd_vd_vd_sve_sleef(vadd_vd_vd_vd_sve_sleef(dqh, dql), vcast_vd_d_sve_sleef(-1.2736634327021899816e-24*0.5))); + } else { + ddi_t_sve_sleef ddi_sve_sleef = rempi_sve_sleef(d); + ql = ddigeti_vi_ddi_sve_sleef(ddi_sve_sleef); + s = ddigetdd_vd2_ddi_sve_sleef(ddi_sve_sleef); + o = vor_vo_vo_vo_sve_sleef(visinf_vo_vd_sve_sleef(d), visnan_vo_vd_sve_sleef(d)); + s = vd2setx_vd2_vd2_vd_sve_sleef(s, vreinterpret_vd_vm_sve_sleef(vor_vm_vo64_vm_sve_sleef(o, vreinterpret_vm_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(s))))); + s = vd2sety_vd2_vd2_vd_sve_sleef(s, vreinterpret_vd_vm_sve_sleef(vor_vm_vo64_vm_sve_sleef(o, vreinterpret_vm_vd_sve_sleef(vd2gety_vd_vd2_sve_sleef(s))))); + } + + t = ddscale_vd2_vd2_vd_sve_sleef(s, vcast_vd_d_sve_sleef(0.5)); + s = ddsqu_vd2_vd2_sve_sleef(t); + + vdouble_sve_sleef s2 = vmul_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(s), vd2getx_vd_vd2_sve_sleef(s)), s4 = vmul_vd_vd_vd_sve_sleef(s2, s2); + u = vmla_vd_vd_vd_vd_sve_sleef((s4), (vmla_vd_vd_vd_vd_sve_sleef((s2), (vmla_vd_vd_vd_vd_sve_sleef((vd2getx_vd_vd2_sve_sleef(s)), (vcast_vd_d_sve_sleef(+0.3245098826639276316e-3)), (vcast_vd_d_sve_sleef(+0.5619219738114323735e-3)))), (vmla_vd_vd_vd_vd_sve_sleef((vd2getx_vd_vd2_sve_sleef(s)), (vcast_vd_d_sve_sleef(+0.1460781502402784494e-2)), (vcast_vd_d_sve_sleef(+0.3591611540792499519e-2)))))), (vmla_vd_vd_vd_vd_sve_sleef((s2), (vmla_vd_vd_vd_vd_sve_sleef((vd2getx_vd_vd2_sve_sleef(s)), (vcast_vd_d_sve_sleef(+0.8863268409563113126e-2)), (vcast_vd_d_sve_sleef(+0.2186948728185535498e-1)))), (vmla_vd_vd_vd_vd_sve_sleef((vd2getx_vd_vd2_sve_sleef(s)), (vcast_vd_d_sve_sleef(+0.5396825399517272970e-1)), (vcast_vd_d_sve_sleef(+0.1333333333330500581e+0))))))) + + ; + + u = vmla_vd_vd_vd_vd_sve_sleef(u, vd2getx_vd_vd2_sve_sleef(s), vcast_vd_d_sve_sleef(+0.3333333333333343695e+0)); + x = ddadd_vd2_vd2_vd2_sve_sleef(t, ddmul_vd2_vd2_vd_sve_sleef(ddmul_vd2_vd2_vd2_sve_sleef(s, t), u)); + + y = ddadd_vd2_vd_vd2_sve_sleef(vcast_vd_d_sve_sleef(-1), ddsqu_vd2_vd2_sve_sleef(x)); + x = ddscale_vd2_vd2_vd_sve_sleef(x, vcast_vd_d_sve_sleef(-2)); + + o = vcast_vo64_vo32_sve_sleef(veq_vo_vi_vi_sve_sleef(vand_vi_vi_vi_sve_sleef(ql, vcast_vi_i_sve_sleef(1)), vcast_vi_i_sve_sleef(1))); + + x = dddiv_vd2_vd2_vd2_sve_sleef(vsel_vd2_vo_vd2_vd2_sve_sleef(o, ddneg_vd2_vd2_sve_sleef(y), x), + vsel_vd2_vo_vd2_vd2_sve_sleef(o, x, y)); + + u = vadd_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(x), vd2gety_vd_vd2_sve_sleef(x)); + + u = vsel_vd_vo_vd_vd_sve_sleef(veq_vo_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(0)), d, u); + + return u; + +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_sve_sleef atan2k_sve_sleef(vdouble_sve_sleef y, vdouble_sve_sleef x) { + vdouble_sve_sleef s, t, u; + vint_sve_sleef q; + vopmask_sve_sleef p; + + q = vsel_vi_vd_vi_sve_sleef(x, vcast_vi_i_sve_sleef(-2)); + x = vabs_vd_vd_sve_sleef(x); + + q = vsel_vi_vd_vd_vi_vi_sve_sleef(x, y, vadd_vi_vi_vi_sve_sleef(q, vcast_vi_i_sve_sleef(1)), q); + p = vlt_vo_vd_vd_sve_sleef(x, y); + s = vsel_vd_vo_vd_vd_sve_sleef(p, vneg_vd_vd_sve_sleef(x), y); + t = vmax_vd_vd_vd_sve_sleef(x, y); + + s = vdiv_vd_vd_vd_sve_sleef(s, t); + t = vmul_vd_vd_vd_sve_sleef(s, s); + + vdouble_sve_sleef t2 = vmul_vd_vd_vd_sve_sleef(t, t), t4 = vmul_vd_vd_vd_sve_sleef(t2, t2), t8 = vmul_vd_vd_vd_sve_sleef(t4, t4), t16 = vmul_vd_vd_vd_sve_sleef(t8, t8); + u = vmla_vd_vd_vd_vd_sve_sleef((t16), (vmla_vd_vd_vd_vd_sve_sleef((t2), (vcast_vd_d_sve_sleef(-1.88796008463073496563746e-05)), (vmla_vd_vd_vd_vd_sve_sleef((t), (vcast_vd_d_sve_sleef(0.000209850076645816976906797)), (vcast_vd_d_sve_sleef(-0.00110611831486672482563471)))))), (vmla_vd_vd_vd_vd_sve_sleef((t8), (vmla_vd_vd_vd_vd_sve_sleef((t4), (vmla_vd_vd_vd_vd_sve_sleef((t2), (vmla_vd_vd_vd_vd_sve_sleef((t), (vcast_vd_d_sve_sleef(0.00370026744188713119232403)), (vcast_vd_d_sve_sleef(-0.00889896195887655491740809)))), (vmla_vd_vd_vd_vd_sve_sleef((t), (vcast_vd_d_sve_sleef(0.016599329773529201970117)), (vcast_vd_d_sve_sleef(-0.0254517624932312641616861)))))), (vmla_vd_vd_vd_vd_sve_sleef((t2), (vmla_vd_vd_vd_vd_sve_sleef((t), (vcast_vd_d_sve_sleef(0.0337852580001353069993897)), (vcast_vd_d_sve_sleef(-0.0407629191276836500001934)))), (vmla_vd_vd_vd_vd_sve_sleef((t), (vcast_vd_d_sve_sleef(0.0466667150077840625632675)), (vcast_vd_d_sve_sleef(-0.0523674852303482457616113)))))))), (vmla_vd_vd_vd_vd_sve_sleef((t4), (vmla_vd_vd_vd_vd_sve_sleef((t2), (vmla_vd_vd_vd_vd_sve_sleef((t), (vcast_vd_d_sve_sleef(0.0587666392926673580854313)), (vcast_vd_d_sve_sleef(-0.0666573579361080525984562)))), (vmla_vd_vd_vd_vd_sve_sleef((t), (vcast_vd_d_sve_sleef(0.0769219538311769618355029)), (vcast_vd_d_sve_sleef(-0.090908995008245008229153)))))), (vmla_vd_vd_vd_vd_sve_sleef((t2), (vmla_vd_vd_vd_vd_sve_sleef((t), (vcast_vd_d_sve_sleef(0.111111105648261418443745)), (vcast_vd_d_sve_sleef(-0.14285714266771329383765)))), (vmla_vd_vd_vd_vd_sve_sleef((t), (vcast_vd_d_sve_sleef(0.199999999996591265594148)), (vcast_vd_d_sve_sleef(-0.333333333333311110369124))))))))))) + + ; + + t = vmla_vd_vd_vd_vd_sve_sleef(s, vmul_vd_vd_vd_sve_sleef(t, u), s); + t = vmla_vd_vd_vd_vd_sve_sleef(vcast_vd_vi_sve_sleef(q), vcast_vd_d_sve_sleef(3.141592653589793238462643383279502884/2), t); + + return t; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_sve_sleef atan2k_u1_sve_sleef(vdouble2_sve_sleef y, vdouble2_sve_sleef x) { + vdouble_sve_sleef u; + vdouble2_sve_sleef s, t; + vint_sve_sleef q; + vopmask_sve_sleef p; + + q = vsel_vi_vd_vi_sve_sleef(vd2getx_vd_vd2_sve_sleef(x), vcast_vi_i_sve_sleef(-2)); + p = vlt_vo_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(x), vcast_vd_d_sve_sleef(0)); + vmask_sve_sleef b = vand_vm_vo64_vm_sve_sleef(p, vreinterpret_vm_vd_sve_sleef(vcast_vd_d_sve_sleef(-0.0))); + x = vd2setx_vd2_vd2_vd_sve_sleef(x, vreinterpret_vd_vm_sve_sleef(vxor_vm_vm_vm_sve_sleef(b, vreinterpret_vm_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(x))))); + x = vd2sety_vd2_vd2_vd_sve_sleef(x, vreinterpret_vd_vm_sve_sleef(vxor_vm_vm_vm_sve_sleef(b, vreinterpret_vm_vd_sve_sleef(vd2gety_vd_vd2_sve_sleef(x))))); + + q = vsel_vi_vd_vd_vi_vi_sve_sleef(vd2getx_vd_vd2_sve_sleef(x), vd2getx_vd_vd2_sve_sleef(y), vadd_vi_vi_vi_sve_sleef(q, vcast_vi_i_sve_sleef(1)), q); + p = vlt_vo_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(x), vd2getx_vd_vd2_sve_sleef(y)); + s = vsel_vd2_vo_vd2_vd2_sve_sleef(p, ddneg_vd2_vd2_sve_sleef(x), y); + t = vsel_vd2_vo_vd2_vd2_sve_sleef(p, y, x); + + s = dddiv_vd2_vd2_vd2_sve_sleef(s, t); + t = ddsqu_vd2_vd2_sve_sleef(s); + t = ddnormalize_vd2_vd2_sve_sleef(t); + + vdouble_sve_sleef t2 = vmul_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(t), vd2getx_vd_vd2_sve_sleef(t)), t4 = vmul_vd_vd_vd_sve_sleef(t2, t2), t8 = vmul_vd_vd_vd_sve_sleef(t4, t4); + u = vmla_vd_vd_vd_vd_sve_sleef((t8), (vmla_vd_vd_vd_vd_sve_sleef((t4), (vmla_vd_vd_vd_vd_sve_sleef((t2), (vmla_vd_vd_vd_vd_sve_sleef((vd2getx_vd_vd2_sve_sleef(t)), (vcast_vd_d_sve_sleef(1.06298484191448746607415e-05)), (vcast_vd_d_sve_sleef(-0.000125620649967286867384336)))), (vmla_vd_vd_vd_vd_sve_sleef((vd2getx_vd_vd2_sve_sleef(t)), (vcast_vd_d_sve_sleef(0.00070557664296393412389774)), (vcast_vd_d_sve_sleef(-0.00251865614498713360352999)))))), (vmla_vd_vd_vd_vd_sve_sleef((t2), (vmla_vd_vd_vd_vd_sve_sleef((vd2getx_vd_vd2_sve_sleef(t)), (vcast_vd_d_sve_sleef(0.00646262899036991172313504)), (vcast_vd_d_sve_sleef(-0.0128281333663399031014274)))), (vmla_vd_vd_vd_vd_sve_sleef((vd2getx_vd_vd2_sve_sleef(t)), (vcast_vd_d_sve_sleef(0.0208024799924145797902497)), (vcast_vd_d_sve_sleef(-0.0289002344784740315686289)))))))), (vmla_vd_vd_vd_vd_sve_sleef((t4), (vmla_vd_vd_vd_vd_sve_sleef((t2), (vmla_vd_vd_vd_vd_sve_sleef((vd2getx_vd_vd2_sve_sleef(t)), (vcast_vd_d_sve_sleef(0.0359785005035104590853656)), (vcast_vd_d_sve_sleef(-0.041848579703592507506027)))), (vmla_vd_vd_vd_vd_sve_sleef((vd2getx_vd_vd2_sve_sleef(t)), (vcast_vd_d_sve_sleef(0.0470843011653283988193763)), (vcast_vd_d_sve_sleef(-0.0524914210588448421068719)))))), (vmla_vd_vd_vd_vd_sve_sleef((t2), (vmla_vd_vd_vd_vd_sve_sleef((vd2getx_vd_vd2_sve_sleef(t)), (vcast_vd_d_sve_sleef(0.0587946590969581003860434)), (vcast_vd_d_sve_sleef(-0.0666620884778795497194182)))), (vmla_vd_vd_vd_vd_sve_sleef((vd2getx_vd_vd2_sve_sleef(t)), (vcast_vd_d_sve_sleef(0.0769225330296203768654095)), (vcast_vd_d_sve_sleef(-0.0909090442773387574781907))))))))) + + ; + u = vmla_vd_vd_vd_vd_sve_sleef(u, vd2getx_vd_vd2_sve_sleef(t), vcast_vd_d_sve_sleef(0.111111108376896236538123)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, vd2getx_vd_vd2_sve_sleef(t), vcast_vd_d_sve_sleef(-0.142857142756268568062339)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, vd2getx_vd_vd2_sve_sleef(t), vcast_vd_d_sve_sleef(0.199999999997977351284817)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, vd2getx_vd_vd2_sve_sleef(t), vcast_vd_d_sve_sleef(-0.333333333333317605173818)); + + t = ddadd_vd2_vd2_vd2_sve_sleef(s, ddmul_vd2_vd2_vd_sve_sleef(ddmul_vd2_vd2_vd2_sve_sleef(s, t), u)); + + t = ddadd_vd2_vd2_vd2_sve_sleef(ddmul_vd2_vd2_vd_sve_sleef(vcast_vd2_d_d_sve_sleef(1.570796326794896557998982, 6.12323399573676603586882e-17), vcast_vd_vi_sve_sleef(q)), t); + + return t; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_sve_sleef visinf2_vd_vd_vd_sve_sleef(vdouble_sve_sleef d, vdouble_sve_sleef m) { + return vreinterpret_vd_vm_sve_sleef(vand_vm_vo64_vm_sve_sleef(visinf_vo_vd_sve_sleef(d), vor_vm_vm_vm_sve_sleef(vand_vm_vm_vm_sve_sleef(vreinterpret_vm_vd_sve_sleef(d), vreinterpret_vm_vd_sve_sleef(vcast_vd_d_sve_sleef(-0.0))), vreinterpret_vm_vd_sve_sleef(m)))); +} + +SLEEF_INLINE SLEEF_CONST vdouble_sve_sleef Sleef_atan2dx_u35sve(vdouble_sve_sleef y, vdouble_sve_sleef x) { + vdouble_sve_sleef r = atan2k_sve_sleef(vabs_vd_vd_sve_sleef(y), x); + + r = vmulsign_vd_vd_vd_sve_sleef(r, x); + r = vsel_vd_vo_vd_vd_sve_sleef(vor_vo_vo_vo_sve_sleef(visinf_vo_vd_sve_sleef(x), veq_vo_vd_vd_sve_sleef(x, vcast_vd_d_sve_sleef(0))), vsub_vd_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(3.141592653589793238462643383279502884/2), visinf2_vd_vd_vd_sve_sleef(x, vmulsign_vd_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(3.141592653589793238462643383279502884/2), x))), r); + r = vsel_vd_vo_vd_vd_sve_sleef(visinf_vo_vd_sve_sleef(y), vsub_vd_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(3.141592653589793238462643383279502884/2), visinf2_vd_vd_vd_sve_sleef(x, vmulsign_vd_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(3.141592653589793238462643383279502884/4), x))), r); + r = vsel_vd_vo_vd_vd_sve_sleef(veq_vo_vd_vd_sve_sleef(y, vcast_vd_d_sve_sleef(0.0)), vreinterpret_vd_vm_sve_sleef(vand_vm_vo64_vm_sve_sleef(vsignbit_vo_vd_sve_sleef(x), vreinterpret_vm_vd_sve_sleef(vcast_vd_d_sve_sleef(3.141592653589793238462643383279502884)))), r); + + r = vreinterpret_vd_vm_sve_sleef(vor_vm_vo64_vm_sve_sleef(vor_vo_vo_vo_sve_sleef(visnan_vo_vd_sve_sleef(x), visnan_vo_vd_sve_sleef(y)), vreinterpret_vm_vd_sve_sleef(vmulsign_vd_vd_vd_sve_sleef(r, y)))); + return r; +} + +SLEEF_INLINE SLEEF_CONST vdouble_sve_sleef Sleef_atan2dx_u10sve(vdouble_sve_sleef y, vdouble_sve_sleef x) { + vopmask_sve_sleef o = vlt_vo_vd_vd_sve_sleef(vabs_vd_vd_sve_sleef(x), vcast_vd_d_sve_sleef(5.5626846462680083984e-309)); + x = vsel_vd_vo_vd_vd_sve_sleef(o, vmul_vd_vd_vd_sve_sleef(x, vcast_vd_d_sve_sleef(UINT64_C(1) << 53)), x); + y = vsel_vd_vo_vd_vd_sve_sleef(o, vmul_vd_vd_vd_sve_sleef(y, vcast_vd_d_sve_sleef(UINT64_C(1) << 53)), y); + + vdouble2_sve_sleef d = atan2k_u1_sve_sleef(vcast_vd2_vd_vd_sve_sleef(vabs_vd_vd_sve_sleef(y), vcast_vd_d_sve_sleef(0)), vcast_vd2_vd_vd_sve_sleef(x, vcast_vd_d_sve_sleef(0))); + vdouble_sve_sleef r = vadd_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(d), vd2gety_vd_vd2_sve_sleef(d)); + + r = vmulsign_vd_vd_vd_sve_sleef(r, x); + r = vsel_vd_vo_vd_vd_sve_sleef(vor_vo_vo_vo_sve_sleef(visinf_vo_vd_sve_sleef(x), veq_vo_vd_vd_sve_sleef(x, vcast_vd_d_sve_sleef(0))), vsub_vd_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(3.141592653589793238462643383279502884/2), visinf2_vd_vd_vd_sve_sleef(x, vmulsign_vd_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(3.141592653589793238462643383279502884/2), x))), r); + r = vsel_vd_vo_vd_vd_sve_sleef(visinf_vo_vd_sve_sleef(y), vsub_vd_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(3.141592653589793238462643383279502884/2), visinf2_vd_vd_vd_sve_sleef(x, vmulsign_vd_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(3.141592653589793238462643383279502884/4), x))), r); + r = vsel_vd_vo_vd_vd_sve_sleef(veq_vo_vd_vd_sve_sleef(y, vcast_vd_d_sve_sleef(0.0)), vreinterpret_vd_vm_sve_sleef(vand_vm_vo64_vm_sve_sleef(vsignbit_vo_vd_sve_sleef(x), vreinterpret_vm_vd_sve_sleef(vcast_vd_d_sve_sleef(3.141592653589793238462643383279502884)))), r); + + r = vreinterpret_vd_vm_sve_sleef(vor_vm_vo64_vm_sve_sleef(vor_vo_vo_vo_sve_sleef(visnan_vo_vd_sve_sleef(x), visnan_vo_vd_sve_sleef(y)), vreinterpret_vm_vd_sve_sleef(vmulsign_vd_vd_vd_sve_sleef(r, y)))); + return r; +} + +SLEEF_INLINE SLEEF_CONST vdouble_sve_sleef Sleef_asindx_u35sve(vdouble_sve_sleef d) { + vopmask_sve_sleef o = vlt_vo_vd_vd_sve_sleef(vabs_vd_vd_sve_sleef(d), vcast_vd_d_sve_sleef(0.5)); + vdouble_sve_sleef x2 = vsel_vd_vo_vd_vd_sve_sleef(o, vmul_vd_vd_vd_sve_sleef(d, d), vmul_vd_vd_vd_sve_sleef(vsub_vd_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(1), vabs_vd_vd_sve_sleef(d)), vcast_vd_d_sve_sleef(0.5))); + vdouble_sve_sleef x = vsel_vd_vo_vd_vd_sve_sleef(o, vabs_vd_vd_sve_sleef(d), vsqrt_vd_vd_sve_sleef(x2)), u; + + vdouble_sve_sleef x4 = vmul_vd_vd_vd_sve_sleef(x2, x2), x8 = vmul_vd_vd_vd_sve_sleef(x4, x4), x16 = vmul_vd_vd_vd_sve_sleef(x8, x8); + u = vmla_vd_vd_vd_vd_sve_sleef((x16), (vmla_vd_vd_vd_vd_sve_sleef((x4), (vmla_vd_vd_vd_vd_sve_sleef((x2), (vcast_vd_d_sve_sleef(+0.3161587650653934628e-1)), (vcast_vd_d_sve_sleef(-0.1581918243329996643e-1)))), (vmla_vd_vd_vd_vd_sve_sleef((x2), (vcast_vd_d_sve_sleef(+0.1929045477267910674e-1)), (vcast_vd_d_sve_sleef(+0.6606077476277170610e-2)))))), (vmla_vd_vd_vd_vd_sve_sleef((x8), (vmla_vd_vd_vd_vd_sve_sleef((x4), (vmla_vd_vd_vd_vd_sve_sleef((x2), (vcast_vd_d_sve_sleef(+0.1215360525577377331e-1)), (vcast_vd_d_sve_sleef(+0.1388715184501609218e-1)))), (vmla_vd_vd_vd_vd_sve_sleef((x2), (vcast_vd_d_sve_sleef(+0.1735956991223614604e-1)), (vcast_vd_d_sve_sleef(+0.2237176181932048341e-1)))))), (vmla_vd_vd_vd_vd_sve_sleef((x4), (vmla_vd_vd_vd_vd_sve_sleef((x2), (vcast_vd_d_sve_sleef(+0.3038195928038132237e-1)), (vcast_vd_d_sve_sleef(+0.4464285681377102438e-1)))), (vmla_vd_vd_vd_vd_sve_sleef((x2), (vcast_vd_d_sve_sleef(+0.7500000000378581611e-1)), (vcast_vd_d_sve_sleef(+0.1666666666666497543e+0))))))))) + + ; + + u = vmla_vd_vd_vd_vd_sve_sleef(u, vmul_vd_vd_vd_sve_sleef(x, x2), x); + + vdouble_sve_sleef r = vsel_vd_vo_vd_vd_sve_sleef(o, u, vmla_vd_vd_vd_vd_sve_sleef(u, vcast_vd_d_sve_sleef(-2), vcast_vd_d_sve_sleef(3.141592653589793238462643383279502884/2))); + return vmulsign_vd_vd_vd_sve_sleef(r, d); +} + +SLEEF_INLINE SLEEF_CONST vdouble_sve_sleef Sleef_asindx_u10sve(vdouble_sve_sleef d) { + vopmask_sve_sleef o = vlt_vo_vd_vd_sve_sleef(vabs_vd_vd_sve_sleef(d), vcast_vd_d_sve_sleef(0.5)); + vdouble_sve_sleef x2 = vsel_vd_vo_vd_vd_sve_sleef(o, vmul_vd_vd_vd_sve_sleef(d, d), vmul_vd_vd_vd_sve_sleef(vsub_vd_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(1), vabs_vd_vd_sve_sleef(d)), vcast_vd_d_sve_sleef(0.5))), u; + vdouble2_sve_sleef x = vsel_vd2_vo_vd2_vd2_sve_sleef(o, vcast_vd2_vd_vd_sve_sleef(vabs_vd_vd_sve_sleef(d), vcast_vd_d_sve_sleef(0)), ddsqrt_vd2_vd_sve_sleef(x2)); + x = vsel_vd2_vo_vd2_vd2_sve_sleef(veq_vo_vd_vd_sve_sleef(vabs_vd_vd_sve_sleef(d), vcast_vd_d_sve_sleef(1.0)), vcast_vd2_d_d_sve_sleef(0, 0), x); + + vdouble_sve_sleef x4 = vmul_vd_vd_vd_sve_sleef(x2, x2), x8 = vmul_vd_vd_vd_sve_sleef(x4, x4), x16 = vmul_vd_vd_vd_sve_sleef(x8, x8); + u = vmla_vd_vd_vd_vd_sve_sleef((x16), (vmla_vd_vd_vd_vd_sve_sleef((x4), (vmla_vd_vd_vd_vd_sve_sleef((x2), (vcast_vd_d_sve_sleef(+0.3161587650653934628e-1)), (vcast_vd_d_sve_sleef(-0.1581918243329996643e-1)))), (vmla_vd_vd_vd_vd_sve_sleef((x2), (vcast_vd_d_sve_sleef(+0.1929045477267910674e-1)), (vcast_vd_d_sve_sleef(+0.6606077476277170610e-2)))))), (vmla_vd_vd_vd_vd_sve_sleef((x8), (vmla_vd_vd_vd_vd_sve_sleef((x4), (vmla_vd_vd_vd_vd_sve_sleef((x2), (vcast_vd_d_sve_sleef(+0.1215360525577377331e-1)), (vcast_vd_d_sve_sleef(+0.1388715184501609218e-1)))), (vmla_vd_vd_vd_vd_sve_sleef((x2), (vcast_vd_d_sve_sleef(+0.1735956991223614604e-1)), (vcast_vd_d_sve_sleef(+0.2237176181932048341e-1)))))), (vmla_vd_vd_vd_vd_sve_sleef((x4), (vmla_vd_vd_vd_vd_sve_sleef((x2), (vcast_vd_d_sve_sleef(+0.3038195928038132237e-1)), (vcast_vd_d_sve_sleef(+0.4464285681377102438e-1)))), (vmla_vd_vd_vd_vd_sve_sleef((x2), (vcast_vd_d_sve_sleef(+0.7500000000378581611e-1)), (vcast_vd_d_sve_sleef(+0.1666666666666497543e+0))))))))) + + ; + + u = vmul_vd_vd_vd_sve_sleef(u, vmul_vd_vd_vd_sve_sleef(x2, vd2getx_vd_vd2_sve_sleef(x))); + + vdouble2_sve_sleef y = ddsub_vd2_vd2_vd_sve_sleef(ddsub_vd2_vd2_vd2_sve_sleef(vcast_vd2_d_d_sve_sleef(3.141592653589793116/4, 1.2246467991473532072e-16/4), x), u); + + vdouble_sve_sleef r = vsel_vd_vo_vd_vd_sve_sleef(o, vadd_vd_vd_vd_sve_sleef(u, vd2getx_vd_vd2_sve_sleef(x)), + vmul_vd_vd_vd_sve_sleef(vadd_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(y), vd2gety_vd_vd2_sve_sleef(y)), vcast_vd_d_sve_sleef(2))); + return vmulsign_vd_vd_vd_sve_sleef(r, d); +} + +SLEEF_INLINE SLEEF_CONST vdouble_sve_sleef Sleef_acosdx_u35sve(vdouble_sve_sleef d) { + vopmask_sve_sleef o = vlt_vo_vd_vd_sve_sleef(vabs_vd_vd_sve_sleef(d), vcast_vd_d_sve_sleef(0.5)); + vdouble_sve_sleef x2 = vsel_vd_vo_vd_vd_sve_sleef(o, vmul_vd_vd_vd_sve_sleef(d, d), + vmul_vd_vd_vd_sve_sleef(vsub_vd_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(1), vabs_vd_vd_sve_sleef(d)), vcast_vd_d_sve_sleef(0.5))), u; + vdouble_sve_sleef x = vsel_vd_vo_vd_vd_sve_sleef(o, vabs_vd_vd_sve_sleef(d), vsqrt_vd_vd_sve_sleef(x2)); + x = vsel_vd_vo_vd_vd_sve_sleef(veq_vo_vd_vd_sve_sleef(vabs_vd_vd_sve_sleef(d), vcast_vd_d_sve_sleef(1.0)), vcast_vd_d_sve_sleef(0), x); + + vdouble_sve_sleef x4 = vmul_vd_vd_vd_sve_sleef(x2, x2), x8 = vmul_vd_vd_vd_sve_sleef(x4, x4), x16 = vmul_vd_vd_vd_sve_sleef(x8, x8); + u = vmla_vd_vd_vd_vd_sve_sleef((x16), (vmla_vd_vd_vd_vd_sve_sleef((x4), (vmla_vd_vd_vd_vd_sve_sleef((x2), (vcast_vd_d_sve_sleef(+0.3161587650653934628e-1)), (vcast_vd_d_sve_sleef(-0.1581918243329996643e-1)))), (vmla_vd_vd_vd_vd_sve_sleef((x2), (vcast_vd_d_sve_sleef(+0.1929045477267910674e-1)), (vcast_vd_d_sve_sleef(+0.6606077476277170610e-2)))))), (vmla_vd_vd_vd_vd_sve_sleef((x8), (vmla_vd_vd_vd_vd_sve_sleef((x4), (vmla_vd_vd_vd_vd_sve_sleef((x2), (vcast_vd_d_sve_sleef(+0.1215360525577377331e-1)), (vcast_vd_d_sve_sleef(+0.1388715184501609218e-1)))), (vmla_vd_vd_vd_vd_sve_sleef((x2), (vcast_vd_d_sve_sleef(+0.1735956991223614604e-1)), (vcast_vd_d_sve_sleef(+0.2237176181932048341e-1)))))), (vmla_vd_vd_vd_vd_sve_sleef((x4), (vmla_vd_vd_vd_vd_sve_sleef((x2), (vcast_vd_d_sve_sleef(+0.3038195928038132237e-1)), (vcast_vd_d_sve_sleef(+0.4464285681377102438e-1)))), (vmla_vd_vd_vd_vd_sve_sleef((x2), (vcast_vd_d_sve_sleef(+0.7500000000378581611e-1)), (vcast_vd_d_sve_sleef(+0.1666666666666497543e+0))))))))) + + ; + + u = vmul_vd_vd_vd_sve_sleef(u, vmul_vd_vd_vd_sve_sleef(x2, x)); + + vdouble_sve_sleef y = vsub_vd_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(3.141592653589793238462643383279502884/2), vadd_vd_vd_vd_sve_sleef(vmulsign_vd_vd_vd_sve_sleef(x, d), vmulsign_vd_vd_vd_sve_sleef(u, d))); + x = vadd_vd_vd_vd_sve_sleef(x, u); + vdouble_sve_sleef r = vsel_vd_vo_vd_vd_sve_sleef(o, y, vmul_vd_vd_vd_sve_sleef(x, vcast_vd_d_sve_sleef(2))); + return vsel_vd_vo_vd_vd_sve_sleef(vandnot_vo_vo_vo_sve_sleef(o, vlt_vo_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(0))), + vd2getx_vd_vd2_sve_sleef(ddadd_vd2_vd2_vd_sve_sleef(vcast_vd2_d_d_sve_sleef(3.141592653589793116, 1.2246467991473532072e-16), + vneg_vd_vd_sve_sleef(r))), r); +} + +SLEEF_INLINE SLEEF_CONST vdouble_sve_sleef Sleef_acosdx_u10sve(vdouble_sve_sleef d) { + vopmask_sve_sleef o = vlt_vo_vd_vd_sve_sleef(vabs_vd_vd_sve_sleef(d), vcast_vd_d_sve_sleef(0.5)); + vdouble_sve_sleef x2 = vsel_vd_vo_vd_vd_sve_sleef(o, vmul_vd_vd_vd_sve_sleef(d, d), vmul_vd_vd_vd_sve_sleef(vsub_vd_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(1), vabs_vd_vd_sve_sleef(d)), vcast_vd_d_sve_sleef(0.5))), u; + vdouble2_sve_sleef x = vsel_vd2_vo_vd2_vd2_sve_sleef(o, vcast_vd2_vd_vd_sve_sleef(vabs_vd_vd_sve_sleef(d), vcast_vd_d_sve_sleef(0)), ddsqrt_vd2_vd_sve_sleef(x2)); + x = vsel_vd2_vo_vd2_vd2_sve_sleef(veq_vo_vd_vd_sve_sleef(vabs_vd_vd_sve_sleef(d), vcast_vd_d_sve_sleef(1.0)), vcast_vd2_d_d_sve_sleef(0, 0), x); + + vdouble_sve_sleef x4 = vmul_vd_vd_vd_sve_sleef(x2, x2), x8 = vmul_vd_vd_vd_sve_sleef(x4, x4), x16 = vmul_vd_vd_vd_sve_sleef(x8, x8); + u = vmla_vd_vd_vd_vd_sve_sleef((x16), (vmla_vd_vd_vd_vd_sve_sleef((x4), (vmla_vd_vd_vd_vd_sve_sleef((x2), (vcast_vd_d_sve_sleef(+0.3161587650653934628e-1)), (vcast_vd_d_sve_sleef(-0.1581918243329996643e-1)))), (vmla_vd_vd_vd_vd_sve_sleef((x2), (vcast_vd_d_sve_sleef(+0.1929045477267910674e-1)), (vcast_vd_d_sve_sleef(+0.6606077476277170610e-2)))))), (vmla_vd_vd_vd_vd_sve_sleef((x8), (vmla_vd_vd_vd_vd_sve_sleef((x4), (vmla_vd_vd_vd_vd_sve_sleef((x2), (vcast_vd_d_sve_sleef(+0.1215360525577377331e-1)), (vcast_vd_d_sve_sleef(+0.1388715184501609218e-1)))), (vmla_vd_vd_vd_vd_sve_sleef((x2), (vcast_vd_d_sve_sleef(+0.1735956991223614604e-1)), (vcast_vd_d_sve_sleef(+0.2237176181932048341e-1)))))), (vmla_vd_vd_vd_vd_sve_sleef((x4), (vmla_vd_vd_vd_vd_sve_sleef((x2), (vcast_vd_d_sve_sleef(+0.3038195928038132237e-1)), (vcast_vd_d_sve_sleef(+0.4464285681377102438e-1)))), (vmla_vd_vd_vd_vd_sve_sleef((x2), (vcast_vd_d_sve_sleef(+0.7500000000378581611e-1)), (vcast_vd_d_sve_sleef(+0.1666666666666497543e+0))))))))) + + ; + + u = vmul_vd_vd_vd_sve_sleef(u, vmul_vd_vd_vd_sve_sleef(x2, vd2getx_vd_vd2_sve_sleef(x))); + + vdouble2_sve_sleef y = ddsub_vd2_vd2_vd2_sve_sleef(vcast_vd2_d_d_sve_sleef(3.141592653589793116/2, 1.2246467991473532072e-16/2), + ddadd_vd2_vd_vd_sve_sleef(vmulsign_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(x), d), vmulsign_vd_vd_vd_sve_sleef(u, d))); + x = ddadd_vd2_vd2_vd_sve_sleef(x, u); + + y = vsel_vd2_vo_vd2_vd2_sve_sleef(o, y, ddscale_vd2_vd2_vd_sve_sleef(x, vcast_vd_d_sve_sleef(2))); + + y = vsel_vd2_vo_vd2_vd2_sve_sleef(vandnot_vo_vo_vo_sve_sleef(o, vlt_vo_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(0))), + ddsub_vd2_vd2_vd2_sve_sleef(vcast_vd2_d_d_sve_sleef(3.141592653589793116, 1.2246467991473532072e-16), y), y); + + return vadd_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(y), vd2gety_vd_vd2_sve_sleef(y)); +} + +SLEEF_INLINE SLEEF_CONST vdouble_sve_sleef Sleef_atandx_u10sve(vdouble_sve_sleef d) { + vdouble2_sve_sleef d2 = atan2k_u1_sve_sleef(vcast_vd2_vd_vd_sve_sleef(vabs_vd_vd_sve_sleef(d), vcast_vd_d_sve_sleef(0)), vcast_vd2_d_d_sve_sleef(1, 0)); + vdouble_sve_sleef r = vadd_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(d2), vd2gety_vd_vd2_sve_sleef(d2)); + r = vsel_vd_vo_vd_vd_sve_sleef(visinf_vo_vd_sve_sleef(d), vcast_vd_d_sve_sleef(1.570796326794896557998982), r); + return vmulsign_vd_vd_vd_sve_sleef(r, d); +} + +SLEEF_INLINE SLEEF_CONST vdouble_sve_sleef Sleef_atandx_u35sve(vdouble_sve_sleef s) { + vdouble_sve_sleef t, u; + vint_sve_sleef q; + + q = vsel_vi_vd_vi_sve_sleef(s, vcast_vi_i_sve_sleef(2)); + s = vabs_vd_vd_sve_sleef(s); + + q = vsel_vi_vd_vd_vi_vi_sve_sleef(vcast_vd_d_sve_sleef(1), s, vadd_vi_vi_vi_sve_sleef(q, vcast_vi_i_sve_sleef(1)), q); + s = vsel_vd_vo_vd_vd_sve_sleef(vlt_vo_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(1), s), vrec_vd_vd_sve_sleef(s), s); + + t = vmul_vd_vd_vd_sve_sleef(s, s); + + vdouble_sve_sleef t2 = vmul_vd_vd_vd_sve_sleef(t, t), t4 = vmul_vd_vd_vd_sve_sleef(t2, t2), t8 = vmul_vd_vd_vd_sve_sleef(t4, t4), t16 = vmul_vd_vd_vd_sve_sleef(t8, t8); + u = vmla_vd_vd_vd_vd_sve_sleef((t16), (vmla_vd_vd_vd_vd_sve_sleef((t2), (vcast_vd_d_sve_sleef(-1.88796008463073496563746e-05)), (vmla_vd_vd_vd_vd_sve_sleef((t), (vcast_vd_d_sve_sleef(0.000209850076645816976906797)), (vcast_vd_d_sve_sleef(-0.00110611831486672482563471)))))), (vmla_vd_vd_vd_vd_sve_sleef((t8), (vmla_vd_vd_vd_vd_sve_sleef((t4), (vmla_vd_vd_vd_vd_sve_sleef((t2), (vmla_vd_vd_vd_vd_sve_sleef((t), (vcast_vd_d_sve_sleef(0.00370026744188713119232403)), (vcast_vd_d_sve_sleef(-0.00889896195887655491740809)))), (vmla_vd_vd_vd_vd_sve_sleef((t), (vcast_vd_d_sve_sleef(0.016599329773529201970117)), (vcast_vd_d_sve_sleef(-0.0254517624932312641616861)))))), (vmla_vd_vd_vd_vd_sve_sleef((t2), (vmla_vd_vd_vd_vd_sve_sleef((t), (vcast_vd_d_sve_sleef(0.0337852580001353069993897)), (vcast_vd_d_sve_sleef(-0.0407629191276836500001934)))), (vmla_vd_vd_vd_vd_sve_sleef((t), (vcast_vd_d_sve_sleef(0.0466667150077840625632675)), (vcast_vd_d_sve_sleef(-0.0523674852303482457616113)))))))), (vmla_vd_vd_vd_vd_sve_sleef((t4), (vmla_vd_vd_vd_vd_sve_sleef((t2), (vmla_vd_vd_vd_vd_sve_sleef((t), (vcast_vd_d_sve_sleef(0.0587666392926673580854313)), (vcast_vd_d_sve_sleef(-0.0666573579361080525984562)))), (vmla_vd_vd_vd_vd_sve_sleef((t), (vcast_vd_d_sve_sleef(0.0769219538311769618355029)), (vcast_vd_d_sve_sleef(-0.090908995008245008229153)))))), (vmla_vd_vd_vd_vd_sve_sleef((t2), (vmla_vd_vd_vd_vd_sve_sleef((t), (vcast_vd_d_sve_sleef(0.111111105648261418443745)), (vcast_vd_d_sve_sleef(-0.14285714266771329383765)))), (vmla_vd_vd_vd_vd_sve_sleef((t), (vcast_vd_d_sve_sleef(0.199999999996591265594148)), (vcast_vd_d_sve_sleef(-0.333333333333311110369124))))))))))) + + ; + + t = vmla_vd_vd_vd_vd_sve_sleef(s, vmul_vd_vd_vd_sve_sleef(t, u), s); + + t = vsel_vd_vo_vd_vd_sve_sleef(vcast_vo64_vo32_sve_sleef(veq_vo_vi_vi_sve_sleef(vand_vi_vi_vi_sve_sleef(q, vcast_vi_i_sve_sleef(1)), vcast_vi_i_sve_sleef(1))), vsub_vd_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(3.141592653589793238462643383279502884/2), t), t); + t = vreinterpret_vd_vm_sve_sleef(vxor_vm_vm_vm_sve_sleef(vand_vm_vo64_vm_sve_sleef(vcast_vo64_vo32_sve_sleef(veq_vo_vi_vi_sve_sleef(vand_vi_vi_vi_sve_sleef(q, vcast_vi_i_sve_sleef(2)), vcast_vi_i_sve_sleef(2))), vreinterpret_vm_vd_sve_sleef(vcast_vd_d_sve_sleef(-0.0))), vreinterpret_vm_vd_sve_sleef(t))); + + return t; +} + +SLEEF_INLINE SLEEF_CONST vdouble_sve_sleef Sleef_logdx_u35sve(vdouble_sve_sleef d) { + vdouble_sve_sleef x, x2; + vdouble_sve_sleef t, m; + + vopmask_sve_sleef o = vlt_vo_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(0x1p-1022)); + d = vsel_vd_vo_vd_vd_sve_sleef(o, vmul_vd_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef((double)(INT64_C(1) << 32) * (double)(INT64_C(1) << 32))), d); + vint_sve_sleef e = vilogb2k_vi_vd_sve_sleef(vmul_vd_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(1.0/0.75))); + m = vldexp3_vd_vd_vi_sve_sleef(d, vneg_vi_vi_sve_sleef(e)); + e = vsel_vi_vo_vi_vi_sve_sleef(vcast_vo32_vo64_sve_sleef(o), vsub_vi_vi_vi_sve_sleef(e, vcast_vi_i_sve_sleef(64)), e); + + x = vdiv_vd_vd_vd_sve_sleef(vsub_vd_vd_vd_sve_sleef(m, vcast_vd_d_sve_sleef(1)), vadd_vd_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(1), m)); + x2 = vmul_vd_vd_vd_sve_sleef(x, x); + + vdouble_sve_sleef x4 = vmul_vd_vd_vd_sve_sleef(x2, x2), x8 = vmul_vd_vd_vd_sve_sleef(x4, x4), x3 = vmul_vd_vd_vd_sve_sleef(x, x2); + t = vmla_vd_vd_vd_vd_sve_sleef((x8), (vmla_vd_vd_vd_vd_sve_sleef((x4), (vcast_vd_d_sve_sleef(0.153487338491425068243146)), (vmla_vd_vd_vd_vd_sve_sleef((x2), (vcast_vd_d_sve_sleef(0.152519917006351951593857)), (vcast_vd_d_sve_sleef(0.181863266251982985677316)))))), (vmla_vd_vd_vd_vd_sve_sleef((x4), (vmla_vd_vd_vd_vd_sve_sleef((x2), (vcast_vd_d_sve_sleef(0.222221366518767365905163)), (vcast_vd_d_sve_sleef(0.285714294746548025383248)))), (vmla_vd_vd_vd_vd_sve_sleef((x2), (vcast_vd_d_sve_sleef(0.399999999950799600689777)), (vcast_vd_d_sve_sleef(0.6666666666667778740063))))))) + + ; + + x = vmla_vd_vd_vd_vd_sve_sleef(x, vcast_vd_d_sve_sleef(2), vmul_vd_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(0.693147180559945286226764), vcast_vd_vi_sve_sleef(e))); + x = vmla_vd_vd_vd_vd_sve_sleef(x3, t, x); + + x = vsel_vd_vo_vd_vd_sve_sleef(vispinf_vo_vd_sve_sleef(d), vcast_vd_d_sve_sleef(__builtin_inf()), x); + x = vsel_vd_vo_vd_vd_sve_sleef(vor_vo_vo_vo_sve_sleef(vlt_vo_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(0)), visnan_vo_vd_sve_sleef(d)), vcast_vd_d_sve_sleef(__builtin_nan("")), x); + x = vsel_vd_vo_vd_vd_sve_sleef(veq_vo_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(0)), vcast_vd_d_sve_sleef(-__builtin_inf()), x); + + return x; +} + +SLEEF_INLINE SLEEF_CONST vdouble_sve_sleef Sleef_expdx_u10sve(vdouble_sve_sleef d) { + vdouble_sve_sleef u = vrint_vd_vd_sve_sleef(vmul_vd_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(1.442695040888963407359924681001892137426645954152985934135449406931))), s; + vint_sve_sleef q = vrint_vi_vd_sve_sleef(u); + + s = vmla_vd_vd_vd_vd_sve_sleef(u, vcast_vd_d_sve_sleef(-.69314718055966295651160180568695068359375), d); + s = vmla_vd_vd_vd_vd_sve_sleef(u, vcast_vd_d_sve_sleef(-.28235290563031577122588448175013436025525412068e-12), s); + + vdouble_sve_sleef s2 = vmul_vd_vd_vd_sve_sleef(s, s), s4 = vmul_vd_vd_vd_sve_sleef(s2, s2), s8 = vmul_vd_vd_vd_sve_sleef(s4, s4); + u = vmla_vd_vd_vd_vd_sve_sleef((s8), (vmla_vd_vd_vd_vd_sve_sleef((s), (vcast_vd_d_sve_sleef(+0.2081276378237164457e-8)), (vcast_vd_d_sve_sleef(+0.2511210703042288022e-7)))), (vmla_vd_vd_vd_vd_sve_sleef((s4), (vmla_vd_vd_vd_vd_sve_sleef((s2), (vmla_vd_vd_vd_vd_sve_sleef((s), (vcast_vd_d_sve_sleef(+0.2755762628169491192e-6)), (vcast_vd_d_sve_sleef(+0.2755723402025388239e-5)))), (vmla_vd_vd_vd_vd_sve_sleef((s), (vcast_vd_d_sve_sleef(+0.2480158687479686264e-4)), (vcast_vd_d_sve_sleef(+0.1984126989855865850e-3)))))), (vmla_vd_vd_vd_vd_sve_sleef((s2), (vmla_vd_vd_vd_vd_sve_sleef((s), (vcast_vd_d_sve_sleef(+0.1388888888914497797e-2)), (vcast_vd_d_sve_sleef(+0.8333333333314938210e-2)))), (vmla_vd_vd_vd_vd_sve_sleef((s), (vcast_vd_d_sve_sleef(+0.4166666666666602598e-1)), (vcast_vd_d_sve_sleef(+0.1666666666666669072e+0))))))))) + + ; + u = vfma_vd_vd_vd_vd_sve_sleef(u, s, vcast_vd_d_sve_sleef(+0.5000000000000000000e+0)); + u = vfma_vd_vd_vd_vd_sve_sleef(u, s, vcast_vd_d_sve_sleef(+0.1000000000000000000e+1)); + u = vfma_vd_vd_vd_vd_sve_sleef(u, s, vcast_vd_d_sve_sleef(+0.1000000000000000000e+1)); + + u = vldexp2_vd_vd_vi_sve_sleef(u, q); + + u = vsel_vd_vo_vd_vd_sve_sleef(vgt_vo_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(709.78271114955742909217217426)), vcast_vd_d_sve_sleef(__builtin_inf()), u); + u = vreinterpret_vd_vm_sve_sleef(vandnot_vm_vo64_vm_sve_sleef(vlt_vo_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(-1000)), vreinterpret_vm_vd_sve_sleef(u))); + + return u; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_sve_sleef expm1k_sve_sleef(vdouble_sve_sleef d) { + vdouble_sve_sleef u = vrint_vd_vd_sve_sleef(vmul_vd_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(1.442695040888963407359924681001892137426645954152985934135449406931))), s; + vint_sve_sleef q = vrint_vi_vd_sve_sleef(u); + + s = vmla_vd_vd_vd_vd_sve_sleef(u, vcast_vd_d_sve_sleef(-.69314718055966295651160180568695068359375), d); + s = vmla_vd_vd_vd_vd_sve_sleef(u, vcast_vd_d_sve_sleef(-.28235290563031577122588448175013436025525412068e-12), s); + + vdouble_sve_sleef s2 = vmul_vd_vd_vd_sve_sleef(s, s), s4 = vmul_vd_vd_vd_sve_sleef(s2, s2), s8 = vmul_vd_vd_vd_sve_sleef(s4, s4); + u = vmla_vd_vd_vd_vd_sve_sleef((s8), (vmla_vd_vd_vd_vd_sve_sleef((s), (vcast_vd_d_sve_sleef(2.08860621107283687536341e-09)), (vcast_vd_d_sve_sleef(2.51112930892876518610661e-08)))), (vmla_vd_vd_vd_vd_sve_sleef((s4), (vmla_vd_vd_vd_vd_sve_sleef((s2), (vmla_vd_vd_vd_vd_sve_sleef((s), (vcast_vd_d_sve_sleef(2.75573911234900471893338e-07)), (vcast_vd_d_sve_sleef(2.75572362911928827629423e-06)))), (vmla_vd_vd_vd_vd_sve_sleef((s), (vcast_vd_d_sve_sleef(2.4801587159235472998791e-05)), (vcast_vd_d_sve_sleef(0.000198412698960509205564975)))))), (vmla_vd_vd_vd_vd_sve_sleef((s2), (vmla_vd_vd_vd_vd_sve_sleef((s), (vcast_vd_d_sve_sleef(0.00138888888889774492207962)), (vcast_vd_d_sve_sleef(0.00833333333331652721664984)))), (vmla_vd_vd_vd_vd_sve_sleef((s), (vcast_vd_d_sve_sleef(0.0416666666666665047591422)), (vcast_vd_d_sve_sleef(0.166666666666666851703837))))))))) + + ; + + u = vadd_vd_vd_vd_sve_sleef(vmla_vd_vd_vd_vd_sve_sleef(s2, vcast_vd_d_sve_sleef(0.5), vmul_vd_vd_vd_sve_sleef(vmul_vd_vd_vd_sve_sleef(s2, s), u)), s); + + u = vsel_vd_vo_vd_vd_sve_sleef(vcast_vo64_vo32_sve_sleef(veq_vo_vi_vi_sve_sleef(q, vcast_vi_i_sve_sleef(0))), u, + vsub_vd_vd_vd_sve_sleef(vldexp2_vd_vd_vi_sve_sleef(vadd_vd_vd_vd_sve_sleef(u, vcast_vd_d_sve_sleef(1)), q), vcast_vd_d_sve_sleef(1))); + + return u; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_sve_sleef logk_sve_sleef(vdouble_sve_sleef d) { + vdouble2_sve_sleef x, x2, s; + vdouble_sve_sleef t, m; + + vopmask_sve_sleef o = vlt_vo_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(0x1p-1022)); + d = vsel_vd_vo_vd_vd_sve_sleef(o, vmul_vd_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef((double)(INT64_C(1) << 32) * (double)(INT64_C(1) << 32))), d); + vint_sve_sleef e = vilogb2k_vi_vd_sve_sleef(vmul_vd_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(1.0/0.75))); + m = vldexp3_vd_vd_vi_sve_sleef(d, vneg_vi_vi_sve_sleef(e)); + e = vsel_vi_vo_vi_vi_sve_sleef(vcast_vo32_vo64_sve_sleef(o), vsub_vi_vi_vi_sve_sleef(e, vcast_vi_i_sve_sleef(64)), e); + + x = dddiv_vd2_vd2_vd2_sve_sleef(ddadd2_vd2_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(-1), m), ddadd2_vd2_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(1), m)); + x2 = ddsqu_vd2_vd2_sve_sleef(x); + + vdouble_sve_sleef x4 = vmul_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(x2), vd2getx_vd_vd2_sve_sleef(x2)), x8 = vmul_vd_vd_vd_sve_sleef(x4, x4), x16 = vmul_vd_vd_vd_sve_sleef(x8, x8); + t = vmla_vd_vd_vd_vd_sve_sleef((x16), (vcast_vd_d_sve_sleef(0.116255524079935043668677)), (vmla_vd_vd_vd_vd_sve_sleef((x8), (vmla_vd_vd_vd_vd_sve_sleef((x4), (vmla_vd_vd_vd_vd_sve_sleef((vd2getx_vd_vd2_sve_sleef(x2)), (vcast_vd_d_sve_sleef(0.103239680901072952701192)), (vcast_vd_d_sve_sleef(0.117754809412463995466069)))), (vmla_vd_vd_vd_vd_sve_sleef((vd2getx_vd_vd2_sve_sleef(x2)), (vcast_vd_d_sve_sleef(0.13332981086846273921509)), (vcast_vd_d_sve_sleef(0.153846227114512262845736)))))), (vmla_vd_vd_vd_vd_sve_sleef((x4), (vmla_vd_vd_vd_vd_sve_sleef((vd2getx_vd_vd2_sve_sleef(x2)), (vcast_vd_d_sve_sleef(0.181818180850050775676507)), (vcast_vd_d_sve_sleef(0.222222222230083560345903)))), (vmla_vd_vd_vd_vd_sve_sleef((vd2getx_vd_vd2_sve_sleef(x2)), (vcast_vd_d_sve_sleef(0.285714285714249172087875)), (vcast_vd_d_sve_sleef(0.400000000000000077715612))))))))) + + ; + + vdouble2_sve_sleef c = vcast_vd2_d_d_sve_sleef(0.666666666666666629659233, 3.80554962542412056336616e-17); + + s = ddmul_vd2_vd2_vd_sve_sleef(vcast_vd2_d_d_sve_sleef(0.693147180559945286226764, 2.319046813846299558417771e-17), vcast_vd_vi_sve_sleef(e)); + + s = ddadd_vd2_vd2_vd2_sve_sleef(s, ddscale_vd2_vd2_vd_sve_sleef(x, vcast_vd_d_sve_sleef(2))); + x = ddmul_vd2_vd2_vd2_sve_sleef(x2, x); + s = ddadd_vd2_vd2_vd2_sve_sleef(s, ddmul_vd2_vd2_vd2_sve_sleef(x, c)); + x = ddmul_vd2_vd2_vd2_sve_sleef(x2, x); + s = ddadd_vd2_vd2_vd2_sve_sleef(s, ddmul_vd2_vd2_vd_sve_sleef(x, t)); + + return s; +} + +SLEEF_INLINE SLEEF_CONST vdouble_sve_sleef Sleef_logdx_u10sve(vdouble_sve_sleef d) { + vdouble2_sve_sleef x; + vdouble_sve_sleef t, m, x2; + + vopmask_sve_sleef o = vlt_vo_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(0x1p-1022)); + d = vsel_vd_vo_vd_vd_sve_sleef(o, vmul_vd_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef((double)(INT64_C(1) << 32) * (double)(INT64_C(1) << 32))), d); + vint_sve_sleef e = vilogb2k_vi_vd_sve_sleef(vmul_vd_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(1.0/0.75))); + m = vldexp3_vd_vd_vi_sve_sleef(d, vneg_vi_vi_sve_sleef(e)); + e = vsel_vi_vo_vi_vi_sve_sleef(vcast_vo32_vo64_sve_sleef(o), vsub_vi_vi_vi_sve_sleef(e, vcast_vi_i_sve_sleef(64)), e); + + x = dddiv_vd2_vd2_vd2_sve_sleef(ddadd2_vd2_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(-1), m), ddadd2_vd2_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(1), m)); + x2 = vmul_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(x), vd2getx_vd_vd2_sve_sleef(x)); + + vdouble_sve_sleef x4 = vmul_vd_vd_vd_sve_sleef(x2, x2), x8 = vmul_vd_vd_vd_sve_sleef(x4, x4); + t = vmla_vd_vd_vd_vd_sve_sleef((x8), (vmla_vd_vd_vd_vd_sve_sleef((x4), (vcast_vd_d_sve_sleef(0.1532076988502701353e+0)), (vmla_vd_vd_vd_vd_sve_sleef((x2), (vcast_vd_d_sve_sleef(0.1525629051003428716e+0)), (vcast_vd_d_sve_sleef(0.1818605932937785996e+0)))))), (vmla_vd_vd_vd_vd_sve_sleef((x4), (vmla_vd_vd_vd_vd_sve_sleef((x2), (vcast_vd_d_sve_sleef(0.2222214519839380009e+0)), (vcast_vd_d_sve_sleef(0.2857142932794299317e+0)))), (vmla_vd_vd_vd_vd_sve_sleef((x2), (vcast_vd_d_sve_sleef(0.3999999999635251990e+0)), (vcast_vd_d_sve_sleef(0.6666666666667333541e+0))))))) + + ; + + vdouble2_sve_sleef s = ddmul_vd2_vd2_vd_sve_sleef(vcast_vd2_d_d_sve_sleef(0.693147180559945286226764, 2.319046813846299558417771e-17), vcast_vd_vi_sve_sleef(e)); + + s = ddadd_vd2_vd2_vd2_sve_sleef(s, ddscale_vd2_vd2_vd_sve_sleef(x, vcast_vd_d_sve_sleef(2))); + s = ddadd_vd2_vd2_vd_sve_sleef(s, vmul_vd_vd_vd_sve_sleef(vmul_vd_vd_vd_sve_sleef(x2, vd2getx_vd_vd2_sve_sleef(x)), t)); + + vdouble_sve_sleef r = vadd_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(s), vd2gety_vd_vd2_sve_sleef(s)); + + r = vsel_vd_vo_vd_vd_sve_sleef(vispinf_vo_vd_sve_sleef(d), vcast_vd_d_sve_sleef(__builtin_inf()), r); + r = vsel_vd_vo_vd_vd_sve_sleef(vor_vo_vo_vo_sve_sleef(vlt_vo_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(0)), visnan_vo_vd_sve_sleef(d)), vcast_vd_d_sve_sleef(__builtin_nan("")), r); + r = vsel_vd_vo_vd_vd_sve_sleef(veq_vo_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(0)), vcast_vd_d_sve_sleef(-__builtin_inf()), r); + + return r; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_sve_sleef expk_sve_sleef(vdouble2_sve_sleef d) { + vdouble_sve_sleef u = vmul_vd_vd_vd_sve_sleef(vadd_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(d), vd2gety_vd_vd2_sve_sleef(d)), vcast_vd_d_sve_sleef(1.442695040888963407359924681001892137426645954152985934135449406931)); + vdouble_sve_sleef dq = vrint_vd_vd_sve_sleef(u); + vint_sve_sleef q = vrint_vi_vd_sve_sleef(dq); + vdouble2_sve_sleef s, t; + + s = ddadd2_vd2_vd2_vd_sve_sleef(d, vmul_vd_vd_vd_sve_sleef(dq, vcast_vd_d_sve_sleef(-.69314718055966295651160180568695068359375))); + s = ddadd2_vd2_vd2_vd_sve_sleef(s, vmul_vd_vd_vd_sve_sleef(dq, vcast_vd_d_sve_sleef(-.28235290563031577122588448175013436025525412068e-12))); + + s = ddnormalize_vd2_vd2_sve_sleef(s); + + vdouble_sve_sleef s2 = vmul_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(s), vd2getx_vd_vd2_sve_sleef(s)), s4 = vmul_vd_vd_vd_sve_sleef(s2, s2), s8 = vmul_vd_vd_vd_sve_sleef(s4, s4); + u = vmla_vd_vd_vd_vd_sve_sleef((s8), (vmla_vd_vd_vd_vd_sve_sleef((vd2getx_vd_vd2_sve_sleef(s)), (vcast_vd_d_sve_sleef(2.51069683420950419527139e-08)), (vcast_vd_d_sve_sleef(2.76286166770270649116855e-07)))), (vmla_vd_vd_vd_vd_sve_sleef((s4), (vmla_vd_vd_vd_vd_sve_sleef((s2), (vmla_vd_vd_vd_vd_sve_sleef((vd2getx_vd_vd2_sve_sleef(s)), (vcast_vd_d_sve_sleef(2.75572496725023574143864e-06)), (vcast_vd_d_sve_sleef(2.48014973989819794114153e-05)))), (vmla_vd_vd_vd_vd_sve_sleef((vd2getx_vd_vd2_sve_sleef(s)), (vcast_vd_d_sve_sleef(0.000198412698809069797676111)), (vcast_vd_d_sve_sleef(0.0013888888939977128960529)))))), (vmla_vd_vd_vd_vd_sve_sleef((s2), (vmla_vd_vd_vd_vd_sve_sleef((vd2getx_vd_vd2_sve_sleef(s)), (vcast_vd_d_sve_sleef(0.00833333333332371417601081)), (vcast_vd_d_sve_sleef(0.0416666666665409524128449)))), (vmla_vd_vd_vd_vd_sve_sleef((vd2getx_vd_vd2_sve_sleef(s)), (vcast_vd_d_sve_sleef(0.166666666666666740681535)), (vcast_vd_d_sve_sleef(0.500000000000000999200722))))))))) + + ; + + t = ddadd_vd2_vd_vd2_sve_sleef(vcast_vd_d_sve_sleef(1), s); + t = ddadd_vd2_vd2_vd2_sve_sleef(t, ddmul_vd2_vd2_vd_sve_sleef(ddsqu_vd2_vd2_sve_sleef(s), u)); + + u = vadd_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(t), vd2gety_vd_vd2_sve_sleef(t)); + u = vldexp2_vd_vd_vi_sve_sleef(u, q); + + u = vreinterpret_vd_vm_sve_sleef(vandnot_vm_vo64_vm_sve_sleef(vlt_vo_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(d), vcast_vd_d_sve_sleef(-1000)), vreinterpret_vm_vd_sve_sleef(u))); + + return u; +} + +SLEEF_INLINE SLEEF_CONST vdouble_sve_sleef Sleef_powdx_u10sve(vdouble_sve_sleef x, vdouble_sve_sleef y) { + + vopmask_sve_sleef yisint = visint_vo_vd_sve_sleef(y); + vopmask_sve_sleef yisodd = vand_vo_vo_vo_sve_sleef(visodd_vo_vd_sve_sleef(y), yisint); + + vdouble2_sve_sleef d = ddmul_vd2_vd2_vd_sve_sleef(logk_sve_sleef(vabs_vd_vd_sve_sleef(x)), y); + vdouble_sve_sleef result = expk_sve_sleef(d); + result = vsel_vd_vo_vd_vd_sve_sleef(vgt_vo_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(d), vcast_vd_d_sve_sleef(709.78271114955742909217217426)), vcast_vd_d_sve_sleef(__builtin_inf()), result); + + result = vmul_vd_vd_vd_sve_sleef(result, + vsel_vd_vo_vd_vd_sve_sleef(vgt_vo_vd_vd_sve_sleef(x, vcast_vd_d_sve_sleef(0)), + vcast_vd_d_sve_sleef(1), + vsel_vd_vo_vd_vd_sve_sleef(yisint, vsel_vd_vo_vd_vd_sve_sleef(yisodd, vcast_vd_d_sve_sleef(-1.0), vcast_vd_d_sve_sleef(1)), vcast_vd_d_sve_sleef(__builtin_nan(""))))); + + vdouble_sve_sleef efx = vmulsign_vd_vd_vd_sve_sleef(vsub_vd_vd_vd_sve_sleef(vabs_vd_vd_sve_sleef(x), vcast_vd_d_sve_sleef(1)), y); + + result = vsel_vd_vo_vd_vd_sve_sleef(visinf_vo_vd_sve_sleef(y), + vreinterpret_vd_vm_sve_sleef(vandnot_vm_vo64_vm_sve_sleef(vlt_vo_vd_vd_sve_sleef(efx, vcast_vd_d_sve_sleef(0.0)), + vreinterpret_vm_vd_sve_sleef(vsel_vd_vo_vd_vd_sve_sleef(veq_vo_vd_vd_sve_sleef(efx, vcast_vd_d_sve_sleef(0.0)), + vcast_vd_d_sve_sleef(1.0), + vcast_vd_d_sve_sleef(__builtin_inf()))))), + result); + + result = vsel_vd_vo_vd_vd_sve_sleef(vor_vo_vo_vo_sve_sleef(visinf_vo_vd_sve_sleef(x), veq_vo_vd_vd_sve_sleef(x, vcast_vd_d_sve_sleef(0.0))), + vmulsign_vd_vd_vd_sve_sleef(vsel_vd_vo_vd_vd_sve_sleef(vxor_vo_vo_vo_sve_sleef(vsignbit_vo_vd_sve_sleef(y), veq_vo_vd_vd_sve_sleef(x, vcast_vd_d_sve_sleef(0.0))), + vcast_vd_d_sve_sleef(0), vcast_vd_d_sve_sleef(__builtin_inf())), + vsel_vd_vo_vd_vd_sve_sleef(yisodd, x, vcast_vd_d_sve_sleef(1))), result); + + result = vreinterpret_vd_vm_sve_sleef(vor_vm_vo64_vm_sve_sleef(vor_vo_vo_vo_sve_sleef(visnan_vo_vd_sve_sleef(x), visnan_vo_vd_sve_sleef(y)), vreinterpret_vm_vd_sve_sleef(result))); + + result = vsel_vd_vo_vd_vd_sve_sleef(vor_vo_vo_vo_sve_sleef(veq_vo_vd_vd_sve_sleef(y, vcast_vd_d_sve_sleef(0)), veq_vo_vd_vd_sve_sleef(x, vcast_vd_d_sve_sleef(1))), vcast_vd_d_sve_sleef(1), result); + + return result; + +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_sve_sleef expk2_sve_sleef(vdouble2_sve_sleef d) { + vdouble_sve_sleef u = vmul_vd_vd_vd_sve_sleef(vadd_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(d), vd2gety_vd_vd2_sve_sleef(d)), vcast_vd_d_sve_sleef(1.442695040888963407359924681001892137426645954152985934135449406931)); + vdouble_sve_sleef dq = vrint_vd_vd_sve_sleef(u); + vint_sve_sleef q = vrint_vi_vd_sve_sleef(dq); + vdouble2_sve_sleef s, t; + + s = ddadd2_vd2_vd2_vd_sve_sleef(d, vmul_vd_vd_vd_sve_sleef(dq, vcast_vd_d_sve_sleef(-.69314718055966295651160180568695068359375))); + s = ddadd2_vd2_vd2_vd_sve_sleef(s, vmul_vd_vd_vd_sve_sleef(dq, vcast_vd_d_sve_sleef(-.28235290563031577122588448175013436025525412068e-12))); + + vdouble2_sve_sleef s2 = ddsqu_vd2_vd2_sve_sleef(s), s4 = ddsqu_vd2_vd2_sve_sleef(s2); + vdouble_sve_sleef s8 = vmul_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(s4), vd2getx_vd_vd2_sve_sleef(s4)); + u = vmla_vd_vd_vd_vd_sve_sleef((s8), (vmla_vd_vd_vd_vd_sve_sleef((vd2getx_vd_vd2_sve_sleef(s)), (vcast_vd_d_sve_sleef(+0.1602472219709932072e-9)), (vcast_vd_d_sve_sleef(+0.2092255183563157007e-8)))), (vmla_vd_vd_vd_vd_sve_sleef((vd2getx_vd_vd2_sve_sleef(s4)), (vmla_vd_vd_vd_vd_sve_sleef((vd2getx_vd_vd2_sve_sleef(s2)), (vmla_vd_vd_vd_vd_sve_sleef((vd2getx_vd_vd2_sve_sleef(s)), (vcast_vd_d_sve_sleef(+0.2505230023782644465e-7)), (vcast_vd_d_sve_sleef(+0.2755724800902135303e-6)))), (vmla_vd_vd_vd_vd_sve_sleef((vd2getx_vd_vd2_sve_sleef(s)), (vcast_vd_d_sve_sleef(+0.2755731892386044373e-5)), (vcast_vd_d_sve_sleef(+0.2480158735605815065e-4)))))), (vmla_vd_vd_vd_vd_sve_sleef((vd2getx_vd_vd2_sve_sleef(s2)), (vmla_vd_vd_vd_vd_sve_sleef((vd2getx_vd_vd2_sve_sleef(s)), (vcast_vd_d_sve_sleef(+0.1984126984148071858e-3)), (vcast_vd_d_sve_sleef(+0.1388888888886763255e-2)))), (vmla_vd_vd_vd_vd_sve_sleef((vd2getx_vd_vd2_sve_sleef(s)), (vcast_vd_d_sve_sleef(+0.8333333333333347095e-2)), (vcast_vd_d_sve_sleef(+0.4166666666666669905e-1))))))))) + + ; + + t = ddadd_vd2_vd_vd2_sve_sleef(vcast_vd_d_sve_sleef(0.5), ddmul_vd2_vd2_vd_sve_sleef(s, vcast_vd_d_sve_sleef(+0.1666666666666666574e+0))); + t = ddadd_vd2_vd_vd2_sve_sleef(vcast_vd_d_sve_sleef(1.0), ddmul_vd2_vd2_vd2_sve_sleef(t, s)); + t = ddadd_vd2_vd_vd2_sve_sleef(vcast_vd_d_sve_sleef(1.0), ddmul_vd2_vd2_vd2_sve_sleef(t, s)); + t = ddadd_vd2_vd2_vd2_sve_sleef(t, ddmul_vd2_vd2_vd_sve_sleef(s4, u)); + + t = vd2setx_vd2_vd2_vd_sve_sleef(t, vldexp2_vd_vd_vi_sve_sleef(vd2getx_vd_vd2_sve_sleef(t), q)); + t = vd2sety_vd2_vd2_vd_sve_sleef(t, vldexp2_vd_vd_vi_sve_sleef(vd2gety_vd_vd2_sve_sleef(t), q)); + + t = vd2setx_vd2_vd2_vd_sve_sleef(t, vreinterpret_vd_vm_sve_sleef(vandnot_vm_vo64_vm_sve_sleef(vlt_vo_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(d), vcast_vd_d_sve_sleef(-1000)), vreinterpret_vm_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(t))))); + t = vd2sety_vd2_vd2_vd_sve_sleef(t, vreinterpret_vd_vm_sve_sleef(vandnot_vm_vo64_vm_sve_sleef(vlt_vo_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(d), vcast_vd_d_sve_sleef(-1000)), vreinterpret_vm_vd_sve_sleef(vd2gety_vd_vd2_sve_sleef(t))))); + + return t; +} + +SLEEF_INLINE SLEEF_CONST vdouble_sve_sleef Sleef_sinhdx_u10sve(vdouble_sve_sleef x) { + vdouble_sve_sleef y = vabs_vd_vd_sve_sleef(x); + vdouble2_sve_sleef d = expk2_sve_sleef(vcast_vd2_vd_vd_sve_sleef(y, vcast_vd_d_sve_sleef(0))); + d = ddsub_vd2_vd2_vd2_sve_sleef(d, ddrec_vd2_vd2_sve_sleef(d)); + y = vmul_vd_vd_vd_sve_sleef(vadd_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(d), vd2gety_vd_vd2_sve_sleef(d)), vcast_vd_d_sve_sleef(0.5)); + + y = vsel_vd_vo_vd_vd_sve_sleef(vor_vo_vo_vo_sve_sleef(vgt_vo_vd_vd_sve_sleef(vabs_vd_vd_sve_sleef(x), vcast_vd_d_sve_sleef(710)), visnan_vo_vd_sve_sleef(y)), vcast_vd_d_sve_sleef(__builtin_inf()), y); + y = vmulsign_vd_vd_vd_sve_sleef(y, x); + y = vreinterpret_vd_vm_sve_sleef(vor_vm_vo64_vm_sve_sleef(visnan_vo_vd_sve_sleef(x), vreinterpret_vm_vd_sve_sleef(y))); + + return y; +} + +SLEEF_INLINE SLEEF_CONST vdouble_sve_sleef Sleef_coshdx_u10sve(vdouble_sve_sleef x) { + vdouble_sve_sleef y = vabs_vd_vd_sve_sleef(x); + vdouble2_sve_sleef d = expk2_sve_sleef(vcast_vd2_vd_vd_sve_sleef(y, vcast_vd_d_sve_sleef(0))); + d = ddadd_vd2_vd2_vd2_sve_sleef(d, ddrec_vd2_vd2_sve_sleef(d)); + y = vmul_vd_vd_vd_sve_sleef(vadd_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(d), vd2gety_vd_vd2_sve_sleef(d)), vcast_vd_d_sve_sleef(0.5)); + + y = vsel_vd_vo_vd_vd_sve_sleef(vor_vo_vo_vo_sve_sleef(vgt_vo_vd_vd_sve_sleef(vabs_vd_vd_sve_sleef(x), vcast_vd_d_sve_sleef(710)), visnan_vo_vd_sve_sleef(y)), vcast_vd_d_sve_sleef(__builtin_inf()), y); + y = vreinterpret_vd_vm_sve_sleef(vor_vm_vo64_vm_sve_sleef(visnan_vo_vd_sve_sleef(x), vreinterpret_vm_vd_sve_sleef(y))); + + return y; +} + +SLEEF_INLINE SLEEF_CONST vdouble_sve_sleef Sleef_tanhdx_u10sve(vdouble_sve_sleef x) { + vdouble_sve_sleef y = vabs_vd_vd_sve_sleef(x); + vdouble2_sve_sleef d = expk2_sve_sleef(vcast_vd2_vd_vd_sve_sleef(y, vcast_vd_d_sve_sleef(0))); + vdouble2_sve_sleef e = ddrec_vd2_vd2_sve_sleef(d); + d = dddiv_vd2_vd2_vd2_sve_sleef(ddadd2_vd2_vd2_vd2_sve_sleef(d, ddneg_vd2_vd2_sve_sleef(e)), ddadd2_vd2_vd2_vd2_sve_sleef(d, e)); + y = vadd_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(d), vd2gety_vd_vd2_sve_sleef(d)); + + y = vsel_vd_vo_vd_vd_sve_sleef(vor_vo_vo_vo_sve_sleef(vgt_vo_vd_vd_sve_sleef(vabs_vd_vd_sve_sleef(x), vcast_vd_d_sve_sleef(18.714973875)), visnan_vo_vd_sve_sleef(y)), vcast_vd_d_sve_sleef(1.0), y); + y = vmulsign_vd_vd_vd_sve_sleef(y, x); + y = vreinterpret_vd_vm_sve_sleef(vor_vm_vo64_vm_sve_sleef(visnan_vo_vd_sve_sleef(x), vreinterpret_vm_vd_sve_sleef(y))); + + return y; +} + +SLEEF_INLINE SLEEF_CONST vdouble_sve_sleef Sleef_sinhdx_u35sve(vdouble_sve_sleef x) { + vdouble_sve_sleef e = expm1k_sve_sleef(vabs_vd_vd_sve_sleef(x)); + + vdouble_sve_sleef y = vdiv_vd_vd_vd_sve_sleef(vadd_vd_vd_vd_sve_sleef(e, vcast_vd_d_sve_sleef(2)), vadd_vd_vd_vd_sve_sleef(e, vcast_vd_d_sve_sleef(1))); + y = vmul_vd_vd_vd_sve_sleef(y, vmul_vd_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(0.5), e)); + + y = vsel_vd_vo_vd_vd_sve_sleef(vor_vo_vo_vo_sve_sleef(vgt_vo_vd_vd_sve_sleef(vabs_vd_vd_sve_sleef(x), vcast_vd_d_sve_sleef(709)), visnan_vo_vd_sve_sleef(y)), vcast_vd_d_sve_sleef(__builtin_inf()), y); + y = vmulsign_vd_vd_vd_sve_sleef(y, x); + y = vreinterpret_vd_vm_sve_sleef(vor_vm_vo64_vm_sve_sleef(visnan_vo_vd_sve_sleef(x), vreinterpret_vm_vd_sve_sleef(y))); + + return y; +} + +SLEEF_INLINE SLEEF_CONST vdouble_sve_sleef Sleef_coshdx_u35sve(vdouble_sve_sleef x) { + vdouble_sve_sleef e = Sleef_expdx_u10sve(vabs_vd_vd_sve_sleef(x)); + vdouble_sve_sleef y = vmla_vd_vd_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(0.5), e, vdiv_vd_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(0.5), e)); + + y = vsel_vd_vo_vd_vd_sve_sleef(vor_vo_vo_vo_sve_sleef(vgt_vo_vd_vd_sve_sleef(vabs_vd_vd_sve_sleef(x), vcast_vd_d_sve_sleef(709)), visnan_vo_vd_sve_sleef(y)), vcast_vd_d_sve_sleef(__builtin_inf()), y); + y = vreinterpret_vd_vm_sve_sleef(vor_vm_vo64_vm_sve_sleef(visnan_vo_vd_sve_sleef(x), vreinterpret_vm_vd_sve_sleef(y))); + + return y; +} + +SLEEF_INLINE SLEEF_CONST vdouble_sve_sleef Sleef_tanhdx_u35sve(vdouble_sve_sleef x) { + vdouble_sve_sleef d = expm1k_sve_sleef(vmul_vd_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(2), vabs_vd_vd_sve_sleef(x))); + vdouble_sve_sleef y = vdiv_vd_vd_vd_sve_sleef(d, vadd_vd_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(2), d)); + + y = vsel_vd_vo_vd_vd_sve_sleef(vor_vo_vo_vo_sve_sleef(vgt_vo_vd_vd_sve_sleef(vabs_vd_vd_sve_sleef(x), vcast_vd_d_sve_sleef(18.714973875)), visnan_vo_vd_sve_sleef(y)), vcast_vd_d_sve_sleef(1.0), y); + y = vmulsign_vd_vd_vd_sve_sleef(y, x); + y = vreinterpret_vd_vm_sve_sleef(vor_vm_vo64_vm_sve_sleef(visnan_vo_vd_sve_sleef(x), vreinterpret_vm_vd_sve_sleef(y))); + + return y; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_sve_sleef logk2_sve_sleef(vdouble2_sve_sleef d) { + vdouble2_sve_sleef x, x2, m, s; + vdouble_sve_sleef t; + vint_sve_sleef e; + + e = vilogbk_vi_vd_sve_sleef(vmul_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(d), vcast_vd_d_sve_sleef(1.0/0.75))); + + m = vd2setxy_vd2_vd_vd_sve_sleef(vldexp2_vd_vd_vi_sve_sleef(vd2getx_vd_vd2_sve_sleef(d), vneg_vi_vi_sve_sleef(e)), + vldexp2_vd_vd_vi_sve_sleef(vd2gety_vd_vd2_sve_sleef(d), vneg_vi_vi_sve_sleef(e))); + + x = dddiv_vd2_vd2_vd2_sve_sleef(ddadd2_vd2_vd2_vd_sve_sleef(m, vcast_vd_d_sve_sleef(-1)), ddadd2_vd2_vd2_vd_sve_sleef(m, vcast_vd_d_sve_sleef(1))); + x2 = ddsqu_vd2_vd2_sve_sleef(x); + + vdouble_sve_sleef x4 = vmul_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(x2), vd2getx_vd_vd2_sve_sleef(x2)), x8 = vmul_vd_vd_vd_sve_sleef(x4, x4); + t = vmla_vd_vd_vd_vd_sve_sleef((x8), (vmla_vd_vd_vd_vd_sve_sleef((x4), (vcast_vd_d_sve_sleef(0.13860436390467167910856)), (vmla_vd_vd_vd_vd_sve_sleef((vd2getx_vd_vd2_sve_sleef(x2)), (vcast_vd_d_sve_sleef(0.131699838841615374240845)), (vcast_vd_d_sve_sleef(0.153914168346271945653214)))))), (vmla_vd_vd_vd_vd_sve_sleef((x4), (vmla_vd_vd_vd_vd_sve_sleef((vd2getx_vd_vd2_sve_sleef(x2)), (vcast_vd_d_sve_sleef(0.181816523941564611721589)), (vcast_vd_d_sve_sleef(0.22222224632662035403996)))), (vmla_vd_vd_vd_vd_sve_sleef((vd2getx_vd_vd2_sve_sleef(x2)), (vcast_vd_d_sve_sleef(0.285714285511134091777308)), (vcast_vd_d_sve_sleef(0.400000000000914013309483))))))) + + ; + t = vmla_vd_vd_vd_vd_sve_sleef(t, vd2getx_vd_vd2_sve_sleef(x2), vcast_vd_d_sve_sleef(0.666666666666664853302393)); + + s = ddmul_vd2_vd2_vd_sve_sleef(vcast_vd2_d_d_sve_sleef(0.693147180559945286226764, 2.319046813846299558417771e-17), vcast_vd_vi_sve_sleef(e)); + s = ddadd_vd2_vd2_vd2_sve_sleef(s, ddscale_vd2_vd2_vd_sve_sleef(x, vcast_vd_d_sve_sleef(2))); + s = ddadd_vd2_vd2_vd2_sve_sleef(s, ddmul_vd2_vd2_vd_sve_sleef(ddmul_vd2_vd2_vd2_sve_sleef(x2, x), t)); + + return s; +} + +SLEEF_INLINE SLEEF_CONST vdouble_sve_sleef Sleef_asinhdx_u10sve(vdouble_sve_sleef x) { + vdouble_sve_sleef y = vabs_vd_vd_sve_sleef(x); + vopmask_sve_sleef o = vgt_vo_vd_vd_sve_sleef(y, vcast_vd_d_sve_sleef(1)); + vdouble2_sve_sleef d; + + d = vsel_vd2_vo_vd2_vd2_sve_sleef(o, ddrec_vd2_vd_sve_sleef(x), vcast_vd2_vd_vd_sve_sleef(y, vcast_vd_d_sve_sleef(0))); + d = ddsqrt_vd2_vd2_sve_sleef(ddadd2_vd2_vd2_vd_sve_sleef(ddsqu_vd2_vd2_sve_sleef(d), vcast_vd_d_sve_sleef(1))); + d = vsel_vd2_vo_vd2_vd2_sve_sleef(o, ddmul_vd2_vd2_vd_sve_sleef(d, y), d); + + d = logk2_sve_sleef(ddnormalize_vd2_vd2_sve_sleef(ddadd2_vd2_vd2_vd_sve_sleef(d, x))); + y = vadd_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(d), vd2gety_vd_vd2_sve_sleef(d)); + + y = vsel_vd_vo_vd_vd_sve_sleef(vor_vo_vo_vo_sve_sleef(vgt_vo_vd_vd_sve_sleef(vabs_vd_vd_sve_sleef(x), vcast_vd_d_sve_sleef(1.3407807929942596355e+154)), + visnan_vo_vd_sve_sleef(y)), + vmulsign_vd_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(__builtin_inf()), x), y); + + y = vreinterpret_vd_vm_sve_sleef(vor_vm_vo64_vm_sve_sleef(visnan_vo_vd_sve_sleef(x), vreinterpret_vm_vd_sve_sleef(y))); + y = vsel_vd_vo_vd_vd_sve_sleef(visnegzero_vo_vd_sve_sleef(x), vcast_vd_d_sve_sleef(-0.0), y); + + return y; +} + +SLEEF_INLINE SLEEF_CONST vdouble_sve_sleef Sleef_acoshdx_u10sve(vdouble_sve_sleef x) { + vdouble2_sve_sleef d = logk2_sve_sleef(ddadd2_vd2_vd2_vd_sve_sleef(ddmul_vd2_vd2_vd2_sve_sleef(ddsqrt_vd2_vd2_sve_sleef(ddadd2_vd2_vd_vd_sve_sleef(x, vcast_vd_d_sve_sleef(1))), ddsqrt_vd2_vd2_sve_sleef(ddadd2_vd2_vd_vd_sve_sleef(x, vcast_vd_d_sve_sleef(-1)))), x)); + vdouble_sve_sleef y = vadd_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(d), vd2gety_vd_vd2_sve_sleef(d)); + + y = vsel_vd_vo_vd_vd_sve_sleef(vor_vo_vo_vo_sve_sleef(vgt_vo_vd_vd_sve_sleef(vabs_vd_vd_sve_sleef(x), vcast_vd_d_sve_sleef(1.3407807929942596355e+154)), + visnan_vo_vd_sve_sleef(y)), + vcast_vd_d_sve_sleef(__builtin_inf()), y); + y = vreinterpret_vd_vm_sve_sleef(vandnot_vm_vo64_vm_sve_sleef(veq_vo_vd_vd_sve_sleef(x, vcast_vd_d_sve_sleef(1.0)), vreinterpret_vm_vd_sve_sleef(y))); + + y = vreinterpret_vd_vm_sve_sleef(vor_vm_vo64_vm_sve_sleef(vlt_vo_vd_vd_sve_sleef(x, vcast_vd_d_sve_sleef(1.0)), vreinterpret_vm_vd_sve_sleef(y))); + y = vreinterpret_vd_vm_sve_sleef(vor_vm_vo64_vm_sve_sleef(visnan_vo_vd_sve_sleef(x), vreinterpret_vm_vd_sve_sleef(y))); + + return y; +} + +SLEEF_INLINE SLEEF_CONST vdouble_sve_sleef Sleef_atanhdx_u10sve(vdouble_sve_sleef x) { + vdouble_sve_sleef y = vabs_vd_vd_sve_sleef(x); + vdouble2_sve_sleef d = logk2_sve_sleef(dddiv_vd2_vd2_vd2_sve_sleef(ddadd2_vd2_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(1), y), ddadd2_vd2_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(1), vneg_vd_vd_sve_sleef(y)))); + y = vreinterpret_vd_vm_sve_sleef(vor_vm_vo64_vm_sve_sleef(vgt_vo_vd_vd_sve_sleef(y, vcast_vd_d_sve_sleef(1.0)), vreinterpret_vm_vd_sve_sleef(vsel_vd_vo_vd_vd_sve_sleef(veq_vo_vd_vd_sve_sleef(y, vcast_vd_d_sve_sleef(1.0)), vcast_vd_d_sve_sleef(__builtin_inf()), vmul_vd_vd_vd_sve_sleef(vadd_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(d), vd2gety_vd_vd2_sve_sleef(d)), vcast_vd_d_sve_sleef(0.5)))))); + + y = vmulsign_vd_vd_vd_sve_sleef(y, x); + y = vreinterpret_vd_vm_sve_sleef(vor_vm_vo64_vm_sve_sleef(vor_vo_vo_vo_sve_sleef(visinf_vo_vd_sve_sleef(x), visnan_vo_vd_sve_sleef(y)), vreinterpret_vm_vd_sve_sleef(y))); + y = vreinterpret_vd_vm_sve_sleef(vor_vm_vo64_vm_sve_sleef(visnan_vo_vd_sve_sleef(x), vreinterpret_vm_vd_sve_sleef(y))); + + return y; +} + +SLEEF_INLINE SLEEF_CONST vdouble_sve_sleef Sleef_cbrtdx_u35sve(vdouble_sve_sleef d) { + vdouble_sve_sleef x, y, q = vcast_vd_d_sve_sleef(1.0); + vint_sve_sleef e, qu, re; + vdouble_sve_sleef t; + + e = vadd_vi_vi_vi_sve_sleef(vilogbk_vi_vd_sve_sleef(vabs_vd_vd_sve_sleef(d)), vcast_vi_i_sve_sleef(1)); + d = vldexp2_vd_vd_vi_sve_sleef(d, vneg_vi_vi_sve_sleef(e)); + + t = vadd_vd_vd_vd_sve_sleef(vcast_vd_vi_sve_sleef(e), vcast_vd_d_sve_sleef(6144)); + qu = vtruncate_vi_vd_sve_sleef(vmul_vd_vd_vd_sve_sleef(t, vcast_vd_d_sve_sleef(1.0/3.0))); + re = vtruncate_vi_vd_sve_sleef(vsub_vd_vd_vd_sve_sleef(t, vmul_vd_vd_vd_sve_sleef(vcast_vd_vi_sve_sleef(qu), vcast_vd_d_sve_sleef(3)))); + + q = vsel_vd_vo_vd_vd_sve_sleef(vcast_vo64_vo32_sve_sleef(veq_vo_vi_vi_sve_sleef(re, vcast_vi_i_sve_sleef(1))), vcast_vd_d_sve_sleef(1.2599210498948731647672106), q); + q = vsel_vd_vo_vd_vd_sve_sleef(vcast_vo64_vo32_sve_sleef(veq_vo_vi_vi_sve_sleef(re, vcast_vi_i_sve_sleef(2))), vcast_vd_d_sve_sleef(1.5874010519681994747517056), q); + q = vldexp2_vd_vd_vi_sve_sleef(q, vsub_vi_vi_vi_sve_sleef(qu, vcast_vi_i_sve_sleef(2048))); + + q = vmulsign_vd_vd_vd_sve_sleef(q, d); + + d = vabs_vd_vd_sve_sleef(d); + + x = vcast_vd_d_sve_sleef(-0.640245898480692909870982); + x = vmla_vd_vd_vd_vd_sve_sleef(x, d, vcast_vd_d_sve_sleef(2.96155103020039511818595)); + x = vmla_vd_vd_vd_vd_sve_sleef(x, d, vcast_vd_d_sve_sleef(-5.73353060922947843636166)); + x = vmla_vd_vd_vd_vd_sve_sleef(x, d, vcast_vd_d_sve_sleef(6.03990368989458747961407)); + x = vmla_vd_vd_vd_vd_sve_sleef(x, d, vcast_vd_d_sve_sleef(-3.85841935510444988821632)); + x = vmla_vd_vd_vd_vd_sve_sleef(x, d, vcast_vd_d_sve_sleef(2.2307275302496609725722)); + + y = vmul_vd_vd_vd_sve_sleef(x, x); y = vmul_vd_vd_vd_sve_sleef(y, y); x = vsub_vd_vd_vd_sve_sleef(x, vmul_vd_vd_vd_sve_sleef(vmlapn_vd_vd_vd_vd_sve_sleef(d, y, x), vcast_vd_d_sve_sleef(1.0 / 3.0))); + y = vmul_vd_vd_vd_sve_sleef(vmul_vd_vd_vd_sve_sleef(d, x), x); + y = vmul_vd_vd_vd_sve_sleef(vsub_vd_vd_vd_sve_sleef(y, vmul_vd_vd_vd_sve_sleef(vmul_vd_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(2.0 / 3.0), y), vmla_vd_vd_vd_vd_sve_sleef(y, x, vcast_vd_d_sve_sleef(-1.0)))), q); + + return y; +} + +SLEEF_INLINE SLEEF_CONST vdouble_sve_sleef Sleef_cbrtdx_u10sve(vdouble_sve_sleef d) { + vdouble_sve_sleef x, y, z, t; + vdouble2_sve_sleef q2 = vcast_vd2_d_d_sve_sleef(1, 0), u, v; + vint_sve_sleef e, qu, re; + + e = vadd_vi_vi_vi_sve_sleef(vilogbk_vi_vd_sve_sleef(vabs_vd_vd_sve_sleef(d)), vcast_vi_i_sve_sleef(1)); + d = vldexp2_vd_vd_vi_sve_sleef(d, vneg_vi_vi_sve_sleef(e)); + + t = vadd_vd_vd_vd_sve_sleef(vcast_vd_vi_sve_sleef(e), vcast_vd_d_sve_sleef(6144)); + qu = vtruncate_vi_vd_sve_sleef(vmul_vd_vd_vd_sve_sleef(t, vcast_vd_d_sve_sleef(1.0/3.0))); + re = vtruncate_vi_vd_sve_sleef(vsub_vd_vd_vd_sve_sleef(t, vmul_vd_vd_vd_sve_sleef(vcast_vd_vi_sve_sleef(qu), vcast_vd_d_sve_sleef(3)))); + + q2 = vsel_vd2_vo_vd2_vd2_sve_sleef(vcast_vo64_vo32_sve_sleef(veq_vo_vi_vi_sve_sleef(re, vcast_vi_i_sve_sleef(1))), vcast_vd2_d_d_sve_sleef(1.2599210498948731907, -2.5899333753005069177e-17), q2); + q2 = vsel_vd2_vo_vd2_vd2_sve_sleef(vcast_vo64_vo32_sve_sleef(veq_vo_vi_vi_sve_sleef(re, vcast_vi_i_sve_sleef(2))), vcast_vd2_d_d_sve_sleef(1.5874010519681995834, -1.0869008194197822986e-16), q2); + + q2 = vd2setxy_vd2_vd_vd_sve_sleef(vmulsign_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(q2), d), vmulsign_vd_vd_vd_sve_sleef(vd2gety_vd_vd2_sve_sleef(q2), d)); + d = vabs_vd_vd_sve_sleef(d); + + x = vcast_vd_d_sve_sleef(-0.640245898480692909870982); + x = vmla_vd_vd_vd_vd_sve_sleef(x, d, vcast_vd_d_sve_sleef(2.96155103020039511818595)); + x = vmla_vd_vd_vd_vd_sve_sleef(x, d, vcast_vd_d_sve_sleef(-5.73353060922947843636166)); + x = vmla_vd_vd_vd_vd_sve_sleef(x, d, vcast_vd_d_sve_sleef(6.03990368989458747961407)); + x = vmla_vd_vd_vd_vd_sve_sleef(x, d, vcast_vd_d_sve_sleef(-3.85841935510444988821632)); + x = vmla_vd_vd_vd_vd_sve_sleef(x, d, vcast_vd_d_sve_sleef(2.2307275302496609725722)); + + y = vmul_vd_vd_vd_sve_sleef(x, x); y = vmul_vd_vd_vd_sve_sleef(y, y); x = vsub_vd_vd_vd_sve_sleef(x, vmul_vd_vd_vd_sve_sleef(vmlapn_vd_vd_vd_vd_sve_sleef(d, y, x), vcast_vd_d_sve_sleef(1.0 / 3.0))); + + z = x; + + u = ddmul_vd2_vd_vd_sve_sleef(x, x); + u = ddmul_vd2_vd2_vd2_sve_sleef(u, u); + u = ddmul_vd2_vd2_vd_sve_sleef(u, d); + u = ddadd2_vd2_vd2_vd_sve_sleef(u, vneg_vd_vd_sve_sleef(x)); + y = vadd_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(u), vd2gety_vd_vd2_sve_sleef(u)); + + y = vmul_vd_vd_vd_sve_sleef(vmul_vd_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(-2.0 / 3.0), y), z); + v = ddadd2_vd2_vd2_vd_sve_sleef(ddmul_vd2_vd_vd_sve_sleef(z, z), y); + v = ddmul_vd2_vd2_vd_sve_sleef(v, d); + v = ddmul_vd2_vd2_vd2_sve_sleef(v, q2); + z = vldexp2_vd_vd_vi_sve_sleef(vadd_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(v), vd2gety_vd_vd2_sve_sleef(v)), vsub_vi_vi_vi_sve_sleef(qu, vcast_vi_i_sve_sleef(2048))); + + z = vsel_vd_vo_vd_vd_sve_sleef(visinf_vo_vd_sve_sleef(d), vmulsign_vd_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(__builtin_inf()), vd2getx_vd_vd2_sve_sleef(q2)), z); + z = vsel_vd_vo_vd_vd_sve_sleef(veq_vo_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(0)), vreinterpret_vd_vm_sve_sleef(vsignbit_vm_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(q2))), z); + + return z; +} + +SLEEF_INLINE SLEEF_CONST vdouble_sve_sleef Sleef_exp2dx_u10sve(vdouble_sve_sleef d) { + vdouble_sve_sleef u = vrint_vd_vd_sve_sleef(d), s; + vint_sve_sleef q = vrint_vi_vd_sve_sleef(u); + + s = vsub_vd_vd_vd_sve_sleef(d, u); + + vdouble_sve_sleef s2 = vmul_vd_vd_vd_sve_sleef(s, s), s4 = vmul_vd_vd_vd_sve_sleef(s2, s2), s8 = vmul_vd_vd_vd_sve_sleef(s4, s4); + u = vmla_vd_vd_vd_vd_sve_sleef((s8), (vmla_vd_vd_vd_vd_sve_sleef((s), (vcast_vd_d_sve_sleef(+0.4434359082926529454e-9)), (vcast_vd_d_sve_sleef(+0.7073164598085707425e-8)))), (vmla_vd_vd_vd_vd_sve_sleef((s4), (vmla_vd_vd_vd_vd_sve_sleef((s2), (vmla_vd_vd_vd_vd_sve_sleef((s), (vcast_vd_d_sve_sleef(+0.1017819260921760451e-6)), (vcast_vd_d_sve_sleef(+0.1321543872511327615e-5)))), (vmla_vd_vd_vd_vd_sve_sleef((s), (vcast_vd_d_sve_sleef(+0.1525273353517584730e-4)), (vcast_vd_d_sve_sleef(+0.1540353045101147808e-3)))))), (vmla_vd_vd_vd_vd_sve_sleef((s2), (vmla_vd_vd_vd_vd_sve_sleef((s), (vcast_vd_d_sve_sleef(+0.1333355814670499073e-2)), (vcast_vd_d_sve_sleef(+0.9618129107597600536e-2)))), (vmla_vd_vd_vd_vd_sve_sleef((s), (vcast_vd_d_sve_sleef(+0.5550410866482046596e-1)), (vcast_vd_d_sve_sleef(+0.2402265069591012214e+0))))))))) + + ; + u = vmla_vd_vd_vd_vd_sve_sleef(u, s, vcast_vd_d_sve_sleef(+0.6931471805599452862e+0)); + + u = vfma_vd_vd_vd_vd_sve_sleef(u, s, vcast_vd_d_sve_sleef(1)); + + u = vldexp2_vd_vd_vi_sve_sleef(u, q); + + u = vsel_vd_vo_vd_vd_sve_sleef(vge_vo_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(1024)), vcast_vd_d_sve_sleef(__builtin_inf()), u); + u = vreinterpret_vd_vm_sve_sleef(vandnot_vm_vo64_vm_sve_sleef(vlt_vo_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(-2000)), vreinterpret_vm_vd_sve_sleef(u))); + + return u; +} + +SLEEF_INLINE SLEEF_CONST vdouble_sve_sleef Sleef_exp2dx_u35sve(vdouble_sve_sleef d) { + vdouble_sve_sleef u = vrint_vd_vd_sve_sleef(d), s; + vint_sve_sleef q = vrint_vi_vd_sve_sleef(u); + + s = vsub_vd_vd_vd_sve_sleef(d, u); + + vdouble_sve_sleef s2 = vmul_vd_vd_vd_sve_sleef(s, s), s4 = vmul_vd_vd_vd_sve_sleef(s2, s2), s8 = vmul_vd_vd_vd_sve_sleef(s4, s4); + u = vmla_vd_vd_vd_vd_sve_sleef((s8), (vmla_vd_vd_vd_vd_sve_sleef((s), (vcast_vd_d_sve_sleef(+0.4434359082926529454e-9)), (vcast_vd_d_sve_sleef(+0.7073164598085707425e-8)))), (vmla_vd_vd_vd_vd_sve_sleef((s4), (vmla_vd_vd_vd_vd_sve_sleef((s2), (vmla_vd_vd_vd_vd_sve_sleef((s), (vcast_vd_d_sve_sleef(+0.1017819260921760451e-6)), (vcast_vd_d_sve_sleef(+0.1321543872511327615e-5)))), (vmla_vd_vd_vd_vd_sve_sleef((s), (vcast_vd_d_sve_sleef(+0.1525273353517584730e-4)), (vcast_vd_d_sve_sleef(+0.1540353045101147808e-3)))))), (vmla_vd_vd_vd_vd_sve_sleef((s2), (vmla_vd_vd_vd_vd_sve_sleef((s), (vcast_vd_d_sve_sleef(+0.1333355814670499073e-2)), (vcast_vd_d_sve_sleef(+0.9618129107597600536e-2)))), (vmla_vd_vd_vd_vd_sve_sleef((s), (vcast_vd_d_sve_sleef(+0.5550410866482046596e-1)), (vcast_vd_d_sve_sleef(+0.2402265069591012214e+0))))))))) + + ; + u = vmla_vd_vd_vd_vd_sve_sleef(u, s, vcast_vd_d_sve_sleef(+0.6931471805599452862e+0)); + + u = vmla_vd_vd_vd_vd_sve_sleef(u, s, vcast_vd_d_sve_sleef(1)); + + u = vldexp2_vd_vd_vi_sve_sleef(u, q); + + u = vsel_vd_vo_vd_vd_sve_sleef(vge_vo_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(1024)), vcast_vd_d_sve_sleef(__builtin_inf()), u); + u = vreinterpret_vd_vm_sve_sleef(vandnot_vm_vo64_vm_sve_sleef(vlt_vo_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(-2000)), vreinterpret_vm_vd_sve_sleef(u))); + + return u; +} + +SLEEF_INLINE SLEEF_CONST vdouble_sve_sleef Sleef_exp10dx_u10sve(vdouble_sve_sleef d) { + vdouble_sve_sleef u = vrint_vd_vd_sve_sleef(vmul_vd_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(3.3219280948873623478703194294893901758648313930))), s; + vint_sve_sleef q = vrint_vi_vd_sve_sleef(u); + + s = vmla_vd_vd_vd_vd_sve_sleef(u, vcast_vd_d_sve_sleef(-0.30102999566383914498), d); + s = vmla_vd_vd_vd_vd_sve_sleef(u, vcast_vd_d_sve_sleef(-1.4205023227266099418e-13), s); + + u = vcast_vd_d_sve_sleef(+0.2411463498334267652e-3); + u = vmla_vd_vd_vd_vd_sve_sleef(u, s, vcast_vd_d_sve_sleef(+0.1157488415217187375e-2)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, s, vcast_vd_d_sve_sleef(+0.5013975546789733659e-2)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, s, vcast_vd_d_sve_sleef(+0.1959762320720533080e-1)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, s, vcast_vd_d_sve_sleef(+0.6808936399446784138e-1)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, s, vcast_vd_d_sve_sleef(+0.2069958494722676234e+0)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, s, vcast_vd_d_sve_sleef(+0.5393829292058536229e+0)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, s, vcast_vd_d_sve_sleef(+0.1171255148908541655e+1)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, s, vcast_vd_d_sve_sleef(+0.2034678592293432953e+1)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, s, vcast_vd_d_sve_sleef(+0.2650949055239205876e+1)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, s, vcast_vd_d_sve_sleef(+0.2302585092994045901e+1)); + + u = vfma_vd_vd_vd_vd_sve_sleef(u, s, vcast_vd_d_sve_sleef(1)); + + u = vldexp2_vd_vd_vi_sve_sleef(u, q); + + u = vsel_vd_vo_vd_vd_sve_sleef(vgt_vo_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(308.25471555991671)), vcast_vd_d_sve_sleef(__builtin_inf()), u); + u = vreinterpret_vd_vm_sve_sleef(vandnot_vm_vo64_vm_sve_sleef(vlt_vo_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(-350)), vreinterpret_vm_vd_sve_sleef(u))); + + return u; +} + +SLEEF_INLINE SLEEF_CONST vdouble_sve_sleef Sleef_exp10dx_u35sve(vdouble_sve_sleef d) { + vdouble_sve_sleef u = vrint_vd_vd_sve_sleef(vmul_vd_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(3.3219280948873623478703194294893901758648313930))), s; + vint_sve_sleef q = vrint_vi_vd_sve_sleef(u); + + s = vmla_vd_vd_vd_vd_sve_sleef(u, vcast_vd_d_sve_sleef(-0.30102999566383914498), d); + s = vmla_vd_vd_vd_vd_sve_sleef(u, vcast_vd_d_sve_sleef(-1.4205023227266099418e-13), s); + + vdouble_sve_sleef s2 = vmul_vd_vd_vd_sve_sleef(s, s), s4 = vmul_vd_vd_vd_sve_sleef(s2, s2), s8 = vmul_vd_vd_vd_sve_sleef(s4, s4); + u = vmla_vd_vd_vd_vd_sve_sleef((s8), (vmla_vd_vd_vd_vd_sve_sleef((s2), (vcast_vd_d_sve_sleef(+0.2411463498334267652e-3)), (vmla_vd_vd_vd_vd_sve_sleef((s), (vcast_vd_d_sve_sleef(+0.1157488415217187375e-2)), (vcast_vd_d_sve_sleef(+0.5013975546789733659e-2)))))), (vmla_vd_vd_vd_vd_sve_sleef((s4), (vmla_vd_vd_vd_vd_sve_sleef((s2), (vmla_vd_vd_vd_vd_sve_sleef((s), (vcast_vd_d_sve_sleef(+0.1959762320720533080e-1)), (vcast_vd_d_sve_sleef(+0.6808936399446784138e-1)))), (vmla_vd_vd_vd_vd_sve_sleef((s), (vcast_vd_d_sve_sleef(+0.2069958494722676234e+0)), (vcast_vd_d_sve_sleef(+0.5393829292058536229e+0)))))), (vmla_vd_vd_vd_vd_sve_sleef((s2), (vmla_vd_vd_vd_vd_sve_sleef((s), (vcast_vd_d_sve_sleef(+0.1171255148908541655e+1)), (vcast_vd_d_sve_sleef(+0.2034678592293432953e+1)))), (vmla_vd_vd_vd_vd_sve_sleef((s), (vcast_vd_d_sve_sleef(+0.2650949055239205876e+1)), (vcast_vd_d_sve_sleef(+0.2302585092994045901e+1))))))))) + + ; + + u = vmla_vd_vd_vd_vd_sve_sleef(u, s, vcast_vd_d_sve_sleef(1)); + + u = vldexp2_vd_vd_vi_sve_sleef(u, q); + + u = vsel_vd_vo_vd_vd_sve_sleef(vgt_vo_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(308.25471555991671)), vcast_vd_d_sve_sleef(__builtin_inf()), u); + u = vreinterpret_vd_vm_sve_sleef(vandnot_vm_vo64_vm_sve_sleef(vlt_vo_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(-350)), vreinterpret_vm_vd_sve_sleef(u))); + + return u; +} + +SLEEF_INLINE SLEEF_CONST vdouble_sve_sleef Sleef_expm1dx_u10sve(vdouble_sve_sleef a) { + vdouble2_sve_sleef d = ddadd2_vd2_vd2_vd_sve_sleef(expk2_sve_sleef(vcast_vd2_vd_vd_sve_sleef(a, vcast_vd_d_sve_sleef(0))), vcast_vd_d_sve_sleef(-1.0)); + vdouble_sve_sleef x = vadd_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(d), vd2gety_vd_vd2_sve_sleef(d)); + x = vsel_vd_vo_vd_vd_sve_sleef(vgt_vo_vd_vd_sve_sleef(a, vcast_vd_d_sve_sleef(709.782712893383996732223)), vcast_vd_d_sve_sleef(__builtin_inf()), x); + x = vsel_vd_vo_vd_vd_sve_sleef(vlt_vo_vd_vd_sve_sleef(a, vcast_vd_d_sve_sleef(-36.736800569677101399113302437)), vcast_vd_d_sve_sleef(-1), x); + x = vsel_vd_vo_vd_vd_sve_sleef(visnegzero_vo_vd_sve_sleef(a), vcast_vd_d_sve_sleef(-0.0), x); + return x; +} + +SLEEF_INLINE SLEEF_CONST vdouble_sve_sleef Sleef_log10dx_u10sve(vdouble_sve_sleef d) { + vdouble2_sve_sleef x; + vdouble_sve_sleef t, m, x2; + + vopmask_sve_sleef o = vlt_vo_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(0x1p-1022)); + d = vsel_vd_vo_vd_vd_sve_sleef(o, vmul_vd_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef((double)(INT64_C(1) << 32) * (double)(INT64_C(1) << 32))), d); + vint_sve_sleef e = vilogb2k_vi_vd_sve_sleef(vmul_vd_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(1.0/0.75))); + m = vldexp3_vd_vd_vi_sve_sleef(d, vneg_vi_vi_sve_sleef(e)); + e = vsel_vi_vo_vi_vi_sve_sleef(vcast_vo32_vo64_sve_sleef(o), vsub_vi_vi_vi_sve_sleef(e, vcast_vi_i_sve_sleef(64)), e); + + x = dddiv_vd2_vd2_vd2_sve_sleef(ddadd2_vd2_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(-1), m), ddadd2_vd2_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(1), m)); + x2 = vmul_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(x), vd2getx_vd_vd2_sve_sleef(x)); + + vdouble_sve_sleef x4 = vmul_vd_vd_vd_sve_sleef(x2, x2), x8 = vmul_vd_vd_vd_sve_sleef(x4, x4); + t = vmla_vd_vd_vd_vd_sve_sleef((x8), (vmla_vd_vd_vd_vd_sve_sleef((x4), (vcast_vd_d_sve_sleef(+0.6653725819576758460e-1)), (vmla_vd_vd_vd_vd_sve_sleef((x2), (vcast_vd_d_sve_sleef(+0.6625722782820833712e-1)), (vcast_vd_d_sve_sleef(+0.7898105214313944078e-1)))))), (vmla_vd_vd_vd_vd_sve_sleef((x4), (vmla_vd_vd_vd_vd_sve_sleef((x2), (vcast_vd_d_sve_sleef(+0.9650955035715275132e-1)), (vcast_vd_d_sve_sleef(+0.1240841409721444993e+0)))), (vmla_vd_vd_vd_vd_sve_sleef((x2), (vcast_vd_d_sve_sleef(+0.1737177927454605086e+0)), (vcast_vd_d_sve_sleef(+0.2895296546021972617e+0))))))) + + ; + + vdouble2_sve_sleef s = ddmul_vd2_vd2_vd_sve_sleef(vcast_vd2_d_d_sve_sleef(0.30102999566398119802, -2.803728127785170339e-18), vcast_vd_vi_sve_sleef(e)); + + s = ddadd_vd2_vd2_vd2_sve_sleef(s, ddmul_vd2_vd2_vd2_sve_sleef(x, vcast_vd2_d_d_sve_sleef(0.86858896380650363334, 1.1430059694096389311e-17))); + s = ddadd_vd2_vd2_vd_sve_sleef(s, vmul_vd_vd_vd_sve_sleef(vmul_vd_vd_vd_sve_sleef(x2, vd2getx_vd_vd2_sve_sleef(x)), t)); + + vdouble_sve_sleef r = vadd_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(s), vd2gety_vd_vd2_sve_sleef(s)); + + r = vsel_vd_vo_vd_vd_sve_sleef(vispinf_vo_vd_sve_sleef(d), vcast_vd_d_sve_sleef(__builtin_inf()), r); + r = vsel_vd_vo_vd_vd_sve_sleef(vor_vo_vo_vo_sve_sleef(vlt_vo_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(0)), visnan_vo_vd_sve_sleef(d)), vcast_vd_d_sve_sleef(__builtin_nan("")), r); + r = vsel_vd_vo_vd_vd_sve_sleef(veq_vo_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(0)), vcast_vd_d_sve_sleef(-__builtin_inf()), r); + + return r; +} + +SLEEF_INLINE SLEEF_CONST vdouble_sve_sleef Sleef_log2dx_u10sve(vdouble_sve_sleef d) { + vdouble2_sve_sleef x; + vdouble_sve_sleef t, m, x2; + + vopmask_sve_sleef o = vlt_vo_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(0x1p-1022)); + d = vsel_vd_vo_vd_vd_sve_sleef(o, vmul_vd_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef((double)(INT64_C(1) << 32) * (double)(INT64_C(1) << 32))), d); + vint_sve_sleef e = vilogb2k_vi_vd_sve_sleef(vmul_vd_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(1.0/0.75))); + m = vldexp3_vd_vd_vi_sve_sleef(d, vneg_vi_vi_sve_sleef(e)); + e = vsel_vi_vo_vi_vi_sve_sleef(vcast_vo32_vo64_sve_sleef(o), vsub_vi_vi_vi_sve_sleef(e, vcast_vi_i_sve_sleef(64)), e); + + x = dddiv_vd2_vd2_vd2_sve_sleef(ddadd2_vd2_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(-1), m), ddadd2_vd2_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(1), m)); + x2 = vmul_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(x), vd2getx_vd_vd2_sve_sleef(x)); + + vdouble_sve_sleef x4 = vmul_vd_vd_vd_sve_sleef(x2, x2), x8 = vmul_vd_vd_vd_sve_sleef(x4, x4); + t = vmla_vd_vd_vd_vd_sve_sleef((x8), (vmla_vd_vd_vd_vd_sve_sleef((x4), (vcast_vd_d_sve_sleef(+0.2211941750456081490e+0)), (vmla_vd_vd_vd_vd_sve_sleef((x2), (vcast_vd_d_sve_sleef(+0.2200768693152277689e+0)), (vcast_vd_d_sve_sleef(+0.2623708057488514656e+0)))))), (vmla_vd_vd_vd_vd_sve_sleef((x4), (vmla_vd_vd_vd_vd_sve_sleef((x2), (vcast_vd_d_sve_sleef(+0.3205977477944495502e+0)), (vcast_vd_d_sve_sleef(+0.4121985945485324709e+0)))), (vmla_vd_vd_vd_vd_sve_sleef((x2), (vcast_vd_d_sve_sleef(+0.5770780162997058982e+0)), (vcast_vd_d_sve_sleef(+0.96179669392608091449))))))) + + ; + + vdouble2_sve_sleef s = ddadd2_vd2_vd_vd2_sve_sleef(vcast_vd_vi_sve_sleef(e), + ddmul_vd2_vd2_vd2_sve_sleef(x, vcast_vd2_d_d_sve_sleef(2.885390081777926774, 6.0561604995516736434e-18))); + + s = ddadd2_vd2_vd2_vd_sve_sleef(s, vmul_vd_vd_vd_sve_sleef(vmul_vd_vd_vd_sve_sleef(x2, vd2getx_vd_vd2_sve_sleef(x)), t)); + + vdouble_sve_sleef r = vadd_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(s), vd2gety_vd_vd2_sve_sleef(s)); + + r = vsel_vd_vo_vd_vd_sve_sleef(vispinf_vo_vd_sve_sleef(d), vcast_vd_d_sve_sleef(__builtin_inf()), r); + r = vsel_vd_vo_vd_vd_sve_sleef(vor_vo_vo_vo_sve_sleef(vlt_vo_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(0)), visnan_vo_vd_sve_sleef(d)), vcast_vd_d_sve_sleef(__builtin_nan("")), r); + r = vsel_vd_vo_vd_vd_sve_sleef(veq_vo_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(0)), vcast_vd_d_sve_sleef(-__builtin_inf()), r); + + return r; +} + +SLEEF_INLINE SLEEF_CONST vdouble_sve_sleef Sleef_log2dx_u35sve(vdouble_sve_sleef d) { + vdouble_sve_sleef m, t, x, x2; + + vopmask_sve_sleef o = vlt_vo_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(0x1p-1022)); + d = vsel_vd_vo_vd_vd_sve_sleef(o, vmul_vd_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef((double)(INT64_C(1) << 32) * (double)(INT64_C(1) << 32))), d); + vint_sve_sleef e = vilogb2k_vi_vd_sve_sleef(vmul_vd_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(1.0/0.75))); + m = vldexp3_vd_vd_vi_sve_sleef(d, vneg_vi_vi_sve_sleef(e)); + e = vsel_vi_vo_vi_vi_sve_sleef(vcast_vo32_vo64_sve_sleef(o), vsub_vi_vi_vi_sve_sleef(e, vcast_vi_i_sve_sleef(64)), e); + + x = vdiv_vd_vd_vd_sve_sleef(vsub_vd_vd_vd_sve_sleef(m, vcast_vd_d_sve_sleef(1)), vadd_vd_vd_vd_sve_sleef(m, vcast_vd_d_sve_sleef(1))); + x2 = vmul_vd_vd_vd_sve_sleef(x, x); + + t = vcast_vd_d_sve_sleef(+0.2211941750456081490e+0); + t = vmla_vd_vd_vd_vd_sve_sleef(t, x2, vcast_vd_d_sve_sleef(+0.2200768693152277689e+0)); + t = vmla_vd_vd_vd_vd_sve_sleef(t, x2, vcast_vd_d_sve_sleef(+0.2623708057488514656e+0)); + t = vmla_vd_vd_vd_vd_sve_sleef(t, x2, vcast_vd_d_sve_sleef(+0.3205977477944495502e+0)); + t = vmla_vd_vd_vd_vd_sve_sleef(t, x2, vcast_vd_d_sve_sleef(+0.4121985945485324709e+0)); + t = vmla_vd_vd_vd_vd_sve_sleef(t, x2, vcast_vd_d_sve_sleef(+0.5770780162997058982e+0)); + t = vmla_vd_vd_vd_vd_sve_sleef(t, x2, vcast_vd_d_sve_sleef(+0.96179669392608091449 )); + + vdouble2_sve_sleef s = ddadd_vd2_vd_vd2_sve_sleef(vcast_vd_vi_sve_sleef(e), + ddmul_vd2_vd_vd_sve_sleef(x, vcast_vd_d_sve_sleef(2.885390081777926774))); + + vdouble_sve_sleef r = vmla_vd_vd_vd_vd_sve_sleef(t, vmul_vd_vd_vd_sve_sleef(x, x2), vadd_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(s), vd2gety_vd_vd2_sve_sleef(s))); + + r = vsel_vd_vo_vd_vd_sve_sleef(vispinf_vo_vd_sve_sleef(d), vcast_vd_d_sve_sleef(__builtin_inf()), r); + r = vsel_vd_vo_vd_vd_sve_sleef(vor_vo_vo_vo_sve_sleef(vlt_vo_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(0)), visnan_vo_vd_sve_sleef(d)), vcast_vd_d_sve_sleef(__builtin_nan("")), r); + r = vsel_vd_vo_vd_vd_sve_sleef(veq_vo_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(0)), vcast_vd_d_sve_sleef(-__builtin_inf()), r); + + return r; +} + +SLEEF_INLINE SLEEF_CONST vdouble_sve_sleef Sleef_log1pdx_u10sve(vdouble_sve_sleef d) { + vdouble2_sve_sleef x; + vdouble_sve_sleef t, m, x2; + + vdouble_sve_sleef dp1 = vadd_vd_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(1)); + + vopmask_sve_sleef o = vlt_vo_vd_vd_sve_sleef(dp1, vcast_vd_d_sve_sleef(0x1p-1022)); + dp1 = vsel_vd_vo_vd_vd_sve_sleef(o, vmul_vd_vd_vd_sve_sleef(dp1, vcast_vd_d_sve_sleef((double)(INT64_C(1) << 32) * (double)(INT64_C(1) << 32))), dp1); + vint_sve_sleef e = vilogb2k_vi_vd_sve_sleef(vmul_vd_vd_vd_sve_sleef(dp1, vcast_vd_d_sve_sleef(1.0/0.75))); + t = vldexp3_vd_vd_vi_sve_sleef(vcast_vd_d_sve_sleef(1), vneg_vi_vi_sve_sleef(e)); + m = vmla_vd_vd_vd_vd_sve_sleef(d, t, vsub_vd_vd_vd_sve_sleef(t, vcast_vd_d_sve_sleef(1))); + e = vsel_vi_vo_vi_vi_sve_sleef(vcast_vo32_vo64_sve_sleef(o), vsub_vi_vi_vi_sve_sleef(e, vcast_vi_i_sve_sleef(64)), e); + vdouble2_sve_sleef s = ddmul_vd2_vd2_vd_sve_sleef(vcast_vd2_d_d_sve_sleef(0.693147180559945286226764, 2.319046813846299558417771e-17), vcast_vd_vi_sve_sleef(e)); + + x = dddiv_vd2_vd2_vd2_sve_sleef(vcast_vd2_vd_vd_sve_sleef(m, vcast_vd_d_sve_sleef(0)), ddadd_vd2_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(2), m)); + x2 = vmul_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(x), vd2getx_vd_vd2_sve_sleef(x)); + + vdouble_sve_sleef x4 = vmul_vd_vd_vd_sve_sleef(x2, x2), x8 = vmul_vd_vd_vd_sve_sleef(x4, x4); + t = vmla_vd_vd_vd_vd_sve_sleef((x8), (vmla_vd_vd_vd_vd_sve_sleef((x4), (vcast_vd_d_sve_sleef(0.1532076988502701353e+0)), (vmla_vd_vd_vd_vd_sve_sleef((x2), (vcast_vd_d_sve_sleef(0.1525629051003428716e+0)), (vcast_vd_d_sve_sleef(0.1818605932937785996e+0)))))), (vmla_vd_vd_vd_vd_sve_sleef((x4), (vmla_vd_vd_vd_vd_sve_sleef((x2), (vcast_vd_d_sve_sleef(0.2222214519839380009e+0)), (vcast_vd_d_sve_sleef(0.2857142932794299317e+0)))), (vmla_vd_vd_vd_vd_sve_sleef((x2), (vcast_vd_d_sve_sleef(0.3999999999635251990e+0)), (vcast_vd_d_sve_sleef(0.6666666666667333541e+0))))))) + + ; + + s = ddadd_vd2_vd2_vd2_sve_sleef(s, ddscale_vd2_vd2_vd_sve_sleef(x, vcast_vd_d_sve_sleef(2))); + s = ddadd_vd2_vd2_vd_sve_sleef(s, vmul_vd_vd_vd_sve_sleef(vmul_vd_vd_vd_sve_sleef(x2, vd2getx_vd_vd2_sve_sleef(x)), t)); + + vdouble_sve_sleef r = vadd_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(s), vd2gety_vd_vd2_sve_sleef(s)); + + r = vsel_vd_vo_vd_vd_sve_sleef(vgt_vo_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(1e+307)), vcast_vd_d_sve_sleef(__builtin_inf()), r); + r = vsel_vd_vo_vd_vd_sve_sleef(vor_vo_vo_vo_sve_sleef(vlt_vo_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(-1)), visnan_vo_vd_sve_sleef(d)), vcast_vd_d_sve_sleef(__builtin_nan("")), r); + r = vsel_vd_vo_vd_vd_sve_sleef(veq_vo_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(-1)), vcast_vd_d_sve_sleef(-__builtin_inf()), r); + r = vsel_vd_vo_vd_vd_sve_sleef(visnegzero_vo_vd_sve_sleef(d), vcast_vd_d_sve_sleef(-0.0), r); + + return r; +} + +SLEEF_INLINE SLEEF_CONST vdouble_sve_sleef Sleef_fabsdx_sve(vdouble_sve_sleef x) { return vabs_vd_vd_sve_sleef(x); } + +SLEEF_INLINE SLEEF_CONST vdouble_sve_sleef Sleef_copysigndx_sve(vdouble_sve_sleef x, vdouble_sve_sleef y) { return vcopysign_vd_vd_vd_sve_sleef(x, y); } + +SLEEF_INLINE SLEEF_CONST vdouble_sve_sleef Sleef_fmaxdx_sve(vdouble_sve_sleef x, vdouble_sve_sleef y) { + + return vsel_vd_vo_vd_vd_sve_sleef(visnan_vo_vd_sve_sleef(y), x, vsel_vd_vo_vd_vd_sve_sleef(vgt_vo_vd_vd_sve_sleef(x, y), x, y)); + +} + +SLEEF_INLINE SLEEF_CONST vdouble_sve_sleef Sleef_fmindx_sve(vdouble_sve_sleef x, vdouble_sve_sleef y) { + + return vsel_vd_vo_vd_vd_sve_sleef(visnan_vo_vd_sve_sleef(y), x, vsel_vd_vo_vd_vd_sve_sleef(vgt_vo_vd_vd_sve_sleef(y, x), x, y)); + +} + +SLEEF_INLINE SLEEF_CONST vdouble_sve_sleef Sleef_fdimdx_sve(vdouble_sve_sleef x, vdouble_sve_sleef y) { + vdouble_sve_sleef ret = vsub_vd_vd_vd_sve_sleef(x, y); + ret = vsel_vd_vo_vd_vd_sve_sleef(vor_vo_vo_vo_sve_sleef(vlt_vo_vd_vd_sve_sleef(ret, vcast_vd_d_sve_sleef(0)), veq_vo_vd_vd_sve_sleef(x, y)), vcast_vd_d_sve_sleef(0), ret); + return ret; +} + +SLEEF_INLINE SLEEF_CONST vdouble_sve_sleef Sleef_truncdx_sve(vdouble_sve_sleef x) { return vtruncate2_vd_vd_sve_sleef_sve_sleef(x); } +SLEEF_INLINE SLEEF_CONST vdouble_sve_sleef Sleef_floordx_sve(vdouble_sve_sleef x) { return vfloor2_vd_vd_sve_sleef(x); } +SLEEF_INLINE SLEEF_CONST vdouble_sve_sleef Sleef_ceildx_sve(vdouble_sve_sleef x) { return vceil2_vd_vd_sve_sleef(x); } +SLEEF_INLINE SLEEF_CONST vdouble_sve_sleef Sleef_rounddx_sve(vdouble_sve_sleef x) { return vround2_vd_vd_sve_sleef(x); } +SLEEF_INLINE SLEEF_CONST vdouble_sve_sleef Sleef_rintdx_sve(vdouble_sve_sleef x) { return vrint2_vd_vd_sve_sleef(x); } + +SLEEF_INLINE SLEEF_CONST vdouble_sve_sleef Sleef_nextafterdx_sve(vdouble_sve_sleef x, vdouble_sve_sleef y) { + x = vsel_vd_vo_vd_vd_sve_sleef(veq_vo_vd_vd_sve_sleef(x, vcast_vd_d_sve_sleef(0)), vmulsign_vd_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(0), y), x); + vmask_sve_sleef xi2 = vreinterpret_vm_vd_sve_sleef(x); + vopmask_sve_sleef c = vxor_vo_vo_vo_sve_sleef(vsignbit_vo_vd_sve_sleef(x), vge_vo_vd_vd_sve_sleef(y, x)); + + xi2 = vsel_vm_vo64_vm_vm_sve_sleef(c, vneg64_vm_vm_sve_sleef(vxor_vm_vm_vm_sve_sleef(xi2, vcast_vm_i_i_sve_sleef((int)(1U << 31), 0))), xi2); + + xi2 = vsel_vm_vo64_vm_vm_sve_sleef(vneq_vo_vd_vd_sve_sleef(x, y), vsub64_vm_vm_vm_sve_sleef(xi2, vcast_vm_i_i_sve_sleef(0, 1)), xi2); + + xi2 = vsel_vm_vo64_vm_vm_sve_sleef(c, vneg64_vm_vm_sve_sleef(vxor_vm_vm_vm_sve_sleef(xi2, vcast_vm_i_i_sve_sleef((int)(1U << 31), 0))), xi2); + + vdouble_sve_sleef ret = vreinterpret_vd_vm_sve_sleef(xi2); + + ret = vsel_vd_vo_vd_vd_sve_sleef(vand_vo_vo_vo_sve_sleef(veq_vo_vd_vd_sve_sleef(ret, vcast_vd_d_sve_sleef(0)), vneq_vo_vd_vd_sve_sleef(x, vcast_vd_d_sve_sleef(0))), + vmulsign_vd_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(0), x), ret); + + ret = vsel_vd_vo_vd_vd_sve_sleef(vand_vo_vo_vo_sve_sleef(veq_vo_vd_vd_sve_sleef(x, vcast_vd_d_sve_sleef(0)), veq_vo_vd_vd_sve_sleef(y, vcast_vd_d_sve_sleef(0))), y, ret); + + ret = vsel_vd_vo_vd_vd_sve_sleef(vor_vo_vo_vo_sve_sleef(visnan_vo_vd_sve_sleef(x), visnan_vo_vd_sve_sleef(y)), vcast_vd_d_sve_sleef(__builtin_nan("")), ret); + + return ret; +} + +SLEEF_INLINE SLEEF_CONST vdouble_sve_sleef Sleef_frfrexpdx_sve(vdouble_sve_sleef x) { + x = vsel_vd_vo_vd_vd_sve_sleef(vlt_vo_vd_vd_sve_sleef(vabs_vd_vd_sve_sleef(x), vcast_vd_d_sve_sleef(0x1p-1022)), vmul_vd_vd_vd_sve_sleef(x, vcast_vd_d_sve_sleef(UINT64_C(1) << 63)), x); + + vmask_sve_sleef xm = vreinterpret_vm_vd_sve_sleef(x); + xm = vand_vm_vm_vm_sve_sleef(xm, vcast_vm_i64_sve_sleef(~INT64_C(0x7ff0000000000000))); + xm = vor_vm_vm_vm_sve_sleef (xm, vcast_vm_i64_sve_sleef( INT64_C(0x3fe0000000000000))); + + vdouble_sve_sleef ret = vreinterpret_vd_vm_sve_sleef(xm); + + ret = vsel_vd_vo_vd_vd_sve_sleef(visinf_vo_vd_sve_sleef(x), vmulsign_vd_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(__builtin_inf()), x), ret); + ret = vsel_vd_vo_vd_vd_sve_sleef(veq_vo_vd_vd_sve_sleef(x, vcast_vd_d_sve_sleef(0)), x, ret); + + return ret; +} + +SLEEF_INLINE SLEEF_CONST vint_sve_sleef Sleef_expfrexpdx_sve(vdouble_sve_sleef x) { + x = vsel_vd_vo_vd_vd_sve_sleef(vlt_vo_vd_vd_sve_sleef(vabs_vd_vd_sve_sleef(x), vcast_vd_d_sve_sleef(0x1p-1022)), vmul_vd_vd_vd_sve_sleef(x, vcast_vd_d_sve_sleef(UINT64_C(1) << 63)), x); + + vint_sve_sleef ret = vcastu_vi_vm_sve_sleef(vreinterpret_vm_vd_sve_sleef(x)); + ret = vsub_vi_vi_vi_sve_sleef(vand_vi_vi_vi_sve_sleef(vsrl_vi_vi_i_sve_sleef(ret, 20), vcast_vi_i_sve_sleef(0x7ff)), vcast_vi_i_sve_sleef(0x3fe)); + + ret = vsel_vi_vo_vi_vi_sve_sleef(vor_vo_vo_vo_sve_sleef(vor_vo_vo_vo_sve_sleef(veq_vo_vd_vd_sve_sleef(x, vcast_vd_d_sve_sleef(0)), visnan_vo_vd_sve_sleef(x)), visinf_vo_vd_sve_sleef(x)), vcast_vi_i_sve_sleef(0), ret); + + return ret; +} + +SLEEF_INLINE SLEEF_CONST vdouble_sve_sleef Sleef_fmadx_sve(vdouble_sve_sleef x, vdouble_sve_sleef y, vdouble_sve_sleef z) { + + return vfma_vd_vd_vd_vd_sve_sleef(x, y, z); + +} + +SLEEF_INLINE SLEEF_CONST vdouble_sve_sleef Sleef_sqrtdx_u05sve(vdouble_sve_sleef d) { + + vdouble_sve_sleef q, w, x, y, z; + + d = vsel_vd_vo_vd_vd_sve_sleef(vlt_vo_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(0)), vcast_vd_d_sve_sleef(__builtin_nan("")), d); + + vopmask_sve_sleef o = vlt_vo_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(8.636168555094445E-78)); + d = vsel_vd_vo_vd_vd_sve_sleef(o, vmul_vd_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(1.157920892373162E77)), d); + q = vsel_vd_vo_vd_vd_sve_sleef(o, vcast_vd_d_sve_sleef(2.9387358770557188E-39), vcast_vd_d_sve_sleef(1)); + + y = vreinterpret_vd_vm_sve_sleef(vsub64_vm_vm_vm_sve_sleef(vcast_vm_i_i_sve_sleef(0x5fe6ec85, 0xe7de30da), svreinterpret_s32_u64(svlsr_n_u64_x(svptrue_b8(), svreinterpret_u64_s32(vreinterpret_vm_vd_sve_sleef(d)), 1)))); + + x = vmul_vd_vd_vd_sve_sleef(d, y); w = vmul_vd_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(0.5), y); + y = vfmanp_vd_vd_vd_vd_sve_sleef(x, w, vcast_vd_d_sve_sleef(0.5)); + x = vfma_vd_vd_vd_vd_sve_sleef(x, y, x); w = vfma_vd_vd_vd_vd_sve_sleef(w, y, w); + y = vfmanp_vd_vd_vd_vd_sve_sleef(x, w, vcast_vd_d_sve_sleef(0.5)); + x = vfma_vd_vd_vd_vd_sve_sleef(x, y, x); w = vfma_vd_vd_vd_vd_sve_sleef(w, y, w); + y = vfmanp_vd_vd_vd_vd_sve_sleef(x, w, vcast_vd_d_sve_sleef(0.5)); + x = vfma_vd_vd_vd_vd_sve_sleef(x, y, x); w = vfma_vd_vd_vd_vd_sve_sleef(w, y, w); + + y = vfmanp_vd_vd_vd_vd_sve_sleef(x, w, vcast_vd_d_sve_sleef(1.5)); w = vadd_vd_vd_vd_sve_sleef(w, w); + w = vmul_vd_vd_vd_sve_sleef(w, y); + x = vmul_vd_vd_vd_sve_sleef(w, d); + y = vfmapn_vd_vd_vd_vd_sve_sleef(w, d, x); z = vfmanp_vd_vd_vd_vd_sve_sleef(w, x, vcast_vd_d_sve_sleef(1)); + + z = vfmanp_vd_vd_vd_vd_sve_sleef(w, y, z); w = vmul_vd_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(0.5), x); + w = vfma_vd_vd_vd_vd_sve_sleef(w, z, y); + w = vadd_vd_vd_vd_sve_sleef(w, x); + + w = vmul_vd_vd_vd_sve_sleef(w, q); + + w = vsel_vd_vo_vd_vd_sve_sleef(vor_vo_vo_vo_sve_sleef(veq_vo_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(0)), + veq_vo_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(__builtin_inf()))), d, w); + + w = vsel_vd_vo_vd_vd_sve_sleef(vlt_vo_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(0)), vcast_vd_d_sve_sleef(__builtin_nan("")), w); + + return w; + +} + +SLEEF_INLINE SLEEF_CONST vdouble_sve_sleef Sleef_sqrtdx_sve(vdouble_sve_sleef d) { + + return vsqrt_vd_vd_sve_sleef(d); + +} + +SLEEF_INLINE SLEEF_CONST vdouble_sve_sleef Sleef_sqrtdx_u35sve(vdouble_sve_sleef d) { return Sleef_sqrtdx_u05sve(d); } + +SLEEF_INLINE SLEEF_CONST vdouble_sve_sleef Sleef_hypotdx_u05sve(vdouble_sve_sleef x, vdouble_sve_sleef y) { + x = vabs_vd_vd_sve_sleef(x); + y = vabs_vd_vd_sve_sleef(y); + vdouble_sve_sleef min = vmin_vd_vd_vd_sve_sleef(x, y), n = min; + vdouble_sve_sleef max = vmax_vd_vd_vd_sve_sleef(x, y), d = max; + + vopmask_sve_sleef o = vlt_vo_vd_vd_sve_sleef(max, vcast_vd_d_sve_sleef(0x1p-1022)); + n = vsel_vd_vo_vd_vd_sve_sleef(o, vmul_vd_vd_vd_sve_sleef(n, vcast_vd_d_sve_sleef(UINT64_C(1) << 54)), n); + d = vsel_vd_vo_vd_vd_sve_sleef(o, vmul_vd_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(UINT64_C(1) << 54)), d); + + vdouble2_sve_sleef t = dddiv_vd2_vd2_vd2_sve_sleef(vcast_vd2_vd_vd_sve_sleef(n, vcast_vd_d_sve_sleef(0)), vcast_vd2_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(0))); + t = ddmul_vd2_vd2_vd_sve_sleef(ddsqrt_vd2_vd2_sve_sleef(ddadd2_vd2_vd2_vd_sve_sleef(ddsqu_vd2_vd2_sve_sleef(t), vcast_vd_d_sve_sleef(1))), max); + vdouble_sve_sleef ret = vadd_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(t), vd2gety_vd_vd2_sve_sleef(t)); + ret = vsel_vd_vo_vd_vd_sve_sleef(visnan_vo_vd_sve_sleef(ret), vcast_vd_d_sve_sleef(__builtin_inf()), ret); + ret = vsel_vd_vo_vd_vd_sve_sleef(veq_vo_vd_vd_sve_sleef(min, vcast_vd_d_sve_sleef(0)), max, ret); + ret = vsel_vd_vo_vd_vd_sve_sleef(vor_vo_vo_vo_sve_sleef(visnan_vo_vd_sve_sleef(x), visnan_vo_vd_sve_sleef(y)), vcast_vd_d_sve_sleef(__builtin_nan("")), ret); + ret = vsel_vd_vo_vd_vd_sve_sleef(vor_vo_vo_vo_sve_sleef(veq_vo_vd_vd_sve_sleef(x, vcast_vd_d_sve_sleef(__builtin_inf())), veq_vo_vd_vd_sve_sleef(y, vcast_vd_d_sve_sleef(__builtin_inf()))), vcast_vd_d_sve_sleef(__builtin_inf()), ret); + + return ret; +} + +SLEEF_INLINE SLEEF_CONST vdouble_sve_sleef Sleef_hypotdx_u35sve(vdouble_sve_sleef x, vdouble_sve_sleef y) { + x = vabs_vd_vd_sve_sleef(x); + y = vabs_vd_vd_sve_sleef(y); + vdouble_sve_sleef min = vmin_vd_vd_vd_sve_sleef(x, y); + vdouble_sve_sleef max = vmax_vd_vd_vd_sve_sleef(x, y); + + vdouble_sve_sleef t = vdiv_vd_vd_vd_sve_sleef(min, max); + vdouble_sve_sleef ret = vmul_vd_vd_vd_sve_sleef(max, vsqrt_vd_vd_sve_sleef(vmla_vd_vd_vd_vd_sve_sleef(t, t, vcast_vd_d_sve_sleef(1)))); + ret = vsel_vd_vo_vd_vd_sve_sleef(veq_vo_vd_vd_sve_sleef(min, vcast_vd_d_sve_sleef(0)), max, ret); + ret = vsel_vd_vo_vd_vd_sve_sleef(vor_vo_vo_vo_sve_sleef(visnan_vo_vd_sve_sleef(x), visnan_vo_vd_sve_sleef(y)), vcast_vd_d_sve_sleef(__builtin_nan("")), ret); + ret = vsel_vd_vo_vd_vd_sve_sleef(vor_vo_vo_vo_sve_sleef(veq_vo_vd_vd_sve_sleef(x, vcast_vd_d_sve_sleef(__builtin_inf())), veq_vo_vd_vd_sve_sleef(y, vcast_vd_d_sve_sleef(__builtin_inf()))), vcast_vd_d_sve_sleef(__builtin_inf()), ret); + + return ret; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble_sve_sleef vptrunc_vd_vd_sve_sleef(vdouble_sve_sleef x) { + + return vtruncate_vd_vd_sve_sleef(x); + +} + +SLEEF_INLINE SLEEF_CONST vdouble_sve_sleef Sleef_fmoddx_sve(vdouble_sve_sleef x, vdouble_sve_sleef y) { + vdouble_sve_sleef n = vabs_vd_vd_sve_sleef(x), d = vabs_vd_vd_sve_sleef(y), s = vcast_vd_d_sve_sleef(1), q; + vopmask_sve_sleef o = vlt_vo_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(0x1p-1022)); + n = vsel_vd_vo_vd_vd_sve_sleef(o, vmul_vd_vd_vd_sve_sleef(n, vcast_vd_d_sve_sleef(UINT64_C(1) << 54)), n); + d = vsel_vd_vo_vd_vd_sve_sleef(o, vmul_vd_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(UINT64_C(1) << 54)), d); + s = vsel_vd_vo_vd_vd_sve_sleef(o, vmul_vd_vd_vd_sve_sleef(s , vcast_vd_d_sve_sleef(1.0 / (UINT64_C(1) << 54))), s); + vdouble2_sve_sleef r = vcast_vd2_vd_vd_sve_sleef(n, vcast_vd_d_sve_sleef(0)); + vdouble_sve_sleef rd = vtoward0_vd_vd_sve_sleef(vrec_vd_vd_sve_sleef(d)); + + for(int i=0;i<21;i++) { + q = vptrunc_vd_vd_sve_sleef(vmul_vd_vd_vd_sve_sleef(vtoward0_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(r)), rd)); + + q = vsel_vd_vo_vd_vd_sve_sleef(vand_vo_vo_vo_sve_sleef(vgt_vo_vd_vd_sve_sleef(vmul_vd_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(3), d), vd2getx_vd_vd2_sve_sleef(r)), + vge_vo_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(r), d)), + vcast_vd_d_sve_sleef(2), q); + q = vsel_vd_vo_vd_vd_sve_sleef(vand_vo_vo_vo_sve_sleef(vgt_vo_vd_vd_sve_sleef(vadd_vd_vd_vd_sve_sleef(d, d), vd2getx_vd_vd2_sve_sleef(r)), + vge_vo_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(r), d)), + vcast_vd_d_sve_sleef(1), q); + r = ddnormalize_vd2_vd2_sve_sleef(ddadd2_vd2_vd2_vd2_sve_sleef(r, ddmul_vd2_vd_vd_sve_sleef(q, vneg_vd_vd_sve_sleef(d)))); + if (vtestallones_i_vo64_sve_sleef(vlt_vo_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(r), d))) break; + } + + vdouble_sve_sleef ret = vmul_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(r), s); + ret = vsel_vd_vo_vd_vd_sve_sleef(veq_vo_vd_vd_sve_sleef(vadd_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(r), vd2gety_vd_vd2_sve_sleef(r)), d), vcast_vd_d_sve_sleef(0), ret); + + ret = vmulsign_vd_vd_vd_sve_sleef(ret, x); + + ret = vsel_vd_vo_vd_vd_sve_sleef(vlt_vo_vd_vd_sve_sleef(n, d), x, ret); + ret = vsel_vd_vo_vd_vd_sve_sleef(veq_vo_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(0)), vcast_vd_d_sve_sleef(__builtin_nan("")), ret); + + return ret; +} + +static SLEEF_ALWAYS_INLINE vdouble_sve_sleef vrintk2_vd_vd_sve_sleef(vdouble_sve_sleef d) { + + return vrint_vd_vd_sve_sleef(d); + +} + +SLEEF_INLINE SLEEF_CONST vdouble_sve_sleef Sleef_remainderdx_sve(vdouble_sve_sleef x, vdouble_sve_sleef y) { + vdouble_sve_sleef n = vabs_vd_vd_sve_sleef(x), d = vabs_vd_vd_sve_sleef(y), s = vcast_vd_d_sve_sleef(1), q; + vopmask_sve_sleef o = vlt_vo_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(0x1p-1022*2)); + n = vsel_vd_vo_vd_vd_sve_sleef(o, vmul_vd_vd_vd_sve_sleef(n, vcast_vd_d_sve_sleef(UINT64_C(1) << 54)), n); + d = vsel_vd_vo_vd_vd_sve_sleef(o, vmul_vd_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(UINT64_C(1) << 54)), d); + s = vsel_vd_vo_vd_vd_sve_sleef(o, vmul_vd_vd_vd_sve_sleef(s , vcast_vd_d_sve_sleef(1.0 / (UINT64_C(1) << 54))), s); + vdouble_sve_sleef rd = vrec_vd_vd_sve_sleef(d); + vdouble2_sve_sleef r = vcast_vd2_vd_vd_sve_sleef(n, vcast_vd_d_sve_sleef(0)); + vopmask_sve_sleef qisodd = vneq_vo_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(0), vcast_vd_d_sve_sleef(0)); + + for(int i=0;i<21;i++) { + q = vrintk2_vd_vd_sve_sleef(vmul_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(r), rd)); + + q = vsel_vd_vo_vd_vd_sve_sleef(vlt_vo_vd_vd_sve_sleef(vabs_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(r)), vmul_vd_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(1.5))), vmulsign_vd_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(1.0), vd2getx_vd_vd2_sve_sleef(r)), q); + q = vsel_vd_vo_vd_vd_sve_sleef(vor_vo_vo_vo_sve_sleef(vlt_vo_vd_vd_sve_sleef(vabs_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(r)), vmul_vd_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(0.5))), + vandnot_vo_vo_vo_sve_sleef(qisodd, veq_vo_vd_vd_sve_sleef(vabs_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(r)), vmul_vd_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(0.5))))), + vcast_vd_d_sve_sleef(0.0), q); + if (vtestallones_i_vo64_sve_sleef(veq_vo_vd_vd_sve_sleef(q, vcast_vd_d_sve_sleef(0)))) break; + q = vsel_vd_vo_vd_vd_sve_sleef(visinf_vo_vd_sve_sleef(vmul_vd_vd_vd_sve_sleef(q, vneg_vd_vd_sve_sleef(d))), vadd_vd_vd_vd_sve_sleef(q, vmulsign_vd_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(-1), vd2getx_vd_vd2_sve_sleef(r))), q); + qisodd = vxor_vo_vo_vo_sve_sleef(qisodd, visodd_vo_vd_sve_sleef(q)); + r = ddnormalize_vd2_vd2_sve_sleef(ddadd2_vd2_vd2_vd2_sve_sleef(r, ddmul_vd2_vd_vd_sve_sleef(q, vneg_vd_vd_sve_sleef(d)))); + } + + vdouble_sve_sleef ret = vmul_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(r), s); + ret = vmulsign_vd_vd_vd_sve_sleef(ret, x); + ret = vsel_vd_vo_vd_vd_sve_sleef(visinf_vo_vd_sve_sleef(y), vsel_vd_vo_vd_vd_sve_sleef(visinf_vo_vd_sve_sleef(x), vcast_vd_d_sve_sleef(__builtin_nan("")), x), ret); + ret = vsel_vd_vo_vd_vd_sve_sleef(veq_vo_vd_vd_sve_sleef(d, vcast_vd_d_sve_sleef(0)), vcast_vd_d_sve_sleef(__builtin_nan("")), ret); + return ret; +} + +static SLEEF_CONST dd2_sve_sleef gammak_sve_sleef(vdouble_sve_sleef a) { + vdouble2_sve_sleef clc = vcast_vd2_d_d_sve_sleef(0, 0), clln = vcast_vd2_d_d_sve_sleef(1, 0), clld = vcast_vd2_d_d_sve_sleef(1, 0); + vdouble2_sve_sleef x, y, z; + vdouble_sve_sleef t, u; + + vopmask_sve_sleef otiny = vlt_vo_vd_vd_sve_sleef(vabs_vd_vd_sve_sleef(a), vcast_vd_d_sve_sleef(1e-306)), oref = vlt_vo_vd_vd_sve_sleef(a, vcast_vd_d_sve_sleef(0.5)); + + x = vsel_vd2_vo_vd2_vd2_sve_sleef(otiny, vcast_vd2_d_d_sve_sleef(0, 0), + vsel_vd2_vo_vd2_vd2_sve_sleef(oref, ddadd2_vd2_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(1), vneg_vd_vd_sve_sleef(a)), + vcast_vd2_vd_vd_sve_sleef(a, vcast_vd_d_sve_sleef(0)))); + + vopmask_sve_sleef o0 = vand_vo_vo_vo_sve_sleef(vle_vo_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(0.5), vd2getx_vd_vd2_sve_sleef(x)), vle_vo_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(x), vcast_vd_d_sve_sleef(1.1))); + vopmask_sve_sleef o2 = vle_vo_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(2.3), vd2getx_vd_vd2_sve_sleef(x)); + + y = ddnormalize_vd2_vd2_sve_sleef(ddmul_vd2_vd2_vd2_sve_sleef(ddadd2_vd2_vd2_vd_sve_sleef(x, vcast_vd_d_sve_sleef(1)), x)); + y = ddnormalize_vd2_vd2_sve_sleef(ddmul_vd2_vd2_vd2_sve_sleef(ddadd2_vd2_vd2_vd_sve_sleef(x, vcast_vd_d_sve_sleef(2)), y)); + y = ddnormalize_vd2_vd2_sve_sleef(ddmul_vd2_vd2_vd2_sve_sleef(ddadd2_vd2_vd2_vd_sve_sleef(x, vcast_vd_d_sve_sleef(3)), y)); + y = ddnormalize_vd2_vd2_sve_sleef(ddmul_vd2_vd2_vd2_sve_sleef(ddadd2_vd2_vd2_vd_sve_sleef(x, vcast_vd_d_sve_sleef(4)), y)); + + vopmask_sve_sleef o = vand_vo_vo_vo_sve_sleef(o2, vle_vo_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(x), vcast_vd_d_sve_sleef(7))); + clln = vsel_vd2_vo_vd2_vd2_sve_sleef(o, y, clln); + + x = vsel_vd2_vo_vd2_vd2_sve_sleef(o, ddadd2_vd2_vd2_vd_sve_sleef(x, vcast_vd_d_sve_sleef(5)), x); + + t = vsel_vd_vo_vd_vd_sve_sleef(o2, vrec_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(x)), vd2getx_vd_vd2_sve_sleef(ddnormalize_vd2_vd2_sve_sleef(ddadd2_vd2_vd2_vd_sve_sleef(x, vsel_vd_vo_d_d_sve_sleef(o0, -1, -2))))); + + u = vsel_vd_vo_vo_d_d_d_sve_sleef(o2, o0, -156.801412704022726379848862, +0.2947916772827614196e+2, +0.7074816000864609279e-7); + u = vmla_vd_vd_vd_vd_sve_sleef(u, t, vsel_vd_vo_vo_d_d_d_sve_sleef(o2, o0, +1.120804464289911606838558160000, +0.1281459691827820109e+3, +0.4009244333008730443e-6)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, t, vsel_vd_vo_vo_d_d_d_sve_sleef(o2, o0, +13.39798545514258921833306020000, +0.2617544025784515043e+3, +0.1040114641628246946e-5)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, t, vsel_vd_vo_vo_d_d_d_sve_sleef(o2, o0, -0.116546276599463200848033357000, +0.3287022855685790432e+3, +0.1508349150733329167e-5)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, t, vsel_vd_vo_vo_d_d_d_sve_sleef(o2, o0, -1.391801093265337481495562410000, +0.2818145867730348186e+3, +0.1288143074933901020e-5)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, t, vsel_vd_vo_vo_d_d_d_sve_sleef(o2, o0, +0.015056113040026424412918973400, +0.1728670414673559605e+3, +0.4744167749884993937e-6)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, t, vsel_vd_vo_vo_d_d_d_sve_sleef(o2, o0, +0.179540117061234856098844714000, +0.7748735764030416817e+2, -0.6554816306542489902e-7)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, t, vsel_vd_vo_vo_d_d_d_sve_sleef(o2, o0, -0.002481743600264997730942489280, +0.2512856643080930752e+2, -0.3189252471452599844e-6)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, t, vsel_vd_vo_vo_d_d_d_sve_sleef(o2, o0, -0.029527880945699120504851034100, +0.5766792106140076868e+1, +0.1358883821470355377e-6)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, t, vsel_vd_vo_vo_d_d_d_sve_sleef(o2, o0, +0.000540164767892604515196325186, +0.7270275473996180571e+0, -0.4343931277157336040e-6)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, t, vsel_vd_vo_vo_d_d_d_sve_sleef(o2, o0, +0.006403362833808069794787256200, +0.8396709124579147809e-1, +0.9724785897406779555e-6)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, t, vsel_vd_vo_vo_d_d_d_sve_sleef(o2, o0, -0.000162516262783915816896611252, -0.8211558669746804595e-1, -0.2036886057225966011e-5)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, t, vsel_vd_vo_vo_d_d_d_sve_sleef(o2, o0, -0.001914438498565477526465972390, +0.6828831828341884458e-1, +0.4373363141819725815e-5)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, t, vsel_vd_vo_vo_d_d_d_sve_sleef(o2, o0, +7.20489541602001055898311517e-05, -0.7712481339961671511e-1, -0.9439951268304008677e-5)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, t, vsel_vd_vo_vo_d_d_d_sve_sleef(o2, o0, +0.000839498720672087279971000786, +0.8337492023017314957e-1, +0.2050727030376389804e-4)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, t, vsel_vd_vo_vo_d_d_d_sve_sleef(o2, o0, -5.17179090826059219329394422e-05, -0.9094964931456242518e-1, -0.4492620183431184018e-4)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, t, vsel_vd_vo_vo_d_d_d_sve_sleef(o2, o0, -0.000592166437353693882857342347, +0.1000996313575929358e+0, +0.9945751236071875931e-4)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, t, vsel_vd_vo_vo_d_d_d_sve_sleef(o2, o0, +6.97281375836585777403743539e-05, -0.1113342861544207724e+0, -0.2231547599034983196e-3)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, t, vsel_vd_vo_vo_d_d_d_sve_sleef(o2, o0, +0.000784039221720066627493314301, +0.1255096673213020875e+0, +0.5096695247101967622e-3)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, t, vsel_vd_vo_vo_d_d_d_sve_sleef(o2, o0, -0.000229472093621399176949318732, -0.1440498967843054368e+0, -0.1192753911667886971e-2)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, t, vsel_vd_vo_vo_d_d_d_sve_sleef(o2, o0, -0.002681327160493827160473958490, +0.1695571770041949811e+0, +0.2890510330742210310e-2)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, t, vsel_vd_vo_vo_d_d_d_sve_sleef(o2, o0, +0.003472222222222222222175164840, -0.2073855510284092762e+0, -0.7385551028674461858e-2)); + u = vmla_vd_vd_vd_vd_sve_sleef(u, t, vsel_vd_vo_vo_d_d_d_sve_sleef(o2, o0, +0.083333333333333333335592087900, +0.2705808084277815939e+0, +0.2058080842778455335e-1)); + + y = ddmul_vd2_vd2_vd2_sve_sleef(ddadd2_vd2_vd2_vd_sve_sleef(x, vcast_vd_d_sve_sleef(-0.5)), logk2_sve_sleef(x)); + y = ddadd2_vd2_vd2_vd2_sve_sleef(y, ddneg_vd2_vd2_sve_sleef(x)); + y = ddadd2_vd2_vd2_vd2_sve_sleef(y, vcast_vd2_d_d_sve_sleef(0.91893853320467278056, -3.8782941580672414498e-17)); + + z = ddadd2_vd2_vd2_vd_sve_sleef(ddmul_vd2_vd_vd_sve_sleef (u, t), vsel_vd_vo_d_d_sve_sleef(o0, -0.4006856343865314862e+0, -0.6735230105319810201e-1)); + z = ddadd2_vd2_vd2_vd_sve_sleef(ddmul_vd2_vd2_vd_sve_sleef(z, t), vsel_vd_vo_d_d_sve_sleef(o0, +0.8224670334241132030e+0, +0.3224670334241132030e+0)); + z = ddadd2_vd2_vd2_vd_sve_sleef(ddmul_vd2_vd2_vd_sve_sleef(z, t), vsel_vd_vo_d_d_sve_sleef(o0, -0.5772156649015328655e+0, +0.4227843350984671345e+0)); + z = ddmul_vd2_vd2_vd_sve_sleef(z, t); + + clc = vsel_vd2_vo_vd2_vd2_sve_sleef(o2, y, z); + + clld = vsel_vd2_vo_vd2_vd2_sve_sleef(o2, ddadd2_vd2_vd2_vd_sve_sleef(ddmul_vd2_vd_vd_sve_sleef(u, t), vcast_vd_d_sve_sleef(1)), clld); + + y = clln; + + clc = vsel_vd2_vo_vd2_vd2_sve_sleef(otiny, vcast_vd2_d_d_sve_sleef(83.1776616671934334590333, 3.67103459631568507221878e-15), + vsel_vd2_vo_vd2_vd2_sve_sleef(oref, ddadd2_vd2_vd2_vd2_sve_sleef(vcast_vd2_d_d_sve_sleef(1.1447298858494001639, 1.026595116270782638e-17), ddneg_vd2_vd2_sve_sleef(clc)), clc)); + clln = vsel_vd2_vo_vd2_vd2_sve_sleef(otiny, vcast_vd2_d_d_sve_sleef(1, 0), vsel_vd2_vo_vd2_vd2_sve_sleef(oref, clln, clld)); + + if (!vtestallones_i_vo64_sve_sleef(vnot_vo64_vo64_sve_sleef(oref))) { + t = vsub_vd_vd_vd_sve_sleef(a, vmul_vd_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(INT64_C(1) << 28), vcast_vd_vi_sve_sleef(vtruncate_vi_vd_sve_sleef(vmul_vd_vd_vd_sve_sleef(a, vcast_vd_d_sve_sleef(1.0 / (INT64_C(1) << 28))))))); + x = ddmul_vd2_vd2_vd2_sve_sleef(clld, sinpik_sve_sleef(t)); + } + + clld = vsel_vd2_vo_vd2_vd2_sve_sleef(otiny, vcast_vd2_vd_vd_sve_sleef(vmul_vd_vd_vd_sve_sleef(a, vcast_vd_d_sve_sleef((INT64_C(1) << 60)*(double)(INT64_C(1) << 60))), vcast_vd_d_sve_sleef(0)), + vsel_vd2_vo_vd2_vd2_sve_sleef(oref, x, y)); + + return dd2setab_dd2_vd2_vd2_sve_sleef(clc, dddiv_vd2_vd2_vd2_sve_sleef(clln, clld)); +} + +SLEEF_INLINE SLEEF_CONST vdouble_sve_sleef Sleef_tgammadx_u10sve(vdouble_sve_sleef a) { + dd2_sve_sleef d = gammak_sve_sleef(a); + vdouble2_sve_sleef y = ddmul_vd2_vd2_vd2_sve_sleef(expk2_sve_sleef(dd2geta_vd2_dd2_sve_sleef(d)), dd2getb_vd2_dd2_sve_sleef(d)); + vdouble_sve_sleef r = vadd_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(y), vd2gety_vd_vd2_sve_sleef(y)); + vopmask_sve_sleef o; + + o = vor_vo_vo_vo_sve_sleef(vor_vo_vo_vo_sve_sleef(veq_vo_vd_vd_sve_sleef(a, vcast_vd_d_sve_sleef(-__builtin_inf())), + vand_vo_vo_vo_sve_sleef(vlt_vo_vd_vd_sve_sleef(a, vcast_vd_d_sve_sleef(0)), visint_vo_vd_sve_sleef(a))), + vand_vo_vo_vo_sve_sleef(vand_vo_vo_vo_sve_sleef(visnumber_vo_vd_sve_sleef(a), vlt_vo_vd_vd_sve_sleef(a, vcast_vd_d_sve_sleef(0))), visnan_vo_vd_sve_sleef(r))); + r = vsel_vd_vo_vd_vd_sve_sleef(o, vcast_vd_d_sve_sleef(__builtin_nan("")), r); + + o = vand_vo_vo_vo_sve_sleef(vand_vo_vo_vo_sve_sleef(vor_vo_vo_vo_sve_sleef(veq_vo_vd_vd_sve_sleef(a, vcast_vd_d_sve_sleef(__builtin_inf())), visnumber_vo_vd_sve_sleef(a)), + vge_vo_vd_vd_sve_sleef(a, vcast_vd_d_sve_sleef(-0x1p-1022))), + vor_vo_vo_vo_sve_sleef(vor_vo_vo_vo_sve_sleef(veq_vo_vd_vd_sve_sleef(a, vcast_vd_d_sve_sleef(0)), vgt_vo_vd_vd_sve_sleef(a, vcast_vd_d_sve_sleef(200))), visnan_vo_vd_sve_sleef(r))); + r = vsel_vd_vo_vd_vd_sve_sleef(o, vmulsign_vd_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(__builtin_inf()), a), r); + + return r; +} + +SLEEF_INLINE SLEEF_CONST vdouble_sve_sleef Sleef_lgammadx_u10sve(vdouble_sve_sleef a) { + dd2_sve_sleef d = gammak_sve_sleef(a); + vdouble2_sve_sleef y = ddadd2_vd2_vd2_vd2_sve_sleef(dd2geta_vd2_dd2_sve_sleef(d), logk2_sve_sleef(ddabs_vd2_vd2_sve_sleef(dd2getb_vd2_dd2_sve_sleef(d)))); + vdouble_sve_sleef r = vadd_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(y), vd2gety_vd_vd2_sve_sleef(y)); + vopmask_sve_sleef o; + + o = vor_vo_vo_vo_sve_sleef(visinf_vo_vd_sve_sleef(a), + vor_vo_vo_vo_sve_sleef(vand_vo_vo_vo_sve_sleef(vle_vo_vd_vd_sve_sleef(a, vcast_vd_d_sve_sleef(0)), visint_vo_vd_sve_sleef(a)), + vand_vo_vo_vo_sve_sleef(visnumber_vo_vd_sve_sleef(a), visnan_vo_vd_sve_sleef(r)))); + r = vsel_vd_vo_vd_vd_sve_sleef(o, vcast_vd_d_sve_sleef(__builtin_inf()), r); + + return r; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_sve_sleef ddmla_vd2_vd_vd2_vd2_sve_sleef(vdouble_sve_sleef x, vdouble2_sve_sleef y, vdouble2_sve_sleef z) { + return ddadd_vd2_vd2_vd2_sve_sleef(z, ddmul_vd2_vd2_vd_sve_sleef(y, x)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_sve_sleef poly2dd_b_sve_sleef(vdouble_sve_sleef x, vdouble2_sve_sleef c1, vdouble2_sve_sleef c0) { return ddmla_vd2_vd_vd2_vd2_sve_sleef(x, c1, c0); } +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_sve_sleef poly2dd_sve_sleef(vdouble_sve_sleef x, vdouble_sve_sleef c1, vdouble2_sve_sleef c0) { return ddmla_vd2_vd_vd2_vd2_sve_sleef(x, vcast_vd2_vd_vd_sve_sleef(c1, vcast_vd_d_sve_sleef(0)), c0); } +static SLEEF_ALWAYS_INLINE SLEEF_CONST vdouble2_sve_sleef poly4dd_sve_sleef(vdouble_sve_sleef x, vdouble_sve_sleef c3, vdouble2_sve_sleef c2, vdouble2_sve_sleef c1, vdouble2_sve_sleef c0) { + return ddmla_vd2_vd_vd2_vd2_sve_sleef(vmul_vd_vd_vd_sve_sleef(x, x), poly2dd_sve_sleef(x, c3, c2), poly2dd_b_sve_sleef(x, c1, c0)); +} + +SLEEF_INLINE SLEEF_CONST vdouble_sve_sleef Sleef_erfdx_u10sve(vdouble_sve_sleef a) { + vdouble_sve_sleef t, x = vabs_vd_vd_sve_sleef(a); + vdouble2_sve_sleef t2; + vdouble_sve_sleef x2 = vmul_vd_vd_vd_sve_sleef(x, x), x4 = vmul_vd_vd_vd_sve_sleef(x2, x2); + vdouble_sve_sleef x8 = vmul_vd_vd_vd_sve_sleef(x4, x4), x16 = vmul_vd_vd_vd_sve_sleef(x8, x8); + vopmask_sve_sleef o25 = vle_vo_vd_vd_sve_sleef(x, vcast_vd_d_sve_sleef(2.5)); + + if (__builtin_expect(!!(vtestallones_i_vo64_sve_sleef(o25)), 1)) { + + t = vmla_vd_vd_vd_vd_sve_sleef((x16), (vmla_vd_vd_vd_vd_sve_sleef((x4), (vcast_vd_d_sve_sleef(-0.2083271002525222097e-14)), (vmla_vd_vd_vd_vd_sve_sleef((x2), (vmla_vd_vd_vd_vd_sve_sleef((x), (vcast_vd_d_sve_sleef(+0.7151909970790897009e-13)), (vcast_vd_d_sve_sleef(-0.1162238220110999364e-11)))), (vmla_vd_vd_vd_vd_sve_sleef((x), (vcast_vd_d_sve_sleef(+0.1186474230821585259e-10)), (vcast_vd_d_sve_sleef(-0.8499973178354613440e-10)))))))), (vmla_vd_vd_vd_vd_sve_sleef((x8), (vmla_vd_vd_vd_vd_sve_sleef((x4), (vmla_vd_vd_vd_vd_sve_sleef((x2), (vmla_vd_vd_vd_vd_sve_sleef((x), (vcast_vd_d_sve_sleef(+0.4507647462598841629e-9)), (vcast_vd_d_sve_sleef(-0.1808044474288848915e-8)))), (vmla_vd_vd_vd_vd_sve_sleef((x), (vcast_vd_d_sve_sleef(+0.5435081826716212389e-8)), (vcast_vd_d_sve_sleef(-0.1143939895758628484e-7)))))), (vmla_vd_vd_vd_vd_sve_sleef((x2), (vmla_vd_vd_vd_vd_sve_sleef((x), (vcast_vd_d_sve_sleef(+0.1215442362680889243e-7)), (vcast_vd_d_sve_sleef(+0.1669878756181250355e-7)))), (vmla_vd_vd_vd_vd_sve_sleef((x), (vcast_vd_d_sve_sleef(-0.9808074602255194288e-7)), (vcast_vd_d_sve_sleef(+0.1389000557865837204e-6)))))))), (vmla_vd_vd_vd_vd_sve_sleef((x4), (vmla_vd_vd_vd_vd_sve_sleef((x2), (vmla_vd_vd_vd_vd_sve_sleef((x), (vcast_vd_d_sve_sleef(+0.2945514529987331866e-6)), (vcast_vd_d_sve_sleef(-0.1842918273003998283e-5)))), (vmla_vd_vd_vd_vd_sve_sleef((x), (vcast_vd_d_sve_sleef(+0.3417987836115362136e-5)), (vcast_vd_d_sve_sleef(+0.3860236356493129101e-5)))))), (vmla_vd_vd_vd_vd_sve_sleef((x2), (vmla_vd_vd_vd_vd_sve_sleef((x), (vcast_vd_d_sve_sleef(-0.3309403072749947546e-4)), (vcast_vd_d_sve_sleef(+0.1060862922597579532e-3)))), (vmla_vd_vd_vd_vd_sve_sleef((x), (vcast_vd_d_sve_sleef(+0.2323253155213076174e-3)), (vcast_vd_d_sve_sleef(+0.1490149719145544729e-3))))))))))) + + ; + t2 = poly4dd_sve_sleef(x, t, + vcast_vd2_d_d_sve_sleef(0.0092877958392275604405, 7.9287559463961107493e-19), + vcast_vd2_d_d_sve_sleef(0.042275531758784692937, 1.3785226620501016138e-19), + vcast_vd2_d_d_sve_sleef(0.07052369794346953491, 9.5846628070792092842e-19)); + t2 = ddadd_vd2_vd_vd2_sve_sleef(vcast_vd_d_sve_sleef(1), ddmul_vd2_vd2_vd_sve_sleef(t2, x)); + t2 = ddsqu_vd2_vd2_sve_sleef(t2); + t2 = ddsqu_vd2_vd2_sve_sleef(t2); + t2 = ddsqu_vd2_vd2_sve_sleef(t2); + t2 = ddsqu_vd2_vd2_sve_sleef(t2); + t2 = ddrec_vd2_vd2_sve_sleef(t2); + } else { + + t = vmla_vd_vd_vd_vd_sve_sleef((x16), (vmla_vd_vd_vd_vd_sve_sleef((x4), ((vsel_vd_vo_d_d_sve_sleef(o25, -0.2083271002525222097e-14, -0.4024015130752621932e-18))), (vmla_vd_vd_vd_vd_sve_sleef((x2), (vmla_vd_vd_vd_vd_sve_sleef((x), ((vsel_vd_vo_d_d_sve_sleef(o25, +0.7151909970790897009e-13, +0.3847193332817048172e-16))), ((vsel_vd_vo_d_d_sve_sleef(o25, -0.1162238220110999364e-11, -0.1749316241455644088e-14))))), (vmla_vd_vd_vd_vd_sve_sleef((x), ((vsel_vd_vo_d_d_sve_sleef(o25, +0.1186474230821585259e-10, +0.5029618322872872715e-13))), ((vsel_vd_vo_d_d_sve_sleef(o25, -0.8499973178354613440e-10, -0.1025221466851463164e-11))))))))), (vmla_vd_vd_vd_vd_sve_sleef((x8), (vmla_vd_vd_vd_vd_sve_sleef((x4), (vmla_vd_vd_vd_vd_sve_sleef((x2), (vmla_vd_vd_vd_vd_sve_sleef((x), ((vsel_vd_vo_d_d_sve_sleef(o25, +0.4507647462598841629e-9, +0.1573695559331945583e-10))), ((vsel_vd_vo_d_d_sve_sleef(o25, -0.1808044474288848915e-8, -0.1884658558040203709e-9))))), (vmla_vd_vd_vd_vd_sve_sleef((x), ((vsel_vd_vo_d_d_sve_sleef(o25, +0.5435081826716212389e-8, +0.1798167853032159309e-8))), ((vsel_vd_vo_d_d_sve_sleef(o25, -0.1143939895758628484e-7, -0.1380745342355033142e-7))))))), (vmla_vd_vd_vd_vd_sve_sleef((x2), (vmla_vd_vd_vd_vd_sve_sleef((x), ((vsel_vd_vo_d_d_sve_sleef(o25, +0.1215442362680889243e-7, +0.8525705726469103499e-7))), ((vsel_vd_vo_d_d_sve_sleef(o25, +0.1669878756181250355e-7, -0.4160448058101303405e-6))))), (vmla_vd_vd_vd_vd_sve_sleef((x), ((vsel_vd_vo_d_d_sve_sleef(o25, -0.9808074602255194288e-7, +0.1517272660008588485e-5))), ((vsel_vd_vo_d_d_sve_sleef(o25, +0.1389000557865837204e-6, -0.3341634127317201697e-5))))))))), (vmla_vd_vd_vd_vd_sve_sleef((x4), (vmla_vd_vd_vd_vd_sve_sleef((x2), (vmla_vd_vd_vd_vd_sve_sleef((x), ((vsel_vd_vo_d_d_sve_sleef(o25, +0.2945514529987331866e-6, -0.2515023395879724513e-5))), ((vsel_vd_vo_d_d_sve_sleef(o25, -0.1842918273003998283e-5, +0.6539731269664907554e-4))))), (vmla_vd_vd_vd_vd_sve_sleef((x), ((vsel_vd_vo_d_d_sve_sleef(o25, +0.3417987836115362136e-5, -0.3551065097428388658e-3))), ((vsel_vd_vo_d_d_sve_sleef(o25, +0.3860236356493129101e-5, +0.1210736097958368864e-2))))))), (vmla_vd_vd_vd_vd_sve_sleef((x2), (vmla_vd_vd_vd_vd_sve_sleef((x), ((vsel_vd_vo_d_d_sve_sleef(o25, -0.3309403072749947546e-4, -0.2605566912579998680e-2))), ((vsel_vd_vo_d_d_sve_sleef(o25, +0.1060862922597579532e-3, +0.1252823202436093193e-2))))), (vmla_vd_vd_vd_vd_sve_sleef((x), ((vsel_vd_vo_d_d_sve_sleef(o25, +0.2323253155213076174e-3, +0.1820191395263313222e-1))), ((vsel_vd_vo_d_d_sve_sleef(o25, +0.1490149719145544729e-3, -0.1021557155453465954e+0)))))))))))) + + ; + t2 = poly4dd_sve_sleef(x, t, + vsel_vd2_vo_vd2_vd2_sve_sleef(o25, vcast_vd2_d_d_sve_sleef(0.0092877958392275604405, 7.9287559463961107493e-19), + vcast_vd2_d_d_sve_sleef(-0.63691044383641748361, -2.4249477526539431839e-17)), + vsel_vd2_vo_vd2_vd2_sve_sleef(o25, vcast_vd2_d_d_sve_sleef(0.042275531758784692937, 1.3785226620501016138e-19), + vcast_vd2_d_d_sve_sleef(-1.1282926061803961737, -6.2970338860410996505e-17)), + vsel_vd2_vo_vd2_vd2_sve_sleef(o25, vcast_vd2_d_d_sve_sleef(0.07052369794346953491, 9.5846628070792092842e-19), + vcast_vd2_d_d_sve_sleef(-1.2261313785184804967e-05, -5.5329707514490107044e-22))); + vdouble2_sve_sleef s2 = ddadd_vd2_vd_vd2_sve_sleef(vcast_vd_d_sve_sleef(1), ddmul_vd2_vd2_vd_sve_sleef(t2, x)); + s2 = ddsqu_vd2_vd2_sve_sleef(s2); + s2 = ddsqu_vd2_vd2_sve_sleef(s2); + s2 = ddsqu_vd2_vd2_sve_sleef(s2); + s2 = ddsqu_vd2_vd2_sve_sleef(s2); + s2 = ddrec_vd2_vd2_sve_sleef(s2); + t2 = vsel_vd2_vo_vd2_vd2_sve_sleef(o25, s2, vcast_vd2_vd_vd_sve_sleef(expk_sve_sleef(t2), vcast_vd_d_sve_sleef(0))); + } + + t2 = ddadd2_vd2_vd2_vd_sve_sleef(t2, vcast_vd_d_sve_sleef(-1)); + + vdouble_sve_sleef z = vneg_vd_vd_sve_sleef(vadd_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(t2), vd2gety_vd_vd2_sve_sleef(t2))); + z = vsel_vd_vo_vd_vd_sve_sleef(vlt_vo_vd_vd_sve_sleef(x, vcast_vd_d_sve_sleef(1e-8)), vmul_vd_vd_vd_sve_sleef(x, vcast_vd_d_sve_sleef(1.12837916709551262756245475959)), z); + z = vsel_vd_vo_vd_vd_sve_sleef(vge_vo_vd_vd_sve_sleef(x, vcast_vd_d_sve_sleef(6)), vcast_vd_d_sve_sleef(1), z); + z = vsel_vd_vo_vd_vd_sve_sleef(visinf_vo_vd_sve_sleef(a), vcast_vd_d_sve_sleef(1), z); + z = vsel_vd_vo_vd_vd_sve_sleef(veq_vo_vd_vd_sve_sleef(a, vcast_vd_d_sve_sleef(0)), vcast_vd_d_sve_sleef(0), z); + z = vmulsign_vd_vd_vd_sve_sleef(z, a); + + return z; +} + +SLEEF_INLINE SLEEF_CONST vdouble_sve_sleef Sleef_erfcdx_u15sve(vdouble_sve_sleef a) { + vdouble_sve_sleef s = a, r = vcast_vd_d_sve_sleef(0), t; + vdouble2_sve_sleef u, d, x; + a = vabs_vd_vd_sve_sleef(a); + vopmask_sve_sleef o0 = vlt_vo_vd_vd_sve_sleef(a, vcast_vd_d_sve_sleef(1.0)); + vopmask_sve_sleef o1 = vlt_vo_vd_vd_sve_sleef(a, vcast_vd_d_sve_sleef(2.2)); + vopmask_sve_sleef o2 = vlt_vo_vd_vd_sve_sleef(a, vcast_vd_d_sve_sleef(4.2)); + vopmask_sve_sleef o3 = vlt_vo_vd_vd_sve_sleef(a, vcast_vd_d_sve_sleef(27.3)); + + u = vsel_vd2_vo_vd2_vd2_sve_sleef(o0, ddmul_vd2_vd_vd_sve_sleef(a, a), vsel_vd2_vo_vd2_vd2_sve_sleef(o1, vcast_vd2_vd_vd_sve_sleef(a, vcast_vd_d_sve_sleef(0)), dddiv_vd2_vd2_vd2_sve_sleef(vcast_vd2_d_d_sve_sleef(1, 0), vcast_vd2_vd_vd_sve_sleef(a, vcast_vd_d_sve_sleef(0))))); + + t = vsel_vd_vo_vo_vo_d_d_d_d_sve_sleef(o0, o1, o2, +0.6801072401395386139e-20, +0.3438010341362585303e-12, -0.5757819536420710449e+2, +0.2334249729638701319e+5); + t = vmla_vd_vd_vd_vd_sve_sleef(t, vd2getx_vd_vd2_sve_sleef(u), vsel_vd_vo_vo_vo_d_d_d_d_sve_sleef(o0, o1, o2, -0.2161766247570055669e-18, -0.1237021188160598264e-10, +0.4669289654498104483e+3, -0.4695661044933107769e+5)); + t = vmla_vd_vd_vd_vd_sve_sleef(t, vd2getx_vd_vd2_sve_sleef(u), vsel_vd_vo_vo_vo_d_d_d_d_sve_sleef(o0, o1, o2, +0.4695919173301595670e-17, +0.2117985839877627852e-09, -0.1796329879461355858e+4, +0.3173403108748643353e+5)); + t = vmla_vd_vd_vd_vd_sve_sleef(t, vd2getx_vd_vd2_sve_sleef(u), vsel_vd_vo_vo_vo_d_d_d_d_sve_sleef(o0, o1, o2, -0.9049140419888007122e-16, -0.2290560929177369506e-08, +0.4355892193699575728e+4, +0.3242982786959573787e+4)); + t = vmla_vd_vd_vd_vd_sve_sleef(t, vd2getx_vd_vd2_sve_sleef(u), vsel_vd_vo_vo_vo_d_d_d_d_sve_sleef(o0, o1, o2, +0.1634018903557410728e-14, +0.1748931621698149538e-07, -0.7456258884965764992e+4, -0.2014717999760347811e+5)); + t = vmla_vd_vd_vd_vd_sve_sleef(t, vd2getx_vd_vd2_sve_sleef(u), vsel_vd_vo_vo_vo_d_d_d_d_sve_sleef(o0, o1, o2, -0.2783485786333451745e-13, -0.9956602606623249195e-07, +0.9553977358167021521e+4, +0.1554006970967118286e+5)); + t = vmla_vd_vd_vd_vd_sve_sleef(t, vd2getx_vd_vd2_sve_sleef(u), vsel_vd_vo_vo_vo_d_d_d_d_sve_sleef(o0, o1, o2, +0.4463221276786415752e-12, +0.4330010240640327080e-06, -0.9470019905444229153e+4, -0.6150874190563554293e+4)); + t = vmla_vd_vd_vd_vd_sve_sleef(t, vd2getx_vd_vd2_sve_sleef(u), vsel_vd_vo_vo_vo_d_d_d_d_sve_sleef(o0, o1, o2, -0.6711366622850136563e-11, -0.1435050600991763331e-05, +0.7387344321849855078e+4, +0.1240047765634815732e+4)); + t = vmla_vd_vd_vd_vd_sve_sleef(t, vd2getx_vd_vd2_sve_sleef(u), vsel_vd_vo_vo_vo_d_d_d_d_sve_sleef(o0, o1, o2, +0.9422759050232662223e-10, +0.3460139479650695662e-05, -0.4557713054166382790e+4, -0.8210325475752699731e+2)); + t = vmla_vd_vd_vd_vd_sve_sleef(t, vd2getx_vd_vd2_sve_sleef(u), vsel_vd_vo_vo_vo_d_d_d_d_sve_sleef(o0, o1, o2, -0.1229055530100229098e-08, -0.4988908180632898173e-05, +0.2207866967354055305e+4, +0.3242443880839930870e+2)); + t = vmla_vd_vd_vd_vd_sve_sleef(t, vd2getx_vd_vd2_sve_sleef(u), vsel_vd_vo_vo_vo_d_d_d_d_sve_sleef(o0, o1, o2, +0.1480719281585086512e-07, -0.1308775976326352012e-05, -0.8217975658621754746e+3, -0.2923418863833160586e+2)); + t = vmla_vd_vd_vd_vd_sve_sleef(t, vd2getx_vd_vd2_sve_sleef(u), vsel_vd_vo_vo_vo_d_d_d_d_sve_sleef(o0, o1, o2, -0.1636584469123399803e-06, +0.2825086540850310103e-04, +0.2268659483507917400e+3, +0.3457461732814383071e+0)); + t = vmla_vd_vd_vd_vd_sve_sleef(t, vd2getx_vd_vd2_sve_sleef(u), vsel_vd_vo_vo_vo_d_d_d_d_sve_sleef(o0, o1, o2, +0.1646211436588923575e-05, -0.6393913713069986071e-04, -0.4633361260318560682e+2, +0.5489730155952392998e+1)); + t = vmla_vd_vd_vd_vd_sve_sleef(t, vd2getx_vd_vd2_sve_sleef(u), vsel_vd_vo_vo_vo_d_d_d_d_sve_sleef(o0, o1, o2, -0.1492565035840623511e-04, -0.2566436514695078926e-04, +0.9557380123733945965e+1, +0.1559934132251294134e-2)); + t = vmla_vd_vd_vd_vd_sve_sleef(t, vd2getx_vd_vd2_sve_sleef(u), vsel_vd_vo_vo_vo_d_d_d_d_sve_sleef(o0, o1, o2, +0.1205533298178967851e-03, +0.5895792375659440364e-03, -0.2958429331939661289e+1, -0.1541741566831520638e+1)); + t = vmla_vd_vd_vd_vd_sve_sleef(t, vd2getx_vd_vd2_sve_sleef(u), vsel_vd_vo_vo_vo_d_d_d_d_sve_sleef(o0, o1, o2, -0.8548327023450850081e-03, -0.1695715579163588598e-02, +0.1670329508092765480e+0, +0.2823152230558364186e-5)); + t = vmla_vd_vd_vd_vd_sve_sleef(t, vd2getx_vd_vd2_sve_sleef(u), vsel_vd_vo_vo_vo_d_d_d_d_sve_sleef(o0, o1, o2, +0.5223977625442187932e-02, +0.2089116434918055149e-03, +0.6096615680115419211e+0, +0.6249999184195342838e+0)); + t = vmla_vd_vd_vd_vd_sve_sleef(t, vd2getx_vd_vd2_sve_sleef(u), vsel_vd_vo_vo_vo_d_d_d_d_sve_sleef(o0, o1, o2, -0.2686617064513125222e-01, +0.1912855949584917753e-01, +0.1059212443193543585e-2, +0.1741749416408701288e-8)); + + d = ddmul_vd2_vd2_vd_sve_sleef(u, t); + d = ddadd2_vd2_vd2_vd2_sve_sleef(d, vcast_vd2_vd_vd_sve_sleef(vsel_vd_vo_vo_vo_d_d_d_d_sve_sleef(o0, o1, o2, 0.11283791670955126141, -0.10277263343147646779, -0.50005180473999022439, -0.5000000000258444377), + vsel_vd_vo_vo_vo_d_d_d_d_sve_sleef(o0, o1, o2, -4.0175691625932118483e-18, -6.2338714083404900225e-18, 2.6362140569041995803e-17, -4.0074044712386992281e-17))); + d = ddmul_vd2_vd2_vd2_sve_sleef(d, u); + d = ddadd2_vd2_vd2_vd2_sve_sleef(d, vcast_vd2_vd_vd_sve_sleef(vsel_vd_vo_vo_vo_d_d_d_d_sve_sleef(o0, o1, o2, -0.37612638903183753802, -0.63661976742916359662, 1.601106273924963368e-06, 2.3761973137523364792e-13), + vsel_vd_vo_vo_vo_d_d_d_d_sve_sleef(o0, o1, o2, 1.3391897206042552387e-17, 7.6321019159085724662e-18, 1.1974001857764476775e-23, -1.1670076950531026582e-29))); + d = ddmul_vd2_vd2_vd2_sve_sleef(d, u); + d = ddadd2_vd2_vd2_vd2_sve_sleef(d, vcast_vd2_vd_vd_sve_sleef(vsel_vd_vo_vo_vo_d_d_d_d_sve_sleef(o0, o1, o2, 1.1283791670955125586, -1.1283791674717296161, -0.57236496645145429341, -0.57236494292470108114), + vsel_vd_vo_vo_vo_d_d_d_d_sve_sleef(o0, o1, o2, 1.5335459613165822674e-17, 8.0896847755965377194e-17, 3.0704553245872027258e-17, -2.3984352208056898003e-17))); + + x = ddmul_vd2_vd2_vd_sve_sleef(vsel_vd2_vo_vd2_vd2_sve_sleef(o1, d, vcast_vd2_vd_vd_sve_sleef(vneg_vd_vd_sve_sleef(a), vcast_vd_d_sve_sleef(0))), a); + x = vsel_vd2_vo_vd2_vd2_sve_sleef(o1, x, ddadd2_vd2_vd2_vd2_sve_sleef(x, d)); + x = vsel_vd2_vo_vd2_vd2_sve_sleef(o0, ddsub_vd2_vd2_vd2_sve_sleef(vcast_vd2_d_d_sve_sleef(1, 0), x), expk2_sve_sleef(x)); + x = vsel_vd2_vo_vd2_vd2_sve_sleef(o1, x, ddmul_vd2_vd2_vd2_sve_sleef(x, u)); + + r = vsel_vd_vo_vd_vd_sve_sleef(o3, vadd_vd_vd_vd_sve_sleef(vd2getx_vd_vd2_sve_sleef(x), vd2gety_vd_vd2_sve_sleef(x)), vcast_vd_d_sve_sleef(0)); + r = vsel_vd_vo_vd_vd_sve_sleef(vsignbit_vo_vd_sve_sleef(s), vsub_vd_vd_vd_sve_sleef(vcast_vd_d_sve_sleef(2), r), r); + r = vsel_vd_vo_vd_vd_sve_sleef(visnan_vo_vd_sve_sleef(s), vcast_vd_d_sve_sleef(__builtin_nan("")), r); + return r; +} + +#if !defined(__NVCC__) && ((defined(__SIZEOF_FLOAT128__) && __SIZEOF_FLOAT128__ == 16) || (defined(__linux__) && defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))) || (defined(__PPC64__) && defined(__GNUC__) && !defined(__clang__) && __GNUC__ >= 8)) +#define SLEEF_FLOAT128_IS_IEEEQP +#endif + +#if !defined(SLEEF_FLOAT128_IS_IEEEQP) && !defined(__NVCC__) && defined(__SIZEOF_LONG_DOUBLE__) && __SIZEOF_LONG_DOUBLE__ == 16 && (defined(__aarch64__) || defined(__zarch__)) +#define SLEEF_LONGDOUBLE_IS_IEEEQP +#endif + +#if !defined(Sleef_quad_DEFINED) +#define Sleef_quad_DEFINED +typedef struct { uint64_t x, y; } Sleef_uint64_2t; +#if defined(SLEEF_FLOAT128_IS_IEEEQP) +typedef __float128 Sleef_quad; +#define SLEEF_QUAD_C(x) (x ## Q) +#elif defined(SLEEF_LONGDOUBLE_IS_IEEEQP) +typedef long double Sleef_quad; +#define SLEEF_QUAD_C(x) (x ## L) +#else +typedef Sleef_uint64_2t Sleef_quad; +#endif +#endif + +extern const float Sleef_rempitabsp[]; + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_sve_sleef vupper_vf_vf_sve_sleef(vfloat_sve_sleef d) { + return vreinterpret_vf_vi2_sve_sleef(vand_vi2_vi2_vi2_sve_sleef(vreinterpret_vi2_vf_sve_sleef(d), vcast_vi2_i_sve_sleef(0xfffff000))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_sve_sleef vcast_vf2_vf_vf_sve_sleef(vfloat_sve_sleef h, vfloat_sve_sleef l) { + return vf2setxy_vf2_vf_vf_sve_sleef(h, l); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_sve_sleef vcast_vf2_f_f_sve_sleef(float h, float l) { + return vf2setxy_vf2_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(h), vcast_vf_f_sve_sleef(l)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_sve_sleef vcast_vf2_d_sve_sleef(double d) { + return vf2setxy_vf2_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(d), vcast_vf_f_sve_sleef(d - (float)d)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_sve_sleef vsel_vf2_vo_vf2_vf2_sve_sleef(vopmask_sve_sleef m, vfloat2_sve_sleef x, vfloat2_sve_sleef y) { + return vf2setxy_vf2_vf_vf_sve_sleef(vsel_vf_vo_vf_vf_sve_sleef(m, vf2getx_vf_vf2_sve_sleef(x), vf2getx_vf_vf2_sve_sleef(y)), vsel_vf_vo_vf_vf_sve_sleef(m, vf2gety_vf_vf2_sve_sleef(x), vf2gety_vf_vf2_sve_sleef(y))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_sve_sleef vsel_vf2_vo_f_f_f_f_sve_sleef(vopmask_sve_sleef o, float x1, float y1, float x0, float y0) { + return vf2setxy_vf2_vf_vf_sve_sleef(vsel_vf_vo_f_f_sve_sleef(o, x1, x0), vsel_vf_vo_f_f_sve_sleef(o, y1, y0)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_sve_sleef vsel_vf2_vo_vo_d_d_d_sve_sleef(vopmask_sve_sleef o0, vopmask_sve_sleef o1, double d0, double d1, double d2) { + return vsel_vf2_vo_vf2_vf2_sve_sleef(o0, vcast_vf2_d_sve_sleef(d0), vsel_vf2_vo_vf2_vf2_sve_sleef(o1, vcast_vf2_d_sve_sleef(d1), vcast_vf2_d_sve_sleef(d2))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_sve_sleef vsel_vf2_vo_vo_vo_d_d_d_d_sve_sleef(vopmask_sve_sleef o0, vopmask_sve_sleef o1, vopmask_sve_sleef o2, double d0, double d1, double d2, double d3) { + return vsel_vf2_vo_vf2_vf2_sve_sleef(o0, vcast_vf2_d_sve_sleef(d0), vsel_vf2_vo_vf2_vf2_sve_sleef(o1, vcast_vf2_d_sve_sleef(d1), vsel_vf2_vo_vf2_vf2_sve_sleef(o2, vcast_vf2_d_sve_sleef(d2), vcast_vf2_d_sve_sleef(d3)))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_sve_sleef vabs_vf2_vf2_sve_sleef(vfloat2_sve_sleef x) { + return vcast_vf2_vf_vf_sve_sleef(vreinterpret_vf_vm_sve_sleef(vxor_vm_vm_vm_sve_sleef(vand_vm_vm_vm_sve_sleef(vreinterpret_vm_vf_sve_sleef(vcast_vf_f_sve_sleef(-0.0)), vreinterpret_vm_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(x))), vreinterpret_vm_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(x)))), + vreinterpret_vf_vm_sve_sleef(vxor_vm_vm_vm_sve_sleef(vand_vm_vm_vm_sve_sleef(vreinterpret_vm_vf_sve_sleef(vcast_vf_f_sve_sleef(-0.0)), vreinterpret_vm_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(x))), vreinterpret_vm_vf_sve_sleef(vf2gety_vf_vf2_sve_sleef(x))))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_sve_sleef vadd_vf_3vf_sve_sleef(vfloat_sve_sleef v0, vfloat_sve_sleef v1, vfloat_sve_sleef v2) { + return vadd_vf_vf_vf_sve_sleef(vadd_vf_vf_vf_sve_sleef(v0, v1), v2); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_sve_sleef vadd_vf_4vf_sve_sleef(vfloat_sve_sleef v0, vfloat_sve_sleef v1, vfloat_sve_sleef v2, vfloat_sve_sleef v3) { + return vadd_vf_3vf_sve_sleef(vadd_vf_vf_vf_sve_sleef(v0, v1), v2, v3); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_sve_sleef vadd_vf_5vf_sve_sleef(vfloat_sve_sleef v0, vfloat_sve_sleef v1, vfloat_sve_sleef v2, vfloat_sve_sleef v3, vfloat_sve_sleef v4) { + return vadd_vf_4vf_sve_sleef(vadd_vf_vf_vf_sve_sleef(v0, v1), v2, v3, v4); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_sve_sleef vadd_vf_6vf_sve_sleef(vfloat_sve_sleef v0, vfloat_sve_sleef v1, vfloat_sve_sleef v2, vfloat_sve_sleef v3, vfloat_sve_sleef v4, vfloat_sve_sleef v5) { + return vadd_vf_5vf_sve_sleef(vadd_vf_vf_vf_sve_sleef(v0, v1), v2, v3, v4, v5); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_sve_sleef vadd_vf_7vf_sve_sleef(vfloat_sve_sleef v0, vfloat_sve_sleef v1, vfloat_sve_sleef v2, vfloat_sve_sleef v3, vfloat_sve_sleef v4, vfloat_sve_sleef v5, vfloat_sve_sleef v6) { + return vadd_vf_6vf_sve_sleef(vadd_vf_vf_vf_sve_sleef(v0, v1), v2, v3, v4, v5, v6); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_sve_sleef vsub_vf_3vf_sve_sleef(vfloat_sve_sleef v0, vfloat_sve_sleef v1, vfloat_sve_sleef v2) { + return vsub_vf_vf_vf_sve_sleef(vsub_vf_vf_vf_sve_sleef(v0, v1), v2); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_sve_sleef vsub_vf_4vf_sve_sleef(vfloat_sve_sleef v0, vfloat_sve_sleef v1, vfloat_sve_sleef v2, vfloat_sve_sleef v3) { + return vsub_vf_3vf_sve_sleef(vsub_vf_vf_vf_sve_sleef(v0, v1), v2, v3); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_sve_sleef vsub_vf_5vf_sve_sleef(vfloat_sve_sleef v0, vfloat_sve_sleef v1, vfloat_sve_sleef v2, vfloat_sve_sleef v3, vfloat_sve_sleef v4) { + return vsub_vf_4vf_sve_sleef(vsub_vf_vf_vf_sve_sleef(v0, v1), v2, v3, v4); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_sve_sleef dfneg_vf2_vf2_sve_sleef(vfloat2_sve_sleef x) { + return vcast_vf2_vf_vf_sve_sleef(vneg_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(x)), vneg_vf_vf_sve_sleef(vf2gety_vf_vf2_sve_sleef(x))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_sve_sleef dfabs_vf2_vf2_sve_sleef(vfloat2_sve_sleef x) { + return vcast_vf2_vf_vf_sve_sleef(vabs_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(x)), + vreinterpret_vf_vm_sve_sleef(vxor_vm_vm_vm_sve_sleef(vreinterpret_vm_vf_sve_sleef(vf2gety_vf_vf2_sve_sleef(x)), vand_vm_vm_vm_sve_sleef(vreinterpret_vm_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(x)), vreinterpret_vm_vf_sve_sleef(vcast_vf_f_sve_sleef(-0.0f)))))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_sve_sleef dfnormalize_vf2_vf2_sve_sleef(vfloat2_sve_sleef t) { + vfloat_sve_sleef s = vadd_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(t), vf2gety_vf_vf2_sve_sleef(t)); + return vf2setxy_vf2_vf_vf_sve_sleef(s, vadd_vf_vf_vf_sve_sleef(vsub_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(t), s), vf2gety_vf_vf2_sve_sleef(t))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_sve_sleef dfscale_vf2_vf2_vf_sve_sleef(vfloat2_sve_sleef d, vfloat_sve_sleef s) { + return vf2setxy_vf2_vf_vf_sve_sleef(vmul_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(d), s), vmul_vf_vf_vf_sve_sleef(vf2gety_vf_vf2_sve_sleef(d), s)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_sve_sleef dfadd_vf2_vf_vf_sve_sleef(vfloat_sve_sleef x, vfloat_sve_sleef y) { + vfloat_sve_sleef s = vadd_vf_vf_vf_sve_sleef(x, y); + return vf2setxy_vf2_vf_vf_sve_sleef(s, vadd_vf_vf_vf_sve_sleef(vsub_vf_vf_vf_sve_sleef(x, s), y)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_sve_sleef dfadd2_vf2_vf_vf_sve_sleef(vfloat_sve_sleef x, vfloat_sve_sleef y) { + vfloat_sve_sleef s = vadd_vf_vf_vf_sve_sleef(x, y); + vfloat_sve_sleef v = vsub_vf_vf_vf_sve_sleef(s, x); + return vf2setxy_vf2_vf_vf_sve_sleef(s, vadd_vf_vf_vf_sve_sleef(vsub_vf_vf_vf_sve_sleef(x, vsub_vf_vf_vf_sve_sleef(s, v)), vsub_vf_vf_vf_sve_sleef(y, v))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_sve_sleef dfadd2_vf2_vf_vf2_sve_sleef(vfloat_sve_sleef x, vfloat2_sve_sleef y) { + vfloat_sve_sleef s = vadd_vf_vf_vf_sve_sleef(x, vf2getx_vf_vf2_sve_sleef(y)); + vfloat_sve_sleef v = vsub_vf_vf_vf_sve_sleef(s, x); + return vf2setxy_vf2_vf_vf_sve_sleef(s, vadd_vf_vf_vf_sve_sleef(vadd_vf_vf_vf_sve_sleef(vsub_vf_vf_vf_sve_sleef(x, vsub_vf_vf_vf_sve_sleef(s, v)), vsub_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(y), v)), vf2gety_vf_vf2_sve_sleef(y))); + +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_sve_sleef dfadd_vf2_vf2_vf_sve_sleef(vfloat2_sve_sleef x, vfloat_sve_sleef y) { + vfloat_sve_sleef s = vadd_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(x), y); + return vf2setxy_vf2_vf_vf_sve_sleef(s, vadd_vf_3vf_sve_sleef(vsub_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(x), s), y, vf2gety_vf_vf2_sve_sleef(x))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_sve_sleef dfsub_vf2_vf2_vf_sve_sleef(vfloat2_sve_sleef x, vfloat_sve_sleef y) { + vfloat_sve_sleef s = vsub_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(x), y); + return vf2setxy_vf2_vf_vf_sve_sleef(s, vadd_vf_vf_vf_sve_sleef(vsub_vf_vf_vf_sve_sleef(vsub_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(x), s), y), vf2gety_vf_vf2_sve_sleef(x))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_sve_sleef dfadd2_vf2_vf2_vf_sve_sleef(vfloat2_sve_sleef x, vfloat_sve_sleef y) { + vfloat_sve_sleef s = vadd_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(x), y); + vfloat_sve_sleef v = vsub_vf_vf_vf_sve_sleef(s, vf2getx_vf_vf2_sve_sleef(x)); + vfloat_sve_sleef t = vadd_vf_vf_vf_sve_sleef(vsub_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(x), vsub_vf_vf_vf_sve_sleef(s, v)), vsub_vf_vf_vf_sve_sleef(y, v)); + return vf2setxy_vf2_vf_vf_sve_sleef(s, vadd_vf_vf_vf_sve_sleef(t, vf2gety_vf_vf2_sve_sleef(x))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_sve_sleef dfadd_vf2_vf_vf2_sve_sleef(vfloat_sve_sleef x, vfloat2_sve_sleef y) { + vfloat_sve_sleef s = vadd_vf_vf_vf_sve_sleef(x, vf2getx_vf_vf2_sve_sleef(y)); + return vf2setxy_vf2_vf_vf_sve_sleef(s, vadd_vf_3vf_sve_sleef(vsub_vf_vf_vf_sve_sleef(x, s), vf2getx_vf_vf2_sve_sleef(y), vf2gety_vf_vf2_sve_sleef(y))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_sve_sleef dfadd_vf2_vf2_vf2_sve_sleef(vfloat2_sve_sleef x, vfloat2_sve_sleef y) { + + vfloat_sve_sleef s = vadd_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(x), vf2getx_vf_vf2_sve_sleef(y)); + return vf2setxy_vf2_vf_vf_sve_sleef(s, vadd_vf_4vf_sve_sleef(vsub_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(x), s), vf2getx_vf_vf2_sve_sleef(y), vf2gety_vf_vf2_sve_sleef(x), vf2gety_vf_vf2_sve_sleef(y))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_sve_sleef dfadd2_vf2_vf2_vf2_sve_sleef(vfloat2_sve_sleef x, vfloat2_sve_sleef y) { + vfloat_sve_sleef s = vadd_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(x), vf2getx_vf_vf2_sve_sleef(y)); + vfloat_sve_sleef v = vsub_vf_vf_vf_sve_sleef(s, vf2getx_vf_vf2_sve_sleef(x)); + vfloat_sve_sleef t = vadd_vf_vf_vf_sve_sleef(vsub_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(x), vsub_vf_vf_vf_sve_sleef(s, v)), vsub_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(y), v)); + return vf2setxy_vf2_vf_vf_sve_sleef(s, vadd_vf_vf_vf_sve_sleef(t, vadd_vf_vf_vf_sve_sleef(vf2gety_vf_vf2_sve_sleef(x), vf2gety_vf_vf2_sve_sleef(y)))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_sve_sleef dfsub_vf2_vf_vf_sve_sleef(vfloat_sve_sleef x, vfloat_sve_sleef y) { + + vfloat_sve_sleef s = vsub_vf_vf_vf_sve_sleef(x, y); + return vf2setxy_vf2_vf_vf_sve_sleef(s, vsub_vf_vf_vf_sve_sleef(vsub_vf_vf_vf_sve_sleef(x, s), y)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_sve_sleef dfsub_vf2_vf2_vf2_sve_sleef(vfloat2_sve_sleef x, vfloat2_sve_sleef y) { + + vfloat_sve_sleef s = vsub_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(x), vf2getx_vf_vf2_sve_sleef(y)); + vfloat_sve_sleef t = vsub_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(x), s); + t = vsub_vf_vf_vf_sve_sleef(t, vf2getx_vf_vf2_sve_sleef(y)); + t = vadd_vf_vf_vf_sve_sleef(t, vf2gety_vf_vf2_sve_sleef(x)); + return vf2setxy_vf2_vf_vf_sve_sleef(s, vsub_vf_vf_vf_sve_sleef(t, vf2gety_vf_vf2_sve_sleef(y))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_sve_sleef dfdiv_vf2_vf2_vf2_sve_sleef(vfloat2_sve_sleef n, vfloat2_sve_sleef d) { + vfloat_sve_sleef t = vrec_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(d)); + vfloat_sve_sleef s = vmul_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(n), t); + vfloat_sve_sleef u = vfmapn_vf_vf_vf_vf_sve_sleef(t, vf2getx_vf_vf2_sve_sleef(n), s); + vfloat_sve_sleef v = vfmanp_vf_vf_vf_vf_sve_sleef(vf2gety_vf_vf2_sve_sleef(d), t, vfmanp_vf_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(d), t, vcast_vf_f_sve_sleef(1))); + return vf2setxy_vf2_vf_vf_sve_sleef(s, vfma_vf_vf_vf_vf_sve_sleef(s, v, vfma_vf_vf_vf_vf_sve_sleef(vf2gety_vf_vf2_sve_sleef(n), t, u))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_sve_sleef dfmul_vf2_vf_vf_sve_sleef(vfloat_sve_sleef x, vfloat_sve_sleef y) { + vfloat_sve_sleef s = vmul_vf_vf_vf_sve_sleef(x, y); + return vf2setxy_vf2_vf_vf_sve_sleef(s, vfmapn_vf_vf_vf_vf_sve_sleef(x, y, s)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_sve_sleef dfsqu_vf2_vf2_sve_sleef(vfloat2_sve_sleef x) { + vfloat_sve_sleef s = vmul_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(x), vf2getx_vf_vf2_sve_sleef(x)); + return vf2setxy_vf2_vf_vf_sve_sleef(s, vfma_vf_vf_vf_vf_sve_sleef(vadd_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(x), vf2getx_vf_vf2_sve_sleef(x)), vf2gety_vf_vf2_sve_sleef(x), vfmapn_vf_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(x), vf2getx_vf_vf2_sve_sleef(x), s))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_sve_sleef dfsqu_vf_vf2_sve_sleef(vfloat2_sve_sleef x) { + return vfma_vf_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(x), vf2getx_vf_vf2_sve_sleef(x), vadd_vf_vf_vf_sve_sleef(vmul_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(x), vf2gety_vf_vf2_sve_sleef(x)), vmul_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(x), vf2gety_vf_vf2_sve_sleef(x)))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_sve_sleef dfmul_vf2_vf2_vf2_sve_sleef(vfloat2_sve_sleef x, vfloat2_sve_sleef y) { + vfloat_sve_sleef s = vmul_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(x), vf2getx_vf_vf2_sve_sleef(y)); + return vf2setxy_vf2_vf_vf_sve_sleef(s, vfma_vf_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(x), vf2gety_vf_vf2_sve_sleef(y), vfma_vf_vf_vf_vf_sve_sleef(vf2gety_vf_vf2_sve_sleef(x), vf2getx_vf_vf2_sve_sleef(y), vfmapn_vf_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(x), vf2getx_vf_vf2_sve_sleef(y), s)))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_sve_sleef dfmul_vf_vf2_vf2_sve_sleef(vfloat2_sve_sleef x, vfloat2_sve_sleef y) { + return vfma_vf_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(x), vf2getx_vf_vf2_sve_sleef(y), vfma_vf_vf_vf_vf_sve_sleef(vf2gety_vf_vf2_sve_sleef(x), vf2getx_vf_vf2_sve_sleef(y), vmul_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(x), vf2gety_vf_vf2_sve_sleef(y)))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_sve_sleef dfmul_vf2_vf2_vf_sve_sleef(vfloat2_sve_sleef x, vfloat_sve_sleef y) { + vfloat_sve_sleef s = vmul_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(x), y); + return vf2setxy_vf2_vf_vf_sve_sleef(s, vfma_vf_vf_vf_vf_sve_sleef(vf2gety_vf_vf2_sve_sleef(x), y, vfmapn_vf_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(x), y, s))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_sve_sleef dfrec_vf2_vf_sve_sleef(vfloat_sve_sleef d) { + vfloat_sve_sleef s = vrec_vf_vf_sve_sleef(d); + return vf2setxy_vf2_vf_vf_sve_sleef(s, vmul_vf_vf_vf_sve_sleef(s, vfmanp_vf_vf_vf_vf_sve_sleef(d, s, vcast_vf_f_sve_sleef(1)))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_sve_sleef dfrec_vf2_vf2_sve_sleef(vfloat2_sve_sleef d) { + vfloat_sve_sleef s = vrec_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(d)); + return vf2setxy_vf2_vf_vf_sve_sleef(s, vmul_vf_vf_vf_sve_sleef(s, vfmanp_vf_vf_vf_vf_sve_sleef(vf2gety_vf_vf2_sve_sleef(d), s, vfmanp_vf_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(d), s, vcast_vf_f_sve_sleef(1))))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_sve_sleef dfsqrt_vf2_vf2_sve_sleef(vfloat2_sve_sleef d) { + + vfloat_sve_sleef t = vsqrt_vf_vf_sve_sleef(vadd_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(d), vf2gety_vf_vf2_sve_sleef(d))); + return dfscale_vf2_vf2_vf_sve_sleef(dfmul_vf2_vf2_vf2_sve_sleef(dfadd2_vf2_vf2_vf2_sve_sleef(d, dfmul_vf2_vf_vf_sve_sleef(t, t)), dfrec_vf2_vf_sve_sleef(t)), vcast_vf_f_sve_sleef(0.5)); + +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_sve_sleef dfsqrt_vf2_vf_sve_sleef(vfloat_sve_sleef d) { + vfloat_sve_sleef t = vsqrt_vf_vf_sve_sleef(d); + return dfscale_vf2_vf2_vf_sve_sleef(dfmul_vf2_vf2_vf2_sve_sleef(dfadd2_vf2_vf_vf2_sve_sleef(d, dfmul_vf2_vf_vf_sve_sleef(t, t)), dfrec_vf2_vf_sve_sleef(t)), vcast_vf_f_sve_sleef(0.5f)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vopmask_sve_sleef visnegzero_vo_vf_sve_sleef(vfloat_sve_sleef d) { + return veq_vo_vi2_vi2_sve_sleef(vreinterpret_vi2_vf_sve_sleef(d), vreinterpret_vi2_vf_sve_sleef(vcast_vf_f_sve_sleef(-0.0))); +} + +static SLEEF_ALWAYS_INLINE vopmask_sve_sleef vnot_vo32_vo32_sve_sleef(vopmask_sve_sleef x) { + return vxor_vo_vo_vo_sve_sleef(x, veq_vo_vi2_vi2_sve_sleef(vcast_vi2_i_sve_sleef(0), vcast_vi2_i_sve_sleef(0))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vmask_sve_sleef vsignbit_vm_vf_sve_sleef(vfloat_sve_sleef f) { + return vand_vm_vm_vm_sve_sleef(vreinterpret_vm_vf_sve_sleef(f), vreinterpret_vm_vf_sve_sleef(vcast_vf_f_sve_sleef(-0.0f))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_sve_sleef vmulsign_vf_vf_vf_sve_sleef(vfloat_sve_sleef x, vfloat_sve_sleef y) { + return vreinterpret_vf_vm_sve_sleef(vxor_vm_vm_vm_sve_sleef(vreinterpret_vm_vf_sve_sleef(x), vsignbit_vm_vf_sve_sleef(y))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_sve_sleef vcopysign_vf_vf_vf_sve_sleef(vfloat_sve_sleef x, vfloat_sve_sleef y) { + return vreinterpret_vf_vm_sve_sleef(vxor_vm_vm_vm_sve_sleef(vandnot_vm_vm_vm_sve_sleef(vreinterpret_vm_vf_sve_sleef(vcast_vf_f_sve_sleef(-0.0f)), vreinterpret_vm_vf_sve_sleef(x)), + vand_vm_vm_vm_sve_sleef (vreinterpret_vm_vf_sve_sleef(vcast_vf_f_sve_sleef(-0.0f)), vreinterpret_vm_vf_sve_sleef(y)))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_sve_sleef vsign_vf_vf_sve_sleef(vfloat_sve_sleef f) { + return vreinterpret_vf_vm_sve_sleef(vor_vm_vm_vm_sve_sleef(vreinterpret_vm_vf_sve_sleef(vcast_vf_f_sve_sleef(1.0f)), vand_vm_vm_vm_sve_sleef(vreinterpret_vm_vf_sve_sleef(vcast_vf_f_sve_sleef(-0.0f)), vreinterpret_vm_vf_sve_sleef(f)))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vopmask_sve_sleef vsignbit_vo_vf_sve_sleef(vfloat_sve_sleef d) { + return veq_vo_vi2_vi2_sve_sleef(vand_vi2_vi2_vi2_sve_sleef(vreinterpret_vi2_vf_sve_sleef(d), vcast_vi2_i_sve_sleef(0x80000000)), vcast_vi2_i_sve_sleef(0x80000000)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vint2_sve_sleef vsel_vi2_vf_vf_vi2_vi2_sve_sleef(vfloat_sve_sleef f0, vfloat_sve_sleef f1, vint2_sve_sleef x, vint2_sve_sleef y) { + return vsel_vi2_vo_vi2_vi2_sve_sleef(vlt_vo_vf_vf_sve_sleef(f0, f1), x, y); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vint2_sve_sleef vsel_vi2_vf_vi2_sve_sleef(vfloat_sve_sleef d, vint2_sve_sleef x) { + return vand_vi2_vo_vi2_sve_sleef(vsignbit_vo_vf_sve_sleef(d), x); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vopmask_sve_sleef visint_vo_vf_sve_sleef(vfloat_sve_sleef y) { return veq_vo_vf_vf_sve_sleef(vtruncate_vf_vf_sve_sleef(y), y); } + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vopmask_sve_sleef visnumber_vo_vf_sve_sleef(vfloat_sve_sleef x) { return vnot_vo32_vo32_sve_sleef(vor_vo_vo_vo_sve_sleef(visinf_vo_vf_sve_sleef(x), visnan_vo_vf_sve_sleef(x))); } + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vint2_sve_sleef vilogbk_vi2_vf_sve_sleef(vfloat_sve_sleef d) { + vopmask_sve_sleef o = vlt_vo_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(5.421010862427522E-20f)); + d = vsel_vf_vo_vf_vf_sve_sleef(o, vmul_vf_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(1.8446744073709552E19f), d), d); + vint2_sve_sleef q = vand_vi2_vi2_vi2_sve_sleef(svreinterpret_s32_u32(svlsr_n_u32_x(svptrue_b8(), svreinterpret_u32_s32(vreinterpret_vi2_vf_sve_sleef(d)), 23)), vcast_vi2_i_sve_sleef(0xff)); + q = vsub_vi2_vi2_vi2_sve_sleef(q, vsel_vi2_vo_vi2_vi2_sve_sleef(o, vcast_vi2_i_sve_sleef(64 + 0x7f), vcast_vi2_i_sve_sleef(0x7f))); + return q; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vint2_sve_sleef vilogb2k_vi2_vf_sve_sleef(vfloat_sve_sleef d) { + vint2_sve_sleef q = vreinterpret_vi2_vf_sve_sleef(d); + q = svreinterpret_s32_u32(svlsr_n_u32_x(svptrue_b8(), svreinterpret_u32_s32(q), 23)); + q = vand_vi2_vi2_vi2_sve_sleef(q, vcast_vi2_i_sve_sleef(0xff)); + q = vsub_vi2_vi2_vi2_sve_sleef(q, vcast_vi2_i_sve_sleef(0x7f)); + return q; +} + +SLEEF_INLINE SLEEF_CONST vint2_sve_sleef Sleef_ilogbfx_sve(vfloat_sve_sleef d) { + vint2_sve_sleef e = vilogbk_vi2_vf_sve_sleef(vabs_vf_vf_sve_sleef(d)); + e = vsel_vi2_vo_vi2_vi2_sve_sleef(veq_vo_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(0.0f)), vcast_vi2_i_sve_sleef(SLEEF_FP_ILOGB0), e); + e = vsel_vi2_vo_vi2_vi2_sve_sleef(visnan_vo_vf_sve_sleef(d), vcast_vi2_i_sve_sleef(SLEEF_FP_ILOGBNAN), e); + e = vsel_vi2_vo_vi2_vi2_sve_sleef(visinf_vo_vf_sve_sleef(d), vcast_vi2_i_sve_sleef(2147483647), e); + return e; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_sve_sleef vpow2i_vf_vi2_sve_sleef(vint2_sve_sleef q) { + return vreinterpret_vf_vi2_sve_sleef(svlsl_n_s32_x(svptrue_b8(), vadd_vi2_vi2_vi2_sve_sleef(q, vcast_vi2_i_sve_sleef(0x7f)), 23)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_sve_sleef vldexp_vf_vf_vi2_sve_sleef(vfloat_sve_sleef x, vint2_sve_sleef q) { + vfloat_sve_sleef u; + vint2_sve_sleef m = svasr_n_s32_x(svptrue_b8(), q, 31); + m = svlsl_n_s32_x(svptrue_b8(), vsub_vi2_vi2_vi2_sve_sleef(svasr_n_s32_x(svptrue_b8(), vadd_vi2_vi2_vi2_sve_sleef(m, q), 6), m), 4); + q = vsub_vi2_vi2_vi2_sve_sleef(q, svlsl_n_s32_x(svptrue_b8(), m, 2)); + m = vadd_vi2_vi2_vi2_sve_sleef(m, vcast_vi2_i_sve_sleef(0x7f)); + m = vand_vi2_vi2_vi2_sve_sleef(vgt_vi2_vi2_vi2_sve_sleef(m, vcast_vi2_i_sve_sleef(0)), m); + vint2_sve_sleef n = vgt_vi2_vi2_vi2_sve_sleef(m, vcast_vi2_i_sve_sleef(0xff)); + m = vor_vi2_vi2_vi2_sve_sleef(vandnot_vi2_vi2_vi2_sve_sleef(n, m), vand_vi2_vi2_vi2_sve_sleef(n, vcast_vi2_i_sve_sleef(0xff))); + u = vreinterpret_vf_vi2_sve_sleef(svlsl_n_s32_x(svptrue_b8(), m, 23)); + x = vmul_vf_vf_vf_sve_sleef(vmul_vf_vf_vf_sve_sleef(vmul_vf_vf_vf_sve_sleef(vmul_vf_vf_vf_sve_sleef(x, u), u), u), u); + u = vreinterpret_vf_vi2_sve_sleef(svlsl_n_s32_x(svptrue_b8(), vadd_vi2_vi2_vi2_sve_sleef(q, vcast_vi2_i_sve_sleef(0x7f)), 23)); + return vmul_vf_vf_vf_sve_sleef(x, u); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_sve_sleef vldexp2_vf_vf_vi2_sve_sleef(vfloat_sve_sleef d, vint2_sve_sleef e) { + return vmul_vf_vf_vf_sve_sleef(vmul_vf_vf_vf_sve_sleef(d, vpow2i_vf_vi2_sve_sleef(svasr_n_s32_x(svptrue_b8(), e, 1))), vpow2i_vf_vi2_sve_sleef(vsub_vi2_vi2_vi2_sve_sleef(e, svasr_n_s32_x(svptrue_b8(), e, 1)))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_sve_sleef vldexp3_vf_vf_vi2_sve_sleef(vfloat_sve_sleef d, vint2_sve_sleef q) { + return vreinterpret_vf_vi2_sve_sleef(vadd_vi2_vi2_vi2_sve_sleef(vreinterpret_vi2_vf_sve_sleef(d), svlsl_n_s32_x(svptrue_b8(), q, 23))); +} + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_ldexpfx_sve(vfloat_sve_sleef x, vint2_sve_sleef q) { return vldexp_vf_vf_vi2_sve_sleef(x, q); } + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_sve_sleef vorsign_vf_vf_vf_sve_sleef(vfloat_sve_sleef x, vfloat_sve_sleef y) { + return vreinterpret_vf_vm_sve_sleef(vor_vm_vm_vm_sve_sleef(vreinterpret_vm_vf_sve_sleef(x), vsignbit_vm_vf_sve_sleef(y))); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST fi_t_sve_sleef rempisubf_sve_sleef(vfloat_sve_sleef x) { + + vfloat_sve_sleef y = vrint_vf_vf_sve_sleef(vmul_vf_vf_vf_sve_sleef(x, vcast_vf_f_sve_sleef(4))); + vint2_sve_sleef vi = vtruncate_vi2_vf_sve_sleef(vsub_vf_vf_vf_sve_sleef(y, vmul_vf_vf_vf_sve_sleef(vrint_vf_vf_sve_sleef(x), vcast_vf_f_sve_sleef(4)))); + return fisetdi_fi_vf_vi2_sve_sleef(vsub_vf_vf_vf_sve_sleef(x, vmul_vf_vf_vf_sve_sleef(y, vcast_vf_f_sve_sleef(0.25))), vi); + +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST dfi_t_sve_sleef rempif_sve_sleef(vfloat_sve_sleef a) { + vfloat2_sve_sleef x, y; + vint2_sve_sleef ex = vilogb2k_vi2_vf_sve_sleef(a); + + ex = vsub_vi2_vi2_vi2_sve_sleef(ex, vcast_vi2_i_sve_sleef(25)); + vint2_sve_sleef q = vand_vi2_vo_vi2_sve_sleef(vgt_vo_vi2_vi2_sve_sleef(ex, vcast_vi2_i_sve_sleef(90-25)), vcast_vi2_i_sve_sleef(-64)); + a = vldexp3_vf_vf_vi2_sve_sleef(a, q); + ex = vandnot_vi2_vi2_vi2_sve_sleef(svasr_n_s32_x(svptrue_b8(), ex, 31), ex); + ex = svlsl_n_s32_x(svptrue_b8(), ex, 2); + x = dfmul_vf2_vf_vf_sve_sleef(a, vgather_vf_p_vi2_sve_sleef(Sleef_rempitabsp, ex)); + fi_t_sve_sleef di = rempisubf_sve_sleef(vf2getx_vf_vf2_sve_sleef(x)); + q = figeti_vi2_di_sve_sleef(di); + x = vf2setx_vf2_vf2_vf_sve_sleef(x, figetd_vf_di_sve_sleef(di)); + x = dfnormalize_vf2_vf2_sve_sleef(x); + y = dfmul_vf2_vf_vf_sve_sleef(a, vgather_vf_p_vi2_sve_sleef(Sleef_rempitabsp+1, ex)); + x = dfadd2_vf2_vf2_vf2_sve_sleef(x, y); + di = rempisubf_sve_sleef(vf2getx_vf_vf2_sve_sleef(x)); + q = vadd_vi2_vi2_vi2_sve_sleef(q, figeti_vi2_di_sve_sleef(di)); + x = vf2setx_vf2_vf2_vf_sve_sleef(x, figetd_vf_di_sve_sleef(di)); + x = dfnormalize_vf2_vf2_sve_sleef(x); + y = vcast_vf2_vf_vf_sve_sleef(vgather_vf_p_vi2_sve_sleef(Sleef_rempitabsp+2, ex), vgather_vf_p_vi2_sve_sleef(Sleef_rempitabsp+3, ex)); + y = dfmul_vf2_vf2_vf_sve_sleef(y, a); + x = dfadd2_vf2_vf2_vf2_sve_sleef(x, y); + x = dfnormalize_vf2_vf2_sve_sleef(x); + x = dfmul_vf2_vf2_vf2_sve_sleef(x, vcast_vf2_f_f_sve_sleef(3.1415927410125732422f*2, -8.7422776573475857731e-08f*2)); + x = vsel_vf2_vo_vf2_vf2_sve_sleef(vlt_vo_vf_vf_sve_sleef(vabs_vf_vf_sve_sleef(a), vcast_vf_f_sve_sleef(0.7f)), vcast_vf2_vf_vf_sve_sleef(a, vcast_vf_f_sve_sleef(0)), x); + return dfisetdfi_dfi_vf2_vi2_sve_sleef(x, q); +} + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_sinfx_u35sve(vfloat_sve_sleef d) { + + vint2_sve_sleef q; + vfloat_sve_sleef u, s, r = d; + + if (__builtin_expect(!!(vtestallones_i_vo32_sve_sleef(vlt_vo_vf_vf_sve_sleef(vabs_vf_vf_sve_sleef(d), vcast_vf_f_sve_sleef(125.0f)))), 1)) { + q = vrint_vi2_vf_sve_sleef(vmul_vf_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef((float)0.318309886183790671537767526745028724))); + u = vcast_vf_vi2_sve_sleef(q); + d = vmla_vf_vf_vf_vf_sve_sleef(u, vcast_vf_f_sve_sleef(-3.1414794921875f), d); + d = vmla_vf_vf_vf_vf_sve_sleef(u, vcast_vf_f_sve_sleef(-0.00011315941810607910156f), d); + d = vmla_vf_vf_vf_vf_sve_sleef(u, vcast_vf_f_sve_sleef(-1.9841872589410058936e-09f), d); + } else if (__builtin_expect(!!(vtestallones_i_vo32_sve_sleef(vlt_vo_vf_vf_sve_sleef(vabs_vf_vf_sve_sleef(d), vcast_vf_f_sve_sleef(39000)))), 1)) { + q = vrint_vi2_vf_sve_sleef(vmul_vf_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef((float)0.318309886183790671537767526745028724))); + u = vcast_vf_vi2_sve_sleef(q); + d = vmla_vf_vf_vf_vf_sve_sleef(u, vcast_vf_f_sve_sleef(-3.140625f), d); + d = vmla_vf_vf_vf_vf_sve_sleef(u, vcast_vf_f_sve_sleef(-0.0009670257568359375f), d); + d = vmla_vf_vf_vf_vf_sve_sleef(u, vcast_vf_f_sve_sleef(-6.2771141529083251953e-07f), d); + d = vmla_vf_vf_vf_vf_sve_sleef(u, vcast_vf_f_sve_sleef(-1.2154201256553420762e-10f), d); + } else { + dfi_t_sve_sleef dfi_sve_sleef = rempif_sve_sleef(d); + q = vand_vi2_vi2_vi2_sve_sleef(dfigeti_vi2_dfi_sve_sleef(dfi_sve_sleef), vcast_vi2_i_sve_sleef(3)); + q = vadd_vi2_vi2_vi2_sve_sleef(vadd_vi2_vi2_vi2_sve_sleef(q, q), vsel_vi2_vo_vi2_vi2_sve_sleef(vgt_vo_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(dfigetdf_vf2_dfi_sve_sleef(dfi_sve_sleef)), vcast_vf_f_sve_sleef(0)), vcast_vi2_i_sve_sleef(2), vcast_vi2_i_sve_sleef(1))); + q = svasr_n_s32_x(svptrue_b8(), q, 2); + vopmask_sve_sleef o = veq_vo_vi2_vi2_sve_sleef(vand_vi2_vi2_vi2_sve_sleef(dfigeti_vi2_dfi_sve_sleef(dfi_sve_sleef), vcast_vi2_i_sve_sleef(1)), vcast_vi2_i_sve_sleef(1)); + vfloat2_sve_sleef x = vcast_vf2_vf_vf_sve_sleef(vmulsign_vf_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(3.1415927410125732422f*-0.5), vf2getx_vf_vf2_sve_sleef(dfigetdf_vf2_dfi_sve_sleef(dfi_sve_sleef))), + vmulsign_vf_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(-8.7422776573475857731e-08f*-0.5), vf2getx_vf_vf2_sve_sleef(dfigetdf_vf2_dfi_sve_sleef(dfi_sve_sleef)))); + x = dfadd2_vf2_vf2_vf2_sve_sleef(dfigetdf_vf2_dfi_sve_sleef(dfi_sve_sleef), x); + dfi_sve_sleef = dfisetdf_dfi_dfi_vf2_sve_sleef(dfi_sve_sleef, vsel_vf2_vo_vf2_vf2_sve_sleef(o, x, dfigetdf_vf2_dfi_sve_sleef(dfi_sve_sleef))); + d = vadd_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(dfigetdf_vf2_dfi_sve_sleef(dfi_sve_sleef)), vf2gety_vf_vf2_sve_sleef(dfigetdf_vf2_dfi_sve_sleef(dfi_sve_sleef))); + + d = vreinterpret_vf_vm_sve_sleef(vor_vm_vo32_vm_sve_sleef(vor_vo_vo_vo_sve_sleef(visinf_vo_vf_sve_sleef(r), visnan_vo_vf_sve_sleef(r)), vreinterpret_vm_vf_sve_sleef(d))); + } + + s = vmul_vf_vf_vf_sve_sleef(d, d); + + d = vreinterpret_vf_vm_sve_sleef(vxor_vm_vm_vm_sve_sleef(vand_vm_vo32_vm_sve_sleef(veq_vo_vi2_vi2_sve_sleef(vand_vi2_vi2_vi2_sve_sleef(q, vcast_vi2_i_sve_sleef(1)), vcast_vi2_i_sve_sleef(1)), vreinterpret_vm_vf_sve_sleef(vcast_vf_f_sve_sleef(-0.0f))), vreinterpret_vm_vf_sve_sleef(d))); + + u = vcast_vf_f_sve_sleef(2.6083159809786593541503e-06f); + u = vmla_vf_vf_vf_vf_sve_sleef(u, s, vcast_vf_f_sve_sleef(-0.0001981069071916863322258f)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, s, vcast_vf_f_sve_sleef(0.00833307858556509017944336f)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, s, vcast_vf_f_sve_sleef(-0.166666597127914428710938f)); + + u = vadd_vf_vf_vf_sve_sleef(vmul_vf_vf_vf_sve_sleef(s, vmul_vf_vf_vf_sve_sleef(u, d)), d); + + u = vsel_vf_vo_vf_vf_sve_sleef(visnegzero_vo_vf_sve_sleef(r), r, u); + + return u; + +} + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_cosfx_u35sve(vfloat_sve_sleef d) { + + vint2_sve_sleef q; + vfloat_sve_sleef u, s, r = d; + + if (__builtin_expect(!!(vtestallones_i_vo32_sve_sleef(vlt_vo_vf_vf_sve_sleef(vabs_vf_vf_sve_sleef(d), vcast_vf_f_sve_sleef(125.0f)))), 1)) { + q = vrint_vi2_vf_sve_sleef(vsub_vf_vf_vf_sve_sleef(vmul_vf_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef((float)0.318309886183790671537767526745028724)), vcast_vf_f_sve_sleef(0.5f))); + q = vadd_vi2_vi2_vi2_sve_sleef(vadd_vi2_vi2_vi2_sve_sleef(q, q), vcast_vi2_i_sve_sleef(1)); + + u = vcast_vf_vi2_sve_sleef(q); + d = vmla_vf_vf_vf_vf_sve_sleef(u, vcast_vf_f_sve_sleef(-3.1414794921875f*0.5f), d); + d = vmla_vf_vf_vf_vf_sve_sleef(u, vcast_vf_f_sve_sleef(-0.00011315941810607910156f*0.5f), d); + d = vmla_vf_vf_vf_vf_sve_sleef(u, vcast_vf_f_sve_sleef(-1.9841872589410058936e-09f*0.5f), d); + } else if (__builtin_expect(!!(vtestallones_i_vo32_sve_sleef(vlt_vo_vf_vf_sve_sleef(vabs_vf_vf_sve_sleef(d), vcast_vf_f_sve_sleef(39000)))), 1)) { + q = vrint_vi2_vf_sve_sleef(vsub_vf_vf_vf_sve_sleef(vmul_vf_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef((float)0.318309886183790671537767526745028724)), vcast_vf_f_sve_sleef(0.5f))); + q = vadd_vi2_vi2_vi2_sve_sleef(vadd_vi2_vi2_vi2_sve_sleef(q, q), vcast_vi2_i_sve_sleef(1)); + + u = vcast_vf_vi2_sve_sleef(q); + d = vmla_vf_vf_vf_vf_sve_sleef(u, vcast_vf_f_sve_sleef(-3.140625f*0.5f), d); + d = vmla_vf_vf_vf_vf_sve_sleef(u, vcast_vf_f_sve_sleef(-0.0009670257568359375f*0.5f), d); + d = vmla_vf_vf_vf_vf_sve_sleef(u, vcast_vf_f_sve_sleef(-6.2771141529083251953e-07f*0.5f), d); + d = vmla_vf_vf_vf_vf_sve_sleef(u, vcast_vf_f_sve_sleef(-1.2154201256553420762e-10f*0.5f), d); + } else { + dfi_t_sve_sleef dfi_sve_sleef = rempif_sve_sleef(d); + q = vand_vi2_vi2_vi2_sve_sleef(dfigeti_vi2_dfi_sve_sleef(dfi_sve_sleef), vcast_vi2_i_sve_sleef(3)); + q = vadd_vi2_vi2_vi2_sve_sleef(vadd_vi2_vi2_vi2_sve_sleef(q, q), vsel_vi2_vo_vi2_vi2_sve_sleef(vgt_vo_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(dfigetdf_vf2_dfi_sve_sleef(dfi_sve_sleef)), vcast_vf_f_sve_sleef(0)), vcast_vi2_i_sve_sleef(8), vcast_vi2_i_sve_sleef(7))); + q = svasr_n_s32_x(svptrue_b8(), q, 1); + vopmask_sve_sleef o = veq_vo_vi2_vi2_sve_sleef(vand_vi2_vi2_vi2_sve_sleef(dfigeti_vi2_dfi_sve_sleef(dfi_sve_sleef), vcast_vi2_i_sve_sleef(1)), vcast_vi2_i_sve_sleef(0)); + vfloat_sve_sleef y = vsel_vf_vo_vf_vf_sve_sleef(vgt_vo_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(dfigetdf_vf2_dfi_sve_sleef(dfi_sve_sleef)), vcast_vf_f_sve_sleef(0)), vcast_vf_f_sve_sleef(0), vcast_vf_f_sve_sleef(-1)); + vfloat2_sve_sleef x = vcast_vf2_vf_vf_sve_sleef(vmulsign_vf_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(3.1415927410125732422f*-0.5), y), + vmulsign_vf_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(-8.7422776573475857731e-08f*-0.5), y)); + x = dfadd2_vf2_vf2_vf2_sve_sleef(dfigetdf_vf2_dfi_sve_sleef(dfi_sve_sleef), x); + dfi_sve_sleef = dfisetdf_dfi_dfi_vf2_sve_sleef(dfi_sve_sleef, vsel_vf2_vo_vf2_vf2_sve_sleef(o, x, dfigetdf_vf2_dfi_sve_sleef(dfi_sve_sleef))); + d = vadd_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(dfigetdf_vf2_dfi_sve_sleef(dfi_sve_sleef)), vf2gety_vf_vf2_sve_sleef(dfigetdf_vf2_dfi_sve_sleef(dfi_sve_sleef))); + + d = vreinterpret_vf_vm_sve_sleef(vor_vm_vo32_vm_sve_sleef(vor_vo_vo_vo_sve_sleef(visinf_vo_vf_sve_sleef(r), visnan_vo_vf_sve_sleef(r)), vreinterpret_vm_vf_sve_sleef(d))); + } + + s = vmul_vf_vf_vf_sve_sleef(d, d); + + d = vreinterpret_vf_vm_sve_sleef(vxor_vm_vm_vm_sve_sleef(vand_vm_vo32_vm_sve_sleef(veq_vo_vi2_vi2_sve_sleef(vand_vi2_vi2_vi2_sve_sleef(q, vcast_vi2_i_sve_sleef(2)), vcast_vi2_i_sve_sleef(0)), vreinterpret_vm_vf_sve_sleef(vcast_vf_f_sve_sleef(-0.0f))), vreinterpret_vm_vf_sve_sleef(d))); + + u = vcast_vf_f_sve_sleef(2.6083159809786593541503e-06f); + u = vmla_vf_vf_vf_vf_sve_sleef(u, s, vcast_vf_f_sve_sleef(-0.0001981069071916863322258f)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, s, vcast_vf_f_sve_sleef(0.00833307858556509017944336f)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, s, vcast_vf_f_sve_sleef(-0.166666597127914428710938f)); + + u = vadd_vf_vf_vf_sve_sleef(vmul_vf_vf_vf_sve_sleef(s, vmul_vf_vf_vf_sve_sleef(u, d)), d); + + return u; + +} + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_tanfx_u35sve(vfloat_sve_sleef d) { + + vint2_sve_sleef q; + vopmask_sve_sleef o; + vfloat_sve_sleef u, s, x; + + x = d; + + if (__builtin_expect(!!(vtestallones_i_vo32_sve_sleef(vlt_vo_vf_vf_sve_sleef(vabs_vf_vf_sve_sleef(d), vcast_vf_f_sve_sleef(125.0f*0.5f)))), 1)) { + q = vrint_vi2_vf_sve_sleef(vmul_vf_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef((float)(2 * 0.318309886183790671537767526745028724)))); + u = vcast_vf_vi2_sve_sleef(q); + x = vmla_vf_vf_vf_vf_sve_sleef(u, vcast_vf_f_sve_sleef(-3.1414794921875f*0.5f), x); + x = vmla_vf_vf_vf_vf_sve_sleef(u, vcast_vf_f_sve_sleef(-0.00011315941810607910156f*0.5f), x); + x = vmla_vf_vf_vf_vf_sve_sleef(u, vcast_vf_f_sve_sleef(-1.9841872589410058936e-09f*0.5f), x); + } else if (__builtin_expect(!!(vtestallones_i_vo32_sve_sleef(vlt_vo_vf_vf_sve_sleef(vabs_vf_vf_sve_sleef(d), vcast_vf_f_sve_sleef(39000)))), 1)) { + q = vrint_vi2_vf_sve_sleef(vmul_vf_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef((float)(2 * 0.318309886183790671537767526745028724)))); + u = vcast_vf_vi2_sve_sleef(q); + x = vmla_vf_vf_vf_vf_sve_sleef(u, vcast_vf_f_sve_sleef(-3.140625f*0.5f), x); + x = vmla_vf_vf_vf_vf_sve_sleef(u, vcast_vf_f_sve_sleef(-0.0009670257568359375f*0.5f), x); + x = vmla_vf_vf_vf_vf_sve_sleef(u, vcast_vf_f_sve_sleef(-6.2771141529083251953e-07f*0.5f), x); + x = vmla_vf_vf_vf_vf_sve_sleef(u, vcast_vf_f_sve_sleef(-1.2154201256553420762e-10f*0.5f), x); + } else { + dfi_t_sve_sleef dfi_sve_sleef = rempif_sve_sleef(d); + q = dfigeti_vi2_dfi_sve_sleef(dfi_sve_sleef); + x = vadd_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(dfigetdf_vf2_dfi_sve_sleef(dfi_sve_sleef)), vf2gety_vf_vf2_sve_sleef(dfigetdf_vf2_dfi_sve_sleef(dfi_sve_sleef))); + x = vreinterpret_vf_vm_sve_sleef(vor_vm_vo32_vm_sve_sleef(vor_vo_vo_vo_sve_sleef(visinf_vo_vf_sve_sleef(d), visnan_vo_vf_sve_sleef(d)), vreinterpret_vm_vf_sve_sleef(x))); + x = vsel_vf_vo_vf_vf_sve_sleef(visnegzero_vo_vf_sve_sleef(d), d, x); + } + + s = vmul_vf_vf_vf_sve_sleef(x, x); + + o = veq_vo_vi2_vi2_sve_sleef(vand_vi2_vi2_vi2_sve_sleef(q, vcast_vi2_i_sve_sleef(1)), vcast_vi2_i_sve_sleef(1)); + x = vreinterpret_vf_vm_sve_sleef(vxor_vm_vm_vm_sve_sleef(vand_vm_vo32_vm_sve_sleef(o, vreinterpret_vm_vf_sve_sleef(vcast_vf_f_sve_sleef(-0.0f))), vreinterpret_vm_vf_sve_sleef(x))); + + vfloat_sve_sleef s2 = vmul_vf_vf_vf_sve_sleef(s, s), s4 = vmul_vf_vf_vf_sve_sleef(s2, s2); + u = vmla_vf_vf_vf_vf_sve_sleef((s4), (vmla_vf_vf_vf_vf_sve_sleef((s), (vcast_vf_f_sve_sleef(0.00927245803177356719970703f)), (vcast_vf_f_sve_sleef(0.00331984995864331722259521f)))), (vmla_vf_vf_vf_vf_sve_sleef((s2), (vmla_vf_vf_vf_vf_sve_sleef((s), (vcast_vf_f_sve_sleef(0.0242998078465461730957031f)), (vcast_vf_f_sve_sleef(0.0534495301544666290283203f)))), (vmla_vf_vf_vf_vf_sve_sleef((s), (vcast_vf_f_sve_sleef(0.133383005857467651367188f)), (vcast_vf_f_sve_sleef(0.333331853151321411132812f))))))) + + ; + + u = vmla_vf_vf_vf_vf_sve_sleef(s, vmul_vf_vf_vf_sve_sleef(u, x), x); + + u = vsel_vf_vo_vf_vf_sve_sleef(o, vrec_vf_vf_sve_sleef(u), u); + + return u; + +} + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_sinfx_u10sve(vfloat_sve_sleef d) { + + vint2_sve_sleef q; + vfloat_sve_sleef u, v; + vfloat2_sve_sleef s, t, x; + + if (__builtin_expect(!!(vtestallones_i_vo32_sve_sleef(vlt_vo_vf_vf_sve_sleef(vabs_vf_vf_sve_sleef(d), vcast_vf_f_sve_sleef(125.0f)))), 1)) { + u = vrint_vf_vf_sve_sleef(vmul_vf_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(0.318309886183790671537767526745028724))); + q = vrint_vi2_vf_sve_sleef(u); + v = vmla_vf_vf_vf_vf_sve_sleef(u, vcast_vf_f_sve_sleef(-3.1414794921875f), d); + s = dfadd2_vf2_vf_vf_sve_sleef(v, vmul_vf_vf_vf_sve_sleef(u, vcast_vf_f_sve_sleef(-0.00011315941810607910156f))); + s = dfadd_vf2_vf2_vf_sve_sleef(s, vmul_vf_vf_vf_sve_sleef(u, vcast_vf_f_sve_sleef(-1.9841872589410058936e-09f))); + } else { + dfi_t_sve_sleef dfi_sve_sleef = rempif_sve_sleef(d); + q = vand_vi2_vi2_vi2_sve_sleef(dfigeti_vi2_dfi_sve_sleef(dfi_sve_sleef), vcast_vi2_i_sve_sleef(3)); + q = vadd_vi2_vi2_vi2_sve_sleef(vadd_vi2_vi2_vi2_sve_sleef(q, q), vsel_vi2_vo_vi2_vi2_sve_sleef(vgt_vo_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(dfigetdf_vf2_dfi_sve_sleef(dfi_sve_sleef)), vcast_vf_f_sve_sleef(0)), vcast_vi2_i_sve_sleef(2), vcast_vi2_i_sve_sleef(1))); + q = svasr_n_s32_x(svptrue_b8(), q, 2); + vopmask_sve_sleef o = veq_vo_vi2_vi2_sve_sleef(vand_vi2_vi2_vi2_sve_sleef(dfigeti_vi2_dfi_sve_sleef(dfi_sve_sleef), vcast_vi2_i_sve_sleef(1)), vcast_vi2_i_sve_sleef(1)); + vfloat2_sve_sleef x = vcast_vf2_vf_vf_sve_sleef(vmulsign_vf_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(3.1415927410125732422f*-0.5), vf2getx_vf_vf2_sve_sleef(dfigetdf_vf2_dfi_sve_sleef(dfi_sve_sleef))), + vmulsign_vf_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(-8.7422776573475857731e-08f*-0.5), vf2getx_vf_vf2_sve_sleef(dfigetdf_vf2_dfi_sve_sleef(dfi_sve_sleef)))); + x = dfadd2_vf2_vf2_vf2_sve_sleef(dfigetdf_vf2_dfi_sve_sleef(dfi_sve_sleef), x); + dfi_sve_sleef = dfisetdf_dfi_dfi_vf2_sve_sleef(dfi_sve_sleef, vsel_vf2_vo_vf2_vf2_sve_sleef(o, x, dfigetdf_vf2_dfi_sve_sleef(dfi_sve_sleef))); + s = dfnormalize_vf2_vf2_sve_sleef(dfigetdf_vf2_dfi_sve_sleef(dfi_sve_sleef)); + + s = vf2setx_vf2_vf2_vf_sve_sleef(s, vreinterpret_vf_vm_sve_sleef(vor_vm_vo32_vm_sve_sleef(vor_vo_vo_vo_sve_sleef(visinf_vo_vf_sve_sleef(d), visnan_vo_vf_sve_sleef(d)), vreinterpret_vm_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(s))))); + + } + + t = s; + s = dfsqu_vf2_vf2_sve_sleef(s); + + u = vcast_vf_f_sve_sleef(2.6083159809786593541503e-06f); + u = vmla_vf_vf_vf_vf_sve_sleef(u, vf2getx_vf_vf2_sve_sleef(s), vcast_vf_f_sve_sleef(-0.0001981069071916863322258f)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, vf2getx_vf_vf2_sve_sleef(s), vcast_vf_f_sve_sleef(0.00833307858556509017944336f)); + + x = dfadd_vf2_vf_vf2_sve_sleef(vcast_vf_f_sve_sleef(1), dfmul_vf2_vf2_vf2_sve_sleef(dfadd_vf2_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(-0.166666597127914428710938f), vmul_vf_vf_vf_sve_sleef(u, vf2getx_vf_vf2_sve_sleef(s))), s)); + + u = dfmul_vf_vf2_vf2_sve_sleef(t, x); + + u = vreinterpret_vf_vm_sve_sleef(vxor_vm_vm_vm_sve_sleef(vand_vm_vo32_vm_sve_sleef(veq_vo_vi2_vi2_sve_sleef(vand_vi2_vi2_vi2_sve_sleef(q, vcast_vi2_i_sve_sleef(1)), vcast_vi2_i_sve_sleef(1)), vreinterpret_vm_vf_sve_sleef(vcast_vf_f_sve_sleef(-0.0))), vreinterpret_vm_vf_sve_sleef(u))); + + u = vsel_vf_vo_vf_vf_sve_sleef(visnegzero_vo_vf_sve_sleef(d), d, u); + + return u; + +} + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_cosfx_u10sve(vfloat_sve_sleef d) { + + vint2_sve_sleef q; + vfloat_sve_sleef u; + vfloat2_sve_sleef s, t, x; + + if (__builtin_expect(!!(vtestallones_i_vo32_sve_sleef(vlt_vo_vf_vf_sve_sleef(vabs_vf_vf_sve_sleef(d), vcast_vf_f_sve_sleef(125.0f)))), 1)) { + vfloat_sve_sleef dq = vmla_vf_vf_vf_vf_sve_sleef(vrint_vf_vf_sve_sleef(vmla_vf_vf_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(0.318309886183790671537767526745028724), vcast_vf_f_sve_sleef(-0.5f))), + vcast_vf_f_sve_sleef(2), vcast_vf_f_sve_sleef(1)); + q = vrint_vi2_vf_sve_sleef(dq); + s = dfadd2_vf2_vf_vf_sve_sleef (d, vmul_vf_vf_vf_sve_sleef(dq, vcast_vf_f_sve_sleef(-3.1414794921875f*0.5f))); + s = dfadd2_vf2_vf2_vf_sve_sleef(s, vmul_vf_vf_vf_sve_sleef(dq, vcast_vf_f_sve_sleef(-0.00011315941810607910156f*0.5f))); + s = dfadd2_vf2_vf2_vf_sve_sleef(s, vmul_vf_vf_vf_sve_sleef(dq, vcast_vf_f_sve_sleef(-1.9841872589410058936e-09f*0.5f))); + } else { + dfi_t_sve_sleef dfi_sve_sleef = rempif_sve_sleef(d); + q = vand_vi2_vi2_vi2_sve_sleef(dfigeti_vi2_dfi_sve_sleef(dfi_sve_sleef), vcast_vi2_i_sve_sleef(3)); + q = vadd_vi2_vi2_vi2_sve_sleef(vadd_vi2_vi2_vi2_sve_sleef(q, q), vsel_vi2_vo_vi2_vi2_sve_sleef(vgt_vo_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(dfigetdf_vf2_dfi_sve_sleef(dfi_sve_sleef)), vcast_vf_f_sve_sleef(0)), vcast_vi2_i_sve_sleef(8), vcast_vi2_i_sve_sleef(7))); + q = svasr_n_s32_x(svptrue_b8(), q, 1); + vopmask_sve_sleef o = veq_vo_vi2_vi2_sve_sleef(vand_vi2_vi2_vi2_sve_sleef(dfigeti_vi2_dfi_sve_sleef(dfi_sve_sleef), vcast_vi2_i_sve_sleef(1)), vcast_vi2_i_sve_sleef(0)); + vfloat_sve_sleef y = vsel_vf_vo_vf_vf_sve_sleef(vgt_vo_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(dfigetdf_vf2_dfi_sve_sleef(dfi_sve_sleef)), vcast_vf_f_sve_sleef(0)), vcast_vf_f_sve_sleef(0), vcast_vf_f_sve_sleef(-1)); + vfloat2_sve_sleef x = vcast_vf2_vf_vf_sve_sleef(vmulsign_vf_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(3.1415927410125732422f*-0.5), y), + vmulsign_vf_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(-8.7422776573475857731e-08f*-0.5), y)); + x = dfadd2_vf2_vf2_vf2_sve_sleef(dfigetdf_vf2_dfi_sve_sleef(dfi_sve_sleef), x); + dfi_sve_sleef = dfisetdf_dfi_dfi_vf2_sve_sleef(dfi_sve_sleef, vsel_vf2_vo_vf2_vf2_sve_sleef(o, x, dfigetdf_vf2_dfi_sve_sleef(dfi_sve_sleef))); + s = dfnormalize_vf2_vf2_sve_sleef(dfigetdf_vf2_dfi_sve_sleef(dfi_sve_sleef)); + + s = vf2setx_vf2_vf2_vf_sve_sleef(s, vreinterpret_vf_vm_sve_sleef(vor_vm_vo32_vm_sve_sleef(vor_vo_vo_vo_sve_sleef(visinf_vo_vf_sve_sleef(d), visnan_vo_vf_sve_sleef(d)), vreinterpret_vm_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(s))))); + + } + + t = s; + s = dfsqu_vf2_vf2_sve_sleef(s); + + u = vcast_vf_f_sve_sleef(2.6083159809786593541503e-06f); + u = vmla_vf_vf_vf_vf_sve_sleef(u, vf2getx_vf_vf2_sve_sleef(s), vcast_vf_f_sve_sleef(-0.0001981069071916863322258f)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, vf2getx_vf_vf2_sve_sleef(s), vcast_vf_f_sve_sleef(0.00833307858556509017944336f)); + + x = dfadd_vf2_vf_vf2_sve_sleef(vcast_vf_f_sve_sleef(1), dfmul_vf2_vf2_vf2_sve_sleef(dfadd_vf2_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(-0.166666597127914428710938f), vmul_vf_vf_vf_sve_sleef(u, vf2getx_vf_vf2_sve_sleef(s))), s)); + + u = dfmul_vf_vf2_vf2_sve_sleef(t, x); + + u = vreinterpret_vf_vm_sve_sleef(vxor_vm_vm_vm_sve_sleef(vand_vm_vo32_vm_sve_sleef(veq_vo_vi2_vi2_sve_sleef(vand_vi2_vi2_vi2_sve_sleef(q, vcast_vi2_i_sve_sleef(2)), vcast_vi2_i_sve_sleef(0)), vreinterpret_vm_vf_sve_sleef(vcast_vf_f_sve_sleef(-0.0))), vreinterpret_vm_vf_sve_sleef(u))); + + return u; + +} + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_fastsinfx_u3500sve(vfloat_sve_sleef d) { + vint2_sve_sleef q; + vfloat_sve_sleef u, s, t = d; + + s = vmul_vf_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef((float)0.318309886183790671537767526745028724)); + u = vrint_vf_vf_sve_sleef(s); + q = vrint_vi2_vf_sve_sleef(s); + d = vmla_vf_vf_vf_vf_sve_sleef(u, vcast_vf_f_sve_sleef(-(float)3.141592653589793238462643383279502884), d); + + s = vmul_vf_vf_vf_sve_sleef(d, d); + + u = vcast_vf_f_sve_sleef(-0.1881748176e-3); + u = vmla_vf_vf_vf_vf_sve_sleef(u, s, vcast_vf_f_sve_sleef(+0.8323502727e-2)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, s, vcast_vf_f_sve_sleef(-0.1666651368e+0)); + u = vmla_vf_vf_vf_vf_sve_sleef(vmul_vf_vf_vf_sve_sleef(s, d), u, d); + + u = vreinterpret_vf_vm_sve_sleef(vxor_vm_vm_vm_sve_sleef(vand_vm_vo32_vm_sve_sleef(veq_vo_vi2_vi2_sve_sleef(vand_vi2_vi2_vi2_sve_sleef(q, vcast_vi2_i_sve_sleef(1)), vcast_vi2_i_sve_sleef(1)), vreinterpret_vm_vf_sve_sleef(vcast_vf_f_sve_sleef(-0.0f))), vreinterpret_vm_vf_sve_sleef(u))); + + vopmask_sve_sleef g = vlt_vo_vf_vf_sve_sleef(vabs_vf_vf_sve_sleef(t), vcast_vf_f_sve_sleef(30.0f)); + if (!__builtin_expect(!!(vtestallones_i_vo32_sve_sleef(g)), 1)) return vsel_vf_vo_vf_vf_sve_sleef(g, u, Sleef_sinfx_u35sve(t)); + + return u; +} + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_fastcosfx_u3500sve(vfloat_sve_sleef d) { + vint2_sve_sleef q; + vfloat_sve_sleef u, s, t = d; + + s = vmla_vf_vf_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef((float)0.318309886183790671537767526745028724), vcast_vf_f_sve_sleef(-0.5f)); + u = vrint_vf_vf_sve_sleef(s); + q = vrint_vi2_vf_sve_sleef(s); + d = vmla_vf_vf_vf_vf_sve_sleef(u, vcast_vf_f_sve_sleef(-(float)3.141592653589793238462643383279502884), vsub_vf_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef((float)3.141592653589793238462643383279502884 * 0.5f))); + + s = vmul_vf_vf_vf_sve_sleef(d, d); + + u = vcast_vf_f_sve_sleef(-0.1881748176e-3); + u = vmla_vf_vf_vf_vf_sve_sleef(u, s, vcast_vf_f_sve_sleef(+0.8323502727e-2)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, s, vcast_vf_f_sve_sleef(-0.1666651368e+0)); + u = vmla_vf_vf_vf_vf_sve_sleef(vmul_vf_vf_vf_sve_sleef(s, d), u, d); + + u = vreinterpret_vf_vm_sve_sleef(vxor_vm_vm_vm_sve_sleef(vand_vm_vo32_vm_sve_sleef(veq_vo_vi2_vi2_sve_sleef(vand_vi2_vi2_vi2_sve_sleef(q, vcast_vi2_i_sve_sleef(1)), vcast_vi2_i_sve_sleef(0)), vreinterpret_vm_vf_sve_sleef(vcast_vf_f_sve_sleef(-0.0f))), vreinterpret_vm_vf_sve_sleef(u))); + + vopmask_sve_sleef g = vlt_vo_vf_vf_sve_sleef(vabs_vf_vf_sve_sleef(t), vcast_vf_f_sve_sleef(30.0f)); + if (!__builtin_expect(!!(vtestallones_i_vo32_sve_sleef(g)), 1)) return vsel_vf_vo_vf_vf_sve_sleef(g, u, Sleef_cosfx_u35sve(t)); + + return u; +} + +SLEEF_INLINE SLEEF_CONST vfloat2_sve_sleef Sleef_sincosfx_u35sve(vfloat_sve_sleef d) { + + vint2_sve_sleef q; + vopmask_sve_sleef o; + vfloat_sve_sleef u, s, t, rx, ry; + vfloat2_sve_sleef r; + + s = d; + + if (__builtin_expect(!!(vtestallones_i_vo32_sve_sleef(vlt_vo_vf_vf_sve_sleef(vabs_vf_vf_sve_sleef(d), vcast_vf_f_sve_sleef(125.0f)))), 1)) { + q = vrint_vi2_vf_sve_sleef(vmul_vf_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef((float)0.636619772367581343075535053490057448))); + u = vcast_vf_vi2_sve_sleef(q); + s = vmla_vf_vf_vf_vf_sve_sleef(u, vcast_vf_f_sve_sleef(-3.1414794921875f*0.5f), s); + s = vmla_vf_vf_vf_vf_sve_sleef(u, vcast_vf_f_sve_sleef(-0.00011315941810607910156f*0.5f), s); + s = vmla_vf_vf_vf_vf_sve_sleef(u, vcast_vf_f_sve_sleef(-1.9841872589410058936e-09f*0.5f), s); + } else if (__builtin_expect(!!(vtestallones_i_vo32_sve_sleef(vlt_vo_vf_vf_sve_sleef(vabs_vf_vf_sve_sleef(d), vcast_vf_f_sve_sleef(39000)))), 1)) { + q = vrint_vi2_vf_sve_sleef(vmul_vf_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef((float)0.636619772367581343075535053490057448))); + u = vcast_vf_vi2_sve_sleef(q); + s = vmla_vf_vf_vf_vf_sve_sleef(u, vcast_vf_f_sve_sleef(-3.140625f*0.5f), s); + s = vmla_vf_vf_vf_vf_sve_sleef(u, vcast_vf_f_sve_sleef(-0.0009670257568359375f*0.5f), s); + s = vmla_vf_vf_vf_vf_sve_sleef(u, vcast_vf_f_sve_sleef(-6.2771141529083251953e-07f*0.5f), s); + s = vmla_vf_vf_vf_vf_sve_sleef(u, vcast_vf_f_sve_sleef(-1.2154201256553420762e-10f*0.5f), s); + } else { + dfi_t_sve_sleef dfi_sve_sleef = rempif_sve_sleef(d); + q = dfigeti_vi2_dfi_sve_sleef(dfi_sve_sleef); + s = vadd_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(dfigetdf_vf2_dfi_sve_sleef(dfi_sve_sleef)), vf2gety_vf_vf2_sve_sleef(dfigetdf_vf2_dfi_sve_sleef(dfi_sve_sleef))); + s = vreinterpret_vf_vm_sve_sleef(vor_vm_vo32_vm_sve_sleef(vor_vo_vo_vo_sve_sleef(visinf_vo_vf_sve_sleef(d), visnan_vo_vf_sve_sleef(d)), vreinterpret_vm_vf_sve_sleef(s))); + } + + t = s; + + s = vmul_vf_vf_vf_sve_sleef(s, s); + + u = vcast_vf_f_sve_sleef(-0.000195169282960705459117889f); + u = vmla_vf_vf_vf_vf_sve_sleef(u, s, vcast_vf_f_sve_sleef(0.00833215750753879547119141f)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, s, vcast_vf_f_sve_sleef(-0.166666537523269653320312f)); + + rx = vmla_vf_vf_vf_vf_sve_sleef(vmul_vf_vf_vf_sve_sleef(u, s), t, t); + rx = vsel_vf_vo_vf_vf_sve_sleef(visnegzero_vo_vf_sve_sleef(d), vcast_vf_f_sve_sleef(-0.0f), rx); + + u = vcast_vf_f_sve_sleef(-2.71811842367242206819355e-07f); + u = vmla_vf_vf_vf_vf_sve_sleef(u, s, vcast_vf_f_sve_sleef(2.47990446951007470488548e-05f)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, s, vcast_vf_f_sve_sleef(-0.00138888787478208541870117f)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, s, vcast_vf_f_sve_sleef(0.0416666641831398010253906f)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, s, vcast_vf_f_sve_sleef(-0.5)); + + ry = vmla_vf_vf_vf_vf_sve_sleef(s, u, vcast_vf_f_sve_sleef(1)); + + o = veq_vo_vi2_vi2_sve_sleef(vand_vi2_vi2_vi2_sve_sleef(q, vcast_vi2_i_sve_sleef(1)), vcast_vi2_i_sve_sleef(0)); + r = vf2setxy_vf2_vf_vf_sve_sleef(vsel_vf_vo_vf_vf_sve_sleef(o, rx, ry), vsel_vf_vo_vf_vf_sve_sleef(o, ry, rx)); + + o = veq_vo_vi2_vi2_sve_sleef(vand_vi2_vi2_vi2_sve_sleef(q, vcast_vi2_i_sve_sleef(2)), vcast_vi2_i_sve_sleef(2)); + r = vf2setx_vf2_vf2_vf_sve_sleef(r, vreinterpret_vf_vm_sve_sleef(vxor_vm_vm_vm_sve_sleef(vand_vm_vo32_vm_sve_sleef(o, vreinterpret_vm_vf_sve_sleef(vcast_vf_f_sve_sleef(-0.0))), vreinterpret_vm_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(r))))); + + o = veq_vo_vi2_vi2_sve_sleef(vand_vi2_vi2_vi2_sve_sleef(vadd_vi2_vi2_vi2_sve_sleef(q, vcast_vi2_i_sve_sleef(1)), vcast_vi2_i_sve_sleef(2)), vcast_vi2_i_sve_sleef(2)); + r = vf2sety_vf2_vf2_vf_sve_sleef(r, vreinterpret_vf_vm_sve_sleef(vxor_vm_vm_vm_sve_sleef(vand_vm_vo32_vm_sve_sleef(o, vreinterpret_vm_vf_sve_sleef(vcast_vf_f_sve_sleef(-0.0))), vreinterpret_vm_vf_sve_sleef(vf2gety_vf_vf2_sve_sleef(r))))); + + return r; + +} + +SLEEF_INLINE SLEEF_CONST vfloat2_sve_sleef Sleef_sincosfx_u10sve(vfloat_sve_sleef d) { + + vint2_sve_sleef q; + vopmask_sve_sleef o; + vfloat_sve_sleef u, v, rx, ry; + vfloat2_sve_sleef r, s, t, x; + + if (__builtin_expect(!!(vtestallones_i_vo32_sve_sleef(vlt_vo_vf_vf_sve_sleef(vabs_vf_vf_sve_sleef(d), vcast_vf_f_sve_sleef(125.0f)))), 1)) { + u = vrint_vf_vf_sve_sleef(vmul_vf_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(2 * 0.318309886183790671537767526745028724))); + q = vrint_vi2_vf_sve_sleef(u); + v = vmla_vf_vf_vf_vf_sve_sleef(u, vcast_vf_f_sve_sleef(-3.1414794921875f*0.5f), d); + s = dfadd2_vf2_vf_vf_sve_sleef(v, vmul_vf_vf_vf_sve_sleef(u, vcast_vf_f_sve_sleef(-0.00011315941810607910156f*0.5f))); + s = dfadd_vf2_vf2_vf_sve_sleef(s, vmul_vf_vf_vf_sve_sleef(u, vcast_vf_f_sve_sleef(-1.9841872589410058936e-09f*0.5f))); + } else { + dfi_t_sve_sleef dfi_sve_sleef = rempif_sve_sleef(d); + q = dfigeti_vi2_dfi_sve_sleef(dfi_sve_sleef); + s = dfigetdf_vf2_dfi_sve_sleef(dfi_sve_sleef); + o = vor_vo_vo_vo_sve_sleef(visinf_vo_vf_sve_sleef(d), visnan_vo_vf_sve_sleef(d)); + s = vf2setx_vf2_vf2_vf_sve_sleef(s, vreinterpret_vf_vm_sve_sleef(vor_vm_vo32_vm_sve_sleef(o, vreinterpret_vm_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(s))))); + } + + t = s; + + s = vf2setx_vf2_vf2_vf_sve_sleef(s, dfsqu_vf_vf2_sve_sleef(s)); + + u = vcast_vf_f_sve_sleef(-0.000195169282960705459117889f); + u = vmla_vf_vf_vf_vf_sve_sleef(u, vf2getx_vf_vf2_sve_sleef(s), vcast_vf_f_sve_sleef(0.00833215750753879547119141f)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, vf2getx_vf_vf2_sve_sleef(s), vcast_vf_f_sve_sleef(-0.166666537523269653320312f)); + + u = vmul_vf_vf_vf_sve_sleef(u, vmul_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(s), vf2getx_vf_vf2_sve_sleef(t))); + + x = dfadd_vf2_vf2_vf_sve_sleef(t, u); + rx = vadd_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(x), vf2gety_vf_vf2_sve_sleef(x)); + + rx = vsel_vf_vo_vf_vf_sve_sleef(visnegzero_vo_vf_sve_sleef(d), vcast_vf_f_sve_sleef(-0.0f), rx); + + u = vcast_vf_f_sve_sleef(-2.71811842367242206819355e-07f); + u = vmla_vf_vf_vf_vf_sve_sleef(u, vf2getx_vf_vf2_sve_sleef(s), vcast_vf_f_sve_sleef(2.47990446951007470488548e-05f)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, vf2getx_vf_vf2_sve_sleef(s), vcast_vf_f_sve_sleef(-0.00138888787478208541870117f)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, vf2getx_vf_vf2_sve_sleef(s), vcast_vf_f_sve_sleef(0.0416666641831398010253906f)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, vf2getx_vf_vf2_sve_sleef(s), vcast_vf_f_sve_sleef(-0.5)); + + x = dfadd_vf2_vf_vf2_sve_sleef(vcast_vf_f_sve_sleef(1), dfmul_vf2_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(s), u)); + ry = vadd_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(x), vf2gety_vf_vf2_sve_sleef(x)); + + o = veq_vo_vi2_vi2_sve_sleef(vand_vi2_vi2_vi2_sve_sleef(q, vcast_vi2_i_sve_sleef(1)), vcast_vi2_i_sve_sleef(0)); + r = vf2setxy_vf2_vf_vf_sve_sleef(vsel_vf_vo_vf_vf_sve_sleef(o, rx, ry), vsel_vf_vo_vf_vf_sve_sleef(o, ry, rx)); + + o = veq_vo_vi2_vi2_sve_sleef(vand_vi2_vi2_vi2_sve_sleef(q, vcast_vi2_i_sve_sleef(2)), vcast_vi2_i_sve_sleef(2)); + r = vf2setx_vf2_vf2_vf_sve_sleef(r, vreinterpret_vf_vm_sve_sleef(vxor_vm_vm_vm_sve_sleef(vand_vm_vo32_vm_sve_sleef(o, vreinterpret_vm_vf_sve_sleef(vcast_vf_f_sve_sleef(-0.0))), vreinterpret_vm_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(r))))); + + o = veq_vo_vi2_vi2_sve_sleef(vand_vi2_vi2_vi2_sve_sleef(vadd_vi2_vi2_vi2_sve_sleef(q, vcast_vi2_i_sve_sleef(1)), vcast_vi2_i_sve_sleef(2)), vcast_vi2_i_sve_sleef(2)); + r = vf2sety_vf2_vf2_vf_sve_sleef(r, vreinterpret_vf_vm_sve_sleef(vxor_vm_vm_vm_sve_sleef(vand_vm_vo32_vm_sve_sleef(o, vreinterpret_vm_vf_sve_sleef(vcast_vf_f_sve_sleef(-0.0))), vreinterpret_vm_vf_sve_sleef(vf2gety_vf_vf2_sve_sleef(r))))); + + return r; + +} + +SLEEF_INLINE SLEEF_CONST vfloat2_sve_sleef Sleef_sincospifx_u05sve(vfloat_sve_sleef d) { + vopmask_sve_sleef o; + vfloat_sve_sleef u, s, t, rx, ry; + vfloat2_sve_sleef r, x, s2; + + u = vmul_vf_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(4)); + vint2_sve_sleef q = vtruncate_vi2_vf_sve_sleef(u); + q = vand_vi2_vi2_vi2_sve_sleef(vadd_vi2_vi2_vi2_sve_sleef(q, vxor_vi2_vi2_vi2_sve_sleef(svreinterpret_s32_u32(svlsr_n_u32_x(svptrue_b8(), svreinterpret_u32_s32(q), 31)), vcast_vi2_i_sve_sleef(1))), vcast_vi2_i_sve_sleef(~1)); + s = vsub_vf_vf_vf_sve_sleef(u, vcast_vf_vi2_sve_sleef(q)); + + t = s; + s = vmul_vf_vf_vf_sve_sleef(s, s); + s2 = dfmul_vf2_vf_vf_sve_sleef(t, t); + + u = vcast_vf_f_sve_sleef(+0.3093842054e-6); + u = vmla_vf_vf_vf_vf_sve_sleef(u, s, vcast_vf_f_sve_sleef(-0.3657307388e-4)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, s, vcast_vf_f_sve_sleef(+0.2490393585e-2)); + x = dfadd2_vf2_vf_vf2_sve_sleef(vmul_vf_vf_vf_sve_sleef(u, s), vcast_vf2_f_f_sve_sleef(-0.080745510756969451904, -1.3373665339076936258e-09)); + x = dfadd2_vf2_vf2_vf2_sve_sleef(dfmul_vf2_vf2_vf2_sve_sleef(s2, x), vcast_vf2_f_f_sve_sleef(0.78539818525314331055, -2.1857338617566484855e-08)); + + x = dfmul_vf2_vf2_vf_sve_sleef(x, t); + rx = vadd_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(x), vf2gety_vf_vf2_sve_sleef(x)); + + rx = vsel_vf_vo_vf_vf_sve_sleef(visnegzero_vo_vf_sve_sleef(d), vcast_vf_f_sve_sleef(-0.0f), rx); + + u = vcast_vf_f_sve_sleef(-0.2430611801e-7); + u = vmla_vf_vf_vf_vf_sve_sleef(u, s, vcast_vf_f_sve_sleef(+0.3590577080e-5)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, s, vcast_vf_f_sve_sleef(-0.3259917721e-3)); + x = dfadd2_vf2_vf_vf2_sve_sleef(vmul_vf_vf_vf_sve_sleef(u, s), vcast_vf2_f_f_sve_sleef(0.015854343771934509277, 4.4940051354032242811e-10)); + x = dfadd2_vf2_vf2_vf2_sve_sleef(dfmul_vf2_vf2_vf2_sve_sleef(s2, x), vcast_vf2_f_f_sve_sleef(-0.30842512845993041992, -9.0728339030733922277e-09)); + + x = dfadd2_vf2_vf2_vf_sve_sleef(dfmul_vf2_vf2_vf2_sve_sleef(x, s2), vcast_vf_f_sve_sleef(1)); + ry = vadd_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(x), vf2gety_vf_vf2_sve_sleef(x)); + + o = veq_vo_vi2_vi2_sve_sleef(vand_vi2_vi2_vi2_sve_sleef(q, vcast_vi2_i_sve_sleef(2)), vcast_vi2_i_sve_sleef(0)); + r = vf2setxy_vf2_vf_vf_sve_sleef(vsel_vf_vo_vf_vf_sve_sleef(o, rx, ry), vsel_vf_vo_vf_vf_sve_sleef(o, ry, rx)); + + o = veq_vo_vi2_vi2_sve_sleef(vand_vi2_vi2_vi2_sve_sleef(q, vcast_vi2_i_sve_sleef(4)), vcast_vi2_i_sve_sleef(4)); + r = vf2setx_vf2_vf2_vf_sve_sleef(r, vreinterpret_vf_vm_sve_sleef(vxor_vm_vm_vm_sve_sleef(vand_vm_vo32_vm_sve_sleef(o, vreinterpret_vm_vf_sve_sleef(vcast_vf_f_sve_sleef(-0.0))), vreinterpret_vm_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(r))))); + + o = veq_vo_vi2_vi2_sve_sleef(vand_vi2_vi2_vi2_sve_sleef(vadd_vi2_vi2_vi2_sve_sleef(q, vcast_vi2_i_sve_sleef(2)), vcast_vi2_i_sve_sleef(4)), vcast_vi2_i_sve_sleef(4)); + r = vf2sety_vf2_vf2_vf_sve_sleef(r, vreinterpret_vf_vm_sve_sleef(vxor_vm_vm_vm_sve_sleef(vand_vm_vo32_vm_sve_sleef(o, vreinterpret_vm_vf_sve_sleef(vcast_vf_f_sve_sleef(-0.0))), vreinterpret_vm_vf_sve_sleef(vf2gety_vf_vf2_sve_sleef(r))))); + + o = vgt_vo_vf_vf_sve_sleef(vabs_vf_vf_sve_sleef(d), vcast_vf_f_sve_sleef(1e+7f)); + r = vf2setx_vf2_vf2_vf_sve_sleef(r, vreinterpret_vf_vm_sve_sleef(vandnot_vm_vo32_vm_sve_sleef(o, vreinterpret_vm_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(r))))); + r = vf2sety_vf2_vf2_vf_sve_sleef(r, vreinterpret_vf_vm_sve_sleef(vandnot_vm_vo32_vm_sve_sleef(o, vreinterpret_vm_vf_sve_sleef(vf2gety_vf_vf2_sve_sleef(r))))); + + o = visinf_vo_vf_sve_sleef(d); + r = vf2setx_vf2_vf2_vf_sve_sleef(r, vreinterpret_vf_vm_sve_sleef(vor_vm_vo32_vm_sve_sleef(o, vreinterpret_vm_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(r))))); + r = vf2sety_vf2_vf2_vf_sve_sleef(r, vreinterpret_vf_vm_sve_sleef(vor_vm_vo32_vm_sve_sleef(o, vreinterpret_vm_vf_sve_sleef(vf2gety_vf_vf2_sve_sleef(r))))); + + return r; +} + +SLEEF_INLINE SLEEF_CONST vfloat2_sve_sleef Sleef_sincospifx_u35sve(vfloat_sve_sleef d) { + vopmask_sve_sleef o; + vfloat_sve_sleef u, s, t, rx, ry; + vfloat2_sve_sleef r; + + u = vmul_vf_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(4)); + vint2_sve_sleef q = vtruncate_vi2_vf_sve_sleef(u); + q = vand_vi2_vi2_vi2_sve_sleef(vadd_vi2_vi2_vi2_sve_sleef(q, vxor_vi2_vi2_vi2_sve_sleef(svreinterpret_s32_u32(svlsr_n_u32_x(svptrue_b8(), svreinterpret_u32_s32(q), 31)), vcast_vi2_i_sve_sleef(1))), vcast_vi2_i_sve_sleef(~1)); + s = vsub_vf_vf_vf_sve_sleef(u, vcast_vf_vi2_sve_sleef(q)); + + t = s; + s = vmul_vf_vf_vf_sve_sleef(s, s); + + u = vcast_vf_f_sve_sleef(-0.3600925265e-4); + u = vmla_vf_vf_vf_vf_sve_sleef(u, s, vcast_vf_f_sve_sleef(+0.2490088111e-2)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, s, vcast_vf_f_sve_sleef(-0.8074551076e-1)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, s, vcast_vf_f_sve_sleef(+0.7853981853e+0)); + + rx = vmul_vf_vf_vf_sve_sleef(u, t); + + u = vcast_vf_f_sve_sleef(+0.3539815225e-5); + u = vmla_vf_vf_vf_vf_sve_sleef(u, s, vcast_vf_f_sve_sleef(-0.3259574005e-3)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, s, vcast_vf_f_sve_sleef(+0.1585431583e-1)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, s, vcast_vf_f_sve_sleef(-0.3084251285e+0)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, s, vcast_vf_f_sve_sleef(1)); + + ry = u; + + o = veq_vo_vi2_vi2_sve_sleef(vand_vi2_vi2_vi2_sve_sleef(q, vcast_vi2_i_sve_sleef(2)), vcast_vi2_i_sve_sleef(0)); + r = vf2setxy_vf2_vf_vf_sve_sleef(vsel_vf_vo_vf_vf_sve_sleef(o, rx, ry), vsel_vf_vo_vf_vf_sve_sleef(o, ry, rx)); + + o = veq_vo_vi2_vi2_sve_sleef(vand_vi2_vi2_vi2_sve_sleef(q, vcast_vi2_i_sve_sleef(4)), vcast_vi2_i_sve_sleef(4)); + r = vf2setx_vf2_vf2_vf_sve_sleef(r, vreinterpret_vf_vm_sve_sleef(vxor_vm_vm_vm_sve_sleef(vand_vm_vo32_vm_sve_sleef(o, vreinterpret_vm_vf_sve_sleef(vcast_vf_f_sve_sleef(-0.0))), vreinterpret_vm_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(r))))); + + o = veq_vo_vi2_vi2_sve_sleef(vand_vi2_vi2_vi2_sve_sleef(vadd_vi2_vi2_vi2_sve_sleef(q, vcast_vi2_i_sve_sleef(2)), vcast_vi2_i_sve_sleef(4)), vcast_vi2_i_sve_sleef(4)); + r = vf2sety_vf2_vf2_vf_sve_sleef(r, vreinterpret_vf_vm_sve_sleef(vxor_vm_vm_vm_sve_sleef(vand_vm_vo32_vm_sve_sleef(o, vreinterpret_vm_vf_sve_sleef(vcast_vf_f_sve_sleef(-0.0))), vreinterpret_vm_vf_sve_sleef(vf2gety_vf_vf2_sve_sleef(r))))); + + o = vgt_vo_vf_vf_sve_sleef(vabs_vf_vf_sve_sleef(d), vcast_vf_f_sve_sleef(1e+7f)); + r = vf2setx_vf2_vf2_vf_sve_sleef(r, vreinterpret_vf_vm_sve_sleef(vandnot_vm_vo32_vm_sve_sleef(o, vreinterpret_vm_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(r))))); + r = vf2sety_vf2_vf2_vf_sve_sleef(r, vreinterpret_vf_vm_sve_sleef(vandnot_vm_vo32_vm_sve_sleef(o, vreinterpret_vm_vf_sve_sleef(vf2gety_vf_vf2_sve_sleef(r))))); + + o = visinf_vo_vf_sve_sleef(d); + r = vf2setx_vf2_vf2_vf_sve_sleef(r, vreinterpret_vf_vm_sve_sleef(vor_vm_vo32_vm_sve_sleef(o, vreinterpret_vm_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(r))))); + r = vf2sety_vf2_vf2_vf_sve_sleef(r, vreinterpret_vf_vm_sve_sleef(vor_vm_vo32_vm_sve_sleef(o, vreinterpret_vm_vf_sve_sleef(vf2gety_vf_vf2_sve_sleef(r))))); + + return r; +} + +SLEEF_INLINE vfloat2_sve_sleef Sleef_modffx_sve(vfloat_sve_sleef x) { + vfloat_sve_sleef fr = vsub_vf_vf_vf_sve_sleef(x, vcast_vf_vi2_sve_sleef(vtruncate_vi2_vf_sve_sleef(x))); + fr = vsel_vf_vo_vf_vf_sve_sleef(vgt_vo_vf_vf_sve_sleef(vabs_vf_vf_sve_sleef(x), vcast_vf_f_sve_sleef(INT64_C(1) << 23)), vcast_vf_f_sve_sleef(0), fr); + + vfloat2_sve_sleef ret; + + ret = vf2setxy_vf2_vf_vf_sve_sleef(vcopysign_vf_vf_vf_sve_sleef(fr, x), vcopysign_vf_vf_vf_sve_sleef(vsub_vf_vf_vf_sve_sleef(x, fr), x)); + + return ret; +} + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_tanfx_u10sve(vfloat_sve_sleef d) { + + vint2_sve_sleef q; + vfloat_sve_sleef u, v; + vfloat2_sve_sleef s, t, x; + vopmask_sve_sleef o; + + if (__builtin_expect(!!(vtestallones_i_vo32_sve_sleef(vlt_vo_vf_vf_sve_sleef(vabs_vf_vf_sve_sleef(d), vcast_vf_f_sve_sleef(125.0f)))), 1)) { + u = vrint_vf_vf_sve_sleef(vmul_vf_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(2 * 0.318309886183790671537767526745028724))); + q = vrint_vi2_vf_sve_sleef(u); + v = vmla_vf_vf_vf_vf_sve_sleef(u, vcast_vf_f_sve_sleef(-3.1414794921875f*0.5f), d); + s = dfadd2_vf2_vf_vf_sve_sleef(v, vmul_vf_vf_vf_sve_sleef(u, vcast_vf_f_sve_sleef(-0.00011315941810607910156f*0.5f))); + s = dfadd_vf2_vf2_vf_sve_sleef(s, vmul_vf_vf_vf_sve_sleef(u, vcast_vf_f_sve_sleef(-1.9841872589410058936e-09f*0.5f))); + } else { + dfi_t_sve_sleef dfi_sve_sleef = rempif_sve_sleef(d); + q = dfigeti_vi2_dfi_sve_sleef(dfi_sve_sleef); + s = dfigetdf_vf2_dfi_sve_sleef(dfi_sve_sleef); + o = vor_vo_vo_vo_sve_sleef(visinf_vo_vf_sve_sleef(d), visnan_vo_vf_sve_sleef(d)); + s = vf2setx_vf2_vf2_vf_sve_sleef(s, vreinterpret_vf_vm_sve_sleef(vor_vm_vo32_vm_sve_sleef(o, vreinterpret_vm_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(s))))); + s = vf2sety_vf2_vf2_vf_sve_sleef(s, vreinterpret_vf_vm_sve_sleef(vor_vm_vo32_vm_sve_sleef(o, vreinterpret_vm_vf_sve_sleef(vf2gety_vf_vf2_sve_sleef(s))))); + } + + o = veq_vo_vi2_vi2_sve_sleef(vand_vi2_vi2_vi2_sve_sleef(q, vcast_vi2_i_sve_sleef(1)), vcast_vi2_i_sve_sleef(1)); + vmask_sve_sleef n = vand_vm_vo32_vm_sve_sleef(o, vreinterpret_vm_vf_sve_sleef(vcast_vf_f_sve_sleef(-0.0))); + + s = vf2setx_vf2_vf2_vf_sve_sleef(s, vreinterpret_vf_vm_sve_sleef(vxor_vm_vm_vm_sve_sleef(vreinterpret_vm_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(s)), n))); + s = vf2sety_vf2_vf2_vf_sve_sleef(s, vreinterpret_vf_vm_sve_sleef(vxor_vm_vm_vm_sve_sleef(vreinterpret_vm_vf_sve_sleef(vf2gety_vf_vf2_sve_sleef(s)), n))); + + t = s; + s = dfsqu_vf2_vf2_sve_sleef(s); + s = dfnormalize_vf2_vf2_sve_sleef(s); + + u = vcast_vf_f_sve_sleef(0.00446636462584137916564941f); + u = vmla_vf_vf_vf_vf_sve_sleef(u, vf2getx_vf_vf2_sve_sleef(s), vcast_vf_f_sve_sleef(-8.3920182078145444393158e-05f)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, vf2getx_vf_vf2_sve_sleef(s), vcast_vf_f_sve_sleef(0.0109639242291450500488281f)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, vf2getx_vf_vf2_sve_sleef(s), vcast_vf_f_sve_sleef(0.0212360303848981857299805f)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, vf2getx_vf_vf2_sve_sleef(s), vcast_vf_f_sve_sleef(0.0540687143802642822265625f)); + + x = dfadd_vf2_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(0.133325666189193725585938f), vmul_vf_vf_vf_sve_sleef(u, vf2getx_vf_vf2_sve_sleef(s))); + x = dfadd_vf2_vf_vf2_sve_sleef(vcast_vf_f_sve_sleef(1), dfmul_vf2_vf2_vf2_sve_sleef(dfadd_vf2_vf_vf2_sve_sleef(vcast_vf_f_sve_sleef(0.33333361148834228515625f), dfmul_vf2_vf2_vf2_sve_sleef(s, x)), s)); + x = dfmul_vf2_vf2_vf2_sve_sleef(t, x); + + x = vsel_vf2_vo_vf2_vf2_sve_sleef(o, dfrec_vf2_vf2_sve_sleef(x), x); + + u = vadd_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(x), vf2gety_vf_vf2_sve_sleef(x)); + + u = vsel_vf_vo_vf_vf_sve_sleef(visnegzero_vo_vf_sve_sleef(d), d, u); + + return u; + +} + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_atanfx_u35sve(vfloat_sve_sleef d) { + vfloat_sve_sleef s, t, u; + vint2_sve_sleef q; + + q = vsel_vi2_vf_vi2_sve_sleef(d, vcast_vi2_i_sve_sleef(2)); + s = vabs_vf_vf_sve_sleef(d); + + q = vsel_vi2_vf_vf_vi2_vi2_sve_sleef(vcast_vf_f_sve_sleef(1.0f), s, vadd_vi2_vi2_vi2_sve_sleef(q, vcast_vi2_i_sve_sleef(1)), q); + s = vsel_vf_vo_vf_vf_sve_sleef(vlt_vo_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(1.0f), s), vrec_vf_vf_sve_sleef(s), s); + + t = vmul_vf_vf_vf_sve_sleef(s, s); + + vfloat_sve_sleef t2 = vmul_vf_vf_vf_sve_sleef(t, t), t4 = vmul_vf_vf_vf_sve_sleef(t2, t2); + u = vmla_vf_vf_vf_vf_sve_sleef((t4), (vmla_vf_vf_vf_vf_sve_sleef((t2), (vmla_vf_vf_vf_vf_sve_sleef((t), (vcast_vf_f_sve_sleef(0.00282363896258175373077393f)), (vcast_vf_f_sve_sleef(-0.0159569028764963150024414f)))), (vmla_vf_vf_vf_vf_sve_sleef((t), (vcast_vf_f_sve_sleef(0.0425049886107444763183594f)), (vcast_vf_f_sve_sleef(-0.0748900920152664184570312f)))))), (vmla_vf_vf_vf_vf_sve_sleef((t2), (vmla_vf_vf_vf_vf_sve_sleef((t), (vcast_vf_f_sve_sleef(0.106347933411598205566406f)), (vcast_vf_f_sve_sleef(-0.142027363181114196777344f)))), (vmla_vf_vf_vf_vf_sve_sleef((t), (vcast_vf_f_sve_sleef(0.199926957488059997558594f)), (vcast_vf_f_sve_sleef(-0.333331018686294555664062f))))))) + + ; + + t = vmla_vf_vf_vf_vf_sve_sleef(s, vmul_vf_vf_vf_sve_sleef(t, u), s); + + t = vsel_vf_vo_vf_vf_sve_sleef(veq_vo_vi2_vi2_sve_sleef(vand_vi2_vi2_vi2_sve_sleef(q, vcast_vi2_i_sve_sleef(1)), vcast_vi2_i_sve_sleef(1)), vsub_vf_vf_vf_sve_sleef(vcast_vf_f_sve_sleef((float)(3.141592653589793238462643383279502884/2)), t), t); + + t = vreinterpret_vf_vm_sve_sleef(vxor_vm_vm_vm_sve_sleef(vand_vm_vo32_vm_sve_sleef(veq_vo_vi2_vi2_sve_sleef(vand_vi2_vi2_vi2_sve_sleef(q, vcast_vi2_i_sve_sleef(2)), vcast_vi2_i_sve_sleef(2)), vreinterpret_vm_vf_sve_sleef(vcast_vf_f_sve_sleef(-0.0f))), vreinterpret_vm_vf_sve_sleef(t))); + + return t; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_sve_sleef atan2kf_sve_sleef(vfloat_sve_sleef y, vfloat_sve_sleef x) { + vfloat_sve_sleef s, t, u; + vint2_sve_sleef q; + vopmask_sve_sleef p; + + q = vsel_vi2_vf_vi2_sve_sleef(x, vcast_vi2_i_sve_sleef(-2)); + x = vabs_vf_vf_sve_sleef(x); + + q = vsel_vi2_vf_vf_vi2_vi2_sve_sleef(x, y, vadd_vi2_vi2_vi2_sve_sleef(q, vcast_vi2_i_sve_sleef(1)), q); + p = vlt_vo_vf_vf_sve_sleef(x, y); + s = vsel_vf_vo_vf_vf_sve_sleef(p, vneg_vf_vf_sve_sleef(x), y); + t = vmax_vf_vf_vf_sve_sleef(x, y); + + s = vdiv_vf_vf_vf_sve_sleef(s, t); + t = vmul_vf_vf_vf_sve_sleef(s, s); + + vfloat_sve_sleef t2 = vmul_vf_vf_vf_sve_sleef(t, t), t4 = vmul_vf_vf_vf_sve_sleef(t2, t2); + u = vmla_vf_vf_vf_vf_sve_sleef((t4), (vmla_vf_vf_vf_vf_sve_sleef((t2), (vmla_vf_vf_vf_vf_sve_sleef((t), (vcast_vf_f_sve_sleef(0.00282363896258175373077393f)), (vcast_vf_f_sve_sleef(-0.0159569028764963150024414f)))), (vmla_vf_vf_vf_vf_sve_sleef((t), (vcast_vf_f_sve_sleef(0.0425049886107444763183594f)), (vcast_vf_f_sve_sleef(-0.0748900920152664184570312f)))))), (vmla_vf_vf_vf_vf_sve_sleef((t2), (vmla_vf_vf_vf_vf_sve_sleef((t), (vcast_vf_f_sve_sleef(0.106347933411598205566406f)), (vcast_vf_f_sve_sleef(-0.142027363181114196777344f)))), (vmla_vf_vf_vf_vf_sve_sleef((t), (vcast_vf_f_sve_sleef(0.199926957488059997558594f)), (vcast_vf_f_sve_sleef(-0.333331018686294555664062f))))))) + + ; + + t = vmla_vf_vf_vf_vf_sve_sleef(s, vmul_vf_vf_vf_sve_sleef(t, u), s); + t = vmla_vf_vf_vf_vf_sve_sleef(vcast_vf_vi2_sve_sleef(q), vcast_vf_f_sve_sleef((float)(3.141592653589793238462643383279502884/2)), t); + + return t; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_sve_sleef visinf2_vf_vf_vf_sve_sleef(vfloat_sve_sleef d, vfloat_sve_sleef m) { + return vreinterpret_vf_vm_sve_sleef(vand_vm_vo32_vm_sve_sleef(visinf_vo_vf_sve_sleef(d), vor_vm_vm_vm_sve_sleef(vsignbit_vm_vf_sve_sleef(d), vreinterpret_vm_vf_sve_sleef(m)))); +} + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_atan2fx_u35sve(vfloat_sve_sleef y, vfloat_sve_sleef x) { + vfloat_sve_sleef r = atan2kf_sve_sleef(vabs_vf_vf_sve_sleef(y), x); + + r = vmulsign_vf_vf_vf_sve_sleef(r, x); + r = vsel_vf_vo_vf_vf_sve_sleef(vor_vo_vo_vo_sve_sleef(visinf_vo_vf_sve_sleef(x), veq_vo_vf_vf_sve_sleef(x, vcast_vf_f_sve_sleef(0.0f))), vsub_vf_vf_vf_sve_sleef(vcast_vf_f_sve_sleef((float)(3.141592653589793238462643383279502884/2)), visinf2_vf_vf_vf_sve_sleef(x, vmulsign_vf_vf_vf_sve_sleef(vcast_vf_f_sve_sleef((float)(3.141592653589793238462643383279502884/2)), x))), r); + r = vsel_vf_vo_vf_vf_sve_sleef(visinf_vo_vf_sve_sleef(y), vsub_vf_vf_vf_sve_sleef(vcast_vf_f_sve_sleef((float)(3.141592653589793238462643383279502884/2)), visinf2_vf_vf_vf_sve_sleef(x, vmulsign_vf_vf_vf_sve_sleef(vcast_vf_f_sve_sleef((float)(3.141592653589793238462643383279502884/4)), x))), r); + + r = vsel_vf_vo_vf_vf_sve_sleef(veq_vo_vf_vf_sve_sleef(y, vcast_vf_f_sve_sleef(0.0f)), vreinterpret_vf_vm_sve_sleef(vand_vm_vo32_vm_sve_sleef(vsignbit_vo_vf_sve_sleef(x), vreinterpret_vm_vf_sve_sleef(vcast_vf_f_sve_sleef((float)3.141592653589793238462643383279502884)))), r); + + r = vreinterpret_vf_vm_sve_sleef(vor_vm_vo32_vm_sve_sleef(vor_vo_vo_vo_sve_sleef(visnan_vo_vf_sve_sleef(x), visnan_vo_vf_sve_sleef(y)), vreinterpret_vm_vf_sve_sleef(vmulsign_vf_vf_vf_sve_sleef(r, y)))); + return r; +} + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_asinfx_u35sve(vfloat_sve_sleef d) { + vopmask_sve_sleef o = vlt_vo_vf_vf_sve_sleef(vabs_vf_vf_sve_sleef(d), vcast_vf_f_sve_sleef(0.5f)); + vfloat_sve_sleef x2 = vsel_vf_vo_vf_vf_sve_sleef(o, vmul_vf_vf_vf_sve_sleef(d, d), vmul_vf_vf_vf_sve_sleef(vsub_vf_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(1), vabs_vf_vf_sve_sleef(d)), vcast_vf_f_sve_sleef(0.5f))); + vfloat_sve_sleef x = vsel_vf_vo_vf_vf_sve_sleef(o, vabs_vf_vf_sve_sleef(d), vsqrt_vf_vf_sve_sleef(x2)), u; + + u = vcast_vf_f_sve_sleef(+0.4197454825e-1); + u = vmla_vf_vf_vf_vf_sve_sleef(u, x2, vcast_vf_f_sve_sleef(+0.2424046025e-1)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, x2, vcast_vf_f_sve_sleef(+0.4547423869e-1)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, x2, vcast_vf_f_sve_sleef(+0.7495029271e-1)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, x2, vcast_vf_f_sve_sleef(+0.1666677296e+0)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, vmul_vf_vf_vf_sve_sleef(x, x2), x); + + vfloat_sve_sleef r = vsel_vf_vo_vf_vf_sve_sleef(o, u, vmla_vf_vf_vf_vf_sve_sleef(u, vcast_vf_f_sve_sleef(-2), vcast_vf_f_sve_sleef(((float)3.141592653589793238462643383279502884)/2))); + return vmulsign_vf_vf_vf_sve_sleef(r, d); +} + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_acosfx_u35sve(vfloat_sve_sleef d) { + vopmask_sve_sleef o = vlt_vo_vf_vf_sve_sleef(vabs_vf_vf_sve_sleef(d), vcast_vf_f_sve_sleef(0.5f)); + vfloat_sve_sleef x2 = vsel_vf_vo_vf_vf_sve_sleef(o, vmul_vf_vf_vf_sve_sleef(d, d), + vmul_vf_vf_vf_sve_sleef(vsub_vf_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(1), vabs_vf_vf_sve_sleef(d)), vcast_vf_f_sve_sleef(0.5f))), u; + vfloat_sve_sleef x = vsel_vf_vo_vf_vf_sve_sleef(o, vabs_vf_vf_sve_sleef(d), vsqrt_vf_vf_sve_sleef(x2)); + x = vsel_vf_vo_vf_vf_sve_sleef(veq_vo_vf_vf_sve_sleef(vabs_vf_vf_sve_sleef(d), vcast_vf_f_sve_sleef(1.0f)), vcast_vf_f_sve_sleef(0), x); + + u = vcast_vf_f_sve_sleef(+0.4197454825e-1); + u = vmla_vf_vf_vf_vf_sve_sleef(u, x2, vcast_vf_f_sve_sleef(+0.2424046025e-1)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, x2, vcast_vf_f_sve_sleef(+0.4547423869e-1)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, x2, vcast_vf_f_sve_sleef(+0.7495029271e-1)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, x2, vcast_vf_f_sve_sleef(+0.1666677296e+0)); + u = vmul_vf_vf_vf_sve_sleef(u, vmul_vf_vf_vf_sve_sleef(x2, x)); + + vfloat_sve_sleef y = vsub_vf_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(3.1415926535897932f/2), vadd_vf_vf_vf_sve_sleef(vmulsign_vf_vf_vf_sve_sleef(x, d), vmulsign_vf_vf_vf_sve_sleef(u, d))); + x = vadd_vf_vf_vf_sve_sleef(x, u); + vfloat_sve_sleef r = vsel_vf_vo_vf_vf_sve_sleef(o, y, vmul_vf_vf_vf_sve_sleef(x, vcast_vf_f_sve_sleef(2))); + return vsel_vf_vo_vf_vf_sve_sleef(vandnot_vo_vo_vo_sve_sleef(o, vlt_vo_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(0))), + vf2getx_vf_vf2_sve_sleef(dfadd_vf2_vf2_vf_sve_sleef(vcast_vf2_f_f_sve_sleef(3.1415927410125732422f,-8.7422776573475857731e-08f), + vneg_vf_vf_sve_sleef(r))), r); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_sve_sleef atan2kf_u1_sve_sleef(vfloat2_sve_sleef y, vfloat2_sve_sleef x) { + vfloat_sve_sleef u; + vfloat2_sve_sleef s, t; + vint2_sve_sleef q; + vopmask_sve_sleef p; + vmask_sve_sleef r; + + q = vsel_vi2_vf_vf_vi2_vi2_sve_sleef(vf2getx_vf_vf2_sve_sleef(x), vcast_vf_f_sve_sleef(0), vcast_vi2_i_sve_sleef(-2), vcast_vi2_i_sve_sleef(0)); + p = vlt_vo_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(x), vcast_vf_f_sve_sleef(0)); + r = vand_vm_vo32_vm_sve_sleef(p, vreinterpret_vm_vf_sve_sleef(vcast_vf_f_sve_sleef(-0.0))); + x = vf2setx_vf2_vf2_vf_sve_sleef(x, vreinterpret_vf_vm_sve_sleef(vxor_vm_vm_vm_sve_sleef(vreinterpret_vm_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(x)), r))); + x = vf2sety_vf2_vf2_vf_sve_sleef(x, vreinterpret_vf_vm_sve_sleef(vxor_vm_vm_vm_sve_sleef(vreinterpret_vm_vf_sve_sleef(vf2gety_vf_vf2_sve_sleef(x)), r))); + + q = vsel_vi2_vf_vf_vi2_vi2_sve_sleef(vf2getx_vf_vf2_sve_sleef(x), vf2getx_vf_vf2_sve_sleef(y), vadd_vi2_vi2_vi2_sve_sleef(q, vcast_vi2_i_sve_sleef(1)), q); + p = vlt_vo_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(x), vf2getx_vf_vf2_sve_sleef(y)); + s = vsel_vf2_vo_vf2_vf2_sve_sleef(p, dfneg_vf2_vf2_sve_sleef(x), y); + t = vsel_vf2_vo_vf2_vf2_sve_sleef(p, y, x); + + s = dfdiv_vf2_vf2_vf2_sve_sleef(s, t); + t = dfsqu_vf2_vf2_sve_sleef(s); + t = dfnormalize_vf2_vf2_sve_sleef(t); + + u = vcast_vf_f_sve_sleef(-0.00176397908944636583328247f); + u = vmla_vf_vf_vf_vf_sve_sleef(u, vf2getx_vf_vf2_sve_sleef(t), vcast_vf_f_sve_sleef(0.0107900900766253471374512f)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, vf2getx_vf_vf2_sve_sleef(t), vcast_vf_f_sve_sleef(-0.0309564601629972457885742f)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, vf2getx_vf_vf2_sve_sleef(t), vcast_vf_f_sve_sleef(0.0577365085482597351074219f)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, vf2getx_vf_vf2_sve_sleef(t), vcast_vf_f_sve_sleef(-0.0838950723409652709960938f)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, vf2getx_vf_vf2_sve_sleef(t), vcast_vf_f_sve_sleef(0.109463557600975036621094f)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, vf2getx_vf_vf2_sve_sleef(t), vcast_vf_f_sve_sleef(-0.142626821994781494140625f)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, vf2getx_vf_vf2_sve_sleef(t), vcast_vf_f_sve_sleef(0.199983194470405578613281f)); + + t = dfmul_vf2_vf2_vf2_sve_sleef(t, dfadd_vf2_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(-0.333332866430282592773438f), vmul_vf_vf_vf_sve_sleef(u, vf2getx_vf_vf2_sve_sleef(t)))); + t = dfmul_vf2_vf2_vf2_sve_sleef(s, dfadd_vf2_vf_vf2_sve_sleef(vcast_vf_f_sve_sleef(1), t)); + t = dfadd_vf2_vf2_vf2_sve_sleef(dfmul_vf2_vf2_vf_sve_sleef(vcast_vf2_f_f_sve_sleef(1.5707963705062866211f, -4.3711388286737928865e-08f), vcast_vf_vi2_sve_sleef(q)), t); + + return t; +} + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_atan2fx_u10sve(vfloat_sve_sleef y, vfloat_sve_sleef x) { + vopmask_sve_sleef o = vlt_vo_vf_vf_sve_sleef(vabs_vf_vf_sve_sleef(x), vcast_vf_f_sve_sleef(2.9387372783541830947e-39f)); + x = vsel_vf_vo_vf_vf_sve_sleef(o, vmul_vf_vf_vf_sve_sleef(x, vcast_vf_f_sve_sleef(1 << 24)), x); + y = vsel_vf_vo_vf_vf_sve_sleef(o, vmul_vf_vf_vf_sve_sleef(y, vcast_vf_f_sve_sleef(1 << 24)), y); + + vfloat2_sve_sleef d = atan2kf_u1_sve_sleef(vcast_vf2_vf_vf_sve_sleef(vabs_vf_vf_sve_sleef(y), vcast_vf_f_sve_sleef(0)), vcast_vf2_vf_vf_sve_sleef(x, vcast_vf_f_sve_sleef(0))); + vfloat_sve_sleef r = vadd_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(d), vf2gety_vf_vf2_sve_sleef(d)); + + r = vmulsign_vf_vf_vf_sve_sleef(r, x); + r = vsel_vf_vo_vf_vf_sve_sleef(vor_vo_vo_vo_sve_sleef(visinf_vo_vf_sve_sleef(x), veq_vo_vf_vf_sve_sleef(x, vcast_vf_f_sve_sleef(0))), vsub_vf_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(3.141592653589793238462643383279502884/2), visinf2_vf_vf_vf_sve_sleef(x, vmulsign_vf_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(3.141592653589793238462643383279502884/2), x))), r); + r = vsel_vf_vo_vf_vf_sve_sleef(visinf_vo_vf_sve_sleef(y), vsub_vf_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(3.141592653589793238462643383279502884/2), visinf2_vf_vf_vf_sve_sleef(x, vmulsign_vf_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(3.141592653589793238462643383279502884/4), x))), r); + r = vsel_vf_vo_vf_vf_sve_sleef(veq_vo_vf_vf_sve_sleef(y, vcast_vf_f_sve_sleef(0.0f)), vreinterpret_vf_vm_sve_sleef(vand_vm_vo32_vm_sve_sleef(vsignbit_vo_vf_sve_sleef(x), vreinterpret_vm_vf_sve_sleef(vcast_vf_f_sve_sleef((float)3.141592653589793238462643383279502884)))), r); + + r = vreinterpret_vf_vm_sve_sleef(vor_vm_vo32_vm_sve_sleef(vor_vo_vo_vo_sve_sleef(visnan_vo_vf_sve_sleef(x), visnan_vo_vf_sve_sleef(y)), vreinterpret_vm_vf_sve_sleef(vmulsign_vf_vf_vf_sve_sleef(r, y)))); + return r; +} + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_asinfx_u10sve(vfloat_sve_sleef d) { + vopmask_sve_sleef o = vlt_vo_vf_vf_sve_sleef(vabs_vf_vf_sve_sleef(d), vcast_vf_f_sve_sleef(0.5f)); + vfloat_sve_sleef x2 = vsel_vf_vo_vf_vf_sve_sleef(o, vmul_vf_vf_vf_sve_sleef(d, d), vmul_vf_vf_vf_sve_sleef(vsub_vf_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(1), vabs_vf_vf_sve_sleef(d)), vcast_vf_f_sve_sleef(0.5f))), u; + vfloat2_sve_sleef x = vsel_vf2_vo_vf2_vf2_sve_sleef(o, vcast_vf2_vf_vf_sve_sleef(vabs_vf_vf_sve_sleef(d), vcast_vf_f_sve_sleef(0)), dfsqrt_vf2_vf_sve_sleef(x2)); + x = vsel_vf2_vo_vf2_vf2_sve_sleef(veq_vo_vf_vf_sve_sleef(vabs_vf_vf_sve_sleef(d), vcast_vf_f_sve_sleef(1.0f)), vcast_vf2_f_f_sve_sleef(0, 0), x); + + u = vcast_vf_f_sve_sleef(+0.4197454825e-1); + u = vmla_vf_vf_vf_vf_sve_sleef(u, x2, vcast_vf_f_sve_sleef(+0.2424046025e-1)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, x2, vcast_vf_f_sve_sleef(+0.4547423869e-1)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, x2, vcast_vf_f_sve_sleef(+0.7495029271e-1)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, x2, vcast_vf_f_sve_sleef(+0.1666677296e+0)); + u = vmul_vf_vf_vf_sve_sleef(u, vmul_vf_vf_vf_sve_sleef(x2, vf2getx_vf_vf2_sve_sleef(x))); + + vfloat2_sve_sleef y = dfsub_vf2_vf2_vf_sve_sleef(dfsub_vf2_vf2_vf2_sve_sleef(vcast_vf2_f_f_sve_sleef(3.1415927410125732422f/4,-8.7422776573475857731e-08f/4), x), u); + + vfloat_sve_sleef r = vsel_vf_vo_vf_vf_sve_sleef(o, vadd_vf_vf_vf_sve_sleef(u, vf2getx_vf_vf2_sve_sleef(x)), + vmul_vf_vf_vf_sve_sleef(vadd_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(y), vf2gety_vf_vf2_sve_sleef(y)), vcast_vf_f_sve_sleef(2))); + return vmulsign_vf_vf_vf_sve_sleef(r, d); +} + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_acosfx_u10sve(vfloat_sve_sleef d) { + vopmask_sve_sleef o = vlt_vo_vf_vf_sve_sleef(vabs_vf_vf_sve_sleef(d), vcast_vf_f_sve_sleef(0.5f)); + vfloat_sve_sleef x2 = vsel_vf_vo_vf_vf_sve_sleef(o, vmul_vf_vf_vf_sve_sleef(d, d), vmul_vf_vf_vf_sve_sleef(vsub_vf_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(1), vabs_vf_vf_sve_sleef(d)), vcast_vf_f_sve_sleef(0.5f))), u; + vfloat2_sve_sleef x = vsel_vf2_vo_vf2_vf2_sve_sleef(o, vcast_vf2_vf_vf_sve_sleef(vabs_vf_vf_sve_sleef(d), vcast_vf_f_sve_sleef(0)), dfsqrt_vf2_vf_sve_sleef(x2)); + x = vsel_vf2_vo_vf2_vf2_sve_sleef(veq_vo_vf_vf_sve_sleef(vabs_vf_vf_sve_sleef(d), vcast_vf_f_sve_sleef(1.0f)), vcast_vf2_f_f_sve_sleef(0, 0), x); + + u = vcast_vf_f_sve_sleef(+0.4197454825e-1); + u = vmla_vf_vf_vf_vf_sve_sleef(u, x2, vcast_vf_f_sve_sleef(+0.2424046025e-1)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, x2, vcast_vf_f_sve_sleef(+0.4547423869e-1)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, x2, vcast_vf_f_sve_sleef(+0.7495029271e-1)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, x2, vcast_vf_f_sve_sleef(+0.1666677296e+0)); + u = vmul_vf_vf_vf_sve_sleef(u, vmul_vf_vf_vf_sve_sleef(x2, vf2getx_vf_vf2_sve_sleef(x))); + + vfloat2_sve_sleef y = dfsub_vf2_vf2_vf2_sve_sleef(vcast_vf2_f_f_sve_sleef(3.1415927410125732422f/2, -8.7422776573475857731e-08f/2), + dfadd_vf2_vf_vf_sve_sleef(vmulsign_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(x), d), vmulsign_vf_vf_vf_sve_sleef(u, d))); + x = dfadd_vf2_vf2_vf_sve_sleef(x, u); + + y = vsel_vf2_vo_vf2_vf2_sve_sleef(o, y, dfscale_vf2_vf2_vf_sve_sleef(x, vcast_vf_f_sve_sleef(2))); + + y = vsel_vf2_vo_vf2_vf2_sve_sleef(vandnot_vo_vo_vo_sve_sleef(o, vlt_vo_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(0))), + dfsub_vf2_vf2_vf2_sve_sleef(vcast_vf2_f_f_sve_sleef(3.1415927410125732422f, -8.7422776573475857731e-08f), y), y); + + return vadd_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(y), vf2gety_vf_vf2_sve_sleef(y)); +} + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_atanfx_u10sve(vfloat_sve_sleef d) { + vfloat2_sve_sleef d2 = atan2kf_u1_sve_sleef(vcast_vf2_vf_vf_sve_sleef(vabs_vf_vf_sve_sleef(d), vcast_vf_f_sve_sleef(0)), vcast_vf2_f_f_sve_sleef(1, 0)); + vfloat_sve_sleef r = vadd_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(d2), vf2gety_vf_vf2_sve_sleef(d2)); + r = vsel_vf_vo_vf_vf_sve_sleef(visinf_vo_vf_sve_sleef(d), vcast_vf_f_sve_sleef(1.570796326794896557998982), r); + return vmulsign_vf_vf_vf_sve_sleef(r, d); +} + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_logfx_u35sve(vfloat_sve_sleef d) { + vfloat_sve_sleef x, x2, t, m; + + vopmask_sve_sleef o = vlt_vo_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(0x1p-126)); + d = vsel_vf_vo_vf_vf_sve_sleef(o, vmul_vf_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef((float)(INT64_C(1) << 32) * (float)(INT64_C(1) << 32))), d); + vint2_sve_sleef e = vilogb2k_vi2_vf_sve_sleef(vmul_vf_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(1.0f/0.75f))); + m = vldexp3_vf_vf_vi2_sve_sleef(d, vneg_vi2_vi2_sve_sleef(e)); + e = vsel_vi2_vo_vi2_vi2_sve_sleef(o, vsub_vi2_vi2_vi2_sve_sleef(e, vcast_vi2_i_sve_sleef(64)), e); + + x = vdiv_vf_vf_vf_sve_sleef(vsub_vf_vf_vf_sve_sleef(m, vcast_vf_f_sve_sleef(1.0f)), vadd_vf_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(1.0f), m)); + x2 = vmul_vf_vf_vf_sve_sleef(x, x); + + t = vcast_vf_f_sve_sleef(0.2392828464508056640625f); + t = vmla_vf_vf_vf_vf_sve_sleef(t, x2, vcast_vf_f_sve_sleef(0.28518211841583251953125f)); + t = vmla_vf_vf_vf_vf_sve_sleef(t, x2, vcast_vf_f_sve_sleef(0.400005877017974853515625f)); + t = vmla_vf_vf_vf_vf_sve_sleef(t, x2, vcast_vf_f_sve_sleef(0.666666686534881591796875f)); + t = vmla_vf_vf_vf_vf_sve_sleef(t, x2, vcast_vf_f_sve_sleef(2.0f)); + + x = vmla_vf_vf_vf_vf_sve_sleef(x, t, vmul_vf_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(0.693147180559945286226764f), vcast_vf_vi2_sve_sleef(e))); + x = vsel_vf_vo_vf_vf_sve_sleef(vispinf_vo_vf_sve_sleef(d), vcast_vf_f_sve_sleef(__builtin_inff()), x); + x = vsel_vf_vo_vf_vf_sve_sleef(vor_vo_vo_vo_sve_sleef(vlt_vo_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(0)), visnan_vo_vf_sve_sleef(d)), vcast_vf_f_sve_sleef(__builtin_nanf("")), x); + x = vsel_vf_vo_vf_vf_sve_sleef(veq_vo_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(0)), vcast_vf_f_sve_sleef(-__builtin_inff()), x); + + return x; +} + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_expfx_u10sve(vfloat_sve_sleef d) { + vint2_sve_sleef q = vrint_vi2_vf_sve_sleef(vmul_vf_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(1.442695040888963407359924681001892137426645954152985934135449406931f))); + vfloat_sve_sleef s, u; + + s = vmla_vf_vf_vf_vf_sve_sleef(vcast_vf_vi2_sve_sleef(q), vcast_vf_f_sve_sleef(-0.693145751953125f), d); + s = vmla_vf_vf_vf_vf_sve_sleef(vcast_vf_vi2_sve_sleef(q), vcast_vf_f_sve_sleef(-1.428606765330187045e-06f), s); + + u = vcast_vf_f_sve_sleef(0.000198527617612853646278381); + u = vmla_vf_vf_vf_vf_sve_sleef(u, s, vcast_vf_f_sve_sleef(0.00139304355252534151077271)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, s, vcast_vf_f_sve_sleef(0.00833336077630519866943359)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, s, vcast_vf_f_sve_sleef(0.0416664853692054748535156)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, s, vcast_vf_f_sve_sleef(0.166666671633720397949219)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, s, vcast_vf_f_sve_sleef(0.5)); + + u = vadd_vf_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(1.0f), vmla_vf_vf_vf_vf_sve_sleef(vmul_vf_vf_vf_sve_sleef(s, s), u, s)); + + u = vldexp2_vf_vf_vi2_sve_sleef(u, q); + + u = vreinterpret_vf_vm_sve_sleef(vandnot_vm_vo32_vm_sve_sleef(vlt_vo_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(-104)), vreinterpret_vm_vf_sve_sleef(u))); + u = vsel_vf_vo_vf_vf_sve_sleef(vlt_vo_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(100), d), vcast_vf_f_sve_sleef(__builtin_inff()), u); + + return u; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_sve_sleef expm1fk_sve_sleef(vfloat_sve_sleef d) { + vint2_sve_sleef q = vrint_vi2_vf_sve_sleef(vmul_vf_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(1.442695040888963407359924681001892137426645954152985934135449406931f))); + vfloat_sve_sleef s, u; + + s = vmla_vf_vf_vf_vf_sve_sleef(vcast_vf_vi2_sve_sleef(q), vcast_vf_f_sve_sleef(-0.693145751953125f), d); + s = vmla_vf_vf_vf_vf_sve_sleef(vcast_vf_vi2_sve_sleef(q), vcast_vf_f_sve_sleef(-1.428606765330187045e-06f), s); + + vfloat_sve_sleef s2 = vmul_vf_vf_vf_sve_sleef(s, s), s4 = vmul_vf_vf_vf_sve_sleef(s2, s2); + u = vmla_vf_vf_vf_vf_sve_sleef((s4), (vmla_vf_vf_vf_vf_sve_sleef((s), (vcast_vf_f_sve_sleef(0.000198527617612853646278381)), (vcast_vf_f_sve_sleef(0.00139304355252534151077271)))), (vmla_vf_vf_vf_vf_sve_sleef((s2), (vmla_vf_vf_vf_vf_sve_sleef((s), (vcast_vf_f_sve_sleef(0.00833336077630519866943359)), (vcast_vf_f_sve_sleef(0.0416664853692054748535156)))), (vmla_vf_vf_vf_vf_sve_sleef((s), (vcast_vf_f_sve_sleef(0.166666671633720397949219)), (vcast_vf_f_sve_sleef(0.5))))))) + + ; + + u = vmla_vf_vf_vf_vf_sve_sleef(vmul_vf_vf_vf_sve_sleef(s, s), u, s); + + u = vsel_vf_vo_vf_vf_sve_sleef(veq_vo_vi2_vi2_sve_sleef(q, vcast_vi2_i_sve_sleef(0)), u, + vsub_vf_vf_vf_sve_sleef(vldexp2_vf_vf_vi2_sve_sleef(vadd_vf_vf_vf_sve_sleef(u, vcast_vf_f_sve_sleef(1)), q), vcast_vf_f_sve_sleef(1))); + + return u; +} + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_sqrtfx_u35sve(vfloat_sve_sleef d) { return vsqrt_vf_vf_sve_sleef(d); } + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_cbrtfx_u35sve(vfloat_sve_sleef d) { + vfloat_sve_sleef x, y, q = vcast_vf_f_sve_sleef(1.0), t; + vint2_sve_sleef e, qu, re; + + e = vadd_vi2_vi2_vi2_sve_sleef(vilogbk_vi2_vf_sve_sleef(vabs_vf_vf_sve_sleef(d)), vcast_vi2_i_sve_sleef(1)); + d = vldexp2_vf_vf_vi2_sve_sleef(d, vneg_vi2_vi2_sve_sleef(e)); + + t = vadd_vf_vf_vf_sve_sleef(vcast_vf_vi2_sve_sleef(e), vcast_vf_f_sve_sleef(6144)); + qu = vtruncate_vi2_vf_sve_sleef(vmul_vf_vf_vf_sve_sleef(t, vcast_vf_f_sve_sleef(1.0f/3.0f))); + re = vtruncate_vi2_vf_sve_sleef(vsub_vf_vf_vf_sve_sleef(t, vmul_vf_vf_vf_sve_sleef(vcast_vf_vi2_sve_sleef(qu), vcast_vf_f_sve_sleef(3)))); + + q = vsel_vf_vo_vf_vf_sve_sleef(veq_vo_vi2_vi2_sve_sleef(re, vcast_vi2_i_sve_sleef(1)), vcast_vf_f_sve_sleef(1.2599210498948731647672106f), q); + q = vsel_vf_vo_vf_vf_sve_sleef(veq_vo_vi2_vi2_sve_sleef(re, vcast_vi2_i_sve_sleef(2)), vcast_vf_f_sve_sleef(1.5874010519681994747517056f), q); + q = vldexp2_vf_vf_vi2_sve_sleef(q, vsub_vi2_vi2_vi2_sve_sleef(qu, vcast_vi2_i_sve_sleef(2048))); + + q = vmulsign_vf_vf_vf_sve_sleef(q, d); + d = vabs_vf_vf_sve_sleef(d); + + x = vcast_vf_f_sve_sleef(-0.601564466953277587890625f); + x = vmla_vf_vf_vf_vf_sve_sleef(x, d, vcast_vf_f_sve_sleef(2.8208892345428466796875f)); + x = vmla_vf_vf_vf_vf_sve_sleef(x, d, vcast_vf_f_sve_sleef(-5.532182216644287109375f)); + x = vmla_vf_vf_vf_vf_sve_sleef(x, d, vcast_vf_f_sve_sleef(5.898262500762939453125f)); + x = vmla_vf_vf_vf_vf_sve_sleef(x, d, vcast_vf_f_sve_sleef(-3.8095417022705078125f)); + x = vmla_vf_vf_vf_vf_sve_sleef(x, d, vcast_vf_f_sve_sleef(2.2241256237030029296875f)); + + y = vmul_vf_vf_vf_sve_sleef(vmul_vf_vf_vf_sve_sleef(d, x), x); + y = vmul_vf_vf_vf_sve_sleef(vsub_vf_vf_vf_sve_sleef(y, vmul_vf_vf_vf_sve_sleef(vmul_vf_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(2.0f / 3.0f), y), vmla_vf_vf_vf_vf_sve_sleef(y, x, vcast_vf_f_sve_sleef(-1.0f)))), q); + + return y; +} + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_cbrtfx_u10sve(vfloat_sve_sleef d) { + vfloat_sve_sleef x, y, z, t; + vfloat2_sve_sleef q2 = vcast_vf2_f_f_sve_sleef(1, 0), u, v; + vint2_sve_sleef e, qu, re; + + e = vadd_vi2_vi2_vi2_sve_sleef(vilogbk_vi2_vf_sve_sleef(vabs_vf_vf_sve_sleef(d)), vcast_vi2_i_sve_sleef(1)); + d = vldexp2_vf_vf_vi2_sve_sleef(d, vneg_vi2_vi2_sve_sleef(e)); + + t = vadd_vf_vf_vf_sve_sleef(vcast_vf_vi2_sve_sleef(e), vcast_vf_f_sve_sleef(6144)); + qu = vtruncate_vi2_vf_sve_sleef(vmul_vf_vf_vf_sve_sleef(t, vcast_vf_f_sve_sleef(1.0/3.0))); + re = vtruncate_vi2_vf_sve_sleef(vsub_vf_vf_vf_sve_sleef(t, vmul_vf_vf_vf_sve_sleef(vcast_vf_vi2_sve_sleef(qu), vcast_vf_f_sve_sleef(3)))); + + q2 = vsel_vf2_vo_vf2_vf2_sve_sleef(veq_vo_vi2_vi2_sve_sleef(re, vcast_vi2_i_sve_sleef(1)), vcast_vf2_f_f_sve_sleef(1.2599210739135742188f, -2.4018701694217270415e-08), q2); + q2 = vsel_vf2_vo_vf2_vf2_sve_sleef(veq_vo_vi2_vi2_sve_sleef(re, vcast_vi2_i_sve_sleef(2)), vcast_vf2_f_f_sve_sleef(1.5874010324478149414f, 1.9520385308169352356e-08), q2); + + q2 = vf2setx_vf2_vf2_vf_sve_sleef(q2, vmulsign_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(q2), d)); + q2 = vf2sety_vf2_vf2_vf_sve_sleef(q2, vmulsign_vf_vf_vf_sve_sleef(vf2gety_vf_vf2_sve_sleef(q2), d)); + d = vabs_vf_vf_sve_sleef(d); + + x = vcast_vf_f_sve_sleef(-0.601564466953277587890625f); + x = vmla_vf_vf_vf_vf_sve_sleef(x, d, vcast_vf_f_sve_sleef(2.8208892345428466796875f)); + x = vmla_vf_vf_vf_vf_sve_sleef(x, d, vcast_vf_f_sve_sleef(-5.532182216644287109375f)); + x = vmla_vf_vf_vf_vf_sve_sleef(x, d, vcast_vf_f_sve_sleef(5.898262500762939453125f)); + x = vmla_vf_vf_vf_vf_sve_sleef(x, d, vcast_vf_f_sve_sleef(-3.8095417022705078125f)); + x = vmla_vf_vf_vf_vf_sve_sleef(x, d, vcast_vf_f_sve_sleef(2.2241256237030029296875f)); + + y = vmul_vf_vf_vf_sve_sleef(x, x); y = vmul_vf_vf_vf_sve_sleef(y, y); x = vsub_vf_vf_vf_sve_sleef(x, vmul_vf_vf_vf_sve_sleef(vmlanp_vf_vf_vf_vf_sve_sleef(d, y, x), vcast_vf_f_sve_sleef(-1.0 / 3.0))); + + z = x; + + u = dfmul_vf2_vf_vf_sve_sleef(x, x); + u = dfmul_vf2_vf2_vf2_sve_sleef(u, u); + u = dfmul_vf2_vf2_vf_sve_sleef(u, d); + u = dfadd2_vf2_vf2_vf_sve_sleef(u, vneg_vf_vf_sve_sleef(x)); + y = vadd_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(u), vf2gety_vf_vf2_sve_sleef(u)); + + y = vmul_vf_vf_vf_sve_sleef(vmul_vf_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(-2.0 / 3.0), y), z); + v = dfadd2_vf2_vf2_vf_sve_sleef(dfmul_vf2_vf_vf_sve_sleef(z, z), y); + v = dfmul_vf2_vf2_vf_sve_sleef(v, d); + v = dfmul_vf2_vf2_vf2_sve_sleef(v, q2); + z = vldexp2_vf_vf_vi2_sve_sleef(vadd_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(v), vf2gety_vf_vf2_sve_sleef(v)), vsub_vi2_vi2_vi2_sve_sleef(qu, vcast_vi2_i_sve_sleef(2048))); + + z = vsel_vf_vo_vf_vf_sve_sleef(visinf_vo_vf_sve_sleef(d), vmulsign_vf_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(__builtin_inff()), vf2getx_vf_vf2_sve_sleef(q2)), z); + z = vsel_vf_vo_vf_vf_sve_sleef(veq_vo_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(0)), vreinterpret_vf_vm_sve_sleef(vsignbit_vm_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(q2))), z); + + return z; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_sve_sleef logkf_sve_sleef(vfloat_sve_sleef d) { + vfloat2_sve_sleef x, x2; + vfloat_sve_sleef t, m; + + vopmask_sve_sleef o = vlt_vo_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(0x1p-126)); + d = vsel_vf_vo_vf_vf_sve_sleef(o, vmul_vf_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef((float)(INT64_C(1) << 32) * (float)(INT64_C(1) << 32))), d); + vint2_sve_sleef e = vilogb2k_vi2_vf_sve_sleef(vmul_vf_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(1.0f/0.75f))); + m = vldexp3_vf_vf_vi2_sve_sleef(d, vneg_vi2_vi2_sve_sleef(e)); + e = vsel_vi2_vo_vi2_vi2_sve_sleef(o, vsub_vi2_vi2_vi2_sve_sleef(e, vcast_vi2_i_sve_sleef(64)), e); + + x = dfdiv_vf2_vf2_vf2_sve_sleef(dfadd2_vf2_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(-1), m), dfadd2_vf2_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(1), m)); + x2 = dfsqu_vf2_vf2_sve_sleef(x); + + t = vcast_vf_f_sve_sleef(0.240320354700088500976562); + t = vmla_vf_vf_vf_vf_sve_sleef(t, vf2getx_vf_vf2_sve_sleef(x2), vcast_vf_f_sve_sleef(0.285112679004669189453125)); + t = vmla_vf_vf_vf_vf_sve_sleef(t, vf2getx_vf_vf2_sve_sleef(x2), vcast_vf_f_sve_sleef(0.400007992982864379882812)); + vfloat2_sve_sleef c = vcast_vf2_f_f_sve_sleef(0.66666662693023681640625f, 3.69183861259614332084311e-09f); + + vfloat2_sve_sleef s = dfmul_vf2_vf2_vf_sve_sleef(vcast_vf2_f_f_sve_sleef(0.69314718246459960938f, -1.904654323148236017e-09f), vcast_vf_vi2_sve_sleef(e)); + + s = dfadd_vf2_vf2_vf2_sve_sleef(s, dfscale_vf2_vf2_vf_sve_sleef(x, vcast_vf_f_sve_sleef(2))); + s = dfadd_vf2_vf2_vf2_sve_sleef(s, dfmul_vf2_vf2_vf2_sve_sleef(dfmul_vf2_vf2_vf2_sve_sleef(x2, x), + dfadd2_vf2_vf2_vf2_sve_sleef(dfmul_vf2_vf2_vf_sve_sleef(x2, t), c))); + return s; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_sve_sleef logk3f_sve_sleef(vfloat_sve_sleef d) { + vfloat_sve_sleef x, x2, t, m; + + vopmask_sve_sleef o = vlt_vo_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(0x1p-126)); + d = vsel_vf_vo_vf_vf_sve_sleef(o, vmul_vf_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef((float)(INT64_C(1) << 32) * (float)(INT64_C(1) << 32))), d); + vint2_sve_sleef e = vilogb2k_vi2_vf_sve_sleef(vmul_vf_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(1.0f/0.75f))); + m = vldexp3_vf_vf_vi2_sve_sleef(d, vneg_vi2_vi2_sve_sleef(e)); + e = vsel_vi2_vo_vi2_vi2_sve_sleef(o, vsub_vi2_vi2_vi2_sve_sleef(e, vcast_vi2_i_sve_sleef(64)), e); + + x = vdiv_vf_vf_vf_sve_sleef(vsub_vf_vf_vf_sve_sleef(m, vcast_vf_f_sve_sleef(1.0f)), vadd_vf_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(1.0f), m)); + x2 = vmul_vf_vf_vf_sve_sleef(x, x); + + t = vcast_vf_f_sve_sleef(0.2392828464508056640625f); + t = vmla_vf_vf_vf_vf_sve_sleef(t, x2, vcast_vf_f_sve_sleef(0.28518211841583251953125f)); + t = vmla_vf_vf_vf_vf_sve_sleef(t, x2, vcast_vf_f_sve_sleef(0.400005877017974853515625f)); + t = vmla_vf_vf_vf_vf_sve_sleef(t, x2, vcast_vf_f_sve_sleef(0.666666686534881591796875f)); + t = vmla_vf_vf_vf_vf_sve_sleef(t, x2, vcast_vf_f_sve_sleef(2.0f)); + + x = vmla_vf_vf_vf_vf_sve_sleef(x, t, vmul_vf_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(0.693147180559945286226764f), vcast_vf_vi2_sve_sleef(e))); + + return x; +} + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_logfx_u10sve(vfloat_sve_sleef d) { + vfloat2_sve_sleef x; + vfloat_sve_sleef t, m, x2; + + vopmask_sve_sleef o = vlt_vo_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(0x1p-126)); + d = vsel_vf_vo_vf_vf_sve_sleef(o, vmul_vf_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef((float)(INT64_C(1) << 32) * (float)(INT64_C(1) << 32))), d); + vint2_sve_sleef e = vilogb2k_vi2_vf_sve_sleef(vmul_vf_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(1.0f/0.75f))); + m = vldexp3_vf_vf_vi2_sve_sleef(d, vneg_vi2_vi2_sve_sleef(e)); + e = vsel_vi2_vo_vi2_vi2_sve_sleef(o, vsub_vi2_vi2_vi2_sve_sleef(e, vcast_vi2_i_sve_sleef(64)), e); + vfloat2_sve_sleef s = dfmul_vf2_vf2_vf_sve_sleef(vcast_vf2_f_f_sve_sleef(0.69314718246459960938f, -1.904654323148236017e-09f), vcast_vf_vi2_sve_sleef(e)); + + x = dfdiv_vf2_vf2_vf2_sve_sleef(dfadd2_vf2_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(-1), m), dfadd2_vf2_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(1), m)); + x2 = vmul_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(x), vf2getx_vf_vf2_sve_sleef(x)); + + t = vcast_vf_f_sve_sleef(+0.3027294874e+0f); + t = vmla_vf_vf_vf_vf_sve_sleef(t, x2, vcast_vf_f_sve_sleef(+0.3996108174e+0f)); + t = vmla_vf_vf_vf_vf_sve_sleef(t, x2, vcast_vf_f_sve_sleef(+0.6666694880e+0f)); + + s = dfadd_vf2_vf2_vf2_sve_sleef(s, dfscale_vf2_vf2_vf_sve_sleef(x, vcast_vf_f_sve_sleef(2))); + s = dfadd_vf2_vf2_vf_sve_sleef(s, vmul_vf_vf_vf_sve_sleef(vmul_vf_vf_vf_sve_sleef(x2, vf2getx_vf_vf2_sve_sleef(x)), t)); + + vfloat_sve_sleef r = vadd_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(s), vf2gety_vf_vf2_sve_sleef(s)); + + r = vsel_vf_vo_vf_vf_sve_sleef(vispinf_vo_vf_sve_sleef(d), vcast_vf_f_sve_sleef(__builtin_inff()), r); + r = vsel_vf_vo_vf_vf_sve_sleef(vor_vo_vo_vo_sve_sleef(vlt_vo_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(0)), visnan_vo_vf_sve_sleef(d)), vcast_vf_f_sve_sleef(__builtin_nanf("")), r); + r = vsel_vf_vo_vf_vf_sve_sleef(veq_vo_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(0)), vcast_vf_f_sve_sleef(-__builtin_inff()), r); + + return r; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_sve_sleef expkf_sve_sleef(vfloat2_sve_sleef d) { + vfloat_sve_sleef u = vmul_vf_vf_vf_sve_sleef(vadd_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(d), vf2gety_vf_vf2_sve_sleef(d)), vcast_vf_f_sve_sleef(1.442695040888963407359924681001892137426645954152985934135449406931f)); + vint2_sve_sleef q = vrint_vi2_vf_sve_sleef(u); + vfloat2_sve_sleef s, t; + + s = dfadd2_vf2_vf2_vf_sve_sleef(d, vmul_vf_vf_vf_sve_sleef(vcast_vf_vi2_sve_sleef(q), vcast_vf_f_sve_sleef(-0.693145751953125f))); + s = dfadd2_vf2_vf2_vf_sve_sleef(s, vmul_vf_vf_vf_sve_sleef(vcast_vf_vi2_sve_sleef(q), vcast_vf_f_sve_sleef(-1.428606765330187045e-06f))); + + s = dfnormalize_vf2_vf2_sve_sleef(s); + + u = vcast_vf_f_sve_sleef(0.00136324646882712841033936f); + u = vmla_vf_vf_vf_vf_sve_sleef(u, vf2getx_vf_vf2_sve_sleef(s), vcast_vf_f_sve_sleef(0.00836596917361021041870117f)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, vf2getx_vf_vf2_sve_sleef(s), vcast_vf_f_sve_sleef(0.0416710823774337768554688f)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, vf2getx_vf_vf2_sve_sleef(s), vcast_vf_f_sve_sleef(0.166665524244308471679688f)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, vf2getx_vf_vf2_sve_sleef(s), vcast_vf_f_sve_sleef(0.499999850988388061523438f)); + + t = dfadd_vf2_vf2_vf2_sve_sleef(s, dfmul_vf2_vf2_vf_sve_sleef(dfsqu_vf2_vf2_sve_sleef(s), u)); + + t = dfadd_vf2_vf_vf2_sve_sleef(vcast_vf_f_sve_sleef(1), t); + u = vadd_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(t), vf2gety_vf_vf2_sve_sleef(t)); + u = vldexp_vf_vf_vi2_sve_sleef(u, q); + + u = vreinterpret_vf_vm_sve_sleef(vandnot_vm_vo32_vm_sve_sleef(vlt_vo_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(d), vcast_vf_f_sve_sleef(-104)), vreinterpret_vm_vf_sve_sleef(u))); + + return u; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_sve_sleef expk3f_sve_sleef(vfloat_sve_sleef d) { + vint2_sve_sleef q = vrint_vi2_vf_sve_sleef(vmul_vf_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(1.442695040888963407359924681001892137426645954152985934135449406931f))); + vfloat_sve_sleef s, u; + + s = vmla_vf_vf_vf_vf_sve_sleef(vcast_vf_vi2_sve_sleef(q), vcast_vf_f_sve_sleef(-0.693145751953125f), d); + s = vmla_vf_vf_vf_vf_sve_sleef(vcast_vf_vi2_sve_sleef(q), vcast_vf_f_sve_sleef(-1.428606765330187045e-06f), s); + + u = vcast_vf_f_sve_sleef(0.000198527617612853646278381); + u = vmla_vf_vf_vf_vf_sve_sleef(u, s, vcast_vf_f_sve_sleef(0.00139304355252534151077271)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, s, vcast_vf_f_sve_sleef(0.00833336077630519866943359)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, s, vcast_vf_f_sve_sleef(0.0416664853692054748535156)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, s, vcast_vf_f_sve_sleef(0.166666671633720397949219)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, s, vcast_vf_f_sve_sleef(0.5)); + + u = vmla_vf_vf_vf_vf_sve_sleef(vmul_vf_vf_vf_sve_sleef(s, s), u, vadd_vf_vf_vf_sve_sleef(s, vcast_vf_f_sve_sleef(1.0f))); + u = vldexp2_vf_vf_vi2_sve_sleef(u, q); + + u = vreinterpret_vf_vm_sve_sleef(vandnot_vm_vo32_vm_sve_sleef(vlt_vo_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(-104)), vreinterpret_vm_vf_sve_sleef(u))); + + return u; +} + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_powfx_u10sve(vfloat_sve_sleef x, vfloat_sve_sleef y) { + + vopmask_sve_sleef yisint = vor_vo_vo_vo_sve_sleef(veq_vo_vf_vf_sve_sleef(vtruncate_vf_vf_sve_sleef(y), y), vgt_vo_vf_vf_sve_sleef(vabs_vf_vf_sve_sleef(y), vcast_vf_f_sve_sleef(1 << 24))); + vopmask_sve_sleef yisodd = vand_vo_vo_vo_sve_sleef(vand_vo_vo_vo_sve_sleef(veq_vo_vi2_vi2_sve_sleef(vand_vi2_vi2_vi2_sve_sleef(vtruncate_vi2_vf_sve_sleef(y), vcast_vi2_i_sve_sleef(1)), vcast_vi2_i_sve_sleef(1)), yisint), + vlt_vo_vf_vf_sve_sleef(vabs_vf_vf_sve_sleef(y), vcast_vf_f_sve_sleef(1 << 24))); + + vfloat_sve_sleef result = expkf_sve_sleef(dfmul_vf2_vf2_vf_sve_sleef(logkf_sve_sleef(vabs_vf_vf_sve_sleef(x)), y)); + + result = vsel_vf_vo_vf_vf_sve_sleef(visnan_vo_vf_sve_sleef(result), vcast_vf_f_sve_sleef(__builtin_inff()), result); + + result = vmul_vf_vf_vf_sve_sleef(result, + vsel_vf_vo_vf_vf_sve_sleef(vgt_vo_vf_vf_sve_sleef(x, vcast_vf_f_sve_sleef(0)), + vcast_vf_f_sve_sleef(1), + vsel_vf_vo_vf_vf_sve_sleef(yisint, vsel_vf_vo_vf_vf_sve_sleef(yisodd, vcast_vf_f_sve_sleef(-1.0f), vcast_vf_f_sve_sleef(1)), vcast_vf_f_sve_sleef(__builtin_nanf(""))))); + + vfloat_sve_sleef efx = vmulsign_vf_vf_vf_sve_sleef(vsub_vf_vf_vf_sve_sleef(vabs_vf_vf_sve_sleef(x), vcast_vf_f_sve_sleef(1)), y); + + result = vsel_vf_vo_vf_vf_sve_sleef(visinf_vo_vf_sve_sleef(y), + vreinterpret_vf_vm_sve_sleef(vandnot_vm_vo32_vm_sve_sleef(vlt_vo_vf_vf_sve_sleef(efx, vcast_vf_f_sve_sleef(0.0f)), + vreinterpret_vm_vf_sve_sleef(vsel_vf_vo_vf_vf_sve_sleef(veq_vo_vf_vf_sve_sleef(efx, vcast_vf_f_sve_sleef(0.0f)), + vcast_vf_f_sve_sleef(1.0f), + vcast_vf_f_sve_sleef(__builtin_inff()))))), + result); + + result = vsel_vf_vo_vf_vf_sve_sleef(vor_vo_vo_vo_sve_sleef(visinf_vo_vf_sve_sleef(x), veq_vo_vf_vf_sve_sleef(x, vcast_vf_f_sve_sleef(0.0))), + vmulsign_vf_vf_vf_sve_sleef(vsel_vf_vo_vf_vf_sve_sleef(vxor_vo_vo_vo_sve_sleef(vsignbit_vo_vf_sve_sleef(y), veq_vo_vf_vf_sve_sleef(x, vcast_vf_f_sve_sleef(0.0f))), + vcast_vf_f_sve_sleef(0), vcast_vf_f_sve_sleef(__builtin_inff())), + vsel_vf_vo_vf_vf_sve_sleef(yisodd, x, vcast_vf_f_sve_sleef(1))), result); + + result = vreinterpret_vf_vm_sve_sleef(vor_vm_vo32_vm_sve_sleef(vor_vo_vo_vo_sve_sleef(visnan_vo_vf_sve_sleef(x), visnan_vo_vf_sve_sleef(y)), vreinterpret_vm_vf_sve_sleef(result))); + + result = vsel_vf_vo_vf_vf_sve_sleef(vor_vo_vo_vo_sve_sleef(veq_vo_vf_vf_sve_sleef(y, vcast_vf_f_sve_sleef(0)), veq_vo_vf_vf_sve_sleef(x, vcast_vf_f_sve_sleef(1))), vcast_vf_f_sve_sleef(1), result); + + return result; + +} + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_fastpowfx_u3500sve(vfloat_sve_sleef x, vfloat_sve_sleef y) { + vfloat_sve_sleef result = expk3f_sve_sleef(vmul_vf_vf_vf_sve_sleef(logk3f_sve_sleef(vabs_vf_vf_sve_sleef(x)), y)); + vopmask_sve_sleef yisint = vor_vo_vo_vo_sve_sleef(veq_vo_vf_vf_sve_sleef(vtruncate_vf_vf_sve_sleef(y), y), vgt_vo_vf_vf_sve_sleef(vabs_vf_vf_sve_sleef(y), vcast_vf_f_sve_sleef(1 << 24))); + vopmask_sve_sleef yisodd = vand_vo_vo_vo_sve_sleef(vand_vo_vo_vo_sve_sleef(veq_vo_vi2_vi2_sve_sleef(vand_vi2_vi2_vi2_sve_sleef(vtruncate_vi2_vf_sve_sleef(y), vcast_vi2_i_sve_sleef(1)), vcast_vi2_i_sve_sleef(1)), yisint), + vlt_vo_vf_vf_sve_sleef(vabs_vf_vf_sve_sleef(y), vcast_vf_f_sve_sleef(1 << 24))); + + result = vsel_vf_vo_vf_vf_sve_sleef(vand_vo_vo_vo_sve_sleef(vsignbit_vo_vf_sve_sleef(x), yisodd), vneg_vf_vf_sve_sleef(result), result); + + result = vsel_vf_vo_vf_vf_sve_sleef(veq_vo_vf_vf_sve_sleef(x, vcast_vf_f_sve_sleef(0)), vcast_vf_f_sve_sleef(0), result); + result = vsel_vf_vo_vf_vf_sve_sleef(veq_vo_vf_vf_sve_sleef(y, vcast_vf_f_sve_sleef(0)), vcast_vf_f_sve_sleef(1), result); + + return result; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_sve_sleef expk2f_sve_sleef(vfloat2_sve_sleef d) { + vfloat_sve_sleef u = vmul_vf_vf_vf_sve_sleef(vadd_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(d), vf2gety_vf_vf2_sve_sleef(d)), vcast_vf_f_sve_sleef(1.442695040888963407359924681001892137426645954152985934135449406931f)); + vint2_sve_sleef q = vrint_vi2_vf_sve_sleef(u); + vfloat2_sve_sleef s, t; + + s = dfadd2_vf2_vf2_vf_sve_sleef(d, vmul_vf_vf_vf_sve_sleef(vcast_vf_vi2_sve_sleef(q), vcast_vf_f_sve_sleef(-0.693145751953125f))); + s = dfadd2_vf2_vf2_vf_sve_sleef(s, vmul_vf_vf_vf_sve_sleef(vcast_vf_vi2_sve_sleef(q), vcast_vf_f_sve_sleef(-1.428606765330187045e-06f))); + + u = vcast_vf_f_sve_sleef(+0.1980960224e-3f); + u = vmla_vf_vf_vf_vf_sve_sleef(u, vf2getx_vf_vf2_sve_sleef(s), vcast_vf_f_sve_sleef(+0.1394256484e-2f)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, vf2getx_vf_vf2_sve_sleef(s), vcast_vf_f_sve_sleef(+0.8333456703e-2f)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, vf2getx_vf_vf2_sve_sleef(s), vcast_vf_f_sve_sleef(+0.4166637361e-1f)); + + t = dfadd2_vf2_vf2_vf_sve_sleef(dfmul_vf2_vf2_vf_sve_sleef(s, u), vcast_vf_f_sve_sleef(+0.166666659414234244790680580464e+0f)); + t = dfadd2_vf2_vf2_vf_sve_sleef(dfmul_vf2_vf2_vf2_sve_sleef(s, t), vcast_vf_f_sve_sleef(0.5)); + t = dfadd2_vf2_vf2_vf2_sve_sleef(s, dfmul_vf2_vf2_vf2_sve_sleef(dfsqu_vf2_vf2_sve_sleef(s), t)); + + t = dfadd_vf2_vf_vf2_sve_sleef(vcast_vf_f_sve_sleef(1), t); + + t = vf2setx_vf2_vf2_vf_sve_sleef(t, vldexp2_vf_vf_vi2_sve_sleef(vf2getx_vf_vf2_sve_sleef(t), q)); + t = vf2sety_vf2_vf2_vf_sve_sleef(t, vldexp2_vf_vf_vi2_sve_sleef(vf2gety_vf_vf2_sve_sleef(t), q)); + + t = vf2setx_vf2_vf2_vf_sve_sleef(t, vreinterpret_vf_vm_sve_sleef(vandnot_vm_vo32_vm_sve_sleef(vlt_vo_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(d), vcast_vf_f_sve_sleef(-104)), vreinterpret_vm_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(t))))); + t = vf2sety_vf2_vf2_vf_sve_sleef(t, vreinterpret_vf_vm_sve_sleef(vandnot_vm_vo32_vm_sve_sleef(vlt_vo_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(d), vcast_vf_f_sve_sleef(-104)), vreinterpret_vm_vf_sve_sleef(vf2gety_vf_vf2_sve_sleef(t))))); + + return t; +} + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_sinhfx_u10sve(vfloat_sve_sleef x) { + vfloat_sve_sleef y = vabs_vf_vf_sve_sleef(x); + vfloat2_sve_sleef d = expk2f_sve_sleef(vcast_vf2_vf_vf_sve_sleef(y, vcast_vf_f_sve_sleef(0))); + d = dfsub_vf2_vf2_vf2_sve_sleef(d, dfrec_vf2_vf2_sve_sleef(d)); + y = vmul_vf_vf_vf_sve_sleef(vadd_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(d), vf2gety_vf_vf2_sve_sleef(d)), vcast_vf_f_sve_sleef(0.5)); + + y = vsel_vf_vo_vf_vf_sve_sleef(vor_vo_vo_vo_sve_sleef(vgt_vo_vf_vf_sve_sleef(vabs_vf_vf_sve_sleef(x), vcast_vf_f_sve_sleef(89)), + visnan_vo_vf_sve_sleef(y)), vcast_vf_f_sve_sleef(__builtin_inff()), y); + y = vmulsign_vf_vf_vf_sve_sleef(y, x); + y = vreinterpret_vf_vm_sve_sleef(vor_vm_vo32_vm_sve_sleef(visnan_vo_vf_sve_sleef(x), vreinterpret_vm_vf_sve_sleef(y))); + + return y; +} + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_coshfx_u10sve(vfloat_sve_sleef x) { + vfloat_sve_sleef y = vabs_vf_vf_sve_sleef(x); + vfloat2_sve_sleef d = expk2f_sve_sleef(vcast_vf2_vf_vf_sve_sleef(y, vcast_vf_f_sve_sleef(0))); + d = dfadd_vf2_vf2_vf2_sve_sleef(d, dfrec_vf2_vf2_sve_sleef(d)); + y = vmul_vf_vf_vf_sve_sleef(vadd_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(d), vf2gety_vf_vf2_sve_sleef(d)), vcast_vf_f_sve_sleef(0.5)); + + y = vsel_vf_vo_vf_vf_sve_sleef(vor_vo_vo_vo_sve_sleef(vgt_vo_vf_vf_sve_sleef(vabs_vf_vf_sve_sleef(x), vcast_vf_f_sve_sleef(89)), + visnan_vo_vf_sve_sleef(y)), vcast_vf_f_sve_sleef(__builtin_inff()), y); + y = vreinterpret_vf_vm_sve_sleef(vor_vm_vo32_vm_sve_sleef(visnan_vo_vf_sve_sleef(x), vreinterpret_vm_vf_sve_sleef(y))); + + return y; +} + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_tanhfx_u10sve(vfloat_sve_sleef x) { + vfloat_sve_sleef y = vabs_vf_vf_sve_sleef(x); + vfloat2_sve_sleef d = expk2f_sve_sleef(vcast_vf2_vf_vf_sve_sleef(y, vcast_vf_f_sve_sleef(0))); + vfloat2_sve_sleef e = dfrec_vf2_vf2_sve_sleef(d); + d = dfdiv_vf2_vf2_vf2_sve_sleef(dfadd_vf2_vf2_vf2_sve_sleef(d, dfneg_vf2_vf2_sve_sleef(e)), dfadd_vf2_vf2_vf2_sve_sleef(d, e)); + y = vadd_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(d), vf2gety_vf_vf2_sve_sleef(d)); + + y = vsel_vf_vo_vf_vf_sve_sleef(vor_vo_vo_vo_sve_sleef(vgt_vo_vf_vf_sve_sleef(vabs_vf_vf_sve_sleef(x), vcast_vf_f_sve_sleef(8.664339742f)), + visnan_vo_vf_sve_sleef(y)), vcast_vf_f_sve_sleef(1.0f), y); + y = vmulsign_vf_vf_vf_sve_sleef(y, x); + y = vreinterpret_vf_vm_sve_sleef(vor_vm_vo32_vm_sve_sleef(visnan_vo_vf_sve_sleef(x), vreinterpret_vm_vf_sve_sleef(y))); + + return y; +} + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_sinhfx_u35sve(vfloat_sve_sleef x) { + vfloat_sve_sleef e = expm1fk_sve_sleef(vabs_vf_vf_sve_sleef(x)); + vfloat_sve_sleef y = vdiv_vf_vf_vf_sve_sleef(vadd_vf_vf_vf_sve_sleef(e, vcast_vf_f_sve_sleef(2)), vadd_vf_vf_vf_sve_sleef(e, vcast_vf_f_sve_sleef(1))); + y = vmul_vf_vf_vf_sve_sleef(y, vmul_vf_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(0.5f), e)); + + y = vsel_vf_vo_vf_vf_sve_sleef(vor_vo_vo_vo_sve_sleef(vgt_vo_vf_vf_sve_sleef(vabs_vf_vf_sve_sleef(x), vcast_vf_f_sve_sleef(88)), + visnan_vo_vf_sve_sleef(y)), vcast_vf_f_sve_sleef(__builtin_inff()), y); + y = vmulsign_vf_vf_vf_sve_sleef(y, x); + y = vreinterpret_vf_vm_sve_sleef(vor_vm_vo32_vm_sve_sleef(visnan_vo_vf_sve_sleef(x), vreinterpret_vm_vf_sve_sleef(y))); + + return y; +} + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_coshfx_u35sve(vfloat_sve_sleef x) { + vfloat_sve_sleef e = Sleef_expfx_u10sve(vabs_vf_vf_sve_sleef(x)); + vfloat_sve_sleef y = vmla_vf_vf_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(0.5f), e, vdiv_vf_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(0.5), e)); + + y = vsel_vf_vo_vf_vf_sve_sleef(vor_vo_vo_vo_sve_sleef(vgt_vo_vf_vf_sve_sleef(vabs_vf_vf_sve_sleef(x), vcast_vf_f_sve_sleef(88)), + visnan_vo_vf_sve_sleef(y)), vcast_vf_f_sve_sleef(__builtin_inff()), y); + y = vreinterpret_vf_vm_sve_sleef(vor_vm_vo32_vm_sve_sleef(visnan_vo_vf_sve_sleef(x), vreinterpret_vm_vf_sve_sleef(y))); + + return y; +} + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_tanhfx_u35sve(vfloat_sve_sleef x) { + vfloat_sve_sleef d = expm1fk_sve_sleef(vmul_vf_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(2), vabs_vf_vf_sve_sleef(x))); + vfloat_sve_sleef y = vdiv_vf_vf_vf_sve_sleef(d, vadd_vf_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(2), d)); + + y = vsel_vf_vo_vf_vf_sve_sleef(vor_vo_vo_vo_sve_sleef(vgt_vo_vf_vf_sve_sleef(vabs_vf_vf_sve_sleef(x), vcast_vf_f_sve_sleef(8.664339742f)), + visnan_vo_vf_sve_sleef(y)), vcast_vf_f_sve_sleef(1.0f), y); + y = vmulsign_vf_vf_vf_sve_sleef(y, x); + y = vreinterpret_vf_vm_sve_sleef(vor_vm_vo32_vm_sve_sleef(visnan_vo_vf_sve_sleef(x), vreinterpret_vm_vf_sve_sleef(y))); + + return y; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_sve_sleef logk2f_sve_sleef(vfloat2_sve_sleef d) { + vfloat2_sve_sleef x, x2, m, s; + vfloat_sve_sleef t; + vint2_sve_sleef e; + + e = vilogbk_vi2_vf_sve_sleef(vmul_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(d), vcast_vf_f_sve_sleef(1.0f/0.75f))); + + m = dfscale_vf2_vf2_vf_sve_sleef(d, vpow2i_vf_vi2_sve_sleef(vneg_vi2_vi2_sve_sleef(e))); + + x = dfdiv_vf2_vf2_vf2_sve_sleef(dfadd2_vf2_vf2_vf_sve_sleef(m, vcast_vf_f_sve_sleef(-1)), dfadd2_vf2_vf2_vf_sve_sleef(m, vcast_vf_f_sve_sleef(1))); + x2 = dfsqu_vf2_vf2_sve_sleef(x); + + t = vcast_vf_f_sve_sleef(0.2392828464508056640625f); + t = vmla_vf_vf_vf_vf_sve_sleef(t, vf2getx_vf_vf2_sve_sleef(x2), vcast_vf_f_sve_sleef(0.28518211841583251953125f)); + t = vmla_vf_vf_vf_vf_sve_sleef(t, vf2getx_vf_vf2_sve_sleef(x2), vcast_vf_f_sve_sleef(0.400005877017974853515625f)); + t = vmla_vf_vf_vf_vf_sve_sleef(t, vf2getx_vf_vf2_sve_sleef(x2), vcast_vf_f_sve_sleef(0.666666686534881591796875f)); + + s = dfmul_vf2_vf2_vf_sve_sleef(vcast_vf2_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(0.69314718246459960938f), vcast_vf_f_sve_sleef(-1.904654323148236017e-09f)), vcast_vf_vi2_sve_sleef(e)); + s = dfadd_vf2_vf2_vf2_sve_sleef(s, dfscale_vf2_vf2_vf_sve_sleef(x, vcast_vf_f_sve_sleef(2))); + s = dfadd_vf2_vf2_vf2_sve_sleef(s, dfmul_vf2_vf2_vf_sve_sleef(dfmul_vf2_vf2_vf2_sve_sleef(x2, x), t)); + + return s; +} + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_asinhfx_u10sve(vfloat_sve_sleef x) { + vfloat_sve_sleef y = vabs_vf_vf_sve_sleef(x); + vopmask_sve_sleef o = vgt_vo_vf_vf_sve_sleef(y, vcast_vf_f_sve_sleef(1)); + vfloat2_sve_sleef d; + + d = vsel_vf2_vo_vf2_vf2_sve_sleef(o, dfrec_vf2_vf_sve_sleef(x), vcast_vf2_vf_vf_sve_sleef(y, vcast_vf_f_sve_sleef(0))); + d = dfsqrt_vf2_vf2_sve_sleef(dfadd2_vf2_vf2_vf_sve_sleef(dfsqu_vf2_vf2_sve_sleef(d), vcast_vf_f_sve_sleef(1))); + d = vsel_vf2_vo_vf2_vf2_sve_sleef(o, dfmul_vf2_vf2_vf_sve_sleef(d, y), d); + + d = logk2f_sve_sleef(dfnormalize_vf2_vf2_sve_sleef(dfadd2_vf2_vf2_vf_sve_sleef(d, x))); + y = vadd_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(d), vf2gety_vf_vf2_sve_sleef(d)); + + y = vsel_vf_vo_vf_vf_sve_sleef(vor_vo_vo_vo_sve_sleef(vgt_vo_vf_vf_sve_sleef(vabs_vf_vf_sve_sleef(x), vcast_vf_f_sve_sleef(18446743523953729536.0)), + visnan_vo_vf_sve_sleef(y)), + vmulsign_vf_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(__builtin_inff()), x), y); + y = vreinterpret_vf_vm_sve_sleef(vor_vm_vo32_vm_sve_sleef(visnan_vo_vf_sve_sleef(x), vreinterpret_vm_vf_sve_sleef(y))); + y = vsel_vf_vo_vf_vf_sve_sleef(visnegzero_vo_vf_sve_sleef(x), vcast_vf_f_sve_sleef(-0.0), y); + + return y; +} + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_acoshfx_u10sve(vfloat_sve_sleef x) { + vfloat2_sve_sleef d = logk2f_sve_sleef(dfadd2_vf2_vf2_vf_sve_sleef(dfmul_vf2_vf2_vf2_sve_sleef(dfsqrt_vf2_vf2_sve_sleef(dfadd2_vf2_vf_vf_sve_sleef(x, vcast_vf_f_sve_sleef(1))), dfsqrt_vf2_vf2_sve_sleef(dfadd2_vf2_vf_vf_sve_sleef(x, vcast_vf_f_sve_sleef(-1)))), x)); + vfloat_sve_sleef y = vadd_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(d), vf2gety_vf_vf2_sve_sleef(d)); + + y = vsel_vf_vo_vf_vf_sve_sleef(vor_vo_vo_vo_sve_sleef(vgt_vo_vf_vf_sve_sleef(vabs_vf_vf_sve_sleef(x), vcast_vf_f_sve_sleef(18446743523953729536.0)), + visnan_vo_vf_sve_sleef(y)), + vcast_vf_f_sve_sleef(__builtin_inff()), y); + + y = vreinterpret_vf_vm_sve_sleef(vandnot_vm_vo32_vm_sve_sleef(veq_vo_vf_vf_sve_sleef(x, vcast_vf_f_sve_sleef(1.0f)), vreinterpret_vm_vf_sve_sleef(y))); + + y = vreinterpret_vf_vm_sve_sleef(vor_vm_vo32_vm_sve_sleef(vlt_vo_vf_vf_sve_sleef(x, vcast_vf_f_sve_sleef(1.0f)), vreinterpret_vm_vf_sve_sleef(y))); + y = vreinterpret_vf_vm_sve_sleef(vor_vm_vo32_vm_sve_sleef(visnan_vo_vf_sve_sleef(x), vreinterpret_vm_vf_sve_sleef(y))); + + return y; +} + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_atanhfx_u10sve(vfloat_sve_sleef x) { + vfloat_sve_sleef y = vabs_vf_vf_sve_sleef(x); + vfloat2_sve_sleef d = logk2f_sve_sleef(dfdiv_vf2_vf2_vf2_sve_sleef(dfadd2_vf2_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(1), y), dfadd2_vf2_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(1), vneg_vf_vf_sve_sleef(y)))); + y = vreinterpret_vf_vm_sve_sleef(vor_vm_vo32_vm_sve_sleef(vgt_vo_vf_vf_sve_sleef(y, vcast_vf_f_sve_sleef(1.0)), vreinterpret_vm_vf_sve_sleef(vsel_vf_vo_vf_vf_sve_sleef(veq_vo_vf_vf_sve_sleef(y, vcast_vf_f_sve_sleef(1.0)), vcast_vf_f_sve_sleef(__builtin_inff()), vmul_vf_vf_vf_sve_sleef(vadd_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(d), vf2gety_vf_vf2_sve_sleef(d)), vcast_vf_f_sve_sleef(0.5)))))); + + y = vreinterpret_vf_vm_sve_sleef(vor_vm_vo32_vm_sve_sleef(vor_vo_vo_vo_sve_sleef(visinf_vo_vf_sve_sleef(x), visnan_vo_vf_sve_sleef(y)), vreinterpret_vm_vf_sve_sleef(y))); + y = vmulsign_vf_vf_vf_sve_sleef(y, x); + y = vreinterpret_vf_vm_sve_sleef(vor_vm_vo32_vm_sve_sleef(visnan_vo_vf_sve_sleef(x), vreinterpret_vm_vf_sve_sleef(y))); + + return y; +} + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_exp2fx_u10sve(vfloat_sve_sleef d) { + vfloat_sve_sleef u = vrint_vf_vf_sve_sleef(d), s; + vint2_sve_sleef q = vrint_vi2_vf_sve_sleef(u); + + s = vsub_vf_vf_vf_sve_sleef(d, u); + + u = vcast_vf_f_sve_sleef(+0.1535920892e-3); + u = vmla_vf_vf_vf_vf_sve_sleef(u, s, vcast_vf_f_sve_sleef(+0.1339262701e-2)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, s, vcast_vf_f_sve_sleef(+0.9618384764e-2)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, s, vcast_vf_f_sve_sleef(+0.5550347269e-1)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, s, vcast_vf_f_sve_sleef(+0.2402264476e+0)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, s, vcast_vf_f_sve_sleef(+0.6931471825e+0)); + + u = vfma_vf_vf_vf_vf_sve_sleef(u, s, vcast_vf_f_sve_sleef(1)); + + u = vldexp2_vf_vf_vi2_sve_sleef(u, q); + + u = vsel_vf_vo_vf_vf_sve_sleef(vge_vo_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(128)), vcast_vf_f_sve_sleef(__builtin_inf()), u); + u = vreinterpret_vf_vm_sve_sleef(vandnot_vm_vo32_vm_sve_sleef(vlt_vo_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(-150)), vreinterpret_vm_vf_sve_sleef(u))); + + return u; +} + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_exp2fx_u35sve(vfloat_sve_sleef d) { + vfloat_sve_sleef u = vrint_vf_vf_sve_sleef(d), s; + vint2_sve_sleef q = vrint_vi2_vf_sve_sleef(u); + + s = vsub_vf_vf_vf_sve_sleef(d, u); + + u = vcast_vf_f_sve_sleef(+0.1535920892e-3); + u = vmla_vf_vf_vf_vf_sve_sleef(u, s, vcast_vf_f_sve_sleef(+0.1339262701e-2)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, s, vcast_vf_f_sve_sleef(+0.9618384764e-2)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, s, vcast_vf_f_sve_sleef(+0.5550347269e-1)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, s, vcast_vf_f_sve_sleef(+0.2402264476e+0)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, s, vcast_vf_f_sve_sleef(+0.6931471825e+0)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, s, vcast_vf_f_sve_sleef(+0.1000000000e+1)); + + u = vldexp2_vf_vf_vi2_sve_sleef(u, q); + + u = vsel_vf_vo_vf_vf_sve_sleef(vge_vo_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(128)), vcast_vf_f_sve_sleef(__builtin_inf()), u); + u = vreinterpret_vf_vm_sve_sleef(vandnot_vm_vo32_vm_sve_sleef(vlt_vo_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(-150)), vreinterpret_vm_vf_sve_sleef(u))); + + return u; +} + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_exp10fx_u10sve(vfloat_sve_sleef d) { + vfloat_sve_sleef u = vrint_vf_vf_sve_sleef(vmul_vf_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(3.3219280948873623478703194294893901758648313930))), s; + vint2_sve_sleef q = vrint_vi2_vf_sve_sleef(u); + + s = vmla_vf_vf_vf_vf_sve_sleef(u, vcast_vf_f_sve_sleef(-0.3010253906f), d); + s = vmla_vf_vf_vf_vf_sve_sleef(u, vcast_vf_f_sve_sleef(-4.605038981e-06f), s); + + u = vcast_vf_f_sve_sleef(+0.6802555919e-1); + u = vmla_vf_vf_vf_vf_sve_sleef(u, s, vcast_vf_f_sve_sleef(+0.2078080326e+0)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, s, vcast_vf_f_sve_sleef(+0.5393903852e+0)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, s, vcast_vf_f_sve_sleef(+0.1171245337e+1)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, s, vcast_vf_f_sve_sleef(+0.2034678698e+1)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, s, vcast_vf_f_sve_sleef(+0.2650949001e+1)); + vfloat2_sve_sleef x = dfadd_vf2_vf2_vf_sve_sleef(vcast_vf2_f_f_sve_sleef(2.3025851249694824219, -3.1705172516493593157e-08), vmul_vf_vf_vf_sve_sleef(u, s)); + u = vf2getx_vf_vf2_sve_sleef(dfnormalize_vf2_vf2_sve_sleef(dfadd_vf2_vf_vf2_sve_sleef(vcast_vf_f_sve_sleef(1), dfmul_vf2_vf2_vf_sve_sleef(x, s)))); + + u = vldexp2_vf_vf_vi2_sve_sleef(u, q); + + u = vsel_vf_vo_vf_vf_sve_sleef(vgt_vo_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(38.5318394191036238941387f)), vcast_vf_f_sve_sleef(__builtin_inff()), u); + u = vreinterpret_vf_vm_sve_sleef(vandnot_vm_vo32_vm_sve_sleef(vlt_vo_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(-50)), vreinterpret_vm_vf_sve_sleef(u))); + + return u; +} + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_exp10fx_u35sve(vfloat_sve_sleef d) { + vfloat_sve_sleef u = vrint_vf_vf_sve_sleef(vmul_vf_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(3.3219280948873623478703194294893901758648313930))), s; + vint2_sve_sleef q = vrint_vi2_vf_sve_sleef(u); + + s = vmla_vf_vf_vf_vf_sve_sleef(u, vcast_vf_f_sve_sleef(-0.3010253906f), d); + s = vmla_vf_vf_vf_vf_sve_sleef(u, vcast_vf_f_sve_sleef(-4.605038981e-06f), s); + + u = vcast_vf_f_sve_sleef(+0.2064004987e+0); + u = vmla_vf_vf_vf_vf_sve_sleef(u, s, vcast_vf_f_sve_sleef(+0.5417877436e+0)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, s, vcast_vf_f_sve_sleef(+0.1171286821e+1)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, s, vcast_vf_f_sve_sleef(+0.2034656048e+1)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, s, vcast_vf_f_sve_sleef(+0.2650948763e+1)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, s, vcast_vf_f_sve_sleef(+0.2302585125e+1)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, s, vcast_vf_f_sve_sleef(+0.1000000000e+1)); + + u = vldexp2_vf_vf_vi2_sve_sleef(u, q); + + u = vsel_vf_vo_vf_vf_sve_sleef(vgt_vo_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(38.5318394191036238941387f)), vcast_vf_f_sve_sleef(__builtin_inff()), u); + u = vreinterpret_vf_vm_sve_sleef(vandnot_vm_vo32_vm_sve_sleef(vlt_vo_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(-50)), vreinterpret_vm_vf_sve_sleef(u))); + + return u; +} + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_expm1fx_u10sve(vfloat_sve_sleef a) { + vfloat2_sve_sleef d = dfadd2_vf2_vf2_vf_sve_sleef(expk2f_sve_sleef(vcast_vf2_vf_vf_sve_sleef(a, vcast_vf_f_sve_sleef(0))), vcast_vf_f_sve_sleef(-1.0)); + vfloat_sve_sleef x = vadd_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(d), vf2gety_vf_vf2_sve_sleef(d)); + x = vsel_vf_vo_vf_vf_sve_sleef(vgt_vo_vf_vf_sve_sleef(a, vcast_vf_f_sve_sleef(88.72283172607421875f)), vcast_vf_f_sve_sleef(__builtin_inff()), x); + x = vsel_vf_vo_vf_vf_sve_sleef(vlt_vo_vf_vf_sve_sleef(a, vcast_vf_f_sve_sleef(-16.635532333438687426013570f)), vcast_vf_f_sve_sleef(-1), x); + x = vsel_vf_vo_vf_vf_sve_sleef(visnegzero_vo_vf_sve_sleef(a), vcast_vf_f_sve_sleef(-0.0f), x); + return x; +} + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_log10fx_u10sve(vfloat_sve_sleef d) { + vfloat2_sve_sleef x; + vfloat_sve_sleef t, m, x2; + + vopmask_sve_sleef o = vlt_vo_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(0x1p-126)); + d = vsel_vf_vo_vf_vf_sve_sleef(o, vmul_vf_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef((float)(INT64_C(1) << 32) * (float)(INT64_C(1) << 32))), d); + vint2_sve_sleef e = vilogb2k_vi2_vf_sve_sleef(vmul_vf_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(1.0/0.75))); + m = vldexp3_vf_vf_vi2_sve_sleef(d, vneg_vi2_vi2_sve_sleef(e)); + e = vsel_vi2_vo_vi2_vi2_sve_sleef(o, vsub_vi2_vi2_vi2_sve_sleef(e, vcast_vi2_i_sve_sleef(64)), e); + + x = dfdiv_vf2_vf2_vf2_sve_sleef(dfadd2_vf2_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(-1), m), dfadd2_vf2_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(1), m)); + x2 = vmul_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(x), vf2getx_vf_vf2_sve_sleef(x)); + + t = vcast_vf_f_sve_sleef(+0.1314289868e+0); + t = vmla_vf_vf_vf_vf_sve_sleef(t, x2, vcast_vf_f_sve_sleef( +0.1735493541e+0)); + t = vmla_vf_vf_vf_vf_sve_sleef(t, x2, vcast_vf_f_sve_sleef( +0.2895309627e+0)); + + vfloat2_sve_sleef s = dfmul_vf2_vf2_vf_sve_sleef(vcast_vf2_f_f_sve_sleef(0.30103001, -1.432098889e-08), vcast_vf_vi2_sve_sleef(e)); + + s = dfadd_vf2_vf2_vf2_sve_sleef(s, dfmul_vf2_vf2_vf2_sve_sleef(x, vcast_vf2_f_f_sve_sleef(0.868588984, -2.170757285e-08))); + s = dfadd_vf2_vf2_vf_sve_sleef(s, vmul_vf_vf_vf_sve_sleef(vmul_vf_vf_vf_sve_sleef(x2, vf2getx_vf_vf2_sve_sleef(x)), t)); + + vfloat_sve_sleef r = vadd_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(s), vf2gety_vf_vf2_sve_sleef(s)); + + r = vsel_vf_vo_vf_vf_sve_sleef(vispinf_vo_vf_sve_sleef(d), vcast_vf_f_sve_sleef(__builtin_inf()), r); + r = vsel_vf_vo_vf_vf_sve_sleef(vor_vo_vo_vo_sve_sleef(vlt_vo_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(0)), visnan_vo_vf_sve_sleef(d)), vcast_vf_f_sve_sleef(__builtin_nan("")), r); + r = vsel_vf_vo_vf_vf_sve_sleef(veq_vo_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(0)), vcast_vf_f_sve_sleef(-__builtin_inf()), r); + + return r; +} + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_log2fx_u10sve(vfloat_sve_sleef d) { + vfloat2_sve_sleef x; + vfloat_sve_sleef t, m, x2; + + vopmask_sve_sleef o = vlt_vo_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(0x1p-126)); + d = vsel_vf_vo_vf_vf_sve_sleef(o, vmul_vf_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef((float)(INT64_C(1) << 32) * (float)(INT64_C(1) << 32))), d); + vint2_sve_sleef e = vilogb2k_vi2_vf_sve_sleef(vmul_vf_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(1.0/0.75))); + m = vldexp3_vf_vf_vi2_sve_sleef(d, vneg_vi2_vi2_sve_sleef(e)); + e = vsel_vi2_vo_vi2_vi2_sve_sleef(o, vsub_vi2_vi2_vi2_sve_sleef(e, vcast_vi2_i_sve_sleef(64)), e); + + x = dfdiv_vf2_vf2_vf2_sve_sleef(dfadd2_vf2_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(-1), m), dfadd2_vf2_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(1), m)); + x2 = vmul_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(x), vf2getx_vf_vf2_sve_sleef(x)); + + t = vcast_vf_f_sve_sleef(+0.4374550283e+0f); + t = vmla_vf_vf_vf_vf_sve_sleef(t, x2, vcast_vf_f_sve_sleef(+0.5764790177e+0f)); + t = vmla_vf_vf_vf_vf_sve_sleef(t, x2, vcast_vf_f_sve_sleef(+0.9618012905120f)); + + vfloat2_sve_sleef s = dfadd2_vf2_vf_vf2_sve_sleef(vcast_vf_vi2_sve_sleef(e), + dfmul_vf2_vf2_vf2_sve_sleef(x, vcast_vf2_f_f_sve_sleef(2.8853900432586669922, 3.2734474483568488616e-08))); + + s = dfadd2_vf2_vf2_vf_sve_sleef(s, vmul_vf_vf_vf_sve_sleef(vmul_vf_vf_vf_sve_sleef(x2, vf2getx_vf_vf2_sve_sleef(x)), t)); + + vfloat_sve_sleef r = vadd_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(s), vf2gety_vf_vf2_sve_sleef(s)); + + r = vsel_vf_vo_vf_vf_sve_sleef(vispinf_vo_vf_sve_sleef(d), vcast_vf_f_sve_sleef(__builtin_inf()), r); + r = vsel_vf_vo_vf_vf_sve_sleef(vor_vo_vo_vo_sve_sleef(vlt_vo_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(0)), visnan_vo_vf_sve_sleef(d)), vcast_vf_f_sve_sleef(__builtin_nan("")), r); + r = vsel_vf_vo_vf_vf_sve_sleef(veq_vo_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(0)), vcast_vf_f_sve_sleef(-__builtin_inf()), r); + + return r; +} + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_log2fx_u35sve(vfloat_sve_sleef d) { + vfloat_sve_sleef m, t, x, x2; + + vopmask_sve_sleef o = vlt_vo_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(0x1p-126)); + d = vsel_vf_vo_vf_vf_sve_sleef(o, vmul_vf_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef((float)(INT64_C(1) << 32) * (float)(INT64_C(1) << 32))), d); + vint2_sve_sleef e = vilogb2k_vi2_vf_sve_sleef(vmul_vf_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(1.0/0.75))); + m = vldexp3_vf_vf_vi2_sve_sleef(d, vneg_vi2_vi2_sve_sleef(e)); + e = vsel_vi2_vo_vi2_vi2_sve_sleef(o, vsub_vi2_vi2_vi2_sve_sleef(e, vcast_vi2_i_sve_sleef(64)), e); + + x = vdiv_vf_vf_vf_sve_sleef(vsub_vf_vf_vf_sve_sleef(m, vcast_vf_f_sve_sleef(1)), vadd_vf_vf_vf_sve_sleef(m, vcast_vf_f_sve_sleef(1))); + x2 = vmul_vf_vf_vf_sve_sleef(x, x); + + t = vcast_vf_f_sve_sleef(+0.4374088347e+0); + t = vmla_vf_vf_vf_vf_sve_sleef(t, x2, vcast_vf_f_sve_sleef(+0.5764843822e+0)); + t = vmla_vf_vf_vf_vf_sve_sleef(t, x2, vcast_vf_f_sve_sleef(+0.9618024230e+0)); + + vfloat_sve_sleef r = vmla_vf_vf_vf_vf_sve_sleef(vmul_vf_vf_vf_sve_sleef(x2, x), t, + vmla_vf_vf_vf_vf_sve_sleef(x, vcast_vf_f_sve_sleef(+0.2885390043e+1), vcast_vf_vi2_sve_sleef(e))); + + r = vsel_vf_vo_vf_vf_sve_sleef(vispinf_vo_vf_sve_sleef(d), vcast_vf_f_sve_sleef(__builtin_inf()), r); + r = vsel_vf_vo_vf_vf_sve_sleef(vor_vo_vo_vo_sve_sleef(vlt_vo_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(0)), visnan_vo_vf_sve_sleef(d)), vcast_vf_f_sve_sleef(__builtin_nan("")), r); + r = vsel_vf_vo_vf_vf_sve_sleef(veq_vo_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(0)), vcast_vf_f_sve_sleef(-__builtin_inf()), r); + + return r; +} + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_log1pfx_u10sve(vfloat_sve_sleef d) { + vfloat2_sve_sleef x; + vfloat_sve_sleef t, m, x2; + + vfloat_sve_sleef dp1 = vadd_vf_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(1)); + + vopmask_sve_sleef o = vlt_vo_vf_vf_sve_sleef(dp1, vcast_vf_f_sve_sleef(0x1p-126)); + dp1 = vsel_vf_vo_vf_vf_sve_sleef(o, vmul_vf_vf_vf_sve_sleef(dp1, vcast_vf_f_sve_sleef((float)(INT64_C(1) << 32) * (float)(INT64_C(1) << 32))), dp1); + vint2_sve_sleef e = vilogb2k_vi2_vf_sve_sleef(vmul_vf_vf_vf_sve_sleef(dp1, vcast_vf_f_sve_sleef(1.0f/0.75f))); + t = vldexp3_vf_vf_vi2_sve_sleef(vcast_vf_f_sve_sleef(1), vneg_vi2_vi2_sve_sleef(e)); + m = vmla_vf_vf_vf_vf_sve_sleef(d, t, vsub_vf_vf_vf_sve_sleef(t, vcast_vf_f_sve_sleef(1))); + e = vsel_vi2_vo_vi2_vi2_sve_sleef(o, vsub_vi2_vi2_vi2_sve_sleef(e, vcast_vi2_i_sve_sleef(64)), e); + vfloat2_sve_sleef s = dfmul_vf2_vf2_vf_sve_sleef(vcast_vf2_f_f_sve_sleef(0.69314718246459960938f, -1.904654323148236017e-09f), vcast_vf_vi2_sve_sleef(e)); + + x = dfdiv_vf2_vf2_vf2_sve_sleef(vcast_vf2_vf_vf_sve_sleef(m, vcast_vf_f_sve_sleef(0)), dfadd_vf2_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(2), m)); + x2 = vmul_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(x), vf2getx_vf_vf2_sve_sleef(x)); + + t = vcast_vf_f_sve_sleef(+0.3027294874e+0f); + t = vmla_vf_vf_vf_vf_sve_sleef(t, x2, vcast_vf_f_sve_sleef(+0.3996108174e+0f)); + t = vmla_vf_vf_vf_vf_sve_sleef(t, x2, vcast_vf_f_sve_sleef(+0.6666694880e+0f)); + + s = dfadd_vf2_vf2_vf2_sve_sleef(s, dfscale_vf2_vf2_vf_sve_sleef(x, vcast_vf_f_sve_sleef(2))); + s = dfadd_vf2_vf2_vf_sve_sleef(s, vmul_vf_vf_vf_sve_sleef(vmul_vf_vf_vf_sve_sleef(x2, vf2getx_vf_vf2_sve_sleef(x)), t)); + + vfloat_sve_sleef r = vadd_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(s), vf2gety_vf_vf2_sve_sleef(s)); + + r = vsel_vf_vo_vf_vf_sve_sleef(vgt_vo_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(1e+38)), vcast_vf_f_sve_sleef(__builtin_inff()), r); + r = vreinterpret_vf_vm_sve_sleef(vor_vm_vo32_vm_sve_sleef(vgt_vo_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(-1), d), vreinterpret_vm_vf_sve_sleef(r))); + r = vsel_vf_vo_vf_vf_sve_sleef(veq_vo_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(-1)), vcast_vf_f_sve_sleef(-__builtin_inff()), r); + r = vsel_vf_vo_vf_vf_sve_sleef(visnegzero_vo_vf_sve_sleef(d), vcast_vf_f_sve_sleef(-0.0f), r); + + return r; +} + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_fabsfx_sve(vfloat_sve_sleef x) { return vabs_vf_vf_sve_sleef(x); } + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_copysignfx_sve(vfloat_sve_sleef x, vfloat_sve_sleef y) { return vcopysign_vf_vf_vf_sve_sleef(x, y); } + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_fmaxfx_sve(vfloat_sve_sleef x, vfloat_sve_sleef y) { + + return vsel_vf_vo_vf_vf_sve_sleef(visnan_vo_vf_sve_sleef(y), x, vsel_vf_vo_vf_vf_sve_sleef(vgt_vo_vf_vf_sve_sleef(x, y), x, y)); + +} + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_fminfx_sve(vfloat_sve_sleef x, vfloat_sve_sleef y) { + + return vsel_vf_vo_vf_vf_sve_sleef(visnan_vo_vf_sve_sleef(y), x, vsel_vf_vo_vf_vf_sve_sleef(vgt_vo_vf_vf_sve_sleef(y, x), x, y)); + +} + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_fdimfx_sve(vfloat_sve_sleef x, vfloat_sve_sleef y) { + vfloat_sve_sleef ret = vsub_vf_vf_vf_sve_sleef(x, y); + ret = vsel_vf_vo_vf_vf_sve_sleef(vor_vo_vo_vo_sve_sleef(vlt_vo_vf_vf_sve_sleef(ret, vcast_vf_f_sve_sleef(0)), veq_vo_vf_vf_sve_sleef(x, y)), vcast_vf_f_sve_sleef(0), ret); + return ret; +} + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_truncfx_sve(vfloat_sve_sleef x) { + + return vtruncate_vf_vf_sve_sleef(x); + +} + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_floorfx_sve(vfloat_sve_sleef x) { + vfloat_sve_sleef fr = vsub_vf_vf_vf_sve_sleef(x, vcast_vf_vi2_sve_sleef(vtruncate_vi2_vf_sve_sleef(x))); + fr = vsel_vf_vo_vf_vf_sve_sleef(vlt_vo_vf_vf_sve_sleef(fr, vcast_vf_f_sve_sleef(0)), vadd_vf_vf_vf_sve_sleef(fr, vcast_vf_f_sve_sleef(1.0f)), fr); + return vsel_vf_vo_vf_vf_sve_sleef(vor_vo_vo_vo_sve_sleef(visinf_vo_vf_sve_sleef(x), vge_vo_vf_vf_sve_sleef(vabs_vf_vf_sve_sleef(x), vcast_vf_f_sve_sleef(INT64_C(1) << 23))), x, vcopysign_vf_vf_vf_sve_sleef(vsub_vf_vf_vf_sve_sleef(x, fr), x)); +} + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_ceilfx_sve(vfloat_sve_sleef x) { + vfloat_sve_sleef fr = vsub_vf_vf_vf_sve_sleef(x, vcast_vf_vi2_sve_sleef(vtruncate_vi2_vf_sve_sleef(x))); + fr = vsel_vf_vo_vf_vf_sve_sleef(vle_vo_vf_vf_sve_sleef(fr, vcast_vf_f_sve_sleef(0)), fr, vsub_vf_vf_vf_sve_sleef(fr, vcast_vf_f_sve_sleef(1.0f))); + return vsel_vf_vo_vf_vf_sve_sleef(vor_vo_vo_vo_sve_sleef(visinf_vo_vf_sve_sleef(x), vge_vo_vf_vf_sve_sleef(vabs_vf_vf_sve_sleef(x), vcast_vf_f_sve_sleef(INT64_C(1) << 23))), x, vcopysign_vf_vf_vf_sve_sleef(vsub_vf_vf_vf_sve_sleef(x, fr), x)); +} + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_roundfx_sve(vfloat_sve_sleef d) { + vfloat_sve_sleef x = vadd_vf_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(0.5f)); + vfloat_sve_sleef fr = vsub_vf_vf_vf_sve_sleef(x, vcast_vf_vi2_sve_sleef(vtruncate_vi2_vf_sve_sleef(x))); + x = vsel_vf_vo_vf_vf_sve_sleef(vand_vo_vo_vo_sve_sleef(vle_vo_vf_vf_sve_sleef(x, vcast_vf_f_sve_sleef(0)), veq_vo_vf_vf_sve_sleef(fr, vcast_vf_f_sve_sleef(0))), vsub_vf_vf_vf_sve_sleef(x, vcast_vf_f_sve_sleef(1.0f)), x); + fr = vsel_vf_vo_vf_vf_sve_sleef(vlt_vo_vf_vf_sve_sleef(fr, vcast_vf_f_sve_sleef(0)), vadd_vf_vf_vf_sve_sleef(fr, vcast_vf_f_sve_sleef(1.0f)), fr); + x = vsel_vf_vo_vf_vf_sve_sleef(veq_vo_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(0.4999999701976776123f)), vcast_vf_f_sve_sleef(0), x); + return vsel_vf_vo_vf_vf_sve_sleef(vor_vo_vo_vo_sve_sleef(visinf_vo_vf_sve_sleef(d), vge_vo_vf_vf_sve_sleef(vabs_vf_vf_sve_sleef(d), vcast_vf_f_sve_sleef(INT64_C(1) << 23))), d, vcopysign_vf_vf_vf_sve_sleef(vsub_vf_vf_vf_sve_sleef(x, fr), d)); +} + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_rintfx_sve(vfloat_sve_sleef d) { + + return vrint_vf_vf_sve_sleef(d); + +} + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_fmafx_sve(vfloat_sve_sleef x, vfloat_sve_sleef y, vfloat_sve_sleef z) { + + return vfma_vf_vf_vf_vf_sve_sleef(x, y, z); + +} + +SLEEF_INLINE vfloat_sve_sleef Sleef_sqrtfx_u05sve(vfloat_sve_sleef d) { + + vfloat_sve_sleef q, w, x, y, z; + + d = vsel_vf_vo_vf_vf_sve_sleef(vlt_vo_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(0)), vcast_vf_f_sve_sleef(__builtin_nanf("")), d); + + vopmask_sve_sleef o = vlt_vo_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(5.2939559203393770e-23f)); + d = vsel_vf_vo_vf_vf_sve_sleef(o, vmul_vf_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(1.8889465931478580e+22f)), d); + q = vsel_vf_vo_vf_vf_sve_sleef(o, vcast_vf_f_sve_sleef(7.2759576141834260e-12f), vcast_vf_f_sve_sleef(1.0f)); + + y = vreinterpret_vf_vi2_sve_sleef(vsub_vi2_vi2_vi2_sve_sleef(vcast_vi2_i_sve_sleef(0x5f3759df), svreinterpret_s32_u32(svlsr_n_u32_x(svptrue_b8(), svreinterpret_u32_s32(vreinterpret_vi2_vf_sve_sleef(d)), 1)))); + + x = vmul_vf_vf_vf_sve_sleef(d, y); w = vmul_vf_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(0.5), y); + y = vfmanp_vf_vf_vf_vf_sve_sleef(x, w, vcast_vf_f_sve_sleef(0.5)); + x = vfma_vf_vf_vf_vf_sve_sleef(x, y, x); w = vfma_vf_vf_vf_vf_sve_sleef(w, y, w); + y = vfmanp_vf_vf_vf_vf_sve_sleef(x, w, vcast_vf_f_sve_sleef(0.5)); + x = vfma_vf_vf_vf_vf_sve_sleef(x, y, x); w = vfma_vf_vf_vf_vf_sve_sleef(w, y, w); + + y = vfmanp_vf_vf_vf_vf_sve_sleef(x, w, vcast_vf_f_sve_sleef(1.5)); w = vadd_vf_vf_vf_sve_sleef(w, w); + w = vmul_vf_vf_vf_sve_sleef(w, y); + x = vmul_vf_vf_vf_sve_sleef(w, d); + y = vfmapn_vf_vf_vf_vf_sve_sleef(w, d, x); z = vfmanp_vf_vf_vf_vf_sve_sleef(w, x, vcast_vf_f_sve_sleef(1)); + + z = vfmanp_vf_vf_vf_vf_sve_sleef(w, y, z); w = vmul_vf_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(0.5), x); + w = vfma_vf_vf_vf_vf_sve_sleef(w, z, y); + w = vadd_vf_vf_vf_sve_sleef(w, x); + + w = vmul_vf_vf_vf_sve_sleef(w, q); + + w = vsel_vf_vo_vf_vf_sve_sleef(vor_vo_vo_vo_sve_sleef(veq_vo_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(0)), + veq_vo_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(__builtin_inff()))), d, w); + + w = vsel_vf_vo_vf_vf_sve_sleef(vlt_vo_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(0)), vcast_vf_f_sve_sleef(__builtin_nanf("")), w); + + return w; + +} + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_sqrtfx_sve(vfloat_sve_sleef d) { + + return vsqrt_vf_vf_sve_sleef(d); + +} + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_hypotfx_u05sve(vfloat_sve_sleef x, vfloat_sve_sleef y) { + x = vabs_vf_vf_sve_sleef(x); + y = vabs_vf_vf_sve_sleef(y); + vfloat_sve_sleef min = vmin_vf_vf_vf_sve_sleef(x, y), n = min; + vfloat_sve_sleef max = vmax_vf_vf_vf_sve_sleef(x, y), d = max; + + vopmask_sve_sleef o = vlt_vo_vf_vf_sve_sleef(max, vcast_vf_f_sve_sleef(0x1p-126)); + n = vsel_vf_vo_vf_vf_sve_sleef(o, vmul_vf_vf_vf_sve_sleef(n, vcast_vf_f_sve_sleef(UINT64_C(1) << 24)), n); + d = vsel_vf_vo_vf_vf_sve_sleef(o, vmul_vf_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(UINT64_C(1) << 24)), d); + + vfloat2_sve_sleef t = dfdiv_vf2_vf2_vf2_sve_sleef(vcast_vf2_vf_vf_sve_sleef(n, vcast_vf_f_sve_sleef(0)), vcast_vf2_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(0))); + t = dfmul_vf2_vf2_vf_sve_sleef(dfsqrt_vf2_vf2_sve_sleef(dfadd2_vf2_vf2_vf_sve_sleef(dfsqu_vf2_vf2_sve_sleef(t), vcast_vf_f_sve_sleef(1))), max); + vfloat_sve_sleef ret = vadd_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(t), vf2gety_vf_vf2_sve_sleef(t)); + ret = vsel_vf_vo_vf_vf_sve_sleef(visnan_vo_vf_sve_sleef(ret), vcast_vf_f_sve_sleef(__builtin_inff()), ret); + ret = vsel_vf_vo_vf_vf_sve_sleef(veq_vo_vf_vf_sve_sleef(min, vcast_vf_f_sve_sleef(0)), max, ret); + ret = vsel_vf_vo_vf_vf_sve_sleef(vor_vo_vo_vo_sve_sleef(visnan_vo_vf_sve_sleef(x), visnan_vo_vf_sve_sleef(y)), vcast_vf_f_sve_sleef(__builtin_nanf("")), ret); + ret = vsel_vf_vo_vf_vf_sve_sleef(vor_vo_vo_vo_sve_sleef(veq_vo_vf_vf_sve_sleef(x, vcast_vf_f_sve_sleef(__builtin_inff())), veq_vo_vf_vf_sve_sleef(y, vcast_vf_f_sve_sleef(__builtin_inff()))), vcast_vf_f_sve_sleef(__builtin_inff()), ret); + + return ret; +} + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_hypotfx_u35sve(vfloat_sve_sleef x, vfloat_sve_sleef y) { + x = vabs_vf_vf_sve_sleef(x); + y = vabs_vf_vf_sve_sleef(y); + vfloat_sve_sleef min = vmin_vf_vf_vf_sve_sleef(x, y); + vfloat_sve_sleef max = vmax_vf_vf_vf_sve_sleef(x, y); + + vfloat_sve_sleef t = vdiv_vf_vf_vf_sve_sleef(min, max); + vfloat_sve_sleef ret = vmul_vf_vf_vf_sve_sleef(max, vsqrt_vf_vf_sve_sleef(vmla_vf_vf_vf_vf_sve_sleef(t, t, vcast_vf_f_sve_sleef(1)))); + ret = vsel_vf_vo_vf_vf_sve_sleef(veq_vo_vf_vf_sve_sleef(min, vcast_vf_f_sve_sleef(0)), max, ret); + ret = vsel_vf_vo_vf_vf_sve_sleef(vor_vo_vo_vo_sve_sleef(visnan_vo_vf_sve_sleef(x), visnan_vo_vf_sve_sleef(y)), vcast_vf_f_sve_sleef(__builtin_nanf("")), ret); + ret = vsel_vf_vo_vf_vf_sve_sleef(vor_vo_vo_vo_sve_sleef(veq_vo_vf_vf_sve_sleef(x, vcast_vf_f_sve_sleef(__builtin_inff())), veq_vo_vf_vf_sve_sleef(y, vcast_vf_f_sve_sleef(__builtin_inff()))), vcast_vf_f_sve_sleef(__builtin_inff()), ret); + + return ret; +} + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_nextafterfx_sve(vfloat_sve_sleef x, vfloat_sve_sleef y) { + x = vsel_vf_vo_vf_vf_sve_sleef(veq_vo_vf_vf_sve_sleef(x, vcast_vf_f_sve_sleef(0)), vmulsign_vf_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(0), y), x); + vint2_sve_sleef xi2 = vreinterpret_vi2_vf_sve_sleef(x); + vopmask_sve_sleef c = vxor_vo_vo_vo_sve_sleef(vsignbit_vo_vf_sve_sleef(x), vge_vo_vf_vf_sve_sleef(y, x)); + + xi2 = vsel_vi2_vo_vi2_vi2_sve_sleef(c, vsub_vi2_vi2_vi2_sve_sleef(vcast_vi2_i_sve_sleef(0), vxor_vi2_vi2_vi2_sve_sleef(xi2, vcast_vi2_i_sve_sleef((int)(1U << 31)))), xi2); + + xi2 = vsel_vi2_vo_vi2_vi2_sve_sleef(vneq_vo_vf_vf_sve_sleef(x, y), vsub_vi2_vi2_vi2_sve_sleef(xi2, vcast_vi2_i_sve_sleef(1)), xi2); + + xi2 = vsel_vi2_vo_vi2_vi2_sve_sleef(c, vsub_vi2_vi2_vi2_sve_sleef(vcast_vi2_i_sve_sleef(0), vxor_vi2_vi2_vi2_sve_sleef(xi2, vcast_vi2_i_sve_sleef((int)(1U << 31)))), xi2); + + vfloat_sve_sleef ret = vreinterpret_vf_vi2_sve_sleef(xi2); + + ret = vsel_vf_vo_vf_vf_sve_sleef(vand_vo_vo_vo_sve_sleef(veq_vo_vf_vf_sve_sleef(ret, vcast_vf_f_sve_sleef(0)), vneq_vo_vf_vf_sve_sleef(x, vcast_vf_f_sve_sleef(0))), + vmulsign_vf_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(0), x), ret); + + ret = vsel_vf_vo_vf_vf_sve_sleef(vand_vo_vo_vo_sve_sleef(veq_vo_vf_vf_sve_sleef(x, vcast_vf_f_sve_sleef(0)), veq_vo_vf_vf_sve_sleef(y, vcast_vf_f_sve_sleef(0))), y, ret); + + ret = vsel_vf_vo_vf_vf_sve_sleef(vor_vo_vo_vo_sve_sleef(visnan_vo_vf_sve_sleef(x), visnan_vo_vf_sve_sleef(y)), vcast_vf_f_sve_sleef(__builtin_nanf("")), ret); + + return ret; +} + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_frfrexpfx_sve(vfloat_sve_sleef x) { + x = vsel_vf_vo_vf_vf_sve_sleef(vlt_vo_vf_vf_sve_sleef(vabs_vf_vf_sve_sleef(x), vcast_vf_f_sve_sleef(0x1p-126)), vmul_vf_vf_vf_sve_sleef(x, vcast_vf_f_sve_sleef(UINT64_C(1) << 30)), x); + + vmask_sve_sleef xm = vreinterpret_vm_vf_sve_sleef(x); + xm = vand_vm_vm_vm_sve_sleef(xm, vcast_vm_i_i_sve_sleef(~0x7f800000U, ~0x7f800000U)); + xm = vor_vm_vm_vm_sve_sleef (xm, vcast_vm_i_i_sve_sleef( 0x3f000000U, 0x3f000000U)); + + vfloat_sve_sleef ret = vreinterpret_vf_vm_sve_sleef(xm); + + ret = vsel_vf_vo_vf_vf_sve_sleef(visinf_vo_vf_sve_sleef(x), vmulsign_vf_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(__builtin_inff()), x), ret); + ret = vsel_vf_vo_vf_vf_sve_sleef(veq_vo_vf_vf_sve_sleef(x, vcast_vf_f_sve_sleef(0)), x, ret); + + return ret; +} + +SLEEF_INLINE SLEEF_CONST vint2_sve_sleef Sleef_expfrexpfx_sve(vfloat_sve_sleef x) { + + return vcast_vi2_i_sve_sleef(0); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_sve_sleef vtoward0_vf_vf_sve_sleef(vfloat_sve_sleef x) { + vfloat_sve_sleef t = vreinterpret_vf_vi2_sve_sleef(vsub_vi2_vi2_vi2_sve_sleef(vreinterpret_vi2_vf_sve_sleef(x), vcast_vi2_i_sve_sleef(1))); + return vsel_vf_vo_vf_vf_sve_sleef(veq_vo_vf_vf_sve_sleef(x, vcast_vf_f_sve_sleef(0)), vcast_vf_f_sve_sleef(0), t); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_sve_sleef vptrunc_vf_vf_sve_sleef(vfloat_sve_sleef x) { + + return vtruncate_vf_vf_sve_sleef(x); + +} + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_fmodfx_sve(vfloat_sve_sleef x, vfloat_sve_sleef y) { + vfloat_sve_sleef nu = vabs_vf_vf_sve_sleef(x), de = vabs_vf_vf_sve_sleef(y), s = vcast_vf_f_sve_sleef(1), q; + vopmask_sve_sleef o = vlt_vo_vf_vf_sve_sleef(de, vcast_vf_f_sve_sleef(0x1p-126)); + nu = vsel_vf_vo_vf_vf_sve_sleef(o, vmul_vf_vf_vf_sve_sleef(nu, vcast_vf_f_sve_sleef(UINT64_C(1) << 25)), nu); + de = vsel_vf_vo_vf_vf_sve_sleef(o, vmul_vf_vf_vf_sve_sleef(de, vcast_vf_f_sve_sleef(UINT64_C(1) << 25)), de); + s = vsel_vf_vo_vf_vf_sve_sleef(o, vmul_vf_vf_vf_sve_sleef(s , vcast_vf_f_sve_sleef(1.0f / (UINT64_C(1) << 25))), s); + vfloat_sve_sleef rde = vtoward0_vf_vf_sve_sleef(vrec_vf_vf_sve_sleef(de)); + + vfloat2_sve_sleef r = vcast_vf2_vf_vf_sve_sleef(nu, vcast_vf_f_sve_sleef(0)); + + for(int i=0;i<8;i++) { + q = vptrunc_vf_vf_sve_sleef(vmul_vf_vf_vf_sve_sleef(vtoward0_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(r)), rde)); + q = vsel_vf_vo_vf_vf_sve_sleef(vand_vo_vo_vo_sve_sleef(vgt_vo_vf_vf_sve_sleef(vmul_vf_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(3), de), vf2getx_vf_vf2_sve_sleef(r)), + vge_vo_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(r), de)), + vcast_vf_f_sve_sleef(2), q); + q = vsel_vf_vo_vf_vf_sve_sleef(vand_vo_vo_vo_sve_sleef(vgt_vo_vf_vf_sve_sleef(vmul_vf_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(2), de), vf2getx_vf_vf2_sve_sleef(r)), + vge_vo_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(r), de)), + vcast_vf_f_sve_sleef(1), q); + r = dfnormalize_vf2_vf2_sve_sleef(dfadd2_vf2_vf2_vf2_sve_sleef(r, dfmul_vf2_vf_vf_sve_sleef(vptrunc_vf_vf_sve_sleef(q), vneg_vf_vf_sve_sleef(de)))); + if (vtestallones_i_vo32_sve_sleef(vlt_vo_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(r), de))) break; + } + + vfloat_sve_sleef ret = vmul_vf_vf_vf_sve_sleef(vadd_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(r), vf2gety_vf_vf2_sve_sleef(r)), s); + ret = vsel_vf_vo_vf_vf_sve_sleef(veq_vo_vf_vf_sve_sleef(vadd_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(r), vf2gety_vf_vf2_sve_sleef(r)), de), vcast_vf_f_sve_sleef(0), ret); + + ret = vmulsign_vf_vf_vf_sve_sleef(ret, x); + + ret = vsel_vf_vo_vf_vf_sve_sleef(vlt_vo_vf_vf_sve_sleef(nu, de), x, ret); + ret = vsel_vf_vo_vf_vf_sve_sleef(veq_vo_vf_vf_sve_sleef(de, vcast_vf_f_sve_sleef(0)), vcast_vf_f_sve_sleef(__builtin_nanf("")), ret); + + return ret; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat_sve_sleef vrintfk2_vf_vf_sve_sleef(vfloat_sve_sleef d) { + + return vrint_vf_vf_sve_sleef(d); + +} + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_remainderfx_sve(vfloat_sve_sleef x, vfloat_sve_sleef y) { + vfloat_sve_sleef n = vabs_vf_vf_sve_sleef(x), d = vabs_vf_vf_sve_sleef(y), s = vcast_vf_f_sve_sleef(1), q; + vopmask_sve_sleef o = vlt_vo_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(0x1p-126*2)); + n = vsel_vf_vo_vf_vf_sve_sleef(o, vmul_vf_vf_vf_sve_sleef(n, vcast_vf_f_sve_sleef(UINT64_C(1) << 25)), n); + d = vsel_vf_vo_vf_vf_sve_sleef(o, vmul_vf_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(UINT64_C(1) << 25)), d); + s = vsel_vf_vo_vf_vf_sve_sleef(o, vmul_vf_vf_vf_sve_sleef(s , vcast_vf_f_sve_sleef(1.0f / (UINT64_C(1) << 25))), s); + vfloat2_sve_sleef r = vcast_vf2_vf_vf_sve_sleef(n, vcast_vf_f_sve_sleef(0)); + vfloat_sve_sleef rd = vrec_vf_vf_sve_sleef(d); + vopmask_sve_sleef qisodd = vneq_vo_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(0), vcast_vf_f_sve_sleef(0)); + + for(int i=0;i<8;i++) { + q = vrintfk2_vf_vf_sve_sleef(vmul_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(r), rd)); + q = vsel_vf_vo_vf_vf_sve_sleef(vlt_vo_vf_vf_sve_sleef(vabs_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(r)), vmul_vf_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(1.5f))), vmulsign_vf_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(1.0f), vf2getx_vf_vf2_sve_sleef(r)), q); + q = vsel_vf_vo_vf_vf_sve_sleef(vor_vo_vo_vo_sve_sleef(vlt_vo_vf_vf_sve_sleef(vabs_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(r)), vmul_vf_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(0.5f))), + vandnot_vo_vo_vo_sve_sleef(qisodd, veq_vo_vf_vf_sve_sleef(vabs_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(r)), vmul_vf_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(0.5f))))), + vcast_vf_f_sve_sleef(0.0), q); + if (vtestallones_i_vo32_sve_sleef(veq_vo_vf_vf_sve_sleef(q, vcast_vf_f_sve_sleef(0)))) break; + q = vsel_vf_vo_vf_vf_sve_sleef(visinf_vo_vf_sve_sleef(vmul_vf_vf_vf_sve_sleef(q, vneg_vf_vf_sve_sleef(d))), vadd_vf_vf_vf_sve_sleef(q, vmulsign_vf_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(-1), vf2getx_vf_vf2_sve_sleef(r))), q); + qisodd = vxor_vo_vo_vo_sve_sleef(qisodd, vand_vo_vo_vo_sve_sleef(veq_vo_vi2_vi2_sve_sleef(vand_vi2_vi2_vi2_sve_sleef(vtruncate_vi2_vf_sve_sleef(q), vcast_vi2_i_sve_sleef(1)), vcast_vi2_i_sve_sleef(1)), + vlt_vo_vf_vf_sve_sleef(vabs_vf_vf_sve_sleef(q), vcast_vf_f_sve_sleef(1 << 24)))); + r = dfnormalize_vf2_vf2_sve_sleef(dfadd2_vf2_vf2_vf2_sve_sleef(r, dfmul_vf2_vf_vf_sve_sleef(q, vneg_vf_vf_sve_sleef(d)))); + } + + vfloat_sve_sleef ret = vmul_vf_vf_vf_sve_sleef(vadd_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(r), vf2gety_vf_vf2_sve_sleef(r)), s); + ret = vmulsign_vf_vf_vf_sve_sleef(ret, x); + ret = vsel_vf_vo_vf_vf_sve_sleef(visinf_vo_vf_sve_sleef(y), vsel_vf_vo_vf_vf_sve_sleef(visinf_vo_vf_sve_sleef(x), vcast_vf_f_sve_sleef(__builtin_nanf("")), x), ret); + ret = vsel_vf_vo_vf_vf_sve_sleef(veq_vo_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(0)), vcast_vf_f_sve_sleef(__builtin_nanf("")), ret); + return ret; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_sve_sleef sinpifk_sve_sleef(vfloat_sve_sleef d) { + vopmask_sve_sleef o; + vfloat_sve_sleef u, s, t; + vfloat2_sve_sleef x, s2; + + u = vmul_vf_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(4.0)); + vint2_sve_sleef q = vtruncate_vi2_vf_sve_sleef(u); + q = vand_vi2_vi2_vi2_sve_sleef(vadd_vi2_vi2_vi2_sve_sleef(q, vxor_vi2_vi2_vi2_sve_sleef(svreinterpret_s32_u32(svlsr_n_u32_x(svptrue_b8(), svreinterpret_u32_s32(q), 31)), vcast_vi2_i_sve_sleef(1))), vcast_vi2_i_sve_sleef(~1)); + o = veq_vo_vi2_vi2_sve_sleef(vand_vi2_vi2_vi2_sve_sleef(q, vcast_vi2_i_sve_sleef(2)), vcast_vi2_i_sve_sleef(2)); + + s = vsub_vf_vf_vf_sve_sleef(u, vcast_vf_vi2_sve_sleef(q)); + t = s; + s = vmul_vf_vf_vf_sve_sleef(s, s); + s2 = dfmul_vf2_vf_vf_sve_sleef(t, t); + + u = vsel_vf_vo_f_f_sve_sleef(o, -0.2430611801e-7f, +0.3093842054e-6f); + u = vmla_vf_vf_vf_vf_sve_sleef(u, s, vsel_vf_vo_f_f_sve_sleef(o, +0.3590577080e-5f, -0.3657307388e-4f)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, s, vsel_vf_vo_f_f_sve_sleef(o, -0.3259917721e-3f, +0.2490393585e-2f)); + x = dfadd2_vf2_vf_vf2_sve_sleef(vmul_vf_vf_vf_sve_sleef(u, s), + vsel_vf2_vo_f_f_f_f_sve_sleef(o, 0.015854343771934509277, 4.4940051354032242811e-10, + -0.080745510756969451904, -1.3373665339076936258e-09)); + x = dfadd2_vf2_vf2_vf2_sve_sleef(dfmul_vf2_vf2_vf2_sve_sleef(s2, x), + vsel_vf2_vo_f_f_f_f_sve_sleef(o, -0.30842512845993041992, -9.0728339030733922277e-09, + 0.78539818525314331055, -2.1857338617566484855e-08)); + + x = dfmul_vf2_vf2_vf2_sve_sleef(x, vsel_vf2_vo_vf2_vf2_sve_sleef(o, s2, vcast_vf2_vf_vf_sve_sleef(t, vcast_vf_f_sve_sleef(0)))); + x = vsel_vf2_vo_vf2_vf2_sve_sleef(o, dfadd2_vf2_vf2_vf_sve_sleef(x, vcast_vf_f_sve_sleef(1)), x); + + o = veq_vo_vi2_vi2_sve_sleef(vand_vi2_vi2_vi2_sve_sleef(q, vcast_vi2_i_sve_sleef(4)), vcast_vi2_i_sve_sleef(4)); + x = vf2setx_vf2_vf2_vf_sve_sleef(x, vreinterpret_vf_vm_sve_sleef(vxor_vm_vm_vm_sve_sleef(vand_vm_vo32_vm_sve_sleef(o, vreinterpret_vm_vf_sve_sleef(vcast_vf_f_sve_sleef(-0.0))), vreinterpret_vm_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(x))))); + x = vf2sety_vf2_vf2_vf_sve_sleef(x, vreinterpret_vf_vm_sve_sleef(vxor_vm_vm_vm_sve_sleef(vand_vm_vo32_vm_sve_sleef(o, vreinterpret_vm_vf_sve_sleef(vcast_vf_f_sve_sleef(-0.0))), vreinterpret_vm_vf_sve_sleef(vf2gety_vf_vf2_sve_sleef(x))))); + + return x; +} + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_sinpifx_u05sve(vfloat_sve_sleef d) { + vfloat2_sve_sleef x = sinpifk_sve_sleef(d); + vfloat_sve_sleef r = vadd_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(x), vf2gety_vf_vf2_sve_sleef(x)); + + r = vsel_vf_vo_vf_vf_sve_sleef(visnegzero_vo_vf_sve_sleef(d), vcast_vf_f_sve_sleef(-0.0), r); + r = vreinterpret_vf_vm_sve_sleef(vandnot_vm_vo32_vm_sve_sleef(vgt_vo_vf_vf_sve_sleef(vabs_vf_vf_sve_sleef(d), vcast_vf_f_sve_sleef(8e+6f)), vreinterpret_vm_vf_sve_sleef(r))); + r = vreinterpret_vf_vm_sve_sleef(vor_vm_vo32_vm_sve_sleef(visinf_vo_vf_sve_sleef(d), vreinterpret_vm_vf_sve_sleef(r))); + + return r; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_sve_sleef cospifk_sve_sleef(vfloat_sve_sleef d) { + vopmask_sve_sleef o; + vfloat_sve_sleef u, s, t; + vfloat2_sve_sleef x, s2; + + u = vmul_vf_vf_vf_sve_sleef(d, vcast_vf_f_sve_sleef(4.0)); + vint2_sve_sleef q = vtruncate_vi2_vf_sve_sleef(u); + q = vand_vi2_vi2_vi2_sve_sleef(vadd_vi2_vi2_vi2_sve_sleef(q, vxor_vi2_vi2_vi2_sve_sleef(svreinterpret_s32_u32(svlsr_n_u32_x(svptrue_b8(), svreinterpret_u32_s32(q), 31)), vcast_vi2_i_sve_sleef(1))), vcast_vi2_i_sve_sleef(~1)); + o = veq_vo_vi2_vi2_sve_sleef(vand_vi2_vi2_vi2_sve_sleef(q, vcast_vi2_i_sve_sleef(2)), vcast_vi2_i_sve_sleef(0)); + + s = vsub_vf_vf_vf_sve_sleef(u, vcast_vf_vi2_sve_sleef(q)); + t = s; + s = vmul_vf_vf_vf_sve_sleef(s, s); + s2 = dfmul_vf2_vf_vf_sve_sleef(t, t); + + u = vsel_vf_vo_f_f_sve_sleef(o, -0.2430611801e-7f, +0.3093842054e-6f); + u = vmla_vf_vf_vf_vf_sve_sleef(u, s, vsel_vf_vo_f_f_sve_sleef(o, +0.3590577080e-5f, -0.3657307388e-4f)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, s, vsel_vf_vo_f_f_sve_sleef(o, -0.3259917721e-3f, +0.2490393585e-2f)); + x = dfadd2_vf2_vf_vf2_sve_sleef(vmul_vf_vf_vf_sve_sleef(u, s), + vsel_vf2_vo_f_f_f_f_sve_sleef(o, 0.015854343771934509277, 4.4940051354032242811e-10, + -0.080745510756969451904, -1.3373665339076936258e-09)); + x = dfadd2_vf2_vf2_vf2_sve_sleef(dfmul_vf2_vf2_vf2_sve_sleef(s2, x), + vsel_vf2_vo_f_f_f_f_sve_sleef(o, -0.30842512845993041992, -9.0728339030733922277e-09, + 0.78539818525314331055, -2.1857338617566484855e-08)); + + x = dfmul_vf2_vf2_vf2_sve_sleef(x, vsel_vf2_vo_vf2_vf2_sve_sleef(o, s2, vcast_vf2_vf_vf_sve_sleef(t, vcast_vf_f_sve_sleef(0)))); + x = vsel_vf2_vo_vf2_vf2_sve_sleef(o, dfadd2_vf2_vf2_vf_sve_sleef(x, vcast_vf_f_sve_sleef(1)), x); + + o = veq_vo_vi2_vi2_sve_sleef(vand_vi2_vi2_vi2_sve_sleef(vadd_vi2_vi2_vi2_sve_sleef(q, vcast_vi2_i_sve_sleef(2)), vcast_vi2_i_sve_sleef(4)), vcast_vi2_i_sve_sleef(4)); + x = vf2setx_vf2_vf2_vf_sve_sleef(x, vreinterpret_vf_vm_sve_sleef(vxor_vm_vm_vm_sve_sleef(vand_vm_vo32_vm_sve_sleef(o, vreinterpret_vm_vf_sve_sleef(vcast_vf_f_sve_sleef(-0.0))), vreinterpret_vm_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(x))))); + x = vf2sety_vf2_vf2_vf_sve_sleef(x, vreinterpret_vf_vm_sve_sleef(vxor_vm_vm_vm_sve_sleef(vand_vm_vo32_vm_sve_sleef(o, vreinterpret_vm_vf_sve_sleef(vcast_vf_f_sve_sleef(-0.0))), vreinterpret_vm_vf_sve_sleef(vf2gety_vf_vf2_sve_sleef(x))))); + + return x; +} + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_cospifx_u05sve(vfloat_sve_sleef d) { + vfloat2_sve_sleef x = cospifk_sve_sleef(d); + vfloat_sve_sleef r = vadd_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(x), vf2gety_vf_vf2_sve_sleef(x)); + + r = vsel_vf_vo_vf_vf_sve_sleef(vgt_vo_vf_vf_sve_sleef(vabs_vf_vf_sve_sleef(d), vcast_vf_f_sve_sleef(8e+6f)), vcast_vf_f_sve_sleef(1), r); + r = vreinterpret_vf_vm_sve_sleef(vor_vm_vo32_vm_sve_sleef(visinf_vo_vf_sve_sleef(d), vreinterpret_vm_vf_sve_sleef(r))); + + return r; +} + +static SLEEF_CONST df2_sve_sleef gammafk_sve_sleef(vfloat_sve_sleef a) { + vfloat2_sve_sleef clc = vcast_vf2_f_f_sve_sleef(0, 0), clln = vcast_vf2_f_f_sve_sleef(1, 0), clld = vcast_vf2_f_f_sve_sleef(1, 0); + vfloat2_sve_sleef x, y, z; + vfloat_sve_sleef t, u; + + vopmask_sve_sleef otiny = vlt_vo_vf_vf_sve_sleef(vabs_vf_vf_sve_sleef(a), vcast_vf_f_sve_sleef(1e-30f)), oref = vlt_vo_vf_vf_sve_sleef(a, vcast_vf_f_sve_sleef(0.5)); + + x = vsel_vf2_vo_vf2_vf2_sve_sleef(otiny, vcast_vf2_f_f_sve_sleef(0, 0), + vsel_vf2_vo_vf2_vf2_sve_sleef(oref, dfadd2_vf2_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(1), vneg_vf_vf_sve_sleef(a)), + vcast_vf2_vf_vf_sve_sleef(a, vcast_vf_f_sve_sleef(0)))); + + vopmask_sve_sleef o0 = vand_vo_vo_vo_sve_sleef(vle_vo_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(0.5), vf2getx_vf_vf2_sve_sleef(x)), vle_vo_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(x), vcast_vf_f_sve_sleef(1.2))); + vopmask_sve_sleef o2 = vle_vo_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(2.3), vf2getx_vf_vf2_sve_sleef(x)); + + y = dfnormalize_vf2_vf2_sve_sleef(dfmul_vf2_vf2_vf2_sve_sleef(dfadd2_vf2_vf2_vf_sve_sleef(x, vcast_vf_f_sve_sleef(1)), x)); + y = dfnormalize_vf2_vf2_sve_sleef(dfmul_vf2_vf2_vf2_sve_sleef(dfadd2_vf2_vf2_vf_sve_sleef(x, vcast_vf_f_sve_sleef(2)), y)); + + vopmask_sve_sleef o = vand_vo_vo_vo_sve_sleef(o2, vle_vo_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(x), vcast_vf_f_sve_sleef(7))); + clln = vsel_vf2_vo_vf2_vf2_sve_sleef(o, y, clln); + + x = vsel_vf2_vo_vf2_vf2_sve_sleef(o, dfadd2_vf2_vf2_vf_sve_sleef(x, vcast_vf_f_sve_sleef(3)), x); + t = vsel_vf_vo_vf_vf_sve_sleef(o2, vrec_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(x)), vf2getx_vf_vf2_sve_sleef(dfnormalize_vf2_vf2_sve_sleef(dfadd2_vf2_vf2_vf_sve_sleef(x, vsel_vf_vo_f_f_sve_sleef(o0, -1, -2))))); + + u = vsel_vf_vo_vo_f_f_f_sve_sleef(o2, o0, +0.000839498720672087279971000786, +0.9435157776e+0f, +0.1102489550e-3f); + u = vmla_vf_vf_vf_vf_sve_sleef(u, t, vsel_vf_vo_vo_f_f_f_sve_sleef(o2, o0, -5.17179090826059219329394422e-05, +0.8670063615e+0f, +0.8160019934e-4f)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, t, vsel_vf_vo_vo_f_f_f_sve_sleef(o2, o0, -0.000592166437353693882857342347, +0.4826702476e+0f, +0.1528468856e-3f)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, t, vsel_vf_vo_vo_f_f_f_sve_sleef(o2, o0, +6.97281375836585777403743539e-05, -0.8855129778e-1f, -0.2355068718e-3f)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, t, vsel_vf_vo_vo_f_f_f_sve_sleef(o2, o0, +0.000784039221720066627493314301, +0.1013825238e+0f, +0.4962242092e-3f)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, t, vsel_vf_vo_vo_f_f_f_sve_sleef(o2, o0, -0.000229472093621399176949318732, -0.1493408978e+0f, -0.1193488017e-2f)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, t, vsel_vf_vo_vo_f_f_f_sve_sleef(o2, o0, -0.002681327160493827160473958490, +0.1697509140e+0f, +0.2891599433e-2f)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, t, vsel_vf_vo_vo_f_f_f_sve_sleef(o2, o0, +0.003472222222222222222175164840, -0.2072454542e+0f, -0.7385451812e-2f)); + u = vmla_vf_vf_vf_vf_sve_sleef(u, t, vsel_vf_vo_vo_f_f_f_sve_sleef(o2, o0, +0.083333333333333333335592087900, +0.2705872357e+0f, +0.2058077045e-1f)); + + y = dfmul_vf2_vf2_vf2_sve_sleef(dfadd2_vf2_vf2_vf_sve_sleef(x, vcast_vf_f_sve_sleef(-0.5)), logk2f_sve_sleef(x)); + y = dfadd2_vf2_vf2_vf2_sve_sleef(y, dfneg_vf2_vf2_sve_sleef(x)); + y = dfadd2_vf2_vf2_vf2_sve_sleef(y, vcast_vf2_d_sve_sleef(0.91893853320467278056)); + + z = dfadd2_vf2_vf2_vf_sve_sleef(dfmul_vf2_vf_vf_sve_sleef (u, t), vsel_vf_vo_f_f_sve_sleef(o0, -0.400686534596170958447352690395e+0f, -0.673523028297382446749257758235e-1f)); + z = dfadd2_vf2_vf2_vf_sve_sleef(dfmul_vf2_vf2_vf_sve_sleef(z, t), vsel_vf_vo_f_f_sve_sleef(o0, +0.822466960142643054450325495997e+0f, +0.322467033928981157743538726901e+0f)); + z = dfadd2_vf2_vf2_vf_sve_sleef(dfmul_vf2_vf2_vf_sve_sleef(z, t), vsel_vf_vo_f_f_sve_sleef(o0, -0.577215665946766039837398973297e+0f, +0.422784335087484338986941629852e+0f)); + z = dfmul_vf2_vf2_vf_sve_sleef(z, t); + + clc = vsel_vf2_vo_vf2_vf2_sve_sleef(o2, y, z); + + clld = vsel_vf2_vo_vf2_vf2_sve_sleef(o2, dfadd2_vf2_vf2_vf_sve_sleef(dfmul_vf2_vf_vf_sve_sleef(u, t), vcast_vf_f_sve_sleef(1)), clld); + + y = clln; + + clc = vsel_vf2_vo_vf2_vf2_sve_sleef(otiny, vcast_vf2_d_sve_sleef(41.58883083359671856503), + vsel_vf2_vo_vf2_vf2_sve_sleef(oref, dfadd2_vf2_vf2_vf2_sve_sleef(vcast_vf2_d_sve_sleef(1.1447298858494001639), dfneg_vf2_vf2_sve_sleef(clc)), clc)); + clln = vsel_vf2_vo_vf2_vf2_sve_sleef(otiny, vcast_vf2_f_f_sve_sleef(1, 0), vsel_vf2_vo_vf2_vf2_sve_sleef(oref, clln, clld)); + + if (!vtestallones_i_vo32_sve_sleef(vnot_vo32_vo32_sve_sleef(oref))) { + t = vsub_vf_vf_vf_sve_sleef(a, vmul_vf_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(INT64_C(1) << 12), vcast_vf_vi2_sve_sleef(vtruncate_vi2_vf_sve_sleef(vmul_vf_vf_vf_sve_sleef(a, vcast_vf_f_sve_sleef(1.0 / (INT64_C(1) << 12))))))); + x = dfmul_vf2_vf2_vf2_sve_sleef(clld, sinpifk_sve_sleef(t)); + } + + clld = vsel_vf2_vo_vf2_vf2_sve_sleef(otiny, vcast_vf2_vf_vf_sve_sleef(vmul_vf_vf_vf_sve_sleef(a, vcast_vf_f_sve_sleef((INT64_C(1) << 30)*(float)(INT64_C(1) << 30))), vcast_vf_f_sve_sleef(0)), + vsel_vf2_vo_vf2_vf2_sve_sleef(oref, x, y)); + + return df2setab_df2_vf2_vf2_sve_sleef(clc, dfdiv_vf2_vf2_vf2_sve_sleef(clln, clld)); +} + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_tgammafx_u10sve(vfloat_sve_sleef a) { + df2_sve_sleef d = gammafk_sve_sleef(a); + vfloat2_sve_sleef y = dfmul_vf2_vf2_vf2_sve_sleef(expk2f_sve_sleef(df2geta_vf2_df2_sve_sleef(d)), df2getb_vf2_df2_sve_sleef(d)); + vfloat_sve_sleef r = vadd_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(y), vf2gety_vf_vf2_sve_sleef(y)); + vopmask_sve_sleef o; + + o = vor_vo_vo_vo_sve_sleef(vor_vo_vo_vo_sve_sleef(veq_vo_vf_vf_sve_sleef(a, vcast_vf_f_sve_sleef(-__builtin_inff())), + vand_vo_vo_vo_sve_sleef(vlt_vo_vf_vf_sve_sleef(a, vcast_vf_f_sve_sleef(0)), visint_vo_vf_sve_sleef(a))), + vand_vo_vo_vo_sve_sleef(vand_vo_vo_vo_sve_sleef(visnumber_vo_vf_sve_sleef(a), vlt_vo_vf_vf_sve_sleef(a, vcast_vf_f_sve_sleef(0))), visnan_vo_vf_sve_sleef(r))); + r = vsel_vf_vo_vf_vf_sve_sleef(o, vcast_vf_f_sve_sleef(__builtin_nanf("")), r); + + o = vand_vo_vo_vo_sve_sleef(vand_vo_vo_vo_sve_sleef(vor_vo_vo_vo_sve_sleef(veq_vo_vf_vf_sve_sleef(a, vcast_vf_f_sve_sleef(__builtin_inff())), visnumber_vo_vf_sve_sleef(a)), + vge_vo_vf_vf_sve_sleef(a, vcast_vf_f_sve_sleef(-0x1p-126))), + vor_vo_vo_vo_sve_sleef(vor_vo_vo_vo_sve_sleef(veq_vo_vf_vf_sve_sleef(a, vcast_vf_f_sve_sleef(0)), vgt_vo_vf_vf_sve_sleef(a, vcast_vf_f_sve_sleef(36))), visnan_vo_vf_sve_sleef(r))); + r = vsel_vf_vo_vf_vf_sve_sleef(o, vmulsign_vf_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(__builtin_inff()), a), r); + + return r; +} + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_lgammafx_u10sve(vfloat_sve_sleef a) { + df2_sve_sleef d = gammafk_sve_sleef(a); + vfloat2_sve_sleef y = dfadd2_vf2_vf2_vf2_sve_sleef(df2geta_vf2_df2_sve_sleef(d), logk2f_sve_sleef(dfabs_vf2_vf2_sve_sleef(df2getb_vf2_df2_sve_sleef(d)))); + vfloat_sve_sleef r = vadd_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(y), vf2gety_vf_vf2_sve_sleef(y)); + vopmask_sve_sleef o; + + o = vor_vo_vo_vo_sve_sleef(visinf_vo_vf_sve_sleef(a), + vor_vo_vo_vo_sve_sleef(vand_vo_vo_vo_sve_sleef(vle_vo_vf_vf_sve_sleef(a, vcast_vf_f_sve_sleef(0)), visint_vo_vf_sve_sleef(a)), + vand_vo_vo_vo_sve_sleef(visnumber_vo_vf_sve_sleef(a), visnan_vo_vf_sve_sleef(r)))); + r = vsel_vf_vo_vf_vf_sve_sleef(o, vcast_vf_f_sve_sleef(__builtin_inff()), r); + + return r; +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_sve_sleef dfmla_vf2_vf_vf2_vf2_sve_sleef(vfloat_sve_sleef x, vfloat2_sve_sleef y, vfloat2_sve_sleef z) { + return dfadd_vf2_vf2_vf2_sve_sleef(z, dfmul_vf2_vf2_vf_sve_sleef(y, x)); +} + +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_sve_sleef poly2df_b_sve_sleef(vfloat_sve_sleef x, vfloat2_sve_sleef c1, vfloat2_sve_sleef c0) { return dfmla_vf2_vf_vf2_vf2_sve_sleef(x, c1, c0); } +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_sve_sleef poly2df_sve_sleef(vfloat_sve_sleef x, vfloat_sve_sleef c1, vfloat2_sve_sleef c0) { return dfmla_vf2_vf_vf2_vf2_sve_sleef(x, vcast_vf2_vf_vf_sve_sleef(c1, vcast_vf_f_sve_sleef(0)), c0); } +static SLEEF_ALWAYS_INLINE SLEEF_CONST vfloat2_sve_sleef poly4df_sve_sleef(vfloat_sve_sleef x, vfloat_sve_sleef c3, vfloat2_sve_sleef c2, vfloat2_sve_sleef c1, vfloat2_sve_sleef c0) { + return dfmla_vf2_vf_vf2_vf2_sve_sleef(vmul_vf_vf_vf_sve_sleef(x, x), poly2df_sve_sleef(x, c3, c2), poly2df_b_sve_sleef(x, c1, c0)); +} + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_erffx_u10sve(vfloat_sve_sleef a) { + vfloat_sve_sleef t, x = vabs_vf_vf_sve_sleef(a); + vfloat2_sve_sleef t2; + vfloat_sve_sleef x2 = vmul_vf_vf_vf_sve_sleef(x, x), x4 = vmul_vf_vf_vf_sve_sleef(x2, x2); + vopmask_sve_sleef o25 = vle_vo_vf_vf_sve_sleef(x, vcast_vf_f_sve_sleef(2.5)); + + if (__builtin_expect(!!(vtestallones_i_vo32_sve_sleef(o25)), 1)) { + + t = vmla_vf_vf_vf_vf_sve_sleef((x4), (vmla_vf_vf_vf_vf_sve_sleef((x), (vcast_vf_f_sve_sleef(-0.4360447008e-6)), (vcast_vf_f_sve_sleef(+0.6867515367e-5)))), (vmla_vf_vf_vf_vf_sve_sleef((x2), (vmla_vf_vf_vf_vf_sve_sleef((x), (vcast_vf_f_sve_sleef(-0.3045156700e-4)), (vcast_vf_f_sve_sleef(+0.9808536561e-4)))), (vmla_vf_vf_vf_vf_sve_sleef((x), (vcast_vf_f_sve_sleef(+0.2395523916e-3)), (vcast_vf_f_sve_sleef(+0.1459901541e-3))))))) + + ; + t2 = poly4df_sve_sleef(x, t, + vcast_vf2_f_f_sve_sleef(0.0092883445322513580322, -2.7863745897025330755e-11), + vcast_vf2_f_f_sve_sleef(0.042275499552488327026, 1.3461399289988106057e-09), + vcast_vf2_f_f_sve_sleef(0.070523701608180999756, -3.6616309318707365163e-09)); + t2 = dfadd_vf2_vf_vf2_sve_sleef(vcast_vf_f_sve_sleef(1), dfmul_vf2_vf2_vf_sve_sleef(t2, x)); + t2 = dfsqu_vf2_vf2_sve_sleef(t2); + t2 = dfsqu_vf2_vf2_sve_sleef(t2); + t2 = dfsqu_vf2_vf2_sve_sleef(t2); + t2 = dfsqu_vf2_vf2_sve_sleef(t2); + t2 = dfrec_vf2_vf2_sve_sleef(t2); + } else { + + t = vmla_vf_vf_vf_vf_sve_sleef((x4), (vmla_vf_vf_vf_vf_sve_sleef((x), ((vsel_vf_vo_f_f_sve_sleef(o25, -0.4360447008e-6, -0.1130012848e-6))), ((vsel_vf_vo_f_f_sve_sleef(o25, +0.6867515367e-5, +0.4115272986e-5))))), (vmla_vf_vf_vf_vf_sve_sleef((x2), (vmla_vf_vf_vf_vf_sve_sleef((x), ((vsel_vf_vo_f_f_sve_sleef(o25, -0.3045156700e-4, -0.6928304356e-4))), ((vsel_vf_vo_f_f_sve_sleef(o25, +0.9808536561e-4, +0.7172692567e-3))))), (vmla_vf_vf_vf_vf_sve_sleef((x), ((vsel_vf_vo_f_f_sve_sleef(o25, +0.2395523916e-3, -0.5131045356e-2))), ((vsel_vf_vo_f_f_sve_sleef(o25, +0.1459901541e-3, +0.2708637156e-1)))))))) + + ; + t2 = poly4df_sve_sleef(x, t, + vsel_vf2_vo_vf2_vf2_sve_sleef(o25, vcast_vf2_f_f_sve_sleef(0.0092883445322513580322, -2.7863745897025330755e-11), + vcast_vf2_f_f_sve_sleef(-0.11064319312572479248, 3.7050452777225283007e-09)), + vsel_vf2_vo_vf2_vf2_sve_sleef(o25, vcast_vf2_f_f_sve_sleef(0.042275499552488327026, 1.3461399289988106057e-09), + vcast_vf2_f_f_sve_sleef(-0.63192230463027954102, -2.0200432585073177859e-08)), + vsel_vf2_vo_vf2_vf2_sve_sleef(o25, vcast_vf2_f_f_sve_sleef(0.070523701608180999756, -3.6616309318707365163e-09), + vcast_vf2_f_f_sve_sleef(-1.1296638250350952148, 2.5515120196453259252e-08))); + t2 = dfmul_vf2_vf2_vf_sve_sleef(t2, x); + vfloat2_sve_sleef s2 = dfadd_vf2_vf_vf2_sve_sleef(vcast_vf_f_sve_sleef(1), t2); + s2 = dfsqu_vf2_vf2_sve_sleef(s2); + s2 = dfsqu_vf2_vf2_sve_sleef(s2); + s2 = dfsqu_vf2_vf2_sve_sleef(s2); + s2 = dfsqu_vf2_vf2_sve_sleef(s2); + s2 = dfrec_vf2_vf2_sve_sleef(s2); + t2 = vsel_vf2_vo_vf2_vf2_sve_sleef(o25, s2, vcast_vf2_vf_vf_sve_sleef(expkf_sve_sleef(t2), vcast_vf_f_sve_sleef(0))); + } + + t2 = dfadd2_vf2_vf2_vf_sve_sleef(t2, vcast_vf_f_sve_sleef(-1)); + t2 = vsel_vf2_vo_vf2_vf2_sve_sleef(vlt_vo_vf_vf_sve_sleef(x, vcast_vf_f_sve_sleef(1e-4)), dfmul_vf2_vf2_vf_sve_sleef(vcast_vf2_f_f_sve_sleef(-1.1283792257308959961, 5.8635383422197591097e-08), x), t2); + + vfloat_sve_sleef z = vneg_vf_vf_sve_sleef(vadd_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(t2), vf2gety_vf_vf2_sve_sleef(t2))); + z = vsel_vf_vo_vf_vf_sve_sleef(vge_vo_vf_vf_sve_sleef(x, vcast_vf_f_sve_sleef(6)), vcast_vf_f_sve_sleef(1), z); + z = vsel_vf_vo_vf_vf_sve_sleef(visinf_vo_vf_sve_sleef(a), vcast_vf_f_sve_sleef(1), z); + z = vsel_vf_vo_vf_vf_sve_sleef(veq_vo_vf_vf_sve_sleef(a, vcast_vf_f_sve_sleef(0)), vcast_vf_f_sve_sleef(0), z); + z = vmulsign_vf_vf_vf_sve_sleef(z, a); + + return z; +} + +SLEEF_INLINE SLEEF_CONST vfloat_sve_sleef Sleef_erfcfx_u15sve(vfloat_sve_sleef a) { + vfloat_sve_sleef s = a, r = vcast_vf_f_sve_sleef(0), t; + vfloat2_sve_sleef u, d, x; + a = vabs_vf_vf_sve_sleef(a); + vopmask_sve_sleef o0 = vlt_vo_vf_vf_sve_sleef(a, vcast_vf_f_sve_sleef(1.0)); + vopmask_sve_sleef o1 = vlt_vo_vf_vf_sve_sleef(a, vcast_vf_f_sve_sleef(2.2)); + vopmask_sve_sleef o2 = vlt_vo_vf_vf_sve_sleef(a, vcast_vf_f_sve_sleef(4.3)); + vopmask_sve_sleef o3 = vlt_vo_vf_vf_sve_sleef(a, vcast_vf_f_sve_sleef(10.1)); + + u = vsel_vf2_vo_vf2_vf2_sve_sleef(o1, vcast_vf2_vf_vf_sve_sleef(a, vcast_vf_f_sve_sleef(0)), dfdiv_vf2_vf2_vf2_sve_sleef(vcast_vf2_f_f_sve_sleef(1, 0), vcast_vf2_vf_vf_sve_sleef(a, vcast_vf_f_sve_sleef(0)))); + + t = vsel_vf_vo_vo_vo_f_f_f_f_sve_sleef(o0, o1, o2, -0.8638041618e-4f, -0.6236977242e-5f, -0.3869504035e+0f, +0.1115344167e+1f); + t = vmla_vf_vf_vf_vf_sve_sleef(t, vf2getx_vf_vf2_sve_sleef(u), vsel_vf_vo_vo_vo_f_f_f_f_sve_sleef(o0, o1, o2, +0.6000166177e-3f, +0.5749821503e-4f, +0.1288077235e+1f, -0.9454904199e+0f)); + t = vmla_vf_vf_vf_vf_sve_sleef(t, vf2getx_vf_vf2_sve_sleef(u), vsel_vf_vo_vo_vo_f_f_f_f_sve_sleef(o0, o1, o2, -0.1665703603e-2f, +0.6002851478e-5f, -0.1816803217e+1f, -0.3667259514e+0f)); + t = vmla_vf_vf_vf_vf_sve_sleef(t, vf2getx_vf_vf2_sve_sleef(u), vsel_vf_vo_vo_vo_f_f_f_f_sve_sleef(o0, o1, o2, +0.1795156277e-3f, -0.2851036377e-2f, +0.1249150872e+1f, +0.7155663371e+0f)); + t = vmla_vf_vf_vf_vf_sve_sleef(t, vf2getx_vf_vf2_sve_sleef(u), vsel_vf_vo_vo_vo_f_f_f_f_sve_sleef(o0, o1, o2, +0.1914106123e-1f, +0.2260518074e-1f, -0.1328857988e+0f, -0.1262947265e-1f)); + + d = dfmul_vf2_vf2_vf_sve_sleef(u, t); + d = dfadd2_vf2_vf2_vf2_sve_sleef(d, vsel_vf2_vo_vo_vo_d_d_d_d_sve_sleef(o0, o1, o2, -0.102775359343930288081655368891e+0, -0.105247583459338632253369014063e+0, -0.482365310333045318680618892669e+0, -0.498961546254537647970305302739e+0)); + d = dfmul_vf2_vf2_vf2_sve_sleef(d, u); + d = dfadd2_vf2_vf2_vf2_sve_sleef(d, vsel_vf2_vo_vo_vo_d_d_d_d_sve_sleef(o0, o1, o2, -0.636619483208481931303752546439e+0, -0.635609463574589034216723775292e+0, -0.134450203224533979217859332703e-2, -0.471199543422848492080722832666e-4)); + d = dfmul_vf2_vf2_vf2_sve_sleef(d, u); + d = dfadd2_vf2_vf2_vf2_sve_sleef(d, vsel_vf2_vo_vo_vo_d_d_d_d_sve_sleef(o0, o1, o2, -0.112837917790537404939545770596e+1, -0.112855987376668622084547028949e+1, -0.572319781150472949561786101080e+0, -0.572364030327966044425932623525e+0)); + + x = dfmul_vf2_vf2_vf_sve_sleef(vsel_vf2_vo_vf2_vf2_sve_sleef(o1, d, vcast_vf2_vf_vf_sve_sleef(vneg_vf_vf_sve_sleef(a), vcast_vf_f_sve_sleef(0))), a); + x = vsel_vf2_vo_vf2_vf2_sve_sleef(o1, x, dfadd2_vf2_vf2_vf2_sve_sleef(x, d)); + + x = expk2f_sve_sleef(x); + x = vsel_vf2_vo_vf2_vf2_sve_sleef(o1, x, dfmul_vf2_vf2_vf2_sve_sleef(x, u)); + + r = vsel_vf_vo_vf_vf_sve_sleef(o3, vadd_vf_vf_vf_sve_sleef(vf2getx_vf_vf2_sve_sleef(x), vf2gety_vf_vf2_sve_sleef(x)), vcast_vf_f_sve_sleef(0)); + r = vsel_vf_vo_vf_vf_sve_sleef(vsignbit_vo_vf_sve_sleef(s), vsub_vf_vf_vf_sve_sleef(vcast_vf_f_sve_sleef(2), r), r); + r = vsel_vf_vo_vf_vf_sve_sleef(visnan_vo_vf_sve_sleef(s), vcast_vf_f_sve_sleef(__builtin_nanf("")), r); + return r; +} diff --git a/src/jdk.incubator.vector/linux/native/libsleef/lib/vector_math_rvv.c b/src/jdk.incubator.vector/linux/native/libsleef/lib/vector_math_rvv.c new file mode 100644 index 00000000000..438ca0c92ba --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/lib/vector_math_rvv.c @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2024, Rivos 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. + */ + +// On riscv, sleef vector apis depend on native vector intrinsic, which is supported on +// some compiler, e.g. gcc 14+. +// __riscv_v_intrinsic is used to tell if the compiler supports vector intrinsic. +// +// At compile-time, if the current compiler does support vector intrinsics, bridge +// functions will be built in the library. In case the current compiler doesn't support +// vector intrinsics (gcc < 14), then the bridge functions won't be compiled. +// At run-time, if the library is found and the bridge functions are available in the +// library, then the java vector API will call into the bridge functions and sleef. + +#if __GNUC__ >= 14 || (defined(__clang_major__) && __clang_major__ >= 17) + +#ifdef __riscv_v_intrinsic + +#include + +#include + +#include "../generated/misc.h" +#include "../generated/sleefinline_rvvm1.h" + +#include + +// We maintain an invariant in java world that default dynamic rounding mode is RNE, +// please check JDK-8330094, JDK-8330266 for more details. +// Currently, sleef source on riscv does not change rounding mode to others except +// of RNE. But we still think it's safer to make sure that after calling into sleef +// the dynamic rounding mode is always RNE. + +#ifdef DEBUG +#define CHECK_FRM __asm__ __volatile__ ( \ + " frrm t0 \n\t" \ + " beqz t0, 2f \n\t" \ + " csrrw x0, cycle, x0 \n\t" \ + "2: \n\t" \ + : : : "memory" ); +#else +#define CHECK_FRM +#endif + +#define DEFINE_VECTOR_MATH_UNARY_RVV(op, type) \ +JNIEXPORT \ +type op##rvv(type input) { \ + type res = Sleef_##op##rvvm1(input); \ + CHECK_FRM \ + return res; \ +} + +#define DEFINE_VECTOR_MATH_BINARY_RVV(op, type) \ +JNIEXPORT \ +type op##rvv(type input1, type input2) { \ + type res = Sleef_##op##rvvm1(input1, input2); \ + CHECK_FRM \ + return res; \ +} + +DEFINE_VECTOR_MATH_UNARY_RVV(tanfx_u10, vfloat_rvvm1_sleef) +DEFINE_VECTOR_MATH_UNARY_RVV(sinfx_u10, vfloat_rvvm1_sleef) +DEFINE_VECTOR_MATH_UNARY_RVV(sinhfx_u10, vfloat_rvvm1_sleef) +DEFINE_VECTOR_MATH_UNARY_RVV(cosfx_u10, vfloat_rvvm1_sleef) +DEFINE_VECTOR_MATH_UNARY_RVV(coshfx_u10, vfloat_rvvm1_sleef) +DEFINE_VECTOR_MATH_UNARY_RVV(asinfx_u10, vfloat_rvvm1_sleef) +DEFINE_VECTOR_MATH_UNARY_RVV(acosfx_u10, vfloat_rvvm1_sleef) +DEFINE_VECTOR_MATH_UNARY_RVV(atanfx_u10, vfloat_rvvm1_sleef) +DEFINE_VECTOR_MATH_UNARY_RVV(cbrtfx_u10, vfloat_rvvm1_sleef) +DEFINE_VECTOR_MATH_UNARY_RVV(logfx_u10, vfloat_rvvm1_sleef) +DEFINE_VECTOR_MATH_UNARY_RVV(log10fx_u10, vfloat_rvvm1_sleef) +DEFINE_VECTOR_MATH_UNARY_RVV(log1pfx_u10, vfloat_rvvm1_sleef) +DEFINE_VECTOR_MATH_UNARY_RVV(expfx_u10, vfloat_rvvm1_sleef) +DEFINE_VECTOR_MATH_UNARY_RVV(expm1fx_u10, vfloat_rvvm1_sleef) + +DEFINE_VECTOR_MATH_UNARY_RVV(tandx_u10, vdouble_rvvm1_sleef) +DEFINE_VECTOR_MATH_UNARY_RVV(sindx_u10, vdouble_rvvm1_sleef) +DEFINE_VECTOR_MATH_UNARY_RVV(sinhdx_u10, vdouble_rvvm1_sleef) +DEFINE_VECTOR_MATH_UNARY_RVV(cosdx_u10, vdouble_rvvm1_sleef) +DEFINE_VECTOR_MATH_UNARY_RVV(coshdx_u10, vdouble_rvvm1_sleef) +DEFINE_VECTOR_MATH_UNARY_RVV(asindx_u10, vdouble_rvvm1_sleef) +DEFINE_VECTOR_MATH_UNARY_RVV(acosdx_u10, vdouble_rvvm1_sleef) +DEFINE_VECTOR_MATH_UNARY_RVV(atandx_u10, vdouble_rvvm1_sleef) +DEFINE_VECTOR_MATH_UNARY_RVV(cbrtdx_u10, vdouble_rvvm1_sleef) +DEFINE_VECTOR_MATH_UNARY_RVV(logdx_u10, vdouble_rvvm1_sleef) +DEFINE_VECTOR_MATH_UNARY_RVV(log10dx_u10, vdouble_rvvm1_sleef) +DEFINE_VECTOR_MATH_UNARY_RVV(log1pdx_u10, vdouble_rvvm1_sleef) +DEFINE_VECTOR_MATH_UNARY_RVV(expdx_u10, vdouble_rvvm1_sleef) +DEFINE_VECTOR_MATH_UNARY_RVV(expm1dx_u10, vdouble_rvvm1_sleef) + +DEFINE_VECTOR_MATH_BINARY_RVV(atan2fx_u10, vfloat_rvvm1_sleef) +DEFINE_VECTOR_MATH_BINARY_RVV(powfx_u10, vfloat_rvvm1_sleef) +DEFINE_VECTOR_MATH_BINARY_RVV(hypotfx_u05, vfloat_rvvm1_sleef) + +DEFINE_VECTOR_MATH_BINARY_RVV(atan2dx_u10, vdouble_rvvm1_sleef) +DEFINE_VECTOR_MATH_BINARY_RVV(powdx_u10, vdouble_rvvm1_sleef) +DEFINE_VECTOR_MATH_BINARY_RVV(hypotdx_u05, vdouble_rvvm1_sleef) + +#undef DEFINE_VECTOR_MATH_UNARY_RVV + +#undef DEFINE_VECTOR_MATH_BINARY_RVV + +#endif /* __riscv_v_intrinsic */ + +#endif /* check gcc and clang version */ diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/CHANGELOG.md b/src/jdk.incubator.vector/linux/native/libsleef/upstream/CHANGELOG.md new file mode 100644 index 00000000000..750955336f5 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/CHANGELOG.md @@ -0,0 +1,255 @@ +## 3.6.1 - 2024-06-10 + +This patch release provides important bug fixes, including a fix +for API compatibility with 3.5 (#534). +The support and test for some features is still limited, as +documented in [README](./README.md), however significant progress +was made in order to test on Linux, macOS and Windows. + +### Added +- Add support for RISC-V in DFT, QUAD and inline headers (#503, + #522). +- Add GHA workflow to run CI tests on Windows x86 (#540) and macOS + x86/aarch64 (#543). And update test matrix. +- Add GHA workflows to run examples in CI (#550). + +### Changed +- Cleanup/Improve support for RISC-V in LIBM (#520, #521). +- Update supported environment in documentation (#529, #549), + including website and test matrix from README. + +### Fixed +- Major fix and cleanup of CMakeLists.txt (#531). +- Fix compatibility issue after removal of quad and long double + sincospi (#545). Restores functions that are missing in 3.6. +- Various bug fixes (#528, #533, #536, #537). + +## 3.6 - 2024-02-14 + +This release follows a long period of inactivity. The library is now +being actively maintained. However, the support and test for some +features is currently limited, as documented in [README](./README.md). + +### Added +- Add documentation for the quad precision math library +- Enable generation of inline header file for CUDA (PR #337) +- Add support for System/390 z15 support (PR #343) +- Add support for POWER 9 (PR #360) +- Add quad-precision functions (PR #375, #377, #380, #381, #382, #383, + #385, #386, #387) +- Add preliminary support for iOS and Android (PR #388, #389) +- Add OpenMP pragmas to the function declarations in sleef.h to enable + auto-vectorization by GCC (PR #404, #406) +- Add new public CI test infrastructure using GitHub Actions (PR #476) +- Add support for RISC-V in libm (PR #477) + +### Removed +- Remove old CI scripts based on Travis/Jenkins/Appveyor (PR #502) + +### Changed +- Optimise error functions (PR #370) +- Update CMake package config (PR #412) +- Update documentation and move doc/website to main repository (PR #504, + #513) +- Add SLEEF_ prefix to user-facing CMake options (PR #509) +- Disable SVE on Darwin (PR #512) + +### Fixed +- Fix parallel builds with GNU make (PR #491) +- Various bug fixes (PR #492, #499, #508) + +## 3.5.1 - 2020-09-15 +### Changed +- Fixed a bug in handling compiler options + +## 3.5 - 2020-09-01 +- IBM System/390 support is added. +- The library can be built with Clang on Windows. +- Static libraries with LTO can be generated. +- Alternative division and sqrt methods can be chosen with AArch64. +- Header files for inlining the whole SLEEF functions can be generated. +- IEEE remainder function is added. +- GCC-10 can now build SLEEF with SVE support. + +## 3.4.1 - 2019-10-01 +### Changed +- Fixed accuracy problem with tan_u35, atan_u10, log2f_u35 and exp10f_u10. + https://github.com/shibatch/sleef/pull/260 + https://github.com/shibatch/sleef/pull/265 + https://github.com/shibatch/sleef/pull/267 +- SVE intrinsics that are not supported in newer ACLE are replaced. + https://github.com/shibatch/sleef/pull/268 +- FMA4 detection problem is fixed. + https://github.com/shibatch/sleef/pull/262 +- Compilation problem under Windows with MinGW is fixed. + https://github.com/shibatch/sleef/pull/266 + +## 3.4 - 2019-04-28 +### Added +- Faster and low precision functions are added. + https://github.com/shibatch/sleef/pull/229 +- Functions that return consistent results across platforms are + added + https://github.com/shibatch/sleef/pull/216 + https://github.com/shibatch/sleef/pull/224 +- Quad precision math library(libsleefquad) is added + https://github.com/shibatch/sleef/pull/235 + https://github.com/shibatch/sleef/pull/237 + https://github.com/shibatch/sleef/pull/240 +- AArch64 Vector Procedure Call Standard (AAVPCS) support. +### Changed +- Many functions are now faster +- Testers are now faster + +## 3.3.1 - 2018-08-20 +### Added +- FreeBSD support is added +### Changed +- i386 build problem is fixed +- Trigonometric functions now evaluate correctly with full FP + domain. + https://github.com/shibatch/sleef/pull/210 + +## 3.3 - 2018-07-06 +### Added +- SVE target support is added to libsleef. + https://github.com/shibatch/sleef/pull/180 +- SVE target support is added to DFT. With this patch, DFT operations + can be carried out using 256, 512, 1024 and 2048-bit wide vectors + according to runtime availability of vector registers and operators. + https://github.com/shibatch/sleef/pull/182 +- 3.5-ULP versions of sinh, cosh, tanh, sinhf, coshf, tanhf, and the + corresponding testing functionalities are added. + https://github.com/shibatch/sleef/pull/192 +- Power VSX target support is added to libsleef. + https://github.com/shibatch/sleef/pull/195 +- Payne-Hanek like argument reduction is added to libsleef. + https://github.com/shibatch/sleef/pull/197 + +## 3.2 - 2018-02-26 +### Added +- The whole build system of the project migrated from makefiles to + cmake. In particualr this includes `libsleef`, `libsleefgnuabi`, + `libdft` and all the tests. +- Benchmarks that compare `libsleef` vs `SVML` on X86 Linux are + available in the project tree under src/libm-benchmarks directory. +- Extensive upstream testing via Travis CI and Appveyor, on the + following systems: + * OS: Windows / Linux / OSX. + * Compilers: gcc / clang / MSVC. + * Targets: X86 (SSE/AVX/AVX2/AVX512F), AArch64 (Advanced SIMD), ARM + (NEON). Emulators like QEMU or SDE can be used to run the tests. +- Added the following new vector functions (with relative testing): + * `log2` +- New compatibility tests have been added to check that + `libsleefgnuabi` exports the GNUABI symbols correctly. +- The library can be compiled to an LLVM bitcode object. +- Added masked interface to the library to support AVX512F masked + vectorization. + +### Changed +- Use native instructions if available for `sqrt`. +- Fixed fmax and fmin behavior on AArch64: + https://github.com/shibatch/sleef/pull/140 +- Speed improvements for `asin`, `acos`, `fmod` and `log`. Computation + speed of other functions are also improved by general optimization. + https://github.com/shibatch/sleef/pull/97 +- Removed `libm` dependency. + +### Removed +- Makefile build system + +## 3.1 - 2017-07-19 +- Added AArch64 support +- Implemented the remaining C99 math functions : lgamma, tgamma, + erf, erfc, fabs, copysign, fmax, fmin, fdim, trunc, floor, ceil, + round, rint, modf, ldexp, nextafter, frexp, hypot, and fmod. +- Added dispatcher for x86 functions +- Improved reduction of trigonometric functions +- Added support for 32-bit x86, Cygwin, etc. +- Improved tester + +## 3.0 - 2017-02-07 +- New API is defined +- Functions for DFT are added +- sincospi functions are added +- gencoef now supports single, extended and quad precision in addition to double precision +- Linux, Windows and Mac OS X are supported +- GCC, Clang, Intel Compiler, Microsoft Visual C++ are supported +- The library can be compiled as DLLs +- Files needed for creating a debian package are now included + +## 2.120 - 2017-01-30 +- Relicensed to Boost Software License Version 1.0 + +## 2.110 - 2016-12-11 +- The valid range of argument is extended for trig functions +- Specification of each functions regarding to the domain and accuracy is added +- A coefficient generation tool is added +- New testing tools are introduced +- Following functions returned incorrect values when the argument is very large or small : exp, pow, asinh, acosh +- SIMD xsin and xcos returned values more than 1 when FMA is enabled +- Pure C cbrt returned incorrect values when the argument is negative +- tan_u1 returned values with more than 1 ulp of error on rare occasions +- Removed support for Java language(because no one seems using this) + +## 2.100 - 2016-12-04 +- Added support for AVX-512F and Clang Extended Vectors. + +## 2.90 - 2016-11-27 +- Added ilogbf. All the reported bugs(listed below) are fixed. +- Log function returned incorrect values when the argument is very small. +- Signs of returned values were incorrect when the argument is signed zero. +- Tester incorrectly counted ULP in some cases. +- ilogb function returned incorrect values in some cases. + +## 2.80 - 2013-05-18 +- Added support for ARM NEON. Added higher accuracy single + precision functions : sinf_u1, cosf_u1, sincosf_u1, tanf_u1, asinf_u1, + acosf_u1, atanf_u1, atan2f_u1, logf_u1, and cbrtf_u1. + +## 2.70 - 2013-04-30 +- Added higher accuracy functions : sin_u1, cos_u1, sincos_u1, + tan_u1, asin_u1, acos_u1, atan_u1, atan2_u1, log_u1, and + cbrt_u1. These functions evaluate the corresponding function with at + most 1 ulp of error. + +## 2.60 - 2013-03-26 +- Added the remaining single precision functions : powf, sinhf, + coshf, tanhf, exp2f, exp10f, log10f, log1pf. Added support for FMA4 + (for AMD Bulldozer). Added more test cases. Fixed minor bugs (which + degraded accuracy in some rare cases). + +## 2.50 - 2013-03-12 +- Added support for AVX2. SLEEF now compiles with ICC. + +## 2.40 - 2013-03-07 +- Fixed incorrect denormal/nonnumber handling in ldexp, ldexpf, + sinf and cosf. Removed support for Go language. + +## 2.31 - 2012-07-05 +- Added sincosf. + +## 2.30 - 2012-01-20 +- Added single precision functions : sinf, cosf, tanf, asinf, + acosf, atanf, logf, expf, atan2f and cbrtf. + +## 2.20 - 2012-01-09 +- Added exp2, exp10, expm1, log10, log1p, and cbrt. + +## 2.10 - 2012-01-05 +- asin() and acos() are back. +- Added ilogb() and ldexp(). +- Added hyperbolic functions. +- Eliminated dependency on frexp, ldexp, fabs, isnan and isinf. + +## 2.00 - 2011-12-30 +- All of the algorithm has been updated. +- Both accuracy and speed are improved since version 1.10. +- Denormal number handling is also improved. + +## 1.10 - 2010-06-22 +- AVX support is added. Accuracy tester is added. + +## 1.00 - 2010-05-15 +- Initial release diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/CMakeLists.txt b/src/jdk.incubator.vector/linux/native/libsleef/upstream/CMakeLists.txt new file mode 100644 index 00000000000..a37f1ac1046 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/CMakeLists.txt @@ -0,0 +1,339 @@ +cmake_minimum_required(VERSION 3.18) +project(SLEEF VERSION 3.6.1 LANGUAGES C) + +set(SLEEF_SOVERSION ${SLEEF_VERSION_MAJOR}) + +# Options + +option(SLEEF_BUILD_STATIC_TEST_BINS "Build statically linked test executables" OFF) +option(SLEEF_ENABLE_LTO "Enable LTO on GCC or ThinLTO on clang" OFF) +option(SLEEF_BUILD_LIBM "libsleef will be built." ON) +option(SLEEF_BUILD_DFT "libsleefdft will be built." OFF) +option(SLEEF_BUILD_QUAD "libsleefquad will be built." OFF) +option(SLEEF_BUILD_GNUABI_LIBS "libsleefgnuabi will be built." ON) +option(SLEEF_BUILD_SCALAR_LIB "libsleefscalar will be built." OFF) +option(SLEEF_BUILD_TESTS "Tests will be built." ON) +option(SLEEF_BUILD_INLINE_HEADERS "Build header for inlining whole SLEEF functions" OFF) + +option(SLEEF_TEST_ALL_IUT "Perform tests on implementations with all vector extensions" OFF) +option(SLEEF_SHOW_CONFIG "Show SLEEF configuration status messages." ON) +option(SLEEF_SHOW_ERROR_LOG "Show cmake error log." OFF) +option(SLEEF_ASAN "Enable address sanitizing on all targets." OFF) + +option(SLEEF_ENFORCE_TESTER "Build fails if tester is not available" OFF) +option(SLEEF_ENFORCE_TESTER3 "Build fails if tester3 is not built" OFF) + +option(SLEEF_ENABLE_ALTDIV "Enable alternative division method (aarch64 only)" OFF) +option(SLEEF_ENABLE_ALTSQRT "Enable alternative sqrt method (aarch64 only)" OFF) + +option(SLEEF_DISABLE_FFTW "Disable testing the DFT library with FFTW" OFF) +option(SLEEF_DISABLE_MPFR "Disable testing with the MPFR library" OFF) +option(SLEEF_DISABLE_SSL "Disable testing with the SSL library" OFF) + +option(SLEEF_ENABLE_CUDA "Enable CUDA" OFF) +option(SLEEF_ENABLE_CXX "Enable C++" OFF) + +# + +if (DEFINED SLEEF_BUILD_SHARED_LIBS) + set(BUILD_SHARED_LIBS ${SLEEF_BUILD_SHARED_LIBS}) +endif () + +if (SLEEF_SHOW_CONFIG) + # Normalize the value of BUILD_SHARED_LIBS so that it displays nicely + # in the configuration display + if (BUILD_SHARED_LIBS) + set(BUILD_SHARED_LIBS ON) + else () + set(BUILD_SHARED_LIBS OFF) + endif () +endif () + +# Function used to generate safe command arguments for add_custom_command +function(command_arguments PROPNAME) + set(quoted_args "") + foreach(arg ${ARGN}) + list(APPEND quoted_args "\"${arg}\"" ) + endforeach() + set(${PROPNAME} ${quoted_args} PARENT_SCOPE) +endfunction() + +# Helper function for concatenating several files +function(sleef_concat_files) + cmake_parse_arguments(concat_required "" "OUTPUT" "SOURCES" ${ARGN}) + if("${concat_required_OUTPUT}" STREQUAL "") + message(FATAL_ERROR "Must pass OUTPUT to sleef_concat_files") + endif() + + if(NOT concat_required_SOURCES) + message(FATAL_ERROR "sleef_concat_files not passed any SOURCES") + endif() + + add_custom_command( + OUTPUT ${concat_required_OUTPUT} + COMMAND ${CMAKE_COMMAND} -E cat ${concat_required_SOURCES} > ${concat_required_OUTPUT} + DEPENDS ${concat_required_SOURCES} + COMMAND_EXPAND_LISTS) +endfunction() + +# Settings + +set(SLEEF_ALL_SUPPORTED_EXTENSIONS + AVX512FNOFMA AVX512F AVX2 AVX2128 FMA4 AVX SSE4 SSE2 # x86 + SVENOFMA SVE ADVSIMDNOFMA ADVSIMD # Aarch64 + NEON32 NEON32VFPV4 # Aarch32 + VSX VSXNOFMA VSX3 VSX3NOFMA # PPC64 + VXE VXENOFMA VXE2 VXE2NOFMA # IBM Z + RVVM1NOFMA RVVM1 RVVM2NOFMA RVVM2 # RISC-V Vectors + PUREC_SCALAR PURECFMA_SCALAR # Generic type + CACHE STRING "List of SIMD architectures supported by libsleef." + ) + +set(SLEEF_SUPPORTED_LIBM_EXTENSIONS + AVX512FNOFMA AVX512F AVX2 AVX2128 FMA4 AVX SSE4 SSE2 # x86 + SVENOFMA SVE ADVSIMDNOFMA ADVSIMD # Aarch64 + NEON32 NEON32VFPV4 # Aarch32 + VSX VSXNOFMA VSX3 VSX3NOFMA # PPC64 + VXE VXENOFMA VXE2 VXE2NOFMA # IBM Z + RVVM1NOFMA RVVM1 RVVM2NOFMA RVVM2 # RISC-V Vectors + PUREC_SCALAR PURECFMA_SCALAR # Generic type + CACHE STRING "List of SIMD architectures supported by libsleef." + ) +set(SLEEF_SUPPORTED_GNUABI_EXTENSIONS + SSE2 AVX AVX2 AVX512F ADVSIMD SVE + CACHE STRING "List of SIMD architectures supported by libsleef for GNU ABI." +) + +set(SLEEF_SUPPORTED_QUAD_EXTENSIONS + PUREC_SCALAR PURECFMA_SCALAR SSE2 AVX2128 AVX2 AVX512F ADVSIMD SVE VSX VSX3 VXE VXE2 RVVM1 RVVM2) + +# MKMASKED_PARAMS + +command_arguments(MKMASKED_PARAMS_GNUABI_AVX512F_dp avx512f e 8) +command_arguments(MKMASKED_PARAMS_GNUABI_AVX512F_sp avx512f e -16) + +command_arguments(MKMASKED_PARAMS_GNUABI_SVE_dp sve s 2) +command_arguments(MKMASKED_PARAMS_GNUABI_SVE_sp sve s -4) + +# + +set(COSTOVERRIDE_AVX512F 10) +set(COSTOVERRIDE_AVX512FNOFMA 10) +set(COSTOVERRIDE_AVX2 2) +set(COSTOVERRIDE_AVX 2) +set(COSTOVERRIDE_NEON32 2) +set(COSTOVERRIDE_NEON32VFPV4 2) +set(COSTOVERRIDE_SVE 10) +set(COSTOVERRIDE_SVENOFMA 10) +set(COSTOVERRIDE_RVVM1 10) +set(COSTOVERRIDE_RVVM1NOFMA 10) +set(COSTOVERRIDE_RVVM2 20) +set(COSTOVERRIDE_RVVM2NOFMA 20) + +# + +enable_testing() + +if (SLEEF_ENABLE_CXX) + enable_language(CXX) +endif() + +if (SLEEF_ENABLE_CUDA) + enable_language(CUDA) +endif() + +# For specifying installation directories +include(GNUInstallDirs) + +if(NOT DEFINED sleef_SOURCE_DIR) + set(sleef_SOURCE_DIR ${CMAKE_SOURCE_DIR}) +endif() + +if(NOT DEFINED sleef_BINARY_DIR) + set(sleef_BINARY_DIR ${CMAKE_BINARY_DIR}) +endif() + +# Sanity check for in-source builds which we do not want to happen +if(sleef_SOURCE_DIR STREQUAL sleef_BINARY_DIR) + message(FATAL_ERROR "SLEEF does not allow in-source builds. +You can refer to docs/build-with-cmake.md for instructions on how provide a \ +separate build directory. Note: Please remove autogenerated file \ +`CMakeCache.txt` and directory `CMakeFiles` in the current directory.") +endif() + +if(SLEEF_ENABLE_LTO AND BUILD_SHARED_LIBS) + message(FATAL_ERROR "SLEEF_ENABLE_LTO and BUILD_SHARED_LIBS cannot be specified at the same time") +endif(SLEEF_ENABLE_LTO AND BUILD_SHARED_LIBS) + +if(SLEEF_ENABLE_LTO) + include(CheckIPOSupported) + check_ipo_supported(RESULT supported OUTPUT error) +endif() + +# Set output directories for the library files +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin) + +foreach(CONFIG ${CMAKE_CONFIGURATION_TYPES}) + string(TOUPPER ${CONFIG} CONFIG) + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CONFIG} ${PROJECT_BINARY_DIR}/lib) + set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CONFIG} ${PROJECT_BINARY_DIR}/lib) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CONFIG} ${PROJECT_BINARY_DIR}/bin) +endforeach(CONFIG CMAKE_CONFIGURATION_TYPES) + +# Path for finding cmake modules +set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules) +set(SLEEF_SCRIPT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Scripts CACHE PATH + "Path for finding sleef specific cmake scripts") + +if (CMAKE_C_COMPILER_ID MATCHES "Clang" AND "x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC") + message(STATUS "Building with Clang on Windows") + set(SLEEF_CLANG_ON_WINDOWS TRUE) +endif() + +# sleef-config.h.in passes cmake settings to the source code +include(Configure.cmake) +configure_file( + ${PROJECT_SOURCE_DIR}/sleef-config.h.in + ${PROJECT_BINARY_DIR}/include/sleef-config.h @ONLY) + +# We like to have a documented index of all targets in the project. The +# variables listed below carry the names of the targets defined throughout +# the project. + +# Generates object file (shared library) `libsleef` +# Defined in src/libm/CMakeLists.txt via command add_library +set(TARGET_LIBSLEEF "sleef") +set(TARGET_LIBSLEEFGNUABI "sleefgnuabi") +# Generates the sleef.h headers and all the rename headers +# Defined in src/libm/CMakeLists.txt via custom commands and a custom target +set(TARGET_HEADERS "headers") +set(TARGET_INLINE_HEADERS "inline_headers") +set(TARGET_QINLINE_HEADERS "quad_inline_headers") +set(TARGET_LIBINLINE "sleefinline") +# Generates executable files for running the test suite +# Defined in src/libm-tester/CMakeLists.txt via command add_executable +set(TARGET_TESTER "tester") +set(TARGET_IUT "iut") +# The target to generate LLVM bitcode only, available when SLEEF_ENABLE_LLVM_BITCODE is passed to cmake +set(TARGET_LLVM_BITCODE "llvm-bitcode") +# Generates the helper executable file mkrename needed to write the sleef header +set(TARGET_MKRENAME "mkrename") +set(TARGET_MKRENAME_GNUABI "mkrename_gnuabi") +set(TARGET_MKMASKED_GNUABI "mkmasked_gnuabi") +# Generates the helper executable file mkdisp needed to write the sleef header +set(TARGET_MKDISP "mkdisp") +set(TARGET_MKALIAS "mkalias") +# Generates static library common +# Defined in src/common/CMakeLists.txt via command add_library +set(TARGET_LIBCOMMON_OBJ "common") +set(TARGET_LIBARRAYMAP_OBJ "arraymap") + +# Function used to add an executable that is executed on host +function(add_host_executable TARGETNAME) + if (NOT CMAKE_CROSSCOMPILING) + add_executable(${TARGETNAME} ${ARGN}) + # Ensure that Darwin host executable is built as universal binary + if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND CMAKE_OSX_ARCHITECTURES MATCHES "^(x86_64|arm64)$") + target_compile_options(${TARGETNAME} PRIVATE -arch "${CMAKE_HOST_SYSTEM_PROCESSOR}") + target_link_options(${TARGETNAME} PRIVATE -arch "${CMAKE_HOST_SYSTEM_PROCESSOR}") + endif() + else() + add_executable(${TARGETNAME} IMPORTED GLOBAL) + set_property(TARGET ${TARGETNAME} PROPERTY IMPORTED_LOCATION ${NATIVE_BUILD_DIR}/bin/${TARGETNAME}) + endif() +endfunction() + +function(host_target_AAVPCS_definitions TARGETNAME) + if (NOT CMAKE_CROSSCOMPILING) + target_compile_definitions(${TARGETNAME} PRIVATE ENABLE_AAVPCS=1) + endif() +endfunction() + +# Generates object file (shared library) `libsleefdft` +# Defined in src/dft/CMakeLists.txt via command add_library +set(TARGET_LIBDFT "sleefdft") + +# Check subdirectories +add_subdirectory("src") + +# Install the CMake package config +include(CMakePackageConfigHelpers) + +write_basic_package_version_file( + sleefConfigVersion.cmake + COMPATIBILITY SameMajorVersion +) + +set( + SLEEF_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/sleef" + CACHE STRING "CMake package config location relative to the install prefix" +) + +mark_as_advanced(SLEEF_INSTALL_CMAKEDIR) + +install( + FILES + "${PROJECT_SOURCE_DIR}/sleefConfig.cmake" + "${PROJECT_BINARY_DIR}/sleefConfigVersion.cmake" + DESTINATION "${SLEEF_INSTALL_CMAKEDIR}" + COMPONENT sleef_Development +) + +install( + EXPORT sleefTargets + NAMESPACE sleef:: + DESTINATION "${SLEEF_INSTALL_CMAKEDIR}" + COMPONENT sleef_Development +) + +# Extra messages at configuration time. By default is active, it can be +# turned off by invoking cmake with "-DSLEEF_SHOW_CONFIG=OFF". +if(SLEEF_SHOW_CONFIG) + message(STATUS "Configuring build for ${PROJECT_NAME}-v${SLEEF_VERSION}") + message(" Target system: ${CMAKE_SYSTEM}") + if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND CMAKE_OSX_ARCHITECTURES MATCHES "^(x86_64|arm64)$") + message(" Target processor: ${CMAKE_OSX_ARCHITECTURES}") + else() + message(" Target processor: ${CMAKE_SYSTEM_PROCESSOR}") + endif() + message(" Host system: ${CMAKE_HOST_SYSTEM}") + message(" Host processor: ${CMAKE_HOST_SYSTEM_PROCESSOR}") + message(" Detected C compiler: ${CMAKE_C_COMPILER_ID} @ ${CMAKE_C_COMPILER}") + message(" CMake: ${CMAKE_VERSION}") + message(" Make program: ${CMAKE_MAKE_PROGRAM}") + if(CMAKE_CROSSCOMPILING) + message(" Crosscompiling SLEEF.") + message(" Native build dir: ${NATIVE_BUILD_DIR}") + endif(CMAKE_CROSSCOMPILING) + message(STATUS "Using option `${SLEEF_C_FLAGS}` to compile libsleef") + message(STATUS "Building shared libs : " ${BUILD_SHARED_LIBS}) + message(STATUS "Building static test bins: " ${SLEEF_BUILD_STATIC_TEST_BINS}) + message(STATUS "MPFR : " ${LIB_MPFR}) + if (MPFR_INCLUDE_DIR) + message(STATUS "MPFR header file in " ${MPFR_INCLUDE_DIR}) + endif() + message(STATUS "GMP : " ${LIBGMP}) + message(STATUS "RT : " ${LIBRT}) + message(STATUS "FFTW3 : " ${LIBFFTW3}) + message(STATUS "OPENSSL : " ${OPENSSL_VERSION}) + message(STATUS "SDE : " ${SDE_COMMAND}) + if (SLEEF_BUILD_INLINE_HEADERS) + message(STATUS "SED : " ${SED_COMMAND}) + endif() + message(STATUS "COMPILER_SUPPORTS_OPENMP : " ${COMPILER_SUPPORTS_OPENMP}) + if(ENABLE_GNUABI) + message(STATUS "A version of SLEEF compatible with libm and libmvec in GNU libc will be produced (${TARGET_LIBSLEEFGNUABI}.so)") + endif() + if (COMPILER_SUPPORTS_SVE) + message(STATUS "Building SLEEF with VLA SVE support") + if (ARMIE_COMMAND) + message(STATUS "Arm Instruction Emulator found at ${ARMIE_COMMAND}") + message(STATUS "SVE testing is done with ${SVE_VECTOR_BITS}-bits vectors.") + endif() + endif() + if(FORCE_AAVPCS) + message(STATUS "Building SLEEF with AArch64 Vector PCS support") + endif() +endif(SLEEF_SHOW_CONFIG) diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/CONTRIBUTORS.md b/src/jdk.incubator.vector/linux/native/libsleef/upstream/CONTRIBUTORS.md new file mode 100644 index 00000000000..c0f269418f3 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/CONTRIBUTORS.md @@ -0,0 +1,27 @@ +# List of contributors + +These lists are not exhaustive and only provide most relevant contact information. +For an exhausitive list of contributors please refer to the +[GitHub contributors section for SLEEF](https://github.com/shibatch/sleef/graphs/contributors). + +## Maintainers + +| Name | Affiliation | Github profile | +| -------------------- | ----------------------- | ---------------------------------- | +| Pierre Blanchard | Arm Ltd. | https://github.com/blapie | +| Joana Cruz | Arm Ltd. | https://github.com/joanaxcruz | +| Joe Ramsay | Arm Ltd. | https://github.com/joeramsay | +| Naoki Shibata | Nara Institute of Science and Technology | https://github.com/shibatch | + +## Contributors + +| Name | Affiliation | Github profile | +| -------------------- | ----------------------- | ---------------------------------- | +| Anonymous | | https://github.com/friendlyanon | +| Diana Bite | Former Arm Ltd. | https://github.com/diaena | +| Ludovic Henry | Rivos Inc. | https://github.com/luhenry | +| Martin Krastev | Chaos Group | https://github.com/blu | +| Jilayne Lovejoy | Former Arm Inc. | https://github.com/jlovejoy | +| Kerry McLaughlin | Arm Ltd. | https://github.com/kmclaughlin-arm | +| Alexandre Mutel | Unity Technologies | https://github.com/xoofx | +| Francesco Petrogalli | Former Arm Ltd. | https://github.com/fpetrogalli-arm | diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/Configure.cmake b/src/jdk.incubator.vector/linux/native/libsleef/upstream/Configure.cmake new file mode 100644 index 00000000000..d78fc0bccaa --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/Configure.cmake @@ -0,0 +1,860 @@ +include(CheckCCompilerFlag) +include(CheckCSourceCompiles) +include(CheckTypeSize) +include(CheckLanguage) + +# + +if (SLEEF_BUILD_STATIC_TEST_BINS) + set(CMAKE_FIND_LIBRARY_SUFFIXES ".a") + set(BUILD_SHARED_LIBS OFF) + set(CMAKE_EXE_LINKER_FLAGS "-static") +endif() + +set(OPENSSL_EXTRA_LIBRARIES "" CACHE STRING "Extra libraries for openssl") +if (NOT CMAKE_CROSSCOMPILING AND NOT SLEEF_FORCE_FIND_PACKAGE_SSL) + if (SLEEF_BUILD_STATIC_TEST_BINS) + set(OPENSSL_USE_STATIC_LIBS TRUE) + endif() + find_package(OpenSSL) + if (OPENSSL_FOUND) + set(SLEEF_OPENSSL_FOUND TRUE) + set(SLEEF_OPENSSL_LIBRARIES ${OPENSSL_LIBRARIES}) + # Work around for tester3 sig segv, when linking versions of openssl (1.1.1) statically. + # This is a known issue https://github.com/openssl/openssl/issues/13872. + if (SLEEF_BUILD_STATIC_TEST_BINS) + string(REGEX REPLACE + "-lpthread" "-Wl,--whole-archive -lpthread -Wl,--no-whole-archive" + SLEEF_OPENSSL_LIBRARIES "${OPENSSL_LIBRARIES}") + endif() + set(SLEEF_OPENSSL_VERSION ${OPENSSL_VERSION}) + set(SLEEF_OPENSSL_LIBRARIES ${SLEEF_OPENSSL_LIBRARIES} ${OPENSSL_EXTRA_LIBRARIES}) + set(SLEEF_OPENSSL_INCLUDE_DIR ${OPENSSL_INCLUDE_DIR}) + endif() +else() + # find_package cannot find OpenSSL when cross-compiling + find_library(LIBSSL ssl) + find_library(LIBCRYPTO crypto) + if (LIBSSL AND LIBCRYPTO) + set(SLEEF_OPENSSL_FOUND TRUE) + set(SLEEF_OPENSSL_LIBRARIES ${LIBSSL} ${LIBCRYPTO} ${OPENSSL_EXTRA_LIBRARIES}) + set(SLEEF_OPENSSL_VERSION ${LIBSSL}) + endif() +endif() + +if (SLEEF_ENFORCE_TESTER3 AND NOT SLEEF_OPENSSL_FOUND) + message(FATAL_ERROR "SLEEF_ENFORCE_TESTER3 is specified and OpenSSL not found") +endif() + +# Some toolchains require explicit linking of the libraries following. +find_library(LIB_MPFR mpfr) +find_library(LIBM m) +find_library(LIBGMP gmp) +find_library(LIBRT rt) +find_library(LIBFFTW3 fftw3) + +if (LIB_MPFR) + find_path(MPFR_INCLUDE_DIR + NAMES mpfr.h + ONLY_CMAKE_FIND_ROOT_PATH) +endif(LIB_MPFR) + +if (LIBFFTW3) + find_path(FFTW3_INCLUDE_DIR + NAMES fftw3.h + ONLY_CMAKE_FIND_ROOT_PATH) +endif(LIBFFTW3) + +if (NOT LIBM) + set(LIBM "") +endif() + +if (NOT LIBRT) + set(LIBRT "") +endif() + +if (SLEEF_DISABLE_MPFR) + set(LIB_MPFR "") +endif() + +if (SLEEF_DISABLE_SSL) + set(SLEEF_OPENSSL_FOUND FALSE) +endif() + +# Force set default build type if none was specified +# Note: some sleef code requires the optimisation flags turned on +if(NOT CMAKE_BUILD_TYPE) + message(STATUS "Setting build type to 'Release' (required for full support).") + set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS + "Debug" "Release" "RelWithDebInfo" "MinSizeRel") +endif() + +# Sanitizers +if(SLEEF_ASAN) + # Add address sanitizing to all targets + add_compile_options(-fno-omit-frame-pointer -fsanitize=address) + add_link_options(-fno-omit-frame-pointer -fsanitize=address) +endif() + +# TARGET PROCESSOR DETECTION +set(SLEEF_TARGET_PROCESSOR "${CMAKE_SYSTEM_PROCESSOR}") +if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND CMAKE_OSX_ARCHITECTURES MATCHES "^(x86_64|arm64)$") + set(SLEEF_TARGET_PROCESSOR "${CMAKE_OSX_ARCHITECTURES}") +endif() + +# PLATFORM DETECTION +if(CMAKE_SIZEOF_VOID_P EQUAL 4) + set(SLEEF_ARCH_32BIT ON CACHE INTERNAL "True for 32-bit architecture.") +endif() + +if(SLEEF_TARGET_PROCESSOR MATCHES "(x86|AMD64|amd64|^i.86$)") + set(SLEEF_ARCH_X86 ON CACHE INTERNAL "True for x86 architecture.") + + set(CLANG_FLAGS_ENABLE_PURECFMA_SCALAR "-mavx2;-mfma") +elseif(SLEEF_TARGET_PROCESSOR MATCHES "aarch64|arm64") + set(SLEEF_ARCH_AARCH64 ON CACHE INTERNAL "True for Aarch64 architecture.") + # Aarch64 requires support for advsimdfma4 + set(COMPILER_SUPPORTS_ADVSIMD 1) + set(COMPILER_SUPPORTS_ADVSIMDNOFMA 1) + +elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "arm") + set(SLEEF_ARCH_AARCH32 ON CACHE INTERNAL "True for Aarch32 architecture.") + set(COMPILER_SUPPORTS_NEON32 1) + set(COMPILER_SUPPORTS_NEON32VFPV4 1) + + set(CLANG_FLAGS_ENABLE_PURECFMA_SCALAR "-mfpu=vfpv4") +elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)64") + set(SLEEF_ARCH_PPC64 ON CACHE INTERNAL "True for PPC64 architecture.") + + set(CLANG_FLAGS_ENABLE_PURECFMA_SCALAR "-mvsx") +elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "s390x") + set(SLEEF_ARCH_S390X ON CACHE INTERNAL "True for IBM Z architecture.") + + set(CLANG_FLAGS_ENABLE_PUREC_SCALAR "-march=z14;-mzvector") + set(CLANG_FLAGS_ENABLE_PURECFMA_SCALAR "-march=z14;-mzvector") +elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "riscv64") + set(SLEEF_ARCH_RISCV64 ON CACHE INTERNAL "True for RISCV64 architecture.") +endif() + +set(COMPILER_SUPPORTS_PUREC_SCALAR 1) +set(COMPILER_SUPPORTS_PURECFMA_SCALAR 1) + +# Compiler feature detection + +# Detect CLANG executable path (on both Windows and Linux/OSX) +if(NOT CLANG_EXE_PATH) + # If the current compiler used by CMAKE is already clang, use this one directly + if(CMAKE_C_COMPILER MATCHES "clang") + set(CLANG_EXE_PATH ${CMAKE_C_COMPILER}) + else() + # Else we may find clang on the path? + find_program(CLANG_EXE_PATH NAMES clang "clang-11" "clang-10" "clang-9" "clang-8" "clang-7" "clang-6.0" "clang-5.0" "clang-4.0" "clang-3.9") + endif() +endif() + +# Allow to define the Gcc/Clang here +# As we might compile the lib with MSVC, but generates bitcode with CLANG +# Intel vector extensions. +set(CLANG_FLAGS_ENABLE_SSE2 "-msse2") +set(CLANG_FLAGS_ENABLE_SSE4 "-msse4.1") +set(CLANG_FLAGS_ENABLE_AVX "-mavx") +set(CLANG_FLAGS_ENABLE_FMA4 "-mfma4") +set(CLANG_FLAGS_ENABLE_AVX2 "-mavx2;-mfma") +set(CLANG_FLAGS_ENABLE_AVX2128 "-mavx2;-mfma") +set(CLANG_FLAGS_ENABLE_AVX512F "-mavx512f") +set(CLANG_FLAGS_ENABLE_AVX512FNOFMA "-mavx512f") +set(CLANG_FLAGS_ENABLE_NEON32 "--target=arm-linux-gnueabihf;-mcpu=cortex-a8") +set(CLANG_FLAGS_ENABLE_NEON32VFPV4 "-march=armv7-a;-mfpu=neon-vfpv4") +# Arm AArch64 vector extensions. +set(CLANG_FLAGS_ENABLE_SVE "-march=armv8-a+sve") +set(CLANG_FLAGS_ENABLE_SVENOFMA "-march=armv8-a+sve") +# PPC64 +set(CLANG_FLAGS_ENABLE_VSX "-mcpu=power8") +set(CLANG_FLAGS_ENABLE_VSXNOFMA "-mcpu=power8") +set(CLANG_FLAGS_ENABLE_VSX3 "-mcpu=power9") +set(CLANG_FLAGS_ENABLE_VSX3NOFMA "-mcpu=power9") +# IBM z +set(CLANG_FLAGS_ENABLE_VXE "-march=z14;-mzvector") +set(CLANG_FLAGS_ENABLE_VXENOFMA "-march=z14;-mzvector") +set(CLANG_FLAGS_ENABLE_VXE2 "-march=z15;-mzvector") +set(CLANG_FLAGS_ENABLE_VXE2NOFMA "-march=z15;-mzvector") +# RISC-V +set(CLANG_FLAGS_ENABLE_RVVM1 "-march=rv64gcv_zba_zbb_zbs") +set(CLANG_FLAGS_ENABLE_RVVM1NOFMA "-march=rv64gcv_zba_zbb_zbs") +set(CLANG_FLAGS_ENABLE_RVVM2 "-march=rv64gcv_zba_zbb_zbs") +set(CLANG_FLAGS_ENABLE_RVVM2NOFMA "-march=rv64gcv_zba_zbb_zbs") + +set(FLAGS_OTHERS "") + +# All variables storing compiler flags should be prefixed with FLAGS_ +if(CMAKE_C_COMPILER_ID MATCHES "(GNU|Clang)") + # Always compile sleef with -ffp-contract. + set(FLAGS_STRICTMATH "-ffp-contract=off") + set(FLAGS_FASTMATH "-ffast-math") + set(FLAGS_NOSTRICTALIASING "-fno-strict-aliasing") + + if (SLEEF_ARCH_X86 AND SLEEF_ARCH_32BIT) + string(CONCAT FLAGS_STRICTMATH ${FLAGS_STRICTMATH} " -msse2 -mfpmath=sse") + string(CONCAT FLAGS_FASTMATH ${FLAGS_FASTMATH} " -msse2 -mfpmath=sse") + endif() + + # Without the options below, gcc generates calls to libm + string(CONCAT FLAGS_OTHERS "-fno-math-errno -fno-trapping-math") + + # Intel vector extensions. + foreach(SIMD ${SLEEF_ALL_SUPPORTED_EXTENSIONS}) + set(FLAGS_ENABLE_${SIMD} ${CLANG_FLAGS_ENABLE_${SIMD}}) + endforeach() + + # Warning flags. + set(FLAGS_WALL "-Wall -Wno-unused-function -Wno-attributes -Wno-unused-result") + if(CMAKE_C_COMPILER_ID MATCHES "GNU") + # The following compiler option is needed to suppress the warning + # "AVX vector return without AVX enabled changes the ABI" at + # src/arch/helpervecext.h:88 + string(CONCAT FLAGS_WALL ${FLAGS_WALL} " -Wno-psabi") + set(FLAGS_ENABLE_NEON32 "-mfpu=neon") + endif(CMAKE_C_COMPILER_ID MATCHES "GNU") + + if(CMAKE_C_COMPILER_ID MATCHES "Clang" AND SLEEF_ENABLE_LTO) + if (NOT SLEEF_LLVM_AR_COMMAND) + find_program(SLEEF_LLVM_AR_COMMAND "llvm-ar") + endif() + if (SLEEF_LLVM_AR_COMMAND) + SET(CMAKE_AR ${SLEEF_LLVM_AR_COMMAND}) + SET(CMAKE_C_ARCHIVE_CREATE " rcs ") + SET(CMAKE_C_ARCHIVE_FINISH "true") + endif(SLEEF_LLVM_AR_COMMAND) + string(CONCAT FLAGS_OTHERS "-flto=thin") + endif(CMAKE_C_COMPILER_ID MATCHES "Clang" AND SLEEF_ENABLE_LTO) + + # Flags for generating inline headers + set(FLAG_PREPROCESS "-E") + set(FLAG_PRESERVE_COMMENTS "-C") + set(FLAG_INCLUDE "-I") + set(FLAG_DEFINE "-D") + + if (SLEEF_CLANG_ON_WINDOWS) + # The following line is required to prevent clang from displaying + # many warnings. Clang on Windows references MSVC header files, + # which have deprecation and security attributes for many + # functions. + + string(CONCAT FLAGS_WALL ${FLAGS_WALL} " -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -Wno-deprecated-declarations") + endif() +elseif(MSVC) + # Intel vector extensions. + if (CMAKE_CL_64) + set(FLAGS_ENABLE_SSE2 /D__SSE2__) + set(FLAGS_ENABLE_SSE4 /D__SSE2__ /D__SSE3__ /D__SSE4_1__) + else() + set(FLAGS_ENABLE_SSE2 /D__SSE2__ /arch:SSE2) + set(FLAGS_ENABLE_SSE4 /D__SSE2__ /D__SSE3__ /D__SSE4_1__ /arch:SSE2) + endif() + set(FLAGS_ENABLE_AVX /D__SSE2__ /D__SSE3__ /D__SSE4_1__ /D__AVX__ /arch:AVX) + set(FLAGS_ENABLE_FMA4 /D__SSE2__ /D__SSE3__ /D__SSE4_1__ /D__AVX__ /D__AVX2__ /D__FMA4__ /arch:AVX2) + set(FLAGS_ENABLE_AVX2 /D__SSE2__ /D__SSE3__ /D__SSE4_1__ /D__AVX__ /D__AVX2__ /arch:AVX2) + set(FLAGS_ENABLE_AVX2128 /D__SSE2__ /D__SSE3__ /D__SSE4_1__ /D__AVX__ /D__AVX2__ /arch:AVX2) + set(FLAGS_ENABLE_AVX512F /D__SSE2__ /D__SSE3__ /D__SSE4_1__ /D__AVX__ /D__AVX2__ /D__AVX512F__ /arch:AVX2) + set(FLAGS_ENABLE_AVX512FNOFMA /D__SSE2__ /D__SSE3__ /D__SSE4_1__ /D__AVX__ /D__AVX2__ /D__AVX512F__ /arch:AVX2) + set(FLAGS_ENABLE_PURECFMA_SCALAR /D__SSE2__ /D__SSE3__ /D__SSE4_1__ /D__AVX__ /D__AVX2__ /arch:AVX2) + set(FLAGS_WALL "/D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_DEPRECATE") + + set(FLAGS_NO_ERRNO "") + + set(FLAG_PREPROCESS "/E") + set(FLAG_PRESERVE_COMMENTS "/C") + set(FLAG_INCLUDE "/I") + set(FLAG_DEFINE "/D") +elseif(CMAKE_C_COMPILER_ID MATCHES "Intel") + set(FLAGS_ENABLE_SSE2 "-msse2") + set(FLAGS_ENABLE_SSE4 "-msse4.1") + set(FLAGS_ENABLE_AVX "-mavx") + set(FLAGS_ENABLE_AVX2 "-march=core-avx2") + set(FLAGS_ENABLE_AVX2128 "-march=core-avx2") + set(FLAGS_ENABLE_AVX512F "-xCOMMON-AVX512") + set(FLAGS_ENABLE_AVX512FNOFMA "-xCOMMON-AVX512") + set(FLAGS_ENABLE_PURECFMA_SCALAR "-march=core-avx2;-fno-strict-aliasing") + set(FLAGS_ENABLE_FMA4 "-msse2") # This is a dummy flag + if(CMAKE_C_COMPILER_ID MATCHES "IntelLLVM") + set(FLAGS_STRICTMATH "-fp-model strict -Qoption,cpp,--extended_float_types") + set(FLAGS_FASTMATH "-fp-model fast -Qoption,cpp,--extended_float_types") + else() + set(FLAGS_STRICTMATH "-fp-model strict -Qoption,cpp,--extended_float_type") + set(FLAGS_FASTMATH "-fp-model fast=2 -Qoption,cpp,--extended_float_type") + endif() + set(FLAGS_NOSTRICTALIASING "-fno-strict-aliasing") + set(FLAGS_WALL "-fmax-errors=3 -Wall -Wno-unused -Wno-attributes") + + set(FLAGS_NO_ERRNO "") + + set(FLAG_PREPROCESS "-E") + set(FLAG_PRESERVE_COMMENTS "-C") + set(FLAG_INCLUDE "-I") + set(FLAG_DEFINE "-D") +endif() + +set(SLEEF_C_FLAGS "${FLAGS_WALL} ${FLAGS_STRICTMATH} ${FLAGS_OTHERS}") +if(CMAKE_C_COMPILER_ID MATCHES "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER 6.99) + set(DFT_C_FLAGS "${FLAGS_WALL} ${FLAGS_NOSTRICTALIASING} ${FLAGS_OTHERS}") +else() + set(DFT_C_FLAGS "${FLAGS_WALL} ${FLAGS_NOSTRICTALIASING} ${FLAGS_FASTMATH} ${FLAGS_OTHERS}") +endif() + +if(CMAKE_C_COMPILER_ID MATCHES "GNU") + set(FLAGS_ENABLE_SVE "${FLAGS_ENABLE_SVE};-fno-tree-vrp") +endif() + +if (CMAKE_SYSTEM_PROCESSOR MATCHES "^i.86$" AND CMAKE_C_COMPILER_ID MATCHES "GNU") + set(SLEEF_C_FLAGS "${SLEEF_C_FLAGS} -msse2 -mfpmath=sse") + set(DFT_C_FLAGS "${DFT_C_FLAGS} -msse2 -mfpmath=sse -m128bit-long-double") +elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^i.86$" AND CMAKE_C_COMPILER_ID MATCHES "Clang") + set(SLEEF_C_FLAGS "${SLEEF_C_FLAGS} -msse2 -mfpmath=sse") + set(DFT_C_FLAGS "${DFT_C_FLAGS} -msse2 -mfpmath=sse") +endif() + +if(CYGWIN OR MINGW) + set(SLEEF_C_FLAGS "${SLEEF_C_FLAGS} -fno-asynchronous-unwind-tables") + set(DFT_C_FLAGS "${DFT_C_FLAGS} -fno-asynchronous-unwind-tables") +endif() + +if(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64" AND CMAKE_C_COMPILER_ID MATCHES "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER 9.3 AND CMAKE_C_COMPILER_VERSION VERSION_LESS 10.2) + set(SLEEF_C_FLAGS "${SLEEF_C_FLAGS} -fno-shrink-wrap -fno-tree-vrp") + set(DFT_C_FLAGS "${DFT_C_FLAGS} -fno-shrink-wrap -fno-tree-vrp") +endif() + +# FEATURE DETECTION + +# Long double + +option(SLEEF_DISABLE_LONG_DOUBLE "Disable long double" OFF) +option(SLEEF_ENFORCE_LONG_DOUBLE "Build fails if long double is not supported by the compiler" OFF) + +if(NOT SLEEF_DISABLE_LONG_DOUBLE) + CHECK_TYPE_SIZE("long double" LD_SIZE) + if(LD_SIZE GREATER "9") + # This is needed to check since internal compiler error occurs with gcc 4.x + CHECK_C_SOURCE_COMPILES(" + typedef long double vlongdouble __attribute__((vector_size(sizeof(long double)*2))); + vlongdouble vcast_vl_l(long double d) { return (vlongdouble) { d, d }; } + int main() { vlongdouble vld = vcast_vl_l(0); + }" COMPILER_SUPPORTS_LONG_DOUBLE) + endif() +else() + message(STATUS "Support for long double disabled by CMake option") +endif() + +if (SLEEF_ENFORCE_LONG_DOUBLE AND NOT COMPILER_SUPPORTS_LONG_DOUBLE) + message(FATAL_ERROR "SLEEF_ENFORCE_LONG_DOUBLE is specified and that feature is disabled or not supported by the compiler") +endif() + +# float128 + +option(SLEEF_DISABLE_FLOAT128 "Disable float128" OFF) +option(SLEEF_ENFORCE_FLOAT128 "Build fails if float128 is not supported by the compiler" OFF) + +if(NOT SLEEF_DISABLE_FLOAT128) + CHECK_C_SOURCE_COMPILES(" + int main() { __float128 r = 1; + }" COMPILER_SUPPORTS_FLOAT128) +else() + message(STATUS "Support for float128 disabled by CMake option") +endif() + +if (SLEEF_ENFORCE_FLOAT128 AND NOT COMPILER_SUPPORTS_FLOAT128) + message(FATAL_ERROR "SLEEF_ENFORCE_FLOAT128 is specified and that feature is disabled or not supported by the compiler") +endif() + +if(COMPILER_SUPPORTS_FLOAT128) + CHECK_C_SOURCE_COMPILES(" + #include + int main() { __float128 r = 1; + }" COMPILER_SUPPORTS_QUADMATH) +endif() + +# SSE2 + +option(SLEEF_DISABLE_SSE2 "Disable SSE2" OFF) +option(SLEEF_ENFORCE_SSE2 "Build fails if SSE2 is not supported by the compiler" OFF) + +if(SLEEF_ARCH_X86 AND NOT SLEEF_DISABLE_SSE2) + string (REPLACE ";" " " CMAKE_REQUIRED_FLAGS "${FLAGS_ENABLE_SSE2}") + CHECK_C_SOURCE_COMPILES(" + #if defined(_MSC_VER) + #include + #else + #include + #endif + int main() { + __m128d r = _mm_mul_pd(_mm_set1_pd(1), _mm_set1_pd(2)); }" + COMPILER_SUPPORTS_SSE2) +endif() + +if (SLEEF_ENFORCE_SSE2 AND NOT COMPILER_SUPPORTS_SSE2) + message(FATAL_ERROR "SLEEF_ENFORCE_SSE2 is specified and that feature is disabled or not supported by the compiler") +endif() + +# SSE 4.1 + +option(SLEEF_DISABLE_SSE4 "Disable SSE4" OFF) +option(SLEEF_ENFORCE_SSE4 "Build fails if SSE4 is not supported by the compiler" OFF) + +if(SLEEF_ARCH_X86 AND NOT SLEEF_DISABLE_SSE4) + string (REPLACE ";" " " CMAKE_REQUIRED_FLAGS "${FLAGS_ENABLE_SSE4}") + CHECK_C_SOURCE_COMPILES(" + #if defined(_MSC_VER) + #include + #else + #include + #endif + int main() { + __m128d r = _mm_floor_sd(_mm_set1_pd(1), _mm_set1_pd(2)); }" + COMPILER_SUPPORTS_SSE4) +endif() + +if (SLEEF_ENFORCE_SSE4 AND NOT COMPILER_SUPPORTS_SSE4) + message(FATAL_ERROR "SLEEF_ENFORCE_SSE4 is specified and that feature is disabled or not supported by the compiler") +endif() + +# AVX + +option(SLEEF_ENFORCE_AVX "Disable AVX" OFF) +option(SLEEF_ENFORCE_AVX "Build fails if AVX is not supported by the compiler" OFF) + +if(SLEEF_ARCH_X86 AND NOT SLEEF_DISABLE_AVX) + string (REPLACE ";" " " CMAKE_REQUIRED_FLAGS "${FLAGS_ENABLE_AVX}") + CHECK_C_SOURCE_COMPILES(" + #if defined(_MSC_VER) + #include + #else + #include + #endif + int main() { + __m256d r = _mm256_add_pd(_mm256_set1_pd(1), _mm256_set1_pd(2)); + }" COMPILER_SUPPORTS_AVX) +endif() + +if (SLEEF_ENFORCE_AVX AND NOT COMPILER_SUPPORTS_AVX) + message(FATAL_ERROR "SLEEF_ENFORCE_AVX is specified and that feature is disabled or not supported by the compiler") +endif() + +# FMA4 + +option(SLEEF_DISABLE_FMA4 "Disable FMA4" OFF) +option(SLEEF_ENFORCE_FMA4 "Build fails if FMA4 is not supported by the compiler" OFF) + +if(SLEEF_ARCH_X86 AND NOT SLEEF_DISABLE_FMA4) + string (REPLACE ";" " " CMAKE_REQUIRED_FLAGS "${FLAGS_ENABLE_FMA4}") + CHECK_C_SOURCE_COMPILES(" + #if defined(_MSC_VER) + #include + #else + #include + #endif + int main() { + __m256d r = _mm256_macc_pd(_mm256_set1_pd(1), _mm256_set1_pd(2), _mm256_set1_pd(3)); }" + COMPILER_SUPPORTS_FMA4) +endif() + +if (SLEEF_ENFORCE_FMA4 AND NOT COMPILER_SUPPORTS_FMA4) + message(FATAL_ERROR "SLEEF_ENFORCE_FMA4 is specified and that feature is disabled or not supported by the compiler") +endif() + +# AVX2 + +option(SLEEF_DISABLE_AVX2 "Disable AVX2" OFF) +option(SLEEF_ENFORCE_AVX2 "Build fails if AVX2 is not supported by the compiler" OFF) + +if(SLEEF_ARCH_X86 AND NOT SLEEF_DISABLE_AVX2) + string (REPLACE ";" " " CMAKE_REQUIRED_FLAGS "${FLAGS_ENABLE_AVX2}") + CHECK_C_SOURCE_COMPILES(" + #if defined(_MSC_VER) + #include + #else + #include + #endif + int main() { + __m256i r = _mm256_abs_epi32(_mm256_set1_epi32(1)); }" + COMPILER_SUPPORTS_AVX2) + + # AVX2 implies AVX2128 + if(COMPILER_SUPPORTS_AVX2) + set(COMPILER_SUPPORTS_AVX2128 1) + endif() +endif() + +if (SLEEF_ENFORCE_AVX2 AND NOT COMPILER_SUPPORTS_AVX2) + message(FATAL_ERROR "SLEEF_ENFORCE_AVX2 is specified and that feature is disabled or not supported by the compiler") +endif() + +# AVX512F + +option(SLEEF_DISABLE_AVX512F "Disable AVX512F" OFF) +option(SLEEF_ENFORCE_AVX512F "Build fails if AVX512F is not supported by the compiler" OFF) + +if(SLEEF_ARCH_X86 AND NOT SLEEF_DISABLE_AVX512F) + string (REPLACE ";" " " CMAKE_REQUIRED_FLAGS "${FLAGS_ENABLE_AVX512F}") + CHECK_C_SOURCE_COMPILES(" + #if defined(_MSC_VER) + #include + #else + #include + #endif + __m512 addConstant(__m512 arg) { + return _mm512_add_ps(arg, _mm512_set1_ps(1.f)); + } + int main() { + __m512i a = _mm512_set1_epi32(1); + __m256i ymm = _mm512_extracti64x4_epi64(a, 0); + __mmask16 m = _mm512_cmp_epi32_mask(a, a, _MM_CMPINT_EQ); + __m512i r = _mm512_andnot_si512(a, a); }" + COMPILER_SUPPORTS_AVX512F) + + if (COMPILER_SUPPORTS_AVX512F) + set(COMPILER_SUPPORTS_AVX512FNOFMA 1) + endif() +endif() + +if (SLEEF_ENFORCE_AVX512F AND NOT COMPILER_SUPPORTS_AVX512F) + message(FATAL_ERROR "SLEEF_ENFORCE_AVX512F is specified and that feature is disabled or not supported by the compiler") +endif() + +# SVE + +option(SLEEF_DISABLE_SVE "Disable SVE" OFF) +option(SLEEF_ENFORCE_SVE "Build fails if SVE is not supported by the compiler" OFF) + +# Darwin does not support SVE yet (see issue #474), +# therefore we disable SVE on Darwin systems. +if(SLEEF_ARCH_AARCH64 AND NOT SLEEF_DISABLE_SVE AND NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin") + string (REPLACE ";" " " CMAKE_REQUIRED_FLAGS "${FLAGS_ENABLE_SVE}") + CHECK_C_SOURCE_COMPILES(" + #include + int main() { + svint32_t r = svdup_n_s32(1); }" + COMPILER_SUPPORTS_SVE) + + if(COMPILER_SUPPORTS_SVE) + set(COMPILER_SUPPORTS_SVENOFMA 1) + endif() +endif() + +if (SLEEF_ENFORCE_SVE AND NOT COMPILER_SUPPORTS_SVE) + message(FATAL_ERROR "SLEEF_ENFORCE_SVE is specified and that feature is disabled or not supported by the compiler") +endif() + +# VSX + +option(SLEEF_DISABLE_VSX "Disable VSX" OFF) +option(SLEEF_ENFORCE_VSX "Build fails if VSX is not supported by the compiler" OFF) + +if(SLEEF_ARCH_PPC64 AND NOT SLEEF_DISABLE_VSX) + string (REPLACE ";" " " CMAKE_REQUIRED_FLAGS "${FLAGS_ENABLE_VSX}") + CHECK_C_SOURCE_COMPILES(" + #include + #ifndef __LITTLE_ENDIAN__ + #error \"Only VSX(ISA2.07) little-endian mode is supported \" + #endif + int main() { + vector double d; + vector unsigned char p = { + 4, 5, 6, 7, 0, 1, 2, 3, 12, 13, 14, 15, 8, 9, 10, 11 + }; + d = vec_perm(d, d, p); + }" + COMPILER_SUPPORTS_VSX) + + if (COMPILER_SUPPORTS_VSX) + set(COMPILER_SUPPORTS_VSXNOFMA 1) + endif() +endif() + +if (SLEEF_ENFORCE_VSX AND NOT COMPILER_SUPPORTS_VSX) + message(FATAL_ERROR "SLEEF_ENFORCE_VSX is specified and that feature is disabled or not supported by the compiler") +endif() + +# VSX3 + +option(SLEEF_DISABLE_VSX3 "Disable VSX3" OFF) +option(SLEEF_ENFORCE_VSX3 "Build fails if VSX3 is not supported by the compiler" OFF) + +if(SLEEF_ARCH_PPC64 AND NOT SLEEF_DISABLE_VSX3) + string (REPLACE ";" " " CMAKE_REQUIRED_FLAGS "${FLAGS_ENABLE_VSX3}") + CHECK_C_SOURCE_COMPILES(" + #include + #ifndef __LITTLE_ENDIAN__ + #error \"Only VSX3 little-endian mode is supported \" + #endif + int main() { + static vector double d; + static vector unsigned long long a, b; + + d = vec_insert_exp(a, b); + }" + COMPILER_SUPPORTS_VSX3) + + if (COMPILER_SUPPORTS_VSX3) + set(COMPILER_SUPPORTS_VSX3NOFMA 1) + endif() +endif() + +if (SLEEF_ENFORCE_VSX3 AND NOT COMPILER_SUPPORTS_VSX3) + message(FATAL_ERROR "SLEEF_ENFORCE_VSX3 is specified and that feature is disabled or not supported by the compiler") +endif() + +# IBM Z + +option(SLEEF_DISABLE_VXE "Disable VXE" OFF) +option(SLEEF_ENFORCE_VXE "Build fails if VXE is not supported by the compiler" OFF) + +if(SLEEF_ARCH_S390X AND NOT SLEEF_DISABLE_VXE) + string (REPLACE ";" " " CMAKE_REQUIRED_FLAGS "${FLAGS_ENABLE_VXE}") + CHECK_C_SOURCE_COMPILES(" + #include + int main() { + __vector float d; + d = vec_sqrt(d); + }" + COMPILER_SUPPORTS_VXE) + + if(COMPILER_SUPPORTS_VXE) + set(COMPILER_SUPPORTS_VXENOFMA 1) + endif() +endif() + +if (SLEEF_ENFORCE_VXE AND NOT COMPILER_SUPPORTS_VXE) + message(FATAL_ERROR "SLEEF_ENFORCE_VXE is specified and that feature is disabled or not supported by the compiler") +endif() + +# + +option(SLEEF_DISABLE_VXE2 "Disable VXE2" OFF) +option(SLEEF_ENFORCE_VXE2 "Build fails if VXE2 is not supported by the compiler" OFF) + +if(SLEEF_ARCH_S390X AND NOT SLEEF_DISABLE_VXE2) + string (REPLACE ";" " " CMAKE_REQUIRED_FLAGS "${FLAGS_ENABLE_VXE2}") + CHECK_C_SOURCE_COMPILES(" + #include + int main() { + __vector float d; + d = vec_sqrt(d); + }" + COMPILER_SUPPORTS_VXE2) + + if(COMPILER_SUPPORTS_VXE2) + set(COMPILER_SUPPORTS_VXE2NOFMA 1) + endif() +endif() + +if (SLEEF_ENFORCE_VXE2 AND NOT COMPILER_SUPPORTS_VXE2) + message(FATAL_ERROR "SLEEF_ENFORCE_VXE2 is specified and that feature is disabled or not supported by the compiler") +endif() + +# RVVM1 + +option(SLEEF_DISABLE_RVVM1 "Disable RVVM1" OFF) +option(SLEEF_ENFORCE_RVVM1 "Build fails if RVVM1 is not supported by the compiler" OFF) + +if(SLEEF_ARCH_RISCV64 AND NOT SLEEF_DISABLE_RVVM1) + string (REPLACE ";" " " CMAKE_REQUIRED_FLAGS "${FLAGS_ENABLE_RVVM1}") + CHECK_C_SOURCE_COMPILES(" + #include + int main() { + vint32m1_t r = __riscv_vmv_v_x_i32m1(1, __riscv_vlenb() * 8 / 32); }" + COMPILER_SUPPORTS_RVVM1) + + if(COMPILER_SUPPORTS_RVVM1) + set(COMPILER_SUPPORTS_RVVM1NOFMA 1) + endif() +endif() + +if (SLEEF_ENFORCE_RVVM1 AND NOT COMPILER_SUPPORTS_RVVM1) + message(FATAL_ERROR "SLEEF_ENFORCE_RVVM1 is specified and that feature is disabled or not supported by the compiler") +endif() + +# RVVM2 + +option(SLEEF_DISABLE_RVVM2 "Disable RVVM2" OFF) +option(SLEEF_ENFORCE_RVVM2 "Build fails if RVVM2 is not supported by the compiler" OFF) + +if(SLEEF_ARCH_RISCV64 AND NOT SLEEF_DISABLE_RVVM2) + string (REPLACE ";" " " CMAKE_REQUIRED_FLAGS "${FLAGS_ENABLE_RVVM2}") + CHECK_C_SOURCE_COMPILES(" + #include + int main() { + vint32m2_t r = __riscv_vmv_v_x_i32m2(1, 2 * __riscv_vlenb() * 8 / 32); }" + COMPILER_SUPPORTS_RVVM2) + + if(COMPILER_SUPPORTS_RVVM2) + set(COMPILER_SUPPORTS_RVVM2NOFMA 1) + endif() +endif() + +if (SLEEF_ENFORCE_RVVM2 AND NOT COMPILER_SUPPORTS_RVVM2) + message(FATAL_ERROR "SLEEF_ENFORCE_RVVM2 is specified and that feature is disabled or not supported by the compiler") +endif() + +# CUDA + +option(SLEEF_ENFORCE_CUDA "Build fails if CUDA is not supported" OFF) + +if (SLEEF_ENFORCE_CUDA AND NOT CMAKE_CUDA_COMPILER) + message(FATAL_ERROR "SLEEF_ENFORCE_CUDA is specified and that feature is disabled or not supported by the compiler") +endif() + +# OpenMP + +option(SLEEF_DISABLE_OPENMP "Disable OPENMP" OFF) +option(SLEEF_ENFORCE_OPENMP "Build fails if OPENMP is not supported by the compiler" OFF) + +if(NOT SLEEF_DISABLE_OPENMP) + find_package(OpenMP) + # Check if compilation with OpenMP really succeeds + # It might not succeed even though find_package(OpenMP) succeeds. + if(OPENMP_FOUND) + set (CMAKE_REQUIRED_FLAGS "${OpenMP_C_FLAGS}") + CHECK_C_SOURCE_COMPILES(" + #include + int main() { + int i; + #pragma omp parallel for + for(i=0;i < 10;i++) { putchar(0); } + }" + COMPILER_SUPPORTS_OPENMP) + + CHECK_C_SOURCE_COMPILES(" + #pragma omp declare simd notinbranch + double func(double x) { return x + 1; } + double a[1024]; + int main() { + #pragma omp parallel for simd + for (int i = 0; i < 1024; i++) a[i] = func(a[i]); + } + " + COMPILER_SUPPORTS_OMP_SIMD) + endif(OPENMP_FOUND) +else() + message(STATUS "Support for OpenMP disabled by CMake option") +endif() + +if (SLEEF_ENFORCE_OPENMP AND NOT COMPILER_SUPPORTS_OPENMP) + message(FATAL_ERROR "SLEEF_ENFORCE_OPENMP is specified and that feature is disabled or not supported by the compiler") +endif() + +# Weak aliases + +CHECK_C_SOURCE_COMPILES(" +#if defined(__CYGWIN__) +#define EXPORT __stdcall __declspec(dllexport) +#else +#define EXPORT +#endif + EXPORT int f(int a) { + return a + 2; + } + EXPORT int g(int a) __attribute__((weak, alias(\"f\"))); + int main(void) { + return g(2); + }" + COMPILER_SUPPORTS_WEAK_ALIASES) +if (COMPILER_SUPPORTS_WEAK_ALIASES AND + NOT CMAKE_SYSTEM_PROCESSOR MATCHES "arm" AND + NOT CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)64" AND + NOT SLEEF_CLANG_ON_WINDOWS AND + NOT MINGW AND SLEEF_BUILD_GNUABI_LIBS) + set(ENABLE_GNUABI ${COMPILER_SUPPORTS_WEAK_ALIASES}) +endif() + +# Built-in math functions + +CHECK_C_SOURCE_COMPILES(" + int main(void) { + double a = __builtin_sqrt (2); + float b = __builtin_sqrtf(2); + }" + COMPILER_SUPPORTS_BUILTIN_MATH) + +# SYS_getrandom + +CHECK_C_SOURCE_COMPILES(" +#define _GNU_SOURCE +#include +#include +#include + int main(void) { + int i; + syscall(SYS_getrandom, &i, sizeof(i), 0); + }" + COMPILER_SUPPORTS_SYS_GETRANDOM) + +# + +# Reset used flags +set(CMAKE_REQUIRED_FLAGS) +set(CMAKE_REQUIRED_LIBRARIES) + +# Save the default C flags +set(ORG_CMAKE_C_FLAGS ${CMAKE_C_FLAGS}) + +## + +# Check if sde64 command is available + +find_program(SDE_COMMAND sde64) +if (NOT SDE_COMMAND) + find_program(SDE_COMMAND sde) +endif() + +# Check if armie command is available + +find_program(ARMIE_COMMAND armie) +if (NOT SVE_VECTOR_BITS) + set(SVE_VECTOR_BITS 128) +endif() + +# + +find_program(FILECHECK_COMMAND NAMES FileCheck FileCheck-11 FileCheck-10 FileCheck-9) + +# + +find_program(SED_COMMAND sed) + +## + +if(SLEEF_SHOW_ERROR_LOG) + if (EXISTS ${PROJECT_BINARY_DIR}/CMakeFiles/CMakeError.log) + file(READ ${PROJECT_BINARY_DIR}/CMakeFiles/CMakeError.log FILE_CONTENT) + message("") + message("") + message("====== Content of CMakeError.log ======") + message("") + message("${FILE_CONTENT}") + message("") + message("======== End of CMakeError.log ========") + message("") + message("") + endif() +endif(SLEEF_SHOW_ERROR_LOG) + +if (MSVC OR SLEEF_CLANG_ON_WINDOWS) + set(COMPILER_SUPPORTS_OPENMP FALSE) # At this time, OpenMP is not supported on MSVC +endif() + +## + +# Set common definitions + +if (NOT BUILD_SHARED_LIBS) + set(COMMON_TARGET_DEFINITIONS SLEEF_STATIC_LIBS=1) + set(SLEEF_STATIC_LIBS 1) +endif() + +if (COMPILER_SUPPORTS_WEAK_ALIASES) + set(COMMON_TARGET_DEFINITIONS ${COMMON_TARGET_DEFINITIONS} ENABLE_ALIAS=1) +endif() + +if (COMPILER_SUPPORTS_SYS_GETRANDOM) + set(COMMON_TARGET_DEFINITIONS ${COMMON_TARGET_DEFINITIONS} ENABLE_SYS_getrandom=1) +endif() diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/LICENSE.txt b/src/jdk.incubator.vector/linux/native/libsleef/upstream/LICENSE.txt new file mode 100644 index 00000000000..36b7cd93cdf --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/LICENSE.txt @@ -0,0 +1,23 @@ +Boost Software License - Version 1.0 - August 17th, 2003 + +Permission is hereby granted, free of charge, to any person or organization +obtaining a copy of the software and accompanying documentation covered by +this license (the "Software") to use, reproduce, display, distribute, +execute, and transmit the Software, and to prepare derivative works of the +Software, and to permit third-parties to whom the Software is furnished to +do so, all subject to the following: + +The copyright notices in the Software and this entire statement, including +the above license grant, this restriction and the following disclaimer, +must be included in all copies of the Software, in whole or in part, and +all derivative works of the Software, unless such copies or derivative +works are solely in the form of machine-executable object code generated by +a source language processor. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/README.md b/src/jdk.incubator.vector/linux/native/libsleef/upstream/README.md new file mode 100644 index 00000000000..5ba06531d89 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/README.md @@ -0,0 +1,221 @@ +# SLEEF + +![Github Actions](https://github.com/shibatch/sleef/actions/workflows/build_and_test.yml/badge.svg?event=push&branch=master) +[![DOI:10.1109/TPDS.2019.2960333](http://img.shields.io/badge/DOI-10.1109/TPDS.2019.2960333-blue.svg)](https://ieeexplore.ieee.org/document/8936472) +[![License](https://img.shields.io/badge/License-Boost_1.0-lightblue.svg)](https://www.boost.org/LICENSE_1_0.txt) +![CMake](https://img.shields.io/badge/cmake-v3.18+-yellow.svg) +[![Spack](https://img.shields.io/spack/v/sleef)](https://spack.readthedocs.io/en/v0.16.2/package_list.html#sleef) +[![SourceForge Downloads](https://img.shields.io/sourceforge/dt/sleef)](https://sourceforge.net/projects/sleef/) + +SLEEF is a library that implements vectorized versions of C standard math functions. This library also includes DFT subroutines. + +- **Web Page:** [https://sleef.org/][webpage_url] +- **Sources:** [https://github.com/shibatch/sleef][repo_url] + +## Supported environment + +### Test matrix + +The following table summarises currently supported vector extensions, compilers and OS-es. + +:green_circle: : Tested extensively in CI. + +:yellow_circle: : Tested partially in CI. + +:x: : Currently failing some tests in CI. + +:white_circle: : Not tested in CI. Might have passed tests in previous CI framework. + +[This issue](https://github.com/shibatch/sleef/issues/481) tracks progress on improving test coverage. +Compilation of SLEEF on previously supported environments might still be safe, we just cannot verify it yet. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
                  OS/Compiler
                  LinuxmacOSWindows
                  Arch.Vector Extensionsgccllvmiccgccllvmgccllvm-gnullvm-msvcmsvc
                  x86_64SSE2, SSE4,
                  AVX, AVX2, AVX512F
                  :green_circle::green_circle::white_circle::white_circle::green_circle::white_circle::yellow_circle::white_circle::white_circle:
                  x86 32bit
                  (i386)
                  SSE:white_circle::white_circle::white_circle:N/A:white_circle::white_circle::white_circle::white_circle:
                  AArch64
                  (arm)
                  Neon, SVE:green_circle::green_circle:N/AN/A:green_circle:N/A:white_circle::white_circle::white_circle:
                  AArch32
                  (armhf)
                  NEON:green_circle::green_circle:N/AN/AN/A
                  PowerPC
                  (ppc64el)
                  VSX, VSX3:green_circle::green_circle:N/AN/AN/A
                  IBM/Z
                  (s390x)
                  VXE, VXE2:green_circle::green_circle:N/AN/AN/A
                  RISC-V
                  (riscv64)
                  RVV1, RVV2N/A (14+):green_circle:N/AN/AN/A
                  + +### Component support + +The above table is valid for libm in single, double and quadruple precision, as well as fast Discrete Fourier Transform (DFT). + +Generation of inline headers is also supported for most vector extensions. + +LTO is not tested in CI yet, except on Windows. + +### Compiler support + +Results are displayed for gcc 11 and llvm 17, the compiler versions used in CI tests with GitHub Actions. + +Older versions should be supported too, while newer ones are either not tested or have known issues. + +Some compiler versions simply do not support certain vector extensions, for instance SVE is only supported for gcc version 9 onwards. + +Similarly, the RISC-V interface in SLEEF is based on version 1.0 of the intrinsics, which is only supported from llvm version 17 and gcc version 14 onwards. + +Toolchain files provide some information on supported compiler versions. + +### OS support + +Only Linux distributions and macOS are fully tested in CI and thus officially supported. + +Building SLEEF for Windows on x86 machines was officially supported ( :white_circle: ), as of 3.5.1, +however it is only partially tested due to [known limitations of the test suite with MinGW or MSYS2](https://github.com/shibatch/sleef/issues/544). +As a result tests for Windows on x86 only include DFT for now (other tests are disabled in build system), +but all components are built. + +Support for iOS and Android is only preliminary on AArch64. + +SVE is not supported on Darwin-based system and therefore automatically disabled by SLEEF on Darwin. + +### More on supported environment + +Refer to our web page for [more on supported environment][supported_env_url]. + +## Install SLEEF dependencies + +The library itself does not have any additional dependency. + +However some tests require: + +- libssl and libcrypto, that can be provided by installing openssl. +- libm, libgmp and libmpfr +- libfftw. + +These tests can be disabled if necessary. + +## How to build SLEEF + +We recommend relying on CMake as much as possible in the build process to ensure portability. +**CMake 3.18+** is the minimum required. + +1. Check out the source code from our GitHub repository + +``` +git clone https://github.com/shibatch/sleef +``` + +2. Make a separate directory to create an out-of-source build + +``` +cd sleef && mkdir build +``` + +3. Run cmake to configure the project + +``` +cmake -S . -B build +``` + +By default this will generate shared libraries. In order to generate static libraries, pass option `-DBUILD_SHARED_LIBS=OFF`. + +For more verbose output add option `-DSLEEF_SHOW_CONFIG=ON`. + +4. Run make to build the project + +``` +cmake --build build -j --clean-first +``` + +5. Run tests using ctests + +``` +ctest --test-dir build -j +``` + +For more detailed build instructions please refer to the [dedicated section on CMake](./docs/build-with-cmake.md) or to [our web page][build_info_url]. + +## Install SLEEF + +### From source + +Assuming following instructions were followed. + +6. Install to specified directory `` + +``` +cmake --install build --prefix= +``` + +### Using Spack + +SLEEF can also be directly installed using Spack. + +``` +spack install sleef@master +``` + +### Uninstall + +In order to uninstall SLEEF library and headers run + +``` +sudo xargs rm -v < build/install_manifest.txt +``` + +## License + +The software is distributed under the Boost Software License, Version 1.0. +See accompanying file [LICENSE.txt](./LICENSE.txt) or copy at [http://www.boost.org/LICENSE_1_0.txt][license_url]. +Contributions to this project are accepted under the same license. + +Copyright © 2010-2024 SLEEF Project, Naoki Shibata and contributors.
                  + + + + +[webpage_url]: https://sleef.org/ +[build_info_url]: https://sleef.org/compile.xhtml +[supported_env_url]: https://sleef.org/index.xhtml#environment +[repo_url]: https://github.com/shibatch/sleef +[repo_license_url]: https://github.com/shibatch/sleef/blob/main/LICENSE.txt +[license_url]: http://www.boost.org/LICENSE_1_0.txt diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/include/sleefdft.h b/src/jdk.incubator.vector/linux/native/libsleef/upstream/include/sleefdft.h new file mode 100644 index 00000000000..447131cd16d --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/include/sleefdft.h @@ -0,0 +1,71 @@ +#ifndef __SLEEFDFT_H__ +#define __SLEEFDFT_H__ + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include +#include + +#define SLEEF_MODE_FORWARD (0 << 0) +#define SLEEF_MODE_BACKWARD (1 << 0) + +#define SLEEF_MODE_COMPLEX (0 << 1) +#define SLEEF_MODE_REAL (1 << 1) + +#define SLEEF_MODE_ALT (1 << 2) +#define SLEEF_MODE_FFTWCOMPAT (1 << 3) + +#define SLEEF_MODE_DEBUG (1 << 10) +#define SLEEF_MODE_VERBOSE (1 << 11) +#define SLEEF_MODE_NO_MT (1 << 12) + +#define SLEEF_MODE_ESTIMATE (1 << 20) +#define SLEEF_MODE_MEASURE (2 << 20) + +#if (defined(__MINGW32__) || defined(__MINGW64__) || defined(__CYGWIN__) || defined(_MSC_VER)) && !defined(SLEEF_STATIC_LIBS) +#ifdef IMPORT_IS_EXPORT +#define IMPORT __declspec(dllexport) +#else // #ifdef IMPORT_IS_EXPORT +#define IMPORT __declspec(dllimport) +#if (defined(_MSC_VER)) +#pragma comment(lib,"sleefdft.lib") +#endif // #if (defined(_MSC_VER)) +#endif // #ifdef IMPORT_IS_EXPORT +#else // #if (defined(__MINGW32__) || defined(__MINGW64__) || defined(__CYGWIN__) || defined(_MSC_VER)) && !defined(SLEEF_STATIC_LIBS) +#define IMPORT +#endif // #if (defined(__MINGW32__) || defined(__MINGW64__) || defined(__CYGWIN__) || defined(_MSC_VER)) && !defined(SLEEF_STATIC_LIBS) + +IMPORT struct SleefDFT *SleefDFT_double_init1d(uint32_t n, const double *in, double *out, uint64_t mode); +IMPORT struct SleefDFT *SleefDFT_double_init2d(uint32_t n, uint32_t m, const double *in, double *out, uint64_t mode); +IMPORT void SleefDFT_double_execute(struct SleefDFT *ptr, const double *in, double *out); + +IMPORT struct SleefDFT *SleefDFT_float_init1d(uint32_t n, const float *in, float *out, uint64_t mode); +IMPORT struct SleefDFT *SleefDFT_float_init2d(uint32_t n, uint32_t m, const float *in, float *out, uint64_t mode); +IMPORT void SleefDFT_float_execute(struct SleefDFT *ptr, const float *in, float *out); + +IMPORT void SleefDFT_dispose(struct SleefDFT *ptr); + +IMPORT void SleefDFT_setPath(struct SleefDFT *ptr, char *pathStr); + +// + +IMPORT void SleefDFT_setPlanFilePath(const char *path, const char *arch, uint64_t mode); + +#define SLEEF_PLAN_AUTOMATIC 0 +#define SLEEF_PLAN_READONLY (1 << 0) +#define SLEEF_PLAN_RESET (1 << 1) +#define SLEEF_PLAN_BUILDALLPLAN (1 << 2) +#define SLEEF_PLAN_NOLOCK (1 << 3) +#define SLEEF_PLAN_MEASURE (1 << 29) +#define SLEEF_PLAN_REFERTOENVVAR (1 << 30) + +#undef IMPORT + +#ifdef __cplusplus +} +#endif + +#endif // #ifndef __SLEEFDFT_H__ diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/sleef-config.h.in b/src/jdk.incubator.vector/linux/native/libsleef/upstream/sleef-config.h.in new file mode 100644 index 00000000000..53faefcf57d --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/sleef-config.h.in @@ -0,0 +1,11 @@ +// Configuration of @PROJECT_NAME@ ///////////////////////////////////////////// + +#ifndef SLEEF_CONFIG_H +#define SLEEF_CONFIG_H + +#define SLEEF_VERSION_MAJOR @SLEEF_VERSION_MAJOR@ +#define SLEEF_VERSION_MINOR @SLEEF_VERSION_MINOR@ + +#cmakedefine SLEEF_STATIC_LIBS + +#endif // SLEEF_CONFIG_H diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/sleefConfig.cmake b/src/jdk.incubator.vector/linux/native/libsleef/upstream/sleefConfig.cmake new file mode 100644 index 00000000000..6e423f21616 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/sleefConfig.cmake @@ -0,0 +1 @@ +include("${CMAKE_CURRENT_LIST_DIR}/sleefTargets.cmake") diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/CMakeLists.txt b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/CMakeLists.txt new file mode 100644 index 00000000000..0e60e5368de --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/CMakeLists.txt @@ -0,0 +1,22 @@ +include_directories("common") +include_directories("arch") + +add_subdirectory("libm") +if (SLEEF_BUILD_TESTS AND NOT MINGW) + add_subdirectory("libm-tester") +endif() +add_subdirectory("common") + +if (SLEEF_BUILD_DFT) + add_subdirectory("dft") + if (SLEEF_BUILD_TESTS) + add_subdirectory("dft-tester") + endif() +endif() + +if (SLEEF_BUILD_QUAD) + add_subdirectory("quad") + if (SLEEF_BUILD_TESTS AND NOT MINGW) + add_subdirectory("quad-tester") + endif() +endif() diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/arch/helperadvsimd.h b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/arch/helperadvsimd.h new file mode 100644 index 00000000000..48908734135 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/arch/helperadvsimd.h @@ -0,0 +1,837 @@ +/*********************************************************************/ +/* Copyright ARM Ltd. 2010 - 2024. */ +/* Distributed under the Boost Software License, Version 1.0. */ +/* (See accompanying file LICENSE.txt or copy at */ +/* http://www.boost.org/LICENSE_1_0.txt) */ +/*********************************************************************/ + +#if !defined(__ARM_NEON) && !defined(SLEEF_GENHEADER) +#error Please specify advsimd flags. +#endif + +#if !defined(SLEEF_GENHEADER) +#include +#include + +#include "misc.h" +#endif // #if !defined(SLEEF_GENHEADER) + +#define ENABLE_DP +//@#define ENABLE_DP +#define LOG2VECTLENDP 1 +//@#define LOG2VECTLENDP 1 +#define VECTLENDP (1 << LOG2VECTLENDP) +//@#define VECTLENDP (1 << LOG2VECTLENDP) + +#define ENABLE_SP +//@#define ENABLE_SP +#define LOG2VECTLENSP 2 +//@#define LOG2VECTLENSP 2 +#define VECTLENSP (1 << LOG2VECTLENSP) +//@#define VECTLENSP (1 << LOG2VECTLENSP) + +#if CONFIG == 1 +#define ENABLE_FMA_DP +//@#define ENABLE_FMA_DP +#define ENABLE_FMA_SP +//@#define ENABLE_FMA_SP +#endif + +#define FULL_FP_ROUNDING +//@#define FULL_FP_ROUNDING +#define ACCURATE_SQRT +//@#define ACCURATE_SQRT + +#define ISANAME "AArch64 AdvSIMD" + +// Mask definition +typedef uint32x4_t vmask; +typedef uint32x4_t vopmask; + +// Single precision definitions +typedef float32x4_t vfloat; +typedef int32x4_t vint2; + +// Double precision definitions +typedef float64x2_t vdouble; +typedef int32x2_t vint; + +typedef int64x2_t vint64; +typedef uint64x2_t vuint64; + +typedef struct { + vmask x, y; +} vquad; + +typedef vquad vargquad; + +#define DFTPRIORITY 10 + +static INLINE int vavailability_i(int name) { return 3; } +static INLINE void vprefetch_v_p(const void *ptr) { } + +static INLINE VECTOR_CC int vtestallones_i_vo32(vopmask g) { + uint32x2_t x0 = vand_u32(vget_low_u32(g), vget_high_u32(g)); + uint32x2_t x1 = vpmin_u32(x0, x0); + return vget_lane_u32(x1, 0); +} + +static INLINE VECTOR_CC int vtestallones_i_vo64(vopmask g) { + uint32x2_t x0 = vand_u32(vget_low_u32(g), vget_high_u32(g)); + uint32x2_t x1 = vpmin_u32(x0, x0); + return vget_lane_u32(x1, 0); +} + +// Vector load / store +static INLINE VECTOR_CC vdouble vload_vd_p(const double *ptr) { return vld1q_f64(ptr); } +static INLINE VECTOR_CC vdouble vloadu_vd_p(const double *ptr) { return vld1q_f64(ptr); } +static INLINE VECTOR_CC void vstore_v_p_vd(double *ptr, vdouble v) { vst1q_f64(ptr, v); } +static INLINE VECTOR_CC void vstoreu_v_p_vd(double *ptr, vdouble v) { vst1q_f64(ptr, v); } +static INLINE VECTOR_CC vfloat vload_vf_p(const float *ptr) { return vld1q_f32(ptr); } +static INLINE VECTOR_CC vfloat vloadu_vf_p(const float *ptr) { return vld1q_f32(ptr); } +static INLINE VECTOR_CC void vstore_v_p_vf(float *ptr, vfloat v) { vst1q_f32(ptr, v); } +static INLINE VECTOR_CC void vstoreu_v_p_vf(float *ptr, vfloat v) { vst1q_f32(ptr, v); } +static INLINE VECTOR_CC vint2 vloadu_vi2_p(int32_t *p) { return vld1q_s32(p); } +static INLINE VECTOR_CC void vstoreu_v_p_vi2(int32_t *p, vint2 v) { vst1q_s32(p, v); } +static INLINE VECTOR_CC vint vloadu_vi_p(int32_t *p) { return vld1_s32(p); } +static INLINE VECTOR_CC void vstoreu_v_p_vi(int32_t *p, vint v) { vst1_s32(p, v); } + +static INLINE VECTOR_CC vdouble vgather_vd_p_vi(const double *ptr, vint vi) { + return ((vdouble) { ptr[vget_lane_s32(vi, 0)], ptr[vget_lane_s32(vi, 1)]} ); +} + +static INLINE VECTOR_CC vfloat vgather_vf_p_vi2(const float *ptr, vint2 vi2) { + return ((vfloat) { + ptr[vgetq_lane_s32(vi2, 0)], + ptr[vgetq_lane_s32(vi2, 1)], + ptr[vgetq_lane_s32(vi2, 2)], + ptr[vgetq_lane_s32(vi2, 3)] + }); +} + +// Basic logical operations for mask +static INLINE VECTOR_CC vmask vand_vm_vm_vm(vmask x, vmask y) { return vandq_u32(x, y); } +static INLINE VECTOR_CC vmask vandnot_vm_vm_vm(vmask x, vmask y) { + return vbicq_u32(y, x); +} +static INLINE VECTOR_CC vmask vor_vm_vm_vm(vmask x, vmask y) { return vorrq_u32(x, y); } +static INLINE VECTOR_CC vmask vxor_vm_vm_vm(vmask x, vmask y) { return veorq_u32(x, y); } + +// Mask <--> single precision reinterpret +static INLINE VECTOR_CC vmask vreinterpret_vm_vf(vfloat vf) { + return vreinterpretq_u32_f32(vf); +} +static INLINE VECTOR_CC vfloat vreinterpret_vf_vm(vmask vm) { + return vreinterpretq_f32_u32(vm); +} +static INLINE VECTOR_CC vint2 vcast_vi2_vm(vmask vm) { return vreinterpretq_s32_u32(vm); } +static INLINE VECTOR_CC vmask vcast_vm_vi2(vint2 vi) { return vreinterpretq_u32_s32(vi); } + +// Mask <--> double precision reinterpret +static INLINE VECTOR_CC vmask vreinterpret_vm_vd(vdouble vd) { + return vreinterpretq_u32_f64(vd); +} +static INLINE VECTOR_CC vdouble vreinterpret_vd_vm(vmask vm) { + return vreinterpretq_f64_u32(vm); +} +static INLINE VECTOR_CC vfloat vreinterpret_vf_vi2(vint2 vm) { + return vreinterpretq_f32_s32(vm); +} +static INLINE VECTOR_CC vint2 vreinterpret_vi2_vf(vfloat vf) { + return vreinterpretq_s32_f32(vf); +} + +/****************************************/ +/* Single precision FP operations */ +/****************************************/ +// Broadcast +static INLINE VECTOR_CC vfloat vcast_vf_f(float f) { return vdupq_n_f32(f); } + +// Add, Sub, Mul +static INLINE VECTOR_CC vfloat vadd_vf_vf_vf(vfloat x, vfloat y) { + return vaddq_f32(x, y); +} +static INLINE VECTOR_CC vfloat vsub_vf_vf_vf(vfloat x, vfloat y) { + return vsubq_f32(x, y); +} +static INLINE VECTOR_CC vfloat vmul_vf_vf_vf(vfloat x, vfloat y) { + return vmulq_f32(x, y); +} + +// |x|, -x +static INLINE VECTOR_CC vfloat vabs_vf_vf(vfloat f) { return vabsq_f32(f); } +static INLINE VECTOR_CC vfloat vneg_vf_vf(vfloat f) { return vnegq_f32(f); } + +#if CONFIG == 1 +// Multiply accumulate: z = z + x * y +static INLINE VECTOR_CC vfloat vmla_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { + return vfmaq_f32(z, x, y); +} +// Multiply subtract: z = z - x * y +static INLINE VECTOR_CC vfloat vmlanp_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { + return vfmsq_f32(z, x, y); +} +// Multiply subtract: z = x * y - z +static INLINE VECTOR_CC vfloat vmlapn_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { + return vneg_vf_vf(vfmsq_f32(z, x, y)); +} +#else +static INLINE VECTOR_CC vfloat vmla_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return vadd_vf_vf_vf(vmul_vf_vf_vf(x, y), z); } +static INLINE VECTOR_CC vfloat vmlanp_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return vsub_vf_vf_vf(z, vmul_vf_vf_vf(x, y)); } +static INLINE VECTOR_CC vfloat vmlapn_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return vsub_vf_vf_vf(vmul_vf_vf_vf(x, y), z); } +#endif + +static INLINE VECTOR_CC vfloat vfma_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { // z + x * y + return vfmaq_f32(z, x, y); +} + +static INLINE VECTOR_CC vfloat vfmanp_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { // z - x * y + return vfmsq_f32(z, x, y); +} + +static INLINE VECTOR_CC vfloat vfmapn_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { // x * y - z + return vfma_vf_vf_vf_vf(x, y, vneg_vf_vf(z)); +} + +// Reciprocal 1/x, Division, Square root +static INLINE VECTOR_CC vfloat vdiv_vf_vf_vf(vfloat n, vfloat d) { +#ifndef SLEEF_ENABLE_ALTDIV + return vdivq_f32(n, d); +#else + // Finite numbers (including denormal) only, gives mostly correctly rounded result + float32x4_t t, u, x, y; + uint32x4_t i0, i1; + i0 = vandq_u32(vreinterpretq_u32_f32(n), vdupq_n_u32(0x7c000000)); + i1 = vandq_u32(vreinterpretq_u32_f32(d), vdupq_n_u32(0x7c000000)); + i0 = vsubq_u32(vdupq_n_u32(0x7d000000), vshrq_n_u32(vaddq_u32(i0, i1), 1)); + t = vreinterpretq_f32_u32(i0); + y = vmulq_f32(d, t); + x = vmulq_f32(n, t); + t = vrecpeq_f32(y); + t = vmulq_f32(t, vrecpsq_f32(y, t)); + t = vmulq_f32(t, vrecpsq_f32(y, t)); + u = vmulq_f32(x, t); + u = vfmaq_f32(u, vfmsq_f32(x, y, u), t); + return u; +#endif +} +static INLINE VECTOR_CC vfloat vrec_vf_vf(vfloat d) { +#ifndef SLEEF_ENABLE_ALTDIV + return vdiv_vf_vf_vf(vcast_vf_f(1.0f), d); +#else + return vbslq_f32(vceqq_f32(vabs_vf_vf(d), vcast_vf_f(SLEEF_INFINITYf)), + vcast_vf_f(0), vdiv_vf_vf_vf(vcast_vf_f(1.0f), d)); +#endif +} + +static INLINE VECTOR_CC vfloat vsqrt_vf_vf(vfloat d) { +#ifndef SLEEF_ENABLE_ALTSQRT + return vsqrtq_f32(d); +#else + // Gives correctly rounded result for all input range + vfloat w, x, y, z; + + y = vrsqrteq_f32(d); + x = vmul_vf_vf_vf(d, y); w = vmul_vf_vf_vf(vcast_vf_f(0.5), y); + y = vfmanp_vf_vf_vf_vf(x, w, vcast_vf_f(0.5)); + x = vfma_vf_vf_vf_vf(x, y, x); w = vfma_vf_vf_vf_vf(w, y, w); + + y = vfmanp_vf_vf_vf_vf(x, w, vcast_vf_f(1.5)); w = vadd_vf_vf_vf(w, w); + w = vmul_vf_vf_vf(w, y); + x = vmul_vf_vf_vf(w, d); + y = vfmapn_vf_vf_vf_vf(w, d, x); z = vfmanp_vf_vf_vf_vf(w, x, vcast_vf_f(1)); + z = vfmanp_vf_vf_vf_vf(w, y, z); w = vmul_vf_vf_vf(vcast_vf_f(0.5), x); + w = vfma_vf_vf_vf_vf(w, z, y); + w = vadd_vf_vf_vf(w, x); + + return vbslq_f32(vorrq_u32(vceqq_f32(d, vcast_vf_f(0)), + vceqq_f32(d, vcast_vf_f(SLEEF_INFINITYf))), d, w); +#endif +} + +// max, min +static INLINE VECTOR_CC vfloat vmax_vf_vf_vf(vfloat x, vfloat y) { + return vmaxq_f32(x, y); +} +static INLINE VECTOR_CC vfloat vmin_vf_vf_vf(vfloat x, vfloat y) { + return vminq_f32(x, y); +} + +// Comparisons +static INLINE VECTOR_CC vmask veq_vm_vf_vf(vfloat x, vfloat y) { return vceqq_f32(x, y); } +static INLINE VECTOR_CC vmask vneq_vm_vf_vf(vfloat x, vfloat y) { + return vmvnq_u32(vceqq_f32(x, y)); +} +static INLINE VECTOR_CC vmask vlt_vm_vf_vf(vfloat x, vfloat y) { return vcltq_f32(x, y); } +static INLINE VECTOR_CC vmask vle_vm_vf_vf(vfloat x, vfloat y) { return vcleq_f32(x, y); } +static INLINE VECTOR_CC vmask vgt_vm_vf_vf(vfloat x, vfloat y) { return vcgtq_f32(x, y); } +static INLINE VECTOR_CC vmask vge_vm_vf_vf(vfloat x, vfloat y) { return vcgeq_f32(x, y); } + +// Conditional select +static INLINE VECTOR_CC vfloat vsel_vf_vm_vf_vf(vmask mask, vfloat x, vfloat y) { + return vbslq_f32(mask, x, y); +} + +// int <--> float conversions +static INLINE VECTOR_CC vint2 vtruncate_vi2_vf(vfloat vf) { return vcvtq_s32_f32(vf); } +static INLINE VECTOR_CC vfloat vcast_vf_vi2(vint2 vi) { return vcvtq_f32_s32(vi); } +static INLINE VECTOR_CC vint2 vcast_vi2_i(int i) { return vdupq_n_s32(i); } +static INLINE VECTOR_CC vint2 vrint_vi2_vf(vfloat d) { + return vcvtq_s32_f32(vrndnq_f32(d)); +} + +/***************************************/ +/* Single precision integer operations */ +/***************************************/ + +// Add, Sub, Neg (-x) +static INLINE VECTOR_CC vint2 vadd_vi2_vi2_vi2(vint2 x, vint2 y) { + return vaddq_s32(x, y); +} +static INLINE VECTOR_CC vint2 vsub_vi2_vi2_vi2(vint2 x, vint2 y) { + return vsubq_s32(x, y); +} +static INLINE VECTOR_CC vint2 vneg_vi2_vi2(vint2 e) { return vnegq_s32(e); } + +// Logical operations +static INLINE VECTOR_CC vint2 vand_vi2_vi2_vi2(vint2 x, vint2 y) { + return vandq_s32(x, y); +} +static INLINE VECTOR_CC vint2 vandnot_vi2_vi2_vi2(vint2 x, vint2 y) { + return vbicq_s32(y, x); +} +static INLINE VECTOR_CC vint2 vor_vi2_vi2_vi2(vint2 x, vint2 y) { + return vorrq_s32(x, y); +} +static INLINE VECTOR_CC vint2 vxor_vi2_vi2_vi2(vint2 x, vint2 y) { + return veorq_s32(x, y); +} + +// Shifts +#define vsll_vi2_vi2_i(x, c) vshlq_n_s32(x, c) +//@#define vsll_vi2_vi2_i(x, c) vshlq_n_s32(x, c) +#define vsrl_vi2_vi2_i(x, c) \ + vreinterpretq_s32_u32(vshrq_n_u32(vreinterpretq_u32_s32(x), c)) +//@#define vsrl_vi2_vi2_i(x, c) vreinterpretq_s32_u32(vshrq_n_u32(vreinterpretq_u32_s32(x), c)) + +#define vsra_vi2_vi2_i(x, c) vshrq_n_s32(x, c) +//@#define vsra_vi2_vi2_i(x, c) vshrq_n_s32(x, c) +#define vsra_vi_vi_i(x, c) vshr_n_s32(x, c) +//@#define vsra_vi_vi_i(x, c) vshr_n_s32(x, c) +#define vsll_vi_vi_i(x, c) vshl_n_s32(x, c) +//@#define vsll_vi_vi_i(x, c) vshl_n_s32(x, c) +#define vsrl_vi_vi_i(x, c) \ + vreinterpret_s32_u32(vshr_n_u32(vreinterpret_u32_s32(x), c)) +//@#define vsrl_vi_vi_i(x, c) vreinterpret_s32_u32(vshr_n_u32(vreinterpret_u32_s32(x), c)) + +// Comparison returning masks +static INLINE VECTOR_CC vmask veq_vm_vi2_vi2(vint2 x, vint2 y) { return vceqq_s32(x, y); } +static INLINE VECTOR_CC vmask vgt_vm_vi2_vi2(vint2 x, vint2 y) { return vcgeq_s32(x, y); } +// Comparison returning integers +static INLINE VECTOR_CC vint2 vgt_vi2_vi2_vi2(vint2 x, vint2 y) { + return vreinterpretq_s32_u32(vcgtq_s32(x, y)); +} +static INLINE VECTOR_CC vint2 veq_vi2_vi2_vi2(vint2 x, vint2 y) { + return vreinterpretq_s32_u32(vceqq_s32(x, y)); +} + +// Conditional select +static INLINE VECTOR_CC vint2 vsel_vi2_vm_vi2_vi2(vmask m, vint2 x, vint2 y) { + return vbslq_s32(m, x, y); +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +/****************************************/ +/* Double precision FP operations */ +/****************************************/ +// Broadcast +static INLINE VECTOR_CC vdouble vcast_vd_d(double f) { return vdupq_n_f64(f); } + +// Add, Sub, Mul +static INLINE VECTOR_CC vdouble vadd_vd_vd_vd(vdouble x, vdouble y) { + return vaddq_f64(x, y); +} +static INLINE VECTOR_CC vdouble vsub_vd_vd_vd(vdouble x, vdouble y) { + return vsubq_f64(x, y); +} +static INLINE VECTOR_CC vdouble vmul_vd_vd_vd(vdouble x, vdouble y) { + return vmulq_f64(x, y); +} + +// |x|, -x +static INLINE VECTOR_CC vdouble vabs_vd_vd(vdouble f) { return vabsq_f64(f); } +static INLINE VECTOR_CC vdouble vneg_vd_vd(vdouble f) { return vnegq_f64(f); } + +// max, min +static INLINE VECTOR_CC vdouble vmax_vd_vd_vd(vdouble x, vdouble y) { + return vmaxq_f64(x, y); +} +static INLINE VECTOR_CC vdouble vmin_vd_vd_vd(vdouble x, vdouble y) { + return vminq_f64(x, y); +} + +#if CONFIG == 1 +// Multiply accumulate: z = z + x * y +static INLINE VECTOR_CC vdouble vmla_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { + return vfmaq_f64(z, x, y); +} + +static INLINE VECTOR_CC vdouble vmlanp_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { + return vfmsq_f64(z, x, y); +} + +//[z = x * y - z] +static INLINE VECTOR_CC vdouble vmlapn_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { + return vneg_vd_vd(vfmsq_f64(z, x, y)); +} +#else +static INLINE VECTOR_CC vdouble vmla_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return vadd_vd_vd_vd(vmul_vd_vd_vd(x, y), z); } +static INLINE VECTOR_CC vdouble vmlapn_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return vsub_vd_vd_vd(vmul_vd_vd_vd(x, y), z); } +#endif + +static INLINE VECTOR_CC vdouble vfma_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { // z + x * y + return vfmaq_f64(z, x, y); +} + +static INLINE VECTOR_CC vdouble vfmanp_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { // z - x * y + return vfmsq_f64(z, x, y); +} + +static INLINE VECTOR_CC vdouble vfmapn_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { // x * y - z + return vfma_vd_vd_vd_vd(x, y, vneg_vd_vd(z)); +} + +// Reciprocal 1/x, Division, Square root +static INLINE VECTOR_CC vdouble vdiv_vd_vd_vd(vdouble n, vdouble d) { +#ifndef SLEEF_ENABLE_ALTDIV + return vdivq_f64(n, d); +#else + // Finite numbers (including denormal) only, gives mostly correctly rounded result + float64x2_t t, u, x, y; + uint64x2_t i0, i1; + i0 = vandq_u64(vreinterpretq_u64_f64(n), vdupq_n_u64(0x7fc0000000000000L)); + i1 = vandq_u64(vreinterpretq_u64_f64(d), vdupq_n_u64(0x7fc0000000000000L)); + i0 = vsubq_u64(vdupq_n_u64(0x7fd0000000000000L), vshrq_n_u64(vaddq_u64(i0, i1), 1)); + t = vreinterpretq_f64_u64(i0); + y = vmulq_f64(d, t); + x = vmulq_f64(n, t); + t = vrecpeq_f64(y); + t = vmulq_f64(t, vrecpsq_f64(y, t)); + t = vmulq_f64(t, vrecpsq_f64(y, t)); + t = vmulq_f64(t, vrecpsq_f64(y, t)); + u = vmulq_f64(x, t); + u = vfmaq_f64(u, vfmsq_f64(x, y, u), t); + return u; +#endif +} +static INLINE VECTOR_CC vdouble vrec_vd_vd(vdouble d) { +#ifndef SLEEF_ENABLE_ALTDIV + return vdiv_vd_vd_vd(vcast_vd_d(1.0f), d); +#else + return vbslq_f64(vceqq_f64(vabs_vd_vd(d), vcast_vd_d(SLEEF_INFINITY)), + vcast_vd_d(0), vdiv_vd_vd_vd(vcast_vd_d(1.0f), d)); +#endif +} + +static INLINE VECTOR_CC vdouble vsqrt_vd_vd(vdouble d) { +#ifndef SLEEF_ENABLE_ALTSQRT + return vsqrtq_f64(d); +#else + // Gives correctly rounded result for all input range + vdouble w, x, y, z; + + y = vrsqrteq_f64(d); + x = vmul_vd_vd_vd(d, y); w = vmul_vd_vd_vd(vcast_vd_d(0.5), y); + y = vfmanp_vd_vd_vd_vd(x, w, vcast_vd_d(0.5)); + x = vfma_vd_vd_vd_vd(x, y, x); w = vfma_vd_vd_vd_vd(w, y, w); + y = vfmanp_vd_vd_vd_vd(x, w, vcast_vd_d(0.5)); + x = vfma_vd_vd_vd_vd(x, y, x); w = vfma_vd_vd_vd_vd(w, y, w); + + y = vfmanp_vd_vd_vd_vd(x, w, vcast_vd_d(1.5)); w = vadd_vd_vd_vd(w, w); + w = vmul_vd_vd_vd(w, y); + x = vmul_vd_vd_vd(w, d); + y = vfmapn_vd_vd_vd_vd(w, d, x); z = vfmanp_vd_vd_vd_vd(w, x, vcast_vd_d(1)); + z = vfmanp_vd_vd_vd_vd(w, y, z); w = vmul_vd_vd_vd(vcast_vd_d(0.5), x); + w = vfma_vd_vd_vd_vd(w, z, y); + w = vadd_vd_vd_vd(w, x); + + return vbslq_f64(vorrq_u64(vceqq_f64(d, vcast_vd_d(0)), + vceqq_f64(d, vcast_vd_d(SLEEF_INFINITY))), d, w); +#endif +} + +/* Comparisons */ +static INLINE VECTOR_CC vopmask veq_vo_vd_vd(vdouble x, vdouble y) { + return vreinterpretq_u32_u64(vceqq_f64(x, y)); +} +static INLINE VECTOR_CC vopmask vneq_vo_vd_vd(vdouble x, vdouble y) { + return vmvnq_u32(vreinterpretq_u32_u64(vceqq_f64(x, y))); +} +static INLINE VECTOR_CC vopmask vlt_vo_vd_vd(vdouble x, vdouble y) { + return vreinterpretq_u32_u64(vcltq_f64(x, y)); +} +static INLINE VECTOR_CC vopmask vgt_vo_vd_vd(vdouble x, vdouble y) { + return vreinterpretq_u32_u64(vcgtq_f64(x, y)); +} +static INLINE VECTOR_CC vopmask vle_vo_vd_vd(vdouble x, vdouble y) { + return vreinterpretq_u32_u64(vcleq_f64(x, y)); +} +static INLINE VECTOR_CC vopmask vge_vo_vd_vd(vdouble x, vdouble y) { + return vreinterpretq_u32_u64(vcgeq_f64(x, y)); +} + +// Conditional select +static INLINE VECTOR_CC vdouble vsel_vd_vo_vd_vd(vopmask mask, vdouble x, vdouble y) { + return vbslq_f64(vreinterpretq_u64_u32(mask), x, y); +} + +#if 1 +static INLINE CONST VECTOR_CC vdouble vsel_vd_vo_d_d(vopmask o, double v1, double v0) { + return vsel_vd_vo_vd_vd(o, vcast_vd_d(v1), vcast_vd_d(v0)); +} + +static INLINE VECTOR_CC vdouble vsel_vd_vo_vo_d_d_d(vopmask o0, vopmask o1, double d0, double d1, double d2) { + return vsel_vd_vo_vd_vd(o0, vcast_vd_d(d0), vsel_vd_vo_d_d(o1, d1, d2)); +} + +static INLINE VECTOR_CC vdouble vsel_vd_vo_vo_vo_d_d_d_d(vopmask o0, vopmask o1, vopmask o2, double d0, double d1, double d2, double d3) { + return vsel_vd_vo_vd_vd(o0, vcast_vd_d(d0), vsel_vd_vo_vd_vd(o1, vcast_vd_d(d1), vsel_vd_vo_d_d(o2, d2, d3))); +} +#else +// This implementation is slower on the current CPU models (as of May 2017.) +// I(Naoki Shibata) expect that on future CPU models with hardware similar to Super Shuffle Engine, this implementation will be faster. +static INLINE CONST VECTOR_CC vdouble vsel_vd_vo_d_d(vopmask o, double d0, double d1) { + uint8x16_t idx = vbslq_u8(vreinterpretq_u8_u32(o), (uint8x16_t) { 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7 }, + (uint8x16_t) { 8, 9, 10, 11, 12, 13, 14, 15, 8, 9, 10, 11, 12, 13, 14, 15 }); + + uint8x16_t tab = (uint8x16_t) (float64x2_t) { d0, d1 }; + return (vdouble) vqtbl1q_u8(tab, idx); +} + +static INLINE VECTOR_CC vdouble vsel_vd_vo_vo_vo_d_d_d_d(vopmask o0, vopmask o1, vopmask o2, double d0, double d1, double d2, double d3) { + uint8x16_t idx = vbslq_u8(vreinterpretq_u8_u32(o0), (uint8x16_t) { 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7 }, + vbslq_u8(vreinterpretq_u8_u32(o1), (uint8x16_t) { 8, 9, 10, 11, 12, 13, 14, 15, 8, 9, 10, 11, 12, 13, 14, 15 }, + vbslq_u8(vreinterpretq_u8_u32(o2), (uint8x16_t) { 16, 17, 18, 19, 20, 21, 22, 23, 16, 17, 18, 19, 20, 21, 22, 23 }, + (uint8x16_t) { 24, 25, 26, 27, 28, 29, 30, 31, 24, 25, 26, 27, 28, 29, 30, 31 }))); + + uint8x16x2_t tab = { { (uint8x16_t) (float64x2_t) { d0, d1 }, (uint8x16_t) (float64x2_t) { d2, d3 } } }; + return (vdouble) vqtbl2q_u8(tab, idx); +} + +static INLINE VECTOR_CC vdouble vsel_vd_vo_vo_d_d_d(vopmask o0, vopmask o1, double d0, double d1, double d2) { + return vsel_vd_vo_vo_vo_d_d_d_d(o0, o1, o1, d0, d1, d2, d2); +} +#endif + +static INLINE VECTOR_CC vdouble vrint_vd_vd(vdouble d) { return vrndnq_f64(d); } +static INLINE VECTOR_CC vfloat vrint_vf_vf(vfloat d) { return vrndnq_f32(d); } + +/****************************************/ +/* int <--> float conversions */ +/****************************************/ +static INLINE VECTOR_CC vint vtruncate_vi_vd(vdouble vf) { + return vmovn_s64(vcvtq_s64_f64(vf)); +} +static INLINE VECTOR_CC vdouble vcast_vd_vi(vint vi) { + return vcvtq_f64_s64(vmovl_s32(vi)); +} +static INLINE VECTOR_CC vint vcast_vi_i(int i) { return vdup_n_s32(i); } +static INLINE VECTOR_CC vint vrint_vi_vd(vdouble d) { + return vqmovn_s64(vcvtq_s64_f64(vrndnq_f64(d))); +} + +/***************************************/ +/* Integer operations */ +/***************************************/ + +// Add, Sub, Neg (-x) +static INLINE VECTOR_CC vint vadd_vi_vi_vi(vint x, vint y) { return vadd_s32(x, y); } +static INLINE VECTOR_CC vint vsub_vi_vi_vi(vint x, vint y) { return vsub_s32(x, y); } +static INLINE VECTOR_CC vint vneg_vi_vi(vint e) { return vneg_s32(e); } + +// Logical operations +static INLINE VECTOR_CC vint vand_vi_vi_vi(vint x, vint y) { return vand_s32(x, y); } +static INLINE VECTOR_CC vint vandnot_vi_vi_vi(vint x, vint y) { return vbic_s32(y, x); } +static INLINE VECTOR_CC vint vor_vi_vi_vi(vint x, vint y) { return vorr_s32(x, y); } +static INLINE VECTOR_CC vint vxor_vi_vi_vi(vint x, vint y) { return veor_s32(x, y); } + +// Comparison returning masks +static INLINE VECTOR_CC vopmask veq_vo_vi_vi(vint x, vint y) { + return vcombine_u32(vceq_s32(x, y), vdup_n_u32(0)); +} + +// Conditional select +static INLINE VECTOR_CC vint vsel_vi_vm_vi_vi(vmask m, vint x, vint y) { + return vbsl_s32(vget_low_u32(m), x, y); +} + +/***************************************/ +/* Predicates */ +/***************************************/ +static INLINE VECTOR_CC vopmask visinf_vo_vd(vdouble d) { + const float64x2_t inf = vdupq_n_f64(SLEEF_INFINITY); + const float64x2_t neg_inf = vdupq_n_f64(-SLEEF_INFINITY); + uint64x2_t cmp = vorrq_u64(vceqq_f64(d, inf), vceqq_f64(d, neg_inf)); + return vreinterpretq_u32_u64(cmp); +} + +static INLINE VECTOR_CC vopmask visnan_vo_vd(vdouble d) { + return vmvnq_u32(vreinterpretq_u32_u64(vceqq_f64(d, d))); +} + +static INLINE VECTOR_CC vopmask vispinf_vo_vd(vdouble d) { + return vreinterpretq_u32_u64(vceqq_f64(d, vdupq_n_f64(SLEEF_INFINITY))); +} + +static INLINE VECTOR_CC vopmask visminf_vo_vd(vdouble d) { + return vreinterpretq_u32_u64(vceqq_f64(d, vdupq_n_f64(-SLEEF_INFINITY))); +} + +static INLINE VECTOR_CC vfloat vsel_vf_vo_vf_vf(vopmask mask, vfloat x, vfloat y) { + return vbslq_f32(mask, x, y); +} + +static INLINE CONST VECTOR_CC vfloat vsel_vf_vo_f_f(vopmask o, float v1, float v0) { + return vsel_vf_vo_vf_vf(o, vcast_vf_f(v1), vcast_vf_f(v0)); +} + +static INLINE VECTOR_CC vfloat vsel_vf_vo_vo_f_f_f(vopmask o0, vopmask o1, float d0, float d1, float d2) { + return vsel_vf_vo_vf_vf(o0, vcast_vf_f(d0), vsel_vf_vo_f_f(o1, d1, d2)); +} + +static INLINE VECTOR_CC vfloat vsel_vf_vo_vo_vo_f_f_f_f(vopmask o0, vopmask o1, vopmask o2, float d0, float d1, float d2, float d3) { + return vsel_vf_vo_vf_vf(o0, vcast_vf_f(d0), vsel_vf_vo_vf_vf(o1, vcast_vf_f(d1), vsel_vf_vo_f_f(o2, d2, d3))); +} + +static INLINE VECTOR_CC vopmask veq_vo_vf_vf(vfloat x, vfloat y) { + return vceqq_f32(x, y); +} +static INLINE VECTOR_CC vopmask vneq_vo_vf_vf(vfloat x, vfloat y) { + return vmvnq_u32(vceqq_f32(x, y)); +} +static INLINE VECTOR_CC vopmask vlt_vo_vf_vf(vfloat x, vfloat y) { + return vcltq_f32(x, y); +} +static INLINE VECTOR_CC vopmask vle_vo_vf_vf(vfloat x, vfloat y) { + return vcleq_f32(x, y); +} +static INLINE VECTOR_CC vopmask vgt_vo_vf_vf(vfloat x, vfloat y) { + return vcgtq_f32(x, y); +} +static INLINE VECTOR_CC vopmask vge_vo_vf_vf(vfloat x, vfloat y) { + return vcgeq_f32(x, y); +} + +static INLINE VECTOR_CC vopmask veq_vo_vi2_vi2(vint2 x, vint2 y) { + return vceqq_s32(x, y); +} +static INLINE VECTOR_CC vopmask vgt_vo_vi2_vi2(vint2 x, vint2 y) { + return vcgtq_s32(x, y); +} +static INLINE VECTOR_CC vopmask vgt_vo_vi_vi(vint x, vint y) { + return vcombine_u32(vcgt_s32(x, y), vdup_n_u32(0)); +} +static INLINE VECTOR_CC vopmask visinf_vo_vf(vfloat d) { + return veq_vo_vf_vf(vabs_vf_vf(d), vcast_vf_f(SLEEF_INFINITYf)); +} +static INLINE VECTOR_CC vopmask vispinf_vo_vf(vfloat d) { + return veq_vo_vf_vf(d, vcast_vf_f(SLEEF_INFINITYf)); +} +static INLINE VECTOR_CC vopmask visminf_vo_vf(vfloat d) { + return veq_vo_vf_vf(d, vcast_vf_f(-SLEEF_INFINITYf)); +} +static INLINE VECTOR_CC vopmask visnan_vo_vf(vfloat d) { return vneq_vo_vf_vf(d, d); } + +static INLINE VECTOR_CC vopmask vcast_vo32_vo64(vopmask m) { + return vuzpq_u32(m, m).val[0]; +} +static INLINE VECTOR_CC vopmask vcast_vo64_vo32(vopmask m) { + return vzipq_u32(m, m).val[0]; +} +static INLINE VECTOR_CC vopmask vcast_vo_i(int i) { + return vreinterpretq_u32_u64(vdupq_n_u64((uint64_t)(i ? -1 : 0))); +} + +static INLINE VECTOR_CC vopmask vand_vo_vo_vo(vopmask x, vopmask y) { + return vandq_u32(x, y); +} +static INLINE VECTOR_CC vopmask vandnot_vo_vo_vo(vopmask x, vopmask y) { + return vbicq_u32(y, x); +} +static INLINE VECTOR_CC vopmask vor_vo_vo_vo(vopmask x, vopmask y) { + return vorrq_u32(x, y); +} +static INLINE VECTOR_CC vopmask vxor_vo_vo_vo(vopmask x, vopmask y) { + return veorq_u32(x, y); +} + +static INLINE VECTOR_CC vint2 vsel_vi2_vo_vi2_vi2(vopmask m, vint2 x, vint2 y) { + return vbslq_s32(m, x, y); +} +static INLINE VECTOR_CC vint2 vand_vi2_vo_vi2(vopmask x, vint2 y) { + return vandq_s32(vreinterpretq_s32_u32(x), y); +} +static INLINE VECTOR_CC vint2 vandnot_vi2_vo_vi2(vopmask x, vint2 y) { + return vbicq_s32(y, vreinterpretq_s32_u32(x)); +} +static INLINE VECTOR_CC vint vandnot_vi_vo_vi(vopmask x, vint y) { + return vbic_s32(y, vget_low_s32(vreinterpretq_s32_u32(x))); +} +static INLINE VECTOR_CC vmask vand_vm_vo32_vm(vopmask x, vmask y) { + return vandq_u32(x, y); +} +static INLINE VECTOR_CC vmask vand_vm_vo64_vm(vopmask x, vmask y) { + return vandq_u32(x, y); +} +static INLINE VECTOR_CC vmask vandnot_vm_vo32_vm(vopmask x, vmask y) { + return vbicq_u32(y, x); +} +static INLINE VECTOR_CC vmask vandnot_vm_vo64_vm(vopmask x, vmask y) { + return vbicq_u32(y, x); +} +static INLINE VECTOR_CC vmask vor_vm_vo32_vm(vopmask x, vmask y) { + return vorrq_u32(x, y); +} +static INLINE VECTOR_CC vmask vor_vm_vo64_vm(vopmask x, vmask y) { + return vorrq_u32(x, y); +} +static INLINE VECTOR_CC vmask vxor_vm_vo32_vm(vopmask x, vmask y) { + return veorq_u32(x, y); +} + +static INLINE VECTOR_CC vfloat vtruncate_vf_vf(vfloat vd) { return vrndq_f32(vd); } + +static INLINE VECTOR_CC vmask vcast_vm_i_i(int i0, int i1) { + return vreinterpretq_u32_u64(vdupq_n_u64((0xffffffff & (uint64_t)i1) | (((uint64_t)i0) << 32))); +} + +static INLINE vmask vcast_vm_i64(int64_t i) { + return vreinterpretq_u32_u64(vdupq_n_u64((uint64_t)i)); +} +static INLINE vmask vcast_vm_u64(uint64_t i) { + return vreinterpretq_u32_u64(vdupq_n_u64(i)); +} + +static INLINE VECTOR_CC vopmask veq64_vo_vm_vm(vmask x, vmask y) { + return vreinterpretq_u32_u64(vceqq_s64(vreinterpretq_s64_u32(x), vreinterpretq_s64_u32(y))); +} + +static INLINE VECTOR_CC vmask vadd64_vm_vm_vm(vmask x, vmask y) { + return vreinterpretq_u32_s64(vaddq_s64(vreinterpretq_s64_u32(x), vreinterpretq_s64_u32(y))); +} + +static INLINE VECTOR_CC vint vsel_vi_vo_vi_vi(vopmask m, vint x, vint y) { + return vbsl_s32(vget_low_u32(m), x, y); +} + +// Logical operations +static INLINE VECTOR_CC vint vand_vi_vo_vi(vopmask x, vint y) { + return vand_s32(vreinterpret_s32_u32(vget_low_u32(x)), y); +} + +static INLINE VECTOR_CC vmask vcastu_vm_vi(vint vi) { + return vrev64q_u32(vreinterpretq_u32_u64(vmovl_u32(vreinterpret_u32_s32(vi)))); +} +static INLINE VECTOR_CC vint vcastu_vi_vm(vmask vi2) { + return vreinterpret_s32_u32(vmovn_u64(vreinterpretq_u64_u32(vrev64q_u32(vi2)))); +} +static INLINE VECTOR_CC vdouble vtruncate_vd_vd(vdouble vd) { return vrndq_f64(vd); } + +// + +#define PNMASK ((vdouble) { +0.0, -0.0 }) +#define NPMASK ((vdouble) { -0.0, +0.0 }) +#define PNMASKf ((vfloat) { +0.0f, -0.0f, +0.0f, -0.0f }) +#define NPMASKf ((vfloat) { -0.0f, +0.0f, -0.0f, +0.0f }) + +static INLINE VECTOR_CC vdouble vposneg_vd_vd(vdouble d) { return vreinterpret_vd_vm(vxor_vm_vm_vm(vreinterpret_vm_vd(d), vreinterpret_vm_vd(PNMASK))); } +static INLINE VECTOR_CC vdouble vnegpos_vd_vd(vdouble d) { return vreinterpret_vd_vm(vxor_vm_vm_vm(vreinterpret_vm_vd(d), vreinterpret_vm_vd(NPMASK))); } +static INLINE VECTOR_CC vfloat vposneg_vf_vf(vfloat d) { return (vfloat)vxor_vm_vm_vm((vmask)d, (vmask)PNMASKf); } +static INLINE VECTOR_CC vfloat vnegpos_vf_vf(vfloat d) { return (vfloat)vxor_vm_vm_vm((vmask)d, (vmask)NPMASKf); } + +static INLINE VECTOR_CC vdouble vsubadd_vd_vd_vd(vdouble x, vdouble y) { return vadd_vd_vd_vd(x, vnegpos_vd_vd(y)); } +static INLINE VECTOR_CC vfloat vsubadd_vf_vf_vf(vfloat d0, vfloat d1) { return vadd_vf_vf_vf(d0, vnegpos_vf_vf(d1)); } +static INLINE VECTOR_CC vdouble vmlsubadd_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return vsubadd_vd_vd_vd(vmul_vd_vd_vd(x, y), z); } +static INLINE VECTOR_CC vfloat vmlsubadd_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return vsubadd_vf_vf_vf(vmul_vf_vf_vf(x, y), z); } + +static INLINE VECTOR_CC vdouble vrev21_vd_vd(vdouble d0) { return (float64x2_t)vcombine_u64(vget_high_u64((uint64x2_t)d0), vget_low_u64((uint64x2_t)d0)); } +static INLINE VECTOR_CC vdouble vreva2_vd_vd(vdouble vd) { return vd; } + +static INLINE VECTOR_CC void vstream_v_p_vd(double *ptr, vdouble v) { vstore_v_p_vd(ptr, v); } +static INLINE VECTOR_CC void vscatter2_v_p_i_i_vd(double *ptr, int offset, int step, vdouble v) { vstore_v_p_vd((double *)(&ptr[2*offset]), v); } +static INLINE VECTOR_CC void vsscatter2_v_p_i_i_vd(double *ptr, int offset, int step, vdouble v) { vstore_v_p_vd((double *)(&ptr[2*offset]), v); } + +static INLINE VECTOR_CC vfloat vrev21_vf_vf(vfloat d0) { return vrev64q_f32(d0); } +static INLINE VECTOR_CC vfloat vreva2_vf_vf(vfloat d0) { return vcombine_f32(vget_high_f32(d0), vget_low_f32(d0)); } + +static INLINE VECTOR_CC void vstream_v_p_vf(float *ptr, vfloat v) { vstore_v_p_vf(ptr, v); } + +static INLINE VECTOR_CC void vscatter2_v_p_i_i_vf(float *ptr, int offset, int step, vfloat v) { + vst1_f32((float *)(ptr+(offset + step * 0)*2), vget_low_f32(v)); + vst1_f32((float *)(ptr+(offset + step * 1)*2), vget_high_f32(v)); +} + +static INLINE VECTOR_CC void vsscatter2_v_p_i_i_vf(float *ptr, int offset, int step, vfloat v) { + vst1_f32((float *)(ptr+(offset + step * 0)*2), vget_low_f32(v)); + vst1_f32((float *)(ptr+(offset + step * 1)*2), vget_high_f32(v)); +} + +// + +static vquad loadu_vq_p(void *p) { + vquad vq; + memcpy(&vq, p, VECTLENDP * 16); + return vq; +} + +static INLINE vquad cast_vq_aq(vargquad aq) { + vquad vq; + memcpy(&vq, &aq, VECTLENDP * 16); + return vq; +} + +static INLINE vargquad cast_aq_vq(vquad vq) { + vargquad aq; + memcpy(&aq, &vq, VECTLENDP * 16); + return aq; +} + +static INLINE int vtestallzeros_i_vo64(vopmask g) { + uint32x2_t x0 = vorr_u32(vget_low_u32(g), vget_high_u32(g)); + uint32x2_t x1 = vpmax_u32(x0, x0); + return ~vget_lane_u32(x1, 0); +} + +static INLINE vmask vsel_vm_vo64_vm_vm(vopmask m, vmask x, vmask y) { return vbslq_u32(m, x, y); } + +static INLINE vmask vsub64_vm_vm_vm(vmask x, vmask y) { + return vreinterpretq_u32_s64(vsubq_s64(vreinterpretq_s64_u32(x), vreinterpretq_s64_u32(y))); +} + +static INLINE vmask vneg64_vm_vm(vmask x) { + return vreinterpretq_u32_s64(vnegq_s64(vreinterpretq_s64_u32(x))); +} + +static INLINE vopmask vgt64_vo_vm_vm(vmask x, vmask y) { + return vreinterpretq_u32_u64(vcgtq_s64(vreinterpretq_s64_u32(x), vreinterpretq_s64_u32(y))); +} + +#define vsll64_vm_vm_i(x, c) vreinterpretq_u32_u64(vshlq_n_u64(vreinterpretq_u64_u32(x), c)) +//@#define vsll64_vm_vm_i(x, c) vreinterpretq_u32_u64(vshlq_n_u64(vreinterpretq_u64_u32(x), c)) +#define vsrl64_vm_vm_i(x, c) vreinterpretq_u32_u64(vshrq_n_u64(vreinterpretq_u64_u32(x), c)) +//@#define vsrl64_vm_vm_i(x, c) vreinterpretq_u32_u64(vshrq_n_u64(vreinterpretq_u64_u32(x), c)) + +static INLINE vmask vcast_vm_vi(vint vi) { + vmask m = vreinterpretq_u32_u64(vmovl_u32(vreinterpret_u32_s32(vi))); + return vor_vm_vm_vm(vcastu_vm_vi(vreinterpret_s32_u32(vget_low_u32(vgt_vo_vi_vi(vcast_vi_i(0), vi)))), m); +} +static INLINE vint vcast_vi_vm(vmask vm) { return vreinterpret_s32_u32(vmovn_u64(vreinterpretq_u64_u32(vm))); } + +static INLINE vmask vreinterpret_vm_vi64(vint64 v) { return vreinterpretq_u32_s64(v); } +static INLINE vint64 vreinterpret_vi64_vm(vmask m) { return vreinterpretq_s64_u32(m); } +static INLINE vmask vreinterpret_vm_vu64(vuint64 v) { return vreinterpretq_u32_u64(v); } +static INLINE vuint64 vreinterpret_vu64_vm(vmask m) { return vreinterpretq_u64_u32(m); } diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/arch/helperavx.h b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/arch/helperavx.h new file mode 100644 index 00000000000..1b6da17e84d --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/arch/helperavx.h @@ -0,0 +1,638 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#if CONFIG == 1 + +#if !defined(__AVX__) && !defined(SLEEF_GENHEADER) +#error Please specify -mavx. +#endif + +#elif CONFIG == 4 + +#if (!defined(__AVX__) || !defined(__FMA4__)) && !defined(SLEEF_GENHEADER) +#error Please specify -mavx and -mfma4. +#endif + +#else +#error CONFIG macro invalid or not defined +#endif + +#define ENABLE_DP +//@#define ENABLE_DP +#define LOG2VECTLENDP 2 +//@#define LOG2VECTLENDP 2 +#define VECTLENDP (1 << LOG2VECTLENDP) +//@#define VECTLENDP (1 << LOG2VECTLENDP) + +#define ENABLE_SP +//@#define ENABLE_SP +#define LOG2VECTLENSP (LOG2VECTLENDP+1) +//@#define LOG2VECTLENSP (LOG2VECTLENDP+1) +#define VECTLENSP (1 << LOG2VECTLENSP) +//@#define VECTLENSP (1 << LOG2VECTLENSP) + +#define FULL_FP_ROUNDING +//@#define FULL_FP_ROUNDING +#define ACCURATE_SQRT +//@#define ACCURATE_SQRT + +#if !defined(SLEEF_GENHEADER) +#if defined(_MSC_VER) +#include +#else +#include +#endif + +#include +#include "misc.h" +#endif // #if !defined(SLEEF_GENHEADER) + +typedef __m256i vmask; +typedef __m256i vopmask; + +typedef __m256d vdouble; +typedef __m128i vint; + +typedef __m256 vfloat; +typedef struct { __m128i x, y; } vint2; + +typedef __m256i vint64; +typedef __m256i vuint64; + +typedef struct { + vmask x, y; +} vquad; + +typedef vquad vargquad; + +// + +#if !defined(SLEEF_GENHEADER) + +#ifndef __SLEEF_H__ +void Sleef_x86CpuID(int32_t out[4], uint32_t eax, uint32_t ecx); +#endif + +static INLINE int cpuSupportsAVX() { + int32_t reg[4]; + Sleef_x86CpuID(reg, 1, 0); + return (reg[2] & (1 << 28)) != 0; +} + +static INLINE int cpuSupportsFMA4() { + int32_t reg[4]; + Sleef_x86CpuID(reg, 0x80000001, 0); + return (reg[2] & (1 << 16)) != 0; +} + +#if CONFIG == 4 && defined(__AVX__) && defined(__FMA4__) +static INLINE int vavailability_i(int name) { + int d = cpuSupportsAVX() && cpuSupportsFMA4(); + return d ? 3 : 0; +} + +#define ENABLE_FMA_DP +#define ENABLE_FMA_SP + +#define ISANAME "AVX + AMD FMA4" +#define DFTPRIORITY 21 +#else +static INLINE int vavailability_i(int name) { + int d = cpuSupportsAVX(); + return d ? 3 : 0; +} + +#define ISANAME "AVX" +#define DFTPRIORITY 20 +#endif + +#endif // #if !defined(SLEEF_GENHEADER) + +static INLINE void vprefetch_v_p(const void *ptr) { _mm_prefetch(ptr, _MM_HINT_T0); } + +static INLINE int vtestallones_i_vo32(vopmask g) { + return _mm_test_all_ones(_mm_and_si128(_mm256_extractf128_si256(g, 0), _mm256_extractf128_si256(g, 1))); +} + +static INLINE int vtestallones_i_vo64(vopmask g) { + return _mm_test_all_ones(_mm_and_si128(_mm256_extractf128_si256(g, 0), _mm256_extractf128_si256(g, 1))); +} + +// + +static INLINE vdouble vcast_vd_d(double d) { return _mm256_set1_pd(d); } +static INLINE vmask vreinterpret_vm_vd(vdouble vd) { return _mm256_castpd_si256(vd); } +static INLINE vdouble vreinterpret_vd_vm(vmask vm) { return _mm256_castsi256_pd(vm); } + +// + +static vint2 vloadu_vi2_p(int32_t *p) { + vint2 r; + r.x = _mm_loadu_si128((__m128i *) p ); + r.y = _mm_loadu_si128((__m128i *)(p + 4)); + return r; +} + +static void vstoreu_v_p_vi2(int32_t *p, vint2 v) { + _mm_storeu_si128((__m128i *) p , v.x); + _mm_storeu_si128((__m128i *)(p + 4), v.y); +} + +static vint vloadu_vi_p(int32_t *p) { return _mm_loadu_si128((__m128i *)p); } +static void vstoreu_v_p_vi(int32_t *p, vint v) { _mm_storeu_si128((__m128i *)p, v); } + +// + +static INLINE vmask vand_vm_vm_vm(vmask x, vmask y) { return vreinterpret_vm_vd(_mm256_and_pd(vreinterpret_vd_vm(x), vreinterpret_vd_vm(y))); } +static INLINE vmask vandnot_vm_vm_vm(vmask x, vmask y) { return vreinterpret_vm_vd(_mm256_andnot_pd(vreinterpret_vd_vm(x), vreinterpret_vd_vm(y))); } +static INLINE vmask vor_vm_vm_vm(vmask x, vmask y) { return vreinterpret_vm_vd(_mm256_or_pd(vreinterpret_vd_vm(x), vreinterpret_vd_vm(y))); } +static INLINE vmask vxor_vm_vm_vm(vmask x, vmask y) { return vreinterpret_vm_vd(_mm256_xor_pd(vreinterpret_vd_vm(x), vreinterpret_vd_vm(y))); } + +static INLINE vopmask vand_vo_vo_vo(vopmask x, vopmask y) { return vreinterpret_vm_vd(_mm256_and_pd(vreinterpret_vd_vm(x), vreinterpret_vd_vm(y))); } +static INLINE vopmask vandnot_vo_vo_vo(vopmask x, vopmask y) { return vreinterpret_vm_vd(_mm256_andnot_pd(vreinterpret_vd_vm(x), vreinterpret_vd_vm(y))); } +static INLINE vopmask vor_vo_vo_vo(vopmask x, vopmask y) { return vreinterpret_vm_vd(_mm256_or_pd(vreinterpret_vd_vm(x), vreinterpret_vd_vm(y))); } +static INLINE vopmask vxor_vo_vo_vo(vopmask x, vopmask y) { return vreinterpret_vm_vd(_mm256_xor_pd(vreinterpret_vd_vm(x), vreinterpret_vd_vm(y))); } + +static INLINE vmask vand_vm_vo64_vm(vopmask x, vmask y) { return vreinterpret_vm_vd(_mm256_and_pd(vreinterpret_vd_vm(x), vreinterpret_vd_vm(y))); } +static INLINE vmask vandnot_vm_vo64_vm(vopmask x, vmask y) { return vreinterpret_vm_vd(_mm256_andnot_pd(vreinterpret_vd_vm(x), vreinterpret_vd_vm(y))); } +static INLINE vmask vor_vm_vo64_vm(vopmask x, vmask y) { return vreinterpret_vm_vd(_mm256_or_pd(vreinterpret_vd_vm(x), vreinterpret_vd_vm(y))); } +static INLINE vmask vxor_vm_vo64_vm(vopmask x, vmask y) { return vreinterpret_vm_vd(_mm256_xor_pd(vreinterpret_vd_vm(x), vreinterpret_vd_vm(y))); } + +static INLINE vmask vand_vm_vo32_vm(vopmask x, vmask y) { return vreinterpret_vm_vd(_mm256_and_pd(vreinterpret_vd_vm(x), vreinterpret_vd_vm(y))); } +static INLINE vmask vandnot_vm_vo32_vm(vopmask x, vmask y) { return vreinterpret_vm_vd(_mm256_andnot_pd(vreinterpret_vd_vm(x), vreinterpret_vd_vm(y))); } +static INLINE vmask vor_vm_vo32_vm(vopmask x, vmask y) { return vreinterpret_vm_vd(_mm256_or_pd(vreinterpret_vd_vm(x), vreinterpret_vd_vm(y))); } +static INLINE vmask vxor_vm_vo32_vm(vopmask x, vmask y) { return vreinterpret_vm_vd(_mm256_xor_pd(vreinterpret_vd_vm(x), vreinterpret_vd_vm(y))); } + +static INLINE vopmask vcast_vo32_vo64(vopmask o) { + return _mm256_castsi128_si256(_mm256_cvtpd_epi32(_mm256_and_pd(vreinterpret_vd_vm(o), _mm256_set1_pd(-1.0)))); +} + +static INLINE vopmask vcast_vo64_vo32(vopmask o) { + return vreinterpret_vm_vd(_mm256_cmp_pd(_mm256_cvtepi32_pd(_mm256_castsi256_si128(o)), _mm256_set1_pd(-1.0), _CMP_EQ_OQ)); +} + +static INLINE vopmask vcast_vo_i(int i) { return _mm256_set1_epi64x(i ? -1 : 0); } + +// + +static INLINE vint vrint_vi_vd(vdouble vd) { return _mm256_cvtpd_epi32(vd); } +static INLINE vint vtruncate_vi_vd(vdouble vd) { return _mm256_cvttpd_epi32(vd); } +static INLINE vdouble vrint_vd_vd(vdouble vd) { return _mm256_round_pd(vd, _MM_FROUND_TO_NEAREST_INT |_MM_FROUND_NO_EXC); } +static INLINE vdouble vtruncate_vd_vd(vdouble vd) { return _mm256_round_pd(vd, _MM_FROUND_TO_ZERO |_MM_FROUND_NO_EXC); } +static INLINE vfloat vrint_vf_vf(vfloat vd) { return _mm256_round_ps(vd, _MM_FROUND_TO_NEAREST_INT |_MM_FROUND_NO_EXC); } +static INLINE vfloat vtruncate_vf_vf(vfloat vf) { return _mm256_round_ps(vf, _MM_FROUND_TO_ZERO |_MM_FROUND_NO_EXC); } +static INLINE vdouble vcast_vd_vi(vint vi) { return _mm256_cvtepi32_pd(vi); } +static INLINE vint vcast_vi_i(int i) { return _mm_set1_epi32(i); } + +static INLINE vmask vcastu_vm_vi(vint vi) { + __m256i m = _mm256_castsi128_si256(_mm_and_si128(_mm_shuffle_epi32(vi, 0x40), _mm_set_epi32(-1, 0, -1, 0))); + return _mm256_insertf128_si256(m, _mm_and_si128(_mm_shuffle_epi32(vi, 0xc8), _mm_set_epi32(-1, 0, -1, 0)), 1); +} + +static INLINE vint vcastu_vi_vm(vmask vi) { + return _mm_or_si128(_mm_and_si128(_mm_shuffle_epi32(_mm256_castsi256_si128(vi) , 0x0d), _mm_set_epi32( 0, 0, -1, -1)), + _mm_and_si128(_mm_shuffle_epi32(_mm256_extractf128_si256(vi, 1), 0xd0), _mm_set_epi32(-1, -1, 0, 0))); +} + +static INLINE vmask vcast_vm_i_i(int i0, int i1) { + return _mm256_set_epi32(i0, i1, i0, i1, i0, i1, i0, i1); +} + +static INLINE vopmask veq64_vo_vm_vm(vmask x, vmask y) { + return vreinterpret_vm_vd(_mm256_cmp_pd(vreinterpret_vd_vm(vxor_vm_vm_vm(vxor_vm_vm_vm(x, y), vreinterpret_vm_vd(_mm256_set1_pd(1.0)))), _mm256_set1_pd(1.0), _CMP_EQ_OQ)); +} + +static INLINE vmask vcast_vm_i64(int64_t i) { return _mm256_set1_epi64x(i); } +static INLINE vmask vcast_vm_u64(uint64_t i) { return _mm256_set1_epi64x((uint64_t)i); } + +// + +static INLINE vdouble vadd_vd_vd_vd(vdouble x, vdouble y) { return _mm256_add_pd(x, y); } +static INLINE vdouble vsub_vd_vd_vd(vdouble x, vdouble y) { return _mm256_sub_pd(x, y); } +static INLINE vdouble vmul_vd_vd_vd(vdouble x, vdouble y) { return _mm256_mul_pd(x, y); } +static INLINE vdouble vdiv_vd_vd_vd(vdouble x, vdouble y) { return _mm256_div_pd(x, y); } +static INLINE vdouble vrec_vd_vd(vdouble x) { return _mm256_div_pd(_mm256_set1_pd(1), x); } +static INLINE vdouble vsqrt_vd_vd(vdouble x) { return _mm256_sqrt_pd(x); } +static INLINE vdouble vabs_vd_vd(vdouble d) { return _mm256_andnot_pd(_mm256_set1_pd(-0.0), d); } +static INLINE vdouble vneg_vd_vd(vdouble d) { return _mm256_xor_pd(_mm256_set1_pd(-0.0), d); } +static INLINE vdouble vmax_vd_vd_vd(vdouble x, vdouble y) { return _mm256_max_pd(x, y); } +static INLINE vdouble vmin_vd_vd_vd(vdouble x, vdouble y) { return _mm256_min_pd(x, y); } + +#if CONFIG == 1 +static INLINE vdouble vmla_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return vadd_vd_vd_vd(vmul_vd_vd_vd(x, y), z); } +static INLINE vdouble vmlapn_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return vsub_vd_vd_vd(vmul_vd_vd_vd(x, y), z); } +static INLINE vdouble vmlanp_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return vsub_vd_vd_vd(z, vmul_vd_vd_vd(x, y)); } +#else +static INLINE vdouble vmla_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return _mm256_macc_pd(x, y, z); } +static INLINE vdouble vmlapn_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return _mm256_msub_pd(x, y, z); } +static INLINE vdouble vmlanp_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return _mm256_nmacc_pd(x, y, z); } +static INLINE vdouble vfma_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return _mm256_macc_pd(x, y, z); } +static INLINE vdouble vfmapp_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return _mm256_macc_pd(x, y, z); } +static INLINE vdouble vfmapn_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return _mm256_msub_pd(x, y, z); } +static INLINE vdouble vfmanp_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return _mm256_nmacc_pd(x, y, z); } +static INLINE vdouble vfmann_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return _mm256_nmsub_pd(x, y, z); } +#endif + +static INLINE vopmask veq_vo_vd_vd(vdouble x, vdouble y) { return vreinterpret_vm_vd(_mm256_cmp_pd(x, y, _CMP_EQ_OQ)); } +static INLINE vopmask vneq_vo_vd_vd(vdouble x, vdouble y) { return vreinterpret_vm_vd(_mm256_cmp_pd(x, y, _CMP_NEQ_UQ)); } +static INLINE vopmask vlt_vo_vd_vd(vdouble x, vdouble y) { return vreinterpret_vm_vd(_mm256_cmp_pd(x, y, _CMP_LT_OQ)); } +static INLINE vopmask vle_vo_vd_vd(vdouble x, vdouble y) { return vreinterpret_vm_vd(_mm256_cmp_pd(x, y, _CMP_LE_OQ)); } +static INLINE vopmask vgt_vo_vd_vd(vdouble x, vdouble y) { return vreinterpret_vm_vd(_mm256_cmp_pd(x, y, _CMP_GT_OQ)); } +static INLINE vopmask vge_vo_vd_vd(vdouble x, vdouble y) { return vreinterpret_vm_vd(_mm256_cmp_pd(x, y, _CMP_GE_OQ)); } + +// + +static INLINE vint vadd_vi_vi_vi(vint x, vint y) { return _mm_add_epi32(x, y); } +static INLINE vint vsub_vi_vi_vi(vint x, vint y) { return _mm_sub_epi32(x, y); } +static INLINE vint vneg_vi_vi(vint e) { return vsub_vi_vi_vi(vcast_vi_i(0), e); } + +static INLINE vint vand_vi_vi_vi(vint x, vint y) { return _mm_and_si128(x, y); } +static INLINE vint vandnot_vi_vi_vi(vint x, vint y) { return _mm_andnot_si128(x, y); } +static INLINE vint vor_vi_vi_vi(vint x, vint y) { return _mm_or_si128(x, y); } +static INLINE vint vxor_vi_vi_vi(vint x, vint y) { return _mm_xor_si128(x, y); } + +static INLINE vint vandnot_vi_vo_vi(vopmask m, vint y) { return _mm_andnot_si128(_mm256_castsi256_si128(m), y); } +static INLINE vint vand_vi_vo_vi(vopmask m, vint y) { return _mm_and_si128(_mm256_castsi256_si128(m), y); } + +static INLINE vint vsll_vi_vi_i(vint x, int c) { return _mm_slli_epi32(x, c); } +static INLINE vint vsrl_vi_vi_i(vint x, int c) { return _mm_srli_epi32(x, c); } +static INLINE vint vsra_vi_vi_i(vint x, int c) { return _mm_srai_epi32(x, c); } + +static INLINE vint veq_vi_vi_vi(vint x, vint y) { return _mm_cmpeq_epi32(x, y); } +static INLINE vint vgt_vi_vi_vi(vint x, vint y) { return _mm_cmpgt_epi32(x, y); } + +static INLINE vopmask veq_vo_vi_vi(vint x, vint y) { return _mm256_castsi128_si256(_mm_cmpeq_epi32(x, y)); } +static INLINE vopmask vgt_vo_vi_vi(vint x, vint y) { return _mm256_castsi128_si256(_mm_cmpgt_epi32(x, y)); } + +static INLINE vint vsel_vi_vo_vi_vi(vopmask o, vint x, vint y) { return _mm_blendv_epi8(y, x, _mm256_castsi256_si128(o)); } + +static INLINE vdouble vsel_vd_vo_vd_vd(vopmask o, vdouble x, vdouble y) { return _mm256_blendv_pd(y, x, _mm256_castsi256_pd(o)); } + +static INLINE CONST vdouble vsel_vd_vo_d_d(vopmask o, double v1, double v0) { + return vsel_vd_vo_vd_vd(o, vcast_vd_d(v1), vcast_vd_d(v0)); +} + +static INLINE vdouble vsel_vd_vo_vo_d_d_d(vopmask o0, vopmask o1, double d0, double d1, double d2) { + return vsel_vd_vo_vd_vd(o0, vcast_vd_d(d0), vsel_vd_vo_d_d(o1, d1, d2)); +} + +static INLINE vdouble vsel_vd_vo_vo_vo_d_d_d_d(vopmask o0, vopmask o1, vopmask o2, double d0, double d1, double d2, double d3) { + return vsel_vd_vo_vd_vd(o0, vcast_vd_d(d0), vsel_vd_vo_vd_vd(o1, vcast_vd_d(d1), vsel_vd_vo_d_d(o2, d2, d3))); +} + +static INLINE vopmask visinf_vo_vd(vdouble d) { + return vreinterpret_vm_vd(_mm256_cmp_pd(vabs_vd_vd(d), _mm256_set1_pd(SLEEF_INFINITY), _CMP_EQ_OQ)); +} + +static INLINE vopmask vispinf_vo_vd(vdouble d) { + return vreinterpret_vm_vd(_mm256_cmp_pd(d, _mm256_set1_pd(SLEEF_INFINITY), _CMP_EQ_OQ)); +} + +static INLINE vopmask visminf_vo_vd(vdouble d) { + return vreinterpret_vm_vd(_mm256_cmp_pd(d, _mm256_set1_pd(-SLEEF_INFINITY), _CMP_EQ_OQ)); +} + +static INLINE vopmask visnan_vo_vd(vdouble d) { + return vreinterpret_vm_vd(_mm256_cmp_pd(d, d, _CMP_NEQ_UQ)); +} + +static INLINE vdouble vload_vd_p(const double *ptr) { return _mm256_load_pd(ptr); } +static INLINE vdouble vloadu_vd_p(const double *ptr) { return _mm256_loadu_pd(ptr); } + +static INLINE void vstore_v_p_vd(double *ptr, vdouble v) { _mm256_store_pd(ptr, v); } +static INLINE void vstoreu_v_p_vd(double *ptr, vdouble v) { _mm256_storeu_pd(ptr, v); } + +static INLINE vdouble vgather_vd_p_vi(const double *ptr, vint vi) { + int a[VECTLENDP]; + vstoreu_v_p_vi(a, vi); + return _mm256_set_pd(ptr[a[3]], ptr[a[2]], ptr[a[1]], ptr[a[0]]); +} + +#if defined(_MSC_VER) +// This function is needed when debugging on MSVC. +static INLINE double vcast_d_vd(vdouble v) { + double a[VECTLENDP]; + vstoreu_v_p_vd(a, v); + return a[0]; +} +#endif + +// + +static INLINE vint2 vcast_vi2_vm(vmask vm) { + vint2 r; + r.x = _mm256_castsi256_si128(vm); + r.y = _mm256_extractf128_si256(vm, 1); + return r; +} + +static INLINE vmask vcast_vm_vi2(vint2 vi) { + vmask m = _mm256_castsi128_si256(vi.x); + m = _mm256_insertf128_si256(m, vi.y, 1); + return m; +} + +static INLINE vint2 vrint_vi2_vf(vfloat vf) { return vcast_vi2_vm(_mm256_cvtps_epi32(vf)); } +static INLINE vint2 vtruncate_vi2_vf(vfloat vf) { return vcast_vi2_vm(_mm256_cvttps_epi32(vf)); } +static INLINE vfloat vcast_vf_vi2(vint2 vi) { return _mm256_cvtepi32_ps(vcast_vm_vi2(vi)); } +static INLINE vfloat vcast_vf_f(float f) { return _mm256_set1_ps(f); } +static INLINE vint2 vcast_vi2_i(int i) { vint2 r; r.x = r.y = _mm_set1_epi32(i); return r; } +static INLINE vmask vreinterpret_vm_vf(vfloat vf) { return _mm256_castps_si256(vf); } +static INLINE vfloat vreinterpret_vf_vm(vmask vm) { return _mm256_castsi256_ps(vm); } + +static INLINE vfloat vreinterpret_vf_vi2(vint2 vi) { return vreinterpret_vf_vm(vcast_vm_vi2(vi)); } +static INLINE vint2 vreinterpret_vi2_vf(vfloat vf) { return vcast_vi2_vm(vreinterpret_vm_vf(vf)); } + +static INLINE vfloat vadd_vf_vf_vf(vfloat x, vfloat y) { return _mm256_add_ps(x, y); } +static INLINE vfloat vsub_vf_vf_vf(vfloat x, vfloat y) { return _mm256_sub_ps(x, y); } +static INLINE vfloat vmul_vf_vf_vf(vfloat x, vfloat y) { return _mm256_mul_ps(x, y); } +static INLINE vfloat vdiv_vf_vf_vf(vfloat x, vfloat y) { return _mm256_div_ps(x, y); } +static INLINE vfloat vrec_vf_vf(vfloat x) { return vdiv_vf_vf_vf(vcast_vf_f(1.0f), x); } +static INLINE vfloat vsqrt_vf_vf(vfloat x) { return _mm256_sqrt_ps(x); } +static INLINE vfloat vabs_vf_vf(vfloat f) { return vreinterpret_vf_vm(vandnot_vm_vm_vm(vreinterpret_vm_vf(vcast_vf_f(-0.0f)), vreinterpret_vm_vf(f))); } +static INLINE vfloat vneg_vf_vf(vfloat d) { return vreinterpret_vf_vm(vxor_vm_vm_vm(vreinterpret_vm_vf(vcast_vf_f(-0.0f)), vreinterpret_vm_vf(d))); } +static INLINE vfloat vmax_vf_vf_vf(vfloat x, vfloat y) { return _mm256_max_ps(x, y); } +static INLINE vfloat vmin_vf_vf_vf(vfloat x, vfloat y) { return _mm256_min_ps(x, y); } + +#if CONFIG == 1 +static INLINE vfloat vmla_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return vadd_vf_vf_vf(vmul_vf_vf_vf(x, y), z); } +static INLINE vfloat vmlanp_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return vsub_vf_vf_vf(z, vmul_vf_vf_vf(x, y)); } +static INLINE vfloat vmlapn_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return vsub_vf_vf_vf(vmul_vf_vf_vf(x, y), z); } +#else +static INLINE vfloat vmla_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return _mm256_macc_ps(x, y, z); } +static INLINE vfloat vmlanp_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return _mm256_nmacc_ps(x, y, z); } +static INLINE vfloat vmlapn_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return _mm256_msub_ps(x, y, z); } +static INLINE vfloat vfma_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return _mm256_macc_ps(x, y, z); } +static INLINE vfloat vfmapp_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return _mm256_macc_ps(x, y, z); } +static INLINE vfloat vfmapn_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return _mm256_msub_ps(x, y, z); } +static INLINE vfloat vfmanp_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return _mm256_nmacc_ps(x, y, z); } +static INLINE vfloat vfmann_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return _mm256_nmsub_ps(x, y, z); } +#endif + +static INLINE vopmask veq_vo_vf_vf(vfloat x, vfloat y) { return vreinterpret_vm_vf(_mm256_cmp_ps(x, y, _CMP_EQ_OQ)); } +static INLINE vopmask vneq_vo_vf_vf(vfloat x, vfloat y) { return vreinterpret_vm_vf(_mm256_cmp_ps(x, y, _CMP_NEQ_UQ)); } +static INLINE vopmask vlt_vo_vf_vf(vfloat x, vfloat y) { return vreinterpret_vm_vf(_mm256_cmp_ps(x, y, _CMP_LT_OQ)); } +static INLINE vopmask vle_vo_vf_vf(vfloat x, vfloat y) { return vreinterpret_vm_vf(_mm256_cmp_ps(x, y, _CMP_LE_OQ)); } +static INLINE vopmask vgt_vo_vf_vf(vfloat x, vfloat y) { return vreinterpret_vm_vf(_mm256_cmp_ps(x, y, _CMP_GT_OQ)); } +static INLINE vopmask vge_vo_vf_vf(vfloat x, vfloat y) { return vreinterpret_vm_vf(_mm256_cmp_ps(x, y, _CMP_GE_OQ)); } + +static INLINE vint2 vadd_vi2_vi2_vi2(vint2 x, vint2 y) { + vint2 vi = { _mm_add_epi32(x.x, y.x), _mm_add_epi32(x.y, y.y) }; + return vi; +} + +static INLINE vint2 vsub_vi2_vi2_vi2(vint2 x, vint2 y) { + vint2 vi = { _mm_sub_epi32(x.x, y.x), _mm_sub_epi32(x.y, y.y) }; + return vi; +} + +static INLINE vint2 vneg_vi2_vi2(vint2 e) { + vint2 vi = { _mm_sub_epi32(_mm_set1_epi32(0), e.x), _mm_sub_epi32(_mm_set1_epi32(0), e.y) }; + return vi; +} + +static INLINE vint2 vand_vi2_vi2_vi2(vint2 x, vint2 y) { + vint2 vi = { _mm_and_si128(x.x, y.x), _mm_and_si128(x.y, y.y) }; + return vi; +} + +static INLINE vint2 vandnot_vi2_vi2_vi2(vint2 x, vint2 y) { + vint2 vi = { _mm_andnot_si128(x.x, y.x), _mm_andnot_si128(x.y, y.y) }; + return vi; +} + +static INLINE vint2 vor_vi2_vi2_vi2(vint2 x, vint2 y) { + vint2 vi = { _mm_or_si128(x.x, y.x), _mm_or_si128(x.y, y.y) }; + return vi; +} + +static INLINE vint2 vxor_vi2_vi2_vi2(vint2 x, vint2 y) { + vint2 vi = { _mm_xor_si128(x.x, y.x), _mm_xor_si128(x.y, y.y) }; + return vi; +} + +static INLINE vint2 vand_vi2_vo_vi2(vopmask x, vint2 y) { return vand_vi2_vi2_vi2(vcast_vi2_vm(x), y); } +static INLINE vint2 vandnot_vi2_vo_vi2(vopmask x, vint2 y) { return vandnot_vi2_vi2_vi2(vcast_vi2_vm(x), y); } + +static INLINE vint2 vsll_vi2_vi2_i(vint2 x, int c) { + vint2 vi = { _mm_slli_epi32(x.x, c), _mm_slli_epi32(x.y, c) }; + return vi; +} + +static INLINE vint2 vsrl_vi2_vi2_i(vint2 x, int c) { + vint2 vi = { _mm_srli_epi32(x.x, c), _mm_srli_epi32(x.y, c) }; + return vi; +} + +static INLINE vint2 vsra_vi2_vi2_i(vint2 x, int c) { + vint2 vi = { _mm_srai_epi32(x.x, c), _mm_srai_epi32(x.y, c) }; + return vi; +} + +static INLINE vopmask veq_vo_vi2_vi2(vint2 x, vint2 y) { + vint2 r; + r.x = _mm_cmpeq_epi32(x.x, y.x); + r.y = _mm_cmpeq_epi32(x.y, y.y); + return vcast_vm_vi2(r); +} + +static INLINE vopmask vgt_vo_vi2_vi2(vint2 x, vint2 y) { + vint2 r; + r.x = _mm_cmpgt_epi32(x.x, y.x); + r.y = _mm_cmpgt_epi32(x.y, y.y); + return vcast_vm_vi2(r); +} + +static INLINE vint2 veq_vi2_vi2_vi2(vint2 x, vint2 y) { + vint2 r; + r.x = _mm_cmpeq_epi32(x.x, y.x); + r.y = _mm_cmpeq_epi32(x.y, y.y); + return r; +} + +static INLINE vint2 vgt_vi2_vi2_vi2(vint2 x, vint2 y) { + vint2 r; + r.x = _mm_cmpgt_epi32(x.x, y.x); + r.y = _mm_cmpgt_epi32(x.y, y.y); + return r; +} + +static INLINE vint2 vsel_vi2_vo_vi2_vi2(vopmask m, vint2 x, vint2 y) { + vint2 n = vcast_vi2_vm(m); + vint2 r = { _mm_blendv_epi8(y.x, x.x, n.x), _mm_blendv_epi8(y.y, x.y, n.y) }; + return r; +} + +static INLINE vmask vadd64_vm_vm_vm(vmask x, vmask y) { + vint2 ix = vcast_vi2_vm(x), iy = vcast_vi2_vm(y), iz; + iz.x = _mm_add_epi64(ix.x, iy.x); + iz.y = _mm_add_epi64(ix.y, iy.y); + return vcast_vm_vi2(iz); +} + +static INLINE vfloat vsel_vf_vo_vf_vf(vopmask o, vfloat x, vfloat y) { return _mm256_blendv_ps(y, x, _mm256_castsi256_ps(o)); } + +static INLINE CONST vfloat vsel_vf_vo_f_f(vopmask o, float v1, float v0) { + return vsel_vf_vo_vf_vf(o, vcast_vf_f(v1), vcast_vf_f(v0)); +} + +static INLINE vfloat vsel_vf_vo_vo_f_f_f(vopmask o0, vopmask o1, float d0, float d1, float d2) { + return vsel_vf_vo_vf_vf(o0, vcast_vf_f(d0), vsel_vf_vo_f_f(o1, d1, d2)); +} + +static INLINE vfloat vsel_vf_vo_vo_vo_f_f_f_f(vopmask o0, vopmask o1, vopmask o2, float d0, float d1, float d2, float d3) { + return vsel_vf_vo_vf_vf(o0, vcast_vf_f(d0), vsel_vf_vo_vf_vf(o1, vcast_vf_f(d1), vsel_vf_vo_f_f(o2, d2, d3))); +} + +static INLINE vopmask visinf_vo_vf(vfloat d) { return veq_vo_vf_vf(vabs_vf_vf(d), vcast_vf_f(SLEEF_INFINITYf)); } +static INLINE vopmask vispinf_vo_vf(vfloat d) { return veq_vo_vf_vf(d, vcast_vf_f(SLEEF_INFINITYf)); } +static INLINE vopmask visminf_vo_vf(vfloat d) { return veq_vo_vf_vf(d, vcast_vf_f(-SLEEF_INFINITYf)); } +static INLINE vopmask visnan_vo_vf(vfloat d) { return vneq_vo_vf_vf(d, d); } + +// + +static INLINE vfloat vload_vf_p(const float *ptr) { return _mm256_load_ps(ptr); } +static INLINE vfloat vloadu_vf_p(const float *ptr) { return _mm256_loadu_ps(ptr); } + +static INLINE void vstore_v_p_vf(float *ptr, vfloat v) { _mm256_store_ps(ptr, v); } +static INLINE void vstoreu_v_p_vf(float *ptr, vfloat v) { _mm256_storeu_ps(ptr, v); } + +static INLINE vfloat vgather_vf_p_vi2(const float *ptr, vint2 vi2) { + int a[VECTLENSP]; + vstoreu_v_p_vi2(a, vi2); + return _mm256_set_ps(ptr[a[7]], ptr[a[6]], ptr[a[5]], ptr[a[4]], + ptr[a[3]], ptr[a[2]], ptr[a[1]], ptr[a[0]]); +} + +#ifdef _MSC_VER +// This function is needed when debugging on MSVC. +static INLINE float vcast_f_vf(vfloat v) { + float a[VECTLENSP]; + vstoreu_v_p_vf(a, v); + return a[0]; +} +#endif +// + +#define PNMASK ((vdouble) { +0.0, -0.0, +0.0, -0.0 }) +#define NPMASK ((vdouble) { -0.0, +0.0, -0.0, +0.0 }) +#define PNMASKf ((vfloat) { +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f }) +#define NPMASKf ((vfloat) { -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f }) + +static INLINE vdouble vposneg_vd_vd(vdouble d) { return vreinterpret_vd_vm(vxor_vm_vm_vm(vreinterpret_vm_vd(d), vreinterpret_vm_vd(PNMASK))); } +static INLINE vdouble vnegpos_vd_vd(vdouble d) { return vreinterpret_vd_vm(vxor_vm_vm_vm(vreinterpret_vm_vd(d), vreinterpret_vm_vd(NPMASK))); } +static INLINE vfloat vposneg_vf_vf(vfloat d) { return vreinterpret_vf_vm(vxor_vm_vm_vm(vreinterpret_vm_vf(d), vreinterpret_vm_vf(PNMASKf))); } +static INLINE vfloat vnegpos_vf_vf(vfloat d) { return vreinterpret_vf_vm(vxor_vm_vm_vm(vreinterpret_vm_vf(d), vreinterpret_vm_vf(NPMASKf))); } + +static INLINE vdouble vsubadd_vd_vd_vd(vdouble x, vdouble y) { return _mm256_addsub_pd(x, y); } +static INLINE vfloat vsubadd_vf_vf_vf(vfloat x, vfloat y) { return _mm256_addsub_ps(x, y); } + +#if CONFIG == 1 +static INLINE vdouble vmlsubadd_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return vsubadd_vd_vd_vd(vmul_vd_vd_vd(x, y), z); } +static INLINE vfloat vmlsubadd_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return vsubadd_vf_vf_vf(vmul_vf_vf_vf(x, y), z); } +#else +static INLINE vdouble vmlsubadd_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return vmla_vd_vd_vd_vd(x, y, vnegpos_vd_vd(z)); } +static INLINE vfloat vmlsubadd_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return vmla_vf_vf_vf_vf(x, y, vnegpos_vf_vf(z)); } +#endif + + +static INLINE vdouble vrev21_vd_vd(vdouble d0) { return _mm256_shuffle_pd(d0, d0, (0 << 3) | (1 << 2) | (0 << 1) | (1 << 0)); } +static INLINE vdouble vreva2_vd_vd(vdouble d0) { d0 = _mm256_permute2f128_pd(d0, d0, 1); return _mm256_shuffle_pd(d0, d0, (1 << 3) | (0 << 2) | (1 << 1) | (0 << 0)); } + +static INLINE void vstream_v_p_vd(double *ptr, vdouble v) { _mm256_stream_pd(ptr, v); } +static INLINE void vscatter2_v_p_i_i_vd(double *ptr, int offset, int step, vdouble v) { + _mm_store_pd(&ptr[(offset + step * 0)*2], _mm256_extractf128_pd(v, 0)); + _mm_store_pd(&ptr[(offset + step * 1)*2], _mm256_extractf128_pd(v, 1)); +} + +static INLINE void vsscatter2_v_p_i_i_vd(double *ptr, int offset, int step, vdouble v) { + _mm_stream_pd(&ptr[(offset + step * 0)*2], _mm256_extractf128_pd(v, 0)); + _mm_stream_pd(&ptr[(offset + step * 1)*2], _mm256_extractf128_pd(v, 1)); +} + +// + +static INLINE vfloat vrev21_vf_vf(vfloat d0) { return _mm256_shuffle_ps(d0, d0, (2 << 6) | (3 << 4) | (0 << 2) | (1 << 0)); } +static INLINE vfloat vreva2_vf_vf(vfloat d0) { d0 = _mm256_permute2f128_ps(d0, d0, 1); return _mm256_shuffle_ps(d0, d0, (1 << 6) | (0 << 4) | (3 << 2) | (2 << 0)); } + +static INLINE void vstream_v_p_vf(float *ptr, vfloat v) { _mm256_stream_ps(ptr, v); } + +static INLINE void vscatter2_v_p_i_i_vf(float *ptr, int offset, int step, vfloat v) { + _mm_storel_pd((double *)(ptr+(offset + step * 0)*2), _mm_castsi128_pd(_mm_castps_si128(_mm256_extractf128_ps(v, 0)))); + _mm_storeh_pd((double *)(ptr+(offset + step * 1)*2), _mm_castsi128_pd(_mm_castps_si128(_mm256_extractf128_ps(v, 0)))); + _mm_storel_pd((double *)(ptr+(offset + step * 2)*2), _mm_castsi128_pd(_mm_castps_si128(_mm256_extractf128_ps(v, 1)))); + _mm_storeh_pd((double *)(ptr+(offset + step * 3)*2), _mm_castsi128_pd(_mm_castps_si128(_mm256_extractf128_ps(v, 1)))); +} + +static INLINE void vsscatter2_v_p_i_i_vf(float *ptr, int offset, int step, vfloat v) { vscatter2_v_p_i_i_vf(ptr, offset, step, v); } + +// + +static vquad loadu_vq_p(void *p) { + vquad vq; + memcpy(&vq, p, VECTLENDP * 16); + return vq; +} + +static INLINE vquad cast_vq_aq(vargquad aq) { + vquad vq; + memcpy(&vq, &aq, VECTLENDP * 16); + return vq; +} + +static INLINE vargquad cast_aq_vq(vquad vq) { + vargquad aq; + memcpy(&aq, &vq, VECTLENDP * 16); + return aq; +} + +static INLINE int vtestallzeros_i_vo64(vopmask g) { + return _mm_movemask_epi8(_mm_or_si128(_mm256_extractf128_si256(g, 0), _mm256_extractf128_si256(g, 1))) == 0; +} + +static INLINE vmask vsel_vm_vo64_vm_vm(vopmask o, vmask x, vmask y) { + return vreinterpret_vm_vd(_mm256_blendv_pd(vreinterpret_vd_vm(y), vreinterpret_vd_vm(x), vreinterpret_vd_vm(o))); +} + +static INLINE vmask vsub64_vm_vm_vm(vmask x, vmask y) { + __m128i xh = _mm256_extractf128_si256(x, 1), xl = _mm256_extractf128_si256(x, 0); + __m128i yh = _mm256_extractf128_si256(y, 1), yl = _mm256_extractf128_si256(y, 0); + vmask r = _mm256_castsi128_si256(_mm_sub_epi64(xl, yl)); + return _mm256_insertf128_si256(r, _mm_sub_epi64(xh, yh), 1); +} + +static INLINE vmask vneg64_vm_vm(vmask x) { return vsub64_vm_vm_vm(vcast_vm_i_i(0, 0), x); } +static INLINE vopmask vgt64_vo_vm_vm(vmask x, vmask y) { + __m128i xh = _mm256_extractf128_si256(x, 1), xl = _mm256_extractf128_si256(x, 0); + __m128i yh = _mm256_extractf128_si256(y, 1), yl = _mm256_extractf128_si256(y, 0); + vmask r = _mm256_castsi128_si256(_mm_cmpgt_epi64(xl, yl)); + return _mm256_insertf128_si256(r, _mm_cmpgt_epi64(xh, yh), 1); +} + +#define vsll64_vm_vm_i(x, c) \ + _mm256_insertf128_si256(_mm256_castsi128_si256(_mm_slli_epi64(_mm256_extractf128_si256(x, 0), c)), \ + _mm_slli_epi64(_mm256_extractf128_si256(x, 1), c), 1) +#define vsrl64_vm_vm_i(x, c) \ + _mm256_insertf128_si256(_mm256_castsi128_si256(_mm_srli_epi64(_mm256_extractf128_si256(x, 0), c)), \ + _mm_srli_epi64(_mm256_extractf128_si256(x, 1), c), 1) + +//@#define vsll64_vm_vm_i(x, c) _mm256_insertf128_si256(_mm256_castsi128_si256(_mm_slli_epi64(_mm256_extractf128_si256(x, 0), c)), _mm_slli_epi64(_mm256_extractf128_si256(x, 1), c), 1) +//@#define vsrl64_vm_vm_i(x, c) _mm256_insertf128_si256(_mm256_castsi128_si256(_mm_srli_epi64(_mm256_extractf128_si256(x, 0), c)), _mm_srli_epi64(_mm256_extractf128_si256(x, 1), c), 1) + +static INLINE vmask vcast_vm_vi(vint vi) { + vint vi0 = _mm_and_si128(_mm_shuffle_epi32(vi, (1 << 4) | (1 << 6)), _mm_set_epi32(0, -1, 0, -1)); + vint vi1 = _mm_and_si128(_mm_shuffle_epi32(vi, (2 << 0) | (2 << 2) | (3 << 4) | (3 << 6)), _mm_set_epi32(0, -1, 0, -1)); + vmask m = _mm256_insertf128_si256(_mm256_castsi128_si256(vi0), vi1, 1); + return vor_vm_vm_vm(vcastu_vm_vi(vand_vi_vo_vi(vgt_vo_vi_vi(vcast_vi_i(0), vi), vcast_vi_i(-1))), m); +} +static INLINE vint vcast_vi_vm(vmask vm) { + return _mm_or_si128(_mm_castps_si128(_mm_shuffle_ps(_mm_castsi128_ps(_mm256_castsi256_si128(vm)), _mm_set1_ps(0), 0x08)), + _mm_castps_si128(_mm_shuffle_ps(_mm_set1_ps(0), _mm_castsi128_ps(_mm256_extractf128_si256(vm, 1)), 0x80))); +} + +static INLINE vmask vreinterpret_vm_vi64(vint64 v) { return v; } +static INLINE vint64 vreinterpret_vi64_vm(vmask m) { return m; } +static INLINE vmask vreinterpret_vm_vu64(vuint64 v) { return v; } +static INLINE vuint64 vreinterpret_vu64_vm(vmask m) { return m; } diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/arch/helperavx2.h b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/arch/helperavx2.h new file mode 100644 index 00000000000..4c0c5422170 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/arch/helperavx2.h @@ -0,0 +1,485 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#if CONFIG == 1 + +#if !defined(__AVX2__) && !defined(SLEEF_GENHEADER) +#error Please specify -mavx2. +#endif + +#else +#error CONFIG macro invalid or not defined +#endif + +#define ENABLE_DP +//@#define ENABLE_DP +#define LOG2VECTLENDP 2 +//@#define LOG2VECTLENDP 2 +#define VECTLENDP (1 << LOG2VECTLENDP) +//@#define VECTLENDP (1 << LOG2VECTLENDP) +#define ENABLE_FMA_DP +//@#define ENABLE_FMA_DP + +#define ENABLE_SP +//@#define ENABLE_SP +#define LOG2VECTLENSP (LOG2VECTLENDP+1) +//@#define LOG2VECTLENSP (LOG2VECTLENDP+1) +#define VECTLENSP (1 << LOG2VECTLENSP) +//@#define VECTLENSP (1 << LOG2VECTLENSP) +#define ENABLE_FMA_SP +//@#define ENABLE_FMA_SP + +#define FULL_FP_ROUNDING +//@#define FULL_FP_ROUNDING +#define ACCURATE_SQRT +//@#define ACCURATE_SQRT + +#if !defined(SLEEF_GENHEADER) +#if defined(_MSC_VER) +#include +#else +#include +#endif + +#include +#include "misc.h" +#endif // #if !defined(SLEEF_GENHEADER) + +typedef __m256i vmask; +typedef __m256i vopmask; + +typedef __m256d vdouble; +typedef __m128i vint; + +typedef __m256 vfloat; +typedef __m256i vint2; + +typedef __m256i vint64; +typedef __m256i vuint64; + +typedef struct { + vmask x, y; +} vquad; + +typedef vquad vargquad; + +// + +#if !defined(SLEEF_GENHEADER) + +#ifndef __SLEEF_H__ +void Sleef_x86CpuID(int32_t out[4], uint32_t eax, uint32_t ecx); +#endif + +static INLINE int cpuSupportsAVX2() { + int32_t reg[4]; + Sleef_x86CpuID(reg, 7, 0); + return (reg[1] & (1 << 5)) != 0; +} + +static INLINE int cpuSupportsFMA() { + int32_t reg[4]; + Sleef_x86CpuID(reg, 1, 0); + return (reg[2] & (1 << 12)) != 0; +} + +#if CONFIG == 1 && defined(__AVX2__) +static INLINE int vavailability_i(int name) { + int d = cpuSupportsAVX2() && cpuSupportsFMA(); + return d ? 3 : 0; +} +#define ISANAME "AVX2" +#define DFTPRIORITY 25 +#endif + +#endif // #if !defined(SLEEF_GENHEADER) + +static INLINE void vprefetch_v_p(const void *ptr) { _mm_prefetch(ptr, _MM_HINT_T0); } + +static INLINE int vtestallones_i_vo32(vopmask g) { + return _mm_test_all_ones(_mm_and_si128(_mm256_extractf128_si256(g, 0), _mm256_extractf128_si256(g, 1))); +} + +static INLINE int vtestallones_i_vo64(vopmask g) { + return _mm_test_all_ones(_mm_and_si128(_mm256_extractf128_si256(g, 0), _mm256_extractf128_si256(g, 1))); +} + +// + +static INLINE vdouble vcast_vd_d(double d) { return _mm256_set1_pd(d); } +static INLINE vmask vreinterpret_vm_vd(vdouble vd) { return _mm256_castpd_si256(vd); } +static INLINE vdouble vreinterpret_vd_vm(vmask vm) { return _mm256_castsi256_pd(vm); } + +// + +static vint2 vloadu_vi2_p(int32_t *p) { return _mm256_loadu_si256((__m256i const *)p); } +static void vstoreu_v_p_vi2(int32_t *p, vint2 v) { _mm256_storeu_si256((__m256i *)p, v); } +static vint vloadu_vi_p(int32_t *p) { return _mm_loadu_si128((__m128i *)p); } +static void vstoreu_v_p_vi(int32_t *p, vint v) { _mm_storeu_si128((__m128i *)p, v); } + +// + +static INLINE vmask vand_vm_vm_vm(vmask x, vmask y) { return vreinterpret_vm_vd(_mm256_and_pd(vreinterpret_vd_vm(x), vreinterpret_vd_vm(y))); } +static INLINE vmask vandnot_vm_vm_vm(vmask x, vmask y) { return vreinterpret_vm_vd(_mm256_andnot_pd(vreinterpret_vd_vm(x), vreinterpret_vd_vm(y))); } +static INLINE vmask vor_vm_vm_vm(vmask x, vmask y) { return vreinterpret_vm_vd(_mm256_or_pd(vreinterpret_vd_vm(x), vreinterpret_vd_vm(y))); } +static INLINE vmask vxor_vm_vm_vm(vmask x, vmask y) { return vreinterpret_vm_vd(_mm256_xor_pd(vreinterpret_vd_vm(x), vreinterpret_vd_vm(y))); } + +static INLINE vopmask vand_vo_vo_vo(vopmask x, vopmask y) { return vreinterpret_vm_vd(_mm256_and_pd(vreinterpret_vd_vm(x), vreinterpret_vd_vm(y))); } +static INLINE vopmask vandnot_vo_vo_vo(vopmask x, vopmask y) { return vreinterpret_vm_vd(_mm256_andnot_pd(vreinterpret_vd_vm(x), vreinterpret_vd_vm(y))); } +static INLINE vopmask vor_vo_vo_vo(vopmask x, vopmask y) { return vreinterpret_vm_vd(_mm256_or_pd(vreinterpret_vd_vm(x), vreinterpret_vd_vm(y))); } +static INLINE vopmask vxor_vo_vo_vo(vopmask x, vopmask y) { return vreinterpret_vm_vd(_mm256_xor_pd(vreinterpret_vd_vm(x), vreinterpret_vd_vm(y))); } + +static INLINE vmask vand_vm_vo64_vm(vopmask x, vmask y) { return vreinterpret_vm_vd(_mm256_and_pd(vreinterpret_vd_vm(x), vreinterpret_vd_vm(y))); } +static INLINE vmask vandnot_vm_vo64_vm(vopmask x, vmask y) { return vreinterpret_vm_vd(_mm256_andnot_pd(vreinterpret_vd_vm(x), vreinterpret_vd_vm(y))); } +static INLINE vmask vor_vm_vo64_vm(vopmask x, vmask y) { return vreinterpret_vm_vd(_mm256_or_pd(vreinterpret_vd_vm(x), vreinterpret_vd_vm(y))); } +static INLINE vmask vxor_vm_vo64_vm(vopmask x, vmask y) { return vreinterpret_vm_vd(_mm256_xor_pd(vreinterpret_vd_vm(x), vreinterpret_vd_vm(y))); } + +static INLINE vmask vand_vm_vo32_vm(vopmask x, vmask y) { return vreinterpret_vm_vd(_mm256_and_pd(vreinterpret_vd_vm(x), vreinterpret_vd_vm(y))); } +static INLINE vmask vandnot_vm_vo32_vm(vopmask x, vmask y) { return vreinterpret_vm_vd(_mm256_andnot_pd(vreinterpret_vd_vm(x), vreinterpret_vd_vm(y))); } +static INLINE vmask vor_vm_vo32_vm(vopmask x, vmask y) { return vreinterpret_vm_vd(_mm256_or_pd(vreinterpret_vd_vm(x), vreinterpret_vd_vm(y))); } +static INLINE vmask vxor_vm_vo32_vm(vopmask x, vmask y) { return vreinterpret_vm_vd(_mm256_xor_pd(vreinterpret_vd_vm(x), vreinterpret_vd_vm(y))); } + +static INLINE vopmask vcast_vo32_vo64(vopmask o) { + return _mm256_permutevar8x32_epi32(o, _mm256_set_epi32(0, 0, 0, 0, 6, 4, 2, 0)); +} + +static INLINE vopmask vcast_vo64_vo32(vopmask o) { + return _mm256_permutevar8x32_epi32(o, _mm256_set_epi32(3, 3, 2, 2, 1, 1, 0, 0)); +} + +static INLINE vopmask vcast_vo_i(int i) { return _mm256_set1_epi64x(i ? -1 : 0); } + +// + +static INLINE vint vrint_vi_vd(vdouble vd) { return _mm256_cvtpd_epi32(vd); } +static INLINE vint vtruncate_vi_vd(vdouble vd) { return _mm256_cvttpd_epi32(vd); } +static INLINE vdouble vrint_vd_vd(vdouble vd) { return _mm256_round_pd(vd, _MM_FROUND_TO_NEAREST_INT |_MM_FROUND_NO_EXC); } +static INLINE vfloat vrint_vf_vf(vfloat vd) { return _mm256_round_ps(vd, _MM_FROUND_TO_NEAREST_INT |_MM_FROUND_NO_EXC); } +static INLINE vdouble vtruncate_vd_vd(vdouble vd) { return _mm256_round_pd(vd, _MM_FROUND_TO_ZERO |_MM_FROUND_NO_EXC); } +static INLINE vfloat vtruncate_vf_vf(vfloat vf) { return _mm256_round_ps(vf, _MM_FROUND_TO_ZERO |_MM_FROUND_NO_EXC); } +static INLINE vdouble vcast_vd_vi(vint vi) { return _mm256_cvtepi32_pd(vi); } +static INLINE vint vcast_vi_i(int i) { return _mm_set1_epi32(i); } + +static INLINE vmask vcastu_vm_vi(vint vi) { + return _mm256_slli_epi64(_mm256_cvtepi32_epi64(vi), 32); +} + +static INLINE vint vcastu_vi_vm(vmask vi) { + return _mm_or_si128(_mm_castps_si128(_mm_shuffle_ps(_mm_castsi128_ps(_mm256_castsi256_si128(vi)), _mm_set1_ps(0), 0x0d)), + _mm_castps_si128(_mm_shuffle_ps(_mm_set1_ps(0), _mm_castsi128_ps(_mm256_extractf128_si256(vi, 1)), 0xd0))); +} + +static INLINE vmask vcast_vm_i_i(int i0, int i1) { + return _mm256_set_epi32(i0, i1, i0, i1, i0, i1, i0, i1); +} + +static INLINE vmask vcast_vm_i64(int64_t i) { return _mm256_set1_epi64x(i); } +static INLINE vmask vcast_vm_u64(uint64_t i) { return _mm256_set1_epi64x((uint64_t)i); } + +static INLINE vopmask veq64_vo_vm_vm(vmask x, vmask y) { return _mm256_cmpeq_epi64(x, y); } +static INLINE vmask vadd64_vm_vm_vm(vmask x, vmask y) { return _mm256_add_epi64(x, y); } + +// + +static INLINE vdouble vadd_vd_vd_vd(vdouble x, vdouble y) { return _mm256_add_pd(x, y); } +static INLINE vdouble vsub_vd_vd_vd(vdouble x, vdouble y) { return _mm256_sub_pd(x, y); } +static INLINE vdouble vmul_vd_vd_vd(vdouble x, vdouble y) { return _mm256_mul_pd(x, y); } +static INLINE vdouble vdiv_vd_vd_vd(vdouble x, vdouble y) { return _mm256_div_pd(x, y); } +static INLINE vdouble vrec_vd_vd(vdouble x) { return _mm256_div_pd(_mm256_set1_pd(1), x); } +static INLINE vdouble vsqrt_vd_vd(vdouble x) { return _mm256_sqrt_pd(x); } +static INLINE vdouble vabs_vd_vd(vdouble d) { return _mm256_andnot_pd(_mm256_set1_pd(-0.0), d); } +static INLINE vdouble vneg_vd_vd(vdouble d) { return _mm256_xor_pd(_mm256_set1_pd(-0.0), d); } +static INLINE vdouble vmla_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return _mm256_fmadd_pd(x, y, z); } +static INLINE vdouble vmlapn_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return _mm256_fmsub_pd(x, y, z); } +static INLINE vdouble vmlanp_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return _mm256_fnmadd_pd(x, y, z); } +static INLINE vdouble vmax_vd_vd_vd(vdouble x, vdouble y) { return _mm256_max_pd(x, y); } +static INLINE vdouble vmin_vd_vd_vd(vdouble x, vdouble y) { return _mm256_min_pd(x, y); } + +static INLINE vdouble vfma_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return _mm256_fmadd_pd(x, y, z); } +static INLINE vdouble vfmapp_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return _mm256_fmadd_pd(x, y, z); } +static INLINE vdouble vfmapn_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return _mm256_fmsub_pd(x, y, z); } +static INLINE vdouble vfmanp_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return _mm256_fnmadd_pd(x, y, z); } +static INLINE vdouble vfmann_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return _mm256_fnmsub_pd(x, y, z); } + +static INLINE vopmask veq_vo_vd_vd(vdouble x, vdouble y) { return vreinterpret_vm_vd(_mm256_cmp_pd(x, y, _CMP_EQ_OQ)); } +static INLINE vopmask vneq_vo_vd_vd(vdouble x, vdouble y) { return vreinterpret_vm_vd(_mm256_cmp_pd(x, y, _CMP_NEQ_UQ)); } +static INLINE vopmask vlt_vo_vd_vd(vdouble x, vdouble y) { return vreinterpret_vm_vd(_mm256_cmp_pd(x, y, _CMP_LT_OQ)); } +static INLINE vopmask vle_vo_vd_vd(vdouble x, vdouble y) { return vreinterpret_vm_vd(_mm256_cmp_pd(x, y, _CMP_LE_OQ)); } +static INLINE vopmask vgt_vo_vd_vd(vdouble x, vdouble y) { return vreinterpret_vm_vd(_mm256_cmp_pd(x, y, _CMP_GT_OQ)); } +static INLINE vopmask vge_vo_vd_vd(vdouble x, vdouble y) { return vreinterpret_vm_vd(_mm256_cmp_pd(x, y, _CMP_GE_OQ)); } + +// + +static INLINE vint vadd_vi_vi_vi(vint x, vint y) { return _mm_add_epi32(x, y); } +static INLINE vint vsub_vi_vi_vi(vint x, vint y) { return _mm_sub_epi32(x, y); } +static INLINE vint vneg_vi_vi(vint e) { return vsub_vi_vi_vi(vcast_vi_i(0), e); } + +static INLINE vint vand_vi_vi_vi(vint x, vint y) { return _mm_and_si128(x, y); } +static INLINE vint vandnot_vi_vi_vi(vint x, vint y) { return _mm_andnot_si128(x, y); } +static INLINE vint vor_vi_vi_vi(vint x, vint y) { return _mm_or_si128(x, y); } +static INLINE vint vxor_vi_vi_vi(vint x, vint y) { return _mm_xor_si128(x, y); } + +static INLINE vint vandnot_vi_vo_vi(vopmask m, vint y) { return _mm_andnot_si128(_mm256_castsi256_si128(m), y); } +static INLINE vint vand_vi_vo_vi(vopmask m, vint y) { return _mm_and_si128(_mm256_castsi256_si128(m), y); } + +static INLINE vint vsll_vi_vi_i(vint x, int c) { return _mm_slli_epi32(x, c); } +static INLINE vint vsrl_vi_vi_i(vint x, int c) { return _mm_srli_epi32(x, c); } +static INLINE vint vsra_vi_vi_i(vint x, int c) { return _mm_srai_epi32(x, c); } + +static INLINE vint veq_vi_vi_vi(vint x, vint y) { return _mm_cmpeq_epi32(x, y); } +static INLINE vint vgt_vi_vi_vi(vint x, vint y) { return _mm_cmpgt_epi32(x, y); } + +static INLINE vopmask veq_vo_vi_vi(vint x, vint y) { return _mm256_castsi128_si256(_mm_cmpeq_epi32(x, y)); } +static INLINE vopmask vgt_vo_vi_vi(vint x, vint y) { return _mm256_castsi128_si256(_mm_cmpgt_epi32(x, y)); } + +static INLINE vint vsel_vi_vo_vi_vi(vopmask m, vint x, vint y) { return _mm_blendv_epi8(y, x, _mm256_castsi256_si128(m)); } + +static INLINE vdouble vsel_vd_vo_vd_vd(vopmask o, vdouble x, vdouble y) { return _mm256_blendv_pd(y, x, _mm256_castsi256_pd(o)); } +static INLINE vdouble vsel_vd_vo_d_d(vopmask o, double v1, double v0) { return _mm256_permutevar_pd(_mm256_set_pd(v1, v0, v1, v0), o); } + +static INLINE vdouble vsel_vd_vo_vo_vo_d_d_d_d(vopmask o0, vopmask o1, vopmask o2, double d0, double d1, double d2, double d3) { + __m256i v = _mm256_castpd_si256(vsel_vd_vo_vd_vd(o0, _mm256_castsi256_pd(_mm256_set_epi32(1, 0, 1, 0, 1, 0, 1, 0)), + vsel_vd_vo_vd_vd(o1, _mm256_castsi256_pd(_mm256_set_epi32(3, 2, 3, 2, 3, 2, 3, 2)), + vsel_vd_vo_vd_vd(o2, _mm256_castsi256_pd(_mm256_set_epi32(5, 4, 5, 4, 5, 4, 5, 4)), + _mm256_castsi256_pd(_mm256_set_epi32(7, 6, 7, 6, 7, 6, 7, 6)))))); + return _mm256_castsi256_pd(_mm256_permutevar8x32_epi32(_mm256_castpd_si256(_mm256_set_pd(d3, d2, d1, d0)), v)); +} + +static INLINE vdouble vsel_vd_vo_vo_d_d_d(vopmask o0, vopmask o1, double d0, double d1, double d2) { + return vsel_vd_vo_vo_vo_d_d_d_d(o0, o1, o1, d0, d1, d2, d2); +} + +static INLINE vopmask visinf_vo_vd(vdouble d) { + return vreinterpret_vm_vd(_mm256_cmp_pd(vabs_vd_vd(d), _mm256_set1_pd(SLEEF_INFINITY), _CMP_EQ_OQ)); +} + +static INLINE vopmask vispinf_vo_vd(vdouble d) { + return vreinterpret_vm_vd(_mm256_cmp_pd(d, _mm256_set1_pd(SLEEF_INFINITY), _CMP_EQ_OQ)); +} + +static INLINE vopmask visminf_vo_vd(vdouble d) { + return vreinterpret_vm_vd(_mm256_cmp_pd(d, _mm256_set1_pd(-SLEEF_INFINITY), _CMP_EQ_OQ)); +} + +static INLINE vopmask visnan_vo_vd(vdouble d) { + return vreinterpret_vm_vd(_mm256_cmp_pd(d, d, _CMP_NEQ_UQ)); +} + +#if defined(_MSC_VER) +// This function is needed when debugging on MSVC. +static INLINE double vcast_d_vd(vdouble v) { + double s[4]; + _mm256_storeu_pd(s, v); + return s[0]; +} +#endif + +static INLINE vdouble vload_vd_p(const double *ptr) { return _mm256_load_pd(ptr); } +static INLINE vdouble vloadu_vd_p(const double *ptr) { return _mm256_loadu_pd(ptr); } + +static INLINE void vstore_v_p_vd(double *ptr, vdouble v) { _mm256_store_pd(ptr, v); } +static INLINE void vstoreu_v_p_vd(double *ptr, vdouble v) { _mm256_storeu_pd(ptr, v); } + +static INLINE vdouble vgather_vd_p_vi(const double *ptr, vint vi) { return _mm256_i32gather_pd(ptr, vi, 8); } + +// + +static INLINE vint2 vcast_vi2_vm(vmask vm) { return vm; } +static INLINE vmask vcast_vm_vi2(vint2 vi) { return vi; } + +static INLINE vint2 vrint_vi2_vf(vfloat vf) { return vcast_vi2_vm(_mm256_cvtps_epi32(vf)); } +static INLINE vint2 vtruncate_vi2_vf(vfloat vf) { return vcast_vi2_vm(_mm256_cvttps_epi32(vf)); } +static INLINE vfloat vcast_vf_vi2(vint2 vi) { return _mm256_cvtepi32_ps(vcast_vm_vi2(vi)); } +static INLINE vfloat vcast_vf_f(float f) { return _mm256_set1_ps(f); } +static INLINE vint2 vcast_vi2_i(int i) { return _mm256_set1_epi32(i); } +static INLINE vmask vreinterpret_vm_vf(vfloat vf) { return _mm256_castps_si256(vf); } +static INLINE vfloat vreinterpret_vf_vm(vmask vm) { return _mm256_castsi256_ps(vm); } + +static INLINE vfloat vreinterpret_vf_vi2(vint2 vi) { return vreinterpret_vf_vm(vcast_vm_vi2(vi)); } +static INLINE vint2 vreinterpret_vi2_vf(vfloat vf) { return vcast_vi2_vm(vreinterpret_vm_vf(vf)); } + +static INLINE vfloat vadd_vf_vf_vf(vfloat x, vfloat y) { return _mm256_add_ps(x, y); } +static INLINE vfloat vsub_vf_vf_vf(vfloat x, vfloat y) { return _mm256_sub_ps(x, y); } +static INLINE vfloat vmul_vf_vf_vf(vfloat x, vfloat y) { return _mm256_mul_ps(x, y); } +static INLINE vfloat vdiv_vf_vf_vf(vfloat x, vfloat y) { return _mm256_div_ps(x, y); } +static INLINE vfloat vrec_vf_vf(vfloat x) { return vdiv_vf_vf_vf(vcast_vf_f(1.0f), x); } +static INLINE vfloat vsqrt_vf_vf(vfloat x) { return _mm256_sqrt_ps(x); } +static INLINE vfloat vabs_vf_vf(vfloat f) { return vreinterpret_vf_vm(vandnot_vm_vm_vm(vreinterpret_vm_vf(vcast_vf_f(-0.0f)), vreinterpret_vm_vf(f))); } +static INLINE vfloat vneg_vf_vf(vfloat d) { return vreinterpret_vf_vm(vxor_vm_vm_vm(vreinterpret_vm_vf(vcast_vf_f(-0.0f)), vreinterpret_vm_vf(d))); } +static INLINE vfloat vmla_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return _mm256_fmadd_ps(x, y, z); } +static INLINE vfloat vmlapn_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return _mm256_fmsub_ps(x, y, z); } +static INLINE vfloat vmlanp_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return _mm256_fnmadd_ps(x, y, z); } +static INLINE vfloat vmax_vf_vf_vf(vfloat x, vfloat y) { return _mm256_max_ps(x, y); } +static INLINE vfloat vmin_vf_vf_vf(vfloat x, vfloat y) { return _mm256_min_ps(x, y); } + +static INLINE vfloat vfma_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return _mm256_fmadd_ps(x, y, z); } +static INLINE vfloat vfmapp_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return _mm256_fmadd_ps(x, y, z); } +static INLINE vfloat vfmapn_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return _mm256_fmsub_ps(x, y, z); } +static INLINE vfloat vfmanp_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return _mm256_fnmadd_ps(x, y, z); } +static INLINE vfloat vfmann_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return _mm256_fnmsub_ps(x, y, z); } + +static INLINE vopmask veq_vo_vf_vf(vfloat x, vfloat y) { return vreinterpret_vm_vf(_mm256_cmp_ps(x, y, _CMP_EQ_OQ)); } +static INLINE vopmask vneq_vo_vf_vf(vfloat x, vfloat y) { return vreinterpret_vm_vf(_mm256_cmp_ps(x, y, _CMP_NEQ_UQ)); } +static INLINE vopmask vlt_vo_vf_vf(vfloat x, vfloat y) { return vreinterpret_vm_vf(_mm256_cmp_ps(x, y, _CMP_LT_OQ)); } +static INLINE vopmask vle_vo_vf_vf(vfloat x, vfloat y) { return vreinterpret_vm_vf(_mm256_cmp_ps(x, y, _CMP_LE_OQ)); } +static INLINE vopmask vgt_vo_vf_vf(vfloat x, vfloat y) { return vreinterpret_vm_vf(_mm256_cmp_ps(x, y, _CMP_GT_OQ)); } +static INLINE vopmask vge_vo_vf_vf(vfloat x, vfloat y) { return vreinterpret_vm_vf(_mm256_cmp_ps(x, y, _CMP_GE_OQ)); } + +static INLINE vint2 vadd_vi2_vi2_vi2(vint2 x, vint2 y) { return _mm256_add_epi32(x, y); } +static INLINE vint2 vsub_vi2_vi2_vi2(vint2 x, vint2 y) { return _mm256_sub_epi32(x, y); } +static INLINE vint2 vneg_vi2_vi2(vint2 e) { return vsub_vi2_vi2_vi2(vcast_vi2_i(0), e); } + +static INLINE vint2 vand_vi2_vi2_vi2(vint2 x, vint2 y) { return _mm256_and_si256(x, y); } +static INLINE vint2 vandnot_vi2_vi2_vi2(vint2 x, vint2 y) { return _mm256_andnot_si256(x, y); } +static INLINE vint2 vor_vi2_vi2_vi2(vint2 x, vint2 y) { return _mm256_or_si256(x, y); } +static INLINE vint2 vxor_vi2_vi2_vi2(vint2 x, vint2 y) { return _mm256_xor_si256(x, y); } + +static INLINE vint2 vand_vi2_vo_vi2(vopmask x, vint2 y) { return vand_vi2_vi2_vi2(vcast_vi2_vm(x), y); } +static INLINE vint2 vandnot_vi2_vo_vi2(vopmask x, vint2 y) { return vandnot_vi2_vi2_vi2(vcast_vi2_vm(x), y); } + +static INLINE vint2 vsll_vi2_vi2_i(vint2 x, int c) { return _mm256_slli_epi32(x, c); } +static INLINE vint2 vsrl_vi2_vi2_i(vint2 x, int c) { return _mm256_srli_epi32(x, c); } +static INLINE vint2 vsra_vi2_vi2_i(vint2 x, int c) { return _mm256_srai_epi32(x, c); } + +static INLINE vopmask veq_vo_vi2_vi2(vint2 x, vint2 y) { return _mm256_cmpeq_epi32(x, y); } +static INLINE vopmask vgt_vo_vi2_vi2(vint2 x, vint2 y) { return _mm256_cmpgt_epi32(x, y); } +static INLINE vint2 veq_vi2_vi2_vi2(vint2 x, vint2 y) { return _mm256_cmpeq_epi32(x, y); } +static INLINE vint2 vgt_vi2_vi2_vi2(vint2 x, vint2 y) { return _mm256_cmpgt_epi32(x, y); } + +static INLINE vint2 vsel_vi2_vo_vi2_vi2(vopmask m, vint2 x, vint2 y) { + return _mm256_blendv_epi8(y, x, m); +} + +static INLINE vfloat vsel_vf_vo_vf_vf(vopmask o, vfloat x, vfloat y) { return _mm256_blendv_ps(y, x, _mm256_castsi256_ps(o)); } + +// At this point, the following three functions are implemented in a generic way, +// but I will try target-specific optimization later on. +static INLINE CONST vfloat vsel_vf_vo_f_f(vopmask o, float v1, float v0) { + return vsel_vf_vo_vf_vf(o, vcast_vf_f(v1), vcast_vf_f(v0)); +} + +static INLINE vfloat vsel_vf_vo_vo_f_f_f(vopmask o0, vopmask o1, float d0, float d1, float d2) { + return vsel_vf_vo_vf_vf(o0, vcast_vf_f(d0), vsel_vf_vo_f_f(o1, d1, d2)); +} + +static INLINE vfloat vsel_vf_vo_vo_vo_f_f_f_f(vopmask o0, vopmask o1, vopmask o2, float d0, float d1, float d2, float d3) { + return vsel_vf_vo_vf_vf(o0, vcast_vf_f(d0), vsel_vf_vo_vf_vf(o1, vcast_vf_f(d1), vsel_vf_vo_f_f(o2, d2, d3))); +} + +static INLINE vopmask visinf_vo_vf(vfloat d) { return veq_vo_vf_vf(vabs_vf_vf(d), vcast_vf_f(SLEEF_INFINITYf)); } +static INLINE vopmask vispinf_vo_vf(vfloat d) { return veq_vo_vf_vf(d, vcast_vf_f(SLEEF_INFINITYf)); } +static INLINE vopmask visminf_vo_vf(vfloat d) { return veq_vo_vf_vf(d, vcast_vf_f(-SLEEF_INFINITYf)); } +static INLINE vopmask visnan_vo_vf(vfloat d) { return vneq_vo_vf_vf(d, d); } + +#ifdef _MSC_VER +// This function is needed when debugging on MSVC. +static INLINE float vcast_f_vf(vfloat v) { + float s[8]; + _mm256_storeu_ps(s, v); + return s[0]; +} +#endif + +static INLINE vfloat vload_vf_p(const float *ptr) { return _mm256_load_ps(ptr); } +static INLINE vfloat vloadu_vf_p(const float *ptr) { return _mm256_loadu_ps(ptr); } + +static INLINE void vstore_v_p_vf(float *ptr, vfloat v) { _mm256_store_ps(ptr, v); } +static INLINE void vstoreu_v_p_vf(float *ptr, vfloat v) { _mm256_storeu_ps(ptr, v); } + +static INLINE vfloat vgather_vf_p_vi2(const float *ptr, vint2 vi2) { return _mm256_i32gather_ps(ptr, vi2, 4); } + +// + +#define PNMASK ((vdouble) { +0.0, -0.0, +0.0, -0.0 }) +#define NPMASK ((vdouble) { -0.0, +0.0, -0.0, +0.0 }) +#define PNMASKf ((vfloat) { +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f }) +#define NPMASKf ((vfloat) { -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f }) + +static INLINE vdouble vposneg_vd_vd(vdouble d) { return vreinterpret_vd_vm(vxor_vm_vm_vm(vreinterpret_vm_vd(d), vreinterpret_vm_vd(PNMASK))); } +static INLINE vdouble vnegpos_vd_vd(vdouble d) { return vreinterpret_vd_vm(vxor_vm_vm_vm(vreinterpret_vm_vd(d), vreinterpret_vm_vd(NPMASK))); } +static INLINE vfloat vposneg_vf_vf(vfloat d) { return vreinterpret_vf_vm(vxor_vm_vm_vm(vreinterpret_vm_vf(d), vreinterpret_vm_vf(PNMASKf))); } +static INLINE vfloat vnegpos_vf_vf(vfloat d) { return vreinterpret_vf_vm(vxor_vm_vm_vm(vreinterpret_vm_vf(d), vreinterpret_vm_vf(NPMASKf))); } + +static INLINE vdouble vsubadd_vd_vd_vd(vdouble x, vdouble y) { return _mm256_addsub_pd(x, y); } +static INLINE vfloat vsubadd_vf_vf_vf(vfloat x, vfloat y) { return _mm256_addsub_ps(x, y); } + +static INLINE vdouble vmlsubadd_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return vmla_vd_vd_vd_vd(x, y, vnegpos_vd_vd(z)); } +static INLINE vfloat vmlsubadd_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return vmla_vf_vf_vf_vf(x, y, vnegpos_vf_vf(z)); } + +static INLINE vdouble vrev21_vd_vd(vdouble d0) { return _mm256_shuffle_pd(d0, d0, (0 << 3) | (1 << 2) | (0 << 1) | (1 << 0)); } +static INLINE vdouble vreva2_vd_vd(vdouble d0) { d0 = _mm256_permute2f128_pd(d0, d0, 1); return _mm256_shuffle_pd(d0, d0, (1 << 3) | (0 << 2) | (1 << 1) | (0 << 0)); } + +static INLINE void vstream_v_p_vd(double *ptr, vdouble v) { _mm256_stream_pd(ptr, v); } +static INLINE void vscatter2_v_p_i_i_vd(double *ptr, int offset, int step, vdouble v) { + _mm_store_pd(&ptr[(offset + step * 0)*2], _mm256_extractf128_pd(v, 0)); + _mm_store_pd(&ptr[(offset + step * 1)*2], _mm256_extractf128_pd(v, 1)); +} + +static INLINE void vsscatter2_v_p_i_i_vd(double *ptr, int offset, int step, vdouble v) { + _mm_stream_pd(&ptr[(offset + step * 0)*2], _mm256_extractf128_pd(v, 0)); + _mm_stream_pd(&ptr[(offset + step * 1)*2], _mm256_extractf128_pd(v, 1)); +} + +// + +static INLINE vfloat vrev21_vf_vf(vfloat d0) { return _mm256_shuffle_ps(d0, d0, (2 << 6) | (3 << 4) | (0 << 2) | (1 << 0)); } +static INLINE vfloat vreva2_vf_vf(vfloat d0) { d0 = _mm256_permute2f128_ps(d0, d0, 1); return _mm256_shuffle_ps(d0, d0, (1 << 6) | (0 << 4) | (3 << 2) | (2 << 0)); } + +static INLINE void vstream_v_p_vf(float *ptr, vfloat v) { _mm256_stream_ps(ptr, v); } + +static INLINE void vscatter2_v_p_i_i_vf(float *ptr, int offset, int step, vfloat v) { + _mm_storel_pd((double *)(ptr+(offset + step * 0)*2), _mm_castsi128_pd(_mm_castps_si128(_mm256_extractf128_ps(v, 0)))); + _mm_storeh_pd((double *)(ptr+(offset + step * 1)*2), _mm_castsi128_pd(_mm_castps_si128(_mm256_extractf128_ps(v, 0)))); + _mm_storel_pd((double *)(ptr+(offset + step * 2)*2), _mm_castsi128_pd(_mm_castps_si128(_mm256_extractf128_ps(v, 1)))); + _mm_storeh_pd((double *)(ptr+(offset + step * 3)*2), _mm_castsi128_pd(_mm_castps_si128(_mm256_extractf128_ps(v, 1)))); +} + +static INLINE void vsscatter2_v_p_i_i_vf(float *ptr, int offset, int step, vfloat v) { vscatter2_v_p_i_i_vf(ptr, offset, step, v); } + +// + +static vquad loadu_vq_p(void *p) { + vquad vq; + memcpy(&vq, p, VECTLENDP * 16); + return vq; +} + +static INLINE vquad cast_vq_aq(vargquad aq) { + vquad vq; + memcpy(&vq, &aq, VECTLENDP * 16); + return vq; +} + +static INLINE vargquad cast_aq_vq(vquad vq) { + vargquad aq; + memcpy(&aq, &vq, VECTLENDP * 16); + return aq; +} + +static INLINE int vtestallzeros_i_vo64(vopmask g) { + return _mm_movemask_epi8(_mm_or_si128(_mm256_extractf128_si256(g, 0), _mm256_extractf128_si256(g, 1))) == 0; +} + +static INLINE vmask vsel_vm_vo64_vm_vm(vopmask o, vmask x, vmask y) { return _mm256_blendv_epi8(y, x, o); } + +static INLINE vmask vsub64_vm_vm_vm(vmask x, vmask y) { return _mm256_sub_epi64(x, y); } +static INLINE vmask vneg64_vm_vm(vmask x) { return _mm256_sub_epi64(vcast_vm_i_i(0, 0), x); } +static INLINE vopmask vgt64_vo_vm_vm(vmask x, vmask y) { return _mm256_cmpgt_epi64(x, y); } // signed compare + +#define vsll64_vm_vm_i(x, c) _mm256_slli_epi64(x, c) +#define vsrl64_vm_vm_i(x, c) _mm256_srli_epi64(x, c) +//@#define vsll64_vm_vm_i(x, c) _mm256_slli_epi64(x, c) +//@#define vsrl64_vm_vm_i(x, c) _mm256_srli_epi64(x, c) + +static INLINE vmask vcast_vm_vi(vint vi) { return _mm256_cvtepi32_epi64(vi); } // signed 32-bit => 64-bit +static INLINE vint vcast_vi_vm(vmask vm) { // signed 32-bit <= 64-bit + return _mm_or_si128(_mm_castps_si128(_mm_shuffle_ps(_mm_castsi128_ps(_mm256_castsi256_si128(vm)), _mm_set1_ps(0), 0x08)), + _mm_castps_si128(_mm_shuffle_ps(_mm_set1_ps(0), _mm_castsi128_ps(_mm256_extractf128_si256(vm, 1)), 0x80))); +} + +static INLINE vmask vreinterpret_vm_vi64(vint64 v) { return v; } +static INLINE vint64 vreinterpret_vi64_vm(vmask m) { return m; } +static INLINE vmask vreinterpret_vm_vu64(vuint64 v) { return v; } +static INLINE vuint64 vreinterpret_vu64_vm(vmask m) { return m; } diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/arch/helperavx2_128.h b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/arch/helperavx2_128.h new file mode 100644 index 00000000000..5233db1bfd7 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/arch/helperavx2_128.h @@ -0,0 +1,463 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#if CONFIG == 1 + +#if !defined(__AVX2__) && !defined(SLEEF_GENHEADER) +#error Please specify -mavx2. +#endif + +#else +#error CONFIG macro invalid or not defined +#endif + +#define ENABLE_DP +//@#define ENABLE_DP +#define LOG2VECTLENDP 1 +//@#define LOG2VECTLENDP 1 +#define VECTLENDP (1 << LOG2VECTLENDP) +//@#define VECTLENDP (1 << LOG2VECTLENDP) +#define ENABLE_FMA_DP +//@#define ENABLE_FMA_DP + +#define ENABLE_SP +//@#define ENABLE_SP +#define LOG2VECTLENSP (LOG2VECTLENDP+1) +//@#define LOG2VECTLENSP (LOG2VECTLENDP+1) +#define VECTLENSP (1 << LOG2VECTLENSP) +//@#define VECTLENSP (1 << LOG2VECTLENSP) +#define ENABLE_FMA_SP +//@#define ENABLE_FMA_SP + +#define FULL_FP_ROUNDING +//@#define FULL_FP_ROUNDING +#define ACCURATE_SQRT +//@#define ACCURATE_SQRT + +#if !defined(SLEEF_GENHEADER) +#if defined(_MSC_VER) +#include +#else +#include +#endif + +#include +#include "misc.h" +#endif // #if !defined(SLEEF_GENHEADER) + +typedef __m128i vmask; +typedef __m128i vopmask; + +typedef __m128d vdouble; +typedef __m128i vint; + +typedef __m128 vfloat; +typedef __m128i vint2; + +typedef __m128i vint64; +typedef __m128i vuint64; + +typedef struct { + vmask x, y; +} vquad; + +typedef vquad vargquad; + +// + +#if !defined(SLEEF_GENHEADER) + +#ifndef __SLEEF_H__ +void Sleef_x86CpuID(int32_t out[4], uint32_t eax, uint32_t ecx); +#endif + +static INLINE int cpuSupportsAVX2() { + int32_t reg[4]; + Sleef_x86CpuID(reg, 7, 0); + return (reg[1] & (1 << 5)) != 0; +} + +static INLINE int cpuSupportsFMA() { + int32_t reg[4]; + Sleef_x86CpuID(reg, 1, 0); + return (reg[2] & (1 << 12)) != 0; +} + +#if CONFIG == 1 && defined(__AVX2__) +static INLINE int vavailability_i(int name) { + int d = cpuSupportsAVX2() && cpuSupportsFMA(); + return d ? 3 : 0; +} +#define ISANAME "AVX2" +#define DFTPRIORITY 25 +#endif + +#endif // #if !defined(SLEEF_GENHEADER) + +static INLINE void vprefetch_v_p(const void *ptr) { _mm_prefetch(ptr, _MM_HINT_T0); } + +static INLINE int vtestallones_i_vo32(vopmask g) { return _mm_movemask_epi8(g) == 0xFFFF; } +static INLINE int vtestallones_i_vo64(vopmask g) { return _mm_movemask_epi8(g) == 0xFFFF; } + +// + +static INLINE vdouble vcast_vd_d(double d) { return _mm_set1_pd(d); } +static INLINE vmask vreinterpret_vm_vd(vdouble vd) { return _mm_castpd_si128(vd); } +static INLINE vdouble vreinterpret_vd_vm(vmask vm) { return _mm_castsi128_pd(vm); } + +// + +static vint2 vloadu_vi2_p(int32_t *p) { return _mm_loadu_si128((__m128i const *)p); } +static void vstoreu_v_p_vi2(int32_t *p, vint2 v) { _mm_storeu_si128((__m128i *)p, v); } +static vint vloadu_vi_p(int32_t *p) { return _mm_loadu_si128((__m128i *)p); } +static void vstoreu_v_p_vi(int32_t *p, vint v) { _mm_storeu_si128((__m128i *)p, v); } + +// + +static INLINE vmask vand_vm_vm_vm(vmask x, vmask y) { return vreinterpret_vm_vd(_mm_and_pd(vreinterpret_vd_vm(x), vreinterpret_vd_vm(y))); } +static INLINE vmask vandnot_vm_vm_vm(vmask x, vmask y) { return vreinterpret_vm_vd(_mm_andnot_pd(vreinterpret_vd_vm(x), vreinterpret_vd_vm(y))); } +static INLINE vmask vor_vm_vm_vm(vmask x, vmask y) { return vreinterpret_vm_vd(_mm_or_pd(vreinterpret_vd_vm(x), vreinterpret_vd_vm(y))); } +static INLINE vmask vxor_vm_vm_vm(vmask x, vmask y) { return vreinterpret_vm_vd(_mm_xor_pd(vreinterpret_vd_vm(x), vreinterpret_vd_vm(y))); } + +static INLINE vopmask vand_vo_vo_vo(vopmask x, vopmask y) { return vreinterpret_vm_vd(_mm_and_pd(vreinterpret_vd_vm(x), vreinterpret_vd_vm(y))); } +static INLINE vopmask vandnot_vo_vo_vo(vopmask x, vopmask y) { return vreinterpret_vm_vd(_mm_andnot_pd(vreinterpret_vd_vm(x), vreinterpret_vd_vm(y))); } +static INLINE vopmask vor_vo_vo_vo(vopmask x, vopmask y) { return vreinterpret_vm_vd(_mm_or_pd(vreinterpret_vd_vm(x), vreinterpret_vd_vm(y))); } +static INLINE vopmask vxor_vo_vo_vo(vopmask x, vopmask y) { return vreinterpret_vm_vd(_mm_xor_pd(vreinterpret_vd_vm(x), vreinterpret_vd_vm(y))); } + +static INLINE vmask vand_vm_vo64_vm(vopmask x, vmask y) { return vreinterpret_vm_vd(_mm_and_pd(vreinterpret_vd_vm(x), vreinterpret_vd_vm(y))); } +static INLINE vmask vandnot_vm_vo64_vm(vopmask x, vmask y) { return vreinterpret_vm_vd(_mm_andnot_pd(vreinterpret_vd_vm(x), vreinterpret_vd_vm(y))); } +static INLINE vmask vor_vm_vo64_vm(vopmask x, vmask y) { return vreinterpret_vm_vd(_mm_or_pd(vreinterpret_vd_vm(x), vreinterpret_vd_vm(y))); } +static INLINE vmask vxor_vm_vo64_vm(vopmask x, vmask y) { return vreinterpret_vm_vd(_mm_xor_pd(vreinterpret_vd_vm(x), vreinterpret_vd_vm(y))); } + +static INLINE vmask vand_vm_vo32_vm(vopmask x, vmask y) { return vreinterpret_vm_vd(_mm_and_pd(vreinterpret_vd_vm(x), vreinterpret_vd_vm(y))); } +static INLINE vmask vandnot_vm_vo32_vm(vopmask x, vmask y) { return vreinterpret_vm_vd(_mm_andnot_pd(vreinterpret_vd_vm(x), vreinterpret_vd_vm(y))); } +static INLINE vmask vor_vm_vo32_vm(vopmask x, vmask y) { return vreinterpret_vm_vd(_mm_or_pd(vreinterpret_vd_vm(x), vreinterpret_vd_vm(y))); } +static INLINE vmask vxor_vm_vo32_vm(vopmask x, vmask y) { return vreinterpret_vm_vd(_mm_xor_pd(vreinterpret_vd_vm(x), vreinterpret_vd_vm(y))); } + +static INLINE vopmask vcast_vo32_vo64(vopmask m) { return _mm_shuffle_epi32(m, 0x08); } +static INLINE vopmask vcast_vo64_vo32(vopmask m) { return _mm_shuffle_epi32(m, 0x50); } + +static INLINE vopmask vcast_vo_i(int i) { return _mm_set1_epi64x(i ? -1 : 0); } + +// + +static INLINE vint vrint_vi_vd(vdouble vd) { return _mm_cvtpd_epi32(vd); } +static INLINE vint vtruncate_vi_vd(vdouble vd) { return _mm_cvttpd_epi32(vd); } +static INLINE vdouble vrint_vd_vd(vdouble vd) { return _mm_round_pd(vd, _MM_FROUND_TO_NEAREST_INT |_MM_FROUND_NO_EXC); } +static INLINE vfloat vrint_vf_vf(vfloat vd) { return _mm_round_ps(vd, _MM_FROUND_TO_NEAREST_INT |_MM_FROUND_NO_EXC); } +static INLINE vdouble vtruncate_vd_vd(vdouble vd) { return _mm_round_pd(vd, _MM_FROUND_TO_ZERO |_MM_FROUND_NO_EXC); } +static INLINE vfloat vtruncate_vf_vf(vfloat vf) { return _mm_round_ps(vf, _MM_FROUND_TO_ZERO |_MM_FROUND_NO_EXC); } +static INLINE vdouble vcast_vd_vi(vint vi) { return _mm_cvtepi32_pd(vi); } +static INLINE vint vcast_vi_i(int i) { return _mm_set1_epi32(i); } + +static INLINE vmask vcastu_vm_vi(vint vi) { return _mm_and_si128(_mm_shuffle_epi32(vi, 0x73), _mm_set_epi32(-1, 0, -1, 0)); } +static INLINE vint vcastu_vi_vm(vmask vi) { return _mm_shuffle_epi32(vi, 0x0d); } + +static INLINE vmask vcast_vm_i_i(int i0, int i1) { return _mm_set_epi32(i0, i1, i0, i1); } + +static INLINE vmask vcast_vm_i64(int64_t i) { return _mm_set1_epi64x(i); } +static INLINE vmask vcast_vm_u64(uint64_t i) { return _mm_set1_epi64x((uint64_t)i); } + +static INLINE vopmask veq64_vo_vm_vm(vmask x, vmask y) { return _mm_cmpeq_epi64(x, y); } +static INLINE vmask vadd64_vm_vm_vm(vmask x, vmask y) { return _mm_add_epi64(x, y); } + +// + +static INLINE vdouble vadd_vd_vd_vd(vdouble x, vdouble y) { return _mm_add_pd(x, y); } +static INLINE vdouble vsub_vd_vd_vd(vdouble x, vdouble y) { return _mm_sub_pd(x, y); } +static INLINE vdouble vmul_vd_vd_vd(vdouble x, vdouble y) { return _mm_mul_pd(x, y); } +static INLINE vdouble vdiv_vd_vd_vd(vdouble x, vdouble y) { return _mm_div_pd(x, y); } +static INLINE vdouble vrec_vd_vd(vdouble x) { return _mm_div_pd(_mm_set1_pd(1), x); } +static INLINE vdouble vsqrt_vd_vd(vdouble x) { return _mm_sqrt_pd(x); } +static INLINE vdouble vabs_vd_vd(vdouble d) { return _mm_andnot_pd(_mm_set1_pd(-0.0), d); } +static INLINE vdouble vneg_vd_vd(vdouble d) { return _mm_xor_pd(_mm_set1_pd(-0.0), d); } +static INLINE vdouble vmla_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return _mm_fmadd_pd(x, y, z); } +static INLINE vdouble vmlapn_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return _mm_fmsub_pd(x, y, z); } +static INLINE vdouble vmlanp_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return _mm_fnmadd_pd(x, y, z); } +static INLINE vdouble vmax_vd_vd_vd(vdouble x, vdouble y) { return _mm_max_pd(x, y); } +static INLINE vdouble vmin_vd_vd_vd(vdouble x, vdouble y) { return _mm_min_pd(x, y); } + +static INLINE vdouble vfma_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return _mm_fmadd_pd(x, y, z); } +static INLINE vdouble vfmapp_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return _mm_fmadd_pd(x, y, z); } +static INLINE vdouble vfmapn_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return _mm_fmsub_pd(x, y, z); } +static INLINE vdouble vfmanp_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return _mm_fnmadd_pd(x, y, z); } +static INLINE vdouble vfmann_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return _mm_fnmsub_pd(x, y, z); } + +static INLINE vopmask veq_vo_vd_vd(vdouble x, vdouble y) { return vreinterpret_vm_vd(_mm_cmp_pd(x, y, _CMP_EQ_OQ)); } +static INLINE vopmask vneq_vo_vd_vd(vdouble x, vdouble y) { return vreinterpret_vm_vd(_mm_cmp_pd(x, y, _CMP_NEQ_UQ)); } +static INLINE vopmask vlt_vo_vd_vd(vdouble x, vdouble y) { return vreinterpret_vm_vd(_mm_cmp_pd(x, y, _CMP_LT_OQ)); } +static INLINE vopmask vle_vo_vd_vd(vdouble x, vdouble y) { return vreinterpret_vm_vd(_mm_cmp_pd(x, y, _CMP_LE_OQ)); } +static INLINE vopmask vgt_vo_vd_vd(vdouble x, vdouble y) { return vreinterpret_vm_vd(_mm_cmp_pd(x, y, _CMP_GT_OQ)); } +static INLINE vopmask vge_vo_vd_vd(vdouble x, vdouble y) { return vreinterpret_vm_vd(_mm_cmp_pd(x, y, _CMP_GE_OQ)); } + +// + +static INLINE vint vadd_vi_vi_vi(vint x, vint y) { return _mm_add_epi32(x, y); } +static INLINE vint vsub_vi_vi_vi(vint x, vint y) { return _mm_sub_epi32(x, y); } +static INLINE vint vneg_vi_vi(vint e) { return vsub_vi_vi_vi(vcast_vi_i(0), e); } + +static INLINE vint vand_vi_vi_vi(vint x, vint y) { return _mm_and_si128(x, y); } +static INLINE vint vandnot_vi_vi_vi(vint x, vint y) { return _mm_andnot_si128(x, y); } +static INLINE vint vor_vi_vi_vi(vint x, vint y) { return _mm_or_si128(x, y); } +static INLINE vint vxor_vi_vi_vi(vint x, vint y) { return _mm_xor_si128(x, y); } + +static INLINE vint vand_vi_vo_vi(vopmask x, vint y) { return _mm_and_si128(x, y); } +static INLINE vint vandnot_vi_vo_vi(vopmask x, vint y) { return _mm_andnot_si128(x, y); } + +static INLINE vint vsll_vi_vi_i(vint x, int c) { return _mm_slli_epi32(x, c); } +static INLINE vint vsrl_vi_vi_i(vint x, int c) { return _mm_srli_epi32(x, c); } +static INLINE vint vsra_vi_vi_i(vint x, int c) { return _mm_srai_epi32(x, c); } + +static INLINE vint veq_vi_vi_vi(vint x, vint y) { return _mm_cmpeq_epi32(x, y); } +static INLINE vint vgt_vi_vi_vi(vint x, vint y) { return _mm_cmpgt_epi32(x, y); } + +static INLINE vopmask veq_vo_vi_vi(vint x, vint y) { return _mm_cmpeq_epi32(x, y); } +static INLINE vopmask vgt_vo_vi_vi(vint x, vint y) { return _mm_cmpgt_epi32(x, y); } + +static INLINE vint vsel_vi_vo_vi_vi(vopmask m, vint x, vint y) { return _mm_blendv_epi8(y, x, m); } + +static INLINE vdouble vsel_vd_vo_vd_vd(vopmask o, vdouble x, vdouble y) { return _mm_blendv_pd(y, x, _mm_castsi128_pd(o)); } + +static INLINE CONST vdouble vsel_vd_vo_d_d(vopmask o, double v1, double v0) { + return vsel_vd_vo_vd_vd(o, vcast_vd_d(v1), vcast_vd_d(v0)); +} + +static INLINE vdouble vsel_vd_vo_vo_d_d_d(vopmask o0, vopmask o1, double d0, double d1, double d2) { + return vsel_vd_vo_vd_vd(o0, vcast_vd_d(d0), vsel_vd_vo_d_d(o1, d1, d2)); +} + +static INLINE vdouble vsel_vd_vo_vo_vo_d_d_d_d(vopmask o0, vopmask o1, vopmask o2, double d0, double d1, double d2, double d3) { + return vsel_vd_vo_vd_vd(o0, vcast_vd_d(d0), vsel_vd_vo_vd_vd(o1, vcast_vd_d(d1), vsel_vd_vo_d_d(o2, d2, d3))); +} + +static INLINE vopmask visinf_vo_vd(vdouble d) { + return vreinterpret_vm_vd(_mm_cmp_pd(vabs_vd_vd(d), _mm_set1_pd(SLEEF_INFINITY), _CMP_EQ_OQ)); +} + +static INLINE vopmask vispinf_vo_vd(vdouble d) { + return vreinterpret_vm_vd(_mm_cmp_pd(d, _mm_set1_pd(SLEEF_INFINITY), _CMP_EQ_OQ)); +} + +static INLINE vopmask visminf_vo_vd(vdouble d) { + return vreinterpret_vm_vd(_mm_cmp_pd(d, _mm_set1_pd(-SLEEF_INFINITY), _CMP_EQ_OQ)); +} + +static INLINE vopmask visnan_vo_vd(vdouble d) { + return vreinterpret_vm_vd(_mm_cmp_pd(d, d, _CMP_NEQ_UQ)); +} + +static INLINE vdouble vload_vd_p(const double *ptr) { return _mm_load_pd(ptr); } +static INLINE vdouble vloadu_vd_p(const double *ptr) { return _mm_loadu_pd(ptr); } + +static INLINE void vstore_v_p_vd(double *ptr, vdouble v) { _mm_store_pd(ptr, v); } +static INLINE void vstoreu_v_p_vd(double *ptr, vdouble v) { _mm_storeu_pd(ptr, v); } + +static INLINE vdouble vgather_vd_p_vi(const double *ptr, vint vi) { return _mm_i32gather_pd(ptr, vi, 8); } + +#if defined(_MSC_VER) +// This function is needed when debugging on MSVC. +static INLINE double vcast_d_vd(vdouble v) { + double a[VECTLENDP]; + vstoreu_v_p_vd(a, v); + return a[0]; +} +#endif + +// + +static INLINE vint2 vcast_vi2_vm(vmask vm) { return vm; } +static INLINE vmask vcast_vm_vi2(vint2 vi) { return vi; } + +static INLINE vint2 vrint_vi2_vf(vfloat vf) { return vcast_vi2_vm(_mm_cvtps_epi32(vf)); } +static INLINE vint2 vtruncate_vi2_vf(vfloat vf) { return vcast_vi2_vm(_mm_cvttps_epi32(vf)); } +static INLINE vfloat vcast_vf_vi2(vint2 vi) { return _mm_cvtepi32_ps(vcast_vm_vi2(vi)); } +static INLINE vfloat vcast_vf_f(float f) { return _mm_set1_ps(f); } +static INLINE vint2 vcast_vi2_i(int i) { return _mm_set1_epi32(i); } +static INLINE vmask vreinterpret_vm_vf(vfloat vf) { return _mm_castps_si128(vf); } +static INLINE vfloat vreinterpret_vf_vm(vmask vm) { return _mm_castsi128_ps(vm); } + +static INLINE vfloat vreinterpret_vf_vi2(vint2 vi) { return vreinterpret_vf_vm(vcast_vm_vi2(vi)); } +static INLINE vint2 vreinterpret_vi2_vf(vfloat vf) { return vcast_vi2_vm(vreinterpret_vm_vf(vf)); } + +static INLINE vfloat vadd_vf_vf_vf(vfloat x, vfloat y) { return _mm_add_ps(x, y); } +static INLINE vfloat vsub_vf_vf_vf(vfloat x, vfloat y) { return _mm_sub_ps(x, y); } +static INLINE vfloat vmul_vf_vf_vf(vfloat x, vfloat y) { return _mm_mul_ps(x, y); } +static INLINE vfloat vdiv_vf_vf_vf(vfloat x, vfloat y) { return _mm_div_ps(x, y); } +static INLINE vfloat vrec_vf_vf(vfloat x) { return vdiv_vf_vf_vf(vcast_vf_f(1.0f), x); } +static INLINE vfloat vsqrt_vf_vf(vfloat x) { return _mm_sqrt_ps(x); } +static INLINE vfloat vabs_vf_vf(vfloat f) { return vreinterpret_vf_vm(vandnot_vm_vm_vm(vreinterpret_vm_vf(vcast_vf_f(-0.0f)), vreinterpret_vm_vf(f))); } +static INLINE vfloat vneg_vf_vf(vfloat d) { return vreinterpret_vf_vm(vxor_vm_vm_vm(vreinterpret_vm_vf(vcast_vf_f(-0.0f)), vreinterpret_vm_vf(d))); } +static INLINE vfloat vmla_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return _mm_fmadd_ps(x, y, z); } +static INLINE vfloat vmlapn_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return _mm_fmsub_ps(x, y, z); } +static INLINE vfloat vmlanp_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return _mm_fnmadd_ps(x, y, z); } +static INLINE vfloat vmax_vf_vf_vf(vfloat x, vfloat y) { return _mm_max_ps(x, y); } +static INLINE vfloat vmin_vf_vf_vf(vfloat x, vfloat y) { return _mm_min_ps(x, y); } + +static INLINE vfloat vfma_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return _mm_fmadd_ps(x, y, z); } +static INLINE vfloat vfmapp_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return _mm_fmadd_ps(x, y, z); } +static INLINE vfloat vfmapn_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return _mm_fmsub_ps(x, y, z); } +static INLINE vfloat vfmanp_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return _mm_fnmadd_ps(x, y, z); } +static INLINE vfloat vfmann_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return _mm_fnmsub_ps(x, y, z); } + +static INLINE vopmask veq_vo_vf_vf(vfloat x, vfloat y) { return vreinterpret_vm_vf(_mm_cmp_ps(x, y, _CMP_EQ_OQ)); } +static INLINE vopmask vneq_vo_vf_vf(vfloat x, vfloat y) { return vreinterpret_vm_vf(_mm_cmp_ps(x, y, _CMP_NEQ_UQ)); } +static INLINE vopmask vlt_vo_vf_vf(vfloat x, vfloat y) { return vreinterpret_vm_vf(_mm_cmp_ps(x, y, _CMP_LT_OQ)); } +static INLINE vopmask vle_vo_vf_vf(vfloat x, vfloat y) { return vreinterpret_vm_vf(_mm_cmp_ps(x, y, _CMP_LE_OQ)); } +static INLINE vopmask vgt_vo_vf_vf(vfloat x, vfloat y) { return vreinterpret_vm_vf(_mm_cmp_ps(x, y, _CMP_GT_OQ)); } +static INLINE vopmask vge_vo_vf_vf(vfloat x, vfloat y) { return vreinterpret_vm_vf(_mm_cmp_ps(x, y, _CMP_GE_OQ)); } + +static INLINE vint2 vadd_vi2_vi2_vi2(vint2 x, vint2 y) { return _mm_add_epi32(x, y); } +static INLINE vint2 vsub_vi2_vi2_vi2(vint2 x, vint2 y) { return _mm_sub_epi32(x, y); } +static INLINE vint2 vneg_vi2_vi2(vint2 e) { return vsub_vi2_vi2_vi2(vcast_vi2_i(0), e); } + +static INLINE vint2 vand_vi2_vi2_vi2(vint2 x, vint2 y) { return _mm_and_si128(x, y); } +static INLINE vint2 vandnot_vi2_vi2_vi2(vint2 x, vint2 y) { return _mm_andnot_si128(x, y); } +static INLINE vint2 vor_vi2_vi2_vi2(vint2 x, vint2 y) { return _mm_or_si128(x, y); } +static INLINE vint2 vxor_vi2_vi2_vi2(vint2 x, vint2 y) { return _mm_xor_si128(x, y); } + +static INLINE vint2 vand_vi2_vo_vi2(vopmask x, vint2 y) { return vand_vi2_vi2_vi2(vcast_vi2_vm(x), y); } +static INLINE vint2 vandnot_vi2_vo_vi2(vopmask x, vint2 y) { return vandnot_vi2_vi2_vi2(vcast_vi2_vm(x), y); } + +static INLINE vint2 vsll_vi2_vi2_i(vint2 x, int c) { return _mm_slli_epi32(x, c); } +static INLINE vint2 vsrl_vi2_vi2_i(vint2 x, int c) { return _mm_srli_epi32(x, c); } +static INLINE vint2 vsra_vi2_vi2_i(vint2 x, int c) { return _mm_srai_epi32(x, c); } + +static INLINE vopmask veq_vo_vi2_vi2(vint2 x, vint2 y) { return _mm_cmpeq_epi32(x, y); } +static INLINE vopmask vgt_vo_vi2_vi2(vint2 x, vint2 y) { return _mm_cmpgt_epi32(x, y); } +static INLINE vint2 veq_vi2_vi2_vi2(vint2 x, vint2 y) { return _mm_cmpeq_epi32(x, y); } +static INLINE vint2 vgt_vi2_vi2_vi2(vint2 x, vint2 y) { return _mm_cmpgt_epi32(x, y); } + +static INLINE vint2 vsel_vi2_vo_vi2_vi2(vopmask m, vint2 x, vint2 y) { + return _mm_blendv_epi8(y, x, m); +} + +static INLINE vfloat vsel_vf_vo_vf_vf(vopmask o, vfloat x, vfloat y) { return _mm_blendv_ps(y, x, _mm_castsi128_ps(o)); } + +static INLINE CONST vfloat vsel_vf_vo_f_f(vopmask o, float v1, float v0) { + return vsel_vf_vo_vf_vf(o, vcast_vf_f(v1), vcast_vf_f(v0)); +} + +static INLINE vfloat vsel_vf_vo_vo_f_f_f(vopmask o0, vopmask o1, float d0, float d1, float d2) { + return vsel_vf_vo_vf_vf(o0, vcast_vf_f(d0), vsel_vf_vo_f_f(o1, d1, d2)); +} + +static INLINE vfloat vsel_vf_vo_vo_vo_f_f_f_f(vopmask o0, vopmask o1, vopmask o2, float d0, float d1, float d2, float d3) { + return vsel_vf_vo_vf_vf(o0, vcast_vf_f(d0), vsel_vf_vo_vf_vf(o1, vcast_vf_f(d1), vsel_vf_vo_f_f(o2, d2, d3))); +} + +static INLINE vopmask visinf_vo_vf(vfloat d) { return veq_vo_vf_vf(vabs_vf_vf(d), vcast_vf_f(SLEEF_INFINITYf)); } +static INLINE vopmask vispinf_vo_vf(vfloat d) { return veq_vo_vf_vf(d, vcast_vf_f(SLEEF_INFINITYf)); } +static INLINE vopmask visminf_vo_vf(vfloat d) { return veq_vo_vf_vf(d, vcast_vf_f(-SLEEF_INFINITYf)); } +static INLINE vopmask visnan_vo_vf(vfloat d) { return vneq_vo_vf_vf(d, d); } + +static INLINE vfloat vload_vf_p(const float *ptr) { return _mm_load_ps(ptr); } +static INLINE vfloat vloadu_vf_p(const float *ptr) { return _mm_loadu_ps(ptr); } + +static INLINE void vstore_v_p_vf(float *ptr, vfloat v) { _mm_store_ps(ptr, v); } +static INLINE void vstoreu_v_p_vf(float *ptr, vfloat v) { _mm_storeu_ps(ptr, v); } + +static INLINE vfloat vgather_vf_p_vi2(const float *ptr, vint2 vi2) { return _mm_i32gather_ps(ptr, vi2, 4); } + +#ifdef _MSC_VER +// This function is needed when debugging on MSVC. +static INLINE float vcast_f_vf(vfloat v) { + float a[VECTLENSP]; + vstoreu_v_p_vf(a, v); + return a[0]; +} +#endif + +// + +#define PNMASK ((vdouble) { +0.0, -0.0 }) +#define NPMASK ((vdouble) { -0.0, +0.0 }) +#define PNMASKf ((vfloat) { +0.0f, -0.0f, +0.0f, -0.0f }) +#define NPMASKf ((vfloat) { -0.0f, +0.0f, -0.0f, +0.0f }) + +static INLINE vdouble vposneg_vd_vd(vdouble d) { return vreinterpret_vd_vm(vxor_vm_vm_vm(vreinterpret_vm_vd(d), vreinterpret_vm_vd(PNMASK))); } +static INLINE vdouble vnegpos_vd_vd(vdouble d) { return vreinterpret_vd_vm(vxor_vm_vm_vm(vreinterpret_vm_vd(d), vreinterpret_vm_vd(NPMASK))); } +static INLINE vfloat vposneg_vf_vf(vfloat d) { return vreinterpret_vf_vm(vxor_vm_vm_vm(vreinterpret_vm_vf(d), vreinterpret_vm_vf(PNMASKf))); } +static INLINE vfloat vnegpos_vf_vf(vfloat d) { return vreinterpret_vf_vm(vxor_vm_vm_vm(vreinterpret_vm_vf(d), vreinterpret_vm_vf(NPMASKf))); } + +static INLINE vdouble vsubadd_vd_vd_vd(vdouble x, vdouble y) { return _mm_addsub_pd(x, y); } +static INLINE vfloat vsubadd_vf_vf_vf(vfloat x, vfloat y) { return _mm_addsub_ps(x, y); } + +static INLINE vdouble vmlsubadd_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return vmla_vd_vd_vd_vd(x, y, vnegpos_vd_vd(z)); } +static INLINE vfloat vmlsubadd_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return vmla_vf_vf_vf_vf(x, y, vnegpos_vf_vf(z)); } + +static INLINE vdouble vrev21_vd_vd(vdouble d0) { return _mm_shuffle_pd(d0, d0, 1); } +static INLINE vdouble vreva2_vd_vd(vdouble vd) { return vd; } + +static INLINE void vstream_v_p_vd(double *ptr, vdouble v) { _mm_stream_pd(ptr, v); } +static INLINE void vscatter2_v_p_i_i_vd(double *ptr, int offset, int step, vdouble v) { vstore_v_p_vd((double *)(&ptr[2*offset]), v); } +static INLINE void vsscatter2_v_p_i_i_vd(double *ptr, int offset, int step, vdouble v) { _mm_stream_pd((double *)(&ptr[2*offset]), v); } + +// + +static INLINE vfloat vrev21_vf_vf(vfloat d0) { return _mm_shuffle_ps(d0, d0, (2 << 6) | (3 << 4) | (0 << 2) | (1 << 0)); } +static INLINE vfloat vreva2_vf_vf(vfloat d0) { return _mm_shuffle_ps(d0, d0, (1 << 6) | (0 << 4) | (3 << 2) | (2 << 0)); } + +static INLINE void vstream_v_p_vf(float *ptr, vfloat v) { _mm_stream_ps(ptr, v); } + +static INLINE void vscatter2_v_p_i_i_vf(float *ptr, int offset, int step, vfloat v) { + _mm_storel_pd((double *)(ptr+(offset + step * 0)*2), vreinterpret_vd_vm(vreinterpret_vm_vf(v))); + _mm_storeh_pd((double *)(ptr+(offset + step * 1)*2), vreinterpret_vd_vm(vreinterpret_vm_vf(v))); +} + +static INLINE void vsscatter2_v_p_i_i_vf(float *ptr, int offset, int step, vfloat v) { + _mm_storel_pd((double *)(ptr+(offset + step * 0)*2), vreinterpret_vd_vm(vreinterpret_vm_vf(v))); + _mm_storeh_pd((double *)(ptr+(offset + step * 1)*2), vreinterpret_vd_vm(vreinterpret_vm_vf(v))); +} + +// + +static vquad loadu_vq_p(void *p) { + vquad vq = { + vloadu_vi2_p((int32_t *)p), + vloadu_vi2_p((int32_t *)((uint8_t *)p + sizeof(vmask))) + }; + return vq; +} + +static INLINE vquad cast_vq_aq(vargquad aq) { + vquad vq; + memcpy(&vq, &aq, VECTLENDP * 16); + return vq; +} + +static INLINE vargquad cast_aq_vq(vquad vq) { + vargquad aq; + memcpy(&aq, &vq, VECTLENDP * 16); + return aq; +} + +static void vstoreu_v_p_vq(void *p, vquad vq) { + vstoreu_v_p_vi2((int32_t *)p, vcast_vi2_vm(vq.x)); + vstoreu_v_p_vi2((int32_t *)((uint8_t *)p + sizeof(vmask)), vcast_vi2_vm(vq.y)); +} + +static INLINE int vtestallzeros_i_vo64(vopmask g) { return _mm_movemask_epi8(g) == 0; } + +static INLINE vmask vsel_vm_vo64_vm_vm(vopmask o, vmask x, vmask y) { return _mm_blendv_epi8(y, x, o); } + +static INLINE vmask vsub64_vm_vm_vm(vmask x, vmask y) { return _mm_sub_epi64(x, y); } +static INLINE vmask vneg64_vm_vm(vmask x) { return _mm_sub_epi64(vcast_vm_i_i(0, 0), x); } +static INLINE vopmask vgt64_vo_vm_vm(vmask x, vmask y) { return _mm_cmpgt_epi64(x, y); } // signed compare + +#define vsll64_vm_vm_i(x, c) _mm_slli_epi64(x, c) +#define vsrl64_vm_vm_i(x, c) _mm_srli_epi64(x, c) +//@#define vsll64_vm_vm_i(x, c) _mm_slli_epi64(x, c) +//@#define vsrl64_vm_vm_i(x, c) _mm_srli_epi64(x, c) + +static INLINE vmask vcast_vm_vi(vint vi) { + vmask m = _mm_and_si128(_mm_shuffle_epi32(vi, (0 << 6) | (1 << 4) | (0 << 2) | (0 << 0)), _mm_set_epi32(0, -1, 0, -1)); + return vor_vm_vm_vm(vcastu_vm_vi(vgt_vo_vi_vi(vcast_vi_i(0), vi)), m); +} +static INLINE vint vcast_vi_vm(vmask vm) { return _mm_shuffle_epi32(vm, 0x08); } + +static INLINE vmask vreinterpret_vm_vi64(vint64 v) { return v; } +static INLINE vint64 vreinterpret_vi64_vm(vmask m) { return m; } +static INLINE vmask vreinterpret_vm_vu64(vuint64 v) { return v; } +static INLINE vuint64 vreinterpret_vu64_vm(vmask m) { return m; } diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/arch/helperavx512f.h b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/arch/helperavx512f.h new file mode 100644 index 00000000000..d59379163de --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/arch/helperavx512f.h @@ -0,0 +1,600 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#if CONFIG == 1 || CONFIG == 2 + +#if !defined(__AVX512F__) && !defined(SLEEF_GENHEADER) +#error Please specify -mavx512f. +#endif + +#else +#error CONFIG macro invalid or not defined +#endif + +#define ENABLE_DP +//@#define ENABLE_DP +#define LOG2VECTLENDP 3 +//@#define LOG2VECTLENDP 3 +#define VECTLENDP (1 << LOG2VECTLENDP) +//@#define VECTLENDP (1 << LOG2VECTLENDP) + +#define ENABLE_SP +//@#define ENABLE_SP +#define LOG2VECTLENSP (LOG2VECTLENDP+1) +//@#define LOG2VECTLENSP (LOG2VECTLENDP+1) +#define VECTLENSP (1 << LOG2VECTLENSP) +//@#define VECTLENSP (1 << LOG2VECTLENSP) + +#if CONFIG == 1 +#define ENABLE_FMA_DP +//@#define ENABLE_FMA_DP +#define ENABLE_FMA_SP +//@#define ENABLE_FMA_SP +#endif + +#define FULL_FP_ROUNDING +//@#define FULL_FP_ROUNDING +#define ACCURATE_SQRT +//@#define ACCURATE_SQRT + +#if !defined(SLEEF_GENHEADER) +#if defined(_MSC_VER) +#include +#else +#include +#endif + +#include +#include "misc.h" +#endif // #if !defined(SLEEF_GENHEADER) + +typedef __m512i vmask; +typedef __mmask16 vopmask; + +typedef __m512d vdouble; +typedef __m256i vint; + +typedef __m512 vfloat; +typedef __m512i vint2; + +typedef __m512i vint64; +typedef __m512i vuint64; + +typedef struct { + vmask x, y; +} vquad; + +typedef vquad vargquad; + +// + +#if !defined(SLEEF_GENHEADER) + +#ifndef __SLEEF_H__ +void Sleef_x86CpuID(int32_t out[4], uint32_t eax, uint32_t ecx); +#endif + +static INLINE int cpuSupportsAVX512F() { + int32_t reg[4]; + Sleef_x86CpuID(reg, 7, 0); + return (reg[1] & (1 << 16)) != 0; +} + +#if CONFIG == 1 && defined(__AVX512F__) +static INLINE int vavailability_i(int name) { + int d = cpuSupportsAVX512F(); + return d ? 3 : 0; +} +#define ISANAME "AVX512F" +#define DFTPRIORITY 30 +#endif + +#if CONFIG == 2 && defined(__AVX512F__) +static INLINE int vavailability_i(int name) { + int d = cpuSupportsAVX512F(); + return d ? 3 : 0; +} +#define ISANAME "AVX512FNOFMA" +#define DFTPRIORITY 0 +#endif + +#endif // #if !defined(SLEEF_GENHEADER) + +static INLINE void vprefetch_v_p(const void *ptr) { _mm_prefetch(ptr, _MM_HINT_T0); } + +#ifdef __INTEL_COMPILER +static INLINE int vtestallones_i_vo64(vopmask g) { return _mm512_mask2int(g) == 0xff; } +static INLINE int vtestallones_i_vo32(vopmask g) { return _mm512_mask2int(g) == 0xffff; } +#else +static INLINE int vtestallones_i_vo64(vopmask g) { return g == 0xff; } +static INLINE int vtestallones_i_vo32(vopmask g) { return g == 0xffff; } +#endif + +// + +static vint2 vloadu_vi2_p(int32_t *p) { return _mm512_loadu_si512((__m512i const *)p); } +static void vstoreu_v_p_vi2(int32_t *p, vint2 v) { _mm512_storeu_si512((__m512i *)p, v); } +static vint vloadu_vi_p(int32_t *p) { return _mm256_loadu_si256((__m256i const *)p); } +static void vstoreu_v_p_vi(int32_t *p, vint v) { _mm256_storeu_si256((__m256i *)p, v); } + +// + +static INLINE vmask vand_vm_vm_vm(vmask x, vmask y) { return _mm512_and_si512(x, y); } +static INLINE vmask vandnot_vm_vm_vm(vmask x, vmask y) { return _mm512_andnot_si512(x, y); } +static INLINE vmask vor_vm_vm_vm(vmask x, vmask y) { return _mm512_or_si512(x, y); } +static INLINE vmask vxor_vm_vm_vm(vmask x, vmask y) { return _mm512_xor_si512(x, y); } + +static INLINE vopmask vand_vo_vo_vo(vopmask x, vopmask y) { return _mm512_kand(x, y); } +static INLINE vopmask vandnot_vo_vo_vo(vopmask x, vopmask y) { return _mm512_kandn(x, y); } +static INLINE vopmask vor_vo_vo_vo(vopmask x, vopmask y) { return _mm512_kor(x, y); } +static INLINE vopmask vxor_vo_vo_vo(vopmask x, vopmask y) { return _mm512_kxor(x, y); } + +static INLINE vmask vand_vm_vo64_vm(vopmask o, vmask m) { return _mm512_mask_and_epi64(_mm512_set1_epi32(0), o, m, m); } +static INLINE vmask vandnot_vm_vo64_vm(vopmask o, vmask m) { return _mm512_mask_and_epi64(m, o, _mm512_set1_epi32(0), _mm512_set1_epi32(0)); } +static INLINE vmask vor_vm_vo64_vm(vopmask o, vmask m) { return _mm512_mask_or_epi64(m, o, _mm512_set1_epi32(-1), _mm512_set1_epi32(-1)); } + +static INLINE vmask vand_vm_vo32_vm(vopmask o, vmask m) { return _mm512_mask_and_epi32(_mm512_set1_epi32(0), o, m, m); } +static INLINE vmask vandnot_vm_vo32_vm(vopmask o, vmask m) { return _mm512_mask_and_epi32(m, o, _mm512_set1_epi32(0), _mm512_set1_epi32(0)); } +static INLINE vmask vor_vm_vo32_vm(vopmask o, vmask m) { return _mm512_mask_or_epi32(m, o, _mm512_set1_epi32(-1), _mm512_set1_epi32(-1)); } + +static INLINE vopmask vcast_vo32_vo64(vopmask o) { return o; } +static INLINE vopmask vcast_vo64_vo32(vopmask o) { return o; } + +static INLINE vopmask vcast_vo_i(int i) { return i ? -1 : 0; } + +// + +static INLINE vint vrint_vi_vd(vdouble vd) { + return _mm512_cvt_roundpd_epi32(vd, _MM_FROUND_TO_NEAREST_INT |_MM_FROUND_NO_EXC); +} + +static INLINE vint vtruncate_vi_vd(vdouble vd) { + return _mm512_cvt_roundpd_epi32(vd, _MM_FROUND_TO_ZERO |_MM_FROUND_NO_EXC); +} + +static INLINE vdouble vcast_vd_vi(vint vi) { return _mm512_cvtepi32_pd(vi); } +static INLINE vint vcast_vi_i(int i) { return _mm256_set1_epi32(i); } + +static INLINE vdouble vtruncate_vd_vd(vdouble vd) { + return _mm512_roundscale_pd(vd, _MM_FROUND_TO_ZERO |_MM_FROUND_NO_EXC); +} + +static INLINE vdouble vrint_vd_vd(vdouble vd) { + return _mm512_roundscale_pd(vd, _MM_FROUND_TO_NEAREST_INT |_MM_FROUND_NO_EXC); +} + +static INLINE vmask vcastu_vm_vi(vint vi) { + return _mm512_maskz_permutexvar_epi32(0xaaaa, _mm512_set_epi32(7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0), _mm512_castsi256_si512(vi)); +} + +static INLINE vint vcastu_vi_vm(vmask vi) { + return _mm512_castsi512_si256(_mm512_maskz_permutexvar_epi32(0x00ff, _mm512_set_epi32(0, 0, 0, 0, 0, 0, 0, 0, 15, 13, 11, 9, 7, 5, 3, 1), vi)); +} + +static INLINE vmask vcast_vm_i_i(int i0, int i1) { return _mm512_set_epi32(i0, i1, i0, i1, i0, i1, i0, i1, i0, i1, i0, i1, i0, i1, i0, i1); } + +static INLINE vmask vcast_vm_i64(int64_t i) { return _mm512_set1_epi64(i); } +static INLINE vmask vcast_vm_u64(uint64_t i) { return _mm512_set1_epi64((uint64_t)i); } + +static INLINE vopmask veq64_vo_vm_vm(vmask x, vmask y) { return _mm512_cmp_epi64_mask(x, y, _MM_CMPINT_EQ); } +static INLINE vmask vadd64_vm_vm_vm(vmask x, vmask y) { return _mm512_add_epi64(x, y); } + +// + +static INLINE vdouble vcast_vd_d(double d) { return _mm512_set1_pd(d); } +static INLINE vmask vreinterpret_vm_vd(vdouble vd) { return _mm512_castpd_si512(vd); } +static INLINE vdouble vreinterpret_vd_vm(vmask vm) { return _mm512_castsi512_pd(vm); } + +static INLINE vdouble vadd_vd_vd_vd(vdouble x, vdouble y) { return _mm512_add_pd(x, y); } +static INLINE vdouble vsub_vd_vd_vd(vdouble x, vdouble y) { return _mm512_sub_pd(x, y); } +static INLINE vdouble vmul_vd_vd_vd(vdouble x, vdouble y) { return _mm512_mul_pd(x, y); } +static INLINE vdouble vdiv_vd_vd_vd(vdouble x, vdouble y) { return _mm512_div_pd(x, y); } +static INLINE vdouble vrec_vd_vd(vdouble x) { return _mm512_div_pd(_mm512_set1_pd(1), x); } +static INLINE vdouble vsqrt_vd_vd(vdouble x) { return _mm512_sqrt_pd(x); } +static INLINE vdouble vabs_vd_vd(vdouble d) { return vreinterpret_vd_vm(_mm512_andnot_si512(vreinterpret_vm_vd(_mm512_set1_pd(-0.0)), vreinterpret_vm_vd(d))); } +static INLINE vdouble vneg_vd_vd(vdouble d) { return vreinterpret_vd_vm(_mm512_xor_si512(vreinterpret_vm_vd(_mm512_set1_pd(-0.0)), vreinterpret_vm_vd(d))); } +static INLINE vdouble vmax_vd_vd_vd(vdouble x, vdouble y) { return _mm512_max_pd(x, y); } +static INLINE vdouble vmin_vd_vd_vd(vdouble x, vdouble y) { return _mm512_min_pd(x, y); } + +#if CONFIG == 1 +static INLINE vdouble vmla_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return _mm512_fmadd_pd(x, y, z); } +static INLINE vdouble vmlapn_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return _mm512_fmsub_pd(x, y, z); } +static INLINE vdouble vmlanp_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return _mm512_fnmadd_pd(x, y, z); } +#else +static INLINE vdouble vmla_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return vadd_vd_vd_vd(vmul_vd_vd_vd(x, y), z); } +static INLINE vdouble vmlapn_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return vsub_vd_vd_vd(vmul_vd_vd_vd(x, y), z); } +#endif + +static INLINE vdouble vfma_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return _mm512_fmadd_pd(x, y, z); } +static INLINE vdouble vfmapp_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return _mm512_fmadd_pd(x, y, z); } +static INLINE vdouble vfmapn_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return _mm512_fmsub_pd(x, y, z); } +static INLINE vdouble vfmanp_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return _mm512_fnmadd_pd(x, y, z); } +static INLINE vdouble vfmann_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return _mm512_fnmsub_pd(x, y, z); } + +static INLINE vopmask veq_vo_vd_vd(vdouble x, vdouble y) { return _mm512_cmp_pd_mask(x, y, _CMP_EQ_OQ); } +static INLINE vopmask vneq_vo_vd_vd(vdouble x, vdouble y) { return _mm512_cmp_pd_mask(x, y, _CMP_NEQ_UQ); } +static INLINE vopmask vlt_vo_vd_vd(vdouble x, vdouble y) { return _mm512_cmp_pd_mask(x, y, _CMP_LT_OQ); } +static INLINE vopmask vle_vo_vd_vd(vdouble x, vdouble y) { return _mm512_cmp_pd_mask(x, y, _CMP_LE_OQ); } +static INLINE vopmask vgt_vo_vd_vd(vdouble x, vdouble y) { return _mm512_cmp_pd_mask(x, y, _CMP_GT_OQ); } +static INLINE vopmask vge_vo_vd_vd(vdouble x, vdouble y) { return _mm512_cmp_pd_mask(x, y, _CMP_GE_OQ); } + +// + +static INLINE vint vadd_vi_vi_vi(vint x, vint y) { return _mm256_add_epi32(x, y); } +static INLINE vint vsub_vi_vi_vi(vint x, vint y) { return _mm256_sub_epi32(x, y); } +static INLINE vint vneg_vi_vi(vint e) { return vsub_vi_vi_vi(vcast_vi_i(0), e); } + +static INLINE vint vand_vi_vi_vi(vint x, vint y) { return _mm256_and_si256(x, y); } +static INLINE vint vandnot_vi_vi_vi(vint x, vint y) { return _mm256_andnot_si256(x, y); } + +static INLINE vint vandnot_vi_vo_vi(vopmask o, vint y) { + return _mm512_castsi512_si256(_mm512_mask_and_epi32(_mm512_castsi256_si512(y), o, _mm512_set1_epi32(0), _mm512_set1_epi32(0))); +} +static INLINE vint vand_vi_vo_vi(vopmask o, vint y) { + return _mm512_castsi512_si256(_mm512_mask_and_epi32(_mm512_set1_epi32(0), o, _mm512_castsi256_si512(y), _mm512_castsi256_si512(y))); +} + +static INLINE vint vor_vi_vi_vi(vint x, vint y) { return _mm256_or_si256(x, y); } +static INLINE vint vxor_vi_vi_vi(vint x, vint y) { return _mm256_xor_si256(x, y); } +#define vsll_vi_vi_i(x, c) _mm256_slli_epi32(x, c) +#define vsrl_vi_vi_i(x, c) _mm256_srli_epi32(x, c) +#define vsra_vi_vi_i(x, c) _mm256_srai_epi32(x, c) +//@#define vsll_vi_vi_i(x, c) _mm256_slli_epi32(x, c) +//@#define vsrl_vi_vi_i(x, c) _mm256_srli_epi32(x, c) +//@#define vsra_vi_vi_i(x, c) _mm256_srai_epi32(x, c) + +static INLINE vint veq_vi_vi_vi(vint x, vint y) { return _mm256_cmpeq_epi32(x, y); } +static INLINE vint vgt_vi_vi_vi(vint x, vint y) { return _mm256_cmpgt_epi32(x, y); } + +static INLINE vopmask veq_vo_vi_vi(vint x, vint y) { + return _mm512_cmp_epi32_mask(_mm512_castsi256_si512(x), _mm512_castsi256_si512(y), _MM_CMPINT_EQ); +} +static INLINE vopmask vgt_vo_vi_vi(vint x, vint y) { + return _mm512_cmp_epi32_mask(_mm512_castsi256_si512(y), _mm512_castsi256_si512(x), _MM_CMPINT_LT); +} + +static INLINE vdouble vsel_vd_vo_vd_vd(vopmask mask, vdouble x, vdouble y) { + return _mm512_mask_blend_pd(mask, y, x); +} + +static INLINE CONST vdouble vsel_vd_vo_d_d(vopmask o, double v1, double v0) { + return vsel_vd_vo_vd_vd(o, vcast_vd_d(v1), vcast_vd_d(v0)); +} + +#if 1 +// Probably this is faster +static INLINE vdouble vsel_vd_vo_vo_vo_d_d_d_d(vopmask o0, vopmask o1, vopmask o2, double d0, double d1, double d2, double d3) { + __m512i v = _mm512_castpd_si512(vsel_vd_vo_vd_vd(o0, _mm512_castsi512_pd(_mm512_set_epi64(0, 0, 0, 0, 0, 0, 0, 0)), + vsel_vd_vo_vd_vd(o1, _mm512_castsi512_pd(_mm512_set_epi64(1, 1, 1, 1, 1, 1, 1, 1)), + vsel_vd_vo_vd_vd(o2, _mm512_castsi512_pd(_mm512_set_epi64(2, 2, 2, 2, 2, 2, 2, 2)), + _mm512_castsi512_pd(_mm512_set_epi64(3, 3, 3, 3, 3, 3, 3, 3)))))); + return _mm512_permutexvar_pd(v, _mm512_castpd256_pd512(_mm256_set_pd(d3, d2, d1, d0))); +} + +static INLINE vdouble vsel_vd_vo_vo_d_d_d(vopmask o0, vopmask o1, double d0, double d1, double d2) { + return vsel_vd_vo_vo_vo_d_d_d_d(o0, o1, o1, d0, d1, d2, d2); +} +#else +static INLINE vdouble vsel_vd_vo_vo_d_d_d(vopmask o0, vopmask o1, double d0, double d1, double d2) { + return vsel_vd_vo_vd_vd(o0, vcast_vd_d(d0), vsel_vd_vo_d_d(o1, d1, d2)); +} + +static INLINE vdouble vsel_vd_vo_vo_vo_d_d_d_d(vopmask o0, vopmask o1, vopmask o2, double d0, double d1, double d2, double d3) { + return vsel_vd_vo_vd_vd(o0, vcast_vd_d(d0), vsel_vd_vo_vd_vd(o1, vcast_vd_d(d1), vsel_vd_vo_d_d(o2, d2, d3))); +} +#endif + +static INLINE vopmask visinf_vo_vd(vdouble d) { + return _mm512_cmp_pd_mask(vabs_vd_vd(d), _mm512_set1_pd(SLEEF_INFINITY), _CMP_EQ_OQ); +} + +static INLINE vopmask vispinf_vo_vd(vdouble d) { + return _mm512_cmp_pd_mask(d, _mm512_set1_pd(SLEEF_INFINITY), _CMP_EQ_OQ); +} + +static INLINE vopmask visminf_vo_vd(vdouble d) { + return _mm512_cmp_pd_mask(d, _mm512_set1_pd(-SLEEF_INFINITY), _CMP_EQ_OQ); +} + +static INLINE vopmask visnan_vo_vd(vdouble d) { + return _mm512_cmp_pd_mask(d, d, _CMP_NEQ_UQ); +} + +static INLINE vint vilogbk_vi_vd(vdouble d) { return vrint_vi_vd(_mm512_getexp_pd(d)); } + +// vilogb2k_vi_vd is similar to vilogbk_vi_vd, but the argument has to +// be a normalized FP value. +static INLINE vint vilogb2k_vi_vd(vdouble d) { return vrint_vi_vd(_mm512_getexp_pd(d)); } + +static INLINE vdouble vgetexp_vd_vd(vdouble d) { return _mm512_getexp_pd(d); } +static INLINE vfloat vgetexp_vf_vf(vfloat d) { return _mm512_getexp_ps(d); } + +static INLINE vdouble vgetmant_vd_vd(vdouble d) { return _mm512_getmant_pd(d, _MM_MANT_NORM_p75_1p5, _MM_MANT_SIGN_nan); } +static INLINE vfloat vgetmant_vf_vf(vfloat d) { return _mm512_getmant_ps(d, _MM_MANT_NORM_p75_1p5, _MM_MANT_SIGN_nan); } + +#define vfixup_vd_vd_vd_vi2_i(a, b, c, imm) _mm512_fixupimm_pd((a), (b), (c), (imm)) +#define vfixup_vf_vf_vf_vi2_i(a, b, c, imm) _mm512_fixupimm_ps((a), (b), (c), (imm)) +//@#define vfixup_vd_vd_vd_vi2_i(a, b, c, imm) _mm512_fixupimm_pd((a), (b), (c), (imm)) +//@#define vfixup_vf_vf_vf_vi2_i(a, b, c, imm) _mm512_fixupimm_ps((a), (b), (c), (imm)) + +#if defined(_MSC_VER) +// This function is needed when debugging on MSVC. +static INLINE double vcast_d_vd(vdouble v) { + double s[VECTLENDP]; + _mm512_storeu_pd(s, v); + return s[0]; +} +#endif + +static INLINE vdouble vload_vd_p(const double *ptr) { return _mm512_load_pd(ptr); } +static INLINE vdouble vloadu_vd_p(const double *ptr) { return _mm512_loadu_pd(ptr); } + +static INLINE void vstore_v_p_vd(double *ptr, vdouble v) { _mm512_store_pd(ptr, v); } +static INLINE void vstoreu_v_p_vd(double *ptr, vdouble v) { _mm512_storeu_pd(ptr, v); } + +static INLINE vdouble vgather_vd_p_vi(const double *ptr, vint vi) { return _mm512_i32gather_pd(vi, ptr, 8); } + +// + +static INLINE vint vsel_vi_vo_vi_vi(vopmask m, vint x, vint y) { + return _mm512_castsi512_si256(_mm512_mask_blend_epi32(m, _mm512_castsi256_si512(y), _mm512_castsi256_si512(x))); +} + +// + +static INLINE vmask vreinterpret_vm_vf(vfloat vf) { return _mm512_castps_si512(vf); } +static INLINE vfloat vreinterpret_vf_vm(vmask vm) { return _mm512_castsi512_ps(vm); } +static INLINE vfloat vreinterpret_vf_vi2(vint2 vi) { return _mm512_castsi512_ps(vi); } +static INLINE vint2 vreinterpret_vi2_vf(vfloat vf) { return _mm512_castps_si512(vf); } + +static INLINE vdouble vreinterpret_vd_vf(vfloat vf) { return _mm512_castps_pd(vf); } +static INLINE vfloat vreinterpret_vf_vd(vdouble vd) { return _mm512_castpd_ps(vd); } + +static INLINE vint2 vcast_vi2_vm(vmask vm) { return vm; } +static INLINE vmask vcast_vm_vi2(vint2 vi) { return vi; } + +static INLINE vfloat vcast_vf_vi2(vint2 vi) { return _mm512_cvtepi32_ps(vcast_vm_vi2(vi)); } +static INLINE vfloat vcast_vf_f(float f) { return _mm512_set1_ps(f); } +static INLINE vint2 vcast_vi2_i(int i) { return _mm512_set1_epi32(i); } +static INLINE vint2 vrint_vi2_vf(vfloat vf) { return vcast_vi2_vm(_mm512_cvtps_epi32(vf)); } +static INLINE vint2 vtruncate_vi2_vf(vfloat vf) { return vcast_vi2_vm(_mm512_cvttps_epi32(vf)); } + +static INLINE vfloat vtruncate_vf_vf(vfloat vd) { + return _mm512_roundscale_ps(vd, _MM_FROUND_TO_ZERO |_MM_FROUND_NO_EXC); +} + +static INLINE vfloat vrint_vf_vf(vfloat vd) { + return _mm512_roundscale_ps(vd, _MM_FROUND_TO_NEAREST_INT |_MM_FROUND_NO_EXC); +} + +static INLINE vfloat vadd_vf_vf_vf(vfloat x, vfloat y) { return _mm512_add_ps(x, y); } +static INLINE vfloat vsub_vf_vf_vf(vfloat x, vfloat y) { return _mm512_sub_ps(x, y); } +static INLINE vfloat vmul_vf_vf_vf(vfloat x, vfloat y) { return _mm512_mul_ps(x, y); } +static INLINE vfloat vdiv_vf_vf_vf(vfloat x, vfloat y) { return _mm512_div_ps(x, y); } +static INLINE vfloat vrec_vf_vf(vfloat x) { return vdiv_vf_vf_vf(vcast_vf_f(1.0f), x); } +static INLINE vfloat vsqrt_vf_vf(vfloat x) { return _mm512_sqrt_ps(x); } +static INLINE vfloat vabs_vf_vf(vfloat f) { return vreinterpret_vf_vm(vandnot_vm_vm_vm(vreinterpret_vm_vf(vcast_vf_f(-0.0f)), vreinterpret_vm_vf(f))); } +static INLINE vfloat vneg_vf_vf(vfloat d) { return vreinterpret_vf_vm(vxor_vm_vm_vm(vreinterpret_vm_vf(vcast_vf_f(-0.0f)), vreinterpret_vm_vf(d))); } +static INLINE vfloat vmax_vf_vf_vf(vfloat x, vfloat y) { return _mm512_max_ps(x, y); } +static INLINE vfloat vmin_vf_vf_vf(vfloat x, vfloat y) { return _mm512_min_ps(x, y); } + +#if CONFIG == 1 +static INLINE vfloat vmla_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return _mm512_fmadd_ps(x, y, z); } +static INLINE vfloat vmlapn_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return _mm512_fmsub_ps(x, y, z); } +static INLINE vfloat vmlanp_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return _mm512_fnmadd_ps(x, y, z); } +#else +static INLINE vfloat vmla_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return vadd_vf_vf_vf(vmul_vf_vf_vf(x, y), z); } +static INLINE vfloat vmlanp_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return vsub_vf_vf_vf(z, vmul_vf_vf_vf(x, y)); } +static INLINE vfloat vmlapn_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return vsub_vf_vf_vf(vmul_vf_vf_vf(x, y), z); } +#endif + +static INLINE vfloat vfma_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return _mm512_fmadd_ps(x, y, z); } +static INLINE vfloat vfmapp_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return _mm512_fmadd_ps(x, y, z); } +static INLINE vfloat vfmapn_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return _mm512_fmsub_ps(x, y, z); } +static INLINE vfloat vfmanp_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return _mm512_fnmadd_ps(x, y, z); } +static INLINE vfloat vfmann_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return _mm512_fnmsub_ps(x, y, z); } + +static INLINE vopmask veq_vo_vf_vf(vfloat x, vfloat y) { return _mm512_cmp_ps_mask(x, y, _CMP_EQ_OQ); } +static INLINE vopmask vneq_vo_vf_vf(vfloat x, vfloat y) { return _mm512_cmp_ps_mask(x, y, _CMP_NEQ_UQ); } +static INLINE vopmask vlt_vo_vf_vf(vfloat x, vfloat y) { return _mm512_cmp_ps_mask(x, y, _CMP_LT_OQ); } +static INLINE vopmask vle_vo_vf_vf(vfloat x, vfloat y) { return _mm512_cmp_ps_mask(x, y, _CMP_LE_OQ); } +static INLINE vopmask vgt_vo_vf_vf(vfloat x, vfloat y) { return _mm512_cmp_ps_mask(x, y, _CMP_GT_OQ); } +static INLINE vopmask vge_vo_vf_vf(vfloat x, vfloat y) { return _mm512_cmp_ps_mask(x, y, _CMP_GE_OQ); } + +static INLINE vint2 vadd_vi2_vi2_vi2(vint2 x, vint2 y) { return _mm512_add_epi32(x, y); } +static INLINE vint2 vsub_vi2_vi2_vi2(vint2 x, vint2 y) { return _mm512_sub_epi32(x, y); } +static INLINE vint2 vneg_vi2_vi2(vint2 e) { return vsub_vi2_vi2_vi2(vcast_vi2_i(0), e); } +static INLINE vint2 vand_vi2_vi2_vi2(vint2 x, vint2 y) { return _mm512_and_si512(x, y); } +static INLINE vint2 vandnot_vi2_vi2_vi2(vint2 x, vint2 y) { return _mm512_andnot_si512(x, y); } +static INLINE vint2 vor_vi2_vi2_vi2(vint2 x, vint2 y) { return _mm512_or_si512(x, y); } +static INLINE vint2 vxor_vi2_vi2_vi2(vint2 x, vint2 y) { return _mm512_xor_si512(x, y); } + +static INLINE vint2 vand_vi2_vo_vi2(vopmask o, vint2 m) { + return _mm512_mask_and_epi32(_mm512_set1_epi32(0), o, m, m); +} + +static INLINE vint2 vandnot_vi2_vo_vi2(vopmask o, vint2 m) { + return _mm512_mask_and_epi32(m, o, _mm512_set1_epi32(0), _mm512_set1_epi32(0)); +} + +#define vsll_vi2_vi2_i(x, c) _mm512_slli_epi32(x, c) +#define vsrl_vi2_vi2_i(x, c) _mm512_srli_epi32(x, c) +#define vsra_vi2_vi2_i(x, c) _mm512_srai_epi32(x, c) +//@#define vsll_vi2_vi2_i(x, c) _mm512_slli_epi32(x, c) +//@#define vsrl_vi2_vi2_i(x, c) _mm512_srli_epi32(x, c) +//@#define vsra_vi2_vi2_i(x, c) _mm512_srai_epi32(x, c) +static INLINE vopmask veq_vo_vi2_vi2(vint2 x, vint2 y) { return _mm512_cmpeq_epi32_mask(x, y); } +static INLINE vopmask vgt_vo_vi2_vi2(vint2 x, vint2 y) { return _mm512_cmpgt_epi32_mask(x, y); } + +static INLINE vint2 veq_vi2_vi2_vi2(vint2 x, vint2 y) { + __mmask16 m = _mm512_cmp_epi32_mask(x, y, _MM_CMPINT_EQ); + return _mm512_mask_and_epi32(_mm512_set1_epi32(0), m, _mm512_set1_epi32(-1), _mm512_set1_epi32(-1)); +} +static INLINE vint2 vgt_vi2_vi2_vi2(vint2 x, vint2 y) { + __mmask16 m = _mm512_cmp_epi32_mask(y, x, _MM_CMPINT_LT); + return _mm512_mask_and_epi32(_mm512_set1_epi32(0), m, _mm512_set1_epi32(-1), _mm512_set1_epi32(-1)); +} + +static INLINE vint2 vsel_vi2_vo_vi2_vi2(vopmask m, vint2 x, vint2 y) { + return _mm512_mask_blend_epi32(m, y, x); +} + +static INLINE vfloat vsel_vf_vo_vf_vf(vopmask m, vfloat x, vfloat y) { + return _mm512_mask_blend_ps(m, y, x); +} + +// At this point, the following three functions are implemented in a generic way, +// but I will try target-specific optimization later on. +static INLINE CONST vfloat vsel_vf_vo_f_f(vopmask o, float v1, float v0) { + return vsel_vf_vo_vf_vf(o, vcast_vf_f(v1), vcast_vf_f(v0)); +} + +static INLINE vfloat vsel_vf_vo_vo_f_f_f(vopmask o0, vopmask o1, float d0, float d1, float d2) { + return vsel_vf_vo_vf_vf(o0, vcast_vf_f(d0), vsel_vf_vo_f_f(o1, d1, d2)); +} + +static INLINE vfloat vsel_vf_vo_vo_vo_f_f_f_f(vopmask o0, vopmask o1, vopmask o2, float d0, float d1, float d2, float d3) { + return vsel_vf_vo_vf_vf(o0, vcast_vf_f(d0), vsel_vf_vo_vf_vf(o1, vcast_vf_f(d1), vsel_vf_vo_f_f(o2, d2, d3))); +} + +static INLINE vopmask visinf_vo_vf(vfloat d) { return veq_vo_vf_vf(vabs_vf_vf(d), vcast_vf_f(SLEEF_INFINITYf)); } +static INLINE vopmask vispinf_vo_vf(vfloat d) { return veq_vo_vf_vf(d, vcast_vf_f(SLEEF_INFINITYf)); } +static INLINE vopmask visminf_vo_vf(vfloat d) { return veq_vo_vf_vf(d, vcast_vf_f(-SLEEF_INFINITYf)); } +static INLINE vopmask visnan_vo_vf(vfloat d) { return vneq_vo_vf_vf(d, d); } + +static INLINE vint2 vilogbk_vi2_vf(vfloat d) { return vrint_vi2_vf(_mm512_getexp_ps(d)); } +static INLINE vint2 vilogb2k_vi2_vf(vfloat d) { return vrint_vi2_vf(_mm512_getexp_ps(d)); } + +#ifdef _MSC_VER +// This function is needed when debugging on MSVC. +static INLINE float vcast_f_vf(vfloat v) { + float s[VECTLENSP]; + _mm512_storeu_ps(s, v); + return s[0]; +} +#endif + +static INLINE vfloat vload_vf_p(const float *ptr) { return _mm512_load_ps(ptr); } +static INLINE vfloat vloadu_vf_p(const float *ptr) { return _mm512_loadu_ps(ptr); } + +static INLINE void vstore_v_p_vf(float *ptr, vfloat v) { _mm512_store_ps(ptr, v); } +static INLINE void vstoreu_v_p_vf(float *ptr, vfloat v) { _mm512_storeu_ps(ptr, v); } + +static INLINE vfloat vgather_vf_p_vi2(const float *ptr, vint2 vi2) { return _mm512_i32gather_ps(vi2, ptr, 4); } + +// + +static INLINE vdouble vposneg_vd_vd(vdouble d) { + return vreinterpret_vd_vm(_mm512_mask_xor_epi32(vreinterpret_vm_vd(d), 0xcccc, vreinterpret_vm_vd(d), vreinterpret_vm_vd(_mm512_set1_pd(-0.0)))); +} +static INLINE vdouble vnegpos_vd_vd(vdouble d) { + return vreinterpret_vd_vm(_mm512_mask_xor_epi32(vreinterpret_vm_vd(d), 0x3333, vreinterpret_vm_vd(d), vreinterpret_vm_vd(_mm512_set1_pd(-0.0)))); +} +static INLINE vfloat vposneg_vf_vf(vfloat d) { + return vreinterpret_vf_vm(_mm512_mask_xor_epi32(vreinterpret_vm_vf(d), 0xaaaa, vreinterpret_vm_vf(d), vreinterpret_vm_vf(_mm512_set1_ps(-0.0f)))); +} +static INLINE vfloat vnegpos_vf_vf(vfloat d) { + return vreinterpret_vf_vm(_mm512_mask_xor_epi32(vreinterpret_vm_vf(d), 0x5555, vreinterpret_vm_vf(d), vreinterpret_vm_vf(_mm512_set1_ps(-0.0f)))); +} + +static INLINE vdouble vsubadd_vd_vd_vd(vdouble x, vdouble y) { return vadd_vd_vd_vd(x, vnegpos_vd_vd(y)); } +static INLINE vfloat vsubadd_vf_vf_vf(vfloat x, vfloat y) { return vadd_vf_vf_vf(x, vnegpos_vf_vf(y)); } + +static INLINE vdouble vmlsubadd_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return _mm512_fmaddsub_pd(x, y, z); } +static INLINE vfloat vmlsubadd_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return _mm512_fmaddsub_ps(x, y, z); } + +static INLINE vdouble vrev21_vd_vd(vdouble vd) { return _mm512_permute_pd(vd, 0x55); } + +static INLINE vdouble vreva2_vd_vd(vdouble vd) { + return vreinterpret_vd_vm(_mm512_permutexvar_epi32(_mm512_set_epi32(3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12), vreinterpret_vm_vd(vd))); +} + +static INLINE void vstream_v_p_vd(double *ptr, vdouble v) { _mm512_stream_pd(ptr, v); } + +static INLINE void vscatter2_v_p_i_i_vd(double *ptr, int offset, int step, vdouble v) { + _mm_store_pd(&ptr[(offset + step * 0)*2], _mm_castps_pd(_mm512_extractf32x4_ps(vreinterpret_vf_vd(v), 0))); + _mm_store_pd(&ptr[(offset + step * 1)*2], _mm_castps_pd(_mm512_extractf32x4_ps(vreinterpret_vf_vd(v), 1))); + _mm_store_pd(&ptr[(offset + step * 2)*2], _mm_castps_pd(_mm512_extractf32x4_ps(vreinterpret_vf_vd(v), 2))); + _mm_store_pd(&ptr[(offset + step * 3)*2], _mm_castps_pd(_mm512_extractf32x4_ps(vreinterpret_vf_vd(v), 3))); +} + +static INLINE void vsscatter2_v_p_i_i_vd(double *ptr, int offset, int step, vdouble v) { + _mm_stream_pd(&ptr[(offset + step * 0)*2], _mm_castps_pd(_mm512_extractf32x4_ps(vreinterpret_vf_vd(v), 0))); + _mm_stream_pd(&ptr[(offset + step * 1)*2], _mm_castps_pd(_mm512_extractf32x4_ps(vreinterpret_vf_vd(v), 1))); + _mm_stream_pd(&ptr[(offset + step * 2)*2], _mm_castps_pd(_mm512_extractf32x4_ps(vreinterpret_vf_vd(v), 2))); + _mm_stream_pd(&ptr[(offset + step * 3)*2], _mm_castps_pd(_mm512_extractf32x4_ps(vreinterpret_vf_vd(v), 3))); +} + +// + +static INLINE vfloat vrev21_vf_vf(vfloat vf) { return _mm512_permute_ps(vf, 0xb1); } + +static INLINE vfloat vreva2_vf_vf(vfloat vf) { + return vreinterpret_vf_vm(_mm512_permutexvar_epi32(_mm512_set_epi32(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14), vreinterpret_vm_vf(vf))); +} + +static INLINE void vstream_v_p_vf(float *ptr, vfloat v) { _mm512_stream_ps(ptr, v); } + +static INLINE void vscatter2_v_p_i_i_vf(float *ptr, int offset, int step, vfloat v) { + _mm_storel_pd((double *)(ptr+(offset + step * 0)*2), _mm_castps_pd(_mm512_extractf32x4_ps(v, 0))); + _mm_storeh_pd((double *)(ptr+(offset + step * 1)*2), _mm_castps_pd(_mm512_extractf32x4_ps(v, 0))); + _mm_storel_pd((double *)(ptr+(offset + step * 2)*2), _mm_castps_pd(_mm512_extractf32x4_ps(v, 1))); + _mm_storeh_pd((double *)(ptr+(offset + step * 3)*2), _mm_castps_pd(_mm512_extractf32x4_ps(v, 1))); + _mm_storel_pd((double *)(ptr+(offset + step * 4)*2), _mm_castps_pd(_mm512_extractf32x4_ps(v, 2))); + _mm_storeh_pd((double *)(ptr+(offset + step * 5)*2), _mm_castps_pd(_mm512_extractf32x4_ps(v, 2))); + _mm_storel_pd((double *)(ptr+(offset + step * 6)*2), _mm_castps_pd(_mm512_extractf32x4_ps(v, 3))); + _mm_storeh_pd((double *)(ptr+(offset + step * 7)*2), _mm_castps_pd(_mm512_extractf32x4_ps(v, 3))); +} + +static INLINE void vsscatter2_v_p_i_i_vf(float *ptr, int offset, int step, vfloat v) { vscatter2_v_p_i_i_vf(ptr, offset, step, v); } + +// + +static vquad loadu_vq_p(void *p) { + vquad vq; + memcpy(&vq, p, VECTLENDP * 16); + return vq; +} + +static INLINE vquad cast_vq_aq(vargquad aq) { + vquad vq; + memcpy(&vq, &aq, VECTLENDP * 16); + return vq; +} + +static INLINE vargquad cast_aq_vq(vquad vq) { + vargquad aq; + memcpy(&aq, &vq, VECTLENDP * 16); + return aq; +} + +#ifdef __INTEL_COMPILER +static INLINE int vtestallzeros_i_vo64(vopmask g) { return _mm512_mask2int(g) == 0; } +#else +static INLINE int vtestallzeros_i_vo64(vopmask g) { return g == 0; } +#endif + +static INLINE vmask vsel_vm_vo64_vm_vm(vopmask m, vmask x, vmask y) { return _mm512_mask_blend_epi64(m, y, x); } + +static INLINE vmask vsub64_vm_vm_vm(vmask x, vmask y) { return _mm512_sub_epi64(x, y); } +static INLINE vmask vneg64_vm_vm(vmask x) { return _mm512_sub_epi64(vcast_vm_i_i(0, 0), x); } +static INLINE vopmask vgt64_vo_vm_vm(vmask x, vmask y) { return _mm512_cmp_epi64_mask(y, x, _MM_CMPINT_LT); } // signed compare + +#define vsll64_vm_vm_i(x, c) _mm512_slli_epi64(x, c) +#define vsrl64_vm_vm_i(x, c) _mm512_srli_epi64(x, c) +//@#define vsll64_vm_vm_i(x, c) _mm512_slli_epi64(x, c) +//@#define vsrl64_vm_vm_i(x, c) _mm512_srli_epi64(x, c) + +static INLINE vmask vcast_vm_vi(vint vi) { + return _mm512_cvtepi32_epi64(vi); +} +static INLINE vint vcast_vi_vm(vmask vm) { + return _mm512_cvtepi64_epi32(vm); +} + +static INLINE vmask vreinterpret_vm_vi64(vint64 v) { return v; } +static INLINE vint64 vreinterpret_vi64_vm(vmask m) { return m; } +static INLINE vmask vreinterpret_vm_vu64(vuint64 v) { return v; } +static INLINE vuint64 vreinterpret_vu64_vm(vmask m) { return m; } diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/arch/helperneon32.h b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/arch/helperneon32.h new file mode 100644 index 00000000000..042cad40e1d --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/arch/helperneon32.h @@ -0,0 +1,297 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#if !defined(__ARM_NEON) && !defined(SLEEF_GENHEADER) +#error Please specify -mfpu=neon. +#endif + +#ifdef __aarch64__ +#warning This implementation is for AARCH32. +#endif + +#define ENABLE_SP +//@#define ENABLE_SP +#define LOG2VECTLENSP 2 +//@#define LOG2VECTLENSP 2 +#define VECTLENSP (1 << LOG2VECTLENSP) +//@#define VECTLENSP (1 << LOG2VECTLENSP) + +#if CONFIG == 4 +#define ISANAME "AARCH32 NEON-VFPV4" +#define ENABLE_FMA_SP +//@#define ENABLE_FMA_SP +#else +#define ISANAME "AARCH32 NEON" +#endif +#define DFTPRIORITY 10 + +#define ENABLE_RECSQRT_SP +//@#define ENABLE_RECSQRT_SP + +#include +#include + +#include "misc.h" + +typedef uint32x4_t vmask; +typedef uint32x4_t vopmask; + +//typedef int32x4_t vint; + +typedef float32x4_t vfloat; +typedef int32x4_t vint2; + +// + +static INLINE void vprefetch_v_p(const void *ptr) { } + +static INLINE int vtestallones_i_vo32(vopmask g) { + uint32x2_t x0 = vand_u32(vget_low_u32(g), vget_high_u32(g)); + uint32x2_t x1 = vpmin_u32(x0, x0); + return vget_lane_u32(x1, 0); +} + +static vfloat vloaduf(float *p) { return vld1q_f32(p); } +static void vstoreuf(float *p, vfloat v) { vst1q_f32(p, v); } + +static vint2 vloadu_vi2_p(int32_t *p) { return vld1q_s32(p); } +static void vstoreu_v_p_vi2(int32_t *p, vint2 v) { vst1q_s32(p, v); } + +// + +static INLINE vmask vand_vm_vm_vm(vmask x, vmask y) { return vandq_u32(x, y); } +static INLINE vmask vandnot_vm_vm_vm(vmask x, vmask y) { return vbicq_u32(y, x); } +static INLINE vmask vor_vm_vm_vm(vmask x, vmask y) { return vorrq_u32(x, y); } +static INLINE vmask vxor_vm_vm_vm(vmask x, vmask y) { return veorq_u32(x, y); } + +static INLINE vopmask vand_vo_vo_vo(vopmask x, vopmask y) { return vandq_u32(x, y); } +static INLINE vopmask vandnot_vo_vo_vo(vopmask x, vopmask y) { return vbicq_u32(y, x); } +static INLINE vopmask vor_vo_vo_vo(vopmask x, vopmask y) { return vorrq_u32(x, y); } +static INLINE vopmask vxor_vo_vo_vo(vopmask x, vopmask y) { return veorq_u32(x, y); } + +static INLINE vmask vand_vm_vo64_vm(vopmask x, vmask y) { return vandq_u32(x, y); } +static INLINE vmask vandnot_vm_vo64_vm(vopmask x, vmask y) { return vbicq_u32(y, x); } +static INLINE vmask vor_vm_vo64_vm(vopmask x, vmask y) { return vorrq_u32(x, y); } +static INLINE vmask vxor_vm_vo64_vm(vopmask x, vmask y) { return veorq_u32(x, y); } + +static INLINE vmask vand_vm_vo32_vm(vopmask x, vmask y) { return vandq_u32(x, y); } +static INLINE vmask vandnot_vm_vo32_vm(vopmask x, vmask y) { return vbicq_u32(y, x); } +static INLINE vmask vor_vm_vo32_vm(vopmask x, vmask y) { return vorrq_u32(x, y); } +static INLINE vmask vxor_vm_vo32_vm(vopmask x, vmask y) { return veorq_u32(x, y); } + +static INLINE vopmask vcast_vo32_vo64(vopmask m) { return vuzpq_u32(m, m).val[0]; } +static INLINE vopmask vcast_vo64_vo32(vopmask m) { return vzipq_u32(m, m).val[0]; } + +// + +static INLINE vmask vcast_vm_i_i(int i0, int i1) { return (vmask)vdupq_n_u64((uint64_t)i0 | (((uint64_t)i1) << 32)); } +static INLINE vopmask veq64_vo_vm_vm(vmask x, vmask y) { + uint32x4_t t = vceqq_u32(x, y); + return vandq_u32(t, vrev64q_u32(t)); +} + +// + +static INLINE vint2 vcast_vi2_vm(vmask vm) { return (vint2)vm; } +static INLINE vmask vcast_vm_vi2(vint2 vi) { return (vmask)vi; } +static INLINE vint2 vrint_vi2_vf(vfloat d) { + return vcvtq_s32_f32(vaddq_f32(d, (float32x4_t)vorrq_u32(vandq_u32((uint32x4_t)d, (uint32x4_t)vdupq_n_f32(-0.0f)), (uint32x4_t)vdupq_n_f32(0.5f)))); +} +static INLINE vint2 vtruncate_vi2_vf(vfloat vf) { return vcvtq_s32_f32(vf); } +static INLINE vfloat vcast_vf_vi2(vint2 vi) { return vcvtq_f32_s32(vi); } + +static INLINE vfloat vtruncate_vf_vf(vfloat vd) { return vcast_vf_vi2(vtruncate_vi2_vf(vd)); } +static INLINE vfloat vrint_vf_vf(vfloat vd) { return vcast_vf_vi2(vrint_vi2_vf(vd)); } + +static INLINE vfloat vcast_vf_f(float f) { return vdupq_n_f32(f); } +static INLINE vint2 vcast_vi2_i(int i) { return vdupq_n_s32(i); } +static INLINE vmask vreinterpret_vm_vf(vfloat vf) { return (vmask)vf; } +static INLINE vfloat vreinterpret_vf_vm(vmask vm) { return (vfloat)vm; } +static INLINE vfloat vreinterpret_vf_vi2(vint2 vm) { return (vfloat)vm; } +static INLINE vint2 vreinterpret_vi2_vf(vfloat vf) { return (vint2)vf; } + +static INLINE vfloat vadd_vf_vf_vf(vfloat x, vfloat y) { return vaddq_f32(x, y); } +static INLINE vfloat vsub_vf_vf_vf(vfloat x, vfloat y) { return vsubq_f32(x, y); } +static INLINE vfloat vmul_vf_vf_vf(vfloat x, vfloat y) { return vmulq_f32(x, y); } + +static INLINE vfloat vabs_vf_vf(vfloat f) { return vabsq_f32(f); } +static INLINE vfloat vneg_vf_vf(vfloat f) { return vnegq_f32(f); } +#if CONFIG == 4 +static INLINE vfloat vmla_vf_vf_vf_vf (vfloat x, vfloat y, vfloat z) { return vfmaq_f32(z, x, y); } +static INLINE vfloat vmlanp_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return vfmsq_f32(z, x, y); } +static INLINE vfloat vfma_vf_vf_vf_vf (vfloat x, vfloat y, vfloat z) { return vfmaq_f32(z, x, y); } +static INLINE vfloat vfmanp_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return vfmsq_f32(z, x, y); } +static INLINE vfloat vfmapn_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return vneg_vf_vf(vfmanp_vf_vf_vf_vf(x, y, z)); } +static INLINE vfloat vmlapn_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return vneg_vf_vf(vfmanp_vf_vf_vf_vf(x, y, z)); } + +static INLINE vfloat vdiv_vf_vf_vf(vfloat x, vfloat y) { + float32x4_t t = vrecpeq_f32(y), u; + t = vmulq_f32(t, vrecpsq_f32(y, t)); + t = vfmaq_f32(t, vfmsq_f32(vdupq_n_f32(1.0f), y, t), t); + u = vmulq_f32(x, t); + return vfmaq_f32(u, vfmsq_f32(x, y, u), t); +} + +static INLINE vfloat vsqrt_vf_vf(vfloat d) { + float32x4_t x = vrsqrteq_f32(d); + x = vmulq_f32(x, vrsqrtsq_f32(d, vmulq_f32(x, x))); + x = vmulq_f32(x, vrsqrtsq_f32(d, vmulq_f32(x, x))); + float32x4_t u = vmulq_f32(x, d); + u = vfmaq_f32(u, vfmsq_f32(d, u, u), vmulq_f32(x, vdupq_n_f32(0.5))); + return vreinterpretq_f32_u32(vbicq_u32(vreinterpretq_u32_f32(u), vceqq_f32(d, vdupq_n_f32(0.0f)))); +} + +static INLINE vfloat vrec_vf_vf(vfloat y) { + float32x4_t t = vrecpeq_f32(y); + t = vmulq_f32(t, vrecpsq_f32(y, t)); + t = vfmaq_f32(t, vfmsq_f32(vdupq_n_f32(1.0f), y, t), t); + return vfmaq_f32(t, vfmsq_f32(vdupq_n_f32(1.0f), y, t), t); +} + +static INLINE vfloat vrecsqrt_vf_vf(vfloat d) { + float32x4_t x = vrsqrteq_f32(d); + x = vmulq_f32(x, vrsqrtsq_f32(d, vmulq_f32(x, x))); + return vfmaq_f32(x, vfmsq_f32(vdupq_n_f32(1), x, vmulq_f32(x, d)), vmulq_f32(x, vdupq_n_f32(0.5))); +} +#else // #if CONFIG == 4 +static INLINE vfloat vmla_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return vmlaq_f32(z, x, y); } +static INLINE vfloat vmlanp_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return vmlsq_f32(z, x, y); } +static INLINE vfloat vmlapn_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return vneg_vf_vf(vmlsq_f32(z, x, y)); } + +static INLINE vfloat vdiv_vf_vf_vf(vfloat n, vfloat d) { + float32x4_t x = vrecpeq_f32(d); + x = vmulq_f32(x, vrecpsq_f32(d, x)); + float32x4_t t = vmulq_f32(n, x); + return vmlsq_f32(vaddq_f32(t, t), vmulq_f32(t, x), d); +} + +static INLINE vfloat vsqrt_vf_vf(vfloat d) { + float32x4_t x = vrsqrteq_f32(d); + x = vmulq_f32(x, vrsqrtsq_f32(d, vmulq_f32(x, x))); + float32x4_t u = vmulq_f32(x, d); + u = vmlaq_f32(u, vmlsq_f32(d, u, u), vmulq_f32(x, vdupq_n_f32(0.5))); + return vreinterpretq_f32_u32(vbicq_u32(vreinterpretq_u32_f32(u), vceqq_f32(d, vdupq_n_f32(0.0f)))); +} + +static INLINE vfloat vrec_vf_vf(vfloat d) { + float32x4_t x = vrecpeq_f32(d); + x = vmulq_f32(x, vrecpsq_f32(d, x)); + return vmlsq_f32(vaddq_f32(x, x), vmulq_f32(x, x), d); +} + +static INLINE vfloat vrecsqrt_vf_vf(vfloat d) { + float32x4_t x = vrsqrteq_f32(d); + x = vmulq_f32(x, vrsqrtsq_f32(d, vmulq_f32(x, x))); + return vmlaq_f32(x, vmlsq_f32(vdupq_n_f32(1), x, vmulq_f32(x, d)), vmulq_f32(x, vdupq_n_f32(0.5))); +} +#endif // #if CONFIG == 4 +static INLINE vfloat vmax_vf_vf_vf(vfloat x, vfloat y) { return vmaxq_f32(x, y); } +static INLINE vfloat vmin_vf_vf_vf(vfloat x, vfloat y) { return vminq_f32(x, y); } + +static INLINE vopmask veq_vo_vf_vf(vfloat x, vfloat y) { return vceqq_f32(x, y); } +static INLINE vopmask vneq_vo_vf_vf(vfloat x, vfloat y) { return vmvnq_u32(vceqq_f32(x, y)); } +static INLINE vopmask vlt_vo_vf_vf(vfloat x, vfloat y) { return vcltq_f32(x, y); } +static INLINE vopmask vle_vo_vf_vf(vfloat x, vfloat y) { return vcleq_f32(x, y); } +static INLINE vopmask vgt_vo_vf_vf(vfloat x, vfloat y) { return vcgtq_f32(x, y); } +static INLINE vopmask vge_vo_vf_vf(vfloat x, vfloat y) { return vcgeq_f32(x, y); } + +static INLINE vint2 vadd_vi2_vi2_vi2(vint2 x, vint2 y) { return vaddq_s32(x, y); } +static INLINE vint2 vsub_vi2_vi2_vi2(vint2 x, vint2 y) { return vsubq_s32(x, y); } +static INLINE vint2 vneg_vi2_vi2(vint2 e) { return vnegq_s32(e); } + +static INLINE vint2 vand_vi2_vi2_vi2(vint2 x, vint2 y) { return vandq_s32(x, y); } +static INLINE vint2 vandnot_vi2_vi2_vi2(vint2 x, vint2 y) { return vbicq_s32(y, x); } +static INLINE vint2 vor_vi2_vi2_vi2(vint2 x, vint2 y) { return vorrq_s32(x, y); } +static INLINE vint2 vxor_vi2_vi2_vi2(vint2 x, vint2 y) { return veorq_s32(x, y); } + +static INLINE vint2 vand_vi2_vo_vi2(vopmask x, vint2 y) { return (vint2)vandq_u32(x, (vopmask)y); } +static INLINE vint2 vandnot_vi2_vo_vi2(vopmask x, vint2 y) { return (vint2)vbicq_u32((vopmask)y, x); } + +#define vsll_vi2_vi2_i(x, c) vshlq_n_s32(x, c) +#define vsrl_vi2_vi2_i(x, c) vreinterpretq_s32_u32(vshrq_n_u32(vreinterpretq_u32_s32(x), c)) +#define vsra_vi2_vi2_i(x, c) vshrq_n_s32(x, c) +//@#define vsll_vi2_vi2_i(x, c) vshlq_n_s32(x, c) +//@#define vsrl_vi2_vi2_i(x, c) vreinterpretq_s32_u32(vshrq_n_u32(vreinterpretq_u32_s32(x), c)) +//@#define vsra_vi2_vi2_i(x, c) vshrq_n_s32(x, c) + +static INLINE vopmask veq_vo_vi2_vi2(vint2 x, vint2 y) { return vceqq_s32(x, y); } +static INLINE vopmask vgt_vo_vi2_vi2(vint2 x, vint2 y) { return vcgtq_s32(x, y); } +static INLINE vint2 veq_vi2_vi2_vi2(vint2 x, vint2 y) { return (vint2)vceqq_s32(x, y); } +static INLINE vint2 vgt_vi2_vi2_vi2(vint2 x, vint2 y) { return (vint2)vcgtq_s32(x, y); } + +static INLINE vint2 vsel_vi2_vo_vi2_vi2(vopmask m, vint2 x, vint2 y) { return (vint2)vbslq_u32(m, (vmask)x, (vmask)y); } + +static INLINE vfloat vsel_vf_vo_vf_vf(vopmask mask, vfloat x, vfloat y) { + return (vfloat)vbslq_u32(mask, (vmask)x, (vmask)y); +} + +static INLINE CONST vfloat vsel_vf_vo_f_f(vopmask o, float v1, float v0) { + return vsel_vf_vo_vf_vf(o, vcast_vf_f(v1), vcast_vf_f(v0)); +} + +static INLINE vfloat vsel_vf_vo_vo_f_f_f(vopmask o0, vopmask o1, float d0, float d1, float d2) { + return vsel_vf_vo_vf_vf(o0, vcast_vf_f(d0), vsel_vf_vo_f_f(o1, d1, d2)); +} + +static INLINE vfloat vsel_vf_vo_vo_vo_f_f_f_f(vopmask o0, vopmask o1, vopmask o2, float d0, float d1, float d2, float d3) { + return vsel_vf_vo_vf_vf(o0, vcast_vf_f(d0), vsel_vf_vo_vf_vf(o1, vcast_vf_f(d1), vsel_vf_vo_f_f(o2, d2, d3))); +} + +static INLINE vopmask visinf_vo_vf(vfloat d) { return veq_vo_vf_vf(vabs_vf_vf(d), vcast_vf_f(SLEEF_INFINITYf)); } +static INLINE vopmask vispinf_vo_vf(vfloat d) { return veq_vo_vf_vf(d, vcast_vf_f(SLEEF_INFINITYf)); } +static INLINE vopmask visminf_vo_vf(vfloat d) { return veq_vo_vf_vf(d, vcast_vf_f(-SLEEF_INFINITYf)); } +static INLINE vopmask visnan_vo_vf(vfloat d) { return vneq_vo_vf_vf(d, d); } + +// This function is needed when debugging on MSVC. +static INLINE float vcast_f_vf(vfloat v) { + float p[4]; + vst1q_f32 (p, v); + return p[0]; +} + +static INLINE int vavailability_i(int name) { + if (name != 2) return 0; + return vcast_f_vf(vadd_vf_vf_vf(vcast_vf_f(name), vcast_vf_f(name))) != 0.0; +} + + +static INLINE vfloat vload_vf_p(const float *ptr) { return vld1q_f32(__builtin_assume_aligned(ptr, 16)); } +static INLINE vfloat vloadu_vf_p(const float *ptr) { return vld1q_f32(ptr); } + +static INLINE void vstore_v_p_vf(float *ptr, vfloat v) { vst1q_f32(__builtin_assume_aligned(ptr, 16), v); } +static INLINE void vstoreu_v_p_vf(float *ptr, vfloat v) { vst1q_f32(ptr, v); } + +static INLINE vfloat vgather_vf_p_vi2(const float *ptr, vint2 vi2) { + return ((vfloat) { + ptr[vgetq_lane_s32(vi2, 0)], + ptr[vgetq_lane_s32(vi2, 1)], + ptr[vgetq_lane_s32(vi2, 2)], + ptr[vgetq_lane_s32(vi2, 3)] + }); +} + +#define PNMASKf ((vfloat) { +0.0f, -0.0f, +0.0f, -0.0f }) +#define NPMASKf ((vfloat) { -0.0f, +0.0f, -0.0f, +0.0f }) + +static INLINE vfloat vposneg_vf_vf(vfloat d) { return (vfloat)vxor_vm_vm_vm((vmask)d, (vmask)PNMASKf); } +static INLINE vfloat vnegpos_vf_vf(vfloat d) { return (vfloat)vxor_vm_vm_vm((vmask)d, (vmask)NPMASKf); } + +static INLINE vfloat vsubadd_vf_vf_vf(vfloat d0, vfloat d1) { return vadd_vf_vf_vf(d0, vnegpos_vf_vf(d1)); } +static INLINE vfloat vmlsubadd_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return vsubadd_vf_vf_vf(vmul_vf_vf_vf(x, y), z); } + +static INLINE vfloat vrev21_vf_vf(vfloat d0) { return vrev64q_f32(d0); } +static INLINE vfloat vreva2_vf_vf(vfloat d0) { return vcombine_f32(vget_high_f32(d0), vget_low_f32(d0)); } + +static INLINE void vstream_v_p_vf(float *ptr, vfloat v) { vstore_v_p_vf(ptr, v); } + +static INLINE void vscatter2_v_p_i_i_vf(float *ptr, int offset, int step, vfloat v) { + vst1_f32((float *)(ptr+(offset + step * 0)*2), vget_low_f32(v)); + vst1_f32((float *)(ptr+(offset + step * 1)*2), vget_high_f32(v)); +} + +static INLINE void vsscatter2_v_p_i_i_vf(float *ptr, int offset, int step, vfloat v) { + vst1_f32((float *)(ptr+(offset + step * 0)*2), vget_low_f32(v)); + vst1_f32((float *)(ptr+(offset + step * 1)*2), vget_high_f32(v)); +} diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/arch/helperpower_128.h b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/arch/helperpower_128.h new file mode 100644 index 00000000000..f3ac298f948 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/arch/helperpower_128.h @@ -0,0 +1,873 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#if CONFIG == 1 || CONFIG == 2 || CONFIG == 3 || CONFIG == 4 + +#ifndef __VSX__ +#error Please specify -mcpu=power8 or -mcpu=power9 +#endif + +#else +#error CONFIG macro invalid or not defined +#endif + +#define ENABLE_DP +//@#define ENABLE_DP +#define LOG2VECTLENDP 1 +//@#define LOG2VECTLENDP 1 +#define VECTLENDP (1 << LOG2VECTLENDP) +//@#define VECTLENDP (1 << LOG2VECTLENDP) + +#define ENABLE_SP +//@#define ENABLE_SP +#define LOG2VECTLENSP (LOG2VECTLENDP+1) +//@#define LOG2VECTLENSP (LOG2VECTLENDP+1) +#define VECTLENSP (1 << LOG2VECTLENSP) +//@#define VECTLENSP (1 << LOG2VECTLENSP) + +#if CONFIG == 1 || CONFIG == 3 +#define ENABLE_FMA_DP +//@#define ENABLE_FMA_DP +#define ENABLE_FMA_SP +//@#define ENABLE_FMA_SP +#endif + +#define ACCURATE_SQRT +//@#define ACCURATE_SQRT +#define FULL_FP_ROUNDING +//@#define FULL_FP_ROUNDING + +#if !defined(SLEEF_GENHEADER) +#include +// undef altivec types since CPP and C99 use them as compiler tokens +// use __vector and __bool instead +#undef vector +#undef bool + +#include +#include "misc.h" +#endif // #if !defined(SLEEF_GENHEADER) + +#if CONFIG == 1 || CONFIG == 2 +#define ISANAME "VSX" +#else +#define ISANAME "VSX-3" +#endif + +#define DFTPRIORITY 25 + +static INLINE int vavailability_i(int name) { return 3; } +static INLINE void vprefetch_v_p(const void *ptr) { } + +/********************************************** + ** Types +***********************************************/ +typedef __vector unsigned int vmask; +// using __bool with typedef may cause ambiguous errors +#define vopmask __vector __bool int +//@#define vopmask __vector __bool int +typedef __vector signed int vint; +typedef __vector signed int vint2; +typedef __vector float vfloat; +typedef __vector double vdouble; + +// internal use types +typedef __vector unsigned int v__u32; +typedef __vector unsigned char v__u8; +typedef __vector signed long long v__i64; +typedef __vector unsigned long long v__u64; +#define v__b64 __vector __bool long long + +typedef __vector long long vint64; +typedef __vector unsigned long long vuint64; + +typedef struct { + vmask x, y; +} vquad; + +typedef vquad vargquad; + +/********************************************** + ** Utilities +***********************************************/ +#define vset__vi(v0, v1) ((vint) {v0, v1, v0, v1}) +#define vset__vi2(...) ((vint2) {__VA_ARGS__}) +#define vset__vm(...) ((vmask) {__VA_ARGS__}) +#define vset__vo(...) ((vopmask) {__VA_ARGS__}) +#define vset__vf(...) ((vfloat) {__VA_ARGS__}) +#define vset__vd(...) ((vdouble) {__VA_ARGS__}) +#define vset__u8(...) ((v__u8) {__VA_ARGS__}) +#define vset__u32(...) ((v__u32) {__VA_ARGS__}) +#define vset__s64(...) ((v__i64) {__VA_ARGS__}) +#define vset__u64(...) ((v__u64) {__VA_ARGS__}) + +#define vsetall__vi(v) vset__vi(v, v) +#define vsetall__vi2(v) vset__vi2(v, v, v, v) +#define vsetall__vm(v) vset__vm(v, v, v, v) +#define vsetall__vo(v) vset__vo(v, v, v, v) +#define vsetall__vf(v) vset__vf(v, v, v, v) +#define vsetall__vd(v) vset__vd(v, v) +#define vsetall__u8(v) vset__u8(v, v, v, v, v, v, v, v, v, v, v, v, v, v, v, v) +#define vsetall__u32(v) vset__u32(v, v, v, v) +#define vsetall__s64(v) vset__s64(v, v) +#define vsetall__u64(v) vset__u64(v, v) + +#define vzero__vi() vsetall__vi(0) +#define vzero__vi2() vsetall__vi2(0) +#define vzero__vm() vsetall__vm(0) +#define vzero__vo() vsetall__vo(0) +#define vzero__vf() vsetall__vf(0) +#define vzero__vd() vsetall__vd(0) +#define vzero__u8() vsetall__u8(0) +#define vzero__u32() vsetall__u32(0) +#define vzero__s64() vsetall__s64(0) +#define vzero__u64() vsetall__u64(0) + +//// Swap doubleword elements +#if defined(__clang__) || __GNUC__ >= 7 + static INLINE v__u64 v__swapd_u64(v__u64 v) + { return vec_xxpermdi(v, v, 2); } +#else + static INLINE v__u64 v__swapd_u64(v__u64 v) + { + __asm__ __volatile__("xxswapd %x0,%x1" : "=wa" (v) : "wa" (v)); + return v; + } +#endif + +/********************************************** + ** Memory +***********************************************/ + +////////////// Unaligned memory access ////////////// +/** + * It's not safe to use vector assignment via (cast & dereference) for unaligned memory access + * with almost all clang versions and gcc8 when VSX3 isn't enabled, + * these compilers tends to generate instructions 'lvx/stvx' instead of 'lxvd2x/lxvw4x/stxvd2x/stxvw4x' + * for more information check https://github.com/seiko2plus/vsx_mem_test + * + * TODO: check GCC(9, 10) +*/ +//// load +#if defined(__POWER9_VECTOR__) || (!defined(__clang__) && defined(__GNUC__) && __GNUC__ < 8) +static vint vloadu_vi_p(const int32_t *ptr) +{ return *((vint*)ptr); } +static INLINE vint2 vloadu_vi2_p(const int32_t *ptr) +{ return *((vint2*)ptr); } +static INLINE vfloat vloadu_vf_p(const float *ptr) +{ return *((vfloat*)ptr); } +static INLINE vdouble vloadu_vd_p(const double *ptr) +{ return *((vdouble*)ptr); } +#else +static vint vloadu_vi_p(const int32_t *ptr) +{ return vec_vsx_ld(0, ptr); } +static INLINE vint2 vloadu_vi2_p(const int32_t *ptr) +{ return vec_vsx_ld(0, ptr); } +static INLINE vfloat vloadu_vf_p(const float *ptr) +{ return vec_vsx_ld(0, ptr); } +static INLINE vdouble vloadu_vd_p(const double *ptr) +{ return vec_vsx_ld(0, ptr); } +#endif + +//// store +#if defined(__POWER9_VECTOR__) || (!defined(__clang__) && defined(__GNUC__) && __GNUC__ < 8) +static void vstoreu_v_p_vi(int32_t *ptr, vint v) +{ *((vint*)ptr) = v; } +static void vstoreu_v_p_vi2(int32_t *ptr, vint2 v) +{ *((vint2*)ptr) = v; } +static INLINE void vstoreu_v_p_vf(float *ptr, vfloat v) +{ *((vfloat*)ptr) = v; } +static INLINE void vstoreu_v_p_vd(double *ptr, vdouble v) +{ *((vdouble*)ptr) = v; } +#else +static void vstoreu_v_p_vi(int32_t *ptr, vint v) +{ vec_vsx_st(v, 0, ptr); } +static void vstoreu_v_p_vi2(int32_t *ptr, vint2 v) +{ vec_vsx_st(v, 0, ptr); } +static INLINE void vstoreu_v_p_vf(float *ptr, vfloat v) +{ vec_vsx_st(v, 0, ptr); } +static INLINE void vstoreu_v_p_vd(double *ptr, vdouble v) +{ vec_vsx_st(v, 0, ptr); } +#endif + +////////////// aligned memory access ////////////// +//// load +static INLINE vfloat vload_vf_p(const float *ptr) +{ return vec_ld(0, ptr); } +static INLINE vdouble vload_vd_p(const double *ptr) +{ return *((vdouble*)ptr); } + +//// store +static INLINE void vstore_v_p_vf(float *ptr, vfloat v) +{ vec_st(v, 0, ptr); } +static INLINE void vstore_v_p_vd(double *ptr, vdouble v) +{ *((vdouble*)ptr) = v; } + +////////////// non-temporal memory access ////////////// +//// store +static INLINE void vstream_v_p_vf(float *ptr, vfloat v) +{ vstore_v_p_vf(ptr, v); } +static INLINE void vstream_v_p_vd(double *ptr, vdouble v) +{ vstore_v_p_vd(ptr, v); } + +////////////// LUT ////////////// +//// load +static INLINE vdouble vgather_vd_p_vi(const double *ptr, vint vi) +{ return vset__vd(ptr[vec_extract(vi, 0)], ptr[vec_extract(vi, 1)]); } + +static INLINE vfloat vgather_vf_p_vi2(const float *ptr, vint2 vi2) +{ + return vset__vf( + ptr[vec_extract(vi2, 0)], ptr[vec_extract(vi2, 1)], + ptr[vec_extract(vi2, 2)], ptr[vec_extract(vi2, 3)] + ); +} + +//// store +static INLINE void vscatter2_v_p_i_i_vf(float *ptr, int offset, int step, vfloat v) +{ + const v__u64 vll = (v__u64)v; + float *ptr_low = ptr + offset*2; + float *ptr_high = ptr + (offset + step)*2; + *((uint64_t*)ptr_low) = vec_extract(vll, 0); + *((uint64_t*)ptr_high) = vec_extract(vll, 1); +} + +static INLINE void vsscatter2_v_p_i_i_vf(float *ptr, int offset, int step, vfloat v) +{ vscatter2_v_p_i_i_vf(ptr, offset, step, v); } + +static INLINE void vscatter2_v_p_i_i_vd(double *ptr, int offset, int step, vdouble v) +{ vstore_v_p_vd((double *)(&ptr[2*offset]), v); } + +static INLINE void vsscatter2_v_p_i_i_vd(double *ptr, int offset, int step, vdouble v) +{ vscatter2_v_p_i_i_vd(ptr, offset, step, v); } + +/********************************************** + ** Misc + **********************************************/ + +// vector with a specific value set to all lanes (Vector Splat) +static INLINE vint vcast_vi_i(int i) +{ return vsetall__vi(i); } +static INLINE vint2 vcast_vi2_i(int i) +{ return vsetall__vi2(i); } +static INLINE vfloat vcast_vf_f(float f) +{ return vsetall__vf(f); } +static INLINE vdouble vcast_vd_d(double d) +{ return vsetall__vd(d); } +// cast +static INLINE vint2 vcast_vi2_vm(vmask vm) +{ return (vint2)vm; } +static INLINE vmask vcast_vm_vi2(vint2 vi) +{ return (vmask)vi; } +// get the first element +static INLINE float vcast_f_vf(vfloat v) +{ return vec_extract(v, 0); } +static INLINE double vcast_d_vd(vdouble v) +{ return vec_extract(v, 0); } + +static INLINE vmask vreinterpret_vm_vd(vdouble vd) +{ return (vmask)vd; } +static INLINE vdouble vreinterpret_vd_vm(vmask vm) +{ return (vdouble)vm; } + +static INLINE vmask vreinterpret_vm_vf(vfloat vf) +{ return (vmask)vf; } +static INLINE vfloat vreinterpret_vf_vm(vmask vm) +{ return (vfloat)vm; } +static INLINE vfloat vreinterpret_vf_vi2(vint2 vi) +{ return (vfloat)vi; } +static INLINE vint2 vreinterpret_vi2_vf(vfloat vf) +{ return (vint2)vf; } + +// per element select via mask (blend) +static INLINE vdouble vsel_vd_vo_vd_vd(vopmask o, vdouble x, vdouble y) +{ return vec_sel(y, x, (v__b64)o); } +static INLINE vfloat vsel_vf_vo_vf_vf(vopmask o, vfloat x, vfloat y) +{ return vec_sel(y, x, o); } + +static INLINE vint vsel_vi_vo_vi_vi(vopmask o, vint x, vint y) +{ return vec_sel(y, x, o); } + +static INLINE vint2 vsel_vi2_vo_vi2_vi2(vopmask o, vint2 x, vint2 y) +{ return vec_sel(y, x, o); } + +static INLINE vfloat vsel_vf_vo_f_f(vopmask o, float v1, float v0) +{ + return vsel_vf_vo_vf_vf(o, vsetall__vf(v1), vsetall__vf(v0)); +} +static INLINE vfloat vsel_vf_vo_vo_f_f_f(vopmask o0, vopmask o1, float d0, float d1, float d2) +{ + return vsel_vf_vo_vf_vf(o0, vsetall__vf(d0), vsel_vf_vo_f_f(o1, d1, d2)); +} +static INLINE vfloat vsel_vf_vo_vo_vo_f_f_f_f(vopmask o0, vopmask o1, vopmask o2, float d0, float d1, float d2, float d3) +{ + return vsel_vf_vo_vf_vf(o0, vsetall__vf(d0), vsel_vf_vo_vf_vf(o1, vsetall__vf(d1), vsel_vf_vo_f_f(o2, d2, d3))); +} + +static INLINE vdouble vsel_vd_vo_d_d(vopmask o, double v1, double v0) +{ + return vsel_vd_vo_vd_vd(o, vsetall__vd(v1), vsetall__vd(v0)); +} +static INLINE vdouble vsel_vd_vo_vo_d_d_d(vopmask o0, vopmask o1, double d0, double d1, double d2) +{ + return vsel_vd_vo_vd_vd(o0, vsetall__vd(d0), vsel_vd_vo_d_d(o1, d1, d2)); +} +static INLINE vdouble vsel_vd_vo_vo_vo_d_d_d_d(vopmask o0, vopmask o1, vopmask o2, double d0, double d1, double d2, double d3) +{ + return vsel_vd_vo_vd_vd(o0, vsetall__vd(d0), vsel_vd_vo_vd_vd(o1, vsetall__vd(d1), vsel_vd_vo_d_d(o2, d2, d3))); +} + +static INLINE int vtestallones_i_vo32(vopmask g) +{ return vec_all_ne((vint2)g, vzero__vi2()); } +static INLINE int vtestallones_i_vo64(vopmask g) +{ return vec_all_ne((v__i64)g, vzero__s64()); } + +/********************************************** + ** Conversions + **********************************************/ + +////////////// Numeric ////////////// +// pack 64-bit mask to 32-bit +static INLINE vopmask vcast_vo32_vo64(vopmask m) +{ return (vopmask)vec_pack((v__u64)m, (v__u64)m); } +// clip 64-bit lanes to lower 32-bit +static INLINE vint vcastu_vi_vi2(vint2 vi2) +{ return vec_mergeo(vi2, vec_splat(vi2, 3)); } +static INLINE vint vcastu_vi_vm(vmask vi2) +{ return vec_mergeo((vint2)vi2, vec_splat((vint2)vi2, 3)); } + + +// expand lower 32-bit mask +static INLINE vopmask vcast_vo64_vo32(vopmask m) +{ return vec_mergeh(m, m); } +// unsigned expand lower 32-bit integer +static INLINE vint2 vcastu_vi2_vi(vint vi) +{ return vec_mergeh(vzero__vi(), vi); } +static INLINE vmask vcastu_vm_vi(vint vi) +{ return (vmask)vec_mergeh(vzero__vi(), vi); } + +static INLINE vopmask vcast_vo_i(int i) { + i = i ? -1 : 0; + return (vopmask) { i, i, i, i }; +} + +// signed int to single-precision +static INLINE vfloat vcast_vf_vi2(vint2 vi) +{ + vfloat ret; +#if defined(__clang__) || __GNUC__ >= 9 + ret = __builtin_convertvector(vi, vfloat); +#else + __asm__ __volatile__("xvcvsxwsp %x0,%x1" : "=wa" (ret) : "wa" (vi)); +#endif + return ret; +} + +// lower signed int to double-precision +static INLINE vdouble vcast_vd_vi(vint vi) +{ + vdouble ret; + vint swap = vec_mergeh(vi, vi); +#if defined(__clang__) || __GNUC__ >= 7 + ret = __builtin_vsx_xvcvsxwdp(swap); +#else + __asm__ __volatile__("xvcvsxwdp %x0,%x1" : "=wa" (ret) : "wa" (swap)); +#endif + return ret; +} + +// zip two scalars +static INLINE vmask vcast_vm_i_i(int l, int h) +{ return (vmask)vec_mergeh(vsetall__vi2(h), vsetall__vi2(l)); } + +static INLINE vmask vcast_vm_i64(int64_t i) { + return (vmask)vsetall__s64(i); +} +static INLINE vmask vcast_vm_u64(uint64_t i) { + return (vmask)vsetall__u64(i); +} + +////////////// Truncation ////////////// + +static INLINE vint2 vtruncate_vi2_vf(vfloat vf) +{ + vint2 ret; +#if defined(__clang__) || __GNUC__ >= 9 + ret = __builtin_convertvector(vf, vint2); +#else + __asm__ __volatile__("xvcvspsxws %x0,%x1" : "=wa" (ret) : "wa" (vf)); +#endif + return ret; +} + +static INLINE vint vtruncate_vi_vd(vdouble vd) +{ + vint ret; +#if defined(__clang__) || __GNUC__ >= 7 + ret = __builtin_vsx_xvcvdpsxws(vd); +#else + __asm__ __volatile__("xvcvdpsxws %x0,%x1" : "=wa" (ret) : "wa" (vd)); +#endif + return vec_mergeo(ret, vec_splat(ret, 3)); +} + +static INLINE vdouble vtruncate_vd_vd(vdouble vd) +{ return vec_trunc(vd); } +static INLINE vfloat vtruncate_vf_vf(vfloat vf) +{ return vec_trunc(vf); } + +////////////// Rounding ////////////// + +// towards the nearest even +static INLINE vint vrint_vi_vd(vdouble vd) +{ return vtruncate_vi_vd(vec_rint(vd)); } +static INLINE vint2 vrint_vi2_vf(vfloat vf) +{ return vtruncate_vi2_vf(vec_rint(vf)); } +static INLINE vdouble vrint_vd_vd(vdouble vd) +{ return vec_rint(vd); } +static INLINE vfloat vrint_vf_vf(vfloat vf) +{ return vec_rint(vf); } + +/********************************************** + ** Logical + **********************************************/ + +////////////// And ////////////// +static INLINE vint vand_vi_vi_vi(vint x, vint y) +{ return vec_and(x, y); } +static INLINE vint vand_vi_vo_vi(vopmask x, vint y) +{ return vec_and((vint)x, y); } +static INLINE vint2 vand_vi2_vi2_vi2(vint2 x, vint2 y) +{ return vec_and(x, y); } +static INLINE vint2 vand_vi2_vo_vi2(vopmask x, vint2 y) +{ return (vint2)vec_and((vint2)x, y); } + +static INLINE vmask vand_vm_vm_vm(vmask x, vmask y) +{ return vec_and(x, y); } +static INLINE vmask vand_vm_vo32_vm(vopmask x, vmask y) +{ return vec_and((vmask)x, y); } +static INLINE vmask vand_vm_vo64_vm(vopmask x, vmask y) +{ return vec_and((vmask)x, y); } +static INLINE vopmask vand_vo_vo_vo(vopmask x, vopmask y) +{ return vec_and(x, y); } + +////////////// Or ////////////// +static INLINE vint vor_vi_vi_vi(vint x, vint y) +{ return vec_or(x, y); } +static INLINE vint2 vor_vi2_vi2_vi2(vint2 x, vint2 y) +{ return vec_or(x, y); } + +static INLINE vmask vor_vm_vm_vm(vmask x, vmask y) +{ return vec_or(x, y); } +static INLINE vmask vor_vm_vo32_vm(vopmask x, vmask y) +{ return vec_or((vmask)x, y); } +static INLINE vmask vor_vm_vo64_vm(vopmask x, vmask y) +{ return vec_or((vmask)x, y); } +static INLINE vopmask vor_vo_vo_vo(vopmask x, vopmask y) +{ return vec_or(x, y); } + +////////////// Xor ////////////// +static INLINE vint vxor_vi_vi_vi(vint x, vint y) +{ return vec_xor(x, y); } +static INLINE vint2 vxor_vi2_vi2_vi2(vint2 x, vint2 y) +{ return vec_xor(x, y); } + +static INLINE vmask vxor_vm_vm_vm(vmask x, vmask y) +{ return vec_xor(x, y); } +static INLINE vmask vxor_vm_vo32_vm(vopmask x, vmask y) +{ return vec_xor((vmask)x, y); } +static INLINE vmask vxor_vm_vo64_vm(vopmask x, vmask y) +{ return vec_xor((vmask)x, y); } +static INLINE vopmask vxor_vo_vo_vo(vopmask x, vopmask y) +{ return vec_xor(x, y); } + +////////////// Not ////////////// +static INLINE vopmask vnot_vo_vo(vopmask o) +{ return vec_nor(o, o); } + +////////////// And Not ((~x) & y) ////////////// +static INLINE vint vandnot_vi_vi_vi(vint x, vint y) +{ return vec_andc(y, x); } +static INLINE vint vandnot_vi_vo_vi(vopmask x, vint y) +{ return vec_andc(y, (vint)x); } +static INLINE vint2 vandnot_vi2_vi2_vi2(vint2 x, vint2 y) +{ return vec_andc(y, x); } +static INLINE vmask vandnot_vm_vm_vm(vmask x, vmask y) +{ return vec_andc(y, x); } +static INLINE vmask vandnot_vm_vo64_vm(vopmask x, vmask y) +{ return vec_andc(y, x); } +static INLINE vmask vandnot_vm_vo32_vm(vopmask x, vmask y) +{ return vec_andc(y, x); } +static INLINE vopmask vandnot_vo_vo_vo(vopmask x, vopmask y) +{ return vec_andc(y, x); } +static INLINE vint2 vandnot_vi2_vo_vi2(vopmask x, vint2 y) +{ return vec_andc(y, (vint2)x); } + +/********************************************** + ** Comparison + **********************************************/ + +////////////// Equal ////////////// +static INLINE vint veq_vi_vi_vi(vint x, vint y) +{ return (vint)vec_cmpeq(x, y); } +static INLINE vopmask veq_vo_vi_vi(vint x, vint y) +{ return vec_cmpeq(x, y); } + +static INLINE vopmask veq_vo_vi2_vi2(vint2 x, vint2 y) +{ return vec_cmpeq(x, y); } +static INLINE vint2 veq_vi2_vi2_vi2(vint2 x, vint2 y) +{ return (vint2)vec_cmpeq(x, y); } + +static INLINE vopmask veq64_vo_vm_vm(vmask x, vmask y) +{ return (vopmask)vec_cmpeq((v__u64)x, (v__u64)y); } + +static INLINE vopmask veq_vo_vf_vf(vfloat x, vfloat y) +{ return vec_cmpeq(x, y); } +static INLINE vopmask veq_vo_vd_vd(vdouble x, vdouble y) +{ return (vopmask)vec_cmpeq(x, y); } + +////////////// Not Equal ////////////// +static INLINE vopmask vneq_vo_vf_vf(vfloat x, vfloat y) +{ return vnot_vo_vo(vec_cmpeq(x, y)); } +static INLINE vopmask vneq_vo_vd_vd(vdouble x, vdouble y) +{ return vnot_vo_vo((vopmask)vec_cmpeq(x, y)); } + +////////////// Less Than ////////////// +static INLINE vopmask vlt_vo_vf_vf(vfloat x, vfloat y) +{ return vec_cmplt(x, y); } +static INLINE vopmask vlt_vo_vd_vd(vdouble x, vdouble y) +{ return (vopmask)vec_cmplt(x, y); } + +////////////// Greater Than ////////////// +static INLINE vint vgt_vi_vi_vi(vint x, vint y) +{ return (vint)vec_cmpgt(x, y); } +static INLINE vopmask vgt_vo_vi_vi(vint x, vint y) +{ return vec_cmpgt(x, y);} + +static INLINE vint2 vgt_vi2_vi2_vi2(vint2 x, vint2 y) +{ return (vint2)vec_cmpgt(x, y); } +static INLINE vopmask vgt_vo_vi2_vi2(vint2 x, vint2 y) +{ return vec_cmpgt(x, y); } + +static INLINE vopmask vgt_vo_vf_vf(vfloat x, vfloat y) +{ return vec_cmpgt(x, y); } +static INLINE vopmask vgt_vo_vd_vd(vdouble x, vdouble y) +{ return (vopmask)vec_cmpgt(x, y); } + +////////////// Less Than Or Equal ////////////// +static INLINE vopmask vle_vo_vf_vf(vfloat x, vfloat y) +{ return vec_cmple(x, y); } +static INLINE vopmask vle_vo_vd_vd(vdouble x, vdouble y) +{ return (vopmask)vec_cmple(x, y); } + +////////////// Greater Than Or Equal ////////////// +static INLINE vopmask vge_vo_vf_vf(vfloat x, vfloat y) +{ return vec_cmpge(x, y); } +static INLINE vopmask vge_vo_vd_vd(vdouble x, vdouble y) +{ return (vopmask)vec_cmpge(x, y); } + +////////////// Special Cases ////////////// +static INLINE vopmask visinf_vo_vf(vfloat d) +{ return vec_cmpeq(vec_abs(d), vsetall__vf(SLEEF_INFINITYf)); } +static INLINE vopmask visinf_vo_vd(vdouble d) +{ return (vopmask)vec_cmpeq(vec_abs(d), vsetall__vd(SLEEF_INFINITY)); } + +static INLINE vopmask vispinf_vo_vf(vfloat d) +{ return vec_cmpeq(d, vsetall__vf(SLEEF_INFINITYf)); } +static INLINE vopmask vispinf_vo_vd(vdouble d) +{ return (vopmask)vec_cmpeq(d, vsetall__vd(SLEEF_INFINITY)); } + +static INLINE vopmask visminf_vo_vf(vfloat d) +{ return vec_cmpeq(d, vsetall__vf(-SLEEF_INFINITYf)); } +static INLINE vopmask visminf_vo_vd(vdouble d) +{ return (vopmask)vec_cmpeq(d, vsetall__vd(-SLEEF_INFINITY)); } + +static INLINE vopmask visnan_vo_vf(vfloat d) +{ return vnot_vo_vo(vec_cmpeq(d, d)); } +static INLINE vopmask visnan_vo_vd(vdouble d) +{ return vnot_vo_vo((vopmask)vec_cmpeq(d, d)); } + +/********************************************** + ** Shift + **********************************************/ +////////////// Left ////////////// +static INLINE vint vsll_vi_vi_i(vint x, int c) +{ return vec_sl (x, vsetall__u32(c)); } +static INLINE vint2 vsll_vi2_vi2_i(vint2 x, int c) +{ return vec_sl(x, vsetall__u32(c)); } + +////////////// Right ////////////// +static INLINE vint vsrl_vi_vi_i(vint x, int c) +{ return vec_sr(x, vsetall__u32(c)); } +static INLINE vint2 vsrl_vi2_vi2_i(vint2 x, int c) +{ return vec_sr(x, vsetall__u32(c)); } + +////////////// Algebraic Right ////////////// +static INLINE vint vsra_vi_vi_i(vint x, int c) +{ return vec_sra(x, vsetall__u32(c)); } +static INLINE vint2 vsra_vi2_vi2_i(vint2 x, int c) +{ return vec_sra(x, vsetall__u32(c)); } + +/********************************************** + ** Reorder + **********************************************/ + +////////////// Reverse ////////////// +// Reverse elements order inside the lower and higher parts +static INLINE vint2 vrev21_vi2_vi2(vint2 vi) +{ return vec_mergee(vec_mergeo(vi, vi), vi); } +static INLINE vfloat vrev21_vf_vf(vfloat vf) +{ return (vfloat)vrev21_vi2_vi2((vint2)vf); } + +// Swap the lower and higher parts +static INLINE vfloat vreva2_vf_vf(vfloat vf) +{ return (vfloat)v__swapd_u64((v__u64)vf); } +static INLINE vdouble vrev21_vd_vd(vdouble vd) +{ return (vdouble)v__swapd_u64((v__u64)vd); } +static INLINE vdouble vreva2_vd_vd(vdouble vd) +{ return vd; } + +/********************************************** + ** Arithmetic + **********************************************/ + +////////////// Negation ////////////// +static INLINE vint vneg_vi_vi(vint e) { +#if defined(__clang__) || __GNUC__ >= 9 + return vec_neg(e); +#else + return vec_sub(vzero__vi(), e); +#endif +} +static INLINE vint2 vneg_vi2_vi2(vint2 e) +{ return vneg_vi_vi(e); } + +static INLINE vfloat vneg_vf_vf(vfloat d) +{ + vfloat ret; +#if defined(__clang__) || __GNUC__ >= 9 + ret = vec_neg(d); +#else + __asm__ __volatile__("xvnegsp %x0,%x1" : "=wa" (ret) : "wa" (d)); +#endif + return ret; +} + +static INLINE vdouble vneg_vd_vd(vdouble d) +{ + vdouble ret; +#if defined(__clang__) || __GNUC__ >= 9 + ret = vec_neg(d); +#else + __asm__ __volatile__("xvnegdp %x0,%x1" : "=wa" (ret) : "wa" (d)); +#endif + return ret; +} + +static INLINE vfloat vposneg_vf_vf(vfloat d) +{ return vec_xor(d, vset__vf(+0.0f, -0.0f, +0.0f, -0.0f)); } +static INLINE vdouble vposneg_vd_vd(vdouble d) +{ return vec_xor(d, vset__vd(+0.0, -0.0)); } + +static INLINE vfloat vnegpos_vf_vf(vfloat d) +{ return vec_xor(d, vset__vf(-0.0f, +0.0f, -0.0f, +0.0f)); } +static INLINE vdouble vnegpos_vd_vd(vdouble d) +{ return vec_xor(d, vset__vd(-0.0, +0.0)); } + +////////////// Addition ////////////// +static INLINE vint vadd_vi_vi_vi(vint x, vint y) +{ return vec_add(x, y); } +static INLINE vint2 vadd_vi2_vi2_vi2(vint2 x, vint2 y) +{ return vec_add(x, y); } + +static INLINE vfloat vadd_vf_vf_vf(vfloat x, vfloat y) +{ return vec_add(x, y); } +static INLINE vdouble vadd_vd_vd_vd(vdouble x, vdouble y) +{ return vec_add(x, y); } + +static INLINE vmask vadd64_vm_vm_vm(vmask x, vmask y) +{ return (vmask)vec_add((v__i64)x, (v__i64)y); } + +////////////// Subtraction ////////////// +static INLINE vint vsub_vi_vi_vi(vint x, vint y) +{ return vec_sub(x, y); } +static INLINE vint2 vsub_vi2_vi2_vi2(vint2 x, vint2 y) +{ return vec_sub(x, y); } + +static INLINE vfloat vsub_vf_vf_vf(vfloat x, vfloat y) +{ return vec_sub(x, y); } +static INLINE vdouble vsub_vd_vd_vd(vdouble x, vdouble y) +{ return vec_sub(x, y); } + +static INLINE vdouble vsubadd_vd_vd_vd(vdouble x, vdouble y) +{ return vec_add(x, vnegpos_vd_vd(y)); } +static INLINE vfloat vsubadd_vf_vf_vf(vfloat x, vfloat y) +{ return vec_add(x, vnegpos_vf_vf(y)); } + +////////////// Multiplication ////////////// +static INLINE vfloat vmul_vf_vf_vf(vfloat x, vfloat y) +{ return vec_mul(x, y); } +static INLINE vdouble vmul_vd_vd_vd(vdouble x, vdouble y) +{ return vec_mul(x, y); } + +static INLINE vfloat vdiv_vf_vf_vf(vfloat x, vfloat y) +{ return vec_div(x, y); } +static INLINE vdouble vdiv_vd_vd_vd(vdouble x, vdouble y) +{ return vec_div(x, y); } + +static INLINE vfloat vrec_vf_vf(vfloat x) +{ return vec_div(vsetall__vf(1.0f), x); } +static INLINE vdouble vrec_vd_vd(vdouble x) +{ return vec_div(vsetall__vd(1.0), x); } + +/********************************************** + ** Math + **********************************************/ + +static INLINE vfloat vmax_vf_vf_vf(vfloat x, vfloat y) +{ return vec_max(x, y); } +static INLINE vdouble vmax_vd_vd_vd(vdouble x, vdouble y) +{ return vec_max(x, y); } + +static INLINE vfloat vmin_vf_vf_vf(vfloat x, vfloat y) +{ return vec_min(x, y); } +static INLINE vdouble vmin_vd_vd_vd(vdouble x, vdouble y) +{ return vec_min(x, y); } + +static INLINE vfloat vabs_vf_vf(vfloat f) +{ return vec_abs(f); } +static INLINE vdouble vabs_vd_vd(vdouble d) +{ return vec_abs(d); } + +static INLINE vfloat vsqrt_vf_vf(vfloat f) +{ return vec_sqrt(f); } +static INLINE vdouble vsqrt_vd_vd(vdouble d) +{ return vec_sqrt(d); } + + +/********************************************** + ** FMA3 + **********************************************/ +#if CONFIG == 1 || CONFIG == 3 + +static INLINE vfloat vmla_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) +{ return vec_madd(x, y, z); } +static INLINE vdouble vmla_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) +{ return vec_madd(x, y, z); } + +static INLINE vfloat vmlapn_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) +{ return vec_msub(x, y, z); } +static INLINE vdouble vmlapn_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) +{ return vec_msub(x, y, z); } + +static INLINE vfloat vmlanp_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) +{ return vec_nmsub(x, y, z); } +static INLINE vdouble vmlanp_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) +{ return vec_nmsub(x, y, z); } + +#else + +static INLINE vfloat vmla_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) +{ return vec_add(vec_mul(x, y), z); } +static INLINE vdouble vmla_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) +{ return vec_add(vec_mul(x, y), z); } + +static INLINE vfloat vmlapn_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) +{ return vec_sub(vec_mul(x, y), z); } +static INLINE vdouble vmlapn_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) +{ return vec_sub(vec_mul(x, y), z); } + +static INLINE vfloat vmlanp_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) +{ return vec_sub(z, vec_mul(x, y)); } +static INLINE vdouble vmlanp_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) +{ return vec_sub(z, vec_mul(x, y)); } + +#endif + +static INLINE vfloat vfma_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) +{ return vec_madd(x, y, z); } +static INLINE vdouble vfma_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) +{ return vec_madd(x, y, z); } +static INLINE vfloat vfmapp_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) +{ return vec_madd(x, y, z); } +static INLINE vdouble vfmapp_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) +{ return vec_madd(x, y, z); } + +static INLINE vfloat vfmapn_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) +{ return vec_msub(x, y, z); } +static INLINE vdouble vfmapn_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) +{ return vec_msub(x, y, z); } + +static INLINE vfloat vfmanp_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) +{ return vec_nmsub(x, y, z); } +static INLINE vdouble vfmanp_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) +{ return vec_nmsub(x, y, z); } + +static INLINE vfloat vfmann_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) +{ return vec_nmadd(x, y, z); } +static INLINE vdouble vfmann_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) +{ return vec_nmadd(x, y, z); } + +static INLINE vfloat vmlsubadd_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) +{ return vmla_vf_vf_vf_vf(x, y, vnegpos_vf_vf(z)); } +static INLINE vdouble vmlsubadd_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) +{ return vmla_vd_vd_vd_vd(x, y, vnegpos_vd_vd(z)); } + +// + +static vquad loadu_vq_p(void *p) { + vquad vq; + memcpy(&vq, p, VECTLENDP * 16); + return vq; +} + +static INLINE vquad cast_vq_aq(vargquad aq) { + vquad vq; + memcpy(&vq, &aq, VECTLENDP * 16); + return vq; +} + +static INLINE vargquad cast_aq_vq(vquad vq) { + vargquad aq; + memcpy(&aq, &vq, VECTLENDP * 16); + return aq; +} + +static INLINE int vtestallzeros_i_vo64(vopmask g) { + return vec_all_eq((__vector signed long long)g, vzero__s64()); +} + +static INLINE vmask vsel_vm_vo64_vm_vm(vopmask o, vmask x, vmask y) { + return (vmask)vec_sel((__vector signed long long)y, (__vector signed long long)x, (v__b64)o); +} + +static INLINE vmask vsub64_vm_vm_vm(vmask x, vmask y) { + return (vmask)vec_sub((__vector signed long long)x, (__vector signed long long)y); +} + +static INLINE vmask vneg64_vm_vm(vmask x) { + return (vmask)vec_sub((__vector signed long long) {0, 0}, (__vector signed long long)x); +} + +static INLINE vopmask vgt64_vo_vm_vm(vmask x, vmask y) { + return (vopmask)vec_cmpgt((__vector signed long long)x, (__vector signed long long)y); +} + +#define vsll64_vm_vm_i(x, c) ((vmask)vec_sl((__vector signed long long)x, (__vector unsigned long long)vsetall__vm(c))) +#define vsrl64_vm_vm_i(x, c) ((vmask)vec_sr((__vector signed long long)x, (__vector unsigned long long)vsetall__vm(c))) + +static INLINE vint vcast_vi_vm(vmask vm) { + return (vint) { vm[0], vm[2] }; +} + +static INLINE vmask vcast_vm_vi(vint vi) { + return (vmask) (__vector signed long long) { vi[0], vi[1] }; +} + +static INLINE vmask vreinterpret_vm_vi64(vint64 v) { return (vmask)v; } +static INLINE vint64 vreinterpret_vi64_vm(vmask m) { return (vint64)m; } +static INLINE vmask vreinterpret_vm_vu64(vuint64 v) { return (vmask)v; } +static INLINE vuint64 vreinterpret_vu64_vm(vmask m) { return (vuint64)m; } diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/arch/helperpurec.h b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/arch/helperpurec.h new file mode 100644 index 00000000000..14142a3633d --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/arch/helperpurec.h @@ -0,0 +1,561 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include "misc.h" + +#ifndef CONFIG +#error CONFIG macro not defined +#endif + +#define ENABLE_DP +//@#define ENABLE_DP +#define ENABLE_SP +//@#define ENABLE_SP + +#define LOG2VECTLENDP CONFIG +//@#define LOG2VECTLENDP CONFIG +#define VECTLENDP (1 << LOG2VECTLENDP) +//@#define VECTLENDP (1 << LOG2VECTLENDP) +#define LOG2VECTLENSP (LOG2VECTLENDP+1) +//@#define LOG2VECTLENSP (LOG2VECTLENDP+1) +#define VECTLENSP (1 << LOG2VECTLENSP) +//@#define VECTLENSP (1 << LOG2VECTLENSP) + +#define ACCURATE_SQRT +//@#define ACCURATE_SQRT + +#define DFTPRIORITY LOG2VECTLENDP +#define ISANAME "Pure C Array" + +typedef union { + uint32_t u[VECTLENDP*2]; + uint64_t x[VECTLENDP]; + double d[VECTLENDP]; + float f[VECTLENDP*2]; + int32_t i[VECTLENDP*2]; +} versatileVector; + +typedef versatileVector vmask; +typedef versatileVector vopmask; +typedef versatileVector vdouble; +typedef versatileVector vint; +typedef versatileVector vfloat; +typedef versatileVector vint2; + +typedef union { + uint8_t u[sizeof(long double)*VECTLENDP]; + long double ld[VECTLENDP]; +} longdoubleVector; + +typedef longdoubleVector vmaskl; +typedef longdoubleVector vlongdouble; + +#if defined(Sleef_quad2_DEFINED) && defined(ENABLEFLOAT128) +typedef union { + uint8_t u[sizeof(Sleef_quad)*VECTLENDP]; + Sleef_quad q[VECTLENDP]; +} quadVector; + +typedef quadVector vmaskq; +typedef quadVector vquad; +#endif + +// + +static INLINE int vavailability_i(int name) { return -1; } +static INLINE void vprefetch_v_p(const void *ptr) { } + +static INLINE int vtestallones_i_vo64(vopmask g) { + int ret = 1; for(int i=0;i 0 ? (int)(vd.d[i] + 0.5) : (int)(vd.d[i] - 0.5); return ret; } +static INLINE vdouble vtruncate_vd_vd(vdouble vd) { return vcast_vd_vi(vtruncate_vi_vd(vd)); } +static INLINE vdouble vrint_vd_vd(vdouble vd) { return vcast_vd_vi(vrint_vi_vd(vd)); } +static INLINE vint vcast_vi_i(int j) { vint ret; for(int i=0;i y.d[i] ? x.d[i] : y.d[i]; return ret; } +static INLINE vdouble vmin_vd_vd_vd(vdouble x, vdouble y) { vdouble ret; for(int i=0;i y.d[i] ? -1 : 0; return ret; } +static INLINE vopmask vge_vo_vd_vd(vdouble x, vdouble y) { vopmask ret; for(int i=0;i= y.d[i] ? -1 : 0; return ret; } + +static INLINE vint vadd_vi_vi_vi(vint x, vint y) { vint ret; for(int i=0;i> c; return ret; } +static INLINE vint vsra_vi_vi_i(vint x, int c) { vint ret; for(int i=0;i> c; return ret; } + +static INLINE vopmask veq_vo_vi_vi(vint x, vint y) { vopmask ret; for(int i=0;i y.i[i] ? -1 : 0; return ret; } + +static INLINE vint vsel_vi_vo_vi_vi(vopmask m, vint x, vint y) { + union { vopmask vo; vint2 vi2; } cnv; + cnv.vo = m; + return vor_vi_vi_vi(vand_vi_vi_vi(vreinterpretFirstHalf_vi_vi2(cnv.vi2), x), + vandnot_vi_vi_vi(vreinterpretFirstHalf_vi_vi2(cnv.vi2), y)); +} + +static INLINE vopmask visinf_vo_vd(vdouble d) { vopmask ret; for(int i=0;i 0 ? (int)(vf.f[i] + 0.5) : (int)(vf.f[i] - 0.5); return ret; } +static INLINE vint2 vcast_vi2_i(int j) { vint2 ret; for(int i=0;i y.f[i] ? x.f[i] : y.f[i]; return ret; } +static INLINE vfloat vmin_vf_vf_vf(vfloat x, vfloat y) { vfloat ret; for(int i=0;i y.f[i]) ? -1 : 0); return ret; } +static INLINE vopmask vge_vo_vf_vf(vfloat x, vfloat y) { vopmask ret; for(int i=0;i= y.f[i]) ? -1 : 0); return ret; } + +static INLINE vint vadd_vi2_vi2_vi2(vint x, vint y) { vint ret; for(int i=0;i> c; return ret; } +static INLINE vint2 vsra_vi2_vi2_i(vint2 x, int c) { vint2 ret; for(int i=0;i> c; return ret; } + +static INLINE vopmask visinf_vo_vf (vfloat d) { vopmask ret; for(int i=0;i y.i[i] ? -1 : 0; return ret; } +static INLINE vint2 veq_vi2_vi2_vi2(vint2 x, vint2 y) { vopmask ret; for(int i=0;i y.i[i] ? -1 : 0; return ret; } + +static INLINE vfloat vsqrt_vf_vf(vfloat x) { vfloat ret; for(int i=0;i +#endif + +#ifndef ENABLE_BUILTIN_MATH + +#if !defined(SLEEF_GENHEADER) +#include +#endif + +#define SQRT sqrt +#define SQRTF sqrtf +#define FMA fma +#define FMAF fmaf +#define RINT rint +#define RINTF rintf +#define TRUNC trunc +#define TRUNCF truncf + +#else + +#define SQRT __builtin_sqrt +#define SQRTF __builtin_sqrtf +#define FMA __builtin_fma +#define FMAF __builtin_fmaf +#define RINT __builtin_rint +#define RINTF __builtin_rintf +#define TRUNC __builtin_trunc +#define TRUNCF __builtin_truncf + +#endif + +#if !defined(SLEEF_GENHEADER) +#include "misc.h" +#endif + +#ifndef CONFIG +#error CONFIG macro not defined +#endif + +#define ENABLE_DP +//@#define ENABLE_DP +#define ENABLE_SP +//@#define ENABLE_SP + +#if CONFIG == 2 || CONFIG == 3 +#define ENABLE_FMA_DP +//@#define ENABLE_FMA_DP +#define ENABLE_FMA_SP +//@#define ENABLE_FMA_SP + +#if defined(__AVX2__) || defined(__aarch64__) || defined(__arm__) || defined(__powerpc64__) || defined(__zarch__) || defined(__riscv) || CONFIG == 3 +#ifndef FP_FAST_FMA +//@#ifndef FP_FAST_FMA +#define FP_FAST_FMA +//@#define FP_FAST_FMA +#endif +//@#endif +#ifndef FP_FAST_FMAF +//@#ifndef FP_FAST_FMAF +#define FP_FAST_FMAF +//@#define FP_FAST_FMAF +#endif +//@#endif +#endif + +#if (!defined(FP_FAST_FMA) || !defined(FP_FAST_FMAF)) && !defined(SLEEF_GENHEADER) +#error FP_FAST_FMA or FP_FAST_FMAF not defined +#endif + +#define ISANAME "Pure C scalar with FMA" + +#else // #if CONFIG == 2 || CONFIG == 3 +#define ISANAME "Pure C scalar" +#endif // #if CONFIG == 2 || CONFIG == 3 + +#define LOG2VECTLENDP 0 +//@#define LOG2VECTLENDP 0 +#define VECTLENDP (1 << LOG2VECTLENDP) +//@#define VECTLENDP (1 << LOG2VECTLENDP) +#define LOG2VECTLENSP 0 +//@#define LOG2VECTLENSP 0 +#define VECTLENSP (1 << LOG2VECTLENSP) +//@#define VECTLENSP (1 << LOG2VECTLENSP) + +#define ACCURATE_SQRT +//@#define ACCURATE_SQRT + +#if defined(__SSE4_1__) || defined(__aarch64__) || CONFIG == 3 +#define FULL_FP_ROUNDING +//@#define FULL_FP_ROUNDING +#endif + +#define DFTPRIORITY LOG2VECTLENDP + +typedef uint64_t vmask; +typedef uint32_t vopmask; +typedef double vdouble; +typedef int32_t vint; +typedef float vfloat; +typedef int32_t vint2; + +typedef int64_t vint64; +typedef uint64_t vuint64; + +typedef Sleef_uint64_2t vquad; + +#if CONFIG != 3 +typedef Sleef_quad vargquad; +#else +typedef Sleef_uint64_2t vargquad; +#endif + +// + +static INLINE int vavailability_i(int name) { return -1; } +static INLINE void vprefetch_v_p(const void *ptr) {} + +static INLINE int vtestallones_i_vo64(vopmask g) { return g; } +static INLINE int vtestallones_i_vo32(vopmask g) { return g; } + +// + +static vint2 vloadu_vi2_p(int32_t *p) { return *p; } +static void vstoreu_v_p_vi2(int32_t *p, vint2 v) { *p = v; } +static vint vloadu_vi_p(int32_t *p) { return *p; } +static void vstoreu_v_p_vi(int32_t *p, vint v) { *p = v; } + +// + +static INLINE vopmask vcast_vo32_vo64(vopmask m) { return m; } +static INLINE vopmask vcast_vo64_vo32(vopmask m) { return m; } +static INLINE vopmask vcast_vo_i(int i) { return i ? -1 : 0; } +static INLINE vmask vcast_vm_i_i(int h, int l) { return (((uint64_t)h) << 32) | (uint32_t)l; } + +static INLINE vmask vcast_vm_i64(int64_t i) { return (int64_t)i; } +static INLINE vmask vcast_vm_u64(uint64_t i) { return i; } + +static INLINE vmask vcastu_vm_vi(vint vi) { return ((uint64_t)vi) << 32; } +static INLINE vint vcastu_vi_vm(vmask vm) { return (int32_t)(vm >> 32); } + +static INLINE vdouble vcast_vd_d(double d) { return d; } + +// + +static INLINE vopmask vand_vo_vo_vo (vopmask x, vopmask y) { return x & y; } +static INLINE vopmask vandnot_vo_vo_vo(vopmask x, vopmask y) { return y & ~x; } +static INLINE vopmask vor_vo_vo_vo (vopmask x, vopmask y) { return x | y; } +static INLINE vopmask vxor_vo_vo_vo (vopmask x, vopmask y) { return x ^ y; } + +static INLINE vmask vand_vm_vm_vm (vmask x, vmask y) { return x & y; } +static INLINE vmask vandnot_vm_vm_vm (vmask x, vmask y) { return y & ~x; } +static INLINE vmask vor_vm_vm_vm (vmask x, vmask y) { return x | y; } +static INLINE vmask vxor_vm_vm_vm (vmask x, vmask y) { return x ^ y; } + +static INLINE vmask vcast_vm_vo(vopmask o) { return (vmask)o | (((vmask)o) << 32); } + +static INLINE vmask vand_vm_vo64_vm(vopmask x, vmask y) { return vcast_vm_vo(x) & y; } +static INLINE vmask vandnot_vm_vo64_vm(vopmask x, vmask y) { return y & ~vcast_vm_vo(x); } +static INLINE vmask vor_vm_vo64_vm(vopmask x, vmask y) { return vcast_vm_vo(x) | y; } +static INLINE vmask vxor_vm_vo64_vm(vopmask x, vmask y) { return vcast_vm_vo(x) ^ y; } + +static INLINE vmask vand_vm_vo32_vm(vopmask x, vmask y) { return vcast_vm_vo(x) & y; } +static INLINE vmask vandnot_vm_vo32_vm(vopmask x, vmask y) { return y & ~vcast_vm_vo(x); } +static INLINE vmask vor_vm_vo32_vm(vopmask x, vmask y) { return vcast_vm_vo(x) | y; } +static INLINE vmask vxor_vm_vo32_vm(vopmask x, vmask y) { return vcast_vm_vo(x) ^ y; } + +// + +static INLINE vdouble vsel_vd_vo_vd_vd (vopmask o, vdouble x, vdouble y) { return o ? x : y; } +static INLINE vint2 vsel_vi2_vo_vi2_vi2(vopmask o, vint2 x, vint2 y) { return o ? x : y; } + +static INLINE CONST vdouble vsel_vd_vo_d_d(vopmask o, double v1, double v0) { return o ? v1 : v0; } + +static INLINE vdouble vsel_vd_vo_vo_d_d_d(vopmask o0, vopmask o1, double d0, double d1, double d2) { + return vsel_vd_vo_vd_vd(o0, vcast_vd_d(d0), vsel_vd_vo_d_d(o1, d1, d2)); +} + +static INLINE vdouble vsel_vd_vo_vo_vo_d_d_d_d(vopmask o0, vopmask o1, vopmask o2, double d0, double d1, double d2, double d3) { + return vsel_vd_vo_vd_vd(o0, vcast_vd_d(d0), vsel_vd_vo_vd_vd(o1, vcast_vd_d(d1), vsel_vd_vo_d_d(o2, d2, d3))); +} + +static INLINE vdouble vcast_vd_vi(vint vi) { return vi; } +static INLINE vint vcast_vi_i(int j) { return j; } + +#ifdef FULL_FP_ROUNDING +static INLINE vint vrint_vi_vd(vdouble d) { return (int32_t)RINT(d); } +static INLINE vdouble vrint_vd_vd(vdouble vd) { return RINT(vd); } +static INLINE vdouble vtruncate_vd_vd(vdouble vd) { return TRUNC(vd); } +static INLINE vint vtruncate_vi_vd(vdouble vd) { return (int32_t)TRUNC(vd); } +#else +static INLINE vint vrint_vi_vd(vdouble a) { + a += a > 0 ? 0.5 : -0.5; + uint64_t vx; + memcpy(&vx, &a, sizeof(vx)); + vx -= 1 & (int)a; + memcpy(&a, &vx, sizeof(a)); + return a; +} +static INLINE vdouble vrint_vd_vd(vdouble vd) { return vcast_vd_vi(vrint_vi_vd(vd)); } +static INLINE vint vtruncate_vi_vd(vdouble vd) { return vd; } +static INLINE vdouble vtruncate_vd_vd(vdouble vd) { return vcast_vd_vi(vtruncate_vi_vd(vd)); } +#endif + +static INLINE vopmask veq64_vo_vm_vm(vmask x, vmask y) { return x == y ? ~(uint32_t)0 : 0; } +static INLINE vmask vadd64_vm_vm_vm(vmask x, vmask y) { return x + y; } + +// + +static INLINE vmask vreinterpret_vm_vd(vdouble vd) { vmask vm; memcpy(&vm, &vd, sizeof(vm)); return vm; } +static INLINE vdouble vreinterpret_vd_vm(vmask vm) { vdouble vd; memcpy(&vd, &vm, sizeof(vd)); return vd; } + +static INLINE vdouble vadd_vd_vd_vd(vdouble x, vdouble y) { return x + y; } +static INLINE vdouble vsub_vd_vd_vd(vdouble x, vdouble y) { return x - y; } +static INLINE vdouble vmul_vd_vd_vd(vdouble x, vdouble y) { return x * y; } +static INLINE vdouble vdiv_vd_vd_vd(vdouble x, vdouble y) { return x / y; } +static INLINE vdouble vrec_vd_vd(vdouble x) { return 1 / x; } + +static INLINE vdouble vabs_vd_vd(vdouble d) { + uint64_t vx; + memcpy(&vx, &d, sizeof(vx)); + vx &= UINT64_C(0x7fffffffffffffff); + memcpy(&d, &vx, sizeof(d)); + return d; +} +static INLINE vdouble vneg_vd_vd(vdouble d) { return -d; } + +static INLINE vdouble vmax_vd_vd_vd(vdouble x, vdouble y) { return x > y ? x : y; } +static INLINE vdouble vmin_vd_vd_vd(vdouble x, vdouble y) { return x < y ? x : y; } + +#ifndef ENABLE_FMA_DP +static INLINE vdouble vmla_vd_vd_vd_vd (vdouble x, vdouble y, vdouble z) { return x * y + z; } +static INLINE vdouble vmlapn_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return x * y - z; } +static INLINE vdouble vmlanp_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return -x * y + z; } +#else +static INLINE vdouble vmla_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return FMA(x, y, z); } +static INLINE vdouble vmlapn_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return FMA(x, y, -z); } +static INLINE vdouble vmlanp_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return FMA(-x, y, z); } +static INLINE vdouble vfma_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return FMA(x, y, z); } +static INLINE vdouble vfmapp_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return FMA(x, y, z); } +static INLINE vdouble vfmapn_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return FMA(x, y, -z); } +static INLINE vdouble vfmanp_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return FMA(-x, y, z); } +static INLINE vdouble vfmann_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return FMA(-x, y, -z); } +#endif + +static INLINE vopmask veq_vo_vd_vd(vdouble x, vdouble y) { return x == y ? ~(uint32_t)0 : 0; } +static INLINE vopmask vneq_vo_vd_vd(vdouble x, vdouble y) { return x != y ? ~(uint32_t)0 : 0; } +static INLINE vopmask vlt_vo_vd_vd(vdouble x, vdouble y) { return x < y ? ~(uint32_t)0 : 0; } +static INLINE vopmask vle_vo_vd_vd(vdouble x, vdouble y) { return x <= y ? ~(uint32_t)0 : 0; } +static INLINE vopmask vgt_vo_vd_vd(vdouble x, vdouble y) { return x > y ? ~(uint32_t)0 : 0; } +static INLINE vopmask vge_vo_vd_vd(vdouble x, vdouble y) { return x >= y ? ~(uint32_t)0 : 0; } + +static INLINE vint vadd_vi_vi_vi(vint x, vint y) { return x + y; } +static INLINE vint vsub_vi_vi_vi(vint x, vint y) { return x - y; } +static INLINE vint vneg_vi_vi (vint x) { return - x; } + +static INLINE vint vand_vi_vi_vi(vint x, vint y) { return x & y; } +static INLINE vint vandnot_vi_vi_vi(vint x, vint y) { return y & ~x; } +static INLINE vint vor_vi_vi_vi(vint x, vint y) { return x | y; } +static INLINE vint vxor_vi_vi_vi(vint x, vint y) { return x ^ y; } + +static INLINE vint vand_vi_vo_vi(vopmask x, vint y) { return x & y; } +static INLINE vint vandnot_vi_vo_vi(vopmask x, vint y) { return y & ~x; } + +static INLINE vint vsll_vi_vi_i(vint x, int c) { return (uint32_t)x << c; } +static INLINE vint vsrl_vi_vi_i(vint x, int c) { return (uint32_t)x >> c; } +static INLINE vint vsra_vi_vi_i(vint x, int c) { return x >> c; } + +static INLINE vopmask veq_vo_vi_vi(vint x, vint y) { return x == y ? ~(uint32_t)0 : 0; } +static INLINE vopmask vgt_vo_vi_vi(vint x, vint y) { return x > y ? ~(uint32_t)0 : 0; } + +static INLINE vint vsel_vi_vo_vi_vi(vopmask m, vint x, vint y) { return m ? x : y; } + +static INLINE vopmask visinf_vo_vd(vdouble d) { return (d == SLEEF_INFINITY || d == -SLEEF_INFINITY) ? ~(uint32_t)0 : 0; } +static INLINE vopmask vispinf_vo_vd(vdouble d) { return d == SLEEF_INFINITY ? ~(uint32_t)0 : 0; } +static INLINE vopmask visminf_vo_vd(vdouble d) { return d == -SLEEF_INFINITY ? ~(uint32_t)0 : 0; } +static INLINE vopmask visnan_vo_vd(vdouble d) { return d != d ? ~(uint32_t)0 : 0; } + +static INLINE vdouble vsqrt_vd_vd(vdouble d) { return SQRT(d); } +static INLINE vfloat vsqrt_vf_vf(vfloat x) { return SQRTF(x); } + +static INLINE double vcast_d_vd(vdouble v) { return v; } + +static INLINE vdouble vload_vd_p(const double *ptr) { return *ptr; } +static INLINE vdouble vloadu_vd_p(const double *ptr) { return *ptr; } +static INLINE vdouble vgather_vd_p_vi(const double *ptr, vint vi) { return ptr[vi]; } + +static INLINE void vstore_v_p_vd(double *ptr, vdouble v) { *ptr = v; } +static INLINE void vstoreu_v_p_vd(double *ptr, vdouble v) { *ptr = v; } +static INLINE void vstream_v_p_vd(double *ptr, vdouble v) { *ptr = v; } + +// + +static INLINE vint2 vcast_vi2_vm(vmask vm) { return (int32_t)vm; } +static INLINE vmask vcast_vm_vi2(vint2 vi) { return (uint32_t)vi; } + +static INLINE vfloat vcast_vf_vi2(vint2 vi) { return (int32_t)vi; } +static INLINE vint2 vcast_vi2_i(int j) { return j; } + +#ifdef FULL_FP_ROUNDING +static INLINE vint2 vrint_vi2_vf(vfloat d) { return (int)RINTF(d); } +static INLINE vfloat vrint_vf_vf(vfloat vd) { return RINTF(vd); } +static INLINE vfloat vtruncate_vf_vf(vfloat vd) { return TRUNCF(vd); } +static INLINE vint2 vtruncate_vi2_vf(vfloat vf) { return (int32_t)TRUNCF(vf); } +#else +static INLINE vint2 vrint_vi2_vf(vfloat a) { + a += a > 0 ? 0.5f : -0.5f; + uint32_t vu[1]; + memcpy(vu, &a, sizeof(vu)); + vu[0] -= 1 & (int)a; + memcpy(&a, vu, sizeof(a)); + return (int32_t)a; +} +static INLINE vfloat vrint_vf_vf(vfloat vd) { return vcast_vf_vi2(vrint_vi2_vf(vd)); } +static INLINE vint2 vtruncate_vi2_vf(vfloat vf) { return vf; } +static INLINE vfloat vtruncate_vf_vf(vfloat vd) { return vcast_vf_vi2(vtruncate_vi2_vf(vd)); } +#endif + +static INLINE vfloat vcast_vf_f(float f) { return f; } +static INLINE vmask vreinterpret_vm_vf(vfloat f) { vfloat vf[2] = { f, 0 }; vmask vm; memcpy(&vm, &vf, sizeof(vm)); return vm; } +static INLINE vfloat vreinterpret_vf_vm(vmask vm) { vfloat vf[2]; memcpy(&vf, &vm, sizeof(vf)); return vf[0]; } +static INLINE vfloat vreinterpret_vf_vi2(vint2 vi) { vfloat vf; memcpy(&vf, &vi, sizeof(vf)); return vf; } +static INLINE vint2 vreinterpret_vi2_vf(vfloat f) { vint2 vi2; memcpy(&vi2, &f, sizeof(vi2)); return vi2; } + +static INLINE vfloat vadd_vf_vf_vf(vfloat x, vfloat y) { return x + y; } +static INLINE vfloat vsub_vf_vf_vf(vfloat x, vfloat y) { return x - y; } +static INLINE vfloat vmul_vf_vf_vf(vfloat x, vfloat y) { return x * y; } +static INLINE vfloat vdiv_vf_vf_vf(vfloat x, vfloat y) { return x / y; } +static INLINE vfloat vrec_vf_vf (vfloat x) { return 1 / x; } + +static INLINE vfloat vabs_vf_vf(vfloat x) { + int32_t vi[1]; + memcpy(vi, &x, sizeof(vi)); + vi[0] &= 0x7fffffff; + memcpy(&x, vi, sizeof(x)); + return x; +} +static INLINE vfloat vneg_vf_vf(vfloat x) { return -x; } + +static INLINE vfloat vmax_vf_vf_vf(vfloat x, vfloat y) { return x > y ? x : y; } +static INLINE vfloat vmin_vf_vf_vf(vfloat x, vfloat y) { return x < y ? x : y; } + +#ifndef ENABLE_FMA_SP +static INLINE vfloat vmla_vf_vf_vf_vf (vfloat x, vfloat y, vfloat z) { return x * y + z; } +static INLINE vfloat vmlanp_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return - x * y + z; } +static INLINE vfloat vmlapn_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return x * y - z; } +#else +static INLINE vfloat vmla_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return FMAF(x, y, z); } +static INLINE vfloat vmlapn_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return FMAF(x, y, -z); } +static INLINE vfloat vmlanp_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return FMAF(-x, y, z); } +static INLINE vfloat vfma_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return FMAF(x, y, z); } +static INLINE vfloat vfmapp_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return FMAF(x, y, z); } +static INLINE vfloat vfmapn_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return FMAF(x, y, -z); } +static INLINE vfloat vfmanp_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return FMAF(-x, y, z); } +static INLINE vfloat vfmann_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return FMAF(-x, y, -z); } +#endif + +static INLINE vopmask veq_vo_vf_vf(vfloat x, vfloat y) { return x == y ? ~(uint32_t)0 : 0; } +static INLINE vopmask vneq_vo_vf_vf(vfloat x, vfloat y) { return x != y ? ~(uint32_t)0 : 0; } +static INLINE vopmask vlt_vo_vf_vf(vfloat x, vfloat y) { return x < y ? ~(uint32_t)0 : 0; } +static INLINE vopmask vle_vo_vf_vf(vfloat x, vfloat y) { return x <= y ? ~(uint32_t)0 : 0; } +static INLINE vopmask vgt_vo_vf_vf(vfloat x, vfloat y) { return x > y ? ~(uint32_t)0 : 0; } +static INLINE vopmask vge_vo_vf_vf(vfloat x, vfloat y) { return x >= y ? ~(uint32_t)0 : 0; } + +static INLINE vint2 vadd_vi2_vi2_vi2(vint2 x, vint2 y) { return x + y; } +static INLINE vint2 vsub_vi2_vi2_vi2(vint2 x, vint2 y) { return x - y; } +static INLINE vint2 vneg_vi2_vi2(vint2 x) { return -x; } + +static INLINE vint2 vand_vi2_vi2_vi2(vint2 x, vint2 y) { return x & y; } +static INLINE vint2 vandnot_vi2_vi2_vi2(vint2 x, vint2 y) { return y & ~x; } +static INLINE vint2 vor_vi2_vi2_vi2(vint2 x, vint2 y) { return x | y; } +static INLINE vint2 vxor_vi2_vi2_vi2(vint2 x, vint2 y) { return x ^ y; } + +static INLINE vfloat vsel_vf_vo_vf_vf(vopmask o, vfloat x, vfloat y) { return o ? x : y; } +static INLINE vfloat vsel_vf_vo_f_f(vopmask o, float v1, float v0) { return o ? v1 : v0; } + +static INLINE vfloat vsel_vf_vo_vo_f_f_f(vopmask o0, vopmask o1, float d0, float d1, float d2) { + return vsel_vf_vo_vf_vf(o0, vcast_vf_f(d0), vsel_vf_vo_f_f(o1, d1, d2)); +} + +static INLINE vfloat vsel_vf_vo_vo_vo_f_f_f_f(vopmask o0, vopmask o1, vopmask o2, float d0, float d1, float d2, float d3) { + return vsel_vf_vo_vf_vf(o0, vcast_vf_f(d0), vsel_vf_vo_vf_vf(o1, vcast_vf_f(d1), vsel_vf_vo_f_f(o2, d2, d3))); +} + +static INLINE vint2 vand_vi2_vo_vi2(vopmask x, vint2 y) { return vcast_vm_vo(x) & y; } +static INLINE vint2 vandnot_vi2_vo_vi2(vopmask x, vint2 y) { return y & ~vcast_vm_vo(x); } + +static INLINE vint2 vsll_vi2_vi2_i(vint2 x, int c) { + return x << c; +} +static INLINE vint2 vsrl_vi2_vi2_i(vint2 x, int c) { + return ((uint32_t)x) >> c; +} +static INLINE vint2 vsra_vi2_vi2_i(vint2 x, int c) { + return x >> c; +} + +static INLINE vopmask visinf_vo_vf (vfloat d) { return (d == SLEEF_INFINITYf || d == -SLEEF_INFINITYf) ? ~(uint32_t)0 : 0; } +static INLINE vopmask vispinf_vo_vf(vfloat d) { return d == SLEEF_INFINITYf ? ~(uint32_t)0 : 0; } +static INLINE vopmask visminf_vo_vf(vfloat d) { return d == -SLEEF_INFINITYf ? ~(uint32_t)0 : 0; } +static INLINE vopmask visnan_vo_vf (vfloat d) { return d != d ? ~(uint32_t)0 : 0; } + +static INLINE vopmask veq_vo_vi2_vi2 (vint2 x, vint2 y) { return (int32_t)x == (int32_t)y ? ~(uint32_t)0 : 0; } +static INLINE vopmask vgt_vo_vi2_vi2 (vint2 x, vint2 y) { return (int32_t)x > (int32_t)y ? ~(uint32_t)0 : 0; } +static INLINE vint2 veq_vi2_vi2_vi2(vint2 x, vint2 y) { return (int32_t)x == (int32_t)y ? ~(uint32_t)0 : 0; } +static INLINE vint2 vgt_vi2_vi2_vi2(vint2 x, vint2 y) { return (int32_t)x > (int32_t)y ? ~(uint32_t)0 : 0; } + +static INLINE float vcast_f_vf(vfloat v) { return v; } + +static INLINE vfloat vload_vf_p(const float *ptr) { return *ptr; } +static INLINE vfloat vloadu_vf_p(const float *ptr) { return *ptr; } +static INLINE vfloat vgather_vf_p_vi2(const float *ptr, vint2 vi) { return ptr[vi]; } + +static INLINE void vstore_v_p_vf(float *ptr, vfloat v) { *ptr = v; } +static INLINE void vstoreu_v_p_vf(float *ptr, vfloat v) { *ptr = v; } +static INLINE void vstream_v_p_vf(float *ptr, vfloat v) { *ptr = v; } + +// + +#if defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) +static vquad loadu_vq_p(void *p) { + vquad vq; + memcpy(8 + (char *)&vq, p, 8); + memcpy((char *)&vq, 8 + p, 8); + return vq; +} + +static INLINE vquad cast_vq_aq(vargquad aq) { + vquad vq; + memcpy(8 + (char *)&vq, (char *)&aq, 8); + memcpy((char *)&vq, 8 + (char *)&aq, 8); + return vq; +} + +static INLINE vargquad cast_aq_vq(vquad vq) { + vargquad aq; + memcpy(8 + (char *)&aq, (char *)&vq, 8); + memcpy((char *)&aq, 8 + (char *)&vq, 8); + return aq; +} +#else +static vquad loadu_vq_p(void *p) { + vquad vq; + memcpy(&vq, p, sizeof(vq)); + return vq; +} + +static INLINE vquad cast_vq_aq(vargquad aq) { + vquad vq; + memcpy(&vq, &aq, sizeof(vq)); + return vq; +} + +static INLINE vargquad cast_aq_vq(vquad vq) { + vargquad aq; + memcpy(&aq, &vq, sizeof(aq)); + return aq; +} +#endif + +// + +static INLINE int vtestallzeros_i_vo64(vopmask g) { return !g ? ~(uint32_t)0 : 0; } +static INLINE vmask vsel_vm_vo64_vm_vm(vopmask o, vmask x, vmask y) { return o ? x : y; } + +static INLINE vmask vsub64_vm_vm_vm(vmask x, vmask y) { return (int64_t)x - (int64_t)y; } +static INLINE vmask vneg64_vm_vm(vmask x) { return -(int64_t)x; } + +#define vsll64_vm_vm_i(x, c) ((uint64_t)(x) << (c)) +#define vsrl64_vm_vm_i(x, c) ((uint64_t)(x) >> (c)) +//@#define vsll64_vm_vm_i(x, c) ((uint64_t)(x) << (c)) +//@#define vsrl64_vm_vm_i(x, c) ((uint64_t)(x) >> (c)) + +static INLINE vopmask vgt64_vo_vm_vm(vmask x, vmask y) { return (int64_t)x > (int64_t)y ? ~(uint32_t)0 : 0; } + +static INLINE vmask vcast_vm_vi(vint vi) { return vi; } +static INLINE vint vcast_vi_vm(vmask vm) { return vm; } + +static INLINE vmask vreinterpret_vm_vi64(vint64 v) { return v; } +static INLINE vint64 vreinterpret_vi64_vm(vmask m) { return m; } +static INLINE vmask vreinterpret_vm_vu64(vuint64 v) { return v; } +static INLINE vuint64 vreinterpret_vu64_vm(vmask m) { return m; } diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/arch/helperrvv.h b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/arch/helperrvv.h new file mode 100644 index 00000000000..f304434af80 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/arch/helperrvv.h @@ -0,0 +1,1412 @@ +// Copyright Naoki Shibata and contributors 2023. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef HELPERRVV_H +#define HELPERRVV_H + +#if !defined(SLEEF_GENHEADER) +#include +#include "misc.h" + +#if defined(VECTLENDP) || defined(VECTLENSP) +#error VECTLENDP or VECTLENSP already defined +#endif +#endif // #if !defined(SLEEF_GENHEADER) + +#if CONFIG == 1 || CONFIG == 2 +#define ISANAME "RISC-V Vector Extension with Min. VLEN" +#define SLEEF_RVV_VLEN 0 +#elif CONFIG == 7 +// 128-bit vector length +#define ISANAME "RISC-V Vector Extension 128-bit" +#define LOG2VECTLENDP 1 +#define SLEEF_RVV_VLEN ((1 << 7) / 8) +#define DFTPRIORITY 19 +#elif CONFIG == 8 +// 256-bit vector length +#define ISANAME "RISC-V Vector Extension 256-bit" +#define LOG2VECTLENDP 2 +#define SLEEF_RVV_VLEN ((1 << 8) / 8) +#define DFTPRIORITY 20 +#elif CONFIG == 9 +// 512-bit vector length +#define ISANAME "RISC-V Vector Extension 512-bit" +#define LOG2VECTLENDP 3 +#define SLEEF_RVV_VLEN ((1 << 9) / 8) +#define DFTPRIORITY 21 +#elif CONFIG == 10 +// 1024-bit vector length +#define ISANAME "RISC-V Vector Extension 1024-bit" +#define LOG2VECTLENDP 4 +#define SLEEF_RVV_VLEN ((1 << 10) / 8) +#define DFTPRIORITY 22 +#elif CONFIG == 11 +// 2048-bit vector length +#define ISANAME "RISC-V Vector Extension 2048-bit" +#define LOG2VECTLENDP 5 +#define SLEEF_RVV_VLEN ((1 << 11) / 8) +#define DFTPRIORITY 23 +#else +#error CONFIG macro invalid or not defined +#endif + +#define LOG2VECTLENSP (LOG2VECTLENDP+1) + +#define ENABLE_SP +//@#define ENABLE_SP +#define ENABLE_DP +//@#define ENABLE_DP + +#if CONFIG != 2 +#if defined(ENABLE_RVVM1NOFMA) || defined(ENABLE_RVVM2NOFMA) +#error "RVV NOFMA only supported for CONFIG=2" +#else +#define ENABLE_FMA_SP +//@#define ENABLE_FMA_SP +#define ENABLE_FMA_DP +//@#define ENABLE_FMA_DP +#endif +#endif + +#if __riscv_v_intrinsic < 1000000 && !(defined(__clang_major__) && __clang_major__ >= 18) +// __riscv_vcreate* intrinsics only showed up in v1.0-rc0 of the RVV intrinsics +// spec and have already been implemented in clang-18, but are useful for +// eliminating issues with uninitialised data because they are explicit that +// the whole result has defined values. Here we do our best to offer fallback +// implementations where needed. +// +#define __riscv_vcreate_v_f32m1_f32m2(x, y) __riscv_vset(__riscv_vlmul_ext_v_f32m1_f32m2(x), 1, y) +#define __riscv_vcreate_v_f32m2_f32m4(x, y) __riscv_vset(__riscv_vlmul_ext_v_f32m2_f32m4(x), 1, y) +#define __riscv_vcreate_v_f32m4_f32m8(x, y) __riscv_vset(__riscv_vlmul_ext_v_f32m4_f32m8(x), 1, y) +#define __riscv_vcreate_v_f64m1_f64m2(x, y) __riscv_vset(__riscv_vlmul_ext_v_f64m1_f64m2(x), 1, y) +#define __riscv_vcreate_v_f64m2_f64m4(x, y) __riscv_vset(__riscv_vlmul_ext_v_f64m2_f64m4(x), 1, y) +#define __riscv_vcreate_v_f64m4_f64m8(x, y) __riscv_vset(__riscv_vlmul_ext_v_f64m4_f64m8(x), 1, y) +#define __riscv_vcreate_v_i32m1_i32m2(x, y) __riscv_vset(__riscv_vlmul_ext_v_i32m1_i32m2(x), 1, y) +#define __riscv_vcreate_v_i32m2_i32m4(x, y) __riscv_vset(__riscv_vlmul_ext_v_i32m2_i32m4(x), 1, y) +#define __riscv_vcreate_v_i32m4_i32m8(x, y) __riscv_vset(__riscv_vlmul_ext_v_i32m4_i32m8(x), 1, y) +#define __riscv_vcreate_v_u64m1_u64m2(x, y) __riscv_vset(__riscv_vlmul_ext_v_u64m1_u64m2(x), 1, y) +#define __riscv_vcreate_v_u64m2_u64m4(x, y) __riscv_vset(__riscv_vlmul_ext_v_u64m2_u64m4(x), 1, y) + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wuninitialized" +static INLINE vfloat64m1x4_t __riscv_vcreate_v_f64m1x4(vfloat64m1_t x, vfloat64m1_t y, vfloat64m1_t z, vfloat64m1_t w) { + vfloat64m1x4_t unused; + return __riscv_vset(__riscv_vset(__riscv_vset(__riscv_vset(unused, 0, x), 1, y), 2, z), 3, w); +} +static INLINE vfloat64m2x4_t __riscv_vcreate_v_f64m2x4(vfloat64m2_t x, vfloat64m2_t y, vfloat64m2_t z, vfloat64m2_t w) { + vfloat64m2x4_t unused; + return __riscv_vset(__riscv_vset(__riscv_vset(__riscv_vset(unused, 0, x), 1, y), 2, z), 3, w); +} +#pragma GCC diagnostic pop +#endif + +#ifdef NDEBUG +#define SLEEF_RVV_VEXT(size, from_to, v) __riscv_vlmul_ext_v_##from_to(v) +#else +// In situations where we cast from wider to narrower types and then back again +// we should expect data loss, but it can too easily sneak through undisturbed. +// +// QEMU and some hardware have a feature to automatically wipe partial vectors +// when they get truncated this way, but for pure casts like vlmul_ext we need +// to insert a deliberate move operation to force that to happen. Since it's +// extra work it's only enabled for debug builds. +// +#define SLEEF_RVV_VEXT(size, from_to, v) __riscv_vmv_v(__riscv_vlmul_ext_v_##from_to(v), __riscv_vsetvlmax_##size()) +#endif + +//////////////////////////////////////////////////////////////////////////////// +// RISC-V Vector Types +//////////////////////////////////////////////////////////////////////////////// + +// LMUL-Dependent Type & Macro Definitions: +// +// Some SLEEF types are multi-value structs. RVV vectors have unknown length at +// compile time, so they cannote appear in a struct in Clang. They are instead +// represented as single vectors with "members" packed into the registers of a +// wide-LMUL register group. In the largest cases (ddi_t and ddf_t), this +// requires LMUL=8 if the base type (vfloat or vdouble) has LMUL=2, meaning +// LMUL=2 is currently the widest option for SLEEF function argument types. +#if defined(ENABLE_RVVM1) || defined(ENABLE_RVVM1NOFMA) + +typedef vuint32m1_t rvv_vmask32; +typedef vuint64m1_t vmask; +typedef vbool32_t rvv_sp_vopmask; +typedef vbool64_t rvv_dp_vopmask; + +typedef vint32mf2_t vint; +typedef vint64m1_t vint64; +typedef vuint64m1_t vuint64; +typedef vfloat64m1_t vdouble; +typedef vfloat64m2_t vdouble2; +typedef vfloat64m4_t vdouble3; +typedef vfloat64m4_t dd2; +typedef vuint64m2_t vquad; +typedef vint32m2_t di_t; +typedef vint32m4_t ddi_t; +typedef vfloat32m1_t vfloat; +typedef vfloat32m2_t vfloat2; +typedef vfloat32m4_t df2; +typedef vint32m1_t vint2; +typedef vint32m2_t fi_t; +typedef vint32m4_t dfi_t; +typedef vuint64m1_t rvv_dp_vuint2; + +typedef vfloat64m1x4_t tdx; +typedef vfloat64m1x4_t tdi_t; + +#define SLEEF_RVV_SP_LMUL 1 +#define SLEEF_RVV_DP_LMUL 1 +#define SLEEF_RVV_DP_RUNTIME_VL() __riscv_vsetvlmax_e64m1() +#if SLEEF_RVV_VLEN == 0 +// The configuration didn't provide a constant vector length, meaning it'll +// have to be determined at run-time. RVV offers per-data-width operations for +// this so the result doesn't need to be adjusted and that operation is likely +// to fold into the surrounding code for free. +// +#define VECTLENSP (__riscv_vsetvlmax_e32m1()) +#define VECTLENDP SLEEF_RVV_DP_RUNTIME_VL() +//@#define VECTLENSP __riscv_vsetvlmax_e32m1() +//@#define VECTLENDP __riscv_vsetvlmax_e64m1() +#else +#define VECTLENSP (SLEEF_RVV_SP_LMUL * SLEEF_RVV_VLEN / sizeof(float)) +#define VECTLENDP (SLEEF_RVV_DP_LMUL * SLEEF_RVV_VLEN / sizeof(double)) +//@#define VECTLENSP (SLEEF_RVV_SP_LMUL * SLEEF_RVV_VLEN / sizeof(float)) +//@#define VECTLENDP (SLEEF_RVV_DP_LMUL * SLEEF_RVV_VLEN / sizeof(double)) +#endif +#define SLEEF_RVV_SP_VCAST_VF_F __riscv_vfmv_v_f_f32m1 +#define SLEEF_RVV_SP_VCAST_VI2_I __riscv_vmv_v_x_i32m1 +#define SLEEF_RVV_SP_VREINTERPRET_VF __riscv_vreinterpret_f32m1 +#define SLEEF_RVV_SP_VREINTERPRET_VF2 __riscv_vreinterpret_f32m2 +#define SLEEF_RVV_SP_VREINTERPRET_VM __riscv_vreinterpret_u32m1 +#define SLEEF_RVV_SP_VREINTERPRET_VI2 __riscv_vreinterpret_i32m1 +#define SLEEF_RVV_SP_VREINTERPRET_2VI __riscv_vreinterpret_i32m2 +#define SLEEF_RVV_SP_VREINTERPRET_VU __riscv_vreinterpret_u32m1 +#define SLEEF_RVV_SP_VREINTERPRET_VU2 __riscv_vreinterpret_u32m1 +#define SLEEF_RVV_SP_VREINTERPRET_VOM __riscv_vreinterpret_b32 +#define SLEEF_RVV_SP_VID() __riscv_vid_v_u32m1(VECTLENSP) +#define SLEEF_RVV_SP_VGET_VI2 __riscv_vget_i32m1 +#define SLEEF_RVV_SP_VGET_2VI __riscv_vget_i32m2 +#define SLEEF_RVV_SP_VGET_VF __riscv_vget_f32m1 +#define SLEEF_RVV_SP_VGET_VF2 __riscv_vget_f32m2 +#define SLEEF_RVV_SP_VCREATE_FI __riscv_vcreate_v_i32m1_i32m2 +#define SLEEF_RVV_SP_VCREATE_DFI __riscv_vcreate_v_i32m2_i32m4 +#define SLEEF_RVV_SP_VCREATE_DF2 __riscv_vcreate_v_f32m2_f32m4 +#define SLEEF_RVV_SP_VCREATE_VF2 __riscv_vcreate_v_f32m1_f32m2 +#define SLEEF_RVV_SP_VLMUL_EXT_VI2_TO_FI(v) SLEEF_RVV_VEXT(e32m1, i32m1_i32m2, v) +#define SLEEF_RVV_SP_LOAD_VF __riscv_vle32_v_f32m1 +#define SLEEF_RVV_SP_LOAD_2VI __riscv_vle32_v_i32m2 +#define SLEEF_RVV_SP_VFNCVT_X_F_VI __riscv_vfcvt_x_f_v_i32m1_rm +#define SLEEF_RVV_SP_VFCVT_F_X_VF __riscv_vfcvt_f_x_v_f32m1 +#define SLEEF_RVV_SP_VFCVT_X_F_VF_RM __riscv_vfcvt_x_f_v_i32m1_rm +#define SLEEF_RVV_DP_VCAST_VD_D __riscv_vfmv_v_f_f64m1 +#define SLEEF_RVV_DP_VCAST_VD_VI(x) __riscv_vfwcvt_f(x, VECTLENDP) +#define SLEEF_RVV_DP_VCAST_VI_I __riscv_vmv_v_x_i32mf2 +#define SLEEF_RVV_DP_VCAST_VM_U __riscv_vmv_v_x_u64m1 +#define SLEEF_RVV_DP_VREINTERPRET_VD(v) __riscv_vreinterpret_f64m1(__riscv_vreinterpret_i64m1(v)) +#define SLEEF_RVV_DP_VREINTERPRET_4VD_8VI(x) \ + __riscv_vreinterpret_f64m4(__riscv_vreinterpret_v_i32m4_i64m4(x)) +#define SLEEF_RVV_DP_VREINTERPRET_VM __riscv_vreinterpret_u64m1 +#define SLEEF_RVV_DP_VREINTERPRET_VM_SIGNED __riscv_vreinterpret_i64m1 +#define SLEEF_RVV_DP_VREINTERPRET_VI64 __riscv_vreinterpret_i64m1 +#define SLEEF_RVV_DP_VREINTERPRET_VI __riscv_vreinterpret_i32mf2 +#define SLEEF_RVV_DP_VREINTERPRET_VI2(v) __riscv_vreinterpret_i32m1(__riscv_vreinterpret_i64m1(v)) +#define SLEEF_RVV_DP_VREINTERPRET_4VI(v) __riscv_vreinterpret_i32m2(__riscv_vreinterpret_i64m2(v)) +#define SLEEF_RVV_DP_VREINTERPRET_VU __riscv_vreinterpret_u32mf2 +#define SLEEF_RVV_DP_VREINTERPRET_4VU __riscv_vreinterpret_u32m2 +#define SLEEF_RVV_DP_VREINTERPRET_VQ __riscv_vreinterpret_u64m2 +#define SLEEF_RVV_DP_VREINTERPRET_VOM __riscv_vreinterpret_b64 +#define SLEEF_RVV_DP_VID() __riscv_vid_v_u64m1(VECTLENDP) +#define SLEEF_RVV_DP_VGET_VM __riscv_vget_u64m1 +#define SLEEF_RVV_DP_VGET_VD __riscv_vget_f64m1 +#define SLEEF_RVV_DP_VGET_VD2 __riscv_vget_f64m2 +#define SLEEF_RVV_DP_VGET_4VD __riscv_vget_f64m2 +#define SLEEF_RVV_DP_VGET_VI2 __riscv_vget_i32m1 +#define SLEEF_RVV_DP_VCREATE_DI __riscv_vcreate_v_i32m1_i32m2 +#define SLEEF_RVV_DP_VCREATE_DDI(x, y) __riscv_vcreate_v_i32m2_i32m4(x, SLEEF_RVV_VEXT(e32mf2, i32mf2_i32m2, y)) +#define SLEEF_RVV_DP_VCREATE_TD __riscv_vcreate_v_f64m1x4 +#define SLEEF_RVV_DP_VCREATE_VD2 __riscv_vcreate_v_f64m1_f64m2 +#define SLEEF_RVV_DP_VCREATE_VQ __riscv_vcreate_v_u64m1_u64m2 +#define SLEEF_RVV_DP_VCREATE_3VD(x, y, z) __riscv_vcreate_v_f64m2_f64m4(__riscv_vcreate_v_f64m1_f64m2(x, y), SLEEF_RVV_VEXT(e64m1, f64m1_f64m2, z)) +#define SLEEF_RVV_DP_VCREATE_4VD __riscv_vcreate_v_f64m2_f64m4 +#define SLEEF_RVV_DP_VLMUL_TRUNC_VI2_TO_VI(v) __riscv_vlmul_trunc_i32mf2(v) +#define SLEEF_RVV_DP_VLMUL_EXT_VI_TO_VI2(v) SLEEF_RVV_VEXT(e32mf2, i32mf2_i32m1, v) +#define SLEEF_RVV_DP_LOAD_VD __riscv_vle64_v_f64m1 +#define SLEEF_RVV_DP_LOAD_VI __riscv_vle32_v_i32mf2 +#define SLEEF_RVV_DP_VFNCVT_X_F_VI __riscv_vfncvt_x_f_w_i32mf2_rm +#define SLEEF_RVV_DP_VFCVT_F_X_VD __riscv_vfcvt_f_x_v_f64m1 +#define SLEEF_RVV_DP_VFCVT_X_F_VD_RM __riscv_vfcvt_x_f_v_i64m1_rm + +#elif defined(ENABLE_RVVM2) || defined(ENABLE_RVVM2NOFMA) + +typedef vuint32m2_t rvv_vmask32; +typedef vuint64m2_t vmask; +typedef vbool16_t rvv_sp_vopmask; +typedef vbool32_t rvv_dp_vopmask; + +typedef vint32m1_t vint; +typedef vint64m2_t vint64; +typedef vuint64m2_t vuint64; +typedef vfloat64m2_t vdouble; +typedef vfloat64m4_t vdouble2; +typedef vfloat64m8_t vdouble3; +typedef vfloat64m8_t dd2; +typedef vuint64m4_t vquad; +typedef vint32m4_t di_t; +typedef vint32m8_t ddi_t; +typedef vfloat32m2_t vfloat; +typedef vfloat32m4_t vfloat2; +typedef vfloat32m8_t df2; +typedef vint32m2_t vint2; +typedef vint32m4_t fi_t; +typedef vint32m8_t dfi_t; +typedef vuint64m2_t rvv_dp_vuint2; + +typedef vfloat64m2x4_t tdx; +typedef vfloat64m2x4_t tdi_t; + +#define SLEEF_RVV_SP_LMUL 2 +#define SLEEF_RVV_DP_LMUL 2 +#define SLEEF_RVV_DP_RUNTIME_VL() __riscv_vsetvlmax_e64m2() +#if SLEEF_RVV_VLEN == 0 +// The configuration didn't provide a constant vector length, meaning it'll +// have to be determined at run-time. RVV offers per-data-width operations for +// this so the result doesn't need to be adjusted and that operation is likely +// to fold into the surrounding code for free. +// +#define VECTLENSP (__riscv_vsetvlmax_e32m2()) +#define VECTLENDP SLEEF_RVV_DP_RUNTIME_VL() +//@#define VECTLENSP __riscv_vsetvlmax_e32m2() +//@#define VECTLENDP __riscv_vsetvlmax_e64m2() +#else +#define VECTLENSP (SLEEF_RVV_SP_LMUL * SLEEF_RVV_VLEN / sizeof(float)) +#define VECTLENDP (SLEEF_RVV_DP_LMUL * SLEEF_RVV_VLEN / sizeof(double)) +//@#define VECTLENSP (SLEEF_RVV_SP_LMUL * SLEEF_RVV_VLEN / sizeof(float)) +//@#define VECTLENDP (SLEEF_RVV_DP_LMUL * SLEEF_RVV_VLEN / sizeof(double)) +#endif +#define SLEEF_RVV_SP_VCAST_VF_F __riscv_vfmv_v_f_f32m2 +#define SLEEF_RVV_SP_VCAST_VI2_I __riscv_vmv_v_x_i32m2 +#define SLEEF_RVV_SP_VREINTERPRET_VF __riscv_vreinterpret_f32m2 +#define SLEEF_RVV_SP_VREINTERPRET_VF2 __riscv_vreinterpret_f32m4 +#define SLEEF_RVV_SP_VREINTERPRET_VM __riscv_vreinterpret_u32m2 +#define SLEEF_RVV_SP_VREINTERPRET_VI2 __riscv_vreinterpret_i32m2 +#define SLEEF_RVV_SP_VREINTERPRET_2VI __riscv_vreinterpret_i32m4 +#define SLEEF_RVV_SP_VREINTERPRET_VU __riscv_vreinterpret_u32m2 +#define SLEEF_RVV_SP_VREINTERPRET_VU2 __riscv_vreinterpret_u32m2 +#define SLEEF_RVV_SP_VREINTERPRET_VOM __riscv_vreinterpret_b16 +#define SLEEF_RVV_SP_VID() __riscv_vid_v_u32m2(VECTLENSP) +#define SLEEF_RVV_SP_VGET_VI2 __riscv_vget_i32m2 +#define SLEEF_RVV_SP_VGET_2VI __riscv_vget_i32m4 +#define SLEEF_RVV_SP_VGET_VF __riscv_vget_f32m2 +#define SLEEF_RVV_SP_VGET_VF2 __riscv_vget_f32m4 +#define SLEEF_RVV_SP_VCREATE_FI __riscv_vcreate_v_i32m2_i32m4 +#define SLEEF_RVV_SP_VCREATE_DFI __riscv_vcreate_v_i32m4_i32m8 +#define SLEEF_RVV_SP_VCREATE_DF2 __riscv_vcreate_v_f32m4_f32m8 +#define SLEEF_RVV_SP_VCREATE_VF2 __riscv_vcreate_v_f32m2_f32m4 +#define SLEEF_RVV_SP_VLMUL_EXT_VI2_TO_FI(v) SLEEF_RVV_VEXT(e32m2, i32m2_i32m4, v) +#define SLEEF_RVV_SP_LOAD_VF __riscv_vle32_v_f32m2 +#define SLEEF_RVV_SP_LOAD_2VI __riscv_vle32_v_i32m4 +#define SLEEF_RVV_SP_VFNCVT_X_F_VI __riscv_vfcvt_x_f_v_i32m2_rm +#define SLEEF_RVV_SP_VFCVT_F_X_VF __riscv_vfcvt_f_x_v_f32m2 +#define SLEEF_RVV_SP_VFCVT_X_F_VF_RM __riscv_vfcvt_x_f_v_i32m2_rm +#define SLEEF_RVV_DP_VCAST_VD_D __riscv_vfmv_v_f_f64m2 +#define SLEEF_RVV_DP_VCAST_VD_VI(x) __riscv_vfwcvt_f(x, VECTLENDP) +#define SLEEF_RVV_DP_VCAST_VI_I __riscv_vmv_v_x_i32m1 +#define SLEEF_RVV_DP_VCAST_VM_U __riscv_vmv_v_x_u64m2 +#define SLEEF_RVV_DP_VREINTERPRET_VD(v) __riscv_vreinterpret_f64m2(__riscv_vreinterpret_i64m2(v)) +#define SLEEF_RVV_DP_VREINTERPRET_4VD_8VI(x) \ + __riscv_vreinterpret_f64m8(__riscv_vreinterpret_v_i32m8_i64m8(x)) +#define SLEEF_RVV_DP_VREINTERPRET_VM __riscv_vreinterpret_u64m2 +#define SLEEF_RVV_DP_VREINTERPRET_VM_SIGNED __riscv_vreinterpret_i64m2 +#define SLEEF_RVV_DP_VREINTERPRET_VI64 __riscv_vreinterpret_i64m2 +#define SLEEF_RVV_DP_VREINTERPRET_VI __riscv_vreinterpret_i32m1 +#define SLEEF_RVV_DP_VREINTERPRET_VI2(v) __riscv_vreinterpret_i32m2(__riscv_vreinterpret_i64m2(v)) +#define SLEEF_RVV_DP_VREINTERPRET_4VI(v) __riscv_vreinterpret_i32m4(__riscv_vreinterpret_i64m4(v)) +#define SLEEF_RVV_DP_VREINTERPRET_VU __riscv_vreinterpret_u32m1 +#define SLEEF_RVV_DP_VREINTERPRET_4VU __riscv_vreinterpret_u32m4 +#define SLEEF_RVV_DP_VREINTERPRET_VQ __riscv_vreinterpret_u64m4 +#define SLEEF_RVV_DP_VREINTERPRET_VOM __riscv_vreinterpret_b32 +#define SLEEF_RVV_DP_VID() __riscv_vid_v_u64m2(VECTLENDP) +#define SLEEF_RVV_DP_VGET_VM __riscv_vget_u64m2 +#define SLEEF_RVV_DP_VGET_VD __riscv_vget_f64m2 +#define SLEEF_RVV_DP_VGET_VD2 __riscv_vget_f64m4 +#define SLEEF_RVV_DP_VGET_4VD __riscv_vget_f64m4 +#define SLEEF_RVV_DP_VGET_VI2 __riscv_vget_i32m2 +#define SLEEF_RVV_DP_VCREATE_DI __riscv_vcreate_v_i32m2_i32m4 +#define SLEEF_RVV_DP_VCREATE_DDI(x, y) __riscv_vcreate_v_i32m4_i32m8(x, SLEEF_RVV_VEXT(e32m1, i32m1_i32m4, y)) +#define SLEEF_RVV_DP_VCREATE_TD __riscv_vcreate_v_f64m2x4 +#define SLEEF_RVV_DP_VCREATE_VD2 __riscv_vcreate_v_f64m2_f64m4 +#define SLEEF_RVV_DP_VCREATE_VQ __riscv_vcreate_v_u64m2_u64m4 +#define SLEEF_RVV_DP_VCREATE_3VD(x, y, z) __riscv_vcreate_v_f64m4_f64m8(__riscv_vcreate_v_f64m2_f64m4(x, y), SLEEF_RVV_VEXT(e64m2, f64m2_f64m4, z)) +#define SLEEF_RVV_DP_VCREATE_4VD __riscv_vcreate_v_f64m4_f64m8 +#define SLEEF_RVV_DP_VLMUL_TRUNC_VI2_TO_VI(v) __riscv_vlmul_trunc_i32m1(v) +#define SLEEF_RVV_DP_VLMUL_EXT_VI_TO_VI2(v) SLEEF_RVV_VEXT(e32m1, i32m1_i32m2, v) +#define SLEEF_RVV_DP_LOAD_VD __riscv_vle64_v_f64m2 +#define SLEEF_RVV_DP_LOAD_VI __riscv_vle32_v_i32m1 +#define SLEEF_RVV_DP_VFNCVT_X_F_VI __riscv_vfncvt_x_f_w_i32m1_rm +#define SLEEF_RVV_DP_VFCVT_F_X_VD __riscv_vfcvt_f_x_v_f64m2 +#define SLEEF_RVV_DP_VFCVT_X_F_VD_RM __riscv_vfcvt_x_f_v_i64m2_rm + +#else +#error "unknown rvv lmul" +#endif // ENABLE_RVVM1 + +typedef vquad vargquad; + +static INLINE int vavailability_i(int name) { + // Note that in some cases VECTLENDP is defined as SLEEF_RVV_DP_RUNTIME_VL(), + // which makes this kind of a redundant operation. It's still preferable to + // issue the instructions, though, because if it's not available then it'll + // raise an illegal instruction exception which is trapped by the caller for + // proper error handling in the expected place. + // + return (SLEEF_RVV_DP_RUNTIME_VL() >= VECTLENDP) ? 3 : 0; +} + +//////////////////////////////////////////////////////////////////////////////// +// Single-Precision Functions +//////////////////////////////////////////////////////////////////////////////// + +/****************************************/ +/* Multi-value and multi-word types */ +/****************************************/ +// fi type +static INLINE vfloat figetd_vf_di(fi_t d) { + return SLEEF_RVV_SP_VREINTERPRET_VF(SLEEF_RVV_SP_VGET_VI2(d, 0)); +} +static INLINE vint2 figeti_vi2_di(fi_t d) { + return SLEEF_RVV_SP_VGET_VI2(d, 1); +} +static INLINE fi_t fisetdi_fi_vf_vi2(vfloat d, vint2 i) { + vint2 vdi = SLEEF_RVV_SP_VREINTERPRET_VI2(d); + return SLEEF_RVV_SP_VCREATE_FI(vdi, i); +} +static INLINE vfloat2 dfigetdf_vf2_dfi(dfi_t d) { + return SLEEF_RVV_SP_VREINTERPRET_VF2(SLEEF_RVV_SP_VGET_2VI(d, 0)); +} +static INLINE vint2 dfigeti_vi2_dfi(dfi_t d) { + return SLEEF_RVV_SP_VGET_VI2(d, 2); +} +static INLINE dfi_t dfisetdfi_dfi_vf2_vi2(vfloat2 v, vint2 i) { + fi_t vi = SLEEF_RVV_SP_VREINTERPRET_2VI(v); + fi_t ix = SLEEF_RVV_SP_VLMUL_EXT_VI2_TO_FI(i); + return SLEEF_RVV_SP_VCREATE_DFI(vi, ix); +} +static INLINE dfi_t dfisetdf_dfi_dfi_vf2(dfi_t dfi, vfloat2 v) { + return __riscv_vset(dfi, 0, SLEEF_RVV_SP_VREINTERPRET_2VI(v)); +} +// vfloat2 type +static INLINE vfloat vf2getx_vf_vf2(vfloat2 v) { + return SLEEF_RVV_SP_VGET_VF(v, 0); +} +static INLINE vfloat vf2gety_vf_vf2(vfloat2 v) { + return SLEEF_RVV_SP_VGET_VF(v, 1); +} +static INLINE vfloat2 vf2setxy_vf2_vf_vf(vfloat x, vfloat y) { + return SLEEF_RVV_SP_VCREATE_VF2(x, y); +} +static INLINE vfloat2 vf2setx_vf2_vf2_vf(vfloat2 v, vfloat d) { + return __riscv_vset(v, 0, d); +} +static INLINE vfloat2 vf2sety_vf2_vf2_vf(vfloat2 v, vfloat d) { + return __riscv_vset(v, 1, d); +} +// df2 type +static df2 df2setab_df2_vf2_vf2(vfloat2 a, vfloat2 b) { + return SLEEF_RVV_SP_VCREATE_DF2(a, b); +} +static vfloat2 df2geta_vf2_df2(df2 d) { return SLEEF_RVV_SP_VGET_VF2(d, 0); } +static vfloat2 df2getb_vf2_df2(df2 d) { return SLEEF_RVV_SP_VGET_VF2(d, 1); } +static INLINE vint2 vreinterpret_vi2_vf(vfloat vf) { + return SLEEF_RVV_SP_VREINTERPRET_VI2(vf); +} +static INLINE vfloat vreinterpret_vf_vi2(vint2 vi) { + return SLEEF_RVV_SP_VREINTERPRET_VF(vi); +} + + +/****************************************/ +/* Type Conversions and Broadcasts */ +/****************************************/ +static INLINE vfloat vcast_vf_f(float f) { + return SLEEF_RVV_SP_VCAST_VF_F(f, VECTLENSP); +} +static INLINE vfloat vrint_vf_vf(vfloat vd) { + return SLEEF_RVV_SP_VFCVT_F_X_VF(SLEEF_RVV_SP_VFCVT_X_F_VF_RM(vd, __RISCV_FRM_RNE, VECTLENSP), VECTLENSP); +} +static INLINE vfloat vcast_vf_vi2(vint2 vi) { + return __riscv_vfcvt_f(vi, VECTLENSP); +} +static INLINE vint2 vcast_vi2_i(int i) { + return SLEEF_RVV_SP_VCAST_VI2_I(i, VECTLENSP); +} +static INLINE vint2 vrint_vi2_vf(vfloat vf) { + return SLEEF_RVV_SP_VFNCVT_X_F_VI(vf, __RISCV_FRM_RNE, VECTLENSP); +} +static INLINE vint2 vtruncate_vi2_vf(vfloat vf) { + return __riscv_vfcvt_rtz_x(vf, VECTLENSP); +} +static INLINE vfloat vtruncate_vf_vf(vfloat vf) { + return vcast_vf_vi2(vtruncate_vi2_vf(vf)); +} + + +/****************************************/ +/* Memory Operations */ +/****************************************/ +static INLINE vfloat vload_vf_p(const float *ptr) { + return SLEEF_RVV_SP_LOAD_VF(ptr, VECTLENSP); +} +static INLINE vfloat vloadu_vf_p(const float *ptr) { + return SLEEF_RVV_SP_LOAD_VF(ptr, VECTLENSP); +} +static INLINE void vstore_v_p_vf(float *ptr, vfloat v) { + __riscv_vse32(ptr, v, VECTLENSP); +} +static INLINE void vstoreu_v_p_vf(float *ptr, vfloat v) { + __riscv_vse32(ptr, v, VECTLENSP); +} +static INLINE void vstoreu_v_p_vi2(int32_t *ptr, vint2 v) { + __riscv_vse32(ptr, v, VECTLENSP); +} +static INLINE vfloat vgather_vf_p_vi2(const float *ptr, vint2 vi2) { + return __riscv_vluxei32(ptr, __riscv_vmul(SLEEF_RVV_SP_VREINTERPRET_VU(vi2), sizeof(float), VECTLENSP), VECTLENSP); +} + + +/****************************************/ +/* Floating-Point Arithmetic */ +/****************************************/ +static INLINE vfloat vadd_vf_vf_vf(vfloat x, vfloat y) { + return __riscv_vfadd(x, y, VECTLENSP); +} +static INLINE vfloat vsub_vf_vf_vf(vfloat x, vfloat y) { + return __riscv_vfsub(x, y, VECTLENSP); +} +static INLINE vfloat vmul_vf_vf_vf(vfloat x, vfloat y) { + return __riscv_vfmul(x, y, VECTLENSP); +} +static INLINE vfloat vdiv_vf_vf_vf(vfloat x, vfloat y) { + return __riscv_vfdiv(x, y, VECTLENSP); +} +static INLINE vfloat vmax_vf_vf_vf(vfloat x, vfloat y) { + return __riscv_vfmax(x, y, VECTLENSP); +} +static INLINE vfloat vmin_vf_vf_vf(vfloat x, vfloat y) { + return __riscv_vfmin(x, y, VECTLENSP); +} +static INLINE vfloat vrec_vf_vf(vfloat d) { + return __riscv_vfdiv(vcast_vf_f(1.0f), d, VECTLENSP); +} +static INLINE vfloat vsqrt_vf_vf(vfloat d) { + return __riscv_vfsqrt(d, VECTLENSP); +} +#if defined(ENABLE_FMA_SP) +// Multiply accumulate: z = z + x * y +static INLINE vfloat vmla_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { + return __riscv_vfmadd(x, y, z, VECTLENSP); +} +// Multiply subtract: z = z - x * y +static INLINE vfloat vmlanp_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { + return __riscv_vfnmsub(x, y, z, VECTLENSP); +} +static INLINE vfloat vmlapn_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { + return __riscv_vfmsub(x, y, z, VECTLENSP); +} +#else +static INLINE vfloat vmla_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return vadd_vf_vf_vf(vmul_vf_vf_vf(x, y), z); } +static INLINE vfloat vmlanp_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return vsub_vf_vf_vf(z, vmul_vf_vf_vf(x, y)); } +static INLINE vfloat vmlapn_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return vsub_vf_vf_vf(vmul_vf_vf_vf(x, y), z); } +#endif +// fused multiply add / sub +static INLINE vfloat vfma_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { // (x * y) + z + return __riscv_vfmadd(x, y, z, VECTLENSP); +} +static INLINE vfloat vfmanp_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { // -(x * y) + z + return __riscv_vfnmsub(x, y, z, VECTLENSP); +} +static INLINE vfloat vfmapn_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { // (x * y) - z + return __riscv_vfmsub(x, y, z, VECTLENSP); +} +// sign manipulation +static INLINE vfloat vmulsign_vf_vf_vf(vfloat x, vfloat y) { + return __riscv_vfsgnjx(x, y, VECTLENSP); +} +static INLINE vfloat vcopysign_vf_vf_vf(vfloat x, vfloat y) { + return __riscv_vfsgnj(x, y, VECTLENSP); +} +static INLINE vfloat vsign_vf_vf(vfloat f) { + return __riscv_vfsgnj(SLEEF_RVV_SP_VCAST_VF_F(1.0f, VECTLENSP), f, VECTLENSP); +} +static INLINE vfloat vorsign_vf_vf_vf(vfloat x, vfloat y) { + vint2 xi = SLEEF_RVV_SP_VREINTERPRET_VI2(x); + vint2 yi = SLEEF_RVV_SP_VREINTERPRET_VI2(y); + vint2 xioryi = __riscv_vor(xi, yi, VECTLENSP); + vfloat xory = SLEEF_RVV_SP_VREINTERPRET_VF(xioryi); + return __riscv_vfsgnj(x, xory, VECTLENSP); +} +static INLINE vfloat vabs_vf_vf(vfloat f) { + return __riscv_vfabs(f, VECTLENSP); +} +static INLINE vfloat vneg_vf_vf(vfloat f) { + return __riscv_vfneg(f, VECTLENSP); +} + + +/****************************************/ +/* Integer Arithmetic and Logic */ +/****************************************/ +static INLINE vint2 vadd_vi2_vi2_vi2(vint2 x, vint2 y) { + return __riscv_vadd(x, y, VECTLENSP); +} +static INLINE vint2 vsub_vi2_vi2_vi2(vint2 x, vint2 y) { + return __riscv_vsub(x, y, VECTLENSP); +} +static INLINE vint2 vneg_vi2_vi2(vint2 x) { + return __riscv_vneg(x, VECTLENSP); +} +static INLINE vint2 vand_vi2_vi2_vi2(vint2 x, vint2 y) { + return __riscv_vand(x, y, VECTLENSP); +} +static INLINE vint2 vandnot_vi2_vi2_vi2(vint2 x, vint2 y) { + return __riscv_vand(__riscv_vnot(x, VECTLENSP), y, VECTLENSP); +} +static INLINE vint2 vor_vi2_vi2_vi2(vint2 x, vint2 y) { + return __riscv_vor(x, y, VECTLENSP); +} +static INLINE vint2 vxor_vi2_vi2_vi2(vint2 x, vint2 y) { + return __riscv_vxor(x, y, VECTLENSP); +} +static INLINE vint2 vsll_vi2_vi2_i(vint2 x, int c) { + return __riscv_vsll(x, c, VECTLENSP); +} +static INLINE vint2 vsra_vi2_vi2_i(vint2 x, int c) { + return __riscv_vsra(x, c, VECTLENSP); +} +static INLINE vint2 vsrl_vi2_vi2_i(vint2 x, int c) { + return SLEEF_RVV_SP_VREINTERPRET_VI2(__riscv_vsrl(SLEEF_RVV_SP_VREINTERPRET_VU2(x), c, VECTLENSP)); +} + +/****************************************/ +/* Bitmask Operations */ +/****************************************/ +static INLINE vfloat vreinterpret_vf_vm(vmask vm) { + return SLEEF_RVV_SP_VREINTERPRET_VF(SLEEF_RVV_SP_VREINTERPRET_VM(vm)); +} +static INLINE vmask vreinterpret_vm_vf(vfloat vf) { + return SLEEF_RVV_DP_VREINTERPRET_VM(SLEEF_RVV_SP_VREINTERPRET_VM(vf)); +} + +// These are implementations involving the vopmask type which only work in the +// single-precision case. Unfortunately this has a type conflict with the +// double-precision implemention, and so a temporary rvv_sp_vopmask type is +// used here and then macro-ed back to vopmask at the end of the file if +// needed. +// +static INLINE int vtestallones_i_vo32(rvv_sp_vopmask g) { + return __riscv_vcpop(g, VECTLENSP) == VECTLENSP; +} +static INLINE vmask vor_vm_vo32_vm(rvv_sp_vopmask x, vmask y) { + rvv_vmask32 y32 = SLEEF_RVV_SP_VREINTERPRET_VM(y); + return SLEEF_RVV_DP_VREINTERPRET_VM(__riscv_vmerge(y32, -1, x, VECTLENSP)); +} +static INLINE vmask vand_vm_vo32_vm(rvv_sp_vopmask x, vmask y) { + rvv_vmask32 y32 = SLEEF_RVV_SP_VREINTERPRET_VM(y); + return SLEEF_RVV_DP_VREINTERPRET_VM(__riscv_vmerge(y32, 0, __riscv_vmnot(x, VECTLENSP), VECTLENSP)); +} +static INLINE vmask vandnot_vm_vo32_vm(rvv_sp_vopmask x, vmask y) { + rvv_vmask32 y32 = SLEEF_RVV_SP_VREINTERPRET_VM(y); + return SLEEF_RVV_DP_VREINTERPRET_VM(__riscv_vmerge(y32, 0, x, VECTLENSP)); +} + + +/****************************************/ +/* Logical Mask Operations */ +/****************************************/ +static INLINE rvv_sp_vopmask rvv_sp_vand_vo_vo_vo(rvv_sp_vopmask x, rvv_sp_vopmask y) { + return __riscv_vmand(x, y, VECTLENSP); +} +static INLINE rvv_sp_vopmask rvv_sp_vandnot_vo_vo_vo(rvv_sp_vopmask x, rvv_sp_vopmask y) { + return __riscv_vmandn(y, x, VECTLENSP); +} +static INLINE rvv_sp_vopmask rvv_sp_vor_vo_vo_vo(rvv_sp_vopmask x, rvv_sp_vopmask y) { + return __riscv_vmor(x, y, VECTLENSP); +} +static INLINE rvv_sp_vopmask rvv_sp_vxor_vo_vo_vo(rvv_sp_vopmask x, rvv_sp_vopmask y) { + return __riscv_vmxor(x, y, VECTLENSP); +} +// single precision FP comparison +static INLINE rvv_sp_vopmask veq_vo_vf_vf(vfloat x, vfloat y) { + return __riscv_vmfeq(x, y, VECTLENSP); +} +static INLINE rvv_sp_vopmask vneq_vo_vf_vf(vfloat x, vfloat y) { + return __riscv_vmfne(x, y, VECTLENSP); +} +static INLINE rvv_sp_vopmask vgt_vo_vf_vf(vfloat x, vfloat y) { + return __riscv_vmfgt(x, y, VECTLENSP); +} +static INLINE rvv_sp_vopmask vge_vo_vf_vf(vfloat x, vfloat y) { + return __riscv_vmfge(x, y, VECTLENSP); +} +static INLINE rvv_sp_vopmask vlt_vo_vf_vf(vfloat x, vfloat y) { + return __riscv_vmflt(x, y, VECTLENSP); +} +static INLINE rvv_sp_vopmask vle_vo_vf_vf(vfloat x, vfloat y) { + return __riscv_vmfle(x, y, VECTLENSP); +} +static INLINE rvv_sp_vopmask visnan_vo_vf(vfloat d) { + return __riscv_vmfne(d, d, VECTLENSP); +} +static INLINE rvv_sp_vopmask visinf_vo_vf(vfloat d) { + return __riscv_vmfeq(__riscv_vfabs(d, VECTLENSP), SLEEF_INFINITYf, VECTLENSP); +} +static INLINE rvv_sp_vopmask vispinf_vo_vf(vfloat d) { + return __riscv_vmfeq(d, SLEEF_INFINITYf, VECTLENSP); +} +// conditional select +static INLINE vfloat vsel_vf_vo_vf_vf(rvv_sp_vopmask mask, vfloat x, vfloat y) { + return __riscv_vmerge(y, x, mask, VECTLENSP); +} +static INLINE vfloat vsel_vf_vo_f_f(rvv_sp_vopmask mask, float v1, float v0) { + return __riscv_vfmerge(vcast_vf_f(v0), v1, mask, VECTLENSP); +} +static INLINE vfloat vsel_vf_vo_vo_f_f_f(rvv_sp_vopmask o0, rvv_sp_vopmask o1, float d0, float d1, float d2) { + return __riscv_vfmerge(__riscv_vfmerge(vcast_vf_f(d2), d1, o1, VECTLENSP), d0, o0, VECTLENSP); +} +static INLINE vfloat vsel_vf_vo_vo_vo_f_f_f_f(rvv_sp_vopmask o0, rvv_sp_vopmask o1, rvv_sp_vopmask o2, float d0, float d1, float d2, float d3) { + return __riscv_vfmerge(__riscv_vfmerge(__riscv_vfmerge(vcast_vf_f(d3), d2, o2, VECTLENSP), d1, o1, VECTLENSP), d0, o0, VECTLENSP); +} +// integer comparison +static INLINE rvv_sp_vopmask veq_vo_vi2_vi2(vint2 x, vint2 y) { + return __riscv_vmseq(x, y, VECTLENSP); +} +static INLINE rvv_sp_vopmask vgt_vo_vi2_vi2(vint2 x, vint2 y) { + return __riscv_vmsgt(x, y, VECTLENSP); +} +static INLINE vint2 vgt_vi2_vi2_vi2(vint2 x, vint2 y) { + vint2 zero = vcast_vi2_i(0); + return __riscv_vmerge(zero, -1, __riscv_vmsgt(x, y, VECTLENSP), VECTLENSP); +} +// integer conditional select +static INLINE vint2 vsel_vi2_vo_vi2_vi2(rvv_sp_vopmask m, vint2 x, vint2 y) { + return __riscv_vmerge(y, x, m, VECTLENSP); +} +static INLINE vint2 vand_vi2_vo_vi2(rvv_sp_vopmask x, vint2 y) { + return __riscv_vmerge(y, 0, __riscv_vmnot(x, VECTLENSP), VECTLENSP); +} + + +//////////////////////////////////////////////////////////////////////////////// +// Double-Precision Functions +//////////////////////////////////////////////////////////////////////////////// + +/****************************************/ +/* Multi-value and multi-word types */ +/****************************************/ +// vdouble2 type +static INLINE const vdouble vd2getx_vd_vd2(vdouble2 v) { + return SLEEF_RVV_DP_VGET_VD(v, 0); +} +static INLINE const vdouble vd2gety_vd_vd2(vdouble2 v) { + return SLEEF_RVV_DP_VGET_VD(v, 1); +} +static INLINE const vdouble2 vd2setxy_vd2_vd_vd(vdouble x, vdouble y) { + return SLEEF_RVV_DP_VCREATE_VD2(x, y); +} +static INLINE const vdouble2 vd2setx_vd2_vd2_vd(vdouble2 v, vdouble d) { + return __riscv_vset(v, 0, d); +} +static INLINE const vdouble2 vd2sety_vd2_vd2_vd(vdouble2 v, vdouble d) { + return __riscv_vset(v, 1, d); +} +// dd2 type +static dd2 dd2setab_dd2_vd2_vd2(vdouble2 a, vdouble2 b) { + return SLEEF_RVV_DP_VCREATE_4VD(a, b); +} +static vdouble2 dd2geta_vd2_dd2(dd2 d) { return SLEEF_RVV_DP_VGET_4VD(d, 0); } +static vdouble2 dd2getb_vd2_dd2(dd2 d) { return SLEEF_RVV_DP_VGET_4VD(d, 1); } +// vdouble3 type +static INLINE vdouble vd3getx_vd_vd3(vdouble3 v) { return SLEEF_RVV_DP_VGET_VD(v, 0); } +static INLINE vdouble vd3gety_vd_vd3(vdouble3 v) { return SLEEF_RVV_DP_VGET_VD(v, 1); } +static INLINE vdouble vd3getz_vd_vd3(vdouble3 v) { return SLEEF_RVV_DP_VGET_VD(v, 2); } +static INLINE vdouble3 vd3setxyz_vd3_vd_vd_vd(vdouble x, vdouble y, vdouble z) { + return SLEEF_RVV_DP_VCREATE_3VD(x, y, z); +} +static INLINE vdouble3 vd3setx_vd3_vd3_vd(vdouble3 v, vdouble d) { return __riscv_vset(v, 0, d); } +static INLINE vdouble3 vd3sety_vd3_vd3_vd(vdouble3 v, vdouble d) { return __riscv_vset(v, 1, d); } +static INLINE vdouble3 vd3setz_vd3_vd3_vd(vdouble3 v, vdouble d) { return __riscv_vset(v, 2, d); } +// di type +static INLINE vdouble digetd_vd_di(di_t d) { + vint2 vi = SLEEF_RVV_DP_VGET_VI2(d, 0); + return SLEEF_RVV_DP_VREINTERPRET_VD(vi); +} +static INLINE vint digeti_vi_di(di_t d) { + vint2 vi = SLEEF_RVV_DP_VGET_VI2(d, 1); + return SLEEF_RVV_DP_VLMUL_TRUNC_VI2_TO_VI(vi); +} +static INLINE di_t disetdi_di_vd_vi(vdouble d, vint i) { + vint2 vd = SLEEF_RVV_DP_VREINTERPRET_VI2(d); + vint2 vi = SLEEF_RVV_DP_VLMUL_EXT_VI_TO_VI2(i); + return SLEEF_RVV_DP_VCREATE_DI(vd, vi); +} +// ddi type +static INLINE vdouble2 ddigetdd_vd2_ddi(ddi_t d) { + return SLEEF_RVV_DP_VGET_VD2(SLEEF_RVV_DP_VREINTERPRET_4VD_8VI(d), 0); +} +static INLINE vint ddigeti_vi_ddi(ddi_t d) { + vint2 vi2 = SLEEF_RVV_DP_VGET_VI2(d, 2); + return SLEEF_RVV_DP_VLMUL_TRUNC_VI2_TO_VI(vi2); +} +static INLINE ddi_t ddisetddi_ddi_vd2_vi(vdouble2 v, vint i) { + di_t vdi = SLEEF_RVV_DP_VREINTERPRET_4VI(v); + return SLEEF_RVV_DP_VCREATE_DDI(vdi, i); +} +static INLINE ddi_t ddisetdd_ddi_ddi_vd2(ddi_t ddi, vdouble2 v) { + di_t vdi = SLEEF_RVV_DP_VREINTERPRET_4VI(v); + return __riscv_vset(ddi, 0, vdi); +} + +/****************************************/ +/* Type Conversions and Broadcasts */ +/****************************************/ +static INLINE vdouble vcast_vd_d(double d) { + return SLEEF_RVV_DP_VCAST_VD_D(d, VECTLENDP); +} +static INLINE vdouble vcast_vd_vi(vint i) { + return SLEEF_RVV_DP_VCAST_VD_VI(i); +} +static INLINE vint vcast_vi_i(int32_t i) { + return SLEEF_RVV_DP_VCAST_VI_I(i, VECTLENDP); +} +static INLINE vint vrint_vi_vd(vdouble vd) { + return SLEEF_RVV_DP_VFNCVT_X_F_VI(vd, __RISCV_FRM_RNE, VECTLENDP); +} +static INLINE vdouble vrint_vd_vd(vdouble vd) { + return SLEEF_RVV_DP_VFCVT_F_X_VD(SLEEF_RVV_DP_VFCVT_X_F_VD_RM(vd, __RISCV_FRM_RNE, VECTLENDP), VECTLENDP); +} +static INLINE vint vtruncate_vi_vd(vdouble vd) { + return __riscv_vfncvt_rtz_x(vd, VECTLENDP); +} +static INLINE vdouble vtruncate_vd_vd(vdouble vd) { + return vcast_vd_vi(vtruncate_vi_vd(vd)); +} + + +/****************************************/ +/* Memory Operations */ +/****************************************/ +static INLINE vdouble vload_vd_p(const double *ptr) { + return SLEEF_RVV_DP_LOAD_VD(ptr, VECTLENDP); +} +static INLINE vdouble vloadu_vd_p(const double *ptr) { + return SLEEF_RVV_DP_LOAD_VD(ptr, VECTLENDP); +} +static INLINE vint vloadu_vi_p(int32_t *p) { + return SLEEF_RVV_DP_LOAD_VI(p, VECTLENDP); +} +static INLINE void vstore_v_p_vd(double *ptr, vdouble v) { + __riscv_vse64(ptr, v, VECTLENDP); +} +static INLINE void vstoreu_v_p_vd(double *ptr, vdouble v) { + __riscv_vse64(ptr, v, VECTLENDP); +} +static INLINE void vstoreu_v_p_vi(int32_t *ptr, vint v) { + __riscv_vse32(ptr, v, VECTLENDP); +} +static INLINE vdouble vgather_vd_p_vi(const double *ptr, vint vi) { + return __riscv_vluxei64(ptr, __riscv_vwmulu(SLEEF_RVV_DP_VREINTERPRET_VU(vi), sizeof(double), VECTLENDP), VECTLENDP); +} + + +/****************************************/ +/* Floating-Point Arithmetic */ +/****************************************/ +static INLINE vdouble vadd_vd_vd_vd(vdouble x, vdouble y) { + return __riscv_vfadd(x, y, VECTLENDP); +} +static INLINE vdouble vsub_vd_vd_vd(vdouble x, vdouble y) { + return __riscv_vfsub(x, y, VECTLENDP); +} +static INLINE vdouble vrec_vd_vd(vdouble d) { + return __riscv_vfdiv(vcast_vd_d(1.0), d, VECTLENDP); +} +static INLINE vdouble vabs_vd_vd(vdouble d) { + return __riscv_vfabs(d, VECTLENDP); +} +static INLINE vdouble vsqrt_vd_vd(vdouble d) { + return __riscv_vfsqrt(d, VECTLENDP); +} +static INLINE vdouble vmul_vd_vd_vd(vdouble x, vdouble y) { + return __riscv_vfmul(x, y, VECTLENDP); +} +static INLINE vdouble vdiv_vd_vd_vd(vdouble x, vdouble y) { + return __riscv_vfdiv(x, y, VECTLENDP); +} +static INLINE vdouble vmax_vd_vd_vd(vdouble x, vdouble y) { + return __riscv_vfmax(x, y, VECTLENDP); +} +static INLINE vdouble vmin_vd_vd_vd(vdouble x, vdouble y) { + return __riscv_vfmin(x, y, VECTLENDP); +} +#if defined(ENABLE_FMA_DP) +// Multiply accumulate: z = z + x * y +static INLINE vdouble vmla_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { + return __riscv_vfmadd(x, y, z, VECTLENDP); +} +// Multiply subtract: z = x * y - z +static INLINE vdouble vmlapn_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { + return __riscv_vfmsub(x, y, z, VECTLENDP); +} +// z = z - x * y +static INLINE vdouble vmlanp_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { + return __riscv_vfnmsac(z, x, y, VECTLENDP); +} +#else +static INLINE vdouble vmla_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return vadd_vd_vd_vd(vmul_vd_vd_vd(x, y), z); } +static INLINE vdouble vmlapn_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return vsub_vd_vd_vd(vmul_vd_vd_vd(x, y), z); } +static INLINE vdouble vmlanp_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return vsub_vd_vd_vd(z, vmul_vd_vd_vd(x, y)); } +#endif +// fused multiply add / sub +static INLINE vdouble vfma_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { + return __riscv_vfmadd(x, y, z, VECTLENDP); +} +static INLINE vdouble vfmanp_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { + return __riscv_vfnmsub(x, y, z, VECTLENDP); +} +static INLINE vdouble vfmapn_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { + return __riscv_vfmsub(x, y, z, VECTLENDP); +} +// sign manipulation +static INLINE vdouble vmulsign_vd_vd_vd(vdouble x, vdouble y) { + return __riscv_vfsgnjx(x, y, VECTLENDP); +} +static INLINE vdouble vcopysign_vd_vd_vd(vdouble x, vdouble y) { + return __riscv_vfsgnj(x, y, VECTLENDP); +} +static INLINE vdouble vorsign_vd_vd_vd(vdouble x, vdouble y) { + return __riscv_vfsgnj(x, SLEEF_RVV_DP_VREINTERPRET_VD(__riscv_vor(SLEEF_RVV_DP_VREINTERPRET_VM(x), SLEEF_RVV_DP_VREINTERPRET_VM(y), VECTLENDP)), VECTLENDP); +} +static INLINE vdouble vneg_vd_vd(vdouble d) { + return __riscv_vfneg(d, VECTLENDP); +} + + +/****************************************/ +/* Integer Arithmetic and Logic */ +/****************************************/ +static INLINE vint vadd_vi_vi_vi(vint x, vint y) { + return __riscv_vadd(x, y, VECTLENDP); +} +static INLINE vint vsub_vi_vi_vi(vint x, vint y) { + return __riscv_vsub(x, y, VECTLENDP); +} +static INLINE vint vneg_vi_vi(vint x) { + return __riscv_vneg(x, VECTLENDP); +} +static INLINE vint vand_vi_vi_vi(vint x, vint y) { + return __riscv_vand(x, y, VECTLENDP); +} +static INLINE vint vandnot_vi_vi_vi(vint x, vint y) { + return __riscv_vand(__riscv_vnot(x, VECTLENDP), y, VECTLENDP); +} +static INLINE vint vor_vi_vi_vi(vint x, vint y) { + return __riscv_vor(x, y, VECTLENDP); +} +static INLINE vint vxor_vi_vi_vi(vint x, vint y) { + return __riscv_vxor(x, y, VECTLENDP); +} +static INLINE vint vsll_vi_vi_i(vint x, int c) { + return __riscv_vsll(x, c, VECTLENDP); +} +static INLINE vint vsra_vi_vi_i(vint x, int c) { + return __riscv_vsra(x, c, VECTLENDP); +} +static INLINE vint vsrl_vi_vi_i(vint x, int c) { + return SLEEF_RVV_DP_VREINTERPRET_VI(__riscv_vsrl(SLEEF_RVV_DP_VREINTERPRET_VU(x), c, VECTLENDP)); +} + + +/****************************************/ +/* Bitmask Operations */ +/****************************************/ +static INLINE vmask vcast_vm_i64(int64_t c) { + return SLEEF_RVV_DP_VCAST_VM_U(c, VECTLENDP); +} +static INLINE vmask vcast_vm_u64(uint64_t c) { + return SLEEF_RVV_DP_VCAST_VM_U(c, VECTLENDP); +} +static INLINE vmask vcast_vm_i_i(int64_t h, int64_t l) { + return SLEEF_RVV_DP_VCAST_VM_U((((uint64_t)h) << 32) | (uint32_t) l, VECTLENDP); +} +static INLINE vmask vcast_vm_vi(vint vi) { + return SLEEF_RVV_DP_VREINTERPRET_VM(__riscv_vwcvt_x(vi, VECTLENDP)); +} +static INLINE vmask vcastu_vm_vi(vint vi) { + return __riscv_vsll(SLEEF_RVV_DP_VREINTERPRET_VM(__riscv_vwcvt_x(vi, VECTLENDP)), 32, VECTLENDP); +} +static INLINE vint vcastu_vi_vm(vmask vm) { + return SLEEF_RVV_DP_VREINTERPRET_VI(__riscv_vnsrl(vm, 32, VECTLENDP)); +} +static INLINE vint vcast_vi_vm(vmask vm) { + return SLEEF_RVV_DP_VREINTERPRET_VI(__riscv_vncvt_x(vm, VECTLENDP)); +} + +// These are the complementary case to the earlier comment about +// rvv_sp_vopmask. +// +static INLINE vmask vand_vm_vo64_vm(rvv_dp_vopmask x, vmask y) { + return __riscv_vmerge(y, 0, __riscv_vmnot(x, VECTLENDP), VECTLENDP); +} +static INLINE vmask vand_vm_vm_vm(vmask x, vmask y) { + return __riscv_vand(x, y, VECTLENDP); +} +static INLINE vmask vor_vm_vm_vm(vmask x, vmask y) { + return __riscv_vor(x, y, VECTLENDP); +} +static INLINE vmask vxor_vm_vm_vm(vmask x, vmask y) { + return __riscv_vxor(x, y, VECTLENDP); +} +static INLINE vmask vandnot_vm_vm_vm(vmask x, vmask y) { + return __riscv_vand(__riscv_vnot(x, VECTLENDP), y, VECTLENDP); +} +static INLINE vmask vandnot_vm_vo64_vm(rvv_dp_vopmask x, vmask y) { + return __riscv_vmerge(y, 0, x, VECTLENDP); +} +static INLINE vmask vsll64_vm_vm_i(vmask mask, int64_t c) { + return __riscv_vsll(mask, c, VECTLENDP); +} +static INLINE vmask vsub64_vm_vm_vm(vmask x, vmask y) { + return __riscv_vsub(x, y, VECTLENDP); +} +static INLINE vmask vsrl64_vm_vm_i(vmask mask, int64_t c) { + return __riscv_vsrl(mask, c, VECTLENDP); +} +static INLINE vmask vadd64_vm_vm_vm(vmask x, vmask y) { + return __riscv_vadd(x, y, VECTLENDP); +} +static INLINE vmask vor_vm_vo64_vm(rvv_dp_vopmask x, vmask y) { + return __riscv_vmerge(y, -1, x, VECTLENDP); +} +static INLINE vmask vsel_vm_vo64_vm_vm(rvv_dp_vopmask mask, vmask x, vmask y) { + return __riscv_vmerge(y, x, mask, VECTLENDP); +} +static INLINE vmask vneg64_vm_vm(vmask mask) { + return SLEEF_RVV_DP_VREINTERPRET_VM(__riscv_vneg(SLEEF_RVV_DP_VREINTERPRET_VM_SIGNED(mask), VECTLENDP)); +} +static INLINE vdouble vreinterpret_vd_vm(vmask vm) { + return SLEEF_RVV_DP_VREINTERPRET_VD(vm); +} +static INLINE vmask vreinterpret_vm_vd(vdouble vd) { + return SLEEF_RVV_DP_VREINTERPRET_VM(vd); +} + +// vquad type +static INLINE const vmask vqgetx_vm_vq(vquad v) { return SLEEF_RVV_DP_VGET_VM(v, 0); } +static INLINE const vmask vqgety_vm_vq(vquad v) { return SLEEF_RVV_DP_VGET_VM(v, 1); } +static INLINE vquad vqsetxy_vq_vm_vm(vmask x, vmask y) { + return SLEEF_RVV_DP_VCREATE_VQ(x, y); +} +static INLINE vquad vqsetx_vq_vq_vm(vquad v, vmask x) { return __riscv_vset(v, 0, x); } +static INLINE vquad vqsety_vq_vq_vm(vquad v, vmask y) { return __riscv_vset(v, 1, y); } + + +/****************************************/ +/* Logical Mask Operations */ +/****************************************/ +static INLINE rvv_dp_vopmask vcast_vo64_vo32(rvv_dp_vopmask vo) { + return vo; +} +static INLINE rvv_dp_vopmask vcast_vo32_vo64(rvv_dp_vopmask vo) { + return vo; +} +static INLINE rvv_dp_vopmask rvv_dp_vand_vo_vo_vo(rvv_dp_vopmask x, rvv_dp_vopmask y) { + return __riscv_vmand(x, y, VECTLENDP); +} +static INLINE rvv_dp_vopmask rvv_dp_vandnot_vo_vo_vo(rvv_dp_vopmask x, rvv_dp_vopmask y) { + return __riscv_vmandn(y, x, VECTLENDP); +} +static INLINE rvv_dp_vopmask rvv_dp_vor_vo_vo_vo(rvv_dp_vopmask x, rvv_dp_vopmask y) { + return __riscv_vmor(x, y, VECTLENDP); +} +static INLINE rvv_dp_vopmask rvv_dp_vxor_vo_vo_vo(rvv_dp_vopmask x, rvv_dp_vopmask y) { + return __riscv_vmxor(x, y, VECTLENDP); +} +static INLINE rvv_dp_vopmask veq64_vo_vm_vm(vmask x, vmask y) { + return __riscv_vmseq(x, y, VECTLENDP); +} +static INLINE rvv_dp_vopmask vgt64_vo_vm_vm(vmask x, vmask y) { + return __riscv_vmsgt(SLEEF_RVV_DP_VREINTERPRET_VM_SIGNED(x), SLEEF_RVV_DP_VREINTERPRET_VM_SIGNED(y), VECTLENDP); +} +// double-precision comparison +static INLINE rvv_dp_vopmask visinf_vo_vd(vdouble d) { + return __riscv_vmfeq(__riscv_vfabs(d, VECTLENDP), SLEEF_INFINITY, VECTLENDP); +} +static INLINE rvv_dp_vopmask vispinf_vo_vd(vdouble d) { + return __riscv_vmfeq(d, SLEEF_INFINITY, VECTLENDP); +} +static INLINE rvv_dp_vopmask veq_vo_vd_vd(vdouble x, vdouble y) { + return __riscv_vmfeq(x, y, VECTLENDP); +} +static INLINE rvv_dp_vopmask vneq_vo_vd_vd(vdouble x, vdouble y) { + return __riscv_vmfne(x, y, VECTLENDP); +} +static INLINE rvv_dp_vopmask vlt_vo_vd_vd(vdouble x, vdouble y) { + return __riscv_vmflt(x, y, VECTLENDP); +} +static INLINE rvv_dp_vopmask vle_vo_vd_vd(vdouble x, vdouble y) { + return __riscv_vmfle(x, y, VECTLENDP); +} +static INLINE rvv_dp_vopmask vgt_vo_vd_vd(vdouble x, vdouble y) { + return __riscv_vmfgt(x, y, VECTLENDP); +} +static INLINE rvv_dp_vopmask vge_vo_vd_vd(vdouble x, vdouble y) { + return __riscv_vmfge(x, y, VECTLENDP); +} +static INLINE rvv_dp_vopmask visnan_vo_vd(vdouble d) { + return __riscv_vmfne(d, d, VECTLENDP); +} +// double-precision conditional select +static INLINE vdouble vsel_vd_vo_vd_vd(rvv_dp_vopmask mask, vdouble x, vdouble y) { + return __riscv_vmerge(y, x, mask, VECTLENDP); +} +static INLINE vdouble vsel_vd_vo_d_d(rvv_dp_vopmask mask, double v0, double v1) { + return __riscv_vfmerge(vcast_vd_d(v1), v0, mask, VECTLENDP); +} +static INLINE vdouble vsel_vd_vo_vo_d_d_d(rvv_dp_vopmask o0, rvv_dp_vopmask o1, double d0, double d1, double d2) { + return __riscv_vfmerge(__riscv_vfmerge(vcast_vd_d(d2), d1, o1, VECTLENDP), d0, o0, VECTLENDP); +} +static INLINE vdouble vsel_vd_vo_vo_vo_d_d_d_d(rvv_dp_vopmask o0, rvv_dp_vopmask o1, rvv_dp_vopmask o2, double d0, double d1, double d2, double d3) { + return __riscv_vfmerge(__riscv_vfmerge(__riscv_vfmerge(vcast_vd_d(d3), d2, o2, VECTLENDP), d1, o1, VECTLENDP), d0, o0, VECTLENDP); +} +static INLINE int vtestallones_i_vo64(rvv_dp_vopmask g) { + return __riscv_vcpop(g, VECTLENDP) == VECTLENDP; +} +// integer comparison +static INLINE rvv_dp_vopmask veq_vo_vi_vi(vint x, vint y) { + return __riscv_vmseq(x, y, VECTLENDP); +} +static INLINE rvv_dp_vopmask vgt_vo_vi_vi(vint x, vint y) { + return __riscv_vmsgt(x, y, VECTLENDP); +} +static INLINE vint vgt_vi_vi_vi(vint x, vint y) { + vint zero = vcast_vi_i(0); + return __riscv_vmerge(zero, -1, __riscv_vmsgt(x, y, VECTLENDP), VECTLENDP); +} +// integer conditional select +static INLINE vint vsel_vi_vo_vi_vi(rvv_dp_vopmask m, vint x, vint y) { + return __riscv_vmerge(y, x, m, VECTLENDP); +} +static INLINE vint vandnot_vi_vo_vi(rvv_dp_vopmask mask, vint vi) { + return __riscv_vmerge(vi, 0, mask, VECTLENDP); +} +static INLINE vint vand_vi_vo_vi(rvv_dp_vopmask x, vint y) { + return __riscv_vmerge(y, 0, __riscv_vmnot(x, VECTLENDP), VECTLENDP); +} + +/****************************************/ +/* DFT Operations */ +/****************************************/ + +static INLINE vdouble vposneg_vd_vd(vdouble d) { + rvv_dp_vopmask mask = SLEEF_RVV_DP_VREINTERPRET_VOM(__riscv_vmv_v_x_u8m1(0x55, __riscv_vsetvlmax_e8m1())); + vdouble nd = __riscv_vfneg(d, VECTLENDP); + return __riscv_vmerge(nd, d, mask, VECTLENDP); +} + +static INLINE vdouble vnegpos_vd_vd(vdouble d) { + rvv_dp_vopmask mask = SLEEF_RVV_DP_VREINTERPRET_VOM(__riscv_vmv_v_x_u8m1(0xaa, __riscv_vsetvlmax_e8m1())); + vdouble nd = __riscv_vfneg(d, VECTLENDP); + return __riscv_vmerge(nd, d, mask, VECTLENDP); +} + +static INLINE vfloat vposneg_vf_vf(vfloat d) { + rvv_sp_vopmask mask = SLEEF_RVV_SP_VREINTERPRET_VOM(__riscv_vmv_v_x_u8m1(0x55, __riscv_vsetvlmax_e8m1())); + vfloat nd = __riscv_vfneg(d, VECTLENSP); + return __riscv_vmerge(nd, d, mask, VECTLENSP); +} + +static INLINE vfloat vnegpos_vf_vf(vfloat d) { + rvv_sp_vopmask mask = SLEEF_RVV_SP_VREINTERPRET_VOM(__riscv_vmv_v_x_u8m1(0xaa, __riscv_vsetvlmax_e8m1())); + vfloat nd = __riscv_vfneg(d, VECTLENSP); + return __riscv_vmerge(nd, d, mask, VECTLENSP); +} + +static INLINE vdouble vsubadd_vd_vd_vd(vdouble x, vdouble y) { return vadd_vd_vd_vd(x, vnegpos_vd_vd(y)); } +static INLINE vfloat vsubadd_vf_vf_vf(vfloat d0, vfloat d1) { return vadd_vf_vf_vf(d0, vnegpos_vf_vf(d1)); } +static INLINE vdouble vmlsubadd_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return vfma_vd_vd_vd_vd(x, y, vnegpos_vd_vd(z)); } +static INLINE vfloat vmlsubadd_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return vfma_vf_vf_vf_vf(x, y, vnegpos_vf_vf(z)); } + +// + +static INLINE vdouble vrev21_vd_vd(vdouble vd) { + rvv_dp_vuint2 id = SLEEF_RVV_DP_VID(); + id = __riscv_vxor(id, 1, VECTLENDP); + return __riscv_vrgather(vd, id, VECTLENDP); +} + +static INLINE vfloat vrev21_vf_vf(vfloat vf) { + vint2 id = SLEEF_RVV_SP_VREINTERPRET_VI2(SLEEF_RVV_SP_VID()); + id = __riscv_vxor(id, 1, VECTLENSP); + return __riscv_vrgather(vf, SLEEF_RVV_SP_VREINTERPRET_VU2(id), VECTLENSP); +} + +static INLINE vdouble vreva2_vd_vd(vdouble vd) { + rvv_dp_vuint2 id = SLEEF_RVV_DP_VID(); + id = __riscv_vxor(id, VECTLENDP - 2, VECTLENDP); + return __riscv_vrgather(vd, id, VECTLENDP); +} + +static INLINE vfloat vreva2_vf_vf(vfloat vf) { + vint2 id = SLEEF_RVV_SP_VREINTERPRET_VI2(SLEEF_RVV_SP_VID()); + id = __riscv_vxor(id, VECTLENSP - 2, VECTLENSP); + return __riscv_vrgather(vf, SLEEF_RVV_SP_VREINTERPRET_VU2(id), VECTLENSP); +} + +// + +static INLINE void vscatter2_v_p_i_i_vd(double *ptr, int offset, int step, vdouble v) { + // Address generation for this operation turned out to be overly complex when + // you consider that the loop processes 128 bits per iteration and will + // probably only iterate 2 or 4 times. + // + ptr += offset * 2; + for (int i = 0; i < VECTLENDP; i += 2) { + // PROTIP: Avoid modifying `v` within the loop, and just extract the useful + // part directly in each iteration, because we can. This avoids a + // loop-carried dependency. + // + vdouble vv = __riscv_vslidedown(v, i, 2); + __riscv_vse64(ptr, vv, 2); + ptr += step * 2; + } +} + +static INLINE void vscatter2_v_p_i_i_vf(float *ptr, int offset, int step, vfloat v) { + // as above re: looping + ptr += offset * 2; + for (int i = 0; i < VECTLENSP; i += 2) { + vfloat vv = __riscv_vslidedown(v, i, 2); + __riscv_vse32(ptr, vv, 2); + ptr += step * 2; + } +} + + +/****************************************/ +/* Quad Operations */ +/****************************************/ + + +static INLINE vmask tdxgete_vm_tdx(tdx t) { + return SLEEF_RVV_DP_VREINTERPRET_VM(SLEEF_RVV_DP_VGET_VD(t, 0)); +} +static INLINE vdouble tdxgetd3x_vd_tdx(tdx t) { + return SLEEF_RVV_DP_VGET_VD(t, 1); +} +static INLINE vdouble tdxgetd3y_vd_tdx(tdx t) { + return SLEEF_RVV_DP_VGET_VD(t, 2); +} +static INLINE vdouble tdxgetd3z_vd_tdx(tdx t) { + return SLEEF_RVV_DP_VGET_VD(t, 3); +} +static INLINE tdx tdxsete_tdx_tdx_vm(tdx t, vmask e) { + return __riscv_vset(t, 0, SLEEF_RVV_DP_VREINTERPRET_VD(e)); +} +static INLINE tdx tdxsetx_tdx_tdx_vd(tdx t, vdouble x) { + return __riscv_vset(t, 1, x); +} +static INLINE tdx tdxsety_tdx_tdx_vd(tdx t, vdouble y) { + return __riscv_vset(t, 2, y); +} +static INLINE tdx tdxsetz_tdx_tdx_vd(tdx t, vdouble z) { + return __riscv_vset(t, 3, z); +} + +static INLINE vdouble3 tdxgetd3_vd3_tdx(tdx t) { + return vd3setxyz_vd3_vd_vd_vd(tdxgetd3x_vd_tdx(t), tdxgetd3y_vd_tdx(t), tdxgetd3z_vd_tdx(t)); +} + +static INLINE tdx tdxsetxyz_tdx_tdx_vd_vd_vd(tdx t, vdouble x, vdouble y, vdouble z) { + t = tdxsetx_tdx_tdx_vd(t, x); + t = tdxsety_tdx_tdx_vd(t, y); + t = tdxsetz_tdx_tdx_vd(t, z); + return t; +} +static INLINE tdx tdxsetd3_tdx_tdx_vd3(tdx t, vdouble3 d3) { + return tdxsetxyz_tdx_tdx_vd_vd_vd(t, vd3getx_vd_vd3(d3), vd3gety_vd_vd3(d3), vd3getz_vd_vd3(d3)); +} + +static INLINE tdx tdxseted3_tdx_vm_vd3(vmask e, vdouble3 d3) { + return SLEEF_RVV_DP_VCREATE_TD(SLEEF_RVV_DP_VREINTERPRET_VD(e), + vd3getx_vd_vd3(d3), vd3gety_vd_vd3(d3), vd3getz_vd_vd3(d3)); +} +static INLINE tdx tdxsetexyz_tdx_vm_vd_vd_vd(vmask e, vdouble x, vdouble y, vdouble z) { + return SLEEF_RVV_DP_VCREATE_TD(SLEEF_RVV_DP_VREINTERPRET_VD(e), x, y, z); +} + +static INLINE vdouble tdigetx_vd_tdi(tdi_t d) { + return SLEEF_RVV_DP_VGET_VD(d, 0); +} +static INLINE vdouble tdigety_vd_tdi(tdi_t d) { + return SLEEF_RVV_DP_VGET_VD(d, 1); +} +static INLINE vdouble tdigetz_vd_tdi(tdi_t d) { + return SLEEF_RVV_DP_VGET_VD(d, 2); +} + +static INLINE vint tdigeti_vi_tdi(tdi_t d) { + vdouble vd = SLEEF_RVV_DP_VGET_VD(d, 3); + vint2 vi2 = SLEEF_RVV_DP_VREINTERPRET_VI2(vd); + vint vi = SLEEF_RVV_DP_VLMUL_TRUNC_VI2_TO_VI(vi2); + return vi; +} +static INLINE tdi_t tdisetx_tdi_tdi_vd(tdi_t t, vdouble x) { + return __riscv_vset(t, 0, x); +} +static INLINE tdi_t tdisety_tdi_tdi_vd(tdi_t t, vdouble y) { + return __riscv_vset(t, 1, y); +} +static INLINE tdi_t tdisetz_tdi_tdi_vd(tdi_t t, vdouble z) { + return __riscv_vset(t, 2, z); +} +static INLINE tdi_t tdiseti_tdi_tdi_vi(tdi_t t, vint i) { + vint2 vi2 = SLEEF_RVV_DP_VLMUL_EXT_VI_TO_VI2(i); + vdouble vd = SLEEF_RVV_DP_VREINTERPRET_VD(vi2); + return __riscv_vset(t, 3, vd); +} + +static INLINE vdouble3 tdigettd_vd3_tdi(tdi_t d) { + return vd3setxyz_vd3_vd_vd_vd(tdigetx_vd_tdi(d), tdigety_vd_tdi(d), tdigetz_vd_tdi(d)); +} +static INLINE tdi_t tdisettd_tdi_tdi_vd3(tdi_t tdi, vdouble3 v) { + tdi = tdisetx_tdi_tdi_vd(tdi, vd3getx_vd_vd3(v)); + tdi = tdisety_tdi_tdi_vd(tdi, vd3gety_vd_vd3(v)); + tdi = tdisetz_tdi_tdi_vd(tdi, vd3getz_vd_vd3(v)); + return tdi; +} +static INLINE tdi_t tdisettdi_tdi_vd3_vi(vdouble3 v, vint i) { + tdi_t ret = SLEEF_RVV_DP_VCREATE_TD(vd3getx_vd_vd3(v), vd3gety_vd_vd3(v), vd3getz_vd_vd3(v), vd3getz_vd_vd3(v)); + return tdiseti_tdi_tdi_vi(ret, i); +} + + +static INLINE rvv_dp_vopmask vcast_vo_i(int i) { + return SLEEF_RVV_DP_VREINTERPRET_VOM(__riscv_vmv_v_x_u32m1(i, VECTLENSP)); +} +static INLINE vmask vreinterpret_vm_vi64(vint64 v) { + return SLEEF_RVV_DP_VREINTERPRET_VM(v); +} +static INLINE vint64 vreinterpret_vi64_vm(vmask m) { + return SLEEF_RVV_DP_VREINTERPRET_VI64(m); +} +static INLINE vmask vreinterpret_vm_vu64(vuint64 v) { + return v; +} +static INLINE vuint64 vreinterpret_vu64_vm(vmask m) { + return m; +} +static INLINE int vtestallzeros_i_vo64(rvv_dp_vopmask g) { + return __riscv_vcpop(g, VECTLENDP) == 0; +} + + +static INLINE void vstream_v_p_vd(double *ptr, vdouble v) { vstore_v_p_vd(ptr, v); } +static INLINE void vstream_v_p_vf(float *ptr, vfloat v) { vstore_v_p_vf(ptr, v); } +static INLINE void vsscatter2_v_p_i_i_vd(double *ptr, int offset, int step, vdouble v) { vscatter2_v_p_i_i_vd(ptr, offset, step, v); } +static INLINE void vsscatter2_v_p_i_i_vf(float *ptr, int offset, int step, vfloat v) { vscatter2_v_p_i_i_vf(ptr, offset, step, v); } + +// These functions are for debugging +static double vcast_d_vd(vdouble v) { + return __riscv_vfmv_f(v); +} + +static float vcast_f_vf(vfloat v) { + return __riscv_vfmv_f(v); +} + +static int vcast_i_vi(vint v) { + return __riscv_vmv_x(v); +} + +static int vcast_i_vi2(vint2 v) { + return __riscv_vmv_x(v); +} + +// + +static vquad loadu_vq_p(const int32_t *ptr) { + // We have a lot of vreinterprets, here. It's a side effect of this being a + // corner case, and the intrinsics specification not supporting direct + // casting between arbitrary types. It's necessary to take several + // deliberate steps; first switching signed to unsigned, then changing the + // data width of the lanes. + // + return SLEEF_RVV_DP_VREINTERPRET_VQ(SLEEF_RVV_DP_VREINTERPRET_4VU(SLEEF_RVV_SP_LOAD_2VI(ptr, VECTLENSP * 2))); +} + +static INLINE vquad cast_vq_aq(vargquad aq) { return aq; } +static INLINE vargquad cast_aq_vq(vquad vq) { return vq; } + +static INLINE void vprefetch_v_p(const void *ptr) {} + + +/****************************************/ +/* RVV_SP and RVV_DP reconciliation */ +/****************************************/ + +// About the RISC-V Vector type translations: +// +// Because the single- and double-precision versions of the RVV port have +// conflicting definitions of the vopmask type, they can only +// be defined for at most one precision level in a single translation unit. +// Any functions that use vopmask type are thus given unique names and +// then mapped to the public interface according to the corresponding +// ENABLE_RVV_SP or ENABLE_RVV_DP macro guards. +// +// This is done at the end of the file to avoid unintentional references to +// the public names internally. + +#if defined(ENABLE_RVV_SP) && defined(ENABLE_RVV_DP) +#error Cannot simultaneously define ENABLE_RVV_SP and ENABLE_RVV_DP +#endif + +// Types and functions that conflict with ENABLE_RVV_DP +#ifdef ENABLE_RVV_SP +#define vopmask rvv_sp_vopmask + +#define vand_vo_vo_vo rvv_sp_vand_vo_vo_vo +#define vandnot_vo_vo_vo rvv_sp_vandnot_vo_vo_vo +#define vor_vo_vo_vo rvv_sp_vor_vo_vo_vo +#define vxor_vo_vo_vo rvv_sp_vxor_vo_vo_vo +#endif // ENABLE_RVV_SP + +//@#ifdef ENABLE_RVV_SP +//@#define vopmask rvv_sp_vopmask +// +//@#define vand_vo_vo_vo rvv_sp_vand_vo_vo_vo +//@#define vandnot_vo_vo_vo rvv_sp_vandnot_vo_vo_vo +//@#define vor_vo_vo_vo rvv_sp_vor_vo_vo_vo +//@#define vxor_vo_vo_vo rvv_sp_vxor_vo_vo_vo +//@#endif // ENABLE_RVV_SP + +// Types and functions that conflict with ENABLE_RVV_SP +#ifdef ENABLE_RVV_DP +#define vopmask rvv_dp_vopmask + +#define vand_vo_vo_vo rvv_dp_vand_vo_vo_vo +#define vandnot_vo_vo_vo rvv_dp_vandnot_vo_vo_vo +#define vor_vo_vo_vo rvv_dp_vor_vo_vo_vo +#define vxor_vo_vo_vo rvv_dp_vxor_vo_vo_vo +#endif // ENABLE_RVV_DP + +//@#ifdef ENABLE_RVV_DP +//@#define vopmask rvv_dp_vopmask +// +//@#define vand_vo_vo_vo rvv_dp_vand_vo_vo_vo +//@#define vandnot_vo_vo_vo rvv_dp_vandnot_vo_vo_vo +//@#define vor_vo_vo_vo rvv_dp_vor_vo_vo_vo +//@#define vxor_vo_vo_vo rvv_dp_vxor_vo_vo_vo +//@#endif // ENABLE_RVV_DP + +#endif // HELPERRVV_H diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/arch/helpers390x_128.h b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/arch/helpers390x_128.h new file mode 100644 index 00000000000..924f4eac144 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/arch/helpers390x_128.h @@ -0,0 +1,462 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#if CONFIG == 140 || CONFIG == 141 || CONFIG == 150 || CONFIG == 151 + +#if !defined(__VX__) && !defined(SLEEF_GENHEADER) +#error This helper is for IBM s390x. +#endif + +#if __ARCH__ < 12 && !defined(SLEEF_GENHEADER) +#error Please specify -march=z14 or higher. +#endif + +#else +#error CONFIG macro invalid or not defined +#endif + +#define ENABLE_DP +//@#define ENABLE_DP +#define LOG2VECTLENDP 1 +//@#define LOG2VECTLENDP 1 +#define VECTLENDP (1 << LOG2VECTLENDP) +//@#define VECTLENDP (1 << LOG2VECTLENDP) + +#define ENABLE_SP +//@#define ENABLE_SP +#define LOG2VECTLENSP (LOG2VECTLENDP+1) +//@#define LOG2VECTLENSP (LOG2VECTLENDP+1) +#define VECTLENSP (1 << LOG2VECTLENSP) +//@#define VECTLENSP (1 << LOG2VECTLENSP) + +#if CONFIG == 140 || CONFIG == 150 +#define ENABLE_FMA_DP +//@#define ENABLE_FMA_DP +#define ENABLE_FMA_SP +//@#define ENABLE_FMA_SP +#endif + +#define ACCURATE_SQRT +//@#define ACCURATE_SQRT +#define FULL_FP_ROUNDING +//@#define FULL_FP_ROUNDING + +#if !defined(SLEEF_GENHEADER) +#ifndef SLEEF_VECINTRIN_H_INCLUDED +#include +#define SLEEF_VECINTRIN_H_INCLUDED +#endif + +#include +#include +#include "misc.h" +#endif // #if !defined(SLEEF_GENHEADER) + +typedef __vector unsigned long long vmask; +typedef __vector unsigned long long vopmask; + +typedef __vector double vdouble; +typedef __vector int vint; + +typedef __vector float vfloat; +typedef __vector int vint2; + +typedef __vector long long vint64; +typedef __vector unsigned long long vuint64; + +typedef struct { + vmask x, y; +} vquad; + +typedef vquad vargquad; + +// + +#if !defined(SLEEF_GENHEADER) + +static INLINE int vavailability_i(int n) { + if (n == 1 || n == 2) { + return vec_max((vdouble) {n, n}, (vdouble) {n, n})[0] != 0; + } + return 0; +} + +#if CONFIG == 140 || CONFIG == 141 +#define ISANAME "VXE" +#else +#define ISANAME "VXE2" +#endif + +#define DFTPRIORITY 14 + +#endif // #if !defined(SLEEF_GENHEADER) + +static INLINE void vprefetch_v_p(const void *ptr) { } + +static vint2 vloadu_vi2_p(int32_t *p) { return (vint2) { p[0], p[1], p[2], p[3] }; } +static void vstoreu_v_p_vi2(int32_t *p, vint2 v) { p[0] = v[0]; p[1] = v[1]; p[2] = v[2]; p[3] = v[3]; } +static vint vloadu_vi_p(int32_t *p) { return (vint) { p[0], p[1] }; } +static void vstoreu_v_p_vi(int32_t *p, vint v) { p[0] = v[0]; p[1] = v[1]; } + +static INLINE vdouble vload_vd_p(const double *p) { return (vdouble) { p[0], p[1] }; } +static INLINE void vstore_v_p_vd(double *p, vdouble v) { p[0] = v[0]; p[1] = v[1]; } +static INLINE vdouble vloadu_vd_p(const double *p) { return (vdouble) { p[0], p[1] }; } +static INLINE void vstoreu_v_p_vd(double *p, vdouble v) { p[0] = v[0]; p[1] = v[1]; } + +static INLINE vfloat vload_vf_p(const float *p) { return (vfloat) { p[0], p[1], p[2], p[3] }; } +static INLINE void vstore_v_p_vf(float *p, vfloat v) { p[0] = v[0]; p[1] = v[1]; p[2] = v[2]; p[3] = v[3]; } +static INLINE void vscatter2_v_p_i_i_vf(float *p, int offset, int step, vfloat v) { + *(p+(offset + step * 0)*2 + 0) = v[0]; + *(p+(offset + step * 0)*2 + 1) = v[1]; + *(p+(offset + step * 1)*2 + 0) = v[2]; + *(p+(offset + step * 1)*2 + 1) = v[3]; +} + +static INLINE vfloat vloadu_vf_p(const float *p) { return (vfloat) { p[0], p[1], p[2], p[3] }; } +static INLINE void vstoreu_v_p_vf(float *p, vfloat v) { p[0] = v[0]; p[1] = v[1]; p[2] = v[2]; p[3] = v[3]; } + +static INLINE void vscatter2_v_p_i_i_vd(double *p, int offset, int step, vdouble v) { vstore_v_p_vd((double *)(&p[2*offset]), v); } + +static INLINE vdouble vgather_vd_p_vi(const double *p, vint vi) { + return ((vdouble) { p[vi[0]], p[vi[1]] }); +} + +static INLINE vfloat vgather_vf_p_vi2(const float *p, vint2 vi2) { + return ((vfloat) { p[vi2[0]], p[vi2[1]], p[vi2[2]], p[vi2[3]] }); +} + +static INLINE vopmask vcast_vo_i(int i) { return (vopmask) { i ? (long long)-1 : 0, i ? (long long)-1 : 0 }; } +static INLINE vint vcast_vi_i(int i) { return (vint) { i, i }; } +static INLINE vint2 vcast_vi2_i(int i) { return (vint2) { i, i, i, i }; } +static INLINE vfloat vcast_vf_f(float f) { return (vfloat) { f, f, f, f }; } +static INLINE vdouble vcast_vd_d(double d) { return (vdouble) { d, d }; } + +static INLINE vdouble vcast_vd_vi(vint vi) { return (vdouble) { vi[0], vi[1] }; } +static INLINE vfloat vcast_vf_vi2(vint2 vi) { return (vfloat) { vi[0], vi[1], vi[2], vi[3] }; } +static INLINE vdouble vtruncate_vd_vd(vdouble vd) { return __builtin_s390_vfidb(vd, 4, 5); } +static INLINE vdouble vrint_vd_vd(vdouble vd) { return __builtin_s390_vfidb(vd, 4, 4); } + +static INLINE vint vrint_vi_vd(vdouble vd) { + vd = vrint_vd_vd(vd); + return (vint) { vd[0], vd[1] }; +} +static INLINE vint vtruncate_vi_vd(vdouble vd) { return (vint) { vd[0], vd[1] }; } +static INLINE vint2 vtruncate_vi2_vf(vfloat vf) { return (vint) { vf[0], vf[1], vf[2], vf[3] }; } + +static INLINE vmask vreinterpret_vm_vd(vdouble vd) { return (vmask)vd; } +static INLINE vdouble vreinterpret_vd_vm(vmask vm) { return (vdouble)vm; } + +static INLINE vmask vreinterpret_vm_vf(vfloat vf) { return (vmask)vf; } +static INLINE vfloat vreinterpret_vf_vm(vmask vm) { return (vfloat)vm; } +static INLINE vfloat vreinterpret_vf_vi2(vint2 vi) { return (vfloat)vi; } +static INLINE vint2 vreinterpret_vi2_vf(vfloat vf) { return (vint2)vf; } + +static INLINE vdouble vadd_vd_vd_vd(vdouble x, vdouble y) { return x + y; } +static INLINE vdouble vsub_vd_vd_vd(vdouble x, vdouble y) { return x - y; } +static INLINE vdouble vmul_vd_vd_vd(vdouble x, vdouble y) { return x * y; } +static INLINE vdouble vdiv_vd_vd_vd(vdouble x, vdouble y) { return x / y; } +static INLINE vdouble vrec_vd_vd(vdouble x) { return 1 / x; } +static INLINE vdouble vneg_vd_vd(vdouble d) { return -d; } + +static INLINE vfloat vadd_vf_vf_vf(vfloat x, vfloat y) { return x + y; } +static INLINE vfloat vsub_vf_vf_vf(vfloat x, vfloat y) { return x - y; } +static INLINE vfloat vmul_vf_vf_vf(vfloat x, vfloat y) { return x * y; } +static INLINE vfloat vdiv_vf_vf_vf(vfloat x, vfloat y) { return x / y; } +static INLINE vfloat vrec_vf_vf(vfloat x) { return 1 / x; } +static INLINE vfloat vneg_vf_vf(vfloat d) { return -d; } + +static INLINE vmask vand_vm_vm_vm(vmask x, vmask y) { return x & y; } +static INLINE vmask vandnot_vm_vm_vm(vmask x, vmask y) { return y & ~x; } +static INLINE vmask vor_vm_vm_vm(vmask x, vmask y) { return x | y; } +static INLINE vmask vxor_vm_vm_vm(vmask x, vmask y) { return x ^ y; } + +static INLINE vopmask vand_vo_vo_vo(vopmask x, vopmask y) { return x & y; } +static INLINE vopmask vandnot_vo_vo_vo(vopmask x, vopmask y) { return y & ~x; } +static INLINE vopmask vor_vo_vo_vo(vopmask x, vopmask y) { return x | y; } +static INLINE vopmask vxor_vo_vo_vo(vopmask x, vopmask y) { return x ^ y; } + +static INLINE vmask vand_vm_vo64_vm(vopmask x, vmask y) { return x & y; } +static INLINE vmask vandnot_vm_vo64_vm(vopmask x, vmask y) { return y & ~x; } +static INLINE vmask vor_vm_vo64_vm(vopmask x, vmask y) { return x | y; } +static INLINE vmask vxor_vm_vo64_vm(vopmask x, vmask y) { return x ^ y; } + +static INLINE vmask vand_vm_vo32_vm(vopmask x, vmask y) { return x & y; } +static INLINE vmask vandnot_vm_vo32_vm(vopmask x, vmask y) { return y & ~x; } +static INLINE vmask vor_vm_vo32_vm(vopmask x, vmask y) { return x | y; } +static INLINE vmask vxor_vm_vo32_vm(vopmask x, vmask y) { return x ^ y; } + +static INLINE vdouble vsel_vd_vo_vd_vd(vopmask o, vdouble x, vdouble y) { return vec_sel(y, x, o); } +static INLINE vfloat vsel_vf_vo_vf_vf(vopmask o, vfloat x, vfloat y) { return vec_sel(y, x, (__vector unsigned int)o); } +static INLINE vint2 vsel_vi2_vo_vi2_vi2(vopmask o, vint2 x, vint2 y) { return vec_sel(y, x, (__vector unsigned int)o); } + +static INLINE int vtestallones_i_vo32(vopmask g) { return vec_all_ne((vint2)g, (vint2 ) { 0, 0, 0, 0 }); } +static INLINE int vtestallones_i_vo64(vopmask g) { return vec_all_ne((__vector unsigned long long)g, (__vector unsigned long long) { 0, 0 }); } + +static INLINE vopmask vcast_vo32_vo64(vopmask g) { return (vopmask)(vint) { g[0] != 0 ? -1 : 0, g[1] != 0 ? -1 : 0, 0, 0 }; } +static INLINE vopmask vcast_vo64_vo32(vopmask g) { return (vopmask) { ((vint)g)[0] != 0 ? 0xffffffffffffffffLL : 0, ((vint)g)[1] != 0 ? 0xffffffffffffffffLL : 0 }; } + +static INLINE vmask vcast_vm_i_i(int h, int l) { return (vmask)(vint){ h, l, h, l }; } +static INLINE vmask vcast_vm_i64(int64_t i) { return (vmask)(vint64){ i, i }; } +static INLINE vmask vcast_vm_u64(uint64_t i) { return (vmask)(vuint64){ i, i }; } + +static INLINE vmask vcastu_vm_vi(vint vi) { return (vmask)(vint2){ vi[0], 0, vi[1], 0 }; } +static INLINE vint vcastu_vi_vm(vmask vi2) { return (vint){ vi2[0] >> 32, vi2[1] >> 32 }; } + +static INLINE vint vreinterpretFirstHalf_vi_vi2(vint2 vi2) { return (vint){ vi2[0], vi2[1] }; } +static INLINE vint2 vreinterpretFirstHalf_vi2_vi(vint vi) { return (vint2){ vi[0], vi[1], 0, 0 }; } + +static INLINE vdouble vrev21_vd_vd(vdouble vd) { return (vdouble) { vd[1], vd[0] }; } +static INLINE vdouble vreva2_vd_vd(vdouble vd) { return vd; } +static INLINE vfloat vrev21_vf_vf(vfloat vd) { return (vfloat) { vd[1], vd[0], vd[3], vd[2] }; } +static INLINE vfloat vreva2_vf_vf(vfloat vd) { return (vfloat) { vd[2], vd[3], vd[0], vd[1] }; } + +static INLINE vopmask veq64_vo_vm_vm(vmask x, vmask y) { + return (vopmask) { x[0] == y[0] ? 0xffffffffffffffffLL : 0, x[1] == y[1] ? 0xffffffffffffffffLL : 0 }; +} + +static INLINE vmask vadd64_vm_vm_vm(vmask x, vmask y) { + return (vmask)((__vector long long)x + (__vector long long)y); +} + +// + +#define PNMASK ((vdouble) { +0.0, -0.0 }) +#define NPMASK ((vdouble) { -0.0, +0.0 }) +#define PNMASKf ((vfloat) { +0.0f, -0.0f, +0.0f, -0.0f }) +#define NPMASKf ((vfloat) { -0.0f, +0.0f, -0.0f, +0.0f }) + +static INLINE vdouble vposneg_vd_vd(vdouble d) { return vreinterpret_vd_vm(vxor_vm_vm_vm(vreinterpret_vm_vd(d), vreinterpret_vm_vd(PNMASK))); } +static INLINE vdouble vnegpos_vd_vd(vdouble d) { return vreinterpret_vd_vm(vxor_vm_vm_vm(vreinterpret_vm_vd(d), vreinterpret_vm_vd(NPMASK))); } +static INLINE vfloat vposneg_vf_vf(vfloat d) { return vreinterpret_vf_vm(vxor_vm_vm_vm(vreinterpret_vm_vf(d), vreinterpret_vm_vf(PNMASKf))); } +static INLINE vfloat vnegpos_vf_vf(vfloat d) { return vreinterpret_vf_vm(vxor_vm_vm_vm(vreinterpret_vm_vf(d), vreinterpret_vm_vf(NPMASKf))); } + +// + +static INLINE vdouble vabs_vd_vd(vdouble d) { return vec_abs(d); } +static INLINE vdouble vsubadd_vd_vd_vd(vdouble x, vdouble y) { return vadd_vd_vd_vd(x, vnegpos_vd_vd(y)); } + +#if CONFIG == 140 || CONFIG == 150 +static INLINE vdouble vmla_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return vec_madd(x, y, z); } +static INLINE vdouble vmlapn_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return vec_msub(x, y, z); } +static INLINE vdouble vmlanp_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return vec_nmsub(x, y, z); } +#else +static INLINE vdouble vmla_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return vadd_vd_vd_vd(vmul_vd_vd_vd(x, y), z); } +static INLINE vdouble vmlapn_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return vsub_vd_vd_vd(vmul_vd_vd_vd(x, y), z); } +#endif + +static INLINE vdouble vmlsubadd_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return vmla_vd_vd_vd_vd(x, y, vnegpos_vd_vd(z)); } +static INLINE vdouble vfma_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return vec_madd(x, y, z); } +static INLINE vdouble vfmapp_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return vec_madd(x, y, z); } +static INLINE vdouble vfmapn_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return vec_msub(x, y, z); } +static INLINE vdouble vfmanp_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return vec_nmsub(x, y, z); } +static INLINE vdouble vfmann_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return vec_nmadd(x, y, z); } + +static INLINE vfloat vsubadd_vf_vf_vf(vfloat x, vfloat y) { return vadd_vf_vf_vf(x, vnegpos_vf_vf(y)); } + +#if CONFIG == 140 || CONFIG == 150 +static INLINE vfloat vmla_vf_vf_vf_vf (vfloat x, vfloat y, vfloat z) { return __builtin_s390_vfmasb(x, y, z); } +static INLINE vfloat vmlanp_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return vec_nmsub(x, y, z); } +static INLINE vfloat vmlapn_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return __builtin_s390_vfmssb(x, y, z); } +static INLINE vfloat vfma_vf_vf_vf_vf (vfloat x, vfloat y, vfloat z) { return __builtin_s390_vfmasb(x, y, z); } +static INLINE vfloat vfmapp_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return __builtin_s390_vfmasb(x, y, z); } +static INLINE vfloat vfmapn_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return __builtin_s390_vfmssb(x, y, z); } +static INLINE vfloat vfmanp_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return vec_nmsub(x, y, z); } +static INLINE vfloat vfmann_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return vec_nmadd(x, y, z); } +#else +static INLINE vfloat vmla_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return vadd_vf_vf_vf(vmul_vf_vf_vf(x, y), z); } +static INLINE vfloat vmlanp_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return vsub_vf_vf_vf(z, vmul_vf_vf_vf(x, y)); } +static INLINE vfloat vmlapn_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return vsub_vf_vf_vf(vmul_vf_vf_vf(x, y), z); } +#endif + +static INLINE vfloat vmlsubadd_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return vmla_vf_vf_vf_vf(x, y, vnegpos_vf_vf(z)); } + +// + +static INLINE CONST vdouble vsel_vd_vo_d_d(vopmask o, double v1, double v0) { + return vsel_vd_vo_vd_vd(o, vcast_vd_d(v1), vcast_vd_d(v0)); +} + +static INLINE vdouble vsel_vd_vo_vo_d_d_d(vopmask o0, vopmask o1, double d0, double d1, double d2) { + return vsel_vd_vo_vd_vd(o0, vcast_vd_d(d0), vsel_vd_vo_d_d(o1, d1, d2)); +} + +static INLINE vdouble vsel_vd_vo_vo_vo_d_d_d_d(vopmask o0, vopmask o1, vopmask o2, double d0, double d1, double d2, double d3) { + return vsel_vd_vo_vd_vd(o0, vcast_vd_d(d0), vsel_vd_vo_vd_vd(o1, vcast_vd_d(d1), vsel_vd_vo_d_d(o2, d2, d3))); +} + +// + +static INLINE vopmask vnot_vo_vo(vopmask o) { return ~o; } + +static INLINE vopmask veq_vo_vd_vd(vdouble x, vdouble y) { return (vopmask)vec_cmpeq(x, y); } +static INLINE vopmask vneq_vo_vd_vd(vdouble x, vdouble y) { return (vopmask)vnot_vo_vo(vec_cmpeq(x, y)); } +static INLINE vopmask vlt_vo_vd_vd(vdouble x, vdouble y) { return (vopmask)vec_cmplt(x, y); } +static INLINE vopmask vle_vo_vd_vd(vdouble x, vdouble y) { return (vopmask)vec_cmple(x, y); } +static INLINE vopmask vgt_vo_vd_vd(vdouble x, vdouble y) { return (vopmask)vec_cmpgt(x, y); } +static INLINE vopmask vge_vo_vd_vd(vdouble x, vdouble y) { return (vopmask)vec_cmpge(x, y); } + +static INLINE vint vadd_vi_vi_vi(vint x, vint y) { return x + y; } +static INLINE vint vsub_vi_vi_vi(vint x, vint y) { return x - y; } +static INLINE vint vneg_vi_vi(vint e) { return -e; } + +static INLINE vint vand_vi_vi_vi(vint x, vint y) { return x & y; } +static INLINE vint vandnot_vi_vi_vi(vint x, vint y) { return y & ~x; } +static INLINE vint vor_vi_vi_vi(vint x, vint y) { return x | y; } +static INLINE vint vxor_vi_vi_vi(vint x, vint y) { return x ^ y; } + +static INLINE vint vand_vi_vo_vi(vopmask x, vint y) { return vreinterpretFirstHalf_vi_vi2((vint2)x) & y; } +static INLINE vint vandnot_vi_vo_vi(vopmask x, vint y) { return vec_andc(y, vreinterpretFirstHalf_vi_vi2((vint2)x)); } + +static INLINE vint vsll_vi_vi_i(vint x, int c) { return (vint)(((__vector unsigned int)x) << (__vector unsigned int){c, c, c, c}); } +static INLINE vint vsrl_vi_vi_i(vint x, int c) { return (vint)(((__vector unsigned int)x) >> (__vector unsigned int){c, c, c, c}); } +static INLINE vint vsra_vi_vi_i(vint x, int c) { return x >> (__vector int){c, c, c, c}; } + +static INLINE vint veq_vi_vi_vi(vint x, vint y) { return vec_cmpeq(x, y); } +static INLINE vint vgt_vi_vi_vi(vint x, vint y) { return vec_cmpgt(x, y); } + +static INLINE vopmask veq_vo_vi_vi(vint x, vint y) { return (vopmask)vreinterpretFirstHalf_vi2_vi(vec_cmpeq(x, y)); } +static INLINE vopmask vgt_vo_vi_vi(vint x, vint y) { return (vopmask)vreinterpretFirstHalf_vi2_vi(vec_cmpgt(x, y));} + +static INLINE vint vsel_vi_vo_vi_vi(vopmask m, vint x, vint y) { + return vor_vi_vi_vi(vand_vi_vi_vi(vreinterpretFirstHalf_vi_vi2((vint2)m), x), + vandnot_vi_vi_vi(vreinterpretFirstHalf_vi_vi2((vint2)m), y)); +} + +static INLINE vopmask visinf_vo_vd(vdouble d) { return (vopmask)(vec_cmpeq(vabs_vd_vd(d), vcast_vd_d(SLEEF_INFINITY))); } +static INLINE vopmask vispinf_vo_vd(vdouble d) { return (vopmask)(vec_cmpeq(d, vcast_vd_d(SLEEF_INFINITY))); } +static INLINE vopmask visminf_vo_vd(vdouble d) { return (vopmask)(vec_cmpeq(d, vcast_vd_d(-SLEEF_INFINITY))); } +static INLINE vopmask visnan_vo_vd(vdouble d) { return (vopmask)(vnot_vo_vo(vec_cmpeq(d, d))); } + +static INLINE double vcast_d_vd(vdouble v) { return v[0]; } +static INLINE float vcast_f_vf(vfloat v) { return v[0]; } + +static INLINE void vstream_v_p_vd(double *p, vdouble v) { vstore_v_p_vd(p, v); } +static INLINE void vsscatter2_v_p_i_i_vd(double *p, int offset, int step, vdouble v) { vscatter2_v_p_i_i_vd(p, offset, step, v); } + +// + +static INLINE CONST vfloat vsel_vf_vo_f_f(vopmask o, float v1, float v0) { + return vsel_vf_vo_vf_vf(o, vcast_vf_f(v1), vcast_vf_f(v0)); +} + +static INLINE vfloat vsel_vf_vo_vo_f_f_f(vopmask o0, vopmask o1, float d0, float d1, float d2) { + return vsel_vf_vo_vf_vf(o0, vcast_vf_f(d0), vsel_vf_vo_f_f(o1, d1, d2)); +} + +static INLINE vfloat vsel_vf_vo_vo_vo_f_f_f_f(vopmask o0, vopmask o1, vopmask o2, float d0, float d1, float d2, float d3) { + return vsel_vf_vo_vf_vf(o0, vcast_vf_f(d0), vsel_vf_vo_vf_vf(o1, vcast_vf_f(d1), vsel_vf_vo_f_f(o2, d2, d3))); +} + +static INLINE vint2 vcast_vi2_vm(vmask vm) { return (vint2)vm; } +static INLINE vmask vcast_vm_vi2(vint2 vi) { return (vmask)vi; } + +static INLINE vint2 vadd_vi2_vi2_vi2(vint2 x, vint2 y) { return x + y; } +static INLINE vint2 vsub_vi2_vi2_vi2(vint2 x, vint2 y) { return x - y; } +static INLINE vint2 vneg_vi2_vi2(vint2 e) { return -e; } + +static INLINE vint2 vand_vi2_vi2_vi2(vint2 x, vint2 y) { return x & y; } +static INLINE vint2 vandnot_vi2_vi2_vi2(vint2 x, vint2 y) { return y & ~x; } +static INLINE vint2 vor_vi2_vi2_vi2(vint2 x, vint2 y) { return x | y; } +static INLINE vint2 vxor_vi2_vi2_vi2(vint2 x, vint2 y) { return x ^ y; } + +static INLINE vint2 vand_vi2_vo_vi2(vopmask x, vint2 y) { return (vint2)x & y; } +static INLINE vint2 vandnot_vi2_vo_vi2(vopmask x, vint2 y) { return y & ~(vint2)x; } + +static INLINE vint2 vsll_vi2_vi2_i(vint2 x, int c) { return (vint2)(((__vector unsigned int)x) << (__vector unsigned int){c, c, c, c}); } +static INLINE vint2 vsrl_vi2_vi2_i(vint2 x, int c) { return (vint2)(((__vector unsigned int)x) >> (__vector unsigned int){c, c, c, c}); } +static INLINE vint2 vsra_vi2_vi2_i(vint2 x, int c) { return x >> (__vector int){c, c, c, c}; } + +static INLINE vopmask veq_vo_vi2_vi2(vint2 x, vint2 y) { return (vopmask)vec_cmpeq(x, y); } +static INLINE vopmask vgt_vo_vi2_vi2(vint2 x, vint2 y) { return (vopmask)vec_cmpgt(x, y); } +static INLINE vint2 veq_vi2_vi2_vi2(vint2 x, vint2 y) { return vec_cmpeq(x, y); } +static INLINE vint2 vgt_vi2_vi2_vi2(vint2 x, vint2 y) { return vec_cmpgt(x, y); } + +static INLINE void vsscatter2_v_p_i_i_vf(float *p, int offset, int step, vfloat v) { vscatter2_v_p_i_i_vf(p, offset, step, v); } +static INLINE void vstream_v_p_vf(float *p, vfloat v) { vstore_v_p_vf(p, v); } + +// + +static INLINE vdouble vsqrt_vd_vd(vdouble d) { return vec_sqrt(d); } + +static INLINE vdouble vmax_vd_vd_vd(vdouble x, vdouble y) { return vec_max(x, y); } +static INLINE vdouble vmin_vd_vd_vd(vdouble x, vdouble y) { return vec_min(x, y); } + +static INLINE vopmask veq_vo_vf_vf(vfloat x, vfloat y) { return (vopmask)vec_cmpeq(x, y); } +static INLINE vopmask vneq_vo_vf_vf(vfloat x, vfloat y) { return (vopmask)vnot_vo_vo(vec_cmpeq(x, y)); } +static INLINE vopmask vlt_vo_vf_vf(vfloat x, vfloat y) { return (vopmask)vec_cmplt(x, y); } +static INLINE vopmask vle_vo_vf_vf(vfloat x, vfloat y) { return (vopmask)vec_cmple(x, y); } +static INLINE vopmask vgt_vo_vf_vf(vfloat x, vfloat y) { return (vopmask)vec_cmpgt(x, y); } +static INLINE vopmask vge_vo_vf_vf(vfloat x, vfloat y) { return (vopmask)vec_cmpge(x, y); } + +static INLINE vfloat vabs_vf_vf(vfloat f) { return vec_abs(f); } +static INLINE vfloat vrint_vf_vf(vfloat vf) { return __builtin_s390_vfisb(vf, 4, 4); } +static INLINE vfloat vtruncate_vf_vf(vfloat vf) { return __builtin_s390_vfisb(vf, 4, 5); } +static INLINE vfloat vmax_vf_vf_vf(vfloat x, vfloat y) { return vec_max(x, y); } +static INLINE vfloat vmin_vf_vf_vf(vfloat x, vfloat y) { return vec_min(x, y); } + +static INLINE vfloat vsqrt_vf_vf(vfloat d) { return vec_sqrt(d); } + +static INLINE vopmask visinf_vo_vf (vfloat d) { return veq_vo_vf_vf(vabs_vf_vf(d), vcast_vf_f(SLEEF_INFINITYf)); } +static INLINE vopmask vispinf_vo_vf(vfloat d) { return veq_vo_vf_vf(d, vcast_vf_f(SLEEF_INFINITYf)); } +static INLINE vopmask visminf_vo_vf(vfloat d) { return veq_vo_vf_vf(d, vcast_vf_f(-SLEEF_INFINITYf)); } +static INLINE vopmask visnan_vo_vf (vfloat d) { return vneq_vo_vf_vf(d, d); } + +static INLINE vint2 vrint_vi2_vf(vfloat vf) { + vf = vrint_vf_vf(vf); + return (vint) { vf[0], vf[1], vf[2], vf[3] }; +} + +// + +static vquad loadu_vq_p(void *p) { + vquad vq; + memcpy(&vq, p, VECTLENDP * 16); + return vq; +} + +static INLINE vquad cast_vq_aq(vargquad aq) { + vquad m = { aq.y, aq.x }; + return m; +} +static INLINE vargquad cast_aq_vq(vquad vq) { + vargquad a = { vq.y, vq.x }; + return a; +} + +static INLINE int vtestallzeros_i_vo64(vopmask g) { + return vec_all_eq((__vector signed long long)g, (__vector signed long long){ 0, 0 }); +} + +static INLINE vmask vsel_vm_vo64_vm_vm(vopmask o, vmask x, vmask y) { + return (vmask)vec_sel((__vector signed long long)y, (__vector signed long long)x, (__vector __bool long long)o); +} + +static INLINE vmask vsub64_vm_vm_vm(vmask x, vmask y) { + return (vmask)((__vector signed long long)x - (__vector signed long long)y); +} + +static INLINE vmask vneg64_vm_vm(vmask x) { + return (vmask)((__vector signed long long) {0, 0} - (__vector signed long long)x); +} + +static INLINE vopmask vgt64_vo_vm_vm(vmask x, vmask y) { + return (vopmask)vec_cmpgt((__vector signed long long)x, (__vector signed long long)y); +} + +#define vsll64_vm_vm_i(x, c) ((vmask)((__vector unsigned long long)x << (__vector unsigned long long) { c, c })) +#define vsrl64_vm_vm_i(x, c) ((vmask)((__vector unsigned long long)x >> (__vector unsigned long long) { c, c })) + +static INLINE vint vcast_vi_vm(vmask vm) { + return (vint) { vm[0], vm[1] }; +} + +static INLINE vmask vcast_vm_vi(vint vi) { + return (vmask) (__vector signed long long) { vi[0], vi[1] }; +} + +static INLINE vmask vreinterpret_vm_vi64(vint64 v) { return (vmask)v; } +static INLINE vint64 vreinterpret_vi64_vm(vmask m) { return (vint64)m; } +static INLINE vmask vreinterpret_vm_vu64(vuint64 v) { return (vmask)v; } +static INLINE vuint64 vreinterpret_vu64_vm(vmask m) { return (vuint64)m; } diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/arch/helpersse2.h b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/arch/helpersse2.h new file mode 100644 index 00000000000..833f5f9b8e1 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/arch/helpersse2.h @@ -0,0 +1,517 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#if CONFIG == 2 + +#if !defined(__SSE2__) && !defined(SLEEF_GENHEADER) +#error Please specify -msse2. +#endif + +#elif CONFIG == 3 + +#if (!defined(__SSE2__) || !defined(__SSE3__)) && !defined(SLEEF_GENHEADER) +#error Please specify -msse2 and -msse3 +#endif + +#elif CONFIG == 4 + +#if (!defined(__SSE2__) || !defined(__SSE3__) || !defined(__SSE4_1__)) && !defined(SLEEF_GENHEADER) +#error Please specify -msse2, -msse3 and -msse4.1 +#endif + +#else +#error CONFIG macro invalid or not defined +#endif + +#define ENABLE_DP +//@#define ENABLE_DP +#define LOG2VECTLENDP 1 +//@#define LOG2VECTLENDP 1 +#define VECTLENDP (1 << LOG2VECTLENDP) +//@#define VECTLENDP (1 << LOG2VECTLENDP) + +#define ENABLE_SP +//@#define ENABLE_SP +#define LOG2VECTLENSP (LOG2VECTLENDP+1) +//@#define LOG2VECTLENSP (LOG2VECTLENDP+1) +#define VECTLENSP (1 << LOG2VECTLENSP) +//@#define VECTLENSP (1 << LOG2VECTLENSP) + +#define ACCURATE_SQRT +//@#define ACCURATE_SQRT + +#if !defined(SLEEF_GENHEADER) +#if defined(_MSC_VER) +#include +#else +#include +#endif + +#include +#include "misc.h" +#endif // #if !defined(SLEEF_GENHEADER) + +typedef __m128i vmask; +typedef __m128i vopmask; + +typedef __m128d vdouble; +typedef __m128i vint; + +typedef __m128 vfloat; +typedef __m128i vint2; + +typedef __m128i vint64; +typedef __m128i vuint64; + +typedef struct { + vmask x, y; +} vquad; + +typedef vquad vargquad; + +// + +#if !defined(SLEEF_GENHEADER) + +#ifndef __SLEEF_H__ +void Sleef_x86CpuID(int32_t out[4], uint32_t eax, uint32_t ecx); +#endif + +static INLINE int cpuSupportsSSE2() { + int32_t reg[4]; + Sleef_x86CpuID(reg, 1, 0); + return (reg[3] & (1 << 26)) != 0; +} + +static INLINE int cpuSupportsSSE3() { + int32_t reg[4]; + Sleef_x86CpuID(reg, 1, 0); + return (reg[2] & (1 << 0)) != 0; +} + +static INLINE int cpuSupportsSSE4_1() { + int32_t reg[4]; + Sleef_x86CpuID(reg, 1, 0); + return (reg[2] & (1 << 19)) != 0; +} + +#if defined(__SSE2__) && defined(__SSE3__) && defined(__SSE4_1__) +static INLINE int vavailability_i(int name) { + //int d = __builtin_cpu_supports("sse2") && __builtin_cpu_supports("sse3") && __builtin_cpu_supports("sse4.1"); + int d = cpuSupportsSSE2() && cpuSupportsSSE3() && cpuSupportsSSE4_1(); + return d ? 3 : 0; +} +#define ISANAME "SSE4.1" +#define DFTPRIORITY 12 +#elif defined(__SSE2__) && defined(__SSE3__) +static INLINE int vavailability_i(int name) { + //int d = __builtin_cpu_supports("sse2") && __builtin_cpu_supports("sse3"); + int d = cpuSupportsSSE2() && cpuSupportsSSE3(); + return d ? 3 : 0; +} +#define ISANAME "SSE3" +#define DFTPRIORITY 11 +#else +static INLINE int vavailability_i(int name) { + int d = cpuSupportsSSE2(); + return d ? 3 : 0; +} +#define ISANAME "SSE2" +#define DFTPRIORITY 10 +#endif + +#endif // #if !defined(SLEEF_GENHEADER) + +static INLINE void vprefetch_v_p(const void *ptr) { _mm_prefetch(ptr, _MM_HINT_T0); } + +static INLINE int vtestallones_i_vo32(vopmask g) { return _mm_movemask_epi8(g) == 0xFFFF; } +static INLINE int vtestallones_i_vo64(vopmask g) { return _mm_movemask_epi8(g) == 0xFFFF; } + +// + +static vint2 vloadu_vi2_p(int32_t *p) { return _mm_loadu_si128((__m128i *)p); } +static void vstoreu_v_p_vi2(int32_t *p, vint2 v) { _mm_storeu_si128((__m128i *)p, v); } + +static vint vloadu_vi_p(int32_t *p) { return _mm_loadu_si128((__m128i *)p); } +static void vstoreu_v_p_vi(int32_t *p, vint v) { _mm_storeu_si128((__m128i *)p, v); } + +// + +static INLINE vmask vand_vm_vm_vm(vmask x, vmask y) { return _mm_and_si128(x, y); } +static INLINE vmask vandnot_vm_vm_vm(vmask x, vmask y) { return _mm_andnot_si128(x, y); } +static INLINE vmask vor_vm_vm_vm(vmask x, vmask y) { return _mm_or_si128(x, y); } +static INLINE vmask vxor_vm_vm_vm(vmask x, vmask y) { return _mm_xor_si128(x, y); } + +static INLINE vopmask vand_vo_vo_vo(vopmask x, vopmask y) { return _mm_and_si128(x, y); } +static INLINE vopmask vandnot_vo_vo_vo(vopmask x, vopmask y) { return _mm_andnot_si128(x, y); } +static INLINE vopmask vor_vo_vo_vo(vopmask x, vopmask y) { return _mm_or_si128(x, y); } +static INLINE vopmask vxor_vo_vo_vo(vopmask x, vopmask y) { return _mm_xor_si128(x, y); } + +static INLINE vmask vand_vm_vo64_vm(vopmask x, vmask y) { return _mm_and_si128(x, y); } +static INLINE vmask vor_vm_vo64_vm(vopmask x, vmask y) { return _mm_or_si128(x, y); } +static INLINE vmask vandnot_vm_vo64_vm(vmask x, vmask y) { return _mm_andnot_si128(x, y); } +static INLINE vmask vxor_vm_vo64_vm(vmask x, vmask y) { return _mm_xor_si128(x, y); } + +static INLINE vmask vand_vm_vo32_vm(vopmask x, vmask y) { return _mm_and_si128(x, y); } +static INLINE vmask vor_vm_vo32_vm(vopmask x, vmask y) { return _mm_or_si128(x, y); } +static INLINE vmask vandnot_vm_vo32_vm(vmask x, vmask y) { return _mm_andnot_si128(x, y); } +static INLINE vmask vxor_vm_vo32_vm(vmask x, vmask y) { return _mm_xor_si128(x, y); } + +static INLINE vopmask vcast_vo32_vo64(vopmask m) { return _mm_shuffle_epi32(m, 0x08); } +static INLINE vopmask vcast_vo64_vo32(vopmask m) { return _mm_shuffle_epi32(m, 0x50); } + +static INLINE vopmask vcast_vo_i(int i) { return _mm_set1_epi64x(i ? -1 : 0); } + +// + +static INLINE vint vrint_vi_vd(vdouble vd) { return _mm_cvtpd_epi32(vd); } +static INLINE vint vtruncate_vi_vd(vdouble vd) { return _mm_cvttpd_epi32(vd); } +static INLINE vdouble vcast_vd_vi(vint vi) { return _mm_cvtepi32_pd(vi); } +static INLINE vint vcast_vi_i(int i) { return _mm_set_epi32(0, 0, i, i); } +static INLINE vint2 vcastu_vm_vi(vint vi) { return _mm_and_si128(_mm_shuffle_epi32(vi, 0x73), _mm_set_epi32(-1, 0, -1, 0)); } +static INLINE vint vcastu_vi_vm(vint2 vi) { return _mm_shuffle_epi32(vi, 0x0d); } + +#if CONFIG == 4 +static INLINE vdouble vtruncate_vd_vd(vdouble vd) { return _mm_round_pd(vd, _MM_FROUND_TO_ZERO |_MM_FROUND_NO_EXC); } +static INLINE vdouble vrint_vd_vd(vdouble vd) { return _mm_round_pd(vd, _MM_FROUND_TO_NEAREST_INT |_MM_FROUND_NO_EXC); } +static INLINE vfloat vtruncate_vf_vf(vfloat vf) { return _mm_round_ps(vf, _MM_FROUND_TO_ZERO |_MM_FROUND_NO_EXC); } +static INLINE vfloat vrint_vf_vf(vfloat vd) { return _mm_round_ps(vd, _MM_FROUND_TO_NEAREST_INT |_MM_FROUND_NO_EXC); } +static INLINE vopmask veq64_vo_vm_vm(vmask x, vmask y) { return _mm_cmpeq_epi64(x, y); } +#define FULL_FP_ROUNDING +//@#define FULL_FP_ROUNDING +#else +static INLINE vdouble vtruncate_vd_vd(vdouble vd) { return vcast_vd_vi(vtruncate_vi_vd(vd)); } +static INLINE vdouble vrint_vd_vd(vdouble vd) { return vcast_vd_vi(vrint_vi_vd(vd)); } +static INLINE vopmask veq64_vo_vm_vm(vmask x, vmask y) { + vmask t = _mm_cmpeq_epi32(x, y); + return vand_vm_vm_vm(t, _mm_shuffle_epi32(t, 0xb1)); +} +#endif + +static INLINE vmask vadd64_vm_vm_vm(vmask x, vmask y) { return _mm_add_epi64(x, y); } + +static INLINE vmask vcast_vm_i_i(int i0, int i1) { return _mm_set_epi32(i0, i1, i0, i1); } + +static INLINE vmask vcast_vm_i64(int64_t i) { return _mm_set1_epi64x(i); } +static INLINE vmask vcast_vm_u64(uint64_t i) { return _mm_set1_epi64x((uint64_t)i); } + +// + +static INLINE vdouble vcast_vd_d(double d) { return _mm_set1_pd(d); } +static INLINE vmask vreinterpret_vm_vd(vdouble vd) { return _mm_castpd_si128(vd); } +static INLINE vdouble vreinterpret_vd_vm(vmask vm) { return _mm_castsi128_pd(vm); } + +static INLINE vdouble vadd_vd_vd_vd(vdouble x, vdouble y) { return _mm_add_pd(x, y); } +static INLINE vdouble vsub_vd_vd_vd(vdouble x, vdouble y) { return _mm_sub_pd(x, y); } +static INLINE vdouble vmul_vd_vd_vd(vdouble x, vdouble y) { return _mm_mul_pd(x, y); } +static INLINE vdouble vdiv_vd_vd_vd(vdouble x, vdouble y) { return _mm_div_pd(x, y); } +static INLINE vdouble vrec_vd_vd(vdouble x) { return _mm_div_pd(_mm_set1_pd(1), x); } +static INLINE vdouble vsqrt_vd_vd(vdouble x) { return _mm_sqrt_pd(x); } +static INLINE vdouble vabs_vd_vd(vdouble d) { return _mm_andnot_pd(_mm_set1_pd(-0.0), d); } +static INLINE vdouble vneg_vd_vd(vdouble d) { return _mm_xor_pd(_mm_set1_pd(-0.0), d); } +static INLINE vdouble vmla_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return vadd_vd_vd_vd(vmul_vd_vd_vd(x, y), z); } +static INLINE vdouble vmlapn_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return vsub_vd_vd_vd(vmul_vd_vd_vd(x, y), z); } +static INLINE vdouble vmlanp_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return vsub_vd_vd_vd(z, vmul_vd_vd_vd(x, y)); } +static INLINE vdouble vmax_vd_vd_vd(vdouble x, vdouble y) { return _mm_max_pd(x, y); } +static INLINE vdouble vmin_vd_vd_vd(vdouble x, vdouble y) { return _mm_min_pd(x, y); } + +static INLINE vopmask veq_vo_vd_vd(vdouble x, vdouble y) { return _mm_castpd_si128(_mm_cmpeq_pd(x, y)); } +static INLINE vopmask vneq_vo_vd_vd(vdouble x, vdouble y) { return _mm_castpd_si128(_mm_cmpneq_pd(x, y)); } +static INLINE vopmask vlt_vo_vd_vd(vdouble x, vdouble y) { return _mm_castpd_si128(_mm_cmplt_pd(x, y)); } +static INLINE vopmask vle_vo_vd_vd(vdouble x, vdouble y) { return _mm_castpd_si128(_mm_cmple_pd(x, y)); } +static INLINE vopmask vgt_vo_vd_vd(vdouble x, vdouble y) { return _mm_castpd_si128(_mm_cmpgt_pd(x, y)); } +static INLINE vopmask vge_vo_vd_vd(vdouble x, vdouble y) { return _mm_castpd_si128(_mm_cmpge_pd(x, y)); } + +static INLINE vint vadd_vi_vi_vi(vint x, vint y) { return _mm_add_epi32(x, y); } +static INLINE vint vsub_vi_vi_vi(vint x, vint y) { return _mm_sub_epi32(x, y); } +static INLINE vint vneg_vi_vi(vint e) { return vsub_vi_vi_vi(vcast_vi_i(0), e); } + +static INLINE vint vand_vi_vi_vi(vint x, vint y) { return _mm_and_si128(x, y); } +static INLINE vint vandnot_vi_vi_vi(vint x, vint y) { return _mm_andnot_si128(x, y); } +static INLINE vint vor_vi_vi_vi(vint x, vint y) { return _mm_or_si128(x, y); } +static INLINE vint vxor_vi_vi_vi(vint x, vint y) { return _mm_xor_si128(x, y); } + +static INLINE vint vand_vi_vo_vi(vopmask x, vint y) { return _mm_and_si128(x, y); } +static INLINE vint vandnot_vi_vo_vi(vopmask x, vint y) { return _mm_andnot_si128(x, y); } + +static INLINE vint vsll_vi_vi_i(vint x, int c) { return _mm_slli_epi32(x, c); } +static INLINE vint vsrl_vi_vi_i(vint x, int c) { return _mm_srli_epi32(x, c); } +static INLINE vint vsra_vi_vi_i(vint x, int c) { return _mm_srai_epi32(x, c); } + +static INLINE vint veq_vi_vi_vi(vint x, vint y) { return _mm_cmpeq_epi32(x, y); } +static INLINE vint vgt_vi_vi_vi(vint x, vint y) { return _mm_cmpgt_epi32(x, y); } + +static INLINE vopmask veq_vo_vi_vi(vint x, vint y) { return _mm_cmpeq_epi32(x, y); } +static INLINE vopmask vgt_vo_vi_vi(vint x, vint y) { return _mm_cmpgt_epi32(x, y); } + +#if CONFIG == 4 +static INLINE vint vsel_vi_vo_vi_vi(vopmask m, vint x, vint y) { return _mm_blendv_epi8(y, x, m); } + +static INLINE vdouble vsel_vd_vo_vd_vd(vopmask m, vdouble x, vdouble y) { return _mm_blendv_pd(y, x, _mm_castsi128_pd(m)); } +#else +static INLINE vint vsel_vi_vo_vi_vi(vopmask m, vint x, vint y) { return vor_vm_vm_vm(vand_vm_vm_vm(m, x), vandnot_vm_vm_vm(m, y)); } + +static INLINE vdouble vsel_vd_vo_vd_vd(vopmask opmask, vdouble x, vdouble y) { + return _mm_or_pd(_mm_and_pd(_mm_castsi128_pd(opmask), x), _mm_andnot_pd(_mm_castsi128_pd(opmask), y)); +} +#endif + +static INLINE CONST vdouble vsel_vd_vo_d_d(vopmask o, double v1, double v0) { + return vsel_vd_vo_vd_vd(o, vcast_vd_d(v1), vcast_vd_d(v0)); +} + +static INLINE vdouble vsel_vd_vo_vo_d_d_d(vopmask o0, vopmask o1, double d0, double d1, double d2) { + return vsel_vd_vo_vd_vd(o0, vcast_vd_d(d0), vsel_vd_vo_d_d(o1, d1, d2)); +} + +static INLINE vdouble vsel_vd_vo_vo_vo_d_d_d_d(vopmask o0, vopmask o1, vopmask o2, double d0, double d1, double d2, double d3) { + return vsel_vd_vo_vd_vd(o0, vcast_vd_d(d0), vsel_vd_vo_vd_vd(o1, vcast_vd_d(d1), vsel_vd_vo_d_d(o2, d2, d3))); +} + +static INLINE vopmask visinf_vo_vd(vdouble d) { + return vreinterpret_vm_vd(_mm_cmpeq_pd(vabs_vd_vd(d), _mm_set1_pd(SLEEF_INFINITY))); +} + +static INLINE vopmask vispinf_vo_vd(vdouble d) { + return vreinterpret_vm_vd(_mm_cmpeq_pd(d, _mm_set1_pd(SLEEF_INFINITY))); +} + +static INLINE vopmask visminf_vo_vd(vdouble d) { + return vreinterpret_vm_vd(_mm_cmpeq_pd(d, _mm_set1_pd(-SLEEF_INFINITY))); +} + +static INLINE vopmask visnan_vo_vd(vdouble d) { + return vreinterpret_vm_vd(_mm_cmpneq_pd(d, d)); +} + +// + +static INLINE vdouble vload_vd_p(const double *ptr) { return _mm_load_pd(ptr); } +static INLINE vdouble vloadu_vd_p(const double *ptr) { return _mm_loadu_pd(ptr); } + +static INLINE void vstore_v_p_vd(double *ptr, vdouble v) { _mm_store_pd(ptr, v); } +static INLINE void vstoreu_v_p_vd(double *ptr, vdouble v) { _mm_storeu_pd(ptr, v); } + +static INLINE vdouble vgather_vd_p_vi(const double *ptr, vint vi) { + int a[sizeof(vint)/sizeof(int)]; + vstoreu_v_p_vi(a, vi); + return _mm_set_pd(ptr[a[1]], ptr[a[0]]); +} + +// This function is for debugging +static INLINE double vcast_d_vd(vdouble v) { + double a[VECTLENDP]; + vstoreu_v_p_vd(a, v); + return a[0]; +} + +// + +static INLINE vint2 vcast_vi2_vm(vmask vm) { return vm; } +static INLINE vmask vcast_vm_vi2(vint2 vi) { return vi; } +static INLINE vint2 vrint_vi2_vf(vfloat vf) { return _mm_cvtps_epi32(vf); } +static INLINE vint2 vtruncate_vi2_vf(vfloat vf) { return _mm_cvttps_epi32(vf); } +static INLINE vfloat vcast_vf_vi2(vint2 vi) { return _mm_cvtepi32_ps(vcast_vm_vi2(vi)); } +static INLINE vfloat vcast_vf_f(float f) { return _mm_set1_ps(f); } +static INLINE vint2 vcast_vi2_i(int i) { return _mm_set1_epi32(i); } +static INLINE vmask vreinterpret_vm_vf(vfloat vf) { return _mm_castps_si128(vf); } +static INLINE vfloat vreinterpret_vf_vm(vmask vm) { return _mm_castsi128_ps(vm); } +static INLINE vfloat vreinterpret_vf_vi2(vint2 vm) { return _mm_castsi128_ps(vm); } +static INLINE vint2 vreinterpret_vi2_vf(vfloat vf) { return _mm_castps_si128(vf); } + +#if CONFIG != 4 +static INLINE vfloat vtruncate_vf_vf(vfloat vd) { return vcast_vf_vi2(vtruncate_vi2_vf(vd)); } +static INLINE vfloat vrint_vf_vf(vfloat vf) { return vcast_vf_vi2(vrint_vi2_vf(vf)); } +#endif + +static INLINE vfloat vadd_vf_vf_vf(vfloat x, vfloat y) { return _mm_add_ps(x, y); } +static INLINE vfloat vsub_vf_vf_vf(vfloat x, vfloat y) { return _mm_sub_ps(x, y); } +static INLINE vfloat vmul_vf_vf_vf(vfloat x, vfloat y) { return _mm_mul_ps(x, y); } +static INLINE vfloat vdiv_vf_vf_vf(vfloat x, vfloat y) { return _mm_div_ps(x, y); } +static INLINE vfloat vrec_vf_vf(vfloat x) { return vdiv_vf_vf_vf(vcast_vf_f(1.0f), x); } +static INLINE vfloat vsqrt_vf_vf(vfloat x) { return _mm_sqrt_ps(x); } +static INLINE vfloat vabs_vf_vf(vfloat f) { return vreinterpret_vf_vm(vandnot_vm_vm_vm(vreinterpret_vm_vf(vcast_vf_f(-0.0f)), vreinterpret_vm_vf(f))); } +static INLINE vfloat vneg_vf_vf(vfloat d) { return vreinterpret_vf_vm(vxor_vm_vm_vm(vreinterpret_vm_vf(vcast_vf_f(-0.0f)), vreinterpret_vm_vf(d))); } +static INLINE vfloat vmla_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return vadd_vf_vf_vf(vmul_vf_vf_vf(x, y), z); } +static INLINE vfloat vmlapn_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return vsub_vf_vf_vf(vmul_vf_vf_vf(x, y), z); } +static INLINE vfloat vmlanp_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return vsub_vf_vf_vf(z, vmul_vf_vf_vf(x, y)); } +static INLINE vfloat vmax_vf_vf_vf(vfloat x, vfloat y) { return _mm_max_ps(x, y); } +static INLINE vfloat vmin_vf_vf_vf(vfloat x, vfloat y) { return _mm_min_ps(x, y); } + +static INLINE vopmask veq_vo_vf_vf(vfloat x, vfloat y) { return vreinterpret_vm_vf(_mm_cmpeq_ps(x, y)); } +static INLINE vopmask vneq_vo_vf_vf(vfloat x, vfloat y) { return vreinterpret_vm_vf(_mm_cmpneq_ps(x, y)); } +static INLINE vopmask vlt_vo_vf_vf(vfloat x, vfloat y) { return vreinterpret_vm_vf(_mm_cmplt_ps(x, y)); } +static INLINE vopmask vle_vo_vf_vf(vfloat x, vfloat y) { return vreinterpret_vm_vf(_mm_cmple_ps(x, y)); } +static INLINE vopmask vgt_vo_vf_vf(vfloat x, vfloat y) { return vreinterpret_vm_vf(_mm_cmpgt_ps(x, y)); } +static INLINE vopmask vge_vo_vf_vf(vfloat x, vfloat y) { return vreinterpret_vm_vf(_mm_cmpge_ps(x, y)); } + +static INLINE vint2 vadd_vi2_vi2_vi2(vint2 x, vint2 y) { return vadd_vi_vi_vi(x, y); } +static INLINE vint2 vsub_vi2_vi2_vi2(vint2 x, vint2 y) { return vsub_vi_vi_vi(x, y); } +static INLINE vint2 vneg_vi2_vi2(vint2 e) { return vsub_vi2_vi2_vi2(vcast_vi2_i(0), e); } + +static INLINE vint2 vand_vi2_vi2_vi2(vint2 x, vint2 y) { return vand_vi_vi_vi(x, y); } +static INLINE vint2 vandnot_vi2_vi2_vi2(vint2 x, vint2 y) { return vandnot_vi_vi_vi(x, y); } +static INLINE vint2 vor_vi2_vi2_vi2(vint2 x, vint2 y) { return vor_vi_vi_vi(x, y); } +static INLINE vint2 vxor_vi2_vi2_vi2(vint2 x, vint2 y) { return vxor_vi_vi_vi(x, y); } + +static INLINE vint2 vand_vi2_vo_vi2(vopmask x, vint2 y) { return vand_vi_vo_vi(x, y); } +static INLINE vint2 vandnot_vi2_vo_vi2(vopmask x, vint2 y) { return vandnot_vi_vo_vi(x, y); } + +static INLINE vint2 vsll_vi2_vi2_i(vint2 x, int c) { return vsll_vi_vi_i(x, c); } +static INLINE vint2 vsrl_vi2_vi2_i(vint2 x, int c) { return vsrl_vi_vi_i(x, c); } +static INLINE vint2 vsra_vi2_vi2_i(vint2 x, int c) { return vsra_vi_vi_i(x, c); } + +static INLINE vopmask veq_vo_vi2_vi2(vint2 x, vint2 y) { return _mm_cmpeq_epi32(x, y); } +static INLINE vopmask vgt_vo_vi2_vi2(vint2 x, vint2 y) { return _mm_cmpgt_epi32(x, y); } +static INLINE vint2 veq_vi2_vi2_vi2(vint2 x, vint2 y) { return _mm_cmpeq_epi32(x, y); } +static INLINE vint2 vgt_vi2_vi2_vi2(vint2 x, vint2 y) { return _mm_cmpgt_epi32(x, y); } + +#if CONFIG == 4 +static INLINE vint2 vsel_vi2_vo_vi2_vi2(vopmask m, vint2 x, vint2 y) { return _mm_blendv_epi8(y, x, m); } + +static INLINE vfloat vsel_vf_vo_vf_vf(vopmask m, vfloat x, vfloat y) { return _mm_blendv_ps(y, x, _mm_castsi128_ps(m)); } +#else +static INLINE vint2 vsel_vi2_vo_vi2_vi2(vopmask m, vint2 x, vint2 y) { + return vor_vi2_vi2_vi2(vand_vi2_vi2_vi2(m, x), vandnot_vi2_vi2_vi2(m, y)); +} + +static INLINE vfloat vsel_vf_vo_vf_vf(vopmask opmask, vfloat x, vfloat y) { + return _mm_or_ps(_mm_and_ps(_mm_castsi128_ps(opmask), x), _mm_andnot_ps(_mm_castsi128_ps(opmask), y)); +} +#endif + +static INLINE CONST vfloat vsel_vf_vo_f_f(vopmask o, float v1, float v0) { + return vsel_vf_vo_vf_vf(o, vcast_vf_f(v1), vcast_vf_f(v0)); +} + +static INLINE vfloat vsel_vf_vo_vo_f_f_f(vopmask o0, vopmask o1, float d0, float d1, float d2) { + return vsel_vf_vo_vf_vf(o0, vcast_vf_f(d0), vsel_vf_vo_f_f(o1, d1, d2)); +} + +static INLINE vfloat vsel_vf_vo_vo_vo_f_f_f_f(vopmask o0, vopmask o1, vopmask o2, float d0, float d1, float d2, float d3) { + return vsel_vf_vo_vf_vf(o0, vcast_vf_f(d0), vsel_vf_vo_vf_vf(o1, vcast_vf_f(d1), vsel_vf_vo_f_f(o2, d2, d3))); +} + +static INLINE vopmask visinf_vo_vf(vfloat d) { return veq_vo_vf_vf(vabs_vf_vf(d), vcast_vf_f(SLEEF_INFINITYf)); } +static INLINE vopmask vispinf_vo_vf(vfloat d) { return veq_vo_vf_vf(d, vcast_vf_f(SLEEF_INFINITYf)); } +static INLINE vopmask visminf_vo_vf(vfloat d) { return veq_vo_vf_vf(d, vcast_vf_f(-SLEEF_INFINITYf)); } +static INLINE vopmask visnan_vo_vf(vfloat d) { return vneq_vo_vf_vf(d, d); } + +static INLINE vfloat vload_vf_p(const float *ptr) { return _mm_load_ps(ptr); } +static INLINE vfloat vloadu_vf_p(const float *ptr) { return _mm_loadu_ps(ptr); } + +static INLINE void vstore_v_p_vf(float *ptr, vfloat v) { _mm_store_ps(ptr, v); } +static INLINE void vstoreu_v_p_vf(float *ptr, vfloat v) { _mm_storeu_ps(ptr, v); } + +static INLINE vfloat vgather_vf_p_vi2(const float *ptr, vint2 vi) { + int a[VECTLENSP]; + vstoreu_v_p_vi2(a, vi); + return _mm_set_ps(ptr[a[3]], ptr[a[2]], ptr[a[1]], ptr[a[0]]); +} + +// This function is for debugging +static INLINE float vcast_f_vf(vfloat v) { + float a[VECTLENSP]; + vstoreu_v_p_vf(a, v); + return a[0]; +} + +// + +#define PNMASK ((vdouble) { +0.0, -0.0 }) +#define NPMASK ((vdouble) { -0.0, +0.0 }) +#define PNMASKf ((vfloat) { +0.0f, -0.0f, +0.0f, -0.0f }) +#define NPMASKf ((vfloat) { -0.0f, +0.0f, -0.0f, +0.0f }) + +static INLINE vdouble vposneg_vd_vd(vdouble d) { return vreinterpret_vd_vm(vxor_vm_vm_vm(vreinterpret_vm_vd(d), vreinterpret_vm_vd(PNMASK))); } +static INLINE vdouble vnegpos_vd_vd(vdouble d) { return vreinterpret_vd_vm(vxor_vm_vm_vm(vreinterpret_vm_vd(d), vreinterpret_vm_vd(NPMASK))); } +static INLINE vfloat vposneg_vf_vf(vfloat d) { return vreinterpret_vf_vm(vxor_vm_vm_vm(vreinterpret_vm_vf(d), vreinterpret_vm_vf(PNMASKf))); } +static INLINE vfloat vnegpos_vf_vf(vfloat d) { return vreinterpret_vf_vm(vxor_vm_vm_vm(vreinterpret_vm_vf(d), vreinterpret_vm_vf(NPMASKf))); } + +#if CONFIG >= 3 +static INLINE vdouble vsubadd_vd_vd_vd(vdouble x, vdouble y) { return _mm_addsub_pd(x, y); } +static INLINE vfloat vsubadd_vf_vf_vf(vfloat x, vfloat y) { return _mm_addsub_ps(x, y); } +#else +static INLINE vdouble vsubadd_vd_vd_vd(vdouble x, vdouble y) { return vadd_vd_vd_vd(x, vnegpos_vd_vd(y)); } +static INLINE vfloat vsubadd_vf_vf_vf(vfloat x, vfloat y) { return vadd_vf_vf_vf(x, vnegpos_vf_vf(y)); } +#endif +static INLINE vdouble vmlsubadd_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return vsubadd_vd_vd_vd(vmul_vd_vd_vd(x, y), z); } +static INLINE vfloat vmlsubadd_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return vsubadd_vf_vf_vf(vmul_vf_vf_vf(x, y), z); } + +static INLINE vdouble vrev21_vd_vd(vdouble d0) { return _mm_shuffle_pd(d0, d0, 1); } +static INLINE vdouble vreva2_vd_vd(vdouble vd) { return vd; } + +static INLINE void vstream_v_p_vd(double *ptr, vdouble v) { _mm_stream_pd(ptr, v); } +static INLINE void vscatter2_v_p_i_i_vd(double *ptr, int offset, int step, vdouble v) { vstore_v_p_vd((double *)(&ptr[2*offset]), v); } +static INLINE void vsscatter2_v_p_i_i_vd(double *ptr, int offset, int step, vdouble v) { _mm_stream_pd((double *)(&ptr[2*offset]), v); } + +// + +static INLINE vfloat vrev21_vf_vf(vfloat d0) { return _mm_shuffle_ps(d0, d0, (2 << 6) | (3 << 4) | (0 << 2) | (1 << 0)); } +static INLINE vfloat vreva2_vf_vf(vfloat d0) { return _mm_shuffle_ps(d0, d0, (1 << 6) | (0 << 4) | (3 << 2) | (2 << 0)); } + +static INLINE void vstream_v_p_vf(float *ptr, vfloat v) { _mm_stream_ps(ptr, v); } + +static INLINE void vscatter2_v_p_i_i_vf(float *ptr, int offset, int step, vfloat v) { + _mm_storel_pd((double *)(ptr+(offset + step * 0)*2), vreinterpret_vd_vm(vreinterpret_vm_vf(v))); + _mm_storeh_pd((double *)(ptr+(offset + step * 1)*2), vreinterpret_vd_vm(vreinterpret_vm_vf(v))); +} + +static INLINE void vsscatter2_v_p_i_i_vf(float *ptr, int offset, int step, vfloat v) { + _mm_storel_pd((double *)(ptr+(offset + step * 0)*2), vreinterpret_vd_vm(vreinterpret_vm_vf(v))); + _mm_storeh_pd((double *)(ptr+(offset + step * 1)*2), vreinterpret_vd_vm(vreinterpret_vm_vf(v))); +} + +// + +static vquad loadu_vq_p(void *p) { + vquad vq; + memcpy(&vq, p, VECTLENDP * 16); + return vq; +} + +static INLINE vquad cast_vq_aq(vargquad aq) { + vquad vq; + memcpy(&vq, &aq, VECTLENDP * 16); + return vq; +} + +static INLINE vargquad cast_aq_vq(vquad vq) { + vargquad aq; + memcpy(&aq, &vq, VECTLENDP * 16); + return aq; +} + +static INLINE int vtestallzeros_i_vo64(vopmask g) { return _mm_movemask_epi8(g) == 0; } + +static INLINE vmask vsel_vm_vo64_vm_vm(vopmask o, vmask x, vmask y) { + return vor_vm_vm_vm(vand_vm_vm_vm(o, x), vandnot_vm_vm_vm(o, y)); +} + +static INLINE vmask vsub64_vm_vm_vm(vmask x, vmask y) { return _mm_sub_epi64(x, y); } +static INLINE vmask vneg64_vm_vm(vmask x) { return _mm_sub_epi64(vcast_vm_i_i(0, 0), x); } + +#define vsll64_vm_vm_i(x, c) _mm_slli_epi64(x, c) +#define vsrl64_vm_vm_i(x, c) _mm_srli_epi64(x, c) +//@#define vsll64_vm_vm_i(x, c) _mm_slli_epi64(x, c) +//@#define vsrl64_vm_vm_i(x, c) _mm_srli_epi64(x, c) + +static INLINE vopmask vgt64_vo_vm_vm(vmask x, vmask y) { + int64_t ax[2], ay[2]; + _mm_storeu_si128((__m128i *)ax, x); + _mm_storeu_si128((__m128i *)ay, y); + return _mm_set_epi64x(ax[1] > ay[1] ? -1 : 0, ax[0] > ay[0] ? -1 : 0); +} + +static INLINE vmask vcast_vm_vi(vint vi) { + vmask m = _mm_and_si128(_mm_shuffle_epi32(vi, (0 << 6) | (1 << 4) | (0 << 2) | (0 << 0)), _mm_set_epi32(0, -1, 0, -1)); + return vor_vm_vm_vm(vcastu_vm_vi(vgt_vo_vi_vi(vcast_vi_i(0), vi)), m); +} +static INLINE vint vcast_vi_vm(vmask vm) { return _mm_shuffle_epi32(vm, 0x08); } + +static INLINE vmask vreinterpret_vm_vi64(vint64 v) { return v; } +static INLINE vint64 vreinterpret_vi64_vm(vmask m) { return m; } +static INLINE vmask vreinterpret_vm_vu64(vuint64 v) { return v; } +static INLINE vuint64 vreinterpret_vu64_vm(vmask m) { return m; } diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/arch/helpersve.h b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/arch/helpersve.h new file mode 100644 index 00000000000..75965dc6d92 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/arch/helpersve.h @@ -0,0 +1,1115 @@ +/*********************************************************************/ +/* Copyright ARM Ltd. 2010 - 2024. */ +/* Distributed under the Boost Software License, Version 1.0. */ +/* (See accompanying file LICENSE.txt or copy at */ +/* http://www.boost.org/LICENSE_1_0.txt) */ +/*********************************************************************/ + +#if !defined(__ARM_FEATURE_SVE) && !defined(SLEEF_GENHEADER) +#error Please specify SVE flags. +#endif + +#if !defined(SLEEF_GENHEADER) +#include +#include + +#include "misc.h" +#endif // #if !defined(SLEEF_GENHEADER) + +#if defined(VECTLENDP) || defined(VECTLENSP) +#error VECTLENDP or VECTLENSP already defined +#endif + +#if CONFIG == 1 || CONFIG == 2 +// Vector length agnostic +#define VECTLENSP (svcntw()) +//@#define VECTLENSP (svcntw()) +#define VECTLENDP (svcntd()) +//@#define VECTLENDP (svcntd()) +#define ISANAME "AArch64 SVE" +#define ptrue svptrue_b8() +//@#define ptrue svptrue_b8() +#elif CONFIG == 8 +// 256-bit vector length +#define ISANAME "AArch64 SVE 256-bit" +#define LOG2VECTLENDP 2 +#define ptrue svptrue_pat_b8(SV_VL32) +#define DFTPRIORITY 20 +#elif CONFIG == 9 +// 512-bit vector length +#define ISANAME "AArch64 SVE 512-bit" +#define LOG2VECTLENDP 3 +#define ptrue svptrue_pat_b8(SV_VL64) +#define DFTPRIORITY 21 +#elif CONFIG == 10 +// 1024-bit vector length +#define ISANAME "AArch64 SVE 1024-bit" +#define LOG2VECTLENDP 4 +#define ptrue svptrue_pat_b8(SV_VL128) +#define DFTPRIORITY 22 +#elif CONFIG == 11 +// 2048-bit vector length +#define ISANAME "AArch64 SVE 2048-bit" +#define LOG2VECTLENDP 5 +#define ptrue svptrue_pat_b8(SV_VL256) +#define DFTPRIORITY 23 +#else +#error CONFIG macro invalid or not defined +#endif + +#ifdef LOG2VECTLENDP +// For DFT, VECTLENDP and VECTLENSP are not the size of the available +// vector length, but the size of the partial vectors utilized in the +// computation. The appropriate VECTLENDP and VECTLENSP are chosen by +// the dispatcher according to the value of svcntd(). + +#define LOG2VECTLENSP (LOG2VECTLENDP+1) +#define VECTLENDP (1 << LOG2VECTLENDP) +#define VECTLENSP (1 << LOG2VECTLENSP) +static INLINE int vavailability_i(int name) { return svcntd() >= VECTLENDP ? 3 : 0; } +#else +static INLINE int vavailability_i(int name) { return 3; } +#endif + +#define ENABLE_SP +//@#define ENABLE_SP +#define ENABLE_DP +//@#define ENABLE_DP + +#if CONFIG != 2 +#define ENABLE_FMA_SP +//@#define ENABLE_FMA_SP +#define ENABLE_FMA_DP +//@#define ENABLE_FMA_DP +//#define SPLIT_KERNEL // Benchmark comparison is needed to determine whether this option should be enabled. +#endif + +#define FULL_FP_ROUNDING +//@#define FULL_FP_ROUNDING +#define ACCURATE_SQRT +//@#define ACCURATE_SQRT + +// Type definitions + +// Mask definition +typedef svint32_t vmask; +typedef svbool_t vopmask; + +// Single precision definitions +typedef svfloat32_t vfloat; +typedef svint32_t vint2; + +// Double precision definitions +typedef svfloat64_t vdouble; +typedef svint32_t vint; + +typedef svint64_t vint64; +typedef svuint64_t vuint64; + +// Double-double data type with setter/getter functions +typedef svfloat64x2_t vdouble2; +static INLINE vdouble vd2getx_vd_vd2(vdouble2 v) { return svget2_f64(v, 0); } +static INLINE vdouble vd2gety_vd_vd2(vdouble2 v) { return svget2_f64(v, 1); } +static INLINE vdouble2 vd2setxy_vd2_vd_vd(vdouble x, vdouble y) { return svcreate2_f64(x, y); } +static INLINE vdouble2 vd2setx_vd2_vd2_vd(vdouble2 v, vdouble d) { return svset2_f64(v, 0, d); } +static INLINE vdouble2 vd2sety_vd2_vd2_vd(vdouble2 v, vdouble d) { return svset2_f64(v, 1, d); } + +// Double-float data type with setter/getter functions +typedef svfloat32x2_t vfloat2; +static INLINE vfloat vf2getx_vf_vf2(vfloat2 v) { return svget2_f32(v, 0); } +static INLINE vfloat vf2gety_vf_vf2(vfloat2 v) { return svget2_f32(v, 1); } +static INLINE vfloat2 vf2setxy_vf2_vf_vf(vfloat x, vfloat y) { return svcreate2_f32(x, y); } +static INLINE vfloat2 vf2setx_vf2_vf2_vf(vfloat2 v, vfloat d) { return svset2_f32(v, 0, d); } +static INLINE vfloat2 vf2sety_vf2_vf2_vf(vfloat2 v, vfloat d) { return svset2_f32(v, 1, d); } + +typedef svint32x2_t vquad; +static INLINE vmask vqgetx_vm_vq(vquad v) { return svget2_s32(v, 0); } +static INLINE vmask vqgety_vm_vq(vquad v) { return svget2_s32(v, 1); } +static INLINE vquad vqsetxy_vq_vm_vm(vmask x, vmask y) { return svcreate2_s32(x, y); } +static INLINE vquad vqsetx_vq_vq_vm(vquad v, vmask x) { return svset2_s32(v, 0, x); } +static INLINE vquad vqsety_vq_vq_vm(vquad v, vmask y) { return svset2_s32(v, 1, y); } + +typedef vquad vargquad; + +// Auxiliary data types + +typedef svfloat64x2_t di_t; + +static INLINE vdouble digetd_vd_di(di_t d) { return svget2_f64(d, 0); } +static INLINE vint digeti_vi_di(di_t d) { return svreinterpret_s32_f64(svget2_f64(d, 1)); } +static INLINE di_t disetdi_di_vd_vi(vdouble d, vint i) { + return svcreate2_f64(d, svreinterpret_f64_s32(i)); +} + +// + +typedef svfloat32x2_t fi_t; + +static INLINE vfloat figetd_vf_di(fi_t d) { return svget2_f32(d, 0); } +static INLINE vint2 figeti_vi2_di(fi_t d) { return svreinterpret_s32_f32(svget2_f32(d, 1)); } +static INLINE fi_t fisetdi_fi_vf_vi2(vfloat d, vint2 i) { + return svcreate2_f32(d, svreinterpret_f32_s32(i)); +} + +// + +typedef svfloat64x3_t ddi_t; + +static INLINE vdouble2 ddigetdd_vd2_ddi(ddi_t d) { + return svcreate2_f64(svget3_f64(d, 0), svget3_f64(d, 1)); +} +static INLINE vint ddigeti_vi_ddi(ddi_t d) { return svreinterpret_s32_f64(svget3_f64(d, 2)); } +static INLINE ddi_t ddisetddi_ddi_vd2_vi(vdouble2 v, vint i) { + return svcreate3_f64(svget2_f64(v, 0), svget2_f64(v, 1), + svreinterpret_f64_s32(i)); +} +static INLINE ddi_t ddisetdd_ddi_ddi_vd2(ddi_t ddi, vdouble2 v) { + return svcreate3_f64(svget2_f64(v, 0), svget2_f64(v, 1), svget3_f64(ddi, 2)); +} + +// + +typedef svfloat32x3_t dfi_t; + +static INLINE vfloat2 dfigetdf_vf2_dfi(dfi_t d) { + return svcreate2_f32(svget3_f32(d, 0), svget3_f32(d, 1)); +} +static INLINE vint2 dfigeti_vi2_dfi(dfi_t d) { return svreinterpret_s32_f32(svget3_f32(d, 2)); } +static INLINE dfi_t dfisetdfi_dfi_vf2_vi2(vfloat2 v, vint2 i) { + return svcreate3_f32(svget2_f32(v, 0), svget2_f32(v, 1), + svreinterpret_f32_s32(i)); +} +static INLINE dfi_t dfisetdf_dfi_dfi_vf2(dfi_t dfi, vfloat2 v) { + return svcreate3_f32(svget2_f32(v, 0), svget2_f32(v, 1), svget3_f32(dfi, 2)); +} + +// + +typedef svfloat64x4_t dd2; + +static INLINE dd2 dd2setab_dd2_vd2_vd2(vdouble2 a, vdouble2 b) { + return svcreate4_f64(svget2_f64(a, 0), svget2_f64(a, 1), + svget2_f64(b, 0), svget2_f64(b, 1)); +} +static INLINE vdouble2 dd2geta_vd2_dd2(dd2 d) { + return svcreate2_f64(svget4_f64(d, 0), svget4_f64(d, 1)); +} +static INLINE vdouble2 dd2getb_vd2_dd2(dd2 d) { + return svcreate2_f64(svget4_f64(d, 2), svget4_f64(d, 3)); +} + +// + +typedef svfloat32x4_t df2; + +static INLINE df2 df2setab_df2_vf2_vf2(vfloat2 a, vfloat2 b) { + return svcreate4_f32(svget2_f32(a, 0), svget2_f32(a, 1), + svget2_f32(b, 0), svget2_f32(b, 1)); +} +static INLINE vfloat2 df2geta_vf2_df2(df2 d) { + return svcreate2_f32(svget4_f32(d, 0), svget4_f32(d, 1)); +} +static INLINE vfloat2 df2getb_vf2_df2(df2 d) { + return svcreate2_f32(svget4_f32(d, 2), svget4_f32(d, 3)); +} + +// + +typedef svfloat64x3_t vdouble3; + +static INLINE vdouble vd3getx_vd_vd3(vdouble3 v) { return svget3_f64(v, 0); } +static INLINE vdouble vd3gety_vd_vd3(vdouble3 v) { return svget3_f64(v, 1); } +static INLINE vdouble vd3getz_vd_vd3(vdouble3 v) { return svget3_f64(v, 2); } +static INLINE vdouble3 vd3setxyz_vd3_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return svcreate3_f64(x, y, z); } +static INLINE vdouble3 vd3setx_vd3_vd3_vd(vdouble3 v, vdouble d) { return svset3_f64(v, 0, d); } +static INLINE vdouble3 vd3sety_vd3_vd3_vd(vdouble3 v, vdouble d) { return svset3_f64(v, 1, d); } +static INLINE vdouble3 vd3setz_vd3_vd3_vd(vdouble3 v, vdouble d) { return svset3_f64(v, 2, d); } + +// + +typedef svfloat64x4_t tdx; + +static INLINE vmask tdxgete_vm_tdx(tdx t) { + return svreinterpret_s32_f64(svget4_f64(t, 0)); +} +static INLINE vdouble3 tdxgetd3_vd3_tdx(tdx t) { + return svcreate3_f64(svget4_f64(t, 1), svget4_f64(t, 2), svget4_f64(t, 3)); +} +static INLINE vdouble tdxgetd3x_vd_tdx(tdx t) { return svget4_f64(t, 1); } +static INLINE vdouble tdxgetd3y_vd_tdx(tdx t) { return svget4_f64(t, 2); } +static INLINE vdouble tdxgetd3z_vd_tdx(tdx t) { return svget4_f64(t, 3); } +static INLINE tdx tdxsete_tdx_tdx_vm(tdx t, vmask e) { + return svset4_f64(t, 0, svreinterpret_f64_s32(e)); +} +static INLINE tdx tdxsetd3_tdx_tdx_vd3(tdx t, vdouble3 d3) { + return svcreate4_f64(svget4_f64(t, 0), svget3_f64(d3, 0), svget3_f64(d3, 1), svget3_f64(d3, 2)); +} +static INLINE tdx tdxsetx_tdx_tdx_vd(tdx t, vdouble x) { return svset4_f64(t, 1, x); } +static INLINE tdx tdxsety_tdx_tdx_vd(tdx t, vdouble y) { return svset4_f64(t, 2, y); } +static INLINE tdx tdxsetz_tdx_tdx_vd(tdx t, vdouble z) { return svset4_f64(t, 3, z); } +static INLINE tdx tdxsetxyz_tdx_tdx_vd_vd_vd(tdx t, vdouble x, vdouble y, vdouble z) { + return svcreate4_f64(svget4_f64(t, 0), x, y, z); +} + +static INLINE tdx tdxseted3_tdx_vm_vd3(vmask e, vdouble3 d3) { + return svcreate4_f64(svreinterpret_f64_s32(e), svget3_f64(d3, 0), svget3_f64(d3, 1), svget3_f64(d3, 2)); +} +static INLINE tdx tdxsetexyz_tdx_vm_vd_vd_vd(vmask e, vdouble x, vdouble y, vdouble z) { + return svcreate4_f64(svreinterpret_f64_s32(e), x, y, z); +} + +// + +typedef svfloat64x4_t tdi_t; + +static INLINE vdouble3 tdigettd_vd3_tdi(tdi_t d) { + return svcreate3_f64(svget4_f64(d, 0), svget4_f64(d, 1), svget4_f64(d, 2)); +} +static INLINE vdouble tdigetx_vd_tdi(tdi_t d) { return svget4_f64(d, 0); } +static INLINE vint tdigeti_vi_tdi(tdi_t d) { return svreinterpret_s32_f64(svget4_f64(d, 3)); } +static INLINE tdi_t tdisettdi_tdi_vd3_vi(vdouble3 v, vint i) { + return svcreate4_f64(svget3_f64(v, 0), svget3_f64(v, 1), svget3_f64(v, 2), + svreinterpret_f64_s32(i)); +} +static INLINE tdi_t tdisettd_tdi_tdi_vd3(tdi_t tdi, vdouble3 v) { + return svcreate4_f64(svget3_f64(v, 0), svget3_f64(v, 1), svget3_f64(v, 2), svget4_f64(tdi, 3)); +} + +// + +// masking predicates +#define ALL_TRUE_MASK svdup_n_s32(0xffffffff) +#define ALL_FALSE_MASK svdup_n_s32(0x0) +//@#define ALL_TRUE_MASK svdup_n_s32(0xffffffff) +//@#define ALL_FALSE_MASK svdup_n_s32(0x0) + +static INLINE void vprefetch_v_p(const void *ptr) {} + +// +// +// +// Test if all lanes are active +// +// +// +static INLINE int vtestallones_i_vo32(vopmask g) { + svbool_t pg = svptrue_b32(); + return (svcntp_b32(pg, g) == svcntw()); +} + +static INLINE int vtestallones_i_vo64(vopmask g) { + svbool_t pg = svptrue_b64(); + return (svcntp_b64(pg, g) == svcntd()); +} +// +// +// +// +// +// + +// Vector load / store +static INLINE void vstoreu_v_p_vi2(int32_t *p, vint2 v) { svst1_s32(ptrue, p, v); } + +static INLINE vfloat vload_vf_p(const float *ptr) { + return svld1_f32(ptrue, ptr); +} +static INLINE vfloat vloadu_vf_p(const float *ptr) { + return svld1_f32(ptrue, ptr); +} +static INLINE void vstoreu_v_p_vf(float *ptr, vfloat v) { + svst1_f32(ptrue, ptr, v); +} + +// Basic logical operations for mask +static INLINE vmask vand_vm_vm_vm(vmask x, vmask y) { + return svand_s32_x(ptrue, x, y); +} +static INLINE vmask vandnot_vm_vm_vm(vmask x, vmask y) { + return svbic_s32_x(ptrue, y, x); +} +static INLINE vmask vor_vm_vm_vm(vmask x, vmask y) { + return svorr_s32_x(ptrue, x, y); +} +static INLINE vmask vxor_vm_vm_vm(vmask x, vmask y) { + return sveor_s32_x(ptrue, x, y); +} + +static INLINE vmask vadd64_vm_vm_vm(vmask x, vmask y) { + return svreinterpret_s32_s64( + svadd_s64_x(ptrue, svreinterpret_s64_s32(x), + svreinterpret_s64_s32(y))); +} + +// Mask <--> single precision reinterpret +static INLINE vmask vreinterpret_vm_vf(vfloat vf) { + return svreinterpret_s32_f32(vf); +} +static INLINE vfloat vreinterpret_vf_vm(vmask vm) { + return svreinterpret_f32_s32(vm); +} +static INLINE vfloat vreinterpret_vf_vi2(vint2 vm) { + return svreinterpret_f32_s32(vm); +} +static INLINE vint2 vreinterpret_vi2_vf(vfloat vf) { + return svreinterpret_s32_f32(vf); +} +static INLINE vint2 vcast_vi2_vm(vmask vm) { return vm; } +static INLINE vmask vcast_vm_vi2(vint2 vi) { return vi; } + +// Conditional select +static INLINE vint2 vsel_vi2_vm_vi2_vi2(vmask m, vint2 x, vint2 y) { + return svsel_s32(svcmpeq_s32(ptrue, m, ALL_TRUE_MASK), x, y); +} + +/****************************************/ +/* Single precision FP operations */ +/****************************************/ +// Broadcast +static INLINE vfloat vcast_vf_f(float f) { return svdup_n_f32(f); } + +// Add, Sub, Mul +static INLINE vfloat vadd_vf_vf_vf(vfloat x, vfloat y) { + return svadd_f32_x(ptrue, x, y); +} +static INLINE vfloat vsub_vf_vf_vf(vfloat x, vfloat y) { + return svsub_f32_x(ptrue, x, y); +} +static INLINE vfloat vmul_vf_vf_vf(vfloat x, vfloat y) { + return svmul_f32_x(ptrue, x, y); +} + +// |x|, -x +static INLINE vfloat vabs_vf_vf(vfloat f) { return svabs_f32_x(ptrue, f); } +static INLINE vfloat vneg_vf_vf(vfloat f) { return svneg_f32_x(ptrue, f); } + +// max, min +static INLINE vfloat vmax_vf_vf_vf(vfloat x, vfloat y) { + return svmax_f32_x(ptrue, x, y); +} +static INLINE vfloat vmin_vf_vf_vf(vfloat x, vfloat y) { + return svmin_f32_x(ptrue, x, y); +} + +// int <--> float conversions +static INLINE vint2 vtruncate_vi2_vf(vfloat vf) { + return svcvt_s32_f32_x(ptrue, vf); +} +static INLINE vfloat vcast_vf_vi2(vint2 vi) { + return svcvt_f32_s32_x(ptrue, vi); +} +static INLINE vint2 vcast_vi2_i(int i) { return svdup_n_s32(i); } +static INLINE vint2 vrint_vi2_vf(vfloat d) { + return svcvt_s32_f32_x(ptrue, svrintn_f32_x(ptrue, d)); +} + +#if CONFIG == 1 +// Multiply accumulate: z = z + x * y +static INLINE vfloat vmla_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { + return svmad_f32_x(ptrue, x, y, z); +} +// Multiply subtract: z = z - x * y +static INLINE vfloat vmlanp_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { + return svmsb_f32_x(ptrue, x, y, z); +} +static INLINE vfloat vmlapn_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { + return svnmsb_f32_x(ptrue, x, y, z); +} +#else +static INLINE vfloat vmla_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return vadd_vf_vf_vf(vmul_vf_vf_vf(x, y), z); } +static INLINE vfloat vmlanp_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return vsub_vf_vf_vf(z, vmul_vf_vf_vf(x, y)); } +static INLINE vfloat vmlapn_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return vsub_vf_vf_vf(vmul_vf_vf_vf(x, y), z); } +#endif + +// fused multiply add / sub +static INLINE vfloat vfma_vf_vf_vf_vf(vfloat x, vfloat y, + vfloat z) { // z + x * y + return svmad_f32_x(ptrue, x, y, z); +} +static INLINE vfloat vfmanp_vf_vf_vf_vf(vfloat x, vfloat y, + vfloat z) { // z - x * y + return svmsb_f32_x(ptrue, x, y, z); +} +static INLINE vfloat vfmapn_vf_vf_vf_vf(vfloat x, vfloat y, + vfloat z) { // x * y - z + return svnmsb_f32_x(ptrue, x, y, z); +} + +// conditional select +static INLINE vfloat vsel_vf_vo_vf_vf(vopmask mask, vfloat x, vfloat y) { + return svsel_f32(mask, x, y); +} + +// Reciprocal 1/x, Division, Square root +static INLINE vfloat vdiv_vf_vf_vf(vfloat n, vfloat d) { +#ifndef SLEEF_ENABLE_ALTDIV + return svdiv_f32_x(ptrue, n, d); +#else + // Finite numbers (including denormal) only, gives mostly correctly rounded result + vfloat t, u, x, y; + svuint32_t i0, i1; + i0 = svand_u32_x(ptrue, svreinterpret_u32_f32(n), svdup_n_u32(0x7c000000)); + i1 = svand_u32_x(ptrue, svreinterpret_u32_f32(d), svdup_n_u32(0x7c000000)); + i0 = svsub_u32_x(ptrue, svdup_n_u32(0x7d000000), svlsr_n_u32_x(ptrue, svadd_u32_x(ptrue, i0, i1), 1)); + t = svreinterpret_f32_u32(i0); + y = svmul_f32_x(ptrue, d, t); + x = svmul_f32_x(ptrue, n, t); + t = svrecpe_f32(y); + t = svmul_f32_x(ptrue, t, svrecps_f32(y, t)); + t = svmul_f32_x(ptrue, t, svrecps_f32(y, t)); + u = svmul_f32_x(ptrue, x, t); + u = svmad_f32_x(ptrue, svmsb_f32_x(ptrue, y, u, x), t, u); + return u; +#endif +} +static INLINE vfloat vrec_vf_vf(vfloat d) { +#ifndef SLEEF_ENABLE_ALTDIV + return svdivr_n_f32_x(ptrue, d, 1.0f); +#else + return vsel_vf_vo_vf_vf(svcmpeq_f32(ptrue, vabs_vf_vf(d), vcast_vf_f(SLEEF_INFINITYf)), + vcast_vf_f(0), vdiv_vf_vf_vf(vcast_vf_f(1.0f), d)); +#endif +} +static INLINE vfloat vsqrt_vf_vf(vfloat d) { +#ifndef SLEEF_ENABLE_ALTSQRT + return svsqrt_f32_x(ptrue, d); +#else + // Gives correctly rounded result for all input range + vfloat w, x, y, z; + + y = svrsqrte_f32(d); + x = vmul_vf_vf_vf(d, y); w = vmul_vf_vf_vf(vcast_vf_f(0.5), y); + y = vfmanp_vf_vf_vf_vf(x, w, vcast_vf_f(0.5)); + x = vfma_vf_vf_vf_vf(x, y, x); w = vfma_vf_vf_vf_vf(w, y, w); + + y = vfmanp_vf_vf_vf_vf(x, w, vcast_vf_f(1.5)); w = vadd_vf_vf_vf(w, w); + w = vmul_vf_vf_vf(w, y); + x = vmul_vf_vf_vf(w, d); + y = vfmapn_vf_vf_vf_vf(w, d, x); z = vfmanp_vf_vf_vf_vf(w, x, vcast_vf_f(1)); + z = vfmanp_vf_vf_vf_vf(w, y, z); w = vmul_vf_vf_vf(vcast_vf_f(0.5), x); + w = vfma_vf_vf_vf_vf(w, z, y); + w = vadd_vf_vf_vf(w, x); + + return svsel_f32(svorr_b_z(ptrue, svcmpeq_f32(ptrue, d, vcast_vf_f(0)), + svcmpeq_f32(ptrue, d, vcast_vf_f(SLEEF_INFINITYf))), d, w); +#endif +} +// +// +// +// +// +// +static INLINE CONST vfloat vsel_vf_vo_f_f(vopmask o, float v1, float v0) { + return vsel_vf_vo_vf_vf(o, vcast_vf_f(v1), vcast_vf_f(v0)); +} + +static INLINE vfloat vsel_vf_vo_vo_f_f_f(vopmask o0, vopmask o1, float d0, float d1, float d2) { + return vsel_vf_vo_vf_vf(o0, vcast_vf_f(d0), vsel_vf_vo_f_f(o1, d1, d2)); +} + +static INLINE vfloat vsel_vf_vo_vo_vo_f_f_f_f(vopmask o0, vopmask o1, vopmask o2, float d0, float d1, float d2, float d3) { + return vsel_vf_vo_vf_vf(o0, vcast_vf_f(d0), vsel_vf_vo_vf_vf(o1, vcast_vf_f(d1), vsel_vf_vo_f_f(o2, d2, d3))); +} +// +// +// +// +// +// + +// truncate +static INLINE vfloat vtruncate_vf_vf(vfloat vd) { + return svrintz_f32_x(ptrue, vd); +} + +// +// +// +// Round float +// +// +// +static INLINE vfloat vrint_vf_vf(vfloat vf) { + return svrintn_f32_x(svptrue_b32(), vf); +} +// +// +// +// +// +// + +/***************************************/ +/* Single precision integer operations */ +/***************************************/ + +// Add, Sub, Neg (-x) +static INLINE vint2 vadd_vi2_vi2_vi2(vint2 x, vint2 y) { + return svadd_s32_x(ptrue, x, y); +} +static INLINE vint2 vsub_vi2_vi2_vi2(vint2 x, vint2 y) { + return svsub_s32_x(ptrue, x, y); +} +static INLINE vint2 vneg_vi2_vi2(vint2 e) { return svneg_s32_x(ptrue, e); } + +// Logical operations +static INLINE vint2 vand_vi2_vi2_vi2(vint2 x, vint2 y) { + return svand_s32_x(ptrue, x, y); +} +static INLINE vint2 vandnot_vi2_vi2_vi2(vint2 x, vint2 y) { + return svbic_s32_x(ptrue, y, x); +} +static INLINE vint2 vor_vi2_vi2_vi2(vint2 x, vint2 y) { + return svorr_s32_x(ptrue, x, y); +} +static INLINE vint2 vxor_vi2_vi2_vi2(vint2 x, vint2 y) { + return sveor_s32_x(ptrue, x, y); +} + +// Shifts +#define vsll_vi2_vi2_i(x, c) svlsl_n_s32_x(ptrue, x, c) +//@#define vsll_vi2_vi2_i(x, c) svlsl_n_s32_x(ptrue, x, c) +#define vsrl_vi2_vi2_i(x, c) \ + svreinterpret_s32_u32(svlsr_n_u32_x(ptrue, svreinterpret_u32_s32(x), c)) +//@#define vsrl_vi2_vi2_i(x, c) svreinterpret_s32_u32(svlsr_n_u32_x(ptrue, svreinterpret_u32_s32(x), c)) +#define vsra_vi2_vi2_i(x, c) svasr_n_s32_x(ptrue, x, c) +//@#define vsra_vi2_vi2_i(x, c) svasr_n_s32_x(ptrue, x, c) + +// Comparison returning integers +static INLINE vint2 vgt_vi2_vi2_vi2(vint2 x, vint2 y) { + return svsel_s32(svcmpgt_s32(ptrue, x, y), ALL_TRUE_MASK, ALL_FALSE_MASK); +} + +// conditional select +static INLINE vint2 vsel_vi2_vo_vi2_vi2(vopmask m, vint2 x, vint2 y) { + return svsel_s32(m, x, y); +} + +/****************************************/ +/* opmask operations */ +/****************************************/ +// single precision FP +static INLINE vopmask veq_vo_vf_vf(vfloat x, vfloat y) { + return svcmpeq_f32(ptrue, x, y); +} +static INLINE vopmask vneq_vo_vf_vf(vfloat x, vfloat y) { + return svcmpne_f32(ptrue, x, y); +} +static INLINE vopmask vlt_vo_vf_vf(vfloat x, vfloat y) { + return svcmplt_f32(ptrue, x, y); +} +static INLINE vopmask vle_vo_vf_vf(vfloat x, vfloat y) { + return svcmple_f32(ptrue, x, y); +} +static INLINE vopmask vgt_vo_vf_vf(vfloat x, vfloat y) { + return svcmpgt_f32(ptrue, x, y); +} +static INLINE vopmask vge_vo_vf_vf(vfloat x, vfloat y) { + return svcmpge_f32(ptrue, x, y); +} +static INLINE vopmask visinf_vo_vf(vfloat d) { + return svcmpeq_n_f32(ptrue, vabs_vf_vf(d), SLEEF_INFINITYf); +} +static INLINE vopmask vispinf_vo_vf(vfloat d) { + return svcmpeq_n_f32(ptrue, d, SLEEF_INFINITYf); +} +static INLINE vopmask visminf_vo_vf(vfloat d) { + return svcmpeq_n_f32(ptrue, d, -SLEEF_INFINITYf); +} +static INLINE vopmask visnan_vo_vf(vfloat d) { return vneq_vo_vf_vf(d, d); } + +// integers +static INLINE vopmask veq_vo_vi2_vi2(vint2 x, vint2 y) { + return svcmpeq_s32(ptrue, x, y); +} +static INLINE vopmask vgt_vo_vi2_vi2(vint2 x, vint2 y) { + return svcmpgt_s32(ptrue, x, y); +} + +// logical opmask +static INLINE vopmask vand_vo_vo_vo(vopmask x, vopmask y) { + return svand_b_z(ptrue, x, y); +} +static INLINE vopmask vandnot_vo_vo_vo(vopmask x, vopmask y) { + return svbic_b_z(ptrue, y, x); +} +static INLINE vopmask vor_vo_vo_vo(vopmask x, vopmask y) { + return svorr_b_z(ptrue, x, y); +} +static INLINE vopmask vxor_vo_vo_vo(vopmask x, vopmask y) { + return sveor_b_z(ptrue, x, y); +} + +static INLINE vint2 vand_vi2_vo_vi2(vopmask x, vint2 y) { + // This needs to be zeroing to prevent asinf and atanf denormal test + // failing. + return svand_s32_z(x, y, y); +} + +// bitmask logical operations +static INLINE vmask vand_vm_vo32_vm(vopmask x, vmask y) { + return svsel_s32(x, y, ALL_FALSE_MASK); +} +static INLINE vmask vandnot_vm_vo32_vm(vopmask x, vmask y) { + return svsel_s32(x, ALL_FALSE_MASK, y); +} +static INLINE vmask vor_vm_vo32_vm(vopmask x, vmask y) { + return svsel_s32(x, ALL_TRUE_MASK, y); +} + +// broadcast bitmask +static INLINE vmask vcast_vm_i_i(int i0, int i1) { + return svreinterpret_s32_u64( + svdup_n_u64((0xffffffff & (uint64_t)i1) | (((uint64_t)i0) << 32))); +} + +static INLINE vmask vcast_vm_i64(int64_t i) { + return svreinterpret_s32_u64(svdup_n_u64((uint64_t)i)); +} +static INLINE vmask vcast_vm_u64(uint64_t i) { + return svreinterpret_s32_u64(svdup_n_u64(i)); +} + +/*********************************/ +/* SVE for double precision math */ +/*********************************/ + +// Vector load/store +static INLINE vdouble vload_vd_p(const double *ptr) { + return svld1_f64(ptrue, ptr); +} +static INLINE vdouble vloadu_vd_p(const double *ptr) { + return svld1_f64(ptrue, ptr); +} +static INLINE void vstoreu_v_p_vd(double *ptr, vdouble v) { + svst1_f64(ptrue, ptr, v); +} + +static INLINE void vstoreu_v_p_vi(int *ptr, vint v) { + svst1w_s64(ptrue, ptr, svreinterpret_s64_s32(v)); +} +static vint vloadu_vi_p(int32_t *p) { + return svreinterpret_s32_s64(svld1uw_s64(ptrue, (uint32_t *)p)); +} + +// Reinterpret +static INLINE vdouble vreinterpret_vd_vm(vmask vm) { + return svreinterpret_f64_s32(vm); +} +static INLINE vmask vreinterpret_vm_vd(vdouble vd) { + return svreinterpret_s32_f64(vd); +} +static INLINE vint2 vcastu_vm_vi(vint x) { + return svreinterpret_s32_s64( + svlsl_n_s64_x(ptrue, svreinterpret_s64_s32(x), 32)); +} +static INLINE vint vcastu_vi_vm(vint2 x) { + return svreinterpret_s32_u64( + svlsr_n_u64_x(ptrue, svreinterpret_u64_s32(x), 32)); +} +static INLINE vdouble vcast_vd_vi(vint vi) { + return svcvt_f64_s32_x(ptrue, vi); +} + +// Splat +static INLINE vdouble vcast_vd_d(double d) { return svdup_n_f64(d); } + +// Conditional select +static INLINE vdouble vsel_vd_vo_vd_vd(vopmask o, vdouble x, vdouble y) { + return svsel_f64(o, x, y); +} + +static INLINE CONST vdouble vsel_vd_vo_d_d(vopmask o, double v1, double v0) { + return vsel_vd_vo_vd_vd(o, vcast_vd_d(v1), vcast_vd_d(v0)); +} + +static INLINE vdouble vsel_vd_vo_vo_d_d_d(vopmask o0, vopmask o1, double d0, double d1, double d2) { + return vsel_vd_vo_vd_vd(o0, vcast_vd_d(d0), vsel_vd_vo_d_d(o1, d1, d2)); +} + +static INLINE vdouble vsel_vd_vo_vo_vo_d_d_d_d(vopmask o0, vopmask o1, vopmask o2, double d0, double d1, double d2, double d3) { + return vsel_vd_vo_vd_vd(o0, vcast_vd_d(d0), vsel_vd_vo_vd_vd(o1, vcast_vd_d(d1), vsel_vd_vo_d_d(o2, d2, d3))); +} + +static INLINE vint vsel_vi_vo_vi_vi(vopmask o, vint x, vint y) { + return svsel_s32(o, x, y); +} +// truncate +static INLINE vdouble vtruncate_vd_vd(vdouble vd) { + return svrintz_f64_x(ptrue, vd); +} +static INLINE vint vtruncate_vi_vd(vdouble vd) { + return svcvt_s32_f64_x(ptrue, vd); +} +static INLINE vint vrint_vi_vd(vdouble vd) { + return svcvt_s32_f64_x(ptrue, svrintn_f64_x(ptrue, vd)); +} +static INLINE vdouble vrint_vd_vd(vdouble vd) { + return svrintn_f64_x(ptrue, vd); +} + +// FP math operations +static INLINE vdouble vadd_vd_vd_vd(vdouble x, vdouble y) { + return svadd_f64_x(ptrue, x, y); +} +static INLINE vdouble vsub_vd_vd_vd(vdouble x, vdouble y) { + return svsub_f64_x(ptrue, x, y); +} +static INLINE vdouble vneg_vd_vd(vdouble x) { return svneg_f64_x(ptrue, x); } +static INLINE vdouble vmul_vd_vd_vd(vdouble x, vdouble y) { + return svmul_f64_x(ptrue, x, y); +} +static INLINE vdouble vabs_vd_vd(vdouble x) { return svabs_f64_x(ptrue, x); } +static INLINE vdouble vmax_vd_vd_vd(vdouble x, vdouble y) { + return svmax_f64_x(ptrue, x, y); +} +static INLINE vdouble vmin_vd_vd_vd(vdouble x, vdouble y) { + return svmin_f64_x(ptrue, x, y); +} + +#if CONFIG == 1 +// Multiply accumulate / subtract +static INLINE vdouble vmla_vd_vd_vd_vd(vdouble x, vdouble y, + vdouble z) { // z = x*y + z + return svmad_f64_x(ptrue, x, y, z); +} +static INLINE vdouble vmlapn_vd_vd_vd_vd(vdouble x, vdouble y, + vdouble z) { // z = x * y - z + return svnmsb_f64_x(ptrue, x, y, z); +} +static INLINE vdouble vmlanp_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { + return svmsb_f64_x(ptrue, x, y, z); +} +#else +static INLINE vdouble vmla_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return vadd_vd_vd_vd(vmul_vd_vd_vd(x, y), z); } +static INLINE vdouble vmlapn_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return vsub_vd_vd_vd(vmul_vd_vd_vd(x, y), z); } +#endif + +static INLINE vdouble vfma_vd_vd_vd_vd(vdouble x, vdouble y, + vdouble z) { // z + x * y + return svmad_f64_x(ptrue, x, y, z); +} +static INLINE vdouble vfmanp_vd_vd_vd_vd(vdouble x, vdouble y, + vdouble z) { // z - x * y + return svmsb_f64_x(ptrue, x, y, z); +} +static INLINE vdouble vfmapn_vd_vd_vd_vd(vdouble x, vdouble y, + vdouble z) { // x * y - z + return svnmsb_f64_x(ptrue, x, y, z); +} + +// Reciprocal 1/x, Division, Square root +static INLINE vdouble vdiv_vd_vd_vd(vdouble n, vdouble d) { +#ifndef SLEEF_ENABLE_ALTDIV + return svdiv_f64_x(ptrue, n, d); +#else + // Finite numbers (including denormal) only, gives mostly correctly rounded result + vdouble t, u, x, y; + svuint64_t i0, i1; + i0 = svand_u64_x(ptrue, svreinterpret_u64_f64(n), svdup_n_u64(0x7fc0000000000000L)); + i1 = svand_u64_x(ptrue, svreinterpret_u64_f64(d), svdup_n_u64(0x7fc0000000000000L)); + i0 = svsub_u64_x(ptrue, svdup_n_u64(0x7fd0000000000000L), svlsr_n_u64_x(ptrue, svadd_u64_x(ptrue, i0, i1), 1)); + t = svreinterpret_f64_u64(i0); + y = svmul_f64_x(ptrue, d, t); + x = svmul_f64_x(ptrue, n, t); + t = svrecpe_f64(y); + t = svmul_f64_x(ptrue, t, svrecps_f64(y, t)); + t = svmul_f64_x(ptrue, t, svrecps_f64(y, t)); + t = svmul_f64_x(ptrue, t, svrecps_f64(y, t)); + u = svmul_f64_x(ptrue, x, t); + u = svmad_f64_x(ptrue, svmsb_f64_x(ptrue, y, u, x), t, u); + return u; +#endif +} +static INLINE vdouble vrec_vd_vd(vdouble d) { +#ifndef SLEEF_ENABLE_ALTDIV + return svdivr_n_f64_x(ptrue, d, 1.0); +#else + return vsel_vd_vo_vd_vd(svcmpeq_f64(ptrue, vabs_vd_vd(d), vcast_vd_d(SLEEF_INFINITY)), + vcast_vd_d(0), vdiv_vd_vd_vd(vcast_vd_d(1.0f), d)); +#endif +} +static INLINE vdouble vsqrt_vd_vd(vdouble d) { +#ifndef SLEEF_ENABLE_ALTSQRT + return svsqrt_f64_x(ptrue, d); +#else + // Gives correctly rounded result for all input range + vdouble w, x, y, z; + + y = svrsqrte_f64(d); + x = vmul_vd_vd_vd(d, y); w = vmul_vd_vd_vd(vcast_vd_d(0.5), y); + y = vfmanp_vd_vd_vd_vd(x, w, vcast_vd_d(0.5)); + x = vfma_vd_vd_vd_vd(x, y, x); w = vfma_vd_vd_vd_vd(w, y, w); + y = vfmanp_vd_vd_vd_vd(x, w, vcast_vd_d(0.5)); + x = vfma_vd_vd_vd_vd(x, y, x); w = vfma_vd_vd_vd_vd(w, y, w); + + y = vfmanp_vd_vd_vd_vd(x, w, vcast_vd_d(1.5)); w = vadd_vd_vd_vd(w, w); + w = vmul_vd_vd_vd(w, y); + x = vmul_vd_vd_vd(w, d); + y = vfmapn_vd_vd_vd_vd(w, d, x); z = vfmanp_vd_vd_vd_vd(w, x, vcast_vd_d(1)); + z = vfmanp_vd_vd_vd_vd(w, y, z); w = vmul_vd_vd_vd(vcast_vd_d(0.5), x); + w = vfma_vd_vd_vd_vd(w, z, y); + w = vadd_vd_vd_vd(w, x); + + return svsel_f64(svorr_b_z(ptrue, svcmpeq_f64(ptrue, d, vcast_vd_d(0)), + svcmpeq_f64(ptrue, d, vcast_vd_d(SLEEF_INFINITY))), d, w); +#endif +} + +// Float comparison +static INLINE vopmask vlt_vo_vd_vd(vdouble x, vdouble y) { + return svcmplt_f64(ptrue, x, y); +} +static INLINE vopmask veq_vo_vd_vd(vdouble x, vdouble y) { + return svcmpeq_f64(ptrue, x, y); +} +static INLINE vopmask vgt_vo_vd_vd(vdouble x, vdouble y) { + return svcmpgt_f64(ptrue, x, y); +} +static INLINE vopmask vge_vo_vd_vd(vdouble x, vdouble y) { + return svcmpge_f64(ptrue, x, y); +} +static INLINE vopmask vneq_vo_vd_vd(vdouble x, vdouble y) { + return svcmpne_f64(ptrue, x, y); +} +static INLINE vopmask vle_vo_vd_vd(vdouble x, vdouble y) { + return svcmple_f64(ptrue, x, y); +} + +// predicates +static INLINE vopmask visnan_vo_vd(vdouble vd) { + return svcmpne_f64(ptrue, vd, vd); +} +static INLINE vopmask visinf_vo_vd(vdouble vd) { + return svcmpeq_n_f64(ptrue, svabs_f64_x(ptrue, vd), SLEEF_INFINITY); +} +static INLINE vopmask vispinf_vo_vd(vdouble vd) { + return svcmpeq_n_f64(ptrue, vd, SLEEF_INFINITY); +} +static INLINE vopmask visminf_vo_vd(vdouble vd) { + return svcmpeq_n_f64(ptrue, vd, -SLEEF_INFINITY); +} + +// Comparing bit masks +static INLINE vopmask veq64_vo_vm_vm(vmask x, vmask y) { + return svcmpeq_s64(ptrue, svreinterpret_s64_s32(x), svreinterpret_s64_s32(y)); +} + +// pure predicate operations +static INLINE vopmask vcast_vo32_vo64(vopmask o) { return o; } +static INLINE vopmask vcast_vo64_vo32(vopmask o) { return o; } +static INLINE vopmask vcast_vo_i(int i) { return svcmpne_s32(ptrue, svdup_n_s32(i), svdup_n_s32(0)); } + +// logical integer operations +static INLINE vint vand_vi_vo_vi(vopmask x, vint y) { + // This needs to be a zeroing instruction because we need to make + // sure that the inactive elements for the unpacked integers vector + // are zero. + return svand_s32_z(x, y, y); +} + +static INLINE vint vandnot_vi_vo_vi(vopmask x, vint y) { + return svsel_s32(x, ALL_FALSE_MASK, y); +} +#define vsra_vi_vi_i(x, c) svasr_n_s32_x(ptrue, x, c) +//@#define vsra_vi_vi_i(x, c) svasr_n_s32_x(ptrue, x, c) +#define vsll_vi_vi_i(x, c) svlsl_n_s32_x(ptrue, x, c) +//@#define vsll_vi_vi_i(x, c) svlsl_n_s32_x(ptrue, x, c) + +static INLINE vint vsrl_vi_vi_i(vint x, int c) { + return svreinterpret_s32_u32(svlsr_n_u32_x(ptrue, svreinterpret_u32_s32(x), c)); +} + +static INLINE vint vand_vi_vi_vi(vint x, vint y) { + return svand_s32_x(ptrue, x, y); +} +static INLINE vint vandnot_vi_vi_vi(vint x, vint y) { + return svbic_s32_x(ptrue, y, x); +} +static INLINE vint vxor_vi_vi_vi(vint x, vint y) { + return sveor_s32_x(ptrue, x, y); +} + +// integer math +static INLINE vint vadd_vi_vi_vi(vint x, vint y) { + return svadd_s32_x(ptrue, x, y); +} +static INLINE vint vsub_vi_vi_vi(vint x, vint y) { + return svsub_s32_x(ptrue, x, y); +} +static INLINE vint vneg_vi_vi(vint x) { return svneg_s32_x(ptrue, x); } + +// integer comparison +static INLINE vopmask vgt_vo_vi_vi(vint x, vint y) { + return svcmpgt_s32(ptrue, x, y); +} +static INLINE vopmask veq_vo_vi_vi(vint x, vint y) { + return svcmpeq_s32(ptrue, x, y); +} + +// Splat +static INLINE vint vcast_vi_i(int i) { return svdup_n_s32(i); } + +// bitmask logical operations +static INLINE vmask vand_vm_vo64_vm(vopmask x, vmask y) { + // This needs to be a zeroing instruction because we need to make + // sure that the inactive elements for the unpacked integers vector + // are zero. + return svreinterpret_s32_s64( + svand_s64_z(x, svreinterpret_s64_s32(y), svreinterpret_s64_s32(y))); +} +static INLINE vmask vandnot_vm_vo64_vm(vopmask x, vmask y) { + return svreinterpret_s32_s64(svsel_s64( + x, svreinterpret_s64_s32(ALL_FALSE_MASK), svreinterpret_s64_s32(y))); +} +static INLINE vmask vor_vm_vo64_vm(vopmask x, vmask y) { + return svreinterpret_s32_s64(svsel_s64( + x, svreinterpret_s64_s32(ALL_TRUE_MASK), svreinterpret_s64_s32(y))); +} + +static INLINE vfloat vrev21_vf_vf(vfloat vf) { + return svreinterpret_f32_u64(svrevw_u64_x(ptrue, svreinterpret_u64_f32(vf))); +} + +// Comparison returning integer +static INLINE vint2 veq_vi2_vi2_vi2(vint2 x, vint2 y) { + return svsel_s32(svcmpeq_s32(ptrue, x, y), ALL_TRUE_MASK, ALL_FALSE_MASK); +} + +// Gather + +static INLINE vdouble vgather_vd_p_vi(const double *ptr, vint vi) { + return svld1_gather_s64index_f64(ptrue, ptr, svreinterpret_s64_s32(vi)); +} + +static INLINE vfloat vgather_vf_p_vi2(const float *ptr, vint2 vi2) { + return svld1_gather_s32index_f32(ptrue, ptr, vi2); +} + +// Operations for DFT + +static INLINE vdouble vposneg_vd_vd(vdouble d) { + return svneg_f64_m(d, svdupq_n_b64(0, 1), d); +} + +static INLINE vdouble vnegpos_vd_vd(vdouble d) { + return svneg_f64_m(d, svdupq_n_b64(1, 0), d); +} + +static INLINE vfloat vposneg_vf_vf(vfloat d) { + return svneg_f32_m(d, svdupq_n_b32(0, 1, 0, 1), d); +} + +static INLINE vfloat vnegpos_vf_vf(vfloat d) { + return svneg_f32_m(d, svdupq_n_b32(1, 0, 1, 0), d); +} + +static INLINE vdouble vsubadd_vd_vd_vd(vdouble x, vdouble y) { return vadd_vd_vd_vd(x, vnegpos_vd_vd(y)); } +static INLINE vfloat vsubadd_vf_vf_vf(vfloat d0, vfloat d1) { return vadd_vf_vf_vf(d0, vnegpos_vf_vf(d1)); } +static INLINE vdouble vmlsubadd_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return vfma_vd_vd_vd_vd(x, y, vnegpos_vd_vd(z)); } +static INLINE vfloat vmlsubadd_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return vfma_vf_vf_vf_vf(x, y, vnegpos_vf_vf(z)); } + +// + +static INLINE vdouble vrev21_vd_vd(vdouble x) { return svzip1_f64(svuzp2_f64(x, x), svuzp1_f64(x, x)); } + +static INLINE vdouble vreva2_vd_vd(vdouble vd) { + svint64_t x = svindex_s64((VECTLENDP-1), -1); + x = svzip1_s64(svuzp2_s64(x, x), svuzp1_s64(x, x)); + return svtbl_f64(vd, svreinterpret_u64_s64(x)); +} + +static INLINE vfloat vreva2_vf_vf(vfloat vf) { + svint32_t x = svindex_s32((VECTLENSP-1), -1); + x = svzip1_s32(svuzp2_s32(x, x), svuzp1_s32(x, x)); + return svtbl_f32(vf, svreinterpret_u32_s32(x)); +} + +// + +static INLINE void vscatter2_v_p_i_i_vd(double *ptr, int offset, int step, vdouble v) { + svst1_scatter_u64index_f64(ptrue, ptr + offset*2, svzip1_u64(svindex_u64(0, step*2), svindex_u64(1, step*2)), v); +} + +static INLINE void vscatter2_v_p_i_i_vf(float *ptr, int offset, int step, vfloat v) { + svst1_scatter_u32index_f32(ptrue, ptr + offset*2, svzip1_u32(svindex_u32(0, step*2), svindex_u32(1, step*2)), v); +} + +static INLINE void vstore_v_p_vd(double *ptr, vdouble v) { vstoreu_v_p_vd(ptr, v); } +static INLINE void vstream_v_p_vd(double *ptr, vdouble v) { vstore_v_p_vd(ptr, v); } +static INLINE void vstore_v_p_vf(float *ptr, vfloat v) { vstoreu_v_p_vf(ptr, v); } +static INLINE void vstream_v_p_vf(float *ptr, vfloat v) { vstore_v_p_vf(ptr, v); } +static INLINE void vsscatter2_v_p_i_i_vd(double *ptr, int offset, int step, vdouble v) { vscatter2_v_p_i_i_vd(ptr, offset, step, v); } +static INLINE void vsscatter2_v_p_i_i_vf(float *ptr, int offset, int step, vfloat v) { vscatter2_v_p_i_i_vf(ptr, offset, step, v); } + +// These functions are for debugging +static double vcast_d_vd(vdouble v) { + double a[svcntd()]; + vstoreu_v_p_vd(a, v); + return a[0]; +} + +static float vcast_f_vf(vfloat v) { + float a[svcntw()]; + vstoreu_v_p_vf(a, v); + return a[0]; +} + +static int vcast_i_vi(vint v) { + int a[svcntw()]; + vstoreu_v_p_vi(a, v); + return a[0]; +} + +static int vcast_i_vi2(vint2 v) { + int a[svcntw()]; + vstoreu_v_p_vi2(a, v); + return a[0]; +} + +// + +static vquad loadu_vq_p(const int32_t *ptr) { + int32_t a[svcntw()*2]; + memcpy(a, ptr, svcntw()*8); + return svld2_s32(ptrue, a); +} + +static INLINE vquad cast_vq_aq(vargquad aq) { return aq; } +static INLINE vargquad cast_aq_vq(vquad vq) { return vq; } + +static INLINE int vtestallzeros_i_vo64(vopmask g) { + return svcntp_b64(svptrue_b64(), g) == 0; +} + +static INLINE vmask vsel_vm_vo64_vm_vm(vopmask o, vmask x, vmask y) { + return svreinterpret_s32_s64(svsel_s64(o, svreinterpret_s64_s32(x), svreinterpret_s64_s32(y))); +} + +static INLINE vmask vsub64_vm_vm_vm(vmask x, vmask y) { + return svreinterpret_s32_s64( + svsub_s64_x(ptrue, svreinterpret_s64_s32(x), + svreinterpret_s64_s32(y))); +} + +static INLINE vmask vneg64_vm_vm(vmask x) { + return svreinterpret_s32_s64(svneg_s64_x(ptrue, svreinterpret_s64_s32(x))); +} + +static INLINE vopmask vgt64_vo_vm_vm(vmask x, vmask y) { + return svcmpgt_s64(ptrue, svreinterpret_s64_s32(x), svreinterpret_s64_s32(y)); +} + +#define vsll64_vm_vm_i(x, c) svreinterpret_s32_u64(svlsl_n_u64_x(ptrue, svreinterpret_u64_s32(x), c)) +//@#define vsll64_vm_vm_i(x, c) svreinterpret_s32_u64(svlsl_n_u64_x(ptrue, svreinterpret_u64_s32(x), c)) +#define vsrl64_vm_vm_i(x, c) svreinterpret_s32_u64(svlsr_n_u64_x(ptrue, svreinterpret_u64_s32(x), c)) +//@#define vsrl64_vm_vm_i(x, c) svreinterpret_s32_u64(svlsr_n_u64_x(ptrue, svreinterpret_u64_s32(x), c)) + +static INLINE vmask vcast_vm_vi(vint vi) { return svreinterpret_s32_s64(svextw_s64_z(ptrue, svreinterpret_s64_s32(vi))); } +static INLINE vint vcast_vi_vm(vmask vm) { return vand_vm_vm_vm(vm, vcast_vm_i_i(0, 0xffffffff)); } + +static INLINE vmask vreinterpret_vm_vi64(vint64 v) { return svreinterpret_s32_s64(v); } +static INLINE vint64 vreinterpret_vi64_vm(vmask m) { return svreinterpret_s64_s32(m); } +static INLINE vmask vreinterpret_vm_vu64(vuint64 v) { return svreinterpret_s32_u64(v); } +static INLINE vuint64 vreinterpret_vu64_vm(vmask m) { return svreinterpret_u64_s32(m); } diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/arch/helpervecext.h b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/arch/helpervecext.h new file mode 100644 index 00000000000..3f079317f0b --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/arch/helpervecext.h @@ -0,0 +1,871 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#include "misc.h" + +#ifndef CONFIG +#error CONFIG macro not defined +#endif + +#define ENABLE_DP +#define ENABLE_SP + +#define LOG2VECTLENDP CONFIG +#define VECTLENDP (1 << LOG2VECTLENDP) +#define LOG2VECTLENSP (LOG2VECTLENDP+1) +#define VECTLENSP (1 << LOG2VECTLENSP) + +#define DFTPRIORITY LOG2VECTLENDP + +#if defined(__clang__) +#define ISANAME "Clang Vector Extension" + +typedef uint32_t vmask __attribute__((ext_vector_type(VECTLENDP*2))); +typedef uint32_t vopmask __attribute__((ext_vector_type(VECTLENDP*2))); + +typedef double vdouble __attribute__((ext_vector_type(VECTLENDP))); +typedef int32_t vint __attribute__((ext_vector_type(VECTLENDP))); + +typedef float vfloat __attribute__((ext_vector_type(VECTLENDP*2))); +typedef int32_t vint2 __attribute__((ext_vector_type(VECTLENDP*2))); + +#ifdef ENABLE_LONGDOUBLE +typedef uint8_t vmaskl __attribute__((ext_vector_type(sizeof(long double)*VECTLENDP))); +typedef long double vlongdouble __attribute__((ext_vector_type(VECTLENDP))); +#endif + +#if defined(Sleef_quad2_DEFINED) && defined(ENABLEFLOAT128) +typedef uint8_t vmaskq __attribute__((ext_vector_type(sizeof(Sleef_quad)*VECTLENDP))); +#ifdef ENABLE_LONGDOUBLE +typedef Sleef_quad vquad __attribute__((ext_vector_type(VECTLENDP))); +#endif +#endif +#elif defined(__GNUC__) +#define ISANAME "GCC Vector Extension" + +typedef uint32_t vmask __attribute__((vector_size(sizeof(uint32_t)*VECTLENDP*2))); +typedef uint32_t vopmask __attribute__((vector_size(sizeof(uint32_t)*VECTLENDP*2))); + +typedef double vdouble __attribute__((vector_size(sizeof(double)*VECTLENDP))); +typedef int32_t vint __attribute__((vector_size(sizeof(int32_t)*VECTLENDP))); + +typedef float vfloat __attribute__((vector_size(sizeof(float)*VECTLENDP*2))); +typedef int32_t vint2 __attribute__((vector_size(sizeof(int32_t)*VECTLENDP*2))); + +#ifdef ENABLE_LONGDOUBLE +typedef uint8_t vmaskl __attribute__((vector_size(sizeof(long double)*VECTLENDP))); +typedef long double vlongdouble __attribute__((vector_size(sizeof(long double)*VECTLENDP))); +#endif + +#if defined(Sleef_quad2_DEFINED) && defined(ENABLEFLOAT128) +typedef uint8_t vmaskq __attribute__((vector_size(sizeof(Sleef_quad)*VECTLENDP))); +typedef Sleef_quad vquad __attribute__((vector_size(sizeof(Sleef_quad)*VECTLENDP))); +#endif +#endif + +// + +#if VECTLENDP == 2 +static INLINE vopmask vcast_vo32_vo64(vopmask m) { return (vopmask){ m[1], m[3], 0, 0 }; } +static INLINE vopmask vcast_vo64_vo32(vopmask m) { return (vopmask){ m[0], m[0], m[1], m[1] }; } + +static INLINE vint vcast_vi_i(int i) { return (vint) { i, i }; } +static INLINE vint2 vcast_vi2_i(int i) { return (vint2) { i, i, i, i }; } +static INLINE vfloat vcast_vf_f(float f) { return (vfloat) { f, f, f, f }; } +static INLINE vdouble vcast_vd_d(double d) { return (vdouble) { d, d }; } +#ifdef ENABLE_LONGDOUBLE +static INLINE vlongdouble vcast_vl_l(long double d) { return (vlongdouble) { d, d }; } +#endif +#if defined(Sleef_quad2_DEFINED) && defined(ENABLEFLOAT128) +static INLINE vquad vcast_vq_q(Sleef_quad d) { return (vquad) { d, d }; } +#endif + +static INLINE vmask vcast_vm_i_i(int h, int l) { return (vmask){ l, h, l, h }; } +static INLINE vint2 vcastu_vi2_vi(vint vi) { return (vint2){ 0, vi[0], 0, vi[1] }; } +static INLINE vint vcastu_vi_vi2(vint2 vi2) { return (vint){ vi2[1], vi2[3] }; } + +static INLINE vint vreinterpretFirstHalf_vi_vi2(vint2 vi2) { return (vint){ vi2[0], vi2[1] }; } +static INLINE vint2 vreinterpretFirstHalf_vi2_vi(vint vi) { return (vint2){ vi[0], vi[1], 0, 0 }; } + +static INLINE vdouble vrev21_vd_vd(vdouble vd) { return (vdouble) { vd[1], vd[0] }; } +static INLINE vdouble vreva2_vd_vd(vdouble vd) { return vd; } +static INLINE vfloat vrev21_vf_vf(vfloat vd) { return (vfloat) { vd[1], vd[0], vd[3], vd[2] }; } +static INLINE vfloat vreva2_vf_vf(vfloat vd) { return (vfloat) { vd[2], vd[3], vd[0], vd[1] }; } +#ifdef ENABLE_LONGDOUBLE +static INLINE vlongdouble vrev21_vl_vl(vlongdouble vd) { return (vlongdouble) { vd[1], vd[0] }; } +static INLINE vlongdouble vreva2_vl_vl(vlongdouble vd) { return vd; } +static INLINE vlongdouble vposneg_vl_vl(vlongdouble vd) { return (vlongdouble) { +vd[0], -vd[1] }; } +static INLINE vlongdouble vnegpos_vl_vl(vlongdouble vd) { return (vlongdouble) { -vd[0], +vd[1] }; } +#endif + +#if defined(Sleef_quad2_DEFINED) && defined(ENABLEFLOAT128) +static INLINE vquad vrev21_vq_vq(vquad vd) { return (vquad) { vd[1], vd[0] }; } +static INLINE vquad vreva2_vq_vq(vquad vd) { return vd; } +static INLINE vquad vposneg_vq_vq(vquad vd) { return (vquad) { +vd[0], -vd[1] }; } +static INLINE vquad vnegpos_vq_vq(vquad vd) { return (vquad) { -vd[0], +vd[1] }; } +#endif + +#define PNMASK ((vdouble) { +0.0, -0.0 }) +#define NPMASK ((vdouble) { -0.0, +0.0 }) +static INLINE vdouble vposneg_vd_vd(vdouble d) { return (vdouble)((vmask)d ^ (vmask)PNMASK); } +static INLINE vdouble vnegpos_vd_vd(vdouble d) { return (vdouble)((vmask)d ^ (vmask)NPMASK); } + +#define PNMASKf ((vfloat) { +0.0f, -0.0f, +0.0f, -0.0f }) +#define NPMASKf ((vfloat) { -0.0f, +0.0f, -0.0f, +0.0f }) +static INLINE vfloat vposneg_vf_vf(vfloat d) { return (vfloat)((vmask)d ^ (vmask)PNMASKf); } +static INLINE vfloat vnegpos_vf_vf(vfloat d) { return (vfloat)((vmask)d ^ (vmask)NPMASKf); } +#elif VECTLENDP == 4 +static INLINE vopmask vcast_vo32_vo64(vopmask m) { return (vopmask){ m[1], m[3], m[5], m[7], 0, 0, 0, 0 }; } +static INLINE vopmask vcast_vo64_vo32(vopmask m) { return (vopmask){ m[0], m[0], m[1], m[1], m[2], m[2], m[3], m[3] }; } + +static INLINE vint vcast_vi_i(int i) { return (vint) { i, i, i, i }; } +static INLINE vint2 vcast_vi2_i(int i) { return (vint2) { i, i, i, i, i, i, i, i }; } +static INLINE vfloat vcast_vf_f(float f) { return (vfloat) { f, f, f, f, f, f, f, f }; } +static INLINE vdouble vcast_vd_d(double d) { return (vdouble) { d, d, d, d }; } +#ifdef ENABLE_LONGDOUBLE +static INLINE vlongdouble vcast_vl_l(long double d) { return (vlongdouble) { d, d, d, d }; } +#endif + +static INLINE vmask vcast_vm_i_i(int h, int l) { return (vmask){ l, h, l, h, l, h, l, h }; } +static INLINE vint2 vcastu_vi2_vi(vint vi) { return (vint2){ 0, vi[0], 0, vi[1], 0, vi[2], 0, vi[3] }; } +static INLINE vint vcastu_vi_vi2(vint2 vi2) { return (vint){ vi2[1], vi2[3], vi2[5], vi2[7] }; } + +static INLINE vint vreinterpretFirstHalf_vi_vi2(vint2 vi2) { return (vint){ vi2[0], vi2[1], vi2[2], vi2[3] }; } +static INLINE vint2 vreinterpretFirstHalf_vi2_vi(vint vi) { return (vint2){ vi[0], vi[1], vi[2], vi[3], 0, 0, 0, 0 }; } + +#define PNMASK ((vdouble) { +0.0, -0.0, +0.0, -0.0 }) +#define NPMASK ((vdouble) { -0.0, +0.0, -0.0, +0.0 }) +static INLINE vdouble vposneg_vd_vd(vdouble d) { return (vdouble)((vmask)d ^ (vmask)PNMASK); } +static INLINE vdouble vnegpos_vd_vd(vdouble d) { return (vdouble)((vmask)d ^ (vmask)NPMASK); } + +#define PNMASKf ((vfloat) { +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f }) +#define NPMASKf ((vfloat) { -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f }) +static INLINE vfloat vposneg_vf_vf(vfloat d) { return (vfloat)((vmask)d ^ (vmask)PNMASKf); } +static INLINE vfloat vnegpos_vf_vf(vfloat d) { return (vfloat)((vmask)d ^ (vmask)NPMASKf); } + +static INLINE vdouble vrev21_vd_vd(vdouble vd) { return (vdouble) { vd[1], vd[0], vd[3], vd[2] }; } +static INLINE vdouble vreva2_vd_vd(vdouble vd) { return (vdouble) { vd[2], vd[3], vd[0], vd[1] }; } +static INLINE vfloat vrev21_vf_vf(vfloat vd) { return (vfloat) { vd[1], vd[0], vd[3], vd[2], vd[5], vd[4], vd[7], vd[6] }; } +static INLINE vfloat vreva2_vf_vf(vfloat vd) { return (vfloat) { vd[6], vd[7], vd[4], vd[5], vd[2], vd[3], vd[0], vd[1] }; } +#ifdef ENABLE_LONGDOUBLE +static INLINE vlongdouble vrev21_vl_vl(vlongdouble vd) { return (vlongdouble) { vd[1], vd[0], vd[3], vd[2] }; } +static INLINE vlongdouble vreva2_vl_vl(vlongdouble vd) { return (vlongdouble) { vd[2], vd[3], vd[0], vd[1] }; } +static INLINE vlongdouble vposneg_vl_vl(vlongdouble vd) { return (vlongdouble) { +vd[0], -vd[1], +vd[2], -vd[3] }; } +static INLINE vlongdouble vnegpos_vl_vl(vlongdouble vd) { return (vlongdouble) { -vd[0], +vd[1], -vd[2], +vd[3] }; } +#endif +#elif VECTLENDP == 8 +static INLINE vopmask vcast_vo32_vo64(vopmask m) { return (vopmask){ m[1], m[3], m[5], m[7], m[9], m[11], m[13], m[15], 0, 0, 0, 0, 0, 0, 0, 0 }; } +static INLINE vopmask vcast_vo64_vo32(vopmask m) { return (vopmask){ m[0], m[0], m[1], m[1], m[2], m[2], m[3], m[3], m[4], m[4], m[5], m[5], m[6], m[6], m[7], m[7] }; } + +static INLINE vint vcast_vi_i(int i) { return (vint) { i, i, i, i, i, i, i, i }; } +static INLINE vint2 vcast_vi2_i(int i) { return (vint2) { i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i }; } +static INLINE vfloat vcast_vf_f(float f) { return (vfloat) { f, f, f, f, f, f, f, f, f, f, f, f, f, f, f, f }; } +static INLINE vdouble vcast_vd_d(double d) { return (vdouble) { d, d, d, d, d, d, d, d }; } +#ifdef ENABLE_LONGDOUBLE +static INLINE vlongdouble vcast_vl_l(long double d) { return (vlongdouble) { d, d, d, d, d, d, d, d }; } +#endif + +static INLINE vmask vcast_vm_i_i(int h, int l) { return (vmask){ l, h, l, h, l, h, l, h, l, h, l, h, l, h, l, h }; } +static INLINE vint2 vcastu_vi2_vi(vint vi) { return (vint2){ 0, vi[0], 0, vi[1], 0, vi[2], 0, vi[3], 0, vi[4], 0, vi[5], 0, vi[6], 0, vi[7] }; } +static INLINE vint vcastu_vi_vi2(vint2 vi2) { return (vint){ vi2[1], vi2[3], vi2[5], vi2[7], vi2[9], vi2[11], vi2[13], vi2[15] }; } + +static INLINE vint vreinterpretFirstHalf_vi_vi2(vint2 vi2) { return (vint){ vi2[0], vi2[1], vi2[2], vi2[3], vi2[4], vi2[5], vi2[6], vi2[7] }; } +static INLINE vint2 vreinterpretFirstHalf_vi2_vi(vint vi) { return (vint2){ vi[0], vi[1], vi[2], vi[3], vi[4], vi[5], vi[6], vi[7], 0, 0, 0, 0, 0, 0, 0, 0 }; } + +#define PNMASK ((vdouble) { +0.0, -0.0, +0.0, -0.0, +0.0, -0.0, +0.0, -0.0 }) +#define NPMASK ((vdouble) { -0.0, +0.0, -0.0, +0.0, -0.0, +0.0, -0.0, +0.0 }) +static INLINE vdouble vposneg_vd_vd(vdouble d) { return (vdouble)((vmask)d ^ (vmask)PNMASK); } +static INLINE vdouble vnegpos_vd_vd(vdouble d) { return (vdouble)((vmask)d ^ (vmask)NPMASK); } + +#define PNMASKf ((vfloat) { +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f }) +#define NPMASKf ((vfloat) { -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f }) +static INLINE vfloat vposneg_vf_vf(vfloat d) { return (vfloat)((vmask)d ^ (vmask)PNMASKf); } +static INLINE vfloat vnegpos_vf_vf(vfloat d) { return (vfloat)((vmask)d ^ (vmask)NPMASKf); } + +static INLINE vdouble vrev21_vd_vd(vdouble vd) { return (vdouble) { vd[1], vd[0], vd[3], vd[2], vd[5], vd[4], vd[7], vd[6] }; } +static INLINE vdouble vreva2_vd_vd(vdouble vd) { return (vdouble) { vd[6], vd[7], vd[4], vd[5], vd[2], vd[3], vd[0], vd[1] }; } +static INLINE vfloat vrev21_vf_vf(vfloat vd) { + return (vfloat) { + vd[1], vd[0], vd[3], vd[2], vd[5], vd[4], vd[7], vd[6], + vd[9], vd[8], vd[11], vd[10], vd[13], vd[12], vd[15], vd[14] }; +} +static INLINE vfloat vreva2_vf_vf(vfloat vd) { + return (vfloat) { + vd[14], vd[15], vd[12], vd[13], vd[10], vd[11], vd[8], vd[9], + vd[6], vd[7], vd[4], vd[5], vd[2], vd[3], vd[0], vd[1]}; +} +#ifdef ENABLE_LONGDOUBLE +static INLINE vlongdouble vrev21_vl_vl(vlongdouble vd) { return (vlongdouble) { vd[1], vd[0], vd[3], vd[2], vd[5], vd[4], vd[7], vd[6] }; } +static INLINE vlongdouble vreva2_vl_vl(vlongdouble vd) { return (vlongdouble) { vd[6], vd[7], vd[4], vd[5], vd[2], vd[3], vd[0], vd[1] }; } +static INLINE vlongdouble vposneg_vl_vl(vlongdouble vd) { return (vlongdouble) { +vd[0], -vd[1], +vd[2], -vd[3], +vd[4], -vd[5], +vd[6], -vd[7] }; } +static INLINE vlongdouble vnegpos_vl_vl(vlongdouble vd) { return (vlongdouble) { -vd[0], +vd[1], -vd[2], +vd[3], -vd[4], +vd[5], -vd[6], +vd[7] }; } +#endif +#else +static INLINE vint vcast_vi_i(int k) { + vint ret; + for(int i=0;i y), x, y); } +static INLINE vdouble vmin_vd_vd_vd(vdouble x, vdouble y) { return vsel_vd_vo_vd_vd((vopmask)(x < y), x, y); } + +static INLINE vdouble vsubadd_vd_vd_vd(vdouble x, vdouble y) { return vadd_vd_vd_vd(x, vnegpos_vd_vd(y)); } +static INLINE vdouble vmlsubadd_vd_vd_vd_vd(vdouble x, vdouble y, vdouble z) { return vsubadd_vd_vd_vd(vmul_vd_vd_vd(x, y), z); } + +static INLINE vopmask veq_vo_vd_vd(vdouble x, vdouble y) { return (vopmask)(x == y); } +static INLINE vopmask vneq_vo_vd_vd(vdouble x, vdouble y) { return (vopmask)(x != y); } +static INLINE vopmask vlt_vo_vd_vd(vdouble x, vdouble y) { return (vopmask)(x < y); } +static INLINE vopmask vle_vo_vd_vd(vdouble x, vdouble y) { return (vopmask)(x <= y); } +static INLINE vopmask vgt_vo_vd_vd(vdouble x, vdouble y) { return (vopmask)(x > y); } +static INLINE vopmask vge_vo_vd_vd(vdouble x, vdouble y) { return (vopmask)(x >= y); } + +static INLINE vint vadd_vi_vi_vi(vint x, vint y) { return x + y; } +static INLINE vint vsub_vi_vi_vi(vint x, vint y) { return x - y; } +static INLINE vint vneg_vi_vi(vint e) { return -e; } + +static INLINE vint vand_vi_vi_vi(vint x, vint y) { return x & y; } +static INLINE vint vandnot_vi_vi_vi(vint x, vint y) { return y & ~x; } +static INLINE vint vor_vi_vi_vi(vint x, vint y) { return x | y; } +static INLINE vint vxor_vi_vi_vi(vint x, vint y) { return x ^ y; } + +static INLINE vint vand_vi_vo_vi(vopmask x, vint y) { return vreinterpretFirstHalf_vi_vi2((vint2)x) & y; } +static INLINE vint vandnot_vi_vo_vi(vopmask x, vint y) { return y & ~vreinterpretFirstHalf_vi_vi2((vint2)x); } + +static INLINE vint vsll_vi_vi_i(vint x, int c) { +#if defined(__clang__) + typedef uint32_t vu __attribute__((ext_vector_type(VECTLENDP))); +#else + typedef uint32_t vu __attribute__((vector_size(sizeof(uint32_t)*VECTLENDP))); +#endif + return (vint)(((vu)x) << c); +} + +static INLINE vint vsrl_vi_vi_i(vint x, int c) { +#if defined(__clang__) + typedef uint32_t vu __attribute__((ext_vector_type(VECTLENDP))); +#else + typedef uint32_t vu __attribute__((vector_size(sizeof(uint32_t)*VECTLENDP))); +#endif + return (vint)(((vu)x) >> c); +} + +static INLINE vint vsra_vi_vi_i(vint x, int c) { return x >> c; } + +static INLINE vint veq_vi_vi_vi(vint x, vint y) { return x == y; } +static INLINE vint vgt_vi_vi_vi(vint x, vint y) { return x > y; } + +static INLINE vopmask veq_vo_vi_vi(vint x, vint y) { return (vopmask)vreinterpretFirstHalf_vi2_vi(x == y); } +static INLINE vopmask vgt_vo_vi_vi(vint x, vint y) { return (vopmask)vreinterpretFirstHalf_vi2_vi(x > y);} + +static INLINE vint vsel_vi_vo_vi_vi(vopmask m, vint x, vint y) { + return vor_vi_vi_vi(vand_vi_vi_vi(vreinterpretFirstHalf_vi_vi2((vint2)m), x), + vandnot_vi_vi_vi(vreinterpretFirstHalf_vi_vi2((vint2)m), y)); +} + +static INLINE vopmask visinf_vo_vd(vdouble d) { return (vopmask)(vabs_vd_vd(d) == SLEEF_INFINITY); } +static INLINE vopmask vispinf_vo_vd(vdouble d) { return (vopmask)(d == SLEEF_INFINITY); } +static INLINE vopmask visminf_vo_vd(vdouble d) { return (vopmask)(d == -SLEEF_INFINITY); } +static INLINE vopmask visnan_vo_vd(vdouble d) { return (vopmask)(d != d); } + +static INLINE vdouble vsqrt_vd_vd(vdouble d) { +#if defined(__clang__) + typedef int64_t vi64 __attribute__((ext_vector_type(VECTLENDP))); +#else + typedef int64_t vi64 __attribute__((vector_size(sizeof(int64_t)*VECTLENDP))); +#endif + + vdouble q = vcast_vd_d(1); + + vopmask o = (vopmask)(d < 8.636168555094445E-78); + d = (vdouble)((o & (vmask)(d * 1.157920892373162E77)) | (~o & (vmask)d)); + + q = (vdouble)((o & (vmask)vcast_vd_d(2.9387358770557188E-39)) | (~o & (vmask)vcast_vd_d(1))); + + q = (vdouble)vor_vm_vm_vm(vlt_vo_vd_vd(d, vcast_vd_d(0)), (vmask)q); + + vdouble x = (vdouble)(0x5fe6ec85e7de30daLL - ((vi64)(d + 1e-320) >> 1)); + x = x * ( 3 - d * x * x); + x = x * ( 12 - d * x * x); + x = x * (768 - d * x * x); + x *= 1.0 / (1 << 13); + x = (d - (d * x) * (d * x)) * (x * 0.5) + d * x; + + return x * q; +} + +static INLINE double vcast_d_vd(vdouble v) { return v[0]; } +static INLINE float vcast_f_vf(vfloat v) { return v[0]; } + +static INLINE vdouble vload_vd_p(const double *ptr) { return *(vdouble *)ptr; } +static INLINE vdouble vloadu_vd_p(const double *ptr) { + vdouble vd; + for(int i=0;i y), x, y); } +static INLINE vfloat vmin_vf_vf_vf(vfloat x, vfloat y) { return vsel_vf_vo_vf_vf((vopmask)(x < y), x, y); } + +static INLINE vfloat vsubadd_vf_vf_vf(vfloat x, vfloat y) { return vadd_vf_vf_vf(x, vnegpos_vf_vf(y)); } +static INLINE vfloat vmlsubadd_vf_vf_vf_vf(vfloat x, vfloat y, vfloat z) { return vsubadd_vf_vf_vf(vmul_vf_vf_vf(x, y), z); } + +static INLINE vopmask veq_vo_vf_vf(vfloat x, vfloat y) { return (vopmask)(x == y); } +static INLINE vopmask vneq_vo_vf_vf(vfloat x, vfloat y) { return (vopmask)(x != y); } +static INLINE vopmask vlt_vo_vf_vf(vfloat x, vfloat y) { return (vopmask)(x < y); } +static INLINE vopmask vle_vo_vf_vf(vfloat x, vfloat y) { return (vopmask)(x <= y); } +static INLINE vopmask vgt_vo_vf_vf(vfloat x, vfloat y) { return (vopmask)(x > y); } +static INLINE vopmask vge_vo_vf_vf(vfloat x, vfloat y) { return (vopmask)(x >= y); } + +static INLINE vint2 vadd_vi2_vi2_vi2(vint2 x, vint2 y) { return x + y; } +static INLINE vint2 vsub_vi2_vi2_vi2(vint2 x, vint2 y) { return x - y; } +static INLINE vint2 vneg_vi2_vi2(vint2 e) { return -e; } + +static INLINE vint2 vand_vi2_vi2_vi2(vint2 x, vint2 y) { return x & y; } +static INLINE vint2 vandnot_vi2_vi2_vi2(vint2 x, vint2 y) { return y & ~x; } +static INLINE vint2 vor_vi2_vi2_vi2(vint2 x, vint2 y) { return x | y; } +static INLINE vint2 vxor_vi2_vi2_vi2(vint2 x, vint2 y) { return x ^ y; } + +static INLINE vint2 vand_vi2_vo_vi2(vopmask x, vint2 y) { return (vint2)x & y; } +static INLINE vint2 vandnot_vi2_vo_vi2(vopmask x, vint2 y) { return y & ~(vint2)x; } + +static INLINE vint2 vsll_vi2_vi2_i(vint2 x, int c) { +#if defined(__clang__) + typedef uint32_t vu __attribute__((ext_vector_type(VECTLENDP*2))); +#else + typedef uint32_t vu __attribute__((vector_size(sizeof(uint32_t)*VECTLENDP*2))); +#endif + return (vint2)(((vu)x) << c); +} +static INLINE vint2 vsrl_vi2_vi2_i(vint2 x, int c) { +#if defined(__clang__) + typedef uint32_t vu __attribute__((ext_vector_type(VECTLENDP*2))); +#else + typedef uint32_t vu __attribute__((vector_size(sizeof(uint32_t)*VECTLENDP*2))); +#endif + return (vint2)(((vu)x) >> c); +} +static INLINE vint2 vsra_vi2_vi2_i(vint2 x, int c) { return x >> c; } + +static INLINE vopmask veq_vo_vi2_vi2(vint2 x, vint2 y) { return (vopmask)(x == y); } +static INLINE vopmask vgt_vo_vi2_vi2(vint2 x, vint2 y) { return (vopmask)(x > y); } +static INLINE vint2 veq_vi2_vi2_vi2(vint2 x, vint2 y) { return x == y; } +static INLINE vint2 vgt_vi2_vi2_vi2(vint2 x, vint2 y) { return x > y; } + +static INLINE vopmask visinf_vo_vf(vfloat d) { return (vopmask)(vabs_vf_vf(d) == SLEEF_INFINITYf); } +static INLINE vopmask vispinf_vo_vf(vfloat d) { return (vopmask)(d == SLEEF_INFINITYf); } +static INLINE vopmask visminf_vo_vf(vfloat d) { return (vopmask)(d == -SLEEF_INFINITYf); } +static INLINE vopmask visnan_vo_vf(vfloat d) { return (vopmask)(d != d); } + +static INLINE vfloat vsqrt_vf_vf(vfloat d) { + vfloat q = vcast_vf_f(1); + + vopmask o = (vopmask)(d < 5.4210108624275221700372640043497e-20f); // 2^-64 + d = (vfloat)((o & (vmask)(d * vcast_vf_f(18446744073709551616.0f))) | (~o & (vmask)d)); // 2^64 + q = (vfloat)((o & (vmask)vcast_vf_f(0.00000000023283064365386962890625f)) | (~o & (vmask)vcast_vf_f(1))); // 2^-32 + q = (vfloat)vor_vm_vm_vm(vlt_vo_vf_vf(d, vcast_vf_f(0)), (vmask)q); + + vfloat x = (vfloat)(0x5f330de2 - (((vint2)d) >> 1)); + x = x * ( 3.0f - d * x * x); + x = x * (12.0f - d * x * x); + x *= 0.0625f; + x = (d - (d * x) * (d * x)) * (x * 0.5) + d * x; + + return x * q; +} + +static INLINE vfloat vload_vf_p(const float *ptr) { return *(vfloat *)ptr; } +static INLINE vfloat vloadu_vf_p(const float *ptr) { + vfloat vf; + for(int i=0;i +#include +#include +#include +#include + +#define N 1000 + +FILE *cygopen(const char *path, const char *mode) { +#if defined(__MINGW64__) || defined(__MINGW32__) + FILE *fp = fopen(path, mode); + if (fp != NULL) return fp; + + char *buf = malloc(strlen(path) + N + 1); + snprintf(buf, strlen(path) + N, "cygpath -m '%s'", path); + + FILE *pfp = popen(buf, "r"); + + if (pfp == NULL || fgets(buf, N, pfp) == NULL) { + if (pfp != NULL) pclose(pfp); + free(buf); + return NULL; + } + + pclose(pfp); + + int len = strlen(buf); + if (0 < len && len < N && buf[len-1] == '\n') buf[len-1] = '\0'; + + fp = fopen(buf, mode); + + free(buf); + + return fp; +#else + return fopen(path, mode); +#endif +} + +int nkeywords = 0, nalloc = 0; +char **keywords = NULL, *suffix = NULL; + +int nIgnore = 0; +char **ignore = NULL; + +void insert(char *buf) { + for(int i=0;i\n", argv[0]); + fprintf(stderr, "Print the file on the standard output\n"); + fprintf(stderr, "\n"); + fprintf(stderr, "%s [ ... ]\n", argv[0]); + fprintf(stderr, "Add the suffix to keywords\n"); + exit(-1); + } + + char buf[N]; + + if (argc == 2) { + FILE *fp = cygopen(argv[1], "r"); + if (fp == NULL) { + fprintf(stderr, "Cannot open %s\n", argv[1]); + exit(-1); + } + + while(fgets(buf, N, fp) != NULL) { + fputs(buf, stdout); + } + fclose(fp); + exit(0); + } + + FILE *fp = cygopen(argv[2], "r"); + if (fp == NULL) { + fprintf(stderr, "Cannot open %s\n", argv[2]); + exit(-1); + } + + while(fgets(buf, N, fp) != NULL) { + if (strlen(buf) >= 1) buf[strlen(buf)-1] = '\0'; + keywords[nkeywords] = malloc(sizeof(char) * (strlen(buf) + 1)); + strcpy(keywords[nkeywords], buf); + nkeywords++; + if (nkeywords >= nalloc) { + nalloc *= 2; + keywords = realloc(keywords, sizeof(char *) * nalloc); + } + } + + fclose(fp); + + nIgnore = argc - 4; + ignore = argv + 4; + + suffix = argv[3]; + + fp = cygopen(argv[1], "r"); + if (fp == NULL) { + fprintf(stderr, "Cannot open %s\n", argv[1]); + exit(-1); + } + + doit(fp); + + fclose(fp); + + exit(0); +} + +// cat sleef*inline*.h | egrep -o '[a-zA-Z_][0-9a-zA-Z_]*' | sort | uniq > cand.txt diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/common/arraymap.c b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/common/arraymap.c new file mode 100644 index 00000000000..3e31df5ffec --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/common/arraymap.c @@ -0,0 +1,347 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include +#include +#include + +// + +#if !(defined(__MINGW32__) || defined(__MINGW64__) || defined(_MSC_VER)) +#include +#include +#include + +static void FLOCK(FILE *fp) { flock(fileno(fp), LOCK_EX); } +static void FUNLOCK(FILE *fp) { flock(fileno(fp), LOCK_UN); } +static void FTRUNCATE(FILE *fp, off_t z) { + if (ftruncate(fileno(fp), z)) + ; +} +static FILE *OPENTMPFILE() { return tmpfile(); } +static void CLOSETMPFILE(FILE *fp) { fclose(fp); } +#else +#include +#include + +static void FLOCK(FILE *fp) { } +static void FUNLOCK(FILE *fp) { } +static void FTRUNCATE(FILE *fp, long z) { + fseek(fp, 0, SEEK_SET); + SetEndOfFile((HANDLE)_get_osfhandle(_fileno(fp))); +} +static FILE *OPENTMPFILE() { return fopen("tmpfile.txt", "w+"); } +static void CLOSETMPFILE(FILE *fp) { + fclose(fp); + remove("tmpfile.txt"); +} +#endif + +// + +#define MAGIC_ARRAYMAPNODE 0xf73130fa +#define MAGIC_ARRAYMAP 0x8693bd21 +#define LOGNBUCKETS 8 +#define NBUCKETS (1 << LOGNBUCKETS) + +static int hash(uint64_t key) { + return (key ^ (key >> LOGNBUCKETS) ^ (key >> (LOGNBUCKETS*2)) ^ (key >> (LOGNBUCKETS*3))) & (NBUCKETS-1); +} + +static void String_trim(char *str) { + char *dst = str, *src = str, *pterm = src; + + while(*src != '\0' && isspace((int)*src)) src++; + + for(;*src != '\0';src++) { + *dst++ = *src; + if (!isspace((int)*src)) pterm = dst; + } + + *pterm = '\0'; +} + +typedef struct ArrayMapNode { + uint32_t magic; + uint64_t key; + void *value; +} ArrayMapNode; + +typedef struct ArrayMap { + uint32_t magic; + ArrayMapNode *array[NBUCKETS]; + int size[NBUCKETS], capacity[NBUCKETS], totalSize; +} ArrayMap; + +ArrayMap *initArrayMap() { + ArrayMap *thiz = (ArrayMap *)calloc(1, sizeof(ArrayMap)); + thiz->magic = MAGIC_ARRAYMAP; + + for(int i=0;icapacity[i] = 8; + thiz->array[i] = (ArrayMapNode *)malloc(thiz->capacity[i] * sizeof(ArrayMapNode)); + thiz->size[i] = 0; + } + + thiz->totalSize = 0; + return thiz; +} + +void ArrayMap_dispose(ArrayMap *thiz) { + assert(thiz != NULL && thiz->magic == MAGIC_ARRAYMAP); + + for(int j=0;jsize[j];i++) { + assert(thiz->array[j][i].magic == MAGIC_ARRAYMAPNODE); + thiz->array[j][i].magic = 0; + } + free(thiz->array[j]); + } + + thiz->magic = 0; + free(thiz); +} + +int ArrayMap_size(ArrayMap *thiz) { + assert(thiz != NULL && thiz->magic == MAGIC_ARRAYMAP); + return thiz->totalSize; +} + +uint64_t *ArrayMap_keyArray(ArrayMap *thiz) { + assert(thiz != NULL && thiz->magic == MAGIC_ARRAYMAP); + uint64_t *a = (uint64_t *)malloc(sizeof(uint64_t) * thiz->totalSize); + int p = 0; + for(int j=0;jsize[j];i++) { + assert(thiz->array[j][i].magic == MAGIC_ARRAYMAPNODE); + a[p++] = thiz->array[j][i].key; + } + } + return a; +} + +void **ArrayMap_valueArray(ArrayMap *thiz) { + assert(thiz != NULL && thiz->magic == MAGIC_ARRAYMAP); + void **a = (void **)malloc(sizeof(void *) * thiz->totalSize); + int p = 0; + for(int j=0;jsize[j];i++) { + assert(thiz->array[j][i].magic == MAGIC_ARRAYMAPNODE); + a[p++] = thiz->array[j][i].value; + } + } + return a; +} + +void *ArrayMap_remove(ArrayMap *thiz, uint64_t key) { + assert(thiz != NULL && thiz->magic == MAGIC_ARRAYMAP); + + int h = hash(key); + for(int i=0;isize[h];i++) { + assert(thiz->array[h][i].magic == MAGIC_ARRAYMAPNODE); + if (thiz->array[h][i].key == key) { + void *old = thiz->array[h][i].value; + thiz->array[h][i].key = thiz->array[h][thiz->size[h]-1].key; + thiz->array[h][i].value = thiz->array[h][thiz->size[h]-1].value; + thiz->array[h][thiz->size[h]-1].magic = 0; + thiz->size[h]--; + thiz->totalSize--; + return old; + } + } + + return NULL; +} + +void *ArrayMap_put(ArrayMap *thiz, uint64_t key, void *value) { + if (value == NULL) return ArrayMap_remove(thiz, key); + + assert(thiz != NULL && thiz->magic == MAGIC_ARRAYMAP); + + int h = hash(key); + for(int i=0;isize[h];i++) { + assert(thiz->array[h][i].magic == MAGIC_ARRAYMAPNODE); + if (thiz->array[h][i].key == key) { + void *old = thiz->array[h][i].value; + thiz->array[h][i].value = value; + return old; + } + } + + if (thiz->size[h] >= thiz->capacity[h]) { + thiz->capacity[h] *= 2; + thiz->array[h] = (ArrayMapNode *)realloc(thiz->array[h], thiz->capacity[h] * sizeof(ArrayMapNode)); + } + + ArrayMapNode *n = &(thiz->array[h][thiz->size[h]++]); + n->magic = MAGIC_ARRAYMAPNODE; + n->key = key; + n->value = value; + + thiz->totalSize++; + + return NULL; +} + +void *ArrayMap_get(ArrayMap *thiz, uint64_t key) { + assert(thiz != NULL && thiz->magic == MAGIC_ARRAYMAP); + + int h = hash(key); + for(int i=0;isize[h];i++) { + assert(thiz->array[h][i].magic == MAGIC_ARRAYMAPNODE); + if (thiz->array[h][i].key == key) { + return thiz->array[h][i].value; + } + } + + return NULL; +} + +#define LINELEN (1024*1024) + +ArrayMap *ArrayMap_load(const char *fn, const char *prefix, const char *idstr, int doLock) { + const int idstrlen = (int)strlen(idstr); + int prefixLen = (int)strlen(prefix) + 3; + + if (prefixLen >= LINELEN-10 || idstrlen >= LINELEN-10) return NULL; + + FILE *fp = fopen(fn, "r"); + if (fp == NULL) return NULL; + + if (doLock) FLOCK(fp); + + ArrayMap *thiz = initArrayMap(); + + char *prefix2 = malloc(prefixLen+10); + strcpy(prefix2, prefix); + String_trim(prefix2); + for(char *p = prefix2;*p != '\0';p++) { + if (*p == ':') *p = ';'; + if (*p == ' ') *p = '_'; + } + strcat(prefix2, " : "); + prefixLen = (int)strlen(prefix2); + + char *line = malloc(sizeof(char) * (LINELEN+10)); + line[idstrlen] = '\0'; + + if (fread(line, sizeof(char), idstrlen, fp) != idstrlen || + strcmp(idstr, line) != 0) { + if (doLock) FUNLOCK(fp); + fclose(fp); + free(prefix2); + free(line); + return NULL; + } + + for(;;) { + line[LINELEN] = '\0'; + if (fgets(line, LINELEN, fp) == NULL) break; + if (strncmp(line, prefix2, prefixLen) != 0) continue; + + uint64_t key; + char *value = malloc(sizeof(char) * LINELEN); + + if (sscanf(line + prefixLen, "%" SCNx64 " : %s\n", &key, value) == 2) { + ArrayMap_put(thiz, (uint64_t)key, (void *)value); + } else { + free(value); + } + } + + if (doLock) FUNLOCK(fp); + fclose(fp); + + free(prefix2); + free(line); + + return thiz; +} + +int ArrayMap_save(ArrayMap *thiz, const char *fn, const char *prefix, const char *idstr) { + assert(thiz != NULL && thiz->magic == MAGIC_ARRAYMAP); + + const int idstrlen = (int)strlen(idstr); + int prefixLen = (int)strlen(prefix) + 3; + + if (prefixLen >= LINELEN-10 || idstrlen >= LINELEN-10) return -1; + + // Generate prefix2 + + char *prefix2 = malloc(prefixLen+10); + strcpy(prefix2, prefix); + String_trim(prefix2); + for(char *p = prefix2;*p != '\0';p++) { + if (*p == ':') *p = ';'; + if (*p == ' ') *p = '_'; + } + strcat(prefix2, " : "); + prefixLen = (int)strlen(prefix2); + + // + + FILE *fp = fopen(fn, "a+"); + if (fp == NULL) return -1; + + FLOCK(fp); + fseek(fp, 0, SEEK_SET); + + // Copy the file specified by fn to tmpfile + + FILE *tmpfp = OPENTMPFILE(); + if (tmpfp == NULL) { + FUNLOCK(fp); + fclose(fp); + return -1; + } + + char *line = malloc(sizeof(char) * (LINELEN+10)); + line[idstrlen] = '\0'; + + if (fread(line, sizeof(char), idstrlen, fp) == idstrlen && strcmp(idstr, line) == 0) { + for(;;) { + line[LINELEN] = '\0'; + if (fgets(line, LINELEN, fp) == NULL) break; + if (strncmp(line, prefix2, prefixLen) != 0) fputs(line, tmpfp); + } + } + + // Write the contents in the map into tmpfile + + uint64_t *keys = ArrayMap_keyArray(thiz); + int s = ArrayMap_size(thiz); + + for(int i=0;i= LINELEN-10) continue; + fprintf(tmpfp, "%s %" PRIx64 " : %s\n", prefix2, keys[i], value); + } + + free(keys); + + fseek(fp, 0, SEEK_SET); + FTRUNCATE(fp, 0); + fwrite(idstr, sizeof(char), strlen(idstr), fp); + + fseek(tmpfp, 0, SEEK_SET); + + for(;;) { + size_t s = fread(line, 1, LINELEN, tmpfp); + if (s == 0) break; + fwrite(line, 1, s, fp); + } + + FUNLOCK(fp); + fclose(fp); + + CLOSETMPFILE(tmpfp); + free(prefix2); + free(line); + return 0; +} diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/common/arraymap.h b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/common/arraymap.h new file mode 100644 index 00000000000..9d05abe783a --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/common/arraymap.h @@ -0,0 +1,21 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef __ARRAYMAP_H__ +#define __ARRAYMAP_H__ +typedef struct ArrayMap ArrayMap; + +ArrayMap *initArrayMap(); +void ArrayMap_dispose(ArrayMap *thiz); +int ArrayMap_size(ArrayMap *thiz); +void *ArrayMap_remove(ArrayMap *thiz, uint64_t key); +void *ArrayMap_put(ArrayMap *thiz, uint64_t key, void *value); +void *ArrayMap_get(ArrayMap *thiz, uint64_t key); + +uint64_t *ArrayMap_keyArray(ArrayMap *thiz); +void **ArrayMap_valueArray(ArrayMap *thiz); +int ArrayMap_save(ArrayMap *thiz, const char *fn, const char *prefix, const char *idstr); +ArrayMap *ArrayMap_load(const char *fn, const char *prefix, const char *idstr, int doLock); +#endif diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/common/common.c b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/common/common.c new file mode 100644 index 00000000000..6ebcc3f4ffb --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/common/common.c @@ -0,0 +1,98 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include + +#include "misc.h" + +#if defined(__MINGW32__) || defined(__MINGW64__) || defined(_MSC_VER) +#include + +EXPORT void *Sleef_malloc(size_t z) { return _aligned_malloc(z, 256); } +EXPORT void Sleef_free(void *ptr) { _aligned_free(ptr); } + +EXPORT uint64_t Sleef_currentTimeMicros() { + struct __timeb64 t; + _ftime64(&t); + return t.time * INT64_C(1000000) + t.millitm*1000; +} +#elif defined(__APPLE__) +#include + +EXPORT void *Sleef_malloc(size_t z) { void *ptr = NULL; posix_memalign(&ptr, 256, z); return ptr; } +EXPORT void Sleef_free(void *ptr) { free(ptr); } + +EXPORT uint64_t Sleef_currentTimeMicros() { + struct timeval time; + gettimeofday(&time, NULL); + return (uint64_t)((time.tv_sec * INT64_C(1000000)) + time.tv_usec); +} +#else // #if defined(__MINGW32__) || defined(__MINGW64__) || defined(_MSC_VER) +#include +#include +#if defined(__FreeBSD__) || defined(__OpenBSD__) +#include +#else +#include +#endif + +EXPORT void *Sleef_malloc(size_t z) { void *ptr = NULL; posix_memalign(&ptr, 4096, z); return ptr; } +EXPORT void Sleef_free(void *ptr) { free(ptr); } + +EXPORT uint64_t Sleef_currentTimeMicros() { + struct timespec tp; + clock_gettime(CLOCK_MONOTONIC, &tp); + return (uint64_t)tp.tv_sec * INT64_C(1000000) + ((uint64_t)tp.tv_nsec/1000); +} +#endif // #if defined(__MINGW32__) || defined(__MINGW64__) || defined(_MSC_VER) + +#ifdef _MSC_VER +#include +EXPORT void Sleef_x86CpuID(int32_t out[4], uint32_t eax, uint32_t ecx) { + __cpuidex(out, eax, ecx); +} +#else +#if defined(__x86_64__) || defined(__i386__) +EXPORT void Sleef_x86CpuID(int32_t out[4], uint32_t eax, uint32_t ecx) { + uint32_t a, b, c, d; + __asm__ __volatile__ ("cpuid" : "=a" (a), "=b" (b), "=c" (c), "=d" (d) : "a" (eax), "c"(ecx)); + out[0] = a; out[1] = b; out[2] = c; out[3] = d; +} +#endif +#endif + +#if defined(__i386__) || defined(__x86_64__) || defined(_MSC_VER) +static char x86BrandString[256]; + +EXPORT char *Sleef_getCpuIdString() { + union { + int32_t info[4]; + uint8_t str[16]; + } u; + int i,j; + char *p; + + p = x86BrandString; + + for(i=0;i<3;i++) { + Sleef_x86CpuID(u.info, i + 0x80000002, 0); + + for(j=0;j<16;j++) { + *p++ = u.str[j]; + } + } + + *p++ = '\n'; + + return x86BrandString; +} +#else +EXPORT char *Sleef_getCpuIdString() { + return "Unknown architecture"; +} +#endif diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/common/common.h b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/common/common.h new file mode 100644 index 00000000000..ff278e0792a --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/common/common.h @@ -0,0 +1,9 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef __COMMON_H__ +#define __COMMON_H__ +char *Sleef_getCpuIdString(); +#endif diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/common/commonfuncs.h b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/common/commonfuncs.h new file mode 100644 index 00000000000..494b7b87c7a --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/common/commonfuncs.h @@ -0,0 +1,438 @@ +// Copyright Naoki Shibata and contributors 2010 - 2023. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#if !(defined(ENABLE_SVE) || defined(ENABLE_SVENOFMA) || defined(ENABLE_RVVM1) || defined(ENABLE_RVVM1NOFMA) || defined(ENABLE_RVVM2) || defined(ENABLE_RVVM2NOFMA)) +typedef struct { + vdouble x, y, z; +} vdouble3; + +static INLINE CONST VECTOR_CC vdouble vd3getx_vd_vd3(vdouble3 v) { return v.x; } +static INLINE CONST VECTOR_CC vdouble vd3gety_vd_vd3(vdouble3 v) { return v.y; } +static INLINE CONST VECTOR_CC vdouble vd3getz_vd_vd3(vdouble3 v) { return v.z; } +static INLINE CONST VECTOR_CC vdouble3 vd3setxyz_vd3_vd_vd_vd(vdouble x, vdouble y, vdouble z) { + vdouble3 v = { x, y, z }; + return v; +} +static INLINE CONST VECTOR_CC vdouble3 vd3setx_vd3_vd3_vd(vdouble3 v, vdouble d) { v.x = d; return v; } +static INLINE CONST VECTOR_CC vdouble3 vd3sety_vd3_vd3_vd(vdouble3 v, vdouble d) { v.y = d; return v; } +static INLINE CONST VECTOR_CC vdouble3 vd3setz_vd3_vd3_vd(vdouble3 v, vdouble d) { v.z = d; return v; } + +// + +typedef struct { + vdouble2 a, b; +} dd2; + +static dd2 dd2setab_dd2_vd2_vd2(vdouble2 a, vdouble2 b) { + dd2 r = { a, b }; + return r; +} +static vdouble2 dd2geta_vd2_dd2(dd2 d) { return d.a; } +static vdouble2 dd2getb_vd2_dd2(dd2 d) { return d.b; } + +// + +typedef struct { + vmask e; + vdouble3 d3; +} tdx; + +static INLINE CONST VECTOR_CC vmask tdxgete_vm_tdx(tdx t) { return t.e; } +static INLINE CONST VECTOR_CC vdouble3 tdxgetd3_vd3_tdx(tdx t) { return t.d3; } +static INLINE CONST VECTOR_CC vdouble tdxgetd3x_vd_tdx(tdx t) { return t.d3.x; } +static INLINE CONST VECTOR_CC vdouble tdxgetd3y_vd_tdx(tdx t) { return t.d3.y; } +static INLINE CONST VECTOR_CC vdouble tdxgetd3z_vd_tdx(tdx t) { return t.d3.z; } +static INLINE CONST VECTOR_CC tdx tdxsete_tdx_tdx_vm(tdx t, vmask e) { t.e = e; return t; } +static INLINE CONST VECTOR_CC tdx tdxsetd3_tdx_tdx_vd3(tdx t, vdouble3 d3) { t.d3 = d3; return t; } +static INLINE CONST VECTOR_CC tdx tdxsetx_tdx_tdx_vd(tdx t, vdouble x) { t.d3.x = x; return t; } +static INLINE CONST VECTOR_CC tdx tdxsety_tdx_tdx_vd(tdx t, vdouble y) { t.d3.y = y; return t; } +static INLINE CONST VECTOR_CC tdx tdxsetz_tdx_tdx_vd(tdx t, vdouble z) { t.d3.z = z; return t; } +static INLINE CONST VECTOR_CC tdx tdxsetxyz_tdx_tdx_vd_vd_vd(tdx t, vdouble x, vdouble y, vdouble z) { + t.d3 = (vdouble3) { x, y, z }; + return t; +} + +static INLINE CONST VECTOR_CC tdx tdxseted3_tdx_vm_vd3(vmask e, vdouble3 d3) { return (tdx) { e, d3 }; } +static INLINE CONST VECTOR_CC tdx tdxsetexyz_tdx_vm_vd_vd_vd(vmask e, vdouble x, vdouble y, vdouble z) { + return (tdx) { e, (vdouble3) { x, y, z } }; +} + +static INLINE CONST VECTOR_CC vmask vqgetx_vm_vq(vquad v) { return v.x; } +static INLINE CONST VECTOR_CC vmask vqgety_vm_vq(vquad v) { return v.y; } +static INLINE CONST VECTOR_CC vquad vqsetxy_vq_vm_vm(vmask x, vmask y) { return (vquad) { x, y }; } +static INLINE CONST VECTOR_CC vquad vqsetx_vq_vq_vm(vquad v, vmask x) { v.x = x; return v; } +static INLINE CONST VECTOR_CC vquad vqsety_vq_vq_vm(vquad v, vmask y) { v.y = y; return v; } + +// + +typedef struct { + vdouble d; + vint i; +} di_t; + +static INLINE CONST VECTOR_CC vdouble digetd_vd_di(di_t d) { return d.d; } +static INLINE CONST VECTOR_CC vint digeti_vi_di(di_t d) { return d.i; } +static INLINE CONST VECTOR_CC di_t disetdi_di_vd_vi(vdouble d, vint i) { + di_t r = { d, i }; + return r; +} + +// + +typedef struct { + vdouble2 dd; + vint i; +} ddi_t; + +static INLINE CONST VECTOR_CC vdouble2 ddigetdd_vd2_ddi(ddi_t d) { return d.dd; } +static INLINE CONST VECTOR_CC vint ddigeti_vi_ddi(ddi_t d) { return d.i; } +static INLINE CONST VECTOR_CC ddi_t ddisetddi_ddi_vd2_vi(vdouble2 v, vint i) { + ddi_t r = { v, i }; + return r; +} +static INLINE CONST VECTOR_CC ddi_t ddisetdd_ddi_ddi_vd2(ddi_t ddi, vdouble2 v) { + ddi.dd = v; + return ddi; +} + +// + +typedef struct { + vdouble3 td; + vint i; +} tdi_t; + +static INLINE CONST VECTOR_CC vdouble3 tdigettd_vd3_tdi(tdi_t d) { return d.td; } +static INLINE CONST VECTOR_CC vdouble tdigetx_vd_tdi(tdi_t d) { return d.td.x; } +static INLINE CONST VECTOR_CC vint tdigeti_vi_tdi(tdi_t d) { return d.i; } +static INLINE CONST VECTOR_CC tdi_t tdisettdi_tdi_vd3_vi(vdouble3 v, vint i) { + tdi_t r = { v, i }; + return r; +} +#endif + +#if defined(ENABLE_MAIN) +// Functions for debugging +#include +#include + +static void printvmask(char *mes, vmask g) { + uint64_t u[VECTLENDP]; + vstoreu_v_p_vd((double *)u, vreinterpret_vd_vm(g)); + printf("%s ", mes); + for(int i=0;i= |y| + + vdouble s = vadd_vd_vd_vd(vd2getx_vd_vd2(x), vd2getx_vd_vd2(y)); + return vd2setxy_vd2_vd_vd(s, vadd_vd_4vd(vsub_vd_vd_vd(vd2getx_vd_vd2(x), s), vd2getx_vd_vd2(y), vd2gety_vd_vd2(x), vd2gety_vd_vd2(y))); +} + +static INLINE CONST VECTOR_CC vdouble2 ddadd2_vd2_vd2_vd2(vdouble2 x, vdouble2 y) { + vdouble s = vadd_vd_vd_vd(vd2getx_vd_vd2(x), vd2getx_vd_vd2(y)); + vdouble v = vsub_vd_vd_vd(s, vd2getx_vd_vd2(x)); + vdouble t = vadd_vd_vd_vd(vsub_vd_vd_vd(vd2getx_vd_vd2(x), vsub_vd_vd_vd(s, v)), vsub_vd_vd_vd(vd2getx_vd_vd2(y), v)); + return vd2setxy_vd2_vd_vd(s, vadd_vd_vd_vd(t, vadd_vd_vd_vd(vd2gety_vd_vd2(x), vd2gety_vd_vd2(y)))); +} + +static INLINE CONST VECTOR_CC vdouble2 ddsub_vd2_vd_vd(vdouble x, vdouble y) { + // |x| >= |y| + + vdouble s = vsub_vd_vd_vd(x, y); + return vd2setxy_vd2_vd_vd(s, vsub_vd_vd_vd(vsub_vd_vd_vd(x, s), y)); +} + +static INLINE CONST VECTOR_CC vdouble2 ddsub_vd2_vd2_vd2(vdouble2 x, vdouble2 y) { + // |x| >= |y| + + vdouble s = vsub_vd_vd_vd(vd2getx_vd_vd2(x), vd2getx_vd_vd2(y)); + vdouble t = vsub_vd_vd_vd(vd2getx_vd_vd2(x), s); + t = vsub_vd_vd_vd(t, vd2getx_vd_vd2(y)); + t = vadd_vd_vd_vd(t, vd2gety_vd_vd2(x)); + return vd2setxy_vd2_vd_vd(s, vsub_vd_vd_vd(t, vd2gety_vd_vd2(y))); +} + +#ifdef ENABLE_FMA_DP +static INLINE CONST VECTOR_CC vdouble2 dddiv_vd2_vd2_vd2(vdouble2 n, vdouble2 d) { + vdouble t = vrec_vd_vd(vd2getx_vd_vd2(d)); + vdouble s = vmul_vd_vd_vd(vd2getx_vd_vd2(n), t); + vdouble u = vfmapn_vd_vd_vd_vd(t, vd2getx_vd_vd2(n), s); + vdouble v = vfmanp_vd_vd_vd_vd(vd2gety_vd_vd2(d), t, vfmanp_vd_vd_vd_vd(vd2getx_vd_vd2(d), t, vcast_vd_d(1))); + return vd2setxy_vd2_vd_vd(s, vfma_vd_vd_vd_vd(s, v, vfma_vd_vd_vd_vd(vd2gety_vd_vd2(n), t, u))); +} + +static INLINE CONST VECTOR_CC vdouble2 ddmul_vd2_vd_vd(vdouble x, vdouble y) { + vdouble s = vmul_vd_vd_vd(x, y); + return vd2setxy_vd2_vd_vd(s, vfmapn_vd_vd_vd_vd(x, y, s)); +} + +static INLINE CONST VECTOR_CC vdouble2 ddsqu_vd2_vd2(vdouble2 x) { + vdouble s = vmul_vd_vd_vd(vd2getx_vd_vd2(x), vd2getx_vd_vd2(x)); + return vd2setxy_vd2_vd_vd(s, vfma_vd_vd_vd_vd(vadd_vd_vd_vd(vd2getx_vd_vd2(x), vd2getx_vd_vd2(x)), vd2gety_vd_vd2(x), vfmapn_vd_vd_vd_vd(vd2getx_vd_vd2(x), vd2getx_vd_vd2(x), s))); +} + +static INLINE CONST VECTOR_CC vdouble2 ddmul_vd2_vd2_vd2(vdouble2 x, vdouble2 y) { + vdouble s = vmul_vd_vd_vd(vd2getx_vd_vd2(x), vd2getx_vd_vd2(y)); + return vd2setxy_vd2_vd_vd(s, vfma_vd_vd_vd_vd(vd2getx_vd_vd2(x), vd2gety_vd_vd2(y), vfma_vd_vd_vd_vd(vd2gety_vd_vd2(x), vd2getx_vd_vd2(y), vfmapn_vd_vd_vd_vd(vd2getx_vd_vd2(x), vd2getx_vd_vd2(y), s)))); +} + +static INLINE CONST VECTOR_CC vdouble ddmul_vd_vd2_vd2(vdouble2 x, vdouble2 y) { + return vfma_vd_vd_vd_vd(vd2getx_vd_vd2(x), vd2getx_vd_vd2(y), vfma_vd_vd_vd_vd(vd2gety_vd_vd2(x), vd2getx_vd_vd2(y), vmul_vd_vd_vd(vd2getx_vd_vd2(x), vd2gety_vd_vd2(y)))); +} + +static INLINE CONST VECTOR_CC vdouble ddsqu_vd_vd2(vdouble2 x) { + return vfma_vd_vd_vd_vd(vd2getx_vd_vd2(x), vd2getx_vd_vd2(x), vadd_vd_vd_vd(vmul_vd_vd_vd(vd2getx_vd_vd2(x), vd2gety_vd_vd2(x)), vmul_vd_vd_vd(vd2getx_vd_vd2(x), vd2gety_vd_vd2(x)))); +} + +static INLINE CONST VECTOR_CC vdouble2 ddmul_vd2_vd2_vd(vdouble2 x, vdouble y) { + vdouble s = vmul_vd_vd_vd(vd2getx_vd_vd2(x), y); + return vd2setxy_vd2_vd_vd(s, vfma_vd_vd_vd_vd(vd2gety_vd_vd2(x), y, vfmapn_vd_vd_vd_vd(vd2getx_vd_vd2(x), y, s))); +} + +static INLINE CONST VECTOR_CC vdouble2 ddrec_vd2_vd(vdouble d) { + vdouble s = vrec_vd_vd(d); + return vd2setxy_vd2_vd_vd(s, vmul_vd_vd_vd(s, vfmanp_vd_vd_vd_vd(d, s, vcast_vd_d(1)))); +} + +static INLINE CONST VECTOR_CC vdouble2 ddrec_vd2_vd2(vdouble2 d) { + vdouble s = vrec_vd_vd(vd2getx_vd_vd2(d)); + return vd2setxy_vd2_vd_vd(s, vmul_vd_vd_vd(s, vfmanp_vd_vd_vd_vd(vd2gety_vd_vd2(d), s, vfmanp_vd_vd_vd_vd(vd2getx_vd_vd2(d), s, vcast_vd_d(1))))); +} +#else // #ifdef ENABLE_FMA_DP +static INLINE CONST VECTOR_CC vdouble2 dddiv_vd2_vd2_vd2(vdouble2 n, vdouble2 d) { + vdouble t = vrec_vd_vd(vd2getx_vd_vd2(d)); + vdouble dh = vupper_vd_vd(vd2getx_vd_vd2(d)), dl = vsub_vd_vd_vd(vd2getx_vd_vd2(d), dh); + vdouble th = vupper_vd_vd(t ), tl = vsub_vd_vd_vd(t , th); + vdouble nhh = vupper_vd_vd(vd2getx_vd_vd2(n)), nhl = vsub_vd_vd_vd(vd2getx_vd_vd2(n), nhh); + + vdouble s = vmul_vd_vd_vd(vd2getx_vd_vd2(n), t); + + vdouble u = vadd_vd_5vd(vsub_vd_vd_vd(vmul_vd_vd_vd(nhh, th), s), vmul_vd_vd_vd(nhh, tl), vmul_vd_vd_vd(nhl, th), vmul_vd_vd_vd(nhl, tl), + vmul_vd_vd_vd(s, vsub_vd_5vd(vcast_vd_d(1), vmul_vd_vd_vd(dh, th), vmul_vd_vd_vd(dh, tl), vmul_vd_vd_vd(dl, th), vmul_vd_vd_vd(dl, tl)))); + + return vd2setxy_vd2_vd_vd(s, vmla_vd_vd_vd_vd(t, vsub_vd_vd_vd(vd2gety_vd_vd2(n), vmul_vd_vd_vd(s, vd2gety_vd_vd2(d))), u)); +} + +static INLINE CONST VECTOR_CC vdouble2 ddmul_vd2_vd_vd(vdouble x, vdouble y) { + vdouble xh = vupper_vd_vd(x), xl = vsub_vd_vd_vd(x, xh); + vdouble yh = vupper_vd_vd(y), yl = vsub_vd_vd_vd(y, yh); + + vdouble s = vmul_vd_vd_vd(x, y); + return vd2setxy_vd2_vd_vd(s, vadd_vd_5vd(vmul_vd_vd_vd(xh, yh), vneg_vd_vd(s), vmul_vd_vd_vd(xl, yh), vmul_vd_vd_vd(xh, yl), vmul_vd_vd_vd(xl, yl))); +} + +static INLINE CONST VECTOR_CC vdouble2 ddmul_vd2_vd2_vd(vdouble2 x, vdouble y) { + vdouble xh = vupper_vd_vd(vd2getx_vd_vd2(x)), xl = vsub_vd_vd_vd(vd2getx_vd_vd2(x), xh); + vdouble yh = vupper_vd_vd(y ), yl = vsub_vd_vd_vd(y , yh); + + vdouble s = vmul_vd_vd_vd(vd2getx_vd_vd2(x), y); + return vd2setxy_vd2_vd_vd(s, vadd_vd_6vd(vmul_vd_vd_vd(xh, yh), vneg_vd_vd(s), vmul_vd_vd_vd(xl, yh), vmul_vd_vd_vd(xh, yl), vmul_vd_vd_vd(xl, yl), vmul_vd_vd_vd(vd2gety_vd_vd2(x), y))); +} + +static INLINE CONST VECTOR_CC vdouble2 ddmul_vd2_vd2_vd2(vdouble2 x, vdouble2 y) { + vdouble xh = vupper_vd_vd(vd2getx_vd_vd2(x)), xl = vsub_vd_vd_vd(vd2getx_vd_vd2(x), xh); + vdouble yh = vupper_vd_vd(vd2getx_vd_vd2(y)), yl = vsub_vd_vd_vd(vd2getx_vd_vd2(y), yh); + + vdouble s = vmul_vd_vd_vd(vd2getx_vd_vd2(x), vd2getx_vd_vd2(y)); + return vd2setxy_vd2_vd_vd(s, vadd_vd_7vd(vmul_vd_vd_vd(xh, yh), vneg_vd_vd(s), vmul_vd_vd_vd(xl, yh), vmul_vd_vd_vd(xh, yl), vmul_vd_vd_vd(xl, yl), vmul_vd_vd_vd(vd2getx_vd_vd2(x), vd2gety_vd_vd2(y)), vmul_vd_vd_vd(vd2gety_vd_vd2(x), vd2getx_vd_vd2(y)))); +} + +static INLINE CONST VECTOR_CC vdouble ddmul_vd_vd2_vd2(vdouble2 x, vdouble2 y) { + vdouble xh = vupper_vd_vd(vd2getx_vd_vd2(x)), xl = vsub_vd_vd_vd(vd2getx_vd_vd2(x), xh); + vdouble yh = vupper_vd_vd(vd2getx_vd_vd2(y)), yl = vsub_vd_vd_vd(vd2getx_vd_vd2(y), yh); + + return vadd_vd_6vd(vmul_vd_vd_vd(vd2gety_vd_vd2(x), yh), vmul_vd_vd_vd(xh, vd2gety_vd_vd2(y)), vmul_vd_vd_vd(xl, yl), vmul_vd_vd_vd(xh, yl), vmul_vd_vd_vd(xl, yh), vmul_vd_vd_vd(xh, yh)); +} + +static INLINE CONST VECTOR_CC vdouble2 ddsqu_vd2_vd2(vdouble2 x) { + vdouble xh = vupper_vd_vd(vd2getx_vd_vd2(x)), xl = vsub_vd_vd_vd(vd2getx_vd_vd2(x), xh); + + vdouble s = vmul_vd_vd_vd(vd2getx_vd_vd2(x), vd2getx_vd_vd2(x)); + return vd2setxy_vd2_vd_vd(s, vadd_vd_5vd(vmul_vd_vd_vd(xh, xh), vneg_vd_vd(s), vmul_vd_vd_vd(vadd_vd_vd_vd(xh, xh), xl), vmul_vd_vd_vd(xl, xl), vmul_vd_vd_vd(vd2getx_vd_vd2(x), vadd_vd_vd_vd(vd2gety_vd_vd2(x), vd2gety_vd_vd2(x))))); +} + +static INLINE CONST VECTOR_CC vdouble ddsqu_vd_vd2(vdouble2 x) { + vdouble xh = vupper_vd_vd(vd2getx_vd_vd2(x)), xl = vsub_vd_vd_vd(vd2getx_vd_vd2(x), xh); + + return vadd_vd_5vd(vmul_vd_vd_vd(xh, vd2gety_vd_vd2(x)), vmul_vd_vd_vd(xh, vd2gety_vd_vd2(x)), vmul_vd_vd_vd(xl, xl), vadd_vd_vd_vd(vmul_vd_vd_vd(xh, xl), vmul_vd_vd_vd(xh, xl)), vmul_vd_vd_vd(xh, xh)); +} + +static INLINE CONST VECTOR_CC vdouble2 ddrec_vd2_vd(vdouble d) { + vdouble t = vrec_vd_vd(d); + vdouble dh = vupper_vd_vd(d), dl = vsub_vd_vd_vd(d, dh); + vdouble th = vupper_vd_vd(t), tl = vsub_vd_vd_vd(t, th); + + return vd2setxy_vd2_vd_vd(t, vmul_vd_vd_vd(t, vsub_vd_5vd(vcast_vd_d(1), vmul_vd_vd_vd(dh, th), vmul_vd_vd_vd(dh, tl), vmul_vd_vd_vd(dl, th), vmul_vd_vd_vd(dl, tl)))); +} + +static INLINE CONST VECTOR_CC vdouble2 ddrec_vd2_vd2(vdouble2 d) { + vdouble t = vrec_vd_vd(vd2getx_vd_vd2(d)); + vdouble dh = vupper_vd_vd(vd2getx_vd_vd2(d)), dl = vsub_vd_vd_vd(vd2getx_vd_vd2(d), dh); + vdouble th = vupper_vd_vd(t ), tl = vsub_vd_vd_vd(t , th); + + return vd2setxy_vd2_vd_vd(t, vmul_vd_vd_vd(t, vsub_vd_6vd(vcast_vd_d(1), vmul_vd_vd_vd(dh, th), vmul_vd_vd_vd(dh, tl), vmul_vd_vd_vd(dl, th), vmul_vd_vd_vd(dl, tl), vmul_vd_vd_vd(vd2gety_vd_vd2(d), t)))); +} +#endif // #ifdef ENABLE_FMA_DP + +static INLINE CONST VECTOR_CC vdouble2 ddsqrt_vd2_vd2(vdouble2 d) { + vdouble t = vsqrt_vd_vd(vadd_vd_vd_vd(vd2getx_vd_vd2(d), vd2gety_vd_vd2(d))); + return ddscale_vd2_vd2_vd(ddmul_vd2_vd2_vd2(ddadd2_vd2_vd2_vd2(d, ddmul_vd2_vd_vd(t, t)), ddrec_vd2_vd(t)), vcast_vd_d(0.5)); +} + +static INLINE CONST VECTOR_CC vdouble2 ddsqrt_vd2_vd(vdouble d) { + vdouble t = vsqrt_vd_vd(d); + return ddscale_vd2_vd2_vd(ddmul_vd2_vd2_vd2(ddadd2_vd2_vd_vd2(d, ddmul_vd2_vd_vd(t, t)), ddrec_vd2_vd(t)), vcast_vd_d(0.5)); +} + +static INLINE CONST VECTOR_CC vdouble2 ddmla_vd2_vd2_vd2_vd2(vdouble2 x, vdouble2 y, vdouble2 z) { + return ddadd_vd2_vd2_vd2(z, ddmul_vd2_vd2_vd2(x, y)); +} diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/common/df.h b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/common/df.h new file mode 100644 index 00000000000..b5a6462d58e --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/common/df.h @@ -0,0 +1,369 @@ +// Copyright Naoki Shibata and contributors 2010 - 2024. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#if !(defined(ENABLE_SVE) || defined(ENABLE_SVENOFMA) || defined(ENABLE_RVVM1) || defined(ENABLE_RVVM1NOFMA) || defined(ENABLE_RVVM2) || defined(ENABLE_RVVM2NOFMA)) +#if !defined(SLEEF_ENABLE_CUDA) +typedef struct { + vfloat x, y; +} vfloat2; +#else +typedef float2 vfloat2; +#endif + +static INLINE CONST VECTOR_CC vfloat vf2getx_vf_vf2(vfloat2 v) { return v.x; } +static INLINE CONST VECTOR_CC vfloat vf2gety_vf_vf2(vfloat2 v) { return v.y; } +static INLINE CONST VECTOR_CC vfloat2 vf2setxy_vf2_vf_vf(vfloat x, vfloat y) { vfloat2 v; v.x = x; v.y = y; return v; } +static INLINE CONST VECTOR_CC vfloat2 vf2setx_vf2_vf2_vf(vfloat2 v, vfloat d) { v.x = d; return v; } +static INLINE CONST VECTOR_CC vfloat2 vf2sety_vf2_vf2_vf(vfloat2 v, vfloat d) { v.y = d; return v; } +#endif + +static INLINE CONST VECTOR_CC vfloat vupper_vf_vf(vfloat d) { + return vreinterpret_vf_vi2(vand_vi2_vi2_vi2(vreinterpret_vi2_vf(d), vcast_vi2_i(0xfffff000))); +} + +static INLINE CONST VECTOR_CC vfloat2 vcast_vf2_vf_vf(vfloat h, vfloat l) { + return vf2setxy_vf2_vf_vf(h, l); +} + +static INLINE CONST VECTOR_CC vfloat2 vcast_vf2_f_f(float h, float l) { + return vf2setxy_vf2_vf_vf(vcast_vf_f(h), vcast_vf_f(l)); +} + +static INLINE CONST VECTOR_CC vfloat2 vcast_vf2_d(double d) { + return vf2setxy_vf2_vf_vf(vcast_vf_f(d), vcast_vf_f(d - (float)d)); +} + +static INLINE CONST VECTOR_CC vfloat2 vsel_vf2_vo_vf2_vf2(vopmask m, vfloat2 x, vfloat2 y) { + return vf2setxy_vf2_vf_vf(vsel_vf_vo_vf_vf(m, vf2getx_vf_vf2(x), vf2getx_vf_vf2(y)), vsel_vf_vo_vf_vf(m, vf2gety_vf_vf2(x), vf2gety_vf_vf2(y))); +} + +static INLINE CONST VECTOR_CC vfloat2 vsel_vf2_vo_f_f_f_f(vopmask o, float x1, float y1, float x0, float y0) { + return vf2setxy_vf2_vf_vf(vsel_vf_vo_f_f(o, x1, x0), vsel_vf_vo_f_f(o, y1, y0)); +} + +static INLINE CONST VECTOR_CC vfloat2 vsel_vf2_vo_vo_d_d_d(vopmask o0, vopmask o1, double d0, double d1, double d2) { + return vsel_vf2_vo_vf2_vf2(o0, vcast_vf2_d(d0), vsel_vf2_vo_vf2_vf2(o1, vcast_vf2_d(d1), vcast_vf2_d(d2))); +} + +static INLINE CONST VECTOR_CC vfloat2 vsel_vf2_vo_vo_vo_d_d_d_d(vopmask o0, vopmask o1, vopmask o2, double d0, double d1, double d2, double d3) { + return vsel_vf2_vo_vf2_vf2(o0, vcast_vf2_d(d0), vsel_vf2_vo_vf2_vf2(o1, vcast_vf2_d(d1), vsel_vf2_vo_vf2_vf2(o2, vcast_vf2_d(d2), vcast_vf2_d(d3)))); +} + +static INLINE CONST VECTOR_CC vfloat2 vabs_vf2_vf2(vfloat2 x) { + return vcast_vf2_vf_vf(vreinterpret_vf_vm(vxor_vm_vm_vm(vand_vm_vm_vm(vreinterpret_vm_vf(vcast_vf_f(-0.0)), vreinterpret_vm_vf(vf2getx_vf_vf2(x))), vreinterpret_vm_vf(vf2getx_vf_vf2(x)))), + vreinterpret_vf_vm(vxor_vm_vm_vm(vand_vm_vm_vm(vreinterpret_vm_vf(vcast_vf_f(-0.0)), vreinterpret_vm_vf(vf2getx_vf_vf2(x))), vreinterpret_vm_vf(vf2gety_vf_vf2(x))))); +} + +static INLINE CONST VECTOR_CC vfloat vadd_vf_3vf(vfloat v0, vfloat v1, vfloat v2) { + return vadd_vf_vf_vf(vadd_vf_vf_vf(v0, v1), v2); +} + +static INLINE CONST VECTOR_CC vfloat vadd_vf_4vf(vfloat v0, vfloat v1, vfloat v2, vfloat v3) { + return vadd_vf_3vf(vadd_vf_vf_vf(v0, v1), v2, v3); +} + +static INLINE CONST VECTOR_CC vfloat vadd_vf_5vf(vfloat v0, vfloat v1, vfloat v2, vfloat v3, vfloat v4) { + return vadd_vf_4vf(vadd_vf_vf_vf(v0, v1), v2, v3, v4); +} + +static INLINE CONST VECTOR_CC vfloat vadd_vf_6vf(vfloat v0, vfloat v1, vfloat v2, vfloat v3, vfloat v4, vfloat v5) { + return vadd_vf_5vf(vadd_vf_vf_vf(v0, v1), v2, v3, v4, v5); +} + +static INLINE CONST VECTOR_CC vfloat vadd_vf_7vf(vfloat v0, vfloat v1, vfloat v2, vfloat v3, vfloat v4, vfloat v5, vfloat v6) { + return vadd_vf_6vf(vadd_vf_vf_vf(v0, v1), v2, v3, v4, v5, v6); +} + +static INLINE CONST VECTOR_CC vfloat vsub_vf_3vf(vfloat v0, vfloat v1, vfloat v2) { + return vsub_vf_vf_vf(vsub_vf_vf_vf(v0, v1), v2); +} + +static INLINE CONST VECTOR_CC vfloat vsub_vf_4vf(vfloat v0, vfloat v1, vfloat v2, vfloat v3) { + return vsub_vf_3vf(vsub_vf_vf_vf(v0, v1), v2, v3); +} + +static INLINE CONST VECTOR_CC vfloat vsub_vf_5vf(vfloat v0, vfloat v1, vfloat v2, vfloat v3, vfloat v4) { + return vsub_vf_4vf(vsub_vf_vf_vf(v0, v1), v2, v3, v4); +} + +// + +static INLINE CONST VECTOR_CC vfloat2 dfneg_vf2_vf2(vfloat2 x) { + return vcast_vf2_vf_vf(vneg_vf_vf(vf2getx_vf_vf2(x)), vneg_vf_vf(vf2gety_vf_vf2(x))); +} + +static INLINE CONST VECTOR_CC vfloat2 dfabs_vf2_vf2(vfloat2 x) { + return vcast_vf2_vf_vf(vabs_vf_vf(vf2getx_vf_vf2(x)), + vreinterpret_vf_vm(vxor_vm_vm_vm(vreinterpret_vm_vf(vf2gety_vf_vf2(x)), vand_vm_vm_vm(vreinterpret_vm_vf(vf2getx_vf_vf2(x)), vreinterpret_vm_vf(vcast_vf_f(-0.0f)))))); +} + +static INLINE CONST VECTOR_CC vfloat2 dfnormalize_vf2_vf2(vfloat2 t) { + vfloat s = vadd_vf_vf_vf(vf2getx_vf_vf2(t), vf2gety_vf_vf2(t)); + return vf2setxy_vf2_vf_vf(s, vadd_vf_vf_vf(vsub_vf_vf_vf(vf2getx_vf_vf2(t), s), vf2gety_vf_vf2(t))); +} + +static INLINE CONST VECTOR_CC vfloat2 dfscale_vf2_vf2_vf(vfloat2 d, vfloat s) { + return vf2setxy_vf2_vf_vf(vmul_vf_vf_vf(vf2getx_vf_vf2(d), s), vmul_vf_vf_vf(vf2gety_vf_vf2(d), s)); +} + +static INLINE CONST VECTOR_CC vfloat2 dfadd_vf2_vf_vf(vfloat x, vfloat y) { + vfloat s = vadd_vf_vf_vf(x, y); + return vf2setxy_vf2_vf_vf(s, vadd_vf_vf_vf(vsub_vf_vf_vf(x, s), y)); +} + +static INLINE CONST VECTOR_CC vfloat2 dfadd2_vf2_vf_vf(vfloat x, vfloat y) { + vfloat s = vadd_vf_vf_vf(x, y); + vfloat v = vsub_vf_vf_vf(s, x); + return vf2setxy_vf2_vf_vf(s, vadd_vf_vf_vf(vsub_vf_vf_vf(x, vsub_vf_vf_vf(s, v)), vsub_vf_vf_vf(y, v))); +} + +static INLINE CONST VECTOR_CC vfloat2 dfadd2_vf2_vf_vf2(vfloat x, vfloat2 y) { + vfloat s = vadd_vf_vf_vf(x, vf2getx_vf_vf2(y)); + vfloat v = vsub_vf_vf_vf(s, x); + return vf2setxy_vf2_vf_vf(s, vadd_vf_vf_vf(vadd_vf_vf_vf(vsub_vf_vf_vf(x, vsub_vf_vf_vf(s, v)), vsub_vf_vf_vf(vf2getx_vf_vf2(y), v)), vf2gety_vf_vf2(y))); + +} + +static INLINE CONST VECTOR_CC vfloat2 dfadd_vf2_vf2_vf(vfloat2 x, vfloat y) { + vfloat s = vadd_vf_vf_vf(vf2getx_vf_vf2(x), y); + return vf2setxy_vf2_vf_vf(s, vadd_vf_3vf(vsub_vf_vf_vf(vf2getx_vf_vf2(x), s), y, vf2gety_vf_vf2(x))); +} + +static INLINE CONST VECTOR_CC vfloat2 dfsub_vf2_vf2_vf(vfloat2 x, vfloat y) { + vfloat s = vsub_vf_vf_vf(vf2getx_vf_vf2(x), y); + return vf2setxy_vf2_vf_vf(s, vadd_vf_vf_vf(vsub_vf_vf_vf(vsub_vf_vf_vf(vf2getx_vf_vf2(x), s), y), vf2gety_vf_vf2(x))); +} + +static INLINE CONST VECTOR_CC vfloat2 dfadd2_vf2_vf2_vf(vfloat2 x, vfloat y) { + vfloat s = vadd_vf_vf_vf(vf2getx_vf_vf2(x), y); + vfloat v = vsub_vf_vf_vf(s, vf2getx_vf_vf2(x)); + vfloat t = vadd_vf_vf_vf(vsub_vf_vf_vf(vf2getx_vf_vf2(x), vsub_vf_vf_vf(s, v)), vsub_vf_vf_vf(y, v)); + return vf2setxy_vf2_vf_vf(s, vadd_vf_vf_vf(t, vf2gety_vf_vf2(x))); +} + +static INLINE CONST VECTOR_CC vfloat2 dfadd_vf2_vf_vf2(vfloat x, vfloat2 y) { + vfloat s = vadd_vf_vf_vf(x, vf2getx_vf_vf2(y)); + return vf2setxy_vf2_vf_vf(s, vadd_vf_3vf(vsub_vf_vf_vf(x, s), vf2getx_vf_vf2(y), vf2gety_vf_vf2(y))); +} + +static INLINE CONST VECTOR_CC vfloat2 dfadd_vf2_vf2_vf2(vfloat2 x, vfloat2 y) { + // |x| >= |y| + + vfloat s = vadd_vf_vf_vf(vf2getx_vf_vf2(x), vf2getx_vf_vf2(y)); + return vf2setxy_vf2_vf_vf(s, vadd_vf_4vf(vsub_vf_vf_vf(vf2getx_vf_vf2(x), s), vf2getx_vf_vf2(y), vf2gety_vf_vf2(x), vf2gety_vf_vf2(y))); +} + +static INLINE CONST VECTOR_CC vfloat2 dfadd2_vf2_vf2_vf2(vfloat2 x, vfloat2 y) { + vfloat s = vadd_vf_vf_vf(vf2getx_vf_vf2(x), vf2getx_vf_vf2(y)); + vfloat v = vsub_vf_vf_vf(s, vf2getx_vf_vf2(x)); + vfloat t = vadd_vf_vf_vf(vsub_vf_vf_vf(vf2getx_vf_vf2(x), vsub_vf_vf_vf(s, v)), vsub_vf_vf_vf(vf2getx_vf_vf2(y), v)); + return vf2setxy_vf2_vf_vf(s, vadd_vf_vf_vf(t, vadd_vf_vf_vf(vf2gety_vf_vf2(x), vf2gety_vf_vf2(y)))); +} + +static INLINE CONST VECTOR_CC vfloat2 dfsub_vf2_vf_vf(vfloat x, vfloat y) { + // |x| >= |y| + + vfloat s = vsub_vf_vf_vf(x, y); + return vf2setxy_vf2_vf_vf(s, vsub_vf_vf_vf(vsub_vf_vf_vf(x, s), y)); +} + +static INLINE CONST VECTOR_CC vfloat2 dfsub_vf2_vf2_vf2(vfloat2 x, vfloat2 y) { + // |x| >= |y| + + vfloat s = vsub_vf_vf_vf(vf2getx_vf_vf2(x), vf2getx_vf_vf2(y)); + vfloat t = vsub_vf_vf_vf(vf2getx_vf_vf2(x), s); + t = vsub_vf_vf_vf(t, vf2getx_vf_vf2(y)); + t = vadd_vf_vf_vf(t, vf2gety_vf_vf2(x)); + return vf2setxy_vf2_vf_vf(s, vsub_vf_vf_vf(t, vf2gety_vf_vf2(y))); +} + +#ifdef ENABLE_FMA_SP +static INLINE CONST VECTOR_CC vfloat2 dfdiv_vf2_vf2_vf2(vfloat2 n, vfloat2 d) { + vfloat t = vrec_vf_vf(vf2getx_vf_vf2(d)); + vfloat s = vmul_vf_vf_vf(vf2getx_vf_vf2(n), t); + vfloat u = vfmapn_vf_vf_vf_vf(t, vf2getx_vf_vf2(n), s); + vfloat v = vfmanp_vf_vf_vf_vf(vf2gety_vf_vf2(d), t, vfmanp_vf_vf_vf_vf(vf2getx_vf_vf2(d), t, vcast_vf_f(1))); + return vf2setxy_vf2_vf_vf(s, vfma_vf_vf_vf_vf(s, v, vfma_vf_vf_vf_vf(vf2gety_vf_vf2(n), t, u))); +} + +static INLINE CONST VECTOR_CC vfloat2 dfmul_vf2_vf_vf(vfloat x, vfloat y) { + vfloat s = vmul_vf_vf_vf(x, y); + return vf2setxy_vf2_vf_vf(s, vfmapn_vf_vf_vf_vf(x, y, s)); +} + +static INLINE CONST VECTOR_CC vfloat2 dfsqu_vf2_vf2(vfloat2 x) { + vfloat s = vmul_vf_vf_vf(vf2getx_vf_vf2(x), vf2getx_vf_vf2(x)); + return vf2setxy_vf2_vf_vf(s, vfma_vf_vf_vf_vf(vadd_vf_vf_vf(vf2getx_vf_vf2(x), vf2getx_vf_vf2(x)), vf2gety_vf_vf2(x), vfmapn_vf_vf_vf_vf(vf2getx_vf_vf2(x), vf2getx_vf_vf2(x), s))); +} + +static INLINE CONST VECTOR_CC vfloat dfsqu_vf_vf2(vfloat2 x) { + return vfma_vf_vf_vf_vf(vf2getx_vf_vf2(x), vf2getx_vf_vf2(x), vadd_vf_vf_vf(vmul_vf_vf_vf(vf2getx_vf_vf2(x), vf2gety_vf_vf2(x)), vmul_vf_vf_vf(vf2getx_vf_vf2(x), vf2gety_vf_vf2(x)))); +} + +static INLINE CONST VECTOR_CC vfloat2 dfmul_vf2_vf2_vf2(vfloat2 x, vfloat2 y) { + vfloat s = vmul_vf_vf_vf(vf2getx_vf_vf2(x), vf2getx_vf_vf2(y)); + return vf2setxy_vf2_vf_vf(s, vfma_vf_vf_vf_vf(vf2getx_vf_vf2(x), vf2gety_vf_vf2(y), vfma_vf_vf_vf_vf(vf2gety_vf_vf2(x), vf2getx_vf_vf2(y), vfmapn_vf_vf_vf_vf(vf2getx_vf_vf2(x), vf2getx_vf_vf2(y), s)))); +} + +static INLINE CONST VECTOR_CC vfloat dfmul_vf_vf2_vf2(vfloat2 x, vfloat2 y) { + return vfma_vf_vf_vf_vf(vf2getx_vf_vf2(x), vf2getx_vf_vf2(y), vfma_vf_vf_vf_vf(vf2gety_vf_vf2(x), vf2getx_vf_vf2(y), vmul_vf_vf_vf(vf2getx_vf_vf2(x), vf2gety_vf_vf2(y)))); +} + +static INLINE CONST VECTOR_CC vfloat2 dfmul_vf2_vf2_vf(vfloat2 x, vfloat y) { + vfloat s = vmul_vf_vf_vf(vf2getx_vf_vf2(x), y); + return vf2setxy_vf2_vf_vf(s, vfma_vf_vf_vf_vf(vf2gety_vf_vf2(x), y, vfmapn_vf_vf_vf_vf(vf2getx_vf_vf2(x), y, s))); +} + +static INLINE CONST VECTOR_CC vfloat2 dfrec_vf2_vf(vfloat d) { + vfloat s = vrec_vf_vf(d); + return vf2setxy_vf2_vf_vf(s, vmul_vf_vf_vf(s, vfmanp_vf_vf_vf_vf(d, s, vcast_vf_f(1)))); +} + +static INLINE CONST VECTOR_CC vfloat2 dfrec_vf2_vf2(vfloat2 d) { + vfloat s = vrec_vf_vf(vf2getx_vf_vf2(d)); + return vf2setxy_vf2_vf_vf(s, vmul_vf_vf_vf(s, vfmanp_vf_vf_vf_vf(vf2gety_vf_vf2(d), s, vfmanp_vf_vf_vf_vf(vf2getx_vf_vf2(d), s, vcast_vf_f(1))))); +} +#else +static INLINE CONST VECTOR_CC vfloat2 dfdiv_vf2_vf2_vf2(vfloat2 n, vfloat2 d) { + vfloat t = vrec_vf_vf(vf2getx_vf_vf2(d)); + vfloat dh = vupper_vf_vf(vf2getx_vf_vf2(d)), dl = vsub_vf_vf_vf(vf2getx_vf_vf2(d), dh); + vfloat th = vupper_vf_vf(t ), tl = vsub_vf_vf_vf(t , th); + vfloat nhh = vupper_vf_vf(vf2getx_vf_vf2(n)), nhl = vsub_vf_vf_vf(vf2getx_vf_vf2(n), nhh); + + vfloat s = vmul_vf_vf_vf(vf2getx_vf_vf2(n), t); + + vfloat u, w; + w = vcast_vf_f(-1); + w = vmla_vf_vf_vf_vf(dh, th, w); + w = vmla_vf_vf_vf_vf(dh, tl, w); + w = vmla_vf_vf_vf_vf(dl, th, w); + w = vmla_vf_vf_vf_vf(dl, tl, w); + w = vneg_vf_vf(w); + + u = vmla_vf_vf_vf_vf(nhh, th, vneg_vf_vf(s)); + u = vmla_vf_vf_vf_vf(nhh, tl, u); + u = vmla_vf_vf_vf_vf(nhl, th, u); + u = vmla_vf_vf_vf_vf(nhl, tl, u); + u = vmla_vf_vf_vf_vf(s, w, u); + + return vf2setxy_vf2_vf_vf(s, vmla_vf_vf_vf_vf(t, vsub_vf_vf_vf(vf2gety_vf_vf2(n), vmul_vf_vf_vf(s, vf2gety_vf_vf2(d))), u)); +} + +static INLINE CONST VECTOR_CC vfloat2 dfmul_vf2_vf_vf(vfloat x, vfloat y) { + vfloat xh = vupper_vf_vf(x), xl = vsub_vf_vf_vf(x, xh); + vfloat yh = vupper_vf_vf(y), yl = vsub_vf_vf_vf(y, yh); + + vfloat s = vmul_vf_vf_vf(x, y), t; + + t = vmla_vf_vf_vf_vf(xh, yh, vneg_vf_vf(s)); + t = vmla_vf_vf_vf_vf(xl, yh, t); + t = vmla_vf_vf_vf_vf(xh, yl, t); + t = vmla_vf_vf_vf_vf(xl, yl, t); + + return vf2setxy_vf2_vf_vf(s, t); +} + +static INLINE CONST VECTOR_CC vfloat2 dfmul_vf2_vf2_vf(vfloat2 x, vfloat y) { + vfloat xh = vupper_vf_vf(vf2getx_vf_vf2(x)), xl = vsub_vf_vf_vf(vf2getx_vf_vf2(x), xh); + vfloat yh = vupper_vf_vf(y ), yl = vsub_vf_vf_vf(y , yh); + + vfloat s = vmul_vf_vf_vf(vf2getx_vf_vf2(x), y), t; + + t = vmla_vf_vf_vf_vf(xh, yh, vneg_vf_vf(s)); + t = vmla_vf_vf_vf_vf(xl, yh, t); + t = vmla_vf_vf_vf_vf(xh, yl, t); + t = vmla_vf_vf_vf_vf(xl, yl, t); + t = vmla_vf_vf_vf_vf(vf2gety_vf_vf2(x), y, t); + + return vf2setxy_vf2_vf_vf(s, t); +} + +static INLINE CONST VECTOR_CC vfloat2 dfmul_vf2_vf2_vf2(vfloat2 x, vfloat2 y) { + vfloat xh = vupper_vf_vf(vf2getx_vf_vf2(x)), xl = vsub_vf_vf_vf(vf2getx_vf_vf2(x), xh); + vfloat yh = vupper_vf_vf(vf2getx_vf_vf2(y)), yl = vsub_vf_vf_vf(vf2getx_vf_vf2(y), yh); + + vfloat s = vmul_vf_vf_vf(vf2getx_vf_vf2(x), vf2getx_vf_vf2(y)), t; + + t = vmla_vf_vf_vf_vf(xh, yh, vneg_vf_vf(s)); + t = vmla_vf_vf_vf_vf(xl, yh, t); + t = vmla_vf_vf_vf_vf(xh, yl, t); + t = vmla_vf_vf_vf_vf(xl, yl, t); + t = vmla_vf_vf_vf_vf(vf2getx_vf_vf2(x), vf2gety_vf_vf2(y), t); + t = vmla_vf_vf_vf_vf(vf2gety_vf_vf2(x), vf2getx_vf_vf2(y), t); + + return vf2setxy_vf2_vf_vf(s, t); +} + +static INLINE CONST VECTOR_CC vfloat dfmul_vf_vf2_vf2(vfloat2 x, vfloat2 y) { + vfloat xh = vupper_vf_vf(vf2getx_vf_vf2(x)), xl = vsub_vf_vf_vf(vf2getx_vf_vf2(x), xh); + vfloat yh = vupper_vf_vf(vf2getx_vf_vf2(y)), yl = vsub_vf_vf_vf(vf2getx_vf_vf2(y), yh); + + return vadd_vf_6vf(vmul_vf_vf_vf(vf2gety_vf_vf2(x), yh), vmul_vf_vf_vf(xh, vf2gety_vf_vf2(y)), vmul_vf_vf_vf(xl, yl), vmul_vf_vf_vf(xh, yl), vmul_vf_vf_vf(xl, yh), vmul_vf_vf_vf(xh, yh)); +} + +static INLINE CONST VECTOR_CC vfloat2 dfsqu_vf2_vf2(vfloat2 x) { + vfloat xh = vupper_vf_vf(vf2getx_vf_vf2(x)), xl = vsub_vf_vf_vf(vf2getx_vf_vf2(x), xh); + + vfloat s = vmul_vf_vf_vf(vf2getx_vf_vf2(x), vf2getx_vf_vf2(x)), t; + + t = vmla_vf_vf_vf_vf(xh, xh, vneg_vf_vf(s)); + t = vmla_vf_vf_vf_vf(vadd_vf_vf_vf(xh, xh), xl, t); + t = vmla_vf_vf_vf_vf(xl, xl, t); + t = vmla_vf_vf_vf_vf(vf2getx_vf_vf2(x), vadd_vf_vf_vf(vf2gety_vf_vf2(x), vf2gety_vf_vf2(x)), t); + + return vf2setxy_vf2_vf_vf(s, t); +} + +static INLINE CONST VECTOR_CC vfloat dfsqu_vf_vf2(vfloat2 x) { + vfloat xh = vupper_vf_vf(vf2getx_vf_vf2(x)), xl = vsub_vf_vf_vf(vf2getx_vf_vf2(x), xh); + + return vadd_vf_5vf(vmul_vf_vf_vf(xh, vf2gety_vf_vf2(x)), vmul_vf_vf_vf(xh, vf2gety_vf_vf2(x)), vmul_vf_vf_vf(xl, xl), vadd_vf_vf_vf(vmul_vf_vf_vf(xh, xl), vmul_vf_vf_vf(xh, xl)), vmul_vf_vf_vf(xh, xh)); +} + +static INLINE CONST VECTOR_CC vfloat2 dfrec_vf2_vf(vfloat d) { + vfloat t = vrec_vf_vf(d); + vfloat dh = vupper_vf_vf(d), dl = vsub_vf_vf_vf(d, dh); + vfloat th = vupper_vf_vf(t), tl = vsub_vf_vf_vf(t, th); + + vfloat u = vcast_vf_f(-1); + u = vmla_vf_vf_vf_vf(dh, th, u); + u = vmla_vf_vf_vf_vf(dh, tl, u); + u = vmla_vf_vf_vf_vf(dl, th, u); + u = vmla_vf_vf_vf_vf(dl, tl, u); + + return vf2setxy_vf2_vf_vf(t, vmul_vf_vf_vf(vneg_vf_vf(t), u)); +} + +static INLINE CONST VECTOR_CC vfloat2 dfrec_vf2_vf2(vfloat2 d) { + vfloat t = vrec_vf_vf(vf2getx_vf_vf2(d)); + vfloat dh = vupper_vf_vf(vf2getx_vf_vf2(d)), dl = vsub_vf_vf_vf(vf2getx_vf_vf2(d), dh); + vfloat th = vupper_vf_vf(t ), tl = vsub_vf_vf_vf(t , th); + + vfloat u = vcast_vf_f(-1); + u = vmla_vf_vf_vf_vf(dh, th, u); + u = vmla_vf_vf_vf_vf(dh, tl, u); + u = vmla_vf_vf_vf_vf(dl, th, u); + u = vmla_vf_vf_vf_vf(dl, tl, u); + u = vmla_vf_vf_vf_vf(vf2gety_vf_vf2(d), t, u); + + return vf2setxy_vf2_vf_vf(t, vmul_vf_vf_vf(vneg_vf_vf(t), u)); +} +#endif + +static INLINE CONST VECTOR_CC vfloat2 dfsqrt_vf2_vf2(vfloat2 d) { +#ifdef ENABLE_RECSQRT_SP + vfloat x = vrecsqrt_vf_vf(vadd_vf_vf_vf(vf2getx_vf_vf2(d), vf2gety_vf_vf2(d))); + vfloat2 r = dfmul_vf2_vf2_vf(d, x); + return dfscale_vf2_vf2_vf(dfmul_vf2_vf2_vf2(r, dfadd2_vf2_vf2_vf(dfmul_vf2_vf2_vf(r, x), vcast_vf_f(-3.0))), vcast_vf_f(-0.5)); +#else + vfloat t = vsqrt_vf_vf(vadd_vf_vf_vf(vf2getx_vf_vf2(d), vf2gety_vf_vf2(d))); + return dfscale_vf2_vf2_vf(dfmul_vf2_vf2_vf2(dfadd2_vf2_vf2_vf2(d, dfmul_vf2_vf_vf(t, t)), dfrec_vf2_vf(t)), vcast_vf_f(0.5)); +#endif +} + +static INLINE CONST VECTOR_CC vfloat2 dfsqrt_vf2_vf(vfloat d) { + vfloat t = vsqrt_vf_vf(d); + return dfscale_vf2_vf2_vf(dfmul_vf2_vf2_vf2(dfadd2_vf2_vf_vf2(d, dfmul_vf2_vf_vf(t, t)), dfrec_vf2_vf(t)), vcast_vf_f(0.5f)); +} diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/common/estrin.h b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/common/estrin.h new file mode 100644 index 00000000000..1953ac6a6f2 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/common/estrin.h @@ -0,0 +1,40 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// These are macros for evaluating polynomials using Estrin's method + +#define POLY2(x, c1, c0) MLA(x, C2V(c1), C2V(c0)) +#define POLY3(x, x2, c2, c1, c0) MLA(x2, C2V(c2), MLA(x, C2V(c1), C2V(c0))) +#define POLY4(x, x2, c3, c2, c1, c0) MLA(x2, MLA(x, C2V(c3), C2V(c2)), MLA(x, C2V(c1), C2V(c0))) +#define POLY5(x, x2, x4, c4, c3, c2, c1, c0) MLA(x4, C2V(c4), POLY4(x, x2, c3, c2, c1, c0)) +#define POLY6(x, x2, x4, c5, c4, c3, c2, c1, c0) MLA(x4, POLY2(x, c5, c4), POLY4(x, x2, c3, c2, c1, c0)) +#define POLY7(x, x2, x4, c6, c5, c4, c3, c2, c1, c0) MLA(x4, POLY3(x, x2, c6, c5, c4), POLY4(x, x2, c3, c2, c1, c0)) +#define POLY8(x, x2, x4, c7, c6, c5, c4, c3, c2, c1, c0) MLA(x4, POLY4(x, x2, c7, c6, c5, c4), POLY4(x, x2, c3, c2, c1, c0)) +#define POLY9(x, x2, x4, x8, c8, c7, c6, c5, c4, c3, c2, c1, c0)\ + MLA(x8, C2V(c8), POLY8(x, x2, x4, c7, c6, c5, c4, c3, c2, c1, c0)) +#define POLY10(x, x2, x4, x8, c9, c8, c7, c6, c5, c4, c3, c2, c1, c0)\ + MLA(x8, POLY2(x, c9, c8), POLY8(x, x2, x4, c7, c6, c5, c4, c3, c2, c1, c0)) +#define POLY11(x, x2, x4, x8, ca, c9, c8, c7, c6, c5, c4, c3, c2, c1, c0)\ + MLA(x8, POLY3(x, x2, ca, c9, c8), POLY8(x, x2, x4, c7, c6, c5, c4, c3, c2, c1, c0)) +#define POLY12(x, x2, x4, x8, cb, ca, c9, c8, c7, c6, c5, c4, c3, c2, c1, c0)\ + MLA(x8, POLY4(x, x2, cb, ca, c9, c8), POLY8(x, x2, x4, c7, c6, c5, c4, c3, c2, c1, c0)) +#define POLY13(x, x2, x4, x8, cc, cb, ca, c9, c8, c7, c6, c5, c4, c3, c2, c1, c0)\ + MLA(x8, POLY5(x, x2, x4, cc, cb, ca, c9, c8), POLY8(x, x2, x4, c7, c6, c5, c4, c3, c2, c1, c0)) +#define POLY14(x, x2, x4, x8, cd, cc, cb, ca, c9, c8, c7, c6, c5, c4, c3, c2, c1, c0)\ + MLA(x8, POLY6(x, x2, x4, cd, cc, cb, ca, c9, c8), POLY8(x, x2, x4, c7, c6, c5, c4, c3, c2, c1, c0)) +#define POLY15(x, x2, x4, x8, ce, cd, cc, cb, ca, c9, c8, c7, c6, c5, c4, c3, c2, c1, c0)\ + MLA(x8, POLY7(x, x2, x4, ce, cd, cc, cb, ca, c9, c8), POLY8(x, x2, x4, c7, c6, c5, c4, c3, c2, c1, c0)) +#define POLY16(x, x2, x4, x8, cf, ce, cd, cc, cb, ca, c9, c8, c7, c6, c5, c4, c3, c2, c1, c0)\ + MLA(x8, POLY8(x, x2, x4, cf, ce, cd, cc, cb, ca, c9, c8), POLY8(x, x2, x4, c7, c6, c5, c4, c3, c2, c1, c0)) +#define POLY17(x, x2, x4, x8, x16, d0, cf, ce, cd, cc, cb, ca, c9, c8, c7, c6, c5, c4, c3, c2, c1, c0)\ + MLA(x16, C2V(d0), POLY16(x, x2, x4, x8, cf, ce, cd, cc, cb, ca, c9, c8, c7, c6, c5, c4, c3, c2, c1, c0)) +#define POLY18(x, x2, x4, x8, x16, d1, d0, cf, ce, cd, cc, cb, ca, c9, c8, c7, c6, c5, c4, c3, c2, c1, c0)\ + MLA(x16, POLY2(x, d1, d0), POLY16(x, x2, x4, x8, cf, ce, cd, cc, cb, ca, c9, c8, c7, c6, c5, c4, c3, c2, c1, c0)) +#define POLY19(x, x2, x4, x8, x16, d2, d1, d0, cf, ce, cd, cc, cb, ca, c9, c8, c7, c6, c5, c4, c3, c2, c1, c0)\ + MLA(x16, POLY3(x, x2, d2, d1, d0), POLY16(x, x2, x4, x8, cf, ce, cd, cc, cb, ca, c9, c8, c7, c6, c5, c4, c3, c2, c1, c0)) +#define POLY20(x, x2, x4, x8, x16, d3, d2, d1, d0, cf, ce, cd, cc, cb, ca, c9, c8, c7, c6, c5, c4, c3, c2, c1, c0)\ + MLA(x16, POLY4(x, x2, d3, d2, d1, d0), POLY16(x, x2, x4, x8, cf, ce, cd, cc, cb, ca, c9, c8, c7, c6, c5, c4, c3, c2, c1, c0)) +#define POLY21(x, x2, x4, x8, x16, d4, d3, d2, d1, d0, cf, ce, cd, cc, cb, ca, c9, c8, c7, c6, c5, c4, c3, c2, c1, c0)\ + MLA(x16, POLY5(x, x2, x4, d4, d3, d2, d1, d0), POLY16(x, x2, x4, x8, cf, ce, cd, cc, cb, ca, c9, c8, c7, c6, c5, c4, c3, c2, c1, c0)) diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/common/f128util.h b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/common/f128util.h new file mode 100644 index 00000000000..d9cef1510ee --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/common/f128util.h @@ -0,0 +1,92 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#include + +static __float128 mpfr_get_f128(mpfr_t m, mpfr_rnd_t rnd) { + if (isnan(mpfr_get_d(m, GMP_RNDN))) return __builtin_nan(""); + + mpfr_t frr, frd; + mpfr_inits(frr, frd, NULL); + + mpfr_exp_t e; + mpfr_frexp(&e, frr, m, GMP_RNDN); + + double d0 = mpfr_get_d(frr, GMP_RNDN); + mpfr_set_d(frd, d0, GMP_RNDN); + mpfr_sub(frr, frr, frd, GMP_RNDN); + + double d1 = mpfr_get_d(frr, GMP_RNDN); + mpfr_set_d(frd, d1, GMP_RNDN); + mpfr_sub(frr, frr, frd, GMP_RNDN); + + double d2 = mpfr_get_d(frr, GMP_RNDN); + + mpfr_clears(frr, frd, NULL); + return ldexpq((__float128)d2 + (__float128)d1 + (__float128)d0, e); +} + +static void mpfr_set_f128(mpfr_t frx, __float128 f, mpfr_rnd_t rnd) { + char s[128]; + quadmath_snprintf(s, 120, "%.50Qg", f); + mpfr_set_str(frx, s, 10, rnd); +} + +static void printf128(__float128 f) { + char s[128]; + quadmath_snprintf(s, 120, "%.50Qg", f); + printf("%s", s); +} + +static char frstr[16][1000]; +static int frstrcnt = 0; + +static char *toBC(double d) { + union { + double d; + uint64_t u64; + int64_t i64; + } cnv; + + cnv.d = d; + + int64_t l = cnv.i64; + int e = (int)((l >> 52) & ~(-1L << 11)); + int s = (int)(l >> 63); + l = d == 0 ? 0 : ((l & ~((-1L) << 52)) | (1L << 52)); + + char *ptr = frstr[(frstrcnt++) & 15]; + + sprintf(ptr, "%s%lld*2^%d", s != 0 ? "-" : "", (long long int)l, (e-0x3ff-52)); + return ptr; +} + +static char *toBCq(__float128 d) { + union { + __float128 d; + __uint128_t u128; + } cnv; + + cnv.d = d; + + __uint128_t m = cnv.u128; + int e = (int)((m >> 112) & ~(-1L << 15)); + int s = (int)(m >> 127); + m = d == 0 ? 0 : ((m & ((((__uint128_t)1) << 112)-1)) | ((__uint128_t)1 << 112)); + + uint64_t h = m / UINT64_C(10000000000000000000); + uint64_t l = m % UINT64_C(10000000000000000000); + + char *ptr = frstr[(frstrcnt++) & 15]; + + sprintf(ptr, "%s%" PRIu64 "%019" PRIu64 "*2^%d", s != 0 ? "-" : "", h, l, (e-0x3fff-112)); + + return ptr; +} + +static int xisnanq(Sleef_quad x) { return x != x; } +static int xisinfq(Sleef_quad x) { return x == (Sleef_quad)__builtin_inf() || x == -(Sleef_quad)__builtin_inf(); } +static int xisfiniteq(Sleef_quad x) { return !xisnanq(x) && !isinfq(x); } diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/common/keywords.txt b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/common/keywords.txt new file mode 100644 index 00000000000..659fa5e1034 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/common/keywords.txt @@ -0,0 +1,683 @@ +double2 +double3 +float2 +atan2k +atan2kf +atan2kf_u1 +atan2k_u1 +cospik +cospifk +dd +dd2 +dd2geta_vd2_dd2 +dd2getb_vd2_dd2 +dd2setab_dd2_vd2_vd2 +ddabs_vd2_vd2 +ddadd2_vd2_vd2_vd +ddadd2_vd2_vd2_vd2 +ddadd2_vd2_vd_vd +ddadd2_vd2_vd_vd2 +ddadd_vd2_vd2_vd +ddadd_vd2_vd2_vd2 +ddadd_vd2_vd_vd +ddadd_vd2_vd_vd2 +dddiv_vd2_vd2_vd2 +ddi +ddi_t +ddigetdd_vd2_ddi +ddigeti_vi_ddi +ddisetdd_ddi_ddi_vd2 +ddisetddi_ddi_vd2_vi +ddmla_vd2_vd2_vd2_vd2 +ddmla_vd2_vd_vd2_vd2 +ddmul_vd2_vd2_vd +ddmul_vd2_vd2_vd2 +ddmul_vd2_vd_vd +ddmul_vd_vd2_vd2 +ddneg_vd2_vd2 +ddnormalize_vd2_vd2 +ddrec_vd2_vd +ddrec_vd2_vd2 +ddscale_vd2_vd2_d +ddscale_vd2_vd2_vd +ddsqrt_vd2_vd +ddsqrt_vd2_vd2 +ddsqu_vd2_vd2 +ddsqu_vd_vd2 +ddsub_vd2_vd2_vd +ddsub_vd2_vd2_vd2 +ddsub_vd2_vd_vd +df +df2 +df2geta_vf2_df2 +df2getb_vf2_df2 +df2setab_df2_vf2_vf2 +dfabs_vf2_vf2 +dfadd2_vf2_vf2_vf +dfadd2_vf2_vf2_vf2 +dfadd2_vf2_vf_vf +dfadd2_vf2_vf_vf2 +dfadd_vf2_vf2_vf +dfadd_vf2_vf2_vf2 +dfadd_vf2_vf_vf +dfadd_vf2_vf_vf2 +dfdiv_vf2_vf2_vf2 +dfi +dfi_t +dfigetdf_vf2_dfi +dfigeti_vi2_dfi +dfisetdf_dfi_dfi_vf2 +dfisetdfi_dfi_vf2_vi2 +dfmla_vf2_vf_vf2_vf2 +dfmul_vf2_vf2_vf +dfmul_vf2_vf2_vf2 +dfmul_vf2_vf_vf +dfmul_vf_vf2_vf2 +dfneg_vf2_vf2 +dfnormalize_vf2_vf2 +dfrec_vf2_vf +dfrec_vf2_vf2 +dfscale_vf2_vf2_vf +dfsqrt_vf2_vf +dfsqrt_vf2_vf2 +dfsqu_vf2_vf2 +dfsqu_vf_vf2 +dfsub_vf2_vf2_vf +dfsub_vf2_vf2_vf2 +dfsub_vf2_vf_vf +di_t +digetd_vd_di +digeti_vi_di +disetdi_di_vd_vi +expk +expk2 +expk2f +expk3f +expkf +expm1fk +expm1k +fi_t +figetd_vf_di +figeti_vi2_di +fisetdi_fi_vf_vi2 +gammafk +gammak +imdvq_vq_vm_vm +logk +logk2 +logk2f +logk3f +logkf +poly2dd +poly2dd_b +poly2df +poly2df_b +poly4dd +poly4df +pragma +rempi +rempif +rempisub +rempisubf +sinpifk +sinpik +td +tdi_t +tdigeti_vi_tdi +tdigettd_vd3_tdi +tdigetx_vd_tdi +tdisettdi_tdi_vd3_vi +tdx +tdxgetd3_vd3_tdx +tdxgetd3x_vd_tdx +tdxgetd3y_vd_tdx +tdxgetd3z_vd_tdx +tdxgete_vm_tdx +tdxsetd3_tdx_tdx_vd3 +tdxsete_tdx_tdx_vm +tdxseted3_tdx_vm_vd3 +tdxsetexyz_tdx_vm_vd_vd_vd +tdxsetx_tdx_tdx_vd +tdxsetxyz_tdx_tdx_vd_vd_vd +tdxsety_tdx_tdx_vd +tdxsetz_tdx_tdx_vd +vabs_vd_vd +vabs_vf2_vf2 +vabs_vf_vf +add128_vq_vq_vq +vadd64_vm_vm_vm +vadd_vd_3vd +vadd_vd_4vd +vadd_vd_5vd +vadd_vd_6vd +vadd_vd_7vd +vadd_vd_vd_vd +vadd_vf_3vf +vadd_vf_4vf +vadd_vf_5vf +vadd_vf_6vf +vadd_vf_7vf +vadd_vf_vf_vf +vadd_vi2_vi2_vi2 +vadd_vi_vi_vi +vand_vi2_vi2_vi2 +vand_vi2_vo_vi2 +vand_vi_vi_vi +vand_vi_vo_vi +vand_vm_vm_vm +vand_vm_vo32_vm +vand_vm_vo64_vm +vand_vo_vo_vo +vandnot_vi2_vi2_vi2 +vandnot_vi2_vo_vi2 +vandnot_vi_vi_vi +vandnot_vi_vo_vi +vandnot_vm_vm_vm +vandnot_vm_vo32_vm +vandnot_vm_vo64_vm +vandnot_vo_vo_vo +vargquad +vavailability_i +cast_aq_vq +vcast_d_vd +vcast_f_vf +vcast_vd2_d2 +vcast_vd2_d_d +vcast_vd2_vd_vd +vcast_vd_d +vcast_vd_vi +vcast_vd_vm +vcast_vf2_d +vcast_vf2_f_f +vcast_vf2_vf_vf +vcast_vf_f +vcast_vf_vi2 +vcast_vi2_i +vcast_vi2_i_i +vcast_vi2_vm +vcast_vi_i +vcast_vi_vm +vcast_vm_i64 +vcast_vm_i_i +vcast_vm_u64 +vcast_vm_vi +vcast_vm_vi2 +vcast_vm_vo +vcast_vo_i +vcast_vo32_vo64 +vcast_vo64_vo32 +cast_vq_aq +vclearlsb_vd_vd_i +vcopysign_vd_vd_vd +vcopysign_vf_vf_vf +vd +vd2getx_vd_vd2 +vd2gety_vd_vd2 +vd2setx_vd2_vd2_vd +vd2setxy_vd2_vd_vd +vd2sety_vd2_vd2_vd +vd3getx_vd_vd3 +vd3gety_vd_vd3 +vd3getz_vd_vd3 +vd3setx_vd3_vd3_vd +vd3setxyz_vd3_vd_vd_vd +vd3sety_vd3_vd3_vd +vd3setz_vd3_vd3_vd +vdiv_vd_vd_vd +vdiv_vf_vf_vf +vdouble +vdouble2 +vdouble3 +veq64_vo_vm_vm +veq_vi2_vi2_vi2 +veq_vi_vi_vi +veq_vo_vd_vd +veq_vo_vf_vf +veq_vo_vi2_vi2 +veq_vo_vi_vi +versatileVector +vf2getx_vf_vf2 +vf2gety_vf_vf2 +vf2setx_vf2_vf2_vf +vf2setxy_vf2_vf_vf +vf2sety_vf2_vf2_vf +vfloat +vfloat2 +vfma_vd_vd_vd_vd +vfma_vf_vf_vf_vf +vfmann_vd_vd_vd_vd +vfmann_vf_vf_vf_vf +vfmanp_vd_vd_vd_vd +vfmanp_vf_vf_vf_vf +vfmapn_vd_vd_vd_vd +vfmapn_vf_vf_vf_vf +vfmapp_vd_vd_vd_vd +vfmapp_vf_vf_vf_vf +vgather_vd_p_vi +vgather_vf_p_vi2 +vge_vo_vd_vd +vge_vo_vf_vf +vgetexp_vd_vd +vgetexp_vf_vf +vgetmant_vd_vd +vgetmant_vf_vf +vgt64_vo_vm_vm +vgt_vi2_vi2_vi2 +vgt_vi_vi_vi +vgt_vo_vd_vd +vgt_vo_vf_vf +vgt_vo_vi2_vi2 +vgt_vo_vi_vi +vilogb2k_vi2_vf +vilogb2k_vi_vd +vilogb2k_vm_vd +vilogb3k_vm_vd +vilogbk_vi2_vf +vilogbk_vi_vd +vilogbk_vm_vd +vint +vint2 +vint64 +visinf2_vd_vd_vd +visinf2_vf_vf_vf +visinf_vo_vd +visinf_vo_vf +visint_vo_vd +visint_vo_vf +visminf_vo_vd +visminf_vo_vf +visnan_vo_vd +visnan_vo_vf +visnegzero_vo_vd +visnegzero_vo_vf +visnonfinite_vo_vd +visnumber_vo_vd +visnumber_vo_vf +visodd_vo_vd +vispinf_vo_vd +vispinf_vo_vf +vldexp1_vd_vd_vm +vldexp2_vd_vd_vi +vldexp2_vd_vd_vm +vldexp2_vf_vf_vi2 +vldexp3_vd_vd_vi +vldexp3_vd_vd_vm +vldexp3_vf_vf_vi2 +vldexp_vd_vd_vi +vldexp_vf_vf_vi2 +vle_vo_vd_vd +vle_vo_vf_vf +vload_vd_p +vload_vf_p +vloadu_vd_p +vloadu_vf_p +vloadu_vi2_p +vloadu_vi_p +loadu_vq_p +vlt64_vo_vm_vm +vlt_vo_vd_vd +vlt_vo_vf_vf +vmask +vmax_vd_vd_vd +vmax_vf_vf_vf +vmin_vd_vd_vd +vmin_vf_vf_vf +vmla_vd_vd_vd_vd +vmla_vf_vf_vf_vf +vmlanp_vd_vd_vd_vd +vmlanp_vf_vf_vf_vf +vmlapn_vd_vd_vd_vd +vmlapn_vf_vf_vf_vf +vmlsubadd_vd_vd_vd_vd +vmlsubadd_vf_vf_vf_vf +vmul_vd_vd_vd +vmul_vf_vf_vf +vmulsign_vd_vd_vd +vmulsign_vf_vf_vf +vneg64_vm_vm +vneg_vd_vd +vneg_vf_vf +vneg_vi2_vi2 +vneg_vi_vi +vnegpos_vd_vd +vnegpos_vf_vf +vneq_vo_vd_vd +vneq_vo_vf_vf +vnot_vo32_vo32 +vnot_vo64_vo64 +vopmask +vor_vi2_vi2_vi2 +vor_vi_vi_vi +vor_vm_vm_vm +vor_vm_vo32_vm +vor_vm_vo64_vm +vor_vo_vo_vo +vorsign_vd_vd_vd +vorsign_vf_vf_vf +vposneg_vd_vd +vposneg_vf_vf +vpow2i_vd_vi +vpow2i_vd_vm +vpow2i_vf_vi2 +vprefetch_v_p +vptrunc_vd_vd +vptrunc_vf_vf +vqgetx_vm_vq +vqgety_vm_vq +vqsetx_vq_vq_vm +vqsetxy_vq_vm_vm +vqsety_vq_vq_vm +vquad +vrec_vd_vd +vrec_vf_vf +vreinterpret_vd_vf +vreinterpret_vd_vm +vreinterpret_vf_vd +vreinterpret_vf_vi2 +vreinterpret_vf_vm +vreinterpret_vi2_vf +vreinterpret_vi64_vm +vreinterpret_vm_vd +vreinterpret_vm_vf +vreinterpret_vm_vi64 +vreinterpret_vm_vu64 +vreinterpret_vu64_vm +vrev21_vd_vd +vrev21_vf_vf +vreva2_vd_vd +vreva2_vf_vf +vrint_vd_vd +vrint2_vd_vd +vrint_vf_vf +vrint_vi2_vf +vrint_vi_vd +vrintfk2_vf_vf +vrintk2_vd_vd +vscatter2_v_p_i_i_vd +vscatter2_v_p_i_i_vf +vsel_vd2_vo_d_d_d_d +vsel_vd2_vo_vd2_vd2 +vsel_vd_vo_d_d +vsel_vd_vo_vd_vd +vsel_vd_vo_vo_d_d_d +vsel_vd_vo_vo_vo_d_d_d_d +vsel_vf2_vo_f_f_f_f +vsel_vf2_vo_vf2_vf2 +vsel_vf2_vo_vo_d_d_d +vsel_vf2_vo_vo_vo_d_d_d_d +vsel_vf_vo_f_f +vsel_vf_vo_vf_vf +vsel_vf_vo_vo_f_f_f +vsel_vf_vo_vo_vo_f_f_f_f +vsel_vi2_vf_vf_vi2_vi2 +vsel_vi2_vf_vi2 +vsel_vi2_vo_vi2_vi2 +vsel_vi_vd_vd_vi_vi +vsel_vi_vd_vi +vsel_vi_vo_vi_vi +vsel_vm_vo64_vm_vm +sel_vq_vo_vq_vq +vsign_vd_vd +vsign_vf_vf +vsignbit_vm_vd +vsignbit_vm_vf +vsignbit_vo_vd +vsignbit_vo_vf +vsll_vi2_vi2_i +vsll_vi_vi_i +vsqrt_vd_vd +vsqrt_vf_vf +vsra_vi2_vi2_i +vsra_vi_vi_i +vsrl_vi2_vi2_i +vsrl_vi_vi_i +vsscatter2_v_p_i_i_vd +vsscatter2_v_p_i_i_vf +vstore_v_p_vd +vstore_v_p_vf +vstoreu_v_p_vd +vstoreu_v_p_vf +vstoreu_v_p_vi +vstoreu_v_p_vi2 +storeu_v_p_vq +vstream_v_p_vd +vstream_v_p_vf +vsub64_vm_vm_vm +vsub_vd_3vd +vsub_vd_4vd +vsub_vd_5vd +vsub_vd_6vd +vsub_vd_vd_vd +vsub_vf_3vf +vsub_vf_4vf +vsub_vf_5vf +vsub_vf_vf_vf +vsub_vi2_vi2_vi2 +vsub_vi_vi_vi +vsubadd_vd_vd_vd +vsubadd_vf_vf_vf +vtestallones_i_vo32 +vtestallones_i_vo64 +vtestallzeros_i_vo64 +vtoward0_vd_vd +vtoward0_vf_vf +vtruncate_vd_vd +vtruncate2_vd_vd +vtruncate_vf_vf +vtruncate_vi2_vf +vtruncate_vi_vd +vtruncate_vm_vd +vugt64_vo_vm_vm +vuint64 +vupper_vd_vd +vupper_vf_vf +vxor_vi2_vi2_vi2 +vxor_vi_vi_vi +vxor_vm_vm_vm +vxor_vm_vo32_vm +vxor_vm_vo64_vm +vxor_vo_vo_vo +# +abs_tdx_tdx +abs_vd3_vd3 +acos_tdx_tdx +acosh_tdx_tdx +add2_vd3_vd2_vd3 +add2_vd3_vd3_vd3 +add2_vd3_vd_vd3 +add_tdx_tdx_tdx +add_vd3_vd2_vd3 +add_vd3_vd_vd3 +asin_tdx_tdx +asinh_tdx_tdx +atan2_tdx_tdx_tdx +atan_tdx_tdx +atanh_tdx_tdx +cast_tdx_d +cast_tdx_d_d_d +cast_tdx_vd +cast_tdx_vd3 +cast_tdx_vq +cast_vd3_d3 +cast_vd3_d_d_d +cast_vd3_tdx +cast_vd3_vd_vd_vd +cast_vd_tdx +cast_vq_tdx +cmp_vm_tdx_tdx +cmpcnv_vq_vq +cos_tdx_tdx +cosh_tdx_tdx +div2_vd3_vd3_vd3 +div_tdx_tdx_tdx +div_vd3_vd3_vd3 +eq_vo_tdx_tdx +exp10_tdx_tdx +exp10i +exp10tab +exp2_tdx_tdx +exp_tdx_tdx +expm1_tdx_tdx +fastcast_tdx_vd3 +fastcast_tdx_vq +fastcast_vq_tdx +ge_vo_tdx_tdx +gt_vo_tdx_tdx +ilogb_vm_tdx +isinf_vo_vq +isint_vo_tdx +isminf_vo_vq +isnan_vo_tdx +isnan_vo_vq +isnonfinite_vo_vq +isnonfinite_vo_vq_vq +isnonfinite_vo_vq_vq_vq +isodd_vo_tdx +ispinf_vo_vq +iszero_vo_tdx +iszero_vo_vq +le_vo_tdx_tdx +log10_tdx_tdx +log1p_tdx_tdx +log2_tdx_tdx +log_tdx_tdx +logk_tdx_tdx +lt_vo_tdx_tdx +mla_vd3_vd3_vd3_vd3 +modf_tdx_tdx_ptdx +mul2_vd3_vd3_vd3 +mul_tdx_tdx_tdx +mul_vd3_vd2_vd2 +mul_vd3_vd2_vd3 +mul_vd3_vd3_vd +mul_vd3_vd3_vd2 +mul_vd3_vd3_vd3 +mulsign_tdx_tdx_vd +mulsign_vd3_vd3_vd +mulsign_vq_vq_vq +neg_tdx_tdx +neg_vd3_vd3 +neq_vo_tdx_tdx +normalize_vd3_vd3 +poly10dd +poly10dd_b +poly11dd +poly11dd_b +poly12dd +poly12dd_b +poly13dd +poly13dd_b +poly14dd +poly14dd_b +poly15dd +poly15dd_b +poly16dd +poly16dd_b +poly17dd +poly17dd_b +poly18dd +poly18dd_b +poly19dd +poly19dd_b +poly20dd +poly20dd_b +poly21dd +poly21dd_b +poly22dd +poly22dd_b +poly23dd +poly23dd_b +poly24dd +poly24dd_b +poly25dd +poly25dd_b +poly26dd +poly26dd_b +poly27dd +poly27dd_b +poly2d +poly2td +poly2td_b +poly3d +poly3dd +poly3dd_b +poly3td +poly3td_b +poly4d +poly4dd_b +poly4td +poly4td_b +poly5d +poly5dd +poly5dd_b +poly5td +poly5td_b +poly6d +poly6dd +poly6dd_b +poly6td +poly6td_b +poly7d +poly7dd +poly7dd_b +poly7td +poly7td_b +poly8d +poly8dd +poly8dd_b +poly8td +poly8td_b +poly9dd +poly9dd_b +pow_tdx_tdx_tdx +quickrenormalize_vd3_vd3 +quicktwosum_vd2_vd_vd +rec_vd3_vd2 +rec_vd3_vd3 +rempio2q +scale_vd3_vd3_d +scale_vd3_vd3_vd +scaleadd2_vd3_vd3_vd3_vd +scalesub2_vd3_vd3_vd3_vd +sel_tdx_vo_tdx_tdx +sel_vd3_vo_vd3_vd3 +signbit_vo_tdx +sin_tdx_tdx +sinh_tdx_tdx +slowcast_vq_tdx +snprintquad +snprintquadhex +sqrt_tdx_tdx +sqrt_vd3_vd3 +squ_vd3_vd3 +sub2_vd3_vd3_vd3 +sub_tdx_tdx_tdx +tan_tdx_tdx +tanh_tdx_tdx +twoprod_vd2_vd_vd +twosub_vd2_vd_vd +twosubx_vd2_vd_vd_vd +twosum_vd2_vd_vd +twosumx_vd2_vd_vd_vd +vtruncate2_vd_vd +vfloor2_vd_vd +vceil2_vd_vd +vround2_vd_vd +isinf_vo_tdx +trunc_tdx_tdx +rint_tdx_tdx +fmod_tdx_tdx_tdx +remainder_tdx_tdx_tdx +cbrt_tdx_tdx +frexp_tdx_tdx_pvi +fma_tdx_tdx_tdx_tdx +hypot_tdx_tdx_tdx +ilogb_vi_tdx +ldexp_tdx_tdx_vi +Sleef_rempitabsp +Sleef_rempitabdp +Sleef_rempitabqp +vcastu_vm_vi +vcastu_vi_vm +rvv_sp_vopmask +rvv_dp_vopmask diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/common/main_checkfeature.c b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/common/main_checkfeature.c new file mode 100644 index 00000000000..b5d7b9a07f3 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/common/main_checkfeature.c @@ -0,0 +1,50 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include + +#if defined(_MSC_VER) || defined(__MINGW32__) || defined(__MINGW64__) +static jmp_buf sigjmp; +#define SETJMP(x) setjmp(x) +#define LONGJMP longjmp +#else +static sigjmp_buf sigjmp; +#define SETJMP(x) sigsetjmp(x, 1) +#define LONGJMP siglongjmp +#endif + +int main2(int argc, char **argv); +int check_feature(double, float); + +static void sighandler(int signum) { + LONGJMP(sigjmp, 1); +} + +int detectFeature() { + signal(SIGILL, sighandler); + + if (SETJMP(sigjmp) == 0) { + int r = check_feature(1.0, 1.0f); + signal(SIGILL, SIG_DFL); + return r; + } else { + signal(SIGILL, SIG_DFL); + return 0; + } +} + +int main(int argc, char **argv) { + if (!detectFeature()) { + printf("0\n"); + fclose(stdout); + exit(0); + } + + return main2(argc, argv); +} diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/common/misc.h b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/common/misc.h new file mode 100644 index 00000000000..472cae68bd5 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/common/misc.h @@ -0,0 +1,332 @@ +// Copyright Naoki Shibata and contributors 2010 - 2024. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// + +#ifndef __MISC_H__ +#define __MISC_H__ + +#if !defined(SLEEF_GENHEADER) +#include +#include +#endif + +#ifndef M_PI +#define M_PI 3.141592653589793238462643383279502884 +#endif + +#ifndef M_PIl +#define M_PIl 3.141592653589793238462643383279502884L +#endif + +#ifndef M_1_PI +#define M_1_PI 0.318309886183790671537767526745028724 +#endif + +#ifndef M_1_PIl +#define M_1_PIl 0.318309886183790671537767526745028724L +#endif + +#ifndef M_2_PI +#define M_2_PI 0.636619772367581343075535053490057448 +#endif + +#ifndef M_2_PIl +#define M_2_PIl 0.636619772367581343075535053490057448L +#endif + +#if !defined(SLEEF_GENHEADER) + +#ifndef SLEEF_FP_ILOGB0 +#define SLEEF_FP_ILOGB0 ((int)0x80000000) +#endif + +#ifndef SLEEF_FP_ILOGBNAN +#define SLEEF_FP_ILOGBNAN ((int)2147483647) +#endif + +#endif + +#define SLEEF_SNAN (((union { long long int i; double d; }) { .i = INT64_C(0x7ff0000000000001) }).d) +#define SLEEF_SNANf (((union { long int i; float f; }) { .i = 0xff800001 }).f) + +#define SLEEF_FLT_MIN 0x1p-126 +#define SLEEF_DBL_MIN 0x1p-1022 +#define SLEEF_INT_MAX 2147483647 +#define SLEEF_DBL_DENORM_MIN 4.9406564584124654e-324 +#define SLEEF_FLT_DENORM_MIN 1.40129846e-45F + +// + +/* + PI_A to PI_D are constants that satisfy the following two conditions. + + * For PI_A, PI_B and PI_C, the last 28 bits are zero. + * PI_A + PI_B + PI_C + PI_D is close to PI as much as possible. + + The argument of a trig function is multiplied by 1/PI, and the + integral part is divided into two parts, each has at most 28 + bits. So, the maximum argument that could be correctly reduced + should be 2^(28*2-1) PI = 1.1e+17. However, due to internal + double precision calculation, the actual maximum argument that can + be correctly reduced is around 2^47. + */ + +#define PI_A 3.1415926218032836914 +#define PI_B 3.1786509424591713469e-08 +#define PI_C 1.2246467864107188502e-16 +#define PI_D 1.2736634327021899816e-24 +#define TRIGRANGEMAX 1e+14 + +/* + PI_A2 and PI_B2 are constants that satisfy the following two conditions. + + * The last 3 bits of PI_A2 are zero. + * PI_A2 + PI_B2 is close to PI as much as possible. + + The argument of a trig function is multiplied by 1/PI, and the + integral part is multiplied by PI_A2. So, the maximum argument that + could be correctly reduced should be 2^(3-1) PI = 12.6. By testing, + we confirmed that it correctly reduces the argument up to around 15. + */ + +#define PI_A2 3.141592653589793116 +#define PI_B2 1.2246467991473532072e-16 +#define TRIGRANGEMAX2 15 + +#define M_2_PI_H 0.63661977236758138243 +#define M_2_PI_L -3.9357353350364971764e-17 + +#define SQRT_DBL_MAX 1.3407807929942596355e+154 + +#define TRIGRANGEMAX3 1e+9 + +#define M_4_PI 1.273239544735162542821171882678754627704620361328125 + +#define L2U .69314718055966295651160180568695068359375 +#define L2L .28235290563031577122588448175013436025525412068e-12 +#define R_LN2 1.442695040888963407359924681001892137426645954152985934135449406931 + +#define L10U 0.30102999566383914498 // log 2 / log 10 +#define L10L 1.4205023227266099418e-13 +#define LOG10_2 3.3219280948873623478703194294893901758648313930 + +#define L10Uf 0.3010253906f +#define L10Lf 4.605038981e-06f + +// + +#define PI_Af 3.140625f +#define PI_Bf 0.0009670257568359375f +#define PI_Cf 6.2771141529083251953e-07f +#define PI_Df 1.2154201256553420762e-10f +#define TRIGRANGEMAXf 39000 + +#define PI_A2f 3.1414794921875f +#define PI_B2f 0.00011315941810607910156f +#define PI_C2f 1.9841872589410058936e-09f +#define TRIGRANGEMAX2f 125.0f + +#define TRIGRANGEMAX4f 8e+6f + +#define SQRT_FLT_MAX 18446743523953729536.0 + +#define L2Uf 0.693145751953125f +#define L2Lf 1.428606765330187045e-06f + +#define R_LN2f 1.442695040888963407359924681001892137426645954152985934135449406931f +#ifndef M_PIf +# define M_PIf ((float)M_PI) +#endif + +// + +#ifndef MIN +#define MIN(x, y) ((x) < (y) ? (x) : (y)) +#endif + +#ifndef MAX +#define MAX(x, y) ((x) > (y) ? (x) : (y)) +#endif + +#ifndef ABS +#define ABS(x) ((x) < 0 ? -(x) : (x)) +#endif + +#define stringify(s) stringify_(s) +#define stringify_(s) #s + +#if !defined(SLEEF_GENHEADER) +typedef long double longdouble; +#endif + +#if !defined(Sleef_double2_DEFINED) && !defined(SLEEF_GENHEADER) +#define Sleef_double2_DEFINED +typedef struct { + double x, y; +} Sleef_double2; +#endif + +#if !defined(Sleef_float2_DEFINED) && !defined(SLEEF_GENHEADER) +#define Sleef_float2_DEFINED +typedef struct { + float x, y; +} Sleef_float2; +#endif + +#if !defined(Sleef_longdouble2_DEFINED) && !defined(SLEEF_GENHEADER) +#define Sleef_longdouble2_DEFINED +typedef struct { + long double x, y; +} Sleef_longdouble2; +#endif + +#if (defined (__GNUC__) || defined (__clang__) || defined(__INTEL_COMPILER)) && !defined(_MSC_VER) + +#define LIKELY(condition) __builtin_expect(!!(condition), 1) +#define UNLIKELY(condition) __builtin_expect(!!(condition), 0) +#define RESTRICT __restrict__ + +#ifndef __arm__ +#define ALIGNED(x) __attribute__((aligned(x))) +#else +#define ALIGNED(x) +#endif + +#if defined(SLEEF_GENHEADER) + +#define INLINE SLEEF_ALWAYS_INLINE +#define EXPORT SLEEF_INLINE +#define CONST SLEEF_CONST +#define NOEXPORT + +#else // #if defined(SLEEF_GENHEADER) + +#define CONST __attribute__((const)) +#define INLINE __attribute__((always_inline)) + +#if defined(__MINGW32__) || defined(__MINGW64__) || defined(__CYGWIN__) +#ifndef SLEEF_STATIC_LIBS +#define EXPORT __stdcall __declspec(dllexport) +#define NOEXPORT +#else // #ifndef SLEEF_STATIC_LIBS +#define EXPORT +#define NOEXPORT +#endif // #ifndef SLEEF_STATIC_LIBS +#else // #if defined(__MINGW32__) || defined(__MINGW64__) || defined(__CYGWIN__) +#define EXPORT __attribute__((visibility("default"))) +#define NOEXPORT __attribute__ ((visibility ("hidden"))) +#endif // #if defined(__MINGW32__) || defined(__MINGW64__) || defined(__CYGWIN__) + +#endif // #if defined(SLEEF_GENHEADER) + +#define SLEEF_NAN __builtin_nan("") +#define SLEEF_NANf __builtin_nanf("") +#define SLEEF_NANl __builtin_nanl("") +#define SLEEF_INFINITY __builtin_inf() +#define SLEEF_INFINITYf __builtin_inff() +#define SLEEF_INFINITYl __builtin_infl() + +#if defined(__INTEL_COMPILER) || defined (__clang__) +#define SLEEF_INFINITYq __builtin_inf() +#define SLEEF_NANq __builtin_nan("") +#else +#define SLEEF_INFINITYq __builtin_infq() +#define SLEEF_NANq (SLEEF_INFINITYq - SLEEF_INFINITYq) +#endif + +#elif defined(_MSC_VER) // #if (defined (__GNUC__) || defined (__clang__) || defined(__INTEL_COMPILER)) && !defined(_MSC_VER) + +#if defined(SLEEF_GENHEADER) + +#define INLINE SLEEF_ALWAYS_INLINE +#define CONST SLEEF_CONST +#define EXPORT SLEEF_INLINE +#define NOEXPORT + +#else // #if defined(SLEEF_GENHEADER) + +#define INLINE __forceinline +#define CONST +#ifndef SLEEF_STATIC_LIBS +#define EXPORT __declspec(dllexport) +#define NOEXPORT +#else +#define EXPORT +#define NOEXPORT +#endif + +#endif // #if defined(SLEEF_GENHEADER) + +#define RESTRICT +#define ALIGNED(x) +#define LIKELY(condition) (condition) +#define UNLIKELY(condition) (condition) + +#if (defined(__GNUC__) || defined(__CLANG__)) && (defined(__i386__) || defined(__x86_64__)) && !defined(SLEEF_GENHEADER) +#include +#endif + +#define SLEEF_INFINITY (1e+300 * 1e+300) +#define SLEEF_NAN (SLEEF_INFINITY - SLEEF_INFINITY) +#define SLEEF_INFINITYf ((float)SLEEF_INFINITY) +#define SLEEF_NANf ((float)SLEEF_NAN) +#define SLEEF_INFINITYl ((long double)SLEEF_INFINITY) +#define SLEEF_NANl ((long double)SLEEF_NAN) + +#if (defined(_M_AMD64) || defined(_M_X64)) +#ifndef __SSE2__ +#define __SSE2__ +#define __SSE3__ +#define __SSE4_1__ +#endif +#elif _M_IX86_FP == 2 +#ifndef __SSE2__ +#define __SSE2__ +#define __SSE3__ +#define __SSE4_1__ +#endif +#elif _M_IX86_FP == 1 +#ifndef __SSE__ +#define __SSE__ +#endif +#endif + +#endif // #elif defined(_MSC_VER) // #if (defined (__GNUC__) || defined (__clang__) || defined(__INTEL_COMPILER)) && !defined(_MSC_VER) + +#if !defined(__linux__) +#define isinff(x) ((x) == SLEEF_INFINITYf || (x) == -SLEEF_INFINITYf) +#define isinfl(x) ((x) == SLEEF_INFINITYl || (x) == -SLEEF_INFINITYl) +#define isnanf(x) ((x) != (x)) +#define isnanl(x) ((x) != (x)) +#endif + +#endif // #ifndef __MISC_H__ + +#ifdef ENABLE_AAVPCS +#define VECTOR_CC __attribute__((aarch64_vector_pcs)) +#else +#define VECTOR_CC +#endif + +// + +#if defined (__GNUC__) && !defined(__INTEL_COMPILER) +#pragma GCC diagnostic ignored "-Wpragmas" +#pragma GCC diagnostic ignored "-Wunknown-pragmas" +#if !defined (__clang__) +#pragma GCC diagnostic ignored "-Wattribute-alias" +#pragma GCC diagnostic ignored "-Wlto-type-mismatch" +#pragma GCC diagnostic ignored "-Wstringop-overflow" +#endif +#endif + +#if defined(_MSC_VER) +#pragma warning(disable:4101) // warning C4101: 'v': unreferenced local variable +#pragma warning(disable:4116) // warning C4116: unnamed type definition in parentheses +#pragma warning(disable:4244) // warning C4244: 'function': conversion from 'vopmask' to '__mmask8', possible loss of data +#pragma warning(disable:4267) // warning C4267: 'initializing': conversion from 'size_t' to 'const int', possible loss of data +#pragma warning(disable:4305) // warning C4305: 'function': truncation from 'double' to 'float' +#endif diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/common/quaddef.h b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/common/quaddef.h new file mode 100644 index 00000000000..f9762d24f38 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/common/quaddef.h @@ -0,0 +1,99 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#if !defined(SLEEF_GENHEADER) + +#if (defined(__SIZEOF_FLOAT128__) && __SIZEOF_FLOAT128__ == 16) || (defined(__linux__) && defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))) || (defined(__PPC64__) && defined(__GNUC__) && !defined(__clang__) && __GNUC__ >= 8) +#define SLEEF_FLOAT128_IS_IEEEQP +#endif + +#if !defined(SLEEF_FLOAT128_IS_IEEEQP) && defined(__SIZEOF_LONG_DOUBLE__) && __SIZEOF_LONG_DOUBLE__ == 16 && (defined(__aarch64__) || defined(__zarch__)) +#define SLEEF_LONGDOUBLE_IS_IEEEQP +#endif + +#if !defined(Sleef_quad_DEFINED) +#define Sleef_quad_DEFINED +typedef struct { uint64_t x, y; } Sleef_uint64_2t; +#if defined(SLEEF_FLOAT128_IS_IEEEQP) || defined(ENABLEFLOAT128) +typedef __float128 Sleef_quad; +#define SLEEF_QUAD_C(x) (x ## Q) +#elif defined(SLEEF_LONGDOUBLE_IS_IEEEQP) +typedef long double Sleef_quad; +#define SLEEF_QUAD_C(x) (x ## L) +#else +typedef Sleef_uint64_2t Sleef_quad; +#endif +#endif + +#if !defined(Sleef_quad1_DEFINED) +#define Sleef_quad1_DEFINED +typedef union { + struct { + Sleef_quad x; + }; + Sleef_quad s[1]; +} Sleef_quad1; +#endif + +#if !defined(Sleef_quad2_DEFINED) +#define Sleef_quad2_DEFINED +typedef union { + struct { + Sleef_quad x, y; + }; + Sleef_quad s[2]; +} Sleef_quad2; +#endif + +#if !defined(Sleef_quad4_DEFINED) +#define Sleef_quad4_DEFINED +typedef union { + struct { + Sleef_quad x, y, z, w; + }; + Sleef_quad s[4]; +} Sleef_quad4; +#endif + +#if !defined(Sleef_quad8_DEFINED) +#define Sleef_quad8_DEFINED +typedef union { + Sleef_quad s[8]; +} Sleef_quad8; +#endif + +#if defined(__ARM_FEATURE_SVE) && !defined(Sleef_quadx_DEFINED) +#define Sleef_quadx_DEFINED +typedef union { + Sleef_quad s[32]; +} Sleef_quadx; +#endif + + +#else // #if !defined(SLEEF_GENHEADER) + +SLEEFSHARPif !defined(SLEEFXXX__NVCC__) && ((defined(SLEEFXXX__SIZEOF_FLOAT128__) && SLEEFXXX__SIZEOF_FLOAT128__ == 16) || (defined(SLEEFXXX__linux__) && defined(SLEEFXXX__GNUC__) && (defined(SLEEFXXX__i386__) || defined(SLEEFXXX__x86_64__))) || (defined(SLEEFXXX__PPC64__) && defined(SLEEFXXX__GNUC__) && !defined(SLEEFXXX__clang__) && SLEEFXXX__GNUC__ >= 8)) +SLEEFSHARPdefine SLEEFXXXSLEEF_FLOAT128_IS_IEEEQP +SLEEFSHARPendif + +SLEEFSHARPif !defined(SLEEFXXXSLEEF_FLOAT128_IS_IEEEQP) && !defined(SLEEFXXX__NVCC__) && defined(SLEEFXXX__SIZEOF_LONG_DOUBLE__) && SLEEFXXX__SIZEOF_LONG_DOUBLE__ == 16 && (defined(SLEEFXXX__aarch64__) || defined(SLEEFXXX__zarch__)) +SLEEFSHARPdefine SLEEFXXXSLEEF_LONGDOUBLE_IS_IEEEQP +SLEEFSHARPendif + +SLEEFSHARPif !defined(SLEEFXXXSleef_quad_DEFINED) +SLEEFSHARPdefine SLEEFXXXSleef_quad_DEFINED +typedef struct { uint64_t x, y; } Sleef_uint64_2t; +SLEEFSHARPif defined(SLEEFXXXSLEEF_FLOAT128_IS_IEEEQP) +typedef __float128 Sleef_quad; +SLEEFSHARPdefine SLEEFXXXSLEEF_QUAD_C(x) (x ## Q) +SLEEFSHARPelif defined(SLEEFXXXSLEEF_LONGDOUBLE_IS_IEEEQP) +typedef long double Sleef_quad; +SLEEFSHARPdefine SLEEFXXXSLEEF_QUAD_C(x) (x ## L) +SLEEFSHARPelse +typedef Sleef_uint64_2t Sleef_quad; +SLEEFSHARPendif +SLEEFSHARPendif + +#endif // #if !defined(SLEEF_GENHEADER) diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/dft-tester/CMakeLists.txt b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/dft-tester/CMakeLists.txt new file mode 100644 index 00000000000..6cbcdea18cd --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/dft-tester/CMakeLists.txt @@ -0,0 +1,201 @@ +# Compiler properties + +set(CMAKE_C_FLAGS "${ORG_CMAKE_C_FLAGS} ${DFT_C_FLAGS}") + +set(COMMON_TARGET_PROPERTIES + C_STANDARD 99 # -std=gnu99 + ) + +# + +function(add_test_dft TESTNAME) + if (ARMIE_COMMAND) + add_test(NAME ${TESTNAME} COMMAND ${ARMIE_COMMAND} -msve-vector-bits=${SVE_VECTOR_BITS} ${ARGN}) + elseif (NOT EMULATOR AND NOT SDE_COMMAND) + add_test(NAME ${TESTNAME} COMMAND ${ARGN}) + elseif(NOT EMULATOR) + add_test(NAME ${TESTNAME} COMMAND ${SDE_COMMAND} "--" ${ARGN}) + else() + add_test(NAME ${TESTNAME} COMMAND ${EMULATOR} ${ARGN}) + endif() + set_tests_properties(${TESTNAME} PROPERTIES COST 0.1) +endfunction() + +# Include directories + +include_directories(${PROJECT_SOURCE_DIR}/include) # sleefdft.h +include_directories(${sleef_BINARY_DIR}/include) # sleef.h +if (FFTW3_INCLUDE_DIR) + include_directories(${FFTW3_INCLUDE_DIR}) # fftw3.h +endif() + +# Link directories + +link_directories(${sleef_BINARY_DIR}/lib) # libsleef, libsleefdft + +# Link libraries + +set(COMMON_LINK_LIBRARIES ${TARGET_LIBSLEEF} ${TARGET_LIBDFT}) + +if (COMPILER_SUPPORTS_OPENMP) + set(COMMON_LINK_LIBRARIES ${COMMON_LINK_LIBRARIES} ${OpenMP_C_FLAGS}) +endif() + +if((NOT MSVC) AND NOT SLEEF_CLANG_ON_WINDOWS) + # Target executable naivetestdp + set(TARGET_NAIVETESTDP "naivetestdp") + add_executable(${TARGET_NAIVETESTDP} naivetest.c ${PROJECT_SOURCE_DIR}/include/sleefdft.h) + add_dependencies(${TARGET_NAIVETESTDP} ${TARGET_HEADERS} ${TARGET_LIBSLEEF} ${TARGET_LIBDFT}) + target_compile_definitions(${TARGET_NAIVETESTDP} PRIVATE ${COMMON_TARGET_DEFINITIONS} BASETYPEID=1) + target_link_libraries(${TARGET_NAIVETESTDP} ${COMMON_LINK_LIBRARIES}) + set_target_properties(${TARGET_NAIVETESTDP} PROPERTIES ${COMMON_TARGET_PROPERTIES}) + + # Target executable naivetestsp + set(TARGET_NAIVETESTSP "naivetestsp") + add_executable(${TARGET_NAIVETESTSP} naivetest.c ${PROJECT_SOURCE_DIR}/include/sleefdft.h) + add_dependencies(${TARGET_NAIVETESTSP} ${TARGET_HEADERS} ${TARGET_LIBSLEEF} ${TARGET_LIBDFT}) + target_compile_definitions(${TARGET_NAIVETESTSP} PRIVATE ${COMMON_TARGET_DEFINITIONS} BASETYPEID=2) + target_link_libraries(${TARGET_NAIVETESTSP} ${COMMON_LINK_LIBRARIES}) + set_target_properties(${TARGET_NAIVETESTSP} PROPERTIES ${COMMON_TARGET_PROPERTIES}) + + # Test naivetestdp + add_test_dft(${TARGET_NAIVETESTDP}_1 $ 1) + add_test_dft(${TARGET_NAIVETESTDP}_2 $ 2) + add_test_dft(${TARGET_NAIVETESTDP}_3 $ 3) + add_test_dft(${TARGET_NAIVETESTDP}_4 $ 4) + add_test_dft(${TARGET_NAIVETESTDP}_5 $ 5) + add_test_dft(${TARGET_NAIVETESTDP}_10 $ 10) + + # Test naivetestsp + add_test_dft(${TARGET_NAIVETESTSP}_1 $ 1) + add_test_dft(${TARGET_NAIVETESTSP}_2 $ 2) + add_test_dft(${TARGET_NAIVETESTSP}_3 $ 3) + add_test_dft(${TARGET_NAIVETESTSP}_4 $ 4) + add_test_dft(${TARGET_NAIVETESTSP}_5 $ 5) + add_test_dft(${TARGET_NAIVETESTSP}_10 $ 10) +endif() + +# Target executable roundtriptest1ddp +set(TARGET_ROUNDTRIPTEST1DDP "roundtriptest1ddp") +add_executable(${TARGET_ROUNDTRIPTEST1DDP} roundtriptest1d.c ${PROJECT_SOURCE_DIR}/include/sleefdft.h) +add_dependencies(${TARGET_ROUNDTRIPTEST1DDP} ${TARGET_HEADERS} ${TARGET_LIBSLEEF} ${TARGET_LIBDFT}) +target_compile_definitions(${TARGET_ROUNDTRIPTEST1DDP} PRIVATE ${COMMON_TARGET_DEFINITIONS} BASETYPEID=1) +target_link_libraries(${TARGET_ROUNDTRIPTEST1DDP} ${COMMON_LINK_LIBRARIES}) +set_target_properties(${TARGET_ROUNDTRIPTEST1DDP} PROPERTIES ${COMMON_TARGET_PROPERTIES}) + +# Target executable roundtriptest1dsp +set(TARGET_ROUNDTRIPTEST1DSP "roundtriptest1dsp") +add_executable(${TARGET_ROUNDTRIPTEST1DSP} roundtriptest1d.c ${PROJECT_SOURCE_DIR}/include/sleefdft.h) +add_dependencies(${TARGET_ROUNDTRIPTEST1DSP} ${TARGET_HEADERS} ${TARGET_LIBSLEEF} ${TARGET_LIBDFT}) +target_compile_definitions(${TARGET_ROUNDTRIPTEST1DSP} PRIVATE ${COMMON_TARGET_DEFINITIONS} BASETYPEID=2) +target_link_libraries(${TARGET_ROUNDTRIPTEST1DSP} ${COMMON_LINK_LIBRARIES}) +set_target_properties(${TARGET_ROUNDTRIPTEST1DSP} PROPERTIES ${COMMON_TARGET_PROPERTIES}) + +# Target executable roundtriptest2ddp +set(TARGET_ROUNDTRIPTEST2DDP "roundtriptest2ddp") +add_executable(${TARGET_ROUNDTRIPTEST2DDP} roundtriptest2d.c ${PROJECT_SOURCE_DIR}/include/sleefdft.h) +add_dependencies(${TARGET_ROUNDTRIPTEST2DDP} ${TARGET_HEADERS} ${TARGET_LIBSLEEF} ${TARGET_LIBDFT}) +target_compile_definitions(${TARGET_ROUNDTRIPTEST2DDP} PRIVATE ${COMMON_TARGET_DEFINITIONS} BASETYPEID=1) +target_link_libraries(${TARGET_ROUNDTRIPTEST2DDP} ${COMMON_LINK_LIBRARIES}) +set_target_properties(${TARGET_ROUNDTRIPTEST2DDP} PROPERTIES ${COMMON_TARGET_PROPERTIES}) + +# Target executable roundtriptest2dsp +set(TARGET_ROUNDTRIPTEST2DSP "roundtriptest2dsp") +add_executable(${TARGET_ROUNDTRIPTEST2DSP} roundtriptest2d.c ${PROJECT_SOURCE_DIR}/include/sleefdft.h) +add_dependencies(${TARGET_ROUNDTRIPTEST2DSP} ${TARGET_HEADERS} ${TARGET_LIBSLEEF} ${TARGET_LIBDFT}) +target_compile_definitions(${TARGET_ROUNDTRIPTEST2DSP} PRIVATE ${COMMON_TARGET_DEFINITIONS} BASETYPEID=2) +target_link_libraries(${TARGET_ROUNDTRIPTEST2DSP} ${COMMON_LINK_LIBRARIES}) +set_target_properties(${TARGET_ROUNDTRIPTEST2DSP} PROPERTIES ${COMMON_TARGET_PROPERTIES}) + +if (LIBFFTW3 AND NOT SLEEF_DISABLE_FFTW) + # Target executable fftwtest1ddp + set(TARGET_FFTWTEST1DDP "fftwtest1ddp") + add_executable(${TARGET_FFTWTEST1DDP} fftwtest1d.c ${PROJECT_SOURCE_DIR}/include/sleefdft.h) + add_dependencies(${TARGET_FFTWTEST1DDP} ${TARGET_HEADERS} ${TARGET_LIBSLEEF} ${TARGET_LIBDFT}) + target_compile_definitions(${TARGET_FFTWTEST1DDP} PRIVATE ${COMMON_TARGET_DEFINITIONS} BASETYPEID=1) + target_link_libraries(${TARGET_FFTWTEST1DDP} ${COMMON_LINK_LIBRARIES} ${LIBFFTW3}) + set_target_properties(${TARGET_FFTWTEST1DDP} PROPERTIES ${COMMON_TARGET_PROPERTIES}) + + # Target executable fftwtest1dsp + set(TARGET_FFTWTEST1DSP "fftwtest1dsp") + add_executable(${TARGET_FFTWTEST1DSP} fftwtest1d.c ${PROJECT_SOURCE_DIR}/include/sleefdft.h) + add_dependencies(${TARGET_FFTWTEST1DSP} ${TARGET_HEADERS} ${TARGET_LIBSLEEF} ${TARGET_LIBDFT}) + target_compile_definitions(${TARGET_FFTWTEST1DSP} PRIVATE ${COMMON_TARGET_DEFINITIONS} BASETYPEID=2) + target_link_libraries(${TARGET_FFTWTEST1DSP} ${COMMON_LINK_LIBRARIES} ${LIBFFTW3}) + set_target_properties(${TARGET_FFTWTEST1DSP} PROPERTIES ${COMMON_TARGET_PROPERTIES}) + + # Target executable fftwtest2ddp + set(TARGET_FFTWTEST2DDP "fftwtest2ddp") + add_executable(${TARGET_FFTWTEST2DDP} fftwtest2d.c ${PROJECT_SOURCE_DIR}/include/sleefdft.h) + add_dependencies(${TARGET_FFTWTEST2DDP} ${TARGET_HEADERS} ${TARGET_LIBSLEEF} ${TARGET_LIBDFT}) + target_compile_definitions(${TARGET_FFTWTEST2DDP} PRIVATE ${COMMON_TARGET_DEFINITIONS} BASETYPEID=1) + target_link_libraries(${TARGET_FFTWTEST2DDP} ${COMMON_LINK_LIBRARIES} ${LIBFFTW3}) + set_target_properties(${TARGET_FFTWTEST2DDP} PROPERTIES ${COMMON_TARGET_PROPERTIES}) + + # Target executable fftwtest2dsp + set(TARGET_FFTWTEST2DSP "fftwtest2dsp") + add_executable(${TARGET_FFTWTEST2DSP} fftwtest2d.c ${PROJECT_SOURCE_DIR}/include/sleefdft.h) + add_dependencies(${TARGET_FFTWTEST2DSP} ${TARGET_HEADERS} ${TARGET_LIBSLEEF} ${TARGET_LIBDFT}) + target_compile_definitions(${TARGET_FFTWTEST2DSP} PRIVATE ${COMMON_TARGET_DEFINITIONS} BASETYPEID=2) + target_link_libraries(${TARGET_FFTWTEST2DSP} ${COMMON_LINK_LIBRARIES} ${LIBFFTW3}) + set_target_properties(${TARGET_FFTWTEST2DSP} PROPERTIES ${COMMON_TARGET_PROPERTIES}) + + # Test fftwtest1ddp + add_test_dft(${TARGET_FFTWTEST1DDP}_12 $ 12) + add_test_dft(${TARGET_FFTWTEST1DDP}_16 $ 16) + + # Test fftwtest1dsp + add_test_dft(${TARGET_FFTWTEST1DSP}_12 $ 12) + add_test_dft(${TARGET_FFTWTEST1DSP}_16 $ 16) + + # Test fftwtest2ddp + add_test_dft(${TARGET_FFTWTEST2DDP}_2_2 $ 2 2) + add_test_dft(${TARGET_FFTWTEST2DDP}_4_4 $ 4 4) + add_test_dft(${TARGET_FFTWTEST2DDP}_8_8 $ 8 8) + add_test_dft(${TARGET_FFTWTEST2DDP}_10_10 $ 10 10) + add_test_dft(${TARGET_FFTWTEST2DDP}_5_15 $ 5 15) + + # Test fftwtest2dsp + add_test_dft(${TARGET_FFTWTEST2DSP}_2_2 $ 2 2) + add_test_dft(${TARGET_FFTWTEST2DSP}_4_4 $ 4 4) + add_test_dft(${TARGET_FFTWTEST2DSP}_8_8 $ 8 8) + add_test_dft(${TARGET_FFTWTEST2DSP}_10_10 $ 10 10) + add_test_dft(${TARGET_FFTWTEST2DSP}_5_15 $ 5 15) +else(LIBFFTW3 AND NOT SLEEF_DISABLE_FFTW) + if(MSVC OR SLEEF_CLANG_ON_WINDOWS) + # Test roundtriptestdp + add_test_dft(${TARGET_ROUNDTRIPTEST1DDP}_1 $ 1 10) + add_test_dft(${TARGET_ROUNDTRIPTEST1DDP}_2 $ 2 10) + add_test_dft(${TARGET_ROUNDTRIPTEST1DDP}_3 $ 3 10) + add_test_dft(${TARGET_ROUNDTRIPTEST1DDP}_4 $ 4 10) + add_test_dft(${TARGET_ROUNDTRIPTEST1DDP}_5 $ 5 10) + add_test_dft(${TARGET_ROUNDTRIPTEST1DDP}_10 $ 10 10) + + # Test roundtriptestsp + add_test_dft(${TARGET_ROUNDTRIPTEST1DSP}_1 $ 1 10) + add_test_dft(${TARGET_ROUNDTRIPTEST1DSP}_2 $ 2 10) + add_test_dft(${TARGET_ROUNDTRIPTEST1DSP}_3 $ 3 10) + add_test_dft(${TARGET_ROUNDTRIPTEST1DSP}_4 $ 4 10) + add_test_dft(${TARGET_ROUNDTRIPTEST1DSP}_5 $ 5 10) + add_test_dft(${TARGET_ROUNDTRIPTEST1DSP}_10 $ 10 10) + endif() + + add_test_dft(${TARGET_ROUNDTRIPTEST1DDP}_12 $ 12 10) + add_test_dft(${TARGET_ROUNDTRIPTEST1DDP}_16 $ 16 10) + add_test_dft(${TARGET_ROUNDTRIPTEST1DSP}_12 $ 12 10) + add_test_dft(${TARGET_ROUNDTRIPTEST1DSP}_16 $ 16 10) + + # Test roundtriptest2ddp + add_test_dft(${TARGET_ROUNDTRIPTEST2DDP}_2_2 $ 2 2 10) + add_test_dft(${TARGET_ROUNDTRIPTEST2DDP}_4_4 $ 4 4 10) + add_test_dft(${TARGET_ROUNDTRIPTEST2DDP}_8_8 $ 8 8 10) + add_test_dft(${TARGET_ROUNDTRIPTEST2DDP}_10_10 $ 10 10 2) + add_test_dft(${TARGET_ROUNDTRIPTEST2DDP}_5_15 $ 5 15 2) + + # Test roundtriptest2dsp + add_test_dft(${TARGET_ROUNDTRIPTEST2DSP}_2_2 $ 2 2 10) + add_test_dft(${TARGET_ROUNDTRIPTEST2DSP}_4_4 $ 4 4 10) + add_test_dft(${TARGET_ROUNDTRIPTEST2DSP}_8_8 $ 8 8 10) + add_test_dft(${TARGET_ROUNDTRIPTEST2DSP}_10_10 $ 10 10 2) + add_test_dft(${TARGET_ROUNDTRIPTEST2DSP}_5_15 $ 5 15 2) +endif(LIBFFTW3 AND NOT SLEEF_DISABLE_FFTW) diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/dft-tester/bench1d.c b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/dft-tester/bench1d.c new file mode 100644 index 00000000000..a30dbcf296b --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/dft-tester/bench1d.c @@ -0,0 +1,116 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#define _DEFAULT_SOURCE +#define _XOPEN_SOURCE 700 + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef USEFFTW +#include +#include +#else +#include "sleef.h" +#include "sleefdft.h" +#endif + +typedef double real; + +static uint64_t gettime() { + struct timespec tp; + clock_gettime(CLOCK_MONOTONIC, &tp); + return (uint64_t)tp.tv_sec * 1000000000 + ((uint64_t)tp.tv_nsec); +} + +#define REPEAT 8 + +int main(int argc, char **argv) { + if (argc == 1) { + fprintf(stderr, "%s \n", argv[0]); + exit(-1); + } + + int backward = 0; + + int log2n = atoi(argv[1]); + if (log2n < 0) { + backward = 1; + log2n = -log2n; + } + + const int n = 1 << log2n; + const int64_t niter = (int)(100000000000.0 / n / log2n); + + printf("Number of iterations = %lld\n", (long long int)niter); + +#ifdef USEFFTW + fftw_complex *in = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * n); + fftw_complex *out = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * n); + +#if 0 + int fftw_init_threads(void); + fftw_plan_with_nthreads(omp_get_max_threads()); +#endif + + fftw_plan w = fftw_plan_dft_1d(n, in, out, backward ? FFTW_BACKWARD : FFTW_FORWARD, FFTW_MEASURE); + //fftw_plan w = fftw_plan_dft_1d(n, in, out, backward ? FFTW_BACKWARD : FFTW_FORWARD, FFTW_PATIENT); + + for(int i=0;i= 3) mode = SLEEF_MODE_VERBOSE | SLEEF_MODE_ESTIMATE; + + if (backward) mode |= SLEEF_MODE_BACKWARD; + struct SleefDFT *p = SleefDFT_double_init1d(n, in, out, mode); + + if (argc >= 3) SleefDFT_setPath(p, argv[2]); + + for(int i=0;i +#include +#include +#include + +#include +#include + +#include "sleef.h" +#include "sleefdft.h" + +#include + +#ifndef MODE +#define MODE SLEEF_MODE_DEBUG +#endif + +#if BASETYPEID == 1 +#define THRES 1e-30 +#define SleefDFT_init1d SleefDFT_double_init1d +#define SleefDFT_execute SleefDFT_double_execute +typedef double real; +#elif BASETYPEID == 2 +#define THRES 1e-13 +#define SleefDFT_init1d SleefDFT_float_init1d +#define SleefDFT_execute SleefDFT_float_execute +typedef float real; +#else +#error BASETYPEID not set +#endif + +static double squ(double x) { return x * x; } + +// complex forward +double check_cf(int n) { + fftw_complex *in = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * n); + fftw_complex *out = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * n); + fftw_plan w = fftw_plan_dft_1d(n, in, out, FFTW_FORWARD, FFTW_ESTIMATE); + + real *sx = (real *)Sleef_malloc(n*2*sizeof(real)); + real *sy = (real *)Sleef_malloc(n*2*sizeof(real)); + struct SleefDFT *p = SleefDFT_init1d(n, sx, sy, MODE); + + for(int i=0;i\n", argv[0]); + exit(-1); + } + + const int n = 1 << atoi(argv[1]); + + srand((unsigned int)time(NULL)); + + SleefDFT_setPlanFilePath(NULL, NULL, SLEEF_PLAN_RESET | SLEEF_PLAN_READONLY); + + // + + int success = 1; + double e; + + e = check_cf(n); + success = success && e < THRES; + printf("complex forward : %s (%g)\n", e < THRES ? "OK" : "NG", e); + e = check_cb(n); + success = success && e < THRES; + printf("complex backward : %s (%g)\n", e < THRES ? "OK" : "NG", e); + e = check_rf(n); + success = success && e < THRES; + printf("real forward : %s (%g)\n", e < THRES ? "OK" : "NG", e); + e = check_rb(n); + success = success && e < THRES; + printf("real backward : %s (%g)\n", e < THRES ? "OK" : "NG", e); + + exit(success ? 0 : -1); +} diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/dft-tester/fftwtest2d.c b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/dft-tester/fftwtest2d.c new file mode 100644 index 00000000000..6c3872d35ab --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/dft-tester/fftwtest2d.c @@ -0,0 +1,143 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include + +#include +#include + +#include "sleef.h" +#include "sleefdft.h" + +#include + +#ifndef MODE +#define MODE SLEEF_MODE_DEBUG +#endif + +#if BASETYPEID == 1 +#define THRES 1e-30 +#define SleefDFT_init2d SleefDFT_double_init2d +#define SleefDFT_execute SleefDFT_double_execute +typedef double real; +#elif BASETYPEID == 2 +#define THRES 1e-13 +#define SleefDFT_init2d SleefDFT_float_init2d +#define SleefDFT_execute SleefDFT_float_execute +typedef float real; +#else +#error BASETYPEID not set +#endif + +static double squ(double x) { return x * x; } + +// complex forward +double check_cf(int n, int m) { + fftw_complex *in = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * n * m); + fftw_complex *out = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * n * m); + fftw_plan w = fftw_plan_dft_2d(n, m, in, out, FFTW_FORWARD, FFTW_ESTIMATE); + + real *sx = (real *)Sleef_malloc(n*m*2*sizeof(real)); + real *sy = (real *)Sleef_malloc(n*m*2*sizeof(real)); + struct SleefDFT *p = SleefDFT_init2d(n, m, sx, sy, MODE); + + for(int i=0;i \n", argv[0]); + exit(-1); + } + + const int n = 1 << atoi(argv[1]); + const int m = 1 << atoi(argv[2]); + + srand((unsigned int)time(NULL)); + + SleefDFT_setPlanFilePath(NULL, NULL, SLEEF_PLAN_RESET | SLEEF_PLAN_READONLY); + + // + + int success = 1; + double e; + + e = check_cf(n, m); + success = success && e < THRES; + printf("complex forward : %s (%g)\n", e < THRES ? "OK" : "NG", e); + e = check_cb(n, m); + success = success && e < THRES; + printf("complex backward : %s (%g)\n", e < THRES ? "OK" : "NG", e); + + exit(success ? 0 : -1); +} diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/dft-tester/measuredft.c b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/dft-tester/measuredft.c new file mode 100644 index 00000000000..c8ffa6ee8f2 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/dft-tester/measuredft.c @@ -0,0 +1,175 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#define _DEFAULT_SOURCE +#define _XOPEN_SOURCE 700 + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "sleef.h" +#include "sleefdft.h" + +static uint64_t gettime() { + struct timespec tp; + clock_gettime(CLOCK_MONOTONIC, &tp); + return (uint64_t)tp.tv_sec * 1000000000 + ((uint64_t)tp.tv_nsec); +} + +int mode[] = { SLEEF_MODE_MEASURE | SLEEF_MODE_NO_MT, SLEEF_MODE_MEASURE}; + +#define ENABLE_SP +//#define ROUNDTRIP +#define REPEAT 2 +//#define ENABLE_SLEEP +//#define WARMUP + +int main(int argc, char **argv) { + int start = 1, end = 18; + if (argc > 1) start = atoi(argv[1]); + if (argc > 2) end = atoi(argv[2]); + + double *din = (double *)Sleef_malloc((1 << 18)*2 * sizeof(double)); + double *dout = (double *)Sleef_malloc((1 << 18)*2 * sizeof(double)); + float *sin = (float *)Sleef_malloc((1 << 18)*2 * sizeof(float)); + float *sout = (float *)Sleef_malloc((1 << 18)*2 * sizeof(float)); + + SleefDFT_setPlanFilePath(NULL, NULL, SLEEF_PLAN_RESET | SLEEF_PLAN_READONLY); + + for(int log2n=start;log2n<=end;log2n++) { + const int n = 1 << log2n; + int64_t niter = (int64_t)(1000000000.0 / REPEAT / n / log2n); + + printf("%d ", n); + + for(int m=0;m<2;m++) { +#ifdef ENABLE_SLEEP + sleep(1); +#endif + + struct SleefDFT *pf = SleefDFT_double_init1d(n, NULL, NULL, mode[m]); +#ifdef ROUNDTRIP + struct SleefDFT *pb = SleefDFT_double_init1d(n, NULL, NULL, mode[m] | SLEEF_MODE_BACKWARD); +#endif + + for(int i=0;i +#include +#include +#include +#include + +#include +#include + +#include "sleef.h" +#include "sleefdft.h" +#include "misc.h" + +#ifndef MODE +#define MODE SLEEF_MODE_DEBUG +#endif + +#define THRES 1e-4 + +#if BASETYPEID == 1 +#define SleefDFT_init SleefDFT_double_init1d +#define SleefDFT_execute SleefDFT_double_execute +typedef double real; + +typedef double complex cmpl; + +cmpl omega(double n, double kn) { + return cexp((-2 * M_PIl * _Complex_I / n) * kn); +} +#elif BASETYPEID == 2 +#define SleefDFT_init SleefDFT_float_init1d +#define SleefDFT_execute SleefDFT_float_execute +typedef float real; + +typedef double complex cmpl; + +cmpl omega(double n, double kn) { + return cexp((-2 * M_PIl * _Complex_I / n) * kn); +} +#elif BASETYPEID == 3 +#define SleefDFT_init SleefDFT_longdouble_init1d +#define SleefDFT_execute SleefDFT_longdouble_execute +typedef double real; + +typedef double complex cmpl; + +cmpl omega(double n, double kn) { + return cexp((-2 * M_PIl * _Complex_I / n) * kn); +} +#elif BASETYPEID == 4 +#include + +#define SleefDFT_init SleefDFT_quad_init1d +#define SleefDFT_execute SleefDFT_quad_execute +typedef Sleef_quad real; + +typedef double complex cmpl; + +cmpl omega(double n, double kn) { + return cexp((-2 * M_PIl * _Complex_I / n) * kn); +} +#else +#error No BASETYPEID specified +#endif + +void forward(cmpl *ts, cmpl *fs, int len) { + int k, n; + + for(k=0;k THRES) || + (fabs(sy[(i*2+1)] - cimag(fs[i])) > THRES)) { + success = 0; + } + + double t; + t = (sy[(i*2+0)] - creal(fs[i])); + rmsn += t*t; + t = (sy[(i*2+1)] - cimag(fs[i])); + rmsn += t*t; + rmsd += creal(fs[i]) * creal(fs[i]) + cimag(fs[i]) * cimag(fs[i]); + } + + // + + free(fs); + free(ts); + + Sleef_free(sx); + Sleef_free(sy); + SleefDFT_dispose(p); + + // + + return success; +} + +// complex backward +int check_cb(int n) { + int i; + + real *sx = (real *)Sleef_malloc(sizeof(real)*n*2); + real *sy = (real *)Sleef_malloc(sizeof(real)*n*2); + + cmpl *ts = (cmpl *)malloc(sizeof(cmpl)*n); + cmpl *fs = (cmpl *)malloc(sizeof(cmpl)*n); + + // + + for(i=0;i THRES) || + (fabs(sy[(i*2+1)] - cimag(ts[i])) > THRES)) { + success = 0; + } + } + + // + + free(fs); + free(ts); + + Sleef_free(sx); + Sleef_free(sy); + SleefDFT_dispose(p); + + // + + return success; +} + +// real forward +int check_rf(int n) { + int i; + + real *sx = (real *)Sleef_malloc(n * sizeof(real)); + real *sy = (real *)Sleef_malloc((n/2+1)*sizeof(real)*2); + + cmpl *ts = (cmpl *)malloc(sizeof(cmpl)*n); + cmpl *fs = (cmpl *)malloc(sizeof(cmpl)*n); + + // + + for(i=0;i THRES) success = 0; + if (fabs(sy[(2*i+1)] - cimag(fs[i])) > THRES) success = 0; + } + + // + + free(fs); + free(ts); + + Sleef_free(sx); + Sleef_free(sy); + SleefDFT_dispose(p); + + // + + return success; +} + +// real backward +int check_rb(int n) { + int i; + + cmpl *ts = (cmpl *)malloc(sizeof(cmpl)*n); + cmpl *fs = (cmpl *)malloc(sizeof(cmpl)*n); + + // + + for(i=0;i THRES) { + success = 0; + } + + if ((fabs(sy[i] - creal(ts[i])) > THRES)) { + success = 0; + } + } + + // + + free(fs); + free(ts); + + Sleef_free(sx); + Sleef_free(sy); + SleefDFT_dispose(p); + + // + + return success; +} + +int check_arf(int n) { + int i; + + real *sx = (real *)Sleef_malloc(n * sizeof(real)); + real *sy = (real *)Sleef_malloc(n * sizeof(real)); + + cmpl *ts = (cmpl *)malloc(sizeof(cmpl)*n); + cmpl *fs = (cmpl *)malloc(sizeof(cmpl)*n); + + // + + for(i=0;i THRES) success = 0; + if (fabs(sy[(2*0+1)] - creal(fs[n/2])) > THRES) success = 0; + } else { + if (fabs(sy[(2*i+0)] - creal(fs[i])) > THRES) success = 0; + if (fabs(sy[(2*i+1)] - cimag(fs[i])) > THRES) success = 0; + } + } + + // + + Sleef_free(sx); + Sleef_free(sy); + SleefDFT_dispose(p); + + // + + return success; +} + +int check_arb(int n) { + int i; + + real *sx = (real *)Sleef_malloc(n * sizeof(real)); + real *sy = (real *)Sleef_malloc(n * sizeof(real)); + + cmpl *ts = (cmpl *)malloc(sizeof(cmpl)*n); + cmpl *fs = (cmpl *)malloc(sizeof(cmpl)*n); + + // + + for(i=0;i THRES) { + success = 0; + } + + if ((fabs(sy[i]*2 - creal(ts[i])) > THRES)) { + success = 0; + } + } + + // + + free(fs); + free(ts); + + Sleef_free(sx); + Sleef_free(sy); + SleefDFT_dispose(p); + + // + + return success; +} + +int main(int argc, char **argv) { + if (argc != 2) { + fprintf(stderr, "%s \n", argv[0]); + exit(-1); + } + + const int n = 1 << atoi(argv[1]); + + srand((unsigned int)time(NULL)); + + SleefDFT_setPlanFilePath(NULL, NULL, SLEEF_PLAN_RESET | SLEEF_PLAN_READONLY); + + // + + int success = 1; + + printf("complex forward : %s\n", (success &= check_cf(n)) ? "OK" : "NG"); + printf("complex backward : %s\n", (success &= check_cb(n)) ? "OK" : "NG"); + printf("real forward : %s\n", (success &= check_rf(n)) ? "OK" : "NG"); + printf("real backward : %s\n", (success &= check_rb(n)) ? "OK" : "NG"); + printf("real alt forward : %s\n", (success &= check_arf(n)) ? "OK" : "NG"); + printf("real alt backward : %s\n", (success &= check_arb(n)) ? "OK" : "NG"); + + exit(!success); +} diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/dft-tester/roundtriptest1d.c b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/dft-tester/roundtriptest1d.c new file mode 100644 index 00000000000..fd7503109c5 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/dft-tester/roundtriptest1d.c @@ -0,0 +1,174 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include + +#include +#include + +#include "sleef.h" +#include "sleefdft.h" + +#ifndef MODE +#define MODE (SLEEF_MODE_DEBUG | SLEEF_MODE_VERBOSE) +#endif + +#if BASETYPEID == 1 +#define THRES 1e-30 +#define SleefDFT_init SleefDFT_double_init1d +#define SleefDFT_execute SleefDFT_double_execute +typedef double real; +#elif BASETYPEID == 2 +#define THRES 1e-13 +#define SleefDFT_init SleefDFT_float_init1d +#define SleefDFT_execute SleefDFT_float_execute +typedef float real; +#else +#error BASETYPEID not set +#endif + +static double squ(double x) { return x * x; } + +// complex transforms +double check_c(int n) { + struct SleefDFT *p; + + real *sx = (real *)Sleef_malloc(n*2 * sizeof(real)); + real *sy = (real *)Sleef_malloc(n*2 * sizeof(real)); + real *sz = (real *)Sleef_malloc(n*2 * sizeof(real)); + + for(int i=0;i []\n", argv[0]); + exit(-1); + } + + const int n = 1 << atoi(argv[1]); + const int nloop = argc >= 3 ? atoi(argv[2]) : 1; + + srand((unsigned int)time(NULL)); + + SleefDFT_setPlanFilePath(NULL, NULL, SLEEF_PLAN_RESET | SLEEF_PLAN_READONLY); + + // + + int success = 1; + double e; + + for(int i=0;(nloop < 0 || i < nloop) && success;i++) { + e = check_c(n); + success = success && e < THRES; + printf("complex : %s (%g)\n", e < THRES ? "OK" : "NG", e); + e = check_r(n); + success = success && e < THRES; + printf("real : %s (%g)\n", e < THRES ? "OK" : "NG", e); + } + + exit(!success); +} diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/dft-tester/roundtriptest2d.c b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/dft-tester/roundtriptest2d.c new file mode 100644 index 00000000000..c2d287e873f --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/dft-tester/roundtriptest2d.c @@ -0,0 +1,118 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include + +#include +#include + +#include "sleef.h" +#include "sleefdft.h" + +#ifndef MODE +#define MODE (SLEEF_MODE_DEBUG | SLEEF_MODE_VERBOSE) +#endif + +#if BASETYPEID == 1 +#define THRES 1e-30 +#define SleefDFT_init2d SleefDFT_double_init2d +#define SleefDFT_execute SleefDFT_double_execute +typedef double real; +#elif BASETYPEID == 2 +#define THRES 1e-13 +#define SleefDFT_init2d SleefDFT_float_init2d +#define SleefDFT_execute SleefDFT_float_execute +typedef float real; +#else +#error BASETYPEID not set +#endif + +static double squ(double x) { return x * x; } + +// complex transforms +double check_c(int n, int m) { + struct SleefDFT *p; + + real *sx = (real *)Sleef_malloc(n*m*2 * sizeof(real)); + real *sy = (real *)Sleef_malloc(n*m*2 * sizeof(real)); + real *sz = (real *)Sleef_malloc(n*m*2 * sizeof(real)); + + for(int i=0;i []\n", argv[0]); + exit(-1); + } + + const int n = 1 << atoi(argv[1]); + const int m = 1 << atoi(argv[2]); + const int nloop = argc >= 4 ? atoi(argv[3]) : 1; + + srand((unsigned int)time(NULL)); + + SleefDFT_setPlanFilePath(NULL, NULL, SLEEF_PLAN_RESET | SLEEF_PLAN_READONLY); + + // + + int success = 1; + double e; + + for(int i=0;(nloop < 0 || i < nloop) && success;i++) { + e = check_c(n, m); + success = success && e < THRES; + printf("complex : %s (%g)\n", e < THRES ? "OK" : "NG", e); + } + + exit(!success); +} diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/dft-tester/tutorial.c b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/dft-tester/tutorial.c new file mode 100644 index 00000000000..e699e6af236 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/dft-tester/tutorial.c @@ -0,0 +1,80 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// gcc tutorial.c -lsleef -lsleefdft -lm +#include +#include +#include +#include +#include + +#include "sleef.h" +#include "sleefdft.h" + +#define THRES 1e-4 + +typedef double complex cmpl; + +cmpl omega(double n, double kn) { + return cexp((-2 * M_PI * _Complex_I / n) * kn); +} + +void forward(cmpl *ts, cmpl *fs, int len) { + for(int k=0;k THRES) || + (fabs(sy[(i*2+1)] - cimag(fs[i])) > THRES)) { + success = 0; + } + } + + printf("%s\n", success ? "OK" : "NG"); + + free(fs); free(ts); + Sleef_free(sy); Sleef_free(sx); + + SleefDFT_dispose(p); + + exit(success); +} diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/dft/CMakeLists.txt b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/dft/CMakeLists.txt new file mode 100644 index 00000000000..c1a452d7103 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/dft/CMakeLists.txt @@ -0,0 +1,425 @@ + +# Options + +if (COMPILER_SUPPORTS_SVE) + set(SLEEFDFT_MAXBUTWIDTH 6 CACHE STRING "Log_2 (Maximum butterfly length) of butterflies") +else() + set(SLEEFDFT_MAXBUTWIDTH 4 CACHE STRING "Log_2 (Maximum butterfly length) of butterflies") +endif() + +if (SLEEFDFT_MAXBUTWIDTH GREATER 7) + message(FATAL_ERROR "SLEEFDFT_MAXBUTWIDTH has to be smaller than 8." ) +endif() + +option(SLEEFDFT_ENABLE_STREAM "Streaming instructions are utilized in DFT." OFF) + +# Settings + +# Constants definition + +set(LISTSHORTTYPENAME "dp" "sp") +set(LISTLONGTYPENAME "double" "float") +set(LISTTYPEID "1" "2") + +set(MACRODEF_vecextdp BASETYPEID=1 ENABLE_VECEXT CONFIG=1) +set(CFLAGS_vecextdp ${FLAGS_ENABLE_VECEXT}) +set(MACRODEF_vecextsp BASETYPEID=2 ENABLE_VECEXT CONFIG=1) +set(CFLAGS_vecextsp ${FLAGS_ENABLE_VECEXT}) +set(MACRODEF_vecextld BASETYPEID=3 ENABLE_VECEXT CONFIG=1) +set(CFLAGS_vecextld ${FLAGS_ENABLE_VECEXT}) +set(MACRODEF_vecextqp BASETYPEID=4 ENABLE_VECEXT CONFIG=1) +set(CFLAGS_vecextqp ${FLAGS_ENABLE_VECEXT}) +set(MACRODEF_purecdp BASETYPEID=1 ENABLE_PUREC CONFIG=1) +set(CFLAGS_purecdp ${FLAGS_ENABLE_PUREC}) +set(MACRODEF_purecsp BASETYPEID=2 ENABLE_PUREC CONFIG=1) +set(CFLAGS_purecsp ${FLAGS_ENABLE_PUREC}) +set(MACRODEF_purecld BASETYPEID=3 ENABLE_PUREC CONFIG=1) +set(CFLAGS_purecld ${FLAGS_ENABLE_PUREC}) +set(MACRODEF_purecqp BASETYPEID=4 ENABLE_PUREC CONFIG=1) +set(CFLAGS_purecqp ${FLAGS_ENABLE_PUREC}) +set(MACRODEF_sse2dp BASETYPEID=1 ENABLE_SSE2 CONFIG=4) +set(CFLAGS_sse2dp ${FLAGS_ENABLE_SSE4}) +set(MACRODEF_sse2sp BASETYPEID=2 ENABLE_SSE2 CONFIG=4) +set(CFLAGS_sse2sp ${FLAGS_ENABLE_SSE4}) +set(MACRODEF_avxdp BASETYPEID=1 ENABLE_AVX CONFIG=1) +set(CFLAGS_avxdp ${FLAGS_ENABLE_AVX}) +set(MACRODEF_avxsp BASETYPEID=2 ENABLE_AVX CONFIG=1) +set(CFLAGS_avxsp ${FLAGS_ENABLE_AVX}) +set(MACRODEF_avx2dp BASETYPEID=1 ENABLE_AVX2 CONFIG=1) +set(CFLAGS_avx2dp ${FLAGS_ENABLE_AVX2}) +set(MACRODEF_avx2sp BASETYPEID=2 ENABLE_AVX2 CONFIG=1) +set(CFLAGS_avx2sp ${FLAGS_ENABLE_AVX2}) +set(MACRODEF_avx512fdp BASETYPEID=1 ENABLE_AVX512F CONFIG=1) +set(CFLAGS_avx512fdp ${FLAGS_ENABLE_AVX512F}) +set(MACRODEF_avx512fsp BASETYPEID=2 ENABLE_AVX512F CONFIG=1) +set(CFLAGS_avx512fsp ${FLAGS_ENABLE_AVX512F}) +set(MACRODEF_advsimddp BASETYPEID=1 ENABLE_ADVSIMD CONFIG=1) +set(CFLAGS_advsimddp ${FLAGS_ENABLE_ADVSIMD}) +set(MACRODEF_advsimdsp BASETYPEID=2 ENABLE_ADVSIMD CONFIG=1) +set(CFLAGS_advsimdsp ${FLAGS_ENABLE_ADVSIMD}) +set(MACRODEF_neon32sp BASETYPEID=2 ENABLE_NEON32 CONFIG=1) +set(CFLAGS_neon32sp ${FLAGS_ENABLE_NEON32}) +set(MACRODEF_sve256dp BASETYPEID=1 ENABLE_SVE CONFIG=8) +set(CFLAGS_sve256dp ${FLAGS_ENABLE_SVE}) +set(MACRODEF_sve256sp BASETYPEID=2 ENABLE_SVE CONFIG=8) +set(CFLAGS_sve256sp ${FLAGS_ENABLE_SVE}) +set(MACRODEF_sve512dp BASETYPEID=1 ENABLE_SVE CONFIG=9) +set(CFLAGS_sve512dp ${FLAGS_ENABLE_SVE}) +set(MACRODEF_sve512sp BASETYPEID=2 ENABLE_SVE CONFIG=9) +set(CFLAGS_sve512sp ${FLAGS_ENABLE_SVE}) +set(MACRODEF_sve1024dp BASETYPEID=1 ENABLE_SVE CONFIG=10) +set(CFLAGS_sve1024dp ${FLAGS_ENABLE_SVE}) +set(MACRODEF_sve1024sp BASETYPEID=2 ENABLE_SVE CONFIG=10) +set(CFLAGS_sve1024sp ${FLAGS_ENABLE_SVE}) +set(MACRODEF_sve2048dp BASETYPEID=1 ENABLE_SVE CONFIG=11) +set(CFLAGS_sve2048dp ${FLAGS_ENABLE_SVE}) +set(MACRODEF_sve2048sp BASETYPEID=2 ENABLE_SVE CONFIG=11) +set(CFLAGS_sve2048sp ${FLAGS_ENABLE_SVE}) +set(MACRODEF_rvvm1128dp BASETYPEID=1 ENABLE_RVVM1 CONFIG=7) +set(CFLAGS_rvvm1128dp ${FLAGS_ENABLE_RVVM1}) +set(MACRODEF_rvvm1128sp BASETYPEID=2 ENABLE_RVVM1 CONFIG=7) +set(CFLAGS_rvvm1128sp ${FLAGS_ENABLE_RVVM1}) +set(MACRODEF_rvvm1256dp BASETYPEID=1 ENABLE_RVVM1 CONFIG=8) +set(CFLAGS_rvvm1256dp ${FLAGS_ENABLE_RVVM1}) +set(MACRODEF_rvvm1256sp BASETYPEID=2 ENABLE_RVVM1 CONFIG=8) +set(CFLAGS_rvvm1256sp ${FLAGS_ENABLE_RVVM1}) +set(MACRODEF_rvvm1512dp BASETYPEID=1 ENABLE_RVVM1 CONFIG=9) +set(CFLAGS_rvvm1512dp ${FLAGS_ENABLE_RVVM1}) +set(MACRODEF_rvvm1512sp BASETYPEID=2 ENABLE_RVVM1 CONFIG=9) +set(CFLAGS_rvvm1512sp ${FLAGS_ENABLE_RVVM1}) +set(MACRODEF_rvvm11024dp BASETYPEID=1 ENABLE_RVVM1 CONFIG=10) +set(CFLAGS_rvvm11024dp ${FLAGS_ENABLE_RVVM1}) +set(MACRODEF_rvvm11024sp BASETYPEID=2 ENABLE_RVVM1 CONFIG=10) +set(CFLAGS_rvvm11024sp ${FLAGS_ENABLE_RVVM1}) +set(MACRODEF_rvvm12048dp BASETYPEID=1 ENABLE_RVVM1 CONFIG=11) +set(CFLAGS_rvvm12048dp ${FLAGS_ENABLE_RVVM1}) +set(MACRODEF_rvvm12048sp BASETYPEID=2 ENABLE_RVVM1 CONFIG=11) +set(CFLAGS_rvvm12048sp ${FLAGS_ENABLE_RVVM1}) +set(MACRODEF_rvvm2128dp BASETYPEID=1 ENABLE_RVVM2 CONFIG=7) +set(CFLAGS_rvvm2128dp ${FLAGS_ENABLE_RVVM2}) +set(MACRODEF_rvvm2128sp BASETYPEID=2 ENABLE_RVVM2 CONFIG=7) +set(CFLAGS_rvvm2128sp ${FLAGS_ENABLE_RVVM2}) +set(MACRODEF_rvvm2256dp BASETYPEID=1 ENABLE_RVVM2 CONFIG=8) +set(CFLAGS_rvvm2256dp ${FLAGS_ENABLE_RVVM2}) +set(MACRODEF_rvvm2256sp BASETYPEID=2 ENABLE_RVVM2 CONFIG=8) +set(CFLAGS_rvvm2256sp ${FLAGS_ENABLE_RVVM2}) +set(MACRODEF_rvvm2512dp BASETYPEID=1 ENABLE_RVVM2 CONFIG=9) +set(CFLAGS_rvvm2512dp ${FLAGS_ENABLE_RVVM2}) +set(MACRODEF_rvvm2512sp BASETYPEID=2 ENABLE_RVVM2 CONFIG=9) +set(CFLAGS_rvvm2512sp ${FLAGS_ENABLE_RVVM2}) +set(MACRODEF_rvvm21024dp BASETYPEID=1 ENABLE_RVVM2 CONFIG=10) +set(CFLAGS_rvvm21024dp ${FLAGS_ENABLE_RVVM2}) +set(MACRODEF_rvvm21024sp BASETYPEID=2 ENABLE_RVVM2 CONFIG=10) +set(CFLAGS_rvvm21024sp ${FLAGS_ENABLE_RVVM2}) +set(MACRODEF_rvvm22048dp BASETYPEID=1 ENABLE_RVVM2 CONFIG=11) +set(CFLAGS_rvvm22048dp ${FLAGS_ENABLE_RVVM2}) +set(MACRODEF_rvvm22048sp BASETYPEID=2 ENABLE_RVVM2 CONFIG=11) +set(CFLAGS_rvvm22048sp ${FLAGS_ENABLE_RVVM2}) +set(MACRODEF_vsxdp BASETYPEID=1 ENABLE_VSX CONFIG=1) +set(CFLAGS_vsxdp ${FLAGS_ENABLE_VSX}) +set(MACRODEF_vsxsp BASETYPEID=2 ENABLE_VSX CONFIG=1) +set(CFLAGS_vsxsp ${FLAGS_ENABLE_VSX}) +set(MACRODEF_vsx3dp BASETYPEID=1 ENABLE_VSX3 CONFIG=1) +set(CFLAGS_vsx3dp ${FLAGS_ENABLE_VSX3}) +set(MACRODEF_vsx3sp BASETYPEID=2 ENABLE_VSX3 CONFIG=1) +set(CFLAGS_vsx3sp ${FLAGS_ENABLE_VSX3}) +set(MACRODEF_vxedp BASETYPEID=1 ENABLE_VXE CONFIG=140) +set(CFLAGS_vxedp ${FLAGS_ENABLE_VXE}) +set(MACRODEF_vxesp BASETYPEID=2 ENABLE_VXE CONFIG=140) +set(CFLAGS_vxesp ${FLAGS_ENABLE_VXE}) +set(MACRODEF_vxe2dp BASETYPEID=1 ENABLE_VXE2 CONFIG=150) +set(CFLAGS_vxe2dp ${FLAGS_ENABLE_VXE2}) +set(MACRODEF_vxe2sp BASETYPEID=2 ENABLE_VXE2 CONFIG=150) +set(CFLAGS_vxe2sp ${FLAGS_ENABLE_VXE2}) + +# List all available scalar data types + +set(ISALIST_SP purecsp) +set(ISALIST_DP purecdp) + +set(LIST_SUPPORTED_FPTYPE 0 1) +if(CMAKE_C_COMPILER_ID MATCHES "(GNU|Clang)") + set(ISALIST_SP vecextsp) + set(ISALIST_DP vecextdp) +endif(CMAKE_C_COMPILER_ID MATCHES "(GNU|Clang)") + +# List all available vector data types + +if (COMPILER_SUPPORTS_SSE4) + set(ISALIST_SP ${ISALIST_SP} sse2sp) + set(ISALIST_DP ${ISALIST_DP} sse2dp) +endif(COMPILER_SUPPORTS_SSE4) + +if (COMPILER_SUPPORTS_AVX) + set(ISALIST_SP ${ISALIST_SP} avxsp) + set(ISALIST_DP ${ISALIST_DP} avxdp) +endif(COMPILER_SUPPORTS_AVX) + +if (COMPILER_SUPPORTS_AVX2) + set(ISALIST_SP ${ISALIST_SP} avx2sp) + set(ISALIST_DP ${ISALIST_DP} avx2dp) +endif(COMPILER_SUPPORTS_AVX2) + +if (COMPILER_SUPPORTS_AVX512F) + set(ISALIST_SP ${ISALIST_SP} avx512fsp) + set(ISALIST_DP ${ISALIST_DP} avx512fdp) +endif(COMPILER_SUPPORTS_AVX512F) + +if (COMPILER_SUPPORTS_ADVSIMD) + set(ISALIST_SP ${ISALIST_SP} advsimdsp) + set(ISALIST_DP ${ISALIST_DP} advsimddp) +endif(COMPILER_SUPPORTS_ADVSIMD) + +if (COMPILER_SUPPORTS_SVE) + set(ISALIST_SP ${ISALIST_SP} sve256sp sve512sp sve1024sp sve2048sp) + set(ISALIST_DP ${ISALIST_DP} sve256dp sve512dp sve1024dp sve2048dp) +endif(COMPILER_SUPPORTS_SVE) + +if (COMPILER_SUPPORTS_NEON32) + set(ISALIST_SP ${ISALIST_SP} neon32sp) +endif(COMPILER_SUPPORTS_NEON32) + +if (COMPILER_SUPPORTS_RVVM1) + set(ISALIST_SP ${ISALIST_SP} rvvm1128sp rvvm1256sp rvvm1512sp rvvm11024sp rvvm12048sp) + set(ISALIST_DP ${ISALIST_DP} rvvm1128dp rvvm1256dp rvvm1512dp rvvm11024dp rvvm12048dp) +endif(COMPILER_SUPPORTS_RVVM1) + +if (COMPILER_SUPPORTS_RVVM2) + set(ISALIST_SP ${ISALIST_SP} rvvm2128sp rvvm2256sp rvvm2512sp rvvm21024sp rvvm22048sp) + set(ISALIST_DP ${ISALIST_DP} rvvm2128dp rvvm2256dp rvvm2512dp rvvm21024dp rvvm22048dp) +endif(COMPILER_SUPPORTS_RVVM2) + +if (COMPILER_SUPPORTS_VSX) + set(ISALIST_SP ${ISALIST_SP} vsxsp) + set(ISALIST_DP ${ISALIST_DP} vsxdp) +endif(COMPILER_SUPPORTS_VSX) + +if (COMPILER_SUPPORTS_VSX3) + set(ISALIST_SP ${ISALIST_SP} vsx3sp) + set(ISALIST_DP ${ISALIST_DP} vsx3dp) +endif(COMPILER_SUPPORTS_VSX3) + +if (COMPILER_SUPPORTS_VXE) + set(ISALIST_SP ${ISALIST_SP} vxesp) + set(ISALIST_DP ${ISALIST_DP} vxedp) +endif(COMPILER_SUPPORTS_VXE) + +if (COMPILER_SUPPORTS_VXE2) + set(ISALIST_SP ${ISALIST_SP} vxe2sp) + set(ISALIST_DP ${ISALIST_DP} vxe2dp) +endif(COMPILER_SUPPORTS_VXE2) + +if(SLEEFDFT_ENABLE_STREAM) + set(NLIST 0 1 2 3) +else() + set(NLIST 0 2) +endif() + +# + +# Compiler properties + +set(CMAKE_C_FLAGS "${ORG_CMAKE_C_FLAGS} ${DFT_C_FLAGS}") +set(COMMON_TARGET_PROPERTIES + C_STANDARD 99 # -std=gnu99 + ) + +if (BUILD_SHARED_LIBS) + list(APPEND COMMON_TARGET_PROPERTIES POSITION_INDEPENDENT_CODE ON) # -fPIC +endif() + +set(COMMON_TARGET_DEFINITIONS ${COMMON_TARGET_DEFINITIONS} MAXBUTWIDTH=${SLEEFDFT_MAXBUTWIDTH}) + +if (SLEEFDFT_ENABLE_STREAM) + set(COMMON_TARGET_DEFINITIONS ${COMMON_TARGET_DEFINITIONS} ENABLE_STREAM=1) +else() + set(COMMON_TARGET_DEFINITIONS ${COMMON_TARGET_DEFINITIONS} ENABLE_STREAM=0) +endif() + +if(COMPILER_SUPPORTS_OPENMP) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") +endif(COMPILER_SUPPORTS_OPENMP) + + +# Include directories + +include_directories(${PROJECT_SOURCE_DIR}/include) +include_directories(${PROJECT_BINARY_DIR}/include) +include_directories(${CMAKE_CURRENT_BINARY_DIR}) + +# Target mkunroll + +set(TARGET_MKUNROLL "mkunroll") +add_host_executable(${TARGET_MKUNROLL} mkunroll.c) +set_target_properties(${TARGET_MKUNROLL} PROPERTIES ${COMMON_TARGET_PROPERTIES}) +if (NOT CMAKE_CROSSCOMPILING) + target_compile_definitions(${TARGET_MKUNROLL} PRIVATE ${COMMON_TARGET_DEFINITIONS}) +endif() + +# Target mkdispatch + +set(TARGET_MKDISPATCH "mkdispatch") +add_host_executable(${TARGET_MKDISPATCH} mkdispatch.c) +set_target_properties(${TARGET_MKDISPATCH} PROPERTIES ${COMMON_TARGET_PROPERTIES}) +if (NOT CMAKE_CROSSCOMPILING) + target_compile_definitions(${TARGET_MKDISPATCH} PRIVATE ${COMMON_TARGET_DEFINITIONS}) +endif() + +# Target dispatchparam.h + +add_custom_command(OUTPUT dispatchparam.h + COMMENT "Generating dispatchparam.h" + COMMAND $ paramonly ${SLEEFDFT_MAXBUTWIDTH} ${ISALIST_DP} > ${CMAKE_CURRENT_BINARY_DIR}/dispatchparam.h + DEPENDS ${TARGET_MKDISPATCH} + ) +add_custom_target(dispatchparam.h_generated SOURCES ${CMAKE_CURRENT_BINARY_DIR}/dispatchparam.h) + +# Target dispatch*.h + +foreach(T ${LIST_SUPPORTED_FPTYPE}) + list(GET LISTSHORTTYPENAME ${T} ST) # ST is "dp", for example + string(TOUPPER ${ST} CST) # CST is "DP" + list(GET LISTLONGTYPENAME ${T} LT) # LT is "double" + list(GET LISTTYPEID ${T} ID) # ID is 1 + + string(CONCAT S "dispatch" ${ST} ".h") # S is dispatchdp.h + add_custom_command(OUTPUT ${S} + COMMENT "Generating ${S}" + COMMAND $ ${LT} ${SLEEFDFT_MAXBUTWIDTH} ${ISALIST_${CST}} > ${S} + DEPENDS ${TARGET_MKDISPATCH} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + ) + + string(CONCAT G ${S} "_generated") # G is dispatchdp.h_generated + add_custom_target(${G} SOURCES ${S}) +endforeach() + +# Target dftcommon.o + +add_library(dftcommon_obj OBJECT dftcommon.c dftcommon.h ${CMAKE_CURRENT_BINARY_DIR}/dispatchparam.h ${sleef_BINARY_DIR}/include/sleef.h) +add_dependencies(dftcommon_obj ${TARGET_HEADERS} dispatchparam.h_generated) +set_source_files_properties(${sleef_BINARY_DIR}/include/sleef.h PROPERTIES GENERATED TRUE) +set_target_properties(dftcommon_obj PROPERTIES ${COMMON_TARGET_PROPERTIES}) +target_compile_definitions(dftcommon_obj PRIVATE ${COMMON_TARGET_DEFINITIONS}) + +# Target dft*.o + +foreach(T ${LIST_SUPPORTED_FPTYPE}) + list(GET LISTSHORTTYPENAME ${T} ST) # ST is "dp", for example + + string(CONCAT G "dft" ${ST} "_obj") # G is "dftdp_obj" + string(CONCAT S "dispatch" ${ST} ".h") # S is "dispatchdp.h" + add_library(${G} OBJECT dft.c dftcommon.h ${S}) + string(CONCAT SG ${S} "_generated") # SG is "dispatchdp.h_generated" + add_dependencies(${G} ${SG} ${TARGET_HEADERS}) + set_target_properties(${G} PROPERTIES ${COMMON_TARGET_PROPERTIES}) + list(GET LISTTYPEID ${T} ID) # ID is 1 + target_compile_definitions(${G} PRIVATE BASETYPEID=${ID} ${COMMON_TARGET_DEFINITIONS}) +endforeach() + +# Copy unroll0.org to ${CMAKE_CURRENT_BINARY_DIR} + +add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/unroll0.org + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/unroll0.org ${CMAKE_CURRENT_BINARY_DIR} + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/unroll0.org) +add_custom_target(unroll0.org.copied DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/unroll0.org) + +# Target unroll*.c + +foreach(T ${LIST_SUPPORTED_FPTYPE}) + list(GET LISTSHORTTYPENAME ${T} ST) # ST is "dp", for example + string(TOUPPER ${ST} CST) # CST is "DP" + list(GET LISTLONGTYPENAME ${T} LT) # LT is "double" + + foreach(E ${ISALIST_${CST}}) # E is "sse2dp" + foreach(N ${NLIST}) + string(CONCAT UC unroll_ ${N} _ ${E} ".c") # UC is "unroll_0_sse2dp.c" + set(UNROLL_TARGET_${CST} ${UNROLL_TARGET_${CST}} ${UC}) + endforeach() + endforeach() + message(STATUS "Unroll target for ${CST} : ${UNROLL_TARGET_${CST}}") + + if(UNROLL_TARGET_${CST}) + add_custom_command(OUTPUT ${UNROLL_TARGET_${CST}} + COMMENT "Generating ${UNROLL_TARGET_${CST}}" + COMMAND $ ${LT} ${ISALIST_${CST}} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + DEPENDS ${TARGET_MKUNROLL} unroll0.org.copied + ) + add_custom_target(unroll_target_${ST} DEPENDS ${UNROLL_TARGET_${CST}}) + endif() +endforeach() + +# Target unroll*.o + +foreach(T ${LIST_SUPPORTED_FPTYPE}) + list(GET LISTSHORTTYPENAME ${T} ST) # ST is "dp", for example + string(TOUPPER ${ST} CST) # CST is "DP" + list(GET LISTLONGTYPENAME ${T} LT) # LT is "double" + + foreach(E ${ISALIST_${CST}}) # E is "sse2dp" + foreach(N ${NLIST}) + string(CONCAT U unroll_ ${N} _ ${E}) # U is "unroll_0_sse2dp" + string(CONCAT UG ${U} "_obj") # UG is "unroll_0_sse2dp_obj" + string(CONCAT UC ${U} ".c") # UC is "unroll_0_sse2dp.c" + add_library(${UG} OBJECT ${UC}) + set_target_properties(${UG} PROPERTIES ${COMMON_TARGET_PROPERTIES}) + target_include_directories(${UG} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) + target_compile_definitions(${UG} PRIVATE ${COMMON_TARGET_DEFINITIONS} ${MACRODEF_${E}}) + target_compile_options(${UG} PRIVATE ${CFLAGS_${E}}) + add_dependencies(${UG} ${TARGET_HEADERS} unroll_target_${ST}) + endforeach() + endforeach() +endforeach() + +# Target libdft + +add_library(${TARGET_LIBDFT} $ $) +target_link_libraries(${TARGET_LIBDFT} ${TARGET_LIBSLEEF} ${LIBM}) + +foreach(T ${LIST_SUPPORTED_FPTYPE}) + list(GET LISTSHORTTYPENAME ${T} ST) # ST is "dp", for example + + string(CONCAT G "dft" ${ST} "_obj") # G is "dftdp_obj" + target_sources(${TARGET_LIBDFT} PRIVATE $) +endforeach() + +foreach(T ${LIST_SUPPORTED_FPTYPE}) + list(GET LISTSHORTTYPENAME ${T} ST) # ST is "dp", for example + string(TOUPPER ${ST} CST) # CST is "DP" + + foreach(E ${ISALIST_${CST}}) # E is "sse2dp" + foreach(N ${NLIST}) + string(CONCAT UG unroll_ ${N} _ ${E} "_obj") # U is "unroll_0_sse2dp_obj" + target_sources(${TARGET_LIBDFT} PRIVATE $) + endforeach() + endforeach() +endforeach() + +set_target_properties(${TARGET_LIBDFT} PROPERTIES + VERSION ${SLEEF_VERSION} + SOVERSION ${SLEEF_SOVERSION} + PUBLIC_HEADER ${PROJECT_SOURCE_DIR}/include/sleefdft.h + ${COMMON_TARGET_PROPERTIES} + ) + +# Install +install( + TARGETS ${TARGET_LIBDFT} + EXPORT sleefTargets + PUBLIC_HEADER # + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" + COMPONENT sleef_Development + LIBRARY # + DESTINATION "${CMAKE_INSTALL_LIBDIR}" + COMPONENT sleef_Runtime + NAMELINK_COMPONENT sleef_Development + ARCHIVE # + DESTINATION "${CMAKE_INSTALL_LIBDIR}" + COMPONENT sleef_Development + RUNTIME # + DESTINATION "${CMAKE_INSTALL_BINDIR}" + COMPONENT sleef_Runtime + INCLUDES # + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" +) diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/dft/dft.c b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/dft/dft.c new file mode 100644 index 00000000000..bc47589a12c --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/dft/dft.c @@ -0,0 +1,1441 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "sleef.h" + +#include "misc.h" +#include "common.h" +#include "arraymap.h" +#include "dftcommon.h" + +#ifdef _OPENMP +#include +#endif + +#if BASETYPEID == 1 +typedef double real; +typedef Sleef_double2 sc_t; +#define BASETYPESTRING "double" +#define MAGIC 0x27182818 +#define MAGIC2D 0x17320508 +#define INIT SleefDFT_double_init1d +#define EXECUTE SleefDFT_double_execute +#define INIT2D SleefDFT_double_init2d +#define CTBL ctbl_double +#define REALSUB0 realSub0_double +#define REALSUB1 realSub1_double +#define GETINT getInt_double +#define GETPTR getPtr_double +#define DFTF dftf_double +#define DFTB dftb_double +#define TBUTF tbutf_double +#define TBUTB tbutb_double +#define BUTF butf_double +#define BUTB butb_double +#define SINCOSPI Sleef_sincospi_u05 +#include "dispatchdp.h" +#elif BASETYPEID == 2 +typedef float real; +typedef Sleef_float2 sc_t; +#define BASETYPESTRING "float" +#define MAGIC 0x31415926 +#define MAGIC2D 0x22360679 +#define INIT SleefDFT_float_init1d +#define EXECUTE SleefDFT_float_execute +#define INIT2D SleefDFT_float_init2d +#define CTBL ctbl_float +#define REALSUB0 realSub0_float +#define REALSUB1 realSub1_float +#define GETINT getInt_float +#define GETPTR getPtr_float +#define DFTF dftf_float +#define DFTB dftb_float +#define TBUTF tbutf_float +#define TBUTB tbutb_float +#define BUTF butf_float +#define BUTB butb_float +#define SINCOSPI Sleef_sincospif_u05 +#include "dispatchsp.h" +#else +#error No BASETYPEID specified +#endif + +#define IMPORT_IS_EXPORT +#include "sleefdft.h" + +// + +real CTBL[] = { + 0.7071067811865475243818940365159164684883L, -0.7071067811865475243818940365159164684883L, + 0.9238795325112867561014214079495587839119L, -0.382683432365089771723257530688933059082L, + 0.382683432365089771723257530688933059082L, -0.9238795325112867561014214079495587839119L, +#if MAXBUTWIDTH >= 5 + 0.9807852804032304491190993878113602022495L, -0.1950903220161282678433729148581576851029L, + 0.5555702330196022247573058028269343822103L, -0.8314696123025452370808655033762590846891L, + 0.8314696123025452370808655033762590846891L, -0.5555702330196022247573058028269343822103L, + 0.1950903220161282678433729148581576851029L, -0.9807852804032304491190993878113602022495L, +#endif +#if MAXBUTWIDTH >= 6 + 0.9951847266721968862310254699821143731242L, -0.09801714032956060199569840382660679267701L, + 0.6343932841636454982026105398063009488396L, -0.7730104533627369607965383602188325085081L, + 0.881921264348355029715105513066220055407L, -0.4713967368259976485449225247492677226546L, + 0.2902846772544623676448431737195932100803L, -0.9569403357322088649310892760624369657307L, + 0.9569403357322088649310892760624369657307L, -0.2902846772544623676448431737195932100803L, + 0.4713967368259976485449225247492677226546L, -0.881921264348355029715105513066220055407L, + 0.7730104533627369607965383602188325085081L, -0.6343932841636454982026105398063009488396L, + 0.09801714032956060199569840382660679267701L, -0.9951847266721968862310254699821143731242L, +#endif +#if MAXBUTWIDTH >= 7 + 0.9987954562051723927007702841240899260811L, -0.04906767432741801425355085940205324135377L, + 0.6715589548470184006194634573905233310143L, -0.7409511253549590911932944126139233276263L, + 0.9039892931234433315823215138173907234886L, -0.427555093430282094315230886905077056781L, + 0.336889853392220050702686798271834334173L, -0.9415440651830207783906830087961026265475L, + 0.9700312531945439926159106824865574481009L, -0.2429801799032638899447731489766866275204L, + 0.5141027441932217266072797923204262815489L, -0.8577286100002720698929313536407192941624L, + 0.8032075314806449097991200569701675249235L, -0.5956993044924333434615715265891822127742L, + 0.1467304744553617516588479505190711904561L, -0.9891765099647809734561415551112872890371L, + 0.9891765099647809734561415551112872890371L, -0.1467304744553617516588479505190711904561L, + 0.5956993044924333434615715265891822127742L, -0.8032075314806449097991200569701675249235L, + 0.8577286100002720698929313536407192941624L, -0.5141027441932217266072797923204262815489L, + 0.2429801799032638899447731489766866275204L, -0.9700312531945439926159106824865574481009L, + 0.9415440651830207783906830087961026265475L, -0.336889853392220050702686798271834334173L, + 0.427555093430282094315230886905077056781L, -0.9039892931234433315823215138173907234886L, + 0.7409511253549590911932944126139233276263L, -0.6715589548470184006194634573905233310143L, + 0.04906767432741801425355085940205324135377L, -0.9987954562051723927007702841240899260811L, +#endif +}; + +#ifndef ENABLE_STREAM +#error ENABLE_STREAM not defined +#endif + +static const int constK[] = { 0, 2, 6, 14, 38, 94, 230, 542, 1254 }; + +extern const char *configStr[]; + +extern int planFilePathSet; + +// Utility functions + +#if defined(_MSC_VER) || defined(__MINGW32__) || defined(__MINGW64__) +static jmp_buf sigjmp; +#define SETJMP(x) setjmp(x) +#define LONGJMP longjmp +#else +static sigjmp_buf sigjmp; +#define SETJMP(x) sigsetjmp(x, 1) +#define LONGJMP siglongjmp +#endif + +static void sighandler(int signum) { LONGJMP(sigjmp, 1); } + +static int checkISAAvailability(int isa) { + signal(SIGILL, sighandler); + + if (SETJMP(sigjmp) == 0) { + int ret = GETINT[isa] != NULL && (*GETINT[isa])(BASETYPEID); + signal(SIGILL, SIG_DFL); + return ret; + } + + signal(SIGILL, SIG_DFL); + return 0; +} + +#ifdef _OPENMP +static int omp_thread_count() { + int n = 0; +#pragma omp parallel reduction(+:n) + n += 1; + return n; +} +#endif + +static void startAllThreads(const int nth) { +#ifdef _OPENMP + volatile int8_t *state = calloc(nth, 1); + int th=0; +#pragma omp parallel for + for(th=0;thlog2len; + if (level == N) { + if ((p->mode & SLEEF_MODE_BACKWARD) == 0) { + void (*func)(real *, const real *, const int) = DFTF[config][p->isa][N]; + (*func)(d, s, log2len-N); + } else { + void (*func)(real *, const real *, const int) = DFTB[config][p->isa][N]; + (*func)(d, s, log2len-N); + } + } else if (level == log2len) { + assert(p->vecwidth <= (1 << N)); + if ((p->mode & SLEEF_MODE_BACKWARD) == 0) { + void (*func)(real *, uint32_t *, const real *, const int, const real *, const int) = TBUTF[config][p->isa][N]; + (*func)(d, p->perm[level], s, log2len-N, p->tbl[N][level], K); + } else { + void (*func)(real *, uint32_t *, const real *, const int, const real *, const int) = TBUTB[config][p->isa][N]; + (*func)(d, p->perm[level], s, log2len-N, p->tbl[N][level], K); + } + } else { + if ((p->mode & SLEEF_MODE_BACKWARD) == 0) { + void (*func)(real *, uint32_t *, const int, const real *, const int, const real *, const int) = BUTF[config][p->isa][N]; + (*func)(d, p->perm[level], log2len-level, s, log2len-N, p->tbl[N][level], K); + } else { + void (*func)(real *, uint32_t *, const int, const real *, const int, const real *, const int) = BUTB[config][p->isa][N]; + (*func)(d, p->perm[level], log2len-level, s, log2len-N, p->tbl[N][level], K); + } + } +} + +// Transposer + +#if defined(__GNUC__) && __GNUC__ < 5 +// This is another workaround of a bug in gcc-4 +#define LOG2BS 3 +#else +#define LOG2BS 4 +#endif + +#define BS (1 << LOG2BS) +#define TRANSPOSE_BLOCK(y2) do { \ + for(int x2=y2+1;x2= N-1) return cnt; + const int level = levelorg - levelinc; + if (bot - top > 4) { + const int bl = 1 << (N - levelinc); + const int w = bl/4; + for(int j=0;j<(bot-top)/bl;j++) { + for(int i=0;i> 1) | ((k & 0x55555555) << 1)); + r = (((r & 0xcccccccc) >> 2) | ((r & 0x33333333) << 2)); + r = (((r & 0xf0f0f0f0) >> 4) | ((r & 0x0f0f0f0f) << 4)); + r = (((r & 0xff00ff00) >> 8) | ((r & 0x00ff00ff) << 8)); + r = ((r >> 16) | (r << 16)) >> (32-nbits); + + return (((r << s) | (k & ~(-1 << s))) & ~(-1 << d)) | + ((((k >> s) | (r & (-1 << (nbits-s)))) << d) & ~(-1 << nbits)); +} + +static real **makeTable(int sign, int vecwidth, int log2len, const int N, const int K) { + if (log2len < N) return NULL; + + int *p = (int *)malloc(sizeof(int)*((N+1)<bestTime = tm; + for(uint32_t j = 0;j < p->log2len+1;j++) { + p->bestPathConfig[j] = pathConfig[j]; + p->bestPath[j] = path[j]; + } + return nTrial; + } + + if (level < 1) return nTrial-1; + + for(int i=0;i<10;i++) { + int N; + + do { + N = 1 + rand() % MAXBUTWIDTH; + } while(p->tm[0][level*(MAXBUTWIDTH+1)+N] >= 1ULL << 60); + + if (p->vecwidth > (1 << N) || N == p->log2len) continue; + + path[level] = N; + for(;;) { + pathConfig[level] = rand() % CONFIGMAX; +#if ENABLE_STREAM == 0 + pathConfig[level] &= ~1; +#endif + if ((p->mode2 & SLEEF_MODE2_MT1D) == 0 && (pathConfig[level] & CONFIG_MT) != 0) continue; + break; + } + for(int j = level-1;j >= 0;j--) path[j] = 0; + nTrial = searchForRandomPathRecurse(p, level - N, path, pathConfig, 0, nTrial); + if (nTrial <= 0) break; + if (p->bestTime < 1ULL << 60) break; + } + + return nTrial - 1; +} + +// Planner + +#define NSHORTESTPATHS 15 +#define MAXPATHLEN (MAXLOG2LEN+1) +#define POSMAX (CONFIGMAX * MAXLOG2LEN * (MAXBUTWIDTH+1)) + +static int cln2pos(int config, int level, int N) { return (config * MAXLOG2LEN + level) * MAXBUTWIDTH + N; } +static int pos2config(int pos) { return pos == -1 ? -1 : ((pos - 1) / (MAXBUTWIDTH * MAXLOG2LEN)); } +static int pos2level(int pos) { return pos == -1 ? -1 : (((pos - 1) / MAXBUTWIDTH) % MAXLOG2LEN); } +static int pos2N(int pos) { return pos == -1 ? -1 : ((pos - 1) % MAXBUTWIDTH + 1); } + +typedef struct { + SleefDFT *p; + + int countu[POSMAX]; + int path[NSHORTESTPATHS][MAXPATHLEN]; + int pathLen[NSHORTESTPATHS]; + uint64_t cost[NSHORTESTPATHS]; + int nPaths; + + int *heap; + int *heapLen; + uint64_t *heapCost; + int heapSize, nPathsInHeap; +} ks_t; + +static ks_t *ksInit(SleefDFT *p) { + ks_t *q = calloc(1, sizeof(ks_t)); + q->p = p; + q->heapSize = 10; + q->heap = calloc(q->heapSize, sizeof(int)*MAXPATHLEN); + q->heapCost = calloc(q->heapSize, sizeof(uint64_t)); + q->heapLen = calloc(q->heapSize, sizeof(int)); + return q; +} + +static void ksDispose(ks_t *q) { + free(q->heapCost); + free(q->heapLen); + free(q->heap); + free(q); +} + +// returns the number of paths in the heap +static int ksSize(ks_t *q) { return q->nPathsInHeap; } + +// adds a path to the heap +static void ksAddPath(ks_t *q, int *path, int pathLen, uint64_t cost) { + assert(pathLen <= MAXPATHLEN); + + if (q->nPathsInHeap == q->heapSize) { + q->heapSize *= 2; + q->heap = realloc(q->heap, q->heapSize * sizeof(int)*MAXPATHLEN); + q->heapCost = realloc(q->heapCost, q->heapSize * sizeof(uint64_t)); + q->heapLen = realloc(q->heapLen, q->heapSize * sizeof(int)); + } + + for(int i=0;iheap[q->nPathsInHeap * MAXPATHLEN + i] = path[i]; + q->heapLen[q->nPathsInHeap] = pathLen; + q->heapCost[q->nPathsInHeap] = cost; + q->nPathsInHeap++; +} + +// returns the cost of n-th paths in the heap +static uint64_t ksCost(ks_t *q, int n) { + assert(0 <= n && n < q->nPathsInHeap); + return q->heapCost[n]; +} + +// copies the n-th paths in the heap to path, returns its length +static int ksGetPath(ks_t *q, int *path, int n) { + assert(0 <= n && n < q->nPathsInHeap); + int len = q->heapLen[n]; + for(int i=0;iheap[n * MAXPATHLEN + i]; + return len; +} + +// removes the n-th paths in the heap +static void ksRemove(ks_t *q, int n) { + assert(0 <= n && n < q->nPathsInHeap); + + for(int i=n;inPathsInHeap-1;i++) { + int len = q->heapLen[i+1]; + assert(len < MAXPATHLEN); + for(int j=0;jheap[i * MAXPATHLEN + j] = q->heap[(i+1) * MAXPATHLEN + j]; + q->heapLen[i] = q->heapLen[i+1]; + q->heapCost[i] = q->heapCost[i+1]; + } + q->nPathsInHeap--; +} + +// returns the countu value at pos +static int ksCountu(ks_t *q, int pos) { + assert(0 <= pos && pos < POSMAX); + return q->countu[pos]; +} + +// set the countu value at pos to n +static void ksSetCountu(ks_t *q, int pos, int n) { + assert(0 <= pos && pos < POSMAX); + q->countu[pos] = n; +} + +// adds a path as one of the best k paths, returns the number best paths +static int ksAddBestPath(ks_t *q, int *path, int pathLen, uint64_t cost) { + assert(pathLen <= MAXPATHLEN); + assert(q->nPaths < NSHORTESTPATHS); + for(int i=0;ipath[q->nPaths][i] = path[i]; + q->pathLen[q->nPaths] = pathLen; + q->cost[q->nPaths] = cost; + q->nPaths++; + return q->nPaths; +} + +// returns if pos is a destination +static int ksIsDest(ks_t *q, int pos) { return pos2level(pos) == 0; } + +// returns n-th adjacent nodes at pos. +static int ksAdjacent(ks_t *q, int pos, int n) { + if (pos != -1 && pos2level(pos) == 0) return -1; + + int NMAX = MIN(MIN(q->p->log2len, MAXBUTWIDTH+1), q->p->log2len - q->p->log2vecwidth + 1); + + if (pos == -1) { + int N = n / 2 + MAX(q->p->log2vecwidth, 1); + if (N >= NMAX) return -1; + return cln2pos((n & 1) * CONFIG_MT, q->p->log2len, N); + } + + int config = (pos2config(pos) & CONFIG_MT); + int N = n + 1; + int level = pos2level(pos) - pos2N(pos); + + if (level < 0 || N >= NMAX) return -1; + if (level == 0) return n == 0 ? cln2pos(0, 0, 0) : -1; + + return cln2pos(config, level, N); +} + +static uint64_t ksAdjacentCost(ks_t *q, int pos, int n) { + int nxpos = ksAdjacent(q, pos, n); + if (nxpos == -1) return 0; + int config = pos2config(nxpos), level = pos2level(nxpos), N = pos2N(nxpos); + uint64_t ret0 = q->p->tm[config | 0][level*(MAXBUTWIDTH+1) + N]; + uint64_t ret1 = q->p->tm[config | 1][level*(MAXBUTWIDTH+1) + N]; + return MIN(ret0, ret1); +} + +static void searchForBestPath(SleefDFT *p) { + ks_t *q = ksInit(p); + + for(int i=0;;i++) { + int v = ksAdjacent(q, -1, i); + if (v == -1) break; + uint64_t c = ksAdjacentCost(q, -1, i); + int path[1] = { v }; + ksAddPath(q, path, 1, c); + } + + while(ksSize(q) != 0) { + uint64_t bestCost = 1ULL << 60; + int bestPathNum = -1; + + for(int i=0;i= NSHORTESTPATHS) continue; + ksSetCountu(q, lastPos, ksCountu(q, lastPos)+1); + + if (ksIsDest(q, lastPos)) { + if (ksAddBestPath(q, path, pathLen, cost) >= NSHORTESTPATHS) break; + continue; + } + + for(int i=0;;i++) { + int v = ksAdjacent(q, lastPos, i); + if (v == -1) break; + assert(0 <= pos2N(v) && pos2N(v) <= q->p->log2len); + uint64_t c = ksAdjacentCost(q, lastPos, i); + path[pathLen] = v; + ksAddPath(q, path, pathLen+1, cost + c); + } + } + + for(int j = p->log2len;j >= 0;j--) p->bestPath[j] = 0; + + if (((p->mode & SLEEF_MODE_MEASURE) != 0 || (planFilePathSet && (p->mode & SLEEF_MODE_MEASUREBITS) == 0))) { + uint64_t besttm = 1ULL << 62; + int bestPath = -1; + const int niter = 1 + 5000000 / ((1 << p->log2len) + 1); + + real *s2 = NULL, *d2 = NULL; + const real *s = p->in == NULL ? (s2 = (real *)memset(Sleef_malloc((2 << p->log2len) * sizeof(real)), 0, sizeof(real) * (2 << p->log2len))) : p->in; + real *d = p->out == NULL ? (d2 = (real *)memset(Sleef_malloc((2 << p->log2len) * sizeof(real)), 0, sizeof(real) * (2 << p->log2len))) : p->out; + +#ifdef _OPENMP + const int tn = omp_get_thread_num(); +#else + const int tn = 0; +#endif + + real *t[] = { p->x1[tn], p->x0[tn], d }; + + for(int mt=0;mt<2;mt++) { + for(int i=q->nPaths-1;i>=0;i--) { + if (((pos2config(q->path[i][0]) & CONFIG_MT) != 0) != mt) continue; + + if ((p->mode & SLEEF_MODE_VERBOSE) != 0) { + for(int j=0;jpathLen[i];j++) { + int N = pos2N(q->path[i][j]); + int level = pos2level(q->path[i][j]); + int config = pos2config(q->path[i][j]) & ~1; + uint64_t t0 = q->p->tm[config | 0][level*(MAXBUTWIDTH+1) + N]; + uint64_t t1 = q->p->tm[config | 1][level*(MAXBUTWIDTH+1) + N]; + config = t0 < t1 ? config : (config | 1); + + if (N != 0) printf("%d(%s) ", N, configStr[config]); + } + } + + if (mt) startAllThreads(p->nThread); + + uint64_t tm0 = Sleef_currentTimeMicros(); + for(int k=0;kpathLen & 1) == 1) nb = -1; + for(int level = p->log2len, j=0;level >= 1;j++) { + assert(pos2level(q->path[i][j]) == level); + int N = pos2N(q->path[i][j]); + int config = pos2config(q->path[i][j]) & ~1; + uint64_t t0 = q->p->tm[config | 0][level*(MAXBUTWIDTH+1) + N]; + uint64_t t1 = q->p->tm[config | 1][level*(MAXBUTWIDTH+1) + N]; + config = t0 < t1 ? config : (config | 1); + dispatch(p, N, t[nb+1], lb, level, config); + level -= N; + lb = t[nb+1]; + nb = (nb + 1) & 1; + } + } + uint64_t tm1 = Sleef_currentTimeMicros(); + for(int k=0;kpathLen & 1) == 1) nb = -1; + for(int level = p->log2len, j=0;level >= 1;j++) { + assert(pos2level(q->path[i][j]) == level); + int N = pos2N(q->path[i][j]); + int config = pos2config(q->path[i][j]) & ~1; + uint64_t t0 = q->p->tm[config | 0][level*(MAXBUTWIDTH+1) + N]; + uint64_t t1 = q->p->tm[config | 1][level*(MAXBUTWIDTH+1) + N]; + config = t0 < t1 ? config : (config | 1); + dispatch(p, N, t[nb+1], lb, level, config); + level -= N; + lb = t[nb+1]; + nb = (nb + 1) & 1; + } + } + uint64_t tm2 = Sleef_currentTimeMicros(); + + if ((p->mode & SLEEF_MODE_VERBOSE) != 0) printf(" : %lld %lld\n", (long long int)(tm1 - tm0), (long long int)(tm2 - tm1)); + if ((tm1 - tm0) < besttm) { + bestPath = i; + besttm = tm1 - tm0; + } + if ((tm2 - tm1) < besttm) { + bestPath = i; + besttm = tm2 - tm1; + } + } + } + + for(int level = p->log2len, j=0;level >= 1;j++) { + assert(pos2level(q->path[bestPath][j]) == level); + int N = pos2N(q->path[bestPath][j]); + + int config = pos2config(q->path[bestPath][j]) & ~1; + uint64_t t0 = q->p->tm[config | 0][level*(MAXBUTWIDTH+1) + N]; + uint64_t t1 = q->p->tm[config | 1][level*(MAXBUTWIDTH+1) + N]; + config = t0 < t1 ? config : (config | 1); + + p->bestPath[level] = N; + p->bestPathConfig[level] = config; + level -= N; + } + + if (d2 != NULL) Sleef_free(d2); + if (s2 != NULL) Sleef_free(s2); + } else { + for(int level = p->log2len, j=0;level >= 1;j++) { + int bestPath = 0; + assert(pos2level(q->path[bestPath][j]) == level); + int N = pos2N(q->path[bestPath][j]); + int config = pos2config(q->path[bestPath][j]); + p->bestPath[level] = N; + p->bestPathConfig[level] = config; + level -= N; + } + } + + ksDispose(q); +} + +// + +static uint64_t estimate(int log2len, int level, int N, int config) { + uint64_t ret = N * 1000 + ABS(N-3) * 1000; + if (log2len >= 14 && (config & CONFIG_MT) != 0) ret /= 2; + return ret; +} + +static void measureBut(SleefDFT *p) { + if (p->x0 == NULL) return; + + // + +#ifdef _OPENMP + const int tn = omp_get_thread_num(); +#else + const int tn = 0; +#endif + + real *s = (real *)memset(p->x0[tn], 0, sizeof(real) * (2 << p->log2len)); + real *d = (real *)memset(p->x1[tn], 0, sizeof(real) * (2 << p->log2len)); + + const int niter = 1 + 100000 / ((1 << p->log2len) + 1); + +#define MEASURE_REPEAT 4 + + for(int rep=1;rep<=MEASURE_REPEAT;rep++) { + for(int config=0;configmode2 & SLEEF_MODE2_MT1D) == 0 && (config & CONFIG_MT) != 0) continue; + for(uint32_t level = p->log2len;level >= 1;level--) { + for(uint32_t N=1;N<=MAXBUTWIDTH;N++) { + if (level < N || p->log2len <= N) continue; + if (level == N) { + if ((int)p->log2len - (int)level < p->log2vecwidth) continue; + + uint64_t tm = Sleef_currentTimeMicros(); + for(int i=0;itm[config][level*(MAXBUTWIDTH+1)+N] = MIN(p->tm[config][level*(MAXBUTWIDTH+1)+N], tm); + } else if (level == p->log2len) { + if (p->tbl[N] == NULL || p->tbl[N][level] == NULL) continue; + if (p->vecwidth > (1 << N)) continue; + if ((config & CONFIG_MT) != 0) { + int i1=0; +#ifdef _OPENMP +#pragma omp parallel for +#endif + for(i1=0;i1 < (1 << (p->log2len-N-p->log2vecwidth));i1++) { + int i0 = i1 << p->log2vecwidth; + p->perm[level][i1] = 2*perm(p->log2len, i0, p->log2len-level, p->log2len-(level-N)); + } + } else { + for(int i0=0, i1=0;i0 < (1 << (p->log2len-N));i0+=p->vecwidth, i1++) { + p->perm[level][i1] = 2*perm(p->log2len, i0, p->log2len-level, p->log2len-(level-N)); + } + } + + uint64_t tm = Sleef_currentTimeMicros(); + for(int i=0;itm[config][level*(MAXBUTWIDTH+1)+N] = MIN(p->tm[config][level*(MAXBUTWIDTH+1)+N], tm); + } else { + if (p->tbl[N] == NULL || p->tbl[N][level] == NULL) continue; + if (p->vecwidth > 2 && p->log2len <= N+2) continue; + if ((int)p->log2len - (int)level < p->log2vecwidth) continue; + if ((config & CONFIG_MT) != 0) { + int i1=0; +#ifdef _OPENMP +#pragma omp parallel for +#endif + for(i1=0;i1 < (1 << (p->log2len-N-p->log2vecwidth));i1++) { + int i0 = i1 << p->log2vecwidth; + p->perm[level][i1] = 2*perm(p->log2len, i0, p->log2len-level, p->log2len-(level-N)); + } + } else { + for(int i0=0, i1=0;i0 < (1 << (p->log2len-N));i0+=p->vecwidth, i1++) { + p->perm[level][i1] = 2*perm(p->log2len, i0, p->log2len-level, p->log2len-(level-N)); + } + } + + uint64_t tm = Sleef_currentTimeMicros(); + for(int i=0;itm[config][level*(MAXBUTWIDTH+1)+N] = MIN(p->tm[config][level*(MAXBUTWIDTH+1)+N], tm); + } + } + } + } + } + + if ((p->mode & SLEEF_MODE_VERBOSE) != 0) { + for(uint32_t level = p->log2len;level >= 1;level--) { + for(uint32_t N=1;N<=MAXBUTWIDTH;N++) { + if (level < N || p->log2len <= N) continue; + if (level == N) { + if ((int)p->log2len - (int)level < p->log2vecwidth) continue; + printf("bot %d, %d, %d, ", p->log2len, level, N); + for(int config=0;configtm[config][level*(MAXBUTWIDTH+1)+N] == 1ULL << 60) { + printf("N/A, "); + } else { + printf("%lld, ", (long long int)p->tm[config][level*(MAXBUTWIDTH+1)+N]); + } + } + printf("\n"); + } else if (level == p->log2len) { + if (p->tbl[N] == NULL || p->tbl[N][level] == NULL) continue; + if (p->vecwidth > (1 << N)) continue; + printf("top %d, %d, %d, ", p->log2len, level, N); + for(int config=0;configtm[config][level*(MAXBUTWIDTH+1)+N] == 1ULL << 60) { + printf("N/A, "); + } else { + printf("%lld, ", (long long int)p->tm[config][level*(MAXBUTWIDTH+1)+N]); + } + } + printf("\n"); + } else { + if (p->tbl[N] == NULL || p->tbl[N][level] == NULL) continue; + if (p->vecwidth > 2 && p->log2len <= N+2) continue; + if ((int)p->log2len - (int)level < p->log2vecwidth) continue; + printf("mid %d, %d, %d, ", p->log2len, level, N); + for(int config=0;configtm[config][level*(MAXBUTWIDTH+1)+N] == 1ULL << 60) { + printf("N/A, "); + } else { + printf("%lld, ", (long long int)p->tm[config][level*(MAXBUTWIDTH+1)+N]); + } + } + printf("\n"); + } + } + } + } +} + +static void estimateBut(SleefDFT *p) { + for(uint32_t level = p->log2len;level >= 1;level--) { + for(uint32_t N=1;N<=MAXBUTWIDTH;N++) { + if (level < N || p->log2len <= N) continue; + if (level == N) { + if ((int)p->log2len - (int)level < p->log2vecwidth) continue; + for(int config=0;configtm[config][level*(MAXBUTWIDTH+1)+N] = estimate(p->log2len, level, N, config); + } + } else if (level == p->log2len) { + if (p->tbl[N] == NULL || p->tbl[N][level] == NULL) continue; + if (p->vecwidth > (1 << N)) continue; + for(int config=0;configtm[config][level*(MAXBUTWIDTH+1)+N] = estimate(p->log2len, level, N, config); + } + } else { + if (p->tbl[N] == NULL || p->tbl[N][level] == NULL) continue; + if (p->vecwidth > 2 && p->log2len <= N+2) continue; + if ((int)p->log2len - (int)level < p->log2vecwidth) continue; + for(int config=0;configtm[config][level*(MAXBUTWIDTH+1)+N] = estimate(p->log2len, level, N, config); + } + } + } + } +} + +static int measure(SleefDFT *p, int randomize) { + if (p->log2len == 1) { + p->bestTime = 1ULL << 60; + + p->pathLen = 1; + p->bestPath[1] = 1; + + return 1; + } + + if (PlanManager_loadMeasurementResultsP(p, (p->mode & SLEEF_MODE_NO_MT) != 0 ? 1 : 0)) { + if ((p->mode & SLEEF_MODE_VERBOSE) != 0) { + printf("Path(loaded) : "); + for(int j = p->log2len;j >= 0;j--) if (p->bestPath[j] != 0) printf("%d(%s) ", p->bestPath[j], configStr[p->bestPathConfig[j]]); + printf("\n"); + } + + return 1; + } + + int toBeSaved = 0; + + for(uint32_t level = p->log2len;level >= 1;level--) { + for(uint32_t N=1;N<=MAXBUTWIDTH;N++) { + for(int config=0;configtm[config][level*(MAXBUTWIDTH+1)+N] = 1ULL << 60; + } + } + } + + if (((p->mode & SLEEF_MODE_MEASURE) != 0 || (planFilePathSet && (p->mode & SLEEF_MODE_MEASUREBITS) == 0)) && !randomize) { + measureBut(p); + toBeSaved = 1; + } else { + estimateBut(p); + } + + int executable = 0; + for(int i=1;i<=MAXBUTWIDTH && !executable;i++) { + if (p->tm[0][p->log2len*(MAXBUTWIDTH+1)+i] < (1ULL << 60)) executable = 1; + } + + if (!executable) return 0; + + p->bestTime = 1ULL << 60; + + p->bestPath[p->log2len] = 0; + + if (!randomize) { + searchForBestPath(p); + } else { + int path[MAXLOG2LEN+1]; + int pathConfig[MAXLOG2LEN+1]; + for(int j = p->log2len;j >= 0;j--) path[j] = pathConfig[j] = 0; + + int nTrial = 100000; + do { + nTrial = searchForRandomPathRecurse(p, p->log2len, path, pathConfig, 0, nTrial); + } while(p->bestTime == 1ULL << 60 && nTrial >= 0); + } + + if (p->bestPath[p->log2len] == 0) return 0; + + p->pathLen = 0; + for(int j = p->log2len;j >= 0;j--) if (p->bestPath[j] != 0) p->pathLen++; + + if ((p->mode & SLEEF_MODE_VERBOSE) != 0) { + printf("Path"); + if (randomize) printf("(random) :"); + else if (toBeSaved) printf("(measured) :"); + else printf("(estimated) :"); + + for(int j = p->log2len;j >= 0;j--) if (p->bestPath[j] != 0) printf("%d(%s) ", p->bestPath[j], configStr[p->bestPathConfig[j]]); + printf("\n"); + } + + if (toBeSaved) { + PlanManager_saveMeasurementResultsP(p, (p->mode & SLEEF_MODE_NO_MT) != 0 ? 1 : 0); + } + + return 1; +} + +static void measureTranspose(SleefDFT *p) { + if (PlanManager_loadMeasurementResultsT(p)) { + if ((p->mode & SLEEF_MODE_VERBOSE) != 0) printf("transpose NoMT(loaded): %lld\n", (long long int)p->tmNoMT); + if ((p->mode & SLEEF_MODE_VERBOSE) != 0) printf("transpose MT(loaded): %lld\n", (long long int)p->tmMT); + return; + } + + if ((p->mode & SLEEF_MODE_MEASURE) == 0 && (!planFilePathSet || (p->mode & SLEEF_MODE_MEASUREBITS) != 0)) { + if (p->log2hlen + p->log2vlen >= 14) { + p->tmNoMT = 20; + p->tmMT = 10; + if ((p->mode & SLEEF_MODE_VERBOSE) != 0) printf("transpose : selected MT(estimated)\n"); + } else { + p->tmNoMT = 10; + p->tmMT = 20; + if ((p->mode & SLEEF_MODE_VERBOSE) != 0) printf("transpose : selected NoMT(estimated)\n"); + } + return; + } + + real *tBuf2 = (real *)Sleef_malloc(sizeof(real)*2*p->hlen*p->vlen); + + const int niter = 1 + 5000000 / (p->hlen * p->vlen + 1); + uint64_t tm; + + tm = Sleef_currentTimeMicros(); + for(int i=0;itBuf, p->log2hlen, p->log2vlen); + transpose(tBuf2, p->tBuf, p->log2vlen, p->log2hlen); + } + p->tmNoMT = Sleef_currentTimeMicros() - tm + 1; + + if ((p->mode & SLEEF_MODE_VERBOSE) != 0) printf("transpose NoMT(measured): %lld\n", (long long int)p->tmNoMT); + +#ifdef _OPENMP + tm = Sleef_currentTimeMicros(); + for(int i=0;itBuf, p->log2hlen, p->log2vlen); + transposeMT(tBuf2, p->tBuf, p->log2vlen, p->log2hlen); + } + p->tmMT = Sleef_currentTimeMicros() - tm + 1; + + if ((p->mode & SLEEF_MODE_VERBOSE) != 0) printf("transpose MT(measured): %lld\n", (long long int)p->tmMT); +#else + p->tmMT = p->tmNoMT*2; +#endif + + Sleef_free(tBuf2); + + PlanManager_saveMeasurementResultsT(p); +} + +// Implementation of SleefDFT_*_init1d + +EXPORT SleefDFT *INIT(uint32_t n, const real *in, real *out, uint64_t mode) { + SleefDFT *p = (SleefDFT *)calloc(1, sizeof(SleefDFT)); + p->magic = MAGIC; + p->baseTypeID = BASETYPEID; + p->in = (const void *)in; + p->out = (void *)out; + + // Mode + + p->mode = mode; + + if ((p->mode & SLEEF_MODE_NO_MT) == 0) { + p->mode2 |= SLEEF_MODE2_MT1D; + } + + if ((mode & SLEEF_MODE_REAL) != 0) n /= 2; + p->log2len = ilog2(n); + + if (p->log2len <= 1) return p; + + if ((mode & SLEEF_MODE_ALT) != 0) p->mode = mode = mode ^ SLEEF_MODE_BACKWARD; + +#ifdef _OPENMP + p->nThread = omp_thread_count(); +#else + p->nThread = 1; + p->mode2 &= ~SLEEF_MODE2_MT1D; +#endif + + // ISA availability + + int bestPriority = -1; + p->isa = -1; + + for(int i=0;i= (uint32_t)((*GETINT[i])(GETINT_VECWIDTH) * (*GETINT[i])(GETINT_VECWIDTH))) { + bestPriority = (*GETINT[i])(GETINT_DFTPRIORITY); + p->isa = i; + } + } + + if (p->isa == -1) { + if ((p->mode & SLEEF_MODE_VERBOSE) != 0) printf("ISA not available\n"); + p->magic = 0; + free(p); + return NULL; + } + + // Tables + + p->perm = (uint32_t **)calloc(sizeof(uint32_t *), p->log2len+1); + for(int level = p->log2len;level >= 1;level--) { + p->perm[level] = (uint32_t *)Sleef_malloc(sizeof(uint32_t) * ((1 << p->log2len) + 8)); + } + + p->x0 = malloc(sizeof(real *) * p->nThread); + p->x1 = malloc(sizeof(real *) * p->nThread); + + for(int i=0;inThread;i++) { + p->x0[i] = (real *)Sleef_malloc(sizeof(real) * 2 * n); + p->x1[i] = (real *)Sleef_malloc(sizeof(real) * 2 * n); + } + + if ((mode & SLEEF_MODE_REAL) != 0) { + p->rtCoef0 = (real *)Sleef_malloc(sizeof(real) * n); + p->rtCoef1 = (real *)Sleef_malloc(sizeof(real) * n); + + if ((mode & SLEEF_MODE_BACKWARD) == 0) { + for(uint32_t i=0;irtCoef0)[i*2+0] = ((real *)p->rtCoef0)[i*2+1] = (real)0.5 - (real)0.5 * sc.x; + ((real *)p->rtCoef1)[i*2+0] = ((real *)p->rtCoef1)[i*2+1] = (real)0.5*sc.y; + } + } else { + for(uint32_t i=0;irtCoef0)[i*2+0] = ((real *)p->rtCoef0)[i*2+1] = (real)0.5 + (real)0.5 * sc.x; + ((real *)p->rtCoef1)[i*2+0] = ((real *)p->rtCoef1)[i*2+1] = (real)0.5*sc.y; + } + } + } + + // Measure + + int sign = (mode & SLEEF_MODE_BACKWARD) != 0 ? -1 : 1; + + p->vecwidth = (*GETINT[p->isa])(GETINT_VECWIDTH); + p->log2vecwidth = ilog2(p->vecwidth); + + for(int i=1;i<=MAXBUTWIDTH;i++) { + ((real ***)p->tbl)[i] = makeTable(sign, p->vecwidth, p->log2len, i, constK[i]); + } + + if (!measure(p, (mode & SLEEF_MODE_DEBUG))) { + // Fall back to the first ISA + freeTables(p); + p->isa = 0; + + p->vecwidth = (*GETINT[p->isa])(GETINT_VECWIDTH); + p->log2vecwidth = ilog2(p->vecwidth); + + for(int i=1;i<=MAXBUTWIDTH;i++) { + ((real ***)p->tbl)[i] = makeTable(sign, p->vecwidth, p->log2len, i, constK[i]); + } + + for(int level = p->log2len;level >= 1;) { + int N = ABS(p->bestPath[level]); + if (level == N) { level -= N; continue; } + + int i1 = 0; + for(int i0=0;i0 < (1 << (p->log2len-N));i0+=p->vecwidth, i1++) { + p->perm[level][i1] = 2*perm(p->log2len, i0, p->log2len-level, p->log2len-(level-N)); + } + for(;i1 < (1 << p->log2len) + 8;i1++) p->perm[level][i1] = 0; + + level -= N; + } + + if (!measure(p, (mode & SLEEF_MODE_DEBUG))) { + if ((p->mode & SLEEF_MODE_VERBOSE) != 0) printf("Suitable ISA not found. This should not happen.\n"); + return NULL; + } + } + + for(int level = p->log2len;level >= 1;) { + int N = ABS(p->bestPath[level]); + if (level == N) { level -= N; continue; } + + int i1 = 0; + for(int i0=0;i0 < (1 << (p->log2len-N));i0+=p->vecwidth, i1++) { + p->perm[level][i1] = 2*perm(p->log2len, i0, p->log2len-level, p->log2len-(level-N)); + } + for(;i1 < (1 << p->log2len) + 8;i1++) p->perm[level][i1] = 0; + + level -= N; + } + + if ((p->mode & SLEEF_MODE_VERBOSE) != 0) printf("ISA : %s %d bit %s\n", (char *)(*GETPTR[p->isa])(0), (int)(GETINT[p->isa](GETINT_VECWIDTH) * sizeof(real) * 16), BASETYPESTRING); + + return p; +} + +// Implementation of SleefDFT_*_init2d + +EXPORT SleefDFT *INIT2D(uint32_t vlen, uint32_t hlen, const real *in, real *out, uint64_t mode) { + SleefDFT *p = (SleefDFT *)calloc(1, sizeof(SleefDFT)); + p->magic = MAGIC2D; + p->mode = mode; + p->baseTypeID = BASETYPEID; + p->in = in; + p->out = out; + p->hlen = hlen; + p->log2hlen = ilog2(hlen); + p->vlen = vlen; + p->log2vlen = ilog2(vlen); + + uint64_t mode1D = mode; + mode1D |= SLEEF_MODE_NO_MT; + + if ((mode & SLEEF_MODE_NO_MT) == 0) p->mode3 |= SLEEF_MODE3_MT2D; + + p->instH = p->instV = INIT(hlen, NULL, NULL, mode1D); + if (hlen != vlen) p->instV = INIT(vlen, NULL, NULL, mode1D); + + p->tBuf = (void *)Sleef_malloc(sizeof(real)*2*hlen*vlen); + + measureTranspose(p); + + return p; +} + +// Implementation of SleefDFT_*_execute + +EXPORT void EXECUTE(SleefDFT *p, const real *s0, real *d0) { + assert(p != NULL && (p->magic == MAGIC || p->magic == MAGIC2D)); + + const real *s = s0 == NULL ? p->in : s0; + real *d = d0 == NULL ? p->out : d0; + + if (p->magic == MAGIC2D) { + // S -> T -> D -> T -> D + + real *tBuf = (real *)(p->tBuf); + +#ifdef _OPENMP + if ((p->mode3 & SLEEF_MODE3_MT2D) != 0 && + (((p->mode & SLEEF_MODE_DEBUG) == 0 && p->tmMT < p->tmNoMT) || + ((p->mode & SLEEF_MODE_DEBUG) != 0 && (rand() & 1)))) + { + int y=0; +#pragma omp parallel for + for(y=0;yvlen;y++) { + EXECUTE(p->instH, &s[p->hlen*2*y], &tBuf[p->hlen*2*y]); + } + + transposeMT(d, tBuf, p->log2vlen, p->log2hlen); + +#pragma omp parallel for + for(y=0;yhlen;y++) { + EXECUTE(p->instV, &d[p->vlen*2*y], &tBuf[p->vlen*2*y]); + } + + transposeMT(d, tBuf, p->log2hlen, p->log2vlen); + } else +#endif + { + for(int y=0;yvlen;y++) { + EXECUTE(p->instH, &s[p->hlen*2*y], &tBuf[p->hlen*2*y]); + } + + transpose(d, tBuf, p->log2vlen, p->log2hlen); + + for(int y=0;yhlen;y++) { + EXECUTE(p->instV, &d[p->vlen*2*y], &tBuf[p->vlen*2*y]); + } + + transpose(d, tBuf, p->log2hlen, p->log2vlen); + } + + return; + } + + if (p->log2len <= 1) { + if ((p->mode & SLEEF_MODE_REAL) == 0) { + real r0 = s[0] + s[2]; + real r1 = s[1] + s[3]; + real r2 = s[0] - s[2]; + real r3 = s[1] - s[3]; + d[0] = r0; d[1] = r1; d[2] = r2; d[3] = r3; + } else { + if ((p->mode & SLEEF_MODE_ALT) == 0) { + if (p->log2len == 1) { + if ((p->mode & SLEEF_MODE_BACKWARD) == 0) { + real r0 = s[0] + s[2] + (s[1] + s[3]); + real r1 = s[0] + s[2] - (s[1] + s[3]); + real r2 = s[0] - s[2]; + real r3 = s[3] - s[1]; + d[0] = r0; d[1] = 0; d[2] = r2; d[3] = r3; d[4] = r1; d[5] = 0; + } else { + real r0 = (s[0] + s[4])*(real)0.5 + s[2]; + real r1 = (s[0] - s[4])*(real)0.5 - s[3]; + real r2 = (s[0] + s[4])*(real)0.5 - s[2]; + real r3 = (s[0] - s[4])*(real)0.5 + s[3]; + d[0] = r0*2; d[1] = r1*2; d[2] = r2*2; d[3] = r3*2; + } + } else { + if ((p->mode & SLEEF_MODE_BACKWARD) == 0) { + real r0 = s[0] + s[1]; + real r1 = s[0] - s[1]; + d[0] = r0; d[1] = 0; d[2] = r1; d[3] = 0; + } else { + real r0 = s[0] + s[2]; + real r1 = s[0] - s[2]; + d[0] = r0; d[1] = r1; + } + } + } else { + if (p->log2len == 1) { + if ((p->mode & SLEEF_MODE_BACKWARD) == 0) { + real r0 = s[0] + s[2] + (s[1] + s[3]); + real r1 = s[0] + s[2] - (s[1] + s[3]); + real r2 = s[0] - s[2]; + real r3 = s[1] - s[3]; + d[0] = r0; d[1] = r1; d[2] = r2; d[3] = r3; + } else { + real r0 = (s[0] + s[1])*(real)0.5 + s[2]; + real r1 = (s[0] - s[1])*(real)0.5 + s[3]; + real r2 = (s[0] + s[1])*(real)0.5 - s[2]; + real r3 = (s[0] - s[1])*(real)0.5 - s[3]; + d[0] = r0; d[1] = r1; d[2] = r2; d[3] = r3; + } + } else { + real c = ((p->mode & SLEEF_MODE_BACKWARD) != 0) ? (real)0.5 : (real)1.0; + real r0 = s[0] + s[1]; + real r1 = s[0] - s[1]; + d[0] = r0 * c; d[1] = r1 * c; + } + } + } + return; + } + + // + +#ifdef _OPENMP + const int tn = omp_get_thread_num(); + real *t[] = { p->x1[tn], p->x0[tn], d }; +#else + real *t[] = { p->x1[0], p->x0[0], d }; +#endif + + const real *lb = s; + int nb = 0; + + if ((p->mode & SLEEF_MODE_REAL) != 0 && (p->pathLen & 1) == 0 && + ((p->mode & SLEEF_MODE_BACKWARD) != 0) != ((p->mode & SLEEF_MODE_ALT) != 0)) nb = -1; + if ((p->mode & SLEEF_MODE_REAL) == 0 && (p->pathLen & 1) == 1) nb = -1; + + if ((p->mode & SLEEF_MODE_REAL) != 0 && + ((p->mode & SLEEF_MODE_BACKWARD) != 0) != ((p->mode & SLEEF_MODE_ALT) != 0)) { + (*REALSUB1[p->isa])(t[nb+1], s, p->log2len, p->rtCoef0, p->rtCoef1, (p->mode & SLEEF_MODE_ALT) == 0); + if ((p-> mode & SLEEF_MODE_ALT) == 0) t[nb+1][(1 << p->log2len)+1] = -s[(1 << p->log2len)+1] * 2; + lb = t[nb+1]; + nb = (nb + 1) & 1; + } + + for(int level = p->log2len;level >= 1;) { + int N = ABS(p->bestPath[level]), config = p->bestPathConfig[level]; + dispatch(p, N, t[nb+1], lb, level, config); + level -= N; + lb = t[nb+1]; + nb = (nb + 1) & 1; + } + + if ((p->mode & SLEEF_MODE_REAL) != 0 && + ((p->mode & SLEEF_MODE_BACKWARD) == 0) != ((p->mode & SLEEF_MODE_ALT) != 0)) { + (*REALSUB0[p->isa])(d, lb, p->log2len, p->rtCoef0, p->rtCoef1); + if ((p->mode & SLEEF_MODE_ALT) == 0) { + d[(1 << p->log2len)+1] = -d[(1 << p->log2len)+1]; + d[(2 << p->log2len)+0] = d[1]; + d[(2 << p->log2len)+1] = 0; + d[1] = 0; + } + } +} diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/dft/dftcommon.c b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/dft/dftcommon.c new file mode 100644 index 00000000000..184af8f2027 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/dft/dftcommon.c @@ -0,0 +1,423 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include +#include +#include + +#include + +#ifdef _OPENMP +#include +#endif + +#include "misc.h" +#include "sleef.h" + +#define IMPORT_IS_EXPORT +#include "sleefdft.h" +#include "dispatchparam.h" +#include "dftcommon.h" +#include "common.h" +#include "arraymap.h" + +#define MAGIC_FLOAT 0x31415926 +#define MAGIC_DOUBLE 0x27182818 + +#define MAGIC2D_FLOAT 0x22360679 +#define MAGIC2D_DOUBLE 0x17320508 + +const char *configStr[] = { "ST", "ST stream", "MT", "MT stream" }; + +static int parsePathStr(char *p, int *path, int *config, int pathLenMax, int log2len) { + int pathLen = 0, l2l = 0; + + for(;;) { + while(*p == ' ') p++; + if (*p == '\0') break; + if (!isdigit((int)*p)) return -1; + + pathLen++; + if (pathLen >= pathLenMax) return -2; + + int n = 0; + while(isdigit((int)*p)) n = n * 10 + *p++ - '0'; + + if (n > MAXBUTWIDTH) return -6; + path[pathLen-1] = n; + l2l += n; + config[pathLen-1] = 0; + + if (*p != '(') continue; + + int c; + for(c=3;c>=0;c--) if (strncmp(p+1, configStr[c], strlen(configStr[c])) == 0) break; + if (c == -1) return -3; + p += strlen(configStr[c]) + 1; + if (*p != ')') return -4; + p++; + + config[pathLen-1] = c; + } + + if (l2l != log2len) return -5; + + return pathLen; +} + +EXPORT void SleefDFT_setPath(SleefDFT *p, char *pathStr) { + assert(p != NULL && (p->magic == MAGIC_FLOAT || p->magic == MAGIC_DOUBLE)); + + int path[32], config[32]; + int pathLen = parsePathStr(pathStr, path, config, 31, p->log2len); + + if (pathLen < 0) { + if ((p->mode & SLEEF_MODE_VERBOSE) != 0) printf("Error %d in parsing path string : %s\n", pathLen, pathStr); + return; + } + + for(uint32_t j = 0;j <= p->log2len;j++) p->bestPath[j] = 0; + + for(int level = p->log2len, j=0;level > 0 && j < pathLen;) { + p->bestPath[level] = path[j]; + p->bestPathConfig[level] = config[j]; + level -= path[j]; + j++; + } + + p->pathLen = 0; + for(int j = p->log2len;j >= 0;j--) if (p->bestPath[j] != 0) p->pathLen++; + + if ((p->mode & SLEEF_MODE_VERBOSE) != 0) { + printf("Set path : "); + for(int j = p->log2len;j >= 0;j--) if (p->bestPath[j] != 0) printf("%d(%s) ", p->bestPath[j], configStr[p->bestPathConfig[j]]); + printf("\n"); + } +} + +void freeTables(SleefDFT *p) { + for(int N=1;N<=MAXBUTWIDTH;N++) { + for(uint32_t level=N;level<=p->log2len;level++) { + Sleef_free(p->tbl[N][level]); + } + free(p->tbl[N]); + p->tbl[N] = NULL; + } +} + +EXPORT void SleefDFT_dispose(SleefDFT *p) { + if (p != NULL && (p->magic == MAGIC2D_FLOAT || p->magic == MAGIC2D_DOUBLE)) { + Sleef_free(p->tBuf); + SleefDFT_dispose(p->instH); + if (p->hlen != p->vlen) SleefDFT_dispose(p->instV); + + p->magic = 0; + free(p); + return; + } + + assert(p != NULL && (p->magic == MAGIC_FLOAT || p->magic == MAGIC_DOUBLE)); + + if (p->log2len <= 1) { + p->magic = 0; + free(p); + return; + } + + if ((p->mode & SLEEF_MODE_REAL) != 0) { + Sleef_free(p->rtCoef1); + Sleef_free(p->rtCoef0); + p->rtCoef0 = p->rtCoef1 = NULL; + } + + for(int level = p->log2len;level >= 1;level--) { + Sleef_free(p->perm[level]); + } + free(p->perm); + p->perm = NULL; + + freeTables(p); + + p->magic = 0; + free(p); +} + +uint32_t ilog2(uint32_t q) { + static const uint32_t tab[] = {0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4}; + uint32_t r = 0,qq; + + if (q & 0xffff0000) r = 16; + + q >>= r; + qq = q | (q >> 1); + qq |= (qq >> 2); + qq = ((qq & 0x10) >> 4) | ((qq & 0x100) >> 7) | ((qq & 0x1000) >> 10); + + return r + tab[qq] * 4 + tab[q >> (tab[qq] * 4)] - 1; +} + +// + +char *dftPlanFilePath = NULL; +char *archID = NULL; +uint64_t planMode = SLEEF_PLAN_REFERTOENVVAR; +ArrayMap *planMap = NULL; +int planFilePathSet = 0, planFileLoaded = 0; +#ifdef _OPENMP +omp_lock_t planMapLock; +int planMapLockInitialized = 0; +#endif + +static void initPlanMapLock() { +#ifdef _OPENMP +#pragma omp critical + { + if (!planMapLockInitialized) { + planMapLockInitialized = 1; + omp_init_lock(&planMapLock); + } + } +#endif +} + +static void planMap_clear() { + if (planMap != NULL) ArrayMap_dispose(planMap); + planMap = NULL; +} + +EXPORT void SleefDFT_setPlanFilePath(const char *path, const char *arch, uint64_t mode) { + initPlanMapLock(); + + if ((mode & SLEEF_PLAN_RESET) != 0) { + planMap_clear(); + planFileLoaded = 0; + planFilePathSet = 0; + } + + if (dftPlanFilePath != NULL) free(dftPlanFilePath); + if (path != NULL) { + dftPlanFilePath = malloc(strlen(path)+10); + strcpy(dftPlanFilePath, path); + } else { + dftPlanFilePath = NULL; + } + + if (archID != NULL) free(archID); + if (arch == NULL) arch = Sleef_getCpuIdString(); + archID = malloc(strlen(arch)+10); + strcpy(archID, arch); + + planMode = mode; + planFilePathSet = 1; +} + +static void loadPlanFromFile() { + if (planFilePathSet == 0 && (planMode & SLEEF_PLAN_REFERTOENVVAR) != 0) { + char *s = getenv(ENVVAR); + if (s != NULL) SleefDFT_setPlanFilePath(s, NULL, planMode); + } + + if (planMap != NULL) ArrayMap_dispose(planMap); + + if (dftPlanFilePath != NULL && (planMode & SLEEF_PLAN_RESET) == 0) { + planMap = ArrayMap_load(dftPlanFilePath, archID, PLANFILEID, (planMode & SLEEF_PLAN_NOLOCK) == 0); + } + + if (planMap == NULL) planMap = initArrayMap(); + + planFileLoaded = 1; +} + +static void savePlanToFile() { + assert(planFileLoaded); + if ((planMode & SLEEF_PLAN_READONLY) == 0 && dftPlanFilePath != NULL) { + ArrayMap_save(planMap, dftPlanFilePath, archID, PLANFILEID); + } +} + +#define CATBIT 8 +#define BASETYPEIDBIT 2 +#define LOG2LENBIT 8 +#define DIRBIT 1 + +#define BUTSTATBIT 16 + +static uint64_t keyButStat(int baseTypeID, int log2len, int dir, int butStat) { + dir = (dir & SLEEF_MODE_BACKWARD) == 0; + int cat = 0; + uint64_t k = 0; + k = (k << BUTSTATBIT) | (butStat & ~(~(uint64_t)0 << BUTSTATBIT)); + k = (k << LOG2LENBIT) | (log2len & ~(~(uint64_t)0 << LOG2LENBIT)); + k = (k << DIRBIT) | (dir & ~(~(uint64_t)0 << LOG2LENBIT)); + k = (k << BASETYPEIDBIT) | (baseTypeID & ~(~(uint64_t)0 << BASETYPEIDBIT)); + k = (k << CATBIT) | (cat & ~(~(uint64_t)0 << CATBIT)); + return k; +} + +#define LEVELBIT LOG2LENBIT +#define BUTCONFIGBIT 8 +#define TRANSCONFIGBIT 8 + +static uint64_t keyTrans(int baseTypeID, int hlen, int vlen, int transConfig) { + int max = MAX(hlen, vlen), min = MIN(hlen, vlen); + int cat = 2; + uint64_t k = 0; + k = (k << TRANSCONFIGBIT) | (transConfig & ~(~(uint64_t)0 << TRANSCONFIGBIT)); + k = (k << LOG2LENBIT) | (max & ~(~(uint64_t)0 << LOG2LENBIT)); + k = (k << LOG2LENBIT) | (min & ~(~(uint64_t)0 << LOG2LENBIT)); + k = (k << BASETYPEIDBIT) | (baseTypeID & ~(~(uint64_t)0 << BASETYPEIDBIT)); + k = (k << CATBIT) | (cat & ~(~(uint64_t)0 << CATBIT)); + return k; +} + +static uint64_t keyPath(int baseTypeID, int log2len, int dir, int level, int config) { + dir = (dir & SLEEF_MODE_BACKWARD) == 0; + int cat = 3; + uint64_t k = 0; + k = (k << BUTCONFIGBIT) | (config & ~(~(uint64_t)0 << BUTCONFIGBIT)); + k = (k << LEVELBIT) | (level & ~(~(uint64_t)0 << LEVELBIT)); + k = (k << LOG2LENBIT) | (log2len & ~(~(uint64_t)0 << LOG2LENBIT)); + k = (k << DIRBIT) | (dir & ~(~(uint64_t)0 << LOG2LENBIT)); + k = (k << BASETYPEIDBIT) | (baseTypeID & ~(~(uint64_t)0 << BASETYPEIDBIT)); + k = (k << CATBIT) | (cat & ~(~(uint64_t)0 << CATBIT)); + return k; +} + +static uint64_t keyPathConfig(int baseTypeID, int log2len, int dir, int level, int config) { + dir = (dir & SLEEF_MODE_BACKWARD) == 0; + int cat = 4; + uint64_t k = 0; + k = (k << BUTCONFIGBIT) | (config & ~(~(uint64_t)0 << BUTCONFIGBIT)); + k = (k << LEVELBIT) | (level & ~(~(uint64_t)0 << LEVELBIT)); + k = (k << LOG2LENBIT) | (log2len & ~(~(uint64_t)0 << LOG2LENBIT)); + k = (k << DIRBIT) | (dir & ~(~(uint64_t)0 << LOG2LENBIT)); + k = (k << BASETYPEIDBIT) | (baseTypeID & ~(~(uint64_t)0 << BASETYPEIDBIT)); + k = (k << CATBIT) | (cat & ~(~(uint64_t)0 << CATBIT)); + return k; +} + +static uint64_t planMap_getU64(uint64_t key) { + char *s = ArrayMap_get(planMap, key); + if (s == NULL) return 0; + uint64_t ret; + if (sscanf(s, "%" SCNx64, &ret) != 1) return 0; + return ret; +} + +static void planMap_putU64(uint64_t key, uint64_t value) { + char *s = malloc(100); + sprintf(s, "%" PRIx64, value); + s = ArrayMap_put(planMap, key, s); + if (s != NULL) free(s); +} + +int PlanManager_loadMeasurementResultsP(SleefDFT *p, int pathCat) { + assert(p != NULL && (p->magic == MAGIC_FLOAT || p->magic == MAGIC_DOUBLE)); + + initPlanMapLock(); + +#ifdef _OPENMP + omp_set_lock(&planMapLock); +#endif + if (!planFileLoaded) loadPlanFromFile(); + + int stat = planMap_getU64(keyButStat(p->baseTypeID, p->log2len, p->mode, pathCat+10)); + if (stat == 0) { +#ifdef _OPENMP + omp_unset_lock(&planMapLock); +#endif + return 0; + } + + int ret = 1; + + for(int j = p->log2len;j >= 0;j--) { + p->bestPath[j] = planMap_getU64(keyPath(p->baseTypeID, p->log2len, p->mode, j, pathCat)); + p->bestPathConfig[j] = planMap_getU64(keyPathConfig(p->baseTypeID, p->log2len, p->mode, j, pathCat)); + if (p->bestPath[j] > MAXBUTWIDTH) ret = 0; + } + + p->pathLen = 0; + for(int j = p->log2len;j >= 0;j--) if (p->bestPath[j] != 0) p->pathLen++; + +#ifdef _OPENMP + omp_unset_lock(&planMapLock); +#endif + return ret; +} + +void PlanManager_saveMeasurementResultsP(SleefDFT *p, int pathCat) { + assert(p != NULL && (p->magic == MAGIC_FLOAT || p->magic == MAGIC_DOUBLE)); + + initPlanMapLock(); + +#ifdef _OPENMP + omp_set_lock(&planMapLock); +#endif + if (!planFileLoaded) loadPlanFromFile(); + + if (planMap_getU64(keyButStat(p->baseTypeID, p->log2len, p->mode, pathCat+10)) != 0) { +#ifdef _OPENMP + omp_unset_lock(&planMapLock); +#endif + return; + } + + for(int j = p->log2len;j >= 0;j--) { + planMap_putU64(keyPath(p->baseTypeID, p->log2len, p->mode, j, pathCat), p->bestPath[j]); + planMap_putU64(keyPathConfig(p->baseTypeID, p->log2len, p->mode, j, pathCat), p->bestPathConfig[j]); + } + + planMap_putU64(keyButStat(p->baseTypeID, p->log2len, p->mode, pathCat+10), 1); + + if ((planMode & SLEEF_PLAN_READONLY) == 0) savePlanToFile(); + +#ifdef _OPENMP + omp_unset_lock(&planMapLock); +#endif +} + +int PlanManager_loadMeasurementResultsT(SleefDFT *p) { + assert(p != NULL && (p->magic == MAGIC2D_FLOAT || p->magic == MAGIC2D_DOUBLE)); + + initPlanMapLock(); + +#ifdef _OPENMP + omp_set_lock(&planMapLock); +#endif + if (!planFileLoaded) loadPlanFromFile(); + + p->tmNoMT = planMap_getU64(keyTrans(p->baseTypeID, p->log2hlen, p->log2vlen, 0)); + p->tmMT = planMap_getU64(keyTrans(p->baseTypeID, p->log2hlen, p->log2vlen, 1)); + +#ifdef _OPENMP + omp_unset_lock(&planMapLock); +#endif + return p->tmNoMT != 0; +} + +void PlanManager_saveMeasurementResultsT(SleefDFT *p) { + assert(p != NULL && (p->magic == MAGIC2D_FLOAT || p->magic == MAGIC2D_DOUBLE)); + + initPlanMapLock(); + +#ifdef _OPENMP + omp_set_lock(&planMapLock); +#endif + if (!planFileLoaded) loadPlanFromFile(); + + planMap_putU64(keyTrans(p->baseTypeID, p->log2hlen, p->log2vlen, 0), p->tmNoMT); + planMap_putU64(keyTrans(p->baseTypeID, p->log2hlen, p->log2vlen, 1), p->tmMT ); + + if ((planMode & SLEEF_PLAN_READONLY) == 0) savePlanToFile(); + +#ifdef _OPENMP + omp_unset_lock(&planMapLock); +#endif +} diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/dft/dftcommon.h b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/dft/dftcommon.h new file mode 100644 index 00000000000..54a461d7d92 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/dft/dftcommon.h @@ -0,0 +1,69 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#define CONFIGMAX 4 +#define CONFIG_STREAM 1 +#define CONFIG_MT 2 + +#define MAXLOG2LEN 32 + +typedef struct SleefDFT { + uint32_t magic; + uint64_t mode, mode2, mode3; + int baseTypeID; + const void *in; + void *out; + + union { + struct { + uint32_t log2len; + + void **tbl[MAXBUTWIDTH+1]; + void *rtCoef0, *rtCoef1; + uint32_t **perm; + + void **x0, **x1; + + int isa; + int planMode; + + int vecwidth, log2vecwidth; + int nThread; + + uint64_t tm[CONFIGMAX][(MAXBUTWIDTH+1)*32]; + uint64_t bestTime; + int16_t bestPath[32], bestPathConfig[32], pathLen; + }; + + struct { + int32_t hlen, vlen; + int32_t log2hlen, log2vlen; + uint64_t tmNoMT, tmMT; + struct SleefDFT *instH, *instV; + void *tBuf; + }; + }; +} SleefDFT; + +#define SLEEF_MODE2_MT1D (1 << 0) +#define SLEEF_MODE3_MT2D (1 << 0) + +#define PLANFILEID "SLEEFDFT0\n" +#define ENVVAR "SLEEFDFTPLAN" + +#define SLEEF_MODE_MEASUREBITS (3 << 20) + +void freeTables(SleefDFT *p); +uint32_t ilog2(uint32_t q); + +//int PlanManager_loadMeasurementResultsB(SleefDFT *p); +//void PlanManager_saveMeasurementResultsB(SleefDFT *p, int butStat); +int PlanManager_loadMeasurementResultsT(SleefDFT *p); +void PlanManager_saveMeasurementResultsT(SleefDFT *p); +int PlanManager_loadMeasurementResultsP(SleefDFT *p, int pathCat); +void PlanManager_saveMeasurementResultsP(SleefDFT *p, int pathCat); + +#define GETINT_VECWIDTH 100 +#define GETINT_DFTPRIORITY 101 diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/dft/mkdispatch.c b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/dft/mkdispatch.c new file mode 100644 index 00000000000..76d6b72e835 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/dft/mkdispatch.c @@ -0,0 +1,193 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include + +#ifndef ENABLE_STREAM +#error ENABLE_STREAM not defined +#endif + +int main(int argc, char **argv) { + if (argc < 3) { + fprintf(stderr, "Usage : %s ...\n", argv[0]); + exit(-1); + } + + const char *basetype = argv[1]; + const int maxbutwidth = atoi(argv[2]); + const int isastart = 3; + const int isamax = argc - isastart; + +#if ENABLE_STREAM == 1 + const int enable_stream = 1; +#else + const int enable_stream = 0; +#endif + + printf("#define MAXBUTWIDTH %d\n", maxbutwidth); + printf("\n"); + + if (strcmp(basetype, "paramonly") == 0) exit(0); + + printf("#define ISAMAX %d\n", isamax); + printf("#define CONFIGMAX 4\n"); + + for(int k=isastart;k +#include +#include +#include + +#define CONFIGMAX 4 + +char *replaceAll(const char *in, const char *pat, const char *replace) { + const int replaceLen = (int)strlen(replace); + const int patLen = (int)strlen(pat); + + char *str = malloc(strlen(in)+1); + strcpy(str, in); + + for(;;) { + char *p = strstr(str, pat); + if (p == NULL) return str; + + int replace_pos = (int)(p - str); + int tail_len = (int)strlen(p + patLen); + + char *newstr = malloc(strlen(str) + (replaceLen - patLen) + 1); + + memcpy(newstr, str, replace_pos); + memcpy(newstr + replace_pos, replace, replaceLen); + memcpy(newstr + replace_pos + replaceLen, str + replace_pos + patLen, tail_len+1); + + free(str); + str = newstr; + } + + return str; +} + +#define LEN 1024 +char line[LEN+10]; + +int main(int argc, char **argv) { + if (argc < 2) { + fprintf(stderr, "Usage : %s ...\n", argv[0]); + exit(-1); + } + + const char *baseType = argv[1]; + const int isastart = 2; + + for(int config=0;config> outShift); + + store(out, (0 << outShift), plus(load(in, (0 << inShift)), load(in, (1 << inShift)))); + real2 v4 = minus(load(in, (0 << inShift)), load(in, (1 << inShift))); + store(out, (1 << outShift), ctimesminusplus(v4, tbl[0 + tbloffset], ctimes(reverse(v4), tbl[1 + tbloffset]))); + } +} + +ALIGNED(8192) void but2b_%CONFIG%_%ISA%(real *RESTRICT out0, uint32_t *q, const int outShift, const real *RESTRICT in0, const int inShift, const real *RESTRICT tbl, const int K) { + const int k = 1 << (inShift - LOG2VECWIDTH); + int i=0; +#pragma omp parallel for + for(i=0;i < k;i++) { + int i0 = i << LOG2VECWIDTH; + real *out = out0 + q[i]; + const real *in = in0 + i0*2; + const int tbloffset = K * (i0 >> outShift); + + store(out, (0 << outShift), plus(load(in, (0 << inShift)), load(in, (1 << inShift)))); + real2 v4 = minus(load(in, (0 << inShift)), load(in, (1 << inShift))); + store(out, (1 << outShift), ctimesminusplus(v4, tbl[0 + tbloffset], ctimes(reverse(v4), tbl[1 + tbloffset]))); + } +} + +ALIGNED(8192) void tbut2f_%CONFIG%_%ISA%(real *RESTRICT out0, uint32_t *q, const real *RESTRICT in0, const int inShift, const real *RESTRICT tbl, const int K) { + const int k = 1 << (inShift - LOG2VECWIDTH); + int i=0; +#pragma omp parallel for + for(i=0;i < k;i++) { + int i0 = i << LOG2VECWIDTH; + real *out = out0 + q[i]; + const real *in = in0 + i0*2; + const int tbloffset = K * i0; + + scatter(out, 0, 2, plus(load(in, (0 << inShift)), load(in, (1 << inShift)))); + real2 v4 = minus(load(in, (0 << inShift)), load(in, (1 << inShift))); + scatter(out, 1, 2, timesminusplus(v4, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v4), load(tbl, 1 * VECWIDTH + tbloffset)))); + } +} + +ALIGNED(8192) void tbut2b_%CONFIG%_%ISA%(real *RESTRICT out0, uint32_t *q, const real *RESTRICT in0, const int inShift, const real *RESTRICT tbl, const int K) { + const int k = 1 << (inShift - LOG2VECWIDTH); + int i=0; +#pragma omp parallel for + for(i=0;i < k;i++) { + int i0 = i << LOG2VECWIDTH; + real *out = out0 + q[i]; + const real *in = in0 + i0*2; + const int tbloffset = K * i0; + + scatter(out, 0, 2, plus(load(in, (0 << inShift)), load(in, (1 << inShift)))); + real2 v4 = minus(load(in, (0 << inShift)), load(in, (1 << inShift))); + scatter(out, 1, 2, timesminusplus(v4, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v4), load(tbl, 1 * VECWIDTH + tbloffset)))); + } +} + +ALIGNED(8192) void dft4f_%CONFIG%_%ISA%(real *RESTRICT out0, const real *RESTRICT in0, const int shift) { + const int k = 1 << (shift - LOG2VECWIDTH); + int i=0; +#pragma omp parallel for + for(i=0;i < k;i++) { + int i0 = i << LOG2VECWIDTH; + real *out = out0 + i0*2; + const real *in = in0 + i0*2; + + real2 v3 = load(in, 1 << shift); + real2 v5 = load(in, 3 << shift); + real2 v7 = reverse(minus(v3, v5)); + real2 v13 = plus(v3, v5); + real2 v4 = load(in, 2 << shift); + real2 v2 = load(in, 0 << shift); + real2 v8 = minus(v4, v2); + real2 v12 = plus(v2, v4); + store(out, 3 << shift, minus(uminusplus(v7), v8)); + store(out, 1 << shift, minus(uplusminus(v7), v8)); + store(out, 2 << shift, minus(v12, v13)); + store(out, 0 << shift, plus(v12, v13)); + } +} + +ALIGNED(8192) void dft4b_%CONFIG%_%ISA%(real *RESTRICT out0, const real *RESTRICT in0, const int shift) { + const int k = 1 << (shift - LOG2VECWIDTH); + int i=0; +#pragma omp parallel for + for(i=0;i < k;i++) { + int i0 = i << LOG2VECWIDTH; + real *out = out0 + i0*2; + const real *in = in0 + i0*2; + + real2 v3 = load(in, 1 << shift); + real2 v5 = load(in, 3 << shift); + real2 v13 = plus(v3, v5); + real2 v7 = reverse(minus(v5, v3)); + real2 v4 = load(in, 2 << shift); + real2 v2 = load(in, 0 << shift); + real2 v8 = minus(v4, v2); + store(out, 3 << shift, minus(uminusplus(v7), v8)); + store(out, 1 << shift, minus(uplusminus(v7), v8)); + real2 v12 = plus(v2, v4); + store(out, 2 << shift, minus(v12, v13)); + store(out, 0 << shift, plus(v12, v13)); + } +} + +ALIGNED(8192) void but4f_%CONFIG%_%ISA%(real *RESTRICT out0, uint32_t *q, const int outShift, const real *RESTRICT in0, const int inShift, const real *RESTRICT tbl, const int K) { + const int k = 1 << (inShift - LOG2VECWIDTH); + int i=0; +#pragma omp parallel for + for(i=0;i < k;i++) { + int i0 = i << LOG2VECWIDTH; + real *out = out0 + q[i]; + const real *in = in0 + i0*2; + const int tbloffset = K * (i0 >> outShift); + + real2 v5 = load(in, 3 << inShift); + real2 v3 = load(in, 1 << inShift); + real2 v7 = reverse(minus(v3, v5)); + real2 v13 = plus(v3, v5); + real2 v2 = load(in, 0 << inShift); + real2 v4 = load(in, 2 << inShift); + real2 v8 = minus(v4, v2); + real2 v12 = plus(v2, v4); + store(out, 0 << outShift, plus(v12, v13)); + real2 v26 = minus(v12, v13); + store(out, 2 << outShift, ctimesminusplus(v26, tbl[0 + tbloffset], ctimes(reverse(v26), tbl[1 + tbloffset]))); + real2 v11 = minusplus(uminus(v7), v8); + real2 v9 = minusplus(v7, v8); + store(out, 1 << outShift, ctimesminusplus(reverse(v9), tbl[2 + tbloffset], ctimes(v9, tbl[3 + tbloffset]))); + store(out, 3 << outShift, ctimesminusplus(reverse(v11), tbl[4 + tbloffset], ctimes(v11, tbl[5 + tbloffset]))); + } +} + +ALIGNED(8192) void but4b_%CONFIG%_%ISA%(real *RESTRICT out0, uint32_t *q, const int outShift, const real *RESTRICT in0, const int inShift, const real *RESTRICT tbl, const int K) { + const int k = 1 << (inShift - LOG2VECWIDTH); + int i=0; +#pragma omp parallel for + for(i=0;i < k;i++) { + int i0 = i << LOG2VECWIDTH; + real *out = out0 + q[i]; + const real *in = in0 + i0*2; + const int tbloffset = K * (i0 >> outShift); + + real2 v5 = load(in, 3 << inShift); + real2 v3 = load(in, 1 << inShift); + real2 v7 = reverse(minus(v5, v3)); + real2 v13 = plus(v3, v5); + real2 v2 = load(in, 0 << inShift); + real2 v4 = load(in, 2 << inShift); + real2 v8 = minus(v4, v2); + real2 v12 = plus(v2, v4); + store(out, 0 << outShift, plus(v12, v13)); + real2 v26 = minus(v12, v13); + store(out, 2 << outShift, ctimesminusplus(v26, tbl[0 + tbloffset], ctimes(reverse(v26), tbl[1 + tbloffset]))); + real2 v11 = minusplus(uminus(v7), v8); + real2 v9 = minusplus(v7, v8); + store(out, 1 << outShift, ctimesminusplus(reverse(v9), tbl[2 + tbloffset], ctimes(v9, tbl[3 + tbloffset]))); + store(out, 3 << outShift, ctimesminusplus(reverse(v11), tbl[4 + tbloffset], ctimes(v11, tbl[5 + tbloffset]))); + } +} + +ALIGNED(8192) void tbut4f_%CONFIG%_%ISA%(real *RESTRICT out0, uint32_t *q, const real *RESTRICT in0, const int inShift, const real *RESTRICT tbl, const int K) { + const int k = 1 << (inShift - LOG2VECWIDTH); + int i=0; +#pragma omp parallel for + for(i=0;i < k;i++) { + int i0 = i << LOG2VECWIDTH; + real *out = out0 + q[i]; + const real *in = in0 + i0*2; + const int tbloffset = K * i0; + + real2 v5 = load(in, 3 << inShift); + real2 v3 = load(in, 1 << inShift); + real2 v7 = reverse(minus(v3, v5)); + real2 v13 = plus(v3, v5); + real2 v2 = load(in, 0 << inShift); + real2 v4 = load(in, 2 << inShift); + real2 v8 = minus(v4, v2); + real2 v12 = plus(v2, v4); + scatter(out, 0, 4, plus(v12, v13)); + real2 v26 = minus(v12, v13); + scatter(out, 2, 4, timesminusplus(v26, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v26), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v11 = minusplus(uminus(v7), v8); + real2 v9 = minusplus(v7, v8); + scatter(out, 1, 4, timesminusplus(reverse(v9), load(tbl, 2 * VECWIDTH + tbloffset), times(v9, load(tbl, 3 * VECWIDTH + tbloffset)))); + scatter(out, 3, 4, timesminusplus(reverse(v11), load(tbl, 4 * VECWIDTH + tbloffset), times(v11, load(tbl, 5 * VECWIDTH + tbloffset)))); + } +} + +ALIGNED(8192) void tbut4b_%CONFIG%_%ISA%(real *RESTRICT out0, uint32_t *q, const real *RESTRICT in0, const int inShift, const real *RESTRICT tbl, const int K) { + const int k = 1 << (inShift - LOG2VECWIDTH); + int i=0; +#pragma omp parallel for + for(i=0;i < k;i++) { + int i0 = i << LOG2VECWIDTH; + real *out = out0 + q[i]; + const real *in = in0 + i0*2; + const int tbloffset = K * i0; + + real2 v5 = load(in, 3 << inShift); + real2 v3 = load(in, 1 << inShift); + real2 v7 = reverse(minus(v5, v3)); + real2 v13 = plus(v3, v5); + real2 v2 = load(in, 0 << inShift); + real2 v4 = load(in, 2 << inShift); + real2 v8 = minus(v4, v2); + real2 v12 = plus(v2, v4); + scatter(out, 0, 4, plus(v12, v13)); + real2 v26 = minus(v12, v13); + scatter(out, 2, 4, timesminusplus(v26, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v26), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v11 = minusplus(uminus(v7), v8); + real2 v9 = minusplus(v7, v8); + scatter(out, 1, 4, timesminusplus(reverse(v9), load(tbl, 2 * VECWIDTH + tbloffset), times(v9, load(tbl, 3 * VECWIDTH + tbloffset)))); + scatter(out, 3, 4, timesminusplus(reverse(v11), load(tbl, 4 * VECWIDTH + tbloffset), times(v11, load(tbl, 5 * VECWIDTH + tbloffset)))); + } +} + +#if MAXBUTWIDTH >= 3 +ALIGNED(8192) void dft8f_%CONFIG%_%ISA%(real *RESTRICT out0, const real *RESTRICT in0, const int shift) { + const int k = 1 << (shift - LOG2VECWIDTH); + int i=0; +#pragma omp parallel for + for(i=0;i < k;i++) { + int i0 = i << LOG2VECWIDTH; + real *out = out0 + i0*2; + const real *in = in0 + i0*2; + + real2 v9 = load(in, 7 << shift); + real2 v5 = load(in, 3 << shift); + real2 v33 = plus(v5, v9); + real2 v27 = reverse(minus(v5, v9)); + real2 v3 = load(in, 1 << shift); + real2 v7 = load(in, 5 << shift); + real2 v32 = plus(v3, v7); + real2 v28 = minus(v7, v3); + real2 v45 = reverse(minus(v32, v33)); + real2 v51 = plus(v32, v33); + real2 v29 = minusplus(v27, v28); + real2 v31 = minusplus(uminus(v27), v28); + real2 v43 = ctimesminusplus(reverse(v31), ctbl[1], ctimes(v31, ctbl[0])); + real2 v6 = load(in, 4 << shift); + real2 v2 = load(in, 0 << shift); + real2 v12 = minus(v6, v2); + real2 v16 = plus(v2, v6); + real2 v8 = load(in, 6 << shift); + real2 v4 = load(in, 2 << shift); + real2 v17 = plus(v4, v8); + real2 v11 = reverse(minus(v4, v8)); + real2 v46 = minus(v17, v16); + store(out, 2 << shift, minus(uplusminus(v45), v46)); + store(out, 6 << shift, minus(uminusplus(v45), v46)); + real2 v50 = plus(v16, v17); + store(out, 4 << shift, minus(v50, v51)); + store(out, 0 << shift, plus(v50, v51)); + real2 v25 = minus(uminusplus(v11), v12); + store(out, 3 << shift, plus(v25, v43)); + store(out, 7 << shift, minus(v25, v43)); + real2 v21 = minus(uplusminus(v11), v12); + real2 v38 = ctimesminusplus(reverse(v29), ctbl[1], ctimes(v29, ctbl[1])); + store(out, 1 << shift, plus(v21, v38)); + store(out, 5 << shift, minus(v21, v38)); + } +} + +ALIGNED(8192) void dft8b_%CONFIG%_%ISA%(real *RESTRICT out0, const real *RESTRICT in0, const int shift) { + const int k = 1 << (shift - LOG2VECWIDTH); + int i=0; +#pragma omp parallel for + for(i=0;i < k;i++) { + int i0 = i << LOG2VECWIDTH; + real *out = out0 + i0*2; + const real *in = in0 + i0*2; + + real2 v8 = load(in, 6 << shift); + real2 v4 = load(in, 2 << shift); + real2 v17 = plus(v4, v8); + real2 v11 = reverse(minus(v8, v4)); + real2 v2 = load(in, 0 << shift); + real2 v6 = load(in, 4 << shift); + real2 v16 = plus(v2, v6); + real2 v12 = minus(v6, v2); + real2 v50 = plus(v16, v17); + real2 v46 = minus(v17, v16); + real2 v21 = minus(uplusminus(v11), v12); + real2 v25 = minus(uminusplus(v11), v12); + real2 v3 = load(in, 1 << shift); + real2 v7 = load(in, 5 << shift); + real2 v28 = minus(v7, v3); + real2 v32 = plus(v3, v7); + real2 v5 = load(in, 3 << shift); + real2 v9 = load(in, 7 << shift); + real2 v33 = plus(v5, v9); + real2 v27 = reverse(minus(v9, v5)); + real2 v45 = reverse(minus(v33, v32)); + real2 v51 = plus(v32, v33); + store(out, 0 << shift, plus(v50, v51)); + store(out, 4 << shift, minus(v50, v51)); + store(out, 2 << shift, minus(uplusminus(v45), v46)); + store(out, 6 << shift, minus(uminusplus(v45), v46)); + real2 v31 = minusplus(uminus(v27), v28); + real2 v29 = minusplus(v27, v28); + real2 v43 = ctimesminusplus(reverse(v31), ctbl[0], ctimes(v31, ctbl[0])); + store(out, 7 << shift, minus(v25, v43)); + store(out, 3 << shift, plus(v25, v43)); + real2 v39 = ctimesminusplus(reverse(v29), ctbl[0], ctimes(v29, ctbl[1])); + store(out, 1 << shift, plus(v21, v39)); + store(out, 5 << shift, minus(v21, v39)); + } +} + +ALIGNED(8192) void but8f_%CONFIG%_%ISA%(real *RESTRICT out0, uint32_t *q, const int outShift, const real *RESTRICT in0, const int inShift, const real *RESTRICT tbl, const int K) { + const int k = 1 << (inShift - LOG2VECWIDTH); + int i=0; +#pragma omp parallel for + for(i=0;i < k;i++) { + int i0 = i << LOG2VECWIDTH; + real *out = out0 + q[i]; + const real *in = in0 + i0*2; + const int tbloffset = K * (i0 >> outShift); + + real2 v9 = load(in, 7 << inShift); + real2 v5 = load(in, 3 << inShift); + real2 v37 = plus(v5, v9); + real2 v31 = reverse(minus(v5, v9)); + real2 v7 = load(in, 5 << inShift); + real2 v3 = load(in, 1 << inShift); + real2 v36 = plus(v3, v7); + real2 v32 = minus(v7, v3); + real2 v57 = plus(v36, v37); + real2 v51 = reverse(minus(v36, v37)); + real2 v35 = minusplus(uminus(v31), v32); + real2 v33 = minusplus(v31, v32); + real2 v43 = ctimesminusplus(reverse(v33), tbl[6 + tbloffset], ctimes(v33, tbl[7 + tbloffset])); + real2 v6 = load(in, 4 << inShift); + real2 v2 = load(in, 0 << inShift); + real2 v16 = plus(v2, v6); + real2 v12 = minus(v6, v2); + real2 v8 = load(in, 6 << inShift); + real2 v4 = load(in, 2 << inShift); + real2 v17 = plus(v4, v8); + real2 v11 = reverse(minus(v4, v8)); + real2 v52 = minus(v17, v16); + real2 v56 = plus(v16, v17); + store(out, 0 << outShift, plus(v56, v57)); + real2 v70 = minus(v56, v57); + store(out, 4 << outShift, ctimesminusplus(v70, tbl[0 + tbloffset], ctimes(reverse(v70), tbl[1 + tbloffset]))); + real2 v53 = minusplus(v51, v52); + store(out, 2 << outShift, ctimesminusplus(reverse(v53), tbl[10 + tbloffset], ctimes(v53, tbl[11 + tbloffset]))); + real2 v55 = minusplus(uminus(v51), v52); + store(out, 6 << outShift, ctimesminusplus(reverse(v55), tbl[12 + tbloffset], ctimes(v55, tbl[13 + tbloffset]))); + real2 v15 = minusplus(uminus(v11), v12); + real2 v13 = minusplus(v11, v12); + real2 v23 = ctimesminusplus(reverse(v13), tbl[2 + tbloffset], ctimes(v13, tbl[3 + tbloffset])); + store(out, 1 << outShift, plus(v23, v43)); + real2 v78 = minus(v23, v43); + store(out, 5 << outShift, ctimesminusplus(v78, tbl[0 + tbloffset], ctimes(reverse(v78), tbl[1 + tbloffset]))); + real2 v49 = ctimesminusplus(reverse(v35), tbl[8 + tbloffset], ctimes(v35, tbl[9 + tbloffset])); + real2 v29 = ctimesminusplus(reverse(v15), tbl[4 + tbloffset], ctimes(v15, tbl[5 + tbloffset])); + store(out, 3 << outShift, plus(v29, v49)); + real2 v84 = minus(v29, v49); + store(out, 7 << outShift, ctimesminusplus(v84, tbl[0 + tbloffset], ctimes(reverse(v84), tbl[1 + tbloffset]))); + } +} + +ALIGNED(8192) void but8b_%CONFIG%_%ISA%(real *RESTRICT out0, uint32_t *q, const int outShift, const real *RESTRICT in0, const int inShift, const real *RESTRICT tbl, const int K) { + const int k = 1 << (inShift - LOG2VECWIDTH); + int i=0; +#pragma omp parallel for + for(i=0;i < k;i++) { + int i0 = i << LOG2VECWIDTH; + real *out = out0 + q[i]; + const real *in = in0 + i0*2; + const int tbloffset = K * (i0 >> outShift); + + real2 v9 = load(in, 7 << inShift); + real2 v5 = load(in, 3 << inShift); + real2 v37 = plus(v5, v9); + real2 v31 = reverse(minus(v9, v5)); + real2 v7 = load(in, 5 << inShift); + real2 v3 = load(in, 1 << inShift); + real2 v36 = plus(v3, v7); + real2 v32 = minus(v7, v3); + real2 v57 = plus(v36, v37); + real2 v51 = reverse(minus(v37, v36)); + real2 v35 = minusplus(uminus(v31), v32); + real2 v33 = minusplus(v31, v32); + real2 v43 = ctimesminusplus(reverse(v33), tbl[6 + tbloffset], ctimes(v33, tbl[7 + tbloffset])); + real2 v6 = load(in, 4 << inShift); + real2 v2 = load(in, 0 << inShift); + real2 v16 = plus(v2, v6); + real2 v12 = minus(v6, v2); + real2 v8 = load(in, 6 << inShift); + real2 v4 = load(in, 2 << inShift); + real2 v17 = plus(v4, v8); + real2 v11 = reverse(minus(v8, v4)); + real2 v52 = minus(v17, v16); + real2 v56 = plus(v16, v17); + store(out, 0 << outShift, plus(v56, v57)); + real2 v70 = minus(v56, v57); + store(out, 4 << outShift, ctimesminusplus(v70, tbl[0 + tbloffset], ctimes(reverse(v70), tbl[1 + tbloffset]))); + real2 v53 = minusplus(v51, v52); + store(out, 2 << outShift, ctimesminusplus(reverse(v53), tbl[10 + tbloffset], ctimes(v53, tbl[11 + tbloffset]))); + real2 v55 = minusplus(uminus(v51), v52); + store(out, 6 << outShift, ctimesminusplus(reverse(v55), tbl[12 + tbloffset], ctimes(v55, tbl[13 + tbloffset]))); + real2 v15 = minusplus(uminus(v11), v12); + real2 v13 = minusplus(v11, v12); + real2 v23 = ctimesminusplus(reverse(v13), tbl[2 + tbloffset], ctimes(v13, tbl[3 + tbloffset])); + store(out, 1 << outShift, plus(v23, v43)); + real2 v78 = minus(v23, v43); + store(out, 5 << outShift, ctimesminusplus(v78, tbl[0 + tbloffset], ctimes(reverse(v78), tbl[1 + tbloffset]))); + real2 v49 = ctimesminusplus(reverse(v35), tbl[8 + tbloffset], ctimes(v35, tbl[9 + tbloffset])); + real2 v29 = ctimesminusplus(reverse(v15), tbl[4 + tbloffset], ctimes(v15, tbl[5 + tbloffset])); + store(out, 3 << outShift, plus(v29, v49)); + real2 v84 = minus(v29, v49); + store(out, 7 << outShift, ctimesminusplus(v84, tbl[0 + tbloffset], ctimes(reverse(v84), tbl[1 + tbloffset]))); + } +} + +ALIGNED(8192) void tbut8f_%CONFIG%_%ISA%(real *RESTRICT out0, uint32_t *q, const real *RESTRICT in0, const int inShift, const real *RESTRICT tbl, const int K) { + const int k = 1 << (inShift - LOG2VECWIDTH); + int i=0; +#pragma omp parallel for + for(i=0;i < k;i++) { + int i0 = i << LOG2VECWIDTH; + real *out = out0 + q[i]; + const real *in = in0 + i0*2; + const int tbloffset = K * i0; + + real2 v9 = load(in, 7 << inShift); + real2 v5 = load(in, 3 << inShift); + real2 v37 = plus(v5, v9); + real2 v31 = reverse(minus(v5, v9)); + real2 v7 = load(in, 5 << inShift); + real2 v3 = load(in, 1 << inShift); + real2 v36 = plus(v3, v7); + real2 v32 = minus(v7, v3); + real2 v57 = plus(v36, v37); + real2 v51 = reverse(minus(v36, v37)); + real2 v35 = minusplus(uminus(v31), v32); + real2 v33 = minusplus(v31, v32); + real2 v43 = timesminusplus(reverse(v33), load(tbl, 6 * VECWIDTH + tbloffset), times(v33, load(tbl, 7 * VECWIDTH + tbloffset))); + real2 v6 = load(in, 4 << inShift); + real2 v2 = load(in, 0 << inShift); + real2 v16 = plus(v2, v6); + real2 v12 = minus(v6, v2); + real2 v8 = load(in, 6 << inShift); + real2 v4 = load(in, 2 << inShift); + real2 v17 = plus(v4, v8); + real2 v11 = reverse(minus(v4, v8)); + real2 v52 = minus(v17, v16); + real2 v56 = plus(v16, v17); + scatter(out, 0, 8, plus(v56, v57)); + real2 v70 = minus(v56, v57); + scatter(out, 4, 8, timesminusplus(v70, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v70), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v53 = minusplus(v51, v52); + scatter(out, 2, 8, timesminusplus(reverse(v53), load(tbl, 10 * VECWIDTH + tbloffset), times(v53, load(tbl, 11 * VECWIDTH + tbloffset)))); + real2 v55 = minusplus(uminus(v51), v52); + scatter(out, 6, 8, timesminusplus(reverse(v55), load(tbl, 12 * VECWIDTH + tbloffset), times(v55, load(tbl, 13 * VECWIDTH + tbloffset)))); + real2 v15 = minusplus(uminus(v11), v12); + real2 v13 = minusplus(v11, v12); + real2 v23 = timesminusplus(reverse(v13), load(tbl, 2 * VECWIDTH + tbloffset), times(v13, load(tbl, 3 * VECWIDTH + tbloffset))); + scatter(out, 1, 8, plus(v23, v43)); + real2 v78 = minus(v23, v43); + scatter(out, 5, 8, timesminusplus(v78, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v78), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v49 = timesminusplus(reverse(v35), load(tbl, 8 * VECWIDTH + tbloffset), times(v35, load(tbl, 9 * VECWIDTH + tbloffset))); + real2 v29 = timesminusplus(reverse(v15), load(tbl, 4 * VECWIDTH + tbloffset), times(v15, load(tbl, 5 * VECWIDTH + tbloffset))); + scatter(out, 3, 8, plus(v29, v49)); + real2 v84 = minus(v29, v49); + scatter(out, 7, 8, timesminusplus(v84, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v84), load(tbl, 1 * VECWIDTH + tbloffset)))); + } +} + +ALIGNED(8192) void tbut8b_%CONFIG%_%ISA%(real *RESTRICT out0, uint32_t *q, const real *RESTRICT in0, const int inShift, const real *RESTRICT tbl, const int K) { + const int k = 1 << (inShift - LOG2VECWIDTH); + int i=0; +#pragma omp parallel for + for(i=0;i < k;i++) { + int i0 = i << LOG2VECWIDTH; + real *out = out0 + q[i]; + const real *in = in0 + i0*2; + const int tbloffset = K * i0; + + real2 v9 = load(in, 7 << inShift); + real2 v5 = load(in, 3 << inShift); + real2 v37 = plus(v5, v9); + real2 v31 = reverse(minus(v9, v5)); + real2 v7 = load(in, 5 << inShift); + real2 v3 = load(in, 1 << inShift); + real2 v36 = plus(v3, v7); + real2 v32 = minus(v7, v3); + real2 v57 = plus(v36, v37); + real2 v51 = reverse(minus(v37, v36)); + real2 v35 = minusplus(uminus(v31), v32); + real2 v33 = minusplus(v31, v32); + real2 v43 = timesminusplus(reverse(v33), load(tbl, 6 * VECWIDTH + tbloffset), times(v33, load(tbl, 7 * VECWIDTH + tbloffset))); + real2 v6 = load(in, 4 << inShift); + real2 v2 = load(in, 0 << inShift); + real2 v16 = plus(v2, v6); + real2 v12 = minus(v6, v2); + real2 v8 = load(in, 6 << inShift); + real2 v4 = load(in, 2 << inShift); + real2 v17 = plus(v4, v8); + real2 v11 = reverse(minus(v8, v4)); + real2 v52 = minus(v17, v16); + real2 v56 = plus(v16, v17); + scatter(out, 0, 8, plus(v56, v57)); + real2 v70 = minus(v56, v57); + scatter(out, 4, 8, timesminusplus(v70, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v70), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v53 = minusplus(v51, v52); + scatter(out, 2, 8, timesminusplus(reverse(v53), load(tbl, 10 * VECWIDTH + tbloffset), times(v53, load(tbl, 11 * VECWIDTH + tbloffset)))); + real2 v55 = minusplus(uminus(v51), v52); + scatter(out, 6, 8, timesminusplus(reverse(v55), load(tbl, 12 * VECWIDTH + tbloffset), times(v55, load(tbl, 13 * VECWIDTH + tbloffset)))); + real2 v15 = minusplus(uminus(v11), v12); + real2 v13 = minusplus(v11, v12); + real2 v23 = timesminusplus(reverse(v13), load(tbl, 2 * VECWIDTH + tbloffset), times(v13, load(tbl, 3 * VECWIDTH + tbloffset))); + scatter(out, 1, 8, plus(v23, v43)); + real2 v78 = minus(v23, v43); + scatter(out, 5, 8, timesminusplus(v78, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v78), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v49 = timesminusplus(reverse(v35), load(tbl, 8 * VECWIDTH + tbloffset), times(v35, load(tbl, 9 * VECWIDTH + tbloffset))); + real2 v29 = timesminusplus(reverse(v15), load(tbl, 4 * VECWIDTH + tbloffset), times(v15, load(tbl, 5 * VECWIDTH + tbloffset))); + scatter(out, 3, 8, plus(v29, v49)); + real2 v84 = minus(v29, v49); + scatter(out, 7, 8, timesminusplus(v84, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v84), load(tbl, 1 * VECWIDTH + tbloffset)))); + } +} +#endif + +#if MAXBUTWIDTH >= 4 +ALIGNED(8192) void dft16f_%CONFIG%_%ISA%(real *RESTRICT out0, const real *RESTRICT in0, const int shift) { + const int k = 1 << (shift - LOG2VECWIDTH); + int i=0; +#pragma omp parallel for + for(i=0;i < k;i++) { + int i0 = i << LOG2VECWIDTH; + real *out = out0 + i0*2; + const real *in = in0 + i0*2; + + real2 v11 = load(in, 9 << shift); + real2 v3 = load(in, 1 << shift); + real2 v40 = plus(v3, v11); + real2 v36 = minus(v11, v3); + real2 v15 = load(in, 13 << shift); + real2 v7 = load(in, 5 << shift); + real2 v35 = reverse(minus(v7, v15)); + real2 v41 = plus(v7, v15); + real2 v106 = minus(v41, v40); + real2 v110 = plus(v40, v41); + real2 v37 = minusplus(v35, v36); + real2 v39 = minusplus(uminus(v35), v36); + real2 v51 = ctimesminusplus(reverse(v39), ctbl[5], ctimes(v39, ctbl[3])); + real2 v47 = ctimesminusplus(reverse(v37), ctbl[3], ctimes(v37, ctbl[5])); + real2 v13 = load(in, 11 << shift); + real2 v5 = load(in, 3 << shift); + real2 v72 = minus(v13, v5); + real2 v76 = plus(v5, v13); + real2 v17 = load(in, 15 << shift); + real2 v9 = load(in, 7 << shift); + real2 v77 = plus(v9, v17); + real2 v71 = reverse(minus(v9, v17)); + real2 v105 = reverse(minus(v76, v77)); + real2 v111 = plus(v76, v77); + real2 v107 = minusplus(v105, v106); + real2 v109 = minusplus(uminus(v105), v106); + real2 v121 = reverse(minus(v110, v111)); + real2 v127 = plus(v110, v111); + real2 v119 = ctimesminusplus(reverse(v109), ctbl[1], ctimes(v109, ctbl[0])); + real2 v115 = ctimesminusplus(reverse(v107), ctbl[1], ctimes(v107, ctbl[1])); + real2 v8 = load(in, 6 << shift); + real2 v16 = load(in, 14 << shift); + real2 v53 = reverse(minus(v8, v16)); + real2 v59 = plus(v8, v16); + real2 v4 = load(in, 2 << shift); + real2 v12 = load(in, 10 << shift); + real2 v54 = minus(v12, v4); + real2 v58 = plus(v4, v12); + real2 v95 = plus(v58, v59); + real2 v89 = reverse(minus(v58, v59)); + real2 v2 = load(in, 0 << shift); + real2 v10 = load(in, 8 << shift); + real2 v24 = plus(v2, v10); + real2 v20 = minus(v10, v2); + real2 v6 = load(in, 4 << shift); + real2 v14 = load(in, 12 << shift); + real2 v19 = reverse(minus(v6, v14)); + real2 v25 = plus(v6, v14); + real2 v94 = plus(v24, v25); + real2 v90 = minus(v25, v24); + real2 v103 = minus(uminusplus(v89), v90); + real2 v99 = minus(uplusminus(v89), v90); + store(out, 2 << shift, plus(v99, v115)); + store(out, 10 << shift, minus(v99, v115)); + store(out, 6 << shift, plus(v103, v119)); + store(out, 14 << shift, minus(v103, v119)); + real2 v122 = minus(v95, v94); + store(out, 12 << shift, minus(uminusplus(v121), v122)); + store(out, 4 << shift, minus(uplusminus(v121), v122)); + real2 v126 = plus(v94, v95); + store(out, 8 << shift, minus(v126, v127)); + store(out, 0 << shift, plus(v126, v127)); + real2 v57 = minusplus(uminus(v53), v54); + real2 v55 = minusplus(v53, v54); + real2 v64 = ctimesminusplus(reverse(v55), ctbl[1], ctimes(v55, ctbl[1])); + real2 v75 = minusplus(uminus(v71), v72); + real2 v73 = minusplus(v71, v72); + real2 v81 = ctimesminusplus(reverse(v73), ctbl[5], ctimes(v73, ctbl[3])); + real2 v29 = minus(uplusminus(v19), v20); + real2 v33 = minus(uminusplus(v19), v20); + real2 v151 = plus(v29, v64); + real2 v147 = minus(v64, v29); + real2 v152 = plus(v47, v81); + real2 v146 = reverse(minus(v47, v81)); + store(out, 13 << shift, minus(uminusplus(v146), v147)); + store(out, 5 << shift, minus(uplusminus(v146), v147)); + store(out, 9 << shift, minus(v151, v152)); + store(out, 1 << shift, plus(v151, v152)); + real2 v69 = ctimesminusplus(reverse(v57), ctbl[1], ctimes(v57, ctbl[0])); + real2 v87 = ctimesminusplus(reverse(v75), ctbl[4], ctimes(v75, ctbl[2])); + real2 v171 = plus(v51, v87); + real2 v165 = reverse(minus(v51, v87)); + real2 v170 = plus(v33, v69); + real2 v166 = minus(v69, v33); + store(out, 7 << shift, minus(uplusminus(v165), v166)); + store(out, 15 << shift, minus(uminusplus(v165), v166)); + store(out, 11 << shift, minus(v170, v171)); + store(out, 3 << shift, plus(v170, v171)); + } +} + +ALIGNED(8192) void dft16b_%CONFIG%_%ISA%(real *RESTRICT out0, const real *RESTRICT in0, const int shift) { + const int k = 1 << (shift - LOG2VECWIDTH); + int i=0; +#pragma omp parallel for + for(i=0;i < k;i++) { + int i0 = i << LOG2VECWIDTH; + real *out = out0 + i0*2; + const real *in = in0 + i0*2; + + real2 v9 = load(in, 7 << shift); + real2 v17 = load(in, 15 << shift); + real2 v79 = plus(v9, v17); + real2 v73 = reverse(minus(v17, v9)); + real2 v13 = load(in, 11 << shift); + real2 v5 = load(in, 3 << shift); + real2 v78 = plus(v5, v13); + real2 v74 = minus(v13, v5); + real2 v105 = reverse(minus(v79, v78)); + real2 v111 = plus(v78, v79); + real2 v75 = minusplus(v73, v74); + real2 v77 = minusplus(uminus(v73), v74); + real2 v83 = ctimesminusplus(reverse(v75), ctbl[2], ctimes(v75, ctbl[3])); + real2 v7 = load(in, 5 << shift); + real2 v15 = load(in, 13 << shift); + real2 v41 = plus(v7, v15); + real2 v35 = reverse(minus(v15, v7)); + real2 v11 = load(in, 9 << shift); + real2 v3 = load(in, 1 << shift); + real2 v40 = plus(v3, v11); + real2 v36 = minus(v11, v3); + real2 v110 = plus(v40, v41); + real2 v106 = minus(v41, v40); + real2 v121 = reverse(minus(v111, v110)); + real2 v127 = plus(v110, v111); + real2 v109 = minusplus(uminus(v105), v106); + real2 v107 = minusplus(v105, v106); + real2 v119 = ctimesminusplus(reverse(v109), ctbl[0], ctimes(v109, ctbl[0])); + real2 v115 = ctimesminusplus(reverse(v107), ctbl[0], ctimes(v107, ctbl[1])); + real2 v16 = load(in, 14 << shift); + real2 v8 = load(in, 6 << shift); + real2 v55 = reverse(minus(v16, v8)); + real2 v61 = plus(v8, v16); + real2 v12 = load(in, 10 << shift); + real2 v4 = load(in, 2 << shift); + real2 v56 = minus(v12, v4); + real2 v60 = plus(v4, v12); + real2 v89 = reverse(minus(v61, v60)); + real2 v95 = plus(v60, v61); + real2 v14 = load(in, 12 << shift); + real2 v6 = load(in, 4 << shift); + real2 v19 = reverse(minus(v14, v6)); + real2 v25 = plus(v6, v14); + real2 v2 = load(in, 0 << shift); + real2 v10 = load(in, 8 << shift); + real2 v24 = plus(v2, v10); + real2 v20 = minus(v10, v2); + real2 v90 = minus(v25, v24); + real2 v94 = plus(v24, v25); + real2 v103 = minus(uminusplus(v89), v90); + store(out, 6 << shift, plus(v103, v119)); + store(out, 14 << shift, minus(v103, v119)); + real2 v99 = minus(uplusminus(v89), v90); + store(out, 10 << shift, minus(v99, v115)); + store(out, 2 << shift, plus(v99, v115)); + real2 v126 = plus(v94, v95); + store(out, 8 << shift, minus(v126, v127)); + store(out, 0 << shift, plus(v126, v127)); + real2 v122 = minus(v95, v94); + store(out, 12 << shift, minus(uminusplus(v121), v122)); + store(out, 4 << shift, minus(uplusminus(v121), v122)); + real2 v33 = minus(uminusplus(v19), v20); + real2 v29 = minus(uplusminus(v19), v20); + real2 v59 = minusplus(uminus(v55), v56); + real2 v57 = minusplus(v55, v56); + real2 v67 = ctimesminusplus(reverse(v57), ctbl[0], ctimes(v57, ctbl[1])); + real2 v39 = minusplus(uminus(v35), v36); + real2 v37 = minusplus(v35, v36); + real2 v47 = ctimesminusplus(reverse(v37), ctbl[4], ctimes(v37, ctbl[5])); + real2 v146 = reverse(minus(v83, v47)); + real2 v152 = plus(v47, v83); + real2 v147 = minus(v67, v29); + real2 v151 = plus(v29, v67); + store(out, 9 << shift, minus(v151, v152)); + store(out, 1 << shift, plus(v151, v152)); + store(out, 5 << shift, minus(uplusminus(v146), v147)); + store(out, 13 << shift, minus(uminusplus(v146), v147)); + real2 v53 = ctimesminusplus(reverse(v39), ctbl[2], ctimes(v39, ctbl[3])); + real2 v71 = ctimesminusplus(reverse(v59), ctbl[0], ctimes(v59, ctbl[0])); + real2 v166 = minus(v71, v33); + real2 v170 = plus(v33, v71); + real2 v87 = ctimesminusplus(reverse(v77), ctbl[3], ctimes(v77, ctbl[2])); + real2 v165 = reverse(minus(v87, v53)); + store(out, 15 << shift, minus(uminusplus(v165), v166)); + store(out, 7 << shift, minus(uplusminus(v165), v166)); + real2 v171 = plus(v53, v87); + store(out, 3 << shift, plus(v170, v171)); + store(out, 11 << shift, minus(v170, v171)); + } +} + +ALIGNED(8192) void but16f_%CONFIG%_%ISA%(real *RESTRICT out0, uint32_t *q, const int outShift, const real *RESTRICT in0, const int inShift, const real *RESTRICT tbl, const int K) { + const int k = 1 << (inShift - LOG2VECWIDTH); + int i=0; +#pragma omp parallel for + for(i=0;i < k;i++) { + int i0 = i << LOG2VECWIDTH; + real *out = out0 + q[i]; + const real *in = in0 + i0*2; + const int tbloffset = K * (i0 >> outShift); + + real2 v15 = load(in, 13 << inShift); + real2 v7 = load(in, 5 << inShift); + real2 v45 = plus(v7, v15); + real2 v39 = reverse(minus(v7, v15)); + real2 v3 = load(in, 1 << inShift); + real2 v11 = load(in, 9 << inShift); + real2 v40 = minus(v11, v3); + real2 v44 = plus(v3, v11); + real2 v124 = plus(v44, v45); + real2 v120 = minus(v45, v44); + real2 v41 = minusplus(v39, v40); + real2 v43 = minusplus(uminus(v39), v40); + real2 v57 = ctimesminusplus(reverse(v43), tbl[8 + tbloffset], ctimes(v43, tbl[9 + tbloffset])); + real2 v13 = load(in, 11 << inShift); + real2 v5 = load(in, 3 << inShift); + real2 v84 = plus(v5, v13); + real2 v80 = minus(v13, v5); + real2 v17 = load(in, 15 << inShift); + real2 v9 = load(in, 7 << inShift); + real2 v85 = plus(v9, v17); + real2 v79 = reverse(minus(v9, v17)); + real2 v119 = reverse(minus(v84, v85)); + real2 v125 = plus(v84, v85); + real2 v145 = plus(v124, v125); + real2 v139 = reverse(minus(v124, v125)); + real2 v121 = minusplus(v119, v120); + real2 v123 = minusplus(uminus(v119), v120); + real2 v137 = ctimesminusplus(reverse(v123), tbl[24 + tbloffset], ctimes(v123, tbl[25 + tbloffset])); + real2 v131 = ctimesminusplus(reverse(v121), tbl[22 + tbloffset], ctimes(v121, tbl[23 + tbloffset])); + real2 v4 = load(in, 2 << inShift); + real2 v12 = load(in, 10 << inShift); + real2 v64 = plus(v4, v12); + real2 v60 = minus(v12, v4); + real2 v8 = load(in, 6 << inShift); + real2 v16 = load(in, 14 << inShift); + real2 v65 = plus(v8, v16); + real2 v59 = reverse(minus(v8, v16)); + real2 v99 = reverse(minus(v64, v65)); + real2 v105 = plus(v64, v65); + real2 v14 = load(in, 12 << inShift); + real2 v6 = load(in, 4 << inShift); + real2 v25 = plus(v6, v14); + real2 v19 = reverse(minus(v6, v14)); + real2 v10 = load(in, 8 << inShift); + real2 v2 = load(in, 0 << inShift); + real2 v20 = minus(v10, v2); + real2 v24 = plus(v2, v10); + real2 v104 = plus(v24, v25); + real2 v100 = minus(v25, v24); + real2 v140 = minus(v105, v104); + real2 v144 = plus(v104, v105); + store(out, 0 << outShift, plus(v144, v145)); + real2 v158 = minus(v144, v145); + store(out, 8 << outShift, ctimesminusplus(v158, tbl[0 + tbloffset], ctimes(reverse(v158), tbl[1 + tbloffset]))); + real2 v143 = minusplus(uminus(v139), v140); + store(out, 12 << outShift, ctimesminusplus(reverse(v143), tbl[28 + tbloffset], ctimes(v143, tbl[29 + tbloffset]))); + real2 v141 = minusplus(v139, v140); + store(out, 4 << outShift, ctimesminusplus(reverse(v141), tbl[26 + tbloffset], ctimes(v141, tbl[27 + tbloffset]))); + real2 v101 = minusplus(v99, v100); + real2 v103 = minusplus(uminus(v99), v100); + real2 v117 = ctimesminusplus(reverse(v103), tbl[20 + tbloffset], ctimes(v103, tbl[21 + tbloffset])); + store(out, 6 << outShift, plus(v117, v137)); + real2 v172 = minus(v117, v137); + store(out, 14 << outShift, ctimesminusplus(v172, tbl[0 + tbloffset], ctimes(reverse(v172), tbl[1 + tbloffset]))); + real2 v111 = ctimesminusplus(reverse(v101), tbl[18 + tbloffset], ctimes(v101, tbl[19 + tbloffset])); + store(out, 2 << outShift, plus(v111, v131)); + real2 v166 = minus(v111, v131); + store(out, 10 << outShift, ctimesminusplus(v166, tbl[0 + tbloffset], ctimes(reverse(v166), tbl[1 + tbloffset]))); + real2 v23 = minusplus(uminus(v19), v20); + real2 v21 = minusplus(v19, v20); + real2 v81 = minusplus(v79, v80); + real2 v83 = minusplus(uminus(v79), v80); + real2 v97 = ctimesminusplus(reverse(v83), tbl[16 + tbloffset], ctimes(v83, tbl[17 + tbloffset])); + real2 v211 = plus(v57, v97); + real2 v205 = reverse(minus(v57, v97)); + real2 v61 = minusplus(v59, v60); + real2 v63 = minusplus(uminus(v59), v60); + real2 v77 = ctimesminusplus(reverse(v63), tbl[12 + tbloffset], ctimes(v63, tbl[13 + tbloffset])); + real2 v37 = ctimesminusplus(reverse(v23), tbl[4 + tbloffset], ctimes(v23, tbl[5 + tbloffset])); + real2 v210 = plus(v37, v77); + real2 v206 = minus(v77, v37); + store(out, 3 << outShift, plus(v210, v211)); + real2 v224 = minus(v210, v211); + store(out, 11 << outShift, ctimesminusplus(v224, tbl[0 + tbloffset], ctimes(reverse(v224), tbl[1 + tbloffset]))); + real2 v207 = minusplus(v205, v206); + real2 v209 = minusplus(uminus(v205), v206); + store(out, 15 << outShift, ctimesminusplus(reverse(v209), tbl[36 + tbloffset], ctimes(v209, tbl[37 + tbloffset]))); + store(out, 7 << outShift, ctimesminusplus(reverse(v207), tbl[34 + tbloffset], ctimes(v207, tbl[35 + tbloffset]))); + real2 v71 = ctimesminusplus(reverse(v61), tbl[10 + tbloffset], ctimes(v61, tbl[11 + tbloffset])); + real2 v51 = ctimesminusplus(reverse(v41), tbl[6 + tbloffset], ctimes(v41, tbl[7 + tbloffset])); + real2 v91 = ctimesminusplus(reverse(v81), tbl[14 + tbloffset], ctimes(v81, tbl[15 + tbloffset])); + real2 v185 = plus(v51, v91); + real2 v179 = reverse(minus(v51, v91)); + real2 v31 = ctimesminusplus(reverse(v21), tbl[2 + tbloffset], ctimes(v21, tbl[3 + tbloffset])); + real2 v184 = plus(v31, v71); + real2 v180 = minus(v71, v31); + store(out, 1 << outShift, plus(v184, v185)); + real2 v198 = minus(v184, v185); + store(out, 9 << outShift, ctimesminusplus(v198, tbl[0 + tbloffset], ctimes(reverse(v198), tbl[1 + tbloffset]))); + real2 v181 = minusplus(v179, v180); + store(out, 5 << outShift, ctimesminusplus(reverse(v181), tbl[30 + tbloffset], ctimes(v181, tbl[31 + tbloffset]))); + real2 v183 = minusplus(uminus(v179), v180); + store(out, 13 << outShift, ctimesminusplus(reverse(v183), tbl[32 + tbloffset], ctimes(v183, tbl[33 + tbloffset]))); + } +} + +ALIGNED(8192) void but16b_%CONFIG%_%ISA%(real *RESTRICT out0, uint32_t *q, const int outShift, const real *RESTRICT in0, const int inShift, const real *RESTRICT tbl, const int K) { + const int k = 1 << (inShift - LOG2VECWIDTH); + int i=0; +#pragma omp parallel for + for(i=0;i < k;i++) { + int i0 = i << LOG2VECWIDTH; + real *out = out0 + q[i]; + const real *in = in0 + i0*2; + const int tbloffset = K * (i0 >> outShift); + + real2 v15 = load(in, 13 << inShift); + real2 v7 = load(in, 5 << inShift); + real2 v45 = plus(v7, v15); + real2 v39 = reverse(minus(v15, v7)); + real2 v3 = load(in, 1 << inShift); + real2 v11 = load(in, 9 << inShift); + real2 v40 = minus(v11, v3); + real2 v44 = plus(v3, v11); + real2 v124 = plus(v44, v45); + real2 v120 = minus(v45, v44); + real2 v41 = minusplus(v39, v40); + real2 v43 = minusplus(uminus(v39), v40); + real2 v57 = ctimesminusplus(reverse(v43), tbl[8 + tbloffset], ctimes(v43, tbl[9 + tbloffset])); + real2 v13 = load(in, 11 << inShift); + real2 v5 = load(in, 3 << inShift); + real2 v84 = plus(v5, v13); + real2 v80 = minus(v13, v5); + real2 v17 = load(in, 15 << inShift); + real2 v9 = load(in, 7 << inShift); + real2 v85 = plus(v9, v17); + real2 v79 = reverse(minus(v17, v9)); + real2 v119 = reverse(minus(v85, v84)); + real2 v125 = plus(v84, v85); + real2 v145 = plus(v124, v125); + real2 v139 = reverse(minus(v125, v124)); + real2 v121 = minusplus(v119, v120); + real2 v123 = minusplus(uminus(v119), v120); + real2 v137 = ctimesminusplus(reverse(v123), tbl[24 + tbloffset], ctimes(v123, tbl[25 + tbloffset])); + real2 v131 = ctimesminusplus(reverse(v121), tbl[22 + tbloffset], ctimes(v121, tbl[23 + tbloffset])); + real2 v4 = load(in, 2 << inShift); + real2 v12 = load(in, 10 << inShift); + real2 v64 = plus(v4, v12); + real2 v60 = minus(v12, v4); + real2 v8 = load(in, 6 << inShift); + real2 v16 = load(in, 14 << inShift); + real2 v65 = plus(v8, v16); + real2 v59 = reverse(minus(v16, v8)); + real2 v99 = reverse(minus(v65, v64)); + real2 v105 = plus(v64, v65); + real2 v14 = load(in, 12 << inShift); + real2 v6 = load(in, 4 << inShift); + real2 v25 = plus(v6, v14); + real2 v19 = reverse(minus(v14, v6)); + real2 v10 = load(in, 8 << inShift); + real2 v2 = load(in, 0 << inShift); + real2 v20 = minus(v10, v2); + real2 v24 = plus(v2, v10); + real2 v104 = plus(v24, v25); + real2 v100 = minus(v25, v24); + real2 v140 = minus(v105, v104); + real2 v144 = plus(v104, v105); + store(out, 0 << outShift, plus(v144, v145)); + real2 v158 = minus(v144, v145); + store(out, 8 << outShift, ctimesminusplus(v158, tbl[0 + tbloffset], ctimes(reverse(v158), tbl[1 + tbloffset]))); + real2 v143 = minusplus(uminus(v139), v140); + store(out, 12 << outShift, ctimesminusplus(reverse(v143), tbl[28 + tbloffset], ctimes(v143, tbl[29 + tbloffset]))); + real2 v141 = minusplus(v139, v140); + store(out, 4 << outShift, ctimesminusplus(reverse(v141), tbl[26 + tbloffset], ctimes(v141, tbl[27 + tbloffset]))); + real2 v101 = minusplus(v99, v100); + real2 v103 = minusplus(uminus(v99), v100); + real2 v117 = ctimesminusplus(reverse(v103), tbl[20 + tbloffset], ctimes(v103, tbl[21 + tbloffset])); + store(out, 6 << outShift, plus(v117, v137)); + real2 v172 = minus(v117, v137); + store(out, 14 << outShift, ctimesminusplus(v172, tbl[0 + tbloffset], ctimes(reverse(v172), tbl[1 + tbloffset]))); + real2 v111 = ctimesminusplus(reverse(v101), tbl[18 + tbloffset], ctimes(v101, tbl[19 + tbloffset])); + store(out, 2 << outShift, plus(v111, v131)); + real2 v166 = minus(v111, v131); + store(out, 10 << outShift, ctimesminusplus(v166, tbl[0 + tbloffset], ctimes(reverse(v166), tbl[1 + tbloffset]))); + real2 v23 = minusplus(uminus(v19), v20); + real2 v21 = minusplus(v19, v20); + real2 v81 = minusplus(v79, v80); + real2 v83 = minusplus(uminus(v79), v80); + real2 v97 = ctimesminusplus(reverse(v83), tbl[16 + tbloffset], ctimes(v83, tbl[17 + tbloffset])); + real2 v211 = plus(v57, v97); + real2 v205 = reverse(minus(v97, v57)); + real2 v61 = minusplus(v59, v60); + real2 v63 = minusplus(uminus(v59), v60); + real2 v77 = ctimesminusplus(reverse(v63), tbl[12 + tbloffset], ctimes(v63, tbl[13 + tbloffset])); + real2 v37 = ctimesminusplus(reverse(v23), tbl[4 + tbloffset], ctimes(v23, tbl[5 + tbloffset])); + real2 v210 = plus(v37, v77); + real2 v206 = minus(v77, v37); + store(out, 3 << outShift, plus(v210, v211)); + real2 v224 = minus(v210, v211); + store(out, 11 << outShift, ctimesminusplus(v224, tbl[0 + tbloffset], ctimes(reverse(v224), tbl[1 + tbloffset]))); + real2 v207 = minusplus(v205, v206); + real2 v209 = minusplus(uminus(v205), v206); + store(out, 15 << outShift, ctimesminusplus(reverse(v209), tbl[36 + tbloffset], ctimes(v209, tbl[37 + tbloffset]))); + store(out, 7 << outShift, ctimesminusplus(reverse(v207), tbl[34 + tbloffset], ctimes(v207, tbl[35 + tbloffset]))); + real2 v71 = ctimesminusplus(reverse(v61), tbl[10 + tbloffset], ctimes(v61, tbl[11 + tbloffset])); + real2 v51 = ctimesminusplus(reverse(v41), tbl[6 + tbloffset], ctimes(v41, tbl[7 + tbloffset])); + real2 v91 = ctimesminusplus(reverse(v81), tbl[14 + tbloffset], ctimes(v81, tbl[15 + tbloffset])); + real2 v185 = plus(v51, v91); + real2 v179 = reverse(minus(v91, v51)); + real2 v31 = ctimesminusplus(reverse(v21), tbl[2 + tbloffset], ctimes(v21, tbl[3 + tbloffset])); + real2 v184 = plus(v31, v71); + real2 v180 = minus(v71, v31); + store(out, 1 << outShift, plus(v184, v185)); + real2 v198 = minus(v184, v185); + store(out, 9 << outShift, ctimesminusplus(v198, tbl[0 + tbloffset], ctimes(reverse(v198), tbl[1 + tbloffset]))); + real2 v181 = minusplus(v179, v180); + store(out, 5 << outShift, ctimesminusplus(reverse(v181), tbl[30 + tbloffset], ctimes(v181, tbl[31 + tbloffset]))); + real2 v183 = minusplus(uminus(v179), v180); + store(out, 13 << outShift, ctimesminusplus(reverse(v183), tbl[32 + tbloffset], ctimes(v183, tbl[33 + tbloffset]))); + } +} + +ALIGNED(8192) void tbut16f_%CONFIG%_%ISA%(real *RESTRICT out0, uint32_t *q, const real *RESTRICT in0, const int inShift, const real *RESTRICT tbl, const int K) { + const int k = 1 << (inShift - LOG2VECWIDTH); + int i=0; +#pragma omp parallel for + for(i=0;i < k;i++) { + int i0 = i << LOG2VECWIDTH; + real *out = out0 + q[i]; + const real *in = in0 + i0*2; + const int tbloffset = K * i0; + + real2 v15 = load(in, 13 << inShift); + real2 v7 = load(in, 5 << inShift); + real2 v45 = plus(v7, v15); + real2 v39 = reverse(minus(v7, v15)); + real2 v3 = load(in, 1 << inShift); + real2 v11 = load(in, 9 << inShift); + real2 v40 = minus(v11, v3); + real2 v44 = plus(v3, v11); + real2 v124 = plus(v44, v45); + real2 v120 = minus(v45, v44); + real2 v41 = minusplus(v39, v40); + real2 v43 = minusplus(uminus(v39), v40); + real2 v57 = timesminusplus(reverse(v43), load(tbl, 8 * VECWIDTH + tbloffset), times(v43, load(tbl, 9 * VECWIDTH + tbloffset))); + real2 v13 = load(in, 11 << inShift); + real2 v5 = load(in, 3 << inShift); + real2 v84 = plus(v5, v13); + real2 v80 = minus(v13, v5); + real2 v17 = load(in, 15 << inShift); + real2 v9 = load(in, 7 << inShift); + real2 v85 = plus(v9, v17); + real2 v79 = reverse(minus(v9, v17)); + real2 v119 = reverse(minus(v84, v85)); + real2 v125 = plus(v84, v85); + real2 v145 = plus(v124, v125); + real2 v139 = reverse(minus(v124, v125)); + real2 v121 = minusplus(v119, v120); + real2 v123 = minusplus(uminus(v119), v120); + real2 v137 = timesminusplus(reverse(v123), load(tbl, 24 * VECWIDTH + tbloffset), times(v123, load(tbl, 25 * VECWIDTH + tbloffset))); + real2 v131 = timesminusplus(reverse(v121), load(tbl, 22 * VECWIDTH + tbloffset), times(v121, load(tbl, 23 * VECWIDTH + tbloffset))); + real2 v4 = load(in, 2 << inShift); + real2 v12 = load(in, 10 << inShift); + real2 v64 = plus(v4, v12); + real2 v60 = minus(v12, v4); + real2 v8 = load(in, 6 << inShift); + real2 v16 = load(in, 14 << inShift); + real2 v65 = plus(v8, v16); + real2 v59 = reverse(minus(v8, v16)); + real2 v99 = reverse(minus(v64, v65)); + real2 v105 = plus(v64, v65); + real2 v14 = load(in, 12 << inShift); + real2 v6 = load(in, 4 << inShift); + real2 v25 = plus(v6, v14); + real2 v19 = reverse(minus(v6, v14)); + real2 v10 = load(in, 8 << inShift); + real2 v2 = load(in, 0 << inShift); + real2 v20 = minus(v10, v2); + real2 v24 = plus(v2, v10); + real2 v104 = plus(v24, v25); + real2 v100 = minus(v25, v24); + real2 v140 = minus(v105, v104); + real2 v144 = plus(v104, v105); + scatter(out, 0, 16, plus(v144, v145)); + real2 v158 = minus(v144, v145); + scatter(out, 8, 16, timesminusplus(v158, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v158), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v143 = minusplus(uminus(v139), v140); + scatter(out, 12, 16, timesminusplus(reverse(v143), load(tbl, 28 * VECWIDTH + tbloffset), times(v143, load(tbl, 29 * VECWIDTH + tbloffset)))); + real2 v141 = minusplus(v139, v140); + scatter(out, 4, 16, timesminusplus(reverse(v141), load(tbl, 26 * VECWIDTH + tbloffset), times(v141, load(tbl, 27 * VECWIDTH + tbloffset)))); + real2 v101 = minusplus(v99, v100); + real2 v103 = minusplus(uminus(v99), v100); + real2 v117 = timesminusplus(reverse(v103), load(tbl, 20 * VECWIDTH + tbloffset), times(v103, load(tbl, 21 * VECWIDTH + tbloffset))); + scatter(out, 6, 16, plus(v117, v137)); + real2 v172 = minus(v117, v137); + scatter(out, 14, 16, timesminusplus(v172, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v172), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v111 = timesminusplus(reverse(v101), load(tbl, 18 * VECWIDTH + tbloffset), times(v101, load(tbl, 19 * VECWIDTH + tbloffset))); + scatter(out, 2, 16, plus(v111, v131)); + real2 v166 = minus(v111, v131); + scatter(out, 10, 16, timesminusplus(v166, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v166), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v23 = minusplus(uminus(v19), v20); + real2 v21 = minusplus(v19, v20); + real2 v81 = minusplus(v79, v80); + real2 v83 = minusplus(uminus(v79), v80); + real2 v97 = timesminusplus(reverse(v83), load(tbl, 16 * VECWIDTH + tbloffset), times(v83, load(tbl, 17 * VECWIDTH + tbloffset))); + real2 v211 = plus(v57, v97); + real2 v205 = reverse(minus(v57, v97)); + real2 v61 = minusplus(v59, v60); + real2 v63 = minusplus(uminus(v59), v60); + real2 v77 = timesminusplus(reverse(v63), load(tbl, 12 * VECWIDTH + tbloffset), times(v63, load(tbl, 13 * VECWIDTH + tbloffset))); + real2 v37 = timesminusplus(reverse(v23), load(tbl, 4 * VECWIDTH + tbloffset), times(v23, load(tbl, 5 * VECWIDTH + tbloffset))); + real2 v210 = plus(v37, v77); + real2 v206 = minus(v77, v37); + scatter(out, 3, 16, plus(v210, v211)); + real2 v224 = minus(v210, v211); + scatter(out, 11, 16, timesminusplus(v224, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v224), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v207 = minusplus(v205, v206); + real2 v209 = minusplus(uminus(v205), v206); + scatter(out, 15, 16, timesminusplus(reverse(v209), load(tbl, 36 * VECWIDTH + tbloffset), times(v209, load(tbl, 37 * VECWIDTH + tbloffset)))); + scatter(out, 7, 16, timesminusplus(reverse(v207), load(tbl, 34 * VECWIDTH + tbloffset), times(v207, load(tbl, 35 * VECWIDTH + tbloffset)))); + real2 v71 = timesminusplus(reverse(v61), load(tbl, 10 * VECWIDTH + tbloffset), times(v61, load(tbl, 11 * VECWIDTH + tbloffset))); + real2 v51 = timesminusplus(reverse(v41), load(tbl, 6 * VECWIDTH + tbloffset), times(v41, load(tbl, 7 * VECWIDTH + tbloffset))); + real2 v91 = timesminusplus(reverse(v81), load(tbl, 14 * VECWIDTH + tbloffset), times(v81, load(tbl, 15 * VECWIDTH + tbloffset))); + real2 v185 = plus(v51, v91); + real2 v179 = reverse(minus(v51, v91)); + real2 v31 = timesminusplus(reverse(v21), load(tbl, 2 * VECWIDTH + tbloffset), times(v21, load(tbl, 3 * VECWIDTH + tbloffset))); + real2 v184 = plus(v31, v71); + real2 v180 = minus(v71, v31); + scatter(out, 1, 16, plus(v184, v185)); + real2 v198 = minus(v184, v185); + scatter(out, 9, 16, timesminusplus(v198, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v198), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v181 = minusplus(v179, v180); + scatter(out, 5, 16, timesminusplus(reverse(v181), load(tbl, 30 * VECWIDTH + tbloffset), times(v181, load(tbl, 31 * VECWIDTH + tbloffset)))); + real2 v183 = minusplus(uminus(v179), v180); + scatter(out, 13, 16, timesminusplus(reverse(v183), load(tbl, 32 * VECWIDTH + tbloffset), times(v183, load(tbl, 33 * VECWIDTH + tbloffset)))); + } +} + +ALIGNED(8192) void tbut16b_%CONFIG%_%ISA%(real *RESTRICT out0, uint32_t *q, const real *RESTRICT in0, const int inShift, const real *RESTRICT tbl, const int K) { + const int k = 1 << (inShift - LOG2VECWIDTH); + int i=0; +#pragma omp parallel for + for(i=0;i < k;i++) { + int i0 = i << LOG2VECWIDTH; + real *out = out0 + q[i]; + const real *in = in0 + i0*2; + const int tbloffset = K * i0; + + real2 v15 = load(in, 13 << inShift); + real2 v7 = load(in, 5 << inShift); + real2 v45 = plus(v7, v15); + real2 v39 = reverse(minus(v15, v7)); + real2 v3 = load(in, 1 << inShift); + real2 v11 = load(in, 9 << inShift); + real2 v40 = minus(v11, v3); + real2 v44 = plus(v3, v11); + real2 v124 = plus(v44, v45); + real2 v120 = minus(v45, v44); + real2 v41 = minusplus(v39, v40); + real2 v43 = minusplus(uminus(v39), v40); + real2 v57 = timesminusplus(reverse(v43), load(tbl, 8 * VECWIDTH + tbloffset), times(v43, load(tbl, 9 * VECWIDTH + tbloffset))); + real2 v13 = load(in, 11 << inShift); + real2 v5 = load(in, 3 << inShift); + real2 v84 = plus(v5, v13); + real2 v80 = minus(v13, v5); + real2 v17 = load(in, 15 << inShift); + real2 v9 = load(in, 7 << inShift); + real2 v85 = plus(v9, v17); + real2 v79 = reverse(minus(v17, v9)); + real2 v119 = reverse(minus(v85, v84)); + real2 v125 = plus(v84, v85); + real2 v145 = plus(v124, v125); + real2 v139 = reverse(minus(v125, v124)); + real2 v121 = minusplus(v119, v120); + real2 v123 = minusplus(uminus(v119), v120); + real2 v137 = timesminusplus(reverse(v123), load(tbl, 24 * VECWIDTH + tbloffset), times(v123, load(tbl, 25 * VECWIDTH + tbloffset))); + real2 v131 = timesminusplus(reverse(v121), load(tbl, 22 * VECWIDTH + tbloffset), times(v121, load(tbl, 23 * VECWIDTH + tbloffset))); + real2 v4 = load(in, 2 << inShift); + real2 v12 = load(in, 10 << inShift); + real2 v64 = plus(v4, v12); + real2 v60 = minus(v12, v4); + real2 v8 = load(in, 6 << inShift); + real2 v16 = load(in, 14 << inShift); + real2 v65 = plus(v8, v16); + real2 v59 = reverse(minus(v16, v8)); + real2 v99 = reverse(minus(v65, v64)); + real2 v105 = plus(v64, v65); + real2 v14 = load(in, 12 << inShift); + real2 v6 = load(in, 4 << inShift); + real2 v25 = plus(v6, v14); + real2 v19 = reverse(minus(v14, v6)); + real2 v10 = load(in, 8 << inShift); + real2 v2 = load(in, 0 << inShift); + real2 v20 = minus(v10, v2); + real2 v24 = plus(v2, v10); + real2 v104 = plus(v24, v25); + real2 v100 = minus(v25, v24); + real2 v140 = minus(v105, v104); + real2 v144 = plus(v104, v105); + scatter(out, 0, 16, plus(v144, v145)); + real2 v158 = minus(v144, v145); + scatter(out, 8, 16, timesminusplus(v158, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v158), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v143 = minusplus(uminus(v139), v140); + scatter(out, 12, 16, timesminusplus(reverse(v143), load(tbl, 28 * VECWIDTH + tbloffset), times(v143, load(tbl, 29 * VECWIDTH + tbloffset)))); + real2 v141 = minusplus(v139, v140); + scatter(out, 4, 16, timesminusplus(reverse(v141), load(tbl, 26 * VECWIDTH + tbloffset), times(v141, load(tbl, 27 * VECWIDTH + tbloffset)))); + real2 v101 = minusplus(v99, v100); + real2 v103 = minusplus(uminus(v99), v100); + real2 v117 = timesminusplus(reverse(v103), load(tbl, 20 * VECWIDTH + tbloffset), times(v103, load(tbl, 21 * VECWIDTH + tbloffset))); + scatter(out, 6, 16, plus(v117, v137)); + real2 v172 = minus(v117, v137); + scatter(out, 14, 16, timesminusplus(v172, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v172), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v111 = timesminusplus(reverse(v101), load(tbl, 18 * VECWIDTH + tbloffset), times(v101, load(tbl, 19 * VECWIDTH + tbloffset))); + scatter(out, 2, 16, plus(v111, v131)); + real2 v166 = minus(v111, v131); + scatter(out, 10, 16, timesminusplus(v166, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v166), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v23 = minusplus(uminus(v19), v20); + real2 v21 = minusplus(v19, v20); + real2 v81 = minusplus(v79, v80); + real2 v83 = minusplus(uminus(v79), v80); + real2 v97 = timesminusplus(reverse(v83), load(tbl, 16 * VECWIDTH + tbloffset), times(v83, load(tbl, 17 * VECWIDTH + tbloffset))); + real2 v211 = plus(v57, v97); + real2 v205 = reverse(minus(v97, v57)); + real2 v61 = minusplus(v59, v60); + real2 v63 = minusplus(uminus(v59), v60); + real2 v77 = timesminusplus(reverse(v63), load(tbl, 12 * VECWIDTH + tbloffset), times(v63, load(tbl, 13 * VECWIDTH + tbloffset))); + real2 v37 = timesminusplus(reverse(v23), load(tbl, 4 * VECWIDTH + tbloffset), times(v23, load(tbl, 5 * VECWIDTH + tbloffset))); + real2 v210 = plus(v37, v77); + real2 v206 = minus(v77, v37); + scatter(out, 3, 16, plus(v210, v211)); + real2 v224 = minus(v210, v211); + scatter(out, 11, 16, timesminusplus(v224, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v224), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v207 = minusplus(v205, v206); + real2 v209 = minusplus(uminus(v205), v206); + scatter(out, 15, 16, timesminusplus(reverse(v209), load(tbl, 36 * VECWIDTH + tbloffset), times(v209, load(tbl, 37 * VECWIDTH + tbloffset)))); + scatter(out, 7, 16, timesminusplus(reverse(v207), load(tbl, 34 * VECWIDTH + tbloffset), times(v207, load(tbl, 35 * VECWIDTH + tbloffset)))); + real2 v71 = timesminusplus(reverse(v61), load(tbl, 10 * VECWIDTH + tbloffset), times(v61, load(tbl, 11 * VECWIDTH + tbloffset))); + real2 v51 = timesminusplus(reverse(v41), load(tbl, 6 * VECWIDTH + tbloffset), times(v41, load(tbl, 7 * VECWIDTH + tbloffset))); + real2 v91 = timesminusplus(reverse(v81), load(tbl, 14 * VECWIDTH + tbloffset), times(v81, load(tbl, 15 * VECWIDTH + tbloffset))); + real2 v185 = plus(v51, v91); + real2 v179 = reverse(minus(v91, v51)); + real2 v31 = timesminusplus(reverse(v21), load(tbl, 2 * VECWIDTH + tbloffset), times(v21, load(tbl, 3 * VECWIDTH + tbloffset))); + real2 v184 = plus(v31, v71); + real2 v180 = minus(v71, v31); + scatter(out, 1, 16, plus(v184, v185)); + real2 v198 = minus(v184, v185); + scatter(out, 9, 16, timesminusplus(v198, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v198), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v181 = minusplus(v179, v180); + scatter(out, 5, 16, timesminusplus(reverse(v181), load(tbl, 30 * VECWIDTH + tbloffset), times(v181, load(tbl, 31 * VECWIDTH + tbloffset)))); + real2 v183 = minusplus(uminus(v179), v180); + scatter(out, 13, 16, timesminusplus(reverse(v183), load(tbl, 32 * VECWIDTH + tbloffset), times(v183, load(tbl, 33 * VECWIDTH + tbloffset)))); + } +} +#endif + +#if MAXBUTWIDTH >= 5 +ALIGNED(8192) void dft32f_%CONFIG%_%ISA%(real *RESTRICT out0, const real *RESTRICT in0, const int shift) { + const int k = 1 << (shift - LOG2VECWIDTH); + int i=0; +#pragma omp parallel for + for(i=0;i < k;i++) { + int i0 = i << LOG2VECWIDTH; + real *out = out0 + i0*2; + const real *in = in0 + i0*2; + + real2 v15 = load(in, 13 << shift); + real2 v31 = load(in, 29 << shift); + real2 v124 = reverse(minus(v15, v31)); + real2 v130 = plus(v15, v31); + real2 v23 = load(in, 21 << shift); + real2 v7 = load(in, 5 << shift); + real2 v129 = plus(v7, v23); + real2 v125 = minus(v23, v7); + real2 v193 = reverse(minus(v129, v130)); + real2 v199 = plus(v129, v130); + real2 v126 = minusplus(v124, v125); + real2 v128 = minusplus(uminus(v124), v125); + real2 v139 = ctimesminusplus(reverse(v128), ctbl[7], ctimes(v128, ctbl[6])); + real2 v134 = ctimesminusplus(reverse(v126), ctbl[9], ctimes(v126, ctbl[11])); + real2 v19 = load(in, 17 << shift); + real2 v3 = load(in, 1 << shift); + real2 v52 = minus(v19, v3); + real2 v56 = plus(v3, v19); + real2 v27 = load(in, 25 << shift); + real2 v11 = load(in, 9 << shift); + real2 v51 = reverse(minus(v11, v27)); + real2 v57 = plus(v11, v27); + real2 v194 = minus(v57, v56); + real2 v198 = plus(v56, v57); + real2 v53 = minusplus(v51, v52); + real2 v55 = minusplus(uminus(v51), v52); + real2 v69 = ctimesminusplus(reverse(v55), ctbl[11], ctimes(v55, ctbl[9])); + real2 v262 = plus(v198, v199); + real2 v258 = minus(v199, v198); + real2 v195 = minusplus(v193, v194); + real2 v197 = minusplus(uminus(v193), v194); + real2 v207 = ctimesminusplus(reverse(v197), ctbl[5], ctimes(v197, ctbl[3])); + real2 v414 = plus(v69, v139); + real2 v410 = minus(v139, v69); + real2 v203 = ctimesminusplus(reverse(v195), ctbl[3], ctimes(v195, ctbl[5])); + real2 v17 = load(in, 15 << shift); + real2 v33 = load(in, 31 << shift); + real2 v159 = reverse(minus(v17, v33)); + real2 v165 = plus(v17, v33); + real2 v25 = load(in, 23 << shift); + real2 v9 = load(in, 7 << shift); + real2 v164 = plus(v9, v25); + real2 v160 = minus(v25, v9); + real2 v231 = plus(v164, v165); + real2 v225 = reverse(minus(v164, v165)); + real2 v161 = minusplus(v159, v160); + real2 v163 = minusplus(uminus(v159), v160); + real2 v175 = ctimesminusplus(reverse(v163), ctbl[10], ctimes(v163, ctbl[8])); + real2 v13 = load(in, 11 << shift); + real2 v29 = load(in, 27 << shift); + real2 v95 = plus(v13, v29); + real2 v89 = reverse(minus(v13, v29)); + real2 v21 = load(in, 19 << shift); + real2 v5 = load(in, 3 << shift); + real2 v90 = minus(v21, v5); + real2 v94 = plus(v5, v21); + real2 v226 = minus(v95, v94); + real2 v230 = plus(v94, v95); + real2 v229 = minusplus(uminus(v225), v226); + real2 v227 = minusplus(v225, v226); + real2 v239 = ctimesminusplus(reverse(v229), ctbl[4], ctimes(v229, ctbl[2])); + real2 v257 = reverse(minus(v230, v231)); + real2 v263 = plus(v230, v231); + real2 v235 = ctimesminusplus(reverse(v227), ctbl[5], ctimes(v227, ctbl[3])); + real2 v261 = minusplus(uminus(v257), v258); + real2 v259 = minusplus(v257, v258); + real2 v267 = ctimesminusplus(reverse(v259), ctbl[1], ctimes(v259, ctbl[1])); + real2 v298 = reverse(minus(v203, v235)); + real2 v304 = plus(v203, v235); + real2 v271 = ctimesminusplus(reverse(v261), ctbl[1], ctimes(v261, ctbl[0])); + real2 v279 = plus(v262, v263); + real2 v273 = reverse(minus(v262, v263)); + real2 v317 = reverse(minus(v207, v239)); + real2 v323 = plus(v207, v239); + real2 v8 = load(in, 6 << shift); + real2 v24 = load(in, 22 << shift); + real2 v146 = plus(v8, v24); + real2 v142 = minus(v24, v8); + real2 v28 = load(in, 26 << shift); + real2 v12 = load(in, 10 << shift); + real2 v77 = plus(v12, v28); + real2 v71 = reverse(minus(v12, v28)); + real2 v16 = load(in, 14 << shift); + real2 v32 = load(in, 30 << shift); + real2 v147 = plus(v16, v32); + real2 v141 = reverse(minus(v16, v32)); + real2 v209 = reverse(minus(v146, v147)); + real2 v215 = plus(v146, v147); + real2 v20 = load(in, 18 << shift); + real2 v4 = load(in, 2 << shift); + real2 v72 = minus(v20, v4); + real2 v76 = plus(v4, v20); + real2 v214 = plus(v76, v77); + real2 v210 = minus(v77, v76); + real2 v247 = plus(v214, v215); + real2 v241 = reverse(minus(v214, v215)); + real2 v213 = minusplus(uminus(v209), v210); + real2 v211 = minusplus(v209, v210); + real2 v223 = ctimesminusplus(reverse(v213), ctbl[1], ctimes(v213, ctbl[0])); + real2 v219 = ctimesminusplus(reverse(v211), ctbl[1], ctimes(v211, ctbl[1])); + real2 v26 = load(in, 24 << shift); + real2 v10 = load(in, 8 << shift); + real2 v35 = reverse(minus(v10, v26)); + real2 v41 = plus(v10, v26); + real2 v2 = load(in, 0 << shift); + real2 v18 = load(in, 16 << shift); + real2 v40 = plus(v2, v18); + real2 v36 = minus(v18, v2); + real2 v178 = minus(v41, v40); + real2 v182 = plus(v40, v41); + real2 v6 = load(in, 4 << shift); + real2 v22 = load(in, 20 << shift); + real2 v107 = minus(v22, v6); + real2 v111 = plus(v6, v22); + real2 v14 = load(in, 12 << shift); + real2 v30 = load(in, 28 << shift); + real2 v112 = plus(v14, v30); + real2 v106 = reverse(minus(v14, v30)); + real2 v177 = reverse(minus(v111, v112)); + real2 v183 = plus(v111, v112); + real2 v191 = minus(uminusplus(v177), v178); + real2 v187 = minus(uplusminus(v177), v178); + real2 v322 = plus(v191, v223); + real2 v318 = minus(v223, v191); + store(out, 22 << shift, minus(v322, v323)); + store(out, 6 << shift, plus(v322, v323)); + store(out, 14 << shift, minus(uplusminus(v317), v318)); + store(out, 30 << shift, minus(uminusplus(v317), v318)); + real2 v246 = plus(v182, v183); + real2 v242 = minus(v183, v182); + real2 v274 = minus(v247, v246); + store(out, 24 << shift, minus(uminusplus(v273), v274)); + store(out, 8 << shift, minus(uplusminus(v273), v274)); + real2 v278 = plus(v246, v247); + store(out, 16 << shift, minus(v278, v279)); + store(out, 0 << shift, plus(v278, v279)); + real2 v303 = plus(v187, v219); + store(out, 2 << shift, plus(v303, v304)); + store(out, 18 << shift, minus(v303, v304)); + real2 v299 = minus(v219, v187); + store(out, 26 << shift, minus(uminusplus(v298), v299)); + store(out, 10 << shift, minus(uplusminus(v298), v299)); + real2 v255 = minus(uminusplus(v241), v242); + real2 v251 = minus(uplusminus(v241), v242); + store(out, 20 << shift, minus(v251, v267)); + store(out, 4 << shift, plus(v251, v267)); + store(out, 28 << shift, minus(v255, v271)); + store(out, 12 << shift, plus(v255, v271)); + real2 v75 = minusplus(uminus(v71), v72); + real2 v73 = minusplus(v71, v72); + real2 v143 = minusplus(v141, v142); + real2 v145 = minusplus(uminus(v141), v142); + real2 v157 = ctimesminusplus(reverse(v145), ctbl[4], ctimes(v145, ctbl[2])); + real2 v87 = ctimesminusplus(reverse(v75), ctbl[5], ctimes(v75, ctbl[3])); + real2 v91 = minusplus(v89, v90); + real2 v93 = minusplus(uminus(v89), v90); + real2 v104 = ctimesminusplus(reverse(v93), ctbl[13], ctimes(v93, ctbl[12])); + real2 v399 = plus(v87, v157); + real2 v393 = reverse(minus(v87, v157)); + real2 v110 = minusplus(uminus(v106), v107); + real2 v108 = minusplus(v106, v107); + real2 v415 = plus(v104, v175); + real2 v409 = reverse(minus(v104, v175)); + real2 v411 = minusplus(v409, v410); + real2 v413 = minusplus(uminus(v409), v410); + real2 v49 = minus(uminusplus(v35), v36); + real2 v45 = minus(uplusminus(v35), v36); + real2 v122 = ctimesminusplus(reverse(v110), ctbl[1], ctimes(v110, ctbl[0])); + real2 v423 = ctimesminusplus(reverse(v413), ctbl[1], ctimes(v413, ctbl[0])); + real2 v398 = plus(v49, v122); + real2 v394 = minus(v122, v49); + real2 v407 = minus(uminusplus(v393), v394); + store(out, 15 << shift, plus(v407, v423)); + store(out, 31 << shift, minus(v407, v423)); + real2 v403 = minus(uplusminus(v393), v394); + real2 v419 = ctimesminusplus(reverse(v411), ctbl[1], ctimes(v411, ctbl[1])); + store(out, 7 << shift, plus(v403, v419)); + store(out, 23 << shift, minus(v403, v419)); + real2 v431 = plus(v414, v415); + real2 v425 = reverse(minus(v414, v415)); + real2 v430 = plus(v398, v399); + store(out, 19 << shift, minus(v430, v431)); + store(out, 3 << shift, plus(v430, v431)); + real2 v426 = minus(v399, v398); + store(out, 27 << shift, minus(uminusplus(v425), v426)); + store(out, 11 << shift, minus(uplusminus(v425), v426)); + real2 v63 = ctimesminusplus(reverse(v53), ctbl[7], ctimes(v53, ctbl[13])); + real2 v151 = ctimesminusplus(reverse(v143), ctbl[5], ctimes(v143, ctbl[3])); + real2 v99 = ctimesminusplus(reverse(v91), ctbl[11], ctimes(v91, ctbl[9])); + real2 v169 = ctimesminusplus(reverse(v161), ctbl[13], ctimes(v161, ctbl[7])); + real2 v352 = reverse(minus(v99, v169)); + real2 v358 = plus(v99, v169); + real2 v357 = plus(v63, v134); + real2 v353 = minus(v134, v63); + real2 v117 = ctimesminusplus(reverse(v108), ctbl[1], ctimes(v108, ctbl[1])); + real2 v374 = plus(v357, v358); + real2 v368 = reverse(minus(v357, v358)); + real2 v83 = ctimesminusplus(reverse(v73), ctbl[3], ctimes(v73, ctbl[5])); + real2 v336 = reverse(minus(v83, v151)); + real2 v342 = plus(v83, v151); + real2 v341 = plus(v45, v117); + real2 v337 = minus(v117, v45); + real2 v373 = plus(v341, v342); + real2 v369 = minus(v342, v341); + store(out, 9 << shift, minus(uplusminus(v368), v369)); + store(out, 25 << shift, minus(uminusplus(v368), v369)); + store(out, 17 << shift, minus(v373, v374)); + store(out, 1 << shift, plus(v373, v374)); + real2 v354 = minusplus(v352, v353); + real2 v356 = minusplus(uminus(v352), v353); + real2 v362 = ctimesminusplus(reverse(v354), ctbl[1], ctimes(v354, ctbl[1])); + real2 v346 = minus(uplusminus(v336), v337); + store(out, 21 << shift, minus(v346, v362)); + store(out, 5 << shift, plus(v346, v362)); + real2 v350 = minus(uminusplus(v336), v337); + real2 v366 = ctimesminusplus(reverse(v356), ctbl[1], ctimes(v356, ctbl[0])); + store(out, 29 << shift, minus(v350, v366)); + store(out, 13 << shift, plus(v350, v366)); + } +} + +ALIGNED(8192) void dft32b_%CONFIG%_%ISA%(real *RESTRICT out0, const real *RESTRICT in0, const int shift) { + const int k = 1 << (shift - LOG2VECWIDTH); + int i=0; +#pragma omp parallel for + for(i=0;i < k;i++) { + int i0 = i << LOG2VECWIDTH; + real *out = out0 + i0*2; + const real *in = in0 + i0*2; + + real2 v6 = load(in, 4 << shift); + real2 v22 = load(in, 20 << shift); + real2 v109 = minus(v22, v6); + real2 v113 = plus(v6, v22); + real2 v14 = load(in, 12 << shift); + real2 v30 = load(in, 28 << shift); + real2 v108 = reverse(minus(v30, v14)); + real2 v114 = plus(v14, v30); + real2 v183 = plus(v113, v114); + real2 v177 = reverse(minus(v114, v113)); + real2 v110 = minusplus(v108, v109); + real2 v112 = minusplus(uminus(v108), v109); + real2 v120 = ctimesminusplus(reverse(v110), ctbl[0], ctimes(v110, ctbl[1])); + real2 v124 = ctimesminusplus(reverse(v112), ctbl[0], ctimes(v112, ctbl[0])); + real2 v10 = load(in, 8 << shift); + real2 v26 = load(in, 24 << shift); + real2 v35 = reverse(minus(v26, v10)); + real2 v41 = plus(v10, v26); + real2 v18 = load(in, 16 << shift); + real2 v2 = load(in, 0 << shift); + real2 v36 = minus(v18, v2); + real2 v40 = plus(v2, v18); + real2 v178 = minus(v41, v40); + real2 v182 = plus(v40, v41); + real2 v45 = minus(uplusminus(v35), v36); + real2 v49 = minus(uminusplus(v35), v36); + real2 v398 = plus(v49, v124); + real2 v394 = minus(v124, v49); + real2 v242 = minus(v183, v182); + real2 v246 = plus(v182, v183); + real2 v341 = plus(v45, v120); + real2 v337 = minus(v120, v45); + real2 v187 = minus(uplusminus(v177), v178); + real2 v191 = minus(uminusplus(v177), v178); + real2 v7 = load(in, 5 << shift); + real2 v23 = load(in, 21 << shift); + real2 v131 = plus(v7, v23); + real2 v127 = minus(v23, v7); + real2 v15 = load(in, 13 << shift); + real2 v31 = load(in, 29 << shift); + real2 v126 = reverse(minus(v31, v15)); + real2 v132 = plus(v15, v31); + real2 v199 = plus(v131, v132); + real2 v193 = reverse(minus(v132, v131)); + real2 v128 = minusplus(v126, v127); + real2 v130 = minusplus(uminus(v126), v127); + real2 v138 = ctimesminusplus(reverse(v128), ctbl[10], ctimes(v128, ctbl[11])); + real2 v21 = load(in, 19 << shift); + real2 v5 = load(in, 3 << shift); + real2 v92 = minus(v21, v5); + real2 v96 = plus(v5, v21); + real2 v29 = load(in, 27 << shift); + real2 v13 = load(in, 11 << shift); + real2 v97 = plus(v13, v29); + real2 v91 = reverse(minus(v29, v13)); + real2 v95 = minusplus(uminus(v91), v92); + real2 v93 = minusplus(v91, v92); + real2 v230 = plus(v96, v97); + real2 v226 = minus(v97, v96); + real2 v17 = load(in, 15 << shift); + real2 v33 = load(in, 31 << shift); + real2 v166 = plus(v17, v33); + real2 v160 = reverse(minus(v33, v17)); + real2 v9 = load(in, 7 << shift); + real2 v25 = load(in, 23 << shift); + real2 v161 = minus(v25, v9); + real2 v165 = plus(v9, v25); + real2 v231 = plus(v165, v166); + real2 v225 = reverse(minus(v166, v165)); + real2 v263 = plus(v230, v231); + real2 v257 = reverse(minus(v231, v230)); + real2 v229 = minusplus(uminus(v225), v226); + real2 v227 = minusplus(v225, v226); + real2 v235 = ctimesminusplus(reverse(v227), ctbl[2], ctimes(v227, ctbl[3])); + real2 v3 = load(in, 1 << shift); + real2 v19 = load(in, 17 << shift); + real2 v52 = minus(v19, v3); + real2 v56 = plus(v3, v19); + real2 v27 = load(in, 25 << shift); + real2 v11 = load(in, 9 << shift); + real2 v51 = reverse(minus(v27, v11)); + real2 v57 = plus(v11, v27); + real2 v198 = plus(v56, v57); + real2 v194 = minus(v57, v56); + real2 v258 = minus(v199, v198); + real2 v262 = plus(v198, v199); + real2 v273 = reverse(minus(v263, v262)); + real2 v279 = plus(v262, v263); + real2 v259 = minusplus(v257, v258); + real2 v261 = minusplus(uminus(v257), v258); + real2 v271 = ctimesminusplus(reverse(v261), ctbl[0], ctimes(v261, ctbl[0])); + real2 v197 = minusplus(uminus(v193), v194); + real2 v195 = minusplus(v193, v194); + real2 v203 = ctimesminusplus(reverse(v195), ctbl[4], ctimes(v195, ctbl[5])); + real2 v298 = reverse(minus(v235, v203)); + real2 v304 = plus(v203, v235); + real2 v267 = ctimesminusplus(reverse(v259), ctbl[0], ctimes(v259, ctbl[1])); + real2 v4 = load(in, 2 << shift); + real2 v20 = load(in, 18 << shift); + real2 v72 = minus(v20, v4); + real2 v76 = plus(v4, v20); + real2 v28 = load(in, 26 << shift); + real2 v12 = load(in, 10 << shift); + real2 v71 = reverse(minus(v28, v12)); + real2 v77 = plus(v12, v28); + real2 v210 = minus(v77, v76); + real2 v214 = plus(v76, v77); + real2 v32 = load(in, 30 << shift); + real2 v16 = load(in, 14 << shift); + real2 v150 = plus(v16, v32); + real2 v144 = reverse(minus(v32, v16)); + real2 v8 = load(in, 6 << shift); + real2 v24 = load(in, 22 << shift); + real2 v149 = plus(v8, v24); + real2 v145 = minus(v24, v8); + real2 v215 = plus(v149, v150); + real2 v209 = reverse(minus(v150, v149)); + real2 v241 = reverse(minus(v215, v214)); + real2 v247 = plus(v214, v215); + real2 v251 = minus(uplusminus(v241), v242); + real2 v255 = minus(uminusplus(v241), v242); + store(out, 12 << shift, plus(v255, v271)); + store(out, 28 << shift, minus(v255, v271)); + store(out, 4 << shift, plus(v251, v267)); + store(out, 20 << shift, minus(v251, v267)); + real2 v278 = plus(v246, v247); + real2 v274 = minus(v247, v246); + store(out, 24 << shift, minus(uminusplus(v273), v274)); + store(out, 8 << shift, minus(uplusminus(v273), v274)); + store(out, 16 << shift, minus(v278, v279)); + store(out, 0 << shift, plus(v278, v279)); + real2 v211 = minusplus(v209, v210); + real2 v213 = minusplus(uminus(v209), v210); + real2 v219 = ctimesminusplus(reverse(v211), ctbl[0], ctimes(v211, ctbl[1])); + real2 v299 = minus(v219, v187); + real2 v303 = plus(v187, v219); + store(out, 2 << shift, plus(v303, v304)); + store(out, 18 << shift, minus(v303, v304)); + store(out, 10 << shift, minus(uplusminus(v298), v299)); + store(out, 26 << shift, minus(uminusplus(v298), v299)); + real2 v223 = ctimesminusplus(reverse(v213), ctbl[0], ctimes(v213, ctbl[0])); + real2 v322 = plus(v191, v223); + real2 v318 = minus(v223, v191); + real2 v239 = ctimesminusplus(reverse(v229), ctbl[3], ctimes(v229, ctbl[2])); + real2 v207 = ctimesminusplus(reverse(v197), ctbl[2], ctimes(v197, ctbl[3])); + real2 v317 = reverse(minus(v239, v207)); + store(out, 30 << shift, minus(uminusplus(v317), v318)); + store(out, 14 << shift, minus(uplusminus(v317), v318)); + real2 v323 = plus(v207, v239); + store(out, 6 << shift, plus(v322, v323)); + store(out, 22 << shift, minus(v322, v323)); + real2 v101 = ctimesminusplus(reverse(v93), ctbl[8], ctimes(v93, ctbl[9])); + real2 v75 = minusplus(uminus(v71), v72); + real2 v73 = minusplus(v71, v72); + real2 v83 = ctimesminusplus(reverse(v73), ctbl[4], ctimes(v73, ctbl[5])); + real2 v162 = minusplus(v160, v161); + real2 v164 = minusplus(uminus(v160), v161); + real2 v55 = minusplus(uminus(v51), v52); + real2 v53 = minusplus(v51, v52); + real2 v171 = ctimesminusplus(reverse(v162), ctbl[6], ctimes(v162, ctbl[7])); + real2 v352 = reverse(minus(v171, v101)); + real2 v358 = plus(v101, v171); + real2 v63 = ctimesminusplus(reverse(v53), ctbl[12], ctimes(v53, ctbl[13])); + real2 v146 = minusplus(v144, v145); + real2 v148 = minusplus(uminus(v144), v145); + real2 v154 = ctimesminusplus(reverse(v146), ctbl[2], ctimes(v146, ctbl[3])); + real2 v342 = plus(v83, v154); + real2 v336 = reverse(minus(v154, v83)); + real2 v373 = plus(v341, v342); + real2 v369 = minus(v342, v341); + real2 v353 = minus(v138, v63); + real2 v357 = plus(v63, v138); + real2 v374 = plus(v357, v358); + store(out, 1 << shift, plus(v373, v374)); + store(out, 17 << shift, minus(v373, v374)); + real2 v368 = reverse(minus(v358, v357)); + store(out, 25 << shift, minus(uminusplus(v368), v369)); + store(out, 9 << shift, minus(uplusminus(v368), v369)); + real2 v346 = minus(uplusminus(v336), v337); + real2 v350 = minus(uminusplus(v336), v337); + real2 v356 = minusplus(uminus(v352), v353); + real2 v354 = minusplus(v352, v353); + real2 v362 = ctimesminusplus(reverse(v354), ctbl[0], ctimes(v354, ctbl[1])); + store(out, 21 << shift, minus(v346, v362)); + store(out, 5 << shift, plus(v346, v362)); + real2 v366 = ctimesminusplus(reverse(v356), ctbl[0], ctimes(v356, ctbl[0])); + store(out, 13 << shift, plus(v350, v366)); + store(out, 29 << shift, minus(v350, v366)); + real2 v89 = ctimesminusplus(reverse(v75), ctbl[2], ctimes(v75, ctbl[3])); + real2 v106 = ctimesminusplus(reverse(v95), ctbl[6], ctimes(v95, ctbl[12])); + real2 v142 = ctimesminusplus(reverse(v130), ctbl[12], ctimes(v130, ctbl[6])); + real2 v158 = ctimesminusplus(reverse(v148), ctbl[3], ctimes(v148, ctbl[2])); + real2 v393 = reverse(minus(v158, v89)); + real2 v399 = plus(v89, v158); + real2 v403 = minus(uplusminus(v393), v394); + real2 v407 = minus(uminusplus(v393), v394); + real2 v175 = ctimesminusplus(reverse(v164), ctbl[9], ctimes(v164, ctbl[8])); + real2 v415 = plus(v106, v175); + real2 v409 = reverse(minus(v175, v106)); + real2 v69 = ctimesminusplus(reverse(v55), ctbl[8], ctimes(v55, ctbl[9])); + real2 v414 = plus(v69, v142); + real2 v410 = minus(v142, v69); + real2 v411 = minusplus(v409, v410); + real2 v413 = minusplus(uminus(v409), v410); + real2 v419 = ctimesminusplus(reverse(v411), ctbl[0], ctimes(v411, ctbl[1])); + store(out, 23 << shift, minus(v403, v419)); + store(out, 7 << shift, plus(v403, v419)); + real2 v423 = ctimesminusplus(reverse(v413), ctbl[0], ctimes(v413, ctbl[0])); + store(out, 15 << shift, plus(v407, v423)); + store(out, 31 << shift, minus(v407, v423)); + real2 v431 = plus(v414, v415); + real2 v425 = reverse(minus(v415, v414)); + real2 v430 = plus(v398, v399); + real2 v426 = minus(v399, v398); + store(out, 27 << shift, minus(uminusplus(v425), v426)); + store(out, 11 << shift, minus(uplusminus(v425), v426)); + store(out, 19 << shift, minus(v430, v431)); + store(out, 3 << shift, plus(v430, v431)); + } +} + +ALIGNED(8192) void but32f_%CONFIG%_%ISA%(real *RESTRICT out0, uint32_t *q, const int outShift, const real *RESTRICT in0, const int inShift, const real *RESTRICT tbl, const int K) { + const int k = 1 << (inShift - LOG2VECWIDTH); + int i=0; +#pragma omp parallel for + for(i=0;i < k;i++) { + int i0 = i << LOG2VECWIDTH; + real *out = out0 + q[i]; + const real *in = in0 + i0*2; + const int tbloffset = K * (i0 >> outShift); + + real2 v14 = load(in, 12 << inShift); + real2 v30 = load(in, 28 << inShift); + real2 v115 = reverse(minus(v14, v30)); + real2 v121 = plus(v14, v30); + real2 v6 = load(in, 4 << inShift); + real2 v22 = load(in, 20 << inShift); + real2 v120 = plus(v6, v22); + real2 v116 = minus(v22, v6); + real2 v201 = plus(v120, v121); + real2 v195 = reverse(minus(v120, v121)); + real2 v119 = minusplus(uminus(v115), v116); + real2 v117 = minusplus(v115, v116); + real2 v133 = ctimesminusplus(reverse(v119), tbl[20 + tbloffset], ctimes(v119, tbl[21 + tbloffset])); + real2 v127 = ctimesminusplus(reverse(v117), tbl[18 + tbloffset], ctimes(v117, tbl[19 + tbloffset])); + real2 v18 = load(in, 16 << inShift); + real2 v2 = load(in, 0 << inShift); + real2 v40 = plus(v2, v18); + real2 v36 = minus(v18, v2); + real2 v10 = load(in, 8 << inShift); + real2 v26 = load(in, 24 << inShift); + real2 v41 = plus(v10, v26); + real2 v35 = reverse(minus(v10, v26)); + real2 v200 = plus(v40, v41); + real2 v196 = minus(v41, v40); + real2 v37 = minusplus(v35, v36); + real2 v39 = minusplus(uminus(v35), v36); + real2 v53 = ctimesminusplus(reverse(v39), tbl[4 + tbloffset], ctimes(v39, tbl[5 + tbloffset])); + real2 v276 = minus(v201, v200); + real2 v280 = plus(v200, v201); + real2 v47 = ctimesminusplus(reverse(v37), tbl[2 + tbloffset], ctimes(v37, tbl[3 + tbloffset])); + real2 v199 = minusplus(uminus(v195), v196); + real2 v197 = minusplus(v195, v196); + real2 v486 = minus(v133, v53); + real2 v490 = plus(v53, v133); + real2 v213 = ctimesminusplus(reverse(v199), tbl[36 + tbloffset], ctimes(v199, tbl[37 + tbloffset])); + real2 v207 = ctimesminusplus(reverse(v197), tbl[34 + tbloffset], ctimes(v197, tbl[35 + tbloffset])); + real2 v28 = load(in, 26 << inShift); + real2 v12 = load(in, 10 << inShift); + real2 v81 = plus(v12, v28); + real2 v75 = reverse(minus(v12, v28)); + real2 v20 = load(in, 18 << inShift); + real2 v4 = load(in, 2 << inShift); + real2 v80 = plus(v4, v20); + real2 v76 = minus(v20, v4); + real2 v236 = minus(v81, v80); + real2 v240 = plus(v80, v81); + real2 v77 = minusplus(v75, v76); + real2 v79 = minusplus(uminus(v75), v76); + real2 v93 = ctimesminusplus(reverse(v79), tbl[12 + tbloffset], ctimes(v79, tbl[13 + tbloffset])); + real2 v32 = load(in, 30 << inShift); + real2 v16 = load(in, 14 << inShift); + real2 v155 = reverse(minus(v16, v32)); + real2 v161 = plus(v16, v32); + real2 v24 = load(in, 22 << inShift); + real2 v8 = load(in, 6 << inShift); + real2 v160 = plus(v8, v24); + real2 v156 = minus(v24, v8); + real2 v235 = reverse(minus(v160, v161)); + real2 v241 = plus(v160, v161); + real2 v157 = minusplus(v155, v156); + real2 v159 = minusplus(uminus(v155), v156); + real2 v173 = ctimesminusplus(reverse(v159), tbl[28 + tbloffset], ctimes(v159, tbl[29 + tbloffset])); + real2 v485 = reverse(minus(v93, v173)); + real2 v491 = plus(v93, v173); + real2 v489 = minusplus(uminus(v485), v486); + real2 v487 = minusplus(v485, v486); + real2 v239 = minusplus(uminus(v235), v236); + real2 v237 = minusplus(v235, v236); + real2 v253 = ctimesminusplus(reverse(v239), tbl[44 + tbloffset], ctimes(v239, tbl[45 + tbloffset])); + real2 v497 = ctimesminusplus(reverse(v487), tbl[82 + tbloffset], ctimes(v487, tbl[83 + tbloffset])); + real2 v530 = plus(v490, v491); + real2 v526 = minus(v491, v490); + real2 v503 = ctimesminusplus(reverse(v489), tbl[84 + tbloffset], ctimes(v489, tbl[85 + tbloffset])); + real2 v247 = ctimesminusplus(reverse(v237), tbl[42 + tbloffset], ctimes(v237, tbl[43 + tbloffset])); + real2 v356 = minus(v247, v207); + real2 v360 = plus(v207, v247); + real2 v386 = plus(v213, v253); + real2 v382 = minus(v253, v213); + real2 v17 = load(in, 15 << inShift); + real2 v33 = load(in, 31 << inShift); + real2 v175 = reverse(minus(v17, v33)); + real2 v181 = plus(v17, v33); + real2 v25 = load(in, 23 << inShift); + real2 v9 = load(in, 7 << inShift); + real2 v176 = minus(v25, v9); + real2 v180 = plus(v9, v25); + real2 v177 = minusplus(v175, v176); + real2 v179 = minusplus(uminus(v175), v176); + real2 v193 = ctimesminusplus(reverse(v179), tbl[32 + tbloffset], ctimes(v179, tbl[33 + tbloffset])); + real2 v261 = plus(v180, v181); + real2 v255 = reverse(minus(v180, v181)); + real2 v29 = load(in, 27 << inShift); + real2 v13 = load(in, 11 << inShift); + real2 v101 = plus(v13, v29); + real2 v95 = reverse(minus(v13, v29)); + real2 v21 = load(in, 19 << inShift); + real2 v5 = load(in, 3 << inShift); + real2 v100 = plus(v5, v21); + real2 v96 = minus(v21, v5); + real2 v99 = minusplus(uminus(v95), v96); + real2 v97 = minusplus(v95, v96); + real2 v260 = plus(v100, v101); + real2 v256 = minus(v101, v100); + real2 v259 = minusplus(uminus(v255), v256); + real2 v257 = minusplus(v255, v256); + real2 v273 = ctimesminusplus(reverse(v259), tbl[48 + tbloffset], ctimes(v259, tbl[49 + tbloffset])); + real2 v267 = ctimesminusplus(reverse(v257), tbl[46 + tbloffset], ctimes(v257, tbl[47 + tbloffset])); + real2 v3 = load(in, 1 << inShift); + real2 v19 = load(in, 17 << inShift); + real2 v60 = plus(v3, v19); + real2 v56 = minus(v19, v3); + real2 v27 = load(in, 25 << inShift); + real2 v11 = load(in, 9 << inShift); + real2 v55 = reverse(minus(v11, v27)); + real2 v61 = plus(v11, v27); + real2 v220 = plus(v60, v61); + real2 v216 = minus(v61, v60); + real2 v7 = load(in, 5 << inShift); + real2 v23 = load(in, 21 << inShift); + real2 v136 = minus(v23, v7); + real2 v140 = plus(v7, v23); + real2 v15 = load(in, 13 << inShift); + real2 v31 = load(in, 29 << inShift); + real2 v135 = reverse(minus(v15, v31)); + real2 v141 = plus(v15, v31); + real2 v215 = reverse(minus(v140, v141)); + real2 v221 = plus(v140, v141); + real2 v219 = minusplus(uminus(v215), v216); + real2 v217 = minusplus(v215, v216); + real2 v227 = ctimesminusplus(reverse(v217), tbl[38 + tbloffset], ctimes(v217, tbl[39 + tbloffset])); + real2 v355 = reverse(minus(v227, v267)); + real2 v361 = plus(v227, v267); + store(out, 2 << outShift, plus(v360, v361)); + real2 v374 = minus(v360, v361); + store(out, 18 << outShift, ctimesminusplus(v374, tbl[0 + tbloffset], ctimes(reverse(v374), tbl[1 + tbloffset]))); + real2 v357 = minusplus(v355, v356); + store(out, 10 << outShift, ctimesminusplus(reverse(v357), tbl[62 + tbloffset], ctimes(v357, tbl[63 + tbloffset]))); + real2 v359 = minusplus(uminus(v355), v356); + store(out, 26 << outShift, ctimesminusplus(reverse(v359), tbl[64 + tbloffset], ctimes(v359, tbl[65 + tbloffset]))); + real2 v233 = ctimesminusplus(reverse(v219), tbl[40 + tbloffset], ctimes(v219, tbl[41 + tbloffset])); + real2 v381 = reverse(minus(v233, v273)); + real2 v387 = plus(v233, v273); + store(out, 6 << outShift, plus(v386, v387)); + real2 v400 = minus(v386, v387); + store(out, 22 << outShift, ctimesminusplus(v400, tbl[0 + tbloffset], ctimes(reverse(v400), tbl[1 + tbloffset]))); + real2 v383 = minusplus(v381, v382); + real2 v385 = minusplus(uminus(v381), v382); + store(out, 30 << outShift, ctimesminusplus(reverse(v385), tbl[68 + tbloffset], ctimes(v385, tbl[69 + tbloffset]))); + store(out, 14 << outShift, ctimesminusplus(reverse(v383), tbl[66 + tbloffset], ctimes(v383, tbl[67 + tbloffset]))); + real2 v137 = minusplus(v135, v136); + real2 v139 = minusplus(uminus(v135), v136); + real2 v153 = ctimesminusplus(reverse(v139), tbl[24 + tbloffset], ctimes(v139, tbl[25 + tbloffset])); + real2 v113 = ctimesminusplus(reverse(v99), tbl[16 + tbloffset], ctimes(v99, tbl[17 + tbloffset])); + real2 v511 = plus(v113, v193); + real2 v505 = reverse(minus(v113, v193)); + real2 v57 = minusplus(v55, v56); + real2 v59 = minusplus(uminus(v55), v56); + real2 v73 = ctimesminusplus(reverse(v59), tbl[8 + tbloffset], ctimes(v59, tbl[9 + tbloffset])); + real2 v510 = plus(v73, v153); + real2 v506 = minus(v153, v73); + real2 v531 = plus(v510, v511); + real2 v525 = reverse(minus(v510, v511)); + store(out, 3 << outShift, plus(v530, v531)); + real2 v544 = minus(v530, v531); + store(out, 19 << outShift, ctimesminusplus(v544, tbl[0 + tbloffset], ctimes(reverse(v544), tbl[1 + tbloffset]))); + real2 v527 = minusplus(v525, v526); + store(out, 11 << outShift, ctimesminusplus(reverse(v527), tbl[90 + tbloffset], ctimes(v527, tbl[91 + tbloffset]))); + real2 v529 = minusplus(uminus(v525), v526); + store(out, 27 << outShift, ctimesminusplus(reverse(v529), tbl[92 + tbloffset], ctimes(v529, tbl[93 + tbloffset]))); + real2 v509 = minusplus(uminus(v505), v506); + real2 v507 = minusplus(v505, v506); + real2 v523 = ctimesminusplus(reverse(v509), tbl[88 + tbloffset], ctimes(v509, tbl[89 + tbloffset])); + store(out, 15 << outShift, plus(v503, v523)); + real2 v556 = minus(v503, v523); + store(out, 31 << outShift, ctimesminusplus(v556, tbl[0 + tbloffset], ctimes(reverse(v556), tbl[1 + tbloffset]))); + real2 v517 = ctimesminusplus(reverse(v507), tbl[86 + tbloffset], ctimes(v507, tbl[87 + tbloffset])); + store(out, 7 << outShift, plus(v497, v517)); + real2 v550 = minus(v497, v517); + store(out, 23 << outShift, ctimesminusplus(v550, tbl[0 + tbloffset], ctimes(reverse(v550), tbl[1 + tbloffset]))); + real2 v275 = reverse(minus(v240, v241)); + real2 v281 = plus(v240, v241); + real2 v320 = plus(v280, v281); + real2 v316 = minus(v281, v280); + real2 v301 = plus(v260, v261); + real2 v295 = reverse(minus(v260, v261)); + real2 v300 = plus(v220, v221); + real2 v296 = minus(v221, v220); + real2 v315 = reverse(minus(v300, v301)); + real2 v321 = plus(v300, v301); + store(out, 0 << outShift, plus(v320, v321)); + real2 v334 = minus(v320, v321); + store(out, 16 << outShift, ctimesminusplus(v334, tbl[0 + tbloffset], ctimes(reverse(v334), tbl[1 + tbloffset]))); + real2 v319 = minusplus(uminus(v315), v316); + real2 v317 = minusplus(v315, v316); + store(out, 8 << outShift, ctimesminusplus(reverse(v317), tbl[58 + tbloffset], ctimes(v317, tbl[59 + tbloffset]))); + store(out, 24 << outShift, ctimesminusplus(reverse(v319), tbl[60 + tbloffset], ctimes(v319, tbl[61 + tbloffset]))); + real2 v299 = minusplus(uminus(v295), v296); + real2 v297 = minusplus(v295, v296); + real2 v279 = minusplus(uminus(v275), v276); + real2 v277 = minusplus(v275, v276); + real2 v287 = ctimesminusplus(reverse(v277), tbl[50 + tbloffset], ctimes(v277, tbl[51 + tbloffset])); + real2 v307 = ctimesminusplus(reverse(v297), tbl[54 + tbloffset], ctimes(v297, tbl[55 + tbloffset])); + store(out, 4 << outShift, plus(v287, v307)); + real2 v342 = minus(v287, v307); + store(out, 20 << outShift, ctimesminusplus(v342, tbl[0 + tbloffset], ctimes(reverse(v342), tbl[1 + tbloffset]))); + real2 v313 = ctimesminusplus(reverse(v299), tbl[56 + tbloffset], ctimes(v299, tbl[57 + tbloffset])); + real2 v293 = ctimesminusplus(reverse(v279), tbl[52 + tbloffset], ctimes(v279, tbl[53 + tbloffset])); + store(out, 12 << outShift, plus(v293, v313)); + real2 v348 = minus(v293, v313); + store(out, 28 << outShift, ctimesminusplus(v348, tbl[0 + tbloffset], ctimes(reverse(v348), tbl[1 + tbloffset]))); + real2 v87 = ctimesminusplus(reverse(v77), tbl[10 + tbloffset], ctimes(v77, tbl[11 + tbloffset])); + real2 v147 = ctimesminusplus(reverse(v137), tbl[22 + tbloffset], ctimes(v137, tbl[23 + tbloffset])); + real2 v187 = ctimesminusplus(reverse(v177), tbl[30 + tbloffset], ctimes(v177, tbl[31 + tbloffset])); + real2 v167 = ctimesminusplus(reverse(v157), tbl[26 + tbloffset], ctimes(v157, tbl[27 + tbloffset])); + real2 v413 = plus(v87, v167); + real2 v407 = reverse(minus(v87, v167)); + real2 v67 = ctimesminusplus(reverse(v57), tbl[6 + tbloffset], ctimes(v57, tbl[7 + tbloffset])); + real2 v107 = ctimesminusplus(reverse(v97), tbl[14 + tbloffset], ctimes(v97, tbl[15 + tbloffset])); + real2 v427 = reverse(minus(v107, v187)); + real2 v433 = plus(v107, v187); + real2 v432 = plus(v67, v147); + real2 v428 = minus(v147, v67); + real2 v453 = plus(v432, v433); + real2 v447 = reverse(minus(v432, v433)); + real2 v408 = minus(v127, v47); + real2 v412 = plus(v47, v127); + real2 v452 = plus(v412, v413); + real2 v448 = minus(v413, v412); + store(out, 1 << outShift, plus(v452, v453)); + real2 v466 = minus(v452, v453); + store(out, 17 << outShift, ctimesminusplus(v466, tbl[0 + tbloffset], ctimes(reverse(v466), tbl[1 + tbloffset]))); + real2 v451 = minusplus(uminus(v447), v448); + store(out, 25 << outShift, ctimesminusplus(reverse(v451), tbl[80 + tbloffset], ctimes(v451, tbl[81 + tbloffset]))); + real2 v449 = minusplus(v447, v448); + store(out, 9 << outShift, ctimesminusplus(reverse(v449), tbl[78 + tbloffset], ctimes(v449, tbl[79 + tbloffset]))); + real2 v429 = minusplus(v427, v428); + real2 v431 = minusplus(uminus(v427), v428); + real2 v445 = ctimesminusplus(reverse(v431), tbl[76 + tbloffset], ctimes(v431, tbl[77 + tbloffset])); + real2 v409 = minusplus(v407, v408); + real2 v411 = minusplus(uminus(v407), v408); + real2 v425 = ctimesminusplus(reverse(v411), tbl[72 + tbloffset], ctimes(v411, tbl[73 + tbloffset])); + store(out, 13 << outShift, plus(v425, v445)); + real2 v478 = minus(v425, v445); + store(out, 29 << outShift, ctimesminusplus(v478, tbl[0 + tbloffset], ctimes(reverse(v478), tbl[1 + tbloffset]))); + real2 v439 = ctimesminusplus(reverse(v429), tbl[74 + tbloffset], ctimes(v429, tbl[75 + tbloffset])); + real2 v419 = ctimesminusplus(reverse(v409), tbl[70 + tbloffset], ctimes(v409, tbl[71 + tbloffset])); + store(out, 5 << outShift, plus(v419, v439)); + real2 v472 = minus(v419, v439); + store(out, 21 << outShift, ctimesminusplus(v472, tbl[0 + tbloffset], ctimes(reverse(v472), tbl[1 + tbloffset]))); + } +} + +ALIGNED(8192) void but32b_%CONFIG%_%ISA%(real *RESTRICT out0, uint32_t *q, const int outShift, const real *RESTRICT in0, const int inShift, const real *RESTRICT tbl, const int K) { + const int k = 1 << (inShift - LOG2VECWIDTH); + int i=0; +#pragma omp parallel for + for(i=0;i < k;i++) { + int i0 = i << LOG2VECWIDTH; + real *out = out0 + q[i]; + const real *in = in0 + i0*2; + const int tbloffset = K * (i0 >> outShift); + + real2 v14 = load(in, 12 << inShift); + real2 v30 = load(in, 28 << inShift); + real2 v115 = reverse(minus(v30, v14)); + real2 v121 = plus(v14, v30); + real2 v6 = load(in, 4 << inShift); + real2 v22 = load(in, 20 << inShift); + real2 v120 = plus(v6, v22); + real2 v116 = minus(v22, v6); + real2 v201 = plus(v120, v121); + real2 v195 = reverse(minus(v121, v120)); + real2 v119 = minusplus(uminus(v115), v116); + real2 v117 = minusplus(v115, v116); + real2 v133 = ctimesminusplus(reverse(v119), tbl[20 + tbloffset], ctimes(v119, tbl[21 + tbloffset])); + real2 v127 = ctimesminusplus(reverse(v117), tbl[18 + tbloffset], ctimes(v117, tbl[19 + tbloffset])); + real2 v18 = load(in, 16 << inShift); + real2 v2 = load(in, 0 << inShift); + real2 v40 = plus(v2, v18); + real2 v36 = minus(v18, v2); + real2 v10 = load(in, 8 << inShift); + real2 v26 = load(in, 24 << inShift); + real2 v41 = plus(v10, v26); + real2 v35 = reverse(minus(v26, v10)); + real2 v200 = plus(v40, v41); + real2 v196 = minus(v41, v40); + real2 v37 = minusplus(v35, v36); + real2 v39 = minusplus(uminus(v35), v36); + real2 v53 = ctimesminusplus(reverse(v39), tbl[4 + tbloffset], ctimes(v39, tbl[5 + tbloffset])); + real2 v276 = minus(v201, v200); + real2 v280 = plus(v200, v201); + real2 v47 = ctimesminusplus(reverse(v37), tbl[2 + tbloffset], ctimes(v37, tbl[3 + tbloffset])); + real2 v199 = minusplus(uminus(v195), v196); + real2 v197 = minusplus(v195, v196); + real2 v486 = minus(v133, v53); + real2 v490 = plus(v53, v133); + real2 v213 = ctimesminusplus(reverse(v199), tbl[36 + tbloffset], ctimes(v199, tbl[37 + tbloffset])); + real2 v207 = ctimesminusplus(reverse(v197), tbl[34 + tbloffset], ctimes(v197, tbl[35 + tbloffset])); + real2 v28 = load(in, 26 << inShift); + real2 v12 = load(in, 10 << inShift); + real2 v81 = plus(v12, v28); + real2 v75 = reverse(minus(v28, v12)); + real2 v20 = load(in, 18 << inShift); + real2 v4 = load(in, 2 << inShift); + real2 v80 = plus(v4, v20); + real2 v76 = minus(v20, v4); + real2 v236 = minus(v81, v80); + real2 v240 = plus(v80, v81); + real2 v77 = minusplus(v75, v76); + real2 v79 = minusplus(uminus(v75), v76); + real2 v93 = ctimesminusplus(reverse(v79), tbl[12 + tbloffset], ctimes(v79, tbl[13 + tbloffset])); + real2 v32 = load(in, 30 << inShift); + real2 v16 = load(in, 14 << inShift); + real2 v155 = reverse(minus(v32, v16)); + real2 v161 = plus(v16, v32); + real2 v24 = load(in, 22 << inShift); + real2 v8 = load(in, 6 << inShift); + real2 v160 = plus(v8, v24); + real2 v156 = minus(v24, v8); + real2 v235 = reverse(minus(v161, v160)); + real2 v241 = plus(v160, v161); + real2 v157 = minusplus(v155, v156); + real2 v159 = minusplus(uminus(v155), v156); + real2 v173 = ctimesminusplus(reverse(v159), tbl[28 + tbloffset], ctimes(v159, tbl[29 + tbloffset])); + real2 v485 = reverse(minus(v173, v93)); + real2 v491 = plus(v93, v173); + real2 v489 = minusplus(uminus(v485), v486); + real2 v487 = minusplus(v485, v486); + real2 v239 = minusplus(uminus(v235), v236); + real2 v237 = minusplus(v235, v236); + real2 v253 = ctimesminusplus(reverse(v239), tbl[44 + tbloffset], ctimes(v239, tbl[45 + tbloffset])); + real2 v497 = ctimesminusplus(reverse(v487), tbl[82 + tbloffset], ctimes(v487, tbl[83 + tbloffset])); + real2 v530 = plus(v490, v491); + real2 v526 = minus(v491, v490); + real2 v503 = ctimesminusplus(reverse(v489), tbl[84 + tbloffset], ctimes(v489, tbl[85 + tbloffset])); + real2 v247 = ctimesminusplus(reverse(v237), tbl[42 + tbloffset], ctimes(v237, tbl[43 + tbloffset])); + real2 v356 = minus(v247, v207); + real2 v360 = plus(v207, v247); + real2 v386 = plus(v213, v253); + real2 v382 = minus(v253, v213); + real2 v17 = load(in, 15 << inShift); + real2 v33 = load(in, 31 << inShift); + real2 v175 = reverse(minus(v33, v17)); + real2 v181 = plus(v17, v33); + real2 v25 = load(in, 23 << inShift); + real2 v9 = load(in, 7 << inShift); + real2 v176 = minus(v25, v9); + real2 v180 = plus(v9, v25); + real2 v177 = minusplus(v175, v176); + real2 v179 = minusplus(uminus(v175), v176); + real2 v193 = ctimesminusplus(reverse(v179), tbl[32 + tbloffset], ctimes(v179, tbl[33 + tbloffset])); + real2 v261 = plus(v180, v181); + real2 v255 = reverse(minus(v181, v180)); + real2 v29 = load(in, 27 << inShift); + real2 v13 = load(in, 11 << inShift); + real2 v101 = plus(v13, v29); + real2 v95 = reverse(minus(v29, v13)); + real2 v21 = load(in, 19 << inShift); + real2 v5 = load(in, 3 << inShift); + real2 v100 = plus(v5, v21); + real2 v96 = minus(v21, v5); + real2 v99 = minusplus(uminus(v95), v96); + real2 v97 = minusplus(v95, v96); + real2 v260 = plus(v100, v101); + real2 v256 = minus(v101, v100); + real2 v259 = minusplus(uminus(v255), v256); + real2 v257 = minusplus(v255, v256); + real2 v273 = ctimesminusplus(reverse(v259), tbl[48 + tbloffset], ctimes(v259, tbl[49 + tbloffset])); + real2 v267 = ctimesminusplus(reverse(v257), tbl[46 + tbloffset], ctimes(v257, tbl[47 + tbloffset])); + real2 v3 = load(in, 1 << inShift); + real2 v19 = load(in, 17 << inShift); + real2 v60 = plus(v3, v19); + real2 v56 = minus(v19, v3); + real2 v27 = load(in, 25 << inShift); + real2 v11 = load(in, 9 << inShift); + real2 v55 = reverse(minus(v27, v11)); + real2 v61 = plus(v11, v27); + real2 v220 = plus(v60, v61); + real2 v216 = minus(v61, v60); + real2 v7 = load(in, 5 << inShift); + real2 v23 = load(in, 21 << inShift); + real2 v136 = minus(v23, v7); + real2 v140 = plus(v7, v23); + real2 v15 = load(in, 13 << inShift); + real2 v31 = load(in, 29 << inShift); + real2 v135 = reverse(minus(v31, v15)); + real2 v141 = plus(v15, v31); + real2 v215 = reverse(minus(v141, v140)); + real2 v221 = plus(v140, v141); + real2 v219 = minusplus(uminus(v215), v216); + real2 v217 = minusplus(v215, v216); + real2 v227 = ctimesminusplus(reverse(v217), tbl[38 + tbloffset], ctimes(v217, tbl[39 + tbloffset])); + real2 v355 = reverse(minus(v267, v227)); + real2 v361 = plus(v227, v267); + store(out, 2 << outShift, plus(v360, v361)); + real2 v374 = minus(v360, v361); + store(out, 18 << outShift, ctimesminusplus(v374, tbl[0 + tbloffset], ctimes(reverse(v374), tbl[1 + tbloffset]))); + real2 v357 = minusplus(v355, v356); + store(out, 10 << outShift, ctimesminusplus(reverse(v357), tbl[62 + tbloffset], ctimes(v357, tbl[63 + tbloffset]))); + real2 v359 = minusplus(uminus(v355), v356); + store(out, 26 << outShift, ctimesminusplus(reverse(v359), tbl[64 + tbloffset], ctimes(v359, tbl[65 + tbloffset]))); + real2 v233 = ctimesminusplus(reverse(v219), tbl[40 + tbloffset], ctimes(v219, tbl[41 + tbloffset])); + real2 v381 = reverse(minus(v273, v233)); + real2 v387 = plus(v233, v273); + store(out, 6 << outShift, plus(v386, v387)); + real2 v400 = minus(v386, v387); + store(out, 22 << outShift, ctimesminusplus(v400, tbl[0 + tbloffset], ctimes(reverse(v400), tbl[1 + tbloffset]))); + real2 v383 = minusplus(v381, v382); + real2 v385 = minusplus(uminus(v381), v382); + store(out, 30 << outShift, ctimesminusplus(reverse(v385), tbl[68 + tbloffset], ctimes(v385, tbl[69 + tbloffset]))); + store(out, 14 << outShift, ctimesminusplus(reverse(v383), tbl[66 + tbloffset], ctimes(v383, tbl[67 + tbloffset]))); + real2 v137 = minusplus(v135, v136); + real2 v139 = minusplus(uminus(v135), v136); + real2 v153 = ctimesminusplus(reverse(v139), tbl[24 + tbloffset], ctimes(v139, tbl[25 + tbloffset])); + real2 v113 = ctimesminusplus(reverse(v99), tbl[16 + tbloffset], ctimes(v99, tbl[17 + tbloffset])); + real2 v511 = plus(v113, v193); + real2 v505 = reverse(minus(v193, v113)); + real2 v57 = minusplus(v55, v56); + real2 v59 = minusplus(uminus(v55), v56); + real2 v73 = ctimesminusplus(reverse(v59), tbl[8 + tbloffset], ctimes(v59, tbl[9 + tbloffset])); + real2 v510 = plus(v73, v153); + real2 v506 = minus(v153, v73); + real2 v531 = plus(v510, v511); + real2 v525 = reverse(minus(v511, v510)); + store(out, 3 << outShift, plus(v530, v531)); + real2 v544 = minus(v530, v531); + store(out, 19 << outShift, ctimesminusplus(v544, tbl[0 + tbloffset], ctimes(reverse(v544), tbl[1 + tbloffset]))); + real2 v527 = minusplus(v525, v526); + store(out, 11 << outShift, ctimesminusplus(reverse(v527), tbl[90 + tbloffset], ctimes(v527, tbl[91 + tbloffset]))); + real2 v529 = minusplus(uminus(v525), v526); + store(out, 27 << outShift, ctimesminusplus(reverse(v529), tbl[92 + tbloffset], ctimes(v529, tbl[93 + tbloffset]))); + real2 v509 = minusplus(uminus(v505), v506); + real2 v507 = minusplus(v505, v506); + real2 v523 = ctimesminusplus(reverse(v509), tbl[88 + tbloffset], ctimes(v509, tbl[89 + tbloffset])); + store(out, 15 << outShift, plus(v503, v523)); + real2 v556 = minus(v503, v523); + store(out, 31 << outShift, ctimesminusplus(v556, tbl[0 + tbloffset], ctimes(reverse(v556), tbl[1 + tbloffset]))); + real2 v517 = ctimesminusplus(reverse(v507), tbl[86 + tbloffset], ctimes(v507, tbl[87 + tbloffset])); + store(out, 7 << outShift, plus(v497, v517)); + real2 v550 = minus(v497, v517); + store(out, 23 << outShift, ctimesminusplus(v550, tbl[0 + tbloffset], ctimes(reverse(v550), tbl[1 + tbloffset]))); + real2 v275 = reverse(minus(v241, v240)); + real2 v281 = plus(v240, v241); + real2 v320 = plus(v280, v281); + real2 v316 = minus(v281, v280); + real2 v301 = plus(v260, v261); + real2 v295 = reverse(minus(v261, v260)); + real2 v300 = plus(v220, v221); + real2 v296 = minus(v221, v220); + real2 v315 = reverse(minus(v301, v300)); + real2 v321 = plus(v300, v301); + store(out, 0 << outShift, plus(v320, v321)); + real2 v334 = minus(v320, v321); + store(out, 16 << outShift, ctimesminusplus(v334, tbl[0 + tbloffset], ctimes(reverse(v334), tbl[1 + tbloffset]))); + real2 v319 = minusplus(uminus(v315), v316); + real2 v317 = minusplus(v315, v316); + store(out, 8 << outShift, ctimesminusplus(reverse(v317), tbl[58 + tbloffset], ctimes(v317, tbl[59 + tbloffset]))); + store(out, 24 << outShift, ctimesminusplus(reverse(v319), tbl[60 + tbloffset], ctimes(v319, tbl[61 + tbloffset]))); + real2 v299 = minusplus(uminus(v295), v296); + real2 v297 = minusplus(v295, v296); + real2 v279 = minusplus(uminus(v275), v276); + real2 v277 = minusplus(v275, v276); + real2 v287 = ctimesminusplus(reverse(v277), tbl[50 + tbloffset], ctimes(v277, tbl[51 + tbloffset])); + real2 v307 = ctimesminusplus(reverse(v297), tbl[54 + tbloffset], ctimes(v297, tbl[55 + tbloffset])); + store(out, 4 << outShift, plus(v287, v307)); + real2 v342 = minus(v287, v307); + store(out, 20 << outShift, ctimesminusplus(v342, tbl[0 + tbloffset], ctimes(reverse(v342), tbl[1 + tbloffset]))); + real2 v313 = ctimesminusplus(reverse(v299), tbl[56 + tbloffset], ctimes(v299, tbl[57 + tbloffset])); + real2 v293 = ctimesminusplus(reverse(v279), tbl[52 + tbloffset], ctimes(v279, tbl[53 + tbloffset])); + store(out, 12 << outShift, plus(v293, v313)); + real2 v348 = minus(v293, v313); + store(out, 28 << outShift, ctimesminusplus(v348, tbl[0 + tbloffset], ctimes(reverse(v348), tbl[1 + tbloffset]))); + real2 v87 = ctimesminusplus(reverse(v77), tbl[10 + tbloffset], ctimes(v77, tbl[11 + tbloffset])); + real2 v147 = ctimesminusplus(reverse(v137), tbl[22 + tbloffset], ctimes(v137, tbl[23 + tbloffset])); + real2 v187 = ctimesminusplus(reverse(v177), tbl[30 + tbloffset], ctimes(v177, tbl[31 + tbloffset])); + real2 v167 = ctimesminusplus(reverse(v157), tbl[26 + tbloffset], ctimes(v157, tbl[27 + tbloffset])); + real2 v413 = plus(v87, v167); + real2 v407 = reverse(minus(v167, v87)); + real2 v67 = ctimesminusplus(reverse(v57), tbl[6 + tbloffset], ctimes(v57, tbl[7 + tbloffset])); + real2 v107 = ctimesminusplus(reverse(v97), tbl[14 + tbloffset], ctimes(v97, tbl[15 + tbloffset])); + real2 v427 = reverse(minus(v187, v107)); + real2 v433 = plus(v107, v187); + real2 v432 = plus(v67, v147); + real2 v428 = minus(v147, v67); + real2 v453 = plus(v432, v433); + real2 v447 = reverse(minus(v433, v432)); + real2 v408 = minus(v127, v47); + real2 v412 = plus(v47, v127); + real2 v452 = plus(v412, v413); + real2 v448 = minus(v413, v412); + store(out, 1 << outShift, plus(v452, v453)); + real2 v466 = minus(v452, v453); + store(out, 17 << outShift, ctimesminusplus(v466, tbl[0 + tbloffset], ctimes(reverse(v466), tbl[1 + tbloffset]))); + real2 v451 = minusplus(uminus(v447), v448); + store(out, 25 << outShift, ctimesminusplus(reverse(v451), tbl[80 + tbloffset], ctimes(v451, tbl[81 + tbloffset]))); + real2 v449 = minusplus(v447, v448); + store(out, 9 << outShift, ctimesminusplus(reverse(v449), tbl[78 + tbloffset], ctimes(v449, tbl[79 + tbloffset]))); + real2 v429 = minusplus(v427, v428); + real2 v431 = minusplus(uminus(v427), v428); + real2 v445 = ctimesminusplus(reverse(v431), tbl[76 + tbloffset], ctimes(v431, tbl[77 + tbloffset])); + real2 v409 = minusplus(v407, v408); + real2 v411 = minusplus(uminus(v407), v408); + real2 v425 = ctimesminusplus(reverse(v411), tbl[72 + tbloffset], ctimes(v411, tbl[73 + tbloffset])); + store(out, 13 << outShift, plus(v425, v445)); + real2 v478 = minus(v425, v445); + store(out, 29 << outShift, ctimesminusplus(v478, tbl[0 + tbloffset], ctimes(reverse(v478), tbl[1 + tbloffset]))); + real2 v439 = ctimesminusplus(reverse(v429), tbl[74 + tbloffset], ctimes(v429, tbl[75 + tbloffset])); + real2 v419 = ctimesminusplus(reverse(v409), tbl[70 + tbloffset], ctimes(v409, tbl[71 + tbloffset])); + store(out, 5 << outShift, plus(v419, v439)); + real2 v472 = minus(v419, v439); + store(out, 21 << outShift, ctimesminusplus(v472, tbl[0 + tbloffset], ctimes(reverse(v472), tbl[1 + tbloffset]))); + } +} + +ALIGNED(8192) void tbut32f_%CONFIG%_%ISA%(real *RESTRICT out0, uint32_t *q, const real *RESTRICT in0, const int inShift, const real *RESTRICT tbl, const int K) { + const int k = 1 << (inShift - LOG2VECWIDTH); + int i=0; +#pragma omp parallel for + for(i=0;i < k;i++) { + int i0 = i << LOG2VECWIDTH; + real *out = out0 + q[i]; + const real *in = in0 + i0*2; + const int tbloffset = K * i0; + + real2 v14 = load(in, 12 << inShift); + real2 v30 = load(in, 28 << inShift); + real2 v115 = reverse(minus(v14, v30)); + real2 v121 = plus(v14, v30); + real2 v6 = load(in, 4 << inShift); + real2 v22 = load(in, 20 << inShift); + real2 v120 = plus(v6, v22); + real2 v116 = minus(v22, v6); + real2 v201 = plus(v120, v121); + real2 v195 = reverse(minus(v120, v121)); + real2 v119 = minusplus(uminus(v115), v116); + real2 v117 = minusplus(v115, v116); + real2 v133 = timesminusplus(reverse(v119), load(tbl, 20 * VECWIDTH + tbloffset), times(v119, load(tbl, 21 * VECWIDTH + tbloffset))); + real2 v127 = timesminusplus(reverse(v117), load(tbl, 18 * VECWIDTH + tbloffset), times(v117, load(tbl, 19 * VECWIDTH + tbloffset))); + real2 v18 = load(in, 16 << inShift); + real2 v2 = load(in, 0 << inShift); + real2 v40 = plus(v2, v18); + real2 v36 = minus(v18, v2); + real2 v10 = load(in, 8 << inShift); + real2 v26 = load(in, 24 << inShift); + real2 v41 = plus(v10, v26); + real2 v35 = reverse(minus(v10, v26)); + real2 v200 = plus(v40, v41); + real2 v196 = minus(v41, v40); + real2 v37 = minusplus(v35, v36); + real2 v39 = minusplus(uminus(v35), v36); + real2 v53 = timesminusplus(reverse(v39), load(tbl, 4 * VECWIDTH + tbloffset), times(v39, load(tbl, 5 * VECWIDTH + tbloffset))); + real2 v276 = minus(v201, v200); + real2 v280 = plus(v200, v201); + real2 v47 = timesminusplus(reverse(v37), load(tbl, 2 * VECWIDTH + tbloffset), times(v37, load(tbl, 3 * VECWIDTH + tbloffset))); + real2 v199 = minusplus(uminus(v195), v196); + real2 v197 = minusplus(v195, v196); + real2 v486 = minus(v133, v53); + real2 v490 = plus(v53, v133); + real2 v213 = timesminusplus(reverse(v199), load(tbl, 36 * VECWIDTH + tbloffset), times(v199, load(tbl, 37 * VECWIDTH + tbloffset))); + real2 v207 = timesminusplus(reverse(v197), load(tbl, 34 * VECWIDTH + tbloffset), times(v197, load(tbl, 35 * VECWIDTH + tbloffset))); + real2 v28 = load(in, 26 << inShift); + real2 v12 = load(in, 10 << inShift); + real2 v81 = plus(v12, v28); + real2 v75 = reverse(minus(v12, v28)); + real2 v20 = load(in, 18 << inShift); + real2 v4 = load(in, 2 << inShift); + real2 v80 = plus(v4, v20); + real2 v76 = minus(v20, v4); + real2 v236 = minus(v81, v80); + real2 v240 = plus(v80, v81); + real2 v77 = minusplus(v75, v76); + real2 v79 = minusplus(uminus(v75), v76); + real2 v93 = timesminusplus(reverse(v79), load(tbl, 12 * VECWIDTH + tbloffset), times(v79, load(tbl, 13 * VECWIDTH + tbloffset))); + real2 v32 = load(in, 30 << inShift); + real2 v16 = load(in, 14 << inShift); + real2 v155 = reverse(minus(v16, v32)); + real2 v161 = plus(v16, v32); + real2 v24 = load(in, 22 << inShift); + real2 v8 = load(in, 6 << inShift); + real2 v160 = plus(v8, v24); + real2 v156 = minus(v24, v8); + real2 v235 = reverse(minus(v160, v161)); + real2 v241 = plus(v160, v161); + real2 v157 = minusplus(v155, v156); + real2 v159 = minusplus(uminus(v155), v156); + real2 v173 = timesminusplus(reverse(v159), load(tbl, 28 * VECWIDTH + tbloffset), times(v159, load(tbl, 29 * VECWIDTH + tbloffset))); + real2 v485 = reverse(minus(v93, v173)); + real2 v491 = plus(v93, v173); + real2 v489 = minusplus(uminus(v485), v486); + real2 v487 = minusplus(v485, v486); + real2 v239 = minusplus(uminus(v235), v236); + real2 v237 = minusplus(v235, v236); + real2 v253 = timesminusplus(reverse(v239), load(tbl, 44 * VECWIDTH + tbloffset), times(v239, load(tbl, 45 * VECWIDTH + tbloffset))); + real2 v497 = timesminusplus(reverse(v487), load(tbl, 82 * VECWIDTH + tbloffset), times(v487, load(tbl, 83 * VECWIDTH + tbloffset))); + real2 v530 = plus(v490, v491); + real2 v526 = minus(v491, v490); + real2 v503 = timesminusplus(reverse(v489), load(tbl, 84 * VECWIDTH + tbloffset), times(v489, load(tbl, 85 * VECWIDTH + tbloffset))); + real2 v247 = timesminusplus(reverse(v237), load(tbl, 42 * VECWIDTH + tbloffset), times(v237, load(tbl, 43 * VECWIDTH + tbloffset))); + real2 v356 = minus(v247, v207); + real2 v360 = plus(v207, v247); + real2 v386 = plus(v213, v253); + real2 v382 = minus(v253, v213); + real2 v17 = load(in, 15 << inShift); + real2 v33 = load(in, 31 << inShift); + real2 v175 = reverse(minus(v17, v33)); + real2 v181 = plus(v17, v33); + real2 v25 = load(in, 23 << inShift); + real2 v9 = load(in, 7 << inShift); + real2 v176 = minus(v25, v9); + real2 v180 = plus(v9, v25); + real2 v177 = minusplus(v175, v176); + real2 v179 = minusplus(uminus(v175), v176); + real2 v193 = timesminusplus(reverse(v179), load(tbl, 32 * VECWIDTH + tbloffset), times(v179, load(tbl, 33 * VECWIDTH + tbloffset))); + real2 v261 = plus(v180, v181); + real2 v255 = reverse(minus(v180, v181)); + real2 v29 = load(in, 27 << inShift); + real2 v13 = load(in, 11 << inShift); + real2 v101 = plus(v13, v29); + real2 v95 = reverse(minus(v13, v29)); + real2 v21 = load(in, 19 << inShift); + real2 v5 = load(in, 3 << inShift); + real2 v100 = plus(v5, v21); + real2 v96 = minus(v21, v5); + real2 v99 = minusplus(uminus(v95), v96); + real2 v97 = minusplus(v95, v96); + real2 v260 = plus(v100, v101); + real2 v256 = minus(v101, v100); + real2 v259 = minusplus(uminus(v255), v256); + real2 v257 = minusplus(v255, v256); + real2 v273 = timesminusplus(reverse(v259), load(tbl, 48 * VECWIDTH + tbloffset), times(v259, load(tbl, 49 * VECWIDTH + tbloffset))); + real2 v267 = timesminusplus(reverse(v257), load(tbl, 46 * VECWIDTH + tbloffset), times(v257, load(tbl, 47 * VECWIDTH + tbloffset))); + real2 v3 = load(in, 1 << inShift); + real2 v19 = load(in, 17 << inShift); + real2 v60 = plus(v3, v19); + real2 v56 = minus(v19, v3); + real2 v27 = load(in, 25 << inShift); + real2 v11 = load(in, 9 << inShift); + real2 v55 = reverse(minus(v11, v27)); + real2 v61 = plus(v11, v27); + real2 v220 = plus(v60, v61); + real2 v216 = minus(v61, v60); + real2 v7 = load(in, 5 << inShift); + real2 v23 = load(in, 21 << inShift); + real2 v136 = minus(v23, v7); + real2 v140 = plus(v7, v23); + real2 v15 = load(in, 13 << inShift); + real2 v31 = load(in, 29 << inShift); + real2 v135 = reverse(minus(v15, v31)); + real2 v141 = plus(v15, v31); + real2 v215 = reverse(minus(v140, v141)); + real2 v221 = plus(v140, v141); + real2 v219 = minusplus(uminus(v215), v216); + real2 v217 = minusplus(v215, v216); + real2 v227 = timesminusplus(reverse(v217), load(tbl, 38 * VECWIDTH + tbloffset), times(v217, load(tbl, 39 * VECWIDTH + tbloffset))); + real2 v355 = reverse(minus(v227, v267)); + real2 v361 = plus(v227, v267); + scatter(out, 2, 32, plus(v360, v361)); + real2 v374 = minus(v360, v361); + scatter(out, 18, 32, timesminusplus(v374, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v374), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v357 = minusplus(v355, v356); + scatter(out, 10, 32, timesminusplus(reverse(v357), load(tbl, 62 * VECWIDTH + tbloffset), times(v357, load(tbl, 63 * VECWIDTH + tbloffset)))); + real2 v359 = minusplus(uminus(v355), v356); + scatter(out, 26, 32, timesminusplus(reverse(v359), load(tbl, 64 * VECWIDTH + tbloffset), times(v359, load(tbl, 65 * VECWIDTH + tbloffset)))); + real2 v233 = timesminusplus(reverse(v219), load(tbl, 40 * VECWIDTH + tbloffset), times(v219, load(tbl, 41 * VECWIDTH + tbloffset))); + real2 v381 = reverse(minus(v233, v273)); + real2 v387 = plus(v233, v273); + scatter(out, 6, 32, plus(v386, v387)); + real2 v400 = minus(v386, v387); + scatter(out, 22, 32, timesminusplus(v400, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v400), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v383 = minusplus(v381, v382); + real2 v385 = minusplus(uminus(v381), v382); + scatter(out, 30, 32, timesminusplus(reverse(v385), load(tbl, 68 * VECWIDTH + tbloffset), times(v385, load(tbl, 69 * VECWIDTH + tbloffset)))); + scatter(out, 14, 32, timesminusplus(reverse(v383), load(tbl, 66 * VECWIDTH + tbloffset), times(v383, load(tbl, 67 * VECWIDTH + tbloffset)))); + real2 v137 = minusplus(v135, v136); + real2 v139 = minusplus(uminus(v135), v136); + real2 v153 = timesminusplus(reverse(v139), load(tbl, 24 * VECWIDTH + tbloffset), times(v139, load(tbl, 25 * VECWIDTH + tbloffset))); + real2 v113 = timesminusplus(reverse(v99), load(tbl, 16 * VECWIDTH + tbloffset), times(v99, load(tbl, 17 * VECWIDTH + tbloffset))); + real2 v511 = plus(v113, v193); + real2 v505 = reverse(minus(v113, v193)); + real2 v57 = minusplus(v55, v56); + real2 v59 = minusplus(uminus(v55), v56); + real2 v73 = timesminusplus(reverse(v59), load(tbl, 8 * VECWIDTH + tbloffset), times(v59, load(tbl, 9 * VECWIDTH + tbloffset))); + real2 v510 = plus(v73, v153); + real2 v506 = minus(v153, v73); + real2 v531 = plus(v510, v511); + real2 v525 = reverse(minus(v510, v511)); + scatter(out, 3, 32, plus(v530, v531)); + real2 v544 = minus(v530, v531); + scatter(out, 19, 32, timesminusplus(v544, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v544), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v527 = minusplus(v525, v526); + scatter(out, 11, 32, timesminusplus(reverse(v527), load(tbl, 90 * VECWIDTH + tbloffset), times(v527, load(tbl, 91 * VECWIDTH + tbloffset)))); + real2 v529 = minusplus(uminus(v525), v526); + scatter(out, 27, 32, timesminusplus(reverse(v529), load(tbl, 92 * VECWIDTH + tbloffset), times(v529, load(tbl, 93 * VECWIDTH + tbloffset)))); + real2 v509 = minusplus(uminus(v505), v506); + real2 v507 = minusplus(v505, v506); + real2 v523 = timesminusplus(reverse(v509), load(tbl, 88 * VECWIDTH + tbloffset), times(v509, load(tbl, 89 * VECWIDTH + tbloffset))); + scatter(out, 15, 32, plus(v503, v523)); + real2 v556 = minus(v503, v523); + scatter(out, 31, 32, timesminusplus(v556, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v556), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v517 = timesminusplus(reverse(v507), load(tbl, 86 * VECWIDTH + tbloffset), times(v507, load(tbl, 87 * VECWIDTH + tbloffset))); + scatter(out, 7, 32, plus(v497, v517)); + real2 v550 = minus(v497, v517); + scatter(out, 23, 32, timesminusplus(v550, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v550), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v275 = reverse(minus(v240, v241)); + real2 v281 = plus(v240, v241); + real2 v320 = plus(v280, v281); + real2 v316 = minus(v281, v280); + real2 v301 = plus(v260, v261); + real2 v295 = reverse(minus(v260, v261)); + real2 v300 = plus(v220, v221); + real2 v296 = minus(v221, v220); + real2 v315 = reverse(minus(v300, v301)); + real2 v321 = plus(v300, v301); + scatter(out, 0, 32, plus(v320, v321)); + real2 v334 = minus(v320, v321); + scatter(out, 16, 32, timesminusplus(v334, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v334), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v319 = minusplus(uminus(v315), v316); + real2 v317 = minusplus(v315, v316); + scatter(out, 8, 32, timesminusplus(reverse(v317), load(tbl, 58 * VECWIDTH + tbloffset), times(v317, load(tbl, 59 * VECWIDTH + tbloffset)))); + scatter(out, 24, 32, timesminusplus(reverse(v319), load(tbl, 60 * VECWIDTH + tbloffset), times(v319, load(tbl, 61 * VECWIDTH + tbloffset)))); + real2 v299 = minusplus(uminus(v295), v296); + real2 v297 = minusplus(v295, v296); + real2 v279 = minusplus(uminus(v275), v276); + real2 v277 = minusplus(v275, v276); + real2 v287 = timesminusplus(reverse(v277), load(tbl, 50 * VECWIDTH + tbloffset), times(v277, load(tbl, 51 * VECWIDTH + tbloffset))); + real2 v307 = timesminusplus(reverse(v297), load(tbl, 54 * VECWIDTH + tbloffset), times(v297, load(tbl, 55 * VECWIDTH + tbloffset))); + scatter(out, 4, 32, plus(v287, v307)); + real2 v342 = minus(v287, v307); + scatter(out, 20, 32, timesminusplus(v342, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v342), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v313 = timesminusplus(reverse(v299), load(tbl, 56 * VECWIDTH + tbloffset), times(v299, load(tbl, 57 * VECWIDTH + tbloffset))); + real2 v293 = timesminusplus(reverse(v279), load(tbl, 52 * VECWIDTH + tbloffset), times(v279, load(tbl, 53 * VECWIDTH + tbloffset))); + scatter(out, 12, 32, plus(v293, v313)); + real2 v348 = minus(v293, v313); + scatter(out, 28, 32, timesminusplus(v348, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v348), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v87 = timesminusplus(reverse(v77), load(tbl, 10 * VECWIDTH + tbloffset), times(v77, load(tbl, 11 * VECWIDTH + tbloffset))); + real2 v147 = timesminusplus(reverse(v137), load(tbl, 22 * VECWIDTH + tbloffset), times(v137, load(tbl, 23 * VECWIDTH + tbloffset))); + real2 v187 = timesminusplus(reverse(v177), load(tbl, 30 * VECWIDTH + tbloffset), times(v177, load(tbl, 31 * VECWIDTH + tbloffset))); + real2 v167 = timesminusplus(reverse(v157), load(tbl, 26 * VECWIDTH + tbloffset), times(v157, load(tbl, 27 * VECWIDTH + tbloffset))); + real2 v413 = plus(v87, v167); + real2 v407 = reverse(minus(v87, v167)); + real2 v67 = timesminusplus(reverse(v57), load(tbl, 6 * VECWIDTH + tbloffset), times(v57, load(tbl, 7 * VECWIDTH + tbloffset))); + real2 v107 = timesminusplus(reverse(v97), load(tbl, 14 * VECWIDTH + tbloffset), times(v97, load(tbl, 15 * VECWIDTH + tbloffset))); + real2 v427 = reverse(minus(v107, v187)); + real2 v433 = plus(v107, v187); + real2 v432 = plus(v67, v147); + real2 v428 = minus(v147, v67); + real2 v453 = plus(v432, v433); + real2 v447 = reverse(minus(v432, v433)); + real2 v408 = minus(v127, v47); + real2 v412 = plus(v47, v127); + real2 v452 = plus(v412, v413); + real2 v448 = minus(v413, v412); + scatter(out, 1, 32, plus(v452, v453)); + real2 v466 = minus(v452, v453); + scatter(out, 17, 32, timesminusplus(v466, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v466), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v451 = minusplus(uminus(v447), v448); + scatter(out, 25, 32, timesminusplus(reverse(v451), load(tbl, 80 * VECWIDTH + tbloffset), times(v451, load(tbl, 81 * VECWIDTH + tbloffset)))); + real2 v449 = minusplus(v447, v448); + scatter(out, 9, 32, timesminusplus(reverse(v449), load(tbl, 78 * VECWIDTH + tbloffset), times(v449, load(tbl, 79 * VECWIDTH + tbloffset)))); + real2 v429 = minusplus(v427, v428); + real2 v431 = minusplus(uminus(v427), v428); + real2 v445 = timesminusplus(reverse(v431), load(tbl, 76 * VECWIDTH + tbloffset), times(v431, load(tbl, 77 * VECWIDTH + tbloffset))); + real2 v409 = minusplus(v407, v408); + real2 v411 = minusplus(uminus(v407), v408); + real2 v425 = timesminusplus(reverse(v411), load(tbl, 72 * VECWIDTH + tbloffset), times(v411, load(tbl, 73 * VECWIDTH + tbloffset))); + scatter(out, 13, 32, plus(v425, v445)); + real2 v478 = minus(v425, v445); + scatter(out, 29, 32, timesminusplus(v478, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v478), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v439 = timesminusplus(reverse(v429), load(tbl, 74 * VECWIDTH + tbloffset), times(v429, load(tbl, 75 * VECWIDTH + tbloffset))); + real2 v419 = timesminusplus(reverse(v409), load(tbl, 70 * VECWIDTH + tbloffset), times(v409, load(tbl, 71 * VECWIDTH + tbloffset))); + scatter(out, 5, 32, plus(v419, v439)); + real2 v472 = minus(v419, v439); + scatter(out, 21, 32, timesminusplus(v472, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v472), load(tbl, 1 * VECWIDTH + tbloffset)))); + } +} + +ALIGNED(8192) void tbut32b_%CONFIG%_%ISA%(real *RESTRICT out0, uint32_t *q, const real *RESTRICT in0, const int inShift, const real *RESTRICT tbl, const int K) { + const int k = 1 << (inShift - LOG2VECWIDTH); + int i=0; +#pragma omp parallel for + for(i=0;i < k;i++) { + int i0 = i << LOG2VECWIDTH; + real *out = out0 + q[i]; + const real *in = in0 + i0*2; + const int tbloffset = K * i0; + + real2 v14 = load(in, 12 << inShift); + real2 v30 = load(in, 28 << inShift); + real2 v115 = reverse(minus(v30, v14)); + real2 v121 = plus(v14, v30); + real2 v6 = load(in, 4 << inShift); + real2 v22 = load(in, 20 << inShift); + real2 v120 = plus(v6, v22); + real2 v116 = minus(v22, v6); + real2 v201 = plus(v120, v121); + real2 v195 = reverse(minus(v121, v120)); + real2 v119 = minusplus(uminus(v115), v116); + real2 v117 = minusplus(v115, v116); + real2 v133 = timesminusplus(reverse(v119), load(tbl, 20 * VECWIDTH + tbloffset), times(v119, load(tbl, 21 * VECWIDTH + tbloffset))); + real2 v127 = timesminusplus(reverse(v117), load(tbl, 18 * VECWIDTH + tbloffset), times(v117, load(tbl, 19 * VECWIDTH + tbloffset))); + real2 v18 = load(in, 16 << inShift); + real2 v2 = load(in, 0 << inShift); + real2 v40 = plus(v2, v18); + real2 v36 = minus(v18, v2); + real2 v10 = load(in, 8 << inShift); + real2 v26 = load(in, 24 << inShift); + real2 v41 = plus(v10, v26); + real2 v35 = reverse(minus(v26, v10)); + real2 v200 = plus(v40, v41); + real2 v196 = minus(v41, v40); + real2 v37 = minusplus(v35, v36); + real2 v39 = minusplus(uminus(v35), v36); + real2 v53 = timesminusplus(reverse(v39), load(tbl, 4 * VECWIDTH + tbloffset), times(v39, load(tbl, 5 * VECWIDTH + tbloffset))); + real2 v276 = minus(v201, v200); + real2 v280 = plus(v200, v201); + real2 v47 = timesminusplus(reverse(v37), load(tbl, 2 * VECWIDTH + tbloffset), times(v37, load(tbl, 3 * VECWIDTH + tbloffset))); + real2 v199 = minusplus(uminus(v195), v196); + real2 v197 = minusplus(v195, v196); + real2 v486 = minus(v133, v53); + real2 v490 = plus(v53, v133); + real2 v213 = timesminusplus(reverse(v199), load(tbl, 36 * VECWIDTH + tbloffset), times(v199, load(tbl, 37 * VECWIDTH + tbloffset))); + real2 v207 = timesminusplus(reverse(v197), load(tbl, 34 * VECWIDTH + tbloffset), times(v197, load(tbl, 35 * VECWIDTH + tbloffset))); + real2 v28 = load(in, 26 << inShift); + real2 v12 = load(in, 10 << inShift); + real2 v81 = plus(v12, v28); + real2 v75 = reverse(minus(v28, v12)); + real2 v20 = load(in, 18 << inShift); + real2 v4 = load(in, 2 << inShift); + real2 v80 = plus(v4, v20); + real2 v76 = minus(v20, v4); + real2 v236 = minus(v81, v80); + real2 v240 = plus(v80, v81); + real2 v77 = minusplus(v75, v76); + real2 v79 = minusplus(uminus(v75), v76); + real2 v93 = timesminusplus(reverse(v79), load(tbl, 12 * VECWIDTH + tbloffset), times(v79, load(tbl, 13 * VECWIDTH + tbloffset))); + real2 v32 = load(in, 30 << inShift); + real2 v16 = load(in, 14 << inShift); + real2 v155 = reverse(minus(v32, v16)); + real2 v161 = plus(v16, v32); + real2 v24 = load(in, 22 << inShift); + real2 v8 = load(in, 6 << inShift); + real2 v160 = plus(v8, v24); + real2 v156 = minus(v24, v8); + real2 v235 = reverse(minus(v161, v160)); + real2 v241 = plus(v160, v161); + real2 v157 = minusplus(v155, v156); + real2 v159 = minusplus(uminus(v155), v156); + real2 v173 = timesminusplus(reverse(v159), load(tbl, 28 * VECWIDTH + tbloffset), times(v159, load(tbl, 29 * VECWIDTH + tbloffset))); + real2 v485 = reverse(minus(v173, v93)); + real2 v491 = plus(v93, v173); + real2 v489 = minusplus(uminus(v485), v486); + real2 v487 = minusplus(v485, v486); + real2 v239 = minusplus(uminus(v235), v236); + real2 v237 = minusplus(v235, v236); + real2 v253 = timesminusplus(reverse(v239), load(tbl, 44 * VECWIDTH + tbloffset), times(v239, load(tbl, 45 * VECWIDTH + tbloffset))); + real2 v497 = timesminusplus(reverse(v487), load(tbl, 82 * VECWIDTH + tbloffset), times(v487, load(tbl, 83 * VECWIDTH + tbloffset))); + real2 v530 = plus(v490, v491); + real2 v526 = minus(v491, v490); + real2 v503 = timesminusplus(reverse(v489), load(tbl, 84 * VECWIDTH + tbloffset), times(v489, load(tbl, 85 * VECWIDTH + tbloffset))); + real2 v247 = timesminusplus(reverse(v237), load(tbl, 42 * VECWIDTH + tbloffset), times(v237, load(tbl, 43 * VECWIDTH + tbloffset))); + real2 v356 = minus(v247, v207); + real2 v360 = plus(v207, v247); + real2 v386 = plus(v213, v253); + real2 v382 = minus(v253, v213); + real2 v17 = load(in, 15 << inShift); + real2 v33 = load(in, 31 << inShift); + real2 v175 = reverse(minus(v33, v17)); + real2 v181 = plus(v17, v33); + real2 v25 = load(in, 23 << inShift); + real2 v9 = load(in, 7 << inShift); + real2 v176 = minus(v25, v9); + real2 v180 = plus(v9, v25); + real2 v177 = minusplus(v175, v176); + real2 v179 = minusplus(uminus(v175), v176); + real2 v193 = timesminusplus(reverse(v179), load(tbl, 32 * VECWIDTH + tbloffset), times(v179, load(tbl, 33 * VECWIDTH + tbloffset))); + real2 v261 = plus(v180, v181); + real2 v255 = reverse(minus(v181, v180)); + real2 v29 = load(in, 27 << inShift); + real2 v13 = load(in, 11 << inShift); + real2 v101 = plus(v13, v29); + real2 v95 = reverse(minus(v29, v13)); + real2 v21 = load(in, 19 << inShift); + real2 v5 = load(in, 3 << inShift); + real2 v100 = plus(v5, v21); + real2 v96 = minus(v21, v5); + real2 v99 = minusplus(uminus(v95), v96); + real2 v97 = minusplus(v95, v96); + real2 v260 = plus(v100, v101); + real2 v256 = minus(v101, v100); + real2 v259 = minusplus(uminus(v255), v256); + real2 v257 = minusplus(v255, v256); + real2 v273 = timesminusplus(reverse(v259), load(tbl, 48 * VECWIDTH + tbloffset), times(v259, load(tbl, 49 * VECWIDTH + tbloffset))); + real2 v267 = timesminusplus(reverse(v257), load(tbl, 46 * VECWIDTH + tbloffset), times(v257, load(tbl, 47 * VECWIDTH + tbloffset))); + real2 v3 = load(in, 1 << inShift); + real2 v19 = load(in, 17 << inShift); + real2 v60 = plus(v3, v19); + real2 v56 = minus(v19, v3); + real2 v27 = load(in, 25 << inShift); + real2 v11 = load(in, 9 << inShift); + real2 v55 = reverse(minus(v27, v11)); + real2 v61 = plus(v11, v27); + real2 v220 = plus(v60, v61); + real2 v216 = minus(v61, v60); + real2 v7 = load(in, 5 << inShift); + real2 v23 = load(in, 21 << inShift); + real2 v136 = minus(v23, v7); + real2 v140 = plus(v7, v23); + real2 v15 = load(in, 13 << inShift); + real2 v31 = load(in, 29 << inShift); + real2 v135 = reverse(minus(v31, v15)); + real2 v141 = plus(v15, v31); + real2 v215 = reverse(minus(v141, v140)); + real2 v221 = plus(v140, v141); + real2 v219 = minusplus(uminus(v215), v216); + real2 v217 = minusplus(v215, v216); + real2 v227 = timesminusplus(reverse(v217), load(tbl, 38 * VECWIDTH + tbloffset), times(v217, load(tbl, 39 * VECWIDTH + tbloffset))); + real2 v355 = reverse(minus(v267, v227)); + real2 v361 = plus(v227, v267); + scatter(out, 2, 32, plus(v360, v361)); + real2 v374 = minus(v360, v361); + scatter(out, 18, 32, timesminusplus(v374, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v374), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v357 = minusplus(v355, v356); + scatter(out, 10, 32, timesminusplus(reverse(v357), load(tbl, 62 * VECWIDTH + tbloffset), times(v357, load(tbl, 63 * VECWIDTH + tbloffset)))); + real2 v359 = minusplus(uminus(v355), v356); + scatter(out, 26, 32, timesminusplus(reverse(v359), load(tbl, 64 * VECWIDTH + tbloffset), times(v359, load(tbl, 65 * VECWIDTH + tbloffset)))); + real2 v233 = timesminusplus(reverse(v219), load(tbl, 40 * VECWIDTH + tbloffset), times(v219, load(tbl, 41 * VECWIDTH + tbloffset))); + real2 v381 = reverse(minus(v273, v233)); + real2 v387 = plus(v233, v273); + scatter(out, 6, 32, plus(v386, v387)); + real2 v400 = minus(v386, v387); + scatter(out, 22, 32, timesminusplus(v400, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v400), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v383 = minusplus(v381, v382); + real2 v385 = minusplus(uminus(v381), v382); + scatter(out, 30, 32, timesminusplus(reverse(v385), load(tbl, 68 * VECWIDTH + tbloffset), times(v385, load(tbl, 69 * VECWIDTH + tbloffset)))); + scatter(out, 14, 32, timesminusplus(reverse(v383), load(tbl, 66 * VECWIDTH + tbloffset), times(v383, load(tbl, 67 * VECWIDTH + tbloffset)))); + real2 v137 = minusplus(v135, v136); + real2 v139 = minusplus(uminus(v135), v136); + real2 v153 = timesminusplus(reverse(v139), load(tbl, 24 * VECWIDTH + tbloffset), times(v139, load(tbl, 25 * VECWIDTH + tbloffset))); + real2 v113 = timesminusplus(reverse(v99), load(tbl, 16 * VECWIDTH + tbloffset), times(v99, load(tbl, 17 * VECWIDTH + tbloffset))); + real2 v511 = plus(v113, v193); + real2 v505 = reverse(minus(v193, v113)); + real2 v57 = minusplus(v55, v56); + real2 v59 = minusplus(uminus(v55), v56); + real2 v73 = timesminusplus(reverse(v59), load(tbl, 8 * VECWIDTH + tbloffset), times(v59, load(tbl, 9 * VECWIDTH + tbloffset))); + real2 v510 = plus(v73, v153); + real2 v506 = minus(v153, v73); + real2 v531 = plus(v510, v511); + real2 v525 = reverse(minus(v511, v510)); + scatter(out, 3, 32, plus(v530, v531)); + real2 v544 = minus(v530, v531); + scatter(out, 19, 32, timesminusplus(v544, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v544), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v527 = minusplus(v525, v526); + scatter(out, 11, 32, timesminusplus(reverse(v527), load(tbl, 90 * VECWIDTH + tbloffset), times(v527, load(tbl, 91 * VECWIDTH + tbloffset)))); + real2 v529 = minusplus(uminus(v525), v526); + scatter(out, 27, 32, timesminusplus(reverse(v529), load(tbl, 92 * VECWIDTH + tbloffset), times(v529, load(tbl, 93 * VECWIDTH + tbloffset)))); + real2 v509 = minusplus(uminus(v505), v506); + real2 v507 = minusplus(v505, v506); + real2 v523 = timesminusplus(reverse(v509), load(tbl, 88 * VECWIDTH + tbloffset), times(v509, load(tbl, 89 * VECWIDTH + tbloffset))); + scatter(out, 15, 32, plus(v503, v523)); + real2 v556 = minus(v503, v523); + scatter(out, 31, 32, timesminusplus(v556, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v556), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v517 = timesminusplus(reverse(v507), load(tbl, 86 * VECWIDTH + tbloffset), times(v507, load(tbl, 87 * VECWIDTH + tbloffset))); + scatter(out, 7, 32, plus(v497, v517)); + real2 v550 = minus(v497, v517); + scatter(out, 23, 32, timesminusplus(v550, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v550), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v275 = reverse(minus(v241, v240)); + real2 v281 = plus(v240, v241); + real2 v320 = plus(v280, v281); + real2 v316 = minus(v281, v280); + real2 v301 = plus(v260, v261); + real2 v295 = reverse(minus(v261, v260)); + real2 v300 = plus(v220, v221); + real2 v296 = minus(v221, v220); + real2 v315 = reverse(minus(v301, v300)); + real2 v321 = plus(v300, v301); + scatter(out, 0, 32, plus(v320, v321)); + real2 v334 = minus(v320, v321); + scatter(out, 16, 32, timesminusplus(v334, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v334), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v319 = minusplus(uminus(v315), v316); + real2 v317 = minusplus(v315, v316); + scatter(out, 8, 32, timesminusplus(reverse(v317), load(tbl, 58 * VECWIDTH + tbloffset), times(v317, load(tbl, 59 * VECWIDTH + tbloffset)))); + scatter(out, 24, 32, timesminusplus(reverse(v319), load(tbl, 60 * VECWIDTH + tbloffset), times(v319, load(tbl, 61 * VECWIDTH + tbloffset)))); + real2 v299 = minusplus(uminus(v295), v296); + real2 v297 = minusplus(v295, v296); + real2 v279 = minusplus(uminus(v275), v276); + real2 v277 = minusplus(v275, v276); + real2 v287 = timesminusplus(reverse(v277), load(tbl, 50 * VECWIDTH + tbloffset), times(v277, load(tbl, 51 * VECWIDTH + tbloffset))); + real2 v307 = timesminusplus(reverse(v297), load(tbl, 54 * VECWIDTH + tbloffset), times(v297, load(tbl, 55 * VECWIDTH + tbloffset))); + scatter(out, 4, 32, plus(v287, v307)); + real2 v342 = minus(v287, v307); + scatter(out, 20, 32, timesminusplus(v342, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v342), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v313 = timesminusplus(reverse(v299), load(tbl, 56 * VECWIDTH + tbloffset), times(v299, load(tbl, 57 * VECWIDTH + tbloffset))); + real2 v293 = timesminusplus(reverse(v279), load(tbl, 52 * VECWIDTH + tbloffset), times(v279, load(tbl, 53 * VECWIDTH + tbloffset))); + scatter(out, 12, 32, plus(v293, v313)); + real2 v348 = minus(v293, v313); + scatter(out, 28, 32, timesminusplus(v348, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v348), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v87 = timesminusplus(reverse(v77), load(tbl, 10 * VECWIDTH + tbloffset), times(v77, load(tbl, 11 * VECWIDTH + tbloffset))); + real2 v147 = timesminusplus(reverse(v137), load(tbl, 22 * VECWIDTH + tbloffset), times(v137, load(tbl, 23 * VECWIDTH + tbloffset))); + real2 v187 = timesminusplus(reverse(v177), load(tbl, 30 * VECWIDTH + tbloffset), times(v177, load(tbl, 31 * VECWIDTH + tbloffset))); + real2 v167 = timesminusplus(reverse(v157), load(tbl, 26 * VECWIDTH + tbloffset), times(v157, load(tbl, 27 * VECWIDTH + tbloffset))); + real2 v413 = plus(v87, v167); + real2 v407 = reverse(minus(v167, v87)); + real2 v67 = timesminusplus(reverse(v57), load(tbl, 6 * VECWIDTH + tbloffset), times(v57, load(tbl, 7 * VECWIDTH + tbloffset))); + real2 v107 = timesminusplus(reverse(v97), load(tbl, 14 * VECWIDTH + tbloffset), times(v97, load(tbl, 15 * VECWIDTH + tbloffset))); + real2 v427 = reverse(minus(v187, v107)); + real2 v433 = plus(v107, v187); + real2 v432 = plus(v67, v147); + real2 v428 = minus(v147, v67); + real2 v453 = plus(v432, v433); + real2 v447 = reverse(minus(v433, v432)); + real2 v408 = minus(v127, v47); + real2 v412 = plus(v47, v127); + real2 v452 = plus(v412, v413); + real2 v448 = minus(v413, v412); + scatter(out, 1, 32, plus(v452, v453)); + real2 v466 = minus(v452, v453); + scatter(out, 17, 32, timesminusplus(v466, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v466), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v451 = minusplus(uminus(v447), v448); + scatter(out, 25, 32, timesminusplus(reverse(v451), load(tbl, 80 * VECWIDTH + tbloffset), times(v451, load(tbl, 81 * VECWIDTH + tbloffset)))); + real2 v449 = minusplus(v447, v448); + scatter(out, 9, 32, timesminusplus(reverse(v449), load(tbl, 78 * VECWIDTH + tbloffset), times(v449, load(tbl, 79 * VECWIDTH + tbloffset)))); + real2 v429 = minusplus(v427, v428); + real2 v431 = minusplus(uminus(v427), v428); + real2 v445 = timesminusplus(reverse(v431), load(tbl, 76 * VECWIDTH + tbloffset), times(v431, load(tbl, 77 * VECWIDTH + tbloffset))); + real2 v409 = minusplus(v407, v408); + real2 v411 = minusplus(uminus(v407), v408); + real2 v425 = timesminusplus(reverse(v411), load(tbl, 72 * VECWIDTH + tbloffset), times(v411, load(tbl, 73 * VECWIDTH + tbloffset))); + scatter(out, 13, 32, plus(v425, v445)); + real2 v478 = minus(v425, v445); + scatter(out, 29, 32, timesminusplus(v478, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v478), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v439 = timesminusplus(reverse(v429), load(tbl, 74 * VECWIDTH + tbloffset), times(v429, load(tbl, 75 * VECWIDTH + tbloffset))); + real2 v419 = timesminusplus(reverse(v409), load(tbl, 70 * VECWIDTH + tbloffset), times(v409, load(tbl, 71 * VECWIDTH + tbloffset))); + scatter(out, 5, 32, plus(v419, v439)); + real2 v472 = minus(v419, v439); + scatter(out, 21, 32, timesminusplus(v472, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v472), load(tbl, 1 * VECWIDTH + tbloffset)))); + } +} +#endif + +#if MAXBUTWIDTH >= 6 +ALIGNED(8192) void dft64f_%CONFIG%_%ISA%(real *RESTRICT out0, const real *RESTRICT in0, const int shift) { + const int k = 1 << (shift - LOG2VECWIDTH); + int i=0; +#pragma omp parallel for + for(i=0;i < k;i++) { + int i0 = i << LOG2VECWIDTH; + real *out = out0 + i0*2; + const real *in = in0 + i0*2; + +// Pres : 27834 + real2 v13 = load(in, 11 << shift); + real2 v45 = load(in, 43 << shift); + real2 v268 = plus(v13, v45); + real2 v264 = minus(v45, v13); + real2 v61 = load(in, 59 << shift); + real2 v29 = load(in, 27 << shift); + real2 v269 = plus(v29, v61); + real2 v263 = reverse(minus(v29, v61)); + real2 v401 = reverse(minus(v268, v269)); + real2 v407 = plus(v268, v269); + real2 v267 = minusplus(uminus(v263), v264); + real2 v265 = minusplus(v263, v264); + real2 v279 = ctimesminusplus(reverse(v267), ctbl[28], ctimes(v267, ctbl[14])); + real2 v273 = ctimesminusplus(reverse(v265), ctbl[25], ctimes(v265, ctbl[19])); + real2 v5 = load(in, 3 << shift); + real2 v37 = load(in, 35 << shift); + real2 v124 = minus(v37, v5); + real2 v128 = plus(v5, v37); + real2 v21 = load(in, 19 << shift); + real2 v53 = load(in, 51 << shift); + real2 v129 = plus(v21, v53); + real2 v123 = reverse(minus(v21, v53)); + real2 v402 = minus(v129, v128); + real2 v406 = plus(v128, v129); + real2 v405 = minusplus(uminus(v401), v402); + real2 v403 = minusplus(v401, v402); + real2 v415 = ctimesminusplus(reverse(v405), ctbl[13], ctimes(v405, ctbl[12])); + real2 v411 = ctimesminusplus(reverse(v403), ctbl[11], ctimes(v403, ctbl[9])); + real2 v125 = minusplus(v123, v124); + real2 v127 = minusplus(uminus(v123), v124); + real2 v139 = ctimesminusplus(reverse(v127), ctbl[17], ctimes(v127, ctbl[27])); + real2 v534 = plus(v406, v407); + real2 v530 = minus(v407, v406); + real2 v962 = minus(v279, v139); + real2 v966 = plus(v139, v279); + real2 v133 = ctimesminusplus(reverse(v125), ctbl[23], ctimes(v125, ctbl[21])); + real2 v807 = plus(v133, v273); + real2 v803 = minus(v273, v133); + real2 v65 = load(in, 63 << shift); + real2 v33 = load(in, 31 << shift); + real2 v335 = reverse(minus(v33, v65)); + real2 v341 = plus(v33, v65); + real2 v49 = load(in, 47 << shift); + real2 v17 = load(in, 15 << shift); + real2 v340 = plus(v17, v49); + real2 v336 = minus(v49, v17); + real2 v471 = plus(v340, v341); + real2 v465 = reverse(minus(v340, v341)); + real2 v339 = minusplus(uminus(v335), v336); + real2 v337 = minusplus(v335, v336); + real2 v351 = ctimesminusplus(reverse(v339), ctbl[22], ctimes(v339, ctbl[20])); + real2 v345 = ctimesminusplus(reverse(v337), ctbl[29], ctimes(v337, ctbl[15])); + real2 v9 = load(in, 7 << shift); + real2 v41 = load(in, 39 << shift); + real2 v199 = plus(v9, v41); + real2 v195 = minus(v41, v9); + real2 v57 = load(in, 55 << shift); + real2 v25 = load(in, 23 << shift); + real2 v200 = plus(v25, v57); + real2 v194 = reverse(minus(v25, v57)); + real2 v466 = minus(v200, v199); + real2 v470 = plus(v199, v200); + real2 v535 = plus(v470, v471); + real2 v529 = reverse(minus(v470, v471)); + real2 v469 = minusplus(uminus(v465), v466); + real2 v467 = minusplus(v465, v466); + real2 v531 = minusplus(v529, v530); + real2 v533 = minusplus(uminus(v529), v530); + real2 v543 = ctimesminusplus(reverse(v533), ctbl[4], ctimes(v533, ctbl[2])); + real2 v539 = ctimesminusplus(reverse(v531), ctbl[5], ctimes(v531, ctbl[3])); + real2 v561 = reverse(minus(v534, v535)); + real2 v567 = plus(v534, v535); + real2 v479 = ctimesminusplus(reverse(v469), ctbl[10], ctimes(v469, ctbl[8])); + real2 v719 = plus(v415, v479); + real2 v713 = reverse(minus(v415, v479)); + real2 v475 = ctimesminusplus(reverse(v467), ctbl[13], ctimes(v467, ctbl[7])); + real2 v662 = plus(v411, v475); + real2 v656 = reverse(minus(v411, v475)); + real2 v196 = minusplus(v194, v195); + real2 v198 = minusplus(uminus(v194), v195); + real2 v209 = ctimesminusplus(reverse(v198), ctbl[25], ctimes(v198, ctbl[24])); + real2 v961 = reverse(minus(v209, v351)); + real2 v967 = plus(v209, v351); + real2 v963 = minusplus(v961, v962); + real2 v965 = minusplus(uminus(v961), v962); + real2 v975 = ctimesminusplus(reverse(v965), ctbl[4], ctimes(v965, ctbl[2])); + real2 v971 = ctimesminusplus(reverse(v963), ctbl[5], ctimes(v963, ctbl[3])); + real2 v999 = plus(v966, v967); + real2 v993 = reverse(minus(v966, v967)); + real2 v31 = load(in, 29 << shift); + real2 v63 = load(in, 61 << shift); + real2 v305 = plus(v31, v63); + real2 v299 = reverse(minus(v31, v63)); + real2 v47 = load(in, 45 << shift); + real2 v15 = load(in, 13 << shift); + real2 v300 = minus(v47, v15); + real2 v304 = plus(v15, v47); + real2 v439 = plus(v304, v305); + real2 v433 = reverse(minus(v304, v305)); + real2 v301 = minusplus(v299, v300); + real2 v303 = minusplus(uminus(v299), v300); + real2 v315 = ctimesminusplus(reverse(v303), ctbl[16], ctimes(v303, ctbl[26])); + real2 v7 = load(in, 5 << shift); + real2 v39 = load(in, 37 << shift); + real2 v164 = plus(v7, v39); + real2 v160 = minus(v39, v7); + real2 v23 = load(in, 21 << shift); + real2 v55 = load(in, 53 << shift); + real2 v159 = reverse(minus(v23, v55)); + real2 v165 = plus(v23, v55); + real2 v438 = plus(v164, v165); + real2 v434 = minus(v165, v164); + real2 v163 = minusplus(uminus(v159), v160); + real2 v161 = minusplus(v159, v160); + real2 v175 = ctimesminusplus(reverse(v163), ctbl[29], ctimes(v163, ctbl[15])); + real2 v929 = reverse(minus(v175, v315)); + real2 v935 = plus(v175, v315); + real2 v435 = minusplus(v433, v434); + real2 v437 = minusplus(uminus(v433), v434); + real2 v443 = ctimesminusplus(reverse(v435), ctbl[9], ctimes(v435, ctbl[11])); + real2 v497 = reverse(minus(v438, v439)); + real2 v503 = plus(v438, v439); + real2 v447 = ctimesminusplus(reverse(v437), ctbl[7], ctimes(v437, ctbl[6])); + real2 v11 = load(in, 9 << shift); + real2 v43 = load(in, 41 << shift); + real2 v234 = plus(v11, v43); + real2 v230 = minus(v43, v11); + real2 v27 = load(in, 25 << shift); + real2 v59 = load(in, 57 << shift); + real2 v235 = plus(v27, v59); + real2 v229 = reverse(minus(v27, v59)); + real2 v375 = plus(v234, v235); + real2 v369 = reverse(minus(v234, v235)); + real2 v233 = minusplus(uminus(v229), v230); + real2 v231 = minusplus(v229, v230); + real2 v244 = ctimesminusplus(reverse(v233), ctbl[19], ctimes(v233, ctbl[18])); + real2 v19 = load(in, 17 << shift); + real2 v51 = load(in, 49 << shift); + real2 v89 = plus(v19, v51); + real2 v83 = reverse(minus(v19, v51)); + real2 v3 = load(in, 1 << shift); + real2 v35 = load(in, 33 << shift); + real2 v88 = plus(v3, v35); + real2 v84 = minus(v35, v3); + real2 v370 = minus(v89, v88); + real2 v374 = plus(v88, v89); + real2 v371 = minusplus(v369, v370); + real2 v373 = minusplus(uminus(v369), v370); + real2 v383 = ctimesminusplus(reverse(v373), ctbl[11], ctimes(v373, ctbl[9])); + real2 v714 = minus(v447, v383); + real2 v718 = plus(v383, v447); + real2 v502 = plus(v374, v375); + real2 v498 = minus(v375, v374); + real2 v379 = ctimesminusplus(reverse(v371), ctbl[7], ctimes(v371, ctbl[13])); + real2 v657 = minus(v443, v379); + real2 v661 = plus(v379, v443); + real2 v715 = minusplus(v713, v714); + real2 v717 = minusplus(uminus(v713), v714); + real2 v566 = plus(v502, v503); + real2 v562 = minus(v503, v502); + real2 v499 = minusplus(v497, v498); + real2 v501 = minusplus(uminus(v497), v498); + real2 v511 = ctimesminusplus(reverse(v501), ctbl[5], ctimes(v501, ctbl[3])); + real2 v621 = reverse(minus(v511, v543)); + real2 v627 = plus(v511, v543); + real2 v583 = plus(v566, v567); + real2 v577 = reverse(minus(v566, v567)); + real2 v727 = ctimesminusplus(reverse(v717), ctbl[1], ctimes(v717, ctbl[0])); + real2 v723 = ctimesminusplus(reverse(v715), ctbl[1], ctimes(v715, ctbl[1])); + real2 v507 = ctimesminusplus(reverse(v499), ctbl[3], ctimes(v499, ctbl[5])); + real2 v735 = plus(v718, v719); + real2 v729 = reverse(minus(v718, v719)); + real2 v565 = minusplus(uminus(v561), v562); + real2 v563 = minusplus(v561, v562); + real2 v571 = ctimesminusplus(reverse(v563), ctbl[1], ctimes(v563, ctbl[1])); + real2 v602 = reverse(minus(v507, v539)); + real2 v608 = plus(v507, v539); + real2 v660 = minusplus(uminus(v656), v657); + real2 v658 = minusplus(v656, v657); + real2 v670 = ctimesminusplus(reverse(v660), ctbl[1], ctimes(v660, ctbl[0])); + real2 v666 = ctimesminusplus(reverse(v658), ctbl[1], ctimes(v658, ctbl[1])); + real2 v678 = plus(v661, v662); + real2 v672 = reverse(minus(v661, v662)); + real2 v575 = ctimesminusplus(reverse(v565), ctbl[1], ctimes(v565, ctbl[0])); + real2 v28 = load(in, 26 << shift); + real2 v60 = load(in, 58 << shift); + real2 v252 = plus(v28, v60); + real2 v246 = reverse(minus(v28, v60)); + real2 v44 = load(in, 42 << shift); + real2 v12 = load(in, 10 << shift); + real2 v251 = plus(v12, v44); + real2 v247 = minus(v44, v12); + real2 v391 = plus(v251, v252); + real2 v385 = reverse(minus(v251, v252)); + real2 v20 = load(in, 18 << shift); + real2 v52 = load(in, 50 << shift); + real2 v109 = plus(v20, v52); + real2 v103 = reverse(minus(v20, v52)); + real2 v36 = load(in, 34 << shift); + real2 v4 = load(in, 2 << shift); + real2 v108 = plus(v4, v36); + real2 v104 = minus(v36, v4); + real2 v386 = minus(v109, v108); + real2 v390 = plus(v108, v109); + real2 v514 = minus(v391, v390); + real2 v518 = plus(v390, v391); + real2 v389 = minusplus(uminus(v385), v386); + real2 v387 = minusplus(v385, v386); + real2 v399 = ctimesminusplus(reverse(v389), ctbl[5], ctimes(v389, ctbl[3])); + real2 v8 = load(in, 6 << shift); + real2 v40 = load(in, 38 << shift); + real2 v178 = minus(v40, v8); + real2 v182 = plus(v8, v40); + real2 v24 = load(in, 22 << shift); + real2 v56 = load(in, 54 << shift); + real2 v183 = plus(v24, v56); + real2 v177 = reverse(minus(v24, v56)); + real2 v450 = minus(v183, v182); + real2 v454 = plus(v182, v183); + real2 v16 = load(in, 14 << shift); + real2 v48 = load(in, 46 << shift); + real2 v322 = plus(v16, v48); + real2 v318 = minus(v48, v16); + real2 v32 = load(in, 30 << shift); + real2 v64 = load(in, 62 << shift); + real2 v323 = plus(v32, v64); + real2 v317 = reverse(minus(v32, v64)); + real2 v449 = reverse(minus(v322, v323)); + real2 v455 = plus(v322, v323); + real2 v519 = plus(v454, v455); + real2 v513 = reverse(minus(v454, v455)); + real2 v545 = reverse(minus(v518, v519)); + real2 v551 = plus(v518, v519); + real2 v515 = minusplus(v513, v514); + real2 v517 = minusplus(uminus(v513), v514); + real2 v527 = ctimesminusplus(reverse(v517), ctbl[1], ctimes(v517, ctbl[0])); + real2 v523 = ctimesminusplus(reverse(v515), ctbl[1], ctimes(v515, ctbl[1])); + real2 v14 = load(in, 12 << shift); + real2 v46 = load(in, 44 << shift); + real2 v286 = plus(v14, v46); + real2 v282 = minus(v46, v14); + real2 v62 = load(in, 60 << shift); + real2 v30 = load(in, 28 << shift); + real2 v281 = reverse(minus(v30, v62)); + real2 v287 = plus(v30, v62); + real2 v423 = plus(v286, v287); + real2 v417 = reverse(minus(v286, v287)); + real2 v22 = load(in, 20 << shift); + real2 v54 = load(in, 52 << shift); + real2 v147 = plus(v22, v54); + real2 v141 = reverse(minus(v22, v54)); + real2 v38 = load(in, 36 << shift); + real2 v6 = load(in, 4 << shift); + real2 v146 = plus(v6, v38); + real2 v142 = minus(v38, v6); + real2 v422 = plus(v146, v147); + real2 v418 = minus(v147, v146); + real2 v487 = plus(v422, v423); + real2 v481 = reverse(minus(v422, v423)); + real2 v42 = load(in, 40 << shift); + real2 v10 = load(in, 8 << shift); + real2 v212 = minus(v42, v10); + real2 v216 = plus(v10, v42); + real2 v58 = load(in, 56 << shift); + real2 v26 = load(in, 24 << shift); + real2 v217 = plus(v26, v58); + real2 v211 = reverse(minus(v26, v58)); + real2 v353 = reverse(minus(v216, v217)); + real2 v359 = plus(v216, v217); + real2 v18 = load(in, 16 << shift); + real2 v50 = load(in, 48 << shift); + real2 v73 = plus(v18, v50); + real2 v67 = reverse(minus(v18, v50)); + real2 v2 = load(in, 0 << shift); + real2 v34 = load(in, 32 << shift); + real2 v72 = plus(v2, v34); + real2 v68 = minus(v34, v2); + real2 v358 = plus(v72, v73); + real2 v354 = minus(v73, v72); + real2 v486 = plus(v358, v359); + real2 v482 = minus(v359, v358); + real2 v491 = minus(uplusminus(v481), v482); + real2 v495 = minus(uminusplus(v481), v482); + real2 v603 = minus(v523, v491); + real2 v607 = plus(v491, v523); + store(out, 4 << shift, plus(v607, v608)); + store(out, 36 << shift, minus(v607, v608)); + store(out, 52 << shift, minus(uminusplus(v602), v603)); + store(out, 20 << shift, minus(uplusminus(v602), v603)); + real2 v622 = minus(v527, v495); + real2 v626 = plus(v495, v527); + store(out, 60 << shift, minus(uminusplus(v621), v622)); + store(out, 28 << shift, minus(uplusminus(v621), v622)); + store(out, 12 << shift, plus(v626, v627)); + store(out, 44 << shift, minus(v626, v627)); + real2 v550 = plus(v486, v487); + real2 v546 = minus(v487, v486); + real2 v559 = minus(uminusplus(v545), v546); + real2 v555 = minus(uplusminus(v545), v546); + store(out, 8 << shift, plus(v555, v571)); + store(out, 40 << shift, minus(v555, v571)); + store(out, 24 << shift, plus(v559, v575)); + store(out, 56 << shift, minus(v559, v575)); + real2 v578 = minus(v551, v550); + store(out, 48 << shift, minus(uminusplus(v577), v578)); + store(out, 16 << shift, minus(uplusminus(v577), v578)); + real2 v582 = plus(v550, v551); + store(out, 0 << shift, plus(v582, v583)); + store(out, 32 << shift, minus(v582, v583)); + real2 v453 = minusplus(uminus(v449), v450); + real2 v451 = minusplus(v449, v450); + real2 v419 = minusplus(v417, v418); + real2 v421 = minusplus(uminus(v417), v418); + real2 v431 = ctimesminusplus(reverse(v421), ctbl[1], ctimes(v421, ctbl[0])); + real2 v463 = ctimesminusplus(reverse(v453), ctbl[4], ctimes(v453, ctbl[2])); + real2 v703 = plus(v399, v463); + real2 v697 = reverse(minus(v399, v463)); + real2 v367 = minus(uminusplus(v353), v354); + real2 v363 = minus(uplusminus(v353), v354); + real2 v702 = plus(v367, v431); + real2 v698 = minus(v431, v367); + real2 v730 = minus(v703, v702); + store(out, 54 << shift, minus(uminusplus(v729), v730)); + store(out, 22 << shift, minus(uplusminus(v729), v730)); + real2 v734 = plus(v702, v703); + store(out, 6 << shift, plus(v734, v735)); + store(out, 38 << shift, minus(v734, v735)); + real2 v707 = minus(uplusminus(v697), v698); + real2 v711 = minus(uminusplus(v697), v698); + store(out, 30 << shift, plus(v711, v727)); + store(out, 62 << shift, minus(v711, v727)); + store(out, 14 << shift, plus(v707, v723)); + store(out, 46 << shift, minus(v707, v723)); + real2 v395 = ctimesminusplus(reverse(v387), ctbl[3], ctimes(v387, ctbl[5])); + real2 v459 = ctimesminusplus(reverse(v451), ctbl[5], ctimes(v451, ctbl[3])); + real2 v640 = reverse(minus(v395, v459)); + real2 v646 = plus(v395, v459); + real2 v427 = ctimesminusplus(reverse(v419), ctbl[1], ctimes(v419, ctbl[1])); + real2 v641 = minus(v427, v363); + real2 v645 = plus(v363, v427); + real2 v654 = minus(uminusplus(v640), v641); + real2 v650 = minus(uplusminus(v640), v641); + store(out, 10 << shift, plus(v650, v666)); + store(out, 42 << shift, minus(v650, v666)); + store(out, 58 << shift, minus(v654, v670)); + store(out, 26 << shift, plus(v654, v670)); + real2 v673 = minus(v646, v645); + store(out, 50 << shift, minus(uminusplus(v672), v673)); + store(out, 18 << shift, minus(uplusminus(v672), v673)); + real2 v677 = plus(v645, v646); + store(out, 2 << shift, plus(v677, v678)); + store(out, 34 << shift, minus(v677, v678)); + real2 v250 = minusplus(uminus(v246), v247); + real2 v248 = minusplus(v246, v247); + real2 v261 = ctimesminusplus(reverse(v250), ctbl[7], ctimes(v250, ctbl[6])); + real2 v145 = minusplus(uminus(v141), v142); + real2 v143 = minusplus(v141, v142); + real2 v283 = minusplus(v281, v282); + real2 v285 = minusplus(uminus(v281), v282); + real2 v297 = ctimesminusplus(reverse(v285), ctbl[4], ctimes(v285, ctbl[2])); + real2 v157 = ctimesminusplus(reverse(v145), ctbl[5], ctimes(v145, ctbl[3])); + real2 v919 = plus(v157, v297); + real2 v913 = reverse(minus(v157, v297)); + real2 v213 = minusplus(v211, v212); + real2 v215 = minusplus(uminus(v211), v212); + real2 v227 = ctimesminusplus(reverse(v215), ctbl[1], ctimes(v215, ctbl[0])); + real2 v81 = minus(uminusplus(v67), v68); + real2 v77 = minus(uplusminus(v67), v68); + real2 v85 = minusplus(v83, v84); + real2 v87 = minusplus(uminus(v83), v84); + real2 v101 = ctimesminusplus(reverse(v87), ctbl[23], ctimes(v87, ctbl[21])); + real2 v934 = plus(v101, v244); + real2 v930 = minus(v244, v101); + real2 v179 = minusplus(v177, v178); + real2 v181 = minusplus(uminus(v177), v178); + real2 v192 = ctimesminusplus(reverse(v181), ctbl[13], ctimes(v181, ctbl[12])); + real2 v918 = plus(v81, v227); + real2 v914 = minus(v227, v81); + real2 v105 = minusplus(v103, v104); + real2 v107 = minusplus(uminus(v103), v104); + real2 v121 = ctimesminusplus(reverse(v107), ctbl[11], ctimes(v107, ctbl[9])); + real2 v946 = minus(v261, v121); + real2 v950 = plus(v121, v261); + real2 v994 = minus(v935, v934); + real2 v998 = plus(v934, v935); + real2 v1009 = reverse(minus(v998, v999)); + real2 v1015 = plus(v998, v999); + real2 v982 = plus(v918, v919); + real2 v978 = minus(v919, v918); + real2 v321 = minusplus(uminus(v317), v318); + real2 v319 = minusplus(v317, v318); + real2 v333 = ctimesminusplus(reverse(v321), ctbl[10], ctimes(v321, ctbl[8])); + real2 v951 = plus(v192, v333); + real2 v945 = reverse(minus(v192, v333)); + real2 v983 = plus(v950, v951); + real2 v977 = reverse(minus(v950, v951)); + real2 v1014 = plus(v982, v983); + real2 v1010 = minus(v983, v982); + store(out, 3 << shift, plus(v1014, v1015)); + store(out, 35 << shift, minus(v1014, v1015)); + store(out, 51 << shift, minus(uminusplus(v1009), v1010)); + store(out, 19 << shift, minus(uplusminus(v1009), v1010)); + real2 v997 = minusplus(uminus(v993), v994); + real2 v995 = minusplus(v993, v994); + real2 v1003 = ctimesminusplus(reverse(v995), ctbl[1], ctimes(v995, ctbl[1])); + real2 v987 = minus(uplusminus(v977), v978); + store(out, 43 << shift, minus(v987, v1003)); + store(out, 11 << shift, plus(v987, v1003)); + real2 v991 = minus(uminusplus(v977), v978); + real2 v1007 = ctimesminusplus(reverse(v997), ctbl[1], ctimes(v997, ctbl[0])); + store(out, 27 << shift, plus(v991, v1007)); + store(out, 59 << shift, minus(v991, v1007)); + real2 v947 = minusplus(v945, v946); + real2 v949 = minusplus(uminus(v945), v946); + real2 v931 = minusplus(v929, v930); + real2 v933 = minusplus(uminus(v929), v930); + real2 v939 = ctimesminusplus(reverse(v931), ctbl[3], ctimes(v931, ctbl[5])); + real2 v1034 = reverse(minus(v939, v971)); + real2 v1040 = plus(v939, v971); + real2 v927 = minus(uminusplus(v913), v914); + real2 v923 = minus(uplusminus(v913), v914); + real2 v955 = ctimesminusplus(reverse(v947), ctbl[1], ctimes(v947, ctbl[1])); + real2 v1035 = minus(v955, v923); + real2 v1039 = plus(v923, v955); + store(out, 39 << shift, minus(v1039, v1040)); + store(out, 7 << shift, plus(v1039, v1040)); + store(out, 23 << shift, minus(uplusminus(v1034), v1035)); + store(out, 55 << shift, minus(uminusplus(v1034), v1035)); + real2 v959 = ctimesminusplus(reverse(v949), ctbl[1], ctimes(v949, ctbl[0])); + real2 v943 = ctimesminusplus(reverse(v933), ctbl[5], ctimes(v933, ctbl[3])); + real2 v1053 = reverse(minus(v943, v975)); + real2 v1059 = plus(v943, v975); + real2 v1058 = plus(v927, v959); + real2 v1054 = minus(v959, v927); + store(out, 63 << shift, minus(uminusplus(v1053), v1054)); + store(out, 31 << shift, minus(uplusminus(v1053), v1054)); + store(out, 47 << shift, minus(v1058, v1059)); + store(out, 15 << shift, plus(v1058, v1059)); + real2 v309 = ctimesminusplus(reverse(v301), ctbl[21], ctimes(v301, ctbl[23])); + real2 v171 = ctimesminusplus(reverse(v161), ctbl[19], ctimes(v161, ctbl[25])); + real2 v776 = plus(v171, v309); + real2 v770 = reverse(minus(v171, v309)); + real2 v256 = ctimesminusplus(reverse(v248), ctbl[9], ctimes(v248, ctbl[11])); + real2 v222 = ctimesminusplus(reverse(v213), ctbl[1], ctimes(v213, ctbl[1])); + real2 v239 = ctimesminusplus(reverse(v231), ctbl[17], ctimes(v231, ctbl[27])); + real2 v204 = ctimesminusplus(reverse(v196), ctbl[27], ctimes(v196, ctbl[17])); + real2 v291 = ctimesminusplus(reverse(v283), ctbl[5], ctimes(v283, ctbl[3])); + real2 v153 = ctimesminusplus(reverse(v143), ctbl[3], ctimes(v143, ctbl[5])); + real2 v760 = plus(v153, v291); + real2 v754 = reverse(minus(v153, v291)); + real2 v187 = ctimesminusplus(reverse(v179), ctbl[11], ctimes(v179, ctbl[9])); + real2 v95 = ctimesminusplus(reverse(v85), ctbl[15], ctimes(v85, ctbl[29])); + real2 v771 = minus(v239, v95); + real2 v775 = plus(v95, v239); + real2 v839 = plus(v775, v776); + real2 v835 = minus(v776, v775); + real2 v115 = ctimesminusplus(reverse(v105), ctbl[7], ctimes(v105, ctbl[13])); + real2 v791 = plus(v115, v256); + real2 v787 = minus(v256, v115); + real2 v327 = ctimesminusplus(reverse(v319), ctbl[13], ctimes(v319, ctbl[7])); + real2 v792 = plus(v187, v327); + real2 v786 = reverse(minus(v187, v327)); + real2 v824 = plus(v791, v792); + real2 v818 = reverse(minus(v791, v792)); + real2 v808 = plus(v204, v345); + real2 v802 = reverse(minus(v204, v345)); + real2 v840 = plus(v807, v808); + real2 v834 = reverse(minus(v807, v808)); + real2 v850 = reverse(minus(v839, v840)); + real2 v856 = plus(v839, v840); + real2 v759 = plus(v77, v222); + real2 v755 = minus(v222, v77); + real2 v823 = plus(v759, v760); + real2 v819 = minus(v760, v759); + real2 v855 = plus(v823, v824); + store(out, 33 << shift, minus(v855, v856)); + store(out, 1 << shift, plus(v855, v856)); + real2 v851 = minus(v824, v823); + store(out, 49 << shift, minus(uminusplus(v850), v851)); + store(out, 17 << shift, minus(uplusminus(v850), v851)); + real2 v836 = minusplus(v834, v835); + real2 v838 = minusplus(uminus(v834), v835); + real2 v844 = ctimesminusplus(reverse(v836), ctbl[1], ctimes(v836, ctbl[1])); + real2 v828 = minus(uplusminus(v818), v819); + store(out, 41 << shift, minus(v828, v844)); + store(out, 9 << shift, plus(v828, v844)); + real2 v832 = minus(uminusplus(v818), v819); + real2 v848 = ctimesminusplus(reverse(v838), ctbl[1], ctimes(v838, ctbl[0])); + store(out, 25 << shift, plus(v832, v848)); + store(out, 57 << shift, minus(v832, v848)); + real2 v774 = minusplus(uminus(v770), v771); + real2 v772 = minusplus(v770, v771); + real2 v790 = minusplus(uminus(v786), v787); + real2 v788 = minusplus(v786, v787); + real2 v796 = ctimesminusplus(reverse(v788), ctbl[1], ctimes(v788, ctbl[1])); + real2 v780 = ctimesminusplus(reverse(v772), ctbl[3], ctimes(v772, ctbl[5])); + real2 v764 = minus(uplusminus(v754), v755); + real2 v768 = minus(uminusplus(v754), v755); + real2 v876 = minus(v796, v764); + real2 v880 = plus(v764, v796); + real2 v806 = minusplus(uminus(v802), v803); + real2 v804 = minusplus(v802, v803); + real2 v812 = ctimesminusplus(reverse(v804), ctbl[5], ctimes(v804, ctbl[3])); + real2 v881 = plus(v780, v812); + real2 v875 = reverse(minus(v780, v812)); + store(out, 21 << shift, minus(uplusminus(v875), v876)); + store(out, 53 << shift, minus(uminusplus(v875), v876)); + store(out, 5 << shift, plus(v880, v881)); + store(out, 37 << shift, minus(v880, v881)); + real2 v800 = ctimesminusplus(reverse(v790), ctbl[1], ctimes(v790, ctbl[0])); + real2 v784 = ctimesminusplus(reverse(v774), ctbl[5], ctimes(v774, ctbl[3])); + real2 v816 = ctimesminusplus(reverse(v806), ctbl[4], ctimes(v806, ctbl[2])); + real2 v900 = plus(v784, v816); + real2 v894 = reverse(minus(v784, v816)); + real2 v899 = plus(v768, v800); + store(out, 45 << shift, minus(v899, v900)); + store(out, 13 << shift, plus(v899, v900)); + real2 v895 = minus(v800, v768); + store(out, 61 << shift, minus(uminusplus(v894), v895)); + store(out, 29 << shift, minus(uplusminus(v894), v895)); +// Pres : 15312 + } +} + +ALIGNED(8192) void dft64b_%CONFIG%_%ISA%(real *RESTRICT out0, const real *RESTRICT in0, const int shift) { + const int k = 1 << (shift - LOG2VECWIDTH); + int i=0; +#pragma omp parallel for + for(i=0;i < k;i++) { + int i0 = i << LOG2VECWIDTH; + real *out = out0 + i0*2; + const real *in = in0 + i0*2; + +// Pres : 27598 + real2 v27 = load(in, 25 << shift); + real2 v59 = load(in, 57 << shift); + real2 v241 = plus(v27, v59); + real2 v235 = reverse(minus(v59, v27)); + real2 v43 = load(in, 41 << shift); + real2 v11 = load(in, 9 << shift); + real2 v236 = minus(v43, v11); + real2 v240 = plus(v11, v43); + real2 v375 = plus(v240, v241); + real2 v369 = reverse(minus(v241, v240)); + real2 v237 = minusplus(v235, v236); + real2 v239 = minusplus(uminus(v235), v236); + real2 v249 = ctimesminusplus(reverse(v239), ctbl[24], ctimes(v239, ctbl[18])); + real2 v245 = ctimesminusplus(reverse(v237), ctbl[26], ctimes(v237, ctbl[27])); + real2 v3 = load(in, 1 << shift); + real2 v35 = load(in, 33 << shift); + real2 v84 = minus(v35, v3); + real2 v88 = plus(v3, v35); + real2 v51 = load(in, 49 << shift); + real2 v19 = load(in, 17 << shift); + real2 v83 = reverse(minus(v51, v19)); + real2 v89 = plus(v19, v51); + real2 v370 = minus(v89, v88); + real2 v374 = plus(v88, v89); + real2 v85 = minusplus(v83, v84); + real2 v87 = minusplus(uminus(v83), v84); + real2 v101 = ctimesminusplus(reverse(v87), ctbl[20], ctimes(v87, ctbl[21])); + real2 v498 = minus(v375, v374); + real2 v502 = plus(v374, v375); + real2 v934 = plus(v101, v249); + real2 v930 = minus(v249, v101); + real2 v373 = minusplus(uminus(v369), v370); + real2 v371 = minusplus(v369, v370); + real2 v379 = ctimesminusplus(reverse(v371), ctbl[12], ctimes(v371, ctbl[13])); + real2 v383 = ctimesminusplus(reverse(v373), ctbl[8], ctimes(v373, ctbl[9])); + real2 v95 = ctimesminusplus(reverse(v85), ctbl[28], ctimes(v85, ctbl[29])); + real2 v771 = minus(v245, v95); + real2 v775 = plus(v95, v245); + real2 v7 = load(in, 5 << shift); + real2 v39 = load(in, 37 << shift); + real2 v166 = plus(v7, v39); + real2 v162 = minus(v39, v7); + real2 v23 = load(in, 21 << shift); + real2 v55 = load(in, 53 << shift); + real2 v161 = reverse(minus(v55, v23)); + real2 v167 = plus(v23, v55); + real2 v163 = minusplus(v161, v162); + real2 v165 = minusplus(uminus(v161), v162); + real2 v434 = minus(v167, v166); + real2 v438 = plus(v166, v167); + real2 v179 = ctimesminusplus(reverse(v165), ctbl[14], ctimes(v165, ctbl[15])); + real2 v173 = ctimesminusplus(reverse(v163), ctbl[24], ctimes(v163, ctbl[25])); + real2 v15 = load(in, 13 << shift); + real2 v47 = load(in, 45 << shift); + real2 v307 = plus(v15, v47); + real2 v303 = minus(v47, v15); + real2 v63 = load(in, 61 << shift); + real2 v31 = load(in, 29 << shift); + real2 v308 = plus(v31, v63); + real2 v302 = reverse(minus(v63, v31)); + real2 v439 = plus(v307, v308); + real2 v433 = reverse(minus(v308, v307)); + real2 v437 = minusplus(uminus(v433), v434); + real2 v435 = minusplus(v433, v434); + real2 v443 = ctimesminusplus(reverse(v435), ctbl[10], ctimes(v435, ctbl[11])); + real2 v497 = reverse(minus(v439, v438)); + real2 v503 = plus(v438, v439); + real2 v562 = minus(v503, v502); + real2 v566 = plus(v502, v503); + real2 v499 = minusplus(v497, v498); + real2 v501 = minusplus(uminus(v497), v498); + real2 v511 = ctimesminusplus(reverse(v501), ctbl[2], ctimes(v501, ctbl[3])); + real2 v447 = ctimesminusplus(reverse(v437), ctbl[12], ctimes(v437, ctbl[6])); + real2 v507 = ctimesminusplus(reverse(v499), ctbl[4], ctimes(v499, ctbl[5])); + real2 v718 = plus(v383, v447); + real2 v714 = minus(v447, v383); + real2 v306 = minusplus(uminus(v302), v303); + real2 v304 = minusplus(v302, v303); + real2 v318 = ctimesminusplus(reverse(v306), ctbl[27], ctimes(v306, ctbl[26])); + real2 v929 = reverse(minus(v318, v179)); + real2 v935 = plus(v179, v318); + real2 v931 = minusplus(v929, v930); + real2 v933 = minusplus(uminus(v929), v930); + real2 v998 = plus(v934, v935); + real2 v994 = minus(v935, v934); + real2 v661 = plus(v379, v443); + real2 v657 = minus(v443, v379); + real2 v939 = ctimesminusplus(reverse(v931), ctbl[4], ctimes(v931, ctbl[5])); + real2 v943 = ctimesminusplus(reverse(v933), ctbl[2], ctimes(v933, ctbl[3])); + real2 v45 = load(in, 43 << shift); + real2 v13 = load(in, 11 << shift); + real2 v274 = plus(v13, v45); + real2 v270 = minus(v45, v13); + real2 v29 = load(in, 27 << shift); + real2 v61 = load(in, 59 << shift); + real2 v269 = reverse(minus(v61, v29)); + real2 v275 = plus(v29, v61); + real2 v273 = minusplus(uminus(v269), v270); + real2 v271 = minusplus(v269, v270); + real2 v407 = plus(v274, v275); + real2 v401 = reverse(minus(v275, v274)); + real2 v284 = ctimesminusplus(reverse(v273), ctbl[15], ctimes(v273, ctbl[14])); + real2 v5 = load(in, 3 << shift); + real2 v37 = load(in, 35 << shift); + real2 v128 = plus(v5, v37); + real2 v124 = minus(v37, v5); + real2 v53 = load(in, 51 << shift); + real2 v21 = load(in, 19 << shift); + real2 v129 = plus(v21, v53); + real2 v123 = reverse(minus(v53, v21)); + real2 v406 = plus(v128, v129); + real2 v402 = minus(v129, v128); + real2 v405 = minusplus(uminus(v401), v402); + real2 v403 = minusplus(v401, v402); + real2 v415 = ctimesminusplus(reverse(v405), ctbl[6], ctimes(v405, ctbl[12])); + real2 v411 = ctimesminusplus(reverse(v403), ctbl[8], ctimes(v403, ctbl[9])); + real2 v127 = minusplus(uminus(v123), v124); + real2 v125 = minusplus(v123, v124); + real2 v530 = minus(v407, v406); + real2 v534 = plus(v406, v407); + real2 v139 = ctimesminusplus(reverse(v127), ctbl[26], ctimes(v127, ctbl[27])); + real2 v962 = minus(v284, v139); + real2 v966 = plus(v139, v284); + real2 v57 = load(in, 55 << shift); + real2 v25 = load(in, 23 << shift); + real2 v204 = plus(v25, v57); + real2 v198 = reverse(minus(v57, v25)); + real2 v9 = load(in, 7 << shift); + real2 v41 = load(in, 39 << shift); + real2 v199 = minus(v41, v9); + real2 v203 = plus(v9, v41); + real2 v202 = minusplus(uminus(v198), v199); + real2 v200 = minusplus(v198, v199); + real2 v470 = plus(v203, v204); + real2 v466 = minus(v204, v203); + real2 v215 = ctimesminusplus(reverse(v202), ctbl[18], ctimes(v202, ctbl[24])); + real2 v17 = load(in, 15 << shift); + real2 v49 = load(in, 47 << shift); + real2 v338 = minus(v49, v17); + real2 v342 = plus(v17, v49); + real2 v33 = load(in, 31 << shift); + real2 v65 = load(in, 63 << shift); + real2 v337 = reverse(minus(v65, v33)); + real2 v343 = plus(v33, v65); + real2 v341 = minusplus(uminus(v337), v338); + real2 v339 = minusplus(v337, v338); + real2 v351 = ctimesminusplus(reverse(v341), ctbl[21], ctimes(v341, ctbl[20])); + real2 v961 = reverse(minus(v351, v215)); + real2 v967 = plus(v215, v351); + real2 v465 = reverse(minus(v343, v342)); + real2 v471 = plus(v342, v343); + real2 v467 = minusplus(v465, v466); + real2 v469 = minusplus(uminus(v465), v466); + real2 v475 = ctimesminusplus(reverse(v467), ctbl[6], ctimes(v467, ctbl[7])); + real2 v662 = plus(v411, v475); + real2 v656 = reverse(minus(v475, v411)); + real2 v529 = reverse(minus(v471, v470)); + real2 v535 = plus(v470, v471); + real2 v531 = minusplus(v529, v530); + real2 v533 = minusplus(uminus(v529), v530); + real2 v543 = ctimesminusplus(reverse(v533), ctbl[3], ctimes(v533, ctbl[2])); + real2 v561 = reverse(minus(v535, v534)); + real2 v567 = plus(v534, v535); + real2 v565 = minusplus(uminus(v561), v562); + real2 v563 = minusplus(v561, v562); + real2 v571 = ctimesminusplus(reverse(v563), ctbl[0], ctimes(v563, ctbl[1])); + real2 v583 = plus(v566, v567); + real2 v577 = reverse(minus(v567, v566)); + real2 v539 = ctimesminusplus(reverse(v531), ctbl[2], ctimes(v531, ctbl[3])); + real2 v602 = reverse(minus(v539, v507)); + real2 v608 = plus(v507, v539); + real2 v993 = reverse(minus(v967, v966)); + real2 v999 = plus(v966, v967); + real2 v575 = ctimesminusplus(reverse(v565), ctbl[0], ctimes(v565, ctbl[0])); + real2 v1009 = reverse(minus(v999, v998)); + real2 v1015 = plus(v998, v999); + real2 v479 = ctimesminusplus(reverse(v469), ctbl[9], ctimes(v469, ctbl[8])); + real2 v713 = reverse(minus(v479, v415)); + real2 v719 = plus(v415, v479); + real2 v660 = minusplus(uminus(v656), v657); + real2 v658 = minusplus(v656, v657); + real2 v717 = minusplus(uminus(v713), v714); + real2 v715 = minusplus(v713, v714); + real2 v723 = ctimesminusplus(reverse(v715), ctbl[0], ctimes(v715, ctbl[1])); + real2 v666 = ctimesminusplus(reverse(v658), ctbl[0], ctimes(v658, ctbl[1])); + real2 v670 = ctimesminusplus(reverse(v660), ctbl[0], ctimes(v660, ctbl[0])); + real2 v727 = ctimesminusplus(reverse(v717), ctbl[0], ctimes(v717, ctbl[0])); + real2 v735 = plus(v718, v719); + real2 v729 = reverse(minus(v719, v718)); + real2 v621 = reverse(minus(v543, v511)); + real2 v627 = plus(v511, v543); + real2 v672 = reverse(minus(v662, v661)); + real2 v678 = plus(v661, v662); + real2 v28 = load(in, 26 << shift); + real2 v60 = load(in, 58 << shift); + real2 v251 = reverse(minus(v60, v28)); + real2 v257 = plus(v28, v60); + real2 v44 = load(in, 42 << shift); + real2 v12 = load(in, 10 << shift); + real2 v256 = plus(v12, v44); + real2 v252 = minus(v44, v12); + real2 v391 = plus(v256, v257); + real2 v385 = reverse(minus(v257, v256)); + real2 v36 = load(in, 34 << shift); + real2 v4 = load(in, 2 << shift); + real2 v104 = minus(v36, v4); + real2 v108 = plus(v4, v36); + real2 v20 = load(in, 18 << shift); + real2 v52 = load(in, 50 << shift); + real2 v109 = plus(v20, v52); + real2 v103 = reverse(minus(v52, v20)); + real2 v390 = plus(v108, v109); + real2 v386 = minus(v109, v108); + real2 v514 = minus(v391, v390); + real2 v518 = plus(v390, v391); + real2 v387 = minusplus(v385, v386); + real2 v389 = minusplus(uminus(v385), v386); + real2 v399 = ctimesminusplus(reverse(v389), ctbl[2], ctimes(v389, ctbl[3])); + real2 v395 = ctimesminusplus(reverse(v387), ctbl[4], ctimes(v387, ctbl[5])); + real2 v40 = load(in, 38 << shift); + real2 v8 = load(in, 6 << shift); + real2 v182 = minus(v40, v8); + real2 v186 = plus(v8, v40); + real2 v56 = load(in, 54 << shift); + real2 v24 = load(in, 22 << shift); + real2 v187 = plus(v24, v56); + real2 v181 = reverse(minus(v56, v24)); + real2 v454 = plus(v186, v187); + real2 v450 = minus(v187, v186); + real2 v48 = load(in, 46 << shift); + real2 v16 = load(in, 14 << shift); + real2 v325 = plus(v16, v48); + real2 v321 = minus(v48, v16); + real2 v32 = load(in, 30 << shift); + real2 v64 = load(in, 62 << shift); + real2 v326 = plus(v32, v64); + real2 v320 = reverse(minus(v64, v32)); + real2 v455 = plus(v325, v326); + real2 v449 = reverse(minus(v326, v325)); + real2 v513 = reverse(minus(v455, v454)); + real2 v519 = plus(v454, v455); + real2 v515 = minusplus(v513, v514); + real2 v517 = minusplus(uminus(v513), v514); + real2 v551 = plus(v518, v519); + real2 v545 = reverse(minus(v519, v518)); + real2 v523 = ctimesminusplus(reverse(v515), ctbl[0], ctimes(v515, ctbl[1])); + real2 v527 = ctimesminusplus(reverse(v517), ctbl[0], ctimes(v517, ctbl[0])); + real2 v58 = load(in, 56 << shift); + real2 v26 = load(in, 24 << shift); + real2 v217 = reverse(minus(v58, v26)); + real2 v223 = plus(v26, v58); + real2 v50 = load(in, 48 << shift); + real2 v18 = load(in, 16 << shift); + real2 v67 = reverse(minus(v50, v18)); + real2 v73 = plus(v18, v50); + real2 v2 = load(in, 0 << shift); + real2 v34 = load(in, 32 << shift); + real2 v72 = plus(v2, v34); + real2 v68 = minus(v34, v2); + real2 v354 = minus(v73, v72); + real2 v358 = plus(v72, v73); + real2 v10 = load(in, 8 << shift); + real2 v42 = load(in, 40 << shift); + real2 v222 = plus(v10, v42); + real2 v218 = minus(v42, v10); + real2 v359 = plus(v222, v223); + real2 v353 = reverse(minus(v223, v222)); + real2 v482 = minus(v359, v358); + real2 v486 = plus(v358, v359); + real2 v46 = load(in, 44 << shift); + real2 v14 = load(in, 12 << shift); + real2 v287 = minus(v46, v14); + real2 v291 = plus(v14, v46); + real2 v54 = load(in, 52 << shift); + real2 v22 = load(in, 20 << shift); + real2 v147 = plus(v22, v54); + real2 v141 = reverse(minus(v54, v22)); + real2 v38 = load(in, 36 << shift); + real2 v6 = load(in, 4 << shift); + real2 v142 = minus(v38, v6); + real2 v146 = plus(v6, v38); + real2 v418 = minus(v147, v146); + real2 v422 = plus(v146, v147); + real2 v62 = load(in, 60 << shift); + real2 v30 = load(in, 28 << shift); + real2 v286 = reverse(minus(v62, v30)); + real2 v292 = plus(v30, v62); + real2 v423 = plus(v291, v292); + real2 v417 = reverse(minus(v292, v291)); + real2 v481 = reverse(minus(v423, v422)); + real2 v487 = plus(v422, v423); + real2 v550 = plus(v486, v487); + real2 v546 = minus(v487, v486); + real2 v578 = minus(v551, v550); + store(out, 16 << shift, minus(uplusminus(v577), v578)); + store(out, 48 << shift, minus(uminusplus(v577), v578)); + real2 v582 = plus(v550, v551); + store(out, 0 << shift, plus(v582, v583)); + store(out, 32 << shift, minus(v582, v583)); + real2 v559 = minus(uminusplus(v545), v546); + real2 v555 = minus(uplusminus(v545), v546); + store(out, 40 << shift, minus(v555, v571)); + store(out, 8 << shift, plus(v555, v571)); + store(out, 56 << shift, minus(v559, v575)); + store(out, 24 << shift, plus(v559, v575)); + real2 v495 = minus(uminusplus(v481), v482); + real2 v491 = minus(uplusminus(v481), v482); + real2 v626 = plus(v495, v527); + store(out, 12 << shift, plus(v626, v627)); + store(out, 44 << shift, minus(v626, v627)); + real2 v622 = minus(v527, v495); + store(out, 60 << shift, minus(uminusplus(v621), v622)); + store(out, 28 << shift, minus(uplusminus(v621), v622)); + real2 v607 = plus(v491, v523); + real2 v603 = minus(v523, v491); + store(out, 4 << shift, plus(v607, v608)); + store(out, 36 << shift, minus(v607, v608)); + store(out, 20 << shift, minus(uplusminus(v602), v603)); + store(out, 52 << shift, minus(uminusplus(v602), v603)); + real2 v367 = minus(uminusplus(v353), v354); + real2 v363 = minus(uplusminus(v353), v354); + real2 v421 = minusplus(uminus(v417), v418); + real2 v419 = minusplus(v417, v418); + real2 v431 = ctimesminusplus(reverse(v421), ctbl[0], ctimes(v421, ctbl[0])); + real2 v451 = minusplus(v449, v450); + real2 v453 = minusplus(uminus(v449), v450); + real2 v463 = ctimesminusplus(reverse(v453), ctbl[3], ctimes(v453, ctbl[2])); + real2 v697 = reverse(minus(v463, v399)); + real2 v703 = plus(v399, v463); + real2 v698 = minus(v431, v367); + real2 v702 = plus(v367, v431); + real2 v711 = minus(uminusplus(v697), v698); + store(out, 30 << shift, plus(v711, v727)); + store(out, 62 << shift, minus(v711, v727)); + real2 v707 = minus(uplusminus(v697), v698); + store(out, 46 << shift, minus(v707, v723)); + store(out, 14 << shift, plus(v707, v723)); + real2 v734 = plus(v702, v703); + store(out, 6 << shift, plus(v734, v735)); + store(out, 38 << shift, minus(v734, v735)); + real2 v730 = minus(v703, v702); + store(out, 54 << shift, minus(uminusplus(v729), v730)); + store(out, 22 << shift, minus(uplusminus(v729), v730)); + real2 v459 = ctimesminusplus(reverse(v451), ctbl[2], ctimes(v451, ctbl[3])); + real2 v640 = reverse(minus(v459, v395)); + real2 v646 = plus(v395, v459); + real2 v427 = ctimesminusplus(reverse(v419), ctbl[0], ctimes(v419, ctbl[1])); + real2 v641 = minus(v427, v363); + real2 v645 = plus(v363, v427); + real2 v654 = minus(uminusplus(v640), v641); + real2 v650 = minus(uplusminus(v640), v641); + store(out, 10 << shift, plus(v650, v666)); + store(out, 42 << shift, minus(v650, v666)); + store(out, 26 << shift, plus(v654, v670)); + store(out, 58 << shift, minus(v654, v670)); + real2 v673 = minus(v646, v645); + store(out, 18 << shift, minus(uplusminus(v672), v673)); + store(out, 50 << shift, minus(uminusplus(v672), v673)); + real2 v677 = plus(v645, v646); + store(out, 2 << shift, plus(v677, v678)); + store(out, 34 << shift, minus(v677, v678)); + real2 v105 = minusplus(v103, v104); + real2 v107 = minusplus(uminus(v103), v104); + real2 v253 = minusplus(v251, v252); + real2 v255 = minusplus(uminus(v251), v252); + real2 v267 = ctimesminusplus(reverse(v255), ctbl[12], ctimes(v255, ctbl[6])); + real2 v121 = ctimesminusplus(reverse(v107), ctbl[8], ctimes(v107, ctbl[9])); + real2 v950 = plus(v121, v267); + real2 v946 = minus(v267, v121); + real2 v290 = minusplus(uminus(v286), v287); + real2 v288 = minusplus(v286, v287); + real2 v143 = minusplus(v141, v142); + real2 v145 = minusplus(uminus(v141), v142); + real2 v159 = ctimesminusplus(reverse(v145), ctbl[2], ctimes(v145, ctbl[3])); + real2 v300 = ctimesminusplus(reverse(v290), ctbl[3], ctimes(v290, ctbl[2])); + real2 v919 = plus(v159, v300); + real2 v913 = reverse(minus(v300, v159)); + real2 v219 = minusplus(v217, v218); + real2 v221 = minusplus(uminus(v217), v218); + real2 v185 = minusplus(uminus(v181), v182); + real2 v183 = minusplus(v181, v182); + real2 v196 = ctimesminusplus(reverse(v185), ctbl[6], ctimes(v185, ctbl[12])); + real2 v233 = ctimesminusplus(reverse(v221), ctbl[0], ctimes(v221, ctbl[0])); + real2 v324 = minusplus(uminus(v320), v321); + real2 v322 = minusplus(v320, v321); + real2 v335 = ctimesminusplus(reverse(v324), ctbl[9], ctimes(v324, ctbl[8])); + real2 v945 = reverse(minus(v335, v196)); + real2 v951 = plus(v196, v335); + real2 v977 = reverse(minus(v951, v950)); + real2 v983 = plus(v950, v951); + real2 v77 = minus(uplusminus(v67), v68); + real2 v81 = minus(uminusplus(v67), v68); + real2 v914 = minus(v233, v81); + real2 v918 = plus(v81, v233); + real2 v982 = plus(v918, v919); + real2 v978 = minus(v919, v918); + real2 v1014 = plus(v982, v983); + store(out, 3 << shift, plus(v1014, v1015)); + store(out, 35 << shift, minus(v1014, v1015)); + real2 v1010 = minus(v983, v982); + store(out, 19 << shift, minus(uplusminus(v1009), v1010)); + store(out, 51 << shift, minus(uminusplus(v1009), v1010)); + real2 v995 = minusplus(v993, v994); + real2 v997 = minusplus(uminus(v993), v994); + real2 v1007 = ctimesminusplus(reverse(v997), ctbl[0], ctimes(v997, ctbl[0])); + real2 v987 = minus(uplusminus(v977), v978); + real2 v991 = minus(uminusplus(v977), v978); + store(out, 27 << shift, plus(v991, v1007)); + store(out, 59 << shift, minus(v991, v1007)); + real2 v1003 = ctimesminusplus(reverse(v995), ctbl[0], ctimes(v995, ctbl[1])); + store(out, 43 << shift, minus(v987, v1003)); + store(out, 11 << shift, plus(v987, v1003)); + real2 v965 = minusplus(uminus(v961), v962); + real2 v963 = minusplus(v961, v962); + real2 v975 = ctimesminusplus(reverse(v965), ctbl[3], ctimes(v965, ctbl[2])); + real2 v1059 = plus(v943, v975); + real2 v1053 = reverse(minus(v975, v943)); + real2 v947 = minusplus(v945, v946); + real2 v949 = minusplus(uminus(v945), v946); + real2 v959 = ctimesminusplus(reverse(v949), ctbl[0], ctimes(v949, ctbl[0])); + real2 v927 = minus(uminusplus(v913), v914); + real2 v923 = minus(uplusminus(v913), v914); + real2 v1058 = plus(v927, v959); + store(out, 15 << shift, plus(v1058, v1059)); + store(out, 47 << shift, minus(v1058, v1059)); + real2 v1054 = minus(v959, v927); + store(out, 63 << shift, minus(uminusplus(v1053), v1054)); + store(out, 31 << shift, minus(uplusminus(v1053), v1054)); + real2 v955 = ctimesminusplus(reverse(v947), ctbl[0], ctimes(v947, ctbl[1])); + real2 v971 = ctimesminusplus(reverse(v963), ctbl[2], ctimes(v963, ctbl[3])); + real2 v1034 = reverse(minus(v971, v939)); + real2 v1040 = plus(v939, v971); + real2 v1035 = minus(v955, v923); + store(out, 55 << shift, minus(uminusplus(v1034), v1035)); + store(out, 23 << shift, minus(uplusminus(v1034), v1035)); + real2 v1039 = plus(v923, v955); + store(out, 39 << shift, minus(v1039, v1040)); + store(out, 7 << shift, plus(v1039, v1040)); + real2 v263 = ctimesminusplus(reverse(v253), ctbl[10], ctimes(v253, ctbl[11])); + real2 v191 = ctimesminusplus(reverse(v183), ctbl[8], ctimes(v183, ctbl[9])); + real2 v115 = ctimesminusplus(reverse(v105), ctbl[12], ctimes(v105, ctbl[13])); + real2 v787 = minus(v263, v115); + real2 v791 = plus(v115, v263); + real2 v331 = ctimesminusplus(reverse(v322), ctbl[6], ctimes(v322, ctbl[7])); + real2 v786 = reverse(minus(v331, v191)); + real2 v792 = plus(v191, v331); + real2 v280 = ctimesminusplus(reverse(v271), ctbl[18], ctimes(v271, ctbl[19])); + real2 v133 = ctimesminusplus(reverse(v125), ctbl[20], ctimes(v125, ctbl[21])); + real2 v807 = plus(v133, v280); + real2 v803 = minus(v280, v133); + real2 v210 = ctimesminusplus(reverse(v200), ctbl[16], ctimes(v200, ctbl[17])); + real2 v153 = ctimesminusplus(reverse(v143), ctbl[4], ctimes(v143, ctbl[5])); + real2 v347 = ctimesminusplus(reverse(v339), ctbl[14], ctimes(v339, ctbl[15])); + real2 v808 = plus(v210, v347); + real2 v802 = reverse(minus(v347, v210)); + real2 v314 = ctimesminusplus(reverse(v304), ctbl[22], ctimes(v304, ctbl[23])); + real2 v770 = reverse(minus(v314, v173)); + real2 v776 = plus(v173, v314); + real2 v839 = plus(v775, v776); + real2 v835 = minus(v776, v775); + real2 v818 = reverse(minus(v792, v791)); + real2 v824 = plus(v791, v792); + real2 v840 = plus(v807, v808); + real2 v834 = reverse(minus(v808, v807)); + real2 v856 = plus(v839, v840); + real2 v850 = reverse(minus(v840, v839)); + real2 v229 = ctimesminusplus(reverse(v219), ctbl[0], ctimes(v219, ctbl[1])); + real2 v296 = ctimesminusplus(reverse(v288), ctbl[2], ctimes(v288, ctbl[3])); + real2 v760 = plus(v153, v296); + real2 v754 = reverse(minus(v296, v153)); + real2 v759 = plus(v77, v229); + real2 v755 = minus(v229, v77); + real2 v823 = plus(v759, v760); + real2 v819 = minus(v760, v759); + real2 v855 = plus(v823, v824); + store(out, 33 << shift, minus(v855, v856)); + store(out, 1 << shift, plus(v855, v856)); + real2 v851 = minus(v824, v823); + store(out, 17 << shift, minus(uplusminus(v850), v851)); + store(out, 49 << shift, minus(uminusplus(v850), v851)); + real2 v838 = minusplus(uminus(v834), v835); + real2 v836 = minusplus(v834, v835); + real2 v844 = ctimesminusplus(reverse(v836), ctbl[0], ctimes(v836, ctbl[1])); + real2 v832 = minus(uminusplus(v818), v819); + real2 v828 = minus(uplusminus(v818), v819); + store(out, 41 << shift, minus(v828, v844)); + store(out, 9 << shift, plus(v828, v844)); + real2 v848 = ctimesminusplus(reverse(v838), ctbl[0], ctimes(v838, ctbl[0])); + store(out, 25 << shift, plus(v832, v848)); + store(out, 57 << shift, minus(v832, v848)); + real2 v790 = minusplus(uminus(v786), v787); + real2 v788 = minusplus(v786, v787); + real2 v772 = minusplus(v770, v771); + real2 v774 = minusplus(uminus(v770), v771); + real2 v780 = ctimesminusplus(reverse(v772), ctbl[4], ctimes(v772, ctbl[5])); + real2 v806 = minusplus(uminus(v802), v803); + real2 v804 = minusplus(v802, v803); + real2 v812 = ctimesminusplus(reverse(v804), ctbl[2], ctimes(v804, ctbl[3])); + real2 v875 = reverse(minus(v812, v780)); + real2 v881 = plus(v780, v812); + real2 v796 = ctimesminusplus(reverse(v788), ctbl[0], ctimes(v788, ctbl[1])); + real2 v764 = minus(uplusminus(v754), v755); + real2 v768 = minus(uminusplus(v754), v755); + real2 v880 = plus(v764, v796); + real2 v876 = minus(v796, v764); + store(out, 21 << shift, minus(uplusminus(v875), v876)); + store(out, 53 << shift, minus(uminusplus(v875), v876)); + store(out, 37 << shift, minus(v880, v881)); + store(out, 5 << shift, plus(v880, v881)); + real2 v800 = ctimesminusplus(reverse(v790), ctbl[0], ctimes(v790, ctbl[0])); + real2 v784 = ctimesminusplus(reverse(v774), ctbl[2], ctimes(v774, ctbl[3])); + real2 v816 = ctimesminusplus(reverse(v806), ctbl[3], ctimes(v806, ctbl[2])); + real2 v900 = plus(v784, v816); + real2 v894 = reverse(minus(v816, v784)); + real2 v895 = minus(v800, v768); + real2 v899 = plus(v768, v800); + store(out, 45 << shift, minus(v899, v900)); + store(out, 13 << shift, plus(v899, v900)); + store(out, 61 << shift, minus(uminusplus(v894), v895)); + store(out, 29 << shift, minus(uplusminus(v894), v895)); +// Pres : 15320 + } +} + +ALIGNED(8192) void but64f_%CONFIG%_%ISA%(real *RESTRICT out0, uint32_t *q, const int outShift, const real *RESTRICT in0, const int inShift, const real *RESTRICT tbl, const int K) { + const int k = 1 << (inShift - LOG2VECWIDTH); + int i=0; +#pragma omp parallel for + for(i=0;i < k;i++) { + int i0 = i << LOG2VECWIDTH; + real *out = out0 + q[i]; + const real *in = in0 + i0*2; + const int tbloffset = K * (i0 >> outShift); + +// Pres : 30254 + real2 v37 = load(in, 35 << inShift); + real2 v5 = load(in, 3 << inShift); + real2 v132 = plus(v5, v37); + real2 v128 = minus(v37, v5); + real2 v21 = load(in, 19 << inShift); + real2 v53 = load(in, 51 << inShift); + real2 v133 = plus(v21, v53); + real2 v127 = reverse(minus(v21, v53)); + real2 v131 = minusplus(uminus(v127), v128); + real2 v129 = minusplus(v127, v128); + real2 v139 = ctimesminusplus(reverse(v129), tbl[14 + tbloffset], ctimes(v129, tbl[15 + tbloffset])); + real2 v145 = ctimesminusplus(reverse(v131), tbl[16 + tbloffset], ctimes(v131, tbl[17 + tbloffset])); + real2 v448 = minus(v133, v132); + real2 v452 = plus(v132, v133); + real2 v45 = load(in, 43 << inShift); + real2 v13 = load(in, 11 << inShift); + real2 v292 = plus(v13, v45); + real2 v288 = minus(v45, v13); + real2 v29 = load(in, 27 << inShift); + real2 v61 = load(in, 59 << inShift); + real2 v293 = plus(v29, v61); + real2 v287 = reverse(minus(v29, v61)); + real2 v291 = minusplus(uminus(v287), v288); + real2 v289 = minusplus(v287, v288); + real2 v299 = ctimesminusplus(reverse(v289), tbl[46 + tbloffset], ctimes(v289, tbl[47 + tbloffset])); + real2 v453 = plus(v292, v293); + real2 v447 = reverse(minus(v292, v293)); + real2 v608 = minus(v453, v452); + real2 v612 = plus(v452, v453); + real2 v980 = plus(v139, v299); + real2 v976 = minus(v299, v139); + real2 v449 = minusplus(v447, v448); + real2 v451 = minusplus(uminus(v447), v448); + real2 v465 = ctimesminusplus(reverse(v451), tbl[80 + tbloffset], ctimes(v451, tbl[81 + tbloffset])); + real2 v305 = ctimesminusplus(reverse(v291), tbl[48 + tbloffset], ctimes(v291, tbl[49 + tbloffset])); + real2 v1186 = minus(v305, v145); + real2 v1190 = plus(v145, v305); + real2 v459 = ctimesminusplus(reverse(v449), tbl[78 + tbloffset], ctimes(v449, tbl[79 + tbloffset])); + real2 v25 = load(in, 23 << inShift); + real2 v57 = load(in, 55 << inShift); + real2 v207 = reverse(minus(v25, v57)); + real2 v213 = plus(v25, v57); + real2 v9 = load(in, 7 << inShift); + real2 v41 = load(in, 39 << inShift); + real2 v212 = plus(v9, v41); + real2 v208 = minus(v41, v9); + real2 v528 = minus(v213, v212); + real2 v532 = plus(v212, v213); + real2 v209 = minusplus(v207, v208); + real2 v211 = minusplus(uminus(v207), v208); + real2 v225 = ctimesminusplus(reverse(v211), tbl[32 + tbloffset], ctimes(v211, tbl[33 + tbloffset])); + real2 v219 = ctimesminusplus(reverse(v209), tbl[30 + tbloffset], ctimes(v209, tbl[31 + tbloffset])); + real2 v17 = load(in, 15 << inShift); + real2 v49 = load(in, 47 << inShift); + real2 v368 = minus(v49, v17); + real2 v372 = plus(v17, v49); + real2 v33 = load(in, 31 << inShift); + real2 v65 = load(in, 63 << inShift); + real2 v367 = reverse(minus(v33, v65)); + real2 v373 = plus(v33, v65); + real2 v369 = minusplus(v367, v368); + real2 v371 = minusplus(uminus(v367), v368); + real2 v533 = plus(v372, v373); + real2 v527 = reverse(minus(v372, v373)); + real2 v607 = reverse(minus(v532, v533)); + real2 v613 = plus(v532, v533); + real2 v529 = minusplus(v527, v528); + real2 v531 = minusplus(uminus(v527), v528); + real2 v545 = ctimesminusplus(reverse(v531), tbl[96 + tbloffset], ctimes(v531, tbl[97 + tbloffset])); + real2 v653 = plus(v612, v613); + real2 v647 = reverse(minus(v612, v613)); + real2 v609 = minusplus(v607, v608); + real2 v611 = minusplus(uminus(v607), v608); + real2 v863 = plus(v465, v545); + real2 v857 = reverse(minus(v465, v545)); + real2 v539 = ctimesminusplus(reverse(v529), tbl[94 + tbloffset], ctimes(v529, tbl[95 + tbloffset])); + real2 v385 = ctimesminusplus(reverse(v371), tbl[64 + tbloffset], ctimes(v371, tbl[65 + tbloffset])); + real2 v619 = ctimesminusplus(reverse(v609), tbl[110 + tbloffset], ctimes(v609, tbl[111 + tbloffset])); + real2 v1191 = plus(v225, v385); + real2 v1185 = reverse(minus(v225, v385)); + real2 v779 = reverse(minus(v459, v539)); + real2 v785 = plus(v459, v539); + real2 v625 = ctimesminusplus(reverse(v611), tbl[112 + tbloffset], ctimes(v611, tbl[113 + tbloffset])); + real2 v379 = ctimesminusplus(reverse(v369), tbl[62 + tbloffset], ctimes(v369, tbl[63 + tbloffset])); + real2 v975 = reverse(minus(v219, v379)); + real2 v981 = plus(v219, v379); + real2 v977 = minusplus(v975, v976); + real2 v979 = minusplus(uminus(v975), v976); + real2 v987 = ctimesminusplus(reverse(v977), tbl[170 + tbloffset], ctimes(v977, tbl[171 + tbloffset])); + real2 v993 = ctimesminusplus(reverse(v979), tbl[172 + tbloffset], ctimes(v979, tbl[173 + tbloffset])); + real2 v1015 = reverse(minus(v980, v981)); + real2 v1021 = plus(v980, v981); + real2 v11 = load(in, 9 << inShift); + real2 v43 = load(in, 41 << inShift); + real2 v248 = minus(v43, v11); + real2 v252 = plus(v11, v43); + real2 v59 = load(in, 57 << inShift); + real2 v27 = load(in, 25 << inShift); + real2 v253 = plus(v27, v59); + real2 v247 = reverse(minus(v27, v59)); + real2 v413 = plus(v252, v253); + real2 v407 = reverse(minus(v252, v253)); + real2 v249 = minusplus(v247, v248); + real2 v251 = minusplus(uminus(v247), v248); + real2 v259 = ctimesminusplus(reverse(v249), tbl[38 + tbloffset], ctimes(v249, tbl[39 + tbloffset])); + real2 v35 = load(in, 33 << inShift); + real2 v3 = load(in, 1 << inShift); + real2 v92 = plus(v3, v35); + real2 v88 = minus(v35, v3); + real2 v51 = load(in, 49 << inShift); + real2 v19 = load(in, 17 << inShift); + real2 v87 = reverse(minus(v19, v51)); + real2 v93 = plus(v19, v51); + real2 v412 = plus(v92, v93); + real2 v408 = minus(v93, v92); + real2 v411 = minusplus(uminus(v407), v408); + real2 v409 = minusplus(v407, v408); + real2 v91 = minusplus(uminus(v87), v88); + real2 v89 = minusplus(v87, v88); + real2 v99 = ctimesminusplus(reverse(v89), tbl[6 + tbloffset], ctimes(v89, tbl[7 + tbloffset])); + real2 v425 = ctimesminusplus(reverse(v411), tbl[72 + tbloffset], ctimes(v411, tbl[73 + tbloffset])); + real2 v568 = minus(v413, v412); + real2 v572 = plus(v412, v413); + real2 v940 = plus(v99, v259); + real2 v936 = minus(v259, v99); + real2 v419 = ctimesminusplus(reverse(v409), tbl[70 + tbloffset], ctimes(v409, tbl[71 + tbloffset])); + real2 v47 = load(in, 45 << inShift); + real2 v15 = load(in, 13 << inShift); + real2 v332 = plus(v15, v47); + real2 v328 = minus(v47, v15); + real2 v63 = load(in, 61 << inShift); + real2 v31 = load(in, 29 << inShift); + real2 v327 = reverse(minus(v31, v63)); + real2 v333 = plus(v31, v63); + real2 v329 = minusplus(v327, v328); + real2 v331 = minusplus(uminus(v327), v328); + real2 v339 = ctimesminusplus(reverse(v329), tbl[54 + tbloffset], ctimes(v329, tbl[55 + tbloffset])); + real2 v487 = reverse(minus(v332, v333)); + real2 v493 = plus(v332, v333); + real2 v7 = load(in, 5 << inShift); + real2 v39 = load(in, 37 << inShift); + real2 v172 = plus(v7, v39); + real2 v168 = minus(v39, v7); + real2 v55 = load(in, 53 << inShift); + real2 v23 = load(in, 21 << inShift); + real2 v173 = plus(v23, v55); + real2 v167 = reverse(minus(v23, v55)); + real2 v488 = minus(v173, v172); + real2 v492 = plus(v172, v173); + real2 v491 = minusplus(uminus(v487), v488); + real2 v489 = minusplus(v487, v488); + real2 v499 = ctimesminusplus(reverse(v489), tbl[86 + tbloffset], ctimes(v489, tbl[87 + tbloffset])); + real2 v505 = ctimesminusplus(reverse(v491), tbl[88 + tbloffset], ctimes(v491, tbl[89 + tbloffset])); + real2 v567 = reverse(minus(v492, v493)); + real2 v573 = plus(v492, v493); + real2 v571 = minusplus(uminus(v567), v568); + real2 v569 = minusplus(v567, v568); + real2 v579 = ctimesminusplus(reverse(v569), tbl[102 + tbloffset], ctimes(v569, tbl[103 + tbloffset])); + real2 v585 = ctimesminusplus(reverse(v571), tbl[104 + tbloffset], ctimes(v571, tbl[105 + tbloffset])); + real2 v739 = plus(v585, v625); + real2 v733 = reverse(minus(v585, v625)); + real2 v707 = reverse(minus(v579, v619)); + real2 v713 = plus(v579, v619); + real2 v648 = minus(v573, v572); + real2 v652 = plus(v572, v573); + real2 v673 = plus(v652, v653); + real2 v667 = reverse(minus(v652, v653)); + real2 v651 = minusplus(uminus(v647), v648); + real2 v649 = minusplus(v647, v648); + real2 v659 = ctimesminusplus(reverse(v649), tbl[118 + tbloffset], ctimes(v649, tbl[119 + tbloffset])); + real2 v665 = ctimesminusplus(reverse(v651), tbl[120 + tbloffset], ctimes(v651, tbl[121 + tbloffset])); + real2 v780 = minus(v499, v419); + real2 v784 = plus(v419, v499); + real2 v781 = minusplus(v779, v780); + real2 v783 = minusplus(uminus(v779), v780); + real2 v805 = plus(v784, v785); + real2 v799 = reverse(minus(v784, v785)); + real2 v862 = plus(v425, v505); + real2 v858 = minus(v505, v425); + real2 v859 = minusplus(v857, v858); + real2 v861 = minusplus(uminus(v857), v858); + real2 v875 = ctimesminusplus(reverse(v861), tbl[152 + tbloffset], ctimes(v861, tbl[153 + tbloffset])); + real2 v791 = ctimesminusplus(reverse(v781), tbl[138 + tbloffset], ctimes(v781, tbl[139 + tbloffset])); + real2 v797 = ctimesminusplus(reverse(v783), tbl[140 + tbloffset], ctimes(v783, tbl[141 + tbloffset])); + real2 v883 = plus(v862, v863); + real2 v877 = reverse(minus(v862, v863)); + real2 v869 = ctimesminusplus(reverse(v859), tbl[150 + tbloffset], ctimes(v859, tbl[151 + tbloffset])); + real2 v36 = load(in, 34 << inShift); + real2 v4 = load(in, 2 << inShift); + real2 v108 = minus(v36, v4); + real2 v112 = plus(v4, v36); + real2 v52 = load(in, 50 << inShift); + real2 v20 = load(in, 18 << inShift); + real2 v113 = plus(v20, v52); + real2 v107 = reverse(minus(v20, v52)); + real2 v428 = minus(v113, v112); + real2 v432 = plus(v112, v113); + real2 v12 = load(in, 10 << inShift); + real2 v44 = load(in, 42 << inShift); + real2 v268 = minus(v44, v12); + real2 v272 = plus(v12, v44); + real2 v28 = load(in, 26 << inShift); + real2 v60 = load(in, 58 << inShift); + real2 v267 = reverse(minus(v28, v60)); + real2 v273 = plus(v28, v60); + real2 v427 = reverse(minus(v272, v273)); + real2 v433 = plus(v272, v273); + real2 v431 = minusplus(uminus(v427), v428); + real2 v429 = minusplus(v427, v428); + real2 v439 = ctimesminusplus(reverse(v429), tbl[74 + tbloffset], ctimes(v429, tbl[75 + tbloffset])); + real2 v588 = minus(v433, v432); + real2 v592 = plus(v432, v433); + real2 v40 = load(in, 38 << inShift); + real2 v8 = load(in, 6 << inShift); + real2 v188 = minus(v40, v8); + real2 v192 = plus(v8, v40); + real2 v24 = load(in, 22 << inShift); + real2 v56 = load(in, 54 << inShift); + real2 v187 = reverse(minus(v24, v56)); + real2 v193 = plus(v24, v56); + real2 v512 = plus(v192, v193); + real2 v508 = minus(v193, v192); + real2 v32 = load(in, 30 << inShift); + real2 v64 = load(in, 62 << inShift); + real2 v347 = reverse(minus(v32, v64)); + real2 v353 = plus(v32, v64); + real2 v48 = load(in, 46 << inShift); + real2 v16 = load(in, 14 << inShift); + real2 v348 = minus(v48, v16); + real2 v352 = plus(v16, v48); + real2 v513 = plus(v352, v353); + real2 v507 = reverse(minus(v352, v353)); + real2 v587 = reverse(minus(v512, v513)); + real2 v593 = plus(v512, v513); + real2 v633 = plus(v592, v593); + real2 v627 = reverse(minus(v592, v593)); + real2 v591 = minusplus(uminus(v587), v588); + real2 v589 = minusplus(v587, v588); + real2 v605 = ctimesminusplus(reverse(v591), tbl[108 + tbloffset], ctimes(v591, tbl[109 + tbloffset])); + real2 v599 = ctimesminusplus(reverse(v589), tbl[106 + tbloffset], ctimes(v589, tbl[107 + tbloffset])); + real2 v46 = load(in, 44 << inShift); + real2 v14 = load(in, 12 << inShift); + real2 v312 = plus(v14, v46); + real2 v308 = minus(v46, v14); + real2 v62 = load(in, 60 << inShift); + real2 v30 = load(in, 28 << inShift); + real2 v313 = plus(v30, v62); + real2 v307 = reverse(minus(v30, v62)); + real2 v467 = reverse(minus(v312, v313)); + real2 v473 = plus(v312, v313); + real2 v22 = load(in, 20 << inShift); + real2 v54 = load(in, 52 << inShift); + real2 v147 = reverse(minus(v22, v54)); + real2 v153 = plus(v22, v54); + real2 v6 = load(in, 4 << inShift); + real2 v38 = load(in, 36 << inShift); + real2 v148 = minus(v38, v6); + real2 v152 = plus(v6, v38); + real2 v472 = plus(v152, v153); + real2 v468 = minus(v153, v152); + real2 v547 = reverse(minus(v472, v473)); + real2 v553 = plus(v472, v473); + real2 v10 = load(in, 8 << inShift); + real2 v42 = load(in, 40 << inShift); + real2 v232 = plus(v10, v42); + real2 v228 = minus(v42, v10); + real2 v58 = load(in, 56 << inShift); + real2 v26 = load(in, 24 << inShift); + real2 v233 = plus(v26, v58); + real2 v227 = reverse(minus(v26, v58)); + real2 v393 = plus(v232, v233); + real2 v387 = reverse(minus(v232, v233)); + real2 v2 = load(in, 0 << inShift); + real2 v34 = load(in, 32 << inShift); + real2 v72 = plus(v2, v34); + real2 v68 = minus(v34, v2); + real2 v18 = load(in, 16 << inShift); + real2 v50 = load(in, 48 << inShift); + real2 v73 = plus(v18, v50); + real2 v67 = reverse(minus(v18, v50)); + real2 v388 = minus(v73, v72); + real2 v392 = plus(v72, v73); + real2 v548 = minus(v393, v392); + real2 v552 = plus(v392, v393); + real2 v628 = minus(v553, v552); + real2 v632 = plus(v552, v553); + real2 v672 = plus(v632, v633); + real2 v668 = minus(v633, v632); + store(out, 0 << outShift, plus(v672, v673)); + real2 v686 = minus(v672, v673); + store(out, 32 << outShift, ctimesminusplus(v686, tbl[0 + tbloffset], ctimes(reverse(v686), tbl[1 + tbloffset]))); + real2 v669 = minusplus(v667, v668); + real2 v671 = minusplus(uminus(v667), v668); + store(out, 48 << outShift, ctimesminusplus(reverse(v671), tbl[124 + tbloffset], ctimes(v671, tbl[125 + tbloffset]))); + store(out, 16 << outShift, ctimesminusplus(reverse(v669), tbl[122 + tbloffset], ctimes(v669, tbl[123 + tbloffset]))); + real2 v631 = minusplus(uminus(v627), v628); + real2 v629 = minusplus(v627, v628); + real2 v639 = ctimesminusplus(reverse(v629), tbl[114 + tbloffset], ctimes(v629, tbl[115 + tbloffset])); + store(out, 8 << outShift, plus(v639, v659)); + real2 v694 = minus(v639, v659); + store(out, 40 << outShift, ctimesminusplus(v694, tbl[0 + tbloffset], ctimes(reverse(v694), tbl[1 + tbloffset]))); + real2 v645 = ctimesminusplus(reverse(v631), tbl[116 + tbloffset], ctimes(v631, tbl[117 + tbloffset])); + store(out, 24 << outShift, plus(v645, v665)); + real2 v700 = minus(v645, v665); + store(out, 56 << outShift, ctimesminusplus(v700, tbl[0 + tbloffset], ctimes(reverse(v700), tbl[1 + tbloffset]))); + real2 v549 = minusplus(v547, v548); + real2 v551 = minusplus(uminus(v547), v548); + real2 v559 = ctimesminusplus(reverse(v549), tbl[98 + tbloffset], ctimes(v549, tbl[99 + tbloffset])); + real2 v708 = minus(v599, v559); + real2 v712 = plus(v559, v599); + store(out, 4 << outShift, plus(v712, v713)); + real2 v726 = minus(v712, v713); + store(out, 36 << outShift, ctimesminusplus(v726, tbl[0 + tbloffset], ctimes(reverse(v726), tbl[1 + tbloffset]))); + real2 v711 = minusplus(uminus(v707), v708); + real2 v709 = minusplus(v707, v708); + store(out, 20 << outShift, ctimesminusplus(reverse(v709), tbl[126 + tbloffset], ctimes(v709, tbl[127 + tbloffset]))); + store(out, 52 << outShift, ctimesminusplus(reverse(v711), tbl[128 + tbloffset], ctimes(v711, tbl[129 + tbloffset]))); + real2 v565 = ctimesminusplus(reverse(v551), tbl[100 + tbloffset], ctimes(v551, tbl[101 + tbloffset])); + real2 v738 = plus(v565, v605); + real2 v734 = minus(v605, v565); + store(out, 12 << outShift, plus(v738, v739)); + real2 v752 = minus(v738, v739); + store(out, 44 << outShift, ctimesminusplus(v752, tbl[0 + tbloffset], ctimes(reverse(v752), tbl[1 + tbloffset]))); + real2 v737 = minusplus(uminus(v733), v734); + store(out, 60 << outShift, ctimesminusplus(reverse(v737), tbl[132 + tbloffset], ctimes(v737, tbl[133 + tbloffset]))); + real2 v735 = minusplus(v733, v734); + store(out, 28 << outShift, ctimesminusplus(reverse(v735), tbl[130 + tbloffset], ctimes(v735, tbl[131 + tbloffset]))); + real2 v471 = minusplus(uminus(v467), v468); + real2 v469 = minusplus(v467, v468); + real2 v479 = ctimesminusplus(reverse(v469), tbl[82 + tbloffset], ctimes(v469, tbl[83 + tbloffset])); + real2 v511 = minusplus(uminus(v507), v508); + real2 v509 = minusplus(v507, v508); + real2 v519 = ctimesminusplus(reverse(v509), tbl[90 + tbloffset], ctimes(v509, tbl[91 + tbloffset])); + real2 v765 = plus(v439, v519); + real2 v759 = reverse(minus(v439, v519)); + real2 v389 = minusplus(v387, v388); + real2 v391 = minusplus(uminus(v387), v388); + real2 v399 = ctimesminusplus(reverse(v389), tbl[66 + tbloffset], ctimes(v389, tbl[67 + tbloffset])); + real2 v764 = plus(v399, v479); + real2 v760 = minus(v479, v399); + real2 v804 = plus(v764, v765); + real2 v800 = minus(v765, v764); + store(out, 2 << outShift, plus(v804, v805)); + real2 v818 = minus(v804, v805); + store(out, 34 << outShift, ctimesminusplus(v818, tbl[0 + tbloffset], ctimes(reverse(v818), tbl[1 + tbloffset]))); + real2 v803 = minusplus(uminus(v799), v800); + store(out, 50 << outShift, ctimesminusplus(reverse(v803), tbl[144 + tbloffset], ctimes(v803, tbl[145 + tbloffset]))); + real2 v801 = minusplus(v799, v800); + store(out, 18 << outShift, ctimesminusplus(reverse(v801), tbl[142 + tbloffset], ctimes(v801, tbl[143 + tbloffset]))); + real2 v763 = minusplus(uminus(v759), v760); + real2 v761 = minusplus(v759, v760); + real2 v777 = ctimesminusplus(reverse(v763), tbl[136 + tbloffset], ctimes(v763, tbl[137 + tbloffset])); + store(out, 26 << outShift, plus(v777, v797)); + real2 v830 = minus(v777, v797); + store(out, 58 << outShift, ctimesminusplus(v830, tbl[0 + tbloffset], ctimes(reverse(v830), tbl[1 + tbloffset]))); + real2 v771 = ctimesminusplus(reverse(v761), tbl[134 + tbloffset], ctimes(v761, tbl[135 + tbloffset])); + store(out, 10 << outShift, plus(v771, v791)); + real2 v824 = minus(v771, v791); + store(out, 42 << outShift, ctimesminusplus(v824, tbl[0 + tbloffset], ctimes(reverse(v824), tbl[1 + tbloffset]))); + real2 v445 = ctimesminusplus(reverse(v431), tbl[76 + tbloffset], ctimes(v431, tbl[77 + tbloffset])); + real2 v525 = ctimesminusplus(reverse(v511), tbl[92 + tbloffset], ctimes(v511, tbl[93 + tbloffset])); + real2 v837 = reverse(minus(v445, v525)); + real2 v843 = plus(v445, v525); + real2 v485 = ctimesminusplus(reverse(v471), tbl[84 + tbloffset], ctimes(v471, tbl[85 + tbloffset])); + real2 v405 = ctimesminusplus(reverse(v391), tbl[68 + tbloffset], ctimes(v391, tbl[69 + tbloffset])); + real2 v838 = minus(v485, v405); + real2 v842 = plus(v405, v485); + real2 v878 = minus(v843, v842); + real2 v882 = plus(v842, v843); + store(out, 6 << outShift, plus(v882, v883)); + real2 v896 = minus(v882, v883); + store(out, 38 << outShift, ctimesminusplus(v896, tbl[0 + tbloffset], ctimes(reverse(v896), tbl[1 + tbloffset]))); + real2 v881 = minusplus(uminus(v877), v878); + store(out, 54 << outShift, ctimesminusplus(reverse(v881), tbl[156 + tbloffset], ctimes(v881, tbl[157 + tbloffset]))); + real2 v879 = minusplus(v877, v878); + store(out, 22 << outShift, ctimesminusplus(reverse(v879), tbl[154 + tbloffset], ctimes(v879, tbl[155 + tbloffset]))); + real2 v841 = minusplus(uminus(v837), v838); + real2 v839 = minusplus(v837, v838); + real2 v855 = ctimesminusplus(reverse(v841), tbl[148 + tbloffset], ctimes(v841, tbl[149 + tbloffset])); + store(out, 30 << outShift, plus(v855, v875)); + real2 v908 = minus(v855, v875); + store(out, 62 << outShift, ctimesminusplus(v908, tbl[0 + tbloffset], ctimes(reverse(v908), tbl[1 + tbloffset]))); + real2 v849 = ctimesminusplus(reverse(v839), tbl[146 + tbloffset], ctimes(v839, tbl[147 + tbloffset])); + store(out, 14 << outShift, plus(v849, v869)); + real2 v902 = minus(v849, v869); + store(out, 46 << outShift, ctimesminusplus(v902, tbl[0 + tbloffset], ctimes(reverse(v902), tbl[1 + tbloffset]))); + real2 v151 = minusplus(uminus(v147), v148); + real2 v149 = minusplus(v147, v148); + real2 v311 = minusplus(uminus(v307), v308); + real2 v309 = minusplus(v307, v308); + real2 v109 = minusplus(v107, v108); + real2 v111 = minusplus(uminus(v107), v108); + real2 v119 = ctimesminusplus(reverse(v109), tbl[10 + tbloffset], ctimes(v109, tbl[11 + tbloffset])); + real2 v269 = minusplus(v267, v268); + real2 v271 = minusplus(uminus(v267), v268); + real2 v279 = ctimesminusplus(reverse(v269), tbl[42 + tbloffset], ctimes(v269, tbl[43 + tbloffset])); + real2 v960 = plus(v119, v279); + real2 v956 = minus(v279, v119); + real2 v169 = minusplus(v167, v168); + real2 v171 = minusplus(uminus(v167), v168); + real2 v159 = ctimesminusplus(reverse(v149), tbl[18 + tbloffset], ctimes(v149, tbl[19 + tbloffset])); + real2 v319 = ctimesminusplus(reverse(v309), tbl[50 + tbloffset], ctimes(v309, tbl[51 + tbloffset])); + real2 v921 = plus(v159, v319); + real2 v915 = reverse(minus(v159, v319)); + real2 v351 = minusplus(uminus(v347), v348); + real2 v349 = minusplus(v347, v348); + real2 v359 = ctimesminusplus(reverse(v349), tbl[58 + tbloffset], ctimes(v349, tbl[59 + tbloffset])); + real2 v191 = minusplus(uminus(v187), v188); + real2 v189 = minusplus(v187, v188); + real2 v199 = ctimesminusplus(reverse(v189), tbl[26 + tbloffset], ctimes(v189, tbl[27 + tbloffset])); + real2 v961 = plus(v199, v359); + real2 v955 = reverse(minus(v199, v359)); + real2 v995 = reverse(minus(v960, v961)); + real2 v1001 = plus(v960, v961); + real2 v179 = ctimesminusplus(reverse(v169), tbl[22 + tbloffset], ctimes(v169, tbl[23 + tbloffset])); + real2 v941 = plus(v179, v339); + real2 v935 = reverse(minus(v179, v339)); + real2 v1016 = minus(v941, v940); + real2 v1020 = plus(v940, v941); + real2 v71 = minusplus(uminus(v67), v68); + real2 v69 = minusplus(v67, v68); + real2 v79 = ctimesminusplus(reverse(v69), tbl[2 + tbloffset], ctimes(v69, tbl[3 + tbloffset])); + real2 v1041 = plus(v1020, v1021); + real2 v1035 = reverse(minus(v1020, v1021)); + real2 v229 = minusplus(v227, v228); + real2 v231 = minusplus(uminus(v227), v228); + real2 v239 = ctimesminusplus(reverse(v229), tbl[34 + tbloffset], ctimes(v229, tbl[35 + tbloffset])); + real2 v920 = plus(v79, v239); + real2 v916 = minus(v239, v79); + real2 v996 = minus(v921, v920); + real2 v1000 = plus(v920, v921); + real2 v1040 = plus(v1000, v1001); + real2 v1036 = minus(v1001, v1000); + store(out, 1 << outShift, plus(v1040, v1041)); + real2 v1054 = minus(v1040, v1041); + store(out, 33 << outShift, ctimesminusplus(v1054, tbl[0 + tbloffset], ctimes(reverse(v1054), tbl[1 + tbloffset]))); + real2 v1037 = minusplus(v1035, v1036); + real2 v1039 = minusplus(uminus(v1035), v1036); + store(out, 49 << outShift, ctimesminusplus(reverse(v1039), tbl[184 + tbloffset], ctimes(v1039, tbl[185 + tbloffset]))); + store(out, 17 << outShift, ctimesminusplus(reverse(v1037), tbl[182 + tbloffset], ctimes(v1037, tbl[183 + tbloffset]))); + real2 v1017 = minusplus(v1015, v1016); + real2 v1019 = minusplus(uminus(v1015), v1016); + real2 v1033 = ctimesminusplus(reverse(v1019), tbl[180 + tbloffset], ctimes(v1019, tbl[181 + tbloffset])); + real2 v997 = minusplus(v995, v996); + real2 v999 = minusplus(uminus(v995), v996); + real2 v1013 = ctimesminusplus(reverse(v999), tbl[176 + tbloffset], ctimes(v999, tbl[177 + tbloffset])); + store(out, 25 << outShift, plus(v1013, v1033)); + real2 v1066 = minus(v1013, v1033); + store(out, 57 << outShift, ctimesminusplus(v1066, tbl[0 + tbloffset], ctimes(reverse(v1066), tbl[1 + tbloffset]))); + real2 v1027 = ctimesminusplus(reverse(v1017), tbl[178 + tbloffset], ctimes(v1017, tbl[179 + tbloffset])); + real2 v1007 = ctimesminusplus(reverse(v997), tbl[174 + tbloffset], ctimes(v997, tbl[175 + tbloffset])); + store(out, 9 << outShift, plus(v1007, v1027)); + real2 v1060 = minus(v1007, v1027); + store(out, 41 << outShift, ctimesminusplus(v1060, tbl[0 + tbloffset], ctimes(reverse(v1060), tbl[1 + tbloffset]))); + real2 v937 = minusplus(v935, v936); + real2 v939 = minusplus(uminus(v935), v936); + real2 v959 = minusplus(uminus(v955), v956); + real2 v957 = minusplus(v955, v956); + real2 v967 = ctimesminusplus(reverse(v957), tbl[166 + tbloffset], ctimes(v957, tbl[167 + tbloffset])); + real2 v947 = ctimesminusplus(reverse(v937), tbl[162 + tbloffset], ctimes(v937, tbl[163 + tbloffset])); + real2 v919 = minusplus(uminus(v915), v916); + real2 v917 = minusplus(v915, v916); + real2 v1079 = plus(v947, v987); + real2 v1073 = reverse(minus(v947, v987)); + real2 v927 = ctimesminusplus(reverse(v917), tbl[158 + tbloffset], ctimes(v917, tbl[159 + tbloffset])); + real2 v1074 = minus(v967, v927); + real2 v1078 = plus(v927, v967); + store(out, 5 << outShift, plus(v1078, v1079)); + real2 v1092 = minus(v1078, v1079); + store(out, 37 << outShift, ctimesminusplus(v1092, tbl[0 + tbloffset], ctimes(reverse(v1092), tbl[1 + tbloffset]))); + real2 v1075 = minusplus(v1073, v1074); + store(out, 21 << outShift, ctimesminusplus(reverse(v1075), tbl[186 + tbloffset], ctimes(v1075, tbl[187 + tbloffset]))); + real2 v1077 = minusplus(uminus(v1073), v1074); + store(out, 53 << outShift, ctimesminusplus(reverse(v1077), tbl[188 + tbloffset], ctimes(v1077, tbl[189 + tbloffset]))); + real2 v953 = ctimesminusplus(reverse(v939), tbl[164 + tbloffset], ctimes(v939, tbl[165 + tbloffset])); + real2 v1099 = reverse(minus(v953, v993)); + real2 v1105 = plus(v953, v993); + real2 v973 = ctimesminusplus(reverse(v959), tbl[168 + tbloffset], ctimes(v959, tbl[169 + tbloffset])); + real2 v933 = ctimesminusplus(reverse(v919), tbl[160 + tbloffset], ctimes(v919, tbl[161 + tbloffset])); + real2 v1104 = plus(v933, v973); + real2 v1100 = minus(v973, v933); + store(out, 13 << outShift, plus(v1104, v1105)); + real2 v1118 = minus(v1104, v1105); + store(out, 45 << outShift, ctimesminusplus(v1118, tbl[0 + tbloffset], ctimes(reverse(v1118), tbl[1 + tbloffset]))); + real2 v1101 = minusplus(v1099, v1100); + store(out, 29 << outShift, ctimesminusplus(reverse(v1101), tbl[190 + tbloffset], ctimes(v1101, tbl[191 + tbloffset]))); + real2 v1103 = minusplus(uminus(v1099), v1100); + store(out, 61 << outShift, ctimesminusplus(reverse(v1103), tbl[192 + tbloffset], ctimes(v1103, tbl[193 + tbloffset]))); + real2 v345 = ctimesminusplus(reverse(v331), tbl[56 + tbloffset], ctimes(v331, tbl[57 + tbloffset])); + real2 v325 = ctimesminusplus(reverse(v311), tbl[52 + tbloffset], ctimes(v311, tbl[53 + tbloffset])); + real2 v265 = ctimesminusplus(reverse(v251), tbl[40 + tbloffset], ctimes(v251, tbl[41 + tbloffset])); + real2 v185 = ctimesminusplus(reverse(v171), tbl[24 + tbloffset], ctimes(v171, tbl[25 + tbloffset])); + real2 v165 = ctimesminusplus(reverse(v151), tbl[20 + tbloffset], ctimes(v151, tbl[21 + tbloffset])); + real2 v1131 = plus(v165, v325); + real2 v1125 = reverse(minus(v165, v325)); + real2 v1151 = plus(v185, v345); + real2 v1145 = reverse(minus(v185, v345)); + real2 v105 = ctimesminusplus(reverse(v91), tbl[8 + tbloffset], ctimes(v91, tbl[9 + tbloffset])); + real2 v1150 = plus(v105, v265); + real2 v1146 = minus(v265, v105); + real2 v1226 = minus(v1151, v1150); + real2 v1230 = plus(v1150, v1151); + real2 v1231 = plus(v1190, v1191); + real2 v1225 = reverse(minus(v1190, v1191)); + real2 v1245 = reverse(minus(v1230, v1231)); + real2 v1251 = plus(v1230, v1231); + real2 v365 = ctimesminusplus(reverse(v351), tbl[60 + tbloffset], ctimes(v351, tbl[61 + tbloffset])); + real2 v285 = ctimesminusplus(reverse(v271), tbl[44 + tbloffset], ctimes(v271, tbl[45 + tbloffset])); + real2 v205 = ctimesminusplus(reverse(v191), tbl[28 + tbloffset], ctimes(v191, tbl[29 + tbloffset])); + real2 v1171 = plus(v205, v365); + real2 v1165 = reverse(minus(v205, v365)); + real2 v125 = ctimesminusplus(reverse(v111), tbl[12 + tbloffset], ctimes(v111, tbl[13 + tbloffset])); + real2 v85 = ctimesminusplus(reverse(v71), tbl[4 + tbloffset], ctimes(v71, tbl[5 + tbloffset])); + real2 v245 = ctimesminusplus(reverse(v231), tbl[36 + tbloffset], ctimes(v231, tbl[37 + tbloffset])); + real2 v1126 = minus(v245, v85); + real2 v1130 = plus(v85, v245); + real2 v1210 = plus(v1130, v1131); + real2 v1206 = minus(v1131, v1130); + real2 v1166 = minus(v285, v125); + real2 v1170 = plus(v125, v285); + real2 v1211 = plus(v1170, v1171); + real2 v1205 = reverse(minus(v1170, v1171)); + real2 v1246 = minus(v1211, v1210); + real2 v1250 = plus(v1210, v1211); + store(out, 3 << outShift, plus(v1250, v1251)); + real2 v1264 = minus(v1250, v1251); + store(out, 35 << outShift, ctimesminusplus(v1264, tbl[0 + tbloffset], ctimes(reverse(v1264), tbl[1 + tbloffset]))); + real2 v1247 = minusplus(v1245, v1246); + real2 v1249 = minusplus(uminus(v1245), v1246); + store(out, 19 << outShift, ctimesminusplus(reverse(v1247), tbl[218 + tbloffset], ctimes(v1247, tbl[219 + tbloffset]))); + store(out, 51 << outShift, ctimesminusplus(reverse(v1249), tbl[220 + tbloffset], ctimes(v1249, tbl[221 + tbloffset]))); + real2 v1229 = minusplus(uminus(v1225), v1226); + real2 v1227 = minusplus(v1225, v1226); + real2 v1207 = minusplus(v1205, v1206); + real2 v1209 = minusplus(uminus(v1205), v1206); + real2 v1237 = ctimesminusplus(reverse(v1227), tbl[214 + tbloffset], ctimes(v1227, tbl[215 + tbloffset])); + real2 v1217 = ctimesminusplus(reverse(v1207), tbl[210 + tbloffset], ctimes(v1207, tbl[211 + tbloffset])); + store(out, 11 << outShift, plus(v1217, v1237)); + real2 v1270 = minus(v1217, v1237); + store(out, 43 << outShift, ctimesminusplus(v1270, tbl[0 + tbloffset], ctimes(reverse(v1270), tbl[1 + tbloffset]))); + real2 v1223 = ctimesminusplus(reverse(v1209), tbl[212 + tbloffset], ctimes(v1209, tbl[213 + tbloffset])); + real2 v1243 = ctimesminusplus(reverse(v1229), tbl[216 + tbloffset], ctimes(v1229, tbl[217 + tbloffset])); + store(out, 27 << outShift, plus(v1223, v1243)); + real2 v1276 = minus(v1223, v1243); + store(out, 59 << outShift, ctimesminusplus(v1276, tbl[0 + tbloffset], ctimes(reverse(v1276), tbl[1 + tbloffset]))); + real2 v1189 = minusplus(uminus(v1185), v1186); + real2 v1187 = minusplus(v1185, v1186); + real2 v1129 = minusplus(uminus(v1125), v1126); + real2 v1127 = minusplus(v1125, v1126); + real2 v1147 = minusplus(v1145, v1146); + real2 v1149 = minusplus(uminus(v1145), v1146); + real2 v1167 = minusplus(v1165, v1166); + real2 v1169 = minusplus(uminus(v1165), v1166); + real2 v1143 = ctimesminusplus(reverse(v1129), tbl[196 + tbloffset], ctimes(v1129, tbl[197 + tbloffset])); + real2 v1163 = ctimesminusplus(reverse(v1149), tbl[200 + tbloffset], ctimes(v1149, tbl[201 + tbloffset])); + real2 v1203 = ctimesminusplus(reverse(v1189), tbl[208 + tbloffset], ctimes(v1189, tbl[209 + tbloffset])); + real2 v1315 = plus(v1163, v1203); + real2 v1309 = reverse(minus(v1163, v1203)); + real2 v1183 = ctimesminusplus(reverse(v1169), tbl[204 + tbloffset], ctimes(v1169, tbl[205 + tbloffset])); + real2 v1314 = plus(v1143, v1183); + real2 v1310 = minus(v1183, v1143); + store(out, 15 << outShift, plus(v1314, v1315)); + real2 v1328 = minus(v1314, v1315); + store(out, 47 << outShift, ctimesminusplus(v1328, tbl[0 + tbloffset], ctimes(reverse(v1328), tbl[1 + tbloffset]))); + real2 v1311 = minusplus(v1309, v1310); + store(out, 31 << outShift, ctimesminusplus(reverse(v1311), tbl[226 + tbloffset], ctimes(v1311, tbl[227 + tbloffset]))); + real2 v1313 = minusplus(uminus(v1309), v1310); + store(out, 63 << outShift, ctimesminusplus(reverse(v1313), tbl[228 + tbloffset], ctimes(v1313, tbl[229 + tbloffset]))); + real2 v1177 = ctimesminusplus(reverse(v1167), tbl[202 + tbloffset], ctimes(v1167, tbl[203 + tbloffset])); + real2 v1137 = ctimesminusplus(reverse(v1127), tbl[194 + tbloffset], ctimes(v1127, tbl[195 + tbloffset])); + real2 v1197 = ctimesminusplus(reverse(v1187), tbl[206 + tbloffset], ctimes(v1187, tbl[207 + tbloffset])); + real2 v1157 = ctimesminusplus(reverse(v1147), tbl[198 + tbloffset], ctimes(v1147, tbl[199 + tbloffset])); + real2 v1283 = reverse(minus(v1157, v1197)); + real2 v1289 = plus(v1157, v1197); + real2 v1288 = plus(v1137, v1177); + real2 v1284 = minus(v1177, v1137); + store(out, 7 << outShift, plus(v1288, v1289)); + real2 v1302 = minus(v1288, v1289); + store(out, 39 << outShift, ctimesminusplus(v1302, tbl[0 + tbloffset], ctimes(reverse(v1302), tbl[1 + tbloffset]))); + real2 v1285 = minusplus(v1283, v1284); + real2 v1287 = minusplus(uminus(v1283), v1284); + store(out, 55 << outShift, ctimesminusplus(reverse(v1287), tbl[224 + tbloffset], ctimes(v1287, tbl[225 + tbloffset]))); + store(out, 23 << outShift, ctimesminusplus(reverse(v1285), tbl[222 + tbloffset], ctimes(v1285, tbl[223 + tbloffset]))); +// Pres : 17339 + } +} + +ALIGNED(8192) void but64b_%CONFIG%_%ISA%(real *RESTRICT out0, uint32_t *q, const int outShift, const real *RESTRICT in0, const int inShift, const real *RESTRICT tbl, const int K) { + const int k = 1 << (inShift - LOG2VECWIDTH); + int i=0; +#pragma omp parallel for + for(i=0;i < k;i++) { + int i0 = i << LOG2VECWIDTH; + real *out = out0 + q[i]; + const real *in = in0 + i0*2; + const int tbloffset = K * (i0 >> outShift); + +// Pres : 30254 + real2 v37 = load(in, 35 << inShift); + real2 v5 = load(in, 3 << inShift); + real2 v132 = plus(v5, v37); + real2 v128 = minus(v37, v5); + real2 v21 = load(in, 19 << inShift); + real2 v53 = load(in, 51 << inShift); + real2 v133 = plus(v21, v53); + real2 v127 = reverse(minus(v53, v21)); + real2 v131 = minusplus(uminus(v127), v128); + real2 v129 = minusplus(v127, v128); + real2 v139 = ctimesminusplus(reverse(v129), tbl[14 + tbloffset], ctimes(v129, tbl[15 + tbloffset])); + real2 v145 = ctimesminusplus(reverse(v131), tbl[16 + tbloffset], ctimes(v131, tbl[17 + tbloffset])); + real2 v448 = minus(v133, v132); + real2 v452 = plus(v132, v133); + real2 v45 = load(in, 43 << inShift); + real2 v13 = load(in, 11 << inShift); + real2 v292 = plus(v13, v45); + real2 v288 = minus(v45, v13); + real2 v29 = load(in, 27 << inShift); + real2 v61 = load(in, 59 << inShift); + real2 v293 = plus(v29, v61); + real2 v287 = reverse(minus(v61, v29)); + real2 v291 = minusplus(uminus(v287), v288); + real2 v289 = minusplus(v287, v288); + real2 v299 = ctimesminusplus(reverse(v289), tbl[46 + tbloffset], ctimes(v289, tbl[47 + tbloffset])); + real2 v453 = plus(v292, v293); + real2 v447 = reverse(minus(v293, v292)); + real2 v608 = minus(v453, v452); + real2 v612 = plus(v452, v453); + real2 v980 = plus(v139, v299); + real2 v976 = minus(v299, v139); + real2 v449 = minusplus(v447, v448); + real2 v451 = minusplus(uminus(v447), v448); + real2 v465 = ctimesminusplus(reverse(v451), tbl[80 + tbloffset], ctimes(v451, tbl[81 + tbloffset])); + real2 v305 = ctimesminusplus(reverse(v291), tbl[48 + tbloffset], ctimes(v291, tbl[49 + tbloffset])); + real2 v1186 = minus(v305, v145); + real2 v1190 = plus(v145, v305); + real2 v459 = ctimesminusplus(reverse(v449), tbl[78 + tbloffset], ctimes(v449, tbl[79 + tbloffset])); + real2 v25 = load(in, 23 << inShift); + real2 v57 = load(in, 55 << inShift); + real2 v207 = reverse(minus(v57, v25)); + real2 v213 = plus(v25, v57); + real2 v9 = load(in, 7 << inShift); + real2 v41 = load(in, 39 << inShift); + real2 v212 = plus(v9, v41); + real2 v208 = minus(v41, v9); + real2 v528 = minus(v213, v212); + real2 v532 = plus(v212, v213); + real2 v209 = minusplus(v207, v208); + real2 v211 = minusplus(uminus(v207), v208); + real2 v225 = ctimesminusplus(reverse(v211), tbl[32 + tbloffset], ctimes(v211, tbl[33 + tbloffset])); + real2 v219 = ctimesminusplus(reverse(v209), tbl[30 + tbloffset], ctimes(v209, tbl[31 + tbloffset])); + real2 v17 = load(in, 15 << inShift); + real2 v49 = load(in, 47 << inShift); + real2 v368 = minus(v49, v17); + real2 v372 = plus(v17, v49); + real2 v33 = load(in, 31 << inShift); + real2 v65 = load(in, 63 << inShift); + real2 v367 = reverse(minus(v65, v33)); + real2 v373 = plus(v33, v65); + real2 v369 = minusplus(v367, v368); + real2 v371 = minusplus(uminus(v367), v368); + real2 v533 = plus(v372, v373); + real2 v527 = reverse(minus(v373, v372)); + real2 v607 = reverse(minus(v533, v532)); + real2 v613 = plus(v532, v533); + real2 v529 = minusplus(v527, v528); + real2 v531 = minusplus(uminus(v527), v528); + real2 v545 = ctimesminusplus(reverse(v531), tbl[96 + tbloffset], ctimes(v531, tbl[97 + tbloffset])); + real2 v653 = plus(v612, v613); + real2 v647 = reverse(minus(v613, v612)); + real2 v609 = minusplus(v607, v608); + real2 v611 = minusplus(uminus(v607), v608); + real2 v863 = plus(v465, v545); + real2 v857 = reverse(minus(v545, v465)); + real2 v539 = ctimesminusplus(reverse(v529), tbl[94 + tbloffset], ctimes(v529, tbl[95 + tbloffset])); + real2 v385 = ctimesminusplus(reverse(v371), tbl[64 + tbloffset], ctimes(v371, tbl[65 + tbloffset])); + real2 v619 = ctimesminusplus(reverse(v609), tbl[110 + tbloffset], ctimes(v609, tbl[111 + tbloffset])); + real2 v1191 = plus(v225, v385); + real2 v1185 = reverse(minus(v385, v225)); + real2 v779 = reverse(minus(v539, v459)); + real2 v785 = plus(v459, v539); + real2 v625 = ctimesminusplus(reverse(v611), tbl[112 + tbloffset], ctimes(v611, tbl[113 + tbloffset])); + real2 v379 = ctimesminusplus(reverse(v369), tbl[62 + tbloffset], ctimes(v369, tbl[63 + tbloffset])); + real2 v975 = reverse(minus(v379, v219)); + real2 v981 = plus(v219, v379); + real2 v977 = minusplus(v975, v976); + real2 v979 = minusplus(uminus(v975), v976); + real2 v987 = ctimesminusplus(reverse(v977), tbl[170 + tbloffset], ctimes(v977, tbl[171 + tbloffset])); + real2 v993 = ctimesminusplus(reverse(v979), tbl[172 + tbloffset], ctimes(v979, tbl[173 + tbloffset])); + real2 v1015 = reverse(minus(v981, v980)); + real2 v1021 = plus(v980, v981); + real2 v11 = load(in, 9 << inShift); + real2 v43 = load(in, 41 << inShift); + real2 v248 = minus(v43, v11); + real2 v252 = plus(v11, v43); + real2 v59 = load(in, 57 << inShift); + real2 v27 = load(in, 25 << inShift); + real2 v253 = plus(v27, v59); + real2 v247 = reverse(minus(v59, v27)); + real2 v413 = plus(v252, v253); + real2 v407 = reverse(minus(v253, v252)); + real2 v249 = minusplus(v247, v248); + real2 v251 = minusplus(uminus(v247), v248); + real2 v259 = ctimesminusplus(reverse(v249), tbl[38 + tbloffset], ctimes(v249, tbl[39 + tbloffset])); + real2 v35 = load(in, 33 << inShift); + real2 v3 = load(in, 1 << inShift); + real2 v92 = plus(v3, v35); + real2 v88 = minus(v35, v3); + real2 v51 = load(in, 49 << inShift); + real2 v19 = load(in, 17 << inShift); + real2 v87 = reverse(minus(v51, v19)); + real2 v93 = plus(v19, v51); + real2 v412 = plus(v92, v93); + real2 v408 = minus(v93, v92); + real2 v411 = minusplus(uminus(v407), v408); + real2 v409 = minusplus(v407, v408); + real2 v91 = minusplus(uminus(v87), v88); + real2 v89 = minusplus(v87, v88); + real2 v99 = ctimesminusplus(reverse(v89), tbl[6 + tbloffset], ctimes(v89, tbl[7 + tbloffset])); + real2 v425 = ctimesminusplus(reverse(v411), tbl[72 + tbloffset], ctimes(v411, tbl[73 + tbloffset])); + real2 v568 = minus(v413, v412); + real2 v572 = plus(v412, v413); + real2 v940 = plus(v99, v259); + real2 v936 = minus(v259, v99); + real2 v419 = ctimesminusplus(reverse(v409), tbl[70 + tbloffset], ctimes(v409, tbl[71 + tbloffset])); + real2 v47 = load(in, 45 << inShift); + real2 v15 = load(in, 13 << inShift); + real2 v332 = plus(v15, v47); + real2 v328 = minus(v47, v15); + real2 v63 = load(in, 61 << inShift); + real2 v31 = load(in, 29 << inShift); + real2 v327 = reverse(minus(v63, v31)); + real2 v333 = plus(v31, v63); + real2 v329 = minusplus(v327, v328); + real2 v331 = minusplus(uminus(v327), v328); + real2 v339 = ctimesminusplus(reverse(v329), tbl[54 + tbloffset], ctimes(v329, tbl[55 + tbloffset])); + real2 v487 = reverse(minus(v333, v332)); + real2 v493 = plus(v332, v333); + real2 v7 = load(in, 5 << inShift); + real2 v39 = load(in, 37 << inShift); + real2 v172 = plus(v7, v39); + real2 v168 = minus(v39, v7); + real2 v55 = load(in, 53 << inShift); + real2 v23 = load(in, 21 << inShift); + real2 v173 = plus(v23, v55); + real2 v167 = reverse(minus(v55, v23)); + real2 v488 = minus(v173, v172); + real2 v492 = plus(v172, v173); + real2 v491 = minusplus(uminus(v487), v488); + real2 v489 = minusplus(v487, v488); + real2 v499 = ctimesminusplus(reverse(v489), tbl[86 + tbloffset], ctimes(v489, tbl[87 + tbloffset])); + real2 v505 = ctimesminusplus(reverse(v491), tbl[88 + tbloffset], ctimes(v491, tbl[89 + tbloffset])); + real2 v567 = reverse(minus(v493, v492)); + real2 v573 = plus(v492, v493); + real2 v571 = minusplus(uminus(v567), v568); + real2 v569 = minusplus(v567, v568); + real2 v579 = ctimesminusplus(reverse(v569), tbl[102 + tbloffset], ctimes(v569, tbl[103 + tbloffset])); + real2 v585 = ctimesminusplus(reverse(v571), tbl[104 + tbloffset], ctimes(v571, tbl[105 + tbloffset])); + real2 v739 = plus(v585, v625); + real2 v733 = reverse(minus(v625, v585)); + real2 v707 = reverse(minus(v619, v579)); + real2 v713 = plus(v579, v619); + real2 v648 = minus(v573, v572); + real2 v652 = plus(v572, v573); + real2 v673 = plus(v652, v653); + real2 v667 = reverse(minus(v653, v652)); + real2 v651 = minusplus(uminus(v647), v648); + real2 v649 = minusplus(v647, v648); + real2 v659 = ctimesminusplus(reverse(v649), tbl[118 + tbloffset], ctimes(v649, tbl[119 + tbloffset])); + real2 v665 = ctimesminusplus(reverse(v651), tbl[120 + tbloffset], ctimes(v651, tbl[121 + tbloffset])); + real2 v780 = minus(v499, v419); + real2 v784 = plus(v419, v499); + real2 v781 = minusplus(v779, v780); + real2 v783 = minusplus(uminus(v779), v780); + real2 v805 = plus(v784, v785); + real2 v799 = reverse(minus(v785, v784)); + real2 v862 = plus(v425, v505); + real2 v858 = minus(v505, v425); + real2 v859 = minusplus(v857, v858); + real2 v861 = minusplus(uminus(v857), v858); + real2 v875 = ctimesminusplus(reverse(v861), tbl[152 + tbloffset], ctimes(v861, tbl[153 + tbloffset])); + real2 v791 = ctimesminusplus(reverse(v781), tbl[138 + tbloffset], ctimes(v781, tbl[139 + tbloffset])); + real2 v797 = ctimesminusplus(reverse(v783), tbl[140 + tbloffset], ctimes(v783, tbl[141 + tbloffset])); + real2 v883 = plus(v862, v863); + real2 v877 = reverse(minus(v863, v862)); + real2 v869 = ctimesminusplus(reverse(v859), tbl[150 + tbloffset], ctimes(v859, tbl[151 + tbloffset])); + real2 v36 = load(in, 34 << inShift); + real2 v4 = load(in, 2 << inShift); + real2 v108 = minus(v36, v4); + real2 v112 = plus(v4, v36); + real2 v52 = load(in, 50 << inShift); + real2 v20 = load(in, 18 << inShift); + real2 v113 = plus(v20, v52); + real2 v107 = reverse(minus(v52, v20)); + real2 v428 = minus(v113, v112); + real2 v432 = plus(v112, v113); + real2 v12 = load(in, 10 << inShift); + real2 v44 = load(in, 42 << inShift); + real2 v268 = minus(v44, v12); + real2 v272 = plus(v12, v44); + real2 v28 = load(in, 26 << inShift); + real2 v60 = load(in, 58 << inShift); + real2 v267 = reverse(minus(v60, v28)); + real2 v273 = plus(v28, v60); + real2 v427 = reverse(minus(v273, v272)); + real2 v433 = plus(v272, v273); + real2 v431 = minusplus(uminus(v427), v428); + real2 v429 = minusplus(v427, v428); + real2 v439 = ctimesminusplus(reverse(v429), tbl[74 + tbloffset], ctimes(v429, tbl[75 + tbloffset])); + real2 v588 = minus(v433, v432); + real2 v592 = plus(v432, v433); + real2 v40 = load(in, 38 << inShift); + real2 v8 = load(in, 6 << inShift); + real2 v188 = minus(v40, v8); + real2 v192 = plus(v8, v40); + real2 v24 = load(in, 22 << inShift); + real2 v56 = load(in, 54 << inShift); + real2 v187 = reverse(minus(v56, v24)); + real2 v193 = plus(v24, v56); + real2 v512 = plus(v192, v193); + real2 v508 = minus(v193, v192); + real2 v32 = load(in, 30 << inShift); + real2 v64 = load(in, 62 << inShift); + real2 v347 = reverse(minus(v64, v32)); + real2 v353 = plus(v32, v64); + real2 v48 = load(in, 46 << inShift); + real2 v16 = load(in, 14 << inShift); + real2 v348 = minus(v48, v16); + real2 v352 = plus(v16, v48); + real2 v513 = plus(v352, v353); + real2 v507 = reverse(minus(v353, v352)); + real2 v587 = reverse(minus(v513, v512)); + real2 v593 = plus(v512, v513); + real2 v633 = plus(v592, v593); + real2 v627 = reverse(minus(v593, v592)); + real2 v591 = minusplus(uminus(v587), v588); + real2 v589 = minusplus(v587, v588); + real2 v605 = ctimesminusplus(reverse(v591), tbl[108 + tbloffset], ctimes(v591, tbl[109 + tbloffset])); + real2 v599 = ctimesminusplus(reverse(v589), tbl[106 + tbloffset], ctimes(v589, tbl[107 + tbloffset])); + real2 v46 = load(in, 44 << inShift); + real2 v14 = load(in, 12 << inShift); + real2 v312 = plus(v14, v46); + real2 v308 = minus(v46, v14); + real2 v62 = load(in, 60 << inShift); + real2 v30 = load(in, 28 << inShift); + real2 v313 = plus(v30, v62); + real2 v307 = reverse(minus(v62, v30)); + real2 v467 = reverse(minus(v313, v312)); + real2 v473 = plus(v312, v313); + real2 v22 = load(in, 20 << inShift); + real2 v54 = load(in, 52 << inShift); + real2 v147 = reverse(minus(v54, v22)); + real2 v153 = plus(v22, v54); + real2 v6 = load(in, 4 << inShift); + real2 v38 = load(in, 36 << inShift); + real2 v148 = minus(v38, v6); + real2 v152 = plus(v6, v38); + real2 v472 = plus(v152, v153); + real2 v468 = minus(v153, v152); + real2 v547 = reverse(minus(v473, v472)); + real2 v553 = plus(v472, v473); + real2 v10 = load(in, 8 << inShift); + real2 v42 = load(in, 40 << inShift); + real2 v232 = plus(v10, v42); + real2 v228 = minus(v42, v10); + real2 v58 = load(in, 56 << inShift); + real2 v26 = load(in, 24 << inShift); + real2 v233 = plus(v26, v58); + real2 v227 = reverse(minus(v58, v26)); + real2 v393 = plus(v232, v233); + real2 v387 = reverse(minus(v233, v232)); + real2 v2 = load(in, 0 << inShift); + real2 v34 = load(in, 32 << inShift); + real2 v72 = plus(v2, v34); + real2 v68 = minus(v34, v2); + real2 v18 = load(in, 16 << inShift); + real2 v50 = load(in, 48 << inShift); + real2 v73 = plus(v18, v50); + real2 v67 = reverse(minus(v50, v18)); + real2 v388 = minus(v73, v72); + real2 v392 = plus(v72, v73); + real2 v548 = minus(v393, v392); + real2 v552 = plus(v392, v393); + real2 v628 = minus(v553, v552); + real2 v632 = plus(v552, v553); + real2 v672 = plus(v632, v633); + real2 v668 = minus(v633, v632); + store(out, 0 << outShift, plus(v672, v673)); + real2 v686 = minus(v672, v673); + store(out, 32 << outShift, ctimesminusplus(v686, tbl[0 + tbloffset], ctimes(reverse(v686), tbl[1 + tbloffset]))); + real2 v669 = minusplus(v667, v668); + real2 v671 = minusplus(uminus(v667), v668); + store(out, 48 << outShift, ctimesminusplus(reverse(v671), tbl[124 + tbloffset], ctimes(v671, tbl[125 + tbloffset]))); + store(out, 16 << outShift, ctimesminusplus(reverse(v669), tbl[122 + tbloffset], ctimes(v669, tbl[123 + tbloffset]))); + real2 v631 = minusplus(uminus(v627), v628); + real2 v629 = minusplus(v627, v628); + real2 v639 = ctimesminusplus(reverse(v629), tbl[114 + tbloffset], ctimes(v629, tbl[115 + tbloffset])); + store(out, 8 << outShift, plus(v639, v659)); + real2 v694 = minus(v639, v659); + store(out, 40 << outShift, ctimesminusplus(v694, tbl[0 + tbloffset], ctimes(reverse(v694), tbl[1 + tbloffset]))); + real2 v645 = ctimesminusplus(reverse(v631), tbl[116 + tbloffset], ctimes(v631, tbl[117 + tbloffset])); + store(out, 24 << outShift, plus(v645, v665)); + real2 v700 = minus(v645, v665); + store(out, 56 << outShift, ctimesminusplus(v700, tbl[0 + tbloffset], ctimes(reverse(v700), tbl[1 + tbloffset]))); + real2 v549 = minusplus(v547, v548); + real2 v551 = minusplus(uminus(v547), v548); + real2 v559 = ctimesminusplus(reverse(v549), tbl[98 + tbloffset], ctimes(v549, tbl[99 + tbloffset])); + real2 v708 = minus(v599, v559); + real2 v712 = plus(v559, v599); + store(out, 4 << outShift, plus(v712, v713)); + real2 v726 = minus(v712, v713); + store(out, 36 << outShift, ctimesminusplus(v726, tbl[0 + tbloffset], ctimes(reverse(v726), tbl[1 + tbloffset]))); + real2 v711 = minusplus(uminus(v707), v708); + real2 v709 = minusplus(v707, v708); + store(out, 20 << outShift, ctimesminusplus(reverse(v709), tbl[126 + tbloffset], ctimes(v709, tbl[127 + tbloffset]))); + store(out, 52 << outShift, ctimesminusplus(reverse(v711), tbl[128 + tbloffset], ctimes(v711, tbl[129 + tbloffset]))); + real2 v565 = ctimesminusplus(reverse(v551), tbl[100 + tbloffset], ctimes(v551, tbl[101 + tbloffset])); + real2 v738 = plus(v565, v605); + real2 v734 = minus(v605, v565); + store(out, 12 << outShift, plus(v738, v739)); + real2 v752 = minus(v738, v739); + store(out, 44 << outShift, ctimesminusplus(v752, tbl[0 + tbloffset], ctimes(reverse(v752), tbl[1 + tbloffset]))); + real2 v737 = minusplus(uminus(v733), v734); + store(out, 60 << outShift, ctimesminusplus(reverse(v737), tbl[132 + tbloffset], ctimes(v737, tbl[133 + tbloffset]))); + real2 v735 = minusplus(v733, v734); + store(out, 28 << outShift, ctimesminusplus(reverse(v735), tbl[130 + tbloffset], ctimes(v735, tbl[131 + tbloffset]))); + real2 v471 = minusplus(uminus(v467), v468); + real2 v469 = minusplus(v467, v468); + real2 v479 = ctimesminusplus(reverse(v469), tbl[82 + tbloffset], ctimes(v469, tbl[83 + tbloffset])); + real2 v511 = minusplus(uminus(v507), v508); + real2 v509 = minusplus(v507, v508); + real2 v519 = ctimesminusplus(reverse(v509), tbl[90 + tbloffset], ctimes(v509, tbl[91 + tbloffset])); + real2 v765 = plus(v439, v519); + real2 v759 = reverse(minus(v519, v439)); + real2 v389 = minusplus(v387, v388); + real2 v391 = minusplus(uminus(v387), v388); + real2 v399 = ctimesminusplus(reverse(v389), tbl[66 + tbloffset], ctimes(v389, tbl[67 + tbloffset])); + real2 v764 = plus(v399, v479); + real2 v760 = minus(v479, v399); + real2 v804 = plus(v764, v765); + real2 v800 = minus(v765, v764); + store(out, 2 << outShift, plus(v804, v805)); + real2 v818 = minus(v804, v805); + store(out, 34 << outShift, ctimesminusplus(v818, tbl[0 + tbloffset], ctimes(reverse(v818), tbl[1 + tbloffset]))); + real2 v803 = minusplus(uminus(v799), v800); + store(out, 50 << outShift, ctimesminusplus(reverse(v803), tbl[144 + tbloffset], ctimes(v803, tbl[145 + tbloffset]))); + real2 v801 = minusplus(v799, v800); + store(out, 18 << outShift, ctimesminusplus(reverse(v801), tbl[142 + tbloffset], ctimes(v801, tbl[143 + tbloffset]))); + real2 v763 = minusplus(uminus(v759), v760); + real2 v761 = minusplus(v759, v760); + real2 v777 = ctimesminusplus(reverse(v763), tbl[136 + tbloffset], ctimes(v763, tbl[137 + tbloffset])); + store(out, 26 << outShift, plus(v777, v797)); + real2 v830 = minus(v777, v797); + store(out, 58 << outShift, ctimesminusplus(v830, tbl[0 + tbloffset], ctimes(reverse(v830), tbl[1 + tbloffset]))); + real2 v771 = ctimesminusplus(reverse(v761), tbl[134 + tbloffset], ctimes(v761, tbl[135 + tbloffset])); + store(out, 10 << outShift, plus(v771, v791)); + real2 v824 = minus(v771, v791); + store(out, 42 << outShift, ctimesminusplus(v824, tbl[0 + tbloffset], ctimes(reverse(v824), tbl[1 + tbloffset]))); + real2 v445 = ctimesminusplus(reverse(v431), tbl[76 + tbloffset], ctimes(v431, tbl[77 + tbloffset])); + real2 v525 = ctimesminusplus(reverse(v511), tbl[92 + tbloffset], ctimes(v511, tbl[93 + tbloffset])); + real2 v837 = reverse(minus(v525, v445)); + real2 v843 = plus(v445, v525); + real2 v485 = ctimesminusplus(reverse(v471), tbl[84 + tbloffset], ctimes(v471, tbl[85 + tbloffset])); + real2 v405 = ctimesminusplus(reverse(v391), tbl[68 + tbloffset], ctimes(v391, tbl[69 + tbloffset])); + real2 v838 = minus(v485, v405); + real2 v842 = plus(v405, v485); + real2 v878 = minus(v843, v842); + real2 v882 = plus(v842, v843); + store(out, 6 << outShift, plus(v882, v883)); + real2 v896 = minus(v882, v883); + store(out, 38 << outShift, ctimesminusplus(v896, tbl[0 + tbloffset], ctimes(reverse(v896), tbl[1 + tbloffset]))); + real2 v881 = minusplus(uminus(v877), v878); + store(out, 54 << outShift, ctimesminusplus(reverse(v881), tbl[156 + tbloffset], ctimes(v881, tbl[157 + tbloffset]))); + real2 v879 = minusplus(v877, v878); + store(out, 22 << outShift, ctimesminusplus(reverse(v879), tbl[154 + tbloffset], ctimes(v879, tbl[155 + tbloffset]))); + real2 v841 = minusplus(uminus(v837), v838); + real2 v839 = minusplus(v837, v838); + real2 v855 = ctimesminusplus(reverse(v841), tbl[148 + tbloffset], ctimes(v841, tbl[149 + tbloffset])); + store(out, 30 << outShift, plus(v855, v875)); + real2 v908 = minus(v855, v875); + store(out, 62 << outShift, ctimesminusplus(v908, tbl[0 + tbloffset], ctimes(reverse(v908), tbl[1 + tbloffset]))); + real2 v849 = ctimesminusplus(reverse(v839), tbl[146 + tbloffset], ctimes(v839, tbl[147 + tbloffset])); + store(out, 14 << outShift, plus(v849, v869)); + real2 v902 = minus(v849, v869); + store(out, 46 << outShift, ctimesminusplus(v902, tbl[0 + tbloffset], ctimes(reverse(v902), tbl[1 + tbloffset]))); + real2 v151 = minusplus(uminus(v147), v148); + real2 v149 = minusplus(v147, v148); + real2 v311 = minusplus(uminus(v307), v308); + real2 v309 = minusplus(v307, v308); + real2 v109 = minusplus(v107, v108); + real2 v111 = minusplus(uminus(v107), v108); + real2 v119 = ctimesminusplus(reverse(v109), tbl[10 + tbloffset], ctimes(v109, tbl[11 + tbloffset])); + real2 v269 = minusplus(v267, v268); + real2 v271 = minusplus(uminus(v267), v268); + real2 v279 = ctimesminusplus(reverse(v269), tbl[42 + tbloffset], ctimes(v269, tbl[43 + tbloffset])); + real2 v960 = plus(v119, v279); + real2 v956 = minus(v279, v119); + real2 v169 = minusplus(v167, v168); + real2 v171 = minusplus(uminus(v167), v168); + real2 v159 = ctimesminusplus(reverse(v149), tbl[18 + tbloffset], ctimes(v149, tbl[19 + tbloffset])); + real2 v319 = ctimesminusplus(reverse(v309), tbl[50 + tbloffset], ctimes(v309, tbl[51 + tbloffset])); + real2 v921 = plus(v159, v319); + real2 v915 = reverse(minus(v319, v159)); + real2 v351 = minusplus(uminus(v347), v348); + real2 v349 = minusplus(v347, v348); + real2 v359 = ctimesminusplus(reverse(v349), tbl[58 + tbloffset], ctimes(v349, tbl[59 + tbloffset])); + real2 v191 = minusplus(uminus(v187), v188); + real2 v189 = minusplus(v187, v188); + real2 v199 = ctimesminusplus(reverse(v189), tbl[26 + tbloffset], ctimes(v189, tbl[27 + tbloffset])); + real2 v961 = plus(v199, v359); + real2 v955 = reverse(minus(v359, v199)); + real2 v995 = reverse(minus(v961, v960)); + real2 v1001 = plus(v960, v961); + real2 v179 = ctimesminusplus(reverse(v169), tbl[22 + tbloffset], ctimes(v169, tbl[23 + tbloffset])); + real2 v941 = plus(v179, v339); + real2 v935 = reverse(minus(v339, v179)); + real2 v1016 = minus(v941, v940); + real2 v1020 = plus(v940, v941); + real2 v71 = minusplus(uminus(v67), v68); + real2 v69 = minusplus(v67, v68); + real2 v79 = ctimesminusplus(reverse(v69), tbl[2 + tbloffset], ctimes(v69, tbl[3 + tbloffset])); + real2 v1041 = plus(v1020, v1021); + real2 v1035 = reverse(minus(v1021, v1020)); + real2 v229 = minusplus(v227, v228); + real2 v231 = minusplus(uminus(v227), v228); + real2 v239 = ctimesminusplus(reverse(v229), tbl[34 + tbloffset], ctimes(v229, tbl[35 + tbloffset])); + real2 v920 = plus(v79, v239); + real2 v916 = minus(v239, v79); + real2 v996 = minus(v921, v920); + real2 v1000 = plus(v920, v921); + real2 v1040 = plus(v1000, v1001); + real2 v1036 = minus(v1001, v1000); + store(out, 1 << outShift, plus(v1040, v1041)); + real2 v1054 = minus(v1040, v1041); + store(out, 33 << outShift, ctimesminusplus(v1054, tbl[0 + tbloffset], ctimes(reverse(v1054), tbl[1 + tbloffset]))); + real2 v1037 = minusplus(v1035, v1036); + real2 v1039 = minusplus(uminus(v1035), v1036); + store(out, 49 << outShift, ctimesminusplus(reverse(v1039), tbl[184 + tbloffset], ctimes(v1039, tbl[185 + tbloffset]))); + store(out, 17 << outShift, ctimesminusplus(reverse(v1037), tbl[182 + tbloffset], ctimes(v1037, tbl[183 + tbloffset]))); + real2 v1017 = minusplus(v1015, v1016); + real2 v1019 = minusplus(uminus(v1015), v1016); + real2 v1033 = ctimesminusplus(reverse(v1019), tbl[180 + tbloffset], ctimes(v1019, tbl[181 + tbloffset])); + real2 v997 = minusplus(v995, v996); + real2 v999 = minusplus(uminus(v995), v996); + real2 v1013 = ctimesminusplus(reverse(v999), tbl[176 + tbloffset], ctimes(v999, tbl[177 + tbloffset])); + store(out, 25 << outShift, plus(v1013, v1033)); + real2 v1066 = minus(v1013, v1033); + store(out, 57 << outShift, ctimesminusplus(v1066, tbl[0 + tbloffset], ctimes(reverse(v1066), tbl[1 + tbloffset]))); + real2 v1027 = ctimesminusplus(reverse(v1017), tbl[178 + tbloffset], ctimes(v1017, tbl[179 + tbloffset])); + real2 v1007 = ctimesminusplus(reverse(v997), tbl[174 + tbloffset], ctimes(v997, tbl[175 + tbloffset])); + store(out, 9 << outShift, plus(v1007, v1027)); + real2 v1060 = minus(v1007, v1027); + store(out, 41 << outShift, ctimesminusplus(v1060, tbl[0 + tbloffset], ctimes(reverse(v1060), tbl[1 + tbloffset]))); + real2 v937 = minusplus(v935, v936); + real2 v939 = minusplus(uminus(v935), v936); + real2 v959 = minusplus(uminus(v955), v956); + real2 v957 = minusplus(v955, v956); + real2 v967 = ctimesminusplus(reverse(v957), tbl[166 + tbloffset], ctimes(v957, tbl[167 + tbloffset])); + real2 v947 = ctimesminusplus(reverse(v937), tbl[162 + tbloffset], ctimes(v937, tbl[163 + tbloffset])); + real2 v919 = minusplus(uminus(v915), v916); + real2 v917 = minusplus(v915, v916); + real2 v1079 = plus(v947, v987); + real2 v1073 = reverse(minus(v987, v947)); + real2 v927 = ctimesminusplus(reverse(v917), tbl[158 + tbloffset], ctimes(v917, tbl[159 + tbloffset])); + real2 v1074 = minus(v967, v927); + real2 v1078 = plus(v927, v967); + store(out, 5 << outShift, plus(v1078, v1079)); + real2 v1092 = minus(v1078, v1079); + store(out, 37 << outShift, ctimesminusplus(v1092, tbl[0 + tbloffset], ctimes(reverse(v1092), tbl[1 + tbloffset]))); + real2 v1075 = minusplus(v1073, v1074); + store(out, 21 << outShift, ctimesminusplus(reverse(v1075), tbl[186 + tbloffset], ctimes(v1075, tbl[187 + tbloffset]))); + real2 v1077 = minusplus(uminus(v1073), v1074); + store(out, 53 << outShift, ctimesminusplus(reverse(v1077), tbl[188 + tbloffset], ctimes(v1077, tbl[189 + tbloffset]))); + real2 v953 = ctimesminusplus(reverse(v939), tbl[164 + tbloffset], ctimes(v939, tbl[165 + tbloffset])); + real2 v1099 = reverse(minus(v993, v953)); + real2 v1105 = plus(v953, v993); + real2 v973 = ctimesminusplus(reverse(v959), tbl[168 + tbloffset], ctimes(v959, tbl[169 + tbloffset])); + real2 v933 = ctimesminusplus(reverse(v919), tbl[160 + tbloffset], ctimes(v919, tbl[161 + tbloffset])); + real2 v1104 = plus(v933, v973); + real2 v1100 = minus(v973, v933); + store(out, 13 << outShift, plus(v1104, v1105)); + real2 v1118 = minus(v1104, v1105); + store(out, 45 << outShift, ctimesminusplus(v1118, tbl[0 + tbloffset], ctimes(reverse(v1118), tbl[1 + tbloffset]))); + real2 v1101 = minusplus(v1099, v1100); + store(out, 29 << outShift, ctimesminusplus(reverse(v1101), tbl[190 + tbloffset], ctimes(v1101, tbl[191 + tbloffset]))); + real2 v1103 = minusplus(uminus(v1099), v1100); + store(out, 61 << outShift, ctimesminusplus(reverse(v1103), tbl[192 + tbloffset], ctimes(v1103, tbl[193 + tbloffset]))); + real2 v345 = ctimesminusplus(reverse(v331), tbl[56 + tbloffset], ctimes(v331, tbl[57 + tbloffset])); + real2 v325 = ctimesminusplus(reverse(v311), tbl[52 + tbloffset], ctimes(v311, tbl[53 + tbloffset])); + real2 v265 = ctimesminusplus(reverse(v251), tbl[40 + tbloffset], ctimes(v251, tbl[41 + tbloffset])); + real2 v185 = ctimesminusplus(reverse(v171), tbl[24 + tbloffset], ctimes(v171, tbl[25 + tbloffset])); + real2 v165 = ctimesminusplus(reverse(v151), tbl[20 + tbloffset], ctimes(v151, tbl[21 + tbloffset])); + real2 v1131 = plus(v165, v325); + real2 v1125 = reverse(minus(v325, v165)); + real2 v1151 = plus(v185, v345); + real2 v1145 = reverse(minus(v345, v185)); + real2 v105 = ctimesminusplus(reverse(v91), tbl[8 + tbloffset], ctimes(v91, tbl[9 + tbloffset])); + real2 v1150 = plus(v105, v265); + real2 v1146 = minus(v265, v105); + real2 v1226 = minus(v1151, v1150); + real2 v1230 = plus(v1150, v1151); + real2 v1231 = plus(v1190, v1191); + real2 v1225 = reverse(minus(v1191, v1190)); + real2 v1245 = reverse(minus(v1231, v1230)); + real2 v1251 = plus(v1230, v1231); + real2 v365 = ctimesminusplus(reverse(v351), tbl[60 + tbloffset], ctimes(v351, tbl[61 + tbloffset])); + real2 v285 = ctimesminusplus(reverse(v271), tbl[44 + tbloffset], ctimes(v271, tbl[45 + tbloffset])); + real2 v205 = ctimesminusplus(reverse(v191), tbl[28 + tbloffset], ctimes(v191, tbl[29 + tbloffset])); + real2 v1171 = plus(v205, v365); + real2 v1165 = reverse(minus(v365, v205)); + real2 v125 = ctimesminusplus(reverse(v111), tbl[12 + tbloffset], ctimes(v111, tbl[13 + tbloffset])); + real2 v85 = ctimesminusplus(reverse(v71), tbl[4 + tbloffset], ctimes(v71, tbl[5 + tbloffset])); + real2 v245 = ctimesminusplus(reverse(v231), tbl[36 + tbloffset], ctimes(v231, tbl[37 + tbloffset])); + real2 v1126 = minus(v245, v85); + real2 v1130 = plus(v85, v245); + real2 v1210 = plus(v1130, v1131); + real2 v1206 = minus(v1131, v1130); + real2 v1166 = minus(v285, v125); + real2 v1170 = plus(v125, v285); + real2 v1211 = plus(v1170, v1171); + real2 v1205 = reverse(minus(v1171, v1170)); + real2 v1246 = minus(v1211, v1210); + real2 v1250 = plus(v1210, v1211); + store(out, 3 << outShift, plus(v1250, v1251)); + real2 v1264 = minus(v1250, v1251); + store(out, 35 << outShift, ctimesminusplus(v1264, tbl[0 + tbloffset], ctimes(reverse(v1264), tbl[1 + tbloffset]))); + real2 v1247 = minusplus(v1245, v1246); + real2 v1249 = minusplus(uminus(v1245), v1246); + store(out, 19 << outShift, ctimesminusplus(reverse(v1247), tbl[218 + tbloffset], ctimes(v1247, tbl[219 + tbloffset]))); + store(out, 51 << outShift, ctimesminusplus(reverse(v1249), tbl[220 + tbloffset], ctimes(v1249, tbl[221 + tbloffset]))); + real2 v1229 = minusplus(uminus(v1225), v1226); + real2 v1227 = minusplus(v1225, v1226); + real2 v1207 = minusplus(v1205, v1206); + real2 v1209 = minusplus(uminus(v1205), v1206); + real2 v1237 = ctimesminusplus(reverse(v1227), tbl[214 + tbloffset], ctimes(v1227, tbl[215 + tbloffset])); + real2 v1217 = ctimesminusplus(reverse(v1207), tbl[210 + tbloffset], ctimes(v1207, tbl[211 + tbloffset])); + store(out, 11 << outShift, plus(v1217, v1237)); + real2 v1270 = minus(v1217, v1237); + store(out, 43 << outShift, ctimesminusplus(v1270, tbl[0 + tbloffset], ctimes(reverse(v1270), tbl[1 + tbloffset]))); + real2 v1223 = ctimesminusplus(reverse(v1209), tbl[212 + tbloffset], ctimes(v1209, tbl[213 + tbloffset])); + real2 v1243 = ctimesminusplus(reverse(v1229), tbl[216 + tbloffset], ctimes(v1229, tbl[217 + tbloffset])); + store(out, 27 << outShift, plus(v1223, v1243)); + real2 v1276 = minus(v1223, v1243); + store(out, 59 << outShift, ctimesminusplus(v1276, tbl[0 + tbloffset], ctimes(reverse(v1276), tbl[1 + tbloffset]))); + real2 v1189 = minusplus(uminus(v1185), v1186); + real2 v1187 = minusplus(v1185, v1186); + real2 v1129 = minusplus(uminus(v1125), v1126); + real2 v1127 = minusplus(v1125, v1126); + real2 v1147 = minusplus(v1145, v1146); + real2 v1149 = minusplus(uminus(v1145), v1146); + real2 v1167 = minusplus(v1165, v1166); + real2 v1169 = minusplus(uminus(v1165), v1166); + real2 v1143 = ctimesminusplus(reverse(v1129), tbl[196 + tbloffset], ctimes(v1129, tbl[197 + tbloffset])); + real2 v1163 = ctimesminusplus(reverse(v1149), tbl[200 + tbloffset], ctimes(v1149, tbl[201 + tbloffset])); + real2 v1203 = ctimesminusplus(reverse(v1189), tbl[208 + tbloffset], ctimes(v1189, tbl[209 + tbloffset])); + real2 v1315 = plus(v1163, v1203); + real2 v1309 = reverse(minus(v1203, v1163)); + real2 v1183 = ctimesminusplus(reverse(v1169), tbl[204 + tbloffset], ctimes(v1169, tbl[205 + tbloffset])); + real2 v1314 = plus(v1143, v1183); + real2 v1310 = minus(v1183, v1143); + store(out, 15 << outShift, plus(v1314, v1315)); + real2 v1328 = minus(v1314, v1315); + store(out, 47 << outShift, ctimesminusplus(v1328, tbl[0 + tbloffset], ctimes(reverse(v1328), tbl[1 + tbloffset]))); + real2 v1311 = minusplus(v1309, v1310); + store(out, 31 << outShift, ctimesminusplus(reverse(v1311), tbl[226 + tbloffset], ctimes(v1311, tbl[227 + tbloffset]))); + real2 v1313 = minusplus(uminus(v1309), v1310); + store(out, 63 << outShift, ctimesminusplus(reverse(v1313), tbl[228 + tbloffset], ctimes(v1313, tbl[229 + tbloffset]))); + real2 v1177 = ctimesminusplus(reverse(v1167), tbl[202 + tbloffset], ctimes(v1167, tbl[203 + tbloffset])); + real2 v1137 = ctimesminusplus(reverse(v1127), tbl[194 + tbloffset], ctimes(v1127, tbl[195 + tbloffset])); + real2 v1197 = ctimesminusplus(reverse(v1187), tbl[206 + tbloffset], ctimes(v1187, tbl[207 + tbloffset])); + real2 v1157 = ctimesminusplus(reverse(v1147), tbl[198 + tbloffset], ctimes(v1147, tbl[199 + tbloffset])); + real2 v1283 = reverse(minus(v1197, v1157)); + real2 v1289 = plus(v1157, v1197); + real2 v1288 = plus(v1137, v1177); + real2 v1284 = minus(v1177, v1137); + store(out, 7 << outShift, plus(v1288, v1289)); + real2 v1302 = minus(v1288, v1289); + store(out, 39 << outShift, ctimesminusplus(v1302, tbl[0 + tbloffset], ctimes(reverse(v1302), tbl[1 + tbloffset]))); + real2 v1285 = minusplus(v1283, v1284); + real2 v1287 = minusplus(uminus(v1283), v1284); + store(out, 55 << outShift, ctimesminusplus(reverse(v1287), tbl[224 + tbloffset], ctimes(v1287, tbl[225 + tbloffset]))); + store(out, 23 << outShift, ctimesminusplus(reverse(v1285), tbl[222 + tbloffset], ctimes(v1285, tbl[223 + tbloffset]))); +// Pres : 17339 + } +} + +ALIGNED(8192) void tbut64f_%CONFIG%_%ISA%(real *RESTRICT out0, uint32_t *q, const real *RESTRICT in0, const int inShift, const real *RESTRICT tbl, const int K) { + const int k = 1 << (inShift - LOG2VECWIDTH); + int i=0; +#pragma omp parallel for + for(i=0;i < k;i++) { + int i0 = i << LOG2VECWIDTH; + real *out = out0 + q[i]; + const real *in = in0 + i0*2; + const int tbloffset = K * i0; + +// Pres : 30254 + real2 v37 = load(in, 35 << inShift); + real2 v5 = load(in, 3 << inShift); + real2 v132 = plus(v5, v37); + real2 v128 = minus(v37, v5); + real2 v21 = load(in, 19 << inShift); + real2 v53 = load(in, 51 << inShift); + real2 v133 = plus(v21, v53); + real2 v127 = reverse(minus(v21, v53)); + real2 v131 = minusplus(uminus(v127), v128); + real2 v129 = minusplus(v127, v128); + real2 v139 = timesminusplus(reverse(v129), load(tbl, 14 * VECWIDTH + tbloffset), times(v129, load(tbl, 15 * VECWIDTH + tbloffset))); + real2 v145 = timesminusplus(reverse(v131), load(tbl, 16 * VECWIDTH + tbloffset), times(v131, load(tbl, 17 * VECWIDTH + tbloffset))); + real2 v448 = minus(v133, v132); + real2 v452 = plus(v132, v133); + real2 v45 = load(in, 43 << inShift); + real2 v13 = load(in, 11 << inShift); + real2 v292 = plus(v13, v45); + real2 v288 = minus(v45, v13); + real2 v29 = load(in, 27 << inShift); + real2 v61 = load(in, 59 << inShift); + real2 v293 = plus(v29, v61); + real2 v287 = reverse(minus(v29, v61)); + real2 v291 = minusplus(uminus(v287), v288); + real2 v289 = minusplus(v287, v288); + real2 v299 = timesminusplus(reverse(v289), load(tbl, 46 * VECWIDTH + tbloffset), times(v289, load(tbl, 47 * VECWIDTH + tbloffset))); + real2 v453 = plus(v292, v293); + real2 v447 = reverse(minus(v292, v293)); + real2 v608 = minus(v453, v452); + real2 v612 = plus(v452, v453); + real2 v980 = plus(v139, v299); + real2 v976 = minus(v299, v139); + real2 v449 = minusplus(v447, v448); + real2 v451 = minusplus(uminus(v447), v448); + real2 v465 = timesminusplus(reverse(v451), load(tbl, 80 * VECWIDTH + tbloffset), times(v451, load(tbl, 81 * VECWIDTH + tbloffset))); + real2 v305 = timesminusplus(reverse(v291), load(tbl, 48 * VECWIDTH + tbloffset), times(v291, load(tbl, 49 * VECWIDTH + tbloffset))); + real2 v1186 = minus(v305, v145); + real2 v1190 = plus(v145, v305); + real2 v459 = timesminusplus(reverse(v449), load(tbl, 78 * VECWIDTH + tbloffset), times(v449, load(tbl, 79 * VECWIDTH + tbloffset))); + real2 v25 = load(in, 23 << inShift); + real2 v57 = load(in, 55 << inShift); + real2 v207 = reverse(minus(v25, v57)); + real2 v213 = plus(v25, v57); + real2 v9 = load(in, 7 << inShift); + real2 v41 = load(in, 39 << inShift); + real2 v212 = plus(v9, v41); + real2 v208 = minus(v41, v9); + real2 v528 = minus(v213, v212); + real2 v532 = plus(v212, v213); + real2 v209 = minusplus(v207, v208); + real2 v211 = minusplus(uminus(v207), v208); + real2 v225 = timesminusplus(reverse(v211), load(tbl, 32 * VECWIDTH + tbloffset), times(v211, load(tbl, 33 * VECWIDTH + tbloffset))); + real2 v219 = timesminusplus(reverse(v209), load(tbl, 30 * VECWIDTH + tbloffset), times(v209, load(tbl, 31 * VECWIDTH + tbloffset))); + real2 v17 = load(in, 15 << inShift); + real2 v49 = load(in, 47 << inShift); + real2 v368 = minus(v49, v17); + real2 v372 = plus(v17, v49); + real2 v33 = load(in, 31 << inShift); + real2 v65 = load(in, 63 << inShift); + real2 v367 = reverse(minus(v33, v65)); + real2 v373 = plus(v33, v65); + real2 v369 = minusplus(v367, v368); + real2 v371 = minusplus(uminus(v367), v368); + real2 v533 = plus(v372, v373); + real2 v527 = reverse(minus(v372, v373)); + real2 v607 = reverse(minus(v532, v533)); + real2 v613 = plus(v532, v533); + real2 v529 = minusplus(v527, v528); + real2 v531 = minusplus(uminus(v527), v528); + real2 v545 = timesminusplus(reverse(v531), load(tbl, 96 * VECWIDTH + tbloffset), times(v531, load(tbl, 97 * VECWIDTH + tbloffset))); + real2 v653 = plus(v612, v613); + real2 v647 = reverse(minus(v612, v613)); + real2 v609 = minusplus(v607, v608); + real2 v611 = minusplus(uminus(v607), v608); + real2 v863 = plus(v465, v545); + real2 v857 = reverse(minus(v465, v545)); + real2 v539 = timesminusplus(reverse(v529), load(tbl, 94 * VECWIDTH + tbloffset), times(v529, load(tbl, 95 * VECWIDTH + tbloffset))); + real2 v385 = timesminusplus(reverse(v371), load(tbl, 64 * VECWIDTH + tbloffset), times(v371, load(tbl, 65 * VECWIDTH + tbloffset))); + real2 v619 = timesminusplus(reverse(v609), load(tbl, 110 * VECWIDTH + tbloffset), times(v609, load(tbl, 111 * VECWIDTH + tbloffset))); + real2 v1191 = plus(v225, v385); + real2 v1185 = reverse(minus(v225, v385)); + real2 v779 = reverse(minus(v459, v539)); + real2 v785 = plus(v459, v539); + real2 v625 = timesminusplus(reverse(v611), load(tbl, 112 * VECWIDTH + tbloffset), times(v611, load(tbl, 113 * VECWIDTH + tbloffset))); + real2 v379 = timesminusplus(reverse(v369), load(tbl, 62 * VECWIDTH + tbloffset), times(v369, load(tbl, 63 * VECWIDTH + tbloffset))); + real2 v975 = reverse(minus(v219, v379)); + real2 v981 = plus(v219, v379); + real2 v977 = minusplus(v975, v976); + real2 v979 = minusplus(uminus(v975), v976); + real2 v987 = timesminusplus(reverse(v977), load(tbl, 170 * VECWIDTH + tbloffset), times(v977, load(tbl, 171 * VECWIDTH + tbloffset))); + real2 v993 = timesminusplus(reverse(v979), load(tbl, 172 * VECWIDTH + tbloffset), times(v979, load(tbl, 173 * VECWIDTH + tbloffset))); + real2 v1015 = reverse(minus(v980, v981)); + real2 v1021 = plus(v980, v981); + real2 v11 = load(in, 9 << inShift); + real2 v43 = load(in, 41 << inShift); + real2 v248 = minus(v43, v11); + real2 v252 = plus(v11, v43); + real2 v59 = load(in, 57 << inShift); + real2 v27 = load(in, 25 << inShift); + real2 v253 = plus(v27, v59); + real2 v247 = reverse(minus(v27, v59)); + real2 v413 = plus(v252, v253); + real2 v407 = reverse(minus(v252, v253)); + real2 v249 = minusplus(v247, v248); + real2 v251 = minusplus(uminus(v247), v248); + real2 v259 = timesminusplus(reverse(v249), load(tbl, 38 * VECWIDTH + tbloffset), times(v249, load(tbl, 39 * VECWIDTH + tbloffset))); + real2 v35 = load(in, 33 << inShift); + real2 v3 = load(in, 1 << inShift); + real2 v92 = plus(v3, v35); + real2 v88 = minus(v35, v3); + real2 v51 = load(in, 49 << inShift); + real2 v19 = load(in, 17 << inShift); + real2 v87 = reverse(minus(v19, v51)); + real2 v93 = plus(v19, v51); + real2 v412 = plus(v92, v93); + real2 v408 = minus(v93, v92); + real2 v411 = minusplus(uminus(v407), v408); + real2 v409 = minusplus(v407, v408); + real2 v91 = minusplus(uminus(v87), v88); + real2 v89 = minusplus(v87, v88); + real2 v99 = timesminusplus(reverse(v89), load(tbl, 6 * VECWIDTH + tbloffset), times(v89, load(tbl, 7 * VECWIDTH + tbloffset))); + real2 v425 = timesminusplus(reverse(v411), load(tbl, 72 * VECWIDTH + tbloffset), times(v411, load(tbl, 73 * VECWIDTH + tbloffset))); + real2 v568 = minus(v413, v412); + real2 v572 = plus(v412, v413); + real2 v940 = plus(v99, v259); + real2 v936 = minus(v259, v99); + real2 v419 = timesminusplus(reverse(v409), load(tbl, 70 * VECWIDTH + tbloffset), times(v409, load(tbl, 71 * VECWIDTH + tbloffset))); + real2 v47 = load(in, 45 << inShift); + real2 v15 = load(in, 13 << inShift); + real2 v332 = plus(v15, v47); + real2 v328 = minus(v47, v15); + real2 v63 = load(in, 61 << inShift); + real2 v31 = load(in, 29 << inShift); + real2 v327 = reverse(minus(v31, v63)); + real2 v333 = plus(v31, v63); + real2 v329 = minusplus(v327, v328); + real2 v331 = minusplus(uminus(v327), v328); + real2 v339 = timesminusplus(reverse(v329), load(tbl, 54 * VECWIDTH + tbloffset), times(v329, load(tbl, 55 * VECWIDTH + tbloffset))); + real2 v487 = reverse(minus(v332, v333)); + real2 v493 = plus(v332, v333); + real2 v7 = load(in, 5 << inShift); + real2 v39 = load(in, 37 << inShift); + real2 v172 = plus(v7, v39); + real2 v168 = minus(v39, v7); + real2 v55 = load(in, 53 << inShift); + real2 v23 = load(in, 21 << inShift); + real2 v173 = plus(v23, v55); + real2 v167 = reverse(minus(v23, v55)); + real2 v488 = minus(v173, v172); + real2 v492 = plus(v172, v173); + real2 v491 = minusplus(uminus(v487), v488); + real2 v489 = minusplus(v487, v488); + real2 v499 = timesminusplus(reverse(v489), load(tbl, 86 * VECWIDTH + tbloffset), times(v489, load(tbl, 87 * VECWIDTH + tbloffset))); + real2 v505 = timesminusplus(reverse(v491), load(tbl, 88 * VECWIDTH + tbloffset), times(v491, load(tbl, 89 * VECWIDTH + tbloffset))); + real2 v567 = reverse(minus(v492, v493)); + real2 v573 = plus(v492, v493); + real2 v571 = minusplus(uminus(v567), v568); + real2 v569 = minusplus(v567, v568); + real2 v579 = timesminusplus(reverse(v569), load(tbl, 102 * VECWIDTH + tbloffset), times(v569, load(tbl, 103 * VECWIDTH + tbloffset))); + real2 v585 = timesminusplus(reverse(v571), load(tbl, 104 * VECWIDTH + tbloffset), times(v571, load(tbl, 105 * VECWIDTH + tbloffset))); + real2 v739 = plus(v585, v625); + real2 v733 = reverse(minus(v585, v625)); + real2 v707 = reverse(minus(v579, v619)); + real2 v713 = plus(v579, v619); + real2 v648 = minus(v573, v572); + real2 v652 = plus(v572, v573); + real2 v673 = plus(v652, v653); + real2 v667 = reverse(minus(v652, v653)); + real2 v651 = minusplus(uminus(v647), v648); + real2 v649 = minusplus(v647, v648); + real2 v659 = timesminusplus(reverse(v649), load(tbl, 118 * VECWIDTH + tbloffset), times(v649, load(tbl, 119 * VECWIDTH + tbloffset))); + real2 v665 = timesminusplus(reverse(v651), load(tbl, 120 * VECWIDTH + tbloffset), times(v651, load(tbl, 121 * VECWIDTH + tbloffset))); + real2 v780 = minus(v499, v419); + real2 v784 = plus(v419, v499); + real2 v781 = minusplus(v779, v780); + real2 v783 = minusplus(uminus(v779), v780); + real2 v805 = plus(v784, v785); + real2 v799 = reverse(minus(v784, v785)); + real2 v862 = plus(v425, v505); + real2 v858 = minus(v505, v425); + real2 v859 = minusplus(v857, v858); + real2 v861 = minusplus(uminus(v857), v858); + real2 v875 = timesminusplus(reverse(v861), load(tbl, 152 * VECWIDTH + tbloffset), times(v861, load(tbl, 153 * VECWIDTH + tbloffset))); + real2 v791 = timesminusplus(reverse(v781), load(tbl, 138 * VECWIDTH + tbloffset), times(v781, load(tbl, 139 * VECWIDTH + tbloffset))); + real2 v797 = timesminusplus(reverse(v783), load(tbl, 140 * VECWIDTH + tbloffset), times(v783, load(tbl, 141 * VECWIDTH + tbloffset))); + real2 v883 = plus(v862, v863); + real2 v877 = reverse(minus(v862, v863)); + real2 v869 = timesminusplus(reverse(v859), load(tbl, 150 * VECWIDTH + tbloffset), times(v859, load(tbl, 151 * VECWIDTH + tbloffset))); + real2 v36 = load(in, 34 << inShift); + real2 v4 = load(in, 2 << inShift); + real2 v108 = minus(v36, v4); + real2 v112 = plus(v4, v36); + real2 v52 = load(in, 50 << inShift); + real2 v20 = load(in, 18 << inShift); + real2 v113 = plus(v20, v52); + real2 v107 = reverse(minus(v20, v52)); + real2 v428 = minus(v113, v112); + real2 v432 = plus(v112, v113); + real2 v12 = load(in, 10 << inShift); + real2 v44 = load(in, 42 << inShift); + real2 v268 = minus(v44, v12); + real2 v272 = plus(v12, v44); + real2 v28 = load(in, 26 << inShift); + real2 v60 = load(in, 58 << inShift); + real2 v267 = reverse(minus(v28, v60)); + real2 v273 = plus(v28, v60); + real2 v427 = reverse(minus(v272, v273)); + real2 v433 = plus(v272, v273); + real2 v431 = minusplus(uminus(v427), v428); + real2 v429 = minusplus(v427, v428); + real2 v439 = timesminusplus(reverse(v429), load(tbl, 74 * VECWIDTH + tbloffset), times(v429, load(tbl, 75 * VECWIDTH + tbloffset))); + real2 v588 = minus(v433, v432); + real2 v592 = plus(v432, v433); + real2 v40 = load(in, 38 << inShift); + real2 v8 = load(in, 6 << inShift); + real2 v188 = minus(v40, v8); + real2 v192 = plus(v8, v40); + real2 v24 = load(in, 22 << inShift); + real2 v56 = load(in, 54 << inShift); + real2 v187 = reverse(minus(v24, v56)); + real2 v193 = plus(v24, v56); + real2 v512 = plus(v192, v193); + real2 v508 = minus(v193, v192); + real2 v32 = load(in, 30 << inShift); + real2 v64 = load(in, 62 << inShift); + real2 v347 = reverse(minus(v32, v64)); + real2 v353 = plus(v32, v64); + real2 v48 = load(in, 46 << inShift); + real2 v16 = load(in, 14 << inShift); + real2 v348 = minus(v48, v16); + real2 v352 = plus(v16, v48); + real2 v513 = plus(v352, v353); + real2 v507 = reverse(minus(v352, v353)); + real2 v587 = reverse(minus(v512, v513)); + real2 v593 = plus(v512, v513); + real2 v633 = plus(v592, v593); + real2 v627 = reverse(minus(v592, v593)); + real2 v591 = minusplus(uminus(v587), v588); + real2 v589 = minusplus(v587, v588); + real2 v605 = timesminusplus(reverse(v591), load(tbl, 108 * VECWIDTH + tbloffset), times(v591, load(tbl, 109 * VECWIDTH + tbloffset))); + real2 v599 = timesminusplus(reverse(v589), load(tbl, 106 * VECWIDTH + tbloffset), times(v589, load(tbl, 107 * VECWIDTH + tbloffset))); + real2 v46 = load(in, 44 << inShift); + real2 v14 = load(in, 12 << inShift); + real2 v312 = plus(v14, v46); + real2 v308 = minus(v46, v14); + real2 v62 = load(in, 60 << inShift); + real2 v30 = load(in, 28 << inShift); + real2 v313 = plus(v30, v62); + real2 v307 = reverse(minus(v30, v62)); + real2 v467 = reverse(minus(v312, v313)); + real2 v473 = plus(v312, v313); + real2 v22 = load(in, 20 << inShift); + real2 v54 = load(in, 52 << inShift); + real2 v147 = reverse(minus(v22, v54)); + real2 v153 = plus(v22, v54); + real2 v6 = load(in, 4 << inShift); + real2 v38 = load(in, 36 << inShift); + real2 v148 = minus(v38, v6); + real2 v152 = plus(v6, v38); + real2 v472 = plus(v152, v153); + real2 v468 = minus(v153, v152); + real2 v547 = reverse(minus(v472, v473)); + real2 v553 = plus(v472, v473); + real2 v10 = load(in, 8 << inShift); + real2 v42 = load(in, 40 << inShift); + real2 v232 = plus(v10, v42); + real2 v228 = minus(v42, v10); + real2 v58 = load(in, 56 << inShift); + real2 v26 = load(in, 24 << inShift); + real2 v233 = plus(v26, v58); + real2 v227 = reverse(minus(v26, v58)); + real2 v393 = plus(v232, v233); + real2 v387 = reverse(minus(v232, v233)); + real2 v2 = load(in, 0 << inShift); + real2 v34 = load(in, 32 << inShift); + real2 v72 = plus(v2, v34); + real2 v68 = minus(v34, v2); + real2 v18 = load(in, 16 << inShift); + real2 v50 = load(in, 48 << inShift); + real2 v73 = plus(v18, v50); + real2 v67 = reverse(minus(v18, v50)); + real2 v388 = minus(v73, v72); + real2 v392 = plus(v72, v73); + real2 v548 = minus(v393, v392); + real2 v552 = plus(v392, v393); + real2 v628 = minus(v553, v552); + real2 v632 = plus(v552, v553); + real2 v672 = plus(v632, v633); + real2 v668 = minus(v633, v632); + scatter(out, 0, 64, plus(v672, v673)); + real2 v686 = minus(v672, v673); + scatter(out, 32, 64, timesminusplus(v686, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v686), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v669 = minusplus(v667, v668); + real2 v671 = minusplus(uminus(v667), v668); + scatter(out, 48, 64, timesminusplus(reverse(v671), load(tbl, 124 * VECWIDTH + tbloffset), times(v671, load(tbl, 125 * VECWIDTH + tbloffset)))); + scatter(out, 16, 64, timesminusplus(reverse(v669), load(tbl, 122 * VECWIDTH + tbloffset), times(v669, load(tbl, 123 * VECWIDTH + tbloffset)))); + real2 v631 = minusplus(uminus(v627), v628); + real2 v629 = minusplus(v627, v628); + real2 v639 = timesminusplus(reverse(v629), load(tbl, 114 * VECWIDTH + tbloffset), times(v629, load(tbl, 115 * VECWIDTH + tbloffset))); + scatter(out, 8, 64, plus(v639, v659)); + real2 v694 = minus(v639, v659); + scatter(out, 40, 64, timesminusplus(v694, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v694), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v645 = timesminusplus(reverse(v631), load(tbl, 116 * VECWIDTH + tbloffset), times(v631, load(tbl, 117 * VECWIDTH + tbloffset))); + scatter(out, 24, 64, plus(v645, v665)); + real2 v700 = minus(v645, v665); + scatter(out, 56, 64, timesminusplus(v700, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v700), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v549 = minusplus(v547, v548); + real2 v551 = minusplus(uminus(v547), v548); + real2 v559 = timesminusplus(reverse(v549), load(tbl, 98 * VECWIDTH + tbloffset), times(v549, load(tbl, 99 * VECWIDTH + tbloffset))); + real2 v708 = minus(v599, v559); + real2 v712 = plus(v559, v599); + scatter(out, 4, 64, plus(v712, v713)); + real2 v726 = minus(v712, v713); + scatter(out, 36, 64, timesminusplus(v726, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v726), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v711 = minusplus(uminus(v707), v708); + real2 v709 = minusplus(v707, v708); + scatter(out, 20, 64, timesminusplus(reverse(v709), load(tbl, 126 * VECWIDTH + tbloffset), times(v709, load(tbl, 127 * VECWIDTH + tbloffset)))); + scatter(out, 52, 64, timesminusplus(reverse(v711), load(tbl, 128 * VECWIDTH + tbloffset), times(v711, load(tbl, 129 * VECWIDTH + tbloffset)))); + real2 v565 = timesminusplus(reverse(v551), load(tbl, 100 * VECWIDTH + tbloffset), times(v551, load(tbl, 101 * VECWIDTH + tbloffset))); + real2 v738 = plus(v565, v605); + real2 v734 = minus(v605, v565); + scatter(out, 12, 64, plus(v738, v739)); + real2 v752 = minus(v738, v739); + scatter(out, 44, 64, timesminusplus(v752, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v752), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v737 = minusplus(uminus(v733), v734); + scatter(out, 60, 64, timesminusplus(reverse(v737), load(tbl, 132 * VECWIDTH + tbloffset), times(v737, load(tbl, 133 * VECWIDTH + tbloffset)))); + real2 v735 = minusplus(v733, v734); + scatter(out, 28, 64, timesminusplus(reverse(v735), load(tbl, 130 * VECWIDTH + tbloffset), times(v735, load(tbl, 131 * VECWIDTH + tbloffset)))); + real2 v471 = minusplus(uminus(v467), v468); + real2 v469 = minusplus(v467, v468); + real2 v479 = timesminusplus(reverse(v469), load(tbl, 82 * VECWIDTH + tbloffset), times(v469, load(tbl, 83 * VECWIDTH + tbloffset))); + real2 v511 = minusplus(uminus(v507), v508); + real2 v509 = minusplus(v507, v508); + real2 v519 = timesminusplus(reverse(v509), load(tbl, 90 * VECWIDTH + tbloffset), times(v509, load(tbl, 91 * VECWIDTH + tbloffset))); + real2 v765 = plus(v439, v519); + real2 v759 = reverse(minus(v439, v519)); + real2 v389 = minusplus(v387, v388); + real2 v391 = minusplus(uminus(v387), v388); + real2 v399 = timesminusplus(reverse(v389), load(tbl, 66 * VECWIDTH + tbloffset), times(v389, load(tbl, 67 * VECWIDTH + tbloffset))); + real2 v764 = plus(v399, v479); + real2 v760 = minus(v479, v399); + real2 v804 = plus(v764, v765); + real2 v800 = minus(v765, v764); + scatter(out, 2, 64, plus(v804, v805)); + real2 v818 = minus(v804, v805); + scatter(out, 34, 64, timesminusplus(v818, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v818), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v803 = minusplus(uminus(v799), v800); + scatter(out, 50, 64, timesminusplus(reverse(v803), load(tbl, 144 * VECWIDTH + tbloffset), times(v803, load(tbl, 145 * VECWIDTH + tbloffset)))); + real2 v801 = minusplus(v799, v800); + scatter(out, 18, 64, timesminusplus(reverse(v801), load(tbl, 142 * VECWIDTH + tbloffset), times(v801, load(tbl, 143 * VECWIDTH + tbloffset)))); + real2 v763 = minusplus(uminus(v759), v760); + real2 v761 = minusplus(v759, v760); + real2 v777 = timesminusplus(reverse(v763), load(tbl, 136 * VECWIDTH + tbloffset), times(v763, load(tbl, 137 * VECWIDTH + tbloffset))); + scatter(out, 26, 64, plus(v777, v797)); + real2 v830 = minus(v777, v797); + scatter(out, 58, 64, timesminusplus(v830, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v830), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v771 = timesminusplus(reverse(v761), load(tbl, 134 * VECWIDTH + tbloffset), times(v761, load(tbl, 135 * VECWIDTH + tbloffset))); + scatter(out, 10, 64, plus(v771, v791)); + real2 v824 = minus(v771, v791); + scatter(out, 42, 64, timesminusplus(v824, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v824), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v445 = timesminusplus(reverse(v431), load(tbl, 76 * VECWIDTH + tbloffset), times(v431, load(tbl, 77 * VECWIDTH + tbloffset))); + real2 v525 = timesminusplus(reverse(v511), load(tbl, 92 * VECWIDTH + tbloffset), times(v511, load(tbl, 93 * VECWIDTH + tbloffset))); + real2 v837 = reverse(minus(v445, v525)); + real2 v843 = plus(v445, v525); + real2 v485 = timesminusplus(reverse(v471), load(tbl, 84 * VECWIDTH + tbloffset), times(v471, load(tbl, 85 * VECWIDTH + tbloffset))); + real2 v405 = timesminusplus(reverse(v391), load(tbl, 68 * VECWIDTH + tbloffset), times(v391, load(tbl, 69 * VECWIDTH + tbloffset))); + real2 v838 = minus(v485, v405); + real2 v842 = plus(v405, v485); + real2 v878 = minus(v843, v842); + real2 v882 = plus(v842, v843); + scatter(out, 6, 64, plus(v882, v883)); + real2 v896 = minus(v882, v883); + scatter(out, 38, 64, timesminusplus(v896, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v896), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v881 = minusplus(uminus(v877), v878); + scatter(out, 54, 64, timesminusplus(reverse(v881), load(tbl, 156 * VECWIDTH + tbloffset), times(v881, load(tbl, 157 * VECWIDTH + tbloffset)))); + real2 v879 = minusplus(v877, v878); + scatter(out, 22, 64, timesminusplus(reverse(v879), load(tbl, 154 * VECWIDTH + tbloffset), times(v879, load(tbl, 155 * VECWIDTH + tbloffset)))); + real2 v841 = minusplus(uminus(v837), v838); + real2 v839 = minusplus(v837, v838); + real2 v855 = timesminusplus(reverse(v841), load(tbl, 148 * VECWIDTH + tbloffset), times(v841, load(tbl, 149 * VECWIDTH + tbloffset))); + scatter(out, 30, 64, plus(v855, v875)); + real2 v908 = minus(v855, v875); + scatter(out, 62, 64, timesminusplus(v908, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v908), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v849 = timesminusplus(reverse(v839), load(tbl, 146 * VECWIDTH + tbloffset), times(v839, load(tbl, 147 * VECWIDTH + tbloffset))); + scatter(out, 14, 64, plus(v849, v869)); + real2 v902 = minus(v849, v869); + scatter(out, 46, 64, timesminusplus(v902, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v902), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v151 = minusplus(uminus(v147), v148); + real2 v149 = minusplus(v147, v148); + real2 v311 = minusplus(uminus(v307), v308); + real2 v309 = minusplus(v307, v308); + real2 v109 = minusplus(v107, v108); + real2 v111 = minusplus(uminus(v107), v108); + real2 v119 = timesminusplus(reverse(v109), load(tbl, 10 * VECWIDTH + tbloffset), times(v109, load(tbl, 11 * VECWIDTH + tbloffset))); + real2 v269 = minusplus(v267, v268); + real2 v271 = minusplus(uminus(v267), v268); + real2 v279 = timesminusplus(reverse(v269), load(tbl, 42 * VECWIDTH + tbloffset), times(v269, load(tbl, 43 * VECWIDTH + tbloffset))); + real2 v960 = plus(v119, v279); + real2 v956 = minus(v279, v119); + real2 v169 = minusplus(v167, v168); + real2 v171 = minusplus(uminus(v167), v168); + real2 v159 = timesminusplus(reverse(v149), load(tbl, 18 * VECWIDTH + tbloffset), times(v149, load(tbl, 19 * VECWIDTH + tbloffset))); + real2 v319 = timesminusplus(reverse(v309), load(tbl, 50 * VECWIDTH + tbloffset), times(v309, load(tbl, 51 * VECWIDTH + tbloffset))); + real2 v921 = plus(v159, v319); + real2 v915 = reverse(minus(v159, v319)); + real2 v351 = minusplus(uminus(v347), v348); + real2 v349 = minusplus(v347, v348); + real2 v359 = timesminusplus(reverse(v349), load(tbl, 58 * VECWIDTH + tbloffset), times(v349, load(tbl, 59 * VECWIDTH + tbloffset))); + real2 v191 = minusplus(uminus(v187), v188); + real2 v189 = minusplus(v187, v188); + real2 v199 = timesminusplus(reverse(v189), load(tbl, 26 * VECWIDTH + tbloffset), times(v189, load(tbl, 27 * VECWIDTH + tbloffset))); + real2 v961 = plus(v199, v359); + real2 v955 = reverse(minus(v199, v359)); + real2 v995 = reverse(minus(v960, v961)); + real2 v1001 = plus(v960, v961); + real2 v179 = timesminusplus(reverse(v169), load(tbl, 22 * VECWIDTH + tbloffset), times(v169, load(tbl, 23 * VECWIDTH + tbloffset))); + real2 v941 = plus(v179, v339); + real2 v935 = reverse(minus(v179, v339)); + real2 v1016 = minus(v941, v940); + real2 v1020 = plus(v940, v941); + real2 v71 = minusplus(uminus(v67), v68); + real2 v69 = minusplus(v67, v68); + real2 v79 = timesminusplus(reverse(v69), load(tbl, 2 * VECWIDTH + tbloffset), times(v69, load(tbl, 3 * VECWIDTH + tbloffset))); + real2 v1041 = plus(v1020, v1021); + real2 v1035 = reverse(minus(v1020, v1021)); + real2 v229 = minusplus(v227, v228); + real2 v231 = minusplus(uminus(v227), v228); + real2 v239 = timesminusplus(reverse(v229), load(tbl, 34 * VECWIDTH + tbloffset), times(v229, load(tbl, 35 * VECWIDTH + tbloffset))); + real2 v920 = plus(v79, v239); + real2 v916 = minus(v239, v79); + real2 v996 = minus(v921, v920); + real2 v1000 = plus(v920, v921); + real2 v1040 = plus(v1000, v1001); + real2 v1036 = minus(v1001, v1000); + scatter(out, 1, 64, plus(v1040, v1041)); + real2 v1054 = minus(v1040, v1041); + scatter(out, 33, 64, timesminusplus(v1054, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v1054), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v1037 = minusplus(v1035, v1036); + real2 v1039 = minusplus(uminus(v1035), v1036); + scatter(out, 49, 64, timesminusplus(reverse(v1039), load(tbl, 184 * VECWIDTH + tbloffset), times(v1039, load(tbl, 185 * VECWIDTH + tbloffset)))); + scatter(out, 17, 64, timesminusplus(reverse(v1037), load(tbl, 182 * VECWIDTH + tbloffset), times(v1037, load(tbl, 183 * VECWIDTH + tbloffset)))); + real2 v1017 = minusplus(v1015, v1016); + real2 v1019 = minusplus(uminus(v1015), v1016); + real2 v1033 = timesminusplus(reverse(v1019), load(tbl, 180 * VECWIDTH + tbloffset), times(v1019, load(tbl, 181 * VECWIDTH + tbloffset))); + real2 v997 = minusplus(v995, v996); + real2 v999 = minusplus(uminus(v995), v996); + real2 v1013 = timesminusplus(reverse(v999), load(tbl, 176 * VECWIDTH + tbloffset), times(v999, load(tbl, 177 * VECWIDTH + tbloffset))); + scatter(out, 25, 64, plus(v1013, v1033)); + real2 v1066 = minus(v1013, v1033); + scatter(out, 57, 64, timesminusplus(v1066, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v1066), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v1027 = timesminusplus(reverse(v1017), load(tbl, 178 * VECWIDTH + tbloffset), times(v1017, load(tbl, 179 * VECWIDTH + tbloffset))); + real2 v1007 = timesminusplus(reverse(v997), load(tbl, 174 * VECWIDTH + tbloffset), times(v997, load(tbl, 175 * VECWIDTH + tbloffset))); + scatter(out, 9, 64, plus(v1007, v1027)); + real2 v1060 = minus(v1007, v1027); + scatter(out, 41, 64, timesminusplus(v1060, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v1060), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v937 = minusplus(v935, v936); + real2 v939 = minusplus(uminus(v935), v936); + real2 v959 = minusplus(uminus(v955), v956); + real2 v957 = minusplus(v955, v956); + real2 v967 = timesminusplus(reverse(v957), load(tbl, 166 * VECWIDTH + tbloffset), times(v957, load(tbl, 167 * VECWIDTH + tbloffset))); + real2 v947 = timesminusplus(reverse(v937), load(tbl, 162 * VECWIDTH + tbloffset), times(v937, load(tbl, 163 * VECWIDTH + tbloffset))); + real2 v919 = minusplus(uminus(v915), v916); + real2 v917 = minusplus(v915, v916); + real2 v1079 = plus(v947, v987); + real2 v1073 = reverse(minus(v947, v987)); + real2 v927 = timesminusplus(reverse(v917), load(tbl, 158 * VECWIDTH + tbloffset), times(v917, load(tbl, 159 * VECWIDTH + tbloffset))); + real2 v1074 = minus(v967, v927); + real2 v1078 = plus(v927, v967); + scatter(out, 5, 64, plus(v1078, v1079)); + real2 v1092 = minus(v1078, v1079); + scatter(out, 37, 64, timesminusplus(v1092, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v1092), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v1075 = minusplus(v1073, v1074); + scatter(out, 21, 64, timesminusplus(reverse(v1075), load(tbl, 186 * VECWIDTH + tbloffset), times(v1075, load(tbl, 187 * VECWIDTH + tbloffset)))); + real2 v1077 = minusplus(uminus(v1073), v1074); + scatter(out, 53, 64, timesminusplus(reverse(v1077), load(tbl, 188 * VECWIDTH + tbloffset), times(v1077, load(tbl, 189 * VECWIDTH + tbloffset)))); + real2 v953 = timesminusplus(reverse(v939), load(tbl, 164 * VECWIDTH + tbloffset), times(v939, load(tbl, 165 * VECWIDTH + tbloffset))); + real2 v1099 = reverse(minus(v953, v993)); + real2 v1105 = plus(v953, v993); + real2 v973 = timesminusplus(reverse(v959), load(tbl, 168 * VECWIDTH + tbloffset), times(v959, load(tbl, 169 * VECWIDTH + tbloffset))); + real2 v933 = timesminusplus(reverse(v919), load(tbl, 160 * VECWIDTH + tbloffset), times(v919, load(tbl, 161 * VECWIDTH + tbloffset))); + real2 v1104 = plus(v933, v973); + real2 v1100 = minus(v973, v933); + scatter(out, 13, 64, plus(v1104, v1105)); + real2 v1118 = minus(v1104, v1105); + scatter(out, 45, 64, timesminusplus(v1118, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v1118), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v1101 = minusplus(v1099, v1100); + scatter(out, 29, 64, timesminusplus(reverse(v1101), load(tbl, 190 * VECWIDTH + tbloffset), times(v1101, load(tbl, 191 * VECWIDTH + tbloffset)))); + real2 v1103 = minusplus(uminus(v1099), v1100); + scatter(out, 61, 64, timesminusplus(reverse(v1103), load(tbl, 192 * VECWIDTH + tbloffset), times(v1103, load(tbl, 193 * VECWIDTH + tbloffset)))); + real2 v345 = timesminusplus(reverse(v331), load(tbl, 56 * VECWIDTH + tbloffset), times(v331, load(tbl, 57 * VECWIDTH + tbloffset))); + real2 v325 = timesminusplus(reverse(v311), load(tbl, 52 * VECWIDTH + tbloffset), times(v311, load(tbl, 53 * VECWIDTH + tbloffset))); + real2 v265 = timesminusplus(reverse(v251), load(tbl, 40 * VECWIDTH + tbloffset), times(v251, load(tbl, 41 * VECWIDTH + tbloffset))); + real2 v185 = timesminusplus(reverse(v171), load(tbl, 24 * VECWIDTH + tbloffset), times(v171, load(tbl, 25 * VECWIDTH + tbloffset))); + real2 v165 = timesminusplus(reverse(v151), load(tbl, 20 * VECWIDTH + tbloffset), times(v151, load(tbl, 21 * VECWIDTH + tbloffset))); + real2 v1131 = plus(v165, v325); + real2 v1125 = reverse(minus(v165, v325)); + real2 v1151 = plus(v185, v345); + real2 v1145 = reverse(minus(v185, v345)); + real2 v105 = timesminusplus(reverse(v91), load(tbl, 8 * VECWIDTH + tbloffset), times(v91, load(tbl, 9 * VECWIDTH + tbloffset))); + real2 v1150 = plus(v105, v265); + real2 v1146 = minus(v265, v105); + real2 v1226 = minus(v1151, v1150); + real2 v1230 = plus(v1150, v1151); + real2 v1231 = plus(v1190, v1191); + real2 v1225 = reverse(minus(v1190, v1191)); + real2 v1245 = reverse(minus(v1230, v1231)); + real2 v1251 = plus(v1230, v1231); + real2 v365 = timesminusplus(reverse(v351), load(tbl, 60 * VECWIDTH + tbloffset), times(v351, load(tbl, 61 * VECWIDTH + tbloffset))); + real2 v285 = timesminusplus(reverse(v271), load(tbl, 44 * VECWIDTH + tbloffset), times(v271, load(tbl, 45 * VECWIDTH + tbloffset))); + real2 v205 = timesminusplus(reverse(v191), load(tbl, 28 * VECWIDTH + tbloffset), times(v191, load(tbl, 29 * VECWIDTH + tbloffset))); + real2 v1171 = plus(v205, v365); + real2 v1165 = reverse(minus(v205, v365)); + real2 v125 = timesminusplus(reverse(v111), load(tbl, 12 * VECWIDTH + tbloffset), times(v111, load(tbl, 13 * VECWIDTH + tbloffset))); + real2 v85 = timesminusplus(reverse(v71), load(tbl, 4 * VECWIDTH + tbloffset), times(v71, load(tbl, 5 * VECWIDTH + tbloffset))); + real2 v245 = timesminusplus(reverse(v231), load(tbl, 36 * VECWIDTH + tbloffset), times(v231, load(tbl, 37 * VECWIDTH + tbloffset))); + real2 v1126 = minus(v245, v85); + real2 v1130 = plus(v85, v245); + real2 v1210 = plus(v1130, v1131); + real2 v1206 = minus(v1131, v1130); + real2 v1166 = minus(v285, v125); + real2 v1170 = plus(v125, v285); + real2 v1211 = plus(v1170, v1171); + real2 v1205 = reverse(minus(v1170, v1171)); + real2 v1246 = minus(v1211, v1210); + real2 v1250 = plus(v1210, v1211); + scatter(out, 3, 64, plus(v1250, v1251)); + real2 v1264 = minus(v1250, v1251); + scatter(out, 35, 64, timesminusplus(v1264, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v1264), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v1247 = minusplus(v1245, v1246); + real2 v1249 = minusplus(uminus(v1245), v1246); + scatter(out, 19, 64, timesminusplus(reverse(v1247), load(tbl, 218 * VECWIDTH + tbloffset), times(v1247, load(tbl, 219 * VECWIDTH + tbloffset)))); + scatter(out, 51, 64, timesminusplus(reverse(v1249), load(tbl, 220 * VECWIDTH + tbloffset), times(v1249, load(tbl, 221 * VECWIDTH + tbloffset)))); + real2 v1229 = minusplus(uminus(v1225), v1226); + real2 v1227 = minusplus(v1225, v1226); + real2 v1207 = minusplus(v1205, v1206); + real2 v1209 = minusplus(uminus(v1205), v1206); + real2 v1237 = timesminusplus(reverse(v1227), load(tbl, 214 * VECWIDTH + tbloffset), times(v1227, load(tbl, 215 * VECWIDTH + tbloffset))); + real2 v1217 = timesminusplus(reverse(v1207), load(tbl, 210 * VECWIDTH + tbloffset), times(v1207, load(tbl, 211 * VECWIDTH + tbloffset))); + scatter(out, 11, 64, plus(v1217, v1237)); + real2 v1270 = minus(v1217, v1237); + scatter(out, 43, 64, timesminusplus(v1270, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v1270), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v1223 = timesminusplus(reverse(v1209), load(tbl, 212 * VECWIDTH + tbloffset), times(v1209, load(tbl, 213 * VECWIDTH + tbloffset))); + real2 v1243 = timesminusplus(reverse(v1229), load(tbl, 216 * VECWIDTH + tbloffset), times(v1229, load(tbl, 217 * VECWIDTH + tbloffset))); + scatter(out, 27, 64, plus(v1223, v1243)); + real2 v1276 = minus(v1223, v1243); + scatter(out, 59, 64, timesminusplus(v1276, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v1276), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v1189 = minusplus(uminus(v1185), v1186); + real2 v1187 = minusplus(v1185, v1186); + real2 v1129 = minusplus(uminus(v1125), v1126); + real2 v1127 = minusplus(v1125, v1126); + real2 v1147 = minusplus(v1145, v1146); + real2 v1149 = minusplus(uminus(v1145), v1146); + real2 v1167 = minusplus(v1165, v1166); + real2 v1169 = minusplus(uminus(v1165), v1166); + real2 v1143 = timesminusplus(reverse(v1129), load(tbl, 196 * VECWIDTH + tbloffset), times(v1129, load(tbl, 197 * VECWIDTH + tbloffset))); + real2 v1163 = timesminusplus(reverse(v1149), load(tbl, 200 * VECWIDTH + tbloffset), times(v1149, load(tbl, 201 * VECWIDTH + tbloffset))); + real2 v1203 = timesminusplus(reverse(v1189), load(tbl, 208 * VECWIDTH + tbloffset), times(v1189, load(tbl, 209 * VECWIDTH + tbloffset))); + real2 v1315 = plus(v1163, v1203); + real2 v1309 = reverse(minus(v1163, v1203)); + real2 v1183 = timesminusplus(reverse(v1169), load(tbl, 204 * VECWIDTH + tbloffset), times(v1169, load(tbl, 205 * VECWIDTH + tbloffset))); + real2 v1314 = plus(v1143, v1183); + real2 v1310 = minus(v1183, v1143); + scatter(out, 15, 64, plus(v1314, v1315)); + real2 v1328 = minus(v1314, v1315); + scatter(out, 47, 64, timesminusplus(v1328, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v1328), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v1311 = minusplus(v1309, v1310); + scatter(out, 31, 64, timesminusplus(reverse(v1311), load(tbl, 226 * VECWIDTH + tbloffset), times(v1311, load(tbl, 227 * VECWIDTH + tbloffset)))); + real2 v1313 = minusplus(uminus(v1309), v1310); + scatter(out, 63, 64, timesminusplus(reverse(v1313), load(tbl, 228 * VECWIDTH + tbloffset), times(v1313, load(tbl, 229 * VECWIDTH + tbloffset)))); + real2 v1177 = timesminusplus(reverse(v1167), load(tbl, 202 * VECWIDTH + tbloffset), times(v1167, load(tbl, 203 * VECWIDTH + tbloffset))); + real2 v1137 = timesminusplus(reverse(v1127), load(tbl, 194 * VECWIDTH + tbloffset), times(v1127, load(tbl, 195 * VECWIDTH + tbloffset))); + real2 v1197 = timesminusplus(reverse(v1187), load(tbl, 206 * VECWIDTH + tbloffset), times(v1187, load(tbl, 207 * VECWIDTH + tbloffset))); + real2 v1157 = timesminusplus(reverse(v1147), load(tbl, 198 * VECWIDTH + tbloffset), times(v1147, load(tbl, 199 * VECWIDTH + tbloffset))); + real2 v1283 = reverse(minus(v1157, v1197)); + real2 v1289 = plus(v1157, v1197); + real2 v1288 = plus(v1137, v1177); + real2 v1284 = minus(v1177, v1137); + scatter(out, 7, 64, plus(v1288, v1289)); + real2 v1302 = minus(v1288, v1289); + scatter(out, 39, 64, timesminusplus(v1302, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v1302), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v1285 = minusplus(v1283, v1284); + real2 v1287 = minusplus(uminus(v1283), v1284); + scatter(out, 55, 64, timesminusplus(reverse(v1287), load(tbl, 224 * VECWIDTH + tbloffset), times(v1287, load(tbl, 225 * VECWIDTH + tbloffset)))); + scatter(out, 23, 64, timesminusplus(reverse(v1285), load(tbl, 222 * VECWIDTH + tbloffset), times(v1285, load(tbl, 223 * VECWIDTH + tbloffset)))); +// Pres : 17339 + } +} + +ALIGNED(8192) void tbut64b_%CONFIG%_%ISA%(real *RESTRICT out0, uint32_t *q, const real *RESTRICT in0, const int inShift, const real *RESTRICT tbl, const int K) { + const int k = 1 << (inShift - LOG2VECWIDTH); + int i=0; +#pragma omp parallel for + for(i=0;i < k;i++) { + int i0 = i << LOG2VECWIDTH; + real *out = out0 + q[i]; + const real *in = in0 + i0*2; + const int tbloffset = K * i0; + +// Pres : 30254 + real2 v37 = load(in, 35 << inShift); + real2 v5 = load(in, 3 << inShift); + real2 v132 = plus(v5, v37); + real2 v128 = minus(v37, v5); + real2 v21 = load(in, 19 << inShift); + real2 v53 = load(in, 51 << inShift); + real2 v133 = plus(v21, v53); + real2 v127 = reverse(minus(v53, v21)); + real2 v131 = minusplus(uminus(v127), v128); + real2 v129 = minusplus(v127, v128); + real2 v139 = timesminusplus(reverse(v129), load(tbl, 14 * VECWIDTH + tbloffset), times(v129, load(tbl, 15 * VECWIDTH + tbloffset))); + real2 v145 = timesminusplus(reverse(v131), load(tbl, 16 * VECWIDTH + tbloffset), times(v131, load(tbl, 17 * VECWIDTH + tbloffset))); + real2 v448 = minus(v133, v132); + real2 v452 = plus(v132, v133); + real2 v45 = load(in, 43 << inShift); + real2 v13 = load(in, 11 << inShift); + real2 v292 = plus(v13, v45); + real2 v288 = minus(v45, v13); + real2 v29 = load(in, 27 << inShift); + real2 v61 = load(in, 59 << inShift); + real2 v293 = plus(v29, v61); + real2 v287 = reverse(minus(v61, v29)); + real2 v291 = minusplus(uminus(v287), v288); + real2 v289 = minusplus(v287, v288); + real2 v299 = timesminusplus(reverse(v289), load(tbl, 46 * VECWIDTH + tbloffset), times(v289, load(tbl, 47 * VECWIDTH + tbloffset))); + real2 v453 = plus(v292, v293); + real2 v447 = reverse(minus(v293, v292)); + real2 v608 = minus(v453, v452); + real2 v612 = plus(v452, v453); + real2 v980 = plus(v139, v299); + real2 v976 = minus(v299, v139); + real2 v449 = minusplus(v447, v448); + real2 v451 = minusplus(uminus(v447), v448); + real2 v465 = timesminusplus(reverse(v451), load(tbl, 80 * VECWIDTH + tbloffset), times(v451, load(tbl, 81 * VECWIDTH + tbloffset))); + real2 v305 = timesminusplus(reverse(v291), load(tbl, 48 * VECWIDTH + tbloffset), times(v291, load(tbl, 49 * VECWIDTH + tbloffset))); + real2 v1186 = minus(v305, v145); + real2 v1190 = plus(v145, v305); + real2 v459 = timesminusplus(reverse(v449), load(tbl, 78 * VECWIDTH + tbloffset), times(v449, load(tbl, 79 * VECWIDTH + tbloffset))); + real2 v25 = load(in, 23 << inShift); + real2 v57 = load(in, 55 << inShift); + real2 v207 = reverse(minus(v57, v25)); + real2 v213 = plus(v25, v57); + real2 v9 = load(in, 7 << inShift); + real2 v41 = load(in, 39 << inShift); + real2 v212 = plus(v9, v41); + real2 v208 = minus(v41, v9); + real2 v528 = minus(v213, v212); + real2 v532 = plus(v212, v213); + real2 v209 = minusplus(v207, v208); + real2 v211 = minusplus(uminus(v207), v208); + real2 v225 = timesminusplus(reverse(v211), load(tbl, 32 * VECWIDTH + tbloffset), times(v211, load(tbl, 33 * VECWIDTH + tbloffset))); + real2 v219 = timesminusplus(reverse(v209), load(tbl, 30 * VECWIDTH + tbloffset), times(v209, load(tbl, 31 * VECWIDTH + tbloffset))); + real2 v17 = load(in, 15 << inShift); + real2 v49 = load(in, 47 << inShift); + real2 v368 = minus(v49, v17); + real2 v372 = plus(v17, v49); + real2 v33 = load(in, 31 << inShift); + real2 v65 = load(in, 63 << inShift); + real2 v367 = reverse(minus(v65, v33)); + real2 v373 = plus(v33, v65); + real2 v369 = minusplus(v367, v368); + real2 v371 = minusplus(uminus(v367), v368); + real2 v533 = plus(v372, v373); + real2 v527 = reverse(minus(v373, v372)); + real2 v607 = reverse(minus(v533, v532)); + real2 v613 = plus(v532, v533); + real2 v529 = minusplus(v527, v528); + real2 v531 = minusplus(uminus(v527), v528); + real2 v545 = timesminusplus(reverse(v531), load(tbl, 96 * VECWIDTH + tbloffset), times(v531, load(tbl, 97 * VECWIDTH + tbloffset))); + real2 v653 = plus(v612, v613); + real2 v647 = reverse(minus(v613, v612)); + real2 v609 = minusplus(v607, v608); + real2 v611 = minusplus(uminus(v607), v608); + real2 v863 = plus(v465, v545); + real2 v857 = reverse(minus(v545, v465)); + real2 v539 = timesminusplus(reverse(v529), load(tbl, 94 * VECWIDTH + tbloffset), times(v529, load(tbl, 95 * VECWIDTH + tbloffset))); + real2 v385 = timesminusplus(reverse(v371), load(tbl, 64 * VECWIDTH + tbloffset), times(v371, load(tbl, 65 * VECWIDTH + tbloffset))); + real2 v619 = timesminusplus(reverse(v609), load(tbl, 110 * VECWIDTH + tbloffset), times(v609, load(tbl, 111 * VECWIDTH + tbloffset))); + real2 v1191 = plus(v225, v385); + real2 v1185 = reverse(minus(v385, v225)); + real2 v779 = reverse(minus(v539, v459)); + real2 v785 = plus(v459, v539); + real2 v625 = timesminusplus(reverse(v611), load(tbl, 112 * VECWIDTH + tbloffset), times(v611, load(tbl, 113 * VECWIDTH + tbloffset))); + real2 v379 = timesminusplus(reverse(v369), load(tbl, 62 * VECWIDTH + tbloffset), times(v369, load(tbl, 63 * VECWIDTH + tbloffset))); + real2 v975 = reverse(minus(v379, v219)); + real2 v981 = plus(v219, v379); + real2 v977 = minusplus(v975, v976); + real2 v979 = minusplus(uminus(v975), v976); + real2 v987 = timesminusplus(reverse(v977), load(tbl, 170 * VECWIDTH + tbloffset), times(v977, load(tbl, 171 * VECWIDTH + tbloffset))); + real2 v993 = timesminusplus(reverse(v979), load(tbl, 172 * VECWIDTH + tbloffset), times(v979, load(tbl, 173 * VECWIDTH + tbloffset))); + real2 v1015 = reverse(minus(v981, v980)); + real2 v1021 = plus(v980, v981); + real2 v11 = load(in, 9 << inShift); + real2 v43 = load(in, 41 << inShift); + real2 v248 = minus(v43, v11); + real2 v252 = plus(v11, v43); + real2 v59 = load(in, 57 << inShift); + real2 v27 = load(in, 25 << inShift); + real2 v253 = plus(v27, v59); + real2 v247 = reverse(minus(v59, v27)); + real2 v413 = plus(v252, v253); + real2 v407 = reverse(minus(v253, v252)); + real2 v249 = minusplus(v247, v248); + real2 v251 = minusplus(uminus(v247), v248); + real2 v259 = timesminusplus(reverse(v249), load(tbl, 38 * VECWIDTH + tbloffset), times(v249, load(tbl, 39 * VECWIDTH + tbloffset))); + real2 v35 = load(in, 33 << inShift); + real2 v3 = load(in, 1 << inShift); + real2 v92 = plus(v3, v35); + real2 v88 = minus(v35, v3); + real2 v51 = load(in, 49 << inShift); + real2 v19 = load(in, 17 << inShift); + real2 v87 = reverse(minus(v51, v19)); + real2 v93 = plus(v19, v51); + real2 v412 = plus(v92, v93); + real2 v408 = minus(v93, v92); + real2 v411 = minusplus(uminus(v407), v408); + real2 v409 = minusplus(v407, v408); + real2 v91 = minusplus(uminus(v87), v88); + real2 v89 = minusplus(v87, v88); + real2 v99 = timesminusplus(reverse(v89), load(tbl, 6 * VECWIDTH + tbloffset), times(v89, load(tbl, 7 * VECWIDTH + tbloffset))); + real2 v425 = timesminusplus(reverse(v411), load(tbl, 72 * VECWIDTH + tbloffset), times(v411, load(tbl, 73 * VECWIDTH + tbloffset))); + real2 v568 = minus(v413, v412); + real2 v572 = plus(v412, v413); + real2 v940 = plus(v99, v259); + real2 v936 = minus(v259, v99); + real2 v419 = timesminusplus(reverse(v409), load(tbl, 70 * VECWIDTH + tbloffset), times(v409, load(tbl, 71 * VECWIDTH + tbloffset))); + real2 v47 = load(in, 45 << inShift); + real2 v15 = load(in, 13 << inShift); + real2 v332 = plus(v15, v47); + real2 v328 = minus(v47, v15); + real2 v63 = load(in, 61 << inShift); + real2 v31 = load(in, 29 << inShift); + real2 v327 = reverse(minus(v63, v31)); + real2 v333 = plus(v31, v63); + real2 v329 = minusplus(v327, v328); + real2 v331 = minusplus(uminus(v327), v328); + real2 v339 = timesminusplus(reverse(v329), load(tbl, 54 * VECWIDTH + tbloffset), times(v329, load(tbl, 55 * VECWIDTH + tbloffset))); + real2 v487 = reverse(minus(v333, v332)); + real2 v493 = plus(v332, v333); + real2 v7 = load(in, 5 << inShift); + real2 v39 = load(in, 37 << inShift); + real2 v172 = plus(v7, v39); + real2 v168 = minus(v39, v7); + real2 v55 = load(in, 53 << inShift); + real2 v23 = load(in, 21 << inShift); + real2 v173 = plus(v23, v55); + real2 v167 = reverse(minus(v55, v23)); + real2 v488 = minus(v173, v172); + real2 v492 = plus(v172, v173); + real2 v491 = minusplus(uminus(v487), v488); + real2 v489 = minusplus(v487, v488); + real2 v499 = timesminusplus(reverse(v489), load(tbl, 86 * VECWIDTH + tbloffset), times(v489, load(tbl, 87 * VECWIDTH + tbloffset))); + real2 v505 = timesminusplus(reverse(v491), load(tbl, 88 * VECWIDTH + tbloffset), times(v491, load(tbl, 89 * VECWIDTH + tbloffset))); + real2 v567 = reverse(minus(v493, v492)); + real2 v573 = plus(v492, v493); + real2 v571 = minusplus(uminus(v567), v568); + real2 v569 = minusplus(v567, v568); + real2 v579 = timesminusplus(reverse(v569), load(tbl, 102 * VECWIDTH + tbloffset), times(v569, load(tbl, 103 * VECWIDTH + tbloffset))); + real2 v585 = timesminusplus(reverse(v571), load(tbl, 104 * VECWIDTH + tbloffset), times(v571, load(tbl, 105 * VECWIDTH + tbloffset))); + real2 v739 = plus(v585, v625); + real2 v733 = reverse(minus(v625, v585)); + real2 v707 = reverse(minus(v619, v579)); + real2 v713 = plus(v579, v619); + real2 v648 = minus(v573, v572); + real2 v652 = plus(v572, v573); + real2 v673 = plus(v652, v653); + real2 v667 = reverse(minus(v653, v652)); + real2 v651 = minusplus(uminus(v647), v648); + real2 v649 = minusplus(v647, v648); + real2 v659 = timesminusplus(reverse(v649), load(tbl, 118 * VECWIDTH + tbloffset), times(v649, load(tbl, 119 * VECWIDTH + tbloffset))); + real2 v665 = timesminusplus(reverse(v651), load(tbl, 120 * VECWIDTH + tbloffset), times(v651, load(tbl, 121 * VECWIDTH + tbloffset))); + real2 v780 = minus(v499, v419); + real2 v784 = plus(v419, v499); + real2 v781 = minusplus(v779, v780); + real2 v783 = minusplus(uminus(v779), v780); + real2 v805 = plus(v784, v785); + real2 v799 = reverse(minus(v785, v784)); + real2 v862 = plus(v425, v505); + real2 v858 = minus(v505, v425); + real2 v859 = minusplus(v857, v858); + real2 v861 = minusplus(uminus(v857), v858); + real2 v875 = timesminusplus(reverse(v861), load(tbl, 152 * VECWIDTH + tbloffset), times(v861, load(tbl, 153 * VECWIDTH + tbloffset))); + real2 v791 = timesminusplus(reverse(v781), load(tbl, 138 * VECWIDTH + tbloffset), times(v781, load(tbl, 139 * VECWIDTH + tbloffset))); + real2 v797 = timesminusplus(reverse(v783), load(tbl, 140 * VECWIDTH + tbloffset), times(v783, load(tbl, 141 * VECWIDTH + tbloffset))); + real2 v883 = plus(v862, v863); + real2 v877 = reverse(minus(v863, v862)); + real2 v869 = timesminusplus(reverse(v859), load(tbl, 150 * VECWIDTH + tbloffset), times(v859, load(tbl, 151 * VECWIDTH + tbloffset))); + real2 v36 = load(in, 34 << inShift); + real2 v4 = load(in, 2 << inShift); + real2 v108 = minus(v36, v4); + real2 v112 = plus(v4, v36); + real2 v52 = load(in, 50 << inShift); + real2 v20 = load(in, 18 << inShift); + real2 v113 = plus(v20, v52); + real2 v107 = reverse(minus(v52, v20)); + real2 v428 = minus(v113, v112); + real2 v432 = plus(v112, v113); + real2 v12 = load(in, 10 << inShift); + real2 v44 = load(in, 42 << inShift); + real2 v268 = minus(v44, v12); + real2 v272 = plus(v12, v44); + real2 v28 = load(in, 26 << inShift); + real2 v60 = load(in, 58 << inShift); + real2 v267 = reverse(minus(v60, v28)); + real2 v273 = plus(v28, v60); + real2 v427 = reverse(minus(v273, v272)); + real2 v433 = plus(v272, v273); + real2 v431 = minusplus(uminus(v427), v428); + real2 v429 = minusplus(v427, v428); + real2 v439 = timesminusplus(reverse(v429), load(tbl, 74 * VECWIDTH + tbloffset), times(v429, load(tbl, 75 * VECWIDTH + tbloffset))); + real2 v588 = minus(v433, v432); + real2 v592 = plus(v432, v433); + real2 v40 = load(in, 38 << inShift); + real2 v8 = load(in, 6 << inShift); + real2 v188 = minus(v40, v8); + real2 v192 = plus(v8, v40); + real2 v24 = load(in, 22 << inShift); + real2 v56 = load(in, 54 << inShift); + real2 v187 = reverse(minus(v56, v24)); + real2 v193 = plus(v24, v56); + real2 v512 = plus(v192, v193); + real2 v508 = minus(v193, v192); + real2 v32 = load(in, 30 << inShift); + real2 v64 = load(in, 62 << inShift); + real2 v347 = reverse(minus(v64, v32)); + real2 v353 = plus(v32, v64); + real2 v48 = load(in, 46 << inShift); + real2 v16 = load(in, 14 << inShift); + real2 v348 = minus(v48, v16); + real2 v352 = plus(v16, v48); + real2 v513 = plus(v352, v353); + real2 v507 = reverse(minus(v353, v352)); + real2 v587 = reverse(minus(v513, v512)); + real2 v593 = plus(v512, v513); + real2 v633 = plus(v592, v593); + real2 v627 = reverse(minus(v593, v592)); + real2 v591 = minusplus(uminus(v587), v588); + real2 v589 = minusplus(v587, v588); + real2 v605 = timesminusplus(reverse(v591), load(tbl, 108 * VECWIDTH + tbloffset), times(v591, load(tbl, 109 * VECWIDTH + tbloffset))); + real2 v599 = timesminusplus(reverse(v589), load(tbl, 106 * VECWIDTH + tbloffset), times(v589, load(tbl, 107 * VECWIDTH + tbloffset))); + real2 v46 = load(in, 44 << inShift); + real2 v14 = load(in, 12 << inShift); + real2 v312 = plus(v14, v46); + real2 v308 = minus(v46, v14); + real2 v62 = load(in, 60 << inShift); + real2 v30 = load(in, 28 << inShift); + real2 v313 = plus(v30, v62); + real2 v307 = reverse(minus(v62, v30)); + real2 v467 = reverse(minus(v313, v312)); + real2 v473 = plus(v312, v313); + real2 v22 = load(in, 20 << inShift); + real2 v54 = load(in, 52 << inShift); + real2 v147 = reverse(minus(v54, v22)); + real2 v153 = plus(v22, v54); + real2 v6 = load(in, 4 << inShift); + real2 v38 = load(in, 36 << inShift); + real2 v148 = minus(v38, v6); + real2 v152 = plus(v6, v38); + real2 v472 = plus(v152, v153); + real2 v468 = minus(v153, v152); + real2 v547 = reverse(minus(v473, v472)); + real2 v553 = plus(v472, v473); + real2 v10 = load(in, 8 << inShift); + real2 v42 = load(in, 40 << inShift); + real2 v232 = plus(v10, v42); + real2 v228 = minus(v42, v10); + real2 v58 = load(in, 56 << inShift); + real2 v26 = load(in, 24 << inShift); + real2 v233 = plus(v26, v58); + real2 v227 = reverse(minus(v58, v26)); + real2 v393 = plus(v232, v233); + real2 v387 = reverse(minus(v233, v232)); + real2 v2 = load(in, 0 << inShift); + real2 v34 = load(in, 32 << inShift); + real2 v72 = plus(v2, v34); + real2 v68 = minus(v34, v2); + real2 v18 = load(in, 16 << inShift); + real2 v50 = load(in, 48 << inShift); + real2 v73 = plus(v18, v50); + real2 v67 = reverse(minus(v50, v18)); + real2 v388 = minus(v73, v72); + real2 v392 = plus(v72, v73); + real2 v548 = minus(v393, v392); + real2 v552 = plus(v392, v393); + real2 v628 = minus(v553, v552); + real2 v632 = plus(v552, v553); + real2 v672 = plus(v632, v633); + real2 v668 = minus(v633, v632); + scatter(out, 0, 64, plus(v672, v673)); + real2 v686 = minus(v672, v673); + scatter(out, 32, 64, timesminusplus(v686, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v686), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v669 = minusplus(v667, v668); + real2 v671 = minusplus(uminus(v667), v668); + scatter(out, 48, 64, timesminusplus(reverse(v671), load(tbl, 124 * VECWIDTH + tbloffset), times(v671, load(tbl, 125 * VECWIDTH + tbloffset)))); + scatter(out, 16, 64, timesminusplus(reverse(v669), load(tbl, 122 * VECWIDTH + tbloffset), times(v669, load(tbl, 123 * VECWIDTH + tbloffset)))); + real2 v631 = minusplus(uminus(v627), v628); + real2 v629 = minusplus(v627, v628); + real2 v639 = timesminusplus(reverse(v629), load(tbl, 114 * VECWIDTH + tbloffset), times(v629, load(tbl, 115 * VECWIDTH + tbloffset))); + scatter(out, 8, 64, plus(v639, v659)); + real2 v694 = minus(v639, v659); + scatter(out, 40, 64, timesminusplus(v694, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v694), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v645 = timesminusplus(reverse(v631), load(tbl, 116 * VECWIDTH + tbloffset), times(v631, load(tbl, 117 * VECWIDTH + tbloffset))); + scatter(out, 24, 64, plus(v645, v665)); + real2 v700 = minus(v645, v665); + scatter(out, 56, 64, timesminusplus(v700, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v700), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v549 = minusplus(v547, v548); + real2 v551 = minusplus(uminus(v547), v548); + real2 v559 = timesminusplus(reverse(v549), load(tbl, 98 * VECWIDTH + tbloffset), times(v549, load(tbl, 99 * VECWIDTH + tbloffset))); + real2 v708 = minus(v599, v559); + real2 v712 = plus(v559, v599); + scatter(out, 4, 64, plus(v712, v713)); + real2 v726 = minus(v712, v713); + scatter(out, 36, 64, timesminusplus(v726, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v726), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v711 = minusplus(uminus(v707), v708); + real2 v709 = minusplus(v707, v708); + scatter(out, 20, 64, timesminusplus(reverse(v709), load(tbl, 126 * VECWIDTH + tbloffset), times(v709, load(tbl, 127 * VECWIDTH + tbloffset)))); + scatter(out, 52, 64, timesminusplus(reverse(v711), load(tbl, 128 * VECWIDTH + tbloffset), times(v711, load(tbl, 129 * VECWIDTH + tbloffset)))); + real2 v565 = timesminusplus(reverse(v551), load(tbl, 100 * VECWIDTH + tbloffset), times(v551, load(tbl, 101 * VECWIDTH + tbloffset))); + real2 v738 = plus(v565, v605); + real2 v734 = minus(v605, v565); + scatter(out, 12, 64, plus(v738, v739)); + real2 v752 = minus(v738, v739); + scatter(out, 44, 64, timesminusplus(v752, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v752), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v737 = minusplus(uminus(v733), v734); + scatter(out, 60, 64, timesminusplus(reverse(v737), load(tbl, 132 * VECWIDTH + tbloffset), times(v737, load(tbl, 133 * VECWIDTH + tbloffset)))); + real2 v735 = minusplus(v733, v734); + scatter(out, 28, 64, timesminusplus(reverse(v735), load(tbl, 130 * VECWIDTH + tbloffset), times(v735, load(tbl, 131 * VECWIDTH + tbloffset)))); + real2 v471 = minusplus(uminus(v467), v468); + real2 v469 = minusplus(v467, v468); + real2 v479 = timesminusplus(reverse(v469), load(tbl, 82 * VECWIDTH + tbloffset), times(v469, load(tbl, 83 * VECWIDTH + tbloffset))); + real2 v511 = minusplus(uminus(v507), v508); + real2 v509 = minusplus(v507, v508); + real2 v519 = timesminusplus(reverse(v509), load(tbl, 90 * VECWIDTH + tbloffset), times(v509, load(tbl, 91 * VECWIDTH + tbloffset))); + real2 v765 = plus(v439, v519); + real2 v759 = reverse(minus(v519, v439)); + real2 v389 = minusplus(v387, v388); + real2 v391 = minusplus(uminus(v387), v388); + real2 v399 = timesminusplus(reverse(v389), load(tbl, 66 * VECWIDTH + tbloffset), times(v389, load(tbl, 67 * VECWIDTH + tbloffset))); + real2 v764 = plus(v399, v479); + real2 v760 = minus(v479, v399); + real2 v804 = plus(v764, v765); + real2 v800 = minus(v765, v764); + scatter(out, 2, 64, plus(v804, v805)); + real2 v818 = minus(v804, v805); + scatter(out, 34, 64, timesminusplus(v818, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v818), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v803 = minusplus(uminus(v799), v800); + scatter(out, 50, 64, timesminusplus(reverse(v803), load(tbl, 144 * VECWIDTH + tbloffset), times(v803, load(tbl, 145 * VECWIDTH + tbloffset)))); + real2 v801 = minusplus(v799, v800); + scatter(out, 18, 64, timesminusplus(reverse(v801), load(tbl, 142 * VECWIDTH + tbloffset), times(v801, load(tbl, 143 * VECWIDTH + tbloffset)))); + real2 v763 = minusplus(uminus(v759), v760); + real2 v761 = minusplus(v759, v760); + real2 v777 = timesminusplus(reverse(v763), load(tbl, 136 * VECWIDTH + tbloffset), times(v763, load(tbl, 137 * VECWIDTH + tbloffset))); + scatter(out, 26, 64, plus(v777, v797)); + real2 v830 = minus(v777, v797); + scatter(out, 58, 64, timesminusplus(v830, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v830), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v771 = timesminusplus(reverse(v761), load(tbl, 134 * VECWIDTH + tbloffset), times(v761, load(tbl, 135 * VECWIDTH + tbloffset))); + scatter(out, 10, 64, plus(v771, v791)); + real2 v824 = minus(v771, v791); + scatter(out, 42, 64, timesminusplus(v824, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v824), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v445 = timesminusplus(reverse(v431), load(tbl, 76 * VECWIDTH + tbloffset), times(v431, load(tbl, 77 * VECWIDTH + tbloffset))); + real2 v525 = timesminusplus(reverse(v511), load(tbl, 92 * VECWIDTH + tbloffset), times(v511, load(tbl, 93 * VECWIDTH + tbloffset))); + real2 v837 = reverse(minus(v525, v445)); + real2 v843 = plus(v445, v525); + real2 v485 = timesminusplus(reverse(v471), load(tbl, 84 * VECWIDTH + tbloffset), times(v471, load(tbl, 85 * VECWIDTH + tbloffset))); + real2 v405 = timesminusplus(reverse(v391), load(tbl, 68 * VECWIDTH + tbloffset), times(v391, load(tbl, 69 * VECWIDTH + tbloffset))); + real2 v838 = minus(v485, v405); + real2 v842 = plus(v405, v485); + real2 v878 = minus(v843, v842); + real2 v882 = plus(v842, v843); + scatter(out, 6, 64, plus(v882, v883)); + real2 v896 = minus(v882, v883); + scatter(out, 38, 64, timesminusplus(v896, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v896), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v881 = minusplus(uminus(v877), v878); + scatter(out, 54, 64, timesminusplus(reverse(v881), load(tbl, 156 * VECWIDTH + tbloffset), times(v881, load(tbl, 157 * VECWIDTH + tbloffset)))); + real2 v879 = minusplus(v877, v878); + scatter(out, 22, 64, timesminusplus(reverse(v879), load(tbl, 154 * VECWIDTH + tbloffset), times(v879, load(tbl, 155 * VECWIDTH + tbloffset)))); + real2 v841 = minusplus(uminus(v837), v838); + real2 v839 = minusplus(v837, v838); + real2 v855 = timesminusplus(reverse(v841), load(tbl, 148 * VECWIDTH + tbloffset), times(v841, load(tbl, 149 * VECWIDTH + tbloffset))); + scatter(out, 30, 64, plus(v855, v875)); + real2 v908 = minus(v855, v875); + scatter(out, 62, 64, timesminusplus(v908, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v908), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v849 = timesminusplus(reverse(v839), load(tbl, 146 * VECWIDTH + tbloffset), times(v839, load(tbl, 147 * VECWIDTH + tbloffset))); + scatter(out, 14, 64, plus(v849, v869)); + real2 v902 = minus(v849, v869); + scatter(out, 46, 64, timesminusplus(v902, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v902), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v151 = minusplus(uminus(v147), v148); + real2 v149 = minusplus(v147, v148); + real2 v311 = minusplus(uminus(v307), v308); + real2 v309 = minusplus(v307, v308); + real2 v109 = minusplus(v107, v108); + real2 v111 = minusplus(uminus(v107), v108); + real2 v119 = timesminusplus(reverse(v109), load(tbl, 10 * VECWIDTH + tbloffset), times(v109, load(tbl, 11 * VECWIDTH + tbloffset))); + real2 v269 = minusplus(v267, v268); + real2 v271 = minusplus(uminus(v267), v268); + real2 v279 = timesminusplus(reverse(v269), load(tbl, 42 * VECWIDTH + tbloffset), times(v269, load(tbl, 43 * VECWIDTH + tbloffset))); + real2 v960 = plus(v119, v279); + real2 v956 = minus(v279, v119); + real2 v169 = minusplus(v167, v168); + real2 v171 = minusplus(uminus(v167), v168); + real2 v159 = timesminusplus(reverse(v149), load(tbl, 18 * VECWIDTH + tbloffset), times(v149, load(tbl, 19 * VECWIDTH + tbloffset))); + real2 v319 = timesminusplus(reverse(v309), load(tbl, 50 * VECWIDTH + tbloffset), times(v309, load(tbl, 51 * VECWIDTH + tbloffset))); + real2 v921 = plus(v159, v319); + real2 v915 = reverse(minus(v319, v159)); + real2 v351 = minusplus(uminus(v347), v348); + real2 v349 = minusplus(v347, v348); + real2 v359 = timesminusplus(reverse(v349), load(tbl, 58 * VECWIDTH + tbloffset), times(v349, load(tbl, 59 * VECWIDTH + tbloffset))); + real2 v191 = minusplus(uminus(v187), v188); + real2 v189 = minusplus(v187, v188); + real2 v199 = timesminusplus(reverse(v189), load(tbl, 26 * VECWIDTH + tbloffset), times(v189, load(tbl, 27 * VECWIDTH + tbloffset))); + real2 v961 = plus(v199, v359); + real2 v955 = reverse(minus(v359, v199)); + real2 v995 = reverse(minus(v961, v960)); + real2 v1001 = plus(v960, v961); + real2 v179 = timesminusplus(reverse(v169), load(tbl, 22 * VECWIDTH + tbloffset), times(v169, load(tbl, 23 * VECWIDTH + tbloffset))); + real2 v941 = plus(v179, v339); + real2 v935 = reverse(minus(v339, v179)); + real2 v1016 = minus(v941, v940); + real2 v1020 = plus(v940, v941); + real2 v71 = minusplus(uminus(v67), v68); + real2 v69 = minusplus(v67, v68); + real2 v79 = timesminusplus(reverse(v69), load(tbl, 2 * VECWIDTH + tbloffset), times(v69, load(tbl, 3 * VECWIDTH + tbloffset))); + real2 v1041 = plus(v1020, v1021); + real2 v1035 = reverse(minus(v1021, v1020)); + real2 v229 = minusplus(v227, v228); + real2 v231 = minusplus(uminus(v227), v228); + real2 v239 = timesminusplus(reverse(v229), load(tbl, 34 * VECWIDTH + tbloffset), times(v229, load(tbl, 35 * VECWIDTH + tbloffset))); + real2 v920 = plus(v79, v239); + real2 v916 = minus(v239, v79); + real2 v996 = minus(v921, v920); + real2 v1000 = plus(v920, v921); + real2 v1040 = plus(v1000, v1001); + real2 v1036 = minus(v1001, v1000); + scatter(out, 1, 64, plus(v1040, v1041)); + real2 v1054 = minus(v1040, v1041); + scatter(out, 33, 64, timesminusplus(v1054, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v1054), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v1037 = minusplus(v1035, v1036); + real2 v1039 = minusplus(uminus(v1035), v1036); + scatter(out, 49, 64, timesminusplus(reverse(v1039), load(tbl, 184 * VECWIDTH + tbloffset), times(v1039, load(tbl, 185 * VECWIDTH + tbloffset)))); + scatter(out, 17, 64, timesminusplus(reverse(v1037), load(tbl, 182 * VECWIDTH + tbloffset), times(v1037, load(tbl, 183 * VECWIDTH + tbloffset)))); + real2 v1017 = minusplus(v1015, v1016); + real2 v1019 = minusplus(uminus(v1015), v1016); + real2 v1033 = timesminusplus(reverse(v1019), load(tbl, 180 * VECWIDTH + tbloffset), times(v1019, load(tbl, 181 * VECWIDTH + tbloffset))); + real2 v997 = minusplus(v995, v996); + real2 v999 = minusplus(uminus(v995), v996); + real2 v1013 = timesminusplus(reverse(v999), load(tbl, 176 * VECWIDTH + tbloffset), times(v999, load(tbl, 177 * VECWIDTH + tbloffset))); + scatter(out, 25, 64, plus(v1013, v1033)); + real2 v1066 = minus(v1013, v1033); + scatter(out, 57, 64, timesminusplus(v1066, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v1066), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v1027 = timesminusplus(reverse(v1017), load(tbl, 178 * VECWIDTH + tbloffset), times(v1017, load(tbl, 179 * VECWIDTH + tbloffset))); + real2 v1007 = timesminusplus(reverse(v997), load(tbl, 174 * VECWIDTH + tbloffset), times(v997, load(tbl, 175 * VECWIDTH + tbloffset))); + scatter(out, 9, 64, plus(v1007, v1027)); + real2 v1060 = minus(v1007, v1027); + scatter(out, 41, 64, timesminusplus(v1060, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v1060), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v937 = minusplus(v935, v936); + real2 v939 = minusplus(uminus(v935), v936); + real2 v959 = minusplus(uminus(v955), v956); + real2 v957 = minusplus(v955, v956); + real2 v967 = timesminusplus(reverse(v957), load(tbl, 166 * VECWIDTH + tbloffset), times(v957, load(tbl, 167 * VECWIDTH + tbloffset))); + real2 v947 = timesminusplus(reverse(v937), load(tbl, 162 * VECWIDTH + tbloffset), times(v937, load(tbl, 163 * VECWIDTH + tbloffset))); + real2 v919 = minusplus(uminus(v915), v916); + real2 v917 = minusplus(v915, v916); + real2 v1079 = plus(v947, v987); + real2 v1073 = reverse(minus(v987, v947)); + real2 v927 = timesminusplus(reverse(v917), load(tbl, 158 * VECWIDTH + tbloffset), times(v917, load(tbl, 159 * VECWIDTH + tbloffset))); + real2 v1074 = minus(v967, v927); + real2 v1078 = plus(v927, v967); + scatter(out, 5, 64, plus(v1078, v1079)); + real2 v1092 = minus(v1078, v1079); + scatter(out, 37, 64, timesminusplus(v1092, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v1092), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v1075 = minusplus(v1073, v1074); + scatter(out, 21, 64, timesminusplus(reverse(v1075), load(tbl, 186 * VECWIDTH + tbloffset), times(v1075, load(tbl, 187 * VECWIDTH + tbloffset)))); + real2 v1077 = minusplus(uminus(v1073), v1074); + scatter(out, 53, 64, timesminusplus(reverse(v1077), load(tbl, 188 * VECWIDTH + tbloffset), times(v1077, load(tbl, 189 * VECWIDTH + tbloffset)))); + real2 v953 = timesminusplus(reverse(v939), load(tbl, 164 * VECWIDTH + tbloffset), times(v939, load(tbl, 165 * VECWIDTH + tbloffset))); + real2 v1099 = reverse(minus(v993, v953)); + real2 v1105 = plus(v953, v993); + real2 v973 = timesminusplus(reverse(v959), load(tbl, 168 * VECWIDTH + tbloffset), times(v959, load(tbl, 169 * VECWIDTH + tbloffset))); + real2 v933 = timesminusplus(reverse(v919), load(tbl, 160 * VECWIDTH + tbloffset), times(v919, load(tbl, 161 * VECWIDTH + tbloffset))); + real2 v1104 = plus(v933, v973); + real2 v1100 = minus(v973, v933); + scatter(out, 13, 64, plus(v1104, v1105)); + real2 v1118 = minus(v1104, v1105); + scatter(out, 45, 64, timesminusplus(v1118, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v1118), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v1101 = minusplus(v1099, v1100); + scatter(out, 29, 64, timesminusplus(reverse(v1101), load(tbl, 190 * VECWIDTH + tbloffset), times(v1101, load(tbl, 191 * VECWIDTH + tbloffset)))); + real2 v1103 = minusplus(uminus(v1099), v1100); + scatter(out, 61, 64, timesminusplus(reverse(v1103), load(tbl, 192 * VECWIDTH + tbloffset), times(v1103, load(tbl, 193 * VECWIDTH + tbloffset)))); + real2 v345 = timesminusplus(reverse(v331), load(tbl, 56 * VECWIDTH + tbloffset), times(v331, load(tbl, 57 * VECWIDTH + tbloffset))); + real2 v325 = timesminusplus(reverse(v311), load(tbl, 52 * VECWIDTH + tbloffset), times(v311, load(tbl, 53 * VECWIDTH + tbloffset))); + real2 v265 = timesminusplus(reverse(v251), load(tbl, 40 * VECWIDTH + tbloffset), times(v251, load(tbl, 41 * VECWIDTH + tbloffset))); + real2 v185 = timesminusplus(reverse(v171), load(tbl, 24 * VECWIDTH + tbloffset), times(v171, load(tbl, 25 * VECWIDTH + tbloffset))); + real2 v165 = timesminusplus(reverse(v151), load(tbl, 20 * VECWIDTH + tbloffset), times(v151, load(tbl, 21 * VECWIDTH + tbloffset))); + real2 v1131 = plus(v165, v325); + real2 v1125 = reverse(minus(v325, v165)); + real2 v1151 = plus(v185, v345); + real2 v1145 = reverse(minus(v345, v185)); + real2 v105 = timesminusplus(reverse(v91), load(tbl, 8 * VECWIDTH + tbloffset), times(v91, load(tbl, 9 * VECWIDTH + tbloffset))); + real2 v1150 = plus(v105, v265); + real2 v1146 = minus(v265, v105); + real2 v1226 = minus(v1151, v1150); + real2 v1230 = plus(v1150, v1151); + real2 v1231 = plus(v1190, v1191); + real2 v1225 = reverse(minus(v1191, v1190)); + real2 v1245 = reverse(minus(v1231, v1230)); + real2 v1251 = plus(v1230, v1231); + real2 v365 = timesminusplus(reverse(v351), load(tbl, 60 * VECWIDTH + tbloffset), times(v351, load(tbl, 61 * VECWIDTH + tbloffset))); + real2 v285 = timesminusplus(reverse(v271), load(tbl, 44 * VECWIDTH + tbloffset), times(v271, load(tbl, 45 * VECWIDTH + tbloffset))); + real2 v205 = timesminusplus(reverse(v191), load(tbl, 28 * VECWIDTH + tbloffset), times(v191, load(tbl, 29 * VECWIDTH + tbloffset))); + real2 v1171 = plus(v205, v365); + real2 v1165 = reverse(minus(v365, v205)); + real2 v125 = timesminusplus(reverse(v111), load(tbl, 12 * VECWIDTH + tbloffset), times(v111, load(tbl, 13 * VECWIDTH + tbloffset))); + real2 v85 = timesminusplus(reverse(v71), load(tbl, 4 * VECWIDTH + tbloffset), times(v71, load(tbl, 5 * VECWIDTH + tbloffset))); + real2 v245 = timesminusplus(reverse(v231), load(tbl, 36 * VECWIDTH + tbloffset), times(v231, load(tbl, 37 * VECWIDTH + tbloffset))); + real2 v1126 = minus(v245, v85); + real2 v1130 = plus(v85, v245); + real2 v1210 = plus(v1130, v1131); + real2 v1206 = minus(v1131, v1130); + real2 v1166 = minus(v285, v125); + real2 v1170 = plus(v125, v285); + real2 v1211 = plus(v1170, v1171); + real2 v1205 = reverse(minus(v1171, v1170)); + real2 v1246 = minus(v1211, v1210); + real2 v1250 = plus(v1210, v1211); + scatter(out, 3, 64, plus(v1250, v1251)); + real2 v1264 = minus(v1250, v1251); + scatter(out, 35, 64, timesminusplus(v1264, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v1264), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v1247 = minusplus(v1245, v1246); + real2 v1249 = minusplus(uminus(v1245), v1246); + scatter(out, 19, 64, timesminusplus(reverse(v1247), load(tbl, 218 * VECWIDTH + tbloffset), times(v1247, load(tbl, 219 * VECWIDTH + tbloffset)))); + scatter(out, 51, 64, timesminusplus(reverse(v1249), load(tbl, 220 * VECWIDTH + tbloffset), times(v1249, load(tbl, 221 * VECWIDTH + tbloffset)))); + real2 v1229 = minusplus(uminus(v1225), v1226); + real2 v1227 = minusplus(v1225, v1226); + real2 v1207 = minusplus(v1205, v1206); + real2 v1209 = minusplus(uminus(v1205), v1206); + real2 v1237 = timesminusplus(reverse(v1227), load(tbl, 214 * VECWIDTH + tbloffset), times(v1227, load(tbl, 215 * VECWIDTH + tbloffset))); + real2 v1217 = timesminusplus(reverse(v1207), load(tbl, 210 * VECWIDTH + tbloffset), times(v1207, load(tbl, 211 * VECWIDTH + tbloffset))); + scatter(out, 11, 64, plus(v1217, v1237)); + real2 v1270 = minus(v1217, v1237); + scatter(out, 43, 64, timesminusplus(v1270, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v1270), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v1223 = timesminusplus(reverse(v1209), load(tbl, 212 * VECWIDTH + tbloffset), times(v1209, load(tbl, 213 * VECWIDTH + tbloffset))); + real2 v1243 = timesminusplus(reverse(v1229), load(tbl, 216 * VECWIDTH + tbloffset), times(v1229, load(tbl, 217 * VECWIDTH + tbloffset))); + scatter(out, 27, 64, plus(v1223, v1243)); + real2 v1276 = minus(v1223, v1243); + scatter(out, 59, 64, timesminusplus(v1276, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v1276), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v1189 = minusplus(uminus(v1185), v1186); + real2 v1187 = minusplus(v1185, v1186); + real2 v1129 = minusplus(uminus(v1125), v1126); + real2 v1127 = minusplus(v1125, v1126); + real2 v1147 = minusplus(v1145, v1146); + real2 v1149 = minusplus(uminus(v1145), v1146); + real2 v1167 = minusplus(v1165, v1166); + real2 v1169 = minusplus(uminus(v1165), v1166); + real2 v1143 = timesminusplus(reverse(v1129), load(tbl, 196 * VECWIDTH + tbloffset), times(v1129, load(tbl, 197 * VECWIDTH + tbloffset))); + real2 v1163 = timesminusplus(reverse(v1149), load(tbl, 200 * VECWIDTH + tbloffset), times(v1149, load(tbl, 201 * VECWIDTH + tbloffset))); + real2 v1203 = timesminusplus(reverse(v1189), load(tbl, 208 * VECWIDTH + tbloffset), times(v1189, load(tbl, 209 * VECWIDTH + tbloffset))); + real2 v1315 = plus(v1163, v1203); + real2 v1309 = reverse(minus(v1203, v1163)); + real2 v1183 = timesminusplus(reverse(v1169), load(tbl, 204 * VECWIDTH + tbloffset), times(v1169, load(tbl, 205 * VECWIDTH + tbloffset))); + real2 v1314 = plus(v1143, v1183); + real2 v1310 = minus(v1183, v1143); + scatter(out, 15, 64, plus(v1314, v1315)); + real2 v1328 = minus(v1314, v1315); + scatter(out, 47, 64, timesminusplus(v1328, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v1328), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v1311 = minusplus(v1309, v1310); + scatter(out, 31, 64, timesminusplus(reverse(v1311), load(tbl, 226 * VECWIDTH + tbloffset), times(v1311, load(tbl, 227 * VECWIDTH + tbloffset)))); + real2 v1313 = minusplus(uminus(v1309), v1310); + scatter(out, 63, 64, timesminusplus(reverse(v1313), load(tbl, 228 * VECWIDTH + tbloffset), times(v1313, load(tbl, 229 * VECWIDTH + tbloffset)))); + real2 v1177 = timesminusplus(reverse(v1167), load(tbl, 202 * VECWIDTH + tbloffset), times(v1167, load(tbl, 203 * VECWIDTH + tbloffset))); + real2 v1137 = timesminusplus(reverse(v1127), load(tbl, 194 * VECWIDTH + tbloffset), times(v1127, load(tbl, 195 * VECWIDTH + tbloffset))); + real2 v1197 = timesminusplus(reverse(v1187), load(tbl, 206 * VECWIDTH + tbloffset), times(v1187, load(tbl, 207 * VECWIDTH + tbloffset))); + real2 v1157 = timesminusplus(reverse(v1147), load(tbl, 198 * VECWIDTH + tbloffset), times(v1147, load(tbl, 199 * VECWIDTH + tbloffset))); + real2 v1283 = reverse(minus(v1197, v1157)); + real2 v1289 = plus(v1157, v1197); + real2 v1288 = plus(v1137, v1177); + real2 v1284 = minus(v1177, v1137); + scatter(out, 7, 64, plus(v1288, v1289)); + real2 v1302 = minus(v1288, v1289); + scatter(out, 39, 64, timesminusplus(v1302, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v1302), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v1285 = minusplus(v1283, v1284); + real2 v1287 = minusplus(uminus(v1283), v1284); + scatter(out, 55, 64, timesminusplus(reverse(v1287), load(tbl, 224 * VECWIDTH + tbloffset), times(v1287, load(tbl, 225 * VECWIDTH + tbloffset)))); + scatter(out, 23, 64, timesminusplus(reverse(v1285), load(tbl, 222 * VECWIDTH + tbloffset), times(v1285, load(tbl, 223 * VECWIDTH + tbloffset)))); +// Pres : 17339 + } +} +#endif + +// + +#if MAXBUTWIDTH >= 7 +ALIGNED(8192) void dft128f_%CONFIG%_%ISA%(real *RESTRICT out0, const real *RESTRICT in0, const int shift) { + const int k = 1 << (shift - LOG2VECWIDTH); + int i=0; +#pragma omp parallel for + for(i=0;i < k;i++) { + int i0 = i << LOG2VECWIDTH; + real *out = out0 + i0*2; + const real *in = in0 + i0*2; + +// Pres : 129041 + real2 v109 = load(in, 107 << shift); + real2 v45 = load(in, 43 << shift); + real2 v341 = plus(v45, v109); + real2 v335 = reverse(minus(v45, v109)); + real2 v77 = load(in, 75 << shift); + real2 v13 = load(in, 11 << shift); + real2 v340 = plus(v13, v77); + real2 v336 = minus(v77, v13); + real2 v337 = minusplus(v335, v336); + real2 v339 = minusplus(uminus(v335), v336); + real2 v350 = ctimesminusplus(reverse(v339), ctbl[61], ctimes(v339, ctbl[60])); + real2 v886 = plus(v340, v341); + real2 v882 = minus(v341, v340); + real2 v345 = ctimesminusplus(reverse(v337), ctbl[51], ctimes(v337, ctbl[41])); + real2 v125 = load(in, 123 << shift); + real2 v61 = load(in, 59 << shift); + real2 v621 = plus(v61, v125); + real2 v615 = reverse(minus(v61, v125)); + real2 v29 = load(in, 27 << shift); + real2 v93 = load(in, 91 << shift); + real2 v616 = minus(v93, v29); + real2 v620 = plus(v29, v93); + real2 v887 = plus(v620, v621); + real2 v881 = reverse(minus(v620, v621)); + real2 v1009 = reverse(minus(v886, v887)); + real2 v1015 = plus(v886, v887); + real2 v883 = minusplus(v881, v882); + real2 v885 = minusplus(uminus(v881), v882); + real2 v895 = ctimesminusplus(reverse(v885), ctbl[28], ctimes(v885, ctbl[14])); + real2 v619 = minusplus(uminus(v615), v616); + real2 v617 = minusplus(v615, v616); + real2 v625 = ctimesminusplus(reverse(v617), ctbl[53], ctimes(v617, ctbl[39])); + real2 v891 = ctimesminusplus(reverse(v883), ctbl[25], ctimes(v883, ctbl[19])); + real2 v631 = ctimesminusplus(reverse(v619), ctbl[58], ctimes(v619, ctbl[32])); + real2 v2129 = reverse(minus(v350, v631)); + real2 v2135 = plus(v350, v631); + real2 v1728 = reverse(minus(v345, v625)); + real2 v1734 = plus(v345, v625); + real2 v5 = load(in, 3 << shift); + real2 v69 = load(in, 67 << shift); + real2 v192 = plus(v5, v69); + real2 v188 = minus(v69, v5); + real2 v37 = load(in, 35 << shift); + real2 v101 = load(in, 99 << shift); + real2 v193 = plus(v37, v101); + real2 v187 = reverse(minus(v37, v101)); + real2 v758 = plus(v192, v193); + real2 v754 = minus(v193, v192); + real2 v189 = minusplus(v187, v188); + real2 v191 = minusplus(uminus(v187), v188); + real2 v203 = ctimesminusplus(reverse(v191), ctbl[35], ctimes(v191, ctbl[57])); + real2 v197 = ctimesminusplus(reverse(v189), ctbl[47], ctimes(v189, ctbl[45])); + real2 v53 = load(in, 51 << shift); + real2 v117 = load(in, 115 << shift); + real2 v474 = reverse(minus(v53, v117)); + real2 v480 = plus(v53, v117); + real2 v85 = load(in, 83 << shift); + real2 v21 = load(in, 19 << shift); + real2 v475 = minus(v85, v21); + real2 v479 = plus(v21, v85); + real2 v753 = reverse(minus(v479, v480)); + real2 v759 = plus(v479, v480); + real2 v755 = minusplus(v753, v754); + real2 v757 = minusplus(uminus(v753), v754); + real2 v767 = ctimesminusplus(reverse(v757), ctbl[17], ctimes(v757, ctbl[27])); + real2 v763 = ctimesminusplus(reverse(v755), ctbl[23], ctimes(v755, ctbl[21])); + real2 v1411 = minus(v891, v763); + real2 v1415 = plus(v763, v891); + real2 v1014 = plus(v758, v759); + real2 v1010 = minus(v759, v758); + real2 v1011 = minusplus(v1009, v1010); + real2 v1013 = minusplus(uminus(v1009), v1010); + real2 v1023 = ctimesminusplus(reverse(v1013), ctbl[13], ctimes(v1013, ctbl[12])); + real2 v1570 = minus(v895, v767); + real2 v1574 = plus(v767, v895); + real2 v1142 = plus(v1014, v1015); + real2 v1138 = minus(v1015, v1014); + real2 v478 = minusplus(uminus(v474), v475); + real2 v476 = minusplus(v474, v475); + real2 v484 = ctimesminusplus(reverse(v476), ctbl[49], ctimes(v476, ctbl[43])); + real2 v1733 = plus(v197, v484); + real2 v1729 = minus(v484, v197); + real2 v1861 = plus(v1733, v1734); + real2 v1857 = minus(v1734, v1733); + real2 v1730 = minusplus(v1728, v1729); + real2 v1732 = minusplus(uminus(v1728), v1729); + real2 v1738 = ctimesminusplus(reverse(v1730), ctbl[11], ctimes(v1730, ctbl[9])); + real2 v489 = ctimesminusplus(reverse(v478), ctbl[55], ctimes(v478, ctbl[54])); + real2 v1742 = ctimesminusplus(reverse(v1732), ctbl[13], ctimes(v1732, ctbl[12])); + real2 v1019 = ctimesminusplus(reverse(v1011), ctbl[11], ctimes(v1011, ctbl[9])); + real2 v2134 = plus(v203, v489); + real2 v2130 = minus(v489, v203); + real2 v2262 = plus(v2134, v2135); + real2 v2258 = minus(v2135, v2134); + real2 v105 = load(in, 103 << shift); + real2 v41 = load(in, 39 << shift); + real2 v269 = plus(v41, v105); + real2 v263 = reverse(minus(v41, v105)); + real2 v9 = load(in, 7 << shift); + real2 v73 = load(in, 71 << shift); + real2 v264 = minus(v73, v9); + real2 v268 = plus(v9, v73); + real2 v822 = plus(v268, v269); + real2 v818 = minus(v269, v268); + real2 v265 = minusplus(v263, v264); + real2 v267 = minusplus(uminus(v263), v264); + real2 v275 = ctimesminusplus(reverse(v265), ctbl[55], ctimes(v265, ctbl[37])); + real2 v281 = ctimesminusplus(reverse(v267), ctbl[41], ctimes(v267, ctbl[51])); + real2 v121 = load(in, 119 << shift); + real2 v57 = load(in, 55 << shift); + real2 v549 = plus(v57, v121); + real2 v543 = reverse(minus(v57, v121)); + real2 v25 = load(in, 23 << shift); + real2 v89 = load(in, 87 << shift); + real2 v544 = minus(v89, v25); + real2 v548 = plus(v25, v89); + real2 v817 = reverse(minus(v548, v549)); + real2 v823 = plus(v548, v549); + real2 v819 = minusplus(v817, v818); + real2 v821 = minusplus(uminus(v817), v818); + real2 v547 = minusplus(uminus(v543), v544); + real2 v545 = minusplus(v543, v544); + real2 v553 = ctimesminusplus(reverse(v545), ctbl[57], ctimes(v545, ctbl[35])); + real2 v827 = ctimesminusplus(reverse(v819), ctbl[27], ctimes(v819, ctbl[17])); + real2 v831 = ctimesminusplus(reverse(v821), ctbl[25], ctimes(v821, ctbl[24])); + real2 v559 = ctimesminusplus(reverse(v547), ctbl[52], ctimes(v547, ctbl[38])); + real2 v2198 = plus(v281, v559); + real2 v2194 = minus(v559, v281); + real2 v1793 = minus(v553, v275); + real2 v1797 = plus(v275, v553); + real2 v1078 = plus(v822, v823); + real2 v1074 = minus(v823, v822); + real2 v129 = load(in, 127 << shift); + real2 v65 = load(in, 63 << shift); + real2 v693 = plus(v65, v129); + real2 v687 = reverse(minus(v65, v129)); + real2 v33 = load(in, 31 << shift); + real2 v97 = load(in, 95 << shift); + real2 v692 = plus(v33, v97); + real2 v688 = minus(v97, v33); + real2 v691 = minusplus(uminus(v687), v688); + real2 v689 = minusplus(v687, v688); + real2 v945 = reverse(minus(v692, v693)); + real2 v951 = plus(v692, v693); + real2 v697 = ctimesminusplus(reverse(v689), ctbl[61], ctimes(v689, ctbl[31])); + real2 v703 = ctimesminusplus(reverse(v691), ctbl[46], ctimes(v691, ctbl[44])); + real2 v81 = load(in, 79 << shift); + real2 v17 = load(in, 15 << shift); + real2 v406 = minus(v81, v17); + real2 v410 = plus(v17, v81); + real2 v49 = load(in, 47 << shift); + real2 v113 = load(in, 111 << shift); + real2 v405 = reverse(minus(v49, v113)); + real2 v411 = plus(v49, v113); + real2 v407 = minusplus(v405, v406); + real2 v409 = minusplus(uminus(v405), v406); + real2 v415 = ctimesminusplus(reverse(v407), ctbl[59], ctimes(v407, ctbl[33])); + real2 v1798 = plus(v415, v697); + real2 v1792 = reverse(minus(v415, v697)); + real2 v950 = plus(v410, v411); + real2 v946 = minus(v411, v410); + real2 v949 = minusplus(uminus(v945), v946); + real2 v947 = minusplus(v945, v946); + real2 v1073 = reverse(minus(v950, v951)); + real2 v1079 = plus(v950, v951); + real2 v955 = ctimesminusplus(reverse(v947), ctbl[29], ctimes(v947, ctbl[15])); + real2 v1410 = reverse(minus(v827, v955)); + real2 v1416 = plus(v827, v955); + real2 v1448 = plus(v1415, v1416); + real2 v1442 = reverse(minus(v1415, v1416)); + real2 v1412 = minusplus(v1410, v1411); + real2 v1414 = minusplus(uminus(v1410), v1411); + real2 v1424 = ctimesminusplus(reverse(v1414), ctbl[4], ctimes(v1414, ctbl[2])); + real2 v1077 = minusplus(uminus(v1073), v1074); + real2 v1075 = minusplus(v1073, v1074); + real2 v1087 = ctimesminusplus(reverse(v1077), ctbl[10], ctimes(v1077, ctbl[8])); + real2 v1327 = plus(v1023, v1087); + real2 v1321 = reverse(minus(v1023, v1087)); + real2 v1137 = reverse(minus(v1078, v1079)); + real2 v1143 = plus(v1078, v1079); + real2 v1169 = reverse(minus(v1142, v1143)); + real2 v1175 = plus(v1142, v1143); + real2 v1083 = ctimesminusplus(reverse(v1075), ctbl[13], ctimes(v1075, ctbl[7])); + real2 v1796 = minusplus(uminus(v1792), v1793); + real2 v1794 = minusplus(v1792, v1793); + real2 v1806 = ctimesminusplus(reverse(v1796), ctbl[10], ctimes(v1796, ctbl[8])); + real2 v2046 = plus(v1742, v1806); + real2 v2040 = reverse(minus(v1742, v1806)); + real2 v1270 = plus(v1019, v1083); + real2 v1264 = reverse(minus(v1019, v1083)); + real2 v959 = ctimesminusplus(reverse(v949), ctbl[22], ctimes(v949, ctbl[20])); + real2 v1139 = minusplus(v1137, v1138); + real2 v1141 = minusplus(uminus(v1137), v1138); + real2 v1151 = ctimesminusplus(reverse(v1141), ctbl[4], ctimes(v1141, ctbl[2])); + real2 v1420 = ctimesminusplus(reverse(v1412), ctbl[5], ctimes(v1412, ctbl[3])); + real2 v1569 = reverse(minus(v831, v959)); + real2 v1575 = plus(v831, v959); + real2 v1607 = plus(v1574, v1575); + real2 v1601 = reverse(minus(v1574, v1575)); + real2 v1856 = reverse(minus(v1797, v1798)); + real2 v1862 = plus(v1797, v1798); + real2 v1888 = reverse(minus(v1861, v1862)); + real2 v1894 = plus(v1861, v1862); + real2 v1147 = ctimesminusplus(reverse(v1139), ctbl[5], ctimes(v1139, ctbl[3])); + real2 v1571 = minusplus(v1569, v1570); + real2 v1573 = minusplus(uminus(v1569), v1570); + real2 v1583 = ctimesminusplus(reverse(v1573), ctbl[4], ctimes(v1573, ctbl[2])); + real2 v1858 = minusplus(v1856, v1857); + real2 v1860 = minusplus(uminus(v1856), v1857); + real2 v1870 = ctimesminusplus(reverse(v1860), ctbl[4], ctimes(v1860, ctbl[2])); + real2 v1579 = ctimesminusplus(reverse(v1571), ctbl[5], ctimes(v1571, ctbl[3])); + real2 v1802 = ctimesminusplus(reverse(v1794), ctbl[13], ctimes(v1794, ctbl[7])); + real2 v1989 = plus(v1738, v1802); + real2 v1983 = reverse(minus(v1738, v1802)); + real2 v1866 = ctimesminusplus(reverse(v1858), ctbl[5], ctimes(v1858, ctbl[3])); + real2 v23 = load(in, 21 << shift); + real2 v87 = load(in, 85 << shift); + real2 v513 = plus(v23, v87); + real2 v509 = minus(v87, v23); + real2 v55 = load(in, 53 << shift); + real2 v119 = load(in, 117 << shift); + real2 v514 = plus(v55, v119); + real2 v508 = reverse(minus(v55, v119)); + real2 v791 = plus(v513, v514); + real2 v785 = reverse(minus(v513, v514)); + real2 v512 = minusplus(uminus(v508), v509); + real2 v510 = minusplus(v508, v509); + real2 v518 = ctimesminusplus(reverse(v510), ctbl[41], ctimes(v510, ctbl[51])); + real2 v71 = load(in, 69 << shift); + real2 v7 = load(in, 5 << shift); + real2 v230 = plus(v7, v71); + real2 v226 = minus(v71, v7); + real2 v103 = load(in, 101 << shift); + real2 v39 = load(in, 37 << shift); + real2 v225 = reverse(minus(v39, v103)); + real2 v231 = plus(v39, v103); + real2 v790 = plus(v230, v231); + real2 v786 = minus(v231, v230); + real2 v1042 = minus(v791, v790); + real2 v1046 = plus(v790, v791); + real2 v787 = minusplus(v785, v786); + real2 v789 = minusplus(uminus(v785), v786); + real2 v229 = minusplus(uminus(v225), v226); + real2 v227 = minusplus(v225, v226); + real2 v237 = ctimesminusplus(reverse(v227), ctbl[39], ctimes(v227, ctbl[53])); + real2 v1761 = minus(v518, v237); + real2 v1765 = plus(v237, v518); + real2 v795 = ctimesminusplus(reverse(v787), ctbl[19], ctimes(v787, ctbl[25])); + real2 v799 = ctimesminusplus(reverse(v789), ctbl[29], ctimes(v789, ctbl[15])); + real2 v127 = load(in, 125 << shift); + real2 v63 = load(in, 61 << shift); + real2 v657 = plus(v63, v127); + real2 v651 = reverse(minus(v63, v127)); + real2 v31 = load(in, 29 << shift); + real2 v95 = load(in, 93 << shift); + real2 v652 = minus(v95, v31); + real2 v656 = plus(v31, v95); + real2 v913 = reverse(minus(v656, v657)); + real2 v919 = plus(v656, v657); + real2 v655 = minusplus(uminus(v651), v652); + real2 v653 = minusplus(v651, v652); + real2 v661 = ctimesminusplus(reverse(v653), ctbl[45], ctimes(v653, ctbl[47])); + real2 v111 = load(in, 109 << shift); + real2 v47 = load(in, 45 << shift); + real2 v375 = plus(v47, v111); + real2 v369 = reverse(minus(v47, v111)); + real2 v79 = load(in, 77 << shift); + real2 v15 = load(in, 13 << shift); + real2 v370 = minus(v79, v15); + real2 v374 = plus(v15, v79); + real2 v914 = minus(v375, v374); + real2 v918 = plus(v374, v375); + real2 v371 = minusplus(v369, v370); + real2 v373 = minusplus(uminus(v369), v370); + real2 v915 = minusplus(v913, v914); + real2 v917 = minusplus(uminus(v913), v914); + real2 v927 = ctimesminusplus(reverse(v917), ctbl[16], ctimes(v917, ctbl[26])); + real2 v381 = ctimesminusplus(reverse(v371), ctbl[43], ctimes(v371, ctbl[49])); + real2 v1041 = reverse(minus(v918, v919)); + real2 v1047 = plus(v918, v919); + real2 v1766 = plus(v381, v661); + real2 v1760 = reverse(minus(v381, v661)); + real2 v1762 = minusplus(v1760, v1761); + real2 v1764 = minusplus(uminus(v1760), v1761); + real2 v1824 = reverse(minus(v1765, v1766)); + real2 v1830 = plus(v1765, v1766); + real2 v923 = ctimesminusplus(reverse(v915), ctbl[21], ctimes(v915, ctbl[23])); + real2 v1378 = reverse(minus(v795, v923)); + real2 v1384 = plus(v795, v923); + real2 v1045 = minusplus(uminus(v1041), v1042); + real2 v1043 = minusplus(v1041, v1042); + real2 v1051 = ctimesminusplus(reverse(v1043), ctbl[9], ctimes(v1043, ctbl[11])); + real2 v1537 = reverse(minus(v799, v927)); + real2 v1543 = plus(v799, v927); + real2 v1055 = ctimesminusplus(reverse(v1045), ctbl[7], ctimes(v1045, ctbl[6])); + real2 v1111 = plus(v1046, v1047); + real2 v1105 = reverse(minus(v1046, v1047)); + real2 v115 = load(in, 113 << shift); + real2 v51 = load(in, 49 << shift); + real2 v440 = reverse(minus(v51, v115)); + real2 v446 = plus(v51, v115); + real2 v19 = load(in, 17 << shift); + real2 v83 = load(in, 81 << shift); + real2 v441 = minus(v83, v19); + real2 v445 = plus(v19, v83); + real2 v727 = plus(v445, v446); + real2 v721 = reverse(minus(v445, v446)); + real2 v442 = minusplus(v440, v441); + real2 v444 = minusplus(uminus(v440), v441); + real2 v450 = ctimesminusplus(reverse(v442), ctbl[33], ctimes(v442, ctbl[59])); + real2 v67 = load(in, 65 << shift); + real2 v3 = load(in, 1 << shift); + real2 v148 = minus(v67, v3); + real2 v152 = plus(v3, v67); + real2 v99 = load(in, 97 << shift); + real2 v35 = load(in, 33 << shift); + real2 v147 = reverse(minus(v35, v99)); + real2 v153 = plus(v35, v99); + real2 v726 = plus(v152, v153); + real2 v722 = minus(v153, v152); + real2 v723 = minusplus(v721, v722); + real2 v725 = minusplus(uminus(v721), v722); + real2 v731 = ctimesminusplus(reverse(v723), ctbl[15], ctimes(v723, ctbl[29])); + real2 v735 = ctimesminusplus(reverse(v725), ctbl[23], ctimes(v725, ctbl[21])); + real2 v149 = minusplus(v147, v148); + real2 v151 = minusplus(uminus(v147), v148); + real2 v978 = minus(v727, v726); + real2 v982 = plus(v726, v727); + real2 v159 = ctimesminusplus(reverse(v149), ctbl[31], ctimes(v149, ctbl[61])); + real2 v1701 = plus(v159, v450); + real2 v1697 = minus(v450, v159); + real2 v91 = load(in, 89 << shift); + real2 v27 = load(in, 25 << shift); + real2 v584 = plus(v27, v91); + real2 v580 = minus(v91, v27); + real2 v59 = load(in, 57 << shift); + real2 v123 = load(in, 121 << shift); + real2 v579 = reverse(minus(v59, v123)); + real2 v585 = plus(v59, v123); + real2 v583 = minusplus(uminus(v579), v580); + real2 v581 = minusplus(v579, v580); + real2 v589 = ctimesminusplus(reverse(v581), ctbl[37], ctimes(v581, ctbl[55])); + real2 v855 = plus(v584, v585); + real2 v849 = reverse(minus(v584, v585)); + real2 v11 = load(in, 9 << shift); + real2 v75 = load(in, 73 << shift); + real2 v302 = minus(v75, v11); + real2 v306 = plus(v11, v75); + real2 v107 = load(in, 105 << shift); + real2 v43 = load(in, 41 << shift); + real2 v307 = plus(v43, v107); + real2 v301 = reverse(minus(v43, v107)); + real2 v854 = plus(v306, v307); + real2 v850 = minus(v307, v306); + real2 v851 = minusplus(v849, v850); + real2 v853 = minusplus(uminus(v849), v850); + real2 v863 = ctimesminusplus(reverse(v853), ctbl[19], ctimes(v853, ctbl[18])); + real2 v305 = minusplus(uminus(v301), v302); + real2 v303 = minusplus(v301, v302); + real2 v1538 = minus(v863, v735); + real2 v1542 = plus(v735, v863); + real2 v859 = ctimesminusplus(reverse(v851), ctbl[17], ctimes(v851, ctbl[27])); + real2 v1379 = minus(v859, v731); + real2 v1383 = plus(v731, v859); + real2 v1443 = minus(v1384, v1383); + real2 v1447 = plus(v1383, v1384); + real2 v1446 = minusplus(uminus(v1442), v1443); + real2 v1444 = minusplus(v1442, v1443); + real2 v983 = plus(v854, v855); + real2 v977 = reverse(minus(v854, v855)); + real2 v979 = minusplus(v977, v978); + real2 v981 = minusplus(uminus(v977), v978); + real2 v1456 = ctimesminusplus(reverse(v1446), ctbl[1], ctimes(v1446, ctbl[0])); + real2 v311 = ctimesminusplus(reverse(v303), ctbl[35], ctimes(v303, ctbl[57])); + real2 v1696 = reverse(minus(v311, v589)); + real2 v1702 = plus(v311, v589); + real2 v1452 = ctimesminusplus(reverse(v1444), ctbl[1], ctimes(v1444, ctbl[1])); + real2 v987 = ctimesminusplus(reverse(v979), ctbl[7], ctimes(v979, ctbl[13])); + real2 v1265 = minus(v1051, v987); + real2 v1269 = plus(v987, v1051); + real2 v1266 = minusplus(v1264, v1265); + real2 v1268 = minusplus(uminus(v1264), v1265); + real2 v1278 = ctimesminusplus(reverse(v1268), ctbl[1], ctimes(v1268, ctbl[0])); + real2 v1286 = plus(v1269, v1270); + real2 v1280 = reverse(minus(v1269, v1270)); + real2 v1110 = plus(v982, v983); + real2 v1106 = minus(v983, v982); + real2 v1174 = plus(v1110, v1111); + real2 v1170 = minus(v1111, v1110); + real2 v1185 = reverse(minus(v1174, v1175)); + real2 v1191 = plus(v1174, v1175); + real2 v1171 = minusplus(v1169, v1170); + real2 v1173 = minusplus(uminus(v1169), v1170); + real2 v1179 = ctimesminusplus(reverse(v1171), ctbl[1], ctimes(v1171, ctbl[1])); + real2 v1183 = ctimesminusplus(reverse(v1173), ctbl[1], ctimes(v1173, ctbl[0])); + real2 v991 = ctimesminusplus(reverse(v981), ctbl[11], ctimes(v981, ctbl[9])); + real2 v1322 = minus(v1055, v991); + real2 v1326 = plus(v991, v1055); + real2 v1337 = reverse(minus(v1326, v1327)); + real2 v1343 = plus(v1326, v1327); + real2 v1323 = minusplus(v1321, v1322); + real2 v1325 = minusplus(uminus(v1321), v1322); + real2 v1335 = ctimesminusplus(reverse(v1325), ctbl[1], ctimes(v1325, ctbl[0])); + real2 v1109 = minusplus(uminus(v1105), v1106); + real2 v1107 = minusplus(v1105, v1106); + real2 v1115 = ctimesminusplus(reverse(v1107), ctbl[3], ctimes(v1107, ctbl[5])); + real2 v1274 = ctimesminusplus(reverse(v1266), ctbl[1], ctimes(v1266, ctbl[1])); + real2 v1606 = plus(v1542, v1543); + real2 v1602 = minus(v1543, v1542); + real2 v1216 = plus(v1115, v1147); + real2 v1210 = reverse(minus(v1115, v1147)); + real2 v1331 = ctimesminusplus(reverse(v1323), ctbl[1], ctimes(v1323, ctbl[1])); + real2 v1119 = ctimesminusplus(reverse(v1109), ctbl[5], ctimes(v1109, ctbl[3])); + real2 v1464 = plus(v1447, v1448); + real2 v1458 = reverse(minus(v1447, v1448)); + real2 v1382 = minusplus(uminus(v1378), v1379); + real2 v1380 = minusplus(v1378, v1379); + real2 v1388 = ctimesminusplus(reverse(v1380), ctbl[3], ctimes(v1380, ctbl[5])); + real2 v1392 = ctimesminusplus(reverse(v1382), ctbl[5], ctimes(v1382, ctbl[3])); + real2 v1508 = plus(v1392, v1424); + real2 v1502 = reverse(minus(v1392, v1424)); + real2 v1489 = plus(v1388, v1420); + real2 v1483 = reverse(minus(v1388, v1420)); + real2 v1603 = minusplus(v1601, v1602); + real2 v1605 = minusplus(uminus(v1601), v1602); + real2 v1615 = ctimesminusplus(reverse(v1605), ctbl[1], ctimes(v1605, ctbl[0])); + real2 v1611 = ctimesminusplus(reverse(v1603), ctbl[1], ctimes(v1603, ctbl[1])); + real2 v1617 = reverse(minus(v1606, v1607)); + real2 v1623 = plus(v1606, v1607); + real2 v1541 = minusplus(uminus(v1537), v1538); + real2 v1539 = minusplus(v1537, v1538); + real2 v1547 = ctimesminusplus(reverse(v1539), ctbl[3], ctimes(v1539, ctbl[5])); + real2 v1551 = ctimesminusplus(reverse(v1541), ctbl[5], ctimes(v1541, ctbl[3])); + real2 v1667 = plus(v1551, v1583); + real2 v1661 = reverse(minus(v1551, v1583)); + real2 v1648 = plus(v1547, v1579); + real2 v1642 = reverse(minus(v1547, v1579)); + real2 v1229 = reverse(minus(v1119, v1151)); + real2 v1235 = plus(v1119, v1151); + real2 v76 = load(in, 74 << shift); + real2 v12 = load(in, 10 << shift); + real2 v322 = plus(v12, v76); + real2 v318 = minus(v76, v12); + real2 v44 = load(in, 42 << shift); + real2 v108 = load(in, 106 << shift); + real2 v323 = plus(v44, v108); + real2 v317 = reverse(minus(v44, v108)); + real2 v866 = minus(v323, v322); + real2 v870 = plus(v322, v323); + real2 v92 = load(in, 90 << shift); + real2 v28 = load(in, 26 << shift); + real2 v602 = plus(v28, v92); + real2 v598 = minus(v92, v28); + real2 v60 = load(in, 58 << shift); + real2 v124 = load(in, 122 << shift); + real2 v603 = plus(v60, v124); + real2 v597 = reverse(minus(v60, v124)); + real2 v865 = reverse(minus(v602, v603)); + real2 v871 = plus(v602, v603); + real2 v869 = minusplus(uminus(v865), v866); + real2 v867 = minusplus(v865, v866); + real2 v879 = ctimesminusplus(reverse(v869), ctbl[7], ctimes(v869, ctbl[6])); + real2 v993 = reverse(minus(v870, v871)); + real2 v999 = plus(v870, v871); + real2 v875 = ctimesminusplus(reverse(v867), ctbl[9], ctimes(v867, ctbl[11])); + real2 v100 = load(in, 98 << shift); + real2 v36 = load(in, 34 << shift); + real2 v167 = reverse(minus(v36, v100)); + real2 v173 = plus(v36, v100); + real2 v4 = load(in, 2 << shift); + real2 v68 = load(in, 66 << shift); + real2 v168 = minus(v68, v4); + real2 v172 = plus(v4, v68); + real2 v742 = plus(v172, v173); + real2 v738 = minus(v173, v172); + real2 v84 = load(in, 82 << shift); + real2 v20 = load(in, 18 << shift); + real2 v462 = plus(v20, v84); + real2 v458 = minus(v84, v20); + real2 v116 = load(in, 114 << shift); + real2 v52 = load(in, 50 << shift); + real2 v463 = plus(v52, v116); + real2 v457 = reverse(minus(v52, v116)); + real2 v737 = reverse(minus(v462, v463)); + real2 v743 = plus(v462, v463); + real2 v998 = plus(v742, v743); + real2 v994 = minus(v743, v742); + real2 v739 = minusplus(v737, v738); + real2 v741 = minusplus(uminus(v737), v738); + real2 v995 = minusplus(v993, v994); + real2 v997 = minusplus(uminus(v993), v994); + real2 v1007 = ctimesminusplus(reverse(v997), ctbl[5], ctimes(v997, ctbl[3])); + real2 v747 = ctimesminusplus(reverse(v739), ctbl[7], ctimes(v739, ctbl[13])); + real2 v1395 = minus(v875, v747); + real2 v1399 = plus(v747, v875); + real2 v1003 = ctimesminusplus(reverse(v995), ctbl[3], ctimes(v995, ctbl[5])); + real2 v1122 = minus(v999, v998); + real2 v1126 = plus(v998, v999); + real2 v72 = load(in, 70 << shift); + real2 v8 = load(in, 6 << shift); + real2 v246 = minus(v72, v8); + real2 v250 = plus(v8, v72); + real2 v104 = load(in, 102 << shift); + real2 v40 = load(in, 38 << shift); + real2 v245 = reverse(minus(v40, v104)); + real2 v251 = plus(v40, v104); + real2 v802 = minus(v251, v250); + real2 v806 = plus(v250, v251); + real2 v24 = load(in, 22 << shift); + real2 v88 = load(in, 86 << shift); + real2 v530 = plus(v24, v88); + real2 v526 = minus(v88, v24); + real2 v120 = load(in, 118 << shift); + real2 v56 = load(in, 54 << shift); + real2 v531 = plus(v56, v120); + real2 v525 = reverse(minus(v56, v120)); + real2 v801 = reverse(minus(v530, v531)); + real2 v807 = plus(v530, v531); + real2 v1058 = minus(v807, v806); + real2 v1062 = plus(v806, v807); + real2 v803 = minusplus(v801, v802); + real2 v805 = minusplus(uminus(v801), v802); + real2 v811 = ctimesminusplus(reverse(v803), ctbl[11], ctimes(v803, ctbl[9])); + real2 v128 = load(in, 126 << shift); + real2 v64 = load(in, 62 << shift); + real2 v669 = reverse(minus(v64, v128)); + real2 v675 = plus(v64, v128); + real2 v32 = load(in, 30 << shift); + real2 v96 = load(in, 94 << shift); + real2 v674 = plus(v32, v96); + real2 v670 = minus(v96, v32); + real2 v935 = plus(v674, v675); + real2 v929 = reverse(minus(v674, v675)); + real2 v80 = load(in, 78 << shift); + real2 v16 = load(in, 14 << shift); + real2 v389 = minus(v80, v16); + real2 v393 = plus(v16, v80); + real2 v112 = load(in, 110 << shift); + real2 v48 = load(in, 46 << shift); + real2 v394 = plus(v48, v112); + real2 v388 = reverse(minus(v48, v112)); + real2 v930 = minus(v394, v393); + real2 v934 = plus(v393, v394); + real2 v1063 = plus(v934, v935); + real2 v1057 = reverse(minus(v934, v935)); + real2 v1059 = minusplus(v1057, v1058); + real2 v1061 = minusplus(uminus(v1057), v1058); + real2 v1127 = plus(v1062, v1063); + real2 v1121 = reverse(minus(v1062, v1063)); + real2 v1123 = minusplus(v1121, v1122); + real2 v1125 = minusplus(uminus(v1121), v1122); + real2 v1135 = ctimesminusplus(reverse(v1125), ctbl[1], ctimes(v1125, ctbl[0])); + real2 v1071 = ctimesminusplus(reverse(v1061), ctbl[4], ctimes(v1061, ctbl[2])); + real2 v1311 = plus(v1007, v1071); + real2 v1305 = reverse(minus(v1007, v1071)); + real2 v1131 = ctimesminusplus(reverse(v1123), ctbl[1], ctimes(v1123, ctbl[1])); + real2 v1153 = reverse(minus(v1126, v1127)); + real2 v1159 = plus(v1126, v1127); + real2 v1067 = ctimesminusplus(reverse(v1059), ctbl[5], ctimes(v1059, ctbl[3])); + real2 v1248 = reverse(minus(v1003, v1067)); + real2 v1254 = plus(v1003, v1067); + real2 v94 = load(in, 92 << shift); + real2 v30 = load(in, 28 << shift); + real2 v634 = minus(v94, v30); + real2 v638 = plus(v30, v94); + real2 v126 = load(in, 124 << shift); + real2 v62 = load(in, 60 << shift); + real2 v633 = reverse(minus(v62, v126)); + real2 v639 = plus(v62, v126); + real2 v897 = reverse(minus(v638, v639)); + real2 v903 = plus(v638, v639); + real2 v42 = load(in, 40 << shift); + real2 v106 = load(in, 104 << shift); + real2 v283 = reverse(minus(v42, v106)); + real2 v289 = plus(v42, v106); + real2 v10 = load(in, 8 << shift); + real2 v74 = load(in, 72 << shift); + real2 v284 = minus(v74, v10); + real2 v288 = plus(v10, v74); + real2 v838 = plus(v288, v289); + real2 v834 = minus(v289, v288); + real2 v26 = load(in, 24 << shift); + real2 v90 = load(in, 88 << shift); + real2 v562 = minus(v90, v26); + real2 v566 = plus(v26, v90); + real2 v122 = load(in, 120 << shift); + real2 v58 = load(in, 56 << shift); + real2 v567 = plus(v58, v122); + real2 v561 = reverse(minus(v58, v122)); + real2 v833 = reverse(minus(v566, v567)); + real2 v839 = plus(v566, v567); + real2 v967 = plus(v838, v839); + real2 v961 = reverse(minus(v838, v839)); + real2 v14 = load(in, 12 << shift); + real2 v78 = load(in, 76 << shift); + real2 v353 = minus(v78, v14); + real2 v357 = plus(v14, v78); + real2 v46 = load(in, 44 << shift); + real2 v110 = load(in, 108 << shift); + real2 v358 = plus(v46, v110); + real2 v352 = reverse(minus(v46, v110)); + real2 v898 = minus(v358, v357); + real2 v902 = plus(v357, v358); + real2 v1025 = reverse(minus(v902, v903)); + real2 v1031 = plus(v902, v903); + real2 v114 = load(in, 112 << shift); + real2 v50 = load(in, 48 << shift); + real2 v422 = reverse(minus(v50, v114)); + real2 v428 = plus(v50, v114); + real2 v2 = load(in, 0 << shift); + real2 v66 = load(in, 64 << shift); + real2 v132 = minus(v66, v2); + real2 v136 = plus(v2, v66); + real2 v98 = load(in, 96 << shift); + real2 v34 = load(in, 32 << shift); + real2 v137 = plus(v34, v98); + real2 v131 = reverse(minus(v34, v98)); + real2 v706 = minus(v137, v136); + real2 v710 = plus(v136, v137); + real2 v18 = load(in, 16 << shift); + real2 v82 = load(in, 80 << shift); + real2 v427 = plus(v18, v82); + real2 v423 = minus(v82, v18); + real2 v705 = reverse(minus(v427, v428)); + real2 v711 = plus(v427, v428); + real2 v966 = plus(v710, v711); + real2 v962 = minus(v711, v710); + real2 v1090 = minus(v967, v966); + real2 v1094 = plus(v966, v967); + real2 v70 = load(in, 68 << shift); + real2 v6 = load(in, 4 << shift); + real2 v210 = plus(v6, v70); + real2 v206 = minus(v70, v6); + real2 v38 = load(in, 36 << shift); + real2 v102 = load(in, 100 << shift); + real2 v211 = plus(v38, v102); + real2 v205 = reverse(minus(v38, v102)); + real2 v774 = plus(v210, v211); + real2 v770 = minus(v211, v210); + real2 v22 = load(in, 20 << shift); + real2 v86 = load(in, 84 << shift); + real2 v492 = minus(v86, v22); + real2 v496 = plus(v22, v86); + real2 v118 = load(in, 116 << shift); + real2 v54 = load(in, 52 << shift); + real2 v497 = plus(v54, v118); + real2 v491 = reverse(minus(v54, v118)); + real2 v775 = plus(v496, v497); + real2 v769 = reverse(minus(v496, v497)); + real2 v1030 = plus(v774, v775); + real2 v1026 = minus(v775, v774); + real2 v1095 = plus(v1030, v1031); + real2 v1089 = reverse(minus(v1030, v1031)); + real2 v1103 = minus(uminusplus(v1089), v1090); + real2 v1099 = minus(uplusminus(v1089), v1090); + real2 v1230 = minus(v1135, v1103); + store(out, 56 << shift, minus(uplusminus(v1229), v1230)); + store(out, 120 << shift, minus(uminusplus(v1229), v1230)); + real2 v1234 = plus(v1103, v1135); + store(out, 24 << shift, plus(v1234, v1235)); + store(out, 88 << shift, minus(v1234, v1235)); + real2 v1211 = minus(v1131, v1099); + real2 v1215 = plus(v1099, v1131); + store(out, 8 << shift, plus(v1215, v1216)); + store(out, 72 << shift, minus(v1215, v1216)); + store(out, 40 << shift, minus(uplusminus(v1210), v1211)); + store(out, 104 << shift, minus(uminusplus(v1210), v1211)); + real2 v1158 = plus(v1094, v1095); + real2 v1154 = minus(v1095, v1094); + real2 v1186 = minus(v1159, v1158); + store(out, 32 << shift, minus(uplusminus(v1185), v1186)); + store(out, 96 << shift, minus(uminusplus(v1185), v1186)); + real2 v1190 = plus(v1158, v1159); + store(out, 64 << shift, minus(v1190, v1191)); + store(out, 0 << shift, plus(v1190, v1191)); + real2 v1163 = minus(uplusminus(v1153), v1154); + store(out, 16 << shift, plus(v1163, v1179)); + store(out, 80 << shift, minus(v1163, v1179)); + real2 v1167 = minus(uminusplus(v1153), v1154); + store(out, 112 << shift, minus(v1167, v1183)); + store(out, 48 << shift, plus(v1167, v1183)); + real2 v971 = minus(uplusminus(v961), v962); + real2 v975 = minus(uminusplus(v961), v962); + real2 v1027 = minusplus(v1025, v1026); + real2 v1029 = minusplus(uminus(v1025), v1026); + real2 v1039 = ctimesminusplus(reverse(v1029), ctbl[1], ctimes(v1029, ctbl[0])); + real2 v1306 = minus(v1039, v975); + real2 v1310 = plus(v975, v1039); + real2 v1319 = minus(uminusplus(v1305), v1306); + real2 v1315 = minus(uplusminus(v1305), v1306); + store(out, 124 << shift, minus(v1319, v1335)); + store(out, 60 << shift, plus(v1319, v1335)); + store(out, 28 << shift, plus(v1315, v1331)); + store(out, 92 << shift, minus(v1315, v1331)); + real2 v1342 = plus(v1310, v1311); + store(out, 76 << shift, minus(v1342, v1343)); + store(out, 12 << shift, plus(v1342, v1343)); + real2 v1338 = minus(v1311, v1310); + store(out, 44 << shift, minus(uplusminus(v1337), v1338)); + store(out, 108 << shift, minus(uminusplus(v1337), v1338)); + real2 v1035 = ctimesminusplus(reverse(v1027), ctbl[1], ctimes(v1027, ctbl[1])); + real2 v1249 = minus(v1035, v971); + real2 v1253 = plus(v971, v1035); + real2 v1262 = minus(uminusplus(v1248), v1249); + real2 v1258 = minus(uplusminus(v1248), v1249); + store(out, 84 << shift, minus(v1258, v1274)); + store(out, 20 << shift, plus(v1258, v1274)); + store(out, 52 << shift, plus(v1262, v1278)); + store(out, 116 << shift, minus(v1262, v1278)); + real2 v1281 = minus(v1254, v1253); + real2 v1285 = plus(v1253, v1254); + store(out, 68 << shift, minus(v1285, v1286)); + store(out, 4 << shift, plus(v1285, v1286)); + store(out, 100 << shift, minus(uminusplus(v1280), v1281)); + store(out, 36 << shift, minus(uplusminus(v1280), v1281)); + real2 v835 = minusplus(v833, v834); + real2 v837 = minusplus(uminus(v833), v834); + real2 v843 = ctimesminusplus(reverse(v835), ctbl[1], ctimes(v835, ctbl[1])); + real2 v773 = minusplus(uminus(v769), v770); + real2 v771 = minusplus(v769, v770); + real2 v779 = ctimesminusplus(reverse(v771), ctbl[3], ctimes(v771, ctbl[5])); + real2 v901 = minusplus(uminus(v897), v898); + real2 v899 = minusplus(v897, v898); + real2 v907 = ctimesminusplus(reverse(v899), ctbl[5], ctimes(v899, ctbl[3])); + real2 v719 = minus(uminusplus(v705), v706); + real2 v715 = minus(uplusminus(v705), v706); + real2 v933 = minusplus(uminus(v929), v930); + real2 v931 = minusplus(v929, v930); + real2 v939 = ctimesminusplus(reverse(v931), ctbl[13], ctimes(v931, ctbl[7])); + real2 v1394 = reverse(minus(v811, v939)); + real2 v1400 = plus(v811, v939); + real2 v1426 = reverse(minus(v1399, v1400)); + real2 v1432 = plus(v1399, v1400); + real2 v1367 = plus(v715, v843); + real2 v1363 = minus(v843, v715); + real2 v1368 = plus(v779, v907); + real2 v1362 = reverse(minus(v779, v907)); + real2 v1427 = minus(v1368, v1367); + real2 v1431 = plus(v1367, v1368); + real2 v1440 = minus(uminusplus(v1426), v1427); + real2 v1436 = minus(uplusminus(v1426), v1427); + store(out, 18 << shift, plus(v1436, v1452)); + store(out, 82 << shift, minus(v1436, v1452)); + store(out, 114 << shift, minus(v1440, v1456)); + store(out, 50 << shift, plus(v1440, v1456)); + real2 v1459 = minus(v1432, v1431); + store(out, 98 << shift, minus(uminusplus(v1458), v1459)); + store(out, 34 << shift, minus(uplusminus(v1458), v1459)); + real2 v1463 = plus(v1431, v1432); + store(out, 2 << shift, plus(v1463, v1464)); + store(out, 66 << shift, minus(v1463, v1464)); + real2 v1372 = minus(uplusminus(v1362), v1363); + real2 v1376 = minus(uminusplus(v1362), v1363); + real2 v1398 = minusplus(uminus(v1394), v1395); + real2 v1396 = minusplus(v1394, v1395); + real2 v1404 = ctimesminusplus(reverse(v1396), ctbl[1], ctimes(v1396, ctbl[1])); + real2 v1484 = minus(v1404, v1372); + store(out, 106 << shift, minus(uminusplus(v1483), v1484)); + store(out, 42 << shift, minus(uplusminus(v1483), v1484)); + real2 v1488 = plus(v1372, v1404); + store(out, 10 << shift, plus(v1488, v1489)); + store(out, 74 << shift, minus(v1488, v1489)); + real2 v1408 = ctimesminusplus(reverse(v1398), ctbl[1], ctimes(v1398, ctbl[0])); + real2 v1503 = minus(v1408, v1376); + store(out, 122 << shift, minus(uminusplus(v1502), v1503)); + store(out, 58 << shift, minus(uplusminus(v1502), v1503)); + real2 v1507 = plus(v1376, v1408); + store(out, 90 << shift, minus(v1507, v1508)); + store(out, 26 << shift, plus(v1507, v1508)); + real2 v847 = ctimesminusplus(reverse(v837), ctbl[1], ctimes(v837, ctbl[0])); + real2 v911 = ctimesminusplus(reverse(v901), ctbl[4], ctimes(v901, ctbl[2])); + real2 v815 = ctimesminusplus(reverse(v805), ctbl[13], ctimes(v805, ctbl[12])); + real2 v1522 = minus(v847, v719); + real2 v1526 = plus(v719, v847); + real2 v751 = ctimesminusplus(reverse(v741), ctbl[11], ctimes(v741, ctbl[9])); + real2 v1554 = minus(v879, v751); + real2 v1558 = plus(v751, v879); + real2 v943 = ctimesminusplus(reverse(v933), ctbl[10], ctimes(v933, ctbl[8])); + real2 v1553 = reverse(minus(v815, v943)); + real2 v1559 = plus(v815, v943); + real2 v1591 = plus(v1558, v1559); + real2 v1585 = reverse(minus(v1558, v1559)); + real2 v783 = ctimesminusplus(reverse(v773), ctbl[5], ctimes(v773, ctbl[3])); + real2 v1521 = reverse(minus(v783, v911)); + real2 v1527 = plus(v783, v911); + real2 v1586 = minus(v1527, v1526); + real2 v1590 = plus(v1526, v1527); + real2 v1595 = minus(uplusminus(v1585), v1586); + store(out, 22 << shift, plus(v1595, v1611)); + store(out, 86 << shift, minus(v1595, v1611)); + real2 v1599 = minus(uminusplus(v1585), v1586); + store(out, 118 << shift, minus(v1599, v1615)); + store(out, 54 << shift, plus(v1599, v1615)); + real2 v1622 = plus(v1590, v1591); + store(out, 70 << shift, minus(v1622, v1623)); + store(out, 6 << shift, plus(v1622, v1623)); + real2 v1618 = minus(v1591, v1590); + store(out, 102 << shift, minus(uminusplus(v1617), v1618)); + store(out, 38 << shift, minus(uplusminus(v1617), v1618)); + real2 v1557 = minusplus(uminus(v1553), v1554); + real2 v1555 = minusplus(v1553, v1554); + real2 v1563 = ctimesminusplus(reverse(v1555), ctbl[1], ctimes(v1555, ctbl[1])); + real2 v1531 = minus(uplusminus(v1521), v1522); + real2 v1535 = minus(uminusplus(v1521), v1522); + real2 v1643 = minus(v1563, v1531); + store(out, 46 << shift, minus(uplusminus(v1642), v1643)); + store(out, 110 << shift, minus(uminusplus(v1642), v1643)); + real2 v1647 = plus(v1531, v1563); + store(out, 78 << shift, minus(v1647, v1648)); + store(out, 14 << shift, plus(v1647, v1648)); + real2 v1567 = ctimesminusplus(reverse(v1557), ctbl[1], ctimes(v1557, ctbl[0])); + real2 v1666 = plus(v1535, v1567); + real2 v1662 = minus(v1567, v1535); + store(out, 94 << shift, minus(v1666, v1667)); + store(out, 30 << shift, plus(v1666, v1667)); + store(out, 126 << shift, minus(uminusplus(v1661), v1662)); + store(out, 62 << shift, minus(uplusminus(v1661), v1662)); + real2 v426 = minusplus(uminus(v422), v423); + real2 v424 = minusplus(v422, v423); + real2 v433 = ctimesminusplus(reverse(v424), ctbl[1], ctimes(v424, ctbl[1])); + real2 v141 = minus(uplusminus(v131), v132); + real2 v145 = minus(uminusplus(v131), v132); + real2 v1685 = plus(v141, v433); + real2 v1681 = minus(v433, v141); + real2 v247 = minusplus(v245, v246); + real2 v249 = minusplus(uminus(v245), v246); + real2 v207 = minusplus(v205, v206); + real2 v209 = minusplus(uminus(v205), v206); + real2 v217 = ctimesminusplus(reverse(v207), ctbl[7], ctimes(v207, ctbl[13])); + real2 v321 = minusplus(uminus(v317), v318); + real2 v319 = minusplus(v317, v318); + real2 v565 = minusplus(uminus(v561), v562); + real2 v563 = minusplus(v561, v562); + real2 v285 = minusplus(v283, v284); + real2 v287 = minusplus(uminus(v283), v284); + real2 v295 = ctimesminusplus(reverse(v285), ctbl[3], ctimes(v285, ctbl[5])); + real2 v329 = ctimesminusplus(reverse(v319), ctbl[19], ctimes(v319, ctbl[25])); + real2 v571 = ctimesminusplus(reverse(v563), ctbl[5], ctimes(v563, ctbl[3])); + real2 v1680 = reverse(minus(v295, v571)); + real2 v1686 = plus(v295, v571); + real2 v601 = minusplus(uminus(v597), v598); + real2 v599 = minusplus(v597, v598); + real2 v607 = ctimesminusplus(reverse(v599), ctbl[21], ctimes(v599, ctbl[23])); + real2 v1718 = plus(v329, v607); + real2 v1712 = reverse(minus(v329, v607)); + real2 v527 = minusplus(v525, v526); + real2 v529 = minusplus(uminus(v525), v526); + real2 v461 = minusplus(uminus(v457), v458); + real2 v459 = minusplus(v457, v458); + real2 v467 = ctimesminusplus(reverse(v459), ctbl[17], ctimes(v459, ctbl[27])); + real2 v255 = ctimesminusplus(reverse(v247), ctbl[23], ctimes(v247, ctbl[21])); + real2 v637 = minusplus(uminus(v633), v634); + real2 v635 = minusplus(v633, v634); + real2 v643 = ctimesminusplus(reverse(v635), ctbl[13], ctimes(v635, ctbl[7])); + real2 v1813 = plus(v1685, v1686); + real2 v1809 = minus(v1686, v1685); + real2 v493 = minusplus(v491, v492); + real2 v495 = minusplus(uminus(v491), v492); + real2 v171 = minusplus(uminus(v167), v168); + real2 v169 = minusplus(v167, v168); + real2 v354 = minusplus(v352, v353); + real2 v356 = minusplus(uminus(v352), v353); + real2 v362 = ctimesminusplus(reverse(v354), ctbl[11], ctimes(v354, ctbl[9])); + real2 v179 = ctimesminusplus(reverse(v169), ctbl[15], ctimes(v169, ctbl[29])); + real2 v1717 = plus(v179, v467); + real2 v1713 = minus(v467, v179); + real2 v1841 = minus(v1718, v1717); + real2 v1845 = plus(v1717, v1718); + real2 v501 = ctimesminusplus(reverse(v493), ctbl[9], ctimes(v493, ctbl[11])); + real2 v1745 = minus(v501, v217); + real2 v1749 = plus(v217, v501); + real2 v671 = minusplus(v669, v670); + real2 v673 = minusplus(uminus(v669), v670); + real2 v679 = ctimesminusplus(reverse(v671), ctbl[29], ctimes(v671, ctbl[15])); + real2 v535 = ctimesminusplus(reverse(v527), ctbl[25], ctimes(v527, ctbl[19])); + real2 v1781 = plus(v255, v535); + real2 v1777 = minus(v535, v255); + real2 v1825 = minus(v1702, v1701); + real2 v1829 = plus(v1701, v1702); + real2 v1889 = minus(v1830, v1829); + real2 v1893 = plus(v1829, v1830); + real2 v1910 = plus(v1893, v1894); + real2 v1904 = reverse(minus(v1893, v1894)); + real2 v392 = minusplus(uminus(v388), v389); + real2 v390 = minusplus(v388, v389); + real2 v398 = ctimesminusplus(reverse(v390), ctbl[27], ctimes(v390, ctbl[17])); + real2 v1776 = reverse(minus(v398, v679)); + real2 v1782 = plus(v398, v679); + real2 v1744 = reverse(minus(v362, v643)); + real2 v1750 = plus(v362, v643); + real2 v1808 = reverse(minus(v1749, v1750)); + real2 v1814 = plus(v1749, v1750); + real2 v1873 = minus(v1814, v1813); + real2 v1877 = plus(v1813, v1814); + real2 v1846 = plus(v1781, v1782); + real2 v1840 = reverse(minus(v1781, v1782)); + real2 v1872 = reverse(minus(v1845, v1846)); + real2 v1878 = plus(v1845, v1846); + real2 v1909 = plus(v1877, v1878); + store(out, 1 << shift, plus(v1909, v1910)); + store(out, 65 << shift, minus(v1909, v1910)); + real2 v1905 = minus(v1878, v1877); + store(out, 33 << shift, minus(uplusminus(v1904), v1905)); + store(out, 97 << shift, minus(uminusplus(v1904), v1905)); + real2 v1822 = minus(uminusplus(v1808), v1809); + real2 v1818 = minus(uplusminus(v1808), v1809); + real2 v1826 = minusplus(v1824, v1825); + real2 v1828 = minusplus(uminus(v1824), v1825); + real2 v1838 = ctimesminusplus(reverse(v1828), ctbl[5], ctimes(v1828, ctbl[3])); + real2 v1948 = reverse(minus(v1838, v1870)); + real2 v1954 = plus(v1838, v1870); + real2 v1844 = minusplus(uminus(v1840), v1841); + real2 v1842 = minusplus(v1840, v1841); + real2 v1854 = ctimesminusplus(reverse(v1844), ctbl[1], ctimes(v1844, ctbl[0])); + real2 v1953 = plus(v1822, v1854); + real2 v1949 = minus(v1854, v1822); + store(out, 89 << shift, minus(v1953, v1954)); + store(out, 25 << shift, plus(v1953, v1954)); + store(out, 121 << shift, minus(uminusplus(v1948), v1949)); + store(out, 57 << shift, minus(uplusminus(v1948), v1949)); + real2 v1834 = ctimesminusplus(reverse(v1826), ctbl[3], ctimes(v1826, ctbl[5])); + real2 v1850 = ctimesminusplus(reverse(v1842), ctbl[1], ctimes(v1842, ctbl[1])); + real2 v1929 = reverse(minus(v1834, v1866)); + real2 v1935 = plus(v1834, v1866); + real2 v1934 = plus(v1818, v1850); + real2 v1930 = minus(v1850, v1818); + store(out, 105 << shift, minus(uminusplus(v1929), v1930)); + store(out, 41 << shift, minus(uplusminus(v1929), v1930)); + store(out, 73 << shift, minus(v1934, v1935)); + store(out, 9 << shift, plus(v1934, v1935)); + real2 v1890 = minusplus(v1888, v1889); + real2 v1892 = minusplus(uminus(v1888), v1889); + real2 v1902 = ctimesminusplus(reverse(v1892), ctbl[1], ctimes(v1892, ctbl[0])); + real2 v1886 = minus(uminusplus(v1872), v1873); + store(out, 113 << shift, minus(v1886, v1902)); + store(out, 49 << shift, plus(v1886, v1902)); + real2 v1882 = minus(uplusminus(v1872), v1873); + real2 v1898 = ctimesminusplus(reverse(v1890), ctbl[1], ctimes(v1890, ctbl[1])); + store(out, 17 << shift, plus(v1882, v1898)); + store(out, 81 << shift, minus(v1882, v1898)); + real2 v1700 = minusplus(uminus(v1696), v1697); + real2 v1698 = minusplus(v1696, v1697); + real2 v1690 = minus(uplusminus(v1680), v1681); + real2 v1694 = minus(uminusplus(v1680), v1681); + real2 v1778 = minusplus(v1776, v1777); + real2 v1780 = minusplus(uminus(v1776), v1777); + real2 v1774 = ctimesminusplus(reverse(v1764), ctbl[7], ctimes(v1764, ctbl[6])); + real2 v1710 = ctimesminusplus(reverse(v1700), ctbl[11], ctimes(v1700, ctbl[9])); + real2 v2041 = minus(v1774, v1710); + real2 v2045 = plus(v1710, v1774); + real2 v1714 = minusplus(v1712, v1713); + real2 v1716 = minusplus(uminus(v1712), v1713); + real2 v2042 = minusplus(v2040, v2041); + real2 v2044 = minusplus(uminus(v2040), v2041); + real2 v2054 = ctimesminusplus(reverse(v2044), ctbl[1], ctimes(v2044, ctbl[0])); + real2 v1726 = ctimesminusplus(reverse(v1716), ctbl[5], ctimes(v1716, ctbl[3])); + real2 v1748 = minusplus(uminus(v1744), v1745); + real2 v1746 = minusplus(v1744, v1745); + real2 v1758 = ctimesminusplus(reverse(v1748), ctbl[1], ctimes(v1748, ctbl[0])); + real2 v2029 = plus(v1694, v1758); + real2 v2025 = minus(v1758, v1694); + real2 v1790 = ctimesminusplus(reverse(v1780), ctbl[4], ctimes(v1780, ctbl[2])); + real2 v2024 = reverse(minus(v1726, v1790)); + real2 v2030 = plus(v1726, v1790); + real2 v2038 = minus(uminusplus(v2024), v2025); + store(out, 61 << shift, plus(v2038, v2054)); + store(out, 125 << shift, minus(v2038, v2054)); + real2 v2034 = minus(uplusminus(v2024), v2025); + real2 v2050 = ctimesminusplus(reverse(v2042), ctbl[1], ctimes(v2042, ctbl[1])); + store(out, 93 << shift, minus(v2034, v2050)); + store(out, 29 << shift, plus(v2034, v2050)); + real2 v2056 = reverse(minus(v2045, v2046)); + real2 v2062 = plus(v2045, v2046); + real2 v2061 = plus(v2029, v2030); + store(out, 13 << shift, plus(v2061, v2062)); + store(out, 77 << shift, minus(v2061, v2062)); + real2 v2057 = minus(v2030, v2029); + store(out, 45 << shift, minus(uplusminus(v2056), v2057)); + store(out, 109 << shift, minus(uminusplus(v2056), v2057)); + real2 v1754 = ctimesminusplus(reverse(v1746), ctbl[1], ctimes(v1746, ctbl[1])); + real2 v1722 = ctimesminusplus(reverse(v1714), ctbl[3], ctimes(v1714, ctbl[5])); + real2 v1770 = ctimesminusplus(reverse(v1762), ctbl[9], ctimes(v1762, ctbl[11])); + real2 v1706 = ctimesminusplus(reverse(v1698), ctbl[7], ctimes(v1698, ctbl[13])); + real2 v1988 = plus(v1706, v1770); + real2 v1984 = minus(v1770, v1706); + real2 v1968 = minus(v1754, v1690); + real2 v1972 = plus(v1690, v1754); + real2 v1985 = minusplus(v1983, v1984); + real2 v1987 = minusplus(uminus(v1983), v1984); + real2 v1993 = ctimesminusplus(reverse(v1985), ctbl[1], ctimes(v1985, ctbl[1])); + real2 v1786 = ctimesminusplus(reverse(v1778), ctbl[5], ctimes(v1778, ctbl[3])); + real2 v1967 = reverse(minus(v1722, v1786)); + real2 v1973 = plus(v1722, v1786); + real2 v1977 = minus(uplusminus(v1967), v1968); + real2 v1981 = minus(uminusplus(v1967), v1968); + store(out, 85 << shift, minus(v1977, v1993)); + store(out, 21 << shift, plus(v1977, v1993)); + real2 v1997 = ctimesminusplus(reverse(v1987), ctbl[1], ctimes(v1987, ctbl[0])); + store(out, 117 << shift, minus(v1981, v1997)); + store(out, 53 << shift, plus(v1981, v1997)); + real2 v2004 = plus(v1972, v1973); + real2 v2000 = minus(v1973, v1972); + real2 v1999 = reverse(minus(v1988, v1989)); + real2 v2005 = plus(v1988, v1989); + store(out, 5 << shift, plus(v2004, v2005)); + store(out, 69 << shift, minus(v2004, v2005)); + store(out, 37 << shift, minus(uplusminus(v1999), v2000)); + store(out, 101 << shift, minus(uminusplus(v1999), v2000)); + real2 v333 = ctimesminusplus(reverse(v321), ctbl[29], ctimes(v321, ctbl[15])); + real2 v613 = ctimesminusplus(reverse(v601), ctbl[16], ctimes(v601, ctbl[26])); + real2 v2113 = reverse(minus(v333, v613)); + real2 v2119 = plus(v333, v613); + real2 v595 = ctimesminusplus(reverse(v583), ctbl[40], ctimes(v583, ctbl[50])); + real2 v455 = ctimesminusplus(reverse(v444), ctbl[43], ctimes(v444, ctbl[42])); + real2 v165 = ctimesminusplus(reverse(v151), ctbl[47], ctimes(v151, ctbl[45])); + real2 v2102 = plus(v165, v455); + real2 v2098 = minus(v455, v165); + real2 v315 = ctimesminusplus(reverse(v305), ctbl[53], ctimes(v305, ctbl[39])); + real2 v2097 = reverse(minus(v315, v595)); + real2 v2103 = plus(v315, v595); + real2 v261 = ctimesminusplus(reverse(v249), ctbl[17], ctimes(v249, ctbl[27])); + real2 v299 = ctimesminusplus(reverse(v287), ctbl[5], ctimes(v287, ctbl[3])); + real2 v523 = ctimesminusplus(reverse(v512), ctbl[31], ctimes(v512, ctbl[30])); + real2 v541 = ctimesminusplus(reverse(v529), ctbl[28], ctimes(v529, ctbl[14])); + real2 v2182 = plus(v261, v541); + real2 v2178 = minus(v541, v261); + real2 v243 = ctimesminusplus(reverse(v229), ctbl[59], ctimes(v229, ctbl[33])); + real2 v667 = ctimesminusplus(reverse(v655), ctbl[34], ctimes(v655, ctbl[56])); + real2 v2166 = plus(v243, v523); + real2 v2162 = minus(v523, v243); + real2 v386 = ctimesminusplus(reverse(v373), ctbl[37], ctimes(v373, ctbl[36])); + real2 v2161 = reverse(minus(v386, v667)); + real2 v2167 = plus(v386, v667); + real2 v472 = ctimesminusplus(reverse(v461), ctbl[19], ctimes(v461, ctbl[18])); + real2 v185 = ctimesminusplus(reverse(v171), ctbl[23], ctimes(v171, ctbl[21])); + real2 v2114 = minus(v472, v185); + real2 v2118 = plus(v185, v472); + real2 v420 = ctimesminusplus(reverse(v409), ctbl[49], ctimes(v409, ctbl[48])); + real2 v506 = ctimesminusplus(reverse(v495), ctbl[7], ctimes(v495, ctbl[6])); + real2 v2199 = plus(v420, v703); + real2 v2193 = reverse(minus(v420, v703)); + real2 v649 = ctimesminusplus(reverse(v637), ctbl[10], ctimes(v637, ctbl[8])); + real2 v223 = ctimesminusplus(reverse(v209), ctbl[11], ctimes(v209, ctbl[9])); + real2 v2146 = minus(v506, v223); + real2 v2150 = plus(v223, v506); + real2 v2231 = plus(v2166, v2167); + real2 v2225 = reverse(minus(v2166, v2167)); + real2 v685 = ctimesminusplus(reverse(v673), ctbl[22], ctimes(v673, ctbl[20])); + real2 v2257 = reverse(minus(v2198, v2199)); + real2 v2263 = plus(v2198, v2199); + real2 v2226 = minus(v2103, v2102); + real2 v2230 = plus(v2102, v2103); + real2 v2294 = plus(v2230, v2231); + real2 v2290 = minus(v2231, v2230); + real2 v2246 = plus(v2118, v2119); + real2 v2242 = minus(v2119, v2118); + real2 v577 = ctimesminusplus(reverse(v565), ctbl[4], ctimes(v565, ctbl[2])); + real2 v2081 = reverse(minus(v299, v577)); + real2 v2087 = plus(v299, v577); + real2 v403 = ctimesminusplus(reverse(v392), ctbl[25], ctimes(v392, ctbl[24])); + real2 v2177 = reverse(minus(v403, v685)); + real2 v2183 = plus(v403, v685); + real2 v438 = ctimesminusplus(reverse(v426), ctbl[1], ctimes(v426, ctbl[0])); + real2 v2086 = plus(v145, v438); + real2 v2082 = minus(v438, v145); + real2 v2210 = minus(v2087, v2086); + real2 v2214 = plus(v2086, v2087); + real2 v2247 = plus(v2182, v2183); + real2 v2241 = reverse(minus(v2182, v2183)); + real2 v2279 = plus(v2246, v2247); + real2 v2273 = reverse(minus(v2246, v2247)); + real2 v367 = ctimesminusplus(reverse(v356), ctbl[13], ctimes(v356, ctbl[12])); + real2 v2151 = plus(v367, v649); + real2 v2145 = reverse(minus(v367, v649)); + real2 v2209 = reverse(minus(v2150, v2151)); + real2 v2215 = plus(v2150, v2151); + real2 v2274 = minus(v2215, v2214); + real2 v2278 = plus(v2214, v2215); + real2 v2310 = plus(v2278, v2279); + real2 v2306 = minus(v2279, v2278); + real2 v2295 = plus(v2262, v2263); + real2 v2289 = reverse(minus(v2262, v2263)); + real2 v2311 = plus(v2294, v2295); + store(out, 3 << shift, plus(v2310, v2311)); + store(out, 67 << shift, minus(v2310, v2311)); + real2 v2305 = reverse(minus(v2294, v2295)); + store(out, 35 << shift, minus(uplusminus(v2305), v2306)); + store(out, 99 << shift, minus(uminusplus(v2305), v2306)); + real2 v2287 = minus(uminusplus(v2273), v2274); + real2 v2283 = minus(uplusminus(v2273), v2274); + real2 v2291 = minusplus(v2289, v2290); + real2 v2293 = minusplus(uminus(v2289), v2290); + real2 v2299 = ctimesminusplus(reverse(v2291), ctbl[1], ctimes(v2291, ctbl[1])); + store(out, 19 << shift, plus(v2283, v2299)); + store(out, 83 << shift, minus(v2283, v2299)); + real2 v2303 = ctimesminusplus(reverse(v2293), ctbl[1], ctimes(v2293, ctbl[0])); + store(out, 51 << shift, plus(v2287, v2303)); + store(out, 115 << shift, minus(v2287, v2303)); + real2 v2229 = minusplus(uminus(v2225), v2226); + real2 v2227 = minusplus(v2225, v2226); + real2 v2235 = ctimesminusplus(reverse(v2227), ctbl[3], ctimes(v2227, ctbl[5])); + real2 v2219 = minus(uplusminus(v2209), v2210); + real2 v2223 = minus(uminusplus(v2209), v2210); + real2 v2243 = minusplus(v2241, v2242); + real2 v2245 = minusplus(uminus(v2241), v2242); + real2 v2251 = ctimesminusplus(reverse(v2243), ctbl[1], ctimes(v2243, ctbl[1])); + real2 v2331 = minus(v2251, v2219); + real2 v2335 = plus(v2219, v2251); + real2 v2259 = minusplus(v2257, v2258); + real2 v2261 = minusplus(uminus(v2257), v2258); + real2 v2267 = ctimesminusplus(reverse(v2259), ctbl[5], ctimes(v2259, ctbl[3])); + real2 v2336 = plus(v2235, v2267); + store(out, 75 << shift, minus(v2335, v2336)); + store(out, 11 << shift, plus(v2335, v2336)); + real2 v2330 = reverse(minus(v2235, v2267)); + store(out, 107 << shift, minus(uminusplus(v2330), v2331)); + store(out, 43 << shift, minus(uplusminus(v2330), v2331)); + real2 v2239 = ctimesminusplus(reverse(v2229), ctbl[5], ctimes(v2229, ctbl[3])); + real2 v2271 = ctimesminusplus(reverse(v2261), ctbl[4], ctimes(v2261, ctbl[2])); + real2 v2255 = ctimesminusplus(reverse(v2245), ctbl[1], ctimes(v2245, ctbl[0])); + real2 v2350 = minus(v2255, v2223); + real2 v2354 = plus(v2223, v2255); + real2 v2355 = plus(v2239, v2271); + store(out, 91 << shift, minus(v2354, v2355)); + store(out, 27 << shift, plus(v2354, v2355)); + real2 v2349 = reverse(minus(v2239, v2271)); + store(out, 59 << shift, minus(uplusminus(v2349), v2350)); + store(out, 123 << shift, minus(uminusplus(v2349), v2350)); + real2 v2091 = minus(uplusminus(v2081), v2082); + real2 v2095 = minus(uminusplus(v2081), v2082); + real2 v2181 = minusplus(uminus(v2177), v2178); + real2 v2179 = minusplus(v2177, v2178); + real2 v2101 = minusplus(uminus(v2097), v2098); + real2 v2099 = minusplus(v2097, v2098); + real2 v2165 = minusplus(uminus(v2161), v2162); + real2 v2163 = minusplus(v2161, v2162); + real2 v2147 = minusplus(v2145, v2146); + real2 v2149 = minusplus(uminus(v2145), v2146); + real2 v2155 = ctimesminusplus(reverse(v2147), ctbl[1], ctimes(v2147, ctbl[1])); + real2 v2197 = minusplus(uminus(v2193), v2194); + real2 v2195 = minusplus(v2193, v2194); + real2 v2117 = minusplus(uminus(v2113), v2114); + real2 v2115 = minusplus(v2113, v2114); + real2 v2123 = ctimesminusplus(reverse(v2115), ctbl[3], ctimes(v2115, ctbl[5])); + real2 v2171 = ctimesminusplus(reverse(v2163), ctbl[9], ctimes(v2163, ctbl[11])); + real2 v2107 = ctimesminusplus(reverse(v2099), ctbl[7], ctimes(v2099, ctbl[13])); + real2 v2389 = plus(v2107, v2171); + real2 v2385 = minus(v2171, v2107); + real2 v2187 = ctimesminusplus(reverse(v2179), ctbl[5], ctimes(v2179, ctbl[3])); + real2 v2374 = plus(v2123, v2187); + real2 v2368 = reverse(minus(v2123, v2187)); + real2 v2369 = minus(v2155, v2091); + real2 v2373 = plus(v2091, v2155); + real2 v2405 = plus(v2373, v2374); + real2 v2401 = minus(v2374, v2373); + real2 v2203 = ctimesminusplus(reverse(v2195), ctbl[13], ctimes(v2195, ctbl[7])); + real2 v2131 = minusplus(v2129, v2130); + real2 v2133 = minusplus(uminus(v2129), v2130); + real2 v2139 = ctimesminusplus(reverse(v2131), ctbl[11], ctimes(v2131, ctbl[9])); + real2 v2390 = plus(v2139, v2203); + real2 v2384 = reverse(minus(v2139, v2203)); + real2 v2400 = reverse(minus(v2389, v2390)); + store(out, 103 << shift, minus(uminusplus(v2400), v2401)); + store(out, 39 << shift, minus(uplusminus(v2400), v2401)); + real2 v2406 = plus(v2389, v2390); + store(out, 71 << shift, minus(v2405, v2406)); + store(out, 7 << shift, plus(v2405, v2406)); + real2 v2382 = minus(uminusplus(v2368), v2369); + real2 v2378 = minus(uplusminus(v2368), v2369); + real2 v2388 = minusplus(uminus(v2384), v2385); + real2 v2386 = minusplus(v2384, v2385); + real2 v2398 = ctimesminusplus(reverse(v2388), ctbl[1], ctimes(v2388, ctbl[0])); + store(out, 119 << shift, minus(v2382, v2398)); + store(out, 55 << shift, plus(v2382, v2398)); + real2 v2394 = ctimesminusplus(reverse(v2386), ctbl[1], ctimes(v2386, ctbl[1])); + store(out, 87 << shift, minus(v2378, v2394)); + store(out, 23 << shift, plus(v2378, v2394)); + real2 v2127 = ctimesminusplus(reverse(v2117), ctbl[5], ctimes(v2117, ctbl[3])); + real2 v2175 = ctimesminusplus(reverse(v2165), ctbl[7], ctimes(v2165, ctbl[6])); + real2 v2111 = ctimesminusplus(reverse(v2101), ctbl[11], ctimes(v2101, ctbl[9])); + real2 v2442 = minus(v2175, v2111); + real2 v2446 = plus(v2111, v2175); + real2 v2207 = ctimesminusplus(reverse(v2197), ctbl[10], ctimes(v2197, ctbl[8])); + real2 v2159 = ctimesminusplus(reverse(v2149), ctbl[1], ctimes(v2149, ctbl[0])); + real2 v2430 = plus(v2095, v2159); + real2 v2426 = minus(v2159, v2095); + real2 v2191 = ctimesminusplus(reverse(v2181), ctbl[4], ctimes(v2181, ctbl[2])); + real2 v2143 = ctimesminusplus(reverse(v2133), ctbl[13], ctimes(v2133, ctbl[12])); + real2 v2447 = plus(v2143, v2207); + real2 v2441 = reverse(minus(v2143, v2207)); + real2 v2425 = reverse(minus(v2127, v2191)); + real2 v2431 = plus(v2127, v2191); + real2 v2458 = minus(v2431, v2430); + real2 v2462 = plus(v2430, v2431); + real2 v2457 = reverse(minus(v2446, v2447)); + store(out, 47 << shift, minus(uplusminus(v2457), v2458)); + store(out, 111 << shift, minus(uminusplus(v2457), v2458)); + real2 v2463 = plus(v2446, v2447); + store(out, 79 << shift, minus(v2462, v2463)); + store(out, 15 << shift, plus(v2462, v2463)); + real2 v2435 = minus(uplusminus(v2425), v2426); + real2 v2439 = minus(uminusplus(v2425), v2426); + real2 v2445 = minusplus(uminus(v2441), v2442); + real2 v2443 = minusplus(v2441, v2442); + real2 v2451 = ctimesminusplus(reverse(v2443), ctbl[1], ctimes(v2443, ctbl[1])); + store(out, 31 << shift, plus(v2435, v2451)); + store(out, 95 << shift, minus(v2435, v2451)); + real2 v2455 = ctimesminusplus(reverse(v2445), ctbl[1], ctimes(v2445, ctbl[0])); + store(out, 127 << shift, minus(v2439, v2455)); + store(out, 63 << shift, plus(v2439, v2455)); +// Pres : 68124 + } +} + +ALIGNED(8192) void dft128b_%CONFIG%_%ISA%(real *RESTRICT out0, const real *RESTRICT in0, const int shift) { + const int k = 1 << (shift - LOG2VECWIDTH); + int i=0; +#pragma omp parallel for + for(i=0;i < k;i++) { + int i0 = i << LOG2VECWIDTH; + real *out = out0 + i0*2; + const real *in = in0 + i0*2; + +// Pres : 135650 + real2 v51 = load(in, 49 << shift); + real2 v115 = load(in, 113 << shift); + real2 v456 = plus(v51, v115); + real2 v450 = reverse(minus(v115, v51)); + real2 v83 = load(in, 81 << shift); + real2 v19 = load(in, 17 << shift); + real2 v455 = plus(v19, v83); + real2 v451 = minus(v83, v19); + real2 v721 = reverse(minus(v456, v455)); + real2 v727 = plus(v455, v456); + real2 v452 = minusplus(v450, v451); + real2 v454 = minusplus(uminus(v450), v451); + real2 v462 = ctimesminusplus(reverse(v452), ctbl[58], ctimes(v452, ctbl[59])); + real2 v466 = ctimesminusplus(reverse(v454), ctbl[48], ctimes(v454, ctbl[42])); + real2 v35 = load(in, 33 << shift); + real2 v99 = load(in, 97 << shift); + real2 v147 = reverse(minus(v99, v35)); + real2 v153 = plus(v35, v99); + real2 v3 = load(in, 1 << shift); + real2 v67 = load(in, 65 << shift); + real2 v152 = plus(v3, v67); + real2 v148 = minus(v67, v3); + real2 v722 = minus(v153, v152); + real2 v726 = plus(v152, v153); + real2 v982 = plus(v726, v727); + real2 v978 = minus(v727, v726); + real2 v149 = minusplus(v147, v148); + real2 v151 = minusplus(uminus(v147), v148); + real2 v165 = ctimesminusplus(reverse(v151), ctbl[44], ctimes(v151, ctbl[45])); + real2 v159 = ctimesminusplus(reverse(v149), ctbl[60], ctimes(v149, ctbl[61])); + real2 v723 = minusplus(v721, v722); + real2 v725 = minusplus(uminus(v721), v722); + real2 v2102 = plus(v165, v466); + real2 v2098 = minus(v466, v165); + real2 v731 = ctimesminusplus(reverse(v723), ctbl[28], ctimes(v723, ctbl[29])); + real2 v1697 = minus(v462, v159); + real2 v1701 = plus(v159, v462); + real2 v735 = ctimesminusplus(reverse(v725), ctbl[20], ctimes(v725, ctbl[21])); + real2 v75 = load(in, 73 << shift); + real2 v11 = load(in, 9 << shift); + real2 v304 = minus(v75, v11); + real2 v308 = plus(v11, v75); + real2 v107 = load(in, 105 << shift); + real2 v43 = load(in, 41 << shift); + real2 v309 = plus(v43, v107); + real2 v303 = reverse(minus(v107, v43)); + real2 v854 = plus(v308, v309); + real2 v850 = minus(v309, v308); + real2 v307 = minusplus(uminus(v303), v304); + real2 v305 = minusplus(v303, v304); + real2 v313 = ctimesminusplus(reverse(v305), ctbl[56], ctimes(v305, ctbl[57])); + real2 v319 = ctimesminusplus(reverse(v307), ctbl[38], ctimes(v307, ctbl[39])); + real2 v27 = load(in, 25 << shift); + real2 v91 = load(in, 89 << shift); + real2 v591 = plus(v27, v91); + real2 v587 = minus(v91, v27); + real2 v59 = load(in, 57 << shift); + real2 v123 = load(in, 121 << shift); + real2 v592 = plus(v59, v123); + real2 v586 = reverse(minus(v123, v59)); + real2 v849 = reverse(minus(v592, v591)); + real2 v855 = plus(v591, v592); + real2 v983 = plus(v854, v855); + real2 v977 = reverse(minus(v855, v854)); + real2 v590 = minusplus(uminus(v586), v587); + real2 v588 = minusplus(v586, v587); + real2 v597 = ctimesminusplus(reverse(v588), ctbl[54], ctimes(v588, ctbl[55])); + real2 v1110 = plus(v982, v983); + real2 v1106 = minus(v983, v982); + real2 v853 = minusplus(uminus(v849), v850); + real2 v851 = minusplus(v849, v850); + real2 v859 = ctimesminusplus(reverse(v851), ctbl[26], ctimes(v851, ctbl[27])); + real2 v1702 = plus(v313, v597); + real2 v1696 = reverse(minus(v597, v313)); + real2 v1825 = minus(v1702, v1701); + real2 v1829 = plus(v1701, v1702); + real2 v1700 = minusplus(uminus(v1696), v1697); + real2 v1698 = minusplus(v1696, v1697); + real2 v1710 = ctimesminusplus(reverse(v1700), ctbl[8], ctimes(v1700, ctbl[9])); + real2 v1706 = ctimesminusplus(reverse(v1698), ctbl[12], ctimes(v1698, ctbl[13])); + real2 v1379 = minus(v859, v731); + real2 v1383 = plus(v731, v859); + real2 v863 = ctimesminusplus(reverse(v853), ctbl[24], ctimes(v853, ctbl[18])); + real2 v1538 = minus(v863, v735); + real2 v1542 = plus(v735, v863); + real2 v981 = minusplus(uminus(v977), v978); + real2 v979 = minusplus(v977, v978); + real2 v987 = ctimesminusplus(reverse(v979), ctbl[12], ctimes(v979, ctbl[13])); + real2 v601 = ctimesminusplus(reverse(v590), ctbl[51], ctimes(v590, ctbl[50])); + real2 v991 = ctimesminusplus(reverse(v981), ctbl[8], ctimes(v981, ctbl[9])); + real2 v2103 = plus(v319, v601); + real2 v2097 = reverse(minus(v601, v319)); + real2 v2226 = minus(v2103, v2102); + real2 v2230 = plus(v2102, v2103); + real2 v2101 = minusplus(uminus(v2097), v2098); + real2 v2099 = minusplus(v2097, v2098); + real2 v2107 = ctimesminusplus(reverse(v2099), ctbl[12], ctimes(v2099, ctbl[13])); + real2 v127 = load(in, 125 << shift); + real2 v63 = load(in, 61 << shift); + real2 v660 = plus(v63, v127); + real2 v654 = reverse(minus(v127, v63)); + real2 v31 = load(in, 29 << shift); + real2 v95 = load(in, 93 << shift); + real2 v659 = plus(v31, v95); + real2 v655 = minus(v95, v31); + real2 v913 = reverse(minus(v660, v659)); + real2 v919 = plus(v659, v660); + real2 v658 = minusplus(uminus(v654), v655); + real2 v656 = minusplus(v654, v655); + real2 v666 = ctimesminusplus(reverse(v656), ctbl[46], ctimes(v656, ctbl[47])); + real2 v670 = ctimesminusplus(reverse(v658), ctbl[57], ctimes(v658, ctbl[56])); + real2 v47 = load(in, 45 << shift); + real2 v111 = load(in, 109 << shift); + real2 v377 = reverse(minus(v111, v47)); + real2 v383 = plus(v47, v111); + real2 v15 = load(in, 13 << shift); + real2 v79 = load(in, 77 << shift); + real2 v378 = minus(v79, v15); + real2 v382 = plus(v15, v79); + real2 v379 = minusplus(v377, v378); + real2 v381 = minusplus(uminus(v377), v378); + real2 v394 = ctimesminusplus(reverse(v381), ctbl[54], ctimes(v381, ctbl[36])); + real2 v2167 = plus(v394, v670); + real2 v2161 = reverse(minus(v670, v394)); + real2 v914 = minus(v383, v382); + real2 v918 = plus(v382, v383); + real2 v1047 = plus(v918, v919); + real2 v1041 = reverse(minus(v919, v918)); + real2 v917 = minusplus(uminus(v913), v914); + real2 v915 = minusplus(v913, v914); + real2 v923 = ctimesminusplus(reverse(v915), ctbl[22], ctimes(v915, ctbl[23])); + real2 v389 = ctimesminusplus(reverse(v379), ctbl[48], ctimes(v379, ctbl[49])); + real2 v1760 = reverse(minus(v666, v389)); + real2 v1766 = plus(v389, v666); + real2 v927 = ctimesminusplus(reverse(v917), ctbl[27], ctimes(v917, ctbl[26])); + real2 v87 = load(in, 85 << shift); + real2 v23 = load(in, 21 << shift); + real2 v520 = minus(v87, v23); + real2 v524 = plus(v23, v87); + real2 v55 = load(in, 53 << shift); + real2 v119 = load(in, 117 << shift); + real2 v519 = reverse(minus(v119, v55)); + real2 v525 = plus(v55, v119); + real2 v523 = minusplus(uminus(v519), v520); + real2 v521 = minusplus(v519, v520); + real2 v529 = ctimesminusplus(reverse(v521), ctbl[50], ctimes(v521, ctbl[51])); + real2 v533 = ctimesminusplus(reverse(v523), ctbl[60], ctimes(v523, ctbl[30])); + real2 v791 = plus(v524, v525); + real2 v785 = reverse(minus(v525, v524)); + real2 v39 = load(in, 37 << shift); + real2 v103 = load(in, 101 << shift); + real2 v231 = plus(v39, v103); + real2 v225 = reverse(minus(v103, v39)); + real2 v7 = load(in, 5 << shift); + real2 v71 = load(in, 69 << shift); + real2 v226 = minus(v71, v7); + real2 v230 = plus(v7, v71); + real2 v227 = minusplus(v225, v226); + real2 v229 = minusplus(uminus(v225), v226); + real2 v243 = ctimesminusplus(reverse(v229), ctbl[32], ctimes(v229, ctbl[33])); + real2 v2162 = minus(v533, v243); + real2 v2166 = plus(v243, v533); + real2 v2231 = plus(v2166, v2167); + real2 v2225 = reverse(minus(v2167, v2166)); + real2 v237 = ctimesminusplus(reverse(v227), ctbl[52], ctimes(v227, ctbl[53])); + real2 v1761 = minus(v529, v237); + real2 v1765 = plus(v237, v529); + real2 v1824 = reverse(minus(v1766, v1765)); + real2 v1830 = plus(v1765, v1766); + real2 v790 = plus(v230, v231); + real2 v786 = minus(v231, v230); + real2 v1826 = minusplus(v1824, v1825); + real2 v1828 = minusplus(uminus(v1824), v1825); + real2 v1764 = minusplus(uminus(v1760), v1761); + real2 v1762 = minusplus(v1760, v1761); + real2 v1889 = minus(v1830, v1829); + real2 v1893 = plus(v1829, v1830); + real2 v1838 = ctimesminusplus(reverse(v1828), ctbl[2], ctimes(v1828, ctbl[3])); + real2 v1774 = ctimesminusplus(reverse(v1764), ctbl[12], ctimes(v1764, ctbl[6])); + real2 v2041 = minus(v1774, v1710); + real2 v2045 = plus(v1710, v1774); + real2 v1770 = ctimesminusplus(reverse(v1762), ctbl[10], ctimes(v1762, ctbl[11])); + real2 v1988 = plus(v1706, v1770); + real2 v1984 = minus(v1770, v1706); + real2 v1834 = ctimesminusplus(reverse(v1826), ctbl[4], ctimes(v1826, ctbl[5])); + real2 v787 = minusplus(v785, v786); + real2 v789 = minusplus(uminus(v785), v786); + real2 v799 = ctimesminusplus(reverse(v789), ctbl[14], ctimes(v789, ctbl[15])); + real2 v1046 = plus(v790, v791); + real2 v1042 = minus(v791, v790); + real2 v1043 = minusplus(v1041, v1042); + real2 v1045 = minusplus(uminus(v1041), v1042); + real2 v1537 = reverse(minus(v927, v799)); + real2 v1543 = plus(v799, v927); + real2 v1606 = plus(v1542, v1543); + real2 v1602 = minus(v1543, v1542); + real2 v795 = ctimesminusplus(reverse(v787), ctbl[24], ctimes(v787, ctbl[25])); + real2 v1105 = reverse(minus(v1047, v1046)); + real2 v1111 = plus(v1046, v1047); + real2 v1384 = plus(v795, v923); + real2 v1378 = reverse(minus(v923, v795)); + real2 v1107 = minusplus(v1105, v1106); + real2 v1109 = minusplus(uminus(v1105), v1106); + real2 v1119 = ctimesminusplus(reverse(v1109), ctbl[2], ctimes(v1109, ctbl[3])); + real2 v1382 = minusplus(uminus(v1378), v1379); + real2 v1380 = minusplus(v1378, v1379); + real2 v1388 = ctimesminusplus(reverse(v1380), ctbl[4], ctimes(v1380, ctbl[5])); + real2 v1115 = ctimesminusplus(reverse(v1107), ctbl[4], ctimes(v1107, ctbl[5])); + real2 v1392 = ctimesminusplus(reverse(v1382), ctbl[2], ctimes(v1382, ctbl[3])); + real2 v1443 = minus(v1384, v1383); + real2 v1447 = plus(v1383, v1384); + real2 v1539 = minusplus(v1537, v1538); + real2 v1541 = minusplus(uminus(v1537), v1538); + real2 v1551 = ctimesminusplus(reverse(v1541), ctbl[2], ctimes(v1541, ctbl[3])); + real2 v1547 = ctimesminusplus(reverse(v1539), ctbl[4], ctimes(v1539, ctbl[5])); + real2 v1051 = ctimesminusplus(reverse(v1043), ctbl[10], ctimes(v1043, ctbl[11])); + real2 v2290 = minus(v2231, v2230); + real2 v2294 = plus(v2230, v2231); + real2 v1174 = plus(v1110, v1111); + real2 v1170 = minus(v1111, v1110); + real2 v1265 = minus(v1051, v987); + real2 v1269 = plus(v987, v1051); + real2 v1055 = ctimesminusplus(reverse(v1045), ctbl[12], ctimes(v1045, ctbl[6])); + real2 v1322 = minus(v1055, v991); + real2 v1326 = plus(v991, v1055); + real2 v129 = load(in, 127 << shift); + real2 v65 = load(in, 63 << shift); + real2 v688 = reverse(minus(v129, v65)); + real2 v694 = plus(v65, v129); + real2 v33 = load(in, 31 << shift); + real2 v97 = load(in, 95 << shift); + real2 v689 = minus(v97, v33); + real2 v693 = plus(v33, v97); + real2 v951 = plus(v693, v694); + real2 v945 = reverse(minus(v694, v693)); + real2 v692 = minusplus(uminus(v688), v689); + real2 v690 = minusplus(v688, v689); + real2 v699 = ctimesminusplus(reverse(v690), ctbl[30], ctimes(v690, ctbl[31])); + real2 v17 = load(in, 15 << shift); + real2 v81 = load(in, 79 << shift); + real2 v420 = plus(v17, v81); + real2 v416 = minus(v81, v17); + real2 v113 = load(in, 111 << shift); + real2 v49 = load(in, 47 << shift); + real2 v415 = reverse(minus(v113, v49)); + real2 v421 = plus(v49, v113); + real2 v419 = minusplus(uminus(v415), v416); + real2 v417 = minusplus(v415, v416); + real2 v425 = ctimesminusplus(reverse(v417), ctbl[32], ctimes(v417, ctbl[33])); + real2 v1792 = reverse(minus(v699, v425)); + real2 v1798 = plus(v425, v699); + real2 v950 = plus(v420, v421); + real2 v946 = minus(v421, v420); + real2 v947 = minusplus(v945, v946); + real2 v949 = minusplus(uminus(v945), v946); + real2 v959 = ctimesminusplus(reverse(v949), ctbl[21], ctimes(v949, ctbl[20])); + real2 v955 = ctimesminusplus(reverse(v947), ctbl[14], ctimes(v947, ctbl[15])); + real2 v1079 = plus(v950, v951); + real2 v1073 = reverse(minus(v951, v950)); + real2 v73 = load(in, 71 << shift); + real2 v9 = load(in, 7 << shift); + real2 v268 = plus(v9, v73); + real2 v264 = minus(v73, v9); + real2 v105 = load(in, 103 << shift); + real2 v41 = load(in, 39 << shift); + real2 v269 = plus(v41, v105); + real2 v263 = reverse(minus(v105, v41)); + real2 v818 = minus(v269, v268); + real2 v822 = plus(v268, v269); + real2 v267 = minusplus(uminus(v263), v264); + real2 v265 = minusplus(v263, v264); + real2 v275 = ctimesminusplus(reverse(v265), ctbl[36], ctimes(v265, ctbl[37])); + real2 v89 = load(in, 87 << shift); + real2 v25 = load(in, 23 << shift); + real2 v557 = plus(v25, v89); + real2 v553 = minus(v89, v25); + real2 v121 = load(in, 119 << shift); + real2 v57 = load(in, 55 << shift); + real2 v558 = plus(v57, v121); + real2 v552 = reverse(minus(v121, v57)); + real2 v823 = plus(v557, v558); + real2 v817 = reverse(minus(v558, v557)); + real2 v1078 = plus(v822, v823); + real2 v1074 = minus(v823, v822); + real2 v819 = minusplus(v817, v818); + real2 v821 = minusplus(uminus(v817), v818); + real2 v1077 = minusplus(uminus(v1073), v1074); + real2 v1075 = minusplus(v1073, v1074); + real2 v1083 = ctimesminusplus(reverse(v1075), ctbl[6], ctimes(v1075, ctbl[7])); + real2 v1087 = ctimesminusplus(reverse(v1077), ctbl[9], ctimes(v1077, ctbl[8])); + real2 v556 = minusplus(uminus(v552), v553); + real2 v554 = minusplus(v552, v553); + real2 v564 = ctimesminusplus(reverse(v554), ctbl[34], ctimes(v554, ctbl[35])); + real2 v1793 = minus(v564, v275); + real2 v1797 = plus(v275, v564); + real2 v1862 = plus(v1797, v1798); + real2 v1856 = reverse(minus(v1798, v1797)); + real2 v1794 = minusplus(v1792, v1793); + real2 v1796 = minusplus(uminus(v1792), v1793); + real2 v827 = ctimesminusplus(reverse(v819), ctbl[16], ctimes(v819, ctbl[17])); + real2 v1410 = reverse(minus(v955, v827)); + real2 v1416 = plus(v827, v955); + real2 v1143 = plus(v1078, v1079); + real2 v1137 = reverse(minus(v1079, v1078)); + real2 v831 = ctimesminusplus(reverse(v821), ctbl[18], ctimes(v821, ctbl[24])); + real2 v1575 = plus(v831, v959); + real2 v1569 = reverse(minus(v959, v831)); + real2 v5 = load(in, 3 << shift); + real2 v69 = load(in, 67 << shift); + real2 v188 = minus(v69, v5); + real2 v192 = plus(v5, v69); + real2 v101 = load(in, 99 << shift); + real2 v37 = load(in, 35 << shift); + real2 v193 = plus(v37, v101); + real2 v187 = reverse(minus(v101, v37)); + real2 v754 = minus(v193, v192); + real2 v758 = plus(v192, v193); + real2 v189 = minusplus(v187, v188); + real2 v191 = minusplus(uminus(v187), v188); + real2 v197 = ctimesminusplus(reverse(v189), ctbl[44], ctimes(v189, ctbl[45])); + real2 v21 = load(in, 19 << shift); + real2 v85 = load(in, 83 << shift); + real2 v485 = minus(v85, v21); + real2 v489 = plus(v21, v85); + real2 v53 = load(in, 51 << shift); + real2 v117 = load(in, 115 << shift); + real2 v484 = reverse(minus(v117, v53)); + real2 v490 = plus(v53, v117); + real2 v753 = reverse(minus(v490, v489)); + real2 v759 = plus(v489, v490); + real2 v757 = minusplus(uminus(v753), v754); + real2 v755 = minusplus(v753, v754); + real2 v767 = ctimesminusplus(reverse(v757), ctbl[26], ctimes(v757, ctbl[27])); + real2 v763 = ctimesminusplus(reverse(v755), ctbl[20], ctimes(v755, ctbl[21])); + real2 v486 = minusplus(v484, v485); + real2 v488 = minusplus(uminus(v484), v485); + real2 v495 = ctimesminusplus(reverse(v486), ctbl[42], ctimes(v486, ctbl[43])); + real2 v1729 = minus(v495, v197); + real2 v1733 = plus(v197, v495); + real2 v1014 = plus(v758, v759); + real2 v1010 = minus(v759, v758); + real2 v13 = load(in, 11 << shift); + real2 v77 = load(in, 75 << shift); + real2 v342 = minus(v77, v13); + real2 v346 = plus(v13, v77); + real2 v45 = load(in, 43 << shift); + real2 v109 = load(in, 107 << shift); + real2 v347 = plus(v45, v109); + real2 v341 = reverse(minus(v109, v45)); + real2 v345 = minusplus(uminus(v341), v342); + real2 v343 = minusplus(v341, v342); + real2 v882 = minus(v347, v346); + real2 v886 = plus(v346, v347); + real2 v353 = ctimesminusplus(reverse(v343), ctbl[40], ctimes(v343, ctbl[41])); + real2 v125 = load(in, 123 << shift); + real2 v61 = load(in, 59 << shift); + real2 v621 = reverse(minus(v125, v61)); + real2 v627 = plus(v61, v125); + real2 v93 = load(in, 91 << shift); + real2 v29 = load(in, 27 << shift); + real2 v622 = minus(v93, v29); + real2 v626 = plus(v29, v93); + real2 v887 = plus(v626, v627); + real2 v881 = reverse(minus(v627, v626)); + real2 v885 = minusplus(uminus(v881), v882); + real2 v883 = minusplus(v881, v882); + real2 v891 = ctimesminusplus(reverse(v883), ctbl[18], ctimes(v883, ctbl[19])); + real2 v1009 = reverse(minus(v887, v886)); + real2 v1015 = plus(v886, v887); + real2 v1415 = plus(v763, v891); + real2 v1411 = minus(v891, v763); + real2 v895 = ctimesminusplus(reverse(v885), ctbl[15], ctimes(v885, ctbl[14])); + real2 v1570 = minus(v895, v767); + real2 v1574 = plus(v767, v895); + real2 v1142 = plus(v1014, v1015); + real2 v1138 = minus(v1015, v1014); + real2 v1011 = minusplus(v1009, v1010); + real2 v1013 = minusplus(uminus(v1009), v1010); + real2 v1023 = ctimesminusplus(reverse(v1013), ctbl[6], ctimes(v1013, ctbl[12])); + real2 v1019 = ctimesminusplus(reverse(v1011), ctbl[8], ctimes(v1011, ctbl[9])); + real2 v1321 = reverse(minus(v1087, v1023)); + real2 v1327 = plus(v1023, v1087); + real2 v1414 = minusplus(uminus(v1410), v1411); + real2 v1412 = minusplus(v1410, v1411); + real2 v1424 = ctimesminusplus(reverse(v1414), ctbl[3], ctimes(v1414, ctbl[2])); + real2 v1508 = plus(v1392, v1424); + real2 v1502 = reverse(minus(v1424, v1392)); + real2 v1264 = reverse(minus(v1083, v1019)); + real2 v1270 = plus(v1019, v1083); + real2 v1286 = plus(v1269, v1270); + real2 v1280 = reverse(minus(v1270, v1269)); + real2 v1268 = minusplus(uminus(v1264), v1265); + real2 v1266 = minusplus(v1264, v1265); + real2 v1141 = minusplus(uminus(v1137), v1138); + real2 v1139 = minusplus(v1137, v1138); + real2 v1147 = ctimesminusplus(reverse(v1139), ctbl[2], ctimes(v1139, ctbl[3])); + real2 v1278 = ctimesminusplus(reverse(v1268), ctbl[0], ctimes(v1268, ctbl[0])); + real2 v1151 = ctimesminusplus(reverse(v1141), ctbl[3], ctimes(v1141, ctbl[2])); + real2 v1235 = plus(v1119, v1151); + real2 v1229 = reverse(minus(v1151, v1119)); + real2 v1420 = ctimesminusplus(reverse(v1412), ctbl[2], ctimes(v1412, ctbl[3])); + real2 v1483 = reverse(minus(v1420, v1388)); + real2 v1489 = plus(v1388, v1420); + real2 v1274 = ctimesminusplus(reverse(v1266), ctbl[0], ctimes(v1266, ctbl[1])); + real2 v1607 = plus(v1574, v1575); + real2 v1601 = reverse(minus(v1575, v1574)); + real2 v1605 = minusplus(uminus(v1601), v1602); + real2 v1603 = minusplus(v1601, v1602); + real2 v1175 = plus(v1142, v1143); + real2 v1169 = reverse(minus(v1143, v1142)); + real2 v1171 = minusplus(v1169, v1170); + real2 v1173 = minusplus(uminus(v1169), v1170); + real2 v1179 = ctimesminusplus(reverse(v1171), ctbl[0], ctimes(v1171, ctbl[1])); + real2 v1191 = plus(v1174, v1175); + real2 v1185 = reverse(minus(v1175, v1174)); + real2 v1325 = minusplus(uminus(v1321), v1322); + real2 v1323 = minusplus(v1321, v1322); + real2 v1331 = ctimesminusplus(reverse(v1323), ctbl[0], ctimes(v1323, ctbl[1])); + real2 v1448 = plus(v1415, v1416); + real2 v1442 = reverse(minus(v1416, v1415)); + real2 v1446 = minusplus(uminus(v1442), v1443); + real2 v1444 = minusplus(v1442, v1443); + real2 v1452 = ctimesminusplus(reverse(v1444), ctbl[0], ctimes(v1444, ctbl[1])); + real2 v1464 = plus(v1447, v1448); + real2 v1458 = reverse(minus(v1448, v1447)); + real2 v1335 = ctimesminusplus(reverse(v1325), ctbl[0], ctimes(v1325, ctbl[0])); + real2 v1337 = reverse(minus(v1327, v1326)); + real2 v1343 = plus(v1326, v1327); + real2 v1183 = ctimesminusplus(reverse(v1173), ctbl[0], ctimes(v1173, ctbl[0])); + real2 v1456 = ctimesminusplus(reverse(v1446), ctbl[0], ctimes(v1446, ctbl[0])); + real2 v1210 = reverse(minus(v1147, v1115)); + real2 v1216 = plus(v1115, v1147); + real2 v1623 = plus(v1606, v1607); + real2 v1617 = reverse(minus(v1607, v1606)); + real2 v1571 = minusplus(v1569, v1570); + real2 v1573 = minusplus(uminus(v1569), v1570); + real2 v1583 = ctimesminusplus(reverse(v1573), ctbl[3], ctimes(v1573, ctbl[2])); + real2 v1661 = reverse(minus(v1583, v1551)); + real2 v1667 = plus(v1551, v1583); + real2 v1611 = ctimesminusplus(reverse(v1603), ctbl[0], ctimes(v1603, ctbl[1])); + real2 v1615 = ctimesminusplus(reverse(v1605), ctbl[0], ctimes(v1605, ctbl[0])); + real2 v1579 = ctimesminusplus(reverse(v1571), ctbl[2], ctimes(v1571, ctbl[3])); + real2 v1648 = plus(v1547, v1579); + real2 v1642 = reverse(minus(v1579, v1547)); + real2 v92 = load(in, 90 << shift); + real2 v28 = load(in, 26 << shift); + real2 v604 = minus(v92, v28); + real2 v608 = plus(v28, v92); + real2 v60 = load(in, 58 << shift); + real2 v124 = load(in, 122 << shift); + real2 v603 = reverse(minus(v124, v60)); + real2 v609 = plus(v60, v124); + real2 v871 = plus(v608, v609); + real2 v865 = reverse(minus(v609, v608)); + real2 v76 = load(in, 74 << shift); + real2 v12 = load(in, 10 << shift); + real2 v322 = minus(v76, v12); + real2 v326 = plus(v12, v76); + real2 v108 = load(in, 106 << shift); + real2 v44 = load(in, 42 << shift); + real2 v321 = reverse(minus(v108, v44)); + real2 v327 = plus(v44, v108); + real2 v870 = plus(v326, v327); + real2 v866 = minus(v327, v326); + real2 v993 = reverse(minus(v871, v870)); + real2 v999 = plus(v870, v871); + real2 v869 = minusplus(uminus(v865), v866); + real2 v867 = minusplus(v865, v866); + real2 v875 = ctimesminusplus(reverse(v867), ctbl[10], ctimes(v867, ctbl[11])); + real2 v879 = ctimesminusplus(reverse(v869), ctbl[12], ctimes(v869, ctbl[6])); + real2 v36 = load(in, 34 << shift); + real2 v100 = load(in, 98 << shift); + real2 v167 = reverse(minus(v100, v36)); + real2 v173 = plus(v36, v100); + real2 v68 = load(in, 66 << shift); + real2 v4 = load(in, 2 << shift); + real2 v168 = minus(v68, v4); + real2 v172 = plus(v4, v68); + real2 v742 = plus(v172, v173); + real2 v738 = minus(v173, v172); + real2 v52 = load(in, 50 << shift); + real2 v116 = load(in, 114 << shift); + real2 v468 = reverse(minus(v116, v52)); + real2 v474 = plus(v52, v116); + real2 v84 = load(in, 82 << shift); + real2 v20 = load(in, 18 << shift); + real2 v469 = minus(v84, v20); + real2 v473 = plus(v20, v84); + real2 v743 = plus(v473, v474); + real2 v737 = reverse(minus(v474, v473)); + real2 v739 = minusplus(v737, v738); + real2 v741 = minusplus(uminus(v737), v738); + real2 v747 = ctimesminusplus(reverse(v739), ctbl[12], ctimes(v739, ctbl[13])); + real2 v998 = plus(v742, v743); + real2 v994 = minus(v743, v742); + real2 v1399 = plus(v747, v875); + real2 v1395 = minus(v875, v747); + real2 v1122 = minus(v999, v998); + real2 v1126 = plus(v998, v999); + real2 v997 = minusplus(uminus(v993), v994); + real2 v995 = minusplus(v993, v994); + real2 v1003 = ctimesminusplus(reverse(v995), ctbl[4], ctimes(v995, ctbl[5])); + real2 v1007 = ctimesminusplus(reverse(v997), ctbl[2], ctimes(v997, ctbl[3])); + real2 v80 = load(in, 78 << shift); + real2 v16 = load(in, 14 << shift); + real2 v397 = minus(v80, v16); + real2 v401 = plus(v16, v80); + real2 v48 = load(in, 46 << shift); + real2 v112 = load(in, 110 << shift); + real2 v402 = plus(v48, v112); + real2 v396 = reverse(minus(v112, v48)); + real2 v934 = plus(v401, v402); + real2 v930 = minus(v402, v401); + real2 v96 = load(in, 94 << shift); + real2 v32 = load(in, 30 << shift); + real2 v673 = minus(v96, v32); + real2 v677 = plus(v32, v96); + real2 v64 = load(in, 62 << shift); + real2 v128 = load(in, 126 << shift); + real2 v678 = plus(v64, v128); + real2 v672 = reverse(minus(v128, v64)); + real2 v929 = reverse(minus(v678, v677)); + real2 v935 = plus(v677, v678); + real2 v933 = minusplus(uminus(v929), v930); + real2 v931 = minusplus(v929, v930); + real2 v1057 = reverse(minus(v935, v934)); + real2 v1063 = plus(v934, v935); + real2 v939 = ctimesminusplus(reverse(v931), ctbl[6], ctimes(v931, ctbl[7])); + real2 v104 = load(in, 102 << shift); + real2 v40 = load(in, 38 << shift); + real2 v251 = plus(v40, v104); + real2 v245 = reverse(minus(v104, v40)); + real2 v72 = load(in, 70 << shift); + real2 v8 = load(in, 6 << shift); + real2 v246 = minus(v72, v8); + real2 v250 = plus(v8, v72); + real2 v802 = minus(v251, v250); + real2 v806 = plus(v250, v251); + real2 v88 = load(in, 86 << shift); + real2 v24 = load(in, 22 << shift); + real2 v540 = plus(v24, v88); + real2 v536 = minus(v88, v24); + real2 v120 = load(in, 118 << shift); + real2 v56 = load(in, 54 << shift); + real2 v541 = plus(v56, v120); + real2 v535 = reverse(minus(v120, v56)); + real2 v807 = plus(v540, v541); + real2 v801 = reverse(minus(v541, v540)); + real2 v1062 = plus(v806, v807); + real2 v1058 = minus(v807, v806); + real2 v1059 = minusplus(v1057, v1058); + real2 v1061 = minusplus(uminus(v1057), v1058); + real2 v1127 = plus(v1062, v1063); + real2 v1121 = reverse(minus(v1063, v1062)); + real2 v1071 = ctimesminusplus(reverse(v1061), ctbl[3], ctimes(v1061, ctbl[2])); + real2 v1067 = ctimesminusplus(reverse(v1059), ctbl[2], ctimes(v1059, ctbl[3])); + real2 v1153 = reverse(minus(v1127, v1126)); + real2 v1159 = plus(v1126, v1127); + real2 v1123 = minusplus(v1121, v1122); + real2 v1125 = minusplus(uminus(v1121), v1122); + real2 v1254 = plus(v1003, v1067); + real2 v1248 = reverse(minus(v1067, v1003)); + real2 v1131 = ctimesminusplus(reverse(v1123), ctbl[0], ctimes(v1123, ctbl[1])); + real2 v1305 = reverse(minus(v1071, v1007)); + real2 v1311 = plus(v1007, v1071); + real2 v1135 = ctimesminusplus(reverse(v1125), ctbl[0], ctimes(v1125, ctbl[0])); + real2 v42 = load(in, 40 << shift); + real2 v106 = load(in, 104 << shift); + real2 v283 = reverse(minus(v106, v42)); + real2 v289 = plus(v42, v106); + real2 v10 = load(in, 8 << shift); + real2 v74 = load(in, 72 << shift); + real2 v284 = minus(v74, v10); + real2 v288 = plus(v10, v74); + real2 v838 = plus(v288, v289); + real2 v834 = minus(v289, v288); + real2 v66 = load(in, 64 << shift); + real2 v2 = load(in, 0 << shift); + real2 v132 = minus(v66, v2); + real2 v136 = plus(v2, v66); + real2 v98 = load(in, 96 << shift); + real2 v34 = load(in, 32 << shift); + real2 v131 = reverse(minus(v98, v34)); + real2 v137 = plus(v34, v98); + real2 v706 = minus(v137, v136); + real2 v710 = plus(v136, v137); + real2 v122 = load(in, 120 << shift); + real2 v58 = load(in, 56 << shift); + real2 v570 = reverse(minus(v122, v58)); + real2 v576 = plus(v58, v122); + real2 v90 = load(in, 88 << shift); + real2 v26 = load(in, 24 << shift); + real2 v575 = plus(v26, v90); + real2 v571 = minus(v90, v26); + real2 v839 = plus(v575, v576); + real2 v833 = reverse(minus(v576, v575)); + real2 v961 = reverse(minus(v839, v838)); + real2 v967 = plus(v838, v839); + real2 v50 = load(in, 48 << shift); + real2 v114 = load(in, 112 << shift); + real2 v438 = plus(v50, v114); + real2 v432 = reverse(minus(v114, v50)); + real2 v82 = load(in, 80 << shift); + real2 v18 = load(in, 16 << shift); + real2 v433 = minus(v82, v18); + real2 v437 = plus(v18, v82); + real2 v705 = reverse(minus(v438, v437)); + real2 v711 = plus(v437, v438); + real2 v962 = minus(v711, v710); + real2 v966 = plus(v710, v711); + real2 v1094 = plus(v966, v967); + real2 v1090 = minus(v967, v966); + real2 v126 = load(in, 124 << shift); + real2 v62 = load(in, 60 << shift); + real2 v643 = plus(v62, v126); + real2 v637 = reverse(minus(v126, v62)); + real2 v30 = load(in, 28 << shift); + real2 v94 = load(in, 92 << shift); + real2 v638 = minus(v94, v30); + real2 v642 = plus(v30, v94); + real2 v903 = plus(v642, v643); + real2 v897 = reverse(minus(v643, v642)); + real2 v14 = load(in, 12 << shift); + real2 v78 = load(in, 76 << shift); + real2 v361 = minus(v78, v14); + real2 v365 = plus(v14, v78); + real2 v46 = load(in, 44 << shift); + real2 v110 = load(in, 108 << shift); + real2 v360 = reverse(minus(v110, v46)); + real2 v366 = plus(v46, v110); + real2 v898 = minus(v366, v365); + real2 v902 = plus(v365, v366); + real2 v1031 = plus(v902, v903); + real2 v1025 = reverse(minus(v903, v902)); + real2 v102 = load(in, 100 << shift); + real2 v38 = load(in, 36 << shift); + real2 v205 = reverse(minus(v102, v38)); + real2 v211 = plus(v38, v102); + real2 v70 = load(in, 68 << shift); + real2 v6 = load(in, 4 << shift); + real2 v210 = plus(v6, v70); + real2 v206 = minus(v70, v6); + real2 v770 = minus(v211, v210); + real2 v774 = plus(v210, v211); + real2 v86 = load(in, 84 << shift); + real2 v22 = load(in, 20 << shift); + real2 v502 = minus(v86, v22); + real2 v506 = plus(v22, v86); + real2 v118 = load(in, 116 << shift); + real2 v54 = load(in, 52 << shift); + real2 v501 = reverse(minus(v118, v54)); + real2 v507 = plus(v54, v118); + real2 v769 = reverse(minus(v507, v506)); + real2 v775 = plus(v506, v507); + real2 v1030 = plus(v774, v775); + real2 v1026 = minus(v775, v774); + real2 v1089 = reverse(minus(v1031, v1030)); + real2 v1095 = plus(v1030, v1031); + real2 v1099 = minus(uplusminus(v1089), v1090); + real2 v1103 = minus(uminusplus(v1089), v1090); + real2 v1215 = plus(v1099, v1131); + store(out, 72 << shift, minus(v1215, v1216)); + store(out, 8 << shift, plus(v1215, v1216)); + real2 v1211 = minus(v1131, v1099); + store(out, 40 << shift, minus(uplusminus(v1210), v1211)); + store(out, 104 << shift, minus(uminusplus(v1210), v1211)); + real2 v1234 = plus(v1103, v1135); + real2 v1230 = minus(v1135, v1103); + store(out, 120 << shift, minus(uminusplus(v1229), v1230)); + store(out, 56 << shift, minus(uplusminus(v1229), v1230)); + store(out, 24 << shift, plus(v1234, v1235)); + store(out, 88 << shift, minus(v1234, v1235)); + real2 v1154 = minus(v1095, v1094); + real2 v1158 = plus(v1094, v1095); + real2 v1167 = minus(uminusplus(v1153), v1154); + real2 v1163 = minus(uplusminus(v1153), v1154); + store(out, 16 << shift, plus(v1163, v1179)); + store(out, 80 << shift, minus(v1163, v1179)); + store(out, 48 << shift, plus(v1167, v1183)); + store(out, 112 << shift, minus(v1167, v1183)); + real2 v1186 = minus(v1159, v1158); + real2 v1190 = plus(v1158, v1159); + store(out, 0 << shift, plus(v1190, v1191)); + store(out, 64 << shift, minus(v1190, v1191)); + store(out, 32 << shift, minus(uplusminus(v1185), v1186)); + store(out, 96 << shift, minus(uminusplus(v1185), v1186)); + real2 v1027 = minusplus(v1025, v1026); + real2 v1029 = minusplus(uminus(v1025), v1026); + real2 v971 = minus(uplusminus(v961), v962); + real2 v975 = minus(uminusplus(v961), v962); + real2 v1039 = ctimesminusplus(reverse(v1029), ctbl[0], ctimes(v1029, ctbl[0])); + real2 v1310 = plus(v975, v1039); + real2 v1306 = minus(v1039, v975); + real2 v1342 = plus(v1310, v1311); + real2 v1338 = minus(v1311, v1310); + store(out, 12 << shift, plus(v1342, v1343)); + store(out, 76 << shift, minus(v1342, v1343)); + store(out, 108 << shift, minus(uminusplus(v1337), v1338)); + store(out, 44 << shift, minus(uplusminus(v1337), v1338)); + real2 v1315 = minus(uplusminus(v1305), v1306); + store(out, 28 << shift, plus(v1315, v1331)); + store(out, 92 << shift, minus(v1315, v1331)); + real2 v1319 = minus(uminusplus(v1305), v1306); + store(out, 60 << shift, plus(v1319, v1335)); + store(out, 124 << shift, minus(v1319, v1335)); + real2 v1035 = ctimesminusplus(reverse(v1027), ctbl[0], ctimes(v1027, ctbl[1])); + real2 v1253 = plus(v971, v1035); + real2 v1249 = minus(v1035, v971); + real2 v1281 = minus(v1254, v1253); + store(out, 36 << shift, minus(uplusminus(v1280), v1281)); + store(out, 100 << shift, minus(uminusplus(v1280), v1281)); + real2 v1285 = plus(v1253, v1254); + store(out, 68 << shift, minus(v1285, v1286)); + store(out, 4 << shift, plus(v1285, v1286)); + real2 v1262 = minus(uminusplus(v1248), v1249); + store(out, 116 << shift, minus(v1262, v1278)); + store(out, 52 << shift, plus(v1262, v1278)); + real2 v1258 = minus(uplusminus(v1248), v1249); + store(out, 20 << shift, plus(v1258, v1274)); + store(out, 84 << shift, minus(v1258, v1274)); + real2 v901 = minusplus(uminus(v897), v898); + real2 v899 = minusplus(v897, v898); + real2 v805 = minusplus(uminus(v801), v802); + real2 v803 = minusplus(v801, v802); + real2 v811 = ctimesminusplus(reverse(v803), ctbl[8], ctimes(v803, ctbl[9])); + real2 v1400 = plus(v811, v939); + real2 v1394 = reverse(minus(v939, v811)); + real2 v837 = minusplus(uminus(v833), v834); + real2 v835 = minusplus(v833, v834); + real2 v843 = ctimesminusplus(reverse(v835), ctbl[0], ctimes(v835, ctbl[1])); + real2 v773 = minusplus(uminus(v769), v770); + real2 v771 = minusplus(v769, v770); + real2 v1398 = minusplus(uminus(v1394), v1395); + real2 v1396 = minusplus(v1394, v1395); + real2 v907 = ctimesminusplus(reverse(v899), ctbl[2], ctimes(v899, ctbl[3])); + real2 v715 = minus(uplusminus(v705), v706); + real2 v719 = minus(uminusplus(v705), v706); + real2 v1363 = minus(v843, v715); + real2 v1367 = plus(v715, v843); + real2 v1408 = ctimesminusplus(reverse(v1398), ctbl[0], ctimes(v1398, ctbl[0])); + real2 v779 = ctimesminusplus(reverse(v771), ctbl[4], ctimes(v771, ctbl[5])); + real2 v1362 = reverse(minus(v907, v779)); + real2 v1368 = plus(v779, v907); + real2 v1376 = minus(uminusplus(v1362), v1363); + real2 v1372 = minus(uplusminus(v1362), v1363); + real2 v1507 = plus(v1376, v1408); + real2 v1503 = minus(v1408, v1376); + store(out, 122 << shift, minus(uminusplus(v1502), v1503)); + store(out, 58 << shift, minus(uplusminus(v1502), v1503)); + store(out, 90 << shift, minus(v1507, v1508)); + store(out, 26 << shift, plus(v1507, v1508)); + real2 v1404 = ctimesminusplus(reverse(v1396), ctbl[0], ctimes(v1396, ctbl[1])); + real2 v1484 = minus(v1404, v1372); + real2 v1488 = plus(v1372, v1404); + store(out, 10 << shift, plus(v1488, v1489)); + store(out, 74 << shift, minus(v1488, v1489)); + store(out, 106 << shift, minus(uminusplus(v1483), v1484)); + store(out, 42 << shift, minus(uplusminus(v1483), v1484)); + real2 v1426 = reverse(minus(v1400, v1399)); + real2 v1432 = plus(v1399, v1400); + real2 v1431 = plus(v1367, v1368); + real2 v1427 = minus(v1368, v1367); + real2 v1463 = plus(v1431, v1432); + store(out, 66 << shift, minus(v1463, v1464)); + store(out, 2 << shift, plus(v1463, v1464)); + real2 v1459 = minus(v1432, v1431); + store(out, 98 << shift, minus(uminusplus(v1458), v1459)); + store(out, 34 << shift, minus(uplusminus(v1458), v1459)); + real2 v1436 = minus(uplusminus(v1426), v1427); + store(out, 82 << shift, minus(v1436, v1452)); + store(out, 18 << shift, plus(v1436, v1452)); + real2 v1440 = minus(uminusplus(v1426), v1427); + store(out, 50 << shift, plus(v1440, v1456)); + store(out, 114 << shift, minus(v1440, v1456)); + real2 v911 = ctimesminusplus(reverse(v901), ctbl[3], ctimes(v901, ctbl[2])); + real2 v783 = ctimesminusplus(reverse(v773), ctbl[2], ctimes(v773, ctbl[3])); + real2 v1527 = plus(v783, v911); + real2 v1521 = reverse(minus(v911, v783)); + real2 v943 = ctimesminusplus(reverse(v933), ctbl[9], ctimes(v933, ctbl[8])); + real2 v847 = ctimesminusplus(reverse(v837), ctbl[0], ctimes(v837, ctbl[0])); + real2 v1522 = minus(v847, v719); + real2 v1526 = plus(v719, v847); + real2 v1590 = plus(v1526, v1527); + real2 v1586 = minus(v1527, v1526); + real2 v815 = ctimesminusplus(reverse(v805), ctbl[6], ctimes(v805, ctbl[12])); + real2 v1559 = plus(v815, v943); + real2 v1553 = reverse(minus(v943, v815)); + real2 v751 = ctimesminusplus(reverse(v741), ctbl[8], ctimes(v741, ctbl[9])); + real2 v1558 = plus(v751, v879); + real2 v1554 = minus(v879, v751); + real2 v1585 = reverse(minus(v1559, v1558)); + real2 v1591 = plus(v1558, v1559); + real2 v1618 = minus(v1591, v1590); + real2 v1622 = plus(v1590, v1591); + store(out, 70 << shift, minus(v1622, v1623)); + store(out, 6 << shift, plus(v1622, v1623)); + store(out, 102 << shift, minus(uminusplus(v1617), v1618)); + store(out, 38 << shift, minus(uplusminus(v1617), v1618)); + real2 v1599 = minus(uminusplus(v1585), v1586); + real2 v1595 = minus(uplusminus(v1585), v1586); + store(out, 22 << shift, plus(v1595, v1611)); + store(out, 86 << shift, minus(v1595, v1611)); + store(out, 54 << shift, plus(v1599, v1615)); + store(out, 118 << shift, minus(v1599, v1615)); + real2 v1555 = minusplus(v1553, v1554); + real2 v1557 = minusplus(uminus(v1553), v1554); + real2 v1531 = minus(uplusminus(v1521), v1522); + real2 v1535 = minus(uminusplus(v1521), v1522); + real2 v1567 = ctimesminusplus(reverse(v1557), ctbl[0], ctimes(v1557, ctbl[0])); + real2 v1666 = plus(v1535, v1567); + store(out, 94 << shift, minus(v1666, v1667)); + store(out, 30 << shift, plus(v1666, v1667)); + real2 v1662 = minus(v1567, v1535); + store(out, 126 << shift, minus(uminusplus(v1661), v1662)); + store(out, 62 << shift, minus(uplusminus(v1661), v1662)); + real2 v1563 = ctimesminusplus(reverse(v1555), ctbl[0], ctimes(v1555, ctbl[1])); + real2 v1643 = minus(v1563, v1531); + store(out, 46 << shift, minus(uplusminus(v1642), v1643)); + store(out, 110 << shift, minus(uminusplus(v1642), v1643)); + real2 v1647 = plus(v1531, v1563); + store(out, 78 << shift, minus(v1647, v1648)); + store(out, 14 << shift, plus(v1647, v1648)); + real2 v436 = minusplus(uminus(v432), v433); + real2 v434 = minusplus(v432, v433); + real2 v145 = minus(uminusplus(v131), v132); + real2 v141 = minus(uplusminus(v131), v132); + real2 v607 = minusplus(uminus(v603), v604); + real2 v605 = minusplus(v603, v604); + real2 v615 = ctimesminusplus(reverse(v605), ctbl[22], ctimes(v605, ctbl[23])); + real2 v325 = minusplus(uminus(v321), v322); + real2 v323 = minusplus(v321, v322); + real2 v171 = minusplus(uminus(v167), v168); + real2 v169 = minusplus(v167, v168); + real2 v179 = ctimesminusplus(reverse(v169), ctbl[28], ctimes(v169, ctbl[29])); + real2 v333 = ctimesminusplus(reverse(v323), ctbl[24], ctimes(v323, ctbl[25])); + real2 v1718 = plus(v333, v615); + real2 v1712 = reverse(minus(v615, v333)); + real2 v470 = minusplus(v468, v469); + real2 v472 = minusplus(uminus(v468), v469); + real2 v478 = ctimesminusplus(reverse(v470), ctbl[26], ctimes(v470, ctbl[27])); + real2 v1717 = plus(v179, v478); + real2 v1713 = minus(v478, v179); + real2 v1841 = minus(v1718, v1717); + real2 v1845 = plus(v1717, v1718); + real2 v674 = minusplus(v672, v673); + real2 v676 = minusplus(uminus(v672), v673); + real2 v249 = minusplus(uminus(v245), v246); + real2 v247 = minusplus(v245, v246); + real2 v255 = ctimesminusplus(reverse(v247), ctbl[20], ctimes(v247, ctbl[21])); + real2 v398 = minusplus(v396, v397); + real2 v400 = minusplus(uminus(v396), v397); + real2 v408 = ctimesminusplus(reverse(v398), ctbl[16], ctimes(v398, ctbl[17])); + real2 v572 = minusplus(v570, v571); + real2 v574 = minusplus(uminus(v570), v571); + real2 v625 = minusplus(uminus(v621), v622); + real2 v623 = minusplus(v621, v622); + real2 v631 = ctimesminusplus(reverse(v623), ctbl[38], ctimes(v623, ctbl[39])); + real2 v1728 = reverse(minus(v631, v353)); + real2 v1734 = plus(v353, v631); + real2 v1857 = minus(v1734, v1733); + real2 v1861 = plus(v1733, v1734); + real2 v580 = ctimesminusplus(reverse(v572), ctbl[2], ctimes(v572, ctbl[3])); + real2 v537 = minusplus(v535, v536); + real2 v539 = minusplus(uminus(v535), v536); + real2 v546 = ctimesminusplus(reverse(v537), ctbl[18], ctimes(v537, ctbl[19])); + real2 v682 = ctimesminusplus(reverse(v674), ctbl[14], ctimes(v674, ctbl[15])); + real2 v1776 = reverse(minus(v682, v408)); + real2 v1782 = plus(v408, v682); + real2 v641 = minusplus(uminus(v637), v638); + real2 v639 = minusplus(v637, v638); + real2 v287 = minusplus(uminus(v283), v284); + real2 v285 = minusplus(v283, v284); + real2 v295 = ctimesminusplus(reverse(v285), ctbl[4], ctimes(v285, ctbl[5])); + real2 v1680 = reverse(minus(v580, v295)); + real2 v1686 = plus(v295, v580); + real2 v505 = minusplus(uminus(v501), v502); + real2 v503 = minusplus(v501, v502); + real2 v513 = ctimesminusplus(reverse(v503), ctbl[10], ctimes(v503, ctbl[11])); + real2 v444 = ctimesminusplus(reverse(v434), ctbl[0], ctimes(v434, ctbl[1])); + real2 v648 = ctimesminusplus(reverse(v639), ctbl[6], ctimes(v639, ctbl[7])); + real2 v1685 = plus(v141, v444); + real2 v1681 = minus(v444, v141); + real2 v1888 = reverse(minus(v1862, v1861)); + real2 v1894 = plus(v1861, v1862); + real2 v1910 = plus(v1893, v1894); + real2 v1904 = reverse(minus(v1894, v1893)); + real2 v1813 = plus(v1685, v1686); + real2 v1809 = minus(v1686, v1685); + real2 v1777 = minus(v546, v255); + real2 v1781 = plus(v255, v546); + real2 v207 = minusplus(v205, v206); + real2 v209 = minusplus(uminus(v205), v206); + real2 v1840 = reverse(minus(v1782, v1781)); + real2 v1846 = plus(v1781, v1782); + real2 v1878 = plus(v1845, v1846); + real2 v1872 = reverse(minus(v1846, v1845)); + real2 v364 = minusplus(uminus(v360), v361); + real2 v362 = minusplus(v360, v361); + real2 v370 = ctimesminusplus(reverse(v362), ctbl[8], ctimes(v362, ctbl[9])); + real2 v1744 = reverse(minus(v648, v370)); + real2 v1750 = plus(v370, v648); + real2 v217 = ctimesminusplus(reverse(v207), ctbl[12], ctimes(v207, ctbl[13])); + real2 v1749 = plus(v217, v513); + real2 v1745 = minus(v513, v217); + real2 v1814 = plus(v1749, v1750); + real2 v1808 = reverse(minus(v1750, v1749)); + real2 v1877 = plus(v1813, v1814); + real2 v1873 = minus(v1814, v1813); + real2 v1905 = minus(v1878, v1877); + real2 v1909 = plus(v1877, v1878); + store(out, 33 << shift, minus(uplusminus(v1904), v1905)); + store(out, 97 << shift, minus(uminusplus(v1904), v1905)); + store(out, 65 << shift, minus(v1909, v1910)); + store(out, 1 << shift, plus(v1909, v1910)); + real2 v1890 = minusplus(v1888, v1889); + real2 v1892 = minusplus(uminus(v1888), v1889); + real2 v1902 = ctimesminusplus(reverse(v1892), ctbl[0], ctimes(v1892, ctbl[0])); + real2 v1886 = minus(uminusplus(v1872), v1873); + store(out, 49 << shift, plus(v1886, v1902)); + store(out, 113 << shift, minus(v1886, v1902)); + real2 v1882 = minus(uplusminus(v1872), v1873); + real2 v1898 = ctimesminusplus(reverse(v1890), ctbl[0], ctimes(v1890, ctbl[1])); + store(out, 81 << shift, minus(v1882, v1898)); + store(out, 17 << shift, plus(v1882, v1898)); + real2 v1858 = minusplus(v1856, v1857); + real2 v1860 = minusplus(uminus(v1856), v1857); + real2 v1870 = ctimesminusplus(reverse(v1860), ctbl[3], ctimes(v1860, ctbl[2])); + real2 v1948 = reverse(minus(v1870, v1838)); + real2 v1954 = plus(v1838, v1870); + real2 v1822 = minus(uminusplus(v1808), v1809); + real2 v1818 = minus(uplusminus(v1808), v1809); + real2 v1842 = minusplus(v1840, v1841); + real2 v1844 = minusplus(uminus(v1840), v1841); + real2 v1854 = ctimesminusplus(reverse(v1844), ctbl[0], ctimes(v1844, ctbl[0])); + real2 v1949 = minus(v1854, v1822); + store(out, 121 << shift, minus(uminusplus(v1948), v1949)); + store(out, 57 << shift, minus(uplusminus(v1948), v1949)); + real2 v1953 = plus(v1822, v1854); + store(out, 89 << shift, minus(v1953, v1954)); + store(out, 25 << shift, plus(v1953, v1954)); + real2 v1850 = ctimesminusplus(reverse(v1842), ctbl[0], ctimes(v1842, ctbl[1])); + real2 v1866 = ctimesminusplus(reverse(v1858), ctbl[2], ctimes(v1858, ctbl[3])); + real2 v1929 = reverse(minus(v1866, v1834)); + real2 v1935 = plus(v1834, v1866); + real2 v1930 = minus(v1850, v1818); + store(out, 105 << shift, minus(uminusplus(v1929), v1930)); + store(out, 41 << shift, minus(uplusminus(v1929), v1930)); + real2 v1934 = plus(v1818, v1850); + store(out, 73 << shift, minus(v1934, v1935)); + store(out, 9 << shift, plus(v1934, v1935)); + real2 v1690 = minus(uplusminus(v1680), v1681); + real2 v1694 = minus(uminusplus(v1680), v1681); + real2 v1716 = minusplus(uminus(v1712), v1713); + real2 v1714 = minusplus(v1712, v1713); + real2 v1730 = minusplus(v1728, v1729); + real2 v1732 = minusplus(uminus(v1728), v1729); + real2 v1742 = ctimesminusplus(reverse(v1732), ctbl[6], ctimes(v1732, ctbl[12])); + real2 v1726 = ctimesminusplus(reverse(v1716), ctbl[2], ctimes(v1716, ctbl[3])); + real2 v1780 = minusplus(uminus(v1776), v1777); + real2 v1778 = minusplus(v1776, v1777); + real2 v1790 = ctimesminusplus(reverse(v1780), ctbl[3], ctimes(v1780, ctbl[2])); + real2 v2030 = plus(v1726, v1790); + real2 v2024 = reverse(minus(v1790, v1726)); + real2 v1806 = ctimesminusplus(reverse(v1796), ctbl[9], ctimes(v1796, ctbl[8])); + real2 v1746 = minusplus(v1744, v1745); + real2 v1748 = minusplus(uminus(v1744), v1745); + real2 v2040 = reverse(minus(v1806, v1742)); + real2 v2046 = plus(v1742, v1806); + real2 v2062 = plus(v2045, v2046); + real2 v2056 = reverse(minus(v2046, v2045)); + real2 v1758 = ctimesminusplus(reverse(v1748), ctbl[0], ctimes(v1748, ctbl[0])); + real2 v2025 = minus(v1758, v1694); + real2 v2029 = plus(v1694, v1758); + real2 v2057 = minus(v2030, v2029); + store(out, 109 << shift, minus(uminusplus(v2056), v2057)); + store(out, 45 << shift, minus(uplusminus(v2056), v2057)); + real2 v2061 = plus(v2029, v2030); + store(out, 13 << shift, plus(v2061, v2062)); + store(out, 77 << shift, minus(v2061, v2062)); + real2 v2044 = minusplus(uminus(v2040), v2041); + real2 v2042 = minusplus(v2040, v2041); + real2 v2054 = ctimesminusplus(reverse(v2044), ctbl[0], ctimes(v2044, ctbl[0])); + real2 v2038 = minus(uminusplus(v2024), v2025); + real2 v2034 = minus(uplusminus(v2024), v2025); + store(out, 125 << shift, minus(v2038, v2054)); + store(out, 61 << shift, plus(v2038, v2054)); + real2 v2050 = ctimesminusplus(reverse(v2042), ctbl[0], ctimes(v2042, ctbl[1])); + store(out, 29 << shift, plus(v2034, v2050)); + store(out, 93 << shift, minus(v2034, v2050)); + real2 v1738 = ctimesminusplus(reverse(v1730), ctbl[8], ctimes(v1730, ctbl[9])); + real2 v1802 = ctimesminusplus(reverse(v1794), ctbl[6], ctimes(v1794, ctbl[7])); + real2 v1989 = plus(v1738, v1802); + real2 v1983 = reverse(minus(v1802, v1738)); + real2 v1999 = reverse(minus(v1989, v1988)); + real2 v2005 = plus(v1988, v1989); + real2 v1722 = ctimesminusplus(reverse(v1714), ctbl[4], ctimes(v1714, ctbl[5])); + real2 v1786 = ctimesminusplus(reverse(v1778), ctbl[2], ctimes(v1778, ctbl[3])); + real2 v1973 = plus(v1722, v1786); + real2 v1967 = reverse(minus(v1786, v1722)); + real2 v1754 = ctimesminusplus(reverse(v1746), ctbl[0], ctimes(v1746, ctbl[1])); + real2 v1972 = plus(v1690, v1754); + real2 v1968 = minus(v1754, v1690); + real2 v2004 = plus(v1972, v1973); + store(out, 5 << shift, plus(v2004, v2005)); + store(out, 69 << shift, minus(v2004, v2005)); + real2 v2000 = minus(v1973, v1972); + store(out, 37 << shift, minus(uplusminus(v1999), v2000)); + store(out, 101 << shift, minus(uminusplus(v1999), v2000)); + real2 v1985 = minusplus(v1983, v1984); + real2 v1987 = minusplus(uminus(v1983), v1984); + real2 v1993 = ctimesminusplus(reverse(v1985), ctbl[0], ctimes(v1985, ctbl[1])); + real2 v1977 = minus(uplusminus(v1967), v1968); + store(out, 21 << shift, plus(v1977, v1993)); + store(out, 85 << shift, minus(v1977, v1993)); + real2 v1981 = minus(uminusplus(v1967), v1968); + real2 v1997 = ctimesminusplus(reverse(v1987), ctbl[0], ctimes(v1987, ctbl[0])); + store(out, 117 << shift, minus(v1981, v1997)); + store(out, 53 << shift, plus(v1981, v1997)); + real2 v703 = ctimesminusplus(reverse(v692), ctbl[45], ctimes(v692, ctbl[44])); + real2 v261 = ctimesminusplus(reverse(v249), ctbl[26], ctimes(v249, ctbl[27])); + real2 v550 = ctimesminusplus(reverse(v539), ctbl[15], ctimes(v539, ctbl[14])); + real2 v413 = ctimesminusplus(reverse(v400), ctbl[18], ctimes(v400, ctbl[24])); + real2 v2178 = minus(v550, v261); + real2 v2182 = plus(v261, v550); + real2 v686 = ctimesminusplus(reverse(v676), ctbl[21], ctimes(v676, ctbl[20])); + real2 v2183 = plus(v413, v686); + real2 v2177 = reverse(minus(v686, v413)); + real2 v203 = ctimesminusplus(reverse(v191), ctbl[56], ctimes(v191, ctbl[57])); + real2 v281 = ctimesminusplus(reverse(v267), ctbl[50], ctimes(v267, ctbl[51])); + real2 v2247 = plus(v2182, v2183); + real2 v2241 = reverse(minus(v2183, v2182)); + real2 v619 = ctimesminusplus(reverse(v607), ctbl[27], ctimes(v607, ctbl[26])); + real2 v358 = ctimesminusplus(reverse(v345), ctbl[30], ctimes(v345, ctbl[60])); + real2 v499 = ctimesminusplus(reverse(v488), ctbl[36], ctimes(v488, ctbl[54])); + real2 v2130 = minus(v499, v203); + real2 v2134 = plus(v203, v499); + real2 v185 = ctimesminusplus(reverse(v171), ctbl[20], ctimes(v171, ctbl[21])); + real2 v339 = ctimesminusplus(reverse(v325), ctbl[14], ctimes(v325, ctbl[15])); + real2 v2119 = plus(v339, v619); + real2 v2113 = reverse(minus(v619, v339)); + real2 v482 = ctimesminusplus(reverse(v472), ctbl[24], ctimes(v472, ctbl[18])); + real2 v2114 = minus(v482, v185); + real2 v2118 = plus(v185, v482); + real2 v2246 = plus(v2118, v2119); + real2 v2242 = minus(v2119, v2118); + real2 v584 = ctimesminusplus(reverse(v574), ctbl[3], ctimes(v574, ctbl[2])); + real2 v652 = ctimesminusplus(reverse(v641), ctbl[9], ctimes(v641, ctbl[8])); + real2 v568 = ctimesminusplus(reverse(v556), ctbl[39], ctimes(v556, ctbl[38])); + real2 v2194 = minus(v568, v281); + real2 v2198 = plus(v281, v568); + real2 v517 = ctimesminusplus(reverse(v505), ctbl[12], ctimes(v505, ctbl[6])); + real2 v430 = ctimesminusplus(reverse(v419), ctbl[42], ctimes(v419, ctbl[48])); + real2 v2193 = reverse(minus(v703, v430)); + real2 v2199 = plus(v430, v703); + real2 v2273 = reverse(minus(v2247, v2246)); + real2 v2279 = plus(v2246, v2247); + real2 v375 = ctimesminusplus(reverse(v364), ctbl[6], ctimes(v364, ctbl[12])); + real2 v2145 = reverse(minus(v652, v375)); + real2 v2151 = plus(v375, v652); + real2 v2263 = plus(v2198, v2199); + real2 v2257 = reverse(minus(v2199, v2198)); + real2 v448 = ctimesminusplus(reverse(v436), ctbl[0], ctimes(v436, ctbl[0])); + real2 v635 = ctimesminusplus(reverse(v625), ctbl[33], ctimes(v625, ctbl[32])); + real2 v2129 = reverse(minus(v635, v358)); + real2 v2135 = plus(v358, v635); + real2 v2258 = minus(v2135, v2134); + real2 v2262 = plus(v2134, v2135); + real2 v2086 = plus(v145, v448); + real2 v2082 = minus(v448, v145); + real2 v301 = ctimesminusplus(reverse(v287), ctbl[2], ctimes(v287, ctbl[3])); + real2 v223 = ctimesminusplus(reverse(v209), ctbl[8], ctimes(v209, ctbl[9])); + real2 v2150 = plus(v223, v517); + real2 v2146 = minus(v517, v223); + real2 v2081 = reverse(minus(v584, v301)); + real2 v2087 = plus(v301, v584); + real2 v2210 = minus(v2087, v2086); + real2 v2214 = plus(v2086, v2087); + real2 v2215 = plus(v2150, v2151); + real2 v2209 = reverse(minus(v2151, v2150)); + real2 v2289 = reverse(minus(v2263, v2262)); + real2 v2295 = plus(v2262, v2263); + real2 v2311 = plus(v2294, v2295); + real2 v2305 = reverse(minus(v2295, v2294)); + real2 v2274 = minus(v2215, v2214); + real2 v2278 = plus(v2214, v2215); + real2 v2306 = minus(v2279, v2278); + real2 v2310 = plus(v2278, v2279); + store(out, 35 << shift, minus(uplusminus(v2305), v2306)); + store(out, 99 << shift, minus(uminusplus(v2305), v2306)); + store(out, 3 << shift, plus(v2310, v2311)); + store(out, 67 << shift, minus(v2310, v2311)); + real2 v2293 = minusplus(uminus(v2289), v2290); + real2 v2291 = minusplus(v2289, v2290); + real2 v2303 = ctimesminusplus(reverse(v2293), ctbl[0], ctimes(v2293, ctbl[0])); + real2 v2287 = minus(uminusplus(v2273), v2274); + store(out, 51 << shift, plus(v2287, v2303)); + store(out, 115 << shift, minus(v2287, v2303)); + real2 v2283 = minus(uplusminus(v2273), v2274); + real2 v2299 = ctimesminusplus(reverse(v2291), ctbl[0], ctimes(v2291, ctbl[1])); + store(out, 19 << shift, plus(v2283, v2299)); + store(out, 83 << shift, minus(v2283, v2299)); + real2 v2261 = minusplus(uminus(v2257), v2258); + real2 v2259 = minusplus(v2257, v2258); + real2 v2243 = minusplus(v2241, v2242); + real2 v2245 = minusplus(uminus(v2241), v2242); + real2 v2251 = ctimesminusplus(reverse(v2243), ctbl[0], ctimes(v2243, ctbl[1])); + real2 v2267 = ctimesminusplus(reverse(v2259), ctbl[2], ctimes(v2259, ctbl[3])); + real2 v2229 = minusplus(uminus(v2225), v2226); + real2 v2227 = minusplus(v2225, v2226); + real2 v2235 = ctimesminusplus(reverse(v2227), ctbl[4], ctimes(v2227, ctbl[5])); + real2 v2330 = reverse(minus(v2267, v2235)); + real2 v2336 = plus(v2235, v2267); + real2 v2219 = minus(uplusminus(v2209), v2210); + real2 v2223 = minus(uminusplus(v2209), v2210); + real2 v2335 = plus(v2219, v2251); + real2 v2331 = minus(v2251, v2219); + store(out, 43 << shift, minus(uplusminus(v2330), v2331)); + store(out, 107 << shift, minus(uminusplus(v2330), v2331)); + store(out, 75 << shift, minus(v2335, v2336)); + store(out, 11 << shift, plus(v2335, v2336)); + real2 v2239 = ctimesminusplus(reverse(v2229), ctbl[2], ctimes(v2229, ctbl[3])); + real2 v2271 = ctimesminusplus(reverse(v2261), ctbl[3], ctimes(v2261, ctbl[2])); + real2 v2349 = reverse(minus(v2271, v2239)); + real2 v2355 = plus(v2239, v2271); + real2 v2255 = ctimesminusplus(reverse(v2245), ctbl[0], ctimes(v2245, ctbl[0])); + real2 v2350 = minus(v2255, v2223); + store(out, 59 << shift, minus(uplusminus(v2349), v2350)); + store(out, 123 << shift, minus(uminusplus(v2349), v2350)); + real2 v2354 = plus(v2223, v2255); + store(out, 91 << shift, minus(v2354, v2355)); + store(out, 27 << shift, plus(v2354, v2355)); + real2 v2165 = minusplus(uminus(v2161), v2162); + real2 v2163 = minusplus(v2161, v2162); + real2 v2133 = minusplus(uminus(v2129), v2130); + real2 v2131 = minusplus(v2129, v2130); + real2 v2195 = minusplus(v2193, v2194); + real2 v2197 = minusplus(uminus(v2193), v2194); + real2 v2203 = ctimesminusplus(reverse(v2195), ctbl[6], ctimes(v2195, ctbl[7])); + real2 v2171 = ctimesminusplus(reverse(v2163), ctbl[10], ctimes(v2163, ctbl[11])); + real2 v2385 = minus(v2171, v2107); + real2 v2389 = plus(v2107, v2171); + real2 v2139 = ctimesminusplus(reverse(v2131), ctbl[8], ctimes(v2131, ctbl[9])); + real2 v2390 = plus(v2139, v2203); + real2 v2384 = reverse(minus(v2203, v2139)); + real2 v2406 = plus(v2389, v2390); + real2 v2400 = reverse(minus(v2390, v2389)); + real2 v2181 = minusplus(uminus(v2177), v2178); + real2 v2179 = minusplus(v2177, v2178); + real2 v2091 = minus(uplusminus(v2081), v2082); + real2 v2095 = minus(uminusplus(v2081), v2082); + real2 v2117 = minusplus(uminus(v2113), v2114); + real2 v2115 = minusplus(v2113, v2114); + real2 v2123 = ctimesminusplus(reverse(v2115), ctbl[4], ctimes(v2115, ctbl[5])); + real2 v2187 = ctimesminusplus(reverse(v2179), ctbl[2], ctimes(v2179, ctbl[3])); + real2 v2374 = plus(v2123, v2187); + real2 v2368 = reverse(minus(v2187, v2123)); + real2 v2149 = minusplus(uminus(v2145), v2146); + real2 v2147 = minusplus(v2145, v2146); + real2 v2155 = ctimesminusplus(reverse(v2147), ctbl[0], ctimes(v2147, ctbl[1])); + real2 v2373 = plus(v2091, v2155); + real2 v2369 = minus(v2155, v2091); + real2 v2401 = minus(v2374, v2373); + real2 v2405 = plus(v2373, v2374); + store(out, 71 << shift, minus(v2405, v2406)); + store(out, 7 << shift, plus(v2405, v2406)); + store(out, 103 << shift, minus(uminusplus(v2400), v2401)); + store(out, 39 << shift, minus(uplusminus(v2400), v2401)); + real2 v2388 = minusplus(uminus(v2384), v2385); + real2 v2386 = minusplus(v2384, v2385); + real2 v2398 = ctimesminusplus(reverse(v2388), ctbl[0], ctimes(v2388, ctbl[0])); + real2 v2378 = minus(uplusminus(v2368), v2369); + real2 v2382 = minus(uminusplus(v2368), v2369); + store(out, 55 << shift, plus(v2382, v2398)); + store(out, 119 << shift, minus(v2382, v2398)); + real2 v2394 = ctimesminusplus(reverse(v2386), ctbl[0], ctimes(v2386, ctbl[1])); + store(out, 23 << shift, plus(v2378, v2394)); + store(out, 87 << shift, minus(v2378, v2394)); + real2 v2207 = ctimesminusplus(reverse(v2197), ctbl[9], ctimes(v2197, ctbl[8])); + real2 v2111 = ctimesminusplus(reverse(v2101), ctbl[8], ctimes(v2101, ctbl[9])); + real2 v2175 = ctimesminusplus(reverse(v2165), ctbl[12], ctimes(v2165, ctbl[6])); + real2 v2446 = plus(v2111, v2175); + real2 v2442 = minus(v2175, v2111); + real2 v2143 = ctimesminusplus(reverse(v2133), ctbl[6], ctimes(v2133, ctbl[12])); + real2 v2441 = reverse(minus(v2207, v2143)); + real2 v2447 = plus(v2143, v2207); + real2 v2443 = minusplus(v2441, v2442); + real2 v2445 = minusplus(uminus(v2441), v2442); + real2 v2159 = ctimesminusplus(reverse(v2149), ctbl[0], ctimes(v2149, ctbl[0])); + real2 v2455 = ctimesminusplus(reverse(v2445), ctbl[0], ctimes(v2445, ctbl[0])); + real2 v2127 = ctimesminusplus(reverse(v2117), ctbl[2], ctimes(v2117, ctbl[3])); + real2 v2191 = ctimesminusplus(reverse(v2181), ctbl[3], ctimes(v2181, ctbl[2])); + real2 v2431 = plus(v2127, v2191); + real2 v2425 = reverse(minus(v2191, v2127)); + real2 v2426 = minus(v2159, v2095); + real2 v2430 = plus(v2095, v2159); + real2 v2439 = minus(uminusplus(v2425), v2426); + store(out, 127 << shift, minus(v2439, v2455)); + store(out, 63 << shift, plus(v2439, v2455)); + real2 v2435 = minus(uplusminus(v2425), v2426); + real2 v2451 = ctimesminusplus(reverse(v2443), ctbl[0], ctimes(v2443, ctbl[1])); + store(out, 95 << shift, minus(v2435, v2451)); + store(out, 31 << shift, plus(v2435, v2451)); + real2 v2463 = plus(v2446, v2447); + real2 v2457 = reverse(minus(v2447, v2446)); + real2 v2458 = minus(v2431, v2430); + store(out, 47 << shift, minus(uplusminus(v2457), v2458)); + store(out, 111 << shift, minus(uminusplus(v2457), v2458)); + real2 v2462 = plus(v2430, v2431); + store(out, 79 << shift, minus(v2462, v2463)); + store(out, 15 << shift, plus(v2462, v2463)); +// Pres : 68088 + } +} + +ALIGNED(8192) void but128f_%CONFIG%_%ISA%(real *RESTRICT out0, uint32_t *q, const int outShift, const real *RESTRICT in0, const int inShift, const real *RESTRICT tbl, const int K) { + const int k = 1 << (inShift - LOG2VECWIDTH); + int i=0; +#pragma omp parallel for + for(i=0;i < k;i++) { + int i0 = i << LOG2VECWIDTH; + real *out = out0 + q[i]; + const real *in = in0 + i0*2; + const int tbloffset = K * (i0 >> outShift); + +// Pres : 148586 + real2 v56 = load(in, 54 << inShift); + real2 v120 = load(in, 118 << inShift); + real2 v571 = reverse(minus(v56, v120)); + real2 v577 = plus(v56, v120); + real2 v24 = load(in, 22 << inShift); + real2 v88 = load(in, 86 << inShift); + real2 v576 = plus(v24, v88); + real2 v572 = minus(v88, v24); + real2 v573 = minusplus(v571, v572); + real2 v575 = minusplus(uminus(v571), v572); + real2 v589 = ctimesminusplus(reverse(v575), tbl[92 + tbloffset], ctimes(v575, tbl[93 + tbloffset])); + real2 v583 = ctimesminusplus(reverse(v573), tbl[90 + tbloffset], ctimes(v573, tbl[91 + tbloffset])); + real2 v897 = plus(v576, v577); + real2 v891 = reverse(minus(v576, v577)); + real2 v8 = load(in, 6 << inShift); + real2 v72 = load(in, 70 << inShift); + real2 v252 = minus(v72, v8); + real2 v256 = plus(v8, v72); + real2 v104 = load(in, 102 << inShift); + real2 v40 = load(in, 38 << inShift); + real2 v251 = reverse(minus(v40, v104)); + real2 v257 = plus(v40, v104); + real2 v255 = minusplus(uminus(v251), v252); + real2 v253 = minusplus(v251, v252); + real2 v263 = ctimesminusplus(reverse(v253), tbl[26 + tbloffset], ctimes(v253, tbl[27 + tbloffset])); + real2 v896 = plus(v256, v257); + real2 v892 = minus(v257, v256); + real2 v895 = minusplus(uminus(v891), v892); + real2 v893 = minusplus(v891, v892); + real2 v909 = ctimesminusplus(reverse(v895), tbl[156 + tbloffset], ctimes(v895, tbl[157 + tbloffset])); + real2 v903 = ctimesminusplus(reverse(v893), tbl[154 + tbloffset], ctimes(v893, tbl[155 + tbloffset])); + real2 v269 = ctimesminusplus(reverse(v255), tbl[28 + tbloffset], ctimes(v255, tbl[29 + tbloffset])); + real2 v1216 = plus(v896, v897); + real2 v1212 = minus(v897, v896); + real2 v2160 = minus(v583, v263); + real2 v2164 = plus(v263, v583); + real2 v2686 = minus(v589, v269); + real2 v2690 = plus(v269, v589); + real2 v96 = load(in, 94 << inShift); + real2 v32 = load(in, 30 << inShift); + real2 v736 = plus(v32, v96); + real2 v732 = minus(v96, v32); + real2 v64 = load(in, 62 << inShift); + real2 v128 = load(in, 126 << inShift); + real2 v737 = plus(v64, v128); + real2 v731 = reverse(minus(v64, v128)); + real2 v1057 = plus(v736, v737); + real2 v1051 = reverse(minus(v736, v737)); + real2 v733 = minusplus(v731, v732); + real2 v735 = minusplus(uminus(v731), v732); + real2 v749 = ctimesminusplus(reverse(v735), tbl[124 + tbloffset], ctimes(v735, tbl[125 + tbloffset])); + real2 v743 = ctimesminusplus(reverse(v733), tbl[122 + tbloffset], ctimes(v733, tbl[123 + tbloffset])); + real2 v16 = load(in, 14 << inShift); + real2 v80 = load(in, 78 << inShift); + real2 v412 = minus(v80, v16); + real2 v416 = plus(v16, v80); + real2 v112 = load(in, 110 << inShift); + real2 v48 = load(in, 46 << inShift); + real2 v417 = plus(v48, v112); + real2 v411 = reverse(minus(v48, v112)); + real2 v1056 = plus(v416, v417); + real2 v1052 = minus(v417, v416); + real2 v1055 = minusplus(uminus(v1051), v1052); + real2 v1053 = minusplus(v1051, v1052); + real2 v1063 = ctimesminusplus(reverse(v1053), tbl[186 + tbloffset], ctimes(v1053, tbl[187 + tbloffset])); + real2 v1665 = plus(v903, v1063); + real2 v1659 = reverse(minus(v903, v1063)); + real2 v1069 = ctimesminusplus(reverse(v1055), tbl[188 + tbloffset], ctimes(v1055, tbl[189 + tbloffset])); + real2 v1869 = reverse(minus(v909, v1069)); + real2 v1875 = plus(v909, v1069); + real2 v413 = minusplus(v411, v412); + real2 v415 = minusplus(uminus(v411), v412); + real2 v429 = ctimesminusplus(reverse(v415), tbl[60 + tbloffset], ctimes(v415, tbl[61 + tbloffset])); + real2 v1217 = plus(v1056, v1057); + real2 v1211 = reverse(minus(v1056, v1057)); + real2 v1297 = plus(v1216, v1217); + real2 v1291 = reverse(minus(v1216, v1217)); + real2 v2691 = plus(v429, v749); + real2 v2685 = reverse(minus(v429, v749)); + real2 v2765 = reverse(minus(v2690, v2691)); + real2 v2771 = plus(v2690, v2691); + real2 v2689 = minusplus(uminus(v2685), v2686); + real2 v2687 = minusplus(v2685, v2686); + real2 v2703 = ctimesminusplus(reverse(v2689), tbl[476 + tbloffset], ctimes(v2689, tbl[477 + tbloffset])); + real2 v2697 = ctimesminusplus(reverse(v2687), tbl[474 + tbloffset], ctimes(v2687, tbl[475 + tbloffset])); + real2 v1215 = minusplus(uminus(v1211), v1212); + real2 v1213 = minusplus(v1211, v1212); + real2 v1223 = ctimesminusplus(reverse(v1213), tbl[218 + tbloffset], ctimes(v1213, tbl[219 + tbloffset])); + real2 v1229 = ctimesminusplus(reverse(v1215), tbl[220 + tbloffset], ctimes(v1215, tbl[221 + tbloffset])); + real2 v423 = ctimesminusplus(reverse(v413), tbl[58 + tbloffset], ctimes(v413, tbl[59 + tbloffset])); + real2 v2165 = plus(v423, v743); + real2 v2159 = reverse(minus(v423, v743)); + real2 v2245 = plus(v2164, v2165); + real2 v2239 = reverse(minus(v2164, v2165)); + real2 v44 = load(in, 42 << inShift); + real2 v108 = load(in, 106 << inShift); + real2 v331 = reverse(minus(v44, v108)); + real2 v337 = plus(v44, v108); + real2 v76 = load(in, 74 << inShift); + real2 v12 = load(in, 10 << inShift); + real2 v336 = plus(v12, v76); + real2 v332 = minus(v76, v12); + real2 v976 = plus(v336, v337); + real2 v972 = minus(v337, v336); + real2 v335 = minusplus(uminus(v331), v332); + real2 v333 = minusplus(v331, v332); + real2 v343 = ctimesminusplus(reverse(v333), tbl[42 + tbloffset], ctimes(v333, tbl[43 + tbloffset])); + real2 v349 = ctimesminusplus(reverse(v335), tbl[44 + tbloffset], ctimes(v335, tbl[45 + tbloffset])); + real2 v124 = load(in, 122 << inShift); + real2 v60 = load(in, 58 << inShift); + real2 v651 = reverse(minus(v60, v124)); + real2 v657 = plus(v60, v124); + real2 v28 = load(in, 26 << inShift); + real2 v92 = load(in, 90 << inShift); + real2 v652 = minus(v92, v28); + real2 v656 = plus(v28, v92); + real2 v977 = plus(v656, v657); + real2 v971 = reverse(minus(v656, v657)); + real2 v973 = minusplus(v971, v972); + real2 v975 = minusplus(uminus(v971), v972); + real2 v983 = ctimesminusplus(reverse(v973), tbl[170 + tbloffset], ctimes(v973, tbl[171 + tbloffset])); + real2 v1131 = reverse(minus(v976, v977)); + real2 v1137 = plus(v976, v977); + real2 v655 = minusplus(uminus(v651), v652); + real2 v653 = minusplus(v651, v652); + real2 v669 = ctimesminusplus(reverse(v655), tbl[108 + tbloffset], ctimes(v655, tbl[109 + tbloffset])); + real2 v663 = ctimesminusplus(reverse(v653), tbl[106 + tbloffset], ctimes(v653, tbl[107 + tbloffset])); + real2 v2079 = reverse(minus(v343, v663)); + real2 v2085 = plus(v343, v663); + real2 v2605 = reverse(minus(v349, v669)); + real2 v2611 = plus(v349, v669); + real2 v989 = ctimesminusplus(reverse(v975), tbl[172 + tbloffset], ctimes(v975, tbl[173 + tbloffset])); + real2 v20 = load(in, 18 << inShift); + real2 v84 = load(in, 82 << inShift); + real2 v496 = plus(v20, v84); + real2 v492 = minus(v84, v20); + real2 v52 = load(in, 50 << inShift); + real2 v116 = load(in, 114 << inShift); + real2 v491 = reverse(minus(v52, v116)); + real2 v497 = plus(v52, v116); + real2 v817 = plus(v496, v497); + real2 v811 = reverse(minus(v496, v497)); + real2 v493 = minusplus(v491, v492); + real2 v495 = minusplus(uminus(v491), v492); + real2 v509 = ctimesminusplus(reverse(v495), tbl[76 + tbloffset], ctimes(v495, tbl[77 + tbloffset])); + real2 v503 = ctimesminusplus(reverse(v493), tbl[74 + tbloffset], ctimes(v493, tbl[75 + tbloffset])); + real2 v36 = load(in, 34 << inShift); + real2 v100 = load(in, 98 << inShift); + real2 v171 = reverse(minus(v36, v100)); + real2 v177 = plus(v36, v100); + real2 v68 = load(in, 66 << inShift); + real2 v4 = load(in, 2 << inShift); + real2 v176 = plus(v4, v68); + real2 v172 = minus(v68, v4); + real2 v816 = plus(v176, v177); + real2 v812 = minus(v177, v176); + real2 v1136 = plus(v816, v817); + real2 v1132 = minus(v817, v816); + real2 v1133 = minusplus(v1131, v1132); + real2 v1135 = minusplus(uminus(v1131), v1132); + real2 v1149 = ctimesminusplus(reverse(v1135), tbl[204 + tbloffset], ctimes(v1135, tbl[205 + tbloffset])); + real2 v1296 = plus(v1136, v1137); + real2 v1292 = minus(v1137, v1136); + real2 v1295 = minusplus(uminus(v1291), v1292); + real2 v1293 = minusplus(v1291, v1292); + real2 v1303 = ctimesminusplus(reverse(v1293), tbl[234 + tbloffset], ctimes(v1293, tbl[235 + tbloffset])); + real2 v1331 = reverse(minus(v1296, v1297)); + real2 v1337 = plus(v1296, v1297); + real2 v173 = minusplus(v171, v172); + real2 v175 = minusplus(uminus(v171), v172); + real2 v189 = ctimesminusplus(reverse(v175), tbl[12 + tbloffset], ctimes(v175, tbl[13 + tbloffset])); + real2 v1309 = ctimesminusplus(reverse(v1295), tbl[236 + tbloffset], ctimes(v1295, tbl[237 + tbloffset])); + real2 v815 = minusplus(uminus(v811), v812); + real2 v813 = minusplus(v811, v812); + real2 v1143 = ctimesminusplus(reverse(v1133), tbl[202 + tbloffset], ctimes(v1133, tbl[203 + tbloffset])); + real2 v1541 = reverse(minus(v1149, v1229)); + real2 v1547 = plus(v1149, v1229); + real2 v2610 = plus(v189, v509); + real2 v2606 = minus(v509, v189); + real2 v2770 = plus(v2610, v2611); + real2 v2766 = minus(v2611, v2610); + real2 v823 = ctimesminusplus(reverse(v813), tbl[138 + tbloffset], ctimes(v813, tbl[139 + tbloffset])); + real2 v829 = ctimesminusplus(reverse(v815), tbl[140 + tbloffset], ctimes(v815, tbl[141 + tbloffset])); + real2 v2811 = plus(v2770, v2771); + real2 v2805 = reverse(minus(v2770, v2771)); + real2 v2767 = minusplus(v2765, v2766); + real2 v2769 = minusplus(uminus(v2765), v2766); + real2 v2607 = minusplus(v2605, v2606); + real2 v2609 = minusplus(uminus(v2605), v2606); + real2 v2617 = ctimesminusplus(reverse(v2607), tbl[458 + tbloffset], ctimes(v2607, tbl[459 + tbloffset])); + real2 v2623 = ctimesminusplus(reverse(v2609), tbl[460 + tbloffset], ctimes(v2609, tbl[461 + tbloffset])); + real2 v3013 = reverse(minus(v2623, v2703)); + real2 v3019 = plus(v2623, v2703); + real2 v2783 = ctimesminusplus(reverse(v2769), tbl[492 + tbloffset], ctimes(v2769, tbl[493 + tbloffset])); + real2 v2941 = plus(v2617, v2697); + real2 v2935 = reverse(minus(v2617, v2697)); + real2 v2777 = ctimesminusplus(reverse(v2767), tbl[490 + tbloffset], ctimes(v2767, tbl[491 + tbloffset])); + real2 v1660 = minus(v983, v823); + real2 v1664 = plus(v823, v983); + real2 v1874 = plus(v829, v989); + real2 v1870 = minus(v989, v829); + real2 v1909 = reverse(minus(v1874, v1875)); + real2 v1915 = plus(v1874, v1875); + real2 v1663 = minusplus(uminus(v1659), v1660); + real2 v1661 = minusplus(v1659, v1660); + real2 v1677 = ctimesminusplus(reverse(v1663), tbl[296 + tbloffset], ctimes(v1663, tbl[297 + tbloffset])); + real2 v1873 = minusplus(uminus(v1869), v1870); + real2 v1871 = minusplus(v1869, v1870); + real2 v1887 = ctimesminusplus(reverse(v1873), tbl[332 + tbloffset], ctimes(v1873, tbl[333 + tbloffset])); + real2 v1705 = plus(v1664, v1665); + real2 v1699 = reverse(minus(v1664, v1665)); + real2 v1671 = ctimesminusplus(reverse(v1661), tbl[294 + tbloffset], ctimes(v1661, tbl[295 + tbloffset])); + real2 v1881 = ctimesminusplus(reverse(v1871), tbl[330 + tbloffset], ctimes(v1871, tbl[331 + tbloffset])); + real2 v1469 = plus(v1143, v1223); + real2 v1463 = reverse(minus(v1143, v1223)); + real2 v54 = load(in, 52 << inShift); + real2 v118 = load(in, 116 << inShift); + real2 v537 = plus(v54, v118); + real2 v531 = reverse(minus(v54, v118)); + real2 v86 = load(in, 84 << inShift); + real2 v22 = load(in, 20 << inShift); + real2 v536 = plus(v22, v86); + real2 v532 = minus(v86, v22); + real2 v851 = reverse(minus(v536, v537)); + real2 v857 = plus(v536, v537); + real2 v533 = minusplus(v531, v532); + real2 v535 = minusplus(uminus(v531), v532); + real2 v549 = ctimesminusplus(reverse(v535), tbl[84 + tbloffset], ctimes(v535, tbl[85 + tbloffset])); + real2 v102 = load(in, 100 << inShift); + real2 v38 = load(in, 36 << inShift); + real2 v217 = plus(v38, v102); + real2 v211 = reverse(minus(v38, v102)); + real2 v70 = load(in, 68 << inShift); + real2 v6 = load(in, 4 << inShift); + real2 v216 = plus(v6, v70); + real2 v212 = minus(v70, v6); + real2 v213 = minusplus(v211, v212); + real2 v215 = minusplus(uminus(v211), v212); + real2 v229 = ctimesminusplus(reverse(v215), tbl[20 + tbloffset], ctimes(v215, tbl[21 + tbloffset])); + real2 v2646 = minus(v549, v229); + real2 v2650 = plus(v229, v549); + real2 v856 = plus(v216, v217); + real2 v852 = minus(v217, v216); + real2 v853 = minusplus(v851, v852); + real2 v855 = minusplus(uminus(v851), v852); + real2 v863 = ctimesminusplus(reverse(v853), tbl[146 + tbloffset], ctimes(v853, tbl[147 + tbloffset])); + real2 v869 = ctimesminusplus(reverse(v855), tbl[148 + tbloffset], ctimes(v855, tbl[149 + tbloffset])); + real2 v1176 = plus(v856, v857); + real2 v1172 = minus(v857, v856); + real2 v110 = load(in, 108 << inShift); + real2 v46 = load(in, 44 << inShift); + real2 v377 = plus(v46, v110); + real2 v371 = reverse(minus(v46, v110)); + real2 v78 = load(in, 76 << inShift); + real2 v14 = load(in, 12 << inShift); + real2 v372 = minus(v78, v14); + real2 v376 = plus(v14, v78); + real2 v1012 = minus(v377, v376); + real2 v1016 = plus(v376, v377); + real2 v373 = minusplus(v371, v372); + real2 v375 = minusplus(uminus(v371), v372); + real2 v389 = ctimesminusplus(reverse(v375), tbl[52 + tbloffset], ctimes(v375, tbl[53 + tbloffset])); + real2 v30 = load(in, 28 << inShift); + real2 v94 = load(in, 92 << inShift); + real2 v696 = plus(v30, v94); + real2 v692 = minus(v94, v30); + real2 v62 = load(in, 60 << inShift); + real2 v126 = load(in, 124 << inShift); + real2 v697 = plus(v62, v126); + real2 v691 = reverse(minus(v62, v126)); + real2 v1017 = plus(v696, v697); + real2 v1011 = reverse(minus(v696, v697)); + real2 v1171 = reverse(minus(v1016, v1017)); + real2 v1177 = plus(v1016, v1017); + real2 v1013 = minusplus(v1011, v1012); + real2 v1015 = minusplus(uminus(v1011), v1012); + real2 v1175 = minusplus(uminus(v1171), v1172); + real2 v1173 = minusplus(v1171, v1172); + real2 v1183 = ctimesminusplus(reverse(v1173), tbl[210 + tbloffset], ctimes(v1173, tbl[211 + tbloffset])); + real2 v1189 = ctimesminusplus(reverse(v1175), tbl[212 + tbloffset], ctimes(v1175, tbl[213 + tbloffset])); + real2 v1029 = ctimesminusplus(reverse(v1015), tbl[180 + tbloffset], ctimes(v1015, tbl[181 + tbloffset])); + real2 v1023 = ctimesminusplus(reverse(v1013), tbl[178 + tbloffset], ctimes(v1013, tbl[179 + tbloffset])); + real2 v1625 = plus(v863, v1023); + real2 v1619 = reverse(minus(v863, v1023)); + real2 v1835 = plus(v869, v1029); + real2 v1829 = reverse(minus(v869, v1029)); + real2 v693 = minusplus(v691, v692); + real2 v695 = minusplus(uminus(v691), v692); + real2 v709 = ctimesminusplus(reverse(v695), tbl[116 + tbloffset], ctimes(v695, tbl[117 + tbloffset])); + real2 v2645 = reverse(minus(v389, v709)); + real2 v2651 = plus(v389, v709); + real2 v1257 = plus(v1176, v1177); + real2 v1251 = reverse(minus(v1176, v1177)); + real2 v2731 = plus(v2650, v2651); + real2 v2725 = reverse(minus(v2650, v2651)); + real2 v114 = load(in, 112 << inShift); + real2 v50 = load(in, 48 << inShift); + real2 v457 = plus(v50, v114); + real2 v451 = reverse(minus(v50, v114)); + real2 v18 = load(in, 16 << inShift); + real2 v82 = load(in, 80 << inShift); + real2 v456 = plus(v18, v82); + real2 v452 = minus(v82, v18); + real2 v771 = reverse(minus(v456, v457)); + real2 v777 = plus(v456, v457); + real2 v453 = minusplus(v451, v452); + real2 v455 = minusplus(uminus(v451), v452); + real2 v469 = ctimesminusplus(reverse(v455), tbl[68 + tbloffset], ctimes(v455, tbl[69 + tbloffset])); + real2 v66 = load(in, 64 << inShift); + real2 v2 = load(in, 0 << inShift); + real2 v132 = minus(v66, v2); + real2 v136 = plus(v2, v66); + real2 v98 = load(in, 96 << inShift); + real2 v34 = load(in, 32 << inShift); + real2 v131 = reverse(minus(v34, v98)); + real2 v137 = plus(v34, v98); + real2 v133 = minusplus(v131, v132); + real2 v135 = minusplus(uminus(v131), v132); + real2 v149 = ctimesminusplus(reverse(v135), tbl[4 + tbloffset], ctimes(v135, tbl[5 + tbloffset])); + real2 v2566 = minus(v469, v149); + real2 v2570 = plus(v149, v469); + real2 v772 = minus(v137, v136); + real2 v776 = plus(v136, v137); + real2 v1092 = minus(v777, v776); + real2 v1096 = plus(v776, v777); + real2 v773 = minusplus(v771, v772); + real2 v775 = minusplus(uminus(v771), v772); + real2 v783 = ctimesminusplus(reverse(v773), tbl[130 + tbloffset], ctimes(v773, tbl[131 + tbloffset])); + real2 v789 = ctimesminusplus(reverse(v775), tbl[132 + tbloffset], ctimes(v775, tbl[133 + tbloffset])); + real2 v74 = load(in, 72 << inShift); + real2 v10 = load(in, 8 << inShift); + real2 v296 = plus(v10, v74); + real2 v292 = minus(v74, v10); + real2 v42 = load(in, 40 << inShift); + real2 v106 = load(in, 104 << inShift); + real2 v291 = reverse(minus(v42, v106)); + real2 v297 = plus(v42, v106); + real2 v293 = minusplus(v291, v292); + real2 v295 = minusplus(uminus(v291), v292); + real2 v309 = ctimesminusplus(reverse(v295), tbl[36 + tbloffset], ctimes(v295, tbl[37 + tbloffset])); + real2 v932 = minus(v297, v296); + real2 v936 = plus(v296, v297); + real2 v122 = load(in, 120 << inShift); + real2 v58 = load(in, 56 << inShift); + real2 v617 = plus(v58, v122); + real2 v611 = reverse(minus(v58, v122)); + real2 v26 = load(in, 24 << inShift); + real2 v90 = load(in, 88 << inShift); + real2 v612 = minus(v90, v26); + real2 v616 = plus(v26, v90); + real2 v937 = plus(v616, v617); + real2 v931 = reverse(minus(v616, v617)); + real2 v1091 = reverse(minus(v936, v937)); + real2 v1097 = plus(v936, v937); + real2 v933 = minusplus(v931, v932); + real2 v935 = minusplus(uminus(v931), v932); + real2 v1093 = minusplus(v1091, v1092); + real2 v1095 = minusplus(uminus(v1091), v1092); + real2 v1103 = ctimesminusplus(reverse(v1093), tbl[194 + tbloffset], ctimes(v1093, tbl[195 + tbloffset])); + real2 v1468 = plus(v1103, v1183); + real2 v1464 = minus(v1183, v1103); + real2 v1508 = plus(v1468, v1469); + real2 v1504 = minus(v1469, v1468); + real2 v1252 = minus(v1097, v1096); + real2 v1256 = plus(v1096, v1097); + real2 v1336 = plus(v1256, v1257); + real2 v1332 = minus(v1257, v1256); + real2 v1335 = minusplus(uminus(v1331), v1332); + real2 v1333 = minusplus(v1331, v1332); + real2 v1343 = ctimesminusplus(reverse(v1333), tbl[242 + tbloffset], ctimes(v1333, tbl[243 + tbloffset])); + real2 v1349 = ctimesminusplus(reverse(v1335), tbl[244 + tbloffset], ctimes(v1335, tbl[245 + tbloffset])); + real2 v1376 = plus(v1336, v1337); + real2 v1372 = minus(v1337, v1336); + real2 v1465 = minusplus(v1463, v1464); + real2 v1467 = minusplus(uminus(v1463), v1464); + real2 v1255 = minusplus(uminus(v1251), v1252); + real2 v1253 = minusplus(v1251, v1252); + real2 v1481 = ctimesminusplus(reverse(v1467), tbl[264 + tbloffset], ctimes(v1467, tbl[265 + tbloffset])); + real2 v1475 = ctimesminusplus(reverse(v1465), tbl[262 + tbloffset], ctimes(v1465, tbl[263 + tbloffset])); + real2 v1109 = ctimesminusplus(reverse(v1095), tbl[196 + tbloffset], ctimes(v1095, tbl[197 + tbloffset])); + real2 v1542 = minus(v1189, v1109); + real2 v1546 = plus(v1109, v1189); + real2 v1545 = minusplus(uminus(v1541), v1542); + real2 v1543 = minusplus(v1541, v1542); + real2 v1553 = ctimesminusplus(reverse(v1543), tbl[274 + tbloffset], ctimes(v1543, tbl[275 + tbloffset])); + real2 v1559 = ctimesminusplus(reverse(v1545), tbl[276 + tbloffset], ctimes(v1545, tbl[277 + tbloffset])); + real2 v1582 = minus(v1547, v1546); + real2 v1586 = plus(v1546, v1547); + real2 v1269 = ctimesminusplus(reverse(v1255), tbl[228 + tbloffset], ctimes(v1255, tbl[229 + tbloffset])); + real2 v1438 = minus(v1309, v1269); + real2 v1442 = plus(v1269, v1309); + real2 v1263 = ctimesminusplus(reverse(v1253), tbl[226 + tbloffset], ctimes(v1253, tbl[227 + tbloffset])); + real2 v943 = ctimesminusplus(reverse(v933), tbl[162 + tbloffset], ctimes(v933, tbl[163 + tbloffset])); + real2 v1624 = plus(v783, v943); + real2 v1620 = minus(v943, v783); + real2 v1623 = minusplus(uminus(v1619), v1620); + real2 v1621 = minusplus(v1619, v1620); + real2 v1700 = minus(v1625, v1624); + real2 v1704 = plus(v1624, v1625); + real2 v1631 = ctimesminusplus(reverse(v1621), tbl[286 + tbloffset], ctimes(v1621, tbl[287 + tbloffset])); + real2 v949 = ctimesminusplus(reverse(v935), tbl[164 + tbloffset], ctimes(v935, tbl[165 + tbloffset])); + real2 v1830 = minus(v949, v789); + real2 v1834 = plus(v789, v949); + real2 v1782 = plus(v1631, v1671); + real2 v1778 = minus(v1671, v1631); + real2 v1910 = minus(v1835, v1834); + real2 v1914 = plus(v1834, v1835); + real2 v1950 = minus(v1915, v1914); + real2 v1954 = plus(v1914, v1915); + real2 v1913 = minusplus(uminus(v1909), v1910); + real2 v1911 = minusplus(v1909, v1910); + real2 v613 = minusplus(v611, v612); + real2 v615 = minusplus(uminus(v611), v612); + real2 v629 = ctimesminusplus(reverse(v615), tbl[100 + tbloffset], ctimes(v615, tbl[101 + tbloffset])); + real2 v1744 = plus(v1704, v1705); + real2 v1740 = minus(v1705, v1704); + real2 v1637 = ctimesminusplus(reverse(v1623), tbl[288 + tbloffset], ctimes(v1623, tbl[289 + tbloffset])); + real2 v1927 = ctimesminusplus(reverse(v1913), tbl[340 + tbloffset], ctimes(v1913, tbl[341 + tbloffset])); + real2 v2571 = plus(v309, v629); + real2 v2565 = reverse(minus(v309, v629)); + real2 v1833 = minusplus(uminus(v1829), v1830); + real2 v1831 = minusplus(v1829, v1830); + real2 v1921 = ctimesminusplus(reverse(v1911), tbl[338 + tbloffset], ctimes(v1911, tbl[339 + tbloffset])); + real2 v1804 = minus(v1677, v1637); + real2 v1808 = plus(v1637, v1677); + real2 v1847 = ctimesminusplus(reverse(v1833), tbl[324 + tbloffset], ctimes(v1833, tbl[325 + tbloffset])); + real2 v2014 = minus(v1887, v1847); + real2 v2018 = plus(v1847, v1887); + real2 v1841 = ctimesminusplus(reverse(v1831), tbl[322 + tbloffset], ctimes(v1831, tbl[323 + tbloffset])); + real2 v1988 = minus(v1881, v1841); + real2 v1992 = plus(v1841, v1881); + real2 v1703 = minusplus(uminus(v1699), v1700); + real2 v1701 = minusplus(v1699, v1700); + real2 v1717 = ctimesminusplus(reverse(v1703), tbl[304 + tbloffset], ctimes(v1703, tbl[305 + tbloffset])); + real2 v1711 = ctimesminusplus(reverse(v1701), tbl[302 + tbloffset], ctimes(v1701, tbl[303 + tbloffset])); + real2 v2730 = plus(v2570, v2571); + real2 v2726 = minus(v2571, v2570); + real2 v1412 = minus(v1303, v1263); + real2 v1416 = plus(v1263, v1303); + real2 v63 = load(in, 61 << inShift); + real2 v127 = load(in, 125 << inShift); + real2 v717 = plus(v63, v127); + real2 v711 = reverse(minus(v63, v127)); + real2 v95 = load(in, 93 << inShift); + real2 v31 = load(in, 29 << inShift); + real2 v712 = minus(v95, v31); + real2 v716 = plus(v31, v95); + real2 v1037 = plus(v716, v717); + real2 v1031 = reverse(minus(v716, v717)); + real2 v79 = load(in, 77 << inShift); + real2 v15 = load(in, 13 << inShift); + real2 v396 = plus(v15, v79); + real2 v392 = minus(v79, v15); + real2 v111 = load(in, 109 << inShift); + real2 v47 = load(in, 45 << inShift); + real2 v397 = plus(v47, v111); + real2 v391 = reverse(minus(v47, v111)); + real2 v1032 = minus(v397, v396); + real2 v1036 = plus(v396, v397); + real2 v1033 = minusplus(v1031, v1032); + real2 v1035 = minusplus(uminus(v1031), v1032); + real2 v1049 = ctimesminusplus(reverse(v1035), tbl[184 + tbloffset], ctimes(v1035, tbl[185 + tbloffset])); + real2 v1043 = ctimesminusplus(reverse(v1033), tbl[182 + tbloffset], ctimes(v1033, tbl[183 + tbloffset])); + real2 v1197 = plus(v1036, v1037); + real2 v1191 = reverse(minus(v1036, v1037)); + real2 v23 = load(in, 21 << inShift); + real2 v87 = load(in, 85 << inShift); + real2 v556 = plus(v23, v87); + real2 v552 = minus(v87, v23); + real2 v119 = load(in, 117 << inShift); + real2 v55 = load(in, 53 << inShift); + real2 v557 = plus(v55, v119); + real2 v551 = reverse(minus(v55, v119)); + real2 v877 = plus(v556, v557); + real2 v871 = reverse(minus(v556, v557)); + real2 v7 = load(in, 5 << inShift); + real2 v71 = load(in, 69 << inShift); + real2 v232 = minus(v71, v7); + real2 v236 = plus(v7, v71); + real2 v103 = load(in, 101 << inShift); + real2 v39 = load(in, 37 << inShift); + real2 v237 = plus(v39, v103); + real2 v231 = reverse(minus(v39, v103)); + real2 v876 = plus(v236, v237); + real2 v872 = minus(v237, v236); + real2 v1192 = minus(v877, v876); + real2 v1196 = plus(v876, v877); + real2 v1271 = reverse(minus(v1196, v1197)); + real2 v1277 = plus(v1196, v1197); + real2 v875 = minusplus(uminus(v871), v872); + real2 v873 = minusplus(v871, v872); + real2 v883 = ctimesminusplus(reverse(v873), tbl[150 + tbloffset], ctimes(v873, tbl[151 + tbloffset])); + real2 v1639 = reverse(minus(v883, v1043)); + real2 v1645 = plus(v883, v1043); + real2 v1195 = minusplus(uminus(v1191), v1192); + real2 v1193 = minusplus(v1191, v1192); + real2 v1209 = ctimesminusplus(reverse(v1195), tbl[216 + tbloffset], ctimes(v1195, tbl[217 + tbloffset])); + real2 v1203 = ctimesminusplus(reverse(v1193), tbl[214 + tbloffset], ctimes(v1193, tbl[215 + tbloffset])); + real2 v83 = load(in, 81 << inShift); + real2 v19 = load(in, 17 << inShift); + real2 v476 = plus(v19, v83); + real2 v472 = minus(v83, v19); + real2 v51 = load(in, 49 << inShift); + real2 v115 = load(in, 113 << inShift); + real2 v477 = plus(v51, v115); + real2 v471 = reverse(minus(v51, v115)); + real2 v797 = plus(v476, v477); + real2 v791 = reverse(minus(v476, v477)); + real2 v3 = load(in, 1 << inShift); + real2 v67 = load(in, 65 << inShift); + real2 v156 = plus(v3, v67); + real2 v152 = minus(v67, v3); + real2 v35 = load(in, 33 << inShift); + real2 v99 = load(in, 97 << inShift); + real2 v157 = plus(v35, v99); + real2 v151 = reverse(minus(v35, v99)); + real2 v792 = minus(v157, v156); + real2 v796 = plus(v156, v157); + real2 v793 = minusplus(v791, v792); + real2 v795 = minusplus(uminus(v791), v792); + real2 v803 = ctimesminusplus(reverse(v793), tbl[134 + tbloffset], ctimes(v793, tbl[135 + tbloffset])); + real2 v1112 = minus(v797, v796); + real2 v1116 = plus(v796, v797); + real2 v107 = load(in, 105 << inShift); + real2 v43 = load(in, 41 << inShift); + real2 v317 = plus(v43, v107); + real2 v311 = reverse(minus(v43, v107)); + real2 v75 = load(in, 73 << inShift); + real2 v11 = load(in, 9 << inShift); + real2 v316 = plus(v11, v75); + real2 v312 = minus(v75, v11); + real2 v956 = plus(v316, v317); + real2 v952 = minus(v317, v316); + real2 v59 = load(in, 57 << inShift); + real2 v123 = load(in, 121 << inShift); + real2 v631 = reverse(minus(v59, v123)); + real2 v637 = plus(v59, v123); + real2 v27 = load(in, 25 << inShift); + real2 v91 = load(in, 89 << inShift); + real2 v636 = plus(v27, v91); + real2 v632 = minus(v91, v27); + real2 v957 = plus(v636, v637); + real2 v951 = reverse(minus(v636, v637)); + real2 v1111 = reverse(minus(v956, v957)); + real2 v1117 = plus(v956, v957); + real2 v1276 = plus(v1116, v1117); + real2 v1272 = minus(v1117, v1116); + real2 v1275 = minusplus(uminus(v1271), v1272); + real2 v1273 = minusplus(v1271, v1272); + real2 v1283 = ctimesminusplus(reverse(v1273), tbl[230 + tbloffset], ctimes(v1273, tbl[231 + tbloffset])); + real2 v1352 = minus(v1277, v1276); + real2 v1356 = plus(v1276, v1277); + real2 v1289 = ctimesminusplus(reverse(v1275), tbl[232 + tbloffset], ctimes(v1275, tbl[233 + tbloffset])); + real2 v1115 = minusplus(uminus(v1111), v1112); + real2 v1113 = minusplus(v1111, v1112); + real2 v1123 = ctimesminusplus(reverse(v1113), tbl[198 + tbloffset], ctimes(v1113, tbl[199 + tbloffset])); + real2 v1129 = ctimesminusplus(reverse(v1115), tbl[200 + tbloffset], ctimes(v1115, tbl[201 + tbloffset])); + real2 v1488 = plus(v1123, v1203); + real2 v1484 = minus(v1203, v1123); + real2 v1566 = plus(v1129, v1209); + real2 v1562 = minus(v1209, v1129); + real2 v85 = load(in, 83 << inShift); + real2 v21 = load(in, 19 << inShift); + real2 v512 = minus(v85, v21); + real2 v516 = plus(v21, v85); + real2 v117 = load(in, 115 << inShift); + real2 v53 = load(in, 51 << inShift); + real2 v517 = plus(v53, v117); + real2 v511 = reverse(minus(v53, v117)); + real2 v831 = reverse(minus(v516, v517)); + real2 v837 = plus(v516, v517); + real2 v69 = load(in, 67 << inShift); + real2 v5 = load(in, 3 << inShift); + real2 v192 = minus(v69, v5); + real2 v196 = plus(v5, v69); + real2 v37 = load(in, 35 << inShift); + real2 v101 = load(in, 99 << inShift); + real2 v197 = plus(v37, v101); + real2 v191 = reverse(minus(v37, v101)); + real2 v832 = minus(v197, v196); + real2 v836 = plus(v196, v197); + real2 v1152 = minus(v837, v836); + real2 v1156 = plus(v836, v837); + real2 v61 = load(in, 59 << inShift); + real2 v125 = load(in, 123 << inShift); + real2 v677 = plus(v61, v125); + real2 v671 = reverse(minus(v61, v125)); + real2 v29 = load(in, 27 << inShift); + real2 v93 = load(in, 91 << inShift); + real2 v672 = minus(v93, v29); + real2 v676 = plus(v29, v93); + real2 v997 = plus(v676, v677); + real2 v991 = reverse(minus(v676, v677)); + real2 v109 = load(in, 107 << inShift); + real2 v45 = load(in, 43 << inShift); + real2 v357 = plus(v45, v109); + real2 v351 = reverse(minus(v45, v109)); + real2 v77 = load(in, 75 << inShift); + real2 v13 = load(in, 11 << inShift); + real2 v352 = minus(v77, v13); + real2 v356 = plus(v13, v77); + real2 v992 = minus(v357, v356); + real2 v996 = plus(v356, v357); + real2 v1157 = plus(v996, v997); + real2 v1151 = reverse(minus(v996, v997)); + real2 v1155 = minusplus(uminus(v1151), v1152); + real2 v1153 = minusplus(v1151, v1152); + real2 v1163 = ctimesminusplus(reverse(v1153), tbl[206 + tbloffset], ctimes(v1153, tbl[207 + tbloffset])); + real2 v1316 = plus(v1156, v1157); + real2 v1312 = minus(v1157, v1156); + real2 v41 = load(in, 39 << inShift); + real2 v105 = load(in, 103 << inShift); + real2 v277 = plus(v41, v105); + real2 v271 = reverse(minus(v41, v105)); + real2 v9 = load(in, 7 << inShift); + real2 v73 = load(in, 71 << inShift); + real2 v276 = plus(v9, v73); + real2 v272 = minus(v73, v9); + real2 v916 = plus(v276, v277); + real2 v912 = minus(v277, v276); + real2 v89 = load(in, 87 << inShift); + real2 v25 = load(in, 23 << inShift); + real2 v592 = minus(v89, v25); + real2 v596 = plus(v25, v89); + real2 v57 = load(in, 55 << inShift); + real2 v121 = load(in, 119 << inShift); + real2 v591 = reverse(minus(v57, v121)); + real2 v597 = plus(v57, v121); + real2 v911 = reverse(minus(v596, v597)); + real2 v917 = plus(v596, v597); + real2 v1236 = plus(v916, v917); + real2 v1232 = minus(v917, v916); + real2 v81 = load(in, 79 << inShift); + real2 v17 = load(in, 15 << inShift); + real2 v432 = minus(v81, v17); + real2 v436 = plus(v17, v81); + real2 v113 = load(in, 111 << inShift); + real2 v49 = load(in, 47 << inShift); + real2 v437 = plus(v49, v113); + real2 v431 = reverse(minus(v49, v113)); + real2 v1072 = minus(v437, v436); + real2 v1076 = plus(v436, v437); + real2 v65 = load(in, 63 << inShift); + real2 v129 = load(in, 127 << inShift); + real2 v757 = plus(v65, v129); + real2 v751 = reverse(minus(v65, v129)); + real2 v97 = load(in, 95 << inShift); + real2 v33 = load(in, 31 << inShift); + real2 v752 = minus(v97, v33); + real2 v756 = plus(v33, v97); + real2 v1077 = plus(v756, v757); + real2 v1071 = reverse(minus(v756, v757)); + real2 v1231 = reverse(minus(v1076, v1077)); + real2 v1237 = plus(v1076, v1077); + real2 v1317 = plus(v1236, v1237); + real2 v1311 = reverse(minus(v1236, v1237)); + real2 v1351 = reverse(minus(v1316, v1317)); + real2 v1357 = plus(v1316, v1317); + real2 v1371 = reverse(minus(v1356, v1357)); + real2 v1377 = plus(v1356, v1357); + store(out, 0 << outShift, plus(v1376, v1377)); + real2 v1390 = minus(v1376, v1377); + store(out, 64 << outShift, ctimesminusplus(v1390, tbl[0 + tbloffset], ctimes(reverse(v1390), tbl[1 + tbloffset]))); + real2 v1353 = minusplus(v1351, v1352); + real2 v1355 = minusplus(uminus(v1351), v1352); + real2 v1369 = ctimesminusplus(reverse(v1355), tbl[248 + tbloffset], ctimes(v1355, tbl[249 + tbloffset])); + store(out, 48 << outShift, plus(v1349, v1369)); + real2 v1404 = minus(v1349, v1369); + store(out, 112 << outShift, ctimesminusplus(v1404, tbl[0 + tbloffset], ctimes(reverse(v1404), tbl[1 + tbloffset]))); + real2 v1363 = ctimesminusplus(reverse(v1353), tbl[246 + tbloffset], ctimes(v1353, tbl[247 + tbloffset])); + store(out, 16 << outShift, plus(v1343, v1363)); + real2 v1398 = minus(v1343, v1363); + store(out, 80 << outShift, ctimesminusplus(v1398, tbl[0 + tbloffset], ctimes(reverse(v1398), tbl[1 + tbloffset]))); + real2 v1373 = minusplus(v1371, v1372); + real2 v1375 = minusplus(uminus(v1371), v1372); + store(out, 96 << outShift, ctimesminusplus(reverse(v1375), tbl[252 + tbloffset], ctimes(v1375, tbl[253 + tbloffset]))); + store(out, 32 << outShift, ctimesminusplus(reverse(v1373), tbl[250 + tbloffset], ctimes(v1373, tbl[251 + tbloffset]))); + real2 v1313 = minusplus(v1311, v1312); + real2 v1315 = minusplus(uminus(v1311), v1312); + real2 v1323 = ctimesminusplus(reverse(v1313), tbl[238 + tbloffset], ctimes(v1313, tbl[239 + tbloffset])); + real2 v1417 = plus(v1283, v1323); + real2 v1411 = reverse(minus(v1283, v1323)); + store(out, 8 << outShift, plus(v1416, v1417)); + real2 v1430 = minus(v1416, v1417); + store(out, 72 << outShift, ctimesminusplus(v1430, tbl[0 + tbloffset], ctimes(reverse(v1430), tbl[1 + tbloffset]))); + real2 v1413 = minusplus(v1411, v1412); + real2 v1415 = minusplus(uminus(v1411), v1412); + store(out, 104 << outShift, ctimesminusplus(reverse(v1415), tbl[256 + tbloffset], ctimes(v1415, tbl[257 + tbloffset]))); + store(out, 40 << outShift, ctimesminusplus(reverse(v1413), tbl[254 + tbloffset], ctimes(v1413, tbl[255 + tbloffset]))); + real2 v1329 = ctimesminusplus(reverse(v1315), tbl[240 + tbloffset], ctimes(v1315, tbl[241 + tbloffset])); + real2 v1443 = plus(v1289, v1329); + real2 v1437 = reverse(minus(v1289, v1329)); + store(out, 24 << outShift, plus(v1442, v1443)); + real2 v1456 = minus(v1442, v1443); + store(out, 88 << outShift, ctimesminusplus(v1456, tbl[0 + tbloffset], ctimes(reverse(v1456), tbl[1 + tbloffset]))); + real2 v1441 = minusplus(uminus(v1437), v1438); + real2 v1439 = minusplus(v1437, v1438); + store(out, 120 << outShift, ctimesminusplus(reverse(v1441), tbl[260 + tbloffset], ctimes(v1441, tbl[261 + tbloffset]))); + store(out, 56 << outShift, ctimesminusplus(reverse(v1439), tbl[258 + tbloffset], ctimes(v1439, tbl[259 + tbloffset]))); + real2 v1235 = minusplus(uminus(v1231), v1232); + real2 v1233 = minusplus(v1231, v1232); + real2 v1243 = ctimesminusplus(reverse(v1233), tbl[222 + tbloffset], ctimes(v1233, tbl[223 + tbloffset])); + real2 v1489 = plus(v1163, v1243); + real2 v1483 = reverse(minus(v1163, v1243)); + real2 v1509 = plus(v1488, v1489); + real2 v1503 = reverse(minus(v1488, v1489)); + store(out, 4 << outShift, plus(v1508, v1509)); + real2 v1522 = minus(v1508, v1509); + store(out, 68 << outShift, ctimesminusplus(v1522, tbl[0 + tbloffset], ctimes(reverse(v1522), tbl[1 + tbloffset]))); + real2 v1507 = minusplus(uminus(v1503), v1504); + real2 v1505 = minusplus(v1503, v1504); + store(out, 36 << outShift, ctimesminusplus(reverse(v1505), tbl[270 + tbloffset], ctimes(v1505, tbl[271 + tbloffset]))); + store(out, 100 << outShift, ctimesminusplus(reverse(v1507), tbl[272 + tbloffset], ctimes(v1507, tbl[273 + tbloffset]))); + real2 v1485 = minusplus(v1483, v1484); + real2 v1487 = minusplus(uminus(v1483), v1484); + real2 v1501 = ctimesminusplus(reverse(v1487), tbl[268 + tbloffset], ctimes(v1487, tbl[269 + tbloffset])); + store(out, 52 << outShift, plus(v1481, v1501)); + real2 v1534 = minus(v1481, v1501); + store(out, 116 << outShift, ctimesminusplus(v1534, tbl[0 + tbloffset], ctimes(reverse(v1534), tbl[1 + tbloffset]))); + real2 v1495 = ctimesminusplus(reverse(v1485), tbl[266 + tbloffset], ctimes(v1485, tbl[267 + tbloffset])); + store(out, 20 << outShift, plus(v1475, v1495)); + real2 v1528 = minus(v1475, v1495); + store(out, 84 << outShift, ctimesminusplus(v1528, tbl[0 + tbloffset], ctimes(reverse(v1528), tbl[1 + tbloffset]))); + real2 v1249 = ctimesminusplus(reverse(v1235), tbl[224 + tbloffset], ctimes(v1235, tbl[225 + tbloffset])); + real2 v1169 = ctimesminusplus(reverse(v1155), tbl[208 + tbloffset], ctimes(v1155, tbl[209 + tbloffset])); + real2 v1567 = plus(v1169, v1249); + real2 v1561 = reverse(minus(v1169, v1249)); + real2 v1581 = reverse(minus(v1566, v1567)); + real2 v1587 = plus(v1566, v1567); + store(out, 12 << outShift, plus(v1586, v1587)); + real2 v1600 = minus(v1586, v1587); + store(out, 76 << outShift, ctimesminusplus(v1600, tbl[0 + tbloffset], ctimes(reverse(v1600), tbl[1 + tbloffset]))); + real2 v1583 = minusplus(v1581, v1582); + store(out, 44 << outShift, ctimesminusplus(reverse(v1583), tbl[282 + tbloffset], ctimes(v1583, tbl[283 + tbloffset]))); + real2 v1585 = minusplus(uminus(v1581), v1582); + store(out, 108 << outShift, ctimesminusplus(reverse(v1585), tbl[284 + tbloffset], ctimes(v1585, tbl[285 + tbloffset]))); + real2 v1565 = minusplus(uminus(v1561), v1562); + real2 v1563 = minusplus(v1561, v1562); + real2 v1579 = ctimesminusplus(reverse(v1565), tbl[280 + tbloffset], ctimes(v1565, tbl[281 + tbloffset])); + store(out, 60 << outShift, plus(v1559, v1579)); + real2 v1612 = minus(v1559, v1579); + store(out, 124 << outShift, ctimesminusplus(v1612, tbl[0 + tbloffset], ctimes(reverse(v1612), tbl[1 + tbloffset]))); + real2 v1573 = ctimesminusplus(reverse(v1563), tbl[278 + tbloffset], ctimes(v1563, tbl[279 + tbloffset])); + store(out, 28 << outShift, plus(v1553, v1573)); + real2 v1606 = minus(v1553, v1573); + store(out, 92 << outShift, ctimesminusplus(v1606, tbl[0 + tbloffset], ctimes(reverse(v1606), tbl[1 + tbloffset]))); + real2 v833 = minusplus(v831, v832); + real2 v835 = minusplus(uminus(v831), v832); + real2 v955 = minusplus(uminus(v951), v952); + real2 v953 = minusplus(v951, v952); + real2 v963 = ctimesminusplus(reverse(v953), tbl[166 + tbloffset], ctimes(v953, tbl[167 + tbloffset])); + real2 v995 = minusplus(uminus(v991), v992); + real2 v993 = minusplus(v991, v992); + real2 v1003 = ctimesminusplus(reverse(v993), tbl[174 + tbloffset], ctimes(v993, tbl[175 + tbloffset])); + real2 v843 = ctimesminusplus(reverse(v833), tbl[142 + tbloffset], ctimes(v833, tbl[143 + tbloffset])); + real2 v1640 = minus(v963, v803); + real2 v1644 = plus(v803, v963); + real2 v1680 = minus(v1003, v843); + real2 v1684 = plus(v843, v1003); + real2 v1641 = minusplus(v1639, v1640); + real2 v1643 = minusplus(uminus(v1639), v1640); + real2 v1657 = ctimesminusplus(reverse(v1643), tbl[292 + tbloffset], ctimes(v1643, tbl[293 + tbloffset])); + real2 v913 = minusplus(v911, v912); + real2 v915 = minusplus(uminus(v911), v912); + real2 v1073 = minusplus(v1071, v1072); + real2 v1075 = minusplus(uminus(v1071), v1072); + real2 v923 = ctimesminusplus(reverse(v913), tbl[158 + tbloffset], ctimes(v913, tbl[159 + tbloffset])); + real2 v1083 = ctimesminusplus(reverse(v1073), tbl[190 + tbloffset], ctimes(v1073, tbl[191 + tbloffset])); + real2 v1685 = plus(v923, v1083); + real2 v1679 = reverse(minus(v923, v1083)); + real2 v1681 = minusplus(v1679, v1680); + real2 v1683 = minusplus(uminus(v1679), v1680); + real2 v1697 = ctimesminusplus(reverse(v1683), tbl[300 + tbloffset], ctimes(v1683, tbl[301 + tbloffset])); + real2 v1809 = plus(v1657, v1697); + real2 v1803 = reverse(minus(v1657, v1697)); + store(out, 26 << outShift, plus(v1808, v1809)); + real2 v1822 = minus(v1808, v1809); + store(out, 90 << outShift, ctimesminusplus(v1822, tbl[0 + tbloffset], ctimes(reverse(v1822), tbl[1 + tbloffset]))); + real2 v1807 = minusplus(uminus(v1803), v1804); + real2 v1805 = minusplus(v1803, v1804); + store(out, 58 << outShift, ctimesminusplus(reverse(v1805), tbl[318 + tbloffset], ctimes(v1805, tbl[319 + tbloffset]))); + store(out, 122 << outShift, ctimesminusplus(reverse(v1807), tbl[320 + tbloffset], ctimes(v1807, tbl[321 + tbloffset]))); + real2 v1651 = ctimesminusplus(reverse(v1641), tbl[290 + tbloffset], ctimes(v1641, tbl[291 + tbloffset])); + real2 v1691 = ctimesminusplus(reverse(v1681), tbl[298 + tbloffset], ctimes(v1681, tbl[299 + tbloffset])); + real2 v1783 = plus(v1651, v1691); + real2 v1777 = reverse(minus(v1651, v1691)); + real2 v1779 = minusplus(v1777, v1778); + real2 v1781 = minusplus(uminus(v1777), v1778); + store(out, 106 << outShift, ctimesminusplus(reverse(v1781), tbl[316 + tbloffset], ctimes(v1781, tbl[317 + tbloffset]))); + store(out, 42 << outShift, ctimesminusplus(reverse(v1779), tbl[314 + tbloffset], ctimes(v1779, tbl[315 + tbloffset]))); + store(out, 10 << outShift, plus(v1782, v1783)); + real2 v1796 = minus(v1782, v1783); + store(out, 74 << outShift, ctimesminusplus(v1796, tbl[0 + tbloffset], ctimes(reverse(v1796), tbl[1 + tbloffset]))); + real2 v1720 = minus(v1645, v1644); + real2 v1724 = plus(v1644, v1645); + real2 v1719 = reverse(minus(v1684, v1685)); + real2 v1725 = plus(v1684, v1685); + real2 v1745 = plus(v1724, v1725); + real2 v1739 = reverse(minus(v1724, v1725)); + store(out, 2 << outShift, plus(v1744, v1745)); + real2 v1758 = minus(v1744, v1745); + store(out, 66 << outShift, ctimesminusplus(v1758, tbl[0 + tbloffset], ctimes(reverse(v1758), tbl[1 + tbloffset]))); + real2 v1741 = minusplus(v1739, v1740); + real2 v1743 = minusplus(uminus(v1739), v1740); + store(out, 98 << outShift, ctimesminusplus(reverse(v1743), tbl[312 + tbloffset], ctimes(v1743, tbl[313 + tbloffset]))); + store(out, 34 << outShift, ctimesminusplus(reverse(v1741), tbl[310 + tbloffset], ctimes(v1741, tbl[311 + tbloffset]))); + real2 v1723 = minusplus(uminus(v1719), v1720); + real2 v1721 = minusplus(v1719, v1720); + real2 v1737 = ctimesminusplus(reverse(v1723), tbl[308 + tbloffset], ctimes(v1723, tbl[309 + tbloffset])); + store(out, 50 << outShift, plus(v1717, v1737)); + real2 v1770 = minus(v1717, v1737); + store(out, 114 << outShift, ctimesminusplus(v1770, tbl[0 + tbloffset], ctimes(reverse(v1770), tbl[1 + tbloffset]))); + real2 v1731 = ctimesminusplus(reverse(v1721), tbl[306 + tbloffset], ctimes(v1721, tbl[307 + tbloffset])); + store(out, 18 << outShift, plus(v1711, v1731)); + real2 v1764 = minus(v1711, v1731); + store(out, 82 << outShift, ctimesminusplus(v1764, tbl[0 + tbloffset], ctimes(reverse(v1764), tbl[1 + tbloffset]))); + real2 v809 = ctimesminusplus(reverse(v795), tbl[136 + tbloffset], ctimes(v795, tbl[137 + tbloffset])); + real2 v969 = ctimesminusplus(reverse(v955), tbl[168 + tbloffset], ctimes(v955, tbl[169 + tbloffset])); + real2 v1850 = minus(v969, v809); + real2 v1854 = plus(v809, v969); + real2 v849 = ctimesminusplus(reverse(v835), tbl[144 + tbloffset], ctimes(v835, tbl[145 + tbloffset])); + real2 v929 = ctimesminusplus(reverse(v915), tbl[160 + tbloffset], ctimes(v915, tbl[161 + tbloffset])); + real2 v889 = ctimesminusplus(reverse(v875), tbl[152 + tbloffset], ctimes(v875, tbl[153 + tbloffset])); + real2 v1089 = ctimesminusplus(reverse(v1075), tbl[192 + tbloffset], ctimes(v1075, tbl[193 + tbloffset])); + real2 v1009 = ctimesminusplus(reverse(v995), tbl[176 + tbloffset], ctimes(v995, tbl[177 + tbloffset])); + real2 v1890 = minus(v1009, v849); + real2 v1894 = plus(v849, v1009); + real2 v1849 = reverse(minus(v889, v1049)); + real2 v1855 = plus(v889, v1049); + real2 v1930 = minus(v1855, v1854); + real2 v1934 = plus(v1854, v1855); + real2 v1895 = plus(v929, v1089); + real2 v1889 = reverse(minus(v929, v1089)); + real2 v1929 = reverse(minus(v1894, v1895)); + real2 v1935 = plus(v1894, v1895); + real2 v1955 = plus(v1934, v1935); + real2 v1949 = reverse(minus(v1934, v1935)); + store(out, 6 << outShift, plus(v1954, v1955)); + real2 v1968 = minus(v1954, v1955); + store(out, 70 << outShift, ctimesminusplus(v1968, tbl[0 + tbloffset], ctimes(reverse(v1968), tbl[1 + tbloffset]))); + real2 v1951 = minusplus(v1949, v1950); + store(out, 38 << outShift, ctimesminusplus(reverse(v1951), tbl[346 + tbloffset], ctimes(v1951, tbl[347 + tbloffset]))); + real2 v1953 = minusplus(uminus(v1949), v1950); + store(out, 102 << outShift, ctimesminusplus(reverse(v1953), tbl[348 + tbloffset], ctimes(v1953, tbl[349 + tbloffset]))); + real2 v1931 = minusplus(v1929, v1930); + real2 v1933 = minusplus(uminus(v1929), v1930); + real2 v1947 = ctimesminusplus(reverse(v1933), tbl[344 + tbloffset], ctimes(v1933, tbl[345 + tbloffset])); + store(out, 54 << outShift, plus(v1927, v1947)); + real2 v1980 = minus(v1927, v1947); + store(out, 118 << outShift, ctimesminusplus(v1980, tbl[0 + tbloffset], ctimes(reverse(v1980), tbl[1 + tbloffset]))); + real2 v1941 = ctimesminusplus(reverse(v1931), tbl[342 + tbloffset], ctimes(v1931, tbl[343 + tbloffset])); + store(out, 22 << outShift, plus(v1921, v1941)); + real2 v1974 = minus(v1921, v1941); + store(out, 86 << outShift, ctimesminusplus(v1974, tbl[0 + tbloffset], ctimes(reverse(v1974), tbl[1 + tbloffset]))); + real2 v1851 = minusplus(v1849, v1850); + real2 v1853 = minusplus(uminus(v1849), v1850); + real2 v1867 = ctimesminusplus(reverse(v1853), tbl[328 + tbloffset], ctimes(v1853, tbl[329 + tbloffset])); + real2 v1891 = minusplus(v1889, v1890); + real2 v1893 = minusplus(uminus(v1889), v1890); + real2 v1907 = ctimesminusplus(reverse(v1893), tbl[336 + tbloffset], ctimes(v1893, tbl[337 + tbloffset])); + real2 v2019 = plus(v1867, v1907); + real2 v2013 = reverse(minus(v1867, v1907)); + store(out, 30 << outShift, plus(v2018, v2019)); + real2 v2032 = minus(v2018, v2019); + store(out, 94 << outShift, ctimesminusplus(v2032, tbl[0 + tbloffset], ctimes(reverse(v2032), tbl[1 + tbloffset]))); + real2 v2017 = minusplus(uminus(v2013), v2014); + store(out, 126 << outShift, ctimesminusplus(reverse(v2017), tbl[356 + tbloffset], ctimes(v2017, tbl[357 + tbloffset]))); + real2 v2015 = minusplus(v2013, v2014); + store(out, 62 << outShift, ctimesminusplus(reverse(v2015), tbl[354 + tbloffset], ctimes(v2015, tbl[355 + tbloffset]))); + real2 v1861 = ctimesminusplus(reverse(v1851), tbl[326 + tbloffset], ctimes(v1851, tbl[327 + tbloffset])); + real2 v1901 = ctimesminusplus(reverse(v1891), tbl[334 + tbloffset], ctimes(v1891, tbl[335 + tbloffset])); + real2 v1993 = plus(v1861, v1901); + real2 v1987 = reverse(minus(v1861, v1901)); + store(out, 14 << outShift, plus(v1992, v1993)); + real2 v2006 = minus(v1992, v1993); + store(out, 78 << outShift, ctimesminusplus(v2006, tbl[0 + tbloffset], ctimes(reverse(v2006), tbl[1 + tbloffset]))); + real2 v1991 = minusplus(uminus(v1987), v1988); + store(out, 110 << outShift, ctimesminusplus(reverse(v1991), tbl[352 + tbloffset], ctimes(v1991, tbl[353 + tbloffset]))); + real2 v1989 = minusplus(v1987, v1988); + store(out, 46 << outShift, ctimesminusplus(reverse(v1989), tbl[350 + tbloffset], ctimes(v1989, tbl[351 + tbloffset]))); + real2 v593 = minusplus(v591, v592); + real2 v595 = minusplus(uminus(v591), v592); + real2 v473 = minusplus(v471, v472); + real2 v475 = minusplus(uminus(v471), v472); + real2 v555 = minusplus(uminus(v551), v552); + real2 v553 = minusplus(v551, v552); + real2 v609 = ctimesminusplus(reverse(v595), tbl[96 + tbloffset], ctimes(v595, tbl[97 + tbloffset])); + real2 v195 = minusplus(uminus(v191), v192); + real2 v193 = minusplus(v191, v192); + real2 v275 = minusplus(uminus(v271), v272); + real2 v273 = minusplus(v271, v272); + real2 v673 = minusplus(v671, v672); + real2 v675 = minusplus(uminus(v671), v672); + real2 v689 = ctimesminusplus(reverse(v675), tbl[112 + tbloffset], ctimes(v675, tbl[113 + tbloffset])); + real2 v209 = ctimesminusplus(reverse(v195), tbl[16 + tbloffset], ctimes(v195, tbl[17 + tbloffset])); + real2 v289 = ctimesminusplus(reverse(v275), tbl[32 + tbloffset], ctimes(v275, tbl[33 + tbloffset])); + real2 v755 = minusplus(uminus(v751), v752); + real2 v753 = minusplus(v751, v752); + real2 v435 = minusplus(uminus(v431), v432); + real2 v433 = minusplus(v431, v432); + real2 v513 = minusplus(v511, v512); + real2 v515 = minusplus(uminus(v511), v512); + real2 v529 = ctimesminusplus(reverse(v515), tbl[80 + tbloffset], ctimes(v515, tbl[81 + tbloffset])); + real2 v353 = minusplus(v351, v352); + real2 v355 = minusplus(uminus(v351), v352); + real2 v369 = ctimesminusplus(reverse(v355), tbl[48 + tbloffset], ctimes(v355, tbl[49 + tbloffset])); + real2 v2631 = plus(v369, v689); + real2 v2625 = reverse(minus(v369, v689)); + real2 v449 = ctimesminusplus(reverse(v435), tbl[64 + tbloffset], ctimes(v435, tbl[65 + tbloffset])); + real2 v2710 = plus(v289, v609); + real2 v2706 = minus(v609, v289); + real2 v2630 = plus(v209, v529); + real2 v2626 = minus(v529, v209); + real2 v2790 = plus(v2630, v2631); + real2 v2786 = minus(v2631, v2630); + real2 v713 = minusplus(v711, v712); + real2 v715 = minusplus(uminus(v711), v712); + real2 v769 = ctimesminusplus(reverse(v755), tbl[128 + tbloffset], ctimes(v755, tbl[129 + tbloffset])); + real2 v2705 = reverse(minus(v449, v769)); + real2 v2711 = plus(v449, v769); + real2 v313 = minusplus(v311, v312); + real2 v315 = minusplus(uminus(v311), v312); + real2 v393 = minusplus(v391, v392); + real2 v395 = minusplus(uminus(v391), v392); + real2 v409 = ctimesminusplus(reverse(v395), tbl[56 + tbloffset], ctimes(v395, tbl[57 + tbloffset])); + real2 v729 = ctimesminusplus(reverse(v715), tbl[120 + tbloffset], ctimes(v715, tbl[121 + tbloffset])); + real2 v329 = ctimesminusplus(reverse(v315), tbl[40 + tbloffset], ctimes(v315, tbl[41 + tbloffset])); + real2 v489 = ctimesminusplus(reverse(v475), tbl[72 + tbloffset], ctimes(v475, tbl[73 + tbloffset])); + real2 v153 = minusplus(v151, v152); + real2 v155 = minusplus(uminus(v151), v152); + real2 v169 = ctimesminusplus(reverse(v155), tbl[8 + tbloffset], ctimes(v155, tbl[9 + tbloffset])); + real2 v2586 = minus(v489, v169); + real2 v2590 = plus(v169, v489); + real2 v233 = minusplus(v231, v232); + real2 v235 = minusplus(uminus(v231), v232); + real2 v633 = minusplus(v631, v632); + real2 v635 = minusplus(uminus(v631), v632); + real2 v649 = ctimesminusplus(reverse(v635), tbl[104 + tbloffset], ctimes(v635, tbl[105 + tbloffset])); + real2 v249 = ctimesminusplus(reverse(v235), tbl[24 + tbloffset], ctimes(v235, tbl[25 + tbloffset])); + real2 v569 = ctimesminusplus(reverse(v555), tbl[88 + tbloffset], ctimes(v555, tbl[89 + tbloffset])); + real2 v2670 = plus(v249, v569); + real2 v2666 = minus(v569, v249); + real2 v2785 = reverse(minus(v2710, v2711)); + real2 v2791 = plus(v2710, v2711); + real2 v2825 = reverse(minus(v2790, v2791)); + real2 v2831 = plus(v2790, v2791); + real2 v2671 = plus(v409, v729); + real2 v2665 = reverse(minus(v409, v729)); + real2 v2745 = reverse(minus(v2670, v2671)); + real2 v2751 = plus(v2670, v2671); + real2 v2806 = minus(v2731, v2730); + real2 v2810 = plus(v2730, v2731); + real2 v2846 = minus(v2811, v2810); + real2 v2850 = plus(v2810, v2811); + real2 v2591 = plus(v329, v649); + real2 v2585 = reverse(minus(v329, v649)); + real2 v2750 = plus(v2590, v2591); + real2 v2746 = minus(v2591, v2590); + real2 v2830 = plus(v2750, v2751); + real2 v2826 = minus(v2751, v2750); + real2 v2845 = reverse(minus(v2830, v2831)); + real2 v2851 = plus(v2830, v2831); + store(out, 3 << outShift, plus(v2850, v2851)); + real2 v2864 = minus(v2850, v2851); + store(out, 67 << outShift, ctimesminusplus(v2864, tbl[0 + tbloffset], ctimes(reverse(v2864), tbl[1 + tbloffset]))); + real2 v2849 = minusplus(uminus(v2845), v2846); + real2 v2847 = minusplus(v2845, v2846); + store(out, 35 << outShift, ctimesminusplus(reverse(v2847), tbl[506 + tbloffset], ctimes(v2847, tbl[507 + tbloffset]))); + store(out, 99 << outShift, ctimesminusplus(reverse(v2849), tbl[508 + tbloffset], ctimes(v2849, tbl[509 + tbloffset]))); + real2 v2827 = minusplus(v2825, v2826); + real2 v2829 = minusplus(uminus(v2825), v2826); + real2 v2837 = ctimesminusplus(reverse(v2827), tbl[502 + tbloffset], ctimes(v2827, tbl[503 + tbloffset])); + real2 v2809 = minusplus(uminus(v2805), v2806); + real2 v2807 = minusplus(v2805, v2806); + real2 v2817 = ctimesminusplus(reverse(v2807), tbl[498 + tbloffset], ctimes(v2807, tbl[499 + tbloffset])); + store(out, 19 << outShift, plus(v2817, v2837)); + real2 v2870 = minus(v2817, v2837); + store(out, 83 << outShift, ctimesminusplus(v2870, tbl[0 + tbloffset], ctimes(reverse(v2870), tbl[1 + tbloffset]))); + real2 v2823 = ctimesminusplus(reverse(v2809), tbl[500 + tbloffset], ctimes(v2809, tbl[501 + tbloffset])); + real2 v2843 = ctimesminusplus(reverse(v2829), tbl[504 + tbloffset], ctimes(v2829, tbl[505 + tbloffset])); + store(out, 51 << outShift, plus(v2823, v2843)); + real2 v2876 = minus(v2823, v2843); + store(out, 115 << outShift, ctimesminusplus(v2876, tbl[0 + tbloffset], ctimes(reverse(v2876), tbl[1 + tbloffset]))); + real2 v2787 = minusplus(v2785, v2786); + real2 v2789 = minusplus(uminus(v2785), v2786); + real2 v2803 = ctimesminusplus(reverse(v2789), tbl[496 + tbloffset], ctimes(v2789, tbl[497 + tbloffset])); + real2 v2727 = minusplus(v2725, v2726); + real2 v2729 = minusplus(uminus(v2725), v2726); + real2 v2743 = ctimesminusplus(reverse(v2729), tbl[484 + tbloffset], ctimes(v2729, tbl[485 + tbloffset])); + real2 v2914 = plus(v2743, v2783); + real2 v2910 = minus(v2783, v2743); + real2 v2749 = minusplus(uminus(v2745), v2746); + real2 v2747 = minusplus(v2745, v2746); + real2 v2763 = ctimesminusplus(reverse(v2749), tbl[488 + tbloffset], ctimes(v2749, tbl[489 + tbloffset])); + real2 v2909 = reverse(minus(v2763, v2803)); + real2 v2915 = plus(v2763, v2803); + store(out, 27 << outShift, plus(v2914, v2915)); + real2 v2928 = minus(v2914, v2915); + store(out, 91 << outShift, ctimesminusplus(v2928, tbl[0 + tbloffset], ctimes(reverse(v2928), tbl[1 + tbloffset]))); + real2 v2913 = minusplus(uminus(v2909), v2910); + store(out, 123 << outShift, ctimesminusplus(reverse(v2913), tbl[516 + tbloffset], ctimes(v2913, tbl[517 + tbloffset]))); + real2 v2911 = minusplus(v2909, v2910); + store(out, 59 << outShift, ctimesminusplus(reverse(v2911), tbl[514 + tbloffset], ctimes(v2911, tbl[515 + tbloffset]))); + real2 v2737 = ctimesminusplus(reverse(v2727), tbl[482 + tbloffset], ctimes(v2727, tbl[483 + tbloffset])); + real2 v2888 = plus(v2737, v2777); + real2 v2884 = minus(v2777, v2737); + real2 v2797 = ctimesminusplus(reverse(v2787), tbl[494 + tbloffset], ctimes(v2787, tbl[495 + tbloffset])); + real2 v2757 = ctimesminusplus(reverse(v2747), tbl[486 + tbloffset], ctimes(v2747, tbl[487 + tbloffset])); + real2 v2889 = plus(v2757, v2797); + real2 v2883 = reverse(minus(v2757, v2797)); + store(out, 11 << outShift, plus(v2888, v2889)); + real2 v2902 = minus(v2888, v2889); + store(out, 75 << outShift, ctimesminusplus(v2902, tbl[0 + tbloffset], ctimes(reverse(v2902), tbl[1 + tbloffset]))); + real2 v2887 = minusplus(uminus(v2883), v2884); + store(out, 107 << outShift, ctimesminusplus(reverse(v2887), tbl[512 + tbloffset], ctimes(v2887, tbl[513 + tbloffset]))); + real2 v2885 = minusplus(v2883, v2884); + store(out, 43 << outShift, ctimesminusplus(reverse(v2885), tbl[510 + tbloffset], ctimes(v2885, tbl[511 + tbloffset]))); + real2 v2669 = minusplus(uminus(v2665), v2666); + real2 v2667 = minusplus(v2665, v2666); + real2 v2707 = minusplus(v2705, v2706); + real2 v2709 = minusplus(uminus(v2705), v2706); + real2 v2717 = ctimesminusplus(reverse(v2707), tbl[478 + tbloffset], ctimes(v2707, tbl[479 + tbloffset])); + real2 v2627 = minusplus(v2625, v2626); + real2 v2629 = minusplus(uminus(v2625), v2626); + real2 v2637 = ctimesminusplus(reverse(v2627), tbl[462 + tbloffset], ctimes(v2627, tbl[463 + tbloffset])); + real2 v2961 = plus(v2637, v2717); + real2 v2955 = reverse(minus(v2637, v2717)); + real2 v2649 = minusplus(uminus(v2645), v2646); + real2 v2647 = minusplus(v2645, v2646); + real2 v2569 = minusplus(uminus(v2565), v2566); + real2 v2567 = minusplus(v2565, v2566); + real2 v2577 = ctimesminusplus(reverse(v2567), tbl[450 + tbloffset], ctimes(v2567, tbl[451 + tbloffset])); + real2 v2657 = ctimesminusplus(reverse(v2647), tbl[466 + tbloffset], ctimes(v2647, tbl[467 + tbloffset])); + real2 v2936 = minus(v2657, v2577); + real2 v2940 = plus(v2577, v2657); + real2 v2976 = minus(v2941, v2940); + real2 v2980 = plus(v2940, v2941); + real2 v2677 = ctimesminusplus(reverse(v2667), tbl[470 + tbloffset], ctimes(v2667, tbl[471 + tbloffset])); + real2 v2587 = minusplus(v2585, v2586); + real2 v2589 = minusplus(uminus(v2585), v2586); + real2 v2597 = ctimesminusplus(reverse(v2587), tbl[454 + tbloffset], ctimes(v2587, tbl[455 + tbloffset])); + real2 v2956 = minus(v2677, v2597); + real2 v2960 = plus(v2597, v2677); + real2 v2975 = reverse(minus(v2960, v2961)); + real2 v2981 = plus(v2960, v2961); + store(out, 7 << outShift, plus(v2980, v2981)); + real2 v2994 = minus(v2980, v2981); + store(out, 71 << outShift, ctimesminusplus(v2994, tbl[0 + tbloffset], ctimes(reverse(v2994), tbl[1 + tbloffset]))); + real2 v2979 = minusplus(uminus(v2975), v2976); + store(out, 103 << outShift, ctimesminusplus(reverse(v2979), tbl[528 + tbloffset], ctimes(v2979, tbl[529 + tbloffset]))); + real2 v2977 = minusplus(v2975, v2976); + store(out, 39 << outShift, ctimesminusplus(reverse(v2977), tbl[526 + tbloffset], ctimes(v2977, tbl[527 + tbloffset]))); + real2 v2939 = minusplus(uminus(v2935), v2936); + real2 v2937 = minusplus(v2935, v2936); + real2 v2953 = ctimesminusplus(reverse(v2939), tbl[520 + tbloffset], ctimes(v2939, tbl[521 + tbloffset])); + real2 v2957 = minusplus(v2955, v2956); + real2 v2959 = minusplus(uminus(v2955), v2956); + real2 v2973 = ctimesminusplus(reverse(v2959), tbl[524 + tbloffset], ctimes(v2959, tbl[525 + tbloffset])); + store(out, 55 << outShift, plus(v2953, v2973)); + real2 v3006 = minus(v2953, v2973); + store(out, 119 << outShift, ctimesminusplus(v3006, tbl[0 + tbloffset], ctimes(reverse(v3006), tbl[1 + tbloffset]))); + real2 v2947 = ctimesminusplus(reverse(v2937), tbl[518 + tbloffset], ctimes(v2937, tbl[519 + tbloffset])); + real2 v2967 = ctimesminusplus(reverse(v2957), tbl[522 + tbloffset], ctimes(v2957, tbl[523 + tbloffset])); + store(out, 23 << outShift, plus(v2947, v2967)); + real2 v3000 = minus(v2947, v2967); + store(out, 87 << outShift, ctimesminusplus(v3000, tbl[0 + tbloffset], ctimes(reverse(v3000), tbl[1 + tbloffset]))); + real2 v2663 = ctimesminusplus(reverse(v2649), tbl[468 + tbloffset], ctimes(v2649, tbl[469 + tbloffset])); + real2 v2583 = ctimesminusplus(reverse(v2569), tbl[452 + tbloffset], ctimes(v2569, tbl[453 + tbloffset])); + real2 v3014 = minus(v2663, v2583); + real2 v3018 = plus(v2583, v2663); + real2 v3015 = minusplus(v3013, v3014); + real2 v3017 = minusplus(uminus(v3013), v3014); + real2 v2643 = ctimesminusplus(reverse(v2629), tbl[464 + tbloffset], ctimes(v2629, tbl[465 + tbloffset])); + real2 v2723 = ctimesminusplus(reverse(v2709), tbl[480 + tbloffset], ctimes(v2709, tbl[481 + tbloffset])); + real2 v3039 = plus(v2643, v2723); + real2 v3033 = reverse(minus(v2643, v2723)); + real2 v2683 = ctimesminusplus(reverse(v2669), tbl[472 + tbloffset], ctimes(v2669, tbl[473 + tbloffset])); + real2 v3031 = ctimesminusplus(reverse(v3017), tbl[532 + tbloffset], ctimes(v3017, tbl[533 + tbloffset])); + real2 v2603 = ctimesminusplus(reverse(v2589), tbl[456 + tbloffset], ctimes(v2589, tbl[457 + tbloffset])); + real2 v3034 = minus(v2683, v2603); + real2 v3038 = plus(v2603, v2683); + real2 v3037 = minusplus(uminus(v3033), v3034); + real2 v3035 = minusplus(v3033, v3034); + real2 v3051 = ctimesminusplus(reverse(v3037), tbl[536 + tbloffset], ctimes(v3037, tbl[537 + tbloffset])); + store(out, 63 << outShift, plus(v3031, v3051)); + real2 v3084 = minus(v3031, v3051); + store(out, 127 << outShift, ctimesminusplus(v3084, tbl[0 + tbloffset], ctimes(reverse(v3084), tbl[1 + tbloffset]))); + real2 v3025 = ctimesminusplus(reverse(v3015), tbl[530 + tbloffset], ctimes(v3015, tbl[531 + tbloffset])); + real2 v3045 = ctimesminusplus(reverse(v3035), tbl[534 + tbloffset], ctimes(v3035, tbl[535 + tbloffset])); + store(out, 31 << outShift, plus(v3025, v3045)); + real2 v3078 = minus(v3025, v3045); + store(out, 95 << outShift, ctimesminusplus(v3078, tbl[0 + tbloffset], ctimes(reverse(v3078), tbl[1 + tbloffset]))); + real2 v3058 = plus(v3018, v3019); + real2 v3054 = minus(v3019, v3018); + real2 v3053 = reverse(minus(v3038, v3039)); + real2 v3059 = plus(v3038, v3039); + real2 v3055 = minusplus(v3053, v3054); + store(out, 47 << outShift, ctimesminusplus(reverse(v3055), tbl[538 + tbloffset], ctimes(v3055, tbl[539 + tbloffset]))); + real2 v3057 = minusplus(uminus(v3053), v3054); + store(out, 111 << outShift, ctimesminusplus(reverse(v3057), tbl[540 + tbloffset], ctimes(v3057, tbl[541 + tbloffset]))); + store(out, 15 << outShift, plus(v3058, v3059)); + real2 v3072 = minus(v3058, v3059); + store(out, 79 << outShift, ctimesminusplus(v3072, tbl[0 + tbloffset], ctimes(reverse(v3072), tbl[1 + tbloffset]))); + real2 v683 = ctimesminusplus(reverse(v673), tbl[110 + tbloffset], ctimes(v673, tbl[111 + tbloffset])); + real2 v363 = ctimesminusplus(reverse(v353), tbl[46 + tbloffset], ctimes(v353, tbl[47 + tbloffset])); + real2 v2105 = plus(v363, v683); + real2 v2099 = reverse(minus(v363, v683)); + real2 v283 = ctimesminusplus(reverse(v273), tbl[30 + tbloffset], ctimes(v273, tbl[31 + tbloffset])); + real2 v723 = ctimesminusplus(reverse(v713), tbl[118 + tbloffset], ctimes(v713, tbl[119 + tbloffset])); + real2 v403 = ctimesminusplus(reverse(v393), tbl[54 + tbloffset], ctimes(v393, tbl[55 + tbloffset])); + real2 v603 = ctimesminusplus(reverse(v593), tbl[94 + tbloffset], ctimes(v593, tbl[95 + tbloffset])); + real2 v2180 = minus(v603, v283); + real2 v2184 = plus(v283, v603); + real2 v2145 = plus(v403, v723); + real2 v2139 = reverse(minus(v403, v723)); + real2 v543 = ctimesminusplus(reverse(v533), tbl[82 + tbloffset], ctimes(v533, tbl[83 + tbloffset])); + real2 v383 = ctimesminusplus(reverse(v373), tbl[50 + tbloffset], ctimes(v373, tbl[51 + tbloffset])); + real2 v703 = ctimesminusplus(reverse(v693), tbl[114 + tbloffset], ctimes(v693, tbl[115 + tbloffset])); + real2 v2125 = plus(v383, v703); + real2 v2119 = reverse(minus(v383, v703)); + real2 v223 = ctimesminusplus(reverse(v213), tbl[18 + tbloffset], ctimes(v213, tbl[19 + tbloffset])); + real2 v2120 = minus(v543, v223); + real2 v2124 = plus(v223, v543); + real2 v443 = ctimesminusplus(reverse(v433), tbl[62 + tbloffset], ctimes(v433, tbl[63 + tbloffset])); + real2 v203 = ctimesminusplus(reverse(v193), tbl[14 + tbloffset], ctimes(v193, tbl[15 + tbloffset])); + real2 v763 = ctimesminusplus(reverse(v753), tbl[126 + tbloffset], ctimes(v753, tbl[127 + tbloffset])); + real2 v2179 = reverse(minus(v443, v763)); + real2 v2185 = plus(v443, v763); + real2 v523 = ctimesminusplus(reverse(v513), tbl[78 + tbloffset], ctimes(v513, tbl[79 + tbloffset])); + real2 v2100 = minus(v523, v203); + real2 v2104 = plus(v203, v523); + real2 v2264 = plus(v2104, v2105); + real2 v2260 = minus(v2105, v2104); + real2 v643 = ctimesminusplus(reverse(v633), tbl[102 + tbloffset], ctimes(v633, tbl[103 + tbloffset])); + real2 v2265 = plus(v2184, v2185); + real2 v2259 = reverse(minus(v2184, v2185)); + real2 v563 = ctimesminusplus(reverse(v553), tbl[86 + tbloffset], ctimes(v553, tbl[87 + tbloffset])); + real2 v243 = ctimesminusplus(reverse(v233), tbl[22 + tbloffset], ctimes(v233, tbl[23 + tbloffset])); + real2 v2144 = plus(v243, v563); + real2 v2140 = minus(v563, v243); + real2 v143 = ctimesminusplus(reverse(v133), tbl[2 + tbloffset], ctimes(v133, tbl[3 + tbloffset])); + real2 v183 = ctimesminusplus(reverse(v173), tbl[10 + tbloffset], ctimes(v173, tbl[11 + tbloffset])); + real2 v2084 = plus(v183, v503); + real2 v2080 = minus(v503, v183); + real2 v163 = ctimesminusplus(reverse(v153), tbl[6 + tbloffset], ctimes(v153, tbl[7 + tbloffset])); + real2 v303 = ctimesminusplus(reverse(v293), tbl[34 + tbloffset], ctimes(v293, tbl[35 + tbloffset])); + real2 v623 = ctimesminusplus(reverse(v613), tbl[98 + tbloffset], ctimes(v613, tbl[99 + tbloffset])); + real2 v2039 = reverse(minus(v303, v623)); + real2 v2045 = plus(v303, v623); + real2 v463 = ctimesminusplus(reverse(v453), tbl[66 + tbloffset], ctimes(v453, tbl[67 + tbloffset])); + real2 v2044 = plus(v143, v463); + real2 v2040 = minus(v463, v143); + real2 v2204 = plus(v2044, v2045); + real2 v2200 = minus(v2045, v2044); + real2 v323 = ctimesminusplus(reverse(v313), tbl[38 + tbloffset], ctimes(v313, tbl[39 + tbloffset])); + real2 v2205 = plus(v2124, v2125); + real2 v2199 = reverse(minus(v2124, v2125)); + real2 v2280 = minus(v2205, v2204); + real2 v2284 = plus(v2204, v2205); + real2 v2225 = plus(v2144, v2145); + real2 v2219 = reverse(minus(v2144, v2145)); + real2 v2305 = plus(v2264, v2265); + real2 v2299 = reverse(minus(v2264, v2265)); + real2 v2240 = minus(v2085, v2084); + real2 v2244 = plus(v2084, v2085); + real2 v2279 = reverse(minus(v2244, v2245)); + real2 v2285 = plus(v2244, v2245); + real2 v2281 = minusplus(v2279, v2280); + real2 v2283 = minusplus(uminus(v2279), v2280); + real2 v2291 = ctimesminusplus(reverse(v2281), tbl[406 + tbloffset], ctimes(v2281, tbl[407 + tbloffset])); + real2 v483 = ctimesminusplus(reverse(v473), tbl[70 + tbloffset], ctimes(v473, tbl[71 + tbloffset])); + real2 v2060 = minus(v483, v163); + real2 v2064 = plus(v163, v483); + real2 v2065 = plus(v323, v643); + real2 v2059 = reverse(minus(v323, v643)); + real2 v2220 = minus(v2065, v2064); + real2 v2224 = plus(v2064, v2065); + real2 v2304 = plus(v2224, v2225); + real2 v2300 = minus(v2225, v2224); + real2 v2301 = minusplus(v2299, v2300); + real2 v2303 = minusplus(uminus(v2299), v2300); + real2 v2311 = ctimesminusplus(reverse(v2301), tbl[410 + tbloffset], ctimes(v2301, tbl[411 + tbloffset])); + store(out, 17 << outShift, plus(v2291, v2311)); + real2 v2344 = minus(v2291, v2311); + store(out, 81 << outShift, ctimesminusplus(v2344, tbl[0 + tbloffset], ctimes(reverse(v2344), tbl[1 + tbloffset]))); + real2 v2297 = ctimesminusplus(reverse(v2283), tbl[408 + tbloffset], ctimes(v2283, tbl[409 + tbloffset])); + real2 v2317 = ctimesminusplus(reverse(v2303), tbl[412 + tbloffset], ctimes(v2303, tbl[413 + tbloffset])); + store(out, 49 << outShift, plus(v2297, v2317)); + real2 v2350 = minus(v2297, v2317); + store(out, 113 << outShift, ctimesminusplus(v2350, tbl[0 + tbloffset], ctimes(reverse(v2350), tbl[1 + tbloffset]))); + real2 v2320 = minus(v2285, v2284); + real2 v2324 = plus(v2284, v2285); + real2 v2325 = plus(v2304, v2305); + real2 v2319 = reverse(minus(v2304, v2305)); + store(out, 1 << outShift, plus(v2324, v2325)); + real2 v2338 = minus(v2324, v2325); + store(out, 65 << outShift, ctimesminusplus(v2338, tbl[0 + tbloffset], ctimes(reverse(v2338), tbl[1 + tbloffset]))); + real2 v2321 = minusplus(v2319, v2320); + store(out, 33 << outShift, ctimesminusplus(reverse(v2321), tbl[414 + tbloffset], ctimes(v2321, tbl[415 + tbloffset]))); + real2 v2323 = minusplus(uminus(v2319), v2320); + store(out, 97 << outShift, ctimesminusplus(reverse(v2323), tbl[416 + tbloffset], ctimes(v2323, tbl[417 + tbloffset]))); + real2 v2201 = minusplus(v2199, v2200); + real2 v2203 = minusplus(uminus(v2199), v2200); + real2 v2263 = minusplus(uminus(v2259), v2260); + real2 v2261 = minusplus(v2259, v2260); + real2 v2243 = minusplus(uminus(v2239), v2240); + real2 v2241 = minusplus(v2239, v2240); + real2 v2257 = ctimesminusplus(reverse(v2243), tbl[400 + tbloffset], ctimes(v2243, tbl[401 + tbloffset])); + real2 v2217 = ctimesminusplus(reverse(v2203), tbl[392 + tbloffset], ctimes(v2203, tbl[393 + tbloffset])); + real2 v2388 = plus(v2217, v2257); + real2 v2384 = minus(v2257, v2217); + real2 v2277 = ctimesminusplus(reverse(v2263), tbl[404 + tbloffset], ctimes(v2263, tbl[405 + tbloffset])); + real2 v2221 = minusplus(v2219, v2220); + real2 v2223 = minusplus(uminus(v2219), v2220); + real2 v2237 = ctimesminusplus(reverse(v2223), tbl[396 + tbloffset], ctimes(v2223, tbl[397 + tbloffset])); + real2 v2389 = plus(v2237, v2277); + real2 v2383 = reverse(minus(v2237, v2277)); + store(out, 25 << outShift, plus(v2388, v2389)); + real2 v2402 = minus(v2388, v2389); + store(out, 89 << outShift, ctimesminusplus(v2402, tbl[0 + tbloffset], ctimes(reverse(v2402), tbl[1 + tbloffset]))); + real2 v2385 = minusplus(v2383, v2384); + real2 v2387 = minusplus(uminus(v2383), v2384); + store(out, 121 << outShift, ctimesminusplus(reverse(v2387), tbl[424 + tbloffset], ctimes(v2387, tbl[425 + tbloffset]))); + store(out, 57 << outShift, ctimesminusplus(reverse(v2385), tbl[422 + tbloffset], ctimes(v2385, tbl[423 + tbloffset]))); + real2 v2251 = ctimesminusplus(reverse(v2241), tbl[398 + tbloffset], ctimes(v2241, tbl[399 + tbloffset])); + real2 v2211 = ctimesminusplus(reverse(v2201), tbl[390 + tbloffset], ctimes(v2201, tbl[391 + tbloffset])); + real2 v2358 = minus(v2251, v2211); + real2 v2362 = plus(v2211, v2251); + real2 v2271 = ctimesminusplus(reverse(v2261), tbl[402 + tbloffset], ctimes(v2261, tbl[403 + tbloffset])); + real2 v2231 = ctimesminusplus(reverse(v2221), tbl[394 + tbloffset], ctimes(v2221, tbl[395 + tbloffset])); + real2 v2357 = reverse(minus(v2231, v2271)); + real2 v2363 = plus(v2231, v2271); + store(out, 9 << outShift, plus(v2362, v2363)); + real2 v2376 = minus(v2362, v2363); + store(out, 73 << outShift, ctimesminusplus(v2376, tbl[0 + tbloffset], ctimes(reverse(v2376), tbl[1 + tbloffset]))); + real2 v2361 = minusplus(uminus(v2357), v2358); + store(out, 105 << outShift, ctimesminusplus(reverse(v2361), tbl[420 + tbloffset], ctimes(v2361, tbl[421 + tbloffset]))); + real2 v2359 = minusplus(v2357, v2358); + store(out, 41 << outShift, ctimesminusplus(reverse(v2359), tbl[418 + tbloffset], ctimes(v2359, tbl[419 + tbloffset]))); + real2 v2121 = minusplus(v2119, v2120); + real2 v2123 = minusplus(uminus(v2119), v2120); + real2 v2083 = minusplus(uminus(v2079), v2080); + real2 v2081 = minusplus(v2079, v2080); + real2 v2091 = ctimesminusplus(reverse(v2081), tbl[366 + tbloffset], ctimes(v2081, tbl[367 + tbloffset])); + real2 v2043 = minusplus(uminus(v2039), v2040); + real2 v2041 = minusplus(v2039, v2040); + real2 v2051 = ctimesminusplus(reverse(v2041), tbl[358 + tbloffset], ctimes(v2041, tbl[359 + tbloffset])); + real2 v2131 = ctimesminusplus(reverse(v2121), tbl[374 + tbloffset], ctimes(v2121, tbl[375 + tbloffset])); + real2 v2163 = minusplus(uminus(v2159), v2160); + real2 v2161 = minusplus(v2159, v2160); + real2 v2171 = ctimesminusplus(reverse(v2161), tbl[382 + tbloffset], ctimes(v2161, tbl[383 + tbloffset])); + real2 v2409 = reverse(minus(v2091, v2171)); + real2 v2415 = plus(v2091, v2171); + real2 v2410 = minus(v2131, v2051); + real2 v2414 = plus(v2051, v2131); + real2 v2454 = plus(v2414, v2415); + real2 v2450 = minus(v2415, v2414); + real2 v2181 = minusplus(v2179, v2180); + real2 v2183 = minusplus(uminus(v2179), v2180); + real2 v2191 = ctimesminusplus(reverse(v2181), tbl[386 + tbloffset], ctimes(v2181, tbl[387 + tbloffset])); + real2 v2103 = minusplus(uminus(v2099), v2100); + real2 v2101 = minusplus(v2099, v2100); + real2 v2111 = ctimesminusplus(reverse(v2101), tbl[370 + tbloffset], ctimes(v2101, tbl[371 + tbloffset])); + real2 v2435 = plus(v2111, v2191); + real2 v2429 = reverse(minus(v2111, v2191)); + real2 v2141 = minusplus(v2139, v2140); + real2 v2143 = minusplus(uminus(v2139), v2140); + real2 v2151 = ctimesminusplus(reverse(v2141), tbl[378 + tbloffset], ctimes(v2141, tbl[379 + tbloffset])); + real2 v2063 = minusplus(uminus(v2059), v2060); + real2 v2061 = minusplus(v2059, v2060); + real2 v2071 = ctimesminusplus(reverse(v2061), tbl[362 + tbloffset], ctimes(v2061, tbl[363 + tbloffset])); + real2 v2434 = plus(v2071, v2151); + real2 v2430 = minus(v2151, v2071); + real2 v2455 = plus(v2434, v2435); + real2 v2449 = reverse(minus(v2434, v2435)); + store(out, 5 << outShift, plus(v2454, v2455)); + real2 v2468 = minus(v2454, v2455); + store(out, 69 << outShift, ctimesminusplus(v2468, tbl[0 + tbloffset], ctimes(reverse(v2468), tbl[1 + tbloffset]))); + real2 v2451 = minusplus(v2449, v2450); + real2 v2453 = minusplus(uminus(v2449), v2450); + store(out, 101 << outShift, ctimesminusplus(reverse(v2453), tbl[436 + tbloffset], ctimes(v2453, tbl[437 + tbloffset]))); + store(out, 37 << outShift, ctimesminusplus(reverse(v2451), tbl[434 + tbloffset], ctimes(v2451, tbl[435 + tbloffset]))); + real2 v2411 = minusplus(v2409, v2410); + real2 v2413 = minusplus(uminus(v2409), v2410); + real2 v2433 = minusplus(uminus(v2429), v2430); + real2 v2431 = minusplus(v2429, v2430); + real2 v2421 = ctimesminusplus(reverse(v2411), tbl[426 + tbloffset], ctimes(v2411, tbl[427 + tbloffset])); + real2 v2441 = ctimesminusplus(reverse(v2431), tbl[430 + tbloffset], ctimes(v2431, tbl[431 + tbloffset])); + store(out, 21 << outShift, plus(v2421, v2441)); + real2 v2474 = minus(v2421, v2441); + store(out, 85 << outShift, ctimesminusplus(v2474, tbl[0 + tbloffset], ctimes(reverse(v2474), tbl[1 + tbloffset]))); + real2 v2427 = ctimesminusplus(reverse(v2413), tbl[428 + tbloffset], ctimes(v2413, tbl[429 + tbloffset])); + real2 v2447 = ctimesminusplus(reverse(v2433), tbl[432 + tbloffset], ctimes(v2433, tbl[433 + tbloffset])); + store(out, 53 << outShift, plus(v2427, v2447)); + real2 v2480 = minus(v2427, v2447); + store(out, 117 << outShift, ctimesminusplus(v2480, tbl[0 + tbloffset], ctimes(reverse(v2480), tbl[1 + tbloffset]))); + real2 v2057 = ctimesminusplus(reverse(v2043), tbl[360 + tbloffset], ctimes(v2043, tbl[361 + tbloffset])); + real2 v2097 = ctimesminusplus(reverse(v2083), tbl[368 + tbloffset], ctimes(v2083, tbl[369 + tbloffset])); + real2 v2157 = ctimesminusplus(reverse(v2143), tbl[380 + tbloffset], ctimes(v2143, tbl[381 + tbloffset])); + real2 v2197 = ctimesminusplus(reverse(v2183), tbl[388 + tbloffset], ctimes(v2183, tbl[389 + tbloffset])); + real2 v2117 = ctimesminusplus(reverse(v2103), tbl[372 + tbloffset], ctimes(v2103, tbl[373 + tbloffset])); + real2 v2507 = reverse(minus(v2117, v2197)); + real2 v2513 = plus(v2117, v2197); + real2 v2137 = ctimesminusplus(reverse(v2123), tbl[376 + tbloffset], ctimes(v2123, tbl[377 + tbloffset])); + real2 v2488 = minus(v2137, v2057); + real2 v2492 = plus(v2057, v2137); + real2 v2177 = ctimesminusplus(reverse(v2163), tbl[384 + tbloffset], ctimes(v2163, tbl[385 + tbloffset])); + real2 v2493 = plus(v2097, v2177); + real2 v2487 = reverse(minus(v2097, v2177)); + real2 v2532 = plus(v2492, v2493); + real2 v2528 = minus(v2493, v2492); + real2 v2077 = ctimesminusplus(reverse(v2063), tbl[364 + tbloffset], ctimes(v2063, tbl[365 + tbloffset])); + real2 v2512 = plus(v2077, v2157); + real2 v2508 = minus(v2157, v2077); + real2 v2527 = reverse(minus(v2512, v2513)); + real2 v2533 = plus(v2512, v2513); + real2 v2529 = minusplus(v2527, v2528); + real2 v2531 = minusplus(uminus(v2527), v2528); + store(out, 109 << outShift, ctimesminusplus(reverse(v2531), tbl[448 + tbloffset], ctimes(v2531, tbl[449 + tbloffset]))); + store(out, 45 << outShift, ctimesminusplus(reverse(v2529), tbl[446 + tbloffset], ctimes(v2529, tbl[447 + tbloffset]))); + store(out, 13 << outShift, plus(v2532, v2533)); + real2 v2546 = minus(v2532, v2533); + store(out, 77 << outShift, ctimesminusplus(v2546, tbl[0 + tbloffset], ctimes(reverse(v2546), tbl[1 + tbloffset]))); + real2 v2509 = minusplus(v2507, v2508); + real2 v2511 = minusplus(uminus(v2507), v2508); + real2 v2491 = minusplus(uminus(v2487), v2488); + real2 v2489 = minusplus(v2487, v2488); + real2 v2499 = ctimesminusplus(reverse(v2489), tbl[438 + tbloffset], ctimes(v2489, tbl[439 + tbloffset])); + real2 v2519 = ctimesminusplus(reverse(v2509), tbl[442 + tbloffset], ctimes(v2509, tbl[443 + tbloffset])); + store(out, 29 << outShift, plus(v2499, v2519)); + real2 v2552 = minus(v2499, v2519); + store(out, 93 << outShift, ctimesminusplus(v2552, tbl[0 + tbloffset], ctimes(reverse(v2552), tbl[1 + tbloffset]))); + real2 v2505 = ctimesminusplus(reverse(v2491), tbl[440 + tbloffset], ctimes(v2491, tbl[441 + tbloffset])); + real2 v2525 = ctimesminusplus(reverse(v2511), tbl[444 + tbloffset], ctimes(v2511, tbl[445 + tbloffset])); + store(out, 61 << outShift, plus(v2505, v2525)); + real2 v2558 = minus(v2505, v2525); + store(out, 125 << outShift, ctimesminusplus(v2558, tbl[0 + tbloffset], ctimes(reverse(v2558), tbl[1 + tbloffset]))); +// Pres : 76263 + } +} + +ALIGNED(8192) void but128b_%CONFIG%_%ISA%(real *RESTRICT out0, uint32_t *q, const int outShift, const real *RESTRICT in0, const int inShift, const real *RESTRICT tbl, const int K) { + const int k = 1 << (inShift - LOG2VECWIDTH); + int i=0; +#pragma omp parallel for + for(i=0;i < k;i++) { + int i0 = i << LOG2VECWIDTH; + real *out = out0 + q[i]; + const real *in = in0 + i0*2; + const int tbloffset = K * (i0 >> outShift); + +// Pres : 148586 + real2 v56 = load(in, 54 << inShift); + real2 v120 = load(in, 118 << inShift); + real2 v571 = reverse(minus(v120, v56)); + real2 v577 = plus(v56, v120); + real2 v24 = load(in, 22 << inShift); + real2 v88 = load(in, 86 << inShift); + real2 v576 = plus(v24, v88); + real2 v572 = minus(v88, v24); + real2 v573 = minusplus(v571, v572); + real2 v575 = minusplus(uminus(v571), v572); + real2 v589 = ctimesminusplus(reverse(v575), tbl[92 + tbloffset], ctimes(v575, tbl[93 + tbloffset])); + real2 v583 = ctimesminusplus(reverse(v573), tbl[90 + tbloffset], ctimes(v573, tbl[91 + tbloffset])); + real2 v897 = plus(v576, v577); + real2 v891 = reverse(minus(v577, v576)); + real2 v8 = load(in, 6 << inShift); + real2 v72 = load(in, 70 << inShift); + real2 v252 = minus(v72, v8); + real2 v256 = plus(v8, v72); + real2 v104 = load(in, 102 << inShift); + real2 v40 = load(in, 38 << inShift); + real2 v251 = reverse(minus(v104, v40)); + real2 v257 = plus(v40, v104); + real2 v255 = minusplus(uminus(v251), v252); + real2 v253 = minusplus(v251, v252); + real2 v263 = ctimesminusplus(reverse(v253), tbl[26 + tbloffset], ctimes(v253, tbl[27 + tbloffset])); + real2 v896 = plus(v256, v257); + real2 v892 = minus(v257, v256); + real2 v895 = minusplus(uminus(v891), v892); + real2 v893 = minusplus(v891, v892); + real2 v909 = ctimesminusplus(reverse(v895), tbl[156 + tbloffset], ctimes(v895, tbl[157 + tbloffset])); + real2 v903 = ctimesminusplus(reverse(v893), tbl[154 + tbloffset], ctimes(v893, tbl[155 + tbloffset])); + real2 v269 = ctimesminusplus(reverse(v255), tbl[28 + tbloffset], ctimes(v255, tbl[29 + tbloffset])); + real2 v1216 = plus(v896, v897); + real2 v1212 = minus(v897, v896); + real2 v2160 = minus(v583, v263); + real2 v2164 = plus(v263, v583); + real2 v2686 = minus(v589, v269); + real2 v2690 = plus(v269, v589); + real2 v96 = load(in, 94 << inShift); + real2 v32 = load(in, 30 << inShift); + real2 v736 = plus(v32, v96); + real2 v732 = minus(v96, v32); + real2 v64 = load(in, 62 << inShift); + real2 v128 = load(in, 126 << inShift); + real2 v737 = plus(v64, v128); + real2 v731 = reverse(minus(v128, v64)); + real2 v1057 = plus(v736, v737); + real2 v1051 = reverse(minus(v737, v736)); + real2 v733 = minusplus(v731, v732); + real2 v735 = minusplus(uminus(v731), v732); + real2 v749 = ctimesminusplus(reverse(v735), tbl[124 + tbloffset], ctimes(v735, tbl[125 + tbloffset])); + real2 v743 = ctimesminusplus(reverse(v733), tbl[122 + tbloffset], ctimes(v733, tbl[123 + tbloffset])); + real2 v16 = load(in, 14 << inShift); + real2 v80 = load(in, 78 << inShift); + real2 v412 = minus(v80, v16); + real2 v416 = plus(v16, v80); + real2 v112 = load(in, 110 << inShift); + real2 v48 = load(in, 46 << inShift); + real2 v417 = plus(v48, v112); + real2 v411 = reverse(minus(v112, v48)); + real2 v1056 = plus(v416, v417); + real2 v1052 = minus(v417, v416); + real2 v1055 = minusplus(uminus(v1051), v1052); + real2 v1053 = minusplus(v1051, v1052); + real2 v1063 = ctimesminusplus(reverse(v1053), tbl[186 + tbloffset], ctimes(v1053, tbl[187 + tbloffset])); + real2 v1665 = plus(v903, v1063); + real2 v1659 = reverse(minus(v1063, v903)); + real2 v1069 = ctimesminusplus(reverse(v1055), tbl[188 + tbloffset], ctimes(v1055, tbl[189 + tbloffset])); + real2 v1869 = reverse(minus(v1069, v909)); + real2 v1875 = plus(v909, v1069); + real2 v413 = minusplus(v411, v412); + real2 v415 = minusplus(uminus(v411), v412); + real2 v429 = ctimesminusplus(reverse(v415), tbl[60 + tbloffset], ctimes(v415, tbl[61 + tbloffset])); + real2 v1217 = plus(v1056, v1057); + real2 v1211 = reverse(minus(v1057, v1056)); + real2 v1297 = plus(v1216, v1217); + real2 v1291 = reverse(minus(v1217, v1216)); + real2 v2691 = plus(v429, v749); + real2 v2685 = reverse(minus(v749, v429)); + real2 v2765 = reverse(minus(v2691, v2690)); + real2 v2771 = plus(v2690, v2691); + real2 v2689 = minusplus(uminus(v2685), v2686); + real2 v2687 = minusplus(v2685, v2686); + real2 v2703 = ctimesminusplus(reverse(v2689), tbl[476 + tbloffset], ctimes(v2689, tbl[477 + tbloffset])); + real2 v2697 = ctimesminusplus(reverse(v2687), tbl[474 + tbloffset], ctimes(v2687, tbl[475 + tbloffset])); + real2 v1215 = minusplus(uminus(v1211), v1212); + real2 v1213 = minusplus(v1211, v1212); + real2 v1223 = ctimesminusplus(reverse(v1213), tbl[218 + tbloffset], ctimes(v1213, tbl[219 + tbloffset])); + real2 v1229 = ctimesminusplus(reverse(v1215), tbl[220 + tbloffset], ctimes(v1215, tbl[221 + tbloffset])); + real2 v423 = ctimesminusplus(reverse(v413), tbl[58 + tbloffset], ctimes(v413, tbl[59 + tbloffset])); + real2 v2165 = plus(v423, v743); + real2 v2159 = reverse(minus(v743, v423)); + real2 v2245 = plus(v2164, v2165); + real2 v2239 = reverse(minus(v2165, v2164)); + real2 v44 = load(in, 42 << inShift); + real2 v108 = load(in, 106 << inShift); + real2 v331 = reverse(minus(v108, v44)); + real2 v337 = plus(v44, v108); + real2 v76 = load(in, 74 << inShift); + real2 v12 = load(in, 10 << inShift); + real2 v336 = plus(v12, v76); + real2 v332 = minus(v76, v12); + real2 v976 = plus(v336, v337); + real2 v972 = minus(v337, v336); + real2 v335 = minusplus(uminus(v331), v332); + real2 v333 = minusplus(v331, v332); + real2 v343 = ctimesminusplus(reverse(v333), tbl[42 + tbloffset], ctimes(v333, tbl[43 + tbloffset])); + real2 v349 = ctimesminusplus(reverse(v335), tbl[44 + tbloffset], ctimes(v335, tbl[45 + tbloffset])); + real2 v124 = load(in, 122 << inShift); + real2 v60 = load(in, 58 << inShift); + real2 v651 = reverse(minus(v124, v60)); + real2 v657 = plus(v60, v124); + real2 v28 = load(in, 26 << inShift); + real2 v92 = load(in, 90 << inShift); + real2 v652 = minus(v92, v28); + real2 v656 = plus(v28, v92); + real2 v977 = plus(v656, v657); + real2 v971 = reverse(minus(v657, v656)); + real2 v973 = minusplus(v971, v972); + real2 v975 = minusplus(uminus(v971), v972); + real2 v983 = ctimesminusplus(reverse(v973), tbl[170 + tbloffset], ctimes(v973, tbl[171 + tbloffset])); + real2 v1131 = reverse(minus(v977, v976)); + real2 v1137 = plus(v976, v977); + real2 v655 = minusplus(uminus(v651), v652); + real2 v653 = minusplus(v651, v652); + real2 v669 = ctimesminusplus(reverse(v655), tbl[108 + tbloffset], ctimes(v655, tbl[109 + tbloffset])); + real2 v663 = ctimesminusplus(reverse(v653), tbl[106 + tbloffset], ctimes(v653, tbl[107 + tbloffset])); + real2 v2079 = reverse(minus(v663, v343)); + real2 v2085 = plus(v343, v663); + real2 v2605 = reverse(minus(v669, v349)); + real2 v2611 = plus(v349, v669); + real2 v989 = ctimesminusplus(reverse(v975), tbl[172 + tbloffset], ctimes(v975, tbl[173 + tbloffset])); + real2 v20 = load(in, 18 << inShift); + real2 v84 = load(in, 82 << inShift); + real2 v496 = plus(v20, v84); + real2 v492 = minus(v84, v20); + real2 v52 = load(in, 50 << inShift); + real2 v116 = load(in, 114 << inShift); + real2 v491 = reverse(minus(v116, v52)); + real2 v497 = plus(v52, v116); + real2 v817 = plus(v496, v497); + real2 v811 = reverse(minus(v497, v496)); + real2 v493 = minusplus(v491, v492); + real2 v495 = minusplus(uminus(v491), v492); + real2 v509 = ctimesminusplus(reverse(v495), tbl[76 + tbloffset], ctimes(v495, tbl[77 + tbloffset])); + real2 v503 = ctimesminusplus(reverse(v493), tbl[74 + tbloffset], ctimes(v493, tbl[75 + tbloffset])); + real2 v36 = load(in, 34 << inShift); + real2 v100 = load(in, 98 << inShift); + real2 v171 = reverse(minus(v100, v36)); + real2 v177 = plus(v36, v100); + real2 v68 = load(in, 66 << inShift); + real2 v4 = load(in, 2 << inShift); + real2 v176 = plus(v4, v68); + real2 v172 = minus(v68, v4); + real2 v816 = plus(v176, v177); + real2 v812 = minus(v177, v176); + real2 v1136 = plus(v816, v817); + real2 v1132 = minus(v817, v816); + real2 v1133 = minusplus(v1131, v1132); + real2 v1135 = minusplus(uminus(v1131), v1132); + real2 v1149 = ctimesminusplus(reverse(v1135), tbl[204 + tbloffset], ctimes(v1135, tbl[205 + tbloffset])); + real2 v1296 = plus(v1136, v1137); + real2 v1292 = minus(v1137, v1136); + real2 v1295 = minusplus(uminus(v1291), v1292); + real2 v1293 = minusplus(v1291, v1292); + real2 v1303 = ctimesminusplus(reverse(v1293), tbl[234 + tbloffset], ctimes(v1293, tbl[235 + tbloffset])); + real2 v1331 = reverse(minus(v1297, v1296)); + real2 v1337 = plus(v1296, v1297); + real2 v173 = minusplus(v171, v172); + real2 v175 = minusplus(uminus(v171), v172); + real2 v189 = ctimesminusplus(reverse(v175), tbl[12 + tbloffset], ctimes(v175, tbl[13 + tbloffset])); + real2 v1309 = ctimesminusplus(reverse(v1295), tbl[236 + tbloffset], ctimes(v1295, tbl[237 + tbloffset])); + real2 v815 = minusplus(uminus(v811), v812); + real2 v813 = minusplus(v811, v812); + real2 v1143 = ctimesminusplus(reverse(v1133), tbl[202 + tbloffset], ctimes(v1133, tbl[203 + tbloffset])); + real2 v1541 = reverse(minus(v1229, v1149)); + real2 v1547 = plus(v1149, v1229); + real2 v2610 = plus(v189, v509); + real2 v2606 = minus(v509, v189); + real2 v2770 = plus(v2610, v2611); + real2 v2766 = minus(v2611, v2610); + real2 v823 = ctimesminusplus(reverse(v813), tbl[138 + tbloffset], ctimes(v813, tbl[139 + tbloffset])); + real2 v829 = ctimesminusplus(reverse(v815), tbl[140 + tbloffset], ctimes(v815, tbl[141 + tbloffset])); + real2 v2811 = plus(v2770, v2771); + real2 v2805 = reverse(minus(v2771, v2770)); + real2 v2767 = minusplus(v2765, v2766); + real2 v2769 = minusplus(uminus(v2765), v2766); + real2 v2607 = minusplus(v2605, v2606); + real2 v2609 = minusplus(uminus(v2605), v2606); + real2 v2617 = ctimesminusplus(reverse(v2607), tbl[458 + tbloffset], ctimes(v2607, tbl[459 + tbloffset])); + real2 v2623 = ctimesminusplus(reverse(v2609), tbl[460 + tbloffset], ctimes(v2609, tbl[461 + tbloffset])); + real2 v3013 = reverse(minus(v2703, v2623)); + real2 v3019 = plus(v2623, v2703); + real2 v2783 = ctimesminusplus(reverse(v2769), tbl[492 + tbloffset], ctimes(v2769, tbl[493 + tbloffset])); + real2 v2941 = plus(v2617, v2697); + real2 v2935 = reverse(minus(v2697, v2617)); + real2 v2777 = ctimesminusplus(reverse(v2767), tbl[490 + tbloffset], ctimes(v2767, tbl[491 + tbloffset])); + real2 v1660 = minus(v983, v823); + real2 v1664 = plus(v823, v983); + real2 v1874 = plus(v829, v989); + real2 v1870 = minus(v989, v829); + real2 v1909 = reverse(minus(v1875, v1874)); + real2 v1915 = plus(v1874, v1875); + real2 v1663 = minusplus(uminus(v1659), v1660); + real2 v1661 = minusplus(v1659, v1660); + real2 v1677 = ctimesminusplus(reverse(v1663), tbl[296 + tbloffset], ctimes(v1663, tbl[297 + tbloffset])); + real2 v1873 = minusplus(uminus(v1869), v1870); + real2 v1871 = minusplus(v1869, v1870); + real2 v1887 = ctimesminusplus(reverse(v1873), tbl[332 + tbloffset], ctimes(v1873, tbl[333 + tbloffset])); + real2 v1705 = plus(v1664, v1665); + real2 v1699 = reverse(minus(v1665, v1664)); + real2 v1671 = ctimesminusplus(reverse(v1661), tbl[294 + tbloffset], ctimes(v1661, tbl[295 + tbloffset])); + real2 v1881 = ctimesminusplus(reverse(v1871), tbl[330 + tbloffset], ctimes(v1871, tbl[331 + tbloffset])); + real2 v1469 = plus(v1143, v1223); + real2 v1463 = reverse(minus(v1223, v1143)); + real2 v54 = load(in, 52 << inShift); + real2 v118 = load(in, 116 << inShift); + real2 v537 = plus(v54, v118); + real2 v531 = reverse(minus(v118, v54)); + real2 v86 = load(in, 84 << inShift); + real2 v22 = load(in, 20 << inShift); + real2 v536 = plus(v22, v86); + real2 v532 = minus(v86, v22); + real2 v851 = reverse(minus(v537, v536)); + real2 v857 = plus(v536, v537); + real2 v533 = minusplus(v531, v532); + real2 v535 = minusplus(uminus(v531), v532); + real2 v549 = ctimesminusplus(reverse(v535), tbl[84 + tbloffset], ctimes(v535, tbl[85 + tbloffset])); + real2 v102 = load(in, 100 << inShift); + real2 v38 = load(in, 36 << inShift); + real2 v217 = plus(v38, v102); + real2 v211 = reverse(minus(v102, v38)); + real2 v70 = load(in, 68 << inShift); + real2 v6 = load(in, 4 << inShift); + real2 v216 = plus(v6, v70); + real2 v212 = minus(v70, v6); + real2 v213 = minusplus(v211, v212); + real2 v215 = minusplus(uminus(v211), v212); + real2 v229 = ctimesminusplus(reverse(v215), tbl[20 + tbloffset], ctimes(v215, tbl[21 + tbloffset])); + real2 v2646 = minus(v549, v229); + real2 v2650 = plus(v229, v549); + real2 v856 = plus(v216, v217); + real2 v852 = minus(v217, v216); + real2 v853 = minusplus(v851, v852); + real2 v855 = minusplus(uminus(v851), v852); + real2 v863 = ctimesminusplus(reverse(v853), tbl[146 + tbloffset], ctimes(v853, tbl[147 + tbloffset])); + real2 v869 = ctimesminusplus(reverse(v855), tbl[148 + tbloffset], ctimes(v855, tbl[149 + tbloffset])); + real2 v1176 = plus(v856, v857); + real2 v1172 = minus(v857, v856); + real2 v110 = load(in, 108 << inShift); + real2 v46 = load(in, 44 << inShift); + real2 v377 = plus(v46, v110); + real2 v371 = reverse(minus(v110, v46)); + real2 v78 = load(in, 76 << inShift); + real2 v14 = load(in, 12 << inShift); + real2 v372 = minus(v78, v14); + real2 v376 = plus(v14, v78); + real2 v1012 = minus(v377, v376); + real2 v1016 = plus(v376, v377); + real2 v373 = minusplus(v371, v372); + real2 v375 = minusplus(uminus(v371), v372); + real2 v389 = ctimesminusplus(reverse(v375), tbl[52 + tbloffset], ctimes(v375, tbl[53 + tbloffset])); + real2 v30 = load(in, 28 << inShift); + real2 v94 = load(in, 92 << inShift); + real2 v696 = plus(v30, v94); + real2 v692 = minus(v94, v30); + real2 v62 = load(in, 60 << inShift); + real2 v126 = load(in, 124 << inShift); + real2 v697 = plus(v62, v126); + real2 v691 = reverse(minus(v126, v62)); + real2 v1017 = plus(v696, v697); + real2 v1011 = reverse(minus(v697, v696)); + real2 v1171 = reverse(minus(v1017, v1016)); + real2 v1177 = plus(v1016, v1017); + real2 v1013 = minusplus(v1011, v1012); + real2 v1015 = minusplus(uminus(v1011), v1012); + real2 v1175 = minusplus(uminus(v1171), v1172); + real2 v1173 = minusplus(v1171, v1172); + real2 v1183 = ctimesminusplus(reverse(v1173), tbl[210 + tbloffset], ctimes(v1173, tbl[211 + tbloffset])); + real2 v1189 = ctimesminusplus(reverse(v1175), tbl[212 + tbloffset], ctimes(v1175, tbl[213 + tbloffset])); + real2 v1029 = ctimesminusplus(reverse(v1015), tbl[180 + tbloffset], ctimes(v1015, tbl[181 + tbloffset])); + real2 v1023 = ctimesminusplus(reverse(v1013), tbl[178 + tbloffset], ctimes(v1013, tbl[179 + tbloffset])); + real2 v1625 = plus(v863, v1023); + real2 v1619 = reverse(minus(v1023, v863)); + real2 v1835 = plus(v869, v1029); + real2 v1829 = reverse(minus(v1029, v869)); + real2 v693 = minusplus(v691, v692); + real2 v695 = minusplus(uminus(v691), v692); + real2 v709 = ctimesminusplus(reverse(v695), tbl[116 + tbloffset], ctimes(v695, tbl[117 + tbloffset])); + real2 v2645 = reverse(minus(v709, v389)); + real2 v2651 = plus(v389, v709); + real2 v1257 = plus(v1176, v1177); + real2 v1251 = reverse(minus(v1177, v1176)); + real2 v2731 = plus(v2650, v2651); + real2 v2725 = reverse(minus(v2651, v2650)); + real2 v114 = load(in, 112 << inShift); + real2 v50 = load(in, 48 << inShift); + real2 v457 = plus(v50, v114); + real2 v451 = reverse(minus(v114, v50)); + real2 v18 = load(in, 16 << inShift); + real2 v82 = load(in, 80 << inShift); + real2 v456 = plus(v18, v82); + real2 v452 = minus(v82, v18); + real2 v771 = reverse(minus(v457, v456)); + real2 v777 = plus(v456, v457); + real2 v453 = minusplus(v451, v452); + real2 v455 = minusplus(uminus(v451), v452); + real2 v469 = ctimesminusplus(reverse(v455), tbl[68 + tbloffset], ctimes(v455, tbl[69 + tbloffset])); + real2 v66 = load(in, 64 << inShift); + real2 v2 = load(in, 0 << inShift); + real2 v132 = minus(v66, v2); + real2 v136 = plus(v2, v66); + real2 v98 = load(in, 96 << inShift); + real2 v34 = load(in, 32 << inShift); + real2 v131 = reverse(minus(v98, v34)); + real2 v137 = plus(v34, v98); + real2 v133 = minusplus(v131, v132); + real2 v135 = minusplus(uminus(v131), v132); + real2 v149 = ctimesminusplus(reverse(v135), tbl[4 + tbloffset], ctimes(v135, tbl[5 + tbloffset])); + real2 v2566 = minus(v469, v149); + real2 v2570 = plus(v149, v469); + real2 v772 = minus(v137, v136); + real2 v776 = plus(v136, v137); + real2 v1092 = minus(v777, v776); + real2 v1096 = plus(v776, v777); + real2 v773 = minusplus(v771, v772); + real2 v775 = minusplus(uminus(v771), v772); + real2 v783 = ctimesminusplus(reverse(v773), tbl[130 + tbloffset], ctimes(v773, tbl[131 + tbloffset])); + real2 v789 = ctimesminusplus(reverse(v775), tbl[132 + tbloffset], ctimes(v775, tbl[133 + tbloffset])); + real2 v74 = load(in, 72 << inShift); + real2 v10 = load(in, 8 << inShift); + real2 v296 = plus(v10, v74); + real2 v292 = minus(v74, v10); + real2 v42 = load(in, 40 << inShift); + real2 v106 = load(in, 104 << inShift); + real2 v291 = reverse(minus(v106, v42)); + real2 v297 = plus(v42, v106); + real2 v293 = minusplus(v291, v292); + real2 v295 = minusplus(uminus(v291), v292); + real2 v309 = ctimesminusplus(reverse(v295), tbl[36 + tbloffset], ctimes(v295, tbl[37 + tbloffset])); + real2 v932 = minus(v297, v296); + real2 v936 = plus(v296, v297); + real2 v122 = load(in, 120 << inShift); + real2 v58 = load(in, 56 << inShift); + real2 v617 = plus(v58, v122); + real2 v611 = reverse(minus(v122, v58)); + real2 v26 = load(in, 24 << inShift); + real2 v90 = load(in, 88 << inShift); + real2 v612 = minus(v90, v26); + real2 v616 = plus(v26, v90); + real2 v937 = plus(v616, v617); + real2 v931 = reverse(minus(v617, v616)); + real2 v1091 = reverse(minus(v937, v936)); + real2 v1097 = plus(v936, v937); + real2 v933 = minusplus(v931, v932); + real2 v935 = minusplus(uminus(v931), v932); + real2 v1093 = minusplus(v1091, v1092); + real2 v1095 = minusplus(uminus(v1091), v1092); + real2 v1103 = ctimesminusplus(reverse(v1093), tbl[194 + tbloffset], ctimes(v1093, tbl[195 + tbloffset])); + real2 v1468 = plus(v1103, v1183); + real2 v1464 = minus(v1183, v1103); + real2 v1508 = plus(v1468, v1469); + real2 v1504 = minus(v1469, v1468); + real2 v1252 = minus(v1097, v1096); + real2 v1256 = plus(v1096, v1097); + real2 v1336 = plus(v1256, v1257); + real2 v1332 = minus(v1257, v1256); + real2 v1335 = minusplus(uminus(v1331), v1332); + real2 v1333 = minusplus(v1331, v1332); + real2 v1343 = ctimesminusplus(reverse(v1333), tbl[242 + tbloffset], ctimes(v1333, tbl[243 + tbloffset])); + real2 v1349 = ctimesminusplus(reverse(v1335), tbl[244 + tbloffset], ctimes(v1335, tbl[245 + tbloffset])); + real2 v1376 = plus(v1336, v1337); + real2 v1372 = minus(v1337, v1336); + real2 v1465 = minusplus(v1463, v1464); + real2 v1467 = minusplus(uminus(v1463), v1464); + real2 v1255 = minusplus(uminus(v1251), v1252); + real2 v1253 = minusplus(v1251, v1252); + real2 v1481 = ctimesminusplus(reverse(v1467), tbl[264 + tbloffset], ctimes(v1467, tbl[265 + tbloffset])); + real2 v1475 = ctimesminusplus(reverse(v1465), tbl[262 + tbloffset], ctimes(v1465, tbl[263 + tbloffset])); + real2 v1109 = ctimesminusplus(reverse(v1095), tbl[196 + tbloffset], ctimes(v1095, tbl[197 + tbloffset])); + real2 v1542 = minus(v1189, v1109); + real2 v1546 = plus(v1109, v1189); + real2 v1545 = minusplus(uminus(v1541), v1542); + real2 v1543 = minusplus(v1541, v1542); + real2 v1553 = ctimesminusplus(reverse(v1543), tbl[274 + tbloffset], ctimes(v1543, tbl[275 + tbloffset])); + real2 v1559 = ctimesminusplus(reverse(v1545), tbl[276 + tbloffset], ctimes(v1545, tbl[277 + tbloffset])); + real2 v1582 = minus(v1547, v1546); + real2 v1586 = plus(v1546, v1547); + real2 v1269 = ctimesminusplus(reverse(v1255), tbl[228 + tbloffset], ctimes(v1255, tbl[229 + tbloffset])); + real2 v1438 = minus(v1309, v1269); + real2 v1442 = plus(v1269, v1309); + real2 v1263 = ctimesminusplus(reverse(v1253), tbl[226 + tbloffset], ctimes(v1253, tbl[227 + tbloffset])); + real2 v943 = ctimesminusplus(reverse(v933), tbl[162 + tbloffset], ctimes(v933, tbl[163 + tbloffset])); + real2 v1624 = plus(v783, v943); + real2 v1620 = minus(v943, v783); + real2 v1623 = minusplus(uminus(v1619), v1620); + real2 v1621 = minusplus(v1619, v1620); + real2 v1700 = minus(v1625, v1624); + real2 v1704 = plus(v1624, v1625); + real2 v1631 = ctimesminusplus(reverse(v1621), tbl[286 + tbloffset], ctimes(v1621, tbl[287 + tbloffset])); + real2 v949 = ctimesminusplus(reverse(v935), tbl[164 + tbloffset], ctimes(v935, tbl[165 + tbloffset])); + real2 v1830 = minus(v949, v789); + real2 v1834 = plus(v789, v949); + real2 v1782 = plus(v1631, v1671); + real2 v1778 = minus(v1671, v1631); + real2 v1910 = minus(v1835, v1834); + real2 v1914 = plus(v1834, v1835); + real2 v1950 = minus(v1915, v1914); + real2 v1954 = plus(v1914, v1915); + real2 v1913 = minusplus(uminus(v1909), v1910); + real2 v1911 = minusplus(v1909, v1910); + real2 v613 = minusplus(v611, v612); + real2 v615 = minusplus(uminus(v611), v612); + real2 v629 = ctimesminusplus(reverse(v615), tbl[100 + tbloffset], ctimes(v615, tbl[101 + tbloffset])); + real2 v1744 = plus(v1704, v1705); + real2 v1740 = minus(v1705, v1704); + real2 v1637 = ctimesminusplus(reverse(v1623), tbl[288 + tbloffset], ctimes(v1623, tbl[289 + tbloffset])); + real2 v1927 = ctimesminusplus(reverse(v1913), tbl[340 + tbloffset], ctimes(v1913, tbl[341 + tbloffset])); + real2 v2571 = plus(v309, v629); + real2 v2565 = reverse(minus(v629, v309)); + real2 v1833 = minusplus(uminus(v1829), v1830); + real2 v1831 = minusplus(v1829, v1830); + real2 v1921 = ctimesminusplus(reverse(v1911), tbl[338 + tbloffset], ctimes(v1911, tbl[339 + tbloffset])); + real2 v1804 = minus(v1677, v1637); + real2 v1808 = plus(v1637, v1677); + real2 v1847 = ctimesminusplus(reverse(v1833), tbl[324 + tbloffset], ctimes(v1833, tbl[325 + tbloffset])); + real2 v2014 = minus(v1887, v1847); + real2 v2018 = plus(v1847, v1887); + real2 v1841 = ctimesminusplus(reverse(v1831), tbl[322 + tbloffset], ctimes(v1831, tbl[323 + tbloffset])); + real2 v1988 = minus(v1881, v1841); + real2 v1992 = plus(v1841, v1881); + real2 v1703 = minusplus(uminus(v1699), v1700); + real2 v1701 = minusplus(v1699, v1700); + real2 v1717 = ctimesminusplus(reverse(v1703), tbl[304 + tbloffset], ctimes(v1703, tbl[305 + tbloffset])); + real2 v1711 = ctimesminusplus(reverse(v1701), tbl[302 + tbloffset], ctimes(v1701, tbl[303 + tbloffset])); + real2 v2730 = plus(v2570, v2571); + real2 v2726 = minus(v2571, v2570); + real2 v1412 = minus(v1303, v1263); + real2 v1416 = plus(v1263, v1303); + real2 v63 = load(in, 61 << inShift); + real2 v127 = load(in, 125 << inShift); + real2 v717 = plus(v63, v127); + real2 v711 = reverse(minus(v127, v63)); + real2 v95 = load(in, 93 << inShift); + real2 v31 = load(in, 29 << inShift); + real2 v712 = minus(v95, v31); + real2 v716 = plus(v31, v95); + real2 v1037 = plus(v716, v717); + real2 v1031 = reverse(minus(v717, v716)); + real2 v79 = load(in, 77 << inShift); + real2 v15 = load(in, 13 << inShift); + real2 v396 = plus(v15, v79); + real2 v392 = minus(v79, v15); + real2 v111 = load(in, 109 << inShift); + real2 v47 = load(in, 45 << inShift); + real2 v397 = plus(v47, v111); + real2 v391 = reverse(minus(v111, v47)); + real2 v1032 = minus(v397, v396); + real2 v1036 = plus(v396, v397); + real2 v1033 = minusplus(v1031, v1032); + real2 v1035 = minusplus(uminus(v1031), v1032); + real2 v1049 = ctimesminusplus(reverse(v1035), tbl[184 + tbloffset], ctimes(v1035, tbl[185 + tbloffset])); + real2 v1043 = ctimesminusplus(reverse(v1033), tbl[182 + tbloffset], ctimes(v1033, tbl[183 + tbloffset])); + real2 v1197 = plus(v1036, v1037); + real2 v1191 = reverse(minus(v1037, v1036)); + real2 v23 = load(in, 21 << inShift); + real2 v87 = load(in, 85 << inShift); + real2 v556 = plus(v23, v87); + real2 v552 = minus(v87, v23); + real2 v119 = load(in, 117 << inShift); + real2 v55 = load(in, 53 << inShift); + real2 v557 = plus(v55, v119); + real2 v551 = reverse(minus(v119, v55)); + real2 v877 = plus(v556, v557); + real2 v871 = reverse(minus(v557, v556)); + real2 v7 = load(in, 5 << inShift); + real2 v71 = load(in, 69 << inShift); + real2 v232 = minus(v71, v7); + real2 v236 = plus(v7, v71); + real2 v103 = load(in, 101 << inShift); + real2 v39 = load(in, 37 << inShift); + real2 v237 = plus(v39, v103); + real2 v231 = reverse(minus(v103, v39)); + real2 v876 = plus(v236, v237); + real2 v872 = minus(v237, v236); + real2 v1192 = minus(v877, v876); + real2 v1196 = plus(v876, v877); + real2 v1271 = reverse(minus(v1197, v1196)); + real2 v1277 = plus(v1196, v1197); + real2 v875 = minusplus(uminus(v871), v872); + real2 v873 = minusplus(v871, v872); + real2 v883 = ctimesminusplus(reverse(v873), tbl[150 + tbloffset], ctimes(v873, tbl[151 + tbloffset])); + real2 v1639 = reverse(minus(v1043, v883)); + real2 v1645 = plus(v883, v1043); + real2 v1195 = minusplus(uminus(v1191), v1192); + real2 v1193 = minusplus(v1191, v1192); + real2 v1209 = ctimesminusplus(reverse(v1195), tbl[216 + tbloffset], ctimes(v1195, tbl[217 + tbloffset])); + real2 v1203 = ctimesminusplus(reverse(v1193), tbl[214 + tbloffset], ctimes(v1193, tbl[215 + tbloffset])); + real2 v83 = load(in, 81 << inShift); + real2 v19 = load(in, 17 << inShift); + real2 v476 = plus(v19, v83); + real2 v472 = minus(v83, v19); + real2 v51 = load(in, 49 << inShift); + real2 v115 = load(in, 113 << inShift); + real2 v477 = plus(v51, v115); + real2 v471 = reverse(minus(v115, v51)); + real2 v797 = plus(v476, v477); + real2 v791 = reverse(minus(v477, v476)); + real2 v3 = load(in, 1 << inShift); + real2 v67 = load(in, 65 << inShift); + real2 v156 = plus(v3, v67); + real2 v152 = minus(v67, v3); + real2 v35 = load(in, 33 << inShift); + real2 v99 = load(in, 97 << inShift); + real2 v157 = plus(v35, v99); + real2 v151 = reverse(minus(v99, v35)); + real2 v792 = minus(v157, v156); + real2 v796 = plus(v156, v157); + real2 v793 = minusplus(v791, v792); + real2 v795 = minusplus(uminus(v791), v792); + real2 v803 = ctimesminusplus(reverse(v793), tbl[134 + tbloffset], ctimes(v793, tbl[135 + tbloffset])); + real2 v1112 = minus(v797, v796); + real2 v1116 = plus(v796, v797); + real2 v107 = load(in, 105 << inShift); + real2 v43 = load(in, 41 << inShift); + real2 v317 = plus(v43, v107); + real2 v311 = reverse(minus(v107, v43)); + real2 v75 = load(in, 73 << inShift); + real2 v11 = load(in, 9 << inShift); + real2 v316 = plus(v11, v75); + real2 v312 = minus(v75, v11); + real2 v956 = plus(v316, v317); + real2 v952 = minus(v317, v316); + real2 v59 = load(in, 57 << inShift); + real2 v123 = load(in, 121 << inShift); + real2 v631 = reverse(minus(v123, v59)); + real2 v637 = plus(v59, v123); + real2 v27 = load(in, 25 << inShift); + real2 v91 = load(in, 89 << inShift); + real2 v636 = plus(v27, v91); + real2 v632 = minus(v91, v27); + real2 v957 = plus(v636, v637); + real2 v951 = reverse(minus(v637, v636)); + real2 v1111 = reverse(minus(v957, v956)); + real2 v1117 = plus(v956, v957); + real2 v1276 = plus(v1116, v1117); + real2 v1272 = minus(v1117, v1116); + real2 v1275 = minusplus(uminus(v1271), v1272); + real2 v1273 = minusplus(v1271, v1272); + real2 v1283 = ctimesminusplus(reverse(v1273), tbl[230 + tbloffset], ctimes(v1273, tbl[231 + tbloffset])); + real2 v1352 = minus(v1277, v1276); + real2 v1356 = plus(v1276, v1277); + real2 v1289 = ctimesminusplus(reverse(v1275), tbl[232 + tbloffset], ctimes(v1275, tbl[233 + tbloffset])); + real2 v1115 = minusplus(uminus(v1111), v1112); + real2 v1113 = minusplus(v1111, v1112); + real2 v1123 = ctimesminusplus(reverse(v1113), tbl[198 + tbloffset], ctimes(v1113, tbl[199 + tbloffset])); + real2 v1129 = ctimesminusplus(reverse(v1115), tbl[200 + tbloffset], ctimes(v1115, tbl[201 + tbloffset])); + real2 v1488 = plus(v1123, v1203); + real2 v1484 = minus(v1203, v1123); + real2 v1566 = plus(v1129, v1209); + real2 v1562 = minus(v1209, v1129); + real2 v85 = load(in, 83 << inShift); + real2 v21 = load(in, 19 << inShift); + real2 v512 = minus(v85, v21); + real2 v516 = plus(v21, v85); + real2 v117 = load(in, 115 << inShift); + real2 v53 = load(in, 51 << inShift); + real2 v517 = plus(v53, v117); + real2 v511 = reverse(minus(v117, v53)); + real2 v831 = reverse(minus(v517, v516)); + real2 v837 = plus(v516, v517); + real2 v69 = load(in, 67 << inShift); + real2 v5 = load(in, 3 << inShift); + real2 v192 = minus(v69, v5); + real2 v196 = plus(v5, v69); + real2 v37 = load(in, 35 << inShift); + real2 v101 = load(in, 99 << inShift); + real2 v197 = plus(v37, v101); + real2 v191 = reverse(minus(v101, v37)); + real2 v832 = minus(v197, v196); + real2 v836 = plus(v196, v197); + real2 v1152 = minus(v837, v836); + real2 v1156 = plus(v836, v837); + real2 v61 = load(in, 59 << inShift); + real2 v125 = load(in, 123 << inShift); + real2 v677 = plus(v61, v125); + real2 v671 = reverse(minus(v125, v61)); + real2 v29 = load(in, 27 << inShift); + real2 v93 = load(in, 91 << inShift); + real2 v672 = minus(v93, v29); + real2 v676 = plus(v29, v93); + real2 v997 = plus(v676, v677); + real2 v991 = reverse(minus(v677, v676)); + real2 v109 = load(in, 107 << inShift); + real2 v45 = load(in, 43 << inShift); + real2 v357 = plus(v45, v109); + real2 v351 = reverse(minus(v109, v45)); + real2 v77 = load(in, 75 << inShift); + real2 v13 = load(in, 11 << inShift); + real2 v352 = minus(v77, v13); + real2 v356 = plus(v13, v77); + real2 v992 = minus(v357, v356); + real2 v996 = plus(v356, v357); + real2 v1157 = plus(v996, v997); + real2 v1151 = reverse(minus(v997, v996)); + real2 v1155 = minusplus(uminus(v1151), v1152); + real2 v1153 = minusplus(v1151, v1152); + real2 v1163 = ctimesminusplus(reverse(v1153), tbl[206 + tbloffset], ctimes(v1153, tbl[207 + tbloffset])); + real2 v1316 = plus(v1156, v1157); + real2 v1312 = minus(v1157, v1156); + real2 v41 = load(in, 39 << inShift); + real2 v105 = load(in, 103 << inShift); + real2 v277 = plus(v41, v105); + real2 v271 = reverse(minus(v105, v41)); + real2 v9 = load(in, 7 << inShift); + real2 v73 = load(in, 71 << inShift); + real2 v276 = plus(v9, v73); + real2 v272 = minus(v73, v9); + real2 v916 = plus(v276, v277); + real2 v912 = minus(v277, v276); + real2 v89 = load(in, 87 << inShift); + real2 v25 = load(in, 23 << inShift); + real2 v592 = minus(v89, v25); + real2 v596 = plus(v25, v89); + real2 v57 = load(in, 55 << inShift); + real2 v121 = load(in, 119 << inShift); + real2 v591 = reverse(minus(v121, v57)); + real2 v597 = plus(v57, v121); + real2 v911 = reverse(minus(v597, v596)); + real2 v917 = plus(v596, v597); + real2 v1236 = plus(v916, v917); + real2 v1232 = minus(v917, v916); + real2 v81 = load(in, 79 << inShift); + real2 v17 = load(in, 15 << inShift); + real2 v432 = minus(v81, v17); + real2 v436 = plus(v17, v81); + real2 v113 = load(in, 111 << inShift); + real2 v49 = load(in, 47 << inShift); + real2 v437 = plus(v49, v113); + real2 v431 = reverse(minus(v113, v49)); + real2 v1072 = minus(v437, v436); + real2 v1076 = plus(v436, v437); + real2 v65 = load(in, 63 << inShift); + real2 v129 = load(in, 127 << inShift); + real2 v757 = plus(v65, v129); + real2 v751 = reverse(minus(v129, v65)); + real2 v97 = load(in, 95 << inShift); + real2 v33 = load(in, 31 << inShift); + real2 v752 = minus(v97, v33); + real2 v756 = plus(v33, v97); + real2 v1077 = plus(v756, v757); + real2 v1071 = reverse(minus(v757, v756)); + real2 v1231 = reverse(minus(v1077, v1076)); + real2 v1237 = plus(v1076, v1077); + real2 v1317 = plus(v1236, v1237); + real2 v1311 = reverse(minus(v1237, v1236)); + real2 v1351 = reverse(minus(v1317, v1316)); + real2 v1357 = plus(v1316, v1317); + real2 v1371 = reverse(minus(v1357, v1356)); + real2 v1377 = plus(v1356, v1357); + store(out, 0 << outShift, plus(v1376, v1377)); + real2 v1390 = minus(v1376, v1377); + store(out, 64 << outShift, ctimesminusplus(v1390, tbl[0 + tbloffset], ctimes(reverse(v1390), tbl[1 + tbloffset]))); + real2 v1353 = minusplus(v1351, v1352); + real2 v1355 = minusplus(uminus(v1351), v1352); + real2 v1369 = ctimesminusplus(reverse(v1355), tbl[248 + tbloffset], ctimes(v1355, tbl[249 + tbloffset])); + store(out, 48 << outShift, plus(v1349, v1369)); + real2 v1404 = minus(v1349, v1369); + store(out, 112 << outShift, ctimesminusplus(v1404, tbl[0 + tbloffset], ctimes(reverse(v1404), tbl[1 + tbloffset]))); + real2 v1363 = ctimesminusplus(reverse(v1353), tbl[246 + tbloffset], ctimes(v1353, tbl[247 + tbloffset])); + store(out, 16 << outShift, plus(v1343, v1363)); + real2 v1398 = minus(v1343, v1363); + store(out, 80 << outShift, ctimesminusplus(v1398, tbl[0 + tbloffset], ctimes(reverse(v1398), tbl[1 + tbloffset]))); + real2 v1373 = minusplus(v1371, v1372); + real2 v1375 = minusplus(uminus(v1371), v1372); + store(out, 96 << outShift, ctimesminusplus(reverse(v1375), tbl[252 + tbloffset], ctimes(v1375, tbl[253 + tbloffset]))); + store(out, 32 << outShift, ctimesminusplus(reverse(v1373), tbl[250 + tbloffset], ctimes(v1373, tbl[251 + tbloffset]))); + real2 v1313 = minusplus(v1311, v1312); + real2 v1315 = minusplus(uminus(v1311), v1312); + real2 v1323 = ctimesminusplus(reverse(v1313), tbl[238 + tbloffset], ctimes(v1313, tbl[239 + tbloffset])); + real2 v1417 = plus(v1283, v1323); + real2 v1411 = reverse(minus(v1323, v1283)); + store(out, 8 << outShift, plus(v1416, v1417)); + real2 v1430 = minus(v1416, v1417); + store(out, 72 << outShift, ctimesminusplus(v1430, tbl[0 + tbloffset], ctimes(reverse(v1430), tbl[1 + tbloffset]))); + real2 v1413 = minusplus(v1411, v1412); + real2 v1415 = minusplus(uminus(v1411), v1412); + store(out, 104 << outShift, ctimesminusplus(reverse(v1415), tbl[256 + tbloffset], ctimes(v1415, tbl[257 + tbloffset]))); + store(out, 40 << outShift, ctimesminusplus(reverse(v1413), tbl[254 + tbloffset], ctimes(v1413, tbl[255 + tbloffset]))); + real2 v1329 = ctimesminusplus(reverse(v1315), tbl[240 + tbloffset], ctimes(v1315, tbl[241 + tbloffset])); + real2 v1443 = plus(v1289, v1329); + real2 v1437 = reverse(minus(v1329, v1289)); + store(out, 24 << outShift, plus(v1442, v1443)); + real2 v1456 = minus(v1442, v1443); + store(out, 88 << outShift, ctimesminusplus(v1456, tbl[0 + tbloffset], ctimes(reverse(v1456), tbl[1 + tbloffset]))); + real2 v1441 = minusplus(uminus(v1437), v1438); + real2 v1439 = minusplus(v1437, v1438); + store(out, 120 << outShift, ctimesminusplus(reverse(v1441), tbl[260 + tbloffset], ctimes(v1441, tbl[261 + tbloffset]))); + store(out, 56 << outShift, ctimesminusplus(reverse(v1439), tbl[258 + tbloffset], ctimes(v1439, tbl[259 + tbloffset]))); + real2 v1235 = minusplus(uminus(v1231), v1232); + real2 v1233 = minusplus(v1231, v1232); + real2 v1243 = ctimesminusplus(reverse(v1233), tbl[222 + tbloffset], ctimes(v1233, tbl[223 + tbloffset])); + real2 v1489 = plus(v1163, v1243); + real2 v1483 = reverse(minus(v1243, v1163)); + real2 v1509 = plus(v1488, v1489); + real2 v1503 = reverse(minus(v1489, v1488)); + store(out, 4 << outShift, plus(v1508, v1509)); + real2 v1522 = minus(v1508, v1509); + store(out, 68 << outShift, ctimesminusplus(v1522, tbl[0 + tbloffset], ctimes(reverse(v1522), tbl[1 + tbloffset]))); + real2 v1507 = minusplus(uminus(v1503), v1504); + real2 v1505 = minusplus(v1503, v1504); + store(out, 36 << outShift, ctimesminusplus(reverse(v1505), tbl[270 + tbloffset], ctimes(v1505, tbl[271 + tbloffset]))); + store(out, 100 << outShift, ctimesminusplus(reverse(v1507), tbl[272 + tbloffset], ctimes(v1507, tbl[273 + tbloffset]))); + real2 v1485 = minusplus(v1483, v1484); + real2 v1487 = minusplus(uminus(v1483), v1484); + real2 v1501 = ctimesminusplus(reverse(v1487), tbl[268 + tbloffset], ctimes(v1487, tbl[269 + tbloffset])); + store(out, 52 << outShift, plus(v1481, v1501)); + real2 v1534 = minus(v1481, v1501); + store(out, 116 << outShift, ctimesminusplus(v1534, tbl[0 + tbloffset], ctimes(reverse(v1534), tbl[1 + tbloffset]))); + real2 v1495 = ctimesminusplus(reverse(v1485), tbl[266 + tbloffset], ctimes(v1485, tbl[267 + tbloffset])); + store(out, 20 << outShift, plus(v1475, v1495)); + real2 v1528 = minus(v1475, v1495); + store(out, 84 << outShift, ctimesminusplus(v1528, tbl[0 + tbloffset], ctimes(reverse(v1528), tbl[1 + tbloffset]))); + real2 v1249 = ctimesminusplus(reverse(v1235), tbl[224 + tbloffset], ctimes(v1235, tbl[225 + tbloffset])); + real2 v1169 = ctimesminusplus(reverse(v1155), tbl[208 + tbloffset], ctimes(v1155, tbl[209 + tbloffset])); + real2 v1567 = plus(v1169, v1249); + real2 v1561 = reverse(minus(v1249, v1169)); + real2 v1581 = reverse(minus(v1567, v1566)); + real2 v1587 = plus(v1566, v1567); + store(out, 12 << outShift, plus(v1586, v1587)); + real2 v1600 = minus(v1586, v1587); + store(out, 76 << outShift, ctimesminusplus(v1600, tbl[0 + tbloffset], ctimes(reverse(v1600), tbl[1 + tbloffset]))); + real2 v1583 = minusplus(v1581, v1582); + store(out, 44 << outShift, ctimesminusplus(reverse(v1583), tbl[282 + tbloffset], ctimes(v1583, tbl[283 + tbloffset]))); + real2 v1585 = minusplus(uminus(v1581), v1582); + store(out, 108 << outShift, ctimesminusplus(reverse(v1585), tbl[284 + tbloffset], ctimes(v1585, tbl[285 + tbloffset]))); + real2 v1565 = minusplus(uminus(v1561), v1562); + real2 v1563 = minusplus(v1561, v1562); + real2 v1579 = ctimesminusplus(reverse(v1565), tbl[280 + tbloffset], ctimes(v1565, tbl[281 + tbloffset])); + store(out, 60 << outShift, plus(v1559, v1579)); + real2 v1612 = minus(v1559, v1579); + store(out, 124 << outShift, ctimesminusplus(v1612, tbl[0 + tbloffset], ctimes(reverse(v1612), tbl[1 + tbloffset]))); + real2 v1573 = ctimesminusplus(reverse(v1563), tbl[278 + tbloffset], ctimes(v1563, tbl[279 + tbloffset])); + store(out, 28 << outShift, plus(v1553, v1573)); + real2 v1606 = minus(v1553, v1573); + store(out, 92 << outShift, ctimesminusplus(v1606, tbl[0 + tbloffset], ctimes(reverse(v1606), tbl[1 + tbloffset]))); + real2 v833 = minusplus(v831, v832); + real2 v835 = minusplus(uminus(v831), v832); + real2 v955 = minusplus(uminus(v951), v952); + real2 v953 = minusplus(v951, v952); + real2 v963 = ctimesminusplus(reverse(v953), tbl[166 + tbloffset], ctimes(v953, tbl[167 + tbloffset])); + real2 v995 = minusplus(uminus(v991), v992); + real2 v993 = minusplus(v991, v992); + real2 v1003 = ctimesminusplus(reverse(v993), tbl[174 + tbloffset], ctimes(v993, tbl[175 + tbloffset])); + real2 v843 = ctimesminusplus(reverse(v833), tbl[142 + tbloffset], ctimes(v833, tbl[143 + tbloffset])); + real2 v1640 = minus(v963, v803); + real2 v1644 = plus(v803, v963); + real2 v1680 = minus(v1003, v843); + real2 v1684 = plus(v843, v1003); + real2 v1641 = minusplus(v1639, v1640); + real2 v1643 = minusplus(uminus(v1639), v1640); + real2 v1657 = ctimesminusplus(reverse(v1643), tbl[292 + tbloffset], ctimes(v1643, tbl[293 + tbloffset])); + real2 v913 = minusplus(v911, v912); + real2 v915 = minusplus(uminus(v911), v912); + real2 v1073 = minusplus(v1071, v1072); + real2 v1075 = minusplus(uminus(v1071), v1072); + real2 v923 = ctimesminusplus(reverse(v913), tbl[158 + tbloffset], ctimes(v913, tbl[159 + tbloffset])); + real2 v1083 = ctimesminusplus(reverse(v1073), tbl[190 + tbloffset], ctimes(v1073, tbl[191 + tbloffset])); + real2 v1685 = plus(v923, v1083); + real2 v1679 = reverse(minus(v1083, v923)); + real2 v1681 = minusplus(v1679, v1680); + real2 v1683 = minusplus(uminus(v1679), v1680); + real2 v1697 = ctimesminusplus(reverse(v1683), tbl[300 + tbloffset], ctimes(v1683, tbl[301 + tbloffset])); + real2 v1809 = plus(v1657, v1697); + real2 v1803 = reverse(minus(v1697, v1657)); + store(out, 26 << outShift, plus(v1808, v1809)); + real2 v1822 = minus(v1808, v1809); + store(out, 90 << outShift, ctimesminusplus(v1822, tbl[0 + tbloffset], ctimes(reverse(v1822), tbl[1 + tbloffset]))); + real2 v1807 = minusplus(uminus(v1803), v1804); + real2 v1805 = minusplus(v1803, v1804); + store(out, 58 << outShift, ctimesminusplus(reverse(v1805), tbl[318 + tbloffset], ctimes(v1805, tbl[319 + tbloffset]))); + store(out, 122 << outShift, ctimesminusplus(reverse(v1807), tbl[320 + tbloffset], ctimes(v1807, tbl[321 + tbloffset]))); + real2 v1651 = ctimesminusplus(reverse(v1641), tbl[290 + tbloffset], ctimes(v1641, tbl[291 + tbloffset])); + real2 v1691 = ctimesminusplus(reverse(v1681), tbl[298 + tbloffset], ctimes(v1681, tbl[299 + tbloffset])); + real2 v1783 = plus(v1651, v1691); + real2 v1777 = reverse(minus(v1691, v1651)); + real2 v1779 = minusplus(v1777, v1778); + real2 v1781 = minusplus(uminus(v1777), v1778); + store(out, 106 << outShift, ctimesminusplus(reverse(v1781), tbl[316 + tbloffset], ctimes(v1781, tbl[317 + tbloffset]))); + store(out, 42 << outShift, ctimesminusplus(reverse(v1779), tbl[314 + tbloffset], ctimes(v1779, tbl[315 + tbloffset]))); + store(out, 10 << outShift, plus(v1782, v1783)); + real2 v1796 = minus(v1782, v1783); + store(out, 74 << outShift, ctimesminusplus(v1796, tbl[0 + tbloffset], ctimes(reverse(v1796), tbl[1 + tbloffset]))); + real2 v1720 = minus(v1645, v1644); + real2 v1724 = plus(v1644, v1645); + real2 v1719 = reverse(minus(v1685, v1684)); + real2 v1725 = plus(v1684, v1685); + real2 v1745 = plus(v1724, v1725); + real2 v1739 = reverse(minus(v1725, v1724)); + store(out, 2 << outShift, plus(v1744, v1745)); + real2 v1758 = minus(v1744, v1745); + store(out, 66 << outShift, ctimesminusplus(v1758, tbl[0 + tbloffset], ctimes(reverse(v1758), tbl[1 + tbloffset]))); + real2 v1741 = minusplus(v1739, v1740); + real2 v1743 = minusplus(uminus(v1739), v1740); + store(out, 98 << outShift, ctimesminusplus(reverse(v1743), tbl[312 + tbloffset], ctimes(v1743, tbl[313 + tbloffset]))); + store(out, 34 << outShift, ctimesminusplus(reverse(v1741), tbl[310 + tbloffset], ctimes(v1741, tbl[311 + tbloffset]))); + real2 v1723 = minusplus(uminus(v1719), v1720); + real2 v1721 = minusplus(v1719, v1720); + real2 v1737 = ctimesminusplus(reverse(v1723), tbl[308 + tbloffset], ctimes(v1723, tbl[309 + tbloffset])); + store(out, 50 << outShift, plus(v1717, v1737)); + real2 v1770 = minus(v1717, v1737); + store(out, 114 << outShift, ctimesminusplus(v1770, tbl[0 + tbloffset], ctimes(reverse(v1770), tbl[1 + tbloffset]))); + real2 v1731 = ctimesminusplus(reverse(v1721), tbl[306 + tbloffset], ctimes(v1721, tbl[307 + tbloffset])); + store(out, 18 << outShift, plus(v1711, v1731)); + real2 v1764 = minus(v1711, v1731); + store(out, 82 << outShift, ctimesminusplus(v1764, tbl[0 + tbloffset], ctimes(reverse(v1764), tbl[1 + tbloffset]))); + real2 v809 = ctimesminusplus(reverse(v795), tbl[136 + tbloffset], ctimes(v795, tbl[137 + tbloffset])); + real2 v969 = ctimesminusplus(reverse(v955), tbl[168 + tbloffset], ctimes(v955, tbl[169 + tbloffset])); + real2 v1850 = minus(v969, v809); + real2 v1854 = plus(v809, v969); + real2 v849 = ctimesminusplus(reverse(v835), tbl[144 + tbloffset], ctimes(v835, tbl[145 + tbloffset])); + real2 v929 = ctimesminusplus(reverse(v915), tbl[160 + tbloffset], ctimes(v915, tbl[161 + tbloffset])); + real2 v889 = ctimesminusplus(reverse(v875), tbl[152 + tbloffset], ctimes(v875, tbl[153 + tbloffset])); + real2 v1089 = ctimesminusplus(reverse(v1075), tbl[192 + tbloffset], ctimes(v1075, tbl[193 + tbloffset])); + real2 v1009 = ctimesminusplus(reverse(v995), tbl[176 + tbloffset], ctimes(v995, tbl[177 + tbloffset])); + real2 v1890 = minus(v1009, v849); + real2 v1894 = plus(v849, v1009); + real2 v1849 = reverse(minus(v1049, v889)); + real2 v1855 = plus(v889, v1049); + real2 v1930 = minus(v1855, v1854); + real2 v1934 = plus(v1854, v1855); + real2 v1895 = plus(v929, v1089); + real2 v1889 = reverse(minus(v1089, v929)); + real2 v1929 = reverse(minus(v1895, v1894)); + real2 v1935 = plus(v1894, v1895); + real2 v1955 = plus(v1934, v1935); + real2 v1949 = reverse(minus(v1935, v1934)); + store(out, 6 << outShift, plus(v1954, v1955)); + real2 v1968 = minus(v1954, v1955); + store(out, 70 << outShift, ctimesminusplus(v1968, tbl[0 + tbloffset], ctimes(reverse(v1968), tbl[1 + tbloffset]))); + real2 v1951 = minusplus(v1949, v1950); + store(out, 38 << outShift, ctimesminusplus(reverse(v1951), tbl[346 + tbloffset], ctimes(v1951, tbl[347 + tbloffset]))); + real2 v1953 = minusplus(uminus(v1949), v1950); + store(out, 102 << outShift, ctimesminusplus(reverse(v1953), tbl[348 + tbloffset], ctimes(v1953, tbl[349 + tbloffset]))); + real2 v1931 = minusplus(v1929, v1930); + real2 v1933 = minusplus(uminus(v1929), v1930); + real2 v1947 = ctimesminusplus(reverse(v1933), tbl[344 + tbloffset], ctimes(v1933, tbl[345 + tbloffset])); + store(out, 54 << outShift, plus(v1927, v1947)); + real2 v1980 = minus(v1927, v1947); + store(out, 118 << outShift, ctimesminusplus(v1980, tbl[0 + tbloffset], ctimes(reverse(v1980), tbl[1 + tbloffset]))); + real2 v1941 = ctimesminusplus(reverse(v1931), tbl[342 + tbloffset], ctimes(v1931, tbl[343 + tbloffset])); + store(out, 22 << outShift, plus(v1921, v1941)); + real2 v1974 = minus(v1921, v1941); + store(out, 86 << outShift, ctimesminusplus(v1974, tbl[0 + tbloffset], ctimes(reverse(v1974), tbl[1 + tbloffset]))); + real2 v1851 = minusplus(v1849, v1850); + real2 v1853 = minusplus(uminus(v1849), v1850); + real2 v1867 = ctimesminusplus(reverse(v1853), tbl[328 + tbloffset], ctimes(v1853, tbl[329 + tbloffset])); + real2 v1891 = minusplus(v1889, v1890); + real2 v1893 = minusplus(uminus(v1889), v1890); + real2 v1907 = ctimesminusplus(reverse(v1893), tbl[336 + tbloffset], ctimes(v1893, tbl[337 + tbloffset])); + real2 v2019 = plus(v1867, v1907); + real2 v2013 = reverse(minus(v1907, v1867)); + store(out, 30 << outShift, plus(v2018, v2019)); + real2 v2032 = minus(v2018, v2019); + store(out, 94 << outShift, ctimesminusplus(v2032, tbl[0 + tbloffset], ctimes(reverse(v2032), tbl[1 + tbloffset]))); + real2 v2017 = minusplus(uminus(v2013), v2014); + store(out, 126 << outShift, ctimesminusplus(reverse(v2017), tbl[356 + tbloffset], ctimes(v2017, tbl[357 + tbloffset]))); + real2 v2015 = minusplus(v2013, v2014); + store(out, 62 << outShift, ctimesminusplus(reverse(v2015), tbl[354 + tbloffset], ctimes(v2015, tbl[355 + tbloffset]))); + real2 v1861 = ctimesminusplus(reverse(v1851), tbl[326 + tbloffset], ctimes(v1851, tbl[327 + tbloffset])); + real2 v1901 = ctimesminusplus(reverse(v1891), tbl[334 + tbloffset], ctimes(v1891, tbl[335 + tbloffset])); + real2 v1993 = plus(v1861, v1901); + real2 v1987 = reverse(minus(v1901, v1861)); + store(out, 14 << outShift, plus(v1992, v1993)); + real2 v2006 = minus(v1992, v1993); + store(out, 78 << outShift, ctimesminusplus(v2006, tbl[0 + tbloffset], ctimes(reverse(v2006), tbl[1 + tbloffset]))); + real2 v1991 = minusplus(uminus(v1987), v1988); + store(out, 110 << outShift, ctimesminusplus(reverse(v1991), tbl[352 + tbloffset], ctimes(v1991, tbl[353 + tbloffset]))); + real2 v1989 = minusplus(v1987, v1988); + store(out, 46 << outShift, ctimesminusplus(reverse(v1989), tbl[350 + tbloffset], ctimes(v1989, tbl[351 + tbloffset]))); + real2 v593 = minusplus(v591, v592); + real2 v595 = minusplus(uminus(v591), v592); + real2 v473 = minusplus(v471, v472); + real2 v475 = minusplus(uminus(v471), v472); + real2 v555 = minusplus(uminus(v551), v552); + real2 v553 = minusplus(v551, v552); + real2 v609 = ctimesminusplus(reverse(v595), tbl[96 + tbloffset], ctimes(v595, tbl[97 + tbloffset])); + real2 v195 = minusplus(uminus(v191), v192); + real2 v193 = minusplus(v191, v192); + real2 v275 = minusplus(uminus(v271), v272); + real2 v273 = minusplus(v271, v272); + real2 v673 = minusplus(v671, v672); + real2 v675 = minusplus(uminus(v671), v672); + real2 v689 = ctimesminusplus(reverse(v675), tbl[112 + tbloffset], ctimes(v675, tbl[113 + tbloffset])); + real2 v209 = ctimesminusplus(reverse(v195), tbl[16 + tbloffset], ctimes(v195, tbl[17 + tbloffset])); + real2 v289 = ctimesminusplus(reverse(v275), tbl[32 + tbloffset], ctimes(v275, tbl[33 + tbloffset])); + real2 v755 = minusplus(uminus(v751), v752); + real2 v753 = minusplus(v751, v752); + real2 v435 = minusplus(uminus(v431), v432); + real2 v433 = minusplus(v431, v432); + real2 v513 = minusplus(v511, v512); + real2 v515 = minusplus(uminus(v511), v512); + real2 v529 = ctimesminusplus(reverse(v515), tbl[80 + tbloffset], ctimes(v515, tbl[81 + tbloffset])); + real2 v353 = minusplus(v351, v352); + real2 v355 = minusplus(uminus(v351), v352); + real2 v369 = ctimesminusplus(reverse(v355), tbl[48 + tbloffset], ctimes(v355, tbl[49 + tbloffset])); + real2 v2631 = plus(v369, v689); + real2 v2625 = reverse(minus(v689, v369)); + real2 v449 = ctimesminusplus(reverse(v435), tbl[64 + tbloffset], ctimes(v435, tbl[65 + tbloffset])); + real2 v2710 = plus(v289, v609); + real2 v2706 = minus(v609, v289); + real2 v2630 = plus(v209, v529); + real2 v2626 = minus(v529, v209); + real2 v2790 = plus(v2630, v2631); + real2 v2786 = minus(v2631, v2630); + real2 v713 = minusplus(v711, v712); + real2 v715 = minusplus(uminus(v711), v712); + real2 v769 = ctimesminusplus(reverse(v755), tbl[128 + tbloffset], ctimes(v755, tbl[129 + tbloffset])); + real2 v2705 = reverse(minus(v769, v449)); + real2 v2711 = plus(v449, v769); + real2 v313 = minusplus(v311, v312); + real2 v315 = minusplus(uminus(v311), v312); + real2 v393 = minusplus(v391, v392); + real2 v395 = minusplus(uminus(v391), v392); + real2 v409 = ctimesminusplus(reverse(v395), tbl[56 + tbloffset], ctimes(v395, tbl[57 + tbloffset])); + real2 v729 = ctimesminusplus(reverse(v715), tbl[120 + tbloffset], ctimes(v715, tbl[121 + tbloffset])); + real2 v329 = ctimesminusplus(reverse(v315), tbl[40 + tbloffset], ctimes(v315, tbl[41 + tbloffset])); + real2 v489 = ctimesminusplus(reverse(v475), tbl[72 + tbloffset], ctimes(v475, tbl[73 + tbloffset])); + real2 v153 = minusplus(v151, v152); + real2 v155 = minusplus(uminus(v151), v152); + real2 v169 = ctimesminusplus(reverse(v155), tbl[8 + tbloffset], ctimes(v155, tbl[9 + tbloffset])); + real2 v2586 = minus(v489, v169); + real2 v2590 = plus(v169, v489); + real2 v233 = minusplus(v231, v232); + real2 v235 = minusplus(uminus(v231), v232); + real2 v633 = minusplus(v631, v632); + real2 v635 = minusplus(uminus(v631), v632); + real2 v649 = ctimesminusplus(reverse(v635), tbl[104 + tbloffset], ctimes(v635, tbl[105 + tbloffset])); + real2 v249 = ctimesminusplus(reverse(v235), tbl[24 + tbloffset], ctimes(v235, tbl[25 + tbloffset])); + real2 v569 = ctimesminusplus(reverse(v555), tbl[88 + tbloffset], ctimes(v555, tbl[89 + tbloffset])); + real2 v2670 = plus(v249, v569); + real2 v2666 = minus(v569, v249); + real2 v2785 = reverse(minus(v2711, v2710)); + real2 v2791 = plus(v2710, v2711); + real2 v2825 = reverse(minus(v2791, v2790)); + real2 v2831 = plus(v2790, v2791); + real2 v2671 = plus(v409, v729); + real2 v2665 = reverse(minus(v729, v409)); + real2 v2745 = reverse(minus(v2671, v2670)); + real2 v2751 = plus(v2670, v2671); + real2 v2806 = minus(v2731, v2730); + real2 v2810 = plus(v2730, v2731); + real2 v2846 = minus(v2811, v2810); + real2 v2850 = plus(v2810, v2811); + real2 v2591 = plus(v329, v649); + real2 v2585 = reverse(minus(v649, v329)); + real2 v2750 = plus(v2590, v2591); + real2 v2746 = minus(v2591, v2590); + real2 v2830 = plus(v2750, v2751); + real2 v2826 = minus(v2751, v2750); + real2 v2845 = reverse(minus(v2831, v2830)); + real2 v2851 = plus(v2830, v2831); + store(out, 3 << outShift, plus(v2850, v2851)); + real2 v2864 = minus(v2850, v2851); + store(out, 67 << outShift, ctimesminusplus(v2864, tbl[0 + tbloffset], ctimes(reverse(v2864), tbl[1 + tbloffset]))); + real2 v2849 = minusplus(uminus(v2845), v2846); + real2 v2847 = minusplus(v2845, v2846); + store(out, 35 << outShift, ctimesminusplus(reverse(v2847), tbl[506 + tbloffset], ctimes(v2847, tbl[507 + tbloffset]))); + store(out, 99 << outShift, ctimesminusplus(reverse(v2849), tbl[508 + tbloffset], ctimes(v2849, tbl[509 + tbloffset]))); + real2 v2827 = minusplus(v2825, v2826); + real2 v2829 = minusplus(uminus(v2825), v2826); + real2 v2837 = ctimesminusplus(reverse(v2827), tbl[502 + tbloffset], ctimes(v2827, tbl[503 + tbloffset])); + real2 v2809 = minusplus(uminus(v2805), v2806); + real2 v2807 = minusplus(v2805, v2806); + real2 v2817 = ctimesminusplus(reverse(v2807), tbl[498 + tbloffset], ctimes(v2807, tbl[499 + tbloffset])); + store(out, 19 << outShift, plus(v2817, v2837)); + real2 v2870 = minus(v2817, v2837); + store(out, 83 << outShift, ctimesminusplus(v2870, tbl[0 + tbloffset], ctimes(reverse(v2870), tbl[1 + tbloffset]))); + real2 v2823 = ctimesminusplus(reverse(v2809), tbl[500 + tbloffset], ctimes(v2809, tbl[501 + tbloffset])); + real2 v2843 = ctimesminusplus(reverse(v2829), tbl[504 + tbloffset], ctimes(v2829, tbl[505 + tbloffset])); + store(out, 51 << outShift, plus(v2823, v2843)); + real2 v2876 = minus(v2823, v2843); + store(out, 115 << outShift, ctimesminusplus(v2876, tbl[0 + tbloffset], ctimes(reverse(v2876), tbl[1 + tbloffset]))); + real2 v2787 = minusplus(v2785, v2786); + real2 v2789 = minusplus(uminus(v2785), v2786); + real2 v2803 = ctimesminusplus(reverse(v2789), tbl[496 + tbloffset], ctimes(v2789, tbl[497 + tbloffset])); + real2 v2727 = minusplus(v2725, v2726); + real2 v2729 = minusplus(uminus(v2725), v2726); + real2 v2743 = ctimesminusplus(reverse(v2729), tbl[484 + tbloffset], ctimes(v2729, tbl[485 + tbloffset])); + real2 v2914 = plus(v2743, v2783); + real2 v2910 = minus(v2783, v2743); + real2 v2749 = minusplus(uminus(v2745), v2746); + real2 v2747 = minusplus(v2745, v2746); + real2 v2763 = ctimesminusplus(reverse(v2749), tbl[488 + tbloffset], ctimes(v2749, tbl[489 + tbloffset])); + real2 v2909 = reverse(minus(v2803, v2763)); + real2 v2915 = plus(v2763, v2803); + store(out, 27 << outShift, plus(v2914, v2915)); + real2 v2928 = minus(v2914, v2915); + store(out, 91 << outShift, ctimesminusplus(v2928, tbl[0 + tbloffset], ctimes(reverse(v2928), tbl[1 + tbloffset]))); + real2 v2913 = minusplus(uminus(v2909), v2910); + store(out, 123 << outShift, ctimesminusplus(reverse(v2913), tbl[516 + tbloffset], ctimes(v2913, tbl[517 + tbloffset]))); + real2 v2911 = minusplus(v2909, v2910); + store(out, 59 << outShift, ctimesminusplus(reverse(v2911), tbl[514 + tbloffset], ctimes(v2911, tbl[515 + tbloffset]))); + real2 v2737 = ctimesminusplus(reverse(v2727), tbl[482 + tbloffset], ctimes(v2727, tbl[483 + tbloffset])); + real2 v2888 = plus(v2737, v2777); + real2 v2884 = minus(v2777, v2737); + real2 v2797 = ctimesminusplus(reverse(v2787), tbl[494 + tbloffset], ctimes(v2787, tbl[495 + tbloffset])); + real2 v2757 = ctimesminusplus(reverse(v2747), tbl[486 + tbloffset], ctimes(v2747, tbl[487 + tbloffset])); + real2 v2889 = plus(v2757, v2797); + real2 v2883 = reverse(minus(v2797, v2757)); + store(out, 11 << outShift, plus(v2888, v2889)); + real2 v2902 = minus(v2888, v2889); + store(out, 75 << outShift, ctimesminusplus(v2902, tbl[0 + tbloffset], ctimes(reverse(v2902), tbl[1 + tbloffset]))); + real2 v2887 = minusplus(uminus(v2883), v2884); + store(out, 107 << outShift, ctimesminusplus(reverse(v2887), tbl[512 + tbloffset], ctimes(v2887, tbl[513 + tbloffset]))); + real2 v2885 = minusplus(v2883, v2884); + store(out, 43 << outShift, ctimesminusplus(reverse(v2885), tbl[510 + tbloffset], ctimes(v2885, tbl[511 + tbloffset]))); + real2 v2669 = minusplus(uminus(v2665), v2666); + real2 v2667 = minusplus(v2665, v2666); + real2 v2707 = minusplus(v2705, v2706); + real2 v2709 = minusplus(uminus(v2705), v2706); + real2 v2717 = ctimesminusplus(reverse(v2707), tbl[478 + tbloffset], ctimes(v2707, tbl[479 + tbloffset])); + real2 v2627 = minusplus(v2625, v2626); + real2 v2629 = minusplus(uminus(v2625), v2626); + real2 v2637 = ctimesminusplus(reverse(v2627), tbl[462 + tbloffset], ctimes(v2627, tbl[463 + tbloffset])); + real2 v2961 = plus(v2637, v2717); + real2 v2955 = reverse(minus(v2717, v2637)); + real2 v2649 = minusplus(uminus(v2645), v2646); + real2 v2647 = minusplus(v2645, v2646); + real2 v2569 = minusplus(uminus(v2565), v2566); + real2 v2567 = minusplus(v2565, v2566); + real2 v2577 = ctimesminusplus(reverse(v2567), tbl[450 + tbloffset], ctimes(v2567, tbl[451 + tbloffset])); + real2 v2657 = ctimesminusplus(reverse(v2647), tbl[466 + tbloffset], ctimes(v2647, tbl[467 + tbloffset])); + real2 v2936 = minus(v2657, v2577); + real2 v2940 = plus(v2577, v2657); + real2 v2976 = minus(v2941, v2940); + real2 v2980 = plus(v2940, v2941); + real2 v2677 = ctimesminusplus(reverse(v2667), tbl[470 + tbloffset], ctimes(v2667, tbl[471 + tbloffset])); + real2 v2587 = minusplus(v2585, v2586); + real2 v2589 = minusplus(uminus(v2585), v2586); + real2 v2597 = ctimesminusplus(reverse(v2587), tbl[454 + tbloffset], ctimes(v2587, tbl[455 + tbloffset])); + real2 v2956 = minus(v2677, v2597); + real2 v2960 = plus(v2597, v2677); + real2 v2975 = reverse(minus(v2961, v2960)); + real2 v2981 = plus(v2960, v2961); + store(out, 7 << outShift, plus(v2980, v2981)); + real2 v2994 = minus(v2980, v2981); + store(out, 71 << outShift, ctimesminusplus(v2994, tbl[0 + tbloffset], ctimes(reverse(v2994), tbl[1 + tbloffset]))); + real2 v2979 = minusplus(uminus(v2975), v2976); + store(out, 103 << outShift, ctimesminusplus(reverse(v2979), tbl[528 + tbloffset], ctimes(v2979, tbl[529 + tbloffset]))); + real2 v2977 = minusplus(v2975, v2976); + store(out, 39 << outShift, ctimesminusplus(reverse(v2977), tbl[526 + tbloffset], ctimes(v2977, tbl[527 + tbloffset]))); + real2 v2939 = minusplus(uminus(v2935), v2936); + real2 v2937 = minusplus(v2935, v2936); + real2 v2953 = ctimesminusplus(reverse(v2939), tbl[520 + tbloffset], ctimes(v2939, tbl[521 + tbloffset])); + real2 v2957 = minusplus(v2955, v2956); + real2 v2959 = minusplus(uminus(v2955), v2956); + real2 v2973 = ctimesminusplus(reverse(v2959), tbl[524 + tbloffset], ctimes(v2959, tbl[525 + tbloffset])); + store(out, 55 << outShift, plus(v2953, v2973)); + real2 v3006 = minus(v2953, v2973); + store(out, 119 << outShift, ctimesminusplus(v3006, tbl[0 + tbloffset], ctimes(reverse(v3006), tbl[1 + tbloffset]))); + real2 v2947 = ctimesminusplus(reverse(v2937), tbl[518 + tbloffset], ctimes(v2937, tbl[519 + tbloffset])); + real2 v2967 = ctimesminusplus(reverse(v2957), tbl[522 + tbloffset], ctimes(v2957, tbl[523 + tbloffset])); + store(out, 23 << outShift, plus(v2947, v2967)); + real2 v3000 = minus(v2947, v2967); + store(out, 87 << outShift, ctimesminusplus(v3000, tbl[0 + tbloffset], ctimes(reverse(v3000), tbl[1 + tbloffset]))); + real2 v2663 = ctimesminusplus(reverse(v2649), tbl[468 + tbloffset], ctimes(v2649, tbl[469 + tbloffset])); + real2 v2583 = ctimesminusplus(reverse(v2569), tbl[452 + tbloffset], ctimes(v2569, tbl[453 + tbloffset])); + real2 v3014 = minus(v2663, v2583); + real2 v3018 = plus(v2583, v2663); + real2 v3015 = minusplus(v3013, v3014); + real2 v3017 = minusplus(uminus(v3013), v3014); + real2 v2643 = ctimesminusplus(reverse(v2629), tbl[464 + tbloffset], ctimes(v2629, tbl[465 + tbloffset])); + real2 v2723 = ctimesminusplus(reverse(v2709), tbl[480 + tbloffset], ctimes(v2709, tbl[481 + tbloffset])); + real2 v3039 = plus(v2643, v2723); + real2 v3033 = reverse(minus(v2723, v2643)); + real2 v2683 = ctimesminusplus(reverse(v2669), tbl[472 + tbloffset], ctimes(v2669, tbl[473 + tbloffset])); + real2 v3031 = ctimesminusplus(reverse(v3017), tbl[532 + tbloffset], ctimes(v3017, tbl[533 + tbloffset])); + real2 v2603 = ctimesminusplus(reverse(v2589), tbl[456 + tbloffset], ctimes(v2589, tbl[457 + tbloffset])); + real2 v3034 = minus(v2683, v2603); + real2 v3038 = plus(v2603, v2683); + real2 v3037 = minusplus(uminus(v3033), v3034); + real2 v3035 = minusplus(v3033, v3034); + real2 v3051 = ctimesminusplus(reverse(v3037), tbl[536 + tbloffset], ctimes(v3037, tbl[537 + tbloffset])); + store(out, 63 << outShift, plus(v3031, v3051)); + real2 v3084 = minus(v3031, v3051); + store(out, 127 << outShift, ctimesminusplus(v3084, tbl[0 + tbloffset], ctimes(reverse(v3084), tbl[1 + tbloffset]))); + real2 v3025 = ctimesminusplus(reverse(v3015), tbl[530 + tbloffset], ctimes(v3015, tbl[531 + tbloffset])); + real2 v3045 = ctimesminusplus(reverse(v3035), tbl[534 + tbloffset], ctimes(v3035, tbl[535 + tbloffset])); + store(out, 31 << outShift, plus(v3025, v3045)); + real2 v3078 = minus(v3025, v3045); + store(out, 95 << outShift, ctimesminusplus(v3078, tbl[0 + tbloffset], ctimes(reverse(v3078), tbl[1 + tbloffset]))); + real2 v3058 = plus(v3018, v3019); + real2 v3054 = minus(v3019, v3018); + real2 v3053 = reverse(minus(v3039, v3038)); + real2 v3059 = plus(v3038, v3039); + real2 v3055 = minusplus(v3053, v3054); + store(out, 47 << outShift, ctimesminusplus(reverse(v3055), tbl[538 + tbloffset], ctimes(v3055, tbl[539 + tbloffset]))); + real2 v3057 = minusplus(uminus(v3053), v3054); + store(out, 111 << outShift, ctimesminusplus(reverse(v3057), tbl[540 + tbloffset], ctimes(v3057, tbl[541 + tbloffset]))); + store(out, 15 << outShift, plus(v3058, v3059)); + real2 v3072 = minus(v3058, v3059); + store(out, 79 << outShift, ctimesminusplus(v3072, tbl[0 + tbloffset], ctimes(reverse(v3072), tbl[1 + tbloffset]))); + real2 v683 = ctimesminusplus(reverse(v673), tbl[110 + tbloffset], ctimes(v673, tbl[111 + tbloffset])); + real2 v363 = ctimesminusplus(reverse(v353), tbl[46 + tbloffset], ctimes(v353, tbl[47 + tbloffset])); + real2 v2105 = plus(v363, v683); + real2 v2099 = reverse(minus(v683, v363)); + real2 v283 = ctimesminusplus(reverse(v273), tbl[30 + tbloffset], ctimes(v273, tbl[31 + tbloffset])); + real2 v723 = ctimesminusplus(reverse(v713), tbl[118 + tbloffset], ctimes(v713, tbl[119 + tbloffset])); + real2 v403 = ctimesminusplus(reverse(v393), tbl[54 + tbloffset], ctimes(v393, tbl[55 + tbloffset])); + real2 v603 = ctimesminusplus(reverse(v593), tbl[94 + tbloffset], ctimes(v593, tbl[95 + tbloffset])); + real2 v2180 = minus(v603, v283); + real2 v2184 = plus(v283, v603); + real2 v2145 = plus(v403, v723); + real2 v2139 = reverse(minus(v723, v403)); + real2 v543 = ctimesminusplus(reverse(v533), tbl[82 + tbloffset], ctimes(v533, tbl[83 + tbloffset])); + real2 v383 = ctimesminusplus(reverse(v373), tbl[50 + tbloffset], ctimes(v373, tbl[51 + tbloffset])); + real2 v703 = ctimesminusplus(reverse(v693), tbl[114 + tbloffset], ctimes(v693, tbl[115 + tbloffset])); + real2 v2125 = plus(v383, v703); + real2 v2119 = reverse(minus(v703, v383)); + real2 v223 = ctimesminusplus(reverse(v213), tbl[18 + tbloffset], ctimes(v213, tbl[19 + tbloffset])); + real2 v2120 = minus(v543, v223); + real2 v2124 = plus(v223, v543); + real2 v443 = ctimesminusplus(reverse(v433), tbl[62 + tbloffset], ctimes(v433, tbl[63 + tbloffset])); + real2 v203 = ctimesminusplus(reverse(v193), tbl[14 + tbloffset], ctimes(v193, tbl[15 + tbloffset])); + real2 v763 = ctimesminusplus(reverse(v753), tbl[126 + tbloffset], ctimes(v753, tbl[127 + tbloffset])); + real2 v2179 = reverse(minus(v763, v443)); + real2 v2185 = plus(v443, v763); + real2 v523 = ctimesminusplus(reverse(v513), tbl[78 + tbloffset], ctimes(v513, tbl[79 + tbloffset])); + real2 v2100 = minus(v523, v203); + real2 v2104 = plus(v203, v523); + real2 v2264 = plus(v2104, v2105); + real2 v2260 = minus(v2105, v2104); + real2 v643 = ctimesminusplus(reverse(v633), tbl[102 + tbloffset], ctimes(v633, tbl[103 + tbloffset])); + real2 v2265 = plus(v2184, v2185); + real2 v2259 = reverse(minus(v2185, v2184)); + real2 v563 = ctimesminusplus(reverse(v553), tbl[86 + tbloffset], ctimes(v553, tbl[87 + tbloffset])); + real2 v243 = ctimesminusplus(reverse(v233), tbl[22 + tbloffset], ctimes(v233, tbl[23 + tbloffset])); + real2 v2144 = plus(v243, v563); + real2 v2140 = minus(v563, v243); + real2 v143 = ctimesminusplus(reverse(v133), tbl[2 + tbloffset], ctimes(v133, tbl[3 + tbloffset])); + real2 v183 = ctimesminusplus(reverse(v173), tbl[10 + tbloffset], ctimes(v173, tbl[11 + tbloffset])); + real2 v2084 = plus(v183, v503); + real2 v2080 = minus(v503, v183); + real2 v163 = ctimesminusplus(reverse(v153), tbl[6 + tbloffset], ctimes(v153, tbl[7 + tbloffset])); + real2 v303 = ctimesminusplus(reverse(v293), tbl[34 + tbloffset], ctimes(v293, tbl[35 + tbloffset])); + real2 v623 = ctimesminusplus(reverse(v613), tbl[98 + tbloffset], ctimes(v613, tbl[99 + tbloffset])); + real2 v2039 = reverse(minus(v623, v303)); + real2 v2045 = plus(v303, v623); + real2 v463 = ctimesminusplus(reverse(v453), tbl[66 + tbloffset], ctimes(v453, tbl[67 + tbloffset])); + real2 v2044 = plus(v143, v463); + real2 v2040 = minus(v463, v143); + real2 v2204 = plus(v2044, v2045); + real2 v2200 = minus(v2045, v2044); + real2 v323 = ctimesminusplus(reverse(v313), tbl[38 + tbloffset], ctimes(v313, tbl[39 + tbloffset])); + real2 v2205 = plus(v2124, v2125); + real2 v2199 = reverse(minus(v2125, v2124)); + real2 v2280 = minus(v2205, v2204); + real2 v2284 = plus(v2204, v2205); + real2 v2225 = plus(v2144, v2145); + real2 v2219 = reverse(minus(v2145, v2144)); + real2 v2305 = plus(v2264, v2265); + real2 v2299 = reverse(minus(v2265, v2264)); + real2 v2240 = minus(v2085, v2084); + real2 v2244 = plus(v2084, v2085); + real2 v2279 = reverse(minus(v2245, v2244)); + real2 v2285 = plus(v2244, v2245); + real2 v2281 = minusplus(v2279, v2280); + real2 v2283 = minusplus(uminus(v2279), v2280); + real2 v2291 = ctimesminusplus(reverse(v2281), tbl[406 + tbloffset], ctimes(v2281, tbl[407 + tbloffset])); + real2 v483 = ctimesminusplus(reverse(v473), tbl[70 + tbloffset], ctimes(v473, tbl[71 + tbloffset])); + real2 v2060 = minus(v483, v163); + real2 v2064 = plus(v163, v483); + real2 v2065 = plus(v323, v643); + real2 v2059 = reverse(minus(v643, v323)); + real2 v2220 = minus(v2065, v2064); + real2 v2224 = plus(v2064, v2065); + real2 v2304 = plus(v2224, v2225); + real2 v2300 = minus(v2225, v2224); + real2 v2301 = minusplus(v2299, v2300); + real2 v2303 = minusplus(uminus(v2299), v2300); + real2 v2311 = ctimesminusplus(reverse(v2301), tbl[410 + tbloffset], ctimes(v2301, tbl[411 + tbloffset])); + store(out, 17 << outShift, plus(v2291, v2311)); + real2 v2344 = minus(v2291, v2311); + store(out, 81 << outShift, ctimesminusplus(v2344, tbl[0 + tbloffset], ctimes(reverse(v2344), tbl[1 + tbloffset]))); + real2 v2297 = ctimesminusplus(reverse(v2283), tbl[408 + tbloffset], ctimes(v2283, tbl[409 + tbloffset])); + real2 v2317 = ctimesminusplus(reverse(v2303), tbl[412 + tbloffset], ctimes(v2303, tbl[413 + tbloffset])); + store(out, 49 << outShift, plus(v2297, v2317)); + real2 v2350 = minus(v2297, v2317); + store(out, 113 << outShift, ctimesminusplus(v2350, tbl[0 + tbloffset], ctimes(reverse(v2350), tbl[1 + tbloffset]))); + real2 v2320 = minus(v2285, v2284); + real2 v2324 = plus(v2284, v2285); + real2 v2325 = plus(v2304, v2305); + real2 v2319 = reverse(minus(v2305, v2304)); + store(out, 1 << outShift, plus(v2324, v2325)); + real2 v2338 = minus(v2324, v2325); + store(out, 65 << outShift, ctimesminusplus(v2338, tbl[0 + tbloffset], ctimes(reverse(v2338), tbl[1 + tbloffset]))); + real2 v2321 = minusplus(v2319, v2320); + store(out, 33 << outShift, ctimesminusplus(reverse(v2321), tbl[414 + tbloffset], ctimes(v2321, tbl[415 + tbloffset]))); + real2 v2323 = minusplus(uminus(v2319), v2320); + store(out, 97 << outShift, ctimesminusplus(reverse(v2323), tbl[416 + tbloffset], ctimes(v2323, tbl[417 + tbloffset]))); + real2 v2201 = minusplus(v2199, v2200); + real2 v2203 = minusplus(uminus(v2199), v2200); + real2 v2263 = minusplus(uminus(v2259), v2260); + real2 v2261 = minusplus(v2259, v2260); + real2 v2243 = minusplus(uminus(v2239), v2240); + real2 v2241 = minusplus(v2239, v2240); + real2 v2257 = ctimesminusplus(reverse(v2243), tbl[400 + tbloffset], ctimes(v2243, tbl[401 + tbloffset])); + real2 v2217 = ctimesminusplus(reverse(v2203), tbl[392 + tbloffset], ctimes(v2203, tbl[393 + tbloffset])); + real2 v2388 = plus(v2217, v2257); + real2 v2384 = minus(v2257, v2217); + real2 v2277 = ctimesminusplus(reverse(v2263), tbl[404 + tbloffset], ctimes(v2263, tbl[405 + tbloffset])); + real2 v2221 = minusplus(v2219, v2220); + real2 v2223 = minusplus(uminus(v2219), v2220); + real2 v2237 = ctimesminusplus(reverse(v2223), tbl[396 + tbloffset], ctimes(v2223, tbl[397 + tbloffset])); + real2 v2389 = plus(v2237, v2277); + real2 v2383 = reverse(minus(v2277, v2237)); + store(out, 25 << outShift, plus(v2388, v2389)); + real2 v2402 = minus(v2388, v2389); + store(out, 89 << outShift, ctimesminusplus(v2402, tbl[0 + tbloffset], ctimes(reverse(v2402), tbl[1 + tbloffset]))); + real2 v2385 = minusplus(v2383, v2384); + real2 v2387 = minusplus(uminus(v2383), v2384); + store(out, 121 << outShift, ctimesminusplus(reverse(v2387), tbl[424 + tbloffset], ctimes(v2387, tbl[425 + tbloffset]))); + store(out, 57 << outShift, ctimesminusplus(reverse(v2385), tbl[422 + tbloffset], ctimes(v2385, tbl[423 + tbloffset]))); + real2 v2251 = ctimesminusplus(reverse(v2241), tbl[398 + tbloffset], ctimes(v2241, tbl[399 + tbloffset])); + real2 v2211 = ctimesminusplus(reverse(v2201), tbl[390 + tbloffset], ctimes(v2201, tbl[391 + tbloffset])); + real2 v2358 = minus(v2251, v2211); + real2 v2362 = plus(v2211, v2251); + real2 v2271 = ctimesminusplus(reverse(v2261), tbl[402 + tbloffset], ctimes(v2261, tbl[403 + tbloffset])); + real2 v2231 = ctimesminusplus(reverse(v2221), tbl[394 + tbloffset], ctimes(v2221, tbl[395 + tbloffset])); + real2 v2357 = reverse(minus(v2271, v2231)); + real2 v2363 = plus(v2231, v2271); + store(out, 9 << outShift, plus(v2362, v2363)); + real2 v2376 = minus(v2362, v2363); + store(out, 73 << outShift, ctimesminusplus(v2376, tbl[0 + tbloffset], ctimes(reverse(v2376), tbl[1 + tbloffset]))); + real2 v2361 = minusplus(uminus(v2357), v2358); + store(out, 105 << outShift, ctimesminusplus(reverse(v2361), tbl[420 + tbloffset], ctimes(v2361, tbl[421 + tbloffset]))); + real2 v2359 = minusplus(v2357, v2358); + store(out, 41 << outShift, ctimesminusplus(reverse(v2359), tbl[418 + tbloffset], ctimes(v2359, tbl[419 + tbloffset]))); + real2 v2121 = minusplus(v2119, v2120); + real2 v2123 = minusplus(uminus(v2119), v2120); + real2 v2083 = minusplus(uminus(v2079), v2080); + real2 v2081 = minusplus(v2079, v2080); + real2 v2091 = ctimesminusplus(reverse(v2081), tbl[366 + tbloffset], ctimes(v2081, tbl[367 + tbloffset])); + real2 v2043 = minusplus(uminus(v2039), v2040); + real2 v2041 = minusplus(v2039, v2040); + real2 v2051 = ctimesminusplus(reverse(v2041), tbl[358 + tbloffset], ctimes(v2041, tbl[359 + tbloffset])); + real2 v2131 = ctimesminusplus(reverse(v2121), tbl[374 + tbloffset], ctimes(v2121, tbl[375 + tbloffset])); + real2 v2163 = minusplus(uminus(v2159), v2160); + real2 v2161 = minusplus(v2159, v2160); + real2 v2171 = ctimesminusplus(reverse(v2161), tbl[382 + tbloffset], ctimes(v2161, tbl[383 + tbloffset])); + real2 v2409 = reverse(minus(v2171, v2091)); + real2 v2415 = plus(v2091, v2171); + real2 v2410 = minus(v2131, v2051); + real2 v2414 = plus(v2051, v2131); + real2 v2454 = plus(v2414, v2415); + real2 v2450 = minus(v2415, v2414); + real2 v2181 = minusplus(v2179, v2180); + real2 v2183 = minusplus(uminus(v2179), v2180); + real2 v2191 = ctimesminusplus(reverse(v2181), tbl[386 + tbloffset], ctimes(v2181, tbl[387 + tbloffset])); + real2 v2103 = minusplus(uminus(v2099), v2100); + real2 v2101 = minusplus(v2099, v2100); + real2 v2111 = ctimesminusplus(reverse(v2101), tbl[370 + tbloffset], ctimes(v2101, tbl[371 + tbloffset])); + real2 v2435 = plus(v2111, v2191); + real2 v2429 = reverse(minus(v2191, v2111)); + real2 v2141 = minusplus(v2139, v2140); + real2 v2143 = minusplus(uminus(v2139), v2140); + real2 v2151 = ctimesminusplus(reverse(v2141), tbl[378 + tbloffset], ctimes(v2141, tbl[379 + tbloffset])); + real2 v2063 = minusplus(uminus(v2059), v2060); + real2 v2061 = minusplus(v2059, v2060); + real2 v2071 = ctimesminusplus(reverse(v2061), tbl[362 + tbloffset], ctimes(v2061, tbl[363 + tbloffset])); + real2 v2434 = plus(v2071, v2151); + real2 v2430 = minus(v2151, v2071); + real2 v2455 = plus(v2434, v2435); + real2 v2449 = reverse(minus(v2435, v2434)); + store(out, 5 << outShift, plus(v2454, v2455)); + real2 v2468 = minus(v2454, v2455); + store(out, 69 << outShift, ctimesminusplus(v2468, tbl[0 + tbloffset], ctimes(reverse(v2468), tbl[1 + tbloffset]))); + real2 v2451 = minusplus(v2449, v2450); + real2 v2453 = minusplus(uminus(v2449), v2450); + store(out, 101 << outShift, ctimesminusplus(reverse(v2453), tbl[436 + tbloffset], ctimes(v2453, tbl[437 + tbloffset]))); + store(out, 37 << outShift, ctimesminusplus(reverse(v2451), tbl[434 + tbloffset], ctimes(v2451, tbl[435 + tbloffset]))); + real2 v2411 = minusplus(v2409, v2410); + real2 v2413 = minusplus(uminus(v2409), v2410); + real2 v2433 = minusplus(uminus(v2429), v2430); + real2 v2431 = minusplus(v2429, v2430); + real2 v2421 = ctimesminusplus(reverse(v2411), tbl[426 + tbloffset], ctimes(v2411, tbl[427 + tbloffset])); + real2 v2441 = ctimesminusplus(reverse(v2431), tbl[430 + tbloffset], ctimes(v2431, tbl[431 + tbloffset])); + store(out, 21 << outShift, plus(v2421, v2441)); + real2 v2474 = minus(v2421, v2441); + store(out, 85 << outShift, ctimesminusplus(v2474, tbl[0 + tbloffset], ctimes(reverse(v2474), tbl[1 + tbloffset]))); + real2 v2427 = ctimesminusplus(reverse(v2413), tbl[428 + tbloffset], ctimes(v2413, tbl[429 + tbloffset])); + real2 v2447 = ctimesminusplus(reverse(v2433), tbl[432 + tbloffset], ctimes(v2433, tbl[433 + tbloffset])); + store(out, 53 << outShift, plus(v2427, v2447)); + real2 v2480 = minus(v2427, v2447); + store(out, 117 << outShift, ctimesminusplus(v2480, tbl[0 + tbloffset], ctimes(reverse(v2480), tbl[1 + tbloffset]))); + real2 v2057 = ctimesminusplus(reverse(v2043), tbl[360 + tbloffset], ctimes(v2043, tbl[361 + tbloffset])); + real2 v2097 = ctimesminusplus(reverse(v2083), tbl[368 + tbloffset], ctimes(v2083, tbl[369 + tbloffset])); + real2 v2157 = ctimesminusplus(reverse(v2143), tbl[380 + tbloffset], ctimes(v2143, tbl[381 + tbloffset])); + real2 v2197 = ctimesminusplus(reverse(v2183), tbl[388 + tbloffset], ctimes(v2183, tbl[389 + tbloffset])); + real2 v2117 = ctimesminusplus(reverse(v2103), tbl[372 + tbloffset], ctimes(v2103, tbl[373 + tbloffset])); + real2 v2507 = reverse(minus(v2197, v2117)); + real2 v2513 = plus(v2117, v2197); + real2 v2137 = ctimesminusplus(reverse(v2123), tbl[376 + tbloffset], ctimes(v2123, tbl[377 + tbloffset])); + real2 v2488 = minus(v2137, v2057); + real2 v2492 = plus(v2057, v2137); + real2 v2177 = ctimesminusplus(reverse(v2163), tbl[384 + tbloffset], ctimes(v2163, tbl[385 + tbloffset])); + real2 v2493 = plus(v2097, v2177); + real2 v2487 = reverse(minus(v2177, v2097)); + real2 v2532 = plus(v2492, v2493); + real2 v2528 = minus(v2493, v2492); + real2 v2077 = ctimesminusplus(reverse(v2063), tbl[364 + tbloffset], ctimes(v2063, tbl[365 + tbloffset])); + real2 v2512 = plus(v2077, v2157); + real2 v2508 = minus(v2157, v2077); + real2 v2527 = reverse(minus(v2513, v2512)); + real2 v2533 = plus(v2512, v2513); + real2 v2529 = minusplus(v2527, v2528); + real2 v2531 = minusplus(uminus(v2527), v2528); + store(out, 109 << outShift, ctimesminusplus(reverse(v2531), tbl[448 + tbloffset], ctimes(v2531, tbl[449 + tbloffset]))); + store(out, 45 << outShift, ctimesminusplus(reverse(v2529), tbl[446 + tbloffset], ctimes(v2529, tbl[447 + tbloffset]))); + store(out, 13 << outShift, plus(v2532, v2533)); + real2 v2546 = minus(v2532, v2533); + store(out, 77 << outShift, ctimesminusplus(v2546, tbl[0 + tbloffset], ctimes(reverse(v2546), tbl[1 + tbloffset]))); + real2 v2509 = minusplus(v2507, v2508); + real2 v2511 = minusplus(uminus(v2507), v2508); + real2 v2491 = minusplus(uminus(v2487), v2488); + real2 v2489 = minusplus(v2487, v2488); + real2 v2499 = ctimesminusplus(reverse(v2489), tbl[438 + tbloffset], ctimes(v2489, tbl[439 + tbloffset])); + real2 v2519 = ctimesminusplus(reverse(v2509), tbl[442 + tbloffset], ctimes(v2509, tbl[443 + tbloffset])); + store(out, 29 << outShift, plus(v2499, v2519)); + real2 v2552 = minus(v2499, v2519); + store(out, 93 << outShift, ctimesminusplus(v2552, tbl[0 + tbloffset], ctimes(reverse(v2552), tbl[1 + tbloffset]))); + real2 v2505 = ctimesminusplus(reverse(v2491), tbl[440 + tbloffset], ctimes(v2491, tbl[441 + tbloffset])); + real2 v2525 = ctimesminusplus(reverse(v2511), tbl[444 + tbloffset], ctimes(v2511, tbl[445 + tbloffset])); + store(out, 61 << outShift, plus(v2505, v2525)); + real2 v2558 = minus(v2505, v2525); + store(out, 125 << outShift, ctimesminusplus(v2558, tbl[0 + tbloffset], ctimes(reverse(v2558), tbl[1 + tbloffset]))); +// Pres : 76263 + } +} + +ALIGNED(8192) void tbut128f_%CONFIG%_%ISA%(real *RESTRICT out0, uint32_t *q, const real *RESTRICT in0, const int inShift, const real *RESTRICT tbl, const int K) { + const int k = 1 << (inShift - LOG2VECWIDTH); + int i=0; +#pragma omp parallel for + for(i=0;i < k;i++) { + int i0 = i << LOG2VECWIDTH; + real *out = out0 + q[i]; + const real *in = in0 + i0*2; + const int tbloffset = K * i0; + +// Pres : 148586 + real2 v56 = load(in, 54 << inShift); + real2 v120 = load(in, 118 << inShift); + real2 v571 = reverse(minus(v56, v120)); + real2 v577 = plus(v56, v120); + real2 v24 = load(in, 22 << inShift); + real2 v88 = load(in, 86 << inShift); + real2 v576 = plus(v24, v88); + real2 v572 = minus(v88, v24); + real2 v573 = minusplus(v571, v572); + real2 v575 = minusplus(uminus(v571), v572); + real2 v589 = timesminusplus(reverse(v575), load(tbl, 92 * VECWIDTH + tbloffset), times(v575, load(tbl, 93 * VECWIDTH + tbloffset))); + real2 v583 = timesminusplus(reverse(v573), load(tbl, 90 * VECWIDTH + tbloffset), times(v573, load(tbl, 91 * VECWIDTH + tbloffset))); + real2 v897 = plus(v576, v577); + real2 v891 = reverse(minus(v576, v577)); + real2 v8 = load(in, 6 << inShift); + real2 v72 = load(in, 70 << inShift); + real2 v252 = minus(v72, v8); + real2 v256 = plus(v8, v72); + real2 v104 = load(in, 102 << inShift); + real2 v40 = load(in, 38 << inShift); + real2 v251 = reverse(minus(v40, v104)); + real2 v257 = plus(v40, v104); + real2 v255 = minusplus(uminus(v251), v252); + real2 v253 = minusplus(v251, v252); + real2 v263 = timesminusplus(reverse(v253), load(tbl, 26 * VECWIDTH + tbloffset), times(v253, load(tbl, 27 * VECWIDTH + tbloffset))); + real2 v896 = plus(v256, v257); + real2 v892 = minus(v257, v256); + real2 v895 = minusplus(uminus(v891), v892); + real2 v893 = minusplus(v891, v892); + real2 v909 = timesminusplus(reverse(v895), load(tbl, 156 * VECWIDTH + tbloffset), times(v895, load(tbl, 157 * VECWIDTH + tbloffset))); + real2 v903 = timesminusplus(reverse(v893), load(tbl, 154 * VECWIDTH + tbloffset), times(v893, load(tbl, 155 * VECWIDTH + tbloffset))); + real2 v269 = timesminusplus(reverse(v255), load(tbl, 28 * VECWIDTH + tbloffset), times(v255, load(tbl, 29 * VECWIDTH + tbloffset))); + real2 v1216 = plus(v896, v897); + real2 v1212 = minus(v897, v896); + real2 v2160 = minus(v583, v263); + real2 v2164 = plus(v263, v583); + real2 v2686 = minus(v589, v269); + real2 v2690 = plus(v269, v589); + real2 v96 = load(in, 94 << inShift); + real2 v32 = load(in, 30 << inShift); + real2 v736 = plus(v32, v96); + real2 v732 = minus(v96, v32); + real2 v64 = load(in, 62 << inShift); + real2 v128 = load(in, 126 << inShift); + real2 v737 = plus(v64, v128); + real2 v731 = reverse(minus(v64, v128)); + real2 v1057 = plus(v736, v737); + real2 v1051 = reverse(minus(v736, v737)); + real2 v733 = minusplus(v731, v732); + real2 v735 = minusplus(uminus(v731), v732); + real2 v749 = timesminusplus(reverse(v735), load(tbl, 124 * VECWIDTH + tbloffset), times(v735, load(tbl, 125 * VECWIDTH + tbloffset))); + real2 v743 = timesminusplus(reverse(v733), load(tbl, 122 * VECWIDTH + tbloffset), times(v733, load(tbl, 123 * VECWIDTH + tbloffset))); + real2 v16 = load(in, 14 << inShift); + real2 v80 = load(in, 78 << inShift); + real2 v412 = minus(v80, v16); + real2 v416 = plus(v16, v80); + real2 v112 = load(in, 110 << inShift); + real2 v48 = load(in, 46 << inShift); + real2 v417 = plus(v48, v112); + real2 v411 = reverse(minus(v48, v112)); + real2 v1056 = plus(v416, v417); + real2 v1052 = minus(v417, v416); + real2 v1055 = minusplus(uminus(v1051), v1052); + real2 v1053 = minusplus(v1051, v1052); + real2 v1063 = timesminusplus(reverse(v1053), load(tbl, 186 * VECWIDTH + tbloffset), times(v1053, load(tbl, 187 * VECWIDTH + tbloffset))); + real2 v1665 = plus(v903, v1063); + real2 v1659 = reverse(minus(v903, v1063)); + real2 v1069 = timesminusplus(reverse(v1055), load(tbl, 188 * VECWIDTH + tbloffset), times(v1055, load(tbl, 189 * VECWIDTH + tbloffset))); + real2 v1869 = reverse(minus(v909, v1069)); + real2 v1875 = plus(v909, v1069); + real2 v413 = minusplus(v411, v412); + real2 v415 = minusplus(uminus(v411), v412); + real2 v429 = timesminusplus(reverse(v415), load(tbl, 60 * VECWIDTH + tbloffset), times(v415, load(tbl, 61 * VECWIDTH + tbloffset))); + real2 v1217 = plus(v1056, v1057); + real2 v1211 = reverse(minus(v1056, v1057)); + real2 v1297 = plus(v1216, v1217); + real2 v1291 = reverse(minus(v1216, v1217)); + real2 v2691 = plus(v429, v749); + real2 v2685 = reverse(minus(v429, v749)); + real2 v2765 = reverse(minus(v2690, v2691)); + real2 v2771 = plus(v2690, v2691); + real2 v2689 = minusplus(uminus(v2685), v2686); + real2 v2687 = minusplus(v2685, v2686); + real2 v2703 = timesminusplus(reverse(v2689), load(tbl, 476 * VECWIDTH + tbloffset), times(v2689, load(tbl, 477 * VECWIDTH + tbloffset))); + real2 v2697 = timesminusplus(reverse(v2687), load(tbl, 474 * VECWIDTH + tbloffset), times(v2687, load(tbl, 475 * VECWIDTH + tbloffset))); + real2 v1215 = minusplus(uminus(v1211), v1212); + real2 v1213 = minusplus(v1211, v1212); + real2 v1223 = timesminusplus(reverse(v1213), load(tbl, 218 * VECWIDTH + tbloffset), times(v1213, load(tbl, 219 * VECWIDTH + tbloffset))); + real2 v1229 = timesminusplus(reverse(v1215), load(tbl, 220 * VECWIDTH + tbloffset), times(v1215, load(tbl, 221 * VECWIDTH + tbloffset))); + real2 v423 = timesminusplus(reverse(v413), load(tbl, 58 * VECWIDTH + tbloffset), times(v413, load(tbl, 59 * VECWIDTH + tbloffset))); + real2 v2165 = plus(v423, v743); + real2 v2159 = reverse(minus(v423, v743)); + real2 v2245 = plus(v2164, v2165); + real2 v2239 = reverse(minus(v2164, v2165)); + real2 v44 = load(in, 42 << inShift); + real2 v108 = load(in, 106 << inShift); + real2 v331 = reverse(minus(v44, v108)); + real2 v337 = plus(v44, v108); + real2 v76 = load(in, 74 << inShift); + real2 v12 = load(in, 10 << inShift); + real2 v336 = plus(v12, v76); + real2 v332 = minus(v76, v12); + real2 v976 = plus(v336, v337); + real2 v972 = minus(v337, v336); + real2 v335 = minusplus(uminus(v331), v332); + real2 v333 = minusplus(v331, v332); + real2 v343 = timesminusplus(reverse(v333), load(tbl, 42 * VECWIDTH + tbloffset), times(v333, load(tbl, 43 * VECWIDTH + tbloffset))); + real2 v349 = timesminusplus(reverse(v335), load(tbl, 44 * VECWIDTH + tbloffset), times(v335, load(tbl, 45 * VECWIDTH + tbloffset))); + real2 v124 = load(in, 122 << inShift); + real2 v60 = load(in, 58 << inShift); + real2 v651 = reverse(minus(v60, v124)); + real2 v657 = plus(v60, v124); + real2 v28 = load(in, 26 << inShift); + real2 v92 = load(in, 90 << inShift); + real2 v652 = minus(v92, v28); + real2 v656 = plus(v28, v92); + real2 v977 = plus(v656, v657); + real2 v971 = reverse(minus(v656, v657)); + real2 v973 = minusplus(v971, v972); + real2 v975 = minusplus(uminus(v971), v972); + real2 v983 = timesminusplus(reverse(v973), load(tbl, 170 * VECWIDTH + tbloffset), times(v973, load(tbl, 171 * VECWIDTH + tbloffset))); + real2 v1131 = reverse(minus(v976, v977)); + real2 v1137 = plus(v976, v977); + real2 v655 = minusplus(uminus(v651), v652); + real2 v653 = minusplus(v651, v652); + real2 v669 = timesminusplus(reverse(v655), load(tbl, 108 * VECWIDTH + tbloffset), times(v655, load(tbl, 109 * VECWIDTH + tbloffset))); + real2 v663 = timesminusplus(reverse(v653), load(tbl, 106 * VECWIDTH + tbloffset), times(v653, load(tbl, 107 * VECWIDTH + tbloffset))); + real2 v2079 = reverse(minus(v343, v663)); + real2 v2085 = plus(v343, v663); + real2 v2605 = reverse(minus(v349, v669)); + real2 v2611 = plus(v349, v669); + real2 v989 = timesminusplus(reverse(v975), load(tbl, 172 * VECWIDTH + tbloffset), times(v975, load(tbl, 173 * VECWIDTH + tbloffset))); + real2 v20 = load(in, 18 << inShift); + real2 v84 = load(in, 82 << inShift); + real2 v496 = plus(v20, v84); + real2 v492 = minus(v84, v20); + real2 v52 = load(in, 50 << inShift); + real2 v116 = load(in, 114 << inShift); + real2 v491 = reverse(minus(v52, v116)); + real2 v497 = plus(v52, v116); + real2 v817 = plus(v496, v497); + real2 v811 = reverse(minus(v496, v497)); + real2 v493 = minusplus(v491, v492); + real2 v495 = minusplus(uminus(v491), v492); + real2 v509 = timesminusplus(reverse(v495), load(tbl, 76 * VECWIDTH + tbloffset), times(v495, load(tbl, 77 * VECWIDTH + tbloffset))); + real2 v503 = timesminusplus(reverse(v493), load(tbl, 74 * VECWIDTH + tbloffset), times(v493, load(tbl, 75 * VECWIDTH + tbloffset))); + real2 v36 = load(in, 34 << inShift); + real2 v100 = load(in, 98 << inShift); + real2 v171 = reverse(minus(v36, v100)); + real2 v177 = plus(v36, v100); + real2 v68 = load(in, 66 << inShift); + real2 v4 = load(in, 2 << inShift); + real2 v176 = plus(v4, v68); + real2 v172 = minus(v68, v4); + real2 v816 = plus(v176, v177); + real2 v812 = minus(v177, v176); + real2 v1136 = plus(v816, v817); + real2 v1132 = minus(v817, v816); + real2 v1133 = minusplus(v1131, v1132); + real2 v1135 = minusplus(uminus(v1131), v1132); + real2 v1149 = timesminusplus(reverse(v1135), load(tbl, 204 * VECWIDTH + tbloffset), times(v1135, load(tbl, 205 * VECWIDTH + tbloffset))); + real2 v1296 = plus(v1136, v1137); + real2 v1292 = minus(v1137, v1136); + real2 v1295 = minusplus(uminus(v1291), v1292); + real2 v1293 = minusplus(v1291, v1292); + real2 v1303 = timesminusplus(reverse(v1293), load(tbl, 234 * VECWIDTH + tbloffset), times(v1293, load(tbl, 235 * VECWIDTH + tbloffset))); + real2 v1331 = reverse(minus(v1296, v1297)); + real2 v1337 = plus(v1296, v1297); + real2 v173 = minusplus(v171, v172); + real2 v175 = minusplus(uminus(v171), v172); + real2 v189 = timesminusplus(reverse(v175), load(tbl, 12 * VECWIDTH + tbloffset), times(v175, load(tbl, 13 * VECWIDTH + tbloffset))); + real2 v1309 = timesminusplus(reverse(v1295), load(tbl, 236 * VECWIDTH + tbloffset), times(v1295, load(tbl, 237 * VECWIDTH + tbloffset))); + real2 v815 = minusplus(uminus(v811), v812); + real2 v813 = minusplus(v811, v812); + real2 v1143 = timesminusplus(reverse(v1133), load(tbl, 202 * VECWIDTH + tbloffset), times(v1133, load(tbl, 203 * VECWIDTH + tbloffset))); + real2 v1541 = reverse(minus(v1149, v1229)); + real2 v1547 = plus(v1149, v1229); + real2 v2610 = plus(v189, v509); + real2 v2606 = minus(v509, v189); + real2 v2770 = plus(v2610, v2611); + real2 v2766 = minus(v2611, v2610); + real2 v823 = timesminusplus(reverse(v813), load(tbl, 138 * VECWIDTH + tbloffset), times(v813, load(tbl, 139 * VECWIDTH + tbloffset))); + real2 v829 = timesminusplus(reverse(v815), load(tbl, 140 * VECWIDTH + tbloffset), times(v815, load(tbl, 141 * VECWIDTH + tbloffset))); + real2 v2811 = plus(v2770, v2771); + real2 v2805 = reverse(minus(v2770, v2771)); + real2 v2767 = minusplus(v2765, v2766); + real2 v2769 = minusplus(uminus(v2765), v2766); + real2 v2607 = minusplus(v2605, v2606); + real2 v2609 = minusplus(uminus(v2605), v2606); + real2 v2617 = timesminusplus(reverse(v2607), load(tbl, 458 * VECWIDTH + tbloffset), times(v2607, load(tbl, 459 * VECWIDTH + tbloffset))); + real2 v2623 = timesminusplus(reverse(v2609), load(tbl, 460 * VECWIDTH + tbloffset), times(v2609, load(tbl, 461 * VECWIDTH + tbloffset))); + real2 v3013 = reverse(minus(v2623, v2703)); + real2 v3019 = plus(v2623, v2703); + real2 v2783 = timesminusplus(reverse(v2769), load(tbl, 492 * VECWIDTH + tbloffset), times(v2769, load(tbl, 493 * VECWIDTH + tbloffset))); + real2 v2941 = plus(v2617, v2697); + real2 v2935 = reverse(minus(v2617, v2697)); + real2 v2777 = timesminusplus(reverse(v2767), load(tbl, 490 * VECWIDTH + tbloffset), times(v2767, load(tbl, 491 * VECWIDTH + tbloffset))); + real2 v1660 = minus(v983, v823); + real2 v1664 = plus(v823, v983); + real2 v1874 = plus(v829, v989); + real2 v1870 = minus(v989, v829); + real2 v1909 = reverse(minus(v1874, v1875)); + real2 v1915 = plus(v1874, v1875); + real2 v1663 = minusplus(uminus(v1659), v1660); + real2 v1661 = minusplus(v1659, v1660); + real2 v1677 = timesminusplus(reverse(v1663), load(tbl, 296 * VECWIDTH + tbloffset), times(v1663, load(tbl, 297 * VECWIDTH + tbloffset))); + real2 v1873 = minusplus(uminus(v1869), v1870); + real2 v1871 = minusplus(v1869, v1870); + real2 v1887 = timesminusplus(reverse(v1873), load(tbl, 332 * VECWIDTH + tbloffset), times(v1873, load(tbl, 333 * VECWIDTH + tbloffset))); + real2 v1705 = plus(v1664, v1665); + real2 v1699 = reverse(minus(v1664, v1665)); + real2 v1671 = timesminusplus(reverse(v1661), load(tbl, 294 * VECWIDTH + tbloffset), times(v1661, load(tbl, 295 * VECWIDTH + tbloffset))); + real2 v1881 = timesminusplus(reverse(v1871), load(tbl, 330 * VECWIDTH + tbloffset), times(v1871, load(tbl, 331 * VECWIDTH + tbloffset))); + real2 v1469 = plus(v1143, v1223); + real2 v1463 = reverse(minus(v1143, v1223)); + real2 v54 = load(in, 52 << inShift); + real2 v118 = load(in, 116 << inShift); + real2 v537 = plus(v54, v118); + real2 v531 = reverse(minus(v54, v118)); + real2 v86 = load(in, 84 << inShift); + real2 v22 = load(in, 20 << inShift); + real2 v536 = plus(v22, v86); + real2 v532 = minus(v86, v22); + real2 v851 = reverse(minus(v536, v537)); + real2 v857 = plus(v536, v537); + real2 v533 = minusplus(v531, v532); + real2 v535 = minusplus(uminus(v531), v532); + real2 v549 = timesminusplus(reverse(v535), load(tbl, 84 * VECWIDTH + tbloffset), times(v535, load(tbl, 85 * VECWIDTH + tbloffset))); + real2 v102 = load(in, 100 << inShift); + real2 v38 = load(in, 36 << inShift); + real2 v217 = plus(v38, v102); + real2 v211 = reverse(minus(v38, v102)); + real2 v70 = load(in, 68 << inShift); + real2 v6 = load(in, 4 << inShift); + real2 v216 = plus(v6, v70); + real2 v212 = minus(v70, v6); + real2 v213 = minusplus(v211, v212); + real2 v215 = minusplus(uminus(v211), v212); + real2 v229 = timesminusplus(reverse(v215), load(tbl, 20 * VECWIDTH + tbloffset), times(v215, load(tbl, 21 * VECWIDTH + tbloffset))); + real2 v2646 = minus(v549, v229); + real2 v2650 = plus(v229, v549); + real2 v856 = plus(v216, v217); + real2 v852 = minus(v217, v216); + real2 v853 = minusplus(v851, v852); + real2 v855 = minusplus(uminus(v851), v852); + real2 v863 = timesminusplus(reverse(v853), load(tbl, 146 * VECWIDTH + tbloffset), times(v853, load(tbl, 147 * VECWIDTH + tbloffset))); + real2 v869 = timesminusplus(reverse(v855), load(tbl, 148 * VECWIDTH + tbloffset), times(v855, load(tbl, 149 * VECWIDTH + tbloffset))); + real2 v1176 = plus(v856, v857); + real2 v1172 = minus(v857, v856); + real2 v110 = load(in, 108 << inShift); + real2 v46 = load(in, 44 << inShift); + real2 v377 = plus(v46, v110); + real2 v371 = reverse(minus(v46, v110)); + real2 v78 = load(in, 76 << inShift); + real2 v14 = load(in, 12 << inShift); + real2 v372 = minus(v78, v14); + real2 v376 = plus(v14, v78); + real2 v1012 = minus(v377, v376); + real2 v1016 = plus(v376, v377); + real2 v373 = minusplus(v371, v372); + real2 v375 = minusplus(uminus(v371), v372); + real2 v389 = timesminusplus(reverse(v375), load(tbl, 52 * VECWIDTH + tbloffset), times(v375, load(tbl, 53 * VECWIDTH + tbloffset))); + real2 v30 = load(in, 28 << inShift); + real2 v94 = load(in, 92 << inShift); + real2 v696 = plus(v30, v94); + real2 v692 = minus(v94, v30); + real2 v62 = load(in, 60 << inShift); + real2 v126 = load(in, 124 << inShift); + real2 v697 = plus(v62, v126); + real2 v691 = reverse(minus(v62, v126)); + real2 v1017 = plus(v696, v697); + real2 v1011 = reverse(minus(v696, v697)); + real2 v1171 = reverse(minus(v1016, v1017)); + real2 v1177 = plus(v1016, v1017); + real2 v1013 = minusplus(v1011, v1012); + real2 v1015 = minusplus(uminus(v1011), v1012); + real2 v1175 = minusplus(uminus(v1171), v1172); + real2 v1173 = minusplus(v1171, v1172); + real2 v1183 = timesminusplus(reverse(v1173), load(tbl, 210 * VECWIDTH + tbloffset), times(v1173, load(tbl, 211 * VECWIDTH + tbloffset))); + real2 v1189 = timesminusplus(reverse(v1175), load(tbl, 212 * VECWIDTH + tbloffset), times(v1175, load(tbl, 213 * VECWIDTH + tbloffset))); + real2 v1029 = timesminusplus(reverse(v1015), load(tbl, 180 * VECWIDTH + tbloffset), times(v1015, load(tbl, 181 * VECWIDTH + tbloffset))); + real2 v1023 = timesminusplus(reverse(v1013), load(tbl, 178 * VECWIDTH + tbloffset), times(v1013, load(tbl, 179 * VECWIDTH + tbloffset))); + real2 v1625 = plus(v863, v1023); + real2 v1619 = reverse(minus(v863, v1023)); + real2 v1835 = plus(v869, v1029); + real2 v1829 = reverse(minus(v869, v1029)); + real2 v693 = minusplus(v691, v692); + real2 v695 = minusplus(uminus(v691), v692); + real2 v709 = timesminusplus(reverse(v695), load(tbl, 116 * VECWIDTH + tbloffset), times(v695, load(tbl, 117 * VECWIDTH + tbloffset))); + real2 v2645 = reverse(minus(v389, v709)); + real2 v2651 = plus(v389, v709); + real2 v1257 = plus(v1176, v1177); + real2 v1251 = reverse(minus(v1176, v1177)); + real2 v2731 = plus(v2650, v2651); + real2 v2725 = reverse(minus(v2650, v2651)); + real2 v114 = load(in, 112 << inShift); + real2 v50 = load(in, 48 << inShift); + real2 v457 = plus(v50, v114); + real2 v451 = reverse(minus(v50, v114)); + real2 v18 = load(in, 16 << inShift); + real2 v82 = load(in, 80 << inShift); + real2 v456 = plus(v18, v82); + real2 v452 = minus(v82, v18); + real2 v771 = reverse(minus(v456, v457)); + real2 v777 = plus(v456, v457); + real2 v453 = minusplus(v451, v452); + real2 v455 = minusplus(uminus(v451), v452); + real2 v469 = timesminusplus(reverse(v455), load(tbl, 68 * VECWIDTH + tbloffset), times(v455, load(tbl, 69 * VECWIDTH + tbloffset))); + real2 v66 = load(in, 64 << inShift); + real2 v2 = load(in, 0 << inShift); + real2 v132 = minus(v66, v2); + real2 v136 = plus(v2, v66); + real2 v98 = load(in, 96 << inShift); + real2 v34 = load(in, 32 << inShift); + real2 v131 = reverse(minus(v34, v98)); + real2 v137 = plus(v34, v98); + real2 v133 = minusplus(v131, v132); + real2 v135 = minusplus(uminus(v131), v132); + real2 v149 = timesminusplus(reverse(v135), load(tbl, 4 * VECWIDTH + tbloffset), times(v135, load(tbl, 5 * VECWIDTH + tbloffset))); + real2 v2566 = minus(v469, v149); + real2 v2570 = plus(v149, v469); + real2 v772 = minus(v137, v136); + real2 v776 = plus(v136, v137); + real2 v1092 = minus(v777, v776); + real2 v1096 = plus(v776, v777); + real2 v773 = minusplus(v771, v772); + real2 v775 = minusplus(uminus(v771), v772); + real2 v783 = timesminusplus(reverse(v773), load(tbl, 130 * VECWIDTH + tbloffset), times(v773, load(tbl, 131 * VECWIDTH + tbloffset))); + real2 v789 = timesminusplus(reverse(v775), load(tbl, 132 * VECWIDTH + tbloffset), times(v775, load(tbl, 133 * VECWIDTH + tbloffset))); + real2 v74 = load(in, 72 << inShift); + real2 v10 = load(in, 8 << inShift); + real2 v296 = plus(v10, v74); + real2 v292 = minus(v74, v10); + real2 v42 = load(in, 40 << inShift); + real2 v106 = load(in, 104 << inShift); + real2 v291 = reverse(minus(v42, v106)); + real2 v297 = plus(v42, v106); + real2 v293 = minusplus(v291, v292); + real2 v295 = minusplus(uminus(v291), v292); + real2 v309 = timesminusplus(reverse(v295), load(tbl, 36 * VECWIDTH + tbloffset), times(v295, load(tbl, 37 * VECWIDTH + tbloffset))); + real2 v932 = minus(v297, v296); + real2 v936 = plus(v296, v297); + real2 v122 = load(in, 120 << inShift); + real2 v58 = load(in, 56 << inShift); + real2 v617 = plus(v58, v122); + real2 v611 = reverse(minus(v58, v122)); + real2 v26 = load(in, 24 << inShift); + real2 v90 = load(in, 88 << inShift); + real2 v612 = minus(v90, v26); + real2 v616 = plus(v26, v90); + real2 v937 = plus(v616, v617); + real2 v931 = reverse(minus(v616, v617)); + real2 v1091 = reverse(minus(v936, v937)); + real2 v1097 = plus(v936, v937); + real2 v933 = minusplus(v931, v932); + real2 v935 = minusplus(uminus(v931), v932); + real2 v1093 = minusplus(v1091, v1092); + real2 v1095 = minusplus(uminus(v1091), v1092); + real2 v1103 = timesminusplus(reverse(v1093), load(tbl, 194 * VECWIDTH + tbloffset), times(v1093, load(tbl, 195 * VECWIDTH + tbloffset))); + real2 v1468 = plus(v1103, v1183); + real2 v1464 = minus(v1183, v1103); + real2 v1508 = plus(v1468, v1469); + real2 v1504 = minus(v1469, v1468); + real2 v1252 = minus(v1097, v1096); + real2 v1256 = plus(v1096, v1097); + real2 v1336 = plus(v1256, v1257); + real2 v1332 = minus(v1257, v1256); + real2 v1335 = minusplus(uminus(v1331), v1332); + real2 v1333 = minusplus(v1331, v1332); + real2 v1343 = timesminusplus(reverse(v1333), load(tbl, 242 * VECWIDTH + tbloffset), times(v1333, load(tbl, 243 * VECWIDTH + tbloffset))); + real2 v1349 = timesminusplus(reverse(v1335), load(tbl, 244 * VECWIDTH + tbloffset), times(v1335, load(tbl, 245 * VECWIDTH + tbloffset))); + real2 v1376 = plus(v1336, v1337); + real2 v1372 = minus(v1337, v1336); + real2 v1465 = minusplus(v1463, v1464); + real2 v1467 = minusplus(uminus(v1463), v1464); + real2 v1255 = minusplus(uminus(v1251), v1252); + real2 v1253 = minusplus(v1251, v1252); + real2 v1481 = timesminusplus(reverse(v1467), load(tbl, 264 * VECWIDTH + tbloffset), times(v1467, load(tbl, 265 * VECWIDTH + tbloffset))); + real2 v1475 = timesminusplus(reverse(v1465), load(tbl, 262 * VECWIDTH + tbloffset), times(v1465, load(tbl, 263 * VECWIDTH + tbloffset))); + real2 v1109 = timesminusplus(reverse(v1095), load(tbl, 196 * VECWIDTH + tbloffset), times(v1095, load(tbl, 197 * VECWIDTH + tbloffset))); + real2 v1542 = minus(v1189, v1109); + real2 v1546 = plus(v1109, v1189); + real2 v1545 = minusplus(uminus(v1541), v1542); + real2 v1543 = minusplus(v1541, v1542); + real2 v1553 = timesminusplus(reverse(v1543), load(tbl, 274 * VECWIDTH + tbloffset), times(v1543, load(tbl, 275 * VECWIDTH + tbloffset))); + real2 v1559 = timesminusplus(reverse(v1545), load(tbl, 276 * VECWIDTH + tbloffset), times(v1545, load(tbl, 277 * VECWIDTH + tbloffset))); + real2 v1582 = minus(v1547, v1546); + real2 v1586 = plus(v1546, v1547); + real2 v1269 = timesminusplus(reverse(v1255), load(tbl, 228 * VECWIDTH + tbloffset), times(v1255, load(tbl, 229 * VECWIDTH + tbloffset))); + real2 v1438 = minus(v1309, v1269); + real2 v1442 = plus(v1269, v1309); + real2 v1263 = timesminusplus(reverse(v1253), load(tbl, 226 * VECWIDTH + tbloffset), times(v1253, load(tbl, 227 * VECWIDTH + tbloffset))); + real2 v943 = timesminusplus(reverse(v933), load(tbl, 162 * VECWIDTH + tbloffset), times(v933, load(tbl, 163 * VECWIDTH + tbloffset))); + real2 v1624 = plus(v783, v943); + real2 v1620 = minus(v943, v783); + real2 v1623 = minusplus(uminus(v1619), v1620); + real2 v1621 = minusplus(v1619, v1620); + real2 v1700 = minus(v1625, v1624); + real2 v1704 = plus(v1624, v1625); + real2 v1631 = timesminusplus(reverse(v1621), load(tbl, 286 * VECWIDTH + tbloffset), times(v1621, load(tbl, 287 * VECWIDTH + tbloffset))); + real2 v949 = timesminusplus(reverse(v935), load(tbl, 164 * VECWIDTH + tbloffset), times(v935, load(tbl, 165 * VECWIDTH + tbloffset))); + real2 v1830 = minus(v949, v789); + real2 v1834 = plus(v789, v949); + real2 v1782 = plus(v1631, v1671); + real2 v1778 = minus(v1671, v1631); + real2 v1910 = minus(v1835, v1834); + real2 v1914 = plus(v1834, v1835); + real2 v1950 = minus(v1915, v1914); + real2 v1954 = plus(v1914, v1915); + real2 v1913 = minusplus(uminus(v1909), v1910); + real2 v1911 = minusplus(v1909, v1910); + real2 v613 = minusplus(v611, v612); + real2 v615 = minusplus(uminus(v611), v612); + real2 v629 = timesminusplus(reverse(v615), load(tbl, 100 * VECWIDTH + tbloffset), times(v615, load(tbl, 101 * VECWIDTH + tbloffset))); + real2 v1744 = plus(v1704, v1705); + real2 v1740 = minus(v1705, v1704); + real2 v1637 = timesminusplus(reverse(v1623), load(tbl, 288 * VECWIDTH + tbloffset), times(v1623, load(tbl, 289 * VECWIDTH + tbloffset))); + real2 v1927 = timesminusplus(reverse(v1913), load(tbl, 340 * VECWIDTH + tbloffset), times(v1913, load(tbl, 341 * VECWIDTH + tbloffset))); + real2 v2571 = plus(v309, v629); + real2 v2565 = reverse(minus(v309, v629)); + real2 v1833 = minusplus(uminus(v1829), v1830); + real2 v1831 = minusplus(v1829, v1830); + real2 v1921 = timesminusplus(reverse(v1911), load(tbl, 338 * VECWIDTH + tbloffset), times(v1911, load(tbl, 339 * VECWIDTH + tbloffset))); + real2 v1804 = minus(v1677, v1637); + real2 v1808 = plus(v1637, v1677); + real2 v1847 = timesminusplus(reverse(v1833), load(tbl, 324 * VECWIDTH + tbloffset), times(v1833, load(tbl, 325 * VECWIDTH + tbloffset))); + real2 v2014 = minus(v1887, v1847); + real2 v2018 = plus(v1847, v1887); + real2 v1841 = timesminusplus(reverse(v1831), load(tbl, 322 * VECWIDTH + tbloffset), times(v1831, load(tbl, 323 * VECWIDTH + tbloffset))); + real2 v1988 = minus(v1881, v1841); + real2 v1992 = plus(v1841, v1881); + real2 v1703 = minusplus(uminus(v1699), v1700); + real2 v1701 = minusplus(v1699, v1700); + real2 v1717 = timesminusplus(reverse(v1703), load(tbl, 304 * VECWIDTH + tbloffset), times(v1703, load(tbl, 305 * VECWIDTH + tbloffset))); + real2 v1711 = timesminusplus(reverse(v1701), load(tbl, 302 * VECWIDTH + tbloffset), times(v1701, load(tbl, 303 * VECWIDTH + tbloffset))); + real2 v2730 = plus(v2570, v2571); + real2 v2726 = minus(v2571, v2570); + real2 v1412 = minus(v1303, v1263); + real2 v1416 = plus(v1263, v1303); + real2 v63 = load(in, 61 << inShift); + real2 v127 = load(in, 125 << inShift); + real2 v717 = plus(v63, v127); + real2 v711 = reverse(minus(v63, v127)); + real2 v95 = load(in, 93 << inShift); + real2 v31 = load(in, 29 << inShift); + real2 v712 = minus(v95, v31); + real2 v716 = plus(v31, v95); + real2 v1037 = plus(v716, v717); + real2 v1031 = reverse(minus(v716, v717)); + real2 v79 = load(in, 77 << inShift); + real2 v15 = load(in, 13 << inShift); + real2 v396 = plus(v15, v79); + real2 v392 = minus(v79, v15); + real2 v111 = load(in, 109 << inShift); + real2 v47 = load(in, 45 << inShift); + real2 v397 = plus(v47, v111); + real2 v391 = reverse(minus(v47, v111)); + real2 v1032 = minus(v397, v396); + real2 v1036 = plus(v396, v397); + real2 v1033 = minusplus(v1031, v1032); + real2 v1035 = minusplus(uminus(v1031), v1032); + real2 v1049 = timesminusplus(reverse(v1035), load(tbl, 184 * VECWIDTH + tbloffset), times(v1035, load(tbl, 185 * VECWIDTH + tbloffset))); + real2 v1043 = timesminusplus(reverse(v1033), load(tbl, 182 * VECWIDTH + tbloffset), times(v1033, load(tbl, 183 * VECWIDTH + tbloffset))); + real2 v1197 = plus(v1036, v1037); + real2 v1191 = reverse(minus(v1036, v1037)); + real2 v23 = load(in, 21 << inShift); + real2 v87 = load(in, 85 << inShift); + real2 v556 = plus(v23, v87); + real2 v552 = minus(v87, v23); + real2 v119 = load(in, 117 << inShift); + real2 v55 = load(in, 53 << inShift); + real2 v557 = plus(v55, v119); + real2 v551 = reverse(minus(v55, v119)); + real2 v877 = plus(v556, v557); + real2 v871 = reverse(minus(v556, v557)); + real2 v7 = load(in, 5 << inShift); + real2 v71 = load(in, 69 << inShift); + real2 v232 = minus(v71, v7); + real2 v236 = plus(v7, v71); + real2 v103 = load(in, 101 << inShift); + real2 v39 = load(in, 37 << inShift); + real2 v237 = plus(v39, v103); + real2 v231 = reverse(minus(v39, v103)); + real2 v876 = plus(v236, v237); + real2 v872 = minus(v237, v236); + real2 v1192 = minus(v877, v876); + real2 v1196 = plus(v876, v877); + real2 v1271 = reverse(minus(v1196, v1197)); + real2 v1277 = plus(v1196, v1197); + real2 v875 = minusplus(uminus(v871), v872); + real2 v873 = minusplus(v871, v872); + real2 v883 = timesminusplus(reverse(v873), load(tbl, 150 * VECWIDTH + tbloffset), times(v873, load(tbl, 151 * VECWIDTH + tbloffset))); + real2 v1639 = reverse(minus(v883, v1043)); + real2 v1645 = plus(v883, v1043); + real2 v1195 = minusplus(uminus(v1191), v1192); + real2 v1193 = minusplus(v1191, v1192); + real2 v1209 = timesminusplus(reverse(v1195), load(tbl, 216 * VECWIDTH + tbloffset), times(v1195, load(tbl, 217 * VECWIDTH + tbloffset))); + real2 v1203 = timesminusplus(reverse(v1193), load(tbl, 214 * VECWIDTH + tbloffset), times(v1193, load(tbl, 215 * VECWIDTH + tbloffset))); + real2 v83 = load(in, 81 << inShift); + real2 v19 = load(in, 17 << inShift); + real2 v476 = plus(v19, v83); + real2 v472 = minus(v83, v19); + real2 v51 = load(in, 49 << inShift); + real2 v115 = load(in, 113 << inShift); + real2 v477 = plus(v51, v115); + real2 v471 = reverse(minus(v51, v115)); + real2 v797 = plus(v476, v477); + real2 v791 = reverse(minus(v476, v477)); + real2 v3 = load(in, 1 << inShift); + real2 v67 = load(in, 65 << inShift); + real2 v156 = plus(v3, v67); + real2 v152 = minus(v67, v3); + real2 v35 = load(in, 33 << inShift); + real2 v99 = load(in, 97 << inShift); + real2 v157 = plus(v35, v99); + real2 v151 = reverse(minus(v35, v99)); + real2 v792 = minus(v157, v156); + real2 v796 = plus(v156, v157); + real2 v793 = minusplus(v791, v792); + real2 v795 = minusplus(uminus(v791), v792); + real2 v803 = timesminusplus(reverse(v793), load(tbl, 134 * VECWIDTH + tbloffset), times(v793, load(tbl, 135 * VECWIDTH + tbloffset))); + real2 v1112 = minus(v797, v796); + real2 v1116 = plus(v796, v797); + real2 v107 = load(in, 105 << inShift); + real2 v43 = load(in, 41 << inShift); + real2 v317 = plus(v43, v107); + real2 v311 = reverse(minus(v43, v107)); + real2 v75 = load(in, 73 << inShift); + real2 v11 = load(in, 9 << inShift); + real2 v316 = plus(v11, v75); + real2 v312 = minus(v75, v11); + real2 v956 = plus(v316, v317); + real2 v952 = minus(v317, v316); + real2 v59 = load(in, 57 << inShift); + real2 v123 = load(in, 121 << inShift); + real2 v631 = reverse(minus(v59, v123)); + real2 v637 = plus(v59, v123); + real2 v27 = load(in, 25 << inShift); + real2 v91 = load(in, 89 << inShift); + real2 v636 = plus(v27, v91); + real2 v632 = minus(v91, v27); + real2 v957 = plus(v636, v637); + real2 v951 = reverse(minus(v636, v637)); + real2 v1111 = reverse(minus(v956, v957)); + real2 v1117 = plus(v956, v957); + real2 v1276 = plus(v1116, v1117); + real2 v1272 = minus(v1117, v1116); + real2 v1275 = minusplus(uminus(v1271), v1272); + real2 v1273 = minusplus(v1271, v1272); + real2 v1283 = timesminusplus(reverse(v1273), load(tbl, 230 * VECWIDTH + tbloffset), times(v1273, load(tbl, 231 * VECWIDTH + tbloffset))); + real2 v1352 = minus(v1277, v1276); + real2 v1356 = plus(v1276, v1277); + real2 v1289 = timesminusplus(reverse(v1275), load(tbl, 232 * VECWIDTH + tbloffset), times(v1275, load(tbl, 233 * VECWIDTH + tbloffset))); + real2 v1115 = minusplus(uminus(v1111), v1112); + real2 v1113 = minusplus(v1111, v1112); + real2 v1123 = timesminusplus(reverse(v1113), load(tbl, 198 * VECWIDTH + tbloffset), times(v1113, load(tbl, 199 * VECWIDTH + tbloffset))); + real2 v1129 = timesminusplus(reverse(v1115), load(tbl, 200 * VECWIDTH + tbloffset), times(v1115, load(tbl, 201 * VECWIDTH + tbloffset))); + real2 v1488 = plus(v1123, v1203); + real2 v1484 = minus(v1203, v1123); + real2 v1566 = plus(v1129, v1209); + real2 v1562 = minus(v1209, v1129); + real2 v85 = load(in, 83 << inShift); + real2 v21 = load(in, 19 << inShift); + real2 v512 = minus(v85, v21); + real2 v516 = plus(v21, v85); + real2 v117 = load(in, 115 << inShift); + real2 v53 = load(in, 51 << inShift); + real2 v517 = plus(v53, v117); + real2 v511 = reverse(minus(v53, v117)); + real2 v831 = reverse(minus(v516, v517)); + real2 v837 = plus(v516, v517); + real2 v69 = load(in, 67 << inShift); + real2 v5 = load(in, 3 << inShift); + real2 v192 = minus(v69, v5); + real2 v196 = plus(v5, v69); + real2 v37 = load(in, 35 << inShift); + real2 v101 = load(in, 99 << inShift); + real2 v197 = plus(v37, v101); + real2 v191 = reverse(minus(v37, v101)); + real2 v832 = minus(v197, v196); + real2 v836 = plus(v196, v197); + real2 v1152 = minus(v837, v836); + real2 v1156 = plus(v836, v837); + real2 v61 = load(in, 59 << inShift); + real2 v125 = load(in, 123 << inShift); + real2 v677 = plus(v61, v125); + real2 v671 = reverse(minus(v61, v125)); + real2 v29 = load(in, 27 << inShift); + real2 v93 = load(in, 91 << inShift); + real2 v672 = minus(v93, v29); + real2 v676 = plus(v29, v93); + real2 v997 = plus(v676, v677); + real2 v991 = reverse(minus(v676, v677)); + real2 v109 = load(in, 107 << inShift); + real2 v45 = load(in, 43 << inShift); + real2 v357 = plus(v45, v109); + real2 v351 = reverse(minus(v45, v109)); + real2 v77 = load(in, 75 << inShift); + real2 v13 = load(in, 11 << inShift); + real2 v352 = minus(v77, v13); + real2 v356 = plus(v13, v77); + real2 v992 = minus(v357, v356); + real2 v996 = plus(v356, v357); + real2 v1157 = plus(v996, v997); + real2 v1151 = reverse(minus(v996, v997)); + real2 v1155 = minusplus(uminus(v1151), v1152); + real2 v1153 = minusplus(v1151, v1152); + real2 v1163 = timesminusplus(reverse(v1153), load(tbl, 206 * VECWIDTH + tbloffset), times(v1153, load(tbl, 207 * VECWIDTH + tbloffset))); + real2 v1316 = plus(v1156, v1157); + real2 v1312 = minus(v1157, v1156); + real2 v41 = load(in, 39 << inShift); + real2 v105 = load(in, 103 << inShift); + real2 v277 = plus(v41, v105); + real2 v271 = reverse(minus(v41, v105)); + real2 v9 = load(in, 7 << inShift); + real2 v73 = load(in, 71 << inShift); + real2 v276 = plus(v9, v73); + real2 v272 = minus(v73, v9); + real2 v916 = plus(v276, v277); + real2 v912 = minus(v277, v276); + real2 v89 = load(in, 87 << inShift); + real2 v25 = load(in, 23 << inShift); + real2 v592 = minus(v89, v25); + real2 v596 = plus(v25, v89); + real2 v57 = load(in, 55 << inShift); + real2 v121 = load(in, 119 << inShift); + real2 v591 = reverse(minus(v57, v121)); + real2 v597 = plus(v57, v121); + real2 v911 = reverse(minus(v596, v597)); + real2 v917 = plus(v596, v597); + real2 v1236 = plus(v916, v917); + real2 v1232 = minus(v917, v916); + real2 v81 = load(in, 79 << inShift); + real2 v17 = load(in, 15 << inShift); + real2 v432 = minus(v81, v17); + real2 v436 = plus(v17, v81); + real2 v113 = load(in, 111 << inShift); + real2 v49 = load(in, 47 << inShift); + real2 v437 = plus(v49, v113); + real2 v431 = reverse(minus(v49, v113)); + real2 v1072 = minus(v437, v436); + real2 v1076 = plus(v436, v437); + real2 v65 = load(in, 63 << inShift); + real2 v129 = load(in, 127 << inShift); + real2 v757 = plus(v65, v129); + real2 v751 = reverse(minus(v65, v129)); + real2 v97 = load(in, 95 << inShift); + real2 v33 = load(in, 31 << inShift); + real2 v752 = minus(v97, v33); + real2 v756 = plus(v33, v97); + real2 v1077 = plus(v756, v757); + real2 v1071 = reverse(minus(v756, v757)); + real2 v1231 = reverse(minus(v1076, v1077)); + real2 v1237 = plus(v1076, v1077); + real2 v1317 = plus(v1236, v1237); + real2 v1311 = reverse(minus(v1236, v1237)); + real2 v1351 = reverse(minus(v1316, v1317)); + real2 v1357 = plus(v1316, v1317); + real2 v1371 = reverse(minus(v1356, v1357)); + real2 v1377 = plus(v1356, v1357); + scatter(out, 0, 128, plus(v1376, v1377)); + real2 v1390 = minus(v1376, v1377); + scatter(out, 64, 128, timesminusplus(v1390, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v1390), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v1353 = minusplus(v1351, v1352); + real2 v1355 = minusplus(uminus(v1351), v1352); + real2 v1369 = timesminusplus(reverse(v1355), load(tbl, 248 * VECWIDTH + tbloffset), times(v1355, load(tbl, 249 * VECWIDTH + tbloffset))); + scatter(out, 48, 128, plus(v1349, v1369)); + real2 v1404 = minus(v1349, v1369); + scatter(out, 112, 128, timesminusplus(v1404, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v1404), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v1363 = timesminusplus(reverse(v1353), load(tbl, 246 * VECWIDTH + tbloffset), times(v1353, load(tbl, 247 * VECWIDTH + tbloffset))); + scatter(out, 16, 128, plus(v1343, v1363)); + real2 v1398 = minus(v1343, v1363); + scatter(out, 80, 128, timesminusplus(v1398, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v1398), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v1373 = minusplus(v1371, v1372); + real2 v1375 = minusplus(uminus(v1371), v1372); + scatter(out, 96, 128, timesminusplus(reverse(v1375), load(tbl, 252 * VECWIDTH + tbloffset), times(v1375, load(tbl, 253 * VECWIDTH + tbloffset)))); + scatter(out, 32, 128, timesminusplus(reverse(v1373), load(tbl, 250 * VECWIDTH + tbloffset), times(v1373, load(tbl, 251 * VECWIDTH + tbloffset)))); + real2 v1313 = minusplus(v1311, v1312); + real2 v1315 = minusplus(uminus(v1311), v1312); + real2 v1323 = timesminusplus(reverse(v1313), load(tbl, 238 * VECWIDTH + tbloffset), times(v1313, load(tbl, 239 * VECWIDTH + tbloffset))); + real2 v1417 = plus(v1283, v1323); + real2 v1411 = reverse(minus(v1283, v1323)); + scatter(out, 8, 128, plus(v1416, v1417)); + real2 v1430 = minus(v1416, v1417); + scatter(out, 72, 128, timesminusplus(v1430, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v1430), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v1413 = minusplus(v1411, v1412); + real2 v1415 = minusplus(uminus(v1411), v1412); + scatter(out, 104, 128, timesminusplus(reverse(v1415), load(tbl, 256 * VECWIDTH + tbloffset), times(v1415, load(tbl, 257 * VECWIDTH + tbloffset)))); + scatter(out, 40, 128, timesminusplus(reverse(v1413), load(tbl, 254 * VECWIDTH + tbloffset), times(v1413, load(tbl, 255 * VECWIDTH + tbloffset)))); + real2 v1329 = timesminusplus(reverse(v1315), load(tbl, 240 * VECWIDTH + tbloffset), times(v1315, load(tbl, 241 * VECWIDTH + tbloffset))); + real2 v1443 = plus(v1289, v1329); + real2 v1437 = reverse(minus(v1289, v1329)); + scatter(out, 24, 128, plus(v1442, v1443)); + real2 v1456 = minus(v1442, v1443); + scatter(out, 88, 128, timesminusplus(v1456, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v1456), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v1441 = minusplus(uminus(v1437), v1438); + real2 v1439 = minusplus(v1437, v1438); + scatter(out, 120, 128, timesminusplus(reverse(v1441), load(tbl, 260 * VECWIDTH + tbloffset), times(v1441, load(tbl, 261 * VECWIDTH + tbloffset)))); + scatter(out, 56, 128, timesminusplus(reverse(v1439), load(tbl, 258 * VECWIDTH + tbloffset), times(v1439, load(tbl, 259 * VECWIDTH + tbloffset)))); + real2 v1235 = minusplus(uminus(v1231), v1232); + real2 v1233 = minusplus(v1231, v1232); + real2 v1243 = timesminusplus(reverse(v1233), load(tbl, 222 * VECWIDTH + tbloffset), times(v1233, load(tbl, 223 * VECWIDTH + tbloffset))); + real2 v1489 = plus(v1163, v1243); + real2 v1483 = reverse(minus(v1163, v1243)); + real2 v1509 = plus(v1488, v1489); + real2 v1503 = reverse(minus(v1488, v1489)); + scatter(out, 4, 128, plus(v1508, v1509)); + real2 v1522 = minus(v1508, v1509); + scatter(out, 68, 128, timesminusplus(v1522, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v1522), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v1507 = minusplus(uminus(v1503), v1504); + real2 v1505 = minusplus(v1503, v1504); + scatter(out, 36, 128, timesminusplus(reverse(v1505), load(tbl, 270 * VECWIDTH + tbloffset), times(v1505, load(tbl, 271 * VECWIDTH + tbloffset)))); + scatter(out, 100, 128, timesminusplus(reverse(v1507), load(tbl, 272 * VECWIDTH + tbloffset), times(v1507, load(tbl, 273 * VECWIDTH + tbloffset)))); + real2 v1485 = minusplus(v1483, v1484); + real2 v1487 = minusplus(uminus(v1483), v1484); + real2 v1501 = timesminusplus(reverse(v1487), load(tbl, 268 * VECWIDTH + tbloffset), times(v1487, load(tbl, 269 * VECWIDTH + tbloffset))); + scatter(out, 52, 128, plus(v1481, v1501)); + real2 v1534 = minus(v1481, v1501); + scatter(out, 116, 128, timesminusplus(v1534, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v1534), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v1495 = timesminusplus(reverse(v1485), load(tbl, 266 * VECWIDTH + tbloffset), times(v1485, load(tbl, 267 * VECWIDTH + tbloffset))); + scatter(out, 20, 128, plus(v1475, v1495)); + real2 v1528 = minus(v1475, v1495); + scatter(out, 84, 128, timesminusplus(v1528, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v1528), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v1249 = timesminusplus(reverse(v1235), load(tbl, 224 * VECWIDTH + tbloffset), times(v1235, load(tbl, 225 * VECWIDTH + tbloffset))); + real2 v1169 = timesminusplus(reverse(v1155), load(tbl, 208 * VECWIDTH + tbloffset), times(v1155, load(tbl, 209 * VECWIDTH + tbloffset))); + real2 v1567 = plus(v1169, v1249); + real2 v1561 = reverse(minus(v1169, v1249)); + real2 v1581 = reverse(minus(v1566, v1567)); + real2 v1587 = plus(v1566, v1567); + scatter(out, 12, 128, plus(v1586, v1587)); + real2 v1600 = minus(v1586, v1587); + scatter(out, 76, 128, timesminusplus(v1600, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v1600), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v1583 = minusplus(v1581, v1582); + scatter(out, 44, 128, timesminusplus(reverse(v1583), load(tbl, 282 * VECWIDTH + tbloffset), times(v1583, load(tbl, 283 * VECWIDTH + tbloffset)))); + real2 v1585 = minusplus(uminus(v1581), v1582); + scatter(out, 108, 128, timesminusplus(reverse(v1585), load(tbl, 284 * VECWIDTH + tbloffset), times(v1585, load(tbl, 285 * VECWIDTH + tbloffset)))); + real2 v1565 = minusplus(uminus(v1561), v1562); + real2 v1563 = minusplus(v1561, v1562); + real2 v1579 = timesminusplus(reverse(v1565), load(tbl, 280 * VECWIDTH + tbloffset), times(v1565, load(tbl, 281 * VECWIDTH + tbloffset))); + scatter(out, 60, 128, plus(v1559, v1579)); + real2 v1612 = minus(v1559, v1579); + scatter(out, 124, 128, timesminusplus(v1612, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v1612), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v1573 = timesminusplus(reverse(v1563), load(tbl, 278 * VECWIDTH + tbloffset), times(v1563, load(tbl, 279 * VECWIDTH + tbloffset))); + scatter(out, 28, 128, plus(v1553, v1573)); + real2 v1606 = minus(v1553, v1573); + scatter(out, 92, 128, timesminusplus(v1606, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v1606), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v833 = minusplus(v831, v832); + real2 v835 = minusplus(uminus(v831), v832); + real2 v955 = minusplus(uminus(v951), v952); + real2 v953 = minusplus(v951, v952); + real2 v963 = timesminusplus(reverse(v953), load(tbl, 166 * VECWIDTH + tbloffset), times(v953, load(tbl, 167 * VECWIDTH + tbloffset))); + real2 v995 = minusplus(uminus(v991), v992); + real2 v993 = minusplus(v991, v992); + real2 v1003 = timesminusplus(reverse(v993), load(tbl, 174 * VECWIDTH + tbloffset), times(v993, load(tbl, 175 * VECWIDTH + tbloffset))); + real2 v843 = timesminusplus(reverse(v833), load(tbl, 142 * VECWIDTH + tbloffset), times(v833, load(tbl, 143 * VECWIDTH + tbloffset))); + real2 v1640 = minus(v963, v803); + real2 v1644 = plus(v803, v963); + real2 v1680 = minus(v1003, v843); + real2 v1684 = plus(v843, v1003); + real2 v1641 = minusplus(v1639, v1640); + real2 v1643 = minusplus(uminus(v1639), v1640); + real2 v1657 = timesminusplus(reverse(v1643), load(tbl, 292 * VECWIDTH + tbloffset), times(v1643, load(tbl, 293 * VECWIDTH + tbloffset))); + real2 v913 = minusplus(v911, v912); + real2 v915 = minusplus(uminus(v911), v912); + real2 v1073 = minusplus(v1071, v1072); + real2 v1075 = minusplus(uminus(v1071), v1072); + real2 v923 = timesminusplus(reverse(v913), load(tbl, 158 * VECWIDTH + tbloffset), times(v913, load(tbl, 159 * VECWIDTH + tbloffset))); + real2 v1083 = timesminusplus(reverse(v1073), load(tbl, 190 * VECWIDTH + tbloffset), times(v1073, load(tbl, 191 * VECWIDTH + tbloffset))); + real2 v1685 = plus(v923, v1083); + real2 v1679 = reverse(minus(v923, v1083)); + real2 v1681 = minusplus(v1679, v1680); + real2 v1683 = minusplus(uminus(v1679), v1680); + real2 v1697 = timesminusplus(reverse(v1683), load(tbl, 300 * VECWIDTH + tbloffset), times(v1683, load(tbl, 301 * VECWIDTH + tbloffset))); + real2 v1809 = plus(v1657, v1697); + real2 v1803 = reverse(minus(v1657, v1697)); + scatter(out, 26, 128, plus(v1808, v1809)); + real2 v1822 = minus(v1808, v1809); + scatter(out, 90, 128, timesminusplus(v1822, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v1822), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v1807 = minusplus(uminus(v1803), v1804); + real2 v1805 = minusplus(v1803, v1804); + scatter(out, 58, 128, timesminusplus(reverse(v1805), load(tbl, 318 * VECWIDTH + tbloffset), times(v1805, load(tbl, 319 * VECWIDTH + tbloffset)))); + scatter(out, 122, 128, timesminusplus(reverse(v1807), load(tbl, 320 * VECWIDTH + tbloffset), times(v1807, load(tbl, 321 * VECWIDTH + tbloffset)))); + real2 v1651 = timesminusplus(reverse(v1641), load(tbl, 290 * VECWIDTH + tbloffset), times(v1641, load(tbl, 291 * VECWIDTH + tbloffset))); + real2 v1691 = timesminusplus(reverse(v1681), load(tbl, 298 * VECWIDTH + tbloffset), times(v1681, load(tbl, 299 * VECWIDTH + tbloffset))); + real2 v1783 = plus(v1651, v1691); + real2 v1777 = reverse(minus(v1651, v1691)); + real2 v1779 = minusplus(v1777, v1778); + real2 v1781 = minusplus(uminus(v1777), v1778); + scatter(out, 106, 128, timesminusplus(reverse(v1781), load(tbl, 316 * VECWIDTH + tbloffset), times(v1781, load(tbl, 317 * VECWIDTH + tbloffset)))); + scatter(out, 42, 128, timesminusplus(reverse(v1779), load(tbl, 314 * VECWIDTH + tbloffset), times(v1779, load(tbl, 315 * VECWIDTH + tbloffset)))); + scatter(out, 10, 128, plus(v1782, v1783)); + real2 v1796 = minus(v1782, v1783); + scatter(out, 74, 128, timesminusplus(v1796, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v1796), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v1720 = minus(v1645, v1644); + real2 v1724 = plus(v1644, v1645); + real2 v1719 = reverse(minus(v1684, v1685)); + real2 v1725 = plus(v1684, v1685); + real2 v1745 = plus(v1724, v1725); + real2 v1739 = reverse(minus(v1724, v1725)); + scatter(out, 2, 128, plus(v1744, v1745)); + real2 v1758 = minus(v1744, v1745); + scatter(out, 66, 128, timesminusplus(v1758, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v1758), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v1741 = minusplus(v1739, v1740); + real2 v1743 = minusplus(uminus(v1739), v1740); + scatter(out, 98, 128, timesminusplus(reverse(v1743), load(tbl, 312 * VECWIDTH + tbloffset), times(v1743, load(tbl, 313 * VECWIDTH + tbloffset)))); + scatter(out, 34, 128, timesminusplus(reverse(v1741), load(tbl, 310 * VECWIDTH + tbloffset), times(v1741, load(tbl, 311 * VECWIDTH + tbloffset)))); + real2 v1723 = minusplus(uminus(v1719), v1720); + real2 v1721 = minusplus(v1719, v1720); + real2 v1737 = timesminusplus(reverse(v1723), load(tbl, 308 * VECWIDTH + tbloffset), times(v1723, load(tbl, 309 * VECWIDTH + tbloffset))); + scatter(out, 50, 128, plus(v1717, v1737)); + real2 v1770 = minus(v1717, v1737); + scatter(out, 114, 128, timesminusplus(v1770, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v1770), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v1731 = timesminusplus(reverse(v1721), load(tbl, 306 * VECWIDTH + tbloffset), times(v1721, load(tbl, 307 * VECWIDTH + tbloffset))); + scatter(out, 18, 128, plus(v1711, v1731)); + real2 v1764 = minus(v1711, v1731); + scatter(out, 82, 128, timesminusplus(v1764, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v1764), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v809 = timesminusplus(reverse(v795), load(tbl, 136 * VECWIDTH + tbloffset), times(v795, load(tbl, 137 * VECWIDTH + tbloffset))); + real2 v969 = timesminusplus(reverse(v955), load(tbl, 168 * VECWIDTH + tbloffset), times(v955, load(tbl, 169 * VECWIDTH + tbloffset))); + real2 v1850 = minus(v969, v809); + real2 v1854 = plus(v809, v969); + real2 v849 = timesminusplus(reverse(v835), load(tbl, 144 * VECWIDTH + tbloffset), times(v835, load(tbl, 145 * VECWIDTH + tbloffset))); + real2 v929 = timesminusplus(reverse(v915), load(tbl, 160 * VECWIDTH + tbloffset), times(v915, load(tbl, 161 * VECWIDTH + tbloffset))); + real2 v889 = timesminusplus(reverse(v875), load(tbl, 152 * VECWIDTH + tbloffset), times(v875, load(tbl, 153 * VECWIDTH + tbloffset))); + real2 v1089 = timesminusplus(reverse(v1075), load(tbl, 192 * VECWIDTH + tbloffset), times(v1075, load(tbl, 193 * VECWIDTH + tbloffset))); + real2 v1009 = timesminusplus(reverse(v995), load(tbl, 176 * VECWIDTH + tbloffset), times(v995, load(tbl, 177 * VECWIDTH + tbloffset))); + real2 v1890 = minus(v1009, v849); + real2 v1894 = plus(v849, v1009); + real2 v1849 = reverse(minus(v889, v1049)); + real2 v1855 = plus(v889, v1049); + real2 v1930 = minus(v1855, v1854); + real2 v1934 = plus(v1854, v1855); + real2 v1895 = plus(v929, v1089); + real2 v1889 = reverse(minus(v929, v1089)); + real2 v1929 = reverse(minus(v1894, v1895)); + real2 v1935 = plus(v1894, v1895); + real2 v1955 = plus(v1934, v1935); + real2 v1949 = reverse(minus(v1934, v1935)); + scatter(out, 6, 128, plus(v1954, v1955)); + real2 v1968 = minus(v1954, v1955); + scatter(out, 70, 128, timesminusplus(v1968, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v1968), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v1951 = minusplus(v1949, v1950); + scatter(out, 38, 128, timesminusplus(reverse(v1951), load(tbl, 346 * VECWIDTH + tbloffset), times(v1951, load(tbl, 347 * VECWIDTH + tbloffset)))); + real2 v1953 = minusplus(uminus(v1949), v1950); + scatter(out, 102, 128, timesminusplus(reverse(v1953), load(tbl, 348 * VECWIDTH + tbloffset), times(v1953, load(tbl, 349 * VECWIDTH + tbloffset)))); + real2 v1931 = minusplus(v1929, v1930); + real2 v1933 = minusplus(uminus(v1929), v1930); + real2 v1947 = timesminusplus(reverse(v1933), load(tbl, 344 * VECWIDTH + tbloffset), times(v1933, load(tbl, 345 * VECWIDTH + tbloffset))); + scatter(out, 54, 128, plus(v1927, v1947)); + real2 v1980 = minus(v1927, v1947); + scatter(out, 118, 128, timesminusplus(v1980, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v1980), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v1941 = timesminusplus(reverse(v1931), load(tbl, 342 * VECWIDTH + tbloffset), times(v1931, load(tbl, 343 * VECWIDTH + tbloffset))); + scatter(out, 22, 128, plus(v1921, v1941)); + real2 v1974 = minus(v1921, v1941); + scatter(out, 86, 128, timesminusplus(v1974, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v1974), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v1851 = minusplus(v1849, v1850); + real2 v1853 = minusplus(uminus(v1849), v1850); + real2 v1867 = timesminusplus(reverse(v1853), load(tbl, 328 * VECWIDTH + tbloffset), times(v1853, load(tbl, 329 * VECWIDTH + tbloffset))); + real2 v1891 = minusplus(v1889, v1890); + real2 v1893 = minusplus(uminus(v1889), v1890); + real2 v1907 = timesminusplus(reverse(v1893), load(tbl, 336 * VECWIDTH + tbloffset), times(v1893, load(tbl, 337 * VECWIDTH + tbloffset))); + real2 v2019 = plus(v1867, v1907); + real2 v2013 = reverse(minus(v1867, v1907)); + scatter(out, 30, 128, plus(v2018, v2019)); + real2 v2032 = minus(v2018, v2019); + scatter(out, 94, 128, timesminusplus(v2032, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v2032), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v2017 = minusplus(uminus(v2013), v2014); + scatter(out, 126, 128, timesminusplus(reverse(v2017), load(tbl, 356 * VECWIDTH + tbloffset), times(v2017, load(tbl, 357 * VECWIDTH + tbloffset)))); + real2 v2015 = minusplus(v2013, v2014); + scatter(out, 62, 128, timesminusplus(reverse(v2015), load(tbl, 354 * VECWIDTH + tbloffset), times(v2015, load(tbl, 355 * VECWIDTH + tbloffset)))); + real2 v1861 = timesminusplus(reverse(v1851), load(tbl, 326 * VECWIDTH + tbloffset), times(v1851, load(tbl, 327 * VECWIDTH + tbloffset))); + real2 v1901 = timesminusplus(reverse(v1891), load(tbl, 334 * VECWIDTH + tbloffset), times(v1891, load(tbl, 335 * VECWIDTH + tbloffset))); + real2 v1993 = plus(v1861, v1901); + real2 v1987 = reverse(minus(v1861, v1901)); + scatter(out, 14, 128, plus(v1992, v1993)); + real2 v2006 = minus(v1992, v1993); + scatter(out, 78, 128, timesminusplus(v2006, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v2006), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v1991 = minusplus(uminus(v1987), v1988); + scatter(out, 110, 128, timesminusplus(reverse(v1991), load(tbl, 352 * VECWIDTH + tbloffset), times(v1991, load(tbl, 353 * VECWIDTH + tbloffset)))); + real2 v1989 = minusplus(v1987, v1988); + scatter(out, 46, 128, timesminusplus(reverse(v1989), load(tbl, 350 * VECWIDTH + tbloffset), times(v1989, load(tbl, 351 * VECWIDTH + tbloffset)))); + real2 v593 = minusplus(v591, v592); + real2 v595 = minusplus(uminus(v591), v592); + real2 v473 = minusplus(v471, v472); + real2 v475 = minusplus(uminus(v471), v472); + real2 v555 = minusplus(uminus(v551), v552); + real2 v553 = minusplus(v551, v552); + real2 v609 = timesminusplus(reverse(v595), load(tbl, 96 * VECWIDTH + tbloffset), times(v595, load(tbl, 97 * VECWIDTH + tbloffset))); + real2 v195 = minusplus(uminus(v191), v192); + real2 v193 = minusplus(v191, v192); + real2 v275 = minusplus(uminus(v271), v272); + real2 v273 = minusplus(v271, v272); + real2 v673 = minusplus(v671, v672); + real2 v675 = minusplus(uminus(v671), v672); + real2 v689 = timesminusplus(reverse(v675), load(tbl, 112 * VECWIDTH + tbloffset), times(v675, load(tbl, 113 * VECWIDTH + tbloffset))); + real2 v209 = timesminusplus(reverse(v195), load(tbl, 16 * VECWIDTH + tbloffset), times(v195, load(tbl, 17 * VECWIDTH + tbloffset))); + real2 v289 = timesminusplus(reverse(v275), load(tbl, 32 * VECWIDTH + tbloffset), times(v275, load(tbl, 33 * VECWIDTH + tbloffset))); + real2 v755 = minusplus(uminus(v751), v752); + real2 v753 = minusplus(v751, v752); + real2 v435 = minusplus(uminus(v431), v432); + real2 v433 = minusplus(v431, v432); + real2 v513 = minusplus(v511, v512); + real2 v515 = minusplus(uminus(v511), v512); + real2 v529 = timesminusplus(reverse(v515), load(tbl, 80 * VECWIDTH + tbloffset), times(v515, load(tbl, 81 * VECWIDTH + tbloffset))); + real2 v353 = minusplus(v351, v352); + real2 v355 = minusplus(uminus(v351), v352); + real2 v369 = timesminusplus(reverse(v355), load(tbl, 48 * VECWIDTH + tbloffset), times(v355, load(tbl, 49 * VECWIDTH + tbloffset))); + real2 v2631 = plus(v369, v689); + real2 v2625 = reverse(minus(v369, v689)); + real2 v449 = timesminusplus(reverse(v435), load(tbl, 64 * VECWIDTH + tbloffset), times(v435, load(tbl, 65 * VECWIDTH + tbloffset))); + real2 v2710 = plus(v289, v609); + real2 v2706 = minus(v609, v289); + real2 v2630 = plus(v209, v529); + real2 v2626 = minus(v529, v209); + real2 v2790 = plus(v2630, v2631); + real2 v2786 = minus(v2631, v2630); + real2 v713 = minusplus(v711, v712); + real2 v715 = minusplus(uminus(v711), v712); + real2 v769 = timesminusplus(reverse(v755), load(tbl, 128 * VECWIDTH + tbloffset), times(v755, load(tbl, 129 * VECWIDTH + tbloffset))); + real2 v2705 = reverse(minus(v449, v769)); + real2 v2711 = plus(v449, v769); + real2 v313 = minusplus(v311, v312); + real2 v315 = minusplus(uminus(v311), v312); + real2 v393 = minusplus(v391, v392); + real2 v395 = minusplus(uminus(v391), v392); + real2 v409 = timesminusplus(reverse(v395), load(tbl, 56 * VECWIDTH + tbloffset), times(v395, load(tbl, 57 * VECWIDTH + tbloffset))); + real2 v729 = timesminusplus(reverse(v715), load(tbl, 120 * VECWIDTH + tbloffset), times(v715, load(tbl, 121 * VECWIDTH + tbloffset))); + real2 v329 = timesminusplus(reverse(v315), load(tbl, 40 * VECWIDTH + tbloffset), times(v315, load(tbl, 41 * VECWIDTH + tbloffset))); + real2 v489 = timesminusplus(reverse(v475), load(tbl, 72 * VECWIDTH + tbloffset), times(v475, load(tbl, 73 * VECWIDTH + tbloffset))); + real2 v153 = minusplus(v151, v152); + real2 v155 = minusplus(uminus(v151), v152); + real2 v169 = timesminusplus(reverse(v155), load(tbl, 8 * VECWIDTH + tbloffset), times(v155, load(tbl, 9 * VECWIDTH + tbloffset))); + real2 v2586 = minus(v489, v169); + real2 v2590 = plus(v169, v489); + real2 v233 = minusplus(v231, v232); + real2 v235 = minusplus(uminus(v231), v232); + real2 v633 = minusplus(v631, v632); + real2 v635 = minusplus(uminus(v631), v632); + real2 v649 = timesminusplus(reverse(v635), load(tbl, 104 * VECWIDTH + tbloffset), times(v635, load(tbl, 105 * VECWIDTH + tbloffset))); + real2 v249 = timesminusplus(reverse(v235), load(tbl, 24 * VECWIDTH + tbloffset), times(v235, load(tbl, 25 * VECWIDTH + tbloffset))); + real2 v569 = timesminusplus(reverse(v555), load(tbl, 88 * VECWIDTH + tbloffset), times(v555, load(tbl, 89 * VECWIDTH + tbloffset))); + real2 v2670 = plus(v249, v569); + real2 v2666 = minus(v569, v249); + real2 v2785 = reverse(minus(v2710, v2711)); + real2 v2791 = plus(v2710, v2711); + real2 v2825 = reverse(minus(v2790, v2791)); + real2 v2831 = plus(v2790, v2791); + real2 v2671 = plus(v409, v729); + real2 v2665 = reverse(minus(v409, v729)); + real2 v2745 = reverse(minus(v2670, v2671)); + real2 v2751 = plus(v2670, v2671); + real2 v2806 = minus(v2731, v2730); + real2 v2810 = plus(v2730, v2731); + real2 v2846 = minus(v2811, v2810); + real2 v2850 = plus(v2810, v2811); + real2 v2591 = plus(v329, v649); + real2 v2585 = reverse(minus(v329, v649)); + real2 v2750 = plus(v2590, v2591); + real2 v2746 = minus(v2591, v2590); + real2 v2830 = plus(v2750, v2751); + real2 v2826 = minus(v2751, v2750); + real2 v2845 = reverse(minus(v2830, v2831)); + real2 v2851 = plus(v2830, v2831); + scatter(out, 3, 128, plus(v2850, v2851)); + real2 v2864 = minus(v2850, v2851); + scatter(out, 67, 128, timesminusplus(v2864, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v2864), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v2849 = minusplus(uminus(v2845), v2846); + real2 v2847 = minusplus(v2845, v2846); + scatter(out, 35, 128, timesminusplus(reverse(v2847), load(tbl, 506 * VECWIDTH + tbloffset), times(v2847, load(tbl, 507 * VECWIDTH + tbloffset)))); + scatter(out, 99, 128, timesminusplus(reverse(v2849), load(tbl, 508 * VECWIDTH + tbloffset), times(v2849, load(tbl, 509 * VECWIDTH + tbloffset)))); + real2 v2827 = minusplus(v2825, v2826); + real2 v2829 = minusplus(uminus(v2825), v2826); + real2 v2837 = timesminusplus(reverse(v2827), load(tbl, 502 * VECWIDTH + tbloffset), times(v2827, load(tbl, 503 * VECWIDTH + tbloffset))); + real2 v2809 = minusplus(uminus(v2805), v2806); + real2 v2807 = minusplus(v2805, v2806); + real2 v2817 = timesminusplus(reverse(v2807), load(tbl, 498 * VECWIDTH + tbloffset), times(v2807, load(tbl, 499 * VECWIDTH + tbloffset))); + scatter(out, 19, 128, plus(v2817, v2837)); + real2 v2870 = minus(v2817, v2837); + scatter(out, 83, 128, timesminusplus(v2870, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v2870), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v2823 = timesminusplus(reverse(v2809), load(tbl, 500 * VECWIDTH + tbloffset), times(v2809, load(tbl, 501 * VECWIDTH + tbloffset))); + real2 v2843 = timesminusplus(reverse(v2829), load(tbl, 504 * VECWIDTH + tbloffset), times(v2829, load(tbl, 505 * VECWIDTH + tbloffset))); + scatter(out, 51, 128, plus(v2823, v2843)); + real2 v2876 = minus(v2823, v2843); + scatter(out, 115, 128, timesminusplus(v2876, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v2876), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v2787 = minusplus(v2785, v2786); + real2 v2789 = minusplus(uminus(v2785), v2786); + real2 v2803 = timesminusplus(reverse(v2789), load(tbl, 496 * VECWIDTH + tbloffset), times(v2789, load(tbl, 497 * VECWIDTH + tbloffset))); + real2 v2727 = minusplus(v2725, v2726); + real2 v2729 = minusplus(uminus(v2725), v2726); + real2 v2743 = timesminusplus(reverse(v2729), load(tbl, 484 * VECWIDTH + tbloffset), times(v2729, load(tbl, 485 * VECWIDTH + tbloffset))); + real2 v2914 = plus(v2743, v2783); + real2 v2910 = minus(v2783, v2743); + real2 v2749 = minusplus(uminus(v2745), v2746); + real2 v2747 = minusplus(v2745, v2746); + real2 v2763 = timesminusplus(reverse(v2749), load(tbl, 488 * VECWIDTH + tbloffset), times(v2749, load(tbl, 489 * VECWIDTH + tbloffset))); + real2 v2909 = reverse(minus(v2763, v2803)); + real2 v2915 = plus(v2763, v2803); + scatter(out, 27, 128, plus(v2914, v2915)); + real2 v2928 = minus(v2914, v2915); + scatter(out, 91, 128, timesminusplus(v2928, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v2928), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v2913 = minusplus(uminus(v2909), v2910); + scatter(out, 123, 128, timesminusplus(reverse(v2913), load(tbl, 516 * VECWIDTH + tbloffset), times(v2913, load(tbl, 517 * VECWIDTH + tbloffset)))); + real2 v2911 = minusplus(v2909, v2910); + scatter(out, 59, 128, timesminusplus(reverse(v2911), load(tbl, 514 * VECWIDTH + tbloffset), times(v2911, load(tbl, 515 * VECWIDTH + tbloffset)))); + real2 v2737 = timesminusplus(reverse(v2727), load(tbl, 482 * VECWIDTH + tbloffset), times(v2727, load(tbl, 483 * VECWIDTH + tbloffset))); + real2 v2888 = plus(v2737, v2777); + real2 v2884 = minus(v2777, v2737); + real2 v2797 = timesminusplus(reverse(v2787), load(tbl, 494 * VECWIDTH + tbloffset), times(v2787, load(tbl, 495 * VECWIDTH + tbloffset))); + real2 v2757 = timesminusplus(reverse(v2747), load(tbl, 486 * VECWIDTH + tbloffset), times(v2747, load(tbl, 487 * VECWIDTH + tbloffset))); + real2 v2889 = plus(v2757, v2797); + real2 v2883 = reverse(minus(v2757, v2797)); + scatter(out, 11, 128, plus(v2888, v2889)); + real2 v2902 = minus(v2888, v2889); + scatter(out, 75, 128, timesminusplus(v2902, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v2902), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v2887 = minusplus(uminus(v2883), v2884); + scatter(out, 107, 128, timesminusplus(reverse(v2887), load(tbl, 512 * VECWIDTH + tbloffset), times(v2887, load(tbl, 513 * VECWIDTH + tbloffset)))); + real2 v2885 = minusplus(v2883, v2884); + scatter(out, 43, 128, timesminusplus(reverse(v2885), load(tbl, 510 * VECWIDTH + tbloffset), times(v2885, load(tbl, 511 * VECWIDTH + tbloffset)))); + real2 v2669 = minusplus(uminus(v2665), v2666); + real2 v2667 = minusplus(v2665, v2666); + real2 v2707 = minusplus(v2705, v2706); + real2 v2709 = minusplus(uminus(v2705), v2706); + real2 v2717 = timesminusplus(reverse(v2707), load(tbl, 478 * VECWIDTH + tbloffset), times(v2707, load(tbl, 479 * VECWIDTH + tbloffset))); + real2 v2627 = minusplus(v2625, v2626); + real2 v2629 = minusplus(uminus(v2625), v2626); + real2 v2637 = timesminusplus(reverse(v2627), load(tbl, 462 * VECWIDTH + tbloffset), times(v2627, load(tbl, 463 * VECWIDTH + tbloffset))); + real2 v2961 = plus(v2637, v2717); + real2 v2955 = reverse(minus(v2637, v2717)); + real2 v2649 = minusplus(uminus(v2645), v2646); + real2 v2647 = minusplus(v2645, v2646); + real2 v2569 = minusplus(uminus(v2565), v2566); + real2 v2567 = minusplus(v2565, v2566); + real2 v2577 = timesminusplus(reverse(v2567), load(tbl, 450 * VECWIDTH + tbloffset), times(v2567, load(tbl, 451 * VECWIDTH + tbloffset))); + real2 v2657 = timesminusplus(reverse(v2647), load(tbl, 466 * VECWIDTH + tbloffset), times(v2647, load(tbl, 467 * VECWIDTH + tbloffset))); + real2 v2936 = minus(v2657, v2577); + real2 v2940 = plus(v2577, v2657); + real2 v2976 = minus(v2941, v2940); + real2 v2980 = plus(v2940, v2941); + real2 v2677 = timesminusplus(reverse(v2667), load(tbl, 470 * VECWIDTH + tbloffset), times(v2667, load(tbl, 471 * VECWIDTH + tbloffset))); + real2 v2587 = minusplus(v2585, v2586); + real2 v2589 = minusplus(uminus(v2585), v2586); + real2 v2597 = timesminusplus(reverse(v2587), load(tbl, 454 * VECWIDTH + tbloffset), times(v2587, load(tbl, 455 * VECWIDTH + tbloffset))); + real2 v2956 = minus(v2677, v2597); + real2 v2960 = plus(v2597, v2677); + real2 v2975 = reverse(minus(v2960, v2961)); + real2 v2981 = plus(v2960, v2961); + scatter(out, 7, 128, plus(v2980, v2981)); + real2 v2994 = minus(v2980, v2981); + scatter(out, 71, 128, timesminusplus(v2994, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v2994), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v2979 = minusplus(uminus(v2975), v2976); + scatter(out, 103, 128, timesminusplus(reverse(v2979), load(tbl, 528 * VECWIDTH + tbloffset), times(v2979, load(tbl, 529 * VECWIDTH + tbloffset)))); + real2 v2977 = minusplus(v2975, v2976); + scatter(out, 39, 128, timesminusplus(reverse(v2977), load(tbl, 526 * VECWIDTH + tbloffset), times(v2977, load(tbl, 527 * VECWIDTH + tbloffset)))); + real2 v2939 = minusplus(uminus(v2935), v2936); + real2 v2937 = minusplus(v2935, v2936); + real2 v2953 = timesminusplus(reverse(v2939), load(tbl, 520 * VECWIDTH + tbloffset), times(v2939, load(tbl, 521 * VECWIDTH + tbloffset))); + real2 v2957 = minusplus(v2955, v2956); + real2 v2959 = minusplus(uminus(v2955), v2956); + real2 v2973 = timesminusplus(reverse(v2959), load(tbl, 524 * VECWIDTH + tbloffset), times(v2959, load(tbl, 525 * VECWIDTH + tbloffset))); + scatter(out, 55, 128, plus(v2953, v2973)); + real2 v3006 = minus(v2953, v2973); + scatter(out, 119, 128, timesminusplus(v3006, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v3006), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v2947 = timesminusplus(reverse(v2937), load(tbl, 518 * VECWIDTH + tbloffset), times(v2937, load(tbl, 519 * VECWIDTH + tbloffset))); + real2 v2967 = timesminusplus(reverse(v2957), load(tbl, 522 * VECWIDTH + tbloffset), times(v2957, load(tbl, 523 * VECWIDTH + tbloffset))); + scatter(out, 23, 128, plus(v2947, v2967)); + real2 v3000 = minus(v2947, v2967); + scatter(out, 87, 128, timesminusplus(v3000, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v3000), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v2663 = timesminusplus(reverse(v2649), load(tbl, 468 * VECWIDTH + tbloffset), times(v2649, load(tbl, 469 * VECWIDTH + tbloffset))); + real2 v2583 = timesminusplus(reverse(v2569), load(tbl, 452 * VECWIDTH + tbloffset), times(v2569, load(tbl, 453 * VECWIDTH + tbloffset))); + real2 v3014 = minus(v2663, v2583); + real2 v3018 = plus(v2583, v2663); + real2 v3015 = minusplus(v3013, v3014); + real2 v3017 = minusplus(uminus(v3013), v3014); + real2 v2643 = timesminusplus(reverse(v2629), load(tbl, 464 * VECWIDTH + tbloffset), times(v2629, load(tbl, 465 * VECWIDTH + tbloffset))); + real2 v2723 = timesminusplus(reverse(v2709), load(tbl, 480 * VECWIDTH + tbloffset), times(v2709, load(tbl, 481 * VECWIDTH + tbloffset))); + real2 v3039 = plus(v2643, v2723); + real2 v3033 = reverse(minus(v2643, v2723)); + real2 v2683 = timesminusplus(reverse(v2669), load(tbl, 472 * VECWIDTH + tbloffset), times(v2669, load(tbl, 473 * VECWIDTH + tbloffset))); + real2 v3031 = timesminusplus(reverse(v3017), load(tbl, 532 * VECWIDTH + tbloffset), times(v3017, load(tbl, 533 * VECWIDTH + tbloffset))); + real2 v2603 = timesminusplus(reverse(v2589), load(tbl, 456 * VECWIDTH + tbloffset), times(v2589, load(tbl, 457 * VECWIDTH + tbloffset))); + real2 v3034 = minus(v2683, v2603); + real2 v3038 = plus(v2603, v2683); + real2 v3037 = minusplus(uminus(v3033), v3034); + real2 v3035 = minusplus(v3033, v3034); + real2 v3051 = timesminusplus(reverse(v3037), load(tbl, 536 * VECWIDTH + tbloffset), times(v3037, load(tbl, 537 * VECWIDTH + tbloffset))); + scatter(out, 63, 128, plus(v3031, v3051)); + real2 v3084 = minus(v3031, v3051); + scatter(out, 127, 128, timesminusplus(v3084, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v3084), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v3025 = timesminusplus(reverse(v3015), load(tbl, 530 * VECWIDTH + tbloffset), times(v3015, load(tbl, 531 * VECWIDTH + tbloffset))); + real2 v3045 = timesminusplus(reverse(v3035), load(tbl, 534 * VECWIDTH + tbloffset), times(v3035, load(tbl, 535 * VECWIDTH + tbloffset))); + scatter(out, 31, 128, plus(v3025, v3045)); + real2 v3078 = minus(v3025, v3045); + scatter(out, 95, 128, timesminusplus(v3078, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v3078), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v3058 = plus(v3018, v3019); + real2 v3054 = minus(v3019, v3018); + real2 v3053 = reverse(minus(v3038, v3039)); + real2 v3059 = plus(v3038, v3039); + real2 v3055 = minusplus(v3053, v3054); + scatter(out, 47, 128, timesminusplus(reverse(v3055), load(tbl, 538 * VECWIDTH + tbloffset), times(v3055, load(tbl, 539 * VECWIDTH + tbloffset)))); + real2 v3057 = minusplus(uminus(v3053), v3054); + scatter(out, 111, 128, timesminusplus(reverse(v3057), load(tbl, 540 * VECWIDTH + tbloffset), times(v3057, load(tbl, 541 * VECWIDTH + tbloffset)))); + scatter(out, 15, 128, plus(v3058, v3059)); + real2 v3072 = minus(v3058, v3059); + scatter(out, 79, 128, timesminusplus(v3072, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v3072), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v683 = timesminusplus(reverse(v673), load(tbl, 110 * VECWIDTH + tbloffset), times(v673, load(tbl, 111 * VECWIDTH + tbloffset))); + real2 v363 = timesminusplus(reverse(v353), load(tbl, 46 * VECWIDTH + tbloffset), times(v353, load(tbl, 47 * VECWIDTH + tbloffset))); + real2 v2105 = plus(v363, v683); + real2 v2099 = reverse(minus(v363, v683)); + real2 v283 = timesminusplus(reverse(v273), load(tbl, 30 * VECWIDTH + tbloffset), times(v273, load(tbl, 31 * VECWIDTH + tbloffset))); + real2 v723 = timesminusplus(reverse(v713), load(tbl, 118 * VECWIDTH + tbloffset), times(v713, load(tbl, 119 * VECWIDTH + tbloffset))); + real2 v403 = timesminusplus(reverse(v393), load(tbl, 54 * VECWIDTH + tbloffset), times(v393, load(tbl, 55 * VECWIDTH + tbloffset))); + real2 v603 = timesminusplus(reverse(v593), load(tbl, 94 * VECWIDTH + tbloffset), times(v593, load(tbl, 95 * VECWIDTH + tbloffset))); + real2 v2180 = minus(v603, v283); + real2 v2184 = plus(v283, v603); + real2 v2145 = plus(v403, v723); + real2 v2139 = reverse(minus(v403, v723)); + real2 v543 = timesminusplus(reverse(v533), load(tbl, 82 * VECWIDTH + tbloffset), times(v533, load(tbl, 83 * VECWIDTH + tbloffset))); + real2 v383 = timesminusplus(reverse(v373), load(tbl, 50 * VECWIDTH + tbloffset), times(v373, load(tbl, 51 * VECWIDTH + tbloffset))); + real2 v703 = timesminusplus(reverse(v693), load(tbl, 114 * VECWIDTH + tbloffset), times(v693, load(tbl, 115 * VECWIDTH + tbloffset))); + real2 v2125 = plus(v383, v703); + real2 v2119 = reverse(minus(v383, v703)); + real2 v223 = timesminusplus(reverse(v213), load(tbl, 18 * VECWIDTH + tbloffset), times(v213, load(tbl, 19 * VECWIDTH + tbloffset))); + real2 v2120 = minus(v543, v223); + real2 v2124 = plus(v223, v543); + real2 v443 = timesminusplus(reverse(v433), load(tbl, 62 * VECWIDTH + tbloffset), times(v433, load(tbl, 63 * VECWIDTH + tbloffset))); + real2 v203 = timesminusplus(reverse(v193), load(tbl, 14 * VECWIDTH + tbloffset), times(v193, load(tbl, 15 * VECWIDTH + tbloffset))); + real2 v763 = timesminusplus(reverse(v753), load(tbl, 126 * VECWIDTH + tbloffset), times(v753, load(tbl, 127 * VECWIDTH + tbloffset))); + real2 v2179 = reverse(minus(v443, v763)); + real2 v2185 = plus(v443, v763); + real2 v523 = timesminusplus(reverse(v513), load(tbl, 78 * VECWIDTH + tbloffset), times(v513, load(tbl, 79 * VECWIDTH + tbloffset))); + real2 v2100 = minus(v523, v203); + real2 v2104 = plus(v203, v523); + real2 v2264 = plus(v2104, v2105); + real2 v2260 = minus(v2105, v2104); + real2 v643 = timesminusplus(reverse(v633), load(tbl, 102 * VECWIDTH + tbloffset), times(v633, load(tbl, 103 * VECWIDTH + tbloffset))); + real2 v2265 = plus(v2184, v2185); + real2 v2259 = reverse(minus(v2184, v2185)); + real2 v563 = timesminusplus(reverse(v553), load(tbl, 86 * VECWIDTH + tbloffset), times(v553, load(tbl, 87 * VECWIDTH + tbloffset))); + real2 v243 = timesminusplus(reverse(v233), load(tbl, 22 * VECWIDTH + tbloffset), times(v233, load(tbl, 23 * VECWIDTH + tbloffset))); + real2 v2144 = plus(v243, v563); + real2 v2140 = minus(v563, v243); + real2 v143 = timesminusplus(reverse(v133), load(tbl, 2 * VECWIDTH + tbloffset), times(v133, load(tbl, 3 * VECWIDTH + tbloffset))); + real2 v183 = timesminusplus(reverse(v173), load(tbl, 10 * VECWIDTH + tbloffset), times(v173, load(tbl, 11 * VECWIDTH + tbloffset))); + real2 v2084 = plus(v183, v503); + real2 v2080 = minus(v503, v183); + real2 v163 = timesminusplus(reverse(v153), load(tbl, 6 * VECWIDTH + tbloffset), times(v153, load(tbl, 7 * VECWIDTH + tbloffset))); + real2 v303 = timesminusplus(reverse(v293), load(tbl, 34 * VECWIDTH + tbloffset), times(v293, load(tbl, 35 * VECWIDTH + tbloffset))); + real2 v623 = timesminusplus(reverse(v613), load(tbl, 98 * VECWIDTH + tbloffset), times(v613, load(tbl, 99 * VECWIDTH + tbloffset))); + real2 v2039 = reverse(minus(v303, v623)); + real2 v2045 = plus(v303, v623); + real2 v463 = timesminusplus(reverse(v453), load(tbl, 66 * VECWIDTH + tbloffset), times(v453, load(tbl, 67 * VECWIDTH + tbloffset))); + real2 v2044 = plus(v143, v463); + real2 v2040 = minus(v463, v143); + real2 v2204 = plus(v2044, v2045); + real2 v2200 = minus(v2045, v2044); + real2 v323 = timesminusplus(reverse(v313), load(tbl, 38 * VECWIDTH + tbloffset), times(v313, load(tbl, 39 * VECWIDTH + tbloffset))); + real2 v2205 = plus(v2124, v2125); + real2 v2199 = reverse(minus(v2124, v2125)); + real2 v2280 = minus(v2205, v2204); + real2 v2284 = plus(v2204, v2205); + real2 v2225 = plus(v2144, v2145); + real2 v2219 = reverse(minus(v2144, v2145)); + real2 v2305 = plus(v2264, v2265); + real2 v2299 = reverse(minus(v2264, v2265)); + real2 v2240 = minus(v2085, v2084); + real2 v2244 = plus(v2084, v2085); + real2 v2279 = reverse(minus(v2244, v2245)); + real2 v2285 = plus(v2244, v2245); + real2 v2281 = minusplus(v2279, v2280); + real2 v2283 = minusplus(uminus(v2279), v2280); + real2 v2291 = timesminusplus(reverse(v2281), load(tbl, 406 * VECWIDTH + tbloffset), times(v2281, load(tbl, 407 * VECWIDTH + tbloffset))); + real2 v483 = timesminusplus(reverse(v473), load(tbl, 70 * VECWIDTH + tbloffset), times(v473, load(tbl, 71 * VECWIDTH + tbloffset))); + real2 v2060 = minus(v483, v163); + real2 v2064 = plus(v163, v483); + real2 v2065 = plus(v323, v643); + real2 v2059 = reverse(minus(v323, v643)); + real2 v2220 = minus(v2065, v2064); + real2 v2224 = plus(v2064, v2065); + real2 v2304 = plus(v2224, v2225); + real2 v2300 = minus(v2225, v2224); + real2 v2301 = minusplus(v2299, v2300); + real2 v2303 = minusplus(uminus(v2299), v2300); + real2 v2311 = timesminusplus(reverse(v2301), load(tbl, 410 * VECWIDTH + tbloffset), times(v2301, load(tbl, 411 * VECWIDTH + tbloffset))); + scatter(out, 17, 128, plus(v2291, v2311)); + real2 v2344 = minus(v2291, v2311); + scatter(out, 81, 128, timesminusplus(v2344, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v2344), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v2297 = timesminusplus(reverse(v2283), load(tbl, 408 * VECWIDTH + tbloffset), times(v2283, load(tbl, 409 * VECWIDTH + tbloffset))); + real2 v2317 = timesminusplus(reverse(v2303), load(tbl, 412 * VECWIDTH + tbloffset), times(v2303, load(tbl, 413 * VECWIDTH + tbloffset))); + scatter(out, 49, 128, plus(v2297, v2317)); + real2 v2350 = minus(v2297, v2317); + scatter(out, 113, 128, timesminusplus(v2350, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v2350), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v2320 = minus(v2285, v2284); + real2 v2324 = plus(v2284, v2285); + real2 v2325 = plus(v2304, v2305); + real2 v2319 = reverse(minus(v2304, v2305)); + scatter(out, 1, 128, plus(v2324, v2325)); + real2 v2338 = minus(v2324, v2325); + scatter(out, 65, 128, timesminusplus(v2338, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v2338), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v2321 = minusplus(v2319, v2320); + scatter(out, 33, 128, timesminusplus(reverse(v2321), load(tbl, 414 * VECWIDTH + tbloffset), times(v2321, load(tbl, 415 * VECWIDTH + tbloffset)))); + real2 v2323 = minusplus(uminus(v2319), v2320); + scatter(out, 97, 128, timesminusplus(reverse(v2323), load(tbl, 416 * VECWIDTH + tbloffset), times(v2323, load(tbl, 417 * VECWIDTH + tbloffset)))); + real2 v2201 = minusplus(v2199, v2200); + real2 v2203 = minusplus(uminus(v2199), v2200); + real2 v2263 = minusplus(uminus(v2259), v2260); + real2 v2261 = minusplus(v2259, v2260); + real2 v2243 = minusplus(uminus(v2239), v2240); + real2 v2241 = minusplus(v2239, v2240); + real2 v2257 = timesminusplus(reverse(v2243), load(tbl, 400 * VECWIDTH + tbloffset), times(v2243, load(tbl, 401 * VECWIDTH + tbloffset))); + real2 v2217 = timesminusplus(reverse(v2203), load(tbl, 392 * VECWIDTH + tbloffset), times(v2203, load(tbl, 393 * VECWIDTH + tbloffset))); + real2 v2388 = plus(v2217, v2257); + real2 v2384 = minus(v2257, v2217); + real2 v2277 = timesminusplus(reverse(v2263), load(tbl, 404 * VECWIDTH + tbloffset), times(v2263, load(tbl, 405 * VECWIDTH + tbloffset))); + real2 v2221 = minusplus(v2219, v2220); + real2 v2223 = minusplus(uminus(v2219), v2220); + real2 v2237 = timesminusplus(reverse(v2223), load(tbl, 396 * VECWIDTH + tbloffset), times(v2223, load(tbl, 397 * VECWIDTH + tbloffset))); + real2 v2389 = plus(v2237, v2277); + real2 v2383 = reverse(minus(v2237, v2277)); + scatter(out, 25, 128, plus(v2388, v2389)); + real2 v2402 = minus(v2388, v2389); + scatter(out, 89, 128, timesminusplus(v2402, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v2402), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v2385 = minusplus(v2383, v2384); + real2 v2387 = minusplus(uminus(v2383), v2384); + scatter(out, 121, 128, timesminusplus(reverse(v2387), load(tbl, 424 * VECWIDTH + tbloffset), times(v2387, load(tbl, 425 * VECWIDTH + tbloffset)))); + scatter(out, 57, 128, timesminusplus(reverse(v2385), load(tbl, 422 * VECWIDTH + tbloffset), times(v2385, load(tbl, 423 * VECWIDTH + tbloffset)))); + real2 v2251 = timesminusplus(reverse(v2241), load(tbl, 398 * VECWIDTH + tbloffset), times(v2241, load(tbl, 399 * VECWIDTH + tbloffset))); + real2 v2211 = timesminusplus(reverse(v2201), load(tbl, 390 * VECWIDTH + tbloffset), times(v2201, load(tbl, 391 * VECWIDTH + tbloffset))); + real2 v2358 = minus(v2251, v2211); + real2 v2362 = plus(v2211, v2251); + real2 v2271 = timesminusplus(reverse(v2261), load(tbl, 402 * VECWIDTH + tbloffset), times(v2261, load(tbl, 403 * VECWIDTH + tbloffset))); + real2 v2231 = timesminusplus(reverse(v2221), load(tbl, 394 * VECWIDTH + tbloffset), times(v2221, load(tbl, 395 * VECWIDTH + tbloffset))); + real2 v2357 = reverse(minus(v2231, v2271)); + real2 v2363 = plus(v2231, v2271); + scatter(out, 9, 128, plus(v2362, v2363)); + real2 v2376 = minus(v2362, v2363); + scatter(out, 73, 128, timesminusplus(v2376, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v2376), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v2361 = minusplus(uminus(v2357), v2358); + scatter(out, 105, 128, timesminusplus(reverse(v2361), load(tbl, 420 * VECWIDTH + tbloffset), times(v2361, load(tbl, 421 * VECWIDTH + tbloffset)))); + real2 v2359 = minusplus(v2357, v2358); + scatter(out, 41, 128, timesminusplus(reverse(v2359), load(tbl, 418 * VECWIDTH + tbloffset), times(v2359, load(tbl, 419 * VECWIDTH + tbloffset)))); + real2 v2121 = minusplus(v2119, v2120); + real2 v2123 = minusplus(uminus(v2119), v2120); + real2 v2083 = minusplus(uminus(v2079), v2080); + real2 v2081 = minusplus(v2079, v2080); + real2 v2091 = timesminusplus(reverse(v2081), load(tbl, 366 * VECWIDTH + tbloffset), times(v2081, load(tbl, 367 * VECWIDTH + tbloffset))); + real2 v2043 = minusplus(uminus(v2039), v2040); + real2 v2041 = minusplus(v2039, v2040); + real2 v2051 = timesminusplus(reverse(v2041), load(tbl, 358 * VECWIDTH + tbloffset), times(v2041, load(tbl, 359 * VECWIDTH + tbloffset))); + real2 v2131 = timesminusplus(reverse(v2121), load(tbl, 374 * VECWIDTH + tbloffset), times(v2121, load(tbl, 375 * VECWIDTH + tbloffset))); + real2 v2163 = minusplus(uminus(v2159), v2160); + real2 v2161 = minusplus(v2159, v2160); + real2 v2171 = timesminusplus(reverse(v2161), load(tbl, 382 * VECWIDTH + tbloffset), times(v2161, load(tbl, 383 * VECWIDTH + tbloffset))); + real2 v2409 = reverse(minus(v2091, v2171)); + real2 v2415 = plus(v2091, v2171); + real2 v2410 = minus(v2131, v2051); + real2 v2414 = plus(v2051, v2131); + real2 v2454 = plus(v2414, v2415); + real2 v2450 = minus(v2415, v2414); + real2 v2181 = minusplus(v2179, v2180); + real2 v2183 = minusplus(uminus(v2179), v2180); + real2 v2191 = timesminusplus(reverse(v2181), load(tbl, 386 * VECWIDTH + tbloffset), times(v2181, load(tbl, 387 * VECWIDTH + tbloffset))); + real2 v2103 = minusplus(uminus(v2099), v2100); + real2 v2101 = minusplus(v2099, v2100); + real2 v2111 = timesminusplus(reverse(v2101), load(tbl, 370 * VECWIDTH + tbloffset), times(v2101, load(tbl, 371 * VECWIDTH + tbloffset))); + real2 v2435 = plus(v2111, v2191); + real2 v2429 = reverse(minus(v2111, v2191)); + real2 v2141 = minusplus(v2139, v2140); + real2 v2143 = minusplus(uminus(v2139), v2140); + real2 v2151 = timesminusplus(reverse(v2141), load(tbl, 378 * VECWIDTH + tbloffset), times(v2141, load(tbl, 379 * VECWIDTH + tbloffset))); + real2 v2063 = minusplus(uminus(v2059), v2060); + real2 v2061 = minusplus(v2059, v2060); + real2 v2071 = timesminusplus(reverse(v2061), load(tbl, 362 * VECWIDTH + tbloffset), times(v2061, load(tbl, 363 * VECWIDTH + tbloffset))); + real2 v2434 = plus(v2071, v2151); + real2 v2430 = minus(v2151, v2071); + real2 v2455 = plus(v2434, v2435); + real2 v2449 = reverse(minus(v2434, v2435)); + scatter(out, 5, 128, plus(v2454, v2455)); + real2 v2468 = minus(v2454, v2455); + scatter(out, 69, 128, timesminusplus(v2468, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v2468), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v2451 = minusplus(v2449, v2450); + real2 v2453 = minusplus(uminus(v2449), v2450); + scatter(out, 101, 128, timesminusplus(reverse(v2453), load(tbl, 436 * VECWIDTH + tbloffset), times(v2453, load(tbl, 437 * VECWIDTH + tbloffset)))); + scatter(out, 37, 128, timesminusplus(reverse(v2451), load(tbl, 434 * VECWIDTH + tbloffset), times(v2451, load(tbl, 435 * VECWIDTH + tbloffset)))); + real2 v2411 = minusplus(v2409, v2410); + real2 v2413 = minusplus(uminus(v2409), v2410); + real2 v2433 = minusplus(uminus(v2429), v2430); + real2 v2431 = minusplus(v2429, v2430); + real2 v2421 = timesminusplus(reverse(v2411), load(tbl, 426 * VECWIDTH + tbloffset), times(v2411, load(tbl, 427 * VECWIDTH + tbloffset))); + real2 v2441 = timesminusplus(reverse(v2431), load(tbl, 430 * VECWIDTH + tbloffset), times(v2431, load(tbl, 431 * VECWIDTH + tbloffset))); + scatter(out, 21, 128, plus(v2421, v2441)); + real2 v2474 = minus(v2421, v2441); + scatter(out, 85, 128, timesminusplus(v2474, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v2474), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v2427 = timesminusplus(reverse(v2413), load(tbl, 428 * VECWIDTH + tbloffset), times(v2413, load(tbl, 429 * VECWIDTH + tbloffset))); + real2 v2447 = timesminusplus(reverse(v2433), load(tbl, 432 * VECWIDTH + tbloffset), times(v2433, load(tbl, 433 * VECWIDTH + tbloffset))); + scatter(out, 53, 128, plus(v2427, v2447)); + real2 v2480 = minus(v2427, v2447); + scatter(out, 117, 128, timesminusplus(v2480, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v2480), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v2057 = timesminusplus(reverse(v2043), load(tbl, 360 * VECWIDTH + tbloffset), times(v2043, load(tbl, 361 * VECWIDTH + tbloffset))); + real2 v2097 = timesminusplus(reverse(v2083), load(tbl, 368 * VECWIDTH + tbloffset), times(v2083, load(tbl, 369 * VECWIDTH + tbloffset))); + real2 v2157 = timesminusplus(reverse(v2143), load(tbl, 380 * VECWIDTH + tbloffset), times(v2143, load(tbl, 381 * VECWIDTH + tbloffset))); + real2 v2197 = timesminusplus(reverse(v2183), load(tbl, 388 * VECWIDTH + tbloffset), times(v2183, load(tbl, 389 * VECWIDTH + tbloffset))); + real2 v2117 = timesminusplus(reverse(v2103), load(tbl, 372 * VECWIDTH + tbloffset), times(v2103, load(tbl, 373 * VECWIDTH + tbloffset))); + real2 v2507 = reverse(minus(v2117, v2197)); + real2 v2513 = plus(v2117, v2197); + real2 v2137 = timesminusplus(reverse(v2123), load(tbl, 376 * VECWIDTH + tbloffset), times(v2123, load(tbl, 377 * VECWIDTH + tbloffset))); + real2 v2488 = minus(v2137, v2057); + real2 v2492 = plus(v2057, v2137); + real2 v2177 = timesminusplus(reverse(v2163), load(tbl, 384 * VECWIDTH + tbloffset), times(v2163, load(tbl, 385 * VECWIDTH + tbloffset))); + real2 v2493 = plus(v2097, v2177); + real2 v2487 = reverse(minus(v2097, v2177)); + real2 v2532 = plus(v2492, v2493); + real2 v2528 = minus(v2493, v2492); + real2 v2077 = timesminusplus(reverse(v2063), load(tbl, 364 * VECWIDTH + tbloffset), times(v2063, load(tbl, 365 * VECWIDTH + tbloffset))); + real2 v2512 = plus(v2077, v2157); + real2 v2508 = minus(v2157, v2077); + real2 v2527 = reverse(minus(v2512, v2513)); + real2 v2533 = plus(v2512, v2513); + real2 v2529 = minusplus(v2527, v2528); + real2 v2531 = minusplus(uminus(v2527), v2528); + scatter(out, 109, 128, timesminusplus(reverse(v2531), load(tbl, 448 * VECWIDTH + tbloffset), times(v2531, load(tbl, 449 * VECWIDTH + tbloffset)))); + scatter(out, 45, 128, timesminusplus(reverse(v2529), load(tbl, 446 * VECWIDTH + tbloffset), times(v2529, load(tbl, 447 * VECWIDTH + tbloffset)))); + scatter(out, 13, 128, plus(v2532, v2533)); + real2 v2546 = minus(v2532, v2533); + scatter(out, 77, 128, timesminusplus(v2546, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v2546), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v2509 = minusplus(v2507, v2508); + real2 v2511 = minusplus(uminus(v2507), v2508); + real2 v2491 = minusplus(uminus(v2487), v2488); + real2 v2489 = minusplus(v2487, v2488); + real2 v2499 = timesminusplus(reverse(v2489), load(tbl, 438 * VECWIDTH + tbloffset), times(v2489, load(tbl, 439 * VECWIDTH + tbloffset))); + real2 v2519 = timesminusplus(reverse(v2509), load(tbl, 442 * VECWIDTH + tbloffset), times(v2509, load(tbl, 443 * VECWIDTH + tbloffset))); + scatter(out, 29, 128, plus(v2499, v2519)); + real2 v2552 = minus(v2499, v2519); + scatter(out, 93, 128, timesminusplus(v2552, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v2552), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v2505 = timesminusplus(reverse(v2491), load(tbl, 440 * VECWIDTH + tbloffset), times(v2491, load(tbl, 441 * VECWIDTH + tbloffset))); + real2 v2525 = timesminusplus(reverse(v2511), load(tbl, 444 * VECWIDTH + tbloffset), times(v2511, load(tbl, 445 * VECWIDTH + tbloffset))); + scatter(out, 61, 128, plus(v2505, v2525)); + real2 v2558 = minus(v2505, v2525); + scatter(out, 125, 128, timesminusplus(v2558, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v2558), load(tbl, 1 * VECWIDTH + tbloffset)))); +// Pres : 76263 + } +} + +ALIGNED(8192) void tbut128b_%CONFIG%_%ISA%(real *RESTRICT out0, uint32_t *q, const real *RESTRICT in0, const int inShift, const real *RESTRICT tbl, const int K) { + const int k = 1 << (inShift - LOG2VECWIDTH); + int i=0; +#pragma omp parallel for + for(i=0;i < k;i++) { + int i0 = i << LOG2VECWIDTH; + real *out = out0 + q[i]; + const real *in = in0 + i0*2; + const int tbloffset = K * i0; + +// Pres : 148586 + real2 v56 = load(in, 54 << inShift); + real2 v120 = load(in, 118 << inShift); + real2 v571 = reverse(minus(v120, v56)); + real2 v577 = plus(v56, v120); + real2 v24 = load(in, 22 << inShift); + real2 v88 = load(in, 86 << inShift); + real2 v576 = plus(v24, v88); + real2 v572 = minus(v88, v24); + real2 v573 = minusplus(v571, v572); + real2 v575 = minusplus(uminus(v571), v572); + real2 v589 = timesminusplus(reverse(v575), load(tbl, 92 * VECWIDTH + tbloffset), times(v575, load(tbl, 93 * VECWIDTH + tbloffset))); + real2 v583 = timesminusplus(reverse(v573), load(tbl, 90 * VECWIDTH + tbloffset), times(v573, load(tbl, 91 * VECWIDTH + tbloffset))); + real2 v897 = plus(v576, v577); + real2 v891 = reverse(minus(v577, v576)); + real2 v8 = load(in, 6 << inShift); + real2 v72 = load(in, 70 << inShift); + real2 v252 = minus(v72, v8); + real2 v256 = plus(v8, v72); + real2 v104 = load(in, 102 << inShift); + real2 v40 = load(in, 38 << inShift); + real2 v251 = reverse(minus(v104, v40)); + real2 v257 = plus(v40, v104); + real2 v255 = minusplus(uminus(v251), v252); + real2 v253 = minusplus(v251, v252); + real2 v263 = timesminusplus(reverse(v253), load(tbl, 26 * VECWIDTH + tbloffset), times(v253, load(tbl, 27 * VECWIDTH + tbloffset))); + real2 v896 = plus(v256, v257); + real2 v892 = minus(v257, v256); + real2 v895 = minusplus(uminus(v891), v892); + real2 v893 = minusplus(v891, v892); + real2 v909 = timesminusplus(reverse(v895), load(tbl, 156 * VECWIDTH + tbloffset), times(v895, load(tbl, 157 * VECWIDTH + tbloffset))); + real2 v903 = timesminusplus(reverse(v893), load(tbl, 154 * VECWIDTH + tbloffset), times(v893, load(tbl, 155 * VECWIDTH + tbloffset))); + real2 v269 = timesminusplus(reverse(v255), load(tbl, 28 * VECWIDTH + tbloffset), times(v255, load(tbl, 29 * VECWIDTH + tbloffset))); + real2 v1216 = plus(v896, v897); + real2 v1212 = minus(v897, v896); + real2 v2160 = minus(v583, v263); + real2 v2164 = plus(v263, v583); + real2 v2686 = minus(v589, v269); + real2 v2690 = plus(v269, v589); + real2 v96 = load(in, 94 << inShift); + real2 v32 = load(in, 30 << inShift); + real2 v736 = plus(v32, v96); + real2 v732 = minus(v96, v32); + real2 v64 = load(in, 62 << inShift); + real2 v128 = load(in, 126 << inShift); + real2 v737 = plus(v64, v128); + real2 v731 = reverse(minus(v128, v64)); + real2 v1057 = plus(v736, v737); + real2 v1051 = reverse(minus(v737, v736)); + real2 v733 = minusplus(v731, v732); + real2 v735 = minusplus(uminus(v731), v732); + real2 v749 = timesminusplus(reverse(v735), load(tbl, 124 * VECWIDTH + tbloffset), times(v735, load(tbl, 125 * VECWIDTH + tbloffset))); + real2 v743 = timesminusplus(reverse(v733), load(tbl, 122 * VECWIDTH + tbloffset), times(v733, load(tbl, 123 * VECWIDTH + tbloffset))); + real2 v16 = load(in, 14 << inShift); + real2 v80 = load(in, 78 << inShift); + real2 v412 = minus(v80, v16); + real2 v416 = plus(v16, v80); + real2 v112 = load(in, 110 << inShift); + real2 v48 = load(in, 46 << inShift); + real2 v417 = plus(v48, v112); + real2 v411 = reverse(minus(v112, v48)); + real2 v1056 = plus(v416, v417); + real2 v1052 = minus(v417, v416); + real2 v1055 = minusplus(uminus(v1051), v1052); + real2 v1053 = minusplus(v1051, v1052); + real2 v1063 = timesminusplus(reverse(v1053), load(tbl, 186 * VECWIDTH + tbloffset), times(v1053, load(tbl, 187 * VECWIDTH + tbloffset))); + real2 v1665 = plus(v903, v1063); + real2 v1659 = reverse(minus(v1063, v903)); + real2 v1069 = timesminusplus(reverse(v1055), load(tbl, 188 * VECWIDTH + tbloffset), times(v1055, load(tbl, 189 * VECWIDTH + tbloffset))); + real2 v1869 = reverse(minus(v1069, v909)); + real2 v1875 = plus(v909, v1069); + real2 v413 = minusplus(v411, v412); + real2 v415 = minusplus(uminus(v411), v412); + real2 v429 = timesminusplus(reverse(v415), load(tbl, 60 * VECWIDTH + tbloffset), times(v415, load(tbl, 61 * VECWIDTH + tbloffset))); + real2 v1217 = plus(v1056, v1057); + real2 v1211 = reverse(minus(v1057, v1056)); + real2 v1297 = plus(v1216, v1217); + real2 v1291 = reverse(minus(v1217, v1216)); + real2 v2691 = plus(v429, v749); + real2 v2685 = reverse(minus(v749, v429)); + real2 v2765 = reverse(minus(v2691, v2690)); + real2 v2771 = plus(v2690, v2691); + real2 v2689 = minusplus(uminus(v2685), v2686); + real2 v2687 = minusplus(v2685, v2686); + real2 v2703 = timesminusplus(reverse(v2689), load(tbl, 476 * VECWIDTH + tbloffset), times(v2689, load(tbl, 477 * VECWIDTH + tbloffset))); + real2 v2697 = timesminusplus(reverse(v2687), load(tbl, 474 * VECWIDTH + tbloffset), times(v2687, load(tbl, 475 * VECWIDTH + tbloffset))); + real2 v1215 = minusplus(uminus(v1211), v1212); + real2 v1213 = minusplus(v1211, v1212); + real2 v1223 = timesminusplus(reverse(v1213), load(tbl, 218 * VECWIDTH + tbloffset), times(v1213, load(tbl, 219 * VECWIDTH + tbloffset))); + real2 v1229 = timesminusplus(reverse(v1215), load(tbl, 220 * VECWIDTH + tbloffset), times(v1215, load(tbl, 221 * VECWIDTH + tbloffset))); + real2 v423 = timesminusplus(reverse(v413), load(tbl, 58 * VECWIDTH + tbloffset), times(v413, load(tbl, 59 * VECWIDTH + tbloffset))); + real2 v2165 = plus(v423, v743); + real2 v2159 = reverse(minus(v743, v423)); + real2 v2245 = plus(v2164, v2165); + real2 v2239 = reverse(minus(v2165, v2164)); + real2 v44 = load(in, 42 << inShift); + real2 v108 = load(in, 106 << inShift); + real2 v331 = reverse(minus(v108, v44)); + real2 v337 = plus(v44, v108); + real2 v76 = load(in, 74 << inShift); + real2 v12 = load(in, 10 << inShift); + real2 v336 = plus(v12, v76); + real2 v332 = minus(v76, v12); + real2 v976 = plus(v336, v337); + real2 v972 = minus(v337, v336); + real2 v335 = minusplus(uminus(v331), v332); + real2 v333 = minusplus(v331, v332); + real2 v343 = timesminusplus(reverse(v333), load(tbl, 42 * VECWIDTH + tbloffset), times(v333, load(tbl, 43 * VECWIDTH + tbloffset))); + real2 v349 = timesminusplus(reverse(v335), load(tbl, 44 * VECWIDTH + tbloffset), times(v335, load(tbl, 45 * VECWIDTH + tbloffset))); + real2 v124 = load(in, 122 << inShift); + real2 v60 = load(in, 58 << inShift); + real2 v651 = reverse(minus(v124, v60)); + real2 v657 = plus(v60, v124); + real2 v28 = load(in, 26 << inShift); + real2 v92 = load(in, 90 << inShift); + real2 v652 = minus(v92, v28); + real2 v656 = plus(v28, v92); + real2 v977 = plus(v656, v657); + real2 v971 = reverse(minus(v657, v656)); + real2 v973 = minusplus(v971, v972); + real2 v975 = minusplus(uminus(v971), v972); + real2 v983 = timesminusplus(reverse(v973), load(tbl, 170 * VECWIDTH + tbloffset), times(v973, load(tbl, 171 * VECWIDTH + tbloffset))); + real2 v1131 = reverse(minus(v977, v976)); + real2 v1137 = plus(v976, v977); + real2 v655 = minusplus(uminus(v651), v652); + real2 v653 = minusplus(v651, v652); + real2 v669 = timesminusplus(reverse(v655), load(tbl, 108 * VECWIDTH + tbloffset), times(v655, load(tbl, 109 * VECWIDTH + tbloffset))); + real2 v663 = timesminusplus(reverse(v653), load(tbl, 106 * VECWIDTH + tbloffset), times(v653, load(tbl, 107 * VECWIDTH + tbloffset))); + real2 v2079 = reverse(minus(v663, v343)); + real2 v2085 = plus(v343, v663); + real2 v2605 = reverse(minus(v669, v349)); + real2 v2611 = plus(v349, v669); + real2 v989 = timesminusplus(reverse(v975), load(tbl, 172 * VECWIDTH + tbloffset), times(v975, load(tbl, 173 * VECWIDTH + tbloffset))); + real2 v20 = load(in, 18 << inShift); + real2 v84 = load(in, 82 << inShift); + real2 v496 = plus(v20, v84); + real2 v492 = minus(v84, v20); + real2 v52 = load(in, 50 << inShift); + real2 v116 = load(in, 114 << inShift); + real2 v491 = reverse(minus(v116, v52)); + real2 v497 = plus(v52, v116); + real2 v817 = plus(v496, v497); + real2 v811 = reverse(minus(v497, v496)); + real2 v493 = minusplus(v491, v492); + real2 v495 = minusplus(uminus(v491), v492); + real2 v509 = timesminusplus(reverse(v495), load(tbl, 76 * VECWIDTH + tbloffset), times(v495, load(tbl, 77 * VECWIDTH + tbloffset))); + real2 v503 = timesminusplus(reverse(v493), load(tbl, 74 * VECWIDTH + tbloffset), times(v493, load(tbl, 75 * VECWIDTH + tbloffset))); + real2 v36 = load(in, 34 << inShift); + real2 v100 = load(in, 98 << inShift); + real2 v171 = reverse(minus(v100, v36)); + real2 v177 = plus(v36, v100); + real2 v68 = load(in, 66 << inShift); + real2 v4 = load(in, 2 << inShift); + real2 v176 = plus(v4, v68); + real2 v172 = minus(v68, v4); + real2 v816 = plus(v176, v177); + real2 v812 = minus(v177, v176); + real2 v1136 = plus(v816, v817); + real2 v1132 = minus(v817, v816); + real2 v1133 = minusplus(v1131, v1132); + real2 v1135 = minusplus(uminus(v1131), v1132); + real2 v1149 = timesminusplus(reverse(v1135), load(tbl, 204 * VECWIDTH + tbloffset), times(v1135, load(tbl, 205 * VECWIDTH + tbloffset))); + real2 v1296 = plus(v1136, v1137); + real2 v1292 = minus(v1137, v1136); + real2 v1295 = minusplus(uminus(v1291), v1292); + real2 v1293 = minusplus(v1291, v1292); + real2 v1303 = timesminusplus(reverse(v1293), load(tbl, 234 * VECWIDTH + tbloffset), times(v1293, load(tbl, 235 * VECWIDTH + tbloffset))); + real2 v1331 = reverse(minus(v1297, v1296)); + real2 v1337 = plus(v1296, v1297); + real2 v173 = minusplus(v171, v172); + real2 v175 = minusplus(uminus(v171), v172); + real2 v189 = timesminusplus(reverse(v175), load(tbl, 12 * VECWIDTH + tbloffset), times(v175, load(tbl, 13 * VECWIDTH + tbloffset))); + real2 v1309 = timesminusplus(reverse(v1295), load(tbl, 236 * VECWIDTH + tbloffset), times(v1295, load(tbl, 237 * VECWIDTH + tbloffset))); + real2 v815 = minusplus(uminus(v811), v812); + real2 v813 = minusplus(v811, v812); + real2 v1143 = timesminusplus(reverse(v1133), load(tbl, 202 * VECWIDTH + tbloffset), times(v1133, load(tbl, 203 * VECWIDTH + tbloffset))); + real2 v1541 = reverse(minus(v1229, v1149)); + real2 v1547 = plus(v1149, v1229); + real2 v2610 = plus(v189, v509); + real2 v2606 = minus(v509, v189); + real2 v2770 = plus(v2610, v2611); + real2 v2766 = minus(v2611, v2610); + real2 v823 = timesminusplus(reverse(v813), load(tbl, 138 * VECWIDTH + tbloffset), times(v813, load(tbl, 139 * VECWIDTH + tbloffset))); + real2 v829 = timesminusplus(reverse(v815), load(tbl, 140 * VECWIDTH + tbloffset), times(v815, load(tbl, 141 * VECWIDTH + tbloffset))); + real2 v2811 = plus(v2770, v2771); + real2 v2805 = reverse(minus(v2771, v2770)); + real2 v2767 = minusplus(v2765, v2766); + real2 v2769 = minusplus(uminus(v2765), v2766); + real2 v2607 = minusplus(v2605, v2606); + real2 v2609 = minusplus(uminus(v2605), v2606); + real2 v2617 = timesminusplus(reverse(v2607), load(tbl, 458 * VECWIDTH + tbloffset), times(v2607, load(tbl, 459 * VECWIDTH + tbloffset))); + real2 v2623 = timesminusplus(reverse(v2609), load(tbl, 460 * VECWIDTH + tbloffset), times(v2609, load(tbl, 461 * VECWIDTH + tbloffset))); + real2 v3013 = reverse(minus(v2703, v2623)); + real2 v3019 = plus(v2623, v2703); + real2 v2783 = timesminusplus(reverse(v2769), load(tbl, 492 * VECWIDTH + tbloffset), times(v2769, load(tbl, 493 * VECWIDTH + tbloffset))); + real2 v2941 = plus(v2617, v2697); + real2 v2935 = reverse(minus(v2697, v2617)); + real2 v2777 = timesminusplus(reverse(v2767), load(tbl, 490 * VECWIDTH + tbloffset), times(v2767, load(tbl, 491 * VECWIDTH + tbloffset))); + real2 v1660 = minus(v983, v823); + real2 v1664 = plus(v823, v983); + real2 v1874 = plus(v829, v989); + real2 v1870 = minus(v989, v829); + real2 v1909 = reverse(minus(v1875, v1874)); + real2 v1915 = plus(v1874, v1875); + real2 v1663 = minusplus(uminus(v1659), v1660); + real2 v1661 = minusplus(v1659, v1660); + real2 v1677 = timesminusplus(reverse(v1663), load(tbl, 296 * VECWIDTH + tbloffset), times(v1663, load(tbl, 297 * VECWIDTH + tbloffset))); + real2 v1873 = minusplus(uminus(v1869), v1870); + real2 v1871 = minusplus(v1869, v1870); + real2 v1887 = timesminusplus(reverse(v1873), load(tbl, 332 * VECWIDTH + tbloffset), times(v1873, load(tbl, 333 * VECWIDTH + tbloffset))); + real2 v1705 = plus(v1664, v1665); + real2 v1699 = reverse(minus(v1665, v1664)); + real2 v1671 = timesminusplus(reverse(v1661), load(tbl, 294 * VECWIDTH + tbloffset), times(v1661, load(tbl, 295 * VECWIDTH + tbloffset))); + real2 v1881 = timesminusplus(reverse(v1871), load(tbl, 330 * VECWIDTH + tbloffset), times(v1871, load(tbl, 331 * VECWIDTH + tbloffset))); + real2 v1469 = plus(v1143, v1223); + real2 v1463 = reverse(minus(v1223, v1143)); + real2 v54 = load(in, 52 << inShift); + real2 v118 = load(in, 116 << inShift); + real2 v537 = plus(v54, v118); + real2 v531 = reverse(minus(v118, v54)); + real2 v86 = load(in, 84 << inShift); + real2 v22 = load(in, 20 << inShift); + real2 v536 = plus(v22, v86); + real2 v532 = minus(v86, v22); + real2 v851 = reverse(minus(v537, v536)); + real2 v857 = plus(v536, v537); + real2 v533 = minusplus(v531, v532); + real2 v535 = minusplus(uminus(v531), v532); + real2 v549 = timesminusplus(reverse(v535), load(tbl, 84 * VECWIDTH + tbloffset), times(v535, load(tbl, 85 * VECWIDTH + tbloffset))); + real2 v102 = load(in, 100 << inShift); + real2 v38 = load(in, 36 << inShift); + real2 v217 = plus(v38, v102); + real2 v211 = reverse(minus(v102, v38)); + real2 v70 = load(in, 68 << inShift); + real2 v6 = load(in, 4 << inShift); + real2 v216 = plus(v6, v70); + real2 v212 = minus(v70, v6); + real2 v213 = minusplus(v211, v212); + real2 v215 = minusplus(uminus(v211), v212); + real2 v229 = timesminusplus(reverse(v215), load(tbl, 20 * VECWIDTH + tbloffset), times(v215, load(tbl, 21 * VECWIDTH + tbloffset))); + real2 v2646 = minus(v549, v229); + real2 v2650 = plus(v229, v549); + real2 v856 = plus(v216, v217); + real2 v852 = minus(v217, v216); + real2 v853 = minusplus(v851, v852); + real2 v855 = minusplus(uminus(v851), v852); + real2 v863 = timesminusplus(reverse(v853), load(tbl, 146 * VECWIDTH + tbloffset), times(v853, load(tbl, 147 * VECWIDTH + tbloffset))); + real2 v869 = timesminusplus(reverse(v855), load(tbl, 148 * VECWIDTH + tbloffset), times(v855, load(tbl, 149 * VECWIDTH + tbloffset))); + real2 v1176 = plus(v856, v857); + real2 v1172 = minus(v857, v856); + real2 v110 = load(in, 108 << inShift); + real2 v46 = load(in, 44 << inShift); + real2 v377 = plus(v46, v110); + real2 v371 = reverse(minus(v110, v46)); + real2 v78 = load(in, 76 << inShift); + real2 v14 = load(in, 12 << inShift); + real2 v372 = minus(v78, v14); + real2 v376 = plus(v14, v78); + real2 v1012 = minus(v377, v376); + real2 v1016 = plus(v376, v377); + real2 v373 = minusplus(v371, v372); + real2 v375 = minusplus(uminus(v371), v372); + real2 v389 = timesminusplus(reverse(v375), load(tbl, 52 * VECWIDTH + tbloffset), times(v375, load(tbl, 53 * VECWIDTH + tbloffset))); + real2 v30 = load(in, 28 << inShift); + real2 v94 = load(in, 92 << inShift); + real2 v696 = plus(v30, v94); + real2 v692 = minus(v94, v30); + real2 v62 = load(in, 60 << inShift); + real2 v126 = load(in, 124 << inShift); + real2 v697 = plus(v62, v126); + real2 v691 = reverse(minus(v126, v62)); + real2 v1017 = plus(v696, v697); + real2 v1011 = reverse(minus(v697, v696)); + real2 v1171 = reverse(minus(v1017, v1016)); + real2 v1177 = plus(v1016, v1017); + real2 v1013 = minusplus(v1011, v1012); + real2 v1015 = minusplus(uminus(v1011), v1012); + real2 v1175 = minusplus(uminus(v1171), v1172); + real2 v1173 = minusplus(v1171, v1172); + real2 v1183 = timesminusplus(reverse(v1173), load(tbl, 210 * VECWIDTH + tbloffset), times(v1173, load(tbl, 211 * VECWIDTH + tbloffset))); + real2 v1189 = timesminusplus(reverse(v1175), load(tbl, 212 * VECWIDTH + tbloffset), times(v1175, load(tbl, 213 * VECWIDTH + tbloffset))); + real2 v1029 = timesminusplus(reverse(v1015), load(tbl, 180 * VECWIDTH + tbloffset), times(v1015, load(tbl, 181 * VECWIDTH + tbloffset))); + real2 v1023 = timesminusplus(reverse(v1013), load(tbl, 178 * VECWIDTH + tbloffset), times(v1013, load(tbl, 179 * VECWIDTH + tbloffset))); + real2 v1625 = plus(v863, v1023); + real2 v1619 = reverse(minus(v1023, v863)); + real2 v1835 = plus(v869, v1029); + real2 v1829 = reverse(minus(v1029, v869)); + real2 v693 = minusplus(v691, v692); + real2 v695 = minusplus(uminus(v691), v692); + real2 v709 = timesminusplus(reverse(v695), load(tbl, 116 * VECWIDTH + tbloffset), times(v695, load(tbl, 117 * VECWIDTH + tbloffset))); + real2 v2645 = reverse(minus(v709, v389)); + real2 v2651 = plus(v389, v709); + real2 v1257 = plus(v1176, v1177); + real2 v1251 = reverse(minus(v1177, v1176)); + real2 v2731 = plus(v2650, v2651); + real2 v2725 = reverse(minus(v2651, v2650)); + real2 v114 = load(in, 112 << inShift); + real2 v50 = load(in, 48 << inShift); + real2 v457 = plus(v50, v114); + real2 v451 = reverse(minus(v114, v50)); + real2 v18 = load(in, 16 << inShift); + real2 v82 = load(in, 80 << inShift); + real2 v456 = plus(v18, v82); + real2 v452 = minus(v82, v18); + real2 v771 = reverse(minus(v457, v456)); + real2 v777 = plus(v456, v457); + real2 v453 = minusplus(v451, v452); + real2 v455 = minusplus(uminus(v451), v452); + real2 v469 = timesminusplus(reverse(v455), load(tbl, 68 * VECWIDTH + tbloffset), times(v455, load(tbl, 69 * VECWIDTH + tbloffset))); + real2 v66 = load(in, 64 << inShift); + real2 v2 = load(in, 0 << inShift); + real2 v132 = minus(v66, v2); + real2 v136 = plus(v2, v66); + real2 v98 = load(in, 96 << inShift); + real2 v34 = load(in, 32 << inShift); + real2 v131 = reverse(minus(v98, v34)); + real2 v137 = plus(v34, v98); + real2 v133 = minusplus(v131, v132); + real2 v135 = minusplus(uminus(v131), v132); + real2 v149 = timesminusplus(reverse(v135), load(tbl, 4 * VECWIDTH + tbloffset), times(v135, load(tbl, 5 * VECWIDTH + tbloffset))); + real2 v2566 = minus(v469, v149); + real2 v2570 = plus(v149, v469); + real2 v772 = minus(v137, v136); + real2 v776 = plus(v136, v137); + real2 v1092 = minus(v777, v776); + real2 v1096 = plus(v776, v777); + real2 v773 = minusplus(v771, v772); + real2 v775 = minusplus(uminus(v771), v772); + real2 v783 = timesminusplus(reverse(v773), load(tbl, 130 * VECWIDTH + tbloffset), times(v773, load(tbl, 131 * VECWIDTH + tbloffset))); + real2 v789 = timesminusplus(reverse(v775), load(tbl, 132 * VECWIDTH + tbloffset), times(v775, load(tbl, 133 * VECWIDTH + tbloffset))); + real2 v74 = load(in, 72 << inShift); + real2 v10 = load(in, 8 << inShift); + real2 v296 = plus(v10, v74); + real2 v292 = minus(v74, v10); + real2 v42 = load(in, 40 << inShift); + real2 v106 = load(in, 104 << inShift); + real2 v291 = reverse(minus(v106, v42)); + real2 v297 = plus(v42, v106); + real2 v293 = minusplus(v291, v292); + real2 v295 = minusplus(uminus(v291), v292); + real2 v309 = timesminusplus(reverse(v295), load(tbl, 36 * VECWIDTH + tbloffset), times(v295, load(tbl, 37 * VECWIDTH + tbloffset))); + real2 v932 = minus(v297, v296); + real2 v936 = plus(v296, v297); + real2 v122 = load(in, 120 << inShift); + real2 v58 = load(in, 56 << inShift); + real2 v617 = plus(v58, v122); + real2 v611 = reverse(minus(v122, v58)); + real2 v26 = load(in, 24 << inShift); + real2 v90 = load(in, 88 << inShift); + real2 v612 = minus(v90, v26); + real2 v616 = plus(v26, v90); + real2 v937 = plus(v616, v617); + real2 v931 = reverse(minus(v617, v616)); + real2 v1091 = reverse(minus(v937, v936)); + real2 v1097 = plus(v936, v937); + real2 v933 = minusplus(v931, v932); + real2 v935 = minusplus(uminus(v931), v932); + real2 v1093 = minusplus(v1091, v1092); + real2 v1095 = minusplus(uminus(v1091), v1092); + real2 v1103 = timesminusplus(reverse(v1093), load(tbl, 194 * VECWIDTH + tbloffset), times(v1093, load(tbl, 195 * VECWIDTH + tbloffset))); + real2 v1468 = plus(v1103, v1183); + real2 v1464 = minus(v1183, v1103); + real2 v1508 = plus(v1468, v1469); + real2 v1504 = minus(v1469, v1468); + real2 v1252 = minus(v1097, v1096); + real2 v1256 = plus(v1096, v1097); + real2 v1336 = plus(v1256, v1257); + real2 v1332 = minus(v1257, v1256); + real2 v1335 = minusplus(uminus(v1331), v1332); + real2 v1333 = minusplus(v1331, v1332); + real2 v1343 = timesminusplus(reverse(v1333), load(tbl, 242 * VECWIDTH + tbloffset), times(v1333, load(tbl, 243 * VECWIDTH + tbloffset))); + real2 v1349 = timesminusplus(reverse(v1335), load(tbl, 244 * VECWIDTH + tbloffset), times(v1335, load(tbl, 245 * VECWIDTH + tbloffset))); + real2 v1376 = plus(v1336, v1337); + real2 v1372 = minus(v1337, v1336); + real2 v1465 = minusplus(v1463, v1464); + real2 v1467 = minusplus(uminus(v1463), v1464); + real2 v1255 = minusplus(uminus(v1251), v1252); + real2 v1253 = minusplus(v1251, v1252); + real2 v1481 = timesminusplus(reverse(v1467), load(tbl, 264 * VECWIDTH + tbloffset), times(v1467, load(tbl, 265 * VECWIDTH + tbloffset))); + real2 v1475 = timesminusplus(reverse(v1465), load(tbl, 262 * VECWIDTH + tbloffset), times(v1465, load(tbl, 263 * VECWIDTH + tbloffset))); + real2 v1109 = timesminusplus(reverse(v1095), load(tbl, 196 * VECWIDTH + tbloffset), times(v1095, load(tbl, 197 * VECWIDTH + tbloffset))); + real2 v1542 = minus(v1189, v1109); + real2 v1546 = plus(v1109, v1189); + real2 v1545 = minusplus(uminus(v1541), v1542); + real2 v1543 = minusplus(v1541, v1542); + real2 v1553 = timesminusplus(reverse(v1543), load(tbl, 274 * VECWIDTH + tbloffset), times(v1543, load(tbl, 275 * VECWIDTH + tbloffset))); + real2 v1559 = timesminusplus(reverse(v1545), load(tbl, 276 * VECWIDTH + tbloffset), times(v1545, load(tbl, 277 * VECWIDTH + tbloffset))); + real2 v1582 = minus(v1547, v1546); + real2 v1586 = plus(v1546, v1547); + real2 v1269 = timesminusplus(reverse(v1255), load(tbl, 228 * VECWIDTH + tbloffset), times(v1255, load(tbl, 229 * VECWIDTH + tbloffset))); + real2 v1438 = minus(v1309, v1269); + real2 v1442 = plus(v1269, v1309); + real2 v1263 = timesminusplus(reverse(v1253), load(tbl, 226 * VECWIDTH + tbloffset), times(v1253, load(tbl, 227 * VECWIDTH + tbloffset))); + real2 v943 = timesminusplus(reverse(v933), load(tbl, 162 * VECWIDTH + tbloffset), times(v933, load(tbl, 163 * VECWIDTH + tbloffset))); + real2 v1624 = plus(v783, v943); + real2 v1620 = minus(v943, v783); + real2 v1623 = minusplus(uminus(v1619), v1620); + real2 v1621 = minusplus(v1619, v1620); + real2 v1700 = minus(v1625, v1624); + real2 v1704 = plus(v1624, v1625); + real2 v1631 = timesminusplus(reverse(v1621), load(tbl, 286 * VECWIDTH + tbloffset), times(v1621, load(tbl, 287 * VECWIDTH + tbloffset))); + real2 v949 = timesminusplus(reverse(v935), load(tbl, 164 * VECWIDTH + tbloffset), times(v935, load(tbl, 165 * VECWIDTH + tbloffset))); + real2 v1830 = minus(v949, v789); + real2 v1834 = plus(v789, v949); + real2 v1782 = plus(v1631, v1671); + real2 v1778 = minus(v1671, v1631); + real2 v1910 = minus(v1835, v1834); + real2 v1914 = plus(v1834, v1835); + real2 v1950 = minus(v1915, v1914); + real2 v1954 = plus(v1914, v1915); + real2 v1913 = minusplus(uminus(v1909), v1910); + real2 v1911 = minusplus(v1909, v1910); + real2 v613 = minusplus(v611, v612); + real2 v615 = minusplus(uminus(v611), v612); + real2 v629 = timesminusplus(reverse(v615), load(tbl, 100 * VECWIDTH + tbloffset), times(v615, load(tbl, 101 * VECWIDTH + tbloffset))); + real2 v1744 = plus(v1704, v1705); + real2 v1740 = minus(v1705, v1704); + real2 v1637 = timesminusplus(reverse(v1623), load(tbl, 288 * VECWIDTH + tbloffset), times(v1623, load(tbl, 289 * VECWIDTH + tbloffset))); + real2 v1927 = timesminusplus(reverse(v1913), load(tbl, 340 * VECWIDTH + tbloffset), times(v1913, load(tbl, 341 * VECWIDTH + tbloffset))); + real2 v2571 = plus(v309, v629); + real2 v2565 = reverse(minus(v629, v309)); + real2 v1833 = minusplus(uminus(v1829), v1830); + real2 v1831 = minusplus(v1829, v1830); + real2 v1921 = timesminusplus(reverse(v1911), load(tbl, 338 * VECWIDTH + tbloffset), times(v1911, load(tbl, 339 * VECWIDTH + tbloffset))); + real2 v1804 = minus(v1677, v1637); + real2 v1808 = plus(v1637, v1677); + real2 v1847 = timesminusplus(reverse(v1833), load(tbl, 324 * VECWIDTH + tbloffset), times(v1833, load(tbl, 325 * VECWIDTH + tbloffset))); + real2 v2014 = minus(v1887, v1847); + real2 v2018 = plus(v1847, v1887); + real2 v1841 = timesminusplus(reverse(v1831), load(tbl, 322 * VECWIDTH + tbloffset), times(v1831, load(tbl, 323 * VECWIDTH + tbloffset))); + real2 v1988 = minus(v1881, v1841); + real2 v1992 = plus(v1841, v1881); + real2 v1703 = minusplus(uminus(v1699), v1700); + real2 v1701 = minusplus(v1699, v1700); + real2 v1717 = timesminusplus(reverse(v1703), load(tbl, 304 * VECWIDTH + tbloffset), times(v1703, load(tbl, 305 * VECWIDTH + tbloffset))); + real2 v1711 = timesminusplus(reverse(v1701), load(tbl, 302 * VECWIDTH + tbloffset), times(v1701, load(tbl, 303 * VECWIDTH + tbloffset))); + real2 v2730 = plus(v2570, v2571); + real2 v2726 = minus(v2571, v2570); + real2 v1412 = minus(v1303, v1263); + real2 v1416 = plus(v1263, v1303); + real2 v63 = load(in, 61 << inShift); + real2 v127 = load(in, 125 << inShift); + real2 v717 = plus(v63, v127); + real2 v711 = reverse(minus(v127, v63)); + real2 v95 = load(in, 93 << inShift); + real2 v31 = load(in, 29 << inShift); + real2 v712 = minus(v95, v31); + real2 v716 = plus(v31, v95); + real2 v1037 = plus(v716, v717); + real2 v1031 = reverse(minus(v717, v716)); + real2 v79 = load(in, 77 << inShift); + real2 v15 = load(in, 13 << inShift); + real2 v396 = plus(v15, v79); + real2 v392 = minus(v79, v15); + real2 v111 = load(in, 109 << inShift); + real2 v47 = load(in, 45 << inShift); + real2 v397 = plus(v47, v111); + real2 v391 = reverse(minus(v111, v47)); + real2 v1032 = minus(v397, v396); + real2 v1036 = plus(v396, v397); + real2 v1033 = minusplus(v1031, v1032); + real2 v1035 = minusplus(uminus(v1031), v1032); + real2 v1049 = timesminusplus(reverse(v1035), load(tbl, 184 * VECWIDTH + tbloffset), times(v1035, load(tbl, 185 * VECWIDTH + tbloffset))); + real2 v1043 = timesminusplus(reverse(v1033), load(tbl, 182 * VECWIDTH + tbloffset), times(v1033, load(tbl, 183 * VECWIDTH + tbloffset))); + real2 v1197 = plus(v1036, v1037); + real2 v1191 = reverse(minus(v1037, v1036)); + real2 v23 = load(in, 21 << inShift); + real2 v87 = load(in, 85 << inShift); + real2 v556 = plus(v23, v87); + real2 v552 = minus(v87, v23); + real2 v119 = load(in, 117 << inShift); + real2 v55 = load(in, 53 << inShift); + real2 v557 = plus(v55, v119); + real2 v551 = reverse(minus(v119, v55)); + real2 v877 = plus(v556, v557); + real2 v871 = reverse(minus(v557, v556)); + real2 v7 = load(in, 5 << inShift); + real2 v71 = load(in, 69 << inShift); + real2 v232 = minus(v71, v7); + real2 v236 = plus(v7, v71); + real2 v103 = load(in, 101 << inShift); + real2 v39 = load(in, 37 << inShift); + real2 v237 = plus(v39, v103); + real2 v231 = reverse(minus(v103, v39)); + real2 v876 = plus(v236, v237); + real2 v872 = minus(v237, v236); + real2 v1192 = minus(v877, v876); + real2 v1196 = plus(v876, v877); + real2 v1271 = reverse(minus(v1197, v1196)); + real2 v1277 = plus(v1196, v1197); + real2 v875 = minusplus(uminus(v871), v872); + real2 v873 = minusplus(v871, v872); + real2 v883 = timesminusplus(reverse(v873), load(tbl, 150 * VECWIDTH + tbloffset), times(v873, load(tbl, 151 * VECWIDTH + tbloffset))); + real2 v1639 = reverse(minus(v1043, v883)); + real2 v1645 = plus(v883, v1043); + real2 v1195 = minusplus(uminus(v1191), v1192); + real2 v1193 = minusplus(v1191, v1192); + real2 v1209 = timesminusplus(reverse(v1195), load(tbl, 216 * VECWIDTH + tbloffset), times(v1195, load(tbl, 217 * VECWIDTH + tbloffset))); + real2 v1203 = timesminusplus(reverse(v1193), load(tbl, 214 * VECWIDTH + tbloffset), times(v1193, load(tbl, 215 * VECWIDTH + tbloffset))); + real2 v83 = load(in, 81 << inShift); + real2 v19 = load(in, 17 << inShift); + real2 v476 = plus(v19, v83); + real2 v472 = minus(v83, v19); + real2 v51 = load(in, 49 << inShift); + real2 v115 = load(in, 113 << inShift); + real2 v477 = plus(v51, v115); + real2 v471 = reverse(minus(v115, v51)); + real2 v797 = plus(v476, v477); + real2 v791 = reverse(minus(v477, v476)); + real2 v3 = load(in, 1 << inShift); + real2 v67 = load(in, 65 << inShift); + real2 v156 = plus(v3, v67); + real2 v152 = minus(v67, v3); + real2 v35 = load(in, 33 << inShift); + real2 v99 = load(in, 97 << inShift); + real2 v157 = plus(v35, v99); + real2 v151 = reverse(minus(v99, v35)); + real2 v792 = minus(v157, v156); + real2 v796 = plus(v156, v157); + real2 v793 = minusplus(v791, v792); + real2 v795 = minusplus(uminus(v791), v792); + real2 v803 = timesminusplus(reverse(v793), load(tbl, 134 * VECWIDTH + tbloffset), times(v793, load(tbl, 135 * VECWIDTH + tbloffset))); + real2 v1112 = minus(v797, v796); + real2 v1116 = plus(v796, v797); + real2 v107 = load(in, 105 << inShift); + real2 v43 = load(in, 41 << inShift); + real2 v317 = plus(v43, v107); + real2 v311 = reverse(minus(v107, v43)); + real2 v75 = load(in, 73 << inShift); + real2 v11 = load(in, 9 << inShift); + real2 v316 = plus(v11, v75); + real2 v312 = minus(v75, v11); + real2 v956 = plus(v316, v317); + real2 v952 = minus(v317, v316); + real2 v59 = load(in, 57 << inShift); + real2 v123 = load(in, 121 << inShift); + real2 v631 = reverse(minus(v123, v59)); + real2 v637 = plus(v59, v123); + real2 v27 = load(in, 25 << inShift); + real2 v91 = load(in, 89 << inShift); + real2 v636 = plus(v27, v91); + real2 v632 = minus(v91, v27); + real2 v957 = plus(v636, v637); + real2 v951 = reverse(minus(v637, v636)); + real2 v1111 = reverse(minus(v957, v956)); + real2 v1117 = plus(v956, v957); + real2 v1276 = plus(v1116, v1117); + real2 v1272 = minus(v1117, v1116); + real2 v1275 = minusplus(uminus(v1271), v1272); + real2 v1273 = minusplus(v1271, v1272); + real2 v1283 = timesminusplus(reverse(v1273), load(tbl, 230 * VECWIDTH + tbloffset), times(v1273, load(tbl, 231 * VECWIDTH + tbloffset))); + real2 v1352 = minus(v1277, v1276); + real2 v1356 = plus(v1276, v1277); + real2 v1289 = timesminusplus(reverse(v1275), load(tbl, 232 * VECWIDTH + tbloffset), times(v1275, load(tbl, 233 * VECWIDTH + tbloffset))); + real2 v1115 = minusplus(uminus(v1111), v1112); + real2 v1113 = minusplus(v1111, v1112); + real2 v1123 = timesminusplus(reverse(v1113), load(tbl, 198 * VECWIDTH + tbloffset), times(v1113, load(tbl, 199 * VECWIDTH + tbloffset))); + real2 v1129 = timesminusplus(reverse(v1115), load(tbl, 200 * VECWIDTH + tbloffset), times(v1115, load(tbl, 201 * VECWIDTH + tbloffset))); + real2 v1488 = plus(v1123, v1203); + real2 v1484 = minus(v1203, v1123); + real2 v1566 = plus(v1129, v1209); + real2 v1562 = minus(v1209, v1129); + real2 v85 = load(in, 83 << inShift); + real2 v21 = load(in, 19 << inShift); + real2 v512 = minus(v85, v21); + real2 v516 = plus(v21, v85); + real2 v117 = load(in, 115 << inShift); + real2 v53 = load(in, 51 << inShift); + real2 v517 = plus(v53, v117); + real2 v511 = reverse(minus(v117, v53)); + real2 v831 = reverse(minus(v517, v516)); + real2 v837 = plus(v516, v517); + real2 v69 = load(in, 67 << inShift); + real2 v5 = load(in, 3 << inShift); + real2 v192 = minus(v69, v5); + real2 v196 = plus(v5, v69); + real2 v37 = load(in, 35 << inShift); + real2 v101 = load(in, 99 << inShift); + real2 v197 = plus(v37, v101); + real2 v191 = reverse(minus(v101, v37)); + real2 v832 = minus(v197, v196); + real2 v836 = plus(v196, v197); + real2 v1152 = minus(v837, v836); + real2 v1156 = plus(v836, v837); + real2 v61 = load(in, 59 << inShift); + real2 v125 = load(in, 123 << inShift); + real2 v677 = plus(v61, v125); + real2 v671 = reverse(minus(v125, v61)); + real2 v29 = load(in, 27 << inShift); + real2 v93 = load(in, 91 << inShift); + real2 v672 = minus(v93, v29); + real2 v676 = plus(v29, v93); + real2 v997 = plus(v676, v677); + real2 v991 = reverse(minus(v677, v676)); + real2 v109 = load(in, 107 << inShift); + real2 v45 = load(in, 43 << inShift); + real2 v357 = plus(v45, v109); + real2 v351 = reverse(minus(v109, v45)); + real2 v77 = load(in, 75 << inShift); + real2 v13 = load(in, 11 << inShift); + real2 v352 = minus(v77, v13); + real2 v356 = plus(v13, v77); + real2 v992 = minus(v357, v356); + real2 v996 = plus(v356, v357); + real2 v1157 = plus(v996, v997); + real2 v1151 = reverse(minus(v997, v996)); + real2 v1155 = minusplus(uminus(v1151), v1152); + real2 v1153 = minusplus(v1151, v1152); + real2 v1163 = timesminusplus(reverse(v1153), load(tbl, 206 * VECWIDTH + tbloffset), times(v1153, load(tbl, 207 * VECWIDTH + tbloffset))); + real2 v1316 = plus(v1156, v1157); + real2 v1312 = minus(v1157, v1156); + real2 v41 = load(in, 39 << inShift); + real2 v105 = load(in, 103 << inShift); + real2 v277 = plus(v41, v105); + real2 v271 = reverse(minus(v105, v41)); + real2 v9 = load(in, 7 << inShift); + real2 v73 = load(in, 71 << inShift); + real2 v276 = plus(v9, v73); + real2 v272 = minus(v73, v9); + real2 v916 = plus(v276, v277); + real2 v912 = minus(v277, v276); + real2 v89 = load(in, 87 << inShift); + real2 v25 = load(in, 23 << inShift); + real2 v592 = minus(v89, v25); + real2 v596 = plus(v25, v89); + real2 v57 = load(in, 55 << inShift); + real2 v121 = load(in, 119 << inShift); + real2 v591 = reverse(minus(v121, v57)); + real2 v597 = plus(v57, v121); + real2 v911 = reverse(minus(v597, v596)); + real2 v917 = plus(v596, v597); + real2 v1236 = plus(v916, v917); + real2 v1232 = minus(v917, v916); + real2 v81 = load(in, 79 << inShift); + real2 v17 = load(in, 15 << inShift); + real2 v432 = minus(v81, v17); + real2 v436 = plus(v17, v81); + real2 v113 = load(in, 111 << inShift); + real2 v49 = load(in, 47 << inShift); + real2 v437 = plus(v49, v113); + real2 v431 = reverse(minus(v113, v49)); + real2 v1072 = minus(v437, v436); + real2 v1076 = plus(v436, v437); + real2 v65 = load(in, 63 << inShift); + real2 v129 = load(in, 127 << inShift); + real2 v757 = plus(v65, v129); + real2 v751 = reverse(minus(v129, v65)); + real2 v97 = load(in, 95 << inShift); + real2 v33 = load(in, 31 << inShift); + real2 v752 = minus(v97, v33); + real2 v756 = plus(v33, v97); + real2 v1077 = plus(v756, v757); + real2 v1071 = reverse(minus(v757, v756)); + real2 v1231 = reverse(minus(v1077, v1076)); + real2 v1237 = plus(v1076, v1077); + real2 v1317 = plus(v1236, v1237); + real2 v1311 = reverse(minus(v1237, v1236)); + real2 v1351 = reverse(minus(v1317, v1316)); + real2 v1357 = plus(v1316, v1317); + real2 v1371 = reverse(minus(v1357, v1356)); + real2 v1377 = plus(v1356, v1357); + scatter(out, 0, 128, plus(v1376, v1377)); + real2 v1390 = minus(v1376, v1377); + scatter(out, 64, 128, timesminusplus(v1390, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v1390), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v1353 = minusplus(v1351, v1352); + real2 v1355 = minusplus(uminus(v1351), v1352); + real2 v1369 = timesminusplus(reverse(v1355), load(tbl, 248 * VECWIDTH + tbloffset), times(v1355, load(tbl, 249 * VECWIDTH + tbloffset))); + scatter(out, 48, 128, plus(v1349, v1369)); + real2 v1404 = minus(v1349, v1369); + scatter(out, 112, 128, timesminusplus(v1404, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v1404), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v1363 = timesminusplus(reverse(v1353), load(tbl, 246 * VECWIDTH + tbloffset), times(v1353, load(tbl, 247 * VECWIDTH + tbloffset))); + scatter(out, 16, 128, plus(v1343, v1363)); + real2 v1398 = minus(v1343, v1363); + scatter(out, 80, 128, timesminusplus(v1398, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v1398), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v1373 = minusplus(v1371, v1372); + real2 v1375 = minusplus(uminus(v1371), v1372); + scatter(out, 96, 128, timesminusplus(reverse(v1375), load(tbl, 252 * VECWIDTH + tbloffset), times(v1375, load(tbl, 253 * VECWIDTH + tbloffset)))); + scatter(out, 32, 128, timesminusplus(reverse(v1373), load(tbl, 250 * VECWIDTH + tbloffset), times(v1373, load(tbl, 251 * VECWIDTH + tbloffset)))); + real2 v1313 = minusplus(v1311, v1312); + real2 v1315 = minusplus(uminus(v1311), v1312); + real2 v1323 = timesminusplus(reverse(v1313), load(tbl, 238 * VECWIDTH + tbloffset), times(v1313, load(tbl, 239 * VECWIDTH + tbloffset))); + real2 v1417 = plus(v1283, v1323); + real2 v1411 = reverse(minus(v1323, v1283)); + scatter(out, 8, 128, plus(v1416, v1417)); + real2 v1430 = minus(v1416, v1417); + scatter(out, 72, 128, timesminusplus(v1430, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v1430), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v1413 = minusplus(v1411, v1412); + real2 v1415 = minusplus(uminus(v1411), v1412); + scatter(out, 104, 128, timesminusplus(reverse(v1415), load(tbl, 256 * VECWIDTH + tbloffset), times(v1415, load(tbl, 257 * VECWIDTH + tbloffset)))); + scatter(out, 40, 128, timesminusplus(reverse(v1413), load(tbl, 254 * VECWIDTH + tbloffset), times(v1413, load(tbl, 255 * VECWIDTH + tbloffset)))); + real2 v1329 = timesminusplus(reverse(v1315), load(tbl, 240 * VECWIDTH + tbloffset), times(v1315, load(tbl, 241 * VECWIDTH + tbloffset))); + real2 v1443 = plus(v1289, v1329); + real2 v1437 = reverse(minus(v1329, v1289)); + scatter(out, 24, 128, plus(v1442, v1443)); + real2 v1456 = minus(v1442, v1443); + scatter(out, 88, 128, timesminusplus(v1456, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v1456), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v1441 = minusplus(uminus(v1437), v1438); + real2 v1439 = minusplus(v1437, v1438); + scatter(out, 120, 128, timesminusplus(reverse(v1441), load(tbl, 260 * VECWIDTH + tbloffset), times(v1441, load(tbl, 261 * VECWIDTH + tbloffset)))); + scatter(out, 56, 128, timesminusplus(reverse(v1439), load(tbl, 258 * VECWIDTH + tbloffset), times(v1439, load(tbl, 259 * VECWIDTH + tbloffset)))); + real2 v1235 = minusplus(uminus(v1231), v1232); + real2 v1233 = minusplus(v1231, v1232); + real2 v1243 = timesminusplus(reverse(v1233), load(tbl, 222 * VECWIDTH + tbloffset), times(v1233, load(tbl, 223 * VECWIDTH + tbloffset))); + real2 v1489 = plus(v1163, v1243); + real2 v1483 = reverse(minus(v1243, v1163)); + real2 v1509 = plus(v1488, v1489); + real2 v1503 = reverse(minus(v1489, v1488)); + scatter(out, 4, 128, plus(v1508, v1509)); + real2 v1522 = minus(v1508, v1509); + scatter(out, 68, 128, timesminusplus(v1522, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v1522), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v1507 = minusplus(uminus(v1503), v1504); + real2 v1505 = minusplus(v1503, v1504); + scatter(out, 36, 128, timesminusplus(reverse(v1505), load(tbl, 270 * VECWIDTH + tbloffset), times(v1505, load(tbl, 271 * VECWIDTH + tbloffset)))); + scatter(out, 100, 128, timesminusplus(reverse(v1507), load(tbl, 272 * VECWIDTH + tbloffset), times(v1507, load(tbl, 273 * VECWIDTH + tbloffset)))); + real2 v1485 = minusplus(v1483, v1484); + real2 v1487 = minusplus(uminus(v1483), v1484); + real2 v1501 = timesminusplus(reverse(v1487), load(tbl, 268 * VECWIDTH + tbloffset), times(v1487, load(tbl, 269 * VECWIDTH + tbloffset))); + scatter(out, 52, 128, plus(v1481, v1501)); + real2 v1534 = minus(v1481, v1501); + scatter(out, 116, 128, timesminusplus(v1534, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v1534), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v1495 = timesminusplus(reverse(v1485), load(tbl, 266 * VECWIDTH + tbloffset), times(v1485, load(tbl, 267 * VECWIDTH + tbloffset))); + scatter(out, 20, 128, plus(v1475, v1495)); + real2 v1528 = minus(v1475, v1495); + scatter(out, 84, 128, timesminusplus(v1528, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v1528), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v1249 = timesminusplus(reverse(v1235), load(tbl, 224 * VECWIDTH + tbloffset), times(v1235, load(tbl, 225 * VECWIDTH + tbloffset))); + real2 v1169 = timesminusplus(reverse(v1155), load(tbl, 208 * VECWIDTH + tbloffset), times(v1155, load(tbl, 209 * VECWIDTH + tbloffset))); + real2 v1567 = plus(v1169, v1249); + real2 v1561 = reverse(minus(v1249, v1169)); + real2 v1581 = reverse(minus(v1567, v1566)); + real2 v1587 = plus(v1566, v1567); + scatter(out, 12, 128, plus(v1586, v1587)); + real2 v1600 = minus(v1586, v1587); + scatter(out, 76, 128, timesminusplus(v1600, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v1600), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v1583 = minusplus(v1581, v1582); + scatter(out, 44, 128, timesminusplus(reverse(v1583), load(tbl, 282 * VECWIDTH + tbloffset), times(v1583, load(tbl, 283 * VECWIDTH + tbloffset)))); + real2 v1585 = minusplus(uminus(v1581), v1582); + scatter(out, 108, 128, timesminusplus(reverse(v1585), load(tbl, 284 * VECWIDTH + tbloffset), times(v1585, load(tbl, 285 * VECWIDTH + tbloffset)))); + real2 v1565 = minusplus(uminus(v1561), v1562); + real2 v1563 = minusplus(v1561, v1562); + real2 v1579 = timesminusplus(reverse(v1565), load(tbl, 280 * VECWIDTH + tbloffset), times(v1565, load(tbl, 281 * VECWIDTH + tbloffset))); + scatter(out, 60, 128, plus(v1559, v1579)); + real2 v1612 = minus(v1559, v1579); + scatter(out, 124, 128, timesminusplus(v1612, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v1612), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v1573 = timesminusplus(reverse(v1563), load(tbl, 278 * VECWIDTH + tbloffset), times(v1563, load(tbl, 279 * VECWIDTH + tbloffset))); + scatter(out, 28, 128, plus(v1553, v1573)); + real2 v1606 = minus(v1553, v1573); + scatter(out, 92, 128, timesminusplus(v1606, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v1606), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v833 = minusplus(v831, v832); + real2 v835 = minusplus(uminus(v831), v832); + real2 v955 = minusplus(uminus(v951), v952); + real2 v953 = minusplus(v951, v952); + real2 v963 = timesminusplus(reverse(v953), load(tbl, 166 * VECWIDTH + tbloffset), times(v953, load(tbl, 167 * VECWIDTH + tbloffset))); + real2 v995 = minusplus(uminus(v991), v992); + real2 v993 = minusplus(v991, v992); + real2 v1003 = timesminusplus(reverse(v993), load(tbl, 174 * VECWIDTH + tbloffset), times(v993, load(tbl, 175 * VECWIDTH + tbloffset))); + real2 v843 = timesminusplus(reverse(v833), load(tbl, 142 * VECWIDTH + tbloffset), times(v833, load(tbl, 143 * VECWIDTH + tbloffset))); + real2 v1640 = minus(v963, v803); + real2 v1644 = plus(v803, v963); + real2 v1680 = minus(v1003, v843); + real2 v1684 = plus(v843, v1003); + real2 v1641 = minusplus(v1639, v1640); + real2 v1643 = minusplus(uminus(v1639), v1640); + real2 v1657 = timesminusplus(reverse(v1643), load(tbl, 292 * VECWIDTH + tbloffset), times(v1643, load(tbl, 293 * VECWIDTH + tbloffset))); + real2 v913 = minusplus(v911, v912); + real2 v915 = minusplus(uminus(v911), v912); + real2 v1073 = minusplus(v1071, v1072); + real2 v1075 = minusplus(uminus(v1071), v1072); + real2 v923 = timesminusplus(reverse(v913), load(tbl, 158 * VECWIDTH + tbloffset), times(v913, load(tbl, 159 * VECWIDTH + tbloffset))); + real2 v1083 = timesminusplus(reverse(v1073), load(tbl, 190 * VECWIDTH + tbloffset), times(v1073, load(tbl, 191 * VECWIDTH + tbloffset))); + real2 v1685 = plus(v923, v1083); + real2 v1679 = reverse(minus(v1083, v923)); + real2 v1681 = minusplus(v1679, v1680); + real2 v1683 = minusplus(uminus(v1679), v1680); + real2 v1697 = timesminusplus(reverse(v1683), load(tbl, 300 * VECWIDTH + tbloffset), times(v1683, load(tbl, 301 * VECWIDTH + tbloffset))); + real2 v1809 = plus(v1657, v1697); + real2 v1803 = reverse(minus(v1697, v1657)); + scatter(out, 26, 128, plus(v1808, v1809)); + real2 v1822 = minus(v1808, v1809); + scatter(out, 90, 128, timesminusplus(v1822, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v1822), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v1807 = minusplus(uminus(v1803), v1804); + real2 v1805 = minusplus(v1803, v1804); + scatter(out, 58, 128, timesminusplus(reverse(v1805), load(tbl, 318 * VECWIDTH + tbloffset), times(v1805, load(tbl, 319 * VECWIDTH + tbloffset)))); + scatter(out, 122, 128, timesminusplus(reverse(v1807), load(tbl, 320 * VECWIDTH + tbloffset), times(v1807, load(tbl, 321 * VECWIDTH + tbloffset)))); + real2 v1651 = timesminusplus(reverse(v1641), load(tbl, 290 * VECWIDTH + tbloffset), times(v1641, load(tbl, 291 * VECWIDTH + tbloffset))); + real2 v1691 = timesminusplus(reverse(v1681), load(tbl, 298 * VECWIDTH + tbloffset), times(v1681, load(tbl, 299 * VECWIDTH + tbloffset))); + real2 v1783 = plus(v1651, v1691); + real2 v1777 = reverse(minus(v1691, v1651)); + real2 v1779 = minusplus(v1777, v1778); + real2 v1781 = minusplus(uminus(v1777), v1778); + scatter(out, 106, 128, timesminusplus(reverse(v1781), load(tbl, 316 * VECWIDTH + tbloffset), times(v1781, load(tbl, 317 * VECWIDTH + tbloffset)))); + scatter(out, 42, 128, timesminusplus(reverse(v1779), load(tbl, 314 * VECWIDTH + tbloffset), times(v1779, load(tbl, 315 * VECWIDTH + tbloffset)))); + scatter(out, 10, 128, plus(v1782, v1783)); + real2 v1796 = minus(v1782, v1783); + scatter(out, 74, 128, timesminusplus(v1796, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v1796), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v1720 = minus(v1645, v1644); + real2 v1724 = plus(v1644, v1645); + real2 v1719 = reverse(minus(v1685, v1684)); + real2 v1725 = plus(v1684, v1685); + real2 v1745 = plus(v1724, v1725); + real2 v1739 = reverse(minus(v1725, v1724)); + scatter(out, 2, 128, plus(v1744, v1745)); + real2 v1758 = minus(v1744, v1745); + scatter(out, 66, 128, timesminusplus(v1758, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v1758), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v1741 = minusplus(v1739, v1740); + real2 v1743 = minusplus(uminus(v1739), v1740); + scatter(out, 98, 128, timesminusplus(reverse(v1743), load(tbl, 312 * VECWIDTH + tbloffset), times(v1743, load(tbl, 313 * VECWIDTH + tbloffset)))); + scatter(out, 34, 128, timesminusplus(reverse(v1741), load(tbl, 310 * VECWIDTH + tbloffset), times(v1741, load(tbl, 311 * VECWIDTH + tbloffset)))); + real2 v1723 = minusplus(uminus(v1719), v1720); + real2 v1721 = minusplus(v1719, v1720); + real2 v1737 = timesminusplus(reverse(v1723), load(tbl, 308 * VECWIDTH + tbloffset), times(v1723, load(tbl, 309 * VECWIDTH + tbloffset))); + scatter(out, 50, 128, plus(v1717, v1737)); + real2 v1770 = minus(v1717, v1737); + scatter(out, 114, 128, timesminusplus(v1770, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v1770), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v1731 = timesminusplus(reverse(v1721), load(tbl, 306 * VECWIDTH + tbloffset), times(v1721, load(tbl, 307 * VECWIDTH + tbloffset))); + scatter(out, 18, 128, plus(v1711, v1731)); + real2 v1764 = minus(v1711, v1731); + scatter(out, 82, 128, timesminusplus(v1764, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v1764), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v809 = timesminusplus(reverse(v795), load(tbl, 136 * VECWIDTH + tbloffset), times(v795, load(tbl, 137 * VECWIDTH + tbloffset))); + real2 v969 = timesminusplus(reverse(v955), load(tbl, 168 * VECWIDTH + tbloffset), times(v955, load(tbl, 169 * VECWIDTH + tbloffset))); + real2 v1850 = minus(v969, v809); + real2 v1854 = plus(v809, v969); + real2 v849 = timesminusplus(reverse(v835), load(tbl, 144 * VECWIDTH + tbloffset), times(v835, load(tbl, 145 * VECWIDTH + tbloffset))); + real2 v929 = timesminusplus(reverse(v915), load(tbl, 160 * VECWIDTH + tbloffset), times(v915, load(tbl, 161 * VECWIDTH + tbloffset))); + real2 v889 = timesminusplus(reverse(v875), load(tbl, 152 * VECWIDTH + tbloffset), times(v875, load(tbl, 153 * VECWIDTH + tbloffset))); + real2 v1089 = timesminusplus(reverse(v1075), load(tbl, 192 * VECWIDTH + tbloffset), times(v1075, load(tbl, 193 * VECWIDTH + tbloffset))); + real2 v1009 = timesminusplus(reverse(v995), load(tbl, 176 * VECWIDTH + tbloffset), times(v995, load(tbl, 177 * VECWIDTH + tbloffset))); + real2 v1890 = minus(v1009, v849); + real2 v1894 = plus(v849, v1009); + real2 v1849 = reverse(minus(v1049, v889)); + real2 v1855 = plus(v889, v1049); + real2 v1930 = minus(v1855, v1854); + real2 v1934 = plus(v1854, v1855); + real2 v1895 = plus(v929, v1089); + real2 v1889 = reverse(minus(v1089, v929)); + real2 v1929 = reverse(minus(v1895, v1894)); + real2 v1935 = plus(v1894, v1895); + real2 v1955 = plus(v1934, v1935); + real2 v1949 = reverse(minus(v1935, v1934)); + scatter(out, 6, 128, plus(v1954, v1955)); + real2 v1968 = minus(v1954, v1955); + scatter(out, 70, 128, timesminusplus(v1968, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v1968), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v1951 = minusplus(v1949, v1950); + scatter(out, 38, 128, timesminusplus(reverse(v1951), load(tbl, 346 * VECWIDTH + tbloffset), times(v1951, load(tbl, 347 * VECWIDTH + tbloffset)))); + real2 v1953 = minusplus(uminus(v1949), v1950); + scatter(out, 102, 128, timesminusplus(reverse(v1953), load(tbl, 348 * VECWIDTH + tbloffset), times(v1953, load(tbl, 349 * VECWIDTH + tbloffset)))); + real2 v1931 = minusplus(v1929, v1930); + real2 v1933 = minusplus(uminus(v1929), v1930); + real2 v1947 = timesminusplus(reverse(v1933), load(tbl, 344 * VECWIDTH + tbloffset), times(v1933, load(tbl, 345 * VECWIDTH + tbloffset))); + scatter(out, 54, 128, plus(v1927, v1947)); + real2 v1980 = minus(v1927, v1947); + scatter(out, 118, 128, timesminusplus(v1980, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v1980), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v1941 = timesminusplus(reverse(v1931), load(tbl, 342 * VECWIDTH + tbloffset), times(v1931, load(tbl, 343 * VECWIDTH + tbloffset))); + scatter(out, 22, 128, plus(v1921, v1941)); + real2 v1974 = minus(v1921, v1941); + scatter(out, 86, 128, timesminusplus(v1974, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v1974), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v1851 = minusplus(v1849, v1850); + real2 v1853 = minusplus(uminus(v1849), v1850); + real2 v1867 = timesminusplus(reverse(v1853), load(tbl, 328 * VECWIDTH + tbloffset), times(v1853, load(tbl, 329 * VECWIDTH + tbloffset))); + real2 v1891 = minusplus(v1889, v1890); + real2 v1893 = minusplus(uminus(v1889), v1890); + real2 v1907 = timesminusplus(reverse(v1893), load(tbl, 336 * VECWIDTH + tbloffset), times(v1893, load(tbl, 337 * VECWIDTH + tbloffset))); + real2 v2019 = plus(v1867, v1907); + real2 v2013 = reverse(minus(v1907, v1867)); + scatter(out, 30, 128, plus(v2018, v2019)); + real2 v2032 = minus(v2018, v2019); + scatter(out, 94, 128, timesminusplus(v2032, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v2032), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v2017 = minusplus(uminus(v2013), v2014); + scatter(out, 126, 128, timesminusplus(reverse(v2017), load(tbl, 356 * VECWIDTH + tbloffset), times(v2017, load(tbl, 357 * VECWIDTH + tbloffset)))); + real2 v2015 = minusplus(v2013, v2014); + scatter(out, 62, 128, timesminusplus(reverse(v2015), load(tbl, 354 * VECWIDTH + tbloffset), times(v2015, load(tbl, 355 * VECWIDTH + tbloffset)))); + real2 v1861 = timesminusplus(reverse(v1851), load(tbl, 326 * VECWIDTH + tbloffset), times(v1851, load(tbl, 327 * VECWIDTH + tbloffset))); + real2 v1901 = timesminusplus(reverse(v1891), load(tbl, 334 * VECWIDTH + tbloffset), times(v1891, load(tbl, 335 * VECWIDTH + tbloffset))); + real2 v1993 = plus(v1861, v1901); + real2 v1987 = reverse(minus(v1901, v1861)); + scatter(out, 14, 128, plus(v1992, v1993)); + real2 v2006 = minus(v1992, v1993); + scatter(out, 78, 128, timesminusplus(v2006, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v2006), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v1991 = minusplus(uminus(v1987), v1988); + scatter(out, 110, 128, timesminusplus(reverse(v1991), load(tbl, 352 * VECWIDTH + tbloffset), times(v1991, load(tbl, 353 * VECWIDTH + tbloffset)))); + real2 v1989 = minusplus(v1987, v1988); + scatter(out, 46, 128, timesminusplus(reverse(v1989), load(tbl, 350 * VECWIDTH + tbloffset), times(v1989, load(tbl, 351 * VECWIDTH + tbloffset)))); + real2 v593 = minusplus(v591, v592); + real2 v595 = minusplus(uminus(v591), v592); + real2 v473 = minusplus(v471, v472); + real2 v475 = minusplus(uminus(v471), v472); + real2 v555 = minusplus(uminus(v551), v552); + real2 v553 = minusplus(v551, v552); + real2 v609 = timesminusplus(reverse(v595), load(tbl, 96 * VECWIDTH + tbloffset), times(v595, load(tbl, 97 * VECWIDTH + tbloffset))); + real2 v195 = minusplus(uminus(v191), v192); + real2 v193 = minusplus(v191, v192); + real2 v275 = minusplus(uminus(v271), v272); + real2 v273 = minusplus(v271, v272); + real2 v673 = minusplus(v671, v672); + real2 v675 = minusplus(uminus(v671), v672); + real2 v689 = timesminusplus(reverse(v675), load(tbl, 112 * VECWIDTH + tbloffset), times(v675, load(tbl, 113 * VECWIDTH + tbloffset))); + real2 v209 = timesminusplus(reverse(v195), load(tbl, 16 * VECWIDTH + tbloffset), times(v195, load(tbl, 17 * VECWIDTH + tbloffset))); + real2 v289 = timesminusplus(reverse(v275), load(tbl, 32 * VECWIDTH + tbloffset), times(v275, load(tbl, 33 * VECWIDTH + tbloffset))); + real2 v755 = minusplus(uminus(v751), v752); + real2 v753 = minusplus(v751, v752); + real2 v435 = minusplus(uminus(v431), v432); + real2 v433 = minusplus(v431, v432); + real2 v513 = minusplus(v511, v512); + real2 v515 = minusplus(uminus(v511), v512); + real2 v529 = timesminusplus(reverse(v515), load(tbl, 80 * VECWIDTH + tbloffset), times(v515, load(tbl, 81 * VECWIDTH + tbloffset))); + real2 v353 = minusplus(v351, v352); + real2 v355 = minusplus(uminus(v351), v352); + real2 v369 = timesminusplus(reverse(v355), load(tbl, 48 * VECWIDTH + tbloffset), times(v355, load(tbl, 49 * VECWIDTH + tbloffset))); + real2 v2631 = plus(v369, v689); + real2 v2625 = reverse(minus(v689, v369)); + real2 v449 = timesminusplus(reverse(v435), load(tbl, 64 * VECWIDTH + tbloffset), times(v435, load(tbl, 65 * VECWIDTH + tbloffset))); + real2 v2710 = plus(v289, v609); + real2 v2706 = minus(v609, v289); + real2 v2630 = plus(v209, v529); + real2 v2626 = minus(v529, v209); + real2 v2790 = plus(v2630, v2631); + real2 v2786 = minus(v2631, v2630); + real2 v713 = minusplus(v711, v712); + real2 v715 = minusplus(uminus(v711), v712); + real2 v769 = timesminusplus(reverse(v755), load(tbl, 128 * VECWIDTH + tbloffset), times(v755, load(tbl, 129 * VECWIDTH + tbloffset))); + real2 v2705 = reverse(minus(v769, v449)); + real2 v2711 = plus(v449, v769); + real2 v313 = minusplus(v311, v312); + real2 v315 = minusplus(uminus(v311), v312); + real2 v393 = minusplus(v391, v392); + real2 v395 = minusplus(uminus(v391), v392); + real2 v409 = timesminusplus(reverse(v395), load(tbl, 56 * VECWIDTH + tbloffset), times(v395, load(tbl, 57 * VECWIDTH + tbloffset))); + real2 v729 = timesminusplus(reverse(v715), load(tbl, 120 * VECWIDTH + tbloffset), times(v715, load(tbl, 121 * VECWIDTH + tbloffset))); + real2 v329 = timesminusplus(reverse(v315), load(tbl, 40 * VECWIDTH + tbloffset), times(v315, load(tbl, 41 * VECWIDTH + tbloffset))); + real2 v489 = timesminusplus(reverse(v475), load(tbl, 72 * VECWIDTH + tbloffset), times(v475, load(tbl, 73 * VECWIDTH + tbloffset))); + real2 v153 = minusplus(v151, v152); + real2 v155 = minusplus(uminus(v151), v152); + real2 v169 = timesminusplus(reverse(v155), load(tbl, 8 * VECWIDTH + tbloffset), times(v155, load(tbl, 9 * VECWIDTH + tbloffset))); + real2 v2586 = minus(v489, v169); + real2 v2590 = plus(v169, v489); + real2 v233 = minusplus(v231, v232); + real2 v235 = minusplus(uminus(v231), v232); + real2 v633 = minusplus(v631, v632); + real2 v635 = minusplus(uminus(v631), v632); + real2 v649 = timesminusplus(reverse(v635), load(tbl, 104 * VECWIDTH + tbloffset), times(v635, load(tbl, 105 * VECWIDTH + tbloffset))); + real2 v249 = timesminusplus(reverse(v235), load(tbl, 24 * VECWIDTH + tbloffset), times(v235, load(tbl, 25 * VECWIDTH + tbloffset))); + real2 v569 = timesminusplus(reverse(v555), load(tbl, 88 * VECWIDTH + tbloffset), times(v555, load(tbl, 89 * VECWIDTH + tbloffset))); + real2 v2670 = plus(v249, v569); + real2 v2666 = minus(v569, v249); + real2 v2785 = reverse(minus(v2711, v2710)); + real2 v2791 = plus(v2710, v2711); + real2 v2825 = reverse(minus(v2791, v2790)); + real2 v2831 = plus(v2790, v2791); + real2 v2671 = plus(v409, v729); + real2 v2665 = reverse(minus(v729, v409)); + real2 v2745 = reverse(minus(v2671, v2670)); + real2 v2751 = plus(v2670, v2671); + real2 v2806 = minus(v2731, v2730); + real2 v2810 = plus(v2730, v2731); + real2 v2846 = minus(v2811, v2810); + real2 v2850 = plus(v2810, v2811); + real2 v2591 = plus(v329, v649); + real2 v2585 = reverse(minus(v649, v329)); + real2 v2750 = plus(v2590, v2591); + real2 v2746 = minus(v2591, v2590); + real2 v2830 = plus(v2750, v2751); + real2 v2826 = minus(v2751, v2750); + real2 v2845 = reverse(minus(v2831, v2830)); + real2 v2851 = plus(v2830, v2831); + scatter(out, 3, 128, plus(v2850, v2851)); + real2 v2864 = minus(v2850, v2851); + scatter(out, 67, 128, timesminusplus(v2864, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v2864), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v2849 = minusplus(uminus(v2845), v2846); + real2 v2847 = minusplus(v2845, v2846); + scatter(out, 35, 128, timesminusplus(reverse(v2847), load(tbl, 506 * VECWIDTH + tbloffset), times(v2847, load(tbl, 507 * VECWIDTH + tbloffset)))); + scatter(out, 99, 128, timesminusplus(reverse(v2849), load(tbl, 508 * VECWIDTH + tbloffset), times(v2849, load(tbl, 509 * VECWIDTH + tbloffset)))); + real2 v2827 = minusplus(v2825, v2826); + real2 v2829 = minusplus(uminus(v2825), v2826); + real2 v2837 = timesminusplus(reverse(v2827), load(tbl, 502 * VECWIDTH + tbloffset), times(v2827, load(tbl, 503 * VECWIDTH + tbloffset))); + real2 v2809 = minusplus(uminus(v2805), v2806); + real2 v2807 = minusplus(v2805, v2806); + real2 v2817 = timesminusplus(reverse(v2807), load(tbl, 498 * VECWIDTH + tbloffset), times(v2807, load(tbl, 499 * VECWIDTH + tbloffset))); + scatter(out, 19, 128, plus(v2817, v2837)); + real2 v2870 = minus(v2817, v2837); + scatter(out, 83, 128, timesminusplus(v2870, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v2870), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v2823 = timesminusplus(reverse(v2809), load(tbl, 500 * VECWIDTH + tbloffset), times(v2809, load(tbl, 501 * VECWIDTH + tbloffset))); + real2 v2843 = timesminusplus(reverse(v2829), load(tbl, 504 * VECWIDTH + tbloffset), times(v2829, load(tbl, 505 * VECWIDTH + tbloffset))); + scatter(out, 51, 128, plus(v2823, v2843)); + real2 v2876 = minus(v2823, v2843); + scatter(out, 115, 128, timesminusplus(v2876, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v2876), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v2787 = minusplus(v2785, v2786); + real2 v2789 = minusplus(uminus(v2785), v2786); + real2 v2803 = timesminusplus(reverse(v2789), load(tbl, 496 * VECWIDTH + tbloffset), times(v2789, load(tbl, 497 * VECWIDTH + tbloffset))); + real2 v2727 = minusplus(v2725, v2726); + real2 v2729 = minusplus(uminus(v2725), v2726); + real2 v2743 = timesminusplus(reverse(v2729), load(tbl, 484 * VECWIDTH + tbloffset), times(v2729, load(tbl, 485 * VECWIDTH + tbloffset))); + real2 v2914 = plus(v2743, v2783); + real2 v2910 = minus(v2783, v2743); + real2 v2749 = minusplus(uminus(v2745), v2746); + real2 v2747 = minusplus(v2745, v2746); + real2 v2763 = timesminusplus(reverse(v2749), load(tbl, 488 * VECWIDTH + tbloffset), times(v2749, load(tbl, 489 * VECWIDTH + tbloffset))); + real2 v2909 = reverse(minus(v2803, v2763)); + real2 v2915 = plus(v2763, v2803); + scatter(out, 27, 128, plus(v2914, v2915)); + real2 v2928 = minus(v2914, v2915); + scatter(out, 91, 128, timesminusplus(v2928, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v2928), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v2913 = minusplus(uminus(v2909), v2910); + scatter(out, 123, 128, timesminusplus(reverse(v2913), load(tbl, 516 * VECWIDTH + tbloffset), times(v2913, load(tbl, 517 * VECWIDTH + tbloffset)))); + real2 v2911 = minusplus(v2909, v2910); + scatter(out, 59, 128, timesminusplus(reverse(v2911), load(tbl, 514 * VECWIDTH + tbloffset), times(v2911, load(tbl, 515 * VECWIDTH + tbloffset)))); + real2 v2737 = timesminusplus(reverse(v2727), load(tbl, 482 * VECWIDTH + tbloffset), times(v2727, load(tbl, 483 * VECWIDTH + tbloffset))); + real2 v2888 = plus(v2737, v2777); + real2 v2884 = minus(v2777, v2737); + real2 v2797 = timesminusplus(reverse(v2787), load(tbl, 494 * VECWIDTH + tbloffset), times(v2787, load(tbl, 495 * VECWIDTH + tbloffset))); + real2 v2757 = timesminusplus(reverse(v2747), load(tbl, 486 * VECWIDTH + tbloffset), times(v2747, load(tbl, 487 * VECWIDTH + tbloffset))); + real2 v2889 = plus(v2757, v2797); + real2 v2883 = reverse(minus(v2797, v2757)); + scatter(out, 11, 128, plus(v2888, v2889)); + real2 v2902 = minus(v2888, v2889); + scatter(out, 75, 128, timesminusplus(v2902, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v2902), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v2887 = minusplus(uminus(v2883), v2884); + scatter(out, 107, 128, timesminusplus(reverse(v2887), load(tbl, 512 * VECWIDTH + tbloffset), times(v2887, load(tbl, 513 * VECWIDTH + tbloffset)))); + real2 v2885 = minusplus(v2883, v2884); + scatter(out, 43, 128, timesminusplus(reverse(v2885), load(tbl, 510 * VECWIDTH + tbloffset), times(v2885, load(tbl, 511 * VECWIDTH + tbloffset)))); + real2 v2669 = minusplus(uminus(v2665), v2666); + real2 v2667 = minusplus(v2665, v2666); + real2 v2707 = minusplus(v2705, v2706); + real2 v2709 = minusplus(uminus(v2705), v2706); + real2 v2717 = timesminusplus(reverse(v2707), load(tbl, 478 * VECWIDTH + tbloffset), times(v2707, load(tbl, 479 * VECWIDTH + tbloffset))); + real2 v2627 = minusplus(v2625, v2626); + real2 v2629 = minusplus(uminus(v2625), v2626); + real2 v2637 = timesminusplus(reverse(v2627), load(tbl, 462 * VECWIDTH + tbloffset), times(v2627, load(tbl, 463 * VECWIDTH + tbloffset))); + real2 v2961 = plus(v2637, v2717); + real2 v2955 = reverse(minus(v2717, v2637)); + real2 v2649 = minusplus(uminus(v2645), v2646); + real2 v2647 = minusplus(v2645, v2646); + real2 v2569 = minusplus(uminus(v2565), v2566); + real2 v2567 = minusplus(v2565, v2566); + real2 v2577 = timesminusplus(reverse(v2567), load(tbl, 450 * VECWIDTH + tbloffset), times(v2567, load(tbl, 451 * VECWIDTH + tbloffset))); + real2 v2657 = timesminusplus(reverse(v2647), load(tbl, 466 * VECWIDTH + tbloffset), times(v2647, load(tbl, 467 * VECWIDTH + tbloffset))); + real2 v2936 = minus(v2657, v2577); + real2 v2940 = plus(v2577, v2657); + real2 v2976 = minus(v2941, v2940); + real2 v2980 = plus(v2940, v2941); + real2 v2677 = timesminusplus(reverse(v2667), load(tbl, 470 * VECWIDTH + tbloffset), times(v2667, load(tbl, 471 * VECWIDTH + tbloffset))); + real2 v2587 = minusplus(v2585, v2586); + real2 v2589 = minusplus(uminus(v2585), v2586); + real2 v2597 = timesminusplus(reverse(v2587), load(tbl, 454 * VECWIDTH + tbloffset), times(v2587, load(tbl, 455 * VECWIDTH + tbloffset))); + real2 v2956 = minus(v2677, v2597); + real2 v2960 = plus(v2597, v2677); + real2 v2975 = reverse(minus(v2961, v2960)); + real2 v2981 = plus(v2960, v2961); + scatter(out, 7, 128, plus(v2980, v2981)); + real2 v2994 = minus(v2980, v2981); + scatter(out, 71, 128, timesminusplus(v2994, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v2994), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v2979 = minusplus(uminus(v2975), v2976); + scatter(out, 103, 128, timesminusplus(reverse(v2979), load(tbl, 528 * VECWIDTH + tbloffset), times(v2979, load(tbl, 529 * VECWIDTH + tbloffset)))); + real2 v2977 = minusplus(v2975, v2976); + scatter(out, 39, 128, timesminusplus(reverse(v2977), load(tbl, 526 * VECWIDTH + tbloffset), times(v2977, load(tbl, 527 * VECWIDTH + tbloffset)))); + real2 v2939 = minusplus(uminus(v2935), v2936); + real2 v2937 = minusplus(v2935, v2936); + real2 v2953 = timesminusplus(reverse(v2939), load(tbl, 520 * VECWIDTH + tbloffset), times(v2939, load(tbl, 521 * VECWIDTH + tbloffset))); + real2 v2957 = minusplus(v2955, v2956); + real2 v2959 = minusplus(uminus(v2955), v2956); + real2 v2973 = timesminusplus(reverse(v2959), load(tbl, 524 * VECWIDTH + tbloffset), times(v2959, load(tbl, 525 * VECWIDTH + tbloffset))); + scatter(out, 55, 128, plus(v2953, v2973)); + real2 v3006 = minus(v2953, v2973); + scatter(out, 119, 128, timesminusplus(v3006, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v3006), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v2947 = timesminusplus(reverse(v2937), load(tbl, 518 * VECWIDTH + tbloffset), times(v2937, load(tbl, 519 * VECWIDTH + tbloffset))); + real2 v2967 = timesminusplus(reverse(v2957), load(tbl, 522 * VECWIDTH + tbloffset), times(v2957, load(tbl, 523 * VECWIDTH + tbloffset))); + scatter(out, 23, 128, plus(v2947, v2967)); + real2 v3000 = minus(v2947, v2967); + scatter(out, 87, 128, timesminusplus(v3000, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v3000), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v2663 = timesminusplus(reverse(v2649), load(tbl, 468 * VECWIDTH + tbloffset), times(v2649, load(tbl, 469 * VECWIDTH + tbloffset))); + real2 v2583 = timesminusplus(reverse(v2569), load(tbl, 452 * VECWIDTH + tbloffset), times(v2569, load(tbl, 453 * VECWIDTH + tbloffset))); + real2 v3014 = minus(v2663, v2583); + real2 v3018 = plus(v2583, v2663); + real2 v3015 = minusplus(v3013, v3014); + real2 v3017 = minusplus(uminus(v3013), v3014); + real2 v2643 = timesminusplus(reverse(v2629), load(tbl, 464 * VECWIDTH + tbloffset), times(v2629, load(tbl, 465 * VECWIDTH + tbloffset))); + real2 v2723 = timesminusplus(reverse(v2709), load(tbl, 480 * VECWIDTH + tbloffset), times(v2709, load(tbl, 481 * VECWIDTH + tbloffset))); + real2 v3039 = plus(v2643, v2723); + real2 v3033 = reverse(minus(v2723, v2643)); + real2 v2683 = timesminusplus(reverse(v2669), load(tbl, 472 * VECWIDTH + tbloffset), times(v2669, load(tbl, 473 * VECWIDTH + tbloffset))); + real2 v3031 = timesminusplus(reverse(v3017), load(tbl, 532 * VECWIDTH + tbloffset), times(v3017, load(tbl, 533 * VECWIDTH + tbloffset))); + real2 v2603 = timesminusplus(reverse(v2589), load(tbl, 456 * VECWIDTH + tbloffset), times(v2589, load(tbl, 457 * VECWIDTH + tbloffset))); + real2 v3034 = minus(v2683, v2603); + real2 v3038 = plus(v2603, v2683); + real2 v3037 = minusplus(uminus(v3033), v3034); + real2 v3035 = minusplus(v3033, v3034); + real2 v3051 = timesminusplus(reverse(v3037), load(tbl, 536 * VECWIDTH + tbloffset), times(v3037, load(tbl, 537 * VECWIDTH + tbloffset))); + scatter(out, 63, 128, plus(v3031, v3051)); + real2 v3084 = minus(v3031, v3051); + scatter(out, 127, 128, timesminusplus(v3084, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v3084), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v3025 = timesminusplus(reverse(v3015), load(tbl, 530 * VECWIDTH + tbloffset), times(v3015, load(tbl, 531 * VECWIDTH + tbloffset))); + real2 v3045 = timesminusplus(reverse(v3035), load(tbl, 534 * VECWIDTH + tbloffset), times(v3035, load(tbl, 535 * VECWIDTH + tbloffset))); + scatter(out, 31, 128, plus(v3025, v3045)); + real2 v3078 = minus(v3025, v3045); + scatter(out, 95, 128, timesminusplus(v3078, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v3078), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v3058 = plus(v3018, v3019); + real2 v3054 = minus(v3019, v3018); + real2 v3053 = reverse(minus(v3039, v3038)); + real2 v3059 = plus(v3038, v3039); + real2 v3055 = minusplus(v3053, v3054); + scatter(out, 47, 128, timesminusplus(reverse(v3055), load(tbl, 538 * VECWIDTH + tbloffset), times(v3055, load(tbl, 539 * VECWIDTH + tbloffset)))); + real2 v3057 = minusplus(uminus(v3053), v3054); + scatter(out, 111, 128, timesminusplus(reverse(v3057), load(tbl, 540 * VECWIDTH + tbloffset), times(v3057, load(tbl, 541 * VECWIDTH + tbloffset)))); + scatter(out, 15, 128, plus(v3058, v3059)); + real2 v3072 = minus(v3058, v3059); + scatter(out, 79, 128, timesminusplus(v3072, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v3072), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v683 = timesminusplus(reverse(v673), load(tbl, 110 * VECWIDTH + tbloffset), times(v673, load(tbl, 111 * VECWIDTH + tbloffset))); + real2 v363 = timesminusplus(reverse(v353), load(tbl, 46 * VECWIDTH + tbloffset), times(v353, load(tbl, 47 * VECWIDTH + tbloffset))); + real2 v2105 = plus(v363, v683); + real2 v2099 = reverse(minus(v683, v363)); + real2 v283 = timesminusplus(reverse(v273), load(tbl, 30 * VECWIDTH + tbloffset), times(v273, load(tbl, 31 * VECWIDTH + tbloffset))); + real2 v723 = timesminusplus(reverse(v713), load(tbl, 118 * VECWIDTH + tbloffset), times(v713, load(tbl, 119 * VECWIDTH + tbloffset))); + real2 v403 = timesminusplus(reverse(v393), load(tbl, 54 * VECWIDTH + tbloffset), times(v393, load(tbl, 55 * VECWIDTH + tbloffset))); + real2 v603 = timesminusplus(reverse(v593), load(tbl, 94 * VECWIDTH + tbloffset), times(v593, load(tbl, 95 * VECWIDTH + tbloffset))); + real2 v2180 = minus(v603, v283); + real2 v2184 = plus(v283, v603); + real2 v2145 = plus(v403, v723); + real2 v2139 = reverse(minus(v723, v403)); + real2 v543 = timesminusplus(reverse(v533), load(tbl, 82 * VECWIDTH + tbloffset), times(v533, load(tbl, 83 * VECWIDTH + tbloffset))); + real2 v383 = timesminusplus(reverse(v373), load(tbl, 50 * VECWIDTH + tbloffset), times(v373, load(tbl, 51 * VECWIDTH + tbloffset))); + real2 v703 = timesminusplus(reverse(v693), load(tbl, 114 * VECWIDTH + tbloffset), times(v693, load(tbl, 115 * VECWIDTH + tbloffset))); + real2 v2125 = plus(v383, v703); + real2 v2119 = reverse(minus(v703, v383)); + real2 v223 = timesminusplus(reverse(v213), load(tbl, 18 * VECWIDTH + tbloffset), times(v213, load(tbl, 19 * VECWIDTH + tbloffset))); + real2 v2120 = minus(v543, v223); + real2 v2124 = plus(v223, v543); + real2 v443 = timesminusplus(reverse(v433), load(tbl, 62 * VECWIDTH + tbloffset), times(v433, load(tbl, 63 * VECWIDTH + tbloffset))); + real2 v203 = timesminusplus(reverse(v193), load(tbl, 14 * VECWIDTH + tbloffset), times(v193, load(tbl, 15 * VECWIDTH + tbloffset))); + real2 v763 = timesminusplus(reverse(v753), load(tbl, 126 * VECWIDTH + tbloffset), times(v753, load(tbl, 127 * VECWIDTH + tbloffset))); + real2 v2179 = reverse(minus(v763, v443)); + real2 v2185 = plus(v443, v763); + real2 v523 = timesminusplus(reverse(v513), load(tbl, 78 * VECWIDTH + tbloffset), times(v513, load(tbl, 79 * VECWIDTH + tbloffset))); + real2 v2100 = minus(v523, v203); + real2 v2104 = plus(v203, v523); + real2 v2264 = plus(v2104, v2105); + real2 v2260 = minus(v2105, v2104); + real2 v643 = timesminusplus(reverse(v633), load(tbl, 102 * VECWIDTH + tbloffset), times(v633, load(tbl, 103 * VECWIDTH + tbloffset))); + real2 v2265 = plus(v2184, v2185); + real2 v2259 = reverse(minus(v2185, v2184)); + real2 v563 = timesminusplus(reverse(v553), load(tbl, 86 * VECWIDTH + tbloffset), times(v553, load(tbl, 87 * VECWIDTH + tbloffset))); + real2 v243 = timesminusplus(reverse(v233), load(tbl, 22 * VECWIDTH + tbloffset), times(v233, load(tbl, 23 * VECWIDTH + tbloffset))); + real2 v2144 = plus(v243, v563); + real2 v2140 = minus(v563, v243); + real2 v143 = timesminusplus(reverse(v133), load(tbl, 2 * VECWIDTH + tbloffset), times(v133, load(tbl, 3 * VECWIDTH + tbloffset))); + real2 v183 = timesminusplus(reverse(v173), load(tbl, 10 * VECWIDTH + tbloffset), times(v173, load(tbl, 11 * VECWIDTH + tbloffset))); + real2 v2084 = plus(v183, v503); + real2 v2080 = minus(v503, v183); + real2 v163 = timesminusplus(reverse(v153), load(tbl, 6 * VECWIDTH + tbloffset), times(v153, load(tbl, 7 * VECWIDTH + tbloffset))); + real2 v303 = timesminusplus(reverse(v293), load(tbl, 34 * VECWIDTH + tbloffset), times(v293, load(tbl, 35 * VECWIDTH + tbloffset))); + real2 v623 = timesminusplus(reverse(v613), load(tbl, 98 * VECWIDTH + tbloffset), times(v613, load(tbl, 99 * VECWIDTH + tbloffset))); + real2 v2039 = reverse(minus(v623, v303)); + real2 v2045 = plus(v303, v623); + real2 v463 = timesminusplus(reverse(v453), load(tbl, 66 * VECWIDTH + tbloffset), times(v453, load(tbl, 67 * VECWIDTH + tbloffset))); + real2 v2044 = plus(v143, v463); + real2 v2040 = minus(v463, v143); + real2 v2204 = plus(v2044, v2045); + real2 v2200 = minus(v2045, v2044); + real2 v323 = timesminusplus(reverse(v313), load(tbl, 38 * VECWIDTH + tbloffset), times(v313, load(tbl, 39 * VECWIDTH + tbloffset))); + real2 v2205 = plus(v2124, v2125); + real2 v2199 = reverse(minus(v2125, v2124)); + real2 v2280 = minus(v2205, v2204); + real2 v2284 = plus(v2204, v2205); + real2 v2225 = plus(v2144, v2145); + real2 v2219 = reverse(minus(v2145, v2144)); + real2 v2305 = plus(v2264, v2265); + real2 v2299 = reverse(minus(v2265, v2264)); + real2 v2240 = minus(v2085, v2084); + real2 v2244 = plus(v2084, v2085); + real2 v2279 = reverse(minus(v2245, v2244)); + real2 v2285 = plus(v2244, v2245); + real2 v2281 = minusplus(v2279, v2280); + real2 v2283 = minusplus(uminus(v2279), v2280); + real2 v2291 = timesminusplus(reverse(v2281), load(tbl, 406 * VECWIDTH + tbloffset), times(v2281, load(tbl, 407 * VECWIDTH + tbloffset))); + real2 v483 = timesminusplus(reverse(v473), load(tbl, 70 * VECWIDTH + tbloffset), times(v473, load(tbl, 71 * VECWIDTH + tbloffset))); + real2 v2060 = minus(v483, v163); + real2 v2064 = plus(v163, v483); + real2 v2065 = plus(v323, v643); + real2 v2059 = reverse(minus(v643, v323)); + real2 v2220 = minus(v2065, v2064); + real2 v2224 = plus(v2064, v2065); + real2 v2304 = plus(v2224, v2225); + real2 v2300 = minus(v2225, v2224); + real2 v2301 = minusplus(v2299, v2300); + real2 v2303 = minusplus(uminus(v2299), v2300); + real2 v2311 = timesminusplus(reverse(v2301), load(tbl, 410 * VECWIDTH + tbloffset), times(v2301, load(tbl, 411 * VECWIDTH + tbloffset))); + scatter(out, 17, 128, plus(v2291, v2311)); + real2 v2344 = minus(v2291, v2311); + scatter(out, 81, 128, timesminusplus(v2344, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v2344), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v2297 = timesminusplus(reverse(v2283), load(tbl, 408 * VECWIDTH + tbloffset), times(v2283, load(tbl, 409 * VECWIDTH + tbloffset))); + real2 v2317 = timesminusplus(reverse(v2303), load(tbl, 412 * VECWIDTH + tbloffset), times(v2303, load(tbl, 413 * VECWIDTH + tbloffset))); + scatter(out, 49, 128, plus(v2297, v2317)); + real2 v2350 = minus(v2297, v2317); + scatter(out, 113, 128, timesminusplus(v2350, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v2350), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v2320 = minus(v2285, v2284); + real2 v2324 = plus(v2284, v2285); + real2 v2325 = plus(v2304, v2305); + real2 v2319 = reverse(minus(v2305, v2304)); + scatter(out, 1, 128, plus(v2324, v2325)); + real2 v2338 = minus(v2324, v2325); + scatter(out, 65, 128, timesminusplus(v2338, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v2338), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v2321 = minusplus(v2319, v2320); + scatter(out, 33, 128, timesminusplus(reverse(v2321), load(tbl, 414 * VECWIDTH + tbloffset), times(v2321, load(tbl, 415 * VECWIDTH + tbloffset)))); + real2 v2323 = minusplus(uminus(v2319), v2320); + scatter(out, 97, 128, timesminusplus(reverse(v2323), load(tbl, 416 * VECWIDTH + tbloffset), times(v2323, load(tbl, 417 * VECWIDTH + tbloffset)))); + real2 v2201 = minusplus(v2199, v2200); + real2 v2203 = minusplus(uminus(v2199), v2200); + real2 v2263 = minusplus(uminus(v2259), v2260); + real2 v2261 = minusplus(v2259, v2260); + real2 v2243 = minusplus(uminus(v2239), v2240); + real2 v2241 = minusplus(v2239, v2240); + real2 v2257 = timesminusplus(reverse(v2243), load(tbl, 400 * VECWIDTH + tbloffset), times(v2243, load(tbl, 401 * VECWIDTH + tbloffset))); + real2 v2217 = timesminusplus(reverse(v2203), load(tbl, 392 * VECWIDTH + tbloffset), times(v2203, load(tbl, 393 * VECWIDTH + tbloffset))); + real2 v2388 = plus(v2217, v2257); + real2 v2384 = minus(v2257, v2217); + real2 v2277 = timesminusplus(reverse(v2263), load(tbl, 404 * VECWIDTH + tbloffset), times(v2263, load(tbl, 405 * VECWIDTH + tbloffset))); + real2 v2221 = minusplus(v2219, v2220); + real2 v2223 = minusplus(uminus(v2219), v2220); + real2 v2237 = timesminusplus(reverse(v2223), load(tbl, 396 * VECWIDTH + tbloffset), times(v2223, load(tbl, 397 * VECWIDTH + tbloffset))); + real2 v2389 = plus(v2237, v2277); + real2 v2383 = reverse(minus(v2277, v2237)); + scatter(out, 25, 128, plus(v2388, v2389)); + real2 v2402 = minus(v2388, v2389); + scatter(out, 89, 128, timesminusplus(v2402, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v2402), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v2385 = minusplus(v2383, v2384); + real2 v2387 = minusplus(uminus(v2383), v2384); + scatter(out, 121, 128, timesminusplus(reverse(v2387), load(tbl, 424 * VECWIDTH + tbloffset), times(v2387, load(tbl, 425 * VECWIDTH + tbloffset)))); + scatter(out, 57, 128, timesminusplus(reverse(v2385), load(tbl, 422 * VECWIDTH + tbloffset), times(v2385, load(tbl, 423 * VECWIDTH + tbloffset)))); + real2 v2251 = timesminusplus(reverse(v2241), load(tbl, 398 * VECWIDTH + tbloffset), times(v2241, load(tbl, 399 * VECWIDTH + tbloffset))); + real2 v2211 = timesminusplus(reverse(v2201), load(tbl, 390 * VECWIDTH + tbloffset), times(v2201, load(tbl, 391 * VECWIDTH + tbloffset))); + real2 v2358 = minus(v2251, v2211); + real2 v2362 = plus(v2211, v2251); + real2 v2271 = timesminusplus(reverse(v2261), load(tbl, 402 * VECWIDTH + tbloffset), times(v2261, load(tbl, 403 * VECWIDTH + tbloffset))); + real2 v2231 = timesminusplus(reverse(v2221), load(tbl, 394 * VECWIDTH + tbloffset), times(v2221, load(tbl, 395 * VECWIDTH + tbloffset))); + real2 v2357 = reverse(minus(v2271, v2231)); + real2 v2363 = plus(v2231, v2271); + scatter(out, 9, 128, plus(v2362, v2363)); + real2 v2376 = minus(v2362, v2363); + scatter(out, 73, 128, timesminusplus(v2376, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v2376), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v2361 = minusplus(uminus(v2357), v2358); + scatter(out, 105, 128, timesminusplus(reverse(v2361), load(tbl, 420 * VECWIDTH + tbloffset), times(v2361, load(tbl, 421 * VECWIDTH + tbloffset)))); + real2 v2359 = minusplus(v2357, v2358); + scatter(out, 41, 128, timesminusplus(reverse(v2359), load(tbl, 418 * VECWIDTH + tbloffset), times(v2359, load(tbl, 419 * VECWIDTH + tbloffset)))); + real2 v2121 = minusplus(v2119, v2120); + real2 v2123 = minusplus(uminus(v2119), v2120); + real2 v2083 = minusplus(uminus(v2079), v2080); + real2 v2081 = minusplus(v2079, v2080); + real2 v2091 = timesminusplus(reverse(v2081), load(tbl, 366 * VECWIDTH + tbloffset), times(v2081, load(tbl, 367 * VECWIDTH + tbloffset))); + real2 v2043 = minusplus(uminus(v2039), v2040); + real2 v2041 = minusplus(v2039, v2040); + real2 v2051 = timesminusplus(reverse(v2041), load(tbl, 358 * VECWIDTH + tbloffset), times(v2041, load(tbl, 359 * VECWIDTH + tbloffset))); + real2 v2131 = timesminusplus(reverse(v2121), load(tbl, 374 * VECWIDTH + tbloffset), times(v2121, load(tbl, 375 * VECWIDTH + tbloffset))); + real2 v2163 = minusplus(uminus(v2159), v2160); + real2 v2161 = minusplus(v2159, v2160); + real2 v2171 = timesminusplus(reverse(v2161), load(tbl, 382 * VECWIDTH + tbloffset), times(v2161, load(tbl, 383 * VECWIDTH + tbloffset))); + real2 v2409 = reverse(minus(v2171, v2091)); + real2 v2415 = plus(v2091, v2171); + real2 v2410 = minus(v2131, v2051); + real2 v2414 = plus(v2051, v2131); + real2 v2454 = plus(v2414, v2415); + real2 v2450 = minus(v2415, v2414); + real2 v2181 = minusplus(v2179, v2180); + real2 v2183 = minusplus(uminus(v2179), v2180); + real2 v2191 = timesminusplus(reverse(v2181), load(tbl, 386 * VECWIDTH + tbloffset), times(v2181, load(tbl, 387 * VECWIDTH + tbloffset))); + real2 v2103 = minusplus(uminus(v2099), v2100); + real2 v2101 = minusplus(v2099, v2100); + real2 v2111 = timesminusplus(reverse(v2101), load(tbl, 370 * VECWIDTH + tbloffset), times(v2101, load(tbl, 371 * VECWIDTH + tbloffset))); + real2 v2435 = plus(v2111, v2191); + real2 v2429 = reverse(minus(v2191, v2111)); + real2 v2141 = minusplus(v2139, v2140); + real2 v2143 = minusplus(uminus(v2139), v2140); + real2 v2151 = timesminusplus(reverse(v2141), load(tbl, 378 * VECWIDTH + tbloffset), times(v2141, load(tbl, 379 * VECWIDTH + tbloffset))); + real2 v2063 = minusplus(uminus(v2059), v2060); + real2 v2061 = minusplus(v2059, v2060); + real2 v2071 = timesminusplus(reverse(v2061), load(tbl, 362 * VECWIDTH + tbloffset), times(v2061, load(tbl, 363 * VECWIDTH + tbloffset))); + real2 v2434 = plus(v2071, v2151); + real2 v2430 = minus(v2151, v2071); + real2 v2455 = plus(v2434, v2435); + real2 v2449 = reverse(minus(v2435, v2434)); + scatter(out, 5, 128, plus(v2454, v2455)); + real2 v2468 = minus(v2454, v2455); + scatter(out, 69, 128, timesminusplus(v2468, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v2468), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v2451 = minusplus(v2449, v2450); + real2 v2453 = minusplus(uminus(v2449), v2450); + scatter(out, 101, 128, timesminusplus(reverse(v2453), load(tbl, 436 * VECWIDTH + tbloffset), times(v2453, load(tbl, 437 * VECWIDTH + tbloffset)))); + scatter(out, 37, 128, timesminusplus(reverse(v2451), load(tbl, 434 * VECWIDTH + tbloffset), times(v2451, load(tbl, 435 * VECWIDTH + tbloffset)))); + real2 v2411 = minusplus(v2409, v2410); + real2 v2413 = minusplus(uminus(v2409), v2410); + real2 v2433 = minusplus(uminus(v2429), v2430); + real2 v2431 = minusplus(v2429, v2430); + real2 v2421 = timesminusplus(reverse(v2411), load(tbl, 426 * VECWIDTH + tbloffset), times(v2411, load(tbl, 427 * VECWIDTH + tbloffset))); + real2 v2441 = timesminusplus(reverse(v2431), load(tbl, 430 * VECWIDTH + tbloffset), times(v2431, load(tbl, 431 * VECWIDTH + tbloffset))); + scatter(out, 21, 128, plus(v2421, v2441)); + real2 v2474 = minus(v2421, v2441); + scatter(out, 85, 128, timesminusplus(v2474, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v2474), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v2427 = timesminusplus(reverse(v2413), load(tbl, 428 * VECWIDTH + tbloffset), times(v2413, load(tbl, 429 * VECWIDTH + tbloffset))); + real2 v2447 = timesminusplus(reverse(v2433), load(tbl, 432 * VECWIDTH + tbloffset), times(v2433, load(tbl, 433 * VECWIDTH + tbloffset))); + scatter(out, 53, 128, plus(v2427, v2447)); + real2 v2480 = minus(v2427, v2447); + scatter(out, 117, 128, timesminusplus(v2480, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v2480), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v2057 = timesminusplus(reverse(v2043), load(tbl, 360 * VECWIDTH + tbloffset), times(v2043, load(tbl, 361 * VECWIDTH + tbloffset))); + real2 v2097 = timesminusplus(reverse(v2083), load(tbl, 368 * VECWIDTH + tbloffset), times(v2083, load(tbl, 369 * VECWIDTH + tbloffset))); + real2 v2157 = timesminusplus(reverse(v2143), load(tbl, 380 * VECWIDTH + tbloffset), times(v2143, load(tbl, 381 * VECWIDTH + tbloffset))); + real2 v2197 = timesminusplus(reverse(v2183), load(tbl, 388 * VECWIDTH + tbloffset), times(v2183, load(tbl, 389 * VECWIDTH + tbloffset))); + real2 v2117 = timesminusplus(reverse(v2103), load(tbl, 372 * VECWIDTH + tbloffset), times(v2103, load(tbl, 373 * VECWIDTH + tbloffset))); + real2 v2507 = reverse(minus(v2197, v2117)); + real2 v2513 = plus(v2117, v2197); + real2 v2137 = timesminusplus(reverse(v2123), load(tbl, 376 * VECWIDTH + tbloffset), times(v2123, load(tbl, 377 * VECWIDTH + tbloffset))); + real2 v2488 = minus(v2137, v2057); + real2 v2492 = plus(v2057, v2137); + real2 v2177 = timesminusplus(reverse(v2163), load(tbl, 384 * VECWIDTH + tbloffset), times(v2163, load(tbl, 385 * VECWIDTH + tbloffset))); + real2 v2493 = plus(v2097, v2177); + real2 v2487 = reverse(minus(v2177, v2097)); + real2 v2532 = plus(v2492, v2493); + real2 v2528 = minus(v2493, v2492); + real2 v2077 = timesminusplus(reverse(v2063), load(tbl, 364 * VECWIDTH + tbloffset), times(v2063, load(tbl, 365 * VECWIDTH + tbloffset))); + real2 v2512 = plus(v2077, v2157); + real2 v2508 = minus(v2157, v2077); + real2 v2527 = reverse(minus(v2513, v2512)); + real2 v2533 = plus(v2512, v2513); + real2 v2529 = minusplus(v2527, v2528); + real2 v2531 = minusplus(uminus(v2527), v2528); + scatter(out, 109, 128, timesminusplus(reverse(v2531), load(tbl, 448 * VECWIDTH + tbloffset), times(v2531, load(tbl, 449 * VECWIDTH + tbloffset)))); + scatter(out, 45, 128, timesminusplus(reverse(v2529), load(tbl, 446 * VECWIDTH + tbloffset), times(v2529, load(tbl, 447 * VECWIDTH + tbloffset)))); + scatter(out, 13, 128, plus(v2532, v2533)); + real2 v2546 = minus(v2532, v2533); + scatter(out, 77, 128, timesminusplus(v2546, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v2546), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v2509 = minusplus(v2507, v2508); + real2 v2511 = minusplus(uminus(v2507), v2508); + real2 v2491 = minusplus(uminus(v2487), v2488); + real2 v2489 = minusplus(v2487, v2488); + real2 v2499 = timesminusplus(reverse(v2489), load(tbl, 438 * VECWIDTH + tbloffset), times(v2489, load(tbl, 439 * VECWIDTH + tbloffset))); + real2 v2519 = timesminusplus(reverse(v2509), load(tbl, 442 * VECWIDTH + tbloffset), times(v2509, load(tbl, 443 * VECWIDTH + tbloffset))); + scatter(out, 29, 128, plus(v2499, v2519)); + real2 v2552 = minus(v2499, v2519); + scatter(out, 93, 128, timesminusplus(v2552, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v2552), load(tbl, 1 * VECWIDTH + tbloffset)))); + real2 v2505 = timesminusplus(reverse(v2491), load(tbl, 440 * VECWIDTH + tbloffset), times(v2491, load(tbl, 441 * VECWIDTH + tbloffset))); + real2 v2525 = timesminusplus(reverse(v2511), load(tbl, 444 * VECWIDTH + tbloffset), times(v2511, load(tbl, 445 * VECWIDTH + tbloffset))); + scatter(out, 61, 128, plus(v2505, v2525)); + real2 v2558 = minus(v2505, v2525); + scatter(out, 125, 128, timesminusplus(v2558, load(tbl, 0 * VECWIDTH + tbloffset), times(reverse(v2558), load(tbl, 1 * VECWIDTH + tbloffset)))); +// Pres : 76263 + } +} +#endif + +// + +#undef EMITREALSUB + +#ifdef EMITREALSUB +ALIGNED(8192) void realSub0_%ISA%(real *d, const real *s, const int log2len, const real *rtCoef0, const real *rtCoef1) { + const int n = 1 << log2len; + real s0 = s[0], s1 = s[1]; + int k=1; + + d[n+0] = s[n+0]; + d[n+1] = s[n+1]; + + for(;;k+=VECWIDTH) { + int idx0 = k, idx1 = n-VECWIDTH+1-k; + if (idx0 + VECWIDTH >= idx1) break; + + real2 v = loadu(s, idx0); + real2 u = reverse2(load (s, idx1)); + + real2 t = minusplus(v, u); + real2 m = minusplus(reverse(times(t, loadu(rtCoef1, k))), + times(t, loadu(rtCoef0, k))); + + storeu(d, idx0, minusplus(v, uminus(m))); + store (d, idx1, reverse2(minus(u, m))); + } + + for(;k= idx1) break; + + real2 v = loadu(s, idx0); + real2 u = reverse2(load (s, idx1)); + + real2 t = minusplus(v, u); + real2 m = minusplus(reverse(times(t, loadu(rtCoef1, k))), + times(t, loadu(rtCoef0, k))); + + storeu(d, idx0, ctimes(uplusminus(minus(u, m)), c)); + store (d, idx1, ctimes(reverse2(minusplus(m, uminus(v))), c)); + } + + for(;k +#include "sleef.h" + +#ifdef ENABLE_SSE2 +#include "helpersse2.h" +#endif + +#ifdef ENABLE_AVX +#include "helperavx.h" +#endif + +#ifdef ENABLE_AVX2 +#include "helperavx2.h" +#endif + +#ifdef ENABLE_AVX512F +#include "helperavx512f.h" +#endif + +#ifdef ENABLE_NEON32 +#include "helperneon32.h" +#endif + +#ifdef ENABLE_ADVSIMD +#include "helperadvsimd.h" +#endif + +#ifdef ENABLE_SVE +#include "helpersve.h" +#endif + +#if defined(ENABLE_RVVM1) || defined(ENABLE_RVVM2) +#include "helperrvv.h" +#endif + +#ifdef ENABLE_VSX +#include "helperpower_128.h" +#endif + +#ifdef ENABLE_VSX3 +#include "helperpower_128.h" +#endif + +#ifdef ENABLE_VXE +#include "helpers390x_128.h" +#endif + +#ifdef ENABLE_VXE2 +#include "helpers390x_128.h" +#endif + +#ifdef ENABLE_VECEXT +#include "helpervecext.h" +#endif + +#ifdef ENABLE_PUREC +#include "helperpurec.h" +#endif + +#define IMPORT_IS_EXPORT +#include "sleefdft.h" + +#if BASETYPEID == 1 +#define LOG2VECWIDTH (LOG2VECTLENDP-1) +#define VECWIDTH (1 << LOG2VECWIDTH) + +typedef double real; +typedef vdouble real2; + +static int available(int name) { return vavailability_i(name); } + +static INLINE real2 uminus(real2 d0) { return vneg_vd_vd(d0); } +static INLINE real2 uplusminus(real2 d0) { return vposneg_vd_vd(d0); } +static INLINE real2 uminusplus(real2 d0) { return vnegpos_vd_vd(d0); } + +static INLINE real2 plus(real2 d0, real2 d1) { return vadd_vd_vd_vd(d0, d1); } +static INLINE real2 minus(real2 d0, real2 d1) { return vsub_vd_vd_vd(d0, d1); } +static INLINE real2 minusplus(real2 d0, real2 d1) { return vsubadd_vd_vd_vd(d0, d1); } +static INLINE real2 times(real2 d0, real2 d1) { return vmul_vd_vd_vd(d0, d1); } +static INLINE real2 timesminusplus(real2 d0, real2 d2, real2 d1) { return vmlsubadd_vd_vd_vd_vd(d0, d2, d1); } +static INLINE real2 ctimes(real2 d0, real d) { return vmul_vd_vd_vd(d0, vcast_vd_d(d)); } +static INLINE real2 ctimesminusplus(real2 d0, real c, real2 d1) { return vmlsubadd_vd_vd_vd_vd(d0, vcast_vd_d(c), d1); } + +static INLINE real2 reverse(real2 d0) { return vrev21_vd_vd(d0); } +static INLINE real2 reverse2(real2 d0) { return vreva2_vd_vd(d0); } + +static INLINE real2 loadc(real c) { return vcast_vd_d(c); } + +static INLINE real2 load(const real *ptr, int offset) { return vload_vd_p(&ptr[2*offset]); } +static INLINE real2 loadu(const real *ptr, int offset) { return vloadu_vd_p(&ptr[2*offset]); } +static INLINE void store(real *ptr, int offset, real2 v) { vstore_v_p_vd(&ptr[2*offset], v); } +static INLINE void storeu(real *ptr, int offset, real2 v) { vstoreu_v_p_vd(&ptr[2*offset], v); } +static INLINE void stream(real *ptr, int offset, real2 v) { vstream_v_p_vd(&ptr[2*offset], v); } +static INLINE void scatter(real *ptr, int offset, int step, real2 v) { vscatter2_v_p_i_i_vd(ptr, offset, step, v); } +static INLINE void scstream(real *ptr, int offset, int step, real2 v) { vsscatter2_v_p_i_i_vd(ptr, offset, step, v); } + +static INLINE void prefetch(real *ptr, int offset) { vprefetch_v_p(&ptr[2*offset]); } +#elif BASETYPEID == 2 +#define LOG2VECWIDTH (LOG2VECTLENSP-1) +#define VECWIDTH (1 << LOG2VECWIDTH) + +typedef float real; +typedef vfloat real2; + +static int available(int name) { return vavailability_i(name); } + +static INLINE real2 uminus(real2 d0) { return vneg_vf_vf(d0); } +static INLINE real2 uplusminus(real2 d0) { return vposneg_vf_vf(d0); } +static INLINE real2 uminusplus(real2 d0) { return vnegpos_vf_vf(d0); } + +static INLINE real2 plus(real2 d0, real2 d1) { return vadd_vf_vf_vf(d0, d1); } +static INLINE real2 minus(real2 d0, real2 d1) { return vsub_vf_vf_vf(d0, d1); } +static INLINE real2 minusplus(real2 d0, real2 d1) { return vsubadd_vf_vf_vf(d0, d1); } +static INLINE real2 times(real2 d0, real2 d1) { return vmul_vf_vf_vf(d0, d1); } +static INLINE real2 ctimes(real2 d0, real d) { return vmul_vf_vf_vf(d0, vcast_vf_f(d)); } +static INLINE real2 timesminusplus(real2 d0, real2 d2, real2 d1) { return vmlsubadd_vf_vf_vf_vf(d0, d2, d1); } +static INLINE real2 ctimesminusplus(real2 d0, real c, real2 d1) { return vmlsubadd_vf_vf_vf_vf(d0, vcast_vf_f(c), d1); } + +static INLINE real2 reverse(real2 d0) { return vrev21_vf_vf(d0); } +static INLINE real2 reverse2(real2 d0) { return vreva2_vf_vf(d0); } + +static INLINE real2 loadc(real c) { return vcast_vf_f(c); } + +static INLINE real2 load(const real *ptr, int offset) { return vload_vf_p(&ptr[2*offset]); } +static INLINE real2 loadu(const real *ptr, int offset) { return vloadu_vf_p(&ptr[2*offset]); } +static INLINE void store(real *ptr, int offset, real2 v) { vstore_v_p_vf(&ptr[2*offset], v); } +static INLINE void storeu(real *ptr, int offset, real2 v) { vstoreu_v_p_vf(&ptr[2*offset], v); } +static INLINE void stream(real *ptr, int offset, real2 v) { vstream_v_p_vf(&ptr[2*offset], v); } +static INLINE void scatter(real *ptr, int offset, int step, real2 v) { vscatter2_v_p_i_i_vf(ptr, offset, step, v); } +static INLINE void scstream(real *ptr, int offset, int step, real2 v) { vsscatter2_v_p_i_i_vf(ptr, offset, step, v); } + +static INLINE void prefetch(real *ptr, int offset) { vprefetch_v_p(&ptr[2*offset]); } +#else +#error No BASETYPEID specified +#endif + +#endif diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/gencoef/Makefile b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/gencoef/Makefile new file mode 100644 index 00000000000..38394880c82 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/gencoef/Makefile @@ -0,0 +1,16 @@ +.PHONY: all +all : gencoef mkrempitab mkrempitabqp + +gencoef : gencoef.c simplexfr.c sp.h dp.h ld.h qp.h + gcc -O gencoef.c simplexfr.c -o gencoef -lmpfr -lm + +mkrempitab : mkrempitab.c + gcc -O mkrempitab.c -o mkrempitab -lmpfr + +mkrempitabqp : mkrempitabqp.c + gcc -O mkrempitabqp.c -o mkrempitabqp -lmpfr + +.PHONY: clean +clean : + rm -f gencoef gencoefdp gencoefld mkrempitab mkrempitabqp a.out *~ + rm -f *.obj *.lib *.dll *.exp *.exe diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/gencoef/dp.h b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/gencoef/dp.h new file mode 100644 index 00000000000..038988e78b7 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/gencoef/dp.h @@ -0,0 +1,196 @@ +// This is part of SLEEF, written by Naoki +// Shibata. http://shibatch.sourceforge.net + +// The code in this file is distributed under the Creative Commons +// Attribution 4.0 International License. + +#define PREC_TARGET 53 + +#if 0 +#define N 8 // Degree of equation +#define S 40 // Number of samples for phase 1 +#define L 4 // Number of high precision coefficients +#define MIN 0.0 // Min argument +#define MAX (M_PI/4) // Max argument +#define PMUL 2 // The form of polynomial is y = x^(PADD+PMUL*0) + x^(PADD+PMUL*1) + ... +#define PADD 1 + +void TARGET(mpfr_t ret, mpfr_t a) { mpfr_sin(ret, a, GMP_RNDN); } // The function to approximate +void CFUNC(mpfr_t dst, mpfr_t src) { mpfr_set(dst, src, GMP_RNDN); } +#define FIXCOEF0 1.0 // Fix coef 0 to 1.0 +#endif + +#if 0 +#define N 10 +#define S 40 +#define L 2 +#define MIN 0.0 +#define MAX (M_PI/4) + +void TARGET(mpfr_t ret, mpfr_t a) { // cos(x) - 1 + mpfr_t x; + mpfr_init(x); + mpfr_cos(ret, a, GMP_RNDN); + mpfr_set_ld(x, 1, GMP_RNDN); + mpfr_sub(ret, ret, x, GMP_RNDN); + mpfr_clear(x); +} +void CFUNC(mpfr_t dst, mpfr_t src) { mpfr_set(dst, src, GMP_RNDN); } + +#define PMUL 2 +#define PADD 2 +#define FIXCOEF0 (-0.5) +#endif + + +#if 0 // for xsincospi4_u05 +#define S 40 +#define N 8 +#define L 2 +#define MIN 0.0 +#define MAX 1.0 +#define PMUL 2 +#define PADD 1 + +void TARGET(mpfr_t ret, mpfr_t a) { + mpfr_t x, y; + mpfr_inits(x, y, NULL); + mpfr_const_pi(x, GMP_RNDN); + mpfr_set_d(y, 1.0/4, GMP_RNDN); + mpfr_mul(x, x, y, GMP_RNDN); + mpfr_mul(x, x, a, GMP_RNDN); + mpfr_sin(ret, x, GMP_RNDN); + mpfr_clears(x, y, NULL); +} +void CFUNC(mpfr_t dst, mpfr_t src) { mpfr_set(dst, src, GMP_RNDN); } +#endif + +#if 0 // for xsincospi4_u05 +#define N 8 +#define S 40 +#define L 2 +#define MIN 0.0 +#define MAX 1.0 + +void TARGET(mpfr_t ret, mpfr_t a) { + mpfr_t x, y; + mpfr_inits(x, y, NULL); + mpfr_const_pi(x, GMP_RNDN); + mpfr_set_d(y, 1.0/4, GMP_RNDN); + mpfr_mul(x, x, y, GMP_RNDN); + mpfr_mul(x, x, a, GMP_RNDN); + mpfr_cos(ret, x, GMP_RNDN); + mpfr_set_ld(x, 1, GMP_RNDN); + mpfr_sub(ret, ret, x, GMP_RNDN); + mpfr_clears(x, y, NULL); +} +void CFUNC(mpfr_t dst, mpfr_t src) { mpfr_set(dst, src, GMP_RNDN); } +#define PMUL 2 +#define PADD 2 +#endif + + +#if 0 // for xsincospi4 +#define N 7 +#define S 40 +#define L 0 +#define MIN 0.0 +#define MAX 1.0 +#define PMUL 2 +#define PADD 1 + +void TARGET(mpfr_t ret, mpfr_t a) { + mpfr_t x, y; + mpfr_inits(x, y, NULL); + mpfr_const_pi(x, GMP_RNDN); + mpfr_set_d(y, 1.0/4, GMP_RNDN); + mpfr_mul(x, x, y, GMP_RNDN); + mpfr_mul(x, x, a, GMP_RNDN); + mpfr_sin(ret, x, GMP_RNDN); + mpfr_clears(x, y, NULL); +} +void CFUNC(mpfr_t dst, mpfr_t src) { mpfr_set(dst, src, GMP_RNDN); } +#endif + + +#if 0 +#define N 17 +#define S 60 +#define L 0 +#define MIN 0.0 +#define MAX (M_PI/4) +#define PMUL 2 +#define PADD 1 + +void TARGET(mpfr_t ret, mpfr_t a) { mpfr_tan(ret, a, GMP_RNDN); } +void CFUNC(mpfr_t dst, mpfr_t src) { mpfr_set(dst, src, GMP_RNDN); } +#define FIXCOEF0 1.0 +#endif + +#if 0 +#define N 11 +#define S 35 +#define L 2 +#define MIN 1 //0.75 +#define MAX 1.5 +#define PMUL 2 +#define PADD 1 + +void TARGET(mpfr_t ret, mpfr_t a) { mpfr_log(ret, a, GMP_RNDN); } +void CFUNC(mpfr_t frd, mpfr_t fra) { + mpfr_t tmp, one; + mpfr_inits(tmp, one, NULL); + mpfr_set_d(one, 1, GMP_RNDN); + mpfr_add(tmp, fra, one, GMP_RNDN); + mpfr_sub(frd, fra, one, GMP_RNDN); + mpfr_div(frd, frd, tmp, GMP_RNDN); + mpfr_clears(tmp, one, NULL); +} +#define FIXCOEF0 2.0 +#endif + +#if 1 +#define N 12 +#define S 50 +#define L 2 +#define MIN -0.347 +#define MAX 0.347 // 0.5 log 2 +#define PMUL 1 +#define PADD 0 + +void TARGET(mpfr_t ret, mpfr_t a) { mpfr_exp(ret, a, GMP_RNDN); } +void CFUNC(mpfr_t dst, mpfr_t src) { mpfr_set(dst, src, GMP_RNDN); } +#define FIXCOEF0 1.0 +#define FIXCOEF1 1.0 +//#define FIXCOEF2 0.5 +#endif + +#if 0 +#define N 21 +#define S 100 +#define L 1 +#define P 1.1 +#define MIN 0.0 +#define MAX 1.0 +#define PMUL 2 +#define PADD 1 + +void TARGET(mpfr_t ret, mpfr_t a) { mpfr_atan(ret, a, GMP_RNDN); } +void CFUNC(mpfr_t dst, mpfr_t src) { mpfr_set(dst, src, GMP_RNDN); } +#define FIXCOEF0 1.0 +#endif + +#if 0 +#define N 20 +#define S 100 +#define L 0 +#define P 1.54 +#define MIN 0.0 +#define MAX 0.708 +#define PMUL 2 +#define PADD 1 + +void TARGET(mpfr_t ret, mpfr_t a) { mpfr_asin(ret, a, GMP_RNDN); } +void CFUNC(mpfr_t dst, mpfr_t src) { mpfr_set(dst, src, GMP_RNDN); } +#define FIXCOEF0 1.0 +#endif diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/gencoef/gencoef.c b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/gencoef/gencoef.c new file mode 100644 index 00000000000..62ff69d8476 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/gencoef/gencoef.c @@ -0,0 +1,375 @@ +// This is part of SLEEF, written by Naoki Shibata. http://shibatch.sourceforge.net + +// Since the original code for simplex algorithm is developed by Haruhiko Okumura and +// the code is distributed under the Creative Commons Attribution 4.0 International License, +// the contents under this directory are also distributed under the same license. + +#include +#include +#include +#include +#include +#include +#include +#include + +//#include "sp.h" +#include "dp.h" +//#include "ld.h" +//#include "qp.h" + +#undef VERBOSE + +#define PREC 4096 + +#define EPS 1e-50 + +#define PREC2 (PREC_TARGET*4) + +#ifndef P +#define P 1 +#endif + +#ifndef Q +#define Q 10000 +#endif + +void mpfr_zinit(mpfr_t m); +void regressMinRelError_fr(int n, int m, mpfr_t **x, mpfr_t *result); + +char *mpfrToStr(mpfr_t m) { + mpfr_t fra; + mpfr_init2(fra, mpfr_get_prec(m)); + + mpfr_abs(fra, m, GMP_RNDN); + mpfr_exp_t e; + char *s = mpfr_get_str(NULL, &e, 10, 0, fra, GMP_RNDN); + + char *ret = malloc(strlen(s) + 20); + + if (mpfr_sgn(m) == -1) ret[0] = '-'; else ret[0] = '+'; + ret[1] = '0'; + ret[2] = '.'; + + strcpy(&ret[3], s); + mpfr_free_str(s); + + char estr[10]; + sprintf(estr, "e%+d", (int)e); + strcat(ret, estr); + + mpfr_clears(fra, NULL); + return ret; +} + +double countULP(mpfr_t d, mpfr_t c) { + mpfr_t fry, frw; + mpfr_inits(fry, frw, NULL); + + double c2 = mpfr_get_d(c, GMP_RNDN); + if (c2 == 0 && mpfr_cmp_d(d, 0) != 0) return 10000; + + long e; + mpfr_get_d_2exp(&e, c, GMP_RNDN); + mpfr_set_ui_2exp(frw, 1, e-PREC_TARGET, GMP_RNDN); + + mpfr_sub(fry, d, c, GMP_RNDN); + mpfr_div(fry, fry, frw, GMP_RNDN); + double u = fabs(mpfr_get_d(fry, GMP_RNDN)); + + mpfr_clears(fry, frw, NULL); + + return u; +} + +void func(mpfr_t s, mpfr_t x, mpfr_t *coef, int n) { + mpfr_set_prec(s, PREC_TARGET); + mpfr_set(s, coef[n-1], GMP_RNDN); + + for(int i=n-1;i>0;i--) { + if (i == L-1) { + mpfr_t t; + mpfr_init2(t, PREC2); + mpfr_set(t, s, GMP_RNDN); + mpfr_set_prec(s, PREC2); + mpfr_set(s, t, GMP_RNDN); + mpfr_clear(t); + } + mpfr_mul(s, s, x, GMP_RNDN); + mpfr_add(s, s, coef[i-1], GMP_RNDN); + } +} + +int main(int argc, char **argv) +{ + int i, j; + int n, m; + double p; + + mpfr_set_default_prec(PREC); + +#if 0 + { + mpfr_t a, b; + mpfr_inits(a, b, NULL); + + float x = M_PI; + mpfr_set_d(a, x, GMP_RNDN); + x = nexttowardf(x, 100); + x = nexttowardf(x, 100); + x = nexttowardf(x, 100); + mpfr_set_d(b, x, GMP_RNDN); + + printf("%g\n", countULP(b, a)); + mpfr_clears(a, b, NULL); + exit(0); + } +#endif + +#if 0 + { + mpfr_t a, b; + mpfr_inits(a, b, NULL); + + double x = M_PI; + mpfr_set_d(a, x, GMP_RNDN); + x = nexttoward(x, 100); + x = nexttoward(x, 100); + x = nexttoward(x, 100); + mpfr_set_d(b, x, GMP_RNDN); + + printf("%g\n", countULP(b, a)); + mpfr_clears(a, b, NULL); + exit(0); + } +#endif + +#if 0 + { + mpfr_t a, b; + mpfr_inits(a, b, NULL); + + long double x = M_PI; + mpfr_set_ld(a, x, GMP_RNDN); + x = nexttowardl(x, 100); + x = nexttowardl(x, 100); + x = nexttowardl(x, 100); + mpfr_set_ld(b, x, GMP_RNDN); + + printf("%g\n", countULP(b, a)); + mpfr_clears(a, b, NULL); + exit(0); + } +#endif + +#if 0 + { + mpfr_t a, b; + mpfr_inits(a, b, NULL); + + __float128 x = M_PI; + mpfr_set_f128(a, x, GMP_RNDN); + x = nextafterq(x, 100); + x = nextafterq(x, 100); + x = nextafterq(x, 100); + mpfr_set_f128(b, x, GMP_RNDN); + + printf("%g\n", countULP(b, a)); + mpfr_clears(a, b, NULL); + exit(0); + } +#endif + + m = N+1; + n = argc >= 2 ? atoi(argv[1]) : S; + p = argc >= 3 ? atof(argv[2]) : P; + + mpfr_t **x, *result; // x[m][n], result[m] + + x = calloc(sizeof(mpfr_t *), m); + result = calloc(sizeof(mpfr_t), m); + for(i=0;i=0;i--) { + mpfr_set_prec(fra, PREC_TARGET+4); + mpfr_set(fra, result[i], GMP_RNDN); + + char *s; + printf("%s, \n", s = mpfrToStr(fra)); + free(s); + } + printf("\n"); + + mpfr_set_prec(fra, PREC); + + double emax = 0; + + for(i=0;i<=n*10;i++) { + double a = i * (double)(MAX - MIN) / (n*10.0) + MIN; + mpfr_set_d(fra, a, GMP_RNDN); + + CFUNC(frd, fra); + + mpfr_set_d(frb, 0, GMP_RNDN); + + for(j=m-1;j>=0;j--) { + mpfr_set_d(frc, (double)j*PMUL+PADD, GMP_RNDN); + mpfr_pow(frc, frd, frc, GMP_RNDN); + mpfr_mul(frc, frc, result[j], GMP_RNDN); + mpfr_add(frb, frb, frc, GMP_RNDN); + } + + TARGET(frc, fra); + double u = countULP(frb, frc); + + if (u > emax) emax = u; + } + + printf("Phase 1 : Max error = %g ULP\n\n", emax); + fflush(stdout); + + // + + mpfr_t bestcoef[N], curcoef[N]; + + for(i=0;i= L ? PREC_TARGET : PREC2); + mpfr_set(bestcoef[i], result[i], GMP_RNDN); + + mpfr_init2(curcoef[i], i >= L ? PREC_TARGET : PREC2); + mpfr_set(curcoef[i], result[i], GMP_RNDN); + } + + srandom(time(NULL)); + + mpfr_set_default_prec(PREC2); + + static mpfr_t a[Q], v[Q], am[Q], aa[Q]; + + for(i=0;i=0;j--) { + mpfr_set_d(frc, (double)j*PMUL+PADD, GMP_RNDN); + mpfr_pow(frc, a[i], frc, GMP_RNDN); + mpfr_mul(frc, frc, curcoef[j], GMP_RNDN); + mpfr_add(frb, frb, frc, GMP_RNDN); + } + + double e = countULP(frb, v[i]); + + //printf("c = %.20g, t = %.20g, ulp = %g\n", mpfr_get_d(v[i], GMP_RNDN), mpfr_get_d(frb, GMP_RNDN), e); + + if (!isfinite(e)) continue; + if (e > emax) { emax = e; worstx = mpfr_get_d(a[i], GMP_RNDN); } + esum += e; + } + mpfr_set_prec(frb, PREC); + + //printf("emax = %g\n", emax); + + if (emax < best || (emax == best && esum < bestsum)) { + for(i=0;i 10) printf("Max error = %g ULP, Sum error = %g (Max error at %g)\n", emax, esum, worstx); + if ((best - emax) / best > 0.0001) k = 0; + best = emax; + bestsum = esum; + bestworstx = worstx; + } + + for(i=0;i 0) { + for(int j=0;jr;j--) mpfr_nextbelow(curcoef[i]); + } + } + } + + printf("\n"); + + for(i=N-1;i>=0;i--) { + mpfr_set_prec(fra, i >= L ? PREC_TARGET+4 : PREC2); + mpfr_set(fra, bestcoef[i], GMP_RNDN); + + char *s; + printf("%s, \n", s = mpfrToStr(fra)); + free(s); + } + printf("\nPhase 2 : max error = %g ULP at %g\n", best, bestworstx); + + exit(0); +} diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/gencoef/gencoef.txt b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/gencoef/gencoef.txt new file mode 100644 index 00000000000..f57bdfe5352 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/gencoef/gencoef.txt @@ -0,0 +1,43 @@ + +With this small tool, the coefficients for polynomial approximation +used in kernels can be generated. + +Usage + +Edit gencoefdp.c. In the beginning of the file, specifications of the +parameters for generating coefficients are listed. Enable one of them +by changing #if. Then, run make to compile the source code. Run the +gencoef, and it will show the generated coefficients in a few minutes. + + +How it works + +There are two phases of the program. + +The first phase is the regression for minimizing the maximum relative +error. This problem can be reduced to a linear programming problem, +and the Simplex method is used in this implementation. This requires +multi-precision calculation, and the implementation uses the MPFR +library to do this. In this phase, only a small number of values +(specified by S macro, usually 40 or so) of the function to +approximate are sampled within the argument range. The function to +approximate can be given by FRFUNC function. Specifying higher values +for S does not always give better results. + +The second phase is to optimize the coefficients so that it gives good +accuracy with double precision calculation. In this phase, it checks +100000 points (specified by Q macro) within the specified argument +range to see if the polynomial gives good error bound. In some cases, +the last few terms have to be calculated in higher precision in order +to achieve 1 ULP overall accuracy, and this implementation can take +care of that. The L parameter specifies the number of high precision +coefficients. + +In some cases, it is desirable to fix the last few coefficients to +values like 1. This can be specified if you define FIXCOEF0 +macro. This sometimes does not work, however. In this case, you need +to specify the function to approximate as shown in the definition for +cos. + +Finding a set of good parameters is not a straightforward process. You +usually need many iterations of trial and error. diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/gencoef/ld.h b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/gencoef/ld.h new file mode 100644 index 00000000000..069202c4989 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/gencoef/ld.h @@ -0,0 +1,178 @@ +// This is part of SLEEF, written by Naoki +// Shibata. http://shibatch.sourceforge.net + +// The code in this file is distributed under the Creative Commons +// Attribution 4.0 International License. + +#define PREC_TARGET 64 + +#if 0 +#define N 8 // Degree of equation +#define S 40 // Number of samples for phase 1 +#define L 4 // Number of high precision coefficients +#define MIN 0.0 // Min argument +#define MAX (M_PI/4) // Max argument +#define PMUL 2 // The form of polynomial is y = x^(PADD+PMUL*0) + x^(PADD+PMUL*1) + ... +#define PADD 1 + +void TARGET(mpfr_t ret, mpfr_t a) { mpfr_sin(ret, a, GMP_RNDN); } // The function to approximate +void CFUNC(mpfr_t dst, mpfr_t src) { mpfr_set(dst, src, GMP_RNDN); } +#define FIXCOEF0 1.0 // Fix coef 0 to 1.0 +#endif + +#if 0 +#define N 10 +#define S 40 +#define L 2 +#define MIN 0.0 +#define MAX (M_PI/4) +void TARGET(mpfr_t ret, mpfr_t a) { // cos(x) - 1 + mpfr_t x; + mpfr_init(x); + mpfr_cos(ret, a, GMP_RNDN); + mpfr_set_ld(x, 1, GMP_RNDN); + mpfr_sub(ret, ret, x, GMP_RNDN); + mpfr_clear(x); +} +void CFUNC(mpfr_t dst, mpfr_t src) { mpfr_set(dst, src, GMP_RNDN); } + +#define PMUL 2 +#define PADD 2 +#define FIXCOEF0 (-0.5) +#endif + + +#if 0 // for xsincospi4_u05 +#define N 9 +#define S 40 +#define L 2 +#define MIN 0.0 +#define MAX 1.0 +#define PMUL 2 +#define PADD 1 + +void TARGET(mpfr_t ret, mpfr_t a) { + mpfr_t x, y; + mpfr_inits(x, y, NULL); + mpfr_const_pi(x, GMP_RNDN); + mpfr_set_d(y, 1.0/4, GMP_RNDN); + mpfr_mul(x, x, y, GMP_RNDN); + mpfr_mul(x, x, a, GMP_RNDN); + mpfr_sin(ret, x, GMP_RNDN); + mpfr_clears(x, y, NULL); +} +void CFUNC(mpfr_t dst, mpfr_t src) { mpfr_set(dst, src, GMP_RNDN); } +#endif + +#if 0 // for xsincospi4_u05 +#define N 9 +#define S 40 +#define L 2 +#define MIN 0.0 +#define MAX 1.0 +void TARGET(mpfr_t ret, mpfr_t a) { // cos(x) - 1 + mpfr_t x, y; + mpfr_inits(x, y, NULL); + mpfr_const_pi(x, GMP_RNDN); + mpfr_set_d(y, 1.0/4, GMP_RNDN); + mpfr_mul(x, x, y, GMP_RNDN); + mpfr_mul(x, x, a, GMP_RNDN); + mpfr_cos(ret, x, GMP_RNDN); + mpfr_set_ld(x, 1, GMP_RNDN); + mpfr_sub(ret, ret, x, GMP_RNDN); + mpfr_clears(x, y, NULL); +} +void CFUNC(mpfr_t dst, mpfr_t src) { mpfr_set(dst, src, GMP_RNDN); } +#define PMUL 2 +#define PADD 2 +#endif + + +#if 0 // for xsincospi4 +#define N 7 +#define S 40 +#define L 0 +#define MIN 0.0 +#define MAX 1.0 +#define PMUL 2 +#define PADD 1 + +void TARGET(mpfr_t ret, mpfr_t a) { + mpfr_t x, y; + mpfr_inits(x, y, NULL); + mpfr_const_pi(x, GMP_RNDN); + mpfr_set_d(y, 1.0/4, GMP_RNDN); + mpfr_mul(x, x, y, GMP_RNDN); + mpfr_mul(x, x, a, GMP_RNDN); + mpfr_sin(ret, x, GMP_RNDN); + mpfr_clears(x, y, NULL); +} +void CFUNC(mpfr_t dst, mpfr_t src) { mpfr_set(dst, src, GMP_RNDN); } +#endif + + +#if 0 +#define N 17 +#define S 40 +#define L 0 +#define MIN 0.0 +#define MAX (M_PI/4) +#define PMUL 2 +#define PADD 1 + +void TARGET(mpfr_t ret, mpfr_t a) { mpfr_tan(ret, a, GMP_RNDN); } +void CFUNC(mpfr_t dst, mpfr_t src) { mpfr_set(dst, src, GMP_RNDN); } +#define FIXCOEF0 1.0 +#endif + +#if 0 +#define N 9 +#define S 40 +#define L 2 +#define MIN 1 //0.75 +#define MAX 1.5 +#define PMUL 2 +#define PADD 1 + +void TARGET(mpfr_t ret, mpfr_t a) { mpfr_log(ret, a, GMP_RNDN); } +void CFUNC(mpfr_t frd, mpfr_t fra) { + mpfr_t tmp, one; + mpfr_inits(tmp, one, NULL); + mpfr_set_d(one, 1, GMP_RNDN); + mpfr_add(tmp, fra, one, GMP_RNDN); + mpfr_sub(frd, fra, one, GMP_RNDN); + mpfr_div(frd, frd, tmp, GMP_RNDN); + mpfr_clear(tmp, one, NULL); +} +#define FIXCOEF0 2.0 +#endif + +#if 0 +#define N 12 +#define S 50 +#define L 0 +#define MIN -0.347 +#define MAX 0.347 // 0.5 log 2 +#define PMUL 1 +#define PADD 0 + +void TARGET(mpfr_t ret, mpfr_t a) { mpfr_exp(ret, a, GMP_RNDN); } +void CFUNC(mpfr_t dst, mpfr_t src) { mpfr_set(dst, src, GMP_RNDN); } +#define FIXCOEF0 1.0 +#define FIXCOEF1 1.0 +#define FIXCOEF2 0.5 +#endif + +#if 0 +#define N 22 +#define S 100 +#define L 2 +#define MIN 0.0 +#define MAX 1.0 +#define PMUL 2 +#define PADD 1 + +void TARGET(mpfr_t ret, mpfr_t a) { mpfr_atan(ret, a, GMP_RNDN); } +void CFUNC(mpfr_t dst, mpfr_t src) { mpfr_set(dst, src, GMP_RNDN); } +#define FIXCOEF0 1.0 +#endif diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/gencoef/mkrempitab.c b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/gencoef/mkrempitab.c new file mode 100644 index 00000000000..cf48cd3e97c --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/gencoef/mkrempitab.c @@ -0,0 +1,121 @@ +#include +#include +#include +#include +#include + +static int64_t doubleToRawLongBits(double d) { + union { + double f; + int64_t i; + } tmp; + tmp.f = d; + return tmp.i; +} + +static double longBitsToDouble(int64_t i) { + union { + double f; + int64_t i; + } tmp; + tmp.i = i; + return tmp.f; +} + +static double removelsb(double d) { + return longBitsToDouble(doubleToRawLongBits(d) & 0xfffffffffffffffeLL); +} + +static int32_t floatToRawIntBits(float d) { + union { + float f; + int32_t i; + } tmp; + tmp.f = d; + return tmp.i; +} + +static float intBitsToFloat(int32_t i) { + union { + float f; + int32_t i; + } tmp; + tmp.i = i; + return tmp.f; +} + +static float removelsbf(float x) { + return intBitsToFloat(0xfffffffc & floatToRawIntBits(x)); +} + +int main(int argc, char **argv) { + mpfr_set_default_prec(2048); + mpfr_t pi, rpi, xrpi, x, y, z, r; + mpfr_inits(pi, rpi, xrpi, x, y, z, r, NULL); + mpfr_const_pi(pi, GMP_RNDN); + mpfr_set_d(x, 0.5, GMP_RNDN); + mpfr_div(rpi, x, pi, GMP_RNDN); + + printf("NOEXPORT ALIGNED(64) const double rempitabdp[] = {\n"); + for(int i=55;i<1024;i++) { + int M = i > 700 ? -64 : 0; + int ex = i - 53; + if (ex < -52) ex = -52; + mpfr_set_d(x, ldexp(1, ex), GMP_RNDN); + mpfr_mul(y, x, rpi, GMP_RNDN); + mpfr_frac(xrpi, y, GMP_RNDN); + mpfr_div(xrpi, xrpi, x, GMP_RNDN); + + mpfr_set_exp(xrpi, mpfr_get_exp(xrpi) - M); + + mpfr_set(x, xrpi, GMP_RNDN); + + double rpi0 = removelsb(mpfr_get_d(x, GMP_RNDN)); + mpfr_set_d(y, rpi0, GMP_RNDN); + mpfr_sub(x, x, y, GMP_RNDN); + + double rpi1 = removelsb(mpfr_get_d(x, GMP_RNDN)); + mpfr_set_d(y, rpi1, GMP_RNDN); + mpfr_sub(x, x, y, GMP_RNDN); + + double rpi2 = removelsb(mpfr_get_d(x, GMP_RNDN)); + mpfr_set_d(y, rpi2, GMP_RNDN); + mpfr_sub(x, x, y, GMP_RNDN); + + double rpi3 = mpfr_get_d(x, GMP_RNDN); + + printf(" %.20g, %.20g, %.20g, %.20g,\n", rpi0, rpi1, rpi2, rpi3); + } + printf("};\n\n"); + + printf("NOEXPORT ALIGNED(64) const float rempitabsp[] = {\n"); + for(int i=25;i<128;i++) { + int M = i > 90 ? -64 : 0; + int ex = i - 23; + mpfr_set_d(x, ldexp(1, ex), GMP_RNDN); + mpfr_mul(y, x, rpi, GMP_RNDN); + mpfr_frac(xrpi, y, GMP_RNDN); + mpfr_div(xrpi, xrpi, x, GMP_RNDN); + + mpfr_set_exp(xrpi, mpfr_get_exp(xrpi) - M); + + mpfr_set(x, xrpi, GMP_RNDN); + + float rpi20 = removelsbf(mpfr_get_d(x, GMP_RNDN)); + mpfr_set_d(y, rpi20, GMP_RNDN); + mpfr_sub(x, x, y, GMP_RNDN); + + float rpi21 = removelsbf(mpfr_get_d(x, GMP_RNDN)); + mpfr_set_d(y, rpi21, GMP_RNDN); + mpfr_sub(x, x, y, GMP_RNDN); + + float rpi22 = removelsbf(mpfr_get_d(x, GMP_RNDN)); + mpfr_set_d(y, rpi22, GMP_RNDN); + mpfr_sub(x, x, y, GMP_RNDN); + + float rpi23 = mpfr_get_d(x, GMP_RNDN); + + printf(" %.10g, %.10g, %.10g, %.10g,\n", rpi20, rpi21, rpi22, rpi23); + } + printf("};\n"); +} diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/gencoef/mkrempitabqp.c b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/gencoef/mkrempitabqp.c new file mode 100644 index 00000000000..51e02c619ec --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/gencoef/mkrempitabqp.c @@ -0,0 +1,63 @@ +#include +#include +#include +#include +#include +#include +#include + +#define N 8 +#define B 8 +#define NCOL (53-B) +#define NROW ((16385+(53-B)*N-106)/NCOL+1) + +static double *rempitabqp = NULL; + +void generateRempitabqp() { + rempitabqp = calloc(16385-106+(53-B)*(N+1), sizeof(double)); + + int orgprec = mpfr_get_default_prec(); + mpfr_set_default_prec(18000); + + mpfr_t pi, m, n, o; + mpfr_inits(pi, m, n, o, NULL); + mpfr_const_pi(pi, GMP_RNDN); + + mpfr_d_div(n, 0.5, pi, GMP_RNDN); + + for(int e=106;e<16385+(53-B)*N;e++) { + mpfr_set(m, n, GMP_RNDN); + + mpfr_set_ui_2exp(o, 1, -(113 - e), GMP_RNDN); + mpfr_mul(m, m, o, GMP_RNDN); + + mpfr_frac(m, m, GMP_RNDN); + + mpfr_set_ui_2exp(o, 1, (53-B), GMP_RNDN); + mpfr_mul(m, m, o, GMP_RNDN); + + mpfr_trunc(m, m); + + mpfr_set_ui_2exp(o, 1, 7-(53-B), GMP_RNDN); + mpfr_mul(m, m, o, GMP_RNDN); + + int col = (e - 106) % NCOL; + int row = (e - 106) / NCOL; + rempitabqp[col * NROW + row] = mpfr_get_d(m, GMP_RNDN); + } + + mpfr_clears(pi, m, n, o, NULL); + mpfr_set_default_prec(orgprec); +} + + +int main(int argc, char **argv) { + generateRempitabqp(); + + printf("NOEXPORT const double Sleef_rempitabqp[] = {\n "); + for(int i=0;i<16385-106+(53-B)*(N+1);i++) { + printf("%.20g, ", rempitabqp[i]); + if ((i & 3) == 3) printf("\n "); + } + printf("\n};\n"); +} diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/gencoef/qp.h b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/gencoef/qp.h new file mode 100644 index 00000000000..ec0d409e28f --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/gencoef/qp.h @@ -0,0 +1,161 @@ +// This is part of SLEEF, written by Naoki +// Shibata. http://shibatch.sourceforge.net + +// The code in this file is distributed under the Creative Commons +// Attribution 4.0 International License. + +#define PREC_TARGET 113 + +// + +#if 0 +#define N 15 // Degree of equation +#define S 150 // Number of samples for phase 1 +#define L 0 // Number of high precision coefficients +#define P 0.37 +#define MIN 0.0 // Min argument +#define MAX (M_PI/2) // Max argument +#define PMUL 2 // The form of polynomial is y = x^(PADD+PMUL*0) + x^(PADD+PMUL*1) + ... +#define PADD 3 +void TARGET(mpfr_t ret, mpfr_t a) { // The function to approximate + mpfr_sin(ret, a, GMP_RNDN); + mpfr_sub(ret, ret, a, GMP_RNDN); // ret = sin(a) - a +} +void CFUNC(mpfr_t dst, mpfr_t src) { mpfr_set(dst, src, GMP_RNDN); } +#endif + +#if 0 +#define N 15 +#define S 150 +#define L 0 +#define MIN 0.0 +#define MAX (M_PI/2) +void TARGET(mpfr_t ret, mpfr_t a) { // cos(x) - 1 + mpfr_t x; + mpfr_init(x); + mpfr_cos(ret, a, GMP_RNDN); + mpfr_set_ld(x, 1, GMP_RNDN); + mpfr_sub(ret, ret, x, GMP_RNDN); + mpfr_clear(x); +} +void CFUNC(mpfr_t dst, mpfr_t src) { mpfr_set(dst, src, GMP_RNDN); } + +#define PMUL 2 +#define PADD 2 +//#define FIXCOEF0 (-0.5) +#endif + + +#if 0 // for xsincospi4_u05 +#define N 13 +#define S 150 +#define L 2 +#define P 0.9 +#define MIN 0.0 +#define MAX 1.0 +#define PMUL 2 +#define PADD 1 + +void TARGET(mpfr_t ret, mpfr_t a) { + mpfr_t x, y; + mpfr_inits(x, y, NULL); + mpfr_const_pi(x, GMP_RNDN); + mpfr_set_d(y, 1.0/4, GMP_RNDN); + mpfr_mul(x, x, y, GMP_RNDN); + mpfr_mul(x, x, a, GMP_RNDN); + mpfr_sin(ret, x, GMP_RNDN); + mpfr_clears(x, y, NULL); +} +void CFUNC(mpfr_t dst, mpfr_t src) { mpfr_set(dst, src, GMP_RNDN); } +#endif + +#if 0 // for xsincospi4_u05 +#define N 13 +#define S 150 +#define L 2 +#define MIN 0.0 +#define MAX 1.0 +void TARGET(mpfr_t ret, mpfr_t a) { // cos(x) - 1 + mpfr_t x, y; + mpfr_inits(x, y, NULL); + mpfr_const_pi(x, GMP_RNDN); + mpfr_set_d(y, 1.0/4, GMP_RNDN); + mpfr_mul(x, x, y, GMP_RNDN); + mpfr_mul(x, x, a, GMP_RNDN); + mpfr_cos(ret, x, GMP_RNDN); + mpfr_set_ld(x, 1, GMP_RNDN); + mpfr_sub(ret, ret, x, GMP_RNDN); + mpfr_clears(x, y, NULL); +} +void CFUNC(mpfr_t dst, mpfr_t src) { mpfr_set(dst, src, GMP_RNDN); } +#define PMUL 2 +#define PADD 2 +#endif + +#if 0 // running +#define N 31 +#define S 100 +#define P 1.7 +#define L 0 +#define MIN 0.0 +#define MAX (M_PI/4) +#define PMUL 2 +#define PADD 1 + +void TARGET(mpfr_t ret, mpfr_t a) { mpfr_tan(ret, a, GMP_RNDN); } +void CFUNC(mpfr_t dst, mpfr_t src) { mpfr_set(dst, src, GMP_RNDN); } +#define FIXCOEF0 1.0 +#endif + +#if 0 // running +#define N 20 +#define S 110 +#define L 2 +#define MIN 1 //0.75 +#define MAX 1.5 +#define PMUL 2 +#define PADD 1 + +void TARGET(mpfr_t ret, mpfr_t a) { mpfr_log(ret, a, GMP_RNDN); } +void CFUNC(mpfr_t frd, mpfr_t fra) { + mpfr_t tmp, one; + mpfr_inits(tmp, one, NULL); + mpfr_set_d(one, 1, GMP_RNDN); + mpfr_add(tmp, fra, one, GMP_RNDN); + mpfr_sub(frd, fra, one, GMP_RNDN); + mpfr_div(frd, frd, tmp, GMP_RNDN); + mpfr_clears(tmp, one, NULL); +} +#define FIXCOEF0 2.0 +#endif + +#if 1 +#define N 22 +#define S 140 +#define L 2 +#define MIN -0.347 +#define MAX 0.347 // 0.5 log 2 +#define PMUL 1 +#define PADD 0 + +void TARGET(mpfr_t ret, mpfr_t a) { mpfr_exp(ret, a, GMP_RNDN); } +void CFUNC(mpfr_t dst, mpfr_t src) { mpfr_set(dst, src, GMP_RNDN); } +#define FIXCOEF0 1.0 +#define FIXCOEF1 1.0 +//#define FIXCOEF2 0.5 +#endif + +#if 0 // running +#define N 45 +#define S 100 +#define P 1.55 +#define L 2 +#define MIN 0.0 +#define MAX 1.0 +#define PMUL 2 +#define PADD 1 + +void TARGET(mpfr_t ret, mpfr_t a) { mpfr_atan(ret, a, GMP_RNDN); } +void CFUNC(mpfr_t dst, mpfr_t src) { mpfr_set(dst, src, GMP_RNDN); } +#define FIXCOEF0 1.0 +#endif diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/gencoef/simplexfr.c b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/gencoef/simplexfr.c new file mode 100644 index 00000000000..f58ed3d5a0d --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/gencoef/simplexfr.c @@ -0,0 +1,459 @@ + // The original code for simplex algorithm is taken from Haruhiko Okumura's book. +// https://oku.edu.mie-u.ac.jp/~okumura/algo/ +// The code is distributed under the Creative Commons Attribution 4.0 International License. +// https://creativecommons.org/licenses/by/4.0/ + +// The code is modified by Naoki Shibata to process arbitrary precision numbers. + +#include +#include +#include +#include +#include +#include +#include + +#define PREC 4096 +#define EPS 1e-50 + +#define OK 0 +#define MAXIMIZABLE_TO_INFINITY 1 +#define NOT_FEASIBLE 2 +#define ERROR (-1) + +#define NOP (-1) +#define EQU (0) +#define LEQ 1 +#define GEQ 2 + +static int m, n, n1, n2, n3, jmax; +static int *col, *row, *nonzero_row, *inequality; +static mpfr_t **a, *c, **q, *pivotcolumn; + +static mpfr_t zero, one, eps, minuseps, large; + +void mpfr_zinit(mpfr_t m) { + mpfr_init(m); + mpfr_set_d(m, 0, GMP_RNDN); +} + +static void init(int n0, int m0) { + int i, j; + + m = m0; n = n0; + + mpfr_init(zero); mpfr_set_d(zero, 0, GMP_RNDN); + mpfr_init(one); mpfr_set_d(one, 1, GMP_RNDN); + + mpfr_init(eps); + mpfr_set_d(eps, EPS, GMP_RNDN); + + mpfr_init(minuseps); + mpfr_set_d(minuseps, -EPS, GMP_RNDN); + + mpfr_init(large); + mpfr_set_d(large, 1.0 / EPS, GMP_RNDN); + + a = malloc(sizeof(mpfr_t *) * (m + 1)); + for(i=0;i < m+1;i++) { + a[i] = malloc(sizeof(mpfr_t) * (n + 1)); + for(j=0;j < (n+1);j++) { + mpfr_zinit(a[i][j]); + } + } + + q = malloc(sizeof(mpfr_t *) * (m + 1)); + for(i=0;i < m+1;i++) { + q[i] = malloc(sizeof(mpfr_t) * (m + 1)); + for(j=0;j < m+1;j++) { + mpfr_zinit(q[i][j]); + } + } + + c = malloc(sizeof(mpfr_t) * (n + 1)); + for(j=0;j < (n+1);j++) { + mpfr_zinit(c[j]); + } + + pivotcolumn = malloc(sizeof(mpfr_t) * (m + 1)); + for(j=0;j < (m+1);j++) { + mpfr_zinit(pivotcolumn[j]); + } + + col = calloc(m+1, sizeof(int)); + row = calloc(n+2*m+1, sizeof(int)); + nonzero_row = calloc(n+2*m+1, sizeof(int)); + inequality = calloc(m+1, sizeof(int)); +} + +static void dispose() { + mpfr_clears(zero, one, eps, minuseps, large, (mpfr_ptr)0); + + int i, j; + + for(i=0;i < m+1;i++) { + for(j=0;j < m+1;j++) { + mpfr_clear(q[i][j]); + } + free(q[i]); + } + free(q); + + for(i=0;i < m+1;i++) { + for(j=0;j < n+1;j++) { + mpfr_clear(a[i][j]); + } + free(a[i]); + } + free(a); + + for(j=0;j < n+1;j++) { + mpfr_clear(c[j]); + } + free(c); + + for(j=0;j < m+1;j++) { + mpfr_clear(pivotcolumn[j]); + } + free(pivotcolumn); + + free(col); + free(row); + free(nonzero_row); + free(inequality); +} + +static void prepare() { + int i; + + n1 = n; + for (i = 1; i <= m; i++) + if (inequality[i] == GEQ) { + n1++; nonzero_row[n1] = i; + } + n2 = n1; + for (i = 1; i <= m; i++) + if (inequality[i] == LEQ) { + n2++; col[i] = n2; + nonzero_row[n2] = row[n2] = i; + } + n3 = n2; + for (i = 1; i <= m; i++) + if (inequality[i] != LEQ) { + n3++; col[i] = n3; + nonzero_row[n3] = row[n3] = i; + } + + for (i = 0; i <= m; i++) { + mpfr_set_d(q[i][i], 1, GMP_RNDN); + } +} + +static void tableau(mpfr_t ret, int i, int j) { + int k; + + if (col[i] < 0) { mpfr_set_d(ret, 0, GMP_RNDN); return; } + + if (j <= n) { + mpfr_t s; + mpfr_zinit(s); + mpfr_set_d(s, 0, GMP_RNDN); + + mpfr_t *tab = malloc(sizeof(mpfr_t) * (m + 1)); + mpfr_ptr *ptab = malloc(sizeof(mpfr_ptr) * (m + 1)); + for (k = 0; k <= m; k++) { + mpfr_zinit(tab[k]); + ptab[k] = (mpfr_ptr)&tab[k]; + mpfr_mul(tab[k], q[i][k], a[k][j], GMP_RNDN); + } + mpfr_sum(s, ptab, m+1, GMP_RNDN); + for (k = 0; k <= m; k++) { + mpfr_clear(tab[k]); + } + free(ptab); + free(tab); + + mpfr_set(ret, s, GMP_RNDN); + mpfr_clear(s); + return; + } + + mpfr_set(ret, q[i][nonzero_row[j]], GMP_RNDN); + + if (j <= n1) { mpfr_neg(ret, ret, GMP_RNDN); return; } + if (j <= n2 || i != 0) return; + + mpfr_add(ret, ret, one, GMP_RNDN); + return; +} + +static void pivot(int ipivot, int jpivot) { + int i, j; + mpfr_t u; + + mpfr_zinit(u); + + mpfr_set(u, pivotcolumn[ipivot], GMP_RNDN); + + for (j = 1; j <= m; j++) { + mpfr_div(q[ipivot][j], q[ipivot][j], u, GMP_RNDN); + } + + for (i = 0; i <= m; i++) + if (i != ipivot) { + mpfr_set(u, pivotcolumn[i], GMP_RNDN); + + for (j = 1; j <= m; j++) { + mpfr_fms(q[i][j], q[ipivot][j], u, q[i][j], GMP_RNDN); + mpfr_neg(q[i][j], q[i][j], GMP_RNDN); + } + } + + row[col[ipivot]] = 0; + + col[ipivot] = jpivot; row[jpivot] = ipivot; + + mpfr_clear(u); +} + +static int minimize() { + int i, ipivot, jpivot; + mpfr_t t, u; + mpfr_inits(t, u, (mpfr_ptr)0); + + for (;;) { + for (jpivot = 1; jpivot <= jmax; jpivot++) { + if (row[jpivot] == 0) { + tableau(pivotcolumn[0], 0, jpivot); + if (mpfr_cmp(pivotcolumn[0], minuseps) < 0) break; + } + } + if (jpivot > jmax) { + mpfr_clears(t, u, (mpfr_ptr)0); + return 1; + } + + mpfr_set(u, large, GMP_RNDN); + ipivot = 0; + for (i = 1; i <= m; i++) { + tableau(pivotcolumn[i], i, jpivot); + if (mpfr_cmp(pivotcolumn[i], eps) > 0) { + tableau(t, i, 0); + mpfr_div(t, t, pivotcolumn[i], GMP_RNDN); + if (mpfr_cmp(t, u) < 0) { ipivot = i; mpfr_set(u, t, GMP_RNDN); } + } + } + if (ipivot == 0) { + mpfr_clears(t, u, (mpfr_ptr)0); + return 0; // the objective function can be minimized to -infinite + } + pivot(ipivot, jpivot); + } +} + +static int phase1() { + int i, j; + mpfr_t u; + mpfr_zinit(u); + + jmax = n3; + for (i = 0; i <= m; i++) { + if (col[i] > n2) mpfr_set_d(q[0][i], -1, GMP_RNDN); + } + + minimize(); + + tableau(u, 0, 0); + if (mpfr_cmp(u, minuseps) < 0) { + mpfr_clear(u); + return 0; + } + for (i = 1; i <= m; i++) { + if (col[i] > n2) { + col[i] = -1; + } + } + mpfr_set_d(q[0][0], 1, GMP_RNDN); + for (j = 1; j <= m; j++) mpfr_set_d(q[0][j], 0, GMP_RNDN); + for (i = 1; i <= m; i++) { + if ((j = col[i]) > 0 && j <= n && mpfr_cmp_d(c[j], 0) != 0) { + mpfr_set(u, c[j], GMP_RNDN); + for (j = 1; j <= m; j++) { + mpfr_fms(q[0][j], q[i][j], u, q[0][j], GMP_RNDN); + mpfr_neg(q[0][j], q[0][j], GMP_RNDN); + } + } + + } + + mpfr_clear(u); + return 1; +} + +static int phase2() { + int j; + jmax = n2; + for (j = 0; j <= n; j++) { + mpfr_set(a[0][j], c[j], GMP_RNDN); + } + + return minimize(); +} + +int solve_fr(mpfr_t *result, int n0, int m0, mpfr_t **a0, int *ineq0, mpfr_t *c0) { + int i,j; + + m = m0; // number of inequations + n = n0+1; // number of variables + + init(n, m); + + mpfr_t csum; + mpfr_zinit(csum); + + for(j=0;j /dev/null) +ARCH := $(shell uname -p) + +all : +ifndef BUILDDIR + @echo + @echo Please set the build directory to BUILDDIR environment variable and run make once again. + @echo e.g. export BUILDDIR='`pwd`'/../../build + @echo +else + @echo + @echo You can start measurement by "'"make measure"'". +ifdef ICCAVAILABLE + @echo You can start measurement with SVML by "'"make measureSVML"'". +endif + @echo Then, you can plot the results of measurement by "'"make plot"'". + @echo + @echo You have to install java and gnuplot to do plotting. + @echo Stop all tasks on the computer before starting measurement. + @echo +endif + +benchsvml128_10.o : benchsvml128.c bench.h + -command -v icc >/dev/null 2>&1 && icc benchsvml128.c -Wall -I.. -DSVMLULP=1 -fimf-max-error=1.0 -fimf-domain-exclusion=0 -march=core-avx2 -O0 -lm -c -o benchsvml128_10.o + +benchsvml128_40.o : benchsvml128.c bench.h + -command -v icc >/dev/null 2>&1 && icc benchsvml128.c -Wall -I.. -DSVMLULP=4 -fimf-max-error=4.0 -fimf-domain-exclusion=0 -march=core-avx2 -O0 -lm -c -o benchsvml128_40.o + +benchsvml256_10.o : benchsvml256.c bench.h + -command -v icc >/dev/null 2>&1 && icc benchsvml256.c -Wall -I.. -DSVMLULP=1 -fimf-max-error=1.0 -fimf-domain-exclusion=0 -march=core-avx2 -O0 -lm -c -o benchsvml256_10.o + +benchsvml256_40.o : benchsvml256.c bench.h + -command -v icc >/dev/null 2>&1 && icc benchsvml256.c -Wall -I.. -DSVMLULP=4 -fimf-max-error=4.0 -fimf-domain-exclusion=0 -march=core-avx2 -O0 -lm -c -o benchsvml256_40.o + +benchsvml512_10.o : benchsvml512.c bench.h + -command -v icc >/dev/null 2>&1 && icc benchsvml512.c -Wall -I.. -DSVMLULP=1 -fimf-max-error=1.0 -fimf-domain-exclusion=0 -xCOMMON-AVX512 -O0 -lm -c -o benchsvml512_10.o + +benchsvml512_40.o : benchsvml512.c bench.h + -command -v icc >/dev/null 2>&1 && icc benchsvml512.c -Wall -I.. -DSVMLULP=4 -fimf-max-error=4.0 -fimf-domain-exclusion=0 -xCOMMON-AVX512 -O0 -lm -c -o benchsvml512_40.o + + +benchsvml_10 : benchsvml.c benchsvml128_10.o benchsvml256_10.o benchsvml512_10.o bench.h + -command -v icc >/dev/null 2>&1 && icc benchsvml.c benchsvml128_10.o benchsvml256_10.o benchsvml512_10.o -Wall -I.. -DSVMLULP=1 -fimf-max-error=1.0 -fimf-domain-exclusion=0 -O0 -march=native -lm -o benchsvml_10 + +benchsvml_40 : benchsvml.c benchsvml128_40.o benchsvml256_40.o benchsvml512_40.o bench.h + -command -v icc >/dev/null 2>&1 && icc benchsvml.c benchsvml128_40.o benchsvml256_40.o benchsvml512_40.o -Wall -I.. -DSVMLULP=4 -fimf-max-error=4.0 -fimf-domain-exclusion=0 -O0 -march=native -lm -o benchsvml_40 + +# + +ifeq ($(ARCH),aarch64) + +benchsleef : benchsleef.c benchsleef128.o bench.h + $(CC) benchsleef.c benchsleef128.o -Wall -O0 -g -I$(BUILDDIR)/include -L$(BUILDDIR)/lib -Wno-attributes -lsleef -lm -o benchsleef + +benchsleef128.o : benchsleef128.c bench.h + $(CC) benchsleef128.c -Wall -march=native -O0 -g -I$(BUILDDIR)/include -L$(BUILDDIR)/lib -Wno-attributes -c + +else ifeq ($(ARCH),s390x) + +benchsleef : benchsleef.c benchsleef128.o bench.h + $(CC) benchsleef.c benchsleef128.o -Wall -march=native -O0 -g -I$(BUILDDIR)/include -L$(BUILDDIR)/lib -Wno-attributes -lsleef -lm -o benchsleef + +benchsleef128.o : benchsleef128.c bench.h + $(CC) benchsleef128.c -Wall -mzvector -march=native -O0 -g -I$(BUILDDIR)/include -L$(BUILDDIR)/lib -Wno-attributes -c + +else ifeq ($(ARCH),ppc64le) + +benchsleef : benchsleef.c benchsleef128.o bench.h + $(CC) benchsleef.c benchsleef128.o -Wall -mcpu=native -O0 -g -I$(BUILDDIR)/include -L$(BUILDDIR)/lib -Wno-attributes -lsleef -lm -o benchsleef + +benchsleef128.o : benchsleef128.c bench.h + $(CC) benchsleef128.c -Wall -mcpu=native -O0 -g -I$(BUILDDIR)/include -L$(BUILDDIR)/lib -Wno-attributes -c + +else + +benchsleef : benchsleef.c benchsleef128.o benchsleef256.o benchsleef512.o bench.h + $(CC) benchsleef.c benchsleef128.o benchsleef256.o benchsleef512.o -Wall -O0 -g -I$(BUILDDIR)/include -L$(BUILDDIR)/lib -Wno-attributes -lsleef -lm -o benchsleef + +benchsleef128.o : benchsleef128.c bench.h + $(CC) benchsleef128.c -Wall -march=native -O0 -g -I$(BUILDDIR)/include -L$(BUILDDIR)/lib -Wno-attributes -c + +benchsleef256.o : benchsleef256.c bench.h + $(CC) benchsleef256.c -Wall -march=native -O0 -g -I$(BUILDDIR)/include -L$(BUILDDIR)/lib -Wno-attributes -c + +benchsleef512.o : benchsleef512.c bench.h + $(CC) benchsleef512.c -Wall -mavx512f -O0 -g -I$(BUILDDIR)/include -L$(BUILDDIR)/lib -Wno-attributes -c + +endif + +# + +ProcessData.class : ProcessData.java + javac ProcessData.java + +# + +ifndef BUILDDIR +measure : + @echo + @echo Please set the build directory to BUILDDIR environment variable and run make once again. + @echo e.g. export BUILDDIR='`pwd`'/../../build + @echo +else +measure : benchsleef + chmod +x ./measure.sh + LD_LIBRARY_PATH=$(BUILDDIR)/lib ./measure.sh ./benchsleef + @echo + @echo Now, you can plot the results of measurement by "'"make plot"'". + @echo You can do another measurement by "'"make measure"'". +ifdef ICCAVAILABLE + @echo You can start another measurement with SVML by "'"make measureSVML"'". +endif + @echo You can start over by "'"make restart"'". + @echo +endif + +measureSVML : all benchsvml_10 benchsvml_40 + chmod +x ./measure.sh + ./measure.sh ./benchsvml_10 ./benchsvml_40 + @echo + @echo Now, you can plot the results of measurement by "'"make plot"'". + @echo You can do another measurement by "'"make measure"'". +ifdef ICCAVAILABLE + @echo You can start another measurement with SVML by "'"make measureSVML"'". +endif + @echo You can start over by "'"make restart"'". + @echo + +plot : ProcessData.class counter.txt + java ProcessData *dptrig*.out + gnuplot script.out + mv output.png trigdp.png + java ProcessData *dpnontrig*.out + gnuplot script.out + mv output.png nontrigdp.png + java ProcessData *sptrig*.out + gnuplot script.out + mv output.png trigsp.png + java ProcessData *spnontrig*.out + gnuplot script.out + mv output.png nontrigsp.png + @echo + @echo Plotted results are in trigdp.png, nontrigdp.png, trigsp.png and nontrigsp.png. + @echo + +clean : + rm -f *~ a.out *.so *.so.* *.a *.s *.o + rm -rf *.dSYM *.dylib + rm -f *.obj *.lib *.dll *.exp *.exe *.stackdump + rm -f *.class *.png benchsleef benchsvml_10 benchsvml_40 *.out counter.txt + +restart : + rm -f *.out counter.txt diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-benchmarks/ProcessData.java b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-benchmarks/ProcessData.java new file mode 100644 index 00000000000..7231191e990 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-benchmarks/ProcessData.java @@ -0,0 +1,193 @@ +import java.util.*; +import java.io.*; + +public class ProcessData { + static final int DP = 64, SP = 32; + + static LinkedHashMap funcNameOrder = new LinkedHashMap(); + + static class Key { + final String funcName; + + final int prec, bits; + final ArrayList range = new ArrayList(); + final double ulps; + + Key(String s) { + String[] a = s.split(","); + + funcName = a[0].trim(); + if (funcNameOrder.get(funcName) == null) { + funcNameOrder.put(funcName, funcNameOrder.size()); + } + + prec = + a[1].trim().equals("DP") ? DP : + a[1].trim().equals("SP") ? SP : + 0; + + bits = Integer.parseInt(a[2].trim()); + + int c; + + for(c = 3;;c++) { + if (a[c].trim().endsWith("ulps")) break; + range.add(Double.parseDouble(a[c])); + } + + ulps = Double.parseDouble(a[c].trim().replace("ulps", "")); + } + + public int hashCode() { + int h = funcName.hashCode(); + h ^= prec ^ bits; + return h; + } + + public boolean equals(Object o) { + if (this == o) return true; + Key k = (Key) o; + if (funcName.compareTo(k.funcName) != 0) return false; + if (prec != k.prec) return false; + if (bits != k.bits) return false; + if (range.size() != k.range.size()) return false; + for(int i=0;i { + public int compare(Key d0, Key d1) { + if (d0 == d1) return 0; + if (d0.prec < d1.prec) return 1; + if (d0.prec > d1.prec) return -1; + if (d0.ulps > d1.ulps) return 1; + if (d0.ulps < d1.ulps) return -1; + + int fc = (int)funcNameOrder.get(d0.funcName) - (int)funcNameOrder.get(d1.funcName); + if (fc != 0) return fc; + + if (d0.bits > d1.bits) return 1; + if (d0.bits < d1.bits) return -1; + + if (d0.range.size() > d1.range.size()) return 1; + if (d0.range.size() < d1.range.size()) return -1; + + for(int i=0;i d1.range.get(i)) return 1; + if (d0.range.get(i) < d1.range.get(i)) return -1; + } + + return 0; + } + } + + public static void main(String[] args) throws Exception { + LinkedHashMap> allData = new LinkedHashMap>(); + TreeSet allKeys = new TreeSet(new KeyComparator()); + LinkedHashSet allColumnTitles = new LinkedHashSet(); + double maximum = 0; + + for(int i=0;i v = allData.get(key); + if (v == null) { + v = new LinkedHashMap(); + allData.put(key, v); + } + String[] a = s.split(","); + + double time = Double.parseDouble(a[a.length-1]); + v.put(columnTitle, time); + maximum = Math.max(maximum, time); + } + + lnr.close(); + } + + PrintStream ps = new PrintStream("data.out"); + + for(Key k : allKeys) { + ps.print("\"" + k + "\" "); + + LinkedHashMap v = allData.get(k); + + for(String s : allColumnTitles) { + Double d = v.get(s); + if (d != null) ps.print(d); + if (d == null) ps.print("0"); + ps.print("\t"); + } + ps.println(); + } + + ps.close(); + + ps = new PrintStream("script.out"); + + ps.println("set terminal pngcairo size 1280, 800 font \",10\""); + ps.println("set output \"output.png\""); + + ps.println("color00 = \"#FF5050\";"); // red + ps.println("color01 = \"#0066FF\";"); // blue + ps.println("color02 = \"#00FF00\";"); // green + ps.println("color03 = \"#FF9900\";"); // orange + ps.println("color04 = \"#CC00CC\";"); // purple + ps.println("color05 = \"#880000\";"); // brown + ps.println("color06 = \"#003300\";"); // dark green + ps.println("color07 = \"#000066\";"); // dark blue + + ps.println("set style data histogram"); + ps.println("set style histogram cluster gap 1"); + ps.println("set style fill solid 1.00"); + ps.println("set boxwidth 0.9"); + ps.println("set xtics format \"\""); + ps.println("set xtics rotate by -90"); + ps.println("set grid ytics"); + + ps.println("set ylabel \"Execution time in micro sec.\""); + ps.println("set yrange [0:*]"); + ps.println("set bmargin 24"); + + ps.println("set title \"Single execution time in micro sec.\""); + ps.print("plot"); + + int i = 0; + for(String s : allColumnTitles) { + ps.print("\"data.out\" using " + (i+2) + ":xtic(1) title \"" + s + + "\" linecolor rgb color" + String.format("%02d", i)); + if (i != allColumnTitles.size()-1) ps.print(", "); + i++; + } + ps.println(); + + ps.close(); + } +} diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-benchmarks/bench.h b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-benchmarks/bench.h new file mode 100644 index 00000000000..d4c87edf28b --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-benchmarks/bench.h @@ -0,0 +1,58 @@ +#define NITER1 100000 +#define NITER2 10000 +#define NITER (NITER1 * NITER2) + +#define callFuncSLEEF1_1(funcName, name, xmin, xmax, ulp, arg, type) ({ \ + printf("%s\n", #funcName); \ + uint64_t t = Sleef_currentTimeMicros(); \ + for(int j=0;j +#include +#include +#include +#include +#include +#include + +#include "bench.h" + +int veclen = 16; +double *abufdp, *bbufdp; +float *abufsp, *bbufsp; +FILE *fp; + +#if defined(__i386__) || defined(__x86_64__) +void x86CpuID(int32_t out[4], uint32_t eax, uint32_t ecx) { + uint32_t a, b, c, d; + __asm__ __volatile__ ("cpuid" : "=a" (a), "=b" (b), "=c" (c), "=d" (d) : "a" (eax), "c"(ecx)); + out[0] = a; out[1] = b; out[2] = c; out[3] = d; +} + +int cpuSupportsAVX() { + int32_t reg[4]; + x86CpuID(reg, 1, 0); + return (reg[2] & (1 << 28)) != 0; +} + +int cpuSupportsAVX512F() { + int32_t reg[4]; + x86CpuID(reg, 7, 0); + return (reg[1] & (1 << 16)) != 0; +} +#endif + +void fillDP(double *buf, double min, double max) { + for(int i=0;i= 3) fnBase = argv[2]; + + srandom(time(NULL)); + +#if defined(__i386__) || defined(__x86_64__) + int do128bit = 1; + int do256bit = cpuSupportsAVX(); + int do512bit = cpuSupportsAVX512F(); +#elif defined(__ARM_NEON) || defined(__VSX__) || defined(__VX__) + int do128bit = 1; +#else +#error Unsupported architecture +#endif + + posix_memalign((void **)&abufdp, veclen*sizeof(double), NITER1*veclen*sizeof(double)); + posix_memalign((void **)&bbufdp, veclen*sizeof(double), NITER1*veclen*sizeof(double)); + + abufsp = (float *)abufdp; + bbufsp = (float *)bbufdp; + + sprintf(fn, "%sdptrig.out", fnBase); + fp = fopen(fn, "w"); + fprintf(fp, "%s\n", columnTitle); + + if (do128bit) benchSleef128_DPTrig(); +#if defined(__i386__) || defined(__x86_64__) + if (do256bit) benchSleef256_DPTrig(); + if (do512bit) benchSleef512_DPTrig(); +#endif + + fclose(fp); + + sprintf(fn, "%sdpnontrig.out", fnBase); + fp = fopen(fn, "w"); + fprintf(fp, "%s\n", columnTitle); + + if (do128bit) benchSleef128_DPNontrig(); +#if defined(__i386__) || defined(__x86_64__) + if (do256bit) benchSleef256_DPNontrig(); + if (do512bit) benchSleef512_DPNontrig(); +#endif + + fclose(fp); + + sprintf(fn, "%ssptrig.out", fnBase); + fp = fopen(fn, "w"); + fprintf(fp, "%s\n", columnTitle); + + if (do128bit) benchSleef128_SPTrig(); +#if defined(__i386__) || defined(__x86_64__) + if (do256bit) benchSleef256_SPTrig(); + if (do512bit) benchSleef512_SPTrig(); +#endif + + fclose(fp); + + sprintf(fn, "%sspnontrig.out", fnBase); + fp = fopen(fn, "w"); + fprintf(fp, "%s\n", columnTitle); + + if (do128bit) benchSleef128_SPNontrig(); +#if defined(__i386__) || defined(__x86_64__) + if (do256bit) benchSleef256_SPNontrig(); + if (do512bit) benchSleef512_SPNontrig(); +#endif + + fclose(fp); + + exit(0); +} diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-benchmarks/benchsleef128.c b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-benchmarks/benchsleef128.c new file mode 100644 index 00000000000..e5632d18fc1 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-benchmarks/benchsleef128.c @@ -0,0 +1,195 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include +#include +#include + +void fillDP(double *buf, double min, double max); +void fillSP(float *buf, double min, double max); + +extern char x86BrandString[256], versionString[1024]; +extern int veclen; +extern double *abufdp, *bbufdp; +extern float *abufsp, *bbufsp; +extern FILE *fp; + +#include "bench.h" + +#ifdef __SSE2__ +#if defined(_MSC_VER) +#include +#else +#include +#endif +typedef __m128d vdouble; +typedef __m128 vfloat; +#define ENABLED +#elif defined(__ARM_NEON) +#include +typedef float64x2_t vdouble; +typedef float32x4_t vfloat; +#define ENABLED +#elif defined(__VSX__) +#include +typedef __vector double vdouble; +typedef __vector float vfloat; +#define ENABLED +#elif defined(__VX__) +#include +typedef __vector double vdouble; +typedef __vector float vfloat; +#define ENABLED +#endif + +#ifdef ENABLED +void benchSleef128_DPTrig() { + fillDP(abufdp, 0, 6.28); + + callFuncSLEEF1_1(Sleef_sind2_u10 , "sin, DP, 128", 0, 6.28, 1.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_cosd2_u10 , "cos, DP, 128", 0, 6.28, 1.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_tand2_u10 , "tan, DP, 128", 0, 6.28, 1.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_sincosd2_u10, "sincos, DP, 128", 0, 6.28, 1.0, abufdp, vdouble); + + callFuncSLEEF1_1(Sleef_sind2_u35 , "sin, DP, 128", 0, 6.28, 4.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_cosd2_u35 , "cos, DP, 128", 0, 6.28, 4.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_tand2_u35 , "tan, DP, 128", 0, 6.28, 4.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_sincosd2_u35, "sincos, DP, 128", 0, 6.28, 4.0, abufdp, vdouble); + + fillDP(abufdp, 0, 1e+6); + + callFuncSLEEF1_1(Sleef_sind2_u10 , "sin, DP, 128", 0, 1e+6, 1.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_cosd2_u10 , "cos, DP, 128", 0, 1e+6, 1.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_tand2_u10 , "tan, DP, 128", 0, 1e+6, 1.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_sincosd2_u10, "sincos, DP, 128", 0, 1e+6, 1.0, abufdp, vdouble); + + callFuncSLEEF1_1(Sleef_sind2_u35 , "sin, DP, 128", 0, 1e+6, 4.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_cosd2_u35 , "cos, DP, 128", 0, 1e+6, 4.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_tand2_u35 , "tan, DP, 128", 0, 1e+6, 4.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_sincosd2_u35, "sincos, DP, 128", 0, 1e+6, 4.0, abufdp, vdouble); + + fillDP(abufdp, 0, 1e+100); + + callFuncSLEEF1_1(Sleef_sind2_u10 , "sin, DP, 128", 0, 1e+100, 1.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_cosd2_u10 , "cos, DP, 128", 0, 1e+100, 1.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_tand2_u10 , "tan, DP, 128", 0, 1e+100, 1.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_sincosd2_u10, "sincos, DP, 128", 0, 1e+100, 1.0, abufdp, vdouble); + + callFuncSLEEF1_1(Sleef_sind2_u35 , "sin, DP, 128", 0, 1e+100, 4.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_cosd2_u35 , "cos, DP, 128", 0, 1e+100, 4.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_tand2_u35 , "tan, DP, 128", 0, 1e+100, 4.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_sincosd2_u35, "sincos, DP, 128", 0, 1e+100, 4.0, abufdp, vdouble); +} + +void benchSleef128_DPNontrig() { + fillDP(abufdp, 0, 1e+300); + + callFuncSLEEF1_1(Sleef_logd2_u10 , "log, DP, 128", 0, 1e+300, 1.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_log10d2_u10, "log10, DP, 128", 0, 1e+300, 1.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_log1pd2_u10, "log1p, DP, 128", 0, 1e+300, 1.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_logd2_u35 , "log, DP, 128", 0, 1e+300, 4.0, abufdp, vdouble); + + fillDP(abufdp, -700, 700); + + callFuncSLEEF1_1(Sleef_expd2_u10 , "exp, DP, 128", -700, 700, 1.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_exp2d2_u10 , "exp2, DP, 128", -700, 700, 1.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_exp10d2_u10, "exp10, DP, 128", -700, 700, 1.0, abufdp, vdouble); + + fillDP(abufdp, -30, 30); + fillDP(bbufdp, -30, 30); + + callFuncSLEEF1_2(Sleef_powd2_u10, "pow, DP, 128", -30, 30, -30, 30, 1.0, abufdp, bbufdp, vdouble); + + fillDP(abufdp, -1.0, 1.0); + + callFuncSLEEF1_1(Sleef_asind2_u10, "asin, DP, 128", -1.0, 1.0, 1.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_acosd2_u10, "acos, DP, 128", -1.0, 1.0, 1.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_asind2_u35, "asin, DP, 128", -1.0, 1.0, 4.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_acosd2_u35, "acos, DP, 128", -1.0, 1.0, 4.0, abufdp, vdouble); + + fillDP(abufdp, -10, 10); + fillDP(bbufdp, -10, 10); + + callFuncSLEEF1_1(Sleef_atand2_u10, "atan, DP, 128", -10, 10, 1.0, abufdp, vdouble); + callFuncSLEEF1_2(Sleef_atan2d2_u10, "atan2, DP, 128", -10, 10, -10, 10, 1.0, abufdp, bbufdp, vdouble); + callFuncSLEEF1_1(Sleef_atand2_u35, "atan, DP, 128", -10, 10, 4.0, abufdp, vdouble); + callFuncSLEEF1_2(Sleef_atan2d2_u35, "atan2, DP, 128", -10, 10, -10, 10, 4.0, abufdp, bbufdp, vdouble); +} + +void benchSleef128_SPTrig() { + fillSP(abufsp, 0, 6.28); + + callFuncSLEEF1_1(Sleef_sinf4_u10 , "sin, SP, 128", 0, 6.28, 1.0, abufsp, vfloat); + callFuncSLEEF1_1(Sleef_cosf4_u10 , "cos, SP, 128", 0, 6.28, 1.0, abufsp, vfloat); + callFuncSLEEF1_1(Sleef_tanf4_u10 , "tan, SP, 128", 0, 6.28, 1.0, abufsp, vfloat); + callFuncSLEEF1_1(Sleef_sincosf4_u10, "sincos, SP, 128", 0, 6.28, 1.0, abufsp, vfloat); + + callFuncSLEEF1_1(Sleef_sinf4_u35 , "sin, SP, 128", 0, 6.28, 4.0, abufsp, vfloat); + callFuncSLEEF1_1(Sleef_cosf4_u35 , "cos, SP, 128", 0, 6.28, 4.0, abufsp, vfloat); + callFuncSLEEF1_1(Sleef_tanf4_u35 , "tan, SP, 128", 0, 6.28, 4.0, abufsp, vfloat); + callFuncSLEEF1_1(Sleef_sincosf4_u35, "sincos, SP, 128", 0, 6.28, 4.0, abufsp, vfloat); + + fillSP(abufsp, 0, 1e+20); + + callFuncSLEEF1_1(Sleef_sinf4_u10 , "sin, SP, 128", 0, 1e+20, 1.0, abufsp, vfloat); + callFuncSLEEF1_1(Sleef_cosf4_u10 , "cos, SP, 128", 0, 1e+20, 1.0, abufsp, vfloat); + callFuncSLEEF1_1(Sleef_tanf4_u10 , "tan, SP, 128", 0, 1e+20, 1.0, abufsp, vfloat); + callFuncSLEEF1_1(Sleef_sincosf4_u10, "sincos, SP, 128", 0, 1e+20, 1.0, abufsp, vfloat); + + callFuncSLEEF1_1(Sleef_sinf4_u35 , "sin, SP, 128", 0, 1e+20, 4.0, abufsp, vfloat); + callFuncSLEEF1_1(Sleef_cosf4_u35 , "cos, SP, 128", 0, 1e+20, 4.0, abufsp, vfloat); + callFuncSLEEF1_1(Sleef_tanf4_u35 , "tan, SP, 128", 0, 1e+20, 4.0, abufsp, vfloat); + callFuncSLEEF1_1(Sleef_sincosf4_u35, "sincos, SP, 128", 0, 1e+20, 4.0, abufsp, vfloat); +} + +void benchSleef128_SPNontrig() { + fillSP(abufsp, 0, 1e+38); + + callFuncSLEEF1_1(Sleef_logf4_u10 , "log, SP, 128", 0, 1e+38, 1.0, abufsp, vfloat); + callFuncSLEEF1_1(Sleef_log10f4_u10, "log10, SP, 128", 0, 1e+38, 1.0, abufsp, vfloat); + //callFuncSLEEF1_1(Sleef_log1pf4_u10, "log1p, SP, 128", 0, 1e+38, 1.0, abufsp, vfloat); + + callFuncSLEEF1_1(Sleef_logf4_u35 , "log, SP, 128", 0, 1e+38, 4.0, abufsp, vfloat); + //callFuncSLEEF1_1(Sleef_log10f4_u35, "log10, SP, 128", 0, 1e+38, 4.0, abufsp, vfloat); + //callFuncSLEEF1_1(Sleef_log1pf4_u35, "log1p, SP, 128", 0, 1e+38, 4.0, abufsp, vfloat); + + fillSP(abufsp, -100, 100); + + callFuncSLEEF1_1(Sleef_expf4_u10 , "exp, SP, 128", -100, 100, 1.0, abufsp, vfloat); + callFuncSLEEF1_1(Sleef_exp2f4_u10 , "exp2, SP, 128", -100, 100, 1.0, abufsp, vfloat); + callFuncSLEEF1_1(Sleef_exp10f4_u10, "exp10, SP, 128", -100, 100, 1.0, abufsp, vfloat); + + fillSP(abufsp, -30, 30); + fillSP(bbufsp, -30, 30); + + callFuncSLEEF1_2(Sleef_powf4_u10, "pow, SP, 128", -30, 30, -30, 30, 1.0, abufsp, bbufsp, vfloat); + + fillSP(abufsp, -1.0, 1.0); + + callFuncSLEEF1_1(Sleef_asinf4_u10, "asin, SP, 128", -1.0, 1, 1.0, abufsp, vfloat); + callFuncSLEEF1_1(Sleef_acosf4_u10, "acos, SP, 128", -1.0, 1, 1.0, abufsp, vfloat); + + callFuncSLEEF1_1(Sleef_asinf4_u35, "asin, SP, 128", -1.0, 1.0, 4.0, abufsp, vfloat); + callFuncSLEEF1_1(Sleef_acosf4_u35, "acos, SP, 128", -1.0, 1.0, 4.0, abufsp, vfloat); + + fillSP(abufsp, -10, 10); + fillSP(bbufsp, -10, 10); + + callFuncSLEEF1_1(Sleef_atanf4_u10, "atan, SP, 128", -10, 10, 1.0, abufsp, vfloat); + callFuncSLEEF1_2(Sleef_atan2f4_u10, "atan2, SP, 128", -10, 10, -10, 10, 1.0, abufsp, bbufsp, vfloat); + + callFuncSLEEF1_1(Sleef_atanf4_u35, "atan, SP, 128", -10, 10, 4.0, abufsp, vfloat); + callFuncSLEEF1_2(Sleef_atan2f4_u35, "atan2, SP, 128", -10, 10, -10, 10, 4.0, abufsp, bbufsp, vfloat); +} +#else // #ifdef ENABLED +void benchSleef128_DPTrig() {} +void benchSleef128_DPNontrig() {} +void benchSleef128_SPTrig() {} +void benchSleef128_SPNontrig() {} +#endif // #ifdef ENABLED diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-benchmarks/benchsleef256.c b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-benchmarks/benchsleef256.c new file mode 100644 index 00000000000..12cdf35f31b --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-benchmarks/benchsleef256.c @@ -0,0 +1,181 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include +#include +#include + +void fillDP(double *buf, double min, double max); +void fillSP(float *buf, double min, double max); + +extern char x86BrandString[256], versionString[1024]; +extern int veclen; +extern double *abufdp, *bbufdp; +extern float *abufsp, *bbufsp; +extern FILE *fp; + +#include "bench.h" + +#ifdef __AVX__ +#if defined(_MSC_VER) +#include +#else +#include +#endif +typedef __m256d vdouble; +typedef __m256 vfloat; +#define ENABLED +#endif + +#ifdef ENABLED +void benchSleef256_DPTrig() { + fillDP(abufdp, 0, 6.28); + + callFuncSLEEF1_1(Sleef_sind4_u10 , "sin, DP, 256", 0, 6.28, 1.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_cosd4_u10 , "cos, DP, 256", 0, 6.28, 1.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_tand4_u10 , "tan, DP, 256", 0, 6.28, 1.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_sincosd4_u10, "sincos, DP, 256", 0, 6.28, 1.0, abufdp, vdouble); + + callFuncSLEEF1_1(Sleef_sind4_u35 , "sin, DP, 256", 0, 6.28, 4.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_cosd4_u35 , "cos, DP, 256", 0, 6.28, 4.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_tand4_u35 , "tan, DP, 256", 0, 6.28, 4.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_sincosd4_u35, "sincos, DP, 256", 0, 6.28, 4.0, abufdp, vdouble); + + fillDP(abufdp, 0, 1e+6); + + callFuncSLEEF1_1(Sleef_sind4_u10 , "sin, DP, 256", 0, 1e+6, 1.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_cosd4_u10 , "cos, DP, 256", 0, 1e+6, 1.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_tand4_u10 , "tan, DP, 256", 0, 1e+6, 1.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_sincosd4_u10, "sincos, DP, 256", 0, 1e+6, 1.0, abufdp, vdouble); + + callFuncSLEEF1_1(Sleef_sind4_u35 , "sin, DP, 256", 0, 1e+6, 4.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_cosd4_u35 , "cos, DP, 256", 0, 1e+6, 4.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_tand4_u35 , "tan, DP, 256", 0, 1e+6, 4.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_sincosd4_u35, "sincos, DP, 256", 0, 1e+6, 4.0, abufdp, vdouble); + + fillDP(abufdp, 0, 1e+100); + + callFuncSLEEF1_1(Sleef_sind4_u10 , "sin, DP, 256", 0, 1e+100, 1.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_cosd4_u10 , "cos, DP, 256", 0, 1e+100, 1.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_tand4_u10 , "tan, DP, 256", 0, 1e+100, 1.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_sincosd4_u10, "sincos, DP, 256", 0, 1e+100, 1.0, abufdp, vdouble); + + callFuncSLEEF1_1(Sleef_sind4_u35 , "sin, DP, 256", 0, 1e+100, 4.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_cosd4_u35 , "cos, DP, 256", 0, 1e+100, 4.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_tand4_u35 , "tan, DP, 256", 0, 1e+100, 4.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_sincosd4_u35, "sincos, DP, 256", 0, 1e+100, 4.0, abufdp, vdouble); +} + +void benchSleef256_DPNontrig() { + fillDP(abufdp, 0, 1e+300); + + callFuncSLEEF1_1(Sleef_logd4_u10 , "log, DP, 256", 0, 1e+300, 1.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_log10d4_u10, "log10, DP, 256", 0, 1e+300, 1.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_log1pd4_u10, "log1p, DP, 256", 0, 1e+300, 1.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_logd4_u35 , "log, DP, 256", 0, 1e+300, 4.0, abufdp, vdouble); + + fillDP(abufdp, -700, 700); + + callFuncSLEEF1_1(Sleef_expd4_u10 , "exp, DP, 256", -700, 700, 1.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_exp2d4_u10 , "exp2, DP, 256", -700, 700, 1.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_exp10d4_u10, "exp10, DP, 256", -700, 700, 1.0, abufdp, vdouble); + + fillDP(abufdp, -30, 30); + fillDP(bbufdp, -30, 30); + + callFuncSLEEF1_2(Sleef_powd4_u10, "pow, DP, 256", -30, 30, -30, 30, 1.0, abufdp, bbufdp, vdouble); + + fillDP(abufdp, -1.0, 1.0); + + callFuncSLEEF1_1(Sleef_asind4_u10, "asin, DP, 256", -1.0, 1.0, 1.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_acosd4_u10, "acos, DP, 256", -1.0, 1.0, 1.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_asind4_u35, "asin, DP, 256", -1.0, 1.0, 4.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_acosd4_u35, "acos, DP, 256", -1.0, 1.0, 4.0, abufdp, vdouble); + + fillDP(abufdp, -10, 10); + fillDP(bbufdp, -10, 10); + + callFuncSLEEF1_1(Sleef_atand4_u10, "atan, DP, 256", -10, 10, 1.0, abufdp, vdouble); + callFuncSLEEF1_2(Sleef_atan2d4_u10, "atan2, DP, 256", -10, 10, -10, 10, 1.0, abufdp, bbufdp, vdouble); + callFuncSLEEF1_1(Sleef_atand4_u35, "atan, DP, 256", -10, 10, 4.0, abufdp, vdouble); + callFuncSLEEF1_2(Sleef_atan2d4_u35, "atan2, DP, 256", -10, 10, -10, 10, 4.0, abufdp, bbufdp, vdouble); +} + +void benchSleef256_SPTrig() { + fillSP(abufsp, 0, 6.28); + + callFuncSLEEF1_1(Sleef_sinf8_u10 , "sin, SP, 256", 0, 6.28, 1.0, abufsp, vfloat); + callFuncSLEEF1_1(Sleef_cosf8_u10 , "cos, SP, 256", 0, 6.28, 1.0, abufsp, vfloat); + callFuncSLEEF1_1(Sleef_tanf8_u10 , "tan, SP, 256", 0, 6.28, 1.0, abufsp, vfloat); + callFuncSLEEF1_1(Sleef_sincosf8_u10, "sincos, SP, 256", 0, 6.28, 1.0, abufsp, vfloat); + + callFuncSLEEF1_1(Sleef_sinf8_u35 , "sin, SP, 256", 0, 6.28, 4.0, abufsp, vfloat); + callFuncSLEEF1_1(Sleef_cosf8_u35 , "cos, SP, 256", 0, 6.28, 4.0, abufsp, vfloat); + callFuncSLEEF1_1(Sleef_tanf8_u35 , "tan, SP, 256", 0, 6.28, 4.0, abufsp, vfloat); + callFuncSLEEF1_1(Sleef_sincosf8_u35, "sincos, SP, 256", 0, 6.28, 4.0, abufsp, vfloat); + + fillSP(abufsp, 0, 1e+20); + + callFuncSLEEF1_1(Sleef_sinf8_u10 , "sin, SP, 256", 0, 1e+20, 1.0, abufsp, vfloat); + callFuncSLEEF1_1(Sleef_cosf8_u10 , "cos, SP, 256", 0, 1e+20, 1.0, abufsp, vfloat); + callFuncSLEEF1_1(Sleef_tanf8_u10 , "tan, SP, 256", 0, 1e+20, 1.0, abufsp, vfloat); + callFuncSLEEF1_1(Sleef_sincosf8_u10, "sincos, SP, 256", 0, 1e+20, 1.0, abufsp, vfloat); + + callFuncSLEEF1_1(Sleef_sinf8_u35 , "sin, SP, 256", 0, 1e+20, 4.0, abufsp, vfloat); + callFuncSLEEF1_1(Sleef_cosf8_u35 , "cos, SP, 256", 0, 1e+20, 4.0, abufsp, vfloat); + callFuncSLEEF1_1(Sleef_tanf8_u35 , "tan, SP, 256", 0, 1e+20, 4.0, abufsp, vfloat); + callFuncSLEEF1_1(Sleef_sincosf8_u35, "sincos, SP, 256", 0, 1e+20, 4.0, abufsp, vfloat); +} + +void benchSleef256_SPNontrig() { + fillSP(abufsp, 0, 1e+38); + + callFuncSLEEF1_1(Sleef_logf8_u10 , "log, SP, 256", 0, 1e+38, 1.0, abufsp, vfloat); + callFuncSLEEF1_1(Sleef_log10f8_u10, "log10, SP, 256", 0, 1e+38, 1.0, abufsp, vfloat); + //callFuncSLEEF1_1(Sleef_log1pf8_u10, "log1p, SP, 256", 0, 1e+38, 1.0, abufsp, vfloat); + + callFuncSLEEF1_1(Sleef_logf8_u35 , "log, SP, 256", 0, 1e+38, 4.0, abufsp, vfloat); + //callFuncSLEEF1_1(Sleef_log10f8_u35, "log10, SP, 256", 0, 1e+38, 4.0, abufsp, vfloat); + //callFuncSLEEF1_1(Sleef_log1pf8_u35, "log1p, SP, 256", 0, 1e+38, 4.0, abufsp, vfloat); + + fillSP(abufsp, -100, 100); + + callFuncSLEEF1_1(Sleef_expf8_u10 , "exp, SP, 256", -100, 100, 1.0, abufsp, vfloat); + callFuncSLEEF1_1(Sleef_exp2f8_u10 , "exp2, SP, 256", -100, 100, 1.0, abufsp, vfloat); + callFuncSLEEF1_1(Sleef_exp10f8_u10, "exp10, SP, 256", -100, 100, 1.0, abufsp, vfloat); + + fillSP(abufsp, -30, 30); + fillSP(bbufsp, -30, 30); + + callFuncSLEEF1_2(Sleef_powf8_u10, "pow, SP, 256", -30, 30, -30, 30, 1.0, abufsp, bbufsp, vfloat); + + fillSP(abufsp, -1.0, 1.0); + + callFuncSLEEF1_1(Sleef_asinf8_u10, "asin, SP, 256", -1.0, 1, 1.0, abufsp, vfloat); + callFuncSLEEF1_1(Sleef_acosf8_u10, "acos, SP, 256", -1.0, 1, 1.0, abufsp, vfloat); + + callFuncSLEEF1_1(Sleef_asinf8_u35, "asin, SP, 256", -1.0, 1.0, 4.0, abufsp, vfloat); + callFuncSLEEF1_1(Sleef_acosf8_u35, "acos, SP, 256", -1.0, 1.0, 4.0, abufsp, vfloat); + + fillSP(abufsp, -10, 10); + fillSP(bbufsp, -10, 10); + + callFuncSLEEF1_1(Sleef_atanf8_u10, "atan, SP, 256", -10, 10, 1.0, abufsp, vfloat); + callFuncSLEEF1_2(Sleef_atan2f8_u10, "atan2, SP, 256", -10, 10, -10, 10, 1.0, abufsp, bbufsp, vfloat); + + callFuncSLEEF1_1(Sleef_atanf8_u35, "atan, SP, 256", -10, 10, 4.0, abufsp, vfloat); + callFuncSLEEF1_2(Sleef_atan2f8_u35, "atan2, SP, 256", -10, 10, -10, 10, 4.0, abufsp, bbufsp, vfloat); +} +#else // #ifdef ENABLED +void zeroupper256() {} +void benchSleef256_DPTrig() {} +void benchSleef256_DPNontrig() {} +void benchSleef256_SPTrig() {} +void benchSleef256_SPNontrig() {} +#endif // #ifdef ENABLED diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-benchmarks/benchsleef512.c b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-benchmarks/benchsleef512.c new file mode 100644 index 00000000000..296c1236931 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-benchmarks/benchsleef512.c @@ -0,0 +1,180 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include +#include +#include + +void fillDP(double *buf, double min, double max); +void fillSP(float *buf, double min, double max); + +extern char x86BrandString[256], versionString[1024]; +extern int veclen; +extern double *abufdp, *bbufdp; +extern float *abufsp, *bbufsp; +extern FILE *fp; + +#include "bench.h" + +#ifdef __AVX512F__ +#if defined(_MSC_VER) +#include +#else +#include +#endif +typedef __m512d vdouble; +typedef __m512 vfloat; +#define ENABLED +#endif + +#ifdef ENABLED +void benchSleef512_DPTrig() { + fillDP(abufdp, 0, 6.28); + + callFuncSLEEF1_1(Sleef_sind8_u10 , "sin, DP, 512", 0, 6.28, 1.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_cosd8_u10 , "cos, DP, 512", 0, 6.28, 1.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_tand8_u10 , "tan, DP, 512", 0, 6.28, 1.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_sincosd8_u10, "sincos, DP, 512", 0, 6.28, 1.0, abufdp, vdouble); + + callFuncSLEEF1_1(Sleef_sind8_u35 , "sin, DP, 512", 0, 6.28, 4.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_cosd8_u35 , "cos, DP, 512", 0, 6.28, 4.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_tand8_u35 , "tan, DP, 512", 0, 6.28, 4.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_sincosd8_u35, "sincos, DP, 512", 0, 6.28, 4.0, abufdp, vdouble); + + fillDP(abufdp, 0, 1e+6); + + callFuncSLEEF1_1(Sleef_sind8_u10 , "sin, DP, 512", 0, 1e+6, 1.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_cosd8_u10 , "cos, DP, 512", 0, 1e+6, 1.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_tand8_u10 , "tan, DP, 512", 0, 1e+6, 1.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_sincosd8_u10, "sincos, DP, 512", 0, 1e+6, 1.0, abufdp, vdouble); + + callFuncSLEEF1_1(Sleef_sind8_u35 , "sin, DP, 512", 0, 1e+6, 4.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_cosd8_u35 , "cos, DP, 512", 0, 1e+6, 4.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_tand8_u35 , "tan, DP, 512", 0, 1e+6, 4.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_sincosd8_u35, "sincos, DP, 512", 0, 1e+6, 4.0, abufdp, vdouble); + + fillDP(abufdp, 0, 1e+100); + + callFuncSLEEF1_1(Sleef_sind8_u10 , "sin, DP, 512", 0, 1e+100, 1.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_cosd8_u10 , "cos, DP, 512", 0, 1e+100, 1.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_tand8_u10 , "tan, DP, 512", 0, 1e+100, 1.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_sincosd8_u10, "sincos, DP, 512", 0, 1e+100, 1.0, abufdp, vdouble); + + callFuncSLEEF1_1(Sleef_sind8_u35 , "sin, DP, 512", 0, 1e+100, 4.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_cosd8_u35 , "cos, DP, 512", 0, 1e+100, 4.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_tand8_u35 , "tan, DP, 512", 0, 1e+100, 4.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_sincosd8_u35, "sincos, DP, 512", 0, 1e+100, 4.0, abufdp, vdouble); +} + +void benchSleef512_DPNontrig() { + fillDP(abufdp, 0, 1e+300); + + callFuncSLEEF1_1(Sleef_logd8_u10 , "log, DP, 512", 0, 1e+300, 1.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_log10d8_u10, "log10, DP, 512", 0, 1e+300, 1.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_log1pd8_u10, "log1p, DP, 512", 0, 1e+300, 1.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_logd8_u35 , "log, DP, 512", 0, 1e+300, 4.0, abufdp, vdouble); + + fillDP(abufdp, -700, 700); + + callFuncSLEEF1_1(Sleef_expd8_u10 , "exp, DP, 512", -700, 700, 1.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_exp2d8_u10 , "exp2, DP, 512", -700, 700, 1.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_exp10d8_u10, "exp10, DP, 512", -700, 700, 1.0, abufdp, vdouble); + + fillDP(abufdp, -30, 30); + fillDP(bbufdp, -30, 30); + + callFuncSLEEF1_2(Sleef_powd8_u10, "pow, DP, 512", -30, 30, -30, 30, 1.0, abufdp, bbufdp, vdouble); + + fillDP(abufdp, -1.0, 1.0); + + callFuncSLEEF1_1(Sleef_asind8_u10, "asin, DP, 512", -1.0, 1.0, 1.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_acosd8_u10, "acos, DP, 512", -1.0, 1.0, 1.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_asind8_u35, "asin, DP, 512", -1.0, 1.0, 4.0, abufdp, vdouble); + callFuncSLEEF1_1(Sleef_acosd8_u35, "acos, DP, 512", -1.0, 1.0, 4.0, abufdp, vdouble); + + fillDP(abufdp, -10, 10); + fillDP(bbufdp, -10, 10); + + callFuncSLEEF1_1(Sleef_atand8_u10, "atan, DP, 512", -10, 10, 1.0, abufdp, vdouble); + callFuncSLEEF1_2(Sleef_atan2d8_u10, "atan2, DP, 512", -10, 10, -10, 10, 1.0, abufdp, bbufdp, vdouble); + callFuncSLEEF1_1(Sleef_atand8_u35, "atan, DP, 512", -10, 10, 4.0, abufdp, vdouble); + callFuncSLEEF1_2(Sleef_atan2d8_u35, "atan2, DP, 512", -10, 10, -10, 10, 4.0, abufdp, bbufdp, vdouble); +} + +void benchSleef512_SPTrig() { + fillSP(abufsp, 0, 6.28); + + callFuncSLEEF1_1(Sleef_sinf16_u10 , "sin, SP, 512", 0, 6.28, 1.0, abufsp, vfloat); + callFuncSLEEF1_1(Sleef_cosf16_u10 , "cos, SP, 512", 0, 6.28, 1.0, abufsp, vfloat); + callFuncSLEEF1_1(Sleef_tanf16_u10 , "tan, SP, 512", 0, 6.28, 1.0, abufsp, vfloat); + callFuncSLEEF1_1(Sleef_sincosf16_u10, "sincos, SP, 512", 0, 6.28, 1.0, abufsp, vfloat); + + callFuncSLEEF1_1(Sleef_sinf16_u35 , "sin, SP, 512", 0, 6.28, 4.0, abufsp, vfloat); + callFuncSLEEF1_1(Sleef_cosf16_u35 , "cos, SP, 512", 0, 6.28, 4.0, abufsp, vfloat); + callFuncSLEEF1_1(Sleef_tanf16_u35 , "tan, SP, 512", 0, 6.28, 4.0, abufsp, vfloat); + callFuncSLEEF1_1(Sleef_sincosf16_u35, "sincos, SP, 512", 0, 6.28, 4.0, abufsp, vfloat); + + fillSP(abufsp, 0, 1e+20); + + callFuncSLEEF1_1(Sleef_sinf16_u10 , "sin, SP, 512", 0, 1e+20, 1.0, abufsp, vfloat); + callFuncSLEEF1_1(Sleef_cosf16_u10 , "cos, SP, 512", 0, 1e+20, 1.0, abufsp, vfloat); + callFuncSLEEF1_1(Sleef_tanf16_u10 , "tan, SP, 512", 0, 1e+20, 1.0, abufsp, vfloat); + callFuncSLEEF1_1(Sleef_sincosf16_u10, "sincos, SP, 512", 0, 1e+20, 1.0, abufsp, vfloat); + + callFuncSLEEF1_1(Sleef_sinf16_u35 , "sin, SP, 512", 0, 1e+20, 4.0, abufsp, vfloat); + callFuncSLEEF1_1(Sleef_cosf16_u35 , "cos, SP, 512", 0, 1e+20, 4.0, abufsp, vfloat); + callFuncSLEEF1_1(Sleef_tanf16_u35 , "tan, SP, 512", 0, 1e+20, 4.0, abufsp, vfloat); + callFuncSLEEF1_1(Sleef_sincosf16_u35, "sincos, SP, 512", 0, 1e+20, 4.0, abufsp, vfloat); +} + +void benchSleef512_SPNontrig() { + fillSP(abufsp, 0, 1e+38); + + callFuncSLEEF1_1(Sleef_logf16_u10 , "log, SP, 512", 0, 1e+38, 1.0, abufsp, vfloat); + callFuncSLEEF1_1(Sleef_log10f16_u10, "log10, SP, 512", 0, 1e+38, 1.0, abufsp, vfloat); + //callFuncSLEEF1_1(Sleef_log1pf16_u10, "log1p, SP, 512", 0, 1e+38, 1.0, abufsp, vfloat); + + callFuncSLEEF1_1(Sleef_logf16_u35 , "log, SP, 512", 0, 1e+38, 4.0, abufsp, vfloat); + //callFuncSLEEF1_1(Sleef_log10f16_u35, "log10, SP, 512", 0, 1e+38, 4.0, abufsp, vfloat); + //callFuncSLEEF1_1(Sleef_log1pf16_u35, "log1p, SP, 512", 0, 1e+38, 4.0, abufsp, vfloat); + + fillSP(abufsp, -100, 100); + + callFuncSLEEF1_1(Sleef_expf16_u10 , "exp, SP, 512", -100, 100, 1.0, abufsp, vfloat); + callFuncSLEEF1_1(Sleef_exp2f16_u10 , "exp2, SP, 512", -100, 100, 1.0, abufsp, vfloat); + callFuncSLEEF1_1(Sleef_exp10f16_u10, "exp10, SP, 512", -100, 100, 1.0, abufsp, vfloat); + + fillSP(abufsp, -30, 30); + fillSP(bbufsp, -30, 30); + + callFuncSLEEF1_2(Sleef_powf16_u10, "pow, SP, 512", -30, 30, -30, 30, 1.0, abufsp, bbufsp, vfloat); + + fillSP(abufsp, -1.0, 1.0); + + callFuncSLEEF1_1(Sleef_asinf16_u10, "asin, SP, 512", -1.0, 1, 1.0, abufsp, vfloat); + callFuncSLEEF1_1(Sleef_acosf16_u10, "acos, SP, 512", -1.0, 1, 1.0, abufsp, vfloat); + + callFuncSLEEF1_1(Sleef_asinf16_u35, "asin, SP, 512", -1.0, 1.0, 4.0, abufsp, vfloat); + callFuncSLEEF1_1(Sleef_acosf16_u35, "acos, SP, 512", -1.0, 1.0, 4.0, abufsp, vfloat); + + fillSP(abufsp, -10, 10); + fillSP(bbufsp, -10, 10); + + callFuncSLEEF1_1(Sleef_atanf16_u10, "atan, SP, 512", -10, 10, 1.0, abufsp, vfloat); + callFuncSLEEF1_2(Sleef_atan2f16_u10, "atan2, SP, 512", -10, 10, -10, 10, 1.0, abufsp, bbufsp, vfloat); + + callFuncSLEEF1_1(Sleef_atanf16_u35, "atan, SP, 512", -10, 10, 4.0, abufsp, vfloat); + callFuncSLEEF1_2(Sleef_atan2f16_u35, "atan2, SP, 512", -10, 10, -10, 10, 4.0, abufsp, bbufsp, vfloat); +} +#else // #ifdef ENABLED +void benchSleef512_DPTrig() {} +void benchSleef512_DPNontrig() {} +void benchSleef512_SPTrig() {} +void benchSleef512_SPNontrig() {} +#endif // #ifdef ENABLED diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-benchmarks/benchsvml.c b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-benchmarks/benchsvml.c new file mode 100644 index 00000000000..feb9cb6263b --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-benchmarks/benchsvml.c @@ -0,0 +1,153 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "bench.h" + +int veclen = 16; +int enableLogExp; +double *abufdp, *bbufdp; +float *abufsp, *bbufsp; +FILE *fp; + +#if defined(__i386__) || defined(__x86_64__) +void x86CpuID(int32_t out[4], uint32_t eax, uint32_t ecx) { + uint32_t a, b, c, d; + __asm__ __volatile__ ("cpuid" : "=a" (a), "=b" (b), "=c" (c), "=d" (d) : "a" (eax), "c"(ecx)); + out[0] = a; out[1] = b; out[2] = c; out[3] = d; +} + +int cpuSupportsAVX() { + int32_t reg[4]; + x86CpuID(reg, 1, 0); + return (reg[2] & (1 << 28)) != 0; +} + +int cpuSupportsAVX512F() { + int32_t reg[4]; + x86CpuID(reg, 7, 0); + return (reg[1] & (1 << 16)) != 0; +} +#endif + +uint64_t Sleef_currentTimeMicros() { + struct timespec tp; + clock_gettime(CLOCK_MONOTONIC, &tp); + return (uint64_t)tp.tv_sec * 1000000LL + ((uint64_t)tp.tv_nsec/1000); +} + +void fillDP(double *buf, double min, double max) { + for(int i=0;i= 3) fnBase = argv[2]; + + srandom(time(NULL)); + +#if defined(__i386__) || defined(__x86_64__) + int do128bit = 1; + int do256bit = cpuSupportsAVX(); + int do512bit = cpuSupportsAVX512F(); +#elif defined(__ARM_NEON) + int do128bit = 1; + int do256bit = 0; + int do512bit = 0; +#else +#error Unsupported architecture +#endif + + posix_memalign((void **)&abufdp, veclen*sizeof(double), NITER1*veclen*sizeof(double)); + posix_memalign((void **)&bbufdp, veclen*sizeof(double), NITER1*veclen*sizeof(double)); + + abufsp = (float *)abufdp; + bbufsp = (float *)bbufdp; + + enableLogExp = SVMLULP < 2; + + sprintf(fn, "%sdptrig%gulp.out", fnBase, (double)SVMLULP); + fp = fopen(fn, "w"); + fprintf(fp, "%s\n", columnTitle); + + if (do256bit) zeroupper256(); + if (do128bit) benchSVML128_DPTrig(); + if (do256bit) benchSVML256_DPTrig(); + if (do512bit) benchSVML512_DPTrig(); + + fclose(fp); + + sprintf(fn, "%sdpnontrig%gulp.out", fnBase, (double)SVMLULP); + fp = fopen(fn, "w"); + fprintf(fp, "%s\n", columnTitle); + + if (do256bit) zeroupper256(); + if (do128bit) benchSVML128_DPNontrig(); + if (do256bit) benchSVML256_DPNontrig(); + if (do512bit) benchSVML512_DPNontrig(); + + fclose(fp); + + sprintf(fn, "%ssptrig%gulp.out", fnBase, (double)SVMLULP); + fp = fopen(fn, "w"); + fprintf(fp, "%s\n", columnTitle); + + if (do256bit) zeroupper256(); + if (do128bit) benchSVML128_SPTrig(); + if (do256bit) benchSVML256_SPTrig(); + if (do512bit) benchSVML512_SPTrig(); + + fclose(fp); + + sprintf(fn, "%sspnontrig%gulp.out", fnBase, (double)SVMLULP); + fp = fopen(fn, "w"); + fprintf(fp, "%s\n", columnTitle); + + if (do256bit) zeroupper256(); + if (do128bit) benchSVML128_SPNontrig(); + if (do256bit) benchSVML256_SPNontrig(); + if (do512bit) benchSVML512_SPNontrig(); + + fclose(fp); + + exit(0); +} diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-benchmarks/benchsvml128.c b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-benchmarks/benchsvml128.c new file mode 100644 index 00000000000..5c8c5d78546 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-benchmarks/benchsvml128.c @@ -0,0 +1,144 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include +#include +#include +#include + +uint64_t Sleef_currentTimeMicros(); +void fillDP(double *buf, double min, double max); +void fillSP(float *buf, double min, double max); + +extern char x86BrandString[256], versionString[1024]; +extern int veclen; +extern int enableLogExp; +extern double *abufdp, *bbufdp; +extern float *abufsp, *bbufsp; +extern FILE *fp; + +#include "bench.h" + +#ifdef __SSE2__ +typedef __m128d vdouble; +typedef __m128 vfloat; +#define ENABLED +#endif + +#ifdef ENABLED +void benchSVML128_DPTrig() { + fillDP(abufdp, 0, 6.28); + + callFuncSVML1_1(_mm_sin_pd , "sin, DP, 128", 0, 6.28, abufdp, vdouble); + callFuncSVML1_1(_mm_cos_pd , "cos, DP, 128", 0, 6.28, abufdp, vdouble); + callFuncSVML1_1(_mm_tan_pd , "tan, DP, 128", 0, 6.28, abufdp, vdouble); + callFuncSVML2_1(_mm_sincos_pd, "sincos, DP, 128", 0, 6.28, abufdp, vdouble); + + fillDP(abufdp, 0, 1e+6); + + callFuncSVML1_1(_mm_sin_pd , "sin, DP, 128", 0, 1e+6, abufdp, vdouble); + callFuncSVML1_1(_mm_cos_pd , "cos, DP, 128", 0, 1e+6, abufdp, vdouble); + callFuncSVML1_1(_mm_tan_pd , "tan, DP, 128", 0, 1e+6, abufdp, vdouble); + callFuncSVML2_1(_mm_sincos_pd, "sincos, DP, 128", 0, 1e+6, abufdp, vdouble); + + fillDP(abufdp, 0, 1e+100); + + callFuncSVML1_1(_mm_sin_pd , "sin, DP, 128", 0, 1e+100, abufdp, vdouble); + callFuncSVML1_1(_mm_cos_pd , "cos, DP, 128", 0, 1e+100, abufdp, vdouble); + callFuncSVML1_1(_mm_tan_pd , "tan, DP, 128", 0, 1e+100, abufdp, vdouble); + callFuncSVML2_1(_mm_sincos_pd, "sincos, DP, 128", 0, 1e+100, abufdp, vdouble); +} + +void benchSVML128_DPNontrig() { + fillDP(abufdp, 0, 1e+300); + + callFuncSVML1_1(_mm_log_pd , "log, DP, 128", 0, 1e+300, abufdp, vdouble); + + if (enableLogExp) { + callFuncSVML1_1(_mm_log10_pd, "log10, DP, 128", 0, 1e+300, abufdp, vdouble); + callFuncSVML1_1(_mm_log1p_pd, "log1p, DP, 128", 0, 1e+300, abufdp, vdouble); + + fillDP(abufdp, -700, 700); + + callFuncSVML1_1(_mm_exp_pd , "exp, DP, 128", -700, 700, abufdp, vdouble); + callFuncSVML1_1(_mm_exp2_pd , "exp2, DP, 128", -700, 700, abufdp, vdouble); + callFuncSVML1_1(_mm_exp10_pd, "exp10, DP, 128", -700, 700, abufdp, vdouble); + + fillDP(abufdp, -30, 30); + fillDP(bbufdp, -30, 30); + + callFuncSVML1_2(_mm_pow_pd, "pow, DP, 128", -30, 30, -30, 30, abufdp, bbufdp, vdouble); + } + + fillDP(abufdp, -1.0, 1.0); + + callFuncSVML1_1(_mm_asin_pd, "asin, DP, 128", -1.0, 1.0, abufdp, vdouble); + callFuncSVML1_1(_mm_acos_pd, "acos, DP, 128", -1.0, 1.0, abufdp, vdouble); + + fillDP(abufdp, -10, 10); + fillDP(bbufdp, -10, 10); + + callFuncSVML1_1(_mm_atan_pd, "atan, DP, 128", -10, 10, abufdp, vdouble); + callFuncSVML1_2(_mm_atan2_pd, "atan2, DP, 128", -10, 10, -10, 10, abufdp, bbufdp, vdouble); +} + +void benchSVML128_SPTrig() { + fillSP(abufsp, 0, 6.28); + + callFuncSVML1_1(_mm_sin_ps , "sin, SP, 128", 0, 6.28, abufsp, vfloat); + callFuncSVML1_1(_mm_cos_ps , "cos, SP, 128", 0, 6.28, abufsp, vfloat); + callFuncSVML1_1(_mm_tan_ps , "tan, SP, 128", 0, 6.28, abufsp, vfloat); + callFuncSVML2_1(_mm_sincos_ps, "sincos, SP, 128", 0, 6.28, abufsp, vfloat); + + fillSP(abufsp, 0, 1e+20); + + callFuncSVML1_1(_mm_sin_ps , "sin, SP, 128", 0, 1e+20, abufsp, vfloat); + callFuncSVML1_1(_mm_cos_ps , "cos, SP, 128", 0, 1e+20, abufsp, vfloat); + callFuncSVML1_1(_mm_tan_ps , "tan, SP, 128", 0, 1e+20, abufsp, vfloat); + callFuncSVML2_1(_mm_sincos_ps, "sincos, SP, 128", 0, 1e+20, abufsp, vfloat); +} + +void benchSVML128_SPNontrig() { + fillSP(abufsp, 0, 1e+38); + + callFuncSVML1_1(_mm_log_ps , "log, SP, 128", 0, 1e+38, abufsp, vfloat); + + if (enableLogExp) { + callFuncSVML1_1(_mm_log10_ps, "log10, SP, 128", 0, 1e+38, abufsp, vfloat); + //callFuncSVML1_1(_mm_log1p_ps, "log1p, SP, 128", 0, 1e+38, abufsp, vfloat); + + fillSP(abufsp, -100, 100); + + callFuncSVML1_1(_mm_exp_ps , "exp, SP, 128", -100, 100, abufsp, vfloat); + callFuncSVML1_1(_mm_exp2_ps , "exp2, SP, 128", -100, 100, abufsp, vfloat); + callFuncSVML1_1(_mm_exp10_ps, "exp10, SP, 128", -100, 100, abufsp, vfloat); + + fillSP(abufsp, -30, 30); + fillSP(bbufsp, -30, 30); + + callFuncSVML1_2(_mm_pow_ps, "pow, SP, 128", -30, 30, -30, 30, abufsp, bbufsp, vfloat); + } + + fillSP(abufsp, -1.0, 1.0); + + callFuncSVML1_1(_mm_asin_ps, "asin, SP, 128", -1.0, 1, abufsp, vfloat); + callFuncSVML1_1(_mm_acos_ps, "acos, SP, 128", -1.0, 1, abufsp, vfloat); + + fillSP(abufsp, -10, 10); + fillSP(bbufsp, -10, 10); + + callFuncSVML1_1(_mm_atan_ps, "atan, SP, 128", -10, 10, abufsp, vfloat); + callFuncSVML1_2(_mm_atan2_ps, "atan2, SP, 128", -10, 10, -10, 10, abufsp, bbufsp, vfloat); +} +#else // #ifdef ENABLED +void benchSVML128_DPTrig() {} +void benchSVML128_DPNontrig() {} +void benchSVML128_SPTrig() {} +void benchSVML128_SPNontrig() {} +#endif // #ifdef ENABLED diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-benchmarks/benchsvml256.c b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-benchmarks/benchsvml256.c new file mode 100644 index 00000000000..2f1e2ee5e21 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-benchmarks/benchsvml256.c @@ -0,0 +1,147 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include +#include +#include +#include + +uint64_t Sleef_currentTimeMicros(); +void fillDP(double *buf, double min, double max); +void fillSP(float *buf, double min, double max); + +extern char x86BrandString[256], versionString[1024]; +extern int veclen; +extern int enableLogExp; +extern double *abufdp, *bbufdp; +extern float *abufsp, *bbufsp; +extern FILE *fp; + +#include "bench.h" + +#ifdef __AVX__ +typedef __m256d vdouble; +typedef __m256 vfloat; +#define ENABLED +#endif + +#ifdef ENABLED +void zeroupper256() { _mm256_zeroupper(); } + +void benchSVML256_DPTrig() { + fillDP(abufdp, 0, 6.28); + + callFuncSVML1_1(_mm256_sin_pd , "sin, DP, 256", 0, 6.28, abufdp, vdouble); + callFuncSVML1_1(_mm256_cos_pd , "cos, DP, 256", 0, 6.28, abufdp, vdouble); + callFuncSVML1_1(_mm256_tan_pd , "tan, DP, 256", 0, 6.28, abufdp, vdouble); + callFuncSVML2_1(_mm256_sincos_pd, "sincos, DP, 256", 0, 6.28, abufdp, vdouble); + + fillDP(abufdp, 0, 1e+6); + + callFuncSVML1_1(_mm256_sin_pd , "sin, DP, 256", 0, 1e+6, abufdp, vdouble); + callFuncSVML1_1(_mm256_cos_pd , "cos, DP, 256", 0, 1e+6, abufdp, vdouble); + callFuncSVML1_1(_mm256_tan_pd , "tan, DP, 256", 0, 1e+6, abufdp, vdouble); + callFuncSVML2_1(_mm256_sincos_pd, "sincos, DP, 256", 0, 1e+6, abufdp, vdouble); + + fillDP(abufdp, 0, 1e+100); + + callFuncSVML1_1(_mm256_sin_pd , "sin, DP, 256", 0, 1e+100, abufdp, vdouble); + callFuncSVML1_1(_mm256_cos_pd , "cos, DP, 256", 0, 1e+100, abufdp, vdouble); + callFuncSVML1_1(_mm256_tan_pd , "tan, DP, 256", 0, 1e+100, abufdp, vdouble); + callFuncSVML2_1(_mm256_sincos_pd, "sincos, DP, 256", 0, 1e+100, abufdp, vdouble); +} + +void benchSVML256_DPNontrig() { + fillDP(abufdp, 0, 1e+300); + + callFuncSVML1_1(_mm256_log_pd , "log, DP, 256", 0, 1e+300, abufdp, vdouble); + + if (enableLogExp) { + callFuncSVML1_1(_mm256_log10_pd, "log10, DP, 256", 0, 1e+300, abufdp, vdouble); + callFuncSVML1_1(_mm256_log1p_pd, "log1p, DP, 256", 0, 1e+300, abufdp, vdouble); + + fillDP(abufdp, -700, 700); + + callFuncSVML1_1(_mm256_exp_pd , "exp, DP, 256", -700, 700, abufdp, vdouble); + callFuncSVML1_1(_mm256_exp2_pd , "exp2, DP, 256", -700, 700, abufdp, vdouble); + callFuncSVML1_1(_mm256_exp10_pd, "exp10, DP, 256", -700, 700, abufdp, vdouble); + + fillDP(abufdp, -30, 30); + fillDP(bbufdp, -30, 30); + + callFuncSVML1_2(_mm256_pow_pd, "pow, DP, 256", -30, 30, -30, 30, abufdp, bbufdp, vdouble); + } + + fillDP(abufdp, -1.0, 1.0); + + callFuncSVML1_1(_mm256_asin_pd, "asin, DP, 256", -1.0, 1.0, abufdp, vdouble); + callFuncSVML1_1(_mm256_acos_pd, "acos, DP, 256", -1.0, 1.0, abufdp, vdouble); + + fillDP(abufdp, -10, 10); + fillDP(bbufdp, -10, 10); + + callFuncSVML1_1(_mm256_atan_pd, "atan, DP, 256", -10, 10, abufdp, vdouble); + callFuncSVML1_2(_mm256_atan2_pd, "atan2, DP, 256", -10, 10, -10, 10, abufdp, bbufdp, vdouble); +} + +void benchSVML256_SPTrig() { + fillSP(abufsp, 0, 6.28); + + callFuncSVML1_1(_mm256_sin_ps , "sin, SP, 256", 0, 6.28, abufsp, vfloat); + callFuncSVML1_1(_mm256_cos_ps , "cos, SP, 256", 0, 6.28, abufsp, vfloat); + callFuncSVML1_1(_mm256_tan_ps , "tan, SP, 256", 0, 6.28, abufsp, vfloat); + callFuncSVML2_1(_mm256_sincos_ps, "sincos, SP, 256", 0, 6.28, abufsp, vfloat); + + fillSP(abufsp, 0, 1e+20); + + callFuncSVML1_1(_mm256_sin_ps , "sin, SP, 256", 0, 1e+20, abufsp, vfloat); + callFuncSVML1_1(_mm256_cos_ps , "cos, SP, 256", 0, 1e+20, abufsp, vfloat); + callFuncSVML1_1(_mm256_tan_ps , "tan, SP, 256", 0, 1e+20, abufsp, vfloat); + callFuncSVML2_1(_mm256_sincos_ps, "sincos, SP, 256", 0, 1e+20, abufsp, vfloat); +} + +void benchSVML256_SPNontrig() { + fillSP(abufsp, 0, 1e+38); + + callFuncSVML1_1(_mm256_log_ps , "log, SP, 256", 0, 1e+38, abufsp, vfloat); + + if (enableLogExp) { + callFuncSVML1_1(_mm256_log10_ps, "log10, SP, 256", 0, 1e+38, abufsp, vfloat); + //callFuncSVML1_1(_mm256_log1p_ps, "log1p, SP, 256", 0, 1e+38, abufsp, vfloat); + + fillSP(abufsp, -100, 100); + + callFuncSVML1_1(_mm256_exp_ps , "exp, SP, 256", -100, 100, abufsp, vfloat); + callFuncSVML1_1(_mm256_exp2_ps , "exp2, SP, 256", -100, 100, abufsp, vfloat); + callFuncSVML1_1(_mm256_exp10_ps, "exp10, SP, 256", -100, 100, abufsp, vfloat); + + fillSP(abufsp, -30, 30); + fillSP(bbufsp, -30, 30); + + callFuncSVML1_2(_mm256_pow_ps, "pow, SP, 256", -30, 30, -30, 30, abufsp, bbufsp, vfloat); + } + + fillSP(abufsp, -1.0, 1.0); + + callFuncSVML1_1(_mm256_asin_ps, "asin, SP, 256", -1.0, 1, abufsp, vfloat); + callFuncSVML1_1(_mm256_acos_ps, "acos, SP, 256", -1.0, 1, abufsp, vfloat); + + fillSP(abufsp, -10, 10); + fillSP(bbufsp, -10, 10); + + callFuncSVML1_1(_mm256_atan_ps, "atan, SP, 256", -10, 10, abufsp, vfloat); + callFuncSVML1_2(_mm256_atan2_ps, "atan2, SP, 256", -10, 10, -10, 10, abufsp, bbufsp, vfloat); +} +#else // #ifdef ENABLED +void zeroupper256() {} +void benchSVML256_DPTrig() {} +void benchSVML256_DPNontrig() {} +void benchSVML256_SPTrig() {} +void benchSVML256_SPNontrig() {} +#endif // #ifdef ENABLED diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-benchmarks/benchsvml512.c b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-benchmarks/benchsvml512.c new file mode 100644 index 00000000000..537ee28658a --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-benchmarks/benchsvml512.c @@ -0,0 +1,144 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include +#include +#include +#include + +uint64_t Sleef_currentTimeMicros(); +void fillDP(double *buf, double min, double max); +void fillSP(float *buf, double min, double max); + +extern char x86BrandString[256], versionString[1024]; +extern int veclen; +extern int enableLogExp; +extern double *abufdp, *bbufdp; +extern float *abufsp, *bbufsp; +extern FILE *fp; + +#include "bench.h" + +#ifdef __AVX512F__ +typedef __m512d vdouble; +typedef __m512 vfloat; +#define ENABLED +#endif + +#ifdef ENABLED +void benchSVML512_DPTrig() { + fillDP(abufdp, 0, 6.28); + + callFuncSVML1_1(_mm512_sin_pd , "sin, DP, 512", 0, 6.28, abufdp, vdouble); + callFuncSVML1_1(_mm512_cos_pd , "cos, DP, 512", 0, 6.28, abufdp, vdouble); + callFuncSVML1_1(_mm512_tan_pd , "tan, DP, 512", 0, 6.28, abufdp, vdouble); + callFuncSVML2_1(_mm512_sincos_pd, "sincos, DP, 512", 0, 6.28, abufdp, vdouble); + + fillDP(abufdp, 0, 1e+6); + + callFuncSVML1_1(_mm512_sin_pd , "sin, DP, 512", 0, 1e+6, abufdp, vdouble); + callFuncSVML1_1(_mm512_cos_pd , "cos, DP, 512", 0, 1e+6, abufdp, vdouble); + callFuncSVML1_1(_mm512_tan_pd , "tan, DP, 512", 0, 1e+6, abufdp, vdouble); + callFuncSVML2_1(_mm512_sincos_pd, "sincos, DP, 512", 0, 1e+6, abufdp, vdouble); + + fillDP(abufdp, 0, 1e+100); + + callFuncSVML1_1(_mm512_sin_pd , "sin, DP, 512", 0, 1e+100, abufdp, vdouble); + callFuncSVML1_1(_mm512_cos_pd , "cos, DP, 512", 0, 1e+100, abufdp, vdouble); + callFuncSVML1_1(_mm512_tan_pd , "tan, DP, 512", 0, 1e+100, abufdp, vdouble); + callFuncSVML2_1(_mm512_sincos_pd, "sincos, DP, 512", 0, 1e+100, abufdp, vdouble); +} + +void benchSVML512_DPNontrig() { + fillDP(abufdp, 0, 1e+300); + + callFuncSVML1_1(_mm512_log_pd , "log, DP, 512", 0, 1e+300, abufdp, vdouble); + + if (enableLogExp) { + callFuncSVML1_1(_mm512_log10_pd, "log10, DP, 512", 0, 1e+300, abufdp, vdouble); + callFuncSVML1_1(_mm512_log1p_pd, "log1p, DP, 512", 0, 1e+300, abufdp, vdouble); + + fillDP(abufdp, -700, 700); + + callFuncSVML1_1(_mm512_exp_pd , "exp, DP, 512", -700, 700, abufdp, vdouble); + callFuncSVML1_1(_mm512_exp2_pd , "exp2, DP, 512", -700, 700, abufdp, vdouble); + callFuncSVML1_1(_mm512_exp10_pd, "exp10, DP, 512", -700, 700, abufdp, vdouble); + + fillDP(abufdp, -30, 30); + fillDP(bbufdp, -30, 30); + + callFuncSVML1_2(_mm512_pow_pd, "pow, DP, 512", -30, 30, -30, 30, abufdp, bbufdp, vdouble); + } + + fillDP(abufdp, -1.0, 1.0); + + callFuncSVML1_1(_mm512_asin_pd, "asin, DP, 512", -1.0, 1.0, abufdp, vdouble); + callFuncSVML1_1(_mm512_acos_pd, "acos, DP, 512", -1.0, 1.0, abufdp, vdouble); + + fillDP(abufdp, -10, 10); + fillDP(bbufdp, -10, 10); + + callFuncSVML1_1(_mm512_atan_pd, "atan, DP, 512", -10, 10, abufdp, vdouble); + callFuncSVML1_2(_mm512_atan2_pd, "atan2, DP, 512", -10, 10, -10, 10, abufdp, bbufdp, vdouble); +} + +void benchSVML512_SPTrig() { + fillSP(abufsp, 0, 6.28); + + callFuncSVML1_1(_mm512_sin_ps , "sin, SP, 512", 0, 6.28, abufsp, vfloat); + callFuncSVML1_1(_mm512_cos_ps , "cos, SP, 512", 0, 6.28, abufsp, vfloat); + callFuncSVML1_1(_mm512_tan_ps , "tan, SP, 512", 0, 6.28, abufsp, vfloat); + callFuncSVML2_1(_mm512_sincos_ps, "sincos, SP, 512", 0, 6.28, abufsp, vfloat); + + fillSP(abufsp, 0, 1e+20); + + callFuncSVML1_1(_mm512_sin_ps , "sin, SP, 512", 0, 1e+20, abufsp, vfloat); + callFuncSVML1_1(_mm512_cos_ps , "cos, SP, 512", 0, 1e+20, abufsp, vfloat); + callFuncSVML1_1(_mm512_tan_ps , "tan, SP, 512", 0, 1e+20, abufsp, vfloat); + callFuncSVML2_1(_mm512_sincos_ps, "sincos, SP, 512", 0, 1e+20, abufsp, vfloat); +} + +void benchSVML512_SPNontrig() { + fillSP(abufsp, 0, 1e+38); + + callFuncSVML1_1(_mm512_log_ps , "log, SP, 512", 0, 1e+38, abufsp, vfloat); + + if (enableLogExp) { + callFuncSVML1_1(_mm512_log10_ps, "log10, SP, 512", 0, 1e+38, abufsp, vfloat); + //callFuncSVML1_1(_mm512_log1p_ps, "log1p, SP, 512", 0, 1e+38, abufsp, vfloat); + + fillSP(abufsp, -100, 100); + + callFuncSVML1_1(_mm512_exp_ps , "exp, SP, 512", -100, 100, abufsp, vfloat); + callFuncSVML1_1(_mm512_exp2_ps , "exp2, SP, 512", -100, 100, abufsp, vfloat); + callFuncSVML1_1(_mm512_exp10_ps, "exp10, SP, 512", -100, 100, abufsp, vfloat); + + fillSP(abufsp, -30, 30); + fillSP(bbufsp, -30, 30); + + callFuncSVML1_2(_mm512_pow_ps, "pow, SP, 512", -30, 30, -30, 30, abufsp, bbufsp, vfloat); + } + + fillSP(abufsp, -1.0, 1.0); + + callFuncSVML1_1(_mm512_asin_ps, "asin, SP, 512", -1.0, 1, abufsp, vfloat); + callFuncSVML1_1(_mm512_acos_ps, "acos, SP, 512", -1.0, 1, abufsp, vfloat); + + fillSP(abufsp, -10, 10); + fillSP(bbufsp, -10, 10); + + callFuncSVML1_1(_mm512_atan_ps, "atan, SP, 512", -10, 10, abufsp, vfloat); + callFuncSVML1_2(_mm512_atan2_ps, "atan2, SP, 512", -10, 10, -10, 10, abufsp, bbufsp, vfloat); +} +#else // #ifdef ENABLED +void benchSVML512_DPTrig() {} +void benchSVML512_DPNontrig() {} +void benchSVML512_SPTrig() {} +void benchSVML512_SPNontrig() {} +#endif // #ifdef ENABLED diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-benchmarks/measure.sh b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-benchmarks/measure.sh new file mode 100644 index 00000000000..74ccb8b5327 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-benchmarks/measure.sh @@ -0,0 +1,17 @@ +#!/bin/sh +echo +read -p "Enter label of measurement(e.g. My desktop PC) : " label + +if [ -f counter.txt ] +then + counter=`cat counter.txt` +else + counter=0 +fi + +echo Measurement in progress. This may take several minutes. +for i in $*; do + $i "$label" $counter +done +counter=$((counter+1)) +echo $counter > counter.txt diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-tester/CMakeLists.txt b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-tester/CMakeLists.txt new file mode 100644 index 00000000000..b391c1525a4 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-tester/CMakeLists.txt @@ -0,0 +1,517 @@ + +# Settings + +# TESTER3_DEFINITIONS + +set(TESTER3_DEFINITIONS_SSE2 ATR=cinz_ DPTYPE=__m128d SPTYPE=__m128 DPTYPESPEC=d2 SPTYPESPEC=f4 EXTSPEC=sse2) +set(TESTER3_DEFINITIONS_SSE4 ATR=cinz_ DPTYPE=__m128d SPTYPE=__m128 DPTYPESPEC=d2 SPTYPESPEC=f4 EXTSPEC=sse4) +set(TESTER3_DEFINITIONS_AVX2128 ATR=finz_ DPTYPE=__m128d SPTYPE=__m128 DPTYPESPEC=d2 SPTYPESPEC=f4 EXTSPEC=avx2128) +set(TESTER3_DEFINITIONS_AVX ATR=cinz_ DPTYPE=__m256d SPTYPE=__m256 DPTYPESPEC=d4 SPTYPESPEC=f8 EXTSPEC=avx) +set(TESTER3_DEFINITIONS_FMA4 ATR=finz_ DPTYPE=__m256d SPTYPE=__m256 DPTYPESPEC=d4 SPTYPESPEC=f8 EXTSPEC=fma4) +set(TESTER3_DEFINITIONS_AVX2 ATR=finz_ DPTYPE=__m256d SPTYPE=__m256 DPTYPESPEC=d4 SPTYPESPEC=f8 EXTSPEC=avx2) +set(TESTER3_DEFINITIONS_AVX512F ATR=finz_ DPTYPE=__m512d SPTYPE=__m512 DPTYPESPEC=d8 SPTYPESPEC=f16 EXTSPEC=avx512f) +set(TESTER3_DEFINITIONS_AVX512FNOFMA ATR=cinz_ DPTYPE=__m512d SPTYPE=__m512 DPTYPESPEC=d8 SPTYPESPEC=f16 EXTSPEC=avx512fnofma) + +set(TESTER3_DEFINITIONS_ADVSIMD ATR=finz_ DPTYPE=float64x2_t SPTYPE=float32x4_t DPTYPESPEC=d2 SPTYPESPEC=f4 EXTSPEC=advsimd) +set(TESTER3_DEFINITIONS_ADVSIMDNOFMA ATR=cinz_ DPTYPE=float64x2_t SPTYPE=float32x4_t DPTYPESPEC=d2 SPTYPESPEC=f4 EXTSPEC=advsimdnofma) +set(TESTER3_DEFINITIONS_SVE ATR=finz_ DPTYPE=svfloat64_t SPTYPE=svfloat32_t DPTYPESPEC=dx SPTYPESPEC=fx EXTSPEC=sve) +set(TESTER3_DEFINITIONS_SVENOFMA ATR=cinz_ DPTYPE=svfloat64_t SPTYPE=svfloat32_t DPTYPESPEC=dx SPTYPESPEC=fx EXTSPEC=svenofma) + +set(TESTER3_DEFINITIONS_VSX ATR=finz_ DPTYPE=SLEEF_VECTOR_DOUBLE SPTYPE=SLEEF_VECTOR_FLOAT DPTYPESPEC=d2 SPTYPESPEC=f4 EXTSPEC=vsx) +set(TESTER3_DEFINITIONS_VSXNOFMA ATR=cinz_ DPTYPE=SLEEF_VECTOR_DOUBLE SPTYPE=SLEEF_VECTOR_FLOAT DPTYPESPEC=d2 SPTYPESPEC=f4 EXTSPEC=vsxnofma) +set(TESTER3_DEFINITIONS_VSX3 ATR=finz_ DPTYPE=SLEEF_VECTOR_DOUBLE SPTYPE=SLEEF_VECTOR_FLOAT DPTYPESPEC=d2 SPTYPESPEC=f4 EXTSPEC=vsx3) +set(TESTER3_DEFINITIONS_VSX3NOFMA ATR=cinz_ DPTYPE=SLEEF_VECTOR_DOUBLE SPTYPE=SLEEF_VECTOR_FLOAT DPTYPESPEC=d2 SPTYPESPEC=f4 EXTSPEC=vsx3nofma) + +set(TESTER3_DEFINITIONS_VXE ATR=finz_ DPTYPE=SLEEF_VECTOR_DOUBLE SPTYPE=SLEEF_VECTOR_FLOAT DPTYPESPEC=d2 SPTYPESPEC=f4 EXTSPEC=vxe) +set(TESTER3_DEFINITIONS_VXENOFMA ATR=cinz_ DPTYPE=SLEEF_VECTOR_DOUBLE SPTYPE=SLEEF_VECTOR_FLOAT DPTYPESPEC=d2 SPTYPESPEC=f4 EXTSPEC=vxenofma) +set(TESTER3_DEFINITIONS_VXE2 ATR=finz_ DPTYPE=SLEEF_VECTOR_DOUBLE SPTYPE=SLEEF_VECTOR_FLOAT DPTYPESPEC=d2 SPTYPESPEC=f4 EXTSPEC=vxe2) +set(TESTER3_DEFINITIONS_VXE2NOFMA ATR=cinz_ DPTYPE=SLEEF_VECTOR_DOUBLE SPTYPE=SLEEF_VECTOR_FLOAT DPTYPESPEC=d2 SPTYPESPEC=f4 EXTSPEC=vxe2nofma) + +set(TESTER3_DEFINITIONS_RVVM1 ATR=finz_ DPTYPE=vfloat64m1_t SPTYPE=vfloat32m1_t DPTYPESPEC=dx SPTYPESPEC=fx EXTSPEC=rvvm1 ENABLE_RVVM1) +set(TESTER3_DEFINITIONS_RVVM1NOFMA ATR=cinz_ DPTYPE=vfloat64m1_t SPTYPE=vfloat32m1_t DPTYPESPEC=dx SPTYPESPEC=fx EXTSPEC=rvvm1nofma ENABLE_RVVM1) +set(TESTER3_DEFINITIONS_RVVM2 ATR=finz_ DPTYPE=vfloat64m2_t SPTYPE=vfloat32m2_t DPTYPESPEC=dx SPTYPESPEC=fx EXTSPEC=rvvm2 ENABLE_RVVM2) +set(TESTER3_DEFINITIONS_RVVM2NOFMA ATR=cinz_ DPTYPE=vfloat64m2_t SPTYPE=vfloat32m2_t DPTYPESPEC=dx SPTYPESPEC=fx EXTSPEC=rvvm2nofma ENABLE_RVVM2) + +set(TESTER3_DEFINITIONS_PUREC_SCALAR ATR=cinz_ DPTYPE=double SPTYPE=float DPTYPESPEC=d1 SPTYPESPEC=f1 EXTSPEC=purec) +set(TESTER3_DEFINITIONS_PURECFMA_SCALAR ATR=finz_ DPTYPE=double SPTYPE=float DPTYPESPEC=d1 SPTYPESPEC=f1 EXTSPEC=purecfma) + +# + +if (SLEEF_ARCH_X86) + set(TEST3_CINZ purec_scalar sse2 sse4 avx avx512fnofma) + set(TEST3_FINZ purecfma_scalar avx2128 avx2 avx512f) +elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64") + set(TEST3_CINZ purec_scalar advsimdnofma svenofma) + set(TEST3_FINZ purecfma_scalar advsimd sve) +elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "arm") + set(TEST3_CINZ purec_scalar) + set(TEST3_FINZ purecfma_scalar) +elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)64") + set(TEST3_CINZ purec_scalar vsxnofma vsx3nofma) + set(TEST3_FINZ purecfma_scalar vsx vsx3) +elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "s390x") + set(TEST3_CINZ purec_scalar vxenofma vxe2nofma) + set(TEST3_FINZ purecfma_scalar vxe vxe2) +elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "riscv64") + set(TEST3_CINZ purec_scalar rvvm1nofma rvvm2nofma) + set(TEST3_FINZ purecfma_scalar rvvm1 rvvm2) +endif() + +# + +link_directories(${sleef_BINARY_DIR}/lib) # libsleef +link_directories(${sleef_BINARY_DIR}/src/common) # common.a +include_directories(${sleef_BINARY_DIR}/include) # sleef.h +include_directories(${sleef_SOURCE_DIR}/src/libm) # rename.h +include_directories(${sleef_BINARY_DIR}/src/libm/include) # rename headers + +if(NOT LIB_MPFR) + find_program(TESTER_COMMAND tester) +endif(NOT LIB_MPFR) + +if (SLEEF_ENFORCE_TESTER AND NOT LIB_MPFR AND NOT TESTER_COMMAND) + message(FATAL_ERROR "SLEEF_ENFORCE_TESTER is specified and tester is not available") +endif(SLEEF_ENFORCE_TESTER AND NOT LIB_MPFR AND NOT TESTER_COMMAND) + +find_library(LIBRT rt) +if (NOT LIBRT) + set(LIBRT "") +endif() + +set(CMAKE_C_FLAGS "${ORG_CMAKE_C_FLAGS} ${SLEEF_C_FLAGS} ${FLAGS_NOSTRICTALIASING}") + +set(COMMON_TARGET_PROPERTIES + C_STANDARD 99 # -std=gnu99 + ) + +if (SLEEF_ENABLE_LTO) + list(APPEND COMMON_TARGET_PROPERTIES INTERPROCEDURAL_OPTIMIZATION TRUE) # -flto +endif() + +# + +function(add_test_iut IUT C) + if (LIB_MPFR) + set(TESTER ${TARGET_TESTER}) + elseif(TESTER_COMMAND) + set(TESTER ${TESTER_COMMAND}) + endif() + # When we are crosscompiling using the mkrename* tools from a native + # build, we use the tester executable from the native build. + if (CMAKE_CROSSCOMPILING AND NATIVE_BUILD_DIR) + set(TESTER ${NATIVE_BUILD_DIR}/bin/${TARGET_TESTER}) + endif(CMAKE_CROSSCOMPILING AND NATIVE_BUILD_DIR) + if (TESTER) + if (NOT EMULATOR) + if (SDE_COMMAND) + set(FLAGS_SDE "--sde" ${SDE_COMMAND}) + else() + set(FLAGS_SDE) + endif() + if (ARMIE_COMMAND) + set(FLAGS_ARMIE ${ARMIE_COMMAND} -msve-vector-bits=${SVE_VECTOR_BITS}) + else() + set(FLAGS_ARMIE) + endif() + add_test(NAME ${IUT} + COMMAND ${TESTER} ${FLAGS_SDE} ${FLAGS_ARMIE} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${IUT} + WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) + set_tests_properties(${IUT} PROPERTIES COST ${C}) + else() + add_test(NAME ${IUT} + COMMAND ${TESTER} "--qemu" ${EMULATOR} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${IUT} + WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) + set_tests_properties(${IUT} PROPERTIES COST ${C}) + endif() + endif() +endfunction() + +# Compile executable 'iut' +add_executable(${TARGET_IUT} iut.c testerutil.c) +target_compile_definitions(${TARGET_IUT} PRIVATE ${COMMON_TARGET_DEFINITIONS}) +target_link_libraries(${TARGET_IUT} ${TARGET_LIBSLEEF} + ${LIBM} ${LIBRT}) +set_target_properties(${TARGET_IUT} PROPERTIES ${COMMON_TARGET_PROPERTIES}) +add_test_iut(${TARGET_IUT} 1.0) +set(IUT_LIST ${TARGET_IUT}) + +# Compile executable 'iutcuda' +if (SLEEF_BUILD_INLINE_HEADERS AND SED_COMMAND AND CMAKE_CUDA_COMPILER) + add_executable(iutcuda iutcuda.cu) + set_target_properties(iutcuda PROPERTIES LINKER_LANGUAGE CUDA) + target_compile_options(iutcuda PRIVATE "--fmad=false;-Xcompiler;-ffp-contract=off") + add_dependencies(iutcuda ${TARGET_INLINE_HEADERS}) + add_test_iut(iutcuda 20.0) + list(APPEND IUT_LIST iutcuda) +endif() + +set(IUT_SRC iutsimd.c ${sleef_SOURCE_DIR}/src/common/main_checkfeature.c testerutil.c) + +# Add vector extension `iut`s +macro(test_extension SIMD) + if(COMPILER_SUPPORTS_${SIMD}) + string(TOLOWER ${SIMD} LCSIMD) + string(CONCAT TARGET_IUT${SIMD} "iut" ${LCSIMD}) + + add_executable(${TARGET_IUT${SIMD}} ${IUT_SRC}) + target_compile_options(${TARGET_IUT${SIMD}} + PRIVATE ${FLAGS_ENABLE_${SIMD}}) + target_compile_definitions(${TARGET_IUT${SIMD}} + PRIVATE ENABLE_${SIMD}=1 ${COMMON_TARGET_DEFINITIONS}) + target_link_libraries(${TARGET_IUT${SIMD}} ${TARGET_LIBSLEEF} + ${LIBM} ${LIBRT}) + if (FORCE_AAVPCS) + target_compile_definitions(${TARGET_IUT${SIMD}} PRIVATE ENABLE_AAVPCS=1) + endif(FORCE_AAVPCS) + + add_dependencies(${TARGET_IUT${SIMD}} ${TARGET_HEADERS}) + add_dependencies(${TARGET_IUT${SIMD}} ${TARGET_LIBSLEEF}) + set_target_properties(${TARGET_IUT${SIMD}} PROPERTIES ${COMMON_TARGET_PROPERTIES}) + if (DEFINED COSTOVERRIDE_${SIMD}) + add_test_iut(${TARGET_IUT${SIMD}} ${COSTOVERRIDE_${SIMD}}) + else() + add_test_iut(${TARGET_IUT${SIMD}} 1.0) + endif() + list(APPEND IUT_LIST ${TARGET_IUT${SIMD}}) + + # The iut programs whose names begin with "iuty" are the iut for the + # deterministic version of functions. By checking the result of + # testing with iutysse2, for example, it can be checked that the + # corresponding deterministic functions passes the accuracy and + # nonnumber tests. + + string(CONCAT IUTYNAME "iuty" ${LCSIMD}) + add_executable(${IUTYNAME} ${IUT_SRC}) + target_compile_options(${IUTYNAME} + PRIVATE ${FLAGS_ENABLE_${SIMD}}) + target_compile_definitions(${IUTYNAME} + PRIVATE ENABLE_${SIMD}=1 ${COMMON_TARGET_DEFINITIONS} DETERMINISTIC=1) + target_link_libraries(${IUTYNAME} ${TARGET_LIBSLEEF} + ${LIBM} ${LIBRT}) + add_dependencies(${IUTYNAME} ${TARGET_HEADERS}) + add_dependencies(${IUTYNAME} ${TARGET_LIBSLEEF}) + set_target_properties(${IUTYNAME} PROPERTIES ${COMMON_TARGET_PROPERTIES}) + if (DEFINED COSTOVERRIDE_${SIMD}) + add_test_iut(${IUTYNAME} ${COSTOVERRIDE_${SIMD}}) + else() + add_test_iut(${IUTYNAME} 1.0) + endif() + list(APPEND IUT_LIST ${IUTYNAME}) + + # The iut programs whose names begin with "iuti" are the iut for the + # inline version of functions. + + if (SLEEF_BUILD_INLINE_HEADERS AND SED_COMMAND) + string(CONCAT IUTINAME "iuti" ${LCSIMD}) + add_executable(${IUTINAME} ${IUT_SRC}) + target_compile_options(${IUTINAME} PRIVATE ${FLAGS_ENABLE_${SIMD}}) + target_compile_definitions(${IUTINAME} + PRIVATE ENABLE_${SIMD}=1 ${COMMON_TARGET_DEFINITIONS} + USE_INLINE_HEADER="sleefinline_${LCSIMD}.h" + MACRO_ONLY_HEADER="macroonly${SIMD}.h" + SIMD_SUFFIX=_${LCSIMD}_sleef + ) + target_include_directories(${IUTINAME} PRIVATE ${PROJECT_BINARY_DIR}/include) + target_link_libraries(${IUTINAME} ${LIBM} ${LIBRT}) + add_dependencies(${IUTINAME} ${TARGET_INLINE_HEADERS}) + set_target_properties(${IUTINAME} PROPERTIES C_STANDARD 99) + if (DEFINED COSTOVERRIDE_${SIMD}) + add_test_iut(${IUTINAME} ${COSTOVERRIDE_${SIMD}}) + else() + add_test_iut(${IUTINAME} 1.0) + endif() + list(APPEND IUT_LIST ${IUTINAME}) + endif(SLEEF_BUILD_INLINE_HEADERS AND SED_COMMAND) + + if(LIB_MPFR AND NOT ${SIMD} STREQUAL NEON32 AND NOT ${SIMD} STREQUAL NEON32VFPV4 AND NOT MINGW) + # Build tester2 SIMD + string(TOLOWER ${SIMD} SCSIMD) + foreach(P dp sp) + set(T "tester2${SCSIMD}${P}") + add_executable(${T} tester2simd${P}.c testerutil.c) + if(FORCE_AAVPCS) + target_compile_definitions(${T} PRIVATE ENABLE_AAVPCS=1) + endif(FORCE_AAVPCS) + target_compile_options(${T} PRIVATE ${FLAGS_ENABLE_${SIMD}}) + target_compile_definitions(${T} PRIVATE ENABLE_${SIMD}=1 USEMPFR=1 ${COMMON_TARGET_DEFINITIONS}) + set_target_properties(${T} PROPERTIES ${COMMON_TARGET_PROPERTIES}) + target_link_libraries(${T} ${TARGET_LIBSLEEF} ${LIB_MPFR} ${LIBM} ${LIBGMP}) + add_dependencies(${T} ${TARGET_HEADERS}) + add_dependencies(${T} ${TARGET_LIBSLEEF}) + if (MPFR_INCLUDE_DIR) + target_include_directories(${T} PRIVATE ${MPFR_INCLUDE_DIR}) + endif() + + # The tester2 programs whose name begins with "tester2y" are the + # testing program for the deterministic version of functions. + + set(T "tester2y${SCSIMD}${P}") + add_executable(${T} tester2simd${P}.c testerutil.c) + target_compile_options(${T} PRIVATE ${FLAGS_ENABLE_${SIMD}}) + target_compile_definitions(${T} PRIVATE ENABLE_${SIMD}=1 USEMPFR=1 ${COMMON_TARGET_DEFINITIONS} DETERMINISTIC=1) + set_target_properties(${T} PROPERTIES ${COMMON_TARGET_PROPERTIES}) + target_link_libraries(${T} ${TARGET_LIBSLEEF} ${LIB_MPFR} ${LIBM} ${LIBGMP}) + add_dependencies(${T} ${TARGET_HEADERS}) + add_dependencies(${T} ${TARGET_LIBSLEEF}) + if (MPFR_INCLUDE_DIR) + target_include_directories(${T} PRIVATE ${MPFR_INCLUDE_DIR}) + endif() + endforeach() + endif() + + if(NOT ${SIMD} STREQUAL NEON32 AND NOT ${SIMD} STREQUAL NEON32VFPV4 AND SLEEF_OPENSSL_FOUND) + # Build tester3 + string(TOLOWER ${SIMD} SCSIMD) + set(T "tester3${SCSIMD}") + add_executable(${T} tester3.c ${sleef_SOURCE_DIR}/src/common/main_checkfeature.c testerutil.c) + target_compile_options(${T} PRIVATE ${FLAGS_ENABLE_${SIMD}}) + target_compile_definitions(${T} PRIVATE ${COMMON_TARGET_DEFINITIONS} ${TESTER3_DEFINITIONS_${SIMD}}) + set_target_properties(${T} PROPERTIES ${COMMON_TARGET_PROPERTIES}) + + # Enable Vector PCS for Advanced SIMD (if supported) + if(FORCE_AAVPCS) + host_target_AAVPCS_definitions(${T}) + endif() + + target_link_libraries(${T} ${TARGET_LIBSLEEF} ${LIBM} ${SLEEF_OPENSSL_LIBRARIES}) + target_include_directories(${T} PRIVATE ${SLEEF_OPENSSL_INCLUDE_DIR}) + add_dependencies(${T} ${TARGET_HEADERS}) + add_dependencies(${T} ${TARGET_LIBSLEEF}) + + # Add test with tester3 + list(FIND TEST3_CINZ ${SCSIMD} INDEX_TEST3_CINZ) + if (NOT INDEX_TEST3_CINZ EQUAL -1) + if (SDE_COMMAND) + add_test(NAME tester3${SCSIMD} COMMAND ${SDE_COMMAND} "--" ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/tester3${SCSIMD} ${sleef_SOURCE_DIR}/src/libm-tester/hash_cinz.txt) + elseif(EMULATOR) + add_test(NAME tester3${SCSIMD} COMMAND ${EMULATOR} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/tester3${SCSIMD} ${sleef_SOURCE_DIR}/src/libm-tester/hash_cinz.txt) + else() + add_test(NAME tester3${SCSIMD} COMMAND tester3${SCSIMD} ${sleef_SOURCE_DIR}/src/libm-tester/hash_cinz.txt) + endif() + if (DEFINED COSTOVERRIDE_${SIMD}) + set_tests_properties(tester3${SCSIMD} PROPERTIES COST ${COSTOVERRIDE_${SIMD}}) + else() + set_tests_properties(tester3${SCSIMD} PROPERTIES COST 0.5) + endif() + endif() + + list(FIND TEST3_FINZ ${SCSIMD} INDEX_TEST3_FINZ) + if (NOT INDEX_TEST3_FINZ EQUAL -1) + if (SDE_COMMAND) + add_test(NAME tester3${SCSIMD} COMMAND ${SDE_COMMAND} "--" ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/tester3${SCSIMD} ${sleef_SOURCE_DIR}/src/libm-tester/hash_finz.txt) + elseif(EMULATOR) + add_test(NAME tester3${SCSIMD} COMMAND ${EMULATOR} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/tester3${SCSIMD} ${sleef_SOURCE_DIR}/src/libm-tester/hash_finz.txt) + else() + add_test(NAME tester3${SCSIMD} COMMAND tester3${SCSIMD} ${sleef_SOURCE_DIR}/src/libm-tester/hash_finz.txt) + endif() + if (DEFINED COSTOVERRIDE_${SIMD}) + set_tests_properties(tester3${SCSIMD} PROPERTIES COST ${COSTOVERRIDE_${SIMD}}) + else() + set_tests_properties(tester3${SCSIMD} PROPERTIES COST 0.5) + endif() + endif() + endif() + endif(COMPILER_SUPPORTS_${SIMD}) +endmacro(test_extension) + +foreach(SIMD ${SLEEF_SUPPORTED_LIBM_EXTENSIONS}) + test_extension(${SIMD}) +endforeach() + +function(add_gnuabi_compatibility_test SIMD MASKED) + if (MASKED) + set(GNUABI_COMPATIBILITY_TEST gnuabi_compatibility_${SIMD}_masked) + else(MASKED) + set(GNUABI_COMPATIBILITY_TEST gnuabi_compatibility_${SIMD}) + endif(MASKED) + add_executable(${GNUABI_COMPATIBILITY_TEST} gnuabi_compatibility.c ${sleef_SOURCE_DIR}/src/common/main_checkfeature.c) + set_target_properties(${GNUABI_COMPATIBILITY_TEST} PROPERTIES ${COMMON_TARGET_PROPERTIES}) + target_compile_options(${GNUABI_COMPATIBILITY_TEST} + PRIVATE ${FLAGS_ENABLE_${SIMD}}) + if (MASKED) + target_compile_definitions(${GNUABI_COMPATIBILITY_TEST} + PRIVATE ENABLE_${SIMD}=1 ${COMMON_TARGET_DEFINITIONS} MASKED_GNUABI=1) + else(MASKED) + target_compile_definitions(${GNUABI_COMPATIBILITY_TEST} + PRIVATE ENABLE_${SIMD}=1 ${COMMON_TARGET_DEFINITIONS}) + endif(MASKED) + if (FORCE_AAVPCS) + target_compile_definitions(${GNUABI_COMPATIBILITY_TEST} PRIVATE ENABLE_AAVPCS=1) + endif(FORCE_AAVPCS) + target_link_libraries(${GNUABI_COMPATIBILITY_TEST} ${TARGET_LIBSLEEFGNUABI} ${LIBM}) + # These are linker tests that don't really need to be executed, + # but seeing them in the report of ctest gives an idea of what + # has been built for testing. + if (EMULATOR) + add_test(NAME ${GNUABI_COMPATIBILITY_TEST} + COMMAND ${EMULATOR} $ + WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) + elseif(SDE_COMMAND) + add_test(NAME ${GNUABI_COMPATIBILITY_TEST} + COMMAND ${SDE_COMMAND} "--" $) + else() + add_test(NAME ${GNUABI_COMPATIBILITY_TEST} + COMMAND $) + endif(EMULATOR) +endfunction(add_gnuabi_compatibility_test) + +if(ENABLE_GNUABI) + foreach(SIMD ${SLEEF_SUPPORTED_GNUABI_EXTENSIONS}) + if(COMPILER_SUPPORTS_${SIMD}) + # GNUABI compatibility for the unmasked symbols. + add_gnuabi_compatibility_test(${SIMD} OFF) + # GNUABI compatibility for the masked symbols. + if (MKMASKED_PARAMS_GNUABI_${SIMD}_sp) + add_gnuabi_compatibility_test(${SIMD} ON) + endif(MKMASKED_PARAMS_GNUABI_${SIMD}_sp) + endif (COMPILER_SUPPORTS_${SIMD}) + endforeach(SIMD ${SLEEF_SUPPORTED_GNUABI_EXTENSIONS}) +endif(ENABLE_GNUABI) + +# + +if (SLEEF_ARCH_X86) + # iutdsp128 + add_executable(iutdsp128 ${IUT_SRC}) + target_compile_definitions(iutdsp128 PRIVATE ENABLE_DSP128=1 ${COMMON_TARGET_DEFINITIONS}) + target_compile_options(iutdsp128 PRIVATE ${FLAGS_ENABLE_SSE2}) + target_link_libraries(iutdsp128 ${TARGET_LIBSLEEF} ${LIBM} ${LIBRT}) + add_dependencies(iutdsp128 ${TARGET_HEADERS} ${TARGET_LIBSLEEF}) + add_test_iut(iutdsp128 1.0) + list(APPEND IUT_LIST iutdsp128) + + # iutdsp256 + add_executable(iutdsp256 ${IUT_SRC}) + target_compile_definitions(iutdsp256 PRIVATE ENABLE_DSP256=1 ${COMMON_TARGET_DEFINITIONS}) + target_compile_options(iutdsp256 PRIVATE ${FLAGS_ENABLE_AVX}) + target_link_libraries(iutdsp256 ${TARGET_LIBSLEEF} ${LIBM} ${LIBRT}) + add_dependencies(iutdsp256 ${TARGET_HEADERS} ${TARGET_LIBSLEEF}) + add_test_iut(iutdsp256 1.0) + list(APPEND IUT_LIST iutdsp256) +endif(SLEEF_ARCH_X86) + +if (SLEEF_ARCH_PPC64) + add_executable(iutdsp128 ${IUT_SRC}) + target_compile_definitions(iutdsp128 PRIVATE ENABLE_DSPPOWER_128=1 ${COMMON_TARGET_DEFINITIONS}) + target_compile_options(iutdsp128 PRIVATE ${FLAGS_ENABLE_VSX}) + target_link_libraries(iutdsp128 ${TARGET_LIBSLEEF} ${LIBM} ${LIBRT}) + add_dependencies(iutdsp128 ${TARGET_HEADERS} ${TARGET_LIBSLEEF}) + add_test_iut(iutdsp128 1.0) + list(APPEND IUT_LIST iutdsp128) +endif(SLEEF_ARCH_PPC64) + +if (SLEEF_ARCH_S390X) + add_executable(iutdsp128 ${IUT_SRC}) + target_compile_definitions(iutdsp128 PRIVATE ENABLE_DSPS390X_128=1 ${COMMON_TARGET_DEFINITIONS}) + target_compile_options(iutdsp128 PRIVATE ${FLAGS_ENABLE_VXE}) + target_link_libraries(iutdsp128 ${TARGET_LIBSLEEF} ${LIBM} ${LIBRT}) + add_dependencies(iutdsp128 ${TARGET_HEADERS} ${TARGET_LIBSLEEF}) + add_test_iut(iutdsp128 1.0) + list(APPEND IUT_LIST iutdsp128) +endif(SLEEF_ARCH_S390X) + +if(SLEEF_BUILD_SCALAR_LIB) + # Compile executable 'iutscalar' + add_executable(iutscalar iut.c testerutil.c) + target_compile_definitions(iutscalar PRIVATE ${COMMON_TARGET_DEFINITIONS}) + target_link_libraries(iutscalar sleefscalar ${TARGET_LIBSLEEF} ${LIBM} ${LIBRT}) + set_target_properties(iutscalar PROPERTIES ${COMMON_TARGET_PROPERTIES}) + add_test_iut(iutscalar 1.0) + list(APPEND IUT_LIST iutscalar) +endif() + +if(LIB_MPFR AND NOT MINGW) + # Build tester2 scalar + set(PRECISIONS dp sp) + if(COMPILER_SUPPORTS_LONG_DOUBLE) + list(APPEND PRECISIONS ld) + endif() + if(COMPILER_SUPPORTS_QUADMATH) + list(APPEND PRECISIONS qp) + set(LIBQUADMATH "-lquadmath") + set(ENABLEFLOAT128 PRIVATE ENABLEFLOAT128=1) + endif() + foreach(P ${PRECISIONS}) + set(T "tester2${P}") + add_executable(${T} tester2${P}.c testerutil.c) + target_compile_definitions(${T} PRIVATE USEMPFR=1 ${ENABLEFLOAT128} ${COMMON_TARGET_DEFINITIONS}) + set_target_properties(${T} PROPERTIES ${COMMON_TARGET_PROPERTIES}) + if (FORCE_AAVPCS) + target_compile_definitions(${T} PRIVATE ENABLE_AAVPCS=1) + endif(FORCE_AAVPCS) + if (MPFR_INCLUDE_DIR) + target_include_directories(${T} PRIVATE ${MPFR_INCLUDE_DIR}) + endif() + target_link_libraries(${T} ${TARGET_LIBSLEEF} ${LIBQUADMATH} ${LIB_MPFR} ${LIBM} ${LIBGMP}) + add_dependencies(${T} ${TARGET_HEADERS}) + add_dependencies(${T} ${TARGET_LIBSLEEF}) + endforeach() + + # Compile executable 'tester' + add_host_executable(${TARGET_TESTER} tester.c testerutil.c) + if (NOT CMAKE_CROSSCOMPILING) + target_link_libraries(${TARGET_TESTER} ${LIB_MPFR} ${TARGET_LIBSLEEF} ${LIBM} ${LIBGMP}) + target_compile_definitions(${TARGET_TESTER} + PRIVATE USEMPFR=1 ${COMMON_TARGET_DEFINITIONS}) + target_compile_options(${TARGET_TESTER} PRIVATE -Wno-unused-result) + set_target_properties(${TARGET_TESTER} PROPERTIES ${COMMON_TARGET_PROPERTIES}) + if (MPFR_INCLUDE_DIR) + target_include_directories(${TARGET_TESTER} PRIVATE ${MPFR_INCLUDE_DIR}) + endif() + endif() +endif(LIB_MPFR AND NOT MINGW) + +if(ENABLE_GNUABI AND COMPILER_SUPPORTS_OMP_SIMD AND NOT SLEEF_TARGET_PROCESSOR MATCHES "^i.86$") + # Build tester for vectorabi + add_executable(testervecabi testervecabi.c) + target_compile_definitions(testervecabi PRIVATE ${COMMON_TARGET_DEFINITIONS}) + target_compile_options(testervecabi PRIVATE ${OpenMP_C_FLAGS}) + target_link_libraries(testervecabi ${TARGET_LIBSLEEF} ${OpenMP_C_FLAGS}) + set_target_properties(testervecabi PROPERTIES C_STANDARD 99) + add_test(NAME testervecabi COMMAND ${EMULATOR} testervecabi + WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) +endif() + +# mveclibtest + +if (ENABLE_GNUABI AND SLEEF_ARCH_X86 AND CMAKE_C_COMPILER_ID MATCHES "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER 7.99) + add_executable(mveclibtest-sse2 mveclibtest.c ${sleef_SOURCE_DIR}/src/common/main_checkfeature.c) + set_target_properties(mveclibtest-sse2 PROPERTIES C_STANDARD 99) + target_compile_options(mveclibtest-sse2 PRIVATE ${FLAGS_FASTMATH} "-O3") + target_link_libraries(mveclibtest-sse2 ${TARGET_LIBSLEEF} ${TARGET_LIBSLEEFGNUABI}) + add_dependencies(mveclibtest-sse2 ${TARGET_HEADERS}) + add_test(NAME mveclibtest-sse2 COMMAND mveclibtest-sse2) + + add_executable(mveclibtest-avx mveclibtest.c ${sleef_SOURCE_DIR}/src/common/main_checkfeature.c) + set_target_properties(mveclibtest-avx PROPERTIES C_STANDARD 99) + target_compile_options(mveclibtest-avx PRIVATE ${FLAGS_FASTMATH} ${FLAGS_ENABLE_AVX} "-O3") + target_link_libraries(mveclibtest-avx ${TARGET_LIBSLEEF} ${TARGET_LIBSLEEFGNUABI}) + add_dependencies(mveclibtest-avx ${TARGET_HEADERS}) + add_test(NAME mveclibtest-avx COMMAND mveclibtest-avx) + + add_executable(mveclibtest-avx2 mveclibtest.c ${sleef_SOURCE_DIR}/src/common/main_checkfeature.c) + set_target_properties(mveclibtest-avx2 PROPERTIES C_STANDARD 99) + target_compile_options(mveclibtest-avx2 PRIVATE ${FLAGS_FASTMATH} ${FLAGS_ENABLE_AVX2} "-O3") + target_link_libraries(mveclibtest-avx2 ${TARGET_LIBSLEEF} ${TARGET_LIBSLEEFGNUABI}) + add_dependencies(mveclibtest-avx2 ${TARGET_HEADERS}) + add_test(NAME mveclibtest-avx2 COMMAND mveclibtest-avx2) + + add_executable(mveclibtest-avx512f mveclibtest.c ${sleef_SOURCE_DIR}/src/common/main_checkfeature.c) + set_target_properties(mveclibtest-avx512f PROPERTIES C_STANDARD 99) + target_compile_options(mveclibtest-avx512f PRIVATE ${FLAGS_FASTMATH} ${FLAGS_ENABLE_AVX512F} "-O3") + target_link_libraries(mveclibtest-avx512f ${TARGET_LIBSLEEF} ${TARGET_LIBSLEEFGNUABI}) + add_dependencies(mveclibtest-avx512f ${TARGET_HEADERS}) + add_test(NAME mveclibtest-avx512f COMMAND mveclibtest-avx512f) +endif() + +# + +if (FILECHECK_COMMAND AND COMPILER_SUPPORTS_OPENMP AND SLEEF_ARCH_X86 AND CMAKE_C_COMPILER_ID MATCHES "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER 7.99) + add_test(NAME autovec-avx2 COMMAND sh -c "${CMAKE_C_COMPILER} -Wno-attributes -fopenmp -mavx2 -O3 ${CMAKE_CURRENT_SOURCE_DIR}/autovec.c -I${sleef_BINARY_DIR}/include -S -o- | ${FILECHECK_COMMAND} ${CMAKE_CURRENT_SOURCE_DIR}/autovec.c -check-prefix=CHECK-AVX2") + add_test(NAME autovec-sse2 COMMAND sh -c "${CMAKE_C_COMPILER} -Wno-attributes -fopenmp -msse2 -O3 ${CMAKE_CURRENT_SOURCE_DIR}/autovec.c -I${sleef_BINARY_DIR}/include -S -o- | ${FILECHECK_COMMAND} ${CMAKE_CURRENT_SOURCE_DIR}/autovec.c -check-prefix=CHECK-SSE2") + add_test(NAME testervecabi-sse2 COMMAND sh -c "${CMAKE_C_COMPILER} -Wno-attributes -fopenmp -msse2 -O3 ${CMAKE_CURRENT_SOURCE_DIR}/testervecabi.c -I${sleef_BINARY_DIR}/include -S -o- | ${FILECHECK_COMMAND} ${CMAKE_CURRENT_SOURCE_DIR}/testervecabi.c -check-prefix=CHECK-SSE2") + add_test(NAME testervecabi-avx2 COMMAND sh -c "${CMAKE_C_COMPILER} -Wno-attributes -fopenmp -mavx2 -O3 ${CMAKE_CURRENT_SOURCE_DIR}/testervecabi.c -I${sleef_BINARY_DIR}/include -S -o- | ${FILECHECK_COMMAND} ${CMAKE_CURRENT_SOURCE_DIR}/testervecabi.c -check-prefix=CHECK-AVX2") +endif() + +# Tests depends on the library +add_dependencies(${TARGET_IUT} ${TARGET_HEADERS}) diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-tester/autovec.c b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-tester/autovec.c new file mode 100644 index 00000000000..41a0d0f2a77 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-tester/autovec.c @@ -0,0 +1,651 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#define SLEEF_ENABLE_OMP_SIMD +#include "sleef.h" + +#define N 1024 +double a[N], b[N], c[N], d[N]; +float e[N], f[N], g[N], h[N]; + +void testsind1_u10() { +// CHECK-SSE2: testsind1_u10 +// CHECK-AVX2: testsind1_u10 + for(int i=0;i` are present in +/// `libsleefgnuabi.so`. +/// +/// The header `math.h` is not the same on all systems, and different +/// macros can activate different sets of functions. The list provide +/// here shoudl cover the union of all possible systems that we want +/// to support. In particular, the test is checking that the "finite" +/// symmbols from `#include ` are present for +/// those systems supporting them. + +#include +#include +#include + +#if defined(ENABLE_SSE4) || defined(ENABLE_SSE2) +#include + +#define ISA_TOKEN b +#define VLEN_SP 4 +#define VLEN_DP 2 +#define VECTOR_CC + +typedef __m128i vopmask; +typedef __m128d vdouble; +typedef __m128 vfloat; +typedef __m128i vint; +typedef __m128i vint2; +#endif /* defined(ENABLE_SSE4) || defined(ENABLE_SSE2) */ + +#ifdef ENABLE_AVX +#include + +#define ISA_TOKEN c +#define VLEN_SP 8 +#define VLEN_DP 4 +#define VECTOR_CC + +typedef __m256i vopmask; +typedef __m256d vdouble; +typedef __m256 vfloat; +typedef __m128i vint; +typedef struct { __m128i x, y; } vint2; +#endif /* ENABLE_AVX */ + +#ifdef ENABLE_AVX2 +#include + +#define ISA_TOKEN d +#define VLEN_SP 8 +#define VLEN_DP 4 +#define VECTOR_CC + +typedef __m256i vopmask; +typedef __m256d vdouble; +typedef __m256 vfloat; +typedef __m128i vint; +typedef __m256i vint2; +#endif /* ENABLE_AVX2 */ + +#ifdef ENABLE_AVX512F +#include + +#define ISA_TOKEN e +#define VLEN_SP 16 +#define VLEN_DP 8 +#define VECTOR_CC + +typedef __mmask16 vopmask; +typedef __m512d vdouble; +typedef __m512 vfloat; +typedef __m256i vint; +typedef __m512i vint2; +#endif /* ENABLE_AVX512F */ + +#ifdef ENABLE_ADVSIMD +#include +#define ISA_TOKEN n +#define VLEN_DP 2 +#define VLEN_SP 4 + +#ifdef ENABLE_AAVPCS +#define VECTOR_CC __attribute__((aarch64_vector_pcs)) +#else +#define VECTOR_CC +#endif + +typedef uint32x4_t vopmask; +typedef float64x2_t vdouble; +typedef float32x4_t vfloat; +typedef int32x2_t vint; +typedef int32x4_t vint2; +#endif /* ENABLE_ADVSIMDF */ + +#ifdef ENABLE_SVE +#include +#define ISA_TOKEN s +#define VLEN_SP (svcntw()) +#define VLEN_DP (svcntd()) +#define VLA_TOKEN x +#define VECTOR_CC + +typedef svbool_t vopmask; +typedef svfloat64_t vdouble; +typedef svfloat32_t vfloat; +typedef svint32_t vint; +typedef svint32_t vint2; +#endif /* ENABLE_SVE */ + +// GNUABI name mangling macro. +#ifndef MASKED_GNUABI + +#define __MAKE_FN_NAME(name, t, vl, p) _ZGV##t##N##vl##p##_##name + +#define __DECLARE_vd_vd(name, t, vl, p) \ + extern vdouble VECTOR_CC __MAKE_FN_NAME(name, t, vl, p)(vdouble) +#define __CALL_vd_vd(name, t, vl, p) \ + do { vd0 = __MAKE_FN_NAME(name, t, vl, p)(vd1); } while(0) + +#define __DECLARE_vi_vd(name, t, vl, p) \ + extern vint VECTOR_CC __MAKE_FN_NAME(name, t, vl, p)(vdouble) +#define __CALL_vi_vd(name, t, vl, p) \ + do { vi0 = __MAKE_FN_NAME(name, t, vl, p)(vd1); } while(0) + +#define __DECLARE_vd_vd_vi(name, t, vl, p) \ + extern vdouble VECTOR_CC __MAKE_FN_NAME(name, t, vl, p)(vdouble, vint) +#define __CALL_vd_vd_vi(name, t, vl, p) \ + do { vd0 = __MAKE_FN_NAME(name, t, vl, p)(vd1, vi2); } while(0) + +#define __DECLARE_vd_vd_vd(name, t, vl, p) \ + extern vdouble VECTOR_CC __MAKE_FN_NAME(name, t, vl, p)(vdouble, vdouble) +#define __CALL_vd_vd_vd(name, t, vl, p) \ + do { vd0 = __MAKE_FN_NAME(name, t, vl, p)(vd1, vd2); } while(0) + +#define __DECLARE_vd_vd_vd_vd(name, t, vl, p) \ + extern vdouble VECTOR_CC __MAKE_FN_NAME(name, t, vl, p)(vdouble, vdouble, vdouble) +#define __CALL_vd_vd_vd_vd(name, t, vl, p) \ + do { vd0 = __MAKE_FN_NAME(name, t, vl, p)(vd1, vd2, vd3); } while(0) + +#define __DECLARE_vd_vd_pvd(name, t, vl, p) \ + extern vdouble VECTOR_CC __MAKE_FN_NAME(name, t, vl, p)(vdouble, vdouble *) +#define __CALL_vd_vd_pvd(name, t, vl, p) \ + do { vd0 = __MAKE_FN_NAME(name, t, vl, p)(vd1, &vd2); } while(0) + +#define __DECLARE_v_vd_pvd_pvd(name, t, vl, p) \ + extern void VECTOR_CC __MAKE_FN_NAME(name, t, vl, p)(vdouble, vdouble *, vdouble *) +#define __CALL_v_vd_pvd_pvd(name, t, vl, p) \ + do { __MAKE_FN_NAME(name, t, vl, p)(vd0, &vd1, &vd2); } while(0) + +#define __DECLARE_vf_vf(name, t, vl, p) \ + extern vfloat VECTOR_CC __MAKE_FN_NAME(name, t, vl, p)(vfloat) +#define __CALL_vf_vf(name, t, vl, p) \ + do { vf0 = __MAKE_FN_NAME(name, t, vl, p)(vf1); } while(0) + +#define __DECLARE_vf_vf_vf(name, t, vl, p) \ + extern vfloat VECTOR_CC __MAKE_FN_NAME(name, t, vl, p)(vfloat, vfloat) +#define __CALL_vf_vf_vf(name, t, vl, p) \ + do { vf0 = __MAKE_FN_NAME(name, t, vl, p)(vf1, vf2); } while(0) + +#define __DECLARE_vf_vf_vf_vf(name, t, vl, p) \ + extern vfloat VECTOR_CC __MAKE_FN_NAME(name, t, vl, p)(vfloat, vfloat, vfloat) +#define __CALL_vf_vf_vf_vf(name, t, vl, p) \ + do { vf0 = __MAKE_FN_NAME(name, t, vl, p)(vf1, vf2, vf3); } while(0) + +#define __DECLARE_vf_vf_pvf(name, t, vl, p) \ + extern vfloat VECTOR_CC __MAKE_FN_NAME(name, t, vl, p)(vfloat, vfloat *) +#define __CALL_vf_vf_pvf(name, t, vl, p) \ + do { vf0 = __MAKE_FN_NAME(name, t, vl, p)(vf1, &vf2); } while(0) + +#define __DECLARE_vi_vf(name, t, vl, p) \ + extern vint2 VECTOR_CC __MAKE_FN_NAME(name, t, vl, p)(vfloat) +#define __CALL_vi_vf(name, t, vl, p) \ + do { vi20 = __MAKE_FN_NAME(name, t, vl, p)(vf1); } while(0) + +#define __DECLARE_vf_vf_vi(name, t, vl, p) \ + extern vfloat VECTOR_CC __MAKE_FN_NAME(name, t, vl, p)(vfloat, vint2) +#define __CALL_vf_vf_vi(name, t, vl, p) \ + do { vf0 = __MAKE_FN_NAME(name, t, vl, p)(vf1, vi22); } while(0) + +#define __DECLARE_v_vf_pvf_pvf(name, t, vl, p) \ + extern vfloat VECTOR_CC __MAKE_FN_NAME(name, t, vl, p)(vfloat, vfloat *, vfloat*) +#define __CALL_v_vf_pvf_pvf(name, t, vl, p) \ + do { __MAKE_FN_NAME(name, t, vl, p)(vf0, &vf1, &vf2); } while(0) + +#else /******************** MASKED_GNUABI *****************************/ + +#define __MAKE_FN_NAME(name, t, vl, p) _ZGV##t##M##vl##p##_##name + +#define __DECLARE_vd_vd(name, t, vl, p) \ + extern vdouble VECTOR_CC __MAKE_FN_NAME(name, t, vl, p)(vdouble, vopmask) +#define __CALL_vd_vd(name, t, vl, p) \ + do { vd0 = __MAKE_FN_NAME(name, t, vl, p)(vd1, mask); } while(0) + +#define __DECLARE_vi_vd(name, t, vl, p) \ + extern vint VECTOR_CC __MAKE_FN_NAME(name, t, vl, p)(vdouble, vopmask) +#define __CALL_vi_vd(name, t, vl, p) \ + do { vi0 = __MAKE_FN_NAME(name, t, vl, p)(vd1, mask); } while(0) + +#define __DECLARE_vd_vd_vi(name, t, vl, p) \ + extern vdouble VECTOR_CC __MAKE_FN_NAME(name, t, vl, p)(vdouble, vint, vopmask) +#define __CALL_vd_vd_vi(name, t, vl, p) \ + do { vd0 = __MAKE_FN_NAME(name, t, vl, p)(vd1, vi2, mask); } while(0) + +#define __DECLARE_vd_vd_vd(name, t, vl, p) \ + extern vdouble VECTOR_CC __MAKE_FN_NAME(name, t, vl, p)(vdouble, vdouble, vopmask) +#define __CALL_vd_vd_vd(name, t, vl, p) \ + do { vd0 = __MAKE_FN_NAME(name, t, vl, p)(vd1, vd2, mask); } while(0) + +#define __DECLARE_vd_vd_vd_vd(name, t, vl, p) \ + extern vdouble VECTOR_CC __MAKE_FN_NAME(name, t, vl, p)(vdouble, vdouble, vdouble, vopmask) +#define __CALL_vd_vd_vd_vd(name, t, vl, p) \ + do { vd0 = __MAKE_FN_NAME(name, t, vl, p)(vd1, vd2, vd3, mask); } while(0) + +#define __DECLARE_vd_vd_pvd(name, t, vl, p) \ + extern vdouble VECTOR_CC __MAKE_FN_NAME(name, t, vl, p)(vdouble, vdouble *, vopmask) +#define __CALL_vd_vd_pvd(name, t, vl, p) \ + do { vd0 = __MAKE_FN_NAME(name, t, vl, p)(vd1, &vd2, mask); } while(0) + +#define __DECLARE_v_vd_pvd_pvd(name, t, vl, p) \ + extern void VECTOR_CC __MAKE_FN_NAME(name, t, vl, p)(vdouble, vdouble *, vdouble *, vopmask) +#define __CALL_v_vd_pvd_pvd(name, t, vl, p) \ + do { __MAKE_FN_NAME(name, t, vl, p)(vd0, &vd1, &vd2, mask); } while(0) + +#define __DECLARE_vf_vf(name, t, vl, p) \ + extern vfloat VECTOR_CC __MAKE_FN_NAME(name, t, vl, p)(vfloat, vopmask) +#define __CALL_vf_vf(name, t, vl, p) \ + do { vf0 = __MAKE_FN_NAME(name, t, vl, p)(vf1, mask); } while(0) + +#define __DECLARE_vf_vf_vf(name, t, vl, p) \ + extern vfloat VECTOR_CC __MAKE_FN_NAME(name, t, vl, p)(vfloat, vfloat, vopmask) +#define __CALL_vf_vf_vf(name, t, vl, p) \ + do { vf0 = __MAKE_FN_NAME(name, t, vl, p)(vf1, vf2, mask); } while(0) + +#define __DECLARE_vf_vf_vf_vf(name, t, vl, p) \ + extern vfloat VECTOR_CC __MAKE_FN_NAME(name, t, vl, p)(vfloat, vfloat, vfloat, vopmask) +#define __CALL_vf_vf_vf_vf(name, t, vl, p) \ + do { vf0 = __MAKE_FN_NAME(name, t, vl, p)(vf1, vf2, vf3, mask); } while(0) + +#define __DECLARE_vf_vf_pvf(name, t, vl, p) \ + extern vfloat VECTOR_CC __MAKE_FN_NAME(name, t, vl, p)(vfloat, vfloat *, vopmask) +#define __CALL_vf_vf_pvf(name, t, vl, p) \ + do { vf0 = __MAKE_FN_NAME(name, t, vl, p)(vf1, &vf2, mask); } while(0) + +#define __DECLARE_vi_vf(name, t, vl, p) \ + extern vint2 VECTOR_CC __MAKE_FN_NAME(name, t, vl, p)(vfloat, vopmask) +#define __CALL_vi_vf(name, t, vl, p) \ + do { vi20 = __MAKE_FN_NAME(name, t, vl, p)(vf1, mask); } while(0) + +#define __DECLARE_vf_vf_vi(name, t, vl, p) \ + extern vfloat VECTOR_CC __MAKE_FN_NAME(name, t, vl, p)(vfloat, vint2, vopmask) +#define __CALL_vf_vf_vi(name, t, vl, p) \ + do { vf0 = __MAKE_FN_NAME(name, t, vl, p)(vf1, vi22, mask); } while(0) + +#define __DECLARE_v_vf_pvf_pvf(name, t, vl, p) \ + extern vfloat VECTOR_CC __MAKE_FN_NAME(name, t, vl, p)(vfloat, vfloat *, vfloat*, vopmask) +#define __CALL_v_vf_pvf_pvf(name, t, vl, p) \ + do { __MAKE_FN_NAME(name, t, vl, p)(vf0, &vf1, &vf2, mask); } while(0) + +#endif /* MASKED_GNUABI */ +// Level-1 expansion macros for declaration and call. The signature of +// each function has three input paramters to avoid segfaults of +// sincos-like functions that are effectively loading data from +// memory. + + +// Make sure that the architectural macros are defined for each vector +// extension. +#ifndef ISA_TOKEN +#error "Missing ISA token" +#endif + +#ifndef VLEN_DP +#error "Missing VLEN_DP" +#endif + +#ifndef VLEN_DP +#error "Missing VLEN_SP" +#endif + +#if defined(ENABLE_SVE) && !defined(VLA_TOKEN) +#error "Missing VLA_TOKEN" +#endif /* defined(ENABLE_SVE) && !defined(VLA_TOKEN) */ + +// Declaration and call, first level expantion to pick up the +// ISA_TOKEN and VLEN_* architectural macros. +#ifndef ENABLE_SVE + +#define DECLARE_DP_vd_vd(name, p) __DECLARE_vd_vd(name, ISA_TOKEN, VLEN_DP, p) +#define CALL_DP_vd_vd(name, p) __CALL_vd_vd(name, ISA_TOKEN, VLEN_DP, p) + +#define DECLARE_DP_vd_vd_vd(name, p) __DECLARE_vd_vd_vd(name, ISA_TOKEN, VLEN_DP, p) +#define CALL_DP_vd_vd_vd(name, p) __CALL_vd_vd_vd(name, ISA_TOKEN, VLEN_DP, p) + +#define DECLARE_DP_vd_vd_vd_vd(name, p) __DECLARE_vd_vd_vd_vd(name, ISA_TOKEN, VLEN_DP, p) +#define CALL_DP_vd_vd_vd_vd(name, p) __CALL_vd_vd_vd_vd(name, ISA_TOKEN, VLEN_DP, p) + +#define DECLARE_DP_vd_vd_pvd(name, p) __DECLARE_vd_vd_pvd(name, ISA_TOKEN, VLEN_DP, p) +#define CALL_DP_vd_vd_pvd(name, p) __CALL_vd_vd_pvd(name, ISA_TOKEN, VLEN_DP, p) + +#define DECLARE_DP_vi_vd(name, p) __DECLARE_vi_vd(name, ISA_TOKEN, VLEN_DP, p) +#define CALL_DP_vi_vd(name, p) __CALL_vi_vd(name, ISA_TOKEN, VLEN_DP, p) + +#define DECLARE_DP_vd_vd_vi(name, p) __DECLARE_vd_vd_vi(name, ISA_TOKEN, VLEN_DP, p) +#define CALL_DP_vd_vd_vi(name, p) __CALL_vd_vd_vi(name, ISA_TOKEN, VLEN_DP, p) + +#define DECLARE_DP_v_vd_pvd_pvd(name, p) __DECLARE_v_vd_pvd_pvd(name, ISA_TOKEN, VLEN_DP, p) +#define CALL_DP_v_vd_pvd_pvd(name, p) __CALL_v_vd_pvd_pvd(name, ISA_TOKEN, VLEN_DP, p) + +#define DECLARE_SP_vf_vf(name, p) __DECLARE_vf_vf(name, ISA_TOKEN, VLEN_SP, p) +#define CALL_SP_vf_vf(name, p) __CALL_vf_vf(name, ISA_TOKEN, VLEN_SP, p) + +#define DECLARE_SP_vf_vf_vf(name, p) __DECLARE_vf_vf_vf(name, ISA_TOKEN, VLEN_SP, p) +#define CALL_SP_vf_vf_vf(name, p) __CALL_vf_vf_vf(name, ISA_TOKEN, VLEN_SP, p) + +#define DECLARE_SP_vf_vf_vf_vf(name, p) __DECLARE_vf_vf_vf_vf(name, ISA_TOKEN, VLEN_SP, p) +#define CALL_SP_vf_vf_vf_vf(name, p) __CALL_vf_vf_vf_vf(name, ISA_TOKEN, VLEN_SP, p) + +#define DECLARE_SP_vf_vf_pvf(name, p) __DECLARE_vf_vf_pvf(name, ISA_TOKEN, VLEN_SP, p) +#define CALL_SP_vf_vf_pvf(name, p) __CALL_vf_vf_pvf(name, ISA_TOKEN, VLEN_SP, p) + +#define DECLARE_SP_vi_vf(name, p) __DECLARE_vi_vf(name, ISA_TOKEN, VLEN_SP, p) +#define CALL_SP_vi_vf(name, p) __CALL_vi_vf(name, ISA_TOKEN, VLEN_SP, p) + +#define DECLARE_SP_vf_vf_vi(name, p) __DECLARE_vf_vf_vi(name, ISA_TOKEN, VLEN_SP, p) +#define CALL_SP_vf_vf_vi(name, p) __CALL_vf_vf_vi(name, ISA_TOKEN, VLEN_SP, p) + +#define DECLARE_SP_v_vf_pvf_pvf(name, p) __DECLARE_v_vf_pvf_pvf(name, ISA_TOKEN, VLEN_SP, p) +#define CALL_SP_v_vf_pvf_pvf(name, p) __CALL_v_vf_pvf_pvf(name, ISA_TOKEN, VLEN_SP, p) + +#else /* ENABLE_SVE */ + +#define DECLARE_DP_vd_vd(name, p) __DECLARE_vd_vd(name, ISA_TOKEN, VLA_TOKEN, p) +#define CALL_DP_vd_vd(name, p) __CALL_vd_vd(name, ISA_TOKEN, VLA_TOKEN, p); svst1_f64(svptrue_b8(), (double *)outbuf, vd0) + +#define DECLARE_DP_vd_vd_vd(name, p) __DECLARE_vd_vd_vd(name, ISA_TOKEN, VLA_TOKEN, p) +#define CALL_DP_vd_vd_vd(name, p) __CALL_vd_vd_vd(name, ISA_TOKEN, VLA_TOKEN, p); svst1_f64(svptrue_b8(), (double *)outbuf, vd0) + +#define DECLARE_DP_vd_vd_vd_vd(name, p) __DECLARE_vd_vd_vd_vd(name, ISA_TOKEN, VLA_TOKEN, p) +#define CALL_DP_vd_vd_vd_vd(name, p) __CALL_vd_vd_vd_vd(name, ISA_TOKEN, VLA_TOKEN, p); svst1_f64(svptrue_b8(), (double *)outbuf, vd0) + +#define DECLARE_DP_vd_vd_pvd(name, p) __DECLARE_vd_vd_pvd(name, ISA_TOKEN, VLA_TOKEN, p) +#define CALL_DP_vd_vd_pvd(name, p) __CALL_vd_vd_pvd(name, ISA_TOKEN, VLA_TOKEN, p); svst1_f64(svptrue_b8(), (double *)outbuf, vd2) + +#define DECLARE_DP_vi_vd(name, p) __DECLARE_vi_vd(name, ISA_TOKEN, VLA_TOKEN, p) +#define CALL_DP_vi_vd(name, p) __CALL_vi_vd(name, ISA_TOKEN, VLA_TOKEN, p); svst1_s32(svptrue_b8(), (int *)outbuf, vi0) + +#define DECLARE_DP_vd_vd_vi(name, p) __DECLARE_vd_vd_vi(name, ISA_TOKEN, VLA_TOKEN, p) +#define CALL_DP_vd_vd_vi(name, p) __CALL_vd_vd_vi(name, ISA_TOKEN, VLA_TOKEN, p); svst1_f64(svptrue_b8(), (double *)outbuf, vd0) + +#define DECLARE_DP_v_vd_pvd_pvd(name, p) __DECLARE_v_vd_pvd_pvd(name, ISA_TOKEN, VLA_TOKEN, p) +#define CALL_DP_v_vd_pvd_pvd(name, p) __CALL_v_vd_pvd_pvd(name, ISA_TOKEN, VLA_TOKEN, p); svst1_f64(svptrue_b8(), (double *)outbuf, vd2) + +#define DECLARE_SP_vf_vf(name, p) __DECLARE_vf_vf(name, ISA_TOKEN, VLA_TOKEN, p) +#define CALL_SP_vf_vf(name, p) __CALL_vf_vf(name, ISA_TOKEN, VLA_TOKEN, p); svst1_f32(svptrue_b8(), (float *)outbuf, vf0) + +#define DECLARE_SP_vf_vf_vf(name, p) __DECLARE_vf_vf_vf(name, ISA_TOKEN, VLA_TOKEN, p) +#define CALL_SP_vf_vf_vf(name, p) __CALL_vf_vf_vf(name, ISA_TOKEN, VLA_TOKEN, p); svst1_f32(svptrue_b8(), (float *)outbuf, vf0) + +#define DECLARE_SP_vf_vf_vf_vf(name, p) __DECLARE_vf_vf_vf_vf(name, ISA_TOKEN, VLA_TOKEN, p) +#define CALL_SP_vf_vf_vf_vf(name, p) __CALL_vf_vf_vf_vf(name, ISA_TOKEN, VLA_TOKEN, p); svst1_f32(svptrue_b8(), (float *)outbuf, vf0) + +#define DECLARE_SP_vf_vf_pvf(name, p) __DECLARE_vf_vf_pvf(name, ISA_TOKEN, VLA_TOKEN, p) +#define CALL_SP_vf_vf_pvf(name, p) __CALL_vf_vf_pvf(name, ISA_TOKEN, VLA_TOKEN, p); svst1_f32(svptrue_b8(), (float *)outbuf, vf2) + +#define DECLARE_SP_vi_vf(name, p) __DECLARE_vi_vf(name, ISA_TOKEN, VLA_TOKEN, p) +#define CALL_SP_vi_vf(name, p) __CALL_vi_vf(name, ISA_TOKEN, VLA_TOKEN, p); svst1_s32(svptrue_b8(), (int *)outbuf, vi20) + +#define DECLARE_SP_vf_vf_vi(name, p) __DECLARE_vf_vf_vi(name, ISA_TOKEN, VLA_TOKEN, p) +#define CALL_SP_vf_vf_vi(name, p) __CALL_vf_vf_vi(name, ISA_TOKEN, VLA_TOKEN, p); svst1_f32(svptrue_b8(), (float *)outbuf, vf0) + +#define DECLARE_SP_v_vf_pvf_pvf(name, p) __DECLARE_v_vf_pvf_pvf(name, ISA_TOKEN, VLA_TOKEN, p) +#define CALL_SP_v_vf_pvf_pvf(name, p) __CALL_v_vf_pvf_pvf(name, ISA_TOKEN, VLA_TOKEN, p); svst1_f32(svptrue_b8(), (float *)outbuf, vf2) + +#endif /* ENABLE_SVE */ + +// + +// Douple precision function declarations. +DECLARE_DP_vd_vd(__acos_finite, v); +DECLARE_DP_vd_vd(__acosh_finite, v); +DECLARE_DP_vd_vd(__asin_finite, v); +DECLARE_DP_vd_vd_vd(__atan2_finite, vv); +DECLARE_DP_vd_vd(__atanh_finite, v); +DECLARE_DP_vd_vd(__cosh_finite, v); +DECLARE_DP_vd_vd(__exp10_finite, v); +DECLARE_DP_vd_vd(__exp2_finite, v); +DECLARE_DP_vd_vd(__exp_finite, v); +DECLARE_DP_vd_vd_vd(__fmod_finite, vv); +DECLARE_DP_vd_vd_pvd(__modf_finite, vl8); +DECLARE_DP_vd_vd_vd(__hypot_finite, vv); +DECLARE_DP_vd_vd(__log10_finite, v); +// DECLARE_DP_vd_vd(__log2_finite,v); +DECLARE_DP_vd_vd(__log_finite, v); +DECLARE_DP_vd_vd_vd(__pow_finite, vv); +DECLARE_DP_vd_vd(__sinh_finite, v); +DECLARE_DP_vd_vd(__sqrt_finite, v); +DECLARE_DP_vd_vd(acos, v); +DECLARE_DP_vd_vd(acosh, v); +DECLARE_DP_vd_vd(asin, v); +DECLARE_DP_vd_vd(asinh, v); +DECLARE_DP_vd_vd(atan, v); +DECLARE_DP_vd_vd_vd(atan2, vv); +DECLARE_DP_vd_vd_vd(__atan2_finite, vv); +DECLARE_DP_vd_vd(atanh, v); +DECLARE_DP_vd_vd(cbrt, v); +DECLARE_DP_vd_vd(ceil, v); +DECLARE_DP_vd_vd_vd(copysign, vv); +DECLARE_DP_vd_vd(cos, v); +DECLARE_DP_vd_vd(cosh, v); +DECLARE_DP_vd_vd(cospi, v); +DECLARE_DP_vd_vd(erf, v); +DECLARE_DP_vd_vd(erfc, v); +DECLARE_DP_vd_vd(exp, v); +DECLARE_DP_vd_vd(exp10, v); +DECLARE_DP_vd_vd(exp2, v); +DECLARE_DP_vi_vd(expfrexp, v); +DECLARE_DP_vd_vd(expm1, v); +DECLARE_DP_vd_vd(fabs, v); +DECLARE_DP_vd_vd_vd(fdim, vv); +DECLARE_DP_vd_vd(floor, v); +DECLARE_DP_vd_vd_vd_vd(fma, vvv); +DECLARE_DP_vd_vd_vd(fmax, vv); +DECLARE_DP_vd_vd_vd(fmin, vv); +DECLARE_DP_vd_vd_vd(fmod, vv); +DECLARE_DP_vd_vd(frfrexp, v); +DECLARE_DP_vd_vd_vd(hypot, vv); +DECLARE_DP_vi_vd(ilogb, v); +DECLARE_DP_vd_vd_vi(ldexp, vv); +DECLARE_DP_vd_vd(lgamma, v); +DECLARE_DP_vd_vd(log, v); +DECLARE_DP_vd_vd(log10, v); +DECLARE_DP_vd_vd(log1p, v); +DECLARE_DP_vd_vd(log2, v); +DECLARE_DP_vd_vd_pvd(modf, vl8); +DECLARE_DP_vd_vd_vd(nextafter, vv); +DECLARE_DP_vd_vd_vd(pow, vv); +DECLARE_DP_vd_vd(rint, v); +DECLARE_DP_vd_vd(round, v); +DECLARE_DP_vd_vd(sin, v); +DECLARE_DP_v_vd_pvd_pvd(sincos, vl8l8); +DECLARE_DP_v_vd_pvd_pvd(sincospi, vl8l8); +DECLARE_DP_vd_vd(sinh, v); +DECLARE_DP_vd_vd(sinpi, v); +DECLARE_DP_vd_vd(sqrt, v); +DECLARE_DP_vd_vd(tan, v); +DECLARE_DP_vd_vd(tanh, v); +DECLARE_DP_vd_vd(tgamma, v); +DECLARE_DP_vd_vd(trunc, v); + +// Single precision function declarations. +DECLARE_SP_vf_vf(__acosf_finite, v); +DECLARE_SP_vf_vf(__acoshf_finite, v); +DECLARE_SP_vf_vf(__asinf_finite, v); +DECLARE_SP_vf_vf_vf(__atan2f_finite, vv); +DECLARE_SP_vf_vf(__atanhf_finite, v); +DECLARE_SP_vf_vf(__coshf_finite, v); +DECLARE_SP_vf_vf(__exp10f_finite, v); +DECLARE_SP_vf_vf(__exp2f_finite, v); +DECLARE_SP_vf_vf(__expf_finite, v); +DECLARE_SP_vf_vf_vf(__fmodf_finite, vv); +DECLARE_SP_vf_vf_pvf(__modff_finite, vl4); +DECLARE_SP_vf_vf_vf(__hypotf_finite, vv); +DECLARE_SP_vf_vf(__log10f_finite, v); +// DECLARE_SP_vf_vf(__log2f_finite,v); +DECLARE_SP_vf_vf(__logf_finite, v); +DECLARE_SP_vf_vf_vf(__powf_finite, vv); +DECLARE_SP_vf_vf(__sinhf_finite, v); +DECLARE_SP_vf_vf(__sqrtf_finite, v); +DECLARE_SP_vf_vf(acosf, v); +DECLARE_SP_vf_vf(acoshf, v); +DECLARE_SP_vf_vf(asinf, v); +DECLARE_SP_vf_vf(asinhf, v); +DECLARE_SP_vf_vf(atanf, v); +DECLARE_SP_vf_vf_vf(atan2f, vv); +DECLARE_SP_vf_vf(atanhf, v); +DECLARE_SP_vf_vf(cbrtf, v); +DECLARE_SP_vf_vf(ceilf, v); +DECLARE_SP_vf_vf_vf(copysignf, vv); +DECLARE_SP_vf_vf(cosf, v); +DECLARE_SP_vf_vf(coshf, v); +DECLARE_SP_vf_vf(cospif, v); +DECLARE_SP_vf_vf(erff, v); +DECLARE_SP_vf_vf(erfcf, v); +DECLARE_SP_vf_vf(expf, v); +DECLARE_SP_vf_vf(exp10f, v); +DECLARE_SP_vf_vf(exp2f, v); +DECLARE_SP_vf_vf(expm1f, v); +DECLARE_SP_vf_vf(fabsf, v); +DECLARE_SP_vf_vf_vf(fdimf, vv); +DECLARE_SP_vf_vf(floorf, v); +DECLARE_SP_vf_vf_vf_vf(fmaf, vvv); +DECLARE_SP_vf_vf_vf(fmaxf, vv); +DECLARE_SP_vf_vf_vf(fminf, vv); +DECLARE_SP_vf_vf_vf(fmodf, vv); +DECLARE_SP_vf_vf(frfrexpf, v); +DECLARE_SP_vf_vf_vf(hypotf, vv); +#ifndef ENABLE_AVX +// These two functions are not checked in some configurations due to +// the issue in https://github.com/shibatch/sleef/issues/221 +DECLARE_SP_vi_vf(expfrexpf, v); +DECLARE_SP_vi_vf(ilogbf, v); +#endif +DECLARE_SP_vf_vf_vi(ldexpf, vv); +DECLARE_SP_vf_vf(lgammaf, v); +DECLARE_SP_vf_vf(logf, v); +DECLARE_SP_vf_vf(log10f, v); +DECLARE_SP_vf_vf(log1pf, v); +DECLARE_SP_vf_vf(log2f, v); +DECLARE_SP_vf_vf_pvf(modff, vl4); +DECLARE_SP_vf_vf_vf(nextafterf, vv); +DECLARE_SP_vf_vf_vf(powf, vv); +DECLARE_SP_vf_vf(rintf, v); +DECLARE_SP_vf_vf(roundf, v); +DECLARE_SP_vf_vf(sinf, v); +DECLARE_SP_v_vf_pvf_pvf(sincosf, vl4l4); +DECLARE_SP_v_vf_pvf_pvf(sincospif, vl4l4); +DECLARE_SP_vf_vf(sinhf, v); +DECLARE_SP_vf_vf(sinpif, v); +DECLARE_SP_vf_vf(sqrtf, v); +DECLARE_SP_vf_vf(tanf, v); +DECLARE_SP_vf_vf(tanhf, v); +DECLARE_SP_vf_vf(tgammaf, v); +DECLARE_SP_vf_vf(truncf, v); + +#ifndef ENABLE_SVE +vdouble vd0, vd1, vd2, vd3; +vfloat vf0, vf1, vf2, vf3; +vint vi0, vi1, vi2, vi3; +vint2 vi20, vi21, vi22, vi23; +vopmask mask; +#else +volatile char outbuf[1024]; +#endif + +int check_feature(double d, float f) { +#ifdef ENABLE_SVE + vdouble vd0 = svdup_n_f64(d), vd1 = svdup_n_f64(d); +#ifdef MASKED_GNUABI + vopmask mask = svcmpne_s32(svptrue_b8(), svdup_n_s32(f), svdup_n_s32(0)); +#endif +#endif + + CALL_DP_vd_vd(__acos_finite, v); +#ifdef ENABLE_SVE + svst1_f64(svptrue_b8(), (double *)outbuf, vd0); +#endif + return 1; +} + +int main2(int argc, char **argv) { +#ifdef ENABLE_SVE + vdouble vd0 = svdup_n_f64(argc), vd1 = svdup_n_f64(argc), vd2 = svdup_n_f64(argc), vd3 = svdup_n_f64(argc); + vfloat vf0 = svdup_n_f32(argc), vf1 = svdup_n_f32(argc), vf2 = svdup_n_f32(argc), vf3 = svdup_n_f32(argc); + vint vi0 = svdup_n_s32(argc), vi2 = svdup_n_s32(argc); + vint2 vi20 = svdup_n_s32(argc), vi22 = svdup_n_s32(argc); +#ifdef MASKED_GNUABI + vopmask mask = svcmpne_s32(svptrue_b8(), svdup_n_s32(argc), svdup_n_s32(0)); +#endif +#endif + + // Double precision function call. + CALL_DP_vd_vd(__acos_finite, v); + CALL_DP_vd_vd(__acosh_finite, v); + CALL_DP_vd_vd(__asin_finite, v); + CALL_DP_vd_vd_vd(__atan2_finite, vv); + CALL_DP_vd_vd(__atanh_finite, v); + CALL_DP_vd_vd(__cosh_finite, v); + CALL_DP_vd_vd(__exp10_finite, v); + CALL_DP_vd_vd(__exp2_finite, v); + CALL_DP_vd_vd(__exp_finite, v); + CALL_DP_vd_vd_vd(__fmod_finite, vv); + CALL_DP_vd_vd_pvd(__modf_finite, vl8); + CALL_DP_vd_vd_vd(__hypot_finite, vv); + CALL_DP_vd_vd(__log10_finite, v); + // CALL_DP_vd_vd(__log2_finite,v); + CALL_DP_vd_vd(__log_finite, v); + CALL_DP_vd_vd_vd(__pow_finite, vv); + CALL_DP_vd_vd(__sinh_finite, v); + CALL_DP_vd_vd(__sqrt_finite, v); + CALL_DP_vd_vd(acos, v); + CALL_DP_vd_vd(acosh, v); + CALL_DP_vd_vd(asin, v); + CALL_DP_vd_vd(asinh, v); + CALL_DP_vd_vd(atan, v); + CALL_DP_vd_vd_vd(atan2, vv); + CALL_DP_vd_vd(atanh, v); + CALL_DP_vd_vd(cbrt, v); + CALL_DP_vd_vd(ceil, v); + CALL_DP_vd_vd_vd(copysign, vv); + CALL_DP_vd_vd(cos, v); + CALL_DP_vd_vd(cosh, v); + CALL_DP_vd_vd(cospi, v); + CALL_DP_vd_vd(erf, v); + CALL_DP_vd_vd(erfc, v); + CALL_DP_vd_vd(exp, v); + CALL_DP_vd_vd(exp10, v); + CALL_DP_vd_vd(exp2, v); + CALL_DP_vi_vd(expfrexp, v); + CALL_DP_vd_vd(expm1, v); + CALL_DP_vd_vd(fabs, v); + CALL_DP_vd_vd_vd(fdim, vv); + CALL_DP_vd_vd(floor, v); + CALL_DP_vd_vd_vd_vd(fma, vvv); + CALL_DP_vd_vd_vd(fmax, vv); + CALL_DP_vd_vd_vd(fmin, vv); + CALL_DP_vd_vd_vd(fmod, vv); + CALL_DP_vd_vd(frfrexp, v); + CALL_DP_vd_vd_vd(hypot, vv); + CALL_DP_vi_vd(ilogb, v); + CALL_DP_vd_vd_vi(ldexp, vv); + CALL_DP_vd_vd(lgamma, v); + CALL_DP_vd_vd(log, v); + CALL_DP_vd_vd(log10, v); + CALL_DP_vd_vd(log1p, v); + CALL_DP_vd_vd(log2, v); + CALL_DP_vd_vd_pvd(modf, vl8); + CALL_DP_vd_vd_vd(nextafter, vv); + CALL_DP_vd_vd_vd(pow, vv); + CALL_DP_vd_vd(rint, v); + CALL_DP_vd_vd(round, v); + CALL_DP_vd_vd(sin, v); + CALL_DP_v_vd_pvd_pvd(sincos, vl8l8); + CALL_DP_v_vd_pvd_pvd(sincospi, vl8l8); + CALL_DP_vd_vd(sinh, v); + CALL_DP_vd_vd(sinpi, v); + CALL_DP_vd_vd(sqrt, v); + CALL_DP_vd_vd(tan, v); + CALL_DP_vd_vd(tanh, v); + CALL_DP_vd_vd(tgamma, v); + CALL_DP_vd_vd(trunc, v); + + // Single precision function call. + CALL_SP_vf_vf(__acosf_finite, v); + CALL_SP_vf_vf(__acoshf_finite, v); + CALL_SP_vf_vf(__asinf_finite, v); + CALL_SP_vf_vf_vf(__atan2f_finite, vv); + CALL_SP_vf_vf(__atanhf_finite, v); + CALL_SP_vf_vf(__coshf_finite, v); + CALL_SP_vf_vf(__exp10f_finite, v); + CALL_SP_vf_vf(__exp2f_finite, v); + CALL_SP_vf_vf(__expf_finite, v); + CALL_SP_vf_vf_vf(__fmodf_finite, vv); + CALL_SP_vf_vf_pvf(__modff_finite, vl4); + CALL_SP_vf_vf_vf(__hypotf_finite, vv); + CALL_SP_vf_vf(__log10f_finite, v); + // CALL_SP_vf_vf(__log2f_finite,v); + CALL_SP_vf_vf(__logf_finite, v); + CALL_SP_vf_vf_vf(__powf_finite, vv); + CALL_SP_vf_vf(__sinhf_finite, v); + CALL_SP_vf_vf(__sqrtf_finite, v); + CALL_SP_vf_vf(acosf, v); + CALL_SP_vf_vf(acoshf, v); + CALL_SP_vf_vf(asinf, v); + CALL_SP_vf_vf(asinhf, v); + CALL_SP_vf_vf(atanf, v); + CALL_SP_vf_vf_vf(atan2f, vv); + CALL_SP_vf_vf(atanhf, v); + CALL_SP_vf_vf(cbrtf, v); + CALL_SP_vf_vf(ceilf, v); + CALL_SP_vf_vf_vf(copysignf, vv); + CALL_SP_vf_vf(cosf, v); + CALL_SP_vf_vf(coshf, v); + CALL_SP_vf_vf(cospif, v); + CALL_SP_vf_vf(erff, v); + CALL_SP_vf_vf(erfcf, v); + CALL_SP_vf_vf(expf, v); + CALL_SP_vf_vf(exp10f, v); + CALL_SP_vf_vf(exp2f, v); + CALL_SP_vf_vf(expm1f, v); + CALL_SP_vf_vf(fabsf, v); + CALL_SP_vf_vf_vf(fdimf, vv); + CALL_SP_vf_vf(floorf, v); + CALL_SP_vf_vf_vf_vf(fmaf, vvv); + CALL_SP_vf_vf_vf(fmaxf, vv); + CALL_SP_vf_vf_vf(fminf, vv); + CALL_SP_vf_vf_vf(fmodf, vv); + CALL_SP_vf_vf(frfrexpf, v); + CALL_SP_vf_vf_vf(hypotf, vv); +#ifndef ENABLE_AVX +// These two functions are not checked in some configurations due to +// the issue in https://github.com/shibatch/sleef/issues/221 + CALL_SP_vi_vf(expfrexpf, v); + CALL_SP_vi_vf(ilogbf, v); +#endif + CALL_SP_vf_vf_vi(ldexpf, vv); + CALL_SP_vf_vf(lgammaf, v); + CALL_SP_vf_vf(logf, v); + CALL_SP_vf_vf(log10f, v); + CALL_SP_vf_vf(log1pf, v); + CALL_SP_vf_vf(log2f, v); + CALL_SP_vf_vf_pvf(modff, vl4); + CALL_SP_vf_vf_vf(nextafterf, vv); + CALL_SP_vf_vf_vf(powf, vv); + CALL_SP_vf_vf(rintf, v); + CALL_SP_vf_vf(roundf, v); + CALL_SP_vf_vf(sinf, v); + CALL_SP_v_vf_pvf_pvf(sincosf, vl4l4); + CALL_SP_v_vf_pvf_pvf(sincospif, vl4l4); + CALL_SP_vf_vf(sinhf, v); + CALL_SP_vf_vf(sinpif, v); + CALL_SP_vf_vf(sqrtf, v); + CALL_SP_vf_vf(tanf, v); + CALL_SP_vf_vf(tanhf, v); + CALL_SP_vf_vf(tgammaf, v); + CALL_SP_vf_vf(truncf, v); + + return 0; +} diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-tester/hash_cinz.txt b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-tester/hash_cinz.txt new file mode 100644 index 00000000000..2a8c1a85c9f --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-tester/hash_cinz.txt @@ -0,0 +1,129 @@ +sin u35 bc50dfbcbd8ef534541d1babe90860c7 +sin u10 dbc2cf81f292ef50fa0119e222c6c9f9 +cos u35 506e34a809b80ad3603ed46ba2a574b0 +cos u10 a0f69df5937152b8f8f0e671f3676289 +tan u35 970b5cd7f0e05defa22ebb155ab61a40 +tan u10 5fd08e0552e3ab853439bf5fd2bd344d +sincos u10 7c164edcaa45988f6165b653fc76c495 +sincos u35 38fe7e261e184ed8dbf432ce6bedc5c4 +sincospi u05 0c6fc00c7aaf0b6e67d66542d1be833d +sincospi u35 c428b0fc3e6c5be4d2c03dcd8bb27a7c +log u10 4855b27222d900bea47a27cadba71727 +log u35 c95484de57c167da3d8d6d1baadf9ffa +log2 u10 2662df9af919680ca62e1752fb1b7539 +log2 u35 1cd6d7f194a5e8364191497adc5c5cec +log10 u10 36645e8031d873d66fd0ec2c5959f273 +log1p u10 1383924fb56cf2e7eda27de21320c591 +exp u10 13692a48edf2cf7a3e047b16ddfb7b81 +exp2 u10 436146f8d6dcaa4a754837108a9aa3e1 +exp2 u35 8881d075d9101a1dfa3f6a10b9ee8373 +exp10 u10 9d704b310f683872a6446cfc97726a4d +exp10 u35 bc07745ebc22a7ee97679154c24b23cc +expm1 u10 cd3f0b8e86943d52c278394b60e2d22e +pow u10 a0ea63b27d33262346a35c9439741075 +cbrt u10 5d8bf28ac74624594fd1be9217817690 +cbrt u10 3c896e03746bcf1b3f70182dfec3d93b +cbrt u35 73daa306764e208aab1627ac110b10d7 +cbrt u35 c29b7bf200215425b4ba948c8cc94c42 +hypot u05 cc2f18e409e19a02cadf7b91fd869120 +hypot u35 5194e0a554174a6145511ce3df9c1f46 +asin u10 86c061caec3fa2e1bc71bda4dad29f4c +asin u35 31303b88bdc00206265002d6cc5e89e4 +acos u10 0a1a403590f2ac8364f132b334920945 +acos u35 493f960c1cce57931d95a5a22a0587a3 +atan u10 c97624a24ec034cc0c8985acb61d13cd +atan u10 0be0f550406923016cfeb5ef62c25b15 +atan u35 9d6d83e066b5a4851d44771418c9948c +atan u35 f32c1aa4caa08c6945afd1125ba8b113 +atan2 u10 6b1d9d25fcd96053acc19d1633fab36a +atan2 u35 afb07894347062a96dab705b34eb1763 +sinh u10 61d459b1f368087f6f23ebf8e9f0ea01 +cosh u10 f77eb95f79e274c12b4e92dc0389259b +tanh u10 2bb9dd54ed0fa22bb5f3b6d557eb58a3 +asinh u10 01136e54e2a434839530dda54f33cfdb +acosh u10 2f3c28c9ee2eb2b3d5659c6cb2a58e3e +atanh u10 601a77ba8c1d5175f2808b48a41260c1 +lgamma u10 90cdc41063f4198c6ad592c0cdd0f5da +tgamma u10 6f864c3a1f17fbdf914cac7ffcd82cb7 +erf u10 f4ae148b59bb7501d8f5746300850376 +erfc u15 5e116a4316dafa742769f71e18f6f9fe +fabs bef2f2ac8a4789357e580b4da4f9b9fe +copysign 3219022f267464e3704f90558e8df3bc +fmax 4e4f5220ccfef191864c316df0d18fc0 +fmin c0f8effb6c611e2b3b91b820ad943f62 +fdim e876d103931f18ceede5bfd7e3df7ab0 +fmod 618aa751e13012afdb41ec80dd35e6ba +remainder 8d692dbb44bbc9be5af0c0657d3008b8 +modf f03ce73cd4f9ea7f69c017f6e53355d5 +nextafter 9eba4e30d12d74dc4e8003fcff0f1582 +trunc 1bc7e909eba121dcef7f0e4046937ae5 +floor 2cff66b499dc8a30cec9467de659b774 +ceil b080e632dcb8f8134d8715752be12917 +round 8907e21687ca9c2a539297536e754950 +rint e49f837096bc661fe1c742801dd99a30 +sinf u35 833d845950b9cbb025629fe4c040f8f6 +sinf u10 9c21afa4d7d6af3fc666309c3cd647fe +cosf u35 74d7f871a6553cd0019087895e2052ad +cosf u10 35349e94c323c1614f22093959288010 +tanf u35 bbb7c092d017e96d2454a38a20687735 +tanf u10 227423bc04f42d76a8f68082ba696126 +sincosf u10 83ecc4e3d5295056e9d8c52bc196b666 +sincosf u35 533319caa49a961e4909bd6dcab40721 +sincospif u05 8b3762b67a661957c1414c351ec49034 +sincospif u35 cec15ed76a358091632634166fa77b66 +logf u10 c5a90119943acc4199e1cc7030b5def8 +logf u35 af2fbe4bfa2caaf59c734e3749dd15be +log2f u10 ba8acae369bbb7b6404cccbc633fe25b +log2f u35 ba32ebaa8c470899ebd433d190c00f03 +log10f u10 7e235a82d960e4434575dd39648d8bb7 +log1pf u10 350fc4f13502b36bb1107e1b1122acb1 +expf u10 ee4adaabefa3fac6c0f1925b2a948eea +exp2f u10 b0d283dbae0f36f1b3c7eed9871f0d0d +exp2f u35 522cc30f722f77fceb07015830b351a3 +exp10f u10 b0564be151965600f5744ff2e4992bc9 +exp10f u35 d142f1fb40e44f0c9e042718f27ee3e0 +expm1f u10 ebfd6498cb40f61b609882de8a7f3c74 +powf u10 a7cba3239c87969662e8b41a4dd8b4ab +cbrtf u10 01c5cac23fe21638be1c3eab6e368fd6 +cbrtf u10 2a245b03f83e9114644d03b40dac707b +cbrtf u35 3ce62350fd585f0524a12c974fbe6cf5 +cbrtf u35 2aca0404626a28f7af7f60105ad6e217 +hypotf u05 bc5971cbeebee27b4c0d91fbe3f6bf30 +hypotf u35 a6f0f774b346a6bba08889ff9ba3f193 +asinf u10 7f77f7453b961512c89e87e49c549cfe +asinf u35 22ed8760aa328e1f714031eec592a4d8 +acosf u10 15617dd0429b90e59d2923415934c2a6 +acosf u35 af0b132d9e263721f9296187dbf9b9bf +atanf u10 26b77fb423104b45633cf24500237d6e +atanf u10 4313d0bc2708de53f74d804aac6564d4 +atanf u35 97a1797897955643c722c7d291987331 +atanf u35 7d3f47169415058e8578f11d899bfd10 +atan2f u10 098a33f730fe95ce4774a991db4cee14 +atan2f u35 56fc6bd8349979f0d0b1dcdb57f68363 +sinhf u10 0780a2f57df3a831718195d1ee5c19ef +coshf u10 cfbb6aed408e43a7b7f053474100ff2d +tanhf u10 d19f254d41e8726c748df87b95bc9acd +asinhf u10 260d129221468a86bbfd609c27bfea6a +acoshf u10 24ced7e5631c78b20a5716faeedbaa92 +atanhf u10 164fd77b8372b8c131baaacab1c9e650 +lgammaf u10 3bf6d824175c4f4d86f3073064e41e84 +tgammaf u10 f3a8d25c852068622bdfcae4cb813583 +erff u10 f34af3814153de040b93e573ca7d21d8 +erfcf u15 915ab9830de89a5a504b3ce7cd2fecda +fabsf a3c72220bc0ade68fe22e0a15eb730d4 +copysignf 6b35517b8e1da78d9c9b52915d9a9b19 +fmaxf 9833a60a2080e8fd9ae8de32c758966f +fminf 2dcfa19e1f1ab4973a7dec9f2cc09fa0 +fdimf c5c0fe7b095eb8ccbb19fbf934a36b24 +fmodf 77aa84a9703e202a56e5f4609bd2482b +remainderf 5a453b1217c173e4dc0b0211066750be +modff 5fa4f044f20478216aa085a01b189697 +nextafterf 517c1c8f072e9024518d3d9ead98b85b +truncf 6937050850be63c44d4b7dbd666febe6 +floorf 9341be69ee345c8554bf3ab4e9316133 +ceilf c70874771cbe9741f1f05fedd4b629e9 +roundf 0cf52f6b8015099771e9a7dfa6b090bc +rintf bed68e788e2b11543c09c9d52198abf8 +fastsinf u3500 8eb51f86fb40414dd21284f020f24b6c +fastcosf u3500 69cbc3703f1d2c68695b00b1b09287b2 +fastpowf u3500 e02e6a692cfa22a6b7149168c67ea1d2 diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-tester/hash_finz.txt b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-tester/hash_finz.txt new file mode 100644 index 00000000000..6d8589f35bc --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-tester/hash_finz.txt @@ -0,0 +1,129 @@ +sin u35 c163e4a7e9ccebb2181dcc8653367d8c +sin u10 0d6bf6f2c935db82588222da95659019 +cos u35 52f902bd939d751b5b544ac70181fcff +cos u10 afcdba92a75a76d56b8cf2f22d4bec9e +tan u35 906cc42b6755fe514c5e185fcb4d2f55 +tan u10 c98f29a62067fa63646d9bcc29a310c6 +sincos u10 3fe37f4eb805505152f2b14a22a9f94e +sincos u35 95a7b7f48c71febf10ec6eff796dd391 +sincospi u05 0c6fc00c7aaf0b6e67d66542d1be833d +sincospi u35 c428b0fc3e6c5be4d2c03dcd8bb27a7c +log u10 4855b27222d900bea47a27cadba71727 +log u35 015f8ae899c9b921d48919dd12ef19a9 +log2 u10 2662df9af919680ca62e1752fb1b7539 +log2 u35 908b1949db34ea855944f00089b21e23 +log10 u10 36645e8031d873d66fd0ec2c5959f273 +log1p u10 1383924fb56cf2e7eda27de21320c591 +exp u10 084e5be89c2ad03e356078ea4f287bab +exp2 u10 6e36db9ae2cf9eca82e3d9157c622351 +exp2 u35 6e36db9ae2cf9eca82e3d9157c622351 +exp10 u10 0cc08bc6a3d08d6e61450b5370c6161e +exp10 u35 6904d5509ca794747aa249c13886f90f +expm1 u10 cd3f0b8e86943d52c278394b60e2d22e +pow u10 7e19796027d7c1d1999be948f90e6181 +cbrt u10 5d8bf28ac74624594fd1be9217817690 +cbrt u10 3c896e03746bcf1b3f70182dfec3d93b +cbrt u35 fc7ee3e3e6c54365d708b752c242a947 +cbrt u35 2408714a56d74f8c82389ca6772cdbc1 +hypot u05 cc2f18e409e19a02cadf7b91fd869120 +hypot u35 be7bbd41dffd746b70261ee773cbd4b2 +asin u10 8a21b7c28cdaffc9d3e53f415367932e +asin u35 9c9e8107782898e9faed6924ad1b3cb1 +acos u10 28261e4eb8331865660c814676d5c6bc +acos u35 310911130bfc45b10dabe3a072939331 +atan u10 f931de72f2f6a7928f307a8a382ae255 +atan u10 453f9ef62f58f9829320baf482a1d457 +atan u35 6161b6189609f105b017d8768d0a41f1 +atan u35 6face71d8d93c69448d49ed6140e361d +atan2 u10 469babaeee9bd30e17af2f473b3ea500 +atan2 u35 6a3e764125aab2a0a13e7a0d9ec02f7f +sinh u10 61d459b1f368087f6f23ebf8e9f0ea01 +cosh u10 f77eb95f79e274c12b4e92dc0389259b +tanh u10 2bb9dd54ed0fa22bb5f3b6d557eb58a3 +asinh u10 01136e54e2a434839530dda54f33cfdb +acosh u10 2f3c28c9ee2eb2b3d5659c6cb2a58e3e +atanh u10 601a77ba8c1d5175f2808b48a41260c1 +lgamma u10 90cdc41063f4198c6ad592c0cdd0f5da +tgamma u10 cb9a93844ad1713d2ab92ff5b6398150 +erf u10 8a0bc2146a5c67b6bebc58f4b0076568 +erfc u15 3e247a54183eeddedc33e99c50118995 +fabs bef2f2ac8a4789357e580b4da4f9b9fe +copysign 3219022f267464e3704f90558e8df3bc +fmax 4e4f5220ccfef191864c316df0d18fc0 +fmin c0f8effb6c611e2b3b91b820ad943f62 +fdim e876d103931f18ceede5bfd7e3df7ab0 +fmod 618aa751e13012afdb41ec80dd35e6ba +remainder 8d692dbb44bbc9be5af0c0657d3008b8 +modf f03ce73cd4f9ea7f69c017f6e53355d5 +nextafter 9eba4e30d12d74dc4e8003fcff0f1582 +trunc 1bc7e909eba121dcef7f0e4046937ae5 +floor 2cff66b499dc8a30cec9467de659b774 +ceil b080e632dcb8f8134d8715752be12917 +round 8907e21687ca9c2a539297536e754950 +rint e49f837096bc661fe1c742801dd99a30 +sinf u35 f8f804eae1d9443103e81fec96293477 +sinf u10 3f12a7381f1cbb1830d92b4ec72d21fe +cosf u35 f2f3d1c9f090cde9c02439608dc7066e +cosf u10 dc35f27fae65f63f0aa6ad241f8b387b +tanf u35 68d42ad1fb412e6b8be3853461e61213 +tanf u10 97df301d4f59e67d5318b5356b703f06 +sincosf u10 a97124d810ec461c135dc4fb0c059b6f +sincosf u35 0cc521e52ae1227d311012c2919c1ff2 +sincospif u05 8b3762b67a661957c1414c351ec49034 +sincospif u35 8720757f221c00cc8de24b7dc4949144 +logf u10 c5a90119943acc4199e1cc7030b5def8 +logf u35 b6234302d534d6ccd48155dd6b9a4293 +log2f u10 ba8acae369bbb7b6404cccbc633fe25b +log2f u35 74174c90717c86642b71284452a8aef6 +log10f u10 7e235a82d960e4434575dd39648d8bb7 +log1pf u10 e53dbfa80bcc1a7bcfd21000e6950475 +expf u10 9597388315e4b3e89c4c97ce46374dcf +exp2f u10 42d66e5e4cb88feb29c5b36c632159a5 +exp2f u35 42d66e5e4cb88feb29c5b36c632159a5 +exp10f u10 954f0824b6d949d0da03b49950dc6642 +exp10f u35 6fb0e9a829e12a06679d379d05b53ede +expm1f u10 ebfd6498cb40f61b609882de8a7f3c74 +powf u10 2ed84af40d03e307a620365f172d010d +cbrtf u10 01c5cac23fe21638be1c3eab6e368fd6 +cbrtf u10 2a245b03f83e9114644d03b40dac707b +cbrtf u35 6c22a6dc132c5212250970f22f42256d +cbrtf u35 5ab696ae11f9637413d30e6496d5324b +hypotf u05 bc5971cbeebee27b4c0d91fbe3f6bf30 +hypotf u35 2a7cd97768287084b7fffc7e9fb39072 +asinf u10 e2e571a01984c4ffb3f6e38e0328d90e +asinf u35 70df2dfc3a3569868cce60c38e7b1962 +acosf u10 5180fde4b02a0ca4cd75f0a786a1bfeb +acosf u35 72b0e2f9791f90f1c43570b9e9ba893f +atanf u10 fa672e387a204055f735b7af98dd8a35 +atanf u10 d017670c13bc221b68bc9ee5f41c4b5e +atanf u35 f592e46eaa5d29583f86d3e336f20b6b +atanf u35 e7087fe40de46921826b373d10c40954 +atan2f u10 275b2fa8ee554c45551bb142db9f8197 +atan2f u35 44b187851195d24bab2561eb8f4ff5d0 +sinhf u10 45bc228a14c3e39eeb35e9764394a23e +coshf u10 838d441e85d415ef4fb1e5c5ea966a71 +tanhf u10 d19f254d41e8726c748df87b95bc9acd +asinhf u10 927eeb621a3e2d5039f1a07fcf150901 +acoshf u10 932520013273174fcabe2be4a55f919f +atanhf u10 164fd77b8372b8c131baaacab1c9e650 +lgammaf u10 3bf6d824175c4f4d86f3073064e41e84 +tgammaf u10 c3059747811d98846f74a63d3747ac3d +erff u10 f34af3814153de040b93e573ca7d21d8 +erfcf u15 687a9c577512d349ddbc0643013d2c56 +fabsf a3c72220bc0ade68fe22e0a15eb730d4 +copysignf 6b35517b8e1da78d9c9b52915d9a9b19 +fmaxf 9833a60a2080e8fd9ae8de32c758966f +fminf 2dcfa19e1f1ab4973a7dec9f2cc09fa0 +fdimf c5c0fe7b095eb8ccbb19fbf934a36b24 +fmodf 77aa84a9703e202a56e5f4609bd2482b +remainderf 5a453b1217c173e4dc0b0211066750be +modff 5fa4f044f20478216aa085a01b189697 +nextafterf 517c1c8f072e9024518d3d9ead98b85b +truncf 6937050850be63c44d4b7dbd666febe6 +floorf 9341be69ee345c8554bf3ab4e9316133 +ceilf c70874771cbe9741f1f05fedd4b629e9 +roundf 0cf52f6b8015099771e9a7dfa6b090bc +rintf bed68e788e2b11543c09c9d52198abf8 +fastsinf u3500 5c48081c74cd0316379b580b047dbfc2 +fastcosf u3500 6f73d116f109283e5632c31f5988f55b +fastpowf u3500 6dbb3110412df4fed5a71f50d40def89 diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-tester/iut.c b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-tester/iut.c new file mode 100644 index 00000000000..079bbc09d85 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-tester/iut.c @@ -0,0 +1,777 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include +#include + +#include + +#if defined(__MINGW32__) || defined(__MINGW64__) || defined(_MSC_VER) +#define STDIN_FILENO 0 +#else +#include +#include +#endif + +#include "sleef.h" +#include "testerutil.h" + +#define DORENAME +#include "rename.h" + +#define BUFSIZE 1024 + +int main(int argc, char **argv) { + char buf[BUFSIZE]; + + printf("3\n"); + fflush(stdout); + + for(;;) { + if (fgets(buf, BUFSIZE-1, stdin) == NULL) break; + + if (startsWith(buf, "sin ")) { + uint64_t u; + sscanf(buf, "sin %" PRIx64, &u); + u = d2u(xsin(u2d(u))); + printf("%" PRIx64 "\n", u); + } else if (startsWith(buf, "sin_u1 ")) { + uint64_t u; + sscanf(buf, "sin_u1 %" PRIx64, &u); + u = d2u(xsin_u1(u2d(u))); + printf("%" PRIx64 "\n", u); + } else if (startsWith(buf, "cos ")) { + uint64_t u; + sscanf(buf, "cos %" PRIx64, &u); + u = d2u(xcos(u2d(u))); + printf("%" PRIx64 "\n", u); + } else if (startsWith(buf, "cos_u1 ")) { + uint64_t u; + sscanf(buf, "cos_u1 %" PRIx64, &u); + u = d2u(xcos_u1(u2d(u))); + printf("%" PRIx64 "\n", u); + } else if (startsWith(buf, "sincos ")) { + uint64_t u; + sscanf(buf, "sincos %" PRIx64, &u); + Sleef_double2 x = xsincos(u2d(u)); + printf("%" PRIx64 " %" PRIx64 "\n", d2u(x.x), d2u(x.y)); + } else if (startsWith(buf, "sincos_u1 ")) { + uint64_t u; + sscanf(buf, "sincos_u1 %" PRIx64, &u); + Sleef_double2 x = xsincos_u1(u2d(u)); + printf("%" PRIx64 " %" PRIx64 "\n", d2u(x.x), d2u(x.y)); + } else if (startsWith(buf, "sincospi_u05 ")) { + uint64_t u; + sscanf(buf, "sincospi_u05 %" PRIx64, &u); + Sleef_double2 x = xsincospi_u05(u2d(u)); + printf("%" PRIx64 " %" PRIx64 "\n", d2u(x.x), d2u(x.y)); + } else if (startsWith(buf, "sincospi_u35 ")) { + uint64_t u; + sscanf(buf, "sincospi_u35 %" PRIx64, &u); + Sleef_double2 x = xsincospi_u35(u2d(u)); + printf("%" PRIx64 " %" PRIx64 "\n", d2u(x.x), d2u(x.y)); + } else if (startsWith(buf, "sinpi_u05 ")) { + uint64_t u; + sscanf(buf, "sinpi_u05 %" PRIx64, &u); + u = d2u(xsinpi_u05(u2d(u))); + printf("%" PRIx64 "\n", u); + } else if (startsWith(buf, "cospi_u05 ")) { + uint64_t u; + sscanf(buf, "cospi_u05 %" PRIx64, &u); + u = d2u(xcospi_u05(u2d(u))); + printf("%" PRIx64 "\n", u); + } else if (startsWith(buf, "tan ")) { + uint64_t u; + sscanf(buf, "tan %" PRIx64, &u); + u = d2u(xtan(u2d(u))); + printf("%" PRIx64 "\n", u); + } else if (startsWith(buf, "tan_u1 ")) { + uint64_t u; + sscanf(buf, "tan_u1 %" PRIx64, &u); + u = d2u(xtan_u1(u2d(u))); + printf("%" PRIx64 "\n", u); + } else if (startsWith(buf, "asin ")) { + uint64_t u; + sscanf(buf, "asin %" PRIx64, &u); + u = d2u(xasin(u2d(u))); + printf("%" PRIx64 "\n", u); + } else if (startsWith(buf, "acos ")) { + uint64_t u; + sscanf(buf, "acos %" PRIx64, &u); + u = d2u(xacos(u2d(u))); + printf("%" PRIx64 "\n", u); + } else if (startsWith(buf, "atan ")) { + uint64_t u; + sscanf(buf, "atan %" PRIx64, &u); + u = d2u(xatan(u2d(u))); + printf("%" PRIx64 "\n", u); + } else if (startsWith(buf, "log ")) { + uint64_t u; + sscanf(buf, "log %" PRIx64, &u); + u = d2u(xlog(u2d(u))); + printf("%" PRIx64 "\n", u); + } else if (startsWith(buf, "exp ")) { + uint64_t u; + sscanf(buf, "exp %" PRIx64, &u); + u = d2u(xexp(u2d(u))); + printf("%" PRIx64 "\n", u); + } else if (startsWith(buf, "atan2 ")) { + uint64_t u, v; + sscanf(buf, "atan2 %" PRIx64 " %" PRIx64, &u, &v); + u = d2u(xatan2(u2d(u), u2d(v))); + printf("%" PRIx64 "\n", u); + } else if (startsWith(buf, "asin_u1 ")) { + uint64_t u; + sscanf(buf, "asin_u1 %" PRIx64, &u); + u = d2u(xasin_u1(u2d(u))); + printf("%" PRIx64 "\n", u); + } else if (startsWith(buf, "acos_u1 ")) { + uint64_t u; + sscanf(buf, "acos_u1 %" PRIx64, &u); + u = d2u(xacos_u1(u2d(u))); + printf("%" PRIx64 "\n", u); + } else if (startsWith(buf, "atan_u1 ")) { + uint64_t u; + sscanf(buf, "atan_u1 %" PRIx64, &u); + u = d2u(xatan_u1(u2d(u))); + printf("%" PRIx64 "\n", u); + } else if (startsWith(buf, "atan2_u1 ")) { + uint64_t u, v; + sscanf(buf, "atan2_u1 %" PRIx64 " %" PRIx64, &u, &v); + u = d2u(xatan2_u1(u2d(u), u2d(v))); + printf("%" PRIx64 "\n", u); + } else if (startsWith(buf, "log_u1 ")) { + uint64_t u; + sscanf(buf, "log_u1 %" PRIx64, &u); + u = d2u(xlog_u1(u2d(u))); + printf("%" PRIx64 "\n", u); + } else if (startsWith(buf, "pow ")) { + uint64_t u, v; + sscanf(buf, "pow %" PRIx64 " %" PRIx64, &u, &v); + u = d2u(xpow(u2d(u), u2d(v))); + printf("%" PRIx64 "\n", u); + } else if (startsWith(buf, "sinh ")) { + uint64_t u; + sscanf(buf, "sinh %" PRIx64, &u); + u = d2u(xsinh(u2d(u))); + printf("%" PRIx64 "\n", u); + } else if (startsWith(buf, "cosh ")) { + uint64_t u; + sscanf(buf, "cosh %" PRIx64, &u); + u = d2u(xcosh(u2d(u))); + printf("%" PRIx64 "\n", u); + } else if (startsWith(buf, "tanh ")) { + uint64_t u; + sscanf(buf, "tanh %" PRIx64, &u); + u = d2u(xtanh(u2d(u))); + printf("%" PRIx64 "\n", u); + } else if (startsWith(buf, "sinh_u35 ")) { + uint64_t u; + sscanf(buf, "sinh_u35 %" PRIx64, &u); + u = d2u(xsinh_u35(u2d(u))); + printf("%" PRIx64 "\n", u); + } else if (startsWith(buf, "cosh_u35 ")) { + uint64_t u; + sscanf(buf, "cosh_u35 %" PRIx64, &u); + u = d2u(xcosh_u35(u2d(u))); + printf("%" PRIx64 "\n", u); + } else if (startsWith(buf, "tanh_u35 ")) { + uint64_t u; + sscanf(buf, "tanh_u35 %" PRIx64, &u); + u = d2u(xtanh_u35(u2d(u))); + printf("%" PRIx64 "\n", u); + } else if (startsWith(buf, "asinh ")) { + uint64_t u; + sscanf(buf, "asinh %" PRIx64, &u); + u = d2u(xasinh(u2d(u))); + printf("%" PRIx64 "\n", u); + } else if (startsWith(buf, "acosh ")) { + uint64_t u; + sscanf(buf, "acosh %" PRIx64, &u); + u = d2u(xacosh(u2d(u))); + printf("%" PRIx64 "\n", u); + } else if (startsWith(buf, "atanh ")) { + uint64_t u; + sscanf(buf, "atanh %" PRIx64, &u); + u = d2u(xatanh(u2d(u))); + printf("%" PRIx64 "\n", u); + } else if (startsWith(buf, "fma ")) { + uint64_t u, v, w; + sscanf(buf, "fma %" PRIx64 " %" PRIx64 " %" PRIx64, &u, &v, &w); + u = d2u(xfma(u2d(u), u2d(v), u2d(w))); + printf("%" PRIx64 "\n", u); + } else if (startsWith(buf, "sqrt ")) { + uint64_t u; + sscanf(buf, "sqrt %" PRIx64, &u); + u = d2u(xsqrt(u2d(u))); + printf("%" PRIx64 "\n", u); + } else if (startsWith(buf, "sqrt_u05 ")) { + uint64_t u; + sscanf(buf, "sqrt_u05 %" PRIx64, &u); + u = d2u(xsqrt_u05(u2d(u))); + printf("%" PRIx64 "\n", u); + } else if (startsWith(buf, "sqrt_u35 ")) { + uint64_t u; + sscanf(buf, "sqrt_u35 %" PRIx64, &u); + u = d2u(xsqrt_u35(u2d(u))); + printf("%" PRIx64 "\n", u); + } else if (startsWith(buf, "cbrt ")) { + uint64_t u; + sscanf(buf, "cbrt %" PRIx64, &u); + u = d2u(xcbrt(u2d(u))); + printf("%" PRIx64 "\n", u); + } else if (startsWith(buf, "cbrt_u1 ")) { + uint64_t u; + sscanf(buf, "cbrt_u1 %" PRIx64, &u); + u = d2u(xcbrt_u1(u2d(u))); + printf("%" PRIx64 "\n", u); + } else if (startsWith(buf, "exp2 ")) { + uint64_t u; + sscanf(buf, "exp2 %" PRIx64, &u); + u = d2u(xexp2(u2d(u))); + printf("%" PRIx64 "\n", u); + } else if (startsWith(buf, "exp2_u35 ")) { + uint64_t u; + sscanf(buf, "exp2_u35 %" PRIx64, &u); + u = d2u(xexp2_u35(u2d(u))); + printf("%" PRIx64 "\n", u); + } else if (startsWith(buf, "exp10 ")) { + uint64_t u; + sscanf(buf, "exp10 %" PRIx64, &u); + u = d2u(xexp10(u2d(u))); + printf("%" PRIx64 "\n", u); + } else if (startsWith(buf, "exp10_u35 ")) { + uint64_t u; + sscanf(buf, "exp10_u35 %" PRIx64, &u); + u = d2u(xexp10_u35(u2d(u))); + printf("%" PRIx64 "\n", u); + } else if (startsWith(buf, "expm1 ")) { + uint64_t u; + sscanf(buf, "expm1 %" PRIx64, &u); + u = d2u(xexpm1(u2d(u))); + printf("%" PRIx64 "\n", u); + } else if (startsWith(buf, "log10 ")) { + uint64_t u; + sscanf(buf, "log10 %" PRIx64, &u); + u = d2u(xlog10(u2d(u))); + printf("%" PRIx64 "\n", u); + } else if (startsWith(buf, "log2 ")) { + uint64_t u; + sscanf(buf, "log2 %" PRIx64, &u); + u = d2u(xlog2(u2d(u))); + printf("%" PRIx64 "\n", u); + } else if (startsWith(buf, "log2_u35 ")) { + uint64_t u; + sscanf(buf, "log2_u35 %" PRIx64, &u); + u = d2u(xlog2_u35(u2d(u))); + printf("%" PRIx64 "\n", u); + } else if (startsWith(buf, "log1p ")) { + uint64_t u; + sscanf(buf, "log1p %" PRIx64, &u); + u = d2u(xlog1p(u2d(u))); + printf("%" PRIx64 "\n", u); + } else if (startsWith(buf, "ldexp ")) { + uint64_t u, v; + sscanf(buf, "ldexp %" PRIx64 " %" PRIx64, &u, &v); + u = d2u(xldexp(u2d(u), (int)u2d(v))); + printf("%" PRIx64 "\n", u); + } + + else if (startsWith(buf, "hypot_u05 ")) { + uint64_t u, v; + sscanf(buf, "hypot_u05 %" PRIx64 " %" PRIx64, &u, &v); + u = d2u(xhypot_u05(u2d(u), u2d(v))); + printf("%" PRIx64 "\n", u); + } else if (startsWith(buf, "hypot_u35 ")) { + uint64_t u, v; + sscanf(buf, "hypot_u35 %" PRIx64 " %" PRIx64, &u, &v); + u = d2u(xhypot_u35(u2d(u), u2d(v))); + printf("%" PRIx64 "\n", u); + } else if (startsWith(buf, "copysign ")) { + uint64_t u, v; + sscanf(buf, "copysign %" PRIx64 " %" PRIx64, &u, &v); + u = d2u(xcopysign(u2d(u), u2d(v))); + printf("%" PRIx64 "\n", u); + } else if (startsWith(buf, "fmax ")) { + uint64_t u, v; + sscanf(buf, "fmax %" PRIx64 " %" PRIx64, &u, &v); + u = d2u(xfmax(u2d(u), u2d(v))); + printf("%" PRIx64 "\n", u); + } else if (startsWith(buf, "fmin ")) { + uint64_t u, v; + sscanf(buf, "fmin %" PRIx64 " %" PRIx64, &u, &v); + u = d2u(xfmin(u2d(u), u2d(v))); + printf("%" PRIx64 "\n", u); + } else if (startsWith(buf, "fdim ")) { + uint64_t u, v; + sscanf(buf, "fdim %" PRIx64 " %" PRIx64, &u, &v); + u = d2u(xfdim(u2d(u), u2d(v))); + printf("%" PRIx64 "\n", u); + } else if (startsWith(buf, "nextafter ")) { + uint64_t u, v; + sscanf(buf, "nextafter %" PRIx64 " %" PRIx64, &u, &v); + u = d2u(xnextafter(u2d(u), u2d(v))); + printf("%" PRIx64 "\n", u); + } else if (startsWith(buf, "fmod ")) { + uint64_t u, v; + sscanf(buf, "fmod %" PRIx64 " %" PRIx64, &u, &v); + u = d2u(xfmod(u2d(u), u2d(v))); + printf("%" PRIx64 "\n", u); + } else if (startsWith(buf, "remainder ")) { + uint64_t u, v; + sscanf(buf, "remainder %" PRIx64 " %" PRIx64, &u, &v); + u = d2u(xremainder(u2d(u), u2d(v))); + printf("%" PRIx64 "\n", u); + } else if (startsWith(buf, "fabs ")) { + uint64_t u; + sscanf(buf, "fabs %" PRIx64, &u); + u = d2u(xfabs(u2d(u))); + printf("%" PRIx64 "\n", u); + } else if (startsWith(buf, "trunc ")) { + uint64_t u; + sscanf(buf, "trunc %" PRIx64, &u); + u = d2u(xtrunc(u2d(u))); + printf("%" PRIx64 "\n", u); + } else if (startsWith(buf, "floor ")) { + uint64_t u; + sscanf(buf, "floor %" PRIx64, &u); + u = d2u(xfloor(u2d(u))); + printf("%" PRIx64 "\n", u); + } else if (startsWith(buf, "ceil ")) { + uint64_t u; + sscanf(buf, "ceil %" PRIx64, &u); + u = d2u(xceil(u2d(u))); + printf("%" PRIx64 "\n", u); + } else if (startsWith(buf, "round ")) { + uint64_t u; + sscanf(buf, "round %" PRIx64, &u); + u = d2u(xround(u2d(u))); + printf("%" PRIx64 "\n", u); + } else if (startsWith(buf, "rint ")) { + uint64_t u; + sscanf(buf, "rint %" PRIx64, &u); + u = d2u(xrint(u2d(u))); + printf("%" PRIx64 "\n", u); + } else if (startsWith(buf, "frfrexp ")) { + uint64_t u; + sscanf(buf, "frfrexp %" PRIx64, &u); + u = d2u(xfrfrexp(u2d(u))); + printf("%" PRIx64 "\n", u); + } else if (startsWith(buf, "modf ")) { + uint64_t u; + sscanf(buf, "modf %" PRIx64, &u); + Sleef_double2 x = xmodf(u2d(u)); + printf("%" PRIx64 " %" PRIx64 "\n", d2u(x.x), d2u(x.y)); + } else if (startsWith(buf, "tgamma_u1 ")) { + uint64_t u; + sscanf(buf, "tgamma_u1 %" PRIx64, &u); + u = d2u(xtgamma_u1(u2d(u))); + printf("%" PRIx64 "\n", u); + } else if (startsWith(buf, "lgamma_u1 ")) { + uint64_t u; + sscanf(buf, "lgamma_u1 %" PRIx64, &u); + u = d2u(xlgamma_u1(u2d(u))); + printf("%" PRIx64 "\n", u); + } else if (startsWith(buf, "erf_u1 ")) { + uint64_t u; + sscanf(buf, "erf_u1 %" PRIx64, &u); + u = d2u(xerf_u1(u2d(u))); + printf("%" PRIx64 "\n", u); + } else if (startsWith(buf, "erfc_u15 ")) { + uint64_t u; + sscanf(buf, "erfc_u15 %" PRIx64, &u); + u = d2u(xerfc_u15(u2d(u))); + printf("%" PRIx64 "\n", u); + } + + else if (startsWith(buf, "sinf ")) { + uint32_t u; + sscanf(buf, "sinf %x", &u); + u = f2u(xsinf(u2f(u))); + printf("%x\n", u); + } else if (startsWith(buf, "cosf ")) { + uint32_t u; + sscanf(buf, "cosf %x", &u); + u = f2u(xcosf(u2f(u))); + printf("%x\n", u); + } else if (startsWith(buf, "sincosf ")) { + uint32_t u; + sscanf(buf, "sincosf %x", &u); + Sleef_float2 x = xsincosf(u2f(u)); + printf("%x %x\n", f2u(x.x), f2u(x.y)); + } else if (startsWith(buf, "tanf ")) { + uint32_t u; + sscanf(buf, "tanf %x", &u); + u = f2u(xtanf(u2f(u))); + printf("%x\n", u); + } else if (startsWith(buf, "asinf ")) { + uint32_t u; + sscanf(buf, "asinf %x", &u); + u = f2u(xasinf(u2f(u))); + printf("%x\n", u); + } else if (startsWith(buf, "acosf ")) { + uint32_t u; + sscanf(buf, "acosf %x", &u); + u = f2u(xacosf(u2f(u))); + printf("%x\n", u); + } else if (startsWith(buf, "atanf ")) { + uint32_t u; + sscanf(buf, "atanf %x", &u); + u = f2u(xatanf(u2f(u))); + printf("%x\n", u); + } else if (startsWith(buf, "atan2f ")) { + uint32_t u, v; + sscanf(buf, "atan2f %x %x", &u, &v); + u = f2u(xatan2f(u2f(u), u2f(v))); + printf("%x\n", u); + } else if (startsWith(buf, "logf ")) { + uint32_t u; + sscanf(buf, "logf %x", &u); + u = f2u(xlogf(u2f(u))); + printf("%x\n", u); + } else if (startsWith(buf, "expf ")) { + uint32_t u; + sscanf(buf, "expf %x", &u); + u = f2u(xexpf(u2f(u))); + printf("%x\n", u); + } else if (startsWith(buf, "cbrtf ")) { + uint32_t u; + sscanf(buf, "cbrtf %x", &u); + u = f2u(xcbrtf(u2f(u))); + printf("%x\n", u); + } else if (startsWith(buf, "sqrtf ")) { + uint32_t u; + sscanf(buf, "sqrtf %x", &u); + u = f2u(xsqrtf(u2f(u))); + printf("%x\n", u); + } else if (startsWith(buf, "sqrtf_u05 ")) { + uint32_t u; + sscanf(buf, "sqrtf_u05 %x", &u); + u = f2u(xsqrtf_u05(u2f(u))); + printf("%x\n", u); + } else if (startsWith(buf, "sqrtf_u35 ")) { + uint32_t u; + sscanf(buf, "sqrtf_u35 %x", &u); + u = f2u(xsqrtf_u35(u2f(u))); + printf("%x\n", u); + } else if (startsWith(buf, "ldexpf ")) { + uint32_t u, v; + sscanf(buf, "ldexpf %x %x", &u, &v); + u = f2u(xldexpf(u2f(u), (int)u2f(v))); + printf("%x\n", u); + } else if (startsWith(buf, "powf ")) { + uint32_t u, v; + sscanf(buf, "powf %x %x", &u, &v); + u = f2u(xpowf(u2f(u), u2f(v))); + printf("%x\n", u); + } else if (startsWith(buf, "fastpowf_u3500 ")) { + uint32_t u, v; + sscanf(buf, "fastpowf_u3500 %x %x", &u, &v); + u = f2u(xfastpowf_u3500(u2f(u), u2f(v))); + printf("%x\n", u); + } else if (startsWith(buf, "sinhf ")) { + uint32_t u; + sscanf(buf, "sinhf %x", &u); + u = f2u(xsinhf(u2f(u))); + printf("%x\n", u); + } else if (startsWith(buf, "coshf ")) { + uint32_t u; + sscanf(buf, "coshf %x", &u); + u = f2u(xcoshf(u2f(u))); + printf("%x\n", u); + } else if (startsWith(buf, "tanhf ")) { + uint32_t u; + sscanf(buf, "tanhf %x", &u); + u = f2u(xtanhf(u2f(u))); + printf("%x\n", u); + } else if (startsWith(buf, "sinhf_u35 ")) { + uint32_t u; + sscanf(buf, "sinhf_u35 %x", &u); + u = f2u(xsinhf_u35(u2f(u))); + printf("%x\n", u); + } else if (startsWith(buf, "coshf_u35 ")) { + uint32_t u; + sscanf(buf, "coshf_u35 %x", &u); + u = f2u(xcoshf_u35(u2f(u))); + printf("%x\n", u); + } else if (startsWith(buf, "tanhf_u35 ")) { + uint32_t u; + sscanf(buf, "tanhf_u35 %x", &u); + u = f2u(xtanhf_u35(u2f(u))); + printf("%x\n", u); + } else if (startsWith(buf, "asinhf ")) { + uint32_t u; + sscanf(buf, "asinhf %x", &u); + u = f2u(xasinhf(u2f(u))); + printf("%x\n", u); + } else if (startsWith(buf, "acoshf ")) { + uint32_t u; + sscanf(buf, "acoshf %x", &u); + u = f2u(xacoshf(u2f(u))); + printf("%x\n", u); + } else if (startsWith(buf, "atanhf ")) { + uint32_t u; + sscanf(buf, "atanhf %x", &u); + u = f2u(xatanhf(u2f(u))); + printf("%x\n", u); + } else if (startsWith(buf, "exp2f ")) { + uint32_t u; + sscanf(buf, "exp2f %x", &u); + u = f2u(xexp2f(u2f(u))); + printf("%x\n", u); + } else if (startsWith(buf, "exp10f ")) { + uint32_t u; + sscanf(buf, "exp10f %x", &u); + u = f2u(xexp10f(u2f(u))); + printf("%x\n", u); + } else if (startsWith(buf, "exp2f_u35 ")) { + uint32_t u; + sscanf(buf, "exp2f_u35 %x", &u); + u = f2u(xexp2f_u35(u2f(u))); + printf("%x\n", u); + } else if (startsWith(buf, "exp10f_u35 ")) { + uint32_t u; + sscanf(buf, "exp10f_u35 %x", &u); + u = f2u(xexp10f_u35(u2f(u))); + printf("%x\n", u); + } else if (startsWith(buf, "expm1f ")) { + uint32_t u; + sscanf(buf, "expm1f %x", &u); + u = f2u(xexpm1f(u2f(u))); + printf("%x\n", u); + } else if (startsWith(buf, "log10f ")) { + uint32_t u; + sscanf(buf, "log10f %x", &u); + u = f2u(xlog10f(u2f(u))); + printf("%x\n", u); + } else if (startsWith(buf, "log2f ")) { + uint32_t u; + sscanf(buf, "log2f %x", &u); + u = f2u(xlog2f(u2f(u))); + printf("%x\n", u); + } else if (startsWith(buf, "log2f_u35 ")) { + uint32_t u; + sscanf(buf, "log2f_u35 %x", &u); + u = f2u(xlog2f_u35(u2f(u))); + printf("%x\n", u); + } else if (startsWith(buf, "log1pf ")) { + uint32_t u; + sscanf(buf, "log1pf %x", &u); + u = f2u(xlog1pf(u2f(u))); + printf("%x\n", u); + } else if (startsWith(buf, "sinf_u1 ")) { + uint32_t u; + sscanf(buf, "sinf_u1 %x", &u); + u = f2u(xsinf_u1(u2f(u))); + printf("%x\n", u); + } else if (startsWith(buf, "cosf_u1 ")) { + uint32_t u; + sscanf(buf, "cosf_u1 %x", &u); + u = f2u(xcosf_u1(u2f(u))); + printf("%x\n", u); + } else if (startsWith(buf, "sincosf_u1 ")) { + uint32_t u; + sscanf(buf, "sincosf_u1 %x", &u); + Sleef_float2 x = xsincosf_u1(u2f(u)); + printf("%x %x\n", f2u(x.x), f2u(x.y)); + } else if (startsWith(buf, "sincospif_u05 ")) { + uint32_t u; + sscanf(buf, "sincospif_u05 %x", &u); + Sleef_float2 x = xsincospif_u05(u2f(u)); + printf("%x %x\n", f2u(x.x), f2u(x.y)); + } else if (startsWith(buf, "sincospif_u35 ")) { + uint32_t u; + sscanf(buf, "sincospif_u35 %x", &u); + Sleef_float2 x = xsincospif_u35(u2f(u)); + printf("%x %x\n", f2u(x.x), f2u(x.y)); + } else if (startsWith(buf, "sinpif_u05 ")) { + uint32_t u; + sscanf(buf, "sinpif_u05 %x", &u); + u = f2u(xsinpif_u05(u2f(u))); + printf("%x\n", u); + } else if (startsWith(buf, "cospif_u05 ")) { + uint32_t u; + sscanf(buf, "cospif_u05 %x", &u); + u = f2u(xcospif_u05(u2f(u))); + printf("%x\n", u); + } else if (startsWith(buf, "fastsinf_u3500 ")) { + uint32_t u; + sscanf(buf, "fastsinf_u3500 %x", &u); + u = f2u(xfastsinf_u3500(u2f(u))); + printf("%x\n", u); + } else if (startsWith(buf, "fastcosf_u3500 ")) { + uint32_t u; + sscanf(buf, "fastcosf_u3500 %x", &u); + u = f2u(xfastcosf_u3500(u2f(u))); + printf("%x\n", u); + } else if (startsWith(buf, "tanf_u1 ")) { + uint32_t u; + sscanf(buf, "tanf_u1 %x", &u); + u = f2u(xtanf_u1(u2f(u))); + printf("%x\n", u); + } else if (startsWith(buf, "asinf_u1 ")) { + uint32_t u; + sscanf(buf, "asinf_u1 %x", &u); + u = f2u(xasinf_u1(u2f(u))); + printf("%x\n", u); + } else if (startsWith(buf, "acosf_u1 ")) { + uint32_t u; + sscanf(buf, "acosf_u1 %x", &u); + u = f2u(xacosf_u1(u2f(u))); + printf("%x\n", u); + } else if (startsWith(buf, "atanf_u1 ")) { + uint32_t u; + sscanf(buf, "atanf_u1 %x", &u); + u = f2u(xatanf_u1(u2f(u))); + printf("%x\n", u); + } else if (startsWith(buf, "atan2f_u1 ")) { + uint32_t u, v; + sscanf(buf, "atan2f_u1 %x %x", &u, &v); + u = f2u(xatan2f_u1(u2f(u), u2f(v))); + printf("%x\n", u); + } else if (startsWith(buf, "logf_u1 ")) { + uint32_t u; + sscanf(buf, "logf_u1 %x", &u); + u = f2u(xlogf_u1(u2f(u))); + printf("%x\n", u); + } else if (startsWith(buf, "cbrtf_u1 ")) { + uint32_t u; + sscanf(buf, "cbrtf_u1 %x", &u); + u = f2u(xcbrtf_u1(u2f(u))); + printf("%x\n", u); + } else if (startsWith(buf, "ilogb ")) { + uint64_t u; + int i; + sscanf(buf, "ilogb %" PRIx64, &u); + i = xilogb(u2d(u)); + printf("%d\n", i); + } else if (startsWith(buf, "ilogbf ")) { + uint32_t u; + int i; + sscanf(buf, "ilogbf %x", &u); + i = xilogbf(u2f(u)); + printf("%d\n", i); + } + + else if (startsWith(buf, "hypotf_u05 ")) { + uint32_t u, v; + sscanf(buf, "hypotf_u05 %x %x", &u, &v); + u = f2u(xhypotf_u05(u2f(u), u2f(v))); + printf("%x\n", u); + } else if (startsWith(buf, "hypotf_u35 ")) { + uint32_t u, v; + sscanf(buf, "hypotf_u35 %x %x", &u, &v); + u = f2u(xhypotf_u35(u2f(u), u2f(v))); + printf("%x\n", u); + } else if (startsWith(buf, "copysignf ")) { + uint32_t u, v; + sscanf(buf, "copysignf %x %x", &u, &v); + u = f2u(xcopysignf(u2f(u), u2f(v))); + printf("%x\n", u); + } else if (startsWith(buf, "fmaxf ")) { + uint32_t u, v; + sscanf(buf, "fmaxf %x %x", &u, &v); + u = f2u(xfmaxf(u2f(u), u2f(v))); + printf("%x\n", u); + } else if (startsWith(buf, "fminf ")) { + uint32_t u, v; + sscanf(buf, "fminf %x %x", &u, &v); + u = f2u(xfminf(u2f(u), u2f(v))); + printf("%x\n", u); + } else if (startsWith(buf, "fdimf ")) { + uint32_t u, v; + sscanf(buf, "fdimf %x %x", &u, &v); + u = f2u(xfdimf(u2f(u), u2f(v))); + printf("%x\n", u); + } else if (startsWith(buf, "nextafterf ")) { + uint32_t u, v; + sscanf(buf, "nextafterf %x %x", &u, &v); + u = f2u(xnextafterf(u2f(u), u2f(v))); + printf("%x\n", u); + } else if (startsWith(buf, "fmodf ")) { + uint32_t u, v; + sscanf(buf, "fmodf %x %x", &u, &v); + u = f2u(xfmodf(u2f(u), u2f(v))); + printf("%x\n", u); + } else if (startsWith(buf, "remainderf ")) { + uint32_t u, v; + sscanf(buf, "remainderf %x %x", &u, &v); + u = f2u(xremainderf(u2f(u), u2f(v))); + printf("%x\n", u); + } else if (startsWith(buf, "fabsf ")) { + uint32_t u; + sscanf(buf, "fabsf %x", &u); + u = f2u(xfabsf(u2f(u))); + printf("%x\n", u); + } else if (startsWith(buf, "truncf ")) { + uint32_t u; + sscanf(buf, "truncf %x", &u); + u = f2u(xtruncf(u2f(u))); + printf("%x\n", u); + } else if (startsWith(buf, "floorf ")) { + uint32_t u; + sscanf(buf, "floorf %x", &u); + u = f2u(xfloorf(u2f(u))); + printf("%x\n", u); + } else if (startsWith(buf, "ceilf ")) { + uint32_t u; + sscanf(buf, "ceilf %x", &u); + u = f2u(xceilf(u2f(u))); + printf("%x\n", u); + } else if (startsWith(buf, "roundf ")) { + uint32_t u; + sscanf(buf, "roundf %x", &u); + u = f2u(xroundf(u2f(u))); + printf("%x\n", u); + } else if (startsWith(buf, "rintf ")) { + uint32_t u; + sscanf(buf, "rintf %x", &u); + u = f2u(xrintf(u2f(u))); + printf("%x\n", u); + } else if (startsWith(buf, "frfrexpf ")) { + uint32_t u; + sscanf(buf, "frfrexpf %x", &u); + u = f2u(xfrfrexpf(u2f(u))); + printf("%x\n", u); + } else if (startsWith(buf, "modff ")) { + uint32_t u; + sscanf(buf, "modff %x", &u); + Sleef_float2 x = xmodff(u2f(u)); + printf("%x %x\n", f2u(x.x), f2u(x.y)); + } else if (startsWith(buf, "tgammaf_u1 ")) { + uint32_t u; + sscanf(buf, "tgammaf_u1 %x", &u); + u = f2u(xtgammaf_u1(u2f(u))); + printf("%x\n", u); + } else if (startsWith(buf, "lgammaf_u1 ")) { + uint32_t u; + sscanf(buf, "lgammaf_u1 %x", &u); + u = f2u(xlgammaf_u1(u2f(u))); + printf("%x\n", u); + } else if (startsWith(buf, "erff_u1 ")) { + uint32_t u; + sscanf(buf, "erff_u1 %x", &u); + u = f2u(xerff_u1(u2f(u))); + printf("%x\n", u); + } else if (startsWith(buf, "erfcf_u15 ")) { + uint32_t u; + sscanf(buf, "erfcf_u15 %x", &u); + u = f2u(xerfcf_u15(u2f(u))); + printf("%x\n", u); + } + + else { + break; + } + + fflush(stdout); + } + + return 0; +} diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-tester/iutcuda.cu b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-tester/iutcuda.cu new file mode 100644 index 00000000000..fe58ba29997 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-tester/iutcuda.cu @@ -0,0 +1,546 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "sleefinline_purec_scalar.h" +#include "sleefinline_cuda.h" + +#define STDIN_FILENO 0 + +#define SIMD_SUFFIX _cuda_sleef +#define CONCAT_SIMD_SUFFIX_(keyword, suffix) keyword ## suffix +#define CONCAT_SIMD_SUFFIX(keyword, suffix) CONCAT_SIMD_SUFFIX_(keyword, suffix) + +#define vdouble2 CONCAT_SIMD_SUFFIX(vdouble2, SIMD_SUFFIX) +#define vfloat2 CONCAT_SIMD_SUFFIX(vfloat2, SIMD_SUFFIX) + +// + +static int startsWith(const char *str, const char *prefix) { + while(*prefix != '\0') if (*str++ != *prefix++) return 0; + return *prefix == '\0'; +} + +static double u2d(uint64_t u) { + union { + double f; + uint64_t i; + } tmp; + tmp.i = u; + return tmp.f; +} + +static uint64_t d2u(double d) { + union { + double f; + uint64_t i; + } tmp; + tmp.f = d; + return tmp.i; +} + +static float u2f(uint32_t u) { + union { + float f; + uint32_t i; + } tmp; + tmp.i = u; + return tmp.f; +} + +static uint32_t f2u(float d) { + union { + float f; + uint32_t i; + } tmp; + tmp.f = d; + return tmp.i; +} + +// + +__global__ void xsin(double *r, double *a0) { *r = Sleef_sind1_u35cuda(*a0); } +__global__ void xcos(double *r, double *a0) { *r = Sleef_cosd1_u35cuda(*a0); } +__global__ void xsincos(vdouble2 *r, double *a0) { *r = Sleef_sincosd1_u35cuda(*a0); } +__global__ void xtan(double *r, double *a0) { *r = Sleef_tand1_u35cuda(*a0); } +__global__ void xasin(double *r, double *a0) { *r = Sleef_asind1_u35cuda(*a0); } +__global__ void xacos(double *r, double *a0) { *r = Sleef_acosd1_u35cuda(*a0); } +__global__ void xatan(double *r, double *a0) { *r = Sleef_atand1_u35cuda(*a0); } +__global__ void xatan2(double *r, double *a0, double *a1) { *r = Sleef_atan2d1_u35cuda(*a0, *a1); } +__global__ void xlog(double *r, double *a0) { *r = Sleef_logd1_u35cuda(*a0); } +__global__ void xcbrt(double *r, double *a0) { *r = Sleef_cbrtd1_u35cuda(*a0); } +__global__ void xsin_u1(double *r, double *a0) { *r = Sleef_sind1_u10cuda(*a0); } +__global__ void xcos_u1(double *r, double *a0) { *r = Sleef_cosd1_u10cuda(*a0); } +__global__ void xsincos_u1(vdouble2 *r, double *a0) { *r = Sleef_sincosd1_u10cuda(*a0); } +__global__ void xtan_u1(double *r, double *a0) { *r = Sleef_tand1_u10cuda(*a0); } +__global__ void xasin_u1(double *r, double *a0) { *r = Sleef_asind1_u10cuda(*a0); } +__global__ void xacos_u1(double *r, double *a0) { *r = Sleef_acosd1_u10cuda(*a0); } +__global__ void xatan_u1(double *r, double *a0) { *r = Sleef_atand1_u10cuda(*a0); } +__global__ void xatan2_u1(double *r, double *a0, double *a1) { *r = Sleef_atan2d1_u10cuda(*a0, *a1); } +__global__ void xlog_u1(double *r, double *a0) { *r = Sleef_logd1_u10cuda(*a0); } +__global__ void xcbrt_u1(double *r, double *a0) { *r = Sleef_cbrtd1_u10cuda(*a0); } +__global__ void xexp(double *r, double *a0) { *r = Sleef_expd1_u10cuda(*a0); } +__global__ void xpow(double *r, double *a0, double *a1) { *r = Sleef_powd1_u10cuda(*a0, *a1); } +__global__ void xsinh(double *r, double *a0) { *r = Sleef_sinhd1_u10cuda(*a0); } +__global__ void xcosh(double *r, double *a0) { *r = Sleef_coshd1_u10cuda(*a0); } +__global__ void xtanh(double *r, double *a0) { *r = Sleef_tanhd1_u10cuda(*a0); } +__global__ void xsinh_u35(double *r, double *a0) { *r = Sleef_sinhd1_u35cuda(*a0); } +__global__ void xcosh_u35(double *r, double *a0) { *r = Sleef_coshd1_u35cuda(*a0); } +__global__ void xtanh_u35(double *r, double *a0) { *r = Sleef_tanhd1_u35cuda(*a0); } +__global__ void xasinh(double *r, double *a0) { *r = Sleef_asinhd1_u10cuda(*a0); } +__global__ void xacosh(double *r, double *a0) { *r = Sleef_acoshd1_u10cuda(*a0); } +__global__ void xatanh(double *r, double *a0) { *r = Sleef_atanhd1_u10cuda(*a0); } +__global__ void xexp2(double *r, double *a0) { *r = Sleef_exp2d1_u10cuda(*a0); } +__global__ void xexp2_u35(double *r, double *a0) { *r = Sleef_exp2d1_u35cuda(*a0); } +__global__ void xexp10(double *r, double *a0) { *r = Sleef_exp10d1_u10cuda(*a0); } +__global__ void xexp10_u35(double *r, double *a0) { *r = Sleef_exp10d1_u35cuda(*a0); } +__global__ void xexpm1(double *r, double *a0) { *r = Sleef_expm1d1_u10cuda(*a0); } +__global__ void xlog10(double *r, double *a0) { *r = Sleef_log10d1_u10cuda(*a0); } +__global__ void xlog2(double *r, double *a0) { *r = Sleef_log2d1_u10cuda(*a0); } +__global__ void xlog2_u35(double *r, double *a0) { *r = Sleef_log2d1_u35cuda(*a0); } +__global__ void xlog1p(double *r, double *a0) { *r = Sleef_log1pd1_u10cuda(*a0); } +__global__ void xsincospi_u05(vdouble2 *r, double *a0) { *r = Sleef_sincospid1_u05cuda(*a0); } +__global__ void xsincospi_u35(vdouble2 *r, double *a0) { *r = Sleef_sincospid1_u35cuda(*a0); } +__global__ void xsinpi_u05(double *r, double *a0) { *r = Sleef_sinpid1_u05cuda(*a0); } +__global__ void xcospi_u05(double *r, double *a0) { *r = Sleef_cospid1_u05cuda(*a0); } +__global__ void xldexp(double *r, double *a0, int *a1) { *r = Sleef_ldexpd1_cuda(*a0, *a1); } +__global__ void xilogb(int *r, double *a0) { *r = Sleef_ilogbd1_cuda(*a0); } +__global__ void xfma(double *r, double *a0, double *a1, double *a2) { *r = Sleef_fmad1_cuda(*a0, *a1, *a2); } +__global__ void xsqrt(double *r, double *a0) { *r = Sleef_sqrtd1_cuda(*a0); } +__global__ void xsqrt_u05(double *r, double *a0) { *r = Sleef_sqrtd1_u05cuda(*a0); } +__global__ void xsqrt_u35(double *r, double *a0) { *r = Sleef_sqrtd1_u35cuda(*a0); } +__global__ void xhypot_u05(double *r, double *a0, double *a1) { *r = Sleef_hypotd1_u05cuda(*a0, *a1); } +__global__ void xhypot_u35(double *r, double *a0, double *a1) { *r = Sleef_hypotd1_u35cuda(*a0, *a1); } +__global__ void xfabs(double *r, double *a0) { *r = Sleef_fabsd1_cuda(*a0); } +__global__ void xcopysign(double *r, double *a0, double *a1) { *r = Sleef_copysignd1_cuda(*a0, *a1); } +__global__ void xfmax(double *r, double *a0, double *a1) { *r = Sleef_fmaxd1_cuda(*a0, *a1); } +__global__ void xfmin(double *r, double *a0, double *a1) { *r = Sleef_fmind1_cuda(*a0, *a1); } +__global__ void xfdim(double *r, double *a0, double *a1) { *r = Sleef_fdimd1_cuda(*a0, *a1); } +__global__ void xtrunc(double *r, double *a0) { *r = Sleef_truncd1_cuda(*a0); } +__global__ void xfloor(double *r, double *a0) { *r = Sleef_floord1_cuda(*a0); } +__global__ void xceil(double *r, double *a0) { *r = Sleef_ceild1_cuda(*a0); } +__global__ void xround(double *r, double *a0) { *r = Sleef_roundd1_cuda(*a0); } +__global__ void xrint(double *r, double *a0) { *r = Sleef_rintd1_cuda(*a0); } +__global__ void xnextafter(double *r, double *a0, double *a1) { *r = Sleef_nextafterd1_cuda(*a0, *a1); } +__global__ void xfrfrexp(double *r, double *a0) { *r = Sleef_frfrexpd1_cuda(*a0); } +__global__ void xexpfrexp(int *r, double *a0) { *r = Sleef_expfrexpd1_cuda(*a0); } +__global__ void xfmod(double *r, double *a0, double *a1) { *r = Sleef_fmodd1_cuda(*a0, *a1); } +__global__ void xremainder(double *r, double *a0, double *a1) { *r = Sleef_remainderd1_cuda(*a0, *a1); } +__global__ void xmodf(vdouble2 *r, double *a0) { *r = Sleef_modfd1_cuda(*a0); } +__global__ void xlgamma_u1(double *r, double *a0) { *r = Sleef_lgammad1_u10cuda(*a0); } +__global__ void xtgamma_u1(double *r, double *a0) { *r = Sleef_tgammad1_u10cuda(*a0); } +__global__ void xerf_u1(double *r, double *a0) { *r = Sleef_erfd1_u10cuda(*a0); } +__global__ void xerfc_u15(double *r, double *a0) { *r = Sleef_erfcd1_u15cuda(*a0); } + +__global__ void xsinf(float *r, float *a0) { *r = Sleef_sinf1_u35cuda(*a0); } +__global__ void xcosf(float *r, float *a0) { *r = Sleef_cosf1_u35cuda(*a0); } +__global__ void xsincosf(vfloat2 *r, float *a0) { *r = Sleef_sincosf1_u35cuda(*a0); } +__global__ void xtanf(float *r, float *a0) { *r = Sleef_tanf1_u35cuda(*a0); } +__global__ void xasinf(float *r, float *a0) { *r = Sleef_asinf1_u35cuda(*a0); } +__global__ void xacosf(float *r, float *a0) { *r = Sleef_acosf1_u35cuda(*a0); } +__global__ void xatanf(float *r, float *a0) { *r = Sleef_atanf1_u35cuda(*a0); } +__global__ void xatan2f(float *r, float *a0, float *a1) { *r = Sleef_atan2f1_u35cuda(*a0, *a1); } +__global__ void xlogf(float *r, float *a0) { *r = Sleef_logf1_u35cuda(*a0); } +__global__ void xcbrtf(float *r, float *a0) { *r = Sleef_cbrtf1_u35cuda(*a0); } +__global__ void xsinf_u1(float *r, float *a0) { *r = Sleef_sinf1_u10cuda(*a0); } +__global__ void xcosf_u1(float *r, float *a0) { *r = Sleef_cosf1_u10cuda(*a0); } +__global__ void xsincosf_u1(vfloat2 *r, float *a0) { *r = Sleef_sincosf1_u10cuda(*a0); } +__global__ void xtanf_u1(float *r, float *a0) { *r = Sleef_tanf1_u10cuda(*a0); } +__global__ void xasinf_u1(float *r, float *a0) { *r = Sleef_asinf1_u10cuda(*a0); } +__global__ void xacosf_u1(float *r, float *a0) { *r = Sleef_acosf1_u10cuda(*a0); } +__global__ void xatanf_u1(float *r, float *a0) { *r = Sleef_atanf1_u10cuda(*a0); } +__global__ void xatan2f_u1(float *r, float *a0, float *a1) { *r = Sleef_atan2f1_u10cuda(*a0, *a1); } +__global__ void xlogf_u1(float *r, float *a0) { *r = Sleef_logf1_u10cuda(*a0); } +__global__ void xcbrtf_u1(float *r, float *a0) { *r = Sleef_cbrtf1_u10cuda(*a0); } +__global__ void xexpf(float *r, float *a0) { *r = Sleef_expf1_u10cuda(*a0); } +__global__ void xpowf(float *r, float *a0, float *a1) { *r = Sleef_powf1_u10cuda(*a0, *a1); } +__global__ void xsinhf(float *r, float *a0) { *r = Sleef_sinhf1_u10cuda(*a0); } +__global__ void xcoshf(float *r, float *a0) { *r = Sleef_coshf1_u10cuda(*a0); } +__global__ void xtanhf(float *r, float *a0) { *r = Sleef_tanhf1_u10cuda(*a0); } +__global__ void xsinhf_u35(float *r, float *a0) { *r = Sleef_sinhf1_u35cuda(*a0); } +__global__ void xcoshf_u35(float *r, float *a0) { *r = Sleef_coshf1_u35cuda(*a0); } +__global__ void xtanhf_u35(float *r, float *a0) { *r = Sleef_tanhf1_u35cuda(*a0); } +__global__ void xfastsinf_u3500(float *r, float *a0) { *r = Sleef_fastsinf1_u3500cuda(*a0); } +__global__ void xfastcosf_u3500(float *r, float *a0) { *r = Sleef_fastcosf1_u3500cuda(*a0); } +__global__ void xfastpowf_u3500(float *r, float *a0, float *a1) { *r = Sleef_fastpowf1_u3500cuda(*a0, *a1); } +__global__ void xasinhf(float *r, float *a0) { *r = Sleef_asinhf1_u10cuda(*a0); } +__global__ void xacoshf(float *r, float *a0) { *r = Sleef_acoshf1_u10cuda(*a0); } +__global__ void xatanhf(float *r, float *a0) { *r = Sleef_atanhf1_u10cuda(*a0); } +__global__ void xexp2f(float *r, float *a0) { *r = Sleef_exp2f1_u10cuda(*a0); } +__global__ void xexp2f_u35(float *r, float *a0) { *r = Sleef_exp2f1_u35cuda(*a0); } +__global__ void xexp10f(float *r, float *a0) { *r = Sleef_exp10f1_u10cuda(*a0); } +__global__ void xexp10f_u35(float *r, float *a0) { *r = Sleef_exp10f1_u35cuda(*a0); } +__global__ void xexpm1f(float *r, float *a0) { *r = Sleef_expm1f1_u10cuda(*a0); } +__global__ void xlog10f(float *r, float *a0) { *r = Sleef_log10f1_u10cuda(*a0); } +__global__ void xlog2f(float *r, float *a0) { *r = Sleef_log2f1_u10cuda(*a0); } +__global__ void xlog2f_u35(float *r, float *a0) { *r = Sleef_log2f1_u35cuda(*a0); } +__global__ void xlog1pf(float *r, float *a0) { *r = Sleef_log1pf1_u10cuda(*a0); } +__global__ void xsincospif_u05(vfloat2 *r, float *a0) { *r = Sleef_sincospif1_u05cuda(*a0); } +__global__ void xsincospif_u35(vfloat2 *r, float *a0) { *r = Sleef_sincospif1_u35cuda(*a0); } +__global__ void xsinpif_u05(float *r, float *a0) { *r = Sleef_sinpif1_u05cuda(*a0); } +__global__ void xcospif_u05(float *r, float *a0) { *r = Sleef_cospif1_u05cuda(*a0); } +__global__ void xldexpf(float *r, float *a0, int *a1) { *r = Sleef_ldexpf1_cuda(*a0, *a1); } +__global__ void xilogbf(int *r, float *a0) { *r = Sleef_ilogbf1_cuda(*a0); } +__global__ void xfmaf(float *r, float *a0, float *a1, float *a2) { *r = Sleef_fmaf1_cuda(*a0, *a1, *a2); } +__global__ void xsqrtf(float *r, float *a0) { *r = Sleef_sqrtf1_cuda(*a0); } +__global__ void xsqrtf_u05(float *r, float *a0) { *r = Sleef_sqrtf1_u05cuda(*a0); } +__global__ void xsqrtf_u35(float *r, float *a0) { *r = Sleef_sqrtf1_u35cuda(*a0); } +__global__ void xhypotf_u05(float *r, float *a0, float *a1) { *r = Sleef_hypotf1_u05cuda(*a0, *a1); } +__global__ void xhypotf_u35(float *r, float *a0, float *a1) { *r = Sleef_hypotf1_u35cuda(*a0, *a1); } +__global__ void xfabsf(float *r, float *a0) { *r = Sleef_fabsf1_cuda(*a0); } +__global__ void xcopysignf(float *r, float *a0, float *a1) { *r = Sleef_copysignf1_cuda(*a0, *a1); } +__global__ void xfmaxf(float *r, float *a0, float *a1) { *r = Sleef_fmaxf1_cuda(*a0, *a1); } +__global__ void xfminf(float *r, float *a0, float *a1) { *r = Sleef_fminf1_cuda(*a0, *a1); } +__global__ void xfdimf(float *r, float *a0, float *a1) { *r = Sleef_fdimf1_cuda(*a0, *a1); } +__global__ void xtruncf(float *r, float *a0) { *r = Sleef_truncf1_cuda(*a0); } +__global__ void xfloorf(float *r, float *a0) { *r = Sleef_floorf1_cuda(*a0); } +__global__ void xceilf(float *r, float *a0) { *r = Sleef_ceilf1_cuda(*a0); } +__global__ void xroundf(float *r, float *a0) { *r = Sleef_roundf1_cuda(*a0); } +__global__ void xrintf(float *r, float *a0) { *r = Sleef_rintf1_cuda(*a0); } +__global__ void xnextafterf(float *r, float *a0, float *a1) { *r = Sleef_nextafterf1_cuda(*a0, *a1); } +__global__ void xfrfrexpf(float *r, float *a0) { *r = Sleef_frfrexpf1_cuda(*a0); } +__global__ void xexpfrexpf(float *r, float *a0) { *r = Sleef_expfrexpf1_cuda(*a0); } +__global__ void xfmodf(float *r, float *a0, float *a1) { *r = Sleef_fmodf1_cuda(*a0, *a1); } +__global__ void xremainderf(float *r, float *a0, float *a1) { *r = Sleef_remainderf1_cuda(*a0, *a1); } +__global__ void xmodff(vfloat2 *r, float *a0) { *r = Sleef_modff1_cuda(*a0); } +__global__ void xlgammaf_u1(float *r, float *a0) { *r = Sleef_lgammaf1_u10cuda(*a0); } +__global__ void xtgammaf_u1(float *r, float *a0) { *r = Sleef_tgammaf1_u10cuda(*a0); } +__global__ void xerff_u1(float *r, float *a0) { *r = Sleef_erff1_u10cuda(*a0); } +__global__ void xerfcf_u15(float *r, float *a0) { *r = Sleef_erfcf1_u15cuda(*a0); } + +// + +#define func_d_d(funcStr, funcName) { \ + while (startsWith(buf, funcStr " ")) { \ + uint64_t u; \ + sscanf(buf, funcStr " %" PRIx64, &u); \ + *a0 = u2d(u); \ + funcName<<<1, 1>>>(r, a0); \ + cudaDeviceSynchronize(); \ + printf("%" PRIx64 "\n", d2u(*r)); \ + fflush(stdout); \ + if (fgets(buf, BUFSIZE-1, stdin) == NULL) break; \ + } \ + } + +#define func_d2_d(funcStr, funcName) { \ + while (startsWith(buf, funcStr " ")) { \ + uint64_t u; \ + sscanf(buf, funcStr " %" PRIx64, &u); \ + *a0 = u2d(u); \ + funcName<<<1, 1>>>(r2, a0); \ + cudaDeviceSynchronize(); \ + printf("%" PRIx64 " %" PRIx64 "\n", d2u(r2->x), d2u(r2->y)); \ + fflush(stdout); \ + if (fgets(buf, BUFSIZE-1, stdin) == NULL) break; \ + } \ + } + +#define func_d_d_d(funcStr, funcName) { \ + while (startsWith(buf, funcStr " ")) { \ + uint64_t u, v; \ + sscanf(buf, funcStr " %" PRIx64 " %" PRIx64, &u, &v); \ + *a0 = u2d(u); \ + *a1 = u2d(v); \ + funcName<<<1, 1>>>(r, a0, a1); \ + cudaDeviceSynchronize(); \ + printf("%" PRIx64 "\n", d2u(*r)); \ + fflush(stdout); \ + if (fgets(buf, BUFSIZE-1, stdin) == NULL) break; \ + } \ + } + +#define func_d_d_i(funcStr, funcName) { \ + while (startsWith(buf, funcStr " ")) { \ + uint64_t u, v; \ + sscanf(buf, funcStr " %" PRIx64 " %" PRIx64, &u, &v); \ + *a0 = u2d(u); \ + *i0 = (int)u2d(v); \ + funcName<<<1, 1>>>(r, a0, i0); \ + cudaDeviceSynchronize(); \ + printf("%" PRIx64 "\n", d2u(*r)); \ + fflush(stdout); \ + if (fgets(buf, BUFSIZE-1, stdin) == NULL) break; \ + } \ + } + +#define func_i_d(funcStr, funcName) { \ + while (startsWith(buf, funcStr " ")) { \ + uint64_t u; \ + sscanf(buf, funcStr " %" PRIx64, &u); \ + *a0 = u2d(u); \ + funcName<<<1, 1>>>(i0, a0); \ + cudaDeviceSynchronize(); \ + printf("%d\n", *i0); \ + fflush(stdout); \ + if (fgets(buf, BUFSIZE-1, stdin) == NULL) break; \ + } \ + } + +// + +#define func_f_f(funcStr, funcName) { \ + while (startsWith(buf, funcStr " ")) { \ + uint32_t u; \ + sscanf(buf, funcStr " %x", &u); \ + *b0 = u2f(u); \ + funcName<<<1, 1>>>(s, b0); \ + cudaDeviceSynchronize(); \ + printf("%x\n", f2u(*s)); \ + fflush(stdout); \ + if (fgets(buf, BUFSIZE-1, stdin) == NULL) break; \ + } \ + } + +#define func_f2_f(funcStr, funcName) { \ + while (startsWith(buf, funcStr " ")) { \ + uint32_t u; \ + sscanf(buf, funcStr " %x", &u); \ + *b0 = u2f(u); \ + funcName<<<1, 1>>>(s2, b0); \ + cudaDeviceSynchronize(); \ + printf("%x %x\n", f2u(s2->x), f2u(s2->y)); \ + fflush(stdout); \ + if (fgets(buf, BUFSIZE-1, stdin) == NULL) break; \ + } \ + } + +#define func_f_f_f(funcStr, funcName) { \ + while (startsWith(buf, funcStr " ")) { \ + uint32_t u, v; \ + sscanf(buf, funcStr " %x %x", &u, &v); \ + *b0 = u2f(u); \ + *b1 = u2f(v); \ + funcName<<<1, 1>>>(s, b0, b1); \ + cudaDeviceSynchronize(); \ + printf("%x\n", f2u(*s)); \ + fflush(stdout); \ + if (fgets(buf, BUFSIZE-1, stdin) == NULL) break; \ + } \ + } + +// + +#define BUFSIZE 1024 + +int main(int argc, char **argv) { +#if 0 + cuInit(0); + + int ndevice; + cuDeviceGetCount(&ndevice); + if (ndevice == 0) { + fprintf(stderr, "No cuda device available\n"); + exit(0); + } + + CUdevice device; + char deviceName[1024]; + cuDeviceGet(&device, 0); + cuDeviceGetName(deviceName, 1000, device); + fprintf(stderr, "Device : %s\n", deviceName); +#endif + + cudaSetDeviceFlags(cudaDeviceScheduleSpin); + + vdouble2 *r2; + vfloat2 *s2; + double *r, *a0, *a1, *a2; + float *s, *b0, *b1, *b2; + int *i0; + cudaMallocManaged(&r , 1*sizeof(double)); + cudaMallocManaged(&r2, 1*sizeof(vdouble2)); + cudaMallocManaged(&a0, 1*sizeof(double)); + cudaMallocManaged(&a1, 1*sizeof(double)); + cudaMallocManaged(&a2, 1*sizeof(double)); + cudaMallocManaged(&s , 1*sizeof(float)); + cudaMallocManaged(&s2, 1*sizeof(vfloat2)); + cudaMallocManaged(&b0, 1*sizeof(float)); + cudaMallocManaged(&b1, 1*sizeof(float)); + cudaMallocManaged(&b2, 1*sizeof(float)); + cudaMallocManaged(&i0, 1*sizeof(int)); + + printf("3\n"); + fflush(stdout); + + char buf[BUFSIZE]; + if (fgets(buf, BUFSIZE-1, stdin)) {} + + while(!feof(stdin)) { + func_d_d("sin", xsin); + func_d_d("cos", xcos); + func_d_d("tan", xtan); + func_d_d("asin", xasin); + func_d_d("acos", xacos); + func_d_d("atan", xatan); + func_d_d("log", xlog); + func_d_d("exp", xexp); + + func_d_d("sqrt", xsqrt); + func_d_d("sqrt_u05", xsqrt_u05); + func_d_d("sqrt_u35", xsqrt_u35); + func_d_d("cbrt", xcbrt); + func_d_d("cbrt_u1", xcbrt_u1); + + func_d_d("sinh", xsinh); + func_d_d("cosh", xcosh); + func_d_d("tanh", xtanh); + func_d_d("sinh_u35", xsinh_u35); + func_d_d("cosh_u35", xcosh_u35); + func_d_d("tanh_u35", xtanh_u35); + func_d_d("asinh", xasinh); + func_d_d("acosh", xacosh); + func_d_d("atanh", xatanh); + + func_d_d("sin_u1", xsin_u1); + func_d_d("cos_u1", xcos_u1); + func_d_d("tan_u1", xtan_u1); + func_d_d("sinpi_u05", xsinpi_u05); + func_d_d("cospi_u05", xcospi_u05); + func_d_d("asin_u1", xasin_u1); + func_d_d("acos_u1", xacos_u1); + func_d_d("atan_u1", xatan_u1); + func_d_d("log_u1", xlog_u1); + + func_d_d("exp2", xexp2); + func_d_d("exp10", xexp10); + func_d_d("exp2_u35", xexp2_u35); + func_d_d("exp10_u35", xexp10_u35); + func_d_d("expm1", xexpm1); + func_d_d("log10", xlog10); + func_d_d("log2", xlog2); + func_d_d("log2_u35", xlog2_u35); + func_d_d("log1p", xlog1p); + func_d_d("fabs", xfabs); + func_d_d("trunc", xtrunc); + func_d_d("floor", xfloor); + func_d_d("ceil", xceil); + func_d_d("round", xround); + func_d_d("rint", xrint); + func_d_d("frfrexp", xfrfrexp); + func_d_d("tgamma_u1", xtgamma_u1); + func_d_d("lgamma_u1", xlgamma_u1); + func_d_d("erf_u1", xerf_u1); + func_d_d("erfc_u15", xerfc_u15); + + func_d2_d("sincos", xsincos); + func_d2_d("sincos_u1", xsincos_u1); + func_d2_d("sincospi_u35", xsincospi_u35); + func_d2_d("sincospi_u05", xsincospi_u05); + func_d2_d("modf", xmodf); + + func_d_d_d("pow", xpow); + func_d_d_d("atan2", xatan2); + func_d_d_d("atan2_u1", xatan2_u1); + func_d_d_d("hypot_u05", xhypot_u05); + func_d_d_d("hypot_u35", xhypot_u35); + func_d_d_d("copysign", xcopysign); + func_d_d_d("fmax", xfmax); + func_d_d_d("fmin", xfmin); + func_d_d_d("fdim", xfdim); + func_d_d_d("nextafter", xnextafter); + func_d_d_d("fmod", xfmod); + func_d_d_d("remainder", xremainder); + + func_d_d_i("ldexp", xldexp); + func_i_d("ilogb", xilogb); + func_i_d("expfrexp", xexpfrexp); + + // + + func_f_f("sinf", xsinf); + func_f_f("cosf", xcosf); + func_f_f("tanf", xtanf); + func_f_f("asinf", xasinf); + func_f_f("acosf", xacosf); + func_f_f("atanf", xatanf); + func_f_f("logf", xlogf); + func_f_f("expf", xexpf); + + func_f_f("sqrtf", xsqrtf); + func_f_f("sqrtf_u05", xsqrtf_u05); + func_f_f("sqrtf_u35", xsqrtf_u35); + func_f_f("cbrtf", xcbrtf); + func_f_f("cbrtf_u1", xcbrtf_u1); + + func_f_f("sinhf", xsinhf); + func_f_f("coshf", xcoshf); + func_f_f("tanhf", xtanhf); + func_f_f("sinhf_u35", xsinhf_u35); + func_f_f("coshf_u35", xcoshf_u35); + func_f_f("tanhf_u35", xtanhf_u35); + func_f_f("asinhf", xasinhf); + func_f_f("acoshf", xacoshf); + func_f_f("atanhf", xatanhf); + + func_f_f("sinf_u1", xsinf_u1); + func_f_f("cosf_u1", xcosf_u1); + func_f_f("tanf_u1", xtanf_u1); + func_f_f("sinpif_u05", xsinpif_u05); + func_f_f("cospif_u05", xcospif_u05); + func_f_f("asinf_u1", xasinf_u1); + func_f_f("acosf_u1", xacosf_u1); + func_f_f("atanf_u1", xatanf_u1); + func_f_f("logf_u1", xlogf_u1); + + func_f_f("exp2f", xexp2f); + func_f_f("exp10f", xexp10f); + func_f_f("exp2f_u35", xexp2f_u35); + func_f_f("exp10f_u35", xexp10f_u35); + func_f_f("expm1f", xexpm1f); + func_f_f("log10f", xlog10f); + func_f_f("log2f", xlog2f); + func_f_f("log2f_u35", xlog2f_u35); + func_f_f("log1pf", xlog1pf); + + func_f2_f("sincosf", xsincosf); + func_f2_f("sincosf_u1", xsincosf_u1); + func_f2_f("sincospif_u35", xsincospif_u35); + func_f2_f("sincospif_u05", xsincospif_u05); + + func_f_f_f("powf", xpowf); + func_f_f_f("atan2f", xatan2f); + func_f_f_f("atan2f_u1", xatan2f_u1); + + func_f_f("fabsf", xfabsf); + func_f_f("truncf", xtruncf); + func_f_f("floorf", xfloorf); + func_f_f("ceilf", xceilf); + func_f_f("roundf", xroundf); + func_f_f("rintf", xrintf); + func_f_f("frfrexpf", xfrfrexpf); + + func_f_f_f("hypotf_u05", xhypotf_u05); + func_f_f_f("hypotf_u35", xhypotf_u35); + func_f_f_f("copysignf", xcopysignf); + func_f_f_f("fmaxf", xfmaxf); + func_f_f_f("fminf", xfminf); + func_f_f_f("fdimf", xfdimf); + func_f_f_f("nextafterf", xnextafterf); + func_f_f_f("fmodf", xfmodf); + func_f_f_f("remainderf", xremainderf); + + func_f2_f("modff", xmodff); + + func_f_f("tgammaf_u1", xtgammaf_u1); + func_f_f("lgammaf_u1", xlgammaf_u1); + func_f_f("erff_u1", xerff_u1); + func_f_f("erfcf_u15", xerfcf_u15); + + func_f_f("fastsinf_u3500", xfastsinf_u3500); + func_f_f("fastcosf_u3500", xfastcosf_u3500); + func_f_f_f("fastpowf_u3500", xfastpowf_u3500); + } + + return 0; +} diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-tester/iutsimd.c b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-tester/iutsimd.c new file mode 100644 index 00000000000..dd8ee96ba36 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-tester/iutsimd.c @@ -0,0 +1,859 @@ +// Copyright Naoki Shibata and contributors 2010 - 2023. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include +#include +#include + +#include + +#if defined(_MSC_VER) +#define STDIN_FILENO 0 +#else +#include +#include +#endif + +#include "quaddef.h" +#include "misc.h" + +#if !defined(USE_INLINE_HEADER) +#include "sleef.h" +#else // #if !defined(USE_INLINE_HEADER) +#include +#include +#include +#include + +#if defined(__AVX2__) || defined(__aarch64__) || defined(__arm__) || defined(__powerpc64__) +#ifndef FP_FAST_FMA +#define FP_FAST_FMA +#endif +#endif + +#if defined(_MSC_VER) && !defined(__STDC__) +#define __STDC__ 1 +#endif + +#if (defined(__GNUC__) || defined(__CLANG__)) && (defined(__i386__) || defined(__x86_64__)) +#include +#endif + +#if (defined(_MSC_VER)) +#include +#endif + +#if defined(__ARM_NEON__) || defined(__ARM_NEON) +#include +#endif + +#if defined(__ARM_FEATURE_SVE) +#include +#endif + +#if defined(__riscv) && defined(__riscv_v) +#include +#endif + +#if defined(__VSX__) +#include +#endif + +#if defined(__VX__) +#include +#endif + +#define SLEEF_ALWAYS_INLINE inline +#define SLEEF_INLINE +#define SLEEF_CONST +#include USE_INLINE_HEADER +#include MACRO_ONLY_HEADER + +#ifndef ENABLE_PUREC_SCALAR +#include "sleefinline_purec_scalar.h" +#endif + +#endif // #if !defined(USE_INLINE_HEADER) + +#include "testerutil.h" + +#define DORENAME + +#ifdef ENABLE_SSE2 +#include "renamesse2.h" +#if !defined(USE_INLINE_HEADER) +#define CONFIG 2 +#include "helpersse2.h" +typedef Sleef___m128d_2 vdouble2; +typedef Sleef___m128_2 vfloat2; +#endif +#endif + +#ifdef ENABLE_SSE4 +#include "renamesse4.h" +#if !defined(USE_INLINE_HEADER) +#define CONFIG 4 +#include "helpersse2.h" +typedef Sleef___m128d_2 vdouble2; +typedef Sleef___m128_2 vfloat2; +#endif +#endif + +#ifdef ENABLE_AVX +#include "renameavx.h" +#if !defined(USE_INLINE_HEADER) +#define CONFIG 1 +#include "helperavx.h" +typedef Sleef___m256d_2 vdouble2; +typedef Sleef___m256_2 vfloat2; +#endif +#endif + +#ifdef ENABLE_FMA4 +#include "renamefma4.h" +#if !defined(USE_INLINE_HEADER) +#define CONFIG 4 +#include "helperavx.h" +typedef Sleef___m256d_2 vdouble2; +typedef Sleef___m256_2 vfloat2; +#endif +#endif + +#ifdef ENABLE_AVX2 +#include "renameavx2.h" +#if !defined(USE_INLINE_HEADER) +#define CONFIG 1 +#include "helperavx2.h" +typedef Sleef___m256d_2 vdouble2; +typedef Sleef___m256_2 vfloat2; +#endif +#endif + +#ifdef ENABLE_AVX2128 +#include "renameavx2128.h" +#if !defined(USE_INLINE_HEADER) +#define CONFIG 1 +#include "helperavx2_128.h" +typedef Sleef___m128d_2 vdouble2; +typedef Sleef___m128_2 vfloat2; +#endif +#endif + +#ifdef ENABLE_AVX512F +#include "renameavx512f.h" +#if !defined(USE_INLINE_HEADER) +#define CONFIG 1 +#include "helperavx512f.h" +typedef Sleef___m512d_2 vdouble2; +typedef Sleef___m512_2 vfloat2; +#endif +#endif + +#ifdef ENABLE_AVX512FNOFMA +#include "renameavx512fnofma.h" +#if !defined(USE_INLINE_HEADER) +#define CONFIG 2 +#include "helperavx512f.h" +typedef Sleef___m512d_2 vdouble2; +typedef Sleef___m512_2 vfloat2; +#endif +#endif + +#ifdef ENABLE_VECEXT +#define CONFIG 1 +#include "helpervecext.h" +#include "norename.h" +#endif + +#ifdef ENABLE_PUREC +#define CONFIG 1 +#include "helperpurec.h" +#include "norename.h" +#endif + +#ifdef ENABLE_NEON32 +#include "renameneon32.h" +#if !defined(USE_INLINE_HEADER) +#define CONFIG 1 +#include "helperneon32.h" +typedef Sleef_float32x4_t_2 vfloat2; +#endif +#endif + +#ifdef ENABLE_NEON32VFPV4 +#include "renameneon32vfpv4.h" +#if !defined(USE_INLINE_HEADER) +#define CONFIG 4 +#include "helperneon32.h" +typedef Sleef_float32x4_t_2 vfloat2; +#endif +#endif + +#ifdef ENABLE_ADVSIMD +#include "renameadvsimd.h" +#if !defined(USE_INLINE_HEADER) +#define CONFIG 1 +#include "helperadvsimd.h" +typedef Sleef_float64x2_t_2 vdouble2; +typedef Sleef_float32x4_t_2 vfloat2; +#endif +#endif + +#ifdef ENABLE_ADVSIMDNOFMA +#include "renameadvsimdnofma.h" +#if !defined(USE_INLINE_HEADER) +#define CONFIG 2 +#include "helperadvsimd.h" +typedef Sleef_float64x2_t_2 vdouble2; +typedef Sleef_float32x4_t_2 vfloat2; +#endif +#endif + +#ifdef ENABLE_DSP128 +#define CONFIG 2 +#include "helpersse2.h" +#include "renamedsp128.h" +typedef Sleef___m128d_2 vdouble2; +typedef Sleef___m128_2 vfloat2; +#endif + +#ifdef ENABLE_SVE +#include "renamesve.h" +#if !defined(USE_INLINE_HEADER) +#define CONFIG 1 +#include "helpersve.h" +#endif +#endif + +#ifdef ENABLE_SVENOFMA +#include "renamesvenofma.h" +#if !defined(USE_INLINE_HEADER) +#define CONFIG 2 +#include "helpersve.h" +#endif +#endif + +#ifdef ENABLE_DSP256 +#define CONFIG 1 +#include "helperavx.h" +#include "renamedsp256.h" +typedef Sleef___m256d_2 vdouble2; +typedef Sleef___m256_2 vfloat2; +#endif + +#ifdef ENABLE_VSX +#include "renamevsx.h" +#if !defined(USE_INLINE_HEADER) +#define CONFIG 1 +#include "helperpower_128.h" +#include "renamevsx.h" +typedef Sleef_SLEEF_VECTOR_DOUBLE_2 vdouble2; +typedef Sleef_SLEEF_VECTOR_FLOAT_2 vfloat2; +#endif +#endif + +#ifdef ENABLE_VSXNOFMA +#include "renamevsxnofma.h" +#if !defined(USE_INLINE_HEADER) +#define CONFIG 2 +#include "helperpower_128.h" +#include "renamevsxnofma.h" +typedef Sleef_SLEEF_VECTOR_DOUBLE_2 vdouble2; +typedef Sleef_SLEEF_VECTOR_FLOAT_2 vfloat2; +#endif +#endif + +#ifdef ENABLE_VSX3 +#include "renamevsx3.h" +#if !defined(USE_INLINE_HEADER) +#define CONFIG 3 +#include "helperpower_128.h" +#include "renamevsx3.h" +typedef Sleef_SLEEF_VECTOR_DOUBLE_2 vdouble2; +typedef Sleef_SLEEF_VECTOR_FLOAT_2 vfloat2; +#endif +#endif + +#ifdef ENABLE_VSX3NOFMA +#include "renamevsx3nofma.h" +#if !defined(USE_INLINE_HEADER) +#define CONFIG 4 +#include "helperpower_128.h" +#include "renamevsx3nofma.h" +typedef Sleef_SLEEF_VECTOR_DOUBLE_2 vdouble2; +typedef Sleef_SLEEF_VECTOR_FLOAT_2 vfloat2; +#endif +#endif + +#ifdef ENABLE_VXE +#include "renamevxe.h" +#if !defined(USE_INLINE_HEADER) +#define CONFIG 140 +#include "helpers390x_128.h" +typedef Sleef_SLEEF_VECTOR_DOUBLE_2 vdouble2; +typedef Sleef_SLEEF_VECTOR_FLOAT_2 vfloat2; +#endif +#endif + +#ifdef ENABLE_VXENOFMA +#include "renamevxenofma.h" +#if !defined(USE_INLINE_HEADER) +#define CONFIG 141 +#include "helpers390x_128.h" +typedef Sleef_SLEEF_VECTOR_DOUBLE_2 vdouble2; +typedef Sleef_SLEEF_VECTOR_FLOAT_2 vfloat2; +#endif +#endif + +#ifdef ENABLE_VXE2 +#include "renamevxe2.h" +#if !defined(USE_INLINE_HEADER) +#define CONFIG 150 +#include "helpers390x_128.h" +typedef Sleef_SLEEF_VECTOR_DOUBLE_2 vdouble2; +typedef Sleef_SLEEF_VECTOR_FLOAT_2 vfloat2; +#endif +#endif + +#ifdef ENABLE_VXE2NOFMA +#include "renamevxe2nofma.h" +#if !defined(USE_INLINE_HEADER) +#define CONFIG 151 +#include "helpers390x_128.h" +typedef Sleef_SLEEF_VECTOR_DOUBLE_2 vdouble2; +typedef Sleef_SLEEF_VECTOR_FLOAT_2 vfloat2; +#endif +#endif + +#ifdef ENABLE_DSPPOWER_128 +#define CONFIG 1 +#include "helperpower_128.h" +#include "renamedsp128.h" +typedef Sleef_SLEEF_VECTOR_DOUBLE_2 vdouble2; +typedef Sleef_SLEEF_VECTOR_FLOAT_2 vfloat2; +#endif + +#ifdef ENABLE_DSPS390X_128 +#define CONFIG 140 +#include "helpers390x_128.h" +#include "renamedsp128.h" +typedef Sleef_SLEEF_VECTOR_DOUBLE_2 vdouble2; +typedef Sleef_SLEEF_VECTOR_FLOAT_2 vfloat2; +#endif + +#ifdef ENABLE_RVVM1 +#include "renamervvm1.h" +#if !defined(USE_INLINE_HEADER) +#define CONFIG 1 +#include "helperrvv.h" +#endif +#endif + +#ifdef ENABLE_RVVM1NOFMA +#include "renamervvm1nofma.h" +#if !defined(USE_INLINE_HEADER) +#define CONFIG 2 +#include "helperrvv.h" +#endif +#endif + +#ifdef ENABLE_RVVM2 +#include "renamervvm2.h" +#if !defined(USE_INLINE_HEADER) +#define CONFIG 1 +#include "helperrvv.h" +#endif +#endif + +#ifdef ENABLE_RVVM2NOFMA +#include "renamervvm2nofma.h" +#if !defined(USE_INLINE_HEADER) +#define CONFIG 2 +#include "helperrvv.h" +#endif +#endif + +#ifdef ENABLE_PUREC_SCALAR +#include "renamepurec_scalar.h" +#if !defined(USE_INLINE_HEADER) +#define CONFIG 1 +#include "helperpurec_scalar.h" +typedef Sleef_double_2 vdouble2; +typedef Sleef_float_2 vfloat2; +#endif +#endif + +#ifdef ENABLE_PURECFMA_SCALAR +#include "renamepurecfma_scalar.h" +#if !defined(USE_INLINE_HEADER) +#define CONFIG 2 +#include "helperpurec_scalar.h" +typedef Sleef_double_2 vdouble2; +typedef Sleef_float_2 vfloat2; +#endif +#endif + +#ifdef ENABLE_DSP_SCALAR +#include "renamedspscalar.h" +#define CONFIG 1 +#include "helperpurec_scalar.h" +typedef Sleef_double_2 vdouble2; +typedef Sleef_float_2 vfloat2; +#endif + +#ifdef USE_INLINE_HEADER +#define CONCAT_SIMD_SUFFIX_(keyword, suffix) keyword ## suffix +#define CONCAT_SIMD_SUFFIX(keyword, suffix) CONCAT_SIMD_SUFFIX_(keyword, suffix) +#define vmask CONCAT_SIMD_SUFFIX(vmask, SIMD_SUFFIX) +#define vopmask CONCAT_SIMD_SUFFIX(vopmask, SIMD_SUFFIX) +#define vdouble CONCAT_SIMD_SUFFIX(vdouble, SIMD_SUFFIX) +#define vint CONCAT_SIMD_SUFFIX(vint, SIMD_SUFFIX) +#define vfloat CONCAT_SIMD_SUFFIX(vfloat, SIMD_SUFFIX) +#define vint2 CONCAT_SIMD_SUFFIX(vint2, SIMD_SUFFIX) +#define vdouble2 CONCAT_SIMD_SUFFIX(vdouble2, SIMD_SUFFIX) +#define vfloat2 CONCAT_SIMD_SUFFIX(vfloat2, SIMD_SUFFIX) +#define vd2getx_vd_vd2 CONCAT_SIMD_SUFFIX(vd2getx_vd_vd2, SIMD_SUFFIX) +#define vd2gety_vd_vd2 CONCAT_SIMD_SUFFIX(vd2gety_vd_vd2, SIMD_SUFFIX) +#define vf2getx_vf_vf2 CONCAT_SIMD_SUFFIX(vf2getx_vf_vf2, SIMD_SUFFIX) +#define vf2gety_vf_vf2 CONCAT_SIMD_SUFFIX(vf2gety_vf_vf2, SIMD_SUFFIX) +#define vloadu_vd_p CONCAT_SIMD_SUFFIX(vloadu_vd_p, SIMD_SUFFIX) +#define vstoreu_v_p_vd CONCAT_SIMD_SUFFIX(vstoreu_v_p_vd, SIMD_SUFFIX) +#define vloadu_vf_p CONCAT_SIMD_SUFFIX(vloadu_vf_p, SIMD_SUFFIX) +#define vstoreu_v_p_vf CONCAT_SIMD_SUFFIX(vstoreu_v_p_vf, SIMD_SUFFIX) +#define vloadu_vi_p CONCAT_SIMD_SUFFIX(vloadu_vi_p, SIMD_SUFFIX) +#define vstoreu_v_p_vi CONCAT_SIMD_SUFFIX(vstoreu_v_p_vi, SIMD_SUFFIX) +#endif + +// + +int check_feature(double d, float f) { +#ifdef ENABLE_DP + { + double s[VECTLENDP]; + int i; + for(i=0;i +#include +#include +#include + +#include + +#define N 64 +#define M 256 + +double r0[N], a0[N], a1[N], a2[N]; + +void do_libm() { for(int i=0;i +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include + +#include "misc.h" +#include "testerutil.h" + +#ifndef NANf +#define NANf ((float)NAN) +#endif + +void stop(char *mes) { + fprintf(stderr, "%s\n", mes); + exit(-1); +} + +int ptoc[2], ctop[2]; +int pid; +FILE *fpctop; + +extern char **environ; + +void startChild(const char *path, char *const argv[]) { + pipe(ptoc); + pipe(ctop); + + pid = fork(); + + assert(pid != -1); + + if (pid == 0) { + // child process + char buf0[1], buf1[1]; + + close(ptoc[1]); + close(ctop[0]); + + fflush(stdin); + fflush(stdout); + + if (dup2(ptoc[0], fileno(stdin)) == -1) exit(-1); + if (dup2(ctop[1], fileno(stdout)) == -1) exit(-1); + + setvbuf(stdin, buf0, _IONBF,0); + setvbuf(stdout, buf1, _IONBF,0); + + fflush(stdin); + fflush(stdout); + +#if !defined(__APPLE__) && !defined(__FreeBSD__) + execvpe(path, argv, environ); +#else + execvp(path, argv); +#endif + + fprintf(stderr, "execvp in startChild : %s\n", strerror(errno)); + + exit(-1); + } + + // parent process + + close(ptoc[0]); + close(ctop[1]); +} + +// + +#define child_d_d(funcStr, arg) do { \ + char str[256]; \ + uint64_t u; \ + sprintf(str, funcStr " %" PRIx64 "\n", d2u(arg)); \ + write(ptoc[1], str, strlen(str)); \ + if (fgets(str, 255, fpctop) == NULL) stop("child " funcStr); \ + sscanf(str, "%" PRIx64, &u); \ + return u2d(u); \ + } while(0) + +#define child_d2_d(funcStr, arg) do { \ + char str[256]; \ + uint64_t u, v; \ + sprintf(str, funcStr " %" PRIx64 "\n", d2u(arg)); \ + write(ptoc[1], str, strlen(str)); \ + if (fgets(str, 255, fpctop) == NULL) stop("child " funcStr); \ + sscanf(str, "%" PRIx64 " %" PRIx64, &u, &v); \ + Sleef_double2 ret; \ + ret.x = u2d(u); \ + ret.y = u2d(v); \ + return ret; \ + } while(0) + +#define child_d_d_d(funcStr, arg1, arg2) do { \ + char str[256]; \ + uint64_t u; \ + sprintf(str, funcStr " %" PRIx64 " %" PRIx64 "\n", d2u(arg1), d2u(arg2)); \ + write(ptoc[1], str, strlen(str)); \ + if (fgets(str, 255, fpctop) == NULL) stop("child " funcStr); \ + sscanf(str, "%" PRIx64, &u); \ + return u2d(u); \ + } while(0) + +double child_sin(double x) { child_d_d("sin", x); } +double child_cos(double x) { child_d_d("cos", x); } +double child_tan(double x) { child_d_d("tan", x); } +double child_asin(double x) { child_d_d("asin", x); } +double child_acos(double x) { child_d_d("acos", x); } +double child_atan(double x) { child_d_d("atan", x); } +double child_log(double x) { child_d_d("log", x); } +double child_exp(double x) { child_d_d("exp", x); } +double child_cbrt(double x) { child_d_d("cbrt", x); } +double child_atan2(double y, double x) { child_d_d_d("atan2", y, x); } +Sleef_double2 child_sincos(double x) { child_d2_d("sincos", x); } + +double child_sin_u1(double x) { child_d_d("sin_u1", x); } +double child_cos_u1(double x) { child_d_d("cos_u1", x); } +double child_tan_u1(double x) { child_d_d("tan_u1", x); } +double child_asin_u1(double x) { child_d_d("asin_u1", x); } +double child_acos_u1(double x) { child_d_d("acos_u1", x); } +double child_atan_u1(double x) { child_d_d("atan_u1", x); } +double child_log_u1(double x) { child_d_d("log_u1", x); } +double child_exp_u1(double x) { child_d_d("exp_u1", x); } +double child_cbrt_u1(double x) { child_d_d("cbrt_u1", x); } +double child_atan2_u1(double y, double x) { child_d_d_d("atan2_u1", y, x); } +Sleef_double2 child_sincos_u1(double x) { child_d2_d("sincos_u1", x); } + +double child_pow(double x, double y) { child_d_d_d("pow", x, y); } +double child_sqrt(double x) { child_d_d("sqrt", x); } +double child_sqrt_u05(double x) { child_d_d("sqrt_u05", x); } +double child_sqrt_u35(double x) { child_d_d("sqrt_u35", x); } + +double child_sinh(double x) { child_d_d("sinh", x); } +double child_cosh(double x) { child_d_d("cosh", x); } +double child_tanh(double x) { child_d_d("tanh", x); } +double child_sinh_u35(double x) { child_d_d("sinh_u35", x); } +double child_cosh_u35(double x) { child_d_d("cosh_u35", x); } +double child_tanh_u35(double x) { child_d_d("tanh_u35", x); } +double child_asinh(double x) { child_d_d("asinh", x); } +double child_acosh(double x) { child_d_d("acosh", x); } +double child_atanh(double x) { child_d_d("atanh", x); } + +double child_log10(double x) { child_d_d("log10", x); } +double child_log2(double x) { child_d_d("log2", x); } +double child_log2_u35(double x) { child_d_d("log2_u35", x); } +double child_log1p(double x) { child_d_d("log1p", x); } +double child_exp2(double x) { child_d_d("exp2", x); } +double child_exp10(double x) { child_d_d("exp10", x); } +double child_exp2_u35(double x) { child_d_d("exp2_u35", x); } +double child_exp10_u35(double x) { child_d_d("exp10_u35", x); } +double child_expm1(double x) { child_d_d("expm1", x); } + +Sleef_double2 child_sincospi_u05(double x) { child_d2_d("sincospi_u05", x); } +Sleef_double2 child_sincospi_u35(double x) { child_d2_d("sincospi_u35", x); } +double child_sinpi_u05(double x) { child_d_d("sinpi_u05", x); } +double child_cospi_u05(double x) { child_d_d("cospi_u05", x); } + +double child_hypot_u05(double x, double y) { child_d_d_d("hypot_u05", x, y); } +double child_hypot_u35(double x, double y) { child_d_d_d("hypot_u35", x, y); } +double child_copysign(double x, double y) { child_d_d_d("copysign", x, y); } +double child_fmax(double x, double y) { child_d_d_d("fmax", x, y); } +double child_fmin(double x, double y) { child_d_d_d("fmin", x, y); } +double child_fdim(double x, double y) { child_d_d_d("fdim", x, y); } +double child_nextafter(double x, double y) { child_d_d_d("nextafter", x, y); } +double child_fmod(double x, double y) { child_d_d_d("fmod", x, y); } +double child_remainder(double x, double y) { child_d_d_d("remainder", x, y); } +double child_fabs(double x) { child_d_d("fabs", x); } +double child_trunc(double x) { child_d_d("trunc", x); } +double child_floor(double x) { child_d_d("floor", x); } +double child_ceil(double x) { child_d_d("ceil", x); } +double child_round(double x) { child_d_d("round", x); } +double child_rint(double x) { child_d_d("rint", x); } +double child_frfrexp(double x) { child_d_d("frfrexp", x); } +Sleef_double2 child_modf(double x) { child_d2_d("modf", x); } +double child_tgamma_u1(double x) { child_d_d("tgamma_u1", x); } +double child_lgamma_u1(double x) { child_d_d("lgamma_u1", x); } +double child_erf_u1(double x) { child_d_d("erf_u1", x); } +double child_erfc_u15(double x) { child_d_d("erfc_u15", x); } + +// + +double child_ldexp(double x, int q) { + char str[256]; + uint64_t u; + + sprintf(str, "ldexp %" PRIx64 " %" PRIx64 "\n", d2u(x), d2u(q)); + write(ptoc[1], str, strlen(str)); + if (fgets(str, 255, fpctop) == NULL) stop("child_ldexp"); + sscanf(str, "%" PRIx64, &u); + return u2d(u); +} + +int child_ilogb(double x) { + char str[256]; + int i; + + sprintf(str, "ilogb %" PRIx64 "\n", d2u(x)); + write(ptoc[1], str, strlen(str)); + if (fgets(str, 255, fpctop) == NULL) stop("child_ilogb"); + sscanf(str, "%d", &i); + return i; +} + +// + +#define child_f_f(funcStr, arg) do { \ + char str[256]; \ + uint32_t u; \ + sprintf(str, funcStr " %x\n", f2u(arg)); \ + write(ptoc[1], str, strlen(str)); \ + if (fgets(str, 255, fpctop) == NULL) stop("child " funcStr); \ + sscanf(str, "%x", &u); \ + return u2f(u); \ + } while(0) + +#define child_f2_f(funcStr, arg) do { \ + char str[256]; \ + uint32_t u, v; \ + sprintf(str, funcStr " %x\n", f2u(arg)); \ + write(ptoc[1], str, strlen(str)); \ + if (fgets(str, 255, fpctop) == NULL) stop("child " funcStr); \ + sscanf(str, "%x %x", &u, &v); \ + Sleef_float2 ret; \ + ret.x = u2f(u); \ + ret.y = u2f(v); \ + return ret; \ + } while(0) + +#define child_f_f_f(funcStr, arg1, arg2) do { \ + char str[256]; \ + uint32_t u; \ + sprintf(str, funcStr " %x %x\n", f2u(arg1), f2u(arg2)); \ + write(ptoc[1], str, strlen(str)); \ + if (fgets(str, 255, fpctop) == NULL) stop("child " funcStr); \ + sscanf(str, "%x", &u); \ + return u2f(u); \ + } while(0) + +float child_sinf(float x) { child_f_f("sinf", x); } +float child_cosf(float x) { child_f_f("cosf", x); } +float child_tanf(float x) { child_f_f("tanf", x); } +float child_asinf(float x) { child_f_f("asinf", x); } +float child_acosf(float x) { child_f_f("acosf", x); } +float child_atanf(float x) { child_f_f("atanf", x); } +float child_logf(float x) { child_f_f("logf", x); } +float child_expf(float x) { child_f_f("expf", x); } +float child_cbrtf(float x) { child_f_f("cbrtf", x); } +float child_atan2f(float y, float x) { child_f_f_f("atan2f", y, x); } +Sleef_float2 child_sincosf(float x) { child_f2_f("sincosf", x); } + +float child_sinf_u1(float x) { child_f_f("sinf_u1", x); } +float child_cosf_u1(float x) { child_f_f("cosf_u1", x); } +float child_tanf_u1(float x) { child_f_f("tanf_u1", x); } +float child_asinf_u1(float x) { child_f_f("asinf_u1", x); } +float child_acosf_u1(float x) { child_f_f("acosf_u1", x); } +float child_atanf_u1(float x) { child_f_f("atanf_u1", x); } +float child_logf_u1(float x) { child_f_f("logf_u1", x); } +float child_expf_u1(float x) { child_f_f("expf_u1", x); } +float child_cbrtf_u1(float x) { child_f_f("cbrtf_u1", x); } +float child_atan2f_u1(float y, float x) { child_f_f_f("atan2f_u1", y, x); } +Sleef_float2 child_sincosf_u1(float x) { child_f2_f("sincosf_u1", x); } + +float child_powf(float x, float y) { child_f_f_f("powf", x, y); } +float child_sqrtf(float x) { child_f_f("sqrtf", x); } +float child_sqrtf_u05(float x) { child_f_f("sqrtf_u05", x); } +float child_sqrtf_u35(float x) { child_f_f("sqrtf_u35", x); } + +float child_sinhf(float x) { child_f_f("sinhf", x); } +float child_coshf(float x) { child_f_f("coshf", x); } +float child_tanhf(float x) { child_f_f("tanhf", x); } +float child_sinhf_u35(float x) { child_f_f("sinhf_u35", x); } +float child_coshf_u35(float x) { child_f_f("coshf_u35", x); } +float child_tanhf_u35(float x) { child_f_f("tanhf_u35", x); } +float child_asinhf(float x) { child_f_f("asinhf", x); } +float child_acoshf(float x) { child_f_f("acoshf", x); } +float child_atanhf(float x) { child_f_f("atanhf", x); } + +float child_log10f(float x) { child_f_f("log10f", x); } +float child_log2f(float x) { child_f_f("log2f", x); } +float child_log2f_u35(float x) { child_f_f("log2f_u35", x); } +float child_log1pf(float x) { child_f_f("log1pf", x); } +float child_exp2f(float x) { child_f_f("exp2f", x); } +float child_exp10f(float x) { child_f_f("exp10f", x); } +float child_exp2f_u35(float x) { child_f_f("exp2f_u35", x); } +float child_exp10f_u35(float x) { child_f_f("exp10f_u35", x); } +float child_expm1f(float x) { child_f_f("expm1f", x); } + +Sleef_float2 child_sincospif_u05(float x) { child_f2_f("sincospif_u05", x); } +Sleef_float2 child_sincospif_u35(float x) { child_f2_f("sincospif_u35", x); } +float child_sinpif_u05(float x) { child_f_f("sinpif_u05", x); } +float child_cospif_u05(float x) { child_f_f("cospif_u05", x); } + +float child_hypotf_u05(float x, float y) { child_f_f_f("hypotf_u05", x, y); } +float child_hypotf_u35(float x, float y) { child_f_f_f("hypotf_u35", x, y); } +float child_copysignf(float x, float y) { child_f_f_f("copysignf", x, y); } +float child_fmaxf(float x, float y) { child_f_f_f("fmaxf", x, y); } +float child_fminf(float x, float y) { child_f_f_f("fminf", x, y); } +float child_fdimf(float x, float y) { child_f_f_f("fdimf", x, y); } +float child_nextafterf(float x, float y) { child_f_f_f("nextafterf", x, y); } +float child_fmodf(float x, float y) { child_f_f_f("fmodf", x, y); } +float child_remainderf(float x, float y) { child_f_f_f("remainderf", x, y); } +float child_fabsf(float x) { child_f_f("fabsf", x); } +float child_truncf(float x) { child_f_f("truncf", x); } +float child_floorf(float x) { child_f_f("floorf", x); } +float child_ceilf(float x) { child_f_f("ceilf", x); } +float child_roundf(float x) { child_f_f("roundf", x); } +float child_rintf(float x) { child_f_f("rintf", x); } +float child_frfrexpf(float x) { child_f_f("frfrexpf", x); } +Sleef_float2 child_modff(float x) { child_f2_f("modff", x); } +float child_tgammaf_u1(float x) { child_f_f("tgammaf_u1", x); } +float child_lgammaf_u1(float x) { child_f_f("lgammaf_u1", x); } +float child_erff_u1(float x) { child_f_f("erff_u1", x); } +float child_erfcf_u15(float x) { child_f_f("erfcf_u15", x); } + +float child_fastsinf_u3500(float x) { child_f_f("fastsinf_u3500", x); } +float child_fastcosf_u3500(float x) { child_f_f("fastcosf_u3500", x); } +float child_fastpowf_u3500(float x, float y) { child_f_f_f("fastpowf_u3500", x, y); } + +float child_ldexpf(float x, int q) { + char str[256]; + uint32_t u; + + sprintf(str, "ldexpf %x %x\n", f2u(x), f2u(q)); + write(ptoc[1], str, strlen(str)); + if (fgets(str, 255, fpctop) == NULL) stop("child_powf"); + sscanf(str, "%x", &u); + return u2f(u); +} + +int child_ilogbf(float x) { + char str[256]; + int i; + + sprintf(str, "ilogbf %x\n", f2u(x)); + write(ptoc[1], str, strlen(str)); + if (fgets(str, 255, fpctop) == NULL) stop("child_ilogbf"); + sscanf(str, "%d", &i); + return i; +} + +// + +int allTestsPassed = 1; + +void showResult(int success) { + if (!success) allTestsPassed = 0; + fprintf(stderr, "%s\n", success ? "OK" : "NG **************"); + + if (!success) { + fprintf(stderr, "\n\n*** Test failed\n"); + exit(-1); + } +} + +int enableDP = 0, enableSP = 0, deterministicMode = 0; + +void do_test() { + mpfr_t frc, frt, frx, fry, frz; + mpfr_inits(frc, frt, frx, fry, frz, NULL); + + int i, j; + int64_t i64; + double d, x, y; + int success = 1; + + if (enableDP) { + fprintf(stderr, "Denormal/nonnumber test atan2(y, x)\n\n"); + + fprintf(stderr, "If y is +0 and x is -0, +pi is returned : "); + showResult(child_atan2(+0.0, -0.0) == M_PI); + + fprintf(stderr, "If y is -0 and x is -0, -pi is returned : "); + showResult(child_atan2(-0.0, -0.0) == -M_PI); + + fprintf(stderr, "If y is +0 and x is +0, +0 is returned : "); + showResult(isPlusZero(child_atan2(+0.0, +0.0))); + + fprintf(stderr, "If y is -0 and x is +0, -0 is returned : "); + showResult(isMinusZero(child_atan2(-0.0, +0.0))); + + fprintf(stderr, "If y is positive infinity and x is negative infinity, +3*pi/4 is returned : "); + showResult(child_atan2(POSITIVE_INFINITY, NEGATIVE_INFINITY) == 3*M_PI/4); + + fprintf(stderr, "If y is negative infinity and x is negative infinity, -3*pi/4 is returned : "); + showResult(child_atan2(NEGATIVE_INFINITY, NEGATIVE_INFINITY) == -3*M_PI/4); + + fprintf(stderr, "If y is positive infinity and x is positive infinity, +pi/4 is returned : "); + showResult(child_atan2(POSITIVE_INFINITY, POSITIVE_INFINITY) == M_PI/4); + + fprintf(stderr, "If y is negative infinity and x is positive infinity, -pi/4 is returned : "); + showResult(child_atan2(NEGATIVE_INFINITY, POSITIVE_INFINITY) == -M_PI/4); + + { + fprintf(stderr, "If y is +0 and x is less than 0, +pi is returned : "); + + double ya[] = { +0.0 }; + double xa[] = { -100000.5, -100000, -3, -2.5, -2, -1.5, -1.0, -0.5 }; + + for(i=0;i 1e+300) continue; + cmpDenorm_d_d(mpfr_fmod, child_fmod, xa[i], ya[j]); + } + } + + showResult(success); + } + + { + fprintf(stderr, "remainder denormal/nonnumber test : "); + + double xa[] = { +0.0, -0.0, +1, -1, +1e+100, -1e+100, 1.7e+308, DBL_MAX, -DBL_MAX, DBL_MIN, -DBL_MIN, POSITIVE_INFINITY, NEGATIVE_INFINITY, NAN }; + double ya[] = { +0.0, -0.0, +1, -1, +1e+100, -1e+100, 1.0e+308, DBL_MAX, -DBL_MAX, DBL_MIN, -DBL_MIN, POSITIVE_INFINITY, NEGATIVE_INFINITY, NAN }; + + for(i=0;i 1e+300) continue; + cmpDenorm_d_d(mpfr_remainder, child_remainder, xa[i], ya[j]); + } + } + + showResult(success); + } + + { + fprintf(stderr, "trunc denormal/nonnumber test : "); + double xa[] = { +0.0, -0.0, +1, -1, +1e+10, -1e+10, DBL_MAX, -DBL_MAX, DBL_MIN, -DBL_MIN, POSITIVE_INFINITY, NEGATIVE_INFINITY, NAN }; + for(i=0;i 1e+38) continue; + cmpDenorm_f_f(mpfr_fmod, child_fmodf, xa[i], ya[j]); + } + } + } else { + float xa[] = { +0.0, -0.0, +1, -1, +1e+30, -1e+30, FLT_MAX, -FLT_MAX, FLT_MIN, -FLT_MIN, POSITIVE_INFINITYf, NEGATIVE_INFINITYf, NAN }; + float ya[] = { +0.0, -0.0, +1, -1, +1e+30, -1e+30, FLT_MAX, -FLT_MAX, FLT_MIN, -FLT_MIN, POSITIVE_INFINITYf, NEGATIVE_INFINITYf, NAN }; + for(i=0;i 1e+38) continue; + cmpDenorm_f_f(mpfr_fmod, child_fmodf, xa[i], ya[j]); + } + } + } + + showResult(success); + } + + { + fprintf(stderr, "remainderf denormal/nonnumber test : "); + + if (enableFlushToZero) { + float xa[] = { +0.0, -0.0, +1, -1, +1e+30, -1e+30, FLT_MAX, -FLT_MAX, POSITIVE_INFINITYf, NEGATIVE_INFINITYf, NAN }; + float ya[] = { +0.0, -0.0, +1, -1, POSITIVE_INFINITYf, NEGATIVE_INFINITYf, NAN }; + for(i=0;i 1e+38) continue; + cmpDenorm_f_f(mpfr_remainder, child_remainderf, xa[i], ya[j]); + } + } + } else { + float xa[] = { +0.0, -0.0, +1, -1, +1e+30, -1e+30, FLT_MAX, -FLT_MAX, FLT_MIN, -FLT_MIN, POSITIVE_INFINITYf, NEGATIVE_INFINITYf, NAN }; + float ya[] = { +0.0, -0.0, +1, -1, +1e+30, -1e+30, FLT_MAX, -FLT_MAX, FLT_MIN, -FLT_MIN, POSITIVE_INFINITYf, NEGATIVE_INFINITYf, NAN }; + for(i=0;i 1e+38) continue; + cmpDenorm_f_f(mpfr_remainder, child_remainderf, xa[i], ya[j]); + } + } + } + + showResult(success); + } + + { + fprintf(stderr, "truncf denormal/nonnumber test : "); + float xa[] = { +0.0, -0.0, +1, -1, +1e+10, -1e+10, FLT_MAX, -FLT_MAX, FLT_MIN, -FLT_MIN, POSITIVE_INFINITYf, NEGATIVE_INFINITYf, NAN }; + for(i=0;i bound) { \ + fprintf(stderr, "\narg = %.20g, test = %.20g, correct = %.20g, ULP = %lf\n", argx, childFunc(argx), mpfr_get_d(frc, GMP_RNDN), countULPdp(childFunc(argx), frc)); \ + success = 0; \ + break; \ + } \ + } while(0) + +#define checkAccuracyNR_d(mpfrFunc, childFunc, argx, bound) do { \ + mpfr_set_d(frx, argx, GMP_RNDN); \ + mpfrFunc(frc, frx); \ + if (countULPdp(childFunc(argx), frc) > bound) { \ + fprintf(stderr, "\narg = %.20g, test = %.20g, correct = %.20g, ULP = %lf\n", argx, childFunc(argx), mpfr_get_d(frc, GMP_RNDN), countULPdp(childFunc(argx), frc)); \ + success = 0; \ + break; \ + } \ + } while(0) + +#define checkAccuracy_d_d(mpfrFunc, childFunc, argx, argy, bound) do { \ + mpfr_set_d(frx, argx, GMP_RNDN); \ + mpfr_set_d(fry, argy, GMP_RNDN); \ + mpfrFunc(frc, frx, fry, GMP_RNDN); \ + if (countULPdp(childFunc(argx, argy), frc) > bound) { \ + fprintf(stderr, "\narg = %.20g, %.20g, test = %.20g, correct = %.20g, ULP = %lf\n", \ + argx, argy, childFunc(argx, argy), mpfr_get_d(frc, GMP_RNDN), countULPdp(childFunc(argx, argy), frc)); \ + success = 0; \ + break; \ + } \ + } while(0) + +#define checkAccuracyX_d(mpfrFunc, childFunc, argx, bound) do { \ + mpfr_set_d(frx, argx, GMP_RNDN); \ + mpfrFunc(frc, frx, GMP_RNDN); \ + Sleef_double2 d2 = childFunc(argx); \ + if (countULPdp(d2.x, frc) > bound) { \ + fprintf(stderr, "\narg = %.20g, test = %.20g, correct = %.20g, ULP = %lf\n", argx, d2.x, mpfr_get_d(frc, GMP_RNDN), countULPdp(d2.x, frc)); \ + success = 0; \ + break; \ + } \ + } while(0) + +#define checkAccuracyY_d(mpfrFunc, childFunc, argx, bound) do { \ + mpfr_set_d(frx, argx, GMP_RNDN); \ + mpfrFunc(frc, frx, GMP_RNDN); \ + Sleef_double2 d2 = childFunc(argx); \ + if (countULPdp(d2.y, frc) > bound) { \ + fprintf(stderr, "\narg = %.20g, test = %.20g, correct = %.20g, ULP = %lf\n", argx, d2.y, mpfr_get_d(frc, GMP_RNDN), countULPdp(d2.y, frc)); \ + success = 0; \ + break; \ + } \ + } while(0) + + // + + fprintf(stderr, "\nAccuracy test\n"); + + // + + if (enableDP) { + // 64 > 53(=number of bits in DP mantissa) + mpfr_set_default_prec(64); + + fprintf(stderr, "hypot_u35 : "); + for(y = -10;y < 10 && success;y += 0.15) { + for(x = -10;x < 10 && success;x += 0.15) checkAccuracy_d_d(mpfr_hypot, child_hypot_u35, y, x, 3.5); + } + for(y = -1e+10;y < 1e+10 && success;y += 1.51e+8) { + for(x = -1e+10;x < 1e+10 && success;x += 1.51e+8) checkAccuracy_d_d(mpfr_hypot, child_hypot_u35, y, x, 3.5); + } + showResult(success); + + // + + fprintf(stderr, "hypot_u05 : "); + for(y = -10;y < 10 && success;y += 0.15) { + for(x = -10;x < 10 && success;x += 0.15) checkAccuracy_d_d(mpfr_hypot, child_hypot_u05, y, x, 0.5); + } + for(y = -1e+10;y < 1e+10 && success;y += 1.51e+8) { + for(x = -1e+10;x < 1e+10 && success;x += 1.51e+8) checkAccuracy_d_d(mpfr_hypot, child_hypot_u05, y, x, 0.5); + } + showResult(success); + + // + + fprintf(stderr, "copysign : "); + for(y = -10;y < 10 && success;y += 0.15) { + for(x = -10;x < 10 && success;x += 0.15) checkAccuracy_d_d(mpfr_copysign, child_copysign, y, x, 0); + } + for(y = -1e+10;y < 1e+10 && success;y += 1.51e+8) { + for(x = -1e+10;x < 1e+10 && success;x += 1.51e+8) checkAccuracy_d_d(mpfr_copysign, child_copysign, y, x, 0); + } + showResult(success); + + // + + fprintf(stderr, "fmax : "); + for(y = -10;y < 10 && success;y += 0.15) { + for(x = -10;x < 10 && success;x += 0.15) checkAccuracy_d_d(mpfr_max, child_fmax, y, x, 0); + } + for(y = -1e+10;y < 1e+10 && success;y += 1.51e+8) { + for(x = -1e+10;x < 1e+10 && success;x += 1.51e+8) checkAccuracy_d_d(mpfr_max, child_fmax, y, x, 0); + } + showResult(success); + + // + + fprintf(stderr, "fmin : "); + for(y = -10;y < 10 && success;y += 0.15) { + for(x = -10;x < 10 && success;x += 0.15) checkAccuracy_d_d(mpfr_min, child_fmin, y, x, 0); + } + for(y = -1e+10;y < 1e+10 && success;y += 1.51e+8) { + for(x = -1e+10;x < 1e+10 && success;x += 1.51e+8) checkAccuracy_d_d(mpfr_min, child_fmin, y, x, 0); + } + showResult(success); + + // + + fprintf(stderr, "fdim : "); + for(y = -10;y < 10 && success;y += 0.15) { + for(x = -10;x < 10 && success;x += 0.15) checkAccuracy_d_d(mpfr_dim, child_fdim, y, x, 0.5); + } + for(y = -1e+10;y < 1e+10 && success;y += 1.51e+8) { + for(x = -1e+10;x < 1e+10 && success;x += 1.51e+8) checkAccuracy_d_d(mpfr_dim, child_fdim, y, x, 0.5); + } + showResult(success); + + // + + fprintf(stderr, "fmod : "); + for(y = -10;y < 10 && success;y += 0.15) { + for(x = -10;x < 10 && success;x += 0.15) checkAccuracy_d_d(mpfr_fmod, child_fmod, y, x, 0.5); + } + for(y = -1e+10;y < 1e+10 && success;y += 1.51e+8) { + for(x = -1e+10;x < 1e+10 && success;x += 1.51e+8) checkAccuracy_d_d(mpfr_fmod, child_fmod, y, x, 0.5); + } + showResult(success); + + // + + fprintf(stderr, "remainder : "); + for(y = -10;y < 10 && success;y += 0.15) { + for(x = -10;x < 10 && success;x += 0.15) checkAccuracy_d_d(mpfr_remainder, child_remainder, y, x, 0.5); + } + for(y = -1e+10;y < 1e+10 && success;y += 1.51e+8) { + for(x = -1e+10;x < 1e+10 && success;x += 1.51e+8) checkAccuracy_d_d(mpfr_remainder, child_remainder, y, x, 0.5); + } + showResult(success); + + // + + fprintf(stderr, "trunc : "); + for(x = -100.5;x <= 100.5;x+=0.5) { + for(d = u2d(d2u(x)-3);d <= u2d(d2u(x)+3) && success;d = u2d(d2u(d)+1)) checkAccuracyNR_d(mpfr_trunc, child_trunc, d, 0); + } + for(d = -10000;d < 10000 && success;d += 2.5) checkAccuracyNR_d(mpfr_trunc, child_trunc, d, 0); + { + double start = u2d(d2u((double)(INT64_C(1) << 52))-20), end = u2d(d2u((double)(INT64_C(1) << 52))+20); + for(d = start;d <= end;d = u2d(d2u(d)+1)) checkAccuracyNR_d(mpfr_trunc, child_trunc, d, 0); + for(d = start;d <= end;d = u2d(d2u(d)+1)) checkAccuracyNR_d(mpfr_trunc, child_trunc, -d, 0); + } + showResult(success); + + // + + fprintf(stderr, "floor : "); + for(x = -100.5;x <= 100.5;x+=0.5) { + for(d = u2d(d2u(x)-3);d <= u2d(d2u(x)+3) && success;d = u2d(d2u(d)+1)) checkAccuracyNR_d(mpfr_floor, child_floor, d, 0); + } + for(d = -10000;d < 10000 && success;d += 2.5) checkAccuracyNR_d(mpfr_floor, child_floor, d, 0); + { + double start = u2d(d2u((double)(INT64_C(1) << 52))-20), end = u2d(d2u((double)(INT64_C(1) << 52))+20); + for(d = start;d <= end;d = u2d(d2u(d)+1)) checkAccuracyNR_d(mpfr_floor, child_floor, d, 0); + for(d = start;d <= end;d = u2d(d2u(d)+1)) checkAccuracyNR_d(mpfr_floor, child_floor, -d, 0); + } + showResult(success); + + // + + fprintf(stderr, "ceil : "); + for(x = -100.5;x <= 100.5;x+=0.5) { + for(d = u2d(d2u(x)-3);d <= u2d(d2u(x)+3) && success;d = u2d(d2u(d)+1)) checkAccuracyNR_d(mpfr_ceil, child_ceil, d, 0); + } + for(d = -10000;d < 10000 && success;d += 2.5) checkAccuracyNR_d(mpfr_ceil, child_ceil, d, 0); + { + double start = u2d(d2u((double)(INT64_C(1) << 52))-20), end = u2d(d2u((double)(INT64_C(1) << 52))+20); + for(d = start;d <= end;d = u2d(d2u(d)+1)) checkAccuracyNR_d(mpfr_ceil, child_ceil, d, 0); + for(d = start;d <= end;d = u2d(d2u(d)+1)) checkAccuracyNR_d(mpfr_ceil, child_ceil, -d, 0); + } + showResult(success); + + // + + fprintf(stderr, "round : "); + for(x = -100.5;x <= 100.5;x+=0.5) { + for(d = u2d(d2u(x)-3);d <= u2d(d2u(x)+3) && success;d = u2d(d2u(d)+1)) checkAccuracyNR_d(mpfr_round, child_round, d, 0); + } + for(d = -10000;d < 10000 && success;d += 2.5) checkAccuracyNR_d(mpfr_round, child_round, d, 0); + { + double start = u2d(d2u((double)(INT64_C(1) << 52))-20), end = u2d(d2u((double)(INT64_C(1) << 52))+20); + for(d = start;d <= end;d = u2d(d2u(d)+1)) checkAccuracyNR_d(mpfr_round, child_round, d, 0); + for(d = start;d <= end;d = u2d(d2u(d)+1)) checkAccuracyNR_d(mpfr_round, child_round, -d, 0); + } + showResult(success); + + // + + fprintf(stderr, "rint : "); + for(x = -100.5;x <= 100.5;x+=0.5) { + for(d = u2d(d2u(x)-3);d <= u2d(d2u(x)+3) && success;d = u2d(d2u(d)+1)) checkAccuracy_d(mpfr_rint, child_rint, d, 0); + } + for(d = -10000;d < 10000 && success;d += 2.5) checkAccuracy_d(mpfr_rint, child_rint, d, 0); + { + double start = u2d(d2u((double)(INT64_C(1) << 52))-20), end = u2d(d2u((double)(INT64_C(1) << 52))+20); + for(d = start;d <= end;d = u2d(d2u(d)+1)) checkAccuracy_d(mpfr_rint, child_rint, d, 0); + for(d = start;d <= end;d = u2d(d2u(d)+1)) checkAccuracy_d(mpfr_rint, child_rint, -d, 0); + } + showResult(success); + + // + + fprintf(stderr, "sin : "); + for(d = -10;d < 10 && success;d += 0.002) checkAccuracy_d(mpfr_sin, child_sin, d, 3.5); + for(d = -1e+14;d < 1e+14 && success;d += (1e+10 + 0.1)) checkAccuracy_d(mpfr_sin, child_sin, d, 3.5); + for(i = 0;i < 920 && success;i++) checkAccuracy_d(mpfr_sin, child_sin, pow(2.16, i), 3.5); + for(i64=(int64_t)-1e+14;i64<(int64_t)1e+14 && success;i64+=(int64_t)1e+12) { + double start = u2d(d2u(M_PI_4 * i64)-20), end = u2d(d2u(M_PI_4 * i64)+20); + for(d = start;d <= end;d = u2d(d2u(d)+1)) checkAccuracy_d(mpfr_sin, child_sin, d, 3.5); + } + showResult(success); + + // + + fprintf(stderr, "sin_u1 : "); + for(d = -10;d < 10 && success;d += 0.002) checkAccuracy_d(mpfr_sin, child_sin_u1, d, 1.0); + for(d = -1e+14;d < 1e+14 && success;d += (1e+10 + 0.1)) checkAccuracy_d(mpfr_sin, child_sin_u1, d, 1.0); + for(i = 0;i < 920 && success;i++) checkAccuracy_d(mpfr_sin, child_sin_u1, pow(2.16, i), 1.0); + for(i64=(int64_t)-1e+14;i64<(int64_t)1e+14 && success;i64+=(int64_t)1e+12) { + double start = u2d(d2u(M_PI_4 * i64)-20), end = u2d(d2u(M_PI_4 * i64)+20); + for(d = start;d <= end;d = u2d(d2u(d)+1)) checkAccuracy_d(mpfr_sin, child_sin_u1, d, 1.0); + } + showResult(success); + + // + + fprintf(stderr, "sin in sincos : "); + for(d = -10;d < 10 && success;d += 0.002) checkAccuracyX_d(mpfr_sin, child_sincos, d, 3.5); + for(d = -1e+14;d < 1e+14 && success;d += (1e+10 + 0.1)) checkAccuracyX_d(mpfr_sin, child_sincos, d, 3.5); + for(i = 0;i < 920 && success;i++) checkAccuracyX_d(mpfr_sin, child_sincos, pow(2.16, i), 3.5); + for(i=1;i<10000 && success;i+=31) { + double start = u2d(d2u(M_PI_4 * i)-20), end = u2d(d2u(M_PI_4 * i)+20); + for(d = start;d <= end;d = u2d(d2u(d)+1)) checkAccuracyX_d(mpfr_sin, child_sincos, d, 3.5); + } + showResult(success); + + // + + fprintf(stderr, "sin in sincos_u1 : "); + for(d = -10;d < 10 && success;d += 0.002) checkAccuracyX_d(mpfr_sin, child_sincos_u1, d, 1.0); + for(d = -1e+14;d < 1e+14 && success;d += (1e+10 + 0.1)) checkAccuracyX_d(mpfr_sin, child_sincos_u1, d, 1.0); + for(i = 0;i < 920 && success;i++) checkAccuracyX_d(mpfr_sin, child_sincos_u1, pow(2.16, i), 1.0); + for(i=1;i<10000 && success;i+=31) { + double start = u2d(d2u(M_PI_4 * i)-20), end = u2d(d2u(M_PI_4 * i)+20); + for(d = start;d <= end;d = u2d(d2u(d)+1)) checkAccuracyX_d(mpfr_sin, child_sincos_u1, d, 1.0); + } + showResult(success); + + // + + // 1280 > 1024(=maximum DP exponent) + 53(=number of bits in DP mantissa) + mpfr_set_default_prec(1280); + + fprintf(stderr, "sin in sincospi_u35 : "); + for(d = -10.1;d < 10 && success;d += 0.0021) checkAccuracyX_d(mpfr_sinpi, child_sincospi_u35, d, 3.5); + for(d = -1e+8-0.1;d < 1e+8 && success;d += (1e+10 + 0.1)) checkAccuracyX_d(mpfr_sinpi, child_sincospi_u35, d, 3.5); + for(i=1;i<10000 && success;i+=31) { + double start = u2d(d2u(i)-20), end = u2d(d2u(i)+20); + for(d = start;d <= end;d = u2d(d2u(d)+1)) checkAccuracyX_d(mpfr_sinpi, child_sincospi_u35, d, 3.5); + } + for(i=1;i<=20 && success;i++) { + double start = u2d(d2u(0.25 * i)-20), end = u2d(d2u(0.25 * i)+20); + for(d = start;d <= end;d = u2d(d2u(d)+1)) checkAccuracyX_d(mpfr_sinpi, child_sincospi_u35, d, 3.5); + } + showResult(success); + + // + + fprintf(stderr, "sin in sincospi_u05 : "); + for(d = -10.1;d < 10 && success;d += 0.0021) checkAccuracyX_d(mpfr_sinpi, child_sincospi_u05, d, 0.506); + for(d = -1e+8-0.1;d < 1e+8 && success;d += (1e+10 + 0.1)) checkAccuracyX_d(mpfr_sinpi, child_sincospi_u05, d, 0.506); + for(i=1;i<10000 && success;i+=31) { + double start = u2d(d2u(i)-20), end = u2d(d2u(i)+20); + for(d = start;d <= end;d = u2d(d2u(d)+1)) checkAccuracyX_d(mpfr_sinpi, child_sincospi_u05, d, 0.506); + } + for(i=1;i<=20 && success;i++) { + double start = u2d(d2u(0.25 * i)-20), end = u2d(d2u(0.25 * i)+20); + for(d = start;d <= end;d = u2d(d2u(d)+1)) checkAccuracyX_d(mpfr_sinpi, child_sincospi_u05, d, 0.506); + } + showResult(success); + + // + + fprintf(stderr, "sinpi_u05 : "); + for(d = -10.1;d < 10 && success;d += 0.0021) checkAccuracy_d(mpfr_sinpi, child_sinpi_u05, d, 0.506); + for(d = -1e+8-0.1;d < 1e+8 && success;d += (1e+10 + 0.1)) checkAccuracy_d(mpfr_sinpi, child_sinpi_u05, d, 0.506); + for(i=1;i<10000 && success;i+=31) { + double start = u2d(d2u(i)-20), end = u2d(d2u(i)+20); + for(d = start;d <= end;d = u2d(d2u(d)+1)) checkAccuracy_d(mpfr_sinpi, child_sinpi_u05, d, 0.506); + } + for(i=1;i<=20 && success;i++) { + double start = u2d(d2u(0.25 * i)-20), end = u2d(d2u(0.25 * i)+20); + for(d = start;d <= end;d = u2d(d2u(d)+1)) checkAccuracy_d(mpfr_sinpi, child_sinpi_u05, d, 0.506); + } + showResult(success); + + // + + fprintf(stderr, "cospi_u05 : "); + for(d = -10.1;d < 10 && success;d += 0.0021) checkAccuracy_d(mpfr_cospi, child_cospi_u05, d, 0.506); + for(d = -1e+8-0.1;d < 1e+8 && success;d += (1e+10 + 0.1)) checkAccuracy_d(mpfr_cospi, child_cospi_u05, d, 0.506); + for(i=1;i<10000 && success;i+=31) { + double start = u2d(d2u(i)-20), end = u2d(d2u(i)+20); + for(d = start;d <= end;d = u2d(d2u(d)+1)) checkAccuracy_d(mpfr_cospi, child_cospi_u05, d, 0.506); + } + for(i=1;i<=20 && success;i++) { + double start = u2d(d2u(0.25 * i)-20), end = u2d(d2u(0.25 * i)+20); + for(d = start;d <= end;d = u2d(d2u(d)+1)) checkAccuracy_d(mpfr_cospi, child_cospi_u05, d, 0.506); + } + showResult(success); + + mpfr_set_default_prec(64); + + // + + fprintf(stderr, "cos : "); + for(d = -10;d < 10 && success;d += 0.002) checkAccuracy_d(mpfr_cos, child_cos, d, 3.5); + for(d = -1e+14;d < 1e+14 && success;d += (1e+10 + 0.1)) checkAccuracy_d(mpfr_cos, child_cos, d, 3.5); + for(i = 0;i < 920 && success;i++) checkAccuracy_d(mpfr_cos, child_cos, pow(2.16, i), 3.5); + for(i64=(int64_t)-1e+14;i64<(int64_t)1e+14 && success;i64+=(int64_t)1e+12) { + double start = u2d(d2u(M_PI_4 * i64)-20), end = u2d(d2u(M_PI_4 * i64)+20); + for(d = start;d <= end;d = u2d(d2u(d)+1)) checkAccuracy_d(mpfr_cos, child_cos, d, 3.5); + } + showResult(success); + + // + + fprintf(stderr, "cos_u1 : "); + for(d = -10;d < 10 && success;d += 0.002) checkAccuracy_d(mpfr_cos, child_cos_u1, d, 1.0); + for(d = -1e+14;d < 1e+14 && success;d += (1e+10 + 0.1)) checkAccuracy_d(mpfr_cos, child_cos_u1, d, 1.0); + for(i = 0;i < 920 && success;i++) checkAccuracy_d(mpfr_cos, child_cos_u1, pow(2.16, i), 1.0); + for(i64=(int64_t)-1e+14;i64<(int64_t)1e+14 && success;i64+=(int64_t)1e+12) { + double start = u2d(d2u(M_PI_4 * i64)-20), end = u2d(d2u(M_PI_4 * i64)+20); + for(d = start;d <= end;d = u2d(d2u(d)+1)) checkAccuracy_d(mpfr_cos, child_cos_u1, d, 1.0); + } + showResult(success); + + // + + fprintf(stderr, "cos in sincos : "); + for(d = -10;d < 10 && success;d += 0.002) checkAccuracyY_d(mpfr_cos, child_sincos, d, 3.5); + for(d = -1e+14;d < 1e+14 && success;d += (1e+10 + 0.1)) checkAccuracyY_d(mpfr_cos, child_sincos, d, 3.5); + for(i = 0;i < 920 && success;i++) checkAccuracyY_d(mpfr_cos, child_sincos, pow(2.16, i), 3.5); + for(i=1;i<10000 && success;i+=31) { + double start = u2d(d2u(M_PI_4 * i)-20), end = u2d(d2u(M_PI_4 * i)+20); + for(d = start;d <= end;d = u2d(d2u(d)+1)) checkAccuracyY_d(mpfr_cos, child_sincos, d, 3.5); + } + showResult(success); + + // + + fprintf(stderr, "cos in sincos_u1 : "); + for(d = -10;d < 10 && success;d += 0.002) checkAccuracyY_d(mpfr_cos, child_sincos_u1, d, 1.0); + for(d = -1e+14;d < 1e+14 && success;d += (1e+10 + 0.1)) checkAccuracyY_d(mpfr_cos, child_sincos_u1, d, 1.0); + for(i = 0;i < 920 && success;i++) checkAccuracyY_d(mpfr_cos, child_sincos_u1, pow(2.16, i), 1.0); + for(i=1;i<10000 && success;i+=31) { + double start = u2d(d2u(M_PI_4 * i)-20), end = u2d(d2u(M_PI_4 * i)+20); + for(d = start;d <= end;d = u2d(d2u(d)+1)) checkAccuracyY_d(mpfr_cos, child_sincos_u1, d, 1.0); + } + showResult(success); + + // + + mpfr_set_default_prec(1280); + + fprintf(stderr, "cos in sincospi_u35 : "); + for(d = -10.1;d < 10 && success;d += 0.0021) checkAccuracyY_d(mpfr_cospi, child_sincospi_u35, d, 3.5); + for(d = -1e+8-0.1;d < 1e+8 && success;d += (1e+10 + 0.1)) checkAccuracyY_d(mpfr_cospi, child_sincospi_u35, d, 3.5); + for(i=1;i<10000 && success;i+=31) { + double start = u2d(d2u(i)-20), end = u2d(d2u(i)+20); + for(d = start;d <= end;d = u2d(d2u(d)+1)) checkAccuracyY_d(mpfr_cospi, child_sincospi_u35, d, 3.5); + } + for(i=1;i<=20 && success;i++) { + double start = u2d(d2u(0.25 * i)-20), end = u2d(d2u(0.25 * i)+20); + for(d = start;d <= end;d = u2d(d2u(d)+1)) checkAccuracyY_d(mpfr_cospi, child_sincospi_u35, d, 3.5); + } + showResult(success); + + // + + fprintf(stderr, "cos in sincospi_u05 : "); + for(d = -10.1;d < 10 && success;d += 0.0021) checkAccuracyY_d(mpfr_cospi, child_sincospi_u05, d, 0.506); + for(d = -1e+8-0.1;d < 1e+8 && success;d += (1e+10 + 0.1)) checkAccuracyY_d(mpfr_cospi, child_sincospi_u05, d, 0.506); + for(i=1;i<10000 && success;i+=31) { + double start = u2d(d2u(i)-20), end = u2d(d2u(i)+20); + for(d = start;d <= end;d = u2d(d2u(d)+1)) checkAccuracyY_d(mpfr_cospi, child_sincospi_u05, d, 0.506); + } + for(i=1;i<=20 && success;i++) { + double start = u2d(d2u(0.25 * i)-20), end = u2d(d2u(0.25 * i)+20); + for(d = start;d <= end;d = u2d(d2u(d)+1)) checkAccuracyY_d(mpfr_cospi, child_sincospi_u05, d, 0.506); + } + showResult(success); + + mpfr_set_default_prec(64); + + // + + fprintf(stderr, "tan : "); + for(d = -10;d < 10 && success;d += 0.002) checkAccuracy_d(mpfr_tan, child_tan, d, 3.5); + for(d = -1e+7;d < 1e+7 && success;d += 1000.1) checkAccuracy_d(mpfr_tan, child_tan, d, 3.5); + for(d = -1e+14;d < 1e+14 && success;d += (1e+10 + 0.1)) checkAccuracy_d(mpfr_tan, child_tan, d, 3.5); + for(i = 0;i < 920 && success;i++) checkAccuracy_d(mpfr_tan, child_tan, pow(2.16, i), 3.5); + for(i=1;i<10000 && success;i+=31) { + double start = u2d(d2u(M_PI_4 * i)-20), end = u2d(d2u(M_PI_4 * i)+20); + for(d = start;d <= end;d = u2d(d2u(d)+1)) checkAccuracy_d(mpfr_tan, child_tan, d, 3.5); + } + showResult(success); + + // + + fprintf(stderr, "tan_u1 : "); + for(d = -10;d < 10 && success;d += 0.002) checkAccuracy_d(mpfr_tan, child_tan_u1, d, 1.0); + for(d = -1e+7;d < 1e+7 && success;d += 1000.1) checkAccuracy_d(mpfr_tan, child_tan_u1, d, 1.0); + for(d = -1e+14;d < 1e+14 && success;d += (1e+10 + 0.1)) checkAccuracy_d(mpfr_tan, child_tan_u1, d, 1.0); + for(i = 0;i < 920 && success;i++) checkAccuracy_d(mpfr_tan, child_tan_u1, pow(2.16, i), 1.0); + for(i=1;i<10000 && success;i+=31) { + double start = u2d(d2u(M_PI_4 * i)-20), end = u2d(d2u(M_PI_4 * i)+20); + for(d = start;d <= end;d = u2d(d2u(d)+1)) checkAccuracy_d(mpfr_tan, child_tan_u1, d, 1.0); + } + showResult(success); + + // + + fprintf(stderr, "log : "); + for(d = 0.0001;d < 10 && success;d += 0.001) checkAccuracy_d(mpfr_log, child_log, d, 3.5); + for(d = 0.0001;d < 10000 && success;d += 1.1) checkAccuracy_d(mpfr_log, child_log, d, 3.5); + for(i = -1000;i <= 1000 && success;i+=10) checkAccuracy_d(mpfr_log, child_log, pow(2.1, i), 3.5); + for(i=0;i<10000 && success;i+=10) checkAccuracy_d(mpfr_log, child_log, DBL_MAX * pow(0.9314821319758632, i), 3.5); + for(i=0;i<10000 && success;i+=10) checkAccuracy_d(mpfr_log, child_log, pow(0.933254300796991, i), 3.5); + for(i=0;i<10000 && success;i+=10) checkAccuracy_d(mpfr_log, child_log, DBL_MIN * pow(0.996323, i), 3.5); + showResult(success); + + // + + fprintf(stderr, "log_u1 : "); + for(d = 0.0001;d < 10 && success;d += 0.001) checkAccuracy_d(mpfr_log, child_log_u1, d, 1.0); + for(d = 0.0001;d < 10000 && success;d += 1.1) checkAccuracy_d(mpfr_log, child_log_u1, d, 1.0); + for(i = -1000;i <= 1000 && success;i+=10) checkAccuracy_d(mpfr_log, child_log_u1, pow(2.1, i), 1.0); + for(i=0;i<10000 && success;i+=10) checkAccuracy_d(mpfr_log, child_log_u1, DBL_MAX * pow(0.9314821319758632, i), 1.0); + for(i=0;i<10000 && success;i+=10) checkAccuracy_d(mpfr_log, child_log_u1, pow(0.933254300796991, i), 1.0); + for(i=0;i<10000 && success;i+=10) checkAccuracy_d(mpfr_log, child_log_u1, DBL_MIN * pow(0.996323, i), 1.0); + showResult(success); + + // + + fprintf(stderr, "exp : "); + for(d = -10;d < 10 && success;d += 0.002) checkAccuracy_d(mpfr_exp, child_exp, d, 1.0); + for(d = -1000;d < 1000 && success;d += 1.1) checkAccuracy_d(mpfr_exp, child_exp, d, 1.0); + showResult(success); + + // + + fprintf(stderr, "pow : "); + for(y = 0.1;y < 100 && success;y += 0.6) { + for(x = -100;x < 100 && success;x += 0.6) { + checkAccuracy_d_d(mpfr_pow, child_pow, x, y, 1.0); + } + } + for(y = -1000;y < 1000 && success;y += 0.1) checkAccuracy_d_d(mpfr_pow, child_pow, 2.1, y, 1.0); + showResult(success); + + // + + if (!deterministicMode) { + fprintf(stderr, "sqrt : "); + for(d = -10000;d < 10000 && success;d += 2.1) checkAccuracy_d(mpfr_sqrt, child_sqrt, d, 1.0); + for(i = -1000;i <= 1000 && success;i+=10) checkAccuracy_d(mpfr_sqrt, child_sqrt, pow(2.1, d), 1.0); + showResult(success); + + // + + fprintf(stderr, "sqrt_u05 : "); + for(d = -10000;d < 10000 && success;d += 2.1) checkAccuracy_d(mpfr_sqrt, child_sqrt_u05, d, 0.506); + for(i = -1000;i <= 1000 && success;i+=10) checkAccuracy_d(mpfr_sqrt, child_sqrt_u05, pow(2.1, d), 0.506); + showResult(success); + + // + + fprintf(stderr, "sqrt_u35 : "); + for(d = -10000;d < 10000 && success;d += 2.1) checkAccuracy_d(mpfr_sqrt, child_sqrt_u35, d, 3.5); + for(i = -1000;i <= 1000 && success;i+=10) checkAccuracy_d(mpfr_sqrt, child_sqrt_u35, pow(2.1, d), 3.5); + showResult(success); + } + + // + + fprintf(stderr, "cbrt : "); + for(d = -10000;d < 10000 && success;d += 2.1) checkAccuracy_d(mpfr_cbrt, child_cbrt, d, 3.5); + for(i = -1000;i <= 1000 && success;i+=10) checkAccuracy_d(mpfr_cbrt, child_cbrt, pow(2.1, d), 3.5); + showResult(success); + + // + + fprintf(stderr, "cbrt_u1 : "); + for(d = -10000;d < 10000 && success;d += 2.1) checkAccuracy_d(mpfr_cbrt, child_cbrt_u1, d, 1.0); + for(i = -1000;i <= 1000 && success;i+=10) checkAccuracy_d(mpfr_cbrt, child_cbrt_u1, pow(2.1, d), 1.0); + showResult(success); + + // + + fprintf(stderr, "asin : "); + for(d = -1;d < 1 && success;d += 0.0002) checkAccuracy_d(mpfr_asin, child_asin, d, 3.5); + showResult(success); + + // + + fprintf(stderr, "asin_u1 : "); + for(d = -1;d < 1 && success;d += 0.0002) checkAccuracy_d(mpfr_asin, child_asin_u1, d, 1.0); + showResult(success); + + // + + fprintf(stderr, "acos : "); + for(d = -1;d < 1 && success;d += 0.0002) checkAccuracy_d(mpfr_acos, child_acos, d, 3.5); + showResult(success); + + // + + fprintf(stderr, "acos_u1 : "); + for(d = -1;d < 1 && success;d += 0.0002) checkAccuracy_d(mpfr_acos, child_acos_u1, d, 1.0); + showResult(success); + + // + + fprintf(stderr, "atan : "); + for(d = -10;d < 10 && success;d += 0.002) checkAccuracy_d(mpfr_atan, child_atan, d, 3.5); + for(d = -10000;d < 10000 && success;d += 2.1) checkAccuracy_d(mpfr_atan, child_atan, d, 3.5); + showResult(success); + + // + + fprintf(stderr, "atan_u1 : "); + for(d = -10;d < 10 && success;d += 0.002) checkAccuracy_d(mpfr_atan, child_atan_u1, d, 1.0); + for(d = -10000;d < 10000 && success;d += 2.1) checkAccuracy_d(mpfr_atan, child_atan_u1, d, 1.0); + showResult(success); + + // + + fprintf(stderr, "atan2 : "); + for(y = -10;y < 10 && success;y += 0.15) { + for(x = -10;x < 10 && success;x += 0.15) checkAccuracy_d_d(mpfr_atan2, child_atan2, y, x, 3.5); + } + for(y = -100;y < 100 && success;y += 1.51) { + for(x = -100;x < 100 && success;x += 1.51) checkAccuracy_d_d(mpfr_atan2, child_atan2, y, x, 3.5); + } + showResult(success); + + // + + fprintf(stderr, "atan2_u1 : "); + for(y = -10;y < 10 && success;y += 0.15) { + for(x = -10;x < 10 && success;x += 0.15) checkAccuracy_d_d(mpfr_atan2, child_atan2_u1, y, x, 1.0); + } + for(y = -100;y < 100 && success;y += 1.51) { + for(x = -100;x < 100 && success;x += 1.51) checkAccuracy_d_d(mpfr_atan2, child_atan2_u1, y, x, 1.0); + } + showResult(success); + + // + + fprintf(stderr, "sinh : "); + for(d = -10;d < 10 && success;d += 0.002) checkAccuracy_d(mpfr_sinh, child_sinh, d, 1.0); + for(d = -709;d < 709 && success;d += 0.2) checkAccuracy_d(mpfr_sinh, child_sinh, d, 1.0); + showResult(success); + + // + + fprintf(stderr, "cosh : "); + for(d = -10;d < 10 && success;d += 0.002) checkAccuracy_d(mpfr_cosh, child_cosh, d, 1.0); + for(d = -709;d < 709 && success;d += 0.2) checkAccuracy_d(mpfr_cosh, child_cosh, d, 1.0); + showResult(success); + + // + + fprintf(stderr, "tanh : "); + for(d = -10;d < 10 && success;d += 0.002) checkAccuracy_d(mpfr_tanh, child_tanh, d, 1.0); + for(d = -1000;d < 1000 && success;d += 0.2) checkAccuracy_d(mpfr_tanh, child_tanh, d, 1.0); + showResult(success); + + // + + fprintf(stderr, "sinh_u35 : "); + for(d = -10;d < 10 && success;d += 0.002) checkAccuracy_d(mpfr_sinh, child_sinh_u35, d, 3.5); + for(d = -709;d < 709 && success;d += 0.2) checkAccuracy_d(mpfr_sinh, child_sinh_u35, d, 3.5); + showResult(success); + + // + + fprintf(stderr, "cosh_u35 : "); + for(d = -10;d < 10 && success;d += 0.002) checkAccuracy_d(mpfr_cosh, child_cosh_u35, d, 3.5); + for(d = -709;d < 709 && success;d += 0.2) checkAccuracy_d(mpfr_cosh, child_cosh_u35, d, 3.5); + showResult(success); + + // + + fprintf(stderr, "tanh_u35 : "); + for(d = -10;d < 10 && success;d += 0.002) checkAccuracy_d(mpfr_tanh, child_tanh_u35, d, 3.5); + for(d = -1000;d < 1000 && success;d += 0.2) checkAccuracy_d(mpfr_tanh, child_tanh_u35, d, 3.5); + showResult(success); + + // + + fprintf(stderr, "asinh : "); + for(d = -10;d < 10 && success;d += 0.002) checkAccuracy_d(mpfr_asinh, child_asinh, d, 1.0); + for(d = -1000;d < 1000 && success;d += 0.2) checkAccuracy_d(mpfr_asinh, child_asinh, d, 1.0); + showResult(success); + + // + + fprintf(stderr, "acosh : "); + for(d = 1;d < 10 && success;d += 0.002) checkAccuracy_d(mpfr_acosh, child_acosh, d, 1.0); + for(d = 1;d < 1000 && success;d += 0.2) checkAccuracy_d(mpfr_acosh, child_acosh, d, 1.0); + showResult(success); + + // + + fprintf(stderr, "atanh : "); + for(d = -10;d < 10 && success;d += 0.002) checkAccuracy_d(mpfr_atanh, child_atanh, d, 1.0); + for(d = -1000;d < 1000 && success;d += 0.2) checkAccuracy_d(mpfr_atanh, child_atanh, d, 1.0); + showResult(success); + + // + + fprintf(stderr, "exp2 : "); + for(d = -10;d < 10 && success;d += 0.002) checkAccuracy_d(mpfr_exp2, child_exp2, d, 1.0); + for(d = -1000;d < 1000 && success;d += 0.2) checkAccuracy_d(mpfr_exp2, child_exp2, d, 1.0); + showResult(success); + + // + + fprintf(stderr, "exp10 : "); + for(d = -10;d < 10 && success;d += 0.002) checkAccuracy_d(mpfr_exp10, child_exp10, d, 1.0); + for(d = -300;d < 300 && success;d += 0.1) checkAccuracy_d(mpfr_exp10, child_exp10, d, 1.0); + showResult(success); + + // + + fprintf(stderr, "exp2_u35 : "); + for(d = -10;d < 10 && success;d += 0.002) checkAccuracy_d(mpfr_exp2, child_exp2_u35, d, 3.5); + for(d = -1000;d < 1000 && success;d += 0.2) checkAccuracy_d(mpfr_exp2, child_exp2_u35, d, 3.5); + showResult(success); + + // + + fprintf(stderr, "exp10_u35 : "); + for(d = -10;d < 10 && success;d += 0.002) checkAccuracy_d(mpfr_exp10, child_exp10_u35, d, 3.5); + for(d = -300;d < 300 && success;d += 0.1) checkAccuracy_d(mpfr_exp10, child_exp10_u35, d, 3.5); + showResult(success); + + // + + fprintf(stderr, "expm1 : "); + for(d = -10;d < 10 && success;d += 0.002) checkAccuracy_d(mpfr_expm1, child_expm1, d, 1.0); + for(d = -1000;d < 1000 && success;d += 0.21) checkAccuracy_d(mpfr_expm1, child_expm1, d, 1.0); + for(d = 0;d < 300 && success;d += 0.21) checkAccuracy_d(mpfr_expm1, child_expm1, pow(10, -d), 1.0); + for(d = 0;d < 300 && success;d += 0.21) checkAccuracy_d(mpfr_expm1, child_expm1, (-pow(10, -d)), 1.0); + showResult(success); + + // + + fprintf(stderr, "log10 : "); + for(d = 0.0001;d < 10 && success;d += 0.001) checkAccuracy_d(mpfr_log10, child_log10, d, 1.0); + for(d = 0.0001;d < 10000 && success;d += 1.1) checkAccuracy_d(mpfr_log10, child_log10, d, 1.0); + for(i=0;i<10000 && success;i++) checkAccuracy_d(mpfr_log10, child_log10, (DBL_MIN * pow(0.996323, i)), 1.0); + showResult(success); + + // + + fprintf(stderr, "log2 : "); + for(d = 0.0001;d < 10 && success;d += 0.001) checkAccuracy_d(mpfr_log2, child_log2, d, 1.0); + for(d = 0.0001;d < 10000 && success;d += 1.1) checkAccuracy_d(mpfr_log2, child_log2, d, 1.0); + for(i=0;i<10000 && success;i++) checkAccuracy_d(mpfr_log2, child_log2, (DBL_MIN * pow(0.996323, i)), 1.0); + showResult(success); + + // + + fprintf(stderr, "log2_u35 : "); + for(d = 0.0001;d < 10 && success;d += 0.001) checkAccuracy_d(mpfr_log2, child_log2_u35, d, 3.5); + for(d = 0.0001;d < 10000 && success;d += 1.1) checkAccuracy_d(mpfr_log2, child_log2_u35, d, 3.5); + for(i=0;i<10000 && success;i++) checkAccuracy_d(mpfr_log2, child_log2_u35, (DBL_MIN * pow(0.996323, i)), 3.5); + showResult(success); + + // + + fprintf(stderr, "log1p : "); + for(d = 0.0001;d < 10 && success;d += 0.001) checkAccuracy_d(mpfr_log1p, child_log1p, d, 1.0); + showResult(success); + + // + + fprintf(stderr, "lgamma_u1 : "); + for(d = -5000;d < 5000 && success;d += 1.1) checkAccuracy_d(mpfr_lgamma_nosign, child_lgamma_u1, d, 1.0); + showResult(success); + + // + + fprintf(stderr, "tgamma_u1 : "); + for(d = -10;d < 10 && success;d += 0.002) checkAccuracy_d(mpfr_gamma, child_tgamma_u1, d, 1.0); + showResult(success); + + // + + fprintf(stderr, "erf_u1 : "); + for(d = -100;d < 100 && success;d += 0.02) checkAccuracy_d(mpfr_erf, child_erf_u1, d, 1.0); + showResult(success); + + // + + fprintf(stderr, "erfc_u15 : "); + for(d = -1;d < 100 && success;d += 0.01) checkAccuracy_d(mpfr_erfc, child_erfc_u15, d, 1.5); + showResult(success); + + // + + { + fprintf(stderr, "ilogb : "); + + for(d = 0.0001;d < 10;d += 0.001) { + int q = child_ilogb(d); + int c = ilogb(d); + if (q != c) { + fprintf(stderr, "ilogb : arg = %.20g, test = %d, correct = %d\n", d, ilogb(d), child_ilogb(d)); + success = 0; + showResult(success); + } + } + + for(d = 0.0001;d < 10000;d += 1.1) { + int q = child_ilogb(d); + int c = ilogb(d); + if (q != c) { + fprintf(stderr, "ilogb : arg = %.20g, test = %d, correct = %d\n", d, ilogb(d), child_ilogb(d)); + success = 0; + showResult(success); + } + } + + for(i=0;i<10000;i+=10) { + d = DBL_MIN * pow(0.996323, i); + if (d == 0) continue; + int q = child_ilogb(d); + int c = ilogb(d); + if (q != c) { + fprintf(stderr, "ilogb : arg = %.20g, test = %d, correct = %d\n", d, ilogb(d), child_ilogb(d)); + success = 0; + showResult(success); + } + } + + for(i=0;i<10000;i+=10) { + d = pow(0.933254300796991, i); + if (d == 0) continue; + int q = child_ilogb(d); + int c = ilogb(d); + if (q != c) { + fprintf(stderr, "ilogb : arg = %.20g, test = %d, correct = %d\n", d, ilogb(d), child_ilogb(d)); + success = 0; + showResult(success); + } + } + + showResult(success); + } + } + + // + +#define checkAccuracy_f(mpfrFunc, childFunc, argx, bound) do { \ + mpfr_set_d(frx, (float)flushToZero(argx), GMP_RNDN); \ + mpfrFunc(frc, frx, GMP_RNDN); \ + if (countULPsp(childFunc((float)flushToZero(argx)), frc) > bound) { \ + fprintf(stderr, "\narg = %.20g, test = %.20g, correct = %.20g, ULP = %lf\n", \ + (float)flushToZero(argx), (double)childFunc((float)flushToZero(argx)), mpfr_get_d(frc, GMP_RNDN), countULPsp(childFunc((float)flushToZero(argx)), frc)); \ + success = 0; \ + break; \ + } \ + } while(0) + +#define checkAccuracyNR_f(mpfrFunc, childFunc, argx, bound) do { \ + mpfr_set_d(frx, (float)flushToZero(argx), GMP_RNDN); \ + mpfrFunc(frc, frx); \ + if (countULPsp(childFunc((float)flushToZero(argx)), frc) > bound) { \ + fprintf(stderr, "\narg = %.20g, test = %.20g, correct = %.20g, ULP = %lf\n", \ + (float)flushToZero(argx), (double)childFunc((float)flushToZero(argx)), mpfr_get_d(frc, GMP_RNDN), countULPsp(childFunc((float)flushToZero(argx)), frc)); \ + success = 0; \ + break; \ + } \ + } while(0) + +#define checkAccuracy_f_f(mpfrFunc, childFunc, argx, argy, bound) do { \ + mpfr_set_d(frx, (float)flushToZero(argx), GMP_RNDN); \ + mpfr_set_d(fry, (float)flushToZero(argy), GMP_RNDN); \ + mpfrFunc(frc, frx, fry, GMP_RNDN); \ + if (countULPsp(childFunc((float)flushToZero(argx), (float)flushToZero(argy)), frc) > bound) { \ + fprintf(stderr, "\narg = %.20g, %.20g, test = %.20g, correct = %.20g, ULP = %lf\n", \ + (float)flushToZero(argx), (float)flushToZero(argy), childFunc((float)flushToZero(argx), (float)flushToZero(argy)), mpfr_get_d(frc, GMP_RNDN), countULPsp(childFunc((float)flushToZero(argx), (float)flushToZero(argy)), frc)); \ + success = 0; \ + break; \ + } \ + } while(0) + +#define checkAccuracyX_f(mpfrFunc, childFunc, argx, bound) do { \ + mpfr_set_d(frx, (float)flushToZero(argx), GMP_RNDN); \ + mpfrFunc(frc, frx, GMP_RNDN); \ + Sleef_float2 d2 = childFunc((float)flushToZero(argx)); \ + if (countULPsp(d2.x, frc) > bound) { \ + fprintf(stderr, "\narg = %.20g, test = %.20g, correct = %.20g, ULP = %lf\n", (float)flushToZero(argx), (double)d2.x, mpfr_get_d(frc, GMP_RNDN), countULPsp(d2.x, frc)); \ + success = 0; \ + break; \ + } \ + } while(0) + +#define checkAccuracyY_f(mpfrFunc, childFunc, argx, bound) do { \ + mpfr_set_d(frx, (float)flushToZero(argx), GMP_RNDN); \ + mpfrFunc(frc, frx, GMP_RNDN); \ + Sleef_float2 d2 = childFunc((float)flushToZero(argx)); \ + if (countULPsp(d2.y, frc) > bound) { \ + fprintf(stderr, "\narg = %.20g, test = %.20g, correct = %.20g, ULP = %lf\n", (float)flushToZero(argx), (double)d2.y, mpfr_get_d(frc, GMP_RNDN), countULPsp(d2.y, frc)); \ + success = 0; \ + break; \ + } \ + } while(0) + +#define checkAccuracy2_f(mpfrFunc, childFunc, argx, bound, abound) do { \ + mpfr_set_d(frx, (float)flushToZero(argx), GMP_RNDN); \ + mpfrFunc(frc, frx, GMP_RNDN); \ + double t = childFunc((float)flushToZero(argx)); \ + double ae = fabs(mpfr_get_d(frc, GMP_RNDN) - t); \ + if (countULPsp(t, frc) > bound && ae > abound) { \ + fprintf(stderr, "\narg = %.20g, test = %.20g, correct = %.20g, ULP = %lf, abserror = %g\n", \ + (float)flushToZero(argx), (double)childFunc((float)flushToZero(argx)), mpfr_get_d(frc, GMP_RNDN), countULPsp(childFunc((float)flushToZero(argx)), frc), ae); \ + success = 0; \ + break; \ + } \ + } while(0) + + // + + if (enableSP) { + // 53 > 24(=number of bits in SP mantissa) + mpfr_set_default_prec(53); + + fprintf(stderr, "hypotf_u35 : "); + for(y = -10;y < 10 && success;y += 0.15) { + for(x = -10;x < 10 && success;x += 0.15) checkAccuracy_f_f(mpfr_hypot, child_hypotf_u35, y, x, 3.5); + } + for(y = -1e+7;y < 1e+7 && success;y += 1.51e+5) { + for(x = -1e+7;x < 1e+7 && success;x += 1.51e+5) checkAccuracy_f_f(mpfr_hypot, child_hypotf_u35, y, x, 3.5); + } + showResult(success); + + // + + fprintf(stderr, "hypotf_u05 : "); + for(y = -10;y < 10 && success;y += 0.15) { + for(x = -10;x < 10 && success;x += 0.15) checkAccuracy_f_f(mpfr_hypot, child_hypotf_u05, y, x, 0.5); + } + for(y = -1e+7;y < 1e+7 && success;y += 1.51e+5) { + for(x = -1e+7;x < 1e+7 && success;x += 1.51e+5) checkAccuracy_f_f(mpfr_hypot, child_hypotf_u05, y, x, 0.5); + } + showResult(success); + + // + + fprintf(stderr, "copysignf : "); + for(y = -10;y < 10 && success;y += 0.15) { + for(x = -10;x < 10 && success;x += 0.15) checkAccuracy_f_f(mpfr_copysign, child_copysignf, y, x, 0); + } + for(y = -1e+7;y < 1e+7 && success;y += 1.51e+5) { + for(x = -1e+7;x < 1e+7 && success;x += 1.51e+5) checkAccuracy_f_f(mpfr_copysign, child_copysignf, y, x, 0); + } + showResult(success); + + // + + fprintf(stderr, "fmaxf : "); + for(y = -10;y < 10 && success;y += 0.15) { + for(x = -10;x < 10 && success;x += 0.15) checkAccuracy_f_f(mpfr_max, child_fmaxf, y, x, 0); + } + for(y = -1e+7;y < 1e+7 && success;y += 1.51e+5) { + for(x = -1e+7;x < 1e+7 && success;x += 1.51e+5) checkAccuracy_f_f(mpfr_max, child_fmaxf, y, x, 0); + } + showResult(success); + + // + + fprintf(stderr, "fminf : "); + for(y = -10;y < 10 && success;y += 0.15) { + for(x = -10;x < 10 && success;x += 0.15) checkAccuracy_f_f(mpfr_min, child_fminf, y, x, 0); + } + for(y = -1e+7;y < 1e+7 && success;y += 1.51e+5) { + for(x = -1e+7;x < 1e+7 && success;x += 1.51e+5) checkAccuracy_f_f(mpfr_min, child_fminf, y, x, 0); + } + showResult(success); + + // + + fprintf(stderr, "fdimf : "); + for(y = -10;y < 10 && success;y += 0.15) { + for(x = -10;x < 10 && success;x += 0.15) checkAccuracy_f_f(mpfr_dim, child_fdimf, y, x, 0.5); + } + for(y = -1e+7;y < 1e+7 && success;y += 1.51e+5) { + for(x = -1e+7;x < 1e+7 && success;x += 1.51e+5) checkAccuracy_f_f(mpfr_dim, child_fdimf, y, x, 0.5); + } + showResult(success); + + // + + fprintf(stderr, "fmodf : "); + for(y = -10;y < 10 && success;y += 0.15) { + for(x = -10;x < 10 && success;x += 0.15) checkAccuracy_f_f(mpfr_fmod, child_fmodf, y, x, 0.5); + } + for(y = -1e+7;y < 1e+7 && success;y += 1.51e+5) { + for(x = -1e+7;x < 1e+7 && success;x += 1.51e+5) checkAccuracy_f_f(mpfr_fmod, child_fmodf, y, x, 0.5); + } + showResult(success); + + // + + fprintf(stderr, "remainderf : "); + for(y = -10;y < 10 && success;y += 0.15) { + for(x = -10;x < 10 && success;x += 0.15) checkAccuracy_f_f(mpfr_remainder, child_remainderf, y, x, 0.5); + } + for(y = -1e+7;y < 1e+7 && success;y += 1.51e+5) { + for(x = -1e+7;x < 1e+7 && success;x += 1.51e+5) checkAccuracy_f_f(mpfr_remainder, child_remainderf, y, x, 0.5); + } + checkAccuracy_f_f(mpfr_remainder, child_remainderf, 11114942644092928.0, 224544296009728.0, 0.5); + showResult(success); + + // + + fprintf(stderr, "truncf : "); + for(x = -100.5;x <= 100.5;x+=0.5) { + for(d = u2d(d2u(x)-3);d <= u2d(d2u(x)+3) && success;d = u2d(d2u(d)+1)) checkAccuracyNR_f(mpfr_trunc, child_truncf, d, 0); + } + for(d = -10000;d < 10000 && success;d += 2.5) checkAccuracyNR_f(mpfr_trunc, child_truncf, d, 0); + { + double start = u2f(f2u((double)(INT64_C(1) << 23))-20), end = u2f(f2u((double)(INT64_C(1) << 23))+20); + for(d = start;d <= end;d = u2f(f2u(d)+1)) checkAccuracyNR_f(mpfr_trunc, child_truncf, d, 0); + for(d = start;d <= end;d = u2f(f2u(d)+1)) checkAccuracyNR_f(mpfr_trunc, child_truncf, -d, 0); + } + showResult(success); + + // + + fprintf(stderr, "floorf : "); + for(x = -100.5;x <= 100.5;x+=0.5) { + for(d = u2d(d2u(x)-3);d <= u2d(d2u(x)+3) && success;d = u2d(d2u(d)+1)) checkAccuracyNR_f(mpfr_floor, child_floorf, d, 0); + } + for(d = -10000;d < 10000 && success;d += 2.5) checkAccuracyNR_f(mpfr_floor, child_floorf, d, 0); + { + double start = u2f(f2u((double)(INT64_C(1) << 23))-20), end = u2f(f2u((double)(INT64_C(1) << 23))+20); + for(d = start;d <= end;d = u2f(f2u(d)+1)) checkAccuracyNR_f(mpfr_floor, child_floorf, d, 0); + for(d = start;d <= end;d = u2f(f2u(d)+1)) checkAccuracyNR_f(mpfr_floor, child_floorf, -d, 0); + } + showResult(success); + + // + + fprintf(stderr, "ceilf : "); + for(x = -100.5;x <= 100.5;x+=0.5) { + for(d = u2d(d2u(x)-3);d <= u2d(d2u(x)+3) && success;d = u2d(d2u(d)+1)) checkAccuracyNR_f(mpfr_ceil, child_ceilf, d, 0); + } + for(d = -10000;d < 10000 && success;d += 2.5) checkAccuracyNR_f(mpfr_ceil, child_ceilf, d, 0); + { + double start = u2f(f2u((double)(INT64_C(1) << 23))-20), end = u2f(f2u((double)(INT64_C(1) << 23))+20); + for(d = start;d <= end;d = u2f(f2u(d)+1)) checkAccuracyNR_f(mpfr_ceil, child_ceilf, d, 0); + for(d = start;d <= end;d = u2f(f2u(d)+1)) checkAccuracyNR_f(mpfr_ceil, child_ceilf, -d, 0); + } + showResult(success); + + // + + fprintf(stderr, "roundf : "); + for(x = -100.5;x <= 100.5;x+=0.5) { + for(d = u2d(d2u(x)-3);d <= u2d(d2u(x)+3) && success;d = u2d(d2u(d)+1)) checkAccuracyNR_f(mpfr_round, child_roundf, d, 0); + } + for(d = -10000;d < 10000 && success;d += 2.5) checkAccuracyNR_f(mpfr_round, child_roundf, d, 0); + { + double start = u2f(f2u((double)(INT64_C(1) << 23))-20), end = u2f(f2u((double)(INT64_C(1) << 23))+20); + for(d = start;d <= end;d = u2f(f2u(d)+1)) checkAccuracyNR_f(mpfr_round, child_roundf, d, 0); + for(d = start;d <= end;d = u2f(f2u(d)+1)) checkAccuracyNR_f(mpfr_round, child_roundf, -d, 0); + } + showResult(success); + + // + + fprintf(stderr, "rintf : "); + for(x = -100.5;x <= 100.5;x+=0.5) { + for(d = u2d(d2u(x)-3);d <= u2d(d2u(x)+3) && success;d = u2d(d2u(d)+1)) checkAccuracy_f(mpfr_rint, child_rintf, d, 0); + } + for(d = -10000;d < 10000 && success;d += 2.5) checkAccuracy_f(mpfr_rint, child_rintf, d, 0); + { + double start = u2f(f2u((double)(INT64_C(1) << 23))-20), end = u2f(f2u((double)(INT64_C(1) << 23))+20); + for(d = start;d <= end;d = u2f(f2u(d)+1)) checkAccuracy_f(mpfr_rint, child_rintf, d, 0); + for(d = start;d <= end;d = u2f(f2u(d)+1)) checkAccuracy_f(mpfr_rint, child_rintf, -d, 0); + } + showResult(success); + + // + + fprintf(stderr, "sinf : "); + for(d = -10;d < 10 && success;d += 0.002) checkAccuracy_f(mpfr_sin, child_sinf, d, 3.5); + for(d = -10000;d < 10000 && success;d += 1.1) checkAccuracy_f(mpfr_sin, child_sinf, d, 3.5); + for(i = 0;i < 1000 && success;i++) checkAccuracy_f(mpfr_sin, child_sinf, pow(1.092, i), 3.5); + for(i64=(int64_t)-1000;i64<(int64_t)1000 && success;i64+=(int64_t)1) { + double start = u2f(f2u(M_PI_4 * i64)-20), end = u2f(f2u(M_PI_4 * i64)+20); + for(d = start;d <= end;d = u2f(f2u(d)+1)) checkAccuracy_f(mpfr_sin, child_sinf, d, 3.5); + } + showResult(success); + + // + + fprintf(stderr, "sinf_u1 : "); + for(d = -10;d < 10 && success;d += 0.002) checkAccuracy_f(mpfr_sin, child_sinf_u1, d, 1.0); + for(d = -10000;d < 10000 && success;d += 1.1) checkAccuracy_f(mpfr_sin, child_sinf_u1, d, 1.0); + for(i = 0;i < 1000 && success;i++) checkAccuracy_f(mpfr_sin, child_sinf_u1, pow(1.092, i), 1.0); + for(i64=(int64_t)-1000;i64<(int64_t)1000 && success;i64+=(int64_t)1) { + double start = u2f(f2u(M_PI_4 * i64)-20), end = u2f(f2u(M_PI_4 * i64)+20); + for(d = start;d <= end;d = u2f(f2u(d)+1)) checkAccuracy_f(mpfr_sin, child_sinf_u1, d, 1.0); + } + showResult(success); + + // + + fprintf(stderr, "sin in sincosf : "); + for(d = -10;d < 10 && success;d += 0.002) checkAccuracyX_f(mpfr_sin, child_sincosf, d, 3.5); + for(d = -10000;d < 10000 && success;d += 1.1) checkAccuracyX_f(mpfr_sin, child_sincosf, d, 3.5); + for(i = 0;i < 1000 && success;i++) checkAccuracyX_f(mpfr_sin, child_sincosf, pow(1.092, i), 3.5); + for(i=1;i<10000 && success;i+=31) { + double start = u2f(f2u(M_PI_4 * i)-20), end = u2f(f2u(M_PI_4 * i)+20); + for(d = start;d <= end;d = u2f(f2u(d)+1)) checkAccuracyX_f(mpfr_sin, child_sincosf, d, 3.5); + } + showResult(success); + + // + + fprintf(stderr, "sin in sincosf_u1 : "); + for(d = -10;d < 10 && success;d += 0.002) checkAccuracyX_f(mpfr_sin, child_sincosf_u1, d, 1.0); + for(d = -10000;d < 10000 && success;d += 1.1) checkAccuracyX_f(mpfr_sin, child_sincosf_u1, d, 1.0); + for(i = 0;i < 1000 && success;i++) checkAccuracyX_f(mpfr_sin, child_sincosf_u1, pow(1.092, i), 1.0); + for(i=1;i<10000 && success;i+=31) { + double start = u2f(f2u(M_PI_4 * i)-20), end = u2f(f2u(M_PI_4 * i)+20); + for(d = start;d <= end;d = u2f(f2u(d)+1)) checkAccuracyX_f(mpfr_sin, child_sincosf_u1, d, 1.0); + } + showResult(success); + + // + + // 256 > 128(=maximum SP exponent) + 24(=number of bits in SP mantissa) + mpfr_set_default_prec(256); + + fprintf(stderr, "sin in sincospif_u35 : "); + for(d = -10.1;d < 10 && success;d += 0.0021) checkAccuracyX_f(mpfr_sinpi, child_sincospif_u35, d, 3.5); + for(d = -10000-0.1;d < 10000 && success;d += 1.1) checkAccuracyX_f(mpfr_sinpi, child_sincospif_u35, d, 3.5); + for(i=1;i<10000 && success;i+=31) { + double start = u2f(f2u(i)-20), end = u2f(f2u(i)+20); + for(d = start;d <= end;d = u2f(f2u(d)+1)) checkAccuracyX_f(mpfr_sinpi, child_sincospif_u35, d, 3.5); + } + for(i=1;i<=20 && success;i++) { + double start = u2f(f2u(0.25 * i)-20), end = u2f(f2u(0.25 * i)+20); + for(d = start;d <= end;d = u2f(f2u(d)+1)) checkAccuracyX_f(mpfr_sinpi, child_sincospif_u35, d, 3.5); + } + showResult(success); + + // + + fprintf(stderr, "sin in sincospif_u05 : "); + for(d = -10.1;d < 10 && success;d += 0.0021) checkAccuracyX_f(mpfr_sinpi, child_sincospif_u05, d, 0.506); + for(d = -10000-0.1;d < 10000 && success;d += 1.1) checkAccuracyX_f(mpfr_sinpi, child_sincospif_u05, d, 0.506); + for(i=1;i<10000 && success;i+=31) { + double start = u2f(f2u(i)-20), end = u2f(f2u(i)+20); + for(d = start;d <= end;d = u2f(f2u(d)+1)) checkAccuracyX_f(mpfr_sinpi, child_sincospif_u05, d, 0.506); + } + for(i=1;i<=20 && success;i++) { + double start = u2f(f2u(0.25 * i)-20), end = u2f(f2u(0.25 * i)+20); + for(d = start;d <= end;d = u2f(f2u(d)+1)) checkAccuracyX_f(mpfr_sinpi, child_sincospif_u05, d, 0.506); + } + showResult(success); + + // + + fprintf(stderr, "sinpif_u05 : "); + for(d = -10.1;d < 10 && success;d += 0.0021) checkAccuracy_f(mpfr_sinpi, child_sinpif_u05, d, 0.506); + for(d = -10000-0.1;d < 10000 && success;d += 1.1) checkAccuracy_f(mpfr_sinpi, child_sinpif_u05, d, 0.506); + for(i=1;i<10000 && success;i+=31) { + double start = u2f(f2u(i)-20), end = u2f(f2u(i)+20); + for(d = start;d <= end;d = u2f(f2u(d)+1)) checkAccuracy_f(mpfr_sinpi, child_sinpif_u05, d, 0.506); + } + for(i=1;i<=20 && success;i++) { + double start = u2f(f2u(0.25 * i)-20), end = u2f(f2u(0.25 * i)+20); + for(d = start;d <= end;d = u2f(f2u(d)+1)) checkAccuracy_f(mpfr_sinpi, child_sinpif_u05, d, 0.506); + } + showResult(success); + + // + + fprintf(stderr, "cospif_u05 : "); + for(d = -10.1;d < 10 && success;d += 0.0021) checkAccuracy_f(mpfr_cospi, child_cospif_u05, d, 0.506); + for(d = -10000-0.1;d < 10000 && success;d += 1.1) checkAccuracy_f(mpfr_cospi, child_cospif_u05, d, 0.506); + for(i=1;i<10000 && success;i+=31) { + double start = u2f(f2u(i)-20), end = u2f(f2u(i)+20); + for(d = start;d <= end;d = u2f(f2u(d)+1)) checkAccuracy_f(mpfr_cospi, child_cospif_u05, d, 0.506); + } + for(i=1;i<=20 && success;i++) { + double start = u2f(f2u(0.25 * i)-20), end = u2f(f2u(0.25 * i)+20); + for(d = start;d <= end;d = u2f(f2u(d)+1)) checkAccuracy_f(mpfr_cospi, child_cospif_u05, d, 0.506); + } + showResult(success); + + mpfr_set_default_prec(53); + + // + + fprintf(stderr, "cosf : "); + for(d = -10;d < 10 && success;d += 0.002) checkAccuracy_f(mpfr_cos, child_cosf, d, 3.5); + for(d = -10000;d < 10000 && success;d += 1.1) checkAccuracy_f(mpfr_cos, child_cosf, d, 3.5); + for(i = 0;i < 1000 && success;i++) checkAccuracy_f(mpfr_cos, child_cosf, pow(1.092, i), 3.5); + for(i64=(int64_t)-1000;i64<(int64_t)1000 && success;i64+=(int64_t)1) { + double start = u2f(f2u(M_PI_4 * i64)-20), end = u2f(f2u(M_PI_4 * i64)+20); + for(d = start;d <= end;d = u2f(f2u(d)+1)) checkAccuracy_f(mpfr_cos, child_cosf, d, 3.5); + } + showResult(success); + + // + + fprintf(stderr, "cosf_u1 : "); + for(d = -10;d < 10 && success;d += 0.002) checkAccuracy_f(mpfr_cos, child_cosf_u1, d, 1.0); + for(d = -10000;d < 10000 && success;d += 1.1) checkAccuracy_f(mpfr_cos, child_cosf_u1, d, 1.0); + for(i = 0;i < 1000 && success;i++) checkAccuracy_f(mpfr_cos, child_cosf_u1, pow(1.092, i), 1.0); + for(i64=(int64_t)-1000;i64<(int64_t)1000 && success;i64+=(int64_t)1) { + double start = u2f(f2u(M_PI_4 * i64)-20), end = u2f(f2u(M_PI_4 * i64)+20); + for(d = start;d <= end;d = u2f(f2u(d)+1)) checkAccuracy_f(mpfr_cos, child_cosf_u1, d, 1.0); + } + showResult(success); + + // + + fprintf(stderr, "cos in sincosf : "); + for(d = -10;d < 10 && success;d += 0.002) checkAccuracyY_f(mpfr_cos, child_sincosf, d, 3.5); + for(d = -10000;d < 10000 && success;d += 1.1) checkAccuracyY_f(mpfr_cos, child_sincosf, d, 3.5); + for(i = 0;i < 1000 && success;i++) checkAccuracyY_f(mpfr_cos, child_sincosf, pow(1.092, i), 3.5); + for(i=1;i<10000 && success;i+=31) { + double start = u2f(f2u(M_PI_4 * i)-20), end = u2f(f2u(M_PI_4 * i)+20); + for(d = start;d <= end;d = u2f(f2u(d)+1)) checkAccuracyY_f(mpfr_cos, child_sincosf, d, 3.5); + } + showResult(success); + + // + + fprintf(stderr, "cos in sincosf_u1 : "); + for(d = -10;d < 10 && success;d += 0.002) checkAccuracyY_f(mpfr_cos, child_sincosf_u1, d, 1.0); + for(d = -10000;d < 10000 && success;d += 1.1) checkAccuracyY_f(mpfr_cos, child_sincosf_u1, d, 1.0); + for(i = 0;i < 1000 && success;i++) checkAccuracyY_f(mpfr_cos, child_sincosf_u1, pow(1.092, i), 1.0); + for(i=1;i<10000 && success;i+=31) { + double start = u2f(f2u(M_PI_4 * i)-20), end = u2f(f2u(M_PI_4 * i)+20); + for(d = start;d <= end;d = u2f(f2u(d)+1)) checkAccuracyY_f(mpfr_cos, child_sincosf_u1, d, 1.0); + } + showResult(success); + + // + + mpfr_set_default_prec(256); + + fprintf(stderr, "cos in sincospif_u35 : "); + for(d = -10.1;d < 10 && success;d += 0.0021) checkAccuracyY_f(mpfr_cospi, child_sincospif_u35, d, 3.5); + for(d = -10000-0.1;d < 10000 && success;d += 1.1) checkAccuracyY_f(mpfr_cospi, child_sincospif_u35, d, 3.5); + for(i=1;i<10000 && success;i+=31) { + double start = u2f(f2u(i)-20), end = u2f(f2u(i)+20); + for(d = start;d <= end;d = u2f(f2u(d)+1)) checkAccuracyY_f(mpfr_cospi, child_sincospif_u35, d, 3.5); + } + for(i=1;i<=20 && success;i++) { + double start = u2f(f2u(0.25 * i)-20), end = u2f(f2u(0.25 * i)+20); + for(d = start;d <= end;d = u2f(f2u(d)+1)) checkAccuracyY_f(mpfr_cospi, child_sincospif_u35, d, 3.5); + } + showResult(success); + + // + + fprintf(stderr, "cos in sincospif_u05 : "); + for(d = -10.1;d < 10 && success;d += 0.0021) checkAccuracyY_f(mpfr_cospi, child_sincospif_u05, d, 0.506); + for(d = -10000-0.1;d < 10000 && success;d += 1.1) checkAccuracyY_f(mpfr_cospi, child_sincospif_u05, d, 0.506); + for(i=1;i<10000 && success;i+=31) { + double start = u2f(f2u(i)-20), end = u2f(f2u(i)+20); + for(d = start;d <= end;d = u2f(f2u(d)+1)) checkAccuracyY_f(mpfr_cospi, child_sincospif_u05, d, 0.506); + } + for(i=1;i<=20 && success;i++) { + double start = u2f(f2u(0.25 * i)-20), end = u2f(f2u(0.25 * i)+20); + for(d = start;d <= end;d = u2f(f2u(d)+1)) checkAccuracyY_f(mpfr_cospi, child_sincospif_u05, d, 0.506); + } + showResult(success); + + mpfr_set_default_prec(53); + + // + + fprintf(stderr, "fastsinf_u3500 : "); + for(d = -32;d < 32 && success;d += 0.001) checkAccuracy2_f(mpfr_sin, child_fastsinf_u3500, d, 350, 2e-6); + showResult(success); + + fprintf(stderr, "fastcosf_u3500 : "); + for(d = -32;d < 32 && success;d += 0.001) checkAccuracy2_f(mpfr_cos, child_fastcosf_u3500, d, 350, 2e-6); + showResult(success); + + // + + fprintf(stderr, "tanf : "); + checkAccuracy_f(mpfr_tan, child_tanf, 70.936981201171875, 3.5); + for(d = -10;d < 10 && success;d += 0.002) checkAccuracy_f(mpfr_tan, child_tanf, d, 3.5); + for(d = -10000;d < 10000 && success;d += 1.1) checkAccuracy_f(mpfr_tan, child_tanf, d, 3.5); + for(i = 0;i < 1000 && success;i++) checkAccuracy_f(mpfr_tan, child_tanf, pow(1.092, i), 3.5); + for(i=1;i<10000 && success;i+=31) { + double start = u2f(f2u(M_PI_4 * i)-20), end = u2f(f2u(M_PI_4 * i)+20); + for(d = start;d <= end;d = u2f(f2u(d)+1)) checkAccuracy_f(mpfr_tan, child_tanf, d, 3.5); + } + showResult(success); + + // + + fprintf(stderr, "tanf_u1 : "); + for(d = -10;d < 10 && success;d += 0.002) checkAccuracy_f(mpfr_tan, child_tanf_u1, d, 1.0); + for(d = -10000;d < 10000 && success;d += 1.1) checkAccuracy_f(mpfr_tan, child_tanf_u1, d, 1.0); + for(i = 0;i < 1000 && success;i++) checkAccuracy_f(mpfr_tan, child_tanf_u1, pow(1.092, i), 1.0); + for(i=1;i<10000 && success;i+=31) { + double start = u2f(f2u(M_PI_4 * i)-20), end = u2f(f2u(M_PI_4 * i)+20); + for(d = start;d <= end;d = u2f(f2u(d)+1)) checkAccuracy_f(mpfr_tan, child_tanf_u1, d, 1.0); + } + showResult(success); + + // + + fprintf(stderr, "logf : "); + for(d = 0.0001;d < 10 && success;d += 0.001) checkAccuracy_f(mpfr_log, child_logf, d, 3.5); + for(d = 0.0001;d < 10000 && success;d += 1.1) checkAccuracy_f(mpfr_log, child_logf, d, 3.5); + for(i = -1000;i <= 1000 && success;i+=10) checkAccuracy_f(mpfr_log, child_logf, pow(2.1, i), 3.5); + for(i=0;i<10000 && success;i+=10) checkAccuracy_f(mpfr_log, child_logf, FLT_MAX * pow(0.9314821319758632, i), 3.5); + for(i=0;i<10000 && success;i+=10) checkAccuracy_f(mpfr_log, child_logf, pow(0.933254300796991, i), 3.5); + for(i=0;i<10000 && success;i+=10) checkAccuracy_f(mpfr_log, child_logf, FLT_MIN * pow(0.996323, i), 3.5); + showResult(success); + + // + + fprintf(stderr, "logf_u1 : "); + for(d = 0.0001;d < 10 && success;d += 0.001) checkAccuracy_f(mpfr_log, child_logf_u1, d, 1.0); + for(d = 0.0001;d < 10000 && success;d += 1.1) checkAccuracy_f(mpfr_log, child_logf_u1, d, 1.0); + + if (!enableFlushToZero) { + for(i=0;i<10000 && success;i+=10) checkAccuracy_f(mpfr_log, child_logf_u1, FLT_MAX * pow(0.9314821319758632, i), 1.0); + for(i = -1000;i <= 1000 && success;i+=10) checkAccuracy_f(mpfr_log, child_logf_u1, pow(2.1, i), 1.0); + for(i=0;i<10000 && success;i+=10) checkAccuracy_f(mpfr_log, child_logf_u1, pow(0.933254300796991, i), 1.0); + for(i=0;i<10000 && success;i+=10) checkAccuracy_f(mpfr_log, child_logf_u1, FLT_MIN * pow(0.996323, i), 1.0); + for(d = 0.0001;d < 10 && success;d += 0.001) checkAccuracy_f(mpfr_log, child_logf_u1, d, 1.0); + for(d = 0.0001;d < 10000 && success;d += 1.1) checkAccuracy_f(mpfr_log, child_logf_u1, d, 1.0); + } + showResult(success); + + // + + fprintf(stderr, "expf : "); + for(d = -10;d < 10 && success;d += 0.002) checkAccuracy_f(mpfr_exp, child_expf, d, 1.0); + if (!enableFlushToZero) { + for(d = -1000;d < 1000 && success;d += 1.1) checkAccuracy_f(mpfr_exp, child_expf, d, 1.0); + } + showResult(success); + + // + + fprintf(stderr, "powf : "); + if (!enableFlushToZero) { + for(y = 0.1;y < 100 && success;y += 0.6) { + for(x = -100;x < 100 && success;x += 0.6) { + checkAccuracy_f_f(mpfr_pow, child_powf, x, y, 1.0); + } + } + for(y = -1000;y < 1000 && success;y += 0.1) checkAccuracy_f_f(mpfr_pow, child_powf, 2.1, y, 1.0); + } else { + for(y = 0.1;y < 10 && success;y += 0.06) { + for(x = -100;x < 10 && success;x += 0.06) { + checkAccuracy_f_f(mpfr_pow, child_powf, x, y, 1.0); + } + } + } + showResult(success); + + // + + fprintf(stderr, "fastpowf_u3500 : "); + for(y = -25;y < 25 && success;y += 0.121) { + for(x = 0.1;x < 25 && success;x += 0.251) { + checkAccuracy_f_f(mpfr_pow, child_fastpowf_u3500, x, y, 350); + } + } + showResult(success); + + // + + if (!deterministicMode) { + fprintf(stderr, "sqrtf : "); + if (!enableFlushToZero) { + for(d = -10000;d < 10000 && success;d += 2.1) checkAccuracy_f(mpfr_sqrt, child_sqrtf, d, 1.0); + } + for(i = -1000;i <= 1000 && success;i+=10) checkAccuracy_f(mpfr_sqrt, child_sqrtf, pow(2.1, d), 1.0); + showResult(success); + + // + + fprintf(stderr, "sqrtf_u05 : "); + if (!enableFlushToZero) { + for(d = -10000;d < 10000 && success;d += 2.1) checkAccuracy_f(mpfr_sqrt, child_sqrtf_u05, d, 0.506); + } + for(i = -1000;i <= 1000 && success;i+=10) checkAccuracy_f(mpfr_sqrt, child_sqrtf_u05, pow(2.1, d), 0.506); + showResult(success); + + // + + fprintf(stderr, "sqrtf_u35 : "); + if (!enableFlushToZero) { + for(d = -10000;d < 10000 && success;d += 2.1) checkAccuracy_f(mpfr_sqrt, child_sqrtf_u35, d, 3.5); + } + for(i = -1000;i <= 1000 && success;i+=10) checkAccuracy_f(mpfr_sqrt, child_sqrtf_u35, pow(2.1, d), 3.5); + showResult(success); + } + + // + + fprintf(stderr, "cbrtf : "); + if (!enableFlushToZero) { + for(d = -10000;d < 10000 && success;d += 2.1) checkAccuracy_f(mpfr_cbrt, child_cbrtf, d, 3.5); + } + for(i = -1000;i <= 1000 && success;i+=10) checkAccuracy_f(mpfr_cbrt, child_cbrtf, pow(2.1, d), 3.5); + showResult(success); + + // + + fprintf(stderr, "cbrtf_u1 : "); + if (!enableFlushToZero) { + for(d = -10000;d < 10000 && success;d += 2.1) checkAccuracy_f(mpfr_cbrt, child_cbrtf_u1, d, 1.0); + } + for(i = -1000;i <= 1000 && success;i+=10) checkAccuracy_f(mpfr_cbrt, child_cbrtf_u1, pow(2.1, d), 1.0); + showResult(success); + + // + + fprintf(stderr, "asinf : "); + for(d = -1;d < 1 && success;d += 0.0002) checkAccuracy_f(mpfr_asin, child_asinf, d, 3.5); + showResult(success); + + // + + fprintf(stderr, "asinf_u1 : "); + for(d = -1;d < 1 && success;d += 0.0002) checkAccuracy_f(mpfr_asin, child_asinf_u1, d, 1.0); + showResult(success); + + // + + fprintf(stderr, "acosf : "); + for(d = -1;d < 1 && success;d += 0.0002) checkAccuracy_f(mpfr_acos, child_acosf, d, 3.5); + showResult(success); + + // + + fprintf(stderr, "acosf_u1 : "); + for(d = -1;d < 1 && success;d += 0.0002) checkAccuracy_f(mpfr_acos, child_acosf_u1, d, 1.0); + showResult(success); + + // + + fprintf(stderr, "atanf : "); + for(d = -10;d < 10 && success;d += 0.002) checkAccuracy_f(mpfr_atan, child_atanf, d, 3.5); + for(d = -10000;d < 10000 && success;d += 2.1) checkAccuracy_f(mpfr_atan, child_atanf, d, 3.5); + showResult(success); + + // + + fprintf(stderr, "atanf_u1 : "); + for(d = -10;d < 10 && success;d += 0.002) checkAccuracy_f(mpfr_atan, child_atanf_u1, d, 1.0); + for(d = -10000;d < 10000 && success;d += 2.1) checkAccuracy_f(mpfr_atan, child_atanf_u1, d, 1.0); + showResult(success); + + // + + fprintf(stderr, "atan2f : "); + for(y = -10;y < 10 && success;y += 0.15) { + for(x = -10;x < 10 && success;x += 0.15) checkAccuracy_f_f(mpfr_atan2, child_atan2f, y, x, 3.5); + } + for(y = -100;y < 100 && success;y += 1.51) { + for(x = -100;x < 100 && success;x += 1.51) checkAccuracy_f_f(mpfr_atan2, child_atan2f, y, x, 3.5); + } + showResult(success); + + // + + fprintf(stderr, "atan2f_u1 : "); + for(y = -10;y < 10 && success;y += 0.15) { + for(x = -10;x < 10 && success;x += 0.15) checkAccuracy_f_f(mpfr_atan2, child_atan2f_u1, y, x, 1.0); + } + for(y = -100;y < 100 && success;y += 1.51) { + for(x = -100;x < 100 && success;x += 1.51) checkAccuracy_f_f(mpfr_atan2, child_atan2f_u1, y, x, 1.0); + } + showResult(success); + + // + + fprintf(stderr, "sinhf : "); + for(d = -10;d < 10 && success;d += 0.002) checkAccuracy_f(mpfr_sinh, child_sinhf, d, 1.0); + if (!enableFlushToZero) { + for(d = -88;d < 88 && success;d += 0.2) checkAccuracy_f(mpfr_sinh, child_sinhf, d, 1.0); + } + showResult(success); + + // + + fprintf(stderr, "coshf : "); + for(d = -10;d < 10 && success;d += 0.002) checkAccuracy_f(mpfr_cosh, child_coshf, d, 1.0); + if (!enableFlushToZero) { + for(d = -88;d < 88 && success;d += 0.2) checkAccuracy_f(mpfr_cosh, child_coshf, d, 1.0); + } + showResult(success); + + // + + fprintf(stderr, "tanhf : "); + for(d = -10;d < 10 && success;d += 0.002) checkAccuracy_f(mpfr_tanh, child_tanhf, d, 1.0); + if (!enableFlushToZero) { + for(d = -1000;d < 1000 && success;d += 0.2) checkAccuracy_f(mpfr_tanh, child_tanhf, d, 1.0); + } + showResult(success); + + // + + fprintf(stderr, "sinhf_u35 : "); + for(d = -10;d < 10 && success;d += 0.002) checkAccuracy_f(mpfr_sinh, child_sinhf_u35, d, 3.5); + if (!enableFlushToZero) { + for(d = -88;d < 88 && success;d += 0.2) checkAccuracy_f(mpfr_sinh, child_sinhf_u35, d, 3.5); + } + showResult(success); + + // + + fprintf(stderr, "coshf_u35 : "); + for(d = -10;d < 10 && success;d += 0.002) checkAccuracy_f(mpfr_cosh, child_coshf_u35, d, 3.5); + if (!enableFlushToZero) { + for(d = -88;d < 88 && success;d += 0.2) checkAccuracy_f(mpfr_cosh, child_coshf_u35, d, 3.5); + } + showResult(success); + + // + + fprintf(stderr, "tanhf_u35 : "); + for(d = -10;d < 10 && success;d += 0.002) checkAccuracy_f(mpfr_tanh, child_tanhf_u35, d, 3.5); + if (!enableFlushToZero) { + for(d = -1000;d < 1000 && success;d += 0.2) checkAccuracy_f(mpfr_tanh, child_tanhf_u35, d, 3.5); + } + showResult(success); + + // + + fprintf(stderr, "asinhf : "); + for(d = -10;d < 10 && success;d += 0.002) checkAccuracy_f(mpfr_asinh, child_asinhf, d, 1.0); + if (!enableFlushToZero) { + for(d = -1000;d < 1000 && success;d += 0.2) checkAccuracy_f(mpfr_asinh, child_asinhf, d, 1.0); + } + showResult(success); + + // + + fprintf(stderr, "acoshf : "); + for(d = 1;d < 10 && success;d += 0.002) checkAccuracy_f(mpfr_acosh, child_acoshf, d, 1.0); + if (!enableFlushToZero) { + for(d = 1;d < 1000 && success;d += 0.2) checkAccuracy_f(mpfr_acosh, child_acoshf, d, 1.0); + } + showResult(success); + + // + + fprintf(stderr, "atanhf : "); + for(d = -10;d < 10 && success;d += 0.002) checkAccuracy_f(mpfr_atanh, child_atanhf, d, 1.0); + if (!enableFlushToZero) { + for(d = -1000;d < 1000 && success;d += 0.2) checkAccuracy_f(mpfr_atanh, child_atanhf, d, 1.0); + } + showResult(success); + + // + + fprintf(stderr, "exp2f : "); + for(d = -10;d < 10 && success;d += 0.002) checkAccuracy_f(mpfr_exp2, child_exp2f, d, 1.0); + if (!enableFlushToZero) { + for(d = -1000;d < 1000 && success;d += 0.2) checkAccuracy_f(mpfr_exp2, child_exp2f, d, 1.0); + } + showResult(success); + + // + + fprintf(stderr, "exp10f : "); + for(d = -10;d < 10 && success;d += 0.002) checkAccuracy_f(mpfr_exp10, child_exp10f, d, 1.0); + if (!enableFlushToZero) { + for(d = -300;d < 300 && success;d += 0.1) checkAccuracy_f(mpfr_exp10, child_exp10f, d, 1.0); + } + showResult(success); + + // + + fprintf(stderr, "exp2f_u35 : "); + for(d = -10;d < 10 && success;d += 0.002) checkAccuracy_f(mpfr_exp2, child_exp2f_u35, d, 3.5); + if (!enableFlushToZero) { + for(d = -1000;d < 1000 && success;d += 0.2) checkAccuracy_f(mpfr_exp2, child_exp2f_u35, d, 3.5); + } + showResult(success); + + // + + fprintf(stderr, "exp10f_u35 : "); + for(d = -10;d < 10 && success;d += 0.002) checkAccuracy_f(mpfr_exp10, child_exp10f_u35, d, 3.5); + if (!enableFlushToZero) { + for(d = -300;d < 300 && success;d += 0.1) checkAccuracy_f(mpfr_exp10, child_exp10f_u35, d, 3.5); + } + showResult(success); + + // + + fprintf(stderr, "expm1f : "); + for(d = -10;d < 10 && success;d += 0.002) checkAccuracy_f(mpfr_expm1, child_expm1f, d, 1.0); + if (!enableFlushToZero) { + for(d = -1000;d < 1000 && success;d += 0.21) checkAccuracy_f(mpfr_expm1, child_expm1f, d, 1.0); + for(d = 0;d < 300 && success;d += 0.21) checkAccuracy_f(mpfr_expm1, child_expm1f, pow(10, -d), 1.0); + for(d = 0;d < 300 && success;d += 0.21) checkAccuracy_f(mpfr_expm1, child_expm1f, (-pow(10, -d)), 1.0); + } + showResult(success); + + // + + fprintf(stderr, "log10f : "); + for(d = 0.0001;d < 10 && success;d += 0.001) checkAccuracy_f(mpfr_log10, child_log10f, d, 1.0); + for(d = 0.0001;d < 10000 && success;d += 1.1) checkAccuracy_f(mpfr_log10, child_log10f, d, 1.0); + for(i=0;i<10000 && success;i++) checkAccuracy_f(mpfr_log10, child_log10f, (FLT_MIN * pow(0.996323, i)), 1.0); + showResult(success); + + // + + fprintf(stderr, "log2f : "); + for(d = 0.0001;d < 10 && success;d += 0.001) checkAccuracy_f(mpfr_log2, child_log2f, d, 1.0); + for(d = 0.0001;d < 10000 && success;d += 1.1) checkAccuracy_f(mpfr_log2, child_log2f, d, 1.0); + for(i=0;i<10000 && success;i++) checkAccuracy_f(mpfr_log2, child_log2f, (FLT_MIN * pow(0.996323, i)), 1.0); + showResult(success); + + // + + fprintf(stderr, "log2f_u35 : "); + for(d = 0.0001;d < 10 && success;d += 0.001) checkAccuracy_f(mpfr_log2, child_log2f_u35, d, 3.5); + for(d = 0.0001;d < 10000 && success;d += 1.1) checkAccuracy_f(mpfr_log2, child_log2f_u35, d, 3.5); + for(i=0;i<10000 && success;i++) checkAccuracy_f(mpfr_log2, child_log2f_u35, (FLT_MIN * pow(0.996323, i)), 3.5); + showResult(success); + + // + + fprintf(stderr, "log1pf : "); + for(d = 0.0001;d < 10 && success;d += 0.001) checkAccuracy_f(mpfr_log1p, child_log1pf, d, 1.0); + showResult(success); + + // + + fprintf(stderr, "lgammaf_u1 : "); + for(d = -5000;d < 5000 && success;d += 1.1) checkAccuracy_f(mpfr_lgamma_nosign, child_lgammaf_u1, d, 1.0); + showResult(success); + + // + + fprintf(stderr, "tgammaf_u1 : "); + for(d = -10;d < 10 && success;d += 0.002) checkAccuracy_f(mpfr_gamma, child_tgammaf_u1, d, 1.0); + showResult(success); + + // + + fprintf(stderr, "erff_u1 : "); + for(d = -100;d < 100 && success;d += 0.02) checkAccuracy_f(mpfr_erf, child_erff_u1, d, 1.0); + showResult(success); + + // + + fprintf(stderr, "erfcf_u15 : "); + for(d = -1;d < 8 && success;d += 0.001) checkAccuracy_f(mpfr_erfc, child_erfcf_u15, d, 1.5); + showResult(success); + } + mpfr_clears(frc, frt, frx, fry, frz, NULL); +} + +int main(int argc, char **argv) { + char *argv2[argc+2], *commandSde = NULL, *commandQEmu = NULL; + int i, a2s; + + // BUGFIX: this flush is to prevent incorrect syncing with the + // `iut*` executable that causes failures in the CPU detection on + // some CI systems. + fflush(stdout); + + for(a2s=1;a2s +#include +#include +#include +#include +#include +#include + +#include + +#ifdef ENABLE_SYS_getrandom +#define _GNU_SOURCE +#include +#include +#include +#endif + +#include "sleef.h" +#include "testerutil.h" + +#define DORENAME +#include "rename.h" + +#define DENORMAL_DBL_MIN (4.9406564584124654418e-324) +#define POSITIVE_INFINITY INFINITY +#define NEGATIVE_INFINITY (-INFINITY) + +typedef union { + double d; + uint64_t u64; + int64_t i64; +} conv_t; + +double nexttoward0(double x, int n) { + union { + double f; + uint64_t u; + } cx; + cx.f = x; + cx.u -=n ; + return cx.f; +} + +double rnd() { + conv_t c; + switch(random() & 63) { + case 0: return nexttoward0( 0.0, -(random() & ((1 << (random() & 31)) - 1))); + case 1: return nexttoward0(-0.0, -(random() & ((1 << (random() & 31)) - 1))); + case 2: return nexttoward0( INFINITY, (random() & ((1 << (random() & 31)) - 1))); + case 3: return nexttoward0(-INFINITY, (random() & ((1 << (random() & 31)) - 1))); + } +#ifdef ENABLE_SYS_getrandom + syscall(SYS_getrandom, &c.u64, sizeof(c.u64), 0); +#else + c.u64 = random() | ((uint64_t)random() << 31) | ((uint64_t)random() << 62); +#endif + return c.d; +} + +double rnd_fr() { + conv_t c; + do { +#ifdef ENABLE_SYS_getrandom + syscall(SYS_getrandom, &c.u64, sizeof(c.u64), 0); +#else + c.u64 = random() | ((uint64_t)random() << 31) | ((uint64_t)random() << 62); +#endif + } while(!isnumber(c.d)); + return c.d; +} + +double rnd_zo() { + conv_t c; + do { +#ifdef ENABLE_SYS_getrandom + syscall(SYS_getrandom, &c.u64, sizeof(c.u64), 0); +#else + c.u64 = random() | ((uint64_t)random() << 31) | ((uint64_t)random() << 62); +#endif + } while(!isnumber(c.d) || c.d < -1 || 1 < c.d); + return c.d; +} + +int main(int argc,char **argv) +{ + mpfr_t frw, frx, fry, frz; + + mpfr_set_default_prec(1280); + mpfr_inits(frw, frx, fry, frz, NULL); + + conv_t cd; + double d, t; + double d2, d3, zo; + + int cnt, ecnt = 0; + + srandom(time(NULL)); + + for(cnt = 0;ecnt < 1000;cnt++) { + switch(cnt & 7) { + case 0: + d = rnd(); + d2 = rnd(); + d3 = rnd(); + zo = rnd(); + break; + case 1: + cd.d = rint(rnd_zo() * 1e+10) * M_PI_4; + cd.i64 += (random() & 0xff) - 0x7f; + d = cd.d; + d2 = rnd(); + d3 = rnd(); + zo = rnd(); + break; + case 2: + cd.d = rnd_fr() * M_PI_4; + cd.i64 += (random() & 0xf) - 0x7; + d = cd.d; + d2 = rnd(); + d3 = rnd(); + zo = rnd(); + break; + default: + d = rnd_fr(); + d2 = rnd_fr(); + d3 = rnd_fr(); + zo = rnd_zo(); + break; + } + + Sleef_double2 sc = xsincospi_u05(d); + Sleef_double2 sc2 = xsincospi_u35(d); + + { + const double rangemax2 = 1e+9/4; + + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_sinpi(frx, frx, GMP_RNDN); + + double u0 = countULP2dp(t = sc.x, frx); + + if (u0 != 0 && ((fabs(d) <= rangemax2 && u0 > 0.506) || fabs(t) > 1 || !isnumber(t))) { + printf("Pure C sincospi_u05 sin arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + + double u1 = countULP2dp(t = sc2.x, frx); + + if (u1 != 0 && ((fabs(d) <= rangemax2 && u1 > 1.5) || fabs(t) > 1 || !isnumber(t))) { + printf("Pure C sincospi_u35 sin arg=%.20g ulp=%.20g\n", d, u1); + fflush(stdout); ecnt++; + } + + double u2 = countULP2dp(t = xsinpi_u05(d), frx); + + if (u2 != 0 && ((fabs(d) <= rangemax2 && u2 > 0.506) || fabs(t) > 1 || !isnumber(t))) { + printf("Pure C sinpi_u05 arg=%.20g ulp=%.20g\n", d, u2); + fflush(stdout); ecnt++; + } + } + + { + const double rangemax2 = 1e+9/4; + + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_cospi(frx, frx, GMP_RNDN); + + double u0 = countULP2dp(t = sc.y, frx); + + if (u0 != 0 && ((fabs(d) <= rangemax2 && u0 > 0.506) || fabs(t) > 1 || !isnumber(t))) { + printf("Pure C sincospi_u05 cos arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + + double u1 = countULP2dp(t = sc.y, frx); + + if (u1 != 0 && ((fabs(d) <= rangemax2 && u1 > 1.5) || fabs(t) > 1 || !isnumber(t))) { + printf("Pure C sincospi_u35 cos arg=%.20g ulp=%.20g\n", d, u1); + fflush(stdout); ecnt++; + } + + double u2 = countULP2dp(t = xcospi_u05(d), frx); + + if (u2 != 0 && ((fabs(d) <= rangemax2 && u2 > 0.506) || fabs(t) > 1 || !isnumber(t))) { + printf("Pure C cospi_u05 arg=%.20g ulp=%.20g\n", d, u2); + fflush(stdout); ecnt++; + } + } + + sc = xsincos(d); + sc2 = xsincos_u1(d); + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_sin(frx, frx, GMP_RNDN); + + double u0 = countULPdp(t = xsin(d), frx); + + if (u0 != 0 && (u0 > 3.5 || fabs(t) > 1 || !isnumber(t))) { + printf("Pure C sin arg=%.20g ulp=%.20g\n", d, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + + double u1 = countULPdp(sc.x, frx); + + if (u1 != 0 && (u1 > 3.5 || fabs(t) > 1 || !isnumber(t))) { + printf("Pure C sincos sin arg=%.20g ulp=%.20g\n", d, u1); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + + double u2 = countULPdp(t = xsin_u1(d), frx); + + if (u2 != 0 && (u2 > 1 || fabs(t) > 1 || !isnumber(t))) { + printf("Pure C sin_u1 arg=%.20g ulp=%.20g\n", d, u2); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + + double u3 = countULPdp(t = sc2.x, frx); + + if (u3 != 0 && (u3 > 1 || fabs(t) > 1 || !isnumber(t))) { + printf("Pure C sincos_u1 sin arg=%.20g ulp=%.20g\n", d, u3); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_cos(frx, frx, GMP_RNDN); + + double u0 = countULPdp(t = xcos(d), frx); + + if (u0 != 0 && (u0 > 3.5 || fabs(t) > 1 || !isnumber(t))) { + printf("Pure C cos arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + + double u1 = countULPdp(t = sc.y, frx); + + if (u1 != 0 && (u1 > 3.5 || fabs(t) > 1 || !isnumber(t))) { + printf("Pure C sincos cos arg=%.20g ulp=%.20g\n", d, u1); + fflush(stdout); ecnt++; + } + + double u2 = countULPdp(t = xcos_u1(d), frx); + + if (u2 != 0 && (u2 > 1 || fabs(t) > 1 || !isnumber(t))) { + printf("Pure C cos_u1 arg=%.20g ulp=%.20g\n", d, u2); + fflush(stdout); ecnt++; + } + + double u3 = countULPdp(t = sc2.y, frx); + + if (u3 != 0 && (u3 > 1 || fabs(t) > 1 || !isnumber(t))) { + printf("Pure C sincos_u1 cos arg=%.20g ulp=%.20g\n", d, u3); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_tan(frx, frx, GMP_RNDN); + + double u0 = countULPdp(t = xtan(d), frx); + + if (u0 != 0 && (u0 > 3.5 || isnan(t))) { + printf("Pure C tan arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + + double u1 = countULPdp(t = xtan_u1(d), frx); + + if (u1 != 0 && (u1 > 1 || isnan(t))) { + printf("Pure C tan_u1 arg=%.20g ulp=%.20g\n", d, u1); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, fabs(d), GMP_RNDN); + mpfr_log(frx, frx, GMP_RNDN); + + double u0 = countULPdp(t = xlog(fabs(d)), frx); + + if (u0 > 3.5) { + printf("Pure C log arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + + double u1 = countULPdp(t = xlog_u1(fabs(d)), frx); + + if (u1 > 1) { + printf("Pure C log_u1 arg=%.20g ulp=%.20g\n", d, u1); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, fabs(d), GMP_RNDN); + mpfr_log10(frx, frx, GMP_RNDN); + + double u0 = countULPdp(t = xlog10(fabs(d)), frx); + + if (u0 > 1) { + printf("Pure C log10 arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, fabs(d), GMP_RNDN); + mpfr_log2(frx, frx, GMP_RNDN); + + double u0 = countULPdp(t = xlog2(fabs(d)), frx); + + if (u0 > 1) { + printf("Pure C log2 arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + + double u1 = countULPdp(t = xlog2_u35(fabs(d)), frx); + + if (u1 > 3.5) { + printf("Pure C log2_u35 arg=%.20g ulp=%.20g\n", d, u1); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_log1p(frx, frx, GMP_RNDN); + + double u0 = countULPdp(t = xlog1p(d), frx); + + if ((-1 <= d && d <= 1e+307 && u0 > 1) || + (d < -1 && !isnan(t)) || + (d > 1e+307 && !(u0 <= 1 || isinf(t)))) { + printf("Pure C log1p arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_exp(frx, frx, GMP_RNDN); + + double u0 = countULPdp(t = xexp(d), frx); + + if (u0 > 1) { + printf("Pure C exp arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_exp2(frx, frx, GMP_RNDN); + + double u0 = countULPdp(t = xexp2(d), frx); + + if (u0 > 1) { + printf("Pure C exp2 arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + + double u1 = countULPdp(t = xexp2_u35(d), frx); + + if (u1 > 3.5) { + printf("Pure C exp2_u35 arg=%.20g ulp=%.20g\n", d, u1); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_exp10(frx, frx, GMP_RNDN); + + double u0 = countULPdp(t = xexp10(d), frx); + + if (u0 > 1.09) { + printf("Pure C exp10 arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + + double u1 = countULPdp(t = xexp10_u35(d), frx); + + if (u1 > 3.5) { + printf("Pure C exp10_u35 arg=%.20g ulp=%.20g\n", d, u1); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_expm1(frx, frx, GMP_RNDN); + + double u0 = countULPdp(t = xexpm1(d), frx); + + if (u0 > 1) { + printf("Pure C expm1 arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_set_d(fry, d2, GMP_RNDN); + mpfr_pow(frx, fry, frx, GMP_RNDN); + + double u0 = countULPdp(t = xpow(d2, d), frx); + + if (u0 > 1) { + printf("Pure C pow arg=%.20g, %.20g ulp=%.20g\n", d2, d, u0); + printf("correct = %g, test = %g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_cbrt(frx, frx, GMP_RNDN); + + double u0 = countULPdp(t = xcbrt(d), frx); + + if (u0 > 3.5) { + printf("Pure C cbrt arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + + double u1 = countULPdp(t = xcbrt_u1(d), frx); + + if (u1 > 1) { + printf("Pure C cbrt_u1 arg=%.20g ulp=%.20g\n", d, u1); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, zo, GMP_RNDN); + mpfr_asin(frx, frx, GMP_RNDN); + + double u0 = countULPdp(t = xasin(zo), frx); + + if (u0 > 3.5) { + printf("Pure C asin arg=%.20g ulp=%.20g\n", zo, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + + double u1 = countULPdp(t = xasin_u1(zo), frx); + + if (u1 > 1) { + printf("Pure C asin_u1 arg=%.20g ulp=%.20g\n", zo, u1); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, zo, GMP_RNDN); + mpfr_acos(frx, frx, GMP_RNDN); + + double u0 = countULPdp(t = xacos(zo), frx); + + if (u0 > 3.5) { + printf("Pure C acos arg=%.20g ulp=%.20g\n", zo, u0); + fflush(stdout); ecnt++; + } + + double u1 = countULPdp(t = xacos_u1(zo), frx); + + if (u1 > 1) { + printf("Pure C acos_u1 arg=%.20g ulp=%.20g\n", zo, u1); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_atan(frx, frx, GMP_RNDN); + + double u0 = countULPdp(t = xatan(d), frx); + + if (u0 > 3.5) { + printf("Pure C atan arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + + double u1 = countULPdp(t = xatan_u1(d), frx); + + if (u1 > 1) { + printf("Pure C atan_u1 arg=%.20g ulp=%.20g\n", d, u1); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_set_d(fry, d2, GMP_RNDN); + mpfr_atan2(frx, fry, frx, GMP_RNDN); + + double u0 = countULPdp(t = xatan2(d2, d), frx); + + if (u0 > 3.5) { + printf("Pure C atan2 arg=%.20g, %.20g ulp=%.20g\n", d2, d, u0); + fflush(stdout); ecnt++; + } + + double u1 = countULP2dp(t = xatan2_u1(d2, d), frx); + + if (u1 > 1) { + printf("Pure C atan2_u1 arg=%.20g, %.20g ulp=%.20g\n", d2, d, u1); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_sinh(frx, frx, GMP_RNDN); + + double u0 = countULPdp(t = xsinh(d), frx); + + if ((fabs(d) <= 709 && u0 > 1) || + (d > 709 && !(u0 <= 1 || (isinf(t) && t > 0))) || + (d < -709 && !(u0 <= 1 || (isinf(t) && t < 0)))) { + printf("Pure C sinh arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_cosh(frx, frx, GMP_RNDN); + + double u0 = countULPdp(t = xcosh(d), frx); + + if ((fabs(d) <= 709 && u0 > 1) || !(u0 <= 1 || (isinf(t) && t > 0))) { + printf("Pure C cosh arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_tanh(frx, frx, GMP_RNDN); + + double u0 = countULPdp(t = xtanh(d), frx); + + if (u0 > 1) { + printf("Pure C tanh arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_sinh(frx, frx, GMP_RNDN); + + double u0 = countULPdp(t = xsinh_u35(d), frx); + + if ((fabs(d) <= 709 && u0 > 3.5) || + (d > 709 && !(u0 <= 3.5 || (isinf(t) && t > 0))) || + (d < -709 && !(u0 <= 3.5 || (isinf(t) && t < 0)))) { + printf("Pure C sinh_u35 arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_cosh(frx, frx, GMP_RNDN); + + double u0 = countULPdp(t = xcosh_u35(d), frx); + + if ((fabs(d) <= 709 && u0 > 3.5) || !(u0 <= 3.5 || (isinf(t) && t > 0))) { + printf("Pure C cosh_u35 arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_tanh(frx, frx, GMP_RNDN); + + double u0 = countULPdp(t = xtanh_u35(d), frx); + + if (u0 > 3.5) { + printf("Pure C tanh_u35 arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_asinh(frx, frx, GMP_RNDN); + + double u0 = countULPdp(t = xasinh(d), frx); + + if ((fabs(d) < sqrt(DBL_MAX) && u0 > 1) || + (d >= sqrt(DBL_MAX) && !(u0 <= 1 || (isinf(t) && t > 0))) || + (d <= -sqrt(DBL_MAX) && !(u0 <= 1 || (isinf(t) && t < 0)))) { + printf("Pure C asinh arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_acosh(frx, frx, GMP_RNDN); + + double u0 = countULPdp(t = xacosh(d), frx); + + if ((fabs(d) < sqrt(DBL_MAX) && u0 > 1) || + (d >= sqrt(DBL_MAX) && !(u0 <= 1 || (isinf(t) && t > 0))) || + (d <= -sqrt(DBL_MAX) && !isnan(t))) { + printf("Pure C acosh arg=%.20g ulp=%.20g\n", d, u0); + printf("%.20g\n", t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_atanh(frx, frx, GMP_RNDN); + + double u0 = countULPdp(t = xatanh(d), frx); + + if (u0 > 1) { + printf("Pure C atanh arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + } + + // + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_abs(frx, frx, GMP_RNDN); + + double u0 = countULPdp(t = xfabs(d), frx); + + if (u0 != 0) { + printf("Pure C fabs arg=%.20g ulp=%.20g\n", d, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_set_d(fry, d2, GMP_RNDN); + mpfr_copysign(frx, frx, fry, GMP_RNDN); + + double u0 = countULPdp(t = xcopysign(d, d2), frx); + + if (u0 != 0 && !isnan(d2)) { + printf("Pure C copysign arg=%.20g, %.20g ulp=%.20g\n", d, d2, u0); + printf("correct = %g, test = %g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_set_d(fry, d2, GMP_RNDN); + mpfr_max(frx, frx, fry, GMP_RNDN); + + double u0 = countULPdp(t = xfmax(d, d2), frx); + + if (u0 != 0) { + printf("Pure C fmax arg=%.20g, %.20g ulp=%.20g\n", d, d2, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_set_d(fry, d2, GMP_RNDN); + mpfr_min(frx, frx, fry, GMP_RNDN); + + double u0 = countULPdp(t = xfmin(d, d2), frx); + + if (u0 != 0) { + printf("Pure C fmin arg=%.20g, %.20g ulp=%.20g\n", d, d2, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_set_d(fry, d2, GMP_RNDN); + mpfr_dim(frx, frx, fry, GMP_RNDN); + + double u0 = countULPdp(t = xfdim(d, d2), frx); + + if (u0 > 0.5) { + printf("Pure C fdim arg=%.20g, %.20g ulp=%.20g\n", d, d2, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_trunc(frx, frx); + + double u0 = countULPdp(t = xtrunc(d), frx); + + if (u0 != 0) { + printf("Pure C trunc arg=%.20g ulp=%.20g\n", d, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_floor(frx, frx); + + double u0 = countULPdp(t = xfloor(d), frx); + + if (u0 != 0) { + printf("Pure C floor arg=%.20g ulp=%.20g\n", d, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_ceil(frx, frx); + + double u0 = countULPdp(t = xceil(d), frx); + + if (u0 != 0) { + printf("Pure C ceil arg=%.20g ulp=%.20g\n", d, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_round(frx, frx); + + double u0 = countULPdp(t = xround(d), frx); + + if (u0 != 0) { + printf("Pure C round arg=%.24g ulp=%.20g\n", d, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_rint(frx, frx, GMP_RNDN); + + double u0 = countULPdp(t = xrint(d), frx); + + if (u0 != 0) { + printf("Pure C rint arg=%.24g ulp=%.20g\n", d, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_set_d(fry, d2, GMP_RNDN); + mpfr_set_d(frz, d3, GMP_RNDN); + mpfr_fma(frx, frx, fry, frz, GMP_RNDN); + + double u0 = countULP2dp(t = xfma(d, d2, d3), frx); + double c = mpfr_get_d(frx, GMP_RNDN); + + if ((-1e+303 < c && c < 1e+303 && u0 > 0.5) || + !(u0 <= 0.5 || isinf(t))) { + printf("Pure C fma arg=%.20g, %.20g, %.20g ulp=%.20g\n", d, d2, d3, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_sqrt(frx, frx, GMP_RNDN); + + double u0 = countULPdp(t = xsqrt_u05(d), frx); + + if (u0 > 0.50001) { + printf("Pure C sqrt_u05 arg=%.20g ulp=%.20g\n", d, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_set_d(fry, d2, GMP_RNDN); + mpfr_hypot(frx, frx, fry, GMP_RNDN); + + double u0 = countULP2dp(t = xhypot_u05(d, d2), frx); + + if (u0 > 0.5) { + printf("Pure C hypot arg=%.20g, %.20g ulp=%.20g\n", d, d2, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_set_d(fry, d2, GMP_RNDN); + mpfr_hypot(frx, frx, fry, GMP_RNDN); + + double u0 = countULP2dp(t = xhypot_u35(d, d2), frx); + double c = mpfr_get_d(frx, GMP_RNDN); + + if ((-1e+308 < c && c < 1e+308 && u0 > 3.5) || + !(u0 <= 3.5 || isinf(t))) { + printf("Pure C hypot arg=%.20g, %.20g ulp=%.20g\n", d, d2, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + t = xnextafter(d, d2); + double c = nextafter(d, d2); + + if (!(isnan(t) && isnan(c)) && t != c) { + printf("Pure C nextafter arg=%.20g, %.20g\n", d, d2); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_set_exp(frx, 0); + + double u0 = countULPdp(t = xfrfrexp(d), frx); + + if (d != 0 && isnumber(d) && u0 != 0) { + printf("Pure C frfrexp arg=%.20g ulp=%.20g\n", d, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + int cexp = mpfr_get_exp(frx); + + int texp = xexpfrexp(d); + + if (d != 0 && isnumber(d) && cexp != texp) { + printf("Pure C expfrexp arg=%.20g\n", d); + printf("correct = %d, test = %d\n", cexp, texp); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_set_d(fry, d2, GMP_RNDN); + mpfr_fmod(frx, frx, fry, GMP_RNDN); + + double u0 = countULPdp(t = xfmod(d, d2), frx); + + if (fabsl((long double)d / d2) < 1e+300 && u0 > 0.5) { + printf("Pure C fmod arg=%.20g, %.20g ulp=%.20g\n", d, d2, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_set_d(fry, d2, GMP_RNDN); + mpfr_remainder(frx, frx, fry, GMP_RNDN); + + double u0 = countULPdp(t = xremainder(d, d2), frx); + + if (fabsl((long double)d / d2) < 1e+300 && u0 > 0.5) { + printf("Pure C remainder arg=%.20g, %.20g ulp=%.20g\n", d, d2, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + int exp = (random() & 8191) - 4096; + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_set_exp(frx, mpfr_get_exp(frx) + exp); + + double u0 = countULPdp(t = xldexp(d, exp), frx); + + if (u0 > 0.5) { + printf("Pure C ldexp arg=%.20g %d ulp=%.20g\n", d, exp, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_modf(fry, frz, frx, GMP_RNDN); + + Sleef_double2 t2 = xmodf(d); + double u0 = countULPdp(t2.x, frz); + double u1 = countULPdp(t2.y, fry); + + if (u0 != 0 || u1 != 0) { + printf("Pure C modf arg=%.20g ulp=%.20g %.20g\n", d, u0, u1); + printf("correct = %.20g, %.20g\n", mpfr_get_d(frz, GMP_RNDN), mpfr_get_d(fry, GMP_RNDN)); + printf("test = %.20g, %.20g\n", t2.x, t2.y); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + int s; + mpfr_lgamma(frx, &s, frx, GMP_RNDN); + + double u0 = countULPdp(t = xlgamma_u1(d), frx); + + if (((d < 0 && fabsl(t - mpfr_get_ld(frx, GMP_RNDN)) > 1e-15 && u0 > 1) || (0 <= d && d < 2e+305 && u0 > 1) || (2e+305 <= d && !(u0 <= 1 || isinf(t))))) { + printf("Pure C xlgamma_u1 arg=%.20g ulp=%.20g\n", d, u0); + printf("Correct = %.20Lg, test = %.20g\n", mpfr_get_ld(frx, GMP_RNDN), t); + printf("Diff = %.20Lg\n", fabsl(t - mpfr_get_ld(frx, GMP_RNDN))); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_gamma(frx, frx, GMP_RNDN); + + double u0 = countULP2dp(t = xtgamma_u1(d), frx); + + if (u0 > 1.0) { + printf("Pure C xtgamma_u1 arg=%.20g ulp=%.20g\n", d, u0); + printf("Correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + printf("Diff = %.20Lg\n", fabsl(t - mpfr_get_ld(frx, GMP_RNDN))); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_erfc(frx, frx, GMP_RNDN); + + static double ebz = 9.8813129168249308835e-324; // nextafter(nextafter(0, 1), 1); + + double u0 = countULP2dp(t = xerfc_u15(d), frx); + + if ((d > 26.2 && u0 > 2.5 && !(mpfr_get_d(frx, GMP_RNDN) == 0 && t <= ebz)) || (d <= 26.2 && u0 > 1.5)) { + printf("Pure C xerfc_u15 arg=%.20g ulp=%.20g\n", d, u0); + printf("Correct = %.20Lg, test = %.20g\n", mpfr_get_ld(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_erf(frx, frx, GMP_RNDN); + + double u0 = countULP2dp(t = xerf_u1(d), frx); + + if (u0 > 0.75) { + printf("Pure C xerf_u1 arg=%.20g ulp=%.20g\n", d, u0); + printf("Correct = %.20Lg, test = %.20g\n", mpfr_get_ld(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + } + mpfr_clears(frw, frx, fry, frz, NULL); + exit(0); +} diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-tester/tester2ld.c b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-tester/tester2ld.c new file mode 100644 index 00000000000..dd75119c810 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-tester/tester2ld.c @@ -0,0 +1,241 @@ +// Copyright Naoki Shibata and contributors 2010 - 2024. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "misc.h" + +#ifdef ENABLE_SYS_getrandom +#define _GNU_SOURCE +#include +#include +#include +#endif + +#include "sleef.h" +#include "testerutil.h" + +#define DORENAME +#include "rename.h" + +#define DENORMAL_LDBL_MIN (3.6451995318824746025284059336194e-4951L) +#define XLDBL_MIN (3.3621031431120935062626778173218e-4932L) + +#ifndef M_PIl +#define M_PIl 3.141592653589793238462643383279502884L +#endif + +#ifndef M_PI_4l +#define M_PI_4l .785398163397448309615660845819875721049292L +#endif + +#define POSITIVE_INFINITY INFINITY +#define NEGATIVE_INFINITY (-INFINITY) + +int isnumberl(long double x) { return x != SLEEF_INFINITYl && x != -SLEEF_INFINITYl && x == x; } +int isPlusZerol(long double x) { return x == 0 && copysignl(1, x) == 1; } +int isMinusZerol(long double x) { return x == 0 && copysignl(1, x) == -1; } + +mpfr_t fra, frb, frd; + +double countULP(long double d, mpfr_t c) { + long double c2 = mpfr_get_ld(c, GMP_RNDN); + if (c2 == 0 && d != 0) return 10000; + //if (isPlusZerol(c2) && !isPlusZerol(d)) return 10003; + //if (isMinusZerol(c2) && !isMinusZerol(d)) return 10004; + if (isnanl(c2) && isnanl(d)) return 0; + if (isnanl(c2) || isnanl(d)) return 10001; + if (c2 == POSITIVE_INFINITY && d == POSITIVE_INFINITY) return 0; + if (c2 == NEGATIVE_INFINITY && d == NEGATIVE_INFINITY) return 0; + if (!isnumberl(c2) && !isnumberl(d)) return 0; + + int e; + frexpl(mpfr_get_ld(c, GMP_RNDN), &e); + mpfr_set_ld(frb, fmaxl(ldexpl(1.0, e-64), DENORMAL_LDBL_MIN), GMP_RNDN); + + mpfr_set_ld(frd, d, GMP_RNDN); + mpfr_sub(fra, frd, c, GMP_RNDN); + mpfr_div(fra, fra, frb, GMP_RNDN); + double u = fabs(mpfr_get_d(fra, GMP_RNDN)); + + return u; +} + +double countULP2(long double d, mpfr_t c) { + long double c2 = mpfr_get_ld(c, GMP_RNDN); + if (c2 == 0 && d != 0) return 10000; + //if (isPlusZerol(c2) && !isPlusZerol(d)) return 10003; + //if (isMinusZerol(c2) && !isMinusZerol(d)) return 10004; + if (isnanl(c2) && isnanl(d)) return 0; + if (isnanl(c2) || isnanl(d)) return 10001; + if (c2 == POSITIVE_INFINITY && d == POSITIVE_INFINITY) return 0; + if (c2 == NEGATIVE_INFINITY && d == NEGATIVE_INFINITY) return 0; + if (!isnumberl(c2) && !isnumberl(d)) return 0; + + int e; + frexpl(mpfr_get_ld(c, GMP_RNDN), &e); + mpfr_set_ld(frb, fmaxl(ldexpl(1.0, e-64), LDBL_MIN), GMP_RNDN); + + mpfr_set_ld(frd, d, GMP_RNDN); + mpfr_sub(fra, frd, c, GMP_RNDN); + mpfr_div(fra, fra, frb, GMP_RNDN); + double u = fabs(mpfr_get_d(fra, GMP_RNDN)); + + return u; +} + +typedef union { + long double d; + __int128 u128; +} conv_t; + +long double rnd() { + conv_t c; + switch(random() & 15) { + case 0: return INFINITY; + case 1: return -INFINITY; + } +#ifdef ENABLE_SYS_getrandom + syscall(SYS_getrandom, &c.u128, sizeof(c.u128), 0); +#else + c.u128 = random() | ((__int128)random() << 31) | ((__int128)random() << (31*2)) | ((__int128)random() << (31*3)) | ((__int128)random() << (31*4)); +#endif + return c.d; +} + +long double rnd_fr() { + conv_t c; + do { +#ifdef ENABLE_SYS_getrandom + syscall(SYS_getrandom, &c.u128, sizeof(c.u128), 0); +#else + c.u128 = random() | ((__int128)random() << 31) | ((__int128)random() << (31*2)) | ((__int128)random() << (31*3)) | ((__int128)random() << (31*4)); +#endif + } while(!isnumberl(c.d)); + return c.d; +} + +long double rnd_zo() { + conv_t c; + do { +#ifdef ENABLE_SYS_getrandom + syscall(SYS_getrandom, &c.u128, sizeof(c.u128), 0); +#else + c.u128 = random() | ((__int128)random() << 31) | ((__int128)random() << (31*2)) | ((__int128)random() << (31*3)) | ((__int128)random() << (31*4)); +#endif + } while(!isnumberl(c.d) || c.d < -1 || 1 < c.d); + return c.d; +} + +void sinpifr(mpfr_t ret, long double d) { + mpfr_t frpi, frd; + mpfr_inits(frpi, frd, NULL); + + mpfr_const_pi(frpi, GMP_RNDN); + mpfr_set_d(frd, 1.0, GMP_RNDN); + mpfr_mul(frpi, frpi, frd, GMP_RNDN); + mpfr_set_ld(frd, d, GMP_RNDN); + mpfr_mul(frd, frpi, frd, GMP_RNDN); + mpfr_sin(ret, frd, GMP_RNDN); + + mpfr_clears(frpi, frd, NULL); +} + +void cospifr(mpfr_t ret, long double d) { + mpfr_t frpi, frd; + mpfr_inits(frpi, frd, NULL); + + mpfr_const_pi(frpi, GMP_RNDN); + mpfr_set_d(frd, 1.0, GMP_RNDN); + mpfr_mul(frpi, frpi, frd, GMP_RNDN); + mpfr_set_ld(frd, d, GMP_RNDN); + mpfr_mul(frd, frpi, frd, GMP_RNDN); + mpfr_cos(ret, frd, GMP_RNDN); + + mpfr_clears(frpi, frd, NULL); +} + +int main(int argc,char **argv) +{ + mpfr_t frx; + + mpfr_set_default_prec(256); + mpfr_inits(fra, frb, frd, frx, NULL); + + conv_t cd; + long double d, t; + + int cnt, ecnt = 0; + + srandom(time(NULL)); + + for(cnt = 0;ecnt < 1000;cnt++) { + switch(cnt & 7) { + case 0: + d = rnd(); + break; + case 1: + cd.d = rint((2 * (double)random() / RAND_MAX - 1) * 1e+10) * M_PI_4; + cd.u128 += (random() & 0xff) - 0x7f; + d = cd.d; + break; + default: + d = rnd_fr(); + break; + } + + Sleef_longdouble2 sc = xsincospil_u05(d); + Sleef_longdouble2 sc2 = xsincospil_u35(d); + + { + const double rangemax2 = 1e+9; + + sinpifr(frx, d); + + double u0 = countULP2(t = sc.x, frx); + + if (u0 != 0 && ((fabsl(d) <= rangemax2 && u0 > 0.505) || fabsl(t) > 1 || !isnumberl(t))) { + printf("Pure C sincospil_u05 sin arg=%.30Lg ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + + double u1 = countULP2(t = sc2.x, frx); + + if (u1 != 0 && ((fabsl(d) <= rangemax2 && u1 > 1.5) || fabsl(t) > 1 || !isnumberl(t))) { + printf("Pure C sincospil_u35 sin arg=%.30Lg ulp=%.20g\n", d, u1); + fflush(stdout); ecnt++; + } + } + + { + const double rangemax2 = 1e+9; + + cospifr(frx, d); + + double u0 = countULP2(t = sc.y, frx); + + if (u0 != 0 && ((fabsl(d) <= rangemax2 && u0 > 0.505) || fabsl(t) > 1 || !isnumberl(t))) { + printf("Pure C sincospil_u05 cos arg=%.30Lg ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + + double u1 = countULP2(t = sc.y, frx); + + if (u1 != 0 && ((fabsl(d) <= rangemax2 && u1 > 1.5) || fabsl(t) > 1 || !isnumberl(t))) { + printf("Pure C sincospil_u35 cos arg=%.30Lg ulp=%.20g\n", d, u1); + fflush(stdout); ecnt++; + } + } + + } +} diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-tester/tester2qp.c b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-tester/tester2qp.c new file mode 100644 index 00000000000..2065e2eb74a --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-tester/tester2qp.c @@ -0,0 +1,624 @@ +// Copyright Naoki Shibata and contributors 2010 - 2024. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#ifdef ENABLE_SYS_getrandom +#define _GNU_SOURCE +#include +#include +#include +#endif + +#include "sleef.h" + +#include "f128util.h" + +#define DORENAME +#include "rename.h" + +#define POSITIVE_INFINITY INFINITY +#define NEGATIVE_INFINITY (-INFINITY) + +int isnumberq(Sleef_quad x) { return !isinfq(x) && !isnanq(x); } +int isPlusZeroq(Sleef_quad x) { return x == 0 && copysignq(1, x) == 1; } +int isMinusZeroq(Sleef_quad x) { return x == 0 && copysignq(1, x) == -1; } + +mpfr_t fra, frb, frc, frd; + +double countULP(Sleef_quad d, mpfr_t c) { + Sleef_quad c2 = mpfr_get_f128(c, GMP_RNDN); + if (c2 == 0 && d != 0) return 10000; + //if (isPlusZeroq(c2) && !isPlusZeroq(d)) return 10003; + //if (isMinusZeroq(c2) && !isMinusZeroq(d)) return 10004; + if (isnanq(c2) && isnanq(d)) return 0; + if (isnanq(c2) || isnanq(d)) return 10001; + if (c2 == POSITIVE_INFINITY && d == POSITIVE_INFINITY) return 0; + if (c2 == NEGATIVE_INFINITY && d == NEGATIVE_INFINITY) return 0; + if (!isnumberq(c2) && !isnumberq(d)) return 0; + + int e; + frexpq(mpfr_get_f128(c, GMP_RNDN), &e); + mpfr_set_f128(frb, fmaxq(ldexpq(1.0, e-113), FLT128_DENORM_MIN), GMP_RNDN); + + mpfr_set_f128(frd, d, GMP_RNDN); + mpfr_sub(fra, frd, c, GMP_RNDN); + mpfr_div(fra, fra, frb, GMP_RNDN); + double u = fabs(mpfr_get_d(fra, GMP_RNDN)); + + return u; +} + +double countULP2(Sleef_quad d, mpfr_t c) { + Sleef_quad c2 = mpfr_get_f128(c, GMP_RNDN); + if (c2 == 0 && d != 0) return 10000; + //if (isPlusZeroq(c2) && !isPlusZeroq(d)) return 10003; + //if (isMinusZeroq(c2) && !isMinusZeroq(d)) return 10004; + if (isnanq(c2) && isnanq(d)) return 0; + if (isnanq(c2) || isnanq(d)) return 10001; + if (c2 == POSITIVE_INFINITY && d == POSITIVE_INFINITY) return 0; + if (c2 == NEGATIVE_INFINITY && d == NEGATIVE_INFINITY) return 0; + if (!isnumberq(c2) && !isnumberq(d)) return 0; + + int e; + frexpq(mpfr_get_f128(c, GMP_RNDN), &e); + mpfr_set_f128(frb, fmaxq(ldexpq(1.0, e-113), FLT128_MIN), GMP_RNDN); + + mpfr_set_f128(frd, d, GMP_RNDN); + mpfr_sub(fra, frd, c, GMP_RNDN); + mpfr_div(fra, fra, frb, GMP_RNDN); + double u = fabs(mpfr_get_d(fra, GMP_RNDN)); + + return u; +} + +typedef union { + Sleef_quad d; + __int128 u128; + uint64_t u[2]; +} conv_t; + +Sleef_quad rnd() { + conv_t c; + switch(random() & 15) { + case 0: return INFINITY; + case 1: return -INFINITY; + } +#ifdef ENABLE_SYS_getrandom + syscall(SYS_getrandom, &c.u128, sizeof(c.u128), 0); +#else + c.u128 = random() | ((__int128)random() << 31) | ((__int128)random() << (31*2)) | ((__int128)random() << (31*3)) | ((__int128)random() << (31*4)); +#endif + return c.d; + +} + +Sleef_quad rnd_fr() { + conv_t c; + do { +#ifdef ENABLE_SYS_getrandom + syscall(SYS_getrandom, &c.u128, sizeof(c.u128), 0); +#else + c.u128 = random() | ((__int128)random() << 31) | ((__int128)random() << (31*2)) | ((__int128)random() << (31*3)) | ((__int128)random() << (31*4)); +#endif + } while(!isnumberq(c.d)); + return c.d; +} + +Sleef_quad rnd_zo() { + conv_t c; + do { +#ifdef ENABLE_SYS_getrandom + syscall(SYS_getrandom, &c.u128, sizeof(c.u128), 0); +#else + c.u128 = random() | ((__int128)random() << 31) | ((__int128)random() << (31*2)) | ((__int128)random() << (31*3)) | ((__int128)random() << (31*4)); +#endif + } while(!isnumberq(c.d) || c.d < -1 || 1 < c.d); + return c.d; +} + +void sinpifr(mpfr_t ret, Sleef_quad d) { + mpfr_t frpi, frd; + mpfr_inits(frpi, frd, NULL); + + mpfr_const_pi(frpi, GMP_RNDN); + mpfr_set_d(frd, 1.0, GMP_RNDN); + mpfr_mul(frpi, frpi, frd, GMP_RNDN); + mpfr_set_f128(frd, d, GMP_RNDN); + mpfr_mul(frd, frpi, frd, GMP_RNDN); + mpfr_sin(ret, frd, GMP_RNDN); + + mpfr_clears(frpi, frd, NULL); +} + +void cospifr(mpfr_t ret, Sleef_quad d) { + mpfr_t frpi, frd; + mpfr_inits(frpi, frd, NULL); + + mpfr_const_pi(frpi, GMP_RNDN); + mpfr_set_d(frd, 1.0, GMP_RNDN); + mpfr_mul(frpi, frpi, frd, GMP_RNDN); + mpfr_set_f128(frd, d, GMP_RNDN); + mpfr_mul(frd, frpi, frd, GMP_RNDN); + mpfr_cos(ret, frd, GMP_RNDN); + + mpfr_clears(frpi, frd, NULL); +} + +int main(int argc,char **argv) +{ + mpfr_t frw, frx, fry, frz; + + mpfr_set_default_prec(2048); + mpfr_inits(fra, frb, frc, frd, frw, frx, fry, frz, NULL); + + conv_t cd; + Sleef_quad d, t, d2, zo; + + int cnt, ecnt = 0; + + srandom(time(NULL)); + +#if 0 + cd.d = M_PIq; + mpfr_set_f128(frx, cd.d, GMP_RNDN); + cd.u128 += 3; + printf("%g\n", countULP2(cd.d, frx)); +#endif + + const Sleef_quad rangemax = 1e+9; + + for(cnt = 0;ecnt < 1000;cnt++) { + switch(cnt & 7) { + case 0: + d = rnd(); + d2 = rnd(); + zo = rnd(); + break; + case 1: + cd.d = rint((2 * (double)random() / RAND_MAX - 1) * 1e+10) * M_PI_4; + cd.u128 += (random() & 0xff) - 0x7f; + d = cd.d; + d2 = rnd(); + zo = rnd(); + break; + default: + d = rnd_fr(); + d2 = rnd_fr(); + zo = rnd_zo(); + break; + } + + Sleef_quad2 sc = xsincospiq_u05(d); + Sleef_quad2 sc2 = xsincospiq_u35(d); + + { + const double rangemax2 = 1e+9; + + sinpifr(frx, d); + + double u0 = countULP2(t = sc.x, frx); + + if (u0 != 0 && ((fabs(d) <= rangemax2 && u0 > 0.505) || fabs(t) > 1 || !isnumberq(t))) { + printf("Pure C sincospiq_u05 sin arg="); printf128(d); printf(" ulp=%.20g\n", u0); + fflush(stdout); ecnt++; + } + + double u1 = countULP2(t = sc2.x, frx); + + if (u1 != 0 && ((fabs(d) <= rangemax2 && u1 > 2.0) || fabs(t) > 1 || !isnumberq(t))) { + printf("Pure C sincospiq_u35 sin arg=%.30Lg ulp=%.20g\n", (long double)d, u1); + fflush(stdout); ecnt++; + } + + } + + { + const double rangemax2 = 1e+9; + + cospifr(frx, d); + + double u0 = countULP2(t = sc.y, frx); + + if (u0 != 0 && ((fabs(d) <= rangemax2 && u0 > 0.505) || fabs(t) > 1 || !isnumberq(t))) { + printf("Pure C sincospiq_u05 cos arg=%.30Lg ulp=%.20g\n", (long double)d, u0); + fflush(stdout); ecnt++; + } + + double u1 = countULP2(t = sc.y, frx); + + if (u1 != 0 && ((fabs(d) <= rangemax2 && u1 > 2.0) || fabs(t) > 1 || !isnumberq(t))) { + printf("Pure C sincospiq_u35 cos arg=%.30Lg ulp=%.20g\n", (long double)d, u1); + fflush(stdout); ecnt++; + } + + } + +#if 0 + double2 sc = xsincos(d); + double2 sc2 = xsincos_u1(d); + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_sin(frx, frx, GMP_RNDN); + + double u0 = countULP(t = xsin(d), frx); + + if ((fabs(d) <= rangemax && u0 > 3.5) || fabs(t) > 1 || !isnumberq(t)) { + printf("Pure C sin arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + + double u1 = countULP(sc.x, frx); + + if ((fabs(d) <= rangemax && u1 > 3.5) || fabs(t) > 1 || !isnumberq(t)) { + printf("Pure C sincos sin arg=%.20g ulp=%.20g\n", d, u1); + fflush(stdout); ecnt++; + } + + double u2 = countULP(t = xsin_u1(d), frx); + + if ((fabs(d) <= rangemax && u2 > 1) || fabs(t) > 1 || !isnumberq(t)) { + printf("Pure C sin_u1 arg=%.20g ulp=%.20g\n", d, u2); + fflush(stdout); ecnt++; + } + + double u3 = countULP(t = sc2.x, frx); + + if ((fabs(d) <= rangemax && u3 > 1) || fabs(t) > 1 || !isnumberq(t)) { + printf("Pure C sincos_u1 sin arg=%.20g ulp=%.20g\n", d, u3); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_cos(frx, frx, GMP_RNDN); + + double u0 = countULP(t = xcos(d), frx); + + if ((fabs(d) <= rangemax && u0 > 3.5) || fabs(t) > 1 || !isnumberq(t)) { + printf("Pure C cos arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + + double u1 = countULP(t = sc.y, frx); + + if ((fabs(d) <= rangemax && u1 > 3.5) || fabs(t) > 1 || !isnumberq(t)) { + printf("Pure C sincos cos arg=%.20g ulp=%.20g\n", d, u1); + fflush(stdout); ecnt++; + } + + double u2 = countULP(t = xcos_u1(d), frx); + + if ((fabs(d) <= rangemax && u2 > 1) || fabs(t) > 1 || !isnumberq(t)) { + printf("Pure C cos_u1 arg=%.20g ulp=%.20g\n", d, u2); + fflush(stdout); ecnt++; + } + + double u3 = countULP(t = sc2.y, frx); + + if ((fabs(d) <= rangemax && u3 > 1) || fabs(t) > 1 || !isnumberq(t)) { + printf("Pure C sincos_u1 cos arg=%.20g ulp=%.20g\n", d, u3); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_tan(frx, frx, GMP_RNDN); + + double u0 = countULP(t = xtan(d), frx); + + if ((fabs(d) < 1e+7 && u0 > 3.5) || (fabs(d) <= rangemax && u0 > 5) || isnan(t)) { + printf("Pure C tan arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + + double u1 = countULP(t = xtan_u1(d), frx); + + if ((fabs(d) <= rangemax && u1 > 1) || isnan(t)) { + printf("Pure C tan_u1 arg=%.20g ulp=%.20g\n", d, u1); + fflush(stdout); ecnt++; + } + } + + d = rnd_fr(); + double d2 = rnd_fr(), zo = rnd_zo(); + + { + mpfr_set_d(frx, fabs(d), GMP_RNDN); + mpfr_log(frx, frx, GMP_RNDN); + + double u0 = countULP(t = xlog(fabs(d)), frx); + + if (u0 > 3.5) { + printf("Pure C log arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + + double u1 = countULP(t = xlog_u1(fabs(d)), frx); + + if (u1 > 1) { + printf("Pure C log_u1 arg=%.20g ulp=%.20g\n", d, u1); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, fabs(d), GMP_RNDN); + mpfr_log10(frx, frx, GMP_RNDN); + + double u0 = countULP(t = xlog10(fabs(d)), frx); + + if (u0 > 1) { + printf("Pure C log10 arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_log1p(frx, frx, GMP_RNDN); + + double u0 = countULP(t = xlog1p(d), frx); + + if ((-1 <= d && d <= 1e+307 && u0 > 1) || + (d < -1 && !isnan(t)) || + (d > 1e+307 && !(u0 <= 1 || isinf(t)))) { + printf("Pure C log1p arg=%.20g ulp=%.20g\n", d, u0); + printf("%g\n", t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_exp(frx, frx, GMP_RNDN); + + double u0 = countULP(t = xexp(d), frx); + + if (u0 > 1) { + printf("Pure C exp arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_exp2(frx, frx, GMP_RNDN); + + double u0 = countULP(t = xexp2(d), frx); + + if (u0 > 1) { + printf("Pure C exp2 arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_exp10(frx, frx, GMP_RNDN); + + double u0 = countULP(t = xexp10(d), frx); + + if (u0 > 1) { + printf("Pure C exp10 arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_expm1(frx, frx, GMP_RNDN); + + double u0 = countULP(t = xexpm1(d), frx); + + if (u0 > 1) { + printf("Pure C expm1 arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_set_d(fry, d2, GMP_RNDN); + mpfr_pow(frx, fry, frx, GMP_RNDN); + + double u0 = countULP(t = xpow(d2, d), frx); + + if (u0 > 1) { + printf("Pure C pow arg=%.20g, %.20g ulp=%.20g\n", d2, d, u0); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_cbrt(frx, frx, GMP_RNDN); + + double u0 = countULP(t = xcbrt(d), frx); + + if (u0 > 3.5) { + printf("Pure C cbrt arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + + double u1 = countULP(t = xcbrt_u1(d), frx); + + if (u1 > 1) { + printf("Pure C cbrt_u1 arg=%.20g ulp=%.20g\n", d, u1); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, zo, GMP_RNDN); + mpfr_asin(frx, frx, GMP_RNDN); + + double u0 = countULP(t = xasin(zo), frx); + + if (u0 > 3.5) { + printf("Pure C asin arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + + double u1 = countULP(t = xasin_u1(zo), frx); + + if (u1 > 1) { + printf("Pure C asin_u1 arg=%.20g ulp=%.20g\n", d, u1); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, zo, GMP_RNDN); + mpfr_acos(frx, frx, GMP_RNDN); + + double u0 = countULP(t = xacos(zo), frx); + + if (u0 > 3.5) { + printf("Pure C acos arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + + double u1 = countULP(t = xacos_u1(zo), frx); + + if (u1 > 1) { + printf("Pure C acos_u1 arg=%.20g ulp=%.20g\n", d, u1); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_atan(frx, frx, GMP_RNDN); + + double u0 = countULP(t = xatan(d), frx); + + if (u0 > 3.5) { + printf("Pure C atan arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + + double u1 = countULP(t = xatan_u1(d), frx); + + if (u1 > 1) { + printf("Pure C atan_u1 arg=%.20g ulp=%.20g\n", d, u1); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_set_d(fry, d2, GMP_RNDN); + mpfr_atan2(frx, fry, frx, GMP_RNDN); + + double u0 = countULP(t = xatan2(d2, d), frx); + + if (u0 > 3.5) { + printf("Pure C atan2 arg=%.20g, %.20g ulp=%.20g\n", d2, d, u0); + fflush(stdout); ecnt++; + } + + double u1 = countULP2(t = xatan2_u1(d2, d), frx); + + if (u1 > 1) { + printf("Pure C atan2_u1 arg=%.20g, %.20g ulp=%.20g\n", d2, d, u1); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_sinh(frx, frx, GMP_RNDN); + + double u0 = countULP(t = xsinh(d), frx); + + if ((fabs(d) <= 709 && u0 > 1) || + (d > 709 && !(u0 <= 1 || (isinf(t) && t > 0))) || + (d < -709 && !(u0 <= 1 || (isinf(t) && t < 0)))) { + printf("Pure C sinh arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_cosh(frx, frx, GMP_RNDN); + + double u0 = countULP(t = xcosh(d), frx); + + if ((fabs(d) <= 709 && u0 > 1) || !(u0 <= 1 || (isinf(t) && t > 0))) { + printf("Pure C cosh arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_tanh(frx, frx, GMP_RNDN); + + double u0 = countULP(t = xtanh(d), frx); + + if (u0 > 1) { + printf("Pure C tanh arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_asinh(frx, frx, GMP_RNDN); + + double u0 = countULP(t = xasinh(d), frx); + + if ((fabs(d) < sqrt(DBL_MAX) && u0 > 1) || + (d >= sqrt(DBL_MAX) && !(u0 <= 1 || (isinf(t) && t > 0))) || + (d <= -sqrt(DBL_MAX) && !(u0 <= 1 || (isinf(t) && t < 0)))) { + printf("Pure C asinh arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_acosh(frx, frx, GMP_RNDN); + + double u0 = countULP(t = xacosh(d), frx); + + if ((fabs(d) < sqrt(DBL_MAX) && u0 > 1) || + (d >= sqrt(DBL_MAX) && !(u0 <= 1 || (isinf(t) && t > 0))) || + (d <= -sqrt(DBL_MAX) && !isnan(t))) { + printf("Pure C acosh arg=%.20g ulp=%.20g\n", d, u0); + printf("%.20g\n", t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_atanh(frx, frx, GMP_RNDN); + + double u0 = countULP(t = xatanh(d), frx); + + if (u0 > 1) { + printf("Pure C atanh arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + } +#endif + } +} diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-tester/tester2simddp.c b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-tester/tester2simddp.c new file mode 100644 index 00000000000..1ceffcb6fcf --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-tester/tester2simddp.c @@ -0,0 +1,1298 @@ +// Copyright Naoki Shibata and contributors 2010 - 2023. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include +#include +#include + +#include + +#ifdef ENABLE_SYS_getrandom +#define _GNU_SOURCE +#include +#include +#endif + +#include "sleef.h" +#include "quaddef.h" +#include "testerutil.h" + +#ifdef ENABLE_SSE2 +#define CONFIG 2 +#include "helpersse2.h" +#include "renamesse2.h" +typedef Sleef___m128d_2 vdouble2; +typedef Sleef___m128_2 vfloat2; +#endif + +#ifdef ENABLE_SSE4 +#define CONFIG 4 +#include "helpersse2.h" +#include "renamesse4.h" +typedef Sleef___m128d_2 vdouble2; +typedef Sleef___m128_2 vfloat2; +#endif + +#ifdef ENABLE_AVX +#define CONFIG 1 +#include "helperavx.h" +#include "renameavx.h" +typedef Sleef___m256d_2 vdouble2; +typedef Sleef___m256_2 vfloat2; +#endif + +#ifdef ENABLE_FMA4 +#define CONFIG 4 +#include "helperavx.h" +#include "renamefma4.h" +typedef Sleef___m256d_2 vdouble2; +typedef Sleef___m256_2 vfloat2; +#endif + +#ifdef ENABLE_AVX2 +#define CONFIG 1 +#include "helperavx2.h" +#include "renameavx2.h" +typedef Sleef___m256d_2 vdouble2; +typedef Sleef___m256_2 vfloat2; +#endif + +#ifdef ENABLE_AVX2128 +#define CONFIG 1 +#include "helperavx2_128.h" +#include "renameavx2128.h" +typedef Sleef___m128d_2 vdouble2; +typedef Sleef___m128_2 vfloat2; +#endif + +#ifdef ENABLE_AVX512F +#define CONFIG 1 +#include "helperavx512f.h" +#include "renameavx512f.h" +typedef Sleef___m512d_2 vdouble2; +typedef Sleef___m512_2 vfloat2; +#endif + +#ifdef ENABLE_AVX512FNOFMA +#define CONFIG 2 +#include "helperavx512f.h" +#include "renameavx512fnofma.h" +typedef Sleef___m512d_2 vdouble2; +typedef Sleef___m512_2 vfloat2; +#endif + +#ifdef ENABLE_VECEXT +#define CONFIG 1 +#include "helpervecext.h" +#include "norename.h" +#endif + +#ifdef ENABLE_PUREC +#define CONFIG 1 +#include "helperpurec.h" +#include "norename.h" +#endif + +#ifdef ENABLE_ADVSIMD +#define CONFIG 1 +#include "helperadvsimd.h" +#include "renameadvsimd.h" +typedef Sleef_float64x2_t_2 vdouble2; +typedef Sleef_float32x4_t_2 vfloat2; +#endif + +#ifdef ENABLE_ADVSIMDNOFMA +#define CONFIG 2 +#include "helperadvsimd.h" +#include "renameadvsimdnofma.h" +typedef Sleef_float64x2_t_2 vdouble2; +typedef Sleef_float32x4_t_2 vfloat2; +#endif + +#ifdef ENABLE_SVE +#define CONFIG 1 +#include "helpersve.h" +#include "renamesve.h" +#endif /* ENABLE_SVE */ + +#ifdef ENABLE_SVENOFMA +#define CONFIG 2 +#include "helpersve.h" +#include "renamesvenofma.h" +#endif + +#ifdef ENABLE_VSX +#define CONFIG 1 +#include "helperpower_128.h" +#include "renamevsx.h" +typedef Sleef_SLEEF_VECTOR_DOUBLE_2 vdouble2; +typedef Sleef_SLEEF_VECTOR_FLOAT_2 vfloat2; +#endif + +#ifdef ENABLE_VSXNOFMA +#define CONFIG 2 +#include "helperpower_128.h" +#include "renamevsxnofma.h" +typedef Sleef_SLEEF_VECTOR_DOUBLE_2 vdouble2; +typedef Sleef_SLEEF_VECTOR_FLOAT_2 vfloat2; +#endif + +#ifdef ENABLE_VSX3 +#define CONFIG 3 +#include "helperpower_128.h" +#include "renamevsx3.h" +typedef Sleef_SLEEF_VECTOR_DOUBLE_2 vdouble2; +typedef Sleef_SLEEF_VECTOR_FLOAT_2 vfloat2; +#endif + +#ifdef ENABLE_VSX3NOFMA +#define CONFIG 4 +#include "helperpower_128.h" +#include "renamevsx3nofma.h" +typedef Sleef_SLEEF_VECTOR_DOUBLE_2 vdouble2; +typedef Sleef_SLEEF_VECTOR_FLOAT_2 vfloat2; +#endif + +#ifdef ENABLE_VXE +#define CONFIG 140 +#include "helpers390x_128.h" +#include "renamevxe.h" +typedef Sleef_SLEEF_VECTOR_DOUBLE_2 vdouble2; +typedef Sleef_SLEEF_VECTOR_FLOAT_2 vfloat2; +#endif + +#ifdef ENABLE_VXENOFMA +#define CONFIG 141 +#include "helpers390x_128.h" +#include "renamevxenofma.h" +typedef Sleef_SLEEF_VECTOR_DOUBLE_2 vdouble2; +typedef Sleef_SLEEF_VECTOR_FLOAT_2 vfloat2; +#endif + +#ifdef ENABLE_VXE2 +#define CONFIG 150 +#include "helpers390x_128.h" +#include "renamevxe2.h" +typedef Sleef_SLEEF_VECTOR_DOUBLE_2 vdouble2; +typedef Sleef_SLEEF_VECTOR_FLOAT_2 vfloat2; +#endif + +#ifdef ENABLE_VXE2NOFMA +#define CONFIG 151 +#include "helpers390x_128.h" +#include "renamevxe2nofma.h" +typedef Sleef_SLEEF_VECTOR_DOUBLE_2 vdouble2; +typedef Sleef_SLEEF_VECTOR_FLOAT_2 vfloat2; +#endif + +#ifdef ENABLE_RVVM1 +#define CONFIG 1 +#define ENABLE_RVV_DP +#include "helperrvv.h" +#include "renamervvm1.h" +#include "sleef.h" +#endif + +#ifdef ENABLE_RVVM1NOFMA +#define CONFIG 2 +#define ENABLE_RVV_DP +#include "helperrvv.h" +#include "renamervvm1nofma.h" +#include "sleef.h" +#endif + +#ifdef ENABLE_RVVM2 +#define CONFIG 1 +#define ENABLE_RVV_DP +#include "helperrvv.h" +#include "renamervvm2.h" +#include "sleef.h" +#endif + +#ifdef ENABLE_RVVM2NOFMA +#define CONFIG 2 +#define ENABLE_RVV_DP +#include "helperrvv.h" +#include "renamervvm2nofma.h" +#include "sleef.h" +#endif + +#ifdef ENABLE_PUREC_SCALAR +#define CONFIG 1 +#include "helperpurec_scalar.h" +#include "renamepurec_scalar.h" +typedef Sleef_double_2 vdouble2; +typedef Sleef_float_2 vfloat2; +#endif + +#ifdef ENABLE_PURECFMA_SCALAR +#define CONFIG 2 +#include "helperpurec_scalar.h" +#include "renamepurecfma_scalar.h" +typedef Sleef_double_2 vdouble2; +typedef Sleef_float_2 vfloat2; +#endif + +// + +#if !(defined(ENABLE_SVE) || defined(ENABLE_SVENOFMA) || defined(ENABLE_RVVM1) || defined(ENABLE_RVVM1NOFMA) || defined(ENABLE_RVVM2) || defined(ENABLE_RVVM2NOFMA)) +static vdouble vd2getx_vd_vd2(vdouble2 v) { return v.x; } +static vdouble vd2gety_vd_vd2(vdouble2 v) { return v.y; } +#endif + +// + +#define DENORMAL_DBL_MIN (4.9406564584124654418e-324) + +#define POSITIVE_INFINITY INFINITY +#define NEGATIVE_INFINITY (-INFINITY) + +typedef union { + double d; + uint64_t u64; + int64_t i64; +} conv_t; + +double nexttoward0(double x, int n) { + union { + double f; + uint64_t u; + } cx; + cx.f = x; + cx.u -= n; + return cx.f; +} + +double rnd() { + conv_t c; + switch(random() & 63) { + case 0: return nexttoward0( 0.0, -(random() & ((1 << (random() & 31)) - 1))); + case 1: return nexttoward0(-0.0, -(random() & ((1 << (random() & 31)) - 1))); + case 2: return nexttoward0( INFINITY, (random() & ((1 << (random() & 31)) - 1))); + case 3: return nexttoward0(-INFINITY, (random() & ((1 << (random() & 31)) - 1))); + } +#ifdef ENABLE_SYS_getrandom + syscall(SYS_getrandom, &c.u64, sizeof(c.u64), 0); +#else + c.u64 = random() | ((uint64_t)random() << 31) | ((uint64_t)random() << 62); +#endif + return c.d; +} + +double rnd_fr() { + conv_t c; + do { +#ifdef ENABLE_SYS_getrandom + syscall(SYS_getrandom, &c.u64, sizeof(c.u64), 0); +#else + c.u64 = random() | ((uint64_t)random() << 31) | ((uint64_t)random() << 62); +#endif + } while(!isnumber(c.d)); + return c.d; +} + +double rnd_zo() { + conv_t c; + do { +#ifdef ENABLE_SYS_getrandom + syscall(SYS_getrandom, &c.u64, sizeof(c.u64), 0); +#else + c.u64 = random() | ((uint64_t)random() << 31) | ((uint64_t)random() << 62); +#endif + } while(!isnumber(c.d) || c.d < -1 || 1 < c.d); + return c.d; +} + +void sinpifr(mpfr_t ret, double d) { + mpfr_t frpi, frd; + mpfr_inits(frpi, frd, NULL); + + mpfr_const_pi(frpi, GMP_RNDN); + mpfr_set_d(frd, 1.0, GMP_RNDN); + mpfr_mul(frpi, frpi, frd, GMP_RNDN); + mpfr_set_d(frd, d, GMP_RNDN); + mpfr_mul(frd, frpi, frd, GMP_RNDN); + mpfr_sin(ret, frd, GMP_RNDN); + + mpfr_clears(frpi, frd, NULL); +} + +void cospifr(mpfr_t ret, double d) { + mpfr_t frpi, frd; + mpfr_inits(frpi, frd, NULL); + + mpfr_const_pi(frpi, GMP_RNDN); + mpfr_set_d(frd, 1.0, GMP_RNDN); + mpfr_mul(frpi, frpi, frd, GMP_RNDN); + mpfr_set_d(frd, d, GMP_RNDN); + mpfr_mul(frd, frpi, frd, GMP_RNDN); + mpfr_cos(ret, frd, GMP_RNDN); + + mpfr_clears(frpi, frd, NULL); +} + +vdouble vset(vdouble v, int idx, double d) { + double a[VECTLENDP]; + vstoreu_v_p_vd(a, v); + a[idx] = d; + return vloadu_vd_p(a); +} + +double vget(vdouble v, int idx) { + double a[VECTLENDP]; + vstoreu_v_p_vd(a, v); + return a[idx]; +} + +int vgeti(vint v, int idx) { + int a[VECTLENDP*2]; + vstoreu_v_p_vi(a, v); + return a[idx]; +} + +int main(int argc,char **argv) +{ + mpfr_t frw, frx, fry, frz; + + mpfr_set_default_prec(256); + mpfr_inits(frw, frx, fry, frz, NULL); + + conv_t cd; + double d, t; + double d2, d3, zo; + vdouble vd = vcast_vd_d(0); + vdouble vd2 = vcast_vd_d(0); + vdouble vd3 = vcast_vd_d(0); + vdouble vzo = vcast_vd_d(0); + vdouble vad = vcast_vd_d(0); + vdouble2 sc, sc2; + int cnt, ecnt = 0; + + srandom(time(NULL)); + + for(cnt = 0;ecnt < 1000;cnt++) { + int e = cnt % VECTLENDP; + switch(cnt & 7) { + case 0: + d = rnd(); + d2 = rnd(); + d3 = rnd(); + zo = rnd(); + break; + case 1: + cd.d = rint(rnd_zo() * 1e+10) * M_PI_4; + cd.i64 += (random() & 0xff) - 0x7f; + d = cd.d; + d2 = rnd(); + d3 = rnd(); + zo = rnd(); + break; + case 2: + cd.d = rnd_fr() * M_PI_4; + cd.i64 += (random() & 0xf) - 0x7; + d = cd.d; + d2 = rnd(); + d3 = rnd(); + zo = rnd(); + break; + default: + d = rnd_fr(); + d2 = rnd_fr(); + d3 = rnd_fr(); + zo = rnd_zo(); + break; + } + + vd = vset(vd, e, d); + vd2 = vset(vd2, e, d2); + vd3 = vset(vd3, e, d3); + vzo = vset(vzo, e, zo); + vad = vset(vad, e, fabs(d)); + + // + + sc = xsincospi_u05(vd); + sc2 = xsincospi_u35(vd); + + { + const double rangemax2 = 1e+9/4; + + sinpifr(frx, d); + + double u0 = countULP2dp(t = vget(vd2getx_vd_vd2(sc), e), frx); + + if (u0 != 0 && ((fabs(d) <= rangemax2 && u0 > 0.506) || fabs(t) > 1 || !isnumber(t))) { + printf(ISANAME " sincospi_u05 sin arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + + double u1 = countULP2dp(t = vget(vd2getx_vd_vd2(sc2), e), frx); + + if (u1 != 0 && ((fabs(d) <= rangemax2 && u1 > 1.5) || fabs(t) > 1 || !isnumber(t))) { + printf(ISANAME " sincospi_u35 sin arg=%.20g ulp=%.20g\n", d, u1); + fflush(stdout); ecnt++; + } + + double u2 = countULP2dp(t = vget(xsinpi_u05(vd), e), frx); + + if (u2 != 0 && ((fabs(d) <= rangemax2 && u2 > 0.506) || fabs(t) > 1 || !isnumber(t))) { + printf(ISANAME " sinpi_u05 arg=%.20g ulp=%.20g\n", d, u2); + fflush(stdout); ecnt++; + } + } + + { + const double rangemax2 = 1e+9/4; + + cospifr(frx, d); + + double u0 = countULP2dp(t = vget(vd2gety_vd_vd2(sc), e), frx); + + if (u0 != 0 && ((fabs(d) <= rangemax2 && u0 > 0.506) || fabs(t) > 1 || !isnumber(t))) { + printf(ISANAME " sincospi_u05 cos arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + + double u1 = countULP2dp(t = vget(vd2gety_vd_vd2(sc), e), frx); + + if (u1 != 0 && ((fabs(d) <= rangemax2 && u1 > 1.5) || fabs(t) > 1 || !isnumber(t))) { + printf(ISANAME " sincospi_u35 cos arg=%.20g ulp=%.20g\n", d, u1); + fflush(stdout); ecnt++; + } + + double u2 = countULP2dp(t = vget(xcospi_u05(vd), e), frx); + + if (u2 != 0 && ((fabs(d) <= rangemax2 && u2 > 0.506) || fabs(t) > 1 || !isnumber(t))) { + printf(ISANAME " cospi_u05 arg=%.20g ulp=%.20g\n", d, u2); + fflush(stdout); ecnt++; + } + } + + sc = xsincos(vd); + sc2 = xsincos_u1(vd); + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_sin(frx, frx, GMP_RNDN); + + double u0 = countULPdp(t = vget(xsin(vd), e), frx); + + if (u0 != 0 && (u0 > 3.5 || fabs(t) > 1 || !isnumber(t))) { + printf(ISANAME " sin arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + + double u1 = countULPdp(t = vget(vd2getx_vd_vd2(sc), e), frx); + + if (u1 != 0 && (u1 > 3.5 || fabs(t) > 1 || !isnumber(t))) { + printf(ISANAME " sincos sin arg=%.20g ulp=%.20g\n", d, u1); + fflush(stdout); ecnt++; + } + + double u2 = countULPdp(t = vget(xsin_u1(vd), e), frx); + + if (u2 != 0 && (u2 > 1 || fabs(t) > 1 || !isnumber(t))) { + printf(ISANAME " sin_u1 arg=%.20g ulp=%.20g\n", d, u2); + fflush(stdout); ecnt++; + } + + double u3 = countULPdp(t = vget(vd2getx_vd_vd2(sc2), e), frx); + + if (u3 != 0 && (u3 > 1 || fabs(t) > 1 || !isnumber(t))) { + printf(ISANAME " sincos_u1 sin arg=%.20g ulp=%.20g\n", d, u3); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_cos(frx, frx, GMP_RNDN); + + double u0 = countULPdp(t = vget(xcos(vd), e), frx); + + if (u0 != 0 && (u0 > 3.5 || fabs(t) > 1 || !isnumber(t))) { + printf(ISANAME " cos arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + + double u1 = countULPdp(t = vget(vd2gety_vd_vd2(sc), e), frx); + + if (u1 != 0 && (u1 > 3.5 || fabs(t) > 1 || !isnumber(t))) { + printf(ISANAME " sincos cos arg=%.20g ulp=%.20g\n", d, u1); + fflush(stdout); ecnt++; + } + + double u2 = countULPdp(t = vget(xcos_u1(vd), e), frx); + + if (u2 != 0 && (u2 > 1 || fabs(t) > 1 || !isnumber(t))) { + printf(ISANAME " cos_u1 arg=%.20g ulp=%.20g\n", d, u2); + fflush(stdout); ecnt++; + } + + double u3 = countULPdp(t = vget(vd2gety_vd_vd2(sc2), e), frx); + + if (u3 != 0 && (u3 > 1 || fabs(t) > 1 || !isnumber(t))) { + printf(ISANAME " sincos_u1 cos arg=%.20g ulp=%.20g\n", d, u3); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_tan(frx, frx, GMP_RNDN); + + double u0 = countULPdp(t = vget(xtan(vd), e), frx); + + if (u0 != 0 && (u0 > 3.5 || isnan(t))) { + printf(ISANAME " tan arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + + double u1 = countULPdp(t = vget(xtan_u1(vd), e), frx); + + if (u1 != 0 && (u1 > 1 || isnan(t))) { + printf(ISANAME " tan_u1 arg=%.20g ulp=%.20g\n", d, u1); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, fabs(d), GMP_RNDN); + mpfr_log(frx, frx, GMP_RNDN); + + double u0 = countULPdp(t = vget(xlog(vad), e), frx); + + if (u0 > 3.5) { + printf(ISANAME " log arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + + double u1 = countULPdp(t = vget(xlog_u1(vad), e), frx); + + if (u1 > 1) { + printf(ISANAME " log_u1 arg=%.20g ulp=%.20g\n", d, u1); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, fabs(d), GMP_RNDN); + mpfr_log10(frx, frx, GMP_RNDN); + + double u0 = countULPdp(t = vget(xlog10(vad), e), frx); + + if (u0 > 1) { + printf(ISANAME " log10 arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, fabs(d), GMP_RNDN); + mpfr_log2(frx, frx, GMP_RNDN); + + double u0 = countULPdp(t = vget(xlog2(vad), e), frx); + + if (u0 > 1) { + printf(ISANAME " log2 arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + + double u1 = countULPdp(t = vget(xlog2_u35(vad), e), frx); + + if (u1 > 3.5) { + printf(ISANAME " log2_u35 arg=%.20g ulp=%.20g\n", d, u1); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_log1p(frx, frx, GMP_RNDN); + + double u0 = countULPdp(t = vget(xlog1p(vd), e), frx); + + if ((-1 <= d && d <= 1e+307 && u0 > 1) || + (d < -1 && !isnan(t)) || + (d > 1e+307 && !(u0 <= 1 || isinf(t)))) { + printf(ISANAME " log1p arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_exp(frx, frx, GMP_RNDN); + + double u0 = countULPdp(t = vget(xexp(vd), e), frx); + + if (u0 > 1) { + printf(ISANAME " exp arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_exp2(frx, frx, GMP_RNDN); + + double u0 = countULPdp(t = vget(xexp2(vd), e), frx); + + if (u0 > 1) { + printf(ISANAME " exp2 arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + + double u1 = countULPdp(t = vget(xexp2_u35(vd), e), frx); + + if (u1 > 3.5) { + printf(ISANAME " exp2_u35 arg=%.20g ulp=%.20g\n", d, u1); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_exp10(frx, frx, GMP_RNDN); + + double u0 = countULPdp(t = vget(xexp10(vd), e), frx); + + if (u0 > 1.09) { + printf(ISANAME " exp10 arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + + double u1 = countULPdp(t = vget(xexp10_u35(vd), e), frx); + + if (u1 > 3.5) { + printf(ISANAME " exp10_u35 arg=%.20g ulp=%.20g\n", d, u1); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_expm1(frx, frx, GMP_RNDN); + + double u0 = countULPdp(t = vget(xexpm1(vd), e), frx); + + if (u0 > 1) { + printf(ISANAME " expm1 arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_set_d(fry, d2, GMP_RNDN); + mpfr_pow(frx, fry, frx, GMP_RNDN); + + double u0 = countULPdp(t = vget(xpow(vd2, vd), e), frx); + + if (u0 > 1) { + printf(ISANAME " pow arg=%.20g, %.20g ulp=%.20g\n", d2, d, u0); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_cbrt(frx, frx, GMP_RNDN); + + double u0 = countULPdp(t = vget(xcbrt(vd), e), frx); + + if (u0 > 3.5) { + printf(ISANAME " cbrt arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + + double u1 = countULPdp(t = vget(xcbrt_u1(vd), e), frx); + + if (u1 > 1) { + printf(ISANAME " cbrt_u1 arg=%.20g ulp=%.20g\n", d, u1); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, zo, GMP_RNDN); + mpfr_asin(frx, frx, GMP_RNDN); + + double u0 = countULPdp(t = vget(xasin(vzo), e), frx); + + if (u0 > 3.5) { + printf(ISANAME " asin arg=%.20g ulp=%.20g\n", zo, u0); + fflush(stdout); ecnt++; + } + + double u1 = countULPdp(t = vget(xasin_u1(vzo), e), frx); + + if (u1 > 1) { + printf(ISANAME " asin_u1 arg=%.20g ulp=%.20g\n", zo, u1); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, zo, GMP_RNDN); + mpfr_acos(frx, frx, GMP_RNDN); + + double u0 = countULPdp(t = vget(xacos(vzo), e), frx); + + if (u0 > 3.5) { + printf(ISANAME " acos arg=%.20g ulp=%.20g\n", zo, u0); + fflush(stdout); ecnt++; + } + + double u1 = countULPdp(t = vget(xacos_u1(vzo), e), frx); + + if (u1 > 1) { + printf(ISANAME " acos_u1 arg=%.20g ulp=%.20g\n", zo, u1); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_atan(frx, frx, GMP_RNDN); + + double u0 = countULPdp(t = vget(xatan(vd), e), frx); + + if (u0 > 3.5) { + printf(ISANAME " atan arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + + double u1 = countULPdp(t = vget(xatan_u1(vd), e), frx); + + if (u1 > 1) { + printf(ISANAME " atan_u1 arg=%.20g ulp=%.20g\n", d, u1); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_set_d(fry, d2, GMP_RNDN); + mpfr_atan2(frx, fry, frx, GMP_RNDN); + + double u0 = countULPdp(t = vget(xatan2(vd2, vd), e), frx); + + if (u0 > 3.5) { + printf(ISANAME " atan2 arg=%.20g, %.20g ulp=%.20g\n", d2, d, u0); + fflush(stdout); ecnt++; + } + + double u1 = countULP2dp(t = vget(xatan2_u1(vd2, vd), e), frx); + + if (u1 > 1) { + printf(ISANAME " atan2_u1 arg=%.20g, %.20g ulp=%.20g\n", d2, d, u1); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_sinh(frx, frx, GMP_RNDN); + + double u0 = countULPdp(t = vget(xsinh(vd), e), frx); + + if ((fabs(d) <= 709 && u0 > 1) || + (d > 709 && !(u0 <= 1 || (isinf(t) && t > 0))) || + (d < -709 && !(u0 <= 1 || (isinf(t) && t < 0)))) { + printf(ISANAME " sinh arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_cosh(frx, frx, GMP_RNDN); + + double u0 = countULPdp(t = vget(xcosh(vd), e), frx); + + if ((fabs(d) <= 709 && u0 > 1) || !(u0 <= 1 || (isinf(t) && t > 0))) { + printf(ISANAME " cosh arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_tanh(frx, frx, GMP_RNDN); + + double u0 = countULPdp(t = vget(xtanh(vd), e), frx); + + if (u0 > 1) { + printf(ISANAME " tanh arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_sinh(frx, frx, GMP_RNDN); + + double u0 = countULPdp(t = vget(xsinh_u35(vd), e), frx); + + if ((fabs(d) <= 709 && u0 > 3.5) || + (d > 709 && !(u0 <= 3.5 || (isinf(t) && t > 0))) || + (d < -709 && !(u0 <= 3.5 || (isinf(t) && t < 0)))) { + printf(ISANAME " sinh_u35 arg=%.20g ulp=%.20g\n", d, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_cosh(frx, frx, GMP_RNDN); + + double u0 = countULPdp(t = vget(xcosh_u35(vd), e), frx); + + if ((fabs(d) <= 709 && u0 > 3.5) || !(u0 <= 3.5 || (isinf(t) && t > 0))) { + printf(ISANAME " cosh_u35 arg=%.20g ulp=%.20g\n", d, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_tanh(frx, frx, GMP_RNDN); + + double u0 = countULPdp(t = vget(xtanh_u35(vd), e), frx); + + if (u0 > 3.5) { + printf(ISANAME " tanh_u35 arg=%.20g ulp=%.20g\n", d, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_asinh(frx, frx, GMP_RNDN); + + double u0 = countULPdp(t = vget(xasinh(vd), e), frx); + + if ((fabs(d) < sqrt(DBL_MAX) && u0 > 1) || + (d >= sqrt(DBL_MAX) && !(u0 <= 1 || (isinf(t) && t > 0))) || + (d <= -sqrt(DBL_MAX) && !(u0 <= 1 || (isinf(t) && t < 0)))) { + printf(ISANAME " asinh arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_acosh(frx, frx, GMP_RNDN); + + double u0 = countULPdp(t = vget(xacosh(vd), e), frx); + + if ((fabs(d) < sqrt(DBL_MAX) && u0 > 1) || + (d >= sqrt(DBL_MAX) && !(u0 <= 1 || (isinf(t) && t > 0))) || + (d <= -sqrt(DBL_MAX) && !isnan(t))) { + printf(ISANAME " acosh arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_atanh(frx, frx, GMP_RNDN); + + double u0 = countULPdp(t = vget(xatanh(vd), e), frx); + + if (u0 > 1) { + printf(ISANAME " atanh arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + } + + // + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_abs(frx, frx, GMP_RNDN); + + double u0 = countULPdp(t = vget(xfabs(vd), e), frx); + + if (u0 != 0) { + printf(ISANAME " fabs arg=%.20g ulp=%.20g\n", d, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_set_d(fry, d2, GMP_RNDN); + mpfr_copysign(frx, frx, fry, GMP_RNDN); + + double u0 = countULPdp(t = vget(xcopysign(vd, vd2), e), frx); + + if (u0 != 0 && !isnan(d2)) { + printf(ISANAME " copysign arg=%.20g, %.20g ulp=%.20g\n", d, d2, u0); + printf("correct = %g, test = %g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_set_d(fry, d2, GMP_RNDN); + mpfr_max(frx, frx, fry, GMP_RNDN); + + double u0 = countULPdp(t = vget(xfmax(vd, vd2), e), frx); + + if (u0 != 0) { + printf(ISANAME " fmax arg=%.20g, %.20g ulp=%.20g\n", d, d2, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_set_d(fry, d2, GMP_RNDN); + mpfr_min(frx, frx, fry, GMP_RNDN); + + double u0 = countULPdp(t = vget(xfmin(vd, vd2), e), frx); + + if (u0 != 0) { + printf(ISANAME " fmin arg=%.20g, %.20g ulp=%.20g\n", d, d2, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_set_d(fry, d2, GMP_RNDN); + mpfr_dim(frx, frx, fry, GMP_RNDN); + + double u0 = countULPdp(t = vget(xfdim(vd, vd2), e), frx); + + if (u0 > 0.5) { + printf(ISANAME " fdim arg=%.20g, %.20g ulp=%.20g\n", d, d2, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_trunc(frx, frx); + + double u0 = countULPdp(t = vget(xtrunc(vd), e), frx); + + if (u0 != 0) { + printf(ISANAME " trunc arg=%.20g ulp=%.20g\n", d, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_floor(frx, frx); + + double u0 = countULPdp(t = vget(xfloor(vd), e), frx); + + if (u0 != 0) { + printf(ISANAME " floor arg=%.20g ulp=%.20g\n", d, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_ceil(frx, frx); + + double u0 = countULPdp(t = vget(xceil(vd), e), frx); + + if (u0 != 0) { + printf(ISANAME " ceil arg=%.20g ulp=%.20g\n", d, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_round(frx, frx); + + double u0 = countULPdp(t = vget(xround(vd), e), frx); + + if (u0 != 0) { + printf(ISANAME " round arg=%.24g ulp=%.20g\n", d, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_rint(frx, frx, GMP_RNDN); + + double u0 = countULPdp(t = vget(xrint(vd), e), frx); + + if (u0 != 0) { + printf(ISANAME " rint arg=%.24g ulp=%.20g\n", d, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_set_d(fry, d2, GMP_RNDN); + mpfr_set_d(frz, d3, GMP_RNDN); + mpfr_fma(frx, frx, fry, frz, GMP_RNDN); + + double u0 = countULP2dp(t = vget(xfma(vd, vd2, vd3), e), frx); + double c = mpfr_get_d(frx, GMP_RNDN); + + if ((-1e+303 < c && c < 1e+303 && u0 > 0.5) || + !(u0 <= 0.5 || isinf(t))) { + printf(ISANAME " fma arg=%.20g, %.20g, %.20g ulp=%.20g\n", d, d2, d3, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + +#ifndef DETERMINISTIC + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_sqrt(frx, frx, GMP_RNDN); + + double u0 = countULPdp(t = vget(xsqrt(vd), e), frx); + + if (u0 > 1.0) { + printf(ISANAME " sqrt arg=%.20g ulp=%.20g\n", d, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_sqrt(frx, frx, GMP_RNDN); + + double u0 = countULPdp(t = vget(xsqrt_u05(vd), e), frx); + + if (u0 > 0.50001) { + printf(ISANAME " sqrt_u05 arg=%.20g ulp=%.20g\n", d, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_sqrt(frx, frx, GMP_RNDN); + + double u0 = countULPdp(t = vget(xsqrt_u35(vd), e), frx); + + if (u0 > 3.5) { + printf(ISANAME " sqrt_u35 arg=%.20g ulp=%.20g\n", d, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } +#endif // #ifndef DETERMINISTIC + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_set_d(fry, d2, GMP_RNDN); + mpfr_hypot(frx, frx, fry, GMP_RNDN); + + double u0 = countULP2dp(t = vget(xhypot_u05(vd, vd2), e), frx); + + if (u0 > 0.5) { + printf(ISANAME " hypot_u05 arg=%.20g, %.20g ulp=%.20g\n", d, d2, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_set_d(fry, d2, GMP_RNDN); + mpfr_hypot(frx, frx, fry, GMP_RNDN); + + double u0 = countULP2dp(t = vget(xhypot_u35(vd, vd2), e), frx); + double c = mpfr_get_d(frx, GMP_RNDN); + + if ((-1e+308 < c && c < 1e+308 && u0 > 3.5) || + !(u0 <= 3.5 || isinf(t))) { + if (!(isinf(c) && t == 1.7976931348623157081e+308)) { + printf(ISANAME " hypot_u35 arg=%.20g, %.20g ulp=%.20g\n", d, d2, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + } + + { + t = vget(xnextafter(vd, vd2), e); + double c = nextafter(d, d2); + + if (!(isnan(t) && isnan(c)) && t != c) { + printf(ISANAME " nextafter arg=%.20g, %.20g\n", d, d2); + printf("correct = %.20g, test = %.20g\n", c, t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_set_exp(frx, 0); + + double u0 = countULPdp(t = vget(xfrfrexp(vd), e), frx); + + if (d != 0 && isnumber(d) && u0 != 0) { + printf(ISANAME " frfrexp arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_set_d(fry, d2, GMP_RNDN); + mpfr_fmod(frx, frx, fry, GMP_RNDN); + + double u0 = countULPdp(t = vget(xfmod(vd, vd2), e), frx); + + if (fabsl((long double)d / d2) < 1e+300 && u0 > 0.5) { + printf(ISANAME " fmod arg=%.20g, %.20g ulp=%.20g\n", d, d2, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_set_d(fry, d2, GMP_RNDN); + mpfr_remainder(frx, frx, fry, GMP_RNDN); + + double u0 = countULPdp(t = vget(xremainder(vd, vd2), e), frx); + + if (fabsl((long double)d / d2) < 1e+300 && u0 > 0.5) { + printf(ISANAME " remainder arg=%.20g, %.20g ulp=%.20g\n", d, d2, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + /* + { + mpfr_set_d(frx, d, GMP_RNDN); + int cexp = mpfr_get_exp(frx); + + int texp = vgeti(xexpfrexp(vd), e); + + if (isnumber(d) && cexp != texp) { + printf(ISANAME " expfrexp arg=%.20g\n", d); + fflush(stdout); ecnt++; + } + } + + { + int exp = (random() & 8191) - 4096; + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_set_exp(frx, mpfr_get_exp(frx) + exp); + + double u0 = countULPdp(t = vget(xldexp(d, exp), e), frx); + + if (u0 > 0.5) { + printf(ISANAME " ldexp arg=%.20g %d ulp=%.20g\n", d, exp, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + */ + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_modf(fry, frz, frx, GMP_RNDN); + + vdouble2 t2 = xmodf(vd); + double u0 = countULPdp(vget(vd2getx_vd_vd2(t2), e), frz); + double u1 = countULPdp(vget(vd2gety_vd_vd2(t2), e), fry); + + if (u0 != 0 || u1 != 0) { + printf(ISANAME " modf arg=%.20g ulp=%.20g %.20g\n", d, u0, u1); + printf("correct = %.20g, %.20g\n", mpfr_get_d(frz, GMP_RNDN), mpfr_get_d(fry, GMP_RNDN)); + printf("test = %.20g, %.20g\n", vget(vd2getx_vd_vd2(t2), e), vget(vd2gety_vd_vd2(t2), e)); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + int s; + mpfr_lgamma(frx, &s, frx, GMP_RNDN); + + double u0 = countULPdp(t = vget(xlgamma_u1(vd), e), frx); + + if (((d < 0 && fabsl(t - mpfr_get_ld(frx, GMP_RNDN)) > 1e-15 && u0 > 1) || (0 <= d && d < 2e+305 && u0 > 1) || (2e+305 <= d && !(u0 <= 1 || isinf(t))))) { + printf(ISANAME " xlgamma_u1 arg=%.20g ulp=%.20g\n", d, u0); + printf("Correct = %.20Lg, test = %.20g\n", mpfr_get_ld(frx, GMP_RNDN), t); + printf("Diff = %.20Lg\n", fabsl(t - mpfr_get_ld(frx, GMP_RNDN))); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_gamma(frx, frx, GMP_RNDN); + + double u0 = countULP2dp(t = vget(xtgamma_u1(vd), e), frx); + + if (u0 > 1.0) { + printf(ISANAME " xtgamma_u1 arg=%.20g ulp=%.20g\n", d, u0); + printf("Correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + printf("Diff = %.20Lg\n", fabsl(t - mpfr_get_ld(frx, GMP_RNDN))); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_erfc(frx, frx, GMP_RNDN); + + static double ebz = 9.8813129168249308835e-324; // nextafter(nextafter(0, 1), 1); + + double u0 = countULP2dp(t = vget(xerfc_u15(vd), e), frx); + + if ((d > 26.2 && u0 > 2.5 && !(mpfr_get_d(frx, GMP_RNDN) == 0 && t <= ebz)) || (d <= 26.2 && u0 > 1.5)) { + printf(ISANAME " xerfc_u15 arg=%.20g ulp=%.20g\n", d, u0); + printf("Correct = %.20Lg, test = %.20g\n", mpfr_get_ld(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_erf(frx, frx, GMP_RNDN); + + double u0 = countULP2dp(t = vget(xerf_u1(vd), e), frx); + + if (u0 > 0.75) { + printf(ISANAME " xerf_u1 arg=%.20g ulp=%.20g\n", d, u0); + printf("Correct = %.20Lg, test = %.20g\n", mpfr_get_ld(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + } + mpfr_clears(frw, frx, fry, frz, NULL); +} diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-tester/tester2simdsp.c b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-tester/tester2simdsp.c new file mode 100644 index 00000000000..930cadfb43d --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-tester/tester2simdsp.c @@ -0,0 +1,1298 @@ +// Copyright Naoki Shibata and contributors 2010 - 2023. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include +#include +#include + +#include + +#ifdef ENABLE_SYS_getrandom +#define _GNU_SOURCE +#include +#include +#endif + +#include "sleef.h" +#include "quaddef.h" +#include "testerutil.h" + +#ifdef ENABLE_SSE2 +#define CONFIG 2 +#include "helpersse2.h" +#include "renamesse2.h" +typedef Sleef___m128d_2 vdouble2; +typedef Sleef___m128_2 vfloat2; +#endif + +#ifdef ENABLE_SSE4 +#define CONFIG 4 +#include "helpersse2.h" +#include "renamesse4.h" +typedef Sleef___m128d_2 vdouble2; +typedef Sleef___m128_2 vfloat2; +#endif + +#ifdef ENABLE_AVX +#define CONFIG 1 +#include "helperavx.h" +#include "renameavx.h" +typedef Sleef___m256d_2 vdouble2; +typedef Sleef___m256_2 vfloat2; +#endif + +#ifdef ENABLE_FMA4 +#define CONFIG 4 +#include "helperavx.h" +#include "renamefma4.h" +typedef Sleef___m256d_2 vdouble2; +typedef Sleef___m256_2 vfloat2; +#endif + +#ifdef ENABLE_AVX2 +#define CONFIG 1 +#include "helperavx2.h" +#include "renameavx2.h" +typedef Sleef___m256d_2 vdouble2; +typedef Sleef___m256_2 vfloat2; +#endif + +#ifdef ENABLE_AVX2128 +#define CONFIG 1 +#include "helperavx2_128.h" +#include "renameavx2128.h" +typedef Sleef___m128d_2 vdouble2; +typedef Sleef___m128_2 vfloat2; +#endif + +#ifdef ENABLE_AVX512F +#define CONFIG 1 +#include "helperavx512f.h" +#include "renameavx512f.h" +typedef Sleef___m512d_2 vdouble2; +typedef Sleef___m512_2 vfloat2; +#endif + +#ifdef ENABLE_AVX512FNOFMA +#define CONFIG 2 +#include "helperavx512f.h" +#include "renameavx512fnofma.h" +typedef Sleef___m512d_2 vdouble2; +typedef Sleef___m512_2 vfloat2; +#endif + +#ifdef ENABLE_VECEXT +#define CONFIG 1 +#include "helpervecext.h" +#include "norename.h" +#endif + +#ifdef ENABLE_PUREC +#define CONFIG 1 +#include "helperpurec.h" +#include "norename.h" +#endif + +#ifdef ENABLE_ADVSIMD +#define CONFIG 1 +#include "helperadvsimd.h" +#include "renameadvsimd.h" +typedef Sleef_float64x2_t_2 vdouble2; +typedef Sleef_float32x4_t_2 vfloat2; +#endif + +#ifdef ENABLE_ADVSIMDNOFMA +#define CONFIG 2 +#include "helperadvsimd.h" +#include "renameadvsimdnofma.h" +typedef Sleef_float64x2_t_2 vdouble2; +typedef Sleef_float32x4_t_2 vfloat2; +#endif + +#ifdef ENABLE_SVE +#define CONFIG 1 +#include "helpersve.h" +#include "renamesve.h" +#endif /* ENABLE_SVE */ + +#ifdef ENABLE_SVENOFMA +#define CONFIG 2 +#include "helpersve.h" +#include "renamesvenofma.h" +#endif + +#ifdef ENABLE_VSX +#define CONFIG 1 +#include "helperpower_128.h" +#include "renamevsx.h" +typedef Sleef_SLEEF_VECTOR_DOUBLE_2 vdouble2; +typedef Sleef_SLEEF_VECTOR_FLOAT_2 vfloat2; +#endif + +#ifdef ENABLE_VSXNOFMA +#define CONFIG 2 +#include "helperpower_128.h" +#include "renamevsxnofma.h" +typedef Sleef_SLEEF_VECTOR_DOUBLE_2 vdouble2; +typedef Sleef_SLEEF_VECTOR_FLOAT_2 vfloat2; +#endif + +#ifdef ENABLE_VSX3 +#define CONFIG 3 +#include "helperpower_128.h" +#include "renamevsx3.h" +typedef Sleef_SLEEF_VECTOR_DOUBLE_2 vdouble2; +typedef Sleef_SLEEF_VECTOR_FLOAT_2 vfloat2; +#endif + +#ifdef ENABLE_VSX3NOFMA +#define CONFIG 4 +#include "helperpower_128.h" +#include "renamevsx3nofma.h" +typedef Sleef_SLEEF_VECTOR_DOUBLE_2 vdouble2; +typedef Sleef_SLEEF_VECTOR_FLOAT_2 vfloat2; +#endif + +#ifdef ENABLE_VXE +#define CONFIG 140 +#include "helpers390x_128.h" +#include "renamevxe.h" +typedef Sleef_SLEEF_VECTOR_DOUBLE_2 vdouble2; +typedef Sleef_SLEEF_VECTOR_FLOAT_2 vfloat2; +#endif + +#ifdef ENABLE_VXENOFMA +#define CONFIG 141 +#include "helpers390x_128.h" +#include "renamevxenofma.h" +typedef Sleef_SLEEF_VECTOR_DOUBLE_2 vdouble2; +typedef Sleef_SLEEF_VECTOR_FLOAT_2 vfloat2; +#endif + +#ifdef ENABLE_VXE2 +#define CONFIG 150 +#include "helpers390x_128.h" +#include "renamevxe2.h" +typedef Sleef_SLEEF_VECTOR_DOUBLE_2 vdouble2; +typedef Sleef_SLEEF_VECTOR_FLOAT_2 vfloat2; +#endif + +#ifdef ENABLE_VXE2NOFMA +#define CONFIG 151 +#include "helpers390x_128.h" +#include "renamevxe2nofma.h" +typedef Sleef_SLEEF_VECTOR_DOUBLE_2 vdouble2; +typedef Sleef_SLEEF_VECTOR_FLOAT_2 vfloat2; +#endif + +#ifdef ENABLE_RVVM1 +#define CONFIG 1 +#define ENABLE_RVV_SP +#include "helperrvv.h" +#include "renamervvm1.h" +#include "sleef.h" +#endif + +#ifdef ENABLE_RVVM1NOFMA +#define CONFIG 2 +#define ENABLE_RVV_DP +#include "helperrvv.h" +#include "renamervvm1nofma.h" +#include "sleef.h" +#endif + +#ifdef ENABLE_RVVM2 +#define CONFIG 1 +#define ENABLE_RVV_SP +#include "helperrvv.h" +#include "renamervvm2.h" +#include "sleef.h" +#endif + +#ifdef ENABLE_RVVM2NOFMA +#define CONFIG 2 +#define ENABLE_RVV_DP +#include "helperrvv.h" +#include "renamervvm2nofma.h" +#include "sleef.h" +#endif + +#ifdef ENABLE_PUREC_SCALAR +#define CONFIG 1 +#include "helperpurec_scalar.h" +#include "renamepurec_scalar.h" +typedef Sleef_double_2 vdouble2; +typedef Sleef_float_2 vfloat2; +#endif + +#ifdef ENABLE_PURECFMA_SCALAR +#define CONFIG 2 +#include "helperpurec_scalar.h" +#include "renamepurecfma_scalar.h" +typedef Sleef_double_2 vdouble2; +typedef Sleef_float_2 vfloat2; +#endif + +// + +#if !(defined(ENABLE_SVE) || defined(ENABLE_SVENOFMA) || defined(ENABLE_RVVM1) || defined(ENABLE_RVVM1NOFMA) || defined(ENABLE_RVVM2) || defined(ENABLE_RVVM2NOFMA)) +static vfloat vf2getx_vf_vf2(vfloat2 v) { return v.x; } +static vfloat vf2gety_vf_vf2(vfloat2 v) { return v.y; } +#endif + +// + +#define DENORMAL_FLT_MIN (1.4012984643248170709e-45f) +#define POSITIVE_INFINITYf ((float)INFINITY) +#define NEGATIVE_INFINITYf (-(float)INFINITY) + +typedef union { + double d; + uint64_t u64; + int64_t i64; +} conv64_t; + +typedef union { + float f; + uint32_t u32; + int32_t i32; +} conv32_t; + +static float nexttoward0f(float x, int n) { + union { + float f; + int32_t u; + } cx; + cx.f = x; + cx.u -= n; + return x == 0 ? 0 : cx.f; +} + +float rnd() { + conv32_t c; + switch(random() & 63) { + case 0: return nexttoward0f( 0.0, -(random() & ((1 << (random() & 31)) - 1))); + case 1: return nexttoward0f(-0.0, -(random() & ((1 << (random() & 31)) - 1))); + case 2: return nexttoward0f( INFINITY, (random() & ((1 << (random() & 31)) - 1))); + case 3: return nexttoward0f(-INFINITY, (random() & ((1 << (random() & 31)) - 1))); + } +#ifdef ENABLE_SYS_getrandom + syscall(SYS_getrandom, &c.u32, sizeof(c.u32), 0); +#else + c.u32 = (uint32_t)random() | ((uint32_t)random() << 31); +#endif + return c.f; +} + +float rnd_fr() { + conv32_t c; + do { +#ifdef ENABLE_SYS_getrandom + syscall(SYS_getrandom, &c.u32, sizeof(c.u32), 0); +#else + c.u32 = (uint32_t)random() | ((uint32_t)random() << 31); +#endif + } while(!isnumber(c.f)); + return c.f; +} + +float rnd_zo() { + conv32_t c; + do { +#ifdef ENABLE_SYS_getrandom + syscall(SYS_getrandom, &c.u32, sizeof(c.u32), 0); +#else + c.u32 = (uint32_t)random() | ((uint32_t)random() << 31); +#endif + } while(!isnumber(c.f) || c.f < -1 || 1 < c.f); + return c.f; +} + +vfloat vset(vfloat v, int idx, float d) { + float a[VECTLENSP]; + vstoreu_v_p_vf(a, v); + a[idx] = d; + return vloadu_vf_p(a); +} + +float vget(vfloat v, int idx) { + float a[VECTLENSP]; + vstoreu_v_p_vf(a, v); + return a[idx]; +} + +int main(int argc,char **argv) +{ + mpfr_t frw, frx, fry, frz; + + mpfr_set_default_prec(256); + mpfr_inits(frw, frx, fry, frz, NULL); + + conv32_t cd; + float d, t; + float d2, d3, zo; + vfloat vd = vcast_vf_f(0); + vfloat vd2 = vcast_vf_f(0); + vfloat vd3 = vcast_vf_f(0); + vfloat vzo = vcast_vf_f(0); + vfloat vad = vcast_vf_f(0); + vfloat2 sc, sc2; + int cnt, ecnt = 0; + + srandom(time(NULL)); + + for(cnt = 0;ecnt < 1000;cnt++) { + int e = cnt % VECTLENSP; + switch(cnt & 7) { + case 0: + d = rnd(); + d2 = rnd(); + d3 = rnd(); + zo = rnd(); + break; + case 1: + cd.f = rint(rnd_zo() * 1e+10) * M_PI_4; + cd.i32 += (random() & 0xff) - 0x7f; + d = cd.f; + d2 = rnd(); + d3 = rnd(); + zo = rnd(); + break; + case 2: + cd.f = rnd_fr() * M_PI_4; + cd.i32 += (random() & 0xf) - 0x7; + d = cd.f; + d2 = rnd(); + d3 = rnd(); + zo = rnd(); + break; + default: + d = rnd_fr(); + d2 = rnd_fr(); + d3 = rnd_fr(); + zo = rnd_zo(); + break; + } + + vd = vset(vd, e, d); + vd2 = vset(vd2, e, d2); + vd3 = vset(vd3, e, d3); + vzo = vset(vzo, e, zo); + vad = vset(vad, e, fabs(d)); + + sc = xsincospif_u05(vd); + sc2 = xsincospif_u35(vd); + + { + const double rangemax2 = 1e+7/4; + + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_sinpi(frx, frx, GMP_RNDN); + + double u0 = countULP2sp(t = vget(vf2getx_vf_vf2(sc), e), frx); + + if (u0 != 0 && ((fabs(d) <= rangemax2 && u0 > 0.505) || fabs(t) > 1 || !isnumber(t))) { + printf(ISANAME " sincospif_u05 sin arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + + double u1 = countULP2sp(t = vget(vf2getx_vf_vf2(sc2), e), frx); + + if (u1 != 0 && ((fabs(d) <= rangemax2 && u1 > 2.0) || fabs(t) > 1 || !isnumber(t))) { + printf(ISANAME " sincospif_u35 sin arg=%.20g ulp=%.20g\n", d, u1); + fflush(stdout); ecnt++; + } + + double u2 = countULP2sp(t = vget(xsinpif_u05(vd), e), frx); + + if (u2 != 0 && ((fabs(d) <= rangemax2 && u2 > 0.506) || fabs(t) > 1 || !isnumber(t))) { + printf(ISANAME " sinpif_u05 arg=%.20g ulp=%.20g\n", d, u2); + fflush(stdout); ecnt++; + } + } + + { + const double rangemax2 = 1e+7/4; + + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_cospi(frx, frx, GMP_RNDN); + + double u0 = countULP2sp(t = vget(vf2gety_vf_vf2(sc), e), frx); + + if (u0 != 0 && ((fabs(d) <= rangemax2 && u0 > 0.505) || fabs(t) > 1 || !isnumber(t))) { + printf(ISANAME " sincospif_u05 cos arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + + double u1 = countULP2sp(t = vget(vf2gety_vf_vf2(sc), e), frx); + + if (u1 != 0 && ((fabs(d) <= rangemax2 && u1 > 2.0) || fabs(t) > 1 || !isnumber(t))) { + printf(ISANAME " sincospif_u35 cos arg=%.20g ulp=%.20g\n", d, u1); + fflush(stdout); ecnt++; + } + + double u2 = countULP2sp(t = vget(xcospif_u05(vd), e), frx); + + if (u2 != 0 && ((fabs(d) <= rangemax2 && u2 > 0.506) || fabs(t) > 1 || !isnumber(t))) { + printf(ISANAME " cospif_u05 arg=%.20g ulp=%.20g\n", d, u2); + fflush(stdout); ecnt++; + } + } + + sc = xsincosf(vd); + sc2 = xsincosf_u1(vd); + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_sin(frx, frx, GMP_RNDN); + + float u0 = countULPsp(t = vget(xsinf(vd), e), frx); + + if (u0 != 0 && (u0 > 3.5 || fabs(t) > 1 || !isnumber(t))) { + printf(ISANAME " sinf arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + + float u1 = countULPsp(t = vget(vf2getx_vf_vf2(sc), e), frx); + + if (u1 != 0 && (u1 > 3.5 || fabs(t) > 1 || !isnumber(t))) { + printf(ISANAME " sincosf sin arg=%.20g ulp=%.20g\n", d, u1); + fflush(stdout); ecnt++; + } + + float u2 = countULPsp(t = vget(xsinf_u1(vd), e), frx); + + if (u2 != 0 && (u2 > 1 || fabs(t) > 1 || !isnumber(t))) { + printf(ISANAME " sinf_u1 arg=%.20g ulp=%.20g\n", d, u2); + fflush(stdout); ecnt++; + } + + float u3 = countULPsp(t = vget(vf2getx_vf_vf2(sc2), e), frx); + + if (u3 != 0 && (u3 > 1 || fabs(t) > 1 || !isnumber(t))) { + printf(ISANAME " sincosf_u1 sin arg=%.20g ulp=%.20g\n", d, u3); + fflush(stdout); ecnt++; + } + + float u4 = countULPsp(t = vget(xfastsinf_u3500(vd), e), frx); + double ae4 = fabs(mpfr_get_d(frx, GMP_RNDN) - t); + + if (u4 > 350 && ae4 > 2e-6) { + printf(ISANAME " fastsinf_u3500 arg=%.20g ulp=%.20g\n", d, u4); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_cos(frx, frx, GMP_RNDN); + + float u0 = countULPsp(t = vget(xcosf(vd), e), frx); + + if (u0 != 0 && (u0 > 3.5 || fabs(t) > 1 || !isnumber(t))) { + printf(ISANAME " cosf arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + + float u1 = countULPsp(t = vget(vf2gety_vf_vf2(sc), e), frx); + + if (u1 != 0 && (u1 > 3.5 || fabs(t) > 1 || !isnumber(t))) { + printf(ISANAME " sincosf cos arg=%.20g ulp=%.20g\n", d, u1); + fflush(stdout); ecnt++; + } + + float u2 = countULPsp(t = vget(xcosf_u1(vd), e), frx); + + if (u2 != 0 && (u2 > 1 || fabs(t) > 1 || !isnumber(t))) { + printf(ISANAME " cosf_u1 arg=%.20g ulp=%.20g\n", d, u2); + fflush(stdout); ecnt++; + } + + float u3 = countULPsp(t = vget(vf2gety_vf_vf2(sc2), e), frx); + + if (u3 != 0 && (u3 > 1 || fabs(t) > 1 || !isnumber(t))) { + printf(ISANAME " sincosf_u1 cos arg=%.20g ulp=%.20g\n", d, u3); + fflush(stdout); ecnt++; + } + + float u4 = countULPsp(t = vget(xfastcosf_u3500(vd), e), frx); + double ae4 = fabs(mpfr_get_d(frx, GMP_RNDN) - t); + + if (u4 > 350 && ae4 > 2e-6) { + printf(ISANAME " fastcosf_u3500 arg=%.20g ulp=%.20g\n", d, u4); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_tan(frx, frx, GMP_RNDN); + + float u0 = countULPsp(t = vget(xtanf(vd), e), frx); + + if (u0 != 0 && (u0 > 3.5 || isnan(t))) { + printf(ISANAME " tanf arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + + float u1 = countULPsp(t = vget(xtanf_u1(vd), e), frx); + + if (u1 != 0 && (u1 > 1 || isnan(t))) { + printf(ISANAME " tanf_u1 arg=%.20g ulp=%.20g\n", d, u1); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, fabsf(d), GMP_RNDN); + mpfr_log(frx, frx, GMP_RNDN); + + double u0 = countULPsp(t = vget(xlogf(vad), e), frx); + + if (u0 > 3.5) { + printf(ISANAME " logf arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + + double u1 = countULPsp(t = vget(xlogf_u1(vad), e), frx); + + if (u1 > 1) { + printf(ISANAME " logf_u1 arg=%.20g ulp=%.20g\n", d, u1); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, fabsf(d), GMP_RNDN); + mpfr_log10(frx, frx, GMP_RNDN); + + double u0 = countULPsp(t = vget(xlog10f(vad), e), frx); + + if (u0 > 1) { + printf(ISANAME " log10f arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, fabsf(d), GMP_RNDN); + mpfr_log2(frx, frx, GMP_RNDN); + + double u0 = countULPsp(t = vget(xlog2f(vad), e), frx); + + if (u0 > 1) { + printf(ISANAME " log2f arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + + double u1 = countULPsp(t = vget(xlog2f_u35(vad), e), frx); + + if (u1 > 3.5) { + printf(ISANAME " log2f_u35 arg=%.20g ulp=%.20g\n", d, u1); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_log1p(frx, frx, GMP_RNDN); + + double u0 = countULPsp(t = vget(xlog1pf(vd), e), frx); + + if ((-1 <= d && d <= 1e+38 && u0 > 1) || + (d < -1 && !isnan(t)) || + (d > 1e+38 && !(u0 <= 1 || isinf(t)))) { + printf(ISANAME " log1pf arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_exp(frx, frx, GMP_RNDN); + + double u0 = countULPsp(t = vget(xexpf(vd), e), frx); + + if (u0 > 1) { + printf(ISANAME " expf arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_exp2(frx, frx, GMP_RNDN); + + double u0 = countULPsp(t = vget(xexp2f(vd), e), frx); + + if (u0 > 1) { + printf(ISANAME " exp2f arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + + double u1 = countULPsp(t = vget(xexp2f_u35(vd), e), frx); + + if (u1 > 3.5) { + printf(ISANAME " exp2f_u35 arg=%.20g ulp=%.20g\n", d, u1); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_exp10(frx, frx, GMP_RNDN); + + double u0 = countULPsp(t = vget(xexp10f(vd), e), frx); + + if (u0 > 1) { + printf(ISANAME " exp10f arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + + double u1 = countULPsp(t = vget(xexp10f_u35(vd), e), frx); + + if (u1 > 3.5) { + printf(ISANAME " exp10f_u35 arg=%.20g ulp=%.20g\n", d, u1); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_expm1(frx, frx, GMP_RNDN); + + double u0 = countULPsp(t = vget(xexpm1f(vd), e), frx); + + if (u0 > 1) { + printf(ISANAME " expm1f arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_set_d(fry, d2, GMP_RNDN); + mpfr_pow(frx, fry, frx, GMP_RNDN); + + double u0 = countULPsp(t = vget(xpowf(vd2, vd), e), frx); + + if (u0 > 1) { + printf(ISANAME " powf arg=%.20g, %.20g ulp=%.20g\n", d2, d, u0); + printf("correct = %g, test = %g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + + if (isnumber(d) && isnumber(d2)) { + double u1 = countULPsp(t = vget(xfastpowf_u3500(vd2, vd), e), frx); + + if (isnumber((float)mpfr_get_d(frx, GMP_RNDN)) && u1 > 350) { + printf(ISANAME " fastpowf_u3500 arg=%.20g, %.20g ulp=%.20g\n", d2, d, u1); + printf("correct = %g, test = %g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_cbrt(frx, frx, GMP_RNDN); + + double u0 = countULPsp(t = vget(xcbrtf(vd), e), frx); + + if (u0 > 3.5) { + printf(ISANAME " cbrtf arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + + double u1 = countULPsp(t = vget(xcbrtf_u1(vd), e), frx); + + if (u1 > 1) { + printf(ISANAME " cbrtf_u1 arg=%.20g ulp=%.20g\n", d, u1); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, zo, GMP_RNDN); + mpfr_asin(frx, frx, GMP_RNDN); + + double u0 = countULPsp(t = vget(xasinf(vzo), e), frx); + + if (u0 > 3.5) { + printf(ISANAME " asinf arg=%.20g ulp=%.20g\n", zo, u0); + fflush(stdout); ecnt++; + } + + double u1 = countULPsp(t = vget(xasinf_u1(vzo), e), frx); + + if (u1 > 1) { + printf(ISANAME " asinf_u1 arg=%.20g ulp=%.20g\n", zo, u1); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, zo, GMP_RNDN); + mpfr_acos(frx, frx, GMP_RNDN); + + double u0 = countULPsp(t = vget(xacosf(vzo), e), frx); + + if (u0 > 3.5) { + printf(ISANAME " acosf arg=%.20g ulp=%.20g\n", zo, u0); + fflush(stdout); ecnt++; + } + + double u1 = countULPsp(t = vget(xacosf_u1(vzo), e), frx); + + if (u1 > 1) { + printf(ISANAME " acosf_u1 arg=%.20g ulp=%.20g\n", zo, u1); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_atan(frx, frx, GMP_RNDN); + + double u0 = countULPsp(t = vget(xatanf(vd), e), frx); + + if (u0 > 3.5) { + printf(ISANAME " atanf arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + + double u1 = countULPsp(t = vget(xatanf_u1(vd), e), frx); + + if (u1 > 1) { + printf(ISANAME " atanf_u1 arg=%.20g ulp=%.20g\n", d, u1); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_set_d(fry, d2, GMP_RNDN); + mpfr_atan2(frx, fry, frx, GMP_RNDN); + + double u0 = countULPsp(t = vget(xatan2f(vd2, vd), e), frx); + + if (u0 > 3.5) { + printf(ISANAME " atan2f arg=%.20g, %.20g ulp=%.20g\n", d2, d, u0); + fflush(stdout); ecnt++; + } + + double u1 = countULP2sp(t = vget(xatan2f_u1(vd2, vd), e), frx); + + if (u1 > 1) { + printf(ISANAME " atan2f_u1 arg=%.20g, %.20g ulp=%.20g\n", d2, d, u1); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_sinh(frx, frx, GMP_RNDN); + + double u0 = countULPsp(t = vget(xsinhf(vd), e), frx); + + if ((fabs(d) <= 88.5 && u0 > 1) || + (d > 88.5 && !(u0 <= 1 || (isinf(t) && t > 0))) || + (d < -88.5 && !(u0 <= 1 || (isinf(t) && t < 0)))) { + printf(ISANAME " sinhf arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_cosh(frx, frx, GMP_RNDN); + + double u0 = countULPsp(t = vget(xcoshf(vd), e), frx); + + if ((fabs(d) <= 88.5 && u0 > 1) || !(u0 <= 1 || (isinf(t) && t > 0))) { + printf(ISANAME " coshf arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_tanh(frx, frx, GMP_RNDN); + + double u0 = countULPsp(t = vget(xtanhf(vd), e), frx); + + if (u0 > 1.0001) { + printf(ISANAME " tanhf arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_sinh(frx, frx, GMP_RNDN); + + double u0 = countULPsp(t = vget(xsinhf_u35(vd), e), frx); + + if ((fabs(d) <= 88 && u0 > 3.5) || + (d > 88 && !(u0 <= 3.5 || (isinf(t) && t > 0))) || + (d < -88 && !(u0 <= 3.5 || (isinf(t) && t < 0)))) { + printf(ISANAME " sinhf_u35 arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_cosh(frx, frx, GMP_RNDN); + + double u0 = countULPsp(t = vget(xcoshf_u35(vd), e), frx); + + if ((fabs(d) <= 88 && u0 > 3.5) || !(u0 <= 3.5 || (isinf(t) && t > 0))) { + printf(ISANAME " coshf_u35 arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_tanh(frx, frx, GMP_RNDN); + + double u0 = countULPsp(t = vget(xtanhf_u35(vd), e), frx); + + if (u0 > 3.5) { + printf(ISANAME " tanhf_u35 arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_asinh(frx, frx, GMP_RNDN); + + double u0 = countULPsp(t = vget(xasinhf(vd), e), frx); + + if ((fabs(d) < sqrt(FLT_MAX) && u0 > 1.0001) || + (d >= sqrt(FLT_MAX) && !(u0 <= 1.0001 || (isinf(t) && t > 0))) || + (d <= -sqrt(FLT_MAX) && !(u0 <= 1.0001 || (isinf(t) && t < 0)))) { + printf(ISANAME " asinhf arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_acosh(frx, frx, GMP_RNDN); + + double u0 = countULPsp(t = vget(xacoshf(vd), e), frx); + + if ((fabs(d) < sqrt(FLT_MAX) && u0 > 1.0001) || + (d >= sqrt(FLT_MAX) && !(u0 <= 1.0001 || (isinff(t) && t > 0))) || + (d <= -sqrt(FLT_MAX) && !isnan(t))) { + printf(ISANAME " acoshf arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_atanh(frx, frx, GMP_RNDN); + + double u0 = countULPsp(t = vget(xatanhf(vd), e), frx); + + if (u0 > 1.0001) { + printf(ISANAME " atanhf arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + } + + // + + /* + { + int exp = (random() & 8191) - 4096; + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_set_exp(frx, mpfr_get_exp(frx) + exp); + + double u0 = countULPsp(t = vget(xldexpf(d, exp)), frx); + + if (u0 > 0.5001) { + printf("Pure C ldexpf arg=%.20g %d ulp=%.20g\n", d, exp, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + */ + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_abs(frx, frx, GMP_RNDN); + + double u0 = countULPsp(t = vget(xfabsf(vd), e), frx); + + if (u0 != 0) { + printf(ISANAME " fabsf arg=%.20g ulp=%.20g\n", d, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_set_d(fry, d2, GMP_RNDN); + mpfr_copysign(frx, frx, fry, GMP_RNDN); + + double u0 = countULPsp(t = vget(xcopysignf(vd, vd2), e), frx); + + if (u0 != 0 && !isnan(d2)) { + printf(ISANAME " copysignf arg=%.20g, %.20g ulp=%.20g\n", d, d2, u0); + printf("correct = %g, test = %g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_set_d(fry, d2, GMP_RNDN); + mpfr_max(frx, frx, fry, GMP_RNDN); + + double u0 = countULPsp(t = vget(xfmaxf(vd, vd2), e), frx); + + if (u0 != 0) { + printf(ISANAME " fmaxf arg=%.20g, %.20g ulp=%.20g\n", d, d2, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_set_d(fry, d2, GMP_RNDN); + mpfr_min(frx, frx, fry, GMP_RNDN); + + double u0 = countULPsp(t = vget(xfminf(vd, vd2), e), frx); + + if (u0 != 0) { + printf(ISANAME " fminf arg=%.20g, %.20g ulp=%.20g\n", d, d2, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_set_d(fry, d2, GMP_RNDN); + mpfr_dim(frx, frx, fry, GMP_RNDN); + + double u0 = countULPsp(t = vget(xfdimf(vd, vd2), e), frx); + + if (u0 > 0.5) { + printf(ISANAME " fdimf arg=%.20g, %.20g ulp=%.20g\n", d, d2, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_trunc(frx, frx); + + double u0 = countULPsp(t = vget(xtruncf(vd), e), frx); + + if (u0 != 0) { + printf(ISANAME " truncf arg=%.20g ulp=%.20g\n", d, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_floor(frx, frx); + + double u0 = countULPsp(t = vget(xfloorf(vd), e), frx); + + if (u0 != 0) { + printf(ISANAME " floorf arg=%.20g ulp=%.20g\n", d, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_ceil(frx, frx); + + double u0 = countULPsp(t = vget(xceilf(vd), e), frx); + + if (u0 != 0) { + printf(ISANAME " ceilf arg=%.20g ulp=%.20g\n", d, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_round(frx, frx); + + double u0 = countULPsp(t = vget(xroundf(vd), e), frx); + + if (u0 != 0) { + printf(ISANAME " roundf arg=%.24g ulp=%.20g\n", d, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_rint(frx, frx, GMP_RNDN); + + double u0 = countULPsp(t = vget(xrintf(vd), e), frx); + + if (u0 != 0) { + printf(ISANAME " rintf arg=%.24g ulp=%.20g\n", d, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_modf(fry, frz, frx, GMP_RNDN); + + vfloat2 t2 = xmodff(vd); + double u0 = countULPsp(vget(vf2getx_vf_vf2(t2), e), frz); + double u1 = countULPsp(vget(vf2gety_vf_vf2(t2), e), fry); + + if (u0 != 0 || u1 != 0) { + printf(ISANAME " modff arg=%.20g ulp=%.20g %.20g\n", d, u0, u1); + printf("correct = %.20g, %.20g\n", mpfr_get_d(frz, GMP_RNDN), mpfr_get_d(fry, GMP_RNDN)); + printf("test = %.20g, %.20g\n", vget(vf2getx_vf_vf2(t2), e), vget(vf2gety_vf_vf2(t2), e)); + fflush(stdout); ecnt++; + } + } + + { + t = vget(xnextafterf(vd, vd2), e); + double c = nextafterf(d, d2); + + if (!(isnan(t) && isnan(c)) && t != c) { + printf(ISANAME " nextafterf arg=%.20g, %.20g\n", d, d2); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_set_exp(frx, 0); + + double u0 = countULPsp(t = vget(xfrfrexpf(vd), e), frx); + + if (d != 0 && isnumber(d) && u0 != 0) { + printf(ISANAME " frfrexpf arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + } + + /* + { + mpfr_set_d(frx, d, GMP_RNDN); + int cexp = mpfr_get_exp(frx); + + int texp = xexpfrexpf(d); + + if (d != 0 && isnumber(d) && cexp != texp) { + printf(ISANAME " expfrexpf arg=%.20g\n", d); + fflush(stdout); ecnt++; + } + } + */ + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_set_d(fry, d2, GMP_RNDN); + mpfr_hypot(frx, frx, fry, GMP_RNDN); + + double u0 = countULP2sp(t = vget(xhypotf_u05(vd, vd2), e), frx); + + if (u0 > 0.5001) { + printf(ISANAME " hypotf_u05 arg=%.20g, %.20g ulp=%.20g\n", d, d2, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_set_d(fry, d2, GMP_RNDN); + mpfr_hypot(frx, frx, fry, GMP_RNDN); + + double u0 = countULP2sp(t = vget(xhypotf_u35(vd, vd2), e), frx); + + if (u0 >= 3.5) { + printf(ISANAME " hypotf_u35 arg=%.20g, %.20g ulp=%.20g\n", d, d2, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_set_d(fry, d2, GMP_RNDN); + mpfr_fmod(frx, frx, fry, GMP_RNDN); + + double u0 = countULPsp(t = vget(xfmodf(vd, vd2), e), frx); + + if (fabs((double)d / d2) < 1e+38 && u0 > 0.5) { + printf(ISANAME " fmodf arg=%.20g, %.20g ulp=%.20g\n", d, d2, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_set_d(fry, d2, GMP_RNDN); + mpfr_remainder(frx, frx, fry, GMP_RNDN); + + double u0 = countULPsp(t = vget(xremainderf(vd, vd2), e), frx); + + if (fabs((double)d / d2) < 1e+38 && u0 > 0.5) { + printf(ISANAME " remainderf arg=%.20g, %.20g ulp=%.20g\n", d, d2, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_set_d(fry, d2, GMP_RNDN); + mpfr_set_d(frz, d3, GMP_RNDN); + mpfr_fma(frx, frx, fry, frz, GMP_RNDN); + + double u0 = countULP2sp(t = vget(xfmaf(vd, vd2, vd3), e), frx); + double c = mpfr_get_d(frx, GMP_RNDN); + + if ((-1e+34 < c && c < 1e+33 && u0 > 0.5001) || + !(u0 <= 0.5001 || isinf(t))) { + printf(ISANAME " fmaf arg=%.20g, %.20g, %.20g ulp=%.20g\n", d, d2, d3, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + +#ifndef DETERMINISTIC + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_sqrt(frx, frx, GMP_RNDN); + + double u0 = countULPsp(t = vget(xsqrtf(vd), e), frx); + + if (u0 > 1.0) { + printf(ISANAME " sqrtf arg=%.20g ulp=%.20g\n", d, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_sqrt(frx, frx, GMP_RNDN); + + double u0 = countULPsp(t = vget(xsqrtf_u05(vd), e), frx); + + if (u0 > 0.5001) { + printf(ISANAME " sqrtf_u05 arg=%.20g ulp=%.20g\n", d, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_sqrt(frx, frx, GMP_RNDN); + + double u0 = countULPsp(t = vget(xsqrtf_u35(vd), e), frx); + + if (u0 > 3.5) { + printf(ISANAME " sqrtf_u35 arg=%.20g ulp=%.20g\n", d, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } +#endif // #ifndef DETERMINISTIC + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_erfc(frx, frx, GMP_RNDN); + + double u0 = countULP2sp(t = vget(xerfcf_u15(vd), e), frx); + + if (u0 > 1.5) { + printf(ISANAME " erfcf_u15 arg=%.20g ulp=%.20g\n", d, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_erf(frx, frx, GMP_RNDN); + + double u0 = countULP2sp(t = vget(xerff_u1(vd), e), frx); + + if (u0 > 0.75) { + printf(ISANAME " erff_u1 arg=%.20g ulp=%.20g\n", d, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + int s; + mpfr_lgamma(frx, &s, frx, GMP_RNDN); + + double u0 = countULPsp(t = vget(xlgammaf_u1(vd), e), frx); + + if (((d < 0 && fabsl(t - mpfr_get_ld(frx, GMP_RNDN)) > 1e-8 && u0 > 1) || + (0 <= d && d < 4e+36 && u0 > 1) || (4e+36 <= d && !(u0 <= 1 || isinf(t))))) { + printf(ISANAME " xlgammaf_u1 arg=%.20g ulp=%.20g\n", d, u0); + printf("correct = %.20g, test = %.20g\n", (float)mpfr_get_d(frx, GMP_RNDN), t); + printf("Diff = %.20Lg\n", fabsl(t - mpfr_get_ld(frx, GMP_RNDN))); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_gamma(frx, frx, GMP_RNDN); + + double u0 = countULP2sp(t = vget(xtgammaf_u1(vd), e), frx); + double c = mpfr_get_d(frx, GMP_RNDN); + + if (isnumber(c) || isnumber(t)) { + if (u0 > 1.0) { + printf(ISANAME " xtgammaf_u1 arg=%.20g ulp=%.20g\n", d, u0); + printf("correct = %.20g, test = %.20g\n", (float)mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + } + +#if 0 + if (cnt % 1000 == 0) { + printf("cnt = %d \r", cnt); + fflush(stdout); + } +#endif + } + mpfr_clears(frw, frx, fry, frz, NULL); +} diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-tester/tester2sp.c b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-tester/tester2sp.c new file mode 100644 index 00000000000..b5af3965168 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-tester/tester2sp.c @@ -0,0 +1,1037 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include +#include +#include + +#include + +#ifdef ENABLE_SYS_getrandom +#define _GNU_SOURCE +#include +#include +#include +#endif + +#include "sleef.h" +#include "testerutil.h" + +#define DORENAME +#include "rename.h" + +#if defined(__APPLE__) +static int isinff(float x) { return x == __builtin_inff() || x == -__builtin_inff(); } +#endif + +#if defined(__FreeBSD__) +#define isinff(x) ((x) == (float)(1e+300) || (x) == -(float)(1e+300)) +#endif + +#define DENORMAL_FLT_MIN (1.4012984643248170709e-45f) +#define POSITIVE_INFINITYf ((float)INFINITY) +#define NEGATIVE_INFINITYf (-(float)INFINITY) + +typedef union { + double d; + uint64_t u64; + int64_t i64; +} conv64_t; + +typedef union { + float f; + uint32_t u32; + int32_t i32; +} conv32_t; + +static float nexttoward0f(float x, int n) { + union { + float f; + int32_t u; + } cx; + cx.f = x; + cx.u -= n; + return x == 0 ? 0 : cx.f; +} + +float rnd() { + conv32_t c; + switch(random() & 63) { + case 0: return nexttoward0f( 0.0, -(random() & ((1 << (random() & 31)) - 1))); + case 1: return nexttoward0f(-0.0, -(random() & ((1 << (random() & 31)) - 1))); + case 2: return nexttoward0f( INFINITY, (random() & ((1 << (random() & 31)) - 1))); + case 3: return nexttoward0f(-INFINITY, (random() & ((1 << (random() & 31)) - 1))); + } +#ifdef ENABLE_SYS_getrandom + syscall(SYS_getrandom, &c.u32, sizeof(c.u32), 0); +#else + c.u32 = (uint32_t)random() | ((uint32_t)random() << 31); +#endif + return c.f; +} + +float rnd_fr() { + conv32_t c; + do { +#ifdef ENABLE_SYS_getrandom + syscall(SYS_getrandom, &c.u32, sizeof(c.u32), 0); +#else + c.u32 = (uint32_t)random() | ((uint32_t)random() << 31); +#endif + } while(!isnumber(c.f)); + return c.f; +} + +float rnd_zo() { + conv32_t c; + do { +#ifdef ENABLE_SYS_getrandom + syscall(SYS_getrandom, &c.u32, sizeof(c.u32), 0); +#else + c.u32 = (uint32_t)random() | ((uint32_t)random() << 31); +#endif + } while(!isnumber(c.f) || c.f < -1 || 1 < c.f); + return c.f; +} + +int main(int argc,char **argv) +{ + mpfr_t frw, frx, fry, frz; + + mpfr_set_default_prec(256); + mpfr_inits(frw, frx, fry, frz, NULL); + + conv32_t cd; + float d, t; + float d2, d3, zo; + + int cnt, ecnt = 0; + + srandom(time(NULL)); + + for(cnt = 0;ecnt < 1000;cnt++) { + switch(cnt & 7) { + case 0: + d = rnd(); + d2 = rnd(); + d3 = rnd(); + zo = rnd(); + break; + case 1: + cd.f = rint(rnd_zo() * 1e+10) * M_PI_4; + cd.i32 += (random() & 0xff) - 0x7f; + d = cd.f; + d2 = rnd(); + d3 = rnd(); + zo = rnd(); + break; + case 2: + cd.f = rnd_fr() * M_PI_4; + cd.i32 += (random() & 0xf) - 0x7; + d = cd.f; + d2 = rnd(); + d3 = rnd(); + zo = rnd(); + break; + default: + d = rnd_fr(); + d2 = rnd_fr(); + d3 = rnd_fr(); + zo = rnd_zo(); + break; + } + + Sleef_float2 sc = xsincospif_u05(d); + Sleef_float2 sc2 = xsincospif_u35(d); + + { + const float rangemax2 = 1e+7/4; + + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_sinpi(frx, frx, GMP_RNDN); + + double u0 = countULP2sp(t = sc.x, frx); + + if (u0 != 0 && ((fabs(d) <= rangemax2 && u0 > 0.505) || fabs(t) > 1 || !isnumber(t))) { + printf("Pure C sincospif_u05 sin arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + + double u1 = countULP2sp(t = sc2.x, frx); + + if (u1 != 0 && ((fabs(d) <= rangemax2 && u1 > 2.0) || fabs(t) > 1 || !isnumber(t))) { + printf("Pure C sincospif_u35 sin arg=%.20g ulp=%.20g\n", d, u1); + fflush(stdout); ecnt++; + } + + double u2 = countULP2sp(t = xsinpif_u05(d), frx); + + if (u2 != 0 && ((fabs(d) <= rangemax2 && u2 > 0.506) || fabs(t) > 1 || !isnumber(t))) { + printf("Pure C sinpif_u05 arg=%.20g ulp=%.20g\n", d, u2); + printf("correct = %g, test = %g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + const float rangemax2 = 1e+7/4; + + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_cospi(frx, frx, GMP_RNDN); + + double u0 = countULP2sp(t = sc.y, frx); + + if (u0 != 0 && ((fabs(d) <= rangemax2 && u0 > 0.505) || fabs(t) > 1 || !isnumber(t))) { + printf("Pure C sincospif_u05 cos arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + + double u1 = countULP2sp(t = sc.y, frx); + + if (u1 != 0 && ((fabs(d) <= rangemax2 && u1 > 2.0) || fabs(t) > 1 || !isnumber(t))) { + printf("Pure C sincospif_u35 cos arg=%.20g ulp=%.20g\n", d, u1); + fflush(stdout); ecnt++; + } + + double u2 = countULP2sp(t = xcospif_u05(d), frx); + + if (u2 != 0 && ((fabs(d) <= rangemax2 && u2 > 0.506) || fabs(t) > 1 || !isnumber(t))) { + printf("Pure C cospif_u05 arg=%.20g ulp=%.20g\n", d, u2); + printf("correct = %g, test = %g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + sc = xsincosf(d); + sc2 = xsincosf_u1(d); + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_sin(frx, frx, GMP_RNDN); + + float u0 = countULPsp(t = xsinf(d), frx); + + if (u0 != 0 && (u0 > 3.5 || fabs(t) > 1 || !isnumber(t))) { + printf("Pure C sinf arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + + float u1 = countULPsp(t = sc.x, frx); + + if (u1 != 0 && (u1 > 3.5 || fabs(t) > 1 || !isnumber(t))) { + printf("Pure C sincosf sin arg=%.20g ulp=%.20g\n", d, u1); + fflush(stdout); ecnt++; + } + + float u2 = countULPsp(t = xsinf_u1(d), frx); + + if (u2 != 0 && (u2 > 1 || fabs(t) > 1 || !isnumber(t))) { + printf("Pure C sinf_u1 arg=%.20g ulp=%.20g\n", d, u2); + fflush(stdout); ecnt++; + } + + float u3 = countULPsp(t = sc2.x, frx); + + if (u3 != 0 && (u3 > 1 || fabs(t) > 1 || !isnumber(t))) { + printf("Pure C sincosf_u1 sin arg=%.20g ulp=%.20g\n", d, u3); + fflush(stdout); ecnt++; + } + + float u4 = countULPsp(t = xfastsinf_u3500(d), frx); + double ae4 = fabs(mpfr_get_d(frx, GMP_RNDN) - t); + + if (u4 > 350 && ae4 > 2e-6) { + printf("Pure C fastsinf_u3500 arg=%.20g ulp=%.20g\n", d, u4); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_cos(frx, frx, GMP_RNDN); + + float u0 = countULPsp(t = xcosf(d), frx); + + if (u0 != 0 && (u0 > 3.5 || fabs(t) > 1 || !isnumber(t))) { + printf("Pure C cosf arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + + float u1 = countULPsp(t = sc.y, frx); + + if (u1 != 0 && (u1 > 3.5 || fabs(t) > 1 || !isnumber(t))) { + printf("Pure C sincosf cos arg=%.20g ulp=%.20g\n", d, u1); + fflush(stdout); ecnt++; + } + + float u2 = countULPsp(t = xcosf_u1(d), frx); + + if (u2 != 0 && (u2 > 1 || fabs(t) > 1 || !isnumber(t))) { + printf("Pure C cosf_u1 arg=%.20g ulp=%.20g\n", d, u2); + fflush(stdout); ecnt++; + } + + float u3 = countULPsp(t = sc2.y, frx); + + if (u3 != 0 && (u3 > 1 || fabs(t) > 1 || !isnumber(t))) { + printf("Pure C sincosf_u1 cos arg=%.20g ulp=%.20g\n", d, u3); + fflush(stdout); ecnt++; + } + + float u4 = countULPsp(t = xfastcosf_u3500(d), frx); + double ae4 = fabs(mpfr_get_d(frx, GMP_RNDN) - t); + + if (u4 > 350 && ae4 > 2e-6) { + printf("Pure C fastcosf_u3500 arg=%.20g ulp=%.20g\n", d, u4); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_tan(frx, frx, GMP_RNDN); + + float u0 = countULPsp(t = xtanf(d), frx); + + if (u0 != 0 && (u0 > 3.5 || isnan(t))) { + printf("Pure C tanf arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + + float u1 = countULPsp(t = xtanf_u1(d), frx); + + if (u1 != 0 && (u1 > 1 || isnan(t))) { + printf("Pure C tanf_u1 arg=%.20g ulp=%.20g\n", d, u1); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, fabsf(d), GMP_RNDN); + mpfr_log(frx, frx, GMP_RNDN); + + double u0 = countULPsp(t = xlogf(fabsf(d)), frx); + + if (u0 > 3.5) { + printf("Pure C logf arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + + double u1 = countULPsp(t = xlogf_u1(fabsf(d)), frx); + + if (u1 > 1) { + printf("Pure C logf_u1 arg=%.20g ulp=%.20g\n", d, u1); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, fabsf(d), GMP_RNDN); + mpfr_log10(frx, frx, GMP_RNDN); + + double u0 = countULPsp(t = xlog10f(fabsf(d)), frx); + + if (u0 > 1) { + printf("Pure C log10f arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, fabsf(d), GMP_RNDN); + mpfr_log2(frx, frx, GMP_RNDN); + + double u0 = countULPsp(t = xlog2f(fabsf(d)), frx); + + if (u0 > 1) { + printf("Pure C log2f arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + + double u1 = countULPsp(t = xlog2f_u35(fabsf(d)), frx); + + if (u1 > 3.5) { + printf("Pure C log2f_u35 arg=%.20g ulp=%.20g\n", d, u1); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_log1p(frx, frx, GMP_RNDN); + + double u0 = countULPsp(t = xlog1pf(d), frx); + + if ((-1 <= d && d <= 1e+38 && u0 > 1) || + (d < -1 && !isnan(t)) || + (d > 1e+38 && !(u0 <= 1 || isinf(t)))) { + printf("Pure C log1pf arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_exp(frx, frx, GMP_RNDN); + + double u0 = countULPsp(t = xexpf(d), frx); + + if (u0 > 1) { + printf("Pure C expf arg=%.20g ulp=%.20g\n", d, u0); + printf("correct = %g, test = %g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_exp2(frx, frx, GMP_RNDN); + + double u0 = countULPsp(t = xexp2f(d), frx); + + if (u0 > 1) { + printf("Pure C exp2f arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + + double u1 = countULPsp(t = xexp2f_u35(d), frx); + + if (u1 > 3.5) { + printf("Pure C exp2f_u35 arg=%.20g ulp=%.20g\n", d, u1); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_exp10(frx, frx, GMP_RNDN); + + double u0 = countULPsp(t = xexp10f(d), frx); + + if (u0 > 1) { + printf("Pure C exp10f arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + + double u1 = countULPsp(t = xexp10f_u35(d), frx); + + if (u1 > 3.5) { + printf("Pure C exp10f_u35 arg=%.20g ulp=%.20g\n", d, u1); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_expm1(frx, frx, GMP_RNDN); + + double u0 = countULPsp(t = xexpm1f(d), frx); + + if (u0 > 1) { + printf("Pure C expm1f arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_set_d(fry, d2, GMP_RNDN); + mpfr_pow(frx, fry, frx, GMP_RNDN); + + double u0 = countULPsp(t = xpowf(d2, d), frx); + + if (u0 > 1) { + printf("Pure C powf arg=%.20g, %.20g ulp=%.20g\n", d2, d, u0); + fflush(stdout); ecnt++; + } + + if (isnumber(d) && isnumber(d2)) { + double u1 = countULPsp(t = xfastpowf_u3500(d2, d), frx); + + if (isnumber((float)mpfr_get_d(frx, GMP_RNDN)) && u1 > 350) { + printf("Pure C fastpowf_u3500 arg=%.20g, %.20g ulp=%.20g\n", d2, d, u1); + fflush(stdout); ecnt++; + } + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_cbrt(frx, frx, GMP_RNDN); + + double u0 = countULPsp(t = xcbrtf(d), frx); + + if (u0 > 3.5) { + printf("Pure C cbrtf arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + + double u1 = countULPsp(t = xcbrtf_u1(d), frx); + + if (u1 > 1) { + printf("Pure C cbrtf_u1 arg=%.20g ulp=%.20g\n", d, u1); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, zo, GMP_RNDN); + mpfr_asin(frx, frx, GMP_RNDN); + + double u0 = countULPsp(t = xasinf(zo), frx); + + if (u0 > 3.5) { + printf("Pure C asinf arg=%.20g ulp=%.20g\n", zo, u0); + fflush(stdout); ecnt++; + } + + double u1 = countULPsp(t = xasinf_u1(zo), frx); + + if (u1 > 1) { + printf("Pure C asinf_u1 arg=%.20g ulp=%.20g\n", zo, u1); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, zo, GMP_RNDN); + mpfr_acos(frx, frx, GMP_RNDN); + + double u0 = countULPsp(t = xacosf(zo), frx); + + if (u0 > 3.5) { + printf("Pure C acosf arg=%.20g ulp=%.20g\n", zo, u0); + fflush(stdout); ecnt++; + } + + double u1 = countULPsp(t = xacosf_u1(zo), frx); + + if (u1 > 1) { + printf("Pure C acosf_u1 arg=%.20g ulp=%.20g\n", zo, u1); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_atan(frx, frx, GMP_RNDN); + + double u0 = countULPsp(t = xatanf(d), frx); + + if (u0 > 3.5) { + printf("Pure C atanf arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + + double u1 = countULPsp(t = xatanf_u1(d), frx); + + if (u1 > 1) { + printf("Pure C atanf_u1 arg=%.20g ulp=%.20g\n", d, u1); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_set_d(fry, d2, GMP_RNDN); + mpfr_atan2(frx, fry, frx, GMP_RNDN); + + double u0 = countULPsp(t = xatan2f(d2, d), frx); + + if (u0 > 3.5) { + printf("Pure C atan2f arg=%.20g, %.20g ulp=%.20g\n", d2, d, u0); + fflush(stdout); ecnt++; + } + + double u1 = countULP2sp(t = xatan2f_u1(d2, d), frx); + + if (u1 > 1) { + printf("Pure C atan2f_u1 arg=%.20g, %.20g ulp=%.20g\n", d2, d, u1); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_sinh(frx, frx, GMP_RNDN); + + double u0 = countULPsp(t = xsinhf(d), frx); + + if ((fabs(d) <= 88.5 && u0 > 1) || + (d > 88.5 && !(u0 <= 1 || (isinf(t) && t > 0))) || + (d < -88.5 && !(u0 <= 1 || (isinf(t) && t < 0)))) { + printf("Pure C sinhf arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_cosh(frx, frx, GMP_RNDN); + + double u0 = countULPsp(t = xcoshf(d), frx); + + if ((fabs(d) <= 88.5 && u0 > 1) || !(u0 <= 1 || (isinf(t) && t > 0))) { + printf("Pure C coshf arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_tanh(frx, frx, GMP_RNDN); + + double u0 = countULPsp(t = xtanhf(d), frx); + + if (u0 > 1.0001) { + printf("Pure C tanhf arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_sinh(frx, frx, GMP_RNDN); + + double u0 = countULPsp(t = xsinhf_u35(d), frx); + + if ((fabs(d) <= 88 && u0 > 3.5) || + (d > 88 && !(u0 <= 3.5 || (isinf(t) && t > 0))) || + (d < -88 && !(u0 <= 3.5 || (isinf(t) && t < 0)))) { + printf("Pure C sinhf_u35 arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_cosh(frx, frx, GMP_RNDN); + + double u0 = countULPsp(t = xcoshf_u35(d), frx); + + if ((fabs(d) <= 88 && u0 > 3.5) || !(u0 <= 3.5 || (isinf(t) && t > 0))) { + printf("Pure C coshf_u35 arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_tanh(frx, frx, GMP_RNDN); + + double u0 = countULPsp(t = xtanhf_u35(d), frx); + + if (u0 > 3.5) { + printf("Pure C tanhf_u35 arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_asinh(frx, frx, GMP_RNDN); + + double u0 = countULPsp(t = xasinhf(d), frx); + + if ((fabs(d) < sqrt(FLT_MAX) && u0 > 1.0001) || + (d >= sqrt(FLT_MAX) && !(u0 <= 1.0001 || (isinf(t) && t > 0))) || + (d <= -sqrt(FLT_MAX) && !(u0 <= 1.0001 || (isinf(t) && t < 0)))) { + printf("Pure C asinhf arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_acosh(frx, frx, GMP_RNDN); + + double u0 = countULPsp(t = xacoshf(d), frx); + + if ((fabs(d) < sqrt(FLT_MAX) && u0 > 1.0001) || + (d >= sqrt(FLT_MAX) && !(u0 <= 1.0001 || (isinff(t) && t > 0))) || + (d <= -sqrt(FLT_MAX) && !isnan(t))) { + printf("Pure C acoshf arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_atanh(frx, frx, GMP_RNDN); + + double u0 = countULPsp(t = xatanhf(d), frx); + + if (u0 > 1.0001) { + printf("Pure C atanhf arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + } + + // + + { + int exp = (random() & 8191) - 4096; + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_set_exp(frx, mpfr_get_exp(frx) + exp); + + double u0 = countULPsp(t = xldexpf(d, exp), frx); + + if (u0 > 0.5002) { + printf("Pure C ldexpf arg=%.20g %d ulp=%.20g\n", d, exp, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_abs(frx, frx, GMP_RNDN); + + double u0 = countULPsp(t = xfabsf(d), frx); + + if (u0 != 0) { + printf("Pure C fabsf arg=%.20g ulp=%.20g\n", d, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_set_d(fry, d2, GMP_RNDN); + mpfr_copysign(frx, frx, fry, GMP_RNDN); + + double u0 = countULPsp(t = xcopysignf(d, d2), frx); + + if (u0 != 0 && !isnan(d2)) { + printf("Pure C copysignf arg=%.20g, %.20g ulp=%.20g\n", d, d2, u0); + printf("correct = %g, test = %g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_set_d(fry, d2, GMP_RNDN); + mpfr_max(frx, frx, fry, GMP_RNDN); + + double u0 = countULPsp(t = xfmaxf(d, d2), frx); + + if (u0 != 0) { + printf("Pure C fmaxf arg=%.20g, %.20g ulp=%.20g\n", d, d2, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_set_d(fry, d2, GMP_RNDN); + mpfr_min(frx, frx, fry, GMP_RNDN); + + double u0 = countULPsp(t = xfminf(d, d2), frx); + + if (u0 != 0) { + printf("Pure C fminf arg=%.20g, %.20g ulp=%.20g\n", d, d2, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_set_d(fry, d2, GMP_RNDN); + mpfr_dim(frx, frx, fry, GMP_RNDN); + + double u0 = countULPsp(t = xfdimf(d, d2), frx); + + if (u0 > 0.5) { + printf("Pure C fdimf arg=%.20g, %.20g ulp=%.20g\n", d, d2, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_trunc(frx, frx); + + double u0 = countULPsp(t = xtruncf(d), frx); + + if (u0 != 0) { + printf("Pure C truncf arg=%.20g ulp=%.20g\n", d, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_floor(frx, frx); + + double u0 = countULPsp(t = xfloorf(d), frx); + + if (u0 != 0) { + printf("Pure C floorf arg=%.20g ulp=%.20g\n", d, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_ceil(frx, frx); + + double u0 = countULPsp(t = xceilf(d), frx); + + if (u0 != 0) { + printf("Pure C ceilf arg=%.20g ulp=%.20g\n", d, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_round(frx, frx); + + double u0 = countULPsp(t = xroundf(d), frx); + + if (u0 != 0) { + printf("Pure C roundf arg=%.24g ulp=%.20g\n", d, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_rint(frx, frx, GMP_RNDN); + + double u0 = countULPsp(t = xrintf(d), frx); + + if (u0 != 0) { + printf("Pure C rintf arg=%.24g ulp=%.20g\n", d, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_modf(fry, frz, frx, GMP_RNDN); + + Sleef_float2 t2 = xmodff(d); + double u0 = countULPsp(t2.x, frz); + double u1 = countULPsp(t2.y, fry); + + if (u0 != 0 || u1 != 0) { + printf("Pure C modff arg=%.20g ulp=%.20g %.20g\n", d, u0, u1); + printf("correct = %.20g, %.20g\n", mpfr_get_d(frz, GMP_RNDN), mpfr_get_d(fry, GMP_RNDN)); + printf("test = %.20g, %.20g\n", t2.x, t2.y); + fflush(stdout); ecnt++; + } + } + + + { + t = xnextafterf(d, d2); + double c = nextafterf(d, d2); + + if (!(isnan(t) && isnan(c)) && t != c) { + printf("Pure C nextafterf arg=%.20g, %.20g\n", d, d2); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_set_exp(frx, 0); + + double u0 = countULPsp(t = xfrfrexpf(d), frx); + + if (d != 0 && isnumber(d) && u0 != 0) { + printf("Pure C frfrexpf arg=%.20g ulp=%.20g\n", d, u0); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + int cexp = mpfr_get_exp(frx); + + int texp = xexpfrexpf(d); + + if (d != 0 && isnumber(d) && cexp != texp) { + printf("Pure C expfrexpf arg=%.20g\n", d); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_set_d(fry, d2, GMP_RNDN); + mpfr_hypot(frx, frx, fry, GMP_RNDN); + + double u0 = countULP2sp(t = xhypotf_u05(d, d2), frx); + + if (u0 > 0.5001) { + printf("Pure C hypotf_u05 arg=%.20g, %.20g ulp=%.20g\n", d, d2, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_set_d(fry, d2, GMP_RNDN); + mpfr_hypot(frx, frx, fry, GMP_RNDN); + + double u0 = countULP2sp(t = xhypotf_u35(d, d2), frx); + + if (u0 >= 3.5) { + printf("Pure C hypotf_u35 arg=%.20g, %.20g ulp=%.20g\n", d, d2, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_set_d(fry, d2, GMP_RNDN); + mpfr_fmod(frx, frx, fry, GMP_RNDN); + + double u0 = countULPsp(t = xfmodf(d, d2), frx); + + if (fabs((double)d / d2) < 1e+38 && u0 > 0.5) { + printf("Pure C fmodf arg=%.20g, %.20g ulp=%.20g\n", d, d2, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_set_d(fry, d2, GMP_RNDN); + mpfr_remainder(frx, frx, fry, GMP_RNDN); + + double u0 = countULPsp(t = xremainderf(d, d2), frx); + + if (fabs((double)d / d2) < 1e+38 && u0 > 0.5) { + printf("Pure C remainderf arg=%.20g, %.20g ulp=%.20g\n", d, d2, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_set_d(fry, d2, GMP_RNDN); + mpfr_set_d(frz, d3, GMP_RNDN); + mpfr_fma(frx, frx, fry, frz, GMP_RNDN); + + double u0 = countULP2sp(t = xfmaf(d, d2, d3), frx); + double c = mpfr_get_d(frx, GMP_RNDN); + + if ((-1e+34 < c && c < 1e+33 && u0 > 0.5001) || + !(u0 <= 0.5001 || isinf(t))) { + printf("Pure C fmaf arg=%.20g, %.20g, %.20g ulp=%.20g\n", d, d2, d3, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_sqrt(frx, frx, GMP_RNDN); + + double u0 = countULPsp(t = xsqrtf_u05(d), frx); + + if (u0 > 0.5001) { + printf("Pure C sqrtf_u05 arg=%.20g ulp=%.20g\n", d, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_sqrt(frx, frx, GMP_RNDN); + + double u0 = countULPsp(t = xsqrtf_u35(d), frx); + + if (u0 > 3.5) { + printf("Pure C sqrtf_u35 arg=%.20g ulp=%.20g\n", d, u0); + printf("correct = %.20g, test = %.20g\n", mpfr_get_d(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_erfc(frx, frx, GMP_RNDN); + + double u0 = countULP2sp(t = xerfcf_u15(d), frx); + + if (u0 > 1.5) { + printf("Pure C erfcf arg=%.20g ulp=%.20g\n", d, u0); + printf("Correct = %.20Lg, test = %.20g\n", mpfr_get_ld(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_erf(frx, frx, GMP_RNDN); + + double u0 = countULP2sp(t = xerff_u1(d), frx); + + if (u0 > 0.75) { + printf("Pure C erff arg=%.20g ulp=%.20g\n", d, u0); + printf("Correct = %.20Lg, test = %.20g\n", mpfr_get_ld(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + int s; + mpfr_lgamma(frx, &s, frx, GMP_RNDN); + + double u0 = countULPsp(t = xlgammaf_u1(d), frx); + + if (((d < 0 && fabsl(t - mpfr_get_ld(frx, GMP_RNDN)) > 1e-8 && u0 > 1) || + (0 <= d && d < 4e+36 && u0 > 1) || (4e+36 <= d && !(u0 <= 1 || isinf(t))))) { + printf("Pure C xlgammaf arg=%.20g ulp=%.20g\n", d, u0); + printf("Correct = %.20Lg, test = %.20g\n", mpfr_get_ld(frx, GMP_RNDN), t); + printf("Diff = %.20Lg\n", fabsl(t - mpfr_get_ld(frx, GMP_RNDN))); + fflush(stdout); ecnt++; + } + } + + { + mpfr_set_d(frx, d, GMP_RNDN); + mpfr_gamma(frx, frx, GMP_RNDN); + + double u0 = countULP2sp(t = xtgammaf_u1(d), frx); + double c = mpfr_get_d(frx, GMP_RNDN); + + if (isnumber(c) || isnumber(t)) { + if (u0 > 1.0) { + printf("Pure C xtgamma arg=%.20g ulp=%.20g\n", d, u0); + printf("Correct = %.20Lg, test = %.20g\n", mpfr_get_ld(frx, GMP_RNDN), t); + fflush(stdout); ecnt++; + } + } + } + } + mpfr_clears(frw, frx, fry, frz, NULL); + + exit(0); +} diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-tester/tester3.c b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-tester/tester3.c new file mode 100644 index 00000000000..9abeca4db5b --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-tester/tester3.c @@ -0,0 +1,524 @@ +// Copyright Naoki Shibata and contributors 2010 - 2023. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "sleef.h" +#include "misc.h" +#include "testerutil.h" + +#ifdef __VSX__ +#include +#undef vector +#undef bool +typedef __vector double __vector_double; +typedef __vector float __vector_float; +#endif + +#if defined(__VX__) && defined(__VEC__) +#ifndef SLEEF_VECINTRIN_H_INCLUDED +#include +#define SLEEF_VECINTRIN_H_INCLUDED +#endif +typedef __attribute__((vector_size(16))) double vector_double; +typedef __attribute__((vector_size(16))) float vector_float; +#endif + +// + +#define XNAN (((union { int64_t u; double d; }) { .u = INT64_C(0xffffffffffffffff) }).d) +#define XNANf (((union { int32_t u; float d; }) { .u = 0xffffffff }).d) + +static INLINE double unifyValue(double x) { x = !(x == x) ? XNAN : x; return x; } +static INLINE float unifyValuef(float x) { x = !(x == x) ? XNANf : x; return x; } + +static INLINE double setdouble(double d, int r) { return d; } +static INLINE double getdouble(double v, int r) { return unifyValue(v); } +static INLINE float setfloat(float d, int r) { return d; } +static INLINE float getfloat(float v, int r) { return unifyValuef(v); } + +#if defined(__i386__) || defined(__x86_64__) || defined(_MSC_VER) +static INLINE __m128d set__m128d(double d, int r) { static double a[2]; memrand(a, sizeof(a)); a[r & 1] = d; return _mm_loadu_pd(a); } +static INLINE double get__m128d(__m128d v, int r) { static double a[2]; _mm_storeu_pd(a, v); return unifyValue(a[r & 1]); } +static INLINE __m128 set__m128(float d, int r) { static float a[4]; memrand(a, sizeof(a)); a[r & 3] = d; return _mm_loadu_ps(a); } +static INLINE float get__m128(__m128 v, int r) { static float a[4]; _mm_storeu_ps(a, v); return unifyValuef(a[r & 3]); } + +#if defined(__AVX__) +static INLINE __m256d set__m256d(double d, int r) { static double a[4]; memrand(a, sizeof(a)); a[r & 3] = d; return _mm256_loadu_pd(a); } +static INLINE double get__m256d(__m256d v, int r) { static double a[4]; _mm256_storeu_pd(a, v); return unifyValue(a[r & 3]); } +static INLINE __m256 set__m256(float d, int r) { static float a[8]; memrand(a, sizeof(a)); a[r & 7] = d; return _mm256_loadu_ps(a); } +static INLINE float get__m256(__m256 v, int r) { static float a[8]; _mm256_storeu_ps(a, v); return unifyValuef(a[r & 7]); } +#endif + +#if defined(__AVX512F__) +static INLINE __m512d set__m512d(double d, int r) { static double a[8]; memrand(a, sizeof(a)); a[r & 7] = d; return _mm512_loadu_pd(a); } +static INLINE double get__m512d(__m512d v, int r) { static double a[8]; _mm512_storeu_pd(a, v); return unifyValue(a[r & 7]); } +static INLINE __m512 set__m512(float d, int r) { static float a[16]; memrand(a, sizeof(a)); a[r & 15] = d; return _mm512_loadu_ps(a); } +static INLINE float get__m512(__m512 v, int r) { static float a[16]; _mm512_storeu_ps(a, v); return unifyValuef(a[r & 15]); } +#endif +#endif // #if defined(__i386__) || defined(__x86_64__) || defined(_MSC_VER) + +#if defined(__aarch64__) && defined(__ARM_NEON) +static INLINE VECTOR_CC float64x2_t setfloat64x2_t(double d, int r) { double a[2]; memrand(a, sizeof(a)); a[r & 1] = d; return vld1q_f64(a); } +static INLINE VECTOR_CC double getfloat64x2_t(float64x2_t v, int r) { double a[2]; vst1q_f64(a, v); return unifyValue(a[r & 1]); } +static INLINE VECTOR_CC float32x4_t setfloat32x4_t(float d, int r) { float a[4]; memrand(a, sizeof(a)); a[r & 3] = d; return vld1q_f32(a); } +static INLINE VECTOR_CC float getfloat32x4_t(float32x4_t v, int r) { float a[4]; vst1q_f32(a, v); return unifyValuef(a[r & 3]); } +#endif + +#ifdef __ARM_FEATURE_SVE +static INLINE svfloat64_t setsvfloat64_t(double d, int r) { double a[svcntd()]; memrand(a, sizeof(a)); a[r & (svcntd()-1)] = d; return svld1_f64(svptrue_b8(), a); } +static INLINE double getsvfloat64_t(svfloat64_t v, int r) { double a[svcntd()]; svst1_f64(svptrue_b8(), a, v); return unifyValue(a[r & (svcntd()-1)]); } +static INLINE svfloat32_t setsvfloat32_t(float d, int r) { float a[svcntw()]; memrand(a, sizeof(a)); a[r & (svcntw()-1)] = d; return svld1_f32(svptrue_b8(), a); } +static INLINE float getsvfloat32_t(svfloat32_t v, int r) { float a[svcntw()]; svst1_f32(svptrue_b8(), a, v); return unifyValuef(a[r & (svcntw()-1)]); } + +static svfloat64_t vd2getx_vd_vd2(svfloat64x2_t v) { return svget2_f64(v, 0); } +static svfloat64_t vd2gety_vd_vd2(svfloat64x2_t v) { return svget2_f64(v, 1); } +static svfloat32_t vf2getx_vf_vf2(svfloat32x2_t v) { return svget2_f32(v, 0); } +static svfloat32_t vf2gety_vf_vf2(svfloat32x2_t v) { return svget2_f32(v, 1); } +#endif + +#ifdef __VSX__ +static INLINE __vector double setSLEEF_VECTOR_DOUBLE(double d, int r) { double a[2]; memrand(a, sizeof(a)); a[r & 1] = d; return vec_vsx_ld(0, a); } +static INLINE double getSLEEF_VECTOR_DOUBLE(__vector double v, int r) { double a[2]; vec_vsx_st(v, 0, a); return unifyValue(a[r & 1]); } +static INLINE __vector float setSLEEF_VECTOR_FLOAT(float d, int r) { float a[4]; memrand(a, sizeof(a)); a[r & 3] = d; return vec_vsx_ld(0, a); } +static INLINE float getSLEEF_VECTOR_FLOAT(__vector float v, int r) { float a[4]; vec_vsx_st(v, 0, a); return unifyValuef(a[r & 3]); } +#endif + +#ifdef __VX__ +static INLINE __attribute__((vector_size(16))) double setSLEEF_VECTOR_DOUBLE(double d, int r) { double a[2]; memrand(a, sizeof(a)); a[r & 1] = d; return (__attribute__((vector_size(16))) double) { a[0], a[1] }; } +static INLINE double getSLEEF_VECTOR_DOUBLE(__attribute__((vector_size(16))) double v, int r) { return unifyValue(v[r & 1]); } +static INLINE __attribute__((vector_size(16))) float setSLEEF_VECTOR_FLOAT(float d, int r) { float a[4]; memrand(a, sizeof(a)); a[r & 3] = d; return (__attribute__((vector_size(16))) float) { a[0], a[1], a[2], a[3] }; } +static INLINE float getSLEEF_VECTOR_FLOAT(__attribute__((vector_size(16))) float v, int r) { return unifyValuef(v[r & 3]); } +#endif + +#if __riscv && __riscv_v + +#if defined(ENABLE_RVVM1) +#define VECTLENSP (1 * __riscv_vlenb() / sizeof(float)) +#define VECTLENDP (1 * __riscv_vlenb() / sizeof(double)) + +static INLINE vfloat32m1_t setvfloat32m1_t(float d, int r) { float a[VECTLENSP]; memrand(a, sizeof(a)); a[r & (VECTLENSP-1)] = d; return __riscv_vle32_v_f32m1(a, VECTLENSP); } +static INLINE float getvfloat32m1_t(vfloat32m1_t v, int r) { float a[VECTLENSP]; __riscv_vse32(a, v, VECTLENSP); return unifyValuef(a[r & (VECTLENSP-1)]); } +static INLINE vfloat64m1_t setvfloat64m1_t(double d, int r) { double a[VECTLENDP]; memrand(a, sizeof(a)); a[r & (VECTLENDP-1)] = d; return __riscv_vle64_v_f64m1(a, VECTLENDP); } +static INLINE double getvfloat64m1_t(vfloat64m1_t v, int r) { double a[VECTLENDP]; __riscv_vse64(a, v, VECTLENDP); return unifyValue(a[r & (VECTLENDP-1)]); } + +static vfloat32m1_t vf2getx_vf_vf2(vfloat32m2_t v) { return __riscv_vget_f32m1(v, 0); } +static vfloat32m1_t vf2gety_vf_vf2(vfloat32m2_t v) { return __riscv_vget_f32m1(v, 1); } +static vfloat64m1_t vd2getx_vd_vd2(vfloat64m2_t v) { return __riscv_vget_f64m1(v, 0); } +static vfloat64m1_t vd2gety_vd_vd2(vfloat64m2_t v) { return __riscv_vget_f64m1(v, 1); } + +#elif defined(ENABLE_RVVM2) +#define VECTLENSP (2 * __riscv_vlenb() / sizeof(float)) +#define VECTLENDP (2 * __riscv_vlenb() / sizeof(double)) + +static INLINE vfloat32m2_t setvfloat32m2_t(float d, int r) { float a[VECTLENSP]; memrand(a, sizeof(a)); a[r & (VECTLENSP-1)] = d; return __riscv_vle32_v_f32m2(a, VECTLENSP); } +static INLINE float getvfloat32m2_t(vfloat32m2_t v, int r) { float a[VECTLENSP]; __riscv_vse32(a, v, VECTLENSP); return unifyValuef(a[r & (VECTLENSP-1)]); } +static INLINE vfloat64m2_t setvfloat64m2_t(double d, int r) { double a[VECTLENDP]; memrand(a, sizeof(a)); a[r & (VECTLENDP-1)] = d; return __riscv_vle64_v_f64m2(a, VECTLENDP); } +static INLINE double getvfloat64m2_t(vfloat64m2_t v, int r) { double a[VECTLENDP]; __riscv_vse64(a, v, VECTLENDP); return unifyValue(a[r & (VECTLENDP-1)]); } + +static vfloat32m2_t vf2getx_vf_vf2(vfloat32m4_t v) { return __riscv_vget_f32m2(v, 0); } +static vfloat32m2_t vf2gety_vf_vf2(vfloat32m4_t v) { return __riscv_vget_f32m2(v, 1); } +static vfloat64m2_t vd2getx_vd_vd2(vfloat64m4_t v) { return __riscv_vget_f64m2(v, 0); } +static vfloat64m2_t vd2gety_vd_vd2(vfloat64m4_t v) { return __riscv_vget_f64m2(v, 1); } + +#else +#error "unknown RVV" +#endif + +#undef VECTLENSP +#undef VECTLENDP +#endif + +// + +// ATR = cinz_, NAME = sin, TYPE = d2, ULP = u35, EXT = sse2 +#define FUNC(ATR, NAME, TYPE, ULP, EXT) Sleef_ ## ATR ## NAME ## TYPE ## _ ## ULP ## EXT +#define _TYPE2(TYPE) Sleef_ ## TYPE ## _2 +#define TYPE2(TYPE) _TYPE2(TYPE) +#define SET(TYPE) set ## TYPE +#define GET(TYPE) get ## TYPE + +#if !defined(__ARM_FEATURE_SVE) && !(defined(__riscv) && defined(__riscv_v)) +static DPTYPE vd2getx_vd_vd2(TYPE2(DPTYPE) v) { return v.x; } +static DPTYPE vd2gety_vd_vd2(TYPE2(DPTYPE) v) { return v.y; } +static SPTYPE vf2getx_vf_vf2(TYPE2(SPTYPE) v) { return v.x; } +static SPTYPE vf2gety_vf_vf2(TYPE2(SPTYPE) v) { return v.y; } +#endif + +// + +#define initDigest \ + EVP_MD_CTX *ctx; ctx = EVP_MD_CTX_new(); \ + if (!ctx) { \ + fprintf(stderr, "Error creating context.\n"); \ + return 0; \ + } \ + if (!EVP_DigestInit_ex(ctx, EVP_md5(), NULL)) { \ + fprintf(stderr, "Error initializing context.\n"); \ + return 0; \ + } + +#define checkDigest(NAME, ULP) do { \ + unsigned int md5_digest_len = EVP_MD_size(EVP_md5()); \ + unsigned char *md5_digest; \ + md5_digest = (unsigned char *)malloc(md5_digest_len); \ + if (!EVP_DigestFinal_ex(ctx, md5_digest, &md5_digest_len)) { \ + fprintf(stderr, "Error finalizing digest.\n"); \ + return 0; \ + } \ + EVP_MD_CTX_free(ctx); \ + unsigned char mes[64], buf[64]; \ + memset(mes, 0, 64); \ + sprintf((char *)mes, "%s ", #NAME " " #ULP); \ + char tmp[3] = { 0 }; \ + for (int i = 0; i < md5_digest_len; i++) { \ + sprintf(tmp, "%02x", md5_digest[i]); \ + strcat((char *)mes, tmp); \ + } \ + free(md5_digest); \ + if (fp != NULL) { \ + fgets((char *)buf, 60, fp); \ + if (strncmp((char *)mes, (char *)buf, strlen((char *)mes)) != 0) { \ + puts((char *)mes); \ + puts((char *)buf); \ + success = 0; \ + } \ + } else puts((char *)mes); \ + } while(0) + +#if defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) +#define convertEndianness(ptr, len) do { \ + for(int k=0;k +#include +#include +#include +#include +#include +#include + +#include + +#if defined(__MINGW32__) || defined(__MINGW64__) || defined(_MSC_VER) +#define STDIN_FILENO 0 +#else +#include +#include +#endif + +#if defined(__MINGW32__) || defined(__MINGW64__) +#include +#endif + +#if defined(_MSC_VER) +#include +#endif + +#include "misc.h" + +#define DENORMAL_DBL_MIN (4.9406564584124654418e-324) +#define POSITIVE_INFINITY INFINITY +#define NEGATIVE_INFINITY (-INFINITY) + +#define DENORMAL_FLT_MIN (1.4012984643248170709e-45f) +#define POSITIVE_INFINITYf ((float)INFINITY) +#define NEGATIVE_INFINITYf (-(float)INFINITY) + +int isnumber(double x) { return !isinf(x) && !isnan(x); } +int isPlusZero(double x) { return x == 0 && copysign(1, x) == 1; } +int isMinusZero(double x) { return x == 0 && copysign(1, x) == -1; } +double sign(double d) { return d < 0 ? -1 : 1; } +int xisnan(double x) { return x != x; } + +int isnumberf(float x) { return !isinf(x) && !isnan(x); } +int isPlusZerof(float x) { return x == 0 && copysignf(1, x) == 1; } +int isMinusZerof(float x) { return x == 0 && copysignf(1, x) == -1; } +float signf(float d) { return d < 0 ? -1 : 1; } +int xisnanf(float x) { return x != x; } + +int enableFlushToZero = 0; + +double flushToZero(double y) { + if (enableFlushToZero && fabs(y) < FLT_MIN) y = copysign(0.0, y); + return y; +} + +// + +int readln(int fd, char *buf, int cnt) { + int i, rcnt = 0; + + if (cnt < 1) return -1; + + while(cnt >= 2) { + i = read(fd, buf, 1); + if (i != 1) return i; + + if (*buf == '\n') break; + + rcnt++; + buf++; + cnt--; + } + + *++buf = '\0'; + rcnt++; + return rcnt; +} + +static uint64_t xseed; + +uint64_t xrand() { + xseed = xseed * UINT64_C(6364136223846793005) + 1; + return xseed; +} + +// Fill memory with random bits +void memrand(void *p, int size) { + uint64_t *q = (uint64_t *)p; + int i; + for(i=0;i + +int cmpDenormsp(float x, mpfr_t fry) { + float y = mpfr_get_d(fry, GMP_RNDN); + x = flushToZero(x); + y = flushToZero(y); + if (xisnanf(x) && xisnanf(y)) return 1; + if (xisnanf(x) || xisnanf(y)) return 0; + if (isinf(x) != isinf(y)) return 0; + if (x == POSITIVE_INFINITYf && y == POSITIVE_INFINITYf) return 1; + if (x == NEGATIVE_INFINITYf && y == NEGATIVE_INFINITYf) return 1; + if (y == 0) { + if (isPlusZerof(x) && isPlusZerof(y)) return 1; + if (isMinusZerof(x) && isMinusZerof(y)) return 1; + return 0; + } + if (!xisnanf(x) && !xisnanf(y) && !isinf(x) && !isinf(y)) return signf(x) == signf(y); + return 0; +} + +int cmpDenormdp(double x, mpfr_t fry) { + double y = mpfr_get_d(fry, GMP_RNDN); + if (xisnan(x) && xisnan(y)) return 1; + if (xisnan(x) || xisnan(y)) return 0; + if (isinf(x) != isinf(y)) return 0; + if (x == POSITIVE_INFINITY && y == POSITIVE_INFINITY) return 1; + if (x == NEGATIVE_INFINITY && y == NEGATIVE_INFINITY) return 1; + if (y == 0) { + if (isPlusZero(x) && isPlusZero(y)) return 1; + if (isMinusZero(x) && isMinusZero(y)) return 1; + return 0; + } + if (!xisnan(x) && !xisnan(y) && !isinf(x) && !isinf(y)) return sign(x) == sign(y); + return 0; +} + +double countULPdp(double d, mpfr_t c) { + mpfr_t fra, frb, frc, frd; + mpfr_inits(fra, frb, frc, frd, NULL); + + double c2 = mpfr_get_d(c, GMP_RNDN); + if (c2 == 0 && d != 0) { + mpfr_clears(fra, frb, frc, frd, NULL); + return 10000; + } + if (isnan(c2) && isnan(d)) { + mpfr_clears(fra, frb, frc, frd, NULL); + return 0; + } + if (isnan(c2) || isnan(d)) { + mpfr_clears(fra, frb, frc, frd, NULL); + return 10001; + } + if (c2 == POSITIVE_INFINITY && d == POSITIVE_INFINITY) { + mpfr_clears(fra, frb, frc, frd, NULL); + return 0; + } + if (c2 == NEGATIVE_INFINITY && d == NEGATIVE_INFINITY) { + mpfr_clears(fra, frb, frc, frd, NULL); + return 0; + } + + double v = 0; + if (isinf(d) && !isinf(mpfr_get_d(c, GMP_RNDN))) { + d = copysign(DBL_MAX, c2); + v = 1; + } + + // + + int e; + frexp(mpfr_get_d(c, GMP_RNDN), &e); + mpfr_set_ld(frb, fmaxl(ldexpl(1.0, e-53), DENORMAL_DBL_MIN), GMP_RNDN); + + mpfr_set_d(frd, d, GMP_RNDN); + mpfr_sub(fra, frd, c, GMP_RNDN); + mpfr_div(fra, fra, frb, GMP_RNDN); + double u = fabs(mpfr_get_d(fra, GMP_RNDN)); + + mpfr_clears(fra, frb, frc, frd, NULL); + + return u + v; +} + +double countULP2dp(double d, mpfr_t c) { + mpfr_t fra, frb, frc, frd; + mpfr_inits(fra, frb, frc, frd, NULL); + + double c2 = mpfr_get_d(c, GMP_RNDN); + if (c2 == 0 && d != 0) { + mpfr_clears(fra, frb, frc, frd, NULL); + return 10000; + } + if (isnan(c2) && isnan(d)) { + mpfr_clears(fra, frb, frc, frd, NULL); + return 0; + } + if (isnan(c2) || isnan(d)) { + mpfr_clears(fra, frb, frc, frd, NULL); + return 10001; + } + if (c2 == POSITIVE_INFINITY && d == POSITIVE_INFINITY) { + mpfr_clears(fra, frb, frc, frd, NULL); + return 0; + } + if (c2 == NEGATIVE_INFINITY && d == NEGATIVE_INFINITY) { + mpfr_clears(fra, frb, frc, frd, NULL); + return 0; + } + + double v = 0; + if (isinf(d) && !isinf(mpfr_get_d(c, GMP_RNDN))) { + d = copysign(DBL_MAX, c2); + v = 1; + } + + // + + int e; + frexp(mpfr_get_d(c, GMP_RNDN), &e); + mpfr_set_ld(frb, fmaxl(ldexpl(1.0, e-53), DBL_MIN), GMP_RNDN); + + mpfr_set_d(frd, d, GMP_RNDN); + mpfr_sub(fra, frd, c, GMP_RNDN); + mpfr_div(fra, fra, frb, GMP_RNDN); + double u = fabs(mpfr_get_d(fra, GMP_RNDN)); + + mpfr_clears(fra, frb, frc, frd, NULL); + + return u + v; +} + +double countULPsp(float d, mpfr_t c0) { + double c = mpfr_get_d(c0, GMP_RNDN); + + d = flushToZero(d); + float c2 = flushToZero(c); + if (c2 == 0 && d != 0) return 10000; + if (isnan(c2) && isnan(d)) return 0; + if (isnan(c2) || isnan(d)) return 10001; + if (c2 == POSITIVE_INFINITYf && d == POSITIVE_INFINITYf) return 0; + if (c2 == NEGATIVE_INFINITYf && d == NEGATIVE_INFINITYf) return 0; + + double v = 0; + if (isinf(d) && !isinf(c)) { + d = copysign(FLT_MAX, c2); + v = 1; + } + + // + + int e; + frexp(c, &e); + + double u = fabs(d - c) * fmin(ldexp(1.0, 24-e), 1.0 / DENORMAL_FLT_MIN); + + return u + v; +} + +double countULP2sp(float d, mpfr_t c0) { + double c = mpfr_get_d(c0, GMP_RNDN); + + d = flushToZero(d); + float c2 = flushToZero(c); + if (c2 == 0 && d != 0) return 10000; + if (isnan(c2) && isnan(d)) return 0; + if (isnan(c2) || isnan(d)) return 10001; + if (c2 == POSITIVE_INFINITYf && d == POSITIVE_INFINITYf) return 0; + if (c2 == NEGATIVE_INFINITYf && d == NEGATIVE_INFINITYf) return 0; + + double v = 0; + if (isinf(d) && !isinf(c)) { + d = copysign(FLT_MAX, c2); + v = 1; + } + + // + + int e; + frexp(c, &e); + + double u = fabs(d - c) * fmin(ldexp(1.0, 24-e), 1.0 / FLT_MIN); + + return u + v; +} + +// + +#if MPFR_VERSION < MPFR_VERSION_NUM(4, 2, 0) +void mpfr_sinpi(mpfr_t ret, mpfr_t arg, mpfr_rnd_t rnd) { + mpfr_t frpi, frd; + mpfr_inits(frpi, frd, NULL); + + mpfr_const_pi(frpi, GMP_RNDN); + mpfr_set_d(frd, 1.0, GMP_RNDN); + mpfr_mul(frpi, frpi, frd, GMP_RNDN); + mpfr_mul(frd, frpi, arg, GMP_RNDN); + mpfr_sin(ret, frd, GMP_RNDN); + + mpfr_clears(frpi, frd, NULL); +} + +void mpfr_cospi(mpfr_t ret, mpfr_t arg, mpfr_rnd_t rnd) { + mpfr_t frpi, frd; + mpfr_inits(frpi, frd, NULL); + + mpfr_const_pi(frpi, GMP_RNDN); + mpfr_set_d(frd, 1.0, GMP_RNDN); + mpfr_mul(frpi, frpi, frd, GMP_RNDN); + mpfr_mul(frd, frpi, arg, GMP_RNDN); + mpfr_cos(ret, frd, GMP_RNDN); + + mpfr_clears(frpi, frd, NULL); +} +#endif + +void mpfr_lgamma_nosign(mpfr_t ret, mpfr_t arg, mpfr_rnd_t rnd) { + int s; + mpfr_lgamma(ret, &s, arg, rnd); +} +#endif // #define USEMPFR diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-tester/testerutil.h b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-tester/testerutil.h new file mode 100644 index 00000000000..53350746c3c --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-tester/testerutil.h @@ -0,0 +1,100 @@ +// Copyright Naoki Shibata and contributors 2010 - 2023. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#define DENORMAL_DBL_MIN (4.9406564584124654418e-324) +#define POSITIVE_INFINITY INFINITY +#define NEGATIVE_INFINITY (-INFINITY) + +#define DENORMAL_FLT_MIN (1.4012984643248170709e-45f) +#define POSITIVE_INFINITYf ((float)INFINITY) +#define NEGATIVE_INFINITYf (-(float)INFINITY) + +#ifndef M_PIf +# define M_PIf ((float)M_PI) +#endif + +extern int enableFlushToZero; +double flushToZero(double y); + +int isnumber(double x); +int isPlusZero(double x); +int isMinusZero(double x); +int xisnan(double x); +double sign(double d); + +int isnumberf(float x); +int isPlusZerof(float x); +int isMinusZerof(float x); +int xisnanf(float x); +float signf(float d); + +int readln(int fd, char *buf, int cnt); + +#define XRAND_MAX (INT64_C(0x100000000) * (double)INT64_C(0x100000000)) + +void xsrand(uint64_t s); +uint64_t xrand(); +void memrand(void *p, int size); + +// The following functions are meant to be inlined + +static double u2d(uint64_t u) { + union { + double f; + uint64_t i; + } tmp; + tmp.i = u; + return tmp.f; +} + +static uint64_t d2u(double d) { + union { + double f; + uint64_t i; + } tmp; + tmp.f = d; + return tmp.i; +} + +static float u2f(uint32_t u) { + union { + float f; + uint32_t i; + } tmp; + tmp.i = u; + return tmp.f; +} + +static uint32_t f2u(float d) { + union { + float f; + uint32_t i; + } tmp; + tmp.f = d; + return tmp.i; +} + +static int startsWith(char *str, char *prefix) { + while(*prefix != '\0') if (*str++ != *prefix++) return 0; + return *prefix == '\0'; +} + +// + +#ifdef USEMPFR +int cmpDenormdp(double x, mpfr_t fry); +double countULPdp(double d, mpfr_t c); +double countULP2dp(double d, mpfr_t c); + +int cmpDenormsp(float x, mpfr_t fry); +double countULPsp(float d, mpfr_t c); +double countULP2sp(float d, mpfr_t c); + +#if MPFR_VERSION < MPFR_VERSION_NUM(4, 2, 0) +void mpfr_sinpi(mpfr_t ret, mpfr_t arg, mpfr_rnd_t rnd); +void mpfr_cospi(mpfr_t ret, mpfr_t arg, mpfr_rnd_t rnd); +#endif +void mpfr_lgamma_nosign(mpfr_t ret, mpfr_t arg, mpfr_rnd_t rnd); +#endif diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-tester/testervecabi.c b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-tester/testervecabi.c new file mode 100644 index 00000000000..a428540f15e --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm-tester/testervecabi.c @@ -0,0 +1,850 @@ +#include +#include + +#define SLEEF_ENABLE_OMP_SIMD +#include + +#define N (65536 - 1) +#define THRES 1e-10 +#define THRESF 0.02 + +double a[N], b[N], c[N], d[N]; +float e[N], f[N], g[N], h[N]; + +static void check(char *mes, double thres) { + double err = 0; + for (int i = 0; i < N; i++) err += d[i] >= 0 ? d[i] : -d[i]; + if (err > thres) { + printf("%s, error=%g\n", mes, err); + exit(-1); + } +} + +static void checkf(char *mes, double thres) { + double err = 0; + for (int i = 0; i < N; i++) err += h[i] >= 0 ? h[i] : -h[i]; + if (err > thres) { + printf("%s, error=%g\n", mes, err); + exit(-1); + } +} + +void func00() { +// CHECK-AVX512: func00 +// CHECK-AVX2: func00 +// CHECK-SSE2: func00 + for (int i = 0; i < N; i++) d[i] = Sleef_asin_u10(Sleef_sin_u10(a[i])) - a[i]; + check("sin_u10, asin_u10", THRES); +// CHECK-AVX2-DAG: _ZGVdN4v_Sleef_asin_u10 +// CHECK-AVX2-DAG: _ZGVdN4v_Sleef_sin_u10 +// CHECK-AVX512-DAG: _ZGVeN8v_Sleef_asin_u10 +// CHECK-AVX512-DAG: _ZGVeN8v_Sleef_sin_u10 +// CHECK-SSE2-DAG: _ZGVbN2v_Sleef_asin_u10 +// CHECK-SSE2-DAG: _ZGVbN2v_Sleef_sin_u10 +} + +void func01() { +// CHECK-AVX512: func01 +// CHECK-AVX2: func01 +// CHECK-SSE2: func01 + for (int i = 0; i < N; i++) d[i] = Sleef_asin_u35(Sleef_sin_u35(a[i])) - a[i]; + check("sin_u35, asin_u35", THRES); +// CHECK-AVX2-DAG: _ZGVdN4v_Sleef_asin_u35 +// CHECK-AVX2-DAG: _ZGVdN4v_Sleef_sin_u35 +// CHECK-AVX512-DAG: _ZGVeN8v_Sleef_asin_u35 +// CHECK-AVX512-DAG: _ZGVeN8v_Sleef_sin_u35 +// CHECK-SSE2-DAG: _ZGVbN2v_Sleef_asin_u35 +// CHECK-SSE2-DAG: _ZGVbN2v_Sleef_sin_u35 +} + +void func02() { +// CHECK-AVX512: func02 +// CHECK-AVX2: func02 +// CHECK-SSE2: func02 + for (int i = 0; i < N; i++) d[i] = Sleef_acos_u10(Sleef_cos_u10(a[i])) - a[i]; + check("cos_u10, acos_u10", THRES); +// CHECK-AVX2-DAG: _ZGVdN4v_Sleef_acos_u10 +// CHECK-AVX2-DAG: _ZGVdN4v_Sleef_cos_u10 +// CHECK-AVX512-DAG: _ZGVeN8v_Sleef_acos_u10 +// CHECK-AVX512-DAG: _ZGVeN8v_Sleef_cos_u10 +// CHECK-SSE2-DAG: _ZGVbN2v_Sleef_acos_u10 +// CHECK-SSE2-DAG: _ZGVbN2v_Sleef_cos_u10 +} + +void func03() { +// CHECK-AVX512: func03 +// CHECK-AVX2: func03 +// CHECK-SSE2: func03 + for (int i = 0; i < N; i++) d[i] = Sleef_acos_u35(Sleef_cos_u35(a[i])) - a[i]; + check("cos_u35, acos_u35", THRES); +// CHECK-AVX2-DAG: _ZGVdN4v_Sleef_acos_u35 +// CHECK-AVX2-DAG: _ZGVdN4v_Sleef_cos_u35 +// CHECK-AVX512-DAG: _ZGVeN8v_Sleef_acos_u35 +// CHECK-AVX512-DAG: _ZGVeN8v_Sleef_cos_u35 +// CHECK-SSE2-DAG: _ZGVbN2v_Sleef_acos_u35 +// CHECK-SSE2-DAG: _ZGVbN2v_Sleef_cos_u35 +} + +void func04() { +// CHECK-AVX512: func04 +// CHECK-AVX2: func04 +// CHECK-SSE2: func04 + for (int i = 0; i < N; i++) d[i] = Sleef_atan_u10(Sleef_tan_u10(a[i])) - a[i]; + check("tan_u10, atan_u10", THRES); +// CHECK-AVX2-DAG: _ZGVdN4v_Sleef_atan_u10 +// CHECK-AVX2-DAG: _ZGVdN4v_Sleef_tan_u10 +// CHECK-AVX512-DAG: _ZGVeN8v_Sleef_atan_u10 +// CHECK-AVX512-DAG: _ZGVeN8v_Sleef_tan_u10 +// CHECK-SSE2-DAG: _ZGVbN2v_Sleef_atan_u10 +// CHECK-SSE2-DAG: _ZGVbN2v_Sleef_tan_u10 +} + +void func05() { +// CHECK-AVX512: func05 +// CHECK-AVX2: func05 +// CHECK-SSE2: func05 + for (int i = 0; i < N; i++) d[i] = Sleef_atan_u35(Sleef_tan_u35(a[i])) - a[i]; + check("tan_u35, atan_u35", THRES); +// CHECK-AVX2-DAG: _ZGVdN4v_Sleef_atan_u35 +// CHECK-AVX2-DAG: _ZGVdN4v_Sleef_tan_u35 +// CHECK-AVX512-DAG: _ZGVeN8v_Sleef_atan_u35 +// CHECK-AVX512-DAG: _ZGVeN8v_Sleef_tan_u35 +// CHECK-SSE2-DAG: _ZGVbN2v_Sleef_atan_u35 +// CHECK-SSE2-DAG: _ZGVbN2v_Sleef_tan_u35 +} + +void func06() { +// CHECK-AVX512: func06 +// CHECK-AVX2: func06 +// CHECK-SSE2: func06 + for (int i = 0; i < N; i++) d[i] = Sleef_atan2_u10(b[i] * Sleef_sinpi_u05(a[i]*0.1), b[i] * Sleef_cospi_u05(a[i]*0.1)) - a[i]*0.3141592653589793; + check("sinpi_u05, cospi_u05, atan2_u10", THRES); +// CHECK-AVX2-DAG: _ZGVdN4v_Sleef_sinpi_u05 +// CHECK-AVX2-DAG: _ZGVdN4v_Sleef_cospi_u05 +// CHECK-AVX2-DAG: _ZGVdN4vv_Sleef_atan2_u10 +// CHECK-AVX512-DAG: _ZGVeN8v_Sleef_sinpi_u05 +// CHECK-AVX512-DAG: _ZGVeN8v_Sleef_cospi_u05 +// CHECK-AVX512-DAG: _ZGVeN8vv_Sleef_atan2_u10 +// CHECK-SSE2-DAG: _ZGVbN2v_Sleef_sinpi_u05 +// CHECK-SSE2-DAG: _ZGVbN2v_Sleef_cospi_u05 +// CHECK-SSE2-DAG: _ZGVbN2vv_Sleef_atan2_u10 +} + +void func07() { +// CHECK-AVX512: func07 +// CHECK-AVX2: func07 +// CHECK-SSE2: func07 + for (int i = 0; i < N; i++) d[i] = Sleef_atan2_u35(b[i] * Sleef_sinpi_u05(a[i]*0.1), b[i] * Sleef_cospi_u05(a[i]*0.1)) - a[i]*0.3141592653589793; + check("sinpi_u05, cospi_u05, atan2_u35", THRES); +// CHECK-AVX2-DAG: _ZGVdN4v_Sleef_sinpi_u05 +// CHECK-AVX2-DAG: _ZGVdN4v_Sleef_cospi_u05 +// CHECK-AVX2-DAG: _ZGVdN4vv_Sleef_atan2_u35 +// CHECK-AVX512-DAG: _ZGVeN8v_Sleef_sinpi_u05 +// CHECK-AVX512-DAG: _ZGVeN8v_Sleef_cospi_u05 +// CHECK-AVX512-DAG: _ZGVeN8vv_Sleef_atan2_u35 +// CHECK-SSE2-DAG: _ZGVbN2v_Sleef_sinpi_u05 +// CHECK-SSE2-DAG: _ZGVbN2v_Sleef_cospi_u05 +// CHECK-SSE2-DAG: _ZGVbN2vv_Sleef_atan2_u35 +} + +void func08() { +// CHECK-AVX512: func08 +// CHECK-AVX2: func08 +// CHECK-SSE2: func08 + for (int i = 0; i < N; i++) d[i] = Sleef_log2_u10(Sleef_exp2_u10(a[i])) - a[i]; + check("log2_u10, exp2_u10", THRES); +// CHECK-AVX2-DAG: _ZGVdN4v_Sleef_log2_u10 +// CHECK-AVX2-DAG: _ZGVdN4v_Sleef_exp2_u10 +// CHECK-AVX512-DAG: _ZGVeN8v_Sleef_log2_u10 +// CHECK-AVX512-DAG: _ZGVeN8v_Sleef_exp2_u10 +// CHECK-SSE2-DAG: _ZGVbN2v_Sleef_log2_u10 +// CHECK-SSE2-DAG: _ZGVbN2v_Sleef_exp2_u10 +} + +void func09() { +// CHECK-AVX512: func09 +// CHECK-AVX2: func09 +// CHECK-SSE2: func09 + for (int i = 0; i < N; i++) d[i] = Sleef_log2_u35(Sleef_exp2_u35(a[i])) - a[i]; + check("log2_u35, exp2_u35", THRES); +// CHECK-AVX2-DAG: _ZGVdN4v_Sleef_log2_u35 +// CHECK-AVX2-DAG: _ZGVdN4v_Sleef_exp2_u35 +// CHECK-AVX512-DAG: _ZGVeN8v_Sleef_log2_u35 +// CHECK-AVX512-DAG: _ZGVeN8v_Sleef_exp2_u35 +// CHECK-SSE2-DAG: _ZGVbN2v_Sleef_log2_u35 +// CHECK-SSE2-DAG: _ZGVbN2v_Sleef_exp2_u35 +} + +void func10() { +// CHECK-AVX512: func10 +// CHECK-AVX2: func10 +// CHECK-SSE2: func10 + for (int i = 0; i < N; i++) d[i] = Sleef_log10_u10(Sleef_exp10_u35(a[i])) - a[i]; + check("log10_u10, exp10_u35", THRES); +// CHECK-AVX2-DAG: _ZGVdN4v_Sleef_log10_u10 +// CHECK-AVX2-DAG: _ZGVdN4v_Sleef_exp10_u35 +// CHECK-AVX512-DAG: _ZGVeN8v_Sleef_log10_u10 +// CHECK-AVX512-DAG: _ZGVeN8v_Sleef_exp10_u35 +// CHECK-SSE2-DAG: _ZGVbN2v_Sleef_log10_u10 +// CHECK-SSE2-DAG: _ZGVbN2v_Sleef_exp10_u35 +} + +void func11() { +// CHECK-AVX512: func11 +// CHECK-AVX2: func11 +// CHECK-SSE2: func11 + for (int i = 0; i < N; i++) d[i] = Sleef_log10_u10(Sleef_exp10_u10(a[i])) - a[i]; + check("log10_u10, exp10_u10", THRES); +// CHECK-AVX2-DAG: _ZGVdN4v_Sleef_log10_u10 +// CHECK-AVX2-DAG: _ZGVdN4v_Sleef_exp10_u10 +// CHECK-AVX512-DAG: _ZGVeN8v_Sleef_log10_u10 +// CHECK-AVX512-DAG: _ZGVeN8v_Sleef_exp10_u10 +// CHECK-SSE2-DAG: _ZGVbN2v_Sleef_log10_u10 +// CHECK-SSE2-DAG: _ZGVbN2v_Sleef_exp10_u10 +} + +void func12() { +// CHECK-AVX512: func12 +// CHECK-AVX2: func12 +// CHECK-SSE2: func12 + for (int i = 0; i < N; i++) d[i] = Sleef_log1p_u10(Sleef_expm1_u10(a[i])) - a[i]; + check("log1p_u10, expm1_u10", THRES); +// CHECK-AVX2-DAG: _ZGVdN4v_Sleef_log1p_u10 +// CHECK-AVX2-DAG: _ZGVdN4v_Sleef_expm1_u10 +// CHECK-AVX512-DAG: _ZGVeN8v_Sleef_log1p_u10 +// CHECK-AVX512-DAG: _ZGVeN8v_Sleef_expm1_u10 +// CHECK-SSE2-DAG: _ZGVbN2v_Sleef_log1p_u10 +// CHECK-SSE2-DAG: _ZGVbN2v_Sleef_expm1_u10 +} + +void func13() { +// CHECK-AVX512: func13 +// CHECK-AVX2: func13 +// CHECK-SSE2: func13 + for (int i = 0; i < N; i++) d[i] = Sleef_pow_u10(a[i], b[i]) - Sleef_exp_u10(Sleef_log_u10(a[i]) * b[i]); + check("pow_u10, exp_u10, log_u10", THRES); +// CHECK-AVX2-DAG: _ZGVdN4vv_Sleef_pow_u10 +// CHECK-AVX2-DAG: _ZGVdN4v_Sleef_exp_u10 +// CHECK-AVX2-DAG: _ZGVdN4v_Sleef_log_u10 +// CHECK-AVX512-DAG: _ZGVeN8vv_Sleef_pow_u10 +// CHECK-AVX512-DAG: _ZGVeN8v_Sleef_exp_u10 +// CHECK-AVX512-DAG: _ZGVeN8v_Sleef_log_u10 +// CHECK-SSE2-DAG: _ZGVbN2vv_Sleef_pow_u10 +// CHECK-SSE2-DAG: _ZGVbN2v_Sleef_exp_u10 +// CHECK-SSE2-DAG: _ZGVbN2v_Sleef_log_u10 +} + +void func14() { +// CHECK-AVX512: func14 +// CHECK-AVX2: func14 +// CHECK-SSE2: func14 + for (int i = 0; i < N; i++) d[i] = Sleef_pow_u10(a[i], b[i]) - Sleef_exp_u10(Sleef_log_u35(a[i]) * b[i]); + check("pow_u10, exp_u10, log_u35", THRES); +// CHECK-AVX2-DAG: _ZGVdN4vv_Sleef_pow_u10 +// CHECK-AVX2-DAG: _ZGVdN4v_Sleef_exp_u10 +// CHECK-AVX2-DAG: _ZGVdN4v_Sleef_log_u35 +// CHECK-AVX512-DAG: _ZGVeN8vv_Sleef_pow_u10 +// CHECK-AVX512-DAG: _ZGVeN8v_Sleef_exp_u10 +// CHECK-AVX512-DAG: _ZGVeN8v_Sleef_log_u35 +// CHECK-SSE2-DAG: _ZGVbN2vv_Sleef_pow_u10 +// CHECK-SSE2-DAG: _ZGVbN2v_Sleef_exp_u10 +// CHECK-SSE2-DAG: _ZGVbN2v_Sleef_log_u35 +} + +void func15() { +// CHECK-AVX512: func15 +// CHECK-AVX2: func15 +// CHECK-SSE2: func15 + for (int i = 0; i < N; i++) d[i] = Sleef_cbrt_u10(a[i] * a[i] * a[i]) - a[i]; + check("cbrt_u10", THRES); +// CHECK-AVX2-DAG: _ZGVdN4v_Sleef_cbrt_u10 +// CHECK-AVX512-DAG: _ZGVeN8v_Sleef_cbrt_u10 +// CHECK-SSE2-DAG: _ZGVbN2v_Sleef_cbrt_u10 +} + +void func16() { +// CHECK-AVX512: func16 +// CHECK-AVX2: func16 +// CHECK-SSE2: func16 + for (int i = 0; i < N; i++) d[i] = Sleef_cbrt_u35(a[i] * a[i] * a[i]) - a[i]; + check("cbrt_u35", THRES); +// CHECK-AVX2-DAG: _ZGVdN4v_Sleef_cbrt_u35 +// CHECK-AVX512-DAG: _ZGVeN8v_Sleef_cbrt_u35 +// CHECK-SSE2-DAG: _ZGVbN2v_Sleef_cbrt_u35 +} + +void func17() { +// CHECK-AVX512: func17 +// CHECK-AVX2: func17 +// CHECK-SSE2: func17 + for (int i = 0; i < N; i++) d[i] = Sleef_asinh_u10(Sleef_sinh_u10(a[i])) - a[i]; + check("asinh_u10, sinh_u10", THRES); +// CHECK-AVX2-DAG: _ZGVdN4v_Sleef_asinh_u10 +// CHECK-AVX2-DAG: _ZGVdN4v_Sleef_sinh_u10 +// CHECK-AVX512-DAG: _ZGVeN8v_Sleef_asinh_u10 +// CHECK-AVX512-DAG: _ZGVeN8v_Sleef_sinh_u10 +// CHECK-SSE2-DAG: _ZGVbN2v_Sleef_asinh_u10 +// CHECK-SSE2-DAG: _ZGVbN2v_Sleef_sinh_u10 +} + +void func18() { +// CHECK-AVX512: func18 +// CHECK-AVX2: func18 +// CHECK-SSE2: func18 + for (int i = 0; i < N; i++) d[i] = Sleef_asinh_u10(Sleef_sinh_u35(a[i])) - a[i]; + check("asinh_u10, sinh_u35", THRES); +// CHECK-AVX2-DAG: _ZGVdN4v_Sleef_asinh_u10 +// CHECK-AVX2-DAG: _ZGVdN4v_Sleef_sinh_u35 +// CHECK-AVX512-DAG: _ZGVeN8v_Sleef_asinh_u10 +// CHECK-AVX512-DAG: _ZGVeN8v_Sleef_sinh_u35 +// CHECK-SSE2-DAG: _ZGVbN2v_Sleef_asinh_u10 +// CHECK-SSE2-DAG: _ZGVbN2v_Sleef_sinh_u35 +} + +void func19() { +// CHECK-AVX512: func19 +// CHECK-AVX2: func19 +// CHECK-SSE2: func19 + for (int i = 0; i < N; i++) d[i] = Sleef_acosh_u10(Sleef_cosh_u10(a[i])) - a[i]; + check("acosh_u10, cosh_u10", THRES); +// CHECK-AVX2-DAG: _ZGVdN4v_Sleef_acosh_u10 +// CHECK-AVX2-DAG: _ZGVdN4v_Sleef_cosh_u10 +// CHECK-AVX512-DAG: _ZGVeN8v_Sleef_acosh_u10 +// CHECK-AVX512-DAG: _ZGVeN8v_Sleef_cosh_u10 +// CHECK-SSE2-DAG: _ZGVbN2v_Sleef_acosh_u10 +// CHECK-SSE2-DAG: _ZGVbN2v_Sleef_cosh_u10 +} + +void func20() { +// CHECK-AVX512: func20 +// CHECK-AVX2: func20 +// CHECK-SSE2: func20 + for (int i = 0; i < N; i++) d[i] = Sleef_acosh_u10(Sleef_cosh_u35(a[i])) - a[i]; + check("acosh_u10, cosh_u35", THRES); +// CHECK-AVX2-DAG: _ZGVdN4v_Sleef_acosh_u10 +// CHECK-AVX2-DAG: _ZGVdN4v_Sleef_cosh_u35 +// CHECK-AVX512-DAG: _ZGVeN8v_Sleef_acosh_u10 +// CHECK-AVX512-DAG: _ZGVeN8v_Sleef_cosh_u35 +// CHECK-SSE2-DAG: _ZGVbN2v_Sleef_acosh_u10 +// CHECK-SSE2-DAG: _ZGVbN2v_Sleef_cosh_u35 +} + +void func21() { +// CHECK-AVX512: func21 +// CHECK-AVX2: func21 +// CHECK-SSE2: func21 + for (int i = 0; i < N; i++) d[i] = Sleef_atanh_u10(Sleef_tanh_u10(a[i])) - a[i]; + check("atanh_u10, tanh_u10", THRES); +// CHECK-AVX2-DAG: _ZGVdN4v_Sleef_atanh_u10 +// CHECK-AVX2-DAG: _ZGVdN4v_Sleef_tanh_u10 +// CHECK-AVX512-DAG: _ZGVeN8v_Sleef_atanh_u10 +// CHECK-AVX512-DAG: _ZGVeN8v_Sleef_tanh_u10 +// CHECK-SSE2-DAG: _ZGVbN2v_Sleef_atanh_u10 +// CHECK-SSE2-DAG: _ZGVbN2v_Sleef_tanh_u10 +} + +void func22() { +// CHECK-AVX512: func22 +// CHECK-AVX2: func22 +// CHECK-SSE2: func22 + for (int i = 0; i < N; i++) d[i] = Sleef_atanh_u10(Sleef_tanh_u35(a[i])) - a[i]; + check("atanh_u10, tanh_u35", THRES); +// CHECK-AVX2-DAG: _ZGVdN4v_Sleef_atanh_u10 +// CHECK-AVX2-DAG: _ZGVdN4v_Sleef_tanh_u35 +// CHECK-AVX512-DAG: _ZGVeN8v_Sleef_atanh_u10 +// CHECK-AVX512-DAG: _ZGVeN8v_Sleef_tanh_u35 +// CHECK-SSE2-DAG: _ZGVbN2v_Sleef_atanh_u10 +// CHECK-SSE2-DAG: _ZGVbN2v_Sleef_tanh_u35 +} + +void func23() { +// CHECK-AVX512: func23 +// CHECK-AVX2: func23 +// CHECK-SSE2: func23 + for (int i = 0; i < N; i++) d[i] = Sleef_fma(a[i], b[i], c[i]) - (a[i] * b[i] + c[i]); + check("fma", THRES); +// CHECK-AVX2-DAG: _ZGVdN4vvv_Sleef_fma +// CHECK-AVX512-DAG: _ZGVeN8vvv_Sleef_fma +// CHECK-SSE2-DAG: _ZGVbN2vvv_Sleef_fma +} + +void func24() { +// CHECK-AVX512: func24 +// CHECK-AVX2: func24 +// CHECK-SSE2: func24 + for (int i = 0; i < N; i++) d[i] = Sleef_hypot_u05(a[i], b[i]) - Sleef_sqrt_u05(a[i] * a[i] + b[i] * b[i]); + check("hypot_u05, sqrt_u05", THRES); +// CHECK-AVX2-DAG: _ZGVdN4vv_Sleef_hypot_u05 +// CHECK-AVX512-DAG: _ZGVeN8vv_Sleef_hypot_u05 +// CHECK-SSE2-DAG: _ZGVbN2vv_Sleef_hypot_u05 +} + +void func25() { +// CHECK-AVX512: func25 +// CHECK-AVX2: func25 +// CHECK-SSE2: func25 + for (int i = 0; i < N; i++) d[i] = Sleef_hypot_u35(a[i], b[i]) - Sleef_sqrt_u05(a[i] * a[i] + b[i] * b[i]); + check("hypot_u35, sqrt_u05", THRES); +// CHECK-AVX2-DAG: _ZGVdN4vv_Sleef_hypot_u35 +// CHECK-AVX512-DAG: _ZGVeN8vv_Sleef_hypot_u35 +// CHECK-SSE2-DAG: _ZGVbN2vv_Sleef_hypot_u35 +} + +void func26() { +// CHECK-AVX512: func26 +// CHECK-AVX2: func26 +// CHECK-SSE2: func26 + for (int i = 0; i < N; i++) d[i] = Sleef_fmod(a[i], b[i]) - (a[i] - Sleef_floor(a[i] / b[i]) * b[i]); + check("fmod, floor", THRES); +// CHECK-AVX2-DAG: _ZGVdN4vv_Sleef_fmod +// CHECK-AVX2-DAG: _ZGVdN4v_Sleef_floor +// CHECK-AVX512-DAG: _ZGVeN8vv_Sleef_fmod +// CHECK-AVX512-DAG: _ZGVeN8v_Sleef_floor +// CHECK-SSE2-DAG: _ZGVbN2vv_Sleef_fmod +// CHECK-SSE2-DAG: _ZGVbN2v_Sleef_floor +} + +void func27() { +// CHECK-AVX512: func27 +// CHECK-AVX2: func27 +// CHECK-SSE2: func27 + for (int i = 0; i < N; i++) d[i] = Sleef_remainder(a[i], b[i]) - (a[i] - Sleef_rint(a[i] / b[i]) * b[i]); + check("remainder, rint", THRES); +// CHECK-AVX2-DAG: _ZGVdN4vv_Sleef_remainder +// CHECK-AVX2-DAG: _ZGVdN4v_Sleef_rint +// CHECK-AVX512-DAG: _ZGVeN8vv_Sleef_remainder +// CHECK-AVX512-DAG: _ZGVeN8v_Sleef_rint +// CHECK-SSE2-DAG: _ZGVbN2vv_Sleef_remainder +// CHECK-SSE2-DAG: _ZGVbN2v_Sleef_rint +} + +void func28() { +// CHECK-AVX512: func28 +// CHECK-AVX2: func28 +// CHECK-SSE2: func28 + for (int i = 0; i < N; i++) d[i] = Sleef_nextafter(Sleef_nextafter(a[i], b[i]), -b[i]) - a[i]; + check("nextafter", THRES); +// CHECK-AVX2-DAG: _ZGVdN4vv_Sleef_nextafter +// CHECK-AVX512-DAG: _ZGVeN8vv_Sleef_nextafter +// CHECK-SSE2-DAG: _ZGVbN2vv_Sleef_nextafter +} + +void func29() { +// CHECK-AVX512: func29 +// CHECK-AVX2: func29 +// CHECK-SSE2: func29 + for (int i = 0; i < N; i++) h[i] = Sleef_asinf_u10(Sleef_sinf_u10(e[i])) - e[i]; + checkf("sinf_u10, asinf_u10", THRESF); +// CHECK-AVX2-DAG: _ZGVdN8v_Sleef_asinf_u10 +// CHECK-AVX2-DAG: _ZGVdN8v_Sleef_sinf_u10 +// CHECK-AVX512-DAG: _ZGVeN16v_Sleef_asinf_u10 +// CHECK-AVX512-DAG: _ZGVeN16v_Sleef_sinf_u10 +// CHECK-SSE2-DAG: _ZGVbN4v_Sleef_asinf_u10 +// CHECK-SSE2-DAG: _ZGVbN4v_Sleef_sinf_u10 +} + +void func30() { +// CHECK-AVX512: func30 +// CHECK-AVX2: func30 +// CHECK-SSE2: func30 + for (int i = 0; i < N; i++) h[i] = Sleef_asinf_u35(Sleef_sinf_u35(e[i])) - e[i]; + checkf("sinf_u35, asinf_u35", THRESF); +// CHECK-AVX2-DAG: _ZGVdN8v_Sleef_asinf_u35 +// CHECK-AVX2-DAG: _ZGVdN8v_Sleef_sinf_u35 +// CHECK-AVX512-DAG: _ZGVeN16v_Sleef_asinf_u35 +// CHECK-AVX512-DAG: _ZGVeN16v_Sleef_sinf_u35 +// CHECK-SSE2-DAG: _ZGVbN4v_Sleef_asinf_u35 +// CHECK-SSE2-DAG: _ZGVbN4v_Sleef_sinf_u35 +} + +void func31() { +// CHECK-AVX512: func31 +// CHECK-AVX2: func31 +// CHECK-SSE2: func31 + for (int i = 0; i < N; i++) h[i] = Sleef_acosf_u10(Sleef_cosf_u10(e[i])) - e[i]; + checkf("cosf_u10, acosf_u10", THRESF); +// CHECK-AVX2-DAG: _ZGVdN8v_Sleef_acosf_u10 +// CHECK-AVX2-DAG: _ZGVdN8v_Sleef_cosf_u10 +// CHECK-AVX512-DAG: _ZGVeN16v_Sleef_acosf_u10 +// CHECK-AVX512-DAG: _ZGVeN16v_Sleef_cosf_u10 +// CHECK-SSE2-DAG: _ZGVbN4v_Sleef_acosf_u10 +// CHECK-SSE2-DAG: _ZGVbN4v_Sleef_cosf_u10 +} + +void func32() { +// CHECK-AVX512: func32 +// CHECK-AVX2: func32 +// CHECK-SSE2: func32 + for (int i = 0; i < N; i++) h[i] = Sleef_acosf_u35(Sleef_cosf_u35(e[i])) - e[i]; + checkf("cosf_u35, acosf_u35", THRESF); +// CHECK-AVX2-DAG: _ZGVdN8v_Sleef_acosf_u35 +// CHECK-AVX2-DAG: _ZGVdN8v_Sleef_cosf_u35 +// CHECK-AVX512-DAG: _ZGVeN16v_Sleef_acosf_u35 +// CHECK-AVX512-DAG: _ZGVeN16v_Sleef_cosf_u35 +// CHECK-SSE2-DAG: _ZGVbN4v_Sleef_acosf_u35 +// CHECK-SSE2-DAG: _ZGVbN4v_Sleef_cosf_u35 +} + +void func33() { +// CHECK-AVX512: func33 +// CHECK-AVX2: func33 +// CHECK-SSE2: func33 + for (int i = 0; i < N; i++) h[i] = Sleef_atanf_u10(Sleef_tanf_u10(e[i])) - e[i]; + checkf("tanf_u10, atanf_u10", THRESF); +// CHECK-AVX2-DAG: _ZGVdN8v_Sleef_atanf_u10 +// CHECK-AVX2-DAG: _ZGVdN8v_Sleef_tanf_u10 +// CHECK-AVX512-DAG: _ZGVeN16v_Sleef_atanf_u10 +// CHECK-AVX512-DAG: _ZGVeN16v_Sleef_tanf_u10 +// CHECK-SSE2-DAG: _ZGVbN4v_Sleef_atanf_u10 +// CHECK-SSE2-DAG: _ZGVbN4v_Sleef_tanf_u10 +} + +void func34() { +// CHECK-AVX512: func34 +// CHECK-AVX2: func34 +// CHECK-SSE2: func34 + for (int i = 0; i < N; i++) h[i] = Sleef_atanf_u35(Sleef_tanf_u35(e[i])) - e[i]; + checkf("tanf_u35, atanf_u35", THRESF); +// CHECK-AVX2-DAG: _ZGVdN8v_Sleef_atanf_u35 +// CHECK-AVX2-DAG: _ZGVdN8v_Sleef_tanf_u35 +// CHECK-AVX512-DAG: _ZGVeN16v_Sleef_atanf_u35 +// CHECK-AVX512-DAG: _ZGVeN16v_Sleef_tanf_u35 +// CHECK-SSE2-DAG: _ZGVbN4v_Sleef_atanf_u35 +// CHECK-SSE2-DAG: _ZGVbN4v_Sleef_tanf_u35 +} + +void func35() { +// CHECK-AVX512: func35 +// CHECK-AVX2: func35 +// CHECK-SSE2: func35 + for (int i = 0; i < N; i++) h[i] = Sleef_atan2f_u10(f[i] * Sleef_sinpif_u05(e[i]*0.1), f[i] * Sleef_cospif_u05(e[i]*0.1)) - e[i]*0.3141592653589793; + checkf("sinpif_u05, cospif_u05, atan2f_u10", THRESF); +// CHECK-AVX2-DAG: _ZGVdN8v_Sleef_sinpif_u05 +// CHECK-AVX2-DAG: _ZGVdN8v_Sleef_cospif_u05 +// CHECK-AVX2-DAG: _ZGVdN8vv_Sleef_atan2f_u10 +// CHECK-AVX512-DAG: _ZGVeN16v_Sleef_sinpif_u05 +// CHECK-AVX512-DAG: _ZGVeN16v_Sleef_cospif_u05 +// CHECK-AVX512-DAG: _ZGVeN16vv_Sleef_atan2f_u10 +// CHECK-SSE2-DAG: _ZGVbN4v_Sleef_sinpif_u05 +// CHECK-SSE2-DAG: _ZGVbN4v_Sleef_cospif_u05 +// CHECK-SSE2-DAG: _ZGVbN4vv_Sleef_atan2f_u10 +} + +void func36() { +// CHECK-AVX512: func36 +// CHECK-AVX2: func36 +// CHECK-SSE2: func36 + for (int i = 0; i < N; i++) h[i] = Sleef_atan2f_u35(f[i] * Sleef_sinpif_u05(e[i]*0.1), f[i] * Sleef_cospif_u05(e[i]*0.1)) - e[i]*0.3141592653589793; + checkf("sinpif_u05, cospif_u05, atan2f_u35", THRESF); +// CHECK-AVX2-DAG: _ZGVdN8v_Sleef_sinpif_u05 +// CHECK-AVX2-DAG: _ZGVdN8v_Sleef_cospif_u05 +// CHECK-AVX2-DAG: _ZGVdN8vv_Sleef_atan2f_u35 +// CHECK-AVX512-DAG: _ZGVeN16v_Sleef_sinpif_u05 +// CHECK-AVX512-DAG: _ZGVeN16v_Sleef_cospif_u05 +// CHECK-AVX512-DAG: _ZGVeN16vv_Sleef_atan2f_u35 +// CHECK-SSE2-DAG: _ZGVbN4v_Sleef_sinpif_u05 +// CHECK-SSE2-DAG: _ZGVbN4v_Sleef_cospif_u05 +// CHECK-SSE2-DAG: _ZGVbN4vv_Sleef_atan2f_u35 +} + +void func37() { +// CHECK-AVX512: func37 +// CHECK-AVX2: func37 +// CHECK-SSE2: func37 + for (int i = 0; i < N; i++) h[i] = Sleef_log2f_u10(Sleef_exp2f_u10(e[i])) - e[i]; + checkf("log2f_u10, exp2f_u10", THRESF); +// CHECK-AVX2-DAG: _ZGVdN8v_Sleef_log2f_u10 +// CHECK-AVX2-DAG: _ZGVdN8v_Sleef_exp2f_u10 +// CHECK-AVX512-DAG: _ZGVeN16v_Sleef_log2f_u10 +// CHECK-AVX512-DAG: _ZGVeN16v_Sleef_exp2f_u10 +// CHECK-SSE2-DAG: _ZGVbN4v_Sleef_log2f_u10 +// CHECK-SSE2-DAG: _ZGVbN4v_Sleef_exp2f_u10 +} + +void func38() { +// CHECK-AVX512: func38 +// CHECK-AVX2: func38 +// CHECK-SSE2: func38 + for (int i = 0; i < N; i++) h[i] = Sleef_log2f_u35(Sleef_exp2f_u35(e[i])) - e[i]; + checkf("log2f_u35, exp2f_u35", THRESF); +// CHECK-AVX2-DAG: _ZGVdN8v_Sleef_log2f_u35 +// CHECK-AVX2-DAG: _ZGVdN8v_Sleef_exp2f_u35 +// CHECK-AVX512-DAG: _ZGVeN16v_Sleef_log2f_u35 +// CHECK-AVX512-DAG: _ZGVeN16v_Sleef_exp2f_u35 +// CHECK-SSE2-DAG: _ZGVbN4v_Sleef_log2f_u35 +// CHECK-SSE2-DAG: _ZGVbN4v_Sleef_exp2f_u35 +} + +void func39() { +// CHECK-AVX512: func39 +// CHECK-AVX2: func39 +// CHECK-SSE2: func39 + for (int i = 0; i < N; i++) h[i] = Sleef_log10f_u10(Sleef_exp10f_u35(e[i])) - e[i]; + checkf("log10f_u10, exp10f_u35", THRESF); +// CHECK-AVX2-DAG: _ZGVdN8v_Sleef_log10f_u10 +// CHECK-AVX2-DAG: _ZGVdN8v_Sleef_exp10f_u35 +// CHECK-AVX512-DAG: _ZGVeN16v_Sleef_log10f_u10 +// CHECK-AVX512-DAG: _ZGVeN16v_Sleef_exp10f_u35 +// CHECK-SSE2-DAG: _ZGVbN4v_Sleef_log10f_u10 +// CHECK-SSE2-DAG: _ZGVbN4v_Sleef_exp10f_u35 +} + +void func40() { +// CHECK-AVX512: func40 +// CHECK-AVX2: func40 +// CHECK-SSE2: func40 + for (int i = 0; i < N; i++) h[i] = Sleef_log10f_u10(Sleef_exp10f_u10(e[i])) - e[i]; + checkf("log10f_u10, exp10f_u10", THRESF); +// CHECK-AVX2-DAG: _ZGVdN8v_Sleef_log10f_u10 +// CHECK-AVX2-DAG: _ZGVdN8v_Sleef_exp10f_u10 +// CHECK-AVX512-DAG: _ZGVeN16v_Sleef_log10f_u10 +// CHECK-AVX512-DAG: _ZGVeN16v_Sleef_exp10f_u10 +// CHECK-SSE2-DAG: _ZGVbN4v_Sleef_log10f_u10 +// CHECK-SSE2-DAG: _ZGVbN4v_Sleef_exp10f_u10 +} + +void func41() { +// CHECK-AVX512: func41 +// CHECK-AVX2: func41 +// CHECK-SSE2: func41 + for (int i = 0; i < N; i++) h[i] = Sleef_log1pf_u10(Sleef_expm1f_u10(e[i])) - e[i]; + checkf("log1pf_u10, expm1f_u10", THRESF); +// CHECK-AVX2-DAG: _ZGVdN8v_Sleef_log1pf_u10 +// CHECK-AVX2-DAG: _ZGVdN8v_Sleef_expm1f_u10 +// CHECK-AVX512-DAG: _ZGVeN16v_Sleef_log1pf_u10 +// CHECK-AVX512-DAG: _ZGVeN16v_Sleef_expm1f_u10 +// CHECK-SSE2-DAG: _ZGVbN4v_Sleef_log1pf_u10 +// CHECK-SSE2-DAG: _ZGVbN4v_Sleef_expm1f_u10 +} + +void func42() { +// CHECK-AVX512: func42 +// CHECK-AVX2: func42 +// CHECK-SSE2: func42 + for (int i = 0; i < N; i++) h[i] = Sleef_powf_u10(e[i], f[i]) - Sleef_expf_u10(Sleef_logf_u10(e[i]) * f[i]); + checkf("powf_u10, expf_u10, logf_u10", THRESF); +// CHECK-AVX2-DAG: _ZGVdN8vv_Sleef_powf_u10 +// CHECK-AVX2-DAG: _ZGVdN8v_Sleef_expf_u10 +// CHECK-AVX2-DAG: _ZGVdN8v_Sleef_logf_u10 +// CHECK-AVX512-DAG: _ZGVeN16vv_Sleef_powf_u10 +// CHECK-AVX512-DAG: _ZGVeN16v_Sleef_expf_u10 +// CHECK-AVX512-DAG: _ZGVeN16v_Sleef_logf_u10 +// CHECK-SSE2-DAG: _ZGVbN4vv_Sleef_powf_u10 +// CHECK-SSE2-DAG: _ZGVbN4v_Sleef_expf_u10 +// CHECK-SSE2-DAG: _ZGVbN4v_Sleef_logf_u10 +} + +void func43() { +// CHECK-AVX512: func43 +// CHECK-AVX2: func43 +// CHECK-SSE2: func43 + for (int i = 0; i < N; i++) h[i] = Sleef_powf_u10(e[i], f[i]) - Sleef_expf_u10(Sleef_logf_u35(e[i]) * f[i]); + checkf("powf_u10, expf_u10, logf_u35", THRESF); +// CHECK-AVX2-DAG: _ZGVdN8vv_Sleef_powf_u10 +// CHECK-AVX2-DAG: _ZGVdN8v_Sleef_expf_u10 +// CHECK-AVX2-DAG: _ZGVdN8v_Sleef_logf_u35 +// CHECK-AVX512-DAG: _ZGVeN16vv_Sleef_powf_u10 +// CHECK-AVX512-DAG: _ZGVeN16v_Sleef_expf_u10 +// CHECK-AVX512-DAG: _ZGVeN16v_Sleef_logf_u35 +// CHECK-SSE2-DAG: _ZGVbN4vv_Sleef_powf_u10 +// CHECK-SSE2-DAG: _ZGVbN4v_Sleef_expf_u10 +// CHECK-SSE2-DAG: _ZGVbN4v_Sleef_logf_u35 +} + +void func44() { +// CHECK-AVX512: func44 +// CHECK-AVX2: func44 +// CHECK-SSE2: func44 + for (int i = 0; i < N; i++) h[i] = Sleef_cbrtf_u10(e[i] * e[i] * e[i]) - e[i]; + checkf("cbrtf_u10", THRESF); +// CHECK-AVX2-DAG: _ZGVdN8v_Sleef_cbrtf_u10 +// CHECK-AVX512-DAG: _ZGVeN16v_Sleef_cbrtf_u10 +// CHECK-SSE2-DAG: _ZGVbN4v_Sleef_cbrtf_u10 +} + +void func45() { +// CHECK-AVX512: func45 +// CHECK-AVX2: func45 +// CHECK-SSE2: func45 + for (int i = 0; i < N; i++) h[i] = Sleef_cbrtf_u35(e[i] * e[i] * e[i]) - e[i]; + checkf("cbrtf_u35", THRESF); +// CHECK-AVX2-DAG: _ZGVdN8v_Sleef_cbrtf_u35 +// CHECK-AVX512-DAG: _ZGVeN16v_Sleef_cbrtf_u35 +// CHECK-SSE2-DAG: _ZGVbN4v_Sleef_cbrtf_u35 +} + +void func46() { +// CHECK-AVX512: func46 +// CHECK-AVX2: func46 +// CHECK-SSE2: func46 + for (int i = 0; i < N; i++) h[i] = Sleef_asinhf_u10(Sleef_sinhf_u10(e[i])) - e[i]; + checkf("asinhf_u10, sinhf_u10", THRESF); +// CHECK-AVX2-DAG: _ZGVdN8v_Sleef_asinhf_u10 +// CHECK-AVX2-DAG: _ZGVdN8v_Sleef_sinhf_u10 +// CHECK-AVX512-DAG: _ZGVeN16v_Sleef_asinhf_u10 +// CHECK-AVX512-DAG: _ZGVeN16v_Sleef_sinhf_u10 +// CHECK-SSE2-DAG: _ZGVbN4v_Sleef_asinhf_u10 +// CHECK-SSE2-DAG: _ZGVbN4v_Sleef_sinhf_u10 +} + +void func47() { +// CHECK-AVX512: func47 +// CHECK-AVX2: func47 +// CHECK-SSE2: func47 + for (int i = 0; i < N; i++) h[i] = Sleef_asinhf_u10(Sleef_sinhf_u35(e[i])) - e[i]; + checkf("asinhf_u10, sinhf_u35", THRESF); +// CHECK-AVX2-DAG: _ZGVdN8v_Sleef_asinhf_u10 +// CHECK-AVX2-DAG: _ZGVdN8v_Sleef_sinhf_u35 +// CHECK-AVX512-DAG: _ZGVeN16v_Sleef_asinhf_u10 +// CHECK-AVX512-DAG: _ZGVeN16v_Sleef_sinhf_u35 +// CHECK-SSE2-DAG: _ZGVbN4v_Sleef_asinhf_u10 +// CHECK-SSE2-DAG: _ZGVbN4v_Sleef_sinhf_u35 +} + +void func48() { +// CHECK-AVX512: func48 +// CHECK-AVX2: func48 +// CHECK-SSE2: func48 + for (int i = 0; i < N; i++) h[i] = Sleef_acoshf_u10(Sleef_coshf_u10(e[i])) - e[i]; + checkf("acoshf_u10, coshf_u10", THRESF); +// CHECK-AVX2-DAG: _ZGVdN8v_Sleef_acoshf_u10 +// CHECK-AVX2-DAG: _ZGVdN8v_Sleef_coshf_u10 +// CHECK-AVX512-DAG: _ZGVeN16v_Sleef_acoshf_u10 +// CHECK-AVX512-DAG: _ZGVeN16v_Sleef_coshf_u10 +// CHECK-SSE2-DAG: _ZGVbN4v_Sleef_acoshf_u10 +// CHECK-SSE2-DAG: _ZGVbN4v_Sleef_coshf_u10 +} + +void func49() { +// CHECK-AVX512: func49 +// CHECK-AVX2: func49 +// CHECK-SSE2: func49 + for (int i = 0; i < N; i++) h[i] = Sleef_acoshf_u10(Sleef_coshf_u35(e[i])) - e[i]; + checkf("acoshf_u10, coshf_u35", THRESF); +// CHECK-AVX2-DAG: _ZGVdN8v_Sleef_acoshf_u10 +// CHECK-AVX2-DAG: _ZGVdN8v_Sleef_coshf_u35 +// CHECK-AVX512-DAG: _ZGVeN16v_Sleef_acoshf_u10 +// CHECK-AVX512-DAG: _ZGVeN16v_Sleef_coshf_u35 +// CHECK-SSE2-DAG: _ZGVbN4v_Sleef_acoshf_u10 +// CHECK-SSE2-DAG: _ZGVbN4v_Sleef_coshf_u35 +} + +void func50() { +// CHECK-AVX512: func50 +// CHECK-AVX2: func50 +// CHECK-SSE2: func50 + for (int i = 0; i < N; i++) h[i] = Sleef_atanhf_u10(Sleef_tanhf_u10(e[i])) - e[i]; + checkf("atanhf_u10, tanhf_u10", THRESF); +// CHECK-AVX2-DAG: _ZGVdN8v_Sleef_atanhf_u10 +// CHECK-AVX2-DAG: _ZGVdN8v_Sleef_tanhf_u10 +// CHECK-AVX512-DAG: _ZGVeN16v_Sleef_atanhf_u10 +// CHECK-AVX512-DAG: _ZGVeN16v_Sleef_tanhf_u10 +// CHECK-SSE2-DAG: _ZGVbN4v_Sleef_atanhf_u10 +// CHECK-SSE2-DAG: _ZGVbN4v_Sleef_tanhf_u10 +} + +void func51() { +// CHECK-AVX512: func51 +// CHECK-AVX2: func51 +// CHECK-SSE2: func51 + for (int i = 0; i < N; i++) h[i] = Sleef_atanhf_u10(Sleef_tanhf_u35(e[i])) - e[i]; + checkf("atanhf_u10, tanhf_u35", THRESF); +// CHECK-AVX2-DAG: _ZGVdN8v_Sleef_atanhf_u10 +// CHECK-AVX2-DAG: _ZGVdN8v_Sleef_tanhf_u35 +// CHECK-AVX512-DAG: _ZGVeN16v_Sleef_atanhf_u10 +// CHECK-AVX512-DAG: _ZGVeN16v_Sleef_tanhf_u35 +// CHECK-SSE2-DAG: _ZGVbN4v_Sleef_atanhf_u10 +// CHECK-SSE2-DAG: _ZGVbN4v_Sleef_tanhf_u35 +} + +void func52() { +// CHECK-AVX512: func52 +// CHECK-AVX2: func52 +// CHECK-SSE2: func52 + for (int i = 0; i < N; i++) h[i] = Sleef_fmaf(e[i], f[i], g[i]) - (e[i] * f[i] + g[i]); + checkf("fmaf", THRESF); +// CHECK-AVX2-DAG: _ZGVdN8vvv_Sleef_fma +// CHECK-AVX512-DAG: _ZGVeN16vvv_Sleef_fma +// CHECK-SSE2-DAG: _ZGVbN4vvv_Sleef_fma +} + +void func53() { +// CHECK-AVX512: func53 +// CHECK-AVX2: func53 +// CHECK-SSE2: func53 + for (int i = 0; i < N; i++) h[i] = Sleef_hypotf_u05(e[i], f[i]) - Sleef_sqrtf_u05(e[i] * e[i] + f[i] * f[i]); + checkf("hypotf_u05, sqrtf_u05", THRESF); +// CHECK-AVX2-DAG: _ZGVdN8vv_Sleef_hypotf_u05 +// CHECK-AVX512-DAG: _ZGVeN16vv_Sleef_hypotf_u05 +// CHECK-SSE2-DAG: _ZGVbN4vv_Sleef_hypotf_u05 +} + +void func54() { +// CHECK-AVX512: func54 +// CHECK-AVX2: func54 +// CHECK-SSE2: func54 + for (int i = 0; i < N; i++) h[i] = Sleef_hypotf_u35(e[i], f[i]) - Sleef_sqrtf_u05(e[i] * e[i] + f[i] * f[i]); + checkf("hypotf_u35, sqrtf_u05", THRESF); +// CHECK-AVX2-DAG: _ZGVdN8vv_Sleef_hypotf_u35 +// CHECK-AVX512-DAG: _ZGVeN16vv_Sleef_hypotf_u35 +// CHECK-SSE2-DAG: _ZGVbN4vv_Sleef_hypotf_u35 +} + +void func55() { +// CHECK-AVX2: func55 +// CHECK-SSE2: func55 + for (int i = 0; i < N; i++) h[i] = Sleef_fmodf(e[i], f[i]) - (e[i] - Sleef_floorf(e[i] / f[i]) * f[i]); + checkf("fmodf, floorf", THRESF); +// CHECK-AVX2-DAG: _ZGVdN8vv_Sleef_fmodf +// CHECK-AVX2-DAG: _ZGVdN8v_Sleef_floorf +// CHECK-AVX512-DAG: _ZGVeN16vv_Sleef_fmodf +// CHECK-AVX512-DAG: _ZGVeN16v_Sleef_floorf +// CHECK-SSE2-DAG: _ZGVbN4vv_Sleef_fmodf +// CHECK-SSE2-DAG: _ZGVbN4v_Sleef_floorf +} + +void func56() { +// CHECK-AVX2: func56 +// CHECK-SSE2: func56 + for (int i = 0; i < N; i++) h[i] = Sleef_remainderf(e[i], f[i]) - (e[i] - Sleef_rintf(e[i] / f[i]) * f[i]); + checkf("remainderf, rintf", THRESF); +// CHECK-AVX2-DAG: _ZGVdN8vv_Sleef_remainderf +// CHECK-AVX2-DAG: _ZGVdN8v_Sleef_rintf +// CHECK-AVX512-DAG: _ZGVeN16vv_Sleef_remainderf +// CHECK-AVX512-DAG: _ZGVeN16v_Sleef_rintf +// CHECK-SSE2-DAG: _ZGVbN4vv_Sleef_remainderf +// CHECK-SSE2-DAG: _ZGVbN4v_Sleef_rintf +} + +void func57() { +// CHECK-AVX2: func57 +// CHECK-SSE2: func57 + for (int i = 0; i < N; i++) h[i] = Sleef_nextafterf(Sleef_nextafter(e[i], f[i]), -f[i]) - e[i]; + checkf("nextafterf", THRESF); +// CHECK-AVX2-DAG: _ZGVdN8vv_Sleef_nextafterf +// CHECK-AVX512-DAG: _ZGVeN16vv_Sleef_nextafterf +// CHECK-SSE2-DAG: _ZGVbN4vv_Sleef_nextafterf +} + +int main() { + for (int i = 0; i < N; i++) { + a[i] = 1.5 * rand() / (double)RAND_MAX + 1e-100; + b[i] = 1.5 * rand() / (double)RAND_MAX + 1e-100; + c[i] = 1.5 * rand() / (double)RAND_MAX + 1e-100; + } + + for (int i = 0; i < N; i++) { + e[i] = 1.5 * rand() / (double)RAND_MAX + 1e-100; + f[i] = 1.5 * rand() / (double)RAND_MAX + 1e-100; + g[i] = 1.5 * rand() / (double)RAND_MAX + 1e-100; + } + + func00(); func01(); func02(); func03(); func04(); func05(); func06(); func07(); func08(); func09(); + func10(); func11(); func12(); func13(); func14(); func15(); func16(); func17(); func18(); func19(); + func20(); func21(); func22(); func23(); func24(); func25(); func26(); func27(); func28(); func29(); + func30(); func31(); func32(); func33(); func34(); func35(); func36(); func37(); func38(); func39(); + func40(); func41(); func42(); func43(); func44(); func45(); func46(); func47(); func48(); func49(); + func50(); func51(); func52(); func53(); func54(); func55(); func56(); func57(); + + exit(0); +} diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/CMakeLists.txt b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/CMakeLists.txt new file mode 100644 index 00000000000..aebc3d34edc --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/CMakeLists.txt @@ -0,0 +1,1065 @@ + +# Settings + +if (SLEEF_ARCH_X86) + set(SLEEF_HEADER_LIST + SSE_ + SSE2 + SSE4 + AVX_ + AVX + FMA4 + AVX2 + AVX2128 + AVX512F_ + AVX512F + AVX512FNOFMA + PUREC_SCALAR + PURECFMA_SCALAR + DSP_SCALAR + ) +elseif(SLEEF_ARCH_AARCH64) + set(SLEEF_HEADER_LIST + ADVSIMD_ + ADVSIMD + ADVSIMDNOFMA + SVE + SVENOFMA + PUREC_SCALAR + PURECFMA_SCALAR + DSP_SCALAR + ) +elseif(SLEEF_ARCH_AARCH32) + set(SLEEF_HEADER_LIST + NEON32_ + NEON32 + NEON32VFPV4 + PUREC_SCALAR + PURECFMA_SCALAR + DSP_SCALAR + ) +elseif(SLEEF_ARCH_PPC64) + set(SLEEF_HEADER_LIST + VSX_ + VSX + VSXNOFMA + VSX3 + VSX3NOFMA + PUREC_SCALAR + PURECFMA_SCALAR + DSP_SCALAR + ) +elseif(SLEEF_ARCH_S390X) + set(SLEEF_HEADER_LIST + VXE_ + VXE + VXENOFMA + VXE2 + VXE2NOFMA + PUREC_SCALAR + PURECFMA_SCALAR + DSP_SCALAR + ) +elseif(SLEEF_ARCH_RISCV64) + set(SLEEF_HEADER_LIST + RVVM1 + RVVM1NOFMA + RVVM2 + RVVM2NOFMA + PUREC_SCALAR + PURECFMA_SCALAR + ) +endif() + +# HEADER_PARAMS + +command_arguments(HEADER_PARAMS_SSE_ - 2 4 __m128d __m128 __m128i __m128i __SSE2__) +command_arguments(HEADER_PARAMS_SSE2 cinz_ 2 4 __m128d __m128 __m128i __m128i __SSE2__ sse2) +command_arguments(HEADER_PARAMS_SSE4 cinz_ 2 4 __m128d __m128 __m128i __m128i __SSE2__ sse4) +command_arguments(HEADER_PARAMS_AVX_ - 4 8 __m256d __m256 __m128i "struct { __m128i x, y$ }" __AVX__) +command_arguments(HEADER_PARAMS_AVX cinz_ 4 8 __m256d __m256 __m128i "struct { __m128i x, y$ }" __AVX__ avx) +command_arguments(HEADER_PARAMS_FMA4 finz_ 4 8 __m256d __m256 __m128i "struct { __m128i x, y$ }" __AVX__ fma4) +command_arguments(HEADER_PARAMS_AVX2 finz_ 4 8 __m256d __m256 __m128i __m256i __AVX__ avx2) +command_arguments(HEADER_PARAMS_AVX2128 finz_ 2 4 __m128d __m128 __m128i __m128i __SSE2__ avx2128) +command_arguments(HEADER_PARAMS_AVX512F_ - 8 16 __m512d __m512 __m256i __m512i __AVX512F__) +command_arguments(HEADER_PARAMS_AVX512F finz_ 8 16 __m512d __m512 __m256i __m512i __AVX512F__ avx512f) +command_arguments(HEADER_PARAMS_AVX512FNOFMA cinz_ 8 16 __m512d __m512 __m256i __m512i __AVX512F__ avx512fnofma) + +command_arguments(HEADER_PARAMS_ADVSIMD_ - 2 4 float64x2_t float32x4_t int32x2_t int32x4_t __ARM_NEON) +command_arguments(HEADER_PARAMS_ADVSIMD finz_ 2 4 float64x2_t float32x4_t int32x2_t int32x4_t __ARM_NEON advsimd) +command_arguments(HEADER_PARAMS_ADVSIMDNOFMA cinz_ 2 4 float64x2_t float32x4_t int32x2_t int32x4_t __ARM_NEON advsimdnofma) +command_arguments(HEADER_PARAMS_SVE finz_ x x svfloat64_t svfloat32_t svint32_t svint32_t __ARM_FEATURE_SVE sve) +command_arguments(HEADER_PARAMS_SVENOFMA cinz_ x x svfloat64_t svfloat32_t svint32_t svint32_t __ARM_FEATURE_SVE svenofma) + +command_arguments(HEADER_PARAMS_NEON32_ - 2 4 - float32x4_t int32x2_t int32x4_t __ARM_NEON__) +command_arguments(HEADER_PARAMS_NEON32 cinz_ 2 4 - float32x4_t int32x2_t int32x4_t __ARM_NEON__ neon) +command_arguments(HEADER_PARAMS_NEON32VFPV4 finz_ 2 4 - float32x4_t int32x2_t int32x4_t __ARM_NEON__ neonvfpv4) + +command_arguments(HEADER_PARAMS_VSX_ - 2 4 "SLEEF_VECTOR_DOUBLE" "SLEEF_VECTOR_FLOAT" "SLEEF_VECTOR_INT" "SLEEF_VECTOR_INT" __VSX__) +command_arguments(HEADER_PARAMS_VSX finz_ 2 4 "SLEEF_VECTOR_DOUBLE" "SLEEF_VECTOR_FLOAT" "SLEEF_VECTOR_INT" "SLEEF_VECTOR_INT" __VSX__ vsx) +command_arguments(HEADER_PARAMS_VSXNOFMA cinz_ 2 4 "SLEEF_VECTOR_DOUBLE" "SLEEF_VECTOR_FLOAT" "SLEEF_VECTOR_INT" "SLEEF_VECTOR_INT" __VSX__ vsxnofma) +command_arguments(HEADER_PARAMS_VSX3 finz_ 2 4 "SLEEF_VECTOR_DOUBLE" "SLEEF_VECTOR_FLOAT" "SLEEF_VECTOR_INT" "SLEEF_VECTOR_INT" __VSX__ vsx3) +command_arguments(HEADER_PARAMS_VSX3NOFMA cinz_ 2 4 "SLEEF_VECTOR_DOUBLE" "SLEEF_VECTOR_FLOAT" "SLEEF_VECTOR_INT" "SLEEF_VECTOR_INT" __VSX__ vsx3nofma) + +command_arguments(HEADER_PARAMS_VXE_ - 2 4 "SLEEF_VECTOR_DOUBLE" "SLEEF_VECTOR_FLOAT" "SLEEF_VECTOR_INT" "SLEEF_VECTOR_INT" __VEC__) +command_arguments(HEADER_PARAMS_VXE finz_ 2 4 "SLEEF_VECTOR_DOUBLE" "SLEEF_VECTOR_FLOAT" "SLEEF_VECTOR_INT" "SLEEF_VECTOR_INT" __VEC__ vxe) +command_arguments(HEADER_PARAMS_VXENOFMA cinz_ 2 4 "SLEEF_VECTOR_DOUBLE" "SLEEF_VECTOR_FLOAT" "SLEEF_VECTOR_INT" "SLEEF_VECTOR_INT" __VEC__ vxenofma) +command_arguments(HEADER_PARAMS_VXE2 finz_ 2 4 "SLEEF_VECTOR_DOUBLE" "SLEEF_VECTOR_FLOAT" "SLEEF_VECTOR_INT" "SLEEF_VECTOR_INT" __VEC__ vxe2) +command_arguments(HEADER_PARAMS_VXE2NOFMA cinz_ 2 4 "SLEEF_VECTOR_DOUBLE" "SLEEF_VECTOR_FLOAT" "SLEEF_VECTOR_INT" "SLEEF_VECTOR_INT" __VEC__ vxe2nofma) + +command_arguments(HEADER_PARAMS_RVVM1 finz_ x x vfloat64m1_t vfloat32m1_t vint32mf2_t vint32m1_t __riscv_v rvvm1) +command_arguments(HEADER_PARAMS_RVVM1NOFMA cinz_ x x vfloat64m1_t vfloat32m1_t vint32mf2_t vint32m1_t __riscv_v rvvm1nofma) +command_arguments(HEADER_PARAMS_RVVM2 finz_ x x vfloat64m2_t vfloat32m2_t vint32m1_t vint32m2_t __riscv_v rvvm2) +command_arguments(HEADER_PARAMS_RVVM2NOFMA cinz_ x x vfloat64m2_t vfloat32m2_t vint32m1_t vint32m2_t __riscv_v rvvm2nofma) + +command_arguments(HEADER_PARAMS_DSP_SCALAR - 1 1 double float int32_t int32_t __STDC__) +command_arguments(HEADER_PARAMS_PUREC_SCALAR cinz_ 1 1 double float int32_t int32_t __STDC__ purec) +command_arguments(HEADER_PARAMS_PURECFMA_SCALAR finz_ 1 1 double float int32_t int32_t __STDC__ purecfma) + +# RENAME_PARAMS + +command_arguments(RENAME_PARAMS_SSE2 cinz_ 2 4 sse2) +command_arguments(RENAME_PARAMS_SSE4 cinz_ 2 4 sse4) +command_arguments(RENAME_PARAMS_AVX cinz_ 4 8 avx) +command_arguments(RENAME_PARAMS_FMA4 finz_ 4 8 fma4) +command_arguments(RENAME_PARAMS_AVX2 finz_ 4 8 avx2) +command_arguments(RENAME_PARAMS_AVX2128 finz_ 2 4 avx2128) +command_arguments(RENAME_PARAMS_AVX512F finz_ 8 16 avx512f) +command_arguments(RENAME_PARAMS_AVX512FNOFMA cinz_ 8 16 avx512fnofma) +command_arguments(RENAME_PARAMS_ADVSIMD finz_ 2 4 advsimd) +command_arguments(RENAME_PARAMS_ADVSIMDNOFMA cinz_ 2 4 advsimdnofma) +command_arguments(RENAME_PARAMS_NEON32 cinz_ 2 4 neon) +command_arguments(RENAME_PARAMS_NEON32VFPV4 finz_ 2 4 neonvfpv4) +command_arguments(RENAME_PARAMS_VSX finz_ 2 4 vsx) +command_arguments(RENAME_PARAMS_VSXNOFMA cinz_ 2 4 vsxnofma) +command_arguments(RENAME_PARAMS_VSX3 finz_ 2 4 vsx3) +command_arguments(RENAME_PARAMS_VSX3NOFMA cinz_ 2 4 vsx3nofma) +command_arguments(RENAME_PARAMS_VXE finz_ 2 4 vxe) +command_arguments(RENAME_PARAMS_VXENOFMA cinz_ 2 4 vxenofma) +command_arguments(RENAME_PARAMS_VXE2 finz_ 2 4 vxe2) +command_arguments(RENAME_PARAMS_VXE2NOFMA cinz_ 2 4 vxe2nofma) +command_arguments(RENAME_PARAMS_PUREC_SCALAR cinz_ 1 1 purec) +command_arguments(RENAME_PARAMS_PURECFMA_SCALAR finz_ 1 1 purecfma) +command_arguments(RENAME_PARAMS_CUDA finz_ 1 1 cuda) + +# The vector length parameters in SVE, for SP and DP, are chosen for +# the smallest SVE vector size (128-bit). The name is generated using +# the "x" token of VLA SVE vector functions. +command_arguments(RENAME_PARAMS_SVE finz_ x x sve) +command_arguments(RENAME_PARAMS_SVENOFMA cinz_ x x svenofma) + +command_arguments(RENAME_PARAMS_GNUABI_SSE2 sse2 b 2 4 _mm128d _mm128 _mm128i _mm128i __SSE2__) +command_arguments(RENAME_PARAMS_GNUABI_AVX avx c 4 8 __m256d __m256 __m128i "struct { __m128i x, y$ }" __AVX__) +command_arguments(RENAME_PARAMS_GNUABI_AVX2 avx2 d 4 8 __m256d __m256 __m128i __m256i __AVX2__) +command_arguments(RENAME_PARAMS_GNUABI_AVX512F avx512f e 8 16 __m512d __m512 __m256i __m512i __AVX512F__) +command_arguments(RENAME_PARAMS_GNUABI_ADVSIMD advsimd n 2 4 float64x2_t float32x4_t int32x2_t int32x4_t __ARM_NEON) +# The vector length parameters in SVE, for SP and DP, are chosen for +# the smallest SVE vector size (128-bit). The name is generated using +# the "x" token of VLA SVE vector functions. +command_arguments(RENAME_PARAMS_GNUABI_SVE sve s x x svfloat64_t svfloat32_t svint32_t svint32_t __ARM_SVE) + +command_arguments(RENAME_PARAMS_RVVM1 finz_ x x rvvm1) +command_arguments(RENAME_PARAMS_RVVM1NOFMA cinz_ x x rvvm1nofma) +command_arguments(RENAME_PARAMS_RVVM2 finz_ x x rvvm2) +command_arguments(RENAME_PARAMS_RVVM2NOFMA cinz_ x x rvvm2nofma) + +# ALIAS_PARAMS + +command_arguments(ALIAS_PARAMS_AVX512F_DP 8 __m512d __m256i e avx512f) +command_arguments(ALIAS_PARAMS_AVX512F_SP -16 __m512 __m512i e avx512f) + +command_arguments(ALIAS_PARAMS_ADVSIMD_DP 2 float64x2_t int32x2_t n advsimd) +command_arguments(ALIAS_PARAMS_ADVSIMD_SP -4 float32x4_t int32x4_t n advsimd) + +command_arguments(ALIAS_PARAMS_NEON32_SP -4 float32x4_t int32x4_t - neon) +command_arguments(ALIAS_PARAMS_NEON32_DP 0) + +set(EXT_ENABLE_ALIAS AVX512F ADVSIMD NEON32) + +# + +file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/) +include_directories(${CMAKE_CURRENT_BINARY_DIR}/include/) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}) + +set(CMAKE_C_FLAGS "${ORG_CMAKE_C_FLAGS} ${SLEEF_C_FLAGS}") + +# -------------------------------------------------------------------- +# sleef.h +# -------------------------------------------------------------------- +# File generated for the headers +set(SLEEF_ORG_HEADER ${CMAKE_CURRENT_BINARY_DIR}/sleeflibm_header.h.org) +set(SLEEF_ORG_FOOTER ${CMAKE_CURRENT_SOURCE_DIR}/sleeflibm_footer.h.org) +set(SLEEF_INCLUDE_HEADER ${sleef_BINARY_DIR}/include/sleef.h) + +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/sleeflibm_header.h.org.in ${SLEEF_ORG_HEADER}) + +set(SLEEF_HEADER_SIMD_SECTIONS "") +foreach(SIMD ${SLEEF_HEADER_LIST}) + set(SIMD_SECTION_FILE ${CMAKE_CURRENT_BINARY_DIR}/sleeflibm_${SIMD}.h.tmp) + list(APPEND SLEEF_HEADER_SIMD_SECTIONS ${SIMD_SECTION_FILE}) + add_custom_command( + OUTPUT ${SIMD_SECTION_FILE} + COMMAND $ ${HEADER_PARAMS_${SIMD}} > ${SIMD_SECTION_FILE} + DEPENDS ${TARGET_MKRENAME} + ) +endforeach() + +file(MAKE_DIRECTORY ${sleef_BINARY_DIR}/include) +sleef_concat_files( + OUTPUT ${SLEEF_INCLUDE_HEADER} + SOURCES ${SLEEF_ORG_HEADER} ${SLEEF_HEADER_SIMD_SECTIONS} ${SLEEF_ORG_FOOTER} +) + +# -------------------------------------------------------------------- +# TARGET_MKRENAME +# renameXXX.h for each SIMD +# -------------------------------------------------------------------- +# Helper executable: generates parts of the sleef header file +add_host_executable(${TARGET_MKRENAME} mkrename.c) + +# Enable Vector PCS for Advanced SIMD (if supported) +if(FORCE_AAVPCS) + host_target_AAVPCS_definitions(${TARGET_MKRENAME}) +endif() + +set(HEADER_FILES_GENERATED "") +foreach(SIMD ${SLEEF_SUPPORTED_LIBM_EXTENSIONS}) + if(COMPILER_SUPPORTS_${SIMD}) + # Need lowercase string for rename header + string(TOLOWER ${SIMD} vecarch) + set(OBJECT_${SIMD} "sleef${vecarch}") + set(OBJECTDET_${SIMD} "sleefdet${vecarch}") + set(HEADER_${SIMD} ${CMAKE_CURRENT_BINARY_DIR}/include/rename${vecarch}.h) + list(APPEND HEADER_FILES_GENERATED ${HEADER_${SIMD}}) + + # Generate mkrename commands + add_custom_command(OUTPUT ${HEADER_${SIMD}} + COMMAND echo Generating rename${vecarch}.h: ${TARGET_MKRENAME} ${RENAME_PARAMS_${SIMD}} + COMMAND $ ${RENAME_PARAMS_${SIMD}} > ${HEADER_${SIMD}} + DEPENDS ${TARGET_MKRENAME} + ) + add_custom_target(rename${SIMD}.h_generated DEPENDS ${HEADER_${SIMD}}) + endif() +endforeach() + +# Generate renamecuda.h + +set(HEADER_CUDA ${CMAKE_CURRENT_BINARY_DIR}/include/renamecuda.h) +list(APPEND HEADER_FILES_GENERATED ${HEADER_CUDA}) +add_custom_command(OUTPUT ${HEADER_CUDA} + COMMAND echo Generating renamecuda.h: ${TARGET_MKRENAME} ${RENAME_PARAMS_CUDA} + COMMAND $ ${RENAME_PARAMS_CUDA} > ${HEADER_CUDA} + DEPENDS ${TARGET_MKRENAME} + ) +add_custom_target(renameCUDA.h_generated DEPENDS ${HEADER_CUDA}) + +# -------------------------------------------------------------------- +# TARGET_MKRENAME_GNUABI +# renameXXX_gnuabi.h for each SIMD GNU Abi +# -------------------------------------------------------------------- +# Helper executable: generates parts of the sleef header file gnu_abi +add_host_executable(${TARGET_MKRENAME_GNUABI} mkrename_gnuabi.c) + +set(HEADER_GNUABI_FILES_GENERATED "") +if(ENABLE_GNUABI) + foreach(SIMD ${SLEEF_SUPPORTED_GNUABI_EXTENSIONS}) + if(COMPILER_SUPPORTS_${SIMD}) + string(TOLOWER ${SIMD} vecarch) + set(OBJECT_${SIMD}_dp_GNUABI "sleefgnuabi${vecarch}dp") + set(OBJECT_${SIMD}_sp_GNUABI "sleefgnuabi${vecarch}sp") + set(HEADER_${SIMD}_GNUABI ${CMAKE_CURRENT_BINARY_DIR}/include/rename${vecarch}_gnuabi.h) + list(APPEND HEADER_GNUABI_FILES_GENERATED ${HEADER_${SIMD}_GNUABI}) + + # Generate mkrename_gnuabi commands + add_custom_command(OUTPUT ${HEADER_${SIMD}_GNUABI} + COMMAND echo Generating rename${vecarch}_gnuabi.h: ${TARGET_MKRENAME_GNUABI} ${RENAME_PARAMS_GNUABI_${SIMD}} + COMMAND $ ${RENAME_PARAMS_GNUABI_${SIMD}} > ${HEADER_${SIMD}_GNUABI} + DEPENDS ${TARGET_MKRENAME_GNUABI} + ) + # set_source_files_properties(${HEADER_${SIMD}_GNUABI} PROPERTIES GENERATED TRUE) + endif() + endforeach() +endif() + +# -------------------------------------------------------------------- + +# TARGET_MKMASKED_GNUABI +add_host_executable(${TARGET_MKMASKED_GNUABI} mkmasked_gnuabi.c) + +# maskedXXX_YY_gnuabi.h +if(ENABLE_GNUABI) + foreach(SIMD ${SLEEF_SUPPORTED_GNUABI_EXTENSIONS}) + if(COMPILER_SUPPORTS_${SIMD} AND MKMASKED_PARAMS_GNUABI_${SIMD}_sp) + string(TOLOWER ${SIMD} vecarch) + + set(HEADER_GENERATED "") + foreach(T dp sp) + set(HEADER_MASKED_${SIMD}_${T}_GNUABI ${CMAKE_CURRENT_BINARY_DIR}/include/masked_${vecarch}_${T}_gnuabi.h) + list(APPEND HEADER_GENERATED ${HEADER_MASKED_${SIMD}_${T}_GNUABI}) + + add_custom_command(OUTPUT ${HEADER_MASKED_${SIMD}_${T}_GNUABI} + COMMAND $ ${MKMASKED_PARAMS_GNUABI_${SIMD}_${T}} > ${HEADER_MASKED_${SIMD}_${T}_GNUABI} + DEPENDS ${TARGET_MKMASKED_GNUABI} + ) + endforeach() + add_custom_target(masked${SIMD}_generated DEPENDS ${HEADER_GENERATED}) + endif() + endforeach() +endif() + +# -------------------------------------------------------------------- +# TARGET_HEADERS +# -------------------------------------------------------------------- +add_custom_target(${TARGET_HEADERS} ALL + DEPENDS + ${SLEEF_INCLUDE_HEADER} # Output only + ${HEADER_FILES_GENERATED} # Output only + ${HEADER_GNUABI_FILES_GENERATED} # Output only +) + +# -------------------------------------------------------------------- +# TARGET_MKALIAS +# -------------------------------------------------------------------- +add_host_executable(${TARGET_MKALIAS} mkalias.c) +if(FORCE_AAVPCS) + host_target_AAVPCS_definitions(${TARGET_MKALIAS}) +endif() + +# -------------------------------------------------------------------- +# TARGET_MKDISP +# -------------------------------------------------------------------- +# Helper executable: dispatcher for the vector extensions +add_host_executable(${TARGET_MKDISP} mkdisp.c) + +# Set C standard requirement (-std=gnu99 for gcc) +set_target_properties( + ${TARGET_MKRENAME} ${TARGET_MKRENAME_GNUABI} ${TARGET_MKDISP} + ${TARGET_MKALIAS} ${TARGET_MKMASKED_GNUABI} + PROPERTIES C_STANDARD 99 +) + +# -------------------------------------------------------------------- +# TARGET_LIBSLEEF +# -------------------------------------------------------------------- +# Build main library + +set(COMMON_TARGET_PROPERTIES + C_STANDARD 99 # -std=gnu99 + ) + +if (BUILD_SHARED_LIBS) + list(APPEND COMMON_TARGET_PROPERTIES POSITION_INDEPENDENT_CODE ON) # -fPIC +endif() + +if (SLEEF_ENABLE_LTO) + list(APPEND COMMON_TARGET_PROPERTIES INTERPROCEDURAL_OPTIMIZATION TRUE) # -flto +endif() + +# Original sleef sources +set(STANDARD_SOURCES rempitab.c) +# Check for different precision support and add sources accordingly +if(COMPILER_SUPPORTS_LONG_DOUBLE) + list(APPEND STANDARD_SOURCES sleefld.c) +endif() + +add_library(${TARGET_LIBSLEEF} ${STANDARD_SOURCES}) +add_dependencies(${TARGET_LIBSLEEF} ${TARGET_HEADERS}) +set_target_properties(${TARGET_LIBSLEEF} PROPERTIES + VERSION ${SLEEF_VERSION} + SOVERSION ${SLEEF_SOVERSION} + PUBLIC_HEADER ${SLEEF_INCLUDE_HEADER} + ${COMMON_TARGET_PROPERTIES} +) + +target_compile_definitions(${TARGET_LIBSLEEF} + PRIVATE DORENAME=1 ${COMMON_TARGET_DEFINITIONS} +) + +if(COMPILER_SUPPORTS_FLOAT128) + # TODO: Not supported for LLVM bitcode gen as it has a specific compilation flags + target_sources(${TARGET_LIBSLEEF} PRIVATE sleefqp.c) + target_compile_definitions(${TARGET_LIBSLEEF} + PRIVATE ENABLEFLOAT128=1 ${COMMON_TARGET_DEFINITIONS}) +endif() + +if(COMPILER_SUPPORTS_BUILTIN_MATH) + target_compile_definitions(${TARGET_LIBSLEEF} PRIVATE ENABLE_BUILTIN_MATH=1) +endif() + +# Compile SIMD versions +# Single precision and double precision + +# Include symbols for each SIMD architecture (if supported by the platform) +# Note: adds object file as sources via cmake conditional generator expression +foreach(SIMD ${SLEEF_SUPPORTED_LIBM_EXTENSIONS}) + if(COMPILER_SUPPORTS_${SIMD}) + list(FIND EXT_ENABLE_ALIAS ${SIMD} INDEX_ALIAS) + string(TOLOWER ${SIMD} SIMDLC) + + if (${SIMD} STREQUAL "NEON32" OR ${SIMD} STREQUAL "NEON32VFPV4") + set(SIMD_SOURCES sleefsimdsp.c) + else() + set(SIMD_SOURCES sleefsimdsp.c sleefsimddp.c) + endif() + + # Create a library + add_library(${OBJECT_${SIMD}} OBJECT ${SIMD_SOURCES} ${HEADER_${SIMD}}) + add_library(${OBJECTDET_${SIMD}} OBJECT ${SIMD_SOURCES} ${HEADER_${SIMD}}) + target_compile_definitions(${OBJECTDET_${SIMD}} PRIVATE DETERMINISTIC=1) + + if(COMPILER_SUPPORTS_BUILTIN_MATH) + target_compile_definitions(${OBJECT_${SIMD}} PRIVATE ENABLE_BUILTIN_MATH=1) + target_compile_definitions(${OBJECTDET_${SIMD}} PRIVATE ENABLE_BUILTIN_MATH=1) + endif() + + if(SLEEF_ENABLE_ALTDIV) + target_compile_definitions(${OBJECT_${SIMD}} PRIVATE SLEEF_ENABLE_ALTDIV=1) + target_compile_definitions(${OBJECTDET_${SIMD}} PRIVATE SLEEF_ENABLE_ALTDIV=1) + endif() + + if(SLEEF_ENABLE_ALTSQRT) + target_compile_definitions(${OBJECT_${SIMD}} PRIVATE SLEEF_ENABLE_ALTSQRT=1) + target_compile_definitions(${OBJECTDET_${SIMD}} PRIVATE SLEEF_ENABLE_ALTSQRT=1) + endif() + + if (INDEX_ALIAS EQUAL -1) + target_compile_definitions(${OBJECT_${SIMD}} PRIVATE + ENABLE_${SIMD}=1 + DORENAME=1 + ${COMMON_TARGET_DEFINITIONS} + ) + target_compile_definitions(${OBJECTDET_${SIMD}} PRIVATE + ENABLE_${SIMD}=1 + DORENAME=1 + ${COMMON_TARGET_DEFINITIONS} + ) + else() + add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/alias_${SIMD}_dp.h.tmp + COMMAND $ ${ALIAS_PARAMS_${SIMD}_DP} > ${CMAKE_CURRENT_BINARY_DIR}/alias_${SIMD}_dp.h.tmp + DEPENDS ${TARGET_MKALIAS} + ) + add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/alias_${SIMD}_sp.h.tmp + COMMAND $ ${ALIAS_PARAMS_${SIMD}_SP} > ${CMAKE_CURRENT_BINARY_DIR}/alias_${SIMD}_sp.h.tmp + DEPENDS ${TARGET_MKALIAS} + ) + sleef_concat_files( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/include/alias_${SIMDLC}.h + SOURCES ${CMAKE_CURRENT_BINARY_DIR}/alias_${SIMD}_sp.h.tmp ${CMAKE_CURRENT_BINARY_DIR}/alias_${SIMD}_dp.h.tmp + ) + add_custom_target(alias_${SIMDLC}.h_generated SOURCES ${CMAKE_CURRENT_BINARY_DIR}/include/alias_${SIMDLC}.h) + add_dependencies(${OBJECT_${SIMD}} alias_${SIMDLC}.h_generated) + add_dependencies(${OBJECTDET_${SIMD}} alias_${SIMDLC}.h_generated) + target_compile_definitions(${OBJECT_${SIMD}} PRIVATE + ENABLE_${SIMD}=1 + DORENAME=1 + ${COMMON_TARGET_DEFINITIONS} + ALIAS_NO_EXT_SUFFIX=\"alias_${SIMDLC}.h\" + ) + target_compile_definitions(${OBJECTDET_${SIMD}} PRIVATE + ENABLE_${SIMD}=1 + DORENAME=1 + ${COMMON_TARGET_DEFINITIONS} + ALIAS_NO_EXT_SUFFIX=\"alias_${SIMDLC}.h\" + ) + endif() + + # Enable Vector PCS for Advanced SIMD (if supported) + if(FORCE_AAVPCS AND ${SIMD} STREQUAL "ADVSIMD") + target_compile_definitions(${OBJECT_${SIMD}} PRIVATE + ENABLE_AAVPCS=1 + ) + endif() + + add_dependencies(${OBJECT_${SIMD}} rename${SIMD}.h_generated) + add_dependencies(${OBJECTDET_${SIMD}} rename${SIMD}.h_generated) + + set_target_properties(${OBJECT_${SIMD}} PROPERTIES + ${COMMON_TARGET_PROPERTIES} + ) + + set_target_properties(${OBJECTDET_${SIMD}} PROPERTIES + ${COMMON_TARGET_PROPERTIES} + ) + + target_compile_options(${OBJECT_${SIMD}} PRIVATE + ${FLAGS_ENABLE_${SIMD}}) + + target_compile_options(${OBJECTDET_${SIMD}} PRIVATE + ${FLAGS_ENABLE_${SIMD}}) + + target_sources(${TARGET_LIBSLEEF} PRIVATE $ $) + endif(COMPILER_SUPPORTS_${SIMD}) +endforeach() + +# + +if(SLEEF_BUILD_INLINE_HEADERS) + if(CMAKE_C_COMPILER_ID MATCHES "Intel") + message(FATAL_ERROR "SLEEF_BUILD_INLINE_HEADERS is not supported with Intel Compiler") + endif() + + file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/include/) + set(INLINE_HEADER_FILES_GENERATED "") + + if (SED_COMMAND) + foreach(SIMD ${SLEEF_SUPPORTED_LIBM_EXTENSIONS} CUDA) + if(COMPILER_SUPPORTS_${SIMD} OR ${SIMD} STREQUAL "CUDA") + string(TOLOWER ${SIMD} SIMDLC) + + if(CMAKE_CROSSCOMPILING AND CMAKE_C_COMPILER_ID MATCHES "Clang" AND CMAKE_C_COMPILER_TARGET AND NOT "${SIMD}" STREQUAL "CUDA" ) + set(FLAG_TARGET --target=${CMAKE_C_COMPILER_TARGET}) + endif() + + if ("${SIMD}" STREQUAL "CUDA") + set(TARGET_PP_FLAGS ${FLAG_DEFINE}SLEEF_ALWAYS_INLINE=__device__ + ${FLAG_DEFINE}SLEEF_INLINE=__device__ + ${FLAG_DEFINE}SLEEF_CONST=__device__ + ${FLAG_DEFINE}static=__device__) + set(INLINE_HEADER_ORG ${CMAKE_CURRENT_SOURCE_DIR}/sleefinline_cuda_header.h.org) + # Remove redundant __device__ + set(TARGET_REPLACEMENTS -e "s/__device__ __device__/__device__/g" -e "s/__device__ __device__/__device__/g") + set(TARGET_ADDSUFFIX_KEYWORDS double2 double3 float2) + else() + set(TARGET_ADDSUFFIX_KEYWORDS Sleef_rempitabdp Sleef_rempitabsp) + set(INLINE_HEADER_ORG ${CMAKE_CURRENT_SOURCE_DIR}/sleefinline_header.h.org) + endif() + + set(INLINE_HEADER_FILE ${PROJECT_BINARY_DIR}/include/sleefinline_${SIMDLC}.h) + add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/sleefsimddp${SIMD}.h.tmp + + # Preprocess sleefsimddp.c with SLEEF_GENHEADER defined, comments are preserved + COMMAND "${CMAKE_C_COMPILER}" ${FLAG_PREPROCESS} ${FLAG_PRESERVE_COMMENTS} # gcc -E -C + ${FLAG_TARGET} ${FLAGS_ENABLE_${SIMD}} # -msse2 + ${FLAG_INCLUDE}${PROJECT_SOURCE_DIR}/src/common ${FLAG_INCLUDE}${PROJECT_SOURCE_DIR}/src/arch # -I/sleef/src/common -I/sleef/src/arch + ${FLAG_INCLUDE}${CMAKE_CURRENT_BINARY_DIR}/include/ # -I/build/src/libm/include + ${FLAG_DEFINE}SLEEF_GENHEADER ${FLAG_DEFINE}ENABLE_${SIMD} ${FLAG_DEFINE}DORENAME # -DSLEEF_GENHEADER -DENABLE_SSE2 -DDORENAME + ${TARGET_PP_FLAGS} + ${CMAKE_CURRENT_SOURCE_DIR}/sleefsimddp.c > ${CMAKE_CURRENT_BINARY_DIR}/sleefsimddp${SIMD}.h.tmp # /sleef/src/libm/sleefsimddp.c > /build/libm/sleefsimddpSSE2.h.tmp + + # ${HEADER_${SIMD}} listed here as sleefsimddp.c includes it for renaming + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/sleefsimddp.c ${HEADER_${SIMD}} + ) + + add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/include/macroonly${SIMD}.h + + # Remove all lines except those begin with "//@", then remove "//@" + COMMAND ${SED_COMMAND} -e "/^\\/\\/@#.*$/!d" + -e "s/^\\/\\/@#/#/g" + ${CMAKE_CURRENT_BINARY_DIR}/sleefsimddp${SIMD}.h.tmp + > ${CMAKE_CURRENT_BINARY_DIR}/include/macroonly${SIMD}.h + + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/sleefsimddp${SIMD}.h.tmp + VERBATIM + ) + + add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/sleefsimdsp${SIMD}.h.tmp + + # Preprocess sleefsimdsp.c with SLEEF_GENHEADER defined. Include macroonly*.h instead of helper*.h. + COMMAND "${CMAKE_C_COMPILER}" ${FLAG_PREPROCESS} ${FLAG_PRESERVE_COMMENTS} # gcc -E -C + ${FLAG_TARGET} ${FLAGS_ENABLE_${SIMD}} # -msse2 + ${FLAG_INCLUDE}${PROJECT_SOURCE_DIR}/src/common ${FLAG_INCLUDE}${PROJECT_SOURCE_DIR}/src/arch # -I/sleef/src/common -I/sleef/src/arch + ${FLAG_INCLUDE}${CMAKE_CURRENT_BINARY_DIR}/include/ # -I/build/src/libm/include + ${FLAG_DEFINE}SLEEF_GENHEADER ${FLAG_DEFINE}ENABLE_${SIMD} ${FLAG_DEFINE}DORENAME # -DSLEEF_GENHEADER -DENABLE_SSE2 -DDORENAME + ${TARGET_PP_FLAGS} + ${CMAKE_CURRENT_SOURCE_DIR}/sleefsimdsp.c > ${CMAKE_CURRENT_BINARY_DIR}/sleefsimdsp${SIMD}.h.tmp # /sleef/src/libm/sleefsimdsp.c > /build/libm/sleefsimdspSSE2.h.tmp + + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/include/macroonly${SIMD}.h ${CMAKE_CURRENT_SOURCE_DIR}/sleefsimdsp.c + ) + + add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.c + + # Remove lines beginning with "#" so that the resulting file can be preprocessed again. + COMMAND ${CMAKE_COMMAND} -E cat ${CMAKE_CURRENT_BINARY_DIR}/sleefsimddp${SIMD}.h.tmp + ${CMAKE_CURRENT_BINARY_DIR}/sleefsimdsp${SIMD}.h.tmp + | ${SED_COMMAND} -e "s/^#.*//g" > ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.c + + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/sleefsimdsp${SIMD}.h.tmp ${CMAKE_CURRENT_BINARY_DIR}/sleefsimddp${SIMD}.h.tmp + VERBATIM + ) + + add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.tmp3 + + # Preprocess the intemediate file again to remove comments + COMMAND "${CMAKE_C_COMPILER}" ${FLAG_PREPROCESS} ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.c + # Remove lines beginning with "#" + | ${SED_COMMAND} -e "s/^#.*//g" + > ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.tmp3 + + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.c + VERBATIM + ) + + add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.tmp4 + + COMMAND ${CMAKE_COMMAND} -E cat + ${INLINE_HEADER_ORG} + ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.tmp3 + | ${SED_COMMAND} + # Embed version number into the header + -e "s/SLEEF_VERSION_SLEEF/${SLEEF_VERSION_MAJOR}.${SLEEF_VERSION_MINOR}.${SLEEF_VERSION_PATCH}/g" + -e "s/SLEEF_SIMD_SLEEF/${SIMD}/g" + # Substitute "SLEEFSHARP" at the beginning of line with "#" + -e "s/^SLEEFSHARP/#/g" + # Remove SLEEFXXX + -e "s/SLEEFXXX//g" + # Replace multiple empty lines with a single empty line (part 1) + -e "s/^[[:space:]]*$//g" + > ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.tmp4 + + DEPENDS ${INLINE_HEADER_ORG} ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.tmp3 + VERBATIM + ) + + add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.tmp5 + + # Replace multiple empty lines with a single empty line + # (part 2 - cannot occur in same command as part 1) + COMMAND ${SED_COMMAND} -e "/^$/N" -e "/^\\n$/D" ${TARGET_REPLACEMENTS} ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.tmp4 + > ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.tmp5 + + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.tmp4 + VERBATIM + ) + + add_custom_command( + OUTPUT ${INLINE_HEADER_FILE} + + COMMAND $ ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.tmp5 # addSuffix /build/src/libm/sleefSSE2.h.tmp5 + ${sleef_SOURCE_DIR}/src/common/keywords.txt "_${SIMDLC}_sleef" # keywords.txt "_sse2_sleef" + ${TARGET_ADDSUFFIX_KEYWORDS} + > ${PROJECT_BINARY_DIR}/include/sleefinline_${SIMDLC}.h # > /build/include/sleefinline_sse2.h + + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.tmp5 addSuffix + VERBATIM + ) + + list(APPEND INLINE_HEADER_FILES_GENERATED ${INLINE_HEADER_FILE}) + endif(COMPILER_SUPPORTS_${SIMD} OR ${SIMD} STREQUAL "CUDA") + endforeach() + + add_custom_target(${TARGET_INLINE_HEADERS}_util ALL + DEPENDS + ${INLINE_HEADER_FILES_GENERATED} + ) + + add_library("${TARGET_INLINE_HEADERS}" INTERFACE) + add_dependencies("${TARGET_INLINE_HEADERS}" "${TARGET_INLINE_HEADERS}_util") + target_include_directories( + "${TARGET_INLINE_HEADERS}" + INTERFACE + "$" + ) + + # CMake 3.4 can't have PUBLIC_HEADER property on INTERFACE libraries + install( + FILES ${INLINE_HEADER_FILES_GENERATED} + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" + COMPONENT sleef_Development + ) + + install( + TARGETS "${TARGET_INLINE_HEADERS}" + EXPORT sleefTargets + INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" + ) + endif(SED_COMMAND) +endif(SLEEF_BUILD_INLINE_HEADERS) + +# On some systems we need to explicitly link libsleef against libm to +# use some of the math functions used in the scalar code (for example +# sqrt). +if(LIBM AND NOT COMPILER_SUPPORTS_BUILTIN_MATH) + target_link_libraries(${TARGET_LIBSLEEF} ${LIBM}) +endif() + +target_sources(${TARGET_LIBSLEEF} PRIVATE $) + +# -------------------------------------------------------------------- + +# Target dispscalar.c + +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/dispscalar.c.body + COMMAND $ 1 1 double float int32_t purec purecfma x > ${CMAKE_CURRENT_BINARY_DIR}/dispscalar.c.body + DEPENDS ${TARGET_MKDISP} + ) + +sleef_concat_files( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/dispscalar.c + SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/dispscalar.c.org + ${CMAKE_CURRENT_BINARY_DIR}/dispscalar.c.body + ${CMAKE_CURRENT_SOURCE_DIR}/dispscalar_footer.c.org +) +add_custom_target(dispscalar.c_generated SOURCES ${CMAKE_CURRENT_BINARY_DIR}/dispscalar.c) + +# Target renamedspscalar.h + +add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/include/renamedspscalar.h + COMMAND $ - 1 1 > ${CMAKE_CURRENT_BINARY_DIR}/include/renamedspscalar.h + DEPENDS ${TARGET_MKRENAME} + ) +add_custom_target(renamedspscalar.h_generated SOURCES ${CMAKE_CURRENT_BINARY_DIR}/include/renamedspscalar.h) + +# Target dispscalar_obj + +add_library(dispscalar_obj OBJECT dispscalar.c) +set_target_properties(dispscalar_obj PROPERTIES ${COMMON_TARGET_PROPERTIES}) +target_compile_definitions(dispscalar_obj PRIVATE ${COMMON_TARGET_DEFINITIONS}) +target_include_directories(dispscalar_obj PRIVATE ${sleef_BINARY_DIR}/include) +add_dependencies(dispscalar_obj dispscalar.c_generated renamedspscalar.h_generated ${TARGET_HEADERS}) +target_sources(${TARGET_LIBSLEEF} PRIVATE $) + +# + +function(sleef_generate_disp_simd simd) + add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/disp${simd}.c.tmp + COMMAND $ "${ARGN}" > ${CMAKE_CURRENT_BINARY_DIR}/disp${simd}.c.tmp + DEPENDS ${TARGET_MKDISP} + COMMAND_EXPAND_LISTS + ) + sleef_concat_files(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/disp${simd}.c + SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/disp${simd}.c.org ${CMAKE_CURRENT_BINARY_DIR}/disp${simd}.c.tmp + ) + add_custom_target(disp${simd}.c_generated SOURCES ${CMAKE_CURRENT_BINARY_DIR}/disp${simd}.c) +endfunction() + +function(sleef_generate_rename_simd simd) + add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/include/renamed${simd}.h + COMMAND $ "${ARGN}" > ${CMAKE_CURRENT_BINARY_DIR}/include/renamed${simd}.h + DEPENDS ${TARGET_MKRENAME} + COMMAND_EXPAND_LISTS + ) + add_custom_target(renamed${simd}.h_generated SOURCES ${CMAKE_CURRENT_BINARY_DIR}/include/renamed${simd}.h) + endfunction() + +if (SLEEF_ARCH_X86) + # Target dispsse.c + sleef_generate_disp_simd(sse 2 4 __m128d __m128 __m128i sse2 sse4 avx2128) + + # Target renamedsp128.h + sleef_generate_rename_simd(sp128 - 2 4) + + # Target dispavx.c + sleef_generate_disp_simd(avx 4 8 __m256d __m256 __m128i avx fma4 avx2) + + # Target renamedsp256.h + sleef_generate_rename_simd(sp256 - 4 8) + + # Target dispsse_obj + if (COMPILER_SUPPORTS_FMA4) + set(DISPATCHER_DEFINITIONS ${DISPATCHER_DEFINITIONS} ENABLE_FMA4=1) + endif() + + if (COMPILER_SUPPORTS_AVX2) + set(DISPATCHER_DEFINITIONS ${DISPATCHER_DEFINITIONS} ENABLE_AVX2=1) + endif() + + if(COMPILER_SUPPORTS_SSE2) + add_library(dispsse_obj OBJECT dispsse.c) + target_compile_options(dispsse_obj PRIVATE ${FLAGS_ENABLE_SSE2}) + set_target_properties(dispsse_obj PROPERTIES ${COMMON_TARGET_PROPERTIES}) + target_compile_definitions(dispsse_obj PRIVATE ${COMMON_TARGET_DEFINITIONS} ${DISPATCHER_DEFINITIONS}) + target_include_directories(dispsse_obj PRIVATE ${sleef_BINARY_DIR}/include) + add_dependencies(dispsse_obj dispsse.c_generated renamedsp128.h_generated ${TARGET_HEADERS}) + target_sources(${TARGET_LIBSLEEF} PRIVATE $) + endif() + + # Target dispavx_obj + + if(COMPILER_SUPPORTS_AVX) + add_library(dispavx_obj OBJECT dispavx.c) + target_compile_options(dispavx_obj PRIVATE ${FLAGS_ENABLE_AVX}) + set_target_properties(dispavx_obj PROPERTIES ${COMMON_TARGET_PROPERTIES}) + target_compile_definitions(dispavx_obj PRIVATE ${COMMON_TARGET_DEFINITIONS} ${DISPATCHER_DEFINITIONS}) + target_include_directories(dispavx_obj PRIVATE ${sleef_BINARY_DIR}/include) + add_dependencies(dispavx_obj dispavx.c_generated renamedsp256.h_generated ${TARGET_HEADERS}) + target_sources(${TARGET_LIBSLEEF} PRIVATE $) + endif() +endif(SLEEF_ARCH_X86) + +if (SLEEF_ARCH_PPC64) + # Target disppower_128.c + sleef_generate_disp_simd(power_128 2 4 SLEEF_VECTOR_DOUBLE SLEEF_VECTOR_FLOAT SLEEF_VECTOR_INT vsx vsx3 x) + + # Target renamedsp128.h + sleef_generate_rename_simd(sp128 - 2 4) + + # Target disppower_128_obj + add_library(disppower_128_obj OBJECT disppower_128.c) + target_compile_options(disppower_128_obj PRIVATE ${FLAGS_ENABLE_VSX}) + if(COMPILER_SUPPORTS_VSX3) + set(DISPATCHER_DEFINITIONS ENABLE_VSX3=1) + endif() + set_target_properties(disppower_128_obj PROPERTIES ${COMMON_TARGET_PROPERTIES}) + target_compile_definitions(disppower_128_obj PRIVATE ${COMMON_TARGET_DEFINITIONS} ${DISPATCHER_DEFINITIONS}) + target_include_directories(disppower_128_obj PRIVATE ${CMAKE_BINARY_DIR}/include) + add_dependencies(disppower_128_obj disppower_128.c_generated renamedsp128.h_generated ${TARGET_HEADERS}) + target_sources(${TARGET_LIBSLEEF} PRIVATE $) + + if(COMPILER_SUPPORTS_VSX3) + add_library(tryvsx3_obj OBJECT tryvsx3.c) + target_compile_options(tryvsx3_obj PRIVATE ${FLAGS_ENABLE_VSX3}) + set_target_properties(tryvsx3_obj PROPERTIES ${COMMON_TARGET_PROPERTIES}) + target_sources(${TARGET_LIBSLEEF} PRIVATE $) + endif() +endif(SLEEF_ARCH_PPC64) + +if (SLEEF_ARCH_S390X) + # Target disps390x_128.c + sleef_generate_disp_simd(s390x_128 2 4 SLEEF_VECTOR_DOUBLE SLEEF_VECTOR_FLOAT SLEEF_VECTOR_INT vxe vxe2 x) + + # Target renamedsp128.h + sleef_generate_rename_simd(sp128 - 2 4) + + # Target disps390x_128_obj + add_library(disps390x_128_obj OBJECT disps390x_128.c) + target_compile_options(disps390x_128_obj PRIVATE ${FLAGS_ENABLE_VXE}) + if(COMPILER_SUPPORTS_VXE2) + set(DISPATCHER_DEFINITIONS ENABLE_VXE2=1) + endif() + set_target_properties(disps390x_128_obj PROPERTIES ${COMMON_TARGET_PROPERTIES}) + target_compile_definitions(disps390x_128_obj PRIVATE ${COMMON_TARGET_DEFINITIONS} ${DISPATCHER_DEFINITIONS}) + target_include_directories(disps390x_128_obj PRIVATE ${CMAKE_BINARY_DIR}/include) + add_dependencies(disps390x_128_obj disps390x_128.c_generated renamedsp128.h_generated ${TARGET_HEADERS}) + target_sources(${TARGET_LIBSLEEF} PRIVATE $) + + if(COMPILER_SUPPORTS_VXE2) + add_library(tryvxe2_obj OBJECT tryvxe2.c) + target_compile_options(tryvxe2_obj PRIVATE ${FLAGS_ENABLE_VXE2}) + set_target_properties(tryvxe2_obj PROPERTIES ${COMMON_TARGET_PROPERTIES}) + target_sources(${TARGET_LIBSLEEF} PRIVATE $) + endif() +endif(SLEEF_ARCH_S390X) + +# -------------------------------------------------------------------- +# TARGET_LIBSLEEFGNUABI +# Compile SIMD versions for GNU Abi +# -------------------------------------------------------------------- +# Build gnuabi version from just simd object files +if(ENABLE_GNUABI) + set(TARGET_LIBSLEEFGNUABI_OBJECTS "") + foreach(SIMD ${SLEEF_SUPPORTED_GNUABI_EXTENSIONS}) + if(COMPILER_SUPPORTS_${SIMD}) + # Need lowercase string for rename header + string(TOLOWER ${SIMD} vecarch) + + foreach(T dp sp) + add_library(${OBJECT_${SIMD}_${T}_GNUABI} OBJECT sleefsimd${T}.c ${HEADER_${SIMD}_GNUABI}) + target_compile_definitions(${OBJECT_${SIMD}_${T}_GNUABI} PRIVATE + ENABLE_${SIMD}=1 + DORENAME=1 + ENABLE_GNUABI=1 + ) + + if(FORCE_AAVPCS AND ${SIMD} STREQUAL "ADVSIMD") + target_compile_definitions(${OBJECT_${SIMD}_${T}_GNUABI} PRIVATE + ENABLE_AAVPCS=1 + ) + endif() + + if(SLEEF_ENABLE_ALTDIV) + target_compile_definitions(${OBJECT_${SIMD}_${T}_GNUABI} PRIVATE SLEEF_ENABLE_ALTDIV=1) + endif() + + if(SLEEF_ENABLE_ALTSQRT) + target_compile_definitions(${OBJECT_${SIMD}_${T}_GNUABI} PRIVATE SLEEF_ENABLE_ALTSQRT=1) + endif() + + set_target_properties(${OBJECT_${SIMD}_${T}_GNUABI} PROPERTIES + ${COMMON_TARGET_PROPERTIES} + ) + + target_compile_options(${OBJECT_${SIMD}_${T}_GNUABI} PRIVATE ${FLAGS_ENABLE_${SIMD}}) + if (COMPILER_SUPPORTS_WEAK_ALIASES) + target_compile_options(${OBJECT_${SIMD}_${T}_GNUABI} PRIVATE -DENABLE_GNUABI=1) + endif(COMPILER_SUPPORTS_WEAK_ALIASES) + list(APPEND TARGET_LIBSLEEFGNUABI_OBJECTS $) + + if(MKMASKED_PARAMS_GNUABI_${SIMD}_${T}) + target_compile_definitions(${OBJECT_${SIMD}_${T}_GNUABI} PRIVATE + HEADER_MASKED=\"masked_${vecarch}_${T}_gnuabi.h\") + add_dependencies(${OBJECT_${SIMD}_${T}_GNUABI} masked${SIMD}_generated) + endif() + endforeach() + endif(COMPILER_SUPPORTS_${SIMD}) + endforeach() + + # Create library + add_library(${TARGET_LIBSLEEFGNUABI} ${TARGET_LIBSLEEFGNUABI_OBJECTS} rempitab.c) + + # Library properties + set_target_properties(${TARGET_LIBSLEEFGNUABI} PROPERTIES + VERSION ${SLEEF_VERSION_MAJOR}.${SLEEF_VERSION_MINOR} + SOVERSION ${SLEEF_SOVERSION} + POSITION_INDEPENDENT_CODE ON # -fPIC + C_STANDARD 99 # -std=gnu99 + LINKER_LANGUAGE C + ) + +# On some systems we need to explicitly link libsleefgnuabi against +# libm to use some of the math functions used in the scalar code (for +# example sqrt). +if(LIBM AND NOT COMPILER_SUPPORTS_BUILTIN_MATH) + target_link_libraries(${TARGET_LIBSLEEFGNUABI} ${LIBM}) +endif() +endif(ENABLE_GNUABI) + +# -------------------------------------------------------------------- +# TARGET_LLVM_BITCODE +# Generate LLVM bitcode +# -------------------------------------------------------------------- +if(CLANG_EXE_PATH AND SLEEF_ENABLE_LLVM_BITCODE) + set(SLEEP_LLVM_BITCODE_INCLUDES "") + get_property(SLEEP_LLVM_BITCODE_INCLUDES_LIST DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES) + foreach(INCLUDE_DIRECTORY ${SLEEP_LLVM_BITCODE_INCLUDES_LIST}) + set(SLEEP_LLVM_BITCODE_INCLUDES "${SLEEP_LLVM_BITCODE_INCLUDES} -I ${INCLUDE_DIRECTORY}") + endforeach() + + separate_arguments(SLEEP_LLVM_BITCODE_INCLUDES_CLANG WINDOWS_COMMAND "${SLEEP_LLVM_BITCODE_INCLUDES}") + set(SLEEF_CLANG_LLVM_BITCODE_OPTIONS -O3 -S -emit-llvm -D NDEBUG -D DORENAME=1) + set(LLVM_BITCODE_OUTPUTS "") + + # Generate LLVM bitcode for regular SLEEF + foreach(STANDARD_SOURCE ${STANDARD_SOURCES}) + get_filename_component(SRC_WITHOUT_EXT ${STANDARD_SOURCE} NAME_WE) + set(LLVM_BITCODE_INPUT ${CMAKE_CURRENT_SOURCE_DIR}/${SRC_WITHOUT_EXT}.c) + set(LLVM_BITCODE_OUTPUT ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${SRC_WITHOUT_EXT}.ll) + add_custom_command(OUTPUT ${LLVM_BITCODE_OUTPUT} + COMMAND ${CLANG_EXE_PATH} ${SLEEF_CLANG_LLVM_BITCODE_OPTIONS} -o ${LLVM_BITCODE_OUTPUT} ${LLVM_BITCODE_INPUT} ${SLEEP_LLVM_BITCODE_INCLUDES_CLANG} + DEPENDS + ${LLVM_BITCODE_INPUT} + ) + list(APPEND LLVM_BITCODE_OUTPUTS ${LLVM_BITCODE_OUTPUT}) + endforeach() + + # Generate LLVM bitcode for SIMD SLEEF + foreach(SIMD ${SLEEF_SUPPORTED_LIBM_EXTENSIONS}) + if (${SIMD} STREQUAL "NEON32" OR ${SIMD} STREQUAL "NEON32VFPV4") + set(SIMD_SOURCES sleefsimdsp.c) + else() + set(SIMD_SOURCES sleefsimdsp.c sleefsimddp.c) + endif() + + if(COMPILER_SUPPORTS_${SIMD}) + foreach(SIMD_SOURCE ${SIMD_SOURCES}) + get_filename_component(SIMD_SOURCE_WITHOUT_EXT ${SIMD_SOURCE} NAME_WE) + set(LLVM_BITCODE_INPUT ${CMAKE_CURRENT_SOURCE_DIR}/${SIMD_SOURCE}) + set(LLVM_BITCODE_OUTPUT ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${SIMD_SOURCE_WITHOUT_EXT}_${SIMD}.ll) + add_custom_command(OUTPUT ${LLVM_BITCODE_OUTPUT} + COMMAND ${CLANG_EXE_PATH} ${CLANG_FLAGS_ENABLE_${SIMD}} ${SLEEF_CLANG_LLVM_BITCODE_OPTIONS} -D ENABLE_${SIMD}=1 -o ${LLVM_BITCODE_OUTPUT} ${LLVM_BITCODE_INPUT} ${SLEEP_LLVM_BITCODE_INCLUDES_CLANG} + DEPENDS + ${LLVM_BITCODE_INPUT} + ) + list(APPEND LLVM_BITCODE_OUTPUTS ${LLVM_BITCODE_OUTPUT}) + endforeach() + endif() + endforeach() + + file(MAKE_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) + add_custom_target(${TARGET_LLVM_BITCODE} ALL + DEPENDS + ${LLVM_BITCODE_OUTPUTS} + ) + add_dependencies(${TARGET_LLVM_BITCODE} ${TARGET_HEADERS}) + + install( + FILES ${LLVM_BITCODE_OUTPUTS} + DESTINATION "${CMAKE_INSTALL_LIBDIR}" + COMPONENT sleef_Development + ) +endif() + +# -------------------------------------------------------------------- +# TARGET_LIBSLEEFSCALAR +# -------------------------------------------------------------------- +# Build scalar-only library from sleefdp.c and sleefsp.c +if(SLEEF_BUILD_SCALAR_LIB) + add_library(sleefscalar sleefdp.c sleefsp.c rempitab.c) + add_dependencies(sleefscalar ${TARGET_HEADERS}) + set_target_properties(sleefscalar PROPERTIES + VERSION ${SLEEF_VERSION} + SOVERSION ${SLEEF_SOVERSION} + PUBLIC_HEADER ${SLEEF_INCLUDE_HEADER} + ${COMMON_TARGET_PROPERTIES} + ) + + target_compile_definitions(sleefscalar + PRIVATE DORENAME=1 ${COMMON_TARGET_DEFINITIONS} + ) + + if(COMPILER_SUPPORTS_BUILTIN_MATH) + target_compile_definitions(sleefscalar PRIVATE ENABLE_BUILTIN_MATH=1) + endif() + + install( + TARGETS sleefscalar + EXPORT sleefTargets + LIBRARY # + DESTINATION "${CMAKE_INSTALL_LIBDIR}" + COMPONENT sleef_Runtime + NAMELINK_COMPONENT sleef_Development + ARCHIVE # + DESTINATION "${CMAKE_INSTALL_LIBDIR}" + COMPONENT sleef_Development + RUNTIME # + DESTINATION "${CMAKE_INSTALL_BINDIR}" + COMPONENT sleef_Runtime + ) +endif() + +# -------------------------------------------------------------------- +# Install +# -------------------------------------------------------------------- +# Install libsleef and sleef.h +install( + TARGETS ${TARGET_LIBSLEEF} + EXPORT sleefTargets + PUBLIC_HEADER # + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" + COMPONENT sleef_Development + LIBRARY # + DESTINATION "${CMAKE_INSTALL_LIBDIR}" + COMPONENT sleef_Runtime + NAMELINK_COMPONENT sleef_Development + ARCHIVE # + DESTINATION "${CMAKE_INSTALL_LIBDIR}" + COMPONENT sleef_Development + RUNTIME # + DESTINATION "${CMAKE_INSTALL_BINDIR}" + COMPONENT sleef_Runtime + INCLUDES # + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" +) +configure_file("sleef.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/sleef.pc" @ONLY) +install( + FILES "${CMAKE_CURRENT_BINARY_DIR}/sleef.pc" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig" + COMPONENT sleef_Development +) + +if(ENABLE_GNUABI) + install( + TARGETS ${TARGET_LIBSLEEFGNUABI} + EXPORT sleefTargets + LIBRARY # + DESTINATION "${CMAKE_INSTALL_LIBDIR}" + COMPONENT sleef_Runtime + NAMELINK_COMPONENT sleef_Development + ARCHIVE # + DESTINATION "${CMAKE_INSTALL_LIBDIR}" + COMPONENT sleef_Development + RUNTIME # + DESTINATION "${CMAKE_INSTALL_BINDIR}" + COMPONENT sleef_Runtime + ) +endif() diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/dispatcher.h b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/dispatcher.h new file mode 100644 index 00000000000..6a81892e26e --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/dispatcher.h @@ -0,0 +1,172 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#if (defined (__GNUC__) || defined (__clang__) || defined(__INTEL_COMPILER)) && !defined(_MSC_VER) +#define CONST __attribute__((const)) +#else +#define CONST +#endif + +#if defined(_MSC_VER) || defined(__MINGW32__) || defined(__MINGW64__) +static jmp_buf sigjmp; +#define SETJMP(x) setjmp(x) +#define LONGJMP longjmp +#else +static sigjmp_buf sigjmp; +#define SETJMP(x) sigsetjmp(x, 1) +#define LONGJMP siglongjmp +#endif + +static void sighandler(int signum) { + LONGJMP(sigjmp, 1); +} + +static int cpuSupportsExt(void (*tryExt)()) { + static int cache = -1; + if (cache != -1) return cache; + + void (*org); + org = signal(SIGILL, sighandler); + + if (SETJMP(sigjmp) == 0) { + (*tryExt)(); + cache = 1; + } else { + cache = 0; + } + + signal(SIGILL, org); + return cache; +} + +#ifndef VECALIAS_vf_vf +#define VECALIAS_vf_vf(fptype, funcNameS, funcName, veclen) +#define VECALIAS_vf_vf_vf(fptype, funcNameS, funcName, veclen) +#define VECALIAS_vf_vf_vf_vf(fptype, funcNameS, funcName, veclen) +#endif + +/* + * DISPATCH_R_X, DISPATCH_R_X_Y and DISPATCH_R_X_Y_Z are the macro for + * defining dispatchers. R, X, Y and Z represent the data types of + * return value, first argument, second argument and third argument, + * respectively. vf, vi, i and p correspond to vector FP, vector + * integer, scalar integer and scalar pointer types, respectively. + * + * The arguments for the macros are as follows: + * fptype : FP type name + * veclen : Vector length + * funcnameS : First scalar function name + * funcnameS2 : Second scalar function name + * funcname : Fundamental function name + * pfn : Name of pointer of the function to the dispatcher + * dfn : Name of the dispatcher function + * funcExt0 : Name of the function for vector extension 0 + * funcExt1 : Name of the function for vector extension 1 + * funcExt2 : Name of the function for vector extension 2 + */ + +#define DISPATCH_vf_vf(fptype, veclen, funcNameS, funcNameS2, funcName, pfn, dfn, funcExt0, funcExt1, funcExt2) \ + static CONST VECTOR_CC fptype (*pfn)(fptype arg0); \ + static CONST VECTOR_CC fptype dfn(fptype arg0) { \ + fptype CONST VECTOR_CC (*p)(fptype arg0) = funcExt0; \ + SUBST_IF_EXT1(funcExt1); \ + SUBST_IF_EXT2(funcExt2); \ + pfn = p; \ + return (*pfn)(arg0); \ + } \ + static CONST VECTOR_CC fptype (*pfn)(fptype arg0) = dfn; \ + EXPORT CONST VECTOR_CC fptype funcName(fptype arg0) { return (*pfn)(arg0); } \ + VECALIAS_vf_vf(fptype, funcNameS, funcName, veclen) \ + VECALIAS_vf_vf(fptype, funcNameS2, funcName, veclen) + +#define DISPATCH_vf_vf_vf(fptype, veclen, funcNameS, funcNameS2, funcName, pfn, dfn, funcExt0, funcExt1, funcExt2) \ + static CONST VECTOR_CC fptype (*pfn)(fptype arg0, fptype arg1); \ + static CONST VECTOR_CC fptype dfn(fptype arg0, fptype arg1) { \ + fptype CONST VECTOR_CC (*p)(fptype arg0, fptype arg1) = funcExt0; \ + SUBST_IF_EXT1(funcExt1); \ + SUBST_IF_EXT2(funcExt2); \ + pfn = p; \ + return (*pfn)(arg0, arg1); \ + } \ + static CONST VECTOR_CC fptype (*pfn)(fptype arg0, fptype arg1) = dfn; \ + EXPORT CONST VECTOR_CC fptype funcName(fptype arg0, fptype arg1) { return (*pfn)(arg0, arg1); } \ + VECALIAS_vf_vf_vf(fptype, funcNameS, funcName, veclen) \ + VECALIAS_vf_vf_vf(fptype, funcNameS2, funcName, veclen) + +#define DISPATCH_vf2_vf(fptype, fptype2, veclen, funcNameS, funcNameS2, funcName, pfn, dfn, funcExt0, funcExt1, funcExt2) \ + static CONST VECTOR_CC fptype2 (*pfn)(fptype arg0); \ + static CONST VECTOR_CC fptype2 dfn(fptype arg0) { \ + fptype2 CONST VECTOR_CC (*p)(fptype arg0) = funcExt0; \ + SUBST_IF_EXT1(funcExt1); \ + SUBST_IF_EXT2(funcExt2); \ + pfn = p; \ + return (*pfn)(arg0); \ + } \ + static CONST VECTOR_CC fptype2 (*pfn)(fptype arg0) = dfn; \ + EXPORT CONST VECTOR_CC fptype2 funcName(fptype arg0) { return (*pfn)(arg0); } + +#define DISPATCH_vf_vf_vi(fptype, itype, veclen, funcNameS, funcNameS2, funcName, pfn, dfn, funcExt0, funcExt1, funcExt2) \ + static CONST VECTOR_CC fptype (*pfn)(fptype arg0, itype arg1); \ + static CONST VECTOR_CC fptype dfn(fptype arg0, itype arg1) { \ + fptype CONST VECTOR_CC (*p)(fptype arg0, itype arg1) = funcExt0; \ + SUBST_IF_EXT1(funcExt1); \ + SUBST_IF_EXT2(funcExt2); \ + pfn = p; \ + return (*pfn)(arg0, arg1); \ + } \ + static CONST VECTOR_CC fptype (*pfn)(fptype arg0, itype arg1) = dfn; \ + EXPORT CONST VECTOR_CC fptype funcName(fptype arg0, itype arg1) { return (*pfn)(arg0, arg1); } + +#define DISPATCH_vi_vf(fptype, itype, veclen, funcNameS, funcNameS2, funcName, pfn, dfn, funcExt0, funcExt1, funcExt2) \ + static CONST VECTOR_CC itype (*pfn)(fptype arg0); \ + static CONST VECTOR_CC itype dfn(fptype arg0) { \ + itype CONST VECTOR_CC (*p)(fptype arg0) = funcExt0; \ + SUBST_IF_EXT1(funcExt1); \ + SUBST_IF_EXT2(funcExt2); \ + pfn = p; \ + return (*pfn)(arg0); \ + } \ + static CONST VECTOR_CC itype (*pfn)(fptype arg0) = dfn; \ + EXPORT CONST VECTOR_CC itype funcName(fptype arg0) { return (*pfn)(arg0); } + +#define DISPATCH_vf_vf_vf_vf(fptype, veclen, funcNameS, funcNameS2, funcName, pfn, dfn, funcExt0, funcExt1, funcExt2) \ + static CONST VECTOR_CC fptype (*pfn)(fptype arg0, fptype arg1, fptype arg2); \ + static CONST VECTOR_CC fptype dfn(fptype arg0, fptype arg1, fptype arg2) { \ + fptype CONST VECTOR_CC (*p)(fptype arg0, fptype arg1, fptype arg2) = funcExt0; \ + SUBST_IF_EXT1(funcExt1); \ + SUBST_IF_EXT2(funcExt2); \ + pfn = p; \ + return (*pfn)(arg0, arg1, arg2); \ + } \ + static CONST VECTOR_CC fptype (*pfn)(fptype arg0, fptype arg1, fptype arg2) = dfn; \ + EXPORT CONST VECTOR_CC fptype funcName(fptype arg0, fptype arg1, fptype arg2) { return (*pfn)(arg0, arg1, arg2); } \ + VECALIAS_vf_vf_vf_vf(fptype, funcNameS, funcName, veclen) \ + VECALIAS_vf_vf_vf_vf(fptype, funcNameS2, funcName, veclen) + +#define DISPATCH_i_i(veclen, funcNameS, funcNameS2, funcName, pfn, dfn, funcExt0, funcExt1, funcExt2) \ + static CONST int (*pfn)(int arg0); \ + static CONST int dfn(int arg0) { \ + int CONST (*p)(int) = funcExt0; \ + SUBST_IF_EXT1(funcExt1); \ + SUBST_IF_EXT2(funcExt2); \ + pfn = p; \ + return (*pfn)(arg0); \ + } \ + static CONST int (*pfn)(int arg0) = dfn; \ + EXPORT CONST int funcName(int arg0) { return (*pfn)(arg0); } + +#define DISPATCH_p_i(veclen, funcNameS, funcNameS2, funcName, pfn, dfn, funcExt0, funcExt1, funcExt2) \ + static CONST void *(*pfn)(int arg0); \ + static CONST void *dfn(int arg0) { \ + CONST void *(*p)(int) = funcExt0; \ + SUBST_IF_EXT1(funcExt1); \ + SUBST_IF_EXT2(funcExt2); \ + pfn = p; \ + return (*pfn)(arg0); \ + } \ + static CONST void *(*pfn)(int arg0) = dfn; \ + EXPORT CONST void *funcName(int arg0) { return (*pfn)(arg0); } + +// diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/dispavx.c.org b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/dispavx.c.org new file mode 100644 index 00000000000..30dda0c9f19 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/dispavx.c.org @@ -0,0 +1,72 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include + +#include "misc.h" + +#define SLEEF_IMPORT_IS_EXPORT +#include "sleef.h" + +static int cpuSupportsAVX2() { + static int ret = -1; + if (ret == -1) { + int32_t reg[4]; + Sleef_x86CpuID(reg, 7, 0); + ret = (reg[1] & (1 << 5)) != 0; + } + return ret; +} + +static int cpuSupportsFMA() { + static int ret = -1; + if (ret == -1) { + int32_t reg[4]; + Sleef_x86CpuID(reg, 1, 0); + ret = (reg[2] & (1 << 12)) != 0; + } + return ret; +} + +static int cpuSupportsFMA4() { + static int ret = -1; + if (ret == -1) { + int32_t reg[4]; + Sleef_x86CpuID(reg, 0x80000001, 0); + ret = (reg[2] & (1 << 16)) != 0; + } + return ret; +} + +#ifdef ENABLE_FMA4 +#define SUBST_IF_EXT1(funcfma4) if (cpuSupportsFMA4()) p = funcfma4; +#else +#define SUBST_IF_EXT1(funcfma4) +#endif + +#ifdef ENABLE_AVX2 +#define SUBST_IF_EXT2(funcavx2) if (cpuSupportsAVX2() && cpuSupportsFMA()) p = funcavx2; +#else +#define SUBST_IF_EXT2(funcavx2) +#endif + +#ifdef ENABLE_ALIAS +#define VECALIAS_vf_vf(fptype, funcNameS, funcName, veclen) \ + EXPORT CONST VECTOR_CC fptype _ZGVcN ## veclen ## v_ ## funcNameS(fptype) __attribute__((alias(stringify(funcName)))); \ + EXPORT CONST VECTOR_CC fptype _ZGVdN ## veclen ## v_ ## funcNameS(fptype) __attribute__((alias(stringify(funcName)))); +#define VECALIAS_vf_vf_vf(fptype, funcNameS, funcName, veclen) \ + EXPORT CONST VECTOR_CC fptype _ZGVcN ## veclen ## vv_ ## funcNameS(fptype, fptype) __attribute__((alias(stringify(funcName)))); \ + EXPORT CONST VECTOR_CC fptype _ZGVdN ## veclen ## vv_ ## funcNameS(fptype, fptype) __attribute__((alias(stringify(funcName)))); +#define VECALIAS_vf_vf_vf_vf(fptype, funcNameS, funcName, veclen) \ + EXPORT CONST VECTOR_CC fptype _ZGVcN ## veclen ## vvv_ ## funcNameS(fptype, fptype, fptype) __attribute__((alias(stringify(funcName)))); \ + EXPORT CONST VECTOR_CC fptype _ZGVdN ## veclen ## vvv_ ## funcNameS(fptype, fptype, fptype) __attribute__((alias(stringify(funcName)))); +#endif + +#include "dispatcher.h" + +// diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/disppower_128.c.org b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/disppower_128.c.org new file mode 100644 index 00000000000..334b2b88eef --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/disppower_128.c.org @@ -0,0 +1,30 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include + +#include "misc.h" + +#define SLEEF_IMPORT_IS_EXPORT +#include "sleef.h" + +#include "dispatcher.h" + +typedef __vector double vector_double; +typedef __vector float vector_float; + +#ifdef ENABLE_VSX3 +void sleef_tryVSX3(); +#define SUBST_IF_EXT1(funcvsx3) if (cpuSupportsExt(sleef_tryVSX3)) p = funcvsx3; +#else +#define SUBST_IF_EXT1(funcvsx3) +#endif + +#define SUBST_IF_EXT2(funcExt2) + +// diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/disps390x_128.c.org b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/disps390x_128.c.org new file mode 100644 index 00000000000..ae912145abb --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/disps390x_128.c.org @@ -0,0 +1,27 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include + +#include "misc.h" + +#define SLEEF_IMPORT_IS_EXPORT +#include "sleef.h" + +#include "dispatcher.h" + +#ifdef ENABLE_VXE2 +void sleef_tryVXE2(); +#define SUBST_IF_EXT1(funcvxe2) if (cpuSupportsExt(sleef_tryVXE2)) p = funcvxe2; +#else +#define SUBST_IF_EXT1(funcvxe2) +#endif + +#define SUBST_IF_EXT2(funcExt2) + +// diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/dispscalar.c.org b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/dispscalar.c.org new file mode 100644 index 00000000000..a18f030ad7d --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/dispscalar.c.org @@ -0,0 +1,24 @@ +// Copyright Naoki Shibata and contributors 2010 - 2023. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include + +#include "misc.h" + +#define SLEEF_IMPORT_IS_EXPORT +#include "sleef.h" + +#include "dispatcher.h" + +NOEXPORT double sleef_cpuid_SCALFMA; +static void tryFMA() { sleef_cpuid_SCALFMA = Sleef_sind1_u10purecfma(sleef_cpuid_SCALFMA); } + +#define SUBST_IF_EXT1(funcExt1) if (cpuSupportsExt(tryFMA)) p = funcExt1; +#define SUBST_IF_EXT2(funcExt2) + +// diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/dispscalar_footer.c.org b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/dispscalar_footer.c.org new file mode 100644 index 00000000000..5eb3daf092a --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/dispscalar_footer.c.org @@ -0,0 +1,183 @@ + +// + +#ifdef ENABLE_ALIAS +#define DALIAS_d_d(DFUNC, SFUNC) EXPORT CONST double DFUNC(double) __attribute__((alias( stringify( SFUNC ) ))); +#define DALIAS_d2_d(DFUNC, SFUNC) EXPORT CONST Sleef_double2 DFUNC(double) __attribute__((alias( stringify( SFUNC ) ))); +#define DALIAS_i_d(DFUNC, SFUNC) EXPORT CONST int DFUNC(double) __attribute__((alias( stringify( SFUNC ) ))); +#define DALIAS_d_d_d(DFUNC, SFUNC) EXPORT CONST double DFUNC(double, double) __attribute__((alias( stringify( SFUNC ) ))); +#define DALIAS_d_d_d_d(DFUNC, SFUNC) EXPORT CONST double DFUNC(double, double, double) __attribute__((alias( stringify( SFUNC ) ))); +#define DALIAS_d_d_i(DFUNC, SFUNC) EXPORT CONST double DFUNC(double, int) __attribute__((alias( stringify( SFUNC ) ))); +#define DALIAS_f_f(DFUNC, SFUNC) EXPORT CONST float DFUNC(float) __attribute__((alias( stringify( SFUNC ) ))); +#define DALIAS_f2_f(DFUNC, SFUNC) EXPORT CONST Sleef_float2 DFUNC(float) __attribute__((alias( stringify( SFUNC ) ))); +#define DALIAS_i_f(DFUNC, SFUNC) EXPORT CONST int DFUNC(float) __attribute__((alias( stringify( SFUNC ) ))); +#define DALIAS_f_f_f(DFUNC, SFUNC) EXPORT CONST float DFUNC(float, float) __attribute__((alias( stringify( SFUNC ) ))); +#define DALIAS_f_f_f_f(DFUNC, SFUNC) EXPORT CONST float DFUNC(float, float, float) __attribute__((alias( stringify( SFUNC ) ))); +#define DALIAS_f_f_i(DFUNC, SFUNC) EXPORT CONST float DFUNC(float, int) __attribute__((alias( stringify( SFUNC ) ))); +#else +#define DALIAS_d_d(DFUNC, SFUNC) EXPORT CONST double DFUNC(double d) { return SFUNC (d); } +#define DALIAS_d2_d(DFUNC, SFUNC) EXPORT CONST Sleef_double2 DFUNC(double d) { return SFUNC (d); } +#define DALIAS_i_d(DFUNC, SFUNC) EXPORT CONST int DFUNC(double d) { return SFUNC (d); } +#define DALIAS_d_d_d(DFUNC, SFUNC) EXPORT CONST double DFUNC(double x, double y) { return SFUNC (x, y); } +#define DALIAS_d_d_d_d(DFUNC, SFUNC) EXPORT CONST double DFUNC(double x, double y, double z) { return SFUNC (x, y, z); } +#define DALIAS_d_d_i(DFUNC, SFUNC) EXPORT CONST double DFUNC(double x, int i) { return SFUNC (x, i); } +#define DALIAS_f_f(DFUNC, SFUNC) EXPORT CONST float DFUNC(float d) { return SFUNC (d); } +#define DALIAS_f2_f(DFUNC, SFUNC) EXPORT CONST Sleef_float2 DFUNC(float d) { return SFUNC (d); } +#define DALIAS_i_f(DFUNC, SFUNC) EXPORT CONST int DFUNC(float d) { return SFUNC (d); } +#define DALIAS_f_f_f(DFUNC, SFUNC) EXPORT CONST float DFUNC(float x, float y) { return SFUNC (x, y); } +#define DALIAS_f_f_f_f(DFUNC, SFUNC) EXPORT CONST float DFUNC(float x, float y, float z) { return SFUNC (x, y, z); } +#define DALIAS_f_f_i(DFUNC, SFUNC) EXPORT CONST float DFUNC(float x, int i) { return SFUNC (x, i); } +#endif + +DALIAS_d_d(Sleef_sin_u10, Sleef_sind1_u10) +DALIAS_d_d(Sleef_cos_u10, Sleef_cosd1_u10) +DALIAS_d_d(Sleef_tan_u10, Sleef_tand1_u10) +DALIAS_d_d(Sleef_sin_u35, Sleef_sind1_u35) +DALIAS_d_d(Sleef_cos_u35, Sleef_cosd1_u35) +DALIAS_d_d(Sleef_tan_u35, Sleef_tand1_u35) +DALIAS_d_d(Sleef_asin_u10, Sleef_asind1_u10) +DALIAS_d_d(Sleef_acos_u10, Sleef_acosd1_u10) +DALIAS_d_d(Sleef_atan_u10, Sleef_atand1_u10) +DALIAS_d_d(Sleef_asin_u35, Sleef_asind1_u35) +DALIAS_d_d(Sleef_acos_u35, Sleef_acosd1_u35) +DALIAS_d_d(Sleef_atan_u35, Sleef_atand1_u35) +DALIAS_d_d(Sleef_sinh_u10, Sleef_sinhd1_u10) +DALIAS_d_d(Sleef_cosh_u10, Sleef_coshd1_u10) +DALIAS_d_d(Sleef_tanh_u10, Sleef_tanhd1_u10) +DALIAS_d_d(Sleef_sinh_u35, Sleef_sinhd1_u35) +DALIAS_d_d(Sleef_cosh_u35, Sleef_coshd1_u35) +DALIAS_d_d(Sleef_tanh_u35, Sleef_tanhd1_u35) +DALIAS_d_d(Sleef_asinh_u10, Sleef_asinhd1_u10) +DALIAS_d_d(Sleef_acosh_u10, Sleef_acoshd1_u10) +DALIAS_d_d(Sleef_atanh_u10, Sleef_atanhd1_u10) +DALIAS_d_d(Sleef_log_u10, Sleef_logd1_u10) +DALIAS_d_d(Sleef_log2_u10, Sleef_log2d1_u10) +DALIAS_d_d(Sleef_log10_u10, Sleef_log10d1_u10) +DALIAS_d_d(Sleef_log1p_u10, Sleef_log1pd1_u10) +DALIAS_d_d(Sleef_log_u35, Sleef_logd1_u35) +DALIAS_d_d(Sleef_log2_u35, Sleef_log2d1_u35) +DALIAS_d_d(Sleef_exp_u10, Sleef_expd1_u10) +DALIAS_d_d(Sleef_exp2_u10, Sleef_exp2d1_u10) +DALIAS_d_d(Sleef_exp10_u10, Sleef_exp10d1_u10) +DALIAS_d_d(Sleef_expm1_u10, Sleef_expm1d1_u10) +DALIAS_d_d(Sleef_exp2_u35, Sleef_exp2d1_u35) +DALIAS_d_d(Sleef_exp10_u35, Sleef_exp10d1_u35) +DALIAS_d_d(Sleef_sqrt, Sleef_sqrtd1) +DALIAS_d_d(Sleef_sqrt_u05, Sleef_sqrtd1_u05) +DALIAS_d_d(Sleef_sqrt_u35, Sleef_sqrtd1_u35) +DALIAS_d_d(Sleef_cbrt_u10, Sleef_cbrtd1_u10) +DALIAS_d_d(Sleef_cbrt_u35, Sleef_cbrtd1_u35) +DALIAS_d_d(Sleef_sinpi_u05, Sleef_sinpid1_u05) +DALIAS_d_d(Sleef_cospi_u05, Sleef_cospid1_u05) +DALIAS_d_d(Sleef_fabs, Sleef_fabsd1) +DALIAS_d_d(Sleef_trunc, Sleef_truncd1) +DALIAS_d_d(Sleef_floor, Sleef_floord1) +DALIAS_d_d(Sleef_ceil, Sleef_ceild1) +DALIAS_d_d(Sleef_round, Sleef_roundd1) +DALIAS_d_d(Sleef_rint, Sleef_rintd1) +DALIAS_d_d(Sleef_lgamma_u10, Sleef_lgammad1_u10) +DALIAS_d_d(Sleef_tgamma_u10, Sleef_tgammad1_u10) +DALIAS_d_d(Sleef_erf_u10, Sleef_erfd1_u10) +DALIAS_d_d(Sleef_erfc_u15, Sleef_erfcd1_u15) +DALIAS_d2_d(Sleef_sincospi_u05, Sleef_sincospid1_u05) +DALIAS_d2_d(Sleef_sincospi_u35, Sleef_sincospid1_u35) +DALIAS_d2_d(Sleef_modf, Sleef_modfd1) +DALIAS_d_d_d(Sleef_copysign, Sleef_copysignd1) +DALIAS_d_d_d(Sleef_fmax, Sleef_fmaxd1) +DALIAS_d_d_d(Sleef_fmin, Sleef_fmind1) +DALIAS_d_d_d(Sleef_fdim, Sleef_fdimd1) +DALIAS_d_d_d(Sleef_nextafter, Sleef_nextafterd1) +DALIAS_i_d(Sleef_expfrexp, Sleef_expfrexpd1) +DALIAS_d_d_d_d(Sleef_fma, Sleef_fmad1) +DALIAS_d_d_d(Sleef_hypot_u05, Sleef_hypotd1_u05) +DALIAS_d_d_d(Sleef_hypot_u35, Sleef_hypotd1_u35) +DALIAS_d_d_d(Sleef_fmod, Sleef_fmodd1) +DALIAS_d_d_d(Sleef_remainder, Sleef_remainderd1) +DALIAS_d_d(Sleef_frfrexp, Sleef_frfrexpd1) +DALIAS_d2_d(Sleef_sincos_u35, Sleef_sincosd1_u35) +DALIAS_d2_d(Sleef_sincos_u10, Sleef_sincosd1_u10) +DALIAS_d_d_d(Sleef_atan2_u35, Sleef_atan2d1_u35) +DALIAS_d_d_d(Sleef_atan2_u10, Sleef_atan2d1_u10) +DALIAS_d_d_d(Sleef_pow_u10, Sleef_powd1_u10) +DALIAS_d_d_i(Sleef_ldexp, Sleef_ldexpd1) +DALIAS_i_d(Sleef_ilogb, Sleef_ilogbd1) + +DALIAS_f_f(Sleef_sinf_u35, Sleef_sinf1_u35) +DALIAS_f_f(Sleef_cosf_u35, Sleef_cosf1_u35) +DALIAS_f_f(Sleef_tanf_u35, Sleef_tanf1_u35) +DALIAS_f_f(Sleef_asinf_u35, Sleef_asinf1_u35) +DALIAS_f_f(Sleef_acosf_u35, Sleef_acosf1_u35) +DALIAS_f_f(Sleef_atanf_u35, Sleef_atanf1_u35) +DALIAS_f_f(Sleef_logf_u35, Sleef_logf1_u35) +DALIAS_f_f(Sleef_cbrtf_u35, Sleef_cbrtf1_u35) +DALIAS_f_f(Sleef_sinf_u10, Sleef_sinf1_u10) +DALIAS_f_f(Sleef_cosf_u10, Sleef_cosf1_u10) +DALIAS_f_f(Sleef_fastsinf_u3500, Sleef_fastsinf1_u3500) +DALIAS_f_f(Sleef_fastcosf_u3500, Sleef_fastcosf1_u3500) +DALIAS_f_f(Sleef_tanf_u10, Sleef_tanf1_u10) +DALIAS_f_f(Sleef_asinf_u10, Sleef_asinf1_u10) +DALIAS_f_f(Sleef_acosf_u10, Sleef_acosf1_u10) +DALIAS_f_f(Sleef_atanf_u10, Sleef_atanf1_u10) +DALIAS_f_f(Sleef_logf_u10, Sleef_logf1_u10) +DALIAS_f_f(Sleef_cbrtf_u10, Sleef_cbrtf1_u10) +DALIAS_f_f(Sleef_expf_u10, Sleef_expf1_u10) +DALIAS_f_f(Sleef_sinhf_u10, Sleef_sinhf1_u10) +DALIAS_f_f(Sleef_coshf_u10, Sleef_coshf1_u10) +DALIAS_f_f(Sleef_tanhf_u10, Sleef_tanhf1_u10) +DALIAS_f_f(Sleef_sinhf_u35, Sleef_sinhf1_u35) +DALIAS_f_f(Sleef_coshf_u35, Sleef_coshf1_u35) +DALIAS_f_f(Sleef_tanhf_u35, Sleef_tanhf1_u35) +DALIAS_f_f(Sleef_asinhf_u10, Sleef_asinhf1_u10) +DALIAS_f_f(Sleef_acoshf_u10, Sleef_acoshf1_u10) +DALIAS_f_f(Sleef_atanhf_u10, Sleef_atanhf1_u10) +DALIAS_f_f(Sleef_exp2f_u10, Sleef_exp2f1_u10) +DALIAS_f_f(Sleef_exp10f_u10, Sleef_exp10f1_u10) +DALIAS_f_f(Sleef_exp2f_u35, Sleef_exp2f1_u35) +DALIAS_f_f(Sleef_exp10f_u35, Sleef_exp10f1_u35) +DALIAS_f_f(Sleef_expm1f_u10, Sleef_expm1f1_u10) +DALIAS_f_f(Sleef_log10f_u10, Sleef_log10f1_u10) +DALIAS_f_f(Sleef_log2f_u10, Sleef_log2f1_u10) +DALIAS_f_f(Sleef_log2f_u35, Sleef_log2f1_u35) +DALIAS_f_f(Sleef_log1pf_u10, Sleef_log1pf1_u10) +DALIAS_f_f(Sleef_sinpif_u05, Sleef_sinpif1_u05) +DALIAS_f_f(Sleef_cospif_u05, Sleef_cospif1_u05) +DALIAS_f_f(Sleef_sqrtf_u05, Sleef_sqrtf1_u05) +DALIAS_f_f(Sleef_sqrtf_u35, Sleef_sqrtf1_u35) +DALIAS_f_f(Sleef_lgammaf_u10, Sleef_lgammaf1_u10) +DALIAS_f_f(Sleef_tgammaf_u10, Sleef_tgammaf1_u10) +DALIAS_f_f(Sleef_erff_u10, Sleef_erff1_u10) +DALIAS_f_f(Sleef_erfcf_u15, Sleef_erfcf1_u15) +DALIAS_f_f(Sleef_sqrtf, Sleef_sqrtf1) +DALIAS_f_f(Sleef_fabsf, Sleef_fabsf1) +DALIAS_f_f(Sleef_truncf, Sleef_truncf1) +DALIAS_f_f(Sleef_floorf, Sleef_floorf1) +DALIAS_f_f(Sleef_ceilf, Sleef_ceilf1) +DALIAS_f_f(Sleef_roundf, Sleef_roundf1) +DALIAS_f_f(Sleef_rintf, Sleef_rintf1) +DALIAS_f_f(Sleef_frfrexpf, Sleef_frfrexpf1) +DALIAS_f2_f(Sleef_sincospif_u05, Sleef_sincospif1_u05) +DALIAS_f2_f(Sleef_sincospif_u35, Sleef_sincospif1_u35) +DALIAS_f2_f(Sleef_sincosf_u35, Sleef_sincosf1_u35) +DALIAS_f2_f(Sleef_sincosf_u10, Sleef_sincosf1_u10) +DALIAS_f2_f(Sleef_modff, Sleef_modff1) +DALIAS_f_f_f(Sleef_hypotf_u05, Sleef_hypotf1_u05) +DALIAS_f_f_f(Sleef_hypotf_u35, Sleef_hypotf1_u35) +DALIAS_f_f_f(Sleef_atan2f_u35, Sleef_atan2f1_u35) +DALIAS_f_f_f(Sleef_atan2f_u10, Sleef_atan2f1_u10) +DALIAS_f_f_f(Sleef_powf_u10, Sleef_powf1_u10) +DALIAS_f_f_f(Sleef_fastpowf_u3500, Sleef_fastpowf1_u3500) +DALIAS_f_f_f_f(Sleef_fmaf, Sleef_fmaf1) +DALIAS_f_f_f(Sleef_nextafterf, Sleef_nextafterf1) +DALIAS_f_f_f(Sleef_fmodf, Sleef_fmodf1) +DALIAS_f_f_f(Sleef_remainderf, Sleef_remainderf1) +DALIAS_f_f_f(Sleef_copysignf, Sleef_copysignf1) +DALIAS_f_f_f(Sleef_fmaxf, Sleef_fmaxf1) +DALIAS_f_f_f(Sleef_fminf, Sleef_fminf1) +DALIAS_f_f_f(Sleef_fdimf, Sleef_fdimf1) + +CONST float Sleef_ldexpf1_purec(float, int); +EXPORT CONST float Sleef_ldexpf(float f, int i) { return Sleef_ldexpf1_purec(f, i); } +CONST int Sleef_ilogbf1_purec(float); +EXPORT CONST int Sleef_ilogbf(float f) { return Sleef_ilogbf1_purec(f); } +CONST int Sleef_expfrexpf1_purec(float); +EXPORT CONST int Sleef_expfrexpf(float f) { return Sleef_expfrexpf1_purec(f); } diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/dispsse.c.org b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/dispsse.c.org new file mode 100644 index 00000000000..1436e1030cf --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/dispsse.c.org @@ -0,0 +1,65 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include + +#include "misc.h" + +#define SLEEF_IMPORT_IS_EXPORT +#include "sleef.h" + +static int cpuSupportsSSE4_1() { + static int ret = -1; + if (ret == -1) { + int32_t reg[4]; + Sleef_x86CpuID(reg, 1, 0); + ret = (reg[2] & (1 << 19)) != 0; + } + return ret; +} + +static int cpuSupportsAVX2() { + static int ret = -1; + if (ret == -1) { + int32_t reg[4]; + Sleef_x86CpuID(reg, 7, 0); + ret = (reg[1] & (1 << 5)) != 0; + } + return ret; +} + +static int cpuSupportsFMA() { + static int ret = -1; + if (ret == -1) { + int32_t reg[4]; + Sleef_x86CpuID(reg, 1, 0); + ret = (reg[2] & (1 << 12)) != 0; + } + return ret; +} + +#define SUBST_IF_EXT1(funcsse4) if (cpuSupportsSSE4_1()) p = funcsse4; + +#ifdef ENABLE_AVX2 +#define SUBST_IF_EXT2(funcavx2) if (cpuSupportsAVX2() && cpuSupportsFMA()) p = funcavx2; +#else +#define SUBST_IF_EXT2(funcavx2) +#endif + +#ifdef ENABLE_ALIAS +#define VECALIAS_vf_vf(fptype, funcNameS, funcName, veclen) \ + EXPORT CONST VECTOR_CC fptype _ZGVbN ## veclen ## v_ ## funcNameS(fptype) __attribute__((alias(stringify(funcName)))); +#define VECALIAS_vf_vf_vf(fptype, funcNameS, funcName, veclen) \ + EXPORT CONST VECTOR_CC fptype _ZGVbN ## veclen ## vv_ ## funcNameS(fptype, fptype) __attribute__((alias(stringify(funcName)))); +#define VECALIAS_vf_vf_vf_vf(fptype, funcNameS, funcName, veclen) \ + EXPORT CONST VECTOR_CC fptype _ZGVbN ## veclen ## vvv_ ## funcNameS(fptype, fptype, fptype) __attribute__((alias(stringify(funcName)))); +#endif + +#include "dispatcher.h" + +// diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/funcproto.h b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/funcproto.h new file mode 100644 index 00000000000..1ab66b3b905 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/funcproto.h @@ -0,0 +1,126 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +typedef struct { + char *name; + int ulp; + int ulpSuffix; + int funcType; + int flags; +} funcSpec; + +/* + ulp : (error bound in ulp) * 10 + + ulpSuffix: + 0 : "" + 1 : "_u1" + 2 : "_u05" + 3 : "_u35" + 4 : "_u15" + 5 : "_u3500" + + funcType: + 0 : vdouble func(vdouble); + 1 : vdouble func(vdouble, vdouble); + 2 : vdouble2 func(vdouble); GNUABI : void func(vdouble, double *, double *); + 3 : vdouble func(vdouble, vint); + 4 : vint func(vdouble); + 5 : vdouble func(vdouble, vdouble, vdouble); + 6 : vdouble2 func(vdouble); GNUABI : vdouble func(vdouble, double *); + 7 : int func(int); + 8 : void *func(int); + + flags: + 1 : No GNUABI + 2 : No double func + */ + +funcSpec funcList[] = { + { "sin", 35, 0, 0, 0 }, + { "cos", 35, 0, 0, 0 }, + { "sincos", 35, 0, 2, 0 }, + { "tan", 35, 0, 0, 0 }, + { "asin", 35, 0, 0, 0 }, + { "acos", 35, 0, 0, 0 }, + { "atan", 35, 0, 0, 0 }, + { "atan2", 35, 0, 1, 0 }, + { "log", 35, 0, 0, 0 }, + { "cbrt", 35, 0, 0, 0 }, + { "sin", 10, 1, 0, 0 }, + { "cos", 10, 1, 0, 0 }, + { "sincos", 10, 1, 2, 0 }, + { "tan", 10, 1, 0, 0 }, + { "asin", 10, 1, 0, 0 }, + { "acos", 10, 1, 0, 0 }, + { "atan", 10, 1, 0, 0 }, + { "atan2", 10, 1, 1, 0 }, + { "log", 10, 1, 0, 0 }, + { "cbrt", 10, 1, 0, 0 }, + { "exp", 10, 0, 0, 0 }, + { "pow", 10, 0, 1, 0 }, + { "sinh", 10, 0, 0, 0 }, + { "cosh", 10, 0, 0, 0 }, + { "tanh", 10, 0, 0, 0 }, + { "sinh", 35, 3, 0, 0 }, + { "cosh", 35, 3, 0, 0 }, + { "tanh", 35, 3, 0, 0 }, + + { "fastsin", 3500, 5, 0, 2 }, + { "fastcos", 3500, 5, 0, 2 }, + { "fastpow", 3500, 5, 1, 2 }, + + { "asinh", 10, 0, 0, 0 }, + { "acosh", 10, 0, 0, 0 }, + { "atanh", 10, 0, 0, 0 }, + { "exp2", 10, 0, 0, 0 }, + { "exp2", 35, 3, 0, 0 }, + { "exp10", 10, 0, 0, 0 }, + { "exp10", 35, 3, 0, 0 }, + { "expm1", 10, 0, 0, 0 }, + { "log10", 10, 0, 0, 0 }, + { "log2", 10, 0, 0, 0 }, + { "log2", 35, 3, 0, 0 }, + { "log1p", 10, 0, 0, 0 }, + { "sincospi", 5, 2, 2, 0 }, + { "sincospi", 35, 3, 2, 0 }, + { "sinpi", 5, 2, 0, 0 }, + { "cospi", 5, 2, 0, 0 }, + { "ldexp", -1, 0, 3, 0 }, + { "ilogb", -1, 0, 4, 0 }, + + { "fma", -1, 0, 5, 0 }, + { "sqrt", -1, 0, 0, 0 }, + { "sqrt", 5, 2, 0, 1 }, + { "sqrt", 35, 3, 0, 0 }, + { "hypot", 5, 2, 1, 0 }, + { "hypot", 35, 3, 1, 0 }, + { "fabs", -1, 0, 0, 0 }, + { "copysign", -1, 0, 1, 0 }, + { "fmax", -1, 0, 1, 0 }, + { "fmin", -1, 0, 1, 0 }, + { "fdim", -1, 0, 1, 0 }, + { "trunc", -1, 0, 0, 0 }, + { "floor", -1, 0, 0, 0 }, + { "ceil", -1, 0, 0, 0 }, + { "round", -1, 0, 0, 0 }, + { "rint", -1, 0, 0, 0 }, + { "nextafter", -1, 0, 1, 0 }, + { "frfrexp", -1, 0, 0, 0 }, + { "expfrexp", -1, 0, 4, 0 }, + { "fmod", -1, 0, 1, 0 }, + { "remainder", -1, 0, 1, 0 }, + { "modf", -1, 0, 6, 0 }, + + { "lgamma", 10, 1, 0, 0 }, + { "tgamma", 10, 1, 0, 0 }, + { "erf", 10, 1, 0, 0 }, + { "erfc", 15, 4, 0, 0 }, + + { "getInt", -1, 0, 7, 1}, + { "getPtr", -1, 0, 8, 1}, + + { NULL, -1, 0, 0, 0 }, +}; diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/mkalias.c b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/mkalias.c new file mode 100644 index 00000000000..8a06c791395 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/mkalias.c @@ -0,0 +1,160 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include + +#include "funcproto.h" + +int main(int argc, char **argv) { + if (argc == 2 && strcmp(argv[1], "0") == 0) exit(0); + + if (argc < 6) { + fprintf(stderr, "Usage : %s \n", argv[0]); + exit(-1); + } + + int vw = atoi(argv[1]); + int fptype = vw >= 0 ? 0 : 1; + vw = vw < 0 ? -vw : vw; + char *mangledisa = argv[4]; + int genAliasVectorABI = (mangledisa[0] != '-'); + char *isaname = argc == 6 ? argv[5] : ""; + + char * vectorcc=""; +#ifdef ENABLE_AAVPCS + if (strcmp(isaname, "advsimd") == 0) + vectorcc =" __attribute__((aarch64_vector_pcs))"; + genAliasVectorABI = 0; +#endif + + static char *argType2[] = { + "a0", "a0, a1", "a0", "a0, a1", + "a0", "a0, a1, a2", "a0", "a0", "a0" + }; + static char *typeSpecS[] = { "", "f" }; + static char *typeSpec[] = { "d", "f" }; + static char *vparameterStr[9] = { "v", "vv", "", "vv", "v", "vvv", "", "", "" }; + + static char returnType[9][1000]; + static char argType0[9][1000]; + static char argType1[9][1000]; + + sprintf(returnType[0], "%s", argv[2]); + sprintf(returnType[1], "%s", argv[2]); + sprintf(returnType[2], "%s", fptype ? "vfloat2" : "vdouble2"); + sprintf(returnType[3], "%s", argv[2]); + sprintf(returnType[4], "%s", argv[3]); + sprintf(returnType[5], "%s", argv[2]); + sprintf(returnType[6], "%s", fptype ? "vfloat2" : "vdouble2"); + sprintf(returnType[7], "int"); + sprintf(returnType[8], "void *"); + + sprintf(argType0[0], "%s", argv[2]); + sprintf(argType0[1], "%s, %s", argv[2], argv[2]); + sprintf(argType0[2], "%s", argv[2]); + sprintf(argType0[3], "%s, %s", argv[2], argv[3]); + sprintf(argType0[4], "%s", argv[2]); + sprintf(argType0[5], "%s, %s, %s", argv[2], argv[2], argv[2]); + sprintf(argType0[6], "%s", argv[2]); + sprintf(argType0[7], "int"); + sprintf(argType0[8], "int"); + + sprintf(argType1[0], "%s a0", argv[2]); + sprintf(argType1[1], "%s a0, %s a1", argv[2], argv[2]); + sprintf(argType1[2], "%s a0", argv[2]); + sprintf(argType1[3], "%s a0, %s a1", argv[2], argv[3]); + sprintf(argType1[4], "%s a0", argv[2]); + sprintf(argType1[5], "%s a0, %s a1, %s a2", argv[2], argv[2], argv[2]); + sprintf(argType1[6], "%s a0", argv[2]); + sprintf(argType1[7], "int a0"); + sprintf(argType1[8], "int a0"); + + // + + if (fptype == 0) { + printf("#ifdef __SLEEFSIMDDP_C__\n"); + } else { + printf("#ifdef __SLEEFSIMDSP_C__\n"); + } + printf("#ifdef ENABLE_ALIAS\n"); + + if (argc == 6) { + for(int i=0;funcList[i].name != NULL;i++) { + if (fptype == 0 && (funcList[i].flags & 2) != 0) continue; + if (funcList[i].ulp >= 0) { + printf("EXPORT CONST %s Sleef_%s%s%d_u%02d(%s) __attribute__((alias(\"Sleef_%s%s%d_u%02d%s\"))) %s;\n", + returnType[funcList[i].funcType], + funcList[i].name, typeSpec[fptype], vw, funcList[i].ulp, + argType0[funcList[i].funcType], + funcList[i].name, typeSpec[fptype], vw, funcList[i].ulp, isaname, vectorcc + ); + if (genAliasVectorABI && vparameterStr[funcList[i].funcType] != NULL) { + printf("EXPORT CONST VECTOR_CC %s _ZGV%sN%d%s_Sleef_%s%s_u%02d(%s) __attribute__((alias(\"Sleef_%s%s%d_u%02d%s\")))%s;\n", + returnType[funcList[i].funcType], + mangledisa, vw, vparameterStr[funcList[i].funcType], funcList[i].name, typeSpecS[fptype], funcList[i].ulp, + argType0[funcList[i].funcType], + funcList[i].name, typeSpec[fptype], vw, funcList[i].ulp, isaname, vectorcc + ); + } + } else { + printf("EXPORT CONST %s Sleef_%s%s%d(%s) __attribute__((alias(\"Sleef_%s%s%d_%s\"))) %s;\n", + returnType[funcList[i].funcType], + funcList[i].name, typeSpec[fptype], vw, + argType0[funcList[i].funcType], + funcList[i].name, typeSpec[fptype], vw, isaname, vectorcc + ); + if (genAliasVectorABI && vparameterStr[funcList[i].funcType] != NULL) { + printf("EXPORT CONST VECTOR_CC %s _ZGV%sN%d%s_Sleef_%s%s(%s) __attribute__((alias(\"Sleef_%s%s%d_%s\")))%s;\n", + returnType[funcList[i].funcType], + mangledisa, vw, vparameterStr[funcList[i].funcType], funcList[i].name, typeSpecS[fptype], + argType0[funcList[i].funcType], + funcList[i].name, typeSpec[fptype], vw, isaname, vectorcc + ); + } + } + } + + printf("\n"); + } + + printf("#else // #ifdef ENABLE_ALIAS\n"); + + if (argc == 6) { + for(int i=0;funcList[i].name != NULL;i++) { + if (fptype == 0 && (funcList[i].flags & 2) != 0) continue; + if (funcList[i].ulp >= 0) { + printf("EXPORT CONST %s %s Sleef_%s%s%d_u%02d(%s) { return Sleef_%s%s%d_u%02d%s(%s); }\n", + returnType[funcList[i].funcType], vectorcc, + funcList[i].name, typeSpec[fptype], vw, funcList[i].ulp, + argType1[funcList[i].funcType], + funcList[i].name, typeSpec[fptype], vw, funcList[i].ulp, isaname, + argType2[funcList[i].funcType] + ); + } else { + printf("EXPORT CONST %s %s Sleef_%s%s%d(%s) { return Sleef_%s%s%d_%s(%s); }\n", + returnType[funcList[i].funcType], vectorcc, + funcList[i].name, typeSpec[fptype], vw, + argType1[funcList[i].funcType], + funcList[i].name, typeSpec[fptype], vw, isaname, + argType2[funcList[i].funcType] + ); + } + } + + printf("\n"); + } + + printf("#endif // #ifdef ENABLE_ALIAS\n"); + if (fptype == 0) { + printf("#endif // #ifdef __SLEEFSIMDDP_C__\n"); + } else { + printf("#endif // #ifdef __SLEEFSIMDSP_C__\n"); + } + + exit(0); +} diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/mkdisp.c b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/mkdisp.c new file mode 100644 index 00000000000..7579753cfd9 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/mkdisp.c @@ -0,0 +1,201 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include + +#include "funcproto.h" + +int main(int argc, char **argv) { + if (argc < 7) { + fprintf(stderr, "Usage : %s [ ...]\n", argv[0]); + fprintf(stderr, "\n"); + exit(-1); + } + + const int wdp = atoi(argv[1]), wsp = atoi(argv[2]); + const char *vdoublename = argv[3], *vfloatname = argv[4], *vintname = argv[5]; + const int isastart = 6, nisa = argc - isastart; + + for(int i=0;funcList[i].name != NULL;i++) { + char ulpSuffix0[100] = "", ulpSuffix1[100] = "_"; + if (funcList[i].ulp >= 0) { + sprintf(ulpSuffix0, "_u%02d", funcList[i].ulp); + sprintf(ulpSuffix1, "_u%02d", funcList[i].ulp); + } + + switch(funcList[i].funcType) { + case 0: + if ((funcList[i].flags & 2) == 0) { + printf("DISPATCH_vf_vf(%s, %d, Sleef_%s%s, Sleef_%sd1%s, Sleef_%sd%d%s, pnt_%sd%d%s, disp_%sd%d%s", + vdoublename, + wdp, funcList[i].name, ulpSuffix0, + funcList[i].name, ulpSuffix0, + funcList[i].name, wdp, ulpSuffix0, + funcList[i].name, wdp, ulpSuffix0, + funcList[i].name, wdp, ulpSuffix0); + for(int j=0;j +#include +#include +#include +#include + +#include "funcproto.h" + +int main(int argc, char **argv) { + if (argc < 4) { + fprintf(stderr, "\nUsage : %s \n\n", argv[0]); + fprintf(stderr, "This program generates an include file defining masked functions.\n"); + exit(-1); + } + + // + + const char *isaname = argv[1]; + const char *mangledisa = argv[2]; + const int vw = atoi(argv[3]); + int fptype = 0; + + // Remove the "-" sign in the SP value + const char *cvw = (vw < 0) ? argv[3] + 1 : argv[3]; + + if (vw < 0) { + fptype = 1; + } + + // VLA SVE does not set the vector length in the mangled names. + if (strcmp(isaname, "sve") == 0) + cvw = "x"; + + // + +#define LEN0 16 +#define LEN1 256 + + static char *vfpname[] = { "vdouble", "vfloat" }; + static char *vintname[] = { "vint", "vint2" }; + static int sizeoffp[] = { 8, 4 }; + + static char vparameterStr[7][LEN0] = { "v", "vv", "vl8l8", "vv", "v", "vvv", "vl8" }; + static char *typeSpecS[] = { "", "f" }; + static char funcname[4][LEN1]; + + snprintf(vparameterStr[2], LEN0, "vl%dl%d", sizeoffp[fptype], sizeoffp[fptype]); + snprintf(vparameterStr[6], LEN0, "vl%d", sizeoffp[fptype]); + + // + + for(int i=0;funcList[i].name != NULL;i++) { + if ((funcList[i].flags & 1) != 0) continue; + if (fptype == 0 && (funcList[i].flags & 2) != 0) continue; + if (funcList[i].ulp < 20) { + snprintf(funcname[0], LEN1, "_ZGV%sN%s%s_%s%s", + mangledisa, cvw, vparameterStr[funcList[i].funcType], funcList[i].name, typeSpecS[fptype]); + snprintf(funcname[1], LEN1, "_ZGV%sM%s%s_%s%s", + mangledisa, cvw, vparameterStr[funcList[i].funcType], funcList[i].name, typeSpecS[fptype]); + } else { + snprintf(funcname[0], LEN1, "_ZGV%sN%s%s_%s%s_u%d", + mangledisa, cvw, vparameterStr[funcList[i].funcType], funcList[i].name, typeSpecS[fptype], funcList[i].ulp); + snprintf(funcname[1], LEN1, "_ZGV%sM%s%s_%s%s_u%d", + mangledisa, cvw, vparameterStr[funcList[i].funcType], funcList[i].name, typeSpecS[fptype], funcList[i].ulp); + } + + snprintf(funcname[2], LEN1, "_ZGV%sN%s%s___%s%s_finite", + mangledisa, cvw, vparameterStr[funcList[i].funcType], funcList[i].name, typeSpecS[fptype]); + snprintf(funcname[3], LEN1, "_ZGV%sM%s%s___%s%s_finite", + mangledisa, cvw, vparameterStr[funcList[i].funcType], funcList[i].name, typeSpecS[fptype]); + + switch(funcList[i].funcType) { + case 0: { + printf("EXPORT CONST %s %s(%s a0, vopmask m) { return %s(a0); }\n", + vfpname[fptype], funcname[1], vfpname[fptype], funcname[0]); + + if (funcList[i].ulp < 20) + printf("EXPORT CONST %s %s(%s, vopmask) __attribute__((weak, alias(\"%s\")));\n", + vfpname[fptype], funcname[3], vfpname[fptype], funcname[1]); + else + printf("EXPORT CONST %s %s_u%d(%s, vopmask) __attribute__((weak, alias(\"%s\")));\n", + vfpname[fptype], funcname[3],funcList[i].ulp, vfpname[fptype], funcname[1]); + break; + } + case 1: { + printf("EXPORT CONST %s %s(%s a0, %s a1, vopmask m) { return %s(a0, a1); }\n", + vfpname[fptype], funcname[1], vfpname[fptype], vfpname[fptype], funcname[0]); + if (funcList[i].ulp < 20) + printf("EXPORT CONST %s %s(%s, %s, vopmask) __attribute__((weak, alias(\"%s\")));\n", + vfpname[fptype], funcname[3], vfpname[fptype], vfpname[fptype], funcname[1]); + else + printf("EXPORT CONST %s %s_u%d(%s, %s, vopmask) __attribute__((weak, alias(\"%s\")));\n", + vfpname[fptype], funcname[3],funcList[i].ulp, vfpname[fptype], vfpname[fptype], funcname[1]); + break; + } + case 2: + if (sizeoffp[fptype] == sizeof(double)) { + printf("#ifndef ENABLE_SVE\n"); + printf("EXPORT void %s(vdouble a0, double *a1, double *a2, vopmask m) {\n", funcname[1]); + printf(" double s[VECTLENDP], c[VECTLENDP];\n"); + printf(" int32_t mbuf[VECTLENSP];\n"); + printf(" %s(a0, s, c);\n", funcname[0]); + printf(" vstoreu_v_p_vi2(mbuf, vcast_vi2_vm(vand_vm_vo64_vm(m, vcast_vm_i_i(-1, -1))));\n"); + printf(" for(int i=0;i +#include +#include +#include + +#include "funcproto.h" + +// In VSX intrinsics, vector data types are like "vector float". +// This function replaces space characters with '_'. +char *escapeSpace(char *str) { + char *ret = malloc(strlen(str) + 10); + strcpy(ret, str); + for(char *p = ret;*p != '\0';p++) if (*p == ' ') *p = '_'; + return ret; +} + +int main(int argc, char **argv) { + if (argc < 4) { + fprintf(stderr, "Generate a header for renaming functions\n"); + fprintf(stderr, "Usage : %s []\n", argv[0]); + fprintf(stderr, "\n"); + + fprintf(stderr, "Generate a part of header for library functions\n"); + fprintf(stderr, "Usage : %s []\n", argv[0]); + fprintf(stderr, "\n"); + + exit(-1); + } + + static char *ulpSuffixStr[] = { "", "_u1", "_u05", "_u35", "_u15", "_u3500" }; + + if (argc == 4 || argc == 5) { + char *atrPrefix = strcmp(argv[1], "-") == 0 ? NULL : argv[1]; + char *wdp = argv[2]; + char *wsp = argv[3]; + char *isaname = argc == 4 ? "" : argv[4]; + char *isaub = argc == 5 ? "_" : ""; + + // + + printf("#ifndef DETERMINISTIC\n\n"); + + for(int i=0;funcList[i].name != NULL;i++) { + if (funcList[i].ulp >= 0) { + printf("#define x%s%s Sleef_%s%sd%s_u%02d%s\n", + funcList[i].name, ulpSuffixStr[funcList[i].ulpSuffix], + "", funcList[i].name, wdp, + funcList[i].ulp, isaname); + if (atrPrefix != NULL) { + printf("#define y%s%s Sleef_%s%sd%s_u%02d%s\n", + funcList[i].name, ulpSuffixStr[funcList[i].ulpSuffix], + atrPrefix, funcList[i].name, wdp, + funcList[i].ulp, isaname); + } + } else { + printf("#define x%s Sleef_%s%sd%s%s%s\n", + funcList[i].name, + "", funcList[i].name, wdp, isaub, isaname); + if (atrPrefix != NULL) { + printf("#define y%s Sleef_%s%sd%s%s%s\n", + funcList[i].name, + atrPrefix, funcList[i].name, wdp, isaub, isaname); + } + } + } + + printf("\n"); + + for(int i=0;funcList[i].name != NULL;i++) { + if (funcList[i].ulp >= 0) { + printf("#define x%sf%s Sleef_%s%sf%s_u%02d%s\n", + funcList[i].name, ulpSuffixStr[funcList[i].ulpSuffix], + "", funcList[i].name, wsp, + funcList[i].ulp, isaname); + if (atrPrefix != NULL) { + printf("#define y%sf%s Sleef_%s%sf%s_u%02d%s\n", + funcList[i].name, ulpSuffixStr[funcList[i].ulpSuffix], + atrPrefix, funcList[i].name, wsp, + funcList[i].ulp, isaname); + } + } else { + printf("#define x%sf Sleef_%s%sf%s%s%s\n", + funcList[i].name, + "", funcList[i].name, wsp, isaub, isaname); + if (atrPrefix != NULL) { + printf("#define y%sf Sleef_%s%sf%s%s%s\n", + funcList[i].name, + atrPrefix, funcList[i].name, wsp, isaub, isaname); + } + } + } + + // + + if (atrPrefix != NULL) { + printf("\n#else //#ifndef DETERMINISTIC\n\n"); + + for(int i=0;funcList[i].name != NULL;i++) { + if (funcList[i].ulp >= 0) { + printf("#define x%s%s Sleef_%s%sd%s_u%02d%s\n", + funcList[i].name, ulpSuffixStr[funcList[i].ulpSuffix], + atrPrefix, funcList[i].name, wdp, + funcList[i].ulp, isaname); + } else { + printf("#define x%s Sleef_%s%sd%s%s%s\n", + funcList[i].name, + atrPrefix, funcList[i].name, wdp, isaub, isaname); + } + } + + printf("\n"); + + for(int i=0;funcList[i].name != NULL;i++) { + if (funcList[i].ulp >= 0) { + printf("#define x%sf%s Sleef_%s%sf%s_u%02d%s\n", + funcList[i].name, ulpSuffixStr[funcList[i].ulpSuffix], + atrPrefix, funcList[i].name, wsp, + funcList[i].ulp, isaname); + } else { + printf("#define x%sf Sleef_%s%sf%s%s%s\n", + funcList[i].name, + atrPrefix, funcList[i].name, wsp, isaub, isaname); + } + } + } + + printf("\n#endif // #ifndef DETERMINISTIC\n"); + } + else { + char *atrPrefix = strcmp(argv[1], "-") == 0 ? NULL : argv[1]; + char *wdp = argv[2]; + char *wsp = argv[3]; + char *vdoublename = argv[4], *vdoublename_escspace = escapeSpace(vdoublename); + char *vfloatname = argv[5], *vfloatname_escspace = escapeSpace(vfloatname); + char *vintname = argv[6], *vintname_escspace = escapeSpace(vintname); + char *vint2name = argv[7], *vint2name_escspace = escapeSpace(vint2name); + char *architecture = argv[8]; + char *isaname = argc == 10 ? argv[9] : ""; + char *isaub = argc == 10 ? "_" : ""; + char *str_omp_simd_dp = (argc < 10 && strcmp(wdp, "1") == 0) ? "SLEEF_PRAGMA_OMP_SIMD_DP " : ""; + char *str_omp_simd_sp = (argc < 10 && strcmp(wsp, "1") == 0) ? "SLEEF_PRAGMA_OMP_SIMD_SP " : ""; + + if (strcmp(isaname, "sve") == 0) + wdp = wsp = "x"; + + char * vectorcc = ""; +#ifdef ENABLE_AAVPCS + if (strcmp(isaname, "advsimd") == 0) + vectorcc =" __attribute__((aarch64_vector_pcs))"; +#endif + + printf("#ifdef %s\n", architecture); + + if (strcmp(vdoublename, "-") != 0) { + if (strcmp(vdoublename, "double") != 0) { + printf("\n"); + printf("#ifndef Sleef_%s_2_DEFINED\n", vdoublename_escspace); + if (strcmp(architecture, "__ARM_FEATURE_SVE") == 0) { + printf("typedef svfloat64x2_t Sleef_%s_2;\n", vdoublename_escspace); + } else { + printf("typedef struct {\n"); + printf(" %s x, y;\n", vdoublename); + printf("} Sleef_%s_2;\n", vdoublename_escspace); + } + printf("#define Sleef_%s_2_DEFINED\n", vdoublename_escspace); + printf("#endif\n"); + printf("\n"); + } else { + printf("\n"); + printf("#ifndef Sleef_double_2_DEFINED\n"); + printf("typedef Sleef_double2 Sleef_double_2;\n"); + printf("#define Sleef_double_2_DEFINED\n"); + printf("#endif\n"); + printf("\n"); + } + + for(int i=0;funcList[i].name != NULL;i++) { + switch(funcList[i].funcType) { + case 0: + if (funcList[i].ulp >= 0) { + printf("%sSLEEF_IMPORT SLEEF_CONST %s Sleef_%sd%s_u%02d%s(%s)%s;\n", + str_omp_simd_dp, + vdoublename, + funcList[i].name, wdp, + funcList[i].ulp, isaname, + vdoublename, + vectorcc); + if (atrPrefix != NULL) { + printf("SLEEF_IMPORT SLEEF_CONST %s Sleef_%s%sd%s_u%02d%s(%s)%s;\n", + vdoublename, + atrPrefix, + funcList[i].name, wdp, + funcList[i].ulp, isaname, + vdoublename, + vectorcc); + } + } else { + printf("%sSLEEF_IMPORT SLEEF_CONST %s Sleef_%sd%s%s%s(%s)%s;\n", + str_omp_simd_dp, + vdoublename, + funcList[i].name, wdp, + isaub, isaname, + vdoublename, + vectorcc); + if (atrPrefix != NULL) { + printf("SLEEF_IMPORT SLEEF_CONST %s Sleef_%s%sd%s%s%s(%s)%s;\n", + vdoublename, + atrPrefix, + funcList[i].name, wdp, + isaub, isaname, + vdoublename, + vectorcc); + } + } + break; + case 1: + if (funcList[i].ulp >= 0) { + printf("%sSLEEF_IMPORT SLEEF_CONST %s Sleef_%sd%s_u%02d%s(%s, %s)%s;\n", + str_omp_simd_dp, + vdoublename, + funcList[i].name, wdp, + funcList[i].ulp, isaname, + vdoublename, vdoublename, + vectorcc); + if (atrPrefix != NULL) { + printf("SLEEF_IMPORT SLEEF_CONST %s Sleef_%s%sd%s_u%02d%s(%s, %s)%s;\n", + vdoublename, + atrPrefix, funcList[i].name, wdp, + funcList[i].ulp, isaname, + vdoublename, vdoublename, + vectorcc); + } + } else { + printf("%sSLEEF_IMPORT SLEEF_CONST %s Sleef_%sd%s%s%s(%s, %s)%s;\n", + str_omp_simd_dp, + vdoublename, + funcList[i].name, wdp, + isaub, isaname, + vdoublename, vdoublename, + vectorcc); + if (atrPrefix != NULL) { + printf("SLEEF_IMPORT SLEEF_CONST %s Sleef_%s%sd%s%s%s(%s, %s)%s;\n", + vdoublename, + atrPrefix, funcList[i].name, wdp, + isaub, isaname, + vdoublename, vdoublename, + vectorcc); + } + } + break; + case 2: + case 6: + if (funcList[i].ulp >= 0) { + printf("SLEEF_IMPORT SLEEF_CONST Sleef_%s_2 Sleef_%sd%s_u%02d%s(%s)%s;\n", + vdoublename_escspace, + funcList[i].name, wdp, + funcList[i].ulp, isaname, + vdoublename, + vectorcc); + if (atrPrefix != NULL) { + printf("SLEEF_IMPORT SLEEF_CONST Sleef_%s_2 Sleef_%s%sd%s_u%02d%s(%s)%s;\n", + vdoublename_escspace, + atrPrefix, funcList[i].name, wdp, + funcList[i].ulp, isaname, + vdoublename, + vectorcc); + } + } else { + printf("SLEEF_IMPORT SLEEF_CONST Sleef_%s_2 Sleef_%sd%s%s%s(%s)%s;\n", + vdoublename_escspace, + funcList[i].name, wdp, + isaub, isaname, + vdoublename, + vectorcc); + if (atrPrefix != NULL) { + printf("SLEEF_IMPORT SLEEF_CONST Sleef_%s_2 Sleef_%s%sd%s%s%s(%s)%s;\n", + vdoublename_escspace, + atrPrefix, funcList[i].name, wdp, + isaub, isaname, + vdoublename, + vectorcc); + } + } + break; + case 3: + if (funcList[i].ulp >= 0) { + printf("SLEEF_IMPORT SLEEF_CONST %s Sleef_%sd%s_u%02d%s(%s, %s)%s;\n", + vdoublename, + funcList[i].name, wdp, + funcList[i].ulp, isaname, + vdoublename, vintname, + vectorcc); + if (atrPrefix != NULL) { + printf("SLEEF_IMPORT SLEEF_CONST %s Sleef_%s%sd%s_u%02d%s(%s, %s)%s;\n", + vdoublename, + atrPrefix, funcList[i].name, wdp, + funcList[i].ulp, isaname, + vdoublename, vintname, + vectorcc); + } + } else { + printf("SLEEF_IMPORT SLEEF_CONST %s Sleef_%sd%s%s%s(%s, %s)%s;\n", + vdoublename, + funcList[i].name, wdp, + isaub, isaname, + vdoublename, vintname, + vectorcc); + if (atrPrefix != NULL) { + printf("SLEEF_IMPORT SLEEF_CONST %s Sleef_%s%sd%s%s%s(%s, %s)%s;\n", + vdoublename, + atrPrefix, funcList[i].name, wdp, + isaub, isaname, + vdoublename, vintname, + vectorcc); + } + } + break; + case 4: + if (funcList[i].ulp >= 0) { + printf("SLEEF_IMPORT SLEEF_CONST %s Sleef_%sd%s_u%02d%s(%s)%s;\n", + vintname, + funcList[i].name, wdp, + funcList[i].ulp, isaname, + vdoublename, + vectorcc); + if (atrPrefix != NULL) { + printf("SLEEF_IMPORT SLEEF_CONST %s Sleef_%s%sd%s_u%02d%s(%s)%s;\n", + vintname, + atrPrefix, funcList[i].name, wdp, + funcList[i].ulp, isaname, + vdoublename, + vectorcc); + } + } else { + printf("SLEEF_IMPORT SLEEF_CONST %s Sleef_%sd%s%s%s(%s)%s;\n", + vintname, + funcList[i].name, wdp, + isaub, isaname, + vdoublename, + vectorcc); + if (atrPrefix != NULL) { + printf("SLEEF_IMPORT SLEEF_CONST %s Sleef_%s%sd%s%s%s(%s)%s;\n", + vintname, + atrPrefix, funcList[i].name, wdp, + isaub, isaname, + vdoublename, + vectorcc); + } + } + break; + case 5: + if (funcList[i].ulp >= 0) { + printf("%sSLEEF_IMPORT SLEEF_CONST %s Sleef_%sd%s_u%02d%s(%s, %s, %s)%s;\n", + str_omp_simd_dp, + vdoublename, + funcList[i].name, wdp, + funcList[i].ulp, isaname, + vdoublename, vdoublename, vdoublename, + vectorcc); + if (atrPrefix != NULL) { + printf("SLEEF_IMPORT SLEEF_CONST %s Sleef_%s%sd%s_u%02d%s(%s, %s, %s)%s;\n", + vdoublename, + atrPrefix, funcList[i].name, wdp, + funcList[i].ulp, isaname, + vdoublename, vdoublename, vdoublename, + vectorcc); + } + } else { + printf("SLEEF_IMPORT SLEEF_CONST %s Sleef_%sd%s%s%s(%s, %s, %s)%s;\n", + vdoublename, + funcList[i].name, wdp, + isaub, isaname, + vdoublename, vdoublename, vdoublename, + vectorcc); + if (atrPrefix != NULL) { + printf("SLEEF_IMPORT SLEEF_CONST %s Sleef_%s%sd%s%s%s(%s, %s, %s)%s;\n", + vdoublename, + atrPrefix, funcList[i].name, wdp, + isaub, isaname, + vdoublename, vdoublename, vdoublename, + vectorcc); + } + } + break; + // The two cases below should not use vector calling convention. + // They do not have vector type as argument or return value. + // Also, the corresponding definition (`getPtr` and `getInt`) in `sleefsimd*.c` + // are not defined with `VECTOR_CC`. (Same for single precision case below) + case 7: + printf("SLEEF_IMPORT SLEEF_CONST int Sleef_%sd%s%s%s(int);\n", + funcList[i].name, wdp, isaub, isaname); + break; + case 8: + printf("SLEEF_IMPORT SLEEF_CONST void *Sleef_%sd%s%s%s(int);\n", + funcList[i].name, wdp, isaub, isaname); + break; + } + } + } + + if (strcmp(vfloatname, "float") != 0) { + printf("\n"); + printf("#ifndef Sleef_%s_2_DEFINED\n", vfloatname_escspace); + if (strcmp(architecture, "__ARM_FEATURE_SVE") == 0) { + printf("typedef svfloat32x2_t Sleef_%s_2;\n", vfloatname_escspace); + } else { + printf("typedef struct {\n"); + printf(" %s x, y;\n", vfloatname); + printf("} Sleef_%s_2;\n", vfloatname_escspace); + } + printf("#define Sleef_%s_2_DEFINED\n", vfloatname_escspace); + printf("#endif\n"); + printf("\n"); + } else { + printf("\n"); + printf("#ifndef Sleef_float_2_DEFINED\n"); + printf("typedef Sleef_float2 Sleef_float_2;\n"); + printf("#define Sleef_float_2_DEFINED\n"); + printf("#endif\n"); + printf("\n"); + } + + //printf("typedef %s vint2_%s;\n", vint2name, isaname); + //printf("\n"); + + for(int i=0;funcList[i].name != NULL;i++) { + switch(funcList[i].funcType) { + case 0: + if (funcList[i].ulp >= 0) { + printf("%sSLEEF_IMPORT SLEEF_CONST %s Sleef_%sf%s_u%02d%s(%s)%s;\n", + str_omp_simd_sp, + vfloatname, + funcList[i].name, wsp, + funcList[i].ulp, isaname, + vfloatname, + vectorcc); + if (atrPrefix != NULL) { + printf("SLEEF_IMPORT SLEEF_CONST %s Sleef_%s%sf%s_u%02d%s(%s)%s;\n", + vfloatname, + atrPrefix, funcList[i].name, wsp, + funcList[i].ulp, isaname, + vfloatname, + vectorcc); + } + } else { + printf("%sSLEEF_IMPORT SLEEF_CONST %s Sleef_%sf%s%s%s(%s)%s;\n", + str_omp_simd_sp, + vfloatname, + funcList[i].name, wsp, + isaub, isaname, + vfloatname, + vectorcc); + if (atrPrefix != NULL) { + printf("SLEEF_IMPORT SLEEF_CONST %s Sleef_%s%sf%s%s%s(%s)%s;\n", + vfloatname, + atrPrefix, funcList[i].name, wsp, + isaub, isaname, + vfloatname, + vectorcc); + } + } + break; + case 1: + if (funcList[i].ulp >= 0) { + printf("%sSLEEF_IMPORT SLEEF_CONST %s Sleef_%sf%s_u%02d%s(%s, %s)%s;\n", + str_omp_simd_sp, + vfloatname, + funcList[i].name, wsp, + funcList[i].ulp, isaname, + vfloatname, vfloatname, vectorcc); + if (atrPrefix != NULL) { + printf("SLEEF_IMPORT SLEEF_CONST %s Sleef_%s%sf%s_u%02d%s(%s, %s)%s;\n", + vfloatname, + atrPrefix, funcList[i].name, wsp, + funcList[i].ulp, isaname, + vfloatname, vfloatname, + vectorcc); + } + } else { + printf("%sSLEEF_IMPORT SLEEF_CONST %s Sleef_%sf%s%s%s(%s, %s)%s;\n", + str_omp_simd_sp, + vfloatname, + funcList[i].name, wsp, + isaub, isaname, + vfloatname, vfloatname, + vectorcc); + if (atrPrefix != NULL) { + printf("SLEEF_IMPORT SLEEF_CONST %s Sleef_%s%sf%s%s%s(%s, %s)%s;\n", + vfloatname, + atrPrefix, funcList[i].name, wsp, + isaub, isaname, + vfloatname, vfloatname, + vectorcc); + } + } + break; + case 2: + case 6: + if (funcList[i].ulp >= 0) { + printf("SLEEF_IMPORT SLEEF_CONST Sleef_%s_2 Sleef_%sf%s_u%02d%s(%s)%s;\n", + vfloatname_escspace, + funcList[i].name, wsp, + funcList[i].ulp, isaname, + vfloatname, + vectorcc); + if (atrPrefix != NULL) { + printf("SLEEF_IMPORT SLEEF_CONST Sleef_%s_2 Sleef_%s%sf%s_u%02d%s(%s)%s;\n", + vfloatname_escspace, + atrPrefix, funcList[i].name, wsp, + funcList[i].ulp, isaname, + vfloatname, + vectorcc); + } + } else { + printf("SLEEF_IMPORT SLEEF_CONST Sleef_%s_2 Sleef_%sf%s%s%s(%s)%s;\n", + vfloatname_escspace, + funcList[i].name, wsp, + isaub, isaname, + vfloatname, + vectorcc); + if (atrPrefix != NULL) { + printf("SLEEF_IMPORT SLEEF_CONST Sleef_%s_2 Sleef_%s%sf%s%s%s(%s)%s;\n", + vfloatname_escspace, + atrPrefix, funcList[i].name, wsp, + isaub, isaname, + vfloatname, + vectorcc); + } + } + break; + /* + case 3: + printf("SLEEF_IMPORT SLEEF_CONST %s Sleef_%sf%d_%s(%s, vint2_%s);\n", + vfloatname, + funcList[i].name, wsp, + isaname, + vfloatname, isaname); + break; + case 4: + printf("SLEEF_IMPORT SLEEF_CONST vint2_%s Sleef_%sf%d_%s(%s);\n", + isaname, + funcList[i].name, wsp, + isaname, + vfloatname); + break; + */ + case 5: + if (funcList[i].ulp >= 0) { + printf("%sSLEEF_IMPORT SLEEF_CONST %s Sleef_%sf%s_u%02d%s(%s, %s, %s)%s;\n", + str_omp_simd_sp, + vfloatname, + funcList[i].name, wsp, + funcList[i].ulp, isaname, + vfloatname, vfloatname, vfloatname, + vectorcc); + if (atrPrefix != NULL) { + printf("SLEEF_IMPORT SLEEF_CONST %s Sleef_%s%sf%s_u%02d%s(%s, %s, %s)%s;\n", + vfloatname, + atrPrefix, funcList[i].name, wsp, + funcList[i].ulp, isaname, + vfloatname, vfloatname, vfloatname, + vectorcc); + } + } else { + printf("%sSLEEF_IMPORT SLEEF_CONST %s Sleef_%sf%s%s%s(%s, %s, %s)%s;\n", + str_omp_simd_sp, + vfloatname, + funcList[i].name, wsp, + isaub, isaname, + vfloatname, vfloatname, vfloatname, + vectorcc); + if (atrPrefix != NULL) { + printf("SLEEF_IMPORT SLEEF_CONST %s Sleef_%s%sf%s%s%s(%s, %s, %s)%s;\n", + vfloatname, + atrPrefix, funcList[i].name, wsp, + isaub, isaname, + vfloatname, vfloatname, vfloatname, + vectorcc); + } + } + break; + // The two cases below should not use vector calling convention. + // See comments for double precision case above. + case 7: + printf("SLEEF_IMPORT SLEEF_CONST int Sleef_%sf%s%s%s(int);\n", + funcList[i].name, wsp, isaub, isaname); + if (atrPrefix != NULL) { + printf("SLEEF_IMPORT SLEEF_CONST int Sleef_%s%sf%s%s%s(int);\n", + atrPrefix, funcList[i].name, wsp, isaub, isaname); + } + break; + case 8: + printf("SLEEF_IMPORT SLEEF_CONST void *Sleef_%sf%s%s%s(int);\n", + funcList[i].name, wsp, isaub, isaname); + if (atrPrefix != NULL) { + printf("SLEEF_IMPORT SLEEF_CONST void *Sleef_%s%sf%s%s%s(int);\n", + atrPrefix, funcList[i].name, wsp, isaub, isaname); + } + break; + } + } + + printf("#endif\n"); + + free(vdoublename_escspace); + free(vfloatname_escspace); + free(vintname_escspace); + free(vint2name_escspace); + } + + exit(0); +} diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/mkrename_gnuabi.c b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/mkrename_gnuabi.c new file mode 100644 index 00000000000..ed7ab9164dc --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/mkrename_gnuabi.c @@ -0,0 +1,100 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include + +#include "funcproto.h" + +int main(int argc, char **argv) { + if (argc < 5) { + fprintf(stderr, "Usage : %s \n", argv[0]); + exit(-1); + } + + char *isaname = argv[1]; + char *mangledisa = argv[2]; + char *wdp = argv[3]; + char *wsp = argv[4]; + + // VLA SVE does not set the vector length in the mangled names. + if (strcmp(isaname, "sve") == 0) + wdp = wsp = "x"; + + static char *ulpSuffixStr[] = { "", "_u1", "_u05", "_u35", "_u15", "_u3500" }; + static char *vparameterStrDP[] = { "v", "vv", "vl8l8", "vv", "v", "vvv", "vl8" }; + static char *vparameterStrSP[] = { "v", "vv", "vl4l4", "vv", "v", "vvv", "vl4" }; + + for(int i=0;funcList[i].name != NULL;i++) { + if ((funcList[i].flags & 1) != 0) continue; + if ((funcList[i].flags & 2) != 0) continue; + if (funcList[i].ulp < 0) { + printf("#define x%s _ZGV%sN%s%s_%s\n", funcList[i].name, + mangledisa, wdp, vparameterStrDP[funcList[i].funcType], funcList[i].name); + printf("#define str_x%s \"_ZGV%sN%s%s_%s\"\n", funcList[i].name, + mangledisa, wdp, vparameterStrDP[funcList[i].funcType], funcList[i].name); + printf("#define __%s_finite _ZGV%sN%s%s___%s_finite\n", funcList[i].name, + mangledisa, wdp, vparameterStrDP[funcList[i].funcType], funcList[i].name); + } else if (funcList[i].ulp < 20) { + printf("#define x%s%s _ZGV%sN%s%s_%s\n", + funcList[i].name, ulpSuffixStr[funcList[i].ulpSuffix], + mangledisa, wdp, vparameterStrDP[funcList[i].funcType], funcList[i].name); + printf("#define str_x%s%s \"_ZGV%sN%s%s_%s\"\n", + funcList[i].name, ulpSuffixStr[funcList[i].ulpSuffix], + mangledisa, wdp, vparameterStrDP[funcList[i].funcType], funcList[i].name); + printf("#define __%s%s_finite _ZGV%sN%s%s___%s_finite\n", + funcList[i].name, ulpSuffixStr[funcList[i].ulpSuffix], + mangledisa, wdp, vparameterStrDP[funcList[i].funcType], funcList[i].name); + } else { + printf("#define x%s%s _ZGV%sN%s%s_%s_u%d\n", + funcList[i].name, ulpSuffixStr[funcList[i].ulpSuffix], + mangledisa, wdp, vparameterStrDP[funcList[i].funcType], funcList[i].name, funcList[i].ulp); + printf("#define str_x%s%s \"_ZGV%sN%s%s_%s_u%d\"\n", + funcList[i].name, ulpSuffixStr[funcList[i].ulpSuffix], + mangledisa, wdp, vparameterStrDP[funcList[i].funcType], funcList[i].name, funcList[i].ulp); + printf("#define __%s%s_finite _ZGV%sN%s%s___%s_finite\n", + funcList[i].name, ulpSuffixStr[funcList[i].ulpSuffix], + mangledisa, wdp, vparameterStrDP[funcList[i].funcType], funcList[i].name); + } + } + + printf("\n"); + + for(int i=0;funcList[i].name != NULL;i++) { + if ((funcList[i].flags & 1) != 0) continue; + if (funcList[i].ulp < 0) { + printf("#define x%sf _ZGV%sN%s%s_%sf\n", funcList[i].name, + mangledisa, wsp, vparameterStrSP[funcList[i].funcType], funcList[i].name); + printf("#define str_x%sf \"_ZGV%sN%s%s_%sf\"\n", funcList[i].name, + mangledisa, wsp, vparameterStrSP[funcList[i].funcType], funcList[i].name); + printf("#define __%sf_finite _ZGV%sN%s%s___%sf_finite\n", funcList[i].name, + mangledisa, wsp, vparameterStrSP[funcList[i].funcType], funcList[i].name); + } else if (funcList[i].ulp < 20) { + printf("#define x%sf%s _ZGV%sN%s%s_%sf\n", + funcList[i].name, ulpSuffixStr[funcList[i].ulpSuffix], + mangledisa, wsp, vparameterStrSP[funcList[i].funcType], funcList[i].name); + printf("#define str_x%sf%s \"_ZGV%sN%s%s_%sf\"\n", + funcList[i].name, ulpSuffixStr[funcList[i].ulpSuffix], + mangledisa, wsp, vparameterStrSP[funcList[i].funcType], funcList[i].name); + printf("#define __%sf%s_finite _ZGV%sN%s%s___%sf_finite\n", + funcList[i].name, ulpSuffixStr[funcList[i].ulpSuffix], + mangledisa, wsp, vparameterStrSP[funcList[i].funcType], funcList[i].name); + } else { + printf("#define x%sf%s _ZGV%sN%s%s_%sf_u%d\n", + funcList[i].name, ulpSuffixStr[funcList[i].ulpSuffix], + mangledisa, wsp, vparameterStrSP[funcList[i].funcType], funcList[i].name, funcList[i].ulp); + printf("#define str_x%sf%s \"_ZGV%sN%s%s_%sf_u%d\"\n", + funcList[i].name, ulpSuffixStr[funcList[i].ulpSuffix], + mangledisa, wsp, vparameterStrSP[funcList[i].funcType], funcList[i].name, funcList[i].ulp); + printf("#define __%sf%s_finite _ZGV%sN%s%s___%sf_finite\n", + funcList[i].name, ulpSuffixStr[funcList[i].ulpSuffix], + mangledisa, wsp, vparameterStrSP[funcList[i].funcType], funcList[i].name); + } + } + + exit(0); +} diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/norename.h b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/norename.h new file mode 100644 index 00000000000..e8b3ae6babc --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/norename.h @@ -0,0 +1,203 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include + +#ifdef ENABLE_DP +#ifdef ENABLE_SVE +typedef svfloat64x2_t vdouble2; +#else +typedef struct { + vdouble x, y; +} vdouble2; +#endif + +vdouble xldexp(vdouble x, vint q); +vint xilogb(vdouble d); + +vdouble xsin(vdouble d); +vdouble xcos(vdouble d); +vdouble2 xsincos(vdouble d); +vdouble xtan(vdouble d); +vdouble xasin(vdouble s); +vdouble xacos(vdouble s); +vdouble xatan(vdouble s); +vdouble xatan2(vdouble y, vdouble x); +vdouble xlog(vdouble d); +vdouble xexp(vdouble d); +vdouble xpow(vdouble x, vdouble y); + +vdouble xsinh(vdouble d); +vdouble xcosh(vdouble d); +vdouble xtanh(vdouble d); +vdouble xsinh_u35(vdouble d); +vdouble xcosh_u35(vdouble d); +vdouble xtanh_u35(vdouble d); +vdouble xasinh(vdouble s); +vdouble xacosh(vdouble s); +vdouble xatanh(vdouble s); + +vdouble xcbrt(vdouble d); + +vdouble xexp2(vdouble a); +vdouble xexp10(vdouble a); +vdouble xexp2_u35(vdouble a); +vdouble xexp10_u35(vdouble a); +vdouble xexpm1(vdouble a); +vdouble xlog10(vdouble a); +vdouble xlog2(vdouble a); +vdouble xlog2_u35(vdouble a); +vdouble xlog1p(vdouble a); + +vdouble xsin_u1(vdouble d); +vdouble xcos_u1(vdouble d); +vdouble2 xsincos_u1(vdouble d); +vdouble xtan_u1(vdouble d); +vdouble xasin_u1(vdouble s); +vdouble xacos_u1(vdouble s); +vdouble xatan_u1(vdouble s); +vdouble xatan2_u1(vdouble y, vdouble x); +vdouble xlog_u1(vdouble d); +vdouble xcbrt_u1(vdouble d); + +vdouble2 xsincospi_u05(vdouble d); +vdouble2 xsincospi_u35(vdouble d); +vdouble xsinpi_u05(vdouble d); +vdouble xcospi_u05(vdouble d); + +vdouble xldexp(vdouble, vint); +vint xilogb(vdouble); +vdouble xfma(vdouble, vdouble, vdouble); +vdouble xsqrt(vdouble); +vdouble xsqrt_u05(vdouble); +vdouble xsqrt_u35(vdouble); + +vdouble xhypot_u05(vdouble, vdouble); +vdouble xhypot_u35(vdouble, vdouble); + +vdouble xfabs(vdouble); +vdouble xcopysign(vdouble, vdouble); +vdouble xfmax(vdouble, vdouble); +vdouble xfmin(vdouble, vdouble); +vdouble xfdim(vdouble, vdouble); +vdouble xtrunc(vdouble); +vdouble xfloor(vdouble); +vdouble xceil(vdouble); +vdouble xround(vdouble); +vdouble xrint(vdouble); +vdouble xnextafter(vdouble, vdouble); +vdouble xfrfrexp(vdouble); +vint xexpfrexp(vdouble); +vdouble xfmod(vdouble, vdouble); +vdouble xremainder(vdouble, vdouble); +vdouble2 xmodf(vdouble); + +vdouble xlgamma_u1(vdouble); +vdouble xtgamma_u1(vdouble); + +vdouble xerf_u1(vdouble); +vdouble xerfc_u15(vdouble); +#endif + +// + +#ifdef ENABLE_SP +#ifdef ENABLE_SVE +typedef svfloat32x2_t vfloat2; +#else +typedef struct { + vfloat x, y; +} vfloat2; +#endif + +vfloat xldexpf(vfloat x, vint2 q); +vint2 xilogbf(vfloat d); + +vfloat xsinf(vfloat d); +vfloat xcosf(vfloat d); +vfloat2 xsincosf(vfloat d); +vfloat xtanf(vfloat d); +vfloat xasinf(vfloat s); +vfloat xacosf(vfloat s); +vfloat xatanf(vfloat s); +vfloat xatan2f(vfloat y, vfloat x); +vfloat xlogf(vfloat d); +vfloat xexpf(vfloat d); +vfloat xcbrtf(vfloat s); + +vfloat xpowf(vfloat x, vfloat y); +vfloat xsinhf(vfloat x); +vfloat xcoshf(vfloat x); +vfloat xtanhf(vfloat x); +vfloat xsinhf_u35(vfloat x); +vfloat xcoshf_u35(vfloat x); +vfloat xtanhf_u35(vfloat x); +vfloat xasinhf(vfloat x); +vfloat xacoshf(vfloat x); +vfloat xatanhf(vfloat x); +vfloat xexp2f(vfloat a); +vfloat xexp10f(vfloat a); +vfloat xexp2f_u35(vfloat a); +vfloat xexp10f_u35(vfloat a); +vfloat xexpm1f(vfloat a); +vfloat xlog10f(vfloat a); +vfloat xlog2f(vfloat a); +vfloat xlog2f_u35(vfloat a); +vfloat xlog1pf(vfloat a); + +vfloat xsinf_u1(vfloat d); +vfloat xcosf_u1(vfloat d); +vfloat2 xsincosf_u1(vfloat d); +vfloat xtanf_u1(vfloat d); +vfloat xasinf_u1(vfloat s); +vfloat xacosf_u1(vfloat s); +vfloat xatanf_u1(vfloat s); +vfloat xatan2f_u1(vfloat y, vfloat x); +vfloat xlogf_u1(vfloat d); +vfloat xcbrtf_u1(vfloat s); + +vfloat2 xsincospif_u05(vfloat d); +vfloat2 xsincospif_u35(vfloat d); +vfloat xsinpif_u05(vfloat d); +vfloat xcospif_u05(vfloat d); + + +vfloat xldexpf(vfloat, vint2); +vint2 xilogbf(vfloat); +vfloat xfmaf(vfloat, vfloat, vfloat); +vfloat xsqrtf(vfloat s); +vfloat xsqrtf_u05(vfloat s); +vfloat xsqrtf_u35(vfloat s); + +vfloat xhypotf_u05(vfloat, vfloat); +vfloat xhypotf_u35(vfloat, vfloat); + +vfloat xfabsf(vfloat); +vfloat xcopysignf(vfloat, vfloat); +vfloat xfmaxf(vfloat, vfloat); +vfloat xfminf(vfloat, vfloat); +vfloat xfdimf(vfloat, vfloat); +vfloat xtruncf(vfloat); +vfloat xfloorf(vfloat); +vfloat xceilf(vfloat); +vfloat xroundf(vfloat); +vfloat xrintf(vfloat); +vfloat xnextafterf(vfloat, vfloat); +vfloat xfrfrexpf(vfloat); +vint2 xexpfrexpf(vfloat); +vfloat xfmodf(vfloat, vfloat); +vfloat xremainderf(vfloat, vfloat); +vfloat2 xmodff(vfloat); + +vfloat xlgammaf_u1(vfloat); +vfloat xtgammaf_u1(vfloat); + +vfloat xerff_u1(vfloat); +vfloat xerfcf_u15(vfloat); + +vfloat xfastsinf_u3500(vfloat d); +vfloat xfastcosf_u3500(vfloat d); +vfloat xfastpowf_u3500(vfloat x, vfloat y); +#endif diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/rempitab.c b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/rempitab.c new file mode 100644 index 00000000000..b174bc7bdc1 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/rempitab.c @@ -0,0 +1,1092 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include "misc.h" + +#if !defined(SLEEF_GENHEADER) +#define FUNCATR NOEXPORT ALIGNED(64) +#else +#define FUNCATR EXPORT ALIGNED(64) +#endif + +FUNCATR const double Sleef_rempitabdp[] = { + 0.15915494309189531785, 1.7916237278037667488e-17, 2.5454160968749269937e-33, 2.1132476107887107169e-49, + 0.03415494309189533173, 4.0384494702232122736e-18, 1.0046721413651383112e-33, 2.1132476107887107169e-49, + 0.03415494309189533173, 4.0384494702232122736e-18, 1.0046721413651383112e-33, 2.1132476107887107169e-49, + 0.0029049430918953351999, 5.6900251826959904774e-19, 4.1707169171520598517e-35, -2.496415728504571394e-51, + 0.0029049430918953351999, 5.6900251826959904774e-19, 4.1707169171520598517e-35, -2.496415728504571394e-51, + 0.0029049430918953351999, 5.6900251826959904774e-19, 4.1707169171520598517e-35, -2.496415728504571394e-51, + 0.0029049430918953351999, 5.6900251826959904774e-19, 4.1707169171520598517e-35, -2.496415728504571394e-51, + 0.00095181809189533563356, 1.3532164927539732229e-19, -6.4410794381603004826e-36, 1.7634898158762436344e-52, + 0.00095181809189533563356, 1.3532164927539732229e-19, -6.4410794381603004826e-36, 1.7634898158762436344e-52, + 0.00046353684189533574198, 2.6901432026846872871e-20, -4.2254836195018827479e-37, 9.301187206862134399e-54, + 0.00021939621689533574198, 2.6901432026846872871e-20, -4.2254836195018827479e-37, 9.301187206862134399e-54, + 9.7325904395335769087e-05, -2.0362228529073840241e-22, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 3.6290748145335769087e-05, -2.0362228529073840241e-22, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 5.7731700203357690874e-06, -2.0362228529073840241e-22, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 5.7731700203357690874e-06, -2.0362228529073840241e-22, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 5.7731700203357690874e-06, -2.0362228529073840241e-22, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 1.9584727547107690874e-06, -2.0362228529073840241e-22, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 5.1124121898268875627e-08, 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 5.1124121898268875627e-08, 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 5.1124121898268875627e-08, 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 5.1124121898268875627e-08, 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 5.1124121898268875627e-08, 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 5.1124121898268875627e-08, 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 2.1321799510573569745e-08, 1.5185066224124613304e-24, 2.6226236120327253511e-40, 2.6283399642369025999e-57, + 6.4206383167259151492e-09, -1.3585460269359374382e-25, -1.3244127270701094468e-41, -2.4695541513869446866e-57, + 6.4206383167259151492e-09, -1.3585460269359374382e-25, -1.3244127270701094468e-41, -2.4695541513869446866e-57, + 2.6953480182640010867e-09, -1.3585460269359374382e-25, -1.3244127270701094468e-41, -2.4695541513869446866e-57, + 8.3270286903304384868e-10, 7.0940550444663151936e-26, 9.7147467687967058732e-42, 7.9392906424978921242e-59, + 8.3270286903304384868e-10, 7.0940550444663151936e-26, 9.7147467687967058732e-42, 7.9392906424978921242e-59, + 3.6704158172530459087e-10, 7.0940550444663151936e-26, 9.7147467687967058732e-42, 7.9392906424978921242e-59, + 1.3421093807143501366e-10, 1.9241762160098927996e-26, 3.9750282589222551507e-42, 7.9392906424978921242e-59, + 1.7795616244500218596e-11, -1.452834466126541428e-28, -1.5869767474823787636e-44, -2.6168913164368963837e-61, + 1.7795616244500218596e-11, -1.452834466126541428e-28, -1.5869767474823787636e-44, -2.6168913164368963837e-61, + 1.7795616244500218596e-11, -1.452834466126541428e-28, -1.5869767474823787636e-44, -2.6168913164368963837e-61, + 3.2437010161333667893e-12, -1.452834466126541428e-28, -1.5869767474823787636e-44, -2.6168913164368963837e-61, + 3.2437010161333667893e-12, -1.452834466126541428e-28, -1.5869767474823787636e-44, -2.6168913164368963837e-61, + 3.2437010161333667893e-12, -1.452834466126541428e-28, -1.5869767474823787636e-44, -2.6168913164368963837e-61, + 1.4247116125875099096e-12, 2.5861333686050385673e-28, 2.8971783383570358633e-44, -2.6168913164368963837e-61, + 5.1521691081458187359e-13, 5.6664945123924856962e-29, 6.5510079543732854985e-45, -2.6168913164368963837e-61, + 6.0469559928117805118e-14, 6.1778471897801070206e-30, 9.4581409707401690366e-46, 4.9461632249367446986e-62, + 6.0469559928117805118e-14, 6.1778471897801070206e-30, 9.4581409707401690366e-46, 4.9461632249367446986e-62, + 6.0469559928117805118e-14, 6.1778471897801070206e-30, 9.4581409707401690366e-46, 4.9461632249367446986e-62, + 3.6261410673097965595e-15, -1.3304005198798645927e-31, -1.7578597149294783985e-47, 8.4432539107728104262e-64, + 3.6261410673097965595e-15, -1.3304005198798645927e-31, -1.7578597149294783985e-47, 8.4432539107728104262e-64, + 3.6261410673097965595e-15, -1.3304005198798645927e-31, -1.7578597149294783985e-47, 8.4432539107728104262e-64, + 3.6261410673097965595e-15, -1.3304005198798645927e-31, -1.7578597149294783985e-47, 8.4432539107728104262e-64, + 7.3427388509295482183e-17, 1.4871367740953237822e-32, -1.1571307704883330232e-48, -6.7249112515659578102e-65, + 7.3427388509295482183e-17, 1.4871367740953237822e-32, -1.1571307704883330232e-48, -6.7249112515659578102e-65, + 7.3427388509295482183e-17, 1.4871367740953237822e-32, -1.1571307704883330232e-48, -6.7249112515659578102e-65, + 7.3427388509295482183e-17, 1.4871367740953237822e-32, -1.1571307704883330232e-48, -6.7249112515659578102e-65, + 7.3427388509295482183e-17, 1.4871367740953237822e-32, -1.1571307704883330232e-48, -6.7249112515659578102e-65, + 7.3427388509295482183e-17, 1.4871367740953237822e-32, -1.1571307704883330232e-48, -6.7249112515659578102e-65, + 1.7916237278037667488e-17, 2.5454160968749269937e-33, 2.1132476107887107169e-49, 8.7154294504188129325e-66, + 1.7916237278037667488e-17, 2.5454160968749269937e-33, 2.1132476107887107169e-49, 8.7154294504188129325e-66, + 4.0384494702232122736e-18, 1.0046721413651383112e-33, 2.1132476107887107169e-49, 8.7154294504188129325e-66, + 4.0384494702232122736e-18, 1.0046721413651383112e-33, 2.1132476107887107169e-49, 8.7154294504188129325e-66, + 5.6900251826959904774e-19, 4.1707169171520598517e-35, -2.4964157285045710972e-51, -1.866653112309982615e-67, + 5.6900251826959904774e-19, 4.1707169171520598517e-35, -2.4964157285045710972e-51, -1.866653112309982615e-67, + 5.6900251826959904774e-19, 4.1707169171520598517e-35, -2.4964157285045710972e-51, -1.866653112309982615e-67, + 1.3532164927539732229e-19, -6.4410794381603004826e-36, 1.7634898158762432635e-52, 3.5887057810247033998e-68, + 1.3532164927539732229e-19, -6.4410794381603004826e-36, 1.7634898158762432635e-52, 3.5887057810247033998e-68, + 2.6901432026846872871e-20, -4.2254836195018827479e-37, 9.3011872068621332399e-54, 1.113250147552460308e-69, + 2.6901432026846872871e-20, -4.2254836195018827479e-37, 9.3011872068621332399e-54, 1.113250147552460308e-69, + 2.6901432026846872871e-20, -4.2254836195018827479e-37, 9.3011872068621332399e-54, 1.113250147552460308e-69, + 1.3348904870778067446e-20, -4.2254836195018827479e-37, 9.3011872068621332399e-54, 1.113250147552460308e-69, + 6.5726412927436632287e-21, 1.0820844071023395684e-36, 1.7634898158762432635e-52, 3.5887057810247033998e-68, + 3.1845095037264626247e-21, 3.2976802257607573031e-37, 9.3011872068621332399e-54, 1.113250147552460308e-69, + 1.4904436092178623228e-21, -4.6390169687056261795e-38, -1.1392999419355048437e-54, -4.587677453735884283e-71, + 6.4341066196356198368e-22, -4.6390169687056261795e-38, -1.1392999419355048437e-54, -4.587677453735884283e-71, + 2.1989418833641172011e-22, 4.7649378378726728402e-38, 9.3011872068621332399e-54, 1.113250147552460308e-69, + 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, + 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, + 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, + 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, + 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, + 1.5185066224124613304e-24, 2.6226236120327253511e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, + 1.5185066224124613304e-24, 2.6226236120327253511e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, + 1.5185066224124613304e-24, 2.6226236120327253511e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, + 6.9132600985943383921e-25, 7.8591368887290111994e-41, 2.6283399642369020339e-57, 5.3358074162805516304e-73, + 2.7773570358292009361e-25, -1.3244127270701094468e-41, -2.4695541513869446866e-57, -3.2399200798614356002e-74, + 7.0940550444663151936e-26, 9.7147467687967058732e-42, 7.9392906424978921242e-59, 2.9745456030524896742e-75, + 7.0940550444663151936e-26, 9.7147467687967058732e-42, 7.9392906424978921242e-59, 2.9745456030524896742e-75, + 1.9241762160098927996e-26, 3.9750282589222551507e-42, 7.9392906424978921242e-59, 2.9745456030524896742e-75, + 1.9241762160098927996e-26, 3.9750282589222551507e-42, 7.9392906424978921242e-59, 2.9745456030524896742e-75, + 6.317065088957874881e-27, -3.2976062348358281152e-43, -2.6168913164368963837e-61, 3.7036201000008290615e-78, + 6.317065088957874881e-27, -3.2976062348358281152e-43, -2.6168913164368963837e-61, 3.7036201000008290615e-78, + 3.0858908211726098086e-27, 3.8770419025072344914e-43, 7.9392906424978921242e-59, 2.9745456030524896742e-75, + 1.4703036872799779898e-27, 2.8971783383570358633e-44, -2.6168913164368963837e-61, 3.7036201000008290615e-78, + 6.625101203336619011e-28, 2.8971783383570358633e-44, -2.6168913164368963837e-61, 3.7036201000008290615e-78, + 2.5861333686050385673e-28, 2.8971783383570358633e-44, -2.6168913164368963837e-61, 3.7036201000008290615e-78, + 5.6664945123924856962e-29, 6.5510079543732854985e-45, -2.6168913164368963837e-61, 3.7036201000008290615e-78, + 5.6664945123924856962e-29, 6.5510079543732854985e-45, -2.6168913164368963837e-61, 3.7036201000008290615e-78, + 6.1778471897801070206e-30, 9.4581409707401690366e-46, 4.9461632249367446986e-62, 3.7036201000008290615e-78, + 6.1778471897801070206e-30, 9.4581409707401690366e-46, 4.9461632249367446986e-62, 3.7036201000008290615e-78, + 6.1778471897801070206e-30, 9.4581409707401690366e-46, 4.9461632249367446986e-62, 3.7036201000008290615e-78, + 6.1778471897801070206e-30, 9.4581409707401690366e-46, 4.9461632249367446986e-62, 3.7036201000008290615e-78, + 3.0224035688960604996e-30, 2.451648649116083682e-46, 4.9461632249367446986e-62, 3.7036201000008290615e-78, + 1.4446817584540368888e-30, 2.451648649116083682e-46, 4.9461632249367446986e-62, 3.7036201000008290615e-78, + 6.5582085323302525856e-31, 7.0002556871006273225e-47, 1.0567786762735315635e-62, -6.1446417754639313137e-79, + 2.6139040062251944343e-31, -1.7578597149294783985e-47, 8.4432539107728090768e-64, 1.9517662449371102229e-79, + 6.4175174317266470186e-32, 4.3166913557804827486e-48, 8.4432539107728090768e-64, 1.9517662449371102229e-79, + 6.4175174317266470186e-32, 4.3166913557804827486e-48, 8.4432539107728090768e-64, 1.9517662449371102229e-79, + 1.4871367740953237822e-32, -1.1571307704883330232e-48, -6.7249112515659569668e-65, -7.2335760163150273591e-81, + 1.4871367740953237822e-32, -1.1571307704883330232e-48, -6.7249112515659569668e-65, -7.2335760163150273591e-81, + 2.5454160968749269937e-33, 2.1132476107887107169e-49, 8.7154294504188118783e-66, 1.2001823382693912203e-81, + 2.5454160968749269937e-33, 2.1132476107887107169e-49, 8.7154294504188118783e-66, 1.2001823382693912203e-81, + 2.5454160968749269937e-33, 2.1132476107887107169e-49, 8.7154294504188118783e-66, 1.2001823382693912203e-81, + 1.0046721413651383112e-33, 2.1132476107887107169e-49, 8.7154294504188118783e-66, 1.2001823382693912203e-81, + 2.3430016361024414106e-34, 4.0267819632970559834e-50, -7.8013829534098555144e-67, -1.1759240463442418271e-82, + 2.3430016361024414106e-34, 4.0267819632970559834e-50, -7.8013829534098555144e-67, -1.1759240463442418271e-82, + 4.1707169171520598517e-35, -2.4964157285045710972e-51, -1.866653112309982615e-67, 1.4185069655957361252e-83, + 4.1707169171520598517e-35, -2.4964157285045710972e-51, -1.866653112309982615e-67, 1.4185069655957361252e-83, + 4.1707169171520598517e-35, -2.4964157285045710972e-51, -1.866653112309982615e-67, 1.4185069655957361252e-83, + 1.7633044866680145008e-35, 2.8491136916798196016e-51, 4.0680767287898916022e-67, 1.4185069655957361252e-83, + 5.595982714259923599e-36, 1.7634898158762432635e-52, 3.588705781024702988e-68, 5.9489775128085140685e-84, + 5.595982714259923599e-36, 1.7634898158762432635e-52, 3.588705781024702988e-68, 5.9489775128085140685e-84, + 2.5867171761548675786e-36, 1.7634898158762432635e-52, 3.588705781024702988e-68, 5.9489775128085140685e-84, + 1.0820844071023395684e-36, 1.7634898158762432635e-52, 3.588705781024702988e-68, 5.9489775128085140685e-84, + 3.2976802257607573031e-37, 9.3011872068621332399e-54, 1.113250147552460308e-69, 2.9286284920280944778e-86, + 3.2976802257607573031e-37, 9.3011872068621332399e-54, 1.113250147552460308e-69, 2.9286284920280944778e-86, + 1.4168892644450972904e-37, 9.3011872068621332399e-54, 1.113250147552460308e-69, 2.9286284920280944778e-86, + 4.7649378378726728402e-38, 9.3011872068621332399e-54, 1.113250147552460308e-69, 2.9286284920280944778e-86, + 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 2.6226236120327253511e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 7.8591368887290111994e-41, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 7.8591368887290111994e-41, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 3.2673620808294506214e-41, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 9.7147467687967058732e-42, 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257943935e-91, + 9.7147467687967058732e-42, 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257943935e-91, + 3.9750282589222551507e-42, 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257943935e-91, + 1.1051690039850297894e-42, 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257943935e-91, + 1.1051690039850297894e-42, 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257943935e-91, + 3.8770419025072344914e-43, 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257943935e-91, + 2.8971783383570358633e-44, -2.6168913164368963837e-61, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 2.8971783383570358633e-44, -2.6168913164368963837e-61, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 2.8971783383570358633e-44, -2.6168913164368963837e-61, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 2.8971783383570358633e-44, -2.6168913164368963837e-61, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 6.5510079543732854985e-45, -2.6168913164368963837e-61, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 6.5510079543732854985e-45, -2.6168913164368963837e-61, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 9.4581409707401690366e-46, 4.9461632249367446986e-62, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 9.4581409707401690366e-46, 4.9461632249367446986e-62, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 9.4581409707401690366e-46, 4.9461632249367446986e-62, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 2.451648649116083682e-46, 4.9461632249367446986e-62, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 2.451648649116083682e-46, 4.9461632249367446986e-62, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 7.0002556871006273225e-47, 1.0567786762735315635e-62, -6.1446417754639301152e-79, -1.5355611056488084652e-94, + 7.0002556871006273225e-47, 1.0567786762735315635e-62, -6.1446417754639301152e-79, -1.5355611056488084652e-94, + 2.6211979860855749482e-47, 8.4432539107728090768e-64, 1.9517662449371099233e-79, 2.62202614552995759e-95, + 4.3166913557804827486e-48, 8.4432539107728090768e-64, 1.9517662449371099233e-79, 2.62202614552995759e-95, + 4.3166913557804827486e-48, 8.4432539107728090768e-64, 1.9517662449371099233e-79, 2.62202614552995759e-95, + 4.3166913557804827486e-48, 8.4432539107728090768e-64, 1.9517662449371099233e-79, 2.62202614552995759e-95, + 1.5797802926460750146e-48, 2.3660905534865399025e-64, -7.2335760163150273591e-81, 2.8738690232659205689e-99, + 2.1132476107887107169e-49, 8.7154294504188118783e-66, 1.2001823382693912203e-81, 2.8738690232659205689e-99, + 2.1132476107887107169e-49, 8.7154294504188118783e-66, 1.2001823382693912203e-81, 2.8738690232659205689e-99, + 2.1132476107887107169e-49, 8.7154294504188118783e-66, 1.2001823382693912203e-81, 2.8738690232659205689e-99, + 4.0267819632970559834e-50, -7.8013829534098555144e-67, -1.1759240463442418271e-82, 2.8738690232659205689e-99, + 4.0267819632970559834e-50, -7.8013829534098555144e-67, -1.1759240463442418271e-82, 2.8738690232659205689e-99, + 4.0267819632970559834e-50, -7.8013829534098555144e-67, -1.1759240463442418271e-82, 2.8738690232659205689e-99, + 1.8885701952232994665e-50, -7.8013829534098555144e-67, -1.1759240463442418271e-82, 2.8738690232659205689e-99, + 8.1946431118642097069e-51, 1.5937536410989638719e-66, 1.459625439463388979e-82, 2.8738690232659205689e-99, + 2.8491136916798196016e-51, 4.0680767287898916022e-67, 1.4185069655957361252e-83, -7.8369062883735917115e-100, + 1.7634898158762432635e-52, 3.588705781024702988e-68, 5.9489775128085131541e-84, 1.0450891972142808004e-99, + 1.7634898158762432635e-52, 3.588705781024702988e-68, 5.9489775128085131541e-84, 1.0450891972142808004e-99, + 1.7634898158762432635e-52, 3.588705781024702988e-68, 5.9489775128085131541e-84, 1.0450891972142808004e-99, + 1.7634898158762432635e-52, 3.588705781024702988e-68, 5.9489775128085131541e-84, 1.0450891972142808004e-99, + 9.3011872068621332399e-54, 1.113250147552460308e-69, 2.9286284920280941206e-86, 2.1132026692048600853e-102, + 9.3011872068621332399e-54, 1.113250147552460308e-69, 2.9286284920280941206e-86, 2.1132026692048600853e-102, + 9.3011872068621332399e-54, 1.113250147552460308e-69, 2.9286284920280941206e-86, 2.1132026692048600853e-102, + 9.3011872068621332399e-54, 1.113250147552460308e-69, 2.9286284920280941206e-86, 2.1132026692048600853e-102, + 9.3011872068621332399e-54, 1.113250147552460308e-69, 2.9286284920280941206e-86, 2.1132026692048600853e-102, + 4.0809436324633147776e-54, -4.587677453735884283e-71, -2.8859500138942368532e-87, -5.6567402911297190423e-103, + 1.470821845263904967e-54, -4.587677453735884283e-71, -2.8859500138942368532e-87, -5.6567402911297190423e-103, + 1.6576095166419998917e-55, 2.6568658093254848067e-71, 5.1571087196495574384e-87, 3.2728487032630537605e-103, + 1.6576095166419998917e-55, 2.6568658093254848067e-71, 5.1571087196495574384e-87, 3.2728487032630537605e-103, + 1.6576095166419998917e-55, 2.6568658093254848067e-71, 5.1571087196495574384e-87, 3.2728487032630537605e-103, + 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.5242184730639744369e-90, 1.145584788913072936e-105, + 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.5242184730639744369e-90, 1.145584788913072936e-105, + 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.5242184730639744369e-90, 1.145584788913072936e-105, + 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.5242184730639744369e-90, 1.145584788913072936e-105, + 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.5242184730639744369e-90, 1.145584788913072936e-105, + 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.5242184730639744369e-90, 1.145584788913072936e-105, + 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.554706987098633963e-107, + 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.554706987098633963e-107, + 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.554706987098633963e-107, + 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.554706987098633963e-107, + 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.554706987098633963e-107, + 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.554706987098633963e-107, + 3.9565608646667614317e-59, 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.554706987098633963e-107, + 1.9651959757511960854e-59, 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.554706987098633963e-107, + 9.6951353129341363331e-60, 7.6368645294831185015e-76, 1.0603435429602168369e-91, 1.0451839188820145747e-108, + 4.7167230906452229674e-60, 7.6368645294831185015e-76, 1.0603435429602168369e-91, 1.0451839188820145747e-108, + 2.2275169795007668372e-60, 2.1097166542226745549e-76, 4.4670685979800101779e-92, 1.0451839188820145747e-108, + 9.8291392392853877215e-61, -6.5385728340754726503e-77, -1.3520652573660833788e-93, -2.3220403312043059402e-109, + 3.6061239614242446325e-61, 7.2792968540756372162e-77, 1.3988851821689310822e-92, 1.0451839188820145747e-108, + 4.9461632249367446986e-62, 3.7036201000008285821e-78, 5.6554937751584084315e-94, -1.9306041120023063932e-110, + 4.9461632249367446986e-62, 3.7036201000008285821e-78, 5.6554937751584084315e-94, -1.9306041120023063932e-110, + 4.9461632249367446986e-62, 3.7036201000008285821e-78, 5.6554937751584084315e-94, -1.9306041120023063932e-110, + 1.0567786762735315635e-62, -6.1446417754639301152e-79, -1.535561105648808199e-94, -1.9306041120023063932e-110, + 1.0567786762735315635e-62, -6.1446417754639301152e-79, -1.535561105648808199e-94, -1.9306041120023063932e-110, + 8.4432539107728090768e-64, 1.9517662449371099233e-79, 2.62202614552995759e-95, 6.5314563001514358328e-112, + 8.4432539107728090768e-64, 1.9517662449371099233e-79, 2.62202614552995759e-95, 6.5314563001514358328e-112, + 8.4432539107728090768e-64, 1.9517662449371099233e-79, 2.62202614552995759e-95, 6.5314563001514358328e-112, + 8.4432539107728090768e-64, 1.9517662449371099233e-79, 2.62202614552995759e-95, 6.5314563001514358328e-112, + 2.3660905534865399025e-64, -7.2335760163150273591e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, + 2.3660905534865399025e-64, -7.2335760163150273591e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, + 8.4679971416497210292e-65, -7.2335760163150273591e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, + 8.7154294504188118783e-66, 1.2001823382693912203e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, + 8.7154294504188118783e-66, 1.2001823382693912203e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, + 8.7154294504188118783e-66, 1.2001823382693912203e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, + 8.7154294504188118783e-66, 1.2001823382693912203e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, + 3.9676455775389135587e-66, 1.459625439463388979e-82, 2.8738690232659205689e-99, 1.8395411057335783574e-115, + 1.5937536410989638719e-66, 1.459625439463388979e-82, 2.8738690232659205689e-99, 1.8395411057335783574e-115, + 4.0680767287898916022e-67, 1.4185069655957361252e-83, -7.8369062883735917115e-100, -1.9081236411894110579e-116, + 4.0680767287898916022e-67, 1.4185069655957361252e-83, -7.8369062883735917115e-100, -1.9081236411894110579e-116, + 1.1007118082399544936e-67, 1.4185069655957361252e-83, -7.8369062883735917115e-100, -1.9081236411894110579e-116, + 1.1007118082399544936e-67, 1.4185069655957361252e-83, -7.8369062883735917115e-100, -1.9081236411894110579e-116, + 3.588705781024702988e-68, 5.9489775128085131541e-84, 1.0450891972142805974e-99, 1.8395411057335783574e-115, + 3.588705781024702988e-68, 5.9489775128085131541e-84, 1.0450891972142805974e-99, 1.8395411057335783574e-115, + 1.7341027056809927069e-68, 1.830931441234090934e-84, 1.3069928418846076386e-100, 3.1677600334418876704e-116, + 8.0680116800913756637e-69, -2.2809159455312046184e-85, -4.0748824503880445403e-101, -6.3915272253158644628e-117, + 3.4315039917320989315e-69, -2.2809159455312046184e-85, -4.0748824503880445403e-101, -6.3915272253158644628e-117, + 1.113250147552460308e-69, 2.9286284920280941206e-86, 2.1132026692048600853e-102, -4.6672632026740766185e-119, + 1.113250147552460308e-69, 2.9286284920280941206e-86, 2.1132026692048600853e-102, -4.6672632026740766185e-119, + 5.3368668650755071652e-70, 2.9286284920280941206e-86, 2.1132026692048600853e-102, -4.6672632026740766185e-119, + 2.4390495598509592076e-70, 2.9286284920280941206e-86, 2.1132026692048600853e-102, -4.6672632026740766185e-119, + 9.901409072386855505e-71, -2.8859500138942368532e-87, -5.6567402911297190423e-103, -4.6672632026740766185e-119, + 2.6568658093254848067e-71, 5.1571087196495574384e-87, 3.2728487032630532648e-103, 5.2465720993401781599e-119, + 2.6568658093254848067e-71, 5.1571087196495574384e-87, 3.2728487032630532648e-103, 5.2465720993401781599e-119, + 8.4572999356014273536e-72, 1.1355793528776598461e-87, 3.2728487032630532648e-103, 5.2465720993401781599e-119, + 8.4572999356014273536e-72, 1.1355793528776598461e-87, 3.2728487032630532648e-103, 5.2465720993401781599e-119, + 3.9294603961880721752e-72, 1.3019701118468578292e-88, -7.5747169634236195447e-105, -2.0152904854894729832e-121, + 1.6655406264813940833e-72, 1.3019701118468578292e-88, -7.5747169634236195447e-105, -2.0152904854894729832e-121, + 5.3358074162805516304e-73, 4.5242184730639744369e-90, 1.1455847889130727424e-105, 1.8573014293598455046e-121, + 5.3358074162805516304e-73, 4.5242184730639744369e-90, 1.1455847889130727424e-105, 1.8573014293598455046e-121, + 2.5059077041472040156e-73, 4.5242184730639744369e-90, 1.1455847889130727424e-105, 1.8573014293598455046e-121, + 1.0909578480805302081e-73, 4.5242184730639744369e-90, 1.1455847889130727424e-105, 1.8573014293598455046e-121, + 3.8348292004719330442e-74, 4.5242184730639744369e-90, 1.1455847889130727424e-105, 1.8573014293598455046e-121, + 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.5547069870986327528e-107, 1.6304246661326865276e-122, + 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.5547069870986327528e-107, 1.6304246661326865276e-122, + 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.5547069870986327528e-107, 1.6304246661326865276e-122, + 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.5547069870986327528e-107, 1.6304246661326865276e-122, + 7.6368645294831185015e-76, 1.0603435429602168369e-91, 1.0451839188820145747e-108, 4.2386081393205242443e-125, + 7.6368645294831185015e-76, 1.0603435429602168369e-91, 1.0451839188820145747e-108, 4.2386081393205242443e-125, + 2.1097166542226745549e-76, 4.4670685979800101779e-92, 1.0451839188820145747e-108, 4.2386081393205242443e-125, + 2.1097166542226745549e-76, 4.4670685979800101779e-92, 1.0451839188820145747e-108, 4.2386081393205242443e-125, + 7.2792968540756372162e-77, 1.3988851821689310822e-92, 1.0451839188820145747e-108, 4.2386081393205242443e-125, + 3.7036201000008285821e-78, 5.6554937751584084315e-94, -1.9306041120023063932e-110, 1.0223371855251472933e-126, + 3.7036201000008285821e-78, 5.6554937751584084315e-94, -1.9306041120023063932e-110, 1.0223371855251472933e-126, + 3.7036201000008285821e-78, 5.6554937751584084315e-94, -1.9306041120023063932e-110, 1.0223371855251472933e-126, + 3.7036201000008285821e-78, 5.6554937751584084315e-94, -1.9306041120023063932e-110, 1.0223371855251472933e-126, + 3.7036201000008285821e-78, 5.6554937751584084315e-94, -1.9306041120023063932e-110, 1.0223371855251472933e-126, + 1.5445779612272179051e-78, 8.6145718795359707834e-95, 7.3062078800278780675e-111, 1.0223371855251472933e-126, + 4.6505689184041232695e-79, 8.6145718795359707834e-95, 7.3062078800278780675e-111, 1.0223371855251472933e-126, + 4.6505689184041232695e-79, 8.6145718795359707834e-95, 7.3062078800278780675e-111, 1.0223371855251472933e-126, + 1.9517662449371099233e-79, 2.62202614552995759e-95, 6.5314563001514349095e-112, 9.9039323746573674262e-128, + 6.0236490820360325022e-80, -3.7424672147304925625e-96, -1.784871512364483542e-112, 6.7095375687163151728e-129, + 6.0236490820360325022e-80, -3.7424672147304925625e-96, -1.784871512364483542e-112, 6.7095375687163151728e-129, + 2.6501457402022643213e-80, 3.7482149527770239293e-96, 6.5314563001514349095e-112, 9.9039323746573674262e-128, + 9.6339406928538097998e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, + 1.2001823382693912203e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, + 1.2001823382693912203e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, + 1.2001823382693912203e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, + 1.459625439463388979e-82, 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, + 1.459625439463388979e-82, 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, + 1.459625439463388979e-82, 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, + 1.4185069655957361252e-83, -7.8369062883735917115e-100, -1.9081236411894107761e-116, -2.1796760241698337334e-132, + 1.4185069655957361252e-83, -7.8369062883735917115e-100, -1.9081236411894107761e-116, -2.1796760241698337334e-132, + 1.4185069655957361252e-83, -7.8369062883735917115e-100, -1.9081236411894107761e-116, -2.1796760241698337334e-132, + 1.4185069655957361252e-83, -7.8369062883735917115e-100, -1.9081236411894107761e-116, -2.1796760241698337334e-132, + 5.9489775128085131541e-84, 1.0450891972142805974e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, + 1.830931441234090934e-84, 1.3069928418846076386e-100, 3.1677600334418871069e-116, 3.4556869017247800778e-132, + 1.830931441234090934e-84, 1.3069928418846076386e-100, 3.1677600334418871069e-116, 3.4556869017247800778e-132, + 8.0141992334048515034e-85, 1.3069928418846076386e-100, 3.1677600334418871069e-116, 3.4556869017247800778e-132, + 2.8666416439368237283e-85, 1.6400545060233297363e-101, -4.6672632026740766185e-119, -3.755176715260116501e-136, + 2.9286284920280941206e-86, 2.1132026692048600853e-102, -4.6672632026740766185e-119, -3.755176715260116501e-136, + 2.9286284920280941206e-86, 2.1132026692048600853e-102, -4.6672632026740766185e-119, -3.755176715260116501e-136, + 2.9286284920280941206e-86, 2.1132026692048600853e-102, -4.6672632026740766185e-119, -3.755176715260116501e-136, + 2.9286284920280941206e-86, 2.1132026692048600853e-102, -4.6672632026740766185e-119, -3.755176715260116501e-136, + 1.3200167453193350837e-86, 2.1132026692048600853e-102, -4.6672632026740766185e-119, -3.755176715260116501e-136, + 5.1571087196495574384e-87, 3.2728487032630532648e-103, 5.2465720993401781599e-119, -3.755176715260116501e-136, + 1.1355793528776598461e-87, 3.2728487032630532648e-103, 5.2465720993401781599e-119, -3.755176715260116501e-136, + 1.1355793528776598461e-87, 3.2728487032630532648e-103, 5.2465720993401781599e-119, -3.755176715260116501e-136, + 1.3019701118468578292e-88, -7.5747169634236195447e-105, -2.0152904854894725532e-121, -3.1562414818576682143e-137, + 1.3019701118468578292e-88, -7.5747169634236195447e-105, -2.0152904854894725532e-121, -3.1562414818576682143e-137, + 1.3019701118468578292e-88, -7.5747169634236195447e-105, -2.0152904854894725532e-121, -3.1562414818576682143e-137, + 4.5242184730639744369e-90, 1.1455847889130727424e-105, 1.8573014293598452896e-121, 1.1431992269852683481e-137, + 4.5242184730639744369e-90, 1.1455847889130727424e-105, 1.8573014293598452896e-121, 1.1431992269852683481e-137, + 4.5242184730639744369e-90, 1.1455847889130727424e-105, 1.8573014293598452896e-121, 1.1431992269852683481e-137, + 4.5242184730639744369e-90, 1.1455847889130727424e-105, 1.8573014293598452896e-121, 1.1431992269852683481e-137, + 4.5242184730639744369e-90, 1.1455847889130727424e-105, 1.8573014293598452896e-121, 1.1431992269852683481e-137, + 5.969437008257942845e-91, 5.5547069870986327528e-107, 1.6304246661326865276e-122, 6.8339049774534162772e-139, + 5.969437008257942845e-91, 5.5547069870986327528e-107, 1.6304246661326865276e-122, 6.8339049774534162772e-139, + 5.969437008257942845e-91, 5.5547069870986327528e-107, 1.6304246661326865276e-122, 6.8339049774534162772e-139, + 1.0603435429602168369e-91, 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591188256e-141, + 1.0603435429602168369e-91, 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591188256e-141, + 1.0603435429602168369e-91, 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591188256e-141, + 4.4670685979800101779e-92, 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591188256e-141, + 1.3988851821689310822e-92, 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591188256e-141, + 1.3988851821689310822e-92, 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591188256e-141, + 6.3183932821616130831e-93, 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591188256e-141, + 2.4831640123977650651e-93, 1.9359195088038447797e-109, -4.8867691298577234423e-126, -2.0587960670007823264e-142, + 5.6554937751584084315e-94, -1.9306041120023063932e-110, 1.0223371855251471293e-126, 1.2214168761472102282e-142, + 5.6554937751584084315e-94, -1.9306041120023063932e-110, 1.0223371855251471293e-126, 1.2214168761472102282e-142, + 8.6145718795359707834e-95, 7.3062078800278780675e-111, 1.0223371855251471293e-126, 1.2214168761472102282e-142, + 8.6145718795359707834e-95, 7.3062078800278780675e-111, 1.0223371855251471293e-126, 1.2214168761472102282e-142, + 8.6145718795359707834e-95, 7.3062078800278780675e-111, 1.0223371855251471293e-126, 1.2214168761472102282e-142, + 2.62202614552995759e-95, 6.5314563001514349095e-112, 9.9039323746573674262e-128, -8.6629775332868987041e-145, + 2.62202614552995759e-95, 6.5314563001514349095e-112, 9.9039323746573674262e-128, -8.6629775332868987041e-145, + 1.1238897120284541253e-95, 6.5314563001514349095e-112, 9.9039323746573674262e-128, -8.6629775332868987041e-145, + 3.7482149527770239293e-96, 6.5314563001514349095e-112, 9.9039323746573674262e-128, -8.6629775332868987041e-145, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 1.0450891972142805974e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 1.3069928418846076386e-100, 3.1677600334418871069e-116, 3.4556869017247794521e-132, 8.5448727249069983612e-148, + 1.3069928418846076386e-100, 3.1677600334418871069e-116, 3.4556869017247794521e-132, 8.5448727249069983612e-148, + 1.3069928418846076386e-100, 3.1677600334418871069e-116, 3.4556869017247794521e-132, 8.5448727249069983612e-148, + 1.6400545060233297363e-101, -4.6672632026740766185e-119, -3.755176715260116501e-136, 2.1571619860435652883e-152, + 1.6400545060233297363e-101, -4.6672632026740766185e-119, -3.755176715260116501e-136, 2.1571619860435652883e-152, + 1.6400545060233297363e-101, -4.6672632026740766185e-119, -3.755176715260116501e-136, 2.1571619860435652883e-152, + 2.1132026692048600853e-102, -4.6672632026740766185e-119, -3.755176715260116501e-136, 2.1571619860435652883e-152, + 2.1132026692048600853e-102, -4.6672632026740766185e-119, -3.755176715260116501e-136, 2.1571619860435652883e-152, + 2.1132026692048600853e-102, -4.6672632026740766185e-119, -3.755176715260116501e-136, 2.1571619860435652883e-152, + 3.2728487032630532648e-103, 5.2465720993401781599e-119, -3.755176715260116501e-136, 2.1571619860435652883e-152, + 3.2728487032630532648e-103, 5.2465720993401781599e-119, -3.755176715260116501e-136, 2.1571619860435652883e-152, + 3.2728487032630532648e-103, 5.2465720993401781599e-119, -3.755176715260116501e-136, 2.1571619860435652883e-152, + 1.0404514546648604359e-103, 2.896544483330507019e-120, 3.1239284188885823808e-136, 2.1571619860435652883e-152, + 1.0404514546648604359e-103, 2.896544483330507019e-120, 3.1239284188885823808e-136, 2.1571619860435652883e-152, + 4.8235214251531210473e-104, 2.896544483330507019e-120, 3.1239284188885823808e-136, 2.1571619860435652883e-152, + 2.0330248644053793915e-104, 2.896544483330507019e-120, 3.1239284188885823808e-136, 2.1571619860435652883e-152, + 6.3777658403150887343e-105, -2.0152904854894725532e-121, -3.156241481857667737e-137, -7.0684085473731388916e-153, + 6.3777658403150887343e-105, -2.0152904854894725532e-121, -3.156241481857667737e-137, -7.0684085473731388916e-153, + 2.88964513938041089e-105, 5.7298933442091639924e-121, -3.156241481857667737e-137, -7.0684085473731388916e-153, + 1.1455847889130727424e-105, 1.8573014293598452896e-121, 1.1431992269852681095e-137, 2.4782675885631257398e-153, + 2.7355461367940366859e-106, -7.8994528064813712419e-123, -2.0037599452814940222e-138, 9.1598554579059548847e-155, + 2.7355461367940366859e-106, -7.8994528064813712419e-123, -2.0037599452814940222e-138, 9.1598554579059548847e-155, + 5.5547069870986327528e-107, 1.6304246661326865276e-122, 6.8339049774534147855e-139, 9.1598554579059548847e-155, + 5.5547069870986327528e-107, 1.6304246661326865276e-122, 6.8339049774534147855e-139, 9.1598554579059548847e-155, + 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, + 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, + 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, + 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, + 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, + 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, + 1.9359195088038447797e-109, -4.8867691298577234423e-126, -2.0587960670007819622e-142, -2.8326669474241479263e-158, + 1.9359195088038447797e-109, -4.8867691298577234423e-126, -2.0587960670007819622e-142, -2.8326669474241479263e-158, + 1.9359195088038447797e-109, -4.8867691298577234423e-126, -2.0587960670007819622e-142, -2.8326669474241479263e-158, + 8.7142954880180709975e-110, -4.8867691298577234423e-126, -2.0587960670007819622e-142, -2.8326669474241479263e-158, + 3.3918456880078814158e-110, 6.931443500908017045e-126, 1.1062055705591186799e-141, 1.1734404793201255869e-157, + 7.3062078800278780675e-111, 1.0223371855251471293e-126, 1.2214168761472102282e-142, 8.0910098773220312367e-159, + 7.3062078800278780675e-111, 1.0223371855251471293e-126, 1.2214168761472102282e-142, 8.0910098773220312367e-159, + 6.5314563001514349095e-112, 9.9039323746573674262e-128, -8.6629775332868972816e-145, -1.5987060076657616072e-160, + 6.5314563001514349095e-112, 9.9039323746573674262e-128, -8.6629775332868972816e-145, -1.5987060076657616072e-160, + 6.5314563001514349095e-112, 9.9039323746573674262e-128, -8.6629775332868972816e-145, -1.5987060076657616072e-160, + 6.5314563001514349095e-112, 9.9039323746573674262e-128, -8.6629775332868972816e-145, -1.5987060076657616072e-160, + 2.3732923938934761454e-112, 6.7095375687163138915e-129, 1.6963686085056791706e-144, 1.2464251916751375716e-160, + 2.9421044076449630171e-113, 6.7095375687163138915e-129, 1.6963686085056791706e-144, 1.2464251916751375716e-160, + 2.9421044076449630171e-113, 6.7095375687163138915e-129, 1.6963686085056791706e-144, 1.2464251916751375716e-160, + 2.9421044076449630171e-113, 6.7095375687163138915e-129, 1.6963686085056791706e-144, 1.2464251916751375716e-160, + 3.4325196623373878948e-114, 9.3892593260023063019e-130, 9.4702132359198537748e-146, 1.7950099192230045857e-161, + 3.4325196623373878948e-114, 9.3892593260023063019e-130, 9.4702132359198537748e-146, 1.7950099192230045857e-161, + 3.4325196623373878948e-114, 9.3892593260023063019e-130, 9.4702132359198537748e-146, 1.7950099192230045857e-161, + 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, 2.9106774506606945839e-164, + 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, 2.9106774506606945839e-164, + 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, 2.9106774506606945839e-164, + 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, 2.9106774506606945839e-164, + 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, 2.9106774506606945839e-164, + 8.2436437080731844263e-116, 1.4726412753514008951e-131, -3.9681466199873824165e-148, 2.9106774506606945839e-164, + 3.1677600334418871069e-116, 3.4556869017247794521e-132, 8.544872724906996972e-148, 1.6802919634942429241e-163, + 6.2981819612623816536e-117, 6.3800543877747317218e-133, 7.2423563434801054878e-149, 1.1741471776254779927e-164, + 6.2981819612623816536e-117, 6.3800543877747317218e-133, 7.2423563434801054878e-149, 1.1741471776254779927e-164, + 6.2981819612623816536e-117, 6.3800543877747317218e-133, 7.2423563434801054878e-149, 1.1741471776254779927e-164, + 3.1257546646178208289e-117, -6.6414926959353515111e-134, -5.7828074707888119584e-150, -1.2825052715093464343e-165, + 1.5395410162955400644e-117, -6.6414926959353515111e-134, -5.7828074707888119584e-150, -1.2825052715093464343e-165, + 7.4643419213439950602e-118, 1.0969016447485317626e-133, -5.7828074707888119584e-150, -1.2825052715093464343e-165, + 3.4988078005382940294e-118, 2.1637618757749825688e-134, -8.9490928918944555247e-151, -1.9717385086233606481e-166, + 1.5160407401354430737e-118, 2.1637618757749825688e-134, -8.9490928918944555247e-151, -1.9717385086233606481e-166, + 5.2465720993401781599e-119, -3.755176715260116501e-136, 2.1571619860435648643e-152, 6.3257905089784152346e-168, + 2.896544483330507019e-120, 3.1239284188885823808e-136, 2.1571619860435648643e-152, 6.3257905089784152346e-168, + 2.896544483330507019e-120, 3.1239284188885823808e-136, 2.1571619860435648643e-152, 6.3257905089784152346e-168, + 2.896544483330507019e-120, 3.1239284188885823808e-136, 2.1571619860435648643e-152, 6.3257905089784152346e-168, + 2.896544483330507019e-120, 3.1239284188885823808e-136, 2.1571619860435648643e-152, 6.3257905089784152346e-168, + 2.896544483330507019e-120, 3.1239284188885823808e-136, 2.1571619860435648643e-152, 6.3257905089784152346e-168, + 1.3475077173907800538e-120, -3.156241481857667737e-137, -7.0684085473731388916e-153, -3.3573283875161501977e-170, + 5.7298933442091639924e-121, -3.156241481857667737e-137, -7.0684085473731388916e-153, -3.3573283875161501977e-170, + 1.8573014293598452896e-121, 1.1431992269852681095e-137, 2.4782675885631257398e-153, -3.3573283875161501977e-170, + 1.8573014293598452896e-121, 1.1431992269852681095e-137, 2.4782675885631257398e-153, -3.3573283875161501977e-170, + 8.8915345064751572143e-122, 1.1431992269852681095e-137, 2.4782675885631257398e-153, -3.3573283875161501977e-170, + 4.0507946129135104481e-122, 6.8339049774534147855e-139, 9.1598554579059548847e-155, -4.5159745404911825673e-172, + 1.6304246661326865276e-122, 6.8339049774534147855e-139, 9.1598554579059548847e-155, -4.5159745404911825673e-172, + 4.2023969274227456735e-123, 6.8339049774534147855e-139, 9.1598554579059548847e-155, -4.5159745404911825673e-172, + 4.2023969274227456735e-123, 6.8339049774534147855e-139, 9.1598554579059548847e-155, -4.5159745404911825673e-172, + 1.1769344939467164447e-123, 1.1602886988632691941e-140, 3.0307583960570927356e-156, 5.8345524661064369683e-172, + 1.1769344939467164447e-123, 1.1602886988632691941e-140, 3.0307583960570927356e-156, 5.8345524661064369683e-172, + 4.2056888557770896953e-124, 1.1602886988632691941e-140, 3.0307583960570927356e-156, 5.8345524661064369683e-172, + 4.2386081393205242443e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, 1.2381024895275844856e-174, + 4.2386081393205242443e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, 1.2381024895275844856e-174, + 4.2386081393205242443e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, 1.2381024895275844856e-174, + 4.2386081393205242443e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, 1.2381024895275844856e-174, + 1.8749656131673758844e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, 1.2381024895275844856e-174, + 6.931443500908017045e-126, 1.1062055705591186799e-141, 1.1734404793201255869e-157, 1.2381024895275844856e-174, + 1.0223371855251471293e-126, 1.2214168761472102282e-142, 8.0910098773220302259e-159, 1.2381024895275844856e-174, + 1.0223371855251471293e-126, 1.2214168761472102282e-142, 8.0910098773220302259e-159, 1.2381024895275844856e-174, + 1.0223371855251471293e-126, 1.2214168761472102282e-142, 8.0910098773220302259e-159, 1.2381024895275844856e-174, + 2.8369889610228834887e-127, 4.0136364036021218058e-143, -1.0134099605688458828e-159, -2.5389576707476506925e-176, + 2.8369889610228834887e-127, 4.0136364036021218058e-143, -1.0134099605688458828e-159, -2.5389576707476506925e-176, + 9.9039323746573674262e-128, -8.6629775332868972816e-145, -1.5987060076657612913e-160, -2.5389576707476506925e-176, + 6.7095375687163138915e-129, 1.6963686085056791706e-144, 1.2464251916751375716e-160, 6.197724948400014906e-177, + 6.7095375687163138915e-129, 1.6963686085056791706e-144, 1.2464251916751375716e-160, 6.197724948400014906e-177, + 6.7095375687163138915e-129, 1.6963686085056791706e-144, 1.2464251916751375716e-160, 6.197724948400014906e-177, + 6.7095375687163138915e-129, 1.6963686085056791706e-144, 1.2464251916751375716e-160, 6.197724948400014906e-177, + 9.3892593260023063019e-130, 9.4702132359198537748e-146, 1.7950099192230045857e-161, -1.6991004655691155518e-177, + 9.3892593260023063019e-130, 9.4702132359198537748e-146, 1.7950099192230045857e-161, -1.6991004655691155518e-177, + 9.3892593260023063019e-130, 9.4702132359198537748e-146, 1.7950099192230045857e-161, -1.6991004655691155518e-177, + 2.175994780857201024e-130, 1.4618808551874518553e-146, 1.6802919634942426156e-163, 2.8330093736631818036e-179, + 2.175994780857201024e-130, 1.4618808551874518553e-146, 1.6802919634942426156e-163, 2.8330093736631818036e-179, + 3.7267864457092460442e-131, 4.6083930759590139305e-147, 1.6802919634942426156e-163, 2.8330093736631818036e-179, + 3.7267864457092460442e-131, 4.6083930759590139305e-147, 1.6802919634942426156e-163, 2.8330093736631818036e-179, + 3.7267864457092460442e-131, 4.6083930759590139305e-147, 1.6802919634942426156e-163, 2.8330093736631818036e-179, + 1.4726412753514008951e-131, -3.9681466199873824165e-148, 2.9106774506606941983e-164, 5.1948630316441296498e-180, + 3.4556869017247794521e-132, 8.544872724906996972e-148, 1.6802919634942426156e-163, 2.8330093736631818036e-179, + 3.4556869017247794521e-132, 8.544872724906996972e-148, 1.6802919634942426156e-163, 2.8330093736631818036e-179, + 6.3800543877747317218e-133, 7.2423563434801054878e-149, 1.1741471776254777999e-164, 1.3389912474795152755e-180, + 6.3800543877747317218e-133, 7.2423563434801054878e-149, 1.1741471776254777999e-164, 1.3389912474795152755e-180, + 6.3800543877747317218e-133, 7.2423563434801054878e-149, 1.1741471776254777999e-164, 1.3389912474795152755e-180, + 2.8579525590905986764e-133, -5.7828074707888119584e-150, -1.2825052715093464343e-165, -1.0696067158221530218e-181, + 1.0969016447485317626e-133, -5.7828074707888119584e-150, -1.2825052715093464343e-165, -1.0696067158221530218e-181, + 2.1637618757749825688e-134, -8.9490928918944555247e-151, -1.9717385086233606481e-166, 1.3535321672928907047e-182, + 2.1637618757749825688e-134, -8.9490928918944555247e-151, -1.9717385086233606481e-166, 1.3535321672928907047e-182, + 2.1637618757749825688e-134, -8.9490928918944555247e-151, -1.9717385086233606481e-166, 1.3535321672928907047e-182, + 1.0631050543111905033e-134, 1.5490398016102376505e-150, 3.4549185946116918017e-166, 1.3535321672928907047e-182, + 5.1277664357929471499e-135, 3.2706525621039604902e-151, 7.4159004299416557678e-167, 1.3535321672928907047e-182, + 2.3761243821334675971e-135, 3.2706525621039604902e-151, 7.4159004299416557678e-167, 1.3535321672928907047e-182, + 1.0003033553037281263e-135, 2.1571619860435648643e-152, 6.3257905089784152346e-168, 3.5607241064750984115e-184, + 3.1239284188885823808e-136, 2.1571619860435648643e-152, 6.3257905089784152346e-168, 3.5607241064750984115e-184, + 3.1239284188885823808e-136, 2.1571619860435648643e-152, 6.3257905089784152346e-168, 3.5607241064750984115e-184, + 1.4041521353514076604e-136, 2.1571619860435648643e-152, 6.3257905089784152346e-168, 3.5607241064750984115e-184, + 5.4426399358282049106e-137, 2.4782675885631257398e-153, -3.3573283875161501977e-170, 3.0568054078295488291e-186, + 1.1431992269852681095e-137, 2.4782675885631257398e-153, -3.3573283875161501977e-170, 3.0568054078295488291e-186, + 1.1431992269852681095e-137, 2.4782675885631257398e-153, -3.3573283875161501977e-170, 3.0568054078295488291e-186, + 6.8339049774534147855e-139, 9.1598554579059548847e-155, -4.5159745404911819927e-172, -4.5870810097328578981e-188, + 6.8339049774534147855e-139, 9.1598554579059548847e-155, -4.5159745404911819927e-172, -4.5870810097328578981e-188, + 6.8339049774534147855e-139, 9.1598554579059548847e-155, -4.5159745404911819927e-172, -4.5870810097328578981e-188, + 6.8339049774534147855e-139, 9.1598554579059548847e-155, -4.5159745404911819927e-172, -4.5870810097328578981e-188, + 1.1602886988632691941e-140, 3.0307583960570927356e-156, 5.8345524661064358191e-172, 6.9043123899963188689e-188, + 1.1602886988632691941e-140, 3.0307583960570927356e-156, 5.8345524661064358191e-172, 6.9043123899963188689e-188, + 1.1602886988632691941e-140, 3.0307583960570927356e-156, 5.8345524661064358191e-172, 6.9043123899963188689e-188, + 1.1602886988632691941e-140, 3.0307583960570927356e-156, 5.8345524661064358191e-172, 6.9043123899963188689e-188, + 1.1602886988632691941e-140, 3.0307583960570927356e-156, 5.8345524661064358191e-172, 6.9043123899963188689e-188, + 1.1602886988632691941e-140, 3.0307583960570927356e-156, 5.8345524661064358191e-172, 6.9043123899963188689e-188, + 1.1062055705591186799e-141, 1.1734404793201255869e-157, 1.2381024895275844856e-174, -8.4789520282639751913e-191, + 1.1062055705591186799e-141, 1.1734404793201255869e-157, 1.2381024895275844856e-174, -8.4789520282639751913e-191, + 1.1062055705591186799e-141, 1.1734404793201255869e-157, 1.2381024895275844856e-174, -8.4789520282639751913e-191, + 1.1062055705591186799e-141, 1.1734404793201255869e-157, 1.2381024895275844856e-174, -8.4789520282639751913e-191, + 4.5016298192952031469e-142, -2.8326669474241479263e-158, 1.2381024895275844856e-174, -8.4789520282639751913e-191, + 1.2214168761472102282e-142, 8.0910098773220302259e-159, 1.2381024895275844856e-174, -8.4789520282639751913e-191, + 1.2214168761472102282e-142, 8.0910098773220302259e-159, 1.2381024895275844856e-174, -8.4789520282639751913e-191, + 4.0136364036021218058e-143, -1.0134099605688458828e-159, -2.5389576707476506925e-176, -6.2404128071707654958e-193, + 4.0136364036021218058e-143, -1.0134099605688458828e-159, -2.5389576707476506925e-176, -6.2404128071707654958e-193, + 1.9635033141346264592e-143, -1.0134099605688458828e-159, -2.5389576707476506925e-176, -6.2404128071707654958e-193, + 9.3843676940087855824e-144, 1.2626949989038732076e-159, 2.2730883653953564668e-175, 2.7431118386590483722e-191, + 4.2590349703400483539e-144, 1.2464251916751375716e-160, 6.1977249484000140293e-177, 1.1294061984896458822e-192, + 1.6963686085056791706e-144, 1.2464251916751375716e-160, 6.1977249484000140293e-177, 1.1294061984896458822e-192, + 4.1503542758849472122e-145, -1.7614040799531193879e-161, -1.6991004655691153326e-177, -1.856794109153959173e-193, + 4.1503542758849472122e-145, -1.7614040799531193879e-161, -1.6991004655691153326e-177, -1.856794109153959173e-193, + 9.4702132359198537748e-146, 1.7950099192230045857e-161, -1.6991004655691153326e-177, -1.856794109153959173e-193, + 9.4702132359198537748e-146, 1.7950099192230045857e-161, -1.6991004655691153326e-177, -1.856794109153959173e-193, + 1.4618808551874518553e-146, 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, + 1.4618808551874518553e-146, 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, + 1.4618808551874518553e-146, 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, + 4.6083930759590139305e-147, 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, + 4.6083930759590139305e-147, 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, + 2.105789206980137775e-147, 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, + 8.544872724906996972e-148, 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, + 2.2883630524598079723e-148, 2.9106774506606941983e-164, 5.1948630316441287936e-180, 9.6685396110091032843e-196, + 2.2883630524598079723e-148, 2.9106774506606941983e-164, 5.1948630316441287936e-180, 9.6685396110091032843e-196, + 7.2423563434801054878e-149, 1.1741471776254777999e-164, 1.3389912474795150614e-180, 1.1067843414450286726e-196, + 7.2423563434801054878e-149, 1.1741471776254777999e-164, 1.3389912474795150614e-180, 1.1067843414450286726e-196, + 3.3320377982006123631e-149, 3.0588204110786950436e-165, 3.7502330143836152136e-181, 3.6564932749519464998e-198, + 1.3768785255608653665e-149, 3.0588204110786950436e-165, 3.7502330143836152136e-181, 3.6564932749519464998e-198, + 3.9929888924099219388e-150, -1.9717385086233606481e-166, 1.3535321672928907047e-182, 3.1205762277848031878e-199, + 3.9929888924099219388e-150, -1.9717385086233606481e-166, 1.3535321672928907047e-182, 3.1205762277848031878e-199, + 1.5490398016102376505e-150, 3.4549185946116918017e-166, 1.3535321672928907047e-182, 3.1205762277848031878e-199, + 3.2706525621039604902e-151, 7.4159004299416557678e-167, 1.3535321672928907047e-182, 3.1205762277848031878e-199, + 3.2706525621039604902e-151, 7.4159004299416557678e-167, 1.3535321672928907047e-182, 3.1205762277848031878e-199, + 2.1571619860435648643e-152, 6.3257905089784152346e-168, 3.5607241064750984115e-184, -1.4832196127821708615e-201, + 2.1571619860435648643e-152, 6.3257905089784152346e-168, 3.5607241064750984115e-184, -1.4832196127821708615e-201, + 2.1571619860435648643e-152, 6.3257905089784152346e-168, 3.5607241064750984115e-184, -1.4832196127821708615e-201, + 2.1571619860435648643e-152, 6.3257905089784152346e-168, 3.5607241064750984115e-184, -1.4832196127821708615e-201, + 2.4782675885631257398e-153, -3.3573283875161501977e-170, 3.0568054078295488291e-186, 1.4980560800565462618e-202, + 2.4782675885631257398e-153, -3.3573283875161501977e-170, 3.0568054078295488291e-186, 1.4980560800565462618e-202, + 2.4782675885631257398e-153, -3.3573283875161501977e-170, 3.0568054078295488291e-186, 1.4980560800565462618e-202, + 9.1598554579059548847e-155, -4.5159745404911819927e-172, -4.5870810097328572602e-188, -3.2905064432040069127e-204, + 9.1598554579059548847e-155, -4.5159745404911819927e-172, -4.5870810097328572602e-188, -3.2905064432040069127e-204, + 9.1598554579059548847e-155, -4.5159745404911819927e-172, -4.5870810097328572602e-188, -3.2905064432040069127e-204, + 9.1598554579059548847e-155, -4.5159745404911819927e-172, -4.5870810097328572602e-188, -3.2905064432040069127e-204, + 9.1598554579059548847e-155, -4.5159745404911819927e-172, -4.5870810097328572602e-188, -3.2905064432040069127e-204, + 1.7015147267057481414e-155, -4.5159745404911819927e-172, -4.5870810097328572602e-188, -3.2905064432040069127e-204, + 1.7015147267057481414e-155, -4.5159745404911819927e-172, -4.5870810097328572602e-188, -3.2905064432040069127e-204, + 1.7015147267057481414e-155, -4.5159745404911819927e-172, -4.5870810097328572602e-188, -3.2905064432040069127e-204, + 7.6922213530572229852e-156, -4.5159745404911819927e-172, -4.5870810097328572602e-188, -3.2905064432040069127e-204, + 3.0307583960570927356e-156, 5.8345524661064358191e-172, 6.9043123899963188689e-188, -3.2905064432040069127e-204, + 7.0002691755702864582e-157, 6.5928896280762691321e-173, 1.1586156901317304854e-188, -1.0100405885278530137e-205, + 7.0002691755702864582e-157, 6.5928896280762691321e-173, 1.1586156901317304854e-188, -1.0100405885278530137e-205, + 1.1734404793201255869e-157, 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.3321093418096261919e-207, + 1.1734404793201255869e-157, 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.3321093418096261919e-207, + 1.1734404793201255869e-157, 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.3321093418096261919e-207, + 4.4508689228885539715e-158, 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.3321093418096261919e-207, + 8.0910098773220302259e-159, 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.3321093418096261919e-207, + 8.0910098773220302259e-159, 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.3321093418096261919e-207, + 8.0910098773220302259e-159, 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.3321093418096261919e-207, + 3.5387999583765925506e-159, 2.2730883653953564668e-175, 2.7431118386590483722e-191, -1.3321093418096261919e-207, + 1.2626949989038732076e-159, 2.2730883653953564668e-175, 2.7431118386590483722e-191, -1.3321093418096261919e-207, + 1.2464251916751375716e-160, 6.1977249484000140293e-177, 1.1294061984896456875e-192, 2.2526486929936882202e-208, + 1.2464251916751375716e-160, 6.1977249484000140293e-177, 1.1294061984896456875e-192, 2.2526486929936882202e-208, + 1.2464251916751375716e-160, 6.1977249484000140293e-177, 1.1294061984896456875e-192, 2.2526486929936882202e-208, + 1.2464251916751375716e-160, 6.1977249484000140293e-177, 1.1294061984896456875e-192, 2.2526486929936882202e-208, + 5.3514239183991277695e-161, 6.1977249484000140293e-177, 1.1294061984896456875e-192, 2.2526486929936882202e-208, + 1.7950099192230045857e-161, -1.6991004655691153326e-177, -1.8567941091539589297e-193, -1.8074851186411640793e-209, + 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, + 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, + 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, + 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, + 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, + 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, + 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, + 2.9106774506606941983e-164, 5.1948630316441287936e-180, 9.6685396110091013832e-196, 1.7562785002189357559e-211, + 2.9106774506606941983e-164, 5.1948630316441287936e-180, 9.6685396110091013832e-196, 1.7562785002189357559e-211, + 2.9106774506606941983e-164, 5.1948630316441287936e-180, 9.6685396110091013832e-196, 1.7562785002189357559e-211, + 1.1741471776254777999e-164, 1.3389912474795150614e-180, 1.106784341445028435e-196, 3.3045982549756583552e-212, + 3.0588204110786950436e-165, 3.7502330143836152136e-181, 3.6564932749519464998e-198, 3.7097125405852507464e-214, + 3.0588204110786950436e-165, 3.7502330143836152136e-181, 3.6564932749519464998e-198, 3.7097125405852507464e-214, + 8.8815756978467430465e-166, 1.3403131492807310959e-181, 3.6564932749519464998e-198, 3.7097125405852507464e-214, + 8.8815756978467430465e-166, 1.3403131492807310959e-181, 3.6564932749519464998e-198, 3.7097125405852507464e-214, + 3.4549185946116918017e-166, 1.3535321672928907047e-182, 3.1205762277848031878e-199, -3.3569248349832580936e-217, + 7.4159004299416557678e-167, 1.3535321672928907047e-182, 3.1205762277848031878e-199, -3.3569248349832580936e-217, + 7.4159004299416557678e-167, 1.3535321672928907047e-182, 3.1205762277848031878e-199, -3.3569248349832580936e-217, + 6.3257905089784152346e-168, 3.5607241064750984115e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, + 6.3257905089784152346e-168, 3.5607241064750984115e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, + 6.3257905089784152346e-168, 3.5607241064750984115e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, + 6.3257905089784152346e-168, 3.5607241064750984115e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, + 2.0862146470760309789e-168, -1.146150630053972131e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, + 2.0862146470760309789e-168, -1.146150630053972131e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, + 1.026320681600434562e-168, 1.2072867382105631402e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, + 4.9637369886263658882e-169, 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, + 2.3140020749373754342e-169, 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, + 9.8913461809288020723e-170, 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, + 3.2670088967063259373e-170, 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, + 3.2670088967063259373e-170, 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, + 1.6109245756507072713e-170, -6.2044048008378732802e-187, -5.4322544592823556944e-203, 4.2491789852161138683e-219, + 7.8288241512289757055e-171, 1.2181824638728806485e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, + 3.6886133485899290404e-171, 2.9887099189454666024e-187, 4.774153170641553462e-203, 4.2491789852161138683e-219, + 1.6185079472704052482e-171, 2.9887099189454666024e-187, 4.774153170641553462e-203, 4.2491789852161138683e-219, + 5.8345524661064358191e-172, 6.9043123899963188689e-188, -3.2905064432040069127e-204, -9.1795828160190082842e-224, + 6.5928896280762691321e-173, 1.1586156901317304854e-188, -1.0100405885278530137e-205, -9.1795828160190082842e-224, + 6.5928896280762691321e-173, 1.1586156901317304854e-188, -1.0100405885278530137e-205, -9.1795828160190082842e-224, + 6.5928896280762691321e-173, 1.1586156901317304854e-188, -1.0100405885278530137e-205, -9.1795828160190082842e-224, + 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.332109341809626019e-207, -9.1795828160190082842e-224, + 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.332109341809626019e-207, -9.1795828160190082842e-224, + 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.332109341809626019e-207, -9.1795828160190082842e-224, + 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.332109341809626019e-207, -9.1795828160190082842e-224, + 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.332109341809626019e-207, -9.1795828160190082842e-224, + 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.332109341809626019e-207, -9.1795828160190082842e-224, + 2.2730883653953564668e-175, 2.7431118386590483722e-191, -1.332109341809626019e-207, -9.1795828160190082842e-224, + 2.2730883653953564668e-175, 2.7431118386590483722e-191, -1.332109341809626019e-207, -9.1795828160190082842e-224, + 2.2730883653953564668e-175, 2.7431118386590483722e-191, -1.332109341809626019e-207, -9.1795828160190082842e-224, + 1.0095962991602958391e-175, -6.2404128071707654958e-193, 3.0593092910744445285e-209, 5.4622616159087170031e-225, + 3.7785026604276538491e-176, -6.2404128071707654958e-193, 3.0593092910744445285e-209, 5.4622616159087170031e-225, + 6.1977249484000140293e-177, 1.1294061984896456875e-192, 2.2526486929936882202e-208, -5.3441928036578162463e-225, + 6.1977249484000140293e-177, 1.1294061984896456875e-192, 2.2526486929936882202e-208, -5.3441928036578162463e-225, + 6.1977249484000140293e-177, 1.1294061984896456875e-192, 2.2526486929936882202e-208, -5.3441928036578162463e-225, + 2.2493122414154495675e-177, 2.5268245888628466632e-193, 3.0593092910744445285e-209, 5.4622616159087170031e-225, + 2.7510588792316711745e-178, 3.3501523985444386676e-194, 6.2591208621664049475e-210, 5.9034406125450500218e-227, + 2.7510588792316711745e-178, 3.3501523985444386676e-194, 6.2591208621664049475e-210, 5.9034406125450500218e-227, + 2.7510588792316711745e-178, 3.3501523985444386676e-194, 6.2591208621664049475e-210, 5.9034406125450500218e-227, + 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, 9.9192633285681635836e-229, + 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, 9.9192633285681635836e-229, + 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, 9.9192633285681635836e-229, + 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, 9.9192633285681635836e-229, + 1.2906606599973359683e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, 9.9192633285681635836e-229, + 5.1948630316441287936e-180, 9.6685396110091013832e-196, 1.7562785002189355449e-211, 1.6821693549018732055e-227, + 1.3389912474795150614e-180, 1.106784341445028435e-196, 3.3045982549756578275e-212, 6.2685154049107876715e-228, + 1.3389912474795150614e-180, 1.106784341445028435e-196, 3.3045982549756578275e-212, 6.2685154049107876715e-228, + 3.7502330143836152136e-181, 3.6564932749519464998e-198, 3.7097125405852507464e-214, 2.5658818466966882188e-231, + 3.7502330143836152136e-181, 3.6564932749519464998e-198, 3.7097125405852507464e-214, 2.5658818466966882188e-231, + 1.3403131492807310959e-181, 3.6564932749519464998e-198, 3.7097125405852507464e-214, 2.5658818466966882188e-231, + 1.3535321672928907047e-182, 3.1205762277848031878e-199, -3.3569248349832580936e-217, -1.0577661142165146927e-233, + 1.3535321672928907047e-182, 3.1205762277848031878e-199, -3.3569248349832580936e-217, -1.0577661142165146927e-233, + 1.3535321672928907047e-182, 3.1205762277848031878e-199, -3.3569248349832580936e-217, -1.0577661142165146927e-233, + 1.3535321672928907047e-182, 3.1205762277848031878e-199, -3.3569248349832580936e-217, -1.0577661142165146927e-233, + 6.0043220944823941786e-183, 3.1205762277848031878e-199, -3.3569248349832580936e-217, -1.0577661142165146927e-233, + 2.2388223052591377446e-183, 3.1205762277848031878e-199, -3.3569248349832580936e-217, -1.0577661142165146927e-233, + 3.5607241064750984115e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 3.5607241064750984115e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 3.5607241064750984115e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 1.2072867382105631402e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 1.2181824638728806485e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 2.9887099189454666024e-187, 4.774153170641553462e-203, 4.2491789852161132393e-219, 7.4467067939231424594e-235, + 2.9887099189454666024e-187, 4.774153170641553462e-203, 4.2491789852161132393e-219, 7.4467067939231424594e-235, + 6.9043123899963188689e-188, -3.2905064432040069127e-204, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 6.9043123899963188689e-188, -3.2905064432040069127e-204, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 1.1586156901317304854e-188, -1.0100405885278530137e-205, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 1.1586156901317304854e-188, -1.0100405885278530137e-205, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 1.1586156901317304854e-188, -1.0100405885278530137e-205, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 4.4040360264865697732e-189, -1.0100405885278530137e-205, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 8.129755890712020335e-190, 9.8339840169166049336e-206, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 8.129755890712020335e-190, 9.8339840169166049336e-206, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 8.129755890712020335e-190, 9.8339840169166049336e-206, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 3.6409303439428119063e-190, -1.332109341809626019e-207, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 1.3965175705582071936e-190, -1.332109341809626019e-207, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 2.7431118386590483722e-191, -1.332109341809626019e-207, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 2.7431118386590483722e-191, -1.332109341809626019e-207, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 2.7431118386590483722e-191, -1.332109341809626019e-207, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 1.3403538552936701153e-191, 1.7826390804083638359e-207, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 6.389748636109812983e-192, 2.2526486929936882202e-208, -5.3441928036578156465e-225, -7.741539335184153052e-241, + 2.8828536776963681193e-192, 2.2526486929936882202e-208, -5.3441928036578156465e-225, -7.741539335184153052e-241, + 1.1294061984896456875e-192, 2.2526486929936882202e-208, -5.3441928036578156465e-225, -7.741539335184153052e-241, + 2.5268245888628466632e-193, 3.0593092910744445285e-209, 5.4622616159087170031e-225, 4.2560351759808952526e-241, + 2.5268245888628466632e-193, 3.0593092910744445285e-209, 5.4622616159087170031e-225, 4.2560351759808952526e-241, + 3.3501523985444386676e-194, 6.2591208621664049475e-210, 5.9034406125450490845e-227, 1.3186893776791012681e-242, + 3.3501523985444386676e-194, 6.2591208621664049475e-210, 5.9034406125450490845e-227, 1.3186893776791012681e-242, + 3.3501523985444386676e-194, 6.2591208621664049475e-210, 5.9034406125450490845e-227, 1.3186893776791012681e-242, + 6.1039071228393547627e-195, 1.7562785002189355449e-211, 1.6821693549018732055e-227, -8.7276385348052817035e-244, + 6.1039071228393547627e-195, 1.7562785002189355449e-211, 1.6821693549018732055e-227, -8.7276385348052817035e-244, + 6.1039071228393547627e-195, 1.7562785002189355449e-211, 1.6821693549018732055e-227, -8.7276385348052817035e-244, + 2.6792050150137250131e-195, 1.7562785002189355449e-211, 1.6821693549018732055e-227, -8.7276385348052817035e-244, + 9.6685396110091013832e-196, 1.7562785002189355449e-211, 1.6821693549018732055e-227, -8.7276385348052817035e-244, + 2.0416567491425607157e-177, 6.0959078275963141821e-193, 1.156336993964950812e-208, 2.7126166236326293347e-224, + 2.0416567491425607157e-177, 6.0959078275963141821e-193, 1.156336993964950812e-208, 2.7126166236326293347e-224, + 2.0416567491425607157e-177, 6.0959078275963141821e-193, 1.156336993964950812e-208, 2.7126166236326293347e-224, + 6.7450395650278649168e-179, 6.8432117823206978686e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, + 6.7450395650278649168e-179, 6.8432117823206978686e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, + 6.7450395650278649168e-179, 6.8432117823206978686e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, + 6.7450395650278649168e-179, 6.8432117823206978686e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, + 6.7450395650278649168e-179, 6.8432117823206978686e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, + 5.756447103644822603e-180, -6.1924333305615830735e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 5.756447103644822603e-180, -6.1924333305615830735e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 5.756447103644822603e-180, -6.1924333305615830735e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 5.756447103644822603e-180, -6.1924333305615830735e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 1.9005753194802080146e-180, -6.1924333305615830735e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 1.9005753194802080146e-180, -6.1924333305615830735e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 9.3660737343905436753e-181, -6.1924333305615830735e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 4.5462340041847754398e-181, -6.1924333305615830735e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 2.1363141390818913221e-181, -6.1924333305615830735e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 9.3135420653044926323e-182, -6.1924333305615830735e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 3.2887424025472810002e-182, 7.185309278132283136e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 2.7634257116867652192e-183, 4.9643797378534984559e-199, -9.4699347169310243473e-216, -9.2331809177749095611e-233, + 2.7634257116867652192e-183, 4.9643797378534984559e-199, -9.4699347169310243473e-216, -9.2331809177749095611e-233, + 2.7634257116867652192e-183, 4.9643797378534984559e-199, -9.4699347169310243473e-216, -9.2331809177749095611e-233, + 2.7634257116867652192e-183, 4.9643797378534984559e-199, -9.4699347169310243473e-216, -9.2331809177749095611e-233, + 8.806758170751374203e-184, 7.8383517263666503337e-200, 1.3736749441945438342e-215, -9.2331809177749095611e-233, + 8.806758170751374203e-184, 7.8383517263666503337e-200, 1.3736749441945438342e-215, -9.2331809177749095611e-233, + 4.0998834342223036605e-184, 7.8383517263666503337e-200, 1.3736749441945438342e-215, -9.2331809177749095611e-233, + 1.7464460659577689118e-184, 2.612671019845610006e-200, 2.1334073625072069974e-216, -9.2331809177749095611e-233, + 5.697273818255015375e-185, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 5.697273818255015375e-185, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 2.755477107924346286e-185, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 1.2845787527590117414e-185, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 5.4912957517634446918e-186, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 1.8140498638501083305e-186, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 1.8140498638501083305e-186, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 8.9473839187177424013e-187, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 4.3508265588260719497e-187, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 2.0525478788802367239e-187, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 9.0340853890731911095e-188, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 3.288388689208603045e-188, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 4.1554033927630885323e-189, -9.8582956929636044137e-206, -1.4280619485269765742e-221, 1.2171222696290252021e-237, + 4.1554033927630885323e-189, -9.8582956929636044137e-206, -1.4280619485269765742e-221, 1.2171222696290252021e-237, + 4.1554033927630885323e-189, -9.8582956929636044137e-206, -1.4280619485269765742e-221, 1.2171222696290252021e-237, + 5.643429553477207926e-190, 1.0076094209231528444e-205, 7.8509991660024955813e-222, 1.2171222696290252021e-237, + 5.643429553477207926e-190, 1.0076094209231528444e-205, 7.8509991660024955813e-222, 1.2171222696290252021e-237, + 5.643429553477207926e-190, 1.0076094209231528444e-205, 7.8509991660024955813e-222, 1.2171222696290252021e-237, + 1.1546040067079994973e-190, 1.0889925813396166947e-207, 2.4325525462765697993e-223, -1.1429360314275701698e-239, + 1.1546040067079994973e-190, 1.0889925813396166947e-207, 2.4325525462765697993e-223, -1.1429360314275701698e-239, + 3.2397620015697148712e-192, 3.1030547578511949035e-208, -1.609965144193984205e-224, -1.8313007053436627876e-240, + 3.2397620015697148712e-192, 3.1030547578511949035e-208, -1.609965144193984205e-224, -1.8313007053436627876e-240, + 3.2397620015697148712e-192, 3.1030547578511949035e-208, -1.609965144193984205e-224, -1.8313007053436627876e-240, + 3.2397620015697148712e-192, 3.1030547578511949035e-208, -1.609965144193984205e-224, -1.8313007053436627876e-240, + 3.2397620015697148712e-192, 3.1030547578511949035e-208, -1.609965144193984205e-224, -1.8313007053436627876e-240, + 3.2397620015697148712e-192, 3.1030547578511949035e-208, -1.609965144193984205e-224, -1.8313007053436627876e-240, + 1.4863145223629928288e-192, -7.9038076992129241506e-209, -1.609965144193984205e-224, -1.8313007053436627876e-240, + 6.0959078275963141821e-193, 1.156336993964950812e-208, 2.7126166236326293347e-224, -1.8313007053436627876e-240, + 1.712289129579509076e-193, 1.8297811202182925249e-209, 1.1003018740995688645e-226, 5.827891678485165325e-243, + 1.712289129579509076e-193, 1.8297811202182925249e-209, 1.1003018740995688645e-226, 5.827891678485165325e-243, + 6.1638445507530779946e-194, -6.0361608463951204924e-210, 1.1003018740995688645e-226, 5.827891678485165325e-243, + 6.8432117823206978686e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.029900079464340522e-245, + 6.8432117823206978686e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.029900079464340522e-245, + 6.8432117823206978686e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.029900079464340522e-245, + 6.8432117823206978686e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.029900079464340522e-245, + 3.418509674495068119e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.029900079464340522e-245, + 1.7061586205822532442e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.029900079464340522e-245, + 8.499830936258458068e-196, 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.029900079464340522e-245, + 4.218953301476420881e-196, 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.029900079464340522e-245, + 2.0785144840854027628e-196, -1.9512340798794268979e-214, -3.6162764918921692779e-230, -2.8387319855193022476e-246, + 1.008295075389893466e-196, -1.9512340798794268979e-214, -3.6162764918921692779e-230, -2.8387319855193022476e-246, + 4.7318537104213881764e-197, -1.9512340798794268979e-214, -3.6162764918921692779e-230, -2.8387319855193022476e-246, + 2.0563051886826149345e-197, -1.9512340798794268979e-214, -3.6162764918921692779e-230, -2.8387319855193022476e-246, + 7.185309278132283136e-198, -1.9512340798794268979e-214, -3.6162764918921692779e-230, -2.8387319855193022476e-246, + 4.9643797378534984559e-199, -9.4699347169310243473e-216, -9.2331809177749077733e-233, -1.4042876247421728101e-248, + 4.9643797378534984559e-199, -9.4699347169310243473e-216, -9.2331809177749077733e-233, -1.4042876247421728101e-248, + 4.9643797378534984559e-199, -9.4699347169310243473e-216, -9.2331809177749077733e-233, -1.4042876247421728101e-248, + 4.9643797378534984559e-199, -9.4699347169310243473e-216, -9.2331809177749077733e-233, -1.4042876247421728101e-248, + 7.8383517263666503337e-200, 1.3736749441945438342e-215, -9.2331809177749077733e-233, -1.4042876247421728101e-248, + 7.8383517263666503337e-200, 1.3736749441945438342e-215, -9.2331809177749077733e-233, -1.4042876247421728101e-248, + 7.8383517263666503337e-200, 1.3736749441945438342e-215, -9.2331809177749077733e-233, -1.4042876247421728101e-248, + 2.612671019845610006e-200, 2.1334073625072069974e-216, -9.2331809177749077733e-233, -1.4042876247421728101e-248, + 2.612671019845610006e-200, 2.1334073625072069974e-216, -9.2331809177749077733e-233, -1.4042876247421728101e-248, + 1.306250843215349634e-200, 2.1334073625072069974e-216, -9.2331809177749077733e-233, -1.4042876247421728101e-248, + 6.5304075490021959302e-201, 6.8298960257742791824e-217, 6.8696910062179237095e-233, 3.8349029251851101018e-249, + 3.2643571074265457254e-201, -4.2219277387461470355e-218, -1.753154605289404553e-234, -7.5861268822635538093e-251, + 1.6313318866387202604e-201, -4.2219277387461470355e-218, -1.753154605289404553e-234, -7.5861268822635538093e-251, + 8.1481927624480752786e-202, -4.2219277387461470355e-218, -1.753154605289404553e-234, -7.5861268822635538093e-251, + 4.0656297104785107096e-202, 4.8431832608149701961e-218, 8.3111403472061145651e-234, 1.6001805286092554504e-249, + 2.0243481844937293316e-202, 3.1062776103441183191e-219, 7.6291913283447536617e-235, 2.0347903074934629333e-250, + 1.0037074215013384159e-202, 3.1062776103441183191e-219, 7.6291913283447536617e-235, 2.0347903074934629333e-250, + 4.9338704000514295811e-203, 3.1062776103441183191e-219, 7.6291913283447536617e-235, 2.0347903074934629333e-250, + 2.3822684925704522921e-203, 3.1062776103441183191e-219, 7.6291913283447536617e-235, 2.0347903074934629333e-250, + 1.1064675388299639308e-203, 2.7343042298126957741e-220, 5.5273393987134252385e-236, 1.1432574793608782288e-251, + 4.6856706195971960852e-204, 2.7343042298126957741e-220, 5.5273393987134252385e-236, 1.1432574793608782288e-251, + 1.4961682352459748279e-204, -8.0675475439086544798e-221, -3.6970842501441777651e-237, -5.7032870362481275794e-253, + 1.4961682352459748279e-204, -8.0675475439086544798e-221, -3.6970842501441777651e-237, -5.7032870362481275794e-253, + 6.9879263915816924805e-205, 9.6377473771091526132e-221, 1.5959741828948633012e-236, 2.7031904319843495713e-252, + 3.0010484111426663515e-205, 7.8509991660024955813e-222, 1.2171222696290252021e-237, -2.4742181023285720738e-254, + 1.0076094209231528444e-205, 7.8509991660024955813e-222, 1.2171222696290252021e-237, -2.4742181023285720738e-254, + 1.0889925813396166947e-207, 2.4325525462765697993e-223, -1.1429360314275701698e-239, 8.3218722366085688343e-256, + 1.0889925813396166947e-207, 2.4325525462765697993e-223, -1.1429360314275701698e-239, 8.3218722366085688343e-256, + 1.0889925813396166947e-207, 2.4325525462765697993e-223, -1.1429360314275701698e-239, 8.3218722366085688343e-256, + 1.0889925813396166947e-207, 2.4325525462765697993e-223, -1.1429360314275701698e-239, 8.3218722366085688343e-256, + 1.0889925813396166947e-207, 2.4325525462765697993e-223, -1.1429360314275701698e-239, 8.3218722366085688343e-256, + 1.0889925813396166947e-207, 2.4325525462765697993e-223, -1.1429360314275701698e-239, 8.3218722366085688343e-256, + 1.0889925813396166947e-207, 2.4325525462765697993e-223, -1.1429360314275701698e-239, 8.3218722366085688343e-256, + 3.1030547578511949035e-208, -1.609965144193984205e-224, -1.8313007053436625212e-240, -2.3341145329525059632e-256, + 3.1030547578511949035e-208, -1.609965144193984205e-224, -1.8313007053436625212e-240, -2.3341145329525059632e-256, + 1.156336993964950812e-208, 2.7126166236326293347e-224, -1.8313007053436625212e-240, -2.3341145329525059632e-256, + 1.8297811202182925249e-209, 1.1003018740995688645e-226, 5.827891678485165325e-243, -3.1174271110208206547e-259, + 1.8297811202182925249e-209, 1.1003018740995688645e-226, 5.827891678485165325e-243, -3.1174271110208206547e-259, + 1.8297811202182925249e-209, 1.1003018740995688645e-226, 5.827891678485165325e-243, -3.1174271110208206547e-259, + 6.1308251778939023781e-210, 1.1003018740995688645e-226, 5.827891678485165325e-243, -3.1174271110208206547e-259, + 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 2.3568521170701555846e-212, -7.7818310317651142243e-229, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 1.1686698881356804311e-212, 1.8601114328504743806e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 5.7457877366844311816e-213, 5.409641648369814791e-229, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 2.7753321643482446169e-213, -1.1860946916976500828e-229, 6.3146909508553973881e-246, 1.2573885592501532045e-261, + 1.290104378180150675e-213, 2.1117734783360818049e-229, 4.2928382696354204061e-245, -2.8075477999879273582e-261, + 5.4749048509610403382e-214, 4.6283939331921604413e-230, 6.3146909508553973881e-246, 1.2573885592501532045e-261, + 1.7618353855408067201e-214, 5.060587206499956961e-231, 5.9380161562121075096e-247, -1.2904053011746964278e-263, + 1.7618353855408067201e-214, 5.060587206499956961e-231, 5.9380161562121075096e-247, -1.2904053011746964278e-263, + 8.3356801918574821257e-215, 5.060587206499956961e-231, 5.9380161562121075096e-247, -1.2904053011746964278e-263, + 3.6943433600821895879e-215, 5.060587206499956961e-231, 5.9380161562121075096e-247, -1.2904053011746964278e-263, + 1.3736749441945438342e-215, -9.2331809177749077733e-233, -1.4042876247421726117e-248, -9.9505977179164858712e-265, + 2.1334073625072069974e-216, -9.2331809177749077733e-233, -1.4042876247421726117e-248, -9.9505977179164858712e-265, + 2.1334073625072069974e-216, -9.2331809177749077733e-233, -1.4042876247421726117e-248, -9.9505977179164858712e-265, + 2.1334073625072069974e-216, -9.2331809177749077733e-233, -1.4042876247421726117e-248, -9.9505977179164858712e-265, + 6.8298960257742791824e-217, 6.8696910062179237095e-233, 3.8349029251851101018e-249, -2.6436684620390282645e-267, + 6.8298960257742791824e-217, 6.8696910062179237095e-233, 3.8349029251851101018e-249, -2.6436684620390282645e-267, + 3.2038516259498326923e-217, -1.1817449557784924788e-233, -6.3454186796659920093e-250, -2.6436684620390282645e-267, + 1.3908294260376086421e-217, 2.8439730252197153919e-233, 3.8349029251851101018e-249, -2.6436684620390282645e-267, + 4.8431832608149701961e-218, 8.3111403472061145651e-234, 1.6001805286092554504e-249, -2.6436684620390282645e-267, + 3.1062776103441183191e-219, 7.6291913283447536617e-235, 2.0347903074934629333e-250, -2.6436684620390282645e-267, + 3.1062776103441183191e-219, 7.6291913283447536617e-235, 2.0347903074934629333e-250, -2.6436684620390282645e-267, + 3.1062776103441183191e-219, 7.6291913283447536617e-235, 2.0347903074934629333e-250, -2.6436684620390282645e-267, + 3.1062776103441183191e-219, 7.6291913283447536617e-235, 2.0347903074934629333e-250, -2.6436684620390282645e-267, + 2.7343042298126957741e-220, 5.5273393987134252385e-236, 1.1432574793608780349e-251, 1.2329569415922591084e-267, + 2.7343042298126957741e-220, 5.5273393987134252385e-236, 1.1432574793608780349e-251, 1.2329569415922591084e-267, + 2.7343042298126957741e-220, 5.5273393987134252385e-236, 1.1432574793608780349e-251, 1.2329569415922591084e-267, + 2.7343042298126957741e-220, 5.5273393987134252385e-236, 1.1432574793608780349e-251, 1.2329569415922591084e-267, + 9.6377473771091526132e-221, 1.5959741828948633012e-236, 2.7031904319843490867e-252, 2.638005906844372114e-268, + 7.8509991660024955813e-222, 1.2171222696290252021e-237, -2.4742181023285720738e-254, -1.2030990169203137715e-270, + 7.8509991660024955813e-222, 1.2171222696290252021e-237, -2.4742181023285720738e-254, -1.2030990169203137715e-270, + 7.8509991660024955813e-222, 1.2171222696290252021e-237, -2.4742181023285720738e-254, -1.2030990169203137715e-270, + 7.8509991660024955813e-222, 1.2171222696290252021e-237, -2.4742181023285720738e-254, -1.2030990169203137715e-270, + 2.318094503184431479e-222, -1.1429360314275701698e-239, 8.3218722366085688343e-256, -2.0046830753539155726e-272, + 2.318094503184431479e-222, -1.1429360314275701698e-239, 8.3218722366085688343e-256, -2.0046830753539155726e-272, + 9.3486833747991514629e-223, -1.1429360314275701698e-239, 8.3218722366085688343e-256, -2.0046830753539155726e-272, + 2.4325525462765697993e-223, -1.1429360314275701698e-239, 8.3218722366085688343e-256, -2.0046830753539155726e-272, + 2.4325525462765697993e-223, -1.1429360314275701698e-239, 8.3218722366085688343e-256, -2.0046830753539155726e-272, + 7.0351983914592419146e-224, 7.766758903588374524e-240, 8.3218722366085688343e-256, -2.0046830753539155726e-272, + 7.0351983914592419146e-224, 7.766758903588374524e-240, 8.3218722366085688343e-256, -2.0046830753539155726e-272, + 2.7126166236326293347e-224, -1.8313007053436625212e-240, -2.3341145329525056675e-256, -2.0046830753539155726e-272, + 5.5132573971932232487e-225, 5.6821419688934674008e-241, 3.2988215943776273615e-257, 2.1353977370878701046e-273, + 5.5132573971932232487e-225, 5.6821419688934674008e-241, 3.2988215943776273615e-257, 2.1353977370878701046e-273, + 1.1003018740995688645e-226, 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, + 1.1003018740995688645e-226, 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, + 1.1003018740995688645e-226, 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, + 1.1003018740995688645e-226, 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, + 1.1003018740995688645e-226, 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, + 1.1003018740995688645e-226, 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, + 2.560476225709334075e-227, 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, + 2.560476225709334075e-227, 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, + 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, -1.472095602234059958e-277, + 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, -1.472095602234059958e-277, + 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, -1.472095602234059958e-277, + 1.8601114328504743806e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, -1.472095602234059958e-277, + 5.409641648369814791e-229, -3.0299000794643401155e-245, -2.8075477999879273582e-261, -1.472095602234059958e-277, + 5.409641648369814791e-229, -3.0299000794643401155e-245, -2.8075477999879273582e-261, -1.472095602234059958e-277, + 2.1117734783360818049e-229, 4.2928382696354204061e-245, -2.8075477999879273582e-261, -1.472095602234059958e-277, + 4.6283939331921604413e-230, 6.3146909508553973881e-246, 1.2573885592501529789e-261, 3.0408903374280139822e-277, + 4.6283939331921604413e-230, 6.3146909508553973881e-246, 1.2573885592501529789e-261, 3.0408903374280139822e-277, + 5.060587206499956961e-231, 5.9380161562121075096e-247, -1.2904053011746964278e-263, 8.7279092175580820317e-280, + 5.060587206499956961e-231, 5.9380161562121075096e-247, -1.2904053011746964278e-263, 8.7279092175580820317e-280, + 5.060587206499956961e-231, 5.9380161562121075096e-247, -1.2904053011746964278e-263, 8.7279092175580820317e-280, + 5.060587206499956961e-231, 5.9380161562121075096e-247, -1.2904053011746964278e-263, 8.7279092175580820317e-280, + 2.4841276986611042098e-231, 2.1712682097791944335e-248, 2.9746046415267896827e-264, -8.6516445844406224413e-282, + 1.1958979447416775482e-231, 2.1712682097791944335e-248, 2.9746046415267896827e-264, -8.6516445844406224413e-282, + 5.5178306778196421733e-232, 2.1712682097791944335e-248, 2.9746046415267896827e-264, -8.6516445844406224413e-282, + 2.2972562930210755192e-232, 2.1712682097791944335e-248, 2.9746046415267896827e-264, -8.6516445844406224413e-282, + 6.8696910062179237095e-233, 3.8349029251851101018e-249, -2.6436684620390282645e-267, -4.3807022524130141006e-284, + 6.8696910062179237095e-233, 3.8349029251851101018e-249, -2.6436684620390282645e-267, -4.3807022524130141006e-284, + 2.8439730252197153919e-233, 3.8349029251851101018e-249, -2.6436684620390282645e-267, -4.3807022524130141006e-284, + 8.3111403472061145651e-234, 1.6001805286092554504e-249, -2.6436684620390282645e-267, -4.3807022524130141006e-284, + 8.3111403472061145651e-234, 1.6001805286092554504e-249, -2.6436684620390282645e-267, -4.3807022524130141006e-284, + 3.2789928709583552854e-234, 4.8281933032132812475e-250, -2.6436684620390282645e-267, -4.3807022524130141006e-284, + 7.6291913283447536617e-235, 2.0347903074934629333e-250, -2.6436684620390282645e-267, -4.3807022524130141006e-284, + 7.6291913283447536617e-235, 2.0347903074934629333e-250, -2.6436684620390282645e-267, -4.3807022524130141006e-284, + 1.3390069830350552605e-235, -6.026193929640082176e-252, -7.0535576022338457803e-268, -4.3807022524130141006e-284, + 1.3390069830350552605e-235, -6.026193929640082176e-252, -7.0535576022338457803e-268, -4.3807022524130141006e-284, + 1.3390069830350552605e-235, -6.026193929640082176e-252, -7.0535576022338457803e-268, -4.3807022524130141006e-284, + 5.5273393987134252385e-236, 1.1432574793608780349e-251, 1.2329569415922591084e-267, -4.3807022524130141006e-284, + 1.5959741828948633012e-236, 2.7031904319843490867e-252, 2.638005906844371576e-268, 6.3790946999826013345e-284, + 1.5959741828948633012e-236, 2.7031904319843490867e-252, 2.638005906844371576e-268, 6.3790946999826013345e-284, + 6.1313287894022281692e-237, 5.2084434157824127104e-253, 2.1511502957481757317e-269, 3.2670891426006739096e-285, + 1.2171222696290252021e-237, -2.4742181023285720738e-254, -1.2030990169203137715e-270, -9.5347405022956042207e-287, + 1.2171222696290252021e-237, -2.4742181023285720738e-254, -1.2030990169203137715e-270, -9.5347405022956042207e-287, + 1.2171222696290252021e-237, -2.4742181023285720738e-254, -1.2030990169203137715e-270, -9.5347405022956042207e-287, + 6.0284645465737476297e-238, -2.4742181023285720738e-254, -1.2030990169203137715e-270, -9.5347405022956042207e-287, + 2.9570854717154947523e-238, 4.3456134301905148502e-254, 6.3684349745470443788e-270, -9.5347405022956042207e-287, + 1.4213959342863689955e-238, 9.3569766393097138822e-255, 2.5826679788133653036e-270, -9.5347405022956042207e-287, + 6.5355116557180594664e-239, 9.3569766393097138822e-255, 2.5826679788133653036e-270, -9.5347405022956042207e-287, + 2.6962878121452450746e-239, 8.3218722366085688343e-256, -2.0046830753539152442e-272, -3.4057806738724185961e-288, + 7.766758903588374524e-240, 8.3218722366085688343e-256, -2.0046830753539152442e-272, -3.4057806738724185961e-288, + 7.766758903588374524e-240, 8.3218722366085688343e-256, -2.0046830753539152442e-272, -3.4057806738724185961e-288, + 2.9677290991223565342e-240, -2.3341145329525056675e-256, -2.0046830753539152442e-272, -3.4057806738724185961e-288, + 5.6821419688934674008e-241, 3.2988215943776273615e-257, 2.1353977370878701046e-273, -1.2215123283371736879e-289, + 5.6821419688934674008e-241, 3.2988215943776273615e-257, 2.1353977370878701046e-273, -1.2215123283371736879e-289, + 5.6821419688934674008e-241, 3.2988215943776273615e-257, 2.1353977370878701046e-273, -1.2215123283371736879e-289, + 2.6827483411022054912e-241, 3.2988215943776273615e-257, 2.1353977370878701046e-273, -1.2215123283371736879e-289, + 1.1830515272065748694e-241, -3.117427111020820077e-259, -5.9718623963762788119e-275, 6.1155422068568954053e-291, + 4.3320312025875939195e-242, -3.117427111020820077e-259, -5.9718623963762788119e-275, 6.1155422068568954053e-291, + 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, 6.1155422068568954053e-291, + 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, 6.1155422068568954053e-291, + 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, 6.1155422068568954053e-291, + 1.1413391350613183311e-243, -5.1586784110844895013e-260, -1.9524039360882352712e-276, -2.9779654517181717279e-292, + 1.1413391350613183311e-243, -5.1586784110844895013e-260, -1.9524039360882352712e-276, -2.9779654517181717279e-292, + 1.1413391350613183311e-243, -5.1586784110844895013e-260, -1.9524039360882352712e-276, -2.9779654517181717279e-292, + 5.5552006713333735927e-244, 7.8491179384773690214e-260, -1.9524039360882352712e-276, -2.9779654517181717279e-292, + 2.6261053316934700345e-244, 1.345219763696439399e-260, 1.6579848156414234801e-276, 1.0303712682997740506e-292, + 1.1615576618735179302e-244, 1.345219763696439399e-260, 1.6579848156414234801e-276, 1.0303712682997740506e-292, + 4.2928382696354204061e-245, -2.8075477999879273582e-261, -1.472095602234059958e-277, 2.8287088295287585094e-294, + 6.3146909508553973881e-246, 1.2573885592501529789e-261, 3.0408903374280139822e-277, 2.8287088295287585094e-294, + 6.3146909508553973881e-246, 1.2573885592501529789e-261, 3.0408903374280139822e-277, 2.8287088295287585094e-294, + 6.3146909508553973881e-246, 1.2573885592501529789e-261, 3.0408903374280139822e-277, 2.8287088295287585094e-294, + 1.7379794826680480784e-246, 2.4115446944063306384e-262, 2.202741251392177696e-278, 2.8287088295287585094e-294, + 1.7379794826680480784e-246, 2.4115446944063306384e-262, 2.202741251392177696e-278, 2.8287088295287585094e-294, + 5.9380161562121075096e-247, -1.2904053011746964278e-263, 8.7279092175580810531e-280, 8.8634899828990930877e-296, + 2.1712682097791944335e-248, 2.9746046415267896827e-264, -8.6516445844406224413e-282, -5.0528699238150276549e-299, + 2.1712682097791944335e-248, 2.9746046415267896827e-264, -8.6516445844406224413e-282, -5.0528699238150276549e-299, + 2.1712682097791944335e-248, 2.9746046415267896827e-264, -8.6516445844406224413e-282, -5.0528699238150276549e-299, + 2.1712682097791944335e-248, 2.9746046415267896827e-264, -8.6516445844406224413e-282, -5.0528699238150276549e-299, + 2.1712682097791944335e-248, 2.9746046415267896827e-264, -8.6516445844406224413e-282, -5.0528699238150276549e-299, + 3.8349029251851101018e-249, -2.6436684620390282645e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 3.8349029251851101018e-249, -2.6436684620390282645e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 3.8349029251851101018e-249, -2.6436684620390282645e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 1.6001805286092554504e-249, -2.6436684620390282645e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 4.8281933032132812475e-250, -2.6436684620390282645e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 4.8281933032132812475e-250, -2.6436684620390282645e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 2.0347903074934629333e-250, -2.6436684620390282645e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 6.3808880963355377617e-251, -2.6436684620390282645e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 6.3808880963355377617e-251, -2.6436684620390282645e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 2.8891343516857640937e-251, 5.1095823452235464813e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 1.1432574793608780349e-251, 1.2329569415922591084e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 2.7031904319843490867e-252, 2.638005906844371576e-268, 6.3790946999826013345e-284, -2.7456019707854725967e-300, + 2.7031904319843490867e-252, 2.638005906844371576e-268, 6.3790946999826013345e-284, -2.7456019707854725967e-300, + 5.2084434157824127104e-253, 2.1511502957481757317e-269, 3.2670891426006735363e-285, 2.4084160842482777461e-301, + 5.2084434157824127104e-253, 2.1511502957481757317e-269, 3.2670891426006735363e-285, 2.4084160842482777461e-301, + 5.2084434157824127104e-253, 2.1511502957481757317e-269, 3.2670891426006735363e-285, 2.4084160842482777461e-301, + 2.4805108027747776379e-253, 2.1511502957481757317e-269, 3.2670891426006735363e-285, 2.4084160842482777461e-301, + 1.1165444962709601017e-253, 2.1511502957481757317e-269, 3.2670891426006735363e-285, 2.4084160842482777461e-301, + 4.3456134301905148502e-254, 6.3684349745470443788e-270, -9.5347405022956030541e-287, -1.5805886663557401565e-302, + 9.3569766393097138822e-255, 2.5826679788133653036e-270, -9.5347405022956030541e-287, -1.5805886663557401565e-302, + 9.3569766393097138822e-255, 2.5826679788133653036e-270, -9.5347405022956030541e-287, -1.5805886663557401565e-302, + 8.3218722366085688343e-256, -2.0046830753539152442e-272, -3.4057806738724185961e-288, 2.3458177946667328156e-304, + 8.3218722366085688343e-256, -2.0046830753539152442e-272, -3.4057806738724185961e-288, 2.3458177946667328156e-304, + 8.3218722366085688343e-256, -2.0046830753539152442e-272, -3.4057806738724185961e-288, 2.3458177946667328156e-304, + 8.3218722366085688343e-256, -2.0046830753539152442e-272, -3.4057806738724185961e-288, 2.3458177946667328156e-304, + 2.9938788518280315834e-256, -2.0046830753539152442e-272, -3.4057806738724185961e-288, 2.3458177946667328156e-304, + 3.2988215943776273615e-257, 2.1353977370878701046e-273, -1.2215123283371736879e-289, 6.7342163555358599277e-306, + 3.2988215943776273615e-257, 2.1353977370878701046e-273, -1.2215123283371736879e-289, 6.7342163555358599277e-306, + 3.2988215943776273615e-257, 2.1353977370878701046e-273, -1.2215123283371736879e-289, 6.7342163555358599277e-306, + 3.2988215943776273615e-257, 2.1353977370878701046e-273, -1.2215123283371736879e-289, 6.7342163555358599277e-306, + 1.6338236616337094706e-257, 2.1353977370878701046e-273, -1.2215123283371736879e-289, 6.7342163555358599277e-306, + 8.0132469526175071002e-258, 2.8687869620228451614e-274, -1.9537812801257956865e-290, 1.0380272777574237546e-306, + 3.850752120757712373e-258, 2.8687869620228451614e-274, -1.9537812801257956865e-290, 1.0380272777574237546e-306, + 1.7695047048278150093e-258, 2.8687869620228451614e-274, -1.9537812801257956865e-290, 1.0380272777574237546e-306, + 7.2888099686286655858e-259, 5.581381609158630475e-275, 6.1155422068568946933e-291, 1.0380272777574237546e-306, + 2.0856914288039227544e-259, -1.9524039360882352712e-276, -2.9779654517181712829e-292, -3.000817432603284506e-308, + 2.0856914288039227544e-259, -1.9524039360882352712e-276, -2.9779654517181712829e-292, -3.000817432603284506e-308, + 7.8491179384773690214e-260, -1.9524039360882352712e-276, -2.9779654517181712829e-292, -3.000817432603284506e-308, + 1.345219763696439399e-260, 1.6579848156414234801e-276, 1.0303712682997738281e-292, 1.4493302844111182601e-308, + 1.345219763696439399e-260, 1.6579848156414234801e-276, 1.0303712682997738281e-292, 1.4493302844111182601e-308, + 1.345219763696439399e-260, 1.6579848156414234801e-276, 1.0303712682997738281e-292, 1.4493302844111182601e-308, + 5.3223249184882342185e-261, -1.472095602234059958e-277, 2.8287088295287585094e-294, -1.0874435234232647519e-310, + 1.2573885592501529789e-261, 3.0408903374280139822e-277, 2.8287088295287585094e-294, -1.0874435234232647519e-310, + 1.2573885592501529789e-261, 3.0408903374280139822e-277, 2.8287088295287585094e-294, -1.0874435234232647519e-310, + 2.4115446944063306384e-262, 2.202741251392177696e-278, 2.8287088295287585094e-294, -1.0874435234232647519e-310, + 2.4115446944063306384e-262, 2.202741251392177696e-278, 2.8287088295287585094e-294, -1.0874435234232647519e-310, + 2.4115446944063306384e-262, 2.202741251392177696e-278, 2.8287088295287585094e-294, -1.0874435234232647519e-310, + 1.1412520821444306741e-262, -6.1787496089661820348e-279, -3.028042329852615431e-295, -2.182740474438892116e-311, + 5.0610577601348040988e-263, 7.9243314524777990283e-279, -3.028042329852615431e-295, -2.182740474438892116e-311, + 1.8853262294800541881e-263, 8.7279092175580810531e-280, 8.8634899828990930877e-296, -9.8167844904532653004e-314, + 2.9746046415267896827e-264, -8.6516445844406224413e-282, -5.0528699238150265939e-299, -1.3288013265921760399e-314, + 2.9746046415267896827e-264, -8.6516445844406224413e-282, -5.0528699238150265939e-299, -1.3288013265921760399e-314, + 2.9746046415267896827e-264, -8.6516445844406224413e-282, -5.0528699238150265939e-299, -1.3288013265921760399e-314, + 9.8977243486757054781e-265, -8.6516445844406224413e-282, -5.0528699238150265939e-299, -1.3288013265921760399e-314, + 9.8977243486757054781e-265, -8.6516445844406224413e-282, -5.0528699238150265939e-299, -1.3288013265921760399e-314, + 4.9356438320276576408e-265, -8.6516445844406224413e-282, -5.0528699238150265939e-299, -1.3288013265921760399e-314, + 2.4546035737036337221e-265, -8.6516445844406224413e-282, -5.0528699238150265939e-299, -1.3288013265921760399e-314, + 1.2140834445416214873e-265, 1.8893435613692150014e-281, 3.0075895258731974416e-297, -9.8167844904532653004e-314, + 5.9382337996061564537e-266, 5.1208955146257653156e-282, -5.0528699238150265939e-299, -1.3288013265921760399e-314, + 2.8369334767011265554e-266, 5.1208955146257653156e-282, -5.0528699238150265939e-299, -1.3288013265921760399e-314, + 1.2862833152486119506e-266, 1.6777604898591683764e-282, -5.0528699238150265939e-299, -1.3288013265921760399e-314, + 5.1095823452235464813e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, -2.5539572388808429997e-317, + 1.2329569415922591084e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, -2.5539572388808429997e-317, + 1.2329569415922591084e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, -2.5539572388808429997e-317, + 2.638005906844371576e-268, 6.3790946999826013345e-284, -2.7456019707854725967e-300, -2.5539572388808429997e-317, + 2.638005906844371576e-268, 6.3790946999826013345e-284, -2.7456019707854725967e-300, -2.5539572388808429997e-317, + 2.1511502957481757317e-269, 3.2670891426006735363e-285, 2.4084160842482773317e-301, 5.7350888195772519812e-317, + 2.1511502957481757317e-269, 3.2670891426006735363e-285, 2.4084160842482773317e-301, 5.7350888195772519812e-317, + 2.1511502957481757317e-269, 3.2670891426006735363e-285, 2.4084160842482773317e-301, 5.7350888195772519812e-317, + 2.1511502957481757317e-269, 3.2670891426006735363e-285, 2.4084160842482773317e-301, 5.7350888195772519812e-317, + 6.3684349745470443788e-270, -9.5347405022956030541e-287, -1.5805886663557401565e-302, 3.6369654387311681856e-319, + 6.3684349745470443788e-270, -9.5347405022956030541e-287, -1.5805886663557401565e-302, 3.6369654387311681856e-319, + 2.5826679788133653036e-270, -9.5347405022956030541e-287, -1.5805886663557401565e-302, 3.6369654387311681856e-319, + 6.8978448094652555593e-271, 1.1480487920352081009e-286, 7.5257037990230704094e-303, 3.6369654387311681856e-319, + 6.8978448094652555593e-271, 1.1480487920352081009e-286, 7.5257037990230704094e-303, 3.6369654387311681856e-319, + 2.1656360647981577662e-271, 9.7287370902823839435e-288, 1.6928061833779524157e-303, 3.6369654387311681856e-319, + 2.1656360647981577662e-271, 9.7287370902823839435e-288, 1.6928061833779524157e-303, 3.6369654387311681856e-319, + 9.825838786313830552e-272, 9.7287370902823839435e-288, 1.6928061833779524157e-303, 3.6369654387311681856e-319, + 3.9105778554799569972e-272, 9.7287370902823839435e-288, 1.6928061833779524157e-303, 3.6369654387311681856e-319, + 9.5294739006302120482e-273, -1.2215123283371736879e-289, 6.7342163555358599277e-306, -5.681754927174335258e-322, + 9.5294739006302120482e-273, -1.2215123283371736879e-289, 6.7342163555358599277e-306, -5.681754927174335258e-322, + 2.1353977370878701046e-273, -1.2215123283371736879e-289, 6.7342163555358599277e-306, -5.681754927174335258e-322, + 2.1353977370878701046e-273, -1.2215123283371736879e-289, 6.7342163555358599277e-306, -5.681754927174335258e-322, + 2.8687869620228451614e-274, -1.9537812801257956865e-290, 1.0380272777574237546e-306, 6.4228533959362050743e-323, + 0, 0, 0, 0, +}; + +NOEXPORT ALIGNED(64) const float Sleef_rempitabsp[] = { + 0.159154892, 5.112411827e-08, 3.626141271e-15, -2.036222915e-22, + 0.03415493667, 6.420638243e-09, 7.342738037e-17, 8.135951656e-24, + 0.03415493667, 6.420638243e-09, 7.342738037e-17, 8.135951656e-24, + 0.002904943191, -9.861969574e-11, -9.839336547e-18, -1.790215892e-24, + 0.002904943191, -9.861969574e-11, -9.839336547e-18, -1.790215892e-24, + 0.002904943191, -9.861969574e-11, -9.839336547e-18, -1.790215892e-24, + 0.002904943191, -9.861969574e-11, -9.839336547e-18, -1.790215892e-24, + 0.0009518179577, 1.342109202e-10, 1.791623576e-17, 1.518506657e-24, + 0.0009518179577, 1.342109202e-10, 1.791623576e-17, 1.518506657e-24, + 0.0004635368241, 1.779561221e-11, 4.038449606e-18, -1.358546052e-25, + 0.0002193961991, 1.779561221e-11, 4.038449606e-18, -1.358546052e-25, + 9.73258866e-05, 1.779561221e-11, 4.038449606e-18, -1.358546052e-25, + 3.62907449e-05, 3.243700447e-12, 5.690024473e-19, 7.09405479e-26, + 5.773168596e-06, 1.424711477e-12, 1.3532163e-19, 1.92417627e-26, + 5.773168596e-06, 1.424711477e-12, 1.3532163e-19, 1.92417627e-26, + 5.773168596e-06, 1.424711477e-12, 1.3532163e-19, 1.92417627e-26, + 1.958472239e-06, 5.152167755e-13, 1.3532163e-19, 1.92417627e-26, + 5.112411827e-08, 3.626141271e-15, -2.036222915e-22, 6.177847236e-30, + 5.112411827e-08, 3.626141271e-15, -2.036222915e-22, 6.177847236e-30, + 5.112411827e-08, 3.626141271e-15, -2.036222915e-22, 6.177847236e-30, + 5.112411827e-08, 3.626141271e-15, -2.036222915e-22, 6.177847236e-30, + 5.112411827e-08, 3.626141271e-15, -2.036222915e-22, 6.177847236e-30, + 5.112411827e-08, 3.626141271e-15, -2.036222915e-22, 6.177847236e-30, + 2.132179588e-08, 3.626141271e-15, -2.036222915e-22, 6.177847236e-30, + 6.420638243e-09, 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, + 6.420638243e-09, 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, + 2.695347945e-09, 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, + 8.327027956e-10, 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, + 8.327027956e-10, 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, + 3.670415083e-10, 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, + 1.342109202e-10, 1.791623576e-17, 1.518506361e-24, 2.613904e-31, + 1.779561221e-11, 4.038449606e-18, -1.358545683e-25, -3.443243946e-32, + 1.779561221e-11, 4.038449606e-18, -1.358545683e-25, -3.443243946e-32, + 1.779561221e-11, 4.038449606e-18, -1.358545683e-25, -3.443243946e-32, + 3.243700447e-12, 5.690024473e-19, 7.094053557e-26, 1.487136711e-32, + 3.243700447e-12, 5.690024473e-19, 7.094053557e-26, 1.487136711e-32, + 3.243700447e-12, 5.690024473e-19, 7.094053557e-26, 1.487136711e-32, + 1.424711477e-12, 1.3532163e-19, 1.924175961e-26, 2.545416018e-33, + 5.152167755e-13, 1.3532163e-19, 1.924175961e-26, 2.545416018e-33, + 6.046956013e-14, -2.036222915e-22, 6.177846108e-30, 1.082084378e-36, + 6.046956013e-14, -2.036222915e-22, 6.177846108e-30, 1.082084378e-36, + 6.046956013e-14, -2.036222915e-22, 6.177846108e-30, 1.082084378e-36, + 3.626141271e-15, -2.036222915e-22, 6.177846108e-30, 1.082084378e-36, + 3.626141271e-15, -2.036222915e-22, 6.177846108e-30, 1.082084378e-36, + 3.626141271e-15, -2.036222915e-22, 6.177846108e-30, 1.082084378e-36, + 3.626141271e-15, -2.036222915e-22, 6.177846108e-30, 1.082084378e-36, + 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, 6.296048013e-40, + 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, 6.296048013e-40, + 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, 6.296048013e-40, + 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, 6.296048013e-40, + 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, 6.296048013e-40, + 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, 6.296048013e-40, + 1.791623576e-17, 1.518506361e-24, 2.61390353e-31, 4.764937743e-38, + 1.791623576e-17, 1.518506361e-24, 2.61390353e-31, 4.764937743e-38, + 4.038449606e-18, -1.358545683e-25, -3.443243946e-32, 6.296048013e-40, + 4.038449606e-18, -1.358545683e-25, -3.443243946e-32, 6.296048013e-40, + 5.690024473e-19, 7.094053557e-26, 1.487136711e-32, 6.296048013e-40, + 5.690024473e-19, 7.094053557e-26, 1.487136711e-32, 6.296048013e-40, + 5.690024473e-19, 7.094053557e-26, 1.487136711e-32, 6.296048013e-40, + 1.3532163e-19, 1.924175961e-26, 2.545415467e-33, 6.296048013e-40, + 1.3532163e-19, 1.924175961e-26, 2.545415467e-33, 6.296048013e-40, + 2.690143217e-20, -1.452834402e-28, -6.441077673e-36, -1.764234767e-42, + 2.690143217e-20, -1.452834402e-28, -6.441077673e-36, -1.764234767e-42, + 2.690143217e-20, -1.452834402e-28, -6.441077673e-36, -1.764234767e-42, + 1.334890502e-20, -1.452834402e-28, -6.441077673e-36, -1.764234767e-42, + 6.572641438e-21, -1.452834402e-28, -6.441077673e-36, -1.764234767e-42, + 0.05874381959, 1.222115387e-08, 7.693612965e-16, 1.792054435e-22, + 0.02749382704, 4.77057327e-09, 7.693612965e-16, 1.792054435e-22, + 0.01186883077, 1.045283415e-09, 3.252721926e-16, 7.332633139e-23, + 0.00405633077, 1.045283415e-09, 3.252721926e-16, 7.332633139e-23, + 0.000150081818, -2.454155802e-12, 1.161414894e-20, 1.291319272e-27, + 0.000150081818, -2.454155802e-12, 1.161414894e-20, 1.291319272e-27, + 0.000150081818, -2.454155802e-12, 1.161414894e-20, 1.291319272e-27, + 0.000150081818, -2.454155802e-12, 1.161414894e-20, 1.291319272e-27, + 0.000150081818, -2.454155802e-12, 1.161414894e-20, 1.291319272e-27, + 2.801149822e-05, 4.821800945e-12, 8.789757674e-19, 1.208447639e-25, + 2.801149822e-05, 4.821800945e-12, 8.789757674e-19, 1.208447639e-25, + 2.801149822e-05, 4.821800945e-12, 8.789757674e-19, 1.208447639e-25, + 1.275271279e-05, 1.183823005e-12, 1.161414894e-20, 1.291319272e-27, + 5.12331826e-06, 1.183823005e-12, 1.161414894e-20, 1.291319272e-27, + 1.308621904e-06, 2.743283031e-13, 1.161414894e-20, 1.291319272e-27, + 1.308621904e-06, 2.743283031e-13, 1.161414894e-20, 1.291319272e-27, + 3.549478151e-07, 4.695462769e-14, 1.161414894e-20, 1.291319272e-27, + 3.549478151e-07, 4.695462769e-14, 1.161414894e-20, 1.291319272e-27, + 1.165292645e-07, 1.853292503e-14, 4.837885366e-21, 1.291319272e-27, + 1.165292645e-07, 1.853292503e-14, 4.837885366e-21, 1.291319272e-27, + 5.69246339e-08, 4.322073705e-15, 1.449754789e-21, 7.962890365e-29, + 2.712231151e-08, 4.322073705e-15, 1.449754789e-21, 7.962890365e-29, + 1.222115387e-08, 7.693612965e-16, 1.792054182e-22, 2.91418027e-29, + 4.77057327e-09, 7.693612965e-16, 1.792054182e-22, 2.91418027e-29, + 1.045283415e-09, 3.252721926e-16, 7.332632508e-23, 3.898253736e-30, + 1.045283415e-09, 3.252721926e-16, 7.332632508e-23, 3.898253736e-30, + 1.139611461e-10, 1.996093359e-17, 5.344349223e-25, 1.511644828e-31, + 1.139611461e-10, 1.996093359e-17, 5.344349223e-25, 1.511644828e-31, + 1.139611461e-10, 1.996093359e-17, 5.344349223e-25, 1.511644828e-31, + 1.139611461e-10, 1.996093359e-17, 5.344349223e-25, 1.511644828e-31, + 5.575349904e-11, 6.083145782e-18, 5.344349223e-25, 1.511644828e-31, + 2.664967552e-11, -8.557475018e-19, -8.595036458e-26, -2.139883875e-32, + 1.209775682e-11, 2.61369883e-18, 5.344349223e-25, 1.511644828e-31, + 4.821800945e-12, 8.789757674e-19, 1.208447639e-25, 3.253064536e-33, + 1.183823005e-12, 1.161414894e-20, 1.29131908e-27, 1.715766248e-34, + 1.183823005e-12, 1.161414894e-20, 1.29131908e-27, 1.715766248e-34, + 2.743283031e-13, 1.161414894e-20, 1.29131908e-27, 1.715766248e-34, + 0, 0, 0, 0, +}; diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/rename.h b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/rename.h new file mode 100644 index 00000000000..8810742b1a5 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/rename.h @@ -0,0 +1,181 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#define xsin Sleef_sin_u35 +#define xcos Sleef_cos_u35 +#define xsincos Sleef_sincos_u35 +#define xtan Sleef_tan_u35 +#define xasin Sleef_asin_u35 +#define xacos Sleef_acos_u35 +#define xatan Sleef_atan_u35 +#define xatan2 Sleef_atan2_u35 +#define xlog Sleef_log_u35 +#define xcbrt Sleef_cbrt_u35 + +#define xsin_u1 Sleef_sin_u10 +#define xcos_u1 Sleef_cos_u10 +#define xsincos_u1 Sleef_sincos_u10 +#define xtan_u1 Sleef_tan_u10 +#define xasin_u1 Sleef_asin_u10 +#define xacos_u1 Sleef_acos_u10 +#define xatan_u1 Sleef_atan_u10 +#define xatan2_u1 Sleef_atan2_u10 +#define xlog_u1 Sleef_log_u10 +#define xcbrt_u1 Sleef_cbrt_u10 + +#define xexp Sleef_exp_u10 +#define xpow Sleef_pow_u10 +#define xsinh Sleef_sinh_u10 +#define xcosh Sleef_cosh_u10 +#define xtanh Sleef_tanh_u10 +#define xsinh_u35 Sleef_sinh_u35 +#define xcosh_u35 Sleef_cosh_u35 +#define xtanh_u35 Sleef_tanh_u35 +#define xasinh Sleef_asinh_u10 +#define xacosh Sleef_acosh_u10 +#define xatanh Sleef_atanh_u10 + +#define xexp2 Sleef_exp2_u10 +#define xexp10 Sleef_exp10_u10 +#define xexp2_u35 Sleef_exp2_u35 +#define xexp10_u35 Sleef_exp10_u35 +#define xexpm1 Sleef_expm1_u10 +#define xlog10 Sleef_log10_u10 +#define xlog2 Sleef_log2_u10 +#define xlog2_u35 Sleef_log2_u35 +#define xlog1p Sleef_log1p_u10 + +#define xsincospi_u05 Sleef_sincospi_u05 +#define xsincospi_u35 Sleef_sincospi_u35 +#define xsinpi_u05 Sleef_sinpi_u05 +#define xcospi_u05 Sleef_cospi_u05 + +#define xldexp Sleef_ldexp +#define xilogb Sleef_ilogb + +#define xfma Sleef_fma +#define xsqrt Sleef_sqrt +#define xsqrt_u05 Sleef_sqrt_u05 +#define xsqrt_u35 Sleef_sqrt_u35 +#define xhypot_u05 Sleef_hypot_u05 +#define xhypot_u35 Sleef_hypot_u35 + +#define xfabs Sleef_fabs +#define xcopysign Sleef_copysign +#define xfmax Sleef_fmax +#define xfmin Sleef_fmin +#define xfdim Sleef_fdim +#define xtrunc Sleef_trunc +#define xfloor Sleef_floor +#define xceil Sleef_ceil +#define xround Sleef_round +#define xrint Sleef_rint +#define xnextafter Sleef_nextafter +#define xfrfrexp Sleef_frfrexp +#define xexpfrexp Sleef_expfrexp +#define xfmod Sleef_fmod +#define xremainder Sleef_remainder +#define xmodf Sleef_modf + +#define xlgamma_u1 Sleef_lgamma_u10 +#define xtgamma_u1 Sleef_tgamma_u10 +#define xerf_u1 Sleef_erf_u10 +#define xerfc_u15 Sleef_erfc_u15 + +// + +#define xsinf Sleef_sinf_u35 +#define xcosf Sleef_cosf_u35 +#define xsincosf Sleef_sincosf_u35 +#define xtanf Sleef_tanf_u35 +#define xasinf Sleef_asinf_u35 +#define xacosf Sleef_acosf_u35 +#define xatanf Sleef_atanf_u35 +#define xatan2f Sleef_atan2f_u35 +#define xlogf Sleef_logf_u35 +#define xcbrtf Sleef_cbrtf_u35 + +#define xsinf_u1 Sleef_sinf_u10 +#define xcosf_u1 Sleef_cosf_u10 +#define xsincosf_u1 Sleef_sincosf_u10 +#define xtanf_u1 Sleef_tanf_u10 +#define xasinf_u1 Sleef_asinf_u10 +#define xacosf_u1 Sleef_acosf_u10 +#define xatanf_u1 Sleef_atanf_u10 +#define xatan2f_u1 Sleef_atan2f_u10 +#define xlogf_u1 Sleef_logf_u10 +#define xcbrtf_u1 Sleef_cbrtf_u10 + +#define xexpf Sleef_expf_u10 +#define xpowf Sleef_powf_u10 +#define xsinhf Sleef_sinhf_u10 +#define xcoshf Sleef_coshf_u10 +#define xtanhf Sleef_tanhf_u10 +#define xsinhf_u35 Sleef_sinhf_u35 +#define xcoshf_u35 Sleef_coshf_u35 +#define xtanhf_u35 Sleef_tanhf_u35 +#define xasinhf Sleef_asinhf_u10 +#define xacoshf Sleef_acoshf_u10 +#define xatanhf Sleef_atanhf_u10 + +#define xexp2f Sleef_exp2f_u10 +#define xexp10f Sleef_exp10f_u10 +#define xexp2f_u35 Sleef_exp2f_u35 +#define xexp10f_u35 Sleef_exp10f_u35 +#define xexpm1f Sleef_expm1f_u10 +#define xlog10f Sleef_log10f_u10 +#define xlog2f Sleef_log2f_u10 +#define xlog10f_u35 Sleef_log10f_u35 +#define xlog2f_u35 Sleef_log2f_u35 +#define xlog1pf Sleef_log1pf_u10 + +#define xsincospif_u05 Sleef_sincospif_u05 +#define xsincospif_u35 Sleef_sincospif_u35 +#define xsinpif_u05 Sleef_sinpif_u05 +#define xcospif_u05 Sleef_cospif_u05 + +#define xldexpf Sleef_ldexpf +#define xilogbf Sleef_ilogbf + +#define xfmaf Sleef_fmaf +#define xsqrtf Sleef_sqrtf +#define xsqrtf_u05 Sleef_sqrtf_u05 +#define xsqrtf_u35 Sleef_sqrtf_u35 +#define xhypotf_u05 Sleef_hypotf_u05 +#define xhypotf_u35 Sleef_hypotf_u35 + +#define xfabsf Sleef_fabsf +#define xcopysignf Sleef_copysignf +#define xfmaxf Sleef_fmaxf +#define xfminf Sleef_fminf +#define xfdimf Sleef_fdimf +#define xtruncf Sleef_truncf +#define xfloorf Sleef_floorf +#define xceilf Sleef_ceilf +#define xroundf Sleef_roundf +#define xrintf Sleef_rintf +#define xnextafterf Sleef_nextafterf +#define xfrfrexpf Sleef_frfrexpf +#define xexpfrexpf Sleef_expfrexpf +#define xfmodf Sleef_fmodf +#define xremainderf Sleef_remainderf +#define xmodff Sleef_modff + +#define xlgammaf_u1 Sleef_lgammaf_u10 +#define xtgammaf_u1 Sleef_tgammaf_u10 +#define xerff_u1 Sleef_erff_u10 +#define xerfcf_u15 Sleef_erfcf_u15 + +#define xfastsinf_u3500 Sleef_fastsinf_u3500 +#define xfastcosf_u3500 Sleef_fastcosf_u3500 +#define xfastpowf_u3500 Sleef_fastpowf_u3500 + +// + +#define xsincospil_u05 Sleef_sincospil_u05 +#define xsincospil_u35 Sleef_sincospil_u35 + +#define xsincospiq_u05 Sleef_sincospiq_u05 +#define xsincospiq_u35 Sleef_sincospiq_u35 diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/sleef.pc.in b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/sleef.pc.in new file mode 100644 index 00000000000..f73bc14570d --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/sleef.pc.in @@ -0,0 +1,9 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +libdir=@CMAKE_INSTALL_FULL_LIBDIR@ +includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ + +Name: SLEEF +Description: SIMD Library for Evaluating Elementary Functions, vectorized libm and DFT +Version: @SLEEF_VERSION_MAJOR@.@SLEEF_VERSION_MINOR@.@SLEEF_VERSION_PATCH@ +Cflags: -I${includedir} +Libs: -L${libdir} -lsleef diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/sleefdp.c b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/sleefdp.c new file mode 100644 index 00000000000..0ece9233c16 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/sleefdp.c @@ -0,0 +1,2724 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// Always use -ffp-contract=off option to compile SLEEF. + +#include +#include +#include +#include +#include + +#ifndef ENABLE_BUILTIN_MATH +#include +#define SQRT sqrt +#else +#define SQRT __builtin_sqrt +#endif + +#include "misc.h" + +extern const double Sleef_rempitabdp[]; + +#ifdef DORENAME +#include "rename.h" +#endif + +#if defined(_MSC_VER) && !defined (__clang__) +#pragma fp_contract (off) +#else +#pragma STDC FP_CONTRACT OFF +#endif + +#define MLA mla +#define C2V(x) (x) +#include "estrin.h" + +static INLINE CONST int64_t doubleToRawLongBits(double d) { + int64_t ret; + memcpy(&ret, &d, sizeof(ret)); + return ret; +} + +static INLINE CONST double longBitsToDouble(int64_t i) { + double ret; + memcpy(&ret, &i, sizeof(ret)); + return ret; +} + +static INLINE CONST double fabsk(double x) { + return longBitsToDouble(INT64_C(0x7fffffffffffffff) & doubleToRawLongBits(x)); +} + +static INLINE CONST double mulsign(double x, double y) { + return longBitsToDouble(doubleToRawLongBits(x) ^ (doubleToRawLongBits(y) & (INT64_C(1) << 63))); +} + +static INLINE CONST double copysignk(double x, double y) { + return longBitsToDouble((doubleToRawLongBits(x) & ~(INT64_C(1) << 63)) ^ (doubleToRawLongBits(y) & (INT64_C(1) << 63))); +} + +static INLINE CONST double sign(double d) { return mulsign(1, d); } +static INLINE CONST double mla(double x, double y, double z) { return x * y + z; } +static INLINE CONST double rintk(double x) { return x < 0 ? (int)(x - 0.5) : (int)(x + 0.5); } +static INLINE CONST int ceilk(double x) { return (int)x + (x < 0 ? 0 : 1); } +static INLINE CONST double trunck(double x) { return (double)(int)x; } +static INLINE CONST double fmink(double x, double y) { return x < y ? x : y; } +static INLINE CONST double fmaxk(double x, double y) { return x > y ? x : y; } + +static INLINE CONST int xsignbit(double d) { return (doubleToRawLongBits(d) & doubleToRawLongBits(-0.0)) == doubleToRawLongBits(-0.0); } +static INLINE CONST int xisnan(double x) { return x != x; } +static INLINE CONST int xisinf(double x) { return x == SLEEF_INFINITY || x == -SLEEF_INFINITY; } +static INLINE CONST int xisminf(double x) { return x == -SLEEF_INFINITY; } +static INLINE CONST int xispinf(double x) { return x == SLEEF_INFINITY; } +static INLINE CONST int xisnegzero(double x) { return doubleToRawLongBits(x) == doubleToRawLongBits(-0.0); } +static INLINE CONST int xisnumber(double x) { return !xisinf(x) && !xisnan(x); } + +static INLINE CONST int xisint(double d) { + double x = d - (double)(INT64_C(1) << 31) * (int)(d * (1.0 / (INT64_C(1) << 31))); + return (x == (int)x) || (fabsk(d) >= (double)(INT64_C(1) << 53)); +} + +static INLINE CONST int xisodd(double d) { + double x = d - (double)(INT64_C(1) << 31) * (int)(d * (1.0 / (INT64_C(1) << 31))); + return (1 & (int)x) != 0 && fabsk(d) < (double)(INT64_C(1) << 53); +} + +static INLINE CONST double pow2i(int q) { + return longBitsToDouble(((int64_t)(q + 0x3ff)) << 52); +} + +static INLINE CONST double ldexpk(double x, int q) { + double u; + int m; + m = q >> 31; + m = (((m + q) >> 9) - m) << 7; + q = q - (m << 2); + m += 0x3ff; + m = m < 0 ? 0 : m; + m = m > 0x7ff ? 0x7ff : m; + u = longBitsToDouble(((int64_t)m) << 52); + x = x * u * u * u * u; + u = longBitsToDouble(((int64_t)(q + 0x3ff)) << 52); + return x * u; +} + +static INLINE CONST double ldexp2k(double d, int e) { // faster than ldexpk, short reach + return d * pow2i(e >> 1) * pow2i(e - (e >> 1)); +} + +static INLINE CONST double ldexp3k(double d, int e) { // very fast, no denormal + return longBitsToDouble(doubleToRawLongBits(d) + (((int64_t)e) << 52)); +} + +EXPORT CONST double xldexp(double x, int exp) { + if (exp > 2100) exp = 2100; + if (exp < -2100) exp = -2100; + + int e0 = exp >> 2; + if (exp < 0) e0++; + if (-100 < exp && exp < 100) e0 = 0; + int e1 = exp - (e0 << 2); + + double p = pow2i(e0); + double ret = x * pow2i(e1) * p * p * p * p; + + return ret; +} + +static INLINE CONST int ilogbk(double d) { + int m = d < 4.9090934652977266E-91; + d = m ? 2.037035976334486E90 * d : d; + int q = (doubleToRawLongBits(d) >> 52) & 0x7ff; + q = m ? q - (300 + 0x03ff) : q - 0x03ff; + return q; +} + +// ilogb2k is similar to ilogbk, but the argument has to be a +// normalized FP value. +static INLINE CONST int ilogb2k(double d) { + return ((doubleToRawLongBits(d) >> 52) & 0x7ff) - 0x3ff; +} + +EXPORT CONST int xilogb(double d) { + int e = ilogbk(fabsk(d)); + e = d == 0.0 ? SLEEF_FP_ILOGB0 : e; + e = xisnan(d) ? SLEEF_FP_ILOGBNAN : e; + e = xisinf(d) ? INT_MAX : e; + return e; +} + +// + +#ifndef NDEBUG +static int checkfp(double x) { + if (xisinf(x) || xisnan(x)) return 1; + return 0; +} +#endif + +static INLINE CONST double upper(double d) { + return longBitsToDouble(doubleToRawLongBits(d) & INT64_C(0xfffffffff8000000)); +} + +static INLINE CONST Sleef_double2 dd(double h, double l) { + Sleef_double2 ret; + ret.x = h; ret.y = l; + return ret; +} + +static INLINE CONST Sleef_double2 ddnormalize_d2_d2(Sleef_double2 t) { + Sleef_double2 s; + + s.x = t.x + t.y; + s.y = t.x - s.x + t.y; + + return s; +} + +static INLINE CONST Sleef_double2 ddscale_d2_d2_d(Sleef_double2 d, double s) { + Sleef_double2 r; + + r.x = d.x * s; + r.y = d.y * s; + + return r; +} + +static INLINE CONST Sleef_double2 ddneg_d2_d2(Sleef_double2 d) { + Sleef_double2 r; + + r.x = -d.x; + r.y = -d.y; + + return r; +} + +static INLINE CONST Sleef_double2 ddabs_d2_d2(Sleef_double2 x) { + return dd(x.x < 0 ? -x.x : x.x, x.x < 0 ? -x.y : x.y); +} + +/* + * ddadd and ddadd2 are functions for double-double addition. ddadd + * is simpler and faster than ddadd2, but it requires the absolute + * value of first argument to be larger than the second argument. The + * exact condition that should be met is checked if NDEBUG macro is + * not defined. + * + * Please note that if the results won't be used, it is no problem to + * feed arguments that do not meet this condition. You will see + * warning messages if you turn off NDEBUG macro and run tester2, but + * this is normal. + * + * Please see : + * Jonathan Richard Shewchuk, Adaptive Precision Floating-Point + * Arithmetic and Fast Robust Geometric Predicates, Discrete & + * Computational Geometry 18:305-363, 1997. + */ + +static INLINE CONST Sleef_double2 ddadd_d2_d_d(double x, double y) { + // |x| >= |y| + + Sleef_double2 r; + +#ifndef NDEBUG + if (!(checkfp(x) || checkfp(y) || fabsk(x) >= fabsk(y) || (fabsk(x+y) <= fabsk(x) && fabsk(x+y) <= fabsk(y)))) { + fprintf(stderr, "[ddadd_d2_d_d : %g, %g]\n", x, y); + fflush(stderr); + } +#endif + + r.x = x + y; + r.y = x - r.x + y; + + return r; +} + +static INLINE CONST Sleef_double2 ddadd2_d2_d_d(double x, double y) { + Sleef_double2 r; + + r.x = x + y; + double v = r.x - x; + r.y = (x - (r.x - v)) + (y - v); + + return r; +} + +static INLINE CONST Sleef_double2 ddadd_d2_d2_d(Sleef_double2 x, double y) { + // |x| >= |y| + + Sleef_double2 r; + +#ifndef NDEBUG + if (!(checkfp(x.x) || checkfp(y) || fabsk(x.x) >= fabsk(y) || (fabsk(x.x+y) <= fabsk(x.x) && fabsk(x.x+y) <= fabsk(y)))) { + fprintf(stderr, "[ddadd_d2_d2_d : %g %g]\n", x.x, y); + fflush(stderr); + } +#endif + + r.x = x.x + y; + r.y = x.x - r.x + y + x.y; + + return r; +} + +static INLINE CONST Sleef_double2 ddadd2_d2_d2_d(Sleef_double2 x, double y) { + Sleef_double2 r; + + r.x = x.x + y; + double v = r.x - x.x; + r.y = (x.x - (r.x - v)) + (y - v); + r.y += x.y; + + return r; +} + +static INLINE CONST Sleef_double2 ddadd_d2_d_d2(double x, Sleef_double2 y) { + // |x| >= |y| + + Sleef_double2 r; + +#ifndef NDEBUG + if (!(checkfp(x) || checkfp(y.x) || fabsk(x) >= fabsk(y.x) || (fabsk(x+y.x) <= fabsk(x) && fabsk(x+y.x) <= fabsk(y.x)))) { + fprintf(stderr, "[ddadd_d2_d_d2 : %g %g]\n", x, y.x); + fflush(stderr); + } +#endif + + r.x = x + y.x; + r.y = x - r.x + y.x + y.y; + + return r; +} + +static INLINE CONST Sleef_double2 ddadd2_d2_d_d2(double x, Sleef_double2 y) { + Sleef_double2 r; + + r.x = x + y.x; + double v = r.x - x; + r.y = (x - (r.x - v)) + (y.x - v) + y.y; + + return r; +} + +static INLINE CONST double ddadd2_d_d_d2(double x, Sleef_double2 y) { return y.y + y.x + x; } + +static INLINE CONST Sleef_double2 ddadd_d2_d2_d2(Sleef_double2 x, Sleef_double2 y) { + // |x| >= |y| + + Sleef_double2 r; + +#ifndef NDEBUG + if (!(x.x == 0 || checkfp(x.x) || checkfp(y.x) || fabsk(x.x) >= fabsk(y.x) || (fabsk(x.x+y.x) <= fabsk(x.x) && fabsk(x.x+y.x) <= fabsk(y.x)))) { + fprintf(stderr, "[ddadd_d2_d2_d2 : %g %g]\n", x.x, y.x); + fflush(stderr); + } +#endif + + r.x = x.x + y.x; + r.y = x.x - r.x + y.x + x.y + y.y; + + return r; +} + +static INLINE CONST Sleef_double2 ddadd2_d2_d2_d2(Sleef_double2 x, Sleef_double2 y) { + Sleef_double2 r; + + r.x = x.x + y.x; + double v = r.x - x.x; + r.y = (x.x - (r.x - v)) + (y.x - v); + r.y += x.y + y.y; + + return r; +} + +static INLINE CONST Sleef_double2 ddsub_d2_d2_d2(Sleef_double2 x, Sleef_double2 y) { + // |x| >= |y| + + Sleef_double2 r; + +#ifndef NDEBUG + if (!(checkfp(x.x) || checkfp(y.x) || fabsk(x.x) >= fabsk(y.x) || (fabsk(x.x-y.x) <= fabsk(x.x) && fabsk(x.x-y.x) <= fabsk(y.x)))) { + fprintf(stderr, "[ddsub_d2_d2_d2 : %g %g]\n", x.x, y.x); + fflush(stderr); + } +#endif + + r.x = x.x - y.x; + r.y = x.x - r.x - y.x + x.y - y.y; + + return r; +} + +static INLINE CONST Sleef_double2 dddiv_d2_d2_d2(Sleef_double2 n, Sleef_double2 d) { + double t = 1.0 / d.x; + double dh = upper(d.x), dl = d.x - dh; + double th = upper(t ), tl = t - th; + double nhh = upper(n.x), nhl = n.x - nhh; + + Sleef_double2 q; + + q.x = n.x * t; + + double u = -q.x + nhh * th + nhh * tl + nhl * th + nhl * tl + + q.x * (1 - dh * th - dh * tl - dl * th - dl * tl); + + q.y = t * (n.y - q.x * d.y) + u; + + return q; +} + +static INLINE CONST Sleef_double2 ddmul_d2_d_d(double x, double y) { + double xh = upper(x), xl = x - xh; + double yh = upper(y), yl = y - yh; + Sleef_double2 r; + + r.x = x * y; + r.y = xh * yh - r.x + xl * yh + xh * yl + xl * yl; + + return r; +} + +static INLINE CONST Sleef_double2 ddmul_d2_d2_d(Sleef_double2 x, double y) { + double xh = upper(x.x), xl = x.x - xh; + double yh = upper(y ), yl = y - yh; + Sleef_double2 r; + + r.x = x.x * y; + r.y = xh * yh - r.x + xl * yh + xh * yl + xl * yl + x.y * y; + + return r; +} + +static INLINE CONST Sleef_double2 ddmul_d2_d2_d2(Sleef_double2 x, Sleef_double2 y) { + double xh = upper(x.x), xl = x.x - xh; + double yh = upper(y.x), yl = y.x - yh; + Sleef_double2 r; + + r.x = x.x * y.x; + r.y = xh * yh - r.x + xl * yh + xh * yl + xl * yl + x.x * y.y + x.y * y.x; + + return r; +} + +static INLINE CONST double ddmul_d_d2_d2(Sleef_double2 x, Sleef_double2 y) { + double xh = upper(x.x), xl = x.x - xh; + double yh = upper(y.x), yl = y.x - yh; + + return x.y * yh + xh * y.y + xl * yl + xh * yl + xl * yh + xh * yh; +} + +static INLINE CONST Sleef_double2 ddsqu_d2_d2(Sleef_double2 x) { + double xh = upper(x.x), xl = x.x - xh; + Sleef_double2 r; + + r.x = x.x * x.x; + r.y = xh * xh - r.x + (xh + xh) * xl + xl * xl + x.x * (x.y + x.y); + + return r; +} + +static INLINE CONST double ddsqu_d_d2(Sleef_double2 x) { + double xh = upper(x.x), xl = x.x - xh; + + return xh * x.y + xh * x.y + xl * xl + (xh * xl + xh * xl) + xh * xh; +} + +static INLINE CONST Sleef_double2 ddrec_d2_d(double d) { + double t = 1.0 / d; + double dh = upper(d), dl = d - dh; + double th = upper(t), tl = t - th; + Sleef_double2 q; + + q.x = t; + q.y = t * (1 - dh * th - dh * tl - dl * th - dl * tl); + + return q; +} + +static INLINE CONST Sleef_double2 ddrec_d2_d2(Sleef_double2 d) { + double t = 1.0 / d.x; + double dh = upper(d.x), dl = d.x - dh; + double th = upper(t ), tl = t - th; + Sleef_double2 q; + + q.x = t; + q.y = t * (1 - dh * th - dh * tl - dl * th - dl * tl - d.y * t); + + return q; +} + +static INLINE CONST Sleef_double2 ddsqrt_d2_d2(Sleef_double2 d) { + double t = SQRT(d.x + d.y); + return ddscale_d2_d2_d(ddmul_d2_d2_d2(ddadd2_d2_d2_d2(d, ddmul_d2_d_d(t, t)), ddrec_d2_d(t)), 0.5); +} + +static INLINE CONST Sleef_double2 ddsqrt_d2_d(double d) { + double t = SQRT(d); + return ddscale_d2_d2_d(ddmul_d2_d2_d2(ddadd2_d2_d_d2(d, ddmul_d2_d_d(t, t)), ddrec_d2_d(t)), 0.5); +} + +// + +static INLINE CONST double atan2k(double y, double x) { + double s, t, u; + int q = 0; + + if (x < 0) { x = -x; q = -2; } + if (y > x) { t = x; x = y; y = -t; q += 1; } + + s = y / x; + t = s * s; + + double t2 = t * t, t4 = t2 * t2, t8 = t4 * t4, t16 = t8 * t8; + u = POLY19(t, t2, t4, t8, t16, + -1.88796008463073496563746e-05, + 0.000209850076645816976906797, + -0.00110611831486672482563471, + 0.00370026744188713119232403, + -0.00889896195887655491740809, + 0.016599329773529201970117, + -0.0254517624932312641616861, + 0.0337852580001353069993897, + -0.0407629191276836500001934, + 0.0466667150077840625632675, + -0.0523674852303482457616113, + 0.0587666392926673580854313, + -0.0666573579361080525984562, + 0.0769219538311769618355029, + -0.090908995008245008229153, + 0.111111105648261418443745, + -0.14285714266771329383765, + 0.199999999996591265594148, + -0.333333333333311110369124); + + t = u * t * s + s; + t = q * (M_PI/2) + t; + + return t; +} + +EXPORT CONST double xatan2(double y, double x) { + double r = atan2k(fabsk(y), x); + + r = mulsign(r, x); + if (xisinf(x) || x == 0) r = M_PI/2 - (xisinf(x) ? (sign(x) * (M_PI /2)) : 0); + if (xisinf(y) ) r = M_PI/2 - (xisinf(x) ? (sign(x) * (M_PI*1/4)) : 0); + if ( y == 0) r = (sign(x) == -1 ? M_PI : 0); + + return xisnan(x) || xisnan(y) ? SLEEF_NAN : mulsign(r, y); +} + +EXPORT CONST double xasin(double d) { + int o = fabsk(d) < 0.5; + double x2 = o ? (d*d) : ((1-fabsk(d))*0.5), x = o ? fabsk(d) : SQRT(x2), u; + + double x4 = x2 * x2, x8 = x4 * x4, x16 = x8 * x8; + u = POLY12(x2, x4, x8, x16, + +0.3161587650653934628e-1, + -0.1581918243329996643e-1, + +0.1929045477267910674e-1, + +0.6606077476277170610e-2, + +0.1215360525577377331e-1, + +0.1388715184501609218e-1, + +0.1735956991223614604e-1, + +0.2237176181932048341e-1, + +0.3038195928038132237e-1, + +0.4464285681377102438e-1, + +0.7500000000378581611e-1, + +0.1666666666666497543e+0); + + u = mla(u, x * x2, x); + + double r = o ? u : (M_PI/2 - 2*u); + r = mulsign(r, d); + + return r; +} + +EXPORT CONST double xacos(double d) { + int o = fabsk(d) < 0.5; + double x2 = o ? (d*d) : ((1-fabsk(d))*0.5), u; + double x = o ? fabsk(d) : SQRT(x2); + x = fabsk(d) == 1.0 ? 0 : x; + + double x4 = x2 * x2, x8 = x4 * x4, x16 = x8 * x8; + u = POLY12(x2, x4, x8, x16, + +0.3161587650653934628e-1, + -0.1581918243329996643e-1, + +0.1929045477267910674e-1, + +0.6606077476277170610e-2, + +0.1215360525577377331e-1, + +0.1388715184501609218e-1, + +0.1735956991223614604e-1, + +0.2237176181932048341e-1, + +0.3038195928038132237e-1, + +0.4464285681377102438e-1, + +0.7500000000378581611e-1, + +0.1666666666666497543e+0); + + u *= x * x2; + + double y = 3.1415926535897932/2 - (mulsign(x, d) + mulsign(u, d)); + x += u; + double r = o ? y : (x*2); + if (!o && d < 0) r = ddadd_d2_d2_d(dd(3.141592653589793116, 1.2246467991473532072e-16), -r).x; + + return r; +} + +EXPORT CONST double xatan(double s) { + double t, u; + int q = 0; + + if (sign(s) == -1) { s = -s; q = 2; } + if (s > 1) { s = 1.0 / s; q |= 1; } + + t = s * s; + + double t2 = t * t, t4 = t2 * t2, t8 = t4 * t4, t16 = t8 * t8; + u = POLY19(t, t2, t4, t8, t16, + -1.88796008463073496563746e-05, + 0.000209850076645816976906797, + -0.00110611831486672482563471, + 0.00370026744188713119232403, + -0.00889896195887655491740809, + 0.016599329773529201970117, + -0.0254517624932312641616861, + 0.0337852580001353069993897, + -0.0407629191276836500001934, + 0.0466667150077840625632675, + -0.0523674852303482457616113, + 0.0587666392926673580854313, + -0.0666573579361080525984562, + 0.0769219538311769618355029, + -0.090908995008245008229153, + 0.111111105648261418443745, + -0.14285714266771329383765, + 0.199999999996591265594148, + -0.333333333333311110369124); + + t = s + s * (t * u); + + if ((q & 1) != 0) t = 1.570796326794896557998982 - t; + if ((q & 2) != 0) t = -t; + + return t; +} + +static Sleef_double2 atan2k_u1(Sleef_double2 y, Sleef_double2 x) { + double u; + Sleef_double2 s, t; + int q = 0; + + if (x.x < 0) { x.x = -x.x; x.y = -x.y; q = -2; } + if (y.x > x.x) { t = x; x = y; y.x = -t.x; y.y = -t.y; q += 1; } + + s = dddiv_d2_d2_d2(y, x); + t = ddsqu_d2_d2(s); + t = ddnormalize_d2_d2(t); + + double t2 = t.x * t.x, t4 = t2 * t2, t8 = t4 * t4; + u = POLY16(t.x, t2, t4, t8, + 1.06298484191448746607415e-05, + -0.000125620649967286867384336, + 0.00070557664296393412389774, + -0.00251865614498713360352999, + 0.00646262899036991172313504, + -0.0128281333663399031014274, + 0.0208024799924145797902497, + -0.0289002344784740315686289, + 0.0359785005035104590853656, + -0.041848579703592507506027, + 0.0470843011653283988193763, + -0.0524914210588448421068719, + 0.0587946590969581003860434, + -0.0666620884778795497194182, + 0.0769225330296203768654095, + -0.0909090442773387574781907); + u = mla(u, t.x, 0.111111108376896236538123); + u = mla(u, t.x, -0.142857142756268568062339); + u = mla(u, t.x, 0.199999999997977351284817); + u = mla(u, t.x, -0.333333333333317605173818); + + t = ddadd_d2_d2_d2(s, ddmul_d2_d2_d(ddmul_d2_d2_d2(s, t), u)); + + if (fabsk(s.x) < 1e-200) t = s; + t = ddadd2_d2_d2_d2(ddmul_d2_d2_d(dd(1.570796326794896557998982, 6.12323399573676603586882e-17), q), t); + + return t; +} + +EXPORT CONST double xatan2_u1(double y, double x) { + if (fabsk(x) < 5.5626846462680083984e-309) { y *= (UINT64_C(1) << 53); x *= (UINT64_C(1) << 53); } // nexttoward((1.0 / DBL_MAX), 1) + Sleef_double2 d = atan2k_u1(dd(fabsk(y), 0), dd(x, 0)); + double r = d.x + d.y; + + r = mulsign(r, x); + if (xisinf(x) || x == 0) r = M_PI/2 - (xisinf(x) ? (sign(x) * (M_PI /2)) : 0); + if (xisinf(y) ) r = M_PI/2 - (xisinf(x) ? (sign(x) * (M_PI*1/4)) : 0); + if ( y == 0) r = (sign(x) == -1 ? M_PI : 0); + + return xisnan(x) || xisnan(y) ? SLEEF_NAN : mulsign(r, y); +} + +EXPORT CONST double xasin_u1(double d) { + int o = fabsk(d) < 0.5; + double x2 = o ? (d*d) : ((1-fabsk(d))*0.5), u; + Sleef_double2 x = o ? dd(fabsk(d), 0) : ddsqrt_d2_d(x2); + x = fabsk(d) == 1.0 ? dd(0, 0) : x; + + double x4 = x2 * x2, x8 = x4 * x4, x16 = x8 * x8; + u = POLY12(x2, x4, x8, x16, + +0.3161587650653934628e-1, + -0.1581918243329996643e-1, + +0.1929045477267910674e-1, + +0.6606077476277170610e-2, + +0.1215360525577377331e-1, + +0.1388715184501609218e-1, + +0.1735956991223614604e-1, + +0.2237176181932048341e-1, + +0.3038195928038132237e-1, + +0.4464285681377102438e-1, + +0.7500000000378581611e-1, + +0.1666666666666497543e+0); + + u *= x2 * x.x; + + Sleef_double2 y = ddadd_d2_d2_d(ddsub_d2_d2_d2(dd(3.141592653589793116/4, 1.2246467991473532072e-16/4), x), -u); + double r = o ? (u + x.x) : ((y.x + y.y)*2); + r = mulsign(r, d); + + return r; +} + +EXPORT CONST double xacos_u1(double d) { + int o = fabsk(d) < 0.5; + double x2 = o ? (d*d) : ((1-fabsk(d))*0.5), u; + Sleef_double2 x = o ? dd(fabsk(d), 0) : ddsqrt_d2_d(x2); + x = fabsk(d) == 1.0 ? dd(0, 0) : x; + + double x4 = x2 * x2, x8 = x4 * x4, x16 = x8 * x8; + u = POLY12(x2, x4, x8, x16, + +0.3161587650653934628e-1, + -0.1581918243329996643e-1, + +0.1929045477267910674e-1, + +0.6606077476277170610e-2, + +0.1215360525577377331e-1, + +0.1388715184501609218e-1, + +0.1735956991223614604e-1, + +0.2237176181932048341e-1, + +0.3038195928038132237e-1, + +0.4464285681377102438e-1, + +0.7500000000378581611e-1, + +0.1666666666666497543e+0); + + u *= x.x * x2; + + Sleef_double2 y = ddsub_d2_d2_d2(dd(3.141592653589793116/2, 1.2246467991473532072e-16/2), + ddadd_d2_d_d(mulsign(x.x, d), mulsign(u, d))); + x = ddadd_d2_d2_d(x, u); + y = o ? y : ddscale_d2_d2_d(x, 2); + if (!o && d < 0) y = ddsub_d2_d2_d2(dd(3.141592653589793116, 1.2246467991473532072e-16), y); + + return y.x + y.y; +} + +EXPORT CONST double xatan_u1(double d) { + Sleef_double2 d2 = atan2k_u1(dd(fabsk(d), 0), dd(1, 0)); + double r = d2.x + d2.y; + if (xisinf(d)) r = 1.570796326794896557998982; + return mulsign(r, d); +} + +typedef struct { + double d; + int32_t i; +} di_t; + +typedef struct { + Sleef_double2 dd; + int32_t i; +} ddi_t; + +static INLINE CONST double orsign(double x, double y) { + return longBitsToDouble(doubleToRawLongBits(x) | (doubleToRawLongBits(y) & (INT64_C(1) << 63))); +} + +static CONST di_t rempisub(double x) { + // This function is equivalent to : + // di_t ret = { x - rint(4 * x) * 0.25, (int32_t)(rint(4 * x) - rint(x) * 4) }; + di_t ret; + double c = mulsign(INT64_C(1) << 52, x); + double rint4x = fabsk(4*x) > INT64_C(1) << 52 ? (4*x) : orsign(mla(4, x, c) - c, x); + double rintx = fabsk( x) > INT64_C(1) << 52 ? x : orsign(x + c - c , x); + ret.d = mla(-0.25, rint4x, x); + ret.i = mla(-4 , rintx , rint4x); + return ret; +} + +// Payne-Hanek like argument reduction +static CONST ddi_t rempi(double a) { + Sleef_double2 x, y; + di_t di; + int ex = ilogb2k(a) - 55, q = ex > (700-55) ? -64 : 0; + a = ldexp3k(a, q); + if (ex < 0) ex = 0; + ex *= 4; + x = ddmul_d2_d_d(a, Sleef_rempitabdp[ex]); + di = rempisub(x.x); + q = di.i; + x.x = di.d; + x = ddnormalize_d2_d2(x); + y = ddmul_d2_d_d(a, Sleef_rempitabdp[ex+1]); + x = ddadd2_d2_d2_d2(x, y); + di = rempisub(x.x); + q += di.i; + x.x = di.d; + x = ddnormalize_d2_d2(x); + y = ddmul_d2_d2_d(dd(Sleef_rempitabdp[ex+2], Sleef_rempitabdp[ex+3]), a); + x = ddadd2_d2_d2_d2(x, y); + x = ddnormalize_d2_d2(x); + x = ddmul_d2_d2_d2(x, dd(3.141592653589793116*2, 1.2246467991473532072e-16*2)); + ddi_t ret = { fabsk(a) < 0.7 ? dd(a, 0) : x, q }; + return ret; +} + +EXPORT CONST double xsin(double d) { + double u, s, t = d; + int ql; + + if (fabsk(d) < TRIGRANGEMAX2) { + ql = rintk(d * M_1_PI); + d = mla(ql, -PI_A2, d); + d = mla(ql, -PI_B2, d); + } else if (fabsk(d) < TRIGRANGEMAX) { + double dqh = trunck(d * (M_1_PI / (1 << 24))) * (double)(1 << 24); + ql = rintk(mla(d, M_1_PI, -dqh)); + + d = mla(dqh, -PI_A, d); + d = mla( ql, -PI_A, d); + d = mla(dqh, -PI_B, d); + d = mla( ql, -PI_B, d); + d = mla(dqh, -PI_C, d); + d = mla( ql, -PI_C, d); + d = mla(dqh + ql, -PI_D, d); + } else { + ddi_t ddi = rempi(t); + ql = ((ddi.i & 3) * 2 + (ddi.dd.x > 0) + 1) >> 2; + if ((ddi.i & 1) != 0) { + ddi.dd = ddadd2_d2_d2_d2(ddi.dd, dd(mulsign(3.141592653589793116*-0.5, ddi.dd.x), + mulsign(1.2246467991473532072e-16*-0.5, ddi.dd.x))); + } + d = ddi.dd.x + ddi.dd.y; + if (xisinf(t) || xisnan(t)) d = SLEEF_NAN; + } + + s = d * d; + + if ((ql & 1) != 0) d = -d; + + double s2 = s * s, s4 = s2 * s2; + u = POLY8(s, s2, s4, + -7.97255955009037868891952e-18, + 2.81009972710863200091251e-15, + -7.64712219118158833288484e-13, + 1.60590430605664501629054e-10, + -2.50521083763502045810755e-08, + 2.75573192239198747630416e-06, + -0.000198412698412696162806809, + 0.00833333333333332974823815); + u = mla(u, s, -0.166666666666666657414808); + + u = mla(s, u * d, d); + + if (xisnegzero(t)) u = t; + + return u; +} + +EXPORT CONST double xsin_u1(double d) { + double u; + Sleef_double2 s, t, x; + int ql; + + if (fabsk(d) < TRIGRANGEMAX2) { + ql = rintk(d * M_1_PI); + u = mla(ql, -PI_A2, d); + s = ddadd_d2_d_d (u, ql * -PI_B2); + } else if (fabsk(d) < TRIGRANGEMAX) { + const double dqh = trunck(d * (M_1_PI / (1 << 24))) * (double)(1 << 24); + ql = rintk(mla(d, M_1_PI, -dqh)); + + u = mla(dqh, -PI_A, d); + s = ddadd_d2_d_d (u, ql * -PI_A); + s = ddadd2_d2_d2_d(s, dqh * -PI_B); + s = ddadd2_d2_d2_d(s, ql * -PI_B); + s = ddadd2_d2_d2_d(s, dqh * -PI_C); + s = ddadd2_d2_d2_d(s, ql * -PI_C); + s = ddadd_d2_d2_d (s, (dqh + ql) * -PI_D); + } else { + ddi_t ddi = rempi(d); + ql = ((ddi.i & 3) * 2 + (ddi.dd.x > 0) + 1) >> 2; + if ((ddi.i & 1) != 0) { + ddi.dd = ddadd2_d2_d2_d2(ddi.dd, dd(mulsign(3.141592653589793116*-0.5, ddi.dd.x), + mulsign(1.2246467991473532072e-16*-0.5, ddi.dd.x))); + } + s = ddnormalize_d2_d2(ddi.dd); + if (xisinf(d) || xisnan(d)) s.x = SLEEF_NAN; + } + + t = s; + s = ddsqu_d2_d2(s); + + double s2 = s.x * s.x, s4 = s2 * s2; + u = POLY6(s.x, s2, s4, + 2.72052416138529567917983e-15, + -7.6429259411395447190023e-13, + 1.60589370117277896211623e-10, + -2.5052106814843123359368e-08, + 2.75573192104428224777379e-06, + -0.000198412698412046454654947); + u = mla(u, s.x, 0.00833333333333318056201922); + + x = ddadd_d2_d_d2(1, ddmul_d2_d2_d2(ddadd_d2_d_d(-0.166666666666666657414808, u * s.x), s)); + u = ddmul_d_d2_d2(t, x); + + if ((ql & 1) != 0) u = -u; + if (xisnegzero(d)) u = d; + + return u; +} + +EXPORT CONST double xcos(double d) { + double u, s, t = d; + int ql; + + if (fabsk(d) < TRIGRANGEMAX2) { + ql = mla(2, rintk(d * M_1_PI - 0.5), 1); + d = mla(ql, -PI_A2*0.5, d); + d = mla(ql, -PI_B2*0.5, d); + } else if (fabsk(d) < TRIGRANGEMAX) { + double dqh = trunck(d * (M_1_PI / (INT64_C(1) << 23)) - 0.5 * (M_1_PI / (INT64_C(1) << 23))); + ql = 2*rintk(d * M_1_PI - 0.5 - dqh * (double)(INT64_C(1) << 23))+1; + dqh *= 1 << 24; + + d = mla(dqh, -PI_A*0.5, d); + d = mla( ql, -PI_A*0.5, d); + d = mla(dqh, -PI_B*0.5, d); + d = mla( ql, -PI_B*0.5, d); + d = mla(dqh, -PI_C*0.5, d); + d = mla( ql, -PI_C*0.5, d); + d = mla(dqh + ql , -PI_D*0.5, d); + } else { + ddi_t ddi = rempi(t); + ql = ((ddi.i & 3) * 2 + (ddi.dd.x > 0) + 7) >> 1; + if ((ddi.i & 1) == 0) { + ddi.dd = ddadd2_d2_d2_d2(ddi.dd, dd(mulsign(3.141592653589793116*-0.5, ddi.dd.x > 0 ? 1 : -1), + mulsign(1.2246467991473532072e-16*-0.5, ddi.dd.x > 0 ? 1 : -1))); + } + d = ddi.dd.x + ddi.dd.y; + if (xisinf(t) || xisnan(t)) d = SLEEF_NAN; + } + + s = d * d; + + if ((ql & 2) == 0) d = -d; + + double s2 = s * s, s4 = s2 * s2; + u = POLY8(s, s2, s4, + -7.97255955009037868891952e-18, + 2.81009972710863200091251e-15, + -7.64712219118158833288484e-13, + 1.60590430605664501629054e-10, + -2.50521083763502045810755e-08, + 2.75573192239198747630416e-06, + -0.000198412698412696162806809, + 0.00833333333333332974823815); + u = mla(u, s, -0.166666666666666657414808); + + u = mla(s, u * d, d); + + return u; +} + +EXPORT CONST double xcos_u1(double d) { + double u; + Sleef_double2 s, t, x; + int ql; + + d = fabsk(d); + + if (d < TRIGRANGEMAX2) { + ql = mla(2, rintk(d * M_1_PI - 0.5), 1); + s = ddadd2_d2_d_d(d, ql * (-PI_A2*0.5)); + s = ddadd_d2_d2_d(s, ql * (-PI_B2*0.5)); + } else if (d < TRIGRANGEMAX) { + double dqh = trunck(d * (M_1_PI / (INT64_C(1) << 23)) - 0.5 * (M_1_PI / (INT64_C(1) << 23))); + ql = 2*rintk(d * M_1_PI - 0.5 - dqh * (double)(INT64_C(1) << 23))+1; + dqh *= 1 << 24; + + u = mla(dqh, -PI_A*0.5, d); + s = ddadd2_d2_d_d (u, ql * (-PI_A*0.5)); + s = ddadd2_d2_d2_d(s, dqh * (-PI_B*0.5)); + s = ddadd2_d2_d2_d(s, ql * (-PI_B*0.5)); + s = ddadd2_d2_d2_d(s, dqh * (-PI_C*0.5)); + s = ddadd2_d2_d2_d(s, ql * (-PI_C*0.5)); + s = ddadd_d2_d2_d(s, (dqh + ql) * (-PI_D*0.5)); + } else { + ddi_t ddi = rempi(d); + ql = ((ddi.i & 3) * 2 + (ddi.dd.x > 0) + 7) >> 1; + if ((ddi.i & 1) == 0) { + ddi.dd = ddadd2_d2_d2_d2(ddi.dd, dd(mulsign(3.141592653589793116*-0.5, ddi.dd.x > 0 ? 1 : -1), + mulsign(1.2246467991473532072e-16*-0.5, ddi.dd.x > 0 ? 1 : -1))); + } + s = ddnormalize_d2_d2(ddi.dd); + if (xisinf(d) || xisnan(d)) s.x = SLEEF_NAN; + } + + t = s; + s = ddsqu_d2_d2(s); + + double s2 = s.x * s.x, s4 = s2 * s2; + u = POLY6(s.x, s2, s4, + 2.72052416138529567917983e-15, + -7.6429259411395447190023e-13, + 1.60589370117277896211623e-10, + -2.5052106814843123359368e-08, + 2.75573192104428224777379e-06, + -0.000198412698412046454654947); + u = mla(u, s.x, 0.00833333333333318056201922); + + x = ddadd_d2_d_d2(1, ddmul_d2_d2_d2(ddadd_d2_d_d(-0.166666666666666657414808, u * s.x), s)); + u = ddmul_d_d2_d2(t, x); + + if ((((int)ql) & 2) == 0) u = -u; + + return u; +} + +EXPORT CONST Sleef_double2 xsincos(double d) { + double u, s, t; + Sleef_double2 r; + int ql; + + s = d; + + if (fabsk(d) < TRIGRANGEMAX2) { + ql = rintk(s * (2 * M_1_PI)); + s = mla(ql, -PI_A2*0.5, s); + s = mla(ql, -PI_B2*0.5, s); + } else if (fabsk(d) < TRIGRANGEMAX) { + double dqh = trunck(d * ((2 * M_1_PI) / (1 << 24))) * (double)(1 << 24); + ql = rintk(d * (2 * M_1_PI) - dqh); + + s = mla(dqh, -PI_A * 0.5, s); + s = mla( ql, -PI_A * 0.5, s); + s = mla(dqh, -PI_B * 0.5, s); + s = mla( ql, -PI_B * 0.5, s); + s = mla(dqh, -PI_C * 0.5, s); + s = mla( ql, -PI_C * 0.5, s); + s = mla(dqh + ql, -PI_D * 0.5, s); + } else { + ddi_t ddi = rempi(d); + ql = ddi.i; + s = ddi.dd.x + ddi.dd.y; + if (xisinf(d) || xisnan(d)) s = SLEEF_NAN; + } + + t = s; + + s = s * s; + + u = 1.58938307283228937328511e-10; + u = mla(u, s, -2.50506943502539773349318e-08); + u = mla(u, s, 2.75573131776846360512547e-06); + u = mla(u, s, -0.000198412698278911770864914); + u = mla(u, s, 0.0083333333333191845961746); + u = mla(u, s, -0.166666666666666130709393); + u = u * s * t; + + r.x = t + u; + + if (xisnegzero(d)) r.x = -0.0; + + u = -1.13615350239097429531523e-11; + u = mla(u, s, 2.08757471207040055479366e-09); + u = mla(u, s, -2.75573144028847567498567e-07); + u = mla(u, s, 2.48015872890001867311915e-05); + u = mla(u, s, -0.00138888888888714019282329); + u = mla(u, s, 0.0416666666666665519592062); + u = mla(u, s, -0.5); + + r.y = u * s + 1; + + if ((ql & 1) != 0) { s = r.y; r.y = r.x; r.x = s; } + if ((ql & 2) != 0) { r.x = -r.x; } + if (((ql+1) & 2) != 0) { r.y = -r.y; } + + return r; +} + +EXPORT CONST Sleef_double2 xsincos_u1(double d) { + double u; + Sleef_double2 r, s, t, x; + int ql; + + if (fabsk(d) < TRIGRANGEMAX2) { + ql = rintk(d * (2 * M_1_PI)); + u = mla(ql, -PI_A2*0.5, d); + s = ddadd_d2_d_d (u, ql * (-PI_B2*0.5)); + } else if (fabsk(d) < TRIGRANGEMAX) { + const double dqh = trunck(d * ((2 * M_1_PI) / (1 << 24))) * (double)(1 << 24); + ql = rintk(d * (2 * M_1_PI) - dqh); + + u = mla(dqh, -PI_A*0.5, d); + s = ddadd_d2_d_d(u, ql * (-PI_A*0.5)); + s = ddadd2_d2_d2_d(s, dqh * (-PI_B*0.5)); + s = ddadd2_d2_d2_d(s, ql * (-PI_B*0.5)); + s = ddadd2_d2_d2_d(s, dqh * (-PI_C*0.5)); + s = ddadd2_d2_d2_d(s, ql * (-PI_C*0.5)); + s = ddadd_d2_d2_d(s, (dqh + ql) * (-PI_D*0.5)); + } else { + ddi_t ddi = rempi(d); + ql = ddi.i; + s = ddi.dd; + if (xisinf(d) || xisnan(d)) s = dd(SLEEF_NAN, SLEEF_NAN); + } + + t = s; + + s.x = ddsqu_d_d2(s); + + u = 1.58938307283228937328511e-10; + u = mla(u, s.x, -2.50506943502539773349318e-08); + u = mla(u, s.x, 2.75573131776846360512547e-06); + u = mla(u, s.x, -0.000198412698278911770864914); + u = mla(u, s.x, 0.0083333333333191845961746); + u = mla(u, s.x, -0.166666666666666130709393); + + u *= s.x * t.x; + + x = ddadd_d2_d2_d(t, u); + r.x = x.x + x.y; + + if (xisnegzero(d)) r.x = -0.0; + + u = -1.13615350239097429531523e-11; + u = mla(u, s.x, 2.08757471207040055479366e-09); + u = mla(u, s.x, -2.75573144028847567498567e-07); + u = mla(u, s.x, 2.48015872890001867311915e-05); + u = mla(u, s.x, -0.00138888888888714019282329); + u = mla(u, s.x, 0.0416666666666665519592062); + u = mla(u, s.x, -0.5); + + x = ddadd_d2_d_d2(1, ddmul_d2_d_d(s.x, u)); + r.y = x.x + x.y; + + if ((ql & 1) != 0) { u = r.y; r.y = r.x; r.x = u; } + if ((ql & 2) != 0) { r.x = -r.x; } + if (((ql+1) & 2) != 0) { r.y = -r.y; } + + return r; +} + +EXPORT CONST Sleef_double2 xsincospi_u05(double d) { + double u, s, t; + Sleef_double2 r, x, s2; + + u = d * 4; + int q = ceilk(u) & ~(int)1; + + s = u - (double)q; + t = s; + s = s * s; + s2 = ddmul_d2_d_d(t, t); + + // + + u = -2.02461120785182399295868e-14; + u = mla(u, s, 6.94821830580179461327784e-12); + u = mla(u, s, -1.75724749952853179952664e-09); + u = mla(u, s, 3.13361688966868392878422e-07); + u = mla(u, s, -3.6576204182161551920361e-05); + u = mla(u, s, 0.00249039457019271850274356); + x = ddadd2_d2_d_d2(u * s, dd(-0.0807455121882807852484731, 3.61852475067037104849987e-18)); + x = ddadd2_d2_d2_d2(ddmul_d2_d2_d2(s2, x), dd(0.785398163397448278999491, 3.06287113727155002607105e-17)); + + x = ddmul_d2_d2_d(x, t); + r.x = x.x + x.y; + + if (xisnegzero(d)) r.x = -0.0; + + // + + u = 9.94480387626843774090208e-16; + u = mla(u, s, -3.89796226062932799164047e-13); + u = mla(u, s, 1.15011582539996035266901e-10); + u = mla(u, s, -2.4611369501044697495359e-08); + u = mla(u, s, 3.59086044859052754005062e-06); + u = mla(u, s, -0.000325991886927389905997954); + x = ddadd2_d2_d_d2(u * s, dd(0.0158543442438155018914259, -1.04693272280631521908845e-18)); + x = ddadd2_d2_d2_d2(ddmul_d2_d2_d2(s2, x), dd(-0.308425137534042437259529, -1.95698492133633550338345e-17)); + + x = ddadd2_d2_d2_d(ddmul_d2_d2_d2(x, s2), 1); + r.y = x.x + x.y; + + // + + if ((q & 2) != 0) { s = r.y; r.y = r.x; r.x = s; } + if ((q & 4) != 0) { r.x = -r.x; } + if (((q+2) & 4) != 0) { r.y = -r.y; } + + if (fabsk(d) > TRIGRANGEMAX3/4) { r.x = 0; r.y = 1; } + if (xisinf(d)) { r.x = r.y = SLEEF_NAN; } + + return r; +} + +EXPORT CONST Sleef_double2 xsincospi_u35(double d) { + double u, s, t; + Sleef_double2 r; + + u = d * 4; + int q = ceilk(u) & ~(int)1; + + s = u - (double)q; + t = s; + s = s * s; + + // + + u = +0.6880638894766060136e-11; + u = mla(u, s, -0.1757159564542310199e-8); + u = mla(u, s, +0.3133616327257867311e-6); + u = mla(u, s, -0.3657620416388486452e-4); + u = mla(u, s, +0.2490394570189932103e-2); + u = mla(u, s, -0.8074551218828056320e-1); + u = mla(u, s, +0.7853981633974482790e+0); + + r.x = u * t; + + // + + u = -0.3860141213683794352e-12; + u = mla(u, s, +0.1150057888029681415e-9); + u = mla(u, s, -0.2461136493006663553e-7); + u = mla(u, s, +0.3590860446623516713e-5); + u = mla(u, s, -0.3259918869269435942e-3); + u = mla(u, s, +0.1585434424381541169e-1); + u = mla(u, s, -0.3084251375340424373e+0); + u = mla(u, s, 1); + + r.y = u; + + // + + if ((q & 2) != 0) { s = r.y; r.y = r.x; r.x = s; } + if ((q & 4) != 0) { r.x = -r.x; } + if (((q+2) & 4) != 0) { r.y = -r.y; } + + if (fabsk(d) > TRIGRANGEMAX3/4) { r.x = 0; r.y = 1; } + if (xisinf(d)) { r.x = r.y = SLEEF_NAN; } + + return r; +} + +static INLINE CONST Sleef_double2 sinpik(double d) { + double u, s, t; + Sleef_double2 x, s2; + + u = d * 4; + int q = ceilk(u) & ~1; + int o = (q & 2) != 0; + + s = u - (double)q; + t = s; + s = s * s; + s2 = ddmul_d2_d_d(t, t); + + // + + u = o ? 9.94480387626843774090208e-16 : -2.02461120785182399295868e-14; + u = mla(u, s, o ? -3.89796226062932799164047e-13 : 6.94821830580179461327784e-12); + u = mla(u, s, o ? 1.15011582539996035266901e-10 : -1.75724749952853179952664e-09); + u = mla(u, s, o ? -2.4611369501044697495359e-08 : 3.13361688966868392878422e-07); + u = mla(u, s, o ? 3.59086044859052754005062e-06 : -3.6576204182161551920361e-05); + u = mla(u, s, o ? -0.000325991886927389905997954 : 0.00249039457019271850274356); + x = ddadd2_d2_d_d2(u * s, o ? dd(0.0158543442438155018914259, -1.04693272280631521908845e-18) : + dd(-0.0807455121882807852484731, 3.61852475067037104849987e-18)); + x = ddadd2_d2_d2_d2(ddmul_d2_d2_d2(s2, x), o ? dd(-0.308425137534042437259529, -1.95698492133633550338345e-17) : + dd(0.785398163397448278999491, 3.06287113727155002607105e-17)); + + x = ddmul_d2_d2_d2(x, o ? s2 : dd(t, 0)); + x = o ? ddadd2_d2_d2_d(x, 1) : x; + + // + + if ((q & 4) != 0) { x.x = -x.x; x.y = -x.y; } + + return x; +} + +EXPORT CONST double xsinpi_u05(double d) { + Sleef_double2 x = sinpik(d); + double r = x.x + x.y; + + if (xisnegzero(d)) r = -0.0; + if (fabsk(d) > TRIGRANGEMAX3/4) r = 0; + if (xisinf(d)) r = SLEEF_NAN; + + return r; +} + +static INLINE CONST Sleef_double2 cospik(double d) { + double u, s, t; + Sleef_double2 x, s2; + + u = d * 4; + int q = ceilk(u) & ~1; + int o = (q & 2) == 0; + + s = u - (double)q; + t = s; + s = s * s; + s2 = ddmul_d2_d_d(t, t); + + // + + u = o ? 9.94480387626843774090208e-16 : -2.02461120785182399295868e-14; + u = mla(u, s, o ? -3.89796226062932799164047e-13 : 6.94821830580179461327784e-12); + u = mla(u, s, o ? 1.15011582539996035266901e-10 : -1.75724749952853179952664e-09); + u = mla(u, s, o ? -2.4611369501044697495359e-08 : 3.13361688966868392878422e-07); + u = mla(u, s, o ? 3.59086044859052754005062e-06 : -3.6576204182161551920361e-05); + u = mla(u, s, o ? -0.000325991886927389905997954 : 0.00249039457019271850274356); + x = ddadd2_d2_d_d2(u * s, o ? dd(0.0158543442438155018914259, -1.04693272280631521908845e-18) : + dd(-0.0807455121882807852484731, 3.61852475067037104849987e-18)); + x = ddadd2_d2_d2_d2(ddmul_d2_d2_d2(s2, x), o ? dd(-0.308425137534042437259529, -1.95698492133633550338345e-17) : + dd(0.785398163397448278999491, 3.06287113727155002607105e-17)); + + x = ddmul_d2_d2_d2(x, o ? s2 : dd(t, 0)); + x = o ? ddadd2_d2_d2_d(x, 1) : x; + + // + + if (((q+2) & 4) != 0) { x.x = -x.x; x.y = -x.y; } + + return x; +} + +EXPORT CONST double xcospi_u05(double d) { + Sleef_double2 x = cospik(d); + double r = x.x + x.y; + + if (fabsk(d) > TRIGRANGEMAX3/4) r = 1; + if (xisinf(d)) r = SLEEF_NAN; + + return r; +} + +EXPORT CONST double xtan(double d) { + double u, s, x, y; + int ql; + + if (fabsk(d) < TRIGRANGEMAX2) { + ql = rintk(d * (2 * M_1_PI)); + x = mla(ql, -PI_A2*0.5, d); + x = mla(ql, -PI_B2*0.5, x); + } else if (fabsk(d) < 1e+6) { + double dqh = trunck(d * ((2 * M_1_PI) / (1 << 24))) * (double)(1 << 24); + ql = rintk(d * (2 * M_1_PI) - dqh); + + x = mla(dqh, -PI_A * 0.5, d); + x = mla( ql, -PI_A * 0.5, x); + x = mla(dqh, -PI_B * 0.5, x); + x = mla( ql, -PI_B * 0.5, x); + x = mla(dqh, -PI_C * 0.5, x); + x = mla( ql, -PI_C * 0.5, x); + x = mla(dqh + ql, -PI_D * 0.5, x); + } else { + ddi_t ddi = rempi(d); + ql = ddi.i; + x = ddi.dd.x + ddi.dd.y; + if (xisinf(d) || xisnan(d)) x = SLEEF_NAN; + } + + x *= 0.5; + s = x * x; + + double s2 = s * s, s4 = s2 * s2; + u = POLY8(s, s2, s4, + +0.3245098826639276316e-3, + +0.5619219738114323735e-3, + +0.1460781502402784494e-2, + +0.3591611540792499519e-2, + +0.8863268409563113126e-2, + +0.2186948728185535498e-1, + +0.5396825399517272970e-1, + +0.1333333333330500581e+0); + + u = mla(u, s, +0.3333333333333343695e+0); + u = mla(s, u * x, x); + + y = mla(u, u, -1); + x = -2 * u; + + if ((ql & 1) != 0) { double t = x; x = y; y = -t; } + + u = x / y; + + return u; +} + +EXPORT CONST double xtan_u1(double d) { + double u; + Sleef_double2 s, t, x, y; + int ql; + + if (fabsk(d) < TRIGRANGEMAX2) { + ql = rintk(d * (2 * M_1_PI)); + u = mla(ql, -PI_A2*0.5, d); + s = ddadd_d2_d_d(u, ql * (-PI_B2*0.5)); + } else if (fabsk(d) < TRIGRANGEMAX) { + const double dqh = trunck(d * (M_2_PI / (1 << 24))) * (double)(1 << 24); + s = ddadd2_d2_d2_d(ddmul_d2_d2_d(dd(M_2_PI_H, M_2_PI_L), d), (d < 0 ? -0.5 : 0.5) - dqh); + ql = s.x + s.y; + + u = mla(dqh, -PI_A*0.5, d); + s = ddadd_d2_d_d (u, ql * (-PI_A*0.5)); + s = ddadd2_d2_d2_d(s, dqh * (-PI_B*0.5)); + s = ddadd2_d2_d2_d(s, ql * (-PI_B*0.5)); + s = ddadd2_d2_d2_d(s, dqh * (-PI_C*0.5)); + s = ddadd2_d2_d2_d(s, ql * (-PI_C*0.5)); + s = ddadd_d2_d2_d(s, (dqh + ql) * (-PI_D*0.5)); + } else { + ddi_t ddi = rempi(d); + ql = ddi.i; + s = ddi.dd; + if (xisinf(d) || xisnan(d)) s.x = SLEEF_NAN; + } + + t = ddscale_d2_d2_d(s, 0.5); + s = ddsqu_d2_d2(t); + + double s2 = s.x * s.x, s4 = s2 * s2; + u = POLY8(s.x, s2, s4, + +0.3245098826639276316e-3, + +0.5619219738114323735e-3, + +0.1460781502402784494e-2, + +0.3591611540792499519e-2, + +0.8863268409563113126e-2, + +0.2186948728185535498e-1, + +0.5396825399517272970e-1, + +0.1333333333330500581e+0); + + u = mla(u, s.x, +0.3333333333333343695e+0); + x = ddadd_d2_d2_d2(t, ddmul_d2_d2_d(ddmul_d2_d2_d2(s, t), u)); + + y = ddadd_d2_d_d2(-1, ddsqu_d2_d2(x)); + x = ddscale_d2_d2_d(x, -2); + + if ((ql & 1) != 0) { t = x; x = y; y = ddneg_d2_d2(t); } + + x = dddiv_d2_d2_d2(x, y); + + u = x.x + x.y; + + if (xisnegzero(d)) u = d; + + return u; +} + +EXPORT CONST double xlog(double d) { + double x, x2, t, m; + int e; + + int o = d < DBL_MIN; + if (o) d *= (double)(INT64_C(1) << 32) * (double)(INT64_C(1) << 32); + + e = ilogb2k(d * (1.0/0.75)); + m = ldexp3k(d, -e); + + if (o) e -= 64; + + x = (m-1) / (m+1); + x2 = x * x; + + double x4 = x2 * x2, x8 = x4 * x4; + + t = POLY7(x2, x4, x8, + 0.153487338491425068243146, + 0.152519917006351951593857, + 0.181863266251982985677316, + 0.222221366518767365905163, + 0.285714294746548025383248, + 0.399999999950799600689777, + 0.6666666666667778740063); + + x = x * 2 + 0.693147180559945286226764 * e + x * x2 * t; + + if (xisinf(d)) x = SLEEF_INFINITY; + if (d < 0 || xisnan(d)) x = SLEEF_NAN; + if (d == 0) x = -SLEEF_INFINITY; + + return x; +} + +EXPORT CONST double xexp(double d) { + int q = (int)rintk(d * R_LN2); + double s, u; + + s = mla(q, -L2U, d); + s = mla(q, -L2L, s); + + double s2 = s * s, s4 = s2 * s2, s8 = s4 * s4; + u = POLY10(s, s2, s4, s8, + 2.08860621107283687536341e-09, + 2.51112930892876518610661e-08, + 2.75573911234900471893338e-07, + 2.75572362911928827629423e-06, + 2.4801587159235472998791e-05, + 0.000198412698960509205564975, + 0.00138888888889774492207962, + 0.00833333333331652721664984, + 0.0416666666666665047591422, + 0.166666666666666851703837); + u = mla(u, s, +0.5); + + u = s * s * u + s + 1; + u = ldexp2k(u, q); + + if (d > 709.78271114955742909217217426) u = SLEEF_INFINITY; + if (d < -1000) u = 0; + + return u; +} + +static INLINE CONST double expm1k(double d) { + int q = (int)rintk(d * R_LN2); + double s, u; + + s = mla(q, -L2U, d); + s = mla(q, -L2L, s); + + double s2 = s * s, s4 = s2 * s2, s8 = s4 * s4; + u = POLY10(s, s2, s4, s8, + 2.08860621107283687536341e-09, + 2.51112930892876518610661e-08, + 2.75573911234900471893338e-07, + 2.75572362911928827629423e-06, + 2.4801587159235472998791e-05, + 0.000198412698960509205564975, + 0.00138888888889774492207962, + 0.00833333333331652721664984, + 0.0416666666666665047591422, + 0.166666666666666851703837); + + u = mla(s2, 0.5, s2 * s * u) + s; + + if (q != 0) u = ldexp2k(u + 1, q) - 1; + + return u; +} + +static INLINE CONST Sleef_double2 logk(double d) { + Sleef_double2 x, x2, s; + double m, t; + int e; + + int o = d < DBL_MIN; + if (o) d *= (double)(INT64_C(1) << 32) * (double)(INT64_C(1) << 32); + + e = ilogb2k(d * (1.0/0.75)); + m = ldexp3k(d, -e); + + if (o) e -= 64; + + x = dddiv_d2_d2_d2(ddadd2_d2_d_d(-1, m), ddadd2_d2_d_d(1, m)); + x2 = ddsqu_d2_d2(x); + + double x4 = x2.x * x2.x, x8 = x4 * x4, x16 = x8 * x8; + t = POLY9(x2.x, x4, x8, x16, + 0.116255524079935043668677, + 0.103239680901072952701192, + 0.117754809412463995466069, + 0.13332981086846273921509, + 0.153846227114512262845736, + 0.181818180850050775676507, + 0.222222222230083560345903, + 0.285714285714249172087875, + 0.400000000000000077715612); + + Sleef_double2 c = dd(0.666666666666666629659233, 3.80554962542412056336616e-17); + s = ddmul_d2_d2_d(dd(0.693147180559945286226764, 2.319046813846299558417771e-17), e); + s = ddadd_d2_d2_d2(s, ddscale_d2_d2_d(x, 2)); + x = ddmul_d2_d2_d2(x2, x); + s = ddadd_d2_d2_d2(s, ddmul_d2_d2_d2(x, c)); + x = ddmul_d2_d2_d2(x2, x); + s = ddadd_d2_d2_d2(s, ddmul_d2_d2_d(x, t)); + + return s; +} + +EXPORT CONST double xlog_u1(double d) { + Sleef_double2 x, s; + double m, t, x2; + int e; + + int o = d < DBL_MIN; + if (o) d *= (double)(INT64_C(1) << 32) * (double)(INT64_C(1) << 32); + + e = ilogb2k(d * (1.0/0.75)); + m = ldexp3k(d, -e); + + if (o) e -= 64; + + x = dddiv_d2_d2_d2(ddadd2_d2_d_d(-1, m), ddadd2_d2_d_d(1, m)); + x2 = x.x * x.x; + + double x4 = x2 * x2, x8 = x4 * x4; + t = POLY7(x2, x4, x8, + 0.1532076988502701353e+0, + 0.1525629051003428716e+0, + 0.1818605932937785996e+0, + 0.2222214519839380009e+0, + 0.2857142932794299317e+0, + 0.3999999999635251990e+0, + 0.6666666666667333541e+0); + + s = ddmul_d2_d2_d(dd(0.693147180559945286226764, 2.319046813846299558417771e-17), (double)e); + s = ddadd_d2_d2_d2(s, ddscale_d2_d2_d(x, 2)); + s = ddadd_d2_d2_d(s, x2 * x.x * t); + + double r = s.x + s.y; + + if (xisinf(d)) r = SLEEF_INFINITY; + if (d < 0 || xisnan(d)) r = SLEEF_NAN; + if (d == 0) r = -SLEEF_INFINITY; + + return r; +} + +static INLINE CONST double expk(Sleef_double2 d) { + int q = (int)rintk((d.x + d.y) * R_LN2); + Sleef_double2 s, t; + double u; + + s = ddadd2_d2_d2_d(d, q * -L2U); + s = ddadd2_d2_d2_d(s, q * -L2L); + + s = ddnormalize_d2_d2(s); + + double s2 = s.x * s.x, s4 = s2 * s2, s8 = s4 * s4; + u = POLY10(s.x, s2, s4, s8, + 2.51069683420950419527139e-08, + 2.76286166770270649116855e-07, + 2.75572496725023574143864e-06, + 2.48014973989819794114153e-05, + 0.000198412698809069797676111, + 0.0013888888939977128960529, + 0.00833333333332371417601081, + 0.0416666666665409524128449, + 0.166666666666666740681535, + 0.500000000000000999200722); + + t = ddadd_d2_d_d2(1, s); + t = ddadd_d2_d2_d2(t, ddmul_d2_d2_d(ddsqu_d2_d2(s), u)); + + u = ldexpk(t.x + t.y, q); + + if (d.x < -1000) u = 0; + + return u; +} + +EXPORT CONST double xpow(double x, double y) { + int yisint = xisint(y); + int yisodd = yisint && xisodd(y); + + Sleef_double2 d = ddmul_d2_d2_d(logk(fabsk(x)), y); + double result = expk(d); + + result = (d.x > 709.78271114955742909217217426 || xisnan(result)) ? SLEEF_INFINITY : result; + result *= (x > 0 ? 1 : (yisint ? (yisodd ? -1 : 1) : SLEEF_NAN)); + + double efx = mulsign(fabsk(x) - 1, y); + if (xisinf(y)) result = efx < 0 ? 0.0 : (efx == 0 ? 1.0 : SLEEF_INFINITY); + if (xisinf(x) || x == 0) result = mulsign((xsignbit(y) ^ (x == 0)) ? 0 : SLEEF_INFINITY, yisodd ? x : 1); + if (xisnan(x) || xisnan(y)) result = SLEEF_NAN; + if (y == 0 || x == 1) result = 1; + + return result; +} + +static INLINE CONST Sleef_double2 expk2(Sleef_double2 d) { + int q = (int)rintk((d.x + d.y) * R_LN2); + Sleef_double2 s, t; + double u; + + s = ddadd2_d2_d2_d(d, q * -L2U); + s = ddadd2_d2_d2_d(s, q * -L2L); + + u = +0.1602472219709932072e-9; + u = mla(u, s.x, +0.2092255183563157007e-8); + u = mla(u, s.x, +0.2505230023782644465e-7); + u = mla(u, s.x, +0.2755724800902135303e-6); + u = mla(u, s.x, +0.2755731892386044373e-5); + u = mla(u, s.x, +0.2480158735605815065e-4); + u = mla(u, s.x, +0.1984126984148071858e-3); + u = mla(u, s.x, +0.1388888888886763255e-2); + u = mla(u, s.x, +0.8333333333333347095e-2); + u = mla(u, s.x, +0.4166666666666669905e-1); + + t = ddadd2_d2_d2_d(ddmul_d2_d2_d(s, u), +0.1666666666666666574e+0); + t = ddadd2_d2_d2_d(ddmul_d2_d2_d2(s, t), 0.5); + t = ddadd2_d2_d2_d2(s, ddmul_d2_d2_d2(ddsqu_d2_d2(s), t)); + + t = ddadd2_d2_d_d2(1, t); + + t.x = ldexp2k(t.x, q); + t.y = ldexp2k(t.y, q); + + return d.x < -1000 ? dd(0, 0) : t; +} + +EXPORT CONST double xsinh(double x) { + double y = fabsk(x); + Sleef_double2 d = expk2(dd(y, 0)); + d = ddsub_d2_d2_d2(d, ddrec_d2_d2(d)); + y = (d.x + d.y) * 0.5; + + y = fabsk(x) > 710 ? SLEEF_INFINITY : y; + y = xisnan(y) ? SLEEF_INFINITY : y; + y = mulsign(y, x); + y = xisnan(x) ? SLEEF_NAN : y; + + return y; +} + +EXPORT CONST double xcosh(double x) { + double y = fabsk(x); + Sleef_double2 d = expk2(dd(y, 0)); + d = ddadd_d2_d2_d2(d, ddrec_d2_d2(d)); + y = (d.x + d.y) * 0.5; + + y = fabsk(x) > 710 ? SLEEF_INFINITY : y; + y = xisnan(y) ? SLEEF_INFINITY : y; + y = xisnan(x) ? SLEEF_NAN : y; + + return y; +} + +EXPORT CONST double xtanh(double x) { + double y = fabsk(x); + Sleef_double2 d = expk2(dd(y, 0)); + Sleef_double2 e = ddrec_d2_d2(d); + d = dddiv_d2_d2_d2(ddsub_d2_d2_d2(d, e), ddadd_d2_d2_d2(d, e)); + y = d.x + d.y; + + y = fabsk(x) > 18.714973875 ? 1.0 : y; + y = xisnan(y) ? 1.0 : y; + y = mulsign(y, x); + y = xisnan(x) ? SLEEF_NAN : y; + + return y; +} + +EXPORT CONST double xsinh_u35(double x) { + double e = expm1k(fabsk(x)); + double y = (e + 2) / (e + 1) * (0.5 * e); + + y = fabsk(x) > 709 ? SLEEF_INFINITY : y; + y = xisnan(y) ? SLEEF_INFINITY : y; + y = mulsign(y, x); + y = xisnan(x) ? SLEEF_NAN : y; + + return y; +} + +EXPORT CONST double xcosh_u35(double x) { + double e = xexp(fabsk(x)); + double y = 0.5 / e + 0.5 * e; + + y = fabsk(x) > 709 ? SLEEF_INFINITY : y; + y = xisnan(y) ? SLEEF_INFINITY : y; + y = xisnan(x) ? SLEEF_NAN : y; + + return y; +} + +EXPORT CONST double xtanh_u35(double x) { + double y = fabsk(x); + double d = expm1k(2*y); + y = d / (d + 2); + + y = fabsk(x) > 18.714973875 ? 1.0 : y; + y = xisnan(y) ? 1.0 : y; + y = mulsign(y, x); + y = xisnan(x) ? SLEEF_NAN : y; + + return y; +} + +static INLINE CONST Sleef_double2 logk2(Sleef_double2 d) { + Sleef_double2 x, x2, m, s; + double t; + int e; + + e = ilogbk(d.x * (1.0/0.75)); + + m.x = ldexp2k(d.x, -e); + m.y = ldexp2k(d.y, -e); + + x = dddiv_d2_d2_d2(ddadd2_d2_d2_d(m, -1), ddadd2_d2_d2_d(m, 1)); + x2 = ddsqu_d2_d2(x); + + double x4 = x2.x * x2.x, x8 = x4 * x4; + t = POLY7(x2.x, x4, x8, + 0.13860436390467167910856, + 0.131699838841615374240845, + 0.153914168346271945653214, + 0.181816523941564611721589, + 0.22222224632662035403996, + 0.285714285511134091777308, + 0.400000000000914013309483); + t = mla(t, x2.x, 0.666666666666664853302393); + + s = ddmul_d2_d2_d(dd(0.693147180559945286226764, 2.319046813846299558417771e-17), e); + s = ddadd_d2_d2_d2(s, ddscale_d2_d2_d(x, 2)); + s = ddadd_d2_d2_d2(s, ddmul_d2_d2_d(ddmul_d2_d2_d2(x2, x), t)); + + return s; +} + +EXPORT CONST double xasinh(double x) { + double y = fabsk(x); + Sleef_double2 d; + + d = y > 1 ? ddrec_d2_d(x) : dd(y, 0); + d = ddsqrt_d2_d2(ddadd2_d2_d2_d(ddsqu_d2_d2(d), 1)); + d = y > 1 ? ddmul_d2_d2_d(d, y) : d; + + d = logk2(ddnormalize_d2_d2(ddadd_d2_d2_d(d, x))); + y = d.x + d.y; + + y = (fabsk(x) > SQRT_DBL_MAX || xisnan(y)) ? mulsign(SLEEF_INFINITY, x) : y; + y = xisnan(x) ? SLEEF_NAN : y; + y = xisnegzero(x) ? -0.0 : y; + + return y; +} + +EXPORT CONST double xacosh(double x) { + Sleef_double2 d = logk2(ddadd2_d2_d2_d(ddmul_d2_d2_d2(ddsqrt_d2_d2(ddadd2_d2_d_d(x, 1)), ddsqrt_d2_d2(ddadd2_d2_d_d(x, -1))), x)); + double y = d.x + d.y; + + y = (x > SQRT_DBL_MAX || xisnan(y)) ? SLEEF_INFINITY : y; + y = x == 1.0 ? 0.0 : y; + y = x < 1.0 ? SLEEF_NAN : y; + y = xisnan(x) ? SLEEF_NAN : y; + + return y; +} + +EXPORT CONST double xatanh(double x) { + double y = fabsk(x); + Sleef_double2 d = logk2(dddiv_d2_d2_d2(ddadd2_d2_d_d(1, y), ddadd2_d2_d_d(1, -y))); + y = y > 1.0 ? SLEEF_NAN : (y == 1.0 ? SLEEF_INFINITY : (d.x + d.y) * 0.5); + + y = mulsign(y, x); + y = (xisinf(x) || xisnan(y)) ? SLEEF_NAN : y; + + return y; +} + +// + +EXPORT CONST double xcbrt(double d) { // max error : 2 ulps + double x, y, q = 1.0; + int e, r; + + e = ilogbk(fabsk(d))+1; + d = ldexp2k(d, -e); + r = (e + 6144) % 3; + q = (r == 1) ? 1.2599210498948731647672106 : q; + q = (r == 2) ? 1.5874010519681994747517056 : q; + q = ldexp2k(q, (e + 6144) / 3 - 2048); + + q = mulsign(q, d); + d = fabsk(d); + + x = -0.640245898480692909870982; + x = mla(x, d, 2.96155103020039511818595); + x = mla(x, d, -5.73353060922947843636166); + x = mla(x, d, 6.03990368989458747961407); + x = mla(x, d, -3.85841935510444988821632); + x = mla(x, d, 2.2307275302496609725722); + + y = x * x; y = y * y; x -= (d * y - x) * (1.0 / 3.0); + y = d * x * x; + y = (y - (2.0 / 3.0) * y * (y * x - 1)) * q; + + return y; +} + +EXPORT CONST double xcbrt_u1(double d) { + double x, y, z; + Sleef_double2 q2 = dd(1, 0), u, v; + int e, r; + + e = ilogbk(fabsk(d))+1; + d = ldexp2k(d, -e); + r = (e + 6144) % 3; + q2 = (r == 1) ? dd(1.2599210498948731907, -2.5899333753005069177e-17) : q2; + q2 = (r == 2) ? dd(1.5874010519681995834, -1.0869008194197822986e-16) : q2; + + q2.x = mulsign(q2.x, d); q2.y = mulsign(q2.y, d); + d = fabsk(d); + + x = -0.640245898480692909870982; + x = mla(x, d, 2.96155103020039511818595); + x = mla(x, d, -5.73353060922947843636166); + x = mla(x, d, 6.03990368989458747961407); + x = mla(x, d, -3.85841935510444988821632); + x = mla(x, d, 2.2307275302496609725722); + + y = x * x; y = y * y; x -= (d * y - x) * (1.0 / 3.0); + + z = x; + + u = ddmul_d2_d_d(x, x); + u = ddmul_d2_d2_d2(u, u); + u = ddmul_d2_d2_d(u, d); + u = ddadd2_d2_d2_d(u, -x); + y = u.x + u.y; + + y = -2.0 / 3.0 * y * z; + v = ddadd2_d2_d2_d(ddmul_d2_d_d(z, z), y); + v = ddmul_d2_d2_d(v, d); + v = ddmul_d2_d2_d2(v, q2); + z = ldexp2k(v.x + v.y, (e + 6144) / 3 - 2048); + + if (xisinf(d)) { z = mulsign(SLEEF_INFINITY, q2.x); } + if (d == 0) { z = mulsign(0, q2.x); } + + return z; +} + +EXPORT CONST double xexp2(double d) { + int q = (int)rintk(d); + double s, u; + + s = d - q; + + double s2 = s * s, s4 = s2 * s2, s8 = s4 * s4; + u = POLY10(s, s2, s4, s8, + +0.4434359082926529454e-9, + +0.7073164598085707425e-8, + +0.1017819260921760451e-6, + +0.1321543872511327615e-5, + +0.1525273353517584730e-4, + +0.1540353045101147808e-3, + +0.1333355814670499073e-2, + +0.9618129107597600536e-2, + +0.5550410866482046596e-1, + +0.2402265069591012214e+0); + u = mla(u, s, +0.6931471805599452862e+0); + + u = ddnormalize_d2_d2(ddadd_d2_d_d2(1, ddmul_d2_d_d(u, s))).x; + + u = ldexp2k(u, q); + + if (d >= 1024) u = SLEEF_INFINITY; + if (d < -2000) u = 0; + + return u; +} + +EXPORT CONST double xexp2_u35(double d) { + int q = (int)rintk(d); + double s, u; + + s = d - q; + + u = +0.4434359082926529454e-9; + u = mla(u, s, +0.7073164598085707425e-8); + u = mla(u, s, +0.1017819260921760451e-6); + u = mla(u, s, +0.1321543872511327615e-5); + u = mla(u, s, +0.1525273353517584730e-4); + u = mla(u, s, +0.1540353045101147808e-3); + u = mla(u, s, +0.1333355814670499073e-2); + u = mla(u, s, +0.9618129107597600536e-2); + u = mla(u, s, +0.5550410866482046596e-1); + u = mla(u, s, +0.2402265069591012214e+0); + u = mla(u, s, +0.6931471805599452862e+0); + u = mla(u, s, +0.1000000000000000000e+1); + + u = ldexp2k(u, q); + + if (d >= 1024) u = SLEEF_INFINITY; + if (d < -2000) u = 0; + + return u; +} + +EXPORT CONST double xexp10(double d) { + int q = (int)rintk(d * LOG10_2); + double s, u; + + s = mla(q, -L10U, d); + s = mla(q, -L10L, s); + + u = +0.2411463498334267652e-3; + u = mla(u, s, +0.1157488415217187375e-2); + u = mla(u, s, +0.5013975546789733659e-2); + u = mla(u, s, +0.1959762320720533080e-1); + u = mla(u, s, +0.6808936399446784138e-1); + u = mla(u, s, +0.2069958494722676234e+0); + u = mla(u, s, +0.5393829292058536229e+0); + u = mla(u, s, +0.1171255148908541655e+1); + u = mla(u, s, +0.2034678592293432953e+1); + u = mla(u, s, +0.2650949055239205876e+1); + u = mla(u, s, +0.2302585092994045901e+1); + + u = ddnormalize_d2_d2(ddadd_d2_d_d2(1, ddmul_d2_d_d(u, s))).x; + + u = ldexp2k(u, q); + + if (d > 308.25471555991671) u = SLEEF_INFINITY; // log10(DBL_MAX) + if (d < -350) u = 0; + + return u; +} + +EXPORT CONST double xexp10_u35(double d) { + int q = (int)rintk(d * LOG10_2); + double s, u; + + s = mla(q, -L10U, d); + s = mla(q, -L10L, s); + + u = +0.2411463498334267652e-3; + u = mla(u, s, +0.1157488415217187375e-2); + u = mla(u, s, +0.5013975546789733659e-2); + u = mla(u, s, +0.1959762320720533080e-1); + u = mla(u, s, +0.6808936399446784138e-1); + u = mla(u, s, +0.2069958494722676234e+0); + u = mla(u, s, +0.5393829292058536229e+0); + u = mla(u, s, +0.1171255148908541655e+1); + u = mla(u, s, +0.2034678592293432953e+1); + u = mla(u, s, +0.2650949055239205876e+1); + u = mla(u, s, +0.2302585092994045901e+1); + u = mla(u, s, +0.1000000000000000000e+1); + + u = ldexp2k(u, q); + + if (d > 308.25471555991671) u = SLEEF_INFINITY; + if (d < -350) u = 0; + + return u; +} + +EXPORT CONST double xexpm1(double a) { + Sleef_double2 d = ddadd2_d2_d2_d(expk2(dd(a, 0)), -1.0); + double x = d.x + d.y; + if (a > 709.782712893383996732223) x = SLEEF_INFINITY; // log(DBL_MAX) + if (a < -36.736800569677101399113302437) x = -1; // log(1 - nexttoward(1, 0)) + if (xisnegzero(a)) x = -0.0; + return x; +} + +EXPORT CONST double xlog10(double d) { + Sleef_double2 x, s; + double m, t, x2; + int e; + + int o = d < DBL_MIN; + if (o) d *= (double)(INT64_C(1) << 32) * (double)(INT64_C(1) << 32); + + e = ilogb2k(d * (1.0/0.75)); + m = ldexp3k(d, -e); + + if (o) e -= 64; + + x = dddiv_d2_d2_d2(ddadd2_d2_d_d(-1, m), ddadd2_d2_d_d(1, m)); + x2 = x.x * x.x; + + double x4 = x2 * x2, x8 = x4 * x4; + t = POLY7(x2, x4, x8, + +0.6653725819576758460e-1, + +0.6625722782820833712e-1, + +0.7898105214313944078e-1, + +0.9650955035715275132e-1, + +0.1240841409721444993e+0, + +0.1737177927454605086e+0, + +0.2895296546021972617e+0); + + s = ddmul_d2_d2_d(dd(0.30102999566398119802, -2.803728127785170339e-18), (double)e); + s = ddadd_d2_d2_d2(s, ddmul_d2_d2_d2(x, dd(0.86858896380650363334, 1.1430059694096389311e-17))); + s = ddadd_d2_d2_d(s, x2 * x.x * t); + + double r = s.x + s.y; + + if (xisinf(d)) r = SLEEF_INFINITY; + if (d < 0 || xisnan(d)) r = SLEEF_NAN; + if (d == 0) r = -SLEEF_INFINITY; + + return r; +} + +EXPORT CONST double xlog2(double d) { + Sleef_double2 x, s; + double m, t, x2; + int e; + + int o = d < DBL_MIN; + if (o) d *= (double)(INT64_C(1) << 32) * (double)(INT64_C(1) << 32); + + e = ilogb2k(d * (1.0/0.75)); + m = ldexp3k(d, -e); + + if (o) e -= 64; + + x = dddiv_d2_d2_d2(ddadd2_d2_d_d(-1, m), ddadd2_d2_d_d(1, m)); + x2 = x.x * x.x; + + double x4 = x2 * x2, x8 = x4 * x4; + t = POLY7(x2, x4, x8, + +0.2211941750456081490e+0, + +0.2200768693152277689e+0, + +0.2623708057488514656e+0, + +0.3205977477944495502e+0, + +0.4121985945485324709e+0, + +0.5770780162997058982e+0, + +0.96179669392608091449); + + s = ddadd2_d2_d_d2(e, ddmul_d2_d2_d2(x, dd(2.885390081777926774, 6.0561604995516736434e-18))); + s = ddadd2_d2_d2_d(s, x2 * x.x * t); + + double r = s.x + s.y; + + if (xisinf(d)) r = SLEEF_INFINITY; + if (d < 0 || xisnan(d)) r = SLEEF_NAN; + if (d == 0) r = -SLEEF_INFINITY; + + return r; +} + +EXPORT CONST double xlog2_u35(double d) { + double m, t, x, x2; + int e; + + int o = d < DBL_MIN; + if (o) d *= (double)(INT64_C(1) << 32) * (double)(INT64_C(1) << 32); + + e = ilogb2k(d * (1.0/0.75)); + m = ldexp3k(d, -e); + + if (o) e -= 64; + + x = (m - 1) / (m + 1); + x2 = x * x; + + t = +0.2211941750456081490e+0; + t = mla(t, x2, +0.2200768693152277689e+0); + t = mla(t, x2, +0.2623708057488514656e+0); + t = mla(t, x2, +0.3205977477944495502e+0); + t = mla(t, x2, +0.4121985945485324709e+0); + t = mla(t, x2, +0.5770780162997058982e+0); + t = mla(t, x2, +0.96179669392608091449 ); + + Sleef_double2 s = ddadd_d2_d_d2(e, ddmul_d2_d_d(2.885390081777926774, x)); + double r = mla(t, x * x2, s.x + s.y); + + if (xisinf(d)) r = SLEEF_INFINITY; + if (d < 0 || xisnan(d)) r = SLEEF_NAN; + if (d == 0) r = -SLEEF_INFINITY; + + return r; +} + +EXPORT CONST double xlog1p(double d) { + Sleef_double2 x, s; + double m, t, x2; + int e; + + double dp1 = d + 1; + + int o = dp1 < DBL_MIN; + if (o) dp1 *= (double)(INT64_C(1) << 32) * (double)(INT64_C(1) << 32); + + e = ilogb2k(dp1 * (1.0/0.75)); + + t = ldexp3k(1, -e); + m = mla(d, t, t - 1); + + if (o) e -= 64; + + x = dddiv_d2_d2_d2(dd(m, 0), ddadd_d2_d_d(2, m)); + x2 = x.x * x.x; + + double x4 = x2 * x2, x8 = x4 * x4; + t = POLY7(x2, x4, x8, + 0.1532076988502701353e+0, + 0.1525629051003428716e+0, + 0.1818605932937785996e+0, + 0.2222214519839380009e+0, + 0.2857142932794299317e+0, + 0.3999999999635251990e+0, + 0.6666666666667333541e+0); + + s = ddmul_d2_d2_d(dd(0.693147180559945286226764, 2.319046813846299558417771e-17), (double)e); + s = ddadd_d2_d2_d2(s, ddscale_d2_d2_d(x, 2)); + s = ddadd_d2_d2_d(s, x2 * x.x * t); + + double r = s.x + s.y; + + if (d > 1e+307) r = SLEEF_INFINITY; + if (d < -1 || xisnan(d)) r = SLEEF_NAN; + if (d == -1) r = -SLEEF_INFINITY; + if (xisnegzero(d)) r = -0.0; + + return r; +} + +// + +EXPORT CONST double xfma(double x, double y, double z) { + double h2 = x * y + z, q = 1; + if (fabsk(h2) < 1e-300) { + const double c0 = UINT64_C(1) << 54, c1 = c0 * c0, c2 = c1 * c1; + x *= c1; + y *= c1; + z *= c2; + q = 1.0 / c2; + } + if (fabsk(h2) > 1e+299) { + const double c0 = UINT64_C(1) << 54, c1 = c0 * c0, c2 = c1 * c1; + x *= 1.0 / c1; + y *= 1.0 / c1; + z *= 1. / c2; + q = c2; + } + Sleef_double2 d = ddmul_d2_d_d(x, y); + d = ddadd2_d2_d2_d(d, z); + double ret = (x == 0 || y == 0) ? z : (d.x + d.y); + if ((xisinf(z) && !xisinf(x) && !xisnan(x) && !xisinf(y) && !xisnan(y))) h2 = z; + return (xisinf(h2) || xisnan(h2)) ? h2 : ret*q; +} + +EXPORT CONST double xsqrt_u05(double d) { + double q = 0.5; + + d = d < 0 ? SLEEF_NAN : d; + + if (d < 8.636168555094445E-78) { + d *= 1.157920892373162E77; + q = 2.9387358770557188E-39 * 0.5; + } + + if (d > 1.3407807929942597e+154) { + d *= 7.4583407312002070e-155; + q = 1.1579208923731620e+77 * 0.5; + } + + // http://en.wikipedia.org/wiki/Fast_inverse_square_root + double x = longBitsToDouble(0x5fe6ec85e7de30da - (doubleToRawLongBits(d + 1e-320) >> 1)); + + x = x * (1.5 - 0.5 * d * x * x); + x = x * (1.5 - 0.5 * d * x * x); + x = x * (1.5 - 0.5 * d * x * x) * d; + + Sleef_double2 d2 = ddmul_d2_d2_d2(ddadd2_d2_d_d2(d, ddmul_d2_d_d(x, x)), ddrec_d2_d(x)); + + double ret = (d2.x + d2.y) * q; + + ret = d == SLEEF_INFINITY ? SLEEF_INFINITY : ret; + ret = d == 0 ? d : ret; + + return ret; +} + +EXPORT CONST double xsqrt_u35(double d) { return xsqrt_u05(d); } +EXPORT CONST double xsqrt(double d) { return SQRT(d); } + +EXPORT CONST double xfabs(double x) { return fabsk(x); } + +EXPORT CONST double xcopysign(double x, double y) { return copysignk(x, y); } + +EXPORT CONST double xfmax(double x, double y) { + return y != y ? x : (x > y ? x : y); +} + +EXPORT CONST double xfmin(double x, double y) { + return y != y ? x : (x < y ? x : y); +} + +EXPORT CONST double xfdim(double x, double y) { + double ret = x - y; + if (ret < 0 || x == y) ret = 0; + return ret; +} + +EXPORT CONST double xtrunc(double x) { + double fr = x - (double)(INT64_C(1) << 31) * (int32_t)(x * (1.0 / (INT64_C(1) << 31))); + fr = fr - (int32_t)fr; + return (xisinf(x) || fabsk(x) >= (double)(INT64_C(1) << 52)) ? x : copysignk(x - fr, x); +} + +EXPORT CONST double xfloor(double x) { + double fr = x - (double)(INT64_C(1) << 31) * (int32_t)(x * (1.0 / (INT64_C(1) << 31))); + fr = fr - (int32_t)fr; + fr = fr < 0 ? fr+1.0 : fr; + return (xisinf(x) || fabsk(x) >= (double)(INT64_C(1) << 52)) ? x : copysignk(x - fr, x); +} + +EXPORT CONST double xceil(double x) { + double fr = x - (double)(INT64_C(1) << 31) * (int32_t)(x * (1.0 / (INT64_C(1) << 31))); + fr = fr - (int32_t)fr; + fr = fr <= 0 ? fr : fr-1.0; + return (xisinf(x) || fabsk(x) >= (double)(INT64_C(1) << 52)) ? x : copysignk(x - fr, x); +} + +EXPORT CONST double xround(double d) { + double x = d + 0.5; + double fr = x - (double)(INT64_C(1) << 31) * (int32_t)(x * (1.0 / (INT64_C(1) << 31))); + fr = fr - (int32_t)fr; + if (fr == 0 && x <= 0) x--; + fr = fr < 0 ? fr+1.0 : fr; + x = d == 0.49999999999999994449 ? 0 : x; // nextafter(0.5, 0) + return (xisinf(d) || fabsk(d) >= (double)(INT64_C(1) << 52)) ? d : copysignk(x - fr, d); +} + +EXPORT CONST double xrint(double d) { + double c = mulsign(INT64_C(1) << 52, d); + return fabsk(d) > INT64_C(1) << 52 ? d : orsign(d + c - c, d); +} + +EXPORT CONST double xhypot_u05(double x, double y) { + x = fabsk(x); + y = fabsk(y); + double min = fmink(x, y), n = min; + double max = fmaxk(x, y), d = max; + + if (max < DBL_MIN) { n *= UINT64_C(1) << 54; d *= UINT64_C(1) << 54; } + Sleef_double2 t = dddiv_d2_d2_d2(dd(n, 0), dd(d, 0)); + t = ddmul_d2_d2_d(ddsqrt_d2_d2(ddadd2_d2_d2_d(ddsqu_d2_d2(t), 1)), max); + double ret = t.x + t.y; + if (xisnan(ret)) ret = SLEEF_INFINITY; + if (min == 0) ret = max; + if (xisnan(x) || xisnan(y)) ret = SLEEF_NAN; + if (x == SLEEF_INFINITY || y == SLEEF_INFINITY) ret = SLEEF_INFINITY; + return ret; +} + +EXPORT CONST double xhypot_u35(double x, double y) { + x = fabsk(x); + y = fabsk(y); + double min = fmink(x, y); + double max = fmaxk(x, y); + + double t = min / max; + double ret = max * SQRT(1 + t*t); + if (min == 0) ret = max; + if (xisnan(x) || xisnan(y)) ret = SLEEF_NAN; + if (x == SLEEF_INFINITY || y == SLEEF_INFINITY) ret = SLEEF_INFINITY; + return ret; +} + +EXPORT CONST double xnextafter(double x, double y) { + double cxf; + int64_t cxi; + + x = x == 0 ? mulsign(0, y) : x; + cxf = x; + memcpy(&cxi, &cxf, sizeof(cxi)); + + int c = (cxi < 0) == (y < x); + if (c) cxi = -(cxi ^ (int64_t)(UINT64_C(1) << 63)); + + if (x != y) cxi--; + + if (c) cxi = -(cxi ^ (int64_t)(UINT64_C(1) << 63)); + + memcpy(&cxf, &cxi, sizeof(cxf)); + if (cxf == 0 && x != 0) cxf = mulsign(0, x); + if (x == 0 && y == 0) cxf = y; + if (xisnan(x) || xisnan(y)) cxf = SLEEF_NAN; + + return cxf; +} + +EXPORT CONST double xfrfrexp(double x) { + double cxf; + uint64_t cxu; + + if (fabsk(x) < DBL_MIN) x *= (UINT64_C(1) << 63); + + cxf = x; + memcpy(&cxu, &cxf, sizeof(cxu)); + + cxu &= ~UINT64_C(0x7ff0000000000000); + cxu |= UINT64_C(0x3fe0000000000000); + + memcpy(&cxf, &cxu, sizeof(cxf)); + if (xisinf(x)) cxf = mulsign(SLEEF_INFINITY, x); + if (x == 0) cxf = x; + + return cxf; +} + +EXPORT CONST int xexpfrexp(double x) { + double cxf; + uint64_t cxu; + + int ret = 0; + + if (fabsk(x) < DBL_MIN) { x *= (UINT64_C(1) << 63); ret = -63; } + + cxf = x; + memcpy(&cxu, &cxf, sizeof(cxu)); + + ret += (int32_t)(((cxu >> 52) & 0x7ff)) - 0x3fe; + + if (x == 0 || xisnan(x) || xisinf(x)) ret = 0; + + return ret; +} + +static INLINE CONST double toward0(double d) { + return d == 0 ? 0 : longBitsToDouble(doubleToRawLongBits(d)-1); +} + +static INLINE CONST double removelsb(double d) { + return longBitsToDouble(doubleToRawLongBits(d) & INT64_C(0xfffffffffffffffe)); +} + +static INLINE CONST double ptrunc(double x) { + double fr = mla(-(double)(INT64_C(1) << 31), (int32_t)(x * (1.0 / (INT64_C(1) << 31))), x); + return fabsk(x) >= (double)(INT64_C(1) << 52) ? x : (x - (fr - (int32_t)fr)); +} + +EXPORT CONST double xfmod(double x, double y) { + double n = fabsk(x), d = fabsk(y), s = 1, q; + if (d < DBL_MIN) { n *= UINT64_C(1) << 54; d *= UINT64_C(1) << 54; s = 1.0 / (UINT64_C(1) << 54); } + Sleef_double2 r = dd(n, 0); + double rd = toward0(1.0 / d); + + for(int i=0;i < 21;i++) { // ceil(log2(DBL_MAX) / 52) + q = removelsb(ptrunc(toward0(r.x) * rd)); + q = (3*d > r.x && r.x > d) ? 2 : q; + q = (2*d > r.x && r.x > d) ? 1 : q; + q = r.x == d ? (r.y >= 0 ? 1 : 0) : q; + r = ddnormalize_d2_d2(ddadd2_d2_d2_d2(r, ddmul_d2_d_d(q, -d))); + if (r.x < d) break; + } + + double ret = r.x * s; + if (r.x + r.y == d) ret = 0; + ret = mulsign(ret, x); + if (n < d) ret = x; + if (d == 0) ret = SLEEF_NAN; + + return ret; +} + +static INLINE CONST double rintk2(double d) { + double c = mulsign(INT64_C(1) << 52, d); + return fabsk(d) > INT64_C(1) << 52 ? d : orsign(d + c - c, d); +} + +EXPORT CONST double xremainder(double x, double y) { + double n = fabsk(x), d = fabsk(y), s = 1, q; + if (d < DBL_MIN*2) { n *= UINT64_C(1) << 54; d *= UINT64_C(1) << 54; s = 1.0 / (UINT64_C(1) << 54); } + double rd = 1.0 / d; + Sleef_double2 r = dd(n, 0); + int qisodd = 0; + + for(int i=0;i < 21;i++) { // ceil(log2(DBL_MAX) / 52) + q = removelsb(rintk2(r.x * rd)); + if (fabsk(r.x) < 1.5 * d) q = r.x < 0 ? -1 : 1; + if (fabsk(r.x) < 0.5 * d || (fabsk(r.x) == 0.5 * d && !qisodd)) q = 0; + if (q == 0) break; + if (xisinf(q * -d)) q = q + mulsign(-1, r.x); + qisodd ^= xisodd(q); + r = ddnormalize_d2_d2(ddadd2_d2_d2_d2(r, ddmul_d2_d_d(q, -d))); + } + + double ret = r.x * s; + ret = mulsign(ret, x); + if (xisinf(y)) ret = xisinf(x) ? SLEEF_NAN : x; + if (d == 0) ret = SLEEF_NAN; + + return ret; +} + +EXPORT CONST Sleef_double2 xmodf(double x) { + double fr = x - (double)(INT64_C(1) << 31) * (int32_t)(x * (1.0 / (INT64_C(1) << 31))); + fr = fr - (int32_t)fr; + fr = fabsk(x) >= (double)(INT64_C(1) << 52) ? 0 : fr; + Sleef_double2 ret = { copysignk(fr, x), copysignk(x - fr, x) }; + return ret; +} + +typedef struct { + Sleef_double2 a, b; +} dd2; + +static CONST dd2 gammak(double a) { + Sleef_double2 clc = dd(0, 0), clln = dd(1, 0), clld = dd(1, 0), x, y, z; + double t, u; + + int otiny = fabsk(a) < 1e-306, oref = a < 0.5; + + x = otiny ? dd(0, 0) : (oref ? ddadd2_d2_d_d(1, -a) : dd(a, 0)); + + int o0 = (0.5 <= x.x && x.x <= 1.1), o2 = 2.3 < x.x; + + y = ddnormalize_d2_d2(ddmul_d2_d2_d2(ddadd2_d2_d2_d(x, 1), x)); + y = ddnormalize_d2_d2(ddmul_d2_d2_d2(ddadd2_d2_d2_d(x, 2), y)); + y = ddnormalize_d2_d2(ddmul_d2_d2_d2(ddadd2_d2_d2_d(x, 3), y)); + y = ddnormalize_d2_d2(ddmul_d2_d2_d2(ddadd2_d2_d2_d(x, 4), y)); + + clln = (o2 && x.x <= 7) ? y : clln; + + x = (o2 && x.x <= 7) ? ddadd2_d2_d2_d(x, 5) : x; + t = o2 ? (1.0 / x.x) : ddnormalize_d2_d2(ddadd2_d2_d2_d(x, o0 ? -1 : -2)).x; + + u = o2 ? -156.801412704022726379848862 : (o0 ? +0.2947916772827614196e+2 : +0.7074816000864609279e-7); + u = mla(u, t, o2 ? +1.120804464289911606838558160000 : (o0 ? +0.1281459691827820109e+3 : +0.4009244333008730443e-6)); + u = mla(u, t, o2 ? +13.39798545514258921833306020000 : (o0 ? +0.2617544025784515043e+3 : +0.1040114641628246946e-5)); + u = mla(u, t, o2 ? -0.116546276599463200848033357000 : (o0 ? +0.3287022855685790432e+3 : +0.1508349150733329167e-5)); + u = mla(u, t, o2 ? -1.391801093265337481495562410000 : (o0 ? +0.2818145867730348186e+3 : +0.1288143074933901020e-5)); + u = mla(u, t, o2 ? +0.015056113040026424412918973400 : (o0 ? +0.1728670414673559605e+3 : +0.4744167749884993937e-6)); + u = mla(u, t, o2 ? +0.179540117061234856098844714000 : (o0 ? +0.7748735764030416817e+2 : -0.6554816306542489902e-7)); + u = mla(u, t, o2 ? -0.002481743600264997730942489280 : (o0 ? +0.2512856643080930752e+2 : -0.3189252471452599844e-6)); + u = mla(u, t, o2 ? -0.029527880945699120504851034100 : (o0 ? +0.5766792106140076868e+1 : +0.1358883821470355377e-6)); + u = mla(u, t, o2 ? +0.000540164767892604515196325186 : (o0 ? +0.7270275473996180571e+0 : -0.4343931277157336040e-6)); + u = mla(u, t, o2 ? +0.006403362833808069794787256200 : (o0 ? +0.8396709124579147809e-1 : +0.9724785897406779555e-6)); + u = mla(u, t, o2 ? -0.000162516262783915816896611252 : (o0 ? -0.8211558669746804595e-1 : -0.2036886057225966011e-5)); + u = mla(u, t, o2 ? -0.001914438498565477526465972390 : (o0 ? +0.6828831828341884458e-1 : +0.4373363141819725815e-5)); + u = mla(u, t, o2 ? +7.20489541602001055898311517e-05 : (o0 ? -0.7712481339961671511e-1 : -0.9439951268304008677e-5)); + u = mla(u, t, o2 ? +0.000839498720672087279971000786 : (o0 ? +0.8337492023017314957e-1 : +0.2050727030376389804e-4)); + u = mla(u, t, o2 ? -5.17179090826059219329394422e-05 : (o0 ? -0.9094964931456242518e-1 : -0.4492620183431184018e-4)); + u = mla(u, t, o2 ? -0.000592166437353693882857342347 : (o0 ? +0.1000996313575929358e+0 : +0.9945751236071875931e-4)); + u = mla(u, t, o2 ? +6.97281375836585777403743539e-05 : (o0 ? -0.1113342861544207724e+0 : -0.2231547599034983196e-3)); + u = mla(u, t, o2 ? +0.000784039221720066627493314301 : (o0 ? +0.1255096673213020875e+0 : +0.5096695247101967622e-3)); + u = mla(u, t, o2 ? -0.000229472093621399176949318732 : (o0 ? -0.1440498967843054368e+0 : -0.1192753911667886971e-2)); + u = mla(u, t, o2 ? -0.002681327160493827160473958490 : (o0 ? +0.1695571770041949811e+0 : +0.2890510330742210310e-2)); + u = mla(u, t, o2 ? +0.003472222222222222222175164840 : (o0 ? -0.2073855510284092762e+0 : -0.7385551028674461858e-2)); + u = mla(u, t, o2 ? +0.083333333333333333335592087900 : (o0 ? +0.2705808084277815939e+0 : +0.2058080842778455335e-1)); + + y = ddmul_d2_d2_d2(ddadd2_d2_d2_d(x, -0.5), logk2(x)); + y = ddadd2_d2_d2_d2(y, ddneg_d2_d2(x)); + y = ddadd2_d2_d2_d2(y, dd(0.91893853320467278056, -3.8782941580672414498e-17)); // 0.5*log(2*M_PI) + + z = ddadd2_d2_d2_d(ddmul_d2_d_d (u, t), o0 ? -0.4006856343865314862e+0 : -0.6735230105319810201e-1); + z = ddadd2_d2_d2_d(ddmul_d2_d2_d(z, t), o0 ? +0.8224670334241132030e+0 : +0.3224670334241132030e+0); + z = ddadd2_d2_d2_d(ddmul_d2_d2_d(z, t), o0 ? -0.5772156649015328655e+0 : +0.4227843350984671345e+0); + z = ddmul_d2_d2_d(z, t); + + clc = o2 ? y : z; + + clld = o2 ? ddadd2_d2_d2_d(ddmul_d2_d_d(u, t), 1) : clld; + + y = clln; + + clc = otiny ? dd(83.1776616671934334590333, 3.67103459631568507221878e-15) : // log(2^120) + (oref ? ddadd2_d2_d2_d2(dd(1.1447298858494001639, 1.026595116270782638e-17), ddneg_d2_d2(clc)) : clc); // log(M_PI) + clln = otiny ? dd(1, 0) : (oref ? clln : clld); + + if (oref) x = ddmul_d2_d2_d2(clld, sinpik(a - (double)(INT64_C(1) << 28) * (int32_t)(a * (1.0 / (INT64_C(1) << 28))))); + + clld = otiny ? dd(a*((INT64_C(1) << 60)*(double)(INT64_C(1) << 60)), 0) : (oref ? x : y); + + dd2 ret = { clc, dddiv_d2_d2_d2(clln, clld) }; + + return ret; +} + +EXPORT CONST double xtgamma_u1(double a) { + dd2 d = gammak(a); + Sleef_double2 y = ddmul_d2_d2_d2(expk2(d.a), d.b); + double r = y.x + y.y; + r = (a == -SLEEF_INFINITY || (a < 0 && xisint(a)) || (xisnumber(a) && a < 0 && xisnan(r))) ? SLEEF_NAN : r; + r = ((a == SLEEF_INFINITY || xisnumber(a)) && a >= -DBL_MIN && (a == 0 || a > 200 || xisnan(r))) ? mulsign(SLEEF_INFINITY, a) : r; + return r; +} + +EXPORT CONST double xlgamma_u1(double a) { + dd2 d = gammak(a); + Sleef_double2 y = ddadd2_d2_d2_d2(d.a, logk2(ddabs_d2_d2(d.b))); + double r = y.x + y.y; + r = (xisinf(a) || (a <= 0 && xisint(a)) || (xisnumber(a) && xisnan(r))) ? SLEEF_INFINITY : r; + return r; +} + +static INLINE CONST Sleef_double2 ddmla(double x, Sleef_double2 y, Sleef_double2 z) { + return ddadd2_d2_d2_d2(z, ddmul_d2_d2_d(y, x)); +} +static INLINE CONST Sleef_double2 poly2dd_b(double x, Sleef_double2 c1, Sleef_double2 c0) { return ddmla(x, c1, c0); } +static INLINE CONST Sleef_double2 poly2dd(double x, double c1, Sleef_double2 c0) { return ddmla(x, dd(c1, 0), c0); } +static INLINE CONST Sleef_double2 poly4dd(double x, double c3, Sleef_double2 c2, Sleef_double2 c1, Sleef_double2 c0) { + return ddmla(x*x, poly2dd(x, c3, c2), poly2dd_b(x, c1, c0)); +} + +EXPORT CONST double xerf_u1(double a) { + double t, x = fabsk(a); + Sleef_double2 t2; + double x2 = x * x, x4 = x2 * x2, x8 = x4 * x4, x16 = x8 * x8; + + if (x < 2.5) { + // Abramowitz and Stegun + t = POLY21(x, x2, x4, x8, x16, + -0.2083271002525222097e-14, + +0.7151909970790897009e-13, + -0.1162238220110999364e-11, + +0.1186474230821585259e-10, + -0.8499973178354613440e-10, + +0.4507647462598841629e-9, + -0.1808044474288848915e-8, + +0.5435081826716212389e-8, + -0.1143939895758628484e-7, + +0.1215442362680889243e-7, + +0.1669878756181250355e-7, + -0.9808074602255194288e-7, + +0.1389000557865837204e-6, + +0.2945514529987331866e-6, + -0.1842918273003998283e-5, + +0.3417987836115362136e-5, + +0.3860236356493129101e-5, + -0.3309403072749947546e-4, + +0.1060862922597579532e-3, + +0.2323253155213076174e-3, + +0.1490149719145544729e-3); + t2 = poly4dd(x, t, + dd(0.0092877958392275604405, 7.9287559463961107493e-19), + dd(0.042275531758784692937, 1.3785226620501016138e-19), + dd(0.07052369794346953491, 9.5846628070792092842e-19)); + t2 = ddadd_d2_d_d2(1, ddmul_d2_d2_d(t2, x)); + t2 = ddsqu_d2_d2(t2); + t2 = ddsqu_d2_d2(t2); + t2 = ddsqu_d2_d2(t2); + t2 = ddsqu_d2_d2(t2); + t2 = ddrec_d2_d2(t2); + } else if (x > 6.0) { + t2 = dd(0, 0); + } else { + t = POLY21(x, x2, x4, x8, x16, + -0.4024015130752621932e-18, + +0.3847193332817048172e-16, + -0.1749316241455644088e-14, + +0.5029618322872872715e-13, + -0.1025221466851463164e-11, + +0.1573695559331945583e-10, + -0.1884658558040203709e-9, + +0.1798167853032159309e-8, + -0.1380745342355033142e-7, + +0.8525705726469103499e-7, + -0.4160448058101303405e-6, + +0.1517272660008588485e-5, + -0.3341634127317201697e-5, + -0.2515023395879724513e-5, + +0.6539731269664907554e-4, + -0.3551065097428388658e-3, + +0.1210736097958368864e-2, + -0.2605566912579998680e-2, + +0.1252823202436093193e-2, + +0.1820191395263313222e-1, + -0.1021557155453465954e+0); + t2 = poly4dd(x, t, + dd(-0.63691044383641748361, -2.4249477526539431839e-17), + dd(-1.1282926061803961737, -6.2970338860410996505e-17), + dd(-1.2261313785184804967e-05, -5.5329707514490107044e-22)); + t2 = dd(expk(t2), 0); + } + + t2 = ddadd2_d2_d2_d(t2, -1); + + if (x < 1e-8) t2 = dd(-1.12837916709551262756245475959 * x, 0); + return mulsign(a == 0 ? 0 : (xisinf(a) ? 1 : (-t2.x - t2.y)), a); +} + +EXPORT CONST double xerfc_u15(double a) { + double s = a, r = 0, t; + Sleef_double2 u, d, x; + a = fabsk(a); + int o0 = a < 1.0, o1 = a < 2.2, o2 = a < 4.2, o3 = a < 27.3; + u = o0 ? ddmul_d2_d_d(a, a) : o1 ? dd(a, 0) : dddiv_d2_d2_d2(dd(1, 0), dd(a, 0)); + + t = o0 ? +0.6801072401395386139e-20 : o1 ? +0.3438010341362585303e-12 : o2 ? -0.5757819536420710449e+2 : +0.2334249729638701319e+5; + t = mla(t, u.x, o0 ? -0.2161766247570055669e-18 : o1 ? -0.1237021188160598264e-10 : o2 ? +0.4669289654498104483e+3 : -0.4695661044933107769e+5); + t = mla(t, u.x, o0 ? +0.4695919173301595670e-17 : o1 ? +0.2117985839877627852e-09 : o2 ? -0.1796329879461355858e+4 : +0.3173403108748643353e+5); + t = mla(t, u.x, o0 ? -0.9049140419888007122e-16 : o1 ? -0.2290560929177369506e-08 : o2 ? +0.4355892193699575728e+4 : +0.3242982786959573787e+4); + t = mla(t, u.x, o0 ? +0.1634018903557410728e-14 : o1 ? +0.1748931621698149538e-07 : o2 ? -0.7456258884965764992e+4 : -0.2014717999760347811e+5); + t = mla(t, u.x, o0 ? -0.2783485786333451745e-13 : o1 ? -0.9956602606623249195e-07 : o2 ? +0.9553977358167021521e+4 : +0.1554006970967118286e+5); + t = mla(t, u.x, o0 ? +0.4463221276786415752e-12 : o1 ? +0.4330010240640327080e-06 : o2 ? -0.9470019905444229153e+4 : -0.6150874190563554293e+4); + t = mla(t, u.x, o0 ? -0.6711366622850136563e-11 : o1 ? -0.1435050600991763331e-05 : o2 ? +0.7387344321849855078e+4 : +0.1240047765634815732e+4); + t = mla(t, u.x, o0 ? +0.9422759050232662223e-10 : o1 ? +0.3460139479650695662e-05 : o2 ? -0.4557713054166382790e+4 : -0.8210325475752699731e+2); + t = mla(t, u.x, o0 ? -0.1229055530100229098e-08 : o1 ? -0.4988908180632898173e-05 : o2 ? +0.2207866967354055305e+4 : +0.3242443880839930870e+2); + t = mla(t, u.x, o0 ? +0.1480719281585086512e-07 : o1 ? -0.1308775976326352012e-05 : o2 ? -0.8217975658621754746e+3 : -0.2923418863833160586e+2); + t = mla(t, u.x, o0 ? -0.1636584469123399803e-06 : o1 ? +0.2825086540850310103e-04 : o2 ? +0.2268659483507917400e+3 : +0.3457461732814383071e+0); + t = mla(t, u.x, o0 ? +0.1646211436588923575e-05 : o1 ? -0.6393913713069986071e-04 : o2 ? -0.4633361260318560682e+2 : +0.5489730155952392998e+1); + t = mla(t, u.x, o0 ? -0.1492565035840623511e-04 : o1 ? -0.2566436514695078926e-04 : o2 ? +0.9557380123733945965e+1 : +0.1559934132251294134e-2); + t = mla(t, u.x, o0 ? +0.1205533298178967851e-03 : o1 ? +0.5895792375659440364e-03 : o2 ? -0.2958429331939661289e+1 : -0.1541741566831520638e+1); + t = mla(t, u.x, o0 ? -0.8548327023450850081e-03 : o1 ? -0.1695715579163588598e-02 : o2 ? +0.1670329508092765480e+0 : +0.2823152230558364186e-5); + t = mla(t, u.x, o0 ? +0.5223977625442187932e-02 : o1 ? +0.2089116434918055149e-03 : o2 ? +0.6096615680115419211e+0 : +0.6249999184195342838e+0); + t = mla(t, u.x, o0 ? -0.2686617064513125222e-01 : o1 ? +0.1912855949584917753e-01 : o2 ? +0.1059212443193543585e-2 : +0.1741749416408701288e-8); + + d = ddmul_d2_d2_d(u, t); + d = ddadd2_d2_d2_d2(d, o0 ? dd(0.11283791670955126141, -4.0175691625932118483e-18) : + o1 ? dd(-0.10277263343147646779, -6.2338714083404900225e-18) : + o2 ? dd(-0.50005180473999022439, 2.6362140569041995803e-17) : + dd(-0.5000000000258444377, -4.0074044712386992281e-17)); + d = ddmul_d2_d2_d2(d, u); + d = ddadd2_d2_d2_d2(d, o0 ? dd(-0.37612638903183753802, 1.3391897206042552387e-17) : + o1 ? dd(-0.63661976742916359662, 7.6321019159085724662e-18) : + o2 ? dd(1.601106273924963368e-06, 1.1974001857764476775e-23) : + dd(2.3761973137523364792e-13, -1.1670076950531026582e-29)); + d = ddmul_d2_d2_d2(d, u); + d = ddadd2_d2_d2_d2(d, o0 ? dd(1.1283791670955125586, 1.5335459613165822674e-17) : + o1 ? dd(-1.1283791674717296161, 8.0896847755965377194e-17) : + o2 ? dd(-0.57236496645145429341, 3.0704553245872027258e-17) : + dd(-0.57236494292470108114, -2.3984352208056898003e-17)); + + x = ddmul_d2_d2_d(o1 ? d : dd(-a, 0), a); + x = o1 ? x : ddadd2_d2_d2_d2(x, d); + x = o0 ? ddsub_d2_d2_d2(dd(1, 0), x) : expk2(x); + x = o1 ? x : ddmul_d2_d2_d2(x, u); + + r = o3 ? (x.x + x.y) : 0; + if (s < 0) r = 2 - r; + r = xisnan(s) ? SLEEF_NAN : r; + return r; +} + +#ifdef ENABLE_MAIN +// gcc -w -DENABLE_MAIN -I../common sleefdp.c rempitab.c -lm +#include +int main(int argc, char **argv) { + double d1 = atof(argv[1]); + printf("arg1 = %.20g\n", d1); + //int i1 = atoi(argv[1]); + //double d2 = atof(argv[2]); + //printf("arg2 = %.20g\n", d2); + //printf("%d\n", (int)d2); +#if 0 + double d3 = atof(argv[3]); + printf("arg3 = %.20g\n", d3); +#endif + //printf("%g\n", pow2i(i1)); + //int exp = xexpfrexp(d1); + //double r = xnextafter(d1, d2); + //double r = xfma(d1, d2, d3); + printf("test = %.20g\n", xcos_u1(d1)); + //printf("test = %.20g\n", xlog(d1)); + //r = nextafter(d1, d2); + printf("corr = %.20g\n", cos(d1)); + //printf("%.20g %.20g\n", xround(d1), xrint(d1)); + //Sleef_double2 r = xsincospi_u35(d); + //printf("%g, %g\n", (double)r.x, (double)r.y); +} +#endif diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/sleefinline_cuda_header.h.org b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/sleefinline_cuda_header.h.org new file mode 100644 index 00000000000..c129f4ec297 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/sleefinline_cuda_header.h.org @@ -0,0 +1,1094 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See http://www.boost.org/LICENSE_1_0.txt) + +// This file is generated by SLEEF SLEEF_VERSION_SLEEF + +// Use --fmad=false option to compile this file +// Include cmath, cfloat and cstdint before including this file + +#ifndef SLEEF_FP_ILOGB0 +#define SLEEF_FP_ILOGB0 ((int)0x80000000) +#endif + +#ifndef SLEEF_FP_ILOGBNAN +#define SLEEF_FP_ILOGBNAN ((int)2147483647) +#endif + +__device__ const double Sleef_rempitabdp[] = { + 0.15915494309189531785, 1.7916237278037667488e-17, 2.5454160968749269937e-33, 2.1132476107887107169e-49, + 0.03415494309189533173, 4.0384494702232122736e-18, 1.0046721413651383112e-33, 2.1132476107887107169e-49, + 0.03415494309189533173, 4.0384494702232122736e-18, 1.0046721413651383112e-33, 2.1132476107887107169e-49, + 0.0029049430918953351999, 5.6900251826959904774e-19, 4.1707169171520598517e-35, -2.496415728504571394e-51, + 0.0029049430918953351999, 5.6900251826959904774e-19, 4.1707169171520598517e-35, -2.496415728504571394e-51, + 0.0029049430918953351999, 5.6900251826959904774e-19, 4.1707169171520598517e-35, -2.496415728504571394e-51, + 0.0029049430918953351999, 5.6900251826959904774e-19, 4.1707169171520598517e-35, -2.496415728504571394e-51, + 0.00095181809189533563356, 1.3532164927539732229e-19, -6.4410794381603004826e-36, 1.7634898158762436344e-52, + 0.00095181809189533563356, 1.3532164927539732229e-19, -6.4410794381603004826e-36, 1.7634898158762436344e-52, + 0.00046353684189533574198, 2.6901432026846872871e-20, -4.2254836195018827479e-37, 9.301187206862134399e-54, + 0.00021939621689533574198, 2.6901432026846872871e-20, -4.2254836195018827479e-37, 9.301187206862134399e-54, + 9.7325904395335769087e-05, -2.0362228529073840241e-22, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 3.6290748145335769087e-05, -2.0362228529073840241e-22, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 5.7731700203357690874e-06, -2.0362228529073840241e-22, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 5.7731700203357690874e-06, -2.0362228529073840241e-22, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 5.7731700203357690874e-06, -2.0362228529073840241e-22, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 1.9584727547107690874e-06, -2.0362228529073840241e-22, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 5.1124121898268875627e-08, 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 5.1124121898268875627e-08, 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 5.1124121898268875627e-08, 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 5.1124121898268875627e-08, 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 5.1124121898268875627e-08, 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 5.1124121898268875627e-08, 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 2.1321799510573569745e-08, 1.5185066224124613304e-24, 2.6226236120327253511e-40, 2.6283399642369025999e-57, + 6.4206383167259151492e-09, -1.3585460269359374382e-25, -1.3244127270701094468e-41, -2.4695541513869446866e-57, + 6.4206383167259151492e-09, -1.3585460269359374382e-25, -1.3244127270701094468e-41, -2.4695541513869446866e-57, + 2.6953480182640010867e-09, -1.3585460269359374382e-25, -1.3244127270701094468e-41, -2.4695541513869446866e-57, + 8.3270286903304384868e-10, 7.0940550444663151936e-26, 9.7147467687967058732e-42, 7.9392906424978921242e-59, + 8.3270286903304384868e-10, 7.0940550444663151936e-26, 9.7147467687967058732e-42, 7.9392906424978921242e-59, + 3.6704158172530459087e-10, 7.0940550444663151936e-26, 9.7147467687967058732e-42, 7.9392906424978921242e-59, + 1.3421093807143501366e-10, 1.9241762160098927996e-26, 3.9750282589222551507e-42, 7.9392906424978921242e-59, + 1.7795616244500218596e-11, -1.452834466126541428e-28, -1.5869767474823787636e-44, -2.6168913164368963837e-61, + 1.7795616244500218596e-11, -1.452834466126541428e-28, -1.5869767474823787636e-44, -2.6168913164368963837e-61, + 1.7795616244500218596e-11, -1.452834466126541428e-28, -1.5869767474823787636e-44, -2.6168913164368963837e-61, + 3.2437010161333667893e-12, -1.452834466126541428e-28, -1.5869767474823787636e-44, -2.6168913164368963837e-61, + 3.2437010161333667893e-12, -1.452834466126541428e-28, -1.5869767474823787636e-44, -2.6168913164368963837e-61, + 3.2437010161333667893e-12, -1.452834466126541428e-28, -1.5869767474823787636e-44, -2.6168913164368963837e-61, + 1.4247116125875099096e-12, 2.5861333686050385673e-28, 2.8971783383570358633e-44, -2.6168913164368963837e-61, + 5.1521691081458187359e-13, 5.6664945123924856962e-29, 6.5510079543732854985e-45, -2.6168913164368963837e-61, + 6.0469559928117805118e-14, 6.1778471897801070206e-30, 9.4581409707401690366e-46, 4.9461632249367446986e-62, + 6.0469559928117805118e-14, 6.1778471897801070206e-30, 9.4581409707401690366e-46, 4.9461632249367446986e-62, + 6.0469559928117805118e-14, 6.1778471897801070206e-30, 9.4581409707401690366e-46, 4.9461632249367446986e-62, + 3.6261410673097965595e-15, -1.3304005198798645927e-31, -1.7578597149294783985e-47, 8.4432539107728104262e-64, + 3.6261410673097965595e-15, -1.3304005198798645927e-31, -1.7578597149294783985e-47, 8.4432539107728104262e-64, + 3.6261410673097965595e-15, -1.3304005198798645927e-31, -1.7578597149294783985e-47, 8.4432539107728104262e-64, + 3.6261410673097965595e-15, -1.3304005198798645927e-31, -1.7578597149294783985e-47, 8.4432539107728104262e-64, + 7.3427388509295482183e-17, 1.4871367740953237822e-32, -1.1571307704883330232e-48, -6.7249112515659578102e-65, + 7.3427388509295482183e-17, 1.4871367740953237822e-32, -1.1571307704883330232e-48, -6.7249112515659578102e-65, + 7.3427388509295482183e-17, 1.4871367740953237822e-32, -1.1571307704883330232e-48, -6.7249112515659578102e-65, + 7.3427388509295482183e-17, 1.4871367740953237822e-32, -1.1571307704883330232e-48, -6.7249112515659578102e-65, + 7.3427388509295482183e-17, 1.4871367740953237822e-32, -1.1571307704883330232e-48, -6.7249112515659578102e-65, + 7.3427388509295482183e-17, 1.4871367740953237822e-32, -1.1571307704883330232e-48, -6.7249112515659578102e-65, + 1.7916237278037667488e-17, 2.5454160968749269937e-33, 2.1132476107887107169e-49, 8.7154294504188129325e-66, + 1.7916237278037667488e-17, 2.5454160968749269937e-33, 2.1132476107887107169e-49, 8.7154294504188129325e-66, + 4.0384494702232122736e-18, 1.0046721413651383112e-33, 2.1132476107887107169e-49, 8.7154294504188129325e-66, + 4.0384494702232122736e-18, 1.0046721413651383112e-33, 2.1132476107887107169e-49, 8.7154294504188129325e-66, + 5.6900251826959904774e-19, 4.1707169171520598517e-35, -2.4964157285045710972e-51, -1.866653112309982615e-67, + 5.6900251826959904774e-19, 4.1707169171520598517e-35, -2.4964157285045710972e-51, -1.866653112309982615e-67, + 5.6900251826959904774e-19, 4.1707169171520598517e-35, -2.4964157285045710972e-51, -1.866653112309982615e-67, + 1.3532164927539732229e-19, -6.4410794381603004826e-36, 1.7634898158762432635e-52, 3.5887057810247033998e-68, + 1.3532164927539732229e-19, -6.4410794381603004826e-36, 1.7634898158762432635e-52, 3.5887057810247033998e-68, + 2.6901432026846872871e-20, -4.2254836195018827479e-37, 9.3011872068621332399e-54, 1.113250147552460308e-69, + 2.6901432026846872871e-20, -4.2254836195018827479e-37, 9.3011872068621332399e-54, 1.113250147552460308e-69, + 2.6901432026846872871e-20, -4.2254836195018827479e-37, 9.3011872068621332399e-54, 1.113250147552460308e-69, + 1.3348904870778067446e-20, -4.2254836195018827479e-37, 9.3011872068621332399e-54, 1.113250147552460308e-69, + 6.5726412927436632287e-21, 1.0820844071023395684e-36, 1.7634898158762432635e-52, 3.5887057810247033998e-68, + 3.1845095037264626247e-21, 3.2976802257607573031e-37, 9.3011872068621332399e-54, 1.113250147552460308e-69, + 1.4904436092178623228e-21, -4.6390169687056261795e-38, -1.1392999419355048437e-54, -4.587677453735884283e-71, + 6.4341066196356198368e-22, -4.6390169687056261795e-38, -1.1392999419355048437e-54, -4.587677453735884283e-71, + 2.1989418833641172011e-22, 4.7649378378726728402e-38, 9.3011872068621332399e-54, 1.113250147552460308e-69, + 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, + 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, + 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, + 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, + 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, + 1.5185066224124613304e-24, 2.6226236120327253511e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, + 1.5185066224124613304e-24, 2.6226236120327253511e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, + 1.5185066224124613304e-24, 2.6226236120327253511e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, + 6.9132600985943383921e-25, 7.8591368887290111994e-41, 2.6283399642369020339e-57, 5.3358074162805516304e-73, + 2.7773570358292009361e-25, -1.3244127270701094468e-41, -2.4695541513869446866e-57, -3.2399200798614356002e-74, + 7.0940550444663151936e-26, 9.7147467687967058732e-42, 7.9392906424978921242e-59, 2.9745456030524896742e-75, + 7.0940550444663151936e-26, 9.7147467687967058732e-42, 7.9392906424978921242e-59, 2.9745456030524896742e-75, + 1.9241762160098927996e-26, 3.9750282589222551507e-42, 7.9392906424978921242e-59, 2.9745456030524896742e-75, + 1.9241762160098927996e-26, 3.9750282589222551507e-42, 7.9392906424978921242e-59, 2.9745456030524896742e-75, + 6.317065088957874881e-27, -3.2976062348358281152e-43, -2.6168913164368963837e-61, 3.7036201000008290615e-78, + 6.317065088957874881e-27, -3.2976062348358281152e-43, -2.6168913164368963837e-61, 3.7036201000008290615e-78, + 3.0858908211726098086e-27, 3.8770419025072344914e-43, 7.9392906424978921242e-59, 2.9745456030524896742e-75, + 1.4703036872799779898e-27, 2.8971783383570358633e-44, -2.6168913164368963837e-61, 3.7036201000008290615e-78, + 6.625101203336619011e-28, 2.8971783383570358633e-44, -2.6168913164368963837e-61, 3.7036201000008290615e-78, + 2.5861333686050385673e-28, 2.8971783383570358633e-44, -2.6168913164368963837e-61, 3.7036201000008290615e-78, + 5.6664945123924856962e-29, 6.5510079543732854985e-45, -2.6168913164368963837e-61, 3.7036201000008290615e-78, + 5.6664945123924856962e-29, 6.5510079543732854985e-45, -2.6168913164368963837e-61, 3.7036201000008290615e-78, + 6.1778471897801070206e-30, 9.4581409707401690366e-46, 4.9461632249367446986e-62, 3.7036201000008290615e-78, + 6.1778471897801070206e-30, 9.4581409707401690366e-46, 4.9461632249367446986e-62, 3.7036201000008290615e-78, + 6.1778471897801070206e-30, 9.4581409707401690366e-46, 4.9461632249367446986e-62, 3.7036201000008290615e-78, + 6.1778471897801070206e-30, 9.4581409707401690366e-46, 4.9461632249367446986e-62, 3.7036201000008290615e-78, + 3.0224035688960604996e-30, 2.451648649116083682e-46, 4.9461632249367446986e-62, 3.7036201000008290615e-78, + 1.4446817584540368888e-30, 2.451648649116083682e-46, 4.9461632249367446986e-62, 3.7036201000008290615e-78, + 6.5582085323302525856e-31, 7.0002556871006273225e-47, 1.0567786762735315635e-62, -6.1446417754639313137e-79, + 2.6139040062251944343e-31, -1.7578597149294783985e-47, 8.4432539107728090768e-64, 1.9517662449371102229e-79, + 6.4175174317266470186e-32, 4.3166913557804827486e-48, 8.4432539107728090768e-64, 1.9517662449371102229e-79, + 6.4175174317266470186e-32, 4.3166913557804827486e-48, 8.4432539107728090768e-64, 1.9517662449371102229e-79, + 1.4871367740953237822e-32, -1.1571307704883330232e-48, -6.7249112515659569668e-65, -7.2335760163150273591e-81, + 1.4871367740953237822e-32, -1.1571307704883330232e-48, -6.7249112515659569668e-65, -7.2335760163150273591e-81, + 2.5454160968749269937e-33, 2.1132476107887107169e-49, 8.7154294504188118783e-66, 1.2001823382693912203e-81, + 2.5454160968749269937e-33, 2.1132476107887107169e-49, 8.7154294504188118783e-66, 1.2001823382693912203e-81, + 2.5454160968749269937e-33, 2.1132476107887107169e-49, 8.7154294504188118783e-66, 1.2001823382693912203e-81, + 1.0046721413651383112e-33, 2.1132476107887107169e-49, 8.7154294504188118783e-66, 1.2001823382693912203e-81, + 2.3430016361024414106e-34, 4.0267819632970559834e-50, -7.8013829534098555144e-67, -1.1759240463442418271e-82, + 2.3430016361024414106e-34, 4.0267819632970559834e-50, -7.8013829534098555144e-67, -1.1759240463442418271e-82, + 4.1707169171520598517e-35, -2.4964157285045710972e-51, -1.866653112309982615e-67, 1.4185069655957361252e-83, + 4.1707169171520598517e-35, -2.4964157285045710972e-51, -1.866653112309982615e-67, 1.4185069655957361252e-83, + 4.1707169171520598517e-35, -2.4964157285045710972e-51, -1.866653112309982615e-67, 1.4185069655957361252e-83, + 1.7633044866680145008e-35, 2.8491136916798196016e-51, 4.0680767287898916022e-67, 1.4185069655957361252e-83, + 5.595982714259923599e-36, 1.7634898158762432635e-52, 3.588705781024702988e-68, 5.9489775128085140685e-84, + 5.595982714259923599e-36, 1.7634898158762432635e-52, 3.588705781024702988e-68, 5.9489775128085140685e-84, + 2.5867171761548675786e-36, 1.7634898158762432635e-52, 3.588705781024702988e-68, 5.9489775128085140685e-84, + 1.0820844071023395684e-36, 1.7634898158762432635e-52, 3.588705781024702988e-68, 5.9489775128085140685e-84, + 3.2976802257607573031e-37, 9.3011872068621332399e-54, 1.113250147552460308e-69, 2.9286284920280944778e-86, + 3.2976802257607573031e-37, 9.3011872068621332399e-54, 1.113250147552460308e-69, 2.9286284920280944778e-86, + 1.4168892644450972904e-37, 9.3011872068621332399e-54, 1.113250147552460308e-69, 2.9286284920280944778e-86, + 4.7649378378726728402e-38, 9.3011872068621332399e-54, 1.113250147552460308e-69, 2.9286284920280944778e-86, + 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 2.6226236120327253511e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 7.8591368887290111994e-41, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 7.8591368887290111994e-41, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 3.2673620808294506214e-41, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 9.7147467687967058732e-42, 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257943935e-91, + 9.7147467687967058732e-42, 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257943935e-91, + 3.9750282589222551507e-42, 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257943935e-91, + 1.1051690039850297894e-42, 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257943935e-91, + 1.1051690039850297894e-42, 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257943935e-91, + 3.8770419025072344914e-43, 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257943935e-91, + 2.8971783383570358633e-44, -2.6168913164368963837e-61, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 2.8971783383570358633e-44, -2.6168913164368963837e-61, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 2.8971783383570358633e-44, -2.6168913164368963837e-61, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 2.8971783383570358633e-44, -2.6168913164368963837e-61, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 6.5510079543732854985e-45, -2.6168913164368963837e-61, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 6.5510079543732854985e-45, -2.6168913164368963837e-61, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 9.4581409707401690366e-46, 4.9461632249367446986e-62, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 9.4581409707401690366e-46, 4.9461632249367446986e-62, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 9.4581409707401690366e-46, 4.9461632249367446986e-62, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 2.451648649116083682e-46, 4.9461632249367446986e-62, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 2.451648649116083682e-46, 4.9461632249367446986e-62, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 7.0002556871006273225e-47, 1.0567786762735315635e-62, -6.1446417754639301152e-79, -1.5355611056488084652e-94, + 7.0002556871006273225e-47, 1.0567786762735315635e-62, -6.1446417754639301152e-79, -1.5355611056488084652e-94, + 2.6211979860855749482e-47, 8.4432539107728090768e-64, 1.9517662449371099233e-79, 2.62202614552995759e-95, + 4.3166913557804827486e-48, 8.4432539107728090768e-64, 1.9517662449371099233e-79, 2.62202614552995759e-95, + 4.3166913557804827486e-48, 8.4432539107728090768e-64, 1.9517662449371099233e-79, 2.62202614552995759e-95, + 4.3166913557804827486e-48, 8.4432539107728090768e-64, 1.9517662449371099233e-79, 2.62202614552995759e-95, + 1.5797802926460750146e-48, 2.3660905534865399025e-64, -7.2335760163150273591e-81, 2.8738690232659205689e-99, + 2.1132476107887107169e-49, 8.7154294504188118783e-66, 1.2001823382693912203e-81, 2.8738690232659205689e-99, + 2.1132476107887107169e-49, 8.7154294504188118783e-66, 1.2001823382693912203e-81, 2.8738690232659205689e-99, + 2.1132476107887107169e-49, 8.7154294504188118783e-66, 1.2001823382693912203e-81, 2.8738690232659205689e-99, + 4.0267819632970559834e-50, -7.8013829534098555144e-67, -1.1759240463442418271e-82, 2.8738690232659205689e-99, + 4.0267819632970559834e-50, -7.8013829534098555144e-67, -1.1759240463442418271e-82, 2.8738690232659205689e-99, + 4.0267819632970559834e-50, -7.8013829534098555144e-67, -1.1759240463442418271e-82, 2.8738690232659205689e-99, + 1.8885701952232994665e-50, -7.8013829534098555144e-67, -1.1759240463442418271e-82, 2.8738690232659205689e-99, + 8.1946431118642097069e-51, 1.5937536410989638719e-66, 1.459625439463388979e-82, 2.8738690232659205689e-99, + 2.8491136916798196016e-51, 4.0680767287898916022e-67, 1.4185069655957361252e-83, -7.8369062883735917115e-100, + 1.7634898158762432635e-52, 3.588705781024702988e-68, 5.9489775128085131541e-84, 1.0450891972142808004e-99, + 1.7634898158762432635e-52, 3.588705781024702988e-68, 5.9489775128085131541e-84, 1.0450891972142808004e-99, + 1.7634898158762432635e-52, 3.588705781024702988e-68, 5.9489775128085131541e-84, 1.0450891972142808004e-99, + 1.7634898158762432635e-52, 3.588705781024702988e-68, 5.9489775128085131541e-84, 1.0450891972142808004e-99, + 9.3011872068621332399e-54, 1.113250147552460308e-69, 2.9286284920280941206e-86, 2.1132026692048600853e-102, + 9.3011872068621332399e-54, 1.113250147552460308e-69, 2.9286284920280941206e-86, 2.1132026692048600853e-102, + 9.3011872068621332399e-54, 1.113250147552460308e-69, 2.9286284920280941206e-86, 2.1132026692048600853e-102, + 9.3011872068621332399e-54, 1.113250147552460308e-69, 2.9286284920280941206e-86, 2.1132026692048600853e-102, + 9.3011872068621332399e-54, 1.113250147552460308e-69, 2.9286284920280941206e-86, 2.1132026692048600853e-102, + 4.0809436324633147776e-54, -4.587677453735884283e-71, -2.8859500138942368532e-87, -5.6567402911297190423e-103, + 1.470821845263904967e-54, -4.587677453735884283e-71, -2.8859500138942368532e-87, -5.6567402911297190423e-103, + 1.6576095166419998917e-55, 2.6568658093254848067e-71, 5.1571087196495574384e-87, 3.2728487032630537605e-103, + 1.6576095166419998917e-55, 2.6568658093254848067e-71, 5.1571087196495574384e-87, 3.2728487032630537605e-103, + 1.6576095166419998917e-55, 2.6568658093254848067e-71, 5.1571087196495574384e-87, 3.2728487032630537605e-103, + 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.5242184730639744369e-90, 1.145584788913072936e-105, + 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.5242184730639744369e-90, 1.145584788913072936e-105, + 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.5242184730639744369e-90, 1.145584788913072936e-105, + 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.5242184730639744369e-90, 1.145584788913072936e-105, + 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.5242184730639744369e-90, 1.145584788913072936e-105, + 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.5242184730639744369e-90, 1.145584788913072936e-105, + 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.554706987098633963e-107, + 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.554706987098633963e-107, + 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.554706987098633963e-107, + 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.554706987098633963e-107, + 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.554706987098633963e-107, + 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.554706987098633963e-107, + 3.9565608646667614317e-59, 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.554706987098633963e-107, + 1.9651959757511960854e-59, 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.554706987098633963e-107, + 9.6951353129341363331e-60, 7.6368645294831185015e-76, 1.0603435429602168369e-91, 1.0451839188820145747e-108, + 4.7167230906452229674e-60, 7.6368645294831185015e-76, 1.0603435429602168369e-91, 1.0451839188820145747e-108, + 2.2275169795007668372e-60, 2.1097166542226745549e-76, 4.4670685979800101779e-92, 1.0451839188820145747e-108, + 9.8291392392853877215e-61, -6.5385728340754726503e-77, -1.3520652573660833788e-93, -2.3220403312043059402e-109, + 3.6061239614242446325e-61, 7.2792968540756372162e-77, 1.3988851821689310822e-92, 1.0451839188820145747e-108, + 4.9461632249367446986e-62, 3.7036201000008285821e-78, 5.6554937751584084315e-94, -1.9306041120023063932e-110, + 4.9461632249367446986e-62, 3.7036201000008285821e-78, 5.6554937751584084315e-94, -1.9306041120023063932e-110, + 4.9461632249367446986e-62, 3.7036201000008285821e-78, 5.6554937751584084315e-94, -1.9306041120023063932e-110, + 1.0567786762735315635e-62, -6.1446417754639301152e-79, -1.535561105648808199e-94, -1.9306041120023063932e-110, + 1.0567786762735315635e-62, -6.1446417754639301152e-79, -1.535561105648808199e-94, -1.9306041120023063932e-110, + 8.4432539107728090768e-64, 1.9517662449371099233e-79, 2.62202614552995759e-95, 6.5314563001514358328e-112, + 8.4432539107728090768e-64, 1.9517662449371099233e-79, 2.62202614552995759e-95, 6.5314563001514358328e-112, + 8.4432539107728090768e-64, 1.9517662449371099233e-79, 2.62202614552995759e-95, 6.5314563001514358328e-112, + 8.4432539107728090768e-64, 1.9517662449371099233e-79, 2.62202614552995759e-95, 6.5314563001514358328e-112, + 2.3660905534865399025e-64, -7.2335760163150273591e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, + 2.3660905534865399025e-64, -7.2335760163150273591e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, + 8.4679971416497210292e-65, -7.2335760163150273591e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, + 8.7154294504188118783e-66, 1.2001823382693912203e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, + 8.7154294504188118783e-66, 1.2001823382693912203e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, + 8.7154294504188118783e-66, 1.2001823382693912203e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, + 8.7154294504188118783e-66, 1.2001823382693912203e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, + 3.9676455775389135587e-66, 1.459625439463388979e-82, 2.8738690232659205689e-99, 1.8395411057335783574e-115, + 1.5937536410989638719e-66, 1.459625439463388979e-82, 2.8738690232659205689e-99, 1.8395411057335783574e-115, + 4.0680767287898916022e-67, 1.4185069655957361252e-83, -7.8369062883735917115e-100, -1.9081236411894110579e-116, + 4.0680767287898916022e-67, 1.4185069655957361252e-83, -7.8369062883735917115e-100, -1.9081236411894110579e-116, + 1.1007118082399544936e-67, 1.4185069655957361252e-83, -7.8369062883735917115e-100, -1.9081236411894110579e-116, + 1.1007118082399544936e-67, 1.4185069655957361252e-83, -7.8369062883735917115e-100, -1.9081236411894110579e-116, + 3.588705781024702988e-68, 5.9489775128085131541e-84, 1.0450891972142805974e-99, 1.8395411057335783574e-115, + 3.588705781024702988e-68, 5.9489775128085131541e-84, 1.0450891972142805974e-99, 1.8395411057335783574e-115, + 1.7341027056809927069e-68, 1.830931441234090934e-84, 1.3069928418846076386e-100, 3.1677600334418876704e-116, + 8.0680116800913756637e-69, -2.2809159455312046184e-85, -4.0748824503880445403e-101, -6.3915272253158644628e-117, + 3.4315039917320989315e-69, -2.2809159455312046184e-85, -4.0748824503880445403e-101, -6.3915272253158644628e-117, + 1.113250147552460308e-69, 2.9286284920280941206e-86, 2.1132026692048600853e-102, -4.6672632026740766185e-119, + 1.113250147552460308e-69, 2.9286284920280941206e-86, 2.1132026692048600853e-102, -4.6672632026740766185e-119, + 5.3368668650755071652e-70, 2.9286284920280941206e-86, 2.1132026692048600853e-102, -4.6672632026740766185e-119, + 2.4390495598509592076e-70, 2.9286284920280941206e-86, 2.1132026692048600853e-102, -4.6672632026740766185e-119, + 9.901409072386855505e-71, -2.8859500138942368532e-87, -5.6567402911297190423e-103, -4.6672632026740766185e-119, + 2.6568658093254848067e-71, 5.1571087196495574384e-87, 3.2728487032630532648e-103, 5.2465720993401781599e-119, + 2.6568658093254848067e-71, 5.1571087196495574384e-87, 3.2728487032630532648e-103, 5.2465720993401781599e-119, + 8.4572999356014273536e-72, 1.1355793528776598461e-87, 3.2728487032630532648e-103, 5.2465720993401781599e-119, + 8.4572999356014273536e-72, 1.1355793528776598461e-87, 3.2728487032630532648e-103, 5.2465720993401781599e-119, + 3.9294603961880721752e-72, 1.3019701118468578292e-88, -7.5747169634236195447e-105, -2.0152904854894729832e-121, + 1.6655406264813940833e-72, 1.3019701118468578292e-88, -7.5747169634236195447e-105, -2.0152904854894729832e-121, + 5.3358074162805516304e-73, 4.5242184730639744369e-90, 1.1455847889130727424e-105, 1.8573014293598455046e-121, + 5.3358074162805516304e-73, 4.5242184730639744369e-90, 1.1455847889130727424e-105, 1.8573014293598455046e-121, + 2.5059077041472040156e-73, 4.5242184730639744369e-90, 1.1455847889130727424e-105, 1.8573014293598455046e-121, + 1.0909578480805302081e-73, 4.5242184730639744369e-90, 1.1455847889130727424e-105, 1.8573014293598455046e-121, + 3.8348292004719330442e-74, 4.5242184730639744369e-90, 1.1455847889130727424e-105, 1.8573014293598455046e-121, + 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.5547069870986327528e-107, 1.6304246661326865276e-122, + 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.5547069870986327528e-107, 1.6304246661326865276e-122, + 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.5547069870986327528e-107, 1.6304246661326865276e-122, + 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.5547069870986327528e-107, 1.6304246661326865276e-122, + 7.6368645294831185015e-76, 1.0603435429602168369e-91, 1.0451839188820145747e-108, 4.2386081393205242443e-125, + 7.6368645294831185015e-76, 1.0603435429602168369e-91, 1.0451839188820145747e-108, 4.2386081393205242443e-125, + 2.1097166542226745549e-76, 4.4670685979800101779e-92, 1.0451839188820145747e-108, 4.2386081393205242443e-125, + 2.1097166542226745549e-76, 4.4670685979800101779e-92, 1.0451839188820145747e-108, 4.2386081393205242443e-125, + 7.2792968540756372162e-77, 1.3988851821689310822e-92, 1.0451839188820145747e-108, 4.2386081393205242443e-125, + 3.7036201000008285821e-78, 5.6554937751584084315e-94, -1.9306041120023063932e-110, 1.0223371855251472933e-126, + 3.7036201000008285821e-78, 5.6554937751584084315e-94, -1.9306041120023063932e-110, 1.0223371855251472933e-126, + 3.7036201000008285821e-78, 5.6554937751584084315e-94, -1.9306041120023063932e-110, 1.0223371855251472933e-126, + 3.7036201000008285821e-78, 5.6554937751584084315e-94, -1.9306041120023063932e-110, 1.0223371855251472933e-126, + 3.7036201000008285821e-78, 5.6554937751584084315e-94, -1.9306041120023063932e-110, 1.0223371855251472933e-126, + 1.5445779612272179051e-78, 8.6145718795359707834e-95, 7.3062078800278780675e-111, 1.0223371855251472933e-126, + 4.6505689184041232695e-79, 8.6145718795359707834e-95, 7.3062078800278780675e-111, 1.0223371855251472933e-126, + 4.6505689184041232695e-79, 8.6145718795359707834e-95, 7.3062078800278780675e-111, 1.0223371855251472933e-126, + 1.9517662449371099233e-79, 2.62202614552995759e-95, 6.5314563001514349095e-112, 9.9039323746573674262e-128, + 6.0236490820360325022e-80, -3.7424672147304925625e-96, -1.784871512364483542e-112, 6.7095375687163151728e-129, + 6.0236490820360325022e-80, -3.7424672147304925625e-96, -1.784871512364483542e-112, 6.7095375687163151728e-129, + 2.6501457402022643213e-80, 3.7482149527770239293e-96, 6.5314563001514349095e-112, 9.9039323746573674262e-128, + 9.6339406928538097998e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, + 1.2001823382693912203e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, + 1.2001823382693912203e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, + 1.2001823382693912203e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, + 1.459625439463388979e-82, 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, + 1.459625439463388979e-82, 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, + 1.459625439463388979e-82, 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, + 1.4185069655957361252e-83, -7.8369062883735917115e-100, -1.9081236411894107761e-116, -2.1796760241698337334e-132, + 1.4185069655957361252e-83, -7.8369062883735917115e-100, -1.9081236411894107761e-116, -2.1796760241698337334e-132, + 1.4185069655957361252e-83, -7.8369062883735917115e-100, -1.9081236411894107761e-116, -2.1796760241698337334e-132, + 1.4185069655957361252e-83, -7.8369062883735917115e-100, -1.9081236411894107761e-116, -2.1796760241698337334e-132, + 5.9489775128085131541e-84, 1.0450891972142805974e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, + 1.830931441234090934e-84, 1.3069928418846076386e-100, 3.1677600334418871069e-116, 3.4556869017247800778e-132, + 1.830931441234090934e-84, 1.3069928418846076386e-100, 3.1677600334418871069e-116, 3.4556869017247800778e-132, + 8.0141992334048515034e-85, 1.3069928418846076386e-100, 3.1677600334418871069e-116, 3.4556869017247800778e-132, + 2.8666416439368237283e-85, 1.6400545060233297363e-101, -4.6672632026740766185e-119, -3.755176715260116501e-136, + 2.9286284920280941206e-86, 2.1132026692048600853e-102, -4.6672632026740766185e-119, -3.755176715260116501e-136, + 2.9286284920280941206e-86, 2.1132026692048600853e-102, -4.6672632026740766185e-119, -3.755176715260116501e-136, + 2.9286284920280941206e-86, 2.1132026692048600853e-102, -4.6672632026740766185e-119, -3.755176715260116501e-136, + 2.9286284920280941206e-86, 2.1132026692048600853e-102, -4.6672632026740766185e-119, -3.755176715260116501e-136, + 1.3200167453193350837e-86, 2.1132026692048600853e-102, -4.6672632026740766185e-119, -3.755176715260116501e-136, + 5.1571087196495574384e-87, 3.2728487032630532648e-103, 5.2465720993401781599e-119, -3.755176715260116501e-136, + 1.1355793528776598461e-87, 3.2728487032630532648e-103, 5.2465720993401781599e-119, -3.755176715260116501e-136, + 1.1355793528776598461e-87, 3.2728487032630532648e-103, 5.2465720993401781599e-119, -3.755176715260116501e-136, + 1.3019701118468578292e-88, -7.5747169634236195447e-105, -2.0152904854894725532e-121, -3.1562414818576682143e-137, + 1.3019701118468578292e-88, -7.5747169634236195447e-105, -2.0152904854894725532e-121, -3.1562414818576682143e-137, + 1.3019701118468578292e-88, -7.5747169634236195447e-105, -2.0152904854894725532e-121, -3.1562414818576682143e-137, + 4.5242184730639744369e-90, 1.1455847889130727424e-105, 1.8573014293598452896e-121, 1.1431992269852683481e-137, + 4.5242184730639744369e-90, 1.1455847889130727424e-105, 1.8573014293598452896e-121, 1.1431992269852683481e-137, + 4.5242184730639744369e-90, 1.1455847889130727424e-105, 1.8573014293598452896e-121, 1.1431992269852683481e-137, + 4.5242184730639744369e-90, 1.1455847889130727424e-105, 1.8573014293598452896e-121, 1.1431992269852683481e-137, + 4.5242184730639744369e-90, 1.1455847889130727424e-105, 1.8573014293598452896e-121, 1.1431992269852683481e-137, + 5.969437008257942845e-91, 5.5547069870986327528e-107, 1.6304246661326865276e-122, 6.8339049774534162772e-139, + 5.969437008257942845e-91, 5.5547069870986327528e-107, 1.6304246661326865276e-122, 6.8339049774534162772e-139, + 5.969437008257942845e-91, 5.5547069870986327528e-107, 1.6304246661326865276e-122, 6.8339049774534162772e-139, + 1.0603435429602168369e-91, 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591188256e-141, + 1.0603435429602168369e-91, 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591188256e-141, + 1.0603435429602168369e-91, 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591188256e-141, + 4.4670685979800101779e-92, 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591188256e-141, + 1.3988851821689310822e-92, 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591188256e-141, + 1.3988851821689310822e-92, 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591188256e-141, + 6.3183932821616130831e-93, 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591188256e-141, + 2.4831640123977650651e-93, 1.9359195088038447797e-109, -4.8867691298577234423e-126, -2.0587960670007823264e-142, + 5.6554937751584084315e-94, -1.9306041120023063932e-110, 1.0223371855251471293e-126, 1.2214168761472102282e-142, + 5.6554937751584084315e-94, -1.9306041120023063932e-110, 1.0223371855251471293e-126, 1.2214168761472102282e-142, + 8.6145718795359707834e-95, 7.3062078800278780675e-111, 1.0223371855251471293e-126, 1.2214168761472102282e-142, + 8.6145718795359707834e-95, 7.3062078800278780675e-111, 1.0223371855251471293e-126, 1.2214168761472102282e-142, + 8.6145718795359707834e-95, 7.3062078800278780675e-111, 1.0223371855251471293e-126, 1.2214168761472102282e-142, + 2.62202614552995759e-95, 6.5314563001514349095e-112, 9.9039323746573674262e-128, -8.6629775332868987041e-145, + 2.62202614552995759e-95, 6.5314563001514349095e-112, 9.9039323746573674262e-128, -8.6629775332868987041e-145, + 1.1238897120284541253e-95, 6.5314563001514349095e-112, 9.9039323746573674262e-128, -8.6629775332868987041e-145, + 3.7482149527770239293e-96, 6.5314563001514349095e-112, 9.9039323746573674262e-128, -8.6629775332868987041e-145, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 1.0450891972142805974e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 1.3069928418846076386e-100, 3.1677600334418871069e-116, 3.4556869017247794521e-132, 8.5448727249069983612e-148, + 1.3069928418846076386e-100, 3.1677600334418871069e-116, 3.4556869017247794521e-132, 8.5448727249069983612e-148, + 1.3069928418846076386e-100, 3.1677600334418871069e-116, 3.4556869017247794521e-132, 8.5448727249069983612e-148, + 1.6400545060233297363e-101, -4.6672632026740766185e-119, -3.755176715260116501e-136, 2.1571619860435652883e-152, + 1.6400545060233297363e-101, -4.6672632026740766185e-119, -3.755176715260116501e-136, 2.1571619860435652883e-152, + 1.6400545060233297363e-101, -4.6672632026740766185e-119, -3.755176715260116501e-136, 2.1571619860435652883e-152, + 2.1132026692048600853e-102, -4.6672632026740766185e-119, -3.755176715260116501e-136, 2.1571619860435652883e-152, + 2.1132026692048600853e-102, -4.6672632026740766185e-119, -3.755176715260116501e-136, 2.1571619860435652883e-152, + 2.1132026692048600853e-102, -4.6672632026740766185e-119, -3.755176715260116501e-136, 2.1571619860435652883e-152, + 3.2728487032630532648e-103, 5.2465720993401781599e-119, -3.755176715260116501e-136, 2.1571619860435652883e-152, + 3.2728487032630532648e-103, 5.2465720993401781599e-119, -3.755176715260116501e-136, 2.1571619860435652883e-152, + 3.2728487032630532648e-103, 5.2465720993401781599e-119, -3.755176715260116501e-136, 2.1571619860435652883e-152, + 1.0404514546648604359e-103, 2.896544483330507019e-120, 3.1239284188885823808e-136, 2.1571619860435652883e-152, + 1.0404514546648604359e-103, 2.896544483330507019e-120, 3.1239284188885823808e-136, 2.1571619860435652883e-152, + 4.8235214251531210473e-104, 2.896544483330507019e-120, 3.1239284188885823808e-136, 2.1571619860435652883e-152, + 2.0330248644053793915e-104, 2.896544483330507019e-120, 3.1239284188885823808e-136, 2.1571619860435652883e-152, + 6.3777658403150887343e-105, -2.0152904854894725532e-121, -3.156241481857667737e-137, -7.0684085473731388916e-153, + 6.3777658403150887343e-105, -2.0152904854894725532e-121, -3.156241481857667737e-137, -7.0684085473731388916e-153, + 2.88964513938041089e-105, 5.7298933442091639924e-121, -3.156241481857667737e-137, -7.0684085473731388916e-153, + 1.1455847889130727424e-105, 1.8573014293598452896e-121, 1.1431992269852681095e-137, 2.4782675885631257398e-153, + 2.7355461367940366859e-106, -7.8994528064813712419e-123, -2.0037599452814940222e-138, 9.1598554579059548847e-155, + 2.7355461367940366859e-106, -7.8994528064813712419e-123, -2.0037599452814940222e-138, 9.1598554579059548847e-155, + 5.5547069870986327528e-107, 1.6304246661326865276e-122, 6.8339049774534147855e-139, 9.1598554579059548847e-155, + 5.5547069870986327528e-107, 1.6304246661326865276e-122, 6.8339049774534147855e-139, 9.1598554579059548847e-155, + 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, + 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, + 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, + 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, + 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, + 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, + 1.9359195088038447797e-109, -4.8867691298577234423e-126, -2.0587960670007819622e-142, -2.8326669474241479263e-158, + 1.9359195088038447797e-109, -4.8867691298577234423e-126, -2.0587960670007819622e-142, -2.8326669474241479263e-158, + 1.9359195088038447797e-109, -4.8867691298577234423e-126, -2.0587960670007819622e-142, -2.8326669474241479263e-158, + 8.7142954880180709975e-110, -4.8867691298577234423e-126, -2.0587960670007819622e-142, -2.8326669474241479263e-158, + 3.3918456880078814158e-110, 6.931443500908017045e-126, 1.1062055705591186799e-141, 1.1734404793201255869e-157, + 7.3062078800278780675e-111, 1.0223371855251471293e-126, 1.2214168761472102282e-142, 8.0910098773220312367e-159, + 7.3062078800278780675e-111, 1.0223371855251471293e-126, 1.2214168761472102282e-142, 8.0910098773220312367e-159, + 6.5314563001514349095e-112, 9.9039323746573674262e-128, -8.6629775332868972816e-145, -1.5987060076657616072e-160, + 6.5314563001514349095e-112, 9.9039323746573674262e-128, -8.6629775332868972816e-145, -1.5987060076657616072e-160, + 6.5314563001514349095e-112, 9.9039323746573674262e-128, -8.6629775332868972816e-145, -1.5987060076657616072e-160, + 6.5314563001514349095e-112, 9.9039323746573674262e-128, -8.6629775332868972816e-145, -1.5987060076657616072e-160, + 2.3732923938934761454e-112, 6.7095375687163138915e-129, 1.6963686085056791706e-144, 1.2464251916751375716e-160, + 2.9421044076449630171e-113, 6.7095375687163138915e-129, 1.6963686085056791706e-144, 1.2464251916751375716e-160, + 2.9421044076449630171e-113, 6.7095375687163138915e-129, 1.6963686085056791706e-144, 1.2464251916751375716e-160, + 2.9421044076449630171e-113, 6.7095375687163138915e-129, 1.6963686085056791706e-144, 1.2464251916751375716e-160, + 3.4325196623373878948e-114, 9.3892593260023063019e-130, 9.4702132359198537748e-146, 1.7950099192230045857e-161, + 3.4325196623373878948e-114, 9.3892593260023063019e-130, 9.4702132359198537748e-146, 1.7950099192230045857e-161, + 3.4325196623373878948e-114, 9.3892593260023063019e-130, 9.4702132359198537748e-146, 1.7950099192230045857e-161, + 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, 2.9106774506606945839e-164, + 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, 2.9106774506606945839e-164, + 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, 2.9106774506606945839e-164, + 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, 2.9106774506606945839e-164, + 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, 2.9106774506606945839e-164, + 8.2436437080731844263e-116, 1.4726412753514008951e-131, -3.9681466199873824165e-148, 2.9106774506606945839e-164, + 3.1677600334418871069e-116, 3.4556869017247794521e-132, 8.544872724906996972e-148, 1.6802919634942429241e-163, + 6.2981819612623816536e-117, 6.3800543877747317218e-133, 7.2423563434801054878e-149, 1.1741471776254779927e-164, + 6.2981819612623816536e-117, 6.3800543877747317218e-133, 7.2423563434801054878e-149, 1.1741471776254779927e-164, + 6.2981819612623816536e-117, 6.3800543877747317218e-133, 7.2423563434801054878e-149, 1.1741471776254779927e-164, + 3.1257546646178208289e-117, -6.6414926959353515111e-134, -5.7828074707888119584e-150, -1.2825052715093464343e-165, + 1.5395410162955400644e-117, -6.6414926959353515111e-134, -5.7828074707888119584e-150, -1.2825052715093464343e-165, + 7.4643419213439950602e-118, 1.0969016447485317626e-133, -5.7828074707888119584e-150, -1.2825052715093464343e-165, + 3.4988078005382940294e-118, 2.1637618757749825688e-134, -8.9490928918944555247e-151, -1.9717385086233606481e-166, + 1.5160407401354430737e-118, 2.1637618757749825688e-134, -8.9490928918944555247e-151, -1.9717385086233606481e-166, + 5.2465720993401781599e-119, -3.755176715260116501e-136, 2.1571619860435648643e-152, 6.3257905089784152346e-168, + 2.896544483330507019e-120, 3.1239284188885823808e-136, 2.1571619860435648643e-152, 6.3257905089784152346e-168, + 2.896544483330507019e-120, 3.1239284188885823808e-136, 2.1571619860435648643e-152, 6.3257905089784152346e-168, + 2.896544483330507019e-120, 3.1239284188885823808e-136, 2.1571619860435648643e-152, 6.3257905089784152346e-168, + 2.896544483330507019e-120, 3.1239284188885823808e-136, 2.1571619860435648643e-152, 6.3257905089784152346e-168, + 2.896544483330507019e-120, 3.1239284188885823808e-136, 2.1571619860435648643e-152, 6.3257905089784152346e-168, + 1.3475077173907800538e-120, -3.156241481857667737e-137, -7.0684085473731388916e-153, -3.3573283875161501977e-170, + 5.7298933442091639924e-121, -3.156241481857667737e-137, -7.0684085473731388916e-153, -3.3573283875161501977e-170, + 1.8573014293598452896e-121, 1.1431992269852681095e-137, 2.4782675885631257398e-153, -3.3573283875161501977e-170, + 1.8573014293598452896e-121, 1.1431992269852681095e-137, 2.4782675885631257398e-153, -3.3573283875161501977e-170, + 8.8915345064751572143e-122, 1.1431992269852681095e-137, 2.4782675885631257398e-153, -3.3573283875161501977e-170, + 4.0507946129135104481e-122, 6.8339049774534147855e-139, 9.1598554579059548847e-155, -4.5159745404911825673e-172, + 1.6304246661326865276e-122, 6.8339049774534147855e-139, 9.1598554579059548847e-155, -4.5159745404911825673e-172, + 4.2023969274227456735e-123, 6.8339049774534147855e-139, 9.1598554579059548847e-155, -4.5159745404911825673e-172, + 4.2023969274227456735e-123, 6.8339049774534147855e-139, 9.1598554579059548847e-155, -4.5159745404911825673e-172, + 1.1769344939467164447e-123, 1.1602886988632691941e-140, 3.0307583960570927356e-156, 5.8345524661064369683e-172, + 1.1769344939467164447e-123, 1.1602886988632691941e-140, 3.0307583960570927356e-156, 5.8345524661064369683e-172, + 4.2056888557770896953e-124, 1.1602886988632691941e-140, 3.0307583960570927356e-156, 5.8345524661064369683e-172, + 4.2386081393205242443e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, 1.2381024895275844856e-174, + 4.2386081393205242443e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, 1.2381024895275844856e-174, + 4.2386081393205242443e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, 1.2381024895275844856e-174, + 4.2386081393205242443e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, 1.2381024895275844856e-174, + 1.8749656131673758844e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, 1.2381024895275844856e-174, + 6.931443500908017045e-126, 1.1062055705591186799e-141, 1.1734404793201255869e-157, 1.2381024895275844856e-174, + 1.0223371855251471293e-126, 1.2214168761472102282e-142, 8.0910098773220302259e-159, 1.2381024895275844856e-174, + 1.0223371855251471293e-126, 1.2214168761472102282e-142, 8.0910098773220302259e-159, 1.2381024895275844856e-174, + 1.0223371855251471293e-126, 1.2214168761472102282e-142, 8.0910098773220302259e-159, 1.2381024895275844856e-174, + 2.8369889610228834887e-127, 4.0136364036021218058e-143, -1.0134099605688458828e-159, -2.5389576707476506925e-176, + 2.8369889610228834887e-127, 4.0136364036021218058e-143, -1.0134099605688458828e-159, -2.5389576707476506925e-176, + 9.9039323746573674262e-128, -8.6629775332868972816e-145, -1.5987060076657612913e-160, -2.5389576707476506925e-176, + 6.7095375687163138915e-129, 1.6963686085056791706e-144, 1.2464251916751375716e-160, 6.197724948400014906e-177, + 6.7095375687163138915e-129, 1.6963686085056791706e-144, 1.2464251916751375716e-160, 6.197724948400014906e-177, + 6.7095375687163138915e-129, 1.6963686085056791706e-144, 1.2464251916751375716e-160, 6.197724948400014906e-177, + 6.7095375687163138915e-129, 1.6963686085056791706e-144, 1.2464251916751375716e-160, 6.197724948400014906e-177, + 9.3892593260023063019e-130, 9.4702132359198537748e-146, 1.7950099192230045857e-161, -1.6991004655691155518e-177, + 9.3892593260023063019e-130, 9.4702132359198537748e-146, 1.7950099192230045857e-161, -1.6991004655691155518e-177, + 9.3892593260023063019e-130, 9.4702132359198537748e-146, 1.7950099192230045857e-161, -1.6991004655691155518e-177, + 2.175994780857201024e-130, 1.4618808551874518553e-146, 1.6802919634942426156e-163, 2.8330093736631818036e-179, + 2.175994780857201024e-130, 1.4618808551874518553e-146, 1.6802919634942426156e-163, 2.8330093736631818036e-179, + 3.7267864457092460442e-131, 4.6083930759590139305e-147, 1.6802919634942426156e-163, 2.8330093736631818036e-179, + 3.7267864457092460442e-131, 4.6083930759590139305e-147, 1.6802919634942426156e-163, 2.8330093736631818036e-179, + 3.7267864457092460442e-131, 4.6083930759590139305e-147, 1.6802919634942426156e-163, 2.8330093736631818036e-179, + 1.4726412753514008951e-131, -3.9681466199873824165e-148, 2.9106774506606941983e-164, 5.1948630316441296498e-180, + 3.4556869017247794521e-132, 8.544872724906996972e-148, 1.6802919634942426156e-163, 2.8330093736631818036e-179, + 3.4556869017247794521e-132, 8.544872724906996972e-148, 1.6802919634942426156e-163, 2.8330093736631818036e-179, + 6.3800543877747317218e-133, 7.2423563434801054878e-149, 1.1741471776254777999e-164, 1.3389912474795152755e-180, + 6.3800543877747317218e-133, 7.2423563434801054878e-149, 1.1741471776254777999e-164, 1.3389912474795152755e-180, + 6.3800543877747317218e-133, 7.2423563434801054878e-149, 1.1741471776254777999e-164, 1.3389912474795152755e-180, + 2.8579525590905986764e-133, -5.7828074707888119584e-150, -1.2825052715093464343e-165, -1.0696067158221530218e-181, + 1.0969016447485317626e-133, -5.7828074707888119584e-150, -1.2825052715093464343e-165, -1.0696067158221530218e-181, + 2.1637618757749825688e-134, -8.9490928918944555247e-151, -1.9717385086233606481e-166, 1.3535321672928907047e-182, + 2.1637618757749825688e-134, -8.9490928918944555247e-151, -1.9717385086233606481e-166, 1.3535321672928907047e-182, + 2.1637618757749825688e-134, -8.9490928918944555247e-151, -1.9717385086233606481e-166, 1.3535321672928907047e-182, + 1.0631050543111905033e-134, 1.5490398016102376505e-150, 3.4549185946116918017e-166, 1.3535321672928907047e-182, + 5.1277664357929471499e-135, 3.2706525621039604902e-151, 7.4159004299416557678e-167, 1.3535321672928907047e-182, + 2.3761243821334675971e-135, 3.2706525621039604902e-151, 7.4159004299416557678e-167, 1.3535321672928907047e-182, + 1.0003033553037281263e-135, 2.1571619860435648643e-152, 6.3257905089784152346e-168, 3.5607241064750984115e-184, + 3.1239284188885823808e-136, 2.1571619860435648643e-152, 6.3257905089784152346e-168, 3.5607241064750984115e-184, + 3.1239284188885823808e-136, 2.1571619860435648643e-152, 6.3257905089784152346e-168, 3.5607241064750984115e-184, + 1.4041521353514076604e-136, 2.1571619860435648643e-152, 6.3257905089784152346e-168, 3.5607241064750984115e-184, + 5.4426399358282049106e-137, 2.4782675885631257398e-153, -3.3573283875161501977e-170, 3.0568054078295488291e-186, + 1.1431992269852681095e-137, 2.4782675885631257398e-153, -3.3573283875161501977e-170, 3.0568054078295488291e-186, + 1.1431992269852681095e-137, 2.4782675885631257398e-153, -3.3573283875161501977e-170, 3.0568054078295488291e-186, + 6.8339049774534147855e-139, 9.1598554579059548847e-155, -4.5159745404911819927e-172, -4.5870810097328578981e-188, + 6.8339049774534147855e-139, 9.1598554579059548847e-155, -4.5159745404911819927e-172, -4.5870810097328578981e-188, + 6.8339049774534147855e-139, 9.1598554579059548847e-155, -4.5159745404911819927e-172, -4.5870810097328578981e-188, + 6.8339049774534147855e-139, 9.1598554579059548847e-155, -4.5159745404911819927e-172, -4.5870810097328578981e-188, + 1.1602886988632691941e-140, 3.0307583960570927356e-156, 5.8345524661064358191e-172, 6.9043123899963188689e-188, + 1.1602886988632691941e-140, 3.0307583960570927356e-156, 5.8345524661064358191e-172, 6.9043123899963188689e-188, + 1.1602886988632691941e-140, 3.0307583960570927356e-156, 5.8345524661064358191e-172, 6.9043123899963188689e-188, + 1.1602886988632691941e-140, 3.0307583960570927356e-156, 5.8345524661064358191e-172, 6.9043123899963188689e-188, + 1.1602886988632691941e-140, 3.0307583960570927356e-156, 5.8345524661064358191e-172, 6.9043123899963188689e-188, + 1.1602886988632691941e-140, 3.0307583960570927356e-156, 5.8345524661064358191e-172, 6.9043123899963188689e-188, + 1.1062055705591186799e-141, 1.1734404793201255869e-157, 1.2381024895275844856e-174, -8.4789520282639751913e-191, + 1.1062055705591186799e-141, 1.1734404793201255869e-157, 1.2381024895275844856e-174, -8.4789520282639751913e-191, + 1.1062055705591186799e-141, 1.1734404793201255869e-157, 1.2381024895275844856e-174, -8.4789520282639751913e-191, + 1.1062055705591186799e-141, 1.1734404793201255869e-157, 1.2381024895275844856e-174, -8.4789520282639751913e-191, + 4.5016298192952031469e-142, -2.8326669474241479263e-158, 1.2381024895275844856e-174, -8.4789520282639751913e-191, + 1.2214168761472102282e-142, 8.0910098773220302259e-159, 1.2381024895275844856e-174, -8.4789520282639751913e-191, + 1.2214168761472102282e-142, 8.0910098773220302259e-159, 1.2381024895275844856e-174, -8.4789520282639751913e-191, + 4.0136364036021218058e-143, -1.0134099605688458828e-159, -2.5389576707476506925e-176, -6.2404128071707654958e-193, + 4.0136364036021218058e-143, -1.0134099605688458828e-159, -2.5389576707476506925e-176, -6.2404128071707654958e-193, + 1.9635033141346264592e-143, -1.0134099605688458828e-159, -2.5389576707476506925e-176, -6.2404128071707654958e-193, + 9.3843676940087855824e-144, 1.2626949989038732076e-159, 2.2730883653953564668e-175, 2.7431118386590483722e-191, + 4.2590349703400483539e-144, 1.2464251916751375716e-160, 6.1977249484000140293e-177, 1.1294061984896458822e-192, + 1.6963686085056791706e-144, 1.2464251916751375716e-160, 6.1977249484000140293e-177, 1.1294061984896458822e-192, + 4.1503542758849472122e-145, -1.7614040799531193879e-161, -1.6991004655691153326e-177, -1.856794109153959173e-193, + 4.1503542758849472122e-145, -1.7614040799531193879e-161, -1.6991004655691153326e-177, -1.856794109153959173e-193, + 9.4702132359198537748e-146, 1.7950099192230045857e-161, -1.6991004655691153326e-177, -1.856794109153959173e-193, + 9.4702132359198537748e-146, 1.7950099192230045857e-161, -1.6991004655691153326e-177, -1.856794109153959173e-193, + 1.4618808551874518553e-146, 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, + 1.4618808551874518553e-146, 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, + 1.4618808551874518553e-146, 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, + 4.6083930759590139305e-147, 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, + 4.6083930759590139305e-147, 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, + 2.105789206980137775e-147, 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, + 8.544872724906996972e-148, 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, + 2.2883630524598079723e-148, 2.9106774506606941983e-164, 5.1948630316441287936e-180, 9.6685396110091032843e-196, + 2.2883630524598079723e-148, 2.9106774506606941983e-164, 5.1948630316441287936e-180, 9.6685396110091032843e-196, + 7.2423563434801054878e-149, 1.1741471776254777999e-164, 1.3389912474795150614e-180, 1.1067843414450286726e-196, + 7.2423563434801054878e-149, 1.1741471776254777999e-164, 1.3389912474795150614e-180, 1.1067843414450286726e-196, + 3.3320377982006123631e-149, 3.0588204110786950436e-165, 3.7502330143836152136e-181, 3.6564932749519464998e-198, + 1.3768785255608653665e-149, 3.0588204110786950436e-165, 3.7502330143836152136e-181, 3.6564932749519464998e-198, + 3.9929888924099219388e-150, -1.9717385086233606481e-166, 1.3535321672928907047e-182, 3.1205762277848031878e-199, + 3.9929888924099219388e-150, -1.9717385086233606481e-166, 1.3535321672928907047e-182, 3.1205762277848031878e-199, + 1.5490398016102376505e-150, 3.4549185946116918017e-166, 1.3535321672928907047e-182, 3.1205762277848031878e-199, + 3.2706525621039604902e-151, 7.4159004299416557678e-167, 1.3535321672928907047e-182, 3.1205762277848031878e-199, + 3.2706525621039604902e-151, 7.4159004299416557678e-167, 1.3535321672928907047e-182, 3.1205762277848031878e-199, + 2.1571619860435648643e-152, 6.3257905089784152346e-168, 3.5607241064750984115e-184, -1.4832196127821708615e-201, + 2.1571619860435648643e-152, 6.3257905089784152346e-168, 3.5607241064750984115e-184, -1.4832196127821708615e-201, + 2.1571619860435648643e-152, 6.3257905089784152346e-168, 3.5607241064750984115e-184, -1.4832196127821708615e-201, + 2.1571619860435648643e-152, 6.3257905089784152346e-168, 3.5607241064750984115e-184, -1.4832196127821708615e-201, + 2.4782675885631257398e-153, -3.3573283875161501977e-170, 3.0568054078295488291e-186, 1.4980560800565462618e-202, + 2.4782675885631257398e-153, -3.3573283875161501977e-170, 3.0568054078295488291e-186, 1.4980560800565462618e-202, + 2.4782675885631257398e-153, -3.3573283875161501977e-170, 3.0568054078295488291e-186, 1.4980560800565462618e-202, + 9.1598554579059548847e-155, -4.5159745404911819927e-172, -4.5870810097328572602e-188, -3.2905064432040069127e-204, + 9.1598554579059548847e-155, -4.5159745404911819927e-172, -4.5870810097328572602e-188, -3.2905064432040069127e-204, + 9.1598554579059548847e-155, -4.5159745404911819927e-172, -4.5870810097328572602e-188, -3.2905064432040069127e-204, + 9.1598554579059548847e-155, -4.5159745404911819927e-172, -4.5870810097328572602e-188, -3.2905064432040069127e-204, + 9.1598554579059548847e-155, -4.5159745404911819927e-172, -4.5870810097328572602e-188, -3.2905064432040069127e-204, + 1.7015147267057481414e-155, -4.5159745404911819927e-172, -4.5870810097328572602e-188, -3.2905064432040069127e-204, + 1.7015147267057481414e-155, -4.5159745404911819927e-172, -4.5870810097328572602e-188, -3.2905064432040069127e-204, + 1.7015147267057481414e-155, -4.5159745404911819927e-172, -4.5870810097328572602e-188, -3.2905064432040069127e-204, + 7.6922213530572229852e-156, -4.5159745404911819927e-172, -4.5870810097328572602e-188, -3.2905064432040069127e-204, + 3.0307583960570927356e-156, 5.8345524661064358191e-172, 6.9043123899963188689e-188, -3.2905064432040069127e-204, + 7.0002691755702864582e-157, 6.5928896280762691321e-173, 1.1586156901317304854e-188, -1.0100405885278530137e-205, + 7.0002691755702864582e-157, 6.5928896280762691321e-173, 1.1586156901317304854e-188, -1.0100405885278530137e-205, + 1.1734404793201255869e-157, 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.3321093418096261919e-207, + 1.1734404793201255869e-157, 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.3321093418096261919e-207, + 1.1734404793201255869e-157, 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.3321093418096261919e-207, + 4.4508689228885539715e-158, 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.3321093418096261919e-207, + 8.0910098773220302259e-159, 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.3321093418096261919e-207, + 8.0910098773220302259e-159, 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.3321093418096261919e-207, + 8.0910098773220302259e-159, 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.3321093418096261919e-207, + 3.5387999583765925506e-159, 2.2730883653953564668e-175, 2.7431118386590483722e-191, -1.3321093418096261919e-207, + 1.2626949989038732076e-159, 2.2730883653953564668e-175, 2.7431118386590483722e-191, -1.3321093418096261919e-207, + 1.2464251916751375716e-160, 6.1977249484000140293e-177, 1.1294061984896456875e-192, 2.2526486929936882202e-208, + 1.2464251916751375716e-160, 6.1977249484000140293e-177, 1.1294061984896456875e-192, 2.2526486929936882202e-208, + 1.2464251916751375716e-160, 6.1977249484000140293e-177, 1.1294061984896456875e-192, 2.2526486929936882202e-208, + 1.2464251916751375716e-160, 6.1977249484000140293e-177, 1.1294061984896456875e-192, 2.2526486929936882202e-208, + 5.3514239183991277695e-161, 6.1977249484000140293e-177, 1.1294061984896456875e-192, 2.2526486929936882202e-208, + 1.7950099192230045857e-161, -1.6991004655691153326e-177, -1.8567941091539589297e-193, -1.8074851186411640793e-209, + 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, + 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, + 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, + 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, + 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, + 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, + 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, + 2.9106774506606941983e-164, 5.1948630316441287936e-180, 9.6685396110091013832e-196, 1.7562785002189357559e-211, + 2.9106774506606941983e-164, 5.1948630316441287936e-180, 9.6685396110091013832e-196, 1.7562785002189357559e-211, + 2.9106774506606941983e-164, 5.1948630316441287936e-180, 9.6685396110091013832e-196, 1.7562785002189357559e-211, + 1.1741471776254777999e-164, 1.3389912474795150614e-180, 1.106784341445028435e-196, 3.3045982549756583552e-212, + 3.0588204110786950436e-165, 3.7502330143836152136e-181, 3.6564932749519464998e-198, 3.7097125405852507464e-214, + 3.0588204110786950436e-165, 3.7502330143836152136e-181, 3.6564932749519464998e-198, 3.7097125405852507464e-214, + 8.8815756978467430465e-166, 1.3403131492807310959e-181, 3.6564932749519464998e-198, 3.7097125405852507464e-214, + 8.8815756978467430465e-166, 1.3403131492807310959e-181, 3.6564932749519464998e-198, 3.7097125405852507464e-214, + 3.4549185946116918017e-166, 1.3535321672928907047e-182, 3.1205762277848031878e-199, -3.3569248349832580936e-217, + 7.4159004299416557678e-167, 1.3535321672928907047e-182, 3.1205762277848031878e-199, -3.3569248349832580936e-217, + 7.4159004299416557678e-167, 1.3535321672928907047e-182, 3.1205762277848031878e-199, -3.3569248349832580936e-217, + 6.3257905089784152346e-168, 3.5607241064750984115e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, + 6.3257905089784152346e-168, 3.5607241064750984115e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, + 6.3257905089784152346e-168, 3.5607241064750984115e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, + 6.3257905089784152346e-168, 3.5607241064750984115e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, + 2.0862146470760309789e-168, -1.146150630053972131e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, + 2.0862146470760309789e-168, -1.146150630053972131e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, + 1.026320681600434562e-168, 1.2072867382105631402e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, + 4.9637369886263658882e-169, 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, + 2.3140020749373754342e-169, 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, + 9.8913461809288020723e-170, 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, + 3.2670088967063259373e-170, 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, + 3.2670088967063259373e-170, 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, + 1.6109245756507072713e-170, -6.2044048008378732802e-187, -5.4322544592823556944e-203, 4.2491789852161138683e-219, + 7.8288241512289757055e-171, 1.2181824638728806485e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, + 3.6886133485899290404e-171, 2.9887099189454666024e-187, 4.774153170641553462e-203, 4.2491789852161138683e-219, + 1.6185079472704052482e-171, 2.9887099189454666024e-187, 4.774153170641553462e-203, 4.2491789852161138683e-219, + 5.8345524661064358191e-172, 6.9043123899963188689e-188, -3.2905064432040069127e-204, -9.1795828160190082842e-224, + 6.5928896280762691321e-173, 1.1586156901317304854e-188, -1.0100405885278530137e-205, -9.1795828160190082842e-224, + 6.5928896280762691321e-173, 1.1586156901317304854e-188, -1.0100405885278530137e-205, -9.1795828160190082842e-224, + 6.5928896280762691321e-173, 1.1586156901317304854e-188, -1.0100405885278530137e-205, -9.1795828160190082842e-224, + 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.332109341809626019e-207, -9.1795828160190082842e-224, + 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.332109341809626019e-207, -9.1795828160190082842e-224, + 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.332109341809626019e-207, -9.1795828160190082842e-224, + 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.332109341809626019e-207, -9.1795828160190082842e-224, + 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.332109341809626019e-207, -9.1795828160190082842e-224, + 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.332109341809626019e-207, -9.1795828160190082842e-224, + 2.2730883653953564668e-175, 2.7431118386590483722e-191, -1.332109341809626019e-207, -9.1795828160190082842e-224, + 2.2730883653953564668e-175, 2.7431118386590483722e-191, -1.332109341809626019e-207, -9.1795828160190082842e-224, + 2.2730883653953564668e-175, 2.7431118386590483722e-191, -1.332109341809626019e-207, -9.1795828160190082842e-224, + 1.0095962991602958391e-175, -6.2404128071707654958e-193, 3.0593092910744445285e-209, 5.4622616159087170031e-225, + 3.7785026604276538491e-176, -6.2404128071707654958e-193, 3.0593092910744445285e-209, 5.4622616159087170031e-225, + 6.1977249484000140293e-177, 1.1294061984896456875e-192, 2.2526486929936882202e-208, -5.3441928036578162463e-225, + 6.1977249484000140293e-177, 1.1294061984896456875e-192, 2.2526486929936882202e-208, -5.3441928036578162463e-225, + 6.1977249484000140293e-177, 1.1294061984896456875e-192, 2.2526486929936882202e-208, -5.3441928036578162463e-225, + 2.2493122414154495675e-177, 2.5268245888628466632e-193, 3.0593092910744445285e-209, 5.4622616159087170031e-225, + 2.7510588792316711745e-178, 3.3501523985444386676e-194, 6.2591208621664049475e-210, 5.9034406125450500218e-227, + 2.7510588792316711745e-178, 3.3501523985444386676e-194, 6.2591208621664049475e-210, 5.9034406125450500218e-227, + 2.7510588792316711745e-178, 3.3501523985444386676e-194, 6.2591208621664049475e-210, 5.9034406125450500218e-227, + 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, 9.9192633285681635836e-229, + 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, 9.9192633285681635836e-229, + 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, 9.9192633285681635836e-229, + 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, 9.9192633285681635836e-229, + 1.2906606599973359683e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, 9.9192633285681635836e-229, + 5.1948630316441287936e-180, 9.6685396110091013832e-196, 1.7562785002189355449e-211, 1.6821693549018732055e-227, + 1.3389912474795150614e-180, 1.106784341445028435e-196, 3.3045982549756578275e-212, 6.2685154049107876715e-228, + 1.3389912474795150614e-180, 1.106784341445028435e-196, 3.3045982549756578275e-212, 6.2685154049107876715e-228, + 3.7502330143836152136e-181, 3.6564932749519464998e-198, 3.7097125405852507464e-214, 2.5658818466966882188e-231, + 3.7502330143836152136e-181, 3.6564932749519464998e-198, 3.7097125405852507464e-214, 2.5658818466966882188e-231, + 1.3403131492807310959e-181, 3.6564932749519464998e-198, 3.7097125405852507464e-214, 2.5658818466966882188e-231, + 1.3535321672928907047e-182, 3.1205762277848031878e-199, -3.3569248349832580936e-217, -1.0577661142165146927e-233, + 1.3535321672928907047e-182, 3.1205762277848031878e-199, -3.3569248349832580936e-217, -1.0577661142165146927e-233, + 1.3535321672928907047e-182, 3.1205762277848031878e-199, -3.3569248349832580936e-217, -1.0577661142165146927e-233, + 1.3535321672928907047e-182, 3.1205762277848031878e-199, -3.3569248349832580936e-217, -1.0577661142165146927e-233, + 6.0043220944823941786e-183, 3.1205762277848031878e-199, -3.3569248349832580936e-217, -1.0577661142165146927e-233, + 2.2388223052591377446e-183, 3.1205762277848031878e-199, -3.3569248349832580936e-217, -1.0577661142165146927e-233, + 3.5607241064750984115e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 3.5607241064750984115e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 3.5607241064750984115e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 1.2072867382105631402e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 1.2181824638728806485e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 2.9887099189454666024e-187, 4.774153170641553462e-203, 4.2491789852161132393e-219, 7.4467067939231424594e-235, + 2.9887099189454666024e-187, 4.774153170641553462e-203, 4.2491789852161132393e-219, 7.4467067939231424594e-235, + 6.9043123899963188689e-188, -3.2905064432040069127e-204, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 6.9043123899963188689e-188, -3.2905064432040069127e-204, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 1.1586156901317304854e-188, -1.0100405885278530137e-205, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 1.1586156901317304854e-188, -1.0100405885278530137e-205, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 1.1586156901317304854e-188, -1.0100405885278530137e-205, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 4.4040360264865697732e-189, -1.0100405885278530137e-205, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 8.129755890712020335e-190, 9.8339840169166049336e-206, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 8.129755890712020335e-190, 9.8339840169166049336e-206, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 8.129755890712020335e-190, 9.8339840169166049336e-206, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 3.6409303439428119063e-190, -1.332109341809626019e-207, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 1.3965175705582071936e-190, -1.332109341809626019e-207, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 2.7431118386590483722e-191, -1.332109341809626019e-207, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 2.7431118386590483722e-191, -1.332109341809626019e-207, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 2.7431118386590483722e-191, -1.332109341809626019e-207, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 1.3403538552936701153e-191, 1.7826390804083638359e-207, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 6.389748636109812983e-192, 2.2526486929936882202e-208, -5.3441928036578156465e-225, -7.741539335184153052e-241, + 2.8828536776963681193e-192, 2.2526486929936882202e-208, -5.3441928036578156465e-225, -7.741539335184153052e-241, + 1.1294061984896456875e-192, 2.2526486929936882202e-208, -5.3441928036578156465e-225, -7.741539335184153052e-241, + 2.5268245888628466632e-193, 3.0593092910744445285e-209, 5.4622616159087170031e-225, 4.2560351759808952526e-241, + 2.5268245888628466632e-193, 3.0593092910744445285e-209, 5.4622616159087170031e-225, 4.2560351759808952526e-241, + 3.3501523985444386676e-194, 6.2591208621664049475e-210, 5.9034406125450490845e-227, 1.3186893776791012681e-242, + 3.3501523985444386676e-194, 6.2591208621664049475e-210, 5.9034406125450490845e-227, 1.3186893776791012681e-242, + 3.3501523985444386676e-194, 6.2591208621664049475e-210, 5.9034406125450490845e-227, 1.3186893776791012681e-242, + 6.1039071228393547627e-195, 1.7562785002189355449e-211, 1.6821693549018732055e-227, -8.7276385348052817035e-244, + 6.1039071228393547627e-195, 1.7562785002189355449e-211, 1.6821693549018732055e-227, -8.7276385348052817035e-244, + 6.1039071228393547627e-195, 1.7562785002189355449e-211, 1.6821693549018732055e-227, -8.7276385348052817035e-244, + 2.6792050150137250131e-195, 1.7562785002189355449e-211, 1.6821693549018732055e-227, -8.7276385348052817035e-244, + 9.6685396110091013832e-196, 1.7562785002189355449e-211, 1.6821693549018732055e-227, -8.7276385348052817035e-244, + 2.0416567491425607157e-177, 6.0959078275963141821e-193, 1.156336993964950812e-208, 2.7126166236326293347e-224, + 2.0416567491425607157e-177, 6.0959078275963141821e-193, 1.156336993964950812e-208, 2.7126166236326293347e-224, + 2.0416567491425607157e-177, 6.0959078275963141821e-193, 1.156336993964950812e-208, 2.7126166236326293347e-224, + 6.7450395650278649168e-179, 6.8432117823206978686e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, + 6.7450395650278649168e-179, 6.8432117823206978686e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, + 6.7450395650278649168e-179, 6.8432117823206978686e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, + 6.7450395650278649168e-179, 6.8432117823206978686e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, + 6.7450395650278649168e-179, 6.8432117823206978686e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, + 5.756447103644822603e-180, -6.1924333305615830735e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 5.756447103644822603e-180, -6.1924333305615830735e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 5.756447103644822603e-180, -6.1924333305615830735e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 5.756447103644822603e-180, -6.1924333305615830735e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 1.9005753194802080146e-180, -6.1924333305615830735e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 1.9005753194802080146e-180, -6.1924333305615830735e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 9.3660737343905436753e-181, -6.1924333305615830735e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 4.5462340041847754398e-181, -6.1924333305615830735e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 2.1363141390818913221e-181, -6.1924333305615830735e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 9.3135420653044926323e-182, -6.1924333305615830735e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 3.2887424025472810002e-182, 7.185309278132283136e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 2.7634257116867652192e-183, 4.9643797378534984559e-199, -9.4699347169310243473e-216, -9.2331809177749095611e-233, + 2.7634257116867652192e-183, 4.9643797378534984559e-199, -9.4699347169310243473e-216, -9.2331809177749095611e-233, + 2.7634257116867652192e-183, 4.9643797378534984559e-199, -9.4699347169310243473e-216, -9.2331809177749095611e-233, + 2.7634257116867652192e-183, 4.9643797378534984559e-199, -9.4699347169310243473e-216, -9.2331809177749095611e-233, + 8.806758170751374203e-184, 7.8383517263666503337e-200, 1.3736749441945438342e-215, -9.2331809177749095611e-233, + 8.806758170751374203e-184, 7.8383517263666503337e-200, 1.3736749441945438342e-215, -9.2331809177749095611e-233, + 4.0998834342223036605e-184, 7.8383517263666503337e-200, 1.3736749441945438342e-215, -9.2331809177749095611e-233, + 1.7464460659577689118e-184, 2.612671019845610006e-200, 2.1334073625072069974e-216, -9.2331809177749095611e-233, + 5.697273818255015375e-185, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 5.697273818255015375e-185, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 2.755477107924346286e-185, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 1.2845787527590117414e-185, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 5.4912957517634446918e-186, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 1.8140498638501083305e-186, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 1.8140498638501083305e-186, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 8.9473839187177424013e-187, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 4.3508265588260719497e-187, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 2.0525478788802367239e-187, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 9.0340853890731911095e-188, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 3.288388689208603045e-188, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 4.1554033927630885323e-189, -9.8582956929636044137e-206, -1.4280619485269765742e-221, 1.2171222696290252021e-237, + 4.1554033927630885323e-189, -9.8582956929636044137e-206, -1.4280619485269765742e-221, 1.2171222696290252021e-237, + 4.1554033927630885323e-189, -9.8582956929636044137e-206, -1.4280619485269765742e-221, 1.2171222696290252021e-237, + 5.643429553477207926e-190, 1.0076094209231528444e-205, 7.8509991660024955813e-222, 1.2171222696290252021e-237, + 5.643429553477207926e-190, 1.0076094209231528444e-205, 7.8509991660024955813e-222, 1.2171222696290252021e-237, + 5.643429553477207926e-190, 1.0076094209231528444e-205, 7.8509991660024955813e-222, 1.2171222696290252021e-237, + 1.1546040067079994973e-190, 1.0889925813396166947e-207, 2.4325525462765697993e-223, -1.1429360314275701698e-239, + 1.1546040067079994973e-190, 1.0889925813396166947e-207, 2.4325525462765697993e-223, -1.1429360314275701698e-239, + 3.2397620015697148712e-192, 3.1030547578511949035e-208, -1.609965144193984205e-224, -1.8313007053436627876e-240, + 3.2397620015697148712e-192, 3.1030547578511949035e-208, -1.609965144193984205e-224, -1.8313007053436627876e-240, + 3.2397620015697148712e-192, 3.1030547578511949035e-208, -1.609965144193984205e-224, -1.8313007053436627876e-240, + 3.2397620015697148712e-192, 3.1030547578511949035e-208, -1.609965144193984205e-224, -1.8313007053436627876e-240, + 3.2397620015697148712e-192, 3.1030547578511949035e-208, -1.609965144193984205e-224, -1.8313007053436627876e-240, + 3.2397620015697148712e-192, 3.1030547578511949035e-208, -1.609965144193984205e-224, -1.8313007053436627876e-240, + 1.4863145223629928288e-192, -7.9038076992129241506e-209, -1.609965144193984205e-224, -1.8313007053436627876e-240, + 6.0959078275963141821e-193, 1.156336993964950812e-208, 2.7126166236326293347e-224, -1.8313007053436627876e-240, + 1.712289129579509076e-193, 1.8297811202182925249e-209, 1.1003018740995688645e-226, 5.827891678485165325e-243, + 1.712289129579509076e-193, 1.8297811202182925249e-209, 1.1003018740995688645e-226, 5.827891678485165325e-243, + 6.1638445507530779946e-194, -6.0361608463951204924e-210, 1.1003018740995688645e-226, 5.827891678485165325e-243, + 6.8432117823206978686e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.029900079464340522e-245, + 6.8432117823206978686e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.029900079464340522e-245, + 6.8432117823206978686e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.029900079464340522e-245, + 6.8432117823206978686e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.029900079464340522e-245, + 3.418509674495068119e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.029900079464340522e-245, + 1.7061586205822532442e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.029900079464340522e-245, + 8.499830936258458068e-196, 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.029900079464340522e-245, + 4.218953301476420881e-196, 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.029900079464340522e-245, + 2.0785144840854027628e-196, -1.9512340798794268979e-214, -3.6162764918921692779e-230, -2.8387319855193022476e-246, + 1.008295075389893466e-196, -1.9512340798794268979e-214, -3.6162764918921692779e-230, -2.8387319855193022476e-246, + 4.7318537104213881764e-197, -1.9512340798794268979e-214, -3.6162764918921692779e-230, -2.8387319855193022476e-246, + 2.0563051886826149345e-197, -1.9512340798794268979e-214, -3.6162764918921692779e-230, -2.8387319855193022476e-246, + 7.185309278132283136e-198, -1.9512340798794268979e-214, -3.6162764918921692779e-230, -2.8387319855193022476e-246, + 4.9643797378534984559e-199, -9.4699347169310243473e-216, -9.2331809177749077733e-233, -1.4042876247421728101e-248, + 4.9643797378534984559e-199, -9.4699347169310243473e-216, -9.2331809177749077733e-233, -1.4042876247421728101e-248, + 4.9643797378534984559e-199, -9.4699347169310243473e-216, -9.2331809177749077733e-233, -1.4042876247421728101e-248, + 4.9643797378534984559e-199, -9.4699347169310243473e-216, -9.2331809177749077733e-233, -1.4042876247421728101e-248, + 7.8383517263666503337e-200, 1.3736749441945438342e-215, -9.2331809177749077733e-233, -1.4042876247421728101e-248, + 7.8383517263666503337e-200, 1.3736749441945438342e-215, -9.2331809177749077733e-233, -1.4042876247421728101e-248, + 7.8383517263666503337e-200, 1.3736749441945438342e-215, -9.2331809177749077733e-233, -1.4042876247421728101e-248, + 2.612671019845610006e-200, 2.1334073625072069974e-216, -9.2331809177749077733e-233, -1.4042876247421728101e-248, + 2.612671019845610006e-200, 2.1334073625072069974e-216, -9.2331809177749077733e-233, -1.4042876247421728101e-248, + 1.306250843215349634e-200, 2.1334073625072069974e-216, -9.2331809177749077733e-233, -1.4042876247421728101e-248, + 6.5304075490021959302e-201, 6.8298960257742791824e-217, 6.8696910062179237095e-233, 3.8349029251851101018e-249, + 3.2643571074265457254e-201, -4.2219277387461470355e-218, -1.753154605289404553e-234, -7.5861268822635538093e-251, + 1.6313318866387202604e-201, -4.2219277387461470355e-218, -1.753154605289404553e-234, -7.5861268822635538093e-251, + 8.1481927624480752786e-202, -4.2219277387461470355e-218, -1.753154605289404553e-234, -7.5861268822635538093e-251, + 4.0656297104785107096e-202, 4.8431832608149701961e-218, 8.3111403472061145651e-234, 1.6001805286092554504e-249, + 2.0243481844937293316e-202, 3.1062776103441183191e-219, 7.6291913283447536617e-235, 2.0347903074934629333e-250, + 1.0037074215013384159e-202, 3.1062776103441183191e-219, 7.6291913283447536617e-235, 2.0347903074934629333e-250, + 4.9338704000514295811e-203, 3.1062776103441183191e-219, 7.6291913283447536617e-235, 2.0347903074934629333e-250, + 2.3822684925704522921e-203, 3.1062776103441183191e-219, 7.6291913283447536617e-235, 2.0347903074934629333e-250, + 1.1064675388299639308e-203, 2.7343042298126957741e-220, 5.5273393987134252385e-236, 1.1432574793608782288e-251, + 4.6856706195971960852e-204, 2.7343042298126957741e-220, 5.5273393987134252385e-236, 1.1432574793608782288e-251, + 1.4961682352459748279e-204, -8.0675475439086544798e-221, -3.6970842501441777651e-237, -5.7032870362481275794e-253, + 1.4961682352459748279e-204, -8.0675475439086544798e-221, -3.6970842501441777651e-237, -5.7032870362481275794e-253, + 6.9879263915816924805e-205, 9.6377473771091526132e-221, 1.5959741828948633012e-236, 2.7031904319843495713e-252, + 3.0010484111426663515e-205, 7.8509991660024955813e-222, 1.2171222696290252021e-237, -2.4742181023285720738e-254, + 1.0076094209231528444e-205, 7.8509991660024955813e-222, 1.2171222696290252021e-237, -2.4742181023285720738e-254, + 1.0889925813396166947e-207, 2.4325525462765697993e-223, -1.1429360314275701698e-239, 8.3218722366085688343e-256, + 1.0889925813396166947e-207, 2.4325525462765697993e-223, -1.1429360314275701698e-239, 8.3218722366085688343e-256, + 1.0889925813396166947e-207, 2.4325525462765697993e-223, -1.1429360314275701698e-239, 8.3218722366085688343e-256, + 1.0889925813396166947e-207, 2.4325525462765697993e-223, -1.1429360314275701698e-239, 8.3218722366085688343e-256, + 1.0889925813396166947e-207, 2.4325525462765697993e-223, -1.1429360314275701698e-239, 8.3218722366085688343e-256, + 1.0889925813396166947e-207, 2.4325525462765697993e-223, -1.1429360314275701698e-239, 8.3218722366085688343e-256, + 1.0889925813396166947e-207, 2.4325525462765697993e-223, -1.1429360314275701698e-239, 8.3218722366085688343e-256, + 3.1030547578511949035e-208, -1.609965144193984205e-224, -1.8313007053436625212e-240, -2.3341145329525059632e-256, + 3.1030547578511949035e-208, -1.609965144193984205e-224, -1.8313007053436625212e-240, -2.3341145329525059632e-256, + 1.156336993964950812e-208, 2.7126166236326293347e-224, -1.8313007053436625212e-240, -2.3341145329525059632e-256, + 1.8297811202182925249e-209, 1.1003018740995688645e-226, 5.827891678485165325e-243, -3.1174271110208206547e-259, + 1.8297811202182925249e-209, 1.1003018740995688645e-226, 5.827891678485165325e-243, -3.1174271110208206547e-259, + 1.8297811202182925249e-209, 1.1003018740995688645e-226, 5.827891678485165325e-243, -3.1174271110208206547e-259, + 6.1308251778939023781e-210, 1.1003018740995688645e-226, 5.827891678485165325e-243, -3.1174271110208206547e-259, + 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 2.3568521170701555846e-212, -7.7818310317651142243e-229, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 1.1686698881356804311e-212, 1.8601114328504743806e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 5.7457877366844311816e-213, 5.409641648369814791e-229, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 2.7753321643482446169e-213, -1.1860946916976500828e-229, 6.3146909508553973881e-246, 1.2573885592501532045e-261, + 1.290104378180150675e-213, 2.1117734783360818049e-229, 4.2928382696354204061e-245, -2.8075477999879273582e-261, + 5.4749048509610403382e-214, 4.6283939331921604413e-230, 6.3146909508553973881e-246, 1.2573885592501532045e-261, + 1.7618353855408067201e-214, 5.060587206499956961e-231, 5.9380161562121075096e-247, -1.2904053011746964278e-263, + 1.7618353855408067201e-214, 5.060587206499956961e-231, 5.9380161562121075096e-247, -1.2904053011746964278e-263, + 8.3356801918574821257e-215, 5.060587206499956961e-231, 5.9380161562121075096e-247, -1.2904053011746964278e-263, + 3.6943433600821895879e-215, 5.060587206499956961e-231, 5.9380161562121075096e-247, -1.2904053011746964278e-263, + 1.3736749441945438342e-215, -9.2331809177749077733e-233, -1.4042876247421726117e-248, -9.9505977179164858712e-265, + 2.1334073625072069974e-216, -9.2331809177749077733e-233, -1.4042876247421726117e-248, -9.9505977179164858712e-265, + 2.1334073625072069974e-216, -9.2331809177749077733e-233, -1.4042876247421726117e-248, -9.9505977179164858712e-265, + 2.1334073625072069974e-216, -9.2331809177749077733e-233, -1.4042876247421726117e-248, -9.9505977179164858712e-265, + 6.8298960257742791824e-217, 6.8696910062179237095e-233, 3.8349029251851101018e-249, -2.6436684620390282645e-267, + 6.8298960257742791824e-217, 6.8696910062179237095e-233, 3.8349029251851101018e-249, -2.6436684620390282645e-267, + 3.2038516259498326923e-217, -1.1817449557784924788e-233, -6.3454186796659920093e-250, -2.6436684620390282645e-267, + 1.3908294260376086421e-217, 2.8439730252197153919e-233, 3.8349029251851101018e-249, -2.6436684620390282645e-267, + 4.8431832608149701961e-218, 8.3111403472061145651e-234, 1.6001805286092554504e-249, -2.6436684620390282645e-267, + 3.1062776103441183191e-219, 7.6291913283447536617e-235, 2.0347903074934629333e-250, -2.6436684620390282645e-267, + 3.1062776103441183191e-219, 7.6291913283447536617e-235, 2.0347903074934629333e-250, -2.6436684620390282645e-267, + 3.1062776103441183191e-219, 7.6291913283447536617e-235, 2.0347903074934629333e-250, -2.6436684620390282645e-267, + 3.1062776103441183191e-219, 7.6291913283447536617e-235, 2.0347903074934629333e-250, -2.6436684620390282645e-267, + 2.7343042298126957741e-220, 5.5273393987134252385e-236, 1.1432574793608780349e-251, 1.2329569415922591084e-267, + 2.7343042298126957741e-220, 5.5273393987134252385e-236, 1.1432574793608780349e-251, 1.2329569415922591084e-267, + 2.7343042298126957741e-220, 5.5273393987134252385e-236, 1.1432574793608780349e-251, 1.2329569415922591084e-267, + 2.7343042298126957741e-220, 5.5273393987134252385e-236, 1.1432574793608780349e-251, 1.2329569415922591084e-267, + 9.6377473771091526132e-221, 1.5959741828948633012e-236, 2.7031904319843490867e-252, 2.638005906844372114e-268, + 7.8509991660024955813e-222, 1.2171222696290252021e-237, -2.4742181023285720738e-254, -1.2030990169203137715e-270, + 7.8509991660024955813e-222, 1.2171222696290252021e-237, -2.4742181023285720738e-254, -1.2030990169203137715e-270, + 7.8509991660024955813e-222, 1.2171222696290252021e-237, -2.4742181023285720738e-254, -1.2030990169203137715e-270, + 7.8509991660024955813e-222, 1.2171222696290252021e-237, -2.4742181023285720738e-254, -1.2030990169203137715e-270, + 2.318094503184431479e-222, -1.1429360314275701698e-239, 8.3218722366085688343e-256, -2.0046830753539155726e-272, + 2.318094503184431479e-222, -1.1429360314275701698e-239, 8.3218722366085688343e-256, -2.0046830753539155726e-272, + 9.3486833747991514629e-223, -1.1429360314275701698e-239, 8.3218722366085688343e-256, -2.0046830753539155726e-272, + 2.4325525462765697993e-223, -1.1429360314275701698e-239, 8.3218722366085688343e-256, -2.0046830753539155726e-272, + 2.4325525462765697993e-223, -1.1429360314275701698e-239, 8.3218722366085688343e-256, -2.0046830753539155726e-272, + 7.0351983914592419146e-224, 7.766758903588374524e-240, 8.3218722366085688343e-256, -2.0046830753539155726e-272, + 7.0351983914592419146e-224, 7.766758903588374524e-240, 8.3218722366085688343e-256, -2.0046830753539155726e-272, + 2.7126166236326293347e-224, -1.8313007053436625212e-240, -2.3341145329525056675e-256, -2.0046830753539155726e-272, + 5.5132573971932232487e-225, 5.6821419688934674008e-241, 3.2988215943776273615e-257, 2.1353977370878701046e-273, + 5.5132573971932232487e-225, 5.6821419688934674008e-241, 3.2988215943776273615e-257, 2.1353977370878701046e-273, + 1.1003018740995688645e-226, 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, + 1.1003018740995688645e-226, 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, + 1.1003018740995688645e-226, 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, + 1.1003018740995688645e-226, 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, + 1.1003018740995688645e-226, 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, + 1.1003018740995688645e-226, 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, + 2.560476225709334075e-227, 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, + 2.560476225709334075e-227, 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, + 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, -1.472095602234059958e-277, + 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, -1.472095602234059958e-277, + 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, -1.472095602234059958e-277, + 1.8601114328504743806e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, -1.472095602234059958e-277, + 5.409641648369814791e-229, -3.0299000794643401155e-245, -2.8075477999879273582e-261, -1.472095602234059958e-277, + 5.409641648369814791e-229, -3.0299000794643401155e-245, -2.8075477999879273582e-261, -1.472095602234059958e-277, + 2.1117734783360818049e-229, 4.2928382696354204061e-245, -2.8075477999879273582e-261, -1.472095602234059958e-277, + 4.6283939331921604413e-230, 6.3146909508553973881e-246, 1.2573885592501529789e-261, 3.0408903374280139822e-277, + 4.6283939331921604413e-230, 6.3146909508553973881e-246, 1.2573885592501529789e-261, 3.0408903374280139822e-277, + 5.060587206499956961e-231, 5.9380161562121075096e-247, -1.2904053011746964278e-263, 8.7279092175580820317e-280, + 5.060587206499956961e-231, 5.9380161562121075096e-247, -1.2904053011746964278e-263, 8.7279092175580820317e-280, + 5.060587206499956961e-231, 5.9380161562121075096e-247, -1.2904053011746964278e-263, 8.7279092175580820317e-280, + 5.060587206499956961e-231, 5.9380161562121075096e-247, -1.2904053011746964278e-263, 8.7279092175580820317e-280, + 2.4841276986611042098e-231, 2.1712682097791944335e-248, 2.9746046415267896827e-264, -8.6516445844406224413e-282, + 1.1958979447416775482e-231, 2.1712682097791944335e-248, 2.9746046415267896827e-264, -8.6516445844406224413e-282, + 5.5178306778196421733e-232, 2.1712682097791944335e-248, 2.9746046415267896827e-264, -8.6516445844406224413e-282, + 2.2972562930210755192e-232, 2.1712682097791944335e-248, 2.9746046415267896827e-264, -8.6516445844406224413e-282, + 6.8696910062179237095e-233, 3.8349029251851101018e-249, -2.6436684620390282645e-267, -4.3807022524130141006e-284, + 6.8696910062179237095e-233, 3.8349029251851101018e-249, -2.6436684620390282645e-267, -4.3807022524130141006e-284, + 2.8439730252197153919e-233, 3.8349029251851101018e-249, -2.6436684620390282645e-267, -4.3807022524130141006e-284, + 8.3111403472061145651e-234, 1.6001805286092554504e-249, -2.6436684620390282645e-267, -4.3807022524130141006e-284, + 8.3111403472061145651e-234, 1.6001805286092554504e-249, -2.6436684620390282645e-267, -4.3807022524130141006e-284, + 3.2789928709583552854e-234, 4.8281933032132812475e-250, -2.6436684620390282645e-267, -4.3807022524130141006e-284, + 7.6291913283447536617e-235, 2.0347903074934629333e-250, -2.6436684620390282645e-267, -4.3807022524130141006e-284, + 7.6291913283447536617e-235, 2.0347903074934629333e-250, -2.6436684620390282645e-267, -4.3807022524130141006e-284, + 1.3390069830350552605e-235, -6.026193929640082176e-252, -7.0535576022338457803e-268, -4.3807022524130141006e-284, + 1.3390069830350552605e-235, -6.026193929640082176e-252, -7.0535576022338457803e-268, -4.3807022524130141006e-284, + 1.3390069830350552605e-235, -6.026193929640082176e-252, -7.0535576022338457803e-268, -4.3807022524130141006e-284, + 5.5273393987134252385e-236, 1.1432574793608780349e-251, 1.2329569415922591084e-267, -4.3807022524130141006e-284, + 1.5959741828948633012e-236, 2.7031904319843490867e-252, 2.638005906844371576e-268, 6.3790946999826013345e-284, + 1.5959741828948633012e-236, 2.7031904319843490867e-252, 2.638005906844371576e-268, 6.3790946999826013345e-284, + 6.1313287894022281692e-237, 5.2084434157824127104e-253, 2.1511502957481757317e-269, 3.2670891426006739096e-285, + 1.2171222696290252021e-237, -2.4742181023285720738e-254, -1.2030990169203137715e-270, -9.5347405022956042207e-287, + 1.2171222696290252021e-237, -2.4742181023285720738e-254, -1.2030990169203137715e-270, -9.5347405022956042207e-287, + 1.2171222696290252021e-237, -2.4742181023285720738e-254, -1.2030990169203137715e-270, -9.5347405022956042207e-287, + 6.0284645465737476297e-238, -2.4742181023285720738e-254, -1.2030990169203137715e-270, -9.5347405022956042207e-287, + 2.9570854717154947523e-238, 4.3456134301905148502e-254, 6.3684349745470443788e-270, -9.5347405022956042207e-287, + 1.4213959342863689955e-238, 9.3569766393097138822e-255, 2.5826679788133653036e-270, -9.5347405022956042207e-287, + 6.5355116557180594664e-239, 9.3569766393097138822e-255, 2.5826679788133653036e-270, -9.5347405022956042207e-287, + 2.6962878121452450746e-239, 8.3218722366085688343e-256, -2.0046830753539152442e-272, -3.4057806738724185961e-288, + 7.766758903588374524e-240, 8.3218722366085688343e-256, -2.0046830753539152442e-272, -3.4057806738724185961e-288, + 7.766758903588374524e-240, 8.3218722366085688343e-256, -2.0046830753539152442e-272, -3.4057806738724185961e-288, + 2.9677290991223565342e-240, -2.3341145329525056675e-256, -2.0046830753539152442e-272, -3.4057806738724185961e-288, + 5.6821419688934674008e-241, 3.2988215943776273615e-257, 2.1353977370878701046e-273, -1.2215123283371736879e-289, + 5.6821419688934674008e-241, 3.2988215943776273615e-257, 2.1353977370878701046e-273, -1.2215123283371736879e-289, + 5.6821419688934674008e-241, 3.2988215943776273615e-257, 2.1353977370878701046e-273, -1.2215123283371736879e-289, + 2.6827483411022054912e-241, 3.2988215943776273615e-257, 2.1353977370878701046e-273, -1.2215123283371736879e-289, + 1.1830515272065748694e-241, -3.117427111020820077e-259, -5.9718623963762788119e-275, 6.1155422068568954053e-291, + 4.3320312025875939195e-242, -3.117427111020820077e-259, -5.9718623963762788119e-275, 6.1155422068568954053e-291, + 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, 6.1155422068568954053e-291, + 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, 6.1155422068568954053e-291, + 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, 6.1155422068568954053e-291, + 1.1413391350613183311e-243, -5.1586784110844895013e-260, -1.9524039360882352712e-276, -2.9779654517181717279e-292, + 1.1413391350613183311e-243, -5.1586784110844895013e-260, -1.9524039360882352712e-276, -2.9779654517181717279e-292, + 1.1413391350613183311e-243, -5.1586784110844895013e-260, -1.9524039360882352712e-276, -2.9779654517181717279e-292, + 5.5552006713333735927e-244, 7.8491179384773690214e-260, -1.9524039360882352712e-276, -2.9779654517181717279e-292, + 2.6261053316934700345e-244, 1.345219763696439399e-260, 1.6579848156414234801e-276, 1.0303712682997740506e-292, + 1.1615576618735179302e-244, 1.345219763696439399e-260, 1.6579848156414234801e-276, 1.0303712682997740506e-292, + 4.2928382696354204061e-245, -2.8075477999879273582e-261, -1.472095602234059958e-277, 2.8287088295287585094e-294, + 6.3146909508553973881e-246, 1.2573885592501529789e-261, 3.0408903374280139822e-277, 2.8287088295287585094e-294, + 6.3146909508553973881e-246, 1.2573885592501529789e-261, 3.0408903374280139822e-277, 2.8287088295287585094e-294, + 6.3146909508553973881e-246, 1.2573885592501529789e-261, 3.0408903374280139822e-277, 2.8287088295287585094e-294, + 1.7379794826680480784e-246, 2.4115446944063306384e-262, 2.202741251392177696e-278, 2.8287088295287585094e-294, + 1.7379794826680480784e-246, 2.4115446944063306384e-262, 2.202741251392177696e-278, 2.8287088295287585094e-294, + 5.9380161562121075096e-247, -1.2904053011746964278e-263, 8.7279092175580810531e-280, 8.8634899828990930877e-296, + 2.1712682097791944335e-248, 2.9746046415267896827e-264, -8.6516445844406224413e-282, -5.0528699238150276549e-299, + 2.1712682097791944335e-248, 2.9746046415267896827e-264, -8.6516445844406224413e-282, -5.0528699238150276549e-299, + 2.1712682097791944335e-248, 2.9746046415267896827e-264, -8.6516445844406224413e-282, -5.0528699238150276549e-299, + 2.1712682097791944335e-248, 2.9746046415267896827e-264, -8.6516445844406224413e-282, -5.0528699238150276549e-299, + 2.1712682097791944335e-248, 2.9746046415267896827e-264, -8.6516445844406224413e-282, -5.0528699238150276549e-299, + 3.8349029251851101018e-249, -2.6436684620390282645e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 3.8349029251851101018e-249, -2.6436684620390282645e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 3.8349029251851101018e-249, -2.6436684620390282645e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 1.6001805286092554504e-249, -2.6436684620390282645e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 4.8281933032132812475e-250, -2.6436684620390282645e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 4.8281933032132812475e-250, -2.6436684620390282645e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 2.0347903074934629333e-250, -2.6436684620390282645e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 6.3808880963355377617e-251, -2.6436684620390282645e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 6.3808880963355377617e-251, -2.6436684620390282645e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 2.8891343516857640937e-251, 5.1095823452235464813e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 1.1432574793608780349e-251, 1.2329569415922591084e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 2.7031904319843490867e-252, 2.638005906844371576e-268, 6.3790946999826013345e-284, -2.7456019707854725967e-300, + 2.7031904319843490867e-252, 2.638005906844371576e-268, 6.3790946999826013345e-284, -2.7456019707854725967e-300, + 5.2084434157824127104e-253, 2.1511502957481757317e-269, 3.2670891426006735363e-285, 2.4084160842482777461e-301, + 5.2084434157824127104e-253, 2.1511502957481757317e-269, 3.2670891426006735363e-285, 2.4084160842482777461e-301, + 5.2084434157824127104e-253, 2.1511502957481757317e-269, 3.2670891426006735363e-285, 2.4084160842482777461e-301, + 2.4805108027747776379e-253, 2.1511502957481757317e-269, 3.2670891426006735363e-285, 2.4084160842482777461e-301, + 1.1165444962709601017e-253, 2.1511502957481757317e-269, 3.2670891426006735363e-285, 2.4084160842482777461e-301, + 4.3456134301905148502e-254, 6.3684349745470443788e-270, -9.5347405022956030541e-287, -1.5805886663557401565e-302, + 9.3569766393097138822e-255, 2.5826679788133653036e-270, -9.5347405022956030541e-287, -1.5805886663557401565e-302, + 9.3569766393097138822e-255, 2.5826679788133653036e-270, -9.5347405022956030541e-287, -1.5805886663557401565e-302, + 8.3218722366085688343e-256, -2.0046830753539152442e-272, -3.4057806738724185961e-288, 2.3458177946667328156e-304, + 8.3218722366085688343e-256, -2.0046830753539152442e-272, -3.4057806738724185961e-288, 2.3458177946667328156e-304, + 8.3218722366085688343e-256, -2.0046830753539152442e-272, -3.4057806738724185961e-288, 2.3458177946667328156e-304, + 8.3218722366085688343e-256, -2.0046830753539152442e-272, -3.4057806738724185961e-288, 2.3458177946667328156e-304, + 2.9938788518280315834e-256, -2.0046830753539152442e-272, -3.4057806738724185961e-288, 2.3458177946667328156e-304, + 3.2988215943776273615e-257, 2.1353977370878701046e-273, -1.2215123283371736879e-289, 6.7342163555358599277e-306, + 3.2988215943776273615e-257, 2.1353977370878701046e-273, -1.2215123283371736879e-289, 6.7342163555358599277e-306, + 3.2988215943776273615e-257, 2.1353977370878701046e-273, -1.2215123283371736879e-289, 6.7342163555358599277e-306, + 3.2988215943776273615e-257, 2.1353977370878701046e-273, -1.2215123283371736879e-289, 6.7342163555358599277e-306, + 1.6338236616337094706e-257, 2.1353977370878701046e-273, -1.2215123283371736879e-289, 6.7342163555358599277e-306, + 8.0132469526175071002e-258, 2.8687869620228451614e-274, -1.9537812801257956865e-290, 1.0380272777574237546e-306, + 3.850752120757712373e-258, 2.8687869620228451614e-274, -1.9537812801257956865e-290, 1.0380272777574237546e-306, + 1.7695047048278150093e-258, 2.8687869620228451614e-274, -1.9537812801257956865e-290, 1.0380272777574237546e-306, + 7.2888099686286655858e-259, 5.581381609158630475e-275, 6.1155422068568946933e-291, 1.0380272777574237546e-306, + 2.0856914288039227544e-259, -1.9524039360882352712e-276, -2.9779654517181712829e-292, -3.000817432603284506e-308, + 2.0856914288039227544e-259, -1.9524039360882352712e-276, -2.9779654517181712829e-292, -3.000817432603284506e-308, + 7.8491179384773690214e-260, -1.9524039360882352712e-276, -2.9779654517181712829e-292, -3.000817432603284506e-308, + 1.345219763696439399e-260, 1.6579848156414234801e-276, 1.0303712682997738281e-292, 1.4493302844111182601e-308, + 1.345219763696439399e-260, 1.6579848156414234801e-276, 1.0303712682997738281e-292, 1.4493302844111182601e-308, + 1.345219763696439399e-260, 1.6579848156414234801e-276, 1.0303712682997738281e-292, 1.4493302844111182601e-308, + 5.3223249184882342185e-261, -1.472095602234059958e-277, 2.8287088295287585094e-294, -1.0874435234232647519e-310, + 1.2573885592501529789e-261, 3.0408903374280139822e-277, 2.8287088295287585094e-294, -1.0874435234232647519e-310, + 1.2573885592501529789e-261, 3.0408903374280139822e-277, 2.8287088295287585094e-294, -1.0874435234232647519e-310, + 2.4115446944063306384e-262, 2.202741251392177696e-278, 2.8287088295287585094e-294, -1.0874435234232647519e-310, + 2.4115446944063306384e-262, 2.202741251392177696e-278, 2.8287088295287585094e-294, -1.0874435234232647519e-310, + 2.4115446944063306384e-262, 2.202741251392177696e-278, 2.8287088295287585094e-294, -1.0874435234232647519e-310, + 1.1412520821444306741e-262, -6.1787496089661820348e-279, -3.028042329852615431e-295, -2.182740474438892116e-311, + 5.0610577601348040988e-263, 7.9243314524777990283e-279, -3.028042329852615431e-295, -2.182740474438892116e-311, + 1.8853262294800541881e-263, 8.7279092175580810531e-280, 8.8634899828990930877e-296, -9.8167844904532653004e-314, + 2.9746046415267896827e-264, -8.6516445844406224413e-282, -5.0528699238150265939e-299, -1.3288013265921760399e-314, + 2.9746046415267896827e-264, -8.6516445844406224413e-282, -5.0528699238150265939e-299, -1.3288013265921760399e-314, + 2.9746046415267896827e-264, -8.6516445844406224413e-282, -5.0528699238150265939e-299, -1.3288013265921760399e-314, + 9.8977243486757054781e-265, -8.6516445844406224413e-282, -5.0528699238150265939e-299, -1.3288013265921760399e-314, + 9.8977243486757054781e-265, -8.6516445844406224413e-282, -5.0528699238150265939e-299, -1.3288013265921760399e-314, + 4.9356438320276576408e-265, -8.6516445844406224413e-282, -5.0528699238150265939e-299, -1.3288013265921760399e-314, + 2.4546035737036337221e-265, -8.6516445844406224413e-282, -5.0528699238150265939e-299, -1.3288013265921760399e-314, + 1.2140834445416214873e-265, 1.8893435613692150014e-281, 3.0075895258731974416e-297, -9.8167844904532653004e-314, + 5.9382337996061564537e-266, 5.1208955146257653156e-282, -5.0528699238150265939e-299, -1.3288013265921760399e-314, + 2.8369334767011265554e-266, 5.1208955146257653156e-282, -5.0528699238150265939e-299, -1.3288013265921760399e-314, + 1.2862833152486119506e-266, 1.6777604898591683764e-282, -5.0528699238150265939e-299, -1.3288013265921760399e-314, + 5.1095823452235464813e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, -2.5539572388808429997e-317, + 1.2329569415922591084e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, -2.5539572388808429997e-317, + 1.2329569415922591084e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, -2.5539572388808429997e-317, + 2.638005906844371576e-268, 6.3790946999826013345e-284, -2.7456019707854725967e-300, -2.5539572388808429997e-317, + 2.638005906844371576e-268, 6.3790946999826013345e-284, -2.7456019707854725967e-300, -2.5539572388808429997e-317, + 2.1511502957481757317e-269, 3.2670891426006735363e-285, 2.4084160842482773317e-301, 5.7350888195772519812e-317, + 2.1511502957481757317e-269, 3.2670891426006735363e-285, 2.4084160842482773317e-301, 5.7350888195772519812e-317, + 2.1511502957481757317e-269, 3.2670891426006735363e-285, 2.4084160842482773317e-301, 5.7350888195772519812e-317, + 2.1511502957481757317e-269, 3.2670891426006735363e-285, 2.4084160842482773317e-301, 5.7350888195772519812e-317, + 6.3684349745470443788e-270, -9.5347405022956030541e-287, -1.5805886663557401565e-302, 3.6369654387311681856e-319, + 6.3684349745470443788e-270, -9.5347405022956030541e-287, -1.5805886663557401565e-302, 3.6369654387311681856e-319, + 2.5826679788133653036e-270, -9.5347405022956030541e-287, -1.5805886663557401565e-302, 3.6369654387311681856e-319, + 6.8978448094652555593e-271, 1.1480487920352081009e-286, 7.5257037990230704094e-303, 3.6369654387311681856e-319, + 6.8978448094652555593e-271, 1.1480487920352081009e-286, 7.5257037990230704094e-303, 3.6369654387311681856e-319, + 2.1656360647981577662e-271, 9.7287370902823839435e-288, 1.6928061833779524157e-303, 3.6369654387311681856e-319, + 2.1656360647981577662e-271, 9.7287370902823839435e-288, 1.6928061833779524157e-303, 3.6369654387311681856e-319, + 9.825838786313830552e-272, 9.7287370902823839435e-288, 1.6928061833779524157e-303, 3.6369654387311681856e-319, + 3.9105778554799569972e-272, 9.7287370902823839435e-288, 1.6928061833779524157e-303, 3.6369654387311681856e-319, + 9.5294739006302120482e-273, -1.2215123283371736879e-289, 6.7342163555358599277e-306, -5.681754927174335258e-322, + 9.5294739006302120482e-273, -1.2215123283371736879e-289, 6.7342163555358599277e-306, -5.681754927174335258e-322, + 2.1353977370878701046e-273, -1.2215123283371736879e-289, 6.7342163555358599277e-306, -5.681754927174335258e-322, + 2.1353977370878701046e-273, -1.2215123283371736879e-289, 6.7342163555358599277e-306, -5.681754927174335258e-322, + 2.8687869620228451614e-274, -1.9537812801257956865e-290, 1.0380272777574237546e-306, 6.4228533959362050743e-323, +}; + +__device__ const float Sleef_rempitabsp[] = { + 0.159154892, 5.112411827e-08, 3.626141271e-15, -2.036222915e-22, + 0.03415493667, 6.420638243e-09, 7.342738037e-17, 8.135951656e-24, + 0.03415493667, 6.420638243e-09, 7.342738037e-17, 8.135951656e-24, + 0.002904943191, -9.861969574e-11, -9.839336547e-18, -1.790215892e-24, + 0.002904943191, -9.861969574e-11, -9.839336547e-18, -1.790215892e-24, + 0.002904943191, -9.861969574e-11, -9.839336547e-18, -1.790215892e-24, + 0.002904943191, -9.861969574e-11, -9.839336547e-18, -1.790215892e-24, + 0.0009518179577, 1.342109202e-10, 1.791623576e-17, 1.518506657e-24, + 0.0009518179577, 1.342109202e-10, 1.791623576e-17, 1.518506657e-24, + 0.0004635368241, 1.779561221e-11, 4.038449606e-18, -1.358546052e-25, + 0.0002193961991, 1.779561221e-11, 4.038449606e-18, -1.358546052e-25, + 9.73258866e-05, 1.779561221e-11, 4.038449606e-18, -1.358546052e-25, + 3.62907449e-05, 3.243700447e-12, 5.690024473e-19, 7.09405479e-26, + 5.773168596e-06, 1.424711477e-12, 1.3532163e-19, 1.92417627e-26, + 5.773168596e-06, 1.424711477e-12, 1.3532163e-19, 1.92417627e-26, + 5.773168596e-06, 1.424711477e-12, 1.3532163e-19, 1.92417627e-26, + 1.958472239e-06, 5.152167755e-13, 1.3532163e-19, 1.92417627e-26, + 5.112411827e-08, 3.626141271e-15, -2.036222915e-22, 6.177847236e-30, + 5.112411827e-08, 3.626141271e-15, -2.036222915e-22, 6.177847236e-30, + 5.112411827e-08, 3.626141271e-15, -2.036222915e-22, 6.177847236e-30, + 5.112411827e-08, 3.626141271e-15, -2.036222915e-22, 6.177847236e-30, + 5.112411827e-08, 3.626141271e-15, -2.036222915e-22, 6.177847236e-30, + 5.112411827e-08, 3.626141271e-15, -2.036222915e-22, 6.177847236e-30, + 2.132179588e-08, 3.626141271e-15, -2.036222915e-22, 6.177847236e-30, + 6.420638243e-09, 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, + 6.420638243e-09, 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, + 2.695347945e-09, 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, + 8.327027956e-10, 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, + 8.327027956e-10, 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, + 3.670415083e-10, 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, + 1.342109202e-10, 1.791623576e-17, 1.518506361e-24, 2.613904e-31, + 1.779561221e-11, 4.038449606e-18, -1.358545683e-25, -3.443243946e-32, + 1.779561221e-11, 4.038449606e-18, -1.358545683e-25, -3.443243946e-32, + 1.779561221e-11, 4.038449606e-18, -1.358545683e-25, -3.443243946e-32, + 3.243700447e-12, 5.690024473e-19, 7.094053557e-26, 1.487136711e-32, + 3.243700447e-12, 5.690024473e-19, 7.094053557e-26, 1.487136711e-32, + 3.243700447e-12, 5.690024473e-19, 7.094053557e-26, 1.487136711e-32, + 1.424711477e-12, 1.3532163e-19, 1.924175961e-26, 2.545416018e-33, + 5.152167755e-13, 1.3532163e-19, 1.924175961e-26, 2.545416018e-33, + 6.046956013e-14, -2.036222915e-22, 6.177846108e-30, 1.082084378e-36, + 6.046956013e-14, -2.036222915e-22, 6.177846108e-30, 1.082084378e-36, + 6.046956013e-14, -2.036222915e-22, 6.177846108e-30, 1.082084378e-36, + 3.626141271e-15, -2.036222915e-22, 6.177846108e-30, 1.082084378e-36, + 3.626141271e-15, -2.036222915e-22, 6.177846108e-30, 1.082084378e-36, + 3.626141271e-15, -2.036222915e-22, 6.177846108e-30, 1.082084378e-36, + 3.626141271e-15, -2.036222915e-22, 6.177846108e-30, 1.082084378e-36, + 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, 6.296048013e-40, + 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, 6.296048013e-40, + 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, 6.296048013e-40, + 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, 6.296048013e-40, + 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, 6.296048013e-40, + 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, 6.296048013e-40, + 1.791623576e-17, 1.518506361e-24, 2.61390353e-31, 4.764937743e-38, + 1.791623576e-17, 1.518506361e-24, 2.61390353e-31, 4.764937743e-38, + 4.038449606e-18, -1.358545683e-25, -3.443243946e-32, 6.296048013e-40, + 4.038449606e-18, -1.358545683e-25, -3.443243946e-32, 6.296048013e-40, + 5.690024473e-19, 7.094053557e-26, 1.487136711e-32, 6.296048013e-40, + 5.690024473e-19, 7.094053557e-26, 1.487136711e-32, 6.296048013e-40, + 5.690024473e-19, 7.094053557e-26, 1.487136711e-32, 6.296048013e-40, + 1.3532163e-19, 1.924175961e-26, 2.545415467e-33, 6.296048013e-40, + 1.3532163e-19, 1.924175961e-26, 2.545415467e-33, 6.296048013e-40, + 2.690143217e-20, -1.452834402e-28, -6.441077673e-36, -1.764234767e-42, + 2.690143217e-20, -1.452834402e-28, -6.441077673e-36, -1.764234767e-42, + 2.690143217e-20, -1.452834402e-28, -6.441077673e-36, -1.764234767e-42, + 1.334890502e-20, -1.452834402e-28, -6.441077673e-36, -1.764234767e-42, + 6.572641438e-21, -1.452834402e-28, -6.441077673e-36, -1.764234767e-42, + 0.05874381959, 1.222115387e-08, 7.693612965e-16, 1.792054435e-22, + 0.02749382704, 4.77057327e-09, 7.693612965e-16, 1.792054435e-22, + 0.01186883077, 1.045283415e-09, 3.252721926e-16, 7.332633139e-23, + 0.00405633077, 1.045283415e-09, 3.252721926e-16, 7.332633139e-23, + 0.000150081818, -2.454155802e-12, 1.161414894e-20, 1.291319272e-27, + 0.000150081818, -2.454155802e-12, 1.161414894e-20, 1.291319272e-27, + 0.000150081818, -2.454155802e-12, 1.161414894e-20, 1.291319272e-27, + 0.000150081818, -2.454155802e-12, 1.161414894e-20, 1.291319272e-27, + 0.000150081818, -2.454155802e-12, 1.161414894e-20, 1.291319272e-27, + 2.801149822e-05, 4.821800945e-12, 8.789757674e-19, 1.208447639e-25, + 2.801149822e-05, 4.821800945e-12, 8.789757674e-19, 1.208447639e-25, + 2.801149822e-05, 4.821800945e-12, 8.789757674e-19, 1.208447639e-25, + 1.275271279e-05, 1.183823005e-12, 1.161414894e-20, 1.291319272e-27, + 5.12331826e-06, 1.183823005e-12, 1.161414894e-20, 1.291319272e-27, + 1.308621904e-06, 2.743283031e-13, 1.161414894e-20, 1.291319272e-27, + 1.308621904e-06, 2.743283031e-13, 1.161414894e-20, 1.291319272e-27, + 3.549478151e-07, 4.695462769e-14, 1.161414894e-20, 1.291319272e-27, + 3.549478151e-07, 4.695462769e-14, 1.161414894e-20, 1.291319272e-27, + 1.165292645e-07, 1.853292503e-14, 4.837885366e-21, 1.291319272e-27, + 1.165292645e-07, 1.853292503e-14, 4.837885366e-21, 1.291319272e-27, + 5.69246339e-08, 4.322073705e-15, 1.449754789e-21, 7.962890365e-29, + 2.712231151e-08, 4.322073705e-15, 1.449754789e-21, 7.962890365e-29, + 1.222115387e-08, 7.693612965e-16, 1.792054182e-22, 2.91418027e-29, + 4.77057327e-09, 7.693612965e-16, 1.792054182e-22, 2.91418027e-29, + 1.045283415e-09, 3.252721926e-16, 7.332632508e-23, 3.898253736e-30, + 1.045283415e-09, 3.252721926e-16, 7.332632508e-23, 3.898253736e-30, + 1.139611461e-10, 1.996093359e-17, 5.344349223e-25, 1.511644828e-31, + 1.139611461e-10, 1.996093359e-17, 5.344349223e-25, 1.511644828e-31, + 1.139611461e-10, 1.996093359e-17, 5.344349223e-25, 1.511644828e-31, + 1.139611461e-10, 1.996093359e-17, 5.344349223e-25, 1.511644828e-31, + 5.575349904e-11, 6.083145782e-18, 5.344349223e-25, 1.511644828e-31, + 2.664967552e-11, -8.557475018e-19, -8.595036458e-26, -2.139883875e-32, + 1.209775682e-11, 2.61369883e-18, 5.344349223e-25, 1.511644828e-31, + 4.821800945e-12, 8.789757674e-19, 1.208447639e-25, 3.253064536e-33, + 1.183823005e-12, 1.161414894e-20, 1.29131908e-27, 1.715766248e-34, + 1.183823005e-12, 1.161414894e-20, 1.29131908e-27, 1.715766248e-34, + 2.743283031e-13, 1.161414894e-20, 1.29131908e-27, 1.715766248e-34, +}; diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/sleefinline_header.h.org b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/sleefinline_header.h.org new file mode 100644 index 00000000000..a2cb471e7f6 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/sleefinline_header.h.org @@ -0,0 +1,1120 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See http://www.boost.org/LICENSE_1_0.txt) + +// This file is generated by SLEEF SLEEF_VERSION_SLEEF + +#ifndef SLEEF_ALWAYS_INLINE +#if defined (__GNUC__) || defined (__clang__) || defined(__INTEL_COMPILER) +#define SLEEF_ALWAYS_INLINE inline __attribute__((always_inline)) +#elif defined(_MSC_VER) +#define SLEEF_ALWAYS_INLINE inline __forceinline +#else +#define SLEEF_ALWAYS_INLINE inline +#endif +#endif + +#ifndef SLEEF_INLINE +#define SLEEF_INLINE static inline +#endif + +#ifndef SLEEF_CONST +#define SLEEF_CONST +#endif + +#if defined(_MSC_VER) && !defined (__clang__) +#pragma fp_contract (off) +#else +#pragma STDC FP_CONTRACT OFF +#endif + +#ifndef SLEEF_FP_ILOGB0 +#define SLEEF_FP_ILOGB0 ((int)0x80000000) +#endif + +#ifndef SLEEF_FP_ILOGBNAN +#define SLEEF_FP_ILOGBNAN ((int)2147483647) +#endif + +#define SLEEFINLINE_SLEEF_SIMD_SLEEF_H_INCLUDED + +#ifndef __SLEEF_REMPITAB__ +#define __SLEEF_REMPITAB__ +static const double Sleef_rempitabdp[] = { + 0.15915494309189531785, 1.7916237278037667488e-17, 2.5454160968749269937e-33, 2.1132476107887107169e-49, + 0.03415494309189533173, 4.0384494702232122736e-18, 1.0046721413651383112e-33, 2.1132476107887107169e-49, + 0.03415494309189533173, 4.0384494702232122736e-18, 1.0046721413651383112e-33, 2.1132476107887107169e-49, + 0.0029049430918953351999, 5.6900251826959904774e-19, 4.1707169171520598517e-35, -2.496415728504571394e-51, + 0.0029049430918953351999, 5.6900251826959904774e-19, 4.1707169171520598517e-35, -2.496415728504571394e-51, + 0.0029049430918953351999, 5.6900251826959904774e-19, 4.1707169171520598517e-35, -2.496415728504571394e-51, + 0.0029049430918953351999, 5.6900251826959904774e-19, 4.1707169171520598517e-35, -2.496415728504571394e-51, + 0.00095181809189533563356, 1.3532164927539732229e-19, -6.4410794381603004826e-36, 1.7634898158762436344e-52, + 0.00095181809189533563356, 1.3532164927539732229e-19, -6.4410794381603004826e-36, 1.7634898158762436344e-52, + 0.00046353684189533574198, 2.6901432026846872871e-20, -4.2254836195018827479e-37, 9.301187206862134399e-54, + 0.00021939621689533574198, 2.6901432026846872871e-20, -4.2254836195018827479e-37, 9.301187206862134399e-54, + 9.7325904395335769087e-05, -2.0362228529073840241e-22, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 3.6290748145335769087e-05, -2.0362228529073840241e-22, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 5.7731700203357690874e-06, -2.0362228529073840241e-22, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 5.7731700203357690874e-06, -2.0362228529073840241e-22, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 5.7731700203357690874e-06, -2.0362228529073840241e-22, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 1.9584727547107690874e-06, -2.0362228529073840241e-22, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 5.1124121898268875627e-08, 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 5.1124121898268875627e-08, 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 5.1124121898268875627e-08, 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 5.1124121898268875627e-08, 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 5.1124121898268875627e-08, 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 5.1124121898268875627e-08, 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369025999e-57, + 2.1321799510573569745e-08, 1.5185066224124613304e-24, 2.6226236120327253511e-40, 2.6283399642369025999e-57, + 6.4206383167259151492e-09, -1.3585460269359374382e-25, -1.3244127270701094468e-41, -2.4695541513869446866e-57, + 6.4206383167259151492e-09, -1.3585460269359374382e-25, -1.3244127270701094468e-41, -2.4695541513869446866e-57, + 2.6953480182640010867e-09, -1.3585460269359374382e-25, -1.3244127270701094468e-41, -2.4695541513869446866e-57, + 8.3270286903304384868e-10, 7.0940550444663151936e-26, 9.7147467687967058732e-42, 7.9392906424978921242e-59, + 8.3270286903304384868e-10, 7.0940550444663151936e-26, 9.7147467687967058732e-42, 7.9392906424978921242e-59, + 3.6704158172530459087e-10, 7.0940550444663151936e-26, 9.7147467687967058732e-42, 7.9392906424978921242e-59, + 1.3421093807143501366e-10, 1.9241762160098927996e-26, 3.9750282589222551507e-42, 7.9392906424978921242e-59, + 1.7795616244500218596e-11, -1.452834466126541428e-28, -1.5869767474823787636e-44, -2.6168913164368963837e-61, + 1.7795616244500218596e-11, -1.452834466126541428e-28, -1.5869767474823787636e-44, -2.6168913164368963837e-61, + 1.7795616244500218596e-11, -1.452834466126541428e-28, -1.5869767474823787636e-44, -2.6168913164368963837e-61, + 3.2437010161333667893e-12, -1.452834466126541428e-28, -1.5869767474823787636e-44, -2.6168913164368963837e-61, + 3.2437010161333667893e-12, -1.452834466126541428e-28, -1.5869767474823787636e-44, -2.6168913164368963837e-61, + 3.2437010161333667893e-12, -1.452834466126541428e-28, -1.5869767474823787636e-44, -2.6168913164368963837e-61, + 1.4247116125875099096e-12, 2.5861333686050385673e-28, 2.8971783383570358633e-44, -2.6168913164368963837e-61, + 5.1521691081458187359e-13, 5.6664945123924856962e-29, 6.5510079543732854985e-45, -2.6168913164368963837e-61, + 6.0469559928117805118e-14, 6.1778471897801070206e-30, 9.4581409707401690366e-46, 4.9461632249367446986e-62, + 6.0469559928117805118e-14, 6.1778471897801070206e-30, 9.4581409707401690366e-46, 4.9461632249367446986e-62, + 6.0469559928117805118e-14, 6.1778471897801070206e-30, 9.4581409707401690366e-46, 4.9461632249367446986e-62, + 3.6261410673097965595e-15, -1.3304005198798645927e-31, -1.7578597149294783985e-47, 8.4432539107728104262e-64, + 3.6261410673097965595e-15, -1.3304005198798645927e-31, -1.7578597149294783985e-47, 8.4432539107728104262e-64, + 3.6261410673097965595e-15, -1.3304005198798645927e-31, -1.7578597149294783985e-47, 8.4432539107728104262e-64, + 3.6261410673097965595e-15, -1.3304005198798645927e-31, -1.7578597149294783985e-47, 8.4432539107728104262e-64, + 7.3427388509295482183e-17, 1.4871367740953237822e-32, -1.1571307704883330232e-48, -6.7249112515659578102e-65, + 7.3427388509295482183e-17, 1.4871367740953237822e-32, -1.1571307704883330232e-48, -6.7249112515659578102e-65, + 7.3427388509295482183e-17, 1.4871367740953237822e-32, -1.1571307704883330232e-48, -6.7249112515659578102e-65, + 7.3427388509295482183e-17, 1.4871367740953237822e-32, -1.1571307704883330232e-48, -6.7249112515659578102e-65, + 7.3427388509295482183e-17, 1.4871367740953237822e-32, -1.1571307704883330232e-48, -6.7249112515659578102e-65, + 7.3427388509295482183e-17, 1.4871367740953237822e-32, -1.1571307704883330232e-48, -6.7249112515659578102e-65, + 1.7916237278037667488e-17, 2.5454160968749269937e-33, 2.1132476107887107169e-49, 8.7154294504188129325e-66, + 1.7916237278037667488e-17, 2.5454160968749269937e-33, 2.1132476107887107169e-49, 8.7154294504188129325e-66, + 4.0384494702232122736e-18, 1.0046721413651383112e-33, 2.1132476107887107169e-49, 8.7154294504188129325e-66, + 4.0384494702232122736e-18, 1.0046721413651383112e-33, 2.1132476107887107169e-49, 8.7154294504188129325e-66, + 5.6900251826959904774e-19, 4.1707169171520598517e-35, -2.4964157285045710972e-51, -1.866653112309982615e-67, + 5.6900251826959904774e-19, 4.1707169171520598517e-35, -2.4964157285045710972e-51, -1.866653112309982615e-67, + 5.6900251826959904774e-19, 4.1707169171520598517e-35, -2.4964157285045710972e-51, -1.866653112309982615e-67, + 1.3532164927539732229e-19, -6.4410794381603004826e-36, 1.7634898158762432635e-52, 3.5887057810247033998e-68, + 1.3532164927539732229e-19, -6.4410794381603004826e-36, 1.7634898158762432635e-52, 3.5887057810247033998e-68, + 2.6901432026846872871e-20, -4.2254836195018827479e-37, 9.3011872068621332399e-54, 1.113250147552460308e-69, + 2.6901432026846872871e-20, -4.2254836195018827479e-37, 9.3011872068621332399e-54, 1.113250147552460308e-69, + 2.6901432026846872871e-20, -4.2254836195018827479e-37, 9.3011872068621332399e-54, 1.113250147552460308e-69, + 1.3348904870778067446e-20, -4.2254836195018827479e-37, 9.3011872068621332399e-54, 1.113250147552460308e-69, + 6.5726412927436632287e-21, 1.0820844071023395684e-36, 1.7634898158762432635e-52, 3.5887057810247033998e-68, + 3.1845095037264626247e-21, 3.2976802257607573031e-37, 9.3011872068621332399e-54, 1.113250147552460308e-69, + 1.4904436092178623228e-21, -4.6390169687056261795e-38, -1.1392999419355048437e-54, -4.587677453735884283e-71, + 6.4341066196356198368e-22, -4.6390169687056261795e-38, -1.1392999419355048437e-54, -4.587677453735884283e-71, + 2.1989418833641172011e-22, 4.7649378378726728402e-38, 9.3011872068621332399e-54, 1.113250147552460308e-69, + 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, + 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, + 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, + 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, + 8.135951522836682362e-24, 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, + 1.5185066224124613304e-24, 2.6226236120327253511e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, + 1.5185066224124613304e-24, 2.6226236120327253511e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, + 1.5185066224124613304e-24, 2.6226236120327253511e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, + 6.9132600985943383921e-25, 7.8591368887290111994e-41, 2.6283399642369020339e-57, 5.3358074162805516304e-73, + 2.7773570358292009361e-25, -1.3244127270701094468e-41, -2.4695541513869446866e-57, -3.2399200798614356002e-74, + 7.0940550444663151936e-26, 9.7147467687967058732e-42, 7.9392906424978921242e-59, 2.9745456030524896742e-75, + 7.0940550444663151936e-26, 9.7147467687967058732e-42, 7.9392906424978921242e-59, 2.9745456030524896742e-75, + 1.9241762160098927996e-26, 3.9750282589222551507e-42, 7.9392906424978921242e-59, 2.9745456030524896742e-75, + 1.9241762160098927996e-26, 3.9750282589222551507e-42, 7.9392906424978921242e-59, 2.9745456030524896742e-75, + 6.317065088957874881e-27, -3.2976062348358281152e-43, -2.6168913164368963837e-61, 3.7036201000008290615e-78, + 6.317065088957874881e-27, -3.2976062348358281152e-43, -2.6168913164368963837e-61, 3.7036201000008290615e-78, + 3.0858908211726098086e-27, 3.8770419025072344914e-43, 7.9392906424978921242e-59, 2.9745456030524896742e-75, + 1.4703036872799779898e-27, 2.8971783383570358633e-44, -2.6168913164368963837e-61, 3.7036201000008290615e-78, + 6.625101203336619011e-28, 2.8971783383570358633e-44, -2.6168913164368963837e-61, 3.7036201000008290615e-78, + 2.5861333686050385673e-28, 2.8971783383570358633e-44, -2.6168913164368963837e-61, 3.7036201000008290615e-78, + 5.6664945123924856962e-29, 6.5510079543732854985e-45, -2.6168913164368963837e-61, 3.7036201000008290615e-78, + 5.6664945123924856962e-29, 6.5510079543732854985e-45, -2.6168913164368963837e-61, 3.7036201000008290615e-78, + 6.1778471897801070206e-30, 9.4581409707401690366e-46, 4.9461632249367446986e-62, 3.7036201000008290615e-78, + 6.1778471897801070206e-30, 9.4581409707401690366e-46, 4.9461632249367446986e-62, 3.7036201000008290615e-78, + 6.1778471897801070206e-30, 9.4581409707401690366e-46, 4.9461632249367446986e-62, 3.7036201000008290615e-78, + 6.1778471897801070206e-30, 9.4581409707401690366e-46, 4.9461632249367446986e-62, 3.7036201000008290615e-78, + 3.0224035688960604996e-30, 2.451648649116083682e-46, 4.9461632249367446986e-62, 3.7036201000008290615e-78, + 1.4446817584540368888e-30, 2.451648649116083682e-46, 4.9461632249367446986e-62, 3.7036201000008290615e-78, + 6.5582085323302525856e-31, 7.0002556871006273225e-47, 1.0567786762735315635e-62, -6.1446417754639313137e-79, + 2.6139040062251944343e-31, -1.7578597149294783985e-47, 8.4432539107728090768e-64, 1.9517662449371102229e-79, + 6.4175174317266470186e-32, 4.3166913557804827486e-48, 8.4432539107728090768e-64, 1.9517662449371102229e-79, + 6.4175174317266470186e-32, 4.3166913557804827486e-48, 8.4432539107728090768e-64, 1.9517662449371102229e-79, + 1.4871367740953237822e-32, -1.1571307704883330232e-48, -6.7249112515659569668e-65, -7.2335760163150273591e-81, + 1.4871367740953237822e-32, -1.1571307704883330232e-48, -6.7249112515659569668e-65, -7.2335760163150273591e-81, + 2.5454160968749269937e-33, 2.1132476107887107169e-49, 8.7154294504188118783e-66, 1.2001823382693912203e-81, + 2.5454160968749269937e-33, 2.1132476107887107169e-49, 8.7154294504188118783e-66, 1.2001823382693912203e-81, + 2.5454160968749269937e-33, 2.1132476107887107169e-49, 8.7154294504188118783e-66, 1.2001823382693912203e-81, + 1.0046721413651383112e-33, 2.1132476107887107169e-49, 8.7154294504188118783e-66, 1.2001823382693912203e-81, + 2.3430016361024414106e-34, 4.0267819632970559834e-50, -7.8013829534098555144e-67, -1.1759240463442418271e-82, + 2.3430016361024414106e-34, 4.0267819632970559834e-50, -7.8013829534098555144e-67, -1.1759240463442418271e-82, + 4.1707169171520598517e-35, -2.4964157285045710972e-51, -1.866653112309982615e-67, 1.4185069655957361252e-83, + 4.1707169171520598517e-35, -2.4964157285045710972e-51, -1.866653112309982615e-67, 1.4185069655957361252e-83, + 4.1707169171520598517e-35, -2.4964157285045710972e-51, -1.866653112309982615e-67, 1.4185069655957361252e-83, + 1.7633044866680145008e-35, 2.8491136916798196016e-51, 4.0680767287898916022e-67, 1.4185069655957361252e-83, + 5.595982714259923599e-36, 1.7634898158762432635e-52, 3.588705781024702988e-68, 5.9489775128085140685e-84, + 5.595982714259923599e-36, 1.7634898158762432635e-52, 3.588705781024702988e-68, 5.9489775128085140685e-84, + 2.5867171761548675786e-36, 1.7634898158762432635e-52, 3.588705781024702988e-68, 5.9489775128085140685e-84, + 1.0820844071023395684e-36, 1.7634898158762432635e-52, 3.588705781024702988e-68, 5.9489775128085140685e-84, + 3.2976802257607573031e-37, 9.3011872068621332399e-54, 1.113250147552460308e-69, 2.9286284920280944778e-86, + 3.2976802257607573031e-37, 9.3011872068621332399e-54, 1.113250147552460308e-69, 2.9286284920280944778e-86, + 1.4168892644450972904e-37, 9.3011872068621332399e-54, 1.113250147552460308e-69, 2.9286284920280944778e-86, + 4.7649378378726728402e-38, 9.3011872068621332399e-54, 1.113250147552460308e-69, 2.9286284920280944778e-86, + 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 6.2960434583523738135e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 2.6226236120327253511e-40, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 7.8591368887290111994e-41, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 7.8591368887290111994e-41, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 3.2673620808294506214e-41, 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.524218473063975309e-90, + 9.7147467687967058732e-42, 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257943935e-91, + 9.7147467687967058732e-42, 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257943935e-91, + 3.9750282589222551507e-42, 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257943935e-91, + 1.1051690039850297894e-42, 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257943935e-91, + 1.1051690039850297894e-42, 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257943935e-91, + 3.8770419025072344914e-43, 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257943935e-91, + 2.8971783383570358633e-44, -2.6168913164368963837e-61, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 2.8971783383570358633e-44, -2.6168913164368963837e-61, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 2.8971783383570358633e-44, -2.6168913164368963837e-61, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 2.8971783383570358633e-44, -2.6168913164368963837e-61, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 6.5510079543732854985e-45, -2.6168913164368963837e-61, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 6.5510079543732854985e-45, -2.6168913164368963837e-61, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 9.4581409707401690366e-46, 4.9461632249367446986e-62, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 9.4581409707401690366e-46, 4.9461632249367446986e-62, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 9.4581409707401690366e-46, 4.9461632249367446986e-62, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 2.451648649116083682e-46, 4.9461632249367446986e-62, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 2.451648649116083682e-46, 4.9461632249367446986e-62, 3.7036201000008285821e-78, 5.6554937751584084315e-94, + 7.0002556871006273225e-47, 1.0567786762735315635e-62, -6.1446417754639301152e-79, -1.5355611056488084652e-94, + 7.0002556871006273225e-47, 1.0567786762735315635e-62, -6.1446417754639301152e-79, -1.5355611056488084652e-94, + 2.6211979860855749482e-47, 8.4432539107728090768e-64, 1.9517662449371099233e-79, 2.62202614552995759e-95, + 4.3166913557804827486e-48, 8.4432539107728090768e-64, 1.9517662449371099233e-79, 2.62202614552995759e-95, + 4.3166913557804827486e-48, 8.4432539107728090768e-64, 1.9517662449371099233e-79, 2.62202614552995759e-95, + 4.3166913557804827486e-48, 8.4432539107728090768e-64, 1.9517662449371099233e-79, 2.62202614552995759e-95, + 1.5797802926460750146e-48, 2.3660905534865399025e-64, -7.2335760163150273591e-81, 2.8738690232659205689e-99, + 2.1132476107887107169e-49, 8.7154294504188118783e-66, 1.2001823382693912203e-81, 2.8738690232659205689e-99, + 2.1132476107887107169e-49, 8.7154294504188118783e-66, 1.2001823382693912203e-81, 2.8738690232659205689e-99, + 2.1132476107887107169e-49, 8.7154294504188118783e-66, 1.2001823382693912203e-81, 2.8738690232659205689e-99, + 4.0267819632970559834e-50, -7.8013829534098555144e-67, -1.1759240463442418271e-82, 2.8738690232659205689e-99, + 4.0267819632970559834e-50, -7.8013829534098555144e-67, -1.1759240463442418271e-82, 2.8738690232659205689e-99, + 4.0267819632970559834e-50, -7.8013829534098555144e-67, -1.1759240463442418271e-82, 2.8738690232659205689e-99, + 1.8885701952232994665e-50, -7.8013829534098555144e-67, -1.1759240463442418271e-82, 2.8738690232659205689e-99, + 8.1946431118642097069e-51, 1.5937536410989638719e-66, 1.459625439463388979e-82, 2.8738690232659205689e-99, + 2.8491136916798196016e-51, 4.0680767287898916022e-67, 1.4185069655957361252e-83, -7.8369062883735917115e-100, + 1.7634898158762432635e-52, 3.588705781024702988e-68, 5.9489775128085131541e-84, 1.0450891972142808004e-99, + 1.7634898158762432635e-52, 3.588705781024702988e-68, 5.9489775128085131541e-84, 1.0450891972142808004e-99, + 1.7634898158762432635e-52, 3.588705781024702988e-68, 5.9489775128085131541e-84, 1.0450891972142808004e-99, + 1.7634898158762432635e-52, 3.588705781024702988e-68, 5.9489775128085131541e-84, 1.0450891972142808004e-99, + 9.3011872068621332399e-54, 1.113250147552460308e-69, 2.9286284920280941206e-86, 2.1132026692048600853e-102, + 9.3011872068621332399e-54, 1.113250147552460308e-69, 2.9286284920280941206e-86, 2.1132026692048600853e-102, + 9.3011872068621332399e-54, 1.113250147552460308e-69, 2.9286284920280941206e-86, 2.1132026692048600853e-102, + 9.3011872068621332399e-54, 1.113250147552460308e-69, 2.9286284920280941206e-86, 2.1132026692048600853e-102, + 9.3011872068621332399e-54, 1.113250147552460308e-69, 2.9286284920280941206e-86, 2.1132026692048600853e-102, + 4.0809436324633147776e-54, -4.587677453735884283e-71, -2.8859500138942368532e-87, -5.6567402911297190423e-103, + 1.470821845263904967e-54, -4.587677453735884283e-71, -2.8859500138942368532e-87, -5.6567402911297190423e-103, + 1.6576095166419998917e-55, 2.6568658093254848067e-71, 5.1571087196495574384e-87, 3.2728487032630537605e-103, + 1.6576095166419998917e-55, 2.6568658093254848067e-71, 5.1571087196495574384e-87, 3.2728487032630537605e-103, + 1.6576095166419998917e-55, 2.6568658093254848067e-71, 5.1571087196495574384e-87, 3.2728487032630537605e-103, + 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.5242184730639744369e-90, 1.145584788913072936e-105, + 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.5242184730639744369e-90, 1.145584788913072936e-105, + 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.5242184730639744369e-90, 1.145584788913072936e-105, + 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.5242184730639744369e-90, 1.145584788913072936e-105, + 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.5242184730639744369e-90, 1.145584788913072936e-105, + 2.6283399642369020339e-57, 5.3358074162805516304e-73, 4.5242184730639744369e-90, 1.145584788913072936e-105, + 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.554706987098633963e-107, + 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.554706987098633963e-107, + 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.554706987098633963e-107, + 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.554706987098633963e-107, + 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.554706987098633963e-107, + 7.9392906424978921242e-59, 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.554706987098633963e-107, + 3.9565608646667614317e-59, 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.554706987098633963e-107, + 1.9651959757511960854e-59, 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.554706987098633963e-107, + 9.6951353129341363331e-60, 7.6368645294831185015e-76, 1.0603435429602168369e-91, 1.0451839188820145747e-108, + 4.7167230906452229674e-60, 7.6368645294831185015e-76, 1.0603435429602168369e-91, 1.0451839188820145747e-108, + 2.2275169795007668372e-60, 2.1097166542226745549e-76, 4.4670685979800101779e-92, 1.0451839188820145747e-108, + 9.8291392392853877215e-61, -6.5385728340754726503e-77, -1.3520652573660833788e-93, -2.3220403312043059402e-109, + 3.6061239614242446325e-61, 7.2792968540756372162e-77, 1.3988851821689310822e-92, 1.0451839188820145747e-108, + 4.9461632249367446986e-62, 3.7036201000008285821e-78, 5.6554937751584084315e-94, -1.9306041120023063932e-110, + 4.9461632249367446986e-62, 3.7036201000008285821e-78, 5.6554937751584084315e-94, -1.9306041120023063932e-110, + 4.9461632249367446986e-62, 3.7036201000008285821e-78, 5.6554937751584084315e-94, -1.9306041120023063932e-110, + 1.0567786762735315635e-62, -6.1446417754639301152e-79, -1.535561105648808199e-94, -1.9306041120023063932e-110, + 1.0567786762735315635e-62, -6.1446417754639301152e-79, -1.535561105648808199e-94, -1.9306041120023063932e-110, + 8.4432539107728090768e-64, 1.9517662449371099233e-79, 2.62202614552995759e-95, 6.5314563001514358328e-112, + 8.4432539107728090768e-64, 1.9517662449371099233e-79, 2.62202614552995759e-95, 6.5314563001514358328e-112, + 8.4432539107728090768e-64, 1.9517662449371099233e-79, 2.62202614552995759e-95, 6.5314563001514358328e-112, + 8.4432539107728090768e-64, 1.9517662449371099233e-79, 2.62202614552995759e-95, 6.5314563001514358328e-112, + 2.3660905534865399025e-64, -7.2335760163150273591e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, + 2.3660905534865399025e-64, -7.2335760163150273591e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, + 8.4679971416497210292e-65, -7.2335760163150273591e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, + 8.7154294504188118783e-66, 1.2001823382693912203e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, + 8.7154294504188118783e-66, 1.2001823382693912203e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, + 8.7154294504188118783e-66, 1.2001823382693912203e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, + 8.7154294504188118783e-66, 1.2001823382693912203e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, + 3.9676455775389135587e-66, 1.459625439463388979e-82, 2.8738690232659205689e-99, 1.8395411057335783574e-115, + 1.5937536410989638719e-66, 1.459625439463388979e-82, 2.8738690232659205689e-99, 1.8395411057335783574e-115, + 4.0680767287898916022e-67, 1.4185069655957361252e-83, -7.8369062883735917115e-100, -1.9081236411894110579e-116, + 4.0680767287898916022e-67, 1.4185069655957361252e-83, -7.8369062883735917115e-100, -1.9081236411894110579e-116, + 1.1007118082399544936e-67, 1.4185069655957361252e-83, -7.8369062883735917115e-100, -1.9081236411894110579e-116, + 1.1007118082399544936e-67, 1.4185069655957361252e-83, -7.8369062883735917115e-100, -1.9081236411894110579e-116, + 3.588705781024702988e-68, 5.9489775128085131541e-84, 1.0450891972142805974e-99, 1.8395411057335783574e-115, + 3.588705781024702988e-68, 5.9489775128085131541e-84, 1.0450891972142805974e-99, 1.8395411057335783574e-115, + 1.7341027056809927069e-68, 1.830931441234090934e-84, 1.3069928418846076386e-100, 3.1677600334418876704e-116, + 8.0680116800913756637e-69, -2.2809159455312046184e-85, -4.0748824503880445403e-101, -6.3915272253158644628e-117, + 3.4315039917320989315e-69, -2.2809159455312046184e-85, -4.0748824503880445403e-101, -6.3915272253158644628e-117, + 1.113250147552460308e-69, 2.9286284920280941206e-86, 2.1132026692048600853e-102, -4.6672632026740766185e-119, + 1.113250147552460308e-69, 2.9286284920280941206e-86, 2.1132026692048600853e-102, -4.6672632026740766185e-119, + 5.3368668650755071652e-70, 2.9286284920280941206e-86, 2.1132026692048600853e-102, -4.6672632026740766185e-119, + 2.4390495598509592076e-70, 2.9286284920280941206e-86, 2.1132026692048600853e-102, -4.6672632026740766185e-119, + 9.901409072386855505e-71, -2.8859500138942368532e-87, -5.6567402911297190423e-103, -4.6672632026740766185e-119, + 2.6568658093254848067e-71, 5.1571087196495574384e-87, 3.2728487032630532648e-103, 5.2465720993401781599e-119, + 2.6568658093254848067e-71, 5.1571087196495574384e-87, 3.2728487032630532648e-103, 5.2465720993401781599e-119, + 8.4572999356014273536e-72, 1.1355793528776598461e-87, 3.2728487032630532648e-103, 5.2465720993401781599e-119, + 8.4572999356014273536e-72, 1.1355793528776598461e-87, 3.2728487032630532648e-103, 5.2465720993401781599e-119, + 3.9294603961880721752e-72, 1.3019701118468578292e-88, -7.5747169634236195447e-105, -2.0152904854894729832e-121, + 1.6655406264813940833e-72, 1.3019701118468578292e-88, -7.5747169634236195447e-105, -2.0152904854894729832e-121, + 5.3358074162805516304e-73, 4.5242184730639744369e-90, 1.1455847889130727424e-105, 1.8573014293598455046e-121, + 5.3358074162805516304e-73, 4.5242184730639744369e-90, 1.1455847889130727424e-105, 1.8573014293598455046e-121, + 2.5059077041472040156e-73, 4.5242184730639744369e-90, 1.1455847889130727424e-105, 1.8573014293598455046e-121, + 1.0909578480805302081e-73, 4.5242184730639744369e-90, 1.1455847889130727424e-105, 1.8573014293598455046e-121, + 3.8348292004719330442e-74, 4.5242184730639744369e-90, 1.1455847889130727424e-105, 1.8573014293598455046e-121, + 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.5547069870986327528e-107, 1.6304246661326865276e-122, + 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.5547069870986327528e-107, 1.6304246661326865276e-122, + 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.5547069870986327528e-107, 1.6304246661326865276e-122, + 2.9745456030524891833e-75, 5.969437008257942845e-91, 5.5547069870986327528e-107, 1.6304246661326865276e-122, + 7.6368645294831185015e-76, 1.0603435429602168369e-91, 1.0451839188820145747e-108, 4.2386081393205242443e-125, + 7.6368645294831185015e-76, 1.0603435429602168369e-91, 1.0451839188820145747e-108, 4.2386081393205242443e-125, + 2.1097166542226745549e-76, 4.4670685979800101779e-92, 1.0451839188820145747e-108, 4.2386081393205242443e-125, + 2.1097166542226745549e-76, 4.4670685979800101779e-92, 1.0451839188820145747e-108, 4.2386081393205242443e-125, + 7.2792968540756372162e-77, 1.3988851821689310822e-92, 1.0451839188820145747e-108, 4.2386081393205242443e-125, + 3.7036201000008285821e-78, 5.6554937751584084315e-94, -1.9306041120023063932e-110, 1.0223371855251472933e-126, + 3.7036201000008285821e-78, 5.6554937751584084315e-94, -1.9306041120023063932e-110, 1.0223371855251472933e-126, + 3.7036201000008285821e-78, 5.6554937751584084315e-94, -1.9306041120023063932e-110, 1.0223371855251472933e-126, + 3.7036201000008285821e-78, 5.6554937751584084315e-94, -1.9306041120023063932e-110, 1.0223371855251472933e-126, + 3.7036201000008285821e-78, 5.6554937751584084315e-94, -1.9306041120023063932e-110, 1.0223371855251472933e-126, + 1.5445779612272179051e-78, 8.6145718795359707834e-95, 7.3062078800278780675e-111, 1.0223371855251472933e-126, + 4.6505689184041232695e-79, 8.6145718795359707834e-95, 7.3062078800278780675e-111, 1.0223371855251472933e-126, + 4.6505689184041232695e-79, 8.6145718795359707834e-95, 7.3062078800278780675e-111, 1.0223371855251472933e-126, + 1.9517662449371099233e-79, 2.62202614552995759e-95, 6.5314563001514349095e-112, 9.9039323746573674262e-128, + 6.0236490820360325022e-80, -3.7424672147304925625e-96, -1.784871512364483542e-112, 6.7095375687163151728e-129, + 6.0236490820360325022e-80, -3.7424672147304925625e-96, -1.784871512364483542e-112, 6.7095375687163151728e-129, + 2.6501457402022643213e-80, 3.7482149527770239293e-96, 6.5314563001514349095e-112, 9.9039323746573674262e-128, + 9.6339406928538097998e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, + 1.2001823382693912203e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, + 1.2001823382693912203e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, + 1.2001823382693912203e-81, 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, + 1.459625439463388979e-82, 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, + 1.459625439463388979e-82, 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, + 1.459625439463388979e-82, 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, + 1.4185069655957361252e-83, -7.8369062883735917115e-100, -1.9081236411894107761e-116, -2.1796760241698337334e-132, + 1.4185069655957361252e-83, -7.8369062883735917115e-100, -1.9081236411894107761e-116, -2.1796760241698337334e-132, + 1.4185069655957361252e-83, -7.8369062883735917115e-100, -1.9081236411894107761e-116, -2.1796760241698337334e-132, + 1.4185069655957361252e-83, -7.8369062883735917115e-100, -1.9081236411894107761e-116, -2.1796760241698337334e-132, + 5.9489775128085131541e-84, 1.0450891972142805974e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, + 1.830931441234090934e-84, 1.3069928418846076386e-100, 3.1677600334418871069e-116, 3.4556869017247800778e-132, + 1.830931441234090934e-84, 1.3069928418846076386e-100, 3.1677600334418871069e-116, 3.4556869017247800778e-132, + 8.0141992334048515034e-85, 1.3069928418846076386e-100, 3.1677600334418871069e-116, 3.4556869017247800778e-132, + 2.8666416439368237283e-85, 1.6400545060233297363e-101, -4.6672632026740766185e-119, -3.755176715260116501e-136, + 2.9286284920280941206e-86, 2.1132026692048600853e-102, -4.6672632026740766185e-119, -3.755176715260116501e-136, + 2.9286284920280941206e-86, 2.1132026692048600853e-102, -4.6672632026740766185e-119, -3.755176715260116501e-136, + 2.9286284920280941206e-86, 2.1132026692048600853e-102, -4.6672632026740766185e-119, -3.755176715260116501e-136, + 2.9286284920280941206e-86, 2.1132026692048600853e-102, -4.6672632026740766185e-119, -3.755176715260116501e-136, + 1.3200167453193350837e-86, 2.1132026692048600853e-102, -4.6672632026740766185e-119, -3.755176715260116501e-136, + 5.1571087196495574384e-87, 3.2728487032630532648e-103, 5.2465720993401781599e-119, -3.755176715260116501e-136, + 1.1355793528776598461e-87, 3.2728487032630532648e-103, 5.2465720993401781599e-119, -3.755176715260116501e-136, + 1.1355793528776598461e-87, 3.2728487032630532648e-103, 5.2465720993401781599e-119, -3.755176715260116501e-136, + 1.3019701118468578292e-88, -7.5747169634236195447e-105, -2.0152904854894725532e-121, -3.1562414818576682143e-137, + 1.3019701118468578292e-88, -7.5747169634236195447e-105, -2.0152904854894725532e-121, -3.1562414818576682143e-137, + 1.3019701118468578292e-88, -7.5747169634236195447e-105, -2.0152904854894725532e-121, -3.1562414818576682143e-137, + 4.5242184730639744369e-90, 1.1455847889130727424e-105, 1.8573014293598452896e-121, 1.1431992269852683481e-137, + 4.5242184730639744369e-90, 1.1455847889130727424e-105, 1.8573014293598452896e-121, 1.1431992269852683481e-137, + 4.5242184730639744369e-90, 1.1455847889130727424e-105, 1.8573014293598452896e-121, 1.1431992269852683481e-137, + 4.5242184730639744369e-90, 1.1455847889130727424e-105, 1.8573014293598452896e-121, 1.1431992269852683481e-137, + 4.5242184730639744369e-90, 1.1455847889130727424e-105, 1.8573014293598452896e-121, 1.1431992269852683481e-137, + 5.969437008257942845e-91, 5.5547069870986327528e-107, 1.6304246661326865276e-122, 6.8339049774534162772e-139, + 5.969437008257942845e-91, 5.5547069870986327528e-107, 1.6304246661326865276e-122, 6.8339049774534162772e-139, + 5.969437008257942845e-91, 5.5547069870986327528e-107, 1.6304246661326865276e-122, 6.8339049774534162772e-139, + 1.0603435429602168369e-91, 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591188256e-141, + 1.0603435429602168369e-91, 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591188256e-141, + 1.0603435429602168369e-91, 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591188256e-141, + 4.4670685979800101779e-92, 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591188256e-141, + 1.3988851821689310822e-92, 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591188256e-141, + 1.3988851821689310822e-92, 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591188256e-141, + 6.3183932821616130831e-93, 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591188256e-141, + 2.4831640123977650651e-93, 1.9359195088038447797e-109, -4.8867691298577234423e-126, -2.0587960670007823264e-142, + 5.6554937751584084315e-94, -1.9306041120023063932e-110, 1.0223371855251471293e-126, 1.2214168761472102282e-142, + 5.6554937751584084315e-94, -1.9306041120023063932e-110, 1.0223371855251471293e-126, 1.2214168761472102282e-142, + 8.6145718795359707834e-95, 7.3062078800278780675e-111, 1.0223371855251471293e-126, 1.2214168761472102282e-142, + 8.6145718795359707834e-95, 7.3062078800278780675e-111, 1.0223371855251471293e-126, 1.2214168761472102282e-142, + 8.6145718795359707834e-95, 7.3062078800278780675e-111, 1.0223371855251471293e-126, 1.2214168761472102282e-142, + 2.62202614552995759e-95, 6.5314563001514349095e-112, 9.9039323746573674262e-128, -8.6629775332868987041e-145, + 2.62202614552995759e-95, 6.5314563001514349095e-112, 9.9039323746573674262e-128, -8.6629775332868987041e-145, + 1.1238897120284541253e-95, 6.5314563001514349095e-112, 9.9039323746573674262e-128, -8.6629775332868987041e-145, + 3.7482149527770239293e-96, 6.5314563001514349095e-112, 9.9039323746573674262e-128, -8.6629775332868987041e-145, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 2.8738690232659205689e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 1.0450891972142805974e-99, 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, + 1.3069928418846076386e-100, 3.1677600334418871069e-116, 3.4556869017247794521e-132, 8.5448727249069983612e-148, + 1.3069928418846076386e-100, 3.1677600334418871069e-116, 3.4556869017247794521e-132, 8.5448727249069983612e-148, + 1.3069928418846076386e-100, 3.1677600334418871069e-116, 3.4556869017247794521e-132, 8.5448727249069983612e-148, + 1.6400545060233297363e-101, -4.6672632026740766185e-119, -3.755176715260116501e-136, 2.1571619860435652883e-152, + 1.6400545060233297363e-101, -4.6672632026740766185e-119, -3.755176715260116501e-136, 2.1571619860435652883e-152, + 1.6400545060233297363e-101, -4.6672632026740766185e-119, -3.755176715260116501e-136, 2.1571619860435652883e-152, + 2.1132026692048600853e-102, -4.6672632026740766185e-119, -3.755176715260116501e-136, 2.1571619860435652883e-152, + 2.1132026692048600853e-102, -4.6672632026740766185e-119, -3.755176715260116501e-136, 2.1571619860435652883e-152, + 2.1132026692048600853e-102, -4.6672632026740766185e-119, -3.755176715260116501e-136, 2.1571619860435652883e-152, + 3.2728487032630532648e-103, 5.2465720993401781599e-119, -3.755176715260116501e-136, 2.1571619860435652883e-152, + 3.2728487032630532648e-103, 5.2465720993401781599e-119, -3.755176715260116501e-136, 2.1571619860435652883e-152, + 3.2728487032630532648e-103, 5.2465720993401781599e-119, -3.755176715260116501e-136, 2.1571619860435652883e-152, + 1.0404514546648604359e-103, 2.896544483330507019e-120, 3.1239284188885823808e-136, 2.1571619860435652883e-152, + 1.0404514546648604359e-103, 2.896544483330507019e-120, 3.1239284188885823808e-136, 2.1571619860435652883e-152, + 4.8235214251531210473e-104, 2.896544483330507019e-120, 3.1239284188885823808e-136, 2.1571619860435652883e-152, + 2.0330248644053793915e-104, 2.896544483330507019e-120, 3.1239284188885823808e-136, 2.1571619860435652883e-152, + 6.3777658403150887343e-105, -2.0152904854894725532e-121, -3.156241481857667737e-137, -7.0684085473731388916e-153, + 6.3777658403150887343e-105, -2.0152904854894725532e-121, -3.156241481857667737e-137, -7.0684085473731388916e-153, + 2.88964513938041089e-105, 5.7298933442091639924e-121, -3.156241481857667737e-137, -7.0684085473731388916e-153, + 1.1455847889130727424e-105, 1.8573014293598452896e-121, 1.1431992269852681095e-137, 2.4782675885631257398e-153, + 2.7355461367940366859e-106, -7.8994528064813712419e-123, -2.0037599452814940222e-138, 9.1598554579059548847e-155, + 2.7355461367940366859e-106, -7.8994528064813712419e-123, -2.0037599452814940222e-138, 9.1598554579059548847e-155, + 5.5547069870986327528e-107, 1.6304246661326865276e-122, 6.8339049774534147855e-139, 9.1598554579059548847e-155, + 5.5547069870986327528e-107, 1.6304246661326865276e-122, 6.8339049774534147855e-139, 9.1598554579059548847e-155, + 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, + 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, + 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, + 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, + 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, + 1.0451839188820145747e-108, 4.2386081393205242443e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, + 1.9359195088038447797e-109, -4.8867691298577234423e-126, -2.0587960670007819622e-142, -2.8326669474241479263e-158, + 1.9359195088038447797e-109, -4.8867691298577234423e-126, -2.0587960670007819622e-142, -2.8326669474241479263e-158, + 1.9359195088038447797e-109, -4.8867691298577234423e-126, -2.0587960670007819622e-142, -2.8326669474241479263e-158, + 8.7142954880180709975e-110, -4.8867691298577234423e-126, -2.0587960670007819622e-142, -2.8326669474241479263e-158, + 3.3918456880078814158e-110, 6.931443500908017045e-126, 1.1062055705591186799e-141, 1.1734404793201255869e-157, + 7.3062078800278780675e-111, 1.0223371855251471293e-126, 1.2214168761472102282e-142, 8.0910098773220312367e-159, + 7.3062078800278780675e-111, 1.0223371855251471293e-126, 1.2214168761472102282e-142, 8.0910098773220312367e-159, + 6.5314563001514349095e-112, 9.9039323746573674262e-128, -8.6629775332868972816e-145, -1.5987060076657616072e-160, + 6.5314563001514349095e-112, 9.9039323746573674262e-128, -8.6629775332868972816e-145, -1.5987060076657616072e-160, + 6.5314563001514349095e-112, 9.9039323746573674262e-128, -8.6629775332868972816e-145, -1.5987060076657616072e-160, + 6.5314563001514349095e-112, 9.9039323746573674262e-128, -8.6629775332868972816e-145, -1.5987060076657616072e-160, + 2.3732923938934761454e-112, 6.7095375687163138915e-129, 1.6963686085056791706e-144, 1.2464251916751375716e-160, + 2.9421044076449630171e-113, 6.7095375687163138915e-129, 1.6963686085056791706e-144, 1.2464251916751375716e-160, + 2.9421044076449630171e-113, 6.7095375687163138915e-129, 1.6963686085056791706e-144, 1.2464251916751375716e-160, + 2.9421044076449630171e-113, 6.7095375687163138915e-129, 1.6963686085056791706e-144, 1.2464251916751375716e-160, + 3.4325196623373878948e-114, 9.3892593260023063019e-130, 9.4702132359198537748e-146, 1.7950099192230045857e-161, + 3.4325196623373878948e-114, 9.3892593260023063019e-130, 9.4702132359198537748e-146, 1.7950099192230045857e-161, + 3.4325196623373878948e-114, 9.3892593260023063019e-130, 9.4702132359198537748e-146, 1.7950099192230045857e-161, + 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, 2.9106774506606945839e-164, + 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, 2.9106774506606945839e-164, + 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, 2.9106774506606945839e-164, + 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, 2.9106774506606945839e-164, + 1.8395411057335783574e-115, -7.8150389500644475446e-132, -3.9681466199873824165e-148, 2.9106774506606945839e-164, + 8.2436437080731844263e-116, 1.4726412753514008951e-131, -3.9681466199873824165e-148, 2.9106774506606945839e-164, + 3.1677600334418871069e-116, 3.4556869017247794521e-132, 8.544872724906996972e-148, 1.6802919634942429241e-163, + 6.2981819612623816536e-117, 6.3800543877747317218e-133, 7.2423563434801054878e-149, 1.1741471776254779927e-164, + 6.2981819612623816536e-117, 6.3800543877747317218e-133, 7.2423563434801054878e-149, 1.1741471776254779927e-164, + 6.2981819612623816536e-117, 6.3800543877747317218e-133, 7.2423563434801054878e-149, 1.1741471776254779927e-164, + 3.1257546646178208289e-117, -6.6414926959353515111e-134, -5.7828074707888119584e-150, -1.2825052715093464343e-165, + 1.5395410162955400644e-117, -6.6414926959353515111e-134, -5.7828074707888119584e-150, -1.2825052715093464343e-165, + 7.4643419213439950602e-118, 1.0969016447485317626e-133, -5.7828074707888119584e-150, -1.2825052715093464343e-165, + 3.4988078005382940294e-118, 2.1637618757749825688e-134, -8.9490928918944555247e-151, -1.9717385086233606481e-166, + 1.5160407401354430737e-118, 2.1637618757749825688e-134, -8.9490928918944555247e-151, -1.9717385086233606481e-166, + 5.2465720993401781599e-119, -3.755176715260116501e-136, 2.1571619860435648643e-152, 6.3257905089784152346e-168, + 2.896544483330507019e-120, 3.1239284188885823808e-136, 2.1571619860435648643e-152, 6.3257905089784152346e-168, + 2.896544483330507019e-120, 3.1239284188885823808e-136, 2.1571619860435648643e-152, 6.3257905089784152346e-168, + 2.896544483330507019e-120, 3.1239284188885823808e-136, 2.1571619860435648643e-152, 6.3257905089784152346e-168, + 2.896544483330507019e-120, 3.1239284188885823808e-136, 2.1571619860435648643e-152, 6.3257905089784152346e-168, + 2.896544483330507019e-120, 3.1239284188885823808e-136, 2.1571619860435648643e-152, 6.3257905089784152346e-168, + 1.3475077173907800538e-120, -3.156241481857667737e-137, -7.0684085473731388916e-153, -3.3573283875161501977e-170, + 5.7298933442091639924e-121, -3.156241481857667737e-137, -7.0684085473731388916e-153, -3.3573283875161501977e-170, + 1.8573014293598452896e-121, 1.1431992269852681095e-137, 2.4782675885631257398e-153, -3.3573283875161501977e-170, + 1.8573014293598452896e-121, 1.1431992269852681095e-137, 2.4782675885631257398e-153, -3.3573283875161501977e-170, + 8.8915345064751572143e-122, 1.1431992269852681095e-137, 2.4782675885631257398e-153, -3.3573283875161501977e-170, + 4.0507946129135104481e-122, 6.8339049774534147855e-139, 9.1598554579059548847e-155, -4.5159745404911825673e-172, + 1.6304246661326865276e-122, 6.8339049774534147855e-139, 9.1598554579059548847e-155, -4.5159745404911825673e-172, + 4.2023969274227456735e-123, 6.8339049774534147855e-139, 9.1598554579059548847e-155, -4.5159745404911825673e-172, + 4.2023969274227456735e-123, 6.8339049774534147855e-139, 9.1598554579059548847e-155, -4.5159745404911825673e-172, + 1.1769344939467164447e-123, 1.1602886988632691941e-140, 3.0307583960570927356e-156, 5.8345524661064369683e-172, + 1.1769344939467164447e-123, 1.1602886988632691941e-140, 3.0307583960570927356e-156, 5.8345524661064369683e-172, + 4.2056888557770896953e-124, 1.1602886988632691941e-140, 3.0307583960570927356e-156, 5.8345524661064369683e-172, + 4.2386081393205242443e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, 1.2381024895275844856e-174, + 4.2386081393205242443e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, 1.2381024895275844856e-174, + 4.2386081393205242443e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, 1.2381024895275844856e-174, + 4.2386081393205242443e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, 1.2381024895275844856e-174, + 1.8749656131673758844e-125, 1.1062055705591186799e-141, 1.1734404793201255869e-157, 1.2381024895275844856e-174, + 6.931443500908017045e-126, 1.1062055705591186799e-141, 1.1734404793201255869e-157, 1.2381024895275844856e-174, + 1.0223371855251471293e-126, 1.2214168761472102282e-142, 8.0910098773220302259e-159, 1.2381024895275844856e-174, + 1.0223371855251471293e-126, 1.2214168761472102282e-142, 8.0910098773220302259e-159, 1.2381024895275844856e-174, + 1.0223371855251471293e-126, 1.2214168761472102282e-142, 8.0910098773220302259e-159, 1.2381024895275844856e-174, + 2.8369889610228834887e-127, 4.0136364036021218058e-143, -1.0134099605688458828e-159, -2.5389576707476506925e-176, + 2.8369889610228834887e-127, 4.0136364036021218058e-143, -1.0134099605688458828e-159, -2.5389576707476506925e-176, + 9.9039323746573674262e-128, -8.6629775332868972816e-145, -1.5987060076657612913e-160, -2.5389576707476506925e-176, + 6.7095375687163138915e-129, 1.6963686085056791706e-144, 1.2464251916751375716e-160, 6.197724948400014906e-177, + 6.7095375687163138915e-129, 1.6963686085056791706e-144, 1.2464251916751375716e-160, 6.197724948400014906e-177, + 6.7095375687163138915e-129, 1.6963686085056791706e-144, 1.2464251916751375716e-160, 6.197724948400014906e-177, + 6.7095375687163138915e-129, 1.6963686085056791706e-144, 1.2464251916751375716e-160, 6.197724948400014906e-177, + 9.3892593260023063019e-130, 9.4702132359198537748e-146, 1.7950099192230045857e-161, -1.6991004655691155518e-177, + 9.3892593260023063019e-130, 9.4702132359198537748e-146, 1.7950099192230045857e-161, -1.6991004655691155518e-177, + 9.3892593260023063019e-130, 9.4702132359198537748e-146, 1.7950099192230045857e-161, -1.6991004655691155518e-177, + 2.175994780857201024e-130, 1.4618808551874518553e-146, 1.6802919634942426156e-163, 2.8330093736631818036e-179, + 2.175994780857201024e-130, 1.4618808551874518553e-146, 1.6802919634942426156e-163, 2.8330093736631818036e-179, + 3.7267864457092460442e-131, 4.6083930759590139305e-147, 1.6802919634942426156e-163, 2.8330093736631818036e-179, + 3.7267864457092460442e-131, 4.6083930759590139305e-147, 1.6802919634942426156e-163, 2.8330093736631818036e-179, + 3.7267864457092460442e-131, 4.6083930759590139305e-147, 1.6802919634942426156e-163, 2.8330093736631818036e-179, + 1.4726412753514008951e-131, -3.9681466199873824165e-148, 2.9106774506606941983e-164, 5.1948630316441296498e-180, + 3.4556869017247794521e-132, 8.544872724906996972e-148, 1.6802919634942426156e-163, 2.8330093736631818036e-179, + 3.4556869017247794521e-132, 8.544872724906996972e-148, 1.6802919634942426156e-163, 2.8330093736631818036e-179, + 6.3800543877747317218e-133, 7.2423563434801054878e-149, 1.1741471776254777999e-164, 1.3389912474795152755e-180, + 6.3800543877747317218e-133, 7.2423563434801054878e-149, 1.1741471776254777999e-164, 1.3389912474795152755e-180, + 6.3800543877747317218e-133, 7.2423563434801054878e-149, 1.1741471776254777999e-164, 1.3389912474795152755e-180, + 2.8579525590905986764e-133, -5.7828074707888119584e-150, -1.2825052715093464343e-165, -1.0696067158221530218e-181, + 1.0969016447485317626e-133, -5.7828074707888119584e-150, -1.2825052715093464343e-165, -1.0696067158221530218e-181, + 2.1637618757749825688e-134, -8.9490928918944555247e-151, -1.9717385086233606481e-166, 1.3535321672928907047e-182, + 2.1637618757749825688e-134, -8.9490928918944555247e-151, -1.9717385086233606481e-166, 1.3535321672928907047e-182, + 2.1637618757749825688e-134, -8.9490928918944555247e-151, -1.9717385086233606481e-166, 1.3535321672928907047e-182, + 1.0631050543111905033e-134, 1.5490398016102376505e-150, 3.4549185946116918017e-166, 1.3535321672928907047e-182, + 5.1277664357929471499e-135, 3.2706525621039604902e-151, 7.4159004299416557678e-167, 1.3535321672928907047e-182, + 2.3761243821334675971e-135, 3.2706525621039604902e-151, 7.4159004299416557678e-167, 1.3535321672928907047e-182, + 1.0003033553037281263e-135, 2.1571619860435648643e-152, 6.3257905089784152346e-168, 3.5607241064750984115e-184, + 3.1239284188885823808e-136, 2.1571619860435648643e-152, 6.3257905089784152346e-168, 3.5607241064750984115e-184, + 3.1239284188885823808e-136, 2.1571619860435648643e-152, 6.3257905089784152346e-168, 3.5607241064750984115e-184, + 1.4041521353514076604e-136, 2.1571619860435648643e-152, 6.3257905089784152346e-168, 3.5607241064750984115e-184, + 5.4426399358282049106e-137, 2.4782675885631257398e-153, -3.3573283875161501977e-170, 3.0568054078295488291e-186, + 1.1431992269852681095e-137, 2.4782675885631257398e-153, -3.3573283875161501977e-170, 3.0568054078295488291e-186, + 1.1431992269852681095e-137, 2.4782675885631257398e-153, -3.3573283875161501977e-170, 3.0568054078295488291e-186, + 6.8339049774534147855e-139, 9.1598554579059548847e-155, -4.5159745404911819927e-172, -4.5870810097328578981e-188, + 6.8339049774534147855e-139, 9.1598554579059548847e-155, -4.5159745404911819927e-172, -4.5870810097328578981e-188, + 6.8339049774534147855e-139, 9.1598554579059548847e-155, -4.5159745404911819927e-172, -4.5870810097328578981e-188, + 6.8339049774534147855e-139, 9.1598554579059548847e-155, -4.5159745404911819927e-172, -4.5870810097328578981e-188, + 1.1602886988632691941e-140, 3.0307583960570927356e-156, 5.8345524661064358191e-172, 6.9043123899963188689e-188, + 1.1602886988632691941e-140, 3.0307583960570927356e-156, 5.8345524661064358191e-172, 6.9043123899963188689e-188, + 1.1602886988632691941e-140, 3.0307583960570927356e-156, 5.8345524661064358191e-172, 6.9043123899963188689e-188, + 1.1602886988632691941e-140, 3.0307583960570927356e-156, 5.8345524661064358191e-172, 6.9043123899963188689e-188, + 1.1602886988632691941e-140, 3.0307583960570927356e-156, 5.8345524661064358191e-172, 6.9043123899963188689e-188, + 1.1602886988632691941e-140, 3.0307583960570927356e-156, 5.8345524661064358191e-172, 6.9043123899963188689e-188, + 1.1062055705591186799e-141, 1.1734404793201255869e-157, 1.2381024895275844856e-174, -8.4789520282639751913e-191, + 1.1062055705591186799e-141, 1.1734404793201255869e-157, 1.2381024895275844856e-174, -8.4789520282639751913e-191, + 1.1062055705591186799e-141, 1.1734404793201255869e-157, 1.2381024895275844856e-174, -8.4789520282639751913e-191, + 1.1062055705591186799e-141, 1.1734404793201255869e-157, 1.2381024895275844856e-174, -8.4789520282639751913e-191, + 4.5016298192952031469e-142, -2.8326669474241479263e-158, 1.2381024895275844856e-174, -8.4789520282639751913e-191, + 1.2214168761472102282e-142, 8.0910098773220302259e-159, 1.2381024895275844856e-174, -8.4789520282639751913e-191, + 1.2214168761472102282e-142, 8.0910098773220302259e-159, 1.2381024895275844856e-174, -8.4789520282639751913e-191, + 4.0136364036021218058e-143, -1.0134099605688458828e-159, -2.5389576707476506925e-176, -6.2404128071707654958e-193, + 4.0136364036021218058e-143, -1.0134099605688458828e-159, -2.5389576707476506925e-176, -6.2404128071707654958e-193, + 1.9635033141346264592e-143, -1.0134099605688458828e-159, -2.5389576707476506925e-176, -6.2404128071707654958e-193, + 9.3843676940087855824e-144, 1.2626949989038732076e-159, 2.2730883653953564668e-175, 2.7431118386590483722e-191, + 4.2590349703400483539e-144, 1.2464251916751375716e-160, 6.1977249484000140293e-177, 1.1294061984896458822e-192, + 1.6963686085056791706e-144, 1.2464251916751375716e-160, 6.1977249484000140293e-177, 1.1294061984896458822e-192, + 4.1503542758849472122e-145, -1.7614040799531193879e-161, -1.6991004655691153326e-177, -1.856794109153959173e-193, + 4.1503542758849472122e-145, -1.7614040799531193879e-161, -1.6991004655691153326e-177, -1.856794109153959173e-193, + 9.4702132359198537748e-146, 1.7950099192230045857e-161, -1.6991004655691153326e-177, -1.856794109153959173e-193, + 9.4702132359198537748e-146, 1.7950099192230045857e-161, -1.6991004655691153326e-177, -1.856794109153959173e-193, + 1.4618808551874518553e-146, 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, + 1.4618808551874518553e-146, 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, + 1.4618808551874518553e-146, 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, + 4.6083930759590139305e-147, 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, + 4.6083930759590139305e-147, 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, + 2.105789206980137775e-147, 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, + 8.544872724906996972e-148, 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, + 2.2883630524598079723e-148, 2.9106774506606941983e-164, 5.1948630316441287936e-180, 9.6685396110091032843e-196, + 2.2883630524598079723e-148, 2.9106774506606941983e-164, 5.1948630316441287936e-180, 9.6685396110091032843e-196, + 7.2423563434801054878e-149, 1.1741471776254777999e-164, 1.3389912474795150614e-180, 1.1067843414450286726e-196, + 7.2423563434801054878e-149, 1.1741471776254777999e-164, 1.3389912474795150614e-180, 1.1067843414450286726e-196, + 3.3320377982006123631e-149, 3.0588204110786950436e-165, 3.7502330143836152136e-181, 3.6564932749519464998e-198, + 1.3768785255608653665e-149, 3.0588204110786950436e-165, 3.7502330143836152136e-181, 3.6564932749519464998e-198, + 3.9929888924099219388e-150, -1.9717385086233606481e-166, 1.3535321672928907047e-182, 3.1205762277848031878e-199, + 3.9929888924099219388e-150, -1.9717385086233606481e-166, 1.3535321672928907047e-182, 3.1205762277848031878e-199, + 1.5490398016102376505e-150, 3.4549185946116918017e-166, 1.3535321672928907047e-182, 3.1205762277848031878e-199, + 3.2706525621039604902e-151, 7.4159004299416557678e-167, 1.3535321672928907047e-182, 3.1205762277848031878e-199, + 3.2706525621039604902e-151, 7.4159004299416557678e-167, 1.3535321672928907047e-182, 3.1205762277848031878e-199, + 2.1571619860435648643e-152, 6.3257905089784152346e-168, 3.5607241064750984115e-184, -1.4832196127821708615e-201, + 2.1571619860435648643e-152, 6.3257905089784152346e-168, 3.5607241064750984115e-184, -1.4832196127821708615e-201, + 2.1571619860435648643e-152, 6.3257905089784152346e-168, 3.5607241064750984115e-184, -1.4832196127821708615e-201, + 2.1571619860435648643e-152, 6.3257905089784152346e-168, 3.5607241064750984115e-184, -1.4832196127821708615e-201, + 2.4782675885631257398e-153, -3.3573283875161501977e-170, 3.0568054078295488291e-186, 1.4980560800565462618e-202, + 2.4782675885631257398e-153, -3.3573283875161501977e-170, 3.0568054078295488291e-186, 1.4980560800565462618e-202, + 2.4782675885631257398e-153, -3.3573283875161501977e-170, 3.0568054078295488291e-186, 1.4980560800565462618e-202, + 9.1598554579059548847e-155, -4.5159745404911819927e-172, -4.5870810097328572602e-188, -3.2905064432040069127e-204, + 9.1598554579059548847e-155, -4.5159745404911819927e-172, -4.5870810097328572602e-188, -3.2905064432040069127e-204, + 9.1598554579059548847e-155, -4.5159745404911819927e-172, -4.5870810097328572602e-188, -3.2905064432040069127e-204, + 9.1598554579059548847e-155, -4.5159745404911819927e-172, -4.5870810097328572602e-188, -3.2905064432040069127e-204, + 9.1598554579059548847e-155, -4.5159745404911819927e-172, -4.5870810097328572602e-188, -3.2905064432040069127e-204, + 1.7015147267057481414e-155, -4.5159745404911819927e-172, -4.5870810097328572602e-188, -3.2905064432040069127e-204, + 1.7015147267057481414e-155, -4.5159745404911819927e-172, -4.5870810097328572602e-188, -3.2905064432040069127e-204, + 1.7015147267057481414e-155, -4.5159745404911819927e-172, -4.5870810097328572602e-188, -3.2905064432040069127e-204, + 7.6922213530572229852e-156, -4.5159745404911819927e-172, -4.5870810097328572602e-188, -3.2905064432040069127e-204, + 3.0307583960570927356e-156, 5.8345524661064358191e-172, 6.9043123899963188689e-188, -3.2905064432040069127e-204, + 7.0002691755702864582e-157, 6.5928896280762691321e-173, 1.1586156901317304854e-188, -1.0100405885278530137e-205, + 7.0002691755702864582e-157, 6.5928896280762691321e-173, 1.1586156901317304854e-188, -1.0100405885278530137e-205, + 1.1734404793201255869e-157, 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.3321093418096261919e-207, + 1.1734404793201255869e-157, 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.3321093418096261919e-207, + 1.1734404793201255869e-157, 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.3321093418096261919e-207, + 4.4508689228885539715e-158, 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.3321093418096261919e-207, + 8.0910098773220302259e-159, 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.3321093418096261919e-207, + 8.0910098773220302259e-159, 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.3321093418096261919e-207, + 8.0910098773220302259e-159, 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.3321093418096261919e-207, + 3.5387999583765925506e-159, 2.2730883653953564668e-175, 2.7431118386590483722e-191, -1.3321093418096261919e-207, + 1.2626949989038732076e-159, 2.2730883653953564668e-175, 2.7431118386590483722e-191, -1.3321093418096261919e-207, + 1.2464251916751375716e-160, 6.1977249484000140293e-177, 1.1294061984896456875e-192, 2.2526486929936882202e-208, + 1.2464251916751375716e-160, 6.1977249484000140293e-177, 1.1294061984896456875e-192, 2.2526486929936882202e-208, + 1.2464251916751375716e-160, 6.1977249484000140293e-177, 1.1294061984896456875e-192, 2.2526486929936882202e-208, + 1.2464251916751375716e-160, 6.1977249484000140293e-177, 1.1294061984896456875e-192, 2.2526486929936882202e-208, + 5.3514239183991277695e-161, 6.1977249484000140293e-177, 1.1294061984896456875e-192, 2.2526486929936882202e-208, + 1.7950099192230045857e-161, -1.6991004655691153326e-177, -1.8567941091539589297e-193, -1.8074851186411640793e-209, + 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, + 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, + 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, + 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, + 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, + 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, + 1.6802919634942426156e-163, 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, + 2.9106774506606941983e-164, 5.1948630316441287936e-180, 9.6685396110091013832e-196, 1.7562785002189357559e-211, + 2.9106774506606941983e-164, 5.1948630316441287936e-180, 9.6685396110091013832e-196, 1.7562785002189357559e-211, + 2.9106774506606941983e-164, 5.1948630316441287936e-180, 9.6685396110091013832e-196, 1.7562785002189357559e-211, + 1.1741471776254777999e-164, 1.3389912474795150614e-180, 1.106784341445028435e-196, 3.3045982549756583552e-212, + 3.0588204110786950436e-165, 3.7502330143836152136e-181, 3.6564932749519464998e-198, 3.7097125405852507464e-214, + 3.0588204110786950436e-165, 3.7502330143836152136e-181, 3.6564932749519464998e-198, 3.7097125405852507464e-214, + 8.8815756978467430465e-166, 1.3403131492807310959e-181, 3.6564932749519464998e-198, 3.7097125405852507464e-214, + 8.8815756978467430465e-166, 1.3403131492807310959e-181, 3.6564932749519464998e-198, 3.7097125405852507464e-214, + 3.4549185946116918017e-166, 1.3535321672928907047e-182, 3.1205762277848031878e-199, -3.3569248349832580936e-217, + 7.4159004299416557678e-167, 1.3535321672928907047e-182, 3.1205762277848031878e-199, -3.3569248349832580936e-217, + 7.4159004299416557678e-167, 1.3535321672928907047e-182, 3.1205762277848031878e-199, -3.3569248349832580936e-217, + 6.3257905089784152346e-168, 3.5607241064750984115e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, + 6.3257905089784152346e-168, 3.5607241064750984115e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, + 6.3257905089784152346e-168, 3.5607241064750984115e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, + 6.3257905089784152346e-168, 3.5607241064750984115e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, + 2.0862146470760309789e-168, -1.146150630053972131e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, + 2.0862146470760309789e-168, -1.146150630053972131e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, + 1.026320681600434562e-168, 1.2072867382105631402e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, + 4.9637369886263658882e-169, 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, + 2.3140020749373754342e-169, 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, + 9.8913461809288020723e-170, 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, + 3.2670088967063259373e-170, 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, + 3.2670088967063259373e-170, 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, + 1.6109245756507072713e-170, -6.2044048008378732802e-187, -5.4322544592823556944e-203, 4.2491789852161138683e-219, + 7.8288241512289757055e-171, 1.2181824638728806485e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, + 3.6886133485899290404e-171, 2.9887099189454666024e-187, 4.774153170641553462e-203, 4.2491789852161138683e-219, + 1.6185079472704052482e-171, 2.9887099189454666024e-187, 4.774153170641553462e-203, 4.2491789852161138683e-219, + 5.8345524661064358191e-172, 6.9043123899963188689e-188, -3.2905064432040069127e-204, -9.1795828160190082842e-224, + 6.5928896280762691321e-173, 1.1586156901317304854e-188, -1.0100405885278530137e-205, -9.1795828160190082842e-224, + 6.5928896280762691321e-173, 1.1586156901317304854e-188, -1.0100405885278530137e-205, -9.1795828160190082842e-224, + 6.5928896280762691321e-173, 1.1586156901317304854e-188, -1.0100405885278530137e-205, -9.1795828160190082842e-224, + 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.332109341809626019e-207, -9.1795828160190082842e-224, + 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.332109341809626019e-207, -9.1795828160190082842e-224, + 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.332109341809626019e-207, -9.1795828160190082842e-224, + 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.332109341809626019e-207, -9.1795828160190082842e-224, + 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.332109341809626019e-207, -9.1795828160190082842e-224, + 1.2381024895275844856e-174, -8.4789520282639751913e-191, -1.332109341809626019e-207, -9.1795828160190082842e-224, + 2.2730883653953564668e-175, 2.7431118386590483722e-191, -1.332109341809626019e-207, -9.1795828160190082842e-224, + 2.2730883653953564668e-175, 2.7431118386590483722e-191, -1.332109341809626019e-207, -9.1795828160190082842e-224, + 2.2730883653953564668e-175, 2.7431118386590483722e-191, -1.332109341809626019e-207, -9.1795828160190082842e-224, + 1.0095962991602958391e-175, -6.2404128071707654958e-193, 3.0593092910744445285e-209, 5.4622616159087170031e-225, + 3.7785026604276538491e-176, -6.2404128071707654958e-193, 3.0593092910744445285e-209, 5.4622616159087170031e-225, + 6.1977249484000140293e-177, 1.1294061984896456875e-192, 2.2526486929936882202e-208, -5.3441928036578162463e-225, + 6.1977249484000140293e-177, 1.1294061984896456875e-192, 2.2526486929936882202e-208, -5.3441928036578162463e-225, + 6.1977249484000140293e-177, 1.1294061984896456875e-192, 2.2526486929936882202e-208, -5.3441928036578162463e-225, + 2.2493122414154495675e-177, 2.5268245888628466632e-193, 3.0593092910744445285e-209, 5.4622616159087170031e-225, + 2.7510588792316711745e-178, 3.3501523985444386676e-194, 6.2591208621664049475e-210, 5.9034406125450500218e-227, + 2.7510588792316711745e-178, 3.3501523985444386676e-194, 6.2591208621664049475e-210, 5.9034406125450500218e-227, + 2.7510588792316711745e-178, 3.3501523985444386676e-194, 6.2591208621664049475e-210, 5.9034406125450500218e-227, + 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, 9.9192633285681635836e-229, + 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, 9.9192633285681635836e-229, + 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, 9.9192633285681635836e-229, + 2.8330093736631818036e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, 9.9192633285681635836e-229, + 1.2906606599973359683e-179, -7.4549709281190454638e-196, -1.4481306607622412036e-212, 9.9192633285681635836e-229, + 5.1948630316441287936e-180, 9.6685396110091013832e-196, 1.7562785002189355449e-211, 1.6821693549018732055e-227, + 1.3389912474795150614e-180, 1.106784341445028435e-196, 3.3045982549756578275e-212, 6.2685154049107876715e-228, + 1.3389912474795150614e-180, 1.106784341445028435e-196, 3.3045982549756578275e-212, 6.2685154049107876715e-228, + 3.7502330143836152136e-181, 3.6564932749519464998e-198, 3.7097125405852507464e-214, 2.5658818466966882188e-231, + 3.7502330143836152136e-181, 3.6564932749519464998e-198, 3.7097125405852507464e-214, 2.5658818466966882188e-231, + 1.3403131492807310959e-181, 3.6564932749519464998e-198, 3.7097125405852507464e-214, 2.5658818466966882188e-231, + 1.3535321672928907047e-182, 3.1205762277848031878e-199, -3.3569248349832580936e-217, -1.0577661142165146927e-233, + 1.3535321672928907047e-182, 3.1205762277848031878e-199, -3.3569248349832580936e-217, -1.0577661142165146927e-233, + 1.3535321672928907047e-182, 3.1205762277848031878e-199, -3.3569248349832580936e-217, -1.0577661142165146927e-233, + 1.3535321672928907047e-182, 3.1205762277848031878e-199, -3.3569248349832580936e-217, -1.0577661142165146927e-233, + 6.0043220944823941786e-183, 3.1205762277848031878e-199, -3.3569248349832580936e-217, -1.0577661142165146927e-233, + 2.2388223052591377446e-183, 3.1205762277848031878e-199, -3.3569248349832580936e-217, -1.0577661142165146927e-233, + 3.5607241064750984115e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 3.5607241064750984115e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 3.5607241064750984115e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 1.2072867382105631402e-184, -1.4832196127821708615e-201, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 3.0568054078295488291e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 1.2181824638728806485e-186, 1.4980560800565460352e-202, 2.6911956484118910092e-218, -5.1336618966962585332e-235, + 2.9887099189454666024e-187, 4.774153170641553462e-203, 4.2491789852161132393e-219, 7.4467067939231424594e-235, + 2.9887099189454666024e-187, 4.774153170641553462e-203, 4.2491789852161132393e-219, 7.4467067939231424594e-235, + 6.9043123899963188689e-188, -3.2905064432040069127e-204, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 6.9043123899963188689e-188, -3.2905064432040069127e-204, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 1.1586156901317304854e-188, -1.0100405885278530137e-205, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 1.1586156901317304854e-188, -1.0100405885278530137e-205, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 1.1586156901317304854e-188, -1.0100405885278530137e-205, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 4.4040360264865697732e-189, -1.0100405885278530137e-205, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 8.129755890712020335e-190, 9.8339840169166049336e-206, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 8.129755890712020335e-190, 9.8339840169166049336e-206, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 8.129755890712020335e-190, 9.8339840169166049336e-206, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 3.6409303439428119063e-190, -1.332109341809626019e-207, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 1.3965175705582071936e-190, -1.332109341809626019e-207, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 2.7431118386590483722e-191, -1.332109341809626019e-207, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 2.7431118386590483722e-191, -1.332109341809626019e-207, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 2.7431118386590483722e-191, -1.332109341809626019e-207, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 1.3403538552936701153e-191, 1.7826390804083638359e-207, -9.1795828160190063645e-224, -2.3569545504732004486e-239, + 6.389748636109812983e-192, 2.2526486929936882202e-208, -5.3441928036578156465e-225, -7.741539335184153052e-241, + 2.8828536776963681193e-192, 2.2526486929936882202e-208, -5.3441928036578156465e-225, -7.741539335184153052e-241, + 1.1294061984896456875e-192, 2.2526486929936882202e-208, -5.3441928036578156465e-225, -7.741539335184153052e-241, + 2.5268245888628466632e-193, 3.0593092910744445285e-209, 5.4622616159087170031e-225, 4.2560351759808952526e-241, + 2.5268245888628466632e-193, 3.0593092910744445285e-209, 5.4622616159087170031e-225, 4.2560351759808952526e-241, + 3.3501523985444386676e-194, 6.2591208621664049475e-210, 5.9034406125450490845e-227, 1.3186893776791012681e-242, + 3.3501523985444386676e-194, 6.2591208621664049475e-210, 5.9034406125450490845e-227, 1.3186893776791012681e-242, + 3.3501523985444386676e-194, 6.2591208621664049475e-210, 5.9034406125450490845e-227, 1.3186893776791012681e-242, + 6.1039071228393547627e-195, 1.7562785002189355449e-211, 1.6821693549018732055e-227, -8.7276385348052817035e-244, + 6.1039071228393547627e-195, 1.7562785002189355449e-211, 1.6821693549018732055e-227, -8.7276385348052817035e-244, + 6.1039071228393547627e-195, 1.7562785002189355449e-211, 1.6821693549018732055e-227, -8.7276385348052817035e-244, + 2.6792050150137250131e-195, 1.7562785002189355449e-211, 1.6821693549018732055e-227, -8.7276385348052817035e-244, + 9.6685396110091013832e-196, 1.7562785002189355449e-211, 1.6821693549018732055e-227, -8.7276385348052817035e-244, + 2.0416567491425607157e-177, 6.0959078275963141821e-193, 1.156336993964950812e-208, 2.7126166236326293347e-224, + 2.0416567491425607157e-177, 6.0959078275963141821e-193, 1.156336993964950812e-208, 2.7126166236326293347e-224, + 2.0416567491425607157e-177, 6.0959078275963141821e-193, 1.156336993964950812e-208, 2.7126166236326293347e-224, + 6.7450395650278649168e-179, 6.8432117823206978686e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, + 6.7450395650278649168e-179, 6.8432117823206978686e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, + 6.7450395650278649168e-179, 6.8432117823206978686e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, + 6.7450395650278649168e-179, 6.8432117823206978686e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, + 6.7450395650278649168e-179, 6.8432117823206978686e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, + 5.756447103644822603e-180, -6.1924333305615830735e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 5.756447103644822603e-180, -6.1924333305615830735e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 5.756447103644822603e-180, -6.1924333305615830735e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 5.756447103644822603e-180, -6.1924333305615830735e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 1.9005753194802080146e-180, -6.1924333305615830735e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 1.9005753194802080146e-180, -6.1924333305615830735e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 9.3660737343905436753e-181, -6.1924333305615830735e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 4.5462340041847754398e-181, -6.1924333305615830735e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 2.1363141390818913221e-181, -6.1924333305615830735e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 9.3135420653044926323e-182, -6.1924333305615830735e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 3.2887424025472810002e-182, 7.185309278132283136e-198, -1.9512340798794268979e-214, -3.6162764918921697356e-230, + 2.7634257116867652192e-183, 4.9643797378534984559e-199, -9.4699347169310243473e-216, -9.2331809177749095611e-233, + 2.7634257116867652192e-183, 4.9643797378534984559e-199, -9.4699347169310243473e-216, -9.2331809177749095611e-233, + 2.7634257116867652192e-183, 4.9643797378534984559e-199, -9.4699347169310243473e-216, -9.2331809177749095611e-233, + 2.7634257116867652192e-183, 4.9643797378534984559e-199, -9.4699347169310243473e-216, -9.2331809177749095611e-233, + 8.806758170751374203e-184, 7.8383517263666503337e-200, 1.3736749441945438342e-215, -9.2331809177749095611e-233, + 8.806758170751374203e-184, 7.8383517263666503337e-200, 1.3736749441945438342e-215, -9.2331809177749095611e-233, + 4.0998834342223036605e-184, 7.8383517263666503337e-200, 1.3736749441945438342e-215, -9.2331809177749095611e-233, + 1.7464460659577689118e-184, 2.612671019845610006e-200, 2.1334073625072069974e-216, -9.2331809177749095611e-233, + 5.697273818255015375e-185, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 5.697273818255015375e-185, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 2.755477107924346286e-185, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 1.2845787527590117414e-185, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 5.4912957517634446918e-186, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 1.8140498638501083305e-186, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 1.8140498638501083305e-186, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 8.9473839187177424013e-187, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 4.3508265588260719497e-187, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 2.0525478788802367239e-187, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 9.0340853890731911095e-188, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 3.288388689208603045e-188, -1.6933341491052464293e-204, -4.3478137385944270631e-220, -2.3353910329236990725e-236, + 4.1554033927630885323e-189, -9.8582956929636044137e-206, -1.4280619485269765742e-221, 1.2171222696290252021e-237, + 4.1554033927630885323e-189, -9.8582956929636044137e-206, -1.4280619485269765742e-221, 1.2171222696290252021e-237, + 4.1554033927630885323e-189, -9.8582956929636044137e-206, -1.4280619485269765742e-221, 1.2171222696290252021e-237, + 5.643429553477207926e-190, 1.0076094209231528444e-205, 7.8509991660024955813e-222, 1.2171222696290252021e-237, + 5.643429553477207926e-190, 1.0076094209231528444e-205, 7.8509991660024955813e-222, 1.2171222696290252021e-237, + 5.643429553477207926e-190, 1.0076094209231528444e-205, 7.8509991660024955813e-222, 1.2171222696290252021e-237, + 1.1546040067079994973e-190, 1.0889925813396166947e-207, 2.4325525462765697993e-223, -1.1429360314275701698e-239, + 1.1546040067079994973e-190, 1.0889925813396166947e-207, 2.4325525462765697993e-223, -1.1429360314275701698e-239, + 3.2397620015697148712e-192, 3.1030547578511949035e-208, -1.609965144193984205e-224, -1.8313007053436627876e-240, + 3.2397620015697148712e-192, 3.1030547578511949035e-208, -1.609965144193984205e-224, -1.8313007053436627876e-240, + 3.2397620015697148712e-192, 3.1030547578511949035e-208, -1.609965144193984205e-224, -1.8313007053436627876e-240, + 3.2397620015697148712e-192, 3.1030547578511949035e-208, -1.609965144193984205e-224, -1.8313007053436627876e-240, + 3.2397620015697148712e-192, 3.1030547578511949035e-208, -1.609965144193984205e-224, -1.8313007053436627876e-240, + 3.2397620015697148712e-192, 3.1030547578511949035e-208, -1.609965144193984205e-224, -1.8313007053436627876e-240, + 1.4863145223629928288e-192, -7.9038076992129241506e-209, -1.609965144193984205e-224, -1.8313007053436627876e-240, + 6.0959078275963141821e-193, 1.156336993964950812e-208, 2.7126166236326293347e-224, -1.8313007053436627876e-240, + 1.712289129579509076e-193, 1.8297811202182925249e-209, 1.1003018740995688645e-226, 5.827891678485165325e-243, + 1.712289129579509076e-193, 1.8297811202182925249e-209, 1.1003018740995688645e-226, 5.827891678485165325e-243, + 6.1638445507530779946e-194, -6.0361608463951204924e-210, 1.1003018740995688645e-226, 5.827891678485165325e-243, + 6.8432117823206978686e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.029900079464340522e-245, + 6.8432117823206978686e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.029900079464340522e-245, + 6.8432117823206978686e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.029900079464340522e-245, + 6.8432117823206978686e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.029900079464340522e-245, + 3.418509674495068119e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.029900079464340522e-245, + 1.7061586205822532442e-195, 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.029900079464340522e-245, + 8.499830936258458068e-196, 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.029900079464340522e-245, + 4.218953301476420881e-196, 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.029900079464340522e-245, + 2.0785144840854027628e-196, -1.9512340798794268979e-214, -3.6162764918921692779e-230, -2.8387319855193022476e-246, + 1.008295075389893466e-196, -1.9512340798794268979e-214, -3.6162764918921692779e-230, -2.8387319855193022476e-246, + 4.7318537104213881764e-197, -1.9512340798794268979e-214, -3.6162764918921692779e-230, -2.8387319855193022476e-246, + 2.0563051886826149345e-197, -1.9512340798794268979e-214, -3.6162764918921692779e-230, -2.8387319855193022476e-246, + 7.185309278132283136e-198, -1.9512340798794268979e-214, -3.6162764918921692779e-230, -2.8387319855193022476e-246, + 4.9643797378534984559e-199, -9.4699347169310243473e-216, -9.2331809177749077733e-233, -1.4042876247421728101e-248, + 4.9643797378534984559e-199, -9.4699347169310243473e-216, -9.2331809177749077733e-233, -1.4042876247421728101e-248, + 4.9643797378534984559e-199, -9.4699347169310243473e-216, -9.2331809177749077733e-233, -1.4042876247421728101e-248, + 4.9643797378534984559e-199, -9.4699347169310243473e-216, -9.2331809177749077733e-233, -1.4042876247421728101e-248, + 7.8383517263666503337e-200, 1.3736749441945438342e-215, -9.2331809177749077733e-233, -1.4042876247421728101e-248, + 7.8383517263666503337e-200, 1.3736749441945438342e-215, -9.2331809177749077733e-233, -1.4042876247421728101e-248, + 7.8383517263666503337e-200, 1.3736749441945438342e-215, -9.2331809177749077733e-233, -1.4042876247421728101e-248, + 2.612671019845610006e-200, 2.1334073625072069974e-216, -9.2331809177749077733e-233, -1.4042876247421728101e-248, + 2.612671019845610006e-200, 2.1334073625072069974e-216, -9.2331809177749077733e-233, -1.4042876247421728101e-248, + 1.306250843215349634e-200, 2.1334073625072069974e-216, -9.2331809177749077733e-233, -1.4042876247421728101e-248, + 6.5304075490021959302e-201, 6.8298960257742791824e-217, 6.8696910062179237095e-233, 3.8349029251851101018e-249, + 3.2643571074265457254e-201, -4.2219277387461470355e-218, -1.753154605289404553e-234, -7.5861268822635538093e-251, + 1.6313318866387202604e-201, -4.2219277387461470355e-218, -1.753154605289404553e-234, -7.5861268822635538093e-251, + 8.1481927624480752786e-202, -4.2219277387461470355e-218, -1.753154605289404553e-234, -7.5861268822635538093e-251, + 4.0656297104785107096e-202, 4.8431832608149701961e-218, 8.3111403472061145651e-234, 1.6001805286092554504e-249, + 2.0243481844937293316e-202, 3.1062776103441183191e-219, 7.6291913283447536617e-235, 2.0347903074934629333e-250, + 1.0037074215013384159e-202, 3.1062776103441183191e-219, 7.6291913283447536617e-235, 2.0347903074934629333e-250, + 4.9338704000514295811e-203, 3.1062776103441183191e-219, 7.6291913283447536617e-235, 2.0347903074934629333e-250, + 2.3822684925704522921e-203, 3.1062776103441183191e-219, 7.6291913283447536617e-235, 2.0347903074934629333e-250, + 1.1064675388299639308e-203, 2.7343042298126957741e-220, 5.5273393987134252385e-236, 1.1432574793608782288e-251, + 4.6856706195971960852e-204, 2.7343042298126957741e-220, 5.5273393987134252385e-236, 1.1432574793608782288e-251, + 1.4961682352459748279e-204, -8.0675475439086544798e-221, -3.6970842501441777651e-237, -5.7032870362481275794e-253, + 1.4961682352459748279e-204, -8.0675475439086544798e-221, -3.6970842501441777651e-237, -5.7032870362481275794e-253, + 6.9879263915816924805e-205, 9.6377473771091526132e-221, 1.5959741828948633012e-236, 2.7031904319843495713e-252, + 3.0010484111426663515e-205, 7.8509991660024955813e-222, 1.2171222696290252021e-237, -2.4742181023285720738e-254, + 1.0076094209231528444e-205, 7.8509991660024955813e-222, 1.2171222696290252021e-237, -2.4742181023285720738e-254, + 1.0889925813396166947e-207, 2.4325525462765697993e-223, -1.1429360314275701698e-239, 8.3218722366085688343e-256, + 1.0889925813396166947e-207, 2.4325525462765697993e-223, -1.1429360314275701698e-239, 8.3218722366085688343e-256, + 1.0889925813396166947e-207, 2.4325525462765697993e-223, -1.1429360314275701698e-239, 8.3218722366085688343e-256, + 1.0889925813396166947e-207, 2.4325525462765697993e-223, -1.1429360314275701698e-239, 8.3218722366085688343e-256, + 1.0889925813396166947e-207, 2.4325525462765697993e-223, -1.1429360314275701698e-239, 8.3218722366085688343e-256, + 1.0889925813396166947e-207, 2.4325525462765697993e-223, -1.1429360314275701698e-239, 8.3218722366085688343e-256, + 1.0889925813396166947e-207, 2.4325525462765697993e-223, -1.1429360314275701698e-239, 8.3218722366085688343e-256, + 3.1030547578511949035e-208, -1.609965144193984205e-224, -1.8313007053436625212e-240, -2.3341145329525059632e-256, + 3.1030547578511949035e-208, -1.609965144193984205e-224, -1.8313007053436625212e-240, -2.3341145329525059632e-256, + 1.156336993964950812e-208, 2.7126166236326293347e-224, -1.8313007053436625212e-240, -2.3341145329525059632e-256, + 1.8297811202182925249e-209, 1.1003018740995688645e-226, 5.827891678485165325e-243, -3.1174271110208206547e-259, + 1.8297811202182925249e-209, 1.1003018740995688645e-226, 5.827891678485165325e-243, -3.1174271110208206547e-259, + 1.8297811202182925249e-209, 1.1003018740995688645e-226, 5.827891678485165325e-243, -3.1174271110208206547e-259, + 6.1308251778939023781e-210, 1.1003018740995688645e-226, 5.827891678485165325e-243, -3.1174271110208206547e-259, + 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 4.7332165749391048364e-212, 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 2.3568521170701555846e-212, -7.7818310317651142243e-229, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 1.1686698881356804311e-212, 1.8601114328504743806e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 5.7457877366844311816e-213, 5.409641648369814791e-229, -3.0299000794643401155e-245, -2.8075477999879273582e-261, + 2.7753321643482446169e-213, -1.1860946916976500828e-229, 6.3146909508553973881e-246, 1.2573885592501532045e-261, + 1.290104378180150675e-213, 2.1117734783360818049e-229, 4.2928382696354204061e-245, -2.8075477999879273582e-261, + 5.4749048509610403382e-214, 4.6283939331921604413e-230, 6.3146909508553973881e-246, 1.2573885592501532045e-261, + 1.7618353855408067201e-214, 5.060587206499956961e-231, 5.9380161562121075096e-247, -1.2904053011746964278e-263, + 1.7618353855408067201e-214, 5.060587206499956961e-231, 5.9380161562121075096e-247, -1.2904053011746964278e-263, + 8.3356801918574821257e-215, 5.060587206499956961e-231, 5.9380161562121075096e-247, -1.2904053011746964278e-263, + 3.6943433600821895879e-215, 5.060587206499956961e-231, 5.9380161562121075096e-247, -1.2904053011746964278e-263, + 1.3736749441945438342e-215, -9.2331809177749077733e-233, -1.4042876247421726117e-248, -9.9505977179164858712e-265, + 2.1334073625072069974e-216, -9.2331809177749077733e-233, -1.4042876247421726117e-248, -9.9505977179164858712e-265, + 2.1334073625072069974e-216, -9.2331809177749077733e-233, -1.4042876247421726117e-248, -9.9505977179164858712e-265, + 2.1334073625072069974e-216, -9.2331809177749077733e-233, -1.4042876247421726117e-248, -9.9505977179164858712e-265, + 6.8298960257742791824e-217, 6.8696910062179237095e-233, 3.8349029251851101018e-249, -2.6436684620390282645e-267, + 6.8298960257742791824e-217, 6.8696910062179237095e-233, 3.8349029251851101018e-249, -2.6436684620390282645e-267, + 3.2038516259498326923e-217, -1.1817449557784924788e-233, -6.3454186796659920093e-250, -2.6436684620390282645e-267, + 1.3908294260376086421e-217, 2.8439730252197153919e-233, 3.8349029251851101018e-249, -2.6436684620390282645e-267, + 4.8431832608149701961e-218, 8.3111403472061145651e-234, 1.6001805286092554504e-249, -2.6436684620390282645e-267, + 3.1062776103441183191e-219, 7.6291913283447536617e-235, 2.0347903074934629333e-250, -2.6436684620390282645e-267, + 3.1062776103441183191e-219, 7.6291913283447536617e-235, 2.0347903074934629333e-250, -2.6436684620390282645e-267, + 3.1062776103441183191e-219, 7.6291913283447536617e-235, 2.0347903074934629333e-250, -2.6436684620390282645e-267, + 3.1062776103441183191e-219, 7.6291913283447536617e-235, 2.0347903074934629333e-250, -2.6436684620390282645e-267, + 2.7343042298126957741e-220, 5.5273393987134252385e-236, 1.1432574793608780349e-251, 1.2329569415922591084e-267, + 2.7343042298126957741e-220, 5.5273393987134252385e-236, 1.1432574793608780349e-251, 1.2329569415922591084e-267, + 2.7343042298126957741e-220, 5.5273393987134252385e-236, 1.1432574793608780349e-251, 1.2329569415922591084e-267, + 2.7343042298126957741e-220, 5.5273393987134252385e-236, 1.1432574793608780349e-251, 1.2329569415922591084e-267, + 9.6377473771091526132e-221, 1.5959741828948633012e-236, 2.7031904319843490867e-252, 2.638005906844372114e-268, + 7.8509991660024955813e-222, 1.2171222696290252021e-237, -2.4742181023285720738e-254, -1.2030990169203137715e-270, + 7.8509991660024955813e-222, 1.2171222696290252021e-237, -2.4742181023285720738e-254, -1.2030990169203137715e-270, + 7.8509991660024955813e-222, 1.2171222696290252021e-237, -2.4742181023285720738e-254, -1.2030990169203137715e-270, + 7.8509991660024955813e-222, 1.2171222696290252021e-237, -2.4742181023285720738e-254, -1.2030990169203137715e-270, + 2.318094503184431479e-222, -1.1429360314275701698e-239, 8.3218722366085688343e-256, -2.0046830753539155726e-272, + 2.318094503184431479e-222, -1.1429360314275701698e-239, 8.3218722366085688343e-256, -2.0046830753539155726e-272, + 9.3486833747991514629e-223, -1.1429360314275701698e-239, 8.3218722366085688343e-256, -2.0046830753539155726e-272, + 2.4325525462765697993e-223, -1.1429360314275701698e-239, 8.3218722366085688343e-256, -2.0046830753539155726e-272, + 2.4325525462765697993e-223, -1.1429360314275701698e-239, 8.3218722366085688343e-256, -2.0046830753539155726e-272, + 7.0351983914592419146e-224, 7.766758903588374524e-240, 8.3218722366085688343e-256, -2.0046830753539155726e-272, + 7.0351983914592419146e-224, 7.766758903588374524e-240, 8.3218722366085688343e-256, -2.0046830753539155726e-272, + 2.7126166236326293347e-224, -1.8313007053436625212e-240, -2.3341145329525056675e-256, -2.0046830753539155726e-272, + 5.5132573971932232487e-225, 5.6821419688934674008e-241, 3.2988215943776273615e-257, 2.1353977370878701046e-273, + 5.5132573971932232487e-225, 5.6821419688934674008e-241, 3.2988215943776273615e-257, 2.1353977370878701046e-273, + 1.1003018740995688645e-226, 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, + 1.1003018740995688645e-226, 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, + 1.1003018740995688645e-226, 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, + 1.1003018740995688645e-226, 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, + 1.1003018740995688645e-226, 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, + 1.1003018740995688645e-226, 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, + 2.560476225709334075e-227, 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, + 2.560476225709334075e-227, 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, + 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, -1.472095602234059958e-277, + 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, -1.472095602234059958e-277, + 4.4984059688774601837e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, -1.472095602234059958e-277, + 1.8601114328504743806e-228, -3.0299000794643401155e-245, -2.8075477999879273582e-261, -1.472095602234059958e-277, + 5.409641648369814791e-229, -3.0299000794643401155e-245, -2.8075477999879273582e-261, -1.472095602234059958e-277, + 5.409641648369814791e-229, -3.0299000794643401155e-245, -2.8075477999879273582e-261, -1.472095602234059958e-277, + 2.1117734783360818049e-229, 4.2928382696354204061e-245, -2.8075477999879273582e-261, -1.472095602234059958e-277, + 4.6283939331921604413e-230, 6.3146909508553973881e-246, 1.2573885592501529789e-261, 3.0408903374280139822e-277, + 4.6283939331921604413e-230, 6.3146909508553973881e-246, 1.2573885592501529789e-261, 3.0408903374280139822e-277, + 5.060587206499956961e-231, 5.9380161562121075096e-247, -1.2904053011746964278e-263, 8.7279092175580820317e-280, + 5.060587206499956961e-231, 5.9380161562121075096e-247, -1.2904053011746964278e-263, 8.7279092175580820317e-280, + 5.060587206499956961e-231, 5.9380161562121075096e-247, -1.2904053011746964278e-263, 8.7279092175580820317e-280, + 5.060587206499956961e-231, 5.9380161562121075096e-247, -1.2904053011746964278e-263, 8.7279092175580820317e-280, + 2.4841276986611042098e-231, 2.1712682097791944335e-248, 2.9746046415267896827e-264, -8.6516445844406224413e-282, + 1.1958979447416775482e-231, 2.1712682097791944335e-248, 2.9746046415267896827e-264, -8.6516445844406224413e-282, + 5.5178306778196421733e-232, 2.1712682097791944335e-248, 2.9746046415267896827e-264, -8.6516445844406224413e-282, + 2.2972562930210755192e-232, 2.1712682097791944335e-248, 2.9746046415267896827e-264, -8.6516445844406224413e-282, + 6.8696910062179237095e-233, 3.8349029251851101018e-249, -2.6436684620390282645e-267, -4.3807022524130141006e-284, + 6.8696910062179237095e-233, 3.8349029251851101018e-249, -2.6436684620390282645e-267, -4.3807022524130141006e-284, + 2.8439730252197153919e-233, 3.8349029251851101018e-249, -2.6436684620390282645e-267, -4.3807022524130141006e-284, + 8.3111403472061145651e-234, 1.6001805286092554504e-249, -2.6436684620390282645e-267, -4.3807022524130141006e-284, + 8.3111403472061145651e-234, 1.6001805286092554504e-249, -2.6436684620390282645e-267, -4.3807022524130141006e-284, + 3.2789928709583552854e-234, 4.8281933032132812475e-250, -2.6436684620390282645e-267, -4.3807022524130141006e-284, + 7.6291913283447536617e-235, 2.0347903074934629333e-250, -2.6436684620390282645e-267, -4.3807022524130141006e-284, + 7.6291913283447536617e-235, 2.0347903074934629333e-250, -2.6436684620390282645e-267, -4.3807022524130141006e-284, + 1.3390069830350552605e-235, -6.026193929640082176e-252, -7.0535576022338457803e-268, -4.3807022524130141006e-284, + 1.3390069830350552605e-235, -6.026193929640082176e-252, -7.0535576022338457803e-268, -4.3807022524130141006e-284, + 1.3390069830350552605e-235, -6.026193929640082176e-252, -7.0535576022338457803e-268, -4.3807022524130141006e-284, + 5.5273393987134252385e-236, 1.1432574793608780349e-251, 1.2329569415922591084e-267, -4.3807022524130141006e-284, + 1.5959741828948633012e-236, 2.7031904319843490867e-252, 2.638005906844371576e-268, 6.3790946999826013345e-284, + 1.5959741828948633012e-236, 2.7031904319843490867e-252, 2.638005906844371576e-268, 6.3790946999826013345e-284, + 6.1313287894022281692e-237, 5.2084434157824127104e-253, 2.1511502957481757317e-269, 3.2670891426006739096e-285, + 1.2171222696290252021e-237, -2.4742181023285720738e-254, -1.2030990169203137715e-270, -9.5347405022956042207e-287, + 1.2171222696290252021e-237, -2.4742181023285720738e-254, -1.2030990169203137715e-270, -9.5347405022956042207e-287, + 1.2171222696290252021e-237, -2.4742181023285720738e-254, -1.2030990169203137715e-270, -9.5347405022956042207e-287, + 6.0284645465737476297e-238, -2.4742181023285720738e-254, -1.2030990169203137715e-270, -9.5347405022956042207e-287, + 2.9570854717154947523e-238, 4.3456134301905148502e-254, 6.3684349745470443788e-270, -9.5347405022956042207e-287, + 1.4213959342863689955e-238, 9.3569766393097138822e-255, 2.5826679788133653036e-270, -9.5347405022956042207e-287, + 6.5355116557180594664e-239, 9.3569766393097138822e-255, 2.5826679788133653036e-270, -9.5347405022956042207e-287, + 2.6962878121452450746e-239, 8.3218722366085688343e-256, -2.0046830753539152442e-272, -3.4057806738724185961e-288, + 7.766758903588374524e-240, 8.3218722366085688343e-256, -2.0046830753539152442e-272, -3.4057806738724185961e-288, + 7.766758903588374524e-240, 8.3218722366085688343e-256, -2.0046830753539152442e-272, -3.4057806738724185961e-288, + 2.9677290991223565342e-240, -2.3341145329525056675e-256, -2.0046830753539152442e-272, -3.4057806738724185961e-288, + 5.6821419688934674008e-241, 3.2988215943776273615e-257, 2.1353977370878701046e-273, -1.2215123283371736879e-289, + 5.6821419688934674008e-241, 3.2988215943776273615e-257, 2.1353977370878701046e-273, -1.2215123283371736879e-289, + 5.6821419688934674008e-241, 3.2988215943776273615e-257, 2.1353977370878701046e-273, -1.2215123283371736879e-289, + 2.6827483411022054912e-241, 3.2988215943776273615e-257, 2.1353977370878701046e-273, -1.2215123283371736879e-289, + 1.1830515272065748694e-241, -3.117427111020820077e-259, -5.9718623963762788119e-275, 6.1155422068568954053e-291, + 4.3320312025875939195e-242, -3.117427111020820077e-259, -5.9718623963762788119e-275, 6.1155422068568954053e-291, + 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, 6.1155422068568954053e-291, + 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, 6.1155422068568954053e-291, + 5.827891678485165325e-243, -3.117427111020820077e-259, -5.9718623963762788119e-275, 6.1155422068568954053e-291, + 1.1413391350613183311e-243, -5.1586784110844895013e-260, -1.9524039360882352712e-276, -2.9779654517181717279e-292, + 1.1413391350613183311e-243, -5.1586784110844895013e-260, -1.9524039360882352712e-276, -2.9779654517181717279e-292, + 1.1413391350613183311e-243, -5.1586784110844895013e-260, -1.9524039360882352712e-276, -2.9779654517181717279e-292, + 5.5552006713333735927e-244, 7.8491179384773690214e-260, -1.9524039360882352712e-276, -2.9779654517181717279e-292, + 2.6261053316934700345e-244, 1.345219763696439399e-260, 1.6579848156414234801e-276, 1.0303712682997740506e-292, + 1.1615576618735179302e-244, 1.345219763696439399e-260, 1.6579848156414234801e-276, 1.0303712682997740506e-292, + 4.2928382696354204061e-245, -2.8075477999879273582e-261, -1.472095602234059958e-277, 2.8287088295287585094e-294, + 6.3146909508553973881e-246, 1.2573885592501529789e-261, 3.0408903374280139822e-277, 2.8287088295287585094e-294, + 6.3146909508553973881e-246, 1.2573885592501529789e-261, 3.0408903374280139822e-277, 2.8287088295287585094e-294, + 6.3146909508553973881e-246, 1.2573885592501529789e-261, 3.0408903374280139822e-277, 2.8287088295287585094e-294, + 1.7379794826680480784e-246, 2.4115446944063306384e-262, 2.202741251392177696e-278, 2.8287088295287585094e-294, + 1.7379794826680480784e-246, 2.4115446944063306384e-262, 2.202741251392177696e-278, 2.8287088295287585094e-294, + 5.9380161562121075096e-247, -1.2904053011746964278e-263, 8.7279092175580810531e-280, 8.8634899828990930877e-296, + 2.1712682097791944335e-248, 2.9746046415267896827e-264, -8.6516445844406224413e-282, -5.0528699238150276549e-299, + 2.1712682097791944335e-248, 2.9746046415267896827e-264, -8.6516445844406224413e-282, -5.0528699238150276549e-299, + 2.1712682097791944335e-248, 2.9746046415267896827e-264, -8.6516445844406224413e-282, -5.0528699238150276549e-299, + 2.1712682097791944335e-248, 2.9746046415267896827e-264, -8.6516445844406224413e-282, -5.0528699238150276549e-299, + 2.1712682097791944335e-248, 2.9746046415267896827e-264, -8.6516445844406224413e-282, -5.0528699238150276549e-299, + 3.8349029251851101018e-249, -2.6436684620390282645e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 3.8349029251851101018e-249, -2.6436684620390282645e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 3.8349029251851101018e-249, -2.6436684620390282645e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 1.6001805286092554504e-249, -2.6436684620390282645e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 4.8281933032132812475e-250, -2.6436684620390282645e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 4.8281933032132812475e-250, -2.6436684620390282645e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 2.0347903074934629333e-250, -2.6436684620390282645e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 6.3808880963355377617e-251, -2.6436684620390282645e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 6.3808880963355377617e-251, -2.6436684620390282645e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 2.8891343516857640937e-251, 5.1095823452235464813e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 1.1432574793608780349e-251, 1.2329569415922591084e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, + 2.7031904319843490867e-252, 2.638005906844371576e-268, 6.3790946999826013345e-284, -2.7456019707854725967e-300, + 2.7031904319843490867e-252, 2.638005906844371576e-268, 6.3790946999826013345e-284, -2.7456019707854725967e-300, + 5.2084434157824127104e-253, 2.1511502957481757317e-269, 3.2670891426006735363e-285, 2.4084160842482777461e-301, + 5.2084434157824127104e-253, 2.1511502957481757317e-269, 3.2670891426006735363e-285, 2.4084160842482777461e-301, + 5.2084434157824127104e-253, 2.1511502957481757317e-269, 3.2670891426006735363e-285, 2.4084160842482777461e-301, + 2.4805108027747776379e-253, 2.1511502957481757317e-269, 3.2670891426006735363e-285, 2.4084160842482777461e-301, + 1.1165444962709601017e-253, 2.1511502957481757317e-269, 3.2670891426006735363e-285, 2.4084160842482777461e-301, + 4.3456134301905148502e-254, 6.3684349745470443788e-270, -9.5347405022956030541e-287, -1.5805886663557401565e-302, + 9.3569766393097138822e-255, 2.5826679788133653036e-270, -9.5347405022956030541e-287, -1.5805886663557401565e-302, + 9.3569766393097138822e-255, 2.5826679788133653036e-270, -9.5347405022956030541e-287, -1.5805886663557401565e-302, + 8.3218722366085688343e-256, -2.0046830753539152442e-272, -3.4057806738724185961e-288, 2.3458177946667328156e-304, + 8.3218722366085688343e-256, -2.0046830753539152442e-272, -3.4057806738724185961e-288, 2.3458177946667328156e-304, + 8.3218722366085688343e-256, -2.0046830753539152442e-272, -3.4057806738724185961e-288, 2.3458177946667328156e-304, + 8.3218722366085688343e-256, -2.0046830753539152442e-272, -3.4057806738724185961e-288, 2.3458177946667328156e-304, + 2.9938788518280315834e-256, -2.0046830753539152442e-272, -3.4057806738724185961e-288, 2.3458177946667328156e-304, + 3.2988215943776273615e-257, 2.1353977370878701046e-273, -1.2215123283371736879e-289, 6.7342163555358599277e-306, + 3.2988215943776273615e-257, 2.1353977370878701046e-273, -1.2215123283371736879e-289, 6.7342163555358599277e-306, + 3.2988215943776273615e-257, 2.1353977370878701046e-273, -1.2215123283371736879e-289, 6.7342163555358599277e-306, + 3.2988215943776273615e-257, 2.1353977370878701046e-273, -1.2215123283371736879e-289, 6.7342163555358599277e-306, + 1.6338236616337094706e-257, 2.1353977370878701046e-273, -1.2215123283371736879e-289, 6.7342163555358599277e-306, + 8.0132469526175071002e-258, 2.8687869620228451614e-274, -1.9537812801257956865e-290, 1.0380272777574237546e-306, + 3.850752120757712373e-258, 2.8687869620228451614e-274, -1.9537812801257956865e-290, 1.0380272777574237546e-306, + 1.7695047048278150093e-258, 2.8687869620228451614e-274, -1.9537812801257956865e-290, 1.0380272777574237546e-306, + 7.2888099686286655858e-259, 5.581381609158630475e-275, 6.1155422068568946933e-291, 1.0380272777574237546e-306, + 2.0856914288039227544e-259, -1.9524039360882352712e-276, -2.9779654517181712829e-292, -3.000817432603284506e-308, + 2.0856914288039227544e-259, -1.9524039360882352712e-276, -2.9779654517181712829e-292, -3.000817432603284506e-308, + 7.8491179384773690214e-260, -1.9524039360882352712e-276, -2.9779654517181712829e-292, -3.000817432603284506e-308, + 1.345219763696439399e-260, 1.6579848156414234801e-276, 1.0303712682997738281e-292, 1.4493302844111182601e-308, + 1.345219763696439399e-260, 1.6579848156414234801e-276, 1.0303712682997738281e-292, 1.4493302844111182601e-308, + 1.345219763696439399e-260, 1.6579848156414234801e-276, 1.0303712682997738281e-292, 1.4493302844111182601e-308, + 5.3223249184882342185e-261, -1.472095602234059958e-277, 2.8287088295287585094e-294, -1.0874435234232647519e-310, + 1.2573885592501529789e-261, 3.0408903374280139822e-277, 2.8287088295287585094e-294, -1.0874435234232647519e-310, + 1.2573885592501529789e-261, 3.0408903374280139822e-277, 2.8287088295287585094e-294, -1.0874435234232647519e-310, + 2.4115446944063306384e-262, 2.202741251392177696e-278, 2.8287088295287585094e-294, -1.0874435234232647519e-310, + 2.4115446944063306384e-262, 2.202741251392177696e-278, 2.8287088295287585094e-294, -1.0874435234232647519e-310, + 2.4115446944063306384e-262, 2.202741251392177696e-278, 2.8287088295287585094e-294, -1.0874435234232647519e-310, + 1.1412520821444306741e-262, -6.1787496089661820348e-279, -3.028042329852615431e-295, -2.182740474438892116e-311, + 5.0610577601348040988e-263, 7.9243314524777990283e-279, -3.028042329852615431e-295, -2.182740474438892116e-311, + 1.8853262294800541881e-263, 8.7279092175580810531e-280, 8.8634899828990930877e-296, -9.8167844904532653004e-314, + 2.9746046415267896827e-264, -8.6516445844406224413e-282, -5.0528699238150265939e-299, -1.3288013265921760399e-314, + 2.9746046415267896827e-264, -8.6516445844406224413e-282, -5.0528699238150265939e-299, -1.3288013265921760399e-314, + 2.9746046415267896827e-264, -8.6516445844406224413e-282, -5.0528699238150265939e-299, -1.3288013265921760399e-314, + 9.8977243486757054781e-265, -8.6516445844406224413e-282, -5.0528699238150265939e-299, -1.3288013265921760399e-314, + 9.8977243486757054781e-265, -8.6516445844406224413e-282, -5.0528699238150265939e-299, -1.3288013265921760399e-314, + 4.9356438320276576408e-265, -8.6516445844406224413e-282, -5.0528699238150265939e-299, -1.3288013265921760399e-314, + 2.4546035737036337221e-265, -8.6516445844406224413e-282, -5.0528699238150265939e-299, -1.3288013265921760399e-314, + 1.2140834445416214873e-265, 1.8893435613692150014e-281, 3.0075895258731974416e-297, -9.8167844904532653004e-314, + 5.9382337996061564537e-266, 5.1208955146257653156e-282, -5.0528699238150265939e-299, -1.3288013265921760399e-314, + 2.8369334767011265554e-266, 5.1208955146257653156e-282, -5.0528699238150265939e-299, -1.3288013265921760399e-314, + 1.2862833152486119506e-266, 1.6777604898591683764e-282, -5.0528699238150265939e-299, -1.3288013265921760399e-314, + 5.1095823452235464813e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, -2.5539572388808429997e-317, + 1.2329569415922591084e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, -2.5539572388808429997e-317, + 1.2329569415922591084e-267, -4.3807022524130141006e-284, -2.7456019707854725967e-300, -2.5539572388808429997e-317, + 2.638005906844371576e-268, 6.3790946999826013345e-284, -2.7456019707854725967e-300, -2.5539572388808429997e-317, + 2.638005906844371576e-268, 6.3790946999826013345e-284, -2.7456019707854725967e-300, -2.5539572388808429997e-317, + 2.1511502957481757317e-269, 3.2670891426006735363e-285, 2.4084160842482773317e-301, 5.7350888195772519812e-317, + 2.1511502957481757317e-269, 3.2670891426006735363e-285, 2.4084160842482773317e-301, 5.7350888195772519812e-317, + 2.1511502957481757317e-269, 3.2670891426006735363e-285, 2.4084160842482773317e-301, 5.7350888195772519812e-317, + 2.1511502957481757317e-269, 3.2670891426006735363e-285, 2.4084160842482773317e-301, 5.7350888195772519812e-317, + 6.3684349745470443788e-270, -9.5347405022956030541e-287, -1.5805886663557401565e-302, 3.6369654387311681856e-319, + 6.3684349745470443788e-270, -9.5347405022956030541e-287, -1.5805886663557401565e-302, 3.6369654387311681856e-319, + 2.5826679788133653036e-270, -9.5347405022956030541e-287, -1.5805886663557401565e-302, 3.6369654387311681856e-319, + 6.8978448094652555593e-271, 1.1480487920352081009e-286, 7.5257037990230704094e-303, 3.6369654387311681856e-319, + 6.8978448094652555593e-271, 1.1480487920352081009e-286, 7.5257037990230704094e-303, 3.6369654387311681856e-319, + 2.1656360647981577662e-271, 9.7287370902823839435e-288, 1.6928061833779524157e-303, 3.6369654387311681856e-319, + 2.1656360647981577662e-271, 9.7287370902823839435e-288, 1.6928061833779524157e-303, 3.6369654387311681856e-319, + 9.825838786313830552e-272, 9.7287370902823839435e-288, 1.6928061833779524157e-303, 3.6369654387311681856e-319, + 3.9105778554799569972e-272, 9.7287370902823839435e-288, 1.6928061833779524157e-303, 3.6369654387311681856e-319, + 9.5294739006302120482e-273, -1.2215123283371736879e-289, 6.7342163555358599277e-306, -5.681754927174335258e-322, + 9.5294739006302120482e-273, -1.2215123283371736879e-289, 6.7342163555358599277e-306, -5.681754927174335258e-322, + 2.1353977370878701046e-273, -1.2215123283371736879e-289, 6.7342163555358599277e-306, -5.681754927174335258e-322, + 2.1353977370878701046e-273, -1.2215123283371736879e-289, 6.7342163555358599277e-306, -5.681754927174335258e-322, + 2.8687869620228451614e-274, -1.9537812801257956865e-290, 1.0380272777574237546e-306, 6.4228533959362050743e-323, +}; + +static const float Sleef_rempitabsp[] = { + 0.159154892, 5.112411827e-08, 3.626141271e-15, -2.036222915e-22, + 0.03415493667, 6.420638243e-09, 7.342738037e-17, 8.135951656e-24, + 0.03415493667, 6.420638243e-09, 7.342738037e-17, 8.135951656e-24, + 0.002904943191, -9.861969574e-11, -9.839336547e-18, -1.790215892e-24, + 0.002904943191, -9.861969574e-11, -9.839336547e-18, -1.790215892e-24, + 0.002904943191, -9.861969574e-11, -9.839336547e-18, -1.790215892e-24, + 0.002904943191, -9.861969574e-11, -9.839336547e-18, -1.790215892e-24, + 0.0009518179577, 1.342109202e-10, 1.791623576e-17, 1.518506657e-24, + 0.0009518179577, 1.342109202e-10, 1.791623576e-17, 1.518506657e-24, + 0.0004635368241, 1.779561221e-11, 4.038449606e-18, -1.358546052e-25, + 0.0002193961991, 1.779561221e-11, 4.038449606e-18, -1.358546052e-25, + 9.73258866e-05, 1.779561221e-11, 4.038449606e-18, -1.358546052e-25, + 3.62907449e-05, 3.243700447e-12, 5.690024473e-19, 7.09405479e-26, + 5.773168596e-06, 1.424711477e-12, 1.3532163e-19, 1.92417627e-26, + 5.773168596e-06, 1.424711477e-12, 1.3532163e-19, 1.92417627e-26, + 5.773168596e-06, 1.424711477e-12, 1.3532163e-19, 1.92417627e-26, + 1.958472239e-06, 5.152167755e-13, 1.3532163e-19, 1.92417627e-26, + 5.112411827e-08, 3.626141271e-15, -2.036222915e-22, 6.177847236e-30, + 5.112411827e-08, 3.626141271e-15, -2.036222915e-22, 6.177847236e-30, + 5.112411827e-08, 3.626141271e-15, -2.036222915e-22, 6.177847236e-30, + 5.112411827e-08, 3.626141271e-15, -2.036222915e-22, 6.177847236e-30, + 5.112411827e-08, 3.626141271e-15, -2.036222915e-22, 6.177847236e-30, + 5.112411827e-08, 3.626141271e-15, -2.036222915e-22, 6.177847236e-30, + 2.132179588e-08, 3.626141271e-15, -2.036222915e-22, 6.177847236e-30, + 6.420638243e-09, 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, + 6.420638243e-09, 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, + 2.695347945e-09, 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, + 8.327027956e-10, 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, + 8.327027956e-10, 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, + 3.670415083e-10, 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, + 1.342109202e-10, 1.791623576e-17, 1.518506361e-24, 2.613904e-31, + 1.779561221e-11, 4.038449606e-18, -1.358545683e-25, -3.443243946e-32, + 1.779561221e-11, 4.038449606e-18, -1.358545683e-25, -3.443243946e-32, + 1.779561221e-11, 4.038449606e-18, -1.358545683e-25, -3.443243946e-32, + 3.243700447e-12, 5.690024473e-19, 7.094053557e-26, 1.487136711e-32, + 3.243700447e-12, 5.690024473e-19, 7.094053557e-26, 1.487136711e-32, + 3.243700447e-12, 5.690024473e-19, 7.094053557e-26, 1.487136711e-32, + 1.424711477e-12, 1.3532163e-19, 1.924175961e-26, 2.545416018e-33, + 5.152167755e-13, 1.3532163e-19, 1.924175961e-26, 2.545416018e-33, + 6.046956013e-14, -2.036222915e-22, 6.177846108e-30, 1.082084378e-36, + 6.046956013e-14, -2.036222915e-22, 6.177846108e-30, 1.082084378e-36, + 6.046956013e-14, -2.036222915e-22, 6.177846108e-30, 1.082084378e-36, + 3.626141271e-15, -2.036222915e-22, 6.177846108e-30, 1.082084378e-36, + 3.626141271e-15, -2.036222915e-22, 6.177846108e-30, 1.082084378e-36, + 3.626141271e-15, -2.036222915e-22, 6.177846108e-30, 1.082084378e-36, + 3.626141271e-15, -2.036222915e-22, 6.177846108e-30, 1.082084378e-36, + 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, 6.296048013e-40, + 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, 6.296048013e-40, + 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, 6.296048013e-40, + 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, 6.296048013e-40, + 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, 6.296048013e-40, + 7.342738037e-17, 8.135951656e-24, -1.330400526e-31, 6.296048013e-40, + 1.791623576e-17, 1.518506361e-24, 2.61390353e-31, 4.764937743e-38, + 1.791623576e-17, 1.518506361e-24, 2.61390353e-31, 4.764937743e-38, + 4.038449606e-18, -1.358545683e-25, -3.443243946e-32, 6.296048013e-40, + 4.038449606e-18, -1.358545683e-25, -3.443243946e-32, 6.296048013e-40, + 5.690024473e-19, 7.094053557e-26, 1.487136711e-32, 6.296048013e-40, + 5.690024473e-19, 7.094053557e-26, 1.487136711e-32, 6.296048013e-40, + 5.690024473e-19, 7.094053557e-26, 1.487136711e-32, 6.296048013e-40, + 1.3532163e-19, 1.924175961e-26, 2.545415467e-33, 6.296048013e-40, + 1.3532163e-19, 1.924175961e-26, 2.545415467e-33, 6.296048013e-40, + 2.690143217e-20, -1.452834402e-28, -6.441077673e-36, -1.764234767e-42, + 2.690143217e-20, -1.452834402e-28, -6.441077673e-36, -1.764234767e-42, + 2.690143217e-20, -1.452834402e-28, -6.441077673e-36, -1.764234767e-42, + 1.334890502e-20, -1.452834402e-28, -6.441077673e-36, -1.764234767e-42, + 6.572641438e-21, -1.452834402e-28, -6.441077673e-36, -1.764234767e-42, + 0.05874381959, 1.222115387e-08, 7.693612965e-16, 1.792054435e-22, + 0.02749382704, 4.77057327e-09, 7.693612965e-16, 1.792054435e-22, + 0.01186883077, 1.045283415e-09, 3.252721926e-16, 7.332633139e-23, + 0.00405633077, 1.045283415e-09, 3.252721926e-16, 7.332633139e-23, + 0.000150081818, -2.454155802e-12, 1.161414894e-20, 1.291319272e-27, + 0.000150081818, -2.454155802e-12, 1.161414894e-20, 1.291319272e-27, + 0.000150081818, -2.454155802e-12, 1.161414894e-20, 1.291319272e-27, + 0.000150081818, -2.454155802e-12, 1.161414894e-20, 1.291319272e-27, + 0.000150081818, -2.454155802e-12, 1.161414894e-20, 1.291319272e-27, + 2.801149822e-05, 4.821800945e-12, 8.789757674e-19, 1.208447639e-25, + 2.801149822e-05, 4.821800945e-12, 8.789757674e-19, 1.208447639e-25, + 2.801149822e-05, 4.821800945e-12, 8.789757674e-19, 1.208447639e-25, + 1.275271279e-05, 1.183823005e-12, 1.161414894e-20, 1.291319272e-27, + 5.12331826e-06, 1.183823005e-12, 1.161414894e-20, 1.291319272e-27, + 1.308621904e-06, 2.743283031e-13, 1.161414894e-20, 1.291319272e-27, + 1.308621904e-06, 2.743283031e-13, 1.161414894e-20, 1.291319272e-27, + 3.549478151e-07, 4.695462769e-14, 1.161414894e-20, 1.291319272e-27, + 3.549478151e-07, 4.695462769e-14, 1.161414894e-20, 1.291319272e-27, + 1.165292645e-07, 1.853292503e-14, 4.837885366e-21, 1.291319272e-27, + 1.165292645e-07, 1.853292503e-14, 4.837885366e-21, 1.291319272e-27, + 5.69246339e-08, 4.322073705e-15, 1.449754789e-21, 7.962890365e-29, + 2.712231151e-08, 4.322073705e-15, 1.449754789e-21, 7.962890365e-29, + 1.222115387e-08, 7.693612965e-16, 1.792054182e-22, 2.91418027e-29, + 4.77057327e-09, 7.693612965e-16, 1.792054182e-22, 2.91418027e-29, + 1.045283415e-09, 3.252721926e-16, 7.332632508e-23, 3.898253736e-30, + 1.045283415e-09, 3.252721926e-16, 7.332632508e-23, 3.898253736e-30, + 1.139611461e-10, 1.996093359e-17, 5.344349223e-25, 1.511644828e-31, + 1.139611461e-10, 1.996093359e-17, 5.344349223e-25, 1.511644828e-31, + 1.139611461e-10, 1.996093359e-17, 5.344349223e-25, 1.511644828e-31, + 1.139611461e-10, 1.996093359e-17, 5.344349223e-25, 1.511644828e-31, + 5.575349904e-11, 6.083145782e-18, 5.344349223e-25, 1.511644828e-31, + 2.664967552e-11, -8.557475018e-19, -8.595036458e-26, -2.139883875e-32, + 1.209775682e-11, 2.61369883e-18, 5.344349223e-25, 1.511644828e-31, + 4.821800945e-12, 8.789757674e-19, 1.208447639e-25, 3.253064536e-33, + 1.183823005e-12, 1.161414894e-20, 1.29131908e-27, 1.715766248e-34, + 1.183823005e-12, 1.161414894e-20, 1.29131908e-27, 1.715766248e-34, + 2.743283031e-13, 1.161414894e-20, 1.29131908e-27, 1.715766248e-34, +}; +#endif // #ifndef __SLEEF_REMPITAB__ diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/sleefld.c b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/sleefld.c new file mode 100644 index 00000000000..0d9eff87b08 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/sleefld.c @@ -0,0 +1,419 @@ +// Copyright Naoki Shibata and contributors 2010 - 2024. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// Always use -ffp-contract=off option to compile SLEEF. + +#include + +#include +#include +#include + +#include "misc.h" + +#ifdef DORENAME +#include "rename.h" +#endif + +#if (defined(_MSC_VER)) +#pragma fp_contract (off) +#endif + +static INLINE CONST long double mlal(long double x, long double y, long double z) { return x * y + z; } +static INLINE CONST long double xrintl(long double x) { return x < 0 ? (int)(x - 0.5) : (int)(x + 0.5); } +static INLINE CONST int64_t xceill(long double x) { return (int64_t)x + (x < 0 ? 0 : 1); } +static INLINE CONST long double xtruncl(long double x) { return (long double)(int)x; } + +static INLINE CONST int xisnanl(long double x) { return x != x; } +static INLINE CONST int xisinfl(long double x) { return x == SLEEF_INFINITYl || x == -SLEEF_INFINITYl; } +static INLINE CONST int xisminfl(long double x) { return x == -SLEEF_INFINITYl; } +static INLINE CONST int xispinfl(long double x) { return x == SLEEF_INFINITYl; } + +static INLINE CONST long double xfabsl(long double x) { return x >= 0 ? x : -x; } + +// + +#ifndef NDEBUG +static int checkfp(long double x) { + if (xisinfl(x) || xisnanl(x)) return 1; + return 0; +} +#endif + +static INLINE CONST long double upperl(long double d) { + union { + long double ld; + uint32_t u[4]; + } cnv; + + cnv.ld = d; + cnv.u[0] = 0; + return cnv.ld; +} + +static INLINE CONST Sleef_longdouble2 dl(long double h, long double l) { + Sleef_longdouble2 ret; + ret.x = h; ret.y = l; + return ret; +} + +static INLINE CONST Sleef_longdouble2 dlnormalize_l2_l2(Sleef_longdouble2 t) { + Sleef_longdouble2 s; + + s.x = t.x + t.y; + s.y = t.x - s.x + t.y; + + return s; +} + +static INLINE CONST Sleef_longdouble2 dlscale_l2_l2_l(Sleef_longdouble2 d, long double s) { + Sleef_longdouble2 r; + + r.x = d.x * s; + r.y = d.y * s; + + return r; +} + +static INLINE CONST Sleef_longdouble2 dlneg_l2_l2(Sleef_longdouble2 d) { + Sleef_longdouble2 r; + + r.x = -d.x; + r.y = -d.y; + + return r; +} + +static INLINE CONST Sleef_longdouble2 dladd_l2_l_l(long double x, long double y) { + // |x| >= |y| + + Sleef_longdouble2 r; + +#ifndef NDEBUG + if (!(checkfp(x) || checkfp(y) || xfabsl(x) >= xfabsl(y))) { + fprintf(stderr, "[dladd_l2_l_l : %Lg, %Lg]\n", x, y); + fflush(stderr); + } +#endif + + r.x = x + y; + r.y = x - r.x + y; + + return r; +} + +static INLINE CONST Sleef_longdouble2 dladd2_l2_l_l(long double x, long double y) { + Sleef_longdouble2 r; + + r.x = x + y; + long double v = r.x - x; + r.y = (x - (r.x - v)) + (y - v); + + return r; +} + +static INLINE CONST Sleef_longdouble2 dladd_l2_l2_l(Sleef_longdouble2 x, long double y) { + // |x| >= |y| + + Sleef_longdouble2 r; + +#ifndef NDEBUG + if (!(checkfp(x.x) || checkfp(y) || xfabsl(x.x) >= xfabsl(y))) { + fprintf(stderr, "[dladd_l2_l2_l : %Lg %Lg]\n", x.x, y); + fflush(stderr); + } +#endif + + r.x = x.x + y; + r.y = x.x - r.x + y + x.y; + + return r; +} + +static INLINE CONST Sleef_longdouble2 dladd2_l2_l2_l(Sleef_longdouble2 x, long double y) { + // |x| >= |y| + + Sleef_longdouble2 r; + + r.x = x.x + y; + long double v = r.x - x.x; + r.y = (x.x - (r.x - v)) + (y - v); + r.y += x.y; + + return r; +} + +static INLINE CONST Sleef_longdouble2 dladd_l2_l_l2(long double x, Sleef_longdouble2 y) { + // |x| >= |y| + + Sleef_longdouble2 r; + +#ifndef NDEBUG + if (!(checkfp(x) || checkfp(y.x) || xfabsl(x) >= xfabsl(y.x))) { + fprintf(stderr, "[dladd_l2_l_l2 : %Lg %Lg]\n", x, y.x); + fflush(stderr); + } +#endif + + r.x = x + y.x; + r.y = x - r.x + y.x + y.y; + + return r; +} + +static INLINE CONST Sleef_longdouble2 dladd2_l2_l_l2(long double x, Sleef_longdouble2 y) { + Sleef_longdouble2 r; + + r.x = x + y.x; + long double v = r.x - x; + r.y = (x - (r.x - v)) + (y.x - v) + y.y; + + return r; +} + +static INLINE CONST Sleef_longdouble2 dladd_l2_l2_l2(Sleef_longdouble2 x, Sleef_longdouble2 y) { + // |x| >= |y| + + Sleef_longdouble2 r; + +#ifndef NDEBUG + if (!(checkfp(x.x) || checkfp(y.x) || xfabsl(x.x) >= xfabsl(y.x))) { + fprintf(stderr, "[dladd_l2_l2_l2 : %Lg %Lg]\n", x.x, y.x); + fflush(stderr); + } +#endif + + r.x = x.x + y.x; + r.y = x.x - r.x + y.x + x.y + y.y; + + return r; +} + +static INLINE CONST Sleef_longdouble2 dladd2_l2_l2_l2(Sleef_longdouble2 x, Sleef_longdouble2 y) { + Sleef_longdouble2 r; + + r.x = x.x + y.x; + long double v = r.x - x.x; + r.y = (x.x - (r.x - v)) + (y.x - v); + r.y += x.y + y.y; + + return r; +} + +static INLINE CONST Sleef_longdouble2 dlsub_l2_l2_l2(Sleef_longdouble2 x, Sleef_longdouble2 y) { + // |x| >= |y| + + Sleef_longdouble2 r; + +#ifndef NDEBUG + if (!(checkfp(x.x) || checkfp(y.x) || xfabsl(x.x) >= xfabsl(y.x))) { + fprintf(stderr, "[dlsub_l2_l2_l2 : %Lg %Lg]\n", x.x, y.x); + fflush(stderr); + } +#endif + + r.x = x.x - y.x; + r.y = x.x - r.x - y.x + x.y - y.y; + + return r; +} + +static INLINE CONST Sleef_longdouble2 dldiv_l2_l2_l2(Sleef_longdouble2 n, Sleef_longdouble2 d) { + long double t = 1.0 / d.x; + long double dh = upperl(d.x), dl = d.x - dh; + long double th = upperl(t ), tl = t - th; + long double nhh = upperl(n.x), nhl = n.x - nhh; + + Sleef_longdouble2 q; + + q.x = n.x * t; + + long double u = -q.x + nhh * th + nhh * tl + nhl * th + nhl * tl + + q.x * (1 - dh * th - dh * tl - dl * th - dl * tl); + + q.y = t * (n.y - q.x * d.y) + u; + + return q; +} + +static INLINE CONST Sleef_longdouble2 dlmul_l2_l_l(long double x, long double y) { + long double xh = upperl(x), xl = x - xh; + long double yh = upperl(y), yl = y - yh; + Sleef_longdouble2 r; + + r.x = x * y; + r.y = xh * yh - r.x + xl * yh + xh * yl + xl * yl; + + return r; +} + +static INLINE CONST Sleef_longdouble2 dlmul_l2_l2_l(Sleef_longdouble2 x, long double y) { + long double xh = upperl(x.x), xl = x.x - xh; + long double yh = upperl(y ), yl = y - yh; + Sleef_longdouble2 r; + + r.x = x.x * y; + r.y = xh * yh - r.x + xl * yh + xh * yl + xl * yl + x.y * y; + + return r; +} + +static INLINE CONST Sleef_longdouble2 dlmul_l2_l2_l2(Sleef_longdouble2 x, Sleef_longdouble2 y) { + long double xh = upperl(x.x), xl = x.x - xh; + long double yh = upperl(y.x), yl = y.x - yh; + Sleef_longdouble2 r; + + r.x = x.x * y.x; + r.y = xh * yh - r.x + xl * yh + xh * yl + xl * yl + x.x * y.y + x.y * y.x; + + return r; +} + +static INLINE CONST Sleef_longdouble2 dlsqu_l2_l2(Sleef_longdouble2 x) { + long double xh = upperl(x.x), xl = x.x - xh; + Sleef_longdouble2 r; + + r.x = x.x * x.x; + r.y = xh * xh - r.x + (xh + xh) * xl + xl * xl + x.x * (x.y + x.y); + + return r; +} + +static INLINE CONST Sleef_longdouble2 dlrec_l2_l(long double d) { + long double t = 1.0 / d; + long double dh = upperl(d), dl = d - dh; + long double th = upperl(t), tl = t - th; + Sleef_longdouble2 q; + + q.x = t; + q.y = t * (1 - dh * th - dh * tl - dl * th - dl * tl); + + return q; +} + +static INLINE CONST Sleef_longdouble2 dlrec_l2_l2(Sleef_longdouble2 d) { + long double t = 1.0 / d.x; + long double dh = upperl(d.x), dl = d.x - dh; + long double th = upperl(t ), tl = t - th; + Sleef_longdouble2 q; + + q.x = t; + q.y = t * (1 - dh * th - dh * tl - dl * th - dl * tl - d.y * t); + + return q; +} + +/* +static INLINE CONST Sleef_longdouble2 dlsqrt_l2_l2(Sleef_longdouble2 d) { + long double t = sqrt(d.x + d.y); + return dlscale_l2_l2_l(dlmul_l2_l2_l2(dladd2_l2_l2_l2(d, dlmul_l2_l_l(t, t)), dlrec_l2_l(t)), 0.5); +} +*/ + +// + +EXPORT CONST Sleef_longdouble2 xsincospil_u05(long double d) { + long double u, s, t; + Sleef_longdouble2 r, x, s2; + + u = d * 4; + int64_t q = xceill(u) & ~(int64_t)1; + + s = u - (long double)q; + t = s; + s = s * s; + s2 = dlmul_l2_l_l(t, t); + + // + + u = 4.59265607313529833157632e-17L; + u = mlal(u, s, -2.04096140520547829627419e-14L); + u = mlal(u, s, 6.94845264320316515640316e-12L); + u = mlal(u, s, -1.75724767308629210422023e-09L); + u = mlal(u, s, 3.13361689037693212744991e-07L); + u = mlal(u, s, -3.65762041821772284521155e-05L); + u = mlal(u, s, 0.00249039457019272015784594L); + x = dladd2_l2_l_l2(u * s, dl(-0.0807455121882807817044873L, -2.40179063154839769223037e-21L)); + x = dladd2_l2_l2_l2(dlmul_l2_l2_l2(s2, x), dl(0.785398163397448309628202L, -1.25420305812534448752181e-20L)); + + x = dlmul_l2_l2_l(x, t); + r.x = x.x + x.y; + + // + + u = -2.00423964577657539380734e-18L; + u = mlal(u, s, 1.00185574457758689324113e-15L); + u = mlal(u, s, -3.89807283423502620989528e-13L); + u = mlal(u, s, 1.15011591257563133685341e-10L); + u = mlal(u, s, -2.461136950493305818105e-08L); + u = mlal(u, s, 3.59086044859150791782134e-06L); + u = mlal(u, s, -0.00032599188692739001335938L); + x = dladd2_l2_l_l2(u * s, dl(0.0158543442438155008529635L, -6.97556143018517384674258e-22L)); + x = dladd2_l2_l2_l2(dlmul_l2_l2_l2(s2, x), dl(-0.308425137534042456829379L, -9.19882299434302978226668e-21L)); + + x = dladd2_l2_l2_l(dlmul_l2_l2_l2(x, s2), 1); + r.y = x.x + x.y; + + // + + if ((q & 2) != 0) { s = r.y; r.y = r.x; r.x = s; } + if ((q & 4) != 0) { r.x = -r.x; } + if (((q+2) & 4) != 0) { r.y = -r.y; } + + if (xisinfl(d)) { r.x = r.y = SLEEF_NAN; } + if (!xisinfl(d) && xfabsl(d) > TRIGRANGEMAX3) { r.x = r.y = 0; } + + return r; +} + +EXPORT CONST Sleef_longdouble2 xsincospil_u35(long double d) { + long double u, s, t; + Sleef_longdouble2 r; + + u = d * 4; + int64_t q = xceill(u) & ~(int64_t)1; + + s = u - (long double)q; + t = s; + s = s * s; + + // + + u = -0.2023275819380976135024e-13L; + u = mlal(u, s, +0.6948176964255957574946e-11L); + u = mlal(u, s, -0.1757247450021535880723e-8L); + u = mlal(u, s, +0.3133616889379195970541e-6L); + u = mlal(u, s, -0.3657620418215300856408e-4L); + u = mlal(u, s, +0.2490394570192717262476e-2L); + u = mlal(u, s, -0.8074551218828078160284e-1L); + u = mlal(u, s, +0.7853981633974483096282e+0L); + + r.x = u * t; + + // + + u = +0.9933418221428971922705e-15L; + u = mlal(u, s, -0.3897923064055824005357e-12L); + u = mlal(u, s, +0.1150115771521792692066e-9L); + u = mlal(u, s, -0.2461136949725905367314e-7L); + u = mlal(u, s, +0.3590860448589084195081e-5L); + u = mlal(u, s, -0.3259918869273895914840e-3L); + u = mlal(u, s, +0.1585434424381550079706e-1L); + u = mlal(u, s, -0.3084251375340424568294e+0L); + u = mlal(u, s, 1.0L); + + r.y = u; + + // + + if ((q & 2) != 0) { s = r.y; r.y = r.x; r.x = s; } + if ((q & 4) != 0) { r.x = -r.x; } + if (((q+2) & 4) != 0) { r.y = -r.y; } + + if (xisinfl(d)) { r.x = r.y = SLEEF_NAN; } + if (!xisinfl(d) && xfabsl(d) > TRIGRANGEMAX3) { r.x = r.y = 0; } + + return r; +} diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/sleeflibm_footer.h.org b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/sleeflibm_footer.h.org new file mode 100644 index 00000000000..b30cf6bc0ec --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/sleeflibm_footer.h.org @@ -0,0 +1,8 @@ + +// + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // #ifndef __SLEEF_H__ diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/sleeflibm_header.h.org.in b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/sleeflibm_header.h.org.in new file mode 100644 index 00000000000..66d88db3c70 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/sleeflibm_header.h.org.in @@ -0,0 +1,364 @@ +// Copyright Naoki Shibata and contributors 2010 - 2024. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef __SLEEF_H__ +#define __SLEEF_H__ + +#define SLEEF_VERSION_MAJOR @SLEEF_VERSION_MAJOR@ +#define SLEEF_VERSION_MINOR @SLEEF_VERSION_MINOR@ +#define SLEEF_VERSION_PATCHLEVEL @SLEEF_VERSION_PATCH@ + +#include +#include + +#if defined (__GNUC__) || defined (__clang__) || defined(__INTEL_COMPILER) +#define SLEEF_CONST __attribute__((const)) +#define SLEEF_INLINE __attribute__((always_inline)) +#elif defined(_MSC_VER) +#define SLEEF_CONST +#define SLEEF_INLINE __forceinline +#endif + +#if defined(__AVX2__) || defined(__aarch64__) || defined(__arm__) || defined(__powerpc64__) || defined(__zarch__) +#ifndef FP_FAST_FMA +#define FP_FAST_FMA +#endif +#ifndef FP_FAST_FMAF +#define FP_FAST_FMAF +#endif +#endif + +#if defined(_MSC_VER) && !defined(__STDC__) +#define __STDC__ 1 +#endif + +#if (defined(__MINGW32__) || defined(__MINGW64__) || defined(__CYGWIN__) || defined(_MSC_VER)) && !defined(SLEEF_STATIC_LIBS) +#ifdef SLEEF_IMPORT_IS_EXPORT +#define SLEEF_IMPORT __declspec(dllexport) +#else // #ifdef SLEEF_IMPORT_IS_EXPORT +#define SLEEF_IMPORT __declspec(dllimport) +#if (defined(_MSC_VER)) +#pragma comment(lib,"sleef.lib") +#endif // #if (defined(_MSC_VER)) +#endif // #ifdef SLEEF_IMPORT_IS_EXPORT +#else // #if (defined(__MINGW32__) || defined(__MINGW64__) || defined(__CYGWIN__) || defined(_MSC_VER)) && !defined(SLEEF_STATIC_LIBS) +#define SLEEF_IMPORT +#endif // #if (defined(__MINGW32__) || defined(__MINGW64__) || defined(__CYGWIN__) || defined(_MSC_VER)) && !defined(SLEEF_STATIC_LIBS) + +#if (defined(__GNUC__) || defined(__CLANG__)) && (defined(__i386__) || defined(__x86_64__)) +#include +#endif + +#if (defined(_MSC_VER)) +#include +#endif + +#if defined(__ARM_NEON__) || defined(__ARM_NEON) +#include +#endif + +#if defined(__ARM_FEATURE_SVE) +#include +#endif + +#if defined(__VSX__) && defined(__PPC64__) && defined(__LITTLE_ENDIAN__) +#include +typedef __vector double SLEEF_VECTOR_DOUBLE; +typedef __vector float SLEEF_VECTOR_FLOAT; +typedef __vector int SLEEF_VECTOR_INT; +typedef __vector unsigned int SLEEF_VECTOR_UINT; +typedef __vector long long SLEEF_VECTOR_LONGLONG; +typedef __vector unsigned long long SLEEF_VECTOR_ULONGLONG; +#endif + +#if defined(__VX__) && defined(__VEC__) +#ifndef SLEEF_VECINTRIN_H_INCLUDED +#include +#define SLEEF_VECINTRIN_H_INCLUDED +#endif +typedef __vector double SLEEF_VECTOR_DOUBLE; +typedef __vector float SLEEF_VECTOR_FLOAT; +typedef __vector int SLEEF_VECTOR_INT; +typedef __vector unsigned int SLEEF_VECTOR_UINT; +typedef __vector long long SLEEF_VECTOR_LONGLONG; +typedef __vector unsigned long long SLEEF_VECTOR_ULONGLONG; +#endif + +// + +#if defined(SLEEF_ENABLE_OMP_SIMD) && (defined(__GNUC__) || defined(__CLANG__)) && !defined(__INTEL_COMPILER) +#if defined(__aarch64__) +//#define SLEEF_PRAGMA_OMP_SIMD_DP _Pragma ("omp declare simd simdlen(2) notinbranch") +//#define SLEEF_PRAGMA_OMP_SIMD_SP _Pragma ("omp declare simd simdlen(4) notinbranch") +//#elif defined(__x86_64__) && defined(__AVX512F__) +//#define SLEEF_PRAGMA_OMP_SIMD_DP _Pragma ("omp declare simd simdlen(8) notinbranch") +//#define SLEEF_PRAGMA_OMP_SIMD_SP _Pragma ("omp declare simd simdlen(16) notinbranch") +#elif defined(__x86_64__) && defined(__AVX__) +#define SLEEF_PRAGMA_OMP_SIMD_DP _Pragma ("omp declare simd simdlen(4) notinbranch") +#define SLEEF_PRAGMA_OMP_SIMD_SP _Pragma ("omp declare simd simdlen(8) notinbranch") +#elif defined(__x86_64__) && defined(__SSE2__) +#define SLEEF_PRAGMA_OMP_SIMD_DP _Pragma ("omp declare simd simdlen(2) notinbranch") +#define SLEEF_PRAGMA_OMP_SIMD_SP _Pragma ("omp declare simd simdlen(4) notinbranch") +#endif +#endif + +#ifndef SLEEF_PRAGMA_OMP_SIMD_DP +#define SLEEF_PRAGMA_OMP_SIMD_DP +#define SLEEF_PRAGMA_OMP_SIMD_SP +#endif + +// + +#ifndef SLEEF_FP_ILOGB0 +#define SLEEF_FP_ILOGB0 ((int)0x80000000) +#endif + +#ifndef SLEEF_FP_ILOGBNAN +#define SLEEF_FP_ILOGBNAN ((int)2147483647) +#endif + +// + +SLEEF_IMPORT void *Sleef_malloc(size_t z); +SLEEF_IMPORT void Sleef_free(void *ptr); +SLEEF_IMPORT uint64_t Sleef_currentTimeMicros(); + +#if defined(__i386__) || defined(__x86_64__) || defined(_MSC_VER) +SLEEF_IMPORT void Sleef_x86CpuID(int32_t out[4], uint32_t eax, uint32_t ecx); +#endif + +// + +#if defined(__riscv_v) +#include +typedef vfloat64m2_t Sleef_vfloat64m1_t_2; +typedef vfloat32m2_t Sleef_vfloat32m1_t_2; +typedef vfloat64m4_t Sleef_vfloat64m2_t_2; +typedef vfloat32m4_t Sleef_vfloat32m2_t_2; +#define Sleef_vfloat64m1_t_2_DEFINED +#define Sleef_vfloat32m1_t_2_DEFINED +#define Sleef_vfloat64m2_t_2_DEFINED +#define Sleef_vfloat32m2_t_2_DEFINED +#endif + +#ifndef Sleef_double2_DEFINED +#define Sleef_double2_DEFINED +typedef struct { + double x, y; +} Sleef_double2; +#endif + +#ifndef Sleef_float2_DEFINED +#define Sleef_float2_DEFINED +typedef struct { + float x, y; +} Sleef_float2; +#endif + +#ifndef Sleef_longdouble2_DEFINED +#define Sleef_longdouble2_DEFINED +typedef struct { + long double x, y; +} Sleef_longdouble2; +#endif + +#if (defined(__SIZEOF_FLOAT128__) && __SIZEOF_FLOAT128__ == 16) || (defined(__linux__) && defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))) || (defined(__PPC64__) && defined(__GNUC__) && !defined(__clang__) && __GNUC__ >= 8) +#define SLEEF_FLOAT128_IS_IEEEQP +#endif + +#if !defined(SLEEF_FLOAT128_IS_IEEEQP) && defined(__SIZEOF_LONG_DOUBLE__) && __SIZEOF_LONG_DOUBLE__ == 16 && (defined(__aarch64__) || defined(__zarch__)) +#define SLEEF_LONGDOUBLE_IS_IEEEQP +#endif + +#if !defined(Sleef_quad_DEFINED) +#define Sleef_quad_DEFINED +typedef struct { uint64_t x, y; } Sleef_uint64_2t; +#if defined(SLEEF_FLOAT128_IS_IEEEQP) || defined(ENABLEFLOAT128) +typedef __float128 Sleef_quad; +#define SLEEF_QUAD_C(x) (x ## Q) +#elif defined(SLEEF_LONGDOUBLE_IS_IEEEQP) +typedef long double Sleef_quad; +#define SLEEF_QUAD_C(x) (x ## L) +#else +typedef Sleef_uint64_2t Sleef_quad; +#endif +#endif +#if !defined(Sleef_quad2_DEFINED) +#define Sleef_quad2_DEFINED +typedef union { + struct { + Sleef_quad x, y; + }; + Sleef_quad s[2]; +} Sleef_quad2; +#endif + +#ifdef __cplusplus +extern "C" +{ +#endif + +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST double Sleef_sin_u35(double); +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST double Sleef_cos_u35(double); +SLEEF_IMPORT SLEEF_CONST Sleef_double2 Sleef_sincos_u35(double); +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST double Sleef_tan_u35(double); +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST double Sleef_asin_u35(double); +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST double Sleef_acos_u35(double); +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST double Sleef_atan_u35(double); +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST double Sleef_atan2_u35(double, double); +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST double Sleef_log_u35(double); +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST double Sleef_cbrt_u35(double); +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST double Sleef_sin_u10(double); +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST double Sleef_cos_u10(double); +SLEEF_IMPORT SLEEF_CONST Sleef_double2 Sleef_sincos_u10(double); +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST double Sleef_tan_u10(double); +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST double Sleef_asin_u10(double); +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST double Sleef_acos_u10(double); +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST double Sleef_atan_u10(double); +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST double Sleef_atan2_u10(double, double); +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST double Sleef_log_u10(double); +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST double Sleef_cbrt_u10(double); +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST double Sleef_exp_u10(double); +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST double Sleef_pow_u10(double, double); +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST double Sleef_sinh_u10(double); +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST double Sleef_cosh_u10(double); +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST double Sleef_tanh_u10(double); +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST double Sleef_sinh_u35(double); +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST double Sleef_cosh_u35(double); +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST double Sleef_tanh_u35(double); +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST double Sleef_asinh_u10(double); +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST double Sleef_acosh_u10(double); +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST double Sleef_atanh_u10(double); +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST double Sleef_exp2_u10(double); +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST double Sleef_exp10_u10(double); +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST double Sleef_exp2_u35(double); +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST double Sleef_exp10_u35(double); +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST double Sleef_expm1_u10(double); +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST double Sleef_log10_u10(double); +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST double Sleef_log2_u10(double); +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST double Sleef_log2_u35(double); +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST double Sleef_log1p_u10(double); +SLEEF_IMPORT SLEEF_CONST Sleef_double2 Sleef_sincospi_u05(double); +SLEEF_IMPORT SLEEF_CONST Sleef_double2 Sleef_sincospi_u35(double); +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST double Sleef_sinpi_u05(double); +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST double Sleef_cospi_u05(double); +SLEEF_IMPORT SLEEF_CONST double Sleef_ldexp(double, int); +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST int Sleef_ilogb(double); +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST double Sleef_fma(double, double, double); +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST double Sleef_sqrt(double); +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST double Sleef_sqrt_u05(double); +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST double Sleef_sqrt_u35(double); + +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST double Sleef_hypot_u05(double, double); +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST double Sleef_hypot_u35(double, double); + +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST double Sleef_fabs(double); +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST double Sleef_copysign(double, double); +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST double Sleef_fmax(double, double); +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST double Sleef_fmin(double, double); +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST double Sleef_fdim(double, double); +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST double Sleef_trunc(double); +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST double Sleef_floor(double); +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST double Sleef_ceil(double); +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST double Sleef_round(double); +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST double Sleef_rint(double); +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST double Sleef_nextafter(double, double); +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST double Sleef_frfrexp(double); +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST int Sleef_expfrexp(double); +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST double Sleef_fmod(double, double); +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST double Sleef_remainder(double, double); +SLEEF_IMPORT SLEEF_CONST Sleef_double2 Sleef_modf(double); + +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST double Sleef_lgamma_u10(double); +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST double Sleef_tgamma_u10(double); +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST double Sleef_erf_u10(double); +SLEEF_PRAGMA_OMP_SIMD_DP SLEEF_IMPORT SLEEF_CONST double Sleef_erfc_u15(double); + +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_sinf_u35(float); +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_cosf_u35(float); +SLEEF_IMPORT SLEEF_CONST Sleef_float2 Sleef_sincosf_u35(float); +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_tanf_u35(float); +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_asinf_u35(float); +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_acosf_u35(float); +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_atanf_u35(float); +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_atan2f_u35(float, float); +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_logf_u35(float); +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_cbrtf_u35(float); +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_sinf_u10(float); +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_cosf_u10(float); +SLEEF_IMPORT SLEEF_CONST Sleef_float2 Sleef_sincosf_u10(float); +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_fastsinf_u3500(float); +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_fastcosf_u3500(float); +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_tanf_u10(float); +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_asinf_u10(float); +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_acosf_u10(float); +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_atanf_u10(float); +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_atan2f_u10(float, float); +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_logf_u10(float); +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_cbrtf_u10(float); +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_expf_u10(float); +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_powf_u10(float, float); +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_fastpowf_u3500(float, float); +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_sinhf_u10(float); +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_coshf_u10(float); +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_tanhf_u10(float); +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_sinhf_u35(float); +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_coshf_u35(float); +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_tanhf_u35(float); +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_asinhf_u10(float); +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_acoshf_u10(float); +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_atanhf_u10(float); +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_exp2f_u10(float); +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_exp10f_u10(float); +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_exp2f_u35(float); +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_exp10f_u35(float); +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_expm1f_u10(float); +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_log10f_u10(float); +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_log2f_u10(float); +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_log2f_u35(float); +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_log1pf_u10(float); +SLEEF_IMPORT SLEEF_CONST Sleef_float2 Sleef_sincospif_u05(float); +SLEEF_IMPORT SLEEF_CONST Sleef_float2 Sleef_sincospif_u35(float); +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_sinpif_u05(float d); +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_cospif_u05(float d); +SLEEF_IMPORT SLEEF_CONST float Sleef_ldexpf(float, int); +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST int Sleef_ilogbf(float); +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_fmaf(float, float, float); +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_sqrtf(float); +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_sqrtf_u05(float); +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_sqrtf_u35(float); + +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_hypotf_u05(float, float); +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_hypotf_u35(float, float); + +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_fabsf(float); +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_copysignf(float, float); +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_fmaxf(float, float); +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_fminf(float, float); +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_fdimf(float, float); +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_truncf(float); +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_floorf(float); +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_ceilf(float); +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_roundf(float); +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_rintf(float); +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_nextafterf(float, float); +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_frfrexpf(float); +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST int Sleef_expfrexpf(float); +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_fmodf(float, float); +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_remainderf(float, float); +SLEEF_IMPORT SLEEF_CONST Sleef_float2 Sleef_modff(float); + +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_lgammaf_u10(float); +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_tgammaf_u10(float); +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_erff_u10(float); +SLEEF_PRAGMA_OMP_SIMD_SP SLEEF_IMPORT SLEEF_CONST float Sleef_erfcf_u15(float); + +SLEEF_IMPORT SLEEF_CONST Sleef_longdouble2 Sleef_sincospil_u05(long double); +SLEEF_IMPORT SLEEF_CONST Sleef_longdouble2 Sleef_sincospil_u35(long double); + +#if defined(Sleef_quad2_DEFINED) +SLEEF_IMPORT SLEEF_CONST Sleef_quad2 Sleef_sincospiq_u05(Sleef_quad); +SLEEF_IMPORT SLEEF_CONST Sleef_quad2 Sleef_sincospiq_u35(Sleef_quad); +#endif diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/sleefqp.c b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/sleefqp.c new file mode 100644 index 00000000000..f605c0eb8ad --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/sleefqp.c @@ -0,0 +1,472 @@ +// Copyright Naoki Shibata and contributors 2010 - 2024. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// Always use -ffp-contract=off option to compile SLEEF. + +#include + +#include +#include +#include + +#include "misc.h" +#include "quaddef.h" + +#ifdef DORENAME +#include "rename.h" +#endif + +#if (defined(_MSC_VER)) +#pragma fp_contract (off) +#endif + +static INLINE CONST Sleef_quad mlaq(Sleef_quad x, Sleef_quad y, Sleef_quad z) { return x * y + z; } +static INLINE CONST int64_t xrintq(Sleef_quad x) { return x < 0 ? (int64_t)(x - 0.5) : (int64_t)(x + 0.5); } +static INLINE CONST int64_t xceilq(Sleef_quad x) { return (int64_t)x + (x < 0 ? 0 : 1); } +static INLINE CONST Sleef_quad xtruncq(Sleef_quad x) { return (Sleef_quad)(int64_t)x; } + +static INLINE CONST int xisnanq(Sleef_quad x) { return x != x; } +static INLINE CONST int xisinfq(Sleef_quad x) { return x == SLEEF_INFINITYq || x == -SLEEF_INFINITYq; } +static INLINE CONST int xisminfq(Sleef_quad x) { return x == -SLEEF_INFINITYq; } +static INLINE CONST int xispinfq(Sleef_quad x) { return x == SLEEF_INFINITYq; } + +static INLINE CONST Sleef_quad xfabsq(Sleef_quad x) { + union { + Sleef_quad q; + uint64_t u[2]; + } cnv; + + cnv.q = x; + cnv.u[1] &= UINT64_C(0x7fffffffffffffff); + return cnv.q; +} + +// + +#ifndef NDEBUG +static int checkfp(Sleef_quad x) { + if (xisinfq(x) || xisnanq(x)) return 1; + return 0; +} +#endif + +static INLINE CONST Sleef_quad upperq(Sleef_quad d) { + union { + Sleef_quad q; + uint64_t u[2]; + } cnv; + + cnv.q = d; + cnv.u[0] &= ~((UINT64_C(1) << (112/2+1)) - 1); + return cnv.q; +} + +static INLINE CONST Sleef_quad2 dq(Sleef_quad h, Sleef_quad l) { + Sleef_quad2 ret; + ret.x = h; ret.y = l; + return ret; +} + +static INLINE CONST Sleef_quad2 dqnormalize_q2_q2(Sleef_quad2 t) { + Sleef_quad2 s; + + s.x = t.x + t.y; + s.y = t.x - s.x + t.y; + + return s; +} + +static INLINE CONST Sleef_quad2 dqscale_q2_q2_q(Sleef_quad2 d, Sleef_quad s) { + Sleef_quad2 r; + + r.x = d.x * s; + r.y = d.y * s; + + return r; +} + +static INLINE CONST Sleef_quad2 dqneg_q2_q2(Sleef_quad2 d) { + Sleef_quad2 r; + + r.x = -d.x; + r.y = -d.y; + + return r; +} + +static INLINE CONST Sleef_quad2 dqadd_q2_q_q(Sleef_quad x, Sleef_quad y) { + // |x| >= |y| + + Sleef_quad2 r; + +#ifndef NDEBUG + if (!(checkfp(x) || checkfp(y) || xfabsq(x) >= xfabsq(y))) { + fprintf(stderr, "[dqadd_q2_q_q : %g, %g]\n", (double)x, (double)y); + fflush(stderr); + } +#endif + + r.x = x + y; + r.y = x - r.x + y; + + return r; +} + +static INLINE CONST Sleef_quad2 dqadd2_q2_q_q(Sleef_quad x, Sleef_quad y) { + Sleef_quad2 r; + + r.x = x + y; + Sleef_quad v = r.x - x; + r.y = (x - (r.x - v)) + (y - v); + + return r; +} + +static INLINE CONST Sleef_quad2 dqadd_q2_q2_q(Sleef_quad2 x, Sleef_quad y) { + // |x| >= |y| + + Sleef_quad2 r; + +#ifndef NDEBUG + if (!(checkfp(x.x) || checkfp(y) || xfabsq(x.x) >= xfabsq(y))) { + fprintf(stderr, "[dqadd_q2_q2_q : %g %g]\n", (double)x.x, (double)y); + fflush(stderr); + } +#endif + + r.x = x.x + y; + r.y = x.x - r.x + y + x.y; + + return r; +} + +static INLINE CONST Sleef_quad2 dqadd2_q2_q2_q(Sleef_quad2 x, Sleef_quad y) { + // |x| >= |y| + + Sleef_quad2 r; + + r.x = x.x + y; + Sleef_quad v = r.x - x.x; + r.y = (x.x - (r.x - v)) + (y - v); + r.y += x.y; + + return r; +} + +static INLINE CONST Sleef_quad2 dqadd_q2_q_q2(Sleef_quad x, Sleef_quad2 y) { + // |x| >= |y| + + Sleef_quad2 r; + +#ifndef NDEBUG + if (!(checkfp(x) || checkfp(y.x) || xfabsq(x) >= xfabsq(y.x))) { + fprintf(stderr, "[dqadd_q2_q_q2 : %g %g]\n", (double)x, (double)y.x); + fflush(stderr); + } +#endif + + r.x = x + y.x; + r.y = x - r.x + y.x + y.y; + + return r; +} + +static INLINE CONST Sleef_quad2 dqadd2_q2_q_q2(Sleef_quad x, Sleef_quad2 y) { + Sleef_quad2 r; + + r.x = x + y.x; + Sleef_quad v = r.x - x; + r.y = (x - (r.x - v)) + (y.x - v) + y.y; + + return r; +} + +static INLINE CONST Sleef_quad2 dqadd_q2_q2_q2(Sleef_quad2 x, Sleef_quad2 y) { + // |x| >= |y| + + Sleef_quad2 r; + +#ifndef NDEBUG + if (!(checkfp(x.x) || checkfp(y.x) || xfabsq(x.x) >= xfabsq(y.x))) { + fprintf(stderr, "[dqadd_q2_q2_q2 : %g %g]\n", (double)x.x, (double)y.x); + fflush(stderr); + } +#endif + + r.x = x.x + y.x; + r.y = x.x - r.x + y.x + x.y + y.y; + + return r; +} + +static INLINE CONST Sleef_quad2 dqadd2_q2_q2_q2(Sleef_quad2 x, Sleef_quad2 y) { + Sleef_quad2 r; + + r.x = x.x + y.x; + Sleef_quad v = r.x - x.x; + r.y = (x.x - (r.x - v)) + (y.x - v); + r.y += x.y + y.y; + + return r; +} + +static INLINE CONST Sleef_quad2 dqsub_q2_q2_q2(Sleef_quad2 x, Sleef_quad2 y) { + // |x| >= |y| + + Sleef_quad2 r; + +#ifndef NDEBUG + if (!(checkfp(x.x) || checkfp(y.x) || xfabsq(x.x) >= xfabsq(y.x))) { + fprintf(stderr, "[dqsub_q2_q2_q2 : %g %g]\n", (double)x.x, (double)y.x); + fflush(stderr); + } +#endif + + r.x = x.x - y.x; + r.y = x.x - r.x - y.x + x.y - y.y; + + return r; +} + +static INLINE CONST Sleef_quad2 dqdiv_q2_q2_q2(Sleef_quad2 n, Sleef_quad2 d) { + Sleef_quad t = 1.0 / d.x; + Sleef_quad dh = upperq(d.x), dl = d.x - dh; + Sleef_quad th = upperq(t ), tl = t - th; + Sleef_quad nhh = upperq(n.x), nhl = n.x - nhh; + + Sleef_quad2 q; + + q.x = n.x * t; + + Sleef_quad u = -q.x + nhh * th + nhh * tl + nhl * th + nhl * tl + + q.x * (1 - dh * th - dh * tl - dl * th - dl * tl); + + q.y = t * (n.y - q.x * d.y) + u; + + return q; +} + +static INLINE CONST Sleef_quad2 dqmul_q2_q_q(Sleef_quad x, Sleef_quad y) { + Sleef_quad xh = upperq(x), xl = x - xh; + Sleef_quad yh = upperq(y), yl = y - yh; + Sleef_quad2 r; + + r.x = x * y; + r.y = xh * yh - r.x + xl * yh + xh * yl + xl * yl; + + return r; +} + +static INLINE CONST Sleef_quad2 dqmul_q2_q2_q(Sleef_quad2 x, Sleef_quad y) { + Sleef_quad xh = upperq(x.x), xl = x.x - xh; + Sleef_quad yh = upperq(y ), yl = y - yh; + Sleef_quad2 r; + + r.x = x.x * y; + r.y = xh * yh - r.x + xl * yh + xh * yl + xl * yl + x.y * y; + + return r; +} + +static INLINE CONST Sleef_quad2 dqmul_q2_q2_q2(Sleef_quad2 x, Sleef_quad2 y) { + Sleef_quad xh = upperq(x.x), xl = x.x - xh; + Sleef_quad yh = upperq(y.x), yl = y.x - yh; + Sleef_quad2 r; + + r.x = x.x * y.x; + r.y = xh * yh - r.x + xl * yh + xh * yl + xl * yl + x.x * y.y + x.y * y.x; + + return r; +} + +static INLINE CONST Sleef_quad2 dqsqu_q2_q2(Sleef_quad2 x) { + Sleef_quad xh = upperq(x.x), xl = x.x - xh; + Sleef_quad2 r; + + r.x = x.x * x.x; + r.y = xh * xh - r.x + (xh + xh) * xl + xl * xl + x.x * (x.y + x.y); + + return r; +} + +static INLINE CONST Sleef_quad2 dqrec_q2_q(Sleef_quad d) { + Sleef_quad t = 1.0 / d; + Sleef_quad dh = upperq(d), dl = d - dh; + Sleef_quad th = upperq(t), tl = t - th; + Sleef_quad2 q; + + q.x = t; + q.y = t * (1 - dh * th - dh * tl - dl * th - dl * tl); + + return q; +} + +static INLINE CONST Sleef_quad2 dqrec_q2_q2(Sleef_quad2 d) { + Sleef_quad t = 1.0 / d.x; + Sleef_quad dh = upperq(d.x), dl = d.x - dh; + Sleef_quad th = upperq(t ), tl = t - th; + Sleef_quad2 q; + + q.x = t; + q.y = t * (1 - dh * th - dh * tl - dl * th - dl * tl - d.y * t); + + return q; +} + +/* +static INLINE CONST Sleef_quad2 dqsqrt_q2_q2(Sleef_quad2 d) { + Sleef_quad t = sqrt(d.x + d.y); + return dqscale_q2_q2_q(dqmul_q2_q2_q2(dqadd2_q2_q2_q2(d, dqmul_q2_q_q(t, t)), dqrec_q2_q(t)), 0.5); +} +*/ + +// + +EXPORT CONST Sleef_quad2 xsincospiq_u05(Sleef_quad d) { + Sleef_quad u, s, t; + Sleef_quad2 r, x, s2; + + u = d * 4; + int64_t q = xceilq(u) & ~(int64_t)1; + + s = u - (Sleef_quad)q; + t = s; + s = s * s; + s2 = dqmul_q2_q_q(t, t); + + // + + u = +0.1528321016188828732764080161368244291e-27Q; + u = mlaq(u, s, -0.1494741498689376415859233754050616110e-24Q); + u = mlaq(u, s, +0.1226149947504428931621181953791777769e-21Q); + u = mlaq(u, s, -0.8348589834426964519785265770009675533e-19Q); + u = mlaq(u, s, +0.4628704628834415551415078707261146069e-16Q); + u = mlaq(u, s, -0.2041026339664143925641158896030605061e-13Q); + u = mlaq(u, s, +0.6948453273886629408492386065037620114e-11Q); + u = mlaq(u, s, -0.1757247673443401045145682042627557066e-8Q); + u = mlaq(u, s, +0.3133616890378121520950407496603902388e-6Q); + u = mlaq(u, s, -0.3657620418217725078660518698299784909e-4Q); + u = mlaq(u, s, +0.2490394570192720160015798421577395304e-2Q); + x = dqadd2_q2_q_q2(u * s, dq(-0.08074551218828078170696957048724322192457Q, 5.959584458773288360696286320980429277618e-36)); + x = dqadd2_q2_q2_q2(dqmul_q2_q2_q2(s2, x), dq(0.7853981633974483096156608458198756993698Q, 2.167745574452451779709844565881105067311e-35Q)); + + x = dqmul_q2_q2_q(x, t); + r.x = x.x + x.y; + + // + + u = -0.4616472554003168470361503708527464705e-29Q; + u = mlaq(u, s, +0.4891528531228245577148587028696897180e-26Q); + u = mlaq(u, s, -0.4377345071482935585011339656701961637e-23Q); + u = mlaq(u, s, +0.3278483561449753435303463083506802784e-20Q); + u = mlaq(u, s, -0.2019653396886554861865456720993185772e-17Q); + u = mlaq(u, s, +0.1001886461636271957275884859852184250e-14Q); + u = mlaq(u, s, -0.3898073171259675439843028673969857173e-12Q); + u = mlaq(u, s, +0.1150115912797405152263176921581706121e-9Q); + u = mlaq(u, s, -0.2461136950494199754009084018126527316e-7Q); + u = mlaq(u, s, +0.3590860448591510079069203991167071234e-5Q); + u = mlaq(u, s, -0.3259918869273900136414318317506198622e-3Q); + x = dqadd2_q2_q_q2(u * s, dq(0.01585434424381550085228521039855226376329Q, 6.529088663284413499535484912972485728198e-38Q)); + x = dqadd2_q2_q2_q2(dqmul_q2_q2_q2(s2, x), dq(-0.308425137534042456838577843746129712906Q, -1.006808646313642786855469666154064243572e-35Q)); + + x = dqadd2_q2_q2_q(dqmul_q2_q2_q2(x, s2), 1); + r.y = x.x + x.y; + + // + + if ((q & 2) != 0) { s = r.y; r.y = r.x; r.x = s; } + if ((q & 4) != 0) { r.x = -r.x; } + if (((q+2) & 4) != 0) { r.y = -r.y; } + + if (xisinfq(d)) { r.x = r.y = SLEEF_NANq; } + if (!xisinfq(d) && xfabsq(d) > TRIGRANGEMAX3) { r.x = r.y = 0; } + + return r; +} + +EXPORT CONST Sleef_quad2 xsincospiq_u35(Sleef_quad d) { + Sleef_quad u, s, t; + Sleef_quad2 r; + + u = d * 4; + int64_t q = xceilq(u) & ~(int64_t)1; + + s = u - (Sleef_quad)q; + t = s; + s = s * s; + + // + + u = -0.1485963032785725729464918728185622156e-24Q; + u = mlaq(u, s, +0.1226127943866088943202201676879490635e-21Q); + u = mlaq(u, s, -0.8348589518463078609690110857435995326e-19Q); + u = mlaq(u, s, +0.4628704628547538824855302470312741438e-16Q); + u = mlaq(u, s, -0.2041026339663972432248777826778586936e-13Q); + u = mlaq(u, s, +0.6948453273886628726907826757576187848e-11Q); + u = mlaq(u, s, -0.1757247673443401044967978719804318982e-8Q); + u = mlaq(u, s, +0.3133616890378121520950114757196589206e-6Q); + u = mlaq(u, s, -0.3657620418217725078660518414453815240e-4Q); + u = mlaq(u, s, +0.2490394570192720160015798421435124000e-2Q); + u = mlaq(u, s, -0.8074551218828078170696957048724041729e-1Q); + u = mlaq(u, s, +0.7853981633974483096156608458198756994e+0Q); + + r.x = u * t; + + // + + u = +0.4862670988511544771355006256522366302e-26Q; + u = mlaq(u, s, -0.4377265452147065611484052550741141029e-23Q); + u = mlaq(u, s, +0.3278483433857326331665386021267750285e-20Q); + u = mlaq(u, s, -0.2019653396755055912482006994709659430e-17Q); + u = mlaq(u, s, +0.1001886461636180795663169552615123249e-14Q); + u = mlaq(u, s, -0.3898073171259675007871885150022866077e-12Q); + u = mlaq(u, s, +0.1150115912797405152123832255915284811e-9Q); + u = mlaq(u, s, -0.2461136950494199754008784937314856168e-7Q); + u = mlaq(u, s, +0.3590860448591510079069203583263258862e-5Q); + u = mlaq(u, s, -0.3259918869273900136414318317180623832e-3Q); + u = mlaq(u, s, +0.1585434424381550085228521039855096075e-1Q); + u = mlaq(u, s, -0.3084251375340424568385778437461297129e+0Q); + u = mlaq(u, s, 1.0Q); + + r.y = u; + + // + + if ((q & 2) != 0) { s = r.y; r.y = r.x; r.x = s; } + if ((q & 4) != 0) { r.x = -r.x; } + if (((q+2) & 4) != 0) { r.y = -r.y; } + + if (xisinfq(d)) { r.x = r.y = SLEEF_NANq; } + if (!xisinfq(d) && xfabsq(d) > TRIGRANGEMAX3) { r.x = r.y = 0; } + + return r; +} + +// + +#ifdef ENABLE_MAIN +#include +#include +int main(int argc, char **argv) { + Sleef_quad a = -8.3998726984803832684266802333309369056312711821029e-09Q; + Sleef_quad2 q = xsincospiq_u05(a); + printf(" "); printf128(q.x); printf("\n"); + + /* + printf128(0.1Q); printf("\n"); + Sleef_quad2 q2 = dqmul_q2_q_q(0.1Q, 0.1Q); + printf128(q2.x); printf("\n"); + printf128(q2.y); printf("\n"); + */ + /* + printf("%s\n", toBCq(0.1Q)); + printf("%s\n", toBCq(upperq(0.1Q))); + printf("%s\n", toBCq(0.1Q-upperq(0.1Q))); + Sleef_quad2 q2 = dqmul_q2_q_q(0.1Q, 0.1Q); + printf("%s + ", toBCq(q2.x)); + printf("%s\n", toBCq(q2.y)); + */ +} +#endif diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/sleefsimddp.c b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/sleefsimddp.c new file mode 100644 index 00000000000..1d64424a0ef --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/sleefsimddp.c @@ -0,0 +1,3741 @@ +// Copyright Naoki Shibata and contributors 2010 - 2024. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// Always use -ffp-contract=off option to compile SLEEF. + +#if !defined(SLEEF_GENHEADER) +#include +#include +#include +#include +#endif + +#include "quaddef.h" +#include "misc.h" + +#ifndef SLEEF_ENABLE_CUDA +extern const double Sleef_rempitabdp[]; +#endif + +#define __SLEEFSIMDDP_C__ + +#if defined(_MSC_VER) && !defined (__clang__) +#pragma fp_contract (off) +#else +#pragma STDC FP_CONTRACT OFF +#endif + +// Intel + +#ifdef ENABLE_SSE2 +#define CONFIG 2 +#include "helpersse2.h" +#ifdef DORENAME +#ifdef ENABLE_GNUABI +#include "renamesse2_gnuabi.h" +#else +#include "renamesse2.h" +#endif +#endif +#endif + +#ifdef ENABLE_SSE4 +#define CONFIG 4 +#include "helpersse2.h" +#ifdef DORENAME +#include "renamesse4.h" +#endif +#endif + +#ifdef ENABLE_AVX +#define CONFIG 1 +#include "helperavx.h" +#ifdef DORENAME +#ifdef ENABLE_GNUABI +#include "renameavx_gnuabi.h" +#else +#include "renameavx.h" +#endif +#endif +#endif + +#ifdef ENABLE_FMA4 +#define CONFIG 4 +#include "helperavx.h" +#ifdef DORENAME +#ifdef ENABLE_GNUABI +#include "renamefma4_gnuabi.h" +#else +#include "renamefma4.h" +#endif +#endif +#endif + +#ifdef ENABLE_AVX2 +#define CONFIG 1 +#include "helperavx2.h" +#ifdef DORENAME +#ifdef ENABLE_GNUABI +#include "renameavx2_gnuabi.h" +#else +#include "renameavx2.h" +#endif +#endif +#endif + +#ifdef ENABLE_AVX2128 +#define CONFIG 1 +#include "helperavx2_128.h" +#ifdef DORENAME +#include "renameavx2128.h" +#endif +#endif + +#ifdef ENABLE_AVX512F +#define CONFIG 1 +#include "helperavx512f.h" +#ifdef DORENAME +#ifdef ENABLE_GNUABI +#include "renameavx512f_gnuabi.h" +#else +#include "renameavx512f.h" +#endif +#endif +#endif + +#ifdef ENABLE_AVX512FNOFMA +#define CONFIG 2 +#include "helperavx512f.h" +#ifdef DORENAME +#include "renameavx512fnofma.h" +#endif +#endif + +// Arm + +#ifdef ENABLE_ADVSIMD +#define CONFIG 1 +#include "helperadvsimd.h" +#ifdef DORENAME +#ifdef ENABLE_GNUABI +#include "renameadvsimd_gnuabi.h" +#else +#include "renameadvsimd.h" +#endif +#endif +#endif + +#ifdef ENABLE_ADVSIMDNOFMA +#define CONFIG 2 +#include "helperadvsimd.h" +#ifdef DORENAME +#include "renameadvsimdnofma.h" +#endif +#endif + +#ifdef ENABLE_SVE +#define CONFIG 1 +#include "helpersve.h" +#ifdef DORENAME +#ifdef ENABLE_GNUABI +#include "renamesve_gnuabi.h" +#else +#include "renamesve.h" +#endif /* ENABLE_GNUABI */ +#endif /* DORENAME */ +#endif /* ENABLE_SVE */ + +#ifdef ENABLE_SVENOFMA +#define CONFIG 2 +#include "helpersve.h" +#ifdef DORENAME +#include "renamesvenofma.h" +#endif /* DORENAME */ +#endif /* ENABLE_SVE */ + +// IBM + +#ifdef ENABLE_VSX +#define CONFIG 1 +#include "helperpower_128.h" +#ifdef DORENAME +#include "renamevsx.h" +#endif +#endif + +#ifdef ENABLE_VSXNOFMA +#define CONFIG 2 +#include "helperpower_128.h" +#ifdef DORENAME +#include "renamevsxnofma.h" +#endif +#endif + +#ifdef ENABLE_VSX3 +#define CONFIG 3 +#include "helperpower_128.h" +#ifdef DORENAME +#include "renamevsx3.h" +#endif +#endif + +#ifdef ENABLE_VSX3NOFMA +#define CONFIG 4 +#include "helperpower_128.h" +#ifdef DORENAME +#include "renamevsx3nofma.h" +#endif +#endif + +#ifdef ENABLE_VXE +#define CONFIG 140 +#include "helpers390x_128.h" +#ifdef DORENAME +#include "renamevxe.h" +#endif +#endif + +#ifdef ENABLE_VXENOFMA +#define CONFIG 141 +#include "helpers390x_128.h" +#ifdef DORENAME +#include "renamevxenofma.h" +#endif +#endif + +#ifdef ENABLE_VXE2 +#define CONFIG 150 +#include "helpers390x_128.h" +#ifdef DORENAME +#include "renamevxe2.h" +#endif +#endif + +#ifdef ENABLE_VXE2NOFMA +#define CONFIG 151 +#include "helpers390x_128.h" +#ifdef DORENAME +#include "renamevxe2nofma.h" +#endif +#endif + +// RISC-V +#ifdef ENABLE_RVVM1 +#define CONFIG 1 +#define ENABLE_RVV_DP +#include "helperrvv.h" +#ifdef DORENAME +#include "renamervvm1.h" +#endif +#endif + +#ifdef ENABLE_RVVM1NOFMA +#define CONFIG 2 +#define ENABLE_RVV_DP +#include "helperrvv.h" +#ifdef DORENAME +#include "renamervvm1nofma.h" +#endif +#endif /* ENABLE_RVVM1NOFMA */ + +#ifdef ENABLE_RVVM2 +#define CONFIG 1 +#define ENABLE_RVV_DP +#include "helperrvv.h" +#ifdef DORENAME +#include "renamervvm2.h" +#endif +#endif + +#ifdef ENABLE_RVVM2NOFMA +#define CONFIG 2 +#define ENABLE_RVV_DP +#include "helperrvv.h" +#ifdef DORENAME +#include "renamervvm2nofma.h" +#endif +#endif /* ENABLE_RVVM2NOFMA */ + +// Generic + +#ifdef ENABLE_VECEXT +#define CONFIG 1 +#include "helpervecext.h" +#ifdef DORENAME +#include "renamevecext.h" +#endif +#endif + +#ifdef ENABLE_PUREC +#define CONFIG 1 +#include "helperpurec.h" +#ifdef DORENAME +#include "renamepurec.h" +#endif +#endif + +#ifdef ENABLE_PUREC_SCALAR +#define CONFIG 1 +#include "helperpurec_scalar.h" +#ifdef DORENAME +#include "renamepurec_scalar.h" +#endif +#endif + +#ifdef ENABLE_PURECFMA_SCALAR +#define CONFIG 2 +#include "helperpurec_scalar.h" +#ifdef DORENAME +#include "renamepurecfma_scalar.h" +#endif +#endif + +#ifdef SLEEF_ENABLE_CUDA +#define CONFIG 3 +#include "helperpurec_scalar.h" +#ifdef DORENAME +#include "renamecuda.h" +#endif +#endif + +// + +#define MLA(x, y, z) vmla_vd_vd_vd_vd((x), (y), (z)) +#define C2V(c) vcast_vd_d(c) +#include "estrin.h" + +// + +#include "dd.h" +#include "commonfuncs.h" + +// return d0 < d1 ? x : y +static INLINE CONST VECTOR_CC vint vsel_vi_vd_vd_vi_vi(vdouble d0, vdouble d1, vint x, vint y) { return vsel_vi_vo_vi_vi(vcast_vo32_vo64(vlt_vo_vd_vd(d0, d1)), x, y); } + +// return d0 < 0 ? x : 0 +static INLINE CONST VECTOR_CC vint vsel_vi_vd_vi(vdouble d, vint x) { return vand_vi_vo_vi(vcast_vo32_vo64(vsignbit_vo_vd(d)), x); } + +// + +EXPORT CONST VECTOR_CC vdouble xldexp(vdouble x, vint q) { return vldexp_vd_vd_vi(x, q); } + +EXPORT CONST VECTOR_CC vint xilogb(vdouble d) { + vdouble e = vcast_vd_vi(vilogbk_vi_vd(vabs_vd_vd(d))); + e = vsel_vd_vo_vd_vd(veq_vo_vd_vd(d, vcast_vd_d(0)), vcast_vd_d(SLEEF_FP_ILOGB0), e); + e = vsel_vd_vo_vd_vd(visnan_vo_vd(d), vcast_vd_d(SLEEF_FP_ILOGBNAN), e); + e = vsel_vd_vo_vd_vd(visinf_vo_vd(d), vcast_vd_d(SLEEF_INT_MAX), e); + return vrint_vi_vd(e); +} + +static INLINE CONST ddi_t rempi(vdouble a) { + vdouble2 x, y; + vint ex = vilogb2k_vi_vd(a); +#if defined(ENABLE_AVX512F) || defined(ENABLE_AVX512FNOFMA) + ex = vandnot_vi_vi_vi(vsra_vi_vi_i(ex, 31), ex); + ex = vand_vi_vi_vi(ex, vcast_vi_i(1023)); +#endif + ex = vsub_vi_vi_vi(ex, vcast_vi_i(55)); + vint q = vand_vi_vo_vi(vgt_vo_vi_vi(ex, vcast_vi_i(700-55)), vcast_vi_i(-64)); + a = vldexp3_vd_vd_vi(a, q); + ex = vandnot_vi_vi_vi(vsra_vi_vi_i(ex, 31), ex); + ex = vsll_vi_vi_i(ex, 2); + x = ddmul_vd2_vd_vd(a, vgather_vd_p_vi(Sleef_rempitabdp, ex)); + di_t di = rempisub(vd2getx_vd_vd2(x)); + q = digeti_vi_di(di); + x = vd2setx_vd2_vd2_vd(x, digetd_vd_di(di)); + x = ddnormalize_vd2_vd2(x); + y = ddmul_vd2_vd_vd(a, vgather_vd_p_vi(Sleef_rempitabdp+1, ex)); + x = ddadd2_vd2_vd2_vd2(x, y); + di = rempisub(vd2getx_vd_vd2(x)); + q = vadd_vi_vi_vi(q, digeti_vi_di(di)); + x = vd2setx_vd2_vd2_vd(x, digetd_vd_di(di)); + x = ddnormalize_vd2_vd2(x); + y = vcast_vd2_vd_vd(vgather_vd_p_vi(Sleef_rempitabdp+2, ex), vgather_vd_p_vi(Sleef_rempitabdp+3, ex)); + y = ddmul_vd2_vd2_vd(y, a); + x = ddadd2_vd2_vd2_vd2(x, y); + x = ddnormalize_vd2_vd2(x); + x = ddmul_vd2_vd2_vd2(x, vcast_vd2_d_d(3.141592653589793116*2, 1.2246467991473532072e-16*2)); + vopmask o = vlt_vo_vd_vd(vabs_vd_vd(a), vcast_vd_d(0.7)); + x = vd2setx_vd2_vd2_vd(x, vsel_vd_vo_vd_vd(o, a, vd2getx_vd_vd2(x))); + x = vd2sety_vd2_vd2_vd(x, vreinterpret_vd_vm(vandnot_vm_vo64_vm(o, vreinterpret_vm_vd(vd2gety_vd_vd2(x))))); + return ddisetddi_ddi_vd2_vi(x, q); +} + +EXPORT CONST VECTOR_CC vdouble xsin(vdouble d) { +#if !defined(DETERMINISTIC) +// The SIMD source files(sleefsimd?p.c) are compiled twice for each +// vector extension, with DETERMINISTIC macro turned on and off. +// Below is the normal(faster) implementation of sin function. The +// function name xsin will be renamed to Sleef_sind2_u35sse2 with +// renamesse2.h, for example. + + vdouble u, s, r = d; + vint ql; + + if (LIKELY(vtestallones_i_vo64(vlt_vo_vd_vd(vabs_vd_vd(d), vcast_vd_d(TRIGRANGEMAX2))))) { + vdouble dql = vrint_vd_vd(vmul_vd_vd_vd(d, vcast_vd_d(M_1_PI))); + ql = vrint_vi_vd(dql); + d = vmla_vd_vd_vd_vd(dql, vcast_vd_d(-PI_A2), d); + d = vmla_vd_vd_vd_vd(dql, vcast_vd_d(-PI_B2), d); + } else if (LIKELY(vtestallones_i_vo64(vlt_vo_vd_vd(vabs_vd_vd(d), vcast_vd_d(TRIGRANGEMAX))))) { + vdouble dqh = vtruncate_vd_vd(vmul_vd_vd_vd(d, vcast_vd_d(M_1_PI / (1 << 24)))); + dqh = vmul_vd_vd_vd(dqh, vcast_vd_d(1 << 24)); + vdouble dql = vrint_vd_vd(vmlapn_vd_vd_vd_vd(d, vcast_vd_d(M_1_PI), dqh)); + ql = vrint_vi_vd(dql); + + d = vmla_vd_vd_vd_vd(dqh, vcast_vd_d(-PI_A), d); + d = vmla_vd_vd_vd_vd(dql, vcast_vd_d(-PI_A), d); + d = vmla_vd_vd_vd_vd(dqh, vcast_vd_d(-PI_B), d); + d = vmla_vd_vd_vd_vd(dql, vcast_vd_d(-PI_B), d); + d = vmla_vd_vd_vd_vd(dqh, vcast_vd_d(-PI_C), d); + d = vmla_vd_vd_vd_vd(dql, vcast_vd_d(-PI_C), d); + d = vmla_vd_vd_vd_vd(vadd_vd_vd_vd(dqh, dql), vcast_vd_d(-PI_D), d); + } else { + ddi_t ddi = rempi(d); + ql = vand_vi_vi_vi(ddigeti_vi_ddi(ddi), vcast_vi_i(3)); + ql = vadd_vi_vi_vi(vadd_vi_vi_vi(ql, ql), vsel_vi_vo_vi_vi(vcast_vo32_vo64(vgt_vo_vd_vd(vd2getx_vd_vd2(ddigetdd_vd2_ddi(ddi)), vcast_vd_d(0))), vcast_vi_i(2), vcast_vi_i(1))); + ql = vsra_vi_vi_i(ql, 2); + vopmask o = veq_vo_vi_vi(vand_vi_vi_vi(ddigeti_vi_ddi(ddi), vcast_vi_i(1)), vcast_vi_i(1)); + vdouble2 x = vcast_vd2_vd_vd(vmulsign_vd_vd_vd(vcast_vd_d(-3.141592653589793116 * 0.5), vd2getx_vd_vd2(ddigetdd_vd2_ddi(ddi))), + vmulsign_vd_vd_vd(vcast_vd_d(-1.2246467991473532072e-16 * 0.5), vd2getx_vd_vd2(ddigetdd_vd2_ddi(ddi)))); + x = ddadd2_vd2_vd2_vd2(ddigetdd_vd2_ddi(ddi), x); + ddi = ddisetdd_ddi_ddi_vd2(ddi, vsel_vd2_vo_vd2_vd2(vcast_vo64_vo32(o), x, ddigetdd_vd2_ddi(ddi))); + d = vadd_vd_vd_vd(vd2getx_vd_vd2(ddigetdd_vd2_ddi(ddi)), vd2gety_vd_vd2(ddigetdd_vd2_ddi(ddi))); + d = vreinterpret_vd_vm(vor_vm_vo64_vm(vor_vo_vo_vo(visinf_vo_vd(r), visnan_vo_vd(r)), vreinterpret_vm_vd(d))); + } + + s = vmul_vd_vd_vd(d, d); + + d = vreinterpret_vd_vm(vxor_vm_vm_vm(vand_vm_vo64_vm(vcast_vo64_vo32(veq_vo_vi_vi(vand_vi_vi_vi(ql, vcast_vi_i(1)), vcast_vi_i(1))), vreinterpret_vm_vd(vcast_vd_d(-0.0))), vreinterpret_vm_vd(d))); + + vdouble s2 = vmul_vd_vd_vd(s, s), s4 = vmul_vd_vd_vd(s2, s2); + u = POLY8(s, s2, s4, + -7.97255955009037868891952e-18, + 2.81009972710863200091251e-15, + -7.64712219118158833288484e-13, + 1.60590430605664501629054e-10, + -2.50521083763502045810755e-08, + 2.75573192239198747630416e-06, + -0.000198412698412696162806809, + 0.00833333333333332974823815); + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(-0.166666666666666657414808)); + + u = vadd_vd_vd_vd(vmul_vd_vd_vd(s, vmul_vd_vd_vd(u, d)), d); + + u = vsel_vd_vo_vd_vd(visnegzero_vo_vd(r), r, u); + + return u; + +#else // #if !defined(DETERMINISTIC) + +// This is the deterministic implementation of sin function. Returned +// values from deterministic functions are bitwise consistent across +// all platforms. The function name xsin will be renamed to +// Sleef_cinz_sind2_u35sse2 with renamesse2.h, for example. The +// renaming by rename*.h is switched according to DETERMINISTIC macro. + vdouble u, s, r = d; + vint ql; + + vdouble dql = vrint_vd_vd(vmul_vd_vd_vd(d, vcast_vd_d(M_1_PI))); + ql = vrint_vi_vd(dql); + d = vmla_vd_vd_vd_vd(dql, vcast_vd_d(-PI_A2), d); + d = vmla_vd_vd_vd_vd(dql, vcast_vd_d(-PI_B2), d); + vopmask g = vlt_vo_vd_vd(vabs_vd_vd(r), vcast_vd_d(TRIGRANGEMAX2)); + + if (!LIKELY(vtestallones_i_vo64(g))) { + vdouble dqh = vtruncate_vd_vd(vmul_vd_vd_vd(r, vcast_vd_d(M_1_PI / (1 << 24)))); + dqh = vmul_vd_vd_vd(dqh, vcast_vd_d(1 << 24)); + vdouble dql = vrint_vd_vd(vmlapn_vd_vd_vd_vd(r, vcast_vd_d(M_1_PI), dqh)); + + u = vmla_vd_vd_vd_vd(dqh, vcast_vd_d(-PI_A), r); + u = vmla_vd_vd_vd_vd(dql, vcast_vd_d(-PI_A), u); + u = vmla_vd_vd_vd_vd(dqh, vcast_vd_d(-PI_B), u); + u = vmla_vd_vd_vd_vd(dql, vcast_vd_d(-PI_B), u); + u = vmla_vd_vd_vd_vd(dqh, vcast_vd_d(-PI_C), u); + u = vmla_vd_vd_vd_vd(dql, vcast_vd_d(-PI_C), u); + u = vmla_vd_vd_vd_vd(vadd_vd_vd_vd(dqh, dql), vcast_vd_d(-PI_D), u); + + ql = vsel_vi_vo_vi_vi(vcast_vo32_vo64(g), ql, vrint_vi_vd(dql)); + d = vsel_vd_vo_vd_vd(g, d, u); + g = vlt_vo_vd_vd(vabs_vd_vd(r), vcast_vd_d(TRIGRANGEMAX)); + + if (!LIKELY(vtestallones_i_vo64(g))) { + ddi_t ddi = rempi(r); + vint ql2 = vand_vi_vi_vi(ddigeti_vi_ddi(ddi), vcast_vi_i(3)); + ql2 = vadd_vi_vi_vi(vadd_vi_vi_vi(ql2, ql2), vsel_vi_vo_vi_vi(vcast_vo32_vo64(vgt_vo_vd_vd(vd2getx_vd_vd2(ddigetdd_vd2_ddi(ddi)), vcast_vd_d(0))), vcast_vi_i(2), vcast_vi_i(1))); + ql2 = vsra_vi_vi_i(ql2, 2); + vopmask o = veq_vo_vi_vi(vand_vi_vi_vi(ddigeti_vi_ddi(ddi), vcast_vi_i(1)), vcast_vi_i(1)); + vdouble2 x = vcast_vd2_vd_vd(vmulsign_vd_vd_vd(vcast_vd_d(-3.141592653589793116 * 0.5), vd2getx_vd_vd2(ddigetdd_vd2_ddi(ddi))), + vmulsign_vd_vd_vd(vcast_vd_d(-1.2246467991473532072e-16 * 0.5), vd2getx_vd_vd2(ddigetdd_vd2_ddi(ddi)))); + x = ddadd2_vd2_vd2_vd2(ddigetdd_vd2_ddi(ddi), x); + ddi = ddisetdd_ddi_ddi_vd2(ddi, vsel_vd2_vo_vd2_vd2(vcast_vo64_vo32(o), x, ddigetdd_vd2_ddi(ddi))); + u = vadd_vd_vd_vd(vd2getx_vd_vd2(ddigetdd_vd2_ddi(ddi)), vd2gety_vd_vd2(ddigetdd_vd2_ddi(ddi))); + ql = vsel_vi_vo_vi_vi(vcast_vo32_vo64(g), ql, ql2); + d = vsel_vd_vo_vd_vd(g, d, u); + d = vreinterpret_vd_vm(vor_vm_vo64_vm(vor_vo_vo_vo(visinf_vo_vd(r), visnan_vo_vd(r)), vreinterpret_vm_vd(d))); + } + } + + s = vmul_vd_vd_vd(d, d); + + d = vreinterpret_vd_vm(vxor_vm_vm_vm(vand_vm_vo64_vm(vcast_vo64_vo32(veq_vo_vi_vi(vand_vi_vi_vi(ql, vcast_vi_i(1)), vcast_vi_i(1))), vreinterpret_vm_vd(vcast_vd_d(-0.0))), vreinterpret_vm_vd(d))); + + vdouble s2 = vmul_vd_vd_vd(s, s), s4 = vmul_vd_vd_vd(s2, s2); + u = POLY8(s, s2, s4, + -7.97255955009037868891952e-18, + 2.81009972710863200091251e-15, + -7.64712219118158833288484e-13, + 1.60590430605664501629054e-10, + -2.50521083763502045810755e-08, + 2.75573192239198747630416e-06, + -0.000198412698412696162806809, + 0.00833333333333332974823815); + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(-0.166666666666666657414808)); + + u = vadd_vd_vd_vd(vmul_vd_vd_vd(s, vmul_vd_vd_vd(u, d)), d); + + u = vsel_vd_vo_vd_vd(visnegzero_vo_vd(r), r, u); + + return u; +#endif // #if !defined(DETERMINISTIC) +} + +EXPORT CONST VECTOR_CC vdouble xsin_u1(vdouble d) { +#if !defined(DETERMINISTIC) + vdouble u; + vdouble2 s, t, x; + vint ql; + + if (LIKELY(vtestallones_i_vo64(vlt_vo_vd_vd(vabs_vd_vd(d), vcast_vd_d(TRIGRANGEMAX2))))) { + const vdouble dql = vrint_vd_vd(vmul_vd_vd_vd(d, vcast_vd_d(M_1_PI))); + ql = vrint_vi_vd(dql); + u = vmla_vd_vd_vd_vd(dql, vcast_vd_d(-PI_A2), d); + s = ddadd_vd2_vd_vd (u, vmul_vd_vd_vd(dql, vcast_vd_d(-PI_B2))); + } else if (LIKELY(vtestallones_i_vo64(vlt_vo_vd_vd(vabs_vd_vd(d), vcast_vd_d(TRIGRANGEMAX))))) { + vdouble dqh = vtruncate_vd_vd(vmul_vd_vd_vd(d, vcast_vd_d(M_1_PI / (1 << 24)))); + dqh = vmul_vd_vd_vd(dqh, vcast_vd_d(1 << 24)); + const vdouble dql = vrint_vd_vd(vmlapn_vd_vd_vd_vd(d, vcast_vd_d(M_1_PI), dqh)); + ql = vrint_vi_vd(dql); + + u = vmla_vd_vd_vd_vd(dqh, vcast_vd_d(-PI_A), d); + s = ddadd_vd2_vd_vd (u, vmul_vd_vd_vd(dql, vcast_vd_d(-PI_A))); + s = ddadd2_vd2_vd2_vd(s, vmul_vd_vd_vd(dqh, vcast_vd_d(-PI_B))); + s = ddadd2_vd2_vd2_vd(s, vmul_vd_vd_vd(dql, vcast_vd_d(-PI_B))); + s = ddadd2_vd2_vd2_vd(s, vmul_vd_vd_vd(dqh, vcast_vd_d(-PI_C))); + s = ddadd2_vd2_vd2_vd(s, vmul_vd_vd_vd(dql, vcast_vd_d(-PI_C))); + s = ddadd_vd2_vd2_vd(s, vmul_vd_vd_vd(vadd_vd_vd_vd(dqh, dql), vcast_vd_d(-PI_D))); + } else { + ddi_t ddi = rempi(d); + ql = vand_vi_vi_vi(ddigeti_vi_ddi(ddi), vcast_vi_i(3)); + ql = vadd_vi_vi_vi(vadd_vi_vi_vi(ql, ql), vsel_vi_vo_vi_vi(vcast_vo32_vo64(vgt_vo_vd_vd(vd2getx_vd_vd2(ddigetdd_vd2_ddi(ddi)), vcast_vd_d(0))), vcast_vi_i(2), vcast_vi_i(1))); + ql = vsra_vi_vi_i(ql, 2); + vopmask o = veq_vo_vi_vi(vand_vi_vi_vi(ddigeti_vi_ddi(ddi), vcast_vi_i(1)), vcast_vi_i(1)); + vdouble2 x = vcast_vd2_vd_vd(vmulsign_vd_vd_vd(vcast_vd_d(-3.141592653589793116 * 0.5), vd2getx_vd_vd2(ddigetdd_vd2_ddi(ddi))), + vmulsign_vd_vd_vd(vcast_vd_d(-1.2246467991473532072e-16 * 0.5), vd2getx_vd_vd2(ddigetdd_vd2_ddi(ddi)))); + x = ddadd2_vd2_vd2_vd2(ddigetdd_vd2_ddi(ddi), x); + ddi = ddisetdd_ddi_ddi_vd2(ddi, vsel_vd2_vo_vd2_vd2(vcast_vo64_vo32(o), x, ddigetdd_vd2_ddi(ddi))); + s = ddnormalize_vd2_vd2(ddigetdd_vd2_ddi(ddi)); + s = vd2setx_vd2_vd2_vd(s, vreinterpret_vd_vm(vor_vm_vo64_vm(vor_vo_vo_vo(visinf_vo_vd(d), visnan_vo_vd(d)), vreinterpret_vm_vd(vd2getx_vd_vd2(s))))); + } + + t = s; + s = ddsqu_vd2_vd2(s); + + vdouble s2 = vmul_vd_vd_vd(vd2getx_vd_vd2(s), vd2getx_vd_vd2(s)), s4 = vmul_vd_vd_vd(s2, s2); + u = POLY6(vd2getx_vd_vd2(s), s2, s4, + 2.72052416138529567917983e-15, + -7.6429259411395447190023e-13, + 1.60589370117277896211623e-10, + -2.5052106814843123359368e-08, + 2.75573192104428224777379e-06, + -0.000198412698412046454654947); + u = vmla_vd_vd_vd_vd(u, vd2getx_vd_vd2(s), vcast_vd_d(0.00833333333333318056201922)); + + x = ddadd_vd2_vd_vd2(vcast_vd_d(1), ddmul_vd2_vd2_vd2(ddadd_vd2_vd_vd(vcast_vd_d(-0.166666666666666657414808), vmul_vd_vd_vd(u, vd2getx_vd_vd2(s))), s)); + u = ddmul_vd_vd2_vd2(t, x); + + u = vreinterpret_vd_vm(vxor_vm_vm_vm(vand_vm_vo64_vm(vcast_vo64_vo32(veq_vo_vi_vi(vand_vi_vi_vi(ql, vcast_vi_i(1)), vcast_vi_i(1))), + vreinterpret_vm_vd(vcast_vd_d(-0.0))), vreinterpret_vm_vd(u))); + u = vsel_vd_vo_vd_vd(veq_vo_vd_vd(d, vcast_vd_d(0)), d, u); + + return u; + +#else // #if !defined(DETERMINISTIC) + + vdouble u; + vdouble2 s, t, x; + vint ql; + + vopmask g = vlt_vo_vd_vd(vabs_vd_vd(d), vcast_vd_d(TRIGRANGEMAX2)); + vdouble dql = vrint_vd_vd(vmul_vd_vd_vd(d, vcast_vd_d(M_1_PI))); + ql = vrint_vi_vd(dql); + u = vmla_vd_vd_vd_vd(dql, vcast_vd_d(-PI_A2), d); + x = ddadd_vd2_vd_vd (u, vmul_vd_vd_vd(dql, vcast_vd_d(-PI_B2))); + + if (!LIKELY(vtestallones_i_vo64(g))) { + vdouble dqh = vtruncate_vd_vd(vmul_vd_vd_vd(d, vcast_vd_d(M_1_PI / (1 << 24)))); + dqh = vmul_vd_vd_vd(dqh, vcast_vd_d(1 << 24)); + const vdouble dql = vrint_vd_vd(vmlapn_vd_vd_vd_vd(d, vcast_vd_d(M_1_PI), dqh)); + + u = vmla_vd_vd_vd_vd(dqh, vcast_vd_d(-PI_A), d); + s = ddadd_vd2_vd_vd (u, vmul_vd_vd_vd(dql, vcast_vd_d(-PI_A))); + s = ddadd2_vd2_vd2_vd(s, vmul_vd_vd_vd(dqh, vcast_vd_d(-PI_B))); + s = ddadd2_vd2_vd2_vd(s, vmul_vd_vd_vd(dql, vcast_vd_d(-PI_B))); + s = ddadd2_vd2_vd2_vd(s, vmul_vd_vd_vd(dqh, vcast_vd_d(-PI_C))); + s = ddadd2_vd2_vd2_vd(s, vmul_vd_vd_vd(dql, vcast_vd_d(-PI_C))); + s = ddadd_vd2_vd2_vd(s, vmul_vd_vd_vd(vadd_vd_vd_vd(dqh, dql), vcast_vd_d(-PI_D))); + + ql = vsel_vi_vo_vi_vi(vcast_vo32_vo64(g), ql, vrint_vi_vd(dql)); + x = vsel_vd2_vo_vd2_vd2(g, x, s); + g = vlt_vo_vd_vd(vabs_vd_vd(d), vcast_vd_d(TRIGRANGEMAX)); + + if (!LIKELY(vtestallones_i_vo64(g))) { + ddi_t ddi = rempi(d); + vint ql2 = vand_vi_vi_vi(ddigeti_vi_ddi(ddi), vcast_vi_i(3)); + ql2 = vadd_vi_vi_vi(vadd_vi_vi_vi(ql2, ql2), vsel_vi_vo_vi_vi(vcast_vo32_vo64(vgt_vo_vd_vd(vd2getx_vd_vd2(ddigetdd_vd2_ddi(ddi)), vcast_vd_d(0))), vcast_vi_i(2), vcast_vi_i(1))); + ql2 = vsra_vi_vi_i(ql2, 2); + vopmask o = veq_vo_vi_vi(vand_vi_vi_vi(ddigeti_vi_ddi(ddi), vcast_vi_i(1)), vcast_vi_i(1)); + vdouble2 t = vcast_vd2_vd_vd(vmulsign_vd_vd_vd(vcast_vd_d(-3.141592653589793116 * 0.5), vd2getx_vd_vd2(ddigetdd_vd2_ddi(ddi))), + vmulsign_vd_vd_vd(vcast_vd_d(-1.2246467991473532072e-16 * 0.5), vd2getx_vd_vd2(ddigetdd_vd2_ddi(ddi)))); + t = ddadd2_vd2_vd2_vd2(ddigetdd_vd2_ddi(ddi), t); + ddi = ddisetdd_ddi_ddi_vd2(ddi, vsel_vd2_vo_vd2_vd2(vcast_vo64_vo32(o), t, ddigetdd_vd2_ddi(ddi))); + s = ddnormalize_vd2_vd2(ddigetdd_vd2_ddi(ddi)); + ql = vsel_vi_vo_vi_vi(vcast_vo32_vo64(g), ql, ql2); + x = vsel_vd2_vo_vd2_vd2(g, x, s); + x = vd2setx_vd2_vd2_vd(x, vreinterpret_vd_vm(vor_vm_vo64_vm(vor_vo_vo_vo(visinf_vo_vd(d), visnan_vo_vd(d)), vreinterpret_vm_vd(vd2getx_vd_vd2(x))))); + } + } + + t = x; + s = ddsqu_vd2_vd2(x); + + vdouble s2 = vmul_vd_vd_vd(vd2getx_vd_vd2(s), vd2getx_vd_vd2(s)), s4 = vmul_vd_vd_vd(s2, s2); + u = POLY6(vd2getx_vd_vd2(s), s2, s4, + 2.72052416138529567917983e-15, + -7.6429259411395447190023e-13, + 1.60589370117277896211623e-10, + -2.5052106814843123359368e-08, + 2.75573192104428224777379e-06, + -0.000198412698412046454654947); + u = vmla_vd_vd_vd_vd(u, vd2getx_vd_vd2(s), vcast_vd_d(0.00833333333333318056201922)); + + x = ddadd_vd2_vd_vd2(vcast_vd_d(1), ddmul_vd2_vd2_vd2(ddadd_vd2_vd_vd(vcast_vd_d(-0.166666666666666657414808), vmul_vd_vd_vd(u, vd2getx_vd_vd2(s))), s)); + u = ddmul_vd_vd2_vd2(t, x); + + u = vreinterpret_vd_vm(vxor_vm_vm_vm(vand_vm_vo64_vm(vcast_vo64_vo32(veq_vo_vi_vi(vand_vi_vi_vi(ql, vcast_vi_i(1)), vcast_vi_i(1))), + vreinterpret_vm_vd(vcast_vd_d(-0.0))), vreinterpret_vm_vd(u))); + + u = vsel_vd_vo_vd_vd(veq_vo_vd_vd(d, vcast_vd_d(0)), d, u); + + return u; +#endif // #if !defined(DETERMINISTIC) +} + +EXPORT CONST VECTOR_CC vdouble xcos(vdouble d) { +#if !defined(DETERMINISTIC) + vdouble u, s, r = d; + vint ql; + + if (LIKELY(vtestallones_i_vo64(vlt_vo_vd_vd(vabs_vd_vd(d), vcast_vd_d(TRIGRANGEMAX2))))) { + vdouble dql = vmla_vd_vd_vd_vd(vcast_vd_d(2), + vrint_vd_vd(vmla_vd_vd_vd_vd(d, vcast_vd_d(M_1_PI), vcast_vd_d(-0.5))), + vcast_vd_d(1)); + ql = vrint_vi_vd(dql); + d = vmla_vd_vd_vd_vd(dql, vcast_vd_d(-PI_A2 * 0.5), d); + d = vmla_vd_vd_vd_vd(dql, vcast_vd_d(-PI_B2 * 0.5), d); + } else if (LIKELY(vtestallones_i_vo64(vlt_vo_vd_vd(vabs_vd_vd(d), vcast_vd_d(TRIGRANGEMAX))))) { + vdouble dqh = vtruncate_vd_vd(vmla_vd_vd_vd_vd(d, vcast_vd_d(M_1_PI / (1 << 23)), vcast_vd_d(-M_1_PI / (1 << 24)))); + ql = vrint_vi_vd(vadd_vd_vd_vd(vmul_vd_vd_vd(d, vcast_vd_d(M_1_PI)), + vmla_vd_vd_vd_vd(dqh, vcast_vd_d(-(1 << 23)), vcast_vd_d(-0.5)))); + dqh = vmul_vd_vd_vd(dqh, vcast_vd_d(1 << 24)); + ql = vadd_vi_vi_vi(vadd_vi_vi_vi(ql, ql), vcast_vi_i(1)); + vdouble dql = vcast_vd_vi(ql); + + d = vmla_vd_vd_vd_vd(dqh, vcast_vd_d(-PI_A * 0.5), d); + d = vmla_vd_vd_vd_vd(dql, vcast_vd_d(-PI_A * 0.5), d); + d = vmla_vd_vd_vd_vd(dqh, vcast_vd_d(-PI_B * 0.5), d); + d = vmla_vd_vd_vd_vd(dql, vcast_vd_d(-PI_B * 0.5), d); + d = vmla_vd_vd_vd_vd(dqh, vcast_vd_d(-PI_C * 0.5), d); + d = vmla_vd_vd_vd_vd(dql, vcast_vd_d(-PI_C * 0.5), d); + d = vmla_vd_vd_vd_vd(vadd_vd_vd_vd(dqh, dql), vcast_vd_d(-PI_D * 0.5), d); + } else { + ddi_t ddi = rempi(d); + ql = vand_vi_vi_vi(ddigeti_vi_ddi(ddi), vcast_vi_i(3)); + ql = vadd_vi_vi_vi(vadd_vi_vi_vi(ql, ql), vsel_vi_vo_vi_vi(vcast_vo32_vo64(vgt_vo_vd_vd(vd2getx_vd_vd2(ddigetdd_vd2_ddi(ddi)), vcast_vd_d(0))), vcast_vi_i(8), vcast_vi_i(7))); + ql = vsra_vi_vi_i(ql, 1); + vopmask o = veq_vo_vi_vi(vand_vi_vi_vi(ddigeti_vi_ddi(ddi), vcast_vi_i(1)), vcast_vi_i(0)); + vdouble y = vsel_vd_vo_vd_vd(vgt_vo_vd_vd(vd2getx_vd_vd2(ddigetdd_vd2_ddi(ddi)), vcast_vd_d(0)), vcast_vd_d(0), vcast_vd_d(-1)); + vdouble2 x = vcast_vd2_vd_vd(vmulsign_vd_vd_vd(vcast_vd_d(-3.141592653589793116 * 0.5), y), + vmulsign_vd_vd_vd(vcast_vd_d(-1.2246467991473532072e-16 * 0.5), y)); + x = ddadd2_vd2_vd2_vd2(ddigetdd_vd2_ddi(ddi), x); + ddi = ddisetdd_ddi_ddi_vd2(ddi, vsel_vd2_vo_vd2_vd2(vcast_vo64_vo32(o), x, ddigetdd_vd2_ddi(ddi))); + d = vadd_vd_vd_vd(vd2getx_vd_vd2(ddigetdd_vd2_ddi(ddi)), vd2gety_vd_vd2(ddigetdd_vd2_ddi(ddi))); + d = vreinterpret_vd_vm(vor_vm_vo64_vm(vor_vo_vo_vo(visinf_vo_vd(r), visnan_vo_vd(r)), vreinterpret_vm_vd(d))); + } + + s = vmul_vd_vd_vd(d, d); + + d = vreinterpret_vd_vm(vxor_vm_vm_vm(vand_vm_vo64_vm(vcast_vo64_vo32(veq_vo_vi_vi(vand_vi_vi_vi(ql, vcast_vi_i(2)), vcast_vi_i(0))), vreinterpret_vm_vd(vcast_vd_d(-0.0))), vreinterpret_vm_vd(d))); + + vdouble s2 = vmul_vd_vd_vd(s, s), s4 = vmul_vd_vd_vd(s2, s2); + u = POLY8(s, s2, s4, + -7.97255955009037868891952e-18, + 2.81009972710863200091251e-15, + -7.64712219118158833288484e-13, + 1.60590430605664501629054e-10, + -2.50521083763502045810755e-08, + 2.75573192239198747630416e-06, + -0.000198412698412696162806809, + 0.00833333333333332974823815); + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(-0.166666666666666657414808)); + + u = vadd_vd_vd_vd(vmul_vd_vd_vd(s, vmul_vd_vd_vd(u, d)), d); + + return u; + +#else // #if !defined(DETERMINISTIC) + + vdouble u, s, r = d; + vint ql; + + vopmask g = vlt_vo_vd_vd(vabs_vd_vd(d), vcast_vd_d(TRIGRANGEMAX2)); + vdouble dql = vmla_vd_vd_vd_vd(vcast_vd_d(2), + vrint_vd_vd(vmla_vd_vd_vd_vd(d, vcast_vd_d(M_1_PI), vcast_vd_d(-0.5))), + vcast_vd_d(1)); + ql = vrint_vi_vd(dql); + d = vmla_vd_vd_vd_vd(dql, vcast_vd_d(-PI_A2 * 0.5), d); + d = vmla_vd_vd_vd_vd(dql, vcast_vd_d(-PI_B2 * 0.5), d); + + if (!LIKELY(vtestallones_i_vo64(g))) { + vdouble dqh = vtruncate_vd_vd(vmla_vd_vd_vd_vd(r, vcast_vd_d(M_1_PI / (1 << 23)), vcast_vd_d(-M_1_PI / (1 << 24)))); + vint ql2 = vrint_vi_vd(vadd_vd_vd_vd(vmul_vd_vd_vd(r, vcast_vd_d(M_1_PI)), + vmla_vd_vd_vd_vd(dqh, vcast_vd_d(-(1 << 23)), vcast_vd_d(-0.5)))); + dqh = vmul_vd_vd_vd(dqh, vcast_vd_d(1 << 24)); + ql2 = vadd_vi_vi_vi(vadd_vi_vi_vi(ql2, ql2), vcast_vi_i(1)); + vdouble dql = vcast_vd_vi(ql2); + + u = vmla_vd_vd_vd_vd(dqh, vcast_vd_d(-PI_A * 0.5), r); + u = vmla_vd_vd_vd_vd(dql, vcast_vd_d(-PI_A * 0.5), u); + u = vmla_vd_vd_vd_vd(dqh, vcast_vd_d(-PI_B * 0.5), u); + u = vmla_vd_vd_vd_vd(dql, vcast_vd_d(-PI_B * 0.5), u); + u = vmla_vd_vd_vd_vd(dqh, vcast_vd_d(-PI_C * 0.5), u); + u = vmla_vd_vd_vd_vd(dql, vcast_vd_d(-PI_C * 0.5), u); + u = vmla_vd_vd_vd_vd(vadd_vd_vd_vd(dqh, dql), vcast_vd_d(-PI_D * 0.5), u); + + ql = vsel_vi_vo_vi_vi(vcast_vo32_vo64(g), ql, ql2); + d = vsel_vd_vo_vd_vd(g, d, u); + g = vlt_vo_vd_vd(vabs_vd_vd(r), vcast_vd_d(TRIGRANGEMAX)); + + if (!LIKELY(vtestallones_i_vo64(g))) { + ddi_t ddi = rempi(r); + vint ql2 = vand_vi_vi_vi(ddigeti_vi_ddi(ddi), vcast_vi_i(3)); + ql2 = vadd_vi_vi_vi(vadd_vi_vi_vi(ql2, ql2), vsel_vi_vo_vi_vi(vcast_vo32_vo64(vgt_vo_vd_vd(vd2getx_vd_vd2(ddigetdd_vd2_ddi(ddi)), vcast_vd_d(0))), vcast_vi_i(8), vcast_vi_i(7))); + ql2 = vsra_vi_vi_i(ql2, 1); + vopmask o = veq_vo_vi_vi(vand_vi_vi_vi(ddigeti_vi_ddi(ddi), vcast_vi_i(1)), vcast_vi_i(0)); + vdouble y = vsel_vd_vo_vd_vd(vgt_vo_vd_vd(vd2getx_vd_vd2(ddigetdd_vd2_ddi(ddi)), vcast_vd_d(0)), vcast_vd_d(0), vcast_vd_d(-1)); + vdouble2 x = vcast_vd2_vd_vd(vmulsign_vd_vd_vd(vcast_vd_d(-3.141592653589793116 * 0.5), y), + vmulsign_vd_vd_vd(vcast_vd_d(-1.2246467991473532072e-16 * 0.5), y)); + x = ddadd2_vd2_vd2_vd2(ddigetdd_vd2_ddi(ddi), x); + ddi = ddisetdd_ddi_ddi_vd2(ddi, vsel_vd2_vo_vd2_vd2(vcast_vo64_vo32(o), x, ddigetdd_vd2_ddi(ddi))); + u = vadd_vd_vd_vd(vd2getx_vd_vd2(ddigetdd_vd2_ddi(ddi)), vd2gety_vd_vd2(ddigetdd_vd2_ddi(ddi))); + ql = vsel_vi_vo_vi_vi(vcast_vo32_vo64(g), ql, ql2); + d = vsel_vd_vo_vd_vd(g, d, u); + d = vreinterpret_vd_vm(vor_vm_vo64_vm(vor_vo_vo_vo(visinf_vo_vd(r), visnan_vo_vd(r)), vreinterpret_vm_vd(d))); + } + } + + s = vmul_vd_vd_vd(d, d); + + d = vreinterpret_vd_vm(vxor_vm_vm_vm(vand_vm_vo64_vm(vcast_vo64_vo32(veq_vo_vi_vi(vand_vi_vi_vi(ql, vcast_vi_i(2)), vcast_vi_i(0))), vreinterpret_vm_vd(vcast_vd_d(-0.0))), vreinterpret_vm_vd(d))); + + vdouble s2 = vmul_vd_vd_vd(s, s), s4 = vmul_vd_vd_vd(s2, s2); + u = POLY8(s, s2, s4, + -7.97255955009037868891952e-18, + 2.81009972710863200091251e-15, + -7.64712219118158833288484e-13, + 1.60590430605664501629054e-10, + -2.50521083763502045810755e-08, + 2.75573192239198747630416e-06, + -0.000198412698412696162806809, + 0.00833333333333332974823815); + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(-0.166666666666666657414808)); + + u = vadd_vd_vd_vd(vmul_vd_vd_vd(s, vmul_vd_vd_vd(u, d)), d); + + return u; +#endif // #if !defined(DETERMINISTIC) +} + +EXPORT CONST VECTOR_CC vdouble xcos_u1(vdouble d) { +#if !defined(DETERMINISTIC) + vdouble u; + vdouble2 s, t, x; + vint ql; + + if (LIKELY(vtestallones_i_vo64(vlt_vo_vd_vd(vabs_vd_vd(d), vcast_vd_d(TRIGRANGEMAX2))))) { + vdouble dql = vrint_vd_vd(vmla_vd_vd_vd_vd(d, vcast_vd_d(M_1_PI), vcast_vd_d(-0.5))); + dql = vmla_vd_vd_vd_vd(vcast_vd_d(2), dql, vcast_vd_d(1)); + ql = vrint_vi_vd(dql); + s = ddadd2_vd2_vd_vd(d, vmul_vd_vd_vd(dql, vcast_vd_d(-PI_A2*0.5))); + s = ddadd_vd2_vd2_vd(s, vmul_vd_vd_vd(dql, vcast_vd_d(-PI_B2*0.5))); + } else if (LIKELY(vtestallones_i_vo64(vlt_vo_vd_vd(vabs_vd_vd(d), vcast_vd_d(TRIGRANGEMAX))))) { + vdouble dqh = vtruncate_vd_vd(vmla_vd_vd_vd_vd(d, vcast_vd_d(M_1_PI / (1 << 23)), vcast_vd_d(-M_1_PI / (1 << 24)))); + ql = vrint_vi_vd(vadd_vd_vd_vd(vmul_vd_vd_vd(d, vcast_vd_d(M_1_PI)), + vmla_vd_vd_vd_vd(dqh, vcast_vd_d(-(1 << 23)), vcast_vd_d(-0.5)))); + dqh = vmul_vd_vd_vd(dqh, vcast_vd_d(1 << 24)); + ql = vadd_vi_vi_vi(vadd_vi_vi_vi(ql, ql), vcast_vi_i(1)); + const vdouble dql = vcast_vd_vi(ql); + + u = vmla_vd_vd_vd_vd(dqh, vcast_vd_d(-PI_A * 0.5), d); + s = ddadd2_vd2_vd_vd(u, vmul_vd_vd_vd(dql, vcast_vd_d(-PI_A*0.5))); + s = ddadd2_vd2_vd2_vd(s, vmul_vd_vd_vd(dqh, vcast_vd_d(-PI_B*0.5))); + s = ddadd2_vd2_vd2_vd(s, vmul_vd_vd_vd(dql, vcast_vd_d(-PI_B*0.5))); + s = ddadd2_vd2_vd2_vd(s, vmul_vd_vd_vd(dqh, vcast_vd_d(-PI_C*0.5))); + s = ddadd2_vd2_vd2_vd(s, vmul_vd_vd_vd(dql, vcast_vd_d(-PI_C*0.5))); + s = ddadd_vd2_vd2_vd(s, vmul_vd_vd_vd(vadd_vd_vd_vd(dqh, dql), vcast_vd_d(-PI_D*0.5))); + } else { + ddi_t ddi = rempi(d); + ql = vand_vi_vi_vi(ddigeti_vi_ddi(ddi), vcast_vi_i(3)); + ql = vadd_vi_vi_vi(vadd_vi_vi_vi(ql, ql), vsel_vi_vo_vi_vi(vcast_vo32_vo64(vgt_vo_vd_vd(vd2getx_vd_vd2(ddigetdd_vd2_ddi(ddi)), vcast_vd_d(0))), vcast_vi_i(8), vcast_vi_i(7))); + ql = vsra_vi_vi_i(ql, 1); + vopmask o = veq_vo_vi_vi(vand_vi_vi_vi(ddigeti_vi_ddi(ddi), vcast_vi_i(1)), vcast_vi_i(0)); + vdouble y = vsel_vd_vo_vd_vd(vgt_vo_vd_vd(vd2getx_vd_vd2(ddigetdd_vd2_ddi(ddi)), vcast_vd_d(0)), vcast_vd_d(0), vcast_vd_d(-1)); + vdouble2 x = vcast_vd2_vd_vd(vmulsign_vd_vd_vd(vcast_vd_d(-3.141592653589793116 * 0.5), y), + vmulsign_vd_vd_vd(vcast_vd_d(-1.2246467991473532072e-16 * 0.5), y)); + x = ddadd2_vd2_vd2_vd2(ddigetdd_vd2_ddi(ddi), x); + ddi = ddisetdd_ddi_ddi_vd2(ddi, vsel_vd2_vo_vd2_vd2(vcast_vo64_vo32(o), x, ddigetdd_vd2_ddi(ddi))); + s = ddnormalize_vd2_vd2(ddigetdd_vd2_ddi(ddi)); + s = vd2setx_vd2_vd2_vd(s, vreinterpret_vd_vm(vor_vm_vo64_vm(vor_vo_vo_vo(visinf_vo_vd(d), visnan_vo_vd(d)), vreinterpret_vm_vd(vd2getx_vd_vd2(s))))); + } + + t = s; + s = ddsqu_vd2_vd2(s); + + vdouble s2 = vmul_vd_vd_vd(vd2getx_vd_vd2(s), vd2getx_vd_vd2(s)), s4 = vmul_vd_vd_vd(s2, s2); + u = POLY6(vd2getx_vd_vd2(s), s2, s4, + 2.72052416138529567917983e-15, + -7.6429259411395447190023e-13, + 1.60589370117277896211623e-10, + -2.5052106814843123359368e-08, + 2.75573192104428224777379e-06, + -0.000198412698412046454654947); + u = vmla_vd_vd_vd_vd(u, vd2getx_vd_vd2(s), vcast_vd_d(0.00833333333333318056201922)); + + x = ddadd_vd2_vd_vd2(vcast_vd_d(1), ddmul_vd2_vd2_vd2(ddadd_vd2_vd_vd(vcast_vd_d(-0.166666666666666657414808), vmul_vd_vd_vd(u, vd2getx_vd_vd2(s))), s)); + u = ddmul_vd_vd2_vd2(t, x); + + u = vreinterpret_vd_vm(vxor_vm_vm_vm(vand_vm_vo64_vm(vcast_vo64_vo32(veq_vo_vi_vi(vand_vi_vi_vi(ql, vcast_vi_i(2)), vcast_vi_i(0))), vreinterpret_vm_vd(vcast_vd_d(-0.0))), vreinterpret_vm_vd(u))); + + return u; + +#else // #if !defined(DETERMINISTIC) + + vdouble u; + vdouble2 s, t, x; + vint ql; + + vopmask g = vlt_vo_vd_vd(vabs_vd_vd(d), vcast_vd_d(TRIGRANGEMAX2)); + vdouble dql = vrint_vd_vd(vmla_vd_vd_vd_vd(d, vcast_vd_d(M_1_PI), vcast_vd_d(-0.5))); + dql = vmla_vd_vd_vd_vd(vcast_vd_d(2), dql, vcast_vd_d(1)); + ql = vrint_vi_vd(dql); + x = ddadd2_vd2_vd_vd(d, vmul_vd_vd_vd(dql, vcast_vd_d(-PI_A2*0.5))); + x = ddadd_vd2_vd2_vd(x, vmul_vd_vd_vd(dql, vcast_vd_d(-PI_B2*0.5))); + + if (!LIKELY(vtestallones_i_vo64(g))) { + vdouble dqh = vtruncate_vd_vd(vmla_vd_vd_vd_vd(d, vcast_vd_d(M_1_PI / (1 << 23)), vcast_vd_d(-M_1_PI / (1 << 24)))); + vint ql2 = vrint_vi_vd(vadd_vd_vd_vd(vmul_vd_vd_vd(d, vcast_vd_d(M_1_PI)), + vmla_vd_vd_vd_vd(dqh, vcast_vd_d(-(1 << 23)), vcast_vd_d(-0.5)))); + dqh = vmul_vd_vd_vd(dqh, vcast_vd_d(1 << 24)); + ql2 = vadd_vi_vi_vi(vadd_vi_vi_vi(ql2, ql2), vcast_vi_i(1)); + const vdouble dql = vcast_vd_vi(ql2); + + u = vmla_vd_vd_vd_vd(dqh, vcast_vd_d(-PI_A * 0.5), d); + s = ddadd2_vd2_vd_vd(u, vmul_vd_vd_vd(dql, vcast_vd_d(-PI_A*0.5))); + s = ddadd2_vd2_vd2_vd(s, vmul_vd_vd_vd(dqh, vcast_vd_d(-PI_B*0.5))); + s = ddadd2_vd2_vd2_vd(s, vmul_vd_vd_vd(dql, vcast_vd_d(-PI_B*0.5))); + s = ddadd2_vd2_vd2_vd(s, vmul_vd_vd_vd(dqh, vcast_vd_d(-PI_C*0.5))); + s = ddadd2_vd2_vd2_vd(s, vmul_vd_vd_vd(dql, vcast_vd_d(-PI_C*0.5))); + s = ddadd_vd2_vd2_vd(s, vmul_vd_vd_vd(vadd_vd_vd_vd(dqh, dql), vcast_vd_d(-PI_D*0.5))); + + ql = vsel_vi_vo_vi_vi(vcast_vo32_vo64(g), ql, ql2); + x = vsel_vd2_vo_vd2_vd2(g, x, s); + g = vlt_vo_vd_vd(vabs_vd_vd(d), vcast_vd_d(TRIGRANGEMAX)); + + if (!LIKELY(vtestallones_i_vo64(g))) { + ddi_t ddi = rempi(d); + vint ql2 = vand_vi_vi_vi(ddigeti_vi_ddi(ddi), vcast_vi_i(3)); + ql2 = vadd_vi_vi_vi(vadd_vi_vi_vi(ql2, ql2), vsel_vi_vo_vi_vi(vcast_vo32_vo64(vgt_vo_vd_vd(vd2getx_vd_vd2(ddigetdd_vd2_ddi(ddi)), vcast_vd_d(0))), vcast_vi_i(8), vcast_vi_i(7))); + ql2 = vsra_vi_vi_i(ql2, 1); + vopmask o = veq_vo_vi_vi(vand_vi_vi_vi(ddigeti_vi_ddi(ddi), vcast_vi_i(1)), vcast_vi_i(0)); + vdouble y = vsel_vd_vo_vd_vd(vgt_vo_vd_vd(vd2getx_vd_vd2(ddigetdd_vd2_ddi(ddi)), vcast_vd_d(0)), vcast_vd_d(0), vcast_vd_d(-1)); + vdouble2 t = vcast_vd2_vd_vd(vmulsign_vd_vd_vd(vcast_vd_d(-3.141592653589793116 * 0.5), y), + vmulsign_vd_vd_vd(vcast_vd_d(-1.2246467991473532072e-16 * 0.5), y)); + t = ddadd2_vd2_vd2_vd2(ddigetdd_vd2_ddi(ddi), t); + ddi = ddisetdd_ddi_ddi_vd2(ddi, vsel_vd2_vo_vd2_vd2(vcast_vo64_vo32(o), t, ddigetdd_vd2_ddi(ddi))); + s = ddnormalize_vd2_vd2(ddigetdd_vd2_ddi(ddi)); + ql = vsel_vi_vo_vi_vi(vcast_vo32_vo64(g), ql, ql2); + x = vsel_vd2_vo_vd2_vd2(g, x, s); + x = vd2setx_vd2_vd2_vd(x, vreinterpret_vd_vm(vor_vm_vo64_vm(vor_vo_vo_vo(visinf_vo_vd(d), visnan_vo_vd(d)), vreinterpret_vm_vd(vd2getx_vd_vd2(x))))); + } + } + + t = x; + s = ddsqu_vd2_vd2(x); + + vdouble s2 = vmul_vd_vd_vd(vd2getx_vd_vd2(s), vd2getx_vd_vd2(s)), s4 = vmul_vd_vd_vd(s2, s2); + u = POLY6(vd2getx_vd_vd2(s), s2, s4, + 2.72052416138529567917983e-15, + -7.6429259411395447190023e-13, + 1.60589370117277896211623e-10, + -2.5052106814843123359368e-08, + 2.75573192104428224777379e-06, + -0.000198412698412046454654947); + u = vmla_vd_vd_vd_vd(u, vd2getx_vd_vd2(s), vcast_vd_d(0.00833333333333318056201922)); + + x = ddadd_vd2_vd_vd2(vcast_vd_d(1), ddmul_vd2_vd2_vd2(ddadd_vd2_vd_vd(vcast_vd_d(-0.166666666666666657414808), vmul_vd_vd_vd(u, vd2getx_vd_vd2(s))), s)); + u = ddmul_vd_vd2_vd2(t, x); + + u = vreinterpret_vd_vm(vxor_vm_vm_vm(vand_vm_vo64_vm(vcast_vo64_vo32(veq_vo_vi_vi(vand_vi_vi_vi(ql, vcast_vi_i(2)), vcast_vi_i(0))), vreinterpret_vm_vd(vcast_vd_d(-0.0))), vreinterpret_vm_vd(u))); + + return u; +#endif // #if !defined(DETERMINISTIC) +} + +#ifdef ENABLE_GNUABI +#define TYPE2_FUNCATR static INLINE CONST +#define TYPE6_FUNCATR static INLINE CONST +#define SQRTU05_FUNCATR static INLINE CONST +#define XSINCOS sincosk +#define XSINCOS_U1 sincosk_u1 +#define XSINCOSPI_U05 sincospik_u05 +#define XSINCOSPI_U35 sincospik_u35 +#define XMODF modfk +#else +#define TYPE2_FUNCATR EXPORT +#define TYPE6_FUNCATR EXPORT CONST +#define SQRTU05_FUNCATR EXPORT CONST +#define XSINCOS xsincos +#define XSINCOS_U1 xsincos_u1 +#define XSINCOSPI_U05 xsincospi_u05 +#define XSINCOSPI_U35 xsincospi_u35 +#define XMODF xmodf +#endif + +TYPE2_FUNCATR VECTOR_CC vdouble2 XSINCOS(vdouble d) { +#if !defined(DETERMINISTIC) + vopmask o; + vdouble u, t, rx, ry, s; + vdouble2 r; + vint ql; + + if (LIKELY(vtestallones_i_vo64(vlt_vo_vd_vd(vabs_vd_vd(d), vcast_vd_d(TRIGRANGEMAX2))))) { + vdouble dql = vrint_vd_vd(vmul_vd_vd_vd(d, vcast_vd_d(2 * M_1_PI))); + ql = vrint_vi_vd(dql); + s = vmla_vd_vd_vd_vd(dql, vcast_vd_d(-PI_A2 * 0.5), d); + s = vmla_vd_vd_vd_vd(dql, vcast_vd_d(-PI_B2 * 0.5), s); + } else if (LIKELY(vtestallones_i_vo64(vlt_vo_vd_vd(vabs_vd_vd(d), vcast_vd_d(TRIGRANGEMAX))))) { + vdouble dqh = vtruncate_vd_vd(vmul_vd_vd_vd(d, vcast_vd_d(2*M_1_PI / (1 << 24)))); + dqh = vmul_vd_vd_vd(dqh, vcast_vd_d(1 << 24)); + vdouble dql = vrint_vd_vd(vsub_vd_vd_vd(vmul_vd_vd_vd(d, vcast_vd_d(2*M_1_PI)), dqh)); + ql = vrint_vi_vd(dql); + + s = vmla_vd_vd_vd_vd(dqh, vcast_vd_d(-PI_A * 0.5), d); + s = vmla_vd_vd_vd_vd(dql, vcast_vd_d(-PI_A * 0.5), s); + s = vmla_vd_vd_vd_vd(dqh, vcast_vd_d(-PI_B * 0.5), s); + s = vmla_vd_vd_vd_vd(dql, vcast_vd_d(-PI_B * 0.5), s); + s = vmla_vd_vd_vd_vd(dqh, vcast_vd_d(-PI_C * 0.5), s); + s = vmla_vd_vd_vd_vd(dql, vcast_vd_d(-PI_C * 0.5), s); + s = vmla_vd_vd_vd_vd(vadd_vd_vd_vd(dqh, dql), vcast_vd_d(-PI_D * 0.5), s); + } else { + ddi_t ddi = rempi(d); + ql = ddigeti_vi_ddi(ddi); + s = vadd_vd_vd_vd(vd2getx_vd_vd2(ddigetdd_vd2_ddi(ddi)), vd2gety_vd_vd2(ddigetdd_vd2_ddi(ddi))); + s = vreinterpret_vd_vm(vor_vm_vo64_vm(vor_vo_vo_vo(visinf_vo_vd(d), visnan_vo_vd(d)), vreinterpret_vm_vd(s))); + } + + t = s; + + s = vmul_vd_vd_vd(s, s); + + u = vcast_vd_d(1.58938307283228937328511e-10); + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(-2.50506943502539773349318e-08)); + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(2.75573131776846360512547e-06)); + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(-0.000198412698278911770864914)); + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(0.0083333333333191845961746)); + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(-0.166666666666666130709393)); + + rx = vmla_vd_vd_vd_vd(vmul_vd_vd_vd(u, s), t, t); + rx = vsel_vd_vo_vd_vd(visnegzero_vo_vd(d), vcast_vd_d(-0.0), rx); + + u = vcast_vd_d(-1.13615350239097429531523e-11); + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(2.08757471207040055479366e-09)); + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(-2.75573144028847567498567e-07)); + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(2.48015872890001867311915e-05)); + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(-0.00138888888888714019282329)); + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(0.0416666666666665519592062)); + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(-0.5)); + + ry = vmla_vd_vd_vd_vd(s, u, vcast_vd_d(1)); + + o = vcast_vo64_vo32(veq_vo_vi_vi(vand_vi_vi_vi(ql, vcast_vi_i(1)), vcast_vi_i(0))); + r = vd2setxy_vd2_vd_vd(vsel_vd_vo_vd_vd(o, rx, ry), vsel_vd_vo_vd_vd(o, ry, rx)); + + o = vcast_vo64_vo32(veq_vo_vi_vi(vand_vi_vi_vi(ql, vcast_vi_i(2)), vcast_vi_i(2))); + r = vd2setx_vd2_vd2_vd(r, vreinterpret_vd_vm(vxor_vm_vm_vm(vand_vm_vo64_vm(o, vreinterpret_vm_vd(vcast_vd_d(-0.0))), vreinterpret_vm_vd(vd2getx_vd_vd2(r))))); + + o = vcast_vo64_vo32(veq_vo_vi_vi(vand_vi_vi_vi(vadd_vi_vi_vi(ql, vcast_vi_i(1)), vcast_vi_i(2)), vcast_vi_i(2))); + r = vd2sety_vd2_vd2_vd(r, vreinterpret_vd_vm(vxor_vm_vm_vm(vand_vm_vo64_vm(o, vreinterpret_vm_vd(vcast_vd_d(-0.0))), vreinterpret_vm_vd(vd2gety_vd_vd2(r))))); + + return r; + +#else // #if !defined(DETERMINISTIC) + + vopmask o; + vdouble u, t, rx, ry, s = d; + vdouble2 r; + vint ql; + + vdouble dql = vrint_vd_vd(vmul_vd_vd_vd(s, vcast_vd_d(2 * M_1_PI))); + ql = vrint_vi_vd(dql); + s = vmla_vd_vd_vd_vd(dql, vcast_vd_d(-PI_A2 * 0.5), s); + s = vmla_vd_vd_vd_vd(dql, vcast_vd_d(-PI_B2 * 0.5), s); + vopmask g = vlt_vo_vd_vd(vabs_vd_vd(d), vcast_vd_d(TRIGRANGEMAX2)); + + if (!LIKELY(vtestallones_i_vo64(g))) { + vdouble dqh = vtruncate_vd_vd(vmul_vd_vd_vd(d, vcast_vd_d(2*M_1_PI / (1 << 24)))); + dqh = vmul_vd_vd_vd(dqh, vcast_vd_d(1 << 24)); + vdouble dql = vrint_vd_vd(vsub_vd_vd_vd(vmul_vd_vd_vd(d, vcast_vd_d(2*M_1_PI)), dqh)); + + u = vmla_vd_vd_vd_vd(dqh, vcast_vd_d(-PI_A * 0.5), d); + u = vmla_vd_vd_vd_vd(dql, vcast_vd_d(-PI_A * 0.5), u); + u = vmla_vd_vd_vd_vd(dqh, vcast_vd_d(-PI_B * 0.5), u); + u = vmla_vd_vd_vd_vd(dql, vcast_vd_d(-PI_B * 0.5), u); + u = vmla_vd_vd_vd_vd(dqh, vcast_vd_d(-PI_C * 0.5), u); + u = vmla_vd_vd_vd_vd(dql, vcast_vd_d(-PI_C * 0.5), u); + u = vmla_vd_vd_vd_vd(vadd_vd_vd_vd(dqh, dql), vcast_vd_d(-PI_D * 0.5), u); + + ql = vsel_vi_vo_vi_vi(vcast_vo32_vo64(g), ql, vrint_vi_vd(dql)); + s = vsel_vd_vo_vd_vd(g, s, u); + g = vlt_vo_vd_vd(vabs_vd_vd(d), vcast_vd_d(TRIGRANGEMAX)); + + if (!LIKELY(vtestallones_i_vo64(g))) { + ddi_t ddi = rempi(d); + u = vadd_vd_vd_vd(vd2getx_vd_vd2(ddigetdd_vd2_ddi(ddi)), vd2gety_vd_vd2(ddigetdd_vd2_ddi(ddi))); + u = vreinterpret_vd_vm(vor_vm_vo64_vm(vor_vo_vo_vo(visinf_vo_vd(d), visnan_vo_vd(d)), vreinterpret_vm_vd(u))); + + ql = vsel_vi_vo_vi_vi(vcast_vo32_vo64(g), ql, ddigeti_vi_ddi(ddi)); + s = vsel_vd_vo_vd_vd(g, s, u); + } + } + + t = s; + + s = vmul_vd_vd_vd(s, s); + + u = vcast_vd_d(1.58938307283228937328511e-10); + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(-2.50506943502539773349318e-08)); + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(2.75573131776846360512547e-06)); + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(-0.000198412698278911770864914)); + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(0.0083333333333191845961746)); + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(-0.166666666666666130709393)); + + rx = vmla_vd_vd_vd_vd(vmul_vd_vd_vd(u, s), t, t); + rx = vsel_vd_vo_vd_vd(visnegzero_vo_vd(d), vcast_vd_d(-0.0), rx); + + u = vcast_vd_d(-1.13615350239097429531523e-11); + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(2.08757471207040055479366e-09)); + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(-2.75573144028847567498567e-07)); + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(2.48015872890001867311915e-05)); + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(-0.00138888888888714019282329)); + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(0.0416666666666665519592062)); + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(-0.5)); + + ry = vmla_vd_vd_vd_vd(s, u, vcast_vd_d(1)); + + o = vcast_vo64_vo32(veq_vo_vi_vi(vand_vi_vi_vi(ql, vcast_vi_i(1)), vcast_vi_i(0))); + r = vd2setxy_vd2_vd_vd(vsel_vd_vo_vd_vd(o, rx, ry), vsel_vd_vo_vd_vd(o, ry, rx)); + + o = vcast_vo64_vo32(veq_vo_vi_vi(vand_vi_vi_vi(ql, vcast_vi_i(2)), vcast_vi_i(2))); + r = vd2setx_vd2_vd2_vd(r, vreinterpret_vd_vm(vxor_vm_vm_vm(vand_vm_vo64_vm(o, vreinterpret_vm_vd(vcast_vd_d(-0.0))), vreinterpret_vm_vd(vd2getx_vd_vd2(r))))); + + o = vcast_vo64_vo32(veq_vo_vi_vi(vand_vi_vi_vi(vadd_vi_vi_vi(ql, vcast_vi_i(1)), vcast_vi_i(2)), vcast_vi_i(2))); + r = vd2sety_vd2_vd2_vd(r, vreinterpret_vd_vm(vxor_vm_vm_vm(vand_vm_vo64_vm(o, vreinterpret_vm_vd(vcast_vd_d(-0.0))), vreinterpret_vm_vd(vd2gety_vd_vd2(r))))); + + return r; +#endif // #if !defined(DETERMINISTIC) +} + +TYPE2_FUNCATR VECTOR_CC vdouble2 XSINCOS_U1(vdouble d) { +#if !defined(DETERMINISTIC) + vopmask o; + vdouble u, rx, ry; + vdouble2 r, s, t, x; + vint ql; + + if (LIKELY(vtestallones_i_vo64(vlt_vo_vd_vd(vabs_vd_vd(d), vcast_vd_d(TRIGRANGEMAX2))))) { + const vdouble dql = vrint_vd_vd(vmul_vd_vd_vd(d, vcast_vd_d(2 * M_1_PI))); + ql = vrint_vi_vd(dql); + u = vmla_vd_vd_vd_vd(dql, vcast_vd_d(-PI_A2*0.5), d); + s = ddadd_vd2_vd_vd (u, vmul_vd_vd_vd(dql, vcast_vd_d(-PI_B2*0.5))); + } else if (LIKELY(vtestallones_i_vo64(vlt_vo_vd_vd(vabs_vd_vd(d), vcast_vd_d(TRIGRANGEMAX))))) { + vdouble dqh = vtruncate_vd_vd(vmul_vd_vd_vd(d, vcast_vd_d(2*M_1_PI / (1 << 24)))); + dqh = vmul_vd_vd_vd(dqh, vcast_vd_d(1 << 24)); + const vdouble dql = vrint_vd_vd(vsub_vd_vd_vd(vmul_vd_vd_vd(d, vcast_vd_d(2*M_1_PI)), dqh)); + ql = vrint_vi_vd(dql); + + u = vmla_vd_vd_vd_vd(dqh, vcast_vd_d(-PI_A * 0.5), d); + s = ddadd_vd2_vd_vd(u, vmul_vd_vd_vd(dql, vcast_vd_d(-PI_A*0.5))); + s = ddadd2_vd2_vd2_vd(s, vmul_vd_vd_vd(dqh, vcast_vd_d(-PI_B*0.5))); + s = ddadd2_vd2_vd2_vd(s, vmul_vd_vd_vd(dql, vcast_vd_d(-PI_B*0.5))); + s = ddadd2_vd2_vd2_vd(s, vmul_vd_vd_vd(dqh, vcast_vd_d(-PI_C*0.5))); + s = ddadd2_vd2_vd2_vd(s, vmul_vd_vd_vd(dql, vcast_vd_d(-PI_C*0.5))); + s = ddadd_vd2_vd2_vd(s, vmul_vd_vd_vd(vadd_vd_vd_vd(dqh, dql), vcast_vd_d(-PI_D*0.5))); + } else { + ddi_t ddi = rempi(d); + ql = ddigeti_vi_ddi(ddi); + s = ddigetdd_vd2_ddi(ddi); + o = vor_vo_vo_vo(visinf_vo_vd(d), visnan_vo_vd(d)); + s = vd2setxy_vd2_vd_vd(vreinterpret_vd_vm(vor_vm_vo64_vm(o, vreinterpret_vm_vd(vd2getx_vd_vd2(s)))), + vreinterpret_vd_vm(vor_vm_vo64_vm(o, vreinterpret_vm_vd(vd2gety_vd_vd2(s))))); + } + + t = s; + + s = vd2setx_vd2_vd2_vd(s, ddsqu_vd_vd2(s)); + + u = vcast_vd_d(1.58938307283228937328511e-10); + u = vmla_vd_vd_vd_vd(u, vd2getx_vd_vd2(s), vcast_vd_d(-2.50506943502539773349318e-08)); + u = vmla_vd_vd_vd_vd(u, vd2getx_vd_vd2(s), vcast_vd_d(2.75573131776846360512547e-06)); + u = vmla_vd_vd_vd_vd(u, vd2getx_vd_vd2(s), vcast_vd_d(-0.000198412698278911770864914)); + u = vmla_vd_vd_vd_vd(u, vd2getx_vd_vd2(s), vcast_vd_d(0.0083333333333191845961746)); + u = vmla_vd_vd_vd_vd(u, vd2getx_vd_vd2(s), vcast_vd_d(-0.166666666666666130709393)); + + u = vmul_vd_vd_vd(u, vmul_vd_vd_vd(vd2getx_vd_vd2(s), vd2getx_vd_vd2(t))); + + x = ddadd_vd2_vd2_vd(t, u); + rx = vadd_vd_vd_vd(vd2getx_vd_vd2(x), vd2gety_vd_vd2(x)); + + rx = vsel_vd_vo_vd_vd(visnegzero_vo_vd(d), vcast_vd_d(-0.0), rx); + + u = vcast_vd_d(-1.13615350239097429531523e-11); + u = vmla_vd_vd_vd_vd(u, vd2getx_vd_vd2(s), vcast_vd_d(2.08757471207040055479366e-09)); + u = vmla_vd_vd_vd_vd(u, vd2getx_vd_vd2(s), vcast_vd_d(-2.75573144028847567498567e-07)); + u = vmla_vd_vd_vd_vd(u, vd2getx_vd_vd2(s), vcast_vd_d(2.48015872890001867311915e-05)); + u = vmla_vd_vd_vd_vd(u, vd2getx_vd_vd2(s), vcast_vd_d(-0.00138888888888714019282329)); + u = vmla_vd_vd_vd_vd(u, vd2getx_vd_vd2(s), vcast_vd_d(0.0416666666666665519592062)); + u = vmla_vd_vd_vd_vd(u, vd2getx_vd_vd2(s), vcast_vd_d(-0.5)); + + x = ddadd_vd2_vd_vd2(vcast_vd_d(1), ddmul_vd2_vd_vd(vd2getx_vd_vd2(s), u)); + ry = vadd_vd_vd_vd(vd2getx_vd_vd2(x), vd2gety_vd_vd2(x)); + + o = vcast_vo64_vo32(veq_vo_vi_vi(vand_vi_vi_vi(ql, vcast_vi_i(1)), vcast_vi_i(0))); + r = vd2setxy_vd2_vd_vd(vsel_vd_vo_vd_vd(o, rx, ry), vsel_vd_vo_vd_vd(o, ry, rx)); + + o = vcast_vo64_vo32(veq_vo_vi_vi(vand_vi_vi_vi(ql, vcast_vi_i(2)), vcast_vi_i(2))); + r = vd2setx_vd2_vd2_vd(r, vreinterpret_vd_vm(vxor_vm_vm_vm(vand_vm_vo64_vm(o, vreinterpret_vm_vd(vcast_vd_d(-0.0))), vreinterpret_vm_vd(vd2getx_vd_vd2(r))))); + + o = vcast_vo64_vo32(veq_vo_vi_vi(vand_vi_vi_vi(vadd_vi_vi_vi(ql, vcast_vi_i(1)), vcast_vi_i(2)), vcast_vi_i(2))); + r = vd2sety_vd2_vd2_vd(r, vreinterpret_vd_vm(vxor_vm_vm_vm(vand_vm_vo64_vm(o, vreinterpret_vm_vd(vcast_vd_d(-0.0))), vreinterpret_vm_vd(vd2gety_vd_vd2(r))))); + + return r; + +#else // #if !defined(DETERMINISTIC) + + vopmask o; + vdouble u, rx, ry; + vdouble2 r, s, t, x; + vint ql; + + const vdouble dql = vrint_vd_vd(vmul_vd_vd_vd(d, vcast_vd_d(2 * M_1_PI))); + ql = vrint_vi_vd(dql); + u = vmla_vd_vd_vd_vd(dql, vcast_vd_d(-PI_A2*0.5), d); + s = ddadd_vd2_vd_vd (u, vmul_vd_vd_vd(dql, vcast_vd_d(-PI_B2*0.5))); + vopmask g = vlt_vo_vd_vd(vabs_vd_vd(d), vcast_vd_d(TRIGRANGEMAX2)); + + if (!LIKELY(vtestallones_i_vo64(g))) { + vdouble dqh = vtruncate_vd_vd(vmul_vd_vd_vd(d, vcast_vd_d(2*M_1_PI / (1 << 24)))); + dqh = vmul_vd_vd_vd(dqh, vcast_vd_d(1 << 24)); + const vdouble dql = vrint_vd_vd(vsub_vd_vd_vd(vmul_vd_vd_vd(d, vcast_vd_d(2*M_1_PI)), dqh)); + + u = vmla_vd_vd_vd_vd(dqh, vcast_vd_d(-PI_A * 0.5), d); + x = ddadd_vd2_vd_vd(u, vmul_vd_vd_vd(dql, vcast_vd_d(-PI_A*0.5))); + x = ddadd2_vd2_vd2_vd(x, vmul_vd_vd_vd(dqh, vcast_vd_d(-PI_B*0.5))); + x = ddadd2_vd2_vd2_vd(x, vmul_vd_vd_vd(dql, vcast_vd_d(-PI_B*0.5))); + x = ddadd2_vd2_vd2_vd(x, vmul_vd_vd_vd(dqh, vcast_vd_d(-PI_C*0.5))); + x = ddadd2_vd2_vd2_vd(x, vmul_vd_vd_vd(dql, vcast_vd_d(-PI_C*0.5))); + x = ddadd_vd2_vd2_vd(x, vmul_vd_vd_vd(vadd_vd_vd_vd(dqh, dql), vcast_vd_d(-PI_D*0.5))); + + ql = vsel_vi_vo_vi_vi(vcast_vo32_vo64(g), ql, vrint_vi_vd(dql)); + s = vsel_vd2_vo_vd2_vd2(g, s, x); + g = vlt_vo_vd_vd(vabs_vd_vd(d), vcast_vd_d(TRIGRANGEMAX)); + + if (!LIKELY(vtestallones_i_vo64(g))) { + ddi_t ddi = rempi(d); + x = ddigetdd_vd2_ddi(ddi); + o = vor_vo_vo_vo(visinf_vo_vd(d), visnan_vo_vd(d)); + x = vd2setx_vd2_vd2_vd(x, vreinterpret_vd_vm(vor_vm_vo64_vm(o, vreinterpret_vm_vd(vd2getx_vd_vd2(x))))); + x = vd2sety_vd2_vd2_vd(x, vreinterpret_vd_vm(vor_vm_vo64_vm(o, vreinterpret_vm_vd(vd2gety_vd_vd2(x))))); + + ql = vsel_vi_vo_vi_vi(vcast_vo32_vo64(g), ql, ddigeti_vi_ddi(ddi)); + s = vsel_vd2_vo_vd2_vd2(g, s, x); + } + } + + t = s; + + s = vd2setx_vd2_vd2_vd(s, ddsqu_vd_vd2(s)); + + u = vcast_vd_d(1.58938307283228937328511e-10); + u = vmla_vd_vd_vd_vd(u, vd2getx_vd_vd2(s), vcast_vd_d(-2.50506943502539773349318e-08)); + u = vmla_vd_vd_vd_vd(u, vd2getx_vd_vd2(s), vcast_vd_d(2.75573131776846360512547e-06)); + u = vmla_vd_vd_vd_vd(u, vd2getx_vd_vd2(s), vcast_vd_d(-0.000198412698278911770864914)); + u = vmla_vd_vd_vd_vd(u, vd2getx_vd_vd2(s), vcast_vd_d(0.0083333333333191845961746)); + u = vmla_vd_vd_vd_vd(u, vd2getx_vd_vd2(s), vcast_vd_d(-0.166666666666666130709393)); + + u = vmul_vd_vd_vd(u, vmul_vd_vd_vd(vd2getx_vd_vd2(s), vd2getx_vd_vd2(t))); + + x = ddadd_vd2_vd2_vd(t, u); + rx = vadd_vd_vd_vd(vd2getx_vd_vd2(x), vd2gety_vd_vd2(x)); + + rx = vsel_vd_vo_vd_vd(visnegzero_vo_vd(d), vcast_vd_d(-0.0), rx); + + u = vcast_vd_d(-1.13615350239097429531523e-11); + u = vmla_vd_vd_vd_vd(u, vd2getx_vd_vd2(s), vcast_vd_d(2.08757471207040055479366e-09)); + u = vmla_vd_vd_vd_vd(u, vd2getx_vd_vd2(s), vcast_vd_d(-2.75573144028847567498567e-07)); + u = vmla_vd_vd_vd_vd(u, vd2getx_vd_vd2(s), vcast_vd_d(2.48015872890001867311915e-05)); + u = vmla_vd_vd_vd_vd(u, vd2getx_vd_vd2(s), vcast_vd_d(-0.00138888888888714019282329)); + u = vmla_vd_vd_vd_vd(u, vd2getx_vd_vd2(s), vcast_vd_d(0.0416666666666665519592062)); + u = vmla_vd_vd_vd_vd(u, vd2getx_vd_vd2(s), vcast_vd_d(-0.5)); + + x = ddadd_vd2_vd_vd2(vcast_vd_d(1), ddmul_vd2_vd_vd(vd2getx_vd_vd2(s), u)); + ry = vadd_vd_vd_vd(vd2getx_vd_vd2(x), vd2gety_vd_vd2(x)); + + o = vcast_vo64_vo32(veq_vo_vi_vi(vand_vi_vi_vi(ql, vcast_vi_i(1)), vcast_vi_i(0))); + r = vd2setxy_vd2_vd_vd(vsel_vd_vo_vd_vd(o, rx, ry), vsel_vd_vo_vd_vd(o, ry, rx)); + + o = vcast_vo64_vo32(veq_vo_vi_vi(vand_vi_vi_vi(ql, vcast_vi_i(2)), vcast_vi_i(2))); + r = vd2setx_vd2_vd2_vd(r, vreinterpret_vd_vm(vxor_vm_vm_vm(vand_vm_vo64_vm(o, vreinterpret_vm_vd(vcast_vd_d(-0.0))), vreinterpret_vm_vd(vd2getx_vd_vd2(r))))); + + o = vcast_vo64_vo32(veq_vo_vi_vi(vand_vi_vi_vi(vadd_vi_vi_vi(ql, vcast_vi_i(1)), vcast_vi_i(2)), vcast_vi_i(2))); + r = vd2sety_vd2_vd2_vd(r, vreinterpret_vd_vm(vxor_vm_vm_vm(vand_vm_vo64_vm(o, vreinterpret_vm_vd(vcast_vd_d(-0.0))), vreinterpret_vm_vd(vd2gety_vd_vd2(r))))); + + return r; +#endif // #if !defined(DETERMINISTIC) +} + +#if !defined(DETERMINISTIC) +TYPE2_FUNCATR VECTOR_CC vdouble2 XSINCOSPI_U05(vdouble d) { + vopmask o; + vdouble u, s, t, rx, ry; + vdouble2 r, x, s2; + + u = vmul_vd_vd_vd(d, vcast_vd_d(4.0)); + vint q = vtruncate_vi_vd(u); + q = vand_vi_vi_vi(vadd_vi_vi_vi(q, vxor_vi_vi_vi(vsrl_vi_vi_i(q, 31), vcast_vi_i(1))), vcast_vi_i(~1)); + s = vsub_vd_vd_vd(u, vcast_vd_vi(q)); + + t = s; + s = vmul_vd_vd_vd(s, s); + s2 = ddmul_vd2_vd_vd(t, t); + + // + + u = vcast_vd_d(-2.02461120785182399295868e-14); + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(6.94821830580179461327784e-12)); + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(-1.75724749952853179952664e-09)); + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(3.13361688966868392878422e-07)); + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(-3.6576204182161551920361e-05)); + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(0.00249039457019271850274356)); + x = ddadd2_vd2_vd_vd2(vmul_vd_vd_vd(u, s), vcast_vd2_d_d(-0.0807455121882807852484731, 3.61852475067037104849987e-18)); + x = ddadd2_vd2_vd2_vd2(ddmul_vd2_vd2_vd2(s2, x), vcast_vd2_d_d(0.785398163397448278999491, 3.06287113727155002607105e-17)); + + x = ddmul_vd2_vd2_vd(x, t); + rx = vadd_vd_vd_vd(vd2getx_vd_vd2(x), vd2gety_vd_vd2(x)); + + rx = vsel_vd_vo_vd_vd(visnegzero_vo_vd(d), vcast_vd_d(-0.0), rx); + + // + + u = vcast_vd_d(9.94480387626843774090208e-16); + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(-3.89796226062932799164047e-13)); + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(1.15011582539996035266901e-10)); + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(-2.4611369501044697495359e-08)); + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(3.59086044859052754005062e-06)); + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(-0.000325991886927389905997954)); + x = ddadd2_vd2_vd_vd2(vmul_vd_vd_vd(u, s), vcast_vd2_d_d(0.0158543442438155018914259, -1.04693272280631521908845e-18)); + x = ddadd2_vd2_vd2_vd2(ddmul_vd2_vd2_vd2(s2, x), vcast_vd2_d_d(-0.308425137534042437259529, -1.95698492133633550338345e-17)); + + x = ddadd2_vd2_vd2_vd(ddmul_vd2_vd2_vd2(x, s2), vcast_vd_d(1)); + ry = vadd_vd_vd_vd(vd2getx_vd_vd2(x), vd2gety_vd_vd2(x)); + + // + + o = vcast_vo64_vo32(veq_vo_vi_vi(vand_vi_vi_vi(q, vcast_vi_i(2)), vcast_vi_i(0))); + r = vd2setxy_vd2_vd_vd(vsel_vd_vo_vd_vd(o, rx, ry), vsel_vd_vo_vd_vd(o, ry, rx)); + + o = vcast_vo64_vo32(veq_vo_vi_vi(vand_vi_vi_vi(q, vcast_vi_i(4)), vcast_vi_i(4))); + r = vd2setx_vd2_vd2_vd(r, vreinterpret_vd_vm(vxor_vm_vm_vm(vand_vm_vo64_vm(o, vreinterpret_vm_vd(vcast_vd_d(-0.0))), vreinterpret_vm_vd(vd2getx_vd_vd2(r))))); + + o = vcast_vo64_vo32(veq_vo_vi_vi(vand_vi_vi_vi(vadd_vi_vi_vi(q, vcast_vi_i(2)), vcast_vi_i(4)), vcast_vi_i(4))); + r = vd2sety_vd2_vd2_vd(r, vreinterpret_vd_vm(vxor_vm_vm_vm(vand_vm_vo64_vm(o, vreinterpret_vm_vd(vcast_vd_d(-0.0))), vreinterpret_vm_vd(vd2gety_vd_vd2(r))))); + + o = vgt_vo_vd_vd(vabs_vd_vd(d), vcast_vd_d(TRIGRANGEMAX3/4)); + r = vd2setx_vd2_vd2_vd(r, vreinterpret_vd_vm(vandnot_vm_vo64_vm(o, vreinterpret_vm_vd(vd2getx_vd_vd2(r))))); + r = vd2sety_vd2_vd2_vd(r, vsel_vd_vo_vd_vd(o, vcast_vd_d(1), vd2gety_vd_vd2(r))); + + o = visinf_vo_vd(d); + r = vd2setx_vd2_vd2_vd(r, vreinterpret_vd_vm(vor_vm_vo64_vm(o, vreinterpret_vm_vd(vd2getx_vd_vd2(r))))); + r = vd2sety_vd2_vd2_vd(r, vreinterpret_vd_vm(vor_vm_vo64_vm(o, vreinterpret_vm_vd(vd2gety_vd_vd2(r))))); + + return r; +} + +TYPE2_FUNCATR VECTOR_CC vdouble2 XSINCOSPI_U35(vdouble d) { + vopmask o; + vdouble u, s, t, rx, ry; + vdouble2 r; + + u = vmul_vd_vd_vd(d, vcast_vd_d(4.0)); + vint q = vtruncate_vi_vd(u); + q = vand_vi_vi_vi(vadd_vi_vi_vi(q, vxor_vi_vi_vi(vsrl_vi_vi_i(q, 31), vcast_vi_i(1))), vcast_vi_i(~1)); + s = vsub_vd_vd_vd(u, vcast_vd_vi(q)); + + t = s; + s = vmul_vd_vd_vd(s, s); + + // + + u = vcast_vd_d(+0.6880638894766060136e-11); + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(-0.1757159564542310199e-8)); + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(+0.3133616327257867311e-6)); + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(-0.3657620416388486452e-4)); + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(+0.2490394570189932103e-2)); + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(-0.8074551218828056320e-1)); + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(+0.7853981633974482790e+0)); + + rx = vmul_vd_vd_vd(u, t); + + // + + u = vcast_vd_d(-0.3860141213683794352e-12); + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(+0.1150057888029681415e-9)); + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(-0.2461136493006663553e-7)); + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(+0.3590860446623516713e-5)); + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(-0.3259918869269435942e-3)); + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(+0.1585434424381541169e-1)); + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(-0.3084251375340424373e+0)); + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(1)); + + ry = u; + + // + + o = vcast_vo64_vo32(veq_vo_vi_vi(vand_vi_vi_vi(q, vcast_vi_i(2)), vcast_vi_i(0))); + r = vd2setxy_vd2_vd_vd(vsel_vd_vo_vd_vd(o, rx, ry), vsel_vd_vo_vd_vd(o, ry, rx)); + + o = vcast_vo64_vo32(veq_vo_vi_vi(vand_vi_vi_vi(q, vcast_vi_i(4)), vcast_vi_i(4))); + r = vd2setx_vd2_vd2_vd(r, vreinterpret_vd_vm(vxor_vm_vm_vm(vand_vm_vo64_vm(o, vreinterpret_vm_vd(vcast_vd_d(-0.0))), vreinterpret_vm_vd(vd2getx_vd_vd2(r))))); + + o = vcast_vo64_vo32(veq_vo_vi_vi(vand_vi_vi_vi(vadd_vi_vi_vi(q, vcast_vi_i(2)), vcast_vi_i(4)), vcast_vi_i(4))); + r = vd2sety_vd2_vd2_vd(r, vreinterpret_vd_vm(vxor_vm_vm_vm(vand_vm_vo64_vm(o, vreinterpret_vm_vd(vcast_vd_d(-0.0))), vreinterpret_vm_vd(vd2gety_vd_vd2(r))))); + + o = vgt_vo_vd_vd(vabs_vd_vd(d), vcast_vd_d(TRIGRANGEMAX3/4)); + r = vd2setx_vd2_vd2_vd(r, vreinterpret_vd_vm(vandnot_vm_vo64_vm(o, vreinterpret_vm_vd(vd2getx_vd_vd2(r))))); + r = vd2sety_vd2_vd2_vd(r, vreinterpret_vd_vm(vandnot_vm_vo64_vm(o, vreinterpret_vm_vd(vd2gety_vd_vd2(r))))); + + o = visinf_vo_vd(d); + r = vd2setx_vd2_vd2_vd(r, vreinterpret_vd_vm(vor_vm_vo64_vm(o, vreinterpret_vm_vd(vd2getx_vd_vd2(r))))); + r = vd2sety_vd2_vd2_vd(r, vreinterpret_vd_vm(vor_vm_vo64_vm(o, vreinterpret_vm_vd(vd2gety_vd_vd2(r))))); + + return r; +} + +TYPE6_FUNCATR VECTOR_CC vdouble2 XMODF(vdouble x) { + vdouble fr = vsub_vd_vd_vd(x, vmul_vd_vd_vd(vcast_vd_d(INT64_C(1) << 31), vcast_vd_vi(vtruncate_vi_vd(vmul_vd_vd_vd(x, vcast_vd_d(1.0 / (INT64_C(1) << 31))))))); + fr = vsub_vd_vd_vd(fr, vcast_vd_vi(vtruncate_vi_vd(fr))); + fr = vsel_vd_vo_vd_vd(vgt_vo_vd_vd(vabs_vd_vd(x), vcast_vd_d(INT64_C(1) << 52)), vcast_vd_d(0), fr); + + vdouble2 ret; + + ret = vd2setxy_vd2_vd_vd(vcopysign_vd_vd_vd(fr, x), vcopysign_vd_vd_vd(vsub_vd_vd_vd(x, fr), x)); + + return ret; +} + +#ifdef ENABLE_GNUABI +EXPORT VECTOR_CC void xsincos(vdouble a, double *ps, double *pc) { + vdouble2 r = sincosk(a); + vstoreu_v_p_vd(ps, vd2getx_vd_vd2(r)); + vstoreu_v_p_vd(pc, vd2gety_vd_vd2(r)); +} + +EXPORT VECTOR_CC void xsincos_u1(vdouble a, double *ps, double *pc) { + vdouble2 r = sincosk_u1(a); + vstoreu_v_p_vd(ps, vd2getx_vd_vd2(r)); + vstoreu_v_p_vd(pc, vd2gety_vd_vd2(r)); +} + +EXPORT VECTOR_CC void xsincospi_u05(vdouble a, double *ps, double *pc) { + vdouble2 r = sincospik_u05(a); + vstoreu_v_p_vd(ps, vd2getx_vd_vd2(r)); + vstoreu_v_p_vd(pc, vd2gety_vd_vd2(r)); +} + +EXPORT VECTOR_CC void xsincospi_u35(vdouble a, double *ps, double *pc) { + vdouble2 r = sincospik_u35(a); + vstoreu_v_p_vd(ps, vd2getx_vd_vd2(r)); + vstoreu_v_p_vd(pc, vd2gety_vd_vd2(r)); +} + +EXPORT CONST VECTOR_CC vdouble xmodf(vdouble a, double *iptr) { + vdouble2 r = modfk(a); + vstoreu_v_p_vd(iptr, vd2gety_vd_vd2(r)); + return vd2getx_vd_vd2(r); +} +#endif // #ifdef ENABLE_GNUABI +#endif // #if !defined(DETERMINISTIC) + +static INLINE CONST VECTOR_CC vdouble2 sinpik(vdouble d) { + vopmask o; + vdouble u, s, t; + vdouble2 x, s2; + + u = vmul_vd_vd_vd(d, vcast_vd_d(4.0)); + vint q = vtruncate_vi_vd(u); + q = vand_vi_vi_vi(vadd_vi_vi_vi(q, vxor_vi_vi_vi(vsrl_vi_vi_i(q, 31), vcast_vi_i(1))), vcast_vi_i(~1)); + o = vcast_vo64_vo32(veq_vo_vi_vi(vand_vi_vi_vi(q, vcast_vi_i(2)), vcast_vi_i(2))); + + s = vsub_vd_vd_vd(u, vcast_vd_vi(q)); + t = s; + s = vmul_vd_vd_vd(s, s); + s2 = ddmul_vd2_vd_vd(t, t); + + // + + u = vsel_vd_vo_d_d(o, 9.94480387626843774090208e-16, -2.02461120785182399295868e-14); + u = vmla_vd_vd_vd_vd(u, s, vsel_vd_vo_d_d(o, -3.89796226062932799164047e-13, 6.948218305801794613277840e-12)); + u = vmla_vd_vd_vd_vd(u, s, vsel_vd_vo_d_d(o, 1.150115825399960352669010e-10, -1.75724749952853179952664e-09)); + u = vmla_vd_vd_vd_vd(u, s, vsel_vd_vo_d_d(o, -2.46113695010446974953590e-08, 3.133616889668683928784220e-07)); + u = vmla_vd_vd_vd_vd(u, s, vsel_vd_vo_d_d(o, 3.590860448590527540050620e-06, -3.65762041821615519203610e-05)); + u = vmla_vd_vd_vd_vd(u, s, vsel_vd_vo_d_d(o, -0.000325991886927389905997954, 0.0024903945701927185027435600)); + x = ddadd2_vd2_vd_vd2(vmul_vd_vd_vd(u, s), + vsel_vd2_vo_d_d_d_d(o, 0.0158543442438155018914259, -1.04693272280631521908845e-18, + -0.0807455121882807852484731, 3.61852475067037104849987e-18)); + x = ddadd2_vd2_vd2_vd2(ddmul_vd2_vd2_vd2(s2, x), + vsel_vd2_vo_d_d_d_d(o, -0.308425137534042437259529, -1.95698492133633550338345e-17, + 0.785398163397448278999491, 3.06287113727155002607105e-17)); + + x = ddmul_vd2_vd2_vd2(x, vsel_vd2_vo_vd2_vd2(o, s2, vcast_vd2_vd_vd(t, vcast_vd_d(0)))); + x = vsel_vd2_vo_vd2_vd2(o, ddadd2_vd2_vd2_vd(x, vcast_vd_d(1)), x); + + o = vcast_vo64_vo32(veq_vo_vi_vi(vand_vi_vi_vi(q, vcast_vi_i(4)), vcast_vi_i(4))); + x = vd2setx_vd2_vd2_vd(x, vreinterpret_vd_vm(vxor_vm_vm_vm(vand_vm_vo64_vm(o, vreinterpret_vm_vd(vcast_vd_d(-0.0))), vreinterpret_vm_vd(vd2getx_vd_vd2(x))))); + x = vd2sety_vd2_vd2_vd(x, vreinterpret_vd_vm(vxor_vm_vm_vm(vand_vm_vo64_vm(o, vreinterpret_vm_vd(vcast_vd_d(-0.0))), vreinterpret_vm_vd(vd2gety_vd_vd2(x))))); + + return x; +} + +EXPORT CONST VECTOR_CC vdouble xsinpi_u05(vdouble d) { + vdouble2 x = sinpik(d); + vdouble r = vadd_vd_vd_vd(vd2getx_vd_vd2(x), vd2gety_vd_vd2(x)); + + r = vsel_vd_vo_vd_vd(visnegzero_vo_vd(d), vcast_vd_d(-0.0), r); + r = vreinterpret_vd_vm(vandnot_vm_vo64_vm(vgt_vo_vd_vd(vabs_vd_vd(d), vcast_vd_d(TRIGRANGEMAX3/4)), vreinterpret_vm_vd(r))); + r = vreinterpret_vd_vm(vor_vm_vo64_vm(visinf_vo_vd(d), vreinterpret_vm_vd(r))); + + return r; +} + +static INLINE CONST VECTOR_CC vdouble2 cospik(vdouble d) { + vopmask o; + vdouble u, s, t; + vdouble2 x, s2; + + u = vmul_vd_vd_vd(d, vcast_vd_d(4.0)); + vint q = vtruncate_vi_vd(u); + q = vand_vi_vi_vi(vadd_vi_vi_vi(q, vxor_vi_vi_vi(vsrl_vi_vi_i(q, 31), vcast_vi_i(1))), vcast_vi_i(~1)); + o = vcast_vo64_vo32(veq_vo_vi_vi(vand_vi_vi_vi(q, vcast_vi_i(2)), vcast_vi_i(0))); + + s = vsub_vd_vd_vd(u, vcast_vd_vi(q)); + t = s; + s = vmul_vd_vd_vd(s, s); + s2 = ddmul_vd2_vd_vd(t, t); + + // + + u = vsel_vd_vo_d_d(o, 9.94480387626843774090208e-16, -2.02461120785182399295868e-14); + u = vmla_vd_vd_vd_vd(u, s, vsel_vd_vo_d_d(o, -3.89796226062932799164047e-13, 6.948218305801794613277840e-12)); + u = vmla_vd_vd_vd_vd(u, s, vsel_vd_vo_d_d(o, 1.150115825399960352669010e-10, -1.75724749952853179952664e-09)); + u = vmla_vd_vd_vd_vd(u, s, vsel_vd_vo_d_d(o, -2.46113695010446974953590e-08, 3.133616889668683928784220e-07)); + u = vmla_vd_vd_vd_vd(u, s, vsel_vd_vo_d_d(o, 3.590860448590527540050620e-06, -3.65762041821615519203610e-05)); + u = vmla_vd_vd_vd_vd(u, s, vsel_vd_vo_d_d(o, -0.000325991886927389905997954, 0.0024903945701927185027435600)); + x = ddadd2_vd2_vd_vd2(vmul_vd_vd_vd(u, s), + vsel_vd2_vo_d_d_d_d(o, 0.0158543442438155018914259, -1.04693272280631521908845e-18, + -0.0807455121882807852484731, 3.61852475067037104849987e-18)); + x = ddadd2_vd2_vd2_vd2(ddmul_vd2_vd2_vd2(s2, x), + vsel_vd2_vo_d_d_d_d(o, -0.308425137534042437259529, -1.95698492133633550338345e-17, + 0.785398163397448278999491, 3.06287113727155002607105e-17)); + + x = ddmul_vd2_vd2_vd2(x, vsel_vd2_vo_vd2_vd2(o, s2, vcast_vd2_vd_vd(t, vcast_vd_d(0)))); + x = vsel_vd2_vo_vd2_vd2(o, ddadd2_vd2_vd2_vd(x, vcast_vd_d(1)), x); + + o = vcast_vo64_vo32(veq_vo_vi_vi(vand_vi_vi_vi(vadd_vi_vi_vi(q, vcast_vi_i(2)), vcast_vi_i(4)), vcast_vi_i(4))); + x = vd2setx_vd2_vd2_vd(x, vreinterpret_vd_vm(vxor_vm_vm_vm(vand_vm_vo64_vm(o, vreinterpret_vm_vd(vcast_vd_d(-0.0))), vreinterpret_vm_vd(vd2getx_vd_vd2(x))))); + x = vd2sety_vd2_vd2_vd(x, vreinterpret_vd_vm(vxor_vm_vm_vm(vand_vm_vo64_vm(o, vreinterpret_vm_vd(vcast_vd_d(-0.0))), vreinterpret_vm_vd(vd2gety_vd_vd2(x))))); + + return x; +} + +EXPORT CONST VECTOR_CC vdouble xcospi_u05(vdouble d) { + vdouble2 x = cospik(d); + vdouble r = vadd_vd_vd_vd(vd2getx_vd_vd2(x), vd2gety_vd_vd2(x)); + + r = vsel_vd_vo_vd_vd(vgt_vo_vd_vd(vabs_vd_vd(d), vcast_vd_d(TRIGRANGEMAX3/4)), vcast_vd_d(1), r); + r = vreinterpret_vd_vm(vor_vm_vo64_vm(visinf_vo_vd(d), vreinterpret_vm_vd(r))); + + return r; +} + +EXPORT CONST VECTOR_CC vdouble xtan(vdouble d) { +#if !defined(DETERMINISTIC) + vdouble u, s, x, y; + vopmask o; + vint ql; + + if (LIKELY(vtestallones_i_vo64(vlt_vo_vd_vd(vabs_vd_vd(d), vcast_vd_d(TRIGRANGEMAX2))))) { + vdouble dql = vrint_vd_vd(vmul_vd_vd_vd(d, vcast_vd_d(2 * M_1_PI))); + ql = vrint_vi_vd(dql); + x = vmla_vd_vd_vd_vd(dql, vcast_vd_d(-PI_A2 * 0.5), d); + x = vmla_vd_vd_vd_vd(dql, vcast_vd_d(-PI_B2 * 0.5), x); + } else if (LIKELY(vtestallones_i_vo64(vlt_vo_vd_vd(vabs_vd_vd(d), vcast_vd_d(1e+6))))) { + vdouble dqh = vtruncate_vd_vd(vmul_vd_vd_vd(d, vcast_vd_d(2*M_1_PI / (1 << 24)))); + dqh = vmul_vd_vd_vd(dqh, vcast_vd_d(1 << 24)); + vdouble dql = vrint_vd_vd(vsub_vd_vd_vd(vmul_vd_vd_vd(d, vcast_vd_d(2*M_1_PI)), dqh)); + ql = vrint_vi_vd(dql); + + x = vmla_vd_vd_vd_vd(dqh, vcast_vd_d(-PI_A * 0.5), d); + x = vmla_vd_vd_vd_vd(dql, vcast_vd_d(-PI_A * 0.5), x); + x = vmla_vd_vd_vd_vd(dqh, vcast_vd_d(-PI_B * 0.5), x); + x = vmla_vd_vd_vd_vd(dql, vcast_vd_d(-PI_B * 0.5), x); + x = vmla_vd_vd_vd_vd(dqh, vcast_vd_d(-PI_C * 0.5), x); + x = vmla_vd_vd_vd_vd(dql, vcast_vd_d(-PI_C * 0.5), x); + x = vmla_vd_vd_vd_vd(vadd_vd_vd_vd(dqh, dql), vcast_vd_d(-PI_D * 0.5), x); + } else { + ddi_t ddi = rempi(d); + ql = ddigeti_vi_ddi(ddi); + x = vadd_vd_vd_vd(vd2getx_vd_vd2(ddigetdd_vd2_ddi(ddi)), vd2gety_vd_vd2(ddigetdd_vd2_ddi(ddi))); + x = vreinterpret_vd_vm(vor_vm_vo64_vm(visinf_vo_vd(d), vreinterpret_vm_vd(x))); + x = vreinterpret_vd_vm(vor_vm_vo64_vm(vor_vo_vo_vo(visinf_vo_vd(d), visnan_vo_vd(d)), vreinterpret_vm_vd(x))); + } + + x = vmul_vd_vd_vd(x, vcast_vd_d(0.5)); + s = vmul_vd_vd_vd(x, x); + + vdouble s2 = vmul_vd_vd_vd(s, s), s4 = vmul_vd_vd_vd(s2, s2); + u = POLY8(s, s2, s4, + +0.3245098826639276316e-3, + +0.5619219738114323735e-3, + +0.1460781502402784494e-2, + +0.3591611540792499519e-2, + +0.8863268409563113126e-2, + +0.2186948728185535498e-1, + +0.5396825399517272970e-1, + +0.1333333333330500581e+0); + + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(+0.3333333333333343695e+0)); + u = vmla_vd_vd_vd_vd(s, vmul_vd_vd_vd(u, x), x); + + y = vmla_vd_vd_vd_vd(u, u, vcast_vd_d(-1)); + x = vmul_vd_vd_vd(u, vcast_vd_d(-2)); + + o = vcast_vo64_vo32(veq_vo_vi_vi(vand_vi_vi_vi(ql, vcast_vi_i(1)), vcast_vi_i(1))); + u = vdiv_vd_vd_vd(vsel_vd_vo_vd_vd(o, vneg_vd_vd(y), x), + vsel_vd_vo_vd_vd(o, x, y)); + u = vsel_vd_vo_vd_vd(veq_vo_vd_vd(d, vcast_vd_d(0)), d, u); + + return u; + +#else // #if !defined(DETERMINISTIC) + + vdouble u, s, x, y; + vopmask o; + vint ql; + + vdouble dql = vrint_vd_vd(vmul_vd_vd_vd(d, vcast_vd_d(2 * M_1_PI))); + ql = vrint_vi_vd(dql); + s = vmla_vd_vd_vd_vd(dql, vcast_vd_d(-PI_A2 * 0.5), d); + s = vmla_vd_vd_vd_vd(dql, vcast_vd_d(-PI_B2 * 0.5), s); + vopmask g = vlt_vo_vd_vd(vabs_vd_vd(d), vcast_vd_d(TRIGRANGEMAX2)); + + if (!LIKELY(vtestallones_i_vo64(g))) { + vdouble dqh = vtruncate_vd_vd(vmul_vd_vd_vd(d, vcast_vd_d(2*M_1_PI / (1 << 24)))); + dqh = vmul_vd_vd_vd(dqh, vcast_vd_d(1 << 24)); + vdouble dql = vrint_vd_vd(vsub_vd_vd_vd(vmul_vd_vd_vd(d, vcast_vd_d(2*M_1_PI)), dqh)); + + u = vmla_vd_vd_vd_vd(dqh, vcast_vd_d(-PI_A * 0.5), d); + u = vmla_vd_vd_vd_vd(dql, vcast_vd_d(-PI_A * 0.5), u); + u = vmla_vd_vd_vd_vd(dqh, vcast_vd_d(-PI_B * 0.5), u); + u = vmla_vd_vd_vd_vd(dql, vcast_vd_d(-PI_B * 0.5), u); + u = vmla_vd_vd_vd_vd(dqh, vcast_vd_d(-PI_C * 0.5), u); + u = vmla_vd_vd_vd_vd(dql, vcast_vd_d(-PI_C * 0.5), u); + u = vmla_vd_vd_vd_vd(vadd_vd_vd_vd(dqh, dql), vcast_vd_d(-PI_D * 0.5), u); + + ql = vsel_vi_vo_vi_vi(vcast_vo32_vo64(g), ql, vrint_vi_vd(dql)); + s = vsel_vd_vo_vd_vd(g, s, u); + g = vlt_vo_vd_vd(vabs_vd_vd(d), vcast_vd_d(1e+6)); + + if (!LIKELY(vtestallones_i_vo64(g))) { + ddi_t ddi = rempi(d); + vint ql2 = ddigeti_vi_ddi(ddi); + u = vadd_vd_vd_vd(vd2getx_vd_vd2(ddigetdd_vd2_ddi(ddi)), vd2gety_vd_vd2(ddigetdd_vd2_ddi(ddi))); + u = vreinterpret_vd_vm(vor_vm_vo64_vm(vor_vo_vo_vo(visinf_vo_vd(d), visnan_vo_vd(d)), vreinterpret_vm_vd(u))); + + ql = vsel_vi_vo_vi_vi(vcast_vo32_vo64(g), ql, ql2); + s = vsel_vd_vo_vd_vd(g, s, u); + } + } + + x = vmul_vd_vd_vd(s, vcast_vd_d(0.5)); + s = vmul_vd_vd_vd(x, x); + + vdouble s2 = vmul_vd_vd_vd(s, s), s4 = vmul_vd_vd_vd(s2, s2); + u = POLY8(s, s2, s4, + +0.3245098826639276316e-3, + +0.5619219738114323735e-3, + +0.1460781502402784494e-2, + +0.3591611540792499519e-2, + +0.8863268409563113126e-2, + +0.2186948728185535498e-1, + +0.5396825399517272970e-1, + +0.1333333333330500581e+0); + + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(+0.3333333333333343695e+0)); + u = vmla_vd_vd_vd_vd(s, vmul_vd_vd_vd(u, x), x); + + y = vmla_vd_vd_vd_vd(u, u, vcast_vd_d(-1)); + x = vmul_vd_vd_vd(u, vcast_vd_d(-2)); + + o = vcast_vo64_vo32(veq_vo_vi_vi(vand_vi_vi_vi(ql, vcast_vi_i(1)), vcast_vi_i(1))); + u = vdiv_vd_vd_vd(vsel_vd_vo_vd_vd(o, vneg_vd_vd(y), x), + vsel_vd_vo_vd_vd(o, x, y)); + u = vsel_vd_vo_vd_vd(veq_vo_vd_vd(d, vcast_vd_d(0)), d, u); + + return u; +#endif // #if !defined(DETERMINISTIC) +} + +EXPORT CONST VECTOR_CC vdouble xtan_u1(vdouble d) { +#if !defined(DETERMINISTIC) + vdouble u; + vdouble2 s, t, x, y; + vopmask o; + vint ql; + + if (LIKELY(vtestallones_i_vo64(vlt_vo_vd_vd(vabs_vd_vd(d), vcast_vd_d(TRIGRANGEMAX2))))) { + vdouble dql = vrint_vd_vd(vmul_vd_vd_vd(d, vcast_vd_d(2 * M_1_PI))); + ql = vrint_vi_vd(dql); + u = vmla_vd_vd_vd_vd(dql, vcast_vd_d(-PI_A2*0.5), d); + s = ddadd_vd2_vd_vd (u, vmul_vd_vd_vd(dql, vcast_vd_d(-PI_B2*0.5))); + } else if (LIKELY(vtestallones_i_vo64(vlt_vo_vd_vd(vabs_vd_vd(d), vcast_vd_d(TRIGRANGEMAX))))) { + vdouble dqh = vtruncate_vd_vd(vmul_vd_vd_vd(d, vcast_vd_d(2*M_1_PI / (1 << 24)))); + dqh = vmul_vd_vd_vd(dqh, vcast_vd_d(1 << 24)); + s = ddadd2_vd2_vd2_vd(ddmul_vd2_vd2_vd(vcast_vd2_d_d(M_2_PI_H, M_2_PI_L), d), + vsub_vd_vd_vd(vsel_vd_vo_vd_vd(vlt_vo_vd_vd(d, vcast_vd_d(0)), + vcast_vd_d(-0.5), vcast_vd_d(0.5)), dqh)); + const vdouble dql = vtruncate_vd_vd(vadd_vd_vd_vd(vd2getx_vd_vd2(s), vd2gety_vd_vd2(s))); + ql = vrint_vi_vd(dql); + + u = vmla_vd_vd_vd_vd(dqh, vcast_vd_d(-PI_A * 0.5), d); + s = ddadd_vd2_vd_vd(u, vmul_vd_vd_vd(dql, vcast_vd_d(-PI_A*0.5 ))); + s = ddadd2_vd2_vd2_vd(s, vmul_vd_vd_vd(dqh, vcast_vd_d(-PI_B*0.5))); + s = ddadd2_vd2_vd2_vd(s, vmul_vd_vd_vd(dql, vcast_vd_d(-PI_B*0.5 ))); + s = ddadd2_vd2_vd2_vd(s, vmul_vd_vd_vd(dqh, vcast_vd_d(-PI_C*0.5))); + s = ddadd2_vd2_vd2_vd(s, vmul_vd_vd_vd(dql, vcast_vd_d(-PI_C*0.5 ))); + s = ddadd_vd2_vd2_vd(s, vmul_vd_vd_vd(vadd_vd_vd_vd(dqh, dql), vcast_vd_d(-PI_D*0.5))); + } else { + ddi_t ddi = rempi(d); + ql = ddigeti_vi_ddi(ddi); + s = ddigetdd_vd2_ddi(ddi); + o = vor_vo_vo_vo(visinf_vo_vd(d), visnan_vo_vd(d)); + s = vd2setx_vd2_vd2_vd(s, vreinterpret_vd_vm(vor_vm_vo64_vm(o, vreinterpret_vm_vd(vd2getx_vd_vd2(s))))); + s = vd2sety_vd2_vd2_vd(s, vreinterpret_vd_vm(vor_vm_vo64_vm(o, vreinterpret_vm_vd(vd2gety_vd_vd2(s))))); + } + + t = ddscale_vd2_vd2_vd(s, vcast_vd_d(0.5)); + s = ddsqu_vd2_vd2(t); + + vdouble s2 = vmul_vd_vd_vd(vd2getx_vd_vd2(s), vd2getx_vd_vd2(s)), s4 = vmul_vd_vd_vd(s2, s2); + u = POLY8(vd2getx_vd_vd2(s), s2, s4, + +0.3245098826639276316e-3, + +0.5619219738114323735e-3, + +0.1460781502402784494e-2, + +0.3591611540792499519e-2, + +0.8863268409563113126e-2, + +0.2186948728185535498e-1, + +0.5396825399517272970e-1, + +0.1333333333330500581e+0); + + u = vmla_vd_vd_vd_vd(u, vd2getx_vd_vd2(s), vcast_vd_d(+0.3333333333333343695e+0)); + x = ddadd_vd2_vd2_vd2(t, ddmul_vd2_vd2_vd(ddmul_vd2_vd2_vd2(s, t), u)); + + y = ddadd_vd2_vd_vd2(vcast_vd_d(-1), ddsqu_vd2_vd2(x)); + x = ddscale_vd2_vd2_vd(x, vcast_vd_d(-2)); + + o = vcast_vo64_vo32(veq_vo_vi_vi(vand_vi_vi_vi(ql, vcast_vi_i(1)), vcast_vi_i(1))); + + x = dddiv_vd2_vd2_vd2(vsel_vd2_vo_vd2_vd2(o, ddneg_vd2_vd2(y), x), + vsel_vd2_vo_vd2_vd2(o, x, y)); + + u = vadd_vd_vd_vd(vd2getx_vd_vd2(x), vd2gety_vd_vd2(x)); + + u = vsel_vd_vo_vd_vd(veq_vo_vd_vd(d, vcast_vd_d(0)), d, u); + + return u; + +#else // #if !defined(DETERMINISTIC) + + vdouble u; + vdouble2 s, t, x, y; + vopmask o; + vint ql; + + const vdouble dql = vrint_vd_vd(vmul_vd_vd_vd(d, vcast_vd_d(2 * M_1_PI))); + ql = vrint_vi_vd(dql); + u = vmla_vd_vd_vd_vd(dql, vcast_vd_d(-PI_A2*0.5), d); + s = ddadd_vd2_vd_vd (u, vmul_vd_vd_vd(dql, vcast_vd_d(-PI_B2*0.5))); + vopmask g = vlt_vo_vd_vd(vabs_vd_vd(d), vcast_vd_d(TRIGRANGEMAX2)); + + if (!LIKELY(vtestallones_i_vo64(g))) { + vdouble dqh = vtruncate_vd_vd(vmul_vd_vd_vd(d, vcast_vd_d(2*M_1_PI / (1 << 24)))); + dqh = vmul_vd_vd_vd(dqh, vcast_vd_d(1 << 24)); + x = ddadd2_vd2_vd2_vd(ddmul_vd2_vd2_vd(vcast_vd2_d_d(M_2_PI_H, M_2_PI_L), d), + vsub_vd_vd_vd(vsel_vd_vo_vd_vd(vlt_vo_vd_vd(d, vcast_vd_d(0)), + vcast_vd_d(-0.5), vcast_vd_d(0.5)), dqh)); + const vdouble dql = vtruncate_vd_vd(vadd_vd_vd_vd(vd2getx_vd_vd2(x), vd2gety_vd_vd2(x))); + + u = vmla_vd_vd_vd_vd(dqh, vcast_vd_d(-PI_A * 0.5), d); + x = ddadd_vd2_vd_vd(u, vmul_vd_vd_vd(dql, vcast_vd_d(-PI_A*0.5 ))); + x = ddadd2_vd2_vd2_vd(x, vmul_vd_vd_vd(dqh, vcast_vd_d(-PI_B*0.5))); + x = ddadd2_vd2_vd2_vd(x, vmul_vd_vd_vd(dql, vcast_vd_d(-PI_B*0.5 ))); + x = ddadd2_vd2_vd2_vd(x, vmul_vd_vd_vd(dqh, vcast_vd_d(-PI_C*0.5))); + x = ddadd2_vd2_vd2_vd(x, vmul_vd_vd_vd(dql, vcast_vd_d(-PI_C*0.5 ))); + x = ddadd_vd2_vd2_vd(x, vmul_vd_vd_vd(vadd_vd_vd_vd(dqh, dql), vcast_vd_d(-PI_D*0.5))); + + ql = vsel_vi_vo_vi_vi(vcast_vo32_vo64(g), ql, vrint_vi_vd(dql)); + s = vsel_vd2_vo_vd2_vd2(g, s, x); + g = vlt_vo_vd_vd(vabs_vd_vd(d), vcast_vd_d(TRIGRANGEMAX)); + + if (!LIKELY(vtestallones_i_vo64(g))) { + ddi_t ddi = rempi(d); + x = ddigetdd_vd2_ddi(ddi); + o = vor_vo_vo_vo(visinf_vo_vd(d), visnan_vo_vd(d)); + x = vd2setx_vd2_vd2_vd(x, vreinterpret_vd_vm(vor_vm_vo64_vm(o, vreinterpret_vm_vd(vd2getx_vd_vd2(x))))); + x = vd2sety_vd2_vd2_vd(x, vreinterpret_vd_vm(vor_vm_vo64_vm(o, vreinterpret_vm_vd(vd2gety_vd_vd2(x))))); + + ql = vsel_vi_vo_vi_vi(vcast_vo32_vo64(g), ql, ddigeti_vi_ddi(ddi)); + s = vsel_vd2_vo_vd2_vd2(g, s, x); + } + } + + t = ddscale_vd2_vd2_vd(s, vcast_vd_d(0.5)); + s = ddsqu_vd2_vd2(t); + + vdouble s2 = vmul_vd_vd_vd(vd2getx_vd_vd2(s), vd2getx_vd_vd2(s)), s4 = vmul_vd_vd_vd(s2, s2); + u = POLY8(vd2getx_vd_vd2(s), s2, s4, + +0.3245098826639276316e-3, + +0.5619219738114323735e-3, + +0.1460781502402784494e-2, + +0.3591611540792499519e-2, + +0.8863268409563113126e-2, + +0.2186948728185535498e-1, + +0.5396825399517272970e-1, + +0.1333333333330500581e+0); + + u = vmla_vd_vd_vd_vd(u, vd2getx_vd_vd2(s), vcast_vd_d(+0.3333333333333343695e+0)); + x = ddadd_vd2_vd2_vd2(t, ddmul_vd2_vd2_vd(ddmul_vd2_vd2_vd2(s, t), u)); + + y = ddadd_vd2_vd_vd2(vcast_vd_d(-1), ddsqu_vd2_vd2(x)); + x = ddscale_vd2_vd2_vd(x, vcast_vd_d(-2)); + + o = vcast_vo64_vo32(veq_vo_vi_vi(vand_vi_vi_vi(ql, vcast_vi_i(1)), vcast_vi_i(1))); + + x = dddiv_vd2_vd2_vd2(vsel_vd2_vo_vd2_vd2(o, ddneg_vd2_vd2(y), x), + vsel_vd2_vo_vd2_vd2(o, x, y)); + + u = vadd_vd_vd_vd(vd2getx_vd_vd2(x), vd2gety_vd_vd2(x)); + + u = vsel_vd_vo_vd_vd(veq_vo_vd_vd(d, vcast_vd_d(0)), d, u); + + return u; +#endif // #if !defined(DETERMINISTIC) +} + +static INLINE CONST VECTOR_CC vdouble atan2k(vdouble y, vdouble x) { + vdouble s, t, u; + vint q; + vopmask p; + + q = vsel_vi_vd_vi(x, vcast_vi_i(-2)); + x = vabs_vd_vd(x); + + q = vsel_vi_vd_vd_vi_vi(x, y, vadd_vi_vi_vi(q, vcast_vi_i(1)), q); + p = vlt_vo_vd_vd(x, y); + s = vsel_vd_vo_vd_vd(p, vneg_vd_vd(x), y); + t = vmax_vd_vd_vd(x, y); + + s = vdiv_vd_vd_vd(s, t); + t = vmul_vd_vd_vd(s, s); + + vdouble t2 = vmul_vd_vd_vd(t, t), t4 = vmul_vd_vd_vd(t2, t2), t8 = vmul_vd_vd_vd(t4, t4), t16 = vmul_vd_vd_vd(t8, t8); + u = POLY19(t, t2, t4, t8, t16, + -1.88796008463073496563746e-05, + 0.000209850076645816976906797, + -0.00110611831486672482563471, + 0.00370026744188713119232403, + -0.00889896195887655491740809, + 0.016599329773529201970117, + -0.0254517624932312641616861, + 0.0337852580001353069993897, + -0.0407629191276836500001934, + 0.0466667150077840625632675, + -0.0523674852303482457616113, + 0.0587666392926673580854313, + -0.0666573579361080525984562, + 0.0769219538311769618355029, + -0.090908995008245008229153, + 0.111111105648261418443745, + -0.14285714266771329383765, + 0.199999999996591265594148, + -0.333333333333311110369124); + + t = vmla_vd_vd_vd_vd(s, vmul_vd_vd_vd(t, u), s); + t = vmla_vd_vd_vd_vd(vcast_vd_vi(q), vcast_vd_d(M_PI/2), t); + + return t; +} + +static INLINE CONST VECTOR_CC vdouble2 atan2k_u1(vdouble2 y, vdouble2 x) { + vdouble u; + vdouble2 s, t; + vint q; + vopmask p; + + q = vsel_vi_vd_vi(vd2getx_vd_vd2(x), vcast_vi_i(-2)); + p = vlt_vo_vd_vd(vd2getx_vd_vd2(x), vcast_vd_d(0)); + vmask b = vand_vm_vo64_vm(p, vreinterpret_vm_vd(vcast_vd_d(-0.0))); + x = vd2setx_vd2_vd2_vd(x, vreinterpret_vd_vm(vxor_vm_vm_vm(b, vreinterpret_vm_vd(vd2getx_vd_vd2(x))))); + x = vd2sety_vd2_vd2_vd(x, vreinterpret_vd_vm(vxor_vm_vm_vm(b, vreinterpret_vm_vd(vd2gety_vd_vd2(x))))); + + q = vsel_vi_vd_vd_vi_vi(vd2getx_vd_vd2(x), vd2getx_vd_vd2(y), vadd_vi_vi_vi(q, vcast_vi_i(1)), q); + p = vlt_vo_vd_vd(vd2getx_vd_vd2(x), vd2getx_vd_vd2(y)); + s = vsel_vd2_vo_vd2_vd2(p, ddneg_vd2_vd2(x), y); + t = vsel_vd2_vo_vd2_vd2(p, y, x); + + s = dddiv_vd2_vd2_vd2(s, t); + t = ddsqu_vd2_vd2(s); + t = ddnormalize_vd2_vd2(t); + + vdouble t2 = vmul_vd_vd_vd(vd2getx_vd_vd2(t), vd2getx_vd_vd2(t)), t4 = vmul_vd_vd_vd(t2, t2), t8 = vmul_vd_vd_vd(t4, t4); + u = POLY16(vd2getx_vd_vd2(t), t2, t4, t8, + 1.06298484191448746607415e-05, + -0.000125620649967286867384336, + 0.00070557664296393412389774, + -0.00251865614498713360352999, + 0.00646262899036991172313504, + -0.0128281333663399031014274, + 0.0208024799924145797902497, + -0.0289002344784740315686289, + 0.0359785005035104590853656, + -0.041848579703592507506027, + 0.0470843011653283988193763, + -0.0524914210588448421068719, + 0.0587946590969581003860434, + -0.0666620884778795497194182, + 0.0769225330296203768654095, + -0.0909090442773387574781907); + u = vmla_vd_vd_vd_vd(u, vd2getx_vd_vd2(t), vcast_vd_d(0.111111108376896236538123)); + u = vmla_vd_vd_vd_vd(u, vd2getx_vd_vd2(t), vcast_vd_d(-0.142857142756268568062339)); + u = vmla_vd_vd_vd_vd(u, vd2getx_vd_vd2(t), vcast_vd_d(0.199999999997977351284817)); + u = vmla_vd_vd_vd_vd(u, vd2getx_vd_vd2(t), vcast_vd_d(-0.333333333333317605173818)); + + t = ddadd_vd2_vd2_vd2(s, ddmul_vd2_vd2_vd(ddmul_vd2_vd2_vd2(s, t), u)); + + t = ddadd_vd2_vd2_vd2(ddmul_vd2_vd2_vd(vcast_vd2_d_d(1.570796326794896557998982, 6.12323399573676603586882e-17), vcast_vd_vi(q)), t); + + return t; +} + +static INLINE CONST VECTOR_CC vdouble visinf2_vd_vd_vd(vdouble d, vdouble m) { + return vreinterpret_vd_vm(vand_vm_vo64_vm(visinf_vo_vd(d), vor_vm_vm_vm(vand_vm_vm_vm(vreinterpret_vm_vd(d), vreinterpret_vm_vd(vcast_vd_d(-0.0))), vreinterpret_vm_vd(m)))); +} + +EXPORT CONST VECTOR_CC vdouble xatan2(vdouble y, vdouble x) { + vdouble r = atan2k(vabs_vd_vd(y), x); + + r = vmulsign_vd_vd_vd(r, x); + r = vsel_vd_vo_vd_vd(vor_vo_vo_vo(visinf_vo_vd(x), veq_vo_vd_vd(x, vcast_vd_d(0))), vsub_vd_vd_vd(vcast_vd_d(M_PI/2), visinf2_vd_vd_vd(x, vmulsign_vd_vd_vd(vcast_vd_d(M_PI/2), x))), r); + r = vsel_vd_vo_vd_vd(visinf_vo_vd(y), vsub_vd_vd_vd(vcast_vd_d(M_PI/2), visinf2_vd_vd_vd(x, vmulsign_vd_vd_vd(vcast_vd_d(M_PI/4), x))), r); + r = vsel_vd_vo_vd_vd(veq_vo_vd_vd(y, vcast_vd_d(0.0)), vreinterpret_vd_vm(vand_vm_vo64_vm(vsignbit_vo_vd(x), vreinterpret_vm_vd(vcast_vd_d(M_PI)))), r); + + r = vreinterpret_vd_vm(vor_vm_vo64_vm(vor_vo_vo_vo(visnan_vo_vd(x), visnan_vo_vd(y)), vreinterpret_vm_vd(vmulsign_vd_vd_vd(r, y)))); + return r; +} + +EXPORT CONST VECTOR_CC vdouble xatan2_u1(vdouble y, vdouble x) { + vopmask o = vlt_vo_vd_vd(vabs_vd_vd(x), vcast_vd_d(5.5626846462680083984e-309)); // nexttoward((1.0 / DBL_MAX), 1) + x = vsel_vd_vo_vd_vd(o, vmul_vd_vd_vd(x, vcast_vd_d(UINT64_C(1) << 53)), x); + y = vsel_vd_vo_vd_vd(o, vmul_vd_vd_vd(y, vcast_vd_d(UINT64_C(1) << 53)), y); + + vdouble2 d = atan2k_u1(vcast_vd2_vd_vd(vabs_vd_vd(y), vcast_vd_d(0)), vcast_vd2_vd_vd(x, vcast_vd_d(0))); + vdouble r = vadd_vd_vd_vd(vd2getx_vd_vd2(d), vd2gety_vd_vd2(d)); + + r = vmulsign_vd_vd_vd(r, x); + r = vsel_vd_vo_vd_vd(vor_vo_vo_vo(visinf_vo_vd(x), veq_vo_vd_vd(x, vcast_vd_d(0))), vsub_vd_vd_vd(vcast_vd_d(M_PI/2), visinf2_vd_vd_vd(x, vmulsign_vd_vd_vd(vcast_vd_d(M_PI/2), x))), r); + r = vsel_vd_vo_vd_vd(visinf_vo_vd(y), vsub_vd_vd_vd(vcast_vd_d(M_PI/2), visinf2_vd_vd_vd(x, vmulsign_vd_vd_vd(vcast_vd_d(M_PI/4), x))), r); + r = vsel_vd_vo_vd_vd(veq_vo_vd_vd(y, vcast_vd_d(0.0)), vreinterpret_vd_vm(vand_vm_vo64_vm(vsignbit_vo_vd(x), vreinterpret_vm_vd(vcast_vd_d(M_PI)))), r); + + r = vreinterpret_vd_vm(vor_vm_vo64_vm(vor_vo_vo_vo(visnan_vo_vd(x), visnan_vo_vd(y)), vreinterpret_vm_vd(vmulsign_vd_vd_vd(r, y)))); + return r; +} + +EXPORT CONST VECTOR_CC vdouble xasin(vdouble d) { + vopmask o = vlt_vo_vd_vd(vabs_vd_vd(d), vcast_vd_d(0.5)); + vdouble x2 = vsel_vd_vo_vd_vd(o, vmul_vd_vd_vd(d, d), vmul_vd_vd_vd(vsub_vd_vd_vd(vcast_vd_d(1), vabs_vd_vd(d)), vcast_vd_d(0.5))); + vdouble x = vsel_vd_vo_vd_vd(o, vabs_vd_vd(d), vsqrt_vd_vd(x2)), u; + + vdouble x4 = vmul_vd_vd_vd(x2, x2), x8 = vmul_vd_vd_vd(x4, x4), x16 = vmul_vd_vd_vd(x8, x8); + u = POLY12(x2, x4, x8, x16, + +0.3161587650653934628e-1, + -0.1581918243329996643e-1, + +0.1929045477267910674e-1, + +0.6606077476277170610e-2, + +0.1215360525577377331e-1, + +0.1388715184501609218e-1, + +0.1735956991223614604e-1, + +0.2237176181932048341e-1, + +0.3038195928038132237e-1, + +0.4464285681377102438e-1, + +0.7500000000378581611e-1, + +0.1666666666666497543e+0); + + u = vmla_vd_vd_vd_vd(u, vmul_vd_vd_vd(x, x2), x); + + vdouble r = vsel_vd_vo_vd_vd(o, u, vmla_vd_vd_vd_vd(u, vcast_vd_d(-2), vcast_vd_d(M_PI/2))); + return vmulsign_vd_vd_vd(r, d); +} + +EXPORT CONST VECTOR_CC vdouble xasin_u1(vdouble d) { + vopmask o = vlt_vo_vd_vd(vabs_vd_vd(d), vcast_vd_d(0.5)); + vdouble x2 = vsel_vd_vo_vd_vd(o, vmul_vd_vd_vd(d, d), vmul_vd_vd_vd(vsub_vd_vd_vd(vcast_vd_d(1), vabs_vd_vd(d)), vcast_vd_d(0.5))), u; + vdouble2 x = vsel_vd2_vo_vd2_vd2(o, vcast_vd2_vd_vd(vabs_vd_vd(d), vcast_vd_d(0)), ddsqrt_vd2_vd(x2)); + x = vsel_vd2_vo_vd2_vd2(veq_vo_vd_vd(vabs_vd_vd(d), vcast_vd_d(1.0)), vcast_vd2_d_d(0, 0), x); + + vdouble x4 = vmul_vd_vd_vd(x2, x2), x8 = vmul_vd_vd_vd(x4, x4), x16 = vmul_vd_vd_vd(x8, x8); + u = POLY12(x2, x4, x8, x16, + +0.3161587650653934628e-1, + -0.1581918243329996643e-1, + +0.1929045477267910674e-1, + +0.6606077476277170610e-2, + +0.1215360525577377331e-1, + +0.1388715184501609218e-1, + +0.1735956991223614604e-1, + +0.2237176181932048341e-1, + +0.3038195928038132237e-1, + +0.4464285681377102438e-1, + +0.7500000000378581611e-1, + +0.1666666666666497543e+0); + + u = vmul_vd_vd_vd(u, vmul_vd_vd_vd(x2, vd2getx_vd_vd2(x))); + + vdouble2 y = ddsub_vd2_vd2_vd(ddsub_vd2_vd2_vd2(vcast_vd2_d_d(3.141592653589793116/4, 1.2246467991473532072e-16/4), x), u); + + vdouble r = vsel_vd_vo_vd_vd(o, vadd_vd_vd_vd(u, vd2getx_vd_vd2(x)), + vmul_vd_vd_vd(vadd_vd_vd_vd(vd2getx_vd_vd2(y), vd2gety_vd_vd2(y)), vcast_vd_d(2))); + return vmulsign_vd_vd_vd(r, d); +} + +EXPORT CONST VECTOR_CC vdouble xacos(vdouble d) { + vopmask o = vlt_vo_vd_vd(vabs_vd_vd(d), vcast_vd_d(0.5)); + vdouble x2 = vsel_vd_vo_vd_vd(o, vmul_vd_vd_vd(d, d), + vmul_vd_vd_vd(vsub_vd_vd_vd(vcast_vd_d(1), vabs_vd_vd(d)), vcast_vd_d(0.5))), u; + vdouble x = vsel_vd_vo_vd_vd(o, vabs_vd_vd(d), vsqrt_vd_vd(x2)); + x = vsel_vd_vo_vd_vd(veq_vo_vd_vd(vabs_vd_vd(d), vcast_vd_d(1.0)), vcast_vd_d(0), x); + + vdouble x4 = vmul_vd_vd_vd(x2, x2), x8 = vmul_vd_vd_vd(x4, x4), x16 = vmul_vd_vd_vd(x8, x8); + u = POLY12(x2, x4, x8, x16, + +0.3161587650653934628e-1, + -0.1581918243329996643e-1, + +0.1929045477267910674e-1, + +0.6606077476277170610e-2, + +0.1215360525577377331e-1, + +0.1388715184501609218e-1, + +0.1735956991223614604e-1, + +0.2237176181932048341e-1, + +0.3038195928038132237e-1, + +0.4464285681377102438e-1, + +0.7500000000378581611e-1, + +0.1666666666666497543e+0); + + u = vmul_vd_vd_vd(u, vmul_vd_vd_vd(x2, x)); + + vdouble y = vsub_vd_vd_vd(vcast_vd_d(M_PI/2), vadd_vd_vd_vd(vmulsign_vd_vd_vd(x, d), vmulsign_vd_vd_vd(u, d))); + x = vadd_vd_vd_vd(x, u); + vdouble r = vsel_vd_vo_vd_vd(o, y, vmul_vd_vd_vd(x, vcast_vd_d(2))); + return vsel_vd_vo_vd_vd(vandnot_vo_vo_vo(o, vlt_vo_vd_vd(d, vcast_vd_d(0))), + vd2getx_vd_vd2(ddadd_vd2_vd2_vd(vcast_vd2_d_d(3.141592653589793116, 1.2246467991473532072e-16), + vneg_vd_vd(r))), r); +} + +EXPORT CONST VECTOR_CC vdouble xacos_u1(vdouble d) { + vopmask o = vlt_vo_vd_vd(vabs_vd_vd(d), vcast_vd_d(0.5)); + vdouble x2 = vsel_vd_vo_vd_vd(o, vmul_vd_vd_vd(d, d), vmul_vd_vd_vd(vsub_vd_vd_vd(vcast_vd_d(1), vabs_vd_vd(d)), vcast_vd_d(0.5))), u; + vdouble2 x = vsel_vd2_vo_vd2_vd2(o, vcast_vd2_vd_vd(vabs_vd_vd(d), vcast_vd_d(0)), ddsqrt_vd2_vd(x2)); + x = vsel_vd2_vo_vd2_vd2(veq_vo_vd_vd(vabs_vd_vd(d), vcast_vd_d(1.0)), vcast_vd2_d_d(0, 0), x); + + vdouble x4 = vmul_vd_vd_vd(x2, x2), x8 = vmul_vd_vd_vd(x4, x4), x16 = vmul_vd_vd_vd(x8, x8); + u = POLY12(x2, x4, x8, x16, + +0.3161587650653934628e-1, + -0.1581918243329996643e-1, + +0.1929045477267910674e-1, + +0.6606077476277170610e-2, + +0.1215360525577377331e-1, + +0.1388715184501609218e-1, + +0.1735956991223614604e-1, + +0.2237176181932048341e-1, + +0.3038195928038132237e-1, + +0.4464285681377102438e-1, + +0.7500000000378581611e-1, + +0.1666666666666497543e+0); + + u = vmul_vd_vd_vd(u, vmul_vd_vd_vd(x2, vd2getx_vd_vd2(x))); + + vdouble2 y = ddsub_vd2_vd2_vd2(vcast_vd2_d_d(3.141592653589793116/2, 1.2246467991473532072e-16/2), + ddadd_vd2_vd_vd(vmulsign_vd_vd_vd(vd2getx_vd_vd2(x), d), vmulsign_vd_vd_vd(u, d))); + x = ddadd_vd2_vd2_vd(x, u); + + y = vsel_vd2_vo_vd2_vd2(o, y, ddscale_vd2_vd2_vd(x, vcast_vd_d(2))); + + y = vsel_vd2_vo_vd2_vd2(vandnot_vo_vo_vo(o, vlt_vo_vd_vd(d, vcast_vd_d(0))), + ddsub_vd2_vd2_vd2(vcast_vd2_d_d(3.141592653589793116, 1.2246467991473532072e-16), y), y); + + return vadd_vd_vd_vd(vd2getx_vd_vd2(y), vd2gety_vd_vd2(y)); +} + +EXPORT CONST VECTOR_CC vdouble xatan_u1(vdouble d) { + vdouble2 d2 = atan2k_u1(vcast_vd2_vd_vd(vabs_vd_vd(d), vcast_vd_d(0)), vcast_vd2_d_d(1, 0)); + vdouble r = vadd_vd_vd_vd(vd2getx_vd_vd2(d2), vd2gety_vd_vd2(d2)); + r = vsel_vd_vo_vd_vd(visinf_vo_vd(d), vcast_vd_d(1.570796326794896557998982), r); + return vmulsign_vd_vd_vd(r, d); +} + +EXPORT CONST VECTOR_CC vdouble xatan(vdouble s) { + vdouble t, u; + vint q; +#if defined(__INTEL_COMPILER) && defined(ENABLE_PURECFMA_SCALAR) + vdouble w = s; +#endif + + q = vsel_vi_vd_vi(s, vcast_vi_i(2)); + s = vabs_vd_vd(s); + + q = vsel_vi_vd_vd_vi_vi(vcast_vd_d(1), s, vadd_vi_vi_vi(q, vcast_vi_i(1)), q); + s = vsel_vd_vo_vd_vd(vlt_vo_vd_vd(vcast_vd_d(1), s), vrec_vd_vd(s), s); + + t = vmul_vd_vd_vd(s, s); + + vdouble t2 = vmul_vd_vd_vd(t, t), t4 = vmul_vd_vd_vd(t2, t2), t8 = vmul_vd_vd_vd(t4, t4), t16 = vmul_vd_vd_vd(t8, t8); + u = POLY19(t, t2, t4, t8, t16, + -1.88796008463073496563746e-05, + 0.000209850076645816976906797, + -0.00110611831486672482563471, + 0.00370026744188713119232403, + -0.00889896195887655491740809, + 0.016599329773529201970117, + -0.0254517624932312641616861, + 0.0337852580001353069993897, + -0.0407629191276836500001934, + 0.0466667150077840625632675, + -0.0523674852303482457616113, + 0.0587666392926673580854313, + -0.0666573579361080525984562, + 0.0769219538311769618355029, + -0.090908995008245008229153, + 0.111111105648261418443745, + -0.14285714266771329383765, + 0.199999999996591265594148, + -0.333333333333311110369124); + + t = vmla_vd_vd_vd_vd(s, vmul_vd_vd_vd(t, u), s); + + t = vsel_vd_vo_vd_vd(vcast_vo64_vo32(veq_vo_vi_vi(vand_vi_vi_vi(q, vcast_vi_i(1)), vcast_vi_i(1))), vsub_vd_vd_vd(vcast_vd_d(M_PI/2), t), t); + t = vreinterpret_vd_vm(vxor_vm_vm_vm(vand_vm_vo64_vm(vcast_vo64_vo32(veq_vo_vi_vi(vand_vi_vi_vi(q, vcast_vi_i(2)), vcast_vi_i(2))), vreinterpret_vm_vd(vcast_vd_d(-0.0))), vreinterpret_vm_vd(t))); + +#if defined(__INTEL_COMPILER) && defined(ENABLE_PURECFMA_SCALAR) + t = vsel_vd_vo_vd_vd(veq_vo_vd_vd(w, vcast_vd_d(0)), w, t); +#endif + + return t; +} + +#if !defined(DETERMINISTIC) +EXPORT CONST VECTOR_CC vdouble xlog(vdouble d) { + vdouble x, x2; + vdouble t, m; + +#if !defined(ENABLE_AVX512F) && !defined(ENABLE_AVX512FNOFMA) + vopmask o = vlt_vo_vd_vd(d, vcast_vd_d(SLEEF_DBL_MIN)); + d = vsel_vd_vo_vd_vd(o, vmul_vd_vd_vd(d, vcast_vd_d((double)(INT64_C(1) << 32) * (double)(INT64_C(1) << 32))), d); + vint e = vilogb2k_vi_vd(vmul_vd_vd_vd(d, vcast_vd_d(1.0/0.75))); + m = vldexp3_vd_vd_vi(d, vneg_vi_vi(e)); + e = vsel_vi_vo_vi_vi(vcast_vo32_vo64(o), vsub_vi_vi_vi(e, vcast_vi_i(64)), e); +#else + vdouble e = vgetexp_vd_vd(vmul_vd_vd_vd(d, vcast_vd_d(1.0/0.75))); + e = vsel_vd_vo_vd_vd(vispinf_vo_vd(e), vcast_vd_d(1024.0), e); + m = vgetmant_vd_vd(d); +#endif + + x = vdiv_vd_vd_vd(vsub_vd_vd_vd(m, vcast_vd_d(1)), vadd_vd_vd_vd(vcast_vd_d(1), m)); + x2 = vmul_vd_vd_vd(x, x); + + vdouble x4 = vmul_vd_vd_vd(x2, x2), x8 = vmul_vd_vd_vd(x4, x4), x3 = vmul_vd_vd_vd(x, x2); + t = POLY7(x2, x4, x8, + 0.153487338491425068243146, + 0.152519917006351951593857, + 0.181863266251982985677316, + 0.222221366518767365905163, + 0.285714294746548025383248, + 0.399999999950799600689777, + 0.6666666666667778740063); + +#if !defined(ENABLE_AVX512F) && !defined(ENABLE_AVX512FNOFMA) + x = vmla_vd_vd_vd_vd(x, vcast_vd_d(2), vmul_vd_vd_vd(vcast_vd_d(0.693147180559945286226764), vcast_vd_vi(e))); + x = vmla_vd_vd_vd_vd(x3, t, x); + + x = vsel_vd_vo_vd_vd(vispinf_vo_vd(d), vcast_vd_d(SLEEF_INFINITY), x); + x = vsel_vd_vo_vd_vd(vor_vo_vo_vo(vlt_vo_vd_vd(d, vcast_vd_d(0)), visnan_vo_vd(d)), vcast_vd_d(SLEEF_NAN), x); + x = vsel_vd_vo_vd_vd(veq_vo_vd_vd(d, vcast_vd_d(0)), vcast_vd_d(-SLEEF_INFINITY), x); +#else + x = vmla_vd_vd_vd_vd(x, vcast_vd_d(2), vmul_vd_vd_vd(vcast_vd_d(0.693147180559945286226764), e)); + x = vmla_vd_vd_vd_vd(x3, t, x); + + x = vfixup_vd_vd_vd_vi2_i(x, d, vcast_vi2_i((5 << (5*4))), 0); +#endif + + return x; +} +#endif // #if !defined(DETERMINISTIC) + +EXPORT CONST VECTOR_CC vdouble xexp(vdouble d) { + vdouble u = vrint_vd_vd(vmul_vd_vd_vd(d, vcast_vd_d(R_LN2))), s; + vint q = vrint_vi_vd(u); + + s = vmla_vd_vd_vd_vd(u, vcast_vd_d(-L2U), d); + s = vmla_vd_vd_vd_vd(u, vcast_vd_d(-L2L), s); + +#ifdef ENABLE_FMA_DP + vdouble s2 = vmul_vd_vd_vd(s, s), s4 = vmul_vd_vd_vd(s2, s2), s8 = vmul_vd_vd_vd(s4, s4); + u = POLY10(s, s2, s4, s8, + +0.2081276378237164457e-8, + +0.2511210703042288022e-7, + +0.2755762628169491192e-6, + +0.2755723402025388239e-5, + +0.2480158687479686264e-4, + +0.1984126989855865850e-3, + +0.1388888888914497797e-2, + +0.8333333333314938210e-2, + +0.4166666666666602598e-1, + +0.1666666666666669072e+0); + u = vfma_vd_vd_vd_vd(u, s, vcast_vd_d(+0.5000000000000000000e+0)); + u = vfma_vd_vd_vd_vd(u, s, vcast_vd_d(+0.1000000000000000000e+1)); + u = vfma_vd_vd_vd_vd(u, s, vcast_vd_d(+0.1000000000000000000e+1)); +#else // #ifdef ENABLE_FMA_DP + vdouble s2 = vmul_vd_vd_vd(s, s), s4 = vmul_vd_vd_vd(s2, s2), s8 = vmul_vd_vd_vd(s4, s4); + u = POLY10(s, s2, s4, s8, + 2.08860621107283687536341e-09, + 2.51112930892876518610661e-08, + 2.75573911234900471893338e-07, + 2.75572362911928827629423e-06, + 2.4801587159235472998791e-05, + 0.000198412698960509205564975, + 0.00138888888889774492207962, + 0.00833333333331652721664984, + 0.0416666666666665047591422, + 0.166666666666666851703837); + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(+0.5000000000000000000e+0)); + + u = vadd_vd_vd_vd(vcast_vd_d(1), vmla_vd_vd_vd_vd(vmul_vd_vd_vd(s, s), u, s)); +#endif // #ifdef ENABLE_FMA_DP + + u = vldexp2_vd_vd_vi(u, q); + + u = vsel_vd_vo_vd_vd(vgt_vo_vd_vd(d, vcast_vd_d(709.78271114955742909217217426)), vcast_vd_d(SLEEF_INFINITY), u); + u = vreinterpret_vd_vm(vandnot_vm_vo64_vm(vlt_vo_vd_vd(d, vcast_vd_d(-1000)), vreinterpret_vm_vd(u))); + + return u; +} + +static INLINE CONST VECTOR_CC vdouble expm1k(vdouble d) { + vdouble u = vrint_vd_vd(vmul_vd_vd_vd(d, vcast_vd_d(R_LN2))), s; + vint q = vrint_vi_vd(u); + + s = vmla_vd_vd_vd_vd(u, vcast_vd_d(-L2U), d); + s = vmla_vd_vd_vd_vd(u, vcast_vd_d(-L2L), s); + + vdouble s2 = vmul_vd_vd_vd(s, s), s4 = vmul_vd_vd_vd(s2, s2), s8 = vmul_vd_vd_vd(s4, s4); + u = POLY10(s, s2, s4, s8, + 2.08860621107283687536341e-09, + 2.51112930892876518610661e-08, + 2.75573911234900471893338e-07, + 2.75572362911928827629423e-06, + 2.4801587159235472998791e-05, + 0.000198412698960509205564975, + 0.00138888888889774492207962, + 0.00833333333331652721664984, + 0.0416666666666665047591422, + 0.166666666666666851703837); + + u = vadd_vd_vd_vd(vmla_vd_vd_vd_vd(s2, vcast_vd_d(0.5), vmul_vd_vd_vd(vmul_vd_vd_vd(s2, s), u)), s); + + u = vsel_vd_vo_vd_vd(vcast_vo64_vo32(veq_vo_vi_vi(q, vcast_vi_i(0))), u, + vsub_vd_vd_vd(vldexp2_vd_vd_vi(vadd_vd_vd_vd(u, vcast_vd_d(1)), q), vcast_vd_d(1))); + + return u; +} + +static INLINE CONST VECTOR_CC vdouble2 logk(vdouble d) { + vdouble2 x, x2, s; + vdouble t, m; + +#if !defined(ENABLE_AVX512F) && !defined(ENABLE_AVX512FNOFMA) + vopmask o = vlt_vo_vd_vd(d, vcast_vd_d(SLEEF_DBL_MIN)); + d = vsel_vd_vo_vd_vd(o, vmul_vd_vd_vd(d, vcast_vd_d((double)(INT64_C(1) << 32) * (double)(INT64_C(1) << 32))), d); + vint e = vilogb2k_vi_vd(vmul_vd_vd_vd(d, vcast_vd_d(1.0/0.75))); + m = vldexp3_vd_vd_vi(d, vneg_vi_vi(e)); + e = vsel_vi_vo_vi_vi(vcast_vo32_vo64(o), vsub_vi_vi_vi(e, vcast_vi_i(64)), e); +#else + vdouble e = vgetexp_vd_vd(vmul_vd_vd_vd(d, vcast_vd_d(1.0/0.75))); + e = vsel_vd_vo_vd_vd(vispinf_vo_vd(e), vcast_vd_d(1024.0), e); + m = vgetmant_vd_vd(d); +#endif + + x = dddiv_vd2_vd2_vd2(ddadd2_vd2_vd_vd(vcast_vd_d(-1), m), ddadd2_vd2_vd_vd(vcast_vd_d(1), m)); + x2 = ddsqu_vd2_vd2(x); + + vdouble x4 = vmul_vd_vd_vd(vd2getx_vd_vd2(x2), vd2getx_vd_vd2(x2)), x8 = vmul_vd_vd_vd(x4, x4), x16 = vmul_vd_vd_vd(x8, x8); + t = POLY9(vd2getx_vd_vd2(x2), x4, x8, x16, + 0.116255524079935043668677, + 0.103239680901072952701192, + 0.117754809412463995466069, + 0.13332981086846273921509, + 0.153846227114512262845736, + 0.181818180850050775676507, + 0.222222222230083560345903, + 0.285714285714249172087875, + 0.400000000000000077715612); + + vdouble2 c = vcast_vd2_d_d(0.666666666666666629659233, 3.80554962542412056336616e-17); +#if !defined(ENABLE_AVX512F) && !defined(ENABLE_AVX512FNOFMA) + s = ddmul_vd2_vd2_vd(vcast_vd2_d_d(0.693147180559945286226764, 2.319046813846299558417771e-17), vcast_vd_vi(e)); +#else + s = ddmul_vd2_vd2_vd(vcast_vd2_d_d(0.693147180559945286226764, 2.319046813846299558417771e-17), e); +#endif + s = ddadd_vd2_vd2_vd2(s, ddscale_vd2_vd2_vd(x, vcast_vd_d(2))); + x = ddmul_vd2_vd2_vd2(x2, x); + s = ddadd_vd2_vd2_vd2(s, ddmul_vd2_vd2_vd2(x, c)); + x = ddmul_vd2_vd2_vd2(x2, x); + s = ddadd_vd2_vd2_vd2(s, ddmul_vd2_vd2_vd(x, t)); + + return s; +} + +#if !defined(DETERMINISTIC) +EXPORT CONST VECTOR_CC vdouble xlog_u1(vdouble d) { + vdouble2 x; + vdouble t, m, x2; + +#if !defined(ENABLE_AVX512F) && !defined(ENABLE_AVX512FNOFMA) + vopmask o = vlt_vo_vd_vd(d, vcast_vd_d(SLEEF_DBL_MIN)); + d = vsel_vd_vo_vd_vd(o, vmul_vd_vd_vd(d, vcast_vd_d((double)(INT64_C(1) << 32) * (double)(INT64_C(1) << 32))), d); + vint e = vilogb2k_vi_vd(vmul_vd_vd_vd(d, vcast_vd_d(1.0/0.75))); + m = vldexp3_vd_vd_vi(d, vneg_vi_vi(e)); + e = vsel_vi_vo_vi_vi(vcast_vo32_vo64(o), vsub_vi_vi_vi(e, vcast_vi_i(64)), e); +#else + vdouble e = vgetexp_vd_vd(vmul_vd_vd_vd(d, vcast_vd_d(1.0/0.75))); + e = vsel_vd_vo_vd_vd(vispinf_vo_vd(e), vcast_vd_d(1024.0), e); + m = vgetmant_vd_vd(d); +#endif + + x = dddiv_vd2_vd2_vd2(ddadd2_vd2_vd_vd(vcast_vd_d(-1), m), ddadd2_vd2_vd_vd(vcast_vd_d(1), m)); + x2 = vmul_vd_vd_vd(vd2getx_vd_vd2(x), vd2getx_vd_vd2(x)); + + vdouble x4 = vmul_vd_vd_vd(x2, x2), x8 = vmul_vd_vd_vd(x4, x4); + t = POLY7(x2, x4, x8, + 0.1532076988502701353e+0, + 0.1525629051003428716e+0, + 0.1818605932937785996e+0, + 0.2222214519839380009e+0, + 0.2857142932794299317e+0, + 0.3999999999635251990e+0, + 0.6666666666667333541e+0); + +#if !defined(ENABLE_AVX512F) && !defined(ENABLE_AVX512FNOFMA) + vdouble2 s = ddmul_vd2_vd2_vd(vcast_vd2_d_d(0.693147180559945286226764, 2.319046813846299558417771e-17), vcast_vd_vi(e)); +#else + vdouble2 s = ddmul_vd2_vd2_vd(vcast_vd2_d_d(0.693147180559945286226764, 2.319046813846299558417771e-17), e); +#endif + + s = ddadd_vd2_vd2_vd2(s, ddscale_vd2_vd2_vd(x, vcast_vd_d(2))); + s = ddadd_vd2_vd2_vd(s, vmul_vd_vd_vd(vmul_vd_vd_vd(x2, vd2getx_vd_vd2(x)), t)); + + vdouble r = vadd_vd_vd_vd(vd2getx_vd_vd2(s), vd2gety_vd_vd2(s)); + +#if !defined(ENABLE_AVX512F) && !defined(ENABLE_AVX512FNOFMA) + r = vsel_vd_vo_vd_vd(vispinf_vo_vd(d), vcast_vd_d(SLEEF_INFINITY), r); + r = vsel_vd_vo_vd_vd(vor_vo_vo_vo(vlt_vo_vd_vd(d, vcast_vd_d(0)), visnan_vo_vd(d)), vcast_vd_d(SLEEF_NAN), r); + r = vsel_vd_vo_vd_vd(veq_vo_vd_vd(d, vcast_vd_d(0)), vcast_vd_d(-SLEEF_INFINITY), r); +#else + r = vfixup_vd_vd_vd_vi2_i(r, d, vcast_vi2_i((4 << (2*4)) | (3 << (4*4)) | (5 << (5*4)) | (2 << (6*4))), 0); +#endif + + return r; +} +#endif // #if !defined(DETERMINISTIC) + +static INLINE CONST VECTOR_CC vdouble expk(vdouble2 d) { + vdouble u = vmul_vd_vd_vd(vadd_vd_vd_vd(vd2getx_vd_vd2(d), vd2gety_vd_vd2(d)), vcast_vd_d(R_LN2)); + vdouble dq = vrint_vd_vd(u); + vint q = vrint_vi_vd(dq); + vdouble2 s, t; + + s = ddadd2_vd2_vd2_vd(d, vmul_vd_vd_vd(dq, vcast_vd_d(-L2U))); + s = ddadd2_vd2_vd2_vd(s, vmul_vd_vd_vd(dq, vcast_vd_d(-L2L))); + + s = ddnormalize_vd2_vd2(s); + + vdouble s2 = vmul_vd_vd_vd(vd2getx_vd_vd2(s), vd2getx_vd_vd2(s)), s4 = vmul_vd_vd_vd(s2, s2), s8 = vmul_vd_vd_vd(s4, s4); + u = POLY10(vd2getx_vd_vd2(s), s2, s4, s8, + 2.51069683420950419527139e-08, + 2.76286166770270649116855e-07, + 2.75572496725023574143864e-06, + 2.48014973989819794114153e-05, + 0.000198412698809069797676111, + 0.0013888888939977128960529, + 0.00833333333332371417601081, + 0.0416666666665409524128449, + 0.166666666666666740681535, + 0.500000000000000999200722); + + t = ddadd_vd2_vd_vd2(vcast_vd_d(1), s); + t = ddadd_vd2_vd2_vd2(t, ddmul_vd2_vd2_vd(ddsqu_vd2_vd2(s), u)); + + u = vadd_vd_vd_vd(vd2getx_vd_vd2(t), vd2gety_vd_vd2(t)); + u = vldexp2_vd_vd_vi(u, q); + + u = vreinterpret_vd_vm(vandnot_vm_vo64_vm(vlt_vo_vd_vd(vd2getx_vd_vd2(d), vcast_vd_d(-1000)), vreinterpret_vm_vd(u))); + + return u; +} + +#if !defined(DETERMINISTIC) +EXPORT CONST VECTOR_CC vdouble xpow(vdouble x, vdouble y) { +#if 1 + vopmask yisint = visint_vo_vd(y); + vopmask yisodd = vand_vo_vo_vo(visodd_vo_vd(y), yisint); + + vdouble2 d = ddmul_vd2_vd2_vd(logk(vabs_vd_vd(x)), y); + vdouble result = expk(d); + result = vsel_vd_vo_vd_vd(vgt_vo_vd_vd(vd2getx_vd_vd2(d), vcast_vd_d(709.78271114955742909217217426)), vcast_vd_d(SLEEF_INFINITY), result); + + result = vmul_vd_vd_vd(result, + vsel_vd_vo_vd_vd(vgt_vo_vd_vd(x, vcast_vd_d(0)), + vcast_vd_d(1), + vsel_vd_vo_vd_vd(yisint, vsel_vd_vo_vd_vd(yisodd, vcast_vd_d(-1.0), vcast_vd_d(1)), vcast_vd_d(SLEEF_NAN)))); + + vdouble efx = vmulsign_vd_vd_vd(vsub_vd_vd_vd(vabs_vd_vd(x), vcast_vd_d(1)), y); + + result = vsel_vd_vo_vd_vd(visinf_vo_vd(y), + vreinterpret_vd_vm(vandnot_vm_vo64_vm(vlt_vo_vd_vd(efx, vcast_vd_d(0.0)), + vreinterpret_vm_vd(vsel_vd_vo_vd_vd(veq_vo_vd_vd(efx, vcast_vd_d(0.0)), + vcast_vd_d(1.0), + vcast_vd_d(SLEEF_INFINITY))))), + result); + + result = vsel_vd_vo_vd_vd(vor_vo_vo_vo(visinf_vo_vd(x), veq_vo_vd_vd(x, vcast_vd_d(0.0))), + vmulsign_vd_vd_vd(vsel_vd_vo_vd_vd(vxor_vo_vo_vo(vsignbit_vo_vd(y), veq_vo_vd_vd(x, vcast_vd_d(0.0))), + vcast_vd_d(0), vcast_vd_d(SLEEF_INFINITY)), + vsel_vd_vo_vd_vd(yisodd, x, vcast_vd_d(1))), result); + + result = vreinterpret_vd_vm(vor_vm_vo64_vm(vor_vo_vo_vo(visnan_vo_vd(x), visnan_vo_vd(y)), vreinterpret_vm_vd(result))); + + result = vsel_vd_vo_vd_vd(vor_vo_vo_vo(veq_vo_vd_vd(y, vcast_vd_d(0)), veq_vo_vd_vd(x, vcast_vd_d(1))), vcast_vd_d(1), result); + + return result; +#else + return expk(ddmul_vd2_vd2_vd(logk(x), y)); +#endif +} +#endif // #if !defined(DETERMINISTIC) + +static INLINE CONST VECTOR_CC vdouble2 expk2(vdouble2 d) { + vdouble u = vmul_vd_vd_vd(vadd_vd_vd_vd(vd2getx_vd_vd2(d), vd2gety_vd_vd2(d)), vcast_vd_d(R_LN2)); + vdouble dq = vrint_vd_vd(u); + vint q = vrint_vi_vd(dq); + vdouble2 s, t; + + s = ddadd2_vd2_vd2_vd(d, vmul_vd_vd_vd(dq, vcast_vd_d(-L2U))); + s = ddadd2_vd2_vd2_vd(s, vmul_vd_vd_vd(dq, vcast_vd_d(-L2L))); + + vdouble2 s2 = ddsqu_vd2_vd2(s), s4 = ddsqu_vd2_vd2(s2); + vdouble s8 = vmul_vd_vd_vd(vd2getx_vd_vd2(s4), vd2getx_vd_vd2(s4)); + u = POLY10(vd2getx_vd_vd2(s), vd2getx_vd_vd2(s2), vd2getx_vd_vd2(s4), s8, + +0.1602472219709932072e-9, + +0.2092255183563157007e-8, + +0.2505230023782644465e-7, + +0.2755724800902135303e-6, + +0.2755731892386044373e-5, + +0.2480158735605815065e-4, + +0.1984126984148071858e-3, + +0.1388888888886763255e-2, + +0.8333333333333347095e-2, + +0.4166666666666669905e-1); + + t = ddadd_vd2_vd_vd2(vcast_vd_d(0.5), ddmul_vd2_vd2_vd(s, vcast_vd_d(+0.1666666666666666574e+0))); + t = ddadd_vd2_vd_vd2(vcast_vd_d(1.0), ddmul_vd2_vd2_vd2(t, s)); + t = ddadd_vd2_vd_vd2(vcast_vd_d(1.0), ddmul_vd2_vd2_vd2(t, s)); + t = ddadd_vd2_vd2_vd2(t, ddmul_vd2_vd2_vd(s4, u)); + + t = vd2setx_vd2_vd2_vd(t, vldexp2_vd_vd_vi(vd2getx_vd_vd2(t), q)); + t = vd2sety_vd2_vd2_vd(t, vldexp2_vd_vd_vi(vd2gety_vd_vd2(t), q)); + + t = vd2setx_vd2_vd2_vd(t, vreinterpret_vd_vm(vandnot_vm_vo64_vm(vlt_vo_vd_vd(vd2getx_vd_vd2(d), vcast_vd_d(-1000)), vreinterpret_vm_vd(vd2getx_vd_vd2(t))))); + t = vd2sety_vd2_vd2_vd(t, vreinterpret_vd_vm(vandnot_vm_vo64_vm(vlt_vo_vd_vd(vd2getx_vd_vd2(d), vcast_vd_d(-1000)), vreinterpret_vm_vd(vd2gety_vd_vd2(t))))); + + return t; +} + +#if !defined(DETERMINISTIC) +EXPORT CONST VECTOR_CC vdouble xsinh(vdouble x) { + vdouble y = vabs_vd_vd(x); + vdouble2 d = expk2(vcast_vd2_vd_vd(y, vcast_vd_d(0))); + d = ddsub_vd2_vd2_vd2(d, ddrec_vd2_vd2(d)); + y = vmul_vd_vd_vd(vadd_vd_vd_vd(vd2getx_vd_vd2(d), vd2gety_vd_vd2(d)), vcast_vd_d(0.5)); + + y = vsel_vd_vo_vd_vd(vor_vo_vo_vo(vgt_vo_vd_vd(vabs_vd_vd(x), vcast_vd_d(710)), visnan_vo_vd(y)), vcast_vd_d(SLEEF_INFINITY), y); + y = vmulsign_vd_vd_vd(y, x); + y = vreinterpret_vd_vm(vor_vm_vo64_vm(visnan_vo_vd(x), vreinterpret_vm_vd(y))); + + return y; +} + +EXPORT CONST VECTOR_CC vdouble xcosh(vdouble x) { + vdouble y = vabs_vd_vd(x); + vdouble2 d = expk2(vcast_vd2_vd_vd(y, vcast_vd_d(0))); + d = ddadd_vd2_vd2_vd2(d, ddrec_vd2_vd2(d)); + y = vmul_vd_vd_vd(vadd_vd_vd_vd(vd2getx_vd_vd2(d), vd2gety_vd_vd2(d)), vcast_vd_d(0.5)); + + y = vsel_vd_vo_vd_vd(vor_vo_vo_vo(vgt_vo_vd_vd(vabs_vd_vd(x), vcast_vd_d(710)), visnan_vo_vd(y)), vcast_vd_d(SLEEF_INFINITY), y); + y = vreinterpret_vd_vm(vor_vm_vo64_vm(visnan_vo_vd(x), vreinterpret_vm_vd(y))); + + return y; +} + +EXPORT CONST VECTOR_CC vdouble xtanh(vdouble x) { + vdouble y = vabs_vd_vd(x); + vdouble2 d = expk2(vcast_vd2_vd_vd(y, vcast_vd_d(0))); + vdouble2 e = ddrec_vd2_vd2(d); + d = dddiv_vd2_vd2_vd2(ddadd2_vd2_vd2_vd2(d, ddneg_vd2_vd2(e)), ddadd2_vd2_vd2_vd2(d, e)); + y = vadd_vd_vd_vd(vd2getx_vd_vd2(d), vd2gety_vd_vd2(d)); + + y = vsel_vd_vo_vd_vd(vor_vo_vo_vo(vgt_vo_vd_vd(vabs_vd_vd(x), vcast_vd_d(18.714973875)), visnan_vo_vd(y)), vcast_vd_d(1.0), y); + y = vmulsign_vd_vd_vd(y, x); + y = vreinterpret_vd_vm(vor_vm_vo64_vm(visnan_vo_vd(x), vreinterpret_vm_vd(y))); + + return y; +} + +EXPORT CONST VECTOR_CC vdouble xsinh_u35(vdouble x) { + vdouble e = expm1k(vabs_vd_vd(x)); + + vdouble y = vdiv_vd_vd_vd(vadd_vd_vd_vd(e, vcast_vd_d(2)), vadd_vd_vd_vd(e, vcast_vd_d(1))); + y = vmul_vd_vd_vd(y, vmul_vd_vd_vd(vcast_vd_d(0.5), e)); + + y = vsel_vd_vo_vd_vd(vor_vo_vo_vo(vgt_vo_vd_vd(vabs_vd_vd(x), vcast_vd_d(709)), visnan_vo_vd(y)), vcast_vd_d(SLEEF_INFINITY), y); + y = vmulsign_vd_vd_vd(y, x); + y = vreinterpret_vd_vm(vor_vm_vo64_vm(visnan_vo_vd(x), vreinterpret_vm_vd(y))); + + return y; +} + +EXPORT CONST VECTOR_CC vdouble xcosh_u35(vdouble x) { + vdouble e = xexp(vabs_vd_vd(x)); + vdouble y = vmla_vd_vd_vd_vd(vcast_vd_d(0.5), e, vdiv_vd_vd_vd(vcast_vd_d(0.5), e)); + + y = vsel_vd_vo_vd_vd(vor_vo_vo_vo(vgt_vo_vd_vd(vabs_vd_vd(x), vcast_vd_d(709)), visnan_vo_vd(y)), vcast_vd_d(SLEEF_INFINITY), y); + y = vreinterpret_vd_vm(vor_vm_vo64_vm(visnan_vo_vd(x), vreinterpret_vm_vd(y))); + + return y; +} + +EXPORT CONST VECTOR_CC vdouble xtanh_u35(vdouble x) { + vdouble d = expm1k(vmul_vd_vd_vd(vcast_vd_d(2), vabs_vd_vd(x))); + vdouble y = vdiv_vd_vd_vd(d, vadd_vd_vd_vd(vcast_vd_d(2), d)); + + y = vsel_vd_vo_vd_vd(vor_vo_vo_vo(vgt_vo_vd_vd(vabs_vd_vd(x), vcast_vd_d(18.714973875)), visnan_vo_vd(y)), vcast_vd_d(1.0), y); + y = vmulsign_vd_vd_vd(y, x); + y = vreinterpret_vd_vm(vor_vm_vo64_vm(visnan_vo_vd(x), vreinterpret_vm_vd(y))); + + return y; +} + +static INLINE CONST VECTOR_CC vdouble2 logk2(vdouble2 d) { + vdouble2 x, x2, m, s; + vdouble t; + vint e; + + e = vilogbk_vi_vd(vmul_vd_vd_vd(vd2getx_vd_vd2(d), vcast_vd_d(1.0/0.75))); + + m = vd2setxy_vd2_vd_vd(vldexp2_vd_vd_vi(vd2getx_vd_vd2(d), vneg_vi_vi(e)), + vldexp2_vd_vd_vi(vd2gety_vd_vd2(d), vneg_vi_vi(e))); + + x = dddiv_vd2_vd2_vd2(ddadd2_vd2_vd2_vd(m, vcast_vd_d(-1)), ddadd2_vd2_vd2_vd(m, vcast_vd_d(1))); + x2 = ddsqu_vd2_vd2(x); + + vdouble x4 = vmul_vd_vd_vd(vd2getx_vd_vd2(x2), vd2getx_vd_vd2(x2)), x8 = vmul_vd_vd_vd(x4, x4); + t = POLY7(vd2getx_vd_vd2(x2), x4, x8, + 0.13860436390467167910856, + 0.131699838841615374240845, + 0.153914168346271945653214, + 0.181816523941564611721589, + 0.22222224632662035403996, + 0.285714285511134091777308, + 0.400000000000914013309483); + t = vmla_vd_vd_vd_vd(t, vd2getx_vd_vd2(x2), vcast_vd_d(0.666666666666664853302393)); + + s = ddmul_vd2_vd2_vd(vcast_vd2_d_d(0.693147180559945286226764, 2.319046813846299558417771e-17), vcast_vd_vi(e)); + s = ddadd_vd2_vd2_vd2(s, ddscale_vd2_vd2_vd(x, vcast_vd_d(2))); + s = ddadd_vd2_vd2_vd2(s, ddmul_vd2_vd2_vd(ddmul_vd2_vd2_vd2(x2, x), t)); + + return s; +} + +EXPORT CONST VECTOR_CC vdouble xasinh(vdouble x) { + vdouble y = vabs_vd_vd(x); + vopmask o = vgt_vo_vd_vd(y, vcast_vd_d(1)); + vdouble2 d; + + d = vsel_vd2_vo_vd2_vd2(o, ddrec_vd2_vd(x), vcast_vd2_vd_vd(y, vcast_vd_d(0))); + d = ddsqrt_vd2_vd2(ddadd2_vd2_vd2_vd(ddsqu_vd2_vd2(d), vcast_vd_d(1))); + d = vsel_vd2_vo_vd2_vd2(o, ddmul_vd2_vd2_vd(d, y), d); + + d = logk2(ddnormalize_vd2_vd2(ddadd2_vd2_vd2_vd(d, x))); + y = vadd_vd_vd_vd(vd2getx_vd_vd2(d), vd2gety_vd_vd2(d)); + + y = vsel_vd_vo_vd_vd(vor_vo_vo_vo(vgt_vo_vd_vd(vabs_vd_vd(x), vcast_vd_d(SQRT_DBL_MAX)), + visnan_vo_vd(y)), + vmulsign_vd_vd_vd(vcast_vd_d(SLEEF_INFINITY), x), y); + + y = vreinterpret_vd_vm(vor_vm_vo64_vm(visnan_vo_vd(x), vreinterpret_vm_vd(y))); + y = vsel_vd_vo_vd_vd(visnegzero_vo_vd(x), vcast_vd_d(-0.0), y); + + return y; +} + +EXPORT CONST VECTOR_CC vdouble xacosh(vdouble x) { + vdouble2 d = logk2(ddadd2_vd2_vd2_vd(ddmul_vd2_vd2_vd2(ddsqrt_vd2_vd2(ddadd2_vd2_vd_vd(x, vcast_vd_d(1))), ddsqrt_vd2_vd2(ddadd2_vd2_vd_vd(x, vcast_vd_d(-1)))), x)); + vdouble y = vadd_vd_vd_vd(vd2getx_vd_vd2(d), vd2gety_vd_vd2(d)); + + y = vsel_vd_vo_vd_vd(vor_vo_vo_vo(vgt_vo_vd_vd(vabs_vd_vd(x), vcast_vd_d(SQRT_DBL_MAX)), + visnan_vo_vd(y)), + vcast_vd_d(SLEEF_INFINITY), y); + y = vreinterpret_vd_vm(vandnot_vm_vo64_vm(veq_vo_vd_vd(x, vcast_vd_d(1.0)), vreinterpret_vm_vd(y))); + + y = vreinterpret_vd_vm(vor_vm_vo64_vm(vlt_vo_vd_vd(x, vcast_vd_d(1.0)), vreinterpret_vm_vd(y))); + y = vreinterpret_vd_vm(vor_vm_vo64_vm(visnan_vo_vd(x), vreinterpret_vm_vd(y))); + + return y; +} + +EXPORT CONST VECTOR_CC vdouble xatanh(vdouble x) { + vdouble y = vabs_vd_vd(x); + vdouble2 d = logk2(dddiv_vd2_vd2_vd2(ddadd2_vd2_vd_vd(vcast_vd_d(1), y), ddadd2_vd2_vd_vd(vcast_vd_d(1), vneg_vd_vd(y)))); + y = vreinterpret_vd_vm(vor_vm_vo64_vm(vgt_vo_vd_vd(y, vcast_vd_d(1.0)), vreinterpret_vm_vd(vsel_vd_vo_vd_vd(veq_vo_vd_vd(y, vcast_vd_d(1.0)), vcast_vd_d(SLEEF_INFINITY), vmul_vd_vd_vd(vadd_vd_vd_vd(vd2getx_vd_vd2(d), vd2gety_vd_vd2(d)), vcast_vd_d(0.5)))))); + + y = vmulsign_vd_vd_vd(y, x); + y = vreinterpret_vd_vm(vor_vm_vo64_vm(vor_vo_vo_vo(visinf_vo_vd(x), visnan_vo_vd(y)), vreinterpret_vm_vd(y))); + y = vreinterpret_vd_vm(vor_vm_vo64_vm(visnan_vo_vd(x), vreinterpret_vm_vd(y))); + + return y; +} + +EXPORT CONST VECTOR_CC vdouble xcbrt(vdouble d) { + vdouble x, y, q = vcast_vd_d(1.0); + vint e, qu, re; + vdouble t; + +#if defined(ENABLE_AVX512F) || defined(ENABLE_AVX512FNOFMA) + vdouble s = d; +#endif + e = vadd_vi_vi_vi(vilogbk_vi_vd(vabs_vd_vd(d)), vcast_vi_i(1)); + d = vldexp2_vd_vd_vi(d, vneg_vi_vi(e)); + + t = vadd_vd_vd_vd(vcast_vd_vi(e), vcast_vd_d(6144)); + qu = vtruncate_vi_vd(vmul_vd_vd_vd(t, vcast_vd_d(1.0/3.0))); + re = vtruncate_vi_vd(vsub_vd_vd_vd(t, vmul_vd_vd_vd(vcast_vd_vi(qu), vcast_vd_d(3)))); + + q = vsel_vd_vo_vd_vd(vcast_vo64_vo32(veq_vo_vi_vi(re, vcast_vi_i(1))), vcast_vd_d(1.2599210498948731647672106), q); + q = vsel_vd_vo_vd_vd(vcast_vo64_vo32(veq_vo_vi_vi(re, vcast_vi_i(2))), vcast_vd_d(1.5874010519681994747517056), q); + q = vldexp2_vd_vd_vi(q, vsub_vi_vi_vi(qu, vcast_vi_i(2048))); + + q = vmulsign_vd_vd_vd(q, d); + + d = vabs_vd_vd(d); + + x = vcast_vd_d(-0.640245898480692909870982); + x = vmla_vd_vd_vd_vd(x, d, vcast_vd_d(2.96155103020039511818595)); + x = vmla_vd_vd_vd_vd(x, d, vcast_vd_d(-5.73353060922947843636166)); + x = vmla_vd_vd_vd_vd(x, d, vcast_vd_d(6.03990368989458747961407)); + x = vmla_vd_vd_vd_vd(x, d, vcast_vd_d(-3.85841935510444988821632)); + x = vmla_vd_vd_vd_vd(x, d, vcast_vd_d(2.2307275302496609725722)); + + y = vmul_vd_vd_vd(x, x); y = vmul_vd_vd_vd(y, y); x = vsub_vd_vd_vd(x, vmul_vd_vd_vd(vmlapn_vd_vd_vd_vd(d, y, x), vcast_vd_d(1.0 / 3.0))); + y = vmul_vd_vd_vd(vmul_vd_vd_vd(d, x), x); + y = vmul_vd_vd_vd(vsub_vd_vd_vd(y, vmul_vd_vd_vd(vmul_vd_vd_vd(vcast_vd_d(2.0 / 3.0), y), vmla_vd_vd_vd_vd(y, x, vcast_vd_d(-1.0)))), q); + +#if defined(ENABLE_AVX512F) || defined(ENABLE_AVX512FNOFMA) + y = vsel_vd_vo_vd_vd(visinf_vo_vd(s), vmulsign_vd_vd_vd(vcast_vd_d(SLEEF_INFINITY), s), y); + y = vsel_vd_vo_vd_vd(veq_vo_vd_vd(s, vcast_vd_d(0)), vmulsign_vd_vd_vd(vcast_vd_d(0), s), y); +#endif + + return y; +} + +EXPORT CONST VECTOR_CC vdouble xcbrt_u1(vdouble d) { + vdouble x, y, z, t; + vdouble2 q2 = vcast_vd2_d_d(1, 0), u, v; + vint e, qu, re; + +#if defined(ENABLE_AVX512F) || defined(ENABLE_AVX512FNOFMA) + vdouble s = d; +#endif + e = vadd_vi_vi_vi(vilogbk_vi_vd(vabs_vd_vd(d)), vcast_vi_i(1)); + d = vldexp2_vd_vd_vi(d, vneg_vi_vi(e)); + + t = vadd_vd_vd_vd(vcast_vd_vi(e), vcast_vd_d(6144)); + qu = vtruncate_vi_vd(vmul_vd_vd_vd(t, vcast_vd_d(1.0/3.0))); + re = vtruncate_vi_vd(vsub_vd_vd_vd(t, vmul_vd_vd_vd(vcast_vd_vi(qu), vcast_vd_d(3)))); + + q2 = vsel_vd2_vo_vd2_vd2(vcast_vo64_vo32(veq_vo_vi_vi(re, vcast_vi_i(1))), vcast_vd2_d_d(1.2599210498948731907, -2.5899333753005069177e-17), q2); + q2 = vsel_vd2_vo_vd2_vd2(vcast_vo64_vo32(veq_vo_vi_vi(re, vcast_vi_i(2))), vcast_vd2_d_d(1.5874010519681995834, -1.0869008194197822986e-16), q2); + + q2 = vd2setxy_vd2_vd_vd(vmulsign_vd_vd_vd(vd2getx_vd_vd2(q2), d), vmulsign_vd_vd_vd(vd2gety_vd_vd2(q2), d)); + d = vabs_vd_vd(d); + + x = vcast_vd_d(-0.640245898480692909870982); + x = vmla_vd_vd_vd_vd(x, d, vcast_vd_d(2.96155103020039511818595)); + x = vmla_vd_vd_vd_vd(x, d, vcast_vd_d(-5.73353060922947843636166)); + x = vmla_vd_vd_vd_vd(x, d, vcast_vd_d(6.03990368989458747961407)); + x = vmla_vd_vd_vd_vd(x, d, vcast_vd_d(-3.85841935510444988821632)); + x = vmla_vd_vd_vd_vd(x, d, vcast_vd_d(2.2307275302496609725722)); + + y = vmul_vd_vd_vd(x, x); y = vmul_vd_vd_vd(y, y); x = vsub_vd_vd_vd(x, vmul_vd_vd_vd(vmlapn_vd_vd_vd_vd(d, y, x), vcast_vd_d(1.0 / 3.0))); + + z = x; + + u = ddmul_vd2_vd_vd(x, x); + u = ddmul_vd2_vd2_vd2(u, u); + u = ddmul_vd2_vd2_vd(u, d); + u = ddadd2_vd2_vd2_vd(u, vneg_vd_vd(x)); + y = vadd_vd_vd_vd(vd2getx_vd_vd2(u), vd2gety_vd_vd2(u)); + + y = vmul_vd_vd_vd(vmul_vd_vd_vd(vcast_vd_d(-2.0 / 3.0), y), z); + v = ddadd2_vd2_vd2_vd(ddmul_vd2_vd_vd(z, z), y); + v = ddmul_vd2_vd2_vd(v, d); + v = ddmul_vd2_vd2_vd2(v, q2); + z = vldexp2_vd_vd_vi(vadd_vd_vd_vd(vd2getx_vd_vd2(v), vd2gety_vd_vd2(v)), vsub_vi_vi_vi(qu, vcast_vi_i(2048))); + +#if !defined(ENABLE_AVX512F) && !defined(ENABLE_AVX512FNOFMA) + z = vsel_vd_vo_vd_vd(visinf_vo_vd(d), vmulsign_vd_vd_vd(vcast_vd_d(SLEEF_INFINITY), vd2getx_vd_vd2(q2)), z); + z = vsel_vd_vo_vd_vd(veq_vo_vd_vd(d, vcast_vd_d(0)), vreinterpret_vd_vm(vsignbit_vm_vd(vd2getx_vd_vd2(q2))), z); +#else + z = vsel_vd_vo_vd_vd(visinf_vo_vd(s), vmulsign_vd_vd_vd(vcast_vd_d(SLEEF_INFINITY), s), z); + z = vsel_vd_vo_vd_vd(veq_vo_vd_vd(s, vcast_vd_d(0)), vmulsign_vd_vd_vd(vcast_vd_d(0), s), z); +#endif + + return z; +} +#endif // #if !defined(DETERMINISTIC) + +EXPORT CONST VECTOR_CC vdouble xexp2(vdouble d) { + vdouble u = vrint_vd_vd(d), s; + vint q = vrint_vi_vd(u); + + s = vsub_vd_vd_vd(d, u); + + vdouble s2 = vmul_vd_vd_vd(s, s), s4 = vmul_vd_vd_vd(s2, s2), s8 = vmul_vd_vd_vd(s4, s4); + u = POLY10(s, s2, s4, s8, + +0.4434359082926529454e-9, + +0.7073164598085707425e-8, + +0.1017819260921760451e-6, + +0.1321543872511327615e-5, + +0.1525273353517584730e-4, + +0.1540353045101147808e-3, + +0.1333355814670499073e-2, + +0.9618129107597600536e-2, + +0.5550410866482046596e-1, + +0.2402265069591012214e+0); + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(+0.6931471805599452862e+0)); + +#ifdef ENABLE_FMA_DP + u = vfma_vd_vd_vd_vd(u, s, vcast_vd_d(1)); +#else + u = vd2getx_vd_vd2(ddnormalize_vd2_vd2(ddadd_vd2_vd_vd2(vcast_vd_d(1), ddmul_vd2_vd_vd(u, s)))); +#endif + + u = vldexp2_vd_vd_vi(u, q); + + u = vsel_vd_vo_vd_vd(vge_vo_vd_vd(d, vcast_vd_d(1024)), vcast_vd_d(SLEEF_INFINITY), u); + u = vreinterpret_vd_vm(vandnot_vm_vo64_vm(vlt_vo_vd_vd(d, vcast_vd_d(-2000)), vreinterpret_vm_vd(u))); + + return u; +} + +EXPORT CONST VECTOR_CC vdouble xexp2_u35(vdouble d) { + vdouble u = vrint_vd_vd(d), s; + vint q = vrint_vi_vd(u); + + s = vsub_vd_vd_vd(d, u); + + vdouble s2 = vmul_vd_vd_vd(s, s), s4 = vmul_vd_vd_vd(s2, s2), s8 = vmul_vd_vd_vd(s4, s4); + u = POLY10(s, s2, s4, s8, + +0.4434359082926529454e-9, + +0.7073164598085707425e-8, + +0.1017819260921760451e-6, + +0.1321543872511327615e-5, + +0.1525273353517584730e-4, + +0.1540353045101147808e-3, + +0.1333355814670499073e-2, + +0.9618129107597600536e-2, + +0.5550410866482046596e-1, + +0.2402265069591012214e+0); + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(+0.6931471805599452862e+0)); + + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(1)); + + u = vldexp2_vd_vd_vi(u, q); + + u = vsel_vd_vo_vd_vd(vge_vo_vd_vd(d, vcast_vd_d(1024)), vcast_vd_d(SLEEF_INFINITY), u); + u = vreinterpret_vd_vm(vandnot_vm_vo64_vm(vlt_vo_vd_vd(d, vcast_vd_d(-2000)), vreinterpret_vm_vd(u))); + + return u; +} + +EXPORT CONST VECTOR_CC vdouble xexp10(vdouble d) { + vdouble u = vrint_vd_vd(vmul_vd_vd_vd(d, vcast_vd_d(LOG10_2))), s; + vint q = vrint_vi_vd(u); + + s = vmla_vd_vd_vd_vd(u, vcast_vd_d(-L10U), d); + s = vmla_vd_vd_vd_vd(u, vcast_vd_d(-L10L), s); + + u = vcast_vd_d(+0.2411463498334267652e-3); + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(+0.1157488415217187375e-2)); + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(+0.5013975546789733659e-2)); + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(+0.1959762320720533080e-1)); + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(+0.6808936399446784138e-1)); + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(+0.2069958494722676234e+0)); + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(+0.5393829292058536229e+0)); + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(+0.1171255148908541655e+1)); + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(+0.2034678592293432953e+1)); + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(+0.2650949055239205876e+1)); + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(+0.2302585092994045901e+1)); + +#ifdef ENABLE_FMA_DP + u = vfma_vd_vd_vd_vd(u, s, vcast_vd_d(1)); +#else + u = vd2getx_vd_vd2(ddnormalize_vd2_vd2(ddadd_vd2_vd_vd2(vcast_vd_d(1), ddmul_vd2_vd_vd(u, s)))); +#endif + + u = vldexp2_vd_vd_vi(u, q); + + u = vsel_vd_vo_vd_vd(vgt_vo_vd_vd(d, vcast_vd_d(308.25471555991671)), vcast_vd_d(SLEEF_INFINITY), u); + u = vreinterpret_vd_vm(vandnot_vm_vo64_vm(vlt_vo_vd_vd(d, vcast_vd_d(-350)), vreinterpret_vm_vd(u))); + + return u; +} + +EXPORT CONST VECTOR_CC vdouble xexp10_u35(vdouble d) { + vdouble u = vrint_vd_vd(vmul_vd_vd_vd(d, vcast_vd_d(LOG10_2))), s; + vint q = vrint_vi_vd(u); + + s = vmla_vd_vd_vd_vd(u, vcast_vd_d(-L10U), d); + s = vmla_vd_vd_vd_vd(u, vcast_vd_d(-L10L), s); + + vdouble s2 = vmul_vd_vd_vd(s, s), s4 = vmul_vd_vd_vd(s2, s2), s8 = vmul_vd_vd_vd(s4, s4); + u = POLY11(s, s2, s4, s8, + +0.2411463498334267652e-3, + +0.1157488415217187375e-2, + +0.5013975546789733659e-2, + +0.1959762320720533080e-1, + +0.6808936399446784138e-1, + +0.2069958494722676234e+0, + +0.5393829292058536229e+0, + +0.1171255148908541655e+1, + +0.2034678592293432953e+1, + +0.2650949055239205876e+1, + +0.2302585092994045901e+1); + + u = vmla_vd_vd_vd_vd(u, s, vcast_vd_d(1)); + + u = vldexp2_vd_vd_vi(u, q); + + u = vsel_vd_vo_vd_vd(vgt_vo_vd_vd(d, vcast_vd_d(308.25471555991671)), vcast_vd_d(SLEEF_INFINITY), u); + u = vreinterpret_vd_vm(vandnot_vm_vo64_vm(vlt_vo_vd_vd(d, vcast_vd_d(-350)), vreinterpret_vm_vd(u))); + + return u; +} + +#if !defined(DETERMINISTIC) +EXPORT CONST VECTOR_CC vdouble xexpm1(vdouble a) { + vdouble2 d = ddadd2_vd2_vd2_vd(expk2(vcast_vd2_vd_vd(a, vcast_vd_d(0))), vcast_vd_d(-1.0)); + vdouble x = vadd_vd_vd_vd(vd2getx_vd_vd2(d), vd2gety_vd_vd2(d)); + x = vsel_vd_vo_vd_vd(vgt_vo_vd_vd(a, vcast_vd_d(709.782712893383996732223)), vcast_vd_d(SLEEF_INFINITY), x); + x = vsel_vd_vo_vd_vd(vlt_vo_vd_vd(a, vcast_vd_d(-36.736800569677101399113302437)), vcast_vd_d(-1), x); + x = vsel_vd_vo_vd_vd(visnegzero_vo_vd(a), vcast_vd_d(-0.0), x); + return x; +} + +EXPORT CONST VECTOR_CC vdouble xlog10(vdouble d) { + vdouble2 x; + vdouble t, m, x2; + +#if !defined(ENABLE_AVX512F) && !defined(ENABLE_AVX512FNOFMA) + vopmask o = vlt_vo_vd_vd(d, vcast_vd_d(SLEEF_DBL_MIN)); + d = vsel_vd_vo_vd_vd(o, vmul_vd_vd_vd(d, vcast_vd_d((double)(INT64_C(1) << 32) * (double)(INT64_C(1) << 32))), d); + vint e = vilogb2k_vi_vd(vmul_vd_vd_vd(d, vcast_vd_d(1.0/0.75))); + m = vldexp3_vd_vd_vi(d, vneg_vi_vi(e)); + e = vsel_vi_vo_vi_vi(vcast_vo32_vo64(o), vsub_vi_vi_vi(e, vcast_vi_i(64)), e); +#else + vdouble e = vgetexp_vd_vd(vmul_vd_vd_vd(d, vcast_vd_d(1.0/0.75))); + e = vsel_vd_vo_vd_vd(vispinf_vo_vd(e), vcast_vd_d(1024.0), e); + m = vgetmant_vd_vd(d); +#endif + + x = dddiv_vd2_vd2_vd2(ddadd2_vd2_vd_vd(vcast_vd_d(-1), m), ddadd2_vd2_vd_vd(vcast_vd_d(1), m)); + x2 = vmul_vd_vd_vd(vd2getx_vd_vd2(x), vd2getx_vd_vd2(x)); + + vdouble x4 = vmul_vd_vd_vd(x2, x2), x8 = vmul_vd_vd_vd(x4, x4); + t = POLY7(x2, x4, x8, + +0.6653725819576758460e-1, + +0.6625722782820833712e-1, + +0.7898105214313944078e-1, + +0.9650955035715275132e-1, + +0.1240841409721444993e+0, + +0.1737177927454605086e+0, + +0.2895296546021972617e+0); + +#if !defined(ENABLE_AVX512F) && !defined(ENABLE_AVX512FNOFMA) + vdouble2 s = ddmul_vd2_vd2_vd(vcast_vd2_d_d(0.30102999566398119802, -2.803728127785170339e-18), vcast_vd_vi(e)); +#else + vdouble2 s = ddmul_vd2_vd2_vd(vcast_vd2_d_d(0.30102999566398119802, -2.803728127785170339e-18), e); +#endif + + s = ddadd_vd2_vd2_vd2(s, ddmul_vd2_vd2_vd2(x, vcast_vd2_d_d(0.86858896380650363334, 1.1430059694096389311e-17))); + s = ddadd_vd2_vd2_vd(s, vmul_vd_vd_vd(vmul_vd_vd_vd(x2, vd2getx_vd_vd2(x)), t)); + + vdouble r = vadd_vd_vd_vd(vd2getx_vd_vd2(s), vd2gety_vd_vd2(s)); + +#if !defined(ENABLE_AVX512F) && !defined(ENABLE_AVX512FNOFMA) + r = vsel_vd_vo_vd_vd(vispinf_vo_vd(d), vcast_vd_d(SLEEF_INFINITY), r); + r = vsel_vd_vo_vd_vd(vor_vo_vo_vo(vlt_vo_vd_vd(d, vcast_vd_d(0)), visnan_vo_vd(d)), vcast_vd_d(SLEEF_NAN), r); + r = vsel_vd_vo_vd_vd(veq_vo_vd_vd(d, vcast_vd_d(0)), vcast_vd_d(-SLEEF_INFINITY), r); +#else + r = vfixup_vd_vd_vd_vi2_i(r, d, vcast_vi2_i((4 << (2*4)) | (3 << (4*4)) | (5 << (5*4)) | (2 << (6*4))), 0); +#endif + + return r; +} + +EXPORT CONST VECTOR_CC vdouble xlog2(vdouble d) { + vdouble2 x; + vdouble t, m, x2; + +#if !defined(ENABLE_AVX512F) && !defined(ENABLE_AVX512FNOFMA) + vopmask o = vlt_vo_vd_vd(d, vcast_vd_d(SLEEF_DBL_MIN)); + d = vsel_vd_vo_vd_vd(o, vmul_vd_vd_vd(d, vcast_vd_d((double)(INT64_C(1) << 32) * (double)(INT64_C(1) << 32))), d); + vint e = vilogb2k_vi_vd(vmul_vd_vd_vd(d, vcast_vd_d(1.0/0.75))); + m = vldexp3_vd_vd_vi(d, vneg_vi_vi(e)); + e = vsel_vi_vo_vi_vi(vcast_vo32_vo64(o), vsub_vi_vi_vi(e, vcast_vi_i(64)), e); +#else + vdouble e = vgetexp_vd_vd(vmul_vd_vd_vd(d, vcast_vd_d(1.0/0.75))); + e = vsel_vd_vo_vd_vd(vispinf_vo_vd(e), vcast_vd_d(1024.0), e); + m = vgetmant_vd_vd(d); +#endif + + x = dddiv_vd2_vd2_vd2(ddadd2_vd2_vd_vd(vcast_vd_d(-1), m), ddadd2_vd2_vd_vd(vcast_vd_d(1), m)); + x2 = vmul_vd_vd_vd(vd2getx_vd_vd2(x), vd2getx_vd_vd2(x)); + + vdouble x4 = vmul_vd_vd_vd(x2, x2), x8 = vmul_vd_vd_vd(x4, x4); + t = POLY7(x2, x4, x8, + +0.2211941750456081490e+0, + +0.2200768693152277689e+0, + +0.2623708057488514656e+0, + +0.3205977477944495502e+0, + +0.4121985945485324709e+0, + +0.5770780162997058982e+0, + +0.96179669392608091449); + +#if !defined(ENABLE_AVX512F) && !defined(ENABLE_AVX512FNOFMA) + vdouble2 s = ddadd2_vd2_vd_vd2(vcast_vd_vi(e), + ddmul_vd2_vd2_vd2(x, vcast_vd2_d_d(2.885390081777926774, 6.0561604995516736434e-18))); +#else + vdouble2 s = ddadd2_vd2_vd_vd2(e, + ddmul_vd2_vd2_vd2(x, vcast_vd2_d_d(2.885390081777926774, 6.0561604995516736434e-18))); +#endif + + s = ddadd2_vd2_vd2_vd(s, vmul_vd_vd_vd(vmul_vd_vd_vd(x2, vd2getx_vd_vd2(x)), t)); + + vdouble r = vadd_vd_vd_vd(vd2getx_vd_vd2(s), vd2gety_vd_vd2(s)); + +#if !defined(ENABLE_AVX512F) && !defined(ENABLE_AVX512FNOFMA) + r = vsel_vd_vo_vd_vd(vispinf_vo_vd(d), vcast_vd_d(SLEEF_INFINITY), r); + r = vsel_vd_vo_vd_vd(vor_vo_vo_vo(vlt_vo_vd_vd(d, vcast_vd_d(0)), visnan_vo_vd(d)), vcast_vd_d(SLEEF_NAN), r); + r = vsel_vd_vo_vd_vd(veq_vo_vd_vd(d, vcast_vd_d(0)), vcast_vd_d(-SLEEF_INFINITY), r); +#else + r = vfixup_vd_vd_vd_vi2_i(r, d, vcast_vi2_i((4 << (2*4)) | (3 << (4*4)) | (5 << (5*4)) | (2 << (6*4))), 0); +#endif + + return r; +} + +EXPORT CONST VECTOR_CC vdouble xlog2_u35(vdouble d) { + vdouble m, t, x, x2; + +#if !defined(ENABLE_AVX512F) && !defined(ENABLE_AVX512FNOFMA) + vopmask o = vlt_vo_vd_vd(d, vcast_vd_d(SLEEF_DBL_MIN)); + d = vsel_vd_vo_vd_vd(o, vmul_vd_vd_vd(d, vcast_vd_d((double)(INT64_C(1) << 32) * (double)(INT64_C(1) << 32))), d); + vint e = vilogb2k_vi_vd(vmul_vd_vd_vd(d, vcast_vd_d(1.0/0.75))); + m = vldexp3_vd_vd_vi(d, vneg_vi_vi(e)); + e = vsel_vi_vo_vi_vi(vcast_vo32_vo64(o), vsub_vi_vi_vi(e, vcast_vi_i(64)), e); +#else + vdouble e = vgetexp_vd_vd(vmul_vd_vd_vd(d, vcast_vd_d(1.0/0.75))); + e = vsel_vd_vo_vd_vd(vispinf_vo_vd(e), vcast_vd_d(1024.0), e); + m = vgetmant_vd_vd(d); +#endif + + x = vdiv_vd_vd_vd(vsub_vd_vd_vd(m, vcast_vd_d(1)), vadd_vd_vd_vd(m, vcast_vd_d(1))); + x2 = vmul_vd_vd_vd(x, x); + + t = vcast_vd_d(+0.2211941750456081490e+0); + t = vmla_vd_vd_vd_vd(t, x2, vcast_vd_d(+0.2200768693152277689e+0)); + t = vmla_vd_vd_vd_vd(t, x2, vcast_vd_d(+0.2623708057488514656e+0)); + t = vmla_vd_vd_vd_vd(t, x2, vcast_vd_d(+0.3205977477944495502e+0)); + t = vmla_vd_vd_vd_vd(t, x2, vcast_vd_d(+0.4121985945485324709e+0)); + t = vmla_vd_vd_vd_vd(t, x2, vcast_vd_d(+0.5770780162997058982e+0)); + t = vmla_vd_vd_vd_vd(t, x2, vcast_vd_d(+0.96179669392608091449 )); + +#if !defined(ENABLE_AVX512F) && !defined(ENABLE_AVX512FNOFMA) + vdouble2 s = ddadd_vd2_vd_vd2(vcast_vd_vi(e), + ddmul_vd2_vd_vd(x, vcast_vd_d(2.885390081777926774))); +#else + vdouble2 s = ddadd_vd2_vd_vd2(e, + ddmul_vd2_vd_vd(x, vcast_vd_d(2.885390081777926774))); +#endif + + vdouble r = vmla_vd_vd_vd_vd(t, vmul_vd_vd_vd(x, x2), vadd_vd_vd_vd(vd2getx_vd_vd2(s), vd2gety_vd_vd2(s))); + +#if !defined(ENABLE_AVX512F) && !defined(ENABLE_AVX512FNOFMA) + r = vsel_vd_vo_vd_vd(vispinf_vo_vd(d), vcast_vd_d(SLEEF_INFINITY), r); + r = vsel_vd_vo_vd_vd(vor_vo_vo_vo(vlt_vo_vd_vd(d, vcast_vd_d(0)), visnan_vo_vd(d)), vcast_vd_d(SLEEF_NAN), r); + r = vsel_vd_vo_vd_vd(veq_vo_vd_vd(d, vcast_vd_d(0)), vcast_vd_d(-SLEEF_INFINITY), r); +#else + r = vfixup_vd_vd_vd_vi2_i(r, d, vcast_vi2_i((4 << (2*4)) | (3 << (4*4)) | (5 << (5*4)) | (2 << (6*4))), 0); +#endif + + return r; +} + +EXPORT CONST VECTOR_CC vdouble xlog1p(vdouble d) { + vdouble2 x; + vdouble t, m, x2; + + vdouble dp1 = vadd_vd_vd_vd(d, vcast_vd_d(1)); + +#if !defined(ENABLE_AVX512F) && !defined(ENABLE_AVX512FNOFMA) + vopmask o = vlt_vo_vd_vd(dp1, vcast_vd_d(SLEEF_DBL_MIN)); + dp1 = vsel_vd_vo_vd_vd(o, vmul_vd_vd_vd(dp1, vcast_vd_d((double)(INT64_C(1) << 32) * (double)(INT64_C(1) << 32))), dp1); + vint e = vilogb2k_vi_vd(vmul_vd_vd_vd(dp1, vcast_vd_d(1.0/0.75))); + t = vldexp3_vd_vd_vi(vcast_vd_d(1), vneg_vi_vi(e)); + m = vmla_vd_vd_vd_vd(d, t, vsub_vd_vd_vd(t, vcast_vd_d(1))); + e = vsel_vi_vo_vi_vi(vcast_vo32_vo64(o), vsub_vi_vi_vi(e, vcast_vi_i(64)), e); + vdouble2 s = ddmul_vd2_vd2_vd(vcast_vd2_d_d(0.693147180559945286226764, 2.319046813846299558417771e-17), vcast_vd_vi(e)); +#else + vdouble e = vgetexp_vd_vd(vmul_vd_vd_vd(dp1, vcast_vd_d(1.0/0.75))); + e = vsel_vd_vo_vd_vd(vispinf_vo_vd(e), vcast_vd_d(1024.0), e); + t = vldexp3_vd_vd_vi(vcast_vd_d(1), vneg_vi_vi(vrint_vi_vd(e))); + m = vmla_vd_vd_vd_vd(d, t, vsub_vd_vd_vd(t, vcast_vd_d(1))); + vdouble2 s = ddmul_vd2_vd2_vd(vcast_vd2_d_d(0.693147180559945286226764, 2.319046813846299558417771e-17), e); +#endif + + x = dddiv_vd2_vd2_vd2(vcast_vd2_vd_vd(m, vcast_vd_d(0)), ddadd_vd2_vd_vd(vcast_vd_d(2), m)); + x2 = vmul_vd_vd_vd(vd2getx_vd_vd2(x), vd2getx_vd_vd2(x)); + + vdouble x4 = vmul_vd_vd_vd(x2, x2), x8 = vmul_vd_vd_vd(x4, x4); + t = POLY7(x2, x4, x8, + 0.1532076988502701353e+0, + 0.1525629051003428716e+0, + 0.1818605932937785996e+0, + 0.2222214519839380009e+0, + 0.2857142932794299317e+0, + 0.3999999999635251990e+0, + 0.6666666666667333541e+0); + + s = ddadd_vd2_vd2_vd2(s, ddscale_vd2_vd2_vd(x, vcast_vd_d(2))); + s = ddadd_vd2_vd2_vd(s, vmul_vd_vd_vd(vmul_vd_vd_vd(x2, vd2getx_vd_vd2(x)), t)); + + vdouble r = vadd_vd_vd_vd(vd2getx_vd_vd2(s), vd2gety_vd_vd2(s)); + + r = vsel_vd_vo_vd_vd(vgt_vo_vd_vd(d, vcast_vd_d(1e+307)), vcast_vd_d(SLEEF_INFINITY), r); + r = vsel_vd_vo_vd_vd(vor_vo_vo_vo(vlt_vo_vd_vd(d, vcast_vd_d(-1)), visnan_vo_vd(d)), vcast_vd_d(SLEEF_NAN), r); + r = vsel_vd_vo_vd_vd(veq_vo_vd_vd(d, vcast_vd_d(-1)), vcast_vd_d(-SLEEF_INFINITY), r); + r = vsel_vd_vo_vd_vd(visnegzero_vo_vd(d), vcast_vd_d(-0.0), r); + + return r; +} + +// + +EXPORT CONST VECTOR_CC vdouble xfabs(vdouble x) { return vabs_vd_vd(x); } + +EXPORT CONST VECTOR_CC vdouble xcopysign(vdouble x, vdouble y) { return vcopysign_vd_vd_vd(x, y); } + +EXPORT CONST VECTOR_CC vdouble xfmax(vdouble x, vdouble y) { +#if (defined(__x86_64__) || defined(__i386__)) && !defined(ENABLE_VECEXT) && !defined(ENABLE_PUREC) + return vsel_vd_vo_vd_vd(visnan_vo_vd(y), x, vmax_vd_vd_vd(x, y)); +#else + return vsel_vd_vo_vd_vd(visnan_vo_vd(y), x, vsel_vd_vo_vd_vd(vgt_vo_vd_vd(x, y), x, y)); +#endif +} + +EXPORT CONST VECTOR_CC vdouble xfmin(vdouble x, vdouble y) { +#if (defined(__x86_64__) || defined(__i386__)) && !defined(ENABLE_VECEXT) && !defined(ENABLE_PUREC) + return vsel_vd_vo_vd_vd(visnan_vo_vd(y), x, vmin_vd_vd_vd(x, y)); +#else + return vsel_vd_vo_vd_vd(visnan_vo_vd(y), x, vsel_vd_vo_vd_vd(vgt_vo_vd_vd(y, x), x, y)); +#endif +} + +EXPORT CONST VECTOR_CC vdouble xfdim(vdouble x, vdouble y) { + vdouble ret = vsub_vd_vd_vd(x, y); + ret = vsel_vd_vo_vd_vd(vor_vo_vo_vo(vlt_vo_vd_vd(ret, vcast_vd_d(0)), veq_vo_vd_vd(x, y)), vcast_vd_d(0), ret); + return ret; +} + +EXPORT CONST VECTOR_CC vdouble xtrunc(vdouble x) { return vtruncate2_vd_vd(x); } +EXPORT CONST VECTOR_CC vdouble xfloor(vdouble x) { return vfloor2_vd_vd(x); } +EXPORT CONST VECTOR_CC vdouble xceil(vdouble x) { return vceil2_vd_vd(x); } +EXPORT CONST VECTOR_CC vdouble xround(vdouble x) { return vround2_vd_vd(x); } +EXPORT CONST VECTOR_CC vdouble xrint(vdouble x) { return vrint2_vd_vd(x); } + +EXPORT CONST VECTOR_CC vdouble xnextafter(vdouble x, vdouble y) { + x = vsel_vd_vo_vd_vd(veq_vo_vd_vd(x, vcast_vd_d(0)), vmulsign_vd_vd_vd(vcast_vd_d(0), y), x); + vmask xi2 = vreinterpret_vm_vd(x); + vopmask c = vxor_vo_vo_vo(vsignbit_vo_vd(x), vge_vo_vd_vd(y, x)); + + xi2 = vsel_vm_vo64_vm_vm(c, vneg64_vm_vm(vxor_vm_vm_vm(xi2, vcast_vm_i_i((int)(1U << 31), 0))), xi2); + + xi2 = vsel_vm_vo64_vm_vm(vneq_vo_vd_vd(x, y), vsub64_vm_vm_vm(xi2, vcast_vm_i_i(0, 1)), xi2); + + xi2 = vsel_vm_vo64_vm_vm(c, vneg64_vm_vm(vxor_vm_vm_vm(xi2, vcast_vm_i_i((int)(1U << 31), 0))), xi2); + + vdouble ret = vreinterpret_vd_vm(xi2); + + ret = vsel_vd_vo_vd_vd(vand_vo_vo_vo(veq_vo_vd_vd(ret, vcast_vd_d(0)), vneq_vo_vd_vd(x, vcast_vd_d(0))), + vmulsign_vd_vd_vd(vcast_vd_d(0), x), ret); + + ret = vsel_vd_vo_vd_vd(vand_vo_vo_vo(veq_vo_vd_vd(x, vcast_vd_d(0)), veq_vo_vd_vd(y, vcast_vd_d(0))), y, ret); + + ret = vsel_vd_vo_vd_vd(vor_vo_vo_vo(visnan_vo_vd(x), visnan_vo_vd(y)), vcast_vd_d(SLEEF_NAN), ret); + + return ret; +} + +EXPORT CONST VECTOR_CC vdouble xfrfrexp(vdouble x) { + x = vsel_vd_vo_vd_vd(vlt_vo_vd_vd(vabs_vd_vd(x), vcast_vd_d(SLEEF_DBL_MIN)), vmul_vd_vd_vd(x, vcast_vd_d(UINT64_C(1) << 63)), x); + + vmask xm = vreinterpret_vm_vd(x); + xm = vand_vm_vm_vm(xm, vcast_vm_i64(~INT64_C(0x7ff0000000000000))); + xm = vor_vm_vm_vm (xm, vcast_vm_i64( INT64_C(0x3fe0000000000000))); + + vdouble ret = vreinterpret_vd_vm(xm); + + ret = vsel_vd_vo_vd_vd(visinf_vo_vd(x), vmulsign_vd_vd_vd(vcast_vd_d(SLEEF_INFINITY), x), ret); + ret = vsel_vd_vo_vd_vd(veq_vo_vd_vd(x, vcast_vd_d(0)), x, ret); + + return ret; +} + +EXPORT CONST VECTOR_CC vint xexpfrexp(vdouble x) { + x = vsel_vd_vo_vd_vd(vlt_vo_vd_vd(vabs_vd_vd(x), vcast_vd_d(SLEEF_DBL_MIN)), vmul_vd_vd_vd(x, vcast_vd_d(UINT64_C(1) << 63)), x); + + vint ret = vcastu_vi_vm(vreinterpret_vm_vd(x)); + ret = vsub_vi_vi_vi(vand_vi_vi_vi(vsrl_vi_vi_i(ret, 20), vcast_vi_i(0x7ff)), vcast_vi_i(0x3fe)); + + ret = vsel_vi_vo_vi_vi(vor_vo_vo_vo(vor_vo_vo_vo(veq_vo_vd_vd(x, vcast_vd_d(0)), visnan_vo_vd(x)), visinf_vo_vd(x)), vcast_vi_i(0), ret); + + return ret; +} + +EXPORT CONST VECTOR_CC vdouble xfma(vdouble x, vdouble y, vdouble z) { +#ifdef ENABLE_FMA_DP + return vfma_vd_vd_vd_vd(x, y, z); +#else + vdouble h2 = vadd_vd_vd_vd(vmul_vd_vd_vd(x, y), z), q = vcast_vd_d(1); + vopmask o = vlt_vo_vd_vd(vabs_vd_vd(h2), vcast_vd_d(1e-300)); + { + const double c0 = UINT64_C(1) << 54, c1 = c0 * c0, c2 = c1 * c1; + x = vsel_vd_vo_vd_vd(o, vmul_vd_vd_vd(x, vcast_vd_d(c1)), x); + y = vsel_vd_vo_vd_vd(o, vmul_vd_vd_vd(y, vcast_vd_d(c1)), y); + z = vsel_vd_vo_vd_vd(o, vmul_vd_vd_vd(z, vcast_vd_d(c2)), z); + q = vsel_vd_vo_vd_vd(o, vcast_vd_d(1.0 / c2), q); + } + o = vgt_vo_vd_vd(vabs_vd_vd(h2), vcast_vd_d(1e+300)); + { + const double c0 = UINT64_C(1) << 54, c1 = c0 * c0, c2 = c1 * c1; + x = vsel_vd_vo_vd_vd(o, vmul_vd_vd_vd(x, vcast_vd_d(1.0 / c1)), x); + y = vsel_vd_vo_vd_vd(o, vmul_vd_vd_vd(y, vcast_vd_d(1.0 / c1)), y); + z = vsel_vd_vo_vd_vd(o, vmul_vd_vd_vd(z, vcast_vd_d(1.0 / c2)), z); + q = vsel_vd_vo_vd_vd(o, vcast_vd_d(c2), q); + } + vdouble2 d = ddmul_vd2_vd_vd(x, y); + d = ddadd2_vd2_vd2_vd(d, z); + vdouble ret = vsel_vd_vo_vd_vd(vor_vo_vo_vo(veq_vo_vd_vd(x, vcast_vd_d(0)), veq_vo_vd_vd(y, vcast_vd_d(0))), z, vadd_vd_vd_vd(vd2getx_vd_vd2(d), vd2gety_vd_vd2(d))); + o = visinf_vo_vd(z); + o = vandnot_vo_vo_vo(visinf_vo_vd(x), o); + o = vandnot_vo_vo_vo(visnan_vo_vd(x), o); + o = vandnot_vo_vo_vo(visinf_vo_vd(y), o); + o = vandnot_vo_vo_vo(visnan_vo_vd(y), o); + h2 = vsel_vd_vo_vd_vd(o, z, h2); + + o = vor_vo_vo_vo(visinf_vo_vd(h2), visnan_vo_vd(h2)); + + return vsel_vd_vo_vd_vd(o, h2, vmul_vd_vd_vd(ret, q)); +#endif +} + +SQRTU05_FUNCATR VECTOR_CC vdouble xsqrt_u05(vdouble d) { +#if defined(ENABLE_FMA_DP) + vdouble q, w, x, y, z; + + d = vsel_vd_vo_vd_vd(vlt_vo_vd_vd(d, vcast_vd_d(0)), vcast_vd_d(SLEEF_NAN), d); + + vopmask o = vlt_vo_vd_vd(d, vcast_vd_d(8.636168555094445E-78)); + d = vsel_vd_vo_vd_vd(o, vmul_vd_vd_vd(d, vcast_vd_d(1.157920892373162E77)), d); + q = vsel_vd_vo_vd_vd(o, vcast_vd_d(2.9387358770557188E-39), vcast_vd_d(1)); + + y = vreinterpret_vd_vm(vsub64_vm_vm_vm(vcast_vm_i_i(0x5fe6ec85, 0xe7de30da), vsrl64_vm_vm_i(vreinterpret_vm_vd(d), 1))); + + x = vmul_vd_vd_vd(d, y); w = vmul_vd_vd_vd(vcast_vd_d(0.5), y); + y = vfmanp_vd_vd_vd_vd(x, w, vcast_vd_d(0.5)); + x = vfma_vd_vd_vd_vd(x, y, x); w = vfma_vd_vd_vd_vd(w, y, w); + y = vfmanp_vd_vd_vd_vd(x, w, vcast_vd_d(0.5)); + x = vfma_vd_vd_vd_vd(x, y, x); w = vfma_vd_vd_vd_vd(w, y, w); + y = vfmanp_vd_vd_vd_vd(x, w, vcast_vd_d(0.5)); + x = vfma_vd_vd_vd_vd(x, y, x); w = vfma_vd_vd_vd_vd(w, y, w); + + y = vfmanp_vd_vd_vd_vd(x, w, vcast_vd_d(1.5)); w = vadd_vd_vd_vd(w, w); + w = vmul_vd_vd_vd(w, y); + x = vmul_vd_vd_vd(w, d); + y = vfmapn_vd_vd_vd_vd(w, d, x); z = vfmanp_vd_vd_vd_vd(w, x, vcast_vd_d(1)); + + z = vfmanp_vd_vd_vd_vd(w, y, z); w = vmul_vd_vd_vd(vcast_vd_d(0.5), x); + w = vfma_vd_vd_vd_vd(w, z, y); + w = vadd_vd_vd_vd(w, x); + + w = vmul_vd_vd_vd(w, q); + + w = vsel_vd_vo_vd_vd(vor_vo_vo_vo(veq_vo_vd_vd(d, vcast_vd_d(0)), + veq_vo_vd_vd(d, vcast_vd_d(SLEEF_INFINITY))), d, w); + + w = vsel_vd_vo_vd_vd(vlt_vo_vd_vd(d, vcast_vd_d(0)), vcast_vd_d(SLEEF_NAN), w); + + return w; +#else + vdouble q; + vopmask o; + + d = vsel_vd_vo_vd_vd(vlt_vo_vd_vd(d, vcast_vd_d(0)), vcast_vd_d(SLEEF_NAN), d); + + o = vlt_vo_vd_vd(d, vcast_vd_d(8.636168555094445E-78)); + d = vsel_vd_vo_vd_vd(o, vmul_vd_vd_vd(d, vcast_vd_d(1.157920892373162E77)), d); + q = vsel_vd_vo_vd_vd(o, vcast_vd_d(2.9387358770557188E-39*0.5), vcast_vd_d(0.5)); + + o = vgt_vo_vd_vd(d, vcast_vd_d(1.3407807929942597e+154)); + d = vsel_vd_vo_vd_vd(o, vmul_vd_vd_vd(d, vcast_vd_d(7.4583407312002070e-155)), d); + q = vsel_vd_vo_vd_vd(o, vcast_vd_d(1.1579208923731620e+77*0.5), q); + + vdouble x = vreinterpret_vd_vm(vsub64_vm_vm_vm(vcast_vm_i_i(0x5fe6ec86, 0), vsrl64_vm_vm_i(vreinterpret_vm_vd(vadd_vd_vd_vd(d, vcast_vd_d(1e-320))), 1))); + + x = vmul_vd_vd_vd(x, vsub_vd_vd_vd(vcast_vd_d(1.5), vmul_vd_vd_vd(vmul_vd_vd_vd(vmul_vd_vd_vd(vcast_vd_d(0.5), d), x), x))); + x = vmul_vd_vd_vd(x, vsub_vd_vd_vd(vcast_vd_d(1.5), vmul_vd_vd_vd(vmul_vd_vd_vd(vmul_vd_vd_vd(vcast_vd_d(0.5), d), x), x))); + x = vmul_vd_vd_vd(x, vsub_vd_vd_vd(vcast_vd_d(1.5), vmul_vd_vd_vd(vmul_vd_vd_vd(vmul_vd_vd_vd(vcast_vd_d(0.5), d), x), x))); + x = vmul_vd_vd_vd(x, d); + + vdouble2 d2 = ddmul_vd2_vd2_vd2(ddadd2_vd2_vd_vd2(d, ddmul_vd2_vd_vd(x, x)), ddrec_vd2_vd(x)); + + x = vmul_vd_vd_vd(vadd_vd_vd_vd(vd2getx_vd_vd2(d2), vd2gety_vd_vd2(d2)), q); + + x = vsel_vd_vo_vd_vd(vispinf_vo_vd(d), vcast_vd_d(SLEEF_INFINITY), x); + x = vsel_vd_vo_vd_vd(veq_vo_vd_vd(d, vcast_vd_d(0)), d, x); + + return x; +#endif +} + +EXPORT CONST VECTOR_CC vdouble xsqrt(vdouble d) { +#if defined(ACCURATE_SQRT) + return vsqrt_vd_vd(d); +#else + // fall back to approximation if ACCURATE_SQRT is undefined + return xsqrt_u05(d); +#endif +} + +EXPORT CONST VECTOR_CC vdouble xsqrt_u35(vdouble d) { return xsqrt_u05(d); } + +EXPORT CONST VECTOR_CC vdouble xhypot_u05(vdouble x, vdouble y) { + x = vabs_vd_vd(x); + y = vabs_vd_vd(y); + vdouble min = vmin_vd_vd_vd(x, y), n = min; + vdouble max = vmax_vd_vd_vd(x, y), d = max; + + vopmask o = vlt_vo_vd_vd(max, vcast_vd_d(SLEEF_DBL_MIN)); + n = vsel_vd_vo_vd_vd(o, vmul_vd_vd_vd(n, vcast_vd_d(UINT64_C(1) << 54)), n); + d = vsel_vd_vo_vd_vd(o, vmul_vd_vd_vd(d, vcast_vd_d(UINT64_C(1) << 54)), d); + + vdouble2 t = dddiv_vd2_vd2_vd2(vcast_vd2_vd_vd(n, vcast_vd_d(0)), vcast_vd2_vd_vd(d, vcast_vd_d(0))); + t = ddmul_vd2_vd2_vd(ddsqrt_vd2_vd2(ddadd2_vd2_vd2_vd(ddsqu_vd2_vd2(t), vcast_vd_d(1))), max); + vdouble ret = vadd_vd_vd_vd(vd2getx_vd_vd2(t), vd2gety_vd_vd2(t)); + ret = vsel_vd_vo_vd_vd(visnan_vo_vd(ret), vcast_vd_d(SLEEF_INFINITY), ret); + ret = vsel_vd_vo_vd_vd(veq_vo_vd_vd(min, vcast_vd_d(0)), max, ret); + ret = vsel_vd_vo_vd_vd(vor_vo_vo_vo(visnan_vo_vd(x), visnan_vo_vd(y)), vcast_vd_d(SLEEF_NAN), ret); + ret = vsel_vd_vo_vd_vd(vor_vo_vo_vo(veq_vo_vd_vd(x, vcast_vd_d(SLEEF_INFINITY)), veq_vo_vd_vd(y, vcast_vd_d(SLEEF_INFINITY))), vcast_vd_d(SLEEF_INFINITY), ret); + + return ret; +} + +EXPORT CONST VECTOR_CC vdouble xhypot_u35(vdouble x, vdouble y) { + x = vabs_vd_vd(x); + y = vabs_vd_vd(y); + vdouble min = vmin_vd_vd_vd(x, y); + vdouble max = vmax_vd_vd_vd(x, y); + + vdouble t = vdiv_vd_vd_vd(min, max); + vdouble ret = vmul_vd_vd_vd(max, vsqrt_vd_vd(vmla_vd_vd_vd_vd(t, t, vcast_vd_d(1)))); + ret = vsel_vd_vo_vd_vd(veq_vo_vd_vd(min, vcast_vd_d(0)), max, ret); + ret = vsel_vd_vo_vd_vd(vor_vo_vo_vo(visnan_vo_vd(x), visnan_vo_vd(y)), vcast_vd_d(SLEEF_NAN), ret); + ret = vsel_vd_vo_vd_vd(vor_vo_vo_vo(veq_vo_vd_vd(x, vcast_vd_d(SLEEF_INFINITY)), veq_vo_vd_vd(y, vcast_vd_d(SLEEF_INFINITY))), vcast_vd_d(SLEEF_INFINITY), ret); + + return ret; +} + +static INLINE CONST VECTOR_CC vdouble vptrunc_vd_vd(vdouble x) { // round to integer toward 0, positive argument only +#ifdef FULL_FP_ROUNDING + return vtruncate_vd_vd(x); +#else + vdouble fr = vmla_vd_vd_vd_vd(vcast_vd_d(-(double)(INT64_C(1) << 31)), vcast_vd_vi(vtruncate_vi_vd(vmul_vd_vd_vd(x, vcast_vd_d(1.0 / (INT64_C(1) << 31))))), x); + fr = vsub_vd_vd_vd(fr, vcast_vd_vi(vtruncate_vi_vd(fr))); + return vsel_vd_vo_vd_vd(vge_vo_vd_vd(vabs_vd_vd(x), vcast_vd_d(INT64_C(1) << 52)), x, vsub_vd_vd_vd(x, fr)); +#endif +} + +/* TODO AArch64: potential optimization by using `vfmad_lane_f64` */ +EXPORT CONST VECTOR_CC vdouble xfmod(vdouble x, vdouble y) { + vdouble n = vabs_vd_vd(x), d = vabs_vd_vd(y), s = vcast_vd_d(1), q; + vopmask o = vlt_vo_vd_vd(d, vcast_vd_d(SLEEF_DBL_MIN)); + n = vsel_vd_vo_vd_vd(o, vmul_vd_vd_vd(n, vcast_vd_d(UINT64_C(1) << 54)), n); + d = vsel_vd_vo_vd_vd(o, vmul_vd_vd_vd(d, vcast_vd_d(UINT64_C(1) << 54)), d); + s = vsel_vd_vo_vd_vd(o, vmul_vd_vd_vd(s , vcast_vd_d(1.0 / (UINT64_C(1) << 54))), s); + vdouble2 r = vcast_vd2_vd_vd(n, vcast_vd_d(0)); + vdouble rd = vtoward0_vd_vd(vrec_vd_vd(d)); + + for(int i=0;i<21;i++) { // ceil(log2(DBL_MAX) / 52) + q = vptrunc_vd_vd(vmul_vd_vd_vd(vtoward0_vd_vd(vd2getx_vd_vd2(r)), rd)); +#ifndef ENABLE_FMA_DP + q = vreinterpret_vd_vm(vand_vm_vm_vm(vreinterpret_vm_vd(q), vcast_vm_u64(UINT64_C(0xfffffffffffffffe)))); +#endif + q = vsel_vd_vo_vd_vd(vand_vo_vo_vo(vgt_vo_vd_vd(vmul_vd_vd_vd(vcast_vd_d(3), d), vd2getx_vd_vd2(r)), + vge_vo_vd_vd(vd2getx_vd_vd2(r), d)), + vcast_vd_d(2), q); + q = vsel_vd_vo_vd_vd(vand_vo_vo_vo(vgt_vo_vd_vd(vadd_vd_vd_vd(d, d), vd2getx_vd_vd2(r)), + vge_vo_vd_vd(vd2getx_vd_vd2(r), d)), + vcast_vd_d(1), q); + r = ddnormalize_vd2_vd2(ddadd2_vd2_vd2_vd2(r, ddmul_vd2_vd_vd(q, vneg_vd_vd(d)))); + if (vtestallones_i_vo64(vlt_vo_vd_vd(vd2getx_vd_vd2(r), d))) break; + } + + vdouble ret = vmul_vd_vd_vd(vd2getx_vd_vd2(r), s); + ret = vsel_vd_vo_vd_vd(veq_vo_vd_vd(vadd_vd_vd_vd(vd2getx_vd_vd2(r), vd2gety_vd_vd2(r)), d), vcast_vd_d(0), ret); + + ret = vmulsign_vd_vd_vd(ret, x); + + ret = vsel_vd_vo_vd_vd(vlt_vo_vd_vd(n, d), x, ret); + ret = vsel_vd_vo_vd_vd(veq_vo_vd_vd(d, vcast_vd_d(0)), vcast_vd_d(SLEEF_NAN), ret); + + return ret; +} + +static INLINE VECTOR_CC vdouble vrintk2_vd_vd(vdouble d) { +#ifdef FULL_FP_ROUNDING + return vrint_vd_vd(d); +#else + vdouble c = vmulsign_vd_vd_vd(vcast_vd_d(INT64_C(1) << 52), d); + return vsel_vd_vo_vd_vd(vgt_vo_vd_vd(vabs_vd_vd(d), vcast_vd_d(INT64_C(1) << 52)), + d, vorsign_vd_vd_vd(vsub_vd_vd_vd(vadd_vd_vd_vd(d, c), c), d)); +#endif +} + +EXPORT CONST VECTOR_CC vdouble xremainder(vdouble x, vdouble y) { + vdouble n = vabs_vd_vd(x), d = vabs_vd_vd(y), s = vcast_vd_d(1), q; + vopmask o = vlt_vo_vd_vd(d, vcast_vd_d(SLEEF_DBL_MIN*2)); + n = vsel_vd_vo_vd_vd(o, vmul_vd_vd_vd(n, vcast_vd_d(UINT64_C(1) << 54)), n); + d = vsel_vd_vo_vd_vd(o, vmul_vd_vd_vd(d, vcast_vd_d(UINT64_C(1) << 54)), d); + s = vsel_vd_vo_vd_vd(o, vmul_vd_vd_vd(s , vcast_vd_d(1.0 / (UINT64_C(1) << 54))), s); + vdouble rd = vrec_vd_vd(d); + vdouble2 r = vcast_vd2_vd_vd(n, vcast_vd_d(0)); + vopmask qisodd = vneq_vo_vd_vd(vcast_vd_d(0), vcast_vd_d(0)); + + for(int i=0;i<21;i++) { // ceil(log2(DBL_MAX) / 52) + q = vrintk2_vd_vd(vmul_vd_vd_vd(vd2getx_vd_vd2(r), rd)); +#ifndef ENABLE_FMA_DP + q = vreinterpret_vd_vm(vand_vm_vm_vm(vreinterpret_vm_vd(q), vcast_vm_u64(UINT64_C(0xfffffffffffffffe)))); +#endif + q = vsel_vd_vo_vd_vd(vlt_vo_vd_vd(vabs_vd_vd(vd2getx_vd_vd2(r)), vmul_vd_vd_vd(d, vcast_vd_d(1.5))), vmulsign_vd_vd_vd(vcast_vd_d(1.0), vd2getx_vd_vd2(r)), q); + q = vsel_vd_vo_vd_vd(vor_vo_vo_vo(vlt_vo_vd_vd(vabs_vd_vd(vd2getx_vd_vd2(r)), vmul_vd_vd_vd(d, vcast_vd_d(0.5))), + vandnot_vo_vo_vo(qisodd, veq_vo_vd_vd(vabs_vd_vd(vd2getx_vd_vd2(r)), vmul_vd_vd_vd(d, vcast_vd_d(0.5))))), + vcast_vd_d(0.0), q); + if (vtestallones_i_vo64(veq_vo_vd_vd(q, vcast_vd_d(0)))) break; + q = vsel_vd_vo_vd_vd(visinf_vo_vd(vmul_vd_vd_vd(q, vneg_vd_vd(d))), vadd_vd_vd_vd(q, vmulsign_vd_vd_vd(vcast_vd_d(-1), vd2getx_vd_vd2(r))), q); + qisodd = vxor_vo_vo_vo(qisodd, visodd_vo_vd(q)); + r = ddnormalize_vd2_vd2(ddadd2_vd2_vd2_vd2(r, ddmul_vd2_vd_vd(q, vneg_vd_vd(d)))); + } + + vdouble ret = vmul_vd_vd_vd(vd2getx_vd_vd2(r), s); + ret = vmulsign_vd_vd_vd(ret, x); + ret = vsel_vd_vo_vd_vd(visinf_vo_vd(y), vsel_vd_vo_vd_vd(visinf_vo_vd(x), vcast_vd_d(SLEEF_NAN), x), ret); + ret = vsel_vd_vo_vd_vd(veq_vo_vd_vd(d, vcast_vd_d(0)), vcast_vd_d(SLEEF_NAN), ret); + return ret; +} + +/* TODO AArch64: potential optimization by using `vfmad_lane_f64` */ +static CONST dd2 gammak(vdouble a) { + vdouble2 clc = vcast_vd2_d_d(0, 0), clln = vcast_vd2_d_d(1, 0), clld = vcast_vd2_d_d(1, 0); + vdouble2 x, y, z; + vdouble t, u; + + vopmask otiny = vlt_vo_vd_vd(vabs_vd_vd(a), vcast_vd_d(1e-306)), oref = vlt_vo_vd_vd(a, vcast_vd_d(0.5)); + + x = vsel_vd2_vo_vd2_vd2(otiny, vcast_vd2_d_d(0, 0), + vsel_vd2_vo_vd2_vd2(oref, ddadd2_vd2_vd_vd(vcast_vd_d(1), vneg_vd_vd(a)), + vcast_vd2_vd_vd(a, vcast_vd_d(0)))); + + vopmask o0 = vand_vo_vo_vo(vle_vo_vd_vd(vcast_vd_d(0.5), vd2getx_vd_vd2(x)), vle_vo_vd_vd(vd2getx_vd_vd2(x), vcast_vd_d(1.1))); + vopmask o2 = vle_vo_vd_vd(vcast_vd_d(2.3), vd2getx_vd_vd2(x)); + + y = ddnormalize_vd2_vd2(ddmul_vd2_vd2_vd2(ddadd2_vd2_vd2_vd(x, vcast_vd_d(1)), x)); + y = ddnormalize_vd2_vd2(ddmul_vd2_vd2_vd2(ddadd2_vd2_vd2_vd(x, vcast_vd_d(2)), y)); + y = ddnormalize_vd2_vd2(ddmul_vd2_vd2_vd2(ddadd2_vd2_vd2_vd(x, vcast_vd_d(3)), y)); + y = ddnormalize_vd2_vd2(ddmul_vd2_vd2_vd2(ddadd2_vd2_vd2_vd(x, vcast_vd_d(4)), y)); + + vopmask o = vand_vo_vo_vo(o2, vle_vo_vd_vd(vd2getx_vd_vd2(x), vcast_vd_d(7))); + clln = vsel_vd2_vo_vd2_vd2(o, y, clln); + + x = vsel_vd2_vo_vd2_vd2(o, ddadd2_vd2_vd2_vd(x, vcast_vd_d(5)), x); + + t = vsel_vd_vo_vd_vd(o2, vrec_vd_vd(vd2getx_vd_vd2(x)), vd2getx_vd_vd2(ddnormalize_vd2_vd2(ddadd2_vd2_vd2_vd(x, vsel_vd_vo_d_d(o0, -1, -2))))); + + u = vsel_vd_vo_vo_d_d_d(o2, o0, -156.801412704022726379848862, +0.2947916772827614196e+2, +0.7074816000864609279e-7); + u = vmla_vd_vd_vd_vd(u, t, vsel_vd_vo_vo_d_d_d(o2, o0, +1.120804464289911606838558160000, +0.1281459691827820109e+3, +0.4009244333008730443e-6)); + u = vmla_vd_vd_vd_vd(u, t, vsel_vd_vo_vo_d_d_d(o2, o0, +13.39798545514258921833306020000, +0.2617544025784515043e+3, +0.1040114641628246946e-5)); + u = vmla_vd_vd_vd_vd(u, t, vsel_vd_vo_vo_d_d_d(o2, o0, -0.116546276599463200848033357000, +0.3287022855685790432e+3, +0.1508349150733329167e-5)); + u = vmla_vd_vd_vd_vd(u, t, vsel_vd_vo_vo_d_d_d(o2, o0, -1.391801093265337481495562410000, +0.2818145867730348186e+3, +0.1288143074933901020e-5)); + u = vmla_vd_vd_vd_vd(u, t, vsel_vd_vo_vo_d_d_d(o2, o0, +0.015056113040026424412918973400, +0.1728670414673559605e+3, +0.4744167749884993937e-6)); + u = vmla_vd_vd_vd_vd(u, t, vsel_vd_vo_vo_d_d_d(o2, o0, +0.179540117061234856098844714000, +0.7748735764030416817e+2, -0.6554816306542489902e-7)); + u = vmla_vd_vd_vd_vd(u, t, vsel_vd_vo_vo_d_d_d(o2, o0, -0.002481743600264997730942489280, +0.2512856643080930752e+2, -0.3189252471452599844e-6)); + u = vmla_vd_vd_vd_vd(u, t, vsel_vd_vo_vo_d_d_d(o2, o0, -0.029527880945699120504851034100, +0.5766792106140076868e+1, +0.1358883821470355377e-6)); + u = vmla_vd_vd_vd_vd(u, t, vsel_vd_vo_vo_d_d_d(o2, o0, +0.000540164767892604515196325186, +0.7270275473996180571e+0, -0.4343931277157336040e-6)); + u = vmla_vd_vd_vd_vd(u, t, vsel_vd_vo_vo_d_d_d(o2, o0, +0.006403362833808069794787256200, +0.8396709124579147809e-1, +0.9724785897406779555e-6)); + u = vmla_vd_vd_vd_vd(u, t, vsel_vd_vo_vo_d_d_d(o2, o0, -0.000162516262783915816896611252, -0.8211558669746804595e-1, -0.2036886057225966011e-5)); + u = vmla_vd_vd_vd_vd(u, t, vsel_vd_vo_vo_d_d_d(o2, o0, -0.001914438498565477526465972390, +0.6828831828341884458e-1, +0.4373363141819725815e-5)); + u = vmla_vd_vd_vd_vd(u, t, vsel_vd_vo_vo_d_d_d(o2, o0, +7.20489541602001055898311517e-05, -0.7712481339961671511e-1, -0.9439951268304008677e-5)); + u = vmla_vd_vd_vd_vd(u, t, vsel_vd_vo_vo_d_d_d(o2, o0, +0.000839498720672087279971000786, +0.8337492023017314957e-1, +0.2050727030376389804e-4)); + u = vmla_vd_vd_vd_vd(u, t, vsel_vd_vo_vo_d_d_d(o2, o0, -5.17179090826059219329394422e-05, -0.9094964931456242518e-1, -0.4492620183431184018e-4)); + u = vmla_vd_vd_vd_vd(u, t, vsel_vd_vo_vo_d_d_d(o2, o0, -0.000592166437353693882857342347, +0.1000996313575929358e+0, +0.9945751236071875931e-4)); + u = vmla_vd_vd_vd_vd(u, t, vsel_vd_vo_vo_d_d_d(o2, o0, +6.97281375836585777403743539e-05, -0.1113342861544207724e+0, -0.2231547599034983196e-3)); + u = vmla_vd_vd_vd_vd(u, t, vsel_vd_vo_vo_d_d_d(o2, o0, +0.000784039221720066627493314301, +0.1255096673213020875e+0, +0.5096695247101967622e-3)); + u = vmla_vd_vd_vd_vd(u, t, vsel_vd_vo_vo_d_d_d(o2, o0, -0.000229472093621399176949318732, -0.1440498967843054368e+0, -0.1192753911667886971e-2)); + u = vmla_vd_vd_vd_vd(u, t, vsel_vd_vo_vo_d_d_d(o2, o0, -0.002681327160493827160473958490, +0.1695571770041949811e+0, +0.2890510330742210310e-2)); + u = vmla_vd_vd_vd_vd(u, t, vsel_vd_vo_vo_d_d_d(o2, o0, +0.003472222222222222222175164840, -0.2073855510284092762e+0, -0.7385551028674461858e-2)); + u = vmla_vd_vd_vd_vd(u, t, vsel_vd_vo_vo_d_d_d(o2, o0, +0.083333333333333333335592087900, +0.2705808084277815939e+0, +0.2058080842778455335e-1)); + + y = ddmul_vd2_vd2_vd2(ddadd2_vd2_vd2_vd(x, vcast_vd_d(-0.5)), logk2(x)); + y = ddadd2_vd2_vd2_vd2(y, ddneg_vd2_vd2(x)); + y = ddadd2_vd2_vd2_vd2(y, vcast_vd2_d_d(0.91893853320467278056, -3.8782941580672414498e-17)); // 0.5*log(2*M_PI) + + z = ddadd2_vd2_vd2_vd(ddmul_vd2_vd_vd (u, t), vsel_vd_vo_d_d(o0, -0.4006856343865314862e+0, -0.6735230105319810201e-1)); + z = ddadd2_vd2_vd2_vd(ddmul_vd2_vd2_vd(z, t), vsel_vd_vo_d_d(o0, +0.8224670334241132030e+0, +0.3224670334241132030e+0)); + z = ddadd2_vd2_vd2_vd(ddmul_vd2_vd2_vd(z, t), vsel_vd_vo_d_d(o0, -0.5772156649015328655e+0, +0.4227843350984671345e+0)); + z = ddmul_vd2_vd2_vd(z, t); + + clc = vsel_vd2_vo_vd2_vd2(o2, y, z); + + clld = vsel_vd2_vo_vd2_vd2(o2, ddadd2_vd2_vd2_vd(ddmul_vd2_vd_vd(u, t), vcast_vd_d(1)), clld); + + y = clln; + + clc = vsel_vd2_vo_vd2_vd2(otiny, vcast_vd2_d_d(83.1776616671934334590333, 3.67103459631568507221878e-15), // log(2^120) + vsel_vd2_vo_vd2_vd2(oref, ddadd2_vd2_vd2_vd2(vcast_vd2_d_d(1.1447298858494001639, 1.026595116270782638e-17), ddneg_vd2_vd2(clc)), clc)); // log(M_PI) + clln = vsel_vd2_vo_vd2_vd2(otiny, vcast_vd2_d_d(1, 0), vsel_vd2_vo_vd2_vd2(oref, clln, clld)); + + if (!vtestallones_i_vo64(vnot_vo64_vo64(oref))) { + t = vsub_vd_vd_vd(a, vmul_vd_vd_vd(vcast_vd_d(INT64_C(1) << 28), vcast_vd_vi(vtruncate_vi_vd(vmul_vd_vd_vd(a, vcast_vd_d(1.0 / (INT64_C(1) << 28))))))); + x = ddmul_vd2_vd2_vd2(clld, sinpik(t)); + } + + clld = vsel_vd2_vo_vd2_vd2(otiny, vcast_vd2_vd_vd(vmul_vd_vd_vd(a, vcast_vd_d((INT64_C(1) << 60)*(double)(INT64_C(1) << 60))), vcast_vd_d(0)), + vsel_vd2_vo_vd2_vd2(oref, x, y)); + + return dd2setab_dd2_vd2_vd2(clc, dddiv_vd2_vd2_vd2(clln, clld)); +} + +EXPORT CONST VECTOR_CC vdouble xtgamma_u1(vdouble a) { + dd2 d = gammak(a); + vdouble2 y = ddmul_vd2_vd2_vd2(expk2(dd2geta_vd2_dd2(d)), dd2getb_vd2_dd2(d)); + vdouble r = vadd_vd_vd_vd(vd2getx_vd_vd2(y), vd2gety_vd_vd2(y)); + vopmask o; + + o = vor_vo_vo_vo(vor_vo_vo_vo(veq_vo_vd_vd(a, vcast_vd_d(-SLEEF_INFINITY)), + vand_vo_vo_vo(vlt_vo_vd_vd(a, vcast_vd_d(0)), visint_vo_vd(a))), + vand_vo_vo_vo(vand_vo_vo_vo(visnumber_vo_vd(a), vlt_vo_vd_vd(a, vcast_vd_d(0))), visnan_vo_vd(r))); + r = vsel_vd_vo_vd_vd(o, vcast_vd_d(SLEEF_NAN), r); + + o = vand_vo_vo_vo(vand_vo_vo_vo(vor_vo_vo_vo(veq_vo_vd_vd(a, vcast_vd_d(SLEEF_INFINITY)), visnumber_vo_vd(a)), + vge_vo_vd_vd(a, vcast_vd_d(-SLEEF_DBL_MIN))), + vor_vo_vo_vo(vor_vo_vo_vo(veq_vo_vd_vd(a, vcast_vd_d(0)), vgt_vo_vd_vd(a, vcast_vd_d(200))), visnan_vo_vd(r))); + r = vsel_vd_vo_vd_vd(o, vmulsign_vd_vd_vd(vcast_vd_d(SLEEF_INFINITY), a), r); + + return r; +} + +EXPORT CONST VECTOR_CC vdouble xlgamma_u1(vdouble a) { + dd2 d = gammak(a); + vdouble2 y = ddadd2_vd2_vd2_vd2(dd2geta_vd2_dd2(d), logk2(ddabs_vd2_vd2(dd2getb_vd2_dd2(d)))); + vdouble r = vadd_vd_vd_vd(vd2getx_vd_vd2(y), vd2gety_vd_vd2(y)); + vopmask o; + + o = vor_vo_vo_vo(visinf_vo_vd(a), + vor_vo_vo_vo(vand_vo_vo_vo(vle_vo_vd_vd(a, vcast_vd_d(0)), visint_vo_vd(a)), + vand_vo_vo_vo(visnumber_vo_vd(a), visnan_vo_vd(r)))); + r = vsel_vd_vo_vd_vd(o, vcast_vd_d(SLEEF_INFINITY), r); + + return r; +} + +static INLINE CONST vdouble2 ddmla_vd2_vd_vd2_vd2(vdouble x, vdouble2 y, vdouble2 z) { + return ddadd_vd2_vd2_vd2(z, ddmul_vd2_vd2_vd(y, x)); +} + +static INLINE CONST VECTOR_CC vdouble2 poly2dd_b(vdouble x, vdouble2 c1, vdouble2 c0) { return ddmla_vd2_vd_vd2_vd2(x, c1, c0); } +static INLINE CONST VECTOR_CC vdouble2 poly2dd(vdouble x, vdouble c1, vdouble2 c0) { return ddmla_vd2_vd_vd2_vd2(x, vcast_vd2_vd_vd(c1, vcast_vd_d(0)), c0); } +static INLINE CONST VECTOR_CC vdouble2 poly4dd(vdouble x, vdouble c3, vdouble2 c2, vdouble2 c1, vdouble2 c0) { + return ddmla_vd2_vd_vd2_vd2(vmul_vd_vd_vd(x, x), poly2dd(x, c3, c2), poly2dd_b(x, c1, c0)); +} + +EXPORT CONST VECTOR_CC vdouble xerf_u1(vdouble a) { + vdouble t, x = vabs_vd_vd(a); + vdouble2 t2; + vdouble x2 = vmul_vd_vd_vd(x, x), x4 = vmul_vd_vd_vd(x2, x2); + vdouble x8 = vmul_vd_vd_vd(x4, x4), x16 = vmul_vd_vd_vd(x8, x8); + vopmask o25 = vle_vo_vd_vd(x, vcast_vd_d(2.5)); + + if (LIKELY(vtestallones_i_vo64(o25))) { + // Abramowitz and Stegun + t = POLY21(x, x2, x4, x8, x16, + -0.2083271002525222097e-14, + +0.7151909970790897009e-13, + -0.1162238220110999364e-11, + +0.1186474230821585259e-10, + -0.8499973178354613440e-10, + +0.4507647462598841629e-9, + -0.1808044474288848915e-8, + +0.5435081826716212389e-8, + -0.1143939895758628484e-7, + +0.1215442362680889243e-7, + +0.1669878756181250355e-7, + -0.9808074602255194288e-7, + +0.1389000557865837204e-6, + +0.2945514529987331866e-6, + -0.1842918273003998283e-5, + +0.3417987836115362136e-5, + +0.3860236356493129101e-5, + -0.3309403072749947546e-4, + +0.1060862922597579532e-3, + +0.2323253155213076174e-3, + +0.1490149719145544729e-3); + t2 = poly4dd(x, t, + vcast_vd2_d_d(0.0092877958392275604405, 7.9287559463961107493e-19), + vcast_vd2_d_d(0.042275531758784692937, 1.3785226620501016138e-19), + vcast_vd2_d_d(0.07052369794346953491, 9.5846628070792092842e-19)); + t2 = ddadd_vd2_vd_vd2(vcast_vd_d(1), ddmul_vd2_vd2_vd(t2, x)); + t2 = ddsqu_vd2_vd2(t2); + t2 = ddsqu_vd2_vd2(t2); + t2 = ddsqu_vd2_vd2(t2); + t2 = ddsqu_vd2_vd2(t2); + t2 = ddrec_vd2_vd2(t2); + } else { +#undef C2V +#define C2V(c) (c) + t = POLY21(x, x2, x4, x8, x16, + vsel_vd_vo_d_d(o25, -0.2083271002525222097e-14, -0.4024015130752621932e-18), + vsel_vd_vo_d_d(o25, +0.7151909970790897009e-13, +0.3847193332817048172e-16), + vsel_vd_vo_d_d(o25, -0.1162238220110999364e-11, -0.1749316241455644088e-14), + vsel_vd_vo_d_d(o25, +0.1186474230821585259e-10, +0.5029618322872872715e-13), + vsel_vd_vo_d_d(o25, -0.8499973178354613440e-10, -0.1025221466851463164e-11), + vsel_vd_vo_d_d(o25, +0.4507647462598841629e-9, +0.1573695559331945583e-10), + vsel_vd_vo_d_d(o25, -0.1808044474288848915e-8, -0.1884658558040203709e-9), + vsel_vd_vo_d_d(o25, +0.5435081826716212389e-8, +0.1798167853032159309e-8), + vsel_vd_vo_d_d(o25, -0.1143939895758628484e-7, -0.1380745342355033142e-7), + vsel_vd_vo_d_d(o25, +0.1215442362680889243e-7, +0.8525705726469103499e-7), + vsel_vd_vo_d_d(o25, +0.1669878756181250355e-7, -0.4160448058101303405e-6), + vsel_vd_vo_d_d(o25, -0.9808074602255194288e-7, +0.1517272660008588485e-5), + vsel_vd_vo_d_d(o25, +0.1389000557865837204e-6, -0.3341634127317201697e-5), + vsel_vd_vo_d_d(o25, +0.2945514529987331866e-6, -0.2515023395879724513e-5), + vsel_vd_vo_d_d(o25, -0.1842918273003998283e-5, +0.6539731269664907554e-4), + vsel_vd_vo_d_d(o25, +0.3417987836115362136e-5, -0.3551065097428388658e-3), + vsel_vd_vo_d_d(o25, +0.3860236356493129101e-5, +0.1210736097958368864e-2), + vsel_vd_vo_d_d(o25, -0.3309403072749947546e-4, -0.2605566912579998680e-2), + vsel_vd_vo_d_d(o25, +0.1060862922597579532e-3, +0.1252823202436093193e-2), + vsel_vd_vo_d_d(o25, +0.2323253155213076174e-3, +0.1820191395263313222e-1), + vsel_vd_vo_d_d(o25, +0.1490149719145544729e-3, -0.1021557155453465954e+0)); + t2 = poly4dd(x, t, + vsel_vd2_vo_vd2_vd2(o25, vcast_vd2_d_d(0.0092877958392275604405, 7.9287559463961107493e-19), + vcast_vd2_d_d(-0.63691044383641748361, -2.4249477526539431839e-17)), + vsel_vd2_vo_vd2_vd2(o25, vcast_vd2_d_d(0.042275531758784692937, 1.3785226620501016138e-19), + vcast_vd2_d_d(-1.1282926061803961737, -6.2970338860410996505e-17)), + vsel_vd2_vo_vd2_vd2(o25, vcast_vd2_d_d(0.07052369794346953491, 9.5846628070792092842e-19), + vcast_vd2_d_d(-1.2261313785184804967e-05, -5.5329707514490107044e-22))); + vdouble2 s2 = ddadd_vd2_vd_vd2(vcast_vd_d(1), ddmul_vd2_vd2_vd(t2, x)); + s2 = ddsqu_vd2_vd2(s2); + s2 = ddsqu_vd2_vd2(s2); + s2 = ddsqu_vd2_vd2(s2); + s2 = ddsqu_vd2_vd2(s2); + s2 = ddrec_vd2_vd2(s2); + t2 = vsel_vd2_vo_vd2_vd2(o25, s2, vcast_vd2_vd_vd(expk(t2), vcast_vd_d(0))); + } + + t2 = ddadd2_vd2_vd2_vd(t2, vcast_vd_d(-1)); + + vdouble z = vneg_vd_vd(vadd_vd_vd_vd(vd2getx_vd_vd2(t2), vd2gety_vd_vd2(t2))); + z = vsel_vd_vo_vd_vd(vlt_vo_vd_vd(x, vcast_vd_d(1e-8)), vmul_vd_vd_vd(x, vcast_vd_d(1.12837916709551262756245475959)), z); + z = vsel_vd_vo_vd_vd(vge_vo_vd_vd(x, vcast_vd_d(6)), vcast_vd_d(1), z); + z = vsel_vd_vo_vd_vd(visinf_vo_vd(a), vcast_vd_d(1), z); + z = vsel_vd_vo_vd_vd(veq_vo_vd_vd(a, vcast_vd_d(0)), vcast_vd_d(0), z); + z = vmulsign_vd_vd_vd(z, a); + + return z; +} + +/* TODO AArch64: potential optimization by using `vfmad_lane_f64` */ +EXPORT CONST VECTOR_CC vdouble xerfc_u15(vdouble a) { + vdouble s = a, r = vcast_vd_d(0), t; + vdouble2 u, d, x; + a = vabs_vd_vd(a); + vopmask o0 = vlt_vo_vd_vd(a, vcast_vd_d(1.0)); + vopmask o1 = vlt_vo_vd_vd(a, vcast_vd_d(2.2)); + vopmask o2 = vlt_vo_vd_vd(a, vcast_vd_d(4.2)); + vopmask o3 = vlt_vo_vd_vd(a, vcast_vd_d(27.3)); + + u = vsel_vd2_vo_vd2_vd2(o0, ddmul_vd2_vd_vd(a, a), vsel_vd2_vo_vd2_vd2(o1, vcast_vd2_vd_vd(a, vcast_vd_d(0)), dddiv_vd2_vd2_vd2(vcast_vd2_d_d(1, 0), vcast_vd2_vd_vd(a, vcast_vd_d(0))))); + + t = vsel_vd_vo_vo_vo_d_d_d_d(o0, o1, o2, +0.6801072401395386139e-20, +0.3438010341362585303e-12, -0.5757819536420710449e+2, +0.2334249729638701319e+5); + t = vmla_vd_vd_vd_vd(t, vd2getx_vd_vd2(u), vsel_vd_vo_vo_vo_d_d_d_d(o0, o1, o2, -0.2161766247570055669e-18, -0.1237021188160598264e-10, +0.4669289654498104483e+3, -0.4695661044933107769e+5)); + t = vmla_vd_vd_vd_vd(t, vd2getx_vd_vd2(u), vsel_vd_vo_vo_vo_d_d_d_d(o0, o1, o2, +0.4695919173301595670e-17, +0.2117985839877627852e-09, -0.1796329879461355858e+4, +0.3173403108748643353e+5)); + t = vmla_vd_vd_vd_vd(t, vd2getx_vd_vd2(u), vsel_vd_vo_vo_vo_d_d_d_d(o0, o1, o2, -0.9049140419888007122e-16, -0.2290560929177369506e-08, +0.4355892193699575728e+4, +0.3242982786959573787e+4)); + t = vmla_vd_vd_vd_vd(t, vd2getx_vd_vd2(u), vsel_vd_vo_vo_vo_d_d_d_d(o0, o1, o2, +0.1634018903557410728e-14, +0.1748931621698149538e-07, -0.7456258884965764992e+4, -0.2014717999760347811e+5)); + t = vmla_vd_vd_vd_vd(t, vd2getx_vd_vd2(u), vsel_vd_vo_vo_vo_d_d_d_d(o0, o1, o2, -0.2783485786333451745e-13, -0.9956602606623249195e-07, +0.9553977358167021521e+4, +0.1554006970967118286e+5)); + t = vmla_vd_vd_vd_vd(t, vd2getx_vd_vd2(u), vsel_vd_vo_vo_vo_d_d_d_d(o0, o1, o2, +0.4463221276786415752e-12, +0.4330010240640327080e-06, -0.9470019905444229153e+4, -0.6150874190563554293e+4)); + t = vmla_vd_vd_vd_vd(t, vd2getx_vd_vd2(u), vsel_vd_vo_vo_vo_d_d_d_d(o0, o1, o2, -0.6711366622850136563e-11, -0.1435050600991763331e-05, +0.7387344321849855078e+4, +0.1240047765634815732e+4)); + t = vmla_vd_vd_vd_vd(t, vd2getx_vd_vd2(u), vsel_vd_vo_vo_vo_d_d_d_d(o0, o1, o2, +0.9422759050232662223e-10, +0.3460139479650695662e-05, -0.4557713054166382790e+4, -0.8210325475752699731e+2)); + t = vmla_vd_vd_vd_vd(t, vd2getx_vd_vd2(u), vsel_vd_vo_vo_vo_d_d_d_d(o0, o1, o2, -0.1229055530100229098e-08, -0.4988908180632898173e-05, +0.2207866967354055305e+4, +0.3242443880839930870e+2)); + t = vmla_vd_vd_vd_vd(t, vd2getx_vd_vd2(u), vsel_vd_vo_vo_vo_d_d_d_d(o0, o1, o2, +0.1480719281585086512e-07, -0.1308775976326352012e-05, -0.8217975658621754746e+3, -0.2923418863833160586e+2)); + t = vmla_vd_vd_vd_vd(t, vd2getx_vd_vd2(u), vsel_vd_vo_vo_vo_d_d_d_d(o0, o1, o2, -0.1636584469123399803e-06, +0.2825086540850310103e-04, +0.2268659483507917400e+3, +0.3457461732814383071e+0)); + t = vmla_vd_vd_vd_vd(t, vd2getx_vd_vd2(u), vsel_vd_vo_vo_vo_d_d_d_d(o0, o1, o2, +0.1646211436588923575e-05, -0.6393913713069986071e-04, -0.4633361260318560682e+2, +0.5489730155952392998e+1)); + t = vmla_vd_vd_vd_vd(t, vd2getx_vd_vd2(u), vsel_vd_vo_vo_vo_d_d_d_d(o0, o1, o2, -0.1492565035840623511e-04, -0.2566436514695078926e-04, +0.9557380123733945965e+1, +0.1559934132251294134e-2)); + t = vmla_vd_vd_vd_vd(t, vd2getx_vd_vd2(u), vsel_vd_vo_vo_vo_d_d_d_d(o0, o1, o2, +0.1205533298178967851e-03, +0.5895792375659440364e-03, -0.2958429331939661289e+1, -0.1541741566831520638e+1)); + t = vmla_vd_vd_vd_vd(t, vd2getx_vd_vd2(u), vsel_vd_vo_vo_vo_d_d_d_d(o0, o1, o2, -0.8548327023450850081e-03, -0.1695715579163588598e-02, +0.1670329508092765480e+0, +0.2823152230558364186e-5)); + t = vmla_vd_vd_vd_vd(t, vd2getx_vd_vd2(u), vsel_vd_vo_vo_vo_d_d_d_d(o0, o1, o2, +0.5223977625442187932e-02, +0.2089116434918055149e-03, +0.6096615680115419211e+0, +0.6249999184195342838e+0)); + t = vmla_vd_vd_vd_vd(t, vd2getx_vd_vd2(u), vsel_vd_vo_vo_vo_d_d_d_d(o0, o1, o2, -0.2686617064513125222e-01, +0.1912855949584917753e-01, +0.1059212443193543585e-2, +0.1741749416408701288e-8)); + + d = ddmul_vd2_vd2_vd(u, t); + d = ddadd2_vd2_vd2_vd2(d, vcast_vd2_vd_vd(vsel_vd_vo_vo_vo_d_d_d_d(o0, o1, o2, 0.11283791670955126141, -0.10277263343147646779, -0.50005180473999022439, -0.5000000000258444377), + vsel_vd_vo_vo_vo_d_d_d_d(o0, o1, o2, -4.0175691625932118483e-18, -6.2338714083404900225e-18, 2.6362140569041995803e-17, -4.0074044712386992281e-17))); + d = ddmul_vd2_vd2_vd2(d, u); + d = ddadd2_vd2_vd2_vd2(d, vcast_vd2_vd_vd(vsel_vd_vo_vo_vo_d_d_d_d(o0, o1, o2, -0.37612638903183753802, -0.63661976742916359662, 1.601106273924963368e-06, 2.3761973137523364792e-13), + vsel_vd_vo_vo_vo_d_d_d_d(o0, o1, o2, 1.3391897206042552387e-17, 7.6321019159085724662e-18, 1.1974001857764476775e-23, -1.1670076950531026582e-29))); + d = ddmul_vd2_vd2_vd2(d, u); + d = ddadd2_vd2_vd2_vd2(d, vcast_vd2_vd_vd(vsel_vd_vo_vo_vo_d_d_d_d(o0, o1, o2, 1.1283791670955125586, -1.1283791674717296161, -0.57236496645145429341, -0.57236494292470108114), + vsel_vd_vo_vo_vo_d_d_d_d(o0, o1, o2, 1.5335459613165822674e-17, 8.0896847755965377194e-17, 3.0704553245872027258e-17, -2.3984352208056898003e-17))); + + x = ddmul_vd2_vd2_vd(vsel_vd2_vo_vd2_vd2(o1, d, vcast_vd2_vd_vd(vneg_vd_vd(a), vcast_vd_d(0))), a); + x = vsel_vd2_vo_vd2_vd2(o1, x, ddadd2_vd2_vd2_vd2(x, d)); + x = vsel_vd2_vo_vd2_vd2(o0, ddsub_vd2_vd2_vd2(vcast_vd2_d_d(1, 0), x), expk2(x)); + x = vsel_vd2_vo_vd2_vd2(o1, x, ddmul_vd2_vd2_vd2(x, u)); + + r = vsel_vd_vo_vd_vd(o3, vadd_vd_vd_vd(vd2getx_vd_vd2(x), vd2gety_vd_vd2(x)), vcast_vd_d(0)); + r = vsel_vd_vo_vd_vd(vsignbit_vo_vd(s), vsub_vd_vd_vd(vcast_vd_d(2), r), r); + r = vsel_vd_vo_vd_vd(visnan_vo_vd(s), vcast_vd_d(SLEEF_NAN), r); + return r; +} +#endif // #if !defined(DETERMINISTIC) + +#if !defined(DETERMINISTIC) && !defined(ENABLE_GNUABI) && !defined(SLEEF_GENHEADER) +// The normal and deterministic versions of implementations are common +// for the functions like sincospi_u05. Aliases are defined by +// DALIAS_* macros for such functions. The defined aliases +// (e.g. ysincospi_u05) are renamed(e.g. to +// Sleef_cinz_sincospid2_u05sse2) by rename*.h. + +#ifdef ENABLE_ALIAS +#define DALIAS_vd_vd(FUNC) EXPORT CONST VECTOR_CC vdouble y ## FUNC(vdouble) __attribute__((alias( stringify(x ## FUNC) ))); +#define DALIAS_vd2_vd(FUNC) EXPORT CONST VECTOR_CC vdouble2 y ## FUNC(vdouble) __attribute__((alias( stringify(x ## FUNC) ))); +#define DALIAS_vi_vd(FUNC) EXPORT CONST VECTOR_CC vint y ## FUNC(vdouble) __attribute__((alias( stringify(x ## FUNC) ))); +#define DALIAS_vd_vd_vd(FUNC) EXPORT CONST VECTOR_CC vdouble y ## FUNC(vdouble, vdouble) __attribute__((alias( stringify(x ## FUNC) ))); +#define DALIAS_vd_vd_vd_vd(FUNC) EXPORT CONST VECTOR_CC vdouble y ## FUNC(vdouble, vdouble, vdouble) __attribute__((alias( stringify(x ## FUNC) ))); +#else +#define DALIAS_vd_vd(FUNC) EXPORT CONST VECTOR_CC vdouble y ## FUNC(vdouble d) { return x ## FUNC (d); } +#define DALIAS_vd2_vd(FUNC) EXPORT CONST VECTOR_CC vdouble2 y ## FUNC(vdouble d) { return x ## FUNC (d); } +#define DALIAS_vi_vd(FUNC) EXPORT CONST VECTOR_CC vint y ## FUNC(vdouble d) { return x ## FUNC (d); } +#define DALIAS_vd_vd_vd(FUNC) EXPORT CONST VECTOR_CC vdouble y ## FUNC(vdouble x, vdouble y) { return x ## FUNC (x, y); } +#define DALIAS_vd_vd_vd_vd(FUNC) EXPORT CONST VECTOR_CC vdouble y ## FUNC(vdouble x, vdouble y, vdouble z) { return x ## FUNC (x, y, z); } +#endif + +DALIAS_vd2_vd(sincospi_u05) +DALIAS_vd2_vd(sincospi_u35) +DALIAS_vd2_vd(modf) +DALIAS_vd_vd(log) +DALIAS_vd_vd(log_u1) +DALIAS_vd_vd_vd(pow) +DALIAS_vd_vd(sinh) +DALIAS_vd_vd(cosh) +DALIAS_vd_vd(tanh) +DALIAS_vd_vd(sinh_u35) +DALIAS_vd_vd(cosh_u35) +DALIAS_vd_vd(tanh_u35) +DALIAS_vd_vd(asinh) +DALIAS_vd_vd(acosh) +DALIAS_vd_vd(atanh) +DALIAS_vd_vd(cbrt) +DALIAS_vd_vd(cbrt_u1) +DALIAS_vd_vd(expm1) +DALIAS_vd_vd(log10) +DALIAS_vd_vd(log2) +DALIAS_vd_vd(log2_u35) +DALIAS_vd_vd(log1p) +DALIAS_vd_vd(fabs) +DALIAS_vd_vd_vd(copysign) +DALIAS_vd_vd_vd(fmax) +DALIAS_vd_vd_vd(fmin) +DALIAS_vd_vd_vd(fdim) +DALIAS_vd_vd(trunc) +DALIAS_vd_vd(floor) +DALIAS_vd_vd(ceil) +DALIAS_vd_vd(round) +DALIAS_vd_vd(rint) +DALIAS_vd_vd_vd(nextafter) +DALIAS_vd_vd(frfrexp) +DALIAS_vi_vd(expfrexp) +DALIAS_vd_vd_vd_vd(fma) +DALIAS_vd_vd(sqrt_u05) +DALIAS_vd_vd(sqrt_u35) +DALIAS_vd_vd_vd(hypot_u05) +DALIAS_vd_vd_vd(hypot_u35) +DALIAS_vd_vd_vd(fmod) +DALIAS_vd_vd_vd(remainder) +DALIAS_vd_vd(tgamma_u1) +DALIAS_vd_vd(lgamma_u1) +DALIAS_vd_vd(erf_u1) +DALIAS_vd_vd(erfc_u15) +#endif // #if !defined(DETERMINISTIC) && !defined(ENABLE_GNUABI) && !defined(SLEEF_GENHEADER) + +#if !defined(ENABLE_GNUABI) && !defined(SLEEF_GENHEADER) +EXPORT CONST int xgetInt(int name) { + if (1 <= name && name <= 10) return vavailability_i(name); + return 0; +} + +EXPORT CONST void *xgetPtr(int name) { + if (name == 0) return ISANAME; + return (void *)0; +} +#endif + +#if defined(ALIAS_NO_EXT_SUFFIX) && !defined(DETERMINISTIC) +#include ALIAS_NO_EXT_SUFFIX +#endif + +#ifdef ENABLE_MAIN +// gcc -DENABLE_MAIN -Wno-attributes -I../common -I../arch -DENABLE_AVX2 -mavx2 -mfma sleefsimddp.c rempitab.c ../common/common.c -lm +#include +#include +#include +int main(int argc, char **argv) { + vdouble d1 = vcast_vd_d(atof(argv[1])); + //vdouble d2 = vcast_vd_d(atof(argv[2])); + //vdouble d3 = vcast_vd_d(atof(argv[3])); + //vdouble r = xnextafter(d1, d2); + //int i; + //double fr = frexp(atof(argv[1]), &i); + //printf("%.20g\n", xfma(d1, d2, d3)[0]);; + //printf("test %.20g\n", xtgamma_u1(d1)[0]); + //printf("corr %.20g\n", tgamma(d1[0])); + printf("test %.20g\n", xerf_u1(d1)[0]); + printf("corr %.20g\n", erf(d1[0])); + //printf("test %.20g\n", xerfc_u15(d1)[0]); + //printf("corr %.20g\n", erfc(d1[0])); + //printf("%.20g\n", nextafter(d1[0], d2[0]));; + //printf("%.20g\n", vcast_d_vd(xhypot_u05(d1, d2))); + //printf("%.20g\n", fr); + //printf("%.20g\n", fmod(atof(argv[1]), atof(argv[2]))); + //printf("%.20g\n", xfmod(d1, d2)[0]); + //vdouble2 r = xsincospi_u35(a); + //printf("%g, %g\n", vcast_d_vd(r.x), vcast_d_vd(r.y)); +} +#endif + +#ifdef ENABLE_GNUABI +/* "finite" aliases for compatibility with GLIBC */ +EXPORT CONST VECTOR_CC vdouble __acos_finite (vdouble) __attribute__((weak, alias(str_xacos ))); +EXPORT CONST VECTOR_CC vdouble __acosh_finite (vdouble) __attribute__((weak, alias(str_xacosh ))); +EXPORT CONST VECTOR_CC vdouble __asin_finite (vdouble) __attribute__((weak, alias(str_xasin_u1 ))); +EXPORT CONST VECTOR_CC vdouble __atan2_finite (vdouble, vdouble) __attribute__((weak, alias(str_xatan2_u1 ))); +EXPORT CONST VECTOR_CC vdouble __atanh_finite (vdouble) __attribute__((weak, alias(str_xatanh ))); +EXPORT CONST VECTOR_CC vdouble __cosh_finite (vdouble) __attribute__((weak, alias(str_xcosh ))); +EXPORT CONST VECTOR_CC vdouble __exp10_finite (vdouble) __attribute__((weak, alias(str_xexp10 ))); +EXPORT CONST VECTOR_CC vdouble __exp2_finite (vdouble) __attribute__((weak, alias(str_xexp2 ))); +EXPORT CONST VECTOR_CC vdouble __exp_finite (vdouble) __attribute__((weak, alias(str_xexp ))); +EXPORT CONST VECTOR_CC vdouble __fmod_finite (vdouble, vdouble) __attribute__((weak, alias(str_xfmod ))); +EXPORT CONST VECTOR_CC vdouble __remainder_finite(vdouble, vdouble) __attribute__((weak, alias(str_xremainder))); +EXPORT CONST VECTOR_CC vdouble __modf_finite (vdouble, vdouble *) __attribute__((weak, alias(str_xmodf ))); +EXPORT CONST VECTOR_CC vdouble __hypot_u05_finite(vdouble, vdouble) __attribute__((weak, alias(str_xhypot_u05))); +EXPORT CONST VECTOR_CC vdouble __lgamma_u1_finite(vdouble) __attribute__((weak, alias(str_xlgamma_u1))); +EXPORT CONST VECTOR_CC vdouble __log10_finite (vdouble) __attribute__((weak, alias(str_xlog10 ))); +EXPORT CONST VECTOR_CC vdouble __log_finite (vdouble) __attribute__((weak, alias(str_xlog_u1 ))); +EXPORT CONST VECTOR_CC vdouble __pow_finite (vdouble, vdouble) __attribute__((weak, alias(str_xpow ))); +EXPORT CONST VECTOR_CC vdouble __sinh_finite (vdouble) __attribute__((weak, alias(str_xsinh ))); +EXPORT CONST VECTOR_CC vdouble __sqrt_finite (vdouble) __attribute__((weak, alias(str_xsqrt ))); +EXPORT CONST VECTOR_CC vdouble __tgamma_u1_finite(vdouble) __attribute__((weak, alias(str_xtgamma_u1))); + +#ifdef HEADER_MASKED +#include HEADER_MASKED +#endif +#endif /* #ifdef ENABLE_GNUABI */ diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/sleefsimdsp.c b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/sleefsimdsp.c new file mode 100644 index 00000000000..efe9c0e79c4 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/sleefsimdsp.c @@ -0,0 +1,3709 @@ +// Copyright Naoki Shibata and contributors 2010 - 2024. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// Always use -ffp-contract=off option to compile SLEEF. + +#if !defined(SLEEF_GENHEADER) +#include +#include +#include +#include +#endif + +#include "quaddef.h" +#include "misc.h" + +#ifndef SLEEF_ENABLE_CUDA +extern const float Sleef_rempitabsp[]; +#endif + +#define __SLEEFSIMDSP_C__ + +#if defined(_MSC_VER) && !defined (__clang__) +#pragma fp_contract (off) +#else +#pragma STDC FP_CONTRACT OFF +#endif + +// Intel + +#ifdef ENABLE_SSE2 +#define CONFIG 2 +#if !defined(SLEEF_GENHEADER) +#include "helpersse2.h" +#else +#include "macroonlySSE2.h" +#endif +#ifdef DORENAME +#ifdef ENABLE_GNUABI +#include "renamesse2_gnuabi.h" +#else +#include "renamesse2.h" +#endif +#endif +#endif + +#ifdef ENABLE_SSE4 +#define CONFIG 4 +#if !defined(SLEEF_GENHEADER) +#include "helpersse2.h" +#else +#include "macroonlySSE4.h" +#endif +#ifdef DORENAME +#include "renamesse4.h" +#endif +#endif + +#ifdef ENABLE_AVX +#define CONFIG 1 +#if !defined(SLEEF_GENHEADER) +#include "helperavx.h" +#else +#include "macroonlyAVX.h" +#endif +#ifdef DORENAME +#ifdef ENABLE_GNUABI +#include "renameavx_gnuabi.h" +#else +#include "renameavx.h" +#endif +#endif +#endif + +#ifdef ENABLE_FMA4 +#define CONFIG 4 +#if !defined(SLEEF_GENHEADER) +#include "helperavx.h" +#else +#include "macroonlyFMA4.h" +#endif +#ifdef DORENAME +#ifdef ENABLE_GNUABI +#include "renamefma4_gnuabi.h" +#else +#include "renamefma4.h" +#endif +#endif +#endif + +#ifdef ENABLE_AVX2 +#define CONFIG 1 +#if !defined(SLEEF_GENHEADER) +#include "helperavx2.h" +#else +#include "macroonlyAVX2.h" +#endif +#ifdef DORENAME +#ifdef ENABLE_GNUABI +#include "renameavx2_gnuabi.h" +#else +#include "renameavx2.h" +#endif +#endif +#endif + +#ifdef ENABLE_AVX2128 +#define CONFIG 1 +#if !defined(SLEEF_GENHEADER) +#include "helperavx2_128.h" +#else +#include "macroonlyAVX2128.h" +#endif +#ifdef DORENAME +#include "renameavx2128.h" +#endif +#endif + +#ifdef ENABLE_AVX512F +#define CONFIG 1 +#if !defined(SLEEF_GENHEADER) +#include "helperavx512f.h" +#else +#include "macroonlyAVX512F.h" +#endif +#ifdef DORENAME +#ifdef ENABLE_GNUABI +#include "renameavx512f_gnuabi.h" +#else +#include "renameavx512f.h" +#endif +#endif +#endif + +#ifdef ENABLE_AVX512FNOFMA +#define CONFIG 2 +#if !defined(SLEEF_GENHEADER) +#include "helperavx512f.h" +#else +#include "macroonlyAVX512FNOFMA.h" +#endif +#ifdef DORENAME +#include "renameavx512fnofma.h" +#endif +#endif + +// Arm + +#ifdef ENABLE_ADVSIMD +#define CONFIG 1 +#if !defined(SLEEF_GENHEADER) +#include "helperadvsimd.h" +#else +#include "macroonlyADVSIMD.h" +#endif +#ifdef DORENAME +#ifdef ENABLE_GNUABI +#include "renameadvsimd_gnuabi.h" +#else +#include "renameadvsimd.h" +#endif +#endif +#endif + +#ifdef ENABLE_ADVSIMDNOFMA +#define CONFIG 2 +#if !defined(SLEEF_GENHEADER) +#include "helperadvsimd.h" +#else +#include "macroonlyADVSIMDNOFMA.h" +#endif +#ifdef DORENAME +#include "renameadvsimdnofma.h" +#endif +#endif + +#ifdef ENABLE_NEON32 +#define CONFIG 1 +#if !defined(SLEEF_GENHEADER) +#include "helperneon32.h" +#endif +#ifdef DORENAME +#include "renameneon32.h" +#endif +#endif + +#ifdef ENABLE_NEON32VFPV4 +#define CONFIG 4 +#if !defined(SLEEF_GENHEADER) +#include "helperneon32.h" +#endif +#ifdef DORENAME +#include "renameneon32vfpv4.h" +#endif +#endif + +#ifdef ENABLE_SVE +#define CONFIG 1 +#if !defined(SLEEF_GENHEADER) +#include "helpersve.h" +#else +#include "macroonlySVE.h" +#endif +#ifdef DORENAME +#ifdef ENABLE_GNUABI +#include "renamesve_gnuabi.h" +#else +#include "renamesve.h" +#endif /* ENABLE_GNUABI */ +#endif /* DORENAME */ +#endif /* ENABLE_SVE */ + +#ifdef ENABLE_SVENOFMA +#define CONFIG 2 +#if !defined(SLEEF_GENHEADER) +#include "helpersve.h" +#else +#include "macroonlySVENOFMA.h" +#endif +#ifdef DORENAME +#include "renamesvenofma.h" +#endif /* DORENAME */ +#endif /* ENABLE_SVE */ + +// IBM + +#ifdef ENABLE_VSX +#define CONFIG 1 +#if !defined(SLEEF_GENHEADER) +#include "helperpower_128.h" +#else +#include "macroonlyVSX.h" +#endif +#ifdef DORENAME +#include "renamevsx.h" +#endif +#endif + +#ifdef ENABLE_VSXNOFMA +#define CONFIG 2 +#if !defined(SLEEF_GENHEADER) +#include "helperpower_128.h" +#else +#include "macroonlyVSXNOFMA.h" +#endif +#ifdef DORENAME +#include "renamevsxnofma.h" +#endif +#endif + +#ifdef ENABLE_VSX3 +#define CONFIG 3 +#if !defined(SLEEF_GENHEADER) +#include "helperpower_128.h" +#else +#include "macroonlyVSX3.h" +#endif +#ifdef DORENAME +#include "renamevsx3.h" +#endif +#endif + +#ifdef ENABLE_VSX3NOFMA +#define CONFIG 4 +#if !defined(SLEEF_GENHEADER) +#include "helperpower_128.h" +#else +#include "macroonlyVSX3NOFMA.h" +#endif +#ifdef DORENAME +#include "renamevsx3nofma.h" +#endif +#endif + +#ifdef ENABLE_VXE +#define CONFIG 140 +#if !defined(SLEEF_GENHEADER) +#include "helpers390x_128.h" +#else +#include "macroonlyVXE.h" +#endif +#ifdef DORENAME +#include "renamevxe.h" +#endif +#endif + +#ifdef ENABLE_VXENOFMA +#define CONFIG 141 +#if !defined(SLEEF_GENHEADER) +#include "helpers390x_128.h" +#else +#include "macroonlyVXENOFMA.h" +#endif +#ifdef DORENAME +#include "renamevxenofma.h" +#endif +#endif + +#ifdef ENABLE_VXE2 +#define CONFIG 150 +#if !defined(SLEEF_GENHEADER) +#include "helpers390x_128.h" +#else +#include "macroonlyVXE2.h" +#endif +#ifdef DORENAME +#include "renamevxe2.h" +#endif +#endif + +#ifdef ENABLE_VXE2NOFMA +#define CONFIG 151 +#if !defined(SLEEF_GENHEADER) +#include "helpers390x_128.h" +#else +#include "macroonlyVXE2NOFMA.h" +#endif +#ifdef DORENAME +#include "renamevxe2nofma.h" +#endif +#endif + +// RISC-V +#ifdef ENABLE_RVVM1 +#define CONFIG 1 +#define ENABLE_RVV_SP +#if !defined(SLEEF_GENHEADER) +#include "helperrvv.h" +#else +#include "macroonlyRVVM1.h" +#endif +#ifdef DORENAME +#include "renamervvm1.h" +#endif +#endif + +#ifdef ENABLE_RVVM1NOFMA +#define CONFIG 2 +#define ENABLE_RVV_SP +#if !defined(SLEEF_GENHEADER) +#include "helperrvv.h" +#else +#include "macroonlyRVVM1NOFMA.h" +#endif +#ifdef DORENAME +#include "renamervvm1nofma.h" +#endif +#endif + +#ifdef ENABLE_RVVM2 +#define CONFIG 1 +#define ENABLE_RVV_SP +#if !defined(SLEEF_GENHEADER) +#include "helperrvv.h" +#else +#include "macroonlyRVVM2.h" +#endif +#ifdef DORENAME +#include "renamervvm2.h" +#endif +#endif + +#ifdef ENABLE_RVVM2NOFMA +#define CONFIG 2 +#define ENABLE_RVV_SP +#if !defined(SLEEF_GENHEADER) +#include "helperrvv.h" +#else +#include "macroonlyRVVM2NOFMA.h" +#endif +#ifdef DORENAME +#include "renamervvm2nofma.h" +#endif +#endif + +// Generic + +#ifdef ENABLE_VECEXT +#define CONFIG 1 +#if !defined(SLEEF_GENHEADER) +#include "helpervecext.h" +#endif +#ifdef DORENAME +#include "renamevecext.h" +#endif +#endif + +#ifdef ENABLE_PUREC +#define CONFIG 1 +#if !defined(SLEEF_GENHEADER) +#include "helperpurec.h" +#endif +#ifdef DORENAME +#include "renamepurec.h" +#endif +#endif + +#ifdef ENABLE_PUREC_SCALAR +#define CONFIG 1 +#if !defined(SLEEF_GENHEADER) +#include "helperpurec_scalar.h" +#else +#include "macroonlyPUREC_SCALAR.h" +#endif +#ifdef DORENAME +#include "renamepurec_scalar.h" +#endif +#endif + +#ifdef ENABLE_PURECFMA_SCALAR +#define CONFIG 2 +#if !defined(SLEEF_GENHEADER) +#include "helperpurec_scalar.h" +#else +#include "macroonlyPURECFMA_SCALAR.h" +#endif +#ifdef DORENAME +#include "renamepurecfma_scalar.h" +#endif +#endif + +#ifdef SLEEF_ENABLE_CUDA +#define CONFIG 3 +#if !defined(SLEEF_GENHEADER) +#include "helperpurec_scalar.h" +#else +#include "macroonlyCUDA.h" +#endif +#ifdef DORENAME +#include "renamecuda.h" +#endif +#endif + +// + +#define MLA(x, y, z) vmla_vf_vf_vf_vf((x), (y), (z)) +#define C2V(c) vcast_vf_f(c) +#include "estrin.h" + +// + +#include "df.h" + +static INLINE CONST VECTOR_CC vopmask visnegzero_vo_vf(vfloat d) { + return veq_vo_vi2_vi2(vreinterpret_vi2_vf(d), vreinterpret_vi2_vf(vcast_vf_f(-0.0))); +} + +static INLINE VECTOR_CC vopmask vnot_vo32_vo32(vopmask x) { + return vxor_vo_vo_vo(x, veq_vo_vi2_vi2(vcast_vi2_i(0), vcast_vi2_i(0))); +} + +static INLINE CONST VECTOR_CC vmask vsignbit_vm_vf(vfloat f) { + return vand_vm_vm_vm(vreinterpret_vm_vf(f), vreinterpret_vm_vf(vcast_vf_f(-0.0f))); +} + +#if !(defined(ENABLE_RVVM1) || defined(ENABLE_RVVM1NOFMA) || defined(ENABLE_RVVM2) || defined(ENABLE_RVVM2NOFMA)) +static INLINE CONST VECTOR_CC vfloat vmulsign_vf_vf_vf(vfloat x, vfloat y) { + return vreinterpret_vf_vm(vxor_vm_vm_vm(vreinterpret_vm_vf(x), vsignbit_vm_vf(y))); +} + +static INLINE CONST VECTOR_CC vfloat vcopysign_vf_vf_vf(vfloat x, vfloat y) { + return vreinterpret_vf_vm(vxor_vm_vm_vm(vandnot_vm_vm_vm(vreinterpret_vm_vf(vcast_vf_f(-0.0f)), vreinterpret_vm_vf(x)), + vand_vm_vm_vm (vreinterpret_vm_vf(vcast_vf_f(-0.0f)), vreinterpret_vm_vf(y)))); +} + +static INLINE CONST VECTOR_CC vfloat vsign_vf_vf(vfloat f) { + return vreinterpret_vf_vm(vor_vm_vm_vm(vreinterpret_vm_vf(vcast_vf_f(1.0f)), vand_vm_vm_vm(vreinterpret_vm_vf(vcast_vf_f(-0.0f)), vreinterpret_vm_vf(f)))); +} +#endif + +static INLINE CONST VECTOR_CC vopmask vsignbit_vo_vf(vfloat d) { + return veq_vo_vi2_vi2(vand_vi2_vi2_vi2(vreinterpret_vi2_vf(d), vcast_vi2_i(0x80000000)), vcast_vi2_i(0x80000000)); +} + +static INLINE CONST VECTOR_CC vint2 vsel_vi2_vf_vf_vi2_vi2(vfloat f0, vfloat f1, vint2 x, vint2 y) { + return vsel_vi2_vo_vi2_vi2(vlt_vo_vf_vf(f0, f1), x, y); +} + +static INLINE CONST VECTOR_CC vint2 vsel_vi2_vf_vi2(vfloat d, vint2 x) { + return vand_vi2_vo_vi2(vsignbit_vo_vf(d), x); +} + +static INLINE CONST VECTOR_CC vopmask visint_vo_vf(vfloat y) { return veq_vo_vf_vf(vtruncate_vf_vf(y), y); } + +static INLINE CONST VECTOR_CC vopmask visnumber_vo_vf(vfloat x) { return vnot_vo32_vo32(vor_vo_vo_vo(visinf_vo_vf(x), visnan_vo_vf(x))); } + +#if !defined(ENABLE_AVX512F) && !defined(ENABLE_AVX512FNOFMA) +static INLINE CONST VECTOR_CC vint2 vilogbk_vi2_vf(vfloat d) { + vopmask o = vlt_vo_vf_vf(d, vcast_vf_f(5.421010862427522E-20f)); + d = vsel_vf_vo_vf_vf(o, vmul_vf_vf_vf(vcast_vf_f(1.8446744073709552E19f), d), d); + vint2 q = vand_vi2_vi2_vi2(vsrl_vi2_vi2_i(vreinterpret_vi2_vf(d), 23), vcast_vi2_i(0xff)); + q = vsub_vi2_vi2_vi2(q, vsel_vi2_vo_vi2_vi2(o, vcast_vi2_i(64 + 0x7f), vcast_vi2_i(0x7f))); + return q; +} + +static INLINE CONST VECTOR_CC vint2 vilogb2k_vi2_vf(vfloat d) { + vint2 q = vreinterpret_vi2_vf(d); + q = vsrl_vi2_vi2_i(q, 23); + q = vand_vi2_vi2_vi2(q, vcast_vi2_i(0xff)); + q = vsub_vi2_vi2_vi2(q, vcast_vi2_i(0x7f)); + return q; +} +#endif + +// + +EXPORT CONST VECTOR_CC vint2 xilogbf(vfloat d) { + vint2 e = vilogbk_vi2_vf(vabs_vf_vf(d)); + e = vsel_vi2_vo_vi2_vi2(veq_vo_vf_vf(d, vcast_vf_f(0.0f)), vcast_vi2_i(SLEEF_FP_ILOGB0), e); + e = vsel_vi2_vo_vi2_vi2(visnan_vo_vf(d), vcast_vi2_i(SLEEF_FP_ILOGBNAN), e); + e = vsel_vi2_vo_vi2_vi2(visinf_vo_vf(d), vcast_vi2_i(SLEEF_INT_MAX), e); + return e; +} + +static INLINE CONST VECTOR_CC vfloat vpow2i_vf_vi2(vint2 q) { + return vreinterpret_vf_vi2(vsll_vi2_vi2_i(vadd_vi2_vi2_vi2(q, vcast_vi2_i(0x7f)), 23)); +} + +static INLINE CONST VECTOR_CC vfloat vldexp_vf_vf_vi2(vfloat x, vint2 q) { + vfloat u; + vint2 m = vsra_vi2_vi2_i(q, 31); + m = vsll_vi2_vi2_i(vsub_vi2_vi2_vi2(vsra_vi2_vi2_i(vadd_vi2_vi2_vi2(m, q), 6), m), 4); + q = vsub_vi2_vi2_vi2(q, vsll_vi2_vi2_i(m, 2)); + m = vadd_vi2_vi2_vi2(m, vcast_vi2_i(0x7f)); + m = vand_vi2_vi2_vi2(vgt_vi2_vi2_vi2(m, vcast_vi2_i(0)), m); + vint2 n = vgt_vi2_vi2_vi2(m, vcast_vi2_i(0xff)); + m = vor_vi2_vi2_vi2(vandnot_vi2_vi2_vi2(n, m), vand_vi2_vi2_vi2(n, vcast_vi2_i(0xff))); + u = vreinterpret_vf_vi2(vsll_vi2_vi2_i(m, 23)); + x = vmul_vf_vf_vf(vmul_vf_vf_vf(vmul_vf_vf_vf(vmul_vf_vf_vf(x, u), u), u), u); + u = vreinterpret_vf_vi2(vsll_vi2_vi2_i(vadd_vi2_vi2_vi2(q, vcast_vi2_i(0x7f)), 23)); + return vmul_vf_vf_vf(x, u); +} + +static INLINE CONST VECTOR_CC vfloat vldexp2_vf_vf_vi2(vfloat d, vint2 e) { + return vmul_vf_vf_vf(vmul_vf_vf_vf(d, vpow2i_vf_vi2(vsra_vi2_vi2_i(e, 1))), vpow2i_vf_vi2(vsub_vi2_vi2_vi2(e, vsra_vi2_vi2_i(e, 1)))); +} + +static INLINE CONST VECTOR_CC vfloat vldexp3_vf_vf_vi2(vfloat d, vint2 q) { + return vreinterpret_vf_vi2(vadd_vi2_vi2_vi2(vreinterpret_vi2_vf(d), vsll_vi2_vi2_i(q, 23))); +} + +EXPORT CONST VECTOR_CC vfloat xldexpf(vfloat x, vint2 q) { return vldexp_vf_vf_vi2(x, q); } + +#if !(defined(ENABLE_SVE) || defined(ENABLE_SVENOFMA) || defined(ENABLE_RVVM1) || defined(ENABLE_RVVM1NOFMA) || defined(ENABLE_RVVM2) || defined(ENABLE_RVVM2NOFMA)) +typedef struct { + vfloat d; + vint2 i; +} fi_t; + +static vfloat figetd_vf_di(fi_t d) { return d.d; } +static vint2 figeti_vi2_di(fi_t d) { return d.i; } +static fi_t fisetdi_fi_vf_vi2(vfloat d, vint2 i) { + fi_t r = { d, i }; + return r; +} + +typedef struct { + vfloat2 df; + vint2 i; +} dfi_t; + +static vfloat2 dfigetdf_vf2_dfi(dfi_t d) { return d.df; } +static vint2 dfigeti_vi2_dfi(dfi_t d) { return d.i; } +static dfi_t dfisetdfi_dfi_vf2_vi2(vfloat2 v, vint2 i) { + dfi_t r = { v, i }; + return r; +} +static dfi_t dfisetdf_dfi_dfi_vf2(dfi_t dfi, vfloat2 v) { + dfi.df = v; + return dfi; +} +#endif + +#if !(defined(ENABLE_RVVM1) || defined(ENABLE_RVVM1NOFMA) || defined(ENABLE_RVVM2) || defined(ENABLE_RVVM2NOFMA)) +static INLINE CONST VECTOR_CC vfloat vorsign_vf_vf_vf(vfloat x, vfloat y) { + return vreinterpret_vf_vm(vor_vm_vm_vm(vreinterpret_vm_vf(x), vsignbit_vm_vf(y))); +} +#endif + +static INLINE CONST fi_t rempisubf(vfloat x) { +#ifdef FULL_FP_ROUNDING + vfloat y = vrint_vf_vf(vmul_vf_vf_vf(x, vcast_vf_f(4))); + vint2 vi = vtruncate_vi2_vf(vsub_vf_vf_vf(y, vmul_vf_vf_vf(vrint_vf_vf(x), vcast_vf_f(4)))); + return fisetdi_fi_vf_vi2(vsub_vf_vf_vf(x, vmul_vf_vf_vf(y, vcast_vf_f(0.25))), vi); +#else + vfloat c = vmulsign_vf_vf_vf(vcast_vf_f(1 << 23), x); + vfloat rint4x = vsel_vf_vo_vf_vf(vgt_vo_vf_vf(vabs_vf_vf(vmul_vf_vf_vf(vcast_vf_f(4), x)), vcast_vf_f(1 << 23)), + vmul_vf_vf_vf(vcast_vf_f(4), x), + vorsign_vf_vf_vf(vsub_vf_vf_vf(vmla_vf_vf_vf_vf(vcast_vf_f(4), x, c), c), x)); + vfloat rintx = vsel_vf_vo_vf_vf(vgt_vo_vf_vf(vabs_vf_vf(x), vcast_vf_f(1 << 23)), + x, vorsign_vf_vf_vf(vsub_vf_vf_vf(vadd_vf_vf_vf(x, c), c), x)); + return fisetdi_fi_vf_vi2(vmla_vf_vf_vf_vf(vcast_vf_f(-0.25), rint4x, x), + vtruncate_vi2_vf(vmla_vf_vf_vf_vf(vcast_vf_f(-4), rintx, rint4x))); +#endif +} + +static INLINE CONST dfi_t rempif(vfloat a) { + vfloat2 x, y; + vint2 ex = vilogb2k_vi2_vf(a); +#if defined(ENABLE_AVX512F) || defined(ENABLE_AVX512FNOFMA) + ex = vandnot_vi2_vi2_vi2(vsra_vi2_vi2_i(ex, 31), ex); + ex = vand_vi2_vi2_vi2(ex, vcast_vi2_i(127)); +#endif + ex = vsub_vi2_vi2_vi2(ex, vcast_vi2_i(25)); + vint2 q = vand_vi2_vo_vi2(vgt_vo_vi2_vi2(ex, vcast_vi2_i(90-25)), vcast_vi2_i(-64)); + a = vldexp3_vf_vf_vi2(a, q); + ex = vandnot_vi2_vi2_vi2(vsra_vi2_vi2_i(ex, 31), ex); + ex = vsll_vi2_vi2_i(ex, 2); + x = dfmul_vf2_vf_vf(a, vgather_vf_p_vi2(Sleef_rempitabsp, ex)); + fi_t di = rempisubf(vf2getx_vf_vf2(x)); + q = figeti_vi2_di(di); + x = vf2setx_vf2_vf2_vf(x, figetd_vf_di(di)); + x = dfnormalize_vf2_vf2(x); + y = dfmul_vf2_vf_vf(a, vgather_vf_p_vi2(Sleef_rempitabsp+1, ex)); + x = dfadd2_vf2_vf2_vf2(x, y); + di = rempisubf(vf2getx_vf_vf2(x)); + q = vadd_vi2_vi2_vi2(q, figeti_vi2_di(di)); + x = vf2setx_vf2_vf2_vf(x, figetd_vf_di(di)); + x = dfnormalize_vf2_vf2(x); + y = vcast_vf2_vf_vf(vgather_vf_p_vi2(Sleef_rempitabsp+2, ex), vgather_vf_p_vi2(Sleef_rempitabsp+3, ex)); + y = dfmul_vf2_vf2_vf(y, a); + x = dfadd2_vf2_vf2_vf2(x, y); + x = dfnormalize_vf2_vf2(x); + x = dfmul_vf2_vf2_vf2(x, vcast_vf2_f_f(3.1415927410125732422f*2, -8.7422776573475857731e-08f*2)); + x = vsel_vf2_vo_vf2_vf2(vlt_vo_vf_vf(vabs_vf_vf(a), vcast_vf_f(0.7f)), vcast_vf2_vf_vf(a, vcast_vf_f(0)), x); + return dfisetdfi_dfi_vf2_vi2(x, q); +} + +EXPORT CONST VECTOR_CC vfloat xsinf(vfloat d) { +#if !defined(DETERMINISTIC) + vint2 q; + vfloat u, s, r = d; + + if (LIKELY(vtestallones_i_vo32(vlt_vo_vf_vf(vabs_vf_vf(d), vcast_vf_f(TRIGRANGEMAX2f))))) { + q = vrint_vi2_vf(vmul_vf_vf_vf(d, vcast_vf_f((float)M_1_PI))); + u = vcast_vf_vi2(q); + d = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_A2f), d); + d = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_B2f), d); + d = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_C2f), d); + } else if (LIKELY(vtestallones_i_vo32(vlt_vo_vf_vf(vabs_vf_vf(d), vcast_vf_f(TRIGRANGEMAXf))))) { + q = vrint_vi2_vf(vmul_vf_vf_vf(d, vcast_vf_f((float)M_1_PI))); + u = vcast_vf_vi2(q); + d = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_Af), d); + d = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_Bf), d); + d = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_Cf), d); + d = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_Df), d); + } else { + dfi_t dfi = rempif(d); + q = vand_vi2_vi2_vi2(dfigeti_vi2_dfi(dfi), vcast_vi2_i(3)); + q = vadd_vi2_vi2_vi2(vadd_vi2_vi2_vi2(q, q), vsel_vi2_vo_vi2_vi2(vgt_vo_vf_vf(vf2getx_vf_vf2(dfigetdf_vf2_dfi(dfi)), vcast_vf_f(0)), vcast_vi2_i(2), vcast_vi2_i(1))); + q = vsra_vi2_vi2_i(q, 2); + vopmask o = veq_vo_vi2_vi2(vand_vi2_vi2_vi2(dfigeti_vi2_dfi(dfi), vcast_vi2_i(1)), vcast_vi2_i(1)); + vfloat2 x = vcast_vf2_vf_vf(vmulsign_vf_vf_vf(vcast_vf_f(3.1415927410125732422f*-0.5), vf2getx_vf_vf2(dfigetdf_vf2_dfi(dfi))), + vmulsign_vf_vf_vf(vcast_vf_f(-8.7422776573475857731e-08f*-0.5), vf2getx_vf_vf2(dfigetdf_vf2_dfi(dfi)))); + x = dfadd2_vf2_vf2_vf2(dfigetdf_vf2_dfi(dfi), x); + dfi = dfisetdf_dfi_dfi_vf2(dfi, vsel_vf2_vo_vf2_vf2(o, x, dfigetdf_vf2_dfi(dfi))); + d = vadd_vf_vf_vf(vf2getx_vf_vf2(dfigetdf_vf2_dfi(dfi)), vf2gety_vf_vf2(dfigetdf_vf2_dfi(dfi))); + + d = vreinterpret_vf_vm(vor_vm_vo32_vm(vor_vo_vo_vo(visinf_vo_vf(r), visnan_vo_vf(r)), vreinterpret_vm_vf(d))); + } + + s = vmul_vf_vf_vf(d, d); + + d = vreinterpret_vf_vm(vxor_vm_vm_vm(vand_vm_vo32_vm(veq_vo_vi2_vi2(vand_vi2_vi2_vi2(q, vcast_vi2_i(1)), vcast_vi2_i(1)), vreinterpret_vm_vf(vcast_vf_f(-0.0f))), vreinterpret_vm_vf(d))); + + u = vcast_vf_f(2.6083159809786593541503e-06f); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(-0.0001981069071916863322258f)); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(0.00833307858556509017944336f)); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(-0.166666597127914428710938f)); + + u = vadd_vf_vf_vf(vmul_vf_vf_vf(s, vmul_vf_vf_vf(u, d)), d); + + u = vsel_vf_vo_vf_vf(visnegzero_vo_vf(r), r, u); + + return u; + +#else // #if !defined(DETERMINISTIC) + + vint2 q; + vfloat u, s, r = d; + + q = vrint_vi2_vf(vmul_vf_vf_vf(d, vcast_vf_f((float)M_1_PI))); + u = vcast_vf_vi2(q); + d = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_A2f), d); + d = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_B2f), d); + d = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_C2f), d); + vopmask g = vlt_vo_vf_vf(vabs_vf_vf(r), vcast_vf_f(TRIGRANGEMAX2f)); + + if (!LIKELY(vtestallones_i_vo32(g))) { + s = vcast_vf_vi2(q); + u = vmla_vf_vf_vf_vf(s, vcast_vf_f(-PI_Af), r); + u = vmla_vf_vf_vf_vf(s, vcast_vf_f(-PI_Bf), u); + u = vmla_vf_vf_vf_vf(s, vcast_vf_f(-PI_Cf), u); + u = vmla_vf_vf_vf_vf(s, vcast_vf_f(-PI_Df), u); + + d = vsel_vf_vo_vf_vf(g, d, u); + g = vlt_vo_vf_vf(vabs_vf_vf(r), vcast_vf_f(TRIGRANGEMAXf)); + + if (!LIKELY(vtestallones_i_vo32(g))) { + dfi_t dfi = rempif(r); + vint2 q2 = vand_vi2_vi2_vi2(dfigeti_vi2_dfi(dfi), vcast_vi2_i(3)); + q2 = vadd_vi2_vi2_vi2(vadd_vi2_vi2_vi2(q2, q2), vsel_vi2_vo_vi2_vi2(vgt_vo_vf_vf(vf2getx_vf_vf2(dfigetdf_vf2_dfi(dfi)), vcast_vf_f(0)), vcast_vi2_i(2), vcast_vi2_i(1))); + q2 = vsra_vi2_vi2_i(q2, 2); + vopmask o = veq_vo_vi2_vi2(vand_vi2_vi2_vi2(dfigeti_vi2_dfi(dfi), vcast_vi2_i(1)), vcast_vi2_i(1)); + vfloat2 x = vcast_vf2_vf_vf(vmulsign_vf_vf_vf(vcast_vf_f(3.1415927410125732422f*-0.5), vf2getx_vf_vf2(dfigetdf_vf2_dfi(dfi))), + vmulsign_vf_vf_vf(vcast_vf_f(-8.7422776573475857731e-08f*-0.5), vf2getx_vf_vf2(dfigetdf_vf2_dfi(dfi)))); + x = dfadd2_vf2_vf2_vf2(dfigetdf_vf2_dfi(dfi), x); + dfi = dfisetdf_dfi_dfi_vf2(dfi, vsel_vf2_vo_vf2_vf2(o, x, dfigetdf_vf2_dfi(dfi))); + u = vadd_vf_vf_vf(vf2getx_vf_vf2(dfigetdf_vf2_dfi(dfi)), vf2gety_vf_vf2(dfigetdf_vf2_dfi(dfi))); + + u = vreinterpret_vf_vm(vor_vm_vo32_vm(vor_vo_vo_vo(visinf_vo_vf(r), visnan_vo_vf(r)), vreinterpret_vm_vf(u))); + + q = vsel_vi2_vo_vi2_vi2(g, q, q2); + d = vsel_vf_vo_vf_vf(g, d, u); + } + } + + s = vmul_vf_vf_vf(d, d); + + d = vreinterpret_vf_vm(vxor_vm_vm_vm(vand_vm_vo32_vm(veq_vo_vi2_vi2(vand_vi2_vi2_vi2(q, vcast_vi2_i(1)), vcast_vi2_i(1)), vreinterpret_vm_vf(vcast_vf_f(-0.0f))), vreinterpret_vm_vf(d))); + + u = vcast_vf_f(2.6083159809786593541503e-06f); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(-0.0001981069071916863322258f)); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(0.00833307858556509017944336f)); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(-0.166666597127914428710938f)); + + u = vadd_vf_vf_vf(vmul_vf_vf_vf(s, vmul_vf_vf_vf(u, d)), d); + + u = vsel_vf_vo_vf_vf(visnegzero_vo_vf(r), r, u); + + return u; +#endif // #if !defined(DETERMINISTIC) +} + +EXPORT CONST VECTOR_CC vfloat xcosf(vfloat d) { +#if !defined(DETERMINISTIC) + vint2 q; + vfloat u, s, r = d; + + if (LIKELY(vtestallones_i_vo32(vlt_vo_vf_vf(vabs_vf_vf(d), vcast_vf_f(TRIGRANGEMAX2f))))) { + q = vrint_vi2_vf(vsub_vf_vf_vf(vmul_vf_vf_vf(d, vcast_vf_f((float)M_1_PI)), vcast_vf_f(0.5f))); + q = vadd_vi2_vi2_vi2(vadd_vi2_vi2_vi2(q, q), vcast_vi2_i(1)); + + u = vcast_vf_vi2(q); + d = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_A2f*0.5f), d); + d = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_B2f*0.5f), d); + d = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_C2f*0.5f), d); + } else if (LIKELY(vtestallones_i_vo32(vlt_vo_vf_vf(vabs_vf_vf(d), vcast_vf_f(TRIGRANGEMAXf))))) { + q = vrint_vi2_vf(vsub_vf_vf_vf(vmul_vf_vf_vf(d, vcast_vf_f((float)M_1_PI)), vcast_vf_f(0.5f))); + q = vadd_vi2_vi2_vi2(vadd_vi2_vi2_vi2(q, q), vcast_vi2_i(1)); + + u = vcast_vf_vi2(q); + d = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_Af*0.5f), d); + d = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_Bf*0.5f), d); + d = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_Cf*0.5f), d); + d = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_Df*0.5f), d); + } else { + dfi_t dfi = rempif(d); + q = vand_vi2_vi2_vi2(dfigeti_vi2_dfi(dfi), vcast_vi2_i(3)); + q = vadd_vi2_vi2_vi2(vadd_vi2_vi2_vi2(q, q), vsel_vi2_vo_vi2_vi2(vgt_vo_vf_vf(vf2getx_vf_vf2(dfigetdf_vf2_dfi(dfi)), vcast_vf_f(0)), vcast_vi2_i(8), vcast_vi2_i(7))); + q = vsra_vi2_vi2_i(q, 1); + vopmask o = veq_vo_vi2_vi2(vand_vi2_vi2_vi2(dfigeti_vi2_dfi(dfi), vcast_vi2_i(1)), vcast_vi2_i(0)); + vfloat y = vsel_vf_vo_vf_vf(vgt_vo_vf_vf(vf2getx_vf_vf2(dfigetdf_vf2_dfi(dfi)), vcast_vf_f(0)), vcast_vf_f(0), vcast_vf_f(-1)); + vfloat2 x = vcast_vf2_vf_vf(vmulsign_vf_vf_vf(vcast_vf_f(3.1415927410125732422f*-0.5), y), + vmulsign_vf_vf_vf(vcast_vf_f(-8.7422776573475857731e-08f*-0.5), y)); + x = dfadd2_vf2_vf2_vf2(dfigetdf_vf2_dfi(dfi), x); + dfi = dfisetdf_dfi_dfi_vf2(dfi, vsel_vf2_vo_vf2_vf2(o, x, dfigetdf_vf2_dfi(dfi))); + d = vadd_vf_vf_vf(vf2getx_vf_vf2(dfigetdf_vf2_dfi(dfi)), vf2gety_vf_vf2(dfigetdf_vf2_dfi(dfi))); + + d = vreinterpret_vf_vm(vor_vm_vo32_vm(vor_vo_vo_vo(visinf_vo_vf(r), visnan_vo_vf(r)), vreinterpret_vm_vf(d))); + } + + s = vmul_vf_vf_vf(d, d); + + d = vreinterpret_vf_vm(vxor_vm_vm_vm(vand_vm_vo32_vm(veq_vo_vi2_vi2(vand_vi2_vi2_vi2(q, vcast_vi2_i(2)), vcast_vi2_i(0)), vreinterpret_vm_vf(vcast_vf_f(-0.0f))), vreinterpret_vm_vf(d))); + + u = vcast_vf_f(2.6083159809786593541503e-06f); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(-0.0001981069071916863322258f)); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(0.00833307858556509017944336f)); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(-0.166666597127914428710938f)); + + u = vadd_vf_vf_vf(vmul_vf_vf_vf(s, vmul_vf_vf_vf(u, d)), d); + + return u; + +#else // #if !defined(DETERMINISTIC) + + vint2 q; + vfloat u, s, r = d; + + q = vrint_vi2_vf(vsub_vf_vf_vf(vmul_vf_vf_vf(d, vcast_vf_f((float)M_1_PI)), vcast_vf_f(0.5f))); + q = vadd_vi2_vi2_vi2(vadd_vi2_vi2_vi2(q, q), vcast_vi2_i(1)); + u = vcast_vf_vi2(q); + d = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_A2f*0.5f), d); + d = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_B2f*0.5f), d); + d = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_C2f*0.5f), d); + vopmask g = vlt_vo_vf_vf(vabs_vf_vf(r), vcast_vf_f(TRIGRANGEMAX2f)); + + if (!LIKELY(vtestallones_i_vo32(g))) { + s = vcast_vf_vi2(q); + u = vmla_vf_vf_vf_vf(s, vcast_vf_f(-PI_Af*0.5f), r); + u = vmla_vf_vf_vf_vf(s, vcast_vf_f(-PI_Bf*0.5f), u); + u = vmla_vf_vf_vf_vf(s, vcast_vf_f(-PI_Cf*0.5f), u); + u = vmla_vf_vf_vf_vf(s, vcast_vf_f(-PI_Df*0.5f), u); + + d = vsel_vf_vo_vf_vf(g, d, u); + g = vlt_vo_vf_vf(vabs_vf_vf(r), vcast_vf_f(TRIGRANGEMAXf)); + + if (!LIKELY(vtestallones_i_vo32(g))) { + dfi_t dfi = rempif(r); + vint2 q2 = vand_vi2_vi2_vi2(dfigeti_vi2_dfi(dfi), vcast_vi2_i(3)); + q2 = vadd_vi2_vi2_vi2(vadd_vi2_vi2_vi2(q2, q2), vsel_vi2_vo_vi2_vi2(vgt_vo_vf_vf(vf2getx_vf_vf2(dfigetdf_vf2_dfi(dfi)), vcast_vf_f(0)), vcast_vi2_i(8), vcast_vi2_i(7))); + q2 = vsra_vi2_vi2_i(q2, 1); + vopmask o = veq_vo_vi2_vi2(vand_vi2_vi2_vi2(dfigeti_vi2_dfi(dfi), vcast_vi2_i(1)), vcast_vi2_i(0)); + vfloat y = vsel_vf_vo_vf_vf(vgt_vo_vf_vf(vf2getx_vf_vf2(dfigetdf_vf2_dfi(dfi)), vcast_vf_f(0)), vcast_vf_f(0), vcast_vf_f(-1)); + vfloat2 x = vcast_vf2_vf_vf(vmulsign_vf_vf_vf(vcast_vf_f(3.1415927410125732422f*-0.5), y), + vmulsign_vf_vf_vf(vcast_vf_f(-8.7422776573475857731e-08f*-0.5), y)); + x = dfadd2_vf2_vf2_vf2(dfigetdf_vf2_dfi(dfi), x); + dfi = dfisetdf_dfi_dfi_vf2(dfi, vsel_vf2_vo_vf2_vf2(o, x, dfigetdf_vf2_dfi(dfi))); + u = vadd_vf_vf_vf(vf2getx_vf_vf2(dfigetdf_vf2_dfi(dfi)), vf2gety_vf_vf2(dfigetdf_vf2_dfi(dfi))); + + u = vreinterpret_vf_vm(vor_vm_vo32_vm(vor_vo_vo_vo(visinf_vo_vf(r), visnan_vo_vf(r)), vreinterpret_vm_vf(u))); + + q = vsel_vi2_vo_vi2_vi2(g, q, q2); + d = vsel_vf_vo_vf_vf(g, d, u); + } + } + + s = vmul_vf_vf_vf(d, d); + + d = vreinterpret_vf_vm(vxor_vm_vm_vm(vand_vm_vo32_vm(veq_vo_vi2_vi2(vand_vi2_vi2_vi2(q, vcast_vi2_i(2)), vcast_vi2_i(0)), vreinterpret_vm_vf(vcast_vf_f(-0.0f))), vreinterpret_vm_vf(d))); + + u = vcast_vf_f(2.6083159809786593541503e-06f); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(-0.0001981069071916863322258f)); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(0.00833307858556509017944336f)); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(-0.166666597127914428710938f)); + + u = vadd_vf_vf_vf(vmul_vf_vf_vf(s, vmul_vf_vf_vf(u, d)), d); + + return u; +#endif // #if !defined(DETERMINISTIC) +} + +EXPORT CONST VECTOR_CC vfloat xtanf(vfloat d) { +#if !defined(DETERMINISTIC) + vint2 q; + vopmask o; + vfloat u, s, x; + + x = d; + + if (LIKELY(vtestallones_i_vo32(vlt_vo_vf_vf(vabs_vf_vf(d), vcast_vf_f(TRIGRANGEMAX2f*0.5f))))) { + q = vrint_vi2_vf(vmul_vf_vf_vf(d, vcast_vf_f((float)(2 * M_1_PI)))); + u = vcast_vf_vi2(q); + x = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_A2f*0.5f), x); + x = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_B2f*0.5f), x); + x = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_C2f*0.5f), x); + } else if (LIKELY(vtestallones_i_vo32(vlt_vo_vf_vf(vabs_vf_vf(d), vcast_vf_f(TRIGRANGEMAXf))))) { + q = vrint_vi2_vf(vmul_vf_vf_vf(d, vcast_vf_f((float)(2 * M_1_PI)))); + u = vcast_vf_vi2(q); + x = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_Af*0.5f), x); + x = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_Bf*0.5f), x); + x = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_Cf*0.5f), x); + x = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_Df*0.5f), x); + } else { + dfi_t dfi = rempif(d); + q = dfigeti_vi2_dfi(dfi); + x = vadd_vf_vf_vf(vf2getx_vf_vf2(dfigetdf_vf2_dfi(dfi)), vf2gety_vf_vf2(dfigetdf_vf2_dfi(dfi))); + x = vreinterpret_vf_vm(vor_vm_vo32_vm(vor_vo_vo_vo(visinf_vo_vf(d), visnan_vo_vf(d)), vreinterpret_vm_vf(x))); + x = vsel_vf_vo_vf_vf(visnegzero_vo_vf(d), d, x); + } + + s = vmul_vf_vf_vf(x, x); + + o = veq_vo_vi2_vi2(vand_vi2_vi2_vi2(q, vcast_vi2_i(1)), vcast_vi2_i(1)); + x = vreinterpret_vf_vm(vxor_vm_vm_vm(vand_vm_vo32_vm(o, vreinterpret_vm_vf(vcast_vf_f(-0.0f))), vreinterpret_vm_vf(x))); + +#if defined(ENABLE_NEON32) + u = vcast_vf_f(0.00927245803177356719970703f); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(0.00331984995864331722259521f)); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(0.0242998078465461730957031f)); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(0.0534495301544666290283203f)); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(0.133383005857467651367188f)); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(0.333331853151321411132812f)); +#else + vfloat s2 = vmul_vf_vf_vf(s, s), s4 = vmul_vf_vf_vf(s2, s2); + u = POLY6(s, s2, s4, + 0.00927245803177356719970703f, + 0.00331984995864331722259521f, + 0.0242998078465461730957031f, + 0.0534495301544666290283203f, + 0.133383005857467651367188f, + 0.333331853151321411132812f); +#endif + + u = vmla_vf_vf_vf_vf(s, vmul_vf_vf_vf(u, x), x); + + u = vsel_vf_vo_vf_vf(o, vrec_vf_vf(u), u); + + return u; + +#else // #if !defined(DETERMINISTIC) + + vint2 q; + vopmask o; + vfloat u, s, x; + + q = vrint_vi2_vf(vmul_vf_vf_vf(d, vcast_vf_f((float)(2 * M_1_PI)))); + u = vcast_vf_vi2(q); + x = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_A2f*0.5f), d); + x = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_B2f*0.5f), x); + x = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_C2f*0.5f), x); + vopmask g = vlt_vo_vf_vf(vabs_vf_vf(d), vcast_vf_f(TRIGRANGEMAX2f*0.5f)); + + if (!LIKELY(vtestallones_i_vo32(g))) { + vint2 q2 = vrint_vi2_vf(vmul_vf_vf_vf(d, vcast_vf_f((float)(2 * M_1_PI)))); + s = vcast_vf_vi2(q); + u = vmla_vf_vf_vf_vf(s, vcast_vf_f(-PI_Af*0.5f), d); + u = vmla_vf_vf_vf_vf(s, vcast_vf_f(-PI_Bf*0.5f), u); + u = vmla_vf_vf_vf_vf(s, vcast_vf_f(-PI_Cf*0.5f), u); + u = vmla_vf_vf_vf_vf(s, vcast_vf_f(-PI_Df*0.5f), u); + + q = vsel_vi2_vo_vi2_vi2(g, q, q2); + x = vsel_vf_vo_vf_vf(g, x, u); + g = vlt_vo_vf_vf(vabs_vf_vf(d), vcast_vf_f(TRIGRANGEMAXf)); + + if (!LIKELY(vtestallones_i_vo32(g))) { + dfi_t dfi = rempif(d); + u = vadd_vf_vf_vf(vf2getx_vf_vf2(dfigetdf_vf2_dfi(dfi)), vf2gety_vf_vf2(dfigetdf_vf2_dfi(dfi))); + u = vreinterpret_vf_vm(vor_vm_vo32_vm(vor_vo_vo_vo(visinf_vo_vf(d), visnan_vo_vf(d)), vreinterpret_vm_vf(u))); + u = vsel_vf_vo_vf_vf(visnegzero_vo_vf(d), d, u); + q = vsel_vi2_vo_vi2_vi2(g, q, dfigeti_vi2_dfi(dfi)); + x = vsel_vf_vo_vf_vf(g, x, u); + } + } + + s = vmul_vf_vf_vf(x, x); + + o = veq_vo_vi2_vi2(vand_vi2_vi2_vi2(q, vcast_vi2_i(1)), vcast_vi2_i(1)); + x = vreinterpret_vf_vm(vxor_vm_vm_vm(vand_vm_vo32_vm(o, vreinterpret_vm_vf(vcast_vf_f(-0.0f))), vreinterpret_vm_vf(x))); + +#if defined(ENABLE_NEON32) + u = vcast_vf_f(0.00927245803177356719970703f); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(0.00331984995864331722259521f)); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(0.0242998078465461730957031f)); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(0.0534495301544666290283203f)); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(0.133383005857467651367188f)); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(0.333331853151321411132812f)); +#else + vfloat s2 = vmul_vf_vf_vf(s, s), s4 = vmul_vf_vf_vf(s2, s2); + u = POLY6(s, s2, s4, + 0.00927245803177356719970703f, + 0.00331984995864331722259521f, + 0.0242998078465461730957031f, + 0.0534495301544666290283203f, + 0.133383005857467651367188f, + 0.333331853151321411132812f); +#endif + + u = vmla_vf_vf_vf_vf(s, vmul_vf_vf_vf(u, x), x); + + u = vsel_vf_vo_vf_vf(o, vrec_vf_vf(u), u); + + return u; +#endif // #if !defined(DETERMINISTIC) +} + +EXPORT CONST VECTOR_CC vfloat xsinf_u1(vfloat d) { +#if !defined(DETERMINISTIC) + vint2 q; + vfloat u, v; + vfloat2 s, t, x; + + if (LIKELY(vtestallones_i_vo32(vlt_vo_vf_vf(vabs_vf_vf(d), vcast_vf_f(TRIGRANGEMAX2f))))) { + u = vrint_vf_vf(vmul_vf_vf_vf(d, vcast_vf_f(M_1_PI))); + q = vrint_vi2_vf(u); + v = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_A2f), d); + s = dfadd2_vf2_vf_vf(v, vmul_vf_vf_vf(u, vcast_vf_f(-PI_B2f))); + s = dfadd_vf2_vf2_vf(s, vmul_vf_vf_vf(u, vcast_vf_f(-PI_C2f))); + } else { + dfi_t dfi = rempif(d); + q = vand_vi2_vi2_vi2(dfigeti_vi2_dfi(dfi), vcast_vi2_i(3)); + q = vadd_vi2_vi2_vi2(vadd_vi2_vi2_vi2(q, q), vsel_vi2_vo_vi2_vi2(vgt_vo_vf_vf(vf2getx_vf_vf2(dfigetdf_vf2_dfi(dfi)), vcast_vf_f(0)), vcast_vi2_i(2), vcast_vi2_i(1))); + q = vsra_vi2_vi2_i(q, 2); + vopmask o = veq_vo_vi2_vi2(vand_vi2_vi2_vi2(dfigeti_vi2_dfi(dfi), vcast_vi2_i(1)), vcast_vi2_i(1)); + vfloat2 x = vcast_vf2_vf_vf(vmulsign_vf_vf_vf(vcast_vf_f(3.1415927410125732422f*-0.5), vf2getx_vf_vf2(dfigetdf_vf2_dfi(dfi))), + vmulsign_vf_vf_vf(vcast_vf_f(-8.7422776573475857731e-08f*-0.5), vf2getx_vf_vf2(dfigetdf_vf2_dfi(dfi)))); + x = dfadd2_vf2_vf2_vf2(dfigetdf_vf2_dfi(dfi), x); + dfi = dfisetdf_dfi_dfi_vf2(dfi, vsel_vf2_vo_vf2_vf2(o, x, dfigetdf_vf2_dfi(dfi))); + s = dfnormalize_vf2_vf2(dfigetdf_vf2_dfi(dfi)); + +#if !defined(_MSC_VER) + s = vf2setx_vf2_vf2_vf(s, vreinterpret_vf_vm(vor_vm_vo32_vm(vor_vo_vo_vo(visinf_vo_vf(d), visnan_vo_vf(d)), vreinterpret_vm_vf(vf2getx_vf_vf2(s))))); +#else + s.x = vreinterpret_vf_vm(vor_vm_vo32_vm(vor_vo_vo_vo(visinf_vo_vf(d), visnan_vo_vf(d)), vreinterpret_vm_vf(s.x))); +#endif + } + + t = s; + s = dfsqu_vf2_vf2(s); + + u = vcast_vf_f(2.6083159809786593541503e-06f); + u = vmla_vf_vf_vf_vf(u, vf2getx_vf_vf2(s), vcast_vf_f(-0.0001981069071916863322258f)); + u = vmla_vf_vf_vf_vf(u, vf2getx_vf_vf2(s), vcast_vf_f(0.00833307858556509017944336f)); + + x = dfadd_vf2_vf_vf2(vcast_vf_f(1), dfmul_vf2_vf2_vf2(dfadd_vf2_vf_vf(vcast_vf_f(-0.166666597127914428710938f), vmul_vf_vf_vf(u, vf2getx_vf_vf2(s))), s)); + + u = dfmul_vf_vf2_vf2(t, x); + + u = vreinterpret_vf_vm(vxor_vm_vm_vm(vand_vm_vo32_vm(veq_vo_vi2_vi2(vand_vi2_vi2_vi2(q, vcast_vi2_i(1)), vcast_vi2_i(1)), vreinterpret_vm_vf(vcast_vf_f(-0.0))), vreinterpret_vm_vf(u))); + + u = vsel_vf_vo_vf_vf(visnegzero_vo_vf(d), d, u); + + return u; + +#else // #if !defined(DETERMINISTIC) + + vint2 q; + vfloat u, v; + vfloat2 s, t, x; + + u = vrint_vf_vf(vmul_vf_vf_vf(d, vcast_vf_f(M_1_PI))); + q = vrint_vi2_vf(u); + v = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_A2f), d); + s = dfadd2_vf2_vf_vf(v, vmul_vf_vf_vf(u, vcast_vf_f(-PI_B2f))); + s = dfadd_vf2_vf2_vf(s, vmul_vf_vf_vf(u, vcast_vf_f(-PI_C2f))); + vopmask g = vlt_vo_vf_vf(vabs_vf_vf(d), vcast_vf_f(TRIGRANGEMAX2f)); + + if (!LIKELY(vtestallones_i_vo32(g))) { + dfi_t dfi = rempif(d); + vint2 q2 = vand_vi2_vi2_vi2(dfigeti_vi2_dfi(dfi), vcast_vi2_i(3)); + q2 = vadd_vi2_vi2_vi2(vadd_vi2_vi2_vi2(q2, q2), vsel_vi2_vo_vi2_vi2(vgt_vo_vf_vf(vf2getx_vf_vf2(dfigetdf_vf2_dfi(dfi)), vcast_vf_f(0)), vcast_vi2_i(2), vcast_vi2_i(1))); + q2 = vsra_vi2_vi2_i(q2, 2); + vopmask o = veq_vo_vi2_vi2(vand_vi2_vi2_vi2(dfigeti_vi2_dfi(dfi), vcast_vi2_i(1)), vcast_vi2_i(1)); + vfloat2 x = vcast_vf2_vf_vf(vmulsign_vf_vf_vf(vcast_vf_f(3.1415927410125732422f*-0.5), vf2getx_vf_vf2(dfigetdf_vf2_dfi(dfi))), + vmulsign_vf_vf_vf(vcast_vf_f(-8.7422776573475857731e-08f*-0.5), vf2getx_vf_vf2(dfigetdf_vf2_dfi(dfi)))); + x = dfadd2_vf2_vf2_vf2(dfigetdf_vf2_dfi(dfi), x); + dfi = dfisetdf_dfi_dfi_vf2(dfi, vsel_vf2_vo_vf2_vf2(o, x, dfigetdf_vf2_dfi(dfi))); + t = dfnormalize_vf2_vf2(dfigetdf_vf2_dfi(dfi)); + + t = vf2setx_vf2_vf2_vf(t, vreinterpret_vf_vm(vor_vm_vo32_vm(vor_vo_vo_vo(visinf_vo_vf(d), visnan_vo_vf(d)), vreinterpret_vm_vf(vf2getx_vf_vf2(t))))); + + q = vsel_vi2_vo_vi2_vi2(g, q, q2); + s = vsel_vf2_vo_vf2_vf2(g, s, t); + } + + t = s; + s = dfsqu_vf2_vf2(s); + + u = vcast_vf_f(2.6083159809786593541503e-06f); + u = vmla_vf_vf_vf_vf(u, vf2getx_vf_vf2(s), vcast_vf_f(-0.0001981069071916863322258f)); + u = vmla_vf_vf_vf_vf(u, vf2getx_vf_vf2(s), vcast_vf_f(0.00833307858556509017944336f)); + + x = dfadd_vf2_vf_vf2(vcast_vf_f(1), dfmul_vf2_vf2_vf2(dfadd_vf2_vf_vf(vcast_vf_f(-0.166666597127914428710938f), vmul_vf_vf_vf(u, vf2getx_vf_vf2(s))), s)); + + u = dfmul_vf_vf2_vf2(t, x); + + u = vreinterpret_vf_vm(vxor_vm_vm_vm(vand_vm_vo32_vm(veq_vo_vi2_vi2(vand_vi2_vi2_vi2(q, vcast_vi2_i(1)), vcast_vi2_i(1)), vreinterpret_vm_vf(vcast_vf_f(-0.0))), vreinterpret_vm_vf(u))); + + u = vsel_vf_vo_vf_vf(visnegzero_vo_vf(d), d, u); + + return u; +#endif // #if !defined(DETERMINISTIC) +} + +EXPORT CONST VECTOR_CC vfloat xcosf_u1(vfloat d) { +#if !defined(DETERMINISTIC) + vint2 q; + vfloat u; + vfloat2 s, t, x; + + if (LIKELY(vtestallones_i_vo32(vlt_vo_vf_vf(vabs_vf_vf(d), vcast_vf_f(TRIGRANGEMAX2f))))) { + vfloat dq = vmla_vf_vf_vf_vf(vrint_vf_vf(vmla_vf_vf_vf_vf(d, vcast_vf_f(M_1_PI), vcast_vf_f(-0.5f))), + vcast_vf_f(2), vcast_vf_f(1)); + q = vrint_vi2_vf(dq); + s = dfadd2_vf2_vf_vf (d, vmul_vf_vf_vf(dq, vcast_vf_f(-PI_A2f*0.5f))); + s = dfadd2_vf2_vf2_vf(s, vmul_vf_vf_vf(dq, vcast_vf_f(-PI_B2f*0.5f))); + s = dfadd2_vf2_vf2_vf(s, vmul_vf_vf_vf(dq, vcast_vf_f(-PI_C2f*0.5f))); + } else { + dfi_t dfi = rempif(d); + q = vand_vi2_vi2_vi2(dfigeti_vi2_dfi(dfi), vcast_vi2_i(3)); + q = vadd_vi2_vi2_vi2(vadd_vi2_vi2_vi2(q, q), vsel_vi2_vo_vi2_vi2(vgt_vo_vf_vf(vf2getx_vf_vf2(dfigetdf_vf2_dfi(dfi)), vcast_vf_f(0)), vcast_vi2_i(8), vcast_vi2_i(7))); + q = vsra_vi2_vi2_i(q, 1); + vopmask o = veq_vo_vi2_vi2(vand_vi2_vi2_vi2(dfigeti_vi2_dfi(dfi), vcast_vi2_i(1)), vcast_vi2_i(0)); + vfloat y = vsel_vf_vo_vf_vf(vgt_vo_vf_vf(vf2getx_vf_vf2(dfigetdf_vf2_dfi(dfi)), vcast_vf_f(0)), vcast_vf_f(0), vcast_vf_f(-1)); + vfloat2 x = vcast_vf2_vf_vf(vmulsign_vf_vf_vf(vcast_vf_f(3.1415927410125732422f*-0.5), y), + vmulsign_vf_vf_vf(vcast_vf_f(-8.7422776573475857731e-08f*-0.5), y)); + x = dfadd2_vf2_vf2_vf2(dfigetdf_vf2_dfi(dfi), x); + dfi = dfisetdf_dfi_dfi_vf2(dfi, vsel_vf2_vo_vf2_vf2(o, x, dfigetdf_vf2_dfi(dfi))); + s = dfnormalize_vf2_vf2(dfigetdf_vf2_dfi(dfi)); + +#if !defined(_MSC_VER) + s = vf2setx_vf2_vf2_vf(s, vreinterpret_vf_vm(vor_vm_vo32_vm(vor_vo_vo_vo(visinf_vo_vf(d), visnan_vo_vf(d)), vreinterpret_vm_vf(vf2getx_vf_vf2(s))))); +#else + s.x = vreinterpret_vf_vm(vor_vm_vo32_vm(vor_vo_vo_vo(visinf_vo_vf(d), visnan_vo_vf(d)), vreinterpret_vm_vf(s.x))); +#endif + } + + t = s; + s = dfsqu_vf2_vf2(s); + + u = vcast_vf_f(2.6083159809786593541503e-06f); + u = vmla_vf_vf_vf_vf(u, vf2getx_vf_vf2(s), vcast_vf_f(-0.0001981069071916863322258f)); + u = vmla_vf_vf_vf_vf(u, vf2getx_vf_vf2(s), vcast_vf_f(0.00833307858556509017944336f)); + + x = dfadd_vf2_vf_vf2(vcast_vf_f(1), dfmul_vf2_vf2_vf2(dfadd_vf2_vf_vf(vcast_vf_f(-0.166666597127914428710938f), vmul_vf_vf_vf(u, vf2getx_vf_vf2(s))), s)); + + u = dfmul_vf_vf2_vf2(t, x); + + u = vreinterpret_vf_vm(vxor_vm_vm_vm(vand_vm_vo32_vm(veq_vo_vi2_vi2(vand_vi2_vi2_vi2(q, vcast_vi2_i(2)), vcast_vi2_i(0)), vreinterpret_vm_vf(vcast_vf_f(-0.0))), vreinterpret_vm_vf(u))); + + return u; + +#else // #if !defined(DETERMINISTIC) + + vint2 q; + vfloat u; + vfloat2 s, t, x; + + vfloat dq = vmla_vf_vf_vf_vf(vrint_vf_vf(vmla_vf_vf_vf_vf(d, vcast_vf_f(M_1_PI), vcast_vf_f(-0.5f))), + vcast_vf_f(2), vcast_vf_f(1)); + q = vrint_vi2_vf(dq); + s = dfadd2_vf2_vf_vf (d, vmul_vf_vf_vf(dq, vcast_vf_f(-PI_A2f*0.5f))); + s = dfadd2_vf2_vf2_vf(s, vmul_vf_vf_vf(dq, vcast_vf_f(-PI_B2f*0.5f))); + s = dfadd2_vf2_vf2_vf(s, vmul_vf_vf_vf(dq, vcast_vf_f(-PI_C2f*0.5f))); + vopmask g = vlt_vo_vf_vf(vabs_vf_vf(d), vcast_vf_f(TRIGRANGEMAX2f)); + + if (!LIKELY(vtestallones_i_vo32(g))) { + dfi_t dfi = rempif(d); + vint2 q2 = vand_vi2_vi2_vi2(dfigeti_vi2_dfi(dfi), vcast_vi2_i(3)); + q2 = vadd_vi2_vi2_vi2(vadd_vi2_vi2_vi2(q2, q2), vsel_vi2_vo_vi2_vi2(vgt_vo_vf_vf(vf2getx_vf_vf2(dfigetdf_vf2_dfi(dfi)), vcast_vf_f(0)), vcast_vi2_i(8), vcast_vi2_i(7))); + q2 = vsra_vi2_vi2_i(q2, 1); + vopmask o = veq_vo_vi2_vi2(vand_vi2_vi2_vi2(dfigeti_vi2_dfi(dfi), vcast_vi2_i(1)), vcast_vi2_i(0)); + vfloat y = vsel_vf_vo_vf_vf(vgt_vo_vf_vf(vf2getx_vf_vf2(dfigetdf_vf2_dfi(dfi)), vcast_vf_f(0)), vcast_vf_f(0), vcast_vf_f(-1)); + vfloat2 x = vcast_vf2_vf_vf(vmulsign_vf_vf_vf(vcast_vf_f(3.1415927410125732422f*-0.5), y), + vmulsign_vf_vf_vf(vcast_vf_f(-8.7422776573475857731e-08f*-0.5), y)); + x = dfadd2_vf2_vf2_vf2(dfigetdf_vf2_dfi(dfi), x); + dfi = dfisetdf_dfi_dfi_vf2(dfi, vsel_vf2_vo_vf2_vf2(o, x, dfigetdf_vf2_dfi(dfi))); + t = dfnormalize_vf2_vf2(dfigetdf_vf2_dfi(dfi)); + + t = vf2setx_vf2_vf2_vf(t, vreinterpret_vf_vm(vor_vm_vo32_vm(vor_vo_vo_vo(visinf_vo_vf(d), visnan_vo_vf(d)), vreinterpret_vm_vf(vf2getx_vf_vf2(t))))); + + q = vsel_vi2_vo_vi2_vi2(g, q, q2); + s = vsel_vf2_vo_vf2_vf2(g, s, t); + } + + t = s; + s = dfsqu_vf2_vf2(s); + + u = vcast_vf_f(2.6083159809786593541503e-06f); + u = vmla_vf_vf_vf_vf(u, vf2getx_vf_vf2(s), vcast_vf_f(-0.0001981069071916863322258f)); + u = vmla_vf_vf_vf_vf(u, vf2getx_vf_vf2(s), vcast_vf_f(0.00833307858556509017944336f)); + + x = dfadd_vf2_vf_vf2(vcast_vf_f(1), dfmul_vf2_vf2_vf2(dfadd_vf2_vf_vf(vcast_vf_f(-0.166666597127914428710938f), vmul_vf_vf_vf(u, vf2getx_vf_vf2(s))), s)); + + u = dfmul_vf_vf2_vf2(t, x); + + u = vreinterpret_vf_vm(vxor_vm_vm_vm(vand_vm_vo32_vm(veq_vo_vi2_vi2(vand_vi2_vi2_vi2(q, vcast_vi2_i(2)), vcast_vi2_i(0)), vreinterpret_vm_vf(vcast_vf_f(-0.0))), vreinterpret_vm_vf(u))); + + return u; +#endif // #if !defined(DETERMINISTIC) +} + +EXPORT CONST VECTOR_CC vfloat xfastsinf_u3500(vfloat d) { + vint2 q; + vfloat u, s, t = d; + + s = vmul_vf_vf_vf(d, vcast_vf_f((float)M_1_PI)); + u = vrint_vf_vf(s); + q = vrint_vi2_vf(s); + d = vmla_vf_vf_vf_vf(u, vcast_vf_f(-(float)M_PI), d); + + s = vmul_vf_vf_vf(d, d); + + u = vcast_vf_f(-0.1881748176e-3); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(+0.8323502727e-2)); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(-0.1666651368e+0)); + u = vmla_vf_vf_vf_vf(vmul_vf_vf_vf(s, d), u, d); + + u = vreinterpret_vf_vm(vxor_vm_vm_vm(vand_vm_vo32_vm(veq_vo_vi2_vi2(vand_vi2_vi2_vi2(q, vcast_vi2_i(1)), vcast_vi2_i(1)), vreinterpret_vm_vf(vcast_vf_f(-0.0f))), vreinterpret_vm_vf(u))); + + vopmask g = vlt_vo_vf_vf(vabs_vf_vf(t), vcast_vf_f(30.0f)); + if (!LIKELY(vtestallones_i_vo32(g))) return vsel_vf_vo_vf_vf(g, u, xsinf(t)); + + return u; +} + +EXPORT CONST VECTOR_CC vfloat xfastcosf_u3500(vfloat d) { + vint2 q; + vfloat u, s, t = d; + + s = vmla_vf_vf_vf_vf(d, vcast_vf_f((float)M_1_PI), vcast_vf_f(-0.5f)); + u = vrint_vf_vf(s); + q = vrint_vi2_vf(s); + d = vmla_vf_vf_vf_vf(u, vcast_vf_f(-(float)M_PI), vsub_vf_vf_vf(d, vcast_vf_f((float)M_PI * 0.5f))); + + s = vmul_vf_vf_vf(d, d); + + u = vcast_vf_f(-0.1881748176e-3); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(+0.8323502727e-2)); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(-0.1666651368e+0)); + u = vmla_vf_vf_vf_vf(vmul_vf_vf_vf(s, d), u, d); + + u = vreinterpret_vf_vm(vxor_vm_vm_vm(vand_vm_vo32_vm(veq_vo_vi2_vi2(vand_vi2_vi2_vi2(q, vcast_vi2_i(1)), vcast_vi2_i(0)), vreinterpret_vm_vf(vcast_vf_f(-0.0f))), vreinterpret_vm_vf(u))); + + vopmask g = vlt_vo_vf_vf(vabs_vf_vf(t), vcast_vf_f(30.0f)); + if (!LIKELY(vtestallones_i_vo32(g))) return vsel_vf_vo_vf_vf(g, u, xcosf(t)); + + return u; +} + +#ifdef ENABLE_GNUABI +#define TYPE2_FUNCATR static INLINE CONST +#define TYPE6_FUNCATR static INLINE CONST +#define SQRTFU05_FUNCATR static INLINE CONST +#define XSINCOSF sincosfk +#define XSINCOSF_U1 sincosfk_u1 +#define XSINCOSPIF_U05 sincospifk_u05 +#define XSINCOSPIF_U35 sincospifk_u35 +#define XMODFF modffk +#else +#define TYPE2_FUNCATR EXPORT CONST +#define TYPE6_FUNCATR EXPORT +#define SQRTFU05_FUNCATR EXPORT +#define XSINCOSF xsincosf +#define XSINCOSF_U1 xsincosf_u1 +#define XSINCOSPIF_U05 xsincospif_u05 +#define XSINCOSPIF_U35 xsincospif_u35 +#define XMODFF xmodff +#endif + +TYPE2_FUNCATR VECTOR_CC vfloat2 XSINCOSF(vfloat d) { +#if !defined(DETERMINISTIC) + vint2 q; + vopmask o; + vfloat u, s, t, rx, ry; + vfloat2 r; + + s = d; + + if (LIKELY(vtestallones_i_vo32(vlt_vo_vf_vf(vabs_vf_vf(d), vcast_vf_f(TRIGRANGEMAX2f))))) { + q = vrint_vi2_vf(vmul_vf_vf_vf(d, vcast_vf_f((float)M_2_PI))); + u = vcast_vf_vi2(q); + s = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_A2f*0.5f), s); + s = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_B2f*0.5f), s); + s = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_C2f*0.5f), s); + } else if (LIKELY(vtestallones_i_vo32(vlt_vo_vf_vf(vabs_vf_vf(d), vcast_vf_f(TRIGRANGEMAXf))))) { + q = vrint_vi2_vf(vmul_vf_vf_vf(d, vcast_vf_f((float)M_2_PI))); + u = vcast_vf_vi2(q); + s = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_Af*0.5f), s); + s = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_Bf*0.5f), s); + s = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_Cf*0.5f), s); + s = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_Df*0.5f), s); + } else { + dfi_t dfi = rempif(d); + q = dfigeti_vi2_dfi(dfi); + s = vadd_vf_vf_vf(vf2getx_vf_vf2(dfigetdf_vf2_dfi(dfi)), vf2gety_vf_vf2(dfigetdf_vf2_dfi(dfi))); + s = vreinterpret_vf_vm(vor_vm_vo32_vm(vor_vo_vo_vo(visinf_vo_vf(d), visnan_vo_vf(d)), vreinterpret_vm_vf(s))); + } + + t = s; + + s = vmul_vf_vf_vf(s, s); + + u = vcast_vf_f(-0.000195169282960705459117889f); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(0.00833215750753879547119141f)); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(-0.166666537523269653320312f)); + + rx = vmla_vf_vf_vf_vf(vmul_vf_vf_vf(u, s), t, t); + rx = vsel_vf_vo_vf_vf(visnegzero_vo_vf(d), vcast_vf_f(-0.0f), rx); + + u = vcast_vf_f(-2.71811842367242206819355e-07f); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(2.47990446951007470488548e-05f)); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(-0.00138888787478208541870117f)); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(0.0416666641831398010253906f)); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(-0.5)); + + ry = vmla_vf_vf_vf_vf(s, u, vcast_vf_f(1)); + + o = veq_vo_vi2_vi2(vand_vi2_vi2_vi2(q, vcast_vi2_i(1)), vcast_vi2_i(0)); + r = vf2setxy_vf2_vf_vf(vsel_vf_vo_vf_vf(o, rx, ry), vsel_vf_vo_vf_vf(o, ry, rx)); + + o = veq_vo_vi2_vi2(vand_vi2_vi2_vi2(q, vcast_vi2_i(2)), vcast_vi2_i(2)); + r = vf2setx_vf2_vf2_vf(r, vreinterpret_vf_vm(vxor_vm_vm_vm(vand_vm_vo32_vm(o, vreinterpret_vm_vf(vcast_vf_f(-0.0))), vreinterpret_vm_vf(vf2getx_vf_vf2(r))))); + + o = veq_vo_vi2_vi2(vand_vi2_vi2_vi2(vadd_vi2_vi2_vi2(q, vcast_vi2_i(1)), vcast_vi2_i(2)), vcast_vi2_i(2)); + r = vf2sety_vf2_vf2_vf(r, vreinterpret_vf_vm(vxor_vm_vm_vm(vand_vm_vo32_vm(o, vreinterpret_vm_vf(vcast_vf_f(-0.0))), vreinterpret_vm_vf(vf2gety_vf_vf2(r))))); + + return r; + +#else // #if !defined(DETERMINISTIC) + + vint2 q; + vopmask o; + vfloat u, s, t, rx, ry; + vfloat2 r; + + q = vrint_vi2_vf(vmul_vf_vf_vf(d, vcast_vf_f((float)M_2_PI))); + u = vcast_vf_vi2(q); + s = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_A2f*0.5f), d); + s = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_B2f*0.5f), s); + s = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_C2f*0.5f), s); + vopmask g = vlt_vo_vf_vf(vabs_vf_vf(d), vcast_vf_f(TRIGRANGEMAX2f)); + + if (!LIKELY(vtestallones_i_vo32(g))) { + vint2 q2 = vrint_vi2_vf(vmul_vf_vf_vf(d, vcast_vf_f((float)M_2_PI))); + u = vcast_vf_vi2(q2); + t = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_Af*0.5f), d); + t = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_Bf*0.5f), t); + t = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_Cf*0.5f), t); + t = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_Df*0.5f), t); + + q = vsel_vi2_vo_vi2_vi2(g, q, q2); + s = vsel_vf_vo_vf_vf(g, s, t); + g = vlt_vo_vf_vf(vabs_vf_vf(d), vcast_vf_f(TRIGRANGEMAXf)); + + if (!LIKELY(vtestallones_i_vo32(g))) { + dfi_t dfi = rempif(d); + t = vadd_vf_vf_vf(vf2getx_vf_vf2(dfigetdf_vf2_dfi(dfi)), vf2gety_vf_vf2(dfigetdf_vf2_dfi(dfi))); + t = vreinterpret_vf_vm(vor_vm_vo32_vm(vor_vo_vo_vo(visinf_vo_vf(d), visnan_vo_vf(d)), vreinterpret_vm_vf(t))); + + q = vsel_vi2_vo_vi2_vi2(g, q, dfigeti_vi2_dfi(dfi)); + s = vsel_vf_vo_vf_vf(g, s, t); + } + } + + t = s; + + s = vmul_vf_vf_vf(s, s); + + u = vcast_vf_f(-0.000195169282960705459117889f); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(0.00833215750753879547119141f)); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(-0.166666537523269653320312f)); + + rx = vmla_vf_vf_vf_vf(vmul_vf_vf_vf(u, s), t, t); + rx = vsel_vf_vo_vf_vf(visnegzero_vo_vf(d), vcast_vf_f(-0.0f), rx); + + u = vcast_vf_f(-2.71811842367242206819355e-07f); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(2.47990446951007470488548e-05f)); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(-0.00138888787478208541870117f)); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(0.0416666641831398010253906f)); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(-0.5)); + + ry = vmla_vf_vf_vf_vf(s, u, vcast_vf_f(1)); + + o = veq_vo_vi2_vi2(vand_vi2_vi2_vi2(q, vcast_vi2_i(1)), vcast_vi2_i(0)); + r = vf2setxy_vf2_vf_vf(vsel_vf_vo_vf_vf(o, rx, ry), vsel_vf_vo_vf_vf(o, ry, rx)); + + o = veq_vo_vi2_vi2(vand_vi2_vi2_vi2(q, vcast_vi2_i(2)), vcast_vi2_i(2)); + r = vf2setx_vf2_vf2_vf(r, vreinterpret_vf_vm(vxor_vm_vm_vm(vand_vm_vo32_vm(o, vreinterpret_vm_vf(vcast_vf_f(-0.0))), vreinterpret_vm_vf(vf2getx_vf_vf2(r))))); + + o = veq_vo_vi2_vi2(vand_vi2_vi2_vi2(vadd_vi2_vi2_vi2(q, vcast_vi2_i(1)), vcast_vi2_i(2)), vcast_vi2_i(2)); + r = vf2sety_vf2_vf2_vf(r, vreinterpret_vf_vm(vxor_vm_vm_vm(vand_vm_vo32_vm(o, vreinterpret_vm_vf(vcast_vf_f(-0.0))), vreinterpret_vm_vf(vf2gety_vf_vf2(r))))); + + return r; +#endif // #if !defined(DETERMINISTIC) +} + +TYPE2_FUNCATR VECTOR_CC vfloat2 XSINCOSF_U1(vfloat d) { +#if !defined(DETERMINISTIC) + vint2 q; + vopmask o; + vfloat u, v, rx, ry; + vfloat2 r, s, t, x; + + if (LIKELY(vtestallones_i_vo32(vlt_vo_vf_vf(vabs_vf_vf(d), vcast_vf_f(TRIGRANGEMAX2f))))) { + u = vrint_vf_vf(vmul_vf_vf_vf(d, vcast_vf_f(2 * M_1_PI))); + q = vrint_vi2_vf(u); + v = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_A2f*0.5f), d); + s = dfadd2_vf2_vf_vf(v, vmul_vf_vf_vf(u, vcast_vf_f(-PI_B2f*0.5f))); + s = dfadd_vf2_vf2_vf(s, vmul_vf_vf_vf(u, vcast_vf_f(-PI_C2f*0.5f))); + } else { + dfi_t dfi = rempif(d); + q = dfigeti_vi2_dfi(dfi); + s = dfigetdf_vf2_dfi(dfi); + o = vor_vo_vo_vo(visinf_vo_vf(d), visnan_vo_vf(d)); + s = vf2setx_vf2_vf2_vf(s, vreinterpret_vf_vm(vor_vm_vo32_vm(o, vreinterpret_vm_vf(vf2getx_vf_vf2(s))))); + } + + t = s; + + s = vf2setx_vf2_vf2_vf(s, dfsqu_vf_vf2(s)); + + u = vcast_vf_f(-0.000195169282960705459117889f); + u = vmla_vf_vf_vf_vf(u, vf2getx_vf_vf2(s), vcast_vf_f(0.00833215750753879547119141f)); + u = vmla_vf_vf_vf_vf(u, vf2getx_vf_vf2(s), vcast_vf_f(-0.166666537523269653320312f)); + + u = vmul_vf_vf_vf(u, vmul_vf_vf_vf(vf2getx_vf_vf2(s), vf2getx_vf_vf2(t))); + + x = dfadd_vf2_vf2_vf(t, u); + rx = vadd_vf_vf_vf(vf2getx_vf_vf2(x), vf2gety_vf_vf2(x)); + + rx = vsel_vf_vo_vf_vf(visnegzero_vo_vf(d), vcast_vf_f(-0.0f), rx); + + u = vcast_vf_f(-2.71811842367242206819355e-07f); + u = vmla_vf_vf_vf_vf(u, vf2getx_vf_vf2(s), vcast_vf_f(2.47990446951007470488548e-05f)); + u = vmla_vf_vf_vf_vf(u, vf2getx_vf_vf2(s), vcast_vf_f(-0.00138888787478208541870117f)); + u = vmla_vf_vf_vf_vf(u, vf2getx_vf_vf2(s), vcast_vf_f(0.0416666641831398010253906f)); + u = vmla_vf_vf_vf_vf(u, vf2getx_vf_vf2(s), vcast_vf_f(-0.5)); + + x = dfadd_vf2_vf_vf2(vcast_vf_f(1), dfmul_vf2_vf_vf(vf2getx_vf_vf2(s), u)); + ry = vadd_vf_vf_vf(vf2getx_vf_vf2(x), vf2gety_vf_vf2(x)); + + o = veq_vo_vi2_vi2(vand_vi2_vi2_vi2(q, vcast_vi2_i(1)), vcast_vi2_i(0)); + r = vf2setxy_vf2_vf_vf(vsel_vf_vo_vf_vf(o, rx, ry), vsel_vf_vo_vf_vf(o, ry, rx)); + + o = veq_vo_vi2_vi2(vand_vi2_vi2_vi2(q, vcast_vi2_i(2)), vcast_vi2_i(2)); + r = vf2setx_vf2_vf2_vf(r, vreinterpret_vf_vm(vxor_vm_vm_vm(vand_vm_vo32_vm(o, vreinterpret_vm_vf(vcast_vf_f(-0.0))), vreinterpret_vm_vf(vf2getx_vf_vf2(r))))); + + o = veq_vo_vi2_vi2(vand_vi2_vi2_vi2(vadd_vi2_vi2_vi2(q, vcast_vi2_i(1)), vcast_vi2_i(2)), vcast_vi2_i(2)); + r = vf2sety_vf2_vf2_vf(r, vreinterpret_vf_vm(vxor_vm_vm_vm(vand_vm_vo32_vm(o, vreinterpret_vm_vf(vcast_vf_f(-0.0))), vreinterpret_vm_vf(vf2gety_vf_vf2(r))))); + + return r; + +#else // #if !defined(DETERMINISTIC) + + vint2 q; + vopmask o; + vfloat u, v, rx, ry; + vfloat2 r, s, t, x; + + u = vrint_vf_vf(vmul_vf_vf_vf(d, vcast_vf_f(2 * M_1_PI))); + q = vrint_vi2_vf(u); + v = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_A2f*0.5f), d); + s = dfadd2_vf2_vf_vf(v, vmul_vf_vf_vf(u, vcast_vf_f(-PI_B2f*0.5f))); + s = dfadd_vf2_vf2_vf(s, vmul_vf_vf_vf(u, vcast_vf_f(-PI_C2f*0.5f))); + vopmask g = vlt_vo_vf_vf(vabs_vf_vf(d), vcast_vf_f(TRIGRANGEMAX2f)); + + if (!LIKELY(vtestallones_i_vo32(g))) { + dfi_t dfi = rempif(d); + t = dfigetdf_vf2_dfi(dfi); + o = vor_vo_vo_vo(visinf_vo_vf(d), visnan_vo_vf(d)); + t = vf2setx_vf2_vf2_vf(t, vreinterpret_vf_vm(vor_vm_vo32_vm(o, vreinterpret_vm_vf(vf2getx_vf_vf2(t))))); + q = vsel_vi2_vo_vi2_vi2(g, q, dfigeti_vi2_dfi(dfi)); + s = vsel_vf2_vo_vf2_vf2(g, s, t); + } + + t = s; + + s = vf2setx_vf2_vf2_vf(s, dfsqu_vf_vf2(s)); + + u = vcast_vf_f(-0.000195169282960705459117889f); + u = vmla_vf_vf_vf_vf(u, vf2getx_vf_vf2(s), vcast_vf_f(0.00833215750753879547119141f)); + u = vmla_vf_vf_vf_vf(u, vf2getx_vf_vf2(s), vcast_vf_f(-0.166666537523269653320312f)); + + u = vmul_vf_vf_vf(u, vmul_vf_vf_vf(vf2getx_vf_vf2(s), vf2getx_vf_vf2(t))); + + x = dfadd_vf2_vf2_vf(t, u); + rx = vadd_vf_vf_vf(vf2getx_vf_vf2(x), vf2gety_vf_vf2(x)); + + rx = vsel_vf_vo_vf_vf(visnegzero_vo_vf(d), vcast_vf_f(-0.0f), rx); + + u = vcast_vf_f(-2.71811842367242206819355e-07f); + u = vmla_vf_vf_vf_vf(u, vf2getx_vf_vf2(s), vcast_vf_f(2.47990446951007470488548e-05f)); + u = vmla_vf_vf_vf_vf(u, vf2getx_vf_vf2(s), vcast_vf_f(-0.00138888787478208541870117f)); + u = vmla_vf_vf_vf_vf(u, vf2getx_vf_vf2(s), vcast_vf_f(0.0416666641831398010253906f)); + u = vmla_vf_vf_vf_vf(u, vf2getx_vf_vf2(s), vcast_vf_f(-0.5)); + + x = dfadd_vf2_vf_vf2(vcast_vf_f(1), dfmul_vf2_vf_vf(vf2getx_vf_vf2(s), u)); + ry = vadd_vf_vf_vf(vf2getx_vf_vf2(x), vf2gety_vf_vf2(x)); + + o = veq_vo_vi2_vi2(vand_vi2_vi2_vi2(q, vcast_vi2_i(1)), vcast_vi2_i(0)); + r = vf2setxy_vf2_vf_vf(vsel_vf_vo_vf_vf(o, rx, ry), vsel_vf_vo_vf_vf(o, ry, rx)); + + o = veq_vo_vi2_vi2(vand_vi2_vi2_vi2(q, vcast_vi2_i(2)), vcast_vi2_i(2)); + r = vf2setx_vf2_vf2_vf(r, vreinterpret_vf_vm(vxor_vm_vm_vm(vand_vm_vo32_vm(o, vreinterpret_vm_vf(vcast_vf_f(-0.0))), vreinterpret_vm_vf(vf2getx_vf_vf2(r))))); + + o = veq_vo_vi2_vi2(vand_vi2_vi2_vi2(vadd_vi2_vi2_vi2(q, vcast_vi2_i(1)), vcast_vi2_i(2)), vcast_vi2_i(2)); + r = vf2sety_vf2_vf2_vf(r, vreinterpret_vf_vm(vxor_vm_vm_vm(vand_vm_vo32_vm(o, vreinterpret_vm_vf(vcast_vf_f(-0.0))), vreinterpret_vm_vf(vf2gety_vf_vf2(r))))); + + return r; +#endif // #if !defined(DETERMINISTIC) +} + +#if !defined(DETERMINISTIC) +TYPE2_FUNCATR VECTOR_CC vfloat2 XSINCOSPIF_U05(vfloat d) { + vopmask o; + vfloat u, s, t, rx, ry; + vfloat2 r, x, s2; + + u = vmul_vf_vf_vf(d, vcast_vf_f(4)); + vint2 q = vtruncate_vi2_vf(u); + q = vand_vi2_vi2_vi2(vadd_vi2_vi2_vi2(q, vxor_vi2_vi2_vi2(vsrl_vi2_vi2_i(q, 31), vcast_vi2_i(1))), vcast_vi2_i(~1)); + s = vsub_vf_vf_vf(u, vcast_vf_vi2(q)); + + t = s; + s = vmul_vf_vf_vf(s, s); + s2 = dfmul_vf2_vf_vf(t, t); + + // + + u = vcast_vf_f(+0.3093842054e-6); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(-0.3657307388e-4)); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(+0.2490393585e-2)); + x = dfadd2_vf2_vf_vf2(vmul_vf_vf_vf(u, s), vcast_vf2_f_f(-0.080745510756969451904, -1.3373665339076936258e-09)); + x = dfadd2_vf2_vf2_vf2(dfmul_vf2_vf2_vf2(s2, x), vcast_vf2_f_f(0.78539818525314331055, -2.1857338617566484855e-08)); + + x = dfmul_vf2_vf2_vf(x, t); + rx = vadd_vf_vf_vf(vf2getx_vf_vf2(x), vf2gety_vf_vf2(x)); + + rx = vsel_vf_vo_vf_vf(visnegzero_vo_vf(d), vcast_vf_f(-0.0f), rx); + + // + + u = vcast_vf_f(-0.2430611801e-7); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(+0.3590577080e-5)); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(-0.3259917721e-3)); + x = dfadd2_vf2_vf_vf2(vmul_vf_vf_vf(u, s), vcast_vf2_f_f(0.015854343771934509277, 4.4940051354032242811e-10)); + x = dfadd2_vf2_vf2_vf2(dfmul_vf2_vf2_vf2(s2, x), vcast_vf2_f_f(-0.30842512845993041992, -9.0728339030733922277e-09)); + + x = dfadd2_vf2_vf2_vf(dfmul_vf2_vf2_vf2(x, s2), vcast_vf_f(1)); + ry = vadd_vf_vf_vf(vf2getx_vf_vf2(x), vf2gety_vf_vf2(x)); + + // + + o = veq_vo_vi2_vi2(vand_vi2_vi2_vi2(q, vcast_vi2_i(2)), vcast_vi2_i(0)); + r = vf2setxy_vf2_vf_vf(vsel_vf_vo_vf_vf(o, rx, ry), vsel_vf_vo_vf_vf(o, ry, rx)); + + o = veq_vo_vi2_vi2(vand_vi2_vi2_vi2(q, vcast_vi2_i(4)), vcast_vi2_i(4)); + r = vf2setx_vf2_vf2_vf(r, vreinterpret_vf_vm(vxor_vm_vm_vm(vand_vm_vo32_vm(o, vreinterpret_vm_vf(vcast_vf_f(-0.0))), vreinterpret_vm_vf(vf2getx_vf_vf2(r))))); + + o = veq_vo_vi2_vi2(vand_vi2_vi2_vi2(vadd_vi2_vi2_vi2(q, vcast_vi2_i(2)), vcast_vi2_i(4)), vcast_vi2_i(4)); + r = vf2sety_vf2_vf2_vf(r, vreinterpret_vf_vm(vxor_vm_vm_vm(vand_vm_vo32_vm(o, vreinterpret_vm_vf(vcast_vf_f(-0.0))), vreinterpret_vm_vf(vf2gety_vf_vf2(r))))); + + o = vgt_vo_vf_vf(vabs_vf_vf(d), vcast_vf_f(1e+7f)); + r = vf2setx_vf2_vf2_vf(r, vreinterpret_vf_vm(vandnot_vm_vo32_vm(o, vreinterpret_vm_vf(vf2getx_vf_vf2(r))))); + r = vf2sety_vf2_vf2_vf(r, vreinterpret_vf_vm(vandnot_vm_vo32_vm(o, vreinterpret_vm_vf(vf2gety_vf_vf2(r))))); + + o = visinf_vo_vf(d); + r = vf2setx_vf2_vf2_vf(r, vreinterpret_vf_vm(vor_vm_vo32_vm(o, vreinterpret_vm_vf(vf2getx_vf_vf2(r))))); + r = vf2sety_vf2_vf2_vf(r, vreinterpret_vf_vm(vor_vm_vo32_vm(o, vreinterpret_vm_vf(vf2gety_vf_vf2(r))))); + + return r; +} + +TYPE2_FUNCATR VECTOR_CC vfloat2 XSINCOSPIF_U35(vfloat d) { + vopmask o; + vfloat u, s, t, rx, ry; + vfloat2 r; + + u = vmul_vf_vf_vf(d, vcast_vf_f(4)); + vint2 q = vtruncate_vi2_vf(u); + q = vand_vi2_vi2_vi2(vadd_vi2_vi2_vi2(q, vxor_vi2_vi2_vi2(vsrl_vi2_vi2_i(q, 31), vcast_vi2_i(1))), vcast_vi2_i(~1)); + s = vsub_vf_vf_vf(u, vcast_vf_vi2(q)); + + t = s; + s = vmul_vf_vf_vf(s, s); + + // + + u = vcast_vf_f(-0.3600925265e-4); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(+0.2490088111e-2)); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(-0.8074551076e-1)); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(+0.7853981853e+0)); + + rx = vmul_vf_vf_vf(u, t); + + // + + u = vcast_vf_f(+0.3539815225e-5); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(-0.3259574005e-3)); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(+0.1585431583e-1)); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(-0.3084251285e+0)); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(1)); + + ry = u; + + // + + o = veq_vo_vi2_vi2(vand_vi2_vi2_vi2(q, vcast_vi2_i(2)), vcast_vi2_i(0)); + r = vf2setxy_vf2_vf_vf(vsel_vf_vo_vf_vf(o, rx, ry), vsel_vf_vo_vf_vf(o, ry, rx)); + + o = veq_vo_vi2_vi2(vand_vi2_vi2_vi2(q, vcast_vi2_i(4)), vcast_vi2_i(4)); + r = vf2setx_vf2_vf2_vf(r, vreinterpret_vf_vm(vxor_vm_vm_vm(vand_vm_vo32_vm(o, vreinterpret_vm_vf(vcast_vf_f(-0.0))), vreinterpret_vm_vf(vf2getx_vf_vf2(r))))); + + o = veq_vo_vi2_vi2(vand_vi2_vi2_vi2(vadd_vi2_vi2_vi2(q, vcast_vi2_i(2)), vcast_vi2_i(4)), vcast_vi2_i(4)); + r = vf2sety_vf2_vf2_vf(r, vreinterpret_vf_vm(vxor_vm_vm_vm(vand_vm_vo32_vm(o, vreinterpret_vm_vf(vcast_vf_f(-0.0))), vreinterpret_vm_vf(vf2gety_vf_vf2(r))))); + + o = vgt_vo_vf_vf(vabs_vf_vf(d), vcast_vf_f(1e+7f)); + r = vf2setx_vf2_vf2_vf(r, vreinterpret_vf_vm(vandnot_vm_vo32_vm(o, vreinterpret_vm_vf(vf2getx_vf_vf2(r))))); + r = vf2sety_vf2_vf2_vf(r, vreinterpret_vf_vm(vandnot_vm_vo32_vm(o, vreinterpret_vm_vf(vf2gety_vf_vf2(r))))); + + o = visinf_vo_vf(d); + r = vf2setx_vf2_vf2_vf(r, vreinterpret_vf_vm(vor_vm_vo32_vm(o, vreinterpret_vm_vf(vf2getx_vf_vf2(r))))); + r = vf2sety_vf2_vf2_vf(r, vreinterpret_vf_vm(vor_vm_vo32_vm(o, vreinterpret_vm_vf(vf2gety_vf_vf2(r))))); + + return r; +} + +TYPE6_FUNCATR VECTOR_CC vfloat2 XMODFF(vfloat x) { + vfloat fr = vsub_vf_vf_vf(x, vcast_vf_vi2(vtruncate_vi2_vf(x))); + fr = vsel_vf_vo_vf_vf(vgt_vo_vf_vf(vabs_vf_vf(x), vcast_vf_f(INT64_C(1) << 23)), vcast_vf_f(0), fr); + + vfloat2 ret; + + ret = vf2setxy_vf2_vf_vf(vcopysign_vf_vf_vf(fr, x), vcopysign_vf_vf_vf(vsub_vf_vf_vf(x, fr), x)); + + return ret; +} + +#ifdef ENABLE_GNUABI +EXPORT VECTOR_CC void xsincosf(vfloat a, float *ps, float *pc) { + vfloat2 r = sincosfk(a); + vstoreu_v_p_vf(ps, vf2getx_vf_vf2(r)); + vstoreu_v_p_vf(pc, vf2gety_vf_vf2(r)); +} + +EXPORT VECTOR_CC void xsincosf_u1(vfloat a, float *ps, float *pc) { + vfloat2 r = sincosfk_u1(a); + vstoreu_v_p_vf(ps, vf2getx_vf_vf2(r)); + vstoreu_v_p_vf(pc, vf2gety_vf_vf2(r)); +} + +EXPORT VECTOR_CC void xsincospif_u05(vfloat a, float *ps, float *pc) { + vfloat2 r = sincospifk_u05(a); + vstoreu_v_p_vf(ps, vf2getx_vf_vf2(r)); + vstoreu_v_p_vf(pc, vf2gety_vf_vf2(r)); +} + +EXPORT VECTOR_CC void xsincospif_u35(vfloat a, float *ps, float *pc) { + vfloat2 r = sincospifk_u35(a); + vstoreu_v_p_vf(ps, vf2getx_vf_vf2(r)); + vstoreu_v_p_vf(pc, vf2gety_vf_vf2(r)); +} + +EXPORT CONST VECTOR_CC vfloat xmodff(vfloat a, float *iptr) { + vfloat2 r = modffk(a); + vstoreu_v_p_vf(iptr, vf2gety_vf_vf2(r)); + return vf2getx_vf_vf2(r); +} +#endif // #ifdef ENABLE_GNUABI +#endif // #if !defined(DETERMINISTIC) + +EXPORT CONST VECTOR_CC vfloat xtanf_u1(vfloat d) { +#if !defined(DETERMINISTIC) + vint2 q; + vfloat u, v; + vfloat2 s, t, x; + vopmask o; + + if (LIKELY(vtestallones_i_vo32(vlt_vo_vf_vf(vabs_vf_vf(d), vcast_vf_f(TRIGRANGEMAX2f))))) { + u = vrint_vf_vf(vmul_vf_vf_vf(d, vcast_vf_f(2 * M_1_PI))); + q = vrint_vi2_vf(u); + v = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_A2f*0.5f), d); + s = dfadd2_vf2_vf_vf(v, vmul_vf_vf_vf(u, vcast_vf_f(-PI_B2f*0.5f))); + s = dfadd_vf2_vf2_vf(s, vmul_vf_vf_vf(u, vcast_vf_f(-PI_C2f*0.5f))); + } else { + dfi_t dfi = rempif(d); + q = dfigeti_vi2_dfi(dfi); + s = dfigetdf_vf2_dfi(dfi); + o = vor_vo_vo_vo(visinf_vo_vf(d), visnan_vo_vf(d)); + s = vf2setx_vf2_vf2_vf(s, vreinterpret_vf_vm(vor_vm_vo32_vm(o, vreinterpret_vm_vf(vf2getx_vf_vf2(s))))); + s = vf2sety_vf2_vf2_vf(s, vreinterpret_vf_vm(vor_vm_vo32_vm(o, vreinterpret_vm_vf(vf2gety_vf_vf2(s))))); + } + + o = veq_vo_vi2_vi2(vand_vi2_vi2_vi2(q, vcast_vi2_i(1)), vcast_vi2_i(1)); + vmask n = vand_vm_vo32_vm(o, vreinterpret_vm_vf(vcast_vf_f(-0.0))); +#if !defined(_MSC_VER) + s = vf2setx_vf2_vf2_vf(s, vreinterpret_vf_vm(vxor_vm_vm_vm(vreinterpret_vm_vf(vf2getx_vf_vf2(s)), n))); + s = vf2sety_vf2_vf2_vf(s, vreinterpret_vf_vm(vxor_vm_vm_vm(vreinterpret_vm_vf(vf2gety_vf_vf2(s)), n))); +#else + s.x = vreinterpret_vf_vm(vxor_vm_vm_vm(vreinterpret_vm_vf(s.x), n)); + s.y = vreinterpret_vf_vm(vxor_vm_vm_vm(vreinterpret_vm_vf(s.y), n)); +#endif + + t = s; + s = dfsqu_vf2_vf2(s); + s = dfnormalize_vf2_vf2(s); + + u = vcast_vf_f(0.00446636462584137916564941f); + u = vmla_vf_vf_vf_vf(u, vf2getx_vf_vf2(s), vcast_vf_f(-8.3920182078145444393158e-05f)); + u = vmla_vf_vf_vf_vf(u, vf2getx_vf_vf2(s), vcast_vf_f(0.0109639242291450500488281f)); + u = vmla_vf_vf_vf_vf(u, vf2getx_vf_vf2(s), vcast_vf_f(0.0212360303848981857299805f)); + u = vmla_vf_vf_vf_vf(u, vf2getx_vf_vf2(s), vcast_vf_f(0.0540687143802642822265625f)); + + x = dfadd_vf2_vf_vf(vcast_vf_f(0.133325666189193725585938f), vmul_vf_vf_vf(u, vf2getx_vf_vf2(s))); + x = dfadd_vf2_vf_vf2(vcast_vf_f(1), dfmul_vf2_vf2_vf2(dfadd_vf2_vf_vf2(vcast_vf_f(0.33333361148834228515625f), dfmul_vf2_vf2_vf2(s, x)), s)); + x = dfmul_vf2_vf2_vf2(t, x); + + x = vsel_vf2_vo_vf2_vf2(o, dfrec_vf2_vf2(x), x); + + u = vadd_vf_vf_vf(vf2getx_vf_vf2(x), vf2gety_vf_vf2(x)); + + u = vsel_vf_vo_vf_vf(visnegzero_vo_vf(d), d, u); + + return u; + +#else // #if !defined(DETERMINISTIC) + + vint2 q; + vfloat u, v; + vfloat2 s, t, x; + vopmask o; + + u = vrint_vf_vf(vmul_vf_vf_vf(d, vcast_vf_f(2 * M_1_PI))); + q = vrint_vi2_vf(u); + v = vmla_vf_vf_vf_vf(u, vcast_vf_f(-PI_A2f*0.5f), d); + s = dfadd2_vf2_vf_vf(v, vmul_vf_vf_vf(u, vcast_vf_f(-PI_B2f*0.5f))); + s = dfadd_vf2_vf2_vf(s, vmul_vf_vf_vf(u, vcast_vf_f(-PI_C2f*0.5f))); + vopmask g = vlt_vo_vf_vf(vabs_vf_vf(d), vcast_vf_f(TRIGRANGEMAX2f)); + + if (!LIKELY(vtestallones_i_vo32(g))) { + dfi_t dfi = rempif(d); + t = dfigetdf_vf2_dfi(dfi); + o = vor_vo_vo_vo(visinf_vo_vf(d), visnan_vo_vf(d)); + t = vf2setx_vf2_vf2_vf(t, vreinterpret_vf_vm(vor_vm_vo32_vm(o, vreinterpret_vm_vf(vf2getx_vf_vf2(t))))); + t = vf2sety_vf2_vf2_vf(t, vreinterpret_vf_vm(vor_vm_vo32_vm(o, vreinterpret_vm_vf(vf2gety_vf_vf2(t))))); + q = vsel_vi2_vo_vi2_vi2(g, q, dfigeti_vi2_dfi(dfi)); + s = vsel_vf2_vo_vf2_vf2(g, s, t); + } + + o = veq_vo_vi2_vi2(vand_vi2_vi2_vi2(q, vcast_vi2_i(1)), vcast_vi2_i(1)); + vmask n = vand_vm_vo32_vm(o, vreinterpret_vm_vf(vcast_vf_f(-0.0))); + s = vf2setx_vf2_vf2_vf(s, vreinterpret_vf_vm(vxor_vm_vm_vm(vreinterpret_vm_vf(vf2getx_vf_vf2(s)), n))); + s = vf2sety_vf2_vf2_vf(s, vreinterpret_vf_vm(vxor_vm_vm_vm(vreinterpret_vm_vf(vf2gety_vf_vf2(s)), n))); + + t = s; + s = dfsqu_vf2_vf2(s); + s = dfnormalize_vf2_vf2(s); + + u = vcast_vf_f(0.00446636462584137916564941f); + u = vmla_vf_vf_vf_vf(u, vf2getx_vf_vf2(s), vcast_vf_f(-8.3920182078145444393158e-05f)); + u = vmla_vf_vf_vf_vf(u, vf2getx_vf_vf2(s), vcast_vf_f(0.0109639242291450500488281f)); + u = vmla_vf_vf_vf_vf(u, vf2getx_vf_vf2(s), vcast_vf_f(0.0212360303848981857299805f)); + u = vmla_vf_vf_vf_vf(u, vf2getx_vf_vf2(s), vcast_vf_f(0.0540687143802642822265625f)); + + x = dfadd_vf2_vf_vf(vcast_vf_f(0.133325666189193725585938f), vmul_vf_vf_vf(u, vf2getx_vf_vf2(s))); + x = dfadd_vf2_vf_vf2(vcast_vf_f(1), dfmul_vf2_vf2_vf2(dfadd_vf2_vf_vf2(vcast_vf_f(0.33333361148834228515625f), dfmul_vf2_vf2_vf2(s, x)), s)); + x = dfmul_vf2_vf2_vf2(t, x); + + x = vsel_vf2_vo_vf2_vf2(o, dfrec_vf2_vf2(x), x); + + u = vadd_vf_vf_vf(vf2getx_vf_vf2(x), vf2gety_vf_vf2(x)); + + u = vsel_vf_vo_vf_vf(visnegzero_vo_vf(d), d, u); + + return u; +#endif // #if !defined(DETERMINISTIC) +} + +#if !defined(DETERMINISTIC) +EXPORT CONST VECTOR_CC vfloat xatanf(vfloat d) { + vfloat s, t, u; + vint2 q; + + q = vsel_vi2_vf_vi2(d, vcast_vi2_i(2)); + s = vabs_vf_vf(d); + + q = vsel_vi2_vf_vf_vi2_vi2(vcast_vf_f(1.0f), s, vadd_vi2_vi2_vi2(q, vcast_vi2_i(1)), q); + s = vsel_vf_vo_vf_vf(vlt_vo_vf_vf(vcast_vf_f(1.0f), s), vrec_vf_vf(s), s); + + t = vmul_vf_vf_vf(s, s); + + vfloat t2 = vmul_vf_vf_vf(t, t), t4 = vmul_vf_vf_vf(t2, t2); + u = POLY8(t, t2, t4, + 0.00282363896258175373077393f, + -0.0159569028764963150024414f, + 0.0425049886107444763183594f, + -0.0748900920152664184570312f, + 0.106347933411598205566406f, + -0.142027363181114196777344f, + 0.199926957488059997558594f, + -0.333331018686294555664062f); + + t = vmla_vf_vf_vf_vf(s, vmul_vf_vf_vf(t, u), s); + + t = vsel_vf_vo_vf_vf(veq_vo_vi2_vi2(vand_vi2_vi2_vi2(q, vcast_vi2_i(1)), vcast_vi2_i(1)), vsub_vf_vf_vf(vcast_vf_f((float)(M_PI/2)), t), t); + + t = vreinterpret_vf_vm(vxor_vm_vm_vm(vand_vm_vo32_vm(veq_vo_vi2_vi2(vand_vi2_vi2_vi2(q, vcast_vi2_i(2)), vcast_vi2_i(2)), vreinterpret_vm_vf(vcast_vf_f(-0.0f))), vreinterpret_vm_vf(t))); + +#if defined(ENABLE_NEON32) || defined(ENABLE_NEON32VFPV4) + t = vsel_vf_vo_vf_vf(visinf_vo_vf(d), vmulsign_vf_vf_vf(vcast_vf_f(1.5874010519681994747517056f), d), t); +#endif + + return t; +} +#endif // #if !defined(DETERMINISTIC) + +static INLINE CONST VECTOR_CC vfloat atan2kf(vfloat y, vfloat x) { + vfloat s, t, u; + vint2 q; + vopmask p; + + q = vsel_vi2_vf_vi2(x, vcast_vi2_i(-2)); + x = vabs_vf_vf(x); + + q = vsel_vi2_vf_vf_vi2_vi2(x, y, vadd_vi2_vi2_vi2(q, vcast_vi2_i(1)), q); + p = vlt_vo_vf_vf(x, y); + s = vsel_vf_vo_vf_vf(p, vneg_vf_vf(x), y); + t = vmax_vf_vf_vf(x, y); + + s = vdiv_vf_vf_vf(s, t); + t = vmul_vf_vf_vf(s, s); + + vfloat t2 = vmul_vf_vf_vf(t, t), t4 = vmul_vf_vf_vf(t2, t2); + u = POLY8(t, t2, t4, + 0.00282363896258175373077393f, + -0.0159569028764963150024414f, + 0.0425049886107444763183594f, + -0.0748900920152664184570312f, + 0.106347933411598205566406f, + -0.142027363181114196777344f, + 0.199926957488059997558594f, + -0.333331018686294555664062f); + + t = vmla_vf_vf_vf_vf(s, vmul_vf_vf_vf(t, u), s); + t = vmla_vf_vf_vf_vf(vcast_vf_vi2(q), vcast_vf_f((float)(M_PI/2)), t); + + return t; +} + +static INLINE CONST VECTOR_CC vfloat visinf2_vf_vf_vf(vfloat d, vfloat m) { + return vreinterpret_vf_vm(vand_vm_vo32_vm(visinf_vo_vf(d), vor_vm_vm_vm(vsignbit_vm_vf(d), vreinterpret_vm_vf(m)))); +} + +#if !defined(DETERMINISTIC) +EXPORT CONST VECTOR_CC vfloat xatan2f(vfloat y, vfloat x) { + vfloat r = atan2kf(vabs_vf_vf(y), x); + + r = vmulsign_vf_vf_vf(r, x); + r = vsel_vf_vo_vf_vf(vor_vo_vo_vo(visinf_vo_vf(x), veq_vo_vf_vf(x, vcast_vf_f(0.0f))), vsub_vf_vf_vf(vcast_vf_f((float)(M_PI/2)), visinf2_vf_vf_vf(x, vmulsign_vf_vf_vf(vcast_vf_f((float)(M_PI/2)), x))), r); + r = vsel_vf_vo_vf_vf(visinf_vo_vf(y), vsub_vf_vf_vf(vcast_vf_f((float)(M_PI/2)), visinf2_vf_vf_vf(x, vmulsign_vf_vf_vf(vcast_vf_f((float)(M_PI/4)), x))), r); + + r = vsel_vf_vo_vf_vf(veq_vo_vf_vf(y, vcast_vf_f(0.0f)), vreinterpret_vf_vm(vand_vm_vo32_vm(vsignbit_vo_vf(x), vreinterpret_vm_vf(vcast_vf_f((float)M_PI)))), r); + + r = vreinterpret_vf_vm(vor_vm_vo32_vm(vor_vo_vo_vo(visnan_vo_vf(x), visnan_vo_vf(y)), vreinterpret_vm_vf(vmulsign_vf_vf_vf(r, y)))); + return r; +} + +EXPORT CONST VECTOR_CC vfloat xasinf(vfloat d) { + vopmask o = vlt_vo_vf_vf(vabs_vf_vf(d), vcast_vf_f(0.5f)); + vfloat x2 = vsel_vf_vo_vf_vf(o, vmul_vf_vf_vf(d, d), vmul_vf_vf_vf(vsub_vf_vf_vf(vcast_vf_f(1), vabs_vf_vf(d)), vcast_vf_f(0.5f))); + vfloat x = vsel_vf_vo_vf_vf(o, vabs_vf_vf(d), vsqrt_vf_vf(x2)), u; + + u = vcast_vf_f(+0.4197454825e-1); + u = vmla_vf_vf_vf_vf(u, x2, vcast_vf_f(+0.2424046025e-1)); + u = vmla_vf_vf_vf_vf(u, x2, vcast_vf_f(+0.4547423869e-1)); + u = vmla_vf_vf_vf_vf(u, x2, vcast_vf_f(+0.7495029271e-1)); + u = vmla_vf_vf_vf_vf(u, x2, vcast_vf_f(+0.1666677296e+0)); + u = vmla_vf_vf_vf_vf(u, vmul_vf_vf_vf(x, x2), x); + + vfloat r = vsel_vf_vo_vf_vf(o, u, vmla_vf_vf_vf_vf(u, vcast_vf_f(-2), vcast_vf_f(M_PIf/2))); + return vmulsign_vf_vf_vf(r, d); +} + +EXPORT CONST VECTOR_CC vfloat xacosf(vfloat d) { + vopmask o = vlt_vo_vf_vf(vabs_vf_vf(d), vcast_vf_f(0.5f)); + vfloat x2 = vsel_vf_vo_vf_vf(o, vmul_vf_vf_vf(d, d), + vmul_vf_vf_vf(vsub_vf_vf_vf(vcast_vf_f(1), vabs_vf_vf(d)), vcast_vf_f(0.5f))), u; + vfloat x = vsel_vf_vo_vf_vf(o, vabs_vf_vf(d), vsqrt_vf_vf(x2)); + x = vsel_vf_vo_vf_vf(veq_vo_vf_vf(vabs_vf_vf(d), vcast_vf_f(1.0f)), vcast_vf_f(0), x); + + u = vcast_vf_f(+0.4197454825e-1); + u = vmla_vf_vf_vf_vf(u, x2, vcast_vf_f(+0.2424046025e-1)); + u = vmla_vf_vf_vf_vf(u, x2, vcast_vf_f(+0.4547423869e-1)); + u = vmla_vf_vf_vf_vf(u, x2, vcast_vf_f(+0.7495029271e-1)); + u = vmla_vf_vf_vf_vf(u, x2, vcast_vf_f(+0.1666677296e+0)); + u = vmul_vf_vf_vf(u, vmul_vf_vf_vf(x2, x)); + + vfloat y = vsub_vf_vf_vf(vcast_vf_f(3.1415926535897932f/2), vadd_vf_vf_vf(vmulsign_vf_vf_vf(x, d), vmulsign_vf_vf_vf(u, d))); + x = vadd_vf_vf_vf(x, u); + vfloat r = vsel_vf_vo_vf_vf(o, y, vmul_vf_vf_vf(x, vcast_vf_f(2))); + return vsel_vf_vo_vf_vf(vandnot_vo_vo_vo(o, vlt_vo_vf_vf(d, vcast_vf_f(0))), + vf2getx_vf_vf2(dfadd_vf2_vf2_vf(vcast_vf2_f_f(3.1415927410125732422f,-8.7422776573475857731e-08f), + vneg_vf_vf(r))), r); +} +#endif // #if !defined(DETERMINISTIC) + +// + +static INLINE CONST VECTOR_CC vfloat2 atan2kf_u1(vfloat2 y, vfloat2 x) { + vfloat u; + vfloat2 s, t; + vint2 q; + vopmask p; + vmask r; + + q = vsel_vi2_vf_vf_vi2_vi2(vf2getx_vf_vf2(x), vcast_vf_f(0), vcast_vi2_i(-2), vcast_vi2_i(0)); + p = vlt_vo_vf_vf(vf2getx_vf_vf2(x), vcast_vf_f(0)); + r = vand_vm_vo32_vm(p, vreinterpret_vm_vf(vcast_vf_f(-0.0))); + x = vf2setx_vf2_vf2_vf(x, vreinterpret_vf_vm(vxor_vm_vm_vm(vreinterpret_vm_vf(vf2getx_vf_vf2(x)), r))); + x = vf2sety_vf2_vf2_vf(x, vreinterpret_vf_vm(vxor_vm_vm_vm(vreinterpret_vm_vf(vf2gety_vf_vf2(x)), r))); + + q = vsel_vi2_vf_vf_vi2_vi2(vf2getx_vf_vf2(x), vf2getx_vf_vf2(y), vadd_vi2_vi2_vi2(q, vcast_vi2_i(1)), q); + p = vlt_vo_vf_vf(vf2getx_vf_vf2(x), vf2getx_vf_vf2(y)); + s = vsel_vf2_vo_vf2_vf2(p, dfneg_vf2_vf2(x), y); + t = vsel_vf2_vo_vf2_vf2(p, y, x); + + s = dfdiv_vf2_vf2_vf2(s, t); + t = dfsqu_vf2_vf2(s); + t = dfnormalize_vf2_vf2(t); + + u = vcast_vf_f(-0.00176397908944636583328247f); + u = vmla_vf_vf_vf_vf(u, vf2getx_vf_vf2(t), vcast_vf_f(0.0107900900766253471374512f)); + u = vmla_vf_vf_vf_vf(u, vf2getx_vf_vf2(t), vcast_vf_f(-0.0309564601629972457885742f)); + u = vmla_vf_vf_vf_vf(u, vf2getx_vf_vf2(t), vcast_vf_f(0.0577365085482597351074219f)); + u = vmla_vf_vf_vf_vf(u, vf2getx_vf_vf2(t), vcast_vf_f(-0.0838950723409652709960938f)); + u = vmla_vf_vf_vf_vf(u, vf2getx_vf_vf2(t), vcast_vf_f(0.109463557600975036621094f)); + u = vmla_vf_vf_vf_vf(u, vf2getx_vf_vf2(t), vcast_vf_f(-0.142626821994781494140625f)); + u = vmla_vf_vf_vf_vf(u, vf2getx_vf_vf2(t), vcast_vf_f(0.199983194470405578613281f)); + + t = dfmul_vf2_vf2_vf2(t, dfadd_vf2_vf_vf(vcast_vf_f(-0.333332866430282592773438f), vmul_vf_vf_vf(u, vf2getx_vf_vf2(t)))); + t = dfmul_vf2_vf2_vf2(s, dfadd_vf2_vf_vf2(vcast_vf_f(1), t)); + t = dfadd_vf2_vf2_vf2(dfmul_vf2_vf2_vf(vcast_vf2_f_f(1.5707963705062866211f, -4.3711388286737928865e-08f), vcast_vf_vi2(q)), t); + + return t; +} + +#if !defined(DETERMINISTIC) +EXPORT CONST VECTOR_CC vfloat xatan2f_u1(vfloat y, vfloat x) { + vopmask o = vlt_vo_vf_vf(vabs_vf_vf(x), vcast_vf_f(2.9387372783541830947e-39f)); // nexttowardf((1.0 / FLT_MAX), 1) + x = vsel_vf_vo_vf_vf(o, vmul_vf_vf_vf(x, vcast_vf_f(1 << 24)), x); + y = vsel_vf_vo_vf_vf(o, vmul_vf_vf_vf(y, vcast_vf_f(1 << 24)), y); + + vfloat2 d = atan2kf_u1(vcast_vf2_vf_vf(vabs_vf_vf(y), vcast_vf_f(0)), vcast_vf2_vf_vf(x, vcast_vf_f(0))); + vfloat r = vadd_vf_vf_vf(vf2getx_vf_vf2(d), vf2gety_vf_vf2(d)); + + r = vmulsign_vf_vf_vf(r, x); + r = vsel_vf_vo_vf_vf(vor_vo_vo_vo(visinf_vo_vf(x), veq_vo_vf_vf(x, vcast_vf_f(0))), vsub_vf_vf_vf(vcast_vf_f(M_PI/2), visinf2_vf_vf_vf(x, vmulsign_vf_vf_vf(vcast_vf_f(M_PI/2), x))), r); + r = vsel_vf_vo_vf_vf(visinf_vo_vf(y), vsub_vf_vf_vf(vcast_vf_f(M_PI/2), visinf2_vf_vf_vf(x, vmulsign_vf_vf_vf(vcast_vf_f(M_PI/4), x))), r); + r = vsel_vf_vo_vf_vf(veq_vo_vf_vf(y, vcast_vf_f(0.0f)), vreinterpret_vf_vm(vand_vm_vo32_vm(vsignbit_vo_vf(x), vreinterpret_vm_vf(vcast_vf_f((float)M_PI)))), r); + + r = vreinterpret_vf_vm(vor_vm_vo32_vm(vor_vo_vo_vo(visnan_vo_vf(x), visnan_vo_vf(y)), vreinterpret_vm_vf(vmulsign_vf_vf_vf(r, y)))); + return r; +} + +EXPORT CONST VECTOR_CC vfloat xasinf_u1(vfloat d) { + vopmask o = vlt_vo_vf_vf(vabs_vf_vf(d), vcast_vf_f(0.5f)); + vfloat x2 = vsel_vf_vo_vf_vf(o, vmul_vf_vf_vf(d, d), vmul_vf_vf_vf(vsub_vf_vf_vf(vcast_vf_f(1), vabs_vf_vf(d)), vcast_vf_f(0.5f))), u; + vfloat2 x = vsel_vf2_vo_vf2_vf2(o, vcast_vf2_vf_vf(vabs_vf_vf(d), vcast_vf_f(0)), dfsqrt_vf2_vf(x2)); + x = vsel_vf2_vo_vf2_vf2(veq_vo_vf_vf(vabs_vf_vf(d), vcast_vf_f(1.0f)), vcast_vf2_f_f(0, 0), x); + + u = vcast_vf_f(+0.4197454825e-1); + u = vmla_vf_vf_vf_vf(u, x2, vcast_vf_f(+0.2424046025e-1)); + u = vmla_vf_vf_vf_vf(u, x2, vcast_vf_f(+0.4547423869e-1)); + u = vmla_vf_vf_vf_vf(u, x2, vcast_vf_f(+0.7495029271e-1)); + u = vmla_vf_vf_vf_vf(u, x2, vcast_vf_f(+0.1666677296e+0)); + u = vmul_vf_vf_vf(u, vmul_vf_vf_vf(x2, vf2getx_vf_vf2(x))); + + vfloat2 y = dfsub_vf2_vf2_vf(dfsub_vf2_vf2_vf2(vcast_vf2_f_f(3.1415927410125732422f/4,-8.7422776573475857731e-08f/4), x), u); + + vfloat r = vsel_vf_vo_vf_vf(o, vadd_vf_vf_vf(u, vf2getx_vf_vf2(x)), + vmul_vf_vf_vf(vadd_vf_vf_vf(vf2getx_vf_vf2(y), vf2gety_vf_vf2(y)), vcast_vf_f(2))); + return vmulsign_vf_vf_vf(r, d); +} + +EXPORT CONST VECTOR_CC vfloat xacosf_u1(vfloat d) { + vopmask o = vlt_vo_vf_vf(vabs_vf_vf(d), vcast_vf_f(0.5f)); + vfloat x2 = vsel_vf_vo_vf_vf(o, vmul_vf_vf_vf(d, d), vmul_vf_vf_vf(vsub_vf_vf_vf(vcast_vf_f(1), vabs_vf_vf(d)), vcast_vf_f(0.5f))), u; + vfloat2 x = vsel_vf2_vo_vf2_vf2(o, vcast_vf2_vf_vf(vabs_vf_vf(d), vcast_vf_f(0)), dfsqrt_vf2_vf(x2)); + x = vsel_vf2_vo_vf2_vf2(veq_vo_vf_vf(vabs_vf_vf(d), vcast_vf_f(1.0f)), vcast_vf2_f_f(0, 0), x); + + u = vcast_vf_f(+0.4197454825e-1); + u = vmla_vf_vf_vf_vf(u, x2, vcast_vf_f(+0.2424046025e-1)); + u = vmla_vf_vf_vf_vf(u, x2, vcast_vf_f(+0.4547423869e-1)); + u = vmla_vf_vf_vf_vf(u, x2, vcast_vf_f(+0.7495029271e-1)); + u = vmla_vf_vf_vf_vf(u, x2, vcast_vf_f(+0.1666677296e+0)); + u = vmul_vf_vf_vf(u, vmul_vf_vf_vf(x2, vf2getx_vf_vf2(x))); + + vfloat2 y = dfsub_vf2_vf2_vf2(vcast_vf2_f_f(3.1415927410125732422f/2, -8.7422776573475857731e-08f/2), + dfadd_vf2_vf_vf(vmulsign_vf_vf_vf(vf2getx_vf_vf2(x), d), vmulsign_vf_vf_vf(u, d))); + x = dfadd_vf2_vf2_vf(x, u); + + y = vsel_vf2_vo_vf2_vf2(o, y, dfscale_vf2_vf2_vf(x, vcast_vf_f(2))); + + y = vsel_vf2_vo_vf2_vf2(vandnot_vo_vo_vo(o, vlt_vo_vf_vf(d, vcast_vf_f(0))), + dfsub_vf2_vf2_vf2(vcast_vf2_f_f(3.1415927410125732422f, -8.7422776573475857731e-08f), y), y); + + return vadd_vf_vf_vf(vf2getx_vf_vf2(y), vf2gety_vf_vf2(y)); +} + +EXPORT CONST VECTOR_CC vfloat xatanf_u1(vfloat d) { + vfloat2 d2 = atan2kf_u1(vcast_vf2_vf_vf(vabs_vf_vf(d), vcast_vf_f(0)), vcast_vf2_f_f(1, 0)); + vfloat r = vadd_vf_vf_vf(vf2getx_vf_vf2(d2), vf2gety_vf_vf2(d2)); + r = vsel_vf_vo_vf_vf(visinf_vo_vf(d), vcast_vf_f(1.570796326794896557998982), r); + return vmulsign_vf_vf_vf(r, d); +} +#endif // #if !defined(DETERMINISTIC) + +// + +#if !defined(DETERMINISTIC) +EXPORT CONST VECTOR_CC vfloat xlogf(vfloat d) { + vfloat x, x2, t, m; + +#if !defined(ENABLE_AVX512F) && !defined(ENABLE_AVX512FNOFMA) + vopmask o = vlt_vo_vf_vf(d, vcast_vf_f(SLEEF_FLT_MIN)); + d = vsel_vf_vo_vf_vf(o, vmul_vf_vf_vf(d, vcast_vf_f((float)(INT64_C(1) << 32) * (float)(INT64_C(1) << 32))), d); + vint2 e = vilogb2k_vi2_vf(vmul_vf_vf_vf(d, vcast_vf_f(1.0f/0.75f))); + m = vldexp3_vf_vf_vi2(d, vneg_vi2_vi2(e)); + e = vsel_vi2_vo_vi2_vi2(o, vsub_vi2_vi2_vi2(e, vcast_vi2_i(64)), e); +#else + vfloat e = vgetexp_vf_vf(vmul_vf_vf_vf(d, vcast_vf_f(1.0f/0.75f))); + e = vsel_vf_vo_vf_vf(vispinf_vo_vf(e), vcast_vf_f(128.0f), e); + m = vgetmant_vf_vf(d); +#endif + + x = vdiv_vf_vf_vf(vsub_vf_vf_vf(m, vcast_vf_f(1.0f)), vadd_vf_vf_vf(vcast_vf_f(1.0f), m)); + x2 = vmul_vf_vf_vf(x, x); + + t = vcast_vf_f(0.2392828464508056640625f); + t = vmla_vf_vf_vf_vf(t, x2, vcast_vf_f(0.28518211841583251953125f)); + t = vmla_vf_vf_vf_vf(t, x2, vcast_vf_f(0.400005877017974853515625f)); + t = vmla_vf_vf_vf_vf(t, x2, vcast_vf_f(0.666666686534881591796875f)); + t = vmla_vf_vf_vf_vf(t, x2, vcast_vf_f(2.0f)); + +#if !defined(ENABLE_AVX512F) && !defined(ENABLE_AVX512FNOFMA) + x = vmla_vf_vf_vf_vf(x, t, vmul_vf_vf_vf(vcast_vf_f(0.693147180559945286226764f), vcast_vf_vi2(e))); + x = vsel_vf_vo_vf_vf(vispinf_vo_vf(d), vcast_vf_f(SLEEF_INFINITYf), x); + x = vsel_vf_vo_vf_vf(vor_vo_vo_vo(vlt_vo_vf_vf(d, vcast_vf_f(0)), visnan_vo_vf(d)), vcast_vf_f(SLEEF_NANf), x); + x = vsel_vf_vo_vf_vf(veq_vo_vf_vf(d, vcast_vf_f(0)), vcast_vf_f(-SLEEF_INFINITYf), x); +#else + x = vmla_vf_vf_vf_vf(x, t, vmul_vf_vf_vf(vcast_vf_f(0.693147180559945286226764f), e)); + x = vfixup_vf_vf_vf_vi2_i(x, d, vcast_vi2_i((5 << (5*4))), 0); +#endif + + return x; +} +#endif // #if !defined(DETERMINISTIC) + +#if !defined(DETERMINISTIC) +EXPORT CONST VECTOR_CC vfloat xexpf(vfloat d) { + vint2 q = vrint_vi2_vf(vmul_vf_vf_vf(d, vcast_vf_f(R_LN2f))); + vfloat s, u; + + s = vmla_vf_vf_vf_vf(vcast_vf_vi2(q), vcast_vf_f(-L2Uf), d); + s = vmla_vf_vf_vf_vf(vcast_vf_vi2(q), vcast_vf_f(-L2Lf), s); + + u = vcast_vf_f(0.000198527617612853646278381); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(0.00139304355252534151077271)); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(0.00833336077630519866943359)); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(0.0416664853692054748535156)); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(0.166666671633720397949219)); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(0.5)); + + u = vadd_vf_vf_vf(vcast_vf_f(1.0f), vmla_vf_vf_vf_vf(vmul_vf_vf_vf(s, s), u, s)); + + u = vldexp2_vf_vf_vi2(u, q); + + u = vreinterpret_vf_vm(vandnot_vm_vo32_vm(vlt_vo_vf_vf(d, vcast_vf_f(-104)), vreinterpret_vm_vf(u))); + u = vsel_vf_vo_vf_vf(vlt_vo_vf_vf(vcast_vf_f(100), d), vcast_vf_f(SLEEF_INFINITYf), u); + + return u; +} +#endif // #if !defined(DETERMINISTIC) + +static INLINE CONST VECTOR_CC vfloat expm1fk(vfloat d) { + vint2 q = vrint_vi2_vf(vmul_vf_vf_vf(d, vcast_vf_f(R_LN2f))); + vfloat s, u; + + s = vmla_vf_vf_vf_vf(vcast_vf_vi2(q), vcast_vf_f(-L2Uf), d); + s = vmla_vf_vf_vf_vf(vcast_vf_vi2(q), vcast_vf_f(-L2Lf), s); + + vfloat s2 = vmul_vf_vf_vf(s, s), s4 = vmul_vf_vf_vf(s2, s2); + u = POLY6(s, s2, s4, + 0.000198527617612853646278381, + 0.00139304355252534151077271, + 0.00833336077630519866943359, + 0.0416664853692054748535156, + 0.166666671633720397949219, + 0.5); + + u = vmla_vf_vf_vf_vf(vmul_vf_vf_vf(s, s), u, s); + + u = vsel_vf_vo_vf_vf(veq_vo_vi2_vi2(q, vcast_vi2_i(0)), u, + vsub_vf_vf_vf(vldexp2_vf_vf_vi2(vadd_vf_vf_vf(u, vcast_vf_f(1)), q), vcast_vf_f(1))); + + return u; +} + +#if defined(ENABLE_NEON32) || defined(ENABLE_NEON32VFPV4) +EXPORT CONST VECTOR_CC vfloat xsqrtf_u35(vfloat d) { + vfloat e = vreinterpret_vf_vi2(vadd_vi2_vi2_vi2(vcast_vi2_i(0x20000000), vand_vi2_vi2_vi2(vcast_vi2_i(0x7f000000), vsrl_vi2_vi2_i(vreinterpret_vi2_vf(d), 1)))); + vfloat m = vreinterpret_vf_vi2(vadd_vi2_vi2_vi2(vcast_vi2_i(0x3f000000), vand_vi2_vi2_vi2(vcast_vi2_i(0x01ffffff), vreinterpret_vi2_vf(d)))); + float32x4_t x = vrsqrteq_f32(m); + x = vmulq_f32(x, vrsqrtsq_f32(m, vmulq_f32(x, x))); + float32x4_t u = vmulq_f32(x, m); + u = vmlaq_f32(u, vmlsq_f32(m, u, u), vmulq_f32(x, vdupq_n_f32(0.5))); + e = vreinterpret_vf_vm(vandnot_vm_vo32_vm(veq_vo_vf_vf(d, vcast_vf_f(0)), vreinterpret_vm_vf(e))); + u = vmul_vf_vf_vf(e, u); + + u = vsel_vf_vo_vf_vf(visinf_vo_vf(d), vcast_vf_f(SLEEF_INFINITYf), u); + u = vreinterpret_vf_vm(vor_vm_vo32_vm(vor_vo_vo_vo(visnan_vo_vf(d), vlt_vo_vf_vf(d, vcast_vf_f(0))), vreinterpret_vm_vf(u))); + u = vmulsign_vf_vf_vf(u, d); + + return u; +} +#elif defined(ENABLE_VECEXT) +EXPORT CONST VECTOR_CC vfloat xsqrtf_u35(vfloat d) { + vfloat q = vsqrt_vf_vf(d); + q = vsel_vf_vo_vf_vf(visnegzero_vo_vf(d), vcast_vf_f(-0.0), q); + return vsel_vf_vo_vf_vf(vispinf_vo_vf(d), vcast_vf_f(SLEEF_INFINITYf), q); +} +#else +EXPORT CONST VECTOR_CC vfloat xsqrtf_u35(vfloat d) { return vsqrt_vf_vf(d); } +#endif + +#if !defined(DETERMINISTIC) +EXPORT CONST VECTOR_CC vfloat xcbrtf(vfloat d) { + vfloat x, y, q = vcast_vf_f(1.0), t; + vint2 e, qu, re; + +#if defined(ENABLE_AVX512F) || defined(ENABLE_AVX512FNOFMA) + vfloat s = d; +#endif + e = vadd_vi2_vi2_vi2(vilogbk_vi2_vf(vabs_vf_vf(d)), vcast_vi2_i(1)); + d = vldexp2_vf_vf_vi2(d, vneg_vi2_vi2(e)); + + t = vadd_vf_vf_vf(vcast_vf_vi2(e), vcast_vf_f(6144)); + qu = vtruncate_vi2_vf(vmul_vf_vf_vf(t, vcast_vf_f(1.0f/3.0f))); + re = vtruncate_vi2_vf(vsub_vf_vf_vf(t, vmul_vf_vf_vf(vcast_vf_vi2(qu), vcast_vf_f(3)))); + + q = vsel_vf_vo_vf_vf(veq_vo_vi2_vi2(re, vcast_vi2_i(1)), vcast_vf_f(1.2599210498948731647672106f), q); + q = vsel_vf_vo_vf_vf(veq_vo_vi2_vi2(re, vcast_vi2_i(2)), vcast_vf_f(1.5874010519681994747517056f), q); + q = vldexp2_vf_vf_vi2(q, vsub_vi2_vi2_vi2(qu, vcast_vi2_i(2048))); + + q = vmulsign_vf_vf_vf(q, d); + d = vabs_vf_vf(d); + + x = vcast_vf_f(-0.601564466953277587890625f); + x = vmla_vf_vf_vf_vf(x, d, vcast_vf_f(2.8208892345428466796875f)); + x = vmla_vf_vf_vf_vf(x, d, vcast_vf_f(-5.532182216644287109375f)); + x = vmla_vf_vf_vf_vf(x, d, vcast_vf_f(5.898262500762939453125f)); + x = vmla_vf_vf_vf_vf(x, d, vcast_vf_f(-3.8095417022705078125f)); + x = vmla_vf_vf_vf_vf(x, d, vcast_vf_f(2.2241256237030029296875f)); + + y = vmul_vf_vf_vf(vmul_vf_vf_vf(d, x), x); + y = vmul_vf_vf_vf(vsub_vf_vf_vf(y, vmul_vf_vf_vf(vmul_vf_vf_vf(vcast_vf_f(2.0f / 3.0f), y), vmla_vf_vf_vf_vf(y, x, vcast_vf_f(-1.0f)))), q); + +#if defined(ENABLE_AVX512F) || defined(ENABLE_AVX512FNOFMA) + y = vsel_vf_vo_vf_vf(visinf_vo_vf(s), vmulsign_vf_vf_vf(vcast_vf_f(SLEEF_INFINITYf), s), y); + y = vsel_vf_vo_vf_vf(veq_vo_vf_vf(s, vcast_vf_f(0)), vmulsign_vf_vf_vf(vcast_vf_f(0), s), y); +#endif + + return y; +} +#endif // #if !defined(DETERMINISTIC) + +#if !defined(DETERMINISTIC) +EXPORT CONST VECTOR_CC vfloat xcbrtf_u1(vfloat d) { + vfloat x, y, z, t; + vfloat2 q2 = vcast_vf2_f_f(1, 0), u, v; + vint2 e, qu, re; + +#if defined(ENABLE_AVX512F) || defined(ENABLE_AVX512FNOFMA) + vfloat s = d; +#endif + e = vadd_vi2_vi2_vi2(vilogbk_vi2_vf(vabs_vf_vf(d)), vcast_vi2_i(1)); + d = vldexp2_vf_vf_vi2(d, vneg_vi2_vi2(e)); + + t = vadd_vf_vf_vf(vcast_vf_vi2(e), vcast_vf_f(6144)); + qu = vtruncate_vi2_vf(vmul_vf_vf_vf(t, vcast_vf_f(1.0/3.0))); + re = vtruncate_vi2_vf(vsub_vf_vf_vf(t, vmul_vf_vf_vf(vcast_vf_vi2(qu), vcast_vf_f(3)))); + + q2 = vsel_vf2_vo_vf2_vf2(veq_vo_vi2_vi2(re, vcast_vi2_i(1)), vcast_vf2_f_f(1.2599210739135742188f, -2.4018701694217270415e-08), q2); + q2 = vsel_vf2_vo_vf2_vf2(veq_vo_vi2_vi2(re, vcast_vi2_i(2)), vcast_vf2_f_f(1.5874010324478149414f, 1.9520385308169352356e-08), q2); + + q2 = vf2setx_vf2_vf2_vf(q2, vmulsign_vf_vf_vf(vf2getx_vf_vf2(q2), d)); + q2 = vf2sety_vf2_vf2_vf(q2, vmulsign_vf_vf_vf(vf2gety_vf_vf2(q2), d)); + d = vabs_vf_vf(d); + + x = vcast_vf_f(-0.601564466953277587890625f); + x = vmla_vf_vf_vf_vf(x, d, vcast_vf_f(2.8208892345428466796875f)); + x = vmla_vf_vf_vf_vf(x, d, vcast_vf_f(-5.532182216644287109375f)); + x = vmla_vf_vf_vf_vf(x, d, vcast_vf_f(5.898262500762939453125f)); + x = vmla_vf_vf_vf_vf(x, d, vcast_vf_f(-3.8095417022705078125f)); + x = vmla_vf_vf_vf_vf(x, d, vcast_vf_f(2.2241256237030029296875f)); + + y = vmul_vf_vf_vf(x, x); y = vmul_vf_vf_vf(y, y); x = vsub_vf_vf_vf(x, vmul_vf_vf_vf(vmlanp_vf_vf_vf_vf(d, y, x), vcast_vf_f(-1.0 / 3.0))); + + z = x; + + u = dfmul_vf2_vf_vf(x, x); + u = dfmul_vf2_vf2_vf2(u, u); + u = dfmul_vf2_vf2_vf(u, d); + u = dfadd2_vf2_vf2_vf(u, vneg_vf_vf(x)); + y = vadd_vf_vf_vf(vf2getx_vf_vf2(u), vf2gety_vf_vf2(u)); + + y = vmul_vf_vf_vf(vmul_vf_vf_vf(vcast_vf_f(-2.0 / 3.0), y), z); + v = dfadd2_vf2_vf2_vf(dfmul_vf2_vf_vf(z, z), y); + v = dfmul_vf2_vf2_vf(v, d); + v = dfmul_vf2_vf2_vf2(v, q2); + z = vldexp2_vf_vf_vi2(vadd_vf_vf_vf(vf2getx_vf_vf2(v), vf2gety_vf_vf2(v)), vsub_vi2_vi2_vi2(qu, vcast_vi2_i(2048))); + + z = vsel_vf_vo_vf_vf(visinf_vo_vf(d), vmulsign_vf_vf_vf(vcast_vf_f(SLEEF_INFINITYf), vf2getx_vf_vf2(q2)), z); + z = vsel_vf_vo_vf_vf(veq_vo_vf_vf(d, vcast_vf_f(0)), vreinterpret_vf_vm(vsignbit_vm_vf(vf2getx_vf_vf2(q2))), z); + +#if defined(ENABLE_AVX512F) || defined(ENABLE_AVX512FNOFMA) + z = vsel_vf_vo_vf_vf(visinf_vo_vf(s), vmulsign_vf_vf_vf(vcast_vf_f(SLEEF_INFINITYf), s), z); + z = vsel_vf_vo_vf_vf(veq_vo_vf_vf(s, vcast_vf_f(0)), vmulsign_vf_vf_vf(vcast_vf_f(0), s), z); +#endif + + return z; +} +#endif // #if !defined(DETERMINISTIC) + +static INLINE CONST VECTOR_CC vfloat2 logkf(vfloat d) { + vfloat2 x, x2; + vfloat t, m; + +#if !defined(ENABLE_AVX512F) && !defined(ENABLE_AVX512FNOFMA) + vopmask o = vlt_vo_vf_vf(d, vcast_vf_f(SLEEF_FLT_MIN)); + d = vsel_vf_vo_vf_vf(o, vmul_vf_vf_vf(d, vcast_vf_f((float)(INT64_C(1) << 32) * (float)(INT64_C(1) << 32))), d); + vint2 e = vilogb2k_vi2_vf(vmul_vf_vf_vf(d, vcast_vf_f(1.0f/0.75f))); + m = vldexp3_vf_vf_vi2(d, vneg_vi2_vi2(e)); + e = vsel_vi2_vo_vi2_vi2(o, vsub_vi2_vi2_vi2(e, vcast_vi2_i(64)), e); +#else + vfloat e = vgetexp_vf_vf(vmul_vf_vf_vf(d, vcast_vf_f(1.0f/0.75f))); + e = vsel_vf_vo_vf_vf(vispinf_vo_vf(e), vcast_vf_f(128.0f), e); + m = vgetmant_vf_vf(d); +#endif + + x = dfdiv_vf2_vf2_vf2(dfadd2_vf2_vf_vf(vcast_vf_f(-1), m), dfadd2_vf2_vf_vf(vcast_vf_f(1), m)); + x2 = dfsqu_vf2_vf2(x); + + t = vcast_vf_f(0.240320354700088500976562); + t = vmla_vf_vf_vf_vf(t, vf2getx_vf_vf2(x2), vcast_vf_f(0.285112679004669189453125)); + t = vmla_vf_vf_vf_vf(t, vf2getx_vf_vf2(x2), vcast_vf_f(0.400007992982864379882812)); + vfloat2 c = vcast_vf2_f_f(0.66666662693023681640625f, 3.69183861259614332084311e-09f); + +#if !defined(ENABLE_AVX512F) && !defined(ENABLE_AVX512FNOFMA) + vfloat2 s = dfmul_vf2_vf2_vf(vcast_vf2_f_f(0.69314718246459960938f, -1.904654323148236017e-09f), vcast_vf_vi2(e)); +#else + vfloat2 s = dfmul_vf2_vf2_vf(vcast_vf2_f_f(0.69314718246459960938f, -1.904654323148236017e-09f), e); +#endif + + s = dfadd_vf2_vf2_vf2(s, dfscale_vf2_vf2_vf(x, vcast_vf_f(2))); + s = dfadd_vf2_vf2_vf2(s, dfmul_vf2_vf2_vf2(dfmul_vf2_vf2_vf2(x2, x), + dfadd2_vf2_vf2_vf2(dfmul_vf2_vf2_vf(x2, t), c))); + return s; +} + +static INLINE CONST VECTOR_CC vfloat logk3f(vfloat d) { + vfloat x, x2, t, m; + +#if !defined(ENABLE_AVX512F) && !defined(ENABLE_AVX512FNOFMA) + vopmask o = vlt_vo_vf_vf(d, vcast_vf_f(SLEEF_FLT_MIN)); + d = vsel_vf_vo_vf_vf(o, vmul_vf_vf_vf(d, vcast_vf_f((float)(INT64_C(1) << 32) * (float)(INT64_C(1) << 32))), d); + vint2 e = vilogb2k_vi2_vf(vmul_vf_vf_vf(d, vcast_vf_f(1.0f/0.75f))); + m = vldexp3_vf_vf_vi2(d, vneg_vi2_vi2(e)); + e = vsel_vi2_vo_vi2_vi2(o, vsub_vi2_vi2_vi2(e, vcast_vi2_i(64)), e); +#else + vfloat e = vgetexp_vf_vf(vmul_vf_vf_vf(d, vcast_vf_f(1.0f/0.75f))); + e = vsel_vf_vo_vf_vf(vispinf_vo_vf(e), vcast_vf_f(128.0f), e); + m = vgetmant_vf_vf(d); +#endif + + x = vdiv_vf_vf_vf(vsub_vf_vf_vf(m, vcast_vf_f(1.0f)), vadd_vf_vf_vf(vcast_vf_f(1.0f), m)); + x2 = vmul_vf_vf_vf(x, x); + + t = vcast_vf_f(0.2392828464508056640625f); + t = vmla_vf_vf_vf_vf(t, x2, vcast_vf_f(0.28518211841583251953125f)); + t = vmla_vf_vf_vf_vf(t, x2, vcast_vf_f(0.400005877017974853515625f)); + t = vmla_vf_vf_vf_vf(t, x2, vcast_vf_f(0.666666686534881591796875f)); + t = vmla_vf_vf_vf_vf(t, x2, vcast_vf_f(2.0f)); + +#if !defined(ENABLE_AVX512F) && !defined(ENABLE_AVX512FNOFMA) + x = vmla_vf_vf_vf_vf(x, t, vmul_vf_vf_vf(vcast_vf_f(0.693147180559945286226764f), vcast_vf_vi2(e))); +#else + x = vmla_vf_vf_vf_vf(x, t, vmul_vf_vf_vf(vcast_vf_f(0.693147180559945286226764f), e)); +#endif + + return x; +} + +#if !defined(DETERMINISTIC) +EXPORT CONST VECTOR_CC vfloat xlogf_u1(vfloat d) { + vfloat2 x; + vfloat t, m, x2; + +#if !defined(ENABLE_AVX512F) && !defined(ENABLE_AVX512FNOFMA) + vopmask o = vlt_vo_vf_vf(d, vcast_vf_f(SLEEF_FLT_MIN)); + d = vsel_vf_vo_vf_vf(o, vmul_vf_vf_vf(d, vcast_vf_f((float)(INT64_C(1) << 32) * (float)(INT64_C(1) << 32))), d); + vint2 e = vilogb2k_vi2_vf(vmul_vf_vf_vf(d, vcast_vf_f(1.0f/0.75f))); + m = vldexp3_vf_vf_vi2(d, vneg_vi2_vi2(e)); + e = vsel_vi2_vo_vi2_vi2(o, vsub_vi2_vi2_vi2(e, vcast_vi2_i(64)), e); + vfloat2 s = dfmul_vf2_vf2_vf(vcast_vf2_f_f(0.69314718246459960938f, -1.904654323148236017e-09f), vcast_vf_vi2(e)); +#else + vfloat e = vgetexp_vf_vf(vmul_vf_vf_vf(d, vcast_vf_f(1.0f/0.75f))); + e = vsel_vf_vo_vf_vf(vispinf_vo_vf(e), vcast_vf_f(128.0f), e); + m = vgetmant_vf_vf(d); + vfloat2 s = dfmul_vf2_vf2_vf(vcast_vf2_f_f(0.69314718246459960938f, -1.904654323148236017e-09f), e); +#endif + + x = dfdiv_vf2_vf2_vf2(dfadd2_vf2_vf_vf(vcast_vf_f(-1), m), dfadd2_vf2_vf_vf(vcast_vf_f(1), m)); + x2 = vmul_vf_vf_vf(vf2getx_vf_vf2(x), vf2getx_vf_vf2(x)); + + t = vcast_vf_f(+0.3027294874e+0f); + t = vmla_vf_vf_vf_vf(t, x2, vcast_vf_f(+0.3996108174e+0f)); + t = vmla_vf_vf_vf_vf(t, x2, vcast_vf_f(+0.6666694880e+0f)); + + s = dfadd_vf2_vf2_vf2(s, dfscale_vf2_vf2_vf(x, vcast_vf_f(2))); + s = dfadd_vf2_vf2_vf(s, vmul_vf_vf_vf(vmul_vf_vf_vf(x2, vf2getx_vf_vf2(x)), t)); + + vfloat r = vadd_vf_vf_vf(vf2getx_vf_vf2(s), vf2gety_vf_vf2(s)); + +#if !defined(ENABLE_AVX512F) && !defined(ENABLE_AVX512FNOFMA) + r = vsel_vf_vo_vf_vf(vispinf_vo_vf(d), vcast_vf_f(SLEEF_INFINITYf), r); + r = vsel_vf_vo_vf_vf(vor_vo_vo_vo(vlt_vo_vf_vf(d, vcast_vf_f(0)), visnan_vo_vf(d)), vcast_vf_f(SLEEF_NANf), r); + r = vsel_vf_vo_vf_vf(veq_vo_vf_vf(d, vcast_vf_f(0)), vcast_vf_f(-SLEEF_INFINITYf), r); +#else + r = vfixup_vf_vf_vf_vi2_i(r, d, vcast_vi2_i((4 << (2*4)) | (3 << (4*4)) | (5 << (5*4)) | (2 << (6*4))), 0); +#endif + + return r; +} +#endif // #if !defined(DETERMINISTIC) + +static INLINE CONST VECTOR_CC vfloat expkf(vfloat2 d) { + vfloat u = vmul_vf_vf_vf(vadd_vf_vf_vf(vf2getx_vf_vf2(d), vf2gety_vf_vf2(d)), vcast_vf_f(R_LN2f)); + vint2 q = vrint_vi2_vf(u); + vfloat2 s, t; + + s = dfadd2_vf2_vf2_vf(d, vmul_vf_vf_vf(vcast_vf_vi2(q), vcast_vf_f(-L2Uf))); + s = dfadd2_vf2_vf2_vf(s, vmul_vf_vf_vf(vcast_vf_vi2(q), vcast_vf_f(-L2Lf))); + + s = dfnormalize_vf2_vf2(s); + + u = vcast_vf_f(0.00136324646882712841033936f); + u = vmla_vf_vf_vf_vf(u, vf2getx_vf_vf2(s), vcast_vf_f(0.00836596917361021041870117f)); + u = vmla_vf_vf_vf_vf(u, vf2getx_vf_vf2(s), vcast_vf_f(0.0416710823774337768554688f)); + u = vmla_vf_vf_vf_vf(u, vf2getx_vf_vf2(s), vcast_vf_f(0.166665524244308471679688f)); + u = vmla_vf_vf_vf_vf(u, vf2getx_vf_vf2(s), vcast_vf_f(0.499999850988388061523438f)); + + t = dfadd_vf2_vf2_vf2(s, dfmul_vf2_vf2_vf(dfsqu_vf2_vf2(s), u)); + + t = dfadd_vf2_vf_vf2(vcast_vf_f(1), t); + u = vadd_vf_vf_vf(vf2getx_vf_vf2(t), vf2gety_vf_vf2(t)); + u = vldexp_vf_vf_vi2(u, q); + + u = vreinterpret_vf_vm(vandnot_vm_vo32_vm(vlt_vo_vf_vf(vf2getx_vf_vf2(d), vcast_vf_f(-104)), vreinterpret_vm_vf(u))); + + return u; +} + +static INLINE CONST VECTOR_CC vfloat expk3f(vfloat d) { + vint2 q = vrint_vi2_vf(vmul_vf_vf_vf(d, vcast_vf_f(R_LN2f))); + vfloat s, u; + + s = vmla_vf_vf_vf_vf(vcast_vf_vi2(q), vcast_vf_f(-L2Uf), d); + s = vmla_vf_vf_vf_vf(vcast_vf_vi2(q), vcast_vf_f(-L2Lf), s); + + u = vcast_vf_f(0.000198527617612853646278381); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(0.00139304355252534151077271)); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(0.00833336077630519866943359)); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(0.0416664853692054748535156)); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(0.166666671633720397949219)); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(0.5)); + + u = vmla_vf_vf_vf_vf(vmul_vf_vf_vf(s, s), u, vadd_vf_vf_vf(s, vcast_vf_f(1.0f))); + u = vldexp2_vf_vf_vi2(u, q); + + u = vreinterpret_vf_vm(vandnot_vm_vo32_vm(vlt_vo_vf_vf(d, vcast_vf_f(-104)), vreinterpret_vm_vf(u))); + + return u; +} + +#if !defined(DETERMINISTIC) +EXPORT CONST VECTOR_CC vfloat xpowf(vfloat x, vfloat y) { +#if 1 + vopmask yisint = vor_vo_vo_vo(veq_vo_vf_vf(vtruncate_vf_vf(y), y), vgt_vo_vf_vf(vabs_vf_vf(y), vcast_vf_f(1 << 24))); + vopmask yisodd = vand_vo_vo_vo(vand_vo_vo_vo(veq_vo_vi2_vi2(vand_vi2_vi2_vi2(vtruncate_vi2_vf(y), vcast_vi2_i(1)), vcast_vi2_i(1)), yisint), + vlt_vo_vf_vf(vabs_vf_vf(y), vcast_vf_f(1 << 24))); + +#if defined(ENABLE_NEON32) || defined(ENABLE_NEON32VFPV4) + yisodd = vandnot_vm_vo32_vm(visinf_vo_vf(y), yisodd); +#endif + + vfloat result = expkf(dfmul_vf2_vf2_vf(logkf(vabs_vf_vf(x)), y)); + + result = vsel_vf_vo_vf_vf(visnan_vo_vf(result), vcast_vf_f(SLEEF_INFINITYf), result); + + result = vmul_vf_vf_vf(result, + vsel_vf_vo_vf_vf(vgt_vo_vf_vf(x, vcast_vf_f(0)), + vcast_vf_f(1), + vsel_vf_vo_vf_vf(yisint, vsel_vf_vo_vf_vf(yisodd, vcast_vf_f(-1.0f), vcast_vf_f(1)), vcast_vf_f(SLEEF_NANf)))); + + vfloat efx = vmulsign_vf_vf_vf(vsub_vf_vf_vf(vabs_vf_vf(x), vcast_vf_f(1)), y); + + result = vsel_vf_vo_vf_vf(visinf_vo_vf(y), + vreinterpret_vf_vm(vandnot_vm_vo32_vm(vlt_vo_vf_vf(efx, vcast_vf_f(0.0f)), + vreinterpret_vm_vf(vsel_vf_vo_vf_vf(veq_vo_vf_vf(efx, vcast_vf_f(0.0f)), + vcast_vf_f(1.0f), + vcast_vf_f(SLEEF_INFINITYf))))), + result); + + result = vsel_vf_vo_vf_vf(vor_vo_vo_vo(visinf_vo_vf(x), veq_vo_vf_vf(x, vcast_vf_f(0.0))), + vmulsign_vf_vf_vf(vsel_vf_vo_vf_vf(vxor_vo_vo_vo(vsignbit_vo_vf(y), veq_vo_vf_vf(x, vcast_vf_f(0.0f))), + vcast_vf_f(0), vcast_vf_f(SLEEF_INFINITYf)), + vsel_vf_vo_vf_vf(yisodd, x, vcast_vf_f(1))), result); + + result = vreinterpret_vf_vm(vor_vm_vo32_vm(vor_vo_vo_vo(visnan_vo_vf(x), visnan_vo_vf(y)), vreinterpret_vm_vf(result))); + + result = vsel_vf_vo_vf_vf(vor_vo_vo_vo(veq_vo_vf_vf(y, vcast_vf_f(0)), veq_vo_vf_vf(x, vcast_vf_f(1))), vcast_vf_f(1), result); + + return result; +#else + return expkf(dfmul_vf2_vf2_vf(logkf(x), y)); +#endif +} + +EXPORT CONST VECTOR_CC vfloat xfastpowf_u3500(vfloat x, vfloat y) { + vfloat result = expk3f(vmul_vf_vf_vf(logk3f(vabs_vf_vf(x)), y)); + vopmask yisint = vor_vo_vo_vo(veq_vo_vf_vf(vtruncate_vf_vf(y), y), vgt_vo_vf_vf(vabs_vf_vf(y), vcast_vf_f(1 << 24))); + vopmask yisodd = vand_vo_vo_vo(vand_vo_vo_vo(veq_vo_vi2_vi2(vand_vi2_vi2_vi2(vtruncate_vi2_vf(y), vcast_vi2_i(1)), vcast_vi2_i(1)), yisint), + vlt_vo_vf_vf(vabs_vf_vf(y), vcast_vf_f(1 << 24))); + + result = vsel_vf_vo_vf_vf(vand_vo_vo_vo(vsignbit_vo_vf(x), yisodd), vneg_vf_vf(result), result); + + result = vsel_vf_vo_vf_vf(veq_vo_vf_vf(x, vcast_vf_f(0)), vcast_vf_f(0), result); + result = vsel_vf_vo_vf_vf(veq_vo_vf_vf(y, vcast_vf_f(0)), vcast_vf_f(1), result); + + return result; +} +#endif // #if !defined(DETERMINISTIC) + +static INLINE CONST VECTOR_CC vfloat2 expk2f(vfloat2 d) { + vfloat u = vmul_vf_vf_vf(vadd_vf_vf_vf(vf2getx_vf_vf2(d), vf2gety_vf_vf2(d)), vcast_vf_f(R_LN2f)); + vint2 q = vrint_vi2_vf(u); + vfloat2 s, t; + + s = dfadd2_vf2_vf2_vf(d, vmul_vf_vf_vf(vcast_vf_vi2(q), vcast_vf_f(-L2Uf))); + s = dfadd2_vf2_vf2_vf(s, vmul_vf_vf_vf(vcast_vf_vi2(q), vcast_vf_f(-L2Lf))); + + u = vcast_vf_f(+0.1980960224e-3f); + u = vmla_vf_vf_vf_vf(u, vf2getx_vf_vf2(s), vcast_vf_f(+0.1394256484e-2f)); + u = vmla_vf_vf_vf_vf(u, vf2getx_vf_vf2(s), vcast_vf_f(+0.8333456703e-2f)); + u = vmla_vf_vf_vf_vf(u, vf2getx_vf_vf2(s), vcast_vf_f(+0.4166637361e-1f)); + + t = dfadd2_vf2_vf2_vf(dfmul_vf2_vf2_vf(s, u), vcast_vf_f(+0.166666659414234244790680580464e+0f)); + t = dfadd2_vf2_vf2_vf(dfmul_vf2_vf2_vf2(s, t), vcast_vf_f(0.5)); + t = dfadd2_vf2_vf2_vf2(s, dfmul_vf2_vf2_vf2(dfsqu_vf2_vf2(s), t)); + + t = dfadd_vf2_vf_vf2(vcast_vf_f(1), t); + + t = vf2setx_vf2_vf2_vf(t, vldexp2_vf_vf_vi2(vf2getx_vf_vf2(t), q)); + t = vf2sety_vf2_vf2_vf(t, vldexp2_vf_vf_vi2(vf2gety_vf_vf2(t), q)); + + t = vf2setx_vf2_vf2_vf(t, vreinterpret_vf_vm(vandnot_vm_vo32_vm(vlt_vo_vf_vf(vf2getx_vf_vf2(d), vcast_vf_f(-104)), vreinterpret_vm_vf(vf2getx_vf_vf2(t))))); + t = vf2sety_vf2_vf2_vf(t, vreinterpret_vf_vm(vandnot_vm_vo32_vm(vlt_vo_vf_vf(vf2getx_vf_vf2(d), vcast_vf_f(-104)), vreinterpret_vm_vf(vf2gety_vf_vf2(t))))); + + return t; +} + +#if !defined(DETERMINISTIC) +EXPORT CONST VECTOR_CC vfloat xsinhf(vfloat x) { + vfloat y = vabs_vf_vf(x); + vfloat2 d = expk2f(vcast_vf2_vf_vf(y, vcast_vf_f(0))); + d = dfsub_vf2_vf2_vf2(d, dfrec_vf2_vf2(d)); + y = vmul_vf_vf_vf(vadd_vf_vf_vf(vf2getx_vf_vf2(d), vf2gety_vf_vf2(d)), vcast_vf_f(0.5)); + + y = vsel_vf_vo_vf_vf(vor_vo_vo_vo(vgt_vo_vf_vf(vabs_vf_vf(x), vcast_vf_f(89)), + visnan_vo_vf(y)), vcast_vf_f(SLEEF_INFINITYf), y); + y = vmulsign_vf_vf_vf(y, x); + y = vreinterpret_vf_vm(vor_vm_vo32_vm(visnan_vo_vf(x), vreinterpret_vm_vf(y))); + + return y; +} + +EXPORT CONST VECTOR_CC vfloat xcoshf(vfloat x) { + vfloat y = vabs_vf_vf(x); + vfloat2 d = expk2f(vcast_vf2_vf_vf(y, vcast_vf_f(0))); + d = dfadd_vf2_vf2_vf2(d, dfrec_vf2_vf2(d)); + y = vmul_vf_vf_vf(vadd_vf_vf_vf(vf2getx_vf_vf2(d), vf2gety_vf_vf2(d)), vcast_vf_f(0.5)); + + y = vsel_vf_vo_vf_vf(vor_vo_vo_vo(vgt_vo_vf_vf(vabs_vf_vf(x), vcast_vf_f(89)), + visnan_vo_vf(y)), vcast_vf_f(SLEEF_INFINITYf), y); + y = vreinterpret_vf_vm(vor_vm_vo32_vm(visnan_vo_vf(x), vreinterpret_vm_vf(y))); + + return y; +} + +EXPORT CONST VECTOR_CC vfloat xtanhf(vfloat x) { + vfloat y = vabs_vf_vf(x); + vfloat2 d = expk2f(vcast_vf2_vf_vf(y, vcast_vf_f(0))); + vfloat2 e = dfrec_vf2_vf2(d); + d = dfdiv_vf2_vf2_vf2(dfadd_vf2_vf2_vf2(d, dfneg_vf2_vf2(e)), dfadd_vf2_vf2_vf2(d, e)); + y = vadd_vf_vf_vf(vf2getx_vf_vf2(d), vf2gety_vf_vf2(d)); + + y = vsel_vf_vo_vf_vf(vor_vo_vo_vo(vgt_vo_vf_vf(vabs_vf_vf(x), vcast_vf_f(8.664339742f)), + visnan_vo_vf(y)), vcast_vf_f(1.0f), y); + y = vmulsign_vf_vf_vf(y, x); + y = vreinterpret_vf_vm(vor_vm_vo32_vm(visnan_vo_vf(x), vreinterpret_vm_vf(y))); + + return y; +} + +EXPORT CONST VECTOR_CC vfloat xsinhf_u35(vfloat x) { + vfloat e = expm1fk(vabs_vf_vf(x)); + vfloat y = vdiv_vf_vf_vf(vadd_vf_vf_vf(e, vcast_vf_f(2)), vadd_vf_vf_vf(e, vcast_vf_f(1))); + y = vmul_vf_vf_vf(y, vmul_vf_vf_vf(vcast_vf_f(0.5f), e)); + + y = vsel_vf_vo_vf_vf(vor_vo_vo_vo(vgt_vo_vf_vf(vabs_vf_vf(x), vcast_vf_f(88)), + visnan_vo_vf(y)), vcast_vf_f(SLEEF_INFINITYf), y); + y = vmulsign_vf_vf_vf(y, x); + y = vreinterpret_vf_vm(vor_vm_vo32_vm(visnan_vo_vf(x), vreinterpret_vm_vf(y))); + + return y; +} + +EXPORT CONST VECTOR_CC vfloat xcoshf_u35(vfloat x) { + vfloat e = xexpf(vabs_vf_vf(x)); + vfloat y = vmla_vf_vf_vf_vf(vcast_vf_f(0.5f), e, vdiv_vf_vf_vf(vcast_vf_f(0.5), e)); + + y = vsel_vf_vo_vf_vf(vor_vo_vo_vo(vgt_vo_vf_vf(vabs_vf_vf(x), vcast_vf_f(88)), + visnan_vo_vf(y)), vcast_vf_f(SLEEF_INFINITYf), y); + y = vreinterpret_vf_vm(vor_vm_vo32_vm(visnan_vo_vf(x), vreinterpret_vm_vf(y))); + + return y; +} + +EXPORT CONST VECTOR_CC vfloat xtanhf_u35(vfloat x) { + vfloat d = expm1fk(vmul_vf_vf_vf(vcast_vf_f(2), vabs_vf_vf(x))); + vfloat y = vdiv_vf_vf_vf(d, vadd_vf_vf_vf(vcast_vf_f(2), d)); + + y = vsel_vf_vo_vf_vf(vor_vo_vo_vo(vgt_vo_vf_vf(vabs_vf_vf(x), vcast_vf_f(8.664339742f)), + visnan_vo_vf(y)), vcast_vf_f(1.0f), y); + y = vmulsign_vf_vf_vf(y, x); + y = vreinterpret_vf_vm(vor_vm_vo32_vm(visnan_vo_vf(x), vreinterpret_vm_vf(y))); + + return y; +} +#endif // #if !defined(DETERMINISTIC) + +static INLINE CONST VECTOR_CC vfloat2 logk2f(vfloat2 d) { + vfloat2 x, x2, m, s; + vfloat t; + vint2 e; + +#if !defined(ENABLE_AVX512F) && !defined(ENABLE_AVX512FNOFMA) + e = vilogbk_vi2_vf(vmul_vf_vf_vf(vf2getx_vf_vf2(d), vcast_vf_f(1.0f/0.75f))); +#else + e = vrint_vi2_vf(vgetexp_vf_vf(vmul_vf_vf_vf(vf2getx_vf_vf2(d), vcast_vf_f(1.0f/0.75f)))); +#endif + m = dfscale_vf2_vf2_vf(d, vpow2i_vf_vi2(vneg_vi2_vi2(e))); + + x = dfdiv_vf2_vf2_vf2(dfadd2_vf2_vf2_vf(m, vcast_vf_f(-1)), dfadd2_vf2_vf2_vf(m, vcast_vf_f(1))); + x2 = dfsqu_vf2_vf2(x); + + t = vcast_vf_f(0.2392828464508056640625f); + t = vmla_vf_vf_vf_vf(t, vf2getx_vf_vf2(x2), vcast_vf_f(0.28518211841583251953125f)); + t = vmla_vf_vf_vf_vf(t, vf2getx_vf_vf2(x2), vcast_vf_f(0.400005877017974853515625f)); + t = vmla_vf_vf_vf_vf(t, vf2getx_vf_vf2(x2), vcast_vf_f(0.666666686534881591796875f)); + + s = dfmul_vf2_vf2_vf(vcast_vf2_vf_vf(vcast_vf_f(0.69314718246459960938f), vcast_vf_f(-1.904654323148236017e-09f)), vcast_vf_vi2(e)); + s = dfadd_vf2_vf2_vf2(s, dfscale_vf2_vf2_vf(x, vcast_vf_f(2))); + s = dfadd_vf2_vf2_vf2(s, dfmul_vf2_vf2_vf(dfmul_vf2_vf2_vf2(x2, x), t)); + + return s; +} + +#if !defined(DETERMINISTIC) +EXPORT CONST VECTOR_CC vfloat xasinhf(vfloat x) { + vfloat y = vabs_vf_vf(x); + vopmask o = vgt_vo_vf_vf(y, vcast_vf_f(1)); + vfloat2 d; + + d = vsel_vf2_vo_vf2_vf2(o, dfrec_vf2_vf(x), vcast_vf2_vf_vf(y, vcast_vf_f(0))); + d = dfsqrt_vf2_vf2(dfadd2_vf2_vf2_vf(dfsqu_vf2_vf2(d), vcast_vf_f(1))); + d = vsel_vf2_vo_vf2_vf2(o, dfmul_vf2_vf2_vf(d, y), d); + + d = logk2f(dfnormalize_vf2_vf2(dfadd2_vf2_vf2_vf(d, x))); + y = vadd_vf_vf_vf(vf2getx_vf_vf2(d), vf2gety_vf_vf2(d)); + + y = vsel_vf_vo_vf_vf(vor_vo_vo_vo(vgt_vo_vf_vf(vabs_vf_vf(x), vcast_vf_f(SQRT_FLT_MAX)), + visnan_vo_vf(y)), + vmulsign_vf_vf_vf(vcast_vf_f(SLEEF_INFINITYf), x), y); + y = vreinterpret_vf_vm(vor_vm_vo32_vm(visnan_vo_vf(x), vreinterpret_vm_vf(y))); + y = vsel_vf_vo_vf_vf(visnegzero_vo_vf(x), vcast_vf_f(-0.0), y); + + return y; +} + +EXPORT CONST VECTOR_CC vfloat xacoshf(vfloat x) { + vfloat2 d = logk2f(dfadd2_vf2_vf2_vf(dfmul_vf2_vf2_vf2(dfsqrt_vf2_vf2(dfadd2_vf2_vf_vf(x, vcast_vf_f(1))), dfsqrt_vf2_vf2(dfadd2_vf2_vf_vf(x, vcast_vf_f(-1)))), x)); + vfloat y = vadd_vf_vf_vf(vf2getx_vf_vf2(d), vf2gety_vf_vf2(d)); + + y = vsel_vf_vo_vf_vf(vor_vo_vo_vo(vgt_vo_vf_vf(vabs_vf_vf(x), vcast_vf_f(SQRT_FLT_MAX)), + visnan_vo_vf(y)), + vcast_vf_f(SLEEF_INFINITYf), y); + + y = vreinterpret_vf_vm(vandnot_vm_vo32_vm(veq_vo_vf_vf(x, vcast_vf_f(1.0f)), vreinterpret_vm_vf(y))); + + y = vreinterpret_vf_vm(vor_vm_vo32_vm(vlt_vo_vf_vf(x, vcast_vf_f(1.0f)), vreinterpret_vm_vf(y))); + y = vreinterpret_vf_vm(vor_vm_vo32_vm(visnan_vo_vf(x), vreinterpret_vm_vf(y))); + + return y; +} + +EXPORT CONST VECTOR_CC vfloat xatanhf(vfloat x) { + vfloat y = vabs_vf_vf(x); + vfloat2 d = logk2f(dfdiv_vf2_vf2_vf2(dfadd2_vf2_vf_vf(vcast_vf_f(1), y), dfadd2_vf2_vf_vf(vcast_vf_f(1), vneg_vf_vf(y)))); + y = vreinterpret_vf_vm(vor_vm_vo32_vm(vgt_vo_vf_vf(y, vcast_vf_f(1.0)), vreinterpret_vm_vf(vsel_vf_vo_vf_vf(veq_vo_vf_vf(y, vcast_vf_f(1.0)), vcast_vf_f(SLEEF_INFINITYf), vmul_vf_vf_vf(vadd_vf_vf_vf(vf2getx_vf_vf2(d), vf2gety_vf_vf2(d)), vcast_vf_f(0.5)))))); + + y = vreinterpret_vf_vm(vor_vm_vo32_vm(vor_vo_vo_vo(visinf_vo_vf(x), visnan_vo_vf(y)), vreinterpret_vm_vf(y))); + y = vmulsign_vf_vf_vf(y, x); + y = vreinterpret_vf_vm(vor_vm_vo32_vm(visnan_vo_vf(x), vreinterpret_vm_vf(y))); + + return y; +} +#endif // #if !defined(DETERMINISTIC) + +#if !defined(DETERMINISTIC) +EXPORT CONST VECTOR_CC vfloat xexp2f(vfloat d) { + vfloat u = vrint_vf_vf(d), s; + vint2 q = vrint_vi2_vf(u); + + s = vsub_vf_vf_vf(d, u); + + u = vcast_vf_f(+0.1535920892e-3); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(+0.1339262701e-2)); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(+0.9618384764e-2)); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(+0.5550347269e-1)); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(+0.2402264476e+0)); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(+0.6931471825e+0)); + +#ifdef ENABLE_FMA_SP + u = vfma_vf_vf_vf_vf(u, s, vcast_vf_f(1)); +#else + u = vf2getx_vf_vf2(dfnormalize_vf2_vf2(dfadd_vf2_vf_vf2(vcast_vf_f(1), dfmul_vf2_vf_vf(u, s)))); +#endif + + u = vldexp2_vf_vf_vi2(u, q); + + u = vsel_vf_vo_vf_vf(vge_vo_vf_vf(d, vcast_vf_f(128)), vcast_vf_f(SLEEF_INFINITY), u); + u = vreinterpret_vf_vm(vandnot_vm_vo32_vm(vlt_vo_vf_vf(d, vcast_vf_f(-150)), vreinterpret_vm_vf(u))); + + return u; +} + +EXPORT CONST VECTOR_CC vfloat xexp2f_u35(vfloat d) { + vfloat u = vrint_vf_vf(d), s; + vint2 q = vrint_vi2_vf(u); + + s = vsub_vf_vf_vf(d, u); + + u = vcast_vf_f(+0.1535920892e-3); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(+0.1339262701e-2)); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(+0.9618384764e-2)); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(+0.5550347269e-1)); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(+0.2402264476e+0)); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(+0.6931471825e+0)); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(+0.1000000000e+1)); + + u = vldexp2_vf_vf_vi2(u, q); + + u = vsel_vf_vo_vf_vf(vge_vo_vf_vf(d, vcast_vf_f(128)), vcast_vf_f(SLEEF_INFINITY), u); + u = vreinterpret_vf_vm(vandnot_vm_vo32_vm(vlt_vo_vf_vf(d, vcast_vf_f(-150)), vreinterpret_vm_vf(u))); + + return u; +} + +EXPORT CONST VECTOR_CC vfloat xexp10f(vfloat d) { + vfloat u = vrint_vf_vf(vmul_vf_vf_vf(d, vcast_vf_f(LOG10_2))), s; + vint2 q = vrint_vi2_vf(u); + + s = vmla_vf_vf_vf_vf(u, vcast_vf_f(-L10Uf), d); + s = vmla_vf_vf_vf_vf(u, vcast_vf_f(-L10Lf), s); + + u = vcast_vf_f(+0.6802555919e-1); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(+0.2078080326e+0)); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(+0.5393903852e+0)); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(+0.1171245337e+1)); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(+0.2034678698e+1)); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(+0.2650949001e+1)); + vfloat2 x = dfadd_vf2_vf2_vf(vcast_vf2_f_f(2.3025851249694824219, -3.1705172516493593157e-08), vmul_vf_vf_vf(u, s)); + u = vf2getx_vf_vf2(dfnormalize_vf2_vf2(dfadd_vf2_vf_vf2(vcast_vf_f(1), dfmul_vf2_vf2_vf(x, s)))); + + u = vldexp2_vf_vf_vi2(u, q); + + u = vsel_vf_vo_vf_vf(vgt_vo_vf_vf(d, vcast_vf_f(38.5318394191036238941387f)), vcast_vf_f(SLEEF_INFINITYf), u); + u = vreinterpret_vf_vm(vandnot_vm_vo32_vm(vlt_vo_vf_vf(d, vcast_vf_f(-50)), vreinterpret_vm_vf(u))); + + return u; +} + +EXPORT CONST VECTOR_CC vfloat xexp10f_u35(vfloat d) { + vfloat u = vrint_vf_vf(vmul_vf_vf_vf(d, vcast_vf_f(LOG10_2))), s; + vint2 q = vrint_vi2_vf(u); + + s = vmla_vf_vf_vf_vf(u, vcast_vf_f(-L10Uf), d); + s = vmla_vf_vf_vf_vf(u, vcast_vf_f(-L10Lf), s); + + u = vcast_vf_f(+0.2064004987e+0); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(+0.5417877436e+0)); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(+0.1171286821e+1)); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(+0.2034656048e+1)); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(+0.2650948763e+1)); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(+0.2302585125e+1)); + u = vmla_vf_vf_vf_vf(u, s, vcast_vf_f(+0.1000000000e+1)); + + u = vldexp2_vf_vf_vi2(u, q); + + u = vsel_vf_vo_vf_vf(vgt_vo_vf_vf(d, vcast_vf_f(38.5318394191036238941387f)), vcast_vf_f(SLEEF_INFINITYf), u); + u = vreinterpret_vf_vm(vandnot_vm_vo32_vm(vlt_vo_vf_vf(d, vcast_vf_f(-50)), vreinterpret_vm_vf(u))); + + return u; +} + +EXPORT CONST VECTOR_CC vfloat xexpm1f(vfloat a) { + vfloat2 d = dfadd2_vf2_vf2_vf(expk2f(vcast_vf2_vf_vf(a, vcast_vf_f(0))), vcast_vf_f(-1.0)); + vfloat x = vadd_vf_vf_vf(vf2getx_vf_vf2(d), vf2gety_vf_vf2(d)); + x = vsel_vf_vo_vf_vf(vgt_vo_vf_vf(a, vcast_vf_f(88.72283172607421875f)), vcast_vf_f(SLEEF_INFINITYf), x); + x = vsel_vf_vo_vf_vf(vlt_vo_vf_vf(a, vcast_vf_f(-16.635532333438687426013570f)), vcast_vf_f(-1), x); + x = vsel_vf_vo_vf_vf(visnegzero_vo_vf(a), vcast_vf_f(-0.0f), x); + return x; +} +#endif // #if !defined(DETERMINISTIC) + +#if !defined(DETERMINISTIC) +EXPORT CONST VECTOR_CC vfloat xlog10f(vfloat d) { + vfloat2 x; + vfloat t, m, x2; + +#if !defined(ENABLE_AVX512F) && !defined(ENABLE_AVX512FNOFMA) + vopmask o = vlt_vo_vf_vf(d, vcast_vf_f(SLEEF_FLT_MIN)); + d = vsel_vf_vo_vf_vf(o, vmul_vf_vf_vf(d, vcast_vf_f((float)(INT64_C(1) << 32) * (float)(INT64_C(1) << 32))), d); + vint2 e = vilogb2k_vi2_vf(vmul_vf_vf_vf(d, vcast_vf_f(1.0/0.75))); + m = vldexp3_vf_vf_vi2(d, vneg_vi2_vi2(e)); + e = vsel_vi2_vo_vi2_vi2(o, vsub_vi2_vi2_vi2(e, vcast_vi2_i(64)), e); +#else + vfloat e = vgetexp_vf_vf(vmul_vf_vf_vf(d, vcast_vf_f(1.0/0.75))); + e = vsel_vf_vo_vf_vf(vispinf_vo_vf(e), vcast_vf_f(128.0f), e); + m = vgetmant_vf_vf(d); +#endif + + x = dfdiv_vf2_vf2_vf2(dfadd2_vf2_vf_vf(vcast_vf_f(-1), m), dfadd2_vf2_vf_vf(vcast_vf_f(1), m)); + x2 = vmul_vf_vf_vf(vf2getx_vf_vf2(x), vf2getx_vf_vf2(x)); + + t = vcast_vf_f(+0.1314289868e+0); + t = vmla_vf_vf_vf_vf(t, x2, vcast_vf_f( +0.1735493541e+0)); + t = vmla_vf_vf_vf_vf(t, x2, vcast_vf_f( +0.2895309627e+0)); + +#if !defined(ENABLE_AVX512F) && !defined(ENABLE_AVX512FNOFMA) + vfloat2 s = dfmul_vf2_vf2_vf(vcast_vf2_f_f(0.30103001, -1.432098889e-08), vcast_vf_vi2(e)); +#else + vfloat2 s = dfmul_vf2_vf2_vf(vcast_vf2_f_f(0.30103001, -1.432098889e-08), e); +#endif + + s = dfadd_vf2_vf2_vf2(s, dfmul_vf2_vf2_vf2(x, vcast_vf2_f_f(0.868588984, -2.170757285e-08))); + s = dfadd_vf2_vf2_vf(s, vmul_vf_vf_vf(vmul_vf_vf_vf(x2, vf2getx_vf_vf2(x)), t)); + + vfloat r = vadd_vf_vf_vf(vf2getx_vf_vf2(s), vf2gety_vf_vf2(s)); + +#if !defined(ENABLE_AVX512F) && !defined(ENABLE_AVX512FNOFMA) + r = vsel_vf_vo_vf_vf(vispinf_vo_vf(d), vcast_vf_f(SLEEF_INFINITY), r); + r = vsel_vf_vo_vf_vf(vor_vo_vo_vo(vlt_vo_vf_vf(d, vcast_vf_f(0)), visnan_vo_vf(d)), vcast_vf_f(SLEEF_NAN), r); + r = vsel_vf_vo_vf_vf(veq_vo_vf_vf(d, vcast_vf_f(0)), vcast_vf_f(-SLEEF_INFINITY), r); +#else + r = vfixup_vf_vf_vf_vi2_i(r, d, vcast_vi2_i((4 << (2*4)) | (3 << (4*4)) | (5 << (5*4)) | (2 << (6*4))), 0); +#endif + + return r; +} + +EXPORT CONST VECTOR_CC vfloat xlog2f(vfloat d) { + vfloat2 x; + vfloat t, m, x2; + +#if !defined(ENABLE_AVX512F) && !defined(ENABLE_AVX512FNOFMA) + vopmask o = vlt_vo_vf_vf(d, vcast_vf_f(SLEEF_FLT_MIN)); + d = vsel_vf_vo_vf_vf(o, vmul_vf_vf_vf(d, vcast_vf_f((float)(INT64_C(1) << 32) * (float)(INT64_C(1) << 32))), d); + vint2 e = vilogb2k_vi2_vf(vmul_vf_vf_vf(d, vcast_vf_f(1.0/0.75))); + m = vldexp3_vf_vf_vi2(d, vneg_vi2_vi2(e)); + e = vsel_vi2_vo_vi2_vi2(o, vsub_vi2_vi2_vi2(e, vcast_vi2_i(64)), e); +#else + vfloat e = vgetexp_vf_vf(vmul_vf_vf_vf(d, vcast_vf_f(1.0/0.75))); + e = vsel_vf_vo_vf_vf(vispinf_vo_vf(e), vcast_vf_f(128.0f), e); + m = vgetmant_vf_vf(d); +#endif + + x = dfdiv_vf2_vf2_vf2(dfadd2_vf2_vf_vf(vcast_vf_f(-1), m), dfadd2_vf2_vf_vf(vcast_vf_f(1), m)); + x2 = vmul_vf_vf_vf(vf2getx_vf_vf2(x), vf2getx_vf_vf2(x)); + + t = vcast_vf_f(+0.4374550283e+0f); + t = vmla_vf_vf_vf_vf(t, x2, vcast_vf_f(+0.5764790177e+0f)); + t = vmla_vf_vf_vf_vf(t, x2, vcast_vf_f(+0.9618012905120f)); + +#if !defined(ENABLE_AVX512F) && !defined(ENABLE_AVX512FNOFMA) + vfloat2 s = dfadd2_vf2_vf_vf2(vcast_vf_vi2(e), + dfmul_vf2_vf2_vf2(x, vcast_vf2_f_f(2.8853900432586669922, 3.2734474483568488616e-08))); +#else + vfloat2 s = dfadd2_vf2_vf_vf2(e, + dfmul_vf2_vf2_vf2(x, vcast_vf2_f_f(2.8853900432586669922, 3.2734474483568488616e-08))); +#endif + + s = dfadd2_vf2_vf2_vf(s, vmul_vf_vf_vf(vmul_vf_vf_vf(x2, vf2getx_vf_vf2(x)), t)); + + vfloat r = vadd_vf_vf_vf(vf2getx_vf_vf2(s), vf2gety_vf_vf2(s)); + +#if !defined(ENABLE_AVX512F) && !defined(ENABLE_AVX512FNOFMA) + r = vsel_vf_vo_vf_vf(vispinf_vo_vf(d), vcast_vf_f(SLEEF_INFINITY), r); + r = vsel_vf_vo_vf_vf(vor_vo_vo_vo(vlt_vo_vf_vf(d, vcast_vf_f(0)), visnan_vo_vf(d)), vcast_vf_f(SLEEF_NAN), r); + r = vsel_vf_vo_vf_vf(veq_vo_vf_vf(d, vcast_vf_f(0)), vcast_vf_f(-SLEEF_INFINITY), r); +#else + r = vfixup_vf_vf_vf_vi2_i(r, d, vcast_vi2_i((4 << (2*4)) | (3 << (4*4)) | (5 << (5*4)) | (2 << (6*4))), 0); +#endif + + return r; +} + +EXPORT CONST VECTOR_CC vfloat xlog2f_u35(vfloat d) { + vfloat m, t, x, x2; + +#if !defined(ENABLE_AVX512F) && !defined(ENABLE_AVX512FNOFMA) + vopmask o = vlt_vo_vf_vf(d, vcast_vf_f(SLEEF_FLT_MIN)); + d = vsel_vf_vo_vf_vf(o, vmul_vf_vf_vf(d, vcast_vf_f((float)(INT64_C(1) << 32) * (float)(INT64_C(1) << 32))), d); + vint2 e = vilogb2k_vi2_vf(vmul_vf_vf_vf(d, vcast_vf_f(1.0/0.75))); + m = vldexp3_vf_vf_vi2(d, vneg_vi2_vi2(e)); + e = vsel_vi2_vo_vi2_vi2(o, vsub_vi2_vi2_vi2(e, vcast_vi2_i(64)), e); +#else + vfloat e = vgetexp_vf_vf(vmul_vf_vf_vf(d, vcast_vf_f(1.0/0.75))); + e = vsel_vf_vo_vf_vf(vispinf_vo_vf(e), vcast_vf_f(128.0f), e); + m = vgetmant_vf_vf(d); +#endif + + x = vdiv_vf_vf_vf(vsub_vf_vf_vf(m, vcast_vf_f(1)), vadd_vf_vf_vf(m, vcast_vf_f(1))); + x2 = vmul_vf_vf_vf(x, x); + + t = vcast_vf_f(+0.4374088347e+0); + t = vmla_vf_vf_vf_vf(t, x2, vcast_vf_f(+0.5764843822e+0)); + t = vmla_vf_vf_vf_vf(t, x2, vcast_vf_f(+0.9618024230e+0)); + +#if !defined(ENABLE_AVX512F) && !defined(ENABLE_AVX512FNOFMA) + vfloat r = vmla_vf_vf_vf_vf(vmul_vf_vf_vf(x2, x), t, + vmla_vf_vf_vf_vf(x, vcast_vf_f(+0.2885390043e+1), vcast_vf_vi2(e))); + + r = vsel_vf_vo_vf_vf(vispinf_vo_vf(d), vcast_vf_f(SLEEF_INFINITY), r); + r = vsel_vf_vo_vf_vf(vor_vo_vo_vo(vlt_vo_vf_vf(d, vcast_vf_f(0)), visnan_vo_vf(d)), vcast_vf_f(SLEEF_NAN), r); + r = vsel_vf_vo_vf_vf(veq_vo_vf_vf(d, vcast_vf_f(0)), vcast_vf_f(-SLEEF_INFINITY), r); +#else + vfloat r = vmla_vf_vf_vf_vf(vmul_vf_vf_vf(x2, x), t, + vmla_vf_vf_vf_vf(x, vcast_vf_f(+0.2885390043e+1), e)); + + r = vfixup_vf_vf_vf_vi2_i(r, d, vcast_vi2_i((4 << (2*4)) | (3 << (4*4)) | (5 << (5*4)) | (2 << (6*4))), 0); +#endif + + return r; +} + +EXPORT CONST VECTOR_CC vfloat xlog1pf(vfloat d) { + vfloat2 x; + vfloat t, m, x2; + + vfloat dp1 = vadd_vf_vf_vf(d, vcast_vf_f(1)); + +#if !defined(ENABLE_AVX512F) && !defined(ENABLE_AVX512FNOFMA) + vopmask o = vlt_vo_vf_vf(dp1, vcast_vf_f(SLEEF_FLT_MIN)); + dp1 = vsel_vf_vo_vf_vf(o, vmul_vf_vf_vf(dp1, vcast_vf_f((float)(INT64_C(1) << 32) * (float)(INT64_C(1) << 32))), dp1); + vint2 e = vilogb2k_vi2_vf(vmul_vf_vf_vf(dp1, vcast_vf_f(1.0f/0.75f))); + t = vldexp3_vf_vf_vi2(vcast_vf_f(1), vneg_vi2_vi2(e)); + m = vmla_vf_vf_vf_vf(d, t, vsub_vf_vf_vf(t, vcast_vf_f(1))); + e = vsel_vi2_vo_vi2_vi2(o, vsub_vi2_vi2_vi2(e, vcast_vi2_i(64)), e); + vfloat2 s = dfmul_vf2_vf2_vf(vcast_vf2_f_f(0.69314718246459960938f, -1.904654323148236017e-09f), vcast_vf_vi2(e)); +#else + vfloat e = vgetexp_vf_vf(vmul_vf_vf_vf(dp1, vcast_vf_f(1.0f/0.75f))); + e = vsel_vf_vo_vf_vf(vispinf_vo_vf(e), vcast_vf_f(128.0f), e); + t = vldexp3_vf_vf_vi2(vcast_vf_f(1), vneg_vi2_vi2(vrint_vi2_vf(e))); + m = vmla_vf_vf_vf_vf(d, t, vsub_vf_vf_vf(t, vcast_vf_f(1))); + vfloat2 s = dfmul_vf2_vf2_vf(vcast_vf2_f_f(0.69314718246459960938f, -1.904654323148236017e-09f), e); +#endif + + x = dfdiv_vf2_vf2_vf2(vcast_vf2_vf_vf(m, vcast_vf_f(0)), dfadd_vf2_vf_vf(vcast_vf_f(2), m)); + x2 = vmul_vf_vf_vf(vf2getx_vf_vf2(x), vf2getx_vf_vf2(x)); + + t = vcast_vf_f(+0.3027294874e+0f); + t = vmla_vf_vf_vf_vf(t, x2, vcast_vf_f(+0.3996108174e+0f)); + t = vmla_vf_vf_vf_vf(t, x2, vcast_vf_f(+0.6666694880e+0f)); + + s = dfadd_vf2_vf2_vf2(s, dfscale_vf2_vf2_vf(x, vcast_vf_f(2))); + s = dfadd_vf2_vf2_vf(s, vmul_vf_vf_vf(vmul_vf_vf_vf(x2, vf2getx_vf_vf2(x)), t)); + + vfloat r = vadd_vf_vf_vf(vf2getx_vf_vf2(s), vf2gety_vf_vf2(s)); + + r = vsel_vf_vo_vf_vf(vgt_vo_vf_vf(d, vcast_vf_f(1e+38)), vcast_vf_f(SLEEF_INFINITYf), r); + r = vreinterpret_vf_vm(vor_vm_vo32_vm(vgt_vo_vf_vf(vcast_vf_f(-1), d), vreinterpret_vm_vf(r))); + r = vsel_vf_vo_vf_vf(veq_vo_vf_vf(d, vcast_vf_f(-1)), vcast_vf_f(-SLEEF_INFINITYf), r); + r = vsel_vf_vo_vf_vf(visnegzero_vo_vf(d), vcast_vf_f(-0.0f), r); + + return r; +} +#endif // #if !defined(DETERMINISTIC) + +// + +#if !defined(DETERMINISTIC) +EXPORT CONST VECTOR_CC vfloat xfabsf(vfloat x) { return vabs_vf_vf(x); } + +EXPORT CONST VECTOR_CC vfloat xcopysignf(vfloat x, vfloat y) { return vcopysign_vf_vf_vf(x, y); } + +EXPORT CONST VECTOR_CC vfloat xfmaxf(vfloat x, vfloat y) { +#if (defined(__x86_64__) || defined(__i386__)) && !defined(ENABLE_VECEXT) && !defined(ENABLE_PUREC) + return vsel_vf_vo_vf_vf(visnan_vo_vf(y), x, vmax_vf_vf_vf(x, y)); +#else + return vsel_vf_vo_vf_vf(visnan_vo_vf(y), x, vsel_vf_vo_vf_vf(vgt_vo_vf_vf(x, y), x, y)); +#endif +} + +EXPORT CONST VECTOR_CC vfloat xfminf(vfloat x, vfloat y) { +#if (defined(__x86_64__) || defined(__i386__)) && !defined(ENABLE_VECEXT) && !defined(ENABLE_PUREC) + return vsel_vf_vo_vf_vf(visnan_vo_vf(y), x, vmin_vf_vf_vf(x, y)); +#else + return vsel_vf_vo_vf_vf(visnan_vo_vf(y), x, vsel_vf_vo_vf_vf(vgt_vo_vf_vf(y, x), x, y)); +#endif +} + +EXPORT CONST VECTOR_CC vfloat xfdimf(vfloat x, vfloat y) { + vfloat ret = vsub_vf_vf_vf(x, y); + ret = vsel_vf_vo_vf_vf(vor_vo_vo_vo(vlt_vo_vf_vf(ret, vcast_vf_f(0)), veq_vo_vf_vf(x, y)), vcast_vf_f(0), ret); + return ret; +} + +EXPORT CONST VECTOR_CC vfloat xtruncf(vfloat x) { +#ifdef FULL_FP_ROUNDING + return vtruncate_vf_vf(x); +#else + vfloat fr = vsub_vf_vf_vf(x, vcast_vf_vi2(vtruncate_vi2_vf(x))); + return vsel_vf_vo_vf_vf(vor_vo_vo_vo(visinf_vo_vf(x), vge_vo_vf_vf(vabs_vf_vf(x), vcast_vf_f(INT64_C(1) << 23))), x, vcopysign_vf_vf_vf(vsub_vf_vf_vf(x, fr), x)); +#endif +} + +EXPORT CONST VECTOR_CC vfloat xfloorf(vfloat x) { + vfloat fr = vsub_vf_vf_vf(x, vcast_vf_vi2(vtruncate_vi2_vf(x))); + fr = vsel_vf_vo_vf_vf(vlt_vo_vf_vf(fr, vcast_vf_f(0)), vadd_vf_vf_vf(fr, vcast_vf_f(1.0f)), fr); + return vsel_vf_vo_vf_vf(vor_vo_vo_vo(visinf_vo_vf(x), vge_vo_vf_vf(vabs_vf_vf(x), vcast_vf_f(INT64_C(1) << 23))), x, vcopysign_vf_vf_vf(vsub_vf_vf_vf(x, fr), x)); +} + +EXPORT CONST VECTOR_CC vfloat xceilf(vfloat x) { + vfloat fr = vsub_vf_vf_vf(x, vcast_vf_vi2(vtruncate_vi2_vf(x))); + fr = vsel_vf_vo_vf_vf(vle_vo_vf_vf(fr, vcast_vf_f(0)), fr, vsub_vf_vf_vf(fr, vcast_vf_f(1.0f))); + return vsel_vf_vo_vf_vf(vor_vo_vo_vo(visinf_vo_vf(x), vge_vo_vf_vf(vabs_vf_vf(x), vcast_vf_f(INT64_C(1) << 23))), x, vcopysign_vf_vf_vf(vsub_vf_vf_vf(x, fr), x)); +} + +EXPORT CONST VECTOR_CC vfloat xroundf(vfloat d) { + vfloat x = vadd_vf_vf_vf(d, vcast_vf_f(0.5f)); + vfloat fr = vsub_vf_vf_vf(x, vcast_vf_vi2(vtruncate_vi2_vf(x))); + x = vsel_vf_vo_vf_vf(vand_vo_vo_vo(vle_vo_vf_vf(x, vcast_vf_f(0)), veq_vo_vf_vf(fr, vcast_vf_f(0))), vsub_vf_vf_vf(x, vcast_vf_f(1.0f)), x); + fr = vsel_vf_vo_vf_vf(vlt_vo_vf_vf(fr, vcast_vf_f(0)), vadd_vf_vf_vf(fr, vcast_vf_f(1.0f)), fr); + x = vsel_vf_vo_vf_vf(veq_vo_vf_vf(d, vcast_vf_f(0.4999999701976776123f)), vcast_vf_f(0), x); + return vsel_vf_vo_vf_vf(vor_vo_vo_vo(visinf_vo_vf(d), vge_vo_vf_vf(vabs_vf_vf(d), vcast_vf_f(INT64_C(1) << 23))), d, vcopysign_vf_vf_vf(vsub_vf_vf_vf(x, fr), d)); +} + +EXPORT CONST VECTOR_CC vfloat xrintf(vfloat d) { +#ifdef FULL_FP_ROUNDING + return vrint_vf_vf(d); +#else + vfloat c = vmulsign_vf_vf_vf(vcast_vf_f(1 << 23), d); + return vsel_vf_vo_vf_vf(vgt_vo_vf_vf(vabs_vf_vf(d), vcast_vf_f(1 << 23)), + d, vorsign_vf_vf_vf(vsub_vf_vf_vf(vadd_vf_vf_vf(d, c), c), d)); +#endif +} + +EXPORT CONST VECTOR_CC vfloat xfmaf(vfloat x, vfloat y, vfloat z) { +#ifdef ENABLE_FMA_SP + return vfma_vf_vf_vf_vf(x, y, z); +#else + vfloat h2 = vadd_vf_vf_vf(vmul_vf_vf_vf(x, y), z), q = vcast_vf_f(1); + vopmask o = vlt_vo_vf_vf(vabs_vf_vf(h2), vcast_vf_f(1e-38f)); + { + const float c0 = UINT64_C(1) << 25, c1 = c0 * c0, c2 = c1 * c1; + x = vsel_vf_vo_vf_vf(o, vmul_vf_vf_vf(x, vcast_vf_f(c1)), x); + y = vsel_vf_vo_vf_vf(o, vmul_vf_vf_vf(y, vcast_vf_f(c1)), y); + z = vsel_vf_vo_vf_vf(o, vmul_vf_vf_vf(z, vcast_vf_f(c2)), z); + q = vsel_vf_vo_vf_vf(o, vcast_vf_f(1.0f / c2), q); + } + o = vgt_vo_vf_vf(vabs_vf_vf(h2), vcast_vf_f(1e+38f)); + { + const float c0 = UINT64_C(1) << 25, c1 = c0 * c0, c2 = c1 * c1; + x = vsel_vf_vo_vf_vf(o, vmul_vf_vf_vf(x, vcast_vf_f(1.0f / c1)), x); + y = vsel_vf_vo_vf_vf(o, vmul_vf_vf_vf(y, vcast_vf_f(1.0f / c1)), y); + z = vsel_vf_vo_vf_vf(o, vmul_vf_vf_vf(z, vcast_vf_f(1.0f / c2)), z); + q = vsel_vf_vo_vf_vf(o, vcast_vf_f(c2), q); + } + vfloat2 d = dfmul_vf2_vf_vf(x, y); + d = dfadd2_vf2_vf2_vf(d, z); + vfloat ret = vsel_vf_vo_vf_vf(vor_vo_vo_vo(veq_vo_vf_vf(x, vcast_vf_f(0)), veq_vo_vf_vf(y, vcast_vf_f(0))), z, vadd_vf_vf_vf(vf2getx_vf_vf2(d), vf2gety_vf_vf2(d))); + o = visinf_vo_vf(z); + o = vandnot_vo_vo_vo(visinf_vo_vf(x), o); + o = vandnot_vo_vo_vo(visnan_vo_vf(x), o); + o = vandnot_vo_vo_vo(visinf_vo_vf(y), o); + o = vandnot_vo_vo_vo(visnan_vo_vf(y), o); + h2 = vsel_vf_vo_vf_vf(o, z, h2); + + o = vor_vo_vo_vo(visinf_vo_vf(h2), visnan_vo_vf(h2)); + + return vsel_vf_vo_vf_vf(o, h2, vmul_vf_vf_vf(ret, q)); +#endif +} +#endif // #if !defined(DETERMINISTIC) + +SQRTFU05_FUNCATR VECTOR_CC vfloat xsqrtf_u05(vfloat d) { +#if defined(ENABLE_FMA_SP) + vfloat q, w, x, y, z; + + d = vsel_vf_vo_vf_vf(vlt_vo_vf_vf(d, vcast_vf_f(0)), vcast_vf_f(SLEEF_NANf), d); + + vopmask o = vlt_vo_vf_vf(d, vcast_vf_f(5.2939559203393770e-23f)); + d = vsel_vf_vo_vf_vf(o, vmul_vf_vf_vf(d, vcast_vf_f(1.8889465931478580e+22f)), d); + q = vsel_vf_vo_vf_vf(o, vcast_vf_f(7.2759576141834260e-12f), vcast_vf_f(1.0f)); + + y = vreinterpret_vf_vi2(vsub_vi2_vi2_vi2(vcast_vi2_i(0x5f3759df), vsrl_vi2_vi2_i(vreinterpret_vi2_vf(d), 1))); + + x = vmul_vf_vf_vf(d, y); w = vmul_vf_vf_vf(vcast_vf_f(0.5), y); + y = vfmanp_vf_vf_vf_vf(x, w, vcast_vf_f(0.5)); + x = vfma_vf_vf_vf_vf(x, y, x); w = vfma_vf_vf_vf_vf(w, y, w); + y = vfmanp_vf_vf_vf_vf(x, w, vcast_vf_f(0.5)); + x = vfma_vf_vf_vf_vf(x, y, x); w = vfma_vf_vf_vf_vf(w, y, w); + + y = vfmanp_vf_vf_vf_vf(x, w, vcast_vf_f(1.5)); w = vadd_vf_vf_vf(w, w); + w = vmul_vf_vf_vf(w, y); + x = vmul_vf_vf_vf(w, d); + y = vfmapn_vf_vf_vf_vf(w, d, x); z = vfmanp_vf_vf_vf_vf(w, x, vcast_vf_f(1)); + + z = vfmanp_vf_vf_vf_vf(w, y, z); w = vmul_vf_vf_vf(vcast_vf_f(0.5), x); + w = vfma_vf_vf_vf_vf(w, z, y); + w = vadd_vf_vf_vf(w, x); + + w = vmul_vf_vf_vf(w, q); + + w = vsel_vf_vo_vf_vf(vor_vo_vo_vo(veq_vo_vf_vf(d, vcast_vf_f(0)), + veq_vo_vf_vf(d, vcast_vf_f(SLEEF_INFINITYf))), d, w); + + w = vsel_vf_vo_vf_vf(vlt_vo_vf_vf(d, vcast_vf_f(0)), vcast_vf_f(SLEEF_NANf), w); + + return w; +#else + vfloat q; + vopmask o; + + d = vsel_vf_vo_vf_vf(vlt_vo_vf_vf(d, vcast_vf_f(0)), vcast_vf_f(SLEEF_NANf), d); + + o = vlt_vo_vf_vf(d, vcast_vf_f(5.2939559203393770e-23f)); + d = vsel_vf_vo_vf_vf(o, vmul_vf_vf_vf(d, vcast_vf_f(1.8889465931478580e+22f)), d); + q = vsel_vf_vo_vf_vf(o, vcast_vf_f(7.2759576141834260e-12f*0.5f), vcast_vf_f(0.5f)); + + o = vgt_vo_vf_vf(d, vcast_vf_f(1.8446744073709552e+19f)); + d = vsel_vf_vo_vf_vf(o, vmul_vf_vf_vf(d, vcast_vf_f(5.4210108624275220e-20f)), d); + q = vsel_vf_vo_vf_vf(o, vcast_vf_f(4294967296.0f * 0.5f), q); + + vfloat x = vreinterpret_vf_vi2(vsub_vi2_vi2_vi2(vcast_vi2_i(0x5f375a86), vsrl_vi2_vi2_i(vreinterpret_vi2_vf(vadd_vf_vf_vf(d, vcast_vf_f(1e-45f))), 1))); + + x = vmul_vf_vf_vf(x, vsub_vf_vf_vf(vcast_vf_f(1.5f), vmul_vf_vf_vf(vmul_vf_vf_vf(vmul_vf_vf_vf(vcast_vf_f(0.5f), d), x), x))); + x = vmul_vf_vf_vf(x, vsub_vf_vf_vf(vcast_vf_f(1.5f), vmul_vf_vf_vf(vmul_vf_vf_vf(vmul_vf_vf_vf(vcast_vf_f(0.5f), d), x), x))); + x = vmul_vf_vf_vf(x, vsub_vf_vf_vf(vcast_vf_f(1.5f), vmul_vf_vf_vf(vmul_vf_vf_vf(vmul_vf_vf_vf(vcast_vf_f(0.5f), d), x), x))); + x = vmul_vf_vf_vf(x, d); + + vfloat2 d2 = dfmul_vf2_vf2_vf2(dfadd2_vf2_vf_vf2(d, dfmul_vf2_vf_vf(x, x)), dfrec_vf2_vf(x)); + + x = vmul_vf_vf_vf(vadd_vf_vf_vf(vf2getx_vf_vf2(d2), vf2gety_vf_vf2(d2)), q); + + x = vsel_vf_vo_vf_vf(vispinf_vo_vf(d), vcast_vf_f(SLEEF_INFINITYf), x); + x = vsel_vf_vo_vf_vf(veq_vo_vf_vf(d, vcast_vf_f(0)), d, x); + + return x; +#endif +} + +EXPORT CONST VECTOR_CC vfloat xsqrtf(vfloat d) { +#ifdef ACCURATE_SQRT + return vsqrt_vf_vf(d); +#else + // fall back to approximation if ACCURATE_SQRT is undefined + return xsqrtf_u05(d); +#endif +} + +#if !defined(DETERMINISTIC) +EXPORT CONST VECTOR_CC vfloat xhypotf_u05(vfloat x, vfloat y) { + x = vabs_vf_vf(x); + y = vabs_vf_vf(y); + vfloat min = vmin_vf_vf_vf(x, y), n = min; + vfloat max = vmax_vf_vf_vf(x, y), d = max; + + vopmask o = vlt_vo_vf_vf(max, vcast_vf_f(SLEEF_FLT_MIN)); + n = vsel_vf_vo_vf_vf(o, vmul_vf_vf_vf(n, vcast_vf_f(UINT64_C(1) << 24)), n); + d = vsel_vf_vo_vf_vf(o, vmul_vf_vf_vf(d, vcast_vf_f(UINT64_C(1) << 24)), d); + + vfloat2 t = dfdiv_vf2_vf2_vf2(vcast_vf2_vf_vf(n, vcast_vf_f(0)), vcast_vf2_vf_vf(d, vcast_vf_f(0))); + t = dfmul_vf2_vf2_vf(dfsqrt_vf2_vf2(dfadd2_vf2_vf2_vf(dfsqu_vf2_vf2(t), vcast_vf_f(1))), max); + vfloat ret = vadd_vf_vf_vf(vf2getx_vf_vf2(t), vf2gety_vf_vf2(t)); + ret = vsel_vf_vo_vf_vf(visnan_vo_vf(ret), vcast_vf_f(SLEEF_INFINITYf), ret); + ret = vsel_vf_vo_vf_vf(veq_vo_vf_vf(min, vcast_vf_f(0)), max, ret); + ret = vsel_vf_vo_vf_vf(vor_vo_vo_vo(visnan_vo_vf(x), visnan_vo_vf(y)), vcast_vf_f(SLEEF_NANf), ret); + ret = vsel_vf_vo_vf_vf(vor_vo_vo_vo(veq_vo_vf_vf(x, vcast_vf_f(SLEEF_INFINITYf)), veq_vo_vf_vf(y, vcast_vf_f(SLEEF_INFINITYf))), vcast_vf_f(SLEEF_INFINITYf), ret); + + return ret; +} + +EXPORT CONST VECTOR_CC vfloat xhypotf_u35(vfloat x, vfloat y) { + x = vabs_vf_vf(x); + y = vabs_vf_vf(y); + vfloat min = vmin_vf_vf_vf(x, y); + vfloat max = vmax_vf_vf_vf(x, y); + + vfloat t = vdiv_vf_vf_vf(min, max); + vfloat ret = vmul_vf_vf_vf(max, vsqrt_vf_vf(vmla_vf_vf_vf_vf(t, t, vcast_vf_f(1)))); + ret = vsel_vf_vo_vf_vf(veq_vo_vf_vf(min, vcast_vf_f(0)), max, ret); + ret = vsel_vf_vo_vf_vf(vor_vo_vo_vo(visnan_vo_vf(x), visnan_vo_vf(y)), vcast_vf_f(SLEEF_NANf), ret); + ret = vsel_vf_vo_vf_vf(vor_vo_vo_vo(veq_vo_vf_vf(x, vcast_vf_f(SLEEF_INFINITYf)), veq_vo_vf_vf(y, vcast_vf_f(SLEEF_INFINITYf))), vcast_vf_f(SLEEF_INFINITYf), ret); + + return ret; +} + +EXPORT CONST VECTOR_CC vfloat xnextafterf(vfloat x, vfloat y) { + x = vsel_vf_vo_vf_vf(veq_vo_vf_vf(x, vcast_vf_f(0)), vmulsign_vf_vf_vf(vcast_vf_f(0), y), x); + vint2 xi2 = vreinterpret_vi2_vf(x); + vopmask c = vxor_vo_vo_vo(vsignbit_vo_vf(x), vge_vo_vf_vf(y, x)); + + xi2 = vsel_vi2_vo_vi2_vi2(c, vsub_vi2_vi2_vi2(vcast_vi2_i(0), vxor_vi2_vi2_vi2(xi2, vcast_vi2_i((int)(1U << 31)))), xi2); + + xi2 = vsel_vi2_vo_vi2_vi2(vneq_vo_vf_vf(x, y), vsub_vi2_vi2_vi2(xi2, vcast_vi2_i(1)), xi2); + + xi2 = vsel_vi2_vo_vi2_vi2(c, vsub_vi2_vi2_vi2(vcast_vi2_i(0), vxor_vi2_vi2_vi2(xi2, vcast_vi2_i((int)(1U << 31)))), xi2); + + vfloat ret = vreinterpret_vf_vi2(xi2); + + ret = vsel_vf_vo_vf_vf(vand_vo_vo_vo(veq_vo_vf_vf(ret, vcast_vf_f(0)), vneq_vo_vf_vf(x, vcast_vf_f(0))), + vmulsign_vf_vf_vf(vcast_vf_f(0), x), ret); + + ret = vsel_vf_vo_vf_vf(vand_vo_vo_vo(veq_vo_vf_vf(x, vcast_vf_f(0)), veq_vo_vf_vf(y, vcast_vf_f(0))), y, ret); + + ret = vsel_vf_vo_vf_vf(vor_vo_vo_vo(visnan_vo_vf(x), visnan_vo_vf(y)), vcast_vf_f(SLEEF_NANf), ret); + + return ret; +} + +EXPORT CONST VECTOR_CC vfloat xfrfrexpf(vfloat x) { + x = vsel_vf_vo_vf_vf(vlt_vo_vf_vf(vabs_vf_vf(x), vcast_vf_f(SLEEF_FLT_MIN)), vmul_vf_vf_vf(x, vcast_vf_f(UINT64_C(1) << 30)), x); + + vmask xm = vreinterpret_vm_vf(x); + xm = vand_vm_vm_vm(xm, vcast_vm_i_i(~0x7f800000U, ~0x7f800000U)); + xm = vor_vm_vm_vm (xm, vcast_vm_i_i( 0x3f000000U, 0x3f000000U)); + + vfloat ret = vreinterpret_vf_vm(xm); + + ret = vsel_vf_vo_vf_vf(visinf_vo_vf(x), vmulsign_vf_vf_vf(vcast_vf_f(SLEEF_INFINITYf), x), ret); + ret = vsel_vf_vo_vf_vf(veq_vo_vf_vf(x, vcast_vf_f(0)), x, ret); + + return ret; +} +#endif // #if !defined(DETERMINISTIC) + +EXPORT CONST VECTOR_CC vint2 xexpfrexpf(vfloat x) { + /* + x = vsel_vf_vo_vf_vf(vlt_vo_vf_vf(vabs_vf_vf(x), vcast_vf_f(SLEEF_FLT_MIN)), vmul_vf_vf_vf(x, vcast_vf_f(UINT64_C(1) << 63)), x); + + vint ret = vcastu_vi_vi2(vreinterpret_vi2_vf(x)); + ret = vsub_vi_vi_vi(vand_vi_vi_vi(vsrl_vi_vi_i(ret, 20), vcast_vi_i(0x7ff)), vcast_vi_i(0x3fe)); + + ret = vsel_vi_vo_vi_vi(vor_vo_vo_vo(vor_vo_vo_vo(veq_vo_vf_vf(x, vcast_vf_f(0)), visnan_vo_vf(x)), visinf_vo_vf(x)), vcast_vi_i(0), ret); + + return ret; + */ + return vcast_vi2_i(0); +} + +static INLINE CONST VECTOR_CC vfloat vtoward0_vf_vf(vfloat x) { + vfloat t = vreinterpret_vf_vi2(vsub_vi2_vi2_vi2(vreinterpret_vi2_vf(x), vcast_vi2_i(1))); + return vsel_vf_vo_vf_vf(veq_vo_vf_vf(x, vcast_vf_f(0)), vcast_vf_f(0), t); +} + +static INLINE CONST VECTOR_CC vfloat vptrunc_vf_vf(vfloat x) { +#ifdef FULL_FP_ROUNDING + return vtruncate_vf_vf(x); +#else + vfloat fr = vsub_vf_vf_vf(x, vcast_vf_vi2(vtruncate_vi2_vf(x))); + return vsel_vf_vo_vf_vf(vge_vo_vf_vf(vabs_vf_vf(x), vcast_vf_f(INT64_C(1) << 23)), x, vsub_vf_vf_vf(x, fr)); +#endif +} + +#if !defined(DETERMINISTIC) +EXPORT CONST VECTOR_CC vfloat xfmodf(vfloat x, vfloat y) { + vfloat nu = vabs_vf_vf(x), de = vabs_vf_vf(y), s = vcast_vf_f(1), q; + vopmask o = vlt_vo_vf_vf(de, vcast_vf_f(SLEEF_FLT_MIN)); + nu = vsel_vf_vo_vf_vf(o, vmul_vf_vf_vf(nu, vcast_vf_f(UINT64_C(1) << 25)), nu); + de = vsel_vf_vo_vf_vf(o, vmul_vf_vf_vf(de, vcast_vf_f(UINT64_C(1) << 25)), de); + s = vsel_vf_vo_vf_vf(o, vmul_vf_vf_vf(s , vcast_vf_f(1.0f / (UINT64_C(1) << 25))), s); + vfloat rde = vtoward0_vf_vf(vrec_vf_vf(de)); +#if defined(ENABLE_NEON32) || defined(ENABLE_NEON32VFPV4) + rde = vtoward0_vf_vf(rde); +#endif + vfloat2 r = vcast_vf2_vf_vf(nu, vcast_vf_f(0)); + + for(int i=0;i<8;i++) { // ceil(log2(FLT_MAX) / 22)+1 + q = vptrunc_vf_vf(vmul_vf_vf_vf(vtoward0_vf_vf(vf2getx_vf_vf2(r)), rde)); + q = vsel_vf_vo_vf_vf(vand_vo_vo_vo(vgt_vo_vf_vf(vmul_vf_vf_vf(vcast_vf_f(3), de), vf2getx_vf_vf2(r)), + vge_vo_vf_vf(vf2getx_vf_vf2(r), de)), + vcast_vf_f(2), q); + q = vsel_vf_vo_vf_vf(vand_vo_vo_vo(vgt_vo_vf_vf(vmul_vf_vf_vf(vcast_vf_f(2), de), vf2getx_vf_vf2(r)), + vge_vo_vf_vf(vf2getx_vf_vf2(r), de)), + vcast_vf_f(1), q); + r = dfnormalize_vf2_vf2(dfadd2_vf2_vf2_vf2(r, dfmul_vf2_vf_vf(vptrunc_vf_vf(q), vneg_vf_vf(de)))); + if (vtestallones_i_vo32(vlt_vo_vf_vf(vf2getx_vf_vf2(r), de))) break; + } + + vfloat ret = vmul_vf_vf_vf(vadd_vf_vf_vf(vf2getx_vf_vf2(r), vf2gety_vf_vf2(r)), s); + ret = vsel_vf_vo_vf_vf(veq_vo_vf_vf(vadd_vf_vf_vf(vf2getx_vf_vf2(r), vf2gety_vf_vf2(r)), de), vcast_vf_f(0), ret); + + ret = vmulsign_vf_vf_vf(ret, x); + + ret = vsel_vf_vo_vf_vf(vlt_vo_vf_vf(nu, de), x, ret); + ret = vsel_vf_vo_vf_vf(veq_vo_vf_vf(de, vcast_vf_f(0)), vcast_vf_f(SLEEF_NANf), ret); + + return ret; +} + +static INLINE CONST VECTOR_CC vfloat vrintfk2_vf_vf(vfloat d) { +#ifdef FULL_FP_ROUNDING + return vrint_vf_vf(d); +#else + vfloat c = vmulsign_vf_vf_vf(vcast_vf_f(1 << 23), d); + return vsel_vf_vo_vf_vf(vgt_vo_vf_vf(vabs_vf_vf(d), vcast_vf_f(1 << 23)), + d, vorsign_vf_vf_vf(vsub_vf_vf_vf(vadd_vf_vf_vf(d, c), c), d)); +#endif +} + +EXPORT CONST VECTOR_CC vfloat xremainderf(vfloat x, vfloat y) { + vfloat n = vabs_vf_vf(x), d = vabs_vf_vf(y), s = vcast_vf_f(1), q; + vopmask o = vlt_vo_vf_vf(d, vcast_vf_f(SLEEF_FLT_MIN*2)); + n = vsel_vf_vo_vf_vf(o, vmul_vf_vf_vf(n, vcast_vf_f(UINT64_C(1) << 25)), n); + d = vsel_vf_vo_vf_vf(o, vmul_vf_vf_vf(d, vcast_vf_f(UINT64_C(1) << 25)), d); + s = vsel_vf_vo_vf_vf(o, vmul_vf_vf_vf(s , vcast_vf_f(1.0f / (UINT64_C(1) << 25))), s); + vfloat2 r = vcast_vf2_vf_vf(n, vcast_vf_f(0)); + vfloat rd = vrec_vf_vf(d); + vopmask qisodd = vneq_vo_vf_vf(vcast_vf_f(0), vcast_vf_f(0)); + + for(int i=0;i<8;i++) { // ceil(log2(FLT_MAX) / 22)+1 + q = vrintfk2_vf_vf(vmul_vf_vf_vf(vf2getx_vf_vf2(r), rd)); + q = vsel_vf_vo_vf_vf(vlt_vo_vf_vf(vabs_vf_vf(vf2getx_vf_vf2(r)), vmul_vf_vf_vf(d, vcast_vf_f(1.5f))), vmulsign_vf_vf_vf(vcast_vf_f(1.0f), vf2getx_vf_vf2(r)), q); + q = vsel_vf_vo_vf_vf(vor_vo_vo_vo(vlt_vo_vf_vf(vabs_vf_vf(vf2getx_vf_vf2(r)), vmul_vf_vf_vf(d, vcast_vf_f(0.5f))), + vandnot_vo_vo_vo(qisodd, veq_vo_vf_vf(vabs_vf_vf(vf2getx_vf_vf2(r)), vmul_vf_vf_vf(d, vcast_vf_f(0.5f))))), + vcast_vf_f(0.0), q); + if (vtestallones_i_vo32(veq_vo_vf_vf(q, vcast_vf_f(0)))) break; + q = vsel_vf_vo_vf_vf(visinf_vo_vf(vmul_vf_vf_vf(q, vneg_vf_vf(d))), vadd_vf_vf_vf(q, vmulsign_vf_vf_vf(vcast_vf_f(-1), vf2getx_vf_vf2(r))), q); + qisodd = vxor_vo_vo_vo(qisodd, vand_vo_vo_vo(veq_vo_vi2_vi2(vand_vi2_vi2_vi2(vtruncate_vi2_vf(q), vcast_vi2_i(1)), vcast_vi2_i(1)), + vlt_vo_vf_vf(vabs_vf_vf(q), vcast_vf_f(1 << 24)))); + r = dfnormalize_vf2_vf2(dfadd2_vf2_vf2_vf2(r, dfmul_vf2_vf_vf(q, vneg_vf_vf(d)))); + } + + vfloat ret = vmul_vf_vf_vf(vadd_vf_vf_vf(vf2getx_vf_vf2(r), vf2gety_vf_vf2(r)), s); + ret = vmulsign_vf_vf_vf(ret, x); + ret = vsel_vf_vo_vf_vf(visinf_vo_vf(y), vsel_vf_vo_vf_vf(visinf_vo_vf(x), vcast_vf_f(SLEEF_NANf), x), ret); + ret = vsel_vf_vo_vf_vf(veq_vo_vf_vf(d, vcast_vf_f(0)), vcast_vf_f(SLEEF_NANf), ret); + return ret; +} +#endif // #if !defined(DETERMINISTIC) + +// + +static INLINE CONST VECTOR_CC vfloat2 sinpifk(vfloat d) { + vopmask o; + vfloat u, s, t; + vfloat2 x, s2; + + u = vmul_vf_vf_vf(d, vcast_vf_f(4.0)); + vint2 q = vtruncate_vi2_vf(u); + q = vand_vi2_vi2_vi2(vadd_vi2_vi2_vi2(q, vxor_vi2_vi2_vi2(vsrl_vi2_vi2_i(q, 31), vcast_vi2_i(1))), vcast_vi2_i(~1)); + o = veq_vo_vi2_vi2(vand_vi2_vi2_vi2(q, vcast_vi2_i(2)), vcast_vi2_i(2)); + + s = vsub_vf_vf_vf(u, vcast_vf_vi2(q)); + t = s; + s = vmul_vf_vf_vf(s, s); + s2 = dfmul_vf2_vf_vf(t, t); + + // + + u = vsel_vf_vo_f_f(o, -0.2430611801e-7f, +0.3093842054e-6f); + u = vmla_vf_vf_vf_vf(u, s, vsel_vf_vo_f_f(o, +0.3590577080e-5f, -0.3657307388e-4f)); + u = vmla_vf_vf_vf_vf(u, s, vsel_vf_vo_f_f(o, -0.3259917721e-3f, +0.2490393585e-2f)); + x = dfadd2_vf2_vf_vf2(vmul_vf_vf_vf(u, s), + vsel_vf2_vo_f_f_f_f(o, 0.015854343771934509277, 4.4940051354032242811e-10, + -0.080745510756969451904, -1.3373665339076936258e-09)); + x = dfadd2_vf2_vf2_vf2(dfmul_vf2_vf2_vf2(s2, x), + vsel_vf2_vo_f_f_f_f(o, -0.30842512845993041992, -9.0728339030733922277e-09, + 0.78539818525314331055, -2.1857338617566484855e-08)); + + x = dfmul_vf2_vf2_vf2(x, vsel_vf2_vo_vf2_vf2(o, s2, vcast_vf2_vf_vf(t, vcast_vf_f(0)))); + x = vsel_vf2_vo_vf2_vf2(o, dfadd2_vf2_vf2_vf(x, vcast_vf_f(1)), x); + + o = veq_vo_vi2_vi2(vand_vi2_vi2_vi2(q, vcast_vi2_i(4)), vcast_vi2_i(4)); + x = vf2setx_vf2_vf2_vf(x, vreinterpret_vf_vm(vxor_vm_vm_vm(vand_vm_vo32_vm(o, vreinterpret_vm_vf(vcast_vf_f(-0.0))), vreinterpret_vm_vf(vf2getx_vf_vf2(x))))); + x = vf2sety_vf2_vf2_vf(x, vreinterpret_vf_vm(vxor_vm_vm_vm(vand_vm_vo32_vm(o, vreinterpret_vm_vf(vcast_vf_f(-0.0))), vreinterpret_vm_vf(vf2gety_vf_vf2(x))))); + + return x; +} + +#if !defined(DETERMINISTIC) +EXPORT CONST VECTOR_CC vfloat xsinpif_u05(vfloat d) { + vfloat2 x = sinpifk(d); + vfloat r = vadd_vf_vf_vf(vf2getx_vf_vf2(x), vf2gety_vf_vf2(x)); + + r = vsel_vf_vo_vf_vf(visnegzero_vo_vf(d), vcast_vf_f(-0.0), r); + r = vreinterpret_vf_vm(vandnot_vm_vo32_vm(vgt_vo_vf_vf(vabs_vf_vf(d), vcast_vf_f(TRIGRANGEMAX4f)), vreinterpret_vm_vf(r))); + r = vreinterpret_vf_vm(vor_vm_vo32_vm(visinf_vo_vf(d), vreinterpret_vm_vf(r))); + + return r; +} +#endif // #if !defined(DETERMINISTIC) + +static INLINE CONST VECTOR_CC vfloat2 cospifk(vfloat d) { + vopmask o; + vfloat u, s, t; + vfloat2 x, s2; + + u = vmul_vf_vf_vf(d, vcast_vf_f(4.0)); + vint2 q = vtruncate_vi2_vf(u); + q = vand_vi2_vi2_vi2(vadd_vi2_vi2_vi2(q, vxor_vi2_vi2_vi2(vsrl_vi2_vi2_i(q, 31), vcast_vi2_i(1))), vcast_vi2_i(~1)); + o = veq_vo_vi2_vi2(vand_vi2_vi2_vi2(q, vcast_vi2_i(2)), vcast_vi2_i(0)); + + s = vsub_vf_vf_vf(u, vcast_vf_vi2(q)); + t = s; + s = vmul_vf_vf_vf(s, s); + s2 = dfmul_vf2_vf_vf(t, t); + + // + + u = vsel_vf_vo_f_f(o, -0.2430611801e-7f, +0.3093842054e-6f); + u = vmla_vf_vf_vf_vf(u, s, vsel_vf_vo_f_f(o, +0.3590577080e-5f, -0.3657307388e-4f)); + u = vmla_vf_vf_vf_vf(u, s, vsel_vf_vo_f_f(o, -0.3259917721e-3f, +0.2490393585e-2f)); + x = dfadd2_vf2_vf_vf2(vmul_vf_vf_vf(u, s), + vsel_vf2_vo_f_f_f_f(o, 0.015854343771934509277, 4.4940051354032242811e-10, + -0.080745510756969451904, -1.3373665339076936258e-09)); + x = dfadd2_vf2_vf2_vf2(dfmul_vf2_vf2_vf2(s2, x), + vsel_vf2_vo_f_f_f_f(o, -0.30842512845993041992, -9.0728339030733922277e-09, + 0.78539818525314331055, -2.1857338617566484855e-08)); + + x = dfmul_vf2_vf2_vf2(x, vsel_vf2_vo_vf2_vf2(o, s2, vcast_vf2_vf_vf(t, vcast_vf_f(0)))); + x = vsel_vf2_vo_vf2_vf2(o, dfadd2_vf2_vf2_vf(x, vcast_vf_f(1)), x); + + o = veq_vo_vi2_vi2(vand_vi2_vi2_vi2(vadd_vi2_vi2_vi2(q, vcast_vi2_i(2)), vcast_vi2_i(4)), vcast_vi2_i(4)); + x = vf2setx_vf2_vf2_vf(x, vreinterpret_vf_vm(vxor_vm_vm_vm(vand_vm_vo32_vm(o, vreinterpret_vm_vf(vcast_vf_f(-0.0))), vreinterpret_vm_vf(vf2getx_vf_vf2(x))))); + x = vf2sety_vf2_vf2_vf(x, vreinterpret_vf_vm(vxor_vm_vm_vm(vand_vm_vo32_vm(o, vreinterpret_vm_vf(vcast_vf_f(-0.0))), vreinterpret_vm_vf(vf2gety_vf_vf2(x))))); + + return x; +} + +#if !defined(DETERMINISTIC) +EXPORT CONST VECTOR_CC vfloat xcospif_u05(vfloat d) { + vfloat2 x = cospifk(d); + vfloat r = vadd_vf_vf_vf(vf2getx_vf_vf2(x), vf2gety_vf_vf2(x)); + + r = vsel_vf_vo_vf_vf(vgt_vo_vf_vf(vabs_vf_vf(d), vcast_vf_f(TRIGRANGEMAX4f)), vcast_vf_f(1), r); + r = vreinterpret_vf_vm(vor_vm_vo32_vm(visinf_vo_vf(d), vreinterpret_vm_vf(r))); + + return r; +} +#endif // #if !defined(DETERMINISTIC) + +#if !(defined(ENABLE_SVE) || defined(ENABLE_SVENOFMA) || defined(ENABLE_RVVM1) || defined(ENABLE_RVVM1NOFMA) || defined(ENABLE_RVVM2) || defined(ENABLE_RVVM2NOFMA)) + typedef struct { + vfloat2 a, b; + } df2; + +static df2 df2setab_df2_vf2_vf2(vfloat2 a, vfloat2 b) { + df2 r = { a, b }; + return r; +} +static vfloat2 df2geta_vf2_df2(df2 d) { return d.a; } +static vfloat2 df2getb_vf2_df2(df2 d) { return d.b; } +#endif + +/* TODO AArch64: potential optimization by using `vfmad_lane_f64` */ +static CONST df2 gammafk(vfloat a) { + vfloat2 clc = vcast_vf2_f_f(0, 0), clln = vcast_vf2_f_f(1, 0), clld = vcast_vf2_f_f(1, 0); + vfloat2 x, y, z; + vfloat t, u; + + vopmask otiny = vlt_vo_vf_vf(vabs_vf_vf(a), vcast_vf_f(1e-30f)), oref = vlt_vo_vf_vf(a, vcast_vf_f(0.5)); + + x = vsel_vf2_vo_vf2_vf2(otiny, vcast_vf2_f_f(0, 0), + vsel_vf2_vo_vf2_vf2(oref, dfadd2_vf2_vf_vf(vcast_vf_f(1), vneg_vf_vf(a)), + vcast_vf2_vf_vf(a, vcast_vf_f(0)))); + + vopmask o0 = vand_vo_vo_vo(vle_vo_vf_vf(vcast_vf_f(0.5), vf2getx_vf_vf2(x)), vle_vo_vf_vf(vf2getx_vf_vf2(x), vcast_vf_f(1.2))); + vopmask o2 = vle_vo_vf_vf(vcast_vf_f(2.3), vf2getx_vf_vf2(x)); + + y = dfnormalize_vf2_vf2(dfmul_vf2_vf2_vf2(dfadd2_vf2_vf2_vf(x, vcast_vf_f(1)), x)); + y = dfnormalize_vf2_vf2(dfmul_vf2_vf2_vf2(dfadd2_vf2_vf2_vf(x, vcast_vf_f(2)), y)); + + vopmask o = vand_vo_vo_vo(o2, vle_vo_vf_vf(vf2getx_vf_vf2(x), vcast_vf_f(7))); + clln = vsel_vf2_vo_vf2_vf2(o, y, clln); + + x = vsel_vf2_vo_vf2_vf2(o, dfadd2_vf2_vf2_vf(x, vcast_vf_f(3)), x); + t = vsel_vf_vo_vf_vf(o2, vrec_vf_vf(vf2getx_vf_vf2(x)), vf2getx_vf_vf2(dfnormalize_vf2_vf2(dfadd2_vf2_vf2_vf(x, vsel_vf_vo_f_f(o0, -1, -2))))); + + u = vsel_vf_vo_vo_f_f_f(o2, o0, +0.000839498720672087279971000786, +0.9435157776e+0f, +0.1102489550e-3f); + u = vmla_vf_vf_vf_vf(u, t, vsel_vf_vo_vo_f_f_f(o2, o0, -5.17179090826059219329394422e-05, +0.8670063615e+0f, +0.8160019934e-4f)); + u = vmla_vf_vf_vf_vf(u, t, vsel_vf_vo_vo_f_f_f(o2, o0, -0.000592166437353693882857342347, +0.4826702476e+0f, +0.1528468856e-3f)); + u = vmla_vf_vf_vf_vf(u, t, vsel_vf_vo_vo_f_f_f(o2, o0, +6.97281375836585777403743539e-05, -0.8855129778e-1f, -0.2355068718e-3f)); + u = vmla_vf_vf_vf_vf(u, t, vsel_vf_vo_vo_f_f_f(o2, o0, +0.000784039221720066627493314301, +0.1013825238e+0f, +0.4962242092e-3f)); + u = vmla_vf_vf_vf_vf(u, t, vsel_vf_vo_vo_f_f_f(o2, o0, -0.000229472093621399176949318732, -0.1493408978e+0f, -0.1193488017e-2f)); + u = vmla_vf_vf_vf_vf(u, t, vsel_vf_vo_vo_f_f_f(o2, o0, -0.002681327160493827160473958490, +0.1697509140e+0f, +0.2891599433e-2f)); + u = vmla_vf_vf_vf_vf(u, t, vsel_vf_vo_vo_f_f_f(o2, o0, +0.003472222222222222222175164840, -0.2072454542e+0f, -0.7385451812e-2f)); + u = vmla_vf_vf_vf_vf(u, t, vsel_vf_vo_vo_f_f_f(o2, o0, +0.083333333333333333335592087900, +0.2705872357e+0f, +0.2058077045e-1f)); + + y = dfmul_vf2_vf2_vf2(dfadd2_vf2_vf2_vf(x, vcast_vf_f(-0.5)), logk2f(x)); + y = dfadd2_vf2_vf2_vf2(y, dfneg_vf2_vf2(x)); + y = dfadd2_vf2_vf2_vf2(y, vcast_vf2_d(0.91893853320467278056)); // 0.5*log(2*M_PI) + + z = dfadd2_vf2_vf2_vf(dfmul_vf2_vf_vf (u, t), vsel_vf_vo_f_f(o0, -0.400686534596170958447352690395e+0f, -0.673523028297382446749257758235e-1f)); + z = dfadd2_vf2_vf2_vf(dfmul_vf2_vf2_vf(z, t), vsel_vf_vo_f_f(o0, +0.822466960142643054450325495997e+0f, +0.322467033928981157743538726901e+0f)); + z = dfadd2_vf2_vf2_vf(dfmul_vf2_vf2_vf(z, t), vsel_vf_vo_f_f(o0, -0.577215665946766039837398973297e+0f, +0.422784335087484338986941629852e+0f)); + z = dfmul_vf2_vf2_vf(z, t); + + clc = vsel_vf2_vo_vf2_vf2(o2, y, z); + + clld = vsel_vf2_vo_vf2_vf2(o2, dfadd2_vf2_vf2_vf(dfmul_vf2_vf_vf(u, t), vcast_vf_f(1)), clld); + + y = clln; + + clc = vsel_vf2_vo_vf2_vf2(otiny, vcast_vf2_d(41.58883083359671856503), // log(2^60) + vsel_vf2_vo_vf2_vf2(oref, dfadd2_vf2_vf2_vf2(vcast_vf2_d(1.1447298858494001639), dfneg_vf2_vf2(clc)), clc)); // log(M_PI) + clln = vsel_vf2_vo_vf2_vf2(otiny, vcast_vf2_f_f(1, 0), vsel_vf2_vo_vf2_vf2(oref, clln, clld)); + + if (!vtestallones_i_vo32(vnot_vo32_vo32(oref))) { + t = vsub_vf_vf_vf(a, vmul_vf_vf_vf(vcast_vf_f(INT64_C(1) << 12), vcast_vf_vi2(vtruncate_vi2_vf(vmul_vf_vf_vf(a, vcast_vf_f(1.0 / (INT64_C(1) << 12))))))); + x = dfmul_vf2_vf2_vf2(clld, sinpifk(t)); + } + + clld = vsel_vf2_vo_vf2_vf2(otiny, vcast_vf2_vf_vf(vmul_vf_vf_vf(a, vcast_vf_f((INT64_C(1) << 30)*(float)(INT64_C(1) << 30))), vcast_vf_f(0)), + vsel_vf2_vo_vf2_vf2(oref, x, y)); + + return df2setab_df2_vf2_vf2(clc, dfdiv_vf2_vf2_vf2(clln, clld)); +} + +#if !defined(DETERMINISTIC) +EXPORT CONST VECTOR_CC vfloat xtgammaf_u1(vfloat a) { + df2 d = gammafk(a); + vfloat2 y = dfmul_vf2_vf2_vf2(expk2f(df2geta_vf2_df2(d)), df2getb_vf2_df2(d)); + vfloat r = vadd_vf_vf_vf(vf2getx_vf_vf2(y), vf2gety_vf_vf2(y)); + vopmask o; + + o = vor_vo_vo_vo(vor_vo_vo_vo(veq_vo_vf_vf(a, vcast_vf_f(-SLEEF_INFINITYf)), + vand_vo_vo_vo(vlt_vo_vf_vf(a, vcast_vf_f(0)), visint_vo_vf(a))), + vand_vo_vo_vo(vand_vo_vo_vo(visnumber_vo_vf(a), vlt_vo_vf_vf(a, vcast_vf_f(0))), visnan_vo_vf(r))); + r = vsel_vf_vo_vf_vf(o, vcast_vf_f(SLEEF_NANf), r); + + o = vand_vo_vo_vo(vand_vo_vo_vo(vor_vo_vo_vo(veq_vo_vf_vf(a, vcast_vf_f(SLEEF_INFINITYf)), visnumber_vo_vf(a)), + vge_vo_vf_vf(a, vcast_vf_f(-SLEEF_FLT_MIN))), + vor_vo_vo_vo(vor_vo_vo_vo(veq_vo_vf_vf(a, vcast_vf_f(0)), vgt_vo_vf_vf(a, vcast_vf_f(36))), visnan_vo_vf(r))); + r = vsel_vf_vo_vf_vf(o, vmulsign_vf_vf_vf(vcast_vf_f(SLEEF_INFINITYf), a), r); + + return r; +} + +EXPORT CONST VECTOR_CC vfloat xlgammaf_u1(vfloat a) { + df2 d = gammafk(a); + vfloat2 y = dfadd2_vf2_vf2_vf2(df2geta_vf2_df2(d), logk2f(dfabs_vf2_vf2(df2getb_vf2_df2(d)))); + vfloat r = vadd_vf_vf_vf(vf2getx_vf_vf2(y), vf2gety_vf_vf2(y)); + vopmask o; + + o = vor_vo_vo_vo(visinf_vo_vf(a), + vor_vo_vo_vo(vand_vo_vo_vo(vle_vo_vf_vf(a, vcast_vf_f(0)), visint_vo_vf(a)), + vand_vo_vo_vo(visnumber_vo_vf(a), visnan_vo_vf(r)))); + r = vsel_vf_vo_vf_vf(o, vcast_vf_f(SLEEF_INFINITYf), r); + + return r; +} + +static INLINE CONST vfloat2 dfmla_vf2_vf_vf2_vf2(vfloat x, vfloat2 y, vfloat2 z) { + return dfadd_vf2_vf2_vf2(z, dfmul_vf2_vf2_vf(y, x)); +} + +static INLINE CONST vfloat2 poly2df_b(vfloat x, vfloat2 c1, vfloat2 c0) { return dfmla_vf2_vf_vf2_vf2(x, c1, c0); } +static INLINE CONST vfloat2 poly2df(vfloat x, vfloat c1, vfloat2 c0) { return dfmla_vf2_vf_vf2_vf2(x, vcast_vf2_vf_vf(c1, vcast_vf_f(0)), c0); } +static INLINE CONST vfloat2 poly4df(vfloat x, vfloat c3, vfloat2 c2, vfloat2 c1, vfloat2 c0) { + return dfmla_vf2_vf_vf2_vf2(vmul_vf_vf_vf(x, x), poly2df(x, c3, c2), poly2df_b(x, c1, c0)); +} + +EXPORT CONST VECTOR_CC vfloat xerff_u1(vfloat a) { + vfloat t, x = vabs_vf_vf(a); + vfloat2 t2; + vfloat x2 = vmul_vf_vf_vf(x, x), x4 = vmul_vf_vf_vf(x2, x2); + vopmask o25 = vle_vo_vf_vf(x, vcast_vf_f(2.5)); + + if (LIKELY(vtestallones_i_vo32(o25))) { + // Abramowitz and Stegun + t = POLY6(x, x2, x4, + -0.4360447008e-6, + +0.6867515367e-5, + -0.3045156700e-4, + +0.9808536561e-4, + +0.2395523916e-3, + +0.1459901541e-3); + t2 = poly4df(x, t, + vcast_vf2_f_f(0.0092883445322513580322, -2.7863745897025330755e-11), + vcast_vf2_f_f(0.042275499552488327026, 1.3461399289988106057e-09), + vcast_vf2_f_f(0.070523701608180999756, -3.6616309318707365163e-09)); + t2 = dfadd_vf2_vf_vf2(vcast_vf_f(1), dfmul_vf2_vf2_vf(t2, x)); + t2 = dfsqu_vf2_vf2(t2); + t2 = dfsqu_vf2_vf2(t2); + t2 = dfsqu_vf2_vf2(t2); + t2 = dfsqu_vf2_vf2(t2); + t2 = dfrec_vf2_vf2(t2); + } else { +#undef C2V +#define C2V(c) (c) + t = POLY6(x, x2, x4, + vsel_vf_vo_f_f(o25, -0.4360447008e-6, -0.1130012848e-6), + vsel_vf_vo_f_f(o25, +0.6867515367e-5, +0.4115272986e-5), + vsel_vf_vo_f_f(o25, -0.3045156700e-4, -0.6928304356e-4), + vsel_vf_vo_f_f(o25, +0.9808536561e-4, +0.7172692567e-3), + vsel_vf_vo_f_f(o25, +0.2395523916e-3, -0.5131045356e-2), + vsel_vf_vo_f_f(o25, +0.1459901541e-3, +0.2708637156e-1)); + t2 = poly4df(x, t, + vsel_vf2_vo_vf2_vf2(o25, vcast_vf2_f_f(0.0092883445322513580322, -2.7863745897025330755e-11), + vcast_vf2_f_f(-0.11064319312572479248, 3.7050452777225283007e-09)), + vsel_vf2_vo_vf2_vf2(o25, vcast_vf2_f_f(0.042275499552488327026, 1.3461399289988106057e-09), + vcast_vf2_f_f(-0.63192230463027954102, -2.0200432585073177859e-08)), + vsel_vf2_vo_vf2_vf2(o25, vcast_vf2_f_f(0.070523701608180999756, -3.6616309318707365163e-09), + vcast_vf2_f_f(-1.1296638250350952148, 2.5515120196453259252e-08))); + t2 = dfmul_vf2_vf2_vf(t2, x); + vfloat2 s2 = dfadd_vf2_vf_vf2(vcast_vf_f(1), t2); + s2 = dfsqu_vf2_vf2(s2); + s2 = dfsqu_vf2_vf2(s2); + s2 = dfsqu_vf2_vf2(s2); + s2 = dfsqu_vf2_vf2(s2); + s2 = dfrec_vf2_vf2(s2); + t2 = vsel_vf2_vo_vf2_vf2(o25, s2, vcast_vf2_vf_vf(expkf(t2), vcast_vf_f(0))); + } + + t2 = dfadd2_vf2_vf2_vf(t2, vcast_vf_f(-1)); + t2 = vsel_vf2_vo_vf2_vf2(vlt_vo_vf_vf(x, vcast_vf_f(1e-4)), dfmul_vf2_vf2_vf(vcast_vf2_f_f(-1.1283792257308959961, 5.8635383422197591097e-08), x), t2); + + vfloat z = vneg_vf_vf(vadd_vf_vf_vf(vf2getx_vf_vf2(t2), vf2gety_vf_vf2(t2))); + z = vsel_vf_vo_vf_vf(vge_vo_vf_vf(x, vcast_vf_f(6)), vcast_vf_f(1), z); + z = vsel_vf_vo_vf_vf(visinf_vo_vf(a), vcast_vf_f(1), z); + z = vsel_vf_vo_vf_vf(veq_vo_vf_vf(a, vcast_vf_f(0)), vcast_vf_f(0), z); + z = vmulsign_vf_vf_vf(z, a); + + return z; +} + +/* TODO AArch64: potential optimization by using `vfmad_lane_f64` */ +EXPORT CONST VECTOR_CC vfloat xerfcf_u15(vfloat a) { + vfloat s = a, r = vcast_vf_f(0), t; + vfloat2 u, d, x; + a = vabs_vf_vf(a); + vopmask o0 = vlt_vo_vf_vf(a, vcast_vf_f(1.0)); + vopmask o1 = vlt_vo_vf_vf(a, vcast_vf_f(2.2)); + vopmask o2 = vlt_vo_vf_vf(a, vcast_vf_f(4.3)); + vopmask o3 = vlt_vo_vf_vf(a, vcast_vf_f(10.1)); + + u = vsel_vf2_vo_vf2_vf2(o1, vcast_vf2_vf_vf(a, vcast_vf_f(0)), dfdiv_vf2_vf2_vf2(vcast_vf2_f_f(1, 0), vcast_vf2_vf_vf(a, vcast_vf_f(0)))); + + t = vsel_vf_vo_vo_vo_f_f_f_f(o0, o1, o2, -0.8638041618e-4f, -0.6236977242e-5f, -0.3869504035e+0f, +0.1115344167e+1f); + t = vmla_vf_vf_vf_vf(t, vf2getx_vf_vf2(u), vsel_vf_vo_vo_vo_f_f_f_f(o0, o1, o2, +0.6000166177e-3f, +0.5749821503e-4f, +0.1288077235e+1f, -0.9454904199e+0f)); + t = vmla_vf_vf_vf_vf(t, vf2getx_vf_vf2(u), vsel_vf_vo_vo_vo_f_f_f_f(o0, o1, o2, -0.1665703603e-2f, +0.6002851478e-5f, -0.1816803217e+1f, -0.3667259514e+0f)); + t = vmla_vf_vf_vf_vf(t, vf2getx_vf_vf2(u), vsel_vf_vo_vo_vo_f_f_f_f(o0, o1, o2, +0.1795156277e-3f, -0.2851036377e-2f, +0.1249150872e+1f, +0.7155663371e+0f)); + t = vmla_vf_vf_vf_vf(t, vf2getx_vf_vf2(u), vsel_vf_vo_vo_vo_f_f_f_f(o0, o1, o2, +0.1914106123e-1f, +0.2260518074e-1f, -0.1328857988e+0f, -0.1262947265e-1f)); + + d = dfmul_vf2_vf2_vf(u, t); + d = dfadd2_vf2_vf2_vf2(d, vsel_vf2_vo_vo_vo_d_d_d_d(o0, o1, o2, -0.102775359343930288081655368891e+0, -0.105247583459338632253369014063e+0, -0.482365310333045318680618892669e+0, -0.498961546254537647970305302739e+0)); + d = dfmul_vf2_vf2_vf2(d, u); + d = dfadd2_vf2_vf2_vf2(d, vsel_vf2_vo_vo_vo_d_d_d_d(o0, o1, o2, -0.636619483208481931303752546439e+0, -0.635609463574589034216723775292e+0, -0.134450203224533979217859332703e-2, -0.471199543422848492080722832666e-4)); + d = dfmul_vf2_vf2_vf2(d, u); + d = dfadd2_vf2_vf2_vf2(d, vsel_vf2_vo_vo_vo_d_d_d_d(o0, o1, o2, -0.112837917790537404939545770596e+1, -0.112855987376668622084547028949e+1, -0.572319781150472949561786101080e+0, -0.572364030327966044425932623525e+0)); + + x = dfmul_vf2_vf2_vf(vsel_vf2_vo_vf2_vf2(o1, d, vcast_vf2_vf_vf(vneg_vf_vf(a), vcast_vf_f(0))), a); + x = vsel_vf2_vo_vf2_vf2(o1, x, dfadd2_vf2_vf2_vf2(x, d)); + + x = expk2f(x); + x = vsel_vf2_vo_vf2_vf2(o1, x, dfmul_vf2_vf2_vf2(x, u)); + + r = vsel_vf_vo_vf_vf(o3, vadd_vf_vf_vf(vf2getx_vf_vf2(x), vf2gety_vf_vf2(x)), vcast_vf_f(0)); + r = vsel_vf_vo_vf_vf(vsignbit_vo_vf(s), vsub_vf_vf_vf(vcast_vf_f(2), r), r); + r = vsel_vf_vo_vf_vf(visnan_vo_vf(s), vcast_vf_f(SLEEF_NANf), r); + return r; +} +#endif // #if !defined(DETERMINISTIC) + +#if !defined(DETERMINISTIC) && !defined(ENABLE_GNUABI) && !defined(SLEEF_GENHEADER) +// See sleefsimddp.c for explanation of these macros + +#ifdef ENABLE_ALIAS +#define DALIAS_vf_vf(FUNC) EXPORT CONST VECTOR_CC vfloat y ## FUNC(vfloat) __attribute__((alias( stringify(x ## FUNC) ))); +#define DALIAS_vf2_vf(FUNC) EXPORT CONST VECTOR_CC vfloat2 y ## FUNC(vfloat) __attribute__((alias( stringify(x ## FUNC) ))); +#define DALIAS_vf_vf_vf(FUNC) EXPORT CONST VECTOR_CC vfloat y ## FUNC(vfloat, vfloat) __attribute__((alias( stringify(x ## FUNC) ))); +#define DALIAS_vf_vf_vf_vf(FUNC) EXPORT CONST VECTOR_CC vfloat y ## FUNC(vfloat, vfloat, vfloat) __attribute__((alias( stringify(x ## FUNC) ))); +#else +#define DALIAS_vf_vf(FUNC) EXPORT CONST VECTOR_CC vfloat y ## FUNC(vfloat d) { return x ## FUNC (d); } +#define DALIAS_vf2_vf(FUNC) EXPORT CONST VECTOR_CC vfloat2 y ## FUNC(vfloat d) { return x ## FUNC (d); } +#define DALIAS_vf_vf_vf(FUNC) EXPORT CONST VECTOR_CC vfloat y ## FUNC(vfloat x, vfloat y) { return x ## FUNC (x, y); } +#define DALIAS_vf_vf_vf_vf(FUNC) EXPORT CONST VECTOR_CC vfloat y ## FUNC(vfloat x, vfloat y, vfloat z) { return x ## FUNC (x, y, z); } +#endif + +DALIAS_vf2_vf(sincospif_u05) +DALIAS_vf2_vf(sincospif_u35) +DALIAS_vf2_vf(modff) +DALIAS_vf_vf(atanf) +DALIAS_vf_vf_vf(atan2f) +DALIAS_vf_vf(asinf) +DALIAS_vf_vf(acosf) +DALIAS_vf_vf_vf(atan2f_u1) +DALIAS_vf_vf(asinf_u1) +DALIAS_vf_vf(acosf_u1) +DALIAS_vf_vf(atanf_u1) +DALIAS_vf_vf(logf) +DALIAS_vf_vf(expf) +DALIAS_vf_vf(cbrtf) +DALIAS_vf_vf(cbrtf_u1) +DALIAS_vf_vf(logf_u1) +DALIAS_vf_vf_vf(powf) +DALIAS_vf_vf(sinhf) +DALIAS_vf_vf(coshf) +DALIAS_vf_vf(tanhf) +DALIAS_vf_vf(sinhf_u35) +DALIAS_vf_vf(coshf_u35) +DALIAS_vf_vf(tanhf_u35) +DALIAS_vf_vf(asinhf) +DALIAS_vf_vf(acoshf) +DALIAS_vf_vf(atanhf) +DALIAS_vf_vf(exp2f) +DALIAS_vf_vf(exp2f_u35) +DALIAS_vf_vf(exp10f) +DALIAS_vf_vf(exp10f_u35) +DALIAS_vf_vf(expm1f) +DALIAS_vf_vf(log10f) +DALIAS_vf_vf(log2f) +DALIAS_vf_vf(log2f_u35) +DALIAS_vf_vf(log1pf) +DALIAS_vf_vf(fabsf) +DALIAS_vf_vf_vf(copysignf) +DALIAS_vf_vf_vf(fmaxf) +DALIAS_vf_vf_vf(fminf) +DALIAS_vf_vf_vf(fdimf) +DALIAS_vf_vf(truncf) +DALIAS_vf_vf(floorf) +DALIAS_vf_vf(ceilf) +DALIAS_vf_vf(roundf) +DALIAS_vf_vf(rintf) +DALIAS_vf_vf_vf_vf(fmaf) +DALIAS_vf_vf_vf(hypotf_u05) +DALIAS_vf_vf_vf(hypotf_u35) +DALIAS_vf_vf_vf(nextafterf) +DALIAS_vf_vf(frfrexpf) +DALIAS_vf_vf_vf(fmodf) +DALIAS_vf_vf_vf(remainderf) +DALIAS_vf_vf(sinpif_u05) +DALIAS_vf_vf(cospif_u05) +DALIAS_vf_vf(tgammaf_u1) +DALIAS_vf_vf(lgammaf_u1) +DALIAS_vf_vf(erff_u1) +DALIAS_vf_vf(erfcf_u15) +DALIAS_vf_vf_vf(fastpowf_u3500) +#endif // #if !defined(DETERMINISTIC) && !defined(ENABLE_GNUABI) && !defined(SLEEF_GENHEADER) + +#if !defined(ENABLE_GNUABI) && !defined(SLEEF_GENHEADER) +EXPORT CONST int xgetIntf(int name) { + if (1 <= name && name <= 10) return vavailability_i(name); + return 0; +} + +EXPORT CONST void *xgetPtrf(int name) { + if (name == 0) return ISANAME; + return (void *)0; +} +#endif + +#if defined(ALIAS_NO_EXT_SUFFIX) && !defined(DETERMINISTIC) +#include ALIAS_NO_EXT_SUFFIX +#endif + +#ifdef ENABLE_GNUABI +EXPORT CONST VECTOR_CC vfloat __acosf_finite (vfloat) __attribute__((weak, alias(str_xacosf_u1 ))); +EXPORT CONST VECTOR_CC vfloat __acoshf_finite (vfloat) __attribute__((weak, alias(str_xacoshf ))); +EXPORT CONST VECTOR_CC vfloat __asinf_finite (vfloat) __attribute__((weak, alias(str_xasinf_u1 ))); +EXPORT CONST VECTOR_CC vfloat __atan2f_finite (vfloat, vfloat) __attribute__((weak, alias(str_xatan2f_u1 ))); +EXPORT CONST VECTOR_CC vfloat __atanhf_finite (vfloat) __attribute__((weak, alias(str_xatanhf ))); +EXPORT CONST VECTOR_CC vfloat __coshf_finite (vfloat) __attribute__((weak, alias(str_xcoshf ))); +EXPORT CONST VECTOR_CC vfloat __exp10f_finite (vfloat) __attribute__((weak, alias(str_xexp10f ))); +EXPORT CONST VECTOR_CC vfloat __exp2f_finite (vfloat) __attribute__((weak, alias(str_xexp2f ))); +EXPORT CONST VECTOR_CC vfloat __expf_finite (vfloat) __attribute__((weak, alias(str_xexpf ))); +EXPORT CONST VECTOR_CC vfloat __fmodf_finite (vfloat, vfloat) __attribute__((weak, alias(str_xfmodf ))); +EXPORT CONST VECTOR_CC vfloat __remainderf_finite(vfloat, vfloat) __attribute__((weak, alias(str_xremainderf))); +EXPORT CONST VECTOR_CC vfloat __modff_finite (vfloat, vfloat *) __attribute__((weak, alias(str_xmodff ))); +EXPORT CONST VECTOR_CC vfloat __hypotf_u05_finite(vfloat, vfloat) __attribute__((weak, alias(str_xhypotf_u05))); +EXPORT CONST VECTOR_CC vfloat __lgammaf_u1_finite(vfloat) __attribute__((weak, alias(str_xlgammaf_u1))); +EXPORT CONST VECTOR_CC vfloat __log10f_finite (vfloat) __attribute__((weak, alias(str_xlog10f ))); +EXPORT CONST VECTOR_CC vfloat __logf_finite (vfloat) __attribute__((weak, alias(str_xlogf_u1 ))); +EXPORT CONST VECTOR_CC vfloat __powf_finite (vfloat, vfloat) __attribute__((weak, alias(str_xpowf ))); +EXPORT CONST VECTOR_CC vfloat __sinhf_finite (vfloat) __attribute__((weak, alias(str_xsinhf ))); +EXPORT CONST VECTOR_CC vfloat __sqrtf_finite (vfloat) __attribute__((weak, alias(str_xsqrtf ))); +EXPORT CONST VECTOR_CC vfloat __tgammaf_u1_finite(vfloat) __attribute__((weak, alias(str_xtgammaf_u1))); + +#ifdef HEADER_MASKED +#include HEADER_MASKED +#endif +#endif /* #ifdef ENABLE_GNUABI */ + +#ifdef ENABLE_MAIN +// gcc -DENABLE_MAIN -Wno-attributes -I../common -I../arch -DENABLE_AVX2 -mavx2 -mfma sleefsimdsp.c rempitab.c ../common/common.c -lm +#include +#include +#include +int main(int argc, char **argv) { + vfloat vf1 = vcast_vf_f(atof(argv[1])); + //vfloat vf2 = vcast_vf_f(atof(argv[2])); + + //vfloat r = xpowf(vf1, vf2); + //vfloat r = xsqrtf_u05(vf1); + //printf("%g\n", xnextafterf(vf1, vf2)[0]); + //printf("%g\n", nextafterf(atof(argv[1]), atof(argv[2]))); + printf("t = %.20g\n", xerff_u1(vf1)[0]); + printf("c = %.20g\n", erff(atof(argv[1]))); + +} +#endif diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/sleefsp.c b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/sleefsp.c new file mode 100644 index 00000000000..7d3370c0b02 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/sleefsp.c @@ -0,0 +1,2436 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// Always use -ffp-contract=off option to compile SLEEF. + +#include +#include +#include +#include +#include + +#ifndef ENABLE_BUILTIN_MATH +#include +#define SQRTF sqrtf +#else +#define SQRTF __builtin_sqrtf +#endif + +#include "misc.h" + +extern const float Sleef_rempitabsp[]; + +#ifdef DORENAME +#include "rename.h" +#endif + +#if defined(_MSC_VER) && !defined (__clang__) +#pragma fp_contract (off) +#else +#pragma STDC FP_CONTRACT OFF +#endif + +#define MLA mlaf +#define C2V(x) (x) +#include "estrin.h" + +static INLINE CONST int32_t floatToRawIntBits(float d) { + int32_t ret; + memcpy(&ret, &d, sizeof(ret)); + return ret; +} + +static INLINE CONST float intBitsToFloat(int32_t i) { + float ret; + memcpy(&ret, &i, sizeof(ret)); + return ret; +} + +static INLINE CONST float fabsfk(float x) { + return intBitsToFloat(0x7fffffffL & floatToRawIntBits(x)); +} + +static INLINE CONST float mulsignf(float x, float y) { + return intBitsToFloat(floatToRawIntBits(x) ^ (floatToRawIntBits(y) & (1 << 31))); +} + +static INLINE CONST float copysignfk(float x, float y) { + return intBitsToFloat((floatToRawIntBits(x) & ~(1 << 31)) ^ (floatToRawIntBits(y) & (1 << 31))); +} + +static INLINE CONST float signf(float d) { return mulsignf(1, d); } +static INLINE CONST float mlaf(float x, float y, float z) { return x * y + z; } +static INLINE CONST float rintfk(float x) { return x < 0 ? (int)(x - 0.5f) : (int)(x + 0.5f); } +static INLINE CONST int ceilfk(float x) { return (int)x + (x < 0 ? 0 : 1); } +static INLINE CONST float fminfk(float x, float y) { return x < y ? x : y; } +static INLINE CONST float fmaxfk(float x, float y) { return x > y ? x : y; } +static INLINE CONST int xisintf(float x) { return (x == (int)x); } + +static INLINE CONST int xsignbitf(double d) { return (floatToRawIntBits(d) & floatToRawIntBits(-0.0)) == floatToRawIntBits(-0.0); } +static INLINE CONST int xisnanf(float x) { return x != x; } +static INLINE CONST int xisinff(float x) { return x == SLEEF_INFINITYf || x == -SLEEF_INFINITYf; } +static INLINE CONST int xisminff(float x) { return x == -SLEEF_INFINITYf; } +static INLINE CONST int xispinff(float x) { return x == SLEEF_INFINITYf; } +static INLINE CONST int xisnegzerof(float x) { return floatToRawIntBits(x) == floatToRawIntBits(-0.0); } +static INLINE CONST int xisnumberf(float x) { return !xisinff(x) && !xisnanf(x); } + +static INLINE CONST int ilogbkf(float d) { + int m = d < 5.421010862427522E-20f; + d = m ? 1.8446744073709552E19f * d : d; + int q = (floatToRawIntBits(d) >> 23) & 0xff; + q = m ? q - (64 + 0x7f) : q - 0x7f; + return q; +} + +// vilogb2kf is similar to ilogbkf, but the argument has to be a +// normalized FP value. +static INLINE CONST int ilogb2kf(float d) { + return ((floatToRawIntBits(d) >> 23) & 0xff) - 0x7f; +} + +EXPORT CONST int xilogbf(float d) { + int e = ilogbkf(fabsfk(d)); + e = d == 0.0f ? SLEEF_FP_ILOGB0 : e; + e = xisnanf(d) ? SLEEF_FP_ILOGBNAN : e; + e = xisinff(d) ? INT_MAX : e; + return e; +} + +static INLINE CONST float pow2if(int q) { + return intBitsToFloat(((int32_t)(q + 0x7f)) << 23); +} + +static INLINE CONST float ldexpkf(float x, int q) { + float u; + int m; + m = q >> 31; + m = (((m + q) >> 6) - m) << 4; + q = q - (m << 2); + m += 127; + m = m < 0 ? 0 : m; + m = m > 255 ? 255 : m; + u = intBitsToFloat(((int32_t)m) << 23); + x = x * u * u * u * u; + u = intBitsToFloat(((int32_t)(q + 0x7f)) << 23); + return x * u; +} + +static INLINE CONST float ldexp2kf(float d, int e) { // faster than ldexpkf, short reach + return d * pow2if(e >> 1) * pow2if(e - (e >> 1)); +} + +static INLINE CONST float ldexp3kf(float d, int e) { // very fast, no denormal + return intBitsToFloat(floatToRawIntBits(d) + (e << 23)); +} + +// + +#ifndef NDEBUG +static int checkfp(float x) { + if (xisinff(x) || xisnanf(x)) return 1; + return 0; +} +#endif + +static INLINE CONST float upperf(float d) { + return intBitsToFloat(floatToRawIntBits(d) & 0xfffff000); +} + +static INLINE CONST Sleef_float2 df(float h, float l) { + Sleef_float2 ret; + ret.x = h; ret.y = l; + return ret; +} + +static INLINE CONST Sleef_float2 dfx(double d) { + Sleef_float2 ret; + ret.x = d; ret.y = d - ret.x; + return ret; +} + +static INLINE CONST Sleef_float2 dfnormalize_f2_f2(Sleef_float2 t) { + Sleef_float2 s; + + s.x = t.x + t.y; + s.y = t.x - s.x + t.y; + + return s; +} + +static INLINE CONST Sleef_float2 dfscale_f2_f2_f(Sleef_float2 d, float s) { + Sleef_float2 r; + + r.x = d.x * s; + r.y = d.y * s; + + return r; +} + +static INLINE CONST Sleef_float2 dfneg_f2_f2(Sleef_float2 d) { + Sleef_float2 r; + + r.x = -d.x; + r.y = -d.y; + + return r; +} + +static INLINE CONST Sleef_float2 dfabs_f2_f2(Sleef_float2 x) { + return df(x.x < 0 ? -x.x : x.x, x.x < 0 ? -x.y : x.y); +} + +static INLINE CONST Sleef_float2 dfadd_f2_f_f(float x, float y) { + // |x| >= |y| + + Sleef_float2 r; + +#ifndef NDEBUG + if (!(checkfp(x) || checkfp(y) || fabsfk(x) >= fabsfk(y))) fprintf(stderr, "[dfadd_f2_f_f : %g, %g]", x, y); +#endif + + r.x = x + y; + r.y = x - r.x + y; + + return r; +} + +static INLINE CONST Sleef_float2 dfadd2_f2_f_f(float x, float y) { + Sleef_float2 r; + + r.x = x + y; + float v = r.x - x; + r.y = (x - (r.x - v)) + (y - v); + + return r; +} + +static INLINE CONST Sleef_float2 dfadd_f2_f2_f(Sleef_float2 x, float y) { + // |x| >= |y| + + Sleef_float2 r; + +#ifndef NDEBUG + if (!(checkfp(x.x) || checkfp(y) || fabsfk(x.x) >= fabsfk(y))) fprintf(stderr, "[dfadd_f2_f2_f : %g %g]", x.x, y); +#endif + + r.x = x.x + y; + r.y = x.x - r.x + y + x.y; + + return r; +} + +static INLINE CONST Sleef_float2 dfadd_f2_f_f2(float x, Sleef_float2 y) { + // |x| >= |y| + + Sleef_float2 r; + +#ifndef NDEBUG + if (!(checkfp(x) || checkfp(y.x) || fabsfk(x) >= fabsfk(y.x))) { + fprintf(stderr, "[dfadd_f2_f_f2 : %g %g]\n", x, y.x); + fflush(stderr); + } +#endif + + r.x = x + y.x; + r.y = x - r.x + y.x + y.y; + + return r; +} + +static INLINE CONST Sleef_float2 dfadd2_f2_f2_f(Sleef_float2 x, float y) { + // |x| >= |y| + + Sleef_float2 r; + + r.x = x.x + y; + float v = r.x - x.x; + r.y = (x.x - (r.x - v)) + (y - v); + r.y += x.y; + + return r; +} + +static INLINE CONST Sleef_float2 dfadd2_f2_f_f2(float x, Sleef_float2 y) { + Sleef_float2 r; + + r.x = x + y.x; + float v = r.x - x; + r.y = (x - (r.x - v)) + (y.x - v) + y.y; + + return r; +} + +static INLINE CONST Sleef_float2 dfadd_f2_f2_f2(Sleef_float2 x, Sleef_float2 y) { + // |x| >= |y| + + Sleef_float2 r; + +#ifndef NDEBUG + if (!(checkfp(x.x) || checkfp(y.x) || fabsfk(x.x) >= fabsfk(y.x))) fprintf(stderr, "[dfadd_f2_f2_f2 : %g %g]", x.x, y.x); +#endif + + r.x = x.x + y.x; + r.y = x.x - r.x + y.x + x.y + y.y; + + return r; +} + +static INLINE CONST Sleef_float2 dfadd2_f2_f2_f2(Sleef_float2 x, Sleef_float2 y) { + Sleef_float2 r; + + r.x = x.x + y.x; + float v = r.x - x.x; + r.y = (x.x - (r.x - v)) + (y.x - v); + r.y += x.y + y.y; + + return r; +} + +static INLINE CONST Sleef_float2 dfsub_f2_f2_f2(Sleef_float2 x, Sleef_float2 y) { + // |x| >= |y| + + Sleef_float2 r; + +#ifndef NDEBUG + if (!(checkfp(x.x) || checkfp(y.x) || fabsfk(x.x) >= fabsfk(y.x))) fprintf(stderr, "[dfsub_f2_f2_f2 : %g %g]", x.x, y.x); +#endif + + r.x = x.x - y.x; + r.y = x.x - r.x - y.x + x.y - y.y; + + return r; +} + +static INLINE CONST Sleef_float2 dfdiv_f2_f2_f2(Sleef_float2 n, Sleef_float2 d) { + float t = 1.0f / d.x; + float dh = upperf(d.x), dl = d.x - dh; + float th = upperf(t ), tl = t - th; + float nhh = upperf(n.x), nhl = n.x - nhh; + + Sleef_float2 q; + + q.x = n.x * t; + + float u = -q.x + nhh * th + nhh * tl + nhl * th + nhl * tl + + q.x * (1 - dh * th - dh * tl - dl * th - dl * tl); + + q.y = t * (n.y - q.x * d.y) + u; + + return q; +} + +static INLINE CONST Sleef_float2 dfmul_f2_f_f(float x, float y) { + float xh = upperf(x), xl = x - xh; + float yh = upperf(y), yl = y - yh; + Sleef_float2 r; + + r.x = x * y; + r.y = xh * yh - r.x + xl * yh + xh * yl + xl * yl; + + return r; +} + +static INLINE CONST Sleef_float2 dfmul_f2_f2_f(Sleef_float2 x, float y) { + float xh = upperf(x.x), xl = x.x - xh; + float yh = upperf(y ), yl = y - yh; + Sleef_float2 r; + + r.x = x.x * y; + r.y = xh * yh - r.x + xl * yh + xh * yl + xl * yl + x.y * y; + + return r; +} + +static INLINE CONST Sleef_float2 dfmul_f2_f2_f2(Sleef_float2 x, Sleef_float2 y) { + float xh = upperf(x.x), xl = x.x - xh; + float yh = upperf(y.x), yl = y.x - yh; + Sleef_float2 r; + + r.x = x.x * y.x; + r.y = xh * yh - r.x + xl * yh + xh * yl + xl * yl + x.x * y.y + x.y * y.x; + + return r; +} + +static INLINE CONST float dfmul_f_f2_f2(Sleef_float2 x, Sleef_float2 y) { + float xh = upperf(x.x), xl = x.x - xh; + float yh = upperf(y.x), yl = y.x - yh; + + return x.y * yh + xh * y.y + xl * yl + xh * yl + xl * yh + xh * yh; +} + +static INLINE CONST Sleef_float2 dfsqu_f2_f2(Sleef_float2 x) { + float xh = upperf(x.x), xl = x.x - xh; + Sleef_float2 r; + + r.x = x.x * x.x; + r.y = xh * xh - r.x + (xh + xh) * xl + xl * xl + x.x * (x.y + x.y); + + return r; +} + +static INLINE CONST float dfsqu_f_f2(Sleef_float2 x) { + float xh = upperf(x.x), xl = x.x - xh; + + return xh * x.y + xh * x.y + xl * xl + (xh * xl + xh * xl) + xh * xh; +} + +static INLINE CONST Sleef_float2 dfrec_f2_f(float d) { + float t = 1.0f / d; + float dh = upperf(d), dl = d - dh; + float th = upperf(t), tl = t - th; + Sleef_float2 q; + + q.x = t; + q.y = t * (1 - dh * th - dh * tl - dl * th - dl * tl); + + return q; +} + +static INLINE CONST Sleef_float2 dfrec_f2_f2(Sleef_float2 d) { + float t = 1.0f / d.x; + float dh = upperf(d.x), dl = d.x - dh; + float th = upperf(t ), tl = t - th; + Sleef_float2 q; + + q.x = t; + q.y = t * (1 - dh * th - dh * tl - dl * th - dl * tl - d.y * t); + + return q; +} + +static INLINE CONST Sleef_float2 dfsqrt_f2_f2(Sleef_float2 d) { + float t = SQRTF(d.x + d.y); + return dfscale_f2_f2_f(dfmul_f2_f2_f2(dfadd2_f2_f2_f2(d, dfmul_f2_f_f(t, t)), dfrec_f2_f(t)), 0.5f); +} + +static INLINE CONST Sleef_float2 dfsqrt_f2_f(float d) { + float t = SQRTF(d); + return dfscale_f2_f2_f(dfmul_f2_f2_f2(dfadd2_f2_f_f2(d, dfmul_f2_f_f(t, t)), dfrec_f2_f(t)), 0.5); +} + +// + +typedef struct { + float d; + int32_t i; +} fi_t; + +typedef struct { + Sleef_float2 df; + int32_t i; +} dfi_t; + +static CONST fi_t rempisubf(float x) { + fi_t ret; + float fr = x - (float)(INT64_C(1) << 10) * (int32_t)(x * (1.0f / (INT64_C(1) << 10))); + ret.i = ((7 & ((x > 0 ? 4 : 3) + (int32_t)(fr * 8))) - 3) >> 1; + fr = fr - 0.25f * (int32_t)(fr * 4 + mulsignf(0.5f, x)); + fr = fabsfk(fr) > 0.125f ? (fr - mulsignf(0.5f, x)) : fr; + fr = fabsfk(fr) > 1e+10f ? 0 : fr; + if (fabsfk(x) == 0.12499999254941940308f) { fr = x; ret.i = 0; } + ret.d = fr; + return ret; +} + +static CONST dfi_t rempif(float a) { + Sleef_float2 x, y; + fi_t di; + int ex = ilogb2kf(a) - 25, q = ex > (90 - 25) ? -64 : 0; + a = ldexp3kf(a, q); + if (ex < 0) ex = 0; + ex *= 4; + x = dfmul_f2_f_f(a, Sleef_rempitabsp[ex]); + di = rempisubf(x.x); + q = di.i; + x.x = di.d; + x = dfnormalize_f2_f2(x); + y = dfmul_f2_f_f(a, Sleef_rempitabsp[ex+1]); + x = dfadd2_f2_f2_f2(x, y); + di = rempisubf(x.x); + q += di.i; + x.x = di.d; + x = dfnormalize_f2_f2(x); + y = dfmul_f2_f2_f(df(Sleef_rempitabsp[ex+2], Sleef_rempitabsp[ex+3]), a); + x = dfadd2_f2_f2_f2(x, y); + x = dfnormalize_f2_f2(x); + x = dfmul_f2_f2_f2(x, df(3.1415927410125732422f*2, -8.7422776573475857731e-08f*2)); + dfi_t ret = { fabsfk(a) < 0.7f ? df(a, 0) : x, q }; + return ret; +} + +EXPORT CONST float xsinf(float d) { + int q; + float u, s, t = d; + + if (fabsfk(d) < TRIGRANGEMAX2f) { + q = (int)rintfk(d * (float)M_1_PI); + d = mlaf(q, -PI_A2f, d); + d = mlaf(q, -PI_B2f, d); + d = mlaf(q, -PI_C2f, d); + } else if (fabsfk(d) < TRIGRANGEMAXf) { + q = (int)rintfk(d * (float)M_1_PI); + d = mlaf(q, -PI_Af, d); + d = mlaf(q, -PI_Bf, d); + d = mlaf(q, -PI_Cf, d); + d = mlaf(q, -PI_Df, d); + } else { + dfi_t dfi = rempif(t); + q = ((dfi.i & 3) * 2 + (dfi.df.x > 0) + 1) >> 2; + if ((dfi.i & 1) != 0) { + dfi.df = dfadd2_f2_f2_f2(dfi.df, df(mulsignf(3.1415927410125732422f*-0.5, dfi.df.x), + mulsignf(-8.7422776573475857731e-08f*-0.5, dfi.df.x))); + } + d = dfi.df.x + dfi.df.y; + if (xisinff(t) || xisnanf(t)) d = SLEEF_NANf; + } + + s = d * d; + + if ((q & 1) != 0) d = -d; + + u = 2.6083159809786593541503e-06f; + u = mlaf(u, s, -0.0001981069071916863322258f); + u = mlaf(u, s, 0.00833307858556509017944336f); + u = mlaf(u, s, -0.166666597127914428710938f); + + u = mlaf(s, u * d, d); + + if (xisnegzerof(t)) u = -0.0f; + + return u; +} + +EXPORT CONST float xsinf_u1(float d) { + int q; + float u; + Sleef_float2 s, t, x; + + if (fabsfk(d) < TRIGRANGEMAX2f) { + q = (int)rintfk(d * (float)M_1_PI); + u = mlaf(q, -PI_A2f, d); + s = dfadd2_f2_f_f(u, q * (-PI_B2f)); + s = dfadd_f2_f2_f(s, q * (-PI_C2f)); + } else { + dfi_t dfi = rempif(d); + q = ((dfi.i & 3) * 2 + (dfi.df.x > 0) + 1) >> 2; + if ((dfi.i & 1) != 0) { + dfi.df = dfadd2_f2_f2_f2(dfi.df, df(mulsignf(3.1415927410125732422f*-0.5, dfi.df.x), + mulsignf(-8.7422776573475857731e-08f*-0.5, dfi.df.x))); + } + s = dfnormalize_f2_f2(dfi.df); + if (xisinff(d) || xisnanf(d)) s.x = SLEEF_NANf; + } + + t = s; + s = dfsqu_f2_f2(s); + + u = 2.6083159809786593541503e-06f; + u = mlaf(u, s.x, -0.0001981069071916863322258f); + u = mlaf(u, s.x, 0.00833307858556509017944336f); + + x = dfadd_f2_f_f2(1, dfmul_f2_f2_f2(dfadd_f2_f_f(-0.166666597127914428710938f, u * s.x), s)); + + u = dfmul_f_f2_f2(t, x); + + if ((q & 1) != 0) u = -u; + if (xisnegzerof(d)) u = d; + + return u; +} + +EXPORT CONST float xcosf(float d) { + int q; + float u, s, t = d; + + if (fabsfk(d) < TRIGRANGEMAX2f) { + q = 1 + 2*(int)rintfk(d * (float)M_1_PI - 0.5f); + d = mlaf(q, -PI_A2f*0.5f, d); + d = mlaf(q, -PI_B2f*0.5f, d); + d = mlaf(q, -PI_C2f*0.5f, d); + } else if (fabsfk(d) < TRIGRANGEMAXf) { + q = 1 + 2*(int)rintfk(d * (float)M_1_PI - 0.5f); + d = mlaf(q, -PI_Af*0.5f, d); + d = mlaf(q, -PI_Bf*0.5f, d); + d = mlaf(q, -PI_Cf*0.5f, d); + d = mlaf(q, -PI_Df*0.5f, d); + } else { + dfi_t dfi = rempif(t); + q = ((dfi.i & 3) * 2 + (dfi.df.x > 0) + 7) >> 1; + if ((dfi.i & 1) == 0) { + dfi.df = dfadd2_f2_f2_f2(dfi.df, df(mulsignf(3.1415927410125732422f*-0.5, dfi.df.x > 0 ? 1 : -1), + mulsignf(-8.7422776573475857731e-08f*-0.5, dfi.df.x > 0 ? 1 : -1))); + } + d = dfi.df.x + dfi.df.y; + if (xisinff(t) || xisnanf(t)) d = SLEEF_NANf; + } + + s = d * d; + + if ((q & 2) == 0) d = -d; + + u = 2.6083159809786593541503e-06f; + u = mlaf(u, s, -0.0001981069071916863322258f); + u = mlaf(u, s, 0.00833307858556509017944336f); + u = mlaf(u, s, -0.166666597127914428710938f); + + u = mlaf(s, u * d, d); + + return u; +} + +EXPORT CONST float xcosf_u1(float d) { + float u; + Sleef_float2 s, t, x; + int q; + + if (fabsfk(d) < TRIGRANGEMAX2f) { + d = fabsfk(d); + float dq = mlaf(rintfk(d * (float)M_1_PI - 0.5f), 2, 1); + q = (int)dq; + s = dfadd2_f2_f_f (d, dq * (-PI_A2f*0.5f)); + s = dfadd2_f2_f2_f(s, dq * (-PI_B2f*0.5f)); + s = dfadd2_f2_f2_f(s, dq * (-PI_C2f*0.5f)); + } else { + dfi_t dfi = rempif(d); + q = ((dfi.i & 3) * 2 + (dfi.df.x > 0) + 7) >> 1; + if ((dfi.i & 1) == 0) { + dfi.df = dfadd2_f2_f2_f2(dfi.df, df(mulsignf(3.1415927410125732422f*-0.5, dfi.df.x > 0 ? 1 : -1), + mulsignf(-8.7422776573475857731e-08f*-0.5, dfi.df.x > 0 ? 1 : -1))); + } + s = dfnormalize_f2_f2(dfi.df); + if (xisinff(d) || xisnanf(d)) s.x = SLEEF_NANf; + } + + t = s; + s = dfsqu_f2_f2(s); + + u = 2.6083159809786593541503e-06f; + u = mlaf(u, s.x, -0.0001981069071916863322258f); + u = mlaf(u, s.x, 0.00833307858556509017944336f); + + x = dfadd_f2_f_f2(1, dfmul_f2_f2_f2(dfadd_f2_f_f(-0.166666597127914428710938f, u * s.x), s)); + + u = dfmul_f_f2_f2(t, x); + + if ((((int)q) & 2) == 0) u = -u; + + return u; +} + +EXPORT CONST float xfastsinf_u3500(float d) { + int q; + float u, s, t = d; + + q = rintfk(d * (float)M_1_PI); + d = mlaf(q, -(float)M_PI, d); + + s = d * d; + + u = -0.1881748176e-3; + u = mlaf(u, s, +0.8323502727e-2); + u = mlaf(u, s, -0.1666651368e+0); + u = mlaf(s * d, u, d); + + if ((q & 1) != 0) u = -u; + + if (UNLIKELY(fabsfk(t) > 30.0f)) return xsinf(t); + + return u; +} + +EXPORT CONST float xfastcosf_u3500(float d) { + int q; + float u, s, t = d; + + q = rintfk(mlaf(d, (float)M_1_PI, -0.5f)); + d = mlaf(q, -(float)M_PI, d - (float)M_PI*0.5f); + + s = d * d; + + u = -0.1881748176e-3; + u = mlaf(u, s, +0.8323502727e-2); + u = mlaf(u, s, -0.1666651368e+0); + u = mlaf(s * d, u, d); + + if ((q & 1) == 0) u = -u; + + if (UNLIKELY(fabsfk(t) > 30.0f)) return xcosf(t); + + return u; +} + +EXPORT CONST Sleef_float2 xsincosf(float d) { + int q; + float u, s, t; + Sleef_float2 r; + + s = d; + + if (fabsfk(d) < TRIGRANGEMAX2f) { + q = (int)rintfk(d * ((float)(2 * M_1_PI))); + s = mlaf(q, -PI_A2f*0.5f, s); + s = mlaf(q, -PI_B2f*0.5f, s); + s = mlaf(q, -PI_C2f*0.5f, s); + } else if (fabsfk(d) < TRIGRANGEMAXf) { + q = (int)rintfk(d * ((float)(2 * M_1_PI))); + s = mlaf(q, -PI_Af*0.5f, s); + s = mlaf(q, -PI_Bf*0.5f, s); + s = mlaf(q, -PI_Cf*0.5f, s); + s = mlaf(q, -PI_Df*0.5f, s); + } else { + dfi_t dfi = rempif(d); + q = dfi.i; + s = dfi.df.x + dfi.df.y; + if (xisinff(d) || xisnanf(d)) s = SLEEF_NANf; + } + + t = s; + + s = s * s; + + u = -0.000195169282960705459117889f; + u = mlaf(u, s, 0.00833215750753879547119141f); + u = mlaf(u, s, -0.166666537523269653320312f); + u = u * s * t; + + r.x = t + u; + + if (xisnegzerof(d)) r.x = -0.0f; + + u = -2.71811842367242206819355e-07f; + u = mlaf(u, s, 2.47990446951007470488548e-05f); + u = mlaf(u, s, -0.00138888787478208541870117f); + u = mlaf(u, s, 0.0416666641831398010253906f); + u = mlaf(u, s, -0.5f); + + r.y = u * s + 1; + + if ((q & 1) != 0) { s = r.y; r.y = r.x; r.x = s; } + if ((q & 2) != 0) { r.x = -r.x; } + if (((q+1) & 2) != 0) { r.y = -r.y; } + + return r; +} + +EXPORT CONST Sleef_float2 xsincosf_u1(float d) { + int q; + float u; + Sleef_float2 r, s, t, x; + + if (fabsfk(d) < TRIGRANGEMAX2f) { + q = (int)rintfk(d * (float)(2 * M_1_PI)); + u = mlaf(q, -PI_A2f*0.5f, d); + s = dfadd2_f2_f_f(u, q * (-PI_B2f*0.5f)); + s = dfadd_f2_f2_f(s, q * (-PI_C2f*0.5f)); + } else { + dfi_t dfi = rempif(d); + q = dfi.i; + s = dfi.df; + if (xisinff(d) || xisnanf(d)) s.x = SLEEF_NANf; + } + + t = s; + s.x = dfsqu_f_f2(s); + + u = -0.000195169282960705459117889f; + u = mlaf(u, s.x, 0.00833215750753879547119141f); + u = mlaf(u, s.x, -0.166666537523269653320312f); + + u *= s.x * t.x; + + x = dfadd_f2_f2_f(t, u); + r.x = x.x + x.y; + if (xisnegzerof(d)) r.x = -0.0f; + + u = -2.71811842367242206819355e-07f; + u = mlaf(u, s.x, 2.47990446951007470488548e-05f); + u = mlaf(u, s.x, -0.00138888787478208541870117f); + u = mlaf(u, s.x, 0.0416666641831398010253906f); + u = mlaf(u, s.x, -0.5f); + + x = dfadd_f2_f_f2(1, dfmul_f2_f_f(s.x, u)); + r.y = x.x + x.y; + + if ((q & 1) != 0) { u = r.y; r.y = r.x; r.x = u; } + if ((q & 2) != 0) { r.x = -r.x; } + if (((q+1) & 2) != 0) { r.y = -r.y; } + + return r; +} + +EXPORT CONST Sleef_float2 xsincospif_u05(float d) { + float u, s, t; + Sleef_float2 r, x, s2; + + u = d * 4; + int q = ceilfk(u) & ~(int)1; + + s = u - (float)q; + t = s; + s = s * s; + s2 = dfmul_f2_f_f(t, t); + + // + + u = +0.3093842054e-6; + u = mlaf(u, s, -0.3657307388e-4); + u = mlaf(u, s, +0.2490393585e-2); + x = dfadd2_f2_f_f2(u * s, df(-0.080745510756969451904, -1.3373665339076936258e-09)); + x = dfadd2_f2_f2_f2(dfmul_f2_f2_f2(s2, x), df(0.78539818525314331055, -2.1857338617566484855e-08)); + + x = dfmul_f2_f2_f(x, t); + r.x = x.x + x.y; + if (xisnegzerof(d)) r.x = -0.0f; + + u = -0.2430611801e-7; + u = mlaf(u, s, +0.3590577080e-5); + u = mlaf(u, s, -0.3259917721e-3); + x = dfadd2_f2_f_f2(u * s, df(0.015854343771934509277, 4.4940051354032242811e-10)); + x = dfadd2_f2_f2_f2(dfmul_f2_f2_f2(s2, x), df(-0.30842512845993041992, -9.0728339030733922277e-09)); + + x = dfadd2_f2_f2_f(dfmul_f2_f2_f2(x, s2), 1); + r.y = x.x + x.y; + + if ((q & 2) != 0) { s = r.y; r.y = r.x; r.x = s; } + if ((q & 4) != 0) { r.x = -r.x; } + if (((q+2) & 4) != 0) { r.y = -r.y; } + + if (fabsfk(d) > 1e+7f) { r.x = 0; r.y = 1; } + if (xisinff(d)) { r.x = r.y = SLEEF_NANf; } + + return r; +} + +EXPORT CONST Sleef_float2 xsincospif_u35(float d) { + float u, s, t; + Sleef_float2 r; + + u = d * 4; + int q = ceilfk(u) & ~(int)1; + + s = u - (float)q; + t = s; + s = s * s; + + // + + u = -0.3600925265e-4; + u = mlaf(u, s, +0.2490088111e-2); + u = mlaf(u, s, -0.8074551076e-1); + u = mlaf(u, s, +0.7853981853e+0); + + r.x = u * t; + + u = +0.3539815225e-5; + u = mlaf(u, s, -0.3259574005e-3); + u = mlaf(u, s, +0.1585431583e-1); + u = mlaf(u, s, -0.3084251285e+0); + u = mlaf(u, s, 1); + + r.y = u; + + if ((q & 2) != 0) { s = r.y; r.y = r.x; r.x = s; } + if ((q & 4) != 0) { r.x = -r.x; } + if (((q+2) & 4) != 0) { r.y = -r.y; } + + if (fabsfk(d) > 1e+7f) { r.x = 0; r.y = 1; } + if (xisinff(d)) { r.x = r.y = SLEEF_NANf; } + + return r; +} + +EXPORT CONST float xtanf(float d) { + int q; + float u, s, x; + + x = d; + + if (fabsfk(d) < TRIGRANGEMAX2f*0.5f) { + q = (int)rintfk(d * (float)(2 * M_1_PI)); + x = mlaf(q, -PI_A2f*0.5f, x); + x = mlaf(q, -PI_B2f*0.5f, x); + x = mlaf(q, -PI_C2f*0.5f, x); + } else if (fabsfk(d) < TRIGRANGEMAXf) { + q = (int)rintfk(d * (float)(2 * M_1_PI)); + x = mlaf(q, -PI_Af*0.5f, x); + x = mlaf(q, -PI_Bf*0.5f, x); + x = mlaf(q, -PI_Cf*0.5f, x); + x = mlaf(q, -PI_Df*0.5f, x); + } else { + dfi_t dfi = rempif(d); + q = dfi.i; + x = dfi.df.x + dfi.df.y; + if (xisinff(d) || xisnanf(d)) x = SLEEF_NANf; + } + + s = x * x; + + if ((q & 1) != 0) x = -x; + + float s2 = s * s, s4 = s2 * s2; + u = POLY6(s, s2, s4, + 0.00927245803177356719970703f, + 0.00331984995864331722259521f, + 0.0242998078465461730957031f, + 0.0534495301544666290283203f, + 0.133383005857467651367188f, + 0.333331853151321411132812f); + + u = mlaf(s, u * x, x); + + if ((q & 1) != 0) u = 1.0f / u; + + return u; +} + +EXPORT CONST float xtanf_u1(float d) { + int q; + float u; + Sleef_float2 s, t, x; + + if (fabsfk(d) < TRIGRANGEMAX2f) { + q = (int)rintfk(d * (float)(2 * M_1_PI)); + u = mlaf(q, -PI_A2f*0.5f, d); + s = dfadd2_f2_f_f(u, q * (-PI_B2f*0.5f)); + s = dfadd_f2_f2_f(s, q * (-PI_C2f*0.5f)); + } else { + dfi_t dfi = rempif(d); + q = dfi.i; + s = dfi.df; + if (xisinff(d) || xisnanf(d)) s.x = SLEEF_NANf; + } + + if ((q & 1) != 0) s = dfneg_f2_f2(s); + + t = s; + s = dfsqu_f2_f2(s); + s = dfnormalize_f2_f2(s); + + u = 0.00446636462584137916564941f; + u = mlaf(u, s.x, -8.3920182078145444393158e-05f); + u = mlaf(u, s.x, 0.0109639242291450500488281f); + u = mlaf(u, s.x, 0.0212360303848981857299805f); + u = mlaf(u, s.x, 0.0540687143802642822265625f); + + x = dfadd_f2_f_f(0.133325666189193725585938f, u * s.x); + x = dfadd_f2_f_f2(1, dfmul_f2_f2_f2(dfadd_f2_f_f2(0.33333361148834228515625f, dfmul_f2_f2_f2(s, x)), s)); + x = dfmul_f2_f2_f2(t, x); + + if ((q & 1) != 0) x = dfrec_f2_f2(x); + + u = x.x + x.y; + + if (xisnegzerof(d)) u = -0.0f; + + return u; +} + +EXPORT CONST float xatanf(float s) { + float t, u; + int q = 0; + + if (signf(s) == -1) { s = -s; q = 2; } + if (s > 1) { s = 1.0f / s; q |= 1; } + + t = s * s; + + float t2 = t * t, t4 = t2 * t2; + u = POLY8(t, t2, t4, + 0.00282363896258175373077393f, + -0.0159569028764963150024414f, + 0.0425049886107444763183594f, + -0.0748900920152664184570312f, + 0.106347933411598205566406f, + -0.142027363181114196777344f, + 0.199926957488059997558594f, + -0.333331018686294555664062f); + + t = s + s * (t * u); + + if ((q & 1) != 0) t = 1.570796326794896557998982f - t; + if ((q & 2) != 0) t = -t; + + return t; +} + +static INLINE CONST float atan2kf(float y, float x) { + float s, t, u; + int q = 0; + + if (x < 0) { x = -x; q = -2; } + if (y > x) { t = x; x = y; y = -t; q += 1; } + + s = y / x; + t = s * s; + + float t2 = t * t, t4 = t2 * t2; + u = POLY8(t, t2, t4, + 0.00282363896258175373077393f, + -0.0159569028764963150024414f, + 0.0425049886107444763183594f, + -0.0748900920152664184570312f, + 0.106347933411598205566406f, + -0.142027363181114196777344f, + 0.199926957488059997558594f, + -0.333331018686294555664062f); + + t = u * t * s + s; + t = q * (float)(M_PI/2) + t; + + return t; +} + +EXPORT CONST float xatan2f(float y, float x) { + float r = atan2kf(fabsfk(y), x); + + r = mulsignf(r, x); + if (xisinff(x) || x == 0) r = M_PIf/2 - (xisinff(x) ? (signf(x) * (float)(M_PI /2)) : 0); + if (xisinff(y) ) r = M_PIf/2 - (xisinff(x) ? (signf(x) * (float)(M_PI*1/4)) : 0); + if ( y == 0) r = (signf(x) == -1 ? M_PIf : 0); + + return xisnanf(x) || xisnanf(y) ? SLEEF_NANf : mulsignf(r, y); +} + +EXPORT CONST float xasinf(float d) { + int o = fabsfk(d) < 0.5f; + float x2 = o ? (d*d) : ((1-fabsfk(d))*0.5f), x = o ? fabsfk(d) : SQRTF(x2), u; + + u = +0.4197454825e-1; + u = mlaf(u, x2, +0.2424046025e-1); + u = mlaf(u, x2, +0.4547423869e-1); + u = mlaf(u, x2, +0.7495029271e-1); + u = mlaf(u, x2, +0.1666677296e+0); + u = mlaf(u, x * x2, x); + + float r = o ? u : (M_PIf/2 - 2*u); + r = mulsignf(r, d); + + return r; +} + +EXPORT CONST float xacosf(float d) { + int o = fabsfk(d) < 0.5f; + float x2 = o ? (d*d) : ((1-fabsfk(d))*0.5f), u; + float x = o ? fabsfk(d) : SQRTF(x2); + x = fabsfk(d) == 1.0 ? 0 : x; + + u = +0.4197454825e-1; + u = mlaf(u, x2, +0.2424046025e-1); + u = mlaf(u, x2, +0.4547423869e-1); + u = mlaf(u, x2, +0.7495029271e-1); + u = mlaf(u, x2, +0.1666677296e+0); + + u *= x * x2; + + float y = 3.1415926535897932f/2 - (mulsignf(x, d) + mulsignf(u, d)); + x += u; + float r = o ? y : (x*2); + if (!o && d < 0) r = dfadd_f2_f2_f(df(3.1415927410125732422f,-8.7422776573475857731e-08f), -r).x; + + return r; +} + +static Sleef_float2 atan2kf_u1(Sleef_float2 y, Sleef_float2 x) { + float u; + Sleef_float2 s, t; + int q = 0; + + if (x.x < 0) { x.x = -x.x; x.y = -x.y; q = -2; } + if (y.x > x.x) { t = x; x = y; y.x = -t.x; y.y = -t.y; q += 1; } + + s = dfdiv_f2_f2_f2(y, x); + t = dfsqu_f2_f2(s); + t = dfnormalize_f2_f2(t); + + u = -0.00176397908944636583328247f; + u = mlaf(u, t.x, 0.0107900900766253471374512f); + u = mlaf(u, t.x, -0.0309564601629972457885742f); + u = mlaf(u, t.x, 0.0577365085482597351074219f); + u = mlaf(u, t.x, -0.0838950723409652709960938f); + u = mlaf(u, t.x, 0.109463557600975036621094f); + u = mlaf(u, t.x, -0.142626821994781494140625f); + u = mlaf(u, t.x, 0.199983194470405578613281f); + + t = dfmul_f2_f2_f2(t, dfadd_f2_f_f(-0.333332866430282592773438f, u * t.x)); + t = dfmul_f2_f2_f2(s, dfadd_f2_f_f2(1, t)); + t = dfadd2_f2_f2_f2(dfmul_f2_f2_f(df(1.5707963705062866211f, -4.3711388286737928865e-08f), q), t); + + return t; +} + +EXPORT CONST float xatan2f_u1(float y, float x) { + if (fabsfk(x) < 2.9387372783541830947e-39f) { y *= (UINT64_C(1) << 24); x *= (UINT64_C(1) << 24); } // nexttowardf((1.0 / FLT_MAX), 1) + Sleef_float2 d = atan2kf_u1(df(fabsfk(y), 0), df(x, 0)); + float r = d.x + d.y; + + r = mulsignf(r, x); + if (xisinff(x) || x == 0) r = (float)M_PI/2 - (xisinff(x) ? (signf(x) * (float)(M_PI /2)) : 0.0f); + if (xisinff(y) ) r = (float)M_PI/2 - (xisinff(x) ? (signf(x) * (float)(M_PI*1/4)) : 0.0f); + if ( y == 0) r = (signf(x) == -1 ? (float)M_PI : 0.0f); + + return xisnanf(x) || xisnanf(y) ? SLEEF_NANf : mulsignf(r, y); +} + +EXPORT CONST float xasinf_u1(float d) { + int o = fabsfk(d) < 0.5f; + float x2 = o ? (d*d) : ((1-fabsfk(d))*0.5f), u; + Sleef_float2 x = o ? df(fabsfk(d), 0) : dfsqrt_f2_f(x2); + x = fabsfk(d) == 1.0f ? df(0, 0) : x; + + u = +0.4197454825e-1; + u = mlaf(u, x2, +0.2424046025e-1); + u = mlaf(u, x2, +0.4547423869e-1); + u = mlaf(u, x2, +0.7495029271e-1); + u = mlaf(u, x2, +0.1666677296e+0); + u *= x2 * x.x; + + Sleef_float2 y = dfadd_f2_f2_f(dfsub_f2_f2_f2(df(3.1415927410125732422f/4,-8.7422776573475857731e-08f/4), x), -u); + float r = o ? (u + x.x) : ((y.x + y.y)*2); + r = mulsignf(r, d); + + return r; +} + +EXPORT CONST float xacosf_u1(float d) { + int o = fabsfk(d) < 0.5f; + float x2 = o ? (d*d) : ((1-fabsfk(d))*0.5f), u; + Sleef_float2 x = o ? df(fabsfk(d), 0) : dfsqrt_f2_f(x2); + x = fabsfk(d) == 1.0 ? df(0, 0) : x; + + u = +0.4197454825e-1; + u = mlaf(u, x2, +0.2424046025e-1); + u = mlaf(u, x2, +0.4547423869e-1); + u = mlaf(u, x2, +0.7495029271e-1); + u = mlaf(u, x2, +0.1666677296e+0); + + u = u * x.x * x2; + + Sleef_float2 y = dfsub_f2_f2_f2(df(3.1415927410125732422f/2,-8.7422776573475857731e-08f/2), + dfadd_f2_f_f(mulsignf(x.x, d), mulsignf(u, d))); + x = dfadd_f2_f2_f(x, u); + y = o ? y : dfscale_f2_f2_f(x, 2); + if (!o && d < 0) y = dfsub_f2_f2_f2(df(3.1415927410125732422f,-8.7422776573475857731e-08f), y); + + return y.x + y.y; +} + +EXPORT CONST float xatanf_u1(float d) { + Sleef_float2 d2 = atan2kf_u1(df(fabsfk(d), 0.0f), df(1.0f, 0.0f)); + float r = d2.x + d2.y; + if (xisinff(d)) r = 1.570796326794896557998982f; + return mulsignf(r, d); +} + +EXPORT CONST float xlogf(float d) { + float x, x2, t, m; + int e; + + int o = d < FLT_MIN; + if (o) d *= (float)(INT64_C(1) << 32) * (float)(INT64_C(1) << 32); + + e = ilogb2kf(d * (1.0f/0.75f)); + m = ldexp3kf(d, -e); + + if (o) e -= 64; + + x = (m-1.0f) / (m+1.0f); + x2 = x * x; + + t = 0.2392828464508056640625f; + t = mlaf(t, x2, 0.28518211841583251953125f); + t = mlaf(t, x2, 0.400005877017974853515625f); + t = mlaf(t, x2, 0.666666686534881591796875f); + t = mlaf(t, x2, 2.0f); + + x = x * t + 0.693147180559945286226764f * e; + + if (xisinff(d)) x = SLEEF_INFINITYf; + if (d < 0 || xisnanf(d)) x = SLEEF_NANf; + if (d == 0) x = -SLEEF_INFINITYf; + + return x; +} + +EXPORT CONST float xexpf(float d) { + int q = (int)rintfk(d * R_LN2f); + float s, u; + + s = mlaf(q, -L2Uf, d); + s = mlaf(q, -L2Lf, s); + + u = 0.000198527617612853646278381; + u = mlaf(u, s, 0.00139304355252534151077271); + u = mlaf(u, s, 0.00833336077630519866943359); + u = mlaf(u, s, 0.0416664853692054748535156); + u = mlaf(u, s, 0.166666671633720397949219); + u = mlaf(u, s, 0.5); + + u = s * s * u + s + 1.0f; + u = ldexp2kf(u, q); + + if (d < -104) u = 0; + if (d > 104) u = SLEEF_INFINITYf; + + return u; +} + +static INLINE CONST float expkf(Sleef_float2 d) { + int q = (int)rintfk((d.x + d.y) * R_LN2f); + Sleef_float2 s, t; + float u; + + s = dfadd2_f2_f2_f(d, q * -L2Uf); + s = dfadd2_f2_f2_f(s, q * -L2Lf); + + s = dfnormalize_f2_f2(s); + + u = 0.00136324646882712841033936f; + u = mlaf(u, s.x, 0.00836596917361021041870117f); + u = mlaf(u, s.x, 0.0416710823774337768554688f); + u = mlaf(u, s.x, 0.166665524244308471679688f); + u = mlaf(u, s.x, 0.499999850988388061523438f); + + t = dfadd_f2_f2_f2(s, dfmul_f2_f2_f(dfsqu_f2_f2(s), u)); + + t = dfadd_f2_f_f2(1, t); + + u = ldexpkf(t.x + t.y, q); + + if (d.x < -104) u = 0; + + return u; +} + +static INLINE CONST float expm1kf(float d) { + int q = (int)rintfk(d * R_LN2f); + float s, u; + + s = mlaf(q, -L2Uf, d); + s = mlaf(q, -L2Lf, s); + + float s2 = s * s, s4 = s2 * s2; + u = POLY6(s, s2, s4, + 0.000198527617612853646278381, + 0.00139304355252534151077271, + 0.00833336077630519866943359, + 0.0416664853692054748535156, + 0.166666671633720397949219, + 0.5); + + u = s * s * u + s; + + if (q != 0) u = ldexp2kf(u + 1, q) - 1; + + return u; +} + +static INLINE CONST Sleef_float2 logkf(float d) { + Sleef_float2 x, x2, s; + float m, t; + int e; + + int o = d < FLT_MIN; + if (o) d *= (float)(INT64_C(1) << 32) * (float)(INT64_C(1) << 32); + + e = ilogb2kf(d * (1.0f/0.75f)); + m = ldexp3kf(d, -e); + + if (o) e -= 64; + + x = dfdiv_f2_f2_f2(dfadd2_f2_f_f(-1, m), dfadd2_f2_f_f(1, m)); + x2 = dfsqu_f2_f2(x); + + t = 0.240320354700088500976562; + t = mlaf(t, x2.x, 0.285112679004669189453125); + t = mlaf(t, x2.x, 0.400007992982864379882812); + Sleef_float2 c = df(0.66666662693023681640625f, 3.69183861259614332084311e-09f); + + s = dfmul_f2_f2_f(df(0.69314718246459960938f, -1.904654323148236017e-09f), e); + s = dfadd_f2_f2_f2(s, dfscale_f2_f2_f(x, 2)); + s = dfadd_f2_f2_f2(s, dfmul_f2_f2_f2(dfmul_f2_f2_f2(x2, x), + dfadd2_f2_f2_f2(dfmul_f2_f2_f(x2, t), c))); + return s; +} + +EXPORT CONST float xlogf_u1(float d) { + Sleef_float2 x, s; + float m, t, x2; + int e; + + int o = d < FLT_MIN; + if (o) d *= (float)(INT64_C(1) << 32) * (float)(INT64_C(1) << 32); + + e = ilogb2kf(d * (1.0f/0.75f)); + m = ldexp3kf(d, -e); + + if (o) e -= 64; + + x = dfdiv_f2_f2_f2(dfadd2_f2_f_f(-1, m), dfadd2_f2_f_f(1, m)); + x2 = x.x * x.x; + + t = +0.3027294874e+0f; + t = mlaf(t, x2, +0.3996108174e+0f); + t = mlaf(t, x2, +0.6666694880e+0f); + + s = dfmul_f2_f2_f(df(0.69314718246459960938f, -1.904654323148236017e-09f), (float)e); + s = dfadd_f2_f2_f2(s, dfscale_f2_f2_f(x, 2)); + s = dfadd_f2_f2_f(s, x2 * x.x * t); + + float r = s.x + s.y; + + if (xisinff(d)) r = SLEEF_INFINITYf; + if (d < 0 || xisnanf(d)) r = SLEEF_NANf; + if (d == 0) r = -SLEEF_INFINITYf; + + return r; +} + +static INLINE CONST Sleef_float2 expk2f(Sleef_float2 d) { + int q = (int)rintfk((d.x + d.y) * R_LN2f); + Sleef_float2 s, t; + float u; + + s = dfadd2_f2_f2_f(d, q * -L2Uf); + s = dfadd2_f2_f2_f(s, q * -L2Lf); + + u = +0.1980960224e-3f; + u = mlaf(u, s.x, +0.1394256484e-2f); + u = mlaf(u, s.x, +0.8333456703e-2f); + u = mlaf(u, s.x, +0.4166637361e-1f); + + t = dfadd2_f2_f2_f(dfmul_f2_f2_f(s, u), +0.166666659414234244790680580464e+0f); + t = dfadd2_f2_f2_f(dfmul_f2_f2_f2(s, t), 0.5); + t = dfadd2_f2_f2_f2(s, dfmul_f2_f2_f2(dfsqu_f2_f2(s), t)); + + t = dfadd2_f2_f_f2(1, t); + + t.x = ldexp2kf(t.x, q); + t.y = ldexp2kf(t.y, q); + + return d.x < -104 ? df(0, 0) : t; +} + +EXPORT CONST float xpowf(float x, float y) { + int yisint = (y == (int)y) || (fabsfk(y) >= (float)(INT64_C(1) << 24)); + int yisodd = (1 & (int)y) != 0 && yisint && fabsfk(y) < (float)(INT64_C(1) << 24); + + float result = expkf(dfmul_f2_f2_f(logkf(fabsfk(x)), y)); + + result = xisnanf(result) ? SLEEF_INFINITYf : result; + result *= (x >= 0 ? 1 : (yisint ? (yisodd ? -1 : 1) : SLEEF_NANf)); + + float efx = mulsignf(fabsfk(x) - 1, y); + if (xisinff(y)) result = efx < 0 ? 0.0f : (efx == 0 ? 1.0f : SLEEF_INFINITYf); + if (xisinff(x) || x == 0) result = mulsignf((xsignbitf(y) ^ (x == 0)) ? 0 : SLEEF_INFINITYf, yisodd ? x : 1); + if (xisnanf(x) || xisnanf(y)) result = SLEEF_NANf; + if (y == 0 || x == 1) result = 1; + + return result; +} + +static INLINE CONST float logk3f(float d) { + float x, x2, t, m; + int e; + + int o = d < FLT_MIN; + if (o) d *= (float)(INT64_C(1) << 32) * (float)(INT64_C(1) << 32); + + e = ilogb2kf(d * (1.0f/0.75f)); + m = ldexp3kf(d, -e); + + if (o) e -= 64; + + x = (m-1) / (m+1); + x2 = x * x; + + t = 0.2392828464508056640625f; + t = mlaf(t, x2, 0.28518211841583251953125f); + t = mlaf(t, x2, 0.400005877017974853515625f); + t = mlaf(t, x2, 0.666666686534881591796875f); + t = mlaf(t, x2, 2.0f); + + x = mlaf(x, t, 0.693147180559945286226764f * e); + + return x; +} + +static INLINE CONST float expk3f(float d) { + int q = (int)rintfk(d * R_LN2f); + float s, u; + + s = mlaf(q, -L2Uf, d); + s = mlaf(q, -L2Lf, s); + + u = 0.000198527617612853646278381; + u = mlaf(u, s, 0.00139304355252534151077271); + u = mlaf(u, s, 0.00833336077630519866943359); + u = mlaf(u, s, 0.0416664853692054748535156); + u = mlaf(u, s, 0.166666671633720397949219); + u = mlaf(u, s, 0.5); + + u = mlaf(s * s, u, s + 1.0f); + u = ldexpkf(u, q); + + if (d < -104) u = 0; + + return u; +} + +EXPORT CONST float xfastpowf_u3500(float x, float y) { + float result = expk3f(logk3f(fabsfk(x)) * y); + + int yisint = (y == (int)y) || (fabsfk(y) >= (float)(INT64_C(1) << 24)); + int yisodd = (1 & (int)y) != 0 && yisint && fabsfk(y) < (float)(INT64_C(1) << 24); + + result *= (x < 0 && yisodd) ? -1 : 1; + if (x == 0) result = 0; + if (y == 0) result = 1; + + return result; +} + +EXPORT CONST float xsinhf(float x) { + float y = fabsfk(x); + Sleef_float2 d = expk2f(df(y, 0)); + d = dfsub_f2_f2_f2(d, dfrec_f2_f2(d)); + y = (d.x + d.y) * 0.5f; + + y = fabsfk(x) > 89 ? SLEEF_INFINITYf : y; + y = xisnanf(y) ? SLEEF_INFINITYf : y; + y = mulsignf(y, x); + y = xisnanf(x) ? SLEEF_NANf : y; + + return y; +} + +EXPORT CONST float xcoshf(float x) { + float y = fabsfk(x); + Sleef_float2 d = expk2f(df(y, 0)); + d = dfadd_f2_f2_f2(d, dfrec_f2_f2(d)); + y = (d.x + d.y) * 0.5f; + + y = fabsfk(x) > 89 ? SLEEF_INFINITYf : y; + y = xisnanf(y) ? SLEEF_INFINITYf : y; + y = xisnanf(x) ? SLEEF_NANf : y; + + return y; +} + +EXPORT CONST float xtanhf(float x) { + float y = fabsfk(x); + Sleef_float2 d = expk2f(df(y, 0)); + Sleef_float2 e = dfrec_f2_f2(d); + d = dfdiv_f2_f2_f2(dfsub_f2_f2_f2(d, e), dfadd_f2_f2_f2(d, e)); + y = d.x + d.y; + + y = fabsfk(x) > 18.714973875f ? 1.0f : y; + y = xisnanf(y) ? 1.0f : y; + y = mulsignf(y, x); + y = xisnanf(x) ? SLEEF_NANf : y; + + return y; +} + +EXPORT CONST float xsinhf_u35(float x) { + float e = expm1kf(fabsfk(x)); + float y = (e + 2) / (e + 1) * (0.5f * e); + + y = fabsfk(x) > 88 ? SLEEF_INFINITYf : y; + y = xisnanf(y) ? SLEEF_INFINITYf : y; + y = mulsignf(y, x); + y = xisnanf(x) ? SLEEF_NANf : y; + + return y; +} + +EXPORT CONST float xcoshf_u35(float x) { + float e = xexpf(fabsfk(x)); + float y = 0.5f * e + 0.5f / e; + + y = fabsfk(x) > 88 ? SLEEF_INFINITYf : y; + y = xisnanf(y) ? SLEEF_INFINITYf : y; + y = xisnanf(x) ? SLEEF_NANf : y; + + return y; +} + +EXPORT CONST float xtanhf_u35(float x) { + float y = fabsfk(x); + float d = expm1kf(2*y); + y = d / (d + 2); + + y = fabsfk(x) > 18.714973875f ? 1.0f : y; + y = xisnanf(y) ? 1.0f : y; + y = mulsignf(y, x); + y = xisnanf(x) ? SLEEF_NANf : y; + + return y; +} + +static INLINE CONST Sleef_float2 logk2f(Sleef_float2 d) { + Sleef_float2 x, x2, m, s; + float t; + int e; + + e = ilogbkf(d.x * (1.0f/0.75f)); + m = dfscale_f2_f2_f(d, pow2if(-e)); + + x = dfdiv_f2_f2_f2(dfadd2_f2_f2_f(m, -1), dfadd2_f2_f2_f(m, 1)); + x2 = dfsqu_f2_f2(x); + + t = 0.2392828464508056640625f; + t = mlaf(t, x2.x, 0.28518211841583251953125f); + t = mlaf(t, x2.x, 0.400005877017974853515625f); + t = mlaf(t, x2.x, 0.666666686534881591796875f); + + s = dfmul_f2_f2_f(df(0.69314718246459960938f, -1.904654323148236017e-09f), e); + s = dfadd_f2_f2_f2(s, dfscale_f2_f2_f(x, 2)); + s = dfadd_f2_f2_f2(s, dfmul_f2_f2_f(dfmul_f2_f2_f2(x2, x), t)); + + return s; +} + +EXPORT CONST float xasinhf(float x) { + float y = fabsfk(x); + Sleef_float2 d; + + d = y > 1 ? dfrec_f2_f(x) : df(y, 0); + d = dfsqrt_f2_f2(dfadd2_f2_f2_f(dfsqu_f2_f2(d), 1)); + d = y > 1 ? dfmul_f2_f2_f(d, y) : d; + + d = logk2f(dfnormalize_f2_f2(dfadd_f2_f2_f(d, x))); + y = d.x + d.y; + + y = (fabsfk(x) > SQRT_FLT_MAX || xisnanf(y)) ? mulsignf(SLEEF_INFINITYf, x) : y; + y = xisnanf(x) ? SLEEF_NANf : y; + y = xisnegzerof(x) ? -0.0f : y; + + return y; +} + +EXPORT CONST float xacoshf(float x) { + Sleef_float2 d = logk2f(dfadd2_f2_f2_f(dfmul_f2_f2_f2(dfsqrt_f2_f2(dfadd2_f2_f_f(x, 1)), dfsqrt_f2_f2(dfadd2_f2_f_f(x, -1))), x)); + float y = d.x + d.y; + + y = (x > SQRT_FLT_MAX || xisnanf(y)) ? SLEEF_INFINITYf : y; + y = x == 1.0f ? 0.0f : y; + y = x < 1.0f ? SLEEF_NANf : y; + y = xisnanf(x) ? SLEEF_NANf : y; + + return y; +} + +EXPORT CONST float xatanhf(float x) { + float y = fabsfk(x); + Sleef_float2 d = logk2f(dfdiv_f2_f2_f2(dfadd2_f2_f_f(1, y), dfadd2_f2_f_f(1, -y))); + y = y > 1.0f ? SLEEF_NANf : (y == 1.0f ? SLEEF_INFINITYf : (d.x + d.y) * 0.5f); + + y = xisinff(x) || xisnanf(y) ? SLEEF_NANf : y; + y = mulsignf(y, x); + y = xisnanf(x) ? SLEEF_NANf : y; + + return y; +} + +EXPORT CONST float xexp2f(float d) { + int q = (int)rintfk(d); + float s, u; + + s = d - q; + + u = +0.1535920892e-3; + u = mlaf(u, s, +0.1339262701e-2); + u = mlaf(u, s, +0.9618384764e-2); + u = mlaf(u, s, +0.5550347269e-1); + u = mlaf(u, s, +0.2402264476e+0); + u = mlaf(u, s, +0.6931471825e+0); + u = dfnormalize_f2_f2(dfadd_f2_f_f2(1, dfmul_f2_f_f(u, s))).x; + + u = ldexp2kf(u, q); + + if (d >= 128) u = SLEEF_INFINITYf; + if (d < -150) u = 0; + + return u; +} + +EXPORT CONST float xexp2f_u35(float d) { + int q = (int)rintfk(d); + float s, u; + + s = d - q; + + u = +0.1535920892e-3; + u = mlaf(u, s, +0.1339262701e-2); + u = mlaf(u, s, +0.9618384764e-2); + u = mlaf(u, s, +0.5550347269e-1); + u = mlaf(u, s, +0.2402264476e+0); + u = mlaf(u, s, +0.6931471825e+0); + u = mlaf(u, s, +0.1000000000e+1); + + u = ldexp2kf(u, q); + + if (d >= 128) u = SLEEF_INFINITYf; + if (d < -150) u = 0; + + return u; +} + +EXPORT CONST float xexp10f(float d) { + int q = (int)rintfk(d * (float)LOG10_2); + float s, u; + + s = mlaf(q, -L10Uf, d); + s = mlaf(q, -L10Lf, s); + + u = +0.6802555919e-1; + u = mlaf(u, s, +0.2078080326e+0); + u = mlaf(u, s, +0.5393903852e+0); + u = mlaf(u, s, +0.1171245337e+1); + u = mlaf(u, s, +0.2034678698e+1); + u = mlaf(u, s, +0.2650949001e+1); + Sleef_float2 x = dfadd_f2_f2_f(df(2.3025851249694824219, -3.1705172516493593157e-08), u * s); + u = dfnormalize_f2_f2(dfadd_f2_f_f2(1, dfmul_f2_f2_f(x, s))).x; + + u = ldexp2kf(u, q); + + if (d > 38.5318394191036238941387f) u = SLEEF_INFINITYf; // log10(FLT_MAX) + if (d < -50) u = 0; + + return u; +} + +EXPORT CONST float xexp10f_u35(float d) { + int q = (int)rintfk(d * (float)LOG10_2); + float s, u; + + s = mlaf(q, -L10Uf, d); + s = mlaf(q, -L10Lf, s); + + u = +0.2064004987e+0; + u = mlaf(u, s, +0.5417877436e+0); + u = mlaf(u, s, +0.1171286821e+1); + u = mlaf(u, s, +0.2034656048e+1); + u = mlaf(u, s, +0.2650948763e+1); + u = mlaf(u, s, +0.2302585125e+1); + u = mlaf(u, s, +0.1000000000e+1); + + u = ldexp2kf(u, q); + + if (d > 38.5318394191036238941387f) u = SLEEF_INFINITYf; // log10(FLT_MAX) + if (d < -50) u = 0; + + return u; +} + +EXPORT CONST float xexpm1f(float a) { + Sleef_float2 d = dfadd2_f2_f2_f(expk2f(df(a, 0)), -1.0f); + float x = d.x + d.y; + if (a > 88.72283172607421875f) x = SLEEF_INFINITYf; + if (a < -16.635532333438687426013570f) x = -1; + if (xisnegzerof(a)) x = -0.0f; + return x; +} + +EXPORT CONST float xlog10f(float d) { + Sleef_float2 x, s; + float m, t, x2; + int e; + + int o = d < FLT_MIN; + if (o) d *= (float)(INT64_C(1) << 32) * (float)(INT64_C(1) << 32); + + e = ilogb2kf(d * (1.0f/0.75f)); + m = ldexp3kf(d, -e); + + if (o) e -= 64; + + x = dfdiv_f2_f2_f2(dfadd2_f2_f_f(-1, m), dfadd2_f2_f_f(1, m)); + x2 = x.x * x.x; + + t = +0.1314289868e+0; + t = mlaf(t, x2, +0.1735493541e+0); + t = mlaf(t, x2, +0.2895309627e+0); + + s = dfmul_f2_f2_f(df(0.30103001, -1.432098889e-08), (float)e); + s = dfadd_f2_f2_f2(s, dfmul_f2_f2_f2(x, df(0.868588984, -2.170757285e-08))); + s = dfadd_f2_f2_f(s, x2 * x.x * t); + + float r = s.x + s.y; + + if (xisinff(d)) r = SLEEF_INFINITYf; + if (d < 0 || xisnanf(d)) r = SLEEF_NANf; + if (d == 0) r = -SLEEF_INFINITYf; + + return r; +} + +EXPORT CONST float xlog2f(float d) { + Sleef_float2 x, s; + float m, t, x2; + int e; + + int o = d < FLT_MIN; + if (o) d *= (float)(INT64_C(1) << 32) * (float)(INT64_C(1) << 32); + + e = ilogb2kf(d * (1.0f/0.75f)); + m = ldexp3kf(d, -e); + + if (o) e -= 64; + + x = dfdiv_f2_f2_f2(dfadd2_f2_f_f(-1, m), dfadd2_f2_f_f(1, m)); + x2 = x.x * x.x; + + t = +0.4374550283e+0f; + t = mlaf(t, x2, +0.5764790177e+0f); + t = mlaf(t, x2, +0.9618012905120f); + + s = dfadd2_f2_f_f2(e, dfmul_f2_f2_f2(x, df(2.8853900432586669922, 3.2734474483568488616e-08))); + s = dfadd2_f2_f2_f(s, x2 * x.x * t); + + float r = s.x + s.y; + + if (xisinff(d)) r = SLEEF_INFINITYf; + if (d < 0 || xisnanf(d)) r = SLEEF_NANf; + if (d == 0) r = -SLEEF_INFINITYf; + + return r; +} + +EXPORT CONST float xlog2f_u35(float d) { + float m, t, x, x2; + int e; + + int o = d < FLT_MIN; + if (o) d *= (float)(INT64_C(1) << 32) * (float)(INT64_C(1) << 32); + + e = ilogb2kf(d * (1.0f/0.75f)); + m = ldexp3kf(d, -e); + + if (o) e -= 64; + + x = (m - 1) / (m + 1); + x2 = x * x; + + t = +0.4374088347e+0; + t = mlaf(t, x2, +0.5764843822e+0); + t = mlaf(t, x2, +0.9618024230e+0); + + float r = mlaf(x2 * x, t, mlaf(x, +0.2885390043e+1, e)); + + if (xisinff(d)) r = SLEEF_INFINITYf; + if (d < 0 || xisnanf(d)) r = SLEEF_NANf; + if (d == 0) r = -SLEEF_INFINITYf; + + return r; +} + +EXPORT CONST float xlog1pf(float d) { + Sleef_float2 x, s; + float m, t, x2; + int e; + + float dp1 = d + 1; + + int o = dp1 < FLT_MIN; + if (o) dp1 *= (float)(INT64_C(1) << 32) * (float)(INT64_C(1) << 32); + + e = ilogb2kf(dp1 * (1.0f/0.75f)); + + t = ldexp3kf(1, -e); + m = mlaf(d, t, t-1); + + if (o) e -= 64; + + x = dfdiv_f2_f2_f2(df(m, 0), dfadd_f2_f_f(2, m)); + x2 = x.x * x.x; + + t = +0.3027294874e+0f; + t = mlaf(t, x2, +0.3996108174e+0f); + t = mlaf(t, x2, +0.6666694880e+0f); + + s = dfmul_f2_f2_f(df(0.69314718246459960938f, -1.904654323148236017e-09f), (float)e); + s = dfadd_f2_f2_f2(s, dfscale_f2_f2_f(x, 2)); + s = dfadd_f2_f2_f(s, x2 * x.x * t); + + float r = s.x + s.y; + + if (d > 1e+38) r = SLEEF_INFINITYf; + if (d < -1) r = SLEEF_NANf; + if (d == -1) r = -SLEEF_INFINITYf; + if (xisnegzerof(d)) r = -0.0f; + + return r; +} + +EXPORT CONST float xcbrtf(float d) { + float x, y, q = 1.0f; + int e, r; + + e = ilogbkf(fabsfk(d))+1; + d = ldexp2kf(d, -e); + r = (e + 6144) % 3; + q = (r == 1) ? 1.2599210498948731647672106f : q; + q = (r == 2) ? 1.5874010519681994747517056f : q; + q = ldexp2kf(q, (e + 6144) / 3 - 2048); + + q = mulsignf(q, d); + d = fabsfk(d); + + x = -0.601564466953277587890625f; + x = mlaf(x, d, 2.8208892345428466796875f); + x = mlaf(x, d, -5.532182216644287109375f); + x = mlaf(x, d, 5.898262500762939453125f); + x = mlaf(x, d, -3.8095417022705078125f); + x = mlaf(x, d, 2.2241256237030029296875f); + + y = d * x * x; + y = (y - (2.0f / 3.0f) * y * (y * x - 1.0f)) * q; + + return y; +} + +EXPORT CONST float xcbrtf_u1(float d) { + float x, y, z; + Sleef_float2 q2 = df(1, 0), u, v; + int e, r; + + e = ilogbkf(fabsfk(d))+1; + d = ldexp2kf(d, -e); + r = (e + 6144) % 3; + q2 = (r == 1) ? df(1.2599210739135742188, -2.4018701694217270415e-08) : q2; + q2 = (r == 2) ? df(1.5874010324478149414, 1.9520385308169352356e-08) : q2; + + q2.x = mulsignf(q2.x, d); q2.y = mulsignf(q2.y, d); + d = fabsfk(d); + + x = -0.601564466953277587890625f; + x = mlaf(x, d, 2.8208892345428466796875f); + x = mlaf(x, d, -5.532182216644287109375f); + x = mlaf(x, d, 5.898262500762939453125f); + x = mlaf(x, d, -3.8095417022705078125f); + x = mlaf(x, d, 2.2241256237030029296875f); + + y = x * x; y = y * y; x -= (d * y - x) * (1.0 / 3.0f); + + z = x; + + u = dfmul_f2_f_f(x, x); + u = dfmul_f2_f2_f2(u, u); + u = dfmul_f2_f2_f(u, d); + u = dfadd2_f2_f2_f(u, -x); + y = u.x + u.y; + + y = -2.0 / 3.0 * y * z; + v = dfadd2_f2_f2_f(dfmul_f2_f_f(z, z), y); + v = dfmul_f2_f2_f(v, d); + v = dfmul_f2_f2_f2(v, q2); + z = ldexp2kf(v.x + v.y, (e + 6144) / 3 - 2048); + + if (xisinff(d)) { z = mulsignf(SLEEF_INFINITYf, q2.x); } + if (d == 0) { z = mulsignf(0, q2.x); } + + return z; +} + +// + +EXPORT CONST float xfabsf(float x) { return fabsfk(x); } + +EXPORT CONST float xcopysignf(float x, float y) { return copysignfk(x, y); } + +EXPORT CONST float xfmaxf(float x, float y) { + return y != y ? x : (x > y ? x : y); +} + +EXPORT CONST float xfminf(float x, float y) { + return y != y ? x : (x < y ? x : y); +} + +EXPORT CONST float xfdimf(float x, float y) { + float ret = x - y; + if (ret < 0 || x == y) ret = 0; + return ret; +} + +EXPORT CONST float xtruncf(float x) { + float fr = x - (int32_t)x; + return (xisinff(x) || fabsfk(x) >= (float)(INT64_C(1) << 23)) ? x : copysignfk(x - fr, x); +} + +EXPORT CONST float xfloorf(float x) { + float fr = x - (int32_t)x; + fr = fr < 0 ? fr+1.0f : fr; + return (xisinff(x) || fabsfk(x) >= (float)(INT64_C(1) << 23)) ? x : copysignfk(x - fr, x); +} + +EXPORT CONST float xceilf(float x) { + float fr = x - (int32_t)x; + fr = fr <= 0 ? fr : fr-1.0f; + return (xisinff(x) || fabsfk(x) >= (float)(INT64_C(1) << 23)) ? x : copysignfk(x - fr, x); +} + +EXPORT CONST float xroundf(float d) { + float x = d + 0.5f; + float fr = x - (int32_t)x; + if (fr == 0 && x <= 0) x--; + fr = fr < 0 ? fr+1.0f : fr; + x = d == 0.4999999701976776123f ? 0 : x; // nextafterf(0.5, 0) + return (xisinff(d) || fabsfk(d) >= (float)(INT64_C(1) << 23)) ? d : copysignfk(x - fr, d); +} + +EXPORT CONST float xrintf(float d) { + float x = d + 0.5f; + int32_t isodd = (1 & (int32_t)x) != 0; + float fr = x - (int32_t)x; + fr = (fr < 0 || (fr == 0 && isodd)) ? fr+1.0f : fr; + x = d == 0.50000005960464477539f ? 0 : x; // nextafterf(0.5, 1) + return (xisinff(d) || fabsfk(d) >= (float)(INT64_C(1) << 23)) ? d : copysignfk(x - fr, d); +} + +EXPORT CONST Sleef_float2 xmodff(float x) { + float fr = x - (int32_t)x; + fr = fabsfk(x) > (float)(INT64_C(1) << 23) ? 0 : fr; + Sleef_float2 ret = { copysignfk(fr, x), copysignfk(x - fr, x) }; + return ret; +} + +EXPORT CONST float xldexpf(float x, int exp) { + if (exp > 300) exp = 300; + if (exp < -300) exp = -300; + + int e0 = exp >> 2; + if (exp < 0) e0++; + if (-50 < exp && exp < 50) e0 = 0; + int e1 = exp - (e0 << 2); + + float p = pow2if(e0); + float ret = x * pow2if(e1) * p * p * p * p; + + return ret; +} + +EXPORT CONST float xnextafterf(float x, float y) { + float cxf; + int32_t cxi; + + cxf = x == 0 ? mulsignf(0, y) : x; + memcpy(&cxi, &cxf, sizeof(cxi)); + int c = (cxi < 0) == (y < x); + if (c) cxi = -(cxi ^ (1 << 31)); + + if (x != y) cxi--; + + if (c) cxi = -(cxi ^ (1 << 31)); + + memcpy(&cxf, &cxi, sizeof(cxf)); + if (cxf == 0 && x != 0) cxf = mulsignf(0, x); + if (x == 0 && y == 0) cxf = y; + if (xisnanf(x) || xisnanf(y)) cxf = SLEEF_NANf; + + return cxf; +} + +EXPORT CONST float xfrfrexpf(float x) { + float cxf; + int32_t cxu; + + if (fabsfk(x) < FLT_MIN) x *= (1 << 30); + + cxf = x; + memcpy(&cxu, &cxf, sizeof(cxu)); + + cxu &= ~0x7f800000U; + cxu |= 0x3f000000U; + + memcpy(&cxf, &cxu, sizeof(cxf)); + if (xisinff(x)) cxf = mulsignf(SLEEF_INFINITYf, x); + if (x == 0) cxf = x; + + return cxf; +} + +EXPORT CONST int xexpfrexpf(float x) { + float cxf; + uint32_t cxu; + + int ret = 0; + + if (fabsfk(x) < FLT_MIN) { x *= (1 << 30); ret = -30; } + + cxf = x; + memcpy(&cxu, &cxf, sizeof(cxu)); + ret += (int32_t)(((cxu >> 23) & 0xff)) - 0x7e; + + if (x == 0 || xisnanf(x) || xisinff(x)) ret = 0; + + return ret; +} + +EXPORT CONST float xhypotf_u05(float x, float y) { + x = fabsfk(x); + y = fabsfk(y); + float min = fminfk(x, y), n = min; + float max = fmaxfk(x, y), d = max; + + if (max < FLT_MIN) { n *= UINT64_C(1) << 24; d *= UINT64_C(1) << 24; } + Sleef_float2 t = dfdiv_f2_f2_f2(df(n, 0), df(d, 0)); + t = dfmul_f2_f2_f(dfsqrt_f2_f2(dfadd2_f2_f2_f(dfsqu_f2_f2(t), 1)), max); + float ret = t.x + t.y; + if (xisnanf(ret)) ret = SLEEF_INFINITYf; + if (min == 0) ret = max; + if (xisnanf(x) || xisnanf(y)) ret = SLEEF_NANf; + if (x == SLEEF_INFINITYf || y == SLEEF_INFINITYf) ret = SLEEF_INFINITYf; + return ret; +} + +EXPORT CONST float xhypotf_u35(float x, float y) { + x = fabsfk(x); + y = fabsfk(y); + float min = fminfk(x, y); + float max = fmaxfk(x, y); + + float t = min / max; + float ret = max * SQRTF(1 + t*t); + if (min == 0) ret = max; + if (xisnanf(x) || xisnanf(y)) ret = SLEEF_NANf; + if (x == SLEEF_INFINITYf || y == SLEEF_INFINITYf) ret = SLEEF_INFINITYf; + return ret; +} + +static INLINE CONST float toward0f(float d) { + return d == 0 ? 0 : intBitsToFloat(floatToRawIntBits(d)-1); +} + +static INLINE CONST float ptruncf(float x) { + return fabsfk(x) >= (float)(INT64_C(1) << 23) ? x : (x - (x - (int32_t)x)); +} + +EXPORT CONST float xfmodf(float x, float y) { + float nu = fabsfk(x), de = fabsfk(y), s = 1, q; + if (de < FLT_MIN) { nu *= UINT64_C(1) << 25; de *= UINT64_C(1) << 25; s = 1.0f / (UINT64_C(1) << 25); } + Sleef_float2 r = df(nu, 0); + float rde = toward0f(1.0f / de); + + for(int i=0;i<8;i++) { // ceil(log2(FLT_MAX) / 22)+1 + q = ptruncf(toward0f(r.x) * rde); + q = (3*de > r.x && r.x >= de) ? 2 : q; + q = (2*de > r.x && r.x >= de) ? 1 : q; + r = dfnormalize_f2_f2(dfadd2_f2_f2_f2(r, dfmul_f2_f_f(q, -de))); + if (r.x < de) break; + } + + float ret = (r.x + r.y) * s; + if (r.x + r.y == de) ret = 0; + ret = mulsignf(ret, x); + if (nu < de) ret = x; + if (de == 0) ret = SLEEF_NANf; + + return ret; +} + +static INLINE CONST float rintfk2(float d) { + float x = d + 0.5f; + int32_t isodd = (1 & (int32_t)x) != 0; + float fr = x - (int32_t)x; + fr = (fr < 0 || (fr == 0 && isodd)) ? fr+1.0f : fr; + return (fabsfk(d) >= (float)(INT64_C(1) << 23)) ? d : copysignfk(x - fr, d); +} + +EXPORT CONST float xremainderf(float x, float y) { + float n = fabsfk(x), d = fabsfk(y), s = 1, q; + if (d < FLT_MIN*2) { n *= UINT64_C(1) << 25; d *= UINT64_C(1) << 25; s = 1.0f / (UINT64_C(1) << 25); } + float rd = 1.0f / d; + Sleef_float2 r = df(n, 0); + int qisodd = 0; + + for(int i=0;i<8;i++) { // ceil(log2(FLT_MAX) / 22)+1 + q = rintfk2(r.x * rd); + if (fabsfk(r.x) < 1.5f * d) q = r.x < 0 ? -1 : 1; + if (fabsfk(r.x) < 0.5f * d || (fabsfk(r.x) == 0.5f * d && !qisodd)) q = 0; + if (q == 0) break; + if (xisinff(q * -d)) q = q + mulsignf(-1, r.x); + qisodd ^= (1 & (int)q) != 0 && fabsfk(q) < (float)(INT64_C(1) << 24); + r = dfnormalize_f2_f2(dfadd2_f2_f2_f2(r, dfmul_f2_f_f(q, -d))); + } + + float ret = r.x * s; + ret = mulsignf(ret, x); + if (xisinff(y)) ret = xisinff(x) ? SLEEF_NANf : x; + if (d == 0) ret = SLEEF_NANf; + + return ret; +} + +EXPORT CONST float xsqrtf_u05(float d) { + float q = 0.5f; + + d = d < 0 ? SLEEF_NANf : d; + + if (d < 5.2939559203393770e-23f) { + d *= 1.8889465931478580e+22f; + q = 7.2759576141834260e-12f * 0.5f; + } + + if (d > 1.8446744073709552e+19f) { + d *= 5.4210108624275220e-20f; + q = 4294967296.0f * 0.5f; + } + + // http://en.wikipedia.org/wiki/Fast_inverse_square_root + float x = intBitsToFloat(0x5f375a86 - (floatToRawIntBits(d + 1e-45f) >> 1)); + + x = x * (1.5f - 0.5f * d * x * x); + x = x * (1.5f - 0.5f * d * x * x); + x = x * (1.5f - 0.5f * d * x * x) * d; + + Sleef_float2 d2 = dfmul_f2_f2_f2(dfadd2_f2_f_f2(d, dfmul_f2_f_f(x, x)), dfrec_f2_f(x)); + + float ret = (d2.x + d2.y) * q; + + ret = d == SLEEF_INFINITYf ? SLEEF_INFINITYf : ret; + ret = d == 0 ? d : ret; + + return ret; +} + +EXPORT CONST float xsqrtf_u35(float d) { + float q = 1.0f; + + d = d < 0 ? SLEEF_NANf : d; + + if (d < 5.2939559203393770e-23f) { + d *= 1.8889465931478580e+22f; + q = 7.2759576141834260e-12f; + } + + if (d > 1.8446744073709552e+19f) { + d *= 5.4210108624275220e-20f; + q = 4294967296.0f; + } + + // http://en.wikipedia.org/wiki/Fast_inverse_square_root + float x = intBitsToFloat(0x5f375a86 - (floatToRawIntBits(d + 1e-45) >> 1)); + + x = x * (1.5f - 0.5f * d * x * x); + x = x * (1.5f - 0.5f * d * x * x); + x = x * (1.5f - 0.5f * d * x * x); + x = x * (1.5f - 0.5f * d * x * x); + + return d == SLEEF_INFINITYf ? SLEEF_INFINITYf : (x * d * q); +} + +EXPORT CONST float xsqrtf(float d) { return SQRTF(d); } + +EXPORT CONST float xfmaf(float x, float y, float z) { + float h2 = x * y + z, q = 1; + if (fabsfk(h2) < 1e-38f) { + const float c0 = 1 << 25, c1 = c0 * c0, c2 = c1 * c1; + x *= c1; + y *= c1; + z *= c2; + q = 1.0f / c2; + } + if (fabsfk(h2) > 1e+38f) { + const float c0 = 1 << 25, c1 = c0 * c0, c2 = c1 * c1; + x *= 1.0 / c1; + y *= 1.0 / c1; + z *= 1.0 / c2; + q = c2; + } + Sleef_float2 d = dfmul_f2_f_f(x, y); + d = dfadd2_f2_f2_f(d, z); + float ret = (x == 0 || y == 0) ? z : (d.x + d.y); + if (xisinff(z) && !xisinff(x) && !xisnanf(x) && !xisinff(y) && !xisnanf(y)) h2 = z; + return (xisinff(h2) || xisnanf(h2)) ? h2 : ret*q; +} + +// + +static INLINE CONST Sleef_float2 sinpifk(float d) { + float u, s, t; + Sleef_float2 x, s2; + + u = d * 4; + int q = ceilfk(u) & ~1; + int o = (q & 2) != 0; + + s = u - (float)q; + t = s; + s = s * s; + s2 = dfmul_f2_f_f(t, t); + + // + + u = o ? -0.2430611801e-7f : +0.3093842054e-6f; + u = mlaf(u, s, o ? +0.3590577080e-5f : -0.3657307388e-4f); + u = mlaf(u, s, o ? -0.3259917721e-3f : +0.2490393585e-2f); + x = dfadd2_f2_f_f2(u * s, o ? df(0.015854343771934509277, 4.4940051354032242811e-10) : + df(-0.080745510756969451904, -1.3373665339076936258e-09)); + x = dfadd2_f2_f2_f2(dfmul_f2_f2_f2(s2, x), o ? df(-0.30842512845993041992, -9.0728339030733922277e-09) : + df(0.78539818525314331055, -2.1857338617566484855e-08)); + + x = dfmul_f2_f2_f2(x, o ? s2 : df(t, 0)); + x = o ? dfadd2_f2_f2_f(x, 1) : x; + + // + + if ((q & 4) != 0) { x.x = -x.x; x.y = -x.y; } + + return x; +} + +EXPORT CONST float xsinpif_u05(float d) { + Sleef_float2 x = sinpifk(d); + float r = x.x + x.y; + + if (xisnegzerof(d)) r = -0.0; + if (fabsfk(d) > TRIGRANGEMAX4f) r = 0; + if (xisinff(d)) r = SLEEF_NANf; + + return r; +} + +static INLINE CONST Sleef_float2 cospifk(float d) { + float u, s, t; + Sleef_float2 x, s2; + + u = d * 4; + int q = ceilfk(u) & ~1; + int o = (q & 2) == 0; + + s = u - (float)q; + t = s; + s = s * s; + s2 = dfmul_f2_f_f(t, t); + + // + + u = o ? -0.2430611801e-7f : +0.3093842054e-6f; + u = mlaf(u, s, o ? +0.3590577080e-5f : -0.3657307388e-4f); + u = mlaf(u, s, o ? -0.3259917721e-3f : +0.2490393585e-2f); + x = dfadd2_f2_f_f2(u * s, o ? df(0.015854343771934509277, 4.4940051354032242811e-10) : + df(-0.080745510756969451904, -1.3373665339076936258e-09)); + x = dfadd2_f2_f2_f2(dfmul_f2_f2_f2(s2, x), o ? df(-0.30842512845993041992, -9.0728339030733922277e-09) : + df(0.78539818525314331055, -2.1857338617566484855e-08)); + + x = dfmul_f2_f2_f2(x, o ? s2 : df(t, 0)); + x = o ? dfadd2_f2_f2_f(x, 1) : x; + + // + + if (((q+2) & 4) != 0) { x.x = -x.x; x.y = -x.y; } + + return x; +} + +EXPORT CONST float xcospif_u05(float d) { + Sleef_float2 x = cospifk(d); + float r = x.x + x.y; + + if (fabsfk(d) > TRIGRANGEMAX4f) r = 1; + if (xisinff(d)) r = SLEEF_NANf; + + return r; +} + +typedef struct { + Sleef_float2 a, b; +} df2; + +static CONST df2 gammafk(float a) { + Sleef_float2 clc = df(0, 0), clln = df(1, 0), clld = df(1, 0), x, y, z; + float t, u; + + int otiny = fabsfk(a) < 1e-30f, oref = a < 0.5f; + + x = otiny ? df(0, 0) : (oref ? dfadd2_f2_f_f(1, -a) : df(a, 0)); + + int o0 = (0.5f <= x.x && x.x <= 1.2), o2 = 2.3 < x.x; + + y = dfnormalize_f2_f2(dfmul_f2_f2_f2(dfadd2_f2_f2_f(x, 1), x)); + y = dfnormalize_f2_f2(dfmul_f2_f2_f2(dfadd2_f2_f2_f(x, 2), y)); + + clln = (o2 && x.x <= 7) ? y : clln; + + x = (o2 && x.x <= 7) ? dfadd2_f2_f2_f(x, 3) : x; + t = o2 ? (1.0 / x.x) : dfnormalize_f2_f2(dfadd2_f2_f2_f(x, o0 ? -1 : -2)).x; + + u = o2 ? +0.000839498720672087279971000786 : (o0 ? +0.9435157776e+0f : +0.1102489550e-3f); + u = mlaf(u, t, o2 ? -5.17179090826059219329394422e-05 : (o0 ? +0.8670063615e+0f : +0.8160019934e-4f)); + u = mlaf(u, t, o2 ? -0.000592166437353693882857342347 : (o0 ? +0.4826702476e+0f : +0.1528468856e-3f)); + u = mlaf(u, t, o2 ? +6.97281375836585777403743539e-05 : (o0 ? -0.8855129778e-1f : -0.2355068718e-3f)); + u = mlaf(u, t, o2 ? +0.000784039221720066627493314301 : (o0 ? +0.1013825238e+0f : +0.4962242092e-3f)); + u = mlaf(u, t, o2 ? -0.000229472093621399176949318732 : (o0 ? -0.1493408978e+0f : -0.1193488017e-2f)); + u = mlaf(u, t, o2 ? -0.002681327160493827160473958490 : (o0 ? +0.1697509140e+0f : +0.2891599433e-2f)); + u = mlaf(u, t, o2 ? +0.003472222222222222222175164840 : (o0 ? -0.2072454542e+0f : -0.7385451812e-2f)); + u = mlaf(u, t, o2 ? +0.083333333333333333335592087900 : (o0 ? +0.2705872357e+0f : +0.2058077045e-1f)); + + y = dfmul_f2_f2_f2(dfadd2_f2_f2_f(x, -0.5), logk2f(x)); + y = dfadd2_f2_f2_f2(y, dfneg_f2_f2(x)); + y = dfadd2_f2_f2_f2(y, dfx(0.91893853320467278056)); // 0.5*log(2*M_PI) + + z = dfadd2_f2_f2_f(dfmul_f2_f_f (u, t), o0 ? -0.400686534596170958447352690395e+0f : -0.673523028297382446749257758235e-1f); + z = dfadd2_f2_f2_f(dfmul_f2_f2_f(z, t), o0 ? +0.822466960142643054450325495997e+0f : +0.322467033928981157743538726901e+0f); + z = dfadd2_f2_f2_f(dfmul_f2_f2_f(z, t), o0 ? -0.577215665946766039837398973297e+0f : +0.422784335087484338986941629852e+0f); + z = dfmul_f2_f2_f(z, t); + + clc = o2 ? y : z; + + clld = o2 ? dfadd2_f2_f2_f(dfmul_f2_f_f(u, t), 1) : clld; + + y = clln; + + clc = otiny ? dfx(41.58883083359671856503) : // log(2^60) + (oref ? dfadd2_f2_f2_f2(dfx(1.1447298858494001639), dfneg_f2_f2(clc)) : clc); // log(M_PI) + clln = otiny ? df(1, 0) : (oref ? clln : clld); + + if (oref) x = dfmul_f2_f2_f2(clld, sinpifk(a - (float)(INT64_C(1) << 12) * (int32_t)(a * (1.0 / (INT64_C(1) << 12))))); + + clld = otiny ? df(a*((INT64_C(1) << 30)*(float)(INT64_C(1) << 30)), 0) : (oref ? x : y); + + df2 ret = { clc, dfdiv_f2_f2_f2(clln, clld) }; + + return ret; +} + +EXPORT CONST float xtgammaf_u1(float a) { + df2 d = gammafk(a); + Sleef_float2 y = dfmul_f2_f2_f2(expk2f(d.a), d.b); + float r = y.x + y.y; + r = (a == -SLEEF_INFINITYf || (a < 0 && xisintf(a)) || (xisnumberf(a) && a < 0 && xisnanf(r))) ? SLEEF_NANf : r; + r = ((a == SLEEF_INFINITYf || xisnumberf(a)) && a >= -FLT_MIN && (a == 0 || a > 36 || xisnanf(r))) ? mulsignf(SLEEF_INFINITYf, a) : r; + return r; +} + +EXPORT CONST float xlgammaf_u1(float a) { + df2 d = gammafk(a); + Sleef_float2 y = dfadd2_f2_f2_f2(d.a, logk2f(dfabs_f2_f2(d.b))); + float r = y.x + y.y; + r = (xisinff(a) || (a <= 0 && xisintf(a)) || (xisnumberf(a) && xisnanf(r))) ? SLEEF_INFINITYf : r; + return r; +} + +static INLINE CONST Sleef_float2 dfmla(float x, Sleef_float2 y, Sleef_float2 z) { + return dfadd2_f2_f2_f2(z, dfmul_f2_f2_f(y, x)); +} +static INLINE CONST Sleef_float2 poly2df_b(float x, Sleef_float2 c1, Sleef_float2 c0) { return dfmla(x, c1, c0); } +static INLINE CONST Sleef_float2 poly2df(float x, float c1, Sleef_float2 c0) { return dfmla(x, df(c1, 0), c0); } +static INLINE CONST Sleef_float2 poly4df(float x, float c3, Sleef_float2 c2, Sleef_float2 c1, Sleef_float2 c0) { + return dfmla(x*x, poly2df(x, c3, c2), poly2df_b(x, c1, c0)); +} + +EXPORT CONST float xerff_u1(float a) { + float t, x = fabsfk(a); + Sleef_float2 t2; + float x2 = x * x, x4 = x2 * x2; + + if (x < 2.5) { + // Abramowitz and Stegun + t = POLY6(x, x2, x4, + -0.4360447008e-6, + +0.6867515367e-5, + -0.3045156700e-4, + +0.9808536561e-4, + +0.2395523916e-3, + +0.1459901541e-3); + t2 = poly4df(x, t, + df(0.0092883445322513580322, -2.7863745897025330755e-11), + df(0.042275499552488327026, 1.3461399289988106057e-09), + df(0.070523701608180999756, -3.6616309318707365163e-09)); + t2 = dfadd_f2_f_f2(1, dfmul_f2_f2_f(t2, x)); + t2 = dfsqu_f2_f2(t2); + t2 = dfsqu_f2_f2(t2); + t2 = dfsqu_f2_f2(t2); + t2 = dfsqu_f2_f2(t2); + t2 = dfrec_f2_f2(t2); + } else if (x > 4.0) { + t2 = df(0, 0); + } else { + t = POLY6(x, x2, x4, + -0.1130012848e-6, + +0.4115272986e-5, + -0.6928304356e-4, + +0.7172692567e-3, + -0.5131045356e-2, + +0.2708637156e-1); + t2 = poly4df(x, t, + df(-0.11064319312572479248, 3.7050452777225283007e-09), + df(-0.63192230463027954102, -2.0200432585073177859e-08), + df(-1.1296638250350952148, 2.5515120196453259252e-08)); + t2 = dfmul_f2_f2_f(t2, x); + t2 = df(expkf(t2), 0); + } + + t2 = dfadd2_f2_f2_f(t2, -1); + + if (x < 1e-4) t2 = dfmul_f2_f2_f(df(-1.1283792257308959961, 5.8635383422197591097e-08), x); + return mulsignf(a == 0 ? 0 : (xisinff(a) ? 1 : (-t2.x - t2.y)), a); +} + +EXPORT CONST float xerfcf_u15(float a) { + float s = a, r = 0, t; + Sleef_float2 u, d, x; + a = fabsfk(a); + int o0 = a < 1.0f, o1 = a < 2.2f, o2 = a < 4.3f, o3 = a < 10.1f; + u = o1 ? df(a, 0) : dfdiv_f2_f2_f2(df(1, 0), df(a, 0)); + + t = o0 ? -0.8638041618e-4f : o1 ? -0.6236977242e-5f : o2 ? -0.3869504035e+0f : +0.1115344167e+1f; + t = mlaf(t, u.x, o0 ? +0.6000166177e-3f : o1 ? +0.5749821503e-4f : o2 ? +0.1288077235e+1f : -0.9454904199e+0f); + t = mlaf(t, u.x, o0 ? -0.1665703603e-2f : o1 ? +0.6002851478e-5f : o2 ? -0.1816803217e+1f : -0.3667259514e+0f); + t = mlaf(t, u.x, o0 ? +0.1795156277e-3f : o1 ? -0.2851036377e-2f : o2 ? +0.1249150872e+1f : +0.7155663371e+0f); + t = mlaf(t, u.x, o0 ? +0.1914106123e-1f : o1 ? +0.2260518074e-1f : o2 ? -0.1328857988e+0f : -0.1262947265e-1f); + + d = dfmul_f2_f2_f(u, t); + d = dfadd2_f2_f2_f2(d, o0 ? dfx(-0.102775359343930288081655368891e+0) : + o1 ? dfx(-0.105247583459338632253369014063e+0) : + o2 ? dfx(-0.482365310333045318680618892669e+0) : + dfx(-0.498961546254537647970305302739e+0)); + d = dfmul_f2_f2_f2(d, u); + d = dfadd2_f2_f2_f2(d, o0 ? dfx(-0.636619483208481931303752546439e+0) : + o1 ? dfx(-0.635609463574589034216723775292e+0) : + o2 ? dfx(-0.134450203224533979217859332703e-2) : + dfx(-0.471199543422848492080722832666e-4)); + d = dfmul_f2_f2_f2(d, u); + d = dfadd2_f2_f2_f2(d, o0 ? dfx(-0.112837917790537404939545770596e+1) : + o1 ? dfx(-0.112855987376668622084547028949e+1) : + o2 ? dfx(-0.572319781150472949561786101080e+0) : + dfx(-0.572364030327966044425932623525e+0)); + + x = dfmul_f2_f2_f(o1 ? d : df(-a, 0), a); + x = o1 ? x : dfadd2_f2_f2_f2(x, d); + + x = expk2f(x); + x = o1 ? x : dfmul_f2_f2_f2(x, u); + + r = o3 ? (x.x + x.y) : 0; + if (s < 0) r = 2 - r; + r = xisnanf(s) ? SLEEF_NANf : r; + return r; +} + +// + +#ifdef ENABLE_MAIN +// gcc -w -DENABLE_MAIN -I../common sleefsp.c rempitab.c -lm +#include +int main(int argc, char **argv) { + float d1 = atof(argv[1]); + //float d2 = atof(argv[2]); + //float d3 = atof(argv[3]); + //printf("%.20g, %.20g\n", (double)d1, (double)d2); + //float i2 = atoi(argv[2]); + //float c = xatan2f_u1(d1, d2); + //printf("round %.20g\n", (double)d1); + printf("test = %.20g\n", (double)xsqrtf_u05(d1)); + //printf("correct = %.20g\n", (double)roundf(d1)); + //printf("rint %.20g\n", (double)d1); + //printf("test = %.20g\n", (double)xrintf(d1)); + //printf("correct = %.20g\n", (double)rintf(d1)); + //Sleef_float2 r = xsincospif_u35(d); + //printf("%g, %g\n", (double)r.x, (double)r.y); +} +#endif diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/tryvsx3.c b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/tryvsx3.c new file mode 100644 index 00000000000..b53c750b7cc --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/tryvsx3.c @@ -0,0 +1,8 @@ +#include + +__vector double sleef_cpuid_VSX0; +__vector unsigned long long sleef_cpuid_VSX1, sleef_cpuid_VSX3; + +void sleef_tryVSX3() { + sleef_cpuid_VSX0 = vec_insert_exp(sleef_cpuid_VSX1, sleef_cpuid_VSX3); +} diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/tryvxe2.c b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/tryvxe2.c new file mode 100644 index 00000000000..b4a73a9f863 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/libm/tryvxe2.c @@ -0,0 +1,8 @@ +#include + +__vector float sleef_cpuid_VXE2; +__vector int sleef_cpuid_VXE1; + +void sleef_tryVXE2() { + sleef_cpuid_VXE2 = vec_float(sleef_cpuid_VXE1); +} diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/quad-tester/CMakeLists.txt b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/quad-tester/CMakeLists.txt new file mode 100644 index 00000000000..f884f1b5b96 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/quad-tester/CMakeLists.txt @@ -0,0 +1,253 @@ +link_directories(${sleef_BINARY_DIR}/lib) # libsleefquad +link_directories(${sleef_BINARY_DIR}/src/common) # common.a +include_directories(${sleef_BINARY_DIR}/include) # sleef.h, sleefquad.h +include_directories(${sleef_SOURCE_DIR}/src/quad) # qrename.h +include_directories(${sleef_BINARY_DIR}/src/quad/include) # rename headers + +if(NOT LIB_MPFR) + find_program(QTESTER_COMMAND qtester) +endif(NOT LIB_MPFR) + +find_library(LIBRT rt) +if (NOT LIBRT) + set(LIBRT "") +endif() + +set(CMAKE_C_FLAGS "${ORG_CMAKE_C_FLAGS} ${SLEEF_C_FLAGS} ${FLAGS_NOSTRICTALIASING}") + +if(COMPILER_SUPPORTS_FLOAT128) + list(APPEND COMMON_TARGET_DEFINITIONS ENABLEFLOAT128=1) +endif() + +# + +if(SLEEF_OPENSSL_FOUND) + # Build tester3printf + add_executable(tester3printf tester3printf.c) + add_dependencies(tester3printf sleefquad sleefquad_headers ${TARGET_LIBSLEEF} ${TARGET_HEADERS}) + target_compile_definitions(tester3printf PRIVATE ${COMMON_TARGET_DEFINITIONS}) + set_target_properties(tester3printf PROPERTIES C_STANDARD 99) + target_link_libraries(tester3printf sleefquad ${TARGET_LIBSLEEF} ${SLEEF_OPENSSL_LIBRARIES}) + target_include_directories(tester3printf PRIVATE ${SLEEF_OPENSSL_INCLUDE_DIR}) + + if (SDE_COMMAND) + add_test(NAME tester3printf COMMAND ${SDE_COMMAND} "--" ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/tester3printf ${sleef_SOURCE_DIR}/src/quad-tester/hash_printf.txt) + elseif(EMULATOR) + add_test(NAME tester3printf COMMAND ${EMULATOR} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/tester3printf ${sleef_SOURCE_DIR}/src/quad-tester/hash_printf.txt) + else() + add_test(NAME tester3printf COMMAND tester3printf ${sleef_SOURCE_DIR}/src/quad-tester/hash_printf.txt) + endif() + set_tests_properties(tester3printf PROPERTIES COST 5.0) +endif() + +# + +function(add_test_iut IUT C) + if (LIB_MPFR) + set(QTESTER qtester) + elseif(QTESTER_COMMAND) + set(QTESTER ${QTESTER_COMMAND}) + endif() + # When we are crosscompiling using the mkrename* tools from a native + # build, we use the tester executable from the native build. + if (CMAKE_CROSSCOMPILING AND NATIVE_BUILD_DIR) + set(QTESTER ${NATIVE_BUILD_DIR}/bin/qtester) + endif(CMAKE_CROSSCOMPILING AND NATIVE_BUILD_DIR) + if (QTESTER) + if (NOT EMULATOR) + if (SDE_COMMAND) + set(FLAGS_SDE "--sde" ${SDE_COMMAND}) + else() + set(FLAGS_SDE) + endif() + if (ARMIE_COMMAND) + set(FLAGS_ARMIE ${ARMIE_COMMAND} -msve-vector-bits=${SVE_VECTOR_BITS}) + else() + set(FLAGS_ARMIE) + endif() + add_test(NAME ${IUT} + COMMAND ${QTESTER} ${FLAGS_SDE} ${FLAGS_ARMIE} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${IUT} + WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) + set_tests_properties(${IUT} PROPERTIES COST ${C}) + else() + add_test(NAME ${IUT} + COMMAND ${QTESTER} "--qemu" ${EMULATOR} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${IUT} + WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) + set_tests_properties(${IUT} PROPERTIES COST ${C}) + endif() + endif() +endfunction() + +# Add vector extension `iut`s +set(IUT_SRC qiutsimd.c ${sleef_SOURCE_DIR}/src/common/main_checkfeature.c qtesterutil.c) + +macro(test_extension SIMD) + if(COMPILER_SUPPORTS_${SIMD}) + string(TOLOWER ${SIMD} LCSIMD) + string(CONCAT TARGET_IUT${SIMD} "qiut" ${LCSIMD}) + + add_executable(${TARGET_IUT${SIMD}} ${IUT_SRC}) + target_compile_options(${TARGET_IUT${SIMD}} + PRIVATE ${FLAGS_ENABLE_${SIMD}}) + target_compile_definitions(${TARGET_IUT${SIMD}} + PRIVATE ENABLE_${SIMD}=1 ${COMMON_TARGET_DEFINITIONS}) + target_link_libraries(${TARGET_IUT${SIMD}} sleefquad ${TARGET_LIBSLEEF} ${LIBM} ${LIBRT}) + + add_dependencies(${TARGET_IUT${SIMD}} sleefquad_headers ${TARGET_HEADERS}) + add_dependencies(${TARGET_IUT${SIMD}} sleefquad ${TARGET_LIBSLEEF}) + set_target_properties(${TARGET_IUT${SIMD}} PROPERTIES C_STANDARD 99) + if (DEFINED COSTOVERRIDE_${SIMD}) + math(EXPR C "${COSTOVERRIDE_${SIMD}} + 1") + add_test_iut(${TARGET_IUT${SIMD}} ${C}) + else() + add_test_iut(${TARGET_IUT${SIMD}} 0.5) + endif() + list(APPEND IUT_LIST ${TARGET_IUT${SIMD}}) + + # The iut programs whose names begin with "qiuti" are the iut for the + # inline version of quad functions. + + if (SLEEF_BUILD_INLINE_HEADERS AND SED_COMMAND) + if (MSVC AND NOT SLEEF_CLANG_ON_WINDOWS) + message(STATUS "Quad inline headers are not tested with MSVC") + else() + string(CONCAT IUTINAME "qiuti" ${LCSIMD}) + add_executable(${IUTINAME} ${IUT_SRC}) + target_compile_options(${IUTINAME} + PRIVATE ${FLAGS_ENABLE_${SIMD}}) + target_compile_definitions(${IUTINAME} + PRIVATE ENABLE_${SIMD}=1 ${COMMON_TARGET_DEFINITIONS} + USE_INLINE_HEADER="sleefquadinline_${LCSIMD}.h" + MACRO_ONLY_HEADER="qmacroonly${SIMD}.h" + SIMD_SUFFIX=_${LCSIMD}_sleefq + ) + target_include_directories(${IUTINAME} PRIVATE ${PROJECT_BINARY_DIR}/include) + target_link_libraries(${IUTINAME} ${LIBM} ${LIBRT}) + add_dependencies(${IUTINAME} ${TARGET_QINLINE_HEADERS}) + set_target_properties(${IUTINAME} PROPERTIES C_STANDARD 99) + if (DEFINED COSTOVERRIDE_${SIMD}) + math(EXPR C "${COSTOVERRIDE_${SIMD}} + 1") + add_test_iut(${IUTINAME} ${C}) + else() + add_test_iut(${IUTINAME} 0.5) + endif() + list(APPEND IUT_LIST ${IUTINAME}) + endif() + endif(SLEEF_BUILD_INLINE_HEADERS AND SED_COMMAND) + + if(LIB_MPFR AND NOT MINGW) + # Build qtester2 SIMD + string(TOLOWER ${SIMD} SIMDLC) + set(T "tester2${SIMDLC}qp") + add_executable(${T} tester2simdqp.c qtesterutil.c) + target_compile_options(${T} PRIVATE ${FLAGS_ENABLE_${SIMD}}) + target_compile_definitions(${T} PRIVATE ENABLE_${SIMD}=1 USEMPFR=1 ${COMMON_TARGET_DEFINITIONS}) + set_target_properties(${T} PROPERTIES C_STANDARD 99) + target_link_libraries(${T} sleefquad ${TARGET_LIBSLEEF} ${LIB_MPFR} ${LIBM} ${LIBGMP}) + add_dependencies(${T} sleefquad sleefquad_headers ${TARGET_LIBSLEEF} ${TARGET_HEADERS}) + if (MPFR_INCLUDE_DIR) + target_include_directories(${T} PRIVATE ${MPFR_INCLUDE_DIR}) + endif() + endif() + endif(COMPILER_SUPPORTS_${SIMD}) +endmacro(test_extension) + +foreach(SIMD ${SLEEF_SUPPORTED_QUAD_EXTENSIONS}) + test_extension(${SIMD}) +endforeach() + +# Compile executable 'qiutdspscalar' + +add_executable(qiutdspscalar ${IUT_SRC}) +target_compile_definitions(qiutdspscalar PRIVATE ENABLE_DSPSCALAR=1 ${COMMON_TARGET_DEFINITIONS}) +target_link_libraries(qiutdspscalar sleefquad ${TARGET_LIBSLEEF} ${LIBM} ${LIBRT}) +set_target_properties(qiutdspscalar PROPERTIES C_STANDARD 99) +add_dependencies(qiutdspscalar sleefquad_headers ${TARGET_HEADERS}) +add_dependencies(qiutdspscalar sleefquad ${TARGET_LIBSLEEF}) +add_test_iut(qiutdspscalar 0.5) +list(APPEND IUT_LIST qiutdspscalar) + +if (SLEEF_ARCH_X86) + # Compile executable 'qiutdspx2' + add_executable(qiutdspx2 ${IUT_SRC}) + target_compile_definitions(qiutdspx2 PRIVATE ENABLE_DSPX2_X86=1 ${COMMON_TARGET_DEFINITIONS}) + target_link_libraries(qiutdspx2 sleefquad ${TARGET_LIBSLEEF} ${LIBM} ${LIBRT}) + set_target_properties(qiutdspx2 PROPERTIES C_STANDARD 99) + add_dependencies(qiutdspx2 sleefquad_headers ${TARGET_HEADERS}) + add_dependencies(qiutdspx2 sleefquad ${TARGET_LIBSLEEF}) + add_test_iut(qiutdspx2 0.5) + list(APPEND IUT_LIST qiutdspx2) +endif() + +if (SLEEF_ARCH_AARCH64) + # Compile executable 'qiutdspx2' + add_executable(qiutdspx2 ${IUT_SRC}) + target_compile_definitions(qiutdspx2 PRIVATE ENABLE_DSPX2_AARCH64=1 ${COMMON_TARGET_DEFINITIONS}) + set_target_properties(qiutdspx2 PROPERTIES C_STANDARD 99) + target_link_libraries(qiutdspx2 sleefquad ${TARGET_LIBSLEEF} ${LIBM} ${LIBRT}) + add_dependencies(qiutdspx2 sleefquad_headers ${TARGET_HEADERS}) + add_dependencies(qiutdspx2 sleefquad ${TARGET_LIBSLEEF}) + add_test_iut(qiutdspx2 0.5) + list(APPEND IUT_LIST qiutdspx2) +endif() + +if (SLEEF_ARCH_PPC64) + # Compile executable 'qiutdspx2' + add_executable(qiutdspx2 ${IUT_SRC}) + target_compile_options(qiutdspx2 PRIVATE ${FLAGS_ENABLE_VSX}) + set_target_properties(qiutdspx2 PROPERTIES C_STANDARD 99) + target_compile_definitions(qiutdspx2 PRIVATE ENABLE_DSPX2_PPC64=1 ${COMMON_TARGET_DEFINITIONS}) + target_link_libraries(qiutdspx2 sleefquad ${TARGET_LIBSLEEF} ${LIBM} ${LIBRT}) + add_dependencies(qiutdspx2 sleefquad_headers ${TARGET_HEADERS}) + add_dependencies(qiutdspx2 sleefquad ${TARGET_LIBSLEEF}) + add_test_iut(qiutdspx2 0.5) + list(APPEND IUT_LIST qiutdspx2) +endif() + +if (SLEEF_ARCH_S390X) + # Compile executable 'qiutdspx2' + add_executable(qiutdspx2 ${IUT_SRC}) + target_compile_options(qiutdspx2 PRIVATE ${FLAGS_ENABLE_VXE}) + set_target_properties(qiutdspx2 PROPERTIES C_STANDARD 99) + target_compile_definitions(qiutdspx2 PRIVATE ENABLE_DSPX2_S390X=1 ${COMMON_TARGET_DEFINITIONS}) + target_link_libraries(qiutdspx2 sleefquad ${TARGET_LIBSLEEF} ${LIBM} ${LIBRT}) + add_dependencies(qiutdspx2 sleefquad_headers ${TARGET_HEADERS}) + add_dependencies(qiutdspx2 sleefquad ${TARGET_LIBSLEEF}) + add_test_iut(qiutdspx2 0.5) + list(APPEND IUT_LIST qiutdspx2) +endif() + +# Compile executable 'qiutcuda' + +if (SLEEF_BUILD_INLINE_HEADERS AND SED_COMMAND AND CMAKE_CUDA_COMPILER) + add_executable(qiutcuda qiutcuda.cu) + set_target_properties(qiutcuda PROPERTIES LINKER_LANGUAGE CUDA) + target_compile_options(qiutcuda PRIVATE "--fmad=false;-Xcompiler;-ffp-contract=off") + add_dependencies(qiutcuda ${TARGET_QINLINE_HEADERS}) + add_test_iut(qiutcuda 1.0) + list(APPEND IUT_LIST qiutcuda) +endif() + +# + +if(LIB_MPFR AND NOT MINGW) + # Compile executable 'qtester' + add_host_executable(qtester qtester.c qtesterutil.c) + if (NOT CMAKE_CROSSCOMPILING) + target_link_libraries(qtester sleefquad ${TARGET_LIBSLEEF} ${LIBM} ${LIB_MPFR} ${LIBGMP}) + target_compile_definitions(qtester PRIVATE USEMPFR=1 ${COMMON_TARGET_DEFINITIONS}) + target_compile_options(qtester PRIVATE -Wno-unused-result) + set_target_properties(qtester PROPERTIES C_STANDARD 99) + if (MPFR_INCLUDE_DIR) + target_include_directories(qtester PRIVATE ${MPFR_INCLUDE_DIR}) + endif() + endif() +endif(LIB_MPFR AND NOT MINGW) + +# BUild qutil + +add_executable(qutil qutil.c) +add_dependencies(qutil sleefquad sleefquad_headers ${TARGET_LIBSLEEF} ${TARGET_HEADERS}) +target_compile_definitions(qutil PRIVATE ${COMMON_TARGET_DEFINITIONS}) +set_target_properties(qutil PROPERTIES C_STANDARD 99) +target_link_libraries(qutil sleefquad) diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/quad-tester/hash_printf.txt b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/quad-tester/hash_printf.txt new file mode 100644 index 00000000000..5e6919d554c --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/quad-tester/hash_printf.txt @@ -0,0 +1,4 @@ +Pe 7ff4a1686c831c7a9b1bd62faffe9b14 +Pf 84331dfc378b032877f7a07767db7cc5 +Pg 2351f96a90d34bf4dd80dd6341a47624 +Pa ad6bb18af2f2648e791098ebf87ce25d diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/quad-tester/qiutcuda.cu b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/quad-tester/qiutcuda.cu new file mode 100644 index 00000000000..3baca09029e --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/quad-tester/qiutcuda.cu @@ -0,0 +1,472 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "sleefquadinline_cuda.h" +#include "sleefquadinline_purec_scalar.h" + +#define STDIN_FILENO 0 + +// + +static int startsWith(const char *str, const char *prefix) { + while(*prefix != '\0') if (*str++ != *prefix++) return 0; + return *prefix == '\0'; +} + +static double u2d(uint64_t u) { + union { + double f; + uint64_t i; + } tmp; + tmp.i = u; + return tmp.f; +} + +static uint64_t d2u(double d) { + union { + double f; + uint64_t i; + } tmp; + tmp.f = d; + return tmp.i; +} + +// + +__global__ void xaddq_u05(Sleef_quadx1 *r, Sleef_quadx1 *a0, Sleef_quadx1 *a1) { *r = Sleef_addq1_u05cuda(*a0, *a1); } +__global__ void xsubq_u05(Sleef_quadx1 *r, Sleef_quadx1 *a0, Sleef_quadx1 *a1) { *r = Sleef_subq1_u05cuda(*a0, *a1); } +__global__ void xmulq_u05(Sleef_quadx1 *r, Sleef_quadx1 *a0, Sleef_quadx1 *a1) { *r = Sleef_mulq1_u05cuda(*a0, *a1); } +__global__ void xdivq_u05(Sleef_quadx1 *r, Sleef_quadx1 *a0, Sleef_quadx1 *a1) { *r = Sleef_divq1_u05cuda(*a0, *a1); } +__global__ void xnegq(Sleef_quadx1 *r, Sleef_quadx1 *a0) { *r = Sleef_negq1_cuda(*a0); } + +__global__ void xicmpltq(int *r, Sleef_quadx1 *a0, Sleef_quadx1 *a1) { *r = Sleef_icmpltq1_cuda(*a0, *a1); } +__global__ void xicmpgtq(int *r, Sleef_quadx1 *a0, Sleef_quadx1 *a1) { *r = Sleef_icmpgtq1_cuda(*a0, *a1); } +__global__ void xicmpleq(int *r, Sleef_quadx1 *a0, Sleef_quadx1 *a1) { *r = Sleef_icmpleq1_cuda(*a0, *a1); } +__global__ void xicmpgeq(int *r, Sleef_quadx1 *a0, Sleef_quadx1 *a1) { *r = Sleef_icmpgeq1_cuda(*a0, *a1); } +__global__ void xicmpeqq(int *r, Sleef_quadx1 *a0, Sleef_quadx1 *a1) { *r = Sleef_icmpeqq1_cuda(*a0, *a1); } +__global__ void xicmpneq(int *r, Sleef_quadx1 *a0, Sleef_quadx1 *a1) { *r = Sleef_icmpneq1_cuda(*a0, *a1); } +__global__ void xicmpq(int *r, Sleef_quadx1 *a0, Sleef_quadx1 *a1) { *r = Sleef_icmpq1_cuda(*a0, *a1); } +__global__ void xiunordq(int *r, Sleef_quadx1 *a0, Sleef_quadx1 *a1) { *r = Sleef_iunordq1_cuda(*a0, *a1); } + +__global__ void xcast_from_doubleq(Sleef_quadx1 *r0, double *d0) { *r0 = Sleef_cast_from_doubleq1_cuda(*d0); } +__global__ void xcast_to_doubleq(double *r0, Sleef_quadx1 *a0) { *r0 = Sleef_cast_to_doubleq1_cuda(*a0); } +__global__ void xcast_from_int64q(Sleef_quadx1 *r0, int64_t *i0) { *r0 = Sleef_cast_from_int64q1_cuda(*i0); } +__global__ void xcast_to_int64q(int64_t *r0, Sleef_quadx1 *a0) { *r0 = Sleef_cast_to_int64q1_cuda(*a0); } +__global__ void xcast_from_uint64q(Sleef_quadx1 *r0, uint64_t *u0) { *r0 = Sleef_cast_from_uint64q1_cuda(*u0); } +__global__ void xcast_to_uint64q(uint64_t *r0, Sleef_quadx1 *a0) { *r0 = Sleef_cast_to_uint64q1_cuda(*a0); } + +__global__ void xsqrtq_u05(Sleef_quadx1 *r, Sleef_quadx1 *a0) { *r = Sleef_sqrtq1_u05cuda(*a0); } +__global__ void xcbrtq_u10(Sleef_quadx1 *r, Sleef_quadx1 *a0) { *r = Sleef_cbrtq1_u10cuda(*a0); } +__global__ void xsinq_u10(Sleef_quadx1 *r, Sleef_quadx1 *a0) { *r = Sleef_sinq1_u10cuda(*a0); } +__global__ void xcosq_u10(Sleef_quadx1 *r, Sleef_quadx1 *a0) { *r = Sleef_cosq1_u10cuda(*a0); } +__global__ void xtanq_u10(Sleef_quadx1 *r, Sleef_quadx1 *a0) { *r = Sleef_tanq1_u10cuda(*a0); } +__global__ void xasinq_u10(Sleef_quadx1 *r, Sleef_quadx1 *a0) { *r = Sleef_asinq1_u10cuda(*a0); } +__global__ void xacosq_u10(Sleef_quadx1 *r, Sleef_quadx1 *a0) { *r = Sleef_acosq1_u10cuda(*a0); } +__global__ void xatanq_u10(Sleef_quadx1 *r, Sleef_quadx1 *a0) { *r = Sleef_atanq1_u10cuda(*a0); } +__global__ void xatan2q_u10(Sleef_quadx1 *r, Sleef_quadx1 *a0, Sleef_quadx1 *a1) { *r = Sleef_atan2q1_u10cuda(*a0, *a1); } +__global__ void xexpq_u10(Sleef_quadx1 *r, Sleef_quadx1 *a0) { *r = Sleef_expq1_u10cuda(*a0); } +__global__ void xexp2q_u10(Sleef_quadx1 *r, Sleef_quadx1 *a0) { *r = Sleef_exp2q1_u10cuda(*a0); } +__global__ void xexp10q_u10(Sleef_quadx1 *r, Sleef_quadx1 *a0) { *r = Sleef_exp10q1_u10cuda(*a0); } +__global__ void xexpm1q_u10(Sleef_quadx1 *r, Sleef_quadx1 *a0) { *r = Sleef_expm1q1_u10cuda(*a0); } +__global__ void xlogq_u10(Sleef_quadx1 *r, Sleef_quadx1 *a0) { *r = Sleef_logq1_u10cuda(*a0); } +__global__ void xlog2q_u10(Sleef_quadx1 *r, Sleef_quadx1 *a0) { *r = Sleef_log2q1_u10cuda(*a0); } +__global__ void xlog10q_u10(Sleef_quadx1 *r, Sleef_quadx1 *a0) { *r = Sleef_log10q1_u10cuda(*a0); } +__global__ void xlog1pq_u10(Sleef_quadx1 *r, Sleef_quadx1 *a0) { *r = Sleef_log1pq1_u10cuda(*a0); } +__global__ void xpowq_u10(Sleef_quadx1 *r, Sleef_quadx1 *a0, Sleef_quadx1 *a1) { *r = Sleef_powq1_u10cuda(*a0, *a1); } +__global__ void xsinhq_u10(Sleef_quadx1 *r, Sleef_quadx1 *a0) { *r = Sleef_sinhq1_u10cuda(*a0); } +__global__ void xcoshq_u10(Sleef_quadx1 *r, Sleef_quadx1 *a0) { *r = Sleef_coshq1_u10cuda(*a0); } +__global__ void xtanhq_u10(Sleef_quadx1 *r, Sleef_quadx1 *a0) { *r = Sleef_tanhq1_u10cuda(*a0); } +__global__ void xasinhq_u10(Sleef_quadx1 *r, Sleef_quadx1 *a0) { *r = Sleef_asinhq1_u10cuda(*a0); } +__global__ void xacoshq_u10(Sleef_quadx1 *r, Sleef_quadx1 *a0) { *r = Sleef_acoshq1_u10cuda(*a0); } +__global__ void xatanhq_u10(Sleef_quadx1 *r, Sleef_quadx1 *a0) { *r = Sleef_atanhq1_u10cuda(*a0); } + +__global__ void xfabsq(Sleef_quadx1 *r, Sleef_quadx1 *a0) { *r = Sleef_fabsq1_cuda(*a0); } +__global__ void xcopysignq(Sleef_quadx1 *r, Sleef_quadx1 *a0, Sleef_quadx1 *a1) { *r = Sleef_copysignq1_cuda(*a0, *a1); } +__global__ void xfmaxq(Sleef_quadx1 *r, Sleef_quadx1 *a0, Sleef_quadx1 *a1) { *r = Sleef_fmaxq1_cuda(*a0, *a1); } +__global__ void xfminq(Sleef_quadx1 *r, Sleef_quadx1 *a0, Sleef_quadx1 *a1) { *r = Sleef_fminq1_cuda(*a0, *a1); } +__global__ void xfdimq_u05(Sleef_quadx1 *r, Sleef_quadx1 *a0, Sleef_quadx1 *a1) { *r = Sleef_fdimq1_u05cuda(*a0, *a1); } +__global__ void xfmodq(Sleef_quadx1 *r, Sleef_quadx1 *a0, Sleef_quadx1 *a1) { *r = Sleef_fmodq1_cuda(*a0, *a1); } +__global__ void xremainderq(Sleef_quadx1 *r, Sleef_quadx1 *a0, Sleef_quadx1 *a1) { *r = Sleef_remainderq1_cuda(*a0, *a1); } +__global__ void xfrexpq(Sleef_quadx1 *r, Sleef_quadx1 *a0, int *i0) { *r = Sleef_frexpq1_cuda(*a0, i0); } +__global__ void xmodfq(Sleef_quadx1 *r, Sleef_quadx1 *a0, Sleef_quadx1 *a1) { *r = Sleef_modfq1_cuda(*a0, a1); } +__global__ void xfmaq_u05(Sleef_quadx1 *r, Sleef_quadx1 *a0, Sleef_quadx1 *a1, Sleef_quadx1 *a2) { *r = Sleef_fmaq1_u05cuda(*a0, *a1, *a2); } +__global__ void xhypotq_u05(Sleef_quadx1 *r, Sleef_quadx1 *a0, Sleef_quadx1 *a1) { *r = Sleef_hypotq1_u05cuda(*a0, *a1); } +__global__ void xilogbq(int *r, Sleef_quadx1 *a0) { *r = Sleef_ilogbq1_cuda(*a0); } +__global__ void xldexpq(Sleef_quadx1 *r, Sleef_quadx1 *a0, int *i0) { *r = Sleef_ldexpq1_cuda(*a0, *i0); } + +__global__ void xtruncq(Sleef_quadx1 *r, Sleef_quadx1 *a0) { *r = Sleef_truncq1_cuda(*a0); } +__global__ void xfloorq(Sleef_quadx1 *r, Sleef_quadx1 *a0) { *r = Sleef_floorq1_cuda(*a0); } +__global__ void xceilq(Sleef_quadx1 *r, Sleef_quadx1 *a0) { *r = Sleef_ceilq1_cuda(*a0); } +__global__ void xroundq(Sleef_quadx1 *r, Sleef_quadx1 *a0) { *r = Sleef_roundq1_cuda(*a0); } +__global__ void xrintq(Sleef_quadx1 *r, Sleef_quadx1 *a0) { *r = Sleef_rintq1_cuda(*a0); } + +// + +typedef union { + Sleef_quad q; + struct { + uint64_t l, h; + }; +} cnv128; + +#define BUFSIZE 1024 + +#define func_q_q(funcStr, funcName) { \ + while (startsWith(buf, funcStr " ")) { \ + sentinel = 0; \ + cnv128 c0; \ + sscanf(buf, funcStr " %" PRIx64 ":%" PRIx64, &c0.h, &c0.l); \ + *a0 = Sleef_setq1_cuda(*a0, 0, c0.q); \ + funcName<<<1, 1>>>(r, a0); \ + cudaDeviceSynchronize(); \ + c0.q = Sleef_getq1_cuda(*r, 0); \ + printf("%" PRIx64 ":%" PRIx64 "\n", c0.h, c0.l); \ + fflush(stdout); \ + if (fgets(buf, BUFSIZE-1, stdin) == NULL) break; \ + } \ + } + +#define func_q_q_q(funcStr, funcName) { \ + while (startsWith(buf, funcStr " ")) { \ + sentinel = 0; \ + cnv128 c0, c1; \ + sscanf(buf, funcStr " %" PRIx64 ":%" PRIx64 " %" PRIx64 ":%" PRIx64, &c0.h, &c0.l, &c1.h, &c1.l); \ + *a0 = Sleef_setq1_cuda(*a0, 0, c0.q); \ + *a1 = Sleef_setq1_cuda(*a1, 0, c1.q); \ + funcName<<<1, 1>>>(r, a0, a1); \ + cudaDeviceSynchronize(); \ + c0.q = Sleef_getq1_cuda(*r, 0); \ + printf("%" PRIx64 ":%" PRIx64 "\n", c0.h, c0.l); \ + fflush(stdout); \ + if (fgets(buf, BUFSIZE-1, stdin) == NULL) break; \ + } \ + } + +#define func_q_q_q_q(funcStr, funcName) { \ + while (startsWith(buf, funcStr " ")) { \ + sentinel = 0; \ + cnv128 c0, c1, c2; \ + sscanf(buf, funcStr " %" PRIx64 ":%" PRIx64 " %" PRIx64 ":%" PRIx64 " %" PRIx64 ":%" PRIx64, \ + &c0.h, &c0.l, &c1.h, &c1.l, &c2.h, &c2.l); \ + *a0 = Sleef_setq1_cuda(*a0, 0, c0.q); \ + *a1 = Sleef_setq1_cuda(*a1, 0, c1.q); \ + *a2 = Sleef_setq1_cuda(*a2, 0, c2.q); \ + funcName<<<1, 1>>>(r, a0, a1, a2); \ + cudaDeviceSynchronize(); \ + c0.q = Sleef_getq1_cuda(*r, 0); \ + printf("%" PRIx64 ":%" PRIx64 "\n", c0.h, c0.l); \ + fflush(stdout); \ + if (fgets(buf, BUFSIZE-1, stdin) == NULL) break; \ + } \ + } + +#define func_i_q(funcStr, funcName) { \ + while (startsWith(buf, funcStr " ")) { \ + sentinel = 0; \ + cnv128 c0; \ + sscanf(buf, funcStr " %" PRIx64 ":%" PRIx64, &c0.h, &c0.l); \ + *a0 = Sleef_setq1_cuda(*a0, 0, c0.q); \ + funcName<<<1, 1>>>(i0, a0); \ + cudaDeviceSynchronize(); \ + printf("%d\n", *i0); \ + fflush(stdout); \ + if (fgets(buf, BUFSIZE-1, stdin) == NULL) break; \ + } \ + } + +#define func_i_q_q(funcStr, funcName) { \ + while (startsWith(buf, funcStr " ")) { \ + sentinel = 0; \ + cnv128 c0, c1; \ + sscanf(buf, funcStr " %" PRIx64 ":%" PRIx64 " %" PRIx64 ":%" PRIx64, &c0.h, &c0.l, &c1.h, &c1.l); \ + *a0 = Sleef_setq1_cuda(*a0, 0, c0.q); \ + *a1 = Sleef_setq1_cuda(*a1, 0, c1.q); \ + funcName<<<1, 1>>>(i0, a0, a1); \ + cudaDeviceSynchronize(); \ + printf("%d\n", *i0); \ + fflush(stdout); \ + if (fgets(buf, BUFSIZE-1, stdin) == NULL) break; \ + } \ + } + +#define func_q_q_i(funcStr, funcName) { \ + while (startsWith(buf, funcStr " ")) { \ + sentinel = 0; \ + cnv128 c0; \ + int k; \ + sscanf(buf, funcStr " %" PRIx64 ":%" PRIx64 " %d", &c0.h, &c0.l, &k); \ + *a0 = Sleef_setq1_cuda(*a0, 0, c0.q); \ + *i0 = k; \ + funcName<<<1, 1>>>(r, a0, i0); \ + cudaDeviceSynchronize(); \ + c0.q = Sleef_getq1_cuda(*r, 0); \ + printf("%" PRIx64 ":%" PRIx64 "\n", c0.h, c0.l); \ + fflush(stdout); \ + if (fgets(buf, BUFSIZE-1, stdin) == NULL) break; \ + } \ + } + +#define func_d_q(funcStr, funcName) { \ + while (startsWith(buf, funcStr " ")) { \ + sentinel = 0; \ + cnv128 c0; \ + sscanf(buf, funcStr " %" PRIx64 ":%" PRIx64, &c0.h, &c0.l); \ + *a0 = Sleef_setq1_cuda(*a0, 0, c0.q); \ + funcName<<<1, 1>>>(d0, a0); \ + cudaDeviceSynchronize(); \ + printf("%" PRIx64 "\n", d2u(*d0)); \ + fflush(stdout); \ + if (fgets(buf, BUFSIZE-1, stdin) == NULL) break; \ + } \ + } + +#define func_q_d(funcStr, funcName) { \ + while (startsWith(buf, funcStr " ")) { \ + sentinel = 0; \ + uint64_t u; \ + sscanf(buf, funcStr " %" PRIx64, &u); \ + *d0 = u2d(u); \ + funcName<<<1, 1>>>(r, d0); \ + cudaDeviceSynchronize(); \ + cnv128 c0; \ + c0.q = Sleef_getq1_cuda(*r, 0); \ + printf("%" PRIx64 ":%" PRIx64 "\n", c0.h, c0.l); \ + fflush(stdout); \ + if (fgets(buf, BUFSIZE-1, stdin) == NULL) break; \ + } \ + } + +#define func_i64_q(funcStr, funcName) { \ + while (startsWith(buf, funcStr " ")) { \ + sentinel = 0; \ + cnv128 c0; \ + sscanf(buf, funcStr " %" PRIx64 ":%" PRIx64, &c0.h, &c0.l); \ + *a0 = Sleef_setq1_cuda(*a0, 0, c0.q); \ + funcName<<<1, 1>>>(i64, a0); \ + cudaDeviceSynchronize(); \ + printf("%" PRIx64 "\n", *i64); \ + fflush(stdout); \ + if (fgets(buf, BUFSIZE-1, stdin) == NULL) break; \ + } \ + } + +#define func_q_i64(funcStr, funcName) { \ + while (startsWith(buf, funcStr " ")) { \ + sentinel = 0; \ + sscanf(buf, funcStr " %" PRIx64, i64); \ + funcName<<<1, 1>>>(r, i64); \ + cudaDeviceSynchronize(); \ + cnv128 c0; \ + c0.q = Sleef_getq1_cuda(*r, 0); \ + printf("%" PRIx64 ":%" PRIx64 "\n", c0.h, c0.l); \ + fflush(stdout); \ + if (fgets(buf, BUFSIZE-1, stdin) == NULL) break; \ + } \ + } + +#define func_u64_q(funcStr, funcName) { \ + while (startsWith(buf, funcStr " ")) { \ + sentinel = 0; \ + cnv128 c0; \ + sscanf(buf, funcStr " %" PRIx64 ":%" PRIx64, &c0.h, &c0.l); \ + *a0 = Sleef_setq1_cuda(*a0, 0, c0.q); \ + funcName<<<1, 1>>>(u64, a0); \ + cudaDeviceSynchronize(); \ + printf("%" PRIx64 "\n", *u64); \ + fflush(stdout); \ + if (fgets(buf, BUFSIZE-1, stdin) == NULL) break; \ + } \ + } + +#define func_q_u64(funcStr, funcName) { \ + while (startsWith(buf, funcStr " ")) { \ + sentinel = 0; \ + sscanf(buf, funcStr " %" PRIx64, u64); \ + funcName<<<1, 1>>>(r, u64); \ + cudaDeviceSynchronize(); \ + cnv128 c0; \ + c0.q = Sleef_getq1_cuda(*r, 0); \ + printf("%" PRIx64 ":%" PRIx64 "\n", c0.h, c0.l); \ + fflush(stdout); \ + if (fgets(buf, BUFSIZE-1, stdin) == NULL) break; \ + } \ + } + +#define func_q_q_pi(funcStr, funcName) { \ + while (startsWith(buf, funcStr " ")) { \ + sentinel = 0; \ + cnv128 c0; \ + sscanf(buf, funcStr " %" PRIx64 ":%" PRIx64, &c0.h, &c0.l); \ + *a0 = Sleef_setq1_cuda(*a0, 0, c0.q); \ + funcName<<<1, 1>>>(r, a0, i0); \ + cudaDeviceSynchronize(); \ + c0.q = Sleef_getq1_cuda(*r, 0); \ + printf("%" PRIx64 ":%" PRIx64 " %d\n", c0.h, c0.l, *i0); \ + fflush(stdout); \ + if (fgets(buf, BUFSIZE-1, stdin) == NULL) break; \ + } \ + } + +#define func_q_q_pq(funcStr, funcName) { \ + while (startsWith(buf, funcStr " ")) { \ + sentinel = 0; \ + cnv128 c0, c1; \ + sscanf(buf, funcStr " %" PRIx64 ":%" PRIx64, &c0.h, &c0.l); \ + *a0 = Sleef_setq1_cuda(*a0, 0, c0.q); \ + funcName<<<1, 1>>>(r, a0, a1); \ + cudaDeviceSynchronize(); \ + c0.q = Sleef_getq1_cuda(*r, 0); \ + c1.q = Sleef_getq1_cuda(*a1, 0); \ + printf("%" PRIx64 ":%" PRIx64 " %" PRIx64 ":%" PRIx64 "\n", c0.h, c0.l, c1.h, c1.l); \ + fflush(stdout); \ + if (fgets(buf, BUFSIZE-1, stdin) == NULL) break; \ + } \ + } + +int main(int argc, char **argv) { +#if 0 + cuInit(0); + + int ndevice; + cuDeviceGetCount(&ndevice); + if (ndevice == 0) { + fprintf(stderr, "No cuda device available\n"); + exit(0); + } + + CUdevice device; + char deviceName[1024]; + cuDeviceGet(&device, 0); + cuDeviceGetName(deviceName, 1000, device); + fprintf(stderr, "Device : %s\n", deviceName); +#endif + + cudaSetDeviceFlags(cudaDeviceScheduleSpin); + + Sleef_quadx1 *r, *a0, *a1, *a2; + double *d0; + int *i0; + int64_t *i64; + uint64_t *u64; + cudaMallocManaged(&r , 1*sizeof(Sleef_quadx1)); + cudaMallocManaged(&a0, 1*sizeof(Sleef_quadx1)); + cudaMallocManaged(&a1, 1*sizeof(Sleef_quadx1)); + cudaMallocManaged(&a2, 1*sizeof(Sleef_quadx1)); + cudaMallocManaged(&d0, 1*sizeof(double)); + cudaMallocManaged(&i0, 1*sizeof(int)); + cudaMallocManaged(&i64, 1*sizeof(int64_t)); + cudaMallocManaged(&u64, 1*sizeof(uint64_t)); + + // + + printf("1\n"); + fflush(stdout); + + // + + { + *a0 = Sleef_setq1_cuda(*a0, 0, SLEEF_M_PIq); + *a1 = Sleef_setq1_cuda(*a1, 0, Sleef_strtoq("2.718281828459045235360287471352662498", NULL)); + xmulq_u05<<<1, 1>>>(r, a0, a1); + cudaDeviceSynchronize(); + Sleef_quad v0 = Sleef_getq1_cuda(*r, 0); + if (Sleef_icmpneq1_purec(v0, sleef_q(+0x1114580b45d47LL, 0x49e6108579a2d0caULL, 3))) { + fprintf(stderr, "Testing with Sleef_mulq1_u05cuda failed\n"); + exit(-1); + } + } + + // + + char buf[BUFSIZE]; + if (fgets(buf, BUFSIZE-1, stdin)) {} + int sentinel = 0; + + while(!feof(stdin) && sentinel < 2) { + func_q_q_q("addq_u05", xaddq_u05); + func_q_q_q("subq_u05", xsubq_u05); + func_q_q_q("mulq_u05", xmulq_u05); + func_q_q_q("divq_u05", xdivq_u05); + func_q_q("sqrtq_u05", xsqrtq_u05); + func_q_q("cbrtq_u10", xcbrtq_u10); + func_q_q("sinq_u10", xsinq_u10); + func_q_q("cosq_u10", xcosq_u10); + func_q_q("tanq_u10", xtanq_u10); + func_q_q("asinq_u10", xasinq_u10); + func_q_q("acosq_u10", xacosq_u10); + func_q_q("atanq_u10", xatanq_u10); + func_q_q_q("atan2q_u10", xatan2q_u10); + func_q_q("expq_u10", xexpq_u10); + func_q_q("exp2q_u10", xexp2q_u10); + func_q_q("exp10q_u10", xexp10q_u10); + func_q_q("expm1q_u10", xexpm1q_u10); + func_q_q("logq_u10", xlogq_u10); + func_q_q("log2q_u10", xlog2q_u10); + func_q_q("log10q_u10", xlog10q_u10); + func_q_q("log1pq_u10", xlog1pq_u10); + func_q_q_q("powq_u10", xpowq_u10); + func_q_q("sinhq_u10", xsinhq_u10); + func_q_q("coshq_u10", xcoshq_u10); + func_q_q("tanhq_u10", xtanhq_u10); + func_q_q("asinhq_u10", xasinhq_u10); + func_q_q("acoshq_u10", xacoshq_u10); + func_q_q("atanhq_u10", xatanhq_u10); + + func_q_q("negq", xnegq); + func_q_q("fabsq", xfabsq); + func_q_q_q("copysignq", xcopysignq); + func_q_q_q("fmaxq", xfmaxq); + func_q_q_q("fminq", xfminq); + func_q_q_q("fdimq_u05", xfdimq_u05); + func_q_q_q("fmodq", xfmodq); + func_q_q_q("remainderq", xremainderq); + func_q_q_pi("frexpq", xfrexpq); + func_q_q_pq("modfq", xmodfq); + func_i_q("ilogbq", xilogbq); + func_q_q_i("ldexpq", xldexpq); + func_q_q_q_q("fmaq_u05", xfmaq_u05); + func_q_q_q("hypotq_u05", xhypotq_u05); + + func_q_q("truncq", xtruncq); + func_q_q("floorq", xfloorq); + func_q_q("ceilq", xceilq); + func_q_q("roundq", xroundq); + func_q_q("rintq", xrintq); + + func_q_d("cast_from_doubleq", xcast_from_doubleq); + func_d_q("cast_to_doubleq", xcast_to_doubleq); + func_q_i64("cast_from_int64q", xcast_from_int64q); + func_i64_q("cast_to_int64q", xcast_to_int64q); + func_q_u64("cast_from_uint64q", xcast_from_uint64q); + func_u64_q("cast_to_uint64q", xcast_to_uint64q); + + func_i_q_q("icmpltq", xicmpltq); + func_i_q_q("icmpgtq", xicmpgtq); + func_i_q_q("icmpleq", xicmpleq); + func_i_q_q("icmpgeq", xicmpgeq); + func_i_q_q("icmpeqq", xicmpeqq); + func_i_q_q("icmpneq", xicmpneq); + func_i_q_q("icmpq", xicmpq); + func_i_q_q("iunordq", xiunordq); + + sentinel++; + } + + // + + return 0; +} diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/quad-tester/qiutsimd.c b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/quad-tester/qiutsimd.c new file mode 100644 index 00000000000..b15eecf8bae --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/quad-tester/qiutsimd.c @@ -0,0 +1,804 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include +#include +#include + +#include + +#if defined(_MSC_VER) +#define STDIN_FILENO 0 +#else +#include +#include +#endif + +#include "quaddef.h" +#include "misc.h" + +#if !defined(USE_INLINE_HEADER) +#include "sleef.h" +#include "sleefquad.h" +#else // #if !defined(USE_INLINE_HEADER) +#include +#include +#include +#include +#include +#include + +#if defined(__AVX2__) || defined(__aarch64__) || defined(__arm__) || defined(__powerpc64__) +#ifndef FP_FAST_FMA +#define FP_FAST_FMA +#endif +#endif + +#if defined(_MSC_VER) && !defined(__STDC__) +#define __STDC__ 1 +#endif + +#if (defined(__GNUC__) || defined(__CLANG__)) && (defined(__i386__) || defined(__x86_64__)) +#include +#endif + +#if (defined(_MSC_VER)) +#include +#endif + +#if defined(__ARM_NEON__) || defined(__ARM_NEON) +#include +#endif + +#if defined(__ARM_FEATURE_SVE) +#include +#endif + +#if defined(__riscv) && defined(__riscv_v) +#include +#endif + +#if defined(__VSX__) +#include +#endif + +#if defined(__VX__) +#include +#endif + +#define SLEEF_ALWAYS_INLINE inline +#define SLEEF_INLINE +#define SLEEF_CONST +#include USE_INLINE_HEADER +#include MACRO_ONLY_HEADER + +#ifndef ENABLE_PUREC_SCALAR +#include "sleefquadinline_purec_scalar.h" +#endif + +#endif // #if !defined(USE_INLINE_HEADER) + +#include "qtesterutil.h" + +// + +#ifdef ENABLE_PUREC_SCALAR +#include "qrenamepurec_scalar.h" +#if !defined(USE_INLINE_HEADER) +#define CONFIG 1 +#include "helperpurec_scalar.h" +#define VARGQUAD Sleef_quad +#endif +#endif + +#ifdef ENABLE_PURECFMA_SCALAR +#include "qrenamepurecfma_scalar.h" +#if !defined(USE_INLINE_HEADER) +#define CONFIG 2 +#include "helperpurec_scalar.h" +#define VARGQUAD Sleef_quad +#endif +#endif + +#ifdef ENABLE_DSPSCALAR +#include "qrenamedspscalar.h" +#define CONFIG 1 +#include "helperpurec_scalar.h" +#define VARGQUAD Sleef_quad +#endif + +#ifdef ENABLE_SSE2 +#include "qrenamesse2.h" +#if !defined(USE_INLINE_HEADER) +#define CONFIG 2 +#include "helpersse2.h" +#define VARGQUAD Sleef_quadx2 +#endif +#endif + +#ifdef ENABLE_AVX2128 +#include "qrenameavx2128.h" +#if !defined(USE_INLINE_HEADER) +#define CONFIG 1 +#include "helperavx2_128.h" +#define VARGQUAD Sleef_quadx2 +#endif +#endif + +#ifdef ENABLE_DSPX2_X86 +#include "qrenamedspx2.h" +#define CONFIG 2 +#include "helpersse2.h" +#define VARGQUAD Sleef_quadx2 +#endif + +#ifdef ENABLE_AVX2 +#include "qrenameavx2.h" +#if !defined(USE_INLINE_HEADER) +#define CONFIG 1 +#include "helperavx2.h" +#define VARGQUAD Sleef_quadx4 +#endif +#endif + +#ifdef ENABLE_AVX512F +#include "qrenameavx512f.h" +#if !defined(USE_INLINE_HEADER) +#define CONFIG 1 +#include "helperavx512f.h" +#define VARGQUAD Sleef_quadx8 +#endif +#endif + +#ifdef ENABLE_ADVSIMD +#include "qrenameadvsimd.h" +#if !defined(USE_INLINE_HEADER) +#define CONFIG 1 +#include "helperadvsimd.h" +#define VARGQUAD Sleef_quadx2 +#endif +#endif + +#ifdef ENABLE_DSPX2_AARCH64 +#include "qrenamedspx2.h" +#define CONFIG 2 +#include "helperadvsimd.h" +#define VARGQUAD Sleef_quadx2 +#endif + +#ifdef ENABLE_SVE +#include "qrenamesve.h" +#if !defined(USE_INLINE_HEADER) +#define CONFIG 1 +#include "helpersve.h" +#define VARGQUAD Sleef_svquad +#endif +#define SIZEOF_VARGQUAD (svcntd()*8) +#endif + +#ifdef ENABLE_VSX +#include "qrenamevsx.h" +#if !defined(USE_INLINE_HEADER) +#define CONFIG 1 +#include "helperpower_128.h" +#define VARGQUAD Sleef_quadx2 +#endif +#endif + +#ifdef ENABLE_VSX3 +#include "qrenamevsx3.h" +#if !defined(USE_INLINE_HEADER) +#define CONFIG 3 +#include "helperpower_128.h" +#define VARGQUAD Sleef_quadx2 +#endif +#endif + +#ifdef ENABLE_DSPX2_PPC64 +#include "qrenamedspx2.h" +#define CONFIG 1 +#include "helperpower_128.h" +#define VARGQUAD Sleef_quadx2 +#endif + +#ifdef ENABLE_VXE +#include "qrenamevxe.h" +#if !defined(USE_INLINE_HEADER) +#define CONFIG 140 +#include "helpers390x_128.h" +#define VARGQUAD Sleef_quadx2 +#endif +#endif + +#ifdef ENABLE_VXE2 +#include "qrenamevxe2.h" +#if !defined(USE_INLINE_HEADER) +#define CONFIG 150 +#include "helpers390x_128.h" +#define VARGQUAD Sleef_quadx2 +#endif +#endif + +#ifdef ENABLE_DSPX2_S390X +#include "qrenamedspx2.h" +#define CONFIG 140 +#include "helpers390x_128.h" +#define VARGQUAD Sleef_quadx2 +#endif + +#ifdef ENABLE_RVVM1 +#include "qrenamervvm1.h" +#if !defined(USE_INLINE_HEADER) +#define CONFIG 1 +#define ENABLE_RVV_DP +#include "helperrvv.h" +#define VARGQUAD Sleef_rvvm1quad +#endif +#define SIZEOF_VARGQUAD (__riscv_vsetvlmax_e64m1()*8) +#endif + +#ifdef ENABLE_RVVM2 +#include "qrenamervvm2.h" +#if !defined(USE_INLINE_HEADER) +#define CONFIG 1 +#define ENABLE_RVV_DP +#include "helperrvv.h" +#define VARGQUAD Sleef_rvvm2quad +#endif +#define SIZEOF_VARGQUAD (__riscv_vsetvlmax_e64m2()*8) +#endif + + +#ifndef VARGQUAD +#define VARGQUAD vargquad +#endif + +#ifndef SIZEOF_VARGQUAD +#define SIZEOF_VARGQUAD sizeof(VARGQUAD) +#endif + +#ifdef USE_INLINE_HEADER +#define CONCAT_SIMD_SUFFIX_(keyword, suffix) keyword ## suffix +#define CONCAT_SIMD_SUFFIX(keyword, suffix) CONCAT_SIMD_SUFFIX_(keyword, suffix) +#define vmask CONCAT_SIMD_SUFFIX(vmask, SIMD_SUFFIX) +#define vopmask CONCAT_SIMD_SUFFIX(vopmask, SIMD_SUFFIX) +#define vdouble CONCAT_SIMD_SUFFIX(vdouble, SIMD_SUFFIX) +#define vargquad CONCAT_SIMD_SUFFIX(vargquad, SIMD_SUFFIX) +#define vint CONCAT_SIMD_SUFFIX(vint, SIMD_SUFFIX) +#define vint2 CONCAT_SIMD_SUFFIX(vint2, SIMD_SUFFIX) +#define vdouble2 CONCAT_SIMD_SUFFIX(vdouble2, SIMD_SUFFIX) +#define vd2getx_vd_vd2 CONCAT_SIMD_SUFFIX(vd2getx_vd_vd2, SIMD_SUFFIX) +#define vd2gety_vd_vd2 CONCAT_SIMD_SUFFIX(vd2gety_vd_vd2, SIMD_SUFFIX) +#define vloadu_vd_p CONCAT_SIMD_SUFFIX(vloadu_vd_p, SIMD_SUFFIX) +#define vstoreu_v_p_vd CONCAT_SIMD_SUFFIX(vstoreu_v_p_vd, SIMD_SUFFIX) +#define vloadu_vi_p CONCAT_SIMD_SUFFIX(vloadu_vi_p, SIMD_SUFFIX) +#define vstoreu_v_p_vi CONCAT_SIMD_SUFFIX(vstoreu_v_p_vi, SIMD_SUFFIX) +#define vreinterpret_vm_vu64 CONCAT_SIMD_SUFFIX(vreinterpret_vm_vu64, SIMD_SUFFIX) +#define vreinterpret_vu64_vm CONCAT_SIMD_SUFFIX(vreinterpret_vu64_vm, SIMD_SUFFIX) +#define vreinterpret_vm_vi64 CONCAT_SIMD_SUFFIX(vreinterpret_vm_vi64, SIMD_SUFFIX) +#define vreinterpret_vi64_vm CONCAT_SIMD_SUFFIX(vreinterpret_vi64_vm, SIMD_SUFFIX) +#define vreinterpret_vm_vd CONCAT_SIMD_SUFFIX(vreinterpret_vm_vd, SIMD_SUFFIX) +#define vreinterpret_vd_vm CONCAT_SIMD_SUFFIX(vreinterpret_vd_vm, SIMD_SUFFIX) +#endif + +// + +int check_feature(double d, float f) { + double s[VECTLENDP]; + for(int i=0;i +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include + +#include "misc.h" +#include "qtesterutil.h" + +void stop(char *mes) { + fprintf(stderr, "%s\n", mes); + exit(-1); +} + +int ptoc[2], ctop[2]; +int pid; +FILE *fpctop; + +extern char **environ; + +void startChild(const char *path, char *const argv[]) { + pipe(ptoc); + pipe(ctop); + + pid = fork(); + + assert(pid != -1); + + if (pid == 0) { + // child process + char buf0[1], buf1[1]; + + close(ptoc[1]); + close(ctop[0]); + + fflush(stdin); + fflush(stdout); + + if (dup2(ptoc[0], fileno(stdin)) == -1) exit(-1); + if (dup2(ctop[1], fileno(stdout)) == -1) exit(-1); + + setvbuf(stdin, buf0, _IONBF,0); + setvbuf(stdout, buf1, _IONBF,0); + + fflush(stdin); + fflush(stdout); + +#if !defined(__APPLE__) && !defined(__FreeBSD__) + execvpe(path, argv, environ); +#else + execvp(path, argv); +#endif + + fprintf(stderr, "execvp in startChild : %s\n", strerror(errno)); + + exit(-1); + } + + // parent process + + close(ptoc[0]); + close(ctop[1]); +} + +// + +#if defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) +typedef union { + Sleef_quad q; + struct { + uint64_t h, l; + }; +} cnv128; +#else +typedef union { + Sleef_quad q; + struct { + uint64_t l, h; + }; +} cnv128; +#endif + +#define child_q_q(funcStr, arg) do { \ + char str[256]; \ + cnv128 c; \ + c.q = arg; \ + sprintf(str, funcStr " %" PRIx64 ":%" PRIx64 "\n", c.h, c.l); \ + write(ptoc[1], str, strlen(str)); \ + if (fgets(str, 255, fpctop) == NULL) stop("child " funcStr); \ + sscanf(str, "%" PRIx64 ":%" PRIx64, &c.h, &c.l); \ + return c.q; \ + } while(0) + +#define child_q2_q(funcStr, arg) do { \ + char str[256]; \ + cnv128 c0, c1; \ + c0.q = arg; \ + sprintf(str, funcStr " %" PRIx64 ":%" PRIx64 "\n", c0.h, c0.l); \ + write(ptoc[1], str, strlen(str)); \ + if (fgets(str, 255, fpctop) == NULL) stop("child " funcStr); \ + sscanf(str, "%" PRIx64 ":%" PRIx64 " %" PRIx64 ":%" PRIx64 , &c0.h, &c0.l, &c1.h, &c1.l); \ + Sleef_quad2 ret = { c0.q, c1.q }; \ + return ret; \ + } while(0) + +#define child_q_q_q(funcStr, arg0, arg1) do { \ + char str[256]; \ + cnv128 c0, c1; \ + c0.q = arg0; \ + c1.q = arg1; \ + sprintf(str, funcStr " %" PRIx64 ":%" PRIx64 " %" PRIx64 ":%" PRIx64 "\n", c0.h, c0.l, c1.h, c1.l); \ + write(ptoc[1], str, strlen(str)); \ + if (fgets(str, 255, fpctop) == NULL) stop("child " funcStr); \ + sscanf(str, "%" PRIx64 ":%" PRIx64, &c0.h, &c0.l); \ + return c0.q; \ + } while(0) + +#define child_q_q_q_q(funcStr, arg0, arg1, arg2) do { \ + char str[256]; \ + cnv128 c0, c1, c2; \ + c0.q = arg0; \ + c1.q = arg1; \ + c2.q = arg2; \ + sprintf(str, funcStr " %" PRIx64 ":%" PRIx64 " %" PRIx64 ":%" PRIx64 " %" PRIx64 ":%" PRIx64 "\n", c0.h, c0.l, c1.h, c1.l, c2.h, c2.l); \ + write(ptoc[1], str, strlen(str)); \ + if (fgets(str, 255, fpctop) == NULL) stop("child " funcStr); \ + sscanf(str, "%" PRIx64 ":%" PRIx64, &c0.h, &c0.l); \ + return c0.q; \ + } while(0) + +#define child_i_q(funcStr, arg0) do { \ + char str[256]; \ + cnv128 c0; \ + c0.q = arg0; \ + sprintf(str, funcStr " %" PRIx64 ":%" PRIx64 "\n", c0.h, c0.l); \ + write(ptoc[1], str, strlen(str)); \ + if (fgets(str, 255, fpctop) == NULL) stop("child " funcStr); \ + int i; \ + sscanf(str, "%d", &i); \ + return i; \ + } while(0) + +#define child_i_q_q(funcStr, arg0, arg1) do { \ + char str[256]; \ + cnv128 c0, c1; \ + c0.q = arg0; \ + c1.q = arg1; \ + sprintf(str, funcStr " %" PRIx64 ":%" PRIx64 " %" PRIx64 ":%" PRIx64 "\n", c0.h, c0.l, c1.h, c1.l); \ + write(ptoc[1], str, strlen(str)); \ + if (fgets(str, 255, fpctop) == NULL) stop("child " funcStr); \ + int i; \ + sscanf(str, "%d", &i); \ + return i; \ + } while(0) + +#define child_q_q_i(funcStr, arg0, arg1) do { \ + char str[256]; \ + cnv128 c; \ + c.q = arg0; \ + sprintf(str, funcStr " %" PRIx64 ":%" PRIx64 " %d\n", c.h, c.l, arg1); \ + write(ptoc[1], str, strlen(str)); \ + if (fgets(str, 255, fpctop) == NULL) stop("child " funcStr); \ + sscanf(str, "%" PRIx64 ":%" PRIx64, &c.h, &c.l); \ + return c.q; \ + } while(0) + +#define child_d_q(funcStr, arg) do { \ + char str[256]; \ + cnv128 c; \ + c.q = arg; \ + sprintf(str, funcStr " %" PRIx64 ":%" PRIx64 "\n", c.h, c.l); \ + write(ptoc[1], str, strlen(str)); \ + if (fgets(str, 255, fpctop) == NULL) stop("child " funcStr); \ + uint64_t u; \ + sscanf(str, "%" PRIx64, &u); \ + return u2d(u); \ + } while(0) + +#define child_q_d(funcStr, arg) do { \ + char str[256]; \ + sprintf(str, funcStr " %" PRIx64 "\n", d2u(arg)); \ + write(ptoc[1], str, strlen(str)); \ + if (fgets(str, 255, fpctop) == NULL) stop("child " funcStr); \ + cnv128 c; \ + sscanf(str, "%" PRIx64 ":%" PRIx64, &c.h, &c.l); \ + return c.q; \ + } while(0) + +#define child_m_q(funcStr, arg) do { \ + char str[256]; \ + cnv128 c; \ + c.q = arg; \ + sprintf(str, funcStr " %" PRIx64 ":%" PRIx64 "\n", c.h, c.l); \ + write(ptoc[1], str, strlen(str)); \ + if (fgets(str, 255, fpctop) == NULL) stop("child " funcStr); \ + uint64_t u; \ + sscanf(str, "%" PRIx64, &u); \ + return u; \ + } while(0) + +#define child_q_m(funcStr, arg) do { \ + char str[256]; \ + sprintf(str, funcStr " %" PRIx64 "\n", arg); \ + write(ptoc[1], str, strlen(str)); \ + if (fgets(str, 255, fpctop) == NULL) stop("child " funcStr); \ + cnv128 c; \ + sscanf(str, "%" PRIx64 ":%" PRIx64, &c.h, &c.l); \ + return c.q; \ + } while(0) + +#define child_q_q_pi(funcStr, arg) do { \ + char str[256]; \ + cnv128 c; \ + c.q = arg; \ + sprintf(str, funcStr " %" PRIx64 ":%" PRIx64 "\n", c.h, c.l); \ + write(ptoc[1], str, strlen(str)); \ + if (fgets(str, 255, fpctop) == NULL) stop("child " funcStr); \ + int i; \ + sscanf(str, "%" PRIx64 ":%" PRIx64 " %d", &c.h, &c.l, &i); \ + *ptr = i; \ + return c.q; \ + } while(0) + +#define child_q_q_pq(funcStr, arg) do { \ + char str[256]; \ + cnv128 c0, c1; \ + c0.q = arg; \ + sprintf(str, funcStr " %" PRIx64 ":%" PRIx64 "\n", c0.h, c0.l); \ + write(ptoc[1], str, strlen(str)); \ + if (fgets(str, 255, fpctop) == NULL) stop("child " funcStr); \ + sscanf(str, "%" PRIx64 ":%" PRIx64 " %" PRIx64 ":%" PRIx64, &c0.h, &c0.l, &c1.h, &c1.l); \ + *ptr = c1.q; \ + return c0.q; \ + } while(0) + +#define child_q_str(funcStr, arg) do { \ + char str[256]; \ + sprintf(str, funcStr " %s\n", arg); \ + write(ptoc[1], str, strlen(str)); \ + if (fgets(str, 255, fpctop) == NULL) stop("child " funcStr); \ + cnv128 c; \ + sscanf(str, "%" PRIx64 ":%" PRIx64, &c.h, &c.l); \ + return c.q; \ + } while(0) + +#define child_str_q(funcStr, ret, arg) do { \ + char str[256]; \ + cnv128 c; \ + c.q = arg; \ + sprintf(str, funcStr " %" PRIx64 ":%" PRIx64 "\n", c.h, c.l); \ + write(ptoc[1], str, strlen(str)); \ + if (fgets(str, 255, fpctop) == NULL) stop("child " funcStr); \ + sscanf(str, "%63s", ret); \ + } while(0) + +Sleef_quad child_addq_u05(Sleef_quad x, Sleef_quad y) { child_q_q_q("addq_u05", x, y); } +Sleef_quad child_subq_u05(Sleef_quad x, Sleef_quad y) { child_q_q_q("subq_u05", x, y); } +Sleef_quad child_mulq_u05(Sleef_quad x, Sleef_quad y) { child_q_q_q("mulq_u05", x, y); } +Sleef_quad child_divq_u05(Sleef_quad x, Sleef_quad y) { child_q_q_q("divq_u05", x, y); } +Sleef_quad child_negq(Sleef_quad x) { child_q_q("negq", x); } + +int child_icmpltq(Sleef_quad x, Sleef_quad y) { child_i_q_q("icmpltq", x, y); } +int child_icmpgtq(Sleef_quad x, Sleef_quad y) { child_i_q_q("icmpgtq", x, y); } +int child_icmpleq(Sleef_quad x, Sleef_quad y) { child_i_q_q("icmpleq", x, y); } +int child_icmpgeq(Sleef_quad x, Sleef_quad y) { child_i_q_q("icmpgeq", x, y); } +int child_icmpeqq(Sleef_quad x, Sleef_quad y) { child_i_q_q("icmpeqq", x, y); } +int child_icmpneq(Sleef_quad x, Sleef_quad y) { child_i_q_q("icmpneq", x, y); } +int child_icmpq (Sleef_quad x, Sleef_quad y) { child_i_q_q("icmpq" , x, y); } +int child_iunordq(Sleef_quad x, Sleef_quad y) { child_i_q_q("iunordq", x, y); } + +Sleef_quad child_cast_from_doubleq(double x) { child_q_d("cast_from_doubleq", x); } +double child_cast_to_doubleq(Sleef_quad x) { child_d_q("cast_to_doubleq", x); } +Sleef_quad child_cast_from_int64q(int64_t x) { child_q_m("cast_from_int64q", x); } +int64_t child_cast_to_int64q(Sleef_quad x) { child_m_q("cast_to_int64q", x); } +Sleef_quad child_cast_from_uint64q(uint64_t x) { child_q_m("cast_from_uint64q", x); } +uint64_t child_cast_to_uint64q(Sleef_quad x) { child_m_q("cast_to_uint64q", x); } + +Sleef_quad child_strtoq(const char *s) { child_q_str("strtoq", s); } +void child_snprintf_40Qg(char *ret, Sleef_quad x) { child_str_q("snprintf_40Qg", ret, x); } +void child_snprintf_Qa(char *ret, Sleef_quad x) { child_str_q("snprintf_Qa", ret, x); } + +Sleef_quad child_sqrtq_u05(Sleef_quad x) { child_q_q("sqrtq_u05", x); } +Sleef_quad child_cbrtq_u10(Sleef_quad x) { child_q_q("cbrtq_u10", x); } +Sleef_quad child_sinq_u10(Sleef_quad x) { child_q_q("sinq_u10", x); } +Sleef_quad child_cosq_u10(Sleef_quad x) { child_q_q("cosq_u10", x); } +Sleef_quad child_tanq_u10(Sleef_quad x) { child_q_q("tanq_u10", x); } +Sleef_quad child_asinq_u10(Sleef_quad x) { child_q_q("asinq_u10", x); } +Sleef_quad child_acosq_u10(Sleef_quad x) { child_q_q("acosq_u10", x); } +Sleef_quad child_atanq_u10(Sleef_quad x) { child_q_q("atanq_u10", x); } +Sleef_quad child_atan2q_u10(Sleef_quad x, Sleef_quad y) { child_q_q_q("atan2q_u10", x, y); } +Sleef_quad child_expq_u10(Sleef_quad x) { child_q_q("expq_u10", x); } +Sleef_quad child_exp2q_u10(Sleef_quad x) { child_q_q("exp2q_u10", x); } +Sleef_quad child_exp10q_u10(Sleef_quad x) { child_q_q("exp10q_u10", x); } +Sleef_quad child_expm1q_u10(Sleef_quad x) { child_q_q("expm1q_u10", x); } +Sleef_quad child_logq_u10(Sleef_quad x) { child_q_q("logq_u10", x); } +Sleef_quad child_log2q_u10(Sleef_quad x) { child_q_q("log2q_u10", x); } +Sleef_quad child_log10q_u10(Sleef_quad x) { child_q_q("log10q_u10", x); } +Sleef_quad child_log1pq_u10(Sleef_quad x) { child_q_q("log1pq_u10", x); } +Sleef_quad child_powq_u10(Sleef_quad x, Sleef_quad y) { child_q_q_q("powq_u10", x, y); } +Sleef_quad child_sinhq_u10(Sleef_quad x) { child_q_q("sinhq_u10", x); } +Sleef_quad child_coshq_u10(Sleef_quad x) { child_q_q("coshq_u10", x); } +Sleef_quad child_tanhq_u10(Sleef_quad x) { child_q_q("tanhq_u10", x); } +Sleef_quad child_asinhq_u10(Sleef_quad x) { child_q_q("asinhq_u10", x); } +Sleef_quad child_acoshq_u10(Sleef_quad x) { child_q_q("acoshq_u10", x); } +Sleef_quad child_atanhq_u10(Sleef_quad x) { child_q_q("atanhq_u10", x); } + +Sleef_quad child_fabsq(Sleef_quad x) { child_q_q("fabsq", x); } +Sleef_quad child_copysignq(Sleef_quad x, Sleef_quad y) { child_q_q_q("copysignq", x, y); } +Sleef_quad child_fmaxq(Sleef_quad x, Sleef_quad y) { child_q_q_q("fmaxq", x, y); } +Sleef_quad child_fminq(Sleef_quad x, Sleef_quad y) { child_q_q_q("fminq", x, y); } +Sleef_quad child_fdimq_u05(Sleef_quad x, Sleef_quad y) { child_q_q_q("fdimq_u05", x, y); } +Sleef_quad child_fmodq(Sleef_quad x, Sleef_quad y) { child_q_q_q("fmodq", x, y); } +Sleef_quad child_remainderq(Sleef_quad x, Sleef_quad y) { child_q_q_q("remainderq", x, y); } +Sleef_quad child_frexpq(Sleef_quad x, int *ptr) { child_q_q_pi("frexpq", x); } +Sleef_quad child_modfq(Sleef_quad x, Sleef_quad *ptr) { child_q_q_pq("modfq", x); } + +Sleef_quad child_hypotq_u05(Sleef_quad x, Sleef_quad y) { child_q_q_q("hypotq_u05", x, y); } +Sleef_quad child_fmaq_u05(Sleef_quad x, Sleef_quad y, Sleef_quad z) { child_q_q_q_q("fmaq_u05", x, y, z); } +Sleef_quad child_ldexpq(Sleef_quad x, int k) { child_q_q_i("ldexpq", x, k); } +int child_ilogbq(Sleef_quad x) { child_i_q("ilogbq", x); } + +Sleef_quad child_truncq(Sleef_quad x) { child_q_q("truncq", x); } +Sleef_quad child_floorq(Sleef_quad x) { child_q_q("floorq", x); } +Sleef_quad child_ceilq(Sleef_quad x) { child_q_q("ceilq", x); } +Sleef_quad child_roundq(Sleef_quad x) { child_q_q("roundq", x); } +Sleef_quad child_rintq(Sleef_quad x) { child_q_q("rintq", x); } + +// + +#define cmpDenorm_q(mpfrFunc, childFunc, argx) do { \ + mpfr_set_f128(frx, argx, GMP_RNDN); \ + mpfrFunc(frz, frx, GMP_RNDN); \ + Sleef_quad t = childFunc(argx); \ + double u = countULPf128(t, frz, 1); \ + if (u >= 10) { \ + fprintf(stderr, "\narg = %s\ntest = %s\ncorrect = %s\nulp = %g\n", \ + sprintf128(argx), sprintf128(t), sprintfr(frz), u); \ + success = 0; \ + break; \ + } \ + } while(0) + +#define cmpDenormNMR_q(mpfrFunc, childFunc, argx) do { \ + mpfr_set_f128(frx, argx, GMP_RNDN); \ + mpfrFunc(frz, frx); \ + Sleef_quad t = childFunc(argx); \ + double u = countULPf128(t, frz, 1); \ + if (u >= 10) { \ + fprintf(stderr, "\narg = %s\ntest = %s\ncorrect = %s\nulp = %g\n", \ + sprintf128(argx), sprintf128(t), sprintfr(frz), u); \ + success = 0; \ + break; \ + } \ + } while(0) + +#define cmpDenorm_q_q(mpfrFunc, childFunc, argx, argy) do { \ + mpfr_set_f128(frx, argx, GMP_RNDN); \ + mpfr_set_f128(fry, argy, GMP_RNDN); \ + mpfrFunc(frz, frx, fry, GMP_RNDN); \ + Sleef_quad t = childFunc(argx, argy); \ + double u = countULPf128(t, frz, 1); \ + if (u >= 10) { \ + Sleef_quad qz = mpfr_get_f128(frz, GMP_RNDN); \ + fprintf(stderr, "\narg = %s,\n %s\ntest = %s\ncorrect = %s\nulp = %g\n", \ + sprintf128(argx), sprintf128(argy), sprintf128(t), sprintf128(qz), u); \ + success = 0; \ + break; \ + } \ + } while(0) + +#define cmpDenorm_q_q_q(mpfrFunc, childFunc, argw, argx, argy) do { \ + mpfr_set_f128(frw, argw, GMP_RNDN); \ + mpfr_set_f128(frx, argx, GMP_RNDN); \ + mpfr_set_f128(fry, argy, GMP_RNDN); \ + mpfrFunc(frz, frw, frx, fry, GMP_RNDN); \ + Sleef_quad t = childFunc(argw, argx, argy); \ + double u = countULPf128(t, frz, 1); \ + if (u >= 10) { \ + Sleef_quad qz = mpfr_get_f128(frz, GMP_RNDN); \ + fprintf(stderr, "\narg = %s,\n %s,\n %s\ntest = %s\ncorrect = %s\nulp = %g\n", \ + sprintf128(argw), sprintf128(argx), sprintf128(argy), sprintf128(t), sprintf128(qz), u); \ + success = 0; \ + break; \ + } \ + } while(0) + +#define cmpDenorm_q_pi(mpfrFunc, childFunc, argx) do { \ + mpfr_set_f128(frx, argx, GMP_RNDN); \ + mpfr_exp_t e; \ + mpfrFunc(&e, frz, frx, GMP_RNDN); \ + int i; \ + Sleef_quad t = childFunc(argx, &i); \ + double u = countULPf128(t, frz, 1); \ + if (u >= 10 || i != (int)e) { \ + fprintf(stderr, "\narg = %s\ntest = %s, %d\ncorrect = %s, %d\nulp = %g\n", \ + sprintf128(argx), sprintf128(t), i, sprintfr(frz), (int)e, u); \ + success = 0; \ + break; \ + } \ + } while(0) + +#define cmpDenorm_q_pq(mpfrFunc, childFunc, argx) do { \ + mpfr_set_f128(frx, argx, GMP_RNDN); \ + mpfrFunc(fry, frz, frx, GMP_RNDN); \ + Sleef_quad qi, qf; \ + qf = childFunc(argx, &qi); \ + double u = countULPf128(qf, frz, 1); \ + double v = countULPf128(qi, fry, 1); \ + if (u >= 10 || v >= 10) { \ + fprintf(stderr, "\narg = %s\ntest = %s, %s\ncorrect = %s, %s\nulp = %g, %g\n", \ + sprintf128(argx), sprintf128(qf), sprintf128(qi), sprintfr(frz), sprintfr(fry), u, v); \ + success = 0; \ + break; \ + } \ + } while(0) + +#define checkAccuracy_q(mpfrFunc, childFunc, argx, bound) do { \ + mpfr_set_f128(frx, argx, GMP_RNDN); \ + mpfrFunc(frz, frx, GMP_RNDN); \ + Sleef_quad t = childFunc(argx); \ + double e = countULPf128(t, frz, 0); \ + maxError = fmax(maxError, e); \ + if (e > bound) { \ + fprintf(stderr, "\narg = %s, test = %s, correct = %s, ULP = %lf\n", \ + sprintf128(argx), sprintf128(childFunc(argx)), sprintfr(frz), countULPf128(t, frz, 0)); \ + success = 0; \ + break; \ + } \ + } while(0) + +#define checkAccuracyNMR_q(mpfrFunc, childFunc, argx, bound) do { \ + mpfr_set_f128(frx, argx, GMP_RNDN); \ + mpfrFunc(frz, frx); \ + Sleef_quad t = childFunc(argx); \ + double e = countULPf128(t, frz, 0); \ + maxError = fmax(maxError, e); \ + if (e > bound) { \ + fprintf(stderr, "\narg = %s, test = %s, correct = %s, ULP = %lf\n", \ + sprintf128(argx), sprintf128(childFunc(argx)), sprintfr(frz), countULPf128(t, frz, 0)); \ + success = 0; \ + break; \ + } \ + } while(0) + +#define checkAccuracy_q_q(mpfrFunc, childFunc, argx, argy, bound) do { \ + mpfr_set_f128(frx, argx, GMP_RNDN); \ + mpfr_set_f128(fry, argy, GMP_RNDN); \ + mpfrFunc(frz, frx, fry, GMP_RNDN); \ + Sleef_quad t = childFunc(argx, argy); \ + double e = countULPf128(t, frz, 0); \ + maxError = fmax(maxError, e); \ + if (e > bound) { \ + fprintf(stderr, "\narg = %s, %s, test = %s, correct = %s, ULP = %lf\n", \ + sprintf128(argx), sprintf128(argy), sprintf128(childFunc(argx, argy)), sprintfr(frz), countULPf128(t, frz, 0)); \ + success = 0; \ + break; \ + } \ + } while(0) + +#define checkAccuracy_q_q_q(mpfrFunc, childFunc, argw, argx, argy, bound) do { \ + mpfr_set_f128(frw, argw, GMP_RNDN); \ + mpfr_set_f128(frx, argx, GMP_RNDN); \ + mpfr_set_f128(fry, argy, GMP_RNDN); \ + mpfrFunc(frz, frw, frx, fry, GMP_RNDN); \ + Sleef_quad t = childFunc(argw, argx, argy); \ + double e = countULPf128(t, frz, 0); \ + maxError = fmax(maxError, e); \ + if (e > bound) { \ + fprintf(stderr, "\narg = %s, %s, %s, test = %s, correct = %s, ULP = %lf\n", \ + sprintf128(argw), sprintf128(argx), sprintf128(argy), sprintf128(childFunc(argw, argx, argy)), sprintfr(frz), countULPf128(t, frz, 0)); \ + success = 0; \ + break; \ + } \ + } while(0) + +#define checkAccuracy_q_pi(mpfrFunc, childFunc, argx, bound) do { \ + mpfr_set_f128(frx, argx, GMP_RNDN); \ + mpfr_exp_t ex; \ + mpfrFunc(&ex, frz, frx, GMP_RNDN); \ + int i; \ + Sleef_quad t = childFunc(argx, &i); \ + double e = countULPf128(t, frz, 0); \ + maxError = fmax(maxError, e); \ + if (e > bound || i != (int)ex) { \ + fprintf(stderr, "\narg = %s, test = %s, %d, correct = %s, %d, ULP = %lf\n", \ + sprintf128(argx), sprintf128(t), i, sprintfr(frz), (int)ex, countULPf128(t, frz, 0)); \ + success = 0; \ + break; \ + } \ + } while(0) + +#define checkAccuracy_q_pq(mpfrFunc, childFunc, argx, bound) do { \ + mpfr_set_f128(frx, argx, GMP_RNDN); \ + mpfrFunc(fry, frz, frx, GMP_RNDN); \ + Sleef_quad qi, qf; \ + qf = childFunc(argx, &qi); \ + double ef = countULPf128(qf, frz, 0); \ + double ei = countULPf128(qi, fry, 0); \ + maxError = fmax(maxError, ef); \ + maxError = fmax(maxError, ei); \ + if (ef > bound || ei > bound) { \ + fprintf(stderr, "\narg = %s, test = %s, %s, correct = %s, %s, ULP = %lf, %lf\n", \ + sprintf128(argx), sprintf128(qf), sprintf128(qi), sprintfr(frz), sprintfr(fry), ef, ei); \ + success = 0; \ + break; \ + } \ + } while(0) + +#define testComparison(mpfrFunc, childFunc, argx, argy) do { \ + mpfr_set_f128(frx, argx, GMP_RNDN); \ + mpfr_set_f128(fry, argy, GMP_RNDN); \ + int c = mpfrFunc(frx, fry); \ + int t = childFunc(argx, argy); \ + if ((c != 0) != (t != 0)) { \ + fprintf(stderr, "\narg = %s, %s, test = %d, correct = %d\n", \ + sprintf128(argx), sprintf128(argy), t, c); \ + success = 0; \ + break; \ + } \ + } while(0) + +// + +#define cmpDenormOuterLoop_q(mpfrFunc, childFunc, checkVals) do { \ + for(int i=0;i 0.5) { + fprintf(stderr, "\narg = %s, %d\ntest = %s\ncorrect = %s\nulp = %g\n", + sprintf128(a0), ldexpCheckVals[i], sprintf128(t), sprintfr(frz), u); + success = 0; + break; + } + } + } + + checkResult(success, -1); + } + + { + fprintf(stderr, "ilogb : "); + + static const int correctIlogbVals[] = { + -2147483648, -2147483648, -2, -2, -1, -1, -1, -1, + 0, 0, 0, 0, 0, 0, 1, 1, + 1, 1, 1, 1, 2, 2, 2, 2, + 2, 2, 2, 2, 0, 0, 332, 332, + -332, -332, 9966, 9966, -9966, -9966, 1, -16382, + -16382, -16494, -16494, 2147483647, 2147483647, 2147483647, + }; + + for(int i=0;i +#include +#include +#include +#include +#include +#include +#include + +#include + +#ifdef USEMPFR +#include +#endif + +#if defined(__MINGW32__) || defined(__MINGW64__) || defined(_MSC_VER) +#define STDIN_FILENO 0 +#else +#include +#include +#endif + +#if defined(__MINGW32__) || defined(__MINGW64__) +#include +#endif + +#if defined(_MSC_VER) +#include +#endif + +#include "misc.h" +#include "qtesterutil.h" + +// + +int readln(int fd, char *buf, int cnt) { + int i, rcnt = 0; + + if (cnt < 1) return -1; + + while(cnt >= 2) { + i = read(fd, buf, 1); + if (i != 1) return i; + + if (*buf == '\n') break; + + rcnt++; + buf++; + cnt--; + } + + *++buf = '\0'; + rcnt++; + return rcnt; +} + +int startsWith(char *str, char *prefix) { + return strncmp(str, prefix, strlen(prefix)) == 0; +} + +// + +xuint128 xu(uint64_t h, uint64_t l) { + xuint128 r = { .l = l, .h = h }; + return r; +} + +xuint128 sll128(uint64_t u, int c) { + if (c < 64) { + xuint128 r = { .l = u << c, .h = u >> (64 - c) }; + return r; + } + + xuint128 r = { .l = 0, .h = u << (c - 64) }; + return r; +} + +xuint128 add128(xuint128 x, xuint128 y) { + xuint128 r = { .l = x.l + y.l, .h = x.h + y.h }; + if (r.l < x.l) r.h++; + return r; +} + +static xuint128 cmpcnv(xuint128 cx) { + if ((cx.h & 0x8000000000000000ULL) != 0) { + cx.h ^= 0x7fffffffffffffffULL; + cx.l = ~cx.l; + cx.l++; + if (cx.l == 0) cx.h++; + } + + cx.h ^= 0x8000000000000000ULL; + + return cx; +} + +int lt128(xuint128 x, xuint128 y) { + xuint128 cx = cmpcnv(x), cy = cmpcnv(y); + if (cx.h < cy.h) return 1; + if (cx.h == cy.h && cx.l < cy.l) return 1; + return 0; +} + +// + +typedef union { + Sleef_quad q; + xuint128 x; + struct { +#if defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) + uint64_t h, l; +#else + uint64_t l, h; +#endif + }; +} cnv_t; + +int iszerof128(Sleef_quad a) { + cnv_t c128 = { .q = a }; + return (((c128.h & UINT64_C(0x7fffffffffffffff)) == 0) && c128.l == 0); +} + +int isnegf128(Sleef_quad a) { + cnv_t c128 = { .q = a }; + return c128.h >> 63; +} + +int isinff128(Sleef_quad a) { + cnv_t c128 = { .q = a }; + return (((c128.h & UINT64_C(0x7fffffffffffffff)) == UINT64_C(0x7fff000000000000)) && c128.l == 0); +} + +int isnonnumberf128(Sleef_quad a) { + cnv_t c128 = { .q = a }; + return (c128.h & UINT64_C(0x7fff000000000000)) == UINT64_C(0x7fff000000000000); +} + +int isnanf128(Sleef_quad a) { + return isnonnumberf128(a) && !isinff128(a); +} + +// + +static uint64_t xseed; + +uint64_t xrand() { + uint64_t u = xseed; + xseed = xseed * UINT64_C(6364136223846793005) + 1; + u = (u & ((~UINT64_C(0)) << 32)) | (xseed >> 32); + xseed = xseed * UINT64_C(6364136223846793005) + 1; + return u; +} + +void xsrand(uint64_t s) { + xseed = s; + xrand(); + xrand(); + xrand(); +} + +void memrand(void *p, int size) { + uint64_t *q = (uint64_t *)p; + int i; + for(i=0;i 0, disinf = isinff128(d); + + if (ciszero && !diszero) { + ret = 10000; + } else if (ciszero && diszero) { + ret = 0; + if (checkNegZero && csign != dsign) ret = 10003; + } else if (cisnan && disnan) { + ret = 0; + } else if (cisnan || disnan) { + ret = 10001; + } else if (cisinf && disinf) { + ret = csign == dsign ? 0 : 10002; + } else { + mpfr_set_f128(frd, d, GMP_RNDN); + int e = mpfr_get_exp(frd); + mpfr_set_d(frb, 1, GMP_RNDN); + assert(!mpfr_zero_p(frb)); + mpfr_set_exp(frb, e-113+1); + mpfr_max(frb, frb, fr_denorm_min, GMP_RNDN); + mpfr_sub(fra, frd, c, GMP_RNDN); + mpfr_div(fra, fra, frb, GMP_RNDN); + ret = fabs(mpfr_get_d(fra, GMP_RNDN)); + } + + mpfr_clears(fra, frb, frc, frd, NULL); + return ret; +} + +// + +char *sprintfr(mpfr_t fr) { + int digits = 51; + mpfr_t t; + mpfr_inits(t, NULL); + int sign = mpfr_signbit(fr) ? -1 : 1; + char *s = malloc(digits + 10); + if (mpfr_inf_p(fr)) { + sprintf(s, "%cinf", sign < 0 ? '-' : '+'); + } else if (mpfr_nan_p(fr)) { + sprintf(s, "nan"); + } else { + mpfr_exp_t e; + s[0] = sign < 0 ? '-' : '+'; + s[1] = '0'; + s[2] = '.'; + mpfr_abs(t, fr, GMP_RNDN); + mpfr_get_str(s+3, &e, 10, digits, t, GMP_RNDN); + int ie = e; + char es[32]; + snprintf(es, 30, "e%c%d", ie >= 0 ? '+' : '-', ie >= 0 ? ie : -ie); + strncat(s, es, digits+10); + } + + mpfr_clears(t, NULL); + return s; +} + +// + +#if MPFR_VERSION_MAJOR >= 4 && defined(SLEEF_FLOAT128_IS_IEEEQP) && !defined(__PPC64__) && !defined(__i386__) && !(defined(__APPLE__) && defined(__MACH__)) +void mpfr_set_f128(mpfr_t frx, Sleef_quad q, mpfr_rnd_t rnd) { + int mpfr_set_float128(mpfr_t rop, __float128 op, mpfr_rnd_t rnd); + union { + Sleef_quad q; + __float128 f; + } c; + c.q = q; + mpfr_set_float128(frx, c.f, rnd); +} + +Sleef_quad mpfr_get_f128(mpfr_t m, mpfr_rnd_t rnd) { + __float128 mpfr_get_float128(mpfr_t op, mpfr_rnd_t rnd); + union { + Sleef_quad q; + __float128 f; + } c; + c.f = mpfr_get_float128(m, rnd); + return c.q; +} +#elif defined(SLEEF_LONGDOUBLE_IS_IEEEQP) +void mpfr_set_f128(mpfr_t frx, Sleef_quad q, mpfr_rnd_t rnd) { + union { + Sleef_quad q; + long double f; + } c; + c.q = q; + mpfr_set_ld(frx, c.f, rnd); +} + +Sleef_quad mpfr_get_f128(mpfr_t m, mpfr_rnd_t rnd) { + union { + Sleef_quad q; + long double f; + } c; + c.f = mpfr_get_ld(m, rnd); + return c.q; +} +#else +#pragma message ( "Internal MPFR<->float128 conversion is used" ) +void mpfr_set_f128(mpfr_t frx, Sleef_quad a, mpfr_rnd_t rnd) { + union { + Sleef_quad u; + struct { +#if defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) + uint64_t h, l; +#else + uint64_t l, h; +#endif + }; + } c128 = { .u = a }; + + int sign = (int)(c128.h >> 63); + int exp = ((int)(c128.h >> 48)) & 0x7fff; + + if (isnanf128(a)) { + mpfr_set_nan(frx); + } else if (isinff128(a)) { + mpfr_set_inf(frx, sign ? -1 : 1); + } else if (exp == 0) { + c128.h &= UINT64_C(0xffffffffffff); + mpfr_set_d(frx, ldexp((double)c128.h, 64), GMP_RNDN); + mpfr_add_d(frx, frx, (double)(c128.l & UINT64_C(0xffffffff00000000)), GMP_RNDN); + mpfr_add_d(frx, frx, (double)(c128.l & UINT64_C(0xffffffff)), GMP_RNDN); + mpfr_set_exp(frx, mpfr_get_exp(frx) - 16382 - 112); + mpfr_setsign(frx, frx, sign, GMP_RNDN); + } else { + c128.h &= UINT64_C(0xffffffffffff); + mpfr_set_d(frx, ldexp(1, 112), GMP_RNDN); + mpfr_add_d(frx, frx, ldexp((double)c128.h, 64), GMP_RNDN); + mpfr_add_d(frx, frx, (double)(c128.l & UINT64_C(0xffffffff00000000)), GMP_RNDN); + mpfr_add_d(frx, frx, (double)(c128.l & UINT64_C(0xffffffff)), GMP_RNDN); + mpfr_set_exp(frx, exp - 16382); + mpfr_setsign(frx, frx, sign, GMP_RNDN); + } +} + +static double3 mpfr_get_d3(mpfr_t fr, mpfr_rnd_t rnd) { + double3 ret; + mpfr_t t; + mpfr_inits(t, NULL); + ret.x = mpfr_get_d(fr, GMP_RNDN); + mpfr_sub_d(t, fr, ret.x, GMP_RNDN); + ret.y = mpfr_get_d(t, GMP_RNDN); + mpfr_sub_d(t, t, ret.y, GMP_RNDN); + ret.z = mpfr_get_d(t, GMP_RNDN); + mpfr_clears(t, NULL); + return ret; +} + +static TDX_t mpfr_get_tdx(mpfr_t fr, mpfr_rnd_t rnd) { + TDX_t td; + + if (mpfr_nan_p(fr)) { + td.dd.x = NAN; + td.dd.y = 0; + td.dd.z = 0; + td.e = 0; + return td; + } + + if (mpfr_inf_p(fr)) { + td.dd.x = copysign(INFINITY, mpfr_cmp_d(fr, 0)); + td.dd.y = 0; + td.dd.z = 0; + td.e = 0; + return td; + } + + if (mpfr_zero_p(fr)) { + td.dd.x = copysign(0, mpfr_signbit(fr) ? -1 : 1); + td.dd.y = 0; + td.dd.z = 0; + td.e = 0; + return td; + } + + mpfr_t t; + mpfr_inits(t, NULL); + + mpfr_set(t, fr, GMP_RNDN); + td.e = mpfr_get_exp(fr) + 16382; + assert(!mpfr_zero_p(t)); + mpfr_set_exp(t, 1); + mpfr_setsign(t, t, mpfr_signbit(fr), GMP_RNDN); + td.dd = mpfr_get_d3(t, GMP_RNDN); + + if (fabs(td.dd.x) == 2.0) { + td.dd.x *= 0.5; + td.dd.y *= 0.5; + td.dd.z *= 0.5; + td.e++; + } + + mpfr_clears(t, NULL); + + return td; +} + +#define HBX 1.0 +#define LOGXSCALE 1 +#define XSCALE (1 << LOGXSCALE) +#define SX 61 +#define HBY (1.0 / (UINT64_C(1) << 53)) +#define LOGYSCALE 4 +#define YSCALE (1 << LOGYSCALE) +#define SY 11 +#define HBZ (1.0 / ((UINT64_C(1) << 53) * (double)(UINT64_C(1) << 53))) +#define LOGZSCALE 10 +#define ZSCALE (1 << LOGZSCALE) +#define SZ 36 +#define HBR (1.0 / (UINT64_C(1) << 60)) + +static int64_t doubleToRawLongBits(double d) { + union { + double f; + int64_t i; + } tmp; + tmp.f = d; + return tmp.i; +} + +static double longBitsToDouble(int64_t i) { + union { + double f; + int64_t i; + } tmp; + tmp.i = i; + return tmp.f; +} + +static int xisnonnumber(double x) { + return (doubleToRawLongBits(x) & UINT64_C(0x7ff0000000000000)) == UINT64_C(0x7ff0000000000000); +} + +static double xordu(double x, uint64_t y) { + union { + double d; + uint64_t u; + } cx; + cx.d = x; + cx.u ^= y; + return cx.d; +} + +static double pow2i(int q) { + return longBitsToDouble(((int64_t)(q + 0x3ff)) << 52); +} + +static double ldexp2k(double d, int e) { // faster than ldexpk, short reach + return d * pow2i(e >> 1) * pow2i(e - (e >> 1)); +} + +Sleef_quad mpfr_get_f128(mpfr_t a, mpfr_rnd_t rnd) { + TDX_t f = mpfr_get_tdx(a, rnd); + + cnv_t c128; + + union { + double d; + uint64_t u; + } c64; + + c64.d = f.dd.x; + uint64_t signbit = c64.u & UINT64_C(0x8000000000000000); + int isZero = (f.dd.x == 0.0), denorm = 0; + + f.dd.x = xordu(f.dd.x, signbit); + f.dd.y = xordu(f.dd.y, signbit); + f.dd.z = xordu(f.dd.z, signbit); + + double t = 1; + + if (f.e <= 0) { + t = ldexp2k(0.5, f.e); + if (f.e < -120) t = 0; + f.e = 1; + denorm = 1; + } + + if ((fabs(f.dd.x) == 1.0 && f.dd.y <= -pow(2, -114)) && f.e != 1) { + t = 2; + f.e--; + } + + f.dd.x *= t; + f.dd.y *= t; + f.dd.z *= t; + + c64.d = f.dd.y + HBY * YSCALE; + c64.u &= UINT64_C(0xffffffffffffffff) << LOGYSCALE; + f.dd.z += f.dd.y - (c64.d - (HBZ * ZSCALE + HBY * YSCALE)); + f.dd.y = c64.d; + + double c = denorm ? (HBX * XSCALE + HBX) : (HBX * XSCALE); + c64.d = f.dd.x + c; + c64.u &= UINT64_C(0xffffffffffffffff) << LOGXSCALE; + t = f.dd.y + (f.dd.x - (c64.d - c)); + f.dd.z += f.dd.y - t + (f.dd.x - (c64.d - c)); + f.dd.x = c64.d; + + c64.d = t; + c64.u &= UINT64_C(0xffffffffffffffff) << LOGYSCALE; + f.dd.z += t - c64.d; + f.dd.y = c64.d; + + t = f.dd.z - HBZ * ZSCALE < 0 ? HBZ * (ZSCALE/2) : 0; + f.dd.y -= t; + f.dd.z += t; + + t = f.dd.y - HBY * YSCALE < 0 ? HBY * (YSCALE/2) : 0; + f.dd.x -= t; + f.dd.y += t; + + f.dd.z = f.dd.z + HBR - HBR; + + // + + c64.d = f.dd.x; + c64.u &= UINT64_C(0xfffffffffffff); + c128.x = sll128(c64.u, SX); + + c64.d = f.dd.z; + c64.u &= UINT64_C(0xfffffffffffff); + c128.l |= c64.u >> SZ; + + c64.d = f.dd.y; + c64.u &= UINT64_C(0xfffffffffffff); + c128.x = add128(c128.x, sll128(c64.u, SY)); + + c128.h &= denorm ? UINT64_C(0xffffffffffff) : UINT64_C(0x3ffffffffffff); + c128.h += ((f.e-1) & ~((uint64_t)-1UL << 15)) << 48; + + if (isZero) { c128.l = c128.h = 0; } + if (f.e >= 32767 || f.dd.x == INFINITY) { + c128.h = UINT64_C(0x7fff000000000000); + c128.l = 0; + } + if (xisnonnumber(f.dd.x) && f.dd.x != INFINITY) c128.h = c128.l = UINT64_C(0xffffffffffffffff); + + c128.h |= signbit; + + return c128.q; +} +#endif // #if MPFR_VERSION_MAJOR >= 4 + +char *sprintf128(Sleef_quad q) { + mpfr_t fr; + mpfr_inits(fr, NULL); + mpfr_set_f128(fr, q, GMP_RNDN); + char *f = sprintfr(fr); + mpfr_clears(fr, NULL); + cnv_t c128 = { .q = q }; + char *ret = malloc(128); + sprintf(ret, "%016llx%016llx (%s)", (unsigned long long)c128.h, (unsigned long long)c128.l, f); + free(f); + return ret; +} + +double cast_d_q(Sleef_quad q) { + mpfr_t fr; + mpfr_inits(fr, NULL); + mpfr_set_f128(fr, q, GMP_RNDN); + double ret = mpfr_get_d(fr, GMP_RNDN); + mpfr_clears(fr, NULL); + return ret; +} + +Sleef_quad add_q_d(Sleef_quad q, double d) { + mpfr_t fr; + mpfr_inits(fr, NULL); + mpfr_set_f128(fr, q, GMP_RNDN); + mpfr_add_d(fr, fr, d, GMP_RNDN); + q = mpfr_get_f128(fr, GMP_RNDN); + mpfr_clears(fr, NULL); + return q; +} + +Sleef_quad cast_q_str(const char *s) { + mpfr_t fr; + mpfr_inits(fr, NULL); + mpfr_set_str(fr, s, 10, GMP_RNDN); + Sleef_quad q = mpfr_get_f128(fr, GMP_RNDN); + mpfr_clears(fr, NULL); + return q; +} + +Sleef_quad cast_q_str_hex(const char *s) { + mpfr_t fr; + mpfr_inits(fr, NULL); + mpfr_set_str(fr, s, 16, GMP_RNDN); + Sleef_quad q = mpfr_get_f128(fr, GMP_RNDN); + mpfr_clears(fr, NULL); + return q; +} + +Sleef_quad add_q_q(Sleef_quad q, Sleef_quad r) { + mpfr_t fr0, fr1; + mpfr_inits(fr0, fr1, NULL); + mpfr_set_f128(fr0, q, GMP_RNDN); + mpfr_set_f128(fr1, r, GMP_RNDN); + mpfr_add(fr0, fr0, fr1, GMP_RNDN); + q = mpfr_get_f128(fr0, GMP_RNDN); + mpfr_clears(fr0, fr1, NULL); + return q; +} +#else // #ifdef USEMPFR +char *sprintf128(Sleef_quad x) { + cnv_t c128 = { .q = x }; + char *s = malloc(128); + sprintf(s, "%016llx%016llx", (unsigned long long)c128.h, (unsigned long long)c128.l); + return s; +} +#endif // #ifdef USEMPFR diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/quad-tester/qtesterutil.h b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/quad-tester/qtesterutil.h new file mode 100644 index 00000000000..380e97579eb --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/quad-tester/qtesterutil.h @@ -0,0 +1,66 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include "quaddef.h" + +typedef struct { +#if defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) + uint64_t h, l; +#else + uint64_t l, h; +#endif +} xuint128; + +xuint128 xu(uint64_t h, uint64_t l); +xuint128 sll128(uint64_t u, int c); +xuint128 add128(xuint128 x, xuint128 y); +int lt128(xuint128 x, xuint128 y); + +void xsrand(uint64_t s); +uint64_t xrand(); +void memrand(void *p, int size); +Sleef_quad rndf128(Sleef_quad min, Sleef_quad max, int setSignRandomly); +Sleef_quad rndf128x(); + +int readln(int fd, char *buf, int cnt); +int startsWith(char *str, char *prefix); + +int iszerof128(Sleef_quad a); +int isnegf128(Sleef_quad a); +int isinff128(Sleef_quad a); +int isnonnumberf128(Sleef_quad a); +int isnanf128(Sleef_quad a); + +static double u2d(uint64_t u) { + union { + double f; + uint64_t i; + } tmp; + tmp.i = u; + return tmp.f; +} + +static uint64_t d2u(double d) { + union { + double f; + uint64_t i; + } tmp; + tmp.f = d; + return tmp.i; +} + +#ifdef USEMPFR +void mpfr_set_f128(mpfr_t frx, Sleef_quad a, mpfr_rnd_t rnd); +Sleef_quad mpfr_get_f128(mpfr_t m, mpfr_rnd_t rnd); + +double countULPf128(Sleef_quad d, mpfr_t c, int checkNegZero); +char *sprintfr(mpfr_t fr); +char *sprintf128(Sleef_quad x); + +double cast_d_q(Sleef_quad q); +Sleef_quad cast_q_str(const char *s); +Sleef_quad cast_q_str_hex(const char *s); +Sleef_quad add_q_d(Sleef_quad q, double d); +#endif diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/quad-tester/qutil.c b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/quad-tester/qutil.c new file mode 100644 index 00000000000..11b8b482b2e --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/quad-tester/qutil.c @@ -0,0 +1,41 @@ +#include +#include +#include + +#if defined(_MSC_VER) +#pragma warning(disable:4116) // warning C4116: unnamed type definition in parentheses +#endif + +int main(int argc, char **argv) { + if (argc == 1) { + printf("Usage : %s \n", argv[0]); + exit(-1); + } + + if (argc == 4) { + int64_t h = strtoll(argv[1], NULL, 16); + uint64_t l = strtoull(argv[2], NULL, 16); + int e = atoi(argv[3]); + Sleef_quad q = sleef_q(h, l, e); + Sleef_printf("%+Pa = %.30Pg\n", &q, &q); + exit(0); + } + + union { + struct { +#if defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) + unsigned long long h, l; +#else + unsigned long long l, h; +#endif + }; + Sleef_quad q; + } cnv = { .q = Sleef_strtoq(argv[1], NULL) }; + + Sleef_printf("%+Pa\nsleef_q(%c0x%c%012llxLL, 0x%016llxULL, %d)\n", + &cnv.q, (cnv.h >> 63) ? '-' : '+', + (int)((cnv.h >> 48) & 0x7fff) == 0 ? '0' : '1', + (unsigned long long)(0xffffffffffffULL & cnv.h), + (unsigned long long)cnv.l, + (int)((cnv.h >> 48) & 0x7fff) - 16383); +} diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/quad-tester/tester2printf.c b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/quad-tester/tester2printf.c new file mode 100644 index 00000000000..32ff6301ef0 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/quad-tester/tester2printf.c @@ -0,0 +1,283 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// gcc -O3 -Wno-format tester2printf.c qtesterutil.c -I ../../src/common -I ../../build/include -L ../../build/lib -lsleefquad -lsleef -lquadmath + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "sleefquad.h" +#include "qtesterutil.h" + +void testem_rnd(Sleef_quad val) { + int prec = xrand() % 25, width = xrand() % 50; + char *types[] = { "Qe", "Qf", "Qg", "Qa" }; + for(int i=0;i<4;i++) { + for(int alt=0;alt<2;alt++) { + for(int zero=0;zero<2;zero++) { + for(int left=0;left<2;left++) { + for(int blank=0;blank<2;blank++) { + for(int sign=0;sign<2;sign++) { + char fmt[100], corr[100], corr2[100], test[100]; + int lc, lc2, lt; + + // no width, no prec + + snprintf(fmt, 99, "%%%s%s%s%s%s%s", + alt ? "#" : "", + zero ? "0" : "", + left ? "-" : "", + blank ? " " : "", + sign ? "+" : "", + types[i]); + lc2 = snprintf(corr2, 99, fmt, val); + lc = snprintf(corr, 99, fmt, strtoflt128(corr2, NULL)); + lt = Sleef_snprintf(test, 99, fmt, val); + + if((lc != lt && lc2 != lt) || (strcmp(test, corr) != 0 && strcmp(test, corr2) != 0)) { + printf("val=%Qa %s : c=[%s](%d) t=[%s](%d)\n", val, fmt, corr, lc, test, lt); + return; + } + if (strtoflt128(corr, NULL) != Sleef_strtoq(corr, NULL) && strstr(corr, "nan") == NULL) { + printf("X [%s] : c=[%.40Qg] t=[%.40Qg]\n", corr, strtoflt128(corr, NULL), Sleef_strtoq(corr, NULL)); + return; + } + + // width + + snprintf(fmt, 99, "%%%s%s%s%s%s%d.%s", + alt ? "#" : "", + zero ? "0" : "", + left ? "-" : "", + blank ? " " : "", + sign ? "+" : "", + width, types[i]); + lc2 = snprintf(corr2, 99, fmt, val); + lc = snprintf(corr, 99, fmt, strtoflt128(corr2, NULL)); + lt = Sleef_snprintf(test, 99, fmt, val); + + if((lc != lt && lc2 != lt) || (strcmp(test, corr) != 0 && strcmp(test, corr2) != 0)) { + printf("val=%Qa %s : c=[%s](%d) t=[%s](%d)\n", val, fmt, corr, lc, test, lt); + return; + } + if (strtoflt128(corr, NULL) != Sleef_strtoq(corr, NULL) && strstr(corr, "nan") == NULL) { + printf("X [%s] : c=[%.40Qg] t=[%.40Qg]\n", corr, strtoflt128(corr, NULL), Sleef_strtoq(corr, NULL)); + return; + } + + // prec + + snprintf(fmt, 99, "%%%s%s%s%s%s.%d%s", + alt ? "#" : "", + zero ? "0" : "", + left ? "-" : "", + blank ? " " : "", + sign ? "+" : "", + prec, types[i]); + lc2 = snprintf(corr2, 99, fmt, val); + lc = snprintf(corr, 99, fmt, strtoflt128(corr2, NULL)); + lt = Sleef_snprintf(test, 99, fmt, val); + + if((lc != lt && lc2 != lt) || (strcmp(test, corr) != 0 && strcmp(test, corr2) != 0)) { + printf("val=%Qa %s : c=[%s](%d) t=[%s](%d)\n", val, fmt, corr, lc, test, lt); + return; + } + if (strtoflt128(corr, NULL) != Sleef_strtoq(corr, NULL) && strstr(corr, "nan") == NULL) { + printf("X [%s] : c=[%.40Qg] t=[%.40Qg]\n", corr, strtoflt128(corr, NULL), Sleef_strtoq(corr, NULL)); + return; + } + + // both + + snprintf(fmt, 99, "%%%s%s%s%s%s%d.%d%s", + alt ? "#" : "", + zero ? "0" : "", + left ? "-" : "", + blank ? " " : "", + sign ? "+" : "", + width, prec, types[i]); + lc2 = snprintf(corr2, 99, fmt, val); + lc = snprintf(corr, 99, fmt, strtoflt128(corr2, NULL)); + lt = Sleef_snprintf(test, 99, fmt, val); + + if((lc != lt && lc2 != lt) || (strcmp(test, corr) != 0 && strcmp(test, corr2) != 0)) { + printf("val=%Qa %s : c=[%s](%d) t=[%s](%d)\n", val, fmt, corr, lc, test, lt); + return; + } + if (strtoflt128(corr, NULL) != Sleef_strtoq(corr, NULL) && strstr(corr, "nan") == NULL) { + printf("X [%s] : c=[%.40Qg] t=[%.40Qg]\n", corr, strtoflt128(corr, NULL), Sleef_strtoq(corr, NULL)); + return; + } + } + } + } + } + } + } +} + +int testem(Sleef_quad val) { + int ret = 0; + char *types[] = { "Qe", "Qf", "Qg", "Qa" }; + for(int i=0;i<4;i++) { + for(int alt=0;alt<2;alt++) { + for(int zero=0;zero<2;zero++) { + for(int left=0;left<2;left++) { + for(int blank=0;blank<2;blank++) { + for(int sign=0;sign<2;sign++) { + char fmt[100], corr[100], corr2[100], test[100]; + int lc, lc2, lt; + + snprintf(fmt, 99, "%%%s%s%s%s%s%s", + alt ? "#" : "", + zero ? "0" : "", + left ? "-" : "", + blank ? " " : "", + sign ? "+" : "", + types[i]); + lc2 = snprintf(corr2, 99, fmt, val); + lc = snprintf(corr, 99, fmt, strtoflt128(corr2, NULL)); + lt = Sleef_snprintf(test, 99, fmt, val); + + if((lc != lt && lc2 != lt) || (strcmp(test, corr) != 0 && strcmp(test, corr2) != 0)) { + printf("val=%Qa %s : c=[%s](%d) t=[%s](%d)\n", val, fmt, corr, lc, test, lt); + ret = 1; + } + if (strtoflt128(corr, NULL) != Sleef_strtoq(corr, NULL) && strstr(corr, "nan") == NULL) { + printf("X [%s] : c=[%.40Qg] t=[%.40Qg]\n", corr, strtoflt128(corr, NULL), Sleef_strtoq(corr, NULL)); + ret = 1; + } + + int prec = xrand() % 30, width = xrand() % 30; + + for(int width=6;width<=16;width += 2) { + snprintf(fmt, 99, "%%%s%s%s%s%s%d.%s", + alt ? "#" : "", + zero ? "0" : "", + left ? "-" : "", + blank ? " " : "", + sign ? "+" : "", + width, types[i]); + lc2 = snprintf(corr2, 99, fmt, val); + lc = snprintf(corr, 99, fmt, strtoflt128(corr2, NULL)); + lt = Sleef_snprintf(test, 99, fmt, val); + + if((lc != lt && lc2 != lt) || (strcmp(test, corr) != 0 && strcmp(test, corr2) != 0)) { + printf("val=%Qa %s : c=[%s](%d) t=[%s](%d)\n", val, fmt, corr, lc, test, lt); + ret = 1; + } + if (strtoflt128(corr, NULL) != Sleef_strtoq(corr, NULL) && strstr(corr, "nan") == NULL) { + printf("X [%s] : c=[%.40Qg] t=[%.40Qg]\n", corr, strtoflt128(corr, NULL), Sleef_strtoq(corr, NULL)); + ret = 1; + } + } + + for(int prec=4;prec<=12;prec += 2) { + for(int width=6;width<=16;width += 2) { + snprintf(fmt, 99, "%%%s%s%s%s%s%d.%d%s", + alt ? "#" : "", + zero ? "0" : "", + left ? "-" : "", + blank ? " " : "", + sign ? "+" : "", + width, prec, types[i]); + lc2 = snprintf(corr2, 99, fmt, val); + lc = snprintf(corr, 99, fmt, strtoflt128(corr2, NULL)); + lt = Sleef_snprintf(test, 99, fmt, val); + + if((lc != lt && lc2 != lt) || (strcmp(test, corr) != 0 && strcmp(test, corr2) != 0)) { + printf("val=%Qa %s : c=[%s](%d) t=[%s](%d)\n", val, fmt, corr, lc, test, lt); + ret = 1; + } + if (strtoflt128(corr, NULL) != Sleef_strtoq(corr, NULL) && strstr(corr, "nan") == NULL) { + printf("X [%s] : c=[%.40Qg] t=[%.40Qg]\n", corr, strtoflt128(corr, NULL), Sleef_strtoq(corr, NULL)); + ret = 1; + } + } + + snprintf(fmt, 99, "%%%s%s%s%s%s.%d%s", + alt ? "#" : "", + zero ? "0" : "", + left ? "-" : "", + blank ? " " : "", + sign ? "+" : "", + prec, types[i]); + lc2 = snprintf(corr2, 99, fmt, val); + lc = snprintf(corr, 99, fmt, strtoflt128(corr2, NULL)); + lt = Sleef_snprintf(test, 99, fmt, val); + + if((lc != lt && lc2 != lt) || (strcmp(test, corr) != 0 && strcmp(test, corr2) != 0)) { + printf("val=%Qa %s : c=[%s](%d) t=[%s](%d)\n", val, fmt, corr, lc, test, lt); + ret = 1; + } + if (strtoflt128(corr, NULL) != Sleef_strtoq(corr, NULL) && strstr(corr, "nan") == NULL) { + printf("X [%s] : c=[%.40Qg] t=[%.40Qg]\n", corr, strtoflt128(corr, NULL), Sleef_strtoq(corr, NULL)); + ret = 1; + } + } + } + } + } + } + } + } + return ret; +} + +int main(int argc, char **argv) { + xsrand(time(NULL) + (((int)getpid()) << 12)); + + strtoflt128("1", NULL); // This is for registering hook + + Sleef_quad vals[] = { + 1.2345678912345678912345e+0Q, + 1.2345678912345678912345e+1Q, + 1.2345678912345678912345e-1Q, + 1.2345678912345678912345e+2Q, + 1.2345678912345678912345e-2Q, + 1.2345678912345678912345e+3Q, + 1.2345678912345678912345e-3Q, + 1.2345678912345678912345e+4Q, + 1.2345678912345678912345e-4Q, + 1.2345678912345678912345e+5Q, + 1.2345678912345678912345e-5Q, + 1.2345678912345678912345e+10Q, + 1.2345678912345678912345e-10Q, + 1.2345678912345678912345e+15Q, + 1.2345678912345678912345e-15Q, + 1.2345678912345678912345e+30Q, + 1.2345678912345678912345e-30Q, + //1.2345678912345678912345e+1000Q, + 1.2345678912345678912345e-1000Q, + 1.2345678912345678912345e-4950Q, + //1.2345678912345678912345e+4920Q, + 3.36210314311209350626267781732175260e-4932Q, + //1.18973149535723176508575932662800702e+4932Q, + 6.475175119438025110924438958227646552e-4966Q, + 0.0Q, 1.0Q, + 1e+1Q, 1e+2Q, 1e+3Q, 1e+4Q, 1e+5Q, 1e+6Q, + 1e-1Q, 1e-2Q, 1e-3Q, 1e-4Q, 1e-5Q, 1e-6Q, + 1e+300*1e+300, 1e+300*1e+300 - 1e+300*1e+300 + }; + + for(int i=0;i 1e+25) continue; + testem_rnd(q); + } +} diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/quad-tester/tester2simdqp.c b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/quad-tester/tester2simdqp.c new file mode 100644 index 00000000000..4ddcd36961e --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/quad-tester/tester2simdqp.c @@ -0,0 +1,1098 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include "sleef.h" +#include "sleefquad.h" + +#include "misc.h" +#include "qtesterutil.h" + +// + +#ifdef ENABLE_PUREC_SCALAR +#define CONFIG 1 +#include "helperpurec_scalar.h" +#include "qrenamepurec_scalar.h" +#define VARGQUAD Sleef_quad +#endif + +#ifdef ENABLE_PURECFMA_SCALAR +#define CONFIG 2 +#include "helperpurec_scalar.h" +#include "qrenamepurecfma_scalar.h" +#define VARGQUAD Sleef_quad +#endif + +#ifdef ENABLE_SSE2 +#define CONFIG 2 +#include "helpersse2.h" +#include "qrenamesse2.h" +#define VARGQUAD Sleef_quadx2 +#endif + +#ifdef ENABLE_AVX2128 +#define CONFIG 1 +#include "helperavx2_128.h" +#include "qrenameavx2128.h" +#define VARGQUAD Sleef_quadx2 +#endif + +#ifdef ENABLE_AVX +#define CONFIG 1 +#include "helperavx.h" +#include "qrenameavx.h" +#define VARGQUAD Sleef_quadx4 +#endif + +#ifdef ENABLE_FMA4 +#define CONFIG 4 +#include "helperavx.h" +#include "qrenamefma4.h" +#define VARGQUAD Sleef_quadx4 +#endif + +#ifdef ENABLE_AVX2 +#define CONFIG 1 +#include "helperavx2.h" +#include "qrenameavx2.h" +#define VARGQUAD Sleef_quadx4 +#endif + +#ifdef ENABLE_AVX512F +#define CONFIG 1 +#include "helperavx512f.h" +#include "qrenameavx512f.h" +#define VARGQUAD Sleef_quadx8 +#endif + +#ifdef ENABLE_ADVSIMD +#define CONFIG 1 +#include "helperadvsimd.h" +#include "qrenameadvsimd.h" +#define VARGQUAD Sleef_quadx2 +#endif + +#ifdef ENABLE_SVE +#define CONFIG 1 +#include "helpersve.h" +#include "qrenamesve.h" +#define VARGQUAD Sleef_svquad +#endif + +#ifdef ENABLE_VSX +#define CONFIG 1 +#include "helperpower_128.h" +#include "qrenamevsx.h" +#define VARGQUAD Sleef_quadx2 +#endif + +#ifdef ENABLE_VSX3 +#define CONFIG 3 +#include "helperpower_128.h" +#include "qrenamevsx3.h" +#define VARGQUAD Sleef_quadx2 +#endif + +#ifdef ENABLE_VXE +#define CONFIG 140 +#include "helpers390x_128.h" +#include "qrenamevxe.h" +#define VARGQUAD Sleef_quadx2 +#endif + +#ifdef ENABLE_VXE2 +#define CONFIG 150 +#include "helpers390x_128.h" +#include "qrenamevxe2.h" +#define VARGQUAD Sleef_quadx2 +#endif + +#ifdef ENABLE_RVVM1 +#define CONFIG 1 +#define ENABLE_RVV_DP +#include "helperrvv.h" +#include "qrenamervvm1.h" +#define VARGQUAD Sleef_rvvm1quad +#endif + +#ifdef ENABLE_RVVM2 +#define CONFIG 1 +#define ENABLE_RVV_DP +#include "helperrvv.h" +#include "qrenamervvm2.h" +#define VARGQUAD Sleef_rvvm2quad +#endif + +// + +#define DENORMAL_DBL_MIN (4.9406564584124654418e-324) + +#define POSITIVE_INFINITY INFINITY +#define NEGATIVE_INFINITY (-INFINITY) + +typedef union { + Sleef_quad q; + xuint128 x; + struct { + uint64_t l, h; + }; +} cnv_t; + +Sleef_quad nexttoward0q(Sleef_quad x, int n) { + cnv_t cx; + cx.q = x; + cx.x = add128(cx.x, xu(n < 0 ? 0 : -1, -(int64_t)n)); + return cx.q; +} + +static VARGQUAD vset(VARGQUAD v, int idx, Sleef_quad d) { return xsetq(v, idx, d); } +static Sleef_quad vget(VARGQUAD v, int idx) { return xgetq(v, idx); } + +vdouble vsetd(vdouble v, int idx, double d) { + double a[VECTLENDP]; + vstoreu_v_p_vd(a, v); + a[idx] = d; + return vloadu_vd_p(a); +} + +double vgetd(vdouble v, int idx) { + double a[VECTLENDP]; + vstoreu_v_p_vd(a, v); + return a[idx]; +} + +vmask vsetm(vmask v, int idx, uint64_t d) { + uint64_t a[VECTLENDP]; + vstoreu_v_p_vd((double *)a, vreinterpret_vd_vm(v)); + a[idx] = d; + return vreinterpret_vm_vd(vloadu_vd_p((double *)a)); +} + +int64_t vgeti64(vint64 v, int idx) { + int64_t a[VECTLENDP]; + vstoreu_v_p_vd((double *)a, vreinterpret_vd_vm(vreinterpret_vm_vi64(v))); + return a[idx]; +} + +uint64_t vgetu64(vuint64 v, int idx) { + uint64_t a[VECTLENDP]; + vstoreu_v_p_vd((double *)a, vreinterpret_vd_vm(vreinterpret_vm_vu64(v))); + return a[idx]; +} + +static int vgeti(vint v, int idx) { + int a[VECTLENDP*2]; + vstoreu_v_p_vi(a, v); + return a[idx]; +} + +int main(int argc,char **argv) +{ + mpfr_set_default_prec(1024); + xsrand(time(NULL) + (((int)getpid()) << 12)); + srandom(time(NULL) + (((int)getpid()) << 12)); + + // + + const Sleef_quad oneQ = cast_q_str("1"); + const Sleef_quad oneEMinus300Q = cast_q_str("1e-300"); + const Sleef_quad oneEMinus10Q = cast_q_str("1e-10"); + const Sleef_quad oneEPlus10Q = cast_q_str("1e+10"); + const Sleef_quad oneEMinus100Q = cast_q_str("1e-100"); + const Sleef_quad oneEPlus100Q = cast_q_str("1e+100"); + const Sleef_quad oneEMinus1000Q = cast_q_str("1e-1000"); + const Sleef_quad oneEPlus1000Q = cast_q_str("1e+1000"); + const Sleef_quad quadMin = cast_q_str("3.36210314311209350626267781732175260e-4932"); + const Sleef_quad quadMax = cast_q_str("1.18973149535723176508575932662800702e+4932"); + const Sleef_quad quadDenormMin = cast_q_str("6.475175119438025110924438958227646552e-4966"); +#if defined(ENABLEFLOAT128) + const Sleef_quad M_PI_2Q = cast_q_str("1.5707963267948966192313216916397514"); +#endif + + // + + int cnt, ecnt = 0; + VARGQUAD a0, a1, a2, a3; + vdouble vd0 = vcast_vd_d(0); + Sleef_quad q0, q1, q2, q3, t; + mpfr_t frw, frx, fry, frz; + mpfr_inits(frw, frx, fry, frz, NULL); + +#if !(defined ENABLE_SVE || defined ENABLE_RVVM1 || defined ENABLE_RVVM2) + memset(&a0, 0, sizeof(a0)); + memset(&a1, 0, sizeof(a1)); + memset(&a2, 0, sizeof(a2)); + memset(&a3, 0, sizeof(a3)); +#endif + + for(cnt = 0;ecnt < 1000;cnt++) { + int e = cnt % VECTLENDP; + + // In the following switch-case statement, I am trying to test + // with numbers that tends to trigger bugs. Each case is executed + // once in 128 times of loop execution. + switch(cnt & 127) { + case 127: + q0 = nexttoward0q(quadMin, (xrand() & 63) - 31); + q1 = rndf128x(); + q2 = rndf128x(); + break; + case 126: + q0 = nexttoward0q(quadMax, (xrand() & 31)); + q1 = rndf128x(); + q2 = rndf128x(); + break; + case 125: + q0 = nexttoward0q(quadDenormMin, -(int)(xrand() & 31)); + q1 = rndf128x(); + q2 = rndf128x(); + break; +#if defined(ENABLEFLOAT128) + case 124: + q0 = rndf128x(); + q1 = rndf128x(); + q1 += q0; + q2 = rndf128x(); + break; + case 123: + q0 = rndf128x(); + q1 = rndf128x(); + q1 -= q0; + q2 = rndf128x(); + break; + case 122: + q0 = rndf128x(); + q1 = rndf128x(); + q0 += q1; + q2 = rndf128x(); + break; + case 121: + q0 = rndf128x(); + q1 = rndf128x(); + q0 -= q1; + q2 = rndf128x(); + break; + case 120: + q0 = rndf128x(); + q1 = rndf128x(); + q1 += 1; + q2 = rndf128x(); + break; + case 119: + q0 = rndf128x(); + q1 = rndf128x(); + q0 += 1; + q2 = rndf128x(); + break; + case 118: + q0 = rndf128x(); + q1 = rndf128x(); + q0 += 1; + q1 -= 1; + q2 = rndf128x(); + break; + case 117: + q0 = rndf128x(); + q1 = rndf128x(); + q0 -= 1; + q1 += 1; + q2 = rndf128x(); + break; + case 116: + q0 = rndf128x(); + q1 = rndf128x(); + q1 += copysign(1, q1) * SLEEF_QUAD_MIN; + q2 = rndf128x(); + break; + case 115: + q0 = rndf128x(); + q1 = rndf128x(); + q0 += copysign(1, q0) * SLEEF_QUAD_MIN; + q2 = rndf128x(); + break; + case 114: + q0 = rndf128x(); + q1 = rndf128x(); + q1 -= copysign(1, q1) * SLEEF_QUAD_MIN; + q2 = rndf128x(); + break; + case 113: + q0 = rndf128x(); + q1 = rndf128x(); + q0 -= copysign(1, q0) * SLEEF_QUAD_MIN; + q2 = rndf128x(); + break; +#endif + default: + // Each case in the following switch-case statement is executed + // once in 8 loops. + switch(cnt & 7) { + case 0: + q0 = rndf128(oneEMinus10Q, oneEPlus10Q, 1); + q1 = rndf128(oneEMinus10Q, oneEPlus10Q, 1); + q2 = rndf128(oneEMinus10Q, oneEPlus10Q, 1); + break; + case 1: + q0 = rndf128(oneEMinus100Q, oneEPlus100Q, 1); + q1 = rndf128(oneEMinus100Q, oneEPlus100Q, 1); + q2 = rndf128(oneEMinus100Q, oneEPlus100Q, 1); + break; + case 2: + q0 = rndf128(oneEMinus1000Q, oneEPlus1000Q, 1); + q1 = rndf128(oneEMinus1000Q, oneEPlus1000Q, 1); + q2 = rndf128(oneEMinus1000Q, oneEPlus1000Q, 1); + break; + default: + q0 = rndf128x(); + q1 = rndf128x(); + q2 = rndf128x(); + break; + } + break; + } + + a0 = vset(a0, e, q0); + a1 = vset(a1, e, q1); + a2 = vset(a1, e, q2); + mpfr_set_f128(frx, q0, GMP_RNDN); + mpfr_set_f128(fry, q1, GMP_RNDN); + mpfr_set_f128(frz, q2, GMP_RNDN); + + { + mpfr_add(frw, frx, fry, GMP_RNDN); + + double u0 = countULPf128(t = vget(xaddq_u05(a0, a1), e), frw, 0); + + if (u0 > 0.5000000001) { + printf(ISANAME " add arg=%s %s ulp=%.20g\n", sprintf128(q0), sprintf128(q1), u0); + printf("test = %s\n", sprintf128(t)); + printf("corr = %s\n\n", sprintf128(mpfr_get_f128(frw, GMP_RNDN))); + fflush(stdout); ecnt++; + } + } + + { + mpfr_sub(frw, frx, fry, GMP_RNDN); + + double u0 = countULPf128(t = vget(xsubq_u05(a0, a1), e), frw, 0); + + if (u0 > 0.5000000001) { + printf(ISANAME " sub arg=%s %s ulp=%.20g\n", sprintf128(q0), sprintf128(q1), u0); + printf("test = %s\n", sprintf128(t)); + printf("corr = %s\n\n", sprintf128(mpfr_get_f128(frw, GMP_RNDN))); + fflush(stdout); ecnt++; + } + } + + { + mpfr_mul(frw, frx, fry, GMP_RNDN); + + double u0 = countULPf128(t = vget(xmulq_u05(a0, a1), e), frw, 0); + + if (u0 > 0.5000000001) { + printf(ISANAME " mul arg=%s %s ulp=%.20g\n", sprintf128(q0), sprintf128(q1), u0); + printf("test = %s\n", sprintf128(t)); + printf("corr = %s\n\n", sprintf128(mpfr_get_f128(frw, GMP_RNDN))); + fflush(stdout); ecnt++; + } + } + + { + mpfr_div(frw, frx, fry, GMP_RNDN); + + double u0 = countULPf128(t = vget(xdivq_u05(a0, a1), e), frw, 0); + + if (u0 > 0.5000000001) { + printf(ISANAME " div arg=%s %s ulp=%.20g\n", sprintf128(q0), sprintf128(q1), u0); + printf("test = %s\n", sprintf128(t)); + printf("corr = %s\n\n", sprintf128(mpfr_get_f128(frw, GMP_RNDN))); + fflush(stdout); ecnt++; + } + } + + { + mpfr_sqrt(frw, frx, GMP_RNDN); + + double u0 = countULPf128(t = vget(xsqrtq_u05(a0), e), frw, 0); + + if (u0 > 0.5000000001) { + printf(ISANAME " sqrt arg=%s ulp=%.20g\n", sprintf128(q0), u0); + printf("test = %s\n", sprintf128(t)); + printf("corr = %s\n\n", sprintf128(mpfr_get_f128(frw, GMP_RNDN))); + fflush(stdout); ecnt++; + } + } + + { + mpfr_cbrt(frw, frx, GMP_RNDN); + + double u0 = countULPf128(t = vget(xcbrtq_u10(a0), e), frw, 0); + + if (u0 > 0.7) { + printf(ISANAME " cbrt arg=%s ulp=%.20g\n", sprintf128(q0), u0); + printf("test = %s\n", sprintf128(t)); + printf("corr = %s\n\n", sprintf128(mpfr_get_f128(frw, GMP_RNDN))); + fflush(stdout); ecnt++; + } + } + + { + mpfr_dim(frw, frx, fry, GMP_RNDN); + + double u0 = countULPf128(t = vget(xfdimq_u05(a0, a1), e), frw, 0); + + if (u0 > 0.5000000001) { + printf(ISANAME " fdim arg=%s %s ulp=%.20g\n", sprintf128(q0), sprintf128(q1), u0); + printf("test = %s\n", sprintf128(t)); + printf("corr = %s\n\n", sprintf128(mpfr_get_f128(frw, GMP_RNDN))); + fflush(stdout); ecnt++; + } + } + + { + mpfr_hypot(frw, frx, fry, GMP_RNDN); + + double u0 = countULPf128(t = vget(xhypotq_u05(a0, a1), e), frw, 0); + + if (u0 > 0.5000000001) { + printf(ISANAME " hypot arg=%s %s ulp=%.20g\n", sprintf128(q0), sprintf128(q1), u0); + printf("test = %s\n", sprintf128(t)); + printf("corr = %s\n\n", sprintf128(mpfr_get_f128(frw, GMP_RNDN))); + fflush(stdout); ecnt++; + } + } + + { + mpfr_fma(frw, frx, fry, frz, GMP_RNDN); + + double u0 = countULPf128(t = vget(xfmaq_u05(a0, a1, a2), e), frw, 0); + + if (u0 > 0.5000000001) { + printf(ISANAME " fma arg=%s, %s, %s ulp=%.20g\n", sprintf128(q0), sprintf128(q1), sprintf128(q2), u0); + printf("test = %s\n", sprintf128(t)); + printf("corr = %s\n\n", sprintf128(mpfr_get_f128(frw, GMP_RNDN))); + fflush(stdout); ecnt++; + } + } + + { + mpfr_modf(frw, frz, frx, GMP_RNDN); + + a2 = xmodfq(a0, &a3); + double u0 = countULPf128(q2 = vget(a2, e), frz, 0); + double u1 = countULPf128(q3 = vget(a3, e), frw, 0); + + if (u0 > 0 || u1 > 0) { + printf(ISANAME " modf arg=%s ulp=%.20g, %.20g\n", sprintf128(q0), u0, u1); + printf("test = %s, %s\n", sprintf128(q2), sprintf128(q3)); + printf("corr = %s, %s\n\n", sprintf128(mpfr_get_f128(frw, GMP_RNDN)), sprintf128(mpfr_get_f128(frw, GMP_RNDN))); + fflush(stdout); ecnt++; + } + } + + if (cnt % 101 == 0) { + { + mpfr_fmod(frw, frx, fry, GMP_RNDN); + + double u0 = countULPf128(t = vget(xfmodq(a0, a1), e), frw, 0); + + if (u0 > 0) { + printf(ISANAME " fmod arg=%s %s ulp=%.20g\n", sprintf128(q0), sprintf128(q1), u0); + printf("test = %s\n", sprintf128(t)); + printf("corr = %s\n\n", sprintf128(mpfr_get_f128(frw, GMP_RNDN))); + fflush(stdout); ecnt++; + } + } + + { + mpfr_remainder(frw, frx, fry, GMP_RNDN); + + double u0 = countULPf128(t = vget(xremainderq(a0, a1), e), frw, 0); + + if (u0 > 0) { + printf(ISANAME " remainder arg=%s %s ulp=%.20g\n", sprintf128(q0), sprintf128(q1), u0); + printf("test = %s\n", sprintf128(t)); + printf("corr = %s\n\n", sprintf128(mpfr_get_f128(frw, GMP_RNDN))); + fflush(stdout); ecnt++; + } + } + } + + { + mpfr_trunc(frw, frx); + double u0 = countULPf128(t = vget(xtruncq(a0), e), frw, 0); + + if (u0 > 0) { + printf(ISANAME " trunc arg=%s ulp=%.20g\n", sprintf128(q0), u0); + printf("test = %s\n", sprintf128(t)); + printf("corr = %s\n\n", sprintf128(mpfr_get_f128(frw, GMP_RNDN))); + fflush(stdout); ecnt++; + } + } + + { + mpfr_floor(frw, frx); + double u0 = countULPf128(t = vget(xfloorq(a0), e), frw, 0); + + if (u0 > 0) { + printf(ISANAME " floor arg=%s ulp=%.20g\n", sprintf128(q0), u0); + printf("test = %s\n", sprintf128(t)); + printf("corr = %s\n\n", sprintf128(mpfr_get_f128(frw, GMP_RNDN))); + fflush(stdout); ecnt++; + } + } + + { + mpfr_ceil(frw, frx); + double u0 = countULPf128(t = vget(xceilq(a0), e), frw, 0); + + if (u0 > 0) { + printf(ISANAME " ceil arg=%s ulp=%.20g\n", sprintf128(q0), u0); + printf("test = %s\n", sprintf128(t)); + printf("corr = %s\n\n", sprintf128(mpfr_get_f128(frw, GMP_RNDN))); + fflush(stdout); ecnt++; + } + } + + { + mpfr_round(frw, frx); + double u0 = countULPf128(t = vget(xroundq(a0), e), frw, 0); + + if (u0 > 0) { + printf(ISANAME " round arg=%s ulp=%.20g\n", sprintf128(q0), u0); + printf("test = %s\n", sprintf128(t)); + printf("corr = %s\n\n", sprintf128(mpfr_get_f128(frw, GMP_RNDN))); + fflush(stdout); ecnt++; + } + } + + { + mpfr_rint(frw, frx, GMP_RNDN); + double u0 = countULPf128(t = vget(xrintq(a0), e), frw, 0); + + if (u0 > 0) { + printf(ISANAME " rint arg=%s ulp=%.20g\n", sprintf128(q0), u0); + printf("test = %s\n", sprintf128(t)); + printf("corr = %s\n\n", sprintf128(mpfr_get_f128(frw, GMP_RNDN))); + fflush(stdout); ecnt++; + } + } + + { + double d = mpfr_get_d(frx, GMP_RNDN); + vd0 = vsetd(vd0, e, d); + t = vget(xcast_from_doubleq(vd0), e); + mpfr_set_d(frw, d, GMP_RNDN); + Sleef_quad q2 = mpfr_get_f128(frw, GMP_RNDN); + + if (memcmp(&t, &q2, sizeof(Sleef_quad)) != 0 && !(isnanf128(t) && isnanf128(q2))) { + printf(ISANAME " cast_from_double arg=%.20g\n", d); + printf("test = %s\n", sprintf128(t)); + printf("corr = %s\n\n", sprintf128(q2)); + fflush(stdout); ecnt++; + } + } + + { + double td = vgetd(xcast_to_doubleq(a0), e); + double cd = mpfr_get_d(frx, GMP_RNDN); + + if (fabs(cd) >= DBL_MIN && cd != td && !(isnan(td) && isnan(cd))) { + printf(ISANAME " cast_to_double arg=%s\n", sprintf128(q0)); + printf("test = %.20g\n", td); + printf("corr = %.20g\n", cd); + fflush(stdout); ecnt++; + } + } + + { + int64_t i64 = mpfr_get_sj(frx, GMP_RNDN); + vd0 = vreinterpret_vd_vm(vsetm(vreinterpret_vm_vd(vd0), e, i64)); + t = vget(xcast_from_int64q(vreinterpret_vi64_vm(vreinterpret_vm_vd(vd0))), e); + mpfr_set_sj(frw, i64, GMP_RNDN); + Sleef_quad q2 = mpfr_get_f128(frw, GMP_RNDN); + + if (memcmp(&t, &q2, sizeof(Sleef_quad)) != 0) { + printf(ISANAME " cast_from_int64q arg=%lld\n", (long long)i64); + printf("test = %s\n", sprintf128(t)); + printf("corr = %s\n\n", sprintf128(q2)); + fflush(stdout); ecnt++; + } + } + + { + int64_t td = vgeti64(xcast_to_int64q(a0), e); + int64_t cd = mpfr_get_sj(frx, GMP_RNDZ); + + if (cd != td && !isnan(mpfr_get_d(frx, GMP_RNDN))) { + printf(ISANAME " cast_to_int64q arg=%s\n", sprintf128(q0)); + printf("test = %lld\n", (long long)td); + printf("corr = %lld\n", (long long)cd); + fflush(stdout); ecnt++; + } + } + + { + uint64_t u64 = mpfr_get_uj(frx, GMP_RNDN); + vd0 = vreinterpret_vd_vm(vsetm(vreinterpret_vm_vd(vd0), e, u64)); + t = vget(xcast_from_uint64q(vreinterpret_vu64_vm(vreinterpret_vm_vd(vd0))), e); + mpfr_set_uj(frw, u64, GMP_RNDN); + Sleef_quad q2 = mpfr_get_f128(frw, GMP_RNDN); + + if (memcmp(&t, &q2, sizeof(Sleef_quad)) != 0) { + printf(ISANAME " cast_from_uint64q arg=%llu\n", (unsigned long long)u64); + printf("test = %s\n", sprintf128(t)); + printf("corr = %s\n\n", sprintf128(q2)); + fflush(stdout); ecnt++; + } + } + + { + uint64_t td = vgetu64(xcast_to_uint64q(a0), e); + uint64_t cd = mpfr_get_uj(frx, GMP_RNDZ); + + if (cd != td && !isnan(mpfr_get_d(frx, GMP_RNDN))) { + printf(ISANAME " cast_to_uint64q arg=%s\n", sprintf128(q0)); + printf("test = %llu\n", (unsigned long long)td); + printf("corr = %llu\n", (unsigned long long)cd); + fflush(stdout); ecnt++; + } + } + + { + int ci = mpfr_less_p(frx, fry); + int ti = vgeti(xicmpltq(a0, a1), e); + + if (ci != ti) { + printf(ISANAME " icmpltq arg=%s, %s, test = %d, corr = %d \n", sprintf128(q0), sprintf128(q1), ti, ci); + fflush(stdout); ecnt++; + } + } + + { + int ci = mpfr_greater_p(frx, fry); + int ti = vgeti(xicmpgtq(a0, a1), e); + + if (ci != ti) { + printf(ISANAME " icmpgtq arg=%s, %s, test = %d, corr = %d \n", sprintf128(q0), sprintf128(q1), ti, ci); + fflush(stdout); ecnt++; + } + } + + { + int ci = mpfr_lessequal_p(frx, fry); + int ti = vgeti(xicmpleq(a0, a1), e); + + if (ci != ti) { + printf(ISANAME " icmpleq arg=%s, %s, test = %d, corr = %d \n", sprintf128(q0), sprintf128(q1), ti, ci); + fflush(stdout); ecnt++; + } + } + + { + int ci = mpfr_greaterequal_p(frx, fry); + int ti = vgeti(xicmpgeq(a0, a1), e); + + if (ci != ti) { + printf(ISANAME " icmpgeq arg=%s, %s, test = %d, corr = %d \n", sprintf128(q0), sprintf128(q1), ti, ci); + fflush(stdout); ecnt++; + } + } + + { + int ci = mpfr_equal_p(frx, fry); + int ti = vgeti(xicmpeqq(a0, a1), e); + + if (ci != ti) { + printf(ISANAME " icmpeq arg=%s, %s, test = %d, corr = %d \n", sprintf128(q0), sprintf128(q1), ti, ci); + fflush(stdout); ecnt++; + } + } + + { + int ci = mpfr_lessgreater_p(frx, fry); + int ti = vgeti(xicmpneq(a0, a1), e); + + if (ci != ti) { + printf(ISANAME " icmpne arg=%s, %s, test = %d, corr = %d \n", sprintf128(q0), sprintf128(q1), ti, ci); + fflush(stdout); ecnt++; + } + } + + { + int ci = mpfr_cmp(frx, fry); + int ti = vgeti(xicmpq(a0, a1), e); + + if (ci != ti) { + printf(ISANAME " icmp arg=%s, %s, test = %d, corr = %d \n", sprintf128(q0), sprintf128(q1), ti, ci); + fflush(stdout); ecnt++; + } + } + + { + int ci = mpfr_unordered_p(frx, fry); + int ti = vgeti(xiunordq(a0, a1), e); + + if (ci != ti) { + printf(ISANAME " iunord arg=%s, %s, test = %d, corr = %d \n", sprintf128(q0), sprintf128(q1), ti, ci); + fflush(stdout); ecnt++; + } + } + +#ifdef ENABLE_PUREC_SCALAR +#if !(defined(ENABLEFLOAT128) && defined(__clang__)) + if ((cnt & 15) == 1) { + char s[64]; + Sleef_quad q1; + + Sleef_snprintf(s, 63, "%.40Qg", a0); + q1 = vget(Sleef_strtoq(s, NULL), e); + if (memcmp(&q0, &q1, sizeof(Sleef_quad)) != 0 && !(isnanf128(q0) && isnanf128(q1))) { + printf("snprintf(Qg)/strtoq arg=%s str=%s test=%s\n", sprintf128(q0), s, sprintf128(q1)); + fflush(stdout); ecnt++; + } + + Sleef_snprintf(s, 63, "%Qa", a0); + q1 = vget(Sleef_strtoq(s, NULL), e); + if (memcmp(&q0, &q1, sizeof(Sleef_quad)) != 0 && !(isnanf128(q0) && isnanf128(q1))) { + printf("snprintf(Qa)/strtoq arg=%s str=%s test=%s\n", sprintf128(q0), s, sprintf128(q1)); + fflush(stdout); ecnt++; + } + } +#else + if ((cnt & 15) == 1) { + char s[64]; + Sleef_quad q1; + + Sleef_snprintf(s, 63, "%.40Pg", &a0); + q1 = vget(Sleef_strtoq(s, NULL), e); + if (memcmp(&q0, &q1, sizeof(Sleef_quad)) != 0 && !(isnanf128(q0) && isnanf128(q1))) { + printf("snprintf(Qg)/strtoq arg=%s str=%s test=%s\n", sprintf128(q0), s, sprintf128(q1)); + fflush(stdout); ecnt++; + } + + Sleef_snprintf(s, 63, "%Pa", &a0); + q1 = vget(Sleef_strtoq(s, NULL), e); + if (memcmp(&q0, &q1, sizeof(Sleef_quad)) != 0 && !(isnanf128(q0) && isnanf128(q1))) { + printf("snprintf(Qa)/strtoq arg=%s str=%s test=%s\n", sprintf128(q0), s, sprintf128(q1)); + fflush(stdout); ecnt++; + } + } +#endif +#endif + + { + mpfr_exp(frw, frx, GMP_RNDN); + double u0 = countULPf128(t = vget(xexpq_u10(a0), e), frw, 0); + + if (u0 > 0.8) { + printf(ISANAME " exp arg=%s ulp=%.20g\n", sprintf128(q0), u0); + printf("test = %s\n", sprintf128(t)); + printf("corr = %s\n\n", sprintf128(mpfr_get_f128(frw, GMP_RNDN))); + fflush(stdout); ecnt++; + } + } + + { + mpfr_exp2(frw, frx, GMP_RNDN); + double u0 = countULPf128(t = vget(xexp2q_u10(a0), e), frw, 0); + + if (u0 > 0.8) { + printf(ISANAME " exp2 arg=%s ulp=%.20g\n", sprintf128(q0), u0); + printf("test = %s\n", sprintf128(t)); + printf("corr = %s\n\n", sprintf128(mpfr_get_f128(frw, GMP_RNDN))); + fflush(stdout); ecnt++; + } + } + + { + mpfr_exp10(frw, frx, GMP_RNDN); + double u0 = countULPf128(t = vget(xexp10q_u10(a0), e), frw, 0); + + if (u0 > 0.8) { + printf(ISANAME " exp10 arg=%s ulp=%.20g\n", sprintf128(q0), u0); + printf("test = %s\n", sprintf128(t)); + printf("corr = %s\n\n", sprintf128(mpfr_get_f128(frw, GMP_RNDN))); + fflush(stdout); ecnt++; + } + } + + { + mpfr_expm1(frw, frx, GMP_RNDN); + double u0 = countULPf128(t = vget(xexpm1q_u10(a0), e), frw, 0); + + if (u0 > 0.8) { + printf(ISANAME " expm1 arg=%s ulp=%.20g\n", sprintf128(q0), u0); + printf("test = %s\n", sprintf128(t)); + printf("corr = %s\n\n", sprintf128(mpfr_get_f128(frw, GMP_RNDN))); + fflush(stdout); ecnt++; + } + } + + { + mpfr_log(frw, frx, GMP_RNDN); + double u0 = countULPf128(t = vget(xlogq_u10(a0), e), frw, 0); + + if (u0 > 0.8) { + printf(ISANAME " log arg=%s ulp=%.20g\n", sprintf128(q0), u0); + printf("test = %s\n", sprintf128(t)); + printf("corr = %s\n\n", sprintf128(mpfr_get_f128(frw, GMP_RNDN))); + fflush(stdout); ecnt++; + } + } + + { + mpfr_log2(frw, frx, GMP_RNDN); + double u0 = countULPf128(t = vget(xlog2q_u10(a0), e), frw, 0); + + if (u0 > 0.8) { + printf(ISANAME " log2 arg=%s ulp=%.20g\n", sprintf128(q0), u0); + printf("test = %s\n", sprintf128(t)); + printf("corr = %s\n\n", sprintf128(mpfr_get_f128(frw, GMP_RNDN))); + fflush(stdout); ecnt++; + } + } + + { + mpfr_log10(frw, frx, GMP_RNDN); + double u0 = countULPf128(t = vget(xlog10q_u10(a0), e), frw, 0); + + if (u0 > 0.8) { + printf(ISANAME " log10 arg=%s ulp=%.20g\n", sprintf128(q0), u0); + printf("test = %s\n", sprintf128(t)); + printf("corr = %s\n\n", sprintf128(mpfr_get_f128(frw, GMP_RNDN))); + fflush(stdout); ecnt++; + } + } + + { + mpfr_log1p(frw, frx, GMP_RNDN); + double u0 = countULPf128(t = vget(xlog1pq_u10(a0), e), frw, 0); + + if (u0 > 0.8) { + printf(ISANAME " log1p arg=%s ulp=%.20g\n", sprintf128(q0), u0); + printf("test = %s\n", sprintf128(t)); + printf("corr = %s\n\n", sprintf128(mpfr_get_f128(frw, GMP_RNDN))); + fflush(stdout); ecnt++; + } + } + + { + mpfr_pow(frw, frx, fry, GMP_RNDN); + + double u0 = countULPf128(t = vget(xpowq_u10(a0, a1), e), frw, 0); + + if (u0 > 0.8) { + printf(ISANAME " pow arg=%s %s ulp=%.20g\n", sprintf128(q0), sprintf128(q1), u0); + printf("test = %s\n", sprintf128(t)); + printf("corr = %s\n\n", sprintf128(mpfr_get_f128(frw, GMP_RNDN))); + fflush(stdout); ecnt++; + } + } + + { + mpfr_sinh(frw, frx, GMP_RNDN); + double u0 = countULPf128(t = vget(xsinhq_u10(a0), e), frw, 0); + + if (u0 > 0.7) { + printf(ISANAME " sinh arg=%s ulp=%.20g\n", sprintf128(q0), u0); + printf("test = %s\n", sprintf128(t)); + printf("corr = %s\n\n", sprintf128(mpfr_get_f128(frw, GMP_RNDN))); + fflush(stdout); ecnt++; + } + } + + { + mpfr_cosh(frw, frx, GMP_RNDN); + double u0 = countULPf128(t = vget(xcoshq_u10(a0), e), frw, 0); + + if (u0 > 0.7) { + printf(ISANAME " cosh arg=%s ulp=%.20g\n", sprintf128(q0), u0); + printf("test = %s\n", sprintf128(t)); + printf("corr = %s\n\n", sprintf128(mpfr_get_f128(frw, GMP_RNDN))); + fflush(stdout); ecnt++; + } + } + + { + mpfr_tanh(frw, frx, GMP_RNDN); + double u0 = countULPf128(t = vget(xtanhq_u10(a0), e), frw, 0); + + if (u0 > 0.7) { + printf(ISANAME " tanh arg=%s ulp=%.20g\n", sprintf128(q0), u0); + printf("test = %s\n", sprintf128(t)); + printf("corr = %s\n\n", sprintf128(mpfr_get_f128(frw, GMP_RNDN))); + fflush(stdout); ecnt++; + } + } + + { + mpfr_asinh(frw, frx, GMP_RNDN); + double u0 = countULPf128(t = vget(xasinhq_u10(a0), e), frw, 0); + + if (u0 > 0.7) { + printf(ISANAME " asinh arg=%s ulp=%.20g\n", sprintf128(q0), u0); + printf("test = %s\n", sprintf128(t)); + printf("corr = %s\n\n", sprintf128(mpfr_get_f128(frw, GMP_RNDN))); + fflush(stdout); ecnt++; + } + } + + { + mpfr_acosh(frw, frx, GMP_RNDN); + double u0 = countULPf128(t = vget(xacoshq_u10(a0), e), frw, 0); + + if (u0 > 0.7) { + printf(ISANAME " acosh arg=%s ulp=%.20g\n", sprintf128(q0), u0); + printf("test = %s\n", sprintf128(t)); + printf("corr = %s\n\n", sprintf128(mpfr_get_f128(frw, GMP_RNDN))); + fflush(stdout); ecnt++; + } + } + + { + mpfr_atanh(frw, frx, GMP_RNDN); + double u0 = countULPf128(t = vget(xatanhq_u10(a0), e), frw, 0); + + if (u0 > 0.7) { + printf(ISANAME " atanh arg=%s ulp=%.20g\n", sprintf128(q0), u0); + printf("test = %s\n", sprintf128(t)); + printf("corr = %s\n\n", sprintf128(mpfr_get_f128(frw, GMP_RNDN))); + fflush(stdout); ecnt++; + } + } + + { + mpfr_atan(frw, frx, GMP_RNDN); + double u0 = countULPf128(t = vget(xatanq_u10(a0), e), frw, 0); + + if (u0 > 0.8) { + printf(ISANAME " atan arg=%s ulp=%.20g\n", sprintf128(q0), u0); + printf("test = %s\n", sprintf128(t)); + printf("corr = %s\n\n", sprintf128(mpfr_get_f128(frw, GMP_RNDN))); + fflush(stdout); ecnt++; + } + } + + { + mpfr_atan2(frw, frx, fry, GMP_RNDN); + + double u0 = countULPf128(t = vget(xatan2q_u10(a0, a1), e), frw, 0); + + if (u0 > 0.8) { + printf(ISANAME " atan2 arg=%s %s ulp=%.20g\n", sprintf128(q0), sprintf128(q1), u0); + printf("test = %s\n", sprintf128(t)); + printf("corr = %s\n\n", sprintf128(mpfr_get_f128(frw, GMP_RNDN))); + fflush(stdout); ecnt++; + } + } + + q0 = rndf128(oneEMinus300Q, oneQ, 1); + a0 = vset(a0, e, q0); + mpfr_set_f128(frx, q0, GMP_RNDN); + + { + mpfr_asin(frw, frx, GMP_RNDN); + double u0 = countULPf128(t = vget(xasinq_u10(a0), e), frw, 0); + + if (u0 > 0.8) { + printf(ISANAME " asin arg=%s ulp=%.20g\n", sprintf128(q0), u0); + printf("test = %s\n", sprintf128(t)); + printf("corr = %s\n\n", sprintf128(mpfr_get_f128(frw, GMP_RNDN))); + fflush(stdout); ecnt++; + } + } + + { + mpfr_acos(frw, frx, GMP_RNDN); + double u0 = countULPf128(t = vget(xacosq_u10(a0), e), frw, 0); + + if (u0 > 0.8) { + printf(ISANAME " acos arg=%s ulp=%.20g\n", sprintf128(q0), u0); + printf("test = %s\n", sprintf128(t)); + printf("corr = %s\n\n", sprintf128(mpfr_get_f128(frw, GMP_RNDN))); + fflush(stdout); ecnt++; + } + } + +#if defined(ENABLEFLOAT128) + switch(cnt & 31) { + case 0: { + memrand(&q0, sizeof(__float128)); + q0 = q0 * M_PI_2Q; + } + break; + + case 1: { + int t; + memrand(&t, sizeof(int)); + t &= ~((~0UL) << (xrand() & 31)); + q0 = t * M_PI_2Q; + } + break; + + case 2: + q0 = rndf128x(); + break; + + default: + q0 = rndf128(1e-20, 1e+20, 1); + break; + } + + a0 = vset(a0, e, q0); + mpfr_set_f128(frx, q0, GMP_RNDN); +#endif + + { + mpfr_sin(frw, frx, GMP_RNDN); + double u0 = countULPf128(t = vget(xsinq_u10(a0), e), frw, 0); + + if (u0 > 0.8) { + printf(ISANAME " sin arg=%s ulp=%.20g\n", sprintf128(q0), u0); + printf("test = %s\n", sprintf128(t)); + printf("corr = %s\n\n", sprintf128(mpfr_get_f128(frw, GMP_RNDN))); + fflush(stdout); ecnt++; + } + } + + { + mpfr_cos(frw, frx, GMP_RNDN); + double u0 = countULPf128(t = vget(xcosq_u10(a0), e), frw, 0); + + if (u0 > 0.8) { + printf(ISANAME " cos arg=%s ulp=%.20g\n", sprintf128(q0), u0); + printf("test = %s\n", sprintf128(t)); + printf("corr = %s\n\n", sprintf128(mpfr_get_f128(frw, GMP_RNDN))); + fflush(stdout); ecnt++; + } + } + + { + mpfr_tan(frw, frx, GMP_RNDN); + double u0 = countULPf128(t = vget(xtanq_u10(a0), e), frw, 0); + + if (u0 > 0.8) { + printf(ISANAME " tan arg=%s ulp=%.20g\n", sprintf128(q0), u0); + printf("test = %s\n", sprintf128(t)); + printf("corr = %s\n\n", sprintf128(mpfr_get_f128(frw, GMP_RNDN))); + fflush(stdout); ecnt++; + } + } + } +} diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/quad-tester/tester3printf.c b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/quad-tester/tester3printf.c new file mode 100644 index 00000000000..58c5c8e20da --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/quad-tester/tester3printf.c @@ -0,0 +1,265 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include + +#include + +#include "sleefquad.h" + +static void convertEndianness(void *ptr, int len) { +#if defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) + for(int k=0;k 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 13) +#pragma GCC diagnostic ignored "-Wformat" +#pragma GCC diagnostic ignored "-Wformat-extra-args" + Sleef_registerPrintfHook(); + static char buf[110]; + Sleef_quad q = Sleef_strtoq("3.1415926535897932384626433832795028842", NULL); + + snprintf(buf, 100, "%50.40Pe", &q); + if (strcmp(buf, " 3.1415926535897932384626433832795027974791e+00") != 0) { + fprintf(stderr, "%%50.40Pe %s\n", buf); + exit(-1); + } + snprintf(buf, 100, "%50.40Pf", &q); + if (strcmp(buf, " 3.1415926535897932384626433832795027974791") != 0) { + fprintf(stderr, "%%50.40Pf %s\n", buf); + exit(-1); + } + snprintf(buf, 100, "%50.40Pg", &q); + if (strcmp(buf, " 3.141592653589793238462643383279502797479") != 0) { + fprintf(stderr, "%%50.40Pg %s\n", buf); + exit(-1); + } + snprintf(buf, 100, "%Pa", &q); + if (strcmp(buf, "0x1.921fb54442d18469898cc51701b8p+1") != 0) { + fprintf(stderr, "%%Pa %s\n", buf); + exit(-1); + } +#endif + + // + + FILE *fp = NULL; + + if (argc != 1) { + fp = fopen(argv[1], "r"); + if (fp == NULL) { + fprintf(stderr, "Could not open %s\n", argv[1]); + exit(-1); + } + } + + // + + static char *types[] = { "Pe", "Pf", "Pg", "Pa" }; + + static const char *strvals[] = { + "1.2345678912345678912345e+0Q", + "1.2345678912345678912345e+1Q", + "1.2345678912345678912345e-1Q", + "1.2345678912345678912345e+2Q", + "1.2345678912345678912345e-2Q", + "1.2345678912345678912345e+3Q", + "1.2345678912345678912345e-3Q", + "1.2345678912345678912345e+4Q", + "1.2345678912345678912345e-4Q", + "1.2345678912345678912345e+5Q", + "1.2345678912345678912345e-5Q", + "1.2345678912345678912345e+10Q", + "1.2345678912345678912345e-10Q", + "1.2345678912345678912345e+15Q", + "1.2345678912345678912345e-15Q", + "1.2345678912345678912345e+30Q", + "1.2345678912345678912345e-30Q", + "1.2345678912345678912345e+1000Q", + "1.2345678912345678912345e-1000Q", + "1.2345678912345678912345e-4950Q", + "1.2345678912345678912345e+4920Q", + "3.36210314311209350626267781732175260e-4932", + "1.18973149535723176508575932662800702e+4932", + "6.475175119438025110924438958227646552e-4966", + "0.0Q", "1.0Q", + "1e+1Q", "1e+2Q", "1e+3Q", "1e+4Q", "1e+5Q", "1e+6Q", + "1e-1Q", "1e-2Q", "1e-3Q", "1e-4Q", "1e-5Q", "1e-6Q", + "inf", "nan", + }; + Sleef_quad vals[sizeof(strvals) / sizeof(char *)]; + for(int i=0;i ${QUAD_HEADER_PARAMS_${SIMD}} > ${SIMD_SECTION_FILE} + DEPENDS qmkrename + ) +endforeach() + +file(MAKE_DIRECTORY ${sleef_BINARY_DIR}/include) +sleef_concat_files( + OUTPUT ${SLEEFQUAD_INCLUDE_HEADER} + SOURCES ${SLEEFQUAD_ORG_HEADER} ${SLEEF_HEADER_SIMD_SECTIONS} ${SLEEFQUAD_ORG_FOOTER} +) + +# -------------------------------------------------------------------- +# qmkrename +# qrenameXXX.h for each vector extension +# -------------------------------------------------------------------- +# Helper executable: generates parts of the sleef header file +add_host_executable(qmkrename qmkrename.c) +set_target_properties(qmkrename PROPERTIES ${COMMON_TARGET_PROPERTIES}) + +set(HEADER_FILES_GENERATED "") +foreach(SIMD ${SLEEF_SUPPORTED_QUAD_EXTENSIONS}) + if(COMPILER_SUPPORTS_${SIMD}) + string(TOLOWER ${SIMD} SIMDLC) + set(HEADER_${SIMD} ${CMAKE_CURRENT_BINARY_DIR}/include/qrename${SIMDLC}.h) + list(APPEND HEADER_FILES_GENERATED ${HEADER_${SIMD}}) + + # Generate qmkrename commands + add_custom_command(OUTPUT ${HEADER_${SIMD}} + COMMAND echo Generating qrename${vecarch}.h: qmkrename ${QUAD_RENAME_PARAMS_${SIMD}} + COMMAND $ ${QUAD_RENAME_PARAMS_${SIMD}} > ${HEADER_${SIMD}} + DEPENDS qmkrename + ) + add_custom_target(qrename${SIMD}.h_generated DEPENDS ${HEADER_${SIMD}}) + endif() +endforeach() + +# Generate qrenamecuda.h + +set(HEADER_CUDA ${CMAKE_CURRENT_BINARY_DIR}/include/qrenamecuda.h) +list(APPEND HEADER_FILES_GENERATED ${HEADER_CUDA}) +add_custom_command(OUTPUT ${HEADER_CUDA} + COMMAND echo Generating qrenamecuda.h: qmkrename ${QUAD_RENAME_PARAMS_CUDA} + COMMAND $ ${QUAD_RENAME_PARAMS_CUDA} > ${HEADER_CUDA} + DEPENDS qmkrename + ) +add_custom_target(qrenameCUDA.h_generated DEPENDS ${HEADER_CUDA}) + +# -------------------------------------------------------------------- +# sleefquad_headers +# -------------------------------------------------------------------- +add_custom_target(sleefquad_headers ALL + DEPENDS + ${SLEEFQUAD_INCLUDE_HEADER} + ${HEADER_FILES_GENERATED} +) + +# -------------------------------------------------------------------- +# libsleefquad +# -------------------------------------------------------------------- + +foreach(SIMD ${SLEEF_SUPPORTED_QUAD_EXTENSIONS}) + if(COMPILER_SUPPORTS_${SIMD}) + string(TOLOWER ${SIMD} SIMDLC) + set(OBJECT "sleefquad${SIMDLC}_obj") + add_library(${OBJECT} OBJECT sleefsimdqp.c ${HEADER_${SIMD}}) + + if(COMPILER_SUPPORTS_BUILTIN_MATH) + target_compile_definitions(${OBJECT} PRIVATE ENABLE_BUILTIN_MATH=1) + endif() + target_compile_definitions(${OBJECT} PRIVATE ENABLE_${SIMD}=1 DORENAME=1 ${COMMON_TARGET_DEFINITIONS}) + + set_target_properties(${OBJECT} PROPERTIES ${COMMON_TARGET_PROPERTIES}) + add_dependencies(${OBJECT} qrename${SIMD}.h_generated) + target_compile_options(${OBJECT} PRIVATE ${FLAGS_ENABLE_${SIMD}}) + + list(APPEND SLEEFQUAD_OBJECTS $) + endif() +endforeach() + +add_library(sleefquad rempitabqp.c ${SLEEFQUAD_OBJECTS}) + +set_target_properties(sleefquad PROPERTIES + VERSION ${SLEEF_VERSION} + SOVERSION ${SLEEF_SOVERSION} + PUBLIC_HEADER ${SLEEFQUAD_INCLUDE_HEADER} + ${COMMON_TARGET_PROPERTIES} +) + +set_target_properties(sleefquad PROPERTIES ${COMMON_TARGET_PROPERTIES}) + +if(LIBM AND ((NOT COMPILER_SUPPORTS_BUILTIN_MATH) OR (SLEEF_ARCH_32BIT AND SLEEF_ARCH_X86))) + target_link_libraries(sleefquad ${LIBM}) +endif() + +# -------------------------------------------------------------------- +# Inline headers +# -------------------------------------------------------------------- + +if(SLEEF_BUILD_INLINE_HEADERS) + if(CMAKE_C_COMPILER_ID MATCHES "Intel") + message(FATAL_ERROR "SLEEF_BUILD_INLINE_HEADERS is not supported with Intel Compiler") + endif() + + file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/include/) + set(INLINE_HEADER_FILES_GENERATED "") + + if (SED_COMMAND) + foreach(SIMD ${SLEEF_SUPPORTED_QUAD_EXTENSIONS} CUDA) + if(COMPILER_SUPPORTS_${SIMD} OR "${SIMD}" STREQUAL "CUDA") + string(TOLOWER ${SIMD} SIMDLC) + + if(CMAKE_CROSSCOMPILING AND CMAKE_C_COMPILER_ID MATCHES "Clang" AND CMAKE_C_COMPILER_TARGET AND NOT "${SIMD}" STREQUAL "CUDA" ) + set(FLAG_TARGET --target=${CMAKE_C_COMPILER_TARGET}) + endif() + + if ("${SIMD}" STREQUAL "CUDA") + set(TARGET_PP_FLAGS ${FLAG_DEFINE}SLEEF_ALWAYS_INLINE=__device__ + ${FLAG_DEFINE}SLEEF_INLINE=__device__ + ${FLAG_DEFINE}SLEEF_CONST=__device__ + ${FLAG_DEFINE}static=__device__) + set(INLINE_HEADER_ORG ${CMAKE_CURRENT_SOURCE_DIR}/sleefquadinline_cuda_header.h.org) + # Remove redundant __device__ + set(TARGET_REPLACEMENTS -e "s/__device__ __device__/__device__/g" -e "s/__device__ __device__/__device__/g") + set(TARGET_ADDSUFFIX_KEYWORDS double2 double3 float2) + else() + set(TARGET_ADDSUFFIX_KEYWORDS Sleef_rempitabqp) + set(INLINE_HEADER_ORG ${CMAKE_CURRENT_SOURCE_DIR}/sleefquadinline_header.h.org) + endif() + + + set(INLINE_HEADER_FILE ${PROJECT_BINARY_DIR}/include/sleefquadinline_${SIMDLC}.h) + add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp1 + + # Preprocess sleefsimddp.c with SLEEF_GENHEADER defined, comments are preserved + COMMAND "${CMAKE_C_COMPILER}" ${FLAG_PREPROCESS} ${FLAG_PRESERVE_COMMENTS} # gcc -E -C + ${FLAG_TARGET} ${FLAGS_ENABLE_${SIMD}} # -msse2 + ${FLAG_INCLUDE}${PROJECT_SOURCE_DIR}/src/common ${FLAG_INCLUDE}${PROJECT_SOURCE_DIR}/src/arch # -I/sleef/src/common -I/sleef/src/arch + ${FLAG_INCLUDE}${CMAKE_CURRENT_BINARY_DIR}/include/ # -I/build/src/quad/include + ${FLAG_DEFINE}SLEEF_GENHEADER ${FLAG_DEFINE}ENABLE_${SIMD} ${FLAG_DEFINE}DORENAME # -DSLEEF_GENHEADER -DENABLE_SSE2 -DDORENAME + ${TARGET_PP_FLAGS} + ${CMAKE_CURRENT_SOURCE_DIR}/sleefsimdqp.c > ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp1 # /sleef/src/quad/sleefsimdqp.c > /build/quad/sleefSSE2.h.qtmp1 + + # ${HEADER_${SIMD}} listed here as sleefsimdqp.c includes it for renaming + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/sleefsimdqp.c ${HEADER_${SIMD}} + ) + + add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/include/qmacroonly${SIMD}.h + + # Remove all lines except those begin with "//@", then remove "//@" + COMMAND ${SED_COMMAND} -e "/^\\/\\/@#.*$/!d" -e "s/^\\/\\/@#/#/g" + ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp1 + > ${CMAKE_CURRENT_BINARY_DIR}/include/qmacroonly${SIMD}.h + + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp1 + VERBATIM + ) + + add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/sleefquad${SIMD}.h.c + + # Remove lines beginning with "#" so that the resulting file can be preprocessed again. + COMMAND ${SED_COMMAND} -e "s/^#.*//g" ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp1 # sed -e "s/^#.*//g" /build/src/quad/sleefSSE2.h.qtmp1 + > ${CMAKE_CURRENT_BINARY_DIR}/sleefquad${SIMD}.h.c # > /build/src/quad/sleefquadSSE2.h.c + + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp1 + VERBATIM + ) + + add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp2 + + # Preprocess the intemediate file again to remove comments + COMMAND "${CMAKE_C_COMPILER}" ${FLAG_PREPROCESS} # gcc -E + ${CMAKE_CURRENT_BINARY_DIR}/sleefquad${SIMD}.h.c # /build/src/quad/sleefquadSSE2.h.c + # Remove lines beginning with "#" + | ${SED_COMMAND} -e "s/^#.*//g" + > ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp2 # > /build/src/quad/sleefSSE2.h.qtmp2 + + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/sleefquad${SIMD}.h.c ${CMAKE_CURRENT_BINARY_DIR}/include/qmacroonly${SIMD}.h + VERBATIM + ) + + add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp4 + + COMMAND ${CMAKE_COMMAND} -E cat + ${INLINE_HEADER_ORG} + ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp2 + | ${SED_COMMAND} + # Embed version number into the header + -e "s/SLEEF_VERSION_SLEEF/${SLEEF_VERSION_MAJOR}.${SLEEF_VERSION_MINOR}.${SLEEF_VERSION_PATCH}/g" # "s/SLEEF_VERSION_SLEEF/3.5.0/g" + -e "s/SLEEF_SIMD_SLEEF/${SIMD}/g" # -e "s/SLEEF_SIMD_SLEEF/SSE2/g" + # Substitute "SLEEFSHARP" at the beginning of line with "#" + -e "s/^SLEEFSHARP/#/g" + # Remove SLEEFXXX + -e "s/SLEEFXXX//g" + # Replace multiple empty lines with a single empty line (part 1) + -e "s/^[[:space:]]*$//g" + > ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp4 + + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/sleefquadinline_header.h.org ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp2 + VERBATIM + ) + + add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp8 + + # Replace multiple empty lines with a single empty line + # (part 2 - cannot occur in same command as part 1) + COMMAND ${SED_COMMAND} -e "/^$/N" -e "/^\\n$/D" ${TARGET_REPLACEMENTS} + ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp4 + > ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp8 + + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp4 + VERBATIM + ) + + add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp9 + + COMMAND $ ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp8 # addSuffix /build/src/quad/sleefSSE2.h.qtmp8 + ${sleef_SOURCE_DIR}/src/common/keywords.txt "_${SIMDLC}_sleefq" # keywords.txt "_sse2_sleefq" + ${TARGET_ADDSUFFIX_KEYWORDS} # Sleef_rempitabdp Sleef_rempitabsp + > ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp9 + + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp8 ${sleef_SOURCE_DIR} addSuffix + ) + + sleef_concat_files( + OUTPUT ${INLINE_HEADER_FILE} + SOURCES ${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp9 ${CMAKE_CURRENT_SOURCE_DIR}/sleefquadinline_footer.h.org + ) + + list(APPEND INLINE_HEADER_FILES_GENERATED ${INLINE_HEADER_FILE}) + endif(COMPILER_SUPPORTS_${SIMD} OR "${SIMD}" STREQUAL "CUDA") + endforeach() + + add_custom_target(${TARGET_QINLINE_HEADERS} ALL + DEPENDS + ${INLINE_HEADER_FILES_GENERATED} + ) + install( + FILES ${INLINE_HEADER_FILES_GENERATED} + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" + COMPONENT sleef_Development + ) + endif(SED_COMMAND) +endif(SLEEF_BUILD_INLINE_HEADERS) + + +# -------------------------------------------------------------------- +# qmkdisp +# -------------------------------------------------------------------- +add_host_executable(qmkdisp qmkdisp.c) +set_target_properties(qmkdisp PROPERTIES ${COMMON_TARGET_PROPERTIES}) + +# Target qdispscalar.c + +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/qdispscalar.c.body + COMMAND $ 1 Sleef_quad double int32_t int64_t uint64_t purec purecfma > ${CMAKE_CURRENT_BINARY_DIR}/qdispscalar.c.body + DEPENDS qmkdisp + ) +sleef_concat_files( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/qdispscalar.c + SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/qdispscalar.c.org ${CMAKE_CURRENT_BINARY_DIR}/qdispscalar.c.body + ) + +add_custom_target(qdispscalar.c_generated SOURCES ${CMAKE_CURRENT_BINARY_DIR}/qdispscalar.c) + +# Target renamedspscalar.h + +add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/include/qrenamedspscalar.h + COMMAND $ 1 > ${CMAKE_CURRENT_BINARY_DIR}/include/qrenamedspscalar.h + DEPENDS qmkrename + ) +add_custom_target(qrenamedspscalar.h_generated SOURCES ${CMAKE_CURRENT_BINARY_DIR}/include/qrenamedspscalar.h) + +# Target qdispscalar_obj + +add_library(qdispscalar_obj OBJECT qdispscalar.c) +set_target_properties(qdispscalar_obj PROPERTIES ${COMMON_TARGET_PROPERTIES}) +target_compile_definitions(qdispscalar_obj PRIVATE ${COMMON_TARGET_DEFINITIONS}) +target_include_directories(qdispscalar_obj PRIVATE ${sleef_BINARY_DIR}/include) +add_dependencies(qdispscalar_obj qdispscalar.c_generated qrenamedspscalar.h_generated + sleefquad_headers ${TARGET_LIBSLEEF} ${TARGET_HEADERS}) +target_sources(sleefquad PRIVATE $) + +if(DEFINED QMKDISP_PARAMS_X2) + # Target qdispx2.c + + add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/qdispx2.c.body + COMMAND $ ${QMKDISP_PARAMS_X2} > ${CMAKE_CURRENT_BINARY_DIR}/qdispx2.c.body + DEPENDS qmkdisp + ) + sleef_concat_files( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/qdispx2.c + SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/qdispx2.c.org ${CMAKE_CURRENT_BINARY_DIR}/qdispx2.c.body + ) + add_custom_target(qdispx2.c_generated SOURCES ${CMAKE_CURRENT_BINARY_DIR}/qdispx2.c) + + # Target renamedspx2.h + + add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/include/qrenamedspx2.h + COMMAND $ 2 > ${CMAKE_CURRENT_BINARY_DIR}/include/qrenamedspx2.h + DEPENDS qmkrename + ) + add_custom_target(qrenamedspx2.h_generated SOURCES ${CMAKE_CURRENT_BINARY_DIR}/include/qrenamedspx2.h) + + # Target qdispx2_obj + + add_library(qdispx2_obj OBJECT qdispx2.c) + + if(SLEEF_ARCH_X86) + if (COMPILER_SUPPORTS_AVX2) + set(DISPATCHER_DEFINITIONS ${DISPATCHER_DEFINITIONS} ENABLE_AVX2=1) + endif() + endif() + + if(SLEEF_ARCH_PPC64) + target_compile_options(qdispx2_obj PRIVATE ${FLAGS_ENABLE_VSX}) + if (COMPILER_SUPPORTS_VSX3) + set(DISPATCHER_DEFINITIONS ${DISPATCHER_DEFINITIONS} ENABLE_VSX3=1) + endif() + endif() + + if(SLEEF_ARCH_S390X) + target_compile_options(qdispx2_obj PRIVATE ${FLAGS_ENABLE_VXE}) + if (COMPILER_SUPPORTS_VXE2) + set(DISPATCHER_DEFINITIONS ${DISPATCHER_DEFINITIONS} ENABLE_VXE2=1) + endif() + endif() + + set_target_properties(qdispx2_obj PROPERTIES ${COMMON_TARGET_PROPERTIES}) + target_compile_definitions(qdispx2_obj PRIVATE ${COMMON_TARGET_DEFINITIONS} ${DISPATCHER_DEFINITIONS}) + target_include_directories(qdispx2_obj PRIVATE ${sleef_BINARY_DIR}/include) + add_dependencies(qdispx2_obj qdispx2.c_generated qrenamedspx2.h_generated + sleefquad_headers ${TARGET_LIBSLEEF} ${TARGET_HEADERS}) + target_sources(sleefquad PRIVATE $) +endif(DEFINED QMKDISP_PARAMS_X2) + +# -------------------------------------------------------------------- +# Install +# -------------------------------------------------------------------- +# Install libsleef and sleef.h +install( + TARGETS sleefquad + EXPORT sleefTargets + PUBLIC_HEADER # + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" + COMPONENT sleef_Development + LIBRARY # + DESTINATION "${CMAKE_INSTALL_LIBDIR}" + COMPONENT sleef_Runtime + NAMELINK_COMPONENT sleef_Development + ARCHIVE # + DESTINATION "${CMAKE_INSTALL_LIBDIR}" + COMPONENT sleef_Development + RUNTIME # + DESTINATION "${CMAKE_INSTALL_BINDIR}" + COMPONENT sleef_Runtime + INCLUDES # + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" +) diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/quad/qdispatcher.h b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/quad/qdispatcher.h new file mode 100644 index 00000000000..67032ce597c --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/quad/qdispatcher.h @@ -0,0 +1,154 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#if (defined (__GNUC__) || defined (__clang__) || defined(__INTEL_COMPILER)) && !defined(_MSC_VER) +#define CONST __attribute__((const)) +#else +#define CONST +#endif + +#if defined(_MSC_VER) || defined(__MINGW32__) || defined(__MINGW64__) +static jmp_buf sigjmp; +#define SETJMP(x) setjmp(x) +#define LONGJMP longjmp +#else +static sigjmp_buf sigjmp; +#define SETJMP(x) sigsetjmp(x, 1) +#define LONGJMP siglongjmp +#endif + +static void sighandler(int signum) { + LONGJMP(sigjmp, 1); +} + +static int cpuSupportsExt(void (*tryExt)()) { + static int cache = -1; + if (cache != -1) return cache; + + void (*org); + org = signal(SIGILL, sighandler); + + if (SETJMP(sigjmp) == 0) { + (*tryExt)(); + cache = 1; + } else { + cache = 0; + } + + signal(SIGILL, org); + return cache; +} + +#define DISPATCH_vq_vq(qtype, funcName, pfn, dfn, funcExt0, funcExt1) \ + static CONST VECTOR_CC qtype (*pfn)(qtype arg0); \ + static CONST VECTOR_CC qtype dfn(qtype arg0) { \ + qtype CONST VECTOR_CC (*p)(qtype arg0) = funcExt0; \ + SUBST_IF_EXT1(funcExt1); \ + pfn = p; \ + return (*pfn)(arg0); \ + } \ + static CONST VECTOR_CC qtype (*pfn)(qtype arg0) = dfn; \ + EXPORT CONST VECTOR_CC qtype funcName(qtype arg0) { return (*pfn)(arg0); } + +#define DISPATCH_vq_vq_vq(qtype, funcName, pfn, dfn, funcExt0, funcExt1) \ + static CONST VECTOR_CC qtype (*pfn)(qtype arg0, qtype arg1); \ + static CONST VECTOR_CC qtype dfn(qtype arg0, qtype arg1) { \ + qtype CONST VECTOR_CC (*p)(qtype arg0, qtype arg1) = funcExt0; \ + SUBST_IF_EXT1(funcExt1); \ + pfn = p; \ + return (*pfn)(arg0, arg1); \ + } \ + static CONST VECTOR_CC qtype (*pfn)(qtype arg0, qtype arg1) = dfn; \ + EXPORT CONST VECTOR_CC qtype funcName(qtype arg0, qtype arg1) { return (*pfn)(arg0, arg1); } + +#define DISPATCH_vq_vq_vq_vq(qtype, funcName, pfn, dfn, funcExt0, funcExt1) \ + static CONST VECTOR_CC qtype (*pfn)(qtype arg0, qtype arg1, qtype arg2); \ + static CONST VECTOR_CC qtype dfn(qtype arg0, qtype arg1, qtype arg2) { \ + qtype CONST VECTOR_CC (*p)(qtype arg0, qtype arg1, qtype arg2) = funcExt0; \ + SUBST_IF_EXT1(funcExt1); \ + pfn = p; \ + return (*pfn)(arg0, arg1, arg2); \ + } \ + static CONST VECTOR_CC qtype (*pfn)(qtype arg0, qtype arg1, qtype arg2) = dfn; \ + EXPORT CONST VECTOR_CC qtype funcName(qtype arg0, qtype arg1, qtype arg2) { return (*pfn)(arg0, arg1, arg2); } + +#define DISPATCH_vq_vq_vx(qtype, xtype, funcName, pfn, dfn, funcExt0, funcExt1) \ + static CONST VECTOR_CC qtype (*pfn)(qtype arg0, xtype arg1); \ + static CONST VECTOR_CC qtype dfn(qtype arg0, xtype arg1) { \ + qtype CONST VECTOR_CC (*p)(qtype arg0, xtype arg1) = funcExt0; \ + SUBST_IF_EXT1(funcExt1); \ + pfn = p; \ + return (*pfn)(arg0, arg1); \ + } \ + static CONST VECTOR_CC qtype (*pfn)(qtype arg0, xtype arg1) = dfn; \ + EXPORT CONST VECTOR_CC qtype funcName(qtype arg0, xtype arg1) { return (*pfn)(arg0, arg1); } + +#define DISPATCH_vq_vq_pvx(qtype, xtype, funcName, pfn, dfn, funcExt0, funcExt1) \ + static VECTOR_CC qtype (*pfn)(qtype arg0, xtype *arg1); \ + static VECTOR_CC qtype dfn(qtype arg0, xtype *arg1) { \ + qtype VECTOR_CC (*p)(qtype arg0, xtype *arg1) = funcExt0; \ + SUBST_IF_EXT1(funcExt1); \ + pfn = p; \ + return (*pfn)(arg0, arg1); \ + } \ + static VECTOR_CC qtype (*pfn)(qtype arg0, xtype *arg1) = dfn; \ + EXPORT VECTOR_CC qtype funcName(qtype arg0, xtype *arg1) { return (*pfn)(arg0, arg1); } + +#define DISPATCH_vq_vx(qtype, xtype, funcName, pfn, dfn, funcExt0, funcExt1) \ + static CONST VECTOR_CC qtype (*pfn)(xtype arg0); \ + static CONST VECTOR_CC qtype dfn(xtype arg0) { \ + qtype CONST VECTOR_CC (*p)(xtype arg0) = funcExt0; \ + SUBST_IF_EXT1(funcExt1); \ + pfn = p; \ + return (*pfn)(arg0); \ + } \ + static CONST VECTOR_CC qtype (*pfn)(xtype arg0) = dfn; \ + EXPORT CONST VECTOR_CC qtype funcName(xtype arg0) { return (*pfn)(arg0); } + +#define DISPATCH_vx_vq(qtype, xtype, funcName, pfn, dfn, funcExt0, funcExt1) \ + static CONST VECTOR_CC xtype (*pfn)(qtype arg0); \ + static CONST VECTOR_CC xtype dfn(qtype arg0) { \ + xtype CONST VECTOR_CC (*p)(qtype arg0) = funcExt0; \ + SUBST_IF_EXT1(funcExt1); \ + pfn = p; \ + return (*pfn)(arg0); \ + } \ + static CONST VECTOR_CC xtype (*pfn)(qtype arg0) = dfn; \ + EXPORT CONST VECTOR_CC xtype funcName(qtype arg0) { return (*pfn)(arg0); } + +#define DISPATCH_vx_vq_vq(qtype, xtype, funcName, pfn, dfn, funcExt0, funcExt1) \ + static CONST VECTOR_CC xtype (*pfn)(qtype arg0, qtype arg1); \ + static CONST VECTOR_CC xtype dfn(qtype arg0, qtype arg1) { \ + xtype CONST VECTOR_CC (*p)(qtype arg0, qtype arg1) = funcExt0; \ + SUBST_IF_EXT1(funcExt1); \ + pfn = p; \ + return (*pfn)(arg0, arg1); \ + } \ + static CONST VECTOR_CC xtype (*pfn)(qtype arg0, qtype arg1) = dfn; \ + EXPORT CONST VECTOR_CC xtype funcName(qtype arg0, qtype arg1) { return (*pfn)(arg0, arg1); } + +#define DISPATCH_q_vq_vx(qtype, xtype, funcName, pfn, dfn, funcExt0, funcExt1) \ + static CONST VECTOR_CC Sleef_quad (*pfn)(qtype arg0, xtype arg1); \ + static CONST VECTOR_CC Sleef_quad dfn(qtype arg0, xtype arg1) { \ + Sleef_quad CONST VECTOR_CC (*p)(qtype arg0, xtype arg1) = funcExt0; \ + SUBST_IF_EXT1(funcExt1); \ + pfn = p; \ + return (*pfn)(arg0, arg1); \ + } \ + static CONST VECTOR_CC Sleef_quad (*pfn)(qtype arg0, xtype arg1) = dfn; \ + EXPORT CONST VECTOR_CC Sleef_quad funcName(qtype arg0, xtype arg1) { return (*pfn)(arg0, arg1); } + +#define DISPATCH_vq_vq_vi_q(qtype, xtype, funcName, pfn, dfn, funcExt0, funcExt1) \ + static CONST VECTOR_CC qtype (*pfn)(qtype arg0, xtype arg1, Sleef_quad arg2); \ + static CONST VECTOR_CC qtype dfn(qtype arg0, xtype arg1, Sleef_quad arg2) { \ + qtype CONST VECTOR_CC (*p)(qtype arg0, xtype arg1, Sleef_quad arg2) = funcExt0; \ + SUBST_IF_EXT1(funcExt1); \ + pfn = p; \ + return (*pfn)(arg0, arg1, arg2); \ + } \ + static CONST VECTOR_CC qtype (*pfn)(qtype arg0, xtype arg1, Sleef_quad arg2) = dfn; \ + EXPORT CONST VECTOR_CC qtype funcName(qtype arg0, xtype arg1, Sleef_quad arg2) { return (*pfn)(arg0, arg1, arg2); } + +// diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/quad/qdispscalar.c.org b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/quad/qdispscalar.c.org new file mode 100644 index 00000000000..cc2b89133f5 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/quad/qdispscalar.c.org @@ -0,0 +1,23 @@ +// Copyright Naoki Shibata and contributors 2010 - 2023. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include + +#include "misc.h" + +#define SLEEF_IMPORT_IS_EXPORT +#include "sleefquad.h" + +#include "qdispatcher.h" + +NOEXPORT Sleef_quad sleef_cpuid_QUADFMA_0; +static void tryFMA() { sleef_cpuid_QUADFMA_0 = Sleef_sinq1_u10purecfma(sleef_cpuid_QUADFMA_0); } + +#define SUBST_IF_EXT1(funcExt1) if (cpuSupportsExt(tryFMA)) p = funcExt1; + +// diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/quad/qdispx2.c.org b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/quad/qdispx2.c.org new file mode 100644 index 00000000000..3ee64a5702d --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/quad/qdispx2.c.org @@ -0,0 +1,39 @@ +// Copyright Naoki Shibata and contributors 2010 - 2023. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include + +#include "misc.h" + +#define SLEEF_IMPORT_IS_EXPORT +#include "sleefquad.h" + +#include "qdispatcher.h" + +NOEXPORT Sleef_quadx2 sleef_cpuid_EXT; + +#ifdef ENABLE_AVX2 +static void tryEXT1() { sleef_cpuid_EXT = Sleef_sinq2_u10avx2128(sleef_cpuid_EXT); } +#define SUBST_IF_EXT1(funcExt1) if (cpuSupportsExt(tryEXT1)) p = funcExt1; +#endif + +#ifdef ENABLE_VSX3 +static void tryEXT1() { sleef_cpuid_EXT = Sleef_sinq2_u10vsx3(sleef_cpuid_EXT); } +#define SUBST_IF_EXT1(funcExt1) if (cpuSupportsExt(tryEXT1)) p = funcExt1; +#endif + +#ifdef ENABLE_VXE2 +static void tryEXT1() { sleef_cpuid_EXT = Sleef_sinq2_u10vxe2(sleef_cpuid_EXT); } +#define SUBST_IF_EXT1(funcExt1) if (cpuSupportsExt(tryEXT1)) p = funcExt1; +#endif + +#ifndef SUBST_IF_EXT1 +#define SUBST_IF_EXT1(funcExt1) +#endif + +// diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/quad/qfuncproto.h b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/quad/qfuncproto.h new file mode 100644 index 00000000000..d52e8f8b937 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/quad/qfuncproto.h @@ -0,0 +1,130 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +typedef struct { + char *name; + int ulp; + int ulpSuffix; + int funcType; + int flags; +} funcSpec; + +/* + ulp : (error bound in ulp) * 10 + + ulpSuffix: + 0 : "" + 1 : "_u10" + 2 : "_u05" + + funcType: + 0 : vargquad func(vargquad); + 1 : vargquad func(vargquad, vargquad); + 2 : vargquad2 func(vargquad); + 3 : vargquad func(vargquad, vint); + 4 : vint func(vargquad); + 5 : vargquad func(vargquad, vargquad, vargquad); + 6 : vargquad2 func(vargquad); + 7 : int func(int); + 8 : void *func(int); + 9 : vint func(vargquad, vargquad); + 10 : vdouble func(vargquad); + 11 : vargquad func(vdouble); + 12 : vargquad func(Sleef_quad); + 13 : vargquad func(vint, Sleef_quad, Sleef_quad); + 14 : vargquad func(Sleef_quad *); + 15 : void func(Sleef_quad *, vargquad); + 16 : Sleef_quad func(vargquad, int); + 17 : vargquad func(vargquad, int, Sleef_quad); + 18 : vint64 func(vargquad); + 19 : vargquad func(vint64); + 20 : vuint64 func(vargquad); + 21 : vargquad func(vuint64); + 22 : vargquad func(vargquad, vint *); + 23 : vargquad func(vargquad, vargquad *); + */ + +funcSpec funcList[] = { + { "add", 5, 2, 1, 0 }, + { "sub", 5, 2, 1, 0 }, + { "mul", 5, 2, 1, 0 }, + { "div", 5, 2, 1, 0 }, + { "neg", -1, 0, 0, 0 }, + { "sqrt", 5, 2, 0, 0 }, + { "cbrt", 10, 1, 0, 0 }, + + { "icmplt", -1, 0, 9, 0 }, + { "icmple", -1, 0, 9, 0 }, + { "icmpgt", -1, 0, 9, 0 }, + { "icmpge", -1, 0, 9, 0 }, + { "icmpeq", -1, 0, 9, 0 }, + { "icmpne", -1, 0, 9, 0 }, + { "icmp" , -1, 0, 9, 0 }, + { "iunord", -1, 0, 9, 0 }, + { "iselect", -1, 0, 13, 0 }, + + { "cast_to_double", -1, 0, 10, 0 }, + { "cast_from_double", -1, 0, 11, 0 }, + { "cast_to_int64", -1, 0, 18, 0 }, + { "cast_from_int64", -1, 0, 19, 0 }, + { "cast_to_uint64", -1, 0, 20, 0 }, + { "cast_from_uint64", -1, 0, 21, 0 }, + { "load", -1, 0, 14, 0 }, + { "store", -1, 0, 15, 0 }, + { "get", -1, 0, 16, 0 }, + { "set", -1, 0, 17, 0 }, + { "splat", -1, 0, 12, 0 }, + + { "sin", 10, 1, 0, 0 }, + { "cos", 10, 1, 0, 0 }, + { "tan", 10, 1, 0, 0 }, + + { "asin", 10, 1, 0, 0 }, + { "acos", 10, 1, 0, 0 }, + { "atan", 10, 1, 0, 0 }, + { "atan2", 10, 1, 1, 0 }, + + { "exp", 10, 1, 0, 0 }, + { "exp2", 10, 1, 0, 0 }, + { "exp10", 10, 1, 0, 0 }, + { "expm1", 10, 1, 0, 0 }, + + { "log", 10, 1, 0, 0 }, + { "log2", 10, 1, 0, 0 }, + { "log10", 10, 1, 0, 0 }, + { "log1p", 10, 1, 0, 0 }, + + { "pow", 10, 1, 1, 0 }, + + { "sinh", 10, 1, 0, 0 }, + { "cosh", 10, 1, 0, 0 }, + { "tanh", 10, 1, 0, 0 }, + + { "asinh", 10, 1, 0, 0 }, + { "acosh", 10, 1, 0, 0 }, + { "atanh", 10, 1, 0, 0 }, + + { "trunc", -1, 0, 0, 0 }, + { "floor", -1, 0, 0, 0 }, + { "ceil", -1, 0, 0, 0 }, + { "round", -1, 0, 0, 0 }, + { "rint", -1, 0, 0, 0 }, + + { "fabs", -1, 0, 0, 0 }, + { "copysign", -1, 0, 1, 0 }, + { "fmax", -1, 0, 1, 0 }, + { "fmin", -1, 0, 1, 0 }, + { "fdim", 5, 2, 1, 0 }, + { "fmod", -1, 0, 1, 0 }, + { "remainder", -1, 0, 1, 0 }, + { "frexp", -1, 0, 22, 0 }, + { "modf", -1, 0, 23, 0 }, + { "hypot", 5, 2, 1, 0 }, + { "ldexp", -1, 0, 3, 0 }, + { "ilogb", -1, 0, 4, 0 }, + { "fma", 5, 2, 5, 0 }, + + { NULL, -1, 0, 0, 0 }, +}; diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/quad/qmkdisp.c b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/quad/qmkdisp.c new file mode 100644 index 00000000000..91a9effed3d --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/quad/qmkdisp.c @@ -0,0 +1,206 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include + +#include "qfuncproto.h" + +int main(int argc, char **argv) { + if (argc < 7) { + fprintf(stderr, "Usage : %s [ ...]\n", argv[0]); + fprintf(stderr, "\n"); + exit(-1); + } + + const int wdp = atoi(argv[1]); + const char *vquadname = argv[2], *vdoublename = argv[3]; + const char *vintname = argv[4], *vint64name = argv[5], *vuint64name = argv[6]; + const int isastart = 7, nisa = argc - isastart; + + for(int i=0;funcList[i].name != NULL;i++) { + char ulpSuffix0[100] = "", ulpSuffix1[100] = "_"; + if (funcList[i].ulp >= 0) { + sprintf(ulpSuffix0, "_u%02d", funcList[i].ulp); + sprintf(ulpSuffix1, "_u%02d", funcList[i].ulp); + } + + switch(funcList[i].funcType) { + case 0: + printf("DISPATCH_vq_vq(%s, Sleef_%sq%d%s, pnt_%sq%d%s, disp_%sq%d%s", + vquadname, + funcList[i].name, wdp, ulpSuffix0, + funcList[i].name, wdp, ulpSuffix0, + funcList[i].name, wdp, ulpSuffix0); + for(int j=0;j +#include +#include +#include +#include + +#include "qfuncproto.h" + +int main(int argc, char **argv) { + if (argc < 2) { + fprintf(stderr, "Generate a header for renaming functions\n"); + fprintf(stderr, "Usage : %s []\n", argv[0]); + fprintf(stderr, "\n"); + + fprintf(stderr, "Generate a part of header for library functions\n"); + fprintf(stderr, "Usage : %s []\n", argv[0]); + fprintf(stderr, "\n"); + + exit(-1); + } + + static char *ulpSuffixStr[] = { "", "_u10", "_u05" }; + + if (argc == 2 || argc == 3) { + char *wqp = argv[1]; + char *isaname = argc == 2 ? "" : argv[2]; + char *isaub = argc == 3 ? "_" : ""; + + if (strcmp(isaname, "sve") == 0) wqp = "x"; + + for(int i=0;funcList[i].name != NULL;i++) { + if (funcList[i].ulp >= 0) { + printf("#define x%sq%s Sleef_%sq%s_u%02d%s\n", + funcList[i].name, ulpSuffixStr[funcList[i].ulpSuffix], + funcList[i].name, wqp, + funcList[i].ulp, isaname); + } else { + printf("#define x%sq Sleef_%sq%s%s%s\n", funcList[i].name, funcList[i].name, wqp, isaub, isaname); + } + } + } else { + char *wqp = argv[1]; + char *vargquadname = argv[2]; + char *vargquad2name = argv[3]; + char *vdoublename = argv[4]; + //char *vfloatname = argv[5]; + //char *vmaskname = argv[6]; + char *vintname = argv[7]; + char *vint64name = argv[8]; + char *vuint64name = argv[9]; + char *architecture = argv[10]; + char *isaname = argc == 12 ? argv[11] : ""; + char *isaub = argc == 12 ? "_" : ""; + + if (strcmp(isaname, "sve") == 0) wqp = "x"; + + printf("#ifdef %s\n", architecture); + + if (strcmp(vargquadname, "-") != 0) { + for(int i=0;funcList[i].name != NULL;i++) { + switch(funcList[i].funcType) { + case 0: + if (funcList[i].ulp >= 0) { + printf("SLEEF_IMPORT SLEEF_CONST %s Sleef_%sq%s_u%02d%s(%s);\n", + vargquadname, + funcList[i].name, wqp, + funcList[i].ulp, isaname, + vargquadname); + } else { + printf("SLEEF_IMPORT SLEEF_CONST %s Sleef_%sq%s%s%s(%s);\n", + vargquadname, + funcList[i].name, wqp, + isaub, isaname, + vargquadname); + } + break; + case 1: + if (funcList[i].ulp >= 0) { + printf("SLEEF_IMPORT SLEEF_CONST %s Sleef_%sq%s_u%02d%s(%s, %s);\n", + vargquadname, + funcList[i].name, wqp, + funcList[i].ulp, isaname, + vargquadname, vargquadname); + } else { + printf("SLEEF_IMPORT SLEEF_CONST %s Sleef_%sq%s%s%s(%s, %s);\n", + vargquadname, + funcList[i].name, wqp, + isaub, isaname, + vargquadname, vargquadname); + } + break; + case 2: + case 6: + if (funcList[i].ulp >= 0) { + printf("SLEEF_IMPORT SLEEF_CONST %s Sleef_%sq%s_u%02d%s(%s);\n", + vargquad2name, + funcList[i].name, wqp, + funcList[i].ulp, isaname, + vargquadname); + } else { + printf("SLEEF_IMPORT SLEEF_CONST %s Sleef_%sq%s%s%s(%s);\n", + vargquad2name, + funcList[i].name, wqp, + isaub, isaname, + vargquadname); + } + break; + case 3: + if (funcList[i].ulp >= 0) { + printf("SLEEF_IMPORT SLEEF_CONST %s Sleef_%sq%s_u%02d%s(%s, %s);\n", + vargquadname, + funcList[i].name, wqp, + funcList[i].ulp, isaname, + vargquadname, vintname); + } else { + printf("SLEEF_IMPORT SLEEF_CONST %s Sleef_%sq%s%s%s(%s, %s);\n", + vargquadname, + funcList[i].name, wqp, + isaub, isaname, + vargquadname, vintname); + } + break; + case 4: + if (funcList[i].ulp >= 0) { + printf("SLEEF_IMPORT SLEEF_CONST %s Sleef_%sq%s_u%02d%s(%s);\n", + vintname, + funcList[i].name, wqp, + funcList[i].ulp, isaname, + vargquadname); + } else { + printf("SLEEF_IMPORT SLEEF_CONST %s Sleef_%sq%s%s%s(%s);\n", + vintname, + funcList[i].name, wqp, + isaub, isaname, + vargquadname); + } + break; + case 5: + if (funcList[i].ulp >= 0) { + printf("SLEEF_IMPORT SLEEF_CONST %s Sleef_%sq%s_u%02d%s(%s, %s, %s);\n", + vargquadname, + funcList[i].name, wqp, + funcList[i].ulp, isaname, + vargquadname, vargquadname, vargquadname); + } else { + printf("SLEEF_IMPORT SLEEF_CONST %s Sleef_%sq%s%s%s(%s, %s, %s);\n", + vargquadname, + funcList[i].name, wqp, + isaub, isaname, + vargquadname, vargquadname, vargquadname); + } + break; + case 7: + printf("SLEEF_IMPORT SLEEF_CONST int Sleef_%sq%s%s%s(int);\n", funcList[i].name, wqp, isaub, isaname); + break; + case 8: + printf("SLEEF_IMPORT SLEEF_CONST void *Sleef_%sq%s%s%s(int);\n", funcList[i].name, wqp, isaub, isaname); + break; + case 9: + if (funcList[i].ulp >= 0) { + printf("SLEEF_IMPORT SLEEF_CONST %s Sleef_%sq%s_u%02d%s(%s, %s);\n", + vintname, + funcList[i].name, wqp, + funcList[i].ulp, isaname, + vargquadname, vargquadname); + } else { + printf("SLEEF_IMPORT SLEEF_CONST %s Sleef_%sq%s%s%s(%s, %s);\n", + vintname, + funcList[i].name, wqp, + isaub, isaname, + vargquadname, vargquadname); + } + break; + case 10: + if (funcList[i].ulp >= 0) { + printf("SLEEF_IMPORT SLEEF_CONST %s Sleef_%sq%s_u%02d%s(%s);\n", + vdoublename, + funcList[i].name, wqp, + funcList[i].ulp, isaname, + vargquadname); + } else { + printf("SLEEF_IMPORT SLEEF_CONST %s Sleef_%sq%s%s%s(%s);\n", + vdoublename, + funcList[i].name, wqp, + isaub, isaname, + vargquadname); + } + break; + case 11: + if (funcList[i].ulp >= 0) { + printf("SLEEF_IMPORT SLEEF_CONST %s Sleef_%sq%s_u%02d%s(%s);\n", + vargquadname, + funcList[i].name, wqp, + funcList[i].ulp, isaname, + vdoublename); + } else { + printf("SLEEF_IMPORT SLEEF_CONST %s Sleef_%sq%s%s%s(%s);\n", + vargquadname, + funcList[i].name, wqp, + isaub, isaname, + vdoublename); + } + break; + case 12: + assert(funcList[i].ulp == -1); + printf("SLEEF_IMPORT SLEEF_CONST %s Sleef_%sq%s%s%s(Sleef_quad);\n", + vargquadname, + funcList[i].name, wqp, + isaub, isaname); + break; + case 13: + assert(funcList[i].ulp == -1); + printf("SLEEF_IMPORT SLEEF_CONST %s Sleef_%sq%s%s%s(%s, Sleef_quad, Sleef_quad);\n", + vargquadname, + funcList[i].name, wqp, + isaub, isaname, + vintname); + break; + + case 14: + assert(funcList[i].ulp == -1); + printf("SLEEF_IMPORT SLEEF_CONST %s Sleef_%sq%s%s%s(Sleef_quad *);\n", + vargquadname, + funcList[i].name, wqp, + isaub, isaname); + break; + case 15: + assert(funcList[i].ulp == -1); + printf("SLEEF_IMPORT SLEEF_CONST void Sleef_%sq%s%s%s(Sleef_quad *, %s);\n", + funcList[i].name, wqp, + isaub, isaname, + vargquadname); + break; + case 16: + assert(funcList[i].ulp == -1); + printf("SLEEF_IMPORT SLEEF_CONST Sleef_quad Sleef_%sq%s%s%s(%s, int);\n", + funcList[i].name, wqp, + isaub, isaname, + vargquadname); + break; + case 17: + assert(funcList[i].ulp == -1); + printf("SLEEF_IMPORT SLEEF_CONST %s Sleef_%sq%s%s%s(%s, int, Sleef_quad);\n", + vargquadname, + funcList[i].name, wqp, + isaub, isaname, + vargquadname); + break; + case 18: + if (funcList[i].ulp >= 0) { + printf("SLEEF_IMPORT SLEEF_CONST %s Sleef_%sq%s_u%02d%s(%s);\n", + vint64name, + funcList[i].name, wqp, + funcList[i].ulp, isaname, + vargquadname); + } else { + printf("SLEEF_IMPORT SLEEF_CONST %s Sleef_%sq%s%s%s(%s);\n", + vint64name, + funcList[i].name, wqp, + isaub, isaname, + vargquadname); + } + break; + case 19: + if (funcList[i].ulp >= 0) { + printf("SLEEF_IMPORT SLEEF_CONST %s Sleef_%sq%s_u%02d%s(%s);\n", + vargquadname, + funcList[i].name, wqp, + funcList[i].ulp, isaname, + vint64name); + } else { + printf("SLEEF_IMPORT SLEEF_CONST %s Sleef_%sq%s%s%s(%s);\n", + vargquadname, + funcList[i].name, wqp, + isaub, isaname, + vint64name); + } + break; + case 20: + if (funcList[i].ulp >= 0) { + printf("SLEEF_IMPORT SLEEF_CONST %s Sleef_%sq%s_u%02d%s(%s);\n", + vuint64name, + funcList[i].name, wqp, + funcList[i].ulp, isaname, + vargquadname); + } else { + printf("SLEEF_IMPORT SLEEF_CONST %s Sleef_%sq%s%s%s(%s);\n", + vuint64name, + funcList[i].name, wqp, + isaub, isaname, + vargquadname); + } + break; + case 21: + if (funcList[i].ulp >= 0) { + printf("SLEEF_IMPORT SLEEF_CONST %s Sleef_%sq%s_u%02d%s(%s);\n", + vargquadname, + funcList[i].name, wqp, + funcList[i].ulp, isaname, + vuint64name); + } else { + printf("SLEEF_IMPORT SLEEF_CONST %s Sleef_%sq%s%s%s(%s);\n", + vargquadname, + funcList[i].name, wqp, + isaub, isaname, + vuint64name); + } + break; + case 22: + { + printf("SLEEF_IMPORT %s Sleef_%sq%s%s%s(%s, %s *);\n", + vargquadname, + funcList[i].name, wqp, + isaub, isaname, + vargquadname, vintname); + } + break; + case 23: + { + printf("SLEEF_IMPORT %s Sleef_%sq%s%s%s(%s, %s *);\n", + vargquadname, + funcList[i].name, wqp, + isaub, isaname, + vargquadname, vargquadname); + } + break; + } + } + } + + printf("#endif\n"); + } + + exit(0); +} diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/quad/rempitabqp.c b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/quad/rempitabqp.c new file mode 100644 index 00000000000..add9cdabe7f --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/quad/rempitabqp.c @@ -0,0 +1,4176 @@ +#include "misc.h" + +NOEXPORT const double Sleef_rempitabqp[] = { + 0.15915494308865163475, 114.12758349655632628, 87.820147804392036051, 27.423136899138626177, + 14.254027919272630243, 85.935026329207175877, 114.27691102886092267, 37.750191829592949944, + 2.4546589403216785286, 111.34725244651053799, 62.908236858707823558, 87.408456635555921821, + 64.604759095473127672, 28.784837529448850546, 51.622219578821386676, 23.484166172853292665, + 126.14843699368429952, 64.497947248710261192, 90.04072758117763442, 79.851150118094665231, + 93.238662576877686661, 47.957378064249496674, 44.495092337878304534, 122.05645651105805882, + 36.728927543368627084, 8.9860062754451064393, 3.1885831643376150168, 117.4925837228220189, + 107.81580297079563024, 72.690177145766938338, 6.3499807085099746473, 64.814470052646356635, + 32.07563458668300882, 48.190104861652798718, 40.78663459321251139, 17.552382976566150319, + 13.621939875218231464, 21.256544246167322854, 57.381995073275902541, 9.6354705119701975491, + 41.499050218579213833, 113.6220945173263317, 79.59452043374767527, 103.64401134191575693, + 123.88471844718515058, 101.4736260631980258, 18.097774968078738311, 85.95650738066615304, + 76.065655079091811785, 37.675427324622432934, 68.676777671174932038, 32.00599382463042275, + 53.77951688189568813, 0.19179906913632294163, 73.478443940475699492, 111.92379273104597814, + 40.996545034144219244, 107.14597675384720787, 124.38805678367862129, 98.636395050234568771, + 103.347364549201302, 101.568637595839391, 98.20809433281829115, 0.21127150943721062504, + 6.4992127331242954824, 115.19938259065020247, 123.67517849772775662, 108.64186459926349926, + 2.9984621451549173798, 4.6062990500759042334, 93.491721027461608173, 49.145381707759952405, + 52.727074269980221288, 71.068700205698405625, 99.034355036987108178, 24.011549219118023757, + 111.50147725937858922, 49.03615573892602697, 53.722402094637800474, 91.897739203315722989, + 18.206447852357086958, 109.32060226575413253, 97.416567328084056498, 19.228490159101056634, + 125.86502164847843233, 68.117931140997825423, 37.659347287717537256, 94.778508877261629095, + 125.23389264055003878, 9.1960193313898344059, 89.79227686872400227, 44.219955035077873617, + 80.594031160762824584, 98.175325535910815233, 9.1060313697525998577, 1.3536325568711617962, + 74.266441315219708486, 112.02497297326408443, 78.441242103348486125, 30.240608034280739957, + 35.887181287234852789, 31.222180933826166438, 111.20435677495697746, 16.961934521656075958, + 75.690011131529900013, 19.857096218624064932, 39.445799316181364702, 89.399067092508630594, + 9.8946251570741878822, 75.790836480315192603, 41.449609204857551958, 16.424785501782025676, + 110.92636979258531937, 35.2268612109037349, 93.553590155912388582, 60.716867816085141385, + 101.8275823641452007, 0.52353978253449895419, 53.558147969339188421, 14.022688405977532966, + 47.412589899395243265, 67.466685592477006139, 20.558449846765142865, 42.477512440153077478, + 78.376983236481464701, 52.194720245763164712, 80.210266588394006249, 10.32282516378472792, + 13.76645060176088009, 65.576818637229735032, 113.30637098982697353, 33.130573191992880311, + 85.595008141503058141, 40.008528567348548677, 76.341531842852418777, 14.979836669819633244, + 71.290441850942443125, 102.19776376600566437, 98.564603420047205873, 14.271847993266419508, + 80.116664932062121807, 19.992192520050593885, 36.609960786536248634, 73.030199955795978894, + 104.99763589425128885, 48.433380696202220861, 57.572455457851901883, 118.88634466403527767, + 44.860695004797889851, 73.750690998633217532, 13.556655583906831453, 88.593745596503140405, + 14.11532725519646192, 43.085424128406884847, 9.7802314795590064023, 30.352614322964655003, + 90.858137878454726888, 85.039140199140092591, 23.407077980155008845, 18.207643349760473939, + 20.440075362967036199, 109.47096555736425216, 66.428168903472396778, 106.84400033217025339, + 91.750582754768402083, 76.596534958600386744, 17.320324285941751441, 49.535734807919652667, + 113.66190455558171379, 61.225422811843600357, 18.669559649624716258, 76.387663934096053708, + 74.178235974148265086, 85.815782102505181683, 122.10498128451581579, 24.799236859667871613, + 123.2972609065072902, 50.72595180519783753, 121.41778173806596897, 114.39462376141091227, + 90.193730781800695695, 3.0683144895410805475, 26.293759879121353151, 46.076575149436393986, + 19.660881336145394016, 25.597005338699091226, 101.31112300279710325, 103.8807629969487607, + 91.892762314044375671, 57.045969595055794343, 110.15196133002973511, 94.689776863833685638, + 49.182032269411138259, 123.69104138236070867, 113.69436034850150463, 117.72063118611185928, + 1.4682589776566601358, 23.970066872989264084, 91.772521428280015243, 32.248277749331464292, + 74.556784206688462291, 120.01798423568834551, 87.713686773899098625, 80.036939679470378906, + 58.663490617163915886, 21.035325459186424268, 79.868647571121982764, 19.982377222022478236, + 57.246738529793219641, 1.9401161782407143619, 7.9883917663682950661, 108.92261904602855793, + 42.957866646069305716, 55.213983339206606615, 85.734177860773343127, 8.1786861732471152209, + 113.8021284014939738, 6.3038078266908996738, 108.74856571221971535, 13.502748231236182619, + 29.736439245178189594, 66.181101124901033472, 14.021098141827678774, 50.432291116485430393, + 71.692326357551792171, 112.62160509388922947, 46.52251733029333991, 70.328927450136689004, + 82.779915324492321815, 114.20617270459479187, 120.00074403454345884, 27.256265592593990732, + 72.206675336365151452, 105.47692570983417681, 90.069591432285960764, 59.451044258996262215, + 6.5436011348210740834, 11.666369110360392369, 127.00500442843986093, 66.781588143319822848, + 101.71752368163652136, 110.83473463953487226, 9.4843589676565898117, 87.965483504598523723, + 32.660788242061244091, 94.484722863278875593, 121.36131720729463268, 27.298648878622771008, + 105.17309219513481366, 68.000137710059789242, 93.444196628861391218, 44.093294898437306983, + 44.109477207573945634, 104.37636018792545656, 16.936308635202294681, 42.461140061379410326, + 48.120956522194319405, 47.03053727519363747, 74.836943859434541082, 76.560959611877478892, + 70.982041261755512096, 106.17278879548030091, 17.240951762454642449, 116.54761581097409362, + 85.489981931084912503, 19.448874795671144966, 68.055698282205412397, 120.54780957969705923, + 79.357897397254419047, 26.784055884931149194, 8.8652342647874320392, 93.554617017987766303, + 36.863637874987034593, 107.36296787388710072, 114.24380599117284874, 57.996031665523332777, + 107.15169167585190735, 6.8493815877518500201, 70.030736486780369887, 104.34439242449298035, + 32.394922227955248673, 72.045712768554949434, 125.99193223337715608, 79.855994894536706852, + 102.91479410954343621, 19.828504664699721616, 19.423237169754429488, 49.419210917687451001, + 51.794468197291280376, 59.485514724419772392, 78.600481083303748164, 75.802543954887369182, + 49.485430251796060475, 125.97828236915302114, 98.782930868979747174, 83.325835802559595322, + 59.946491932565550087, 73.477066622643178562, 89.105636388390848879, 73.372970791053376161, + 18.817599439345940482, 102.06705368556504254, 45.42352350837609265, 23.440921115026867483, + 90.344093902869644808, 17.970589397602452664, 53.956875561776541872, 55.525845976218988653, + 49.46730813278190908, 77.778136706394434441, 43.505807501616800437, 67.471431943824427435, + 84.265864734097704059, 14.933240975493390579, 24.684664495714969235, 126.41874786355037941, + 1.3222032844169007149, 126.01238007772190031, 83.383431563808699138, 113.72324844212562311, + 21.304834404720168095, 62.332525882295158226, 51.597882727459364105, 0.67672862408289802261, + 30.132787537324475124, 27.410108195865177549, 20.656855709145020228, 49.723609964024944929, + 119.05708648653671844, 91.246047016928059747, 84.369696109431970399, 85.591131138298806036, + 14.127644950760441134, 4.2155267645284766331, 24.204889203938364517, 19.661099106528126867, + 82.477870938018895686, 120.89188850888967863, 122.58114253445455688, 120.63265677435265388, + 27.082481923996965634, 29.761974944867688464, 72.461197358730714768, 84.204483040954073658, + 80.890771993039379595, 99.777925805155973649, 91.8974949579933309, 94.518818676227965625, + 126.28205386120316689, 88.787575110411125934, 93.769932165232603438, 79.733441483964270446, + 38.645666720854933374, 115.27208568365676911, 31.268716353544732556, 112.30475518474486307, + 74.891574611563555663, 115.66812160437984858, 18.66350298186080181, 94.633595189065090381, + 109.45983699533462641, 108.68776993196661351, 58.76809135159055586, 61.680897811242175521, + 38.882956551777169807, 45.576713001821190119, 7.4377005918177019339, 120.60427874347078614, + 120.21996894028052338, 47.606037590059713693, 0.31830988618094124831, 100.25516699311629054, + 47.640295608784072101, 54.846273798277252354, 28.508055838548898464, 43.870052658417989733, + 100.55382205772184534, 75.500383659185899887, 4.9093178806469950359, 94.694504893021075986, + 125.81647371741928509, 46.816913271115481621, 1.2095181909462553449, 57.569675058897701092, + 103.24443915764277335, 46.968332345710223308, 124.29687398737223702, 0.99589449742416036315, + 52.081455162358906819, 31.702300236192968441, 58.477325153755373321, 95.914756128498993348, + 88.990184675760247046, 116.11291302211611765, 73.457855086737254169, 17.972012550890212879, + 6.3771663286788680125, 106.98516744564767578, 87.631605941594898468, 17.380354291533876676, + 12.699961417023587273, 1.6289401052927132696, 64.15126917336601764, 96.380209723305597436, + 81.573269186425022781, 35.104765953132300638, 27.243879750436462928, 42.513088492334645707, + 114.76399014655180508, 19.270941023940395098, 82.998100437162065646, 99.244189034656301374, + 31.189040867498988518, 79.288022683835151838, 119.76943689437393914, 74.947252126396051608, + 36.195549936161114601, 43.913014761335944058, 24.131310158183623571, 75.350854649248503847, + 9.3535553423498640768, 64.011987649260845501, 107.55903376379137626, 0.38359813827628386207, + 18.956887880955036962, 95.847585462091956288, 81.993090068292076467, 86.291953507698053727, + 120.77611356736088055, 69.272790100472775521, 78.694729098406241974, 75.137275191682419972, + 68.4161886656365823, 0.42254301887442125008, 12.998425466252228944, 102.39876518130404293, + 119.35035699545915122, 89.283729198526998516, 5.9969242903098347597, 9.2125981001554464456, + 58.983442054923216347, 98.290763415519904811, 105.45414853996408056, 14.137400411400449229, + 70.068710073974216357, 48.023098438239685493, 95.002954518757178448, 98.07231147785205394, + 107.44480418927923893, 55.795478406631445978, 36.412895704717811896, 90.641204531511903042, + 66.833134656168112997, 38.456980318205751246, 123.73004329696050263, 8.2358622819956508465, + 75.318694575438712491, 61.557017754526896169, 122.46778528110007755, 18.392038662783306791, + 51.58455373744800454, 88.439910070159385214, 33.188062321529287146, 68.350651071821630467, + 18.212062739505199715, 2.7072651137459615711, 20.53288263044305495, 96.04994594653180684, + 28.882484206696972251, 60.481216068561479915, 71.774362574469705578, 62.444361867655970855, + 94.408713549913954921, 33.923869043315789895, 23.380022263059800025, 39.714192437248129863, + 78.891598632366367383, 50.798134185017261188, 19.789250314152013743, 23.581672960630385205, + 82.899218409715103917, 32.849571003567689331, 93.852739585170638748, 70.453722421811107779, + 59.107180311824777164, 121.43373563217392075, 75.655164728290401399, 1.0470795650689979084, + 107.11629593867837684, 28.045376811955065932, 94.825179798794124508, 6.9333711849540122785, + 41.116899693530285731, 84.955024880309792934, 28.753966472962929402, 104.3894404915299674, + 32.420533176788012497, 20.64565032756945584, 27.532901203525398159, 3.1536372744631080423, + 98.612741979653947055, 66.261146383989398601, 43.190016283006116282, 80.017057134700735332, + 24.683063685704837553, 29.959673339642904466, 14.580883701888524229, 76.39552753201496671, + 69.129206840094411746, 28.543695986536476994, 32.233329864124243613, 39.984385040101187769, + 73.219921573076135246, 18.060399911595595768, 81.995271788502577692, 96.866761392404441722, + 115.14491091570744175, 109.77268932807055535, 89.721390009599417681, 19.501381997266435064, + 27.113311167817300884, 49.18749119300628081, 28.230654510392923839, 86.170848256813769694, + 19.560462959118012805, 60.705228645932947984, 53.716275756913091755, 42.078280398280185182, + 46.81415596031001769, 36.415286699520947877, 40.880150725937710376, 90.941931114732142305, + 4.8563378069484315347, 85.688000664344144752, 55.501165509540442144, 25.193069917200773489, + 34.640648571883502882, 99.071469615842943313, 99.323809111163427588, 122.45084562368720071, + 37.339119299253070494, 24.775327868195745395, 20.356471948300168151, 43.631564205014001345, + 116.20996256903163157, 49.598473719339381205, 118.5945218130145804, 101.45190361039931304, + 114.83556347613557591, 100.78924752282546251, 52.38746156360139139, 6.136628979082161095, + 52.587519758242706303, 92.153150298872787971, 39.321762672290788032, 51.194010677401820431, + 74.622246005597844487, 79.761525993901159381, 55.785524628088751342, 114.09193919011522667, + 92.303922660063108196, 61.379553727667371277, 98.364064538825914497, 119.38208276472505531, + 99.388720697006647242, 107.44126237222371856, 2.9365179553133202717, 47.940133745982166147, + 55.545042856560030486, 64.496555498666566564, 21.113568413380562561, 112.03596847138032899, + 47.42737354780183523, 32.073879358940757811, 117.32698123432783177, 42.070650918376486516, + 31.737295142243965529, 39.964754444044956472, 114.49347705958643928, 3.8802323564814287238, + 15.976783532740228111, 89.845238092057115864, 85.915733292138611432, 110.42796667841685121, + 43.468355721546686254, 16.357372346497868421, 99.604256802987947594, 12.607615653385437327, + 89.497131424439430702, 27.005496462472365238, 59.472878490360017167, 4.3622022498020669445, + 28.042196283655357547, 100.86458223297449877, 15.384652715107222321, 97.243210187778458931, + 93.045034660590317799, 12.657854900277015986, 37.559830648988281609, 100.41234540919322171, + 112.00148806908691768, 54.512531185191619443, 16.413350672733940883, 82.953851419671991607, + 52.139182864571921527, 118.90208851799252443, 13.087202269642148167, 23.332738220724422717, + 126.01000885688335984, 5.5631762866432836745, 75.435047363276680699, 93.669469279069744516, + 18.968717935316817602, 47.930967009197047446, 65.321576484126126161, 60.969445726561389165, + 114.72263441458926536, 54.597297757249179995, 82.346184390273265308, 8.0002754201232164633, + 58.888393257722782437, 88.186589796874613967, 88.218954415151529247, 80.752720375850913115, + 33.872617270404589362, 84.922280122758820653, 96.241913044388638809, 94.061074550390912918, + 21.673887718872720143, 25.121919223758595763, 13.964082523514662171, 84.34557759096060181, + 34.481903524912922876, 105.09523162195182522, 42.979963862169825006, 38.897749591345927911, + 8.1113965644144627731, 113.09561915939775645, 30.715794794508838095, 53.568111769862298388, + 17.730468529578502057, 59.109234035975532606, 73.727275749977707164, 86.725935747777839424, + 100.48761198234569747, 115.99206333105030353, 86.303383351703814697, 13.698763175507338019, + 12.061472973564377753, 80.688784848985960707, 64.789844455914135324, 16.091425537113536848, + 123.98386446675795014, 31.711989789077051682, 77.829588219086872414, 39.657009329399443232, + 38.846474339508858975, 98.838421835374902003, 103.58893639458256075, 118.97102944884318276, + 29.200962166611134307, 23.605087909774738364, 98.970860503595758928, 123.95656473830968025, + 69.565861737963132327, 38.651671605119190644, 119.89298386513473815, 18.954133245289995102, + 50.211272776785335736, 18.745941582106752321, 37.635198878695518943, 76.134107371130085085, + 90.8470470167521853, 46.881842230057372944, 52.688187805739289615, 35.941178795204905327, + 107.91375112355308374, 111.05169195243797731, 98.934616265567456139, 27.556273412788868882, + 87.011615003237238852, 6.9428638876524928492, 40.531729468195408117, 29.866481950986781158, + 49.369328991433576448, 124.83749572710075881, 2.6444065688374394085, 124.02476015544743859, + 38.766863127621036256, 99.446496884251246229, 42.60966880944033619, 124.66505176459031645, + 103.19576545491872821, 1.3534572481657960452, 60.265575074648950249, 54.820216391730355099, + 41.313711418290040456, 99.447219928053527838, 110.11417297307707486, 54.492094033859757474, + 40.739392218867578777, 43.182262276597612072, 28.255289901520882268, 8.4310535290569532663, + 48.409778407876729034, 39.322198213059891714, 36.95574187604142935, 113.78377701778299524, + 117.16228506891275174, 113.26531354870530777, 54.164963847993931267, 59.523949889739014907, + 16.922394717465067515, 40.408966081911785295, 33.781543986082397169, 71.555851610315585276, + 55.794989915990299778, 61.037637352459569229, 124.56410772240997176, 49.575150220825889846, + 59.539864330468844855, 31.466882967928540893, 77.291333441713504726, 102.54417136731353821, + 62.53743270709310309, 96.609510369493364124, 21.783149223130749306, 103.33624320875969715, + 37.3270059637252416, 61.26719037813381874, 90.919673990672890795, 89.375539863933227025, + 117.53618270318111172, 123.36179562248435104, 77.765913103554339614, 91.153426003642380238, + 14.875401183639041847, 113.20855748694521026, 112.43993788056104677, 95.212075180119427387, + 0.63661977236552047543, 72.510333986232581083, 95.280591217568144202, 109.69254759655450471, + 57.016111677097796928, 87.740105316839617444, 73.107644115447328659, 23.000767318371799774, + 9.8186357612976280507, 61.389009786045789951, 123.63294743483857019, 93.633826542230963241, + 2.4190363818925106898, 115.13935011779904016, 78.488878315285546705, 93.936664691424084594, + 120.59374797474447405, 1.9917889948483207263, 104.16291032471781364, 63.404600472385936882, + 116.95465030751438462, 63.829512257001624675, 49.980369351524132071, 104.22582604423587327, + 18.915710173474508338, 35.944025101780425757, 12.754332657361374004, 85.970334891298989533, + 47.263211883189796936, 34.760708583067753352, 25.399922834047174547, 3.257880210589064518, + 0.30253834673567325808, 64.76041944661483285, 35.146538372850045562, 70.209531906264601275, + 54.487759500872925855, 85.026176984672929393, 101.52798029310361017, 38.541882047884428175, + 37.99620087432776927, 70.488378069312602747, 62.378081735001615016, 30.576045367673941655, + 111.53887378875151626, 21.894504252792103216, 72.391099872322229203, 87.826029522671888117, + 48.262620316370885121, 22.701709298497007694, 18.707110684703366132, 0.023975298525328980759, + 87.118067527582752518, 0.76719627655256772414, 37.913775761913711904, 63.695170924187550554, + 35.986180136587790912, 44.583907015399745433, 113.55222713472539908, 10.54558020094918902, + 29.389458196816121927, 22.274550383368477924, 8.8323773312731646001, 0.84508603774884250015, + 25.996850932508095866, 76.797530362611723831, 110.70071399092194042, 50.567458397053997032, + 11.993848580619669519, 18.425196200310892891, 117.96688410985007067, 68.581526831043447601, + 82.908297079928161111, 28.274800822804536438, 12.137420147948432714, 96.046196876483008964, + 62.005909037517994875, 68.144622955707745859, 86.889608378558477852, 111.59095681326289196, + 72.82579140943926177, 53.282409063027444063, 5.6662693123362259939, 76.91396063641514047, + 119.46008659392100526, 16.471724563994939672, 22.637389150877424981, 123.11403550905743032, + 116.93557056220015511, 36.784077325566613581, 103.16910747489964706, 48.879820140318770427, + 66.376124643062212272, 8.7013021436432609335, 36.424125479010399431, 5.4145302274919231422, + 41.065765260889747879, 64.099891893063613679, 57.764968413393944502, 120.96243213712659781, + 15.548725148939411156, 124.88872373531557969, 60.817427099827909842, 67.84773808663157979, + 46.76004452611960005, 79.428384874499897705, 29.783197264732734766, 101.59626837003452238, + 39.578500628304027487, 47.163345921264408389, 37.798436819430207834, 65.699142007139016641, + 59.705479170344915474, 12.907444843622215558, 118.21436062365319231, 114.86747126435147948, + 23.310329456580802798, 2.0941591301416337956, 86.232591877356753685, 56.090753623913769843, + 61.650359597588249017, 13.866742369908024557, 82.233799387064209441, 41.910049760619585868, + 57.507932945929496782, 80.778880983059934806, 64.841066353576024994, 41.291300655138911679, + 55.065802407050796319, 6.3072745489298540633, 69.225483959311532089, 4.5222927679787972011, + 86.380032566015870543, 32.034114269401470665, 49.366127371409675106, 59.919346679285808932, + 29.161767403780686436, 24.791055064033571398, 10.258413680188823491, 57.087391973072953988, + 64.466659728248487227, 79.968770080206013517, 18.439843146152270492, 36.120799823194829514, + 35.990543577008793363, 65.733522784812521422, 102.28982183141852147, 91.545378656144748675, + 51.442780019198835362, 39.002763994532870129, 54.226622335634601768, 98.374982386012561619, + 56.461309020789485658, 44.341696513627539389, 39.120925918236025609, 121.41045729186589597, + 107.43255151382618351, 84.156560796560370363, 93.62831192062003538, 72.830573399041895755, + 81.760301451879058732, 53.88386222946428461, 9.7126756139005010482, 43.376001328688289504, + 111.00233101908088429, 50.386139834401546977, 69.281297143770643743, 70.142939231689524604, + 70.647618222330493154, 116.90169124737440143, 74.678238598506140988, 49.550655736391490791, + 40.712943896600336302, 87.263128410031640669, 104.41992513806326315, 99.196947438682400389, + 109.18904362603279878, 74.903807220802264055, 101.6711269522747898, 73.578495045650925022, + 104.77492312720278278, 12.27325795816432219, 105.17503951648905058, 56.306300597745575942, + 78.643525344581576064, 102.38802135480727884, 21.244492011199326953, 31.523051987802318763, + 111.57104925618114066, 100.18387838023409131, 56.607845320126216393, 122.75910745533838053, + 68.728129077655466972, 110.7641655294537486, 70.777441394016932463, 86.882524744447437115, + 5.8730359106266405433, 95.880267491964332294, 111.09008571312369895, 0.99311099733313312754, + 42.2271368267647631, 96.071936942760657985, 94.854747095603670459, 64.147758717885153601, + 106.65396246865566354, 84.141301836752973031, 63.474590284487931058, 79.929508888093550922, + 100.98695411917287856, 7.7604647129628574476, 31.953567065484094201, 51.690476184117869707, + 43.831466584280860843, 92.855933356833702419, 86.936711443093372509, 32.71474469299937482, + 71.208513605975895189, 25.215231306774512632, 50.994262848878861405, 54.010992924944730476, + 118.94575698072003433, 8.7244044996041338891, 56.084392567314353073, 73.729164465948997531, + 30.76930543021808262, 66.48642037556055584, 58.090069321180635598, 25.315709800554031972, + 75.119661297980201198, 72.824690818390081404, 96.002976138173835352, 109.02506237038323889, + 32.826701345471519744, 37.907702839343983214, 104.27836572914748103, 109.80417703598504886, + 26.174404539284296334, 46.665476441452483414, 124.02001771376671968, 11.126352573290205328, + 22.870094726556999376, 59.338938558139489032, 37.937435870633635204, 95.861934018397732871, + 2.6431529682522523217, 121.93889145312641631, 101.44526882917853072, 109.19459551450199797, + 36.692368780546530616, 16.000550840246432927, 117.77678651544920285, 48.373179593752865912, + 48.437908830306696473, 33.50544075170182623, 67.745234540812816704, 41.844560245521279285, + 64.483826088780915597, 60.122149100781825837, 43.347775437745440286, 50.243838447517191526, + 27.92816504703296232, 40.691155181921203621, 68.963807049829483731, 82.190463243903650437, + 85.959927724339650013, 77.795499182691855822, 16.222793128832563525, 98.191238318795512896, + 61.43158958901767619, 107.13622353972459678, 35.460937059157004114, 118.21846807195470319, + 19.454551499959052308, 45.451871495559316827, 72.975223964695032919, 103.98412666210424504, + 44.606766703407629393, 27.397526351014676038, 24.122945947132393485, 33.377569697975559393, + 1.5796889118282706477, 32.182851074230711674, 119.96772893351590028, 63.423979578157741344, + 27.659176438173744828, 79.314018658798886463, 77.692948679021355929, 69.676843670753441984, + 79.177872789168759482, 109.94205889768636553, 58.401924333222268615, 47.210175819553114707, + 69.941721007195155835, 119.91312947662299848, 11.131723475926264655, 77.303343210242019268, + 111.78596773026947631, 37.908266490579990204, 100.42254555357067147, 37.491883164213504642, + 75.270397757394675864, 24.268214742263808148, 53.6940940335043706, 93.763684460114745889, + 105.37637561147857923, 71.882357590413448634, 87.827502247109805467, 94.103383904879592592, + 69.869232531134912279, 55.112546825581375742, 46.023230006474477705, 13.885727775304985698, + 81.063458936390816234, 59.732963901973562315, 98.738657982870790875, 121.67499145420151763, + 5.2888131376785167959, 120.04952031089487718, 77.53372625524571049, 70.892993768502492458, + 85.219337618884310359, 121.33010352918427088, 78.39153090983745642, 2.7069144963315920904, + 120.5311501492979005, 109.6404327834607102, 82.62742283658371889, 70.894439856110693654, + 92.228345946154149715, 108.98418806771951495, 81.478784437735157553, 86.364524553195224144, + 56.510579803041764535, 16.862107058113906533, 96.819556815753458068, 78.644396426119783428, + 73.911483752086496679, 99.567554035569628468, 106.32457013782914146, 98.530627097410615534, + 108.32992769598786253, 119.04789977947802981, 33.84478943493013503, 80.81793216382357059, + 67.563087972168432316, 15.111703220631170552, 111.58997983198059956, 122.07527470492277644, + 121.12821544481994351, 99.150300441651779693, 119.07972866093768971, 62.933765935860719765, + 26.582666883430647431, 77.088342734627076425, 125.07486541418984416, 65.219020738986728247, + 43.56629844626513659, 78.672486417519394308, 74.654011927450483199, 122.53438075627127546, + 53.83934798134941957, 50.751079727870092029, 107.07236540636586142, 118.72359124497234006, + 27.531826207112317206, 54.306852007284760475, 29.750802367281721672, 98.417114973894058494, + 96.879875761125731515, 62.424150360242492752, 1.2732395447346789297, 17.020667972468800144, + 62.561182435139926383, 91.385095193109009415, 114.03222335419923184, 47.480210633682872867, + 18.215288230894657318, 46.001534636743599549, 19.637271522595256101, 122.77801957209521788, + 119.26589486968077836, 59.267653084461926483, 4.8380727637886593584, 102.2787002356017183, + 28.977756630574731389, 59.873329382851807168, 113.1874959494889481, 3.9835779897002794314, + 80.325820649435627274, 126.80920094477551174, 105.90930061502876924, 127.65902451400324935, + 99.960738703051902121, 80.451652088471746538, 37.831420346949016675, 71.888050203560851514, + 25.508665314726385986, 43.940669782597979065, 94.526423766379593872, 69.521417166135506704, + 50.799845668094349094, 6.515760421178129036, 0.60507669347498449497, 1.5208388932296657003, + 70.293076745703729102, 12.419063812529202551, 108.97551900174948969, 42.052353969349496765, + 75.055960586207220331, 77.08376409576885635, 75.992401748659176519, 12.976756138625205494, + 124.75616347000323003, 61.152090735351521289, 95.077747577503032517, 43.789008505587844411, + 16.782199744648096384, 47.652059045343776233, 96.525240632741770241, 45.403418596994015388, + 37.414221369406732265, 0.047950597054295940325, 46.236135055165505037, 1.5343925531051354483, + 75.827551523827423807, 127.39034184837510111, 71.972360273175581824, 89.167814030803128844, + 99.104454269450798165, 21.091160401898378041, 58.778916393632243853, 44.549100766736955848, + 17.6647546625463292, 1.6901720754976850003, 51.993701865019829711, 25.595060725227085641, + 93.401427981843880843, 101.13491679410799406, 23.987697161239339039, 36.850392400625423761, + 107.93376821970377932, 9.1630536620905331802, 37.816594159856322221, 56.549601645609072875, + 24.274840295900503406, 64.092393752966017928, 124.01181807503962773, 8.2892459114191296976, + 45.779216757120593684, 95.18191362652942189, 17.65158281887852354, 106.56481812605488813, + 11.332538624676089967, 25.82792127283391892, 110.92017318784201052, 32.943449127989879344, + 45.274778301758487942, 118.22807101811849861, 105.87114112440031022, 73.568154651136865141, + 78.338214949799294118, 97.759640280641178833, 4.7522492861244245432, 17.402604287286521867, + 72.848250958020798862, 10.829060454983846284, 82.131530521783133736, 0.19978378612722735852, + 115.52993682679152698, 113.92486427425319562, 31.097450297882460291, 121.77744747063115938, + 121.63485419965945766, 7.6954761732631595805, 93.520089052242838079, 30.856769748999795411, + 59.566394529469107511, 75.192536740069044754, 79.157001256608054973, 94.326691842528816778, + 75.596873638864053646, 3.3982840142780332826, 119.41095834068983095, 25.814889687248069094, + 108.42872124731002259, 101.73494252870295895, 46.620658913161605597, 4.18831826028690557, + 44.465183754713507369, 112.18150724782753969, 123.30071919517649803, 27.733484739819687093, + 36.467598774128418881, 83.820099521239171736, 115.01586589186263154, 33.557761966123507591, + 1.6821327071520499885, 82.582601310277823359, 110.13160481410159264, 12.614549097863346105, + 10.450967918623064179, 9.0445855359612323809, 44.760065132031741086, 64.06822853880294133, + 98.732254742819350213, 119.83869335857161786, 58.323534807561372872, 49.582110128067142796, + 20.516827360377646983, 114.17478394614954595, 0.93331945650061243214, 31.937540160412027035, + 36.879686292304540984, 72.241599646389659029, 71.981087154021224706, 3.4670455696286808234, + 76.579643662840680918, 55.090757312289497349, 102.88556003839767072, 78.005527989065740258, + 108.45324467127284152, 68.749964772025123239, 112.92261804157897132, 88.683393027255078778, + 78.241851836475689197, 114.82091458373542991, 86.865103027656004997, 40.313121593124378705, + 59.256623841243708739, 17.661146798087429488, 35.520602903758117463, 107.76772445892856922, + 19.425351227801002096, 86.752002657380216988, 94.004662038161768578, 100.77227966880673193, + 10.562594287544925464, 12.285878463382687187, 13.295236444664624287, 105.80338249475244083, + 21.356477197012281977, 99.101311472782981582, 81.425887793204310583, 46.526256820066919317, + 80.839850276130164275, 70.393894877368438756, 90.378087252069235547, 21.807614441608166089, + 75.342253904553217581, 19.156990091305488022, 81.54984625440556556, 24.546515916332282359, + 82.350079032978101168, 112.61260119549478986, 29.287050689166790107, 76.77604270961455768, + 42.488984022398653906, 63.046103975608275505, 95.142098512365919305, 72.36775676046818262, + 113.21569064025607076, 117.51821491068039904, 9.4562581553145719226, 93.528331058911135187, + 13.554882788037502905, 45.76504948889487423, 11.746071821256919065, 63.760534983932302566, + 94.180171426247397903, 1.9862219946662662551, 84.454273653533164179, 64.143873885524953948, + 61.709494191210978897, 0.2955174357739451807, 85.307924937314965064, 40.282603673505946063, + 126.94918056897950009, 31.859017776190739824, 73.973908238345757127, 15.520929425925714895, + 63.907134130968188401, 103.38095236823573941, 87.662933168565359665, 57.711866713671042817, + 45.873422886186745018, 65.429489386002387619, 14.417027211951790377, 50.430462613549025264, + 101.98852569775772281, 108.02198584989309893, 109.89151396144006867, 17.448808999208267778, + 112.16878513463234412, 19.458328931897995062, 61.538610860439803218, 4.9728407511211116798, + 116.1801386423612712, 50.631419601111701922, 22.239322595964040374, 17.649381636783800786, + 64.005952276351308683, 90.050124740766477771, 65.653402690943039488, 75.815405678691604408, + 80.556731458298600046, 91.608354071970097721, 52.348809078568592668, 93.330952882908604806, + 120.04003542753343936, 22.252705146580410656, 45.740189453113998752, 118.67787711627897806, + 75.874871741270908387, 63.723868036795465741, 5.2863059365081426222, 115.8777829062564706, + 74.890537658360699425, 90.389191029003995936, 73.384737561093061231, 32.001101680496503832, + 107.5535730308984057, 96.746359187505731825, 96.875817660613392945, 67.010881503407290438, + 7.4904690816256334074, 83.689120491046196548, 0.96765217756183119491, 120.24429820156365167, + 86.695550875490880571, 100.48767689503438305, 55.856330094065924641, 81.38231036384604522, + 9.9276140996626054402, 36.380926487810938852, 43.919855448682938004, 27.590998365383711644, + 32.445586257668765029, 68.382476637591025792, 122.86317917803899036, 86.272447079449193552, + 70.921874118317646207, 108.43693614390940638, 38.909102999918104615, 90.903742991122271633, + 17.950447929393703816, 79.968253324208490085, 89.213533406815258786, 54.795052702029352076, + 48.24589189426478697, 66.755139395951118786, 3.1593778236565412953, 64.365702148465061327, + 111.93545786703180056, 126.84795915631548269, 55.318352876351127634, 30.628037317601410905, + 27.385897358046349837, 11.353687341510521946, 30.355745578341156943, 91.884117795372731052, + 116.80384866644453723, 94.420351639109867392, 11.883442014393949648, 111.82625895324599696, + 22.263446951856167288, 26.606686420487676514, 95.571935460538952611, 75.816532981163618388, + 72.845091107141342945, 74.983766328430647263, 22.540795514789351728, 48.536429484527616296, + 107.38818806701237918, 59.527368920233129757, 82.75275122296079644, 15.764715180830535246, + 47.655004494223248912, 60.206767809762823163, 11.738465062269824557, 110.22509365116275148, + 92.046460012948955409, 27.771455550613609375, 34.126917872781632468, 119.46592780395076261, + 69.477315965745219728, 115.34998290840303525, 10.577626275360671571, 112.09904062179339235, + 27.067452510495058959, 13.785987537008622894, 42.438675237772258697, 114.66020705837217974, + 28.78306181967491284, 5.4138289926668221597, 113.06230029859943897, 91.280865566925058374, + 37.254845673171075759, 13.788879712225025287, 56.456691892311937409, 89.968376135442667874, + 34.957568875473953085, 44.729049106390448287, 113.02115960608352907, 33.724214116231451044, + 65.639113631510554114, 29.288792852243204834, 19.822967504176631337, 71.135108071142894914, + 84.649140275661920896, 69.061254194824869046, 88.659855391979363048, 110.09579955895605963, + 67.689578869863908039, 33.63586432765077916, 7.1261759443368646316, 30.223406441265979083, + 95.179959663964837091, 116.15054940984919085, 114.25643088964352501, 70.300600883307197364, + 110.15945732187537942, 125.86753187172143953, 53.165333766864932841, 26.176685469257790828, + 122.1497308283833263, 2.4380414779734564945, 87.132596892533911159, 29.344972835042426595, + 21.308023854904604377, 117.06876151254255092, 107.67869596269883914, 101.50215945574382204, + 86.144730812735360814, 109.44718248994468013, 55.063652414224634413, 108.61370401456952095, + 59.501604734567081323, 68.834229947791754967, 65.75975152225146303, 124.8483007204849855, + 2.5464790894693578593, 34.041335944937600289, 125.12236487028349075, 54.770190386221656809, + 100.06444670839846367, 94.960421267365745734, 36.430576461789314635, 92.003069273487199098, + 39.274543045194150181, 117.55603914419407374, 110.53178973936155671, 118.53530616892385297, + 9.6761455275809566956, 76.557400471203436609, 57.955513261149462778, 119.74665876570725231, + 98.374991898977896199, 7.9671559794041968416, 32.651641298874892527, 125.61840188955466147, + 83.818601230061176466, 127.31804902801013668, 71.921477406107442221, 32.903304176943493076, + 75.66284069390167133, 15.776100407121703029, 51.017330629452771973, 87.881339565199596109, + 61.052847532762825722, 11.042834332271013409, 101.59969133618869819, 13.031520842356258072, + 1.2101533869499689899, 3.0416777864629693795, 12.586153491407458205, 24.83812762506204308, + 89.951038003498979378, 84.104707938702631509, 22.11192117241807864, 26.167528191541350679, + 23.984803497318353038, 25.953512277254048968, 121.51232694000646006, 122.30418147070668056, + 62.155495155006065033, 87.578017011175688822, 33.564399489296192769, 95.304118090691190446, + 65.050481265483540483, 90.806837193988030776, 74.82844273881346453, 0.095901194108591880649, + 92.472270110331010073, 3.0687851062139088754, 23.655103047658485593, 126.7806836967538402, + 15.944720546354801627, 50.335628061609895667, 70.20890853890159633, 42.182320803796756081, + 117.55783278726448771, 89.098201533473911695, 35.329509325092658401, 3.3803441509953700006, + 103.98740373003965942, 51.19012145045780926, 58.802855963691399666, 74.269833588215988129, + 47.975394322478678077, 73.700784801254485501, 87.867536439407558646, 18.32610732418106636, + 75.633188319712644443, 113.09920329121814575, 48.549680591804644791, 0.18478750593567383476, + 120.02363615007925546, 16.578491822838259395, 91.558433514244825346, 62.36382725305884378, + 35.303165637760685058, 85.129636252109776251, 22.665077249352179933, 51.655842545671475818, + 93.840346375684021041, 65.886898255979758687, 90.549556603520613862, 108.45614203624063521, + 83.742282248804258415, 19.136309302277368261, 28.676429899602226214, 67.519280561282357667, + 9.5044985722488490865, 34.805208574576681713, 17.696501916041597724, 21.658120909971330548, + 36.263061043566267472, 0.39956757225809269585, 103.05987365358669194, 99.849728548506391235, + 62.19490059576855856, 115.55489494126595673, 115.26970839931891533, 15.39095234652995714, + 59.040178104485676158, 61.713539497999590822, 119.132789058941853, 22.385073480141727487, + 30.314002513219747925, 60.653383685061271535, 23.193747277728107292, 6.796568028559704544, + 110.8219166813796619, 51.629779374499776168, 88.85744249462368316, 75.469885057405917905, + 93.241317826323211193, 8.3766365205738111399, 88.930367509430652717, 96.363014495658717351, + 118.60143839035299607, 55.466969479639374185, 72.935197548260475742, 39.640199042481981451, + 102.03173178372526309, 67.115523932247015182, 3.3642654143077379558, 37.165202620559284696, + 92.263209628203185275, 25.229098195726692211, 20.901935837246128358, 18.089171071922464762, + 89.520130264067120152, 0.13645707760952063836, 69.464509485642338404, 111.67738671714323573, + 116.64706961512274574, 99.164220256134285592, 41.033654720758931944, 100.34956789229909191, + 1.8666389130012248643, 63.87508032082405407, 73.759372584612719947, 16.483199292782956036, + 15.962174308042449411, 6.9340911392609996255, 25.159287325681361835, 110.18151462458263268, + 77.771120076798979426, 28.011055978135118494, 88.906489342549321009, 9.4999295440538844559, + 97.845236083161580609, 49.366786054513795534, 28.483703672955016373, 101.64182916747449781, + 45.730206055312009994, 80.626243186248757411, 118.51324768248741748, 35.322293596174858976, + 71.041205807519872906, 87.53544891785713844, 38.850702455605642172, 45.504005314764071954, + 60.009324076327175135, 73.544559337613463867, 21.125188575089850929, 24.571756926765374374, + 26.590472889332886552, 83.606764989504881669, 42.712954394028201932, 70.202622945569601143, + 34.851775586408621166, 93.052513640137476614, 33.679700552263966529, 12.787789754740515491, + 52.756174504138471093, 43.615228883219970157, 22.684507809106435161, 38.313980182614614023, + 35.09969250881113112, 49.093031832668202696, 36.700158065959840314, 97.225202390989579726, + 58.574101378337218193, 25.552085419229115359, 84.977968044797307812, 126.09220795122018899, + 62.284197024735476589, 16.735513520940003218, 98.431381280515779508, 107.03642982136079809, + 18.912516310632781824, 59.056662117822270375, 27.109765576075005811, 91.53009897778974846, + 23.492143642513838131, 127.52106996786824311, 60.360342852494795807, 3.972443989336170489, + 40.908547307069966337, 0.28774777104990789667, 123.41898838242195779, 0.59103487155152834021, + 42.615849874629930127, 80.565207347015530104, 125.89836113795900019, 63.718035552385117626, + 19.947816476691514254, 31.04185885185142979, 127.81426826194001478, 78.761904736475116806, + 47.32586633713071933, 115.42373342734208563, 91.746845772377128014, 2.8589787720047752373, + 28.834054423903580755, 100.86092522710168851, 75.977051395519083599, 88.043971699789835839, + 91.783027922880137339, 34.897617998420173535, 96.33757026926468825, 38.916657863795990124, + 123.07722172087960644, 9.9456815022458613385, 104.36027728472254239, 101.26283920222340384, + 44.478645191928080749, 35.298763273571239552, 0.011904552706255344674, 52.100249481536593521, + 3.3068053818897169549, 23.630811357386846794, 33.113462916600838071, 55.216708143940195441, + 104.69761815714082331, 58.661905765820847591, 112.08007085506687872, 44.505410293160821311, + 91.480378906231635483, 109.35575423256159411, 23.749743482541816775, 127.44773607359093148, + 10.572611873019923223, 103.75556581251657917, 21.781075316725036828, 52.778382058011629852, + 18.769475122186122462, 64.002203360996645642, 87.107146061800449388, 65.492718375015101628, + 65.75163532123042387, 6.0217630068145808764, 14.980938163254904794, 39.378240982092393097, + 1.9353043551273003686, 112.48859640313094133, 45.391101750985399121, 72.975353790068766102, + 111.71266018813548726, 34.764620727692090441, 19.85522819932521088, 72.761852975621877704, + 87.839710897365876008, 55.181996730767423287, 64.891172515341168037, 8.7649532751856895629, + 117.72635835608161869, 44.544894158902025083, 13.843748236638930393, 88.873872287818812765, + 77.818205999839847209, 53.807485982244543266, 35.900895858791045612, 31.936506648420618149, + 50.427066813630517572, 109.59010540405870415, 96.491783788533211919, 5.5102787919022375718, + 6.3187556473167205695, 0.73140429693376063369, 95.8709157340672391, 125.69591831263096537, + 110.63670575270225527, 61.25607463520282181, 54.771794716092699673, 22.707374683021043893, + 60.711491156685951864, 55.768235590749100083, 105.60769733289271244, 60.840703278219734784, + 23.766884028791537276, 95.652517906491993926, 44.526893903712334577, 53.213372840978991007, + 63.143870921081543202, 23.633065962330874754, 17.69018221428632387, 21.967532656861294527, + 45.081591029578703456, 97.072858969058870571, 86.776376134024758358, 119.05473784046989749, + 37.50550244592159288, 31.529430361661070492, 95.310008988446497824, 120.41353561952564633, + 23.476930124543287093, 92.450187302329140948, 56.092920025897910818, 55.542911101227218751, + 68.253835745566902915, 110.9318556079051632, 10.954631931494077435, 102.69996581680607051, + 21.15525255072498112, 96.198081243586784694, 54.134905020990117919, 27.571975074017245788, + 84.877350475548155373, 101.32041411674435949, 57.56612363934982568, 10.827657985337282298, + 98.124600597202515928, 54.561731133850116748, 74.509691346342151519, 27.577759424450050574, + 112.9133837846275128, 51.936752270885335747, 69.91513775094790617, 89.458098212784534553, + 98.04231921216705814, 67.448428232466540067, 3.2782272630211082287, 58.577585704486409668, + 39.645935008356900653, 14.270216142289427808, 41.29828055132747977, 10.122508389653376071, + 49.319710783962364076, 92.191599117915757233, 7.3791577397278160788, 67.271728655301558319, + 14.252351888673729263, 60.446812882535596145, 62.359919327933312161, 104.30109881970201968, + 100.51286177929068799, 12.601201766618032707, 92.31891464375439682, 123.73506374344287906, + 106.33066753372986568, 52.353370938519219635, 116.2994616567666526, 4.8760829559505509678, + 46.265193785067822319, 58.689945670084853191, 42.616047709812846733, 106.13752302508873981, + 87.357391925401316257, 75.004318911491282051, 44.289461625474359607, 90.894364979889360256, + 110.1273048284529068, 89.227408029139041901, 119.00320946913780062, 9.668459895587147912, + 3.5195030445065640379, 121.69660144096997101, 5.0929581789387157187, 68.082671889878838556, + 122.24472974056698149, 109.5403807724469516, 72.128893416800565319, 61.920842534731491469, + 72.861152923582267249, 56.006138546974398196, 78.549086090391938342, 107.11207828839178546, + 93.063579478726751404, 109.07061233784770593, 19.35229105516555137, 25.114800942406873219, + 115.91102652230256354, 111.49331753141814261, 68.749983797955792397, 15.934311958808393683, + 65.303282597753423033, 123.23680377911296091, 39.63720246012599091, 126.63609805602391134, + 15.842954812214884441, 65.80660835389062413, 23.325681387803342659, 31.552200814243406057, + 102.03466125890918192, 47.762679130399192218, 122.10569506552565144, 22.085668664545664797, + 75.199382672377396375, 26.063041684712516144, 2.4203067738999379799, 6.083355572925938759, + 25.17230698281491641, 49.676255250127724139, 51.902076007001596736, 40.209415877405263018, + 44.223842344836157281, 52.335056383082701359, 47.969606994636706077, 51.907024554511735914, + 115.02465388001655811, 116.60836294141336111, 124.31099031001576805, 47.156034022351377644, + 67.128798978596023517, 62.60823618138601887, 2.1009625309707189444, 53.613674387979699532, + 21.65688547762692906, 0.19180238822082174011, 56.944540220662020147, 6.1375702124278177507, + 47.310206095320609165, 125.56136739350768039, 31.889441092709603254, 100.67125612322342931, + 12.41781707780319266, 84.364641607597150141, 107.11566557453261339, 50.19640306694782339, + 70.659018650185316801, 6.76068830199437798, 79.974807460079318844, 102.38024290091561852, + 117.60571192738643731, 20.539667176431976259, 95.950788644960994134, 19.401569602512608981, + 47.735072878815117292, 36.652214648365770699, 23.266376639428926865, 98.198406582436291501, + 97.099361183609289583, 0.36957501187498564832, 112.04727230015851092, 33.156983645680156769, + 55.116867028489650693, 124.72765450611768756, 70.606331275525008095, 42.259272504219552502, + 45.330154498704359867, 103.31168509134658962, 59.68069275137168006, 3.7737965119631553534, + 53.099113207044865703, 88.912284072484908393, 39.484564497608516831, 38.272618604554736521, + 57.352859799208090408, 7.0385611225647153333, 19.008997144497698173, 69.610417149153363425, + 35.393003832083195448, 43.316241819942661095, 72.526122087132534944, 0.7991351445198233705, + 78.119747307177021867, 71.699457097012782469, 124.3898011915407551, 103.10978988253555144, + 102.53941679863783065, 30.78190469305991428, 118.08035620897135232, 123.42707899600281962, + 110.265578117883706, 44.770146960283454973, 60.62800502643949585, 121.30676737012254307, + 46.387494555456214584, 13.593136057123047067, 93.643833362759323791, 103.25955874900319031, + 49.714884989251004299, 22.939770114815473789, 58.482635652646422386, 16.753273041151260259, + 49.860735018864943413, 64.726028991321072681, 109.20287678070599213, 110.93393895928238635, + 17.870395096520951483, 79.28039808496760088, 76.063463567454164149, 6.2310478644940303639, + 6.7285308286154759116, 74.330405241122207372, 56.52641925640637055, 50.458196391453384422, + 41.803871674492256716, 36.178342143848567503, 51.040260528134240303, 0.27291415522267925553, + 10.929018971288314788, 95.354773434290109435, 105.29413923024912947, 70.328440512268571183, + 82.067309441521501867, 72.699135784598183818, 3.7332778260024497285, 127.75016064165174612, + 19.518745169225439895, 32.966398585565912072, 31.924348616084898822, 13.868182278521999251, + 50.31857465136636165, 92.363029249168903334, 27.542240153597958852, 56.022111956273874966, + 49.812978685098642018, 18.999859088111406891, 67.690472166323161218, 98.733572109027591068, + 56.967407345913670724, 75.283658334948995616, 91.460412110627657967, 33.2524863725011528, + 109.02649536497483496, 70.644587192353355931, 14.08241161504338379, 47.07089783571427688, + 77.701404911211284343, 91.008010629528143909, 120.01864815265798825, 19.089118675226927735, + 42.250377150179701857, 49.143513853530748747, 53.180945778669411084, 39.213529979009763338, + 85.425908788060041843, 12.405245891139202286, 69.703551172820880311, 58.105027280274953227, + 67.359401104527933057, 25.575579509481030982, 105.51234900827694219, 87.230457766439940315, + 45.369015618212870322, 76.627960365229228046, 70.199385017622262239, 98.186063665336405393, + 73.400316131923318608, 66.450404781979159452, 117.14820275667443639, 51.104170838461868698, + 41.955936089598253602, 124.18441590244037798, 124.56839404947095318, 33.471027041883644415, + 68.862762561035196995, 86.072859642721596174, 37.825032621265563648, 118.11332423564454075, + 54.2195311521536496, 55.06019795557949692, 46.984287285031314241, 127.04213993573648622, + 120.72068570498959161, 7.9448879786723409779, 81.817094614139932673, 0.57549554210345377214, + 118.83797676484391559, 1.1820697431030566804, 85.231699749263498234, 33.130414694034698186, + 123.79672227591800038, 127.43607110477023525, 39.895632953383028507, 62.083717703706497559, + 127.62853652388366754, 29.523809472950233612, 94.651732674265076639, 102.84746685468780925, + 55.493691544754256029, 5.7179575440095504746, 57.668108847810799489, 73.721850454207014991, + 23.954102791041805176, 48.087943399583309656, 55.566055845760274678, 69.795235996843985049, + 64.675140538529376499, 77.833315727595618227, 118.15444344175921287, 19.891363004495360656, + 80.720554569448722759, 74.52567840444680769, 88.957290383856161498, 70.597526547142479103, + 0.023809105412510689348, 104.20049896307318704, 6.6136107637794339098, 47.261622714773693588, + 66.226925833201676141, 110.43341628788402886, 81.395236314281646628, 117.32381153164533316, + 96.160141710133757442, 89.010820586325280601, 54.960757812466908945, 90.711508465123188216, + 47.499486965087271528, 126.89547214718186297, 21.145223746043484425, 79.511131625033158343, + 43.562150633450073656, 105.5567641160232597, 37.538950244375882903, 0.0044067219969292636961, + 46.214292123604536755, 2.9854367500338412356, 3.5032706424608477391, 12.043526013629161753, + 29.961876326509809587, 78.756481964184786193, 3.8706087102582387161, 96.977192806261882652, + 90.782203501974436222, 17.950707580141170183, 95.425320376270974521, 69.529241455384180881, + 39.71045639865405974, 17.523705951247393386, 47.679421794731752016, 110.36399346153848455, + 1.7823450306823360734, 17.529906550375017105, 107.45271671216323739, 89.089788317804050166, + 27.687496473281498766, 49.747744575641263509, 27.636411999679694418, 107.61497196448908653, + 71.801791717582091223, 63.873013296841236297, 100.85413362726467312, 91.180210808121046284, + 64.983567577066423837, 11.020557583804475144, 12.637511294633441139, 1.4628085938711592462, + 63.741831468138116179, 123.39183662526556873, 93.273411505404510535, 122.51214927040564362, + 109.54358943218539935, 45.414749366042087786, 121.42298231337190373, 111.53647118150183815, + 83.215394665785424877, 121.68140655643946957, 47.53376805758671253, 63.305035812983987853, + 89.053787807424669154, 106.42674568195798201, 126.2877418421630864, 47.266131924661749508, + 35.380364428572647739, 43.935065313722589053, 90.16318205916104489, 66.14571793812137912, + 45.552752268053154694, 110.10947568093979498, 75.01100489184318576, 63.058860723325778963, + 62.620017976896633627, 112.82707123905129265, 46.953860249090212164, 56.900374604658281896, + 112.18584005179582164, 111.08582220245807548, 8.5076714911374438088, 93.863711215810326394, + 21.909263862991792848, 77.399931633612141013, 42.310505101453600219, 64.396162487173569389, + 108.26981004198023584, 55.143950148038129555, 41.754700951099948725, 74.640828233488718979, + 115.13224727869965136, 21.655315970678202575, 68.249201194405031856, 109.12346226770387148, + 21.019382692684303038, 55.155518848903739126, 97.826767569255025592, 103.87350454177430947, + 11.830275501899450319, 50.916196425572707085, 68.084638424337754259, 6.8968564649330801331, + 6.5564545260422164574, 117.15517140897281934, 79.291870016713801306, 28.540432284578855615, + 82.596561102654959541, 20.245016779306752142, 98.63942156792836613, 56.383198235831514467, + 14.758315479459270136, 6.543457310603116639, 28.504703777347458526, 120.89362576507119229, + 124.7198386558702623, 80.602197639407677343, 73.025723558581375983, 25.202403533239703393, + 56.63782928751243162, 119.4701274868893961, 84.661335067459731363, 104.70674187704207725, + 104.59892331353330519, 9.7521659119011019357, 92.530387570135644637, 117.37989134016970638, + 85.232095419629331445, 84.275046050181117607, 46.714783850806270493, 22.008637822982564103, + 88.578923250952357193, 53.788729959782358492, 92.254609656909451587, 50.45481605828172178, + 110.00641893827560125, 19.336919791174295824, 7.0390060890167660546, 115.39320288194358, + 10.185916357881069416, 8.1653437797613150906, 116.48945948113760096, 91.080761544897541171, + 16.257786833601130638, 123.84168506946662092, 17.722305847164534498, 112.01227709395243437, + 29.098172180787514662, 86.224156576787208905, 58.127158957457140787, 90.141224675695411861, + 38.70458211033110274, 50.229601884817384416, 103.82205304460876505, 94.986635062839923194, + 9.4999675959115847945, 31.868623917620425345, 2.6065651955104840454, 118.47360755822592182, + 79.2744049202556198, 125.27219611204782268, 31.685909624433406861, 3.6132167077812482603, + 46.651362775606685318, 63.104401628490450094, 76.069322517818363849, 95.525358260802022414, + 116.21139013105130289, 44.171337329094967572, 22.39876534475479275, 52.126083369425032288, + 4.8406135477998759598, 12.166711145851877518, 50.344613965629832819, 99.352510500255448278, + 103.80415201400319347, 80.418831754810526036, 88.447684689672314562, 104.67011276616540272, + 95.939213989273412153, 103.81404910902710981, 102.04930776003675419, 105.21672588283036021, + 120.62198062003153609, 94.312068044706393266, 6.2575979571920470335, 125.21647236277203774, + 4.2019250619414378889, 107.22734877595939906, 43.313770955253858119, 0.38360477644164348021, + 113.88908044132404029, 12.275140424855635501, 94.62041219064485631, 123.12273478701536078, + 63.778882185422844486, 73.342512246446858626, 24.835634155610023299, 40.729283215197938262, + 86.231331149065226782, 100.39280613389928476, 13.318037300370633602, 13.521376603992393939, + 31.949614920162275666, 76.760485801834875019, 107.21142385477287462, 41.079334352867590496, + 63.901577289921988267, 38.803139205025217962, 95.470145757630234584, 73.304429296731541399, + 46.532753278861491708, 68.396813164876220981, 66.198722367218579166, 0.73915002375360927545, + 96.094544600317021832, 66.313967291360313538, 110.23373405698293936, 121.4553090122390131, + 13.212662551050016191, 84.518545008439105004, 90.660308997412357712, 78.623370182693179231, + 119.36138550274336012, 7.5475930239263107069, 106.19822641409336939, 49.824568144969816785, + 78.969128995217033662, 76.545237209109473042, 114.70571959841618082, 14.077122245129430667, + 38.017994288999034325, 11.220834298306726851, 70.786007664166390896, 86.63248363988896017, + 17.052244174265069887, 1.5982702890432847198, 28.239494614357681712, 15.398914194029202918, + 120.77960238308514818, 78.219579765074740862, 77.078833597275661305, 61.563809386123466538, + 108.16071241794634261, 118.85415799200927722, 92.531156235767411999, 89.540293920566909947, + 121.25601005288262968, 114.61353474024508614, 92.774989110912429169, 27.186272114249732113, + 59.28766672552228556, 78.519117498006380629, 99.429769978502008598, 45.879540229630947579, + 116.96527130529284477, 33.506546082302520517, 99.721470037733524805, 1.4520579826457833406, + 90.405753561415622244, 93.867877918564772699, 35.740790193045540946, 30.560796169938839739, + 24.126927134908328298, 12.462095728988060728, 13.457061657234589802, 20.660810482244414743, + 113.0528385128127411, 100.91639278290676884, 83.607743348984513432, 72.356684287697135005, + 102.08052105626848061, 0.54582831044535851106, 21.858037942580267554, 62.709546868583856849, + 82.588278460501896916, 12.656881024540780345, 36.134618883046641713, 17.398271569196367636, + 7.4665556520085374359, 127.50032128330349224, 39.03749033845087979, 65.932797171131824143, + 63.848697232169797644, 27.736364557043998502, 100.63714930273636128, 56.726058498337806668, + 55.084480307195917703, 112.04422391254774993, 99.625957370197284035, 37.99971817622645176, + 7.3809443326499604154, 69.467144218055182137, 113.93481469183097943, 22.567316669901629211, + 54.920824221255315933, 66.50497274500594358, 90.052990729953307891, 13.289174384706711862, + 28.16482323008676758, 94.141795671432191739, 27.402809822426206665, 54.016021259059925796, + 112.0372963053159765, 38.17823735045385547, 84.500754300359403715, 98.287027707061497495, + 106.36189155733882217, 78.427059958023164654, 42.851817576120083686, 24.81049178228204255, + 11.407102345641760621, 116.21005456055354443, 6.7188022090558661148, 51.151159018965699943, + 83.024698016557522351, 46.460915532879880629, 90.738031236429378623, 25.25592073046209407, + 12.398770035248162458, 68.372127330676448764, 18.800632263850275194, 4.9008095639619568828, + 106.29640551334887277, 102.2083416769237374, 83.911872179200145183, 120.36883180488439393, + 121.13678809894190636, 66.942054083770926809, 9.7255251220740319695, 44.145719285443192348, + 75.650065242534765275, 108.2266484712890815, 108.4390623043072992, 110.12039591115899384, + 93.96857457006626646, 126.08427987147661042, 113.44137140997918323, 15.889775957348319935, + 35.634189228279865347, 1.1509910842105455231, 109.67595352968783118, 2.3641394862097513396, + 42.463399498526996467, 66.260829388073034352, 119.59344455183963873, 126.8721422095404705, + 79.791265906766057014, 124.1674354074166331, 127.25707304776733508, 59.047618945904105203, + 61.303465348533791257, 77.694933709375618491, 110.98738308950851206, 11.435915088019100949, + 115.33621769562523696, 19.443700908414029982, 47.908205582083610352, 96.175886799166619312, + 111.13211169152418734, 11.590471993691608077, 1.3502810770623909775, 27.666631455194874434, + 108.30888688351842575, 39.78272600899435929, 33.441109138901083497, 21.051356808897253359, + 49.914580767715960974, 13.195053094284958206, 0.047618210828659357503, 80.400997926146374084, + 13.22722152755886782, 94.523245429551025154, 4.4538516664069902617, 92.866832575771695701, + 34.790472628566931235, 106.6476230632943043, 64.320283420271152863, 50.021641172650561202, + 109.92151562493745587, 53.423016930246376432, 94.998973930178181035, 125.79094429436372593, + 42.290447492090606829, 31.022263250066316687, 87.12430126690378529, 83.113528232046519406, + 75.077900488751765806, 0.0088134439938585273921, 92.42858424720907351, 5.9708735000676824711, + 7.0065412849216954783, 24.087052027258323506, 59.923752653023257153, 29.512963928369572386, + 7.7412174205201154109, 65.954385612527403282, 53.564407003948872443, 35.901415160285978345, + 62.85064075254558702, 11.058482910768361762, 79.42091279730811948, 35.047411902494786773, + 95.35884358946714201, 92.727986923076969106, 3.5646900613646721467, 35.059813100753672188, + 86.905433424330112757, 50.179576635608100332, 55.374992946562997531, 99.495489151282527018, + 55.272823999363026815, 87.229943928981811041, 15.603583435164182447, 127.74602659368611057, + 73.708267254532984225, 54.360421616245730547, 1.9671351541328476742, 22.041115167608950287, + 25.275022589266882278, 2.9256171877423184924, 127.48366293627987034, 118.78367325053477543, + 58.546823010812659049, 117.02429854081492522, 91.087178864370798692, 90.829498732087813551, + 114.84596462674744544, 95.07294236300731427, 38.430789331574487733, 115.36281311287893914, + 95.06753611517342506, 126.61007162597161368, 50.107575614852976287, 84.853491363919602009, + 124.57548368432617281, 94.532263849323499016, 70.760728857145295478, 87.870130627448816085, + 52.326364118325727759, 4.2914358762427582406, 91.105504536109947367, 92.218951361883227946, + 22.02200978368637152, 126.11772144665155793, 125.24003595379690523, 97.654142478102585301, + 93.907720498180424329, 113.80074920932020177, 96.371680103595281253, 94.171644404916150961, + 17.015342982278525596, 59.727422431620652787, 43.818527725987223675, 26.799863267224282026, + 84.621010202910838416, 0.79232497435077675618, 88.539620083960471675, 110.28790029607625911, + 83.509401902203535428, 21.281656466981075937, 102.26449455739930272, 43.310631941360043129, + 8.4984023888137016911, 90.246924535407742951, 42.038765385368606076, 110.31103769781111623, + 67.653535138513689162, 79.747009083548618946, 23.660551003798900638, 101.83239285114905215, + 8.1692768486755085178, 13.793712929866160266, 13.112909052088070894, 106.31034281794927665, + 30.583740033427602611, 57.080864569161349209, 37.193122205309919082, 40.490033558617142262, + 69.27884313585673226, 112.76639647166302893, 29.516630958918540273, 13.086914621206233278, + 57.009407554698555032, 113.78725153014602256, 121.43967731174416258, 33.204395278818992665, + 18.051447117162751965, 50.404807066479406785, 113.27565857502850122, 110.94025497378243017, + 41.322670134923100704, 81.413483754087792477, 81.197846627066610381, 19.50433182380584185, + 57.060775140274927253, 106.75978268034305074, 42.464190839262300869, 40.550092100362235215, + 93.429567701612540986, 44.017275645968766185, 49.157846501904714387, 107.57745991956835496, + 56.509219313818903174, 100.90963211656708154, 92.012837876551202498, 38.673839582348591648, + 14.078012178037170088, 102.78640576389079797, 20.371832715762138832, 16.33068755952626816, + 104.9789189622788399, 54.161523089795082342, 32.515573667205899255, 119.68337013893324183, + 35.444611694332706975, 96.024554187904868741, 58.196344361578667304, 44.448313153574417811, + 116.25431791491791955, 52.282449351390823722, 77.40916422066220548, 100.45920376963840681, + 79.644106089221168077, 61.973270125679846387, 18.999935191823169589, 63.737247835240850691, + 5.2131303910246060695, 108.94721511645548162, 30.548809840514877578, 122.54439222409564536, + 63.371819248866813723, 7.2264334155624965206, 93.302725551213370636, 126.20880325698453817, + 24.138645035640365677, 63.050716521607682807, 104.42278026210260577, 88.342674658189935144, + 44.7975306895095855, 104.25216673885006458, 9.6812270955997519195, 24.333422291703755036, + 100.68922793126330362, 70.705021000514534535, 79.608304028010024922, 32.83766350962469005, + 48.895369379348267103, 81.340225532334443415, 63.878427978550462285, 79.628098218057857594, + 76.098615520077146357, 82.43345176566435839, 113.24396124006671016, 60.624136089412786532, + 12.515195914387732046, 122.43294472554407548, 8.4038501238865137566, 86.454697551918798126, + 86.627541910507716238, 0.76720955288692493923, 99.778160882648080587, 24.550280849714908982, + 61.240824381293350598, 118.24546957403072156, 127.55776437084932695, 18.685024492893717252, + 49.671268311220046598, 81.458566430399514502, 44.462662298134091543, 72.785612267798569519, + 26.636074600741267204, 27.042753207984787878, 63.899229840328189312, 25.520971603673388017, + 86.42284770954574924, 82.158668705735180993, 127.80315457984397653, 77.606278410054073902, + 62.940291515264107147, 18.608858593463082798, 93.065506557726621395, 8.7936263297560799401, + 4.3974447344371583313, 1.4783000475108565297, 64.189089200637681643, 4.6279345827242650557, + 92.467468113969516708, 114.9106180244780262, 26.425325102103670361, 41.037090016881847987, + 53.320617994828353403, 29.246740365389996441, 110.72277100548672024, 15.095186047856259393, + 84.39645282818673877, 99.649136289943271549, 29.938257990437705303, 25.090474418222584063, + 101.41143919683236163, 28.154244490258861333, 76.035988577998068649, 22.44166859661709168, + 13.57201532833641977, 45.264967279777920339, 34.104488348530139774, 3.1965405780865694396, + 56.478989228715363424, 30.797828388062043814, 113.55920476617393433, 28.439159530153119704, + 26.157667194551322609, 123.12761877225057106, 88.321424835896323202, 109.70831598402219242, + 57.062312471538461978, 51.080587841137457872, 114.51202010576889734, 101.22706948049381026, + 57.549978221824858338, 54.372544228499464225, 118.5753334510482091, 29.038234996016399236, + 70.859539957004017197, 91.759080459265533136, 105.93054261058568954, 67.013092164608679013, + 71.44294007546704961, 2.9041159652952046599, 52.811507122834882466, 59.735755837129545398, + 71.481580386091081891, 61.121592339877679478, 48.253854269816656597, 24.924191457976121455, + 26.914123314469179604, 41.321620964492467465, 98.10567702562912018, 73.832785565817175666, + 39.215486697972664842, 16.713368575397907989, 76.161042112536961213, 1.0916566208907170221, + 43.716075885160535108, 125.41909373717135168, 37.176556921003793832, 25.31376204908156069, + 72.269237766093283426, 34.796543138392735273, 14.933111304020712851, 127.00064256660698447, + 78.074980676905397559, 3.8655943422636482865, 127.69739446433959529, 55.472729114091634983, + 73.274298605472722556, 113.45211699667561334, 110.16896061439547339, 96.088447825099137845, + 71.251914740394568071, 75.99943635245290352, 14.76188866530355881, 10.934288436114002252, + 99.869629383661958855, 45.134633339803258423, 109.84164844251426985, 5.009945490015525138, + 52.105981459906615783, 26.578348769413423724, 56.32964646017717314, 60.283591342864383478, + 54.80561964485241333, 108.03204251812348957, 96.074592610631952994, 76.356474700911348918, + 41.001508600722445408, 68.574055414126632968, 84.723783114681282314, 28.854119916046329308, + 85.703635152240167372, 49.6209835645640851, 22.814204691287159221, 104.42010912110708887, + 13.43760441811173223, 102.30231803793503786, 38.049396033115044702, 92.921831065763399238, + 53.476062472858757246, 50.511841460924188141, 24.797540070499962894, 8.7442546613528975286, + 37.601264527700550389, 9.8016191279275517445, 84.592811026701383526, 76.41668335385111277, + 39.823744358403928345, 112.73766360977242584, 114.27357619788745069, 5.8841081675418536179, + 19.451050244148063939, 88.291438570890022675, 23.300130485073168529, 88.453296942581800977, + 88.87812460861823638, 92.240791822321625659, 59.937149140136170899, 124.16855974295685883, + 98.882742819958366454, 31.779551914696639869, 71.268378456559730694, 2.301982168424729025, + 91.351907059375662357, 4.7282789724195026793, 84.926798997057630913, 4.5216587761497066822, + 111.18688910368291545, 125.74428441908457899, 31.582531813535752008, 120.33487081483690417, + 126.51414609553467017, 118.09523789180821041, 122.60693069707122049, 27.389867418754874961, + 93.974766179017024115, 22.871830176041839877, 102.67243539125047391, 38.887401816828059964, + 95.816411164170858683, 64.351773598336876603, 94.264223383048374671, 23.180943987383216154, + 2.700562154124781955, 55.333262910393386846, 88.617773767036851496, 79.56545201798871858, + 66.882218277802166995, 42.102713617794506717, 99.829161535431921948, 26.390106188569916412, + 0.095236421660956693813, 32.801995852292748168, 26.454443055121373618, 61.046490859102050308, + 8.9077033328176185023, 57.733665151543391403, 69.580945257137500448, 85.295246126592246583, + 0.64056684054230572656, 100.04328234530476038, 91.843031249874911737, 106.84603386049639084, + 61.99794786036000005, 123.58188858872745186, 84.580894984181213658, 62.044526500136271352, + 46.248602533811208559, 38.227056464096676791, 22.155800977503531612, 0.017626887991355033591, + 56.85716849441814702, 11.941747000135364942, 14.013082569843390957, 48.174104054516647011, + 119.84750530604651431, 59.025927856739144772, 15.482434841043868801, 3.908771225054806564, + 107.12881400789774489, 71.80283032057195669, 125.70128150509117404, 22.116965821540361503, + 30.841825594616238959, 70.094823804993211525, 62.717687178937921999, 57.455973846153938212, + 7.1293801227293442935, 70.119626201510982355, 45.810866848660225514, 100.35915327121620066, + 110.74998589312963304, 70.990978302565054037, 110.54564799872969161, 46.459887857963622082, + 31.207166870332002873, 127.49205318737585912, 19.41653450906596845, 108.72084323249146109, + 3.9342703082656953484, 44.082230335217900574, 50.550045178533764556, 5.8512343754882749636, + 126.96732587256337865, 109.56734650106955087, 117.09364602162895608, 106.04859708163348841, + 54.174357728745235363, 53.65899746417926508, 101.69192925349852885, 62.145884726014628541, + 76.861578663152613444, 102.72562622576151625, 62.135072230350488098, 125.22014325194322737, + 100.21515122970959055, 41.706982727842841996, 121.15096736865598359, 61.064527698650636012, + 13.521457714294228936, 47.74026125489763217, 104.65272823665145552, 8.5828717524891544599, + 54.211009072223532712, 56.437902723766455892, 44.044019567376381019, 124.23544289330675383, + 122.48007190759744844, 67.30828495620880858, 59.815440996364486637, 99.601498418644041521, + 64.743360207194200484, 60.343288809832301922, 34.030685964557051193, 119.45484486324130557, + 87.637055451974447351, 53.599726534452202031, 41.242020405821676832, 1.5846499487051914912, + 49.079240167924581328, 92.575800592156156199, 39.018803804407070857, 42.563312933965789853, + 76.528989114798605442, 86.621263882720086258, 16.996804777631041361, 52.493849070815485902, + 84.07753077074085013, 92.622075395625870442, 7.3070702770310163032, 31.494018167097237892, + 47.321102007601439254, 75.664785702298104297, 16.338553697351017036, 27.587425859732320532, + 26.225818104179779766, 84.620685635898553301, 61.167480066855205223, 114.16172913832269842, + 74.386244410619838163, 80.980067117237922503, 10.5576862717171025, 97.532792943326057866, + 59.033261917837080546, 26.173829242412466556, 114.01881510940074804, 99.574503060295683099, + 114.87935462348832516, 66.40879055763798533, 36.10289423432550393, 100.80961413296245155, + 98.551317150060640415, 93.88050994756486034, 82.645340269849839387, 34.826967508179222932, + 34.395693254133220762, 39.0086636476116837, 114.12155028055349248, 85.519565360686101485, + 84.928381678524601739, 81.100184200728108408, 58.859135403225081973, 88.034551291937532369, + 98.315693003813066753, 87.154919839136709925, 113.01843862764144433, 73.819264233137801057, + 56.025675753102404997, 77.347679164697183296, 28.156024356077978155, 77.57281152778523392, + 40.743665431524277665, 32.661375119056174299, 81.957837924557679798, 108.32304617959016468, + 65.03114733441543649, 111.36674027786648367, 70.889223388669051928, 64.049108375809737481, + 116.39268872315733461, 88.896626307152473601, 104.5086358298358391, 104.56489870278528542, + 26.818328441328048939, 72.918407539280451601, 31.288212178442336153, 123.94654025135969277, + 37.999870383646339178, 127.47449567048170138, 10.426260782052850118, 89.894430232910963241, + 61.097619681033393135, 117.08878444819129072, 126.74363849773362745, 14.45286683112863102, + 58.605451102430379251, 124.41760651396907633, 48.277290071280731354, 126.10143304321900359, + 80.845560524208849529, 48.685349316379870288, 89.595061379022808978, 80.504333477700129151, + 19.362454191199503839, 48.666844583411148051, 73.378455862530245213, 13.410042001032707049, + 31.216608056020049844, 65.675327019249380101, 97.790738758700172184, 34.680451064668886829, + 127.75685595710456255, 31.256196436119353166, 24.197231040157930693, 36.86690353133235476, + 98.487922480133420322, 121.24827217882557306, 25.03039182877910207, 116.86588945108815096, + 16.807700247776665492, 44.909395103841234231, 45.255083821015432477, 1.5344191057774878573, + 71.556321765296161175, 49.100561699429817963, 122.48164876259033917, 108.4909391480650811, + 127.1155287416986539, 37.370048985787434503, 99.342536622443731176, 34.917132860799029004, + 88.925324596271821065, 17.571224535597139038, 53.272149201482534409, 54.085506415969575755, + 127.79845968065637862, 51.041943207350414013, 44.845695419095136458, 36.317337411473999964, + 127.60630915969159105, 27.212556820108147804, 125.88058303052821429, 37.217717186929803574, + 58.13101311545324279, 17.58725265951215988, 8.7948894688743166625, 2.9566000950253510382, + 0.37817840127536328509, 9.2558691654521680903, 56.934936227942671394, 101.8212360489560524, + 52.850650204207340721, 82.074180033763695974, 106.64123598965670681, 58.493480730783630861, + 93.445542010973440483, 30.190372095716156764, 40.79290565637711552, 71.298272579886543099, + 59.876515980875410605, 50.180948836448806105, 74.822878393664723262, 56.308488980521360645, + 24.071977155996137299, 44.88333719323418336, 27.144030656672839541, 90.529934559555840679, + 68.208976697060279548, 6.3930811561731388792, 112.95797845743072685, 61.595656776127725607, + 99.118409532347868662, 56.878319060306239408, 52.315334389106283197, 118.25523754450478009, + 48.642849671796284383, 91.416631968044384848, 114.12462494307692396, 102.16117568227855372, + 101.02404021154143265, 74.454138960987620521, 115.09995644364971668, 108.74508845700256643, + 109.1506669020964182, 58.076469992036436452, 13.719079914011672372, 55.518160918534704251, + 83.861085221175017068, 6.0261843292209960055, 14.88588015093409922, 5.8082319305904093198, + 105.62301424566976493, 119.47151167426272877, 14.963160772182163782, 122.24318467975535896, + 96.507708539633313194, 49.848382915952242911, 53.828246628938359208, 82.643241928988572909, + 68.21135405126187834, 19.665571131634351332, 78.430973395945329685, 33.426737150799453957, + 24.322084225073922426, 2.1833132417814340442, 87.432151770324708195, 122.83818747434270335, + 74.353113842007587664, 50.627524098166759359, 16.538475532186566852, 69.593086276785470545, + 29.86622260804506368, 126.00128513321760693, 28.149961353810795117, 7.7311886845309345517, + 127.39478892867919058, 110.94545822818690795, 18.548597210949083092, 98.904233993354864651, + 92.337921228794584749, 64.176895650201913668, 14.50382948079277412, 23.998872704905807041, + 29.523777330607117619, 21.868576872231642483, 71.739258767323917709, 90.269266679610154824, + 91.683296885028539691, 10.019890980031050276, 104.21196291981323157, 53.156697538826847449, + 112.65929292035434628, 120.56718268572876696, 109.61123928970846464, 88.064085036250617122, + 64.149185221267543966, 24.712949401822697837, 82.003017201448528795, 9.1481108282569039147, + 41.447566229362564627, 57.708239832096296595, 43.407270304480334744, 99.2419671291281702, + 45.628409382577956421, 80.840218242214177735, 26.875208836227102438, 76.604636075870075729, + 76.098792066233727382, 57.843662131526798476, 106.95212494571751449, 101.02368292184837628, + 49.595080140999925788, 17.488509322705795057, 75.202529055401100777, 19.603238255858741468, + 41.18562205340640503, 24.83336670770222554, 79.647488716811494669, 97.475327219548489666, + 100.54715239577490138, 11.768216335083707236, 38.902100488299765857, 48.582877141780045349, + 46.600260970149975037, 48.906593885167239932, 49.756249217240110738, 56.481583644643251318, + 119.87429828027597978, 120.33711948591735563, 69.765485639916732907, 63.559103829396917718, + 14.536756913119461387, 4.6039643368530960288, 54.703814118751324713, 9.4565579448426433373, + 41.853597994115261827, 9.0433175523030513432, 94.373778207369468873, 123.48856883816915797, + 63.165063627075141994, 112.66974162967744633, 125.02829219107297831, 108.19047578362005879, + 117.21386139414244099, 54.779734837513387902, 59.949532358034048229, 45.743660352087317733, + 77.344870782500947826, 77.774803633659757907, 63.632822328345355345, 0.70354719667739118449, + 60.528446766096749343, 46.361887974766432308, 5.4011243082495639101, 110.66652582079041167, + 49.23554753407734097, 31.13090403598107514, 5.7644365556043339893, 84.205427235592651414, + 71.658323070863843895, 52.780212377139832824, 0.19047284332191338763, 65.603991704585496336, + 52.908886110242747236, 122.09298171820410062, 17.815406665635237005, 115.46733030309042078, + 11.161890514278638875, 42.590492253184493165, 1.2811336810882494319, 72.086564690613158746, + 55.686062499753461452, 85.692067720992781688, 123.99589572072363808, 119.1637771774585417, + 41.161789968362427317, 124.0890530002725427, 92.497205067622417118, 76.454112928193353582, + 44.311601955007063225, 0.035253775982710067183, 113.71433698883629404, 23.883494000270729885, + 28.026165139686781913, 96.348208109036932001, 111.69501061209302861, 118.05185571347828954, + 30.964869682087737601, 7.8175424501132511068, 86.257628015799127752, 15.60566064114755136, + 123.40256301018234808, 44.233931643080723006, 61.683651189236115897, 12.189647609986423049, + 125.435374357875844, 114.91194769230787642, 14.258760245462326566, 12.23925240302196471, + 91.621733697324089007, 72.718306542436039308, 93.499971786262904061, 13.981956605133746052, + 93.091295997459383216, 92.919775715927244164, 62.414333740667643724, 126.98410637475171825, + 38.833069018135574879, 89.441686464982922189, 7.8685406165313906968, 88.164460670435801148, + 101.10009035706752911, 11.702468750980187906, 125.93465174513039528, 91.134693002142739715, + 106.18729204326155013, 84.09719416326697683, 108.34871545749047073, 107.31799492836216814, + 75.383858506997057702, 124.29176945203289506, 25.723157326308864867, 77.451252451523032505, + 124.27014446070461418, 122.44028650389009272, 72.430302459419181105, 83.413965455689321971, + 114.30193473731196718, 122.12905539730127202, 27.042915428588457871, 95.48052250979890232, + 81.305456473302911036, 17.16574350497830892, 108.42201814444706542, 112.87580544753291178, + 88.088039134756400017, 120.47088578661714564, 116.96014381519853487, 6.6165699124176171608, + 119.63088199273261125, 71.202996837291721022, 1.4867204143884009682, 120.68657761966460384, + 68.061371929117740365, 110.90968972648624913, 47.274110903948894702, 107.19945306890440406, + 82.484040811643353663, 3.1692998974103829823, 98.158480335852800636, 57.151601184312312398, + 78.037607608814141713, 85.126625867935217684, 25.057978229600848863, 45.242527765440172516, + 33.993609555262082722, 104.98769814163460978, 40.155061541485338239, 57.244150791251740884, + 14.614140554062032606, 62.988036334194475785, 94.642204015206516488, 23.329571404596208595, + 32.677107394702034071, 55.174851719464641064, 52.451636208363197511, 41.241371271797106601, + 122.33496013371404842, 100.32345827664903481, 20.772488821243314305, 33.960134234475845005, + 21.115372543437842978, 67.065585886652115732, 118.06652383567416109, 52.34765848482857109, + 100.03763021880513406, 71.149006120595004177, 101.7587092469802883, 4.8175811152759706602, + 72.20578846865464584, 73.619228265928541077, 69.102634300124918809, 59.761019895133358659, + 37.290680539699678775, 69.653935016358445864, 68.791386508266441524, 78.017327295227005379, + 100.24310056111062295, 43.039130721375840949, 41.856763357052841457, 34.200368401456216816, + 117.71827080645380192, 48.069102583878702717, 68.631386007629771484, 46.309839678277057828, + 98.036877255286526633, 19.638528466275602113, 112.05135150620844797, 26.695358329394366592, + 56.312048712159594288, 27.145623055570467841, 81.487330863048555329, 65.322750238115986576, + 35.915675849118997576, 88.646092359183967346, 2.0622946688345109578, 94.733480555736605311, + 13.778446777341741836, 0.098216751623112941161, 104.78537744631830719, 49.79325261430858518, + 81.017271659675316187, 81.129797405570570845, 53.636656882659735857, 17.836815078560903203, + 62.576424356888310285, 119.89308050271938555, 75.999740767296316335, 126.94899134096340276, + 20.852521564109338215, 51.788860465821926482, 122.19523936207042425, 106.17756889638621942, + 125.48727699546725489, 28.90573366225726204, 117.21090220486439648, 120.83521302793815266, + 96.554580142565100687, 124.20286608644164517, 33.691121048417699058, 97.370698632763378555, + 51.190122758049255935, 33.008666955400258303, 38.724908382399007678, 97.33368916682593408, + 18.756911725060490426, 26.820084002065414097, 62.433216112043737667, 3.3506540385023981798, + 67.581477517400344368, 69.360902129341411637, 127.5137119142091251, 62.512392872238706332, + 48.394462080315861385, 73.733807062668347498, 68.975844960270478623, 114.49654435765114613, + 50.060783657561842119, 105.73177890217630193, 33.615400495553330984, 89.818790207682468463, + 90.510167642030864954, 3.0688382115586136933, 15.11264353059232235, 98.201123398863273906, + 116.96329752518431633, 88.981878296133800177, 126.23105748339730781, 74.740097971578506986, + 70.685073244887462351, 69.834265721601695986, 49.85064919254364213, 35.142449071194278076, + 106.54429840296506882, 108.17101283194278949, 127.59691936131275725, 102.08388641470082803, + 89.691390838190272916, 72.634674822951637907, 127.2126183193831821, 54.425113640219933586, + 123.76116606105642859, 74.435434373859607149, 116.26202623090648558, 35.174505319024319761, + 17.589778937748633325, 5.9132001900507020764, 0.75635680255072657019, 18.511738330904336181, + 113.86987245588898077, 75.6424720979121048, 105.70130040841831942, 36.148360067531029927, + 85.282471979313413613, 116.9869614615708997, 58.891084021946880966, 60.380744191432313528, + 81.585811312757869018, 14.596545159773086198, 119.75303196175082121, 100.36189767290125019, + 21.645756787329446524, 112.61697796104272129, 48.143954311992274597, 89.76667438646836672, + 54.288061313349317061, 53.059869119115319336, 8.4179533941205590963, 12.786162312349915737, + 97.915956914861453697, 123.19131355225908919, 70.236819064695737325, 113.75663812061247882, + 104.63066877821620437, 108.51047508900956018, 97.285699343596206745, 54.833263936092407675, + 100.24924988615748589, 76.322351364560745424, 74.048080423086503288, 20.908277921978879021, + 102.19991288730307133, 89.490176914008770837, 90.301333804192836396, 116.1529399840728729, + 27.438159828023344744, 111.03632183707304648, 39.722170442350034136, 12.052368658441992011, + 29.771760301868198439, 11.616463861184456619, 83.246028491343167843, 110.94302334852545755, + 29.926321544367965544, 116.48636935951435589, 65.015417079266626388, 99.696765831904485822, + 107.6564932578803564, 37.286483857980783796, 8.4227081025237566791, 39.331142263272340642, + 28.86194679189065937, 66.853474301598907914, 48.644168450147844851, 4.3666264835665060673, + 46.86430354065305437, 117.67637494868904469, 20.706227684015175328, 101.25504819633351872, + 33.076951064376771683, 11.186172553570941091, 59.732445216093765339, 124.00257026643521385, + 56.299922707621590234, 15.462377369065507082, 126.78957785736201913, 93.89091645637381589, + 37.097194421901804162, 69.808467986713367281, 56.675842457592807477, 0.35379130040382733569, + 29.007658961585548241, 47.997745409811614081, 59.047554661214235239, 43.737153744466922944, + 15.478517534651473397, 52.538533359223947627, 55.366593770057079382, 20.039781960065738531, + 80.42392583962646313, 106.31339507765733288, 97.318585840712330537, 113.13436537146117189, + 91.222478579420567257, 48.128170072504872223, 0.2983704425350879319, 49.425898803649033653, + 36.006034402897057589, 18.296221656513807829, 82.895132458725129254, 115.41647966419259319, + 86.814540608964307467, 70.483934258256340399, 91.256818765159550821, 33.68043648442835547, + 53.750417672457842855, 25.209272151743789436, 24.197584132467454765, 115.68732426305723493, + 85.904249891438666964, 74.047365843696752563, 99.190160281999851577, 34.977018645415228093, + 22.405058110802201554, 39.206476511717482936, 82.37124410681281006, 49.666733415408089058, + 31.294977433626627317, 66.95065443910061731, 73.094304791549802758, 23.536432670167414472, + 77.804200976599531714, 97.165754283560090698, 93.200521940299950074, 97.813187770334479865, + 99.512498434480221476, 112.96316728929014062, 111.74859656055559753, 112.67423897183834924, + 11.530971279833465815, 127.11820765879383544, 29.073513826238922775, 9.2079286737061920576, + 109.40762823750264943, 18.913115889685286675, 83.707195988230523653, 18.086635104609740665, + 60.747556414742575726, 118.97713767633831594, 126.33012725415392197, 97.339483259358530631, + 122.0565843821495946, 88.380951567243755562, 106.42772278828488197, 109.5594696750267758, + 119.89906471606809646, 91.487320704178273445, 26.68974156500553363, 27.549607267319515813, + 127.26564465669071069, 1.407094393354782369, 121.05689353219349869, 92.723775949532864615, + 10.802248616502765799, 93.333051641580823343, 98.47109506815468194, 62.261808071962150279, + 11.528873111212305957, 40.410854471188940806, 15.316646141727687791, 105.56042475427966565, + 0.38094568664746475406, 3.2079834091709926724, 105.81777222048913245, 116.18596343640820123, + 35.630813331274111988, 102.93466060618084157, 22.32378102855727775, 85.180984506368986331, + 2.5622673621801368427, 16.173129381226317491, 111.37212499951056088, 43.384135441989201354, + 119.99179144145091414, 110.3275543549170834, 82.323579936728492612, 120.17810600054872339, + 56.994410135248472216, 24.908225856386707164, 88.62320391001412645, 0.070507551969058113173, + 99.42867397767258808, 47.766988000541459769, 56.052330279377201805, 64.696416218077501981, + 95.390021224189695204, 108.10371142695657909, 61.929739364175475203, 15.635084900230140192, + 44.515256031598255504, 31.211321282298740698, 118.80512602036469616, 88.467863286161446013, + 123.36730237847223179, 24.379295219976484077, 122.87074871575532597, 101.82389538461575285, + 28.517520490924653132, 24.478504806047567399, 55.243467394651815994, 17.436613084875716595, + 58.999943572525808122, 27.963913210271130083, 58.18259199492240441, 57.839551431854488328, + 124.82866748133892543, 125.9682127495034365, 77.666138036274787737, 50.883372929965844378, + 15.737081233066419372, 48.328921340875240276, 74.200180714135058224, 23.404937501964013791, + 123.86930349026442855, 54.269386004289117409, 84.374584086526738247, 40.194388326537591638, + 88.697430914984579431, 86.635989856727974257, 22.767717013997753384, 120.58353890406579012, + 51.446314652621367713, 26.902504903049702989, 120.54028892141286633, 116.88057300778382341, + 16.860604918842000188, 38.82793091138228192, 100.60386947462757234, 116.25811079460254405, + 54.085830857180553721, 62.961045019601442618, 34.610912946605822071, 34.331487009960255818, + 88.844036288897768827, 97.751610895069461549, 48.176078269516438013, 112.94177157323792926, + 105.92028763039706973, 13.2331398248388723, 111.26176398546886048, 14.405993674583442044, + 2.9734408287804399151, 113.37315523933284567, 8.1227438582391187083, 93.819379452972498257, + 94.548221807901427383, 86.398906137812446104, 36.968081623286707327, 6.3385997948244039435, + 68.316960671705601271, 114.30320236862826278, 28.075215217631921405, 42.253251735870435368, + 50.115956459201697726, 90.485055530880345032, 67.987219110527803423, 81.975396283269219566, + 80.310123082970676478, 114.48830158250348177, 29.228281108124065213, 125.97607266839258955, + 61.284408030413032975, 46.659142809192417189, 65.354214789404068142, 110.34970343892928213, + 104.90327241672639502, 82.482742543597851181, 116.66992026743173483, 72.64691655329806963, + 41.544977642486628611, 67.920268468951690011, 42.230745086879323935, 6.1311717733078694437, + 108.13304767134832218, 104.69531696966078016, 72.075260437613906106, 14.298012241193646332, + 75.517418493960576598, 9.6351622305555792991, 16.411576937312929658, 19.238456531860720133, + 10.205268600249837618, 119.52203979026671732, 74.581361079402995529, 11.307870032720529707, + 9.5827730165365210269, 28.034654590457648737, 72.486201122221245896, 86.078261442751681898, + 83.713526714105682913, 68.400736802916071611, 107.43654161290760385, 96.138205167761043413, + 9.2627720152595429681, 92.619679356557753636, 68.073754510573053267, 39.277056932554842206, + 96.102703012416895945, 53.390716658788733184, 112.62409742431918858, 54.291246111144573661, + 34.974661726100748638, 2.6455004762319731526, 71.83135169824163313, 49.292184718367934693, + 4.1245893376726598945, 61.466961111473210622, 27.556893554683483671, 0.19643350324986386113, + 81.570754892636614386, 99.586505228620808339, 34.034543319354270352, 34.25959481114114169, + 107.27331376531947171, 35.673630157121806405, 125.15284871378025855, 111.78616100544240908, + 23.999481534596270649, 125.89798268192680553, 41.705043128218676429, 103.57772093164749094, + 116.39047872414448648, 84.355137792776076822, 122.97455399093450978, 57.811467324518162059, + 106.42180440973243094, 113.67042605587994331, 65.109160285133839352, 120.40573217288329033, + 67.382242096839036094, 66.74139726552675711, 102.38024551609851187, 66.017333910800516605, + 77.449816764801653335, 66.667378333651868161, 37.513823450120980851, 53.640168004130828194, + 124.86643222408747533, 6.7013080770084343385, 7.1629550348043267149, 10.721804258686461253, + 127.0274238284182502, 125.02478574447741266, 96.788924160635360749, 19.467614125340332976, + 9.9516899205445952248, 100.99308871530229226, 100.12156731512732222, 83.463557804352603853, + 67.230800991110299947, 51.637580415368574904, 53.020335284061729908, 6.1376764231172273867, + 30.225287061188282678, 68.40224679773018579, 105.92659505037227063, 49.963756592271238333, + 124.46211496679825359, 21.48019594316065195, 13.370146489778562682, 11.668531443203391973, + 99.701298385087284259, 70.284898142392194131, 85.088596805933775613, 88.342025663889216958, + 127.19383872262915247, 76.167772829405294033, 51.382781676384183811, 17.269349645906913793, + 126.42523663876636419, 108.85022728044350515, 119.52233212211649516, 20.870868747722852277, + 104.52405246181297116, 70.349010638048639521, 35.17955787549726665, 11.826400380101404153, + 1.5127136051014531404, 37.02347666181231034, 99.739744911781599512, 23.284944195827847579, + 83.402600816836638842, 72.296720135065697832, 42.564943958630465204, 105.9739229231417994, + 117.78216804389376193, 120.76148838286826503, 35.171622625515738036, 29.193090319549810374, + 111.5060639235052804, 72.723795345802500378, 43.291513574662531028, 97.23395592208544258, + 96.287908623988187173, 51.53334877293673344, 108.57612262669863412, 106.11973823823063867, + 16.835906788241118193, 25.572324624703469453, 67.831913829726545373, 118.38262710452181636, + 12.473638129395112628, 99.513276241228595609, 81.261337556436046725, 89.020950178022758337, + 66.57139868719241349, 109.66652787218845333, 72.498499772318609757, 24.644702729125128826, + 20.096160846173006576, 41.816555843961396022, 76.399825774609780638, 50.980353828021179652, + 52.602667608389310772, 104.30587996814574581, 54.876319656050327467, 94.072643674146092962, + 79.444340884700068273, 24.104737316883984022, 59.543520603736396879, 23.232927722372551216, + 38.492056982689973665, 93.8860466970509151, 59.852643088739569066, 104.97273871903234976, + 2.0308341585368907545, 71.393531663812609622, 87.312986515760712791, 74.572967715961567592, + 16.845416205047513358, 78.662284526544681285, 57.723893583784956718, 5.706948603197815828, + 97.288336900295689702, 8.7332529671330121346, 93.728607081309746718, 107.35274989737808937, + 41.412455368033988634, 74.510096392667037435, 66.153902128753543366, 22.372345107141882181, + 119.46489043219116866, 120.00514053287042771, 112.59984541524318047, 30.924754738134652143, + 125.57915571472767624, 59.781832912747631781, 74.194388843807246303, 11.616935973426734563, + 113.35168491518561495, 0.70758260080765467137, 58.015317923171096481, 95.995490819623228163, + 118.09510932242847048, 87.474307488933845889, 30.957035069302946795, 105.07706671844789525, + 110.73318754011415876, 40.07956392013511504, 32.847851679256564239, 84.626790155318303732, + 66.637171681428299053, 98.268730742925981758, 54.444957158841134515, 96.256340145009744447, + 0.5967408850701758638, 98.851797607298067305, 72.012068805794115178, 36.592443313031253638, + 37.790264917453896487, 102.83295932838882436, 45.629081217932252912, 12.967868516516318778, + 54.513637530319101643, 67.360872968856710941, 107.50083534491568571, 50.418544303487578873, + 48.395168264938547509, 103.37464852611810784, 43.808499782880971907, 20.094731687397143105, + 70.380320563999703154, 69.954037290830456186, 44.810116221604403108, 78.41295302343860385, + 36.742488213625620119, 99.333466830816178117, 62.589954867256892612, 5.9013088782048725989, + 18.188609583099605516, 47.072865340338466922, 27.608401953202701407, 66.331508567123819375, + 58.401043880603538128, 67.626375540672597708, 71.024996868964080932, 97.92633457858391921, + 95.497193121114833048, 97.348477943676698487, 23.061942559670569608, 126.23641531758767087, + 58.14702765247784555, 18.415857347416022094, 90.815256475005298853, 37.826231779374211328, + 39.414391976461047307, 36.17327020921948133, 121.49511282948878943, 109.95427535268026986, + 124.66025450831148191, 66.678966518720699241, 116.11316876430282719, 48.761903134491149103, + 84.855445576573401922, 91.118939350057189586, 111.7981294321398309, 54.97464140835654689, + 53.37948313001106726, 55.099214534642669605, 126.53128931338142138, 2.8141887867132027168, + 114.11378706439063535, 57.447551899065729231, 21.604497233009169577, 58.666103283165284665, + 68.942190136309363879, 124.52361614392430056, 23.057746222424611915, 80.821708942377881613, + 30.633292283459013561, 83.120849508559331298, 0.76189137329492950812, 6.4159668183456233237, + 83.635544440981902881, 104.37192687281640247, 71.261626662551861955, 77.869321212361683138, + 44.647562057118193479, 42.361969012737972662, 5.1245347243602736853, 32.346258762456272962, + 94.744249999021121766, 86.768270883982040687, 111.98358288290546625, 92.655108709837804781, + 36.647159873460623203, 112.35621200109744677, 113.98882027049694443, 49.816451712777052308, + 49.2464078200282529, 0.14101510394175420515, 70.85734795534517616, 95.533976001082919538, + 112.10466055875804159, 1.39283243615864194, 62.780042448383028386, 88.207422853913158178, + 123.85947872835095041, 31.270169800460280385, 89.030512063196511008, 62.422642564601119375, + 109.6102520407330303, 48.935726572326530004, 118.73460475694446359, 48.758590439956606133, + 117.74149743151428993, 75.647790769231505692, 57.035040981849306263, 48.957009612095134798, + 110.48693478930363199, 34.87322616975143319, 117.99988714505161624, 55.927826420542260166, + 116.36518398984480882, 115.67910286371261464, 121.65733496268148883, 123.93642549901051098, + 27.332276072549575474, 101.76674585993168876, 31.474162466132838745, 96.65784268175411853, + 20.400361428270116448, 46.80987500393166556, 119.73860698052885709, 108.5387720085818728, + 40.749168173053476494, 80.388776653078821255, 49.394861829972796841, 45.271979713455948513, + 45.535434027999144746, 113.16707780813158024, 102.89262930524273543, 53.805009806103043957, + 113.08057784282937064, 105.76114601556764683, 33.721209837684000377, 77.655861822768201819, + 73.207738949258782668, 104.51622158920508809, 108.17166171436110744, 125.92209003920288524, + 69.221825893211644143, 68.662974019924149616, 49.688072577799175633, 67.503221790138923097, + 96.352156539036514005, 97.8835431464794965, 83.840575260794139467, 26.46627964968138258, + 94.523527970937720966, 28.811987349166884087, 5.9468816575645178091, 98.746310478665691335, + 16.245487716481875395, 59.638758905948634492, 61.096443615806492744, 44.797812275624892209, + 73.936163246573414654, 12.677199589652445866, 8.6339213434148405213, 100.60640473725652555, + 56.15043043526384281, 84.506503471740870737, 100.23191291840703343, 52.970111061764328042, + 7.9744382210592448246, 35.950792566542077111, 32.620246165944990935, 100.97660316500696354, + 58.456562216251768405, 123.9521453367851791, 122.56881606082606595, 93.318285618388472358, + 2.7084295788117742632, 92.699406877862202236, 81.806544833456428023, 36.965485087199340342, + 105.33984053486710764, 17.29383310659613926, 83.0899552849768952, 7.8405369379033800215, + 84.46149017375864787, 12.262343546619376866, 88.266095342700282345, 81.390633939325198298, + 16.150520875227812212, 28.596024482390930643, 23.034836987921153195, 19.270324461111158598, + 32.823153874625859316, 38.476913063721440267, 20.410537200503313215, 111.04407958053707262, + 21.162722158805991057, 22.615740065441059414, 19.165546033073042054, 56.069309180918935454, + 16.972402244446129771, 44.156522885507001774, 39.427053428215003805, 8.8014736058357811999, + 86.873083225818845676, 64.276410335522086825, 18.525544030522723915, 57.23935871311914525, + 8.1475090211461065337, 78.55411386511332239, 64.205406024833791889, 106.78143331758110435, + 97.248194848638377152, 108.58249222228914732, 69.949323452201497275, 5.291000952467584284, + 15.66270339648326626, 98.584369436735869385, 8.2491786753453197889, 122.93392222294642124, + 55.113787109366967343, 0.39286700650336570106, 35.141509785276866751, 71.173010457241616677, + 68.069086638708540704, 68.519189622285921359, 86.546627530638943426, 71.34726031424725079, + 122.30569742756415508, 95.572322010884818155, 47.998963069196179276, 123.79596536385361105, + 83.410086256440990837, 79.155441863298619865, 104.78095744829261093, 40.710275585555791622, + 117.94910798186901957, 115.6229346490399621, 84.84360881946849986, 99.34085211176352459, + 2.2183205702713166829, 112.81146434577021864, 6.7644841936817101669, 5.4827945310571521986, + 76.760491032200661721, 4.0346678216046711896, 26.899633529606944649, 5.3347566673037363216, + 75.027646900241961703, 107.28033600826529437, 121.73286444817495067, 13.402616154016868677, + 14.32591006960865343, 21.443608517376560485, 126.05484765684013837, 122.04957148895846331, + 65.577848321270721499, 38.935228250680665951, 19.903379841092828428, 73.986177430608222494, + 72.243134630258282414, 38.927115608708845684, 6.4616019822205998935, 103.27516083073714981, + 106.04067056812345982, 12.275352846234454773, 60.450574122380203335, 8.8044935954640095588, + 83.853190100744541269, 99.927513184546114644, 120.92422993359650718, 42.9603918863213039, + 26.740292979557125363, 23.337062886410421925, 71.402596770178206498, 12.569796284788026242, + 42.177193611871189205, 48.684051327782071894, 126.38767744526194292, 24.335545658810588066, + 102.76556335276836762, 34.538699291817465564, 124.85047327753636637, 89.700454560890648281, + 111.04466424423299031, 41.741737495449342532, 81.048104923629580298, 12.698021276097279042, + 70.3591157509945333, 23.652800760202808306, 3.0254272102029062808, 74.046953323628258659, + 71.479489823563199025, 46.569888391659333138, 38.805201633676915662, 16.593440270131395664, + 85.129887917264568387, 83.947845846287236782, 107.56433608779116184, 113.52297676573653007, + 70.343245251031476073, 58.386180639103258727, 95.012127847014198778, 17.447590691605000757, + 86.583027149328700034, 66.467911844174523139, 64.575817247976374347, 103.06669754587710486, + 89.152245253400906222, 84.239476476461277343, 33.671813576482236385, 51.144649249410576886, + 7.6638276594567287248, 108.76525420904363273, 24.947276258793863235, 71.026552482460829196, + 34.522675112875731429, 50.041900356049154652, 5.1427973743884649593, 91.333055744380544638, + 16.996999544637219515, 49.289405458250257652, 40.192321692346013151, 83.633111687926430022, + 24.799651549219561275, 101.9607076560423593, 105.20533521678225952, 80.611759936291491613, + 109.75263931210429291, 60.145287348295823904, 30.888681769400136545, 48.209474633767968044, + 119.08704120747279376, 46.465855444745102432, 76.98411396538358531, 59.772093394101830199, + 119.70528617748277611, 81.945477438064699527, 4.0616683170774194878, 14.787063327628857223, + 46.625973031525063561, 21.145935431923135184, 33.690832410098664695, 29.324569053089362569, + 115.44778716756991344, 11.413897206399269635, 66.576673800591379404, 17.466505934269662248, + 59.457214162623131415, 86.705499794756178744, 82.824910736071615247, 21.020192785337712849, + 4.3078042575070867315, 44.744690214287402341, 110.92978086438597529, 112.01028106574449339, + 97.199690830486360937, 61.849509476272942265, 123.15831142945535248, 119.56366582549890154, + 20.388777687614492606, 23.233871946857107105, 98.703369830371229909, 1.4151652016153093427, + 116.03063584634583094, 63.990981639250094304, 108.19021864486057893, 46.948614977867691778, + 61.914070138609531568, 82.154133436899428489, 93.466375080228317529, 80.159127840270230081, + 65.695703358516766457, 41.253580310640245443, 5.2743433628602360841, 68.537461485851963516, + 108.88991431768590701, 64.512680290019488893, 1.1934817701439897064, 69.703595214599772589, + 16.024137611588230357, 73.184886626062507275, 75.580529834911430953, 77.665918656777648721, + 91.258162435864505824, 25.935737033032637555, 109.02727506064184126, 6.72174593771705986, + 87.001670689831371419, 100.83708860697515775, 96.790336529880732996, 78.749297052236215677, + 87.616999565761943813, 40.189463374797924189, 12.760641128003044287, 11.908074581660912372, + 89.620232443212444196, 28.8259060468772077, 73.484976427254878217, 70.666933661632356234, + 125.17990973451378522, 11.802617756409745198, 36.377219166199211031, 94.145730680676933844, + 55.216803906409040792, 4.6630171342476387508, 116.80208776121071423, 7.2527510813488333952, + 14.049993737931799842, 67.8526691571714764, 62.994386242233304074, 66.696955887353396975, + 46.123885119344777195, 124.47283063517534174, 116.2940553049556911, 36.831714694835682167, + 53.630512950010597706, 75.652463558748422656, 78.828783952922094613, 72.34654041844260064, + 114.99022565898121684, 91.908550705364177702, 121.32050901662660181, 5.3579330374450364616, + 104.22633752860565437, 97.523806268985936185, 41.710891153150441824, 54.23787870011801715, + 95.596258864279661793, 109.94928281671309378, 106.75896626002213452, 110.19842906928897719, + 125.06257862676284276, 5.6283775734300434124, 100.2275741287812707, 114.89510379813145846, + 43.208994466018339153, 117.33220656633420731, 9.8843802726223657373, 121.04723228784860112, + 46.115492444852861809, 33.643417884755763225, 61.2665845669216651, 38.241699017118662596, + 1.5237827465898590162, 12.831933636694884626, 39.27108888196744374, 80.743853745636442909, + 14.523253325107361889, 27.738642424723366275, 89.295124114236386959, 84.723938025475945324, + 10.249069448720547371, 64.692517524916183902, 61.488499998045881512, 45.536541767967719352, + 95.967165765814570477, 57.310217419675609563, 73.294319746924884384, 96.712424002198531525, + 99.977640540993888862, 99.632903425554104615, 98.492815640056505799, 0.28203020788714638911, + 13.714695910693990299, 63.067952002169477055, 96.209321117516083177, 2.78566487231728388, + 125.56008489676969475, 48.414845707829954335, 119.71895745670190081, 62.540339600924198749, + 50.061024126393022016, 124.84528512920587673, 91.220504081466060597, 97.871453144656697987, + 109.46920951388892718, 97.517180879916850245, 107.48299486303221784, 23.295581538463011384, + 114.07008196369861253, 97.914019224193907576, 92.973869578607263975, 69.746452339506504359, + 107.99977429010323249, 111.85565284108815831, 104.73036797969325562, 103.35820572742886725, + 115.31466992536661564, 119.87285099802102195, 54.664552145102788927, 75.533491719863377512, + 62.948324932269315468, 65.31568536350823706, 40.800722856540232897, 93.619750007866969099, + 111.47721396106135217, 89.077544017163745593, 81.498336346110590966, 32.77755330615764251, + 98.789723659945593681, 90.543959426911897026, 91.070868056001927471, 98.334155616266798461, + 77.785258610485470854, 107.61001961220972589, 98.161155685662379256, 83.522292031135293655, + 67.442419675371638732, 27.311723645540041616, 18.415477898521203315, 81.032443178413814167, + 88.343323428725852864, 123.84418007840940845, 10.443651786426926265, 9.3259480398482992314, + 99.376145155601989245, 7.0064435802814841736, 64.704313078076665988, 67.767086292962630978, + 39.681150521588278934, 52.932559299366403138, 61.047055941875441931, 57.623974698333768174, + 11.893763315132673597, 69.49262095733138267, 32.490975432963750791, 119.27751781189726898, + 122.19288723161298549, 89.595624551253422396, 19.872326493146829307, 25.354399179304891732, + 17.267842686833319021, 73.2128094745130511, 112.3008608705313236, 41.013006943485379452, + 72.463825836814066861, 105.94022212352865608, 15.948876442118489649, 71.901585133084154222, + 65.240492331893619848, 73.953206330013927072, 116.91312443250717479, 119.90429067357399617, + 117.13763212165576988, 58.636571236776944716, 5.4168591576271865051, 57.398813755728042452, + 35.613089666912856046, 73.930970174402318662, 82.679681069734215271, 34.587666213195916498, + 38.1799105699537904, 15.681073875810398022, 40.922980347517295741, 24.524687093242391711, + 48.532190685404202668, 34.781267878650396597, 32.301041750455624424, 57.192048964781861287, + 46.06967397584230639, 38.540648922222317196, 65.646307749251718633, 76.953826127442880534, + 40.82107440101026441, 94.088159161074145231, 42.325444317611982115, 45.231480130882118829, + 38.331092066146084107, 112.13861836183787091, 33.944804488892259542, 88.313045771014003549, + 78.85410685643000761, 17.602947211675200379, 45.746166451641329331, 0.55282067104417365044, + 37.05108806104544783, 114.4787174262382905, 16.295018042295851046, 29.108227730230282759, + 0.41081204967122175731, 85.562866635165846674, 66.496389697280392284, 89.164984444578294642, + 11.898646904402994551, 10.582001904935168568, 31.3254067929701705, 69.168738873471738771, + 16.498357350694277557, 117.86784444589284249, 110.22757421873393469, 0.78573401300673140213, + 70.28301957055737148, 14.346020914486871334, 8.138173277420719387, 9.0383792445754806977, + 45.093255061281524831, 14.694520628498139558, 116.61139485513194813, 63.144644021769636311, + 95.997926138395996531, 119.59193072771086008, 38.820172512885619653, 30.310883726600877708, + 81.561914896585221868, 81.420551171115221223, 107.89821596374167711, 103.24586929808356217, + 41.687217638940637698, 70.68170422352704918, 4.4366411405462713446, 97.622928691540437285, + 13.528968387363420334, 10.965589062117942376, 25.520982064401323441, 8.0693356432093423791, + 53.799267059213889297, 10.669513334611110622, 22.055293800487561384, 86.560672016534226714, + 115.46572889634990133, 26.805232308033737354, 28.65182013921730686, 42.887217034756758949, + 124.10969531368391472, 116.09914297792056459, 3.1556966425414429978, 77.870456501361331902, + 39.806759682189294836, 19.972354861220082967, 16.486269260516564827, 77.854231217417691369, + 12.923203964444837766, 78.550321661477937596, 84.081341136246919632, 24.550705692468909547, + 120.90114824476040667, 17.608987190931657096, 39.706380201492720516, 71.855026369095867267, + 113.84845986719301436, 85.920783772642607801, 53.480585959114250727, 46.674125772824481828, + 14.805193540356412996, 25.139592569576052483, 84.35438722374237841, 97.368102655567781767, + 124.77535489052388584, 48.67109131762481411, 77.531126705536735244, 69.077398583638569107, + 121.70094655507637071, 51.400909121784934541, 94.089328488465980627, 83.483474990902323043, + 34.096209847259160597, 25.396042552198196063, 12.718231501989066601, 47.305601520405616611, + 6.0508544204094505403, 20.093906647260155296, 14.958979647126398049, 93.139776783318666276, + 77.610403267353831325, 33.186880540266429307, 42.259775834532774752, 39.895691692578111542, + 87.128672175585961668, 99.045953531476698117, 12.686490502062952146, 116.77236127821015543, + 62.024255694028397556, 34.895181383213639492, 45.166054298661038047, 4.9358236883526842576, + 1.1516344959563866723, 78.133395091757847695, 50.304490506805450423, 40.478952952922554687, + 67.343627152964472771, 102.28929849882115377, 15.327655318917095428, 89.530508418087265454, + 49.894552517591364449, 14.053104964921658393, 69.045350225751462858, 100.0838007120983093, + 10.285594748780567897, 54.666111488761089277, 33.993999089274439029, 98.578810916500515305, + 80.384643384695664281, 39.266223375852860045, 49.599303098442760529, 75.921415312088356586, + 82.410670433568157023, 33.223519872586621204, 91.505278624208585825, 120.29057469659164781, + 61.777363538800273091, 96.418949267539574066, 110.17408241494558752, 92.931710889493842842, + 25.968227930767170619, 119.54418678820729838, 111.4105723549691902, 35.890954876129399054, + 8.1233366341548389755, 29.574126655257714447, 93.251946063050127123, 42.291870863846270368, + 67.381664820197329391, 58.649138106182363117, 102.89557433513982687, 22.827794412802177249, + 5.1533476011827588081, 34.933011868539324496, 118.91442832524990081, 45.410999589515995467, + 37.649821472143230494, 42.040385570675425697, 8.615608515014173463, 89.489380428578442661, + 93.859561728775588563, 96.020562131492624758, 66.399381660972721875, 123.69901895254952251, + 118.31662285891434294, 111.12733165099780308, 40.777555375228985213, 46.467743893717852188, + 69.406739660742459819, 2.8303304032342566643, 104.06127169269166188, 127.98196327850382659, + 88.380437289721157867, 93.897229955735383555, 123.82814027722270112, 36.308266873802494956, + 58.932750160460273037, 32.318255680544098141, 3.3914067170335329138, 82.507160621280490886, + 10.548686725724110147, 9.0749229717075650115, 89.779828635375451995, 1.0253605800389777869, + 2.3869635402916173916, 11.407190429199545179, 32.048275223180098692, 18.36977325212865253, + 23.161059669826499885, 27.331837313558935421, 54.516324871729011647, 51.871474066068913089, + 90.054550121283682529, 13.443491875437757699, 46.003341379666380817, 73.674177213953953469, + 65.580673059765103972, 29.498594104476069333, 47.233999131523887627, 80.378926749595848378, + 25.521282256006088573, 23.816149163325462723, 51.240464886424888391, 57.651812093758053379, + 18.969952854513394414, 13.333867323268350447, 122.35981946902757045, 23.605235512819490395, + 72.754438332402060041, 60.291461361353867687, 110.43360781281808158, 9.3260342684989154804, + 105.60417552242142847, 14.50550216269766679, 28.099987475867237663, 7.7053383143429527991, + 125.98877248447024613, 5.393911774706793949, 92.247770238693192368, 120.94566127035432146, + 104.5881106099113822, 73.663429389671364333, 107.26102590002483339, 23.304927117500483291, + 29.657567905847827205, 16.693080836888839258, 101.98045131796607166, 55.817101410731993383, + 114.64101803325320361, 10.715866074893710902, 80.452675057214946719, 67.047612537971872371, + 83.421782306300883647, 108.47575740023967228, 63.192517728562961565, 91.898565633429825539, + 85.517932520047907019, 92.396858138581592357, 122.12515725352568552, 11.256755146863724804, + 72.455148257566179382, 101.79020759626291692, 86.417988932040316286, 106.66441313266841462, + 19.768760545248369453, 114.09446457569720224, 92.230984889705723617, 67.286835769511526451, + 122.5331691338433302, 76.483398034237325191, 3.0475654931797180325, 25.663867273389769252, + 78.542177763938525459, 33.487707491272885818, 29.046506650214723777, 55.47728484945037053, + 50.590248228476411896, 41.447876050951890647, 20.49813889744473272, 1.3850350498323678039, + 122.97699999609176302, 91.073083535939076683, 63.934331531629140954, 114.6204348393548571, + 18.588639493853406748, 65.424848004400701029, 71.955281081991415704, 71.265806851111847209, + 68.985631280113011599, 0.56406041577429277822, 27.429391821387980599, 126.13590400434259209, + 64.418642235032166354, 5.5713297446382057387, 123.1201697935393895, 96.82969141566354665, + 111.43791491340380162, 125.0806792018483975, 100.12204825278968201, 121.69057025841539144, + 54.441008162935759174, 67.742906289317033952, 90.938419027781492332, 67.034361759837338468, + 86.965989726064435672, 46.591163076929660747, 100.14016392740086303, 67.82803844839145313, + 57.947739157218165928, 11.492904679016646696, 87.999548580210102955, 95.711305682179954601, + 81.460735959390149219, 78.716411454861372476, 102.62933985073686927, 111.7457019960420439, + 109.32910429020921583, 23.066983439726755023, 125.89664986454226892, 2.6313707270164741203, + 81.601445713084103772, 59.239500015737576177, 94.95442792212634231, 50.155088034331129165, + 34.996672692221181933, 65.555106612318922998, 69.579447319894825341, 53.087918853827432031, + 54.14173611200749292, 68.668311232537234901, 27.570517220974579686, 87.220039224423089763, + 68.32231137132839649, 39.044584062274225289, 6.8848393507432774641, 54.623447291080083232, + 36.830955797046044609, 34.064886356831266312, 48.686646857455343707, 119.6883601568188169, + 20.887303572853852529, 18.651896079700236442, 70.75229031120397849, 14.012887160566606326, + 1.4086261561569699552, 7.5341725859252619557, 79.362301043176557869, 105.86511859873280628, + 122.09411188375088386, 115.24794939666753635, 23.787526630268985173, 10.985241914662765339, + 64.98195086593113956, 110.55503562379817595, 116.38577446322960895, 51.191249102506844793, + 39.744652986293658614, 50.708798358609783463, 34.535685373670276022, 18.425618949029740179, + 96.601721741062647197, 82.026013886974396883, 16.9276516736317717, 83.880444247057312168, + 31.897752884240617277, 15.803170266171946423, 2.4809846637908776756, 19.906412660031492123, + 105.82624886501798755, 111.80858134715163033, 106.27526424331153976, 117.27314247355388943, + 10.83371831525437301, 114.7976275114560849, 71.226179333829350071, 19.861940348808275303, + 37.359362139468430541, 69.175332426391832996, 76.3598211399075808, 31.362147751620796043, + 81.845960695034591481, 49.049374186484783422, 97.064381370808405336, 69.562535757300793193, + 64.602083500911248848, 114.38409792956372257, 92.139347951684612781, 77.081297844448272372, + 3.2926154985070752446, 25.907652254885761067, 81.642148802024166798, 60.176318322148290463, + 84.650888635223964229, 90.462960261764237657, 76.662184132295806194, 96.277236723675741814, + 67.889608977788157063, 48.626091542031645076, 29.708213712860015221, 35.205894423350400757, + 91.492332903282658663, 1.1056413420883473009, 74.102176122094533639, 100.957434852476581, + 32.590036084591702092, 58.216455460460565519, 0.82162409934608149342, 43.125733270335331326, + 4.992779394564422546, 50.329968889160227263, 23.797293808805989102, 21.164003809870337136, + 62.650813585943978978, 10.337477746943477541, 32.996714701392193092, 107.73568889178932295, + 92.455148437467869371, 1.5714680260171007831, 12.566039141114742961, 28.692041828973742668, + 16.276346554841438774, 18.076758489150961395, 90.186510122563049663, 29.389041256999917096, + 105.22278971026389627, 126.2892880435429106, 63.995852276795631042, 111.18386145542172017, + 77.640345025771239307, 60.621767453205393394, 35.123829793174081715, 34.841102342234080425, + 87.796431927486992208, 78.491738596167124342, 83.374435277884913376, 13.36340844705409836, + 8.8732822810961806681, 67.24585738308087457, 27.057936774726840667, 21.931178124235884752, + 51.041964128802646883, 16.138671286418684758, 107.59853411842777859, 21.339026669222221244, + 44.110587600978760747, 45.121344033072091406, 102.93145779269980267, 53.610464616067474708, + 57.30364027843461372, 85.774434069517155876, 120.21939062737146742, 104.19828595584112918, + 6.3113932850865239743, 27.740913002722663805, 79.613519364378589671, 39.944709722440165933, + 32.972538521036767634, 27.708462434835382737, 25.84640792889331351, 29.100643322959513171, + 40.162682272493839264, 49.101411384941457072, 113.80229648952081334, 35.217974381863314193, + 79.412760402989079012, 15.710052738195372513, 99.696919734389666701, 43.841567545285215601, + 106.96117191822850145, 93.348251545648963656, 29.610387080712825991, 50.279185139155742945, + 40.708774447488394799, 66.736205311139201513, 121.55070978104777168, 97.342182635253266199, + 27.062253411077108467, 10.154797167280776193, 115.40189311015274143, 102.80181824357350706, + 60.178656976935599232, 38.966949981804646086, 68.192419694518321194, 50.792085104396392126, + 25.436463003978133202, 94.611203040811233222, 12.101708840818901081, 40.187813294520310592, + 29.917959294256434077, 58.27955356664097053, 27.220806534707662649, 66.373761080532858614, + 84.519551669065549504, 79.791383385159861064, 46.257344351175561314, 70.091907062953396235, + 25.372981004129542271, 105.54472255642031087, 124.04851138805679511, 69.790362766427278984, + 90.332108597322076093, 9.8716473767053685151, 2.3032689919164113235, 28.266790183515695389, + 100.60898101361090085, 80.957905905848747352, 6.6872543059325835202, 76.578596997642307542, + 30.655310637837828835, 51.061016836174530908, 99.789105035182728898, 28.106209929846954765, + 10.090700451506563695, 72.167601424196618609, 20.571189497561135795, 109.33222297752217855, + 67.987998178552516038, 69.157621833004668588, 32.769286769391328562, 78.532446751705720089, + 99.198606196889159037, 23.842830624180351151, 36.821340867136314046, 66.447039745176880388, + 55.010557248420809628, 112.58114939318329562, 123.55472707760418416, 64.837898535082786111, + 92.34816482989481301, 57.863421778987685684, 51.936455861537979217, 111.08837357641823473, + 94.821144709938380402, 71.781909752258798108, 16.246673268309677951, 59.148253310519066872, + 58.503892126100254245, 84.583741727696178714, 6.7633296403946587816, 117.29827621236836421, + 77.791148670279653743, 45.655588825604354497, 10.306695202365517616, 69.866023737082286971, + 109.82885665049980162, 90.821999179031990934, 75.299642944286460988, 84.080771141350851394, + 17.231217030031984905, 50.978760857160523301, 59.719123457554815104, 64.041124262988887494, + 4.7987633219490817282, 119.398037905102683, 108.63324571783232386, 94.254663301995606162, + 81.555110750457970425, 92.935487787439342355, 10.813479321484919637, 5.6606608064721513074, + 80.122543385386961745, 127.96392655701129115, 48.760874579445953714, 59.794459911474405089, + 119.65628055444540223, 72.616533747604989912, 117.86550032092054607, 64.636511361088196281, + 6.7828134340707038064, 37.014321242560981773, 21.097373451448220294, 18.149845943418768002, + 51.55965727075090399, 2.0507211600779555738, 4.7739270805832347833, 22.814380858399090357, + 64.096550446360197384, 36.73954650425730506, 46.32211933965299977, 54.663674627117870841, + 109.03264974345802329, 103.74294813214146416, 52.109100242567365058, 26.886983750875515398, + 92.006682759336399613, 19.348354427911544917, 3.1613461195302079432, 58.997188208952138666, + 94.467998263051413232, 32.757853499191696756, 51.042564512012177147, 47.632298326650925446, + 102.48092977284977678, 115.30362418751610676, 37.939905709026788827, 26.667734646540338872, + 116.7196389380551409, 47.21047102564261877, 17.508876664804120082, 120.58292272271137335, + 92.867215625636163168, 18.65206853700146894, 83.208351044842856936, 29.011004325395333581, + 56.199974951734475326, 15.410676628689543577, 123.97754496894049225, 10.787823549417225877, + 56.495540477390022716, 113.8913225407122809, 81.176221219826402375, 19.326858779346366646, + 86.522051800049666781, 46.609854235000966582, 59.315135811695654411, 33.386161673781316495, + 75.960902635932143312, 111.63420282146762474, 101.28203606650640722, 21.431732149791059783, + 32.905350114433531417, 6.0952250759473827202, 38.843564612605405273, 88.951514800479344558, + 126.38503545712956111, 55.797131266863289056, 43.035865040099452017, 56.793716277166822692, + 116.25031450705137104, 22.513510293731087586, 16.910296515135996742, 75.580415192529471824, + 44.83597786408427055, 85.328826265336829238, 39.537521090500376886, 100.18892915139804245, + 56.461969779415085213, 6.5736715390266908798, 117.06633826769029838, 24.966796068474650383, + 6.095130986359436065, 51.327734546783176484, 29.084355527877050918, 66.975414982545771636, + 58.093013300429447554, 110.95456969890074106, 101.18049645695282379, 82.895752101903781295, + 40.99627779488946544, 2.7700700996683735866, 117.95399999218716403, 54.146167071878153365, + 127.86866306326191989, 101.24086967870971421, 37.177278987710451474, 2.8496960088050400373, + 15.910562163986469386, 14.531613702227332396, 9.9712625602260231972, 1.1281208315485855564, + 54.858783642779599177, 124.27180800868882216, 0.83728447006433270872, 11.142659489280049456, + 118.24033958708241698, 65.659382831330731278, 94.875829826811241219, 122.16135840370043297, + 72.244096505583001999, 115.38114051683078287, 108.88201632587515633, 7.485812578637705883, + 53.876838055566622643, 6.0687235196783149149, 45.931979452128871344, 93.182326153862959472, + 72.280327854805364041, 7.6560768967829062603, 115.89547831443633186, 22.985809358036931371, + 47.999097160423843889, 63.422611364363547182, 34.921471918783936417, 29.432822909726382932, + 77.258679701477376511, 95.491403992087725783, 90.658208580418431666, 46.133966879457148025, + 123.79329972908453783, 5.2627414540365862194, 35.202891426168207545, 118.47900003147879033, + 61.908855844252684619, 100.31017606866225833, 69.993345384446001844, 3.1102132246414839756, + 11.158894639789650682, 106.17583770765486406, 108.28347222401862382, 9.336622465074469801, + 55.141034441952797351, 46.440078448849817505, 8.6446227426567929797, 78.089168124548450578, + 13.769678701486554928, 109.24689458216016646, 73.661911594092089217, 68.129772713662532624, + 97.373293714914325392, 111.37672031363763381, 41.774607145707705058, 37.303792159404110862, + 13.50458062240795698, 28.025774321133212652, 2.8172523123139399104, 15.06834517185416189, + 30.724602086356753716, 83.730237197469250532, 116.1882237675054057, 102.4958987933350727, + 47.575053260537970345, 21.970483829329168657, 1.9639017318659170996, 93.110071247599989874, + 104.77154892645921791, 102.38249820501368959, 79.489305972587317228, 101.41759671721956693, + 69.071370747340552043, 36.851237898063118337, 65.203443482128932374, 36.052027773948793765, + 33.85530334726718138, 39.760888494114624336, 63.795505768481234554, 31.606340532343892846, + 4.9619693275817553513, 39.812825320066622226, 83.652497730039613089, 95.617162694306898629, + 84.550528486626717495, 106.54628494710777886, 21.667436630512383999, 101.59525502291580779, + 14.452358667658700142, 39.723880697616550606, 74.718724278940499062, 10.350664852787303971, + 24.719642279815161601, 62.724295503245230066, 35.691921390069182962, 98.098748372973204823, + 66.128762741620448651, 11.125071514605224365, 1.2041670018261356745, 100.76819585913108313, + 56.27869590337286354, 26.162595688896544743, 6.5852309970141504891, 51.815304509775160113, + 35.284297604048333596, 120.3526366443002189, 41.301777270451566437, 52.925920523532113293, + 25.324368264595250366, 64.554473447355121607, 7.7792179555763141252, 97.252183084063290153, + 59.416427425720030442, 70.411788846704439493, 54.984665806565317325, 2.2112826841803325806, + 20.204352244192705257, 73.914869704953162, 65.180072169183404185, 116.43291092092113104, + 1.6432481986921629868, 86.251466540670662653, 9.9855587891288450919, 100.65993777832045453, + 47.594587617611978203, 42.328007619740674272, 125.30162717188795796, 20.674955493886955082, + 65.993429402788024163, 87.471377783582283882, 56.910296874935738742, 3.1429360520342015661, + 25.132078282229485922, 57.384083657947485335, 32.552693109682877548, 36.15351697830556077, + 52.373020245126099326, 58.77808251400347217, 82.445579420531430515, 124.5785760870858212, + 127.99170455359490006, 94.36772291084707831, 27.280690051542478614, 121.24353490641078679, + 70.24765958634816343, 69.682204684471798828, 47.592863854977622395, 28.983477192337886663, + 38.748870555769826751, 26.72681689410819672, 17.746564562195999315, 6.4917147661617491394, + 54.115873549453681335, 43.862356248471769504, 102.08392825760529377, 32.277342572841007495, + 87.197068236855557188, 42.678053338444442488, 88.221175201957521494, 90.242688066147820791, + 77.862915585399605334, 107.22092923213494942, 114.60728055687286542, 43.548868139037949732, + 112.43878125474657281, 80.39657191168225836, 12.622786570173047949, 55.481826005448965589, + 31.227038728757179342, 79.889419444880331866, 65.945077042073535267, 55.416924869670765474, + 51.692815857786627021, 58.201286645919026341, 80.325364544987678528, 98.202822769886552123, + 99.604592979041626677, 70.435948763730266364, 30.825520805978158023, 31.420105476394383004, + 71.393839468779333401, 87.683135090574069181, 85.922343836460640887, 58.696503091297927313, + 59.220774161425651982, 100.55837027831148589, 81.417548894980427576, 5.4724106222820410039, + 115.10141956209918135, 66.684365270506532397, 54.124506822154216934, 20.309594334565190366, + 102.80378622030912084, 77.603636487147014122, 120.35731395387119846, 77.933899963612930151, + 8.3848393890366423875, 101.58417020879278425, 50.872926007959904382, 61.222406081622466445, + 24.203417681637802161, 80.375626589040621184, 59.835918588512868155, 116.55910713328194106, + 54.441613069418963278, 4.7475221610693552066, 41.039103338134736987, 31.582766770319722127, + 92.514688702354760608, 12.183814125906792469, 50.74596200826272252, 83.089445112844259711, + 120.0970227761172282, 11.580725532858195947, 52.664217194644152187, 19.74329475341073703, + 4.6065379838328226469, 56.533580367035028758, 73.21796202722543967, 33.915811811697494704, + 13.374508611868805019, 25.157193995284615085, 61.310621275675657671, 102.1220336723526998, + 71.578210070365457796, 56.21241985969390953, 20.181400903016765369, 16.335202848393237218, + 41.142378995125909569, 90.664445955047995085, 7.975996357108670054, 10.315243666009337176, + 65.538573538786295103, 29.064893503415078158, 70.397212393778318074, 47.685661248360702302, + 73.64268173427626607, 4.8940794903537607752, 110.02111449684525724, 97.162298786370229209, + 119.1094541552120063, 1.6757970701692102011, 56.696329659789626021, 115.72684355797537137, + 103.87291172307959641, 94.176747152840107447, 61.642289419880398782, 15.563819504517596215, + 32.493346536619355902, 118.29650662103813374, 117.00778425220414647, 41.167483455392357428, + 13.526659280792955542, 106.5965524247403664, 27.582297340559307486, 91.311177651208708994, + 20.613390404734673211, 11.73204747416821192, 91.657713301003241213, 53.643998358067619847, + 22.599285888576559955, 40.161542282701702788, 34.46243406006396981, 101.9575217143210466, + 119.43824691511326819, 0.08224852597777498886, 9.5975266439018014353, 110.79607581020900398, + 89.266491435668285703, 60.509326603994850302, 35.11022150091957883, 57.870975574878684711, + 21.626958642969839275, 11.321321612947940594, 32.245086770777561469, 127.9278531140225823, + 97.521749158891907427, 119.58891982295244816, 111.31256110889444244, 17.233067495213617804, + 107.73100064184473013, 1.2730227221763925627, 13.565626868141407613, 74.028642485121963546, + 42.194746902896440588, 36.299691886837536003, 103.11931454150180798, 4.1014423201559111476, + 9.5478541611664695665, 45.628761716801818693, 0.19310089272039476782, 73.479093008514610119, + 92.64423867930599954, 109.32734925423937966, 90.065299486919684568, 79.485896264282928314, + 104.21820048513473012, 53.773967501754668774, 56.013365518672799226, 38.696708855823089834, + 6.3226922390604158863, 117.99437641790791531, 60.935996526102826465, 65.515706998383393511, + 102.08512902402435429, 95.264596653305488871, 76.961859545703191543, 102.60724837503221352, + 75.879811418053577654, 53.335469293084315723, 105.4392778761102818, 94.42094205128523754, + 35.017753329611878144, 113.16584544542638469, 57.734431251272326335, 37.304137074006575858, + 38.416702089685713872, 58.022008650790667161, 112.39994990346895065, 30.821353257382725133, + 119.95508993788098451, 21.575647098834451754, 112.99108095478368341, 99.782645081428199774, + 34.352442439652804751, 38.65371755869637127, 45.044103600099333562, 93.219708470001933165, + 118.63027162339130882, 66.772323347566270968, 23.921805271867924603, 95.268405642938887468, + 74.564072133012814447, 42.863464299582119565, 65.810700228867062833, 12.19045015189476544, + 77.687129225214448525, 49.903029600962327095, 124.77007091425912222, 111.59426253372657811, + 86.071730080198904034, 113.58743255433728336, 104.50062901410274208, 45.027020587462175172, + 33.820593030275631463, 23.160830385058943648, 89.671955728172179079, 42.657652530673658475, + 79.07504218100439175, 72.377858302796084899, 112.92393955883017043, 13.147343078057019738, + 106.13267653538059676, 49.933592136949300766, 12.19026197271887213, 102.65546909356635297, + 58.168711055757739814, 5.9508299650915432721, 116.18602660086253309, 93.909139397805120097, + 74.360992913909285562, 37.79150420380756259, 81.99255558977893088, 5.540140199340385152, + 107.90799998437432805, 108.29233414375994471, 127.73732612652747775, 74.481739357419428416, + 74.354557975420902949, 5.6993920176100800745, 31.821124327972938772, 29.063227404454664793, + 19.942525120452046394, 2.2562416630971711129, 109.71756728556283633, 120.54361601737764431, + 1.6745689401286654174, 22.285318978563736891, 108.48067917416847195, 3.3187656626651005354, + 61.751659653626120416, 116.32271680740450392, 16.488193011169641977, 102.76228103366520372, + 89.764032651750312652, 14.971625157275411766, 107.75367611113324529, 12.13744703935662983, + 91.863958904261380667, 58.364652307729556924, 16.560655709610728081, 15.312153793569450499, + 103.79095662887266371, 45.971618716073862743, 95.998194320847687777, 126.84522272872709436, + 69.842943837567872833, 58.865645819456403842, 26.517359402958391001, 62.982807984179089544, + 53.316417160836863331, 92.267933758917934028, 119.58659945816907566, 10.525482908073172439, + 70.405782852340053068, 108.95800006295758067, 123.81771168850900722, 72.62035213732815464, + 11.986690768892003689, 6.2204264492829679511, 22.317789279582939344, 84.351675415313366102, + 88.566944448037247639, 18.673244930148939602, 110.2820688839055947, 92.88015689769963501, + 17.289245485317223938, 28.178336249096901156, 27.539357402976747835, 90.493789164323970908, + 19.323823188187816413, 8.2595454273287032265, 66.746587429832288763, 94.753440627275267616, + 83.549214291415410116, 74.607584318808221724, 27.00916124481591396, 56.051548642266425304, + 5.6345046246278798208, 30.13669034370832378, 61.449204172717145411, 39.460474394942139043, + 104.37644753501444939, 76.991797586670145392, 95.150106521075940691, 43.940967658658337314, + 3.9278034637354721781, 58.220142495203617727, 81.543097852922073798, 76.764996410031017149, + 30.978611945178272435, 74.835193434442771832, 10.142741494681104086, 73.702475796129874652, + 2.4068869642578647472, 72.10405554789758753, 67.710606694534362759, 79.521776988229248673, + 127.59101153696246911, 63.212681064687785693, 9.9239386551635107026, 79.62565064013688243, + 39.304995460082864156, 63.234325388617435237, 41.101056973257072968, 85.092569894215557724, + 43.334873261028405977, 75.190510045831615571, 28.904717335317400284, 79.44776139523673919, + 21.437448557880998123, 20.701329705574607942, 49.439284559630323201, 125.44859100649046013, + 71.383842780142003903, 68.197496745950047625, 4.2575254832408973016, 22.250143029210448731, + 2.4083340036559093278, 73.53639171826216625, 112.55739180674572708, 52.325191377793089487, + 13.170461994028300978, 103.63060901955032023, 70.568595208100305172, 112.70527328860043781, + 82.603554540903132875, 105.85184104706422659, 50.648736529194138711, 1.1089468947102432139, + 15.558435911156266229, 66.504366168126580305, 118.83285485144369886, 12.823577693408878986, + 109.96933161313063465, 4.4225653683606651612, 40.408704488389048493, 19.829739409909961978, + 2.3601443383704463486, 104.86582184184226207, 3.2864963973879639525, 44.502933081341325305, + 19.971117578261328163, 73.319875556644547032, 95.189175235223956406, 84.656015239484986523, + 122.60325434377591591, 41.349910987777548144, 3.9868588055796863046, 46.942755567164567765, + 113.82059374987147748, 6.2858721040684031323, 50.264156564458971843, 114.76816731589497067, + 65.105386219365755096, 72.307033956611121539, 104.74604049025219865, 117.55616502801058232, + 36.891158841066499008, 121.15715217417528038, 127.9834091071934381, 60.735445821694156621, + 54.561380103088595206, 114.48706981282521156, 12.495319172699964838, 11.364409368943597656, + 95.185727709955244791, 57.966954384675773326, 77.497741111539653502, 53.453633788216393441, + 35.49312912439199863, 12.983429532323498279, 108.23174709890736267, 87.724712496947176987, + 76.167856515210587531, 64.554685145685652969, 46.394136473711114377, 85.356106676892522955, + 48.442350403918680968, 52.485376132299279561, 27.725831170802848646, 86.441858464273536811, + 101.21456111374573084, 87.097736278079537442, 96.877562509496783605, 32.79314382336451672, + 25.245573140346095897, 110.96365201089793118, 62.454077457517996663, 31.778838889764301712, + 3.8901540841470705345, 110.83384973934153095, 103.38563171557325404, 116.40257329184169066, + 32.650729089978995034, 68.405645539776742226, 71.209185958086891333, 12.871897527460532729, + 61.651041611956316046, 62.840210952792403987, 14.787678937562304782, 47.366270181151776342, + 43.844687672921281774, 117.39300618259585463, 118.44154832285494194, 73.116740556626609759, + 34.835097789960855152, 10.944821244567719987, 102.20283912420200068, 5.3687305410130647942, + 108.24901364430843387, 40.61918866913401871, 77.60757244062187965, 27.207272974297666224, + 112.71462790774603491, 27.867799927225860301, 16.769678778076922754, 75.168340417585568503, + 101.74585201591980876, 122.44481216324493289, 48.406835363279242301, 32.751253178081242368, + 119.67183717702937429, 105.11821426656388212, 108.88322613883792656, 9.4950443221387104131, + 82.078206676269473974, 63.165533540643082233, 57.029377404709521215, 24.367628251813584939, + 101.49192401652908302, 38.178890225692157401, 112.19404555223445641, 23.161451065716391895, + 105.32843438928830437, 39.48658950682147406, 9.2130759676656452939, 113.06716073407369549, + 18.435924054450879339, 67.831623623394989409, 26.749017223737610038, 50.314387990569230169, + 122.62124255135495332, 76.24406734470903757, 15.156420140730915591, 112.42483971938781906, + 40.362801806033530738, 32.670405696786474437, 82.284757990255457116, 53.32889191009599017, + 15.951992714217340108, 20.63048733202231233, 3.0771470775725902058, 58.129787006833794294, + 12.794424787556636147, 95.371322496725042583, 19.28536346855253214, 9.7881589807111595292, + 92.04222899369415245, 66.324597572744096396, 110.2189083104240126, 3.3515941403384204023, + 113.39265931958289002, 103.45368711595438072, 79.745823446162830805, 60.353494305680214893, + 123.28457883976079756, 31.12763900903519243, 64.986693073242349783, 108.59301324207990547, + 106.01556850440829294, 82.334966910784714855, 27.053318561589549063, 85.19310484948073281, + 55.16459468112225295, 54.622355302417417988, 41.226780809469346423, 23.464094948340061819, + 55.315426602006482426, 107.28799671613523969, 45.198571777153119911, 80.323084565403405577, + 68.924868120131577598, 75.915043428645731183, 110.87649383022653637, 0.16449705195554997772, + 19.195053287807240849, 93.59215162042164593, 50.532982871336571407, 121.0186532079897006, + 70.22044300183915766, 115.74195114975736942, 43.25391728593967855, 22.642643225895881187, + 64.490173541558760917, 127.85570622804880259, 67.043498317787452834, 111.17783964590853429, + 94.625122217788884882, 34.466134990430873586, 87.462001283689460251, 2.5460454443527851254, + 27.131253736286453204, 20.057284970243927091, 84.389493805792881176, 72.599383773678709986, + 78.23862908300361596, 8.2028846403118222952, 19.095708322332939133, 91.257523433603637386, + 0.38620178544442751445, 18.958186017032858217, 57.288477358615637058, 90.654698508482397301, + 52.130598973843007116, 30.971792528569494607, 80.436400970269460231, 107.54793500350933755, + 112.02673103734559845, 77.393417711646179669, 12.645384478124469751, 107.98875283581583062, + 121.87199305220929091, 3.0314139967704250012, 76.170258048052346567, 62.529193306614615722, + 25.923719091410021065, 77.214496750068065012, 23.759622836107155308, 106.67093858617226942, + 82.878555752224201569, 60.841884102570475079, 70.035506659227394266, 98.331690890852769371, + 115.46886250254465267, 74.608274148013151716, 76.833404179371427745, 116.0440173015849723, + 96.799899806937901303, 61.642706514769088244, 111.91017987576196902, 43.151294197672541486, + 97.982161909571004799, 71.565290162856399547, 68.704884879305609502, 77.307435117392742541, + 90.088207200202305103, 58.439416940007504309, 109.26054324678625562, 5.5446466951325419359, + 47.843610543739487184, 62.536811285881412914, 21.128144266025628895, 85.72692859916787711, + 3.6214004577341256663, 24.38090030379316886, 27.374258450428897049, 99.806059201928292168, + 121.54014182852188242, 95.188525067456794204, 44.143460160401446046, 99.174865108678204706, + 81.001258028205484152, 90.054041174924350344, 67.641186060551262926, 46.321660770121525275, + 51.343911456344358157, 85.315305061350954929, 30.150084362012421479, 16.755716605595807778, + 97.847879117660340853, 26.294686156117677456, 84.265353070761193521, 99.867184273898601532, + 24.380523945441382239, 77.310938187132705934, 116.33742211151547963, 11.901659930186724523, + 104.37205320172870415, 59.818278795613878174, 20.721985827818571124, 75.583008407618763158, + 35.98511117955786176, 11.080280398684408283, 87.81599996875229408, 88.584668287523527397, + 127.47465225305859349, 20.96347871484249481, 20.709115950841805898, 11.398784035220160149, + 63.642248655945877545, 58.126454808909329586, 39.885050240904092789, 4.5124833261979802046, + 91.435134571129310643, 113.08723203475528862, 3.3491378802573308349, 44.570637957131111762, + 88.961358348336943891, 6.6375313253302010708, 123.50331930725587881, 104.64543361480900785, + 32.976386022342921933, 77.524562067334045423, 51.528065303500625305, 29.943250314554461511, + 87.507352222266490571, 24.274894078716897639, 55.727917808522761334, 116.72930461545911385, + 33.121311419221456163, 30.624307587142538978, 79.581913257745327428, 91.943237432151363464, + 63.996388641699013533, 125.69044545745782671, 11.685887675135745667, 117.73129163891280768, + 53.034718805916782003, 125.96561596835817909, 106.63283432167736464, 56.535867517839506036, + 111.17319891633815132, 21.050965816149982857, 12.811565704683744116, 89.916000125918799313, + 119.63542337702165241, 17.240704274656309281, 23.973381537784007378, 12.440852898565935902, + 44.635578559169516666, 40.703350830630370183, 49.133888896074495278, 37.346489860301517183, + 92.564137767814827384, 57.76031379539927002, 34.578490970634447876, 56.356672498193802312, + 55.078714805957133649, 52.987578328647941817, 38.647646376375632826, 16.519090854661044432, + 5.4931748596682155039, 61.506881254554173211, 39.098428582834458211, 21.215168637616443448, + 54.018322489631827921, 112.10309728453285061, 11.269009249255759642, 60.273380687416647561, + 122.89840834543429082, 78.920948789887916064, 80.752895070032536751, 25.983595173343928764, + 62.300213042151881382, 87.881935317316674627, 7.8556069274709443562, 116.44028499041087343, + 35.086195705847785575, 25.529992820062034298, 61.95722389036018285, 21.670386868885543663, + 20.285482989365846151, 19.404951592259749305, 4.8137739285193674732, 16.208111095798813039, + 7.4212133890723634977, 31.043553976462135324, 127.18202307392493822, 126.42536212937557139, + 19.847877310330659384, 31.25130128027376486, 78.609990920165728312, 126.46865077723487047, + 82.202113946517783916, 42.185139788431115448, 86.669746522060449934, 22.381020091663231142, + 57.809434670638438547, 30.895522790473478381, 42.874897115761996247, 41.402659411149215885, + 98.878569119264284382, 122.89718201298455824, 14.767685560287645785, 8.3949934919000952505, + 8.5150509664817946032, 44.500286058420897461, 4.8166680073154566344, 19.07278343652797048, + 97.114783613491454162, 104.65038275558617897, 26.340923988060239935, 79.261218039104278432, + 13.137190416204248322, 97.410546577204513596, 37.207109081809903728, 83.703682094128453173, + 101.29747305838827742, 2.2178937894204864278, 31.116871822316170437, 5.0087323362567985896, + 109.66570970288739773, 25.64715538682139595, 91.938663226261269301, 8.8451307367213303223, + 80.817408976778096985, 39.659478819819923956, 4.7202886767445306759, 81.731643683684524149, + 6.572992794775927905, 89.005866162682650611, 39.942235156526294304, 18.639751113292732043, + 62.378350470451550791, 41.312030478973611025, 117.20650868755183183, 82.699821975555096287, + 7.9737176111593726091, 93.885511134332773509, 99.641187499742954969, 12.571744208136806265, + 100.52831312892158167, 101.53633463179357932, 2.210772438735148171, 16.614067913225881057, + 81.492080980508035282, 107.11233005602116464, 73.782317682136635995, 114.31430434835419874, + 127.96681821438687621, 121.47089164338831324, 109.12276020618082839, 100.97413962565042311, + 24.990638345399929676, 22.72881873789083329, 62.371455419910489582, 115.93390876935518463, + 26.995482223079307005, 106.90726757643278688, 70.98625824878399726, 25.966859064650634537, + 88.463494197818363318, 47.449424993897991953, 24.335713030424813041, 1.1093702913713059388, + 92.788272947425866732, 42.712213353785045911, 96.884700807837361936, 104.97075226459855912, + 55.451662341609335272, 44.8837169285507116, 74.429122227495099651, 46.195472556162712863, + 65.75512501899356721, 65.58628764672903344, 50.491146280695829773, 93.927304021795862354, + 124.90815491503599333, 63.557677779528603423, 7.7803081682977790479, 93.667699478686699877, + 78.771263431150146062, 104.80514658368338132, 65.301458179961628048, 8.8112910795571224298, + 14.418371916173782665, 25.743795054921065457, 123.30208322391263209, 125.68042190558480797, + 29.575357875124609563, 94.732540362303552683, 87.689375345846201526, 106.78601236519534723, + 108.88309664571352187, 18.233481113253219519, 69.670195579921710305, 21.889642489139077952, + 76.405678248404001351, 10.737461082029767567, 88.498027288616867736, 81.238377338271675399, + 27.215144881243759301, 54.414545948598970426, 97.429255815492069814, 55.735599854451720603, + 33.539357556157483486, 22.336680835174774984, 75.491704031843255507, 116.88962432648986578, + 96.813670726558484603, 65.502506356166122714, 111.34367435406238656, 82.236428533131402219, + 89.766452277675853111, 18.990088644281058805, 36.156413352538947947, 126.33106708128616447, + 114.05875480941904243, 48.735256503630807856, 74.983848033058166038, 76.35778045138795278, + 96.388091104468912818, 46.322902131436421769, 82.656868778576608747, 78.973179013642948121, + 18.426151935334928567, 98.134321468147390988, 36.871848108905396657, 7.6632472467899788171, + 53.498034447475220077, 100.62877598114209832, 117.24248510271354462, 24.488134689418075141, + 30.312840281465469161, 96.849679438775638118, 80.725603612067061476, 65.340811393576586852, + 36.569515980510914233, 106.65778382019198034, 31.903985428434680216, 41.26097466404462466, + 6.1542941551451804116, 116.25957401366758859, 25.588849575116910273, 62.742644993450085167, + 38.57072693710506428, 19.576317961425957037, 56.084457987391942879, 4.6491951454918307718, + 92.437816620848025195, 6.7031882806804787833, 98.78531863916941802, 78.907374231912399409, + 31.491646892325661611, 120.70698861136406776, 118.56915767952159513, 62.255278018074022839, + 1.9733861464883375447, 89.186026484163448913, 84.031137008820223855, 36.669933821569429711, + 54.106637123182736104, 42.38620969896146562, 110.3291893622445059, 109.24471060483483598, + 82.453561618938692845, 46.928189896680123638, 110.63085320401660283, 86.575993432270479389, + 90.3971435543098778, 32.646169130810449133, 9.8497362402667931747, 23.830086857295100344, + 93.752987660453072749, 0.32899410391109995544, 38.390106575618119678, 59.18430324084329186, + 101.06596574267678079, 114.03730641598303919, 12.440886003681953298, 103.48390229951473884, + 86.5078345718793571, 45.285286451795400353, 0.98034708312115981244, 127.71141245610124315, + 6.0869966355785436463, 94.355679291820706567, 61.250244435577769764, 68.932269980865385151, + 46.924002567378920503, 5.0920908887055702507, 54.262507472572906408, 40.114569940491492162, + 40.778987611589400331, 17.19876754736105795, 28.477258166007231921, 16.40576928062364459, + 38.191416644669516245, 54.515046867207274772, 0.7724035708888550289, 37.916372034065716434, + 114.5769547172349121, 53.309397016964794602, 104.26119794768601423, 61.943585057142627193, + 32.872801940542558441, 87.095870007022313075, 96.053462074694834882, 26.786835423292359337, + 25.290768956252577482, 87.977505671635299223, 115.74398610441858182, 6.0628279935444879811, + 24.340516096104693133, 125.05838661322923144, 51.847438182823680108, 26.428993500136130024, + 47.519245672217948595, 85.341877172348176828, 37.757111504448403139, 121.68376820514458814, + 12.071013318458426511, 68.663381781709176721, 102.93772500509294332, 21.216548296029941412, + 25.666808358746493468, 104.08803460317358258, 65.599799613875802606, 123.28541302954181447, + 95.82035975152393803, 86.302588395348720951, 67.964323819145647576, 15.130580325716437073, + 9.4097697586148569826, 26.61487023478912306, 52.176414400404610205, 116.8788338800186466, + 90.521086493572511245, 11.089293390265083872, 95.687221087478974368, 125.07362257176282583, + 42.256288532054895768, 43.453857198335754219, 7.2428009154682513326, 48.761800607586337719, + 54.748516900861432077, 71.612118403860222315, 115.08028365704740281, 62.377050134913588408, + 88.286920320806530071, 70.349730217360047391, 34.002516056414606282, 52.108082349852338666, + 7.2823721211025258526, 92.643321540243050549, 102.68782291269235429, 42.630610122701909859, + 60.300168724024842959, 33.511433211195253534, 67.695758235320681706, 52.58937231223899289, + 40.530706141526025021, 71.734368547797203064, 48.761047890886402456, 26.621876374269049847, + 104.67484422303095926, 23.803319860377087025, 80.744106403457408305, 119.63655759122775635, + 41.443971655640780227, 23.166016815237526316, 71.970222359115723521, 22.160560797372454545, + 47.631999937508226139, 49.169336575050692772, 126.94930450611718697, 41.92695742968498962, + 41.418231901683611795, 22.797568070440320298, 127.28449731189175509, 116.25290961781865917, + 79.770100481808185577, 9.024966652399598388, 54.870269142262259265, 98.174464069510577247, + 6.6982757605146616697, 89.141275914265861502, 49.922716696673887782, 13.27506265066404012, + 119.0066386145153956, 81.290867229618015699, 65.952772044689481845, 27.049124134668090846, + 103.05613060700125061, 59.886500629112561001, 47.014704444532981142, 48.549788157433795277, + 111.45583561704916065, 105.45860923091822769, 66.242622838442912325, 61.248615174288715934, + 31.163826515494292835, 55.886474864302726928, 127.99277728340166504, 123.38089091491565341, + 23.371775350275129313, 107.46258327782561537, 106.06943761183720198, 123.93123193671999616, + 85.265668643354729284, 113.07173503568265005, 94.346397832676302642, 42.101931632299965713, + 25.62313140937112621, 51.832000251841236604, 111.27084675404330483, 34.481408549312618561, + 47.946763075568014756, 24.881705797131871805, 89.271157118339033332, 81.406701661260740366, + 98.267777792148990557, 74.692979720606672345, 57.128275535629654769, 115.52062759079854004, + 69.156981941268895753, 112.71334499638760462, 110.1574296119142673, 105.97515665729588363, + 77.295292752751265652, 33.038181709322088864, 10.986349719336431008, 123.01376250910834642, + 78.196857165668916423, 42.430337275232886896, 108.03664497926729382, 96.206194569065701216, + 22.538018498511519283, 120.5467613748369331, 117.79681669087221962, 29.841897579779470107, + 33.505790140065073501, 51.967190346687857527, 124.60042608430740074, 47.763870634633349255, + 15.711213854945526691, 104.88056998082174687, 70.172391411695571151, 51.059985640124068595, + 123.9144477807203657, 43.340773737771087326, 40.570965978731692303, 38.809903184519498609, + 9.6275478570387349464, 32.416222191597626079, 14.842426778144726995, 62.087107952927908627, + 126.36404614785351441, 124.85072425875114277, 39.695754620661318768, 62.502602560551167699, + 29.219981840335094603, 124.93730155447337893, 36.404227893035567831, 84.370279576865868876, + 45.339493044120899867, 44.762040183326462284, 115.61886934127687709, 61.791045580946956761, + 85.749794231523992494, 82.805318822302069748, 69.757138238532206742, 117.79436402596911648, + 29.53537112057529157, 16.789986983800190501, 17.030101932963589206, 89.000572116841794923, + 9.6333360146309132688, 38.145566873059578938, 66.229567226986546302, 81.300765511172357947, + 52.681847976124117849, 30.522436078208556864, 26.274380832412134623, 66.821093154409027193, + 74.414218163623445434, 39.407364188260544324, 74.594946116776554845, 4.4357875788409728557, + 62.233743644632340875, 10.017464672517235158, 91.33141940577479545, 51.29431077364642988, + 55.877326452522538602, 17.690261473446298623, 33.63481795355619397, 79.318957639639847912, + 9.4405773534926993307, 35.463287367369048297, 13.145985589555493789, 50.011732325365301222, + 79.884470313052588608, 37.279502226585464086, 124.75670094090310158, 82.624060957950860029, + 106.41301737510730163, 37.399643951110192575, 15.947435222322383197, 59.771022268669184996, + 71.282374999485909939, 25.143488416277250508, 73.056626257846801309, 75.072669263587158639, + 4.4215448774702963419, 33.228135826455400093, 34.984161961019708542, 86.224660112045967253, + 19.564635364276909968, 100.62860869671203545, 127.93363642877739039, 114.94178328678026446, + 90.24552041236529476, 73.948279251300846227, 49.981276690799859352, 45.457637475781666581, + 124.74291083982461714, 103.86781753871036926, 53.990964446162251988, 85.814535152869211743, + 13.97251649756799452, 51.933718129304907052, 48.926988395636726636, 94.898849987795983907, + 48.671426060849626083, 2.2187405827462498564, 57.576545894851733465, 85.4244267075737298, + 65.76940161567836185, 81.941504529197118245, 110.90332468321867054, 89.767433857105061179, + 20.858244454990199301, 92.390945112329063704, 3.5102500379907723982, 3.1725752934580668807, + 100.98229256139529753, 59.854608043595362687, 121.81630983007198665, 127.11535555905720685, + 15.560616336599196075, 59.335398957377037732, 29.542526862303930102, 81.610293167370400624, + 2.6029163599232560955, 17.62258215911424486, 28.836743832347565331, 51.487590109845768893, + 118.60416644782890216, 123.36084381116961595, 59.150715750252857106, 61.465080724610743346, + 47.378750691696041031, 85.572024730394332437, 89.766193291427043732, 36.466962226510077016, + 11.34039115984342061, 43.779284978281793883, 24.811356496808002703, 21.474922164063173113, + 48.996054577237373451, 34.476754676543350797, 54.430289762487518601, 108.82909189720157883, + 66.858511630984139629, 111.47119970890344121, 67.078715112314966973, 44.673361670353187947, + 22.983408063690148992, 105.77924865298336954, 65.627341453120607184, 3.0050127123358834069, + 94.68734870812841109, 36.472857066266442416, 51.532904555351706222, 37.98017728856211761, + 72.312826705081533873, 124.66213416257596691, 100.11750961883808486, 97.470513007265253691, + 21.967696066119970055, 24.71556090277954354, 64.776182208937825635, 92.645804262876481516, + 37.313737557156855473, 29.946358027285896242, 36.852303870673495112, 68.268642936294781975, + 73.743696217810793314, 15.326494493579957634, 106.99606889495407813, 73.257551962287834613, + 106.48497020542708924, 48.976269378836150281, 60.625680562934576301, 65.699358877554914216, + 33.451207224137760932, 2.6816227871531737037, 73.139031961025466444, 85.315567640383960679, + 63.807970856869360432, 82.52194932808924932, 12.308588310293998802, 104.51914802733517718, + 51.177699150233820546, 125.48528998690017033, 77.141453874210128561, 39.152635922851914074, + 112.16891597478388576, 9.2983902909872995224, 56.875633241696050391, 13.406376561364595545, + 69.570637278342474019, 29.814748463824798819, 62.9832937846549612, 113.41397722273177351, + 109.13831535904319026, 124.51055603614804568, 3.9467722929803130683, 50.372052968330535805, + 40.06227401764044771, 73.339867643138859421, 108.21327424636547221, 84.772419397926569218, + 92.658378724492649781, 90.489421209673309932, 36.907123237877385691, 93.856379793363885256, + 93.261706408036843641, 45.151986864544596756, 52.7942871086197556, 65.292338261620898265, + 19.699472480533586349, 47.660173714593838667, 59.505975320906145498, 0.65798820782219991088, + 76.780213151236239355, 118.3686064816902217, 74.131931485357199563, 100.07461283196607837, + 24.881772007367544575, 78.967804599033115664, 45.015669143758714199, 90.570572903590800706, + 1.9606941662459576037, 127.4228249122024863, 12.173993271160725271, 60.711358583641413134, + 122.50048887115917751, 9.8645399617307703011, 93.848005134757841006, 10.184181777411140501, + 108.52501494514581282, 80.229139880982984323, 81.557975223178800661, 34.3975350947221159, + 56.954516332014463842, 32.811538561247289181, 76.38283328933903249, 109.03009373441454954, + 1.5448071417777100578, 75.832744068135070847, 101.15390943446982419, 106.61879403393322718, + 80.522395895372028463, 123.88717011428525439, 65.745603881088754861, 46.191740014048264129, + 64.106924149389669765, 53.573670846584718674, 50.581537912508792942, 47.955011343274236424, + 103.48797220883716363, 12.125655987088975962, 48.681032192213024246, 122.11677322645846289, + 103.69487636564736022, 52.857987000272260047, 95.038491344439535169, 42.683754344696353655, + 75.514223008900444256, 115.36753641028917627, 24.142026636920491001, 9.3267635634219914209, + 77.87545001018588664, 42.433096592059882823, 51.333616717496624915, 80.176069206350803142, + 3.1995992277552431915, 118.57082605908726691, 63.640719503051514039, 44.605176790701079881, + 7.9286476382912951522, 30.261160651432874147, 18.819539517229713965, 53.22974046957824612, + 104.35282880081285839, 105.75766776004093117, 53.042172987145022489, 22.178586780533805722, + 63.374442174961586716, 122.14724514352565166, 84.512577064109791536, 86.907714396671508439, + 14.485601830936502665, 97.523601215172675438, 109.49703380172650213, 15.22423680772408261, + 102.16056731409480562, 124.7541002698308148, 48.573840641616698122, 12.699460434720094781, + 68.005032112829212565, 104.21616469970467733, 14.564744242208689684, 57.286643080489739077, + 77.375645825384708587, 85.261220245403819717, 120.60033744804968592, 67.022866422394145047, + 7.3915164706413634121, 105.17874462447798578, 81.061412283055688022, 15.468737095594406128, + 97.522095781772804912, 53.243752748541737674, 81.349688446061918512, 47.606639720757812029, + 33.488212806918454589, 111.2731151824555127, 82.887943311281560455, 46.332033630478690611, + 15.940444718231447041, 44.321121594744909089, 95.263999875016452279, 98.338673150105023524, + 125.89860901223437395, 83.85391485936997924, 82.836463803367223591, 45.595136140884278575, + 126.56899462378714816, 104.50581923564095632, 31.540200963616371155, 18.049933304799196776, + 109.74053828452815651, 68.348928139021154493, 13.396551521032961318, 50.282551828531723004, + 99.845433393347775564, 26.550125301331718219, 110.01327722903442918, 34.581734459239669377, + 3.9055440893789636903, 54.098248269339819672, 78.11226121400250122, 119.773001258225122, + 94.029408889065962285, 97.099576314871228533, 94.911671234101959271, 82.917218461840093369, + 4.4852456768858246505, 122.49723034857743187, 62.32765303098858567, 111.77294972860909184, + 127.98555456680696807, 118.76178182983130682, 46.743550700553896604, 86.925166555654868716, + 84.138875223678041948, 119.86246387344363029, 42.531337286713096546, 98.143470071368938079, + 60.692795665352605283, 84.203863264599931426, 51.246262818742252421, 103.66400050368611119, + 94.541693508086609654, 68.962817098625237122, 95.893526151136029512, 49.763411594267381588, + 50.542314236681704642, 34.81340332252511871, 68.535555584301619092, 21.385959441213344689, + 114.25655107126294752, 103.04125518160071806, 10.313963882541429484, 97.426689992778847227, + 92.314859223832172574, 83.950313314595405245, 26.590585505502531305, 66.076363418644177727, + 21.972699438676499994, 118.02752501822033082, 28.393714331337832846, 84.86067455046941177, + 88.073289958538225619, 64.412389138131402433, 45.076036997026676545, 113.09352274967750418, + 107.59363338174443925, 59.683795159558940213, 67.011580280130147003, 103.93438069337935303, + 121.20085216861480149, 95.527741269266698509, 31.422427709894691361, 81.761139961647131713, + 12.344782823391142301, 102.11997128025177517, 119.8288955614407314, 86.681547475542174652, + 81.141931957463384606, 77.619806369038997218, 19.255095714077469893, 64.832444383195252158, + 29.684853556289453991, 124.17421590585945523, 124.7280922957106668, 121.70144851750228554, + 79.391509241322637536, 125.0052051211023354, 58.439963680673827184, 121.87460310894675786, + 72.808455786074773641, 40.740559153731737752, 90.678986088241799735, 89.524080366656562546, + 103.23773868255375419, 123.5820911618975515, 43.499588463051622966, 37.610637644607777474, + 11.514276477068051463, 107.58872805193823297, 59.070742241150583141, 33.579973967600381002, + 34.060203865930816391, 50.001144233683589846, 19.266672029261826538, 76.291133746122795856, + 4.4591344539767305832, 34.601531022344715893, 105.3636959522482357, 61.044872156417113729, + 52.548761664827907225, 5.6421863088216923643, 20.828436327246890869, 78.814728376524726627, + 21.189892233553109691, 8.8715751576819457114, 124.46748728926468175, 20.034929345038108295, + 54.662838811549590901, 102.58862154729285976, 111.7546529050450772, 35.380522946892597247, + 67.269635907116025919, 30.637915279279695824, 18.881154706985398661, 70.926574734738096595, + 26.291971179110987578, 100.02346465073424042, 31.768940626105177216, 74.559004453170928173, + 121.51340188180984114, 37.248121915905358037, 84.826034750214603264, 74.799287902220385149, + 31.894870444644766394, 119.54204453734200797, 14.564749998971819878, 50.286976832558138995, + 18.113252515697240597, 22.145338527174317278, 8.8430897549405926839, 66.456271652910800185, + 69.968323922043055063, 44.449320224091934506, 39.129270728557457915, 73.257217393427708885, + 127.86727285755841876, 101.8835665735641669, 52.491040824734227499, 19.896558502601692453, + 99.962553381599718705, 90.91527495156697114, 121.48582167965287226, 79.735635077420738526, + 107.98192889232814196, 43.629070305738423485, 27.94503299513598904, 103.8674362586098141, + 97.853976791277091252, 61.797699975591967814, 97.342852121699252166, 4.4374811654924997129, + 115.15309178970710491, 42.848853415151097579, 3.5388032313603616785, 35.883009058397874469, + 93.806649366440979065, 51.534867714210122358, 41.716488909984036582, 56.781890224658127408, + 7.0205000759815447964, 6.3451505869197717402, 73.964585122790595051, 119.70921608719436335, + 115.63261966014761128, 126.23071111811441369, 31.121232673198392149, 118.67079791475407546, + 59.085053724611498183, 35.220586334740801249, 5.205832719846512191, 35.245164318228489719, + 57.673487664695130661, 102.97518021969517577, 109.20833289566144231, 118.72168762233923189, + 118.30143150050571421, 122.93016144922148669, 94.75750138339572004, 43.144049460792302852, + 51.532386582854087465, 72.933924453020154033, 22.68078231968684122, 87.558569956563587766, + 49.622712993616005406, 42.949844328126346227, 97.992109154474746902, 68.953509353086701594, + 108.86057952497867518, 89.658183794406795641, 5.7170232619719172362, 94.94239941781052039, + 6.1574302246299339458, 89.346723340706375893, 45.966816127383935964, 83.558497305970377056, + 3.2546829062412143685, 6.0100254246754047927, 61.37469741625682218, 72.945714132532884832, + 103.06580911070341244, 75.960354577127873199, 16.625653410166705726, 121.3242683251555718, + 72.235019237679807702, 66.941026014530507382, 43.935392132239940111, 49.431121805562725058, + 1.552364417879289249, 57.291608525752963033, 74.627475114313710947, 59.892716054571792483, + 73.704607741350628203, 8.5372858725932019297, 19.487392435621586628, 30.652988987163553247, + 85.992137789911794243, 18.515103924579307204, 84.969940410854178481, 97.952538757672300562, + 121.25136112587279058, 3.3987177551098284312, 66.902414448275521863, 5.3632455743099853862, + 18.278063922054570867, 42.631135280767921358, 127.61594171374235884, 37.043898656178498641, + 24.617176620591635583, 81.038296054670354351, 102.35539830047127907, 122.97057997380397865, + 26.282907748420257121, 78.305271845707466127, 96.337831949567771517, 18.596780581974599045, + 113.75126648339210078, 26.81275312273282907, 11.141274556684948038, 59.629496927649597637, + 125.96658756931356038, 98.827954445467184996, 90.27663071809001849, 121.02111207229609136, + 7.8935445859606261365, 100.74410593666107161, 80.124548035284533398, 18.679735286281356821, + 88.426548492734582396, 41.544838795856776414, 57.31675744898893754, 52.978842419346619863, + 73.81424647575840936, 59.71275958673140849, 58.523412816073687281, 90.303973729089193512, + 105.58857421724314918, 2.5846765232417965308, 39.398944961067172699, 95.320347429187677335, + 119.011950641812291, 1.3159764156480378006, 25.560426302476116689, 108.73721296338408138, + 20.263862970718037104, 72.149225663932156749, 49.763544014738727128, 29.935609198066231329, + 90.031338287521066377, 53.141145807181601413, 3.9213883324955531862, 126.84564982440497261, + 24.347986542321450543, 121.42271716728646425, 117.00097774231835501, 19.729079923465178581, + 59.696010269515682012, 20.368363554825918982, 89.050029890295263613, 32.458279761969606625, + 35.115950446357601322, 68.795070189444231801, 113.90903266402892768, 65.62307712249821634, + 24.765666578681702958, 90.060187468829099089, 3.0896142835590580944, 23.665488136273779674, + 74.307818868943286361, 85.237588067870092345, 33.044791790747694904, 119.77434022857414675, + 3.4912077621775097214, 92.383480028100166237, 0.21384829877933952957, 107.14734169316943735, + 101.16307582501758588, 95.910022686552110827, 78.975944417674327269, 24.251311974177951925, + 97.36206438442968647, 116.23354645292056375, 79.389752731294720434, 105.71597400054815807, + 62.076982688879070338, 85.367508689396345289, 23.028446017804526491, 102.73507282057835255, + 48.284053273840982001, 18.653527126847620821, 27.75090002037177328, 84.866193184119765647, + 102.66723343499688781, 32.352138412701606285, 6.3991984555141243618, 109.14165211817453383, + 127.28143900610302808, 89.210353581402159762, 15.857295276582590304, 60.522321302865748294, + 37.63907903445942793, 106.45948093916013022, 80.705657601629354758, 83.515335520081862342, + 106.08434597429004498, 44.357173561067611445, 126.74888434992681141, 116.29449028705494129, + 41.025154128223221051, 45.815428793343016878, 28.971203661876643309, 67.047202430348988855, + 90.994067603453004267, 30.448473615451803198, 76.321134628193249227, 121.50820053966162959, + 97.147681283233396243, 25.398920869443827542, 8.0100642256620631088, 80.432329399409354664, + 29.129488484417379368, 114.57328616098311613, 26.751291650773055153, 42.522440490811277414, + 113.20067489610300981, 6.0457328447882900946, 14.783032941286364803, 82.35748924895960954, + 34.122824566111376043, 30.937474191192450235, 67.044191563545609824, 106.48750549708711333, + 34.699376892123837024, 95.213279441515624058, 66.976425613840547157, 94.546230364914663369, + 37.775886622563120909, 92.664067260957381222, 31.880889436462894082, 88.642243189493456157, + 62.527999750036542537, 68.677346300213685026, 123.79721802447238588, 39.707829718743596459, + 37.672927606734447181, 91.190272281772195129, 125.13798924757793429, 81.011638471281912643, + 63.08040192723274231, 36.099866609602031531, 91.481076569059950998, 8.6978562780423089862, + 26.793103042065922637, 100.56510365706708399, 71.690866786695551127, 53.100250602667074418, + 92.026554458068858366, 69.163468918479338754, 7.8110881787579273805, 108.19649653868327732, + 28.224522428008640418, 111.54600251645388198, 60.058817778135562548, 66.199152629746095045, + 61.823342468207556522, 37.834436923680186737, 8.9704913537752872799, 116.99446069715486374, + 124.65530606198080932, 95.545899457221821649, 127.97110913361757412, 109.52356365966261365, + 93.487101401111431187, 45.850333111313375412, 40.277750447359721875, 111.72492774688726058, + 85.062674573429831071, 68.286940142737876158, 121.38559133070884855, 40.407726529199862853, + 102.49252563748814282, 79.328001007375860354, 61.083387016176857287, 9.9256341972541122232, + 63.787052302272059023, 99.526823188534763176, 101.08462847336340928, 69.6268066450538754, + 9.071111168603238184, 42.771918882430327358, 100.51310214252953301, 78.082510363201436121, + 20.627927765086496947, 66.853379985561332433, 56.629718447667983128, 39.90062662919081049, + 53.181171011008700589, 4.1527268372883554548, 43.945398877356637968, 108.05505003644066164, + 56.78742866267930367, 41.721349100942461519, 48.146579917080089217, 0.82477827626280486584, + 90.152073994056991069, 98.187045499358646339, 87.187266763488878496, 119.36759031912151841, + 6.0231605602639319841, 79.868761386762344046, 114.40170433723324095, 63.055482538533397019, + 62.844855419793020701, 35.522279923294263426, 24.689565646785922581, 76.239942560507188318, + 111.65779112288510078, 45.363094951087987283, 34.283863914930407191, 27.239612738077994436, + 38.510191428158577764, 1.6648887663905043155, 59.36970711258254596, 120.34843181172254845, + 121.45618459142497159, 115.40289703500820906, 30.78301848264891305, 122.01041024220467079, + 116.87992736135129235, 115.74920621789715369, 17.616911572149547283, 81.481118307467113482, + 53.357972176487237448, 51.048160733316763071, 78.475477365111146355, 119.164182323795103, + 86.999176926103245933, 75.221275289215554949, 23.028552954139740905, 87.177456103876465932, + 118.14148448230116628, 67.159947935200762004, 68.120407731861632783, 100.00228846736717969, + 38.533344058527291054, 24.582267492245591711, 8.9182689079534611665, 69.203062044693069765, + 82.727391904496471398, 122.08974431283422746, 105.09752332965581445, 11.284372617643384729, + 41.656872654497419717, 29.629456753049453255, 42.379784467106219381, 17.743150315367529402, + 120.9349745785293635, 40.06985869007621659, 109.32567762310281978, 77.177243094589357497, + 95.509305810090154409, 70.761045893788832473, 6.5392718142320518382, 61.275830558559391648, + 37.762309413974435301, 13.85314946947619319, 52.583942358225613134, 72.046929301468480844, + 63.537881252213992411, 21.118008906345494324, 115.02680376361968229, 74.496243831814354053, + 41.652069500432844507, 21.598575804440770298, 63.789740889293170767, 111.08408907468401594, + 29.129499997943639755, 100.57395366511627799, 36.226505031394481193, 44.290677054348634556, + 17.686179509884823347, 4.9125433058252383489, 11.936647844086110126, 88.898640448183869012, + 78.258541457118553808, 18.514434786859055748, 127.73454571512047551, 75.767133147128333803, + 104.982081649468455, 39.793117005207022885, 71.925106763203075388, 53.830549903137580259, + 114.9716433593093825, 31.47127015484511503, 87.963857784656283911, 87.258140611476846971, + 55.890065990275616059, 79.734872517223266186, 67.707953582554182503, 123.59539995118757361, + 66.685704243398504332, 8.8749623309886374045, 102.30618357941420982, 85.697706830302195158, + 7.0776064627207233571, 71.766018116799386917, 59.613298732881958131, 103.06973542842024472, + 83.432977819968073163, 113.56378044931625482, 14.041000151963089593, 12.690301173843181459, + 19.929170245584828081, 111.41843217439236469, 103.26523932029886055, 124.46142223622882739, + 62.242465346400422277, 109.34159582950815093, 118.17010744922299637, 70.441172669481602497, + 10.411665439693024382, 70.490328636456979439, 115.3469753293938993, 77.950360439393989509, + 90.416665791326522594, 109.44337524468210177, 108.6028630010150664, 117.86032289844661136, + 61.515002766791440081, 86.288098921584605705, 103.06477316571181291, 17.867848906040308066, + 45.361564639377320418, 47.117139913127175532, 99.245425987232010812, 85.899688656256330432, + 67.984218308953131782, 9.9070187061770411674, 89.721159049960988341, 51.316367588813591283, + 11.434046523947472451, 61.88479883562104078, 12.31486044926350587, 50.693446681412751786, + 91.933632254771509906, 39.116994611940754112, 6.509365812482428737, 12.020050849350809585, + 122.74939483251728234, 17.891428265069407644, 78.131618221410462866, 23.920709154255746398, + 33.25130682033704943, 114.64853665031478158, 16.470038475363253383, 5.882052029061014764, + 87.870784264479880221, 98.862243611125450116, 3.1047288357585784979, 114.58321705150956404, + 21.254950228627421893, 119.78543210914722295, 19.409215482701256406, 17.074571745186403859, + 38.974784871243173257, 61.305977974330744473, 43.984275579823588487, 37.030207849162252387, + 41.93988082171199494, 67.905077515348239103, 114.50272225174558116, 6.7974355102232948411, + 5.8048288965510437265, 10.726491148619970772, 36.556127844109141733, 85.262270561539480696, + 127.23188342748471769, 74.087797312356997281, 49.234353241186909145, 34.076592109344346682, + 76.710796600946196122, 117.94115994760795729, 52.565815496844152221, 28.610543691418570234, + 64.675663899135543033, 37.193561163952836068, 99.502532966784201562, 53.625506245465658139, + 22.282549113369896077, 119.25899385530283325, 123.93317513863075874, 69.655908890938007971, + 52.553261436183674959, 114.04222414459218271, 15.787089171924890252, 73.488211873325781198, + 32.249096070569066796, 37.35947057256635162, 48.853096985469164792, 83.089677591713552829, + 114.63351489797787508, 105.9576848386968777, 19.628492951516818721, 119.42551917346281698, + 117.04682563215101254, 52.607947458182025002, 83.177148434486298356, 5.1693530464835930616, + 78.797889922137983376, 62.640694858378992649, 110.02390128362458199, 2.6319528312960756011, + 51.120852604955871357, 89.474425926768162753, 40.527725941439712187, 16.298451327864313498, + 99.527088029477454256, 59.871218396136100637, 52.062676575042132754, 106.28229161436320283, + 7.8427766649947443511, 125.69129964880994521, 48.695973084646539064, 114.84543433457656647, + 106.00195548463671003, 39.458159846930357162, 119.39202053903136402, 40.736727109655475942, + 50.100059780590527225, 64.91655952393921325, 70.231900892718840623, 9.5901403788921015803, + 99.818065328061493346, 3.2461542449964326806, 49.531333157367043896, 52.120374937658198178, + 6.1792285671181161888, 47.330976272551197326, 20.615637737890210701, 42.475176135740184691, + 66.089583581499027787, 111.5486804571482935, 6.9824155243586574215, 56.766960056200332474, + 0.42769659756231703795, 86.294683386342512676, 74.326151650038809748, 63.820045373107859632, + 29.951888835348654538, 48.502623948359541828, 66.724128768863010919, 104.46709290584476548, + 30.779505462593078846, 83.431948001096316148, 124.15396537776177865, 42.735017378792690579, + 46.056892035612690961, 77.470145641156705096, 96.568106547681964003, 37.307054253695241641, + 55.501800040747184539, 41.732386368243169272, 77.334466869993775617, 64.70427682540321257, + 12.798396911031886702, 90.28330423635270563, 126.56287801220969413, 50.420707162804319523, + 31.714590553165180609, 121.04464260573149659, 75.27815806892249384, 84.918961878323898418, + 33.411315203262347495, 39.030671040167362662, 84.168691948580089957, 88.714347122138860868, + 125.4977686998572608, 104.58898057410988258, 82.050308256446442101, 91.630857586686033756, + 57.942407323756924598, 6.0944048607016156893, 53.988135206906008534, 60.896947230907244375, + 24.642269256390136434, 115.01640107932689716, 66.295362566466792487, 50.797841738887655083, + 16.020128451327764196, 32.864658798818709329, 58.258976968838396715, 101.14657232196623227, + 53.502583301546110306, 85.044880981626192806, 98.401349792206019629, 12.091465689576580189, + 29.566065882576367585, 36.71497849791921908, 68.245649132222752087, 61.874948382388538448, + 6.0883831270948576275, 84.975010994174226653, 69.398753784251312027, 62.426558883034886094, + 5.9528512276847322937, 61.092460729829326738, 75.551773245129879797, 57.328134521914762445, + 63.761778872929426143, 49.284486378986912314, 125.05599950007672305, 9.3546926004310080316, + 119.59443604894477176, 79.415659437487192918, 75.345855213472532341, 54.380544563548028236, + 122.27597849515950656, 34.023276942563825287, 126.16080385446548462, 72.19973321920770104, + 54.962153138119901996, 17.395712556084617972, 53.586206084135483252, 73.130207314137805952, + 15.381733573391102254, 106.20050120533778681, 56.053108916141354712, 10.326937836958677508, + 15.62217635751949274, 88.392993077366554644, 56.449044856020918814, 95.092005032907763962, + 120.11763555627476308, 4.3983052594921900891, 123.64668493641511304, 75.668873847360373475, + 17.940982707554212539, 105.98892139431336545, 121.31061212396525661, 63.091798914447281277, + 127.94221826723878621, 91.047127319328865269, 58.974202802222862374, 91.700666222626750823, + 80.555500894723081728, 95.449855493778159143, 42.12534914686330012, 8.5738802854793902952, + 114.77118266141769709, 80.815453058403363684, 76.985051274979923619, 30.656002014751720708, + 122.16677403235371457, 19.851268394508224446, 127.57410460454775603, 71.053646377073164331, + 74.169256946730456548, 11.2536132901077508, 18.142222337206476368, 85.543837764864292694, + 73.026204285062704002, 28.165020726402872242, 41.255855530176631873, 5.7067599711226648651, + 113.25943689533596626, 79.801253258381620981, 106.36234202201740118, 8.3054536745767109096, + 87.890797754716913914, 88.110100072881323285, 113.57485732535860734, 83.442698201884923037, + 96.293159834160178434, 1.6495565525292477105, 52.304147988117620116, 68.374090998720930656, + 46.374533526981394971, 110.73518063824303681, 12.046321120531501947, 31.73752277352832607, + 100.8034086744664819, 126.11096507706679404, 125.6897108395860414, 71.044559846588526852, + 49.379131293575483141, 24.479885121018014615, 95.315582245770201553, 90.726189902175974566, + 68.567727829860814381, 54.479225476155988872, 77.020382856317155529, 3.329777532781008631, + 118.7394142251687299, 112.69686362344873487, 114.91236918285358115, 102.80579407001641812, + 61.566036965301464079, 116.02082048441297957, 105.75985472270622267, 103.49841243579430738, + 35.233823144302732544, 34.962236614934226964, 106.7159443529744749, 102.09632146663716412, + 28.950954730225930689, 110.32836464759384398, 45.998353852210129844, 22.442550578431109898, + 46.057105908283119788, 46.354912207756569842, 108.28296896460597054, 6.3198958704051619861, + 8.2408154637269035447, 72.004576934734359384, 77.066688117054582108, 49.164534984491183423, + 17.836537815910560312, 10.406124089389777509, 37.454783808996580774, 116.17948862567209289, + 82.1950466593116289, 22.568745235286769457, 83.313745308994839434, 59.25891350609890651, + 84.759568934212438762, 35.486300630738696782, 113.869949157058727, 80.139717380156071158, + 90.651355246209277539, 26.354486189182352973, 63.018611620183946798, 13.522091787577664945, + 13.078543628464103676, 122.5516611171187833, 75.524618827948870603, 27.706298938952386379, + 105.16788471645486425, 16.093858602936961688, 127.07576250442798482, 42.236017812694626627, + 102.05360752724300255, 20.992487663628708106, 83.304139000865689013, 43.197151608881540596, + 127.57948177858997951, 94.168178149368031882, 58.258999995890917489, 73.147907330232555978, + 72.453010062788962387, 88.581354108697269112, 35.372359019769646693, 9.8250866116504766978, + 23.873295688175858231, 49.797280896371376002, 28.517082914237107616, 37.028869573721749475, + 127.46909143024458899, 23.534266294260305585, 81.964163298936909996, 79.586234010417683749, + 15.850213526406150777, 107.6610998062787985, 101.94328671861876501, 62.942540309693868039, + 47.927715569316205801, 46.516281222953693941, 111.7801319805548701, 31.469745034450170351, + 7.4159071651120029856, 119.19079990237878519, 5.3714084867970086634, 17.749924661980912788, + 76.612367158832057612, 43.395413660604390316, 14.155212925445084693, 15.532036233598773833, + 119.22659746576755424, 78.139470856844127411, 38.865955639939784305, 99.127560898632509634, + 28.082000303926179186, 25.380602347686362918, 39.85834049117329414, 94.836864348788367352, + 78.530478640601359075, 120.92284447245765477, 124.48493069280448253, 90.683191659019939834, + 108.34021489844963071, 12.882345338963204995, 20.823330879389686743, 12.980657272917596856, + 102.69395065879143658, 27.900720878791616997, 52.833331582656683167, 90.88675048936784151, + 89.205726002033770783, 107.72064579689322272, 123.03000553358651814, 44.576197843172849389, + 78.129546331423625816, 35.735697812080616131, 90.723129278754640836, 94.234279826257989043, + 70.490851974467659602, 43.799377312516298844, 7.9684366179062635638, 19.814037412357720314, + 51.442318099921976682, 102.63273517762718257, 22.868093047894944903, 123.76959767124208156, + 24.629720898527011741, 101.38689336282914155, 55.867264509543019813, 78.233989223881508224, + 13.018731624964857474, 24.040101698705257149, 117.49878966503456468, 35.782856530142453266, + 28.263236442820925731, 47.841418308511492796, 66.502613640677736839, 101.29707330062956316, + 32.940076950726506766, 11.764104058125667507, 47.741568528963398421, 69.724487222250900231, + 6.2094576715207949746, 101.16643410301912809, 42.509900457258481765, 111.57086421829444589, + 38.818430965402512811, 34.149143490372807719, 77.949569742486346513, 122.61195594866148895, + 87.968551159647176974, 74.060415698324504774, 83.87976164342762786, 7.8101550307001161855, + 101.00544450349116232, 13.594871020446589682, 11.609657793102087453, 21.452982297239941545, + 73.112255688221921446, 42.52454112308259937, 126.46376685497307335, 20.175594624713994563, + 98.468706482373818289, 68.153184218692331342, 25.421593201896030223, 107.88231989521591458, + 105.13163099368830444, 57.221087382840778446, 1.351327798271086067, 74.387122327909310116, + 71.005065933568403125, 107.25101249093131628, 44.565098226743430132, 110.51798771060930449, + 119.86635027726515546, 11.311817781876015943, 105.1065228723709879, 100.08444828918436542, + 31.574178343853418482, 18.976423746651562396, 64.498192141138133593, 74.718941145132703241, + 97.706193970941967564, 38.179355183430743637, 101.26702979595938814, 83.91536967739375541, + 39.256985903037275421, 110.85103834692927194, 106.09365126430202508, 105.21589491636768798, + 38.354296868972596712, 10.338706092970824102, 29.595779844275966752, 125.28138971676162328, + 92.047802567249163985, 5.2639056625921512023, 102.24170520991538069, 50.948851853536325507, + 81.055451882879424375, 32.596902655732264975, 71.054176058954908513, 119.74243679227220127, + 104.12535315008790349, 84.56458322872640565, 15.685553329993126681, 123.38259929761989042, + 97.391946169296716107, 101.69086866915677092, 84.003910969273420051, 78.916319693864352303, + 110.78404107806272805, 81.473454219310951885, 100.20011956118469243, 1.8331190478820644785, + 12.463801785437681247, 19.180280757787841139, 71.636130656122986693, 6.4923084899928653613, + 99.062666314734087791, 104.24074987531639636, 12.358457134236232378, 94.661952545102394652, + 41.231275475780421402, 84.95035227148400736, 4.1791671630016935524, 95.097360914296586998, + 13.964831048717314843, 113.53392011240066495, 0.85539319512827205472, 44.589366772688663332, + 20.652303300077619497, 127.64009074621571926, 59.903777670697309077, 97.005247896722721634, + 5.4482575377296598163, 80.934185811689530965, 61.559010925189795671, 38.863896002196270274, + 120.30793075552355731, 85.470034757585381158, 92.113784071229019901, 26.940291282317048172, + 65.136213095363928005, 74.614108507390483283, 111.00360008149436908, 83.464772736489976523, + 26.668933739991189213, 1.4085536508064251393, 25.596793822067411384, 52.566608472709049238, + 125.12575602441938827, 100.84141432560863905, 63.429181106333999196, 114.08928521146663115, + 22.556316137848625658, 41.837923756647796836, 66.82263040652469499, 78.061342080338363303, + 40.337383897163817892, 49.428694244281359715, 122.99553739971815958, 81.177961148223403143, + 36.100616512896522181, 55.261715173372067511, 115.8848146475138492, 12.188809721403231379, + 107.97627041381201707, 121.79389446181448875, 49.284538512783910846, 102.0328021586574323, + 4.5907251329335849732, 101.59568347777531017, 32.040256902655528393, 65.729317597637418658, + 116.51795393768043141, 74.293144643932464533, 107.00516660309585859, 42.089761963256023591, + 68.802699584412039258, 24.182931379153160378, 59.13213176515273517, 73.42995699584207614, + 8.4912982644455041736, 123.7498967647770769, 12.176766254193353234, 41.950021988352091284, + 10.797507568502624054, 124.85311776606977219, 11.905702455369464587, 122.18492145966229145, + 23.103546490259759594, 114.65626904382952489, 127.52355774585885229, 98.568972757977462607, + 122.1119990001534461, 18.709385200865654042, 111.18887209789318149, 30.831318874978023814, + 22.691710426945064683, 108.76108912709969445, 116.55195699031901313, 68.046553885131288553, + 124.32160770893460722, 16.399466438415402081, 109.92430627623980399, 34.791425112169235945, + 107.17241216827460448, 18.260414628275611904, 30.763467146785842488, 84.401002410675573628, + 112.10621783228270942, 20.653875673917355016, 31.244352715042623458, 48.785986154733109288, + 112.89808971204547561, 62.184010065819165902, 112.23527111254952615, 8.796610518988018157, + 119.29336987283386406, 23.337747694720746949, 35.881965415112063056, 83.977842788630368887, + 114.62122424793051323, 126.18359782889820053, 127.8844365344812104, 54.094254638657730538, + 117.94840560444936273, 55.401332445257139625, 33.111001789449801436, 62.899710987556318287, + 84.250698293726600241, 17.147760570962418569, 101.54236532283903216, 33.630906116810365347, + 25.970102549959847238, 61.312004029507079395, 116.33354806470742915, 39.702536789020086871, + 127.14820920909915003, 14.10729275414996664, 20.338513893460913096, 22.507226580215501599, + 36.284444674416590715, 43.087675529732223367, 18.052408570125408005, 56.330041452805744484, + 82.511711060353263747, 11.413519942248967709, 98.51887379067557049, 31.60250651676687994, + 84.724684044034802355, 16.610907349157059798, 47.781595509437465807, 48.22020014576628455, + 99.14971465072085266, 38.885396403773484053, 64.586319668320356868, 3.299113105058495421, + 104.60829597623887821, 8.7481819974418613128, 92.74906705396642792, 93.470361276486073621, + 24.092642241063003894, 63.475045547060290119, 73.606817348936601775, 124.22193015413722605, + 123.37942167917572078, 14.089119693177053705, 98.758262587150966283, 48.95977024203966721, + 62.631164491544041084, 53.452379804355587112, 9.1354556597216287628, 108.95845095231561572, + 26.040765712634311058, 6.6595550655656552408, 109.47882845034109778, 97.393727246901107719, + 101.82473836571080028, 77.611588140032836236, 123.13207393060656614, 104.04164096882959711, + 83.519709445416083327, 78.996824871588614769, 70.467646288605465088, 69.924473229872091906, + 85.43188870595258777, 76.192642933274328243, 57.901909460455499357, 92.656729295187687967, + 91.996707704420259688, 44.885101156862219796, 92.114211816566239577, 92.709824415516777663, + 88.565937929211941082, 12.639791740810323972, 16.481630927457445068, 16.009153869472356746, + 26.133376234109164216, 98.329069968982366845, 35.673075631821120623, 20.812248178779555019, + 74.909567617996799527, 104.35897725134782377, 36.390093318623257801, 45.137490470577176893, + 38.627490617989678867, 118.517827012201451, 41.519137868424877524, 70.972601261481031543, + 99.739898314121091971, 32.279434760315780295, 53.302710492418555077, 52.708972378364705946, + 126.0372232403678936, 27.044183575155329891, 26.157087256931845332, 117.10332223424120457, + 23.049237655897741206, 55.412597877908410737, 82.335769432909728494, 32.187717205877561355, + 126.15152500885596965, 84.472035625392891234, 76.107215054486005101, 41.98497532726105419, + 38.608278001731378026, 86.394303217766719172, 127.158963557183597, 60.336356298736063763, + 116.51799999178547296, 18.295814660468749935, 16.906020125581562752, 49.162708217394538224, + 70.744718039539293386, 19.650173223300953396, 47.746591376351716463, 99.594561792742752004, + 57.034165828474215232, 74.057739147447136929, 126.93818286048917798, 47.068532588524249149, + 35.928326597877457971, 31.172468020835367497, 31.700427052815939533, 87.322199612561234972, + 75.886573437237530015, 125.88508061938773608, 95.855431138632411603, 93.032562445911025861, + 95.560263961109740194, 62.939490068900340702, 14.83181433022764395, 110.38159980475757038, + 10.742816973594017327, 35.499849323965463554, 25.224734317664115224, 86.790827321208780631, + 28.310425850890169386, 31.064072467201185646, 110.45319493153874646, 28.278941713688254822, + 77.731911279883206589, 70.255121797265019268, 56.164000607852358371, 50.761204695372725837, + 79.716680982350226259, 61.673728697580372682, 29.060957281206356129, 113.84568894491894753, + 120.96986138561260304, 53.366383318043517647, 88.680429796899261419, 25.76469067792640999, + 41.646661758779373486, 25.961314545838831691, 77.387901317582873162, 55.801441757583233994, + 105.66666316531700431, 53.773500978739320999, 50.411452004071179545, 87.441291593790083425, + 118.06001106717303628, 89.152395686349336756, 28.259092662847251631, 71.471395624164870242, + 53.446258557512919651, 60.468559652519616066, 12.981703948935319204, 87.598754625032597687, + 15.936873235812527128, 39.628074824715440627, 102.88463619984759134, 77.265470355254365131, + 45.736186095793527784, 119.53919534248416312, 49.259441797057661461, 74.773786725658283103, + 111.7345290190896776, 28.467978447763016447, 26.037463249929714948, 48.080203397414152278, + 106.99757933006912936, 71.565713060284906533, 56.526472885641851462, 95.682836617026623571, + 5.0052272813591116574, 74.594146601259126328, 65.880153901453013532, 23.528208116251335014, + 95.483137057930434821, 11.448974444501800463, 12.418915343045227928, 74.332868206038256176, + 85.019800914520601509, 95.141728436588891782, 77.636861930805025622, 68.298286980749253416, + 27.899139484976331005, 117.22391189732661587, 47.937102319297991926, 20.120831396652647527, + 39.759523286855255719, 15.62031006140387035, 74.010889006982324645, 27.189742040893179365, + 23.219315586204174906, 42.905964594483521068, 18.224511376443842892, 85.049082246168836718, + 124.9275337099461467, 40.351189249431627104, 68.937412964751274558, 8.3063684373846626841, + 50.843186403795698425, 87.764639790435467148, 82.263261987376608886, 114.44217476568155689, + 2.7026555965458101127, 20.77424465582225821, 14.010131867140444228, 86.502024981862632558, + 89.130196453490498243, 93.03597542122224695, 111.73270055453031091, 22.623635563755669864, + 82.213045744745613774, 72.168896578368730843, 63.148356687706836965, 37.952847493306762772, + 0.99638428227990516461, 21.437882290269044461, 67.412387941883935127, 76.358710366865125252, + 74.534059591922414256, 39.83073935478751082, 78.51397180607818882, 93.702076693862181855, + 84.187302528607688146, 82.431789832735375967, 76.708593737945193425, 20.677412185941648204, + 59.191559688555571483, 122.56277943352688453, 56.095605134498327971, 10.527811325187940383, + 76.483410419830761384, 101.89770370707628899, 34.110903765758848749, 65.193805311468167929, + 14.108352117913455004, 111.48487358454804053, 80.250706300179444952, 41.129166457452811301, + 31.371106659989891341, 118.76519859524341882, 66.783892338597070193, 75.38173733831717982, + 40.00782193855047808, 29.832639387732342584, 93.568082156129094074, 34.946908438625541748, + 72.400239122369384859, 3.6662380957641289569, 24.927603570875362493, 38.360561515579320258, + 15.272261312245973386, 12.984616979989368701, 70.125332629471813561, 80.481499750632792711, + 24.716914268476102734, 61.323905090204789303, 82.462550951564480783, 41.900704542968014721, + 8.3583343260070250835, 62.194721828593173996, 27.929662097438267665, 99.067840224801329896, + 1.7107863902565441094, 89.178733545377326664, 41.304606600158876972, 127.28018149243143853, + 119.80755534139825613, 66.010495793445443269, 10.896515075462957611, 33.86837162337906193, + 123.11802185037959134, 77.727792004396178527, 112.6158615110507526, 42.940069515174400294, + 56.227568142458039802, 53.880582564637734322, 2.272426190731493989, 21.228217014784604544, + 94.007200162992376136, 38.929545472979953047, 53.337867479982378427, 2.8171073016128502786, + 51.193587644134822767, 105.13321694542173645, 122.25151204884241452, 73.682828651217278093, + 126.85836221267163637, 100.17857042293326231, 45.112632275697251316, 83.67584751329923165, + 5.6452608130530279595, 28.122684160676726606, 80.674767794327635784, 98.85738848856635741, + 117.99107479943995713, 34.355922296446806286, 72.201233025793044362, 110.523430346747773, + 103.76962929502769839, 24.377619442810100736, 87.952540827627672115, 115.5877889236289775, + 98.569077025571459671, 76.065604317314864602, 9.1814502658708079252, 75.191366955550620332, + 64.080513805314694764, 3.4586351952784752939, 105.0359078753645008, 20.586289287868567044, + 86.010333206191717181, 84.179523926515685162, 9.6053991688240785152, 48.365862758306320757, + 118.26426353030910832, 18.859913991684152279, 16.982596528894646326, 119.49979352955415379, + 24.353532508386706468, 83.900043976704182569, 21.595015137008886086, 121.70623553213954438, + 23.811404910742567154, 116.36984291932458291, 46.207092980523157166, 101.31253808766268776, + 127.04711549172134255, 69.137945515958563192, 116.22399800030689221, 37.418770401734946063, + 94.37774419578636298, 61.662637749956047628, 45.383420853893767344, 89.522178254203026881, + 105.10391398064166424, 8.0931077702662150841, 120.64321541786921443, 32.798932876834442141, + 91.848612552479607984, 69.582850224342109868, 86.344824336549208965, 36.520829256551223807, + 61.526934293575322954, 40.802004821354785236, 96.212435664565418847, 41.307751347834710032, + 62.488705430085246917, 97.571972309469856555, 97.796179424090951215, 124.36802013164196978, + 96.470542225099052303, 17.593221037979674293, 110.58673974566772813, 46.675495389441493899, + 71.763930830227764091, 39.955685577264375752, 101.24244849586466444, 124.36719565780003904, + 127.7688730689624208, 108.18850927731909906, 107.89681120889872545, 110.80266489051427925, + 66.222003578899602871, 125.79942197511627455, 40.501396587453200482, 34.295521141928475117, + 75.08473064567806432, 67.261812233620730694, 51.940205099919694476, 122.62400805901779677, + 104.6670961294148583, 79.405073578043811722, 126.29641841819830006, 28.214585508299933281, + 40.677027786921826191, 45.014453160431003198, 72.56888934883318143, 86.175351059464446735, + 36.10481714025081601, 112.66008290561512695, 37.023422120706527494, 22.827039884501573397, + 69.03774758135114098, 63.20501303353739786, 41.44936808806960471, 33.221814698314119596, + 95.563191018874931615, 96.440400291536207078, 70.29942930144170532, 77.770792807550606085, + 1.1726393366407137364, 6.5982262101206288207, 81.216591952477756422, 17.496363994887360604, + 57.49813410793649382, 58.940722552972147241, 48.185284482126007788, 126.95009109412421822, + 19.213634697876841528, 120.44386030827809009, 118.75884335835144157, 28.178239386357745389, + 69.516525174301932566, 97.919540484079334419, 125.26232898308808217, 106.90475960871117422, + 18.270911319446895504, 89.916901904631231446, 52.081531425268622115, 13.31911013113494846, + 90.957656900685833534, 66.787454493805853417, 75.64947673142523854, 27.223176280069310451, + 118.26414786121677025, 80.083281937662832206, 39.039418890835804632, 29.993649743180867517, + 12.935292577214568155, 11.848946459747821791, 42.863777411908813519, 24.385285866548656486, + 115.80381892091463669, 57.313458590379013913, 55.993415408840519376, 89.77020231372807757, + 56.228423633136117132, 57.419648831037193304, 49.131875858423882164, 25.279583481620647945, + 32.963261854914890137, 32.018307738944713492, 52.26675246822196641, 68.65813993796473369, + 71.346151263642241247, 41.624496357562748017, 21.819135235997237032, 80.717954502695647534, + 72.780186637246515602, 90.274980941154353786, 77.254981235982995713, 109.035654024402902, + 83.038275736853393028, 13.945202522965701064, 71.479796628242183942, 64.55886952063156059, + 106.60542098483711015, 105.41794475673304987, 124.07444648073578719, 54.088367150310659781, + 52.314174513867328642, 106.20664446848240914, 46.098475311795482412, 110.82519575582045945, + 36.671538865819456987, 64.375434411758760689, 124.30305001771557727, 40.944071250785782468, + 24.214430108972010203, 83.96995065452210838, 77.216556003466394031, 44.788606435537076322, + 126.31792711436719401, 120.67271259747576551, 105.03599998357094591, 36.59162932093749987, + 33.812040251163125504, 98.325416434792714426, 13.489436079078586772, 39.300346446601906791, + 95.493182752707070904, 71.189123585485504009, 114.06833165695206844, 20.115478294897911837, + 125.87636572097835597, 94.137065177048498299, 71.856653195754915942, 62.344936041670734994, + 63.400854105635517044, 46.644399225126107922, 23.77314687447869801, 123.77016123877911014, + 63.710862277268461185, 58.065124891825689701, 63.120527922219480388, 125.8789801378006814, + 29.663628660458925879, 92.763199609515140764, 21.485633947188034654, 70.999698647930927109, + 50.449468635331868427, 45.581654642417561263, 56.620851701780338772, 62.12814493440600927, + 92.906389863077492919, 56.557883427380147623, 27.463822559770051157, 12.510243594530038536, + 112.32800121570471674, 101.52240939074908965, 31.433361964700452518, 123.34745739516074536, + 58.121914562416350236, 99.691377889841533033, 113.93972277122520609, 106.73276663609067327, + 49.360859593798522837, 51.529381355852819979, 83.293323517558746971, 51.922629091681301361, + 26.775802635165746324, 111.60288351517010597, 83.333326330634008627, 107.547001957478642, + 100.82290400814599707, 46.882583187583804829, 108.12002213434971054, 50.304791372698673513, + 56.518185325698141241, 14.942791248329740483, 106.8925171150258393, 120.93711930503923213, + 25.963407897874276387, 47.197509250065195374, 31.873746471625054255, 79.256149649434519233, + 77.769272399698820664, 26.530940710508730263, 91.472372191590693546, 111.07839068496832624, + 98.5188835941189609, 21.547573451320204185, 95.469058038179355208, 56.935956895526032895, + 52.074926499859429896, 96.160406794831942534, 85.995158660141896689, 15.131426120569813065, + 113.0529457712873409, 63.365673234053247143, 10.010454562721861294, 21.188293202521890635, + 3.7603078029060270637, 47.056416232506308006, 62.966274115860869642, 22.897948889003600925, + 24.837830686094093835, 20.66573641208015033, 42.039601829044840997, 62.283456873181421543, + 27.273723861613689223, 8.5965739614985068329, 55.798278969956299989, 106.44782379465323174, + 95.874204638595983852, 40.241662793305295054, 79.519046573710511439, 31.240620122811378678, + 20.02177801396464929, 54.379484081786358729, 46.438631172408349812, 85.811929188967042137, + 36.449022752891323762, 42.098164492341311416, 121.8550674198922934, 80.702378498866892187, + 9.8748259295025491156, 16.612736874769325368, 101.68637280759503483, 47.529279580874572275, + 36.52652397475685575, 100.88434953136311378, 5.4053111930916202255, 41.54848931164451642, + 28.020263734284526436, 45.004049963728903094, 50.260392906984634465, 58.07195084244813188, + 95.46540110906062182, 45.247271127514977707, 36.426091489494865527, 16.337793156737461686, + 126.29671337541367393, 75.905694986613525543, 1.9927685645598103292, 42.8757645805417269, + 6.8247758837715082336, 24.717420733733888483, 21.068119183844828513, 79.661478709578659618, + 29.027943612160015618, 59.40415338772800169, 40.37460505721901427, 36.863579665474389913, + 25.41718747589038685, 41.354824371883296408, 118.38311937711478095, 117.12555886705376906, + 112.19121026899665594, 21.055622650379518745, 24.966820839665160747, 75.795407414152577985, + 68.221807531521335477, 2.387610622936335858, 28.216704235830547987, 94.969747169099719031, + 32.501412600358889904, 82.258332914905622602, 62.742213319983420661, 109.53039719049047562, + 5.5677846771977783646, 22.763474676634359639, 80.015643877100956161, 59.665278775468323147, + 59.136164312258188147, 69.893816877254721476, 16.800478244738769718, 7.3324761915282579139, + 49.855207141750724986, 76.721123031158640515, 30.544522624491946772, 25.969233959982375382, + 12.250665258947265102, 32.962999501265585423, 49.433828536952205468, 122.64781018041321659, + 36.925101903128961567, 83.801409085936029442, 16.716668652014050167, 124.38944365718634799, + 55.859324194880173309, 70.135680449602659792, 3.4215727805167261977, 50.357467090754653327, + 82.609213200321391923, 126.56036298486651503, 111.61511068280015024, 4.0209915868908865377, + 21.793030150925915223, 67.736743246761761839, 118.23604370076282066, 27.455584008795995032, + 97.231723022101505194, 85.880139030348800588, 112.4551362849160796, 107.76116512927546864, + 4.544852381462987978, 42.456434029572847066, 60.014400325984752271, 77.859090945959906094, + 106.67573495996475685, 5.6342146032257005572, 102.38717528827328351, 82.266433890847110888, + 116.50302409768846701, 19.365657302438194165, 125.71672442534691072, 72.357140845866524614, + 90.225264551398140611, 39.351695026598463301, 11.290521626106055919, 56.24536832135709119, + 33.349535588658909546, 69.714776977136352798, 107.98214959887991427, 68.71184459289725055, + 16.402466051589726703, 93.046860693499183981, 79.53925859005539678, 48.755238885623839451, + 47.905081655258982209, 103.17557784726159298, 69.138154051146557322, 24.131208634629729204, + 18.362900531745253829, 22.382733911104878644, 0.16102761062938952819, 6.9172703905605885666, + 82.071815750729001593, 41.172578575740772067, 44.020666412387072342, 40.359047853031370323, + 19.21079833764815703, 96.731725516616279492, 108.52852706061821664, 37.719827983368304558, + 33.965193057792930631, 110.99958705910830759, 48.707065016777050914, 39.800087953408365138, + 43.19003027402141015, 115.41247106427908875, 47.622809821488772286, 104.73968583864916582, + 92.414185961049952311, 74.625076175329013495, 126.09423098344632308, 10.275891031920764362, + 104.44799600061378442, 74.837540803473530104, 60.755488391572725959, 123.32527549991209526, + 90.766841707791172666, 51.044356508409691742, 82.207827961283328477, 16.186215540536068147, + 113.28643083573842887, 65.59786575367252226, 55.697225104962853948, 11.165700448687857715, + 44.68964867309841793, 73.041658513102447614, 123.05386858715064591, 81.60400964271320845, + 64.424871329130837694, 82.615502695669420063, 124.97741086017413181, 67.143944618943351088, + 67.59235884818554041, 120.73604026328757755, 64.941084450198104605, 35.186442075962986564, + 93.17347949133545626, 93.350990778886625776, 15.527861660455528181, 79.911371154532389482, + 74.484896991732966853, 120.73439131560371607, 127.53774613792847958, 88.37701855464183609, + 87.793622417801088886, 93.605329781032196479, 4.4440071578028437216, 123.5988439502325491, + 81.002793174906400964, 68.591042283860588213, 22.169461291359766619, 6.5236244672414613888, + 103.88041019984302693, 117.24801611803923151, 81.334192258833354572, 30.810147156091261422, + 124.59283683639660012, 56.429171016599866562, 81.354055573843652382, 90.028906320865644375, + 17.137778697670000838, 44.350702118928893469, 72.209634280505269999, 97.320165811230253894, + 74.046844241413054988, 45.654079769006784773, 10.075495162702281959, 126.41002606707479572, + 82.898736176139209419, 66.443629396631877171, 63.126382037753501208, 64.880800583076052135, + 12.598858602887048619, 27.54158561510121217, 2.3452786732814274728, 13.19645242024489562, + 34.433183904955512844, 34.992727989774721209, 114.99626821587298764, 117.88144510594429448, + 96.370568964255653555, 125.90018218824843643, 38.427269395757321035, 112.88772061655981815, + 109.51768671670288313, 56.356478772719128756, 11.033050348607503111, 67.839080968162306817, + 122.52465796617980232, 85.809519217422348447, 36.541822638897428988, 51.833803809262462892, + 104.16306285053724423, 26.6382202622735349, 53.915313801375305047, 5.5749089876153448131, + 23.298953462850477081, 54.446352560142258881, 108.52829572243717848, 32.166563875325664412, + 78.078837781671609264, 59.987299486361735035, 25.87058515442913631, 23.697892919495643582, + 85.727554823817627039, 48.770571733100950951, 103.60763784182927338, 114.62691718075802783, + 111.98683081768467673, 51.54040462745615514, 112.45684726627223426, 114.83929766207438661, + 98.263751716847764328, 50.559166963241295889, 65.926523709829780273, 64.036615477889426984, + 104.5335049364475708, 9.3162798759331053589, 14.692302527284482494, 83.248992715125496034, + 43.638270471998112043, 33.435909005394933047, 17.560373274496669183, 52.549961882312345551, + 26.509962471969629405, 90.071308048809441971, 38.076551473706786055, 27.890405045935040107, + 14.959593256488005864, 1.117739041266759159, 85.210841969677858287, 82.835889513469737722, + 120.14889296147157438, 108.17673430062131956, 104.62834902773829526, 84.413288936964818276, + 92.196950623594602803, 93.650391511640918907, 73.343077731642551953, 0.75086882352115935646, + 120.60610003543115454, 81.888142501571564935, 48.428860217947658384, 39.939901309047854738, + 26.433112006932788063, 89.577212871077790624, 124.63585422873802599, 113.34542519495516899, + 82.07199996714189183, 73.183258641874999739, 67.624080502329888986, 68.650832869585428853, + 26.978872158157173544, 78.600692893207451561, 62.986365505417779787, 14.378247170974645996, + 100.13666331390413688, 40.230956589799461653, 123.75273144196034991, 60.274130354100634577, + 15.713306391509831883, 124.68987208334146999, 126.80170821127103409, 93.288798450252215844, + 47.546293748961033998, 119.54032247755822027, 127.42172455453692237, 116.1302497836513794, + 126.24105584444259875, 123.75796027560136281, 59.327257320921489736, 57.526399219030281529, + 42.971267894379707286, 13.999397295861854218, 100.89893727066373685, 91.163309284835122526, + 113.24170340356067754, 124.25628986881565652, 57.812779726154985838, 113.11576685476029525, + 54.927645119540102314, 25.02048718906371505, 96.656002431413071463, 75.044818781498179305, + 62.866723929404543014, 118.69491479032149073, 116.24382912483633845, 71.382755779686704045, + 99.879445542454050155, 85.465533272181346547, 98.721719187597045675, 103.05876271170927794, + 38.586647035117493942, 103.84525818336260272, 53.551605270335130626, 95.20576703034384991, + 38.666652661271655234, 87.094003914960921975, 73.645808016291994136, 93.765166375171247637, + 88.240044268699421082, 100.60958274539734703, 113.03637065139628248, 29.885582496663118945, + 85.785034230055316584, 113.87423861007846426, 51.926815795748552773, 94.395018500130390748, + 63.747492943253746489, 30.512299298872676445, 27.538544799397641327, 53.061881421021098504, + 54.944744383185025072, 94.15678136994029046, 69.0377671882379218, 43.095146902644046349, + 62.938116076358710416, 113.87191379105206579, 104.14985299972249777, 64.320813589667523047, + 43.990317320283793379, 30.262852241143264109, 98.105891542574681807, 126.73134646810649429, + 20.020909125443722587, 42.376586405043781269, 7.5206156058120541275, 94.112832465012616012, + 125.93254823172173928, 45.79589777800720185, 49.67566137218818767, 41.331472824160300661, + 84.079203658089681994, 124.56691374636284309, 54.547447723227378447, 17.193147922997013666, + 111.59655793991623796, 84.895647589310101466, 63.748409277191967703, 80.483325586614228087, + 31.038093147421022877, 62.481240245622757357, 40.04355602792929858, 108.75896816357271746, + 92.877262344820337603, 43.623858377934084274, 72.898045505782647524, 84.19632898468626081, + 115.71013483978822478, 33.404756997733784374, 19.749651859005098231, 33.225473749542288715, + 75.372745615190069657, 95.05855916174914455, 73.05304794951734948, 73.768699062726227567, + 10.810622386183240451, 83.096978623289032839, 56.040527468569052871, 90.008099927457806189, + 100.52078581396926893, 116.14390168489990174, 62.930802218121243641, 90.494542255029955413, + 72.852182978989731055, 32.675586313478561351, 124.59342675083098584, 23.811389973227051087, + 3.9855371291196206585, 85.751529161083453801, 13.649551767543016467, 49.434841467467776965, + 42.136238367693295004, 31.322957419157319237, 58.055887224320031237, 118.80830677545600338, + 80.74921011443802854, 73.727159330948779825, 50.834374951780773699, 82.709648743770230794, + 108.76623875423319987, 106.25111773411117611, 96.382420537993311882, 42.111245300759037491, + 49.933641679333959473, 23.590814828308793949, 8.443615063042670954, 4.7752212458726717159, + 56.433408471664733952, 61.939494338199438062, 65.002825200721417787, 36.516665829811245203, + 125.4844266399704793, 91.060794380980951246, 11.135569354395556729, 45.526949353272357257, + 32.031287754201912321, 119.33055755093664629, 118.27232862452001427, 11.787633754509442952, + 33.600956489477539435, 14.664952383056515828, 99.710414283505087951, 25.44224606231728103, + 61.089045248983893543, 51.938467919964750763, 24.501330517894530203, 65.925999002531170845, + 98.867657073908048915, 117.29562036082643317, 73.850203806261561112, 39.602818171872058883, + 33.433337304031738313, 120.77888731437269598, 111.7186483897639846, 12.271360899205319583, + 6.8431455610334523953, 100.71493418151294463, 37.218426400646421826, 125.12072596973666805, + 95.230221365600300487, 8.0419831737817730755, 43.586060301855468424, 7.4734864935271616559, + 108.47208740152564133, 54.911168017595628044, 66.463446044206648367, 43.760278060701239156, + 96.910272569835797185, 87.522330258550937288, 9.089704762925975956, 84.912868059145694133, + 120.02880065197314252, 27.718181891923450166, 85.351469919929513708, 11.268429206455039093, + 76.774350576550205005, 36.532867781697859755, 105.00604819537693402, 38.731314604880026309, + 123.43344885069745942, 16.714281691736687208, 52.450529102796281222, 78.703390053196926601, + 22.581043252212111838, 112.49073664271418238, 66.699071177321457071, 11.429553954276343575, + 87.964299197763466509, 9.4236891857945010997, 32.804932103183091385, 58.09372138700200594, + 31.078517180110793561, 97.510477771247678902, 95.810163310521602398, 78.351155694526823936, + 10.276308102293114644, 48.262417269259458408, 36.725801063490507659, 44.765467822209757287, + 0.32205522125877905637, 13.834540781124815112, 36.143631501458003186, 82.345157151481544133, + 88.041332824774144683, 80.718095706062740646, 38.421596675299952039, 65.463451033236196963, + 89.057054121236433275, 75.439655966736609116, 67.930386115589499241, 93.99917411821661517, + 97.414130033554101828, 79.600175906816730276, 86.38006054804645828, 102.8249421285581775, + 95.245619642981182551, 81.479371677301969612, 56.828371922103542602, 21.250152350661664968, + 124.18846196689264616, 20.551782063845166704, 80.895992001231206814, 21.675081606947060209, + 121.5109767831490899, 118.65055099982782849, 53.533683415582345333, 102.08871301682302146, + 36.415655922566656955, 32.372431081075774273, 98.572861671480495716, 3.1957315073450445198, + 111.3944502099257079, 22.331400897375715431, 89.379297346200473839, 18.083317026208533207, + 118.10773717430492979, 35.208019285430054879, 0.84974265826531336643, 37.231005391342478106, + 121.9548217203519016, 6.287889237890340155, 7.1847176963747187983, 113.47208052657879307, + 1.8821689003962092102, 70.372884151929611107, 58.346958982674550498, 58.701981557773251552, + 31.055723320914694341, 31.822742309068416944, 20.969793983469571685, 113.46878263121107011, + 127.07549227586059715, 48.754037109287310159, 47.587244835605815751, 59.210659562064392958, + 8.888014315609325422, 119.19768790046873619, 34.005586349816439906, 9.1820845677211764269, + 44.338922582719533239, 13.047248934486560756, 79.76082039968969184, 106.49603223608210101, + 34.668384517666709144, 61.620294312186160823, 121.18567367279320024, 112.8583420332033711, + 34.708111147690942744, 52.05781264173128875, 34.275557395340001676, 88.701404237861424917, + 16.419268561014177976, 66.640331622464145767, 20.093688482826109976, 91.308159538013569545, + 20.150990325408201898, 124.82005213415322942, 37.797472352282056818, 4.8872587932637543418, + 126.2527640755106404, 1.7616011661521042697, 25.197717205774097238, 55.08317123020242434, + 4.6905573465628549457, 26.392904840489791241, 68.866367809911025688, 69.985455979553080397, + 101.99253643174961326, 107.76289021189222694, 64.741137928514945088, 123.80036437649687286, + 76.85453879151828005, 97.775441233123274287, 91.035373433405766264, 112.71295754543825751, + 22.0661006972186442, 7.6781619363282516133, 117.04931593236324261, 43.619038434844696894, + 73.083645277794857975, 103.66760761852856376, 80.326125701074488461, 53.276440524547069799, + 107.83062760275061009, 11.149817975230689626, 46.597906925700954162, 108.89270512028815574, + 89.056591444874356966, 64.333127750654966803, 28.157675563343218528, 119.97459897272347007, + 51.74117030885827262, 47.395785838994925143, 43.455109647635254078, 97.54114346620553988, + 79.215275683662184747, 101.25383436151969363, 95.973661635369353462, 103.08080925491594826, + 96.913694532548106508, 101.67859532415241119, 68.527503433695528656, 101.11833392648622976, + 3.8530474196631985251, 0.073230955782491946593, 81.067009872895141598, 18.632559751866210718, + 29.384605054572602967, 38.497985430250992067, 87.276540943996224087, 66.871818010789866094, + 35.120746548993338365, 105.0999237646246911, 53.019924943942896789, 52.142616097618883941, + 76.15310294741357211, 55.780810091870080214, 29.919186512976011727, 2.2354780825371562969, + 42.421683939359354554, 37.671779026943113422, 112.29778592294678674, 88.353468601246277103, + 81.256698055480228504, 40.826577873933274532, 56.393901247192843584, 59.300783023285475792, + 18.686155463285103906, 1.5017376470459566917, 113.21220007086594705, 35.77628500314312987, + 96.857720435895316768, 79.879802618095709477, 52.866224013869214104, 51.154425742159219226, + 121.27170845747968997, 98.69085038991397596, 36.143999934287421638, 18.366517283753637457, + 7.2481610046634159517, 9.3016657391708577052, 53.957744316317985067, 29.201385786414903123, + 125.97273101083555957, 28.756494341952929972, 72.27332662780827377, 80.461913179602561286, + 119.50546288392069982, 120.54826070820126915, 31.426612783023301745, 121.37974416668657796, + 125.60341642254570615, 58.577596900504431687, 95.092587497925705975, 111.08064495512007852, + 126.84344910907748272, 104.26049956730639678, 124.48211168888883549, 119.51592055120272562, + 118.65451464184297947, 115.05279843806056306, 85.942535788759414572, 27.998794591727346415, + 73.797874541331111686, 54.32661856967388303, 98.483406807124993065, 120.51257973763131304, + 115.62555945231360965, 98.231533709520590492, 109.85529023908020463, 50.040974378131068079, + 65.312004862829780905, 22.089637562996358611, 125.73344785881272401, 109.38982958064661943, + 104.48765824967631488, 14.765511559377046069, 71.75889108491173829, 42.931066544366331073, + 69.443438375197729329, 78.117525423418555874, 77.173294070238625864, 79.690516366725205444, + 107.10321054067389923, 62.411534060687699821, 77.333305322546948446, 46.188007829925481929, + 19.29161603258762625, 59.530332750346133253, 48.480088537402480142, 73.21916549079833203, + 98.072741302792564966, 59.77116499332987587, 43.570068460114271147, 99.748477220156928524, + 103.85363159150074353, 60.790037000260781497, 127.49498588650749298, 61.02459859774535289, + 55.077089598795282654, 106.12376284204219701, 109.88948876637368812, 60.3135627398842189, + 10.075534376475843601, 86.190293805288092699, 125.87623215272105881, 99.743827582107769558, + 80.29970599944863352, 0.64162717933504609391, 87.980634640567586757, 60.525704482290166197, + 68.211783085153001593, 125.46269293621298857, 40.041818250887445174, 84.753172810087562539, + 15.041231211627746234, 60.225664930028870003, 123.86509646344347857, 91.591795556014403701, + 99.35132274437637534, 82.662945648324239301, 40.158407316183001967, 121.13382749272568617, + 109.09489544645475689, 34.38629584599766531, 95.193115879836113891, 41.791295178620202933, + 127.49681855438757339, 32.966651173228456173, 62.076186294842045754, 124.96248049124551471, + 80.087112055862235138, 89.517936327149072895, 57.754524689640675206, 87.247716755871806527, + 17.796091011568933027, 40.392657969376159599, 103.42026967957644956, 66.809513995467568748, + 39.499303718010196462, 66.450947499088215409, 22.745491230383777292, 62.11711832350192708, + 18.106095899038336938, 19.537398125452455133, 21.621244772370118881, 38.193957246578065678, + 112.08105493714174372, 52.016199854919250356, 73.041571627942175837, 104.28780336979980348, + 125.86160443624612526, 52.989084510063548805, 17.70436595797946211, 65.351172626960760681, + 121.18685350166197168, 47.622779946454102173, 7.9710742582428792957, 43.503058322166907601, + 27.299103535086032934, 98.869682934935553931, 84.272476735386590008, 62.645914838314638473, + 116.11177444864370045, 109.61661355091564474, 33.49842022887969506, 19.45431866189755965, + 101.66874990356518538, 37.419297487544099567, 89.532477508470037719, 84.502235468225990189, + 64.764841075986623764, 84.222490601518074982, 99.867283358667918947, 47.181629656617587898, + 16.887230126085341908, 9.5504424917453434318, 112.8668169433294679, 123.8789886764025141, + 2.0056504014428355731, 73.033331659626128385, 122.96885327994459658, 54.121588761961902492, + 22.271138708791113459, 91.053898706544714514, 64.062575508407462621, 110.66111510187693057, + 108.54465724904002855, 23.575267509018885903, 67.20191297895507887, 29.329904766116669634, + 71.420828567010175902, 50.88449212463456206, 122.17809049796778709, 103.87693583992950153, + 49.002661035792698385, 3.8519980050659796689, 69.735314147819735808, 106.59124072165650432, + 19.700407612523122225, 79.205636343744117767, 66.866674608067114605, 113.55777462874902994, + 95.437296779527969193, 24.542721798410639167, 13.68629112207054277, 73.429868363025889266, + 74.43685280129648163, 122.24145193947697408, 62.460442731200600974, 16.083966347563546151, + 87.172120603710936848, 14.946972987057961291, 88.944174803051282652, 109.82233603519489407, + 4.9268920884132967331, 87.52055612140611629, 65.820545139675232349, 47.044660517101874575, + 18.179409525855589891, 41.825736118295026245, 112.05760130394628504, 55.436363783850538312, + 42.702939839859027416, 22.536858412913716165, 25.548701153100410011, 73.065735563399357488, + 82.012096390753868036, 77.462629209763690596, 118.86689770139491884, 33.428563383473374415, + 104.90105820559620042, 29.406780106393853202, 45.162086504427861655, 96.98147328543200274, + 5.3981423546429141425, 22.859107908556325128, 47.928598395526933018, 18.847378371589002199, + 65.609864206366182771, 116.18744277400401188, 62.1570343602252251, 67.020955542498995783, + 63.620326621046842774, 28.702311389053647872, 20.552616204586229287, 96.524834538518916816, + 73.451602126981015317, 89.530935644419514574, 0.64411044251755811274, 27.669081562249630224, + 72.28726300291964435, 36.690314302966726245, 48.082665649551927345, 33.436191412125481293, + 76.843193350603542058, 2.926902066476031905, 50.114108242476504529, 22.879311933476856211, + 7.8607722311826364603, 59.998348236436868319, 66.828260067111841636, 31.20035181363709853, + 44.760121096096554538, 77.649884257119992981, 62.491239285966003081, 34.958743354603939224, + 113.6567438442070852, 42.500304701326967916, 120.37692393378529232, 41.103564127693971386, + 33.791984002462413628, 43.350163213897758396, 115.02195356630181777, 109.30110199965565698, + 107.06736683116832864, 76.177426033646042924, 72.831311845133313909, 64.744862162155186525, + 69.145723342960991431, 6.3914630146937270183, 94.788900419851415791, 44.66280179475506884, + 50.758594692400947679, 36.166634052420704393, 108.21547434860985959, 70.416038570860109758, + 1.6994853165306267329, 74.46201078268859419, 115.90964344070380321, 12.57577847578068031, + 14.369435392753075575, 98.944161053157586139, 3.7643378007960563991, 12.745768303859222215, + 116.693917965349101, 117.4039631155465031, 62.111446641829388682, 63.645484618136833888, + 41.93958796694278135, 98.937565262425778201, 126.15098455172119429, 97.508074218574620318, + 95.174489671211631503, 118.42131912412878592, 17.776028631222288823, 110.39537580093747238, + 68.011172699632879812, 18.364169135442352854, 88.677845165439066477, 26.094497868976759491, + 31.521640799383021658, 84.992064472164202016, 69.336769035333418287, 123.24058862437595963, + 114.37134734559003846, 97.716684066406742204, 69.416222295381885488, 104.1156252834625775, + 68.551114790683641331, 49.402808475722849835, 32.838537122031993931, 5.2806632449282915331, + 40.18737696565585793, 54.61631907602713909, 40.301980650820041774, 121.64010426830645883, + 75.594944704564113636, 9.7745175865311466623, 124.50552815102128079, 3.5232023323042085394, + 50.395434411548194475, 110.16634246040484868, 9.3811146931257098913, 52.78580968098322046, + 9.7327356198256893549, 11.970911959109798772, 75.985072863502864493, 87.525780423788091866, + 1.4822758570335281547, 119.60072875299738371, 25.709077583040198078, 67.550882466250186553, + 54.070746866815170506, 97.425915090876515023, 44.1322013944372884, 15.356323872660141205, + 106.09863186472648522, 87.238076869693031767, 18.167290555593353929, 79.335215237060765503, + 32.652251402148976922, 106.55288104909777758, 87.661255205501220189, 22.299635950461379252, + 93.195813851405546302, 89.785410240579949459, 50.113182889752351912, 0.66625550130993360654, + 56.315351126690075034, 111.94919794544694014, 103.48234061771654524, 94.791571677989850286, + 86.910219295274146134, 67.082286932414717739, 30.430551367328007473, 74.507668723043025238, + 63.947323270742344903, 78.161618509835534496, 65.827389065099850995, 75.357190648308460368, + 9.0550068673946952913, 74.236667852972459514, 7.7060948393263970502, 0.14646191156862187199, + 34.134019745790283196, 37.265119503732421435, 58.769210109145205934, 76.995970860505622113, + 46.553081887996086152, 5.7436360215797321871, 70.241493097990314709, 82.199847529249382205, + 106.03984988788579358, 104.28523219524140586, 24.30620589482714422, 111.56162018374016043, + 59.838373025952023454, 4.4709561650743125938, 84.843367878718709107, 75.343558053889864823, + 96.59557184589721146, 48.706937202496192185, 34.513396110960457008, 81.653155747866549063, + 112.78780249438568717, 118.60156604657095158, 37.372310926570207812, 3.0034752940955513623, + 98.424400141731894109, 71.552570006289897719, 65.715440871794271516, 31.759605236191418953, + 105.73244802773842821, 102.30885148432207643, 114.54341691496301792, 69.381700779827951919, + 72.287999868574843276, 36.733034567507274915, 14.496322009326831903, 18.60333147834171541, + 107.91548863263597013, 58.402771572833444225, 123.94546202167111915, 57.512988683909497922, + 16.546653255620185519, 32.92382635920876055, 111.01092576784503763, 113.09652141640253831, + 62.853225566050241468, 114.75948833337679389, 123.20683284509141231, 117.15519380101250135, + 62.185174995855049929, 94.161289910243795021, 125.68689821815860341, 80.520999134616431547, + 120.96422337778130895, 111.03184110240908922, 109.30902928368959692, 102.10559687612476409, + 43.885071577518829145, 55.997589183458330808, 19.595749082662223373, 108.65323713935140404, + 68.96681361425362411, 113.02515947526626405, 103.25111890463085729, 68.463067419044818962, + 91.710580478160409257, 100.08194875626577414, 2.6240097256595618092, 44.1792751259963552, + 123.46689571762908599, 90.779659161296876846, 80.975316499352629762, 29.531023118757730117, + 15.517782169823476579, 85.862133088736300124, 10.886876750399096636, 28.235050846840749728, + 26.346588140480889706, 31.381032733454048866, 86.206421081347798463, 124.82306812137903762, + 26.666610645093896892, 92.376015659850963857, 38.583232065175252501, 119.06066550069226651, + 96.960177074808598263, 18.438330981600302039, 68.145482605585129932, 119.54232998665975174, + 87.140136920232180273, 71.496954440317495028, 79.70726318300148705, 121.58007400052520097, + 126.98997177301498596, 122.04919719549070578, 110.15417919759420329, 84.247525684088031994, + 91.778977532747376245, 120.6271254797684378, 20.151068752955325181, 44.380587610579823377, + 123.7524643054457556, 71.487655164219177095, 32.59941199889726704, 1.2832543586737301666, + 47.961269281135173514, 121.05140896458397037, 8.4235661703096411657, 122.92538587242597714, + 80.083636501778528327, 41.506345620175125077, 30.082462423255492467, 120.45132986006137799, + 119.73019292689059512, 55.18359111203244538, 70.702645488756388659, 37.325891296648478601, + 80.316814632369641913, 114.26765498545501032, 90.189790892909513786, 68.772591691998968599, + 62.386231759672227781, 83.582590357244043844, 126.99363710877514677, 65.933302346456912346, + 124.15237258968772949, 121.92496098249466741, 32.174224111728108255, 51.03587265429814579, + 115.50904937928498839, 46.495433511743613053, 35.592182023137866054, 80.785315938755957177, + 78.840539359156537103, 5.6190279909351374954, 78.998607436024030903, 4.9018949981764308177, + 45.490982460767554585, 124.23423664700385416, 36.212191798076673876, 39.074796250904910266, + 43.242489544740237761, 76.387914493159769336, 96.162109874283487443, 104.03239970984213869, + 18.083143255887989653, 80.575606739603244932, 123.72320887249225052, 105.97816902012709761, + 35.408731915962562198, 2.7023452539251593407, 114.37370700332394335, 95.245559892908204347, + 15.942148516485758591, 87.006116644333815202, 54.598207070175703848, 69.73936586987474584, + 40.544953470773180015, 125.29182967663291492, 104.22354889729103888, 91.233227101831289474, + 66.996840457759390119, 38.908637323798757279, 75.337499807130370755, 74.838594975091837114, + 51.064955016943713417, 41.004470936455618357, 1.5296821519768855069, 40.444981203039787943, + 71.734566717335837893, 94.363259313235175796, 33.774460252170683816, 19.100884983494324842, + 97.733633886662573786, 119.7579773528050282, 4.011300802889309125, 18.066663319255894748, + 117.93770655988919316, 108.24317752392380498, 44.542277417585864896, 54.107797413093067007, + 0.12515101681856322102, 93.322230203757499112, 89.089314498080057092, 47.150535018041409785, + 6.4038259579101577401, 58.659809532236977248, 14.841657134020351805, 101.7689842492727621, + 116.35618099593921215, 79.753871679859003052, 98.00532207158539677, 7.7039960101355973165, + 11.470628295643109595, 85.18248144331300864, 39.400815225049882429, 30.411272687491873512, + 5.7333492161378671881, 99.115549257501697866, 62.874593559055938385, 49.085443596821278334, + 27.372582244144723518, 18.859736726055416511, 20.873705602596601238, 116.48290387895394815, + 124.92088546240120195, 32.167932695130730281, 46.344241207421873696, 29.89394597411956056, + 49.888349606106203282, 91.644672070389788132, 9.8537841768302314449, 47.041112242815870559, + 3.6410902793504646979, 94.08932103420374915, 36.358819051711179782, 83.651472236593690468, + 96.115202607892570086, 110.87272756770107662, 85.405879679718054831, 45.073716825827432331, + 51.097402306204458, 18.131471126802352956, 36.024192781511374051, 26.925258419531019172, + 109.73379540278983768, 66.857126766950386809, 81.802116411192400847, 58.813560212787706405, + 90.324173008859361289, 65.96294657086400548, 10.796284709285828285, 45.718215817112650257, + 95.857196791053866036, 37.694756743181642378, 3.21972841273600352, 104.37488554800802376, + 124.31406872045408818, 6.0419110849979915656, 127.24065324209368555, 57.404622778107295744, + 41.105232409176096553, 65.04966907704147161, 18.903204253965668613, 51.061871288839029148, + 1.2882208850351162255, 55.338163124502898427, 16.5745260058392887, 73.380628605933452491, + 96.16533129910385469, 66.872382824254600564, 25.686386701207084116, 5.8538041329520638101, + 100.22821648495300906, 45.758623866953712422, 15.721544462365272921, 119.99669647287737462, + 5.6565201342236832716, 62.400703627274197061, 89.520242192196747055, 27.299768514239985961, + 124.98247857193200616, 69.917486709211516427, 99.313487688414170407, 85.00060940265757381, + 112.75384786757058464, 82.207128255387942772, 67.583968004924827255, 86.700326427799154771, + 102.04390713260727352, 90.602203999314951943, 86.134733662340295268, 24.354852067295723828, + 17.662623690270265797, 1.489724324314011028, 10.291446685921982862, 12.782926029391092015, + 61.577800839702831581, 89.325603589510137681, 101.51718938480189536, 72.333268104845046764, + 88.430948697223357158, 12.832077141720219515, 3.3989706330648914445, 20.92402156538082636, + 103.81928688140760642, 25.15155695156136062, 28.73887078550978913, 69.888322106315172277, + 7.5286756015921127982, 25.491536607722082408, 105.38783593070183997, 106.80792623109300621, + 124.22289328365877736, 127.29096923627366778, 83.879175933889200678, 69.875130524855194381, + 124.30196910344602657, 67.016148437152878614, 62.348979342426900985, 108.84263824825757183, + 35.552057262448215624, 92.790751601878582733, 8.0223453992657596245, 36.728338270888343686, + 49.355690330878132954, 52.188995737953518983, 63.043281598769681295, 41.984128944332042011, + 10.673538070670474553, 118.48117724875555723, 100.74269469118371489, 67.433368132817122387, + 10.832444590767408954, 80.231250566928792978, 9.1022295813672826625, 98.805616951445699669, + 65.677074244063987862, 10.561326489856583066, 80.37475393131171586, 109.23263815205427818, + 80.603961301643721526, 115.28020853661655565, 23.189889409128227271, 19.549035173065931303, + 121.01105630204256158, 7.0464046646084170789, 100.79086882310002693, 92.33268492080969736, + 18.762229386251419783, 105.57161936196644092, 19.46547123965137871, 23.941823918223235523, + 23.970145727009366965, 47.051560847576183733, 2.9645517140706942882, 111.20145750599476742, + 51.418155166084034136, 7.1017649325003731064, 108.14149373363397899, 66.851830181753030047, + 88.2644027888745768, 30.71264774532392039, 84.197263729456608417, 46.476153739386063535, + 36.334581111190345837, 30.670430474121531006, 65.304502804301591823, 85.105762098199193133, + 47.322510411002440378, 44.599271900926396484, 58.391627702814730583, 51.570820481159898918, + 100.22636577950470382, 1.3325110026198672131, 112.63070225338378805, 95.898395890897518257, + 78.964681235436728457, 61.583143355983338552, 45.820438590551930247, 6.1645738648294354789, + 60.861102734659652924, 21.015337446086050477, 127.89464654148832778, 28.323237019674706971, + 3.6547781302033399697, 22.714381296616920736, 18.110013734793028561, 20.473335705944919027, + 15.4121896786527941, 0.29292382313724374399, 68.268039491580566391, 74.530239007464842871, + 117.53842021829404985, 25.991941721011244226, 93.106163775992172305, 11.487272043163102353, + 12.482986195984267397, 36.399695058502402389, 84.079699775775225135, 80.570464390482811723, + 48.61241178965792642, 95.123240367480320856, 119.67674605190404691, 8.9419123301522631664, + 41.686735757441056194, 22.687116107783367625, 65.191143691794422921, 97.41387440499238437, + 69.026792221924551995, 35.306311495736736106, 97.575604988775012316, 109.20313209314190317, + 74.744621853140415624, 6.0069505881947407033, 68.848800283467426198, 15.105140012583433418, + 3.4308817435885430314, 63.519210472386475885, 83.464896055480494397, 76.61770296864779084, + 101.08683382992967381, 10.763401559659541817, 16.575999737149686553, 73.466069135014549829, + 28.992644018653663807, 37.2066629566870688, 87.830977265271940269, 116.80554314567052643, + 119.89092404334223829, 115.02597736781899584, 33.093306511240371037, 65.847652718421159079, + 94.021851535693713231, 98.193042832805076614, 125.70645113210412092, 101.51897666675722576, + 118.4136656901864626, 106.31038760202500271, 124.37034999171373784, 60.32257982049122802, + 123.3737964363208448, 33.041998269236501073, 113.92844675556625589, 94.063682204821816413, + 90.618058567382831825, 76.211193752249528188, 87.770143155037658289, 111.99517836691666162, + 39.191498165328084724, 89.306474278706446057, 9.9336272285108861979, 98.050318950536166085, + 78.502237809265352553, 8.9261348380932759028, 55.421160956324456492, 72.163897512531548273, + 5.2480194513191236183, 88.358550251996348379, 118.93379143526180997, 53.559318322597391671, + 33.950632998705259524, 59.062046237515460234, 31.035564339650591137, 43.724266177472600248, + 21.773753500798193272, 56.470101693681499455, 52.693176280961779412, 62.762065466911735712, + 44.412842162699234905, 121.64613624275807524, 53.333221290191431763, 56.752031319701927714, + 77.166464130354142981, 110.12133100138817099, 65.920354149617196526, 36.876661963204242056, + 8.2909652111738978419, 111.08465997332314146, 46.280273840467998525, 14.993908880638628034, + 31.414526366006612079, 115.16014800105403992, 125.97994354603360989, 116.09839439098504954, + 92.308358395192044554, 40.495051368179701967, 55.557955065498390468, 113.2542509595368756, + 40.302137505910650361, 88.761175221163284732, 119.50492861089514918, 14.97531032843835419, + 65.19882399779453408, 2.5665087173474603333, 95.922538562273985008, 114.10281792916794075, + 16.84713234062292031, 117.85077174485559226, 32.167273003557056654, 83.012691240350250155, + 60.164924846514622914, 112.90265972012639395, 111.46038585378119024, 110.36718222406852874, + 13.405290977512777317, 74.651782593300595181, 32.633629264742921805, 100.53530997091365862, + 52.379581785822665552, 9.5451833839979371987, 124.77246351934809354, 39.165180714491725666, + 125.98727421755393152, 3.8666046929174626712, 120.30474517937909695, 115.84992196498933481, + 64.34844822345621651, 102.07174530859992956, 103.01809875856997678, 92.990867023487226106, + 71.184364046279370086, 33.570631877515552333, 29.681078718313074205, 11.23805598187391297, + 29.997214872048061807, 9.8037899963528616354, 90.981964921538747149, 120.46847329400770832, + 72.424383596153347753, 78.149592501809820533, 86.484979089484113501, 24.77582898632317665, + 64.324219748570612865, 80.064799419684277382, 36.166286511779617285, 33.151213479210127844, + 119.44641774498813902, 83.956338040254195221, 70.817463831925124396, 5.4046905078539566603, + 100.74741400665152469, 62.491119785816408694, 31.884297032975155162, 46.012233288667630404, + 109.19641414035504567, 11.47873173974949168, 81.08990694154999801, 122.58365935326946783, + 80.447097794585715747, 54.466454203666216927, 5.9936809155187802389, 77.817274647601152537, + 22.674999614264379488, 21.677189950183674227, 102.12991003388742683, 82.008941872911236715, + 3.0593643039537710138, 80.889962406083213864, 15.469133434675313765, 60.726518626470351592, + 67.548920504341367632, 38.201769966992287664, 67.467267773328785552, 111.51595470561005641, + 8.02260160577861825, 36.133326638515427476, 107.8754131197820243, 88.486355047847609967, + 89.084554835171729792, 108.21559482618613401, 0.25030203364076442085, 58.644460407518636202, + 50.178628996160114184, 94.30107003608281957, 12.80765191582031548, 117.3196190644739545, + 29.683314268044341588, 75.537968498549162177, 104.71236199188206228, 31.507743359721644083, + 68.010644143170793541, 15.407992020271194633, 22.94125659128985717, 42.36496288662601728, + 78.801630450099764857, 60.822545374983747024, 11.466698432279372355, 70.231098515003395732, + 125.74918711811187677, 98.170887193642556667, 54.745164488289447036, 37.719473452110833023, + 41.747411205196840456, 104.96580775791153428, 121.8417709248024039, 64.335865390261460561, + 92.688482414843747392, 59.78789194823912112, 99.776699212216044543, 55.289344140779576264, + 19.70756835366046289, 94.082224485631741118, 7.2821805587045673747, 60.1786420684074983, + 72.717638103425997542, 39.302944473191018915, 64.23040521578877815, 93.745455135405791225, + 42.811759359436109662, 90.147433651654864661, 102.194804612408916, 36.262942253604705911, + 72.048385563022748102, 53.850516839065676322, 91.46759080558331334, 5.7142535339044115972, + 35.604232822384801693, 117.62712042557905079, 52.648346017722360557, 3.9258931417280109599, + 21.59256941857165657, 91.436431634228938492, 63.714393582107732072, 75.389513486363284755, + 6.4394568254756450187, 80.749771096019685501, 120.62813744090817636, 12.08382216999962111, + 126.4813064841873711, 114.80924555621459149, 82.210464818355831085, 2.0993381540829432197, + 37.806408507931337226, 102.1237425776780583, 2.576441770070232451, 110.67632624900579685, + 33.14905201168221538, 18.76125721187054296, 64.330662598211347358, 5.744765648509201128, + 51.372773402414168231, 11.707608265907765599, 72.456432969906018116, 91.517247733907424845, + 31.44308892473418382, 111.99339294575474923, 11.313040268447366543, 124.8014072545520321, + 51.040484384393494111, 54.599537028483609902, 121.9649571438676503, 11.834973418426670833, + 70.626975376831978792, 42.001218805318785599, 97.507695735144807259, 36.414256510779523524, + 7.1679360098532924894, 45.400652855601947522, 76.087814265218185028, 53.204407998633541865, + 44.269467324680590536, 48.709704134591447655, 35.325247380540531594, 2.9794486486280220561, + 20.582893371843965724, 25.565852058782184031, 123.15560167940930114, 50.651207179023913341, + 75.034378769607428694, 16.666536209693731507, 48.861897394446714316, 25.664154283440439031, + 6.797941266129782889, 41.848043130765290698, 79.638573762815212831, 50.30311390312272124, + 57.477741571023216238, 11.776644212630344555, 15.057351203184225596, 50.983073215447802795, + 82.77567186140731792, 85.615852462189650396, 120.44578656732119271, 126.58193847255097353, + 39.758351867782039335, 11.75026104971402674, 120.60393820689569111, 6.0322968743057572283, + 124.69795868485743995, 89.685276496515143663, 71.104114524900069227, 57.581503203757165466, + 16.044690798531519249, 73.456676541776687372, 98.711380661756265908, 104.37799147590703797, + 126.08656319753936259, 83.968257888664084021, 21.347076141344587086, 108.96235449751475244, + 73.485389382371067768, 6.8667362656342447735, 21.664889181538455887, 32.462501133857585955, + 18.204459162738203304, 69.611233902895037318, 3.3541484881279757246, 21.122652979716804111, + 32.749507862627069699, 90.465276304112194339, 33.207922603291081032, 102.5604170732331113, + 46.379778818256454542, 39.098070346135500586, 114.02211260408512317, 14.092809329220472137, + 73.581737646203691838, 56.66536984161939472, 37.524458772506477544, 83.14323872393288184, + 38.93094247930275742, 47.883647836446471047, 47.94029145401873393, 94.103121695152367465, + 5.9291034281450265553, 94.402915011989534833, 102.83631033216806827, 14.203529865004384192, + 88.28298746727159596, 5.7036603635096980724, 48.528805577749153599, 61.425295490651478758, + 40.394527458913216833, 92.95230747877212707, 72.669162222380691674, 61.340860948246699991, + 2.6090056086068216246, 42.211524196398386266, 94.645020822004880756, 89.198543801852792967, + 116.78325540562946117, 103.14164096232343582, 72.452731559009407647, 2.6650220052433724049, + 97.261404506771214074, 63.796791781798674492, 29.929362470873456914, 123.1662867119666771, + 91.640877181103860494, 12.329147729658870958, 121.72220546931930585, 42.030674892175738933, + 127.78929308297665557, 56.646474039349413943, 7.3095562604066799395, 45.428762593233841471, + 36.220027469586057123, 40.946671411889838055, 30.824379357305588201, 0.58584764627812546678, + 8.5360789831647707615, 21.06047801493332372, 107.07684043658809969, 51.983883442026126431, + 58.212327551984344609, 22.974544086326204706, 24.965972391968534794, 72.799390117008442758, + 40.159399551554088248, 33.140928780965623446, 97.224823579319490818, 62.246480734964279691, + 111.35349210380809382, 17.883824660304526333, 83.373471514882112388, 45.374232215570373228, + 2.3822873835924838204, 66.82774880998840672, 10.053584443849103991, 70.61262299147711019, + 67.151209977553662611, 90.406264186287444318, 21.489243706280831248, 12.013901176393119385, + 9.6976005669348523952, 30.210280025170504814, 6.8617634871770860627, 127.03842094477658975, + 38.929792110964626772, 25.235405937299219659, 74.173667659859347623, 21.526803119319083635, + 33.151999474303011084, 18.932138270029099658, 57.985288037307327613, 74.413325913377775578, + 47.661954530547518516, 105.61108629134469084, 111.78184808668811456, 102.05195473563799169, + 66.186613022484380053, 3.6953054368459561374, 60.043703071391064441, 68.386085665613791207, + 123.41290226421187981, 75.037953333518089494, 108.82733138037656317, 84.620775204053643392, + 120.74069998342747567, 120.64515964098609402, 118.74759287264168961, 66.083996538476640126, + 99.856893511136149755, 60.127364409647270804, 53.236117134769301629, 24.422387504502694355, + 47.540286310078954557, 95.990356733833323233, 78.382996330659807427, 50.612948557412892114, + 19.867254457025410375, 68.100637901075970149, 29.004475618530705106, 17.852269676186551806, + 110.84232191265255096, 16.327795025063096546, 10.496038902641885215, 48.717100503996334737, + 109.86758287052361993, 107.11863664519478334, 67.901265997410519049, 118.12409247503092047, + 62.071128679301182274, 87.448532354945200495, 43.547507001596386544, 112.94020338736299891, + 105.38635256192355882, 125.52413093382347142, 88.825684325402107788, 115.29227248551615048, + 106.66644258038286353, 113.50406263940749341, 26.33292826071192394, 92.242662002779979957, + 3.8407082992343930528, 73.753323926408484112, 16.581930422351433663, 94.169319946646282915, + 92.56054768093599705, 29.987817761277256068, 62.829052732016862137, 102.32029600211171783, + 123.95988709207085776, 104.19678878197373706, 56.616716790384089109, 80.990102736359403934, + 111.11591013100041891, 98.508501919073751196, 80.604275011824938701, 49.522350442330207443, + 111.00985722179029835, 29.95062065688034636, 2.3976479955890681595, 5.1330174346985586453, + 63.845077124551607994, 100.20563585833588149, 33.694264681249478599, 107.70154348971118452, + 64.334546007117751287, 38.025382480700500309, 120.32984969303288381, 97.805319440256425878, + 94.920771707566018449, 92.734364448137057479, 26.810581955029192613, 21.303565186601190362, + 65.267258529489481589, 73.070619941827317234, 104.7591635716453311, 19.090366767999512376, + 121.54492703869618708, 78.330361428987089312, 123.97454843510786304, 7.7332093858385633212, + 112.60949035876183189, 103.6998439299823076, 0.69689644691607099958, 76.143490617203497095, + 78.03619751714359154, 57.981734046978090191, 14.368728092558740173, 67.141263755031104665, + 59.36215743662614841, 22.476111963747825939, 59.994429744096123613, 19.60757999270936125, + 53.963929843081132276, 112.93694658801905462, 16.848767192310333485, 28.299185003623279044, + 44.969958178968227003, 49.551657972649991279, 0.64843949714486370794, 32.129598839368554763, + 72.332573023559234571, 66.302426958423893666, 110.89283548997991602, 39.91267608051202842, + 13.634927663850248791, 10.809381015711551299, 73.494828013303049374, 124.98223957163281739, + 63.768594065950310323, 92.024466577338898787, 90.392828280710091349, 22.95746347950262134, + 34.179813883103633998, 117.16731870654257364, 32.894195589171431493, 108.93290840733243385, + 11.987361831041198457, 27.634549295202305075, 45.349999228528758977, 43.354379900370986434, + 76.259820067778491648, 36.017883745822473429, 6.1187286079111800063, 33.779924812166427728, + 30.93826686935062753, 121.45303725294434116, 7.0978410086827352643, 76.403539933988213306, + 6.9345355466612090822, 95.031909411220112815, 16.0452032115572365, 72.26665327703449293, + 87.750826239567686571, 48.972710095698857913, 50.169109670347097563, 88.431189652372268029, + 0.5006040672815288417, 117.2889208150372724, 100.35725799232386635, 60.60214007216563914, + 25.615303831644268939, 106.63923812894790899, 59.366628536092321156, 23.075936997101962334, + 81.424723983764124569, 63.015486719446926145, 8.0212882863415870816, 30.815984040542389266, + 45.882513182579714339, 84.729925773255672539, 29.603260900199529715, 121.64509074996749405, + 22.933396864562382689, 12.462197030010429444, 123.49837423622739152, 68.341774387285113335, + 109.49032897657889407, 75.438946904221666045, 83.49482241039731889, 81.931615515826706542, + 115.68354184960844577, 0.67173078052655910142, 57.376964829687494785, 119.57578389648188022, + 71.553398424432089087, 110.57868828155915253, 39.415136707324563758, 60.164448971263482235, + 14.564361117409134749, 120.35728413681863458, 17.435276206851995084, 78.605888946385675808, + 0.46081043158119427972, 59.49091027081158245, 85.623518718875857303, 52.294867303313367302, + 76.389609224817832001, 72.525884507213049801, 16.096771126045496203, 107.70103367813499062, + 54.935181611166626681, 11.428507067808823194, 71.208465644773241365, 107.25424085115810158, + 105.29669203544472111, 7.8517862834560219198, 43.185138837146951118, 54.872863268457876984, + 127.42878716421910212, 22.779026972726569511, 12.878913650954928016, 33.499542192043008981, + 113.25627488181635272, 24.167644340002880199, 124.96261296837838017, 101.61849111243282096, + 36.42092963671166217, 4.1986763081658864394, 75.612817015866312431, 76.247485155356116593, + 5.1528835401441028807, 93.352652498011593707, 66.298104023364430759, 37.522514423744723899, + 0.6613251964226947166, 11.489531297018402256, 102.74554680482833646, 23.415216531819169177, + 16.91286593981567421, 55.03449546781484969, 62.886177849472005619, 95.98678589150949847, + 22.626080536898371065, 121.6028145091040642, 102.08096876878698822, 109.19907405697085778, + 115.9299142877353006, 23.669946836856979644, 13.253950753663957585, 84.002437610641209176, + 67.015391470289614517, 72.828513021559047047, 14.335872019706584979, 90.801305711207533022, + 24.175628530436370056, 106.40881599726708373, 88.538934649361181073, 97.41940826918289531, + 70.650494761081063189, 5.9588972972560441121, 41.165786743687931448, 51.131704117568006041, + 118.31120335881860228, 101.30241435805146466, 22.068757539214857388, 33.333072419387463015, + 97.723794788893428631, 51.328308566880878061, 13.595882532259565778, 83.696086261534219375, + 31.277147525630425662, 100.60622780624544248, 114.95548314204643248, 23.55328842526068911, + 30.114702406368451193, 101.96614643089924357, 37.551343722818273818, 43.231704924382938771, + 112.89157313464602339, 125.16387694510194706, 79.51670373556407867, 23.500522099431691458, + 113.20787641379138222, 12.064593748615152435, 121.39591736971851788, 51.370552993033925304, + 14.208229049800138455, 115.16300640751433093, 32.089381597066676477, 18.913353083557012724, + 69.422761323516169796, 80.755982951817713911, 124.17312639508236316, 39.936515777328168042, + 42.69415228269281215, 89.924708995033142855, 18.970778764742135536, 13.733472531268489547, + 43.329778363076911774, 64.925002267715171911, 36.408918325480044587, 11.222467805790074635, + 6.7082969762559514493, 42.245305959433608223, 65.499015725257777376, 52.930552608224388678, + 66.415845206585800042, 77.120834146466222592, 92.759557636512909085, 78.19614069227463915, + 100.04422520817024633, 28.185618658444582252, 19.163475292407383677, 113.33073968323878944, + 75.048917545016593067, 38.286477447865763679, 77.861884958605514839, 95.767295672892942093, + 95.880582908041105838, 60.20624339030473493, 11.858206856293691089, 60.805830023982707644, + 77.672620664336136542, 28.407059730012406362, 48.565974934543191921, 11.407320727019396145, + 97.057611155498307198, 122.85059098130295752, 80.789054917830071645, 57.904614957547892118, + 17.338324444761383347, 122.68172189649339998, 5.2180112172136432491, 84.423048392800410511, + 61.290041644013399491, 50.397087603709223913, 105.56651081126256031, 78.283281924650509609, + 16.905463118018815294, 5.3300440104903827887, 66.522809013542428147, 127.59358356359734898, + 59.858724941750551807, 118.33257342393699219, 55.281754362207720987, 24.658295459321379894, + 115.4444109386386117, 84.061349784355115844, 127.57858616595331114, 113.29294807869882789, + 14.619112520813359879, 90.857525186467682943, 72.440054939172114246, 81.89334282377967611, + 61.648758714611176401, 1.1716952925562509336, 17.072157966329541523, 42.12095602987028542, + 86.153680873176199384, 103.96776688405225286, 116.42465510396868922, 45.949088172652409412, + 49.931944783940707566, 17.598780234016885515, 80.318799103108176496, 66.28185756193488487, + 66.449647158638981637, 124.49296146993219736, 94.706984207616187632, 35.767649320612690644, + 38.746943029764224775, 90.748464431140746456, 4.7645747671886056196, 5.6554976199768134393, + 20.107168887701845961, 13.225245982957858359, 6.3024199551109632012, 52.812528372574888635, + 42.978487412561662495, 24.027802352786238771, 19.39520113386970479, 60.420560050344647607, + 13.723526974357810104, 126.0768418895531795, 77.859584221929253545, 50.470811874602077296, + 20.347335319718695246, 43.05360623863816727, 66.303998948606022168, 37.864276540058199316, + 115.97057607461829321, 20.826651826755551156, 95.323909061098675011, 83.222172582693019649, + 95.563696173379867105, 76.103909471279621357, 4.3732260449687601067, 7.3906108736919122748, + 120.08740614278576686, 8.7721713312312203925, 118.8258045284273976, 22.075906667039816966, + 89.654662760756764328, 41.241550408110924764, 113.48139996685858932, 113.29031928197582602, + 109.4951857452870172, 4.1679930769569182303, 71.713787022272299509, 120.25472881929454161, + 106.47223426953860326, 48.844775009005388711, 95.080572620161547093, 63.980713467670284444, + 28.765992661319614854, 101.22589711482578423, 39.734508914054458728, 8.2012758021519402973, + 58.008951237061410211, 35.70453935237674159, 93.684643825305101927, 32.655590050126193091, + 20.992077805283770431, 97.434201007996307453, 91.735165741050877841, 86.237273290393204661, + 7.802531994824676076, 108.24818495006184094, 124.14225735860600253, 46.897064709890400991, + 87.095014003196411068, 97.880406774729635799, 82.772705123850755626, 123.04826186765058083, + 49.651368650807853555, 102.58454497103593894, 85.332885160769365029, 99.008125278814986814, + 52.665856521427485859, 56.485324005559959915, 7.6814165984724240843, 19.506647852816968225, + 33.163860844706505304, 60.338639893296203809, 57.121095361871994101, 59.975635522554512136, + 125.65810546403736225, 76.64059200422707363, 119.9197741841453535, 80.393577563947474118, + 113.2334335807718162, 33.980205472722445847, 94.231820262004475808, 69.017003838151140371, + 33.208550023649877403, 99.044700884664052865, 94.019714443580596708, 59.901241313760692719, + 4.7952959911781363189, 10.266034869397117291, 127.69015424910685397, 72.411271716671762988, + 67.388529362502595177, 87.403086979426007019, 0.66909201423550257459, 76.050764961404638598, + 112.65969938606940559, 67.610638880516489735, 61.841543415135674877, 57.468728896274114959, + 53.621163910058385227, 42.607130373206018703, 2.5345170589826011565, 18.141239883658272447, + 81.518327143290662207, 38.180733536002662731, 115.08985407739601214, 28.660722857977816602, + 119.94909687021572609, 15.466418771680764621, 97.218980717527301749, 79.3996878599646152, + 1.393792893835779978, 24.286981234410632169, 28.07239503428718308, 115.96346809395618038, + 28.737456185121118324, 6.2825275100622093305, 118.72431487325229682, 44.952223927495651878, + 119.98885948819224723, 39.215159985418722499, 107.92785968616590253, 97.873893176038109232, + 33.69753438462066697, 56.598370007246558089, 89.939916357936454006, 99.103315945299982559, + 1.2968789942897274159, 64.259197678740747506, 16.66514604712210712, 4.6048539168514253106, + 93.785670979959832039, 79.825352161024056841, 27.269855327700497583, 21.618762031426740577, + 18.989656026609736728, 121.96447914326563478, 127.53718813190425863, 56.048933154681435553, + 52.785656561420182697, 45.914926959005242679, 68.359627766210905975, 106.33463741308514727, + 65.788391178346500965, 89.865816814664867707, 23.974723662082396913, 55.26909859040461015, + 90.699998457057517953, 86.708759800745610846, 24.519640135556983296, 72.035767491644946858, + 12.237457215822360013, 67.559849624332855456, 61.87653373870489304, 114.90607450588868232, + 14.195682017369108507, 24.807079867976426613, 13.869071093326056143, 62.063818822440225631, + 32.090406423118110979, 16.53330655407262384, 47.501652479135373142, 97.945420191397715826, + 100.3382193406978331, 48.862379304744536057, 1.0012081345666956622, 106.57784163007818279, + 72.714515984647732694, 121.20428014433127828, 51.230607663292175857, 85.27847625789581798, + 118.73325707218464231, 46.151873994207562646, 34.849447967528249137, 126.03097343889385229, + 16.042576572683174163, 61.631968081084778532, 91.765026365163066657, 41.459851546511345077, + 59.206521800402697409, 115.2901814999349881, 45.866793729124765377, 24.924394060024496866, + 118.99674847245842102, 8.6835487745738646481, 90.980657953161426121, 22.87789380844697007, + 38.989644820798275759, 35.863231031657051062, 103.36708369921689155, 1.3434615610531182028, + 114.75392965937862755, 111.15156779296739842, 15.106796848867816152, 93.157376563118305057, + 78.830273414649127517, 120.32889794252696447, 29.128722234821907477, 112.71456827363726916, + 34.870552413707628148, 29.211777892771351617, 0.92162086316238855943, 118.98182054162680288, + 43.247037437751714606, 104.58973460663037258, 24.77921844963930198, 17.051769014426099602, + 32.193542252094630385, 87.402067356269981246, 109.87036322233325336, 22.857014135621284368, + 14.416931289550120709, 86.508481702319841133, 82.593384070889442228, 15.70357256691204384, + 86.370277674293902237, 109.74572653691939195, 126.85757432843820425, 45.558053945453139022, + 25.757827301909856033, 66.999084384089655941, 98.512549763632705435, 48.335288680009398377, + 121.92522593676039833, 75.236982224865641911, 72.841859273423324339, 8.3973526163354108576, + 23.225634031736262841, 24.494970310712233186, 10.30576708029184374, 58.705304996026825393, + 4.5962080467288615182, 75.045028847489447799, 1.3226503928453894332, 22.979062594040442491, + 77.491093609656672925, 46.830433063638338353, 33.82573187963134842, 110.06899093562969938, + 125.77235569894764922, 63.973571783018996939, 45.252161073800380109, 115.20562901821176638, + 76.161937537577614421, 90.398148113945353543, 103.85982857547060121, 47.339893673713959288, + 26.507901507331553148, 40.00487522128605633, 6.0307829405828670133, 17.657026043118094094, + 28.671744039416807937, 53.602611422415066045, 48.351257060876378091, 84.81763199453780544, + 49.077869298726000125, 66.838816538369428599, 13.300989522162126377, 11.917794594512088224, + 82.331573487375862896, 102.26340823513965006, 108.62240671764084254, 74.60482871610292932, + 44.137515078429714777, 66.666144838778564008, 67.447589577786857262, 102.65661713376175612, + 27.191765064522769535, 39.39217252306843875, 62.554295051264489302, 73.212455612494522939, + 101.91096628409286495, 47.106576850521378219, 60.229404812740540365, 75.932292861798487138, + 75.102687445636547636, 86.46340984876951552, 97.78314626929568476, 122.32775389020753209, + 31.03340747112815734, 47.001044198867020896, 98.415752827582764439, 24.12918749723394285, + 114.79183473943703575, 102.74110598606785061, 28.416458099603914889, 102.32601281502866186, + 64.178763194133352954, 37.826706167117663426, 10.84552264703597757, 33.5119659036390658, + 120.34625279016472632, 79.873031554656336084, 85.388304565389262279, 51.849417990066285711, + 37.941557529484271072, 27.466945062536979094, 86.659556726157461526, 1.8500045354303438216, + 72.817836650960089173, 22.444935611580149271, 13.416593952511902899, 84.490611918870854424, + 2.9980314505155547522, 105.86110521645241533, 4.8316904131752380636, 26.241668292936083162, + 57.519115273029456148, 28.392281384552916279, 72.088450416340492666, 56.371237316889164504, + 38.326950584818405332, 98.661479366481216857, 22.097835090033186134, 76.572954895735165337, + 27.723769917214667657, 63.534591345789522165, 63.761165816082211677, 120.41248678060946986, + 23.716413712587382179, 121.61166004796905327, 27.345241328672273085, 56.814119460024812724, + 97.131949869086383842, 22.814641454042430269, 66.115222311000252375, 117.70118196260955301, + 33.57810983566014329, 115.80922991509578424, 34.676648889526404673, 117.36344379298679996, + 10.436022434430924477, 40.846096785600821022, 122.58008328802679898, 100.7941752074220858, + 83.133021622528758598, 28.566563849301019218, 33.810926236037630588, 10.660088020984403556, + 5.0456180270884942729, 127.18716712719469797, 119.71744988350474159, 108.66514684787398437, + 110.56350872441544197, 49.316590918646397768, 102.88882187728086137, 40.122699568713869667, + 127.15717233191026025, 98.58589615739765577, 29.238225041630357737, 53.715050372939003864, + 16.88010987834786647, 35.786685647559352219, 123.2975174292223528, 2.3433905851125018671, + 34.144315932659083046, 84.241912059744208818, 44.307361746356036747, 79.935533768108143704, + 104.84931020793737844, 91.898176345304818824, 99.863889567881415132, 35.197560468037409009, + 32.637598206219990971, 4.5637151238734077197, 4.899294317281601252, 120.9859229398680327, + 61.413968415232375264, 71.535298641225381289, 77.493886059532087529, 53.496928862281492911, + 9.5291495343772112392, 11.310995239953626879, 40.214337775403691921, 26.450491965915716719, + 12.604839910221926402, 105.62505674514977727, 85.95697482512332499, 48.055604705572477542, + 38.790402267739409581, 120.84112010069293319, 27.447053948719258187, 124.15368377910999698, + 27.719168443858507089, 100.94162374920415459, 40.694670639437390491, 86.107212477279972518, + 4.6079978972120443359, 75.728553080120036611, 103.94115214923658641, 41.65330365351474029, + 62.647818122200988, 38.444345165389677277, 63.127392346763372188, 24.207818942559242714, + 8.7464520899375202134, 14.781221747387462528, 112.17481228557153372, 17.544342662466078764, + 109.6516090568547952, 44.151813334083271911, 51.309325521513528656, 82.483100816225487506, + 98.962799933720816625, 98.58063856395529001, 90.990371490574034397, 8.3359861539174744394, + 15.427574044548236998, 112.5094576385927212, 84.944468539077206515, 97.6895500180144154, + 62.161145240323094185, 127.96142693534056889, 57.531985322642867686, 74.451794229651568457, + 79.469017828108917456, 16.402551604303880595, 116.01790247412282042, 71.409078704757121159, + 59.369287650610203855, 65.311180100252386183, 41.98415561057117884, 66.868402015996252885, + 55.470331482105393661, 44.474546580786409322, 15.605063989652990131, 88.496369900127319852, + 120.28451471721200505, 93.79412941978443996, 46.190028006396460114, 67.760813549462909577, + 37.545410247705149231, 118.09652373530116165, 99.302737301619345089, 77.169089942075515864, + 42.665770321542368038, 70.016250557629973628, 105.33171304285497172, 112.97064801111991983, + 15.362833196944848169, 39.01329570563393645, 66.327721689413010608, 120.67727978659240762, + 114.2421907237439882, 119.95127104511266225, 123.31621092807836249, 25.281184008457785239, + 111.83954836829434498, 32.787155127898586215, 98.466867161543632392, 67.960410945448529674, + 60.463640524012589594, 10.034007676302280743, 66.417100047303392785, 70.089401769331743708, + 60.039428887161193416, 119.80248262752138544, 9.5905919823562726378, 20.53206973879787256, + 127.38030849821734591, 16.822543433347163955, 6.7770587250088283326, 46.806173958852014039, + 1.338184028474643128, 24.101529922812915174, 97.319398772142449161, 7.2212777610329794697, + 123.68308683027134975, 114.93745779254822992, 107.24232782011677045, 85.214260746412037406, + 5.0690341179652023129, 36.282479767320182873, 35.036654286581324413, 76.361467072008963441, + 102.17970815479202429, 57.321445715959271183, 111.89819374043145217, 30.932837543365167221, + 66.437961435058241477, 30.799375719929230399, 2.7875857876715599559, 48.573962468821264338, + 56.144790068578004139, 103.92693618791236077, 57.474912370242236648, 12.56505502012805664, + 109.44862974650459364, 89.904447854994941736, 111.97771897638449445, 78.430319970841082977, + 87.85571937233544304, 67.747786352076218463, 67.395068769241333939, 113.19674001449675416, + 51.87983271587654599, 70.206631890599965118, 2.5937579885830928106, 0.5183953574814950116, + 33.33029209424421424, 9.2097078337064886, 59.571341959923302056, 31.650704322048113681, + 54.539710655400995165, 43.237524062853481155, 37.979312053223111434, 115.92895828653490753, + 127.07437626380851725, 112.09786630936287111, 105.57131312284036539, 91.829853918014123337, + 8.7192555324254499283, 84.669274826173932524, 3.5767823566966399085, 51.731633629329735413, + 47.949447324164793827, 110.53819718081285828, 53.399996914118673885, 45.417519601491221692, + 49.03928027111760457, 16.071534983289893717, 24.474914431648358004, 7.1196992486657109112, + 123.75306747741342406, 101.81214901177736465, 28.391364034738217015, 49.614159735952853225, + 27.738142186652112287, 124.12763764488045126, 64.180812846236221958, 33.066613108145247679, + 95.003304958274384262, 67.89084038279906963, 72.676438681395666208, 97.724758609489072114, + 2.0024162691370293032, 85.155683260160003556, 17.429031969299103366, 114.40856028866255656, + 102.46121532658798969, 42.556952515795273939, 109.46651414436928462, 92.303747988415125292, + 69.698895935060136253, 124.06194687778770458, 32.085153145366348326, 123.26393616217319504, + 55.530052730326133315, 82.919703093022690155, 118.4130436008090328, 102.58036299986997619, + 91.733587458249530755, 49.848788120052631712, 109.99349694491684204, 17.367097549151367275, + 53.961315906322852243, 45.75578761689394014, 77.979289641596551519, 71.726462063317740103, + 78.734167398433783092, 2.6869231221098743845, 101.50785931876089307, 94.303135585934796836, + 30.213593697739270283, 58.314753126240248093, 29.660546829301893013, 112.65779588505392894, + 58.257444469647452934, 97.429136547274538316, 69.741104827415256295, 58.423555785542703234, + 1.8432417263284150977, 109.96364108325360576, 86.49407487550706719, 81.179469213260745164, + 49.55843689927860396, 34.103538028852199204, 64.387084504192898748, 46.804134712543600472, + 91.740726444666506723, 45.714028271242568735, 28.833862579103879398, 45.016963404643320246, + 37.186768141778884456, 31.407145133827725658, 44.740555348591442453, 91.491453073842421873, + 125.7151486568764085, 91.116107890906278044, 51.515654603823350044, 5.9981687681829498615, + 69.02509952726541087, 96.670577360022434732, 115.85045187352443463, 22.4739644497349218, + 17.683718546846648678, 16.794705232670821715, 46.451268063472525682, 48.989940621424466372, + 20.611534160583687481, 117.41060999205365079, 9.1924160934613610152, 22.090057694978895597, + 2.6453007856907788664, 45.958125188084522961, 26.98218721931334585, 93.660866127276676707, + 67.651463759266334819, 92.137981871263036737, 123.54471139789529843, 127.94714356603799388, + 90.504322147604398197, 102.41125803642717074, 24.323875075158866821, 52.796296227894345066, + 79.719657150941202417, 94.679787347427918576, 53.015803014663106296, 80.009750442572112661, + 12.061565881165734027, 35.314052086236188188, 57.343488078833615873, 107.20522284483013209, + 96.702514121756394161, 41.63526398907561088, 98.155738597455638228, 5.6776330767388571985, + 26.601979044324252754, 23.835589189027814427, 36.663146974755363772, 76.526816470282938099, + 89.244813435285323067, 21.20965743220585864, 88.275030156863067532, 5.3322896775607659947, + 6.8951791555773525033, 77.313234267523512244, 54.38353012904553907, 78.7843450461368775, + 125.10859010253261658, 18.424911224992683856, 75.821932568185729906, 94.213153701042756438, + 120.45880962548471871, 23.864585723600612255, 22.205374891276733251, 44.926819697542669019, + 67.5662925385950075, 116.65550778041506419, 62.06681494225631468, 94.00208839773767977, + 68.831505655165528879, 48.258374994471523678, 101.58366947887770948, 77.482211972135701217, + 56.832916199211467756, 76.652025630060961703, 0.35752638826670590788, 75.653412334235326853, + 21.691045294071955141, 67.023931807281769579, 112.69250558033309062, 31.746063109316310147, + 42.776609130778524559, 103.69883598013257142, 75.883115058968542144, 54.933890125077596167, + 45.319113452314923052, 3.7000090708643256221, 17.635673301920178346, 44.889871223160298541, + 26.833187905027443776, 40.981223837741708849, 5.9960629010347474832, 83.722210432904830668, + 9.6633808263504761271, 52.483336585872166324, 115.0382305460589123, 56.784562769109470537, + 16.176900832680985332, 112.74247463377832901, 76.653901169640448643, 69.322958732962433714, + 44.195670180070010247, 25.145909791470330674, 55.447539834429335315, 127.06918269157904433, + 127.52233163216806133, 112.82497356121893972, 47.432827425178402336, 115.22332009593810653, + 54.690482657344546169, 113.62823892005326343, 66.263899738172767684, 45.629282908088498516, + 4.2304446220041427296, 107.40236392521910602, 67.156219671323924558, 103.61845983019156847, + 69.353297779056447325, 106.72688758597359993, 20.872044868861848954, 81.692193571205280023, + 117.16016657605723594, 73.588350414847809589, 38.266043245057517197, 57.133127698602038436, + 67.621852472075261176, 21.320176041968807112, 10.091236054180626525, 126.37433425439303392, + 111.43489976701312116, 89.33029369575160672, 93.12701744883088395, 98.633181837296433514, + 77.777643754561722744, 80.245399137431377312, 126.31434466382415849, 69.17179231479531154, + 58.476450083260715473, 107.43010074587800773, 33.76021975669573294, 71.573371295122342417, + 118.59503485844470561, 4.6867811702250037342, 68.288631865321804071, 40.483824119488417637, + 88.614723492715711473, 31.871067536219925387, 81.698620415878394851, 55.796352690613275627, + 71.727779135762830265, 70.395120936074818019, 65.275196412439981941, 9.1274302477468154393, + 9.7985886345668404829, 113.9718458797360654, 122.82793683046838851, 15.070597282454400556, + 26.987772119064175058, 106.99385772456298582, 19.058299068754422478, 22.621990479907253757, + 80.428675550807383843, 52.900983931831433438, 25.209679820447490783, 83.250113490303192521, + 43.913949650246649981, 96.111209411144955084, 77.58080453548245714, 113.68224020138950436, + 54.894107897442154353, 120.30736755821999395, 55.438336887720652157, 73.883247498408309184, + 81.389341278878418962, 44.214424954559945036, 9.2159957944277266506, 23.457106160243711201, + 79.882304298473172821, 83.30660730702948058, 125.295636244401976, 76.888690330779354554, + 126.25478469352674438, 48.415637885118485428, 17.492904179875040427, 29.562443494778563036, + 96.349624571143067442, 35.088685324935795506, 91.303218113709590398, 88.303626668166543823, + 102.61865104303069529, 36.966201632454612991, 69.925599867445271229, 69.161277127914217999, + 53.980742981148068793, 16.671972307834948879, 30.855148089100111974, 97.018915277189080371, + 41.888937078158051008, 67.3791000360288308, 124.32229048064982635, 127.92285387068113778, + 115.06397064528937335, 20.903588459306774894, 30.938035656217834912, 32.805103208611399168, + 104.03580494824927882, 14.818157409514242318, 118.73857530122404569, 2.6223602005047723651, + 83.96831122114599566, 5.7368040319925057702, 110.94066296421078732, 88.949093161572818644, + 31.21012797930961824, 48.992739800258277683, 112.56902943442764808, 59.588258839568879921, + 92.380056012796558207, 7.5216270989258191548, 75.090820495413936442, 108.19304747060596128, + 70.605474603242328158, 26.338179884151031729, 85.331540643088374054, 12.032501115263585234, + 82.663426085713581415, 97.941296022239839658, 30.725666393889696337, 78.026591411271510879, + 4.6554433788296591956, 113.35455957318845321, 100.48438144749161438, 111.90254209022896248, + 118.63242185615672497, 50.562368016919208458, 95.679096736588689964, 65.57431025580081041, + 68.933734323090902762, 7.9208218908970593475, 120.92728104802517919, 20.068015352608199464, + 4.8342000946104235481, 12.178803538663487416, 120.07885777432602481, 111.60496525504277088, + 19.181183964712545276, 41.064139477599383099, 126.76061699643469183, 33.645086866694327909, + 13.554117450017656665, 93.612347917704028077, 2.676368056949286256, 48.203059845629468327, + 66.638797544284898322, 14.442555522069596918, 119.36617366054633749, 101.87491558510009781, + 86.484655640237178886, 42.428521492824074812, 10.138068235930404626, 72.564959534640365746, + 70.073308573166286806, 24.722934144021564862, 76.359416309584048577, 114.64289143192218035, + 95.79638748086290434, 61.865675086733972421, 4.8759228701164829545, 61.598751439858460799, + 5.5751715753431199118, 97.147924937642528675, 112.28958013715964626, 79.85387237582472153, + 114.9498247404844733, 25.130110040259751258, 90.89725949301282526, 51.80889570999352145, + 95.955437952772626886, 28.860639941685803933, 47.71143874467452406, 7.4955727041560749058, + 6.7901375384863058571, 98.393480028993508313, 103.75966543175672996, 12.413263781199930236, + 5.1875159771661856212, 1.0367907149629900232, 66.660584188488428481, 18.4194156674129772, + 119.14268391984660411, 63.301408644096227363, 109.07942131080199033, 86.47504812570696231, + 75.958624106449860847, 103.85791657307345304, 126.14875252762067248, 96.195732618729380192, + 83.142626245684368769, 55.659707836028246675, 17.438511064854537835, 41.338549652347865049, + 7.153564713393279817, 103.46326725865947083, 95.898894648333225632, 93.076394361625716556, + 106.79999382823734777, 90.835039202982443385, 98.078560542235209141, 32.143069966579787433, + 48.949828863296716008, 14.239398497335059801, 119.50613495483048609, 75.624298023554729298, + 56.78272806947643403, 99.22831947190570645, 55.476284373307862552, 120.2552752897645405, + 0.3616256924724439159, 66.133226216294133337, 62.006609916552406503, 7.7816807656017772388, + 17.352877362794970395, 67.449517218978144228, 4.0048325382776965853, 42.311366520320007112, + 34.858063938601844711, 100.8171205773287511, 76.922430653175979387, 85.113905031594185857, + 90.933028288742207224, 56.607495976833888562, 11.397791870123910485, 120.12389375557540916, + 64.170306290736334631, 118.52787232434639009, 111.06010546065590461, 37.839406186049018288, + 108.82608720162170357, 77.160725999743590364, 55.46717491649906151, 99.697576240108901402, + 91.986993889833684079, 34.73419509830273455, 107.92263181264570449, 91.511575233791518258, + 27.958579283196741017, 15.452924126639118185, 29.468334796867566183, 5.3738462442233867478, + 75.015718637525424128, 60.606271171869593672, 60.427187395478540566, 116.62950625248049619, + 59.321093658607424004, 97.315591770107857883, 116.51488893929854385, 66.85827309455271461, + 11.482209654830512591, 116.84711157108540647, 3.6864834526604681741, 91.927282166510849493, + 44.98814975101777236, 34.358938426521490328, 99.11687379855720792, 68.207076057708036387, + 0.77416900838579749689, 93.608269425090838922, 55.481452889333013445, 91.42805654248513747, + 57.667725158207758795, 90.033926809286640491, 74.373536283557768911, 62.814290267655451316, + 89.481110697186522884, 54.982906147688481724, 123.43029731375645497, 54.232215781812556088, + 103.03130920764670009, 11.996337536369537702, 10.050199054534459719, 65.341154720048507443, + 103.70090374704886926, 44.9479288994698436, 35.367437093693297356, 33.58941046534164343, + 92.902536126945051365, 97.979881242848932743, 41.22306832117101294, 106.82121998410730157, + 18.38483218692272203, 44.180115389957791194, 5.2906015713815577328, 91.916250376169045921, + 53.964374438630329678, 59.321732254556991393, 7.3029275185363076162, 56.275963742529711453, + 119.08942279579423484, 127.89428713207962574, 53.008644295212434372, 76.822516072854341473, + 48.647750150317733642, 105.59259245579232811, 31.439314301886042813, 61.359574694855837151, + 106.03160602932985057, 32.019500885144225322, 24.123131762331468053, 70.628104172472376376, + 114.68697615767086972, 86.410445689663902158, 65.405028243512788322, 83.270527978154859738, + 68.311477194911276456, 11.355266153477714397, 53.203958088648505509, 47.671178378055628855, + 73.326293949514365522, 25.053632940569514176, 50.489626870570646133, 42.41931486441535526, + 48.550060313726135064, 10.664579355121531989, 13.790358311158342985, 26.626468535047024488, + 108.76706025809471612, 29.568690092277392978, 122.21718020506523317, 36.84982244998900569, + 23.643865136375097791, 60.426307402089150855, 112.91761925096943742, 47.72917144720122451, + 44.410749782553466503, 89.853639395088976016, 7.1325850771936529782, 105.31101556083012838, + 124.13362988451626734, 60.004176795478997519, 9.6630113103310577571, 96.516749988946685335, + 75.167338957759056939, 26.964423944271402434, 113.66583239842657349, 25.304051260121923406, + 0.71505277653704979457, 23.306824668470653705, 43.38209058814754826, 6.0478636145671771374, + 97.38501116066618124, 63.492126218632620294, 85.553218261560687097, 79.397671960268780822, + 23.766230117937084287, 109.86778025015519233, 90.638226904629846103, 7.4000181417286512442, + 35.271346603840356693, 89.779742446320597082, 53.666375810054887552, 81.962447675483417697, + 11.992125802073132945, 39.444420865809661336, 19.326761652700952254, 104.96667317174797063, + 102.07646109211782459, 113.56912553821894107, 32.353801665365608642, 97.484949267560295993, + 25.307802339284535265, 10.645917465924867429, 88.391340360140020493, 50.291819582940661348, + 110.89507966886230861, 126.13836538316172664, 127.04466326433976064, 97.649947122437879443, + 94.865654850360442651, 102.44664019187621307, 109.38096531469273032, 99.256477840110164834, + 4.5277994763455353677, 91.258565816176997032, 8.4608892440119234379, 86.804727850441850023, + 6.3124393426514870953, 79.236919660386774922, 10.706595558116532629, 85.453775171947199851, + 41.744089737727335887, 35.384387142414198024, 106.32033315211810987, 19.176700829695619177, + 76.532086490115034394, 114.26625539720771485, 7.2437049441505223513, 42.640352083937614225, + 20.182472108364891028, 124.74866850878970581, 94.869799534029880306, 50.660587391506851418, + 58.254034897665405879, 69.266363674596505007, 27.555287509127083467, 32.490798274866392603, + 124.62868932765195495, 10.343584629590623081, 116.95290016652506893, 86.860201491756015457, + 67.520439513395103859, 15.146742590248322813, 109.19006971688941121, 9.3735623404536454473, + 8.5772637306436081417, 80.967648238980473252, 49.229446985431422945, 63.742135072443488752, + 35.397240831756789703, 111.59270538123018923, 15.455558271529298509, 12.790241872153274016, + 2.5503928248799638823, 18.254860495493630879, 19.597177269137318945, 99.943691759475768777, + 117.65587366093677701, 30.141194564908801112, 53.975544238131988095, 85.987715449125971645, + 38.116598137508844957, 45.243980959818145493, 32.857351101614767686, 105.80196786366286688, + 50.419359640898619546, 38.500226980606385041, 87.82789930049693794, 64.222418822293548146, + 27.16160907096855226, 99.364480402779008728, 109.78821579488794669, 112.61473511643998791, + 110.87667377544494229, 19.766494996820256347, 34.778682557756837923, 88.428849909119890071, + 18.431991588855453301, 46.914212320491060382, 31.764608596949983621, 38.613214614062599139, + 122.59127248880758998, 25.777380661562347086, 124.50956938705348875, 96.831275770236970857, + 34.985808359750080854, 59.12488698956076405, 64.699249142286134884, 70.177370649875228992, + 54.606436227422818774, 48.607253336336725624, 77.237302086061390582, 73.93240326491286396, + 11.851199734894180438, 10.322554255828435998, 107.96148596229613759, 33.343944615669897757, + 61.710296178203861928, 66.037830554378160741, 83.777874156319739996, 6.7582000720612995792, + 120.64458096130329068, 127.84570774136591353, 102.1279412905787467, 41.807176918613549788, + 61.876071312435669824, 65.610206417226436315, 80.071609896498557646, 29.636314819032122614, + 109.47715060244809138, 5.244720401013182709, 39.93662244229199132, 11.473608063988649519, + 93.881325928425212624, 49.898186323145637289, 62.42025595861923648, 97.985479600520193344, + 97.138058868855296168, 119.17651767914139782, 56.760112025593116414, 15.043254197855276288, + 22.181640990831510862, 88.386094941215560539, 13.210949206484656315, 52.676359768305701436, + 42.663081286176748108, 24.065002230530808447, 37.326852171430800809, 67.882592044479679316, + 61.451332787783030653, 28.053182822543021757, 9.31088675766295637, 98.709119146380544407, + 72.968762894986866741, 95.805084180461562937, 109.26484371231344994, 101.12473603384205489, + 63.358193473181017907, 3.1486205116052587982, 9.867468646181805525, 15.841643781797756674, + 113.85456209605035838, 40.136030705216398928, 9.6684001892208470963, 24.35760707733061281, + 112.1577155486556876, 95.209930510085541755, 38.362367929425090551, 82.128278955202404177, + 125.52123399286938366, 67.290173733388655819, 27.108234900038951309, 59.224695835408056155, + 5.352736113898572512, 96.406119691262574634, 5.2775950885697966442, 28.885111044142831815, + 110.73234732109631295, 75.749831170203833608, 44.969311280474357773, 84.857042985648149624, + 20.27613647186444723, 17.129919069284369471, 12.146617146332573611, 49.445868288046767702, + 24.718832619171735132, 101.28578286384799867, 63.59277496172580868, 123.73135017346794484, + 9.7518457402329659089, 123.1975028797169216, 11.150343150689877803, 66.29584987528869533, + 96.579160274322930491, 31.707744751653081039, 101.89964948096894659, 50.260220080523140496, + 53.79451898602565052, 103.61779141999068088, 63.910875905545253772, 57.721279883371607866, + 95.422877489349048119, 14.991145408312149812, 13.580275076976249693, 68.786960057990654605, + 79.519330863513459917, 24.826527562399860471, 10.375031954332371242, 2.0735814299296180252, + 5.3211683769768569618, 36.838831334829592379, 110.28536783969320823, 126.6028172881960927, + 90.158842621607618639, 44.950096251417562598, 23.917248212903359672, 79.715833146150544053, + 124.29750505524498294, 64.391465237462398363, 38.285252491368737537, 111.31941567205649335, + 34.877022129709075671, 82.677099304695730098, 14.307129426790197613, 78.926534517322579632, + 63.797789296670089243, 58.152788723255071091, 85.59998765647833352, 53.670078405968524748, + 68.157121084470418282, 64.286139933159574866, 97.899657726593432017, 28.478796994673757581, + 111.01226990966461017, 23.248596047109458596, 113.56545613895650604, 70.456638943811412901, + 110.95256874661936308, 112.51055057952908101, 0.72325138494852581061, 4.2664524325882666744, + 124.01321983310481301, 15.563361531203554478, 34.705754725593578769, 6.8990344379562884569, + 8.0096650765553931706, 84.622733040640014224, 69.716127877207327401, 73.634241154661140172, + 25.844861306355596753, 42.227810063192009693, 53.866056577484414447, 113.21499195366777712, + 22.795583740251458948, 112.2477875111544563, 0.34061258147630724125, 109.05574464869641815, + 94.120210921311809216, 75.678812372101674555, 89.65217440324704512, 26.321451999487180728, + 110.934349833001761, 71.395152480221440783, 55.973987779667368159, 69.468390196609107079, + 87.84526362529504695, 55.023150467583036516, 55.917158566393482033, 30.905848253278236371, + 58.936669593735132366, 10.747692488450411474, 22.031437275050848257, 121.21254234373918734, + 120.85437479096071911, 105.25901250496099237, 118.64218731721848599, 66.631183540219353745, + 105.02977787860072567, 5.7165461891054292209, 22.96441930966466316, 105.69422314217081293, + 7.3729669053245743271, 55.854564333021698985, 89.97629950203554472, 68.717876853046618635, + 70.233747597118053818, 8.4141521154160727747, 1.5483380167752329726, 59.216538850181677844, + 110.96290577866966487, 54.85611308497027494, 115.33545031641915557, 52.067853618576918961, + 20.747072567115537822, 125.62858053531454061, 50.962221394373045769, 109.96581229538060143, + 118.86059462751290994, 108.46443156362875015, 78.062618415293400176, 23.992675072739075404, + 20.100398109072557418, 2.6823094401006528642, 79.401807494097738527, 89.8958577989396872, + 70.734874187386594713, 67.178820930686924839, 57.805072253893740708, 67.959762485697865486, + 82.446136642345663859, 85.642439968214603141, 36.769664373845444061, 88.360230779915582389, + 10.581203142766753444, 55.832500752338091843, 107.92874887726065936, 118.64346450911398279, + 14.605855037072615232, 112.55192748506306089, 110.17884559159210767, 127.78857426415925147, + 106.01728859042850672, 25.645032145708682947, 97.295500300639105262, 83.18518491158465622, + 62.878628603772085626, 122.71914938971531228, 84.063212058659701142, 64.039001770288450643, + 48.246263524666574085, 13.256208344948390732, 101.37395231534537743, 44.820891379331442295, + 2.8100564870292146225, 38.541055956313357456, 8.6229543898225529119, 22.710532306955428794, + 106.40791617729701102, 95.342356756114895688, 18.652587899028731044, 50.107265881139028352, + 100.97925374114129227, 84.838629728830710519, 97.100120627452270128, 21.329158710243063979, + 27.580716622316685971, 53.252937070097686956, 89.534120516189432237, 59.137380184558423935, + 116.43436041013046633, 73.699644899978011381, 47.287730272750195581, 120.85261480418193969, + 97.835238501938874833, 95.458342894402449019, 88.821499565110570984, 51.707278790177952033, + 14.265170154390943935, 82.622031121663894737, 120.26725976903253468, 120.00835359095799504, + 19.326022620665753493, 65.033499977897008648, 22.334677915518113878, 53.928847888546442846, + 99.331664796853146981, 50.608102520243846811, 1.4301055530740995891, 46.613649336941307411, + 86.76418117629509652, 12.095727229137992254, 66.77002232133236248, 126.98425243726887857, + 43.106436523125012172, 30.795343920537561644, 47.532460235877806554, 91.735560500314022647, + 53.276453809259692207, 14.800036283457302488, 70.542693207684351364, 51.559484892641194165, + 107.33275162011341308, 35.924895350966835395, 23.98425160414626589, 78.888841731619322672, + 38.653523305405542487, 81.933346343499579234, 76.152922184239287162, 99.138251076437882148, + 64.707603330734855263, 66.969898535120591987, 50.615604678569070529, 21.291834931853372836, + 48.782680720280040987, 100.58363916588496068, 93.790159337728255196, 124.27673076632709126, + 126.08932652868315927, 67.299894244879396865, 61.731309700724523282, 76.893280383756064111, + 90.761930629389098613, 70.512955680220329668, 9.0555989526947087143, 54.517131632353994064, + 16.921778488027484855, 45.609455700883700047, 12.624878685306612169, 30.473839320773549844, + 21.413191116236703238, 42.907550343894399703, 83.488179475454671774, 70.768774284832034027, + 84.64066630423621973, 38.353401659394876333, 25.064172980233706767, 100.5325107944154297, + 14.487409888301044703, 85.28070416787522845, 40.364944216733420035, 121.4973370175830496, + 61.739599068059760612, 101.32117478301370284, 116.50806979533444974, 10.532727349193010014, + 55.110575018254166935, 64.981596549736423185, 121.25737865530390991, 20.68716925918488414, + 105.90580033305377583, 45.720402983515668893, 7.0408790267902077176, 30.293485180500283604, + 90.380139433778822422, 18.747124680907290895, 17.154527461290854262, 33.935296477960946504, + 98.45889397086284589, 127.4842701448869775, 70.794481663517217385, 95.185410762460378464, + 30.911116543058597017, 25.580483744306548033, 5.1007856497599277645, 36.509720990987261757, + 39.194354538278275868, 71.887383518955175532, 107.31174732187355403, 60.282389129817602225, + 107.95108847626761417, 43.97543089825194329, 76.233196275017689914, 90.487961919636290986, + 65.71470220323317335, 83.603935727325733751, 100.83871928179723909, 77.000453961216408061, + 47.655798600997513859, 0.44483764458709629253, 54.323218141940742498, 70.728960805558017455, + 91.57643158977953135, 97.229470232883613789, 93.753347550889884587, 39.532989993640512694, + 69.557365115517313825, 48.857699818239780143, 36.863983177710906602, 93.828424640982120764, + 63.529217193899967242, 77.226429228128836257, 117.18254497761517996, 51.554761323128332151, + 121.01913877411061549, 65.662551540473941714, 69.971616719500161707, 118.24977397912516608, + 1.3984982845759077463, 12.354741299750457983, 109.21287245484563755, 97.214506672677089227, + 26.474604172126419144, 19.864806529825727921, 23.702399469788360875, 20.645108511660509976, + 87.922971924592275172, 66.687889231339795515, 123.42059235641136183, 4.0756611087599594612, + 39.555748312639479991, 13.516400144126237137, 113.28916192261021934, 127.69141548273546505, + 76.255882581157493405, 83.614353837227099575, 123.75214262487497763, 3.220412834456510609, + 32.143219792997115292, 59.272629638067883207, 90.954301204896182753, 10.489440802026365418, + 79.873244884583982639, 22.947216127980937017, 59.762651856850425247, 99.796372646291274577, + 124.84051191724211094, 67.970959201044024667, 66.276117737714230316, 110.35303535828279564, + 113.52022405118623283, 30.086508395710552577, 44.363281981666659703, 48.772189882431121077, + 26.421898412969312631, 105.35271953661140287, 85.326162572353496216, 48.130004461061616894, + 74.653704342865239596, 7.7651840889593586326, 122.90266557556606131, 56.106365645086043514, + 18.621773515329550719, 69.418238292764726793, 17.93752578997737146, 63.610168360926763853, + 90.529687424630537862, 74.249472067684109788, 126.71638694636203581, 6.2972410232105175965, + 19.73493729236361105, 31.683287563599151326, 99.709124192100716755, 80.272061410432797857, + 19.336800378441694193, 48.715214154664863599, 96.315431097315013176, 62.41986102017108351, + 76.724735858853819082, 36.256557910408446332, 123.04246798574240529, 6.580347466777311638, + 54.216469800077902619, 118.44939167081611231, 10.705472227800783003, 64.812239382525149267, + 10.555190177139593288, 57.77022208828930161, 93.464694642196263885, 23.499662340407667216, + 89.938622560952353524, 41.714085971296299249, 40.552272943728894461, 34.259838138568738941, + 24.293234292665147223, 98.891736576093535405, 49.437665238347108243, 74.571565727695997339, + 127.18554992345525534, 119.46270034693588968, 19.503691480469569797, 118.3950057594338432, + 22.300686301383393584, 4.5916997505810286384, 65.158320548645860981, 63.415489503309800057, + 75.799298961937893182, 100.52044016104628099, 107.58903797205493902, 79.235582839981361758, + 127.82175181109050754, 115.44255976674685371, 62.845754978698096238, 29.982290816624299623, + 27.160550153956137365, 9.5739201159849471878, 31.038661727026919834, 49.653055124799720943, + 20.750063908664742485, 4.1471628598592360504, 10.642336753953713924, 73.677662669662822736, + 92.570735679390054429, 125.20563457639582339, 52.317685243215237278, 89.900192502835125197, + 47.834496425810357323, 31.431666292304726085, 120.59501011049360386, 0.78293047492479672655, + 76.570504982741113054, 94.638831344112986699, 69.75404425942178932, 37.354198609391460195, + 28.614258853584033204, 29.853069034645159263, 127.59557859334017849, 116.30557744651378016, + 43.19997531295666704, 107.34015681194068748, 8.3142421689444745425, 0.5722798663227877114, + 67.799315453186864033, 56.957593989351153141, 94.024539819329220336, 46.49719209422255517, + 99.130912277916650055, 12.91327788762646378, 93.905137493242364144, 97.021101159058162011, + 1.4465027698970516212, 8.5329048651801713277, 120.02643966620962601, 31.126723062407108955, + 69.411509451187157538, 13.798068875912576914, 16.01933015311442432, 41.245466081283666426, + 11.432255754418292781, 19.268482309322280344, 51.689722612711193506, 84.455620126384019386, + 107.73211315497246687, 98.42998390733555425, 45.591167480506555876, 96.495575022308912594, + 0.6812251629562524613, 90.111489297396474285, 60.24042184262725641, 23.357624744206987089, + 51.30434880649409024, 52.642903998977999436, 93.868699666007159976, 14.790304960442881566, + 111.9479755593383743, 10.936780393221852137, 47.6905272505900939, 110.04630093516607303, + 111.83431713278696407, 61.811696506556472741, 117.87333918747026473, 21.495384976900822949, + 44.062874550105334492, 114.42508468748201267, 113.7087495819250762, 82.518025009925622726, + 109.28437463444060995, 5.2623670804423454683, 82.059555757201451343, 11.433092378210858442, + 45.928838619332964299, 83.388446284341625869, 14.745933810649148654, 111.70912866604703595, + 51.952599004074727418, 9.4357537060968752485, 12.467495194236107636, 16.828304230832145549, + 3.0966760335504659452, 118.43307770036699367, 93.925811557339329738, 109.71222616994418786, + 102.67090063283831114, 104.13570723715383792, 41.494145134234713623, 123.25716107062908122, + 101.92444278874972952, 91.931624590764840832, 109.72118925502945785, 88.928863127261138288, + 28.125236830586800352, 47.985350145478150807, 40.200796218145114835, 5.3646188802049437072, + 30.803614988199115032, 51.791715597883012379, 13.469748374776827404, 6.3576418613738496788, + 115.61014450779111939, 7.9195249713993689511, 36.892273284694965696, 43.284879936429206282, + 73.539328747694526101, 48.720461559831164777, 21.162406285533506889, 111.66500150467982166, + 87.85749775452495669, 109.28692901822796557, 29.211710074148868443, 97.103854970129759749, + 92.357691183187853312, 127.57714852832214092, 84.034577180857013445, 51.290064291421003873, + 66.591000601281848503, 38.37036982316931244, 125.75725720754780923, 117.43829877943426254, + 40.126424117323040264, 0.07800354057690128684, 96.49252704933314817, 26.512416689900419442, + 74.747904630690754857, 89.641782758662884589, 5.6201129740584292449, 77.082111912626714911, + 17.245908779645105824, 45.421064613914495567, 84.815832354597660014, 62.684713512229791377, + 37.305175798057462089, 100.21453176228169468, 73.958507482286222512, 41.677259457665059017, + 66.200241254904540256, 42.658317420486127958, 55.161433244633371942, 106.50587414019901189, + 51.068241032378864475, 118.27476036912048585, 104.86872082026457065, 19.399289799956022762, + 94.575460545504029142, 113.70522960836751736, 67.670477003881387645, 62.916685788808536017, + 49.642999130221141968, 103.41455758035590407, 28.530340308785525849, 37.244062243331427453, + 112.53451953806870733, 112.01670718191599008, 38.652045241335144965, 2.0669999557940172963, + 44.669355831036227755, 107.85769577709652367, 70.663329593706293963, 101.21620504048769362, + 2.8602111061481991783, 93.2272986738862528, 45.528362352590193041, 24.191454458279622486, + 5.5400446426683629397, 125.96850487453775713, 86.212873046250024345, 61.590687841075123288, + 95.064920471759251086, 55.471121000628045294, 106.55290761851938441, 29.600072566918242956, + 13.085386415368702728, 103.11896978528602631, 86.665503240226826165, 71.849790701933670789, + 47.96850320829616976, 29.777683463238645345, 77.307046610814722953, 35.866692687002796447, + 24.305844368482212303, 70.276502152879402274, 1.4152066614733485039, 5.9397970702411839738, + 101.23120935713814106, 42.583669863706745673, 97.565361440563719952, 73.16727833177355933, + 59.58031867546014837, 120.5534615326578205, 124.17865305736995651, 6.5997884897587937303, + 123.46261940145268454, 25.786560767515766202, 53.523861258781835204, 13.025911360440659337, + 18.111197905389417429, 109.03426326470798813, 33.843556976054969709, 91.218911401767400093, + 25.249757370613224339, 60.947678641547099687, 42.826382232473406475, 85.815100687792437384, + 38.976358950912981527, 13.537548569667706033, 41.28133260847243946, 76.706803318789752666, + 50.128345960471051512, 73.0650215888308594, 28.974819776605727384, 42.561408335750456899, + 80.729888433470478049, 114.9946740351660992, 123.4791981361231592, 74.642349566031043651, + 105.01613959066889947, 21.065454698386020027, 110.22115003651197185, 1.963193099476484349, + 114.51475731060781982, 41.374338518373406259, 83.81160066610755166, 91.440805967031337786, + 14.081758053580415435, 60.586970361004205188, 52.760278867557644844, 37.494249361814581789, + 34.309054922581708524, 67.870592955925530987, 68.917787941729329759, 126.96854028977759299, + 13.588963327038072748, 62.370821524920756929, 61.822233086117194034, 51.160967488613096066, + 10.201571299519855529, 73.019441981974523515, 78.388709076560189715, 15.774767037913989043, + 86.623494643747108057, 120.56477825963884243, 87.902176952535228338, 87.950861796507524559, + 24.466392550039017806, 52.975923839276219951, 3.4294044064699846786, 39.207871454655105481, + 73.677438563598116161, 26.000907922432816122, 95.311597201995027717, 0.88967528917419258505, + 108.64643628388512298, 13.45792161111603491, 55.15286317956270068, 66.458940465770865558, + 59.506695101779769175, 79.065979987284663366, 11.11473023103462765, 97.715399636479560286, + 73.727966355425451184, 59.656849281964241527, 127.05843438780357246, 26.452858456261310494, + 106.36508995523035992, 103.10952264626030228, 114.03827754822486895, 3.325103080951521406, + 11.943233439003961394, 108.49954795825033216, 2.7969965691518154927, 24.709482599504553946, + 90.425744909694913076, 66.429013345354178455, 52.949208344252838288, 39.729613059651455842, + 47.40479893957672175, 41.29021702332465793, 47.845943849188188324, 5.3757784626832290087, + 118.84118471282272367, 8.1513222175199189223, 79.111496625278959982, 27.032800288256112253, + 98.578323845224076649, 127.38283096547456807, 24.511765162318624789, 39.228707674457837129, + 119.50428524974995526, 6.440825668913021218, 64.286439585994230583, 118.54525927613940439, + 53.908602409792365506, 20.978881604056368815, 31.746489769167965278, 45.894432255961874034, + 119.52530371370448847, 71.592745292586187134, 121.68102383448785986, 7.9419184020916873123, + 4.5522354754320986103, 92.706070716569229262, 99.040448102372465655, 60.173016791421105154, + 88.726563963333319407, 97.544379764862242155, 52.84379682594226324, 82.705439073226443725, + 42.652325144706992432, 96.260008922126871767, 21.307408685730479192, 15.530368177922355244, + 117.80533115113212261, 112.21273129017208703, 37.243547030662739417, 10.836476585529453587, + 35.87505157995474292, 127.22033672185716568, 53.059374849264713703, 20.498944135371857556, + 125.43277389272407163, 12.594482046421035193, 39.4698745847272221, 63.366575127201940631, + 71.418248384205071488, 32.544122820865595713, 38.673600756883388385, 97.430428309333365178, + 64.630862194630026352, 124.839722040345805, 25.449471717707638163, 72.513115820820530644, + 118.08493597148481058, 13.160694933554623276, 108.43293960015944322, 108.89878334163222462, + 21.410944455605203984, 1.6244787650502985343, 21.110380354279186577, 115.5404441765822412, + 58.92938928439252777, 46.999324680818972411, 51.877245121904707048, 83.428171942592598498, + 81.104545887457788922, 68.519676277137477882, 48.586468585333932424, 69.783473152187070809, + 98.875330476697854465, 21.143131455395632656, 126.37109984691414866, 110.92540069387177937, + 39.007382960942777572, 108.79001151886768639, 44.601372602766787168, 9.1833995011656952556, + 2.3166410972917219624, 126.83097900662323809, 23.598597923879424343, 73.040880322096199961, + 87.178075944113516016, 30.471165679966361495, 127.64350362218465307, 102.88511953349370742, + 125.69150995739619248, 59.964581633248599246, 54.321100307912274729, 19.147840231969894376, + 62.077323454053839669, 99.306110249599441886, 41.500127817329484969, 8.2943257197184721008, + 21.284673507911065826, 19.355325339329283452, 57.141471358783746837, 122.41126915279164677, + 104.63537048643411254, 51.800385005670250393, 95.668992851620714646, 62.863332584613090148, + 113.19002022098720772, 1.5658609498532314319, 25.141009965485864086, 61.277662688229611376, + 11.50808851884357864, 74.70839721878292039, 57.228517707168066408, 59.706138069293956505, + 127.19115718668399495, 104.61115489302756032, 86.399950625916972058, 86.680313623881374951, + 16.628484337888949085, 1.1445597326492134016, 7.5986309063737280667, 113.91518797870594426, + 60.049079638658440672, 92.994384188448748318, 70.26182455583330011, 25.826555775256565539, + 59.810274986488366267, 66.042202318116324022, 2.8930055397941032425, 17.065809730363980634, + 112.05287933241925202, 62.253446124817855889, 10.823018902374315076, 27.596137751825153828, + 32.03866030622884864, 82.490932162567332853, 22.864511508836585563, 38.536964618644560687, + 103.37944522542602499, 40.911240252771676751, 87.464226309948571725, 68.859967814671108499, + 91.18233496101674973, 64.991150044617825188, 1.3624503259161429014, 52.22297859479294857, + 120.48084368525451282, 46.715249488413974177, 102.60869761298818048, 105.28580799795963685, + 59.737399332014319953, 29.58060992088940111, 95.895951118676748592, 21.873560786443704274, + 95.381054501183825778, 92.092601870335784042, 95.668634265573928133, 123.62339301311658346, + 107.74667837494052947, 42.990769953801645897, 88.125749100214306964, 100.85016937496766332, + 99.417499163853790378, 37.036050019854883431, 90.568749268881219905, 10.524734160888328915, + 36.119111514402902685, 22.866184756421716884, 91.857677238669566577, 38.776892568683251739, + 29.491867621301935287, 95.418257332094071899, 103.90519800814945484, 18.871507412193750497, + 24.934990388472215272, 33.656608461664291099, 6.1933520671045698691, 108.86615540073762531, + 59.851623114682297455, 91.424452339892013697, 77.341801265680260258, 80.271414474307675846, + 82.988290268473065225, 118.51432214126180043, 75.848885577503097011, 55.863249181533319643, + 91.442378510062553687, 49.857726254522276577, 56.250473661173600703, 95.970700290956301615, + 80.401592436290229671, 10.729237760409887414, 61.607229976398230065, 103.58343119576602476, + 26.939496749553654809, 12.715283722751337336, 103.22028901558223879, 15.839049942798737902, + 73.784546569389931392, 86.569759872862050543, 19.078657495389052201, 97.440923119662329555, + 42.324812571070651757, 95.330003009363281308, 47.714995509053551359, 90.573858036455931142, + 58.423420148301374866, 66.207709940263157478, 56.715382366379344603, 127.15429705664791982, + 40.069154361714026891, 102.58012858284564572, 5.1820012025636970066, 76.740739646342262859, + 123.51451441509925644, 106.87659755886852508, 80.252848234646080527, 0.15600708115744055249, + 64.985054098666296341, 53.024833379804476863, 21.495809261385147693, 51.283565517325769179, + 11.240225948120496469, 26.164223825253429823, 34.491817559290211648, 90.842129227832629113, + 41.631664709195320029, 125.36942702445958275, 74.610351596118562156, 72.429063524567027343, + 19.917014964572445024, 83.354518915333756013, 4.4004825098090805113, 85.316634840972255915, + 110.32286648927038186, 85.01174828039802378, 102.13648206476136693, 108.54952073824460967, + 81.737441640529141296, 38.798579599915683502, 61.150921091011696262, 99.410459216738672694, + 7.3409540077627752908, 125.83337157761707203, 99.285998260445921915, 78.82911516071180813, + 57.060680617571051698, 74.488124486666492885, 97.069039076141052647, 96.033414363831980154, + 77.30409048267028993, 4.1339999115880345926, 89.338711662076093489, 87.71539155419668532, + 13.326659187416225905, 74.432410080975387245, 5.7204222123000363354, 58.4545973477725056, + 91.056724705180386081, 48.382908916559244972, 11.080089285340363858, 123.93700974907915224, + 44.42574609250004869, 123.18137568215388455, 62.129840943518502172, 110.94224200125972857, + 85.105815237038768828, 59.200145133836485911, 26.170772830741043435, 78.237939570575690595, + 45.331006480457290309, 15.699581403867341578, 95.937006416592339519, 59.555366926480928669, + 26.614093221629445907, 71.733385374005592894, 48.611688736968062585, 12.553004305758804549, + 2.8304133229466970079, 11.879594140486005927, 74.462418714276282117, 85.167339727417129325, + 67.130722881131077884, 18.33455666354711866, 119.16063735092393472, 113.10692306531927898, + 120.35730611473991303, 13.199576979521225439, 118.92523880290536908, 51.573121535031532403, + 107.04772251756367041, 26.051822720881318673, 36.222395810782472836, 90.068526529415976256, + 67.687113952113577398, 54.437822803534800187, 50.499514741226448677, 121.89535728309419937, + 85.652764464950450929, 43.630201375584874768, 77.952717901825963054, 27.075097139335412066, + 82.5626652169485169, 25.413606637579505332, 100.256691920945741, 18.130043177661718801, + 57.949639553211454768, 85.122816671504551778, 33.459776866944594076, 101.98934807033583638, + 118.95839627224995638, 21.28469913206572528, 82.032279181337798946, 42.130909396775678033, + 92.442300073023943696, 3.9263861989566066768, 101.02951462121563964, 82.748677036750450497, + 39.6232013322187413, 54.881611934062675573, 28.16351610716083087, 121.17394072200841038, + 105.52055773511528969, 74.988498723629163578, 68.618109845167055028, 7.7411859118546999525, + 9.8355758834622974973, 125.93708057955518598, 27.177926654076145496, 124.74164304984151386, + 123.64446617223438807, 102.32193497722619213, 20.403142599043349037, 18.038883963952685008, + 28.777418153120379429, 31.549534075831616065, 45.246989287497854093, 113.12955651928132284, + 47.804353905074094655, 47.901723593015049119, 48.932785100078035612, 105.9518476785524399, + 6.8588088129399693571, 78.415742909313848941, 19.354877127196232323, 52.001815844869270222, + 62.623194403990055434, 1.7793505783520231489, 89.292872567770245951, 26.915843222235707799, + 110.30572635912903934, 4.9178809315417311154, 119.01339020356317633, 30.131959974569326732, + 22.229460462072893279, 67.43079927296275855, 19.455932710850902367, 119.31369856393212103, + 126.11686877560714493, 52.905716912526258966, 84.730179910464357818, 78.219045292524242541, + 100.0765550964497379, 6.6502061619030428119, 23.886466878011560766, 88.999095916500664316, + 5.5939931383036309853, 49.41896519901274587, 52.851489819393464131, 4.8580266907083569095, + 105.89841668850567658, 79.459226119302911684, 94.8095978791534435, 82.58043404664931586, + 95.691887698376376648, 10.751556925370095996, 109.68236942564544734, 16.302644435043475823, + 30.222993250557919964, 54.065600576515862485, 69.156647690451791277, 126.76566193094913615, + 49.023530324637249578, 78.457415348919312237, 111.00857049949991051, 12.881651337829680415, + 0.57287917199209914543, 109.09051855227880878, 107.81720481958473101, 41.95776320811273763, + 63.492979538335930556, 91.788864511927386047, 111.05060742741261492, 15.185490585176012246, + 115.36204766897571972, 15.883836804183374625, 9.1044709508678351995, 57.412141433142096503, + 70.08089620474493131, 120.34603358284584829, 49.453127926670276793, 67.08875952972448431, + 105.68759365188816446, 37.410878146452887449, 85.304650289417622844, 64.520017844253743533, + 42.614817371460958384, 31.060736355848348467, 107.61066230226788321, 96.425462580344174057, + 74.487094061325478833, 21.672953171058907174, 71.750103159913123818, 126.44067344371433137, + 106.11874969852942741, 40.99788827074735309, 122.86554778544814326, 25.188964092842070386, + 78.9397491694544442, 126.73315025440751924, 14.836496768410142977, 65.088245641731191427, + 77.347201513770414749, 66.860856618670368334, 1.2617243892636906821, 121.67944408069161, + 50.898943435418914305, 17.026231641644699266, 108.16987194296962116, 26.321389867112884531, + 88.865879200322524412, 89.797566683264449239, 42.821888911210407969, 3.2489575301005970687, + 42.220760708562011132, 103.0808883531644824, 117.85877856878505554, 93.998649361637944821, + 103.75449024381305207, 38.856343885188834975, 34.209091774919215823, 9.0393525542749557644, + 97.172937170671502827, 11.566946304377779597, 69.75066095339570893, 42.286262910794903291, + 124.74219969383193529, 93.850801387743558735, 78.014765921889193123, 89.580023037735372782, + 89.202745205533574335, 18.366799002331390511, 4.6332821945870819036, 125.66195801324647618, + 47.197195847762486665, 18.081760644196037902, 46.356151888227032032, 60.942331359936360968, + 127.28700724437294411, 77.770239066991052823, 123.38301991479238495, 119.92916326649719849, + 108.64220061582454946, 38.295680463939788751, 124.15464690811131732, 70.612220499198883772, + 83.000255634658969939, 16.588651439436944202, 42.569347015822131652, 38.710650678658566903, + 114.28294271757113165, 116.82253830558693153, 81.270740972868225072, 103.60077001134413877, + 63.337985703241429292, 125.72666516922981828, 98.380040441974415444, 3.1317218997064628638, + 50.282019930971728172, 122.55532537645922275, 23.01617703769079526, 21.416794437565840781, + 114.45703541433613282, 119.41227613859155099, 126.38231437337162788, 81.222309786058758618, + 44.799901251837582095, 45.360627247762749903, 33.25696867577789817, 2.2891194652984268032, + 15.197261812751094112, 99.830375957411888521, 120.09815927732051932, 57.988768376901134616, + 12.52364911166660022, 51.653111550513131078, 119.62054997298037051, 4.0844046362326480448, + 5.7860110795882064849, 34.131619460731599247, 96.105758664838504046, 124.50689224963571178, + 21.646037804748630151, 55.192275503650307655, 64.077320612461335259, 36.981864325134665705, + 45.729023017673171125, 77.073929237292759353, 78.75889045085204998, 81.822480505546991481, + 46.928452619900781428, 9.7199356293458549771, 54.364669922037137439, 1.9823000892356503755, + 2.7249006518322858028, 104.44595718958953512, 112.96168737050902564, 93.430498976831586333, + 77.217395225979998941, 82.571615995919273701, 119.47479866402863991, 59.161219841782440199, + 63.791902237353497185, 43.747121572891046526, 62.762109002371289534, 56.185203740675206063, + 63.337268531151494244, 119.2467860262368049, 87.493356749881058931, 85.981539907606929773, + 48.251498200432251906, 73.700338749938964611, 70.834998327707580756, 74.07210003971340484, + 53.13749853776243981, 21.049468321776657831, 72.23822302880580537, 45.732369512847071746, + 55.715354477339133155, 77.553785137366503477, 58.983735242607508553, 62.836514664191781776, + 79.810396016298909672, 37.743014824387500994, 49.869980776944430545, 67.313216923328582197, + 12.386704134212777717, 89.732310801475250628, 119.70324622936823289, 54.848904679787665373, + 26.683602531364158494, 32.542828948618989671, 37.97658053694976843, 109.02864428252723883, + 23.697771155006194022, 111.72649836307027726, 54.884757020125107374, 99.715452509044553153, + 112.50094732235083939, 63.941400581916241208, 32.803184872580459341, 21.458475520819774829, + 123.21445995280009811, 79.166862391532049514, 53.878993499107309617, 25.430567445506312652, + 78.440578031164477579, 31.678099885601113783, 19.569093138783500763, 45.139519745724101085, + 38.157314990781742381, 66.881846239324659109, 84.649625142144941492, 62.660006018726562615, + 95.429991018110740697, 53.147716072911862284, 116.84684029660638771, 4.4154198805263149552, + 113.43076473276232718, 126.30859411329583963, 80.13830872343169176, 77.160257165691291448, + 10.364002405131031992, 25.481479292688163696, 119.02902883020215086, 85.753195117740688147, + 32.505696469292161055, 0.31201416231851908378, 1.9701081973325926811, 106.04966675960895373, + 42.991618522770295385, 102.56713103465153836, 22.480451896240992937, 52.328447650506859645, + 68.983635118584061274, 53.684258455665258225, 83.263329418394278036, 122.73885404892280349, + 21.220703192240762291, 16.858127049134054687, 39.834029929148528026, 38.709037830667512026, + 8.8009650196217990015, 42.63326968194814981, 92.645732978544401703, 42.02349656079968554, + 76.272964129526371835, 89.099041476492857328, 35.474883281058282591, 77.597159199831367005, + 122.3018421820270305, 70.820918433477345388, 14.68190801552918856, 123.66674315523778205, + 70.571996520895481808, 29.65823032142361626, 114.12136123514574138, 20.976248973336623749, + 66.138078152285743272, 64.066828727667598287, 26.60818096534057986, 8.2679998231797071639, + 50.677423324155824957, 47.43078310839337064, 26.653318374836089788, 20.864820161950774491, + 11.440844424600072671, 116.90919469554864918, 54.113449410360772163, 96.765817833118489943, + 22.160178570684365695, 119.87401949815830449, 88.851492185003735358, 118.36275136430776911, + 124.25968188704064232, 93.884484002523095114, 42.211630474077537656, 118.40029026767297182, + 52.34154566148572485, 28.475879141151381191, 90.662012960914580617, 31.399162807738321135, + 63.874012833184679039, 119.11073385296185734, 53.228186443262529792, 15.466770748011185788, + 97.22337747393612517, 25.106008611517609097, 5.6608266458933940157, 23.759188280975649832, + 20.924837428556202212, 42.334679454837896628, 6.2614457622621557675, 36.669113327097875299, + 110.32127470185150742, 98.213846130642195931, 112.71461222947982606, 26.399153959046088858, + 109.85047760581073817, 103.14624307006670278, 86.095445035127340816, 52.103645441762637347, + 72.444791621568583651, 52.137053058835590491, 7.3742279042271547951, 108.87564560706960037, + 100.99902948245653533, 115.79071456619203673, 43.305528929900901858, 87.260402751173387514, + 27.905435803651926108, 54.150194278674462112, 37.125330433897033799, 50.827213275162648642, + 72.513383841891482007, 36.260086355323437601, 115.89927910642654751, 42.245633343009103555, + 66.919553733892826131, 75.978696140675310744, 109.91679254449991276, 42.569398264135088539, + 36.064558362675597891, 84.261818793554994045, 56.884600146047887392, 7.8527723979168513324, + 74.059029242434917251, 37.497354073500900995, 79.246402664437482599, 109.76322386812535115, + 56.327032214325299719, 114.34788144402045873, 83.041115470234217355, 21.976997447261965135, + 9.2362196903341100551, 15.482371823709399905, 19.671151766928232973, 123.87416115911037195, + 54.355853308155928971, 121.48328609968666569, 119.28893234447241412, 76.643869954452384263, + 40.806285198086698074, 36.077767927905370016, 57.554836306240758859, 63.099068151663232129, + 90.493978574999346165, 98.25911303856264567, 95.60870781014818931, 95.803447186030098237, + 97.865570200159709202, 83.903695357104879804, 13.717617625883576693, 28.831485818627697881, + 38.709754254392464645, 104.00363168973854044, 125.24638880798011087, 3.5587011567076842766, + 50.585745135540491901, 0, 92.611452718258078676, 9.8357618630871002097, + 110.02678040712635266, 60.263919949138653465, 44.458920924149424536, 6.8615985459255171008, + 38.911865421705442714, 110.62739712786788004, 124.23373755121428985, 105.81143382505615591, + 41.460359820932353614, 28.43809058505212306, 72.153110192899475805, 13.300412323806085624, + 47.772933756026759511, 49.998191833001328632, 11.187986276607261971, 98.837930398025491741, + 105.70297963878692826, 9.7160533814203517977, 83.796833377014991129, 30.918452238609461347, + 61.61919575831052498, 37.160868093302269699, 63.383775396752753295, 21.503113850743829971, + 91.364738851290894672, 32.605288870086951647, 60.445986501115839928, 108.13120115303536295, + 10.313295380907220533, 125.5313238618982723, 98.047060649278137134, 28.914830697842262452, + 94.017140998999821022, 25.76330267565936083, 1.1457583439878362697, 90.181037104561255546, + 87.634409639169462025, 83.915526416225475259, 126.98595907667549909, 55.577729023858410073, + 94.10121485482522985, 30.370981170355662471, 102.72409533795143943, 31.767673608366749249, + 18.208941901735670399, 114.82428286628783098, 12.1617924094935006, 112.69206716569169657, + 98.906255853344191564, 6.1775190594526065979, 83.375187303776328918, 74.821756292909412878, + 42.609300578838883666, 1.0400356885074870661, 85.229634742921916768, 62.121472711700334912, + 87.22132460453940439, 64.850925160691986093, 20.974188122650957666, 43.345906342121452326, + 15.500206319829885615, 124.88134688743230072, 84.237499397058854811, 81.995776541498344159, + 117.73109557089628652, 50.37792818568777875, 29.879498338912526378, 125.46630050881503848, + 29.672993536823923932, 2.1764912834660208318, 26.694403027544467477, 5.7217132373407366686, + 2.5234487785310193431, 115.35888816138321999, 101.79788687083782861, 34.052463283293036511, + 88.339743885939242318, 52.64277973422940704, 49.731758400648686802, 51.595133366528898478, + 85.643777822420815937, 6.4979150602011941373, 84.441521417127660243, 78.161776706332602771, + 107.71755713757374906, 59.997298723279527621, 79.50898048762610415, 77.712687770377669949, + 68.418183549838431645, 18.078705108553549508, 66.345874341343005653, 23.133892608759197174, + 11.501321906791417859, 84.572525821593444562, 121.48439938766750856, 59.701602775490755448, + 28.029531843782024225, 51.160046075474383542, 50.405490411067148671, 36.733598004662781022, + 9.266564389177801786, 123.32391602649295237, 94.394391695524973329, 36.163521288392075803, + 92.712303776454064064, 121.88466271987635992, 126.57401448874952621, 27.540478133985743625, + 118.76603982958840788, 111.85832653299803496, 89.284401231649098918, 76.591360927883215481, + 120.30929381622627261, 13.224440998401405523, 38.000511269317939878, 33.177302878873888403, + 85.138694031644263305, 77.421301357320771785, 100.56588543514590128, 105.64507661117750104, + 34.541481945740088122, 79.201540022688277531, 126.67597140648649656, 123.45333033846327453, + 68.760080883948830888, 6.2634437994129257277, 100.56403986194709432, 117.11065075291844551, + 46.032354075381590519, 42.83358887513531954, 100.91407082867590361, 110.82455227718673996, + 124.76462874674689374, 34.444619572117517237, 89.599802503675164189, 90.721254495525499806, + 66.51393735155579634, 4.5782389305968536064, 30.394523625505826203, 71.660751914827415021, + 112.19631855464103865, 115.97753675380226923, 25.04729822333320044, 103.30622310102990014, + 111.24109994596074102, 8.1688092724652960896, 11.57202215917641297, 68.263238921466836473, + 64.211517329680646071, 121.01378449927142356, 43.292075609497260302, 110.38455100730425329, + 0.15464122492267051712, 73.963728650269331411, 91.45804603534998023, 26.147858474589156685, + 29.517780901707737939, 35.644961011093982961, 93.856905239801562857, 19.439871258691709954, + 108.72933984407427488, 3.964600178471300751, 5.4498013036682095844, 80.891914379182708217, + 97.92337474102168926, 58.860997953666810645, 26.43479045196363586, 37.14323199184218538, + 110.94959732805727981, 118.3224396835648804, 127.58380447470699437, 87.494243145782093052, + 125.52421800474257907, 112.37040748135041213, 126.67453706230662647, 110.49357205247724778, + 46.986713499765755842, 43.963079815213859547, 96.502996400868141791, 19.400677499881567201, + 13.669996655418799492, 20.14420007942680968, 106.27499707552487962, 42.098936643556953641, + 16.47644605761161074, 91.464739025694143493, 111.43070895468190429, 27.107570274733006954, + 117.96747048521501711, 125.67302932838720153, 31.620792032597819343, 75.486029648775001988, + 99.739961553892499069, 6.6264338466571643949, 24.773408268429193413, 51.464621602954139234, + 111.40649245873646578, 109.69780935957533075, 53.367205062728316989, 65.085657897237979341, + 75.953161073903174838, 90.057288565054477658, 47.395542310016026022, 95.452996726140554529, + 109.76951404025385273, 71.430905018092744285, 97.001894644701678772, 127.88280116383248242, + 65.606369745160918683, 42.916951041643187637, 118.4289199056038342, 30.333724783064099029, + 107.75798699821461923, 50.861134891016263282, 28.881156062328955159, 63.356199771202227566, + 39.138186277567001525, 90.27903949144820217, 76.314629981567122741, 5.763692478652956197, + 41.299250284289882984, 125.32001203745676321, 62.859982036221481394, 106.29543214582736255, + 105.69368059321277542, 8.8308397610562678892, 98.861529465528292349, 124.61718822659531725, + 32.276617446867021499, 26.320514331382582895, 20.728004810262063984, 50.962958585379965371, + 110.05805766040793969, 43.506390235481376294, 65.01139293858432211, 0.62402832463703816757, + 3.9402163946688233409, 84.099333519217907451, 85.983237045544228749, 77.134262069303076714, + 44.960903792481985874, 104.65689530101735727, 9.9672702371681225486, 107.36851691133415443, + 38.526658836792194052, 117.47770809784560697, 42.441406384481524583, 33.716254098268109374, + 79.668059858297056053, 77.418075661335024051, 17.601930039243598003, 85.266539363899937598, + 57.291465957088803407, 84.046993121603009058, 24.545928259056381648, 50.198082952985714655, + 70.949766562120203162, 27.194318399666371988, 116.60368436405769899, 13.641836866954690777, + 29.363816031062015099, 119.33348631047920207, 13.143993041790963616, 59.316460642850870499, + 100.24272247029148275, 41.952497946676885476, 4.2761563045751245227, 0.13365745533519657329, + 53.21636193068115972, 16.535999646359414328, 101.35484664831164991, 94.861566216786741279, + 53.306636749672179576, 41.729640323901548982, 22.88168884920378332, 105.81838939109729836, + 108.2268988207251823, 65.531635666236979887, 44.320357141372369369, 111.74803899632024695, + 49.702984370011108695, 108.7255027286191762, 120.51936377408492262, 59.768968005046190228, + 84.42326094815871329, 108.80058053534594364, 104.6830913229714497, 56.951758282306400361, + 53.324025921829161234, 62.79832561547664227, 127.74802566637299606, 110.22146770592371468, + 106.45637288652505958, 30.933541496026009554, 66.446754947872250341, 50.212017223035218194, + 11.321653291786788031, 47.518376561951299664, 41.849674857112404425, 84.669358909675793257, + 12.522891524524311535, 73.338226654199388577, 92.642549403706652811, 68.42769226128802984, + 97.429224458959652111, 52.798307918095815694, 91.700955211625114316, 78.292486140137043549, + 44.190890070254681632, 104.20729088352891267, 16.889583243137167301, 104.27410611767118098, + 14.748455808457947569, 89.751291214142838726, 73.998058964916708646, 103.58142913238407345, + 86.611057859805441694, 46.520805502346775029, 55.810871607303852215, 108.30038855734892422, + 74.250660867794067599, 101.65442655032893526, 17.026767683782964014, 72.520172710650513181, + 103.79855821285309503, 84.491266686021845089, 5.83910746778929024, 23.957392281354259467, + 91.83358508899982553, 85.138796528270177078, 72.129116725354833761, 40.52363758710998809, + 113.76920029209577478, 15.705544795837340644, 20.118058484869834501, 74.994708147005439969, + 30.492805328878603177, 91.526447736250702292, 112.65406442865423742, 100.69576288804455544, + 38.08223094046843471, 43.95399489452393027, 18.47243938066822011, 30.96474364741879981, + 39.342303533860103926, 119.74832231822074391, 108.71170661631549592, 114.96657219937696937, + 110.57786468894846621, 25.287739908904768527, 81.612570396173396148, 72.155535855810740031, + 115.10967261248151772, 126.19813630333010224, 52.987957150002330309, 68.518226077128929319, + 63.217415620300016599, 63.606894372063834453, 67.731140400323056383, 39.807390714209759608, + 27.435235251767153386, 57.662971637255395763, 77.419508508788567269, 80.007263379480718868, + 122.49277761596022174, 7.1174023134153685533, 101.1714902710809838, 0, + 57.222905436516157351, 19.671523726177838398, 92.053560814252705313, 120.52783989827730693, + 88.917841848298849072, 13.723197091851034202, 77.823730843414523406, 93.254794255739398068, + 120.46747510243221768, 83.622867650112311821, 82.920719641864707228, 56.8761811701078841, + 16.306220385798951611, 26.600824647612171248, 95.545867512053519022, 99.996383666002657264, + 22.37597255321816192, 69.67586079605462146, 83.405959277573856525, 19.432106762844341574, + 39.593666754029982258, 61.836904477218922693, 123.23839151662104996, 74.321736186604539398, + 126.76755079350550659, 43.006227701491297921, 54.729477702581789345, 65.210577740173903294, + 120.89197300223531784, 88.262402306070725899, 20.626590761818079045, 123.06264772380018258, + 68.094121298556274269, 57.829661395688162884, 60.034281997999642044, 51.526605351318721659, + 2.2915166879793105181, 52.362074209126149071, 47.268819278342562029, 39.831052832454588497, + 125.97191815335099818, 111.15545804772045813, 60.202429709650459699, 60.74196234071496292, + 77.448190675902878866, 63.535347216733498499, 36.417883803474978777, 101.64856573257566197, + 24.323584818990639178, 97.384134331387031125, 69.812511706688383128, 12.355038118908851175, + 38.750374607556295814, 21.643512585818825755, 85.218601157677767333, 2.080071377018612111, + 42.459269485843833536, 124.2429454234043078, 46.44264920908244676, 1.7018503213839721866, + 41.948376245301915333, 86.691812684242904652, 31.000412639663409209, 121.76269377486823942, + 40.474998794121347601, 35.991553083000326296, 107.46219114179257303, 100.7558563713755575, + 59.758996677828690736, 122.93260101763007697, 59.345987073647847865, 4.3529825669320416637, + 53.388806055088934954, 11.443426474681473337, 5.0468975570656766649, 102.71777632277007797, + 75.59577374167565722, 68.104926566589711001, 48.679487771878484637, 105.28555946845881408, + 99.463516801297373604, 103.19026673306143493, 43.287555644841631874, 12.995830120406026253, + 40.883042834258958464, 28.323553412668843521, 87.43511427514749812, 119.99459744656269322, + 31.017960975255846279, 27.425375540758977877, 8.8363670996768632904, 36.157410217110736994, + 4.6917486826860113069, 46.267785217518394347, 23.002643813586473698, 41.145051643190527102, + 114.96879877533501713, 119.4032055509815109, 56.05906368756404845, 102.32009215094876708, + 100.81098082213429734, 73.467196009325562045, 18.533128778359241551, 118.64783205298954272, + 60.788783391049946658, 72.327042576787789585, 57.424607552911766106, 115.76932543975635781, + 125.14802897749905242, 55.080956267975125229, 109.53207965918045375, 95.716653065999707906, + 50.568802463301835814, 25.182721855770068942, 112.61858763245254522, 26.448881996802811045, + 76.001022538635879755, 66.354605757751414785, 42.277388063292164588, 26.84260271464518155, + 73.131770870295440545, 83.290153222355002072, 69.082963891483814223, 30.403080045380193042, + 125.3519428129766311, 118.90666067693018704, 9.5201617678976617754, 12.526887598829489434, + 73.128079723897826625, 106.22130150583689101, 92.064708150763181038, 85.667177750274277059, + 73.828141657355445204, 93.649104554377117893, 121.52925749349378748, 68.889239144238672452, + 51.199605007353966357, 53.44250899105463759, 5.0278747031115926802, 9.1564778611937072128, + 60.789047251015290385, 15.321503829658468021, 96.392637109285715269, 103.95507350760453846, + 50.094596446670038858, 78.61244620206343825, 94.482199891921482049, 16.337618544930592179, + 23.144044318356463918, 8.5264778429373109248, 0.42303465936493012123, 114.02756899854284711, + 86.584151218998158583, 92.769102014608506579, 0.30928244984897901304, 19.9274573005423008, + 54.916092070699960459, 52.295716949178313371, 59.035561803415475879, 71.289922022191603901, + 59.713810479603125714, 38.879742517387057887, 89.458679688148549758, 7.9292003569426015019, + 10.899602607340057148, 33.783828758369054412, 67.846749482043378521, 117.72199590733362129, + 52.86958090392727172, 74.286463983688008739, 93.899194656118197599, 108.64487936713339877, + 127.16760894941762672, 46.988486291567824082, 123.04843600948879612, 96.740814962704462232, + 125.34907412461689091, 92.98714410495449556, 93.973426999531511683, 87.926159630431357073, + 65.005992801736283582, 38.801354999763134401, 27.339993310837598983, 40.288400158857257338, + 84.549994151049759239, 84.197873287113907281, 32.95289211522685946, 54.929478051391924964, + 94.861417909363808576, 54.215140549469651887, 107.93494097043367219, 123.34605865677440306, + 63.241584065199276665, 22.972059297553641954, 71.479923107784998138, 13.25286769331432879, + 49.546816536858386826, 102.92924320591191645, 94.812984917476569535, 91.395618719150661491, + 106.73441012546027196, 2.1713157944795966614, 23.906322147809987655, 52.114577130108955316, + 94.791084620035690023, 62.905993452284747036, 91.539028080511343433, 14.861810036189126549, + 66.003789289406995522, 127.76560232766860281, 3.2127394903218373656, 85.833902083290013252, + 108.85783981120766839, 60.667449566131836036, 87.515973996429238468, 101.72226978203252656, + 57.762312124657910317, 126.71239954240445513, 78.276372555137641029, 52.55807898290004232, + 24.629259963134245481, 11.527384957305912394, 82.598500568583403947, 122.64002407491352642, + 125.71996407244660077, 84.590864291658363072, 83.387361186425550841, 17.661679522116173757, + 69.723058931060222676, 121.23437645319063449, 64.553234893734042998, 52.641028662765165791, + 41.456009620524127968, 101.92591717076356872, 92.116115320815879386, 87.012780470966390567, + 2.0227858771686442196, 1.2480566492740763351, 7.8804327893412846606, 40.198667038439452881, + 43.966474091092095478, 26.268524138606153429, 89.921807584967609728, 81.313790602034714539, + 19.934540474339883076, 86.737033822668308858, 77.053317673588026082, 106.95541619569121394, + 84.882812768963049166, 67.432508196539856726, 31.336119716597750084, 26.836151322670048103, + 35.203860078490833985, 42.533078727799875196, 114.58293191418124479, 40.093986243206018116, + 49.091856518112763297, 100.39616590597506729, 13.899533124240406323, 54.388636799336381955, + 105.20736872811539797, 27.283673733909381554, 58.727632062127668178, 110.66697262095840415, + 26.287986083581927232, 118.63292128570537898, 72.485444940582965501, 83.904995893353770953, + 8.5523126091502490453, 0.26731491067039314657, 106.43272386136231944, 33.071999292722466635, + 74.709693296626937808, 61.723132433573482558, 106.61327349934435915, 83.459280647803097963, + 45.763377698411204619, 83.636778782198234694, 88.453797641454002587, 3.0632713324739597738, + 88.640714282748376718, 95.496077992640493903, 99.405968740025855368, 89.451005457241990371, + 113.03872754816984525, 119.53793601009601844, 40.84652189632106456, 89.601161070695525268, + 81.366182645942899399, 113.90351656461280072, 106.64805184365832247, 125.59665123095692252, + 127.49605133274963009, 92.442935411851067329, 84.912745773050119169, 61.867082992055657087, + 4.8935098957445006818, 100.42403444607043639, 22.643306583573576063, 95.036753123902599327, + 83.699349714228446828, 41.338717819351586513, 25.045783049052261049, 18.676453308402415132, + 57.2850988074169436, 8.8553845225796976592, 66.858448917919304222, 105.59661583619526937, + 55.401910423253866611, 28.584972280274087097, 88.381780140513001243, 80.414581767057825346, + 33.779166486277972581, 80.548212235342361964, 29.496911616919533117, 51.50258242828931543, + 19.996117929837055271, 79.162858264771784889, 45.222115719610883389, 93.041611004693550058, + 111.62174321461134241, 88.600777114701486425, 20.501321735591773177, 75.308853100657870527, + 34.053535367569566006, 17.040345421304664342, 79.597116425709828036, 40.982533372043690179, + 11.67821493557858048, 47.914784562712156912, 55.667170178003289038, 42.277593056543992134, + 16.258233450709667522, 81.047275174223614158, 99.538400584191549569, 31.411089591674681287, + 40.236116969743306981, 21.989416294010879938, 60.985610657760844333, 55.052895472505042562, + 97.308128857312112814, 73.391525776089110877, 76.16446188093686942, 87.90798978904786054, + 36.94487876133644022, 61.92948729483759962, 78.68460706772384583, 111.4966446364451258, + 89.423413232634629821, 101.93314439875757671, 93.155729377896932419, 50.575479817813175032, + 35.225140792350430274, 16.311071711625118041, 102.21934522496667341, 124.39627260666020447, + 105.9759143000082986, 9.0364521542578586377, 126.4348312406000332, 127.21378874413130688, + 7.4622808006461127661, 79.614781428419519216, 54.870470503534306772, 115.3259432745144295, + 26.839017017580772517, 32.014526758965075715, 116.98555523192044348, 14.234804626834375085, + 74.342980542165605584, 0, 114.4458108730323147, 39.343047452359314775, + 56.107121628509048605, 113.05567979655825184, 49.835683696597698145, 27.446394183705706382, + 27.647461686832684791, 58.509588511482434114, 112.93495020486807334, 39.245735300228261622, + 37.841439283729414456, 113.7523623402157682, 32.612440771597903222, 53.201649295227980474, + 63.091735024110676022, 71.992767332005314529, 44.751945106439961819, 11.351721592112880899, + 38.81191855514771305, 38.864213525688683148, 79.187333508059964515, 123.67380895444148337, + 118.4767830332457379, 20.643472373212716775, 125.53510158701101318, 86.012455402982595842, + 109.45895540516721667, 2.4211554803514445666, 113.78394600447427365, 48.524804612141451798, + 41.253181523639796069, 118.12529544760400313, 8.1882425971125485376, 115.65932279137632577, + 120.06856399599928409, 103.05321070263744332, 4.5830333759586210363, 104.72414841825229814, + 94.537638556685124058, 79.662105664912814973, 123.94383630670563434, 94.310916095440916251, + 120.4048594193009194, 121.48392468143356382, 26.896381351805757731, 127.070694433466997, + 72.835767606953595532, 75.297131465151323937, 48.647169637984916335, 66.768268662777700229, + 11.625023413376766257, 24.710076237817702349, 77.500749215112591628, 43.287025171641289489, + 42.437202315355534665, 4.160142754037224222, 84.918538971691305051, 120.48589084680861561, + 92.885298418164893519, 3.4037006427679443732, 83.896752490607468644, 45.383625368485809304, + 62.000825279330456397, 115.52538754973647883, 80.949997588242695201, 71.983106166004290571, + 86.924382283588784048, 73.511712742751115002, 119.51799335566101945, 117.86520203526015393, + 118.69197414729569573, 8.7059651338640833274, 106.77761211017786991, 22.886852949362946674, + 10.093795114134991309, 77.435552645543793915, 23.191547483354952419, 8.2098531331794220023, + 97.358975543760607252, 82.57111893692126614, 70.927033602598385187, 78.380533466122869868, + 86.575111289683263749, 25.991660240812052507, 81.766085668517916929, 56.64710682534132502, + 46.870228550298634218, 111.98919489312538644, 62.035921950511692557, 54.850751081517955754, + 17.672734199353726581, 72.314820434221473988, 9.3834973653720226139, 92.535570435036788695, + 46.005287627172947396, 82.290103286384692183, 101.93759755067367223, 110.80641110196302179, + 112.11812737513173488, 76.640184301901172148, 73.621961644272232661, 18.93439201865112409, + 37.06625755672212108, 109.29566410597908543, 121.5775667821035313, 16.65408515357557917, + 114.84921510582717019, 103.5386508795163536, 122.29605795499810483, 110.16191253595388844, + 91.06415931836454547, 63.433306131999415811, 101.13760492660367163, 50.365443711543775862, + 97.237175264905090444, 52.897763993609260069, 24.002045077275397489, 4.7092115155028295703, + 84.554776126584329177, 53.685205429294001078, 18.263541740594519069, 38.580306444713642122, + 10.165927782967628445, 60.806160090764024062, 122.70388562595690018, 109.81332135386037407, + 19.040323535795323551, 25.053775197662616847, 18.256159447799291229, 84.44260301167742, + 56.129416301530000055, 43.334355500552192098, 19.656283314714528387, 59.298209108757873764, + 115.05851498699121294, 9.7784782884773449041, 102.39921001470793271, 106.88501798210927518, + 10.05574940622318536, 18.312955722387414426, 121.57809450203058077, 30.643007659320574021, + 64.785274218575068517, 79.910147015209076926, 100.1891928933437157, 29.224892404130514478, + 60.964399783842964098, 32.675237089861184359, 46.288088636712927837, 17.05295568587462185, + 0.84606931873349822126, 100.0551379970893322, 45.168302437999955146, 57.538204029217013158, + 0.61856489969795802608, 39.8549146010846016, 109.83218414139992092, 104.59143389835662674, + 118.07112360683458974, 14.579844044383207802, 119.42762095920625143, 77.759485034777753754, + 50.917359376297099516, 15.858400713885203004, 21.799205214680114295, 67.567657516741746804, + 7.6934989640903950203, 107.44399181466724258, 105.73916180785818142, 20.572927967379655456, + 59.798389312240033178, 89.289758734270435525, 126.33521789883525344, 93.976972583139286144, + 118.09687201898123021, 65.481629925412562443, 122.6981482492374198, 57.9742882099126291, + 59.946853999066661345, 47.852319260866352124, 2.0119856034725671634, 77.602709999526268803, + 54.679986621675197966, 80.576800317718152655, 41.099988302103156457, 40.395746574227814563, + 65.905784230453718919, 109.85895610278748791, 61.722835818727617152, 108.43028109894294175, + 87.869881940870982362, 118.69211731354880612, 126.48316813039855333, 45.944118595110921888, + 14.959846215569996275, 26.505735386628657579, 99.09363307372041163, 77.858486411827470874, + 61.625969834956777049, 54.791237438304960961, 85.468820250920543913, 4.3426315889591933228, + 47.81264429561997531, 104.22915426022154861, 61.582169240071380045, 125.81198690457313205, + 55.078056161022686865, 29.723620072381891077, 4.0075785788176290225, 127.53120465533720562, + 6.4254789806473127101, 43.667804166583664482, 89.71567962241533678, 121.33489913226731005, + 47.031947992862114916, 75.444539564065053128, 115.52462424931945861, 125.42479908481254824, + 28.552745110275282059, 105.11615796580008464, 49.258519926268490963, 23.054769914615462767, + 37.197001137170445872, 117.28004814983069082, 123.43992814489683951, 41.181728583320364123, + 38.774722372851101682, 35.323359044235985493, 11.446117862124083331, 114.46875290638490696, + 1.1064697874680859968, 105.28205732553033158, 82.912019241051893914, 75.851834341530775419, + 56.232230641635396751, 46.025560941932781134, 4.0455717543372884393, 2.4961132985481526703, + 15.760865578682569321, 80.397334076878905762, 87.932948182184190955, 52.537048277215944836, + 51.843615169938857434, 34.627581204069429077, 39.869080948683404131, 45.474067645340255694, + 26.106635347179690143, 85.910832391386065865, 41.765625537929736311, 6.8650163930797134526, + 62.672239433195500169, 53.672302645340096205, 70.407720156981667969, 85.066157455603388371, + 101.16586382836248958, 80.187972486412036233, 98.183713036229164572, 72.792331811950134579, + 27.799066248480812646, 108.77727359867640189, 82.414737456230795942, 54.567347467818763107, + 117.45526412425897433, 93.3339452419168083, 52.575972167167492444, 109.26584257141439593, + 16.97088988116956898, 39.809991786707541905, 17.104625218300498091, 0.53462982134442427196, + 84.865447722724638879, 66.143998585448571248, 21.419386593253875617, 123.4462648671506031, + 85.226546998692356283, 38.918561295606195927, 91.526755396826047217, 39.273557564400107367, + 48.907595282908005174, 6.1265426649515575264, 49.281428565500391414, 62.992155985284625785, + 70.811937480055348715, 50.90201091448761872, 98.077455096343328478, 111.07587202019203687, + 81.693043792645767098, 51.202322141394688515, 34.732365291889436776, 99.807033129229239421, + 85.296103687320282916, 123.19330246191748301, 126.99210266550289816, 56.885870823705772636, + 41.825491546100238338, 123.73416598411131417, 9.7870197914926393423, 72.848068892140872777, + 45.286613167150790105, 62.073506247808836633, 39.398699428456893656, 82.677435638703173026, + 50.091566098104522098, 37.352906616804830264, 114.5701976148338872, 17.710769045163033297, + 5.7168978358422464225, 83.193231672390538733, 110.80382084650773322, 57.169944560551812174, + 48.763560281029640464, 32.829163534115650691, 67.558332972559583141, 33.096424470684723929, + 58.993823233839066233, 103.00516485657863086, 39.992235859677748522, 30.325716529543569777, + 90.444231439225404756, 58.083222009390738094, 95.243486429226322798, 49.201554229402972851, + 41.002643471187184332, 22.617706201315741055, 68.107070735139132012, 34.080690842612966662, + 31.194232851419656072, 81.965066744087380357, 23.35642987115716096, 95.829569125424313825, + 111.33434035600657808, 84.555186113087984268, 32.516466901422973024, 34.094550348450866295, + 71.076801168383099139, 62.822179183349362575, 80.472233939486613963, 43.978832588021759875, + 121.97122131552168867, 110.1057909450137231, 66.616257714627863606, 18.783051552181859734, + 24.328923761877376819, 47.815979578095721081, 73.889757522672880441, 123.85897458967883722, + 29.369214135451329639, 94.993289272893889574, 50.846826465272897622, 75.866288797518791398, + 58.311458755793864839, 101.15095963562635006, 70.450281584700860549, 32.622143423253874062, + 76.438690449936984805, 120.79254521332404693, 83.951828600016597193, 18.072904308519355254, + 124.86966248120370437, 126.42757748826261377, 14.924561601295863511, 31.229562856839038432, + 109.74094100707225152, 102.65188654902885901, 53.678034035161545034, 64.029053517933789408, + 105.97111046384088695, 28.469609253672388149, 20.685961084334849147, 0, + 100.89162174606462941, 78.68609490471862955, 112.21424325702173519, 98.111359593116503675, + 99.671367393195396289, 54.892788367411412764, 55.294923373665369581, 117.01917702296850621, + 97.869900409736146685, 78.491470600456523243, 75.68287856746246689, 99.504724680431536399, + 65.224881543195806444, 106.40329859045596095, 126.18347004822499002, 15.985534664010629058, + 89.503890212879923638, 22.703443184225761797, 77.6238371102954261, 77.728427051381004276, + 30.374667016123567009, 119.34761790888660471, 108.95356606649147579, 41.286944746429071529, + 123.07020317402566434, 44.024910805968829663, 90.917910810334433336, 4.8423109607065271121, + 99.5678920089485473, 97.049609224282903597, 82.506363047283230117, 108.25059089520800626, + 16.376485194228735054, 103.31864558275628951, 112.13712799200220616, 78.106421405274886638, + 9.1660667519208800513, 81.448296836508234264, 61.075277113373886095, 31.324211329829267925, + 119.88767261341490666, 60.621832190885470482, 112.80971883860547678, 114.96784936286712764, + 53.792762703615153441, 126.14138886693763197, 17.671535213910829043, 22.594262930302647874, + 97.294339275973470649, 5.5365373255554004572, 23.250046826753532514, 49.420152475639042677, + 27.001498430225183256, 86.574050343282578979, 84.874404630711069331, 8.3202855080780864228, + 41.83707794338624808, 112.97178169362086919, 57.770596836329787038, 6.8074012855395267252, + 39.793504981214937288, 90.767250736971618608, 124.00165055866455077, 103.05077509947659564, + 33.899995176489028381, 15.966212332012219122, 45.848764567181206075, 19.023425485505867982, + 111.03598671132567688, 107.73040407052394585, 109.38394829459139146, 17.411930267731804634, + 85.555224220355739817, 45.773705898725893348, 20.187590228273620596, 26.87110529108758783, + 46.383094966709904838, 16.419706266362481983, 66.717951087524852483, 37.14223787384617026, + 13.854067205200408353, 28.761066932249377714, 45.150222579366527498, 51.983320481627742993, + 35.532171337035833858, 113.29421365068265004, 93.740457100600906415, 95.978389786250772886, + 124.07184390102338511, 109.70150216303591151, 35.34546839871109114, 16.629640868442947976, + 18.766994730747683207, 57.071140870073577389, 92.01057525434953277, 36.580206572773022344, + 75.875195101350982441, 93.612822203929681564, 96.236254750267107738, 25.280368603805982275, + 19.243923288544465322, 37.86878403730224818, 74.13251511344788014, 90.591328211961808847, + 115.15513356420706259, 33.308170307154796319, 101.69843021165797836, 79.077301759036345175, + 116.59211590999984764, 92.323825071911414852, 54.12831863672909094, 126.8666122640024696, + 74.275209853207343258, 100.7308874230911897, 66.474350529810180888, 105.79552798721852014, + 48.004090154550794978, 9.4184230310092971195, 41.109552253168658353, 107.37041085858800216, + 36.527083481189038139, 77.160612889427284244, 20.331855565935256891, 121.6123201815316861, + 117.40777125191743835, 91.626642707720748149, 38.080647071590647101, 50.107550395325233694, + 36.512318895602220437, 40.885206023354839999, 112.25883260306000011, 86.668711001104384195, + 39.312566629429056775, 118.59641821751938551, 102.11702997398242587, 19.556956576958327787, + 76.798420029419503408, 85.770035964218550362, 20.111498812446370721, 36.62591144477846683, + 115.15618900406116154, 61.286015318644786021, 1.5705484371537750121, 31.820294030421791831, + 72.378385786687431391, 58.449784808261028957, 121.9287995676859282, 65.350474179722368717, + 92.576177273425855674, 34.105911371749243699, 1.6921386374706344213, 72.110275994178664405, + 90.336604875999910291, 115.07640805843402632, 1.2371297993959160522, 79.709829202172841178, + 91.664368282803479815, 81.182867796716891462, 108.14224721366917947, 29.159688088770053582, + 110.85524191841614083, 27.518970069555507507, 101.83471875259419903, 31.716801427770406008, + 43.598410429363866569, 7.1353150334834936075, 15.386997928184428019, 86.887983629338123137, + 83.478323615716362838, 41.145855934759310912, 119.59677862448370433, 50.579517468544509029, + 124.67043579767414485, 59.953945166282210266, 108.1937440379660984, 2.9632598508287628647, + 117.39629649847483961, 115.9485764198252582, 119.89370799813332269, 95.704638521732704248, + 4.0239712069487723056, 27.205419999052537605, 109.35997324335403391, 33.153600635436305311, + 82.199976604206312913, 80.791493148459267104, 3.8115684609110758174, 91.717912205574975815, + 123.44567163745887228, 88.860562197889521485, 47.739763881745602703, 109.38423462710125023, + 124.96633626079710666, 91.888237190221843775, 29.91969243113999255, 53.011470773260953138, + 70.18726614744446124, 27.716972823654941749, 123.2519396699135541, 109.5824748766135599, + 42.937640501841087826, 8.6852631779183866456, 95.625288591243588598, 80.458308520443097223, + 123.16433848014639807, 123.6239738091462641, 110.15611232204537373, 59.447240144763782155, + 8.0151571576388960239, 127.06240931067441124, 12.85095796129462542, 87.335608333170966944, + 51.431359244834311539, 114.6697982645346201, 94.06389598572786781, 22.889079128133744234, + 103.04924849864255521, 122.84959816962509649, 57.105490220554202097, 82.232315931600169279, + 98.517039852536981925, 46.109539829230925534, 74.394002274344529724, 106.56009629966501961, + 118.87985628979367903, 82.363457166640728246, 77.549444745702203363, 70.646718088471970987, + 22.892235724251804641, 100.93750581276981393, 2.2129395749398099724, 82.564114651064301142, + 37.824038482107425807, 23.703668683061550837, 112.4644612832707935, 92.051121883865562268, + 8.0911435086745768785, 4.9922265970963053405, 31.521731157368776621, 32.794668153761449503, + 47.86589636436838191, 105.07409655443188967, 103.68723033987771487, 69.255162408138858154, + 79.738161897366808262, 90.948135290680511389, 52.213270694363018265, 43.82166478277213173, + 83.531251075859472621, 13.730032786159426905, 125.34447886639100034, 107.34460529068383039, + 12.815440313966973918, 42.132314911210414721, 74.331727656728617148, 32.375944972827710444, + 68.367426072461967124, 17.584663623900269158, 55.598132496965263272, 89.554547197356441757, + 36.829474912461591884, 109.13469493564116419, 106.91052824852158665, 58.667890483833616599, + 105.15194433433862287, 90.531685142828791868, 33.94177976233913796, 79.619983573415083811, + 34.209250436600996181, 1.0692596426924865227, 41.730895445452915737, 4.287997170897142496, + 42.838773186511389213, 118.89252973430484417, 42.453093997384712566, 77.837122591216029832, + 55.053510793652094435, 78.547115128800214734, 97.815190565816010348, 12.253085329903115053, + 98.562857131000782829, 125.98431197057288955, 13.62387496011069743, 101.80402182897887542, + 68.154910192690294934, 94.151744040387711721, 35.386087585291534197, 102.40464428278937703, + 69.46473058378251153, 71.614066258462116821, 42.59220737464420381, 118.38660492383860401, + 125.98420533100579632, 113.77174164741154527, 83.650983092204114655, 119.46833196822262835, + 19.574039582988916663, 17.696137784281745553, 90.573226334301580209, 124.14701249561767327, + 78.797398856917425292, 37.354871277406346053, 100.1831321962090442, 74.705813233613298507, + 101.1403952296677744, 35.421538090326066595, 11.433795671688130824, 38.386463344784715446, + 93.607641693015466444, 114.33988912110362435, 97.527120562059280928, 65.658327068234939361, + 7.1166659451191662811, 66.192848941369447857, 117.98764646768177045, 78.010329713157261722, + 79.984471719355497044, 60.651433059090777533, 52.888462878450809512, 116.16644401878511417, + 62.486972858452645596, 98.403108458805945702, 82.005286942374368664, 45.235412402635120088, + 8.2141414702782640234, 68.161381685225933325, 62.388465702842950122, 35.930133488174760714, + 46.712859742317959899, 63.659138250852265628, 94.668680712016794132, 41.110372226175968535, + 65.032933802845946047, 68.189100696905370569, 14.153602336766198277, 125.64435836670236313, + 32.944467878973227926, 87.957665176047157729, 115.94244263104701531, 92.211581890031084185, + 5.2325154292557272129, 37.566103104363719467, 48.657847523754753638, 95.631959156195080141, + 19.779515045349398861, 119.71794917935767444, 58.738428270906297257, 61.986578545787779149, + 101.69365293054943322, 23.732577595037582796, 116.62291751159136766, 74.301919271256338106, + 12.900563169401721098, 65.244286846511386102, 24.87738089987760759, 113.58509042665173183, + 39.903657200033194385, 36.145808617042348487, 121.73932496241104673, 124.85515497652522754, + 29.849123202591727022, 62.459125713681714842, 91.481882014148141025, 77.303773098057718016, + 107.35606807032672805, 0.058107035871216794476, 83.942220927681773901, 56.939218507344776299, + 41.371922168669698294, 0, 73.78324349213289679, 29.372189809440897079, + 96.428486514047108358, 68.222719186236645328, 71.342734786390792578, 109.78557673482282553, + 110.58984674733437714, 106.03835404594065039, 67.739800819475931348, 28.982941200916684465, + 23.365757134928571759, 71.009449360866710776, 2.4497630863952508662, 84.806597180915559875, + 124.36694009644998005, 31.971069328024896095, 51.007780425759847276, 45.406886368455161573, + 27.24767422059449018, 27.456854102762008552, 60.749334032250771997, 110.6952358177768474, + 89.907132132982951589, 82.573889492861781036, 118.14040634805132868, 88.049821611941297306, + 53.835821620668866672, 9.6846219214166922029, 71.135784017900732579, 66.099218448569445172, + 37.012726094570098212, 88.501181790416012518, 32.752970388461108087, 78.637291165516217006, + 96.274255984008050291, 28.212842810549773276, 18.332133503845398081, 34.896593673016468529, + 122.15055422674777219, 62.648422659662173828, 111.77534522682981333, 121.24366438177457894, + 97.619437677214591531, 101.93569872573425528, 107.58552540723394486, 124.28277773387526395, + 35.343070427821658086, 45.188525860608933726, 66.588678551946941298, 11.073074651110800914, + 46.500093653507065028, 98.840304951278085355, 54.002996860454004491, 45.148100686568795936, + 41.748809261422138661, 16.640571016156172846, 83.674155886776134139, 97.943563387241738383, + 115.54119367265957408, 13.61480257107905345, 79.587009962433512555, 53.534501473946875194, + 120.00330111733273952, 78.101550198953191284, 67.799990352978056762, 31.932424664024438243, + 91.697529134362412151, 38.046850971015373943, 94.071973422654991737, 87.460808141051529674, + 90.767896589182782918, 34.823860535467247246, 43.110448440711479634, 91.547411797451786697, + 40.375180456547241192, 53.742210582175175659, 92.766189933419809677, 32.839412532728601946, + 5.4359021750497049652, 74.284475747692340519, 27.708134410400816705, 57.522133864498755429, + 90.300445158733054996, 103.96664096325548599, 71.064342674075305695, 98.58842730136893806, + 59.480914201205450809, 63.956779572505183751, 120.14368780205040821, 91.403004326071823016, + 70.690936797422182281, 33.259281736885895953, 37.533989461495366413, 114.14228174015079276, + 56.02115050869906554, 73.160413145549682667, 23.75039020270560286, 59.225644407863001106, + 64.472509500534215476, 50.56073720761196455, 38.487846577088930644, 75.737568074608134339, + 20.265030226899398258, 53.182656423927255673, 102.31026712841412518, 66.616340614313230617, + 75.396860423319594702, 30.154603518076328328, 105.18423182000333327, 56.647650143822829705, + 108.25663727346181986, 125.73322452800857718, 20.550419706418324495, 73.461774846186017385, + 4.948701059623999754, 83.591055974437040277, 96.008180309101589955, 18.836846062018594239, + 82.219104506340954686, 86.740821717176004313, 73.054166962381714256, 26.321225778854568489, + 40.663711131874151761, 115.22464036306701018, 106.81554250383851468, 55.253285415441496298, + 76.161294143181294203, 100.21510079065046739, 73.024637791204440873, 81.770412046713317977, + 96.5176652061236382, 45.33742200220876839, 78.625133258861751528, 109.19283643504240899, + 76.234059947964851744, 39.113913153920293553, 25.596840058842644794, 43.540071928437100723, + 40.222997624892741442, 73.251822889560571639, 102.31237800812232308, 122.57203063728957204, + 3.1410968743075500242, 63.640588060847221641, 16.756771573374862783, 116.89956961652569589, + 115.85759913537549437, 2.7009483594483754132, 57.152354546851711348, 68.211822743498487398, + 3.3842772749449068215, 16.220551988360966789, 52.673209752003458561, 102.15281611686805263, + 2.4742595987954700831, 31.419658404349320335, 55.328736565610597609, 34.365735593437420903, + 88.284494427338358946, 58.319376177543745143, 93.710483836832281668, 55.037940139114652993, + 75.669437505188398063, 63.433602855540812016, 87.196820858727733139, 14.270630066966987215, + 30.773995856372494018, 45.775967258679884253, 38.956647231432725675, 82.291711869522259803, + 111.19355724896740867, 101.15903493709265604, 121.3408715953482897, 119.90789033256805851, + 88.387488075932196807, 5.9265197016611637082, 106.7925929969533172, 103.89715283965415438, + 111.78741599627028336, 63.409277043465408497, 8.0479424138975446112, 54.410839998108713189, + 90.719946486708067823, 66.3072012708762486, 36.399953208416263806, 33.582986296918534208, + 7.6231369218257896136, 55.435824411153589608, 118.89134327492138254, 49.72112439577904297, + 95.479527763494843384, 90.76846925420613843, 121.9326725215978513, 55.776474380443687551, + 59.8393848622799851, 106.02294154652554425, 12.374532294888922479, 55.433945647313521476, + 118.50387933983074618, 91.1649497532271198, 85.875281003682175651, 17.37052635584041127, + 63.250577182490815176, 32.916617040889832424, 118.32867696029643412, 119.24794761829616618, + 92.312224644090747461, 118.89448028952756431, 16.030314315281430027, 126.12481862134882249, + 25.701915922592888819, 46.671216666341933887, 102.86271848967226106, 101.33959652907287818, + 60.12779197145573562, 45.778158256271126447, 78.098496997288748389, 117.69919633925019298, + 114.21098044111204217, 36.464631863203976536, 69.034079705073963851, 92.219079658465489047, + 20.788004548692697426, 85.120192599333677208, 109.75971257959099603, 36.726914333285094472, + 27.098889491408044705, 13.293436176943941973, 45.78447144850724726, 73.875011625539627858, + 4.4258791498832579236, 37.128229302128602285, 75.648076964214851614, 47.407337366126739653, + 96.928922566545224981, 56.102243767731124535, 16.182287017349153757, 9.9844531941926106811, + 63.043462314737553243, 65.589336307522899006, 95.731792728740401799, 82.148193108867417322, + 79.374460679759067716, 10.510324816281354288, 31.476323794737254502, 53.896270581361022778, + 104.42654138872603653, 87.643329565547901439, 39.062502151718945242, 27.460065572322491789, + 122.68895773278563865, 86.68921058136766078, 25.630880627933947835, 84.26462982242446742, + 20.663455313457234297, 64.751889945659058867, 8.7348521449239342473, 35.169327247800538316, + 111.19626499393416452, 51.109094394712883513, 73.658949824926821748, 90.269389871285966365, + 85.821056497043173295, 117.33578096767087118, 82.303888668680883711, 53.063370285657583736, + 67.883559524681913899, 31.239967146830167621, 68.418500873201992363, 2.1385192853849730454, + 83.461790890905831475, 8.5759943417942849919, 85.677546373026416404, 109.78505946860968834, + 84.90618799477306311, 27.674245182432059664, 110.10702158730782685, 29.094230257604067447, + 67.630381131632020697, 24.506170659809868084, 69.125714262005203636, 123.9686239411457791, + 27.247749920225032838, 75.608043657961388817, 8.3098203853842278477, 60.303488080775423441, + 70.772175170586706372, 76.809288565582392039, 10.92946116756866104, 15.228132516924233641, + 85.184414749292045599, 108.773209847680846, 123.96841066201523063, 99.543483294826728525, + 39.301966184411867289, 110.9366639364452567, 39.148079165977833327, 35.392275568567129085, + 53.146452668606798397, 120.29402499123898451, 29.594797713834850583, 74.709742554816330085, + 72.36626439242172637, 21.411626467230234994, 74.280790459335548803, 70.843076180652133189, + 22.867591343376261648, 76.77292668957306887, 59.215283386034570867, 100.67977824221088667, + 67.054241124122199835, 3.316654136469878722, 14.233331890241970541, 4.3856978827425336931, + 107.97529293536717887, 28.020659426318161422, 31.968943438710994087, 121.30286611818155507, + 105.776925756905257, 104.33288803757022833, 124.97394571690892917, 68.806216917615529383, + 36.010573884748737328, 90.470824805270240176, 16.428282940560166026, 8.3227633704518666491, + 124.77693140568590024, 71.860266976349521428, 93.425719484635919798, 127.31827650170816923, + 61.337361424033588264, 82.220744452355575049, 2.0658676056955300737, 8.3782013938107411377, + 28.307204673536034534, 123.28871673340472626, 65.88893575795009383, 47.915330352097953437, + 103.8848852620976686, 56.423163780062168371, 10.465030858511454426, 75.132206208727438934, + 97.315695047513145255, 63.263918312390160281, 39.5590300907024357, 111.43589835871534888, + 117.47685654181259451, 123.97315709157919628, 75.387305861098866444, 47.465155190078803571, + 105.24583502318637329, 20.603838542512676213, 25.801126338807080174, 2.4885736930227722041, + 49.754761799758853158, 99.170180853303463664, 79.807314400066388771, 72.291617234088334953, + 115.47864992482573143, 121.71030995305045508, 59.698246405183454044, 124.91825142736706766, + 54.963764028299920028, 26.607546196119074011, 86.712136140653456096, 0.11621407174607156776, + 39.884441855363547802, 113.8784370146895526, 82.743844337343034567, 0, + 19.566486984265793581, 58.744379618885432137, 64.856973028097854694, 8.4454383724769286346, + 14.685469572785223136, 91.571153469649289036, 93.179693494672392262, 84.076708091884938767, + 7.4796016389518626966, 57.965882401833368931, 46.731514269860781496, 14.018898721733421553, + 4.8995261727941397112, 41.613194361834757729, 120.73388019289996009, 63.942138656049792189, + 102.01556085151969455, 90.813772736910323147, 54.49534844118898036, 54.913708205524017103, + 121.49866806450518197, 93.390471635557332775, 51.814264265969541157, 37.147778985727200052, + 108.28081269610629533, 48.099643223882594611, 107.67164324133773334, 19.369243842837022385, + 14.271568035805103136, 4.1984368971388903446, 74.025452189143834403, 49.002363580832025036, + 65.505940776925854152, 29.274582331036071992, 64.548511968016100582, 56.425685621099546552, + 36.664267007690796163, 69.793187346036575036, 116.30110845349554438, 125.29684531932798564, + 95.550690453663264634, 114.48732876355279586, 67.238875354432821041, 75.871397451472148532, + 87.171050814471527701, 120.5655554677505279, 70.686140855643316172, 90.377051721221505431, + 5.177357103893882595, 22.146149302221601829, 93.000187307017768035, 69.680609902556170709, + 108.00599372090800898, 90.296201373137591872, 83.497618522844277322, 33.28114203231598367, + 39.348311773555906257, 67.887126774487114744, 103.08238734531914815, 27.22960514216174488, + 31.174019924867025111, 107.06900294789738837, 112.00660223466911702, 28.203100397910020547, + 7.5999807059561135247, 63.864849328052514466, 55.395058268724824302, 76.093701942034385866, + 60.143946845313621452, 46.921616282106697327, 53.535793178365565836, 69.647721070934494492, + 86.220896881426597247, 55.094823594903573394, 80.750360913094482385, 107.4844211643539893, + 57.532379866839619353, 65.678825065457203891, 10.871804350103047909, 20.568951495384681039, + 55.41626882080163341, 115.04426772900114884, 52.60089031746974797, 79.93328192651460995, + 14.128685348154249368, 69.176854602737876121, 118.96182840241090162, 127.91355914501400548, + 112.2873756041044544, 54.80600865214728401, 13.381873594844364561, 66.518563473771791905, + 75.067978922994370805, 100.28456348030158551, 112.04230101740176906, 18.320826291099365335, + 47.50078040541120572, 118.45128881572964019, 0.94501900106843095273, 101.1214744152239291, + 76.975693154181499267, 23.475136149216268677, 40.530060453798796516, 106.36531284785814933, + 76.620534256831888342, 5.2326812286300992128, 22.793720846639189404, 60.309207036156294635, + 82.368463640006666537, 113.29530028764929739, 88.513274546927277697, 123.46644905601715436, + 41.100839412840286968, 18.92354969237203477, 9.8974021192516374867, 39.182111948877718532, + 64.016360618203179911, 37.673692124040826457, 36.43820901268554735, 45.481643434355646605, + 18.108333924763428513, 52.642451557709136978, 81.3274222637519415, 102.44928072613765835, + 85.631085007677029353, 110.50657083088663057, 24.322588286366226384, 72.430201581304572755, + 18.049275582412519725, 35.540824093430273933, 65.035330412247276399, 90.674844004421174759, + 29.250266517727141036, 90.385672870088455966, 24.468119895929703489, 78.227826307840587106, + 51.193680117685289588, 87.080143856874201447, 80.445995249789120862, 18.503645779124781257, + 76.624756016248284141, 117.14406127457914408, 6.2821937486151000485, 127.28117612169444328, + 33.513543146753363544, 105.79913923305502976, 103.71519827075098874, 5.4018967188967508264, + 114.30470909370706067, 8.4236454869969747961, 6.7685545498898136429, 32.441103976721933577, + 105.3464195040105551, 76.305632233736105263, 4.9485191975909401663, 62.839316808698640671, + 110.65747313122119522, 68.731471186878479784, 48.568988854676717892, 116.63875235509112827, + 59.420967673664563335, 110.07588027823294397, 23.338875010376796126, 126.86720571108526201, + 46.393641717455466278, 28.54126013393397443, 61.547991712744988035, 91.551934517359768506, + 77.91329446286908933, 36.583423739048157586, 94.387114497938455315, 74.318069874188950052, + 114.68174319070021738, 111.815780665139755, 48.774976151864393614, 11.853039403325965395, + 85.585185993910272373, 79.794305679311946733, 95.574831992540566716, 126.81855408693081699, + 16.095884827795089222, 108.82167999622106436, 53.439892973419773625, 4.6144025417524971999, + 72.799906416832527611, 67.165972593837068416, 15.246273843651579227, 110.8716488223108172, + 109.78268654984276509, 99.44224879156172392, 62.959055526993324747, 53.536938508415914839, + 115.8653450431957026, 111.5529487608873751, 119.67876972456360818, 84.045883093051088508, + 24.749064589777844958, 110.86789129463068093, 109.00775867966513033, 54.329899506457877578, + 43.750562007364351302, 34.74105271168082254, 126.50115436498163035, 65.833234081783302827, + 108.65735392059650621, 110.49589523659597035, 56.6244492881851329, 109.78896057905512862, + 32.060628630566498032, 124.24963724269764498, 51.403831845185777638, 93.342433332687505754, + 77.725436979348160094, 74.679193058145756368, 120.25558394291147124, 91.556316512545890873, + 28.196993994581134757, 107.39839267850402393, 100.42196088222408434, 72.929263726411591051, + 10.06815941015156568, 56.438159316930978093, 41.576009097389032831, 42.240385198670992395, + 91.519425159181992058, 73.453828666570188943, 54.19777898281608941, 26.586872353887883946, + 91.568942897018132498, 19.750023251079255715, 8.8517582997665158473, 74.256458604260842549, + 23.296153928429703228, 94.814674732257117284, 65.857845133090449963, 112.20448753546224907, + 32.364574034698307514, 19.968906388385221362, 126.08692462947874446, 3.1786726150494359899, + 63.463585457484441577, 36.296386217738472624, 30.748921359518135432, 21.020649632562708575, + 62.952647589474509005, 107.79254116272568353, 80.853082777455711039, 47.286659131095802877, + 78.125004303437890485, 54.920131144648621557, 117.37791546557491529, 45.378421162735321559, + 51.261761255871533649, 40.52925964484893484, 41.326910626918106573, 1.503779891318117734, + 17.469704289847868495, 70.338654495604714612, 94.392529987868329044, 102.21818878942940501, + 19.317899649857281474, 52.538779742575570708, 43.642112994089984568, 106.67156193534538033, + 36.607777337361767422, 106.12674057131880545, 7.7671190493638277985, 62.479934293663973222, + 8.8370017464039847255, 4.2770385707735840697, 38.92358178181166295, 17.151988683592207963, + 43.355092746056470787, 91.570118937223014655, 41.81237598954612622, 55.348490364867757307, + 92.214043174615653697, 58.188460515211772872, 7.260762263264041394, 49.012341319623374147, + 10.251428524014045252, 119.9372478822915582, 54.495499840453703655, 23.216087315922777634, + 16.619640770768455695, 120.60697616155448486, 13.544350341177050723, 25.618577131164784078, + 21.858922335137322079, 30.456265033852105262, 42.368829498587729177, 89.546419695365329972, + 119.93682132403409923, 71.086966589653457049, 78.603932368827372557, 93.87332787289051339, + 78.296158331955666654, 70.78455113713425817, 106.29290533721723477, 112.58804998247796902, + 59.189595427673339145, 21.419485109636298148, 16.73252878484345274, 42.823252934464107966, + 20.561580918674735585, 13.686152361304266378, 45.735182686756161274, 25.54585337914613774, + 118.43056677207277971, 73.359556484425411327, 6.1084822482443996705, 6.633308272939757444, + 28.466663780483941082, 8.771395765488705365, 87.950585870734357741, 56.041318852636322845, + 63.937886877425626153, 114.60573223636674811, 83.553851513814151986, 80.665776075144094648, + 121.94789143382149632, 9.6124338352310587652, 72.021147769501112634, 52.941649610540480353, + 32.856565881120332051, 16.645526740907371277, 121.55386281137543847, 15.720533952702680836, + 58.851438969275477575, 126.63655300341633847, 122.67472284807081451, 36.441488904711150099, + 4.1317352113910601474, 16.756402787621482275, 56.614409347075707046, 118.57743346681309049, + 3.77787151590018766, 95.830660704199544853, 79.769770524195337202, 112.84632756012433674, + 20.93006171702654683, 22.264412417458515847, 66.63139009502629051, 126.52783662478032056, + 79.118060181408509379, 94.871796717434335733, 106.95371308362882701, 119.94631418316203053, + 22.774611722197732888, 94.930310380161245121, 82.491670046372746583, 41.207677085025352426, + 51.602252677614160348, 4.9771473860455444083, 99.509523599521344295, 70.340361706610565307, + 31.614628800136415521, 16.583234468180307886, 102.95729984965510084, 115.42061990610091016, + 119.39649281037054607, 121.83650285473413533, 109.92752805659984006, 53.215092392241786001, + 45.424272281306912191, 0.23242814349214313552, 79.768883710730733583, 99.756874029382743174, + 37.487688674686069135, 0, 39.132973968531587161, 117.48875923777450225, + 1.7139460561957093887, 16.890876744953857269, 29.37093914557408425, 55.142306939302216051, + 58.359386989348422503, 40.153416183769877534, 14.959203277903725393, 115.93176480366673786, + 93.463028539721562993, 28.037797443466843106, 9.7990523455882794224, 83.226388723673153436, + 113.46776038579992019, 127.88427731210322236, 76.031121703043027082, 53.627545473820646293, + 108.99069688237796072, 109.82741641105167218, 114.99733612901400193, 58.780943271114665549, + 103.62852853193908231, 74.295557971458038082, 88.561625392212590668, 96.199286447768827202, + 87.343286482675466686, 38.738487685674044769, 28.543136071610206272, 8.3968737942814186681, + 20.050904378287668806, 98.004727161667688051, 3.0118815538517083041, 58.549164662075781962, + 1.0970239360322011635, 112.8513712421990931, 73.328534015385230305, 11.586374692076788051, + 104.60221690699472674, 122.59369063865960925, 63.101380907330167247, 100.9746575271092297, + 6.4777507088692800608, 23.742794902947935043, 46.342101628946693381, 113.13111093550469377, + 13.372281711290270323, 52.754103442443010863, 10.35471420778776519, 44.292298604446841637, + 58.000374614039174048, 11.361219805115979398, 88.011987441819655942, 52.592402746278821724, + 38.995237045688554645, 66.56228406463196734, 78.696623547115450492, 7.7742535489778674673, + 78.164774690638296306, 54.459210284323489759, 62.348039849737688201, 86.138005895798414713, + 96.013204469338234048, 56.406200795820041094, 15.199961411912227049, 127.72969865610502893, + 110.79011653745328658, 24.187403884068771731, 120.2878936906272429, 93.843232564213394653, + 107.07158635673476965, 11.295442141872626962, 44.441793762853194494, 110.18964718981078477, + 33.500721826192602748, 86.968842328707978595, 115.06475973368287669, 3.3576501309144077823, + 21.743608700206095818, 41.137902990769362077, 110.8325376416069048, 102.08853545800229767, + 105.20178063494313392, 31.866563853029219899, 28.257370696312136715, 10.353709205479390221, + 109.92365680482544121, 127.82711829003164894, 96.574751208208908793, 109.61201730429456802, + 26.763747189692367101, 5.0371269475472217891, 22.135957845992379589, 72.569126960606809007, + 96.084602034803538118, 36.64165258219873067, 95.001560810826049419, 108.90257763145928038, + 1.8900380021404998843, 74.242948830451496178, 25.951386308362998534, 46.950272298432537355, + 81.060120907601231011, 84.73062569571993663, 25.241068513663776685, 10.465362457260198426, + 45.587441693278378807, 120.61841407231622725, 36.736927280016971054, 98.590600575302232755, + 49.026549093858193373, 118.93289811203430872, 82.201678825680573937, 37.847099384744069539, + 19.794804238503274973, 78.364223897759075044, 0.032721236406359821558, 75.347384248081652913, + 72.8764180253710947, 90.963286868711293209, 36.216667849526857026, 105.28490311542191193, + 34.654844527507520979, 76.898561452278954675, 43.262170015357696684, 93.013141661773261148, + 48.645176572736090748, 16.860403162609145511, 36.09855116482503945, 71.081648186864185845, + 2.0706608244981907774, 53.349688008842349518, 58.50053303545792005, 52.771345740176911931, + 48.936239791863044957, 28.455652615681174211, 102.38736023537421715, 46.160287713752040872, + 32.891990499578241725, 37.007291558253200492, 25.24951203250020626, 106.28812254915828817, + 12.564387497233838076, 126.56235224338888656, 67.027086293510365067, 83.598278466113697505, + 79.430396541501977481, 10.803793437797139632, 100.60941818741412135, 16.847290973993949592, + 13.537109099779627286, 64.882207953447505133, 82.692839008024748182, 24.611264467472210526, + 9.8970383951818803325, 125.67863361740091932, 93.314946262446028413, 9.4629423737569595687, + 97.137977709357073763, 105.27750471018225653, 118.84193534733276465, 92.15176055646588793, + 46.677750020757230232, 125.73441142217052402, 92.787283434910932556, 57.08252026786794886, + 123.09598342549361405, 55.103869034723174991, 27.826588925738178659, 73.16684747809995315, + 60.774228995880548609, 20.636139748381538084, 101.36348638140407274, 95.631561330279510003, + 97.549952303728787228, 23.706078806655568769, 43.170371987824182725, 31.588611358627531445, + 63.149663985084771411, 125.63710817386163399, 32.191769655593816424, 89.643359992442128714, + 106.87978594683954725, 9.2288050835086323787, 17.599812833668693202, 6.3319451876741368324, + 30.492547687306796433, 93.743297644625272369, 91.565373099689168157, 70.884497583123447839, + 125.91811105398664949, 107.07387701683546766, 103.73069008639504318, 95.105897521778388182, + 111.35753944913085434, 40.091766186102177016, 49.498129179559327895, 93.735782589264999842, + 90.01551735933026066, 108.65979901291575516, 87.501124014728702605, 69.482105423365283059, + 125.00230872996689868, 3.6664681635702436324, 89.314707841196650406, 92.991790473191940691, + 113.24889857637390378, 91.577921158110257238, 64.121257261136634042, 120.49927448539528996, + 102.80766369037519326, 58.684866665378649486, 27.450873958699958166, 21.358386116295150714, + 112.51116788582658046, 55.112633025091781747, 56.393987989165907493, 86.796785357011685846, + 72.843921764451806666, 17.858527452823182102, 20.136318820303131361, 112.87631863386195619, + 83.152018194778065663, 84.480770397345622769, 55.038850318367622094, 18.907657333140377887, + 108.39555796563217882, 53.173744707779405871, 55.137885794036264997, 39.50004650215851143, + 17.703516599536669673, 20.512917208521685097, 46.592307856863044435, 61.629349464517872548, + 3.7156902661845379043, 96.408975070924498141, 64.729148069396615028, 39.937812776774080703, + 124.17384925895748893, 6.3573452300988719799, 126.92717091496888315, 72.592772435476945248, + 61.497842719036270864, 42.041299265125417151, 125.90529517895265599, 87.585082325455005048, + 33.706165554911422078, 94.573318262195243733, 28.25000860687578097, 109.84026228930088109, + 106.75583093114983058, 90.756842325470643118, 102.5235225117430673, 81.058519289697869681, + 82.653821253836213145, 3.0075597826362354681, 34.939408579699374968, 12.677308991213067202, + 60.785059975740296068, 76.436377578858810011, 38.635799299714562949, 105.07755948515114142, + 87.284225988183607114, 85.343123870690760668, 73.215554674727172824, 84.253481142637610901, + 15.534238098727655597, 124.95986858732794644, 17.674003492807969451, 8.5540771415471681394, + 77.847163563623325899, 34.303977367184415925, 86.710185492116579553, 55.140237874446029309, + 83.624751979092252441, 110.69698072973915259, 56.428086349231307395, 116.37692103042354574, + 14.521524526528082788, 98.024682639246748295, 20.502857048031728482, 111.8744957645831164, + 108.99099968090740731, 46.432174631845555268, 33.23928154154054937, 113.21395232310896972, + 27.088700682354101446, 51.237154262329568155, 43.717844670274644159, 60.912530067704210524, + 84.737658997179096332, 51.092839390734297922, 111.87364264807183645, 14.173933179310552077, + 29.207864737658383092, 59.746655745784664759, 28.592316663914971286, 13.569102274272154318, + 84.585810674438107526, 97.176099964955938049, 118.37919085534667829, 42.838970219272596296, + 33.465057569686905481, 85.646505868928215932, 41.12316183734947117, 27.372304722608532757, + 91.470365373512322549, 51.09170675829591346, 108.86113354414919741, 18.719112968850822654, + 12.216964496488799341, 13.266616545879514888, 56.933327560967882164, 17.542791530981048709, + 47.901171741468715481, 112.08263770527264569, 127.87577375485489029, 101.2114644727371342, + 39.10770302763194195, 33.331552150291827274, 115.89578286764299264, 19.224867670465755509, + 16.042295539002225269, 105.88329922108096071, 65.713131762240664102, 33.291053481818380533, + 115.10772562275087694, 31.441067905405361671, 117.70287793855459313, 125.27310600683631492, + 117.34944569614162901, 72.882977809422300197, 8.2634704227821202949, 33.512805575242964551, + 113.22881869415505207, 109.15486693362618098, 7.5557430318040132988, 63.661321408402727684, + 31.539541048394312384, 97.692655120248673484, 41.860123434053093661, 44.528824834920669673, + 5.2627801900562189985, 125.0556732495642791, 30.236120362820656737, 61.743593434872309444, + 85.907426167261291994, 111.89262836632406106, 45.549223444399103755, 61.86062076032612822, + 36.983340092745493166, 82.415354170050704852, 103.2045053552283207, 9.9542947720947267953, + 71.019047199046326568, 12.680723413221130613, 63.229257600272831041, 33.16646893636425375, + 77.914599699313839665, 102.84123981220545829, 110.79298562074473011, 115.67300570947190863, + 91.855056113199680112, 106.430184784483572, 90.848544562613824382, 0.46485628698792424984, + 31.537767421465105144, 71.513748058765486348, 74.975377349375776248, 0, + 78.265947937066812301, 106.97751847554900451, 3.4278921123914187774, 33.781753489907714538, + 58.741878291148168501, 110.2846138786044321, 116.71877397869684501, 80.306832367539755069, + 29.918406555811088765, 103.8635296073371137, 58.926057079443125986, 56.075594886933686212, + 19.598104691180196824, 38.45277744734994485, 98.935520771603478352, 127.76855462421008269, + 24.062243406086054165, 107.25509094764493057, 89.981393764759559417, 91.654832822106982348, + 101.99467225802800385, 117.56188654223296908, 79.257057063881802605, 20.591115942919714143, + 49.123250784428819316, 64.398572895541292382, 46.686572965350933373, 77.476975371348089539, + 57.086272143220412545, 16.793747588562837336, 40.10180875657897559, 68.009454323335376102, + 6.0237631077034166083, 117.09832932415156392, 2.1940478720680403057, 97.702742484401824186, + 18.657068030770460609, 23.172749384157214081, 81.204433813993091462, 117.1873812773192185, + 126.20276181466397247, 73.949315054218459409, 12.955501417738560122, 47.485589805895870086, + 92.684203257897024741, 98.262221871009387542, 26.744563422580540646, 105.50820688488602173, + 20.70942841557553038, 88.584597208893683273, 116.0007492280783481, 22.722439610235596774, + 48.023974883639311884, 105.18480549255764345, 77.990474091380747268, 5.1245681292675726581, + 29.393247094230900984, 15.548507097959372913, 28.329549381276592612, 108.91842056864697952, + 124.69607969947901438, 44.276011791600467404, 64.026408938676468097, 112.81240159164008219, + 30.399922823828092078, 127.45939731221369584, 93.580233074906573165, 48.374807768141181441, + 112.57578738125812379, 59.686465128430427285, 86.143172713469539303, 22.590884283745253924, + 88.883587525710026966, 92.379294379621569533, 67.001443652388843475, 45.937684657419595169, + 102.12951946736575337, 6.7153002618288155645, 43.487217400412191637, 82.275805981542362133, + 93.665075283217447577, 76.177070916008233326, 82.403561269886267837, 63.733127706058439799, + 56.514741392624273431, 20.70741841096241842, 91.847313609654520405, 127.65423658006693586, + 65.149502416421455564, 91.224034608589136042, 53.527494379384734202, 10.074253895094443578, + 44.271915691988397157, 17.138253921217255993, 64.169204069607076235, 73.283305164401099319, + 62.003121621655736817, 89.805155262918560766, 3.7800760042846377473, 20.485897660902992357, + 51.902772616725997068, 93.900544596868712688, 34.1202418152061, 41.46125139143987326, + 50.482137027327553369, 20.930724914520396851, 91.174883386560395593, 113.2368281446324545, + 73.473854560037580086, 69.181201150604465511, 98.053098187720024725, 109.86579622407225543, + 36.403357651361147873, 75.694198769488139078, 39.589608477010187926, 28.728447795518150087, + 0.065442472816357621923, 22.694768496166943805, 17.752836050745827379, 53.926573737422586419, + 72.433335699057352031, 82.569806230843823869, 69.309689055018679937, 25.797122904557909351, + 86.524340030719031347, 58.026283323546522297, 97.290353145472181495, 33.720806325218291022, + 72.197102329653716879, 14.163296373728371691, 4.1413216489963815548, 106.69937601768469904, + 117.0010660709158401, 105.54269148035382386, 97.872479583726089913, 56.911305231365986401, + 76.774720470748434309, 92.320575427504081745, 65.783980999156483449, 74.014583116506400984, + 50.499024065004050499, 84.576245098316576332, 25.12877499447131413, 125.12470448678141111, + 6.0541725870243681129, 39.196556932231032988, 30.860793083003954962, 21.607586875597917242, + 73.218836374828242697, 33.694581947987899184, 27.074218199562892551, 1.7644159068986482453, + 37.385678016049496364, 49.222528934944421053, 19.794076790367398644, 123.35726723480547662, + 58.629892524892056827, 18.925884747517557116, 66.275955418717785506, 82.555009420368151041, + 109.68387069466916728, 56.30352111293177586, 93.355500041518098442, 123.46882284434468602, + 57.574566869821865112, 114.1650405357395357, 118.1919668509872281, 110.20773806944634998, + 55.653177851479995297, 18.333694956199906301, 121.54845799176109722, 41.272279496766714146, + 74.726972762811783468, 63.263122660562657984, 67.099904607457574457, 47.412157613311137538, + 86.340743975648365449, 63.177222717255062889, 126.2993279701731808, 123.27421634772326797, + 64.383539311191270826, 51.286719984887895407, 85.759571893679094501, 18.457610167017264757, + 35.199625667337386403, 12.663890375348273665, 60.985095374617230846, 59.486595289254182717, + 55.130746199381974293, 13.768995166250533657, 123.83622210797693697, 86.147754033674573293, + 79.461380172793724341, 62.211795043560414342, 94.715078898261708673, 80.183532372204354033, + 98.996258359122293768, 59.471565178533637663, 52.0310347186641593, 89.319598025835148292, + 47.002248029461043188, 10.964210846734204097, 122.00461745993379736, 7.3329363271441252436, + 50.629415682396938791, 57.983580946387519361, 98.497797152751445537, 55.155842316224152455, + 0.24251452227690606378, 112.99854897079421789, 77.61532738075038651, 117.36973333075729897, + 54.901747917399916332, 42.716772232593939407, 97.022335771653160919, 110.22526605018356349, + 112.78797597833545296, 45.593570714027009672, 17.687843528903613333, 35.717054905646364205, + 40.2726376406099007, 97.752637267727550352, 38.304036389559769304, 40.961540794691245537, + 110.07770063673524419, 37.815314666284393752, 88.791115931264357641, 106.34748941555881174, + 110.27577158807252999, 79.00009300431702286, 35.407033199073339347, 41.025834417043370195, + 93.18461571372608887, 123.2586989290357451, 7.4313805323727137875, 64.81795014185263426, + 1.4582961387932300568, 79.875625553551799385, 120.34769851791497786, 12.714690460201381939, + 125.85434182994140428, 17.185544870953890495, 122.99568543807254173, 84.08259853025447228, + 123.81059035790894995, 47.170164650910010096, 67.412331109826482134, 61.146636524390487466, + 56.500017213755199919, 91.680524578605400166, 85.511661862303299131, 53.513684650944924215, + 77.047045023489772575, 34.11703857939937734, 37.307642507672426291, 6.0151195652724709362, + 69.878817159398749936, 25.354617982426134404, 121.57011995148423011, 24.872755157717620023, + 77.271598599432763876, 82.155118970305920811, 46.568451976370852208, 42.686247741385159316, + 18.431109349457983626, 40.506962285275221802, 31.068476197458949173, 121.91973717465589289, + 35.348006985615938902, 17.108154283097974258, 27.694327127246651798, 68.607954734372469829, + 45.420370984233159106, 110.2804757488956966, 39.24950395818814286, 93.393961459478305187, + 112.85617269846625277, 104.75384206084709149, 29.043049053059803555, 68.049365278493496589, + 41.005714096067094943, 95.748991529169870773, 89.98199936181481462, 92.864349263691110536, + 66.478563083084736718, 98.427904646217939444, 54.177401364708202891, 102.47430852465913631, + 87.435689340549288318, 121.82506013541205903, 41.475317994358192664, 102.18567878147223382, + 95.747285296143672895, 28.347866358621104155, 58.415729475316766184, 119.49331149156932952, + 57.184633327829942573, 27.138204548547946615, 41.171621348879853031, 66.352199929915514076, + 108.75838171069335658, 85.677940438545192592, 66.930115139377448941, 43.293011737856431864, + 82.246323674698942341, 54.744609445220703492, 54.940730747024645098, 102.1834135165954649, + 89.72226708829839481, 37.438225937701645307, 24.433928992977598682, 26.533233091759029776, + 113.86665512193576433, 35.085583061962097418, 95.802343482941068942, 96.165275410548929358, + 127.75154750971341855, 74.422928945474268403, 78.2154060552638839, 66.663104300587292528, + 103.79156573528598528, 38.449735340931511018, 32.084591078008088516, 83.766598442165559391, + 3.4262635244813282043, 66.582106963640399044, 102.21545124550175387, 62.882135810814361321, + 107.40575587711282424, 122.54621201367626782, 106.69889139228689601, 17.765955618844600394, + 16.52694084556424059, 67.025611150489567081, 98.457637388313742122, 90.309733867252361961, + 15.111486063608026598, 127.32264281680545537, 63.079082096792262746, 67.385310240497346967, + 83.720246868106187321, 89.057649669841339346, 10.525560380116075976, 122.11134649912855821, + 60.472240725641313475, 123.48718686974825687, 43.814852334526221966, 95.785256732648122124, + 91.09844688879820751, 123.72124152065225644, 73.966680185494624311, 36.830708340105047682, + 78.409010710456641391, 19.908589544193091569, 14.038094398092653137, 25.361446826442261226, + 126.45851520054566208, 66.332937872732145479, 27.829199398631317308, 77.682479624414554564, + 93.585971241493098205, 103.34601141894745524, 55.710112226402998203, 84.860369568970781984, + 53.697089125227648765, 0.92971257397584849969, 63.075534842933848267, 15.027496117534610676, + 21.950754698755190475, 0, 28.531895874137262581, 85.955036951098009013, + 6.8557842247828375548, 67.563506979815429077, 117.48375658229997498, 92.569227757212502183, + 105.43754795739732799, 32.613664735079510137, 59.836813111625815509, 79.727059214674227405, + 117.85211415888625197, 112.15118977386737242, 39.196209382360393647, 76.90555489470352768, + 69.871041543210594682, 127.53710924842016539, 48.124486812175746309, 86.51018189529349911, + 51.962787529522756813, 55.309665644217602676, 75.989344516059645684, 107.12377308446957613, + 30.514114127763605211, 41.182231885839428287, 98.24650156886127661, 0.79714579108258476481, + 93.373145930705504725, 26.953950742696179077, 114.17254428644082509, 33.587495177125674672, + 80.203617513161589159, 8.018908646670752205, 12.047526215410471195, 106.19665864830312785, + 4.3880957441397185903, 67.405484968803648371, 37.314136061540921219, 46.345498768318066141, + 34.408867627989820903, 106.37476255464207497, 124.40552362933158292, 19.898630108436918817, + 25.911002835477120243, 94.97117961179537815, 57.368406515797687462, 68.524443742018775083, + 53.489126845164719271, 83.016413769772043452, 41.418856831154698739, 49.169194417791004525, + 104.00149845615669619, 45.444879220471193548, 96.047949767282261746, 82.369610985118924873, + 27.980948182761494536, 10.249136258535145316, 58.786494188461801969, 31.097014195918745827, + 56.659098762556823203, 89.836841137297597015, 121.39215939895802876, 88.552023583204572788, + 0.052817877356574172154, 97.624803183280164376, 60.799845647659822134, 126.91879462443102966, + 59.16046614981314633, 96.749615536286000861, 97.151574762516247574, 119.37293025686449255, + 44.286345426939078607, 45.181768567494145827, 49.767175051423691912, 56.758588759246777045, + 6.0028873047776869498, 91.875369314842828317, 76.259038934731506743, 13.430600523657631129, + 86.974434800828021253, 36.551611963088362245, 59.330150566438533133, 24.35414183202010463, + 36.807122539772535674, 127.4662554121168796, 113.02948278524854686, 41.414836821928474819, + 55.69462721931267879, 127.30847316013750969, 2.2990048328465491068, 54.448069217178272083, + 107.0549887587694684, 20.148507790188887157, 88.543831383976794314, 34.276507842438149964, + 0.33840813921779044904, 18.566610328802198637, 124.00624324331511161, 51.610310525837121531, + 7.5601520085692754947, 40.971795321805984713, 103.80554523345563211, 59.801089193737425376, + 68.2404836304122, 82.922502782879746519, 100.96427405465510674, 41.861449829044431681, + 54.349766773124429164, 98.473656289268546971, 18.947709120078798151, 10.362402301212569, + 68.10619637544368743, 91.731592448144510854, 72.806715302725933725, 23.388397538976278156, + 79.179216954020375852, 57.456895591036300175, 0.13088494563271524385, 45.389536992333887611, + 35.505672101491654757, 107.85314747484881082, 16.86667139811834204, 37.139612461691285716, + 10.619378110037359875, 51.59424580911945668, 45.048680061438062694, 116.05256664709668257, + 66.580706290944362991, 67.441612650440220023, 16.394204659307433758, 28.326592747456743382, + 8.2826432979964010883, 85.398752035373036051, 106.00213214183531818, 83.085382960711285705, + 67.744959167452179827, 113.82261046273561078, 25.549440941500506597, 56.641150855011801468, + 3.5679619983166048769, 20.029166233012801968, 100.99804813001173898, 41.152490196633152664, + 50.25754998894626624, 122.24940897356282221, 12.108345174048736226, 78.393113864462065976, + 61.721586166007909924, 43.215173751199472463, 18.437672749656485394, 67.389163895975798368, + 54.148436399125785101, 3.5288318137972964905, 74.771356032098992728, 98.445057869888842106, + 39.588153580738435267, 118.71453446961095324, 117.25978504978411365, 37.851769495038752211, + 4.55191083743920899, 37.11001884073994006, 91.367741389338334557, 112.6070422258671897, + 58.711000083039834863, 118.93764568868937204, 115.1491337396473682, 100.33008107148270938, + 108.38393370197809418, 92.415476138892699964, 111.30635570295999059, 36.66738991240345058, + 115.09691598352219444, 82.544558993537066272, 21.453945525623566937, 126.52624532112895395, + 6.1998092149151489139, 94.824315226625913056, 44.681487951296730898, 126.35444543451376376, + 124.59865594034999958, 118.54843269545017392, 0.76707862238254165277, 102.57343996977942879, + 43.519143787358189002, 36.915220334034529515, 70.399251334674772806, 25.327780750696547329, + 121.97019074923446169, 118.97319057850836543, 110.26149239876394859, 27.537990332504705293, + 119.67244421595751191, 44.295508067352784565, 30.922760345587448683, 124.42359008712446666, + 61.430157796527055325, 32.367064744412346045, 69.992516718244587537, 118.94313035706727533, + 104.06206943733195658, 50.639196051670296583, 94.004496058922086377, 21.928421693472046172, + 116.00923491986759473, 14.665872654288250487, 101.25883136479387758, 115.9671618927786767, + 68.995594305502891075, 110.31168463244830491, 0.48502904455745010637, 97.997097941592073767, + 27.230654761504410999, 106.73946666151459794, 109.80349583479983266, 85.433544465191516792, + 66.044671543309959816, 92.450532100370764965, 97.575951956670905929, 91.187141428054019343, + 35.375687057807226665, 71.434109811292728409, 80.545275281223439379, 67.505274535455100704, + 76.608072779119538609, 81.923081589386129053, 92.155401273470488377, 75.630629332572425483, + 49.582231862532353261, 84.694978831121261464, 92.551543176148697967, 30.00018600863404572, + 70.814066398146678694, 82.051668834090378368, 58.369231427455815719, 118.51739785807149019, + 14.862761064749065554, 1.6359002837052685209, 2.9165922775900980923, 31.751251107107236749, + 112.69539703582995571, 25.429380920406401856, 123.70868365988280857, 34.371089741911418969, + 117.99137087614872144, 40.165197060512582539, 119.62118071581789991, 94.34032930182365817, + 6.8246622196529642679, 122.29327304878097493, 113.00003442751403782, 55.36104915721443831, + 43.023323724606598262, 107.02736930189348641, 26.09409004697954515, 68.234077158798754681, + 74.615285015344852582, 12.030239130548579851, 11.757634318797499873, 50.709235964855906786, + 115.14023990296846023, 49.745510315438878024, 26.543197198869165732, 36.310237940611841623, + 93.136903952741704416, 85.372495482770318631, 36.862218698915967252, 81.013924570550443605, + 62.136952394921536325, 115.83947434931178577, 70.696013971231877804, 34.216308566195948515, + 55.388654254496941576, 9.2159094687449396588, 90.840741968469956191, 92.560951497791393194, + 78.499007916379923699, 58.787922918960248353, 97.712345396936143516, 81.507684121694182977, + 58.086098106123245088, 8.0987305569869931787, 82.011428192137827864, 63.497983058343379525, + 51.963998723633267218, 57.728698527385859052, 4.9571261661731114145, 68.855809292435878888, + 108.35480272942004376, 76.948617049321910599, 46.871378681102214614, 115.65012027082411805, + 82.950635988720023306, 76.371357562948105624, 63.494570592287345789, 56.695732717242208309, + 116.83145895063717035, 110.98662298313865904, 114.36926665565988515, 54.27640909709589323, + 82.34324269776334404, 4.7043998598346661311, 89.516763421390351141, 43.355880877094023162, + 5.8602302787548978813, 86.586023475716501707, 36.492647349397884682, 109.48921889044140698, + 109.88146149405292817, 76.366827033194567775, 51.444534176596789621, 74.876451875403290614, + 48.867857985955197364, 53.066466183521697531, 99.733310243871528655, 70.171166123927832814, + 63.604686965885775862, 64.330550821101496695, 127.50309501943047508, 20.845857890952174785, + 28.430812110531405779, 5.3262086011782230344, 79.583131470571970567, 76.899470681863022037, + 64.169182156019815011, 39.533196884331118781, 6.8525270489662943874, 5.1642139272844360676, + 76.430902491003507748, 125.76427162163236062, 86.811511754229286453, 117.09242402735617361, + 85.397782784573792014, 35.531911237689200789, 33.053881691132119158, 6.0512223009827721398, + 68.915274776631122222, 52.619467734504723921, 30.222972127219691174, 126.64528563361091074, + 126.15816419358816347, 6.7706204809983319137, 39.440493736216012621, 50.115299339682678692, + 21.05112076023578993, 116.22269299825711641, 120.94448145128626493, 118.97437373949651374, + 87.629704669056081912, 63.570513465299882228, 54.196893777600052999, 119.44248304130815086, + 19.933360370989248622, 73.661416680213733343, 28.818021420913282782, 39.817179088386183139, + 28.076188796185306273, 50.722893652888160432, 124.91703040109496214, 4.6658757454642909579, + 55.658398797266272595, 27.364959248832747107, 59.171942482989834389, 78.692022837894910481, + 111.42022445280963439, 41.720739137941563968, 107.39417825045529753, 1.8594251479516969994, + 126.15106968586769653, 30.054992235069221351, 43.901509397514018929, 0, + 57.063791748278163141, 43.910073902196018025, 13.711568449569313088, 7.1270139596344961319, + 106.96751316460358794, 57.138455514428642346, 82.875095914794655982, 65.227329470159020275, + 119.673626223255269, 31.454118429352092789, 107.70422831777614192, 96.302379547734744847, + 78.392418764724425273, 25.811109789410693338, 11.742083086424827343, 127.07421849684033077, + 96.248973624355130596, 45.020363790586998221, 103.92557505904551363, 110.61933128843884333, + 23.978689032122929348, 86.247546168939152267, 61.028228255527210422, 82.364463771682494553, + 68.49300313772255322, 1.5942915821688075084, 58.74629186141100945, 53.907901485395996133, + 100.34508857288165018, 67.174990354254987324, 32.407235026323178317, 16.03781729334150441, + 24.09505243082458037, 84.393317296606255695, 8.7761914882830751594, 6.8109699376072967425, + 74.628272123081842437, 92.690997536636132281, 68.817735255983279785, 84.749525109287787927, + 120.81104725866316585, 39.797260216873837635, 51.822005670957878465, 61.942359223590756301, + 114.7368130315990129, 9.0488874840375501662, 106.97825369033307652, 38.032827539544086903, + 82.837713662309397478, 98.33838883558564703, 80.002996912313392386, 90.889758440946025075, + 64.095899534568161471, 36.739221970237849746, 55.961896365522989072, 20.498272517070290633, + 117.57298837692360394, 62.194028391837491654, 113.31819752511728439, 51.673682274598832009, + 114.7843187979196955, 49.104047166409145575, 0.10563575471678632312, 67.249606366560328752, + 121.59969129532328225, 125.83758924886205932, 118.32093229962993064, 65.499231072575639701, + 66.303149525036133127, 110.7458605137289851, 88.572690853878157213, 90.363537134988291655, + 99.534350102847383823, 113.51717751849355409, 12.005774609559011878, 55.750738629689294612, + 24.518077869463013485, 26.861201047318900237, 45.948869601656042505, 73.10322392617672449, + 118.66030113287706627, 48.70828366404020926, 73.614245079548709327, 126.93251082423739717, + 98.058965570497093722, 82.829673643856949639, 111.38925443862899556, 126.61694632027501939, + 4.5980096656930982135, 108.89613843436018215, 86.109977517538936809, 40.297015580381412292, + 49.087662767953588627, 68.553015684876299929, 0.67681627843558089808, 37.133220657608035253, + 120.01248648663022323, 103.22062105167424306, 15.120304017138550989, 81.943590643615607405, + 79.61109046691126423, 119.60217838747848873, 8.4809672608280379791, 37.845005565763131017, + 73.928548109310213476, 83.722899658088863362, 108.69953354625249631, 68.947312578537093941, + 37.895418240157596301, 20.724804602428775979, 8.2123927508910128381, 55.463184896292659687, + 17.61343060545186745, 46.776795077956194291, 30.358433908040751703, 114.91379118207260035, + 0.26176989126543048769, 90.779073984667775221, 71.011344202986947494, 87.706294949697621632, + 33.73334279623668408, 74.279224923382571433, 21.238756220074719749, 103.18849161823891336, + 90.097360122879763367, 104.10513329419700312, 5.1614125818923639599, 6.8832253008804400451, + 32.788409318614867516, 56.653185494913486764, 16.565286595996440155, 42.797504070749710081, + 84.004264283674274338, 38.170765921426209388, 7.4899183349079976324, 99.645220925471221562, + 51.098881883001013193, 113.28230171002360294, 7.1359239966332097538, 40.058332466029241914, + 73.996096260023477953, 82.304980393266305327, 100.51509997789617046, 116.49881794712564442, + 24.21669034810111043, 28.786227728924131952, 123.44317233201581985, 86.430347502398944926, + 36.875345499316608766, 6.7783277919515967369, 108.2968727982515702, 7.0576636275982309598, + 21.542712064201623434, 68.890115739777684212, 79.176307161480508512, 109.42906893922554445, + 106.51957009956822731, 75.703538990077504423, 9.1038216748784179799, 74.220037681483518099, + 54.735482778680307092, 97.2140844517343794, 117.4220001660833077, 109.87529137738238205, + 102.29826747929837438, 72.660162142969056731, 88.767867403959826333, 56.830952277789037907, + 94.612711405919981189, 73.334779824810539139, 102.19383196704802685, 37.089117987074132543, + 42.907891051250771852, 125.05249064225790789, 12.399618429833935807, 61.648630453251826111, + 89.362975902597099775, 124.70889086903116549, 121.19731188070363714, 109.09686539090034785, + 1.5341572447687212843, 77.146879939558857586, 87.038287574716378003, 73.830440668072697008, + 12.798502669349545613, 50.655561501396732638, 115.94038149847256136, 109.94638115702036885, + 92.522984797527897172, 55.075980665013048565, 111.34488843191502383, 88.591016134705569129, + 61.845520691178535344, 120.84718017424893333, 122.86031559305411065, 64.734129488828330068, + 11.985033436492813053, 109.88626071413818863, 80.124138874663913157, 101.27839210334423115, + 60.008992117844172753, 43.856843386947730323, 104.01846983973518945, 29.331745308580138953, + 74.517662729591393145, 103.93432378556099138, 9.9911886110094201285, 92.62336926489660982, + 0.97005808911853819154, 67.994195883184147533, 54.461309523012459977, 85.478933323032833869, + 91.606991669603303308, 42.867088930386671564, 4.0893430866235576104, 56.901064200745167909, + 67.151903913345449837, 54.374282856108038686, 70.751374115618091309, 14.868219622589094797, + 33.090550562450516736, 7.0105490709138393868, 25.216145558242715197, 35.846163178775896085, + 56.310802546944614733, 23.261258665144850966, 99.164463725068344502, 41.389957662246160908, + 57.103086352297395933, 60.000372017271729419, 13.628132796296995366, 36.103337668180756737, + 116.73846285491526942, 109.03479571614298038, 29.725522129498131108, 3.2718005674105370417, + 5.8331845551801961847, 63.502502214218111476, 97.390794071659911424, 50.858761840816441691, + 119.41736731976561714, 68.742179483826475916, 107.98274175229744287, 80.330394121028803056, + 111.2423614316394378, 60.68065860364731634, 13.649324439309566515, 116.58654609756558784, + 98.000068855028075632, 110.72209831442887662, 86.046647449216834502, 86.054738603786972817, + 52.188180093962728279, 8.4681543176011473406, 21.230570030689705163, 24.060478261097159702, + 23.515268637594999745, 101.41847192971545155, 102.28047980593692046, 99.491020630877756048, + 53.086394397738331463, 72.620475881227321224, 58.27380790548704681, 42.744990965540637262, + 73.724437397835572483, 34.027849141100887209, 124.27390478984671063, 103.67894869862720952, + 13.392027942463755608, 68.43261713239189703, 110.77730850899388315, 18.431818937493517296, + 53.681483936943550361, 57.121902995586424368, 28.998015832759847399, 117.57584583792413468, + 67.42469079387592501, 35.015368243388365954, 116.17219621224649018, 16.197461113977624336, + 36.022856384275655728, 126.99596611668675905, 103.92799744726653444, 115.4573970547717181, + 9.9142523323498608079, 9.7116185848753957544, 88.709605458843725501, 25.897234098643821198, + 93.742757362208067207, 103.30024054165187408, 37.901271977443684591, 24.742715125896211248, + 126.98914118457469158, 113.3914654344880546, 105.66291790127797867, 93.973245966280956054, + 100.73853331131977029, 108.55281819419542444, 36.68648539552668808, 9.4087997196729702409, + 51.033526842780702282, 86.711761754188046325, 11.720460557513433741, 45.172046951433003414, + 72.985294698799407342, 90.978437780886451947, 91.762922988109494327, 24.733654066389135551, + 102.88906835319721722, 21.752903750806581229, 97.735715971910394728, 106.13293236704703304, + 71.466620487746695289, 12.342332247855665628, 127.2093739317751897, 0.66110164220663136803, + 127.00619003886095015, 41.691715781904349569, 56.861624221062811557, 10.652417202360084048, + 31.166262941147579113, 25.798941363729682053, 0.3383643120396300219, 79.066393768662237562, + 13.705054097932588775, 10.328427854572510114, 24.861804982010653475, 123.52854324326835922, + 45.623023508462210884, 106.1848480547159852, 42.795565569147584029, 71.063822475378401577, + 66.107763382264238317, 12.102444601969182258, 9.8305495532622444443, 105.23893546900944784, + 60.445944254443020327, 125.29057126722545945, 124.31632838717632694, 13.541240961996663827, + 78.880987472432025243, 100.23059867936535738, 42.10224152047521784, 104.44538599651787081, + 113.88896290257616783, 109.94874747899666545, 47.259409338112163823, 127.14102693059976446, + 108.39378755520374398, 110.88496608261630172, 39.866720741982135223, 19.322833360427466687, + 57.636042841826565564, 79.634358176772366278, 56.152377592370612547, 101.44578730577995884, + 121.83406080218992429, 9.3317514909285819158, 111.31679759453254519, 54.729918497665494215, + 118.34388496598330676, 29.38404567579345894, 94.840448905619268771, 83.441478275886765914, + 86.788356500910595059, 3.7188502959070319775, 124.30213937173539307, 60.109984470138442703, + 87.803018795028037857, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + +}; diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/quad/sleefquad_footer.h.org b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/quad/sleefquad_footer.h.org new file mode 100644 index 00000000000..8f52779ac49 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/quad/sleefquad_footer.h.org @@ -0,0 +1,112 @@ + +// + +#if defined(SLEEF_REPLACE_LIBQUADMATH_FUNCS) + +#ifdef SLEEF_QUAD_C + +#define M_Eq SLEEF_QUAD_C(+0x1.5bf0a8b1457695355fb8ac404e7ap+1) +#define M_LOG2Eq SLEEF_QUAD_C(+0x1.71547652b82fe1777d0ffda0d23ap+0) +#define M_LOG10Eq SLEEF_QUAD_C(+0x1.bcb7b1526e50e32a6ab7555f5a68p-2) +#define M_LN2q SLEEF_QUAD_C(+0x1.62e42fefa39ef35793c7673007e6p-1) +#define M_LN10q SLEEF_QUAD_C(+0x1.26bb1bbb5551582dd4adac5705a6p+1) +#define M_PIq SLEEF_QUAD_C(+0x1.921fb54442d18469898cc51701b8p+1) +#define M_PI_2q SLEEF_QUAD_C(+0x1.921fb54442d18469898cc51701b8p+0) +#define M_PI_4q SLEEF_QUAD_C(+0x1.921fb54442d18469898cc51701b8p-1) +#define M_1_PIq SLEEF_QUAD_C(+0x1.45f306dc9c882a53f84eafa3ea6ap-2) +#define M_2_PIq SLEEF_QUAD_C(+0x1.45f306dc9c882a53f84eafa3ea6ap-1) +#define M_2_SQRTPIq SLEEF_QUAD_C(+0x1.20dd750429b6d11ae3a914fed7fep+0) +#define M_SQRT2q SLEEF_QUAD_C(+0x1.6a09e667f3bcc908b2fb1366ea95p+0) +#define M_SQRT1_2q SLEEF_QUAD_C(+0x1.6a09e667f3bcc908b2fb1366ea95p-1) +#define FLT128_MAX SLEEF_QUAD_C(+0x1.ffffffffffffffffffffffffffffp+16383) +#define FLT128_MIN SLEEF_QUAD_C(+0x1p-16382) +#define FLT128_EPSILON SLEEF_QUAD_C(+0x1p-112) +#define FLT128_DENORM_MIN SLEEF_QUAD_C(+0x0.0000000000000000000000000001p-16382) + +#else // #ifdef SLEEF_QUAD_C + +#define M_Eq sleef_q(+0x15bf0a8b14576LL, 0x95355fb8ac404e7aULL, 1) +#define M_LOG2Eq sleef_q(+0x171547652b82fLL, 0xe1777d0ffda0d23aULL, 0) +#define M_LOG10Eq sleef_q(+0x1bcb7b1526e50LL, 0xe32a6ab7555f5a68ULL, -2) +#define M_LN2q sleef_q(+0x162e42fefa39eLL, 0xf35793c7673007e6ULL, -1) +#define M_LN10q sleef_q(+0x126bb1bbb5551LL, 0x582dd4adac5705a6ULL, 1) +#define M_PIq sleef_q(+0x1921fb54442d1LL, 0x8469898cc51701b8ULL, 1) +#define M_PI_2q sleef_q(+0x1921fb54442d1LL, 0x8469898cc51701b8ULL, 0) +#define M_PI_4q sleef_q(+0x1921fb54442d1LL, 0x8469898cc51701b8ULL, -1) +#define M_1_PIq sleef_q(+0x145f306dc9c88LL, 0x2a53f84eafa3ea6aULL, -2) +#define M_2_PIq sleef_q(+0x145f306dc9c88LL, 0x2a53f84eafa3ea6aULL, -1) +#define M_2_SQRTPIq sleef_q(+0x120dd750429b6LL, 0xd11ae3a914fed7feULL, 0) +#define M_SQRT2q sleef_q(+0x16a09e667f3bcLL, 0xc908b2fb1366ea95ULL, 0) +#define M_SQRT1_2q sleef_q(+0x16a09e667f3bcLL, 0xc908b2fb1366ea95ULL, -1) +#define FLT128_MAX sleef_q(+0x1ffffffffffffLL, 0xffffffffffffffffULL, 16383) +#define FLT128_MIN sleef_q(+0x1000000000000LL, 0x0000000000000000ULL, -16382) +#define FLT128_EPSILON sleef_q(+0x1000000000000LL, 0x0000000000000000ULL, -112) +#define FLT128_DENORM_MIN sleef_q(+0x0000000000000LL, 0x0000000000000001ULL, -16382) + +#endif // #ifdef SLEEF_QUAD_C + +#define FLT128_MANT_DIG 113 +#define FLT128_MIN_EXP (-16381) +#define FLT128_MAX_EXP 16384 +#define FLT128_DIG 33 +#define FLT128_MIN_10_EXP (-4931) +#define FLT128_MAX_10_EXP 4932 + +#endif // #if defined(SLEEF_REPLACE_LIBQUADMATH_FUNCS) + +#ifdef __cplusplus +} // extern "C" + +namespace sleef { +#endif + +#if defined(SLEEF_REPLACE_LIBQUADMATH_FUNCS) || defined(__cplusplus) +static SLEEF_CONST Sleef_quad strtoflt128(const char *str, char **endptr) { return Sleef_strtoq(str, endptr); } +static SLEEF_CONST int quadmath_snprintf(char *str, size_t size, const char *fmt) { return Sleef_snprintf(str, size, fmt); } +static SLEEF_CONST Sleef_quad acosq(Sleef_quad x) { return Sleef_acosq1_u10(x); } +static SLEEF_CONST Sleef_quad acoshq(Sleef_quad x) { return Sleef_acoshq1_u10(x); } +static SLEEF_CONST Sleef_quad asinq(Sleef_quad x) { return Sleef_asinq1_u10(x); } +static SLEEF_CONST Sleef_quad asinhq(Sleef_quad x) { return Sleef_asinhq1_u10(x); } +static SLEEF_CONST Sleef_quad atanq(Sleef_quad x) { return Sleef_atanq1_u10(x); } +static SLEEF_CONST Sleef_quad atanhq(Sleef_quad x) { return Sleef_atanhq1_u10(x); } +static SLEEF_CONST Sleef_quad atan2q(Sleef_quad y, Sleef_quad x) { return Sleef_atan2q1_u10(y, x); } +static SLEEF_CONST Sleef_quad cbrtq(Sleef_quad x) { return Sleef_cbrtq1_u10(x); } +static SLEEF_CONST Sleef_quad ceilq(Sleef_quad x) { return Sleef_ceilq1(x); } +static SLEEF_CONST Sleef_quad copysignq(Sleef_quad x, Sleef_quad y) { return Sleef_copysignq1(x, y); } +static SLEEF_CONST Sleef_quad coshq(Sleef_quad x) { return Sleef_coshq1_u10(x); } +static SLEEF_CONST Sleef_quad cosq(Sleef_quad x) { return Sleef_cosq1_u10(x); } +static SLEEF_CONST Sleef_quad expq(Sleef_quad x) { return Sleef_expq1_u10(x); } +static SLEEF_CONST Sleef_quad expm1q(Sleef_quad x) { return Sleef_expm1q1_u10(x); } +static SLEEF_CONST Sleef_quad fabsq(Sleef_quad x) { return Sleef_fabsq1(x); } +static SLEEF_CONST Sleef_quad fdimq(Sleef_quad x, Sleef_quad y) { return Sleef_fdimq1_u05(x, y); } +static SLEEF_CONST Sleef_quad floorq(Sleef_quad x) { return Sleef_floorq1(x); } +static SLEEF_CONST Sleef_quad fmaq(Sleef_quad x, Sleef_quad y, Sleef_quad z) { return Sleef_fmaq1_u05(x, y, z); } +static SLEEF_CONST Sleef_quad fmaxq(Sleef_quad x, Sleef_quad y) { return Sleef_fmaxq1(x, y); } +static SLEEF_CONST Sleef_quad fminq(Sleef_quad x, Sleef_quad y) { return Sleef_fminq1(x, y); } +static SLEEF_CONST Sleef_quad fmodq(Sleef_quad x, Sleef_quad y) { return Sleef_fmodq1(x, y); } +static SLEEF_CONST Sleef_quad frexpq(Sleef_quad x, int *ptr) { return Sleef_frexpq1(x, ptr); } +static SLEEF_CONST Sleef_quad hypotq(Sleef_quad x, Sleef_quad y) { return Sleef_hypotq1_u05(x, y); } +static SLEEF_CONST int ilogbq(Sleef_quad x) { return Sleef_ilogbq1(x); } +static SLEEF_CONST Sleef_quad ldexpq(Sleef_quad x, int e) { return Sleef_ldexpq1(x, e); } +static SLEEF_CONST Sleef_quad logq(Sleef_quad x) { return Sleef_logq1_u10(x); } +static SLEEF_CONST Sleef_quad log10q(Sleef_quad x) { return Sleef_log10q1_u10(x); } +static SLEEF_CONST Sleef_quad log2q(Sleef_quad x) { return Sleef_log2q1_u10(x); } +static SLEEF_CONST Sleef_quad log1pq(Sleef_quad x) { return Sleef_log1pq1_u10(x); } +static SLEEF_CONST Sleef_quad modfq(Sleef_quad x, Sleef_quad *ptr) { return Sleef_modfq1(x, ptr); } +static SLEEF_CONST Sleef_quad powq(Sleef_quad x, Sleef_quad y) { return Sleef_powq1_u10(x, y); } +static SLEEF_CONST Sleef_quad remainderq(Sleef_quad x, Sleef_quad y) { return Sleef_remainderq1(x, y); } +static SLEEF_CONST Sleef_quad rintq(Sleef_quad x) { return Sleef_rintq1(x); } +static SLEEF_CONST Sleef_quad roundq(Sleef_quad x) { return Sleef_roundq1(x); } +static SLEEF_CONST Sleef_quad sinhq(Sleef_quad x) { return Sleef_sinhq1_u10(x); } +static SLEEF_CONST Sleef_quad sinq(Sleef_quad x) { return Sleef_sinq1_u10(x); } +static SLEEF_CONST Sleef_quad sqrtq(Sleef_quad x) { return Sleef_sqrtq1_u05(x); } +static SLEEF_CONST Sleef_quad tanq(Sleef_quad x) { return Sleef_tanq1_u10(x); } +static SLEEF_CONST Sleef_quad tanhq(Sleef_quad x) { return Sleef_tanhq1_u10(x); } +static SLEEF_CONST Sleef_quad truncq(Sleef_quad x) { return Sleef_truncq1(x); } + +#ifdef __cplusplus +} // namespace sleef +#endif +#endif // #if defined(SLEEF_REPLACE_LIBQUADMATH_FUNCS) || defined(__cplusplus) + +#endif // #ifndef __SLEEFQUAD_H__ diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/quad/sleefquad_header.h.org.in b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/quad/sleefquad_header.h.org.in new file mode 100644 index 00000000000..f38cd7eb79f --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/quad/sleefquad_header.h.org.in @@ -0,0 +1,247 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef __SLEEFQUAD_H__ +#define __SLEEFQUAD_H__ + +#define SLEEF_VERSION_MAJOR @SLEEF_VERSION_MAJOR@ +#define SLEEF_VERSION_MINOR @SLEEF_VERSION_MINOR@ +#define SLEEF_VERSION_PATCHLEVEL @SLEEF_VERSION_PATCH@ + +#include "sleef.h" +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + +#if (defined(__MINGW32__) || defined(__MINGW64__) || defined(__CYGWIN__) || defined(_MSC_VER)) && !defined(SLEEF_STATIC_LIBS) +#ifdef SLEEF_IMPORT_IS_EXPORT +#define SLEEF_IMPORT __declspec(dllexport) +#else // #ifdef SLEEF_IMPORT_IS_EXPORT +#define SLEEF_IMPORT __declspec(dllimport) +#if (defined(_MSC_VER)) +#pragma comment(lib,"sleefquad.lib") +#endif // #if (defined(_MSC_VER)) +#endif // #ifdef SLEEF_IMPORT_IS_EXPORT +#else // #if (defined(__MINGW32__) || defined(__MINGW64__) || defined(__CYGWIN__) || defined(_MSC_VER)) && !defined(SLEEF_STATIC_LIBS) +#define SLEEF_IMPORT +#endif // #if (defined(__MINGW32__) || defined(__MINGW64__) || defined(__CYGWIN__) || defined(_MSC_VER)) && !defined(SLEEF_STATIC_LIBS) + +// + +#if defined (__GNUC__) || defined (__clang__) || defined(__INTEL_COMPILER) +#define SLEEF_CONST __attribute__((const)) +#define SLEEF_INLINE __attribute__((always_inline)) +#elif defined(_MSC_VER) +#define SLEEF_CONST +#define SLEEF_INLINE __forceinline +#endif + +// + +#if (defined(__SIZEOF_FLOAT128__) && __SIZEOF_FLOAT128__ == 16) || (defined(__linux__) && defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))) || (defined(__PPC64__) && defined(__GNUC__) && !defined(__clang__) && __GNUC__ >= 8) +#define SLEEF_FLOAT128_IS_IEEEQP +#endif + +#if !defined(SLEEF_FLOAT128_IS_IEEEQP) && defined(__SIZEOF_LONG_DOUBLE__) && __SIZEOF_LONG_DOUBLE__ == 16 && (defined(__aarch64__) || defined(__zarch__)) +#define SLEEF_LONGDOUBLE_IS_IEEEQP +#endif + +#if !defined(Sleef_quad_DEFINED) +#define Sleef_quad_DEFINED +typedef struct { uint64_t x, y; } Sleef_uint64_2t; +#if defined(SLEEF_FLOAT128_IS_IEEEQP) +typedef __float128 Sleef_quad; +#define SLEEF_QUAD_C(x) (x ## Q) +#elif defined(SLEEF_LONGDOUBLE_IS_IEEEQP) +typedef long double Sleef_quad; +#define SLEEF_QUAD_C(x) (x ## L) +#else +typedef Sleef_uint64_2t Sleef_quad; +#endif +#endif + +// + +#if !defined(Sleef_quadx1_DEFINED) +#define Sleef_quadx1_DEFINED +typedef struct { + uint64_t x, y; +} Sleef_quadx1; +#endif + +#if !defined(Sleef_quadx2_DEFINED) + +#if defined(__SSE2__) +#define Sleef_quadx2_DEFINED +typedef struct { + __m128i x, y; +} Sleef_quadx2; +#endif + +#if defined(__aarch64__) +#define Sleef_quadx2_DEFINED +typedef struct { + uint32x4_t x, y; +} Sleef_quadx2; +#endif + +#if defined(__VSX__) +#define Sleef_quadx2_DEFINED +typedef struct { + __vector unsigned int x, y; +} Sleef_quadx2; +#endif + +#if defined(__VX__) && (defined(__VECTOR_KEYWORD_SUPPORTED__) || defined(__VEC__)) +#define Sleef_quadx2_DEFINED +typedef struct { + __vector unsigned long long x, y; +} Sleef_quadx2; +#endif + +#endif // #if !defined(Sleef_quadx2_DEFINED) + +#if !defined(Sleef_rvvm1quad_DEFINED) +#if defined(__riscv) && defined(__riscv_v) +#define Sleef_rvvm1quadDEFINED +typedef vuint64m1x2_t Sleef_rvvm1quad; +#endif +#endif + +#if !defined(Sleef_rvvm2quad_DEFINED) +#if defined(__riscv) && defined(__riscv_v) +#define Sleef_rvvm2quadDEFINED +typedef vuint64m2x2_t Sleef_rvvm2quad; +#endif +#endif + +#if !defined(Sleef_quadx4_DEFINED) +#if defined(__AVX__) +#define Sleef_quadx4_DEFINED +typedef struct { + __m256i x, y; +} Sleef_quadx4; +#endif +#endif + +#if !defined(Sleef_quadx8_DEFINED) +#if defined(__AVX512F__) +#define Sleef_quadx8_DEFINED +typedef struct { + __m512i x, y; +} Sleef_quadx8; +#endif +#endif + +#if !defined(Sleef_svquad_DEFINED) +#if defined(__ARM_FEATURE_SVE) +#define Sleef_svquad_DEFINED +typedef svfloat64x2_t Sleef_svquad; +#endif +#endif + +// + +#if !defined(SLEEF_Q_DEFINED) +#define SLEEF_Q_DEFINED +static inline Sleef_quad sleef_q(int64_t H, uint64_t L, int E) { +#if defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) + struct { uint64_t h, l; } c; +#else + struct { uint64_t l, h; } c; +#endif + c.h = (((int64_t)(H) < 0 ? 1ULL : 0ULL) << 63) | + ((0x7fff & (uint64_t)((E) + 16383)) << 48) | + ((int64_t)(H) < 0 ? -(int64_t)(H) : (int64_t)(H) & 0xffffffffffffULL); + c.l = (uint64_t)(L); + + Sleef_quad q; + memcpy(&q, &c, 16); + return q; +} +#endif + +// + +#ifdef SLEEF_QUAD_C + +#define SLEEF_M_Eq SLEEF_QUAD_C(+0x1.5bf0a8b1457695355fb8ac404e7ap+1) +#define SLEEF_M_LOG2Eq SLEEF_QUAD_C(+0x1.71547652b82fe1777d0ffda0d23ap+0) +#define SLEEF_M_LOG10Eq SLEEF_QUAD_C(+0x1.bcb7b1526e50e32a6ab7555f5a68p-2) +#define SLEEF_M_LN2q SLEEF_QUAD_C(+0x1.62e42fefa39ef35793c7673007e6p-1) +#define SLEEF_M_LN10q SLEEF_QUAD_C(+0x1.26bb1bbb5551582dd4adac5705a6p+1) +#define SLEEF_M_PIq SLEEF_QUAD_C(+0x1.921fb54442d18469898cc51701b8p+1) +#define SLEEF_M_PI_2q SLEEF_QUAD_C(+0x1.921fb54442d18469898cc51701b8p+0) +#define SLEEF_M_PI_4q SLEEF_QUAD_C(+0x1.921fb54442d18469898cc51701b8p-1) +#define SLEEF_M_1_PIq SLEEF_QUAD_C(+0x1.45f306dc9c882a53f84eafa3ea6ap-2) +#define SLEEF_M_2_PIq SLEEF_QUAD_C(+0x1.45f306dc9c882a53f84eafa3ea6ap-1) +#define SLEEF_M_2_SQRTPIq SLEEF_QUAD_C(+0x1.20dd750429b6d11ae3a914fed7fep+0) +#define SLEEF_M_SQRT2q SLEEF_QUAD_C(+0x1.6a09e667f3bcc908b2fb1366ea95p+0) +#define SLEEF_M_SQRT3q SLEEF_QUAD_C(+0x1.bb67ae8584caa73b25742d7078b8p+0) +#define SLEEF_M_INV_SQRT3q SLEEF_QUAD_C(+0x1.279a74590331c4d218f81e4afb25p-1) +#define SLEEF_M_SQRT1_2q SLEEF_QUAD_C(+0x1.6a09e667f3bcc908b2fb1366ea95p-1) +#define SLEEF_M_INV_SQRTPIq SLEEF_QUAD_C(+0x1.20dd750429b6d11ae3a914fed7fep-1) +#define SLEEF_M_EGAMMAq SLEEF_QUAD_C(+0x1.2788cfc6fb618f49a37c7f0202a6p-1) +#define SLEEF_M_PHIq SLEEF_QUAD_C(+0x1.9e3779b97f4a7c15f39cc0605ceep+0) +#define SLEEF_QUAD_MAX SLEEF_QUAD_C(+0x1.ffffffffffffffffffffffffffffp+16383) +#define SLEEF_QUAD_MIN SLEEF_QUAD_C(+0x1p-16382) +#define SLEEF_QUAD_EPSILON SLEEF_QUAD_C(+0x1p-112) +#define SLEEF_QUAD_DENORM_MIN SLEEF_QUAD_C(+0x0.0000000000000000000000000001p-16382) + +#else // #ifdef SLEEF_QUAD_C + +#define SLEEF_M_Eq sleef_q(+0x15bf0a8b14576LL, 0x95355fb8ac404e7aULL, 1) +#define SLEEF_M_LOG2Eq sleef_q(+0x171547652b82fLL, 0xe1777d0ffda0d23aULL, 0) +#define SLEEF_M_LOG10Eq sleef_q(+0x1bcb7b1526e50LL, 0xe32a6ab7555f5a68ULL, -2) +#define SLEEF_M_LN2q sleef_q(+0x162e42fefa39eLL, 0xf35793c7673007e6ULL, -1) +#define SLEEF_M_LN10q sleef_q(+0x126bb1bbb5551LL, 0x582dd4adac5705a6ULL, 1) +#define SLEEF_M_PIq sleef_q(+0x1921fb54442d1LL, 0x8469898cc51701b8ULL, 1) +#define SLEEF_M_PI_2q sleef_q(+0x1921fb54442d1LL, 0x8469898cc51701b8ULL, 0) +#define SLEEF_M_PI_4q sleef_q(+0x1921fb54442d1LL, 0x8469898cc51701b8ULL, -1) +#define SLEEF_M_1_PIq sleef_q(+0x145f306dc9c88LL, 0x2a53f84eafa3ea6aULL, -2) +#define SLEEF_M_2_PIq sleef_q(+0x145f306dc9c88LL, 0x2a53f84eafa3ea6aULL, -1) +#define SLEEF_M_2_SQRTPIq sleef_q(+0x120dd750429b6LL, 0xd11ae3a914fed7feULL, 0) +#define SLEEF_M_SQRT2q sleef_q(+0x16a09e667f3bcLL, 0xc908b2fb1366ea95ULL, 0) +#define SLEEF_M_SQRT3q sleef_q(+0x1bb67ae8584caLL, 0xa73b25742d7078b8ULL, 0) +#define SLEEF_M_INV_SQRT3q sleef_q(+0x1279a74590331LL, 0xc4d218f81e4afb25ULL, -1) +#define SLEEF_M_SQRT1_2q sleef_q(+0x16a09e667f3bcLL, 0xc908b2fb1366ea95ULL, -1) +#define SLEEF_M_INV_SQRTPIq sleef_q(+0x120dd750429b6LL, 0xd11ae3a914fed7feULL, -1) +#define SLEEF_M_EGAMMAq sleef_q(+0x12788cfc6fb61LL, 0x8f49a37c7f0202a6ULL, -1) +#define SLEEF_M_PHIq sleef_q(+0x19e3779b97f4aLL, 0x7c15f39cc0605ceeULL, 0) +#define SLEEF_QUAD_MAX sleef_q(+0x1ffffffffffffLL, 0xffffffffffffffffULL, 16383) +#define SLEEF_QUAD_MIN sleef_q(+0x1000000000000LL, 0x0000000000000000ULL, -16382) +#define SLEEF_QUAD_EPSILON sleef_q(+0x1000000000000LL, 0x0000000000000000ULL, -112) +#define SLEEF_QUAD_DENORM_MIN sleef_q(+0x0000000000000LL, 0x0000000000000001ULL, -16382) + +#endif // #ifdef SLEEF_QUAD_C + +#define SLEEF_QUAD_MANT_DIG 113 +#define SLEEF_QUAD_MIN_EXP (-16381) +#define SLEEF_QUAD_MAX_EXP 16384 +#define SLEEF_QUAD_DIG 33 +#define SLEEF_QUAD_MIN_10_EXP (-4931) +#define SLEEF_QUAD_MAX_10_EXP 4932 + +// + +#include +#include + +SLEEF_IMPORT Sleef_quad Sleef_strtoq(const char *str, char **endptr); + +SLEEF_IMPORT int Sleef_fprintf(FILE *fp, const char *fmt, ...); +SLEEF_IMPORT int Sleef_vfprintf(FILE *fp, const char *fmt, va_list ap); +SLEEF_IMPORT int Sleef_printf(const char *fmt, ...); +SLEEF_IMPORT int Sleef_vprintf(const char *fmt, va_list ap); +SLEEF_IMPORT int Sleef_snprintf(char *str, size_t size, const char *fmt, ...); +SLEEF_IMPORT int Sleef_vsnprintf(char *str, size_t size, const char *fmt, va_list ap); + +SLEEF_IMPORT int Sleef_registerPrintfHook(); +SLEEF_IMPORT void Sleef_unregisterPrintfHook(); + +// diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/quad/sleefquadinline_cuda_header.h.org b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/quad/sleefquadinline_cuda_header.h.org new file mode 100644 index 00000000000..e6626edc4dd --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/quad/sleefquadinline_cuda_header.h.org @@ -0,0 +1,4196 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See http://www.boost.org/LICENSE_1_0.txt) + +// This file is generated by SLEEF SLEEF_VERSION_SLEEF + +// Use --fmad=false option to compile this file +// Include cmath, cfloat and cstdint before including this file + +#ifndef SLEEF_FP_ILOGB0 +#define SLEEF_FP_ILOGB0 ((int)0x80000000) +#endif + +#ifndef SLEEF_FP_ILOGBNAN +#define SLEEF_FP_ILOGBNAN ((int)2147483647) +#endif + +#if defined(_MSC_VER) && !defined (__clang__) +#pragma fp_contract (off) +#else +#pragma STDC FP_CONTRACT OFF +#endif + +__device__ const double Sleef_rempitabqp[] = { + 0.15915494308865163475, 114.12758349655632628, 87.820147804392036051, 27.423136899138626177, + 14.254027919272630243, 85.935026329207175877, 114.27691102886092267, 37.750191829592949944, + 2.4546589403216785286, 111.34725244651053799, 62.908236858707823558, 87.408456635555921821, + 64.604759095473127672, 28.784837529448850546, 51.622219578821386676, 23.484166172853292665, + 126.14843699368429952, 64.497947248710261192, 90.04072758117763442, 79.851150118094665231, + 93.238662576877686661, 47.957378064249496674, 44.495092337878304534, 122.05645651105805882, + 36.728927543368627084, 8.9860062754451064393, 3.1885831643376150168, 117.4925837228220189, + 107.81580297079563024, 72.690177145766938338, 6.3499807085099746473, 64.814470052646356635, + 32.07563458668300882, 48.190104861652798718, 40.78663459321251139, 17.552382976566150319, + 13.621939875218231464, 21.256544246167322854, 57.381995073275902541, 9.6354705119701975491, + 41.499050218579213833, 113.6220945173263317, 79.59452043374767527, 103.64401134191575693, + 123.88471844718515058, 101.4736260631980258, 18.097774968078738311, 85.95650738066615304, + 76.065655079091811785, 37.675427324622432934, 68.676777671174932038, 32.00599382463042275, + 53.77951688189568813, 0.19179906913632294163, 73.478443940475699492, 111.92379273104597814, + 40.996545034144219244, 107.14597675384720787, 124.38805678367862129, 98.636395050234568771, + 103.347364549201302, 101.568637595839391, 98.20809433281829115, 0.21127150943721062504, + 6.4992127331242954824, 115.19938259065020247, 123.67517849772775662, 108.64186459926349926, + 2.9984621451549173798, 4.6062990500759042334, 93.491721027461608173, 49.145381707759952405, + 52.727074269980221288, 71.068700205698405625, 99.034355036987108178, 24.011549219118023757, + 111.50147725937858922, 49.03615573892602697, 53.722402094637800474, 91.897739203315722989, + 18.206447852357086958, 109.32060226575413253, 97.416567328084056498, 19.228490159101056634, + 125.86502164847843233, 68.117931140997825423, 37.659347287717537256, 94.778508877261629095, + 125.23389264055003878, 9.1960193313898344059, 89.79227686872400227, 44.219955035077873617, + 80.594031160762824584, 98.175325535910815233, 9.1060313697525998577, 1.3536325568711617962, + 74.266441315219708486, 112.02497297326408443, 78.441242103348486125, 30.240608034280739957, + 35.887181287234852789, 31.222180933826166438, 111.20435677495697746, 16.961934521656075958, + 75.690011131529900013, 19.857096218624064932, 39.445799316181364702, 89.399067092508630594, + 9.8946251570741878822, 75.790836480315192603, 41.449609204857551958, 16.424785501782025676, + 110.92636979258531937, 35.2268612109037349, 93.553590155912388582, 60.716867816085141385, + 101.8275823641452007, 0.52353978253449895419, 53.558147969339188421, 14.022688405977532966, + 47.412589899395243265, 67.466685592477006139, 20.558449846765142865, 42.477512440153077478, + 78.376983236481464701, 52.194720245763164712, 80.210266588394006249, 10.32282516378472792, + 13.76645060176088009, 65.576818637229735032, 113.30637098982697353, 33.130573191992880311, + 85.595008141503058141, 40.008528567348548677, 76.341531842852418777, 14.979836669819633244, + 71.290441850942443125, 102.19776376600566437, 98.564603420047205873, 14.271847993266419508, + 80.116664932062121807, 19.992192520050593885, 36.609960786536248634, 73.030199955795978894, + 104.99763589425128885, 48.433380696202220861, 57.572455457851901883, 118.88634466403527767, + 44.860695004797889851, 73.750690998633217532, 13.556655583906831453, 88.593745596503140405, + 14.11532725519646192, 43.085424128406884847, 9.7802314795590064023, 30.352614322964655003, + 90.858137878454726888, 85.039140199140092591, 23.407077980155008845, 18.207643349760473939, + 20.440075362967036199, 109.47096555736425216, 66.428168903472396778, 106.84400033217025339, + 91.750582754768402083, 76.596534958600386744, 17.320324285941751441, 49.535734807919652667, + 113.66190455558171379, 61.225422811843600357, 18.669559649624716258, 76.387663934096053708, + 74.178235974148265086, 85.815782102505181683, 122.10498128451581579, 24.799236859667871613, + 123.2972609065072902, 50.72595180519783753, 121.41778173806596897, 114.39462376141091227, + 90.193730781800695695, 3.0683144895410805475, 26.293759879121353151, 46.076575149436393986, + 19.660881336145394016, 25.597005338699091226, 101.31112300279710325, 103.8807629969487607, + 91.892762314044375671, 57.045969595055794343, 110.15196133002973511, 94.689776863833685638, + 49.182032269411138259, 123.69104138236070867, 113.69436034850150463, 117.72063118611185928, + 1.4682589776566601358, 23.970066872989264084, 91.772521428280015243, 32.248277749331464292, + 74.556784206688462291, 120.01798423568834551, 87.713686773899098625, 80.036939679470378906, + 58.663490617163915886, 21.035325459186424268, 79.868647571121982764, 19.982377222022478236, + 57.246738529793219641, 1.9401161782407143619, 7.9883917663682950661, 108.92261904602855793, + 42.957866646069305716, 55.213983339206606615, 85.734177860773343127, 8.1786861732471152209, + 113.8021284014939738, 6.3038078266908996738, 108.74856571221971535, 13.502748231236182619, + 29.736439245178189594, 66.181101124901033472, 14.021098141827678774, 50.432291116485430393, + 71.692326357551792171, 112.62160509388922947, 46.52251733029333991, 70.328927450136689004, + 82.779915324492321815, 114.20617270459479187, 120.00074403454345884, 27.256265592593990732, + 72.206675336365151452, 105.47692570983417681, 90.069591432285960764, 59.451044258996262215, + 6.5436011348210740834, 11.666369110360392369, 127.00500442843986093, 66.781588143319822848, + 101.71752368163652136, 110.83473463953487226, 9.4843589676565898117, 87.965483504598523723, + 32.660788242061244091, 94.484722863278875593, 121.36131720729463268, 27.298648878622771008, + 105.17309219513481366, 68.000137710059789242, 93.444196628861391218, 44.093294898437306983, + 44.109477207573945634, 104.37636018792545656, 16.936308635202294681, 42.461140061379410326, + 48.120956522194319405, 47.03053727519363747, 74.836943859434541082, 76.560959611877478892, + 70.982041261755512096, 106.17278879548030091, 17.240951762454642449, 116.54761581097409362, + 85.489981931084912503, 19.448874795671144966, 68.055698282205412397, 120.54780957969705923, + 79.357897397254419047, 26.784055884931149194, 8.8652342647874320392, 93.554617017987766303, + 36.863637874987034593, 107.36296787388710072, 114.24380599117284874, 57.996031665523332777, + 107.15169167585190735, 6.8493815877518500201, 70.030736486780369887, 104.34439242449298035, + 32.394922227955248673, 72.045712768554949434, 125.99193223337715608, 79.855994894536706852, + 102.91479410954343621, 19.828504664699721616, 19.423237169754429488, 49.419210917687451001, + 51.794468197291280376, 59.485514724419772392, 78.600481083303748164, 75.802543954887369182, + 49.485430251796060475, 125.97828236915302114, 98.782930868979747174, 83.325835802559595322, + 59.946491932565550087, 73.477066622643178562, 89.105636388390848879, 73.372970791053376161, + 18.817599439345940482, 102.06705368556504254, 45.42352350837609265, 23.440921115026867483, + 90.344093902869644808, 17.970589397602452664, 53.956875561776541872, 55.525845976218988653, + 49.46730813278190908, 77.778136706394434441, 43.505807501616800437, 67.471431943824427435, + 84.265864734097704059, 14.933240975493390579, 24.684664495714969235, 126.41874786355037941, + 1.3222032844169007149, 126.01238007772190031, 83.383431563808699138, 113.72324844212562311, + 21.304834404720168095, 62.332525882295158226, 51.597882727459364105, 0.67672862408289802261, + 30.132787537324475124, 27.410108195865177549, 20.656855709145020228, 49.723609964024944929, + 119.05708648653671844, 91.246047016928059747, 84.369696109431970399, 85.591131138298806036, + 14.127644950760441134, 4.2155267645284766331, 24.204889203938364517, 19.661099106528126867, + 82.477870938018895686, 120.89188850888967863, 122.58114253445455688, 120.63265677435265388, + 27.082481923996965634, 29.761974944867688464, 72.461197358730714768, 84.204483040954073658, + 80.890771993039379595, 99.777925805155973649, 91.8974949579933309, 94.518818676227965625, + 126.28205386120316689, 88.787575110411125934, 93.769932165232603438, 79.733441483964270446, + 38.645666720854933374, 115.27208568365676911, 31.268716353544732556, 112.30475518474486307, + 74.891574611563555663, 115.66812160437984858, 18.66350298186080181, 94.633595189065090381, + 109.45983699533462641, 108.68776993196661351, 58.76809135159055586, 61.680897811242175521, + 38.882956551777169807, 45.576713001821190119, 7.4377005918177019339, 120.60427874347078614, + 120.21996894028052338, 47.606037590059713693, 0.31830988618094124831, 100.25516699311629054, + 47.640295608784072101, 54.846273798277252354, 28.508055838548898464, 43.870052658417989733, + 100.55382205772184534, 75.500383659185899887, 4.9093178806469950359, 94.694504893021075986, + 125.81647371741928509, 46.816913271115481621, 1.2095181909462553449, 57.569675058897701092, + 103.24443915764277335, 46.968332345710223308, 124.29687398737223702, 0.99589449742416036315, + 52.081455162358906819, 31.702300236192968441, 58.477325153755373321, 95.914756128498993348, + 88.990184675760247046, 116.11291302211611765, 73.457855086737254169, 17.972012550890212879, + 6.3771663286788680125, 106.98516744564767578, 87.631605941594898468, 17.380354291533876676, + 12.699961417023587273, 1.6289401052927132696, 64.15126917336601764, 96.380209723305597436, + 81.573269186425022781, 35.104765953132300638, 27.243879750436462928, 42.513088492334645707, + 114.76399014655180508, 19.270941023940395098, 82.998100437162065646, 99.244189034656301374, + 31.189040867498988518, 79.288022683835151838, 119.76943689437393914, 74.947252126396051608, + 36.195549936161114601, 43.913014761335944058, 24.131310158183623571, 75.350854649248503847, + 9.3535553423498640768, 64.011987649260845501, 107.55903376379137626, 0.38359813827628386207, + 18.956887880955036962, 95.847585462091956288, 81.993090068292076467, 86.291953507698053727, + 120.77611356736088055, 69.272790100472775521, 78.694729098406241974, 75.137275191682419972, + 68.4161886656365823, 0.42254301887442125008, 12.998425466252228944, 102.39876518130404293, + 119.35035699545915122, 89.283729198526998516, 5.9969242903098347597, 9.2125981001554464456, + 58.983442054923216347, 98.290763415519904811, 105.45414853996408056, 14.137400411400449229, + 70.068710073974216357, 48.023098438239685493, 95.002954518757178448, 98.07231147785205394, + 107.44480418927923893, 55.795478406631445978, 36.412895704717811896, 90.641204531511903042, + 66.833134656168112997, 38.456980318205751246, 123.73004329696050263, 8.2358622819956508465, + 75.318694575438712491, 61.557017754526896169, 122.46778528110007755, 18.392038662783306791, + 51.58455373744800454, 88.439910070159385214, 33.188062321529287146, 68.350651071821630467, + 18.212062739505199715, 2.7072651137459615711, 20.53288263044305495, 96.04994594653180684, + 28.882484206696972251, 60.481216068561479915, 71.774362574469705578, 62.444361867655970855, + 94.408713549913954921, 33.923869043315789895, 23.380022263059800025, 39.714192437248129863, + 78.891598632366367383, 50.798134185017261188, 19.789250314152013743, 23.581672960630385205, + 82.899218409715103917, 32.849571003567689331, 93.852739585170638748, 70.453722421811107779, + 59.107180311824777164, 121.43373563217392075, 75.655164728290401399, 1.0470795650689979084, + 107.11629593867837684, 28.045376811955065932, 94.825179798794124508, 6.9333711849540122785, + 41.116899693530285731, 84.955024880309792934, 28.753966472962929402, 104.3894404915299674, + 32.420533176788012497, 20.64565032756945584, 27.532901203525398159, 3.1536372744631080423, + 98.612741979653947055, 66.261146383989398601, 43.190016283006116282, 80.017057134700735332, + 24.683063685704837553, 29.959673339642904466, 14.580883701888524229, 76.39552753201496671, + 69.129206840094411746, 28.543695986536476994, 32.233329864124243613, 39.984385040101187769, + 73.219921573076135246, 18.060399911595595768, 81.995271788502577692, 96.866761392404441722, + 115.14491091570744175, 109.77268932807055535, 89.721390009599417681, 19.501381997266435064, + 27.113311167817300884, 49.18749119300628081, 28.230654510392923839, 86.170848256813769694, + 19.560462959118012805, 60.705228645932947984, 53.716275756913091755, 42.078280398280185182, + 46.81415596031001769, 36.415286699520947877, 40.880150725937710376, 90.941931114732142305, + 4.8563378069484315347, 85.688000664344144752, 55.501165509540442144, 25.193069917200773489, + 34.640648571883502882, 99.071469615842943313, 99.323809111163427588, 122.45084562368720071, + 37.339119299253070494, 24.775327868195745395, 20.356471948300168151, 43.631564205014001345, + 116.20996256903163157, 49.598473719339381205, 118.5945218130145804, 101.45190361039931304, + 114.83556347613557591, 100.78924752282546251, 52.38746156360139139, 6.136628979082161095, + 52.587519758242706303, 92.153150298872787971, 39.321762672290788032, 51.194010677401820431, + 74.622246005597844487, 79.761525993901159381, 55.785524628088751342, 114.09193919011522667, + 92.303922660063108196, 61.379553727667371277, 98.364064538825914497, 119.38208276472505531, + 99.388720697006647242, 107.44126237222371856, 2.9365179553133202717, 47.940133745982166147, + 55.545042856560030486, 64.496555498666566564, 21.113568413380562561, 112.03596847138032899, + 47.42737354780183523, 32.073879358940757811, 117.32698123432783177, 42.070650918376486516, + 31.737295142243965529, 39.964754444044956472, 114.49347705958643928, 3.8802323564814287238, + 15.976783532740228111, 89.845238092057115864, 85.915733292138611432, 110.42796667841685121, + 43.468355721546686254, 16.357372346497868421, 99.604256802987947594, 12.607615653385437327, + 89.497131424439430702, 27.005496462472365238, 59.472878490360017167, 4.3622022498020669445, + 28.042196283655357547, 100.86458223297449877, 15.384652715107222321, 97.243210187778458931, + 93.045034660590317799, 12.657854900277015986, 37.559830648988281609, 100.41234540919322171, + 112.00148806908691768, 54.512531185191619443, 16.413350672733940883, 82.953851419671991607, + 52.139182864571921527, 118.90208851799252443, 13.087202269642148167, 23.332738220724422717, + 126.01000885688335984, 5.5631762866432836745, 75.435047363276680699, 93.669469279069744516, + 18.968717935316817602, 47.930967009197047446, 65.321576484126126161, 60.969445726561389165, + 114.72263441458926536, 54.597297757249179995, 82.346184390273265308, 8.0002754201232164633, + 58.888393257722782437, 88.186589796874613967, 88.218954415151529247, 80.752720375850913115, + 33.872617270404589362, 84.922280122758820653, 96.241913044388638809, 94.061074550390912918, + 21.673887718872720143, 25.121919223758595763, 13.964082523514662171, 84.34557759096060181, + 34.481903524912922876, 105.09523162195182522, 42.979963862169825006, 38.897749591345927911, + 8.1113965644144627731, 113.09561915939775645, 30.715794794508838095, 53.568111769862298388, + 17.730468529578502057, 59.109234035975532606, 73.727275749977707164, 86.725935747777839424, + 100.48761198234569747, 115.99206333105030353, 86.303383351703814697, 13.698763175507338019, + 12.061472973564377753, 80.688784848985960707, 64.789844455914135324, 16.091425537113536848, + 123.98386446675795014, 31.711989789077051682, 77.829588219086872414, 39.657009329399443232, + 38.846474339508858975, 98.838421835374902003, 103.58893639458256075, 118.97102944884318276, + 29.200962166611134307, 23.605087909774738364, 98.970860503595758928, 123.95656473830968025, + 69.565861737963132327, 38.651671605119190644, 119.89298386513473815, 18.954133245289995102, + 50.211272776785335736, 18.745941582106752321, 37.635198878695518943, 76.134107371130085085, + 90.8470470167521853, 46.881842230057372944, 52.688187805739289615, 35.941178795204905327, + 107.91375112355308374, 111.05169195243797731, 98.934616265567456139, 27.556273412788868882, + 87.011615003237238852, 6.9428638876524928492, 40.531729468195408117, 29.866481950986781158, + 49.369328991433576448, 124.83749572710075881, 2.6444065688374394085, 124.02476015544743859, + 38.766863127621036256, 99.446496884251246229, 42.60966880944033619, 124.66505176459031645, + 103.19576545491872821, 1.3534572481657960452, 60.265575074648950249, 54.820216391730355099, + 41.313711418290040456, 99.447219928053527838, 110.11417297307707486, 54.492094033859757474, + 40.739392218867578777, 43.182262276597612072, 28.255289901520882268, 8.4310535290569532663, + 48.409778407876729034, 39.322198213059891714, 36.95574187604142935, 113.78377701778299524, + 117.16228506891275174, 113.26531354870530777, 54.164963847993931267, 59.523949889739014907, + 16.922394717465067515, 40.408966081911785295, 33.781543986082397169, 71.555851610315585276, + 55.794989915990299778, 61.037637352459569229, 124.56410772240997176, 49.575150220825889846, + 59.539864330468844855, 31.466882967928540893, 77.291333441713504726, 102.54417136731353821, + 62.53743270709310309, 96.609510369493364124, 21.783149223130749306, 103.33624320875969715, + 37.3270059637252416, 61.26719037813381874, 90.919673990672890795, 89.375539863933227025, + 117.53618270318111172, 123.36179562248435104, 77.765913103554339614, 91.153426003642380238, + 14.875401183639041847, 113.20855748694521026, 112.43993788056104677, 95.212075180119427387, + 0.63661977236552047543, 72.510333986232581083, 95.280591217568144202, 109.69254759655450471, + 57.016111677097796928, 87.740105316839617444, 73.107644115447328659, 23.000767318371799774, + 9.8186357612976280507, 61.389009786045789951, 123.63294743483857019, 93.633826542230963241, + 2.4190363818925106898, 115.13935011779904016, 78.488878315285546705, 93.936664691424084594, + 120.59374797474447405, 1.9917889948483207263, 104.16291032471781364, 63.404600472385936882, + 116.95465030751438462, 63.829512257001624675, 49.980369351524132071, 104.22582604423587327, + 18.915710173474508338, 35.944025101780425757, 12.754332657361374004, 85.970334891298989533, + 47.263211883189796936, 34.760708583067753352, 25.399922834047174547, 3.257880210589064518, + 0.30253834673567325808, 64.76041944661483285, 35.146538372850045562, 70.209531906264601275, + 54.487759500872925855, 85.026176984672929393, 101.52798029310361017, 38.541882047884428175, + 37.99620087432776927, 70.488378069312602747, 62.378081735001615016, 30.576045367673941655, + 111.53887378875151626, 21.894504252792103216, 72.391099872322229203, 87.826029522671888117, + 48.262620316370885121, 22.701709298497007694, 18.707110684703366132, 0.023975298525328980759, + 87.118067527582752518, 0.76719627655256772414, 37.913775761913711904, 63.695170924187550554, + 35.986180136587790912, 44.583907015399745433, 113.55222713472539908, 10.54558020094918902, + 29.389458196816121927, 22.274550383368477924, 8.8323773312731646001, 0.84508603774884250015, + 25.996850932508095866, 76.797530362611723831, 110.70071399092194042, 50.567458397053997032, + 11.993848580619669519, 18.425196200310892891, 117.96688410985007067, 68.581526831043447601, + 82.908297079928161111, 28.274800822804536438, 12.137420147948432714, 96.046196876483008964, + 62.005909037517994875, 68.144622955707745859, 86.889608378558477852, 111.59095681326289196, + 72.82579140943926177, 53.282409063027444063, 5.6662693123362259939, 76.91396063641514047, + 119.46008659392100526, 16.471724563994939672, 22.637389150877424981, 123.11403550905743032, + 116.93557056220015511, 36.784077325566613581, 103.16910747489964706, 48.879820140318770427, + 66.376124643062212272, 8.7013021436432609335, 36.424125479010399431, 5.4145302274919231422, + 41.065765260889747879, 64.099891893063613679, 57.764968413393944502, 120.96243213712659781, + 15.548725148939411156, 124.88872373531557969, 60.817427099827909842, 67.84773808663157979, + 46.76004452611960005, 79.428384874499897705, 29.783197264732734766, 101.59626837003452238, + 39.578500628304027487, 47.163345921264408389, 37.798436819430207834, 65.699142007139016641, + 59.705479170344915474, 12.907444843622215558, 118.21436062365319231, 114.86747126435147948, + 23.310329456580802798, 2.0941591301416337956, 86.232591877356753685, 56.090753623913769843, + 61.650359597588249017, 13.866742369908024557, 82.233799387064209441, 41.910049760619585868, + 57.507932945929496782, 80.778880983059934806, 64.841066353576024994, 41.291300655138911679, + 55.065802407050796319, 6.3072745489298540633, 69.225483959311532089, 4.5222927679787972011, + 86.380032566015870543, 32.034114269401470665, 49.366127371409675106, 59.919346679285808932, + 29.161767403780686436, 24.791055064033571398, 10.258413680188823491, 57.087391973072953988, + 64.466659728248487227, 79.968770080206013517, 18.439843146152270492, 36.120799823194829514, + 35.990543577008793363, 65.733522784812521422, 102.28982183141852147, 91.545378656144748675, + 51.442780019198835362, 39.002763994532870129, 54.226622335634601768, 98.374982386012561619, + 56.461309020789485658, 44.341696513627539389, 39.120925918236025609, 121.41045729186589597, + 107.43255151382618351, 84.156560796560370363, 93.62831192062003538, 72.830573399041895755, + 81.760301451879058732, 53.88386222946428461, 9.7126756139005010482, 43.376001328688289504, + 111.00233101908088429, 50.386139834401546977, 69.281297143770643743, 70.142939231689524604, + 70.647618222330493154, 116.90169124737440143, 74.678238598506140988, 49.550655736391490791, + 40.712943896600336302, 87.263128410031640669, 104.41992513806326315, 99.196947438682400389, + 109.18904362603279878, 74.903807220802264055, 101.6711269522747898, 73.578495045650925022, + 104.77492312720278278, 12.27325795816432219, 105.17503951648905058, 56.306300597745575942, + 78.643525344581576064, 102.38802135480727884, 21.244492011199326953, 31.523051987802318763, + 111.57104925618114066, 100.18387838023409131, 56.607845320126216393, 122.75910745533838053, + 68.728129077655466972, 110.7641655294537486, 70.777441394016932463, 86.882524744447437115, + 5.8730359106266405433, 95.880267491964332294, 111.09008571312369895, 0.99311099733313312754, + 42.2271368267647631, 96.071936942760657985, 94.854747095603670459, 64.147758717885153601, + 106.65396246865566354, 84.141301836752973031, 63.474590284487931058, 79.929508888093550922, + 100.98695411917287856, 7.7604647129628574476, 31.953567065484094201, 51.690476184117869707, + 43.831466584280860843, 92.855933356833702419, 86.936711443093372509, 32.71474469299937482, + 71.208513605975895189, 25.215231306774512632, 50.994262848878861405, 54.010992924944730476, + 118.94575698072003433, 8.7244044996041338891, 56.084392567314353073, 73.729164465948997531, + 30.76930543021808262, 66.48642037556055584, 58.090069321180635598, 25.315709800554031972, + 75.119661297980201198, 72.824690818390081404, 96.002976138173835352, 109.02506237038323889, + 32.826701345471519744, 37.907702839343983214, 104.27836572914748103, 109.80417703598504886, + 26.174404539284296334, 46.665476441452483414, 124.02001771376671968, 11.126352573290205328, + 22.870094726556999376, 59.338938558139489032, 37.937435870633635204, 95.861934018397732871, + 2.6431529682522523217, 121.93889145312641631, 101.44526882917853072, 109.19459551450199797, + 36.692368780546530616, 16.000550840246432927, 117.77678651544920285, 48.373179593752865912, + 48.437908830306696473, 33.50544075170182623, 67.745234540812816704, 41.844560245521279285, + 64.483826088780915597, 60.122149100781825837, 43.347775437745440286, 50.243838447517191526, + 27.92816504703296232, 40.691155181921203621, 68.963807049829483731, 82.190463243903650437, + 85.959927724339650013, 77.795499182691855822, 16.222793128832563525, 98.191238318795512896, + 61.43158958901767619, 107.13622353972459678, 35.460937059157004114, 118.21846807195470319, + 19.454551499959052308, 45.451871495559316827, 72.975223964695032919, 103.98412666210424504, + 44.606766703407629393, 27.397526351014676038, 24.122945947132393485, 33.377569697975559393, + 1.5796889118282706477, 32.182851074230711674, 119.96772893351590028, 63.423979578157741344, + 27.659176438173744828, 79.314018658798886463, 77.692948679021355929, 69.676843670753441984, + 79.177872789168759482, 109.94205889768636553, 58.401924333222268615, 47.210175819553114707, + 69.941721007195155835, 119.91312947662299848, 11.131723475926264655, 77.303343210242019268, + 111.78596773026947631, 37.908266490579990204, 100.42254555357067147, 37.491883164213504642, + 75.270397757394675864, 24.268214742263808148, 53.6940940335043706, 93.763684460114745889, + 105.37637561147857923, 71.882357590413448634, 87.827502247109805467, 94.103383904879592592, + 69.869232531134912279, 55.112546825581375742, 46.023230006474477705, 13.885727775304985698, + 81.063458936390816234, 59.732963901973562315, 98.738657982870790875, 121.67499145420151763, + 5.2888131376785167959, 120.04952031089487718, 77.53372625524571049, 70.892993768502492458, + 85.219337618884310359, 121.33010352918427088, 78.39153090983745642, 2.7069144963315920904, + 120.5311501492979005, 109.6404327834607102, 82.62742283658371889, 70.894439856110693654, + 92.228345946154149715, 108.98418806771951495, 81.478784437735157553, 86.364524553195224144, + 56.510579803041764535, 16.862107058113906533, 96.819556815753458068, 78.644396426119783428, + 73.911483752086496679, 99.567554035569628468, 106.32457013782914146, 98.530627097410615534, + 108.32992769598786253, 119.04789977947802981, 33.84478943493013503, 80.81793216382357059, + 67.563087972168432316, 15.111703220631170552, 111.58997983198059956, 122.07527470492277644, + 121.12821544481994351, 99.150300441651779693, 119.07972866093768971, 62.933765935860719765, + 26.582666883430647431, 77.088342734627076425, 125.07486541418984416, 65.219020738986728247, + 43.56629844626513659, 78.672486417519394308, 74.654011927450483199, 122.53438075627127546, + 53.83934798134941957, 50.751079727870092029, 107.07236540636586142, 118.72359124497234006, + 27.531826207112317206, 54.306852007284760475, 29.750802367281721672, 98.417114973894058494, + 96.879875761125731515, 62.424150360242492752, 1.2732395447346789297, 17.020667972468800144, + 62.561182435139926383, 91.385095193109009415, 114.03222335419923184, 47.480210633682872867, + 18.215288230894657318, 46.001534636743599549, 19.637271522595256101, 122.77801957209521788, + 119.26589486968077836, 59.267653084461926483, 4.8380727637886593584, 102.2787002356017183, + 28.977756630574731389, 59.873329382851807168, 113.1874959494889481, 3.9835779897002794314, + 80.325820649435627274, 126.80920094477551174, 105.90930061502876924, 127.65902451400324935, + 99.960738703051902121, 80.451652088471746538, 37.831420346949016675, 71.888050203560851514, + 25.508665314726385986, 43.940669782597979065, 94.526423766379593872, 69.521417166135506704, + 50.799845668094349094, 6.515760421178129036, 0.60507669347498449497, 1.5208388932296657003, + 70.293076745703729102, 12.419063812529202551, 108.97551900174948969, 42.052353969349496765, + 75.055960586207220331, 77.08376409576885635, 75.992401748659176519, 12.976756138625205494, + 124.75616347000323003, 61.152090735351521289, 95.077747577503032517, 43.789008505587844411, + 16.782199744648096384, 47.652059045343776233, 96.525240632741770241, 45.403418596994015388, + 37.414221369406732265, 0.047950597054295940325, 46.236135055165505037, 1.5343925531051354483, + 75.827551523827423807, 127.39034184837510111, 71.972360273175581824, 89.167814030803128844, + 99.104454269450798165, 21.091160401898378041, 58.778916393632243853, 44.549100766736955848, + 17.6647546625463292, 1.6901720754976850003, 51.993701865019829711, 25.595060725227085641, + 93.401427981843880843, 101.13491679410799406, 23.987697161239339039, 36.850392400625423761, + 107.93376821970377932, 9.1630536620905331802, 37.816594159856322221, 56.549601645609072875, + 24.274840295900503406, 64.092393752966017928, 124.01181807503962773, 8.2892459114191296976, + 45.779216757120593684, 95.18191362652942189, 17.65158281887852354, 106.56481812605488813, + 11.332538624676089967, 25.82792127283391892, 110.92017318784201052, 32.943449127989879344, + 45.274778301758487942, 118.22807101811849861, 105.87114112440031022, 73.568154651136865141, + 78.338214949799294118, 97.759640280641178833, 4.7522492861244245432, 17.402604287286521867, + 72.848250958020798862, 10.829060454983846284, 82.131530521783133736, 0.19978378612722735852, + 115.52993682679152698, 113.92486427425319562, 31.097450297882460291, 121.77744747063115938, + 121.63485419965945766, 7.6954761732631595805, 93.520089052242838079, 30.856769748999795411, + 59.566394529469107511, 75.192536740069044754, 79.157001256608054973, 94.326691842528816778, + 75.596873638864053646, 3.3982840142780332826, 119.41095834068983095, 25.814889687248069094, + 108.42872124731002259, 101.73494252870295895, 46.620658913161605597, 4.18831826028690557, + 44.465183754713507369, 112.18150724782753969, 123.30071919517649803, 27.733484739819687093, + 36.467598774128418881, 83.820099521239171736, 115.01586589186263154, 33.557761966123507591, + 1.6821327071520499885, 82.582601310277823359, 110.13160481410159264, 12.614549097863346105, + 10.450967918623064179, 9.0445855359612323809, 44.760065132031741086, 64.06822853880294133, + 98.732254742819350213, 119.83869335857161786, 58.323534807561372872, 49.582110128067142796, + 20.516827360377646983, 114.17478394614954595, 0.93331945650061243214, 31.937540160412027035, + 36.879686292304540984, 72.241599646389659029, 71.981087154021224706, 3.4670455696286808234, + 76.579643662840680918, 55.090757312289497349, 102.88556003839767072, 78.005527989065740258, + 108.45324467127284152, 68.749964772025123239, 112.92261804157897132, 88.683393027255078778, + 78.241851836475689197, 114.82091458373542991, 86.865103027656004997, 40.313121593124378705, + 59.256623841243708739, 17.661146798087429488, 35.520602903758117463, 107.76772445892856922, + 19.425351227801002096, 86.752002657380216988, 94.004662038161768578, 100.77227966880673193, + 10.562594287544925464, 12.285878463382687187, 13.295236444664624287, 105.80338249475244083, + 21.356477197012281977, 99.101311472782981582, 81.425887793204310583, 46.526256820066919317, + 80.839850276130164275, 70.393894877368438756, 90.378087252069235547, 21.807614441608166089, + 75.342253904553217581, 19.156990091305488022, 81.54984625440556556, 24.546515916332282359, + 82.350079032978101168, 112.61260119549478986, 29.287050689166790107, 76.77604270961455768, + 42.488984022398653906, 63.046103975608275505, 95.142098512365919305, 72.36775676046818262, + 113.21569064025607076, 117.51821491068039904, 9.4562581553145719226, 93.528331058911135187, + 13.554882788037502905, 45.76504948889487423, 11.746071821256919065, 63.760534983932302566, + 94.180171426247397903, 1.9862219946662662551, 84.454273653533164179, 64.143873885524953948, + 61.709494191210978897, 0.2955174357739451807, 85.307924937314965064, 40.282603673505946063, + 126.94918056897950009, 31.859017776190739824, 73.973908238345757127, 15.520929425925714895, + 63.907134130968188401, 103.38095236823573941, 87.662933168565359665, 57.711866713671042817, + 45.873422886186745018, 65.429489386002387619, 14.417027211951790377, 50.430462613549025264, + 101.98852569775772281, 108.02198584989309893, 109.89151396144006867, 17.448808999208267778, + 112.16878513463234412, 19.458328931897995062, 61.538610860439803218, 4.9728407511211116798, + 116.1801386423612712, 50.631419601111701922, 22.239322595964040374, 17.649381636783800786, + 64.005952276351308683, 90.050124740766477771, 65.653402690943039488, 75.815405678691604408, + 80.556731458298600046, 91.608354071970097721, 52.348809078568592668, 93.330952882908604806, + 120.04003542753343936, 22.252705146580410656, 45.740189453113998752, 118.67787711627897806, + 75.874871741270908387, 63.723868036795465741, 5.2863059365081426222, 115.8777829062564706, + 74.890537658360699425, 90.389191029003995936, 73.384737561093061231, 32.001101680496503832, + 107.5535730308984057, 96.746359187505731825, 96.875817660613392945, 67.010881503407290438, + 7.4904690816256334074, 83.689120491046196548, 0.96765217756183119491, 120.24429820156365167, + 86.695550875490880571, 100.48767689503438305, 55.856330094065924641, 81.38231036384604522, + 9.9276140996626054402, 36.380926487810938852, 43.919855448682938004, 27.590998365383711644, + 32.445586257668765029, 68.382476637591025792, 122.86317917803899036, 86.272447079449193552, + 70.921874118317646207, 108.43693614390940638, 38.909102999918104615, 90.903742991122271633, + 17.950447929393703816, 79.968253324208490085, 89.213533406815258786, 54.795052702029352076, + 48.24589189426478697, 66.755139395951118786, 3.1593778236565412953, 64.365702148465061327, + 111.93545786703180056, 126.84795915631548269, 55.318352876351127634, 30.628037317601410905, + 27.385897358046349837, 11.353687341510521946, 30.355745578341156943, 91.884117795372731052, + 116.80384866644453723, 94.420351639109867392, 11.883442014393949648, 111.82625895324599696, + 22.263446951856167288, 26.606686420487676514, 95.571935460538952611, 75.816532981163618388, + 72.845091107141342945, 74.983766328430647263, 22.540795514789351728, 48.536429484527616296, + 107.38818806701237918, 59.527368920233129757, 82.75275122296079644, 15.764715180830535246, + 47.655004494223248912, 60.206767809762823163, 11.738465062269824557, 110.22509365116275148, + 92.046460012948955409, 27.771455550613609375, 34.126917872781632468, 119.46592780395076261, + 69.477315965745219728, 115.34998290840303525, 10.577626275360671571, 112.09904062179339235, + 27.067452510495058959, 13.785987537008622894, 42.438675237772258697, 114.66020705837217974, + 28.78306181967491284, 5.4138289926668221597, 113.06230029859943897, 91.280865566925058374, + 37.254845673171075759, 13.788879712225025287, 56.456691892311937409, 89.968376135442667874, + 34.957568875473953085, 44.729049106390448287, 113.02115960608352907, 33.724214116231451044, + 65.639113631510554114, 29.288792852243204834, 19.822967504176631337, 71.135108071142894914, + 84.649140275661920896, 69.061254194824869046, 88.659855391979363048, 110.09579955895605963, + 67.689578869863908039, 33.63586432765077916, 7.1261759443368646316, 30.223406441265979083, + 95.179959663964837091, 116.15054940984919085, 114.25643088964352501, 70.300600883307197364, + 110.15945732187537942, 125.86753187172143953, 53.165333766864932841, 26.176685469257790828, + 122.1497308283833263, 2.4380414779734564945, 87.132596892533911159, 29.344972835042426595, + 21.308023854904604377, 117.06876151254255092, 107.67869596269883914, 101.50215945574382204, + 86.144730812735360814, 109.44718248994468013, 55.063652414224634413, 108.61370401456952095, + 59.501604734567081323, 68.834229947791754967, 65.75975152225146303, 124.8483007204849855, + 2.5464790894693578593, 34.041335944937600289, 125.12236487028349075, 54.770190386221656809, + 100.06444670839846367, 94.960421267365745734, 36.430576461789314635, 92.003069273487199098, + 39.274543045194150181, 117.55603914419407374, 110.53178973936155671, 118.53530616892385297, + 9.6761455275809566956, 76.557400471203436609, 57.955513261149462778, 119.74665876570725231, + 98.374991898977896199, 7.9671559794041968416, 32.651641298874892527, 125.61840188955466147, + 83.818601230061176466, 127.31804902801013668, 71.921477406107442221, 32.903304176943493076, + 75.66284069390167133, 15.776100407121703029, 51.017330629452771973, 87.881339565199596109, + 61.052847532762825722, 11.042834332271013409, 101.59969133618869819, 13.031520842356258072, + 1.2101533869499689899, 3.0416777864629693795, 12.586153491407458205, 24.83812762506204308, + 89.951038003498979378, 84.104707938702631509, 22.11192117241807864, 26.167528191541350679, + 23.984803497318353038, 25.953512277254048968, 121.51232694000646006, 122.30418147070668056, + 62.155495155006065033, 87.578017011175688822, 33.564399489296192769, 95.304118090691190446, + 65.050481265483540483, 90.806837193988030776, 74.82844273881346453, 0.095901194108591880649, + 92.472270110331010073, 3.0687851062139088754, 23.655103047658485593, 126.7806836967538402, + 15.944720546354801627, 50.335628061609895667, 70.20890853890159633, 42.182320803796756081, + 117.55783278726448771, 89.098201533473911695, 35.329509325092658401, 3.3803441509953700006, + 103.98740373003965942, 51.19012145045780926, 58.802855963691399666, 74.269833588215988129, + 47.975394322478678077, 73.700784801254485501, 87.867536439407558646, 18.32610732418106636, + 75.633188319712644443, 113.09920329121814575, 48.549680591804644791, 0.18478750593567383476, + 120.02363615007925546, 16.578491822838259395, 91.558433514244825346, 62.36382725305884378, + 35.303165637760685058, 85.129636252109776251, 22.665077249352179933, 51.655842545671475818, + 93.840346375684021041, 65.886898255979758687, 90.549556603520613862, 108.45614203624063521, + 83.742282248804258415, 19.136309302277368261, 28.676429899602226214, 67.519280561282357667, + 9.5044985722488490865, 34.805208574576681713, 17.696501916041597724, 21.658120909971330548, + 36.263061043566267472, 0.39956757225809269585, 103.05987365358669194, 99.849728548506391235, + 62.19490059576855856, 115.55489494126595673, 115.26970839931891533, 15.39095234652995714, + 59.040178104485676158, 61.713539497999590822, 119.132789058941853, 22.385073480141727487, + 30.314002513219747925, 60.653383685061271535, 23.193747277728107292, 6.796568028559704544, + 110.8219166813796619, 51.629779374499776168, 88.85744249462368316, 75.469885057405917905, + 93.241317826323211193, 8.3766365205738111399, 88.930367509430652717, 96.363014495658717351, + 118.60143839035299607, 55.466969479639374185, 72.935197548260475742, 39.640199042481981451, + 102.03173178372526309, 67.115523932247015182, 3.3642654143077379558, 37.165202620559284696, + 92.263209628203185275, 25.229098195726692211, 20.901935837246128358, 18.089171071922464762, + 89.520130264067120152, 0.13645707760952063836, 69.464509485642338404, 111.67738671714323573, + 116.64706961512274574, 99.164220256134285592, 41.033654720758931944, 100.34956789229909191, + 1.8666389130012248643, 63.87508032082405407, 73.759372584612719947, 16.483199292782956036, + 15.962174308042449411, 6.9340911392609996255, 25.159287325681361835, 110.18151462458263268, + 77.771120076798979426, 28.011055978135118494, 88.906489342549321009, 9.4999295440538844559, + 97.845236083161580609, 49.366786054513795534, 28.483703672955016373, 101.64182916747449781, + 45.730206055312009994, 80.626243186248757411, 118.51324768248741748, 35.322293596174858976, + 71.041205807519872906, 87.53544891785713844, 38.850702455605642172, 45.504005314764071954, + 60.009324076327175135, 73.544559337613463867, 21.125188575089850929, 24.571756926765374374, + 26.590472889332886552, 83.606764989504881669, 42.712954394028201932, 70.202622945569601143, + 34.851775586408621166, 93.052513640137476614, 33.679700552263966529, 12.787789754740515491, + 52.756174504138471093, 43.615228883219970157, 22.684507809106435161, 38.313980182614614023, + 35.09969250881113112, 49.093031832668202696, 36.700158065959840314, 97.225202390989579726, + 58.574101378337218193, 25.552085419229115359, 84.977968044797307812, 126.09220795122018899, + 62.284197024735476589, 16.735513520940003218, 98.431381280515779508, 107.03642982136079809, + 18.912516310632781824, 59.056662117822270375, 27.109765576075005811, 91.53009897778974846, + 23.492143642513838131, 127.52106996786824311, 60.360342852494795807, 3.972443989336170489, + 40.908547307069966337, 0.28774777104990789667, 123.41898838242195779, 0.59103487155152834021, + 42.615849874629930127, 80.565207347015530104, 125.89836113795900019, 63.718035552385117626, + 19.947816476691514254, 31.04185885185142979, 127.81426826194001478, 78.761904736475116806, + 47.32586633713071933, 115.42373342734208563, 91.746845772377128014, 2.8589787720047752373, + 28.834054423903580755, 100.86092522710168851, 75.977051395519083599, 88.043971699789835839, + 91.783027922880137339, 34.897617998420173535, 96.33757026926468825, 38.916657863795990124, + 123.07722172087960644, 9.9456815022458613385, 104.36027728472254239, 101.26283920222340384, + 44.478645191928080749, 35.298763273571239552, 0.011904552706255344674, 52.100249481536593521, + 3.3068053818897169549, 23.630811357386846794, 33.113462916600838071, 55.216708143940195441, + 104.69761815714082331, 58.661905765820847591, 112.08007085506687872, 44.505410293160821311, + 91.480378906231635483, 109.35575423256159411, 23.749743482541816775, 127.44773607359093148, + 10.572611873019923223, 103.75556581251657917, 21.781075316725036828, 52.778382058011629852, + 18.769475122186122462, 64.002203360996645642, 87.107146061800449388, 65.492718375015101628, + 65.75163532123042387, 6.0217630068145808764, 14.980938163254904794, 39.378240982092393097, + 1.9353043551273003686, 112.48859640313094133, 45.391101750985399121, 72.975353790068766102, + 111.71266018813548726, 34.764620727692090441, 19.85522819932521088, 72.761852975621877704, + 87.839710897365876008, 55.181996730767423287, 64.891172515341168037, 8.7649532751856895629, + 117.72635835608161869, 44.544894158902025083, 13.843748236638930393, 88.873872287818812765, + 77.818205999839847209, 53.807485982244543266, 35.900895858791045612, 31.936506648420618149, + 50.427066813630517572, 109.59010540405870415, 96.491783788533211919, 5.5102787919022375718, + 6.3187556473167205695, 0.73140429693376063369, 95.8709157340672391, 125.69591831263096537, + 110.63670575270225527, 61.25607463520282181, 54.771794716092699673, 22.707374683021043893, + 60.711491156685951864, 55.768235590749100083, 105.60769733289271244, 60.840703278219734784, + 23.766884028791537276, 95.652517906491993926, 44.526893903712334577, 53.213372840978991007, + 63.143870921081543202, 23.633065962330874754, 17.69018221428632387, 21.967532656861294527, + 45.081591029578703456, 97.072858969058870571, 86.776376134024758358, 119.05473784046989749, + 37.50550244592159288, 31.529430361661070492, 95.310008988446497824, 120.41353561952564633, + 23.476930124543287093, 92.450187302329140948, 56.092920025897910818, 55.542911101227218751, + 68.253835745566902915, 110.9318556079051632, 10.954631931494077435, 102.69996581680607051, + 21.15525255072498112, 96.198081243586784694, 54.134905020990117919, 27.571975074017245788, + 84.877350475548155373, 101.32041411674435949, 57.56612363934982568, 10.827657985337282298, + 98.124600597202515928, 54.561731133850116748, 74.509691346342151519, 27.577759424450050574, + 112.9133837846275128, 51.936752270885335747, 69.91513775094790617, 89.458098212784534553, + 98.04231921216705814, 67.448428232466540067, 3.2782272630211082287, 58.577585704486409668, + 39.645935008356900653, 14.270216142289427808, 41.29828055132747977, 10.122508389653376071, + 49.319710783962364076, 92.191599117915757233, 7.3791577397278160788, 67.271728655301558319, + 14.252351888673729263, 60.446812882535596145, 62.359919327933312161, 104.30109881970201968, + 100.51286177929068799, 12.601201766618032707, 92.31891464375439682, 123.73506374344287906, + 106.33066753372986568, 52.353370938519219635, 116.2994616567666526, 4.8760829559505509678, + 46.265193785067822319, 58.689945670084853191, 42.616047709812846733, 106.13752302508873981, + 87.357391925401316257, 75.004318911491282051, 44.289461625474359607, 90.894364979889360256, + 110.1273048284529068, 89.227408029139041901, 119.00320946913780062, 9.668459895587147912, + 3.5195030445065640379, 121.69660144096997101, 5.0929581789387157187, 68.082671889878838556, + 122.24472974056698149, 109.5403807724469516, 72.128893416800565319, 61.920842534731491469, + 72.861152923582267249, 56.006138546974398196, 78.549086090391938342, 107.11207828839178546, + 93.063579478726751404, 109.07061233784770593, 19.35229105516555137, 25.114800942406873219, + 115.91102652230256354, 111.49331753141814261, 68.749983797955792397, 15.934311958808393683, + 65.303282597753423033, 123.23680377911296091, 39.63720246012599091, 126.63609805602391134, + 15.842954812214884441, 65.80660835389062413, 23.325681387803342659, 31.552200814243406057, + 102.03466125890918192, 47.762679130399192218, 122.10569506552565144, 22.085668664545664797, + 75.199382672377396375, 26.063041684712516144, 2.4203067738999379799, 6.083355572925938759, + 25.17230698281491641, 49.676255250127724139, 51.902076007001596736, 40.209415877405263018, + 44.223842344836157281, 52.335056383082701359, 47.969606994636706077, 51.907024554511735914, + 115.02465388001655811, 116.60836294141336111, 124.31099031001576805, 47.156034022351377644, + 67.128798978596023517, 62.60823618138601887, 2.1009625309707189444, 53.613674387979699532, + 21.65688547762692906, 0.19180238822082174011, 56.944540220662020147, 6.1375702124278177507, + 47.310206095320609165, 125.56136739350768039, 31.889441092709603254, 100.67125612322342931, + 12.41781707780319266, 84.364641607597150141, 107.11566557453261339, 50.19640306694782339, + 70.659018650185316801, 6.76068830199437798, 79.974807460079318844, 102.38024290091561852, + 117.60571192738643731, 20.539667176431976259, 95.950788644960994134, 19.401569602512608981, + 47.735072878815117292, 36.652214648365770699, 23.266376639428926865, 98.198406582436291501, + 97.099361183609289583, 0.36957501187498564832, 112.04727230015851092, 33.156983645680156769, + 55.116867028489650693, 124.72765450611768756, 70.606331275525008095, 42.259272504219552502, + 45.330154498704359867, 103.31168509134658962, 59.68069275137168006, 3.7737965119631553534, + 53.099113207044865703, 88.912284072484908393, 39.484564497608516831, 38.272618604554736521, + 57.352859799208090408, 7.0385611225647153333, 19.008997144497698173, 69.610417149153363425, + 35.393003832083195448, 43.316241819942661095, 72.526122087132534944, 0.7991351445198233705, + 78.119747307177021867, 71.699457097012782469, 124.3898011915407551, 103.10978988253555144, + 102.53941679863783065, 30.78190469305991428, 118.08035620897135232, 123.42707899600281962, + 110.265578117883706, 44.770146960283454973, 60.62800502643949585, 121.30676737012254307, + 46.387494555456214584, 13.593136057123047067, 93.643833362759323791, 103.25955874900319031, + 49.714884989251004299, 22.939770114815473789, 58.482635652646422386, 16.753273041151260259, + 49.860735018864943413, 64.726028991321072681, 109.20287678070599213, 110.93393895928238635, + 17.870395096520951483, 79.28039808496760088, 76.063463567454164149, 6.2310478644940303639, + 6.7285308286154759116, 74.330405241122207372, 56.52641925640637055, 50.458196391453384422, + 41.803871674492256716, 36.178342143848567503, 51.040260528134240303, 0.27291415522267925553, + 10.929018971288314788, 95.354773434290109435, 105.29413923024912947, 70.328440512268571183, + 82.067309441521501867, 72.699135784598183818, 3.7332778260024497285, 127.75016064165174612, + 19.518745169225439895, 32.966398585565912072, 31.924348616084898822, 13.868182278521999251, + 50.31857465136636165, 92.363029249168903334, 27.542240153597958852, 56.022111956273874966, + 49.812978685098642018, 18.999859088111406891, 67.690472166323161218, 98.733572109027591068, + 56.967407345913670724, 75.283658334948995616, 91.460412110627657967, 33.2524863725011528, + 109.02649536497483496, 70.644587192353355931, 14.08241161504338379, 47.07089783571427688, + 77.701404911211284343, 91.008010629528143909, 120.01864815265798825, 19.089118675226927735, + 42.250377150179701857, 49.143513853530748747, 53.180945778669411084, 39.213529979009763338, + 85.425908788060041843, 12.405245891139202286, 69.703551172820880311, 58.105027280274953227, + 67.359401104527933057, 25.575579509481030982, 105.51234900827694219, 87.230457766439940315, + 45.369015618212870322, 76.627960365229228046, 70.199385017622262239, 98.186063665336405393, + 73.400316131923318608, 66.450404781979159452, 117.14820275667443639, 51.104170838461868698, + 41.955936089598253602, 124.18441590244037798, 124.56839404947095318, 33.471027041883644415, + 68.862762561035196995, 86.072859642721596174, 37.825032621265563648, 118.11332423564454075, + 54.2195311521536496, 55.06019795557949692, 46.984287285031314241, 127.04213993573648622, + 120.72068570498959161, 7.9448879786723409779, 81.817094614139932673, 0.57549554210345377214, + 118.83797676484391559, 1.1820697431030566804, 85.231699749263498234, 33.130414694034698186, + 123.79672227591800038, 127.43607110477023525, 39.895632953383028507, 62.083717703706497559, + 127.62853652388366754, 29.523809472950233612, 94.651732674265076639, 102.84746685468780925, + 55.493691544754256029, 5.7179575440095504746, 57.668108847810799489, 73.721850454207014991, + 23.954102791041805176, 48.087943399583309656, 55.566055845760274678, 69.795235996843985049, + 64.675140538529376499, 77.833315727595618227, 118.15444344175921287, 19.891363004495360656, + 80.720554569448722759, 74.52567840444680769, 88.957290383856161498, 70.597526547142479103, + 0.023809105412510689348, 104.20049896307318704, 6.6136107637794339098, 47.261622714773693588, + 66.226925833201676141, 110.43341628788402886, 81.395236314281646628, 117.32381153164533316, + 96.160141710133757442, 89.010820586325280601, 54.960757812466908945, 90.711508465123188216, + 47.499486965087271528, 126.89547214718186297, 21.145223746043484425, 79.511131625033158343, + 43.562150633450073656, 105.5567641160232597, 37.538950244375882903, 0.0044067219969292636961, + 46.214292123604536755, 2.9854367500338412356, 3.5032706424608477391, 12.043526013629161753, + 29.961876326509809587, 78.756481964184786193, 3.8706087102582387161, 96.977192806261882652, + 90.782203501974436222, 17.950707580141170183, 95.425320376270974521, 69.529241455384180881, + 39.71045639865405974, 17.523705951247393386, 47.679421794731752016, 110.36399346153848455, + 1.7823450306823360734, 17.529906550375017105, 107.45271671216323739, 89.089788317804050166, + 27.687496473281498766, 49.747744575641263509, 27.636411999679694418, 107.61497196448908653, + 71.801791717582091223, 63.873013296841236297, 100.85413362726467312, 91.180210808121046284, + 64.983567577066423837, 11.020557583804475144, 12.637511294633441139, 1.4628085938711592462, + 63.741831468138116179, 123.39183662526556873, 93.273411505404510535, 122.51214927040564362, + 109.54358943218539935, 45.414749366042087786, 121.42298231337190373, 111.53647118150183815, + 83.215394665785424877, 121.68140655643946957, 47.53376805758671253, 63.305035812983987853, + 89.053787807424669154, 106.42674568195798201, 126.2877418421630864, 47.266131924661749508, + 35.380364428572647739, 43.935065313722589053, 90.16318205916104489, 66.14571793812137912, + 45.552752268053154694, 110.10947568093979498, 75.01100489184318576, 63.058860723325778963, + 62.620017976896633627, 112.82707123905129265, 46.953860249090212164, 56.900374604658281896, + 112.18584005179582164, 111.08582220245807548, 8.5076714911374438088, 93.863711215810326394, + 21.909263862991792848, 77.399931633612141013, 42.310505101453600219, 64.396162487173569389, + 108.26981004198023584, 55.143950148038129555, 41.754700951099948725, 74.640828233488718979, + 115.13224727869965136, 21.655315970678202575, 68.249201194405031856, 109.12346226770387148, + 21.019382692684303038, 55.155518848903739126, 97.826767569255025592, 103.87350454177430947, + 11.830275501899450319, 50.916196425572707085, 68.084638424337754259, 6.8968564649330801331, + 6.5564545260422164574, 117.15517140897281934, 79.291870016713801306, 28.540432284578855615, + 82.596561102654959541, 20.245016779306752142, 98.63942156792836613, 56.383198235831514467, + 14.758315479459270136, 6.543457310603116639, 28.504703777347458526, 120.89362576507119229, + 124.7198386558702623, 80.602197639407677343, 73.025723558581375983, 25.202403533239703393, + 56.63782928751243162, 119.4701274868893961, 84.661335067459731363, 104.70674187704207725, + 104.59892331353330519, 9.7521659119011019357, 92.530387570135644637, 117.37989134016970638, + 85.232095419629331445, 84.275046050181117607, 46.714783850806270493, 22.008637822982564103, + 88.578923250952357193, 53.788729959782358492, 92.254609656909451587, 50.45481605828172178, + 110.00641893827560125, 19.336919791174295824, 7.0390060890167660546, 115.39320288194358, + 10.185916357881069416, 8.1653437797613150906, 116.48945948113760096, 91.080761544897541171, + 16.257786833601130638, 123.84168506946662092, 17.722305847164534498, 112.01227709395243437, + 29.098172180787514662, 86.224156576787208905, 58.127158957457140787, 90.141224675695411861, + 38.70458211033110274, 50.229601884817384416, 103.82205304460876505, 94.986635062839923194, + 9.4999675959115847945, 31.868623917620425345, 2.6065651955104840454, 118.47360755822592182, + 79.2744049202556198, 125.27219611204782268, 31.685909624433406861, 3.6132167077812482603, + 46.651362775606685318, 63.104401628490450094, 76.069322517818363849, 95.525358260802022414, + 116.21139013105130289, 44.171337329094967572, 22.39876534475479275, 52.126083369425032288, + 4.8406135477998759598, 12.166711145851877518, 50.344613965629832819, 99.352510500255448278, + 103.80415201400319347, 80.418831754810526036, 88.447684689672314562, 104.67011276616540272, + 95.939213989273412153, 103.81404910902710981, 102.04930776003675419, 105.21672588283036021, + 120.62198062003153609, 94.312068044706393266, 6.2575979571920470335, 125.21647236277203774, + 4.2019250619414378889, 107.22734877595939906, 43.313770955253858119, 0.38360477644164348021, + 113.88908044132404029, 12.275140424855635501, 94.62041219064485631, 123.12273478701536078, + 63.778882185422844486, 73.342512246446858626, 24.835634155610023299, 40.729283215197938262, + 86.231331149065226782, 100.39280613389928476, 13.318037300370633602, 13.521376603992393939, + 31.949614920162275666, 76.760485801834875019, 107.21142385477287462, 41.079334352867590496, + 63.901577289921988267, 38.803139205025217962, 95.470145757630234584, 73.304429296731541399, + 46.532753278861491708, 68.396813164876220981, 66.198722367218579166, 0.73915002375360927545, + 96.094544600317021832, 66.313967291360313538, 110.23373405698293936, 121.4553090122390131, + 13.212662551050016191, 84.518545008439105004, 90.660308997412357712, 78.623370182693179231, + 119.36138550274336012, 7.5475930239263107069, 106.19822641409336939, 49.824568144969816785, + 78.969128995217033662, 76.545237209109473042, 114.70571959841618082, 14.077122245129430667, + 38.017994288999034325, 11.220834298306726851, 70.786007664166390896, 86.63248363988896017, + 17.052244174265069887, 1.5982702890432847198, 28.239494614357681712, 15.398914194029202918, + 120.77960238308514818, 78.219579765074740862, 77.078833597275661305, 61.563809386123466538, + 108.16071241794634261, 118.85415799200927722, 92.531156235767411999, 89.540293920566909947, + 121.25601005288262968, 114.61353474024508614, 92.774989110912429169, 27.186272114249732113, + 59.28766672552228556, 78.519117498006380629, 99.429769978502008598, 45.879540229630947579, + 116.96527130529284477, 33.506546082302520517, 99.721470037733524805, 1.4520579826457833406, + 90.405753561415622244, 93.867877918564772699, 35.740790193045540946, 30.560796169938839739, + 24.126927134908328298, 12.462095728988060728, 13.457061657234589802, 20.660810482244414743, + 113.0528385128127411, 100.91639278290676884, 83.607743348984513432, 72.356684287697135005, + 102.08052105626848061, 0.54582831044535851106, 21.858037942580267554, 62.709546868583856849, + 82.588278460501896916, 12.656881024540780345, 36.134618883046641713, 17.398271569196367636, + 7.4665556520085374359, 127.50032128330349224, 39.03749033845087979, 65.932797171131824143, + 63.848697232169797644, 27.736364557043998502, 100.63714930273636128, 56.726058498337806668, + 55.084480307195917703, 112.04422391254774993, 99.625957370197284035, 37.99971817622645176, + 7.3809443326499604154, 69.467144218055182137, 113.93481469183097943, 22.567316669901629211, + 54.920824221255315933, 66.50497274500594358, 90.052990729953307891, 13.289174384706711862, + 28.16482323008676758, 94.141795671432191739, 27.402809822426206665, 54.016021259059925796, + 112.0372963053159765, 38.17823735045385547, 84.500754300359403715, 98.287027707061497495, + 106.36189155733882217, 78.427059958023164654, 42.851817576120083686, 24.81049178228204255, + 11.407102345641760621, 116.21005456055354443, 6.7188022090558661148, 51.151159018965699943, + 83.024698016557522351, 46.460915532879880629, 90.738031236429378623, 25.25592073046209407, + 12.398770035248162458, 68.372127330676448764, 18.800632263850275194, 4.9008095639619568828, + 106.29640551334887277, 102.2083416769237374, 83.911872179200145183, 120.36883180488439393, + 121.13678809894190636, 66.942054083770926809, 9.7255251220740319695, 44.145719285443192348, + 75.650065242534765275, 108.2266484712890815, 108.4390623043072992, 110.12039591115899384, + 93.96857457006626646, 126.08427987147661042, 113.44137140997918323, 15.889775957348319935, + 35.634189228279865347, 1.1509910842105455231, 109.67595352968783118, 2.3641394862097513396, + 42.463399498526996467, 66.260829388073034352, 119.59344455183963873, 126.8721422095404705, + 79.791265906766057014, 124.1674354074166331, 127.25707304776733508, 59.047618945904105203, + 61.303465348533791257, 77.694933709375618491, 110.98738308950851206, 11.435915088019100949, + 115.33621769562523696, 19.443700908414029982, 47.908205582083610352, 96.175886799166619312, + 111.13211169152418734, 11.590471993691608077, 1.3502810770623909775, 27.666631455194874434, + 108.30888688351842575, 39.78272600899435929, 33.441109138901083497, 21.051356808897253359, + 49.914580767715960974, 13.195053094284958206, 0.047618210828659357503, 80.400997926146374084, + 13.22722152755886782, 94.523245429551025154, 4.4538516664069902617, 92.866832575771695701, + 34.790472628566931235, 106.6476230632943043, 64.320283420271152863, 50.021641172650561202, + 109.92151562493745587, 53.423016930246376432, 94.998973930178181035, 125.79094429436372593, + 42.290447492090606829, 31.022263250066316687, 87.12430126690378529, 83.113528232046519406, + 75.077900488751765806, 0.0088134439938585273921, 92.42858424720907351, 5.9708735000676824711, + 7.0065412849216954783, 24.087052027258323506, 59.923752653023257153, 29.512963928369572386, + 7.7412174205201154109, 65.954385612527403282, 53.564407003948872443, 35.901415160285978345, + 62.85064075254558702, 11.058482910768361762, 79.42091279730811948, 35.047411902494786773, + 95.35884358946714201, 92.727986923076969106, 3.5646900613646721467, 35.059813100753672188, + 86.905433424330112757, 50.179576635608100332, 55.374992946562997531, 99.495489151282527018, + 55.272823999363026815, 87.229943928981811041, 15.603583435164182447, 127.74602659368611057, + 73.708267254532984225, 54.360421616245730547, 1.9671351541328476742, 22.041115167608950287, + 25.275022589266882278, 2.9256171877423184924, 127.48366293627987034, 118.78367325053477543, + 58.546823010812659049, 117.02429854081492522, 91.087178864370798692, 90.829498732087813551, + 114.84596462674744544, 95.07294236300731427, 38.430789331574487733, 115.36281311287893914, + 95.06753611517342506, 126.61007162597161368, 50.107575614852976287, 84.853491363919602009, + 124.57548368432617281, 94.532263849323499016, 70.760728857145295478, 87.870130627448816085, + 52.326364118325727759, 4.2914358762427582406, 91.105504536109947367, 92.218951361883227946, + 22.02200978368637152, 126.11772144665155793, 125.24003595379690523, 97.654142478102585301, + 93.907720498180424329, 113.80074920932020177, 96.371680103595281253, 94.171644404916150961, + 17.015342982278525596, 59.727422431620652787, 43.818527725987223675, 26.799863267224282026, + 84.621010202910838416, 0.79232497435077675618, 88.539620083960471675, 110.28790029607625911, + 83.509401902203535428, 21.281656466981075937, 102.26449455739930272, 43.310631941360043129, + 8.4984023888137016911, 90.246924535407742951, 42.038765385368606076, 110.31103769781111623, + 67.653535138513689162, 79.747009083548618946, 23.660551003798900638, 101.83239285114905215, + 8.1692768486755085178, 13.793712929866160266, 13.112909052088070894, 106.31034281794927665, + 30.583740033427602611, 57.080864569161349209, 37.193122205309919082, 40.490033558617142262, + 69.27884313585673226, 112.76639647166302893, 29.516630958918540273, 13.086914621206233278, + 57.009407554698555032, 113.78725153014602256, 121.43967731174416258, 33.204395278818992665, + 18.051447117162751965, 50.404807066479406785, 113.27565857502850122, 110.94025497378243017, + 41.322670134923100704, 81.413483754087792477, 81.197846627066610381, 19.50433182380584185, + 57.060775140274927253, 106.75978268034305074, 42.464190839262300869, 40.550092100362235215, + 93.429567701612540986, 44.017275645968766185, 49.157846501904714387, 107.57745991956835496, + 56.509219313818903174, 100.90963211656708154, 92.012837876551202498, 38.673839582348591648, + 14.078012178037170088, 102.78640576389079797, 20.371832715762138832, 16.33068755952626816, + 104.9789189622788399, 54.161523089795082342, 32.515573667205899255, 119.68337013893324183, + 35.444611694332706975, 96.024554187904868741, 58.196344361578667304, 44.448313153574417811, + 116.25431791491791955, 52.282449351390823722, 77.40916422066220548, 100.45920376963840681, + 79.644106089221168077, 61.973270125679846387, 18.999935191823169589, 63.737247835240850691, + 5.2131303910246060695, 108.94721511645548162, 30.548809840514877578, 122.54439222409564536, + 63.371819248866813723, 7.2264334155624965206, 93.302725551213370636, 126.20880325698453817, + 24.138645035640365677, 63.050716521607682807, 104.42278026210260577, 88.342674658189935144, + 44.7975306895095855, 104.25216673885006458, 9.6812270955997519195, 24.333422291703755036, + 100.68922793126330362, 70.705021000514534535, 79.608304028010024922, 32.83766350962469005, + 48.895369379348267103, 81.340225532334443415, 63.878427978550462285, 79.628098218057857594, + 76.098615520077146357, 82.43345176566435839, 113.24396124006671016, 60.624136089412786532, + 12.515195914387732046, 122.43294472554407548, 8.4038501238865137566, 86.454697551918798126, + 86.627541910507716238, 0.76720955288692493923, 99.778160882648080587, 24.550280849714908982, + 61.240824381293350598, 118.24546957403072156, 127.55776437084932695, 18.685024492893717252, + 49.671268311220046598, 81.458566430399514502, 44.462662298134091543, 72.785612267798569519, + 26.636074600741267204, 27.042753207984787878, 63.899229840328189312, 25.520971603673388017, + 86.42284770954574924, 82.158668705735180993, 127.80315457984397653, 77.606278410054073902, + 62.940291515264107147, 18.608858593463082798, 93.065506557726621395, 8.7936263297560799401, + 4.3974447344371583313, 1.4783000475108565297, 64.189089200637681643, 4.6279345827242650557, + 92.467468113969516708, 114.9106180244780262, 26.425325102103670361, 41.037090016881847987, + 53.320617994828353403, 29.246740365389996441, 110.72277100548672024, 15.095186047856259393, + 84.39645282818673877, 99.649136289943271549, 29.938257990437705303, 25.090474418222584063, + 101.41143919683236163, 28.154244490258861333, 76.035988577998068649, 22.44166859661709168, + 13.57201532833641977, 45.264967279777920339, 34.104488348530139774, 3.1965405780865694396, + 56.478989228715363424, 30.797828388062043814, 113.55920476617393433, 28.439159530153119704, + 26.157667194551322609, 123.12761877225057106, 88.321424835896323202, 109.70831598402219242, + 57.062312471538461978, 51.080587841137457872, 114.51202010576889734, 101.22706948049381026, + 57.549978221824858338, 54.372544228499464225, 118.5753334510482091, 29.038234996016399236, + 70.859539957004017197, 91.759080459265533136, 105.93054261058568954, 67.013092164608679013, + 71.44294007546704961, 2.9041159652952046599, 52.811507122834882466, 59.735755837129545398, + 71.481580386091081891, 61.121592339877679478, 48.253854269816656597, 24.924191457976121455, + 26.914123314469179604, 41.321620964492467465, 98.10567702562912018, 73.832785565817175666, + 39.215486697972664842, 16.713368575397907989, 76.161042112536961213, 1.0916566208907170221, + 43.716075885160535108, 125.41909373717135168, 37.176556921003793832, 25.31376204908156069, + 72.269237766093283426, 34.796543138392735273, 14.933111304020712851, 127.00064256660698447, + 78.074980676905397559, 3.8655943422636482865, 127.69739446433959529, 55.472729114091634983, + 73.274298605472722556, 113.45211699667561334, 110.16896061439547339, 96.088447825099137845, + 71.251914740394568071, 75.99943635245290352, 14.76188866530355881, 10.934288436114002252, + 99.869629383661958855, 45.134633339803258423, 109.84164844251426985, 5.009945490015525138, + 52.105981459906615783, 26.578348769413423724, 56.32964646017717314, 60.283591342864383478, + 54.80561964485241333, 108.03204251812348957, 96.074592610631952994, 76.356474700911348918, + 41.001508600722445408, 68.574055414126632968, 84.723783114681282314, 28.854119916046329308, + 85.703635152240167372, 49.6209835645640851, 22.814204691287159221, 104.42010912110708887, + 13.43760441811173223, 102.30231803793503786, 38.049396033115044702, 92.921831065763399238, + 53.476062472858757246, 50.511841460924188141, 24.797540070499962894, 8.7442546613528975286, + 37.601264527700550389, 9.8016191279275517445, 84.592811026701383526, 76.41668335385111277, + 39.823744358403928345, 112.73766360977242584, 114.27357619788745069, 5.8841081675418536179, + 19.451050244148063939, 88.291438570890022675, 23.300130485073168529, 88.453296942581800977, + 88.87812460861823638, 92.240791822321625659, 59.937149140136170899, 124.16855974295685883, + 98.882742819958366454, 31.779551914696639869, 71.268378456559730694, 2.301982168424729025, + 91.351907059375662357, 4.7282789724195026793, 84.926798997057630913, 4.5216587761497066822, + 111.18688910368291545, 125.74428441908457899, 31.582531813535752008, 120.33487081483690417, + 126.51414609553467017, 118.09523789180821041, 122.60693069707122049, 27.389867418754874961, + 93.974766179017024115, 22.871830176041839877, 102.67243539125047391, 38.887401816828059964, + 95.816411164170858683, 64.351773598336876603, 94.264223383048374671, 23.180943987383216154, + 2.700562154124781955, 55.333262910393386846, 88.617773767036851496, 79.56545201798871858, + 66.882218277802166995, 42.102713617794506717, 99.829161535431921948, 26.390106188569916412, + 0.095236421660956693813, 32.801995852292748168, 26.454443055121373618, 61.046490859102050308, + 8.9077033328176185023, 57.733665151543391403, 69.580945257137500448, 85.295246126592246583, + 0.64056684054230572656, 100.04328234530476038, 91.843031249874911737, 106.84603386049639084, + 61.99794786036000005, 123.58188858872745186, 84.580894984181213658, 62.044526500136271352, + 46.248602533811208559, 38.227056464096676791, 22.155800977503531612, 0.017626887991355033591, + 56.85716849441814702, 11.941747000135364942, 14.013082569843390957, 48.174104054516647011, + 119.84750530604651431, 59.025927856739144772, 15.482434841043868801, 3.908771225054806564, + 107.12881400789774489, 71.80283032057195669, 125.70128150509117404, 22.116965821540361503, + 30.841825594616238959, 70.094823804993211525, 62.717687178937921999, 57.455973846153938212, + 7.1293801227293442935, 70.119626201510982355, 45.810866848660225514, 100.35915327121620066, + 110.74998589312963304, 70.990978302565054037, 110.54564799872969161, 46.459887857963622082, + 31.207166870332002873, 127.49205318737585912, 19.41653450906596845, 108.72084323249146109, + 3.9342703082656953484, 44.082230335217900574, 50.550045178533764556, 5.8512343754882749636, + 126.96732587256337865, 109.56734650106955087, 117.09364602162895608, 106.04859708163348841, + 54.174357728745235363, 53.65899746417926508, 101.69192925349852885, 62.145884726014628541, + 76.861578663152613444, 102.72562622576151625, 62.135072230350488098, 125.22014325194322737, + 100.21515122970959055, 41.706982727842841996, 121.15096736865598359, 61.064527698650636012, + 13.521457714294228936, 47.74026125489763217, 104.65272823665145552, 8.5828717524891544599, + 54.211009072223532712, 56.437902723766455892, 44.044019567376381019, 124.23544289330675383, + 122.48007190759744844, 67.30828495620880858, 59.815440996364486637, 99.601498418644041521, + 64.743360207194200484, 60.343288809832301922, 34.030685964557051193, 119.45484486324130557, + 87.637055451974447351, 53.599726534452202031, 41.242020405821676832, 1.5846499487051914912, + 49.079240167924581328, 92.575800592156156199, 39.018803804407070857, 42.563312933965789853, + 76.528989114798605442, 86.621263882720086258, 16.996804777631041361, 52.493849070815485902, + 84.07753077074085013, 92.622075395625870442, 7.3070702770310163032, 31.494018167097237892, + 47.321102007601439254, 75.664785702298104297, 16.338553697351017036, 27.587425859732320532, + 26.225818104179779766, 84.620685635898553301, 61.167480066855205223, 114.16172913832269842, + 74.386244410619838163, 80.980067117237922503, 10.5576862717171025, 97.532792943326057866, + 59.033261917837080546, 26.173829242412466556, 114.01881510940074804, 99.574503060295683099, + 114.87935462348832516, 66.40879055763798533, 36.10289423432550393, 100.80961413296245155, + 98.551317150060640415, 93.88050994756486034, 82.645340269849839387, 34.826967508179222932, + 34.395693254133220762, 39.0086636476116837, 114.12155028055349248, 85.519565360686101485, + 84.928381678524601739, 81.100184200728108408, 58.859135403225081973, 88.034551291937532369, + 98.315693003813066753, 87.154919839136709925, 113.01843862764144433, 73.819264233137801057, + 56.025675753102404997, 77.347679164697183296, 28.156024356077978155, 77.57281152778523392, + 40.743665431524277665, 32.661375119056174299, 81.957837924557679798, 108.32304617959016468, + 65.03114733441543649, 111.36674027786648367, 70.889223388669051928, 64.049108375809737481, + 116.39268872315733461, 88.896626307152473601, 104.5086358298358391, 104.56489870278528542, + 26.818328441328048939, 72.918407539280451601, 31.288212178442336153, 123.94654025135969277, + 37.999870383646339178, 127.47449567048170138, 10.426260782052850118, 89.894430232910963241, + 61.097619681033393135, 117.08878444819129072, 126.74363849773362745, 14.45286683112863102, + 58.605451102430379251, 124.41760651396907633, 48.277290071280731354, 126.10143304321900359, + 80.845560524208849529, 48.685349316379870288, 89.595061379022808978, 80.504333477700129151, + 19.362454191199503839, 48.666844583411148051, 73.378455862530245213, 13.410042001032707049, + 31.216608056020049844, 65.675327019249380101, 97.790738758700172184, 34.680451064668886829, + 127.75685595710456255, 31.256196436119353166, 24.197231040157930693, 36.86690353133235476, + 98.487922480133420322, 121.24827217882557306, 25.03039182877910207, 116.86588945108815096, + 16.807700247776665492, 44.909395103841234231, 45.255083821015432477, 1.5344191057774878573, + 71.556321765296161175, 49.100561699429817963, 122.48164876259033917, 108.4909391480650811, + 127.1155287416986539, 37.370048985787434503, 99.342536622443731176, 34.917132860799029004, + 88.925324596271821065, 17.571224535597139038, 53.272149201482534409, 54.085506415969575755, + 127.79845968065637862, 51.041943207350414013, 44.845695419095136458, 36.317337411473999964, + 127.60630915969159105, 27.212556820108147804, 125.88058303052821429, 37.217717186929803574, + 58.13101311545324279, 17.58725265951215988, 8.7948894688743166625, 2.9566000950253510382, + 0.37817840127536328509, 9.2558691654521680903, 56.934936227942671394, 101.8212360489560524, + 52.850650204207340721, 82.074180033763695974, 106.64123598965670681, 58.493480730783630861, + 93.445542010973440483, 30.190372095716156764, 40.79290565637711552, 71.298272579886543099, + 59.876515980875410605, 50.180948836448806105, 74.822878393664723262, 56.308488980521360645, + 24.071977155996137299, 44.88333719323418336, 27.144030656672839541, 90.529934559555840679, + 68.208976697060279548, 6.3930811561731388792, 112.95797845743072685, 61.595656776127725607, + 99.118409532347868662, 56.878319060306239408, 52.315334389106283197, 118.25523754450478009, + 48.642849671796284383, 91.416631968044384848, 114.12462494307692396, 102.16117568227855372, + 101.02404021154143265, 74.454138960987620521, 115.09995644364971668, 108.74508845700256643, + 109.1506669020964182, 58.076469992036436452, 13.719079914011672372, 55.518160918534704251, + 83.861085221175017068, 6.0261843292209960055, 14.88588015093409922, 5.8082319305904093198, + 105.62301424566976493, 119.47151167426272877, 14.963160772182163782, 122.24318467975535896, + 96.507708539633313194, 49.848382915952242911, 53.828246628938359208, 82.643241928988572909, + 68.21135405126187834, 19.665571131634351332, 78.430973395945329685, 33.426737150799453957, + 24.322084225073922426, 2.1833132417814340442, 87.432151770324708195, 122.83818747434270335, + 74.353113842007587664, 50.627524098166759359, 16.538475532186566852, 69.593086276785470545, + 29.86622260804506368, 126.00128513321760693, 28.149961353810795117, 7.7311886845309345517, + 127.39478892867919058, 110.94545822818690795, 18.548597210949083092, 98.904233993354864651, + 92.337921228794584749, 64.176895650201913668, 14.50382948079277412, 23.998872704905807041, + 29.523777330607117619, 21.868576872231642483, 71.739258767323917709, 90.269266679610154824, + 91.683296885028539691, 10.019890980031050276, 104.21196291981323157, 53.156697538826847449, + 112.65929292035434628, 120.56718268572876696, 109.61123928970846464, 88.064085036250617122, + 64.149185221267543966, 24.712949401822697837, 82.003017201448528795, 9.1481108282569039147, + 41.447566229362564627, 57.708239832096296595, 43.407270304480334744, 99.2419671291281702, + 45.628409382577956421, 80.840218242214177735, 26.875208836227102438, 76.604636075870075729, + 76.098792066233727382, 57.843662131526798476, 106.95212494571751449, 101.02368292184837628, + 49.595080140999925788, 17.488509322705795057, 75.202529055401100777, 19.603238255858741468, + 41.18562205340640503, 24.83336670770222554, 79.647488716811494669, 97.475327219548489666, + 100.54715239577490138, 11.768216335083707236, 38.902100488299765857, 48.582877141780045349, + 46.600260970149975037, 48.906593885167239932, 49.756249217240110738, 56.481583644643251318, + 119.87429828027597978, 120.33711948591735563, 69.765485639916732907, 63.559103829396917718, + 14.536756913119461387, 4.6039643368530960288, 54.703814118751324713, 9.4565579448426433373, + 41.853597994115261827, 9.0433175523030513432, 94.373778207369468873, 123.48856883816915797, + 63.165063627075141994, 112.66974162967744633, 125.02829219107297831, 108.19047578362005879, + 117.21386139414244099, 54.779734837513387902, 59.949532358034048229, 45.743660352087317733, + 77.344870782500947826, 77.774803633659757907, 63.632822328345355345, 0.70354719667739118449, + 60.528446766096749343, 46.361887974766432308, 5.4011243082495639101, 110.66652582079041167, + 49.23554753407734097, 31.13090403598107514, 5.7644365556043339893, 84.205427235592651414, + 71.658323070863843895, 52.780212377139832824, 0.19047284332191338763, 65.603991704585496336, + 52.908886110242747236, 122.09298171820410062, 17.815406665635237005, 115.46733030309042078, + 11.161890514278638875, 42.590492253184493165, 1.2811336810882494319, 72.086564690613158746, + 55.686062499753461452, 85.692067720992781688, 123.99589572072363808, 119.1637771774585417, + 41.161789968362427317, 124.0890530002725427, 92.497205067622417118, 76.454112928193353582, + 44.311601955007063225, 0.035253775982710067183, 113.71433698883629404, 23.883494000270729885, + 28.026165139686781913, 96.348208109036932001, 111.69501061209302861, 118.05185571347828954, + 30.964869682087737601, 7.8175424501132511068, 86.257628015799127752, 15.60566064114755136, + 123.40256301018234808, 44.233931643080723006, 61.683651189236115897, 12.189647609986423049, + 125.435374357875844, 114.91194769230787642, 14.258760245462326566, 12.23925240302196471, + 91.621733697324089007, 72.718306542436039308, 93.499971786262904061, 13.981956605133746052, + 93.091295997459383216, 92.919775715927244164, 62.414333740667643724, 126.98410637475171825, + 38.833069018135574879, 89.441686464982922189, 7.8685406165313906968, 88.164460670435801148, + 101.10009035706752911, 11.702468750980187906, 125.93465174513039528, 91.134693002142739715, + 106.18729204326155013, 84.09719416326697683, 108.34871545749047073, 107.31799492836216814, + 75.383858506997057702, 124.29176945203289506, 25.723157326308864867, 77.451252451523032505, + 124.27014446070461418, 122.44028650389009272, 72.430302459419181105, 83.413965455689321971, + 114.30193473731196718, 122.12905539730127202, 27.042915428588457871, 95.48052250979890232, + 81.305456473302911036, 17.16574350497830892, 108.42201814444706542, 112.87580544753291178, + 88.088039134756400017, 120.47088578661714564, 116.96014381519853487, 6.6165699124176171608, + 119.63088199273261125, 71.202996837291721022, 1.4867204143884009682, 120.68657761966460384, + 68.061371929117740365, 110.90968972648624913, 47.274110903948894702, 107.19945306890440406, + 82.484040811643353663, 3.1692998974103829823, 98.158480335852800636, 57.151601184312312398, + 78.037607608814141713, 85.126625867935217684, 25.057978229600848863, 45.242527765440172516, + 33.993609555262082722, 104.98769814163460978, 40.155061541485338239, 57.244150791251740884, + 14.614140554062032606, 62.988036334194475785, 94.642204015206516488, 23.329571404596208595, + 32.677107394702034071, 55.174851719464641064, 52.451636208363197511, 41.241371271797106601, + 122.33496013371404842, 100.32345827664903481, 20.772488821243314305, 33.960134234475845005, + 21.115372543437842978, 67.065585886652115732, 118.06652383567416109, 52.34765848482857109, + 100.03763021880513406, 71.149006120595004177, 101.7587092469802883, 4.8175811152759706602, + 72.20578846865464584, 73.619228265928541077, 69.102634300124918809, 59.761019895133358659, + 37.290680539699678775, 69.653935016358445864, 68.791386508266441524, 78.017327295227005379, + 100.24310056111062295, 43.039130721375840949, 41.856763357052841457, 34.200368401456216816, + 117.71827080645380192, 48.069102583878702717, 68.631386007629771484, 46.309839678277057828, + 98.036877255286526633, 19.638528466275602113, 112.05135150620844797, 26.695358329394366592, + 56.312048712159594288, 27.145623055570467841, 81.487330863048555329, 65.322750238115986576, + 35.915675849118997576, 88.646092359183967346, 2.0622946688345109578, 94.733480555736605311, + 13.778446777341741836, 0.098216751623112941161, 104.78537744631830719, 49.79325261430858518, + 81.017271659675316187, 81.129797405570570845, 53.636656882659735857, 17.836815078560903203, + 62.576424356888310285, 119.89308050271938555, 75.999740767296316335, 126.94899134096340276, + 20.852521564109338215, 51.788860465821926482, 122.19523936207042425, 106.17756889638621942, + 125.48727699546725489, 28.90573366225726204, 117.21090220486439648, 120.83521302793815266, + 96.554580142565100687, 124.20286608644164517, 33.691121048417699058, 97.370698632763378555, + 51.190122758049255935, 33.008666955400258303, 38.724908382399007678, 97.33368916682593408, + 18.756911725060490426, 26.820084002065414097, 62.433216112043737667, 3.3506540385023981798, + 67.581477517400344368, 69.360902129341411637, 127.5137119142091251, 62.512392872238706332, + 48.394462080315861385, 73.733807062668347498, 68.975844960270478623, 114.49654435765114613, + 50.060783657561842119, 105.73177890217630193, 33.615400495553330984, 89.818790207682468463, + 90.510167642030864954, 3.0688382115586136933, 15.11264353059232235, 98.201123398863273906, + 116.96329752518431633, 88.981878296133800177, 126.23105748339730781, 74.740097971578506986, + 70.685073244887462351, 69.834265721601695986, 49.85064919254364213, 35.142449071194278076, + 106.54429840296506882, 108.17101283194278949, 127.59691936131275725, 102.08388641470082803, + 89.691390838190272916, 72.634674822951637907, 127.2126183193831821, 54.425113640219933586, + 123.76116606105642859, 74.435434373859607149, 116.26202623090648558, 35.174505319024319761, + 17.589778937748633325, 5.9132001900507020764, 0.75635680255072657019, 18.511738330904336181, + 113.86987245588898077, 75.6424720979121048, 105.70130040841831942, 36.148360067531029927, + 85.282471979313413613, 116.9869614615708997, 58.891084021946880966, 60.380744191432313528, + 81.585811312757869018, 14.596545159773086198, 119.75303196175082121, 100.36189767290125019, + 21.645756787329446524, 112.61697796104272129, 48.143954311992274597, 89.76667438646836672, + 54.288061313349317061, 53.059869119115319336, 8.4179533941205590963, 12.786162312349915737, + 97.915956914861453697, 123.19131355225908919, 70.236819064695737325, 113.75663812061247882, + 104.63066877821620437, 108.51047508900956018, 97.285699343596206745, 54.833263936092407675, + 100.24924988615748589, 76.322351364560745424, 74.048080423086503288, 20.908277921978879021, + 102.19991288730307133, 89.490176914008770837, 90.301333804192836396, 116.1529399840728729, + 27.438159828023344744, 111.03632183707304648, 39.722170442350034136, 12.052368658441992011, + 29.771760301868198439, 11.616463861184456619, 83.246028491343167843, 110.94302334852545755, + 29.926321544367965544, 116.48636935951435589, 65.015417079266626388, 99.696765831904485822, + 107.6564932578803564, 37.286483857980783796, 8.4227081025237566791, 39.331142263272340642, + 28.86194679189065937, 66.853474301598907914, 48.644168450147844851, 4.3666264835665060673, + 46.86430354065305437, 117.67637494868904469, 20.706227684015175328, 101.25504819633351872, + 33.076951064376771683, 11.186172553570941091, 59.732445216093765339, 124.00257026643521385, + 56.299922707621590234, 15.462377369065507082, 126.78957785736201913, 93.89091645637381589, + 37.097194421901804162, 69.808467986713367281, 56.675842457592807477, 0.35379130040382733569, + 29.007658961585548241, 47.997745409811614081, 59.047554661214235239, 43.737153744466922944, + 15.478517534651473397, 52.538533359223947627, 55.366593770057079382, 20.039781960065738531, + 80.42392583962646313, 106.31339507765733288, 97.318585840712330537, 113.13436537146117189, + 91.222478579420567257, 48.128170072504872223, 0.2983704425350879319, 49.425898803649033653, + 36.006034402897057589, 18.296221656513807829, 82.895132458725129254, 115.41647966419259319, + 86.814540608964307467, 70.483934258256340399, 91.256818765159550821, 33.68043648442835547, + 53.750417672457842855, 25.209272151743789436, 24.197584132467454765, 115.68732426305723493, + 85.904249891438666964, 74.047365843696752563, 99.190160281999851577, 34.977018645415228093, + 22.405058110802201554, 39.206476511717482936, 82.37124410681281006, 49.666733415408089058, + 31.294977433626627317, 66.95065443910061731, 73.094304791549802758, 23.536432670167414472, + 77.804200976599531714, 97.165754283560090698, 93.200521940299950074, 97.813187770334479865, + 99.512498434480221476, 112.96316728929014062, 111.74859656055559753, 112.67423897183834924, + 11.530971279833465815, 127.11820765879383544, 29.073513826238922775, 9.2079286737061920576, + 109.40762823750264943, 18.913115889685286675, 83.707195988230523653, 18.086635104609740665, + 60.747556414742575726, 118.97713767633831594, 126.33012725415392197, 97.339483259358530631, + 122.0565843821495946, 88.380951567243755562, 106.42772278828488197, 109.5594696750267758, + 119.89906471606809646, 91.487320704178273445, 26.68974156500553363, 27.549607267319515813, + 127.26564465669071069, 1.407094393354782369, 121.05689353219349869, 92.723775949532864615, + 10.802248616502765799, 93.333051641580823343, 98.47109506815468194, 62.261808071962150279, + 11.528873111212305957, 40.410854471188940806, 15.316646141727687791, 105.56042475427966565, + 0.38094568664746475406, 3.2079834091709926724, 105.81777222048913245, 116.18596343640820123, + 35.630813331274111988, 102.93466060618084157, 22.32378102855727775, 85.180984506368986331, + 2.5622673621801368427, 16.173129381226317491, 111.37212499951056088, 43.384135441989201354, + 119.99179144145091414, 110.3275543549170834, 82.323579936728492612, 120.17810600054872339, + 56.994410135248472216, 24.908225856386707164, 88.62320391001412645, 0.070507551969058113173, + 99.42867397767258808, 47.766988000541459769, 56.052330279377201805, 64.696416218077501981, + 95.390021224189695204, 108.10371142695657909, 61.929739364175475203, 15.635084900230140192, + 44.515256031598255504, 31.211321282298740698, 118.80512602036469616, 88.467863286161446013, + 123.36730237847223179, 24.379295219976484077, 122.87074871575532597, 101.82389538461575285, + 28.517520490924653132, 24.478504806047567399, 55.243467394651815994, 17.436613084875716595, + 58.999943572525808122, 27.963913210271130083, 58.18259199492240441, 57.839551431854488328, + 124.82866748133892543, 125.9682127495034365, 77.666138036274787737, 50.883372929965844378, + 15.737081233066419372, 48.328921340875240276, 74.200180714135058224, 23.404937501964013791, + 123.86930349026442855, 54.269386004289117409, 84.374584086526738247, 40.194388326537591638, + 88.697430914984579431, 86.635989856727974257, 22.767717013997753384, 120.58353890406579012, + 51.446314652621367713, 26.902504903049702989, 120.54028892141286633, 116.88057300778382341, + 16.860604918842000188, 38.82793091138228192, 100.60386947462757234, 116.25811079460254405, + 54.085830857180553721, 62.961045019601442618, 34.610912946605822071, 34.331487009960255818, + 88.844036288897768827, 97.751610895069461549, 48.176078269516438013, 112.94177157323792926, + 105.92028763039706973, 13.2331398248388723, 111.26176398546886048, 14.405993674583442044, + 2.9734408287804399151, 113.37315523933284567, 8.1227438582391187083, 93.819379452972498257, + 94.548221807901427383, 86.398906137812446104, 36.968081623286707327, 6.3385997948244039435, + 68.316960671705601271, 114.30320236862826278, 28.075215217631921405, 42.253251735870435368, + 50.115956459201697726, 90.485055530880345032, 67.987219110527803423, 81.975396283269219566, + 80.310123082970676478, 114.48830158250348177, 29.228281108124065213, 125.97607266839258955, + 61.284408030413032975, 46.659142809192417189, 65.354214789404068142, 110.34970343892928213, + 104.90327241672639502, 82.482742543597851181, 116.66992026743173483, 72.64691655329806963, + 41.544977642486628611, 67.920268468951690011, 42.230745086879323935, 6.1311717733078694437, + 108.13304767134832218, 104.69531696966078016, 72.075260437613906106, 14.298012241193646332, + 75.517418493960576598, 9.6351622305555792991, 16.411576937312929658, 19.238456531860720133, + 10.205268600249837618, 119.52203979026671732, 74.581361079402995529, 11.307870032720529707, + 9.5827730165365210269, 28.034654590457648737, 72.486201122221245896, 86.078261442751681898, + 83.713526714105682913, 68.400736802916071611, 107.43654161290760385, 96.138205167761043413, + 9.2627720152595429681, 92.619679356557753636, 68.073754510573053267, 39.277056932554842206, + 96.102703012416895945, 53.390716658788733184, 112.62409742431918858, 54.291246111144573661, + 34.974661726100748638, 2.6455004762319731526, 71.83135169824163313, 49.292184718367934693, + 4.1245893376726598945, 61.466961111473210622, 27.556893554683483671, 0.19643350324986386113, + 81.570754892636614386, 99.586505228620808339, 34.034543319354270352, 34.25959481114114169, + 107.27331376531947171, 35.673630157121806405, 125.15284871378025855, 111.78616100544240908, + 23.999481534596270649, 125.89798268192680553, 41.705043128218676429, 103.57772093164749094, + 116.39047872414448648, 84.355137792776076822, 122.97455399093450978, 57.811467324518162059, + 106.42180440973243094, 113.67042605587994331, 65.109160285133839352, 120.40573217288329033, + 67.382242096839036094, 66.74139726552675711, 102.38024551609851187, 66.017333910800516605, + 77.449816764801653335, 66.667378333651868161, 37.513823450120980851, 53.640168004130828194, + 124.86643222408747533, 6.7013080770084343385, 7.1629550348043267149, 10.721804258686461253, + 127.0274238284182502, 125.02478574447741266, 96.788924160635360749, 19.467614125340332976, + 9.9516899205445952248, 100.99308871530229226, 100.12156731512732222, 83.463557804352603853, + 67.230800991110299947, 51.637580415368574904, 53.020335284061729908, 6.1376764231172273867, + 30.225287061188282678, 68.40224679773018579, 105.92659505037227063, 49.963756592271238333, + 124.46211496679825359, 21.48019594316065195, 13.370146489778562682, 11.668531443203391973, + 99.701298385087284259, 70.284898142392194131, 85.088596805933775613, 88.342025663889216958, + 127.19383872262915247, 76.167772829405294033, 51.382781676384183811, 17.269349645906913793, + 126.42523663876636419, 108.85022728044350515, 119.52233212211649516, 20.870868747722852277, + 104.52405246181297116, 70.349010638048639521, 35.17955787549726665, 11.826400380101404153, + 1.5127136051014531404, 37.02347666181231034, 99.739744911781599512, 23.284944195827847579, + 83.402600816836638842, 72.296720135065697832, 42.564943958630465204, 105.9739229231417994, + 117.78216804389376193, 120.76148838286826503, 35.171622625515738036, 29.193090319549810374, + 111.5060639235052804, 72.723795345802500378, 43.291513574662531028, 97.23395592208544258, + 96.287908623988187173, 51.53334877293673344, 108.57612262669863412, 106.11973823823063867, + 16.835906788241118193, 25.572324624703469453, 67.831913829726545373, 118.38262710452181636, + 12.473638129395112628, 99.513276241228595609, 81.261337556436046725, 89.020950178022758337, + 66.57139868719241349, 109.66652787218845333, 72.498499772318609757, 24.644702729125128826, + 20.096160846173006576, 41.816555843961396022, 76.399825774609780638, 50.980353828021179652, + 52.602667608389310772, 104.30587996814574581, 54.876319656050327467, 94.072643674146092962, + 79.444340884700068273, 24.104737316883984022, 59.543520603736396879, 23.232927722372551216, + 38.492056982689973665, 93.8860466970509151, 59.852643088739569066, 104.97273871903234976, + 2.0308341585368907545, 71.393531663812609622, 87.312986515760712791, 74.572967715961567592, + 16.845416205047513358, 78.662284526544681285, 57.723893583784956718, 5.706948603197815828, + 97.288336900295689702, 8.7332529671330121346, 93.728607081309746718, 107.35274989737808937, + 41.412455368033988634, 74.510096392667037435, 66.153902128753543366, 22.372345107141882181, + 119.46489043219116866, 120.00514053287042771, 112.59984541524318047, 30.924754738134652143, + 125.57915571472767624, 59.781832912747631781, 74.194388843807246303, 11.616935973426734563, + 113.35168491518561495, 0.70758260080765467137, 58.015317923171096481, 95.995490819623228163, + 118.09510932242847048, 87.474307488933845889, 30.957035069302946795, 105.07706671844789525, + 110.73318754011415876, 40.07956392013511504, 32.847851679256564239, 84.626790155318303732, + 66.637171681428299053, 98.268730742925981758, 54.444957158841134515, 96.256340145009744447, + 0.5967408850701758638, 98.851797607298067305, 72.012068805794115178, 36.592443313031253638, + 37.790264917453896487, 102.83295932838882436, 45.629081217932252912, 12.967868516516318778, + 54.513637530319101643, 67.360872968856710941, 107.50083534491568571, 50.418544303487578873, + 48.395168264938547509, 103.37464852611810784, 43.808499782880971907, 20.094731687397143105, + 70.380320563999703154, 69.954037290830456186, 44.810116221604403108, 78.41295302343860385, + 36.742488213625620119, 99.333466830816178117, 62.589954867256892612, 5.9013088782048725989, + 18.188609583099605516, 47.072865340338466922, 27.608401953202701407, 66.331508567123819375, + 58.401043880603538128, 67.626375540672597708, 71.024996868964080932, 97.92633457858391921, + 95.497193121114833048, 97.348477943676698487, 23.061942559670569608, 126.23641531758767087, + 58.14702765247784555, 18.415857347416022094, 90.815256475005298853, 37.826231779374211328, + 39.414391976461047307, 36.17327020921948133, 121.49511282948878943, 109.95427535268026986, + 124.66025450831148191, 66.678966518720699241, 116.11316876430282719, 48.761903134491149103, + 84.855445576573401922, 91.118939350057189586, 111.7981294321398309, 54.97464140835654689, + 53.37948313001106726, 55.099214534642669605, 126.53128931338142138, 2.8141887867132027168, + 114.11378706439063535, 57.447551899065729231, 21.604497233009169577, 58.666103283165284665, + 68.942190136309363879, 124.52361614392430056, 23.057746222424611915, 80.821708942377881613, + 30.633292283459013561, 83.120849508559331298, 0.76189137329492950812, 6.4159668183456233237, + 83.635544440981902881, 104.37192687281640247, 71.261626662551861955, 77.869321212361683138, + 44.647562057118193479, 42.361969012737972662, 5.1245347243602736853, 32.346258762456272962, + 94.744249999021121766, 86.768270883982040687, 111.98358288290546625, 92.655108709837804781, + 36.647159873460623203, 112.35621200109744677, 113.98882027049694443, 49.816451712777052308, + 49.2464078200282529, 0.14101510394175420515, 70.85734795534517616, 95.533976001082919538, + 112.10466055875804159, 1.39283243615864194, 62.780042448383028386, 88.207422853913158178, + 123.85947872835095041, 31.270169800460280385, 89.030512063196511008, 62.422642564601119375, + 109.6102520407330303, 48.935726572326530004, 118.73460475694446359, 48.758590439956606133, + 117.74149743151428993, 75.647790769231505692, 57.035040981849306263, 48.957009612095134798, + 110.48693478930363199, 34.87322616975143319, 117.99988714505161624, 55.927826420542260166, + 116.36518398984480882, 115.67910286371261464, 121.65733496268148883, 123.93642549901051098, + 27.332276072549575474, 101.76674585993168876, 31.474162466132838745, 96.65784268175411853, + 20.400361428270116448, 46.80987500393166556, 119.73860698052885709, 108.5387720085818728, + 40.749168173053476494, 80.388776653078821255, 49.394861829972796841, 45.271979713455948513, + 45.535434027999144746, 113.16707780813158024, 102.89262930524273543, 53.805009806103043957, + 113.08057784282937064, 105.76114601556764683, 33.721209837684000377, 77.655861822768201819, + 73.207738949258782668, 104.51622158920508809, 108.17166171436110744, 125.92209003920288524, + 69.221825893211644143, 68.662974019924149616, 49.688072577799175633, 67.503221790138923097, + 96.352156539036514005, 97.8835431464794965, 83.840575260794139467, 26.46627964968138258, + 94.523527970937720966, 28.811987349166884087, 5.9468816575645178091, 98.746310478665691335, + 16.245487716481875395, 59.638758905948634492, 61.096443615806492744, 44.797812275624892209, + 73.936163246573414654, 12.677199589652445866, 8.6339213434148405213, 100.60640473725652555, + 56.15043043526384281, 84.506503471740870737, 100.23191291840703343, 52.970111061764328042, + 7.9744382210592448246, 35.950792566542077111, 32.620246165944990935, 100.97660316500696354, + 58.456562216251768405, 123.9521453367851791, 122.56881606082606595, 93.318285618388472358, + 2.7084295788117742632, 92.699406877862202236, 81.806544833456428023, 36.965485087199340342, + 105.33984053486710764, 17.29383310659613926, 83.0899552849768952, 7.8405369379033800215, + 84.46149017375864787, 12.262343546619376866, 88.266095342700282345, 81.390633939325198298, + 16.150520875227812212, 28.596024482390930643, 23.034836987921153195, 19.270324461111158598, + 32.823153874625859316, 38.476913063721440267, 20.410537200503313215, 111.04407958053707262, + 21.162722158805991057, 22.615740065441059414, 19.165546033073042054, 56.069309180918935454, + 16.972402244446129771, 44.156522885507001774, 39.427053428215003805, 8.8014736058357811999, + 86.873083225818845676, 64.276410335522086825, 18.525544030522723915, 57.23935871311914525, + 8.1475090211461065337, 78.55411386511332239, 64.205406024833791889, 106.78143331758110435, + 97.248194848638377152, 108.58249222228914732, 69.949323452201497275, 5.291000952467584284, + 15.66270339648326626, 98.584369436735869385, 8.2491786753453197889, 122.93392222294642124, + 55.113787109366967343, 0.39286700650336570106, 35.141509785276866751, 71.173010457241616677, + 68.069086638708540704, 68.519189622285921359, 86.546627530638943426, 71.34726031424725079, + 122.30569742756415508, 95.572322010884818155, 47.998963069196179276, 123.79596536385361105, + 83.410086256440990837, 79.155441863298619865, 104.78095744829261093, 40.710275585555791622, + 117.94910798186901957, 115.6229346490399621, 84.84360881946849986, 99.34085211176352459, + 2.2183205702713166829, 112.81146434577021864, 6.7644841936817101669, 5.4827945310571521986, + 76.760491032200661721, 4.0346678216046711896, 26.899633529606944649, 5.3347566673037363216, + 75.027646900241961703, 107.28033600826529437, 121.73286444817495067, 13.402616154016868677, + 14.32591006960865343, 21.443608517376560485, 126.05484765684013837, 122.04957148895846331, + 65.577848321270721499, 38.935228250680665951, 19.903379841092828428, 73.986177430608222494, + 72.243134630258282414, 38.927115608708845684, 6.4616019822205998935, 103.27516083073714981, + 106.04067056812345982, 12.275352846234454773, 60.450574122380203335, 8.8044935954640095588, + 83.853190100744541269, 99.927513184546114644, 120.92422993359650718, 42.9603918863213039, + 26.740292979557125363, 23.337062886410421925, 71.402596770178206498, 12.569796284788026242, + 42.177193611871189205, 48.684051327782071894, 126.38767744526194292, 24.335545658810588066, + 102.76556335276836762, 34.538699291817465564, 124.85047327753636637, 89.700454560890648281, + 111.04466424423299031, 41.741737495449342532, 81.048104923629580298, 12.698021276097279042, + 70.3591157509945333, 23.652800760202808306, 3.0254272102029062808, 74.046953323628258659, + 71.479489823563199025, 46.569888391659333138, 38.805201633676915662, 16.593440270131395664, + 85.129887917264568387, 83.947845846287236782, 107.56433608779116184, 113.52297676573653007, + 70.343245251031476073, 58.386180639103258727, 95.012127847014198778, 17.447590691605000757, + 86.583027149328700034, 66.467911844174523139, 64.575817247976374347, 103.06669754587710486, + 89.152245253400906222, 84.239476476461277343, 33.671813576482236385, 51.144649249410576886, + 7.6638276594567287248, 108.76525420904363273, 24.947276258793863235, 71.026552482460829196, + 34.522675112875731429, 50.041900356049154652, 5.1427973743884649593, 91.333055744380544638, + 16.996999544637219515, 49.289405458250257652, 40.192321692346013151, 83.633111687926430022, + 24.799651549219561275, 101.9607076560423593, 105.20533521678225952, 80.611759936291491613, + 109.75263931210429291, 60.145287348295823904, 30.888681769400136545, 48.209474633767968044, + 119.08704120747279376, 46.465855444745102432, 76.98411396538358531, 59.772093394101830199, + 119.70528617748277611, 81.945477438064699527, 4.0616683170774194878, 14.787063327628857223, + 46.625973031525063561, 21.145935431923135184, 33.690832410098664695, 29.324569053089362569, + 115.44778716756991344, 11.413897206399269635, 66.576673800591379404, 17.466505934269662248, + 59.457214162623131415, 86.705499794756178744, 82.824910736071615247, 21.020192785337712849, + 4.3078042575070867315, 44.744690214287402341, 110.92978086438597529, 112.01028106574449339, + 97.199690830486360937, 61.849509476272942265, 123.15831142945535248, 119.56366582549890154, + 20.388777687614492606, 23.233871946857107105, 98.703369830371229909, 1.4151652016153093427, + 116.03063584634583094, 63.990981639250094304, 108.19021864486057893, 46.948614977867691778, + 61.914070138609531568, 82.154133436899428489, 93.466375080228317529, 80.159127840270230081, + 65.695703358516766457, 41.253580310640245443, 5.2743433628602360841, 68.537461485851963516, + 108.88991431768590701, 64.512680290019488893, 1.1934817701439897064, 69.703595214599772589, + 16.024137611588230357, 73.184886626062507275, 75.580529834911430953, 77.665918656777648721, + 91.258162435864505824, 25.935737033032637555, 109.02727506064184126, 6.72174593771705986, + 87.001670689831371419, 100.83708860697515775, 96.790336529880732996, 78.749297052236215677, + 87.616999565761943813, 40.189463374797924189, 12.760641128003044287, 11.908074581660912372, + 89.620232443212444196, 28.8259060468772077, 73.484976427254878217, 70.666933661632356234, + 125.17990973451378522, 11.802617756409745198, 36.377219166199211031, 94.145730680676933844, + 55.216803906409040792, 4.6630171342476387508, 116.80208776121071423, 7.2527510813488333952, + 14.049993737931799842, 67.8526691571714764, 62.994386242233304074, 66.696955887353396975, + 46.123885119344777195, 124.47283063517534174, 116.2940553049556911, 36.831714694835682167, + 53.630512950010597706, 75.652463558748422656, 78.828783952922094613, 72.34654041844260064, + 114.99022565898121684, 91.908550705364177702, 121.32050901662660181, 5.3579330374450364616, + 104.22633752860565437, 97.523806268985936185, 41.710891153150441824, 54.23787870011801715, + 95.596258864279661793, 109.94928281671309378, 106.75896626002213452, 110.19842906928897719, + 125.06257862676284276, 5.6283775734300434124, 100.2275741287812707, 114.89510379813145846, + 43.208994466018339153, 117.33220656633420731, 9.8843802726223657373, 121.04723228784860112, + 46.115492444852861809, 33.643417884755763225, 61.2665845669216651, 38.241699017118662596, + 1.5237827465898590162, 12.831933636694884626, 39.27108888196744374, 80.743853745636442909, + 14.523253325107361889, 27.738642424723366275, 89.295124114236386959, 84.723938025475945324, + 10.249069448720547371, 64.692517524916183902, 61.488499998045881512, 45.536541767967719352, + 95.967165765814570477, 57.310217419675609563, 73.294319746924884384, 96.712424002198531525, + 99.977640540993888862, 99.632903425554104615, 98.492815640056505799, 0.28203020788714638911, + 13.714695910693990299, 63.067952002169477055, 96.209321117516083177, 2.78566487231728388, + 125.56008489676969475, 48.414845707829954335, 119.71895745670190081, 62.540339600924198749, + 50.061024126393022016, 124.84528512920587673, 91.220504081466060597, 97.871453144656697987, + 109.46920951388892718, 97.517180879916850245, 107.48299486303221784, 23.295581538463011384, + 114.07008196369861253, 97.914019224193907576, 92.973869578607263975, 69.746452339506504359, + 107.99977429010323249, 111.85565284108815831, 104.73036797969325562, 103.35820572742886725, + 115.31466992536661564, 119.87285099802102195, 54.664552145102788927, 75.533491719863377512, + 62.948324932269315468, 65.31568536350823706, 40.800722856540232897, 93.619750007866969099, + 111.47721396106135217, 89.077544017163745593, 81.498336346110590966, 32.77755330615764251, + 98.789723659945593681, 90.543959426911897026, 91.070868056001927471, 98.334155616266798461, + 77.785258610485470854, 107.61001961220972589, 98.161155685662379256, 83.522292031135293655, + 67.442419675371638732, 27.311723645540041616, 18.415477898521203315, 81.032443178413814167, + 88.343323428725852864, 123.84418007840940845, 10.443651786426926265, 9.3259480398482992314, + 99.376145155601989245, 7.0064435802814841736, 64.704313078076665988, 67.767086292962630978, + 39.681150521588278934, 52.932559299366403138, 61.047055941875441931, 57.623974698333768174, + 11.893763315132673597, 69.49262095733138267, 32.490975432963750791, 119.27751781189726898, + 122.19288723161298549, 89.595624551253422396, 19.872326493146829307, 25.354399179304891732, + 17.267842686833319021, 73.2128094745130511, 112.3008608705313236, 41.013006943485379452, + 72.463825836814066861, 105.94022212352865608, 15.948876442118489649, 71.901585133084154222, + 65.240492331893619848, 73.953206330013927072, 116.91312443250717479, 119.90429067357399617, + 117.13763212165576988, 58.636571236776944716, 5.4168591576271865051, 57.398813755728042452, + 35.613089666912856046, 73.930970174402318662, 82.679681069734215271, 34.587666213195916498, + 38.1799105699537904, 15.681073875810398022, 40.922980347517295741, 24.524687093242391711, + 48.532190685404202668, 34.781267878650396597, 32.301041750455624424, 57.192048964781861287, + 46.06967397584230639, 38.540648922222317196, 65.646307749251718633, 76.953826127442880534, + 40.82107440101026441, 94.088159161074145231, 42.325444317611982115, 45.231480130882118829, + 38.331092066146084107, 112.13861836183787091, 33.944804488892259542, 88.313045771014003549, + 78.85410685643000761, 17.602947211675200379, 45.746166451641329331, 0.55282067104417365044, + 37.05108806104544783, 114.4787174262382905, 16.295018042295851046, 29.108227730230282759, + 0.41081204967122175731, 85.562866635165846674, 66.496389697280392284, 89.164984444578294642, + 11.898646904402994551, 10.582001904935168568, 31.3254067929701705, 69.168738873471738771, + 16.498357350694277557, 117.86784444589284249, 110.22757421873393469, 0.78573401300673140213, + 70.28301957055737148, 14.346020914486871334, 8.138173277420719387, 9.0383792445754806977, + 45.093255061281524831, 14.694520628498139558, 116.61139485513194813, 63.144644021769636311, + 95.997926138395996531, 119.59193072771086008, 38.820172512885619653, 30.310883726600877708, + 81.561914896585221868, 81.420551171115221223, 107.89821596374167711, 103.24586929808356217, + 41.687217638940637698, 70.68170422352704918, 4.4366411405462713446, 97.622928691540437285, + 13.528968387363420334, 10.965589062117942376, 25.520982064401323441, 8.0693356432093423791, + 53.799267059213889297, 10.669513334611110622, 22.055293800487561384, 86.560672016534226714, + 115.46572889634990133, 26.805232308033737354, 28.65182013921730686, 42.887217034756758949, + 124.10969531368391472, 116.09914297792056459, 3.1556966425414429978, 77.870456501361331902, + 39.806759682189294836, 19.972354861220082967, 16.486269260516564827, 77.854231217417691369, + 12.923203964444837766, 78.550321661477937596, 84.081341136246919632, 24.550705692468909547, + 120.90114824476040667, 17.608987190931657096, 39.706380201492720516, 71.855026369095867267, + 113.84845986719301436, 85.920783772642607801, 53.480585959114250727, 46.674125772824481828, + 14.805193540356412996, 25.139592569576052483, 84.35438722374237841, 97.368102655567781767, + 124.77535489052388584, 48.67109131762481411, 77.531126705536735244, 69.077398583638569107, + 121.70094655507637071, 51.400909121784934541, 94.089328488465980627, 83.483474990902323043, + 34.096209847259160597, 25.396042552198196063, 12.718231501989066601, 47.305601520405616611, + 6.0508544204094505403, 20.093906647260155296, 14.958979647126398049, 93.139776783318666276, + 77.610403267353831325, 33.186880540266429307, 42.259775834532774752, 39.895691692578111542, + 87.128672175585961668, 99.045953531476698117, 12.686490502062952146, 116.77236127821015543, + 62.024255694028397556, 34.895181383213639492, 45.166054298661038047, 4.9358236883526842576, + 1.1516344959563866723, 78.133395091757847695, 50.304490506805450423, 40.478952952922554687, + 67.343627152964472771, 102.28929849882115377, 15.327655318917095428, 89.530508418087265454, + 49.894552517591364449, 14.053104964921658393, 69.045350225751462858, 100.0838007120983093, + 10.285594748780567897, 54.666111488761089277, 33.993999089274439029, 98.578810916500515305, + 80.384643384695664281, 39.266223375852860045, 49.599303098442760529, 75.921415312088356586, + 82.410670433568157023, 33.223519872586621204, 91.505278624208585825, 120.29057469659164781, + 61.777363538800273091, 96.418949267539574066, 110.17408241494558752, 92.931710889493842842, + 25.968227930767170619, 119.54418678820729838, 111.4105723549691902, 35.890954876129399054, + 8.1233366341548389755, 29.574126655257714447, 93.251946063050127123, 42.291870863846270368, + 67.381664820197329391, 58.649138106182363117, 102.89557433513982687, 22.827794412802177249, + 5.1533476011827588081, 34.933011868539324496, 118.91442832524990081, 45.410999589515995467, + 37.649821472143230494, 42.040385570675425697, 8.615608515014173463, 89.489380428578442661, + 93.859561728775588563, 96.020562131492624758, 66.399381660972721875, 123.69901895254952251, + 118.31662285891434294, 111.12733165099780308, 40.777555375228985213, 46.467743893717852188, + 69.406739660742459819, 2.8303304032342566643, 104.06127169269166188, 127.98196327850382659, + 88.380437289721157867, 93.897229955735383555, 123.82814027722270112, 36.308266873802494956, + 58.932750160460273037, 32.318255680544098141, 3.3914067170335329138, 82.507160621280490886, + 10.548686725724110147, 9.0749229717075650115, 89.779828635375451995, 1.0253605800389777869, + 2.3869635402916173916, 11.407190429199545179, 32.048275223180098692, 18.36977325212865253, + 23.161059669826499885, 27.331837313558935421, 54.516324871729011647, 51.871474066068913089, + 90.054550121283682529, 13.443491875437757699, 46.003341379666380817, 73.674177213953953469, + 65.580673059765103972, 29.498594104476069333, 47.233999131523887627, 80.378926749595848378, + 25.521282256006088573, 23.816149163325462723, 51.240464886424888391, 57.651812093758053379, + 18.969952854513394414, 13.333867323268350447, 122.35981946902757045, 23.605235512819490395, + 72.754438332402060041, 60.291461361353867687, 110.43360781281808158, 9.3260342684989154804, + 105.60417552242142847, 14.50550216269766679, 28.099987475867237663, 7.7053383143429527991, + 125.98877248447024613, 5.393911774706793949, 92.247770238693192368, 120.94566127035432146, + 104.5881106099113822, 73.663429389671364333, 107.26102590002483339, 23.304927117500483291, + 29.657567905847827205, 16.693080836888839258, 101.98045131796607166, 55.817101410731993383, + 114.64101803325320361, 10.715866074893710902, 80.452675057214946719, 67.047612537971872371, + 83.421782306300883647, 108.47575740023967228, 63.192517728562961565, 91.898565633429825539, + 85.517932520047907019, 92.396858138581592357, 122.12515725352568552, 11.256755146863724804, + 72.455148257566179382, 101.79020759626291692, 86.417988932040316286, 106.66441313266841462, + 19.768760545248369453, 114.09446457569720224, 92.230984889705723617, 67.286835769511526451, + 122.5331691338433302, 76.483398034237325191, 3.0475654931797180325, 25.663867273389769252, + 78.542177763938525459, 33.487707491272885818, 29.046506650214723777, 55.47728484945037053, + 50.590248228476411896, 41.447876050951890647, 20.49813889744473272, 1.3850350498323678039, + 122.97699999609176302, 91.073083535939076683, 63.934331531629140954, 114.6204348393548571, + 18.588639493853406748, 65.424848004400701029, 71.955281081991415704, 71.265806851111847209, + 68.985631280113011599, 0.56406041577429277822, 27.429391821387980599, 126.13590400434259209, + 64.418642235032166354, 5.5713297446382057387, 123.1201697935393895, 96.82969141566354665, + 111.43791491340380162, 125.0806792018483975, 100.12204825278968201, 121.69057025841539144, + 54.441008162935759174, 67.742906289317033952, 90.938419027781492332, 67.034361759837338468, + 86.965989726064435672, 46.591163076929660747, 100.14016392740086303, 67.82803844839145313, + 57.947739157218165928, 11.492904679016646696, 87.999548580210102955, 95.711305682179954601, + 81.460735959390149219, 78.716411454861372476, 102.62933985073686927, 111.7457019960420439, + 109.32910429020921583, 23.066983439726755023, 125.89664986454226892, 2.6313707270164741203, + 81.601445713084103772, 59.239500015737576177, 94.95442792212634231, 50.155088034331129165, + 34.996672692221181933, 65.555106612318922998, 69.579447319894825341, 53.087918853827432031, + 54.14173611200749292, 68.668311232537234901, 27.570517220974579686, 87.220039224423089763, + 68.32231137132839649, 39.044584062274225289, 6.8848393507432774641, 54.623447291080083232, + 36.830955797046044609, 34.064886356831266312, 48.686646857455343707, 119.6883601568188169, + 20.887303572853852529, 18.651896079700236442, 70.75229031120397849, 14.012887160566606326, + 1.4086261561569699552, 7.5341725859252619557, 79.362301043176557869, 105.86511859873280628, + 122.09411188375088386, 115.24794939666753635, 23.787526630268985173, 10.985241914662765339, + 64.98195086593113956, 110.55503562379817595, 116.38577446322960895, 51.191249102506844793, + 39.744652986293658614, 50.708798358609783463, 34.535685373670276022, 18.425618949029740179, + 96.601721741062647197, 82.026013886974396883, 16.9276516736317717, 83.880444247057312168, + 31.897752884240617277, 15.803170266171946423, 2.4809846637908776756, 19.906412660031492123, + 105.82624886501798755, 111.80858134715163033, 106.27526424331153976, 117.27314247355388943, + 10.83371831525437301, 114.7976275114560849, 71.226179333829350071, 19.861940348808275303, + 37.359362139468430541, 69.175332426391832996, 76.3598211399075808, 31.362147751620796043, + 81.845960695034591481, 49.049374186484783422, 97.064381370808405336, 69.562535757300793193, + 64.602083500911248848, 114.38409792956372257, 92.139347951684612781, 77.081297844448272372, + 3.2926154985070752446, 25.907652254885761067, 81.642148802024166798, 60.176318322148290463, + 84.650888635223964229, 90.462960261764237657, 76.662184132295806194, 96.277236723675741814, + 67.889608977788157063, 48.626091542031645076, 29.708213712860015221, 35.205894423350400757, + 91.492332903282658663, 1.1056413420883473009, 74.102176122094533639, 100.957434852476581, + 32.590036084591702092, 58.216455460460565519, 0.82162409934608149342, 43.125733270335331326, + 4.992779394564422546, 50.329968889160227263, 23.797293808805989102, 21.164003809870337136, + 62.650813585943978978, 10.337477746943477541, 32.996714701392193092, 107.73568889178932295, + 92.455148437467869371, 1.5714680260171007831, 12.566039141114742961, 28.692041828973742668, + 16.276346554841438774, 18.076758489150961395, 90.186510122563049663, 29.389041256999917096, + 105.22278971026389627, 126.2892880435429106, 63.995852276795631042, 111.18386145542172017, + 77.640345025771239307, 60.621767453205393394, 35.123829793174081715, 34.841102342234080425, + 87.796431927486992208, 78.491738596167124342, 83.374435277884913376, 13.36340844705409836, + 8.8732822810961806681, 67.24585738308087457, 27.057936774726840667, 21.931178124235884752, + 51.041964128802646883, 16.138671286418684758, 107.59853411842777859, 21.339026669222221244, + 44.110587600978760747, 45.121344033072091406, 102.93145779269980267, 53.610464616067474708, + 57.30364027843461372, 85.774434069517155876, 120.21939062737146742, 104.19828595584112918, + 6.3113932850865239743, 27.740913002722663805, 79.613519364378589671, 39.944709722440165933, + 32.972538521036767634, 27.708462434835382737, 25.84640792889331351, 29.100643322959513171, + 40.162682272493839264, 49.101411384941457072, 113.80229648952081334, 35.217974381863314193, + 79.412760402989079012, 15.710052738195372513, 99.696919734389666701, 43.841567545285215601, + 106.96117191822850145, 93.348251545648963656, 29.610387080712825991, 50.279185139155742945, + 40.708774447488394799, 66.736205311139201513, 121.55070978104777168, 97.342182635253266199, + 27.062253411077108467, 10.154797167280776193, 115.40189311015274143, 102.80181824357350706, + 60.178656976935599232, 38.966949981804646086, 68.192419694518321194, 50.792085104396392126, + 25.436463003978133202, 94.611203040811233222, 12.101708840818901081, 40.187813294520310592, + 29.917959294256434077, 58.27955356664097053, 27.220806534707662649, 66.373761080532858614, + 84.519551669065549504, 79.791383385159861064, 46.257344351175561314, 70.091907062953396235, + 25.372981004129542271, 105.54472255642031087, 124.04851138805679511, 69.790362766427278984, + 90.332108597322076093, 9.8716473767053685151, 2.3032689919164113235, 28.266790183515695389, + 100.60898101361090085, 80.957905905848747352, 6.6872543059325835202, 76.578596997642307542, + 30.655310637837828835, 51.061016836174530908, 99.789105035182728898, 28.106209929846954765, + 10.090700451506563695, 72.167601424196618609, 20.571189497561135795, 109.33222297752217855, + 67.987998178552516038, 69.157621833004668588, 32.769286769391328562, 78.532446751705720089, + 99.198606196889159037, 23.842830624180351151, 36.821340867136314046, 66.447039745176880388, + 55.010557248420809628, 112.58114939318329562, 123.55472707760418416, 64.837898535082786111, + 92.34816482989481301, 57.863421778987685684, 51.936455861537979217, 111.08837357641823473, + 94.821144709938380402, 71.781909752258798108, 16.246673268309677951, 59.148253310519066872, + 58.503892126100254245, 84.583741727696178714, 6.7633296403946587816, 117.29827621236836421, + 77.791148670279653743, 45.655588825604354497, 10.306695202365517616, 69.866023737082286971, + 109.82885665049980162, 90.821999179031990934, 75.299642944286460988, 84.080771141350851394, + 17.231217030031984905, 50.978760857160523301, 59.719123457554815104, 64.041124262988887494, + 4.7987633219490817282, 119.398037905102683, 108.63324571783232386, 94.254663301995606162, + 81.555110750457970425, 92.935487787439342355, 10.813479321484919637, 5.6606608064721513074, + 80.122543385386961745, 127.96392655701129115, 48.760874579445953714, 59.794459911474405089, + 119.65628055444540223, 72.616533747604989912, 117.86550032092054607, 64.636511361088196281, + 6.7828134340707038064, 37.014321242560981773, 21.097373451448220294, 18.149845943418768002, + 51.55965727075090399, 2.0507211600779555738, 4.7739270805832347833, 22.814380858399090357, + 64.096550446360197384, 36.73954650425730506, 46.32211933965299977, 54.663674627117870841, + 109.03264974345802329, 103.74294813214146416, 52.109100242567365058, 26.886983750875515398, + 92.006682759336399613, 19.348354427911544917, 3.1613461195302079432, 58.997188208952138666, + 94.467998263051413232, 32.757853499191696756, 51.042564512012177147, 47.632298326650925446, + 102.48092977284977678, 115.30362418751610676, 37.939905709026788827, 26.667734646540338872, + 116.7196389380551409, 47.21047102564261877, 17.508876664804120082, 120.58292272271137335, + 92.867215625636163168, 18.65206853700146894, 83.208351044842856936, 29.011004325395333581, + 56.199974951734475326, 15.410676628689543577, 123.97754496894049225, 10.787823549417225877, + 56.495540477390022716, 113.8913225407122809, 81.176221219826402375, 19.326858779346366646, + 86.522051800049666781, 46.609854235000966582, 59.315135811695654411, 33.386161673781316495, + 75.960902635932143312, 111.63420282146762474, 101.28203606650640722, 21.431732149791059783, + 32.905350114433531417, 6.0952250759473827202, 38.843564612605405273, 88.951514800479344558, + 126.38503545712956111, 55.797131266863289056, 43.035865040099452017, 56.793716277166822692, + 116.25031450705137104, 22.513510293731087586, 16.910296515135996742, 75.580415192529471824, + 44.83597786408427055, 85.328826265336829238, 39.537521090500376886, 100.18892915139804245, + 56.461969779415085213, 6.5736715390266908798, 117.06633826769029838, 24.966796068474650383, + 6.095130986359436065, 51.327734546783176484, 29.084355527877050918, 66.975414982545771636, + 58.093013300429447554, 110.95456969890074106, 101.18049645695282379, 82.895752101903781295, + 40.99627779488946544, 2.7700700996683735866, 117.95399999218716403, 54.146167071878153365, + 127.86866306326191989, 101.24086967870971421, 37.177278987710451474, 2.8496960088050400373, + 15.910562163986469386, 14.531613702227332396, 9.9712625602260231972, 1.1281208315485855564, + 54.858783642779599177, 124.27180800868882216, 0.83728447006433270872, 11.142659489280049456, + 118.24033958708241698, 65.659382831330731278, 94.875829826811241219, 122.16135840370043297, + 72.244096505583001999, 115.38114051683078287, 108.88201632587515633, 7.485812578637705883, + 53.876838055566622643, 6.0687235196783149149, 45.931979452128871344, 93.182326153862959472, + 72.280327854805364041, 7.6560768967829062603, 115.89547831443633186, 22.985809358036931371, + 47.999097160423843889, 63.422611364363547182, 34.921471918783936417, 29.432822909726382932, + 77.258679701477376511, 95.491403992087725783, 90.658208580418431666, 46.133966879457148025, + 123.79329972908453783, 5.2627414540365862194, 35.202891426168207545, 118.47900003147879033, + 61.908855844252684619, 100.31017606866225833, 69.993345384446001844, 3.1102132246414839756, + 11.158894639789650682, 106.17583770765486406, 108.28347222401862382, 9.336622465074469801, + 55.141034441952797351, 46.440078448849817505, 8.6446227426567929797, 78.089168124548450578, + 13.769678701486554928, 109.24689458216016646, 73.661911594092089217, 68.129772713662532624, + 97.373293714914325392, 111.37672031363763381, 41.774607145707705058, 37.303792159404110862, + 13.50458062240795698, 28.025774321133212652, 2.8172523123139399104, 15.06834517185416189, + 30.724602086356753716, 83.730237197469250532, 116.1882237675054057, 102.4958987933350727, + 47.575053260537970345, 21.970483829329168657, 1.9639017318659170996, 93.110071247599989874, + 104.77154892645921791, 102.38249820501368959, 79.489305972587317228, 101.41759671721956693, + 69.071370747340552043, 36.851237898063118337, 65.203443482128932374, 36.052027773948793765, + 33.85530334726718138, 39.760888494114624336, 63.795505768481234554, 31.606340532343892846, + 4.9619693275817553513, 39.812825320066622226, 83.652497730039613089, 95.617162694306898629, + 84.550528486626717495, 106.54628494710777886, 21.667436630512383999, 101.59525502291580779, + 14.452358667658700142, 39.723880697616550606, 74.718724278940499062, 10.350664852787303971, + 24.719642279815161601, 62.724295503245230066, 35.691921390069182962, 98.098748372973204823, + 66.128762741620448651, 11.125071514605224365, 1.2041670018261356745, 100.76819585913108313, + 56.27869590337286354, 26.162595688896544743, 6.5852309970141504891, 51.815304509775160113, + 35.284297604048333596, 120.3526366443002189, 41.301777270451566437, 52.925920523532113293, + 25.324368264595250366, 64.554473447355121607, 7.7792179555763141252, 97.252183084063290153, + 59.416427425720030442, 70.411788846704439493, 54.984665806565317325, 2.2112826841803325806, + 20.204352244192705257, 73.914869704953162, 65.180072169183404185, 116.43291092092113104, + 1.6432481986921629868, 86.251466540670662653, 9.9855587891288450919, 100.65993777832045453, + 47.594587617611978203, 42.328007619740674272, 125.30162717188795796, 20.674955493886955082, + 65.993429402788024163, 87.471377783582283882, 56.910296874935738742, 3.1429360520342015661, + 25.132078282229485922, 57.384083657947485335, 32.552693109682877548, 36.15351697830556077, + 52.373020245126099326, 58.77808251400347217, 82.445579420531430515, 124.5785760870858212, + 127.99170455359490006, 94.36772291084707831, 27.280690051542478614, 121.24353490641078679, + 70.24765958634816343, 69.682204684471798828, 47.592863854977622395, 28.983477192337886663, + 38.748870555769826751, 26.72681689410819672, 17.746564562195999315, 6.4917147661617491394, + 54.115873549453681335, 43.862356248471769504, 102.08392825760529377, 32.277342572841007495, + 87.197068236855557188, 42.678053338444442488, 88.221175201957521494, 90.242688066147820791, + 77.862915585399605334, 107.22092923213494942, 114.60728055687286542, 43.548868139037949732, + 112.43878125474657281, 80.39657191168225836, 12.622786570173047949, 55.481826005448965589, + 31.227038728757179342, 79.889419444880331866, 65.945077042073535267, 55.416924869670765474, + 51.692815857786627021, 58.201286645919026341, 80.325364544987678528, 98.202822769886552123, + 99.604592979041626677, 70.435948763730266364, 30.825520805978158023, 31.420105476394383004, + 71.393839468779333401, 87.683135090574069181, 85.922343836460640887, 58.696503091297927313, + 59.220774161425651982, 100.55837027831148589, 81.417548894980427576, 5.4724106222820410039, + 115.10141956209918135, 66.684365270506532397, 54.124506822154216934, 20.309594334565190366, + 102.80378622030912084, 77.603636487147014122, 120.35731395387119846, 77.933899963612930151, + 8.3848393890366423875, 101.58417020879278425, 50.872926007959904382, 61.222406081622466445, + 24.203417681637802161, 80.375626589040621184, 59.835918588512868155, 116.55910713328194106, + 54.441613069418963278, 4.7475221610693552066, 41.039103338134736987, 31.582766770319722127, + 92.514688702354760608, 12.183814125906792469, 50.74596200826272252, 83.089445112844259711, + 120.0970227761172282, 11.580725532858195947, 52.664217194644152187, 19.74329475341073703, + 4.6065379838328226469, 56.533580367035028758, 73.21796202722543967, 33.915811811697494704, + 13.374508611868805019, 25.157193995284615085, 61.310621275675657671, 102.1220336723526998, + 71.578210070365457796, 56.21241985969390953, 20.181400903016765369, 16.335202848393237218, + 41.142378995125909569, 90.664445955047995085, 7.975996357108670054, 10.315243666009337176, + 65.538573538786295103, 29.064893503415078158, 70.397212393778318074, 47.685661248360702302, + 73.64268173427626607, 4.8940794903537607752, 110.02111449684525724, 97.162298786370229209, + 119.1094541552120063, 1.6757970701692102011, 56.696329659789626021, 115.72684355797537137, + 103.87291172307959641, 94.176747152840107447, 61.642289419880398782, 15.563819504517596215, + 32.493346536619355902, 118.29650662103813374, 117.00778425220414647, 41.167483455392357428, + 13.526659280792955542, 106.5965524247403664, 27.582297340559307486, 91.311177651208708994, + 20.613390404734673211, 11.73204747416821192, 91.657713301003241213, 53.643998358067619847, + 22.599285888576559955, 40.161542282701702788, 34.46243406006396981, 101.9575217143210466, + 119.43824691511326819, 0.08224852597777498886, 9.5975266439018014353, 110.79607581020900398, + 89.266491435668285703, 60.509326603994850302, 35.11022150091957883, 57.870975574878684711, + 21.626958642969839275, 11.321321612947940594, 32.245086770777561469, 127.9278531140225823, + 97.521749158891907427, 119.58891982295244816, 111.31256110889444244, 17.233067495213617804, + 107.73100064184473013, 1.2730227221763925627, 13.565626868141407613, 74.028642485121963546, + 42.194746902896440588, 36.299691886837536003, 103.11931454150180798, 4.1014423201559111476, + 9.5478541611664695665, 45.628761716801818693, 0.19310089272039476782, 73.479093008514610119, + 92.64423867930599954, 109.32734925423937966, 90.065299486919684568, 79.485896264282928314, + 104.21820048513473012, 53.773967501754668774, 56.013365518672799226, 38.696708855823089834, + 6.3226922390604158863, 117.99437641790791531, 60.935996526102826465, 65.515706998383393511, + 102.08512902402435429, 95.264596653305488871, 76.961859545703191543, 102.60724837503221352, + 75.879811418053577654, 53.335469293084315723, 105.4392778761102818, 94.42094205128523754, + 35.017753329611878144, 113.16584544542638469, 57.734431251272326335, 37.304137074006575858, + 38.416702089685713872, 58.022008650790667161, 112.39994990346895065, 30.821353257382725133, + 119.95508993788098451, 21.575647098834451754, 112.99108095478368341, 99.782645081428199774, + 34.352442439652804751, 38.65371755869637127, 45.044103600099333562, 93.219708470001933165, + 118.63027162339130882, 66.772323347566270968, 23.921805271867924603, 95.268405642938887468, + 74.564072133012814447, 42.863464299582119565, 65.810700228867062833, 12.19045015189476544, + 77.687129225214448525, 49.903029600962327095, 124.77007091425912222, 111.59426253372657811, + 86.071730080198904034, 113.58743255433728336, 104.50062901410274208, 45.027020587462175172, + 33.820593030275631463, 23.160830385058943648, 89.671955728172179079, 42.657652530673658475, + 79.07504218100439175, 72.377858302796084899, 112.92393955883017043, 13.147343078057019738, + 106.13267653538059676, 49.933592136949300766, 12.19026197271887213, 102.65546909356635297, + 58.168711055757739814, 5.9508299650915432721, 116.18602660086253309, 93.909139397805120097, + 74.360992913909285562, 37.79150420380756259, 81.99255558977893088, 5.540140199340385152, + 107.90799998437432805, 108.29233414375994471, 127.73732612652747775, 74.481739357419428416, + 74.354557975420902949, 5.6993920176100800745, 31.821124327972938772, 29.063227404454664793, + 19.942525120452046394, 2.2562416630971711129, 109.71756728556283633, 120.54361601737764431, + 1.6745689401286654174, 22.285318978563736891, 108.48067917416847195, 3.3187656626651005354, + 61.751659653626120416, 116.32271680740450392, 16.488193011169641977, 102.76228103366520372, + 89.764032651750312652, 14.971625157275411766, 107.75367611113324529, 12.13744703935662983, + 91.863958904261380667, 58.364652307729556924, 16.560655709610728081, 15.312153793569450499, + 103.79095662887266371, 45.971618716073862743, 95.998194320847687777, 126.84522272872709436, + 69.842943837567872833, 58.865645819456403842, 26.517359402958391001, 62.982807984179089544, + 53.316417160836863331, 92.267933758917934028, 119.58659945816907566, 10.525482908073172439, + 70.405782852340053068, 108.95800006295758067, 123.81771168850900722, 72.62035213732815464, + 11.986690768892003689, 6.2204264492829679511, 22.317789279582939344, 84.351675415313366102, + 88.566944448037247639, 18.673244930148939602, 110.2820688839055947, 92.88015689769963501, + 17.289245485317223938, 28.178336249096901156, 27.539357402976747835, 90.493789164323970908, + 19.323823188187816413, 8.2595454273287032265, 66.746587429832288763, 94.753440627275267616, + 83.549214291415410116, 74.607584318808221724, 27.00916124481591396, 56.051548642266425304, + 5.6345046246278798208, 30.13669034370832378, 61.449204172717145411, 39.460474394942139043, + 104.37644753501444939, 76.991797586670145392, 95.150106521075940691, 43.940967658658337314, + 3.9278034637354721781, 58.220142495203617727, 81.543097852922073798, 76.764996410031017149, + 30.978611945178272435, 74.835193434442771832, 10.142741494681104086, 73.702475796129874652, + 2.4068869642578647472, 72.10405554789758753, 67.710606694534362759, 79.521776988229248673, + 127.59101153696246911, 63.212681064687785693, 9.9239386551635107026, 79.62565064013688243, + 39.304995460082864156, 63.234325388617435237, 41.101056973257072968, 85.092569894215557724, + 43.334873261028405977, 75.190510045831615571, 28.904717335317400284, 79.44776139523673919, + 21.437448557880998123, 20.701329705574607942, 49.439284559630323201, 125.44859100649046013, + 71.383842780142003903, 68.197496745950047625, 4.2575254832408973016, 22.250143029210448731, + 2.4083340036559093278, 73.53639171826216625, 112.55739180674572708, 52.325191377793089487, + 13.170461994028300978, 103.63060901955032023, 70.568595208100305172, 112.70527328860043781, + 82.603554540903132875, 105.85184104706422659, 50.648736529194138711, 1.1089468947102432139, + 15.558435911156266229, 66.504366168126580305, 118.83285485144369886, 12.823577693408878986, + 109.96933161313063465, 4.4225653683606651612, 40.408704488389048493, 19.829739409909961978, + 2.3601443383704463486, 104.86582184184226207, 3.2864963973879639525, 44.502933081341325305, + 19.971117578261328163, 73.319875556644547032, 95.189175235223956406, 84.656015239484986523, + 122.60325434377591591, 41.349910987777548144, 3.9868588055796863046, 46.942755567164567765, + 113.82059374987147748, 6.2858721040684031323, 50.264156564458971843, 114.76816731589497067, + 65.105386219365755096, 72.307033956611121539, 104.74604049025219865, 117.55616502801058232, + 36.891158841066499008, 121.15715217417528038, 127.9834091071934381, 60.735445821694156621, + 54.561380103088595206, 114.48706981282521156, 12.495319172699964838, 11.364409368943597656, + 95.185727709955244791, 57.966954384675773326, 77.497741111539653502, 53.453633788216393441, + 35.49312912439199863, 12.983429532323498279, 108.23174709890736267, 87.724712496947176987, + 76.167856515210587531, 64.554685145685652969, 46.394136473711114377, 85.356106676892522955, + 48.442350403918680968, 52.485376132299279561, 27.725831170802848646, 86.441858464273536811, + 101.21456111374573084, 87.097736278079537442, 96.877562509496783605, 32.79314382336451672, + 25.245573140346095897, 110.96365201089793118, 62.454077457517996663, 31.778838889764301712, + 3.8901540841470705345, 110.83384973934153095, 103.38563171557325404, 116.40257329184169066, + 32.650729089978995034, 68.405645539776742226, 71.209185958086891333, 12.871897527460532729, + 61.651041611956316046, 62.840210952792403987, 14.787678937562304782, 47.366270181151776342, + 43.844687672921281774, 117.39300618259585463, 118.44154832285494194, 73.116740556626609759, + 34.835097789960855152, 10.944821244567719987, 102.20283912420200068, 5.3687305410130647942, + 108.24901364430843387, 40.61918866913401871, 77.60757244062187965, 27.207272974297666224, + 112.71462790774603491, 27.867799927225860301, 16.769678778076922754, 75.168340417585568503, + 101.74585201591980876, 122.44481216324493289, 48.406835363279242301, 32.751253178081242368, + 119.67183717702937429, 105.11821426656388212, 108.88322613883792656, 9.4950443221387104131, + 82.078206676269473974, 63.165533540643082233, 57.029377404709521215, 24.367628251813584939, + 101.49192401652908302, 38.178890225692157401, 112.19404555223445641, 23.161451065716391895, + 105.32843438928830437, 39.48658950682147406, 9.2130759676656452939, 113.06716073407369549, + 18.435924054450879339, 67.831623623394989409, 26.749017223737610038, 50.314387990569230169, + 122.62124255135495332, 76.24406734470903757, 15.156420140730915591, 112.42483971938781906, + 40.362801806033530738, 32.670405696786474437, 82.284757990255457116, 53.32889191009599017, + 15.951992714217340108, 20.63048733202231233, 3.0771470775725902058, 58.129787006833794294, + 12.794424787556636147, 95.371322496725042583, 19.28536346855253214, 9.7881589807111595292, + 92.04222899369415245, 66.324597572744096396, 110.2189083104240126, 3.3515941403384204023, + 113.39265931958289002, 103.45368711595438072, 79.745823446162830805, 60.353494305680214893, + 123.28457883976079756, 31.12763900903519243, 64.986693073242349783, 108.59301324207990547, + 106.01556850440829294, 82.334966910784714855, 27.053318561589549063, 85.19310484948073281, + 55.16459468112225295, 54.622355302417417988, 41.226780809469346423, 23.464094948340061819, + 55.315426602006482426, 107.28799671613523969, 45.198571777153119911, 80.323084565403405577, + 68.924868120131577598, 75.915043428645731183, 110.87649383022653637, 0.16449705195554997772, + 19.195053287807240849, 93.59215162042164593, 50.532982871336571407, 121.0186532079897006, + 70.22044300183915766, 115.74195114975736942, 43.25391728593967855, 22.642643225895881187, + 64.490173541558760917, 127.85570622804880259, 67.043498317787452834, 111.17783964590853429, + 94.625122217788884882, 34.466134990430873586, 87.462001283689460251, 2.5460454443527851254, + 27.131253736286453204, 20.057284970243927091, 84.389493805792881176, 72.599383773678709986, + 78.23862908300361596, 8.2028846403118222952, 19.095708322332939133, 91.257523433603637386, + 0.38620178544442751445, 18.958186017032858217, 57.288477358615637058, 90.654698508482397301, + 52.130598973843007116, 30.971792528569494607, 80.436400970269460231, 107.54793500350933755, + 112.02673103734559845, 77.393417711646179669, 12.645384478124469751, 107.98875283581583062, + 121.87199305220929091, 3.0314139967704250012, 76.170258048052346567, 62.529193306614615722, + 25.923719091410021065, 77.214496750068065012, 23.759622836107155308, 106.67093858617226942, + 82.878555752224201569, 60.841884102570475079, 70.035506659227394266, 98.331690890852769371, + 115.46886250254465267, 74.608274148013151716, 76.833404179371427745, 116.0440173015849723, + 96.799899806937901303, 61.642706514769088244, 111.91017987576196902, 43.151294197672541486, + 97.982161909571004799, 71.565290162856399547, 68.704884879305609502, 77.307435117392742541, + 90.088207200202305103, 58.439416940007504309, 109.26054324678625562, 5.5446466951325419359, + 47.843610543739487184, 62.536811285881412914, 21.128144266025628895, 85.72692859916787711, + 3.6214004577341256663, 24.38090030379316886, 27.374258450428897049, 99.806059201928292168, + 121.54014182852188242, 95.188525067456794204, 44.143460160401446046, 99.174865108678204706, + 81.001258028205484152, 90.054041174924350344, 67.641186060551262926, 46.321660770121525275, + 51.343911456344358157, 85.315305061350954929, 30.150084362012421479, 16.755716605595807778, + 97.847879117660340853, 26.294686156117677456, 84.265353070761193521, 99.867184273898601532, + 24.380523945441382239, 77.310938187132705934, 116.33742211151547963, 11.901659930186724523, + 104.37205320172870415, 59.818278795613878174, 20.721985827818571124, 75.583008407618763158, + 35.98511117955786176, 11.080280398684408283, 87.81599996875229408, 88.584668287523527397, + 127.47465225305859349, 20.96347871484249481, 20.709115950841805898, 11.398784035220160149, + 63.642248655945877545, 58.126454808909329586, 39.885050240904092789, 4.5124833261979802046, + 91.435134571129310643, 113.08723203475528862, 3.3491378802573308349, 44.570637957131111762, + 88.961358348336943891, 6.6375313253302010708, 123.50331930725587881, 104.64543361480900785, + 32.976386022342921933, 77.524562067334045423, 51.528065303500625305, 29.943250314554461511, + 87.507352222266490571, 24.274894078716897639, 55.727917808522761334, 116.72930461545911385, + 33.121311419221456163, 30.624307587142538978, 79.581913257745327428, 91.943237432151363464, + 63.996388641699013533, 125.69044545745782671, 11.685887675135745667, 117.73129163891280768, + 53.034718805916782003, 125.96561596835817909, 106.63283432167736464, 56.535867517839506036, + 111.17319891633815132, 21.050965816149982857, 12.811565704683744116, 89.916000125918799313, + 119.63542337702165241, 17.240704274656309281, 23.973381537784007378, 12.440852898565935902, + 44.635578559169516666, 40.703350830630370183, 49.133888896074495278, 37.346489860301517183, + 92.564137767814827384, 57.76031379539927002, 34.578490970634447876, 56.356672498193802312, + 55.078714805957133649, 52.987578328647941817, 38.647646376375632826, 16.519090854661044432, + 5.4931748596682155039, 61.506881254554173211, 39.098428582834458211, 21.215168637616443448, + 54.018322489631827921, 112.10309728453285061, 11.269009249255759642, 60.273380687416647561, + 122.89840834543429082, 78.920948789887916064, 80.752895070032536751, 25.983595173343928764, + 62.300213042151881382, 87.881935317316674627, 7.8556069274709443562, 116.44028499041087343, + 35.086195705847785575, 25.529992820062034298, 61.95722389036018285, 21.670386868885543663, + 20.285482989365846151, 19.404951592259749305, 4.8137739285193674732, 16.208111095798813039, + 7.4212133890723634977, 31.043553976462135324, 127.18202307392493822, 126.42536212937557139, + 19.847877310330659384, 31.25130128027376486, 78.609990920165728312, 126.46865077723487047, + 82.202113946517783916, 42.185139788431115448, 86.669746522060449934, 22.381020091663231142, + 57.809434670638438547, 30.895522790473478381, 42.874897115761996247, 41.402659411149215885, + 98.878569119264284382, 122.89718201298455824, 14.767685560287645785, 8.3949934919000952505, + 8.5150509664817946032, 44.500286058420897461, 4.8166680073154566344, 19.07278343652797048, + 97.114783613491454162, 104.65038275558617897, 26.340923988060239935, 79.261218039104278432, + 13.137190416204248322, 97.410546577204513596, 37.207109081809903728, 83.703682094128453173, + 101.29747305838827742, 2.2178937894204864278, 31.116871822316170437, 5.0087323362567985896, + 109.66570970288739773, 25.64715538682139595, 91.938663226261269301, 8.8451307367213303223, + 80.817408976778096985, 39.659478819819923956, 4.7202886767445306759, 81.731643683684524149, + 6.572992794775927905, 89.005866162682650611, 39.942235156526294304, 18.639751113292732043, + 62.378350470451550791, 41.312030478973611025, 117.20650868755183183, 82.699821975555096287, + 7.9737176111593726091, 93.885511134332773509, 99.641187499742954969, 12.571744208136806265, + 100.52831312892158167, 101.53633463179357932, 2.210772438735148171, 16.614067913225881057, + 81.492080980508035282, 107.11233005602116464, 73.782317682136635995, 114.31430434835419874, + 127.96681821438687621, 121.47089164338831324, 109.12276020618082839, 100.97413962565042311, + 24.990638345399929676, 22.72881873789083329, 62.371455419910489582, 115.93390876935518463, + 26.995482223079307005, 106.90726757643278688, 70.98625824878399726, 25.966859064650634537, + 88.463494197818363318, 47.449424993897991953, 24.335713030424813041, 1.1093702913713059388, + 92.788272947425866732, 42.712213353785045911, 96.884700807837361936, 104.97075226459855912, + 55.451662341609335272, 44.8837169285507116, 74.429122227495099651, 46.195472556162712863, + 65.75512501899356721, 65.58628764672903344, 50.491146280695829773, 93.927304021795862354, + 124.90815491503599333, 63.557677779528603423, 7.7803081682977790479, 93.667699478686699877, + 78.771263431150146062, 104.80514658368338132, 65.301458179961628048, 8.8112910795571224298, + 14.418371916173782665, 25.743795054921065457, 123.30208322391263209, 125.68042190558480797, + 29.575357875124609563, 94.732540362303552683, 87.689375345846201526, 106.78601236519534723, + 108.88309664571352187, 18.233481113253219519, 69.670195579921710305, 21.889642489139077952, + 76.405678248404001351, 10.737461082029767567, 88.498027288616867736, 81.238377338271675399, + 27.215144881243759301, 54.414545948598970426, 97.429255815492069814, 55.735599854451720603, + 33.539357556157483486, 22.336680835174774984, 75.491704031843255507, 116.88962432648986578, + 96.813670726558484603, 65.502506356166122714, 111.34367435406238656, 82.236428533131402219, + 89.766452277675853111, 18.990088644281058805, 36.156413352538947947, 126.33106708128616447, + 114.05875480941904243, 48.735256503630807856, 74.983848033058166038, 76.35778045138795278, + 96.388091104468912818, 46.322902131436421769, 82.656868778576608747, 78.973179013642948121, + 18.426151935334928567, 98.134321468147390988, 36.871848108905396657, 7.6632472467899788171, + 53.498034447475220077, 100.62877598114209832, 117.24248510271354462, 24.488134689418075141, + 30.312840281465469161, 96.849679438775638118, 80.725603612067061476, 65.340811393576586852, + 36.569515980510914233, 106.65778382019198034, 31.903985428434680216, 41.26097466404462466, + 6.1542941551451804116, 116.25957401366758859, 25.588849575116910273, 62.742644993450085167, + 38.57072693710506428, 19.576317961425957037, 56.084457987391942879, 4.6491951454918307718, + 92.437816620848025195, 6.7031882806804787833, 98.78531863916941802, 78.907374231912399409, + 31.491646892325661611, 120.70698861136406776, 118.56915767952159513, 62.255278018074022839, + 1.9733861464883375447, 89.186026484163448913, 84.031137008820223855, 36.669933821569429711, + 54.106637123182736104, 42.38620969896146562, 110.3291893622445059, 109.24471060483483598, + 82.453561618938692845, 46.928189896680123638, 110.63085320401660283, 86.575993432270479389, + 90.3971435543098778, 32.646169130810449133, 9.8497362402667931747, 23.830086857295100344, + 93.752987660453072749, 0.32899410391109995544, 38.390106575618119678, 59.18430324084329186, + 101.06596574267678079, 114.03730641598303919, 12.440886003681953298, 103.48390229951473884, + 86.5078345718793571, 45.285286451795400353, 0.98034708312115981244, 127.71141245610124315, + 6.0869966355785436463, 94.355679291820706567, 61.250244435577769764, 68.932269980865385151, + 46.924002567378920503, 5.0920908887055702507, 54.262507472572906408, 40.114569940491492162, + 40.778987611589400331, 17.19876754736105795, 28.477258166007231921, 16.40576928062364459, + 38.191416644669516245, 54.515046867207274772, 0.7724035708888550289, 37.916372034065716434, + 114.5769547172349121, 53.309397016964794602, 104.26119794768601423, 61.943585057142627193, + 32.872801940542558441, 87.095870007022313075, 96.053462074694834882, 26.786835423292359337, + 25.290768956252577482, 87.977505671635299223, 115.74398610441858182, 6.0628279935444879811, + 24.340516096104693133, 125.05838661322923144, 51.847438182823680108, 26.428993500136130024, + 47.519245672217948595, 85.341877172348176828, 37.757111504448403139, 121.68376820514458814, + 12.071013318458426511, 68.663381781709176721, 102.93772500509294332, 21.216548296029941412, + 25.666808358746493468, 104.08803460317358258, 65.599799613875802606, 123.28541302954181447, + 95.82035975152393803, 86.302588395348720951, 67.964323819145647576, 15.130580325716437073, + 9.4097697586148569826, 26.61487023478912306, 52.176414400404610205, 116.8788338800186466, + 90.521086493572511245, 11.089293390265083872, 95.687221087478974368, 125.07362257176282583, + 42.256288532054895768, 43.453857198335754219, 7.2428009154682513326, 48.761800607586337719, + 54.748516900861432077, 71.612118403860222315, 115.08028365704740281, 62.377050134913588408, + 88.286920320806530071, 70.349730217360047391, 34.002516056414606282, 52.108082349852338666, + 7.2823721211025258526, 92.643321540243050549, 102.68782291269235429, 42.630610122701909859, + 60.300168724024842959, 33.511433211195253534, 67.695758235320681706, 52.58937231223899289, + 40.530706141526025021, 71.734368547797203064, 48.761047890886402456, 26.621876374269049847, + 104.67484422303095926, 23.803319860377087025, 80.744106403457408305, 119.63655759122775635, + 41.443971655640780227, 23.166016815237526316, 71.970222359115723521, 22.160560797372454545, + 47.631999937508226139, 49.169336575050692772, 126.94930450611718697, 41.92695742968498962, + 41.418231901683611795, 22.797568070440320298, 127.28449731189175509, 116.25290961781865917, + 79.770100481808185577, 9.024966652399598388, 54.870269142262259265, 98.174464069510577247, + 6.6982757605146616697, 89.141275914265861502, 49.922716696673887782, 13.27506265066404012, + 119.0066386145153956, 81.290867229618015699, 65.952772044689481845, 27.049124134668090846, + 103.05613060700125061, 59.886500629112561001, 47.014704444532981142, 48.549788157433795277, + 111.45583561704916065, 105.45860923091822769, 66.242622838442912325, 61.248615174288715934, + 31.163826515494292835, 55.886474864302726928, 127.99277728340166504, 123.38089091491565341, + 23.371775350275129313, 107.46258327782561537, 106.06943761183720198, 123.93123193671999616, + 85.265668643354729284, 113.07173503568265005, 94.346397832676302642, 42.101931632299965713, + 25.62313140937112621, 51.832000251841236604, 111.27084675404330483, 34.481408549312618561, + 47.946763075568014756, 24.881705797131871805, 89.271157118339033332, 81.406701661260740366, + 98.267777792148990557, 74.692979720606672345, 57.128275535629654769, 115.52062759079854004, + 69.156981941268895753, 112.71334499638760462, 110.1574296119142673, 105.97515665729588363, + 77.295292752751265652, 33.038181709322088864, 10.986349719336431008, 123.01376250910834642, + 78.196857165668916423, 42.430337275232886896, 108.03664497926729382, 96.206194569065701216, + 22.538018498511519283, 120.5467613748369331, 117.79681669087221962, 29.841897579779470107, + 33.505790140065073501, 51.967190346687857527, 124.60042608430740074, 47.763870634633349255, + 15.711213854945526691, 104.88056998082174687, 70.172391411695571151, 51.059985640124068595, + 123.9144477807203657, 43.340773737771087326, 40.570965978731692303, 38.809903184519498609, + 9.6275478570387349464, 32.416222191597626079, 14.842426778144726995, 62.087107952927908627, + 126.36404614785351441, 124.85072425875114277, 39.695754620661318768, 62.502602560551167699, + 29.219981840335094603, 124.93730155447337893, 36.404227893035567831, 84.370279576865868876, + 45.339493044120899867, 44.762040183326462284, 115.61886934127687709, 61.791045580946956761, + 85.749794231523992494, 82.805318822302069748, 69.757138238532206742, 117.79436402596911648, + 29.53537112057529157, 16.789986983800190501, 17.030101932963589206, 89.000572116841794923, + 9.6333360146309132688, 38.145566873059578938, 66.229567226986546302, 81.300765511172357947, + 52.681847976124117849, 30.522436078208556864, 26.274380832412134623, 66.821093154409027193, + 74.414218163623445434, 39.407364188260544324, 74.594946116776554845, 4.4357875788409728557, + 62.233743644632340875, 10.017464672517235158, 91.33141940577479545, 51.29431077364642988, + 55.877326452522538602, 17.690261473446298623, 33.63481795355619397, 79.318957639639847912, + 9.4405773534926993307, 35.463287367369048297, 13.145985589555493789, 50.011732325365301222, + 79.884470313052588608, 37.279502226585464086, 124.75670094090310158, 82.624060957950860029, + 106.41301737510730163, 37.399643951110192575, 15.947435222322383197, 59.771022268669184996, + 71.282374999485909939, 25.143488416277250508, 73.056626257846801309, 75.072669263587158639, + 4.4215448774702963419, 33.228135826455400093, 34.984161961019708542, 86.224660112045967253, + 19.564635364276909968, 100.62860869671203545, 127.93363642877739039, 114.94178328678026446, + 90.24552041236529476, 73.948279251300846227, 49.981276690799859352, 45.457637475781666581, + 124.74291083982461714, 103.86781753871036926, 53.990964446162251988, 85.814535152869211743, + 13.97251649756799452, 51.933718129304907052, 48.926988395636726636, 94.898849987795983907, + 48.671426060849626083, 2.2187405827462498564, 57.576545894851733465, 85.4244267075737298, + 65.76940161567836185, 81.941504529197118245, 110.90332468321867054, 89.767433857105061179, + 20.858244454990199301, 92.390945112329063704, 3.5102500379907723982, 3.1725752934580668807, + 100.98229256139529753, 59.854608043595362687, 121.81630983007198665, 127.11535555905720685, + 15.560616336599196075, 59.335398957377037732, 29.542526862303930102, 81.610293167370400624, + 2.6029163599232560955, 17.62258215911424486, 28.836743832347565331, 51.487590109845768893, + 118.60416644782890216, 123.36084381116961595, 59.150715750252857106, 61.465080724610743346, + 47.378750691696041031, 85.572024730394332437, 89.766193291427043732, 36.466962226510077016, + 11.34039115984342061, 43.779284978281793883, 24.811356496808002703, 21.474922164063173113, + 48.996054577237373451, 34.476754676543350797, 54.430289762487518601, 108.82909189720157883, + 66.858511630984139629, 111.47119970890344121, 67.078715112314966973, 44.673361670353187947, + 22.983408063690148992, 105.77924865298336954, 65.627341453120607184, 3.0050127123358834069, + 94.68734870812841109, 36.472857066266442416, 51.532904555351706222, 37.98017728856211761, + 72.312826705081533873, 124.66213416257596691, 100.11750961883808486, 97.470513007265253691, + 21.967696066119970055, 24.71556090277954354, 64.776182208937825635, 92.645804262876481516, + 37.313737557156855473, 29.946358027285896242, 36.852303870673495112, 68.268642936294781975, + 73.743696217810793314, 15.326494493579957634, 106.99606889495407813, 73.257551962287834613, + 106.48497020542708924, 48.976269378836150281, 60.625680562934576301, 65.699358877554914216, + 33.451207224137760932, 2.6816227871531737037, 73.139031961025466444, 85.315567640383960679, + 63.807970856869360432, 82.52194932808924932, 12.308588310293998802, 104.51914802733517718, + 51.177699150233820546, 125.48528998690017033, 77.141453874210128561, 39.152635922851914074, + 112.16891597478388576, 9.2983902909872995224, 56.875633241696050391, 13.406376561364595545, + 69.570637278342474019, 29.814748463824798819, 62.9832937846549612, 113.41397722273177351, + 109.13831535904319026, 124.51055603614804568, 3.9467722929803130683, 50.372052968330535805, + 40.06227401764044771, 73.339867643138859421, 108.21327424636547221, 84.772419397926569218, + 92.658378724492649781, 90.489421209673309932, 36.907123237877385691, 93.856379793363885256, + 93.261706408036843641, 45.151986864544596756, 52.7942871086197556, 65.292338261620898265, + 19.699472480533586349, 47.660173714593838667, 59.505975320906145498, 0.65798820782219991088, + 76.780213151236239355, 118.3686064816902217, 74.131931485357199563, 100.07461283196607837, + 24.881772007367544575, 78.967804599033115664, 45.015669143758714199, 90.570572903590800706, + 1.9606941662459576037, 127.4228249122024863, 12.173993271160725271, 60.711358583641413134, + 122.50048887115917751, 9.8645399617307703011, 93.848005134757841006, 10.184181777411140501, + 108.52501494514581282, 80.229139880982984323, 81.557975223178800661, 34.3975350947221159, + 56.954516332014463842, 32.811538561247289181, 76.38283328933903249, 109.03009373441454954, + 1.5448071417777100578, 75.832744068135070847, 101.15390943446982419, 106.61879403393322718, + 80.522395895372028463, 123.88717011428525439, 65.745603881088754861, 46.191740014048264129, + 64.106924149389669765, 53.573670846584718674, 50.581537912508792942, 47.955011343274236424, + 103.48797220883716363, 12.125655987088975962, 48.681032192213024246, 122.11677322645846289, + 103.69487636564736022, 52.857987000272260047, 95.038491344439535169, 42.683754344696353655, + 75.514223008900444256, 115.36753641028917627, 24.142026636920491001, 9.3267635634219914209, + 77.87545001018588664, 42.433096592059882823, 51.333616717496624915, 80.176069206350803142, + 3.1995992277552431915, 118.57082605908726691, 63.640719503051514039, 44.605176790701079881, + 7.9286476382912951522, 30.261160651432874147, 18.819539517229713965, 53.22974046957824612, + 104.35282880081285839, 105.75766776004093117, 53.042172987145022489, 22.178586780533805722, + 63.374442174961586716, 122.14724514352565166, 84.512577064109791536, 86.907714396671508439, + 14.485601830936502665, 97.523601215172675438, 109.49703380172650213, 15.22423680772408261, + 102.16056731409480562, 124.7541002698308148, 48.573840641616698122, 12.699460434720094781, + 68.005032112829212565, 104.21616469970467733, 14.564744242208689684, 57.286643080489739077, + 77.375645825384708587, 85.261220245403819717, 120.60033744804968592, 67.022866422394145047, + 7.3915164706413634121, 105.17874462447798578, 81.061412283055688022, 15.468737095594406128, + 97.522095781772804912, 53.243752748541737674, 81.349688446061918512, 47.606639720757812029, + 33.488212806918454589, 111.2731151824555127, 82.887943311281560455, 46.332033630478690611, + 15.940444718231447041, 44.321121594744909089, 95.263999875016452279, 98.338673150105023524, + 125.89860901223437395, 83.85391485936997924, 82.836463803367223591, 45.595136140884278575, + 126.56899462378714816, 104.50581923564095632, 31.540200963616371155, 18.049933304799196776, + 109.74053828452815651, 68.348928139021154493, 13.396551521032961318, 50.282551828531723004, + 99.845433393347775564, 26.550125301331718219, 110.01327722903442918, 34.581734459239669377, + 3.9055440893789636903, 54.098248269339819672, 78.11226121400250122, 119.773001258225122, + 94.029408889065962285, 97.099576314871228533, 94.911671234101959271, 82.917218461840093369, + 4.4852456768858246505, 122.49723034857743187, 62.32765303098858567, 111.77294972860909184, + 127.98555456680696807, 118.76178182983130682, 46.743550700553896604, 86.925166555654868716, + 84.138875223678041948, 119.86246387344363029, 42.531337286713096546, 98.143470071368938079, + 60.692795665352605283, 84.203863264599931426, 51.246262818742252421, 103.66400050368611119, + 94.541693508086609654, 68.962817098625237122, 95.893526151136029512, 49.763411594267381588, + 50.542314236681704642, 34.81340332252511871, 68.535555584301619092, 21.385959441213344689, + 114.25655107126294752, 103.04125518160071806, 10.313963882541429484, 97.426689992778847227, + 92.314859223832172574, 83.950313314595405245, 26.590585505502531305, 66.076363418644177727, + 21.972699438676499994, 118.02752501822033082, 28.393714331337832846, 84.86067455046941177, + 88.073289958538225619, 64.412389138131402433, 45.076036997026676545, 113.09352274967750418, + 107.59363338174443925, 59.683795159558940213, 67.011580280130147003, 103.93438069337935303, + 121.20085216861480149, 95.527741269266698509, 31.422427709894691361, 81.761139961647131713, + 12.344782823391142301, 102.11997128025177517, 119.8288955614407314, 86.681547475542174652, + 81.141931957463384606, 77.619806369038997218, 19.255095714077469893, 64.832444383195252158, + 29.684853556289453991, 124.17421590585945523, 124.7280922957106668, 121.70144851750228554, + 79.391509241322637536, 125.0052051211023354, 58.439963680673827184, 121.87460310894675786, + 72.808455786074773641, 40.740559153731737752, 90.678986088241799735, 89.524080366656562546, + 103.23773868255375419, 123.5820911618975515, 43.499588463051622966, 37.610637644607777474, + 11.514276477068051463, 107.58872805193823297, 59.070742241150583141, 33.579973967600381002, + 34.060203865930816391, 50.001144233683589846, 19.266672029261826538, 76.291133746122795856, + 4.4591344539767305832, 34.601531022344715893, 105.3636959522482357, 61.044872156417113729, + 52.548761664827907225, 5.6421863088216923643, 20.828436327246890869, 78.814728376524726627, + 21.189892233553109691, 8.8715751576819457114, 124.46748728926468175, 20.034929345038108295, + 54.662838811549590901, 102.58862154729285976, 111.7546529050450772, 35.380522946892597247, + 67.269635907116025919, 30.637915279279695824, 18.881154706985398661, 70.926574734738096595, + 26.291971179110987578, 100.02346465073424042, 31.768940626105177216, 74.559004453170928173, + 121.51340188180984114, 37.248121915905358037, 84.826034750214603264, 74.799287902220385149, + 31.894870444644766394, 119.54204453734200797, 14.564749998971819878, 50.286976832558138995, + 18.113252515697240597, 22.145338527174317278, 8.8430897549405926839, 66.456271652910800185, + 69.968323922043055063, 44.449320224091934506, 39.129270728557457915, 73.257217393427708885, + 127.86727285755841876, 101.8835665735641669, 52.491040824734227499, 19.896558502601692453, + 99.962553381599718705, 90.91527495156697114, 121.48582167965287226, 79.735635077420738526, + 107.98192889232814196, 43.629070305738423485, 27.94503299513598904, 103.8674362586098141, + 97.853976791277091252, 61.797699975591967814, 97.342852121699252166, 4.4374811654924997129, + 115.15309178970710491, 42.848853415151097579, 3.5388032313603616785, 35.883009058397874469, + 93.806649366440979065, 51.534867714210122358, 41.716488909984036582, 56.781890224658127408, + 7.0205000759815447964, 6.3451505869197717402, 73.964585122790595051, 119.70921608719436335, + 115.63261966014761128, 126.23071111811441369, 31.121232673198392149, 118.67079791475407546, + 59.085053724611498183, 35.220586334740801249, 5.205832719846512191, 35.245164318228489719, + 57.673487664695130661, 102.97518021969517577, 109.20833289566144231, 118.72168762233923189, + 118.30143150050571421, 122.93016144922148669, 94.75750138339572004, 43.144049460792302852, + 51.532386582854087465, 72.933924453020154033, 22.68078231968684122, 87.558569956563587766, + 49.622712993616005406, 42.949844328126346227, 97.992109154474746902, 68.953509353086701594, + 108.86057952497867518, 89.658183794406795641, 5.7170232619719172362, 94.94239941781052039, + 6.1574302246299339458, 89.346723340706375893, 45.966816127383935964, 83.558497305970377056, + 3.2546829062412143685, 6.0100254246754047927, 61.37469741625682218, 72.945714132532884832, + 103.06580911070341244, 75.960354577127873199, 16.625653410166705726, 121.3242683251555718, + 72.235019237679807702, 66.941026014530507382, 43.935392132239940111, 49.431121805562725058, + 1.552364417879289249, 57.291608525752963033, 74.627475114313710947, 59.892716054571792483, + 73.704607741350628203, 8.5372858725932019297, 19.487392435621586628, 30.652988987163553247, + 85.992137789911794243, 18.515103924579307204, 84.969940410854178481, 97.952538757672300562, + 121.25136112587279058, 3.3987177551098284312, 66.902414448275521863, 5.3632455743099853862, + 18.278063922054570867, 42.631135280767921358, 127.61594171374235884, 37.043898656178498641, + 24.617176620591635583, 81.038296054670354351, 102.35539830047127907, 122.97057997380397865, + 26.282907748420257121, 78.305271845707466127, 96.337831949567771517, 18.596780581974599045, + 113.75126648339210078, 26.81275312273282907, 11.141274556684948038, 59.629496927649597637, + 125.96658756931356038, 98.827954445467184996, 90.27663071809001849, 121.02111207229609136, + 7.8935445859606261365, 100.74410593666107161, 80.124548035284533398, 18.679735286281356821, + 88.426548492734582396, 41.544838795856776414, 57.31675744898893754, 52.978842419346619863, + 73.81424647575840936, 59.71275958673140849, 58.523412816073687281, 90.303973729089193512, + 105.58857421724314918, 2.5846765232417965308, 39.398944961067172699, 95.320347429187677335, + 119.011950641812291, 1.3159764156480378006, 25.560426302476116689, 108.73721296338408138, + 20.263862970718037104, 72.149225663932156749, 49.763544014738727128, 29.935609198066231329, + 90.031338287521066377, 53.141145807181601413, 3.9213883324955531862, 126.84564982440497261, + 24.347986542321450543, 121.42271716728646425, 117.00097774231835501, 19.729079923465178581, + 59.696010269515682012, 20.368363554825918982, 89.050029890295263613, 32.458279761969606625, + 35.115950446357601322, 68.795070189444231801, 113.90903266402892768, 65.62307712249821634, + 24.765666578681702958, 90.060187468829099089, 3.0896142835590580944, 23.665488136273779674, + 74.307818868943286361, 85.237588067870092345, 33.044791790747694904, 119.77434022857414675, + 3.4912077621775097214, 92.383480028100166237, 0.21384829877933952957, 107.14734169316943735, + 101.16307582501758588, 95.910022686552110827, 78.975944417674327269, 24.251311974177951925, + 97.36206438442968647, 116.23354645292056375, 79.389752731294720434, 105.71597400054815807, + 62.076982688879070338, 85.367508689396345289, 23.028446017804526491, 102.73507282057835255, + 48.284053273840982001, 18.653527126847620821, 27.75090002037177328, 84.866193184119765647, + 102.66723343499688781, 32.352138412701606285, 6.3991984555141243618, 109.14165211817453383, + 127.28143900610302808, 89.210353581402159762, 15.857295276582590304, 60.522321302865748294, + 37.63907903445942793, 106.45948093916013022, 80.705657601629354758, 83.515335520081862342, + 106.08434597429004498, 44.357173561067611445, 126.74888434992681141, 116.29449028705494129, + 41.025154128223221051, 45.815428793343016878, 28.971203661876643309, 67.047202430348988855, + 90.994067603453004267, 30.448473615451803198, 76.321134628193249227, 121.50820053966162959, + 97.147681283233396243, 25.398920869443827542, 8.0100642256620631088, 80.432329399409354664, + 29.129488484417379368, 114.57328616098311613, 26.751291650773055153, 42.522440490811277414, + 113.20067489610300981, 6.0457328447882900946, 14.783032941286364803, 82.35748924895960954, + 34.122824566111376043, 30.937474191192450235, 67.044191563545609824, 106.48750549708711333, + 34.699376892123837024, 95.213279441515624058, 66.976425613840547157, 94.546230364914663369, + 37.775886622563120909, 92.664067260957381222, 31.880889436462894082, 88.642243189493456157, + 62.527999750036542537, 68.677346300213685026, 123.79721802447238588, 39.707829718743596459, + 37.672927606734447181, 91.190272281772195129, 125.13798924757793429, 81.011638471281912643, + 63.08040192723274231, 36.099866609602031531, 91.481076569059950998, 8.6978562780423089862, + 26.793103042065922637, 100.56510365706708399, 71.690866786695551127, 53.100250602667074418, + 92.026554458068858366, 69.163468918479338754, 7.8110881787579273805, 108.19649653868327732, + 28.224522428008640418, 111.54600251645388198, 60.058817778135562548, 66.199152629746095045, + 61.823342468207556522, 37.834436923680186737, 8.9704913537752872799, 116.99446069715486374, + 124.65530606198080932, 95.545899457221821649, 127.97110913361757412, 109.52356365966261365, + 93.487101401111431187, 45.850333111313375412, 40.277750447359721875, 111.72492774688726058, + 85.062674573429831071, 68.286940142737876158, 121.38559133070884855, 40.407726529199862853, + 102.49252563748814282, 79.328001007375860354, 61.083387016176857287, 9.9256341972541122232, + 63.787052302272059023, 99.526823188534763176, 101.08462847336340928, 69.6268066450538754, + 9.071111168603238184, 42.771918882430327358, 100.51310214252953301, 78.082510363201436121, + 20.627927765086496947, 66.853379985561332433, 56.629718447667983128, 39.90062662919081049, + 53.181171011008700589, 4.1527268372883554548, 43.945398877356637968, 108.05505003644066164, + 56.78742866267930367, 41.721349100942461519, 48.146579917080089217, 0.82477827626280486584, + 90.152073994056991069, 98.187045499358646339, 87.187266763488878496, 119.36759031912151841, + 6.0231605602639319841, 79.868761386762344046, 114.40170433723324095, 63.055482538533397019, + 62.844855419793020701, 35.522279923294263426, 24.689565646785922581, 76.239942560507188318, + 111.65779112288510078, 45.363094951087987283, 34.283863914930407191, 27.239612738077994436, + 38.510191428158577764, 1.6648887663905043155, 59.36970711258254596, 120.34843181172254845, + 121.45618459142497159, 115.40289703500820906, 30.78301848264891305, 122.01041024220467079, + 116.87992736135129235, 115.74920621789715369, 17.616911572149547283, 81.481118307467113482, + 53.357972176487237448, 51.048160733316763071, 78.475477365111146355, 119.164182323795103, + 86.999176926103245933, 75.221275289215554949, 23.028552954139740905, 87.177456103876465932, + 118.14148448230116628, 67.159947935200762004, 68.120407731861632783, 100.00228846736717969, + 38.533344058527291054, 24.582267492245591711, 8.9182689079534611665, 69.203062044693069765, + 82.727391904496471398, 122.08974431283422746, 105.09752332965581445, 11.284372617643384729, + 41.656872654497419717, 29.629456753049453255, 42.379784467106219381, 17.743150315367529402, + 120.9349745785293635, 40.06985869007621659, 109.32567762310281978, 77.177243094589357497, + 95.509305810090154409, 70.761045893788832473, 6.5392718142320518382, 61.275830558559391648, + 37.762309413974435301, 13.85314946947619319, 52.583942358225613134, 72.046929301468480844, + 63.537881252213992411, 21.118008906345494324, 115.02680376361968229, 74.496243831814354053, + 41.652069500432844507, 21.598575804440770298, 63.789740889293170767, 111.08408907468401594, + 29.129499997943639755, 100.57395366511627799, 36.226505031394481193, 44.290677054348634556, + 17.686179509884823347, 4.9125433058252383489, 11.936647844086110126, 88.898640448183869012, + 78.258541457118553808, 18.514434786859055748, 127.73454571512047551, 75.767133147128333803, + 104.982081649468455, 39.793117005207022885, 71.925106763203075388, 53.830549903137580259, + 114.9716433593093825, 31.47127015484511503, 87.963857784656283911, 87.258140611476846971, + 55.890065990275616059, 79.734872517223266186, 67.707953582554182503, 123.59539995118757361, + 66.685704243398504332, 8.8749623309886374045, 102.30618357941420982, 85.697706830302195158, + 7.0776064627207233571, 71.766018116799386917, 59.613298732881958131, 103.06973542842024472, + 83.432977819968073163, 113.56378044931625482, 14.041000151963089593, 12.690301173843181459, + 19.929170245584828081, 111.41843217439236469, 103.26523932029886055, 124.46142223622882739, + 62.242465346400422277, 109.34159582950815093, 118.17010744922299637, 70.441172669481602497, + 10.411665439693024382, 70.490328636456979439, 115.3469753293938993, 77.950360439393989509, + 90.416665791326522594, 109.44337524468210177, 108.6028630010150664, 117.86032289844661136, + 61.515002766791440081, 86.288098921584605705, 103.06477316571181291, 17.867848906040308066, + 45.361564639377320418, 47.117139913127175532, 99.245425987232010812, 85.899688656256330432, + 67.984218308953131782, 9.9070187061770411674, 89.721159049960988341, 51.316367588813591283, + 11.434046523947472451, 61.88479883562104078, 12.31486044926350587, 50.693446681412751786, + 91.933632254771509906, 39.116994611940754112, 6.509365812482428737, 12.020050849350809585, + 122.74939483251728234, 17.891428265069407644, 78.131618221410462866, 23.920709154255746398, + 33.25130682033704943, 114.64853665031478158, 16.470038475363253383, 5.882052029061014764, + 87.870784264479880221, 98.862243611125450116, 3.1047288357585784979, 114.58321705150956404, + 21.254950228627421893, 119.78543210914722295, 19.409215482701256406, 17.074571745186403859, + 38.974784871243173257, 61.305977974330744473, 43.984275579823588487, 37.030207849162252387, + 41.93988082171199494, 67.905077515348239103, 114.50272225174558116, 6.7974355102232948411, + 5.8048288965510437265, 10.726491148619970772, 36.556127844109141733, 85.262270561539480696, + 127.23188342748471769, 74.087797312356997281, 49.234353241186909145, 34.076592109344346682, + 76.710796600946196122, 117.94115994760795729, 52.565815496844152221, 28.610543691418570234, + 64.675663899135543033, 37.193561163952836068, 99.502532966784201562, 53.625506245465658139, + 22.282549113369896077, 119.25899385530283325, 123.93317513863075874, 69.655908890938007971, + 52.553261436183674959, 114.04222414459218271, 15.787089171924890252, 73.488211873325781198, + 32.249096070569066796, 37.35947057256635162, 48.853096985469164792, 83.089677591713552829, + 114.63351489797787508, 105.9576848386968777, 19.628492951516818721, 119.42551917346281698, + 117.04682563215101254, 52.607947458182025002, 83.177148434486298356, 5.1693530464835930616, + 78.797889922137983376, 62.640694858378992649, 110.02390128362458199, 2.6319528312960756011, + 51.120852604955871357, 89.474425926768162753, 40.527725941439712187, 16.298451327864313498, + 99.527088029477454256, 59.871218396136100637, 52.062676575042132754, 106.28229161436320283, + 7.8427766649947443511, 125.69129964880994521, 48.695973084646539064, 114.84543433457656647, + 106.00195548463671003, 39.458159846930357162, 119.39202053903136402, 40.736727109655475942, + 50.100059780590527225, 64.91655952393921325, 70.231900892718840623, 9.5901403788921015803, + 99.818065328061493346, 3.2461542449964326806, 49.531333157367043896, 52.120374937658198178, + 6.1792285671181161888, 47.330976272551197326, 20.615637737890210701, 42.475176135740184691, + 66.089583581499027787, 111.5486804571482935, 6.9824155243586574215, 56.766960056200332474, + 0.42769659756231703795, 86.294683386342512676, 74.326151650038809748, 63.820045373107859632, + 29.951888835348654538, 48.502623948359541828, 66.724128768863010919, 104.46709290584476548, + 30.779505462593078846, 83.431948001096316148, 124.15396537776177865, 42.735017378792690579, + 46.056892035612690961, 77.470145641156705096, 96.568106547681964003, 37.307054253695241641, + 55.501800040747184539, 41.732386368243169272, 77.334466869993775617, 64.70427682540321257, + 12.798396911031886702, 90.28330423635270563, 126.56287801220969413, 50.420707162804319523, + 31.714590553165180609, 121.04464260573149659, 75.27815806892249384, 84.918961878323898418, + 33.411315203262347495, 39.030671040167362662, 84.168691948580089957, 88.714347122138860868, + 125.4977686998572608, 104.58898057410988258, 82.050308256446442101, 91.630857586686033756, + 57.942407323756924598, 6.0944048607016156893, 53.988135206906008534, 60.896947230907244375, + 24.642269256390136434, 115.01640107932689716, 66.295362566466792487, 50.797841738887655083, + 16.020128451327764196, 32.864658798818709329, 58.258976968838396715, 101.14657232196623227, + 53.502583301546110306, 85.044880981626192806, 98.401349792206019629, 12.091465689576580189, + 29.566065882576367585, 36.71497849791921908, 68.245649132222752087, 61.874948382388538448, + 6.0883831270948576275, 84.975010994174226653, 69.398753784251312027, 62.426558883034886094, + 5.9528512276847322937, 61.092460729829326738, 75.551773245129879797, 57.328134521914762445, + 63.761778872929426143, 49.284486378986912314, 125.05599950007672305, 9.3546926004310080316, + 119.59443604894477176, 79.415659437487192918, 75.345855213472532341, 54.380544563548028236, + 122.27597849515950656, 34.023276942563825287, 126.16080385446548462, 72.19973321920770104, + 54.962153138119901996, 17.395712556084617972, 53.586206084135483252, 73.130207314137805952, + 15.381733573391102254, 106.20050120533778681, 56.053108916141354712, 10.326937836958677508, + 15.62217635751949274, 88.392993077366554644, 56.449044856020918814, 95.092005032907763962, + 120.11763555627476308, 4.3983052594921900891, 123.64668493641511304, 75.668873847360373475, + 17.940982707554212539, 105.98892139431336545, 121.31061212396525661, 63.091798914447281277, + 127.94221826723878621, 91.047127319328865269, 58.974202802222862374, 91.700666222626750823, + 80.555500894723081728, 95.449855493778159143, 42.12534914686330012, 8.5738802854793902952, + 114.77118266141769709, 80.815453058403363684, 76.985051274979923619, 30.656002014751720708, + 122.16677403235371457, 19.851268394508224446, 127.57410460454775603, 71.053646377073164331, + 74.169256946730456548, 11.2536132901077508, 18.142222337206476368, 85.543837764864292694, + 73.026204285062704002, 28.165020726402872242, 41.255855530176631873, 5.7067599711226648651, + 113.25943689533596626, 79.801253258381620981, 106.36234202201740118, 8.3054536745767109096, + 87.890797754716913914, 88.110100072881323285, 113.57485732535860734, 83.442698201884923037, + 96.293159834160178434, 1.6495565525292477105, 52.304147988117620116, 68.374090998720930656, + 46.374533526981394971, 110.73518063824303681, 12.046321120531501947, 31.73752277352832607, + 100.8034086744664819, 126.11096507706679404, 125.6897108395860414, 71.044559846588526852, + 49.379131293575483141, 24.479885121018014615, 95.315582245770201553, 90.726189902175974566, + 68.567727829860814381, 54.479225476155988872, 77.020382856317155529, 3.329777532781008631, + 118.7394142251687299, 112.69686362344873487, 114.91236918285358115, 102.80579407001641812, + 61.566036965301464079, 116.02082048441297957, 105.75985472270622267, 103.49841243579430738, + 35.233823144302732544, 34.962236614934226964, 106.7159443529744749, 102.09632146663716412, + 28.950954730225930689, 110.32836464759384398, 45.998353852210129844, 22.442550578431109898, + 46.057105908283119788, 46.354912207756569842, 108.28296896460597054, 6.3198958704051619861, + 8.2408154637269035447, 72.004576934734359384, 77.066688117054582108, 49.164534984491183423, + 17.836537815910560312, 10.406124089389777509, 37.454783808996580774, 116.17948862567209289, + 82.1950466593116289, 22.568745235286769457, 83.313745308994839434, 59.25891350609890651, + 84.759568934212438762, 35.486300630738696782, 113.869949157058727, 80.139717380156071158, + 90.651355246209277539, 26.354486189182352973, 63.018611620183946798, 13.522091787577664945, + 13.078543628464103676, 122.5516611171187833, 75.524618827948870603, 27.706298938952386379, + 105.16788471645486425, 16.093858602936961688, 127.07576250442798482, 42.236017812694626627, + 102.05360752724300255, 20.992487663628708106, 83.304139000865689013, 43.197151608881540596, + 127.57948177858997951, 94.168178149368031882, 58.258999995890917489, 73.147907330232555978, + 72.453010062788962387, 88.581354108697269112, 35.372359019769646693, 9.8250866116504766978, + 23.873295688175858231, 49.797280896371376002, 28.517082914237107616, 37.028869573721749475, + 127.46909143024458899, 23.534266294260305585, 81.964163298936909996, 79.586234010417683749, + 15.850213526406150777, 107.6610998062787985, 101.94328671861876501, 62.942540309693868039, + 47.927715569316205801, 46.516281222953693941, 111.7801319805548701, 31.469745034450170351, + 7.4159071651120029856, 119.19079990237878519, 5.3714084867970086634, 17.749924661980912788, + 76.612367158832057612, 43.395413660604390316, 14.155212925445084693, 15.532036233598773833, + 119.22659746576755424, 78.139470856844127411, 38.865955639939784305, 99.127560898632509634, + 28.082000303926179186, 25.380602347686362918, 39.85834049117329414, 94.836864348788367352, + 78.530478640601359075, 120.92284447245765477, 124.48493069280448253, 90.683191659019939834, + 108.34021489844963071, 12.882345338963204995, 20.823330879389686743, 12.980657272917596856, + 102.69395065879143658, 27.900720878791616997, 52.833331582656683167, 90.88675048936784151, + 89.205726002033770783, 107.72064579689322272, 123.03000553358651814, 44.576197843172849389, + 78.129546331423625816, 35.735697812080616131, 90.723129278754640836, 94.234279826257989043, + 70.490851974467659602, 43.799377312516298844, 7.9684366179062635638, 19.814037412357720314, + 51.442318099921976682, 102.63273517762718257, 22.868093047894944903, 123.76959767124208156, + 24.629720898527011741, 101.38689336282914155, 55.867264509543019813, 78.233989223881508224, + 13.018731624964857474, 24.040101698705257149, 117.49878966503456468, 35.782856530142453266, + 28.263236442820925731, 47.841418308511492796, 66.502613640677736839, 101.29707330062956316, + 32.940076950726506766, 11.764104058125667507, 47.741568528963398421, 69.724487222250900231, + 6.2094576715207949746, 101.16643410301912809, 42.509900457258481765, 111.57086421829444589, + 38.818430965402512811, 34.149143490372807719, 77.949569742486346513, 122.61195594866148895, + 87.968551159647176974, 74.060415698324504774, 83.87976164342762786, 7.8101550307001161855, + 101.00544450349116232, 13.594871020446589682, 11.609657793102087453, 21.452982297239941545, + 73.112255688221921446, 42.52454112308259937, 126.46376685497307335, 20.175594624713994563, + 98.468706482373818289, 68.153184218692331342, 25.421593201896030223, 107.88231989521591458, + 105.13163099368830444, 57.221087382840778446, 1.351327798271086067, 74.387122327909310116, + 71.005065933568403125, 107.25101249093131628, 44.565098226743430132, 110.51798771060930449, + 119.86635027726515546, 11.311817781876015943, 105.1065228723709879, 100.08444828918436542, + 31.574178343853418482, 18.976423746651562396, 64.498192141138133593, 74.718941145132703241, + 97.706193970941967564, 38.179355183430743637, 101.26702979595938814, 83.91536967739375541, + 39.256985903037275421, 110.85103834692927194, 106.09365126430202508, 105.21589491636768798, + 38.354296868972596712, 10.338706092970824102, 29.595779844275966752, 125.28138971676162328, + 92.047802567249163985, 5.2639056625921512023, 102.24170520991538069, 50.948851853536325507, + 81.055451882879424375, 32.596902655732264975, 71.054176058954908513, 119.74243679227220127, + 104.12535315008790349, 84.56458322872640565, 15.685553329993126681, 123.38259929761989042, + 97.391946169296716107, 101.69086866915677092, 84.003910969273420051, 78.916319693864352303, + 110.78404107806272805, 81.473454219310951885, 100.20011956118469243, 1.8331190478820644785, + 12.463801785437681247, 19.180280757787841139, 71.636130656122986693, 6.4923084899928653613, + 99.062666314734087791, 104.24074987531639636, 12.358457134236232378, 94.661952545102394652, + 41.231275475780421402, 84.95035227148400736, 4.1791671630016935524, 95.097360914296586998, + 13.964831048717314843, 113.53392011240066495, 0.85539319512827205472, 44.589366772688663332, + 20.652303300077619497, 127.64009074621571926, 59.903777670697309077, 97.005247896722721634, + 5.4482575377296598163, 80.934185811689530965, 61.559010925189795671, 38.863896002196270274, + 120.30793075552355731, 85.470034757585381158, 92.113784071229019901, 26.940291282317048172, + 65.136213095363928005, 74.614108507390483283, 111.00360008149436908, 83.464772736489976523, + 26.668933739991189213, 1.4085536508064251393, 25.596793822067411384, 52.566608472709049238, + 125.12575602441938827, 100.84141432560863905, 63.429181106333999196, 114.08928521146663115, + 22.556316137848625658, 41.837923756647796836, 66.82263040652469499, 78.061342080338363303, + 40.337383897163817892, 49.428694244281359715, 122.99553739971815958, 81.177961148223403143, + 36.100616512896522181, 55.261715173372067511, 115.8848146475138492, 12.188809721403231379, + 107.97627041381201707, 121.79389446181448875, 49.284538512783910846, 102.0328021586574323, + 4.5907251329335849732, 101.59568347777531017, 32.040256902655528393, 65.729317597637418658, + 116.51795393768043141, 74.293144643932464533, 107.00516660309585859, 42.089761963256023591, + 68.802699584412039258, 24.182931379153160378, 59.13213176515273517, 73.42995699584207614, + 8.4912982644455041736, 123.7498967647770769, 12.176766254193353234, 41.950021988352091284, + 10.797507568502624054, 124.85311776606977219, 11.905702455369464587, 122.18492145966229145, + 23.103546490259759594, 114.65626904382952489, 127.52355774585885229, 98.568972757977462607, + 122.1119990001534461, 18.709385200865654042, 111.18887209789318149, 30.831318874978023814, + 22.691710426945064683, 108.76108912709969445, 116.55195699031901313, 68.046553885131288553, + 124.32160770893460722, 16.399466438415402081, 109.92430627623980399, 34.791425112169235945, + 107.17241216827460448, 18.260414628275611904, 30.763467146785842488, 84.401002410675573628, + 112.10621783228270942, 20.653875673917355016, 31.244352715042623458, 48.785986154733109288, + 112.89808971204547561, 62.184010065819165902, 112.23527111254952615, 8.796610518988018157, + 119.29336987283386406, 23.337747694720746949, 35.881965415112063056, 83.977842788630368887, + 114.62122424793051323, 126.18359782889820053, 127.8844365344812104, 54.094254638657730538, + 117.94840560444936273, 55.401332445257139625, 33.111001789449801436, 62.899710987556318287, + 84.250698293726600241, 17.147760570962418569, 101.54236532283903216, 33.630906116810365347, + 25.970102549959847238, 61.312004029507079395, 116.33354806470742915, 39.702536789020086871, + 127.14820920909915003, 14.10729275414996664, 20.338513893460913096, 22.507226580215501599, + 36.284444674416590715, 43.087675529732223367, 18.052408570125408005, 56.330041452805744484, + 82.511711060353263747, 11.413519942248967709, 98.51887379067557049, 31.60250651676687994, + 84.724684044034802355, 16.610907349157059798, 47.781595509437465807, 48.22020014576628455, + 99.14971465072085266, 38.885396403773484053, 64.586319668320356868, 3.299113105058495421, + 104.60829597623887821, 8.7481819974418613128, 92.74906705396642792, 93.470361276486073621, + 24.092642241063003894, 63.475045547060290119, 73.606817348936601775, 124.22193015413722605, + 123.37942167917572078, 14.089119693177053705, 98.758262587150966283, 48.95977024203966721, + 62.631164491544041084, 53.452379804355587112, 9.1354556597216287628, 108.95845095231561572, + 26.040765712634311058, 6.6595550655656552408, 109.47882845034109778, 97.393727246901107719, + 101.82473836571080028, 77.611588140032836236, 123.13207393060656614, 104.04164096882959711, + 83.519709445416083327, 78.996824871588614769, 70.467646288605465088, 69.924473229872091906, + 85.43188870595258777, 76.192642933274328243, 57.901909460455499357, 92.656729295187687967, + 91.996707704420259688, 44.885101156862219796, 92.114211816566239577, 92.709824415516777663, + 88.565937929211941082, 12.639791740810323972, 16.481630927457445068, 16.009153869472356746, + 26.133376234109164216, 98.329069968982366845, 35.673075631821120623, 20.812248178779555019, + 74.909567617996799527, 104.35897725134782377, 36.390093318623257801, 45.137490470577176893, + 38.627490617989678867, 118.517827012201451, 41.519137868424877524, 70.972601261481031543, + 99.739898314121091971, 32.279434760315780295, 53.302710492418555077, 52.708972378364705946, + 126.0372232403678936, 27.044183575155329891, 26.157087256931845332, 117.10332223424120457, + 23.049237655897741206, 55.412597877908410737, 82.335769432909728494, 32.187717205877561355, + 126.15152500885596965, 84.472035625392891234, 76.107215054486005101, 41.98497532726105419, + 38.608278001731378026, 86.394303217766719172, 127.158963557183597, 60.336356298736063763, + 116.51799999178547296, 18.295814660468749935, 16.906020125581562752, 49.162708217394538224, + 70.744718039539293386, 19.650173223300953396, 47.746591376351716463, 99.594561792742752004, + 57.034165828474215232, 74.057739147447136929, 126.93818286048917798, 47.068532588524249149, + 35.928326597877457971, 31.172468020835367497, 31.700427052815939533, 87.322199612561234972, + 75.886573437237530015, 125.88508061938773608, 95.855431138632411603, 93.032562445911025861, + 95.560263961109740194, 62.939490068900340702, 14.83181433022764395, 110.38159980475757038, + 10.742816973594017327, 35.499849323965463554, 25.224734317664115224, 86.790827321208780631, + 28.310425850890169386, 31.064072467201185646, 110.45319493153874646, 28.278941713688254822, + 77.731911279883206589, 70.255121797265019268, 56.164000607852358371, 50.761204695372725837, + 79.716680982350226259, 61.673728697580372682, 29.060957281206356129, 113.84568894491894753, + 120.96986138561260304, 53.366383318043517647, 88.680429796899261419, 25.76469067792640999, + 41.646661758779373486, 25.961314545838831691, 77.387901317582873162, 55.801441757583233994, + 105.66666316531700431, 53.773500978739320999, 50.411452004071179545, 87.441291593790083425, + 118.06001106717303628, 89.152395686349336756, 28.259092662847251631, 71.471395624164870242, + 53.446258557512919651, 60.468559652519616066, 12.981703948935319204, 87.598754625032597687, + 15.936873235812527128, 39.628074824715440627, 102.88463619984759134, 77.265470355254365131, + 45.736186095793527784, 119.53919534248416312, 49.259441797057661461, 74.773786725658283103, + 111.7345290190896776, 28.467978447763016447, 26.037463249929714948, 48.080203397414152278, + 106.99757933006912936, 71.565713060284906533, 56.526472885641851462, 95.682836617026623571, + 5.0052272813591116574, 74.594146601259126328, 65.880153901453013532, 23.528208116251335014, + 95.483137057930434821, 11.448974444501800463, 12.418915343045227928, 74.332868206038256176, + 85.019800914520601509, 95.141728436588891782, 77.636861930805025622, 68.298286980749253416, + 27.899139484976331005, 117.22391189732661587, 47.937102319297991926, 20.120831396652647527, + 39.759523286855255719, 15.62031006140387035, 74.010889006982324645, 27.189742040893179365, + 23.219315586204174906, 42.905964594483521068, 18.224511376443842892, 85.049082246168836718, + 124.9275337099461467, 40.351189249431627104, 68.937412964751274558, 8.3063684373846626841, + 50.843186403795698425, 87.764639790435467148, 82.263261987376608886, 114.44217476568155689, + 2.7026555965458101127, 20.77424465582225821, 14.010131867140444228, 86.502024981862632558, + 89.130196453490498243, 93.03597542122224695, 111.73270055453031091, 22.623635563755669864, + 82.213045744745613774, 72.168896578368730843, 63.148356687706836965, 37.952847493306762772, + 0.99638428227990516461, 21.437882290269044461, 67.412387941883935127, 76.358710366865125252, + 74.534059591922414256, 39.83073935478751082, 78.51397180607818882, 93.702076693862181855, + 84.187302528607688146, 82.431789832735375967, 76.708593737945193425, 20.677412185941648204, + 59.191559688555571483, 122.56277943352688453, 56.095605134498327971, 10.527811325187940383, + 76.483410419830761384, 101.89770370707628899, 34.110903765758848749, 65.193805311468167929, + 14.108352117913455004, 111.48487358454804053, 80.250706300179444952, 41.129166457452811301, + 31.371106659989891341, 118.76519859524341882, 66.783892338597070193, 75.38173733831717982, + 40.00782193855047808, 29.832639387732342584, 93.568082156129094074, 34.946908438625541748, + 72.400239122369384859, 3.6662380957641289569, 24.927603570875362493, 38.360561515579320258, + 15.272261312245973386, 12.984616979989368701, 70.125332629471813561, 80.481499750632792711, + 24.716914268476102734, 61.323905090204789303, 82.462550951564480783, 41.900704542968014721, + 8.3583343260070250835, 62.194721828593173996, 27.929662097438267665, 99.067840224801329896, + 1.7107863902565441094, 89.178733545377326664, 41.304606600158876972, 127.28018149243143853, + 119.80755534139825613, 66.010495793445443269, 10.896515075462957611, 33.86837162337906193, + 123.11802185037959134, 77.727792004396178527, 112.6158615110507526, 42.940069515174400294, + 56.227568142458039802, 53.880582564637734322, 2.272426190731493989, 21.228217014784604544, + 94.007200162992376136, 38.929545472979953047, 53.337867479982378427, 2.8171073016128502786, + 51.193587644134822767, 105.13321694542173645, 122.25151204884241452, 73.682828651217278093, + 126.85836221267163637, 100.17857042293326231, 45.112632275697251316, 83.67584751329923165, + 5.6452608130530279595, 28.122684160676726606, 80.674767794327635784, 98.85738848856635741, + 117.99107479943995713, 34.355922296446806286, 72.201233025793044362, 110.523430346747773, + 103.76962929502769839, 24.377619442810100736, 87.952540827627672115, 115.5877889236289775, + 98.569077025571459671, 76.065604317314864602, 9.1814502658708079252, 75.191366955550620332, + 64.080513805314694764, 3.4586351952784752939, 105.0359078753645008, 20.586289287868567044, + 86.010333206191717181, 84.179523926515685162, 9.6053991688240785152, 48.365862758306320757, + 118.26426353030910832, 18.859913991684152279, 16.982596528894646326, 119.49979352955415379, + 24.353532508386706468, 83.900043976704182569, 21.595015137008886086, 121.70623553213954438, + 23.811404910742567154, 116.36984291932458291, 46.207092980523157166, 101.31253808766268776, + 127.04711549172134255, 69.137945515958563192, 116.22399800030689221, 37.418770401734946063, + 94.37774419578636298, 61.662637749956047628, 45.383420853893767344, 89.522178254203026881, + 105.10391398064166424, 8.0931077702662150841, 120.64321541786921443, 32.798932876834442141, + 91.848612552479607984, 69.582850224342109868, 86.344824336549208965, 36.520829256551223807, + 61.526934293575322954, 40.802004821354785236, 96.212435664565418847, 41.307751347834710032, + 62.488705430085246917, 97.571972309469856555, 97.796179424090951215, 124.36802013164196978, + 96.470542225099052303, 17.593221037979674293, 110.58673974566772813, 46.675495389441493899, + 71.763930830227764091, 39.955685577264375752, 101.24244849586466444, 124.36719565780003904, + 127.7688730689624208, 108.18850927731909906, 107.89681120889872545, 110.80266489051427925, + 66.222003578899602871, 125.79942197511627455, 40.501396587453200482, 34.295521141928475117, + 75.08473064567806432, 67.261812233620730694, 51.940205099919694476, 122.62400805901779677, + 104.6670961294148583, 79.405073578043811722, 126.29641841819830006, 28.214585508299933281, + 40.677027786921826191, 45.014453160431003198, 72.56888934883318143, 86.175351059464446735, + 36.10481714025081601, 112.66008290561512695, 37.023422120706527494, 22.827039884501573397, + 69.03774758135114098, 63.20501303353739786, 41.44936808806960471, 33.221814698314119596, + 95.563191018874931615, 96.440400291536207078, 70.29942930144170532, 77.770792807550606085, + 1.1726393366407137364, 6.5982262101206288207, 81.216591952477756422, 17.496363994887360604, + 57.49813410793649382, 58.940722552972147241, 48.185284482126007788, 126.95009109412421822, + 19.213634697876841528, 120.44386030827809009, 118.75884335835144157, 28.178239386357745389, + 69.516525174301932566, 97.919540484079334419, 125.26232898308808217, 106.90475960871117422, + 18.270911319446895504, 89.916901904631231446, 52.081531425268622115, 13.31911013113494846, + 90.957656900685833534, 66.787454493805853417, 75.64947673142523854, 27.223176280069310451, + 118.26414786121677025, 80.083281937662832206, 39.039418890835804632, 29.993649743180867517, + 12.935292577214568155, 11.848946459747821791, 42.863777411908813519, 24.385285866548656486, + 115.80381892091463669, 57.313458590379013913, 55.993415408840519376, 89.77020231372807757, + 56.228423633136117132, 57.419648831037193304, 49.131875858423882164, 25.279583481620647945, + 32.963261854914890137, 32.018307738944713492, 52.26675246822196641, 68.65813993796473369, + 71.346151263642241247, 41.624496357562748017, 21.819135235997237032, 80.717954502695647534, + 72.780186637246515602, 90.274980941154353786, 77.254981235982995713, 109.035654024402902, + 83.038275736853393028, 13.945202522965701064, 71.479796628242183942, 64.55886952063156059, + 106.60542098483711015, 105.41794475673304987, 124.07444648073578719, 54.088367150310659781, + 52.314174513867328642, 106.20664446848240914, 46.098475311795482412, 110.82519575582045945, + 36.671538865819456987, 64.375434411758760689, 124.30305001771557727, 40.944071250785782468, + 24.214430108972010203, 83.96995065452210838, 77.216556003466394031, 44.788606435537076322, + 126.31792711436719401, 120.67271259747576551, 105.03599998357094591, 36.59162932093749987, + 33.812040251163125504, 98.325416434792714426, 13.489436079078586772, 39.300346446601906791, + 95.493182752707070904, 71.189123585485504009, 114.06833165695206844, 20.115478294897911837, + 125.87636572097835597, 94.137065177048498299, 71.856653195754915942, 62.344936041670734994, + 63.400854105635517044, 46.644399225126107922, 23.77314687447869801, 123.77016123877911014, + 63.710862277268461185, 58.065124891825689701, 63.120527922219480388, 125.8789801378006814, + 29.663628660458925879, 92.763199609515140764, 21.485633947188034654, 70.999698647930927109, + 50.449468635331868427, 45.581654642417561263, 56.620851701780338772, 62.12814493440600927, + 92.906389863077492919, 56.557883427380147623, 27.463822559770051157, 12.510243594530038536, + 112.32800121570471674, 101.52240939074908965, 31.433361964700452518, 123.34745739516074536, + 58.121914562416350236, 99.691377889841533033, 113.93972277122520609, 106.73276663609067327, + 49.360859593798522837, 51.529381355852819979, 83.293323517558746971, 51.922629091681301361, + 26.775802635165746324, 111.60288351517010597, 83.333326330634008627, 107.547001957478642, + 100.82290400814599707, 46.882583187583804829, 108.12002213434971054, 50.304791372698673513, + 56.518185325698141241, 14.942791248329740483, 106.8925171150258393, 120.93711930503923213, + 25.963407897874276387, 47.197509250065195374, 31.873746471625054255, 79.256149649434519233, + 77.769272399698820664, 26.530940710508730263, 91.472372191590693546, 111.07839068496832624, + 98.5188835941189609, 21.547573451320204185, 95.469058038179355208, 56.935956895526032895, + 52.074926499859429896, 96.160406794831942534, 85.995158660141896689, 15.131426120569813065, + 113.0529457712873409, 63.365673234053247143, 10.010454562721861294, 21.188293202521890635, + 3.7603078029060270637, 47.056416232506308006, 62.966274115860869642, 22.897948889003600925, + 24.837830686094093835, 20.66573641208015033, 42.039601829044840997, 62.283456873181421543, + 27.273723861613689223, 8.5965739614985068329, 55.798278969956299989, 106.44782379465323174, + 95.874204638595983852, 40.241662793305295054, 79.519046573710511439, 31.240620122811378678, + 20.02177801396464929, 54.379484081786358729, 46.438631172408349812, 85.811929188967042137, + 36.449022752891323762, 42.098164492341311416, 121.8550674198922934, 80.702378498866892187, + 9.8748259295025491156, 16.612736874769325368, 101.68637280759503483, 47.529279580874572275, + 36.52652397475685575, 100.88434953136311378, 5.4053111930916202255, 41.54848931164451642, + 28.020263734284526436, 45.004049963728903094, 50.260392906984634465, 58.07195084244813188, + 95.46540110906062182, 45.247271127514977707, 36.426091489494865527, 16.337793156737461686, + 126.29671337541367393, 75.905694986613525543, 1.9927685645598103292, 42.8757645805417269, + 6.8247758837715082336, 24.717420733733888483, 21.068119183844828513, 79.661478709578659618, + 29.027943612160015618, 59.40415338772800169, 40.37460505721901427, 36.863579665474389913, + 25.41718747589038685, 41.354824371883296408, 118.38311937711478095, 117.12555886705376906, + 112.19121026899665594, 21.055622650379518745, 24.966820839665160747, 75.795407414152577985, + 68.221807531521335477, 2.387610622936335858, 28.216704235830547987, 94.969747169099719031, + 32.501412600358889904, 82.258332914905622602, 62.742213319983420661, 109.53039719049047562, + 5.5677846771977783646, 22.763474676634359639, 80.015643877100956161, 59.665278775468323147, + 59.136164312258188147, 69.893816877254721476, 16.800478244738769718, 7.3324761915282579139, + 49.855207141750724986, 76.721123031158640515, 30.544522624491946772, 25.969233959982375382, + 12.250665258947265102, 32.962999501265585423, 49.433828536952205468, 122.64781018041321659, + 36.925101903128961567, 83.801409085936029442, 16.716668652014050167, 124.38944365718634799, + 55.859324194880173309, 70.135680449602659792, 3.4215727805167261977, 50.357467090754653327, + 82.609213200321391923, 126.56036298486651503, 111.61511068280015024, 4.0209915868908865377, + 21.793030150925915223, 67.736743246761761839, 118.23604370076282066, 27.455584008795995032, + 97.231723022101505194, 85.880139030348800588, 112.4551362849160796, 107.76116512927546864, + 4.544852381462987978, 42.456434029572847066, 60.014400325984752271, 77.859090945959906094, + 106.67573495996475685, 5.6342146032257005572, 102.38717528827328351, 82.266433890847110888, + 116.50302409768846701, 19.365657302438194165, 125.71672442534691072, 72.357140845866524614, + 90.225264551398140611, 39.351695026598463301, 11.290521626106055919, 56.24536832135709119, + 33.349535588658909546, 69.714776977136352798, 107.98214959887991427, 68.71184459289725055, + 16.402466051589726703, 93.046860693499183981, 79.53925859005539678, 48.755238885623839451, + 47.905081655258982209, 103.17557784726159298, 69.138154051146557322, 24.131208634629729204, + 18.362900531745253829, 22.382733911104878644, 0.16102761062938952819, 6.9172703905605885666, + 82.071815750729001593, 41.172578575740772067, 44.020666412387072342, 40.359047853031370323, + 19.21079833764815703, 96.731725516616279492, 108.52852706061821664, 37.719827983368304558, + 33.965193057792930631, 110.99958705910830759, 48.707065016777050914, 39.800087953408365138, + 43.19003027402141015, 115.41247106427908875, 47.622809821488772286, 104.73968583864916582, + 92.414185961049952311, 74.625076175329013495, 126.09423098344632308, 10.275891031920764362, + 104.44799600061378442, 74.837540803473530104, 60.755488391572725959, 123.32527549991209526, + 90.766841707791172666, 51.044356508409691742, 82.207827961283328477, 16.186215540536068147, + 113.28643083573842887, 65.59786575367252226, 55.697225104962853948, 11.165700448687857715, + 44.68964867309841793, 73.041658513102447614, 123.05386858715064591, 81.60400964271320845, + 64.424871329130837694, 82.615502695669420063, 124.97741086017413181, 67.143944618943351088, + 67.59235884818554041, 120.73604026328757755, 64.941084450198104605, 35.186442075962986564, + 93.17347949133545626, 93.350990778886625776, 15.527861660455528181, 79.911371154532389482, + 74.484896991732966853, 120.73439131560371607, 127.53774613792847958, 88.37701855464183609, + 87.793622417801088886, 93.605329781032196479, 4.4440071578028437216, 123.5988439502325491, + 81.002793174906400964, 68.591042283860588213, 22.169461291359766619, 6.5236244672414613888, + 103.88041019984302693, 117.24801611803923151, 81.334192258833354572, 30.810147156091261422, + 124.59283683639660012, 56.429171016599866562, 81.354055573843652382, 90.028906320865644375, + 17.137778697670000838, 44.350702118928893469, 72.209634280505269999, 97.320165811230253894, + 74.046844241413054988, 45.654079769006784773, 10.075495162702281959, 126.41002606707479572, + 82.898736176139209419, 66.443629396631877171, 63.126382037753501208, 64.880800583076052135, + 12.598858602887048619, 27.54158561510121217, 2.3452786732814274728, 13.19645242024489562, + 34.433183904955512844, 34.992727989774721209, 114.99626821587298764, 117.88144510594429448, + 96.370568964255653555, 125.90018218824843643, 38.427269395757321035, 112.88772061655981815, + 109.51768671670288313, 56.356478772719128756, 11.033050348607503111, 67.839080968162306817, + 122.52465796617980232, 85.809519217422348447, 36.541822638897428988, 51.833803809262462892, + 104.16306285053724423, 26.6382202622735349, 53.915313801375305047, 5.5749089876153448131, + 23.298953462850477081, 54.446352560142258881, 108.52829572243717848, 32.166563875325664412, + 78.078837781671609264, 59.987299486361735035, 25.87058515442913631, 23.697892919495643582, + 85.727554823817627039, 48.770571733100950951, 103.60763784182927338, 114.62691718075802783, + 111.98683081768467673, 51.54040462745615514, 112.45684726627223426, 114.83929766207438661, + 98.263751716847764328, 50.559166963241295889, 65.926523709829780273, 64.036615477889426984, + 104.5335049364475708, 9.3162798759331053589, 14.692302527284482494, 83.248992715125496034, + 43.638270471998112043, 33.435909005394933047, 17.560373274496669183, 52.549961882312345551, + 26.509962471969629405, 90.071308048809441971, 38.076551473706786055, 27.890405045935040107, + 14.959593256488005864, 1.117739041266759159, 85.210841969677858287, 82.835889513469737722, + 120.14889296147157438, 108.17673430062131956, 104.62834902773829526, 84.413288936964818276, + 92.196950623594602803, 93.650391511640918907, 73.343077731642551953, 0.75086882352115935646, + 120.60610003543115454, 81.888142501571564935, 48.428860217947658384, 39.939901309047854738, + 26.433112006932788063, 89.577212871077790624, 124.63585422873802599, 113.34542519495516899, + 82.07199996714189183, 73.183258641874999739, 67.624080502329888986, 68.650832869585428853, + 26.978872158157173544, 78.600692893207451561, 62.986365505417779787, 14.378247170974645996, + 100.13666331390413688, 40.230956589799461653, 123.75273144196034991, 60.274130354100634577, + 15.713306391509831883, 124.68987208334146999, 126.80170821127103409, 93.288798450252215844, + 47.546293748961033998, 119.54032247755822027, 127.42172455453692237, 116.1302497836513794, + 126.24105584444259875, 123.75796027560136281, 59.327257320921489736, 57.526399219030281529, + 42.971267894379707286, 13.999397295861854218, 100.89893727066373685, 91.163309284835122526, + 113.24170340356067754, 124.25628986881565652, 57.812779726154985838, 113.11576685476029525, + 54.927645119540102314, 25.02048718906371505, 96.656002431413071463, 75.044818781498179305, + 62.866723929404543014, 118.69491479032149073, 116.24382912483633845, 71.382755779686704045, + 99.879445542454050155, 85.465533272181346547, 98.721719187597045675, 103.05876271170927794, + 38.586647035117493942, 103.84525818336260272, 53.551605270335130626, 95.20576703034384991, + 38.666652661271655234, 87.094003914960921975, 73.645808016291994136, 93.765166375171247637, + 88.240044268699421082, 100.60958274539734703, 113.03637065139628248, 29.885582496663118945, + 85.785034230055316584, 113.87423861007846426, 51.926815795748552773, 94.395018500130390748, + 63.747492943253746489, 30.512299298872676445, 27.538544799397641327, 53.061881421021098504, + 54.944744383185025072, 94.15678136994029046, 69.0377671882379218, 43.095146902644046349, + 62.938116076358710416, 113.87191379105206579, 104.14985299972249777, 64.320813589667523047, + 43.990317320283793379, 30.262852241143264109, 98.105891542574681807, 126.73134646810649429, + 20.020909125443722587, 42.376586405043781269, 7.5206156058120541275, 94.112832465012616012, + 125.93254823172173928, 45.79589777800720185, 49.67566137218818767, 41.331472824160300661, + 84.079203658089681994, 124.56691374636284309, 54.547447723227378447, 17.193147922997013666, + 111.59655793991623796, 84.895647589310101466, 63.748409277191967703, 80.483325586614228087, + 31.038093147421022877, 62.481240245622757357, 40.04355602792929858, 108.75896816357271746, + 92.877262344820337603, 43.623858377934084274, 72.898045505782647524, 84.19632898468626081, + 115.71013483978822478, 33.404756997733784374, 19.749651859005098231, 33.225473749542288715, + 75.372745615190069657, 95.05855916174914455, 73.05304794951734948, 73.768699062726227567, + 10.810622386183240451, 83.096978623289032839, 56.040527468569052871, 90.008099927457806189, + 100.52078581396926893, 116.14390168489990174, 62.930802218121243641, 90.494542255029955413, + 72.852182978989731055, 32.675586313478561351, 124.59342675083098584, 23.811389973227051087, + 3.9855371291196206585, 85.751529161083453801, 13.649551767543016467, 49.434841467467776965, + 42.136238367693295004, 31.322957419157319237, 58.055887224320031237, 118.80830677545600338, + 80.74921011443802854, 73.727159330948779825, 50.834374951780773699, 82.709648743770230794, + 108.76623875423319987, 106.25111773411117611, 96.382420537993311882, 42.111245300759037491, + 49.933641679333959473, 23.590814828308793949, 8.443615063042670954, 4.7752212458726717159, + 56.433408471664733952, 61.939494338199438062, 65.002825200721417787, 36.516665829811245203, + 125.4844266399704793, 91.060794380980951246, 11.135569354395556729, 45.526949353272357257, + 32.031287754201912321, 119.33055755093664629, 118.27232862452001427, 11.787633754509442952, + 33.600956489477539435, 14.664952383056515828, 99.710414283505087951, 25.44224606231728103, + 61.089045248983893543, 51.938467919964750763, 24.501330517894530203, 65.925999002531170845, + 98.867657073908048915, 117.29562036082643317, 73.850203806261561112, 39.602818171872058883, + 33.433337304031738313, 120.77888731437269598, 111.7186483897639846, 12.271360899205319583, + 6.8431455610334523953, 100.71493418151294463, 37.218426400646421826, 125.12072596973666805, + 95.230221365600300487, 8.0419831737817730755, 43.586060301855468424, 7.4734864935271616559, + 108.47208740152564133, 54.911168017595628044, 66.463446044206648367, 43.760278060701239156, + 96.910272569835797185, 87.522330258550937288, 9.089704762925975956, 84.912868059145694133, + 120.02880065197314252, 27.718181891923450166, 85.351469919929513708, 11.268429206455039093, + 76.774350576550205005, 36.532867781697859755, 105.00604819537693402, 38.731314604880026309, + 123.43344885069745942, 16.714281691736687208, 52.450529102796281222, 78.703390053196926601, + 22.581043252212111838, 112.49073664271418238, 66.699071177321457071, 11.429553954276343575, + 87.964299197763466509, 9.4236891857945010997, 32.804932103183091385, 58.09372138700200594, + 31.078517180110793561, 97.510477771247678902, 95.810163310521602398, 78.351155694526823936, + 10.276308102293114644, 48.262417269259458408, 36.725801063490507659, 44.765467822209757287, + 0.32205522125877905637, 13.834540781124815112, 36.143631501458003186, 82.345157151481544133, + 88.041332824774144683, 80.718095706062740646, 38.421596675299952039, 65.463451033236196963, + 89.057054121236433275, 75.439655966736609116, 67.930386115589499241, 93.99917411821661517, + 97.414130033554101828, 79.600175906816730276, 86.38006054804645828, 102.8249421285581775, + 95.245619642981182551, 81.479371677301969612, 56.828371922103542602, 21.250152350661664968, + 124.18846196689264616, 20.551782063845166704, 80.895992001231206814, 21.675081606947060209, + 121.5109767831490899, 118.65055099982782849, 53.533683415582345333, 102.08871301682302146, + 36.415655922566656955, 32.372431081075774273, 98.572861671480495716, 3.1957315073450445198, + 111.3944502099257079, 22.331400897375715431, 89.379297346200473839, 18.083317026208533207, + 118.10773717430492979, 35.208019285430054879, 0.84974265826531336643, 37.231005391342478106, + 121.9548217203519016, 6.287889237890340155, 7.1847176963747187983, 113.47208052657879307, + 1.8821689003962092102, 70.372884151929611107, 58.346958982674550498, 58.701981557773251552, + 31.055723320914694341, 31.822742309068416944, 20.969793983469571685, 113.46878263121107011, + 127.07549227586059715, 48.754037109287310159, 47.587244835605815751, 59.210659562064392958, + 8.888014315609325422, 119.19768790046873619, 34.005586349816439906, 9.1820845677211764269, + 44.338922582719533239, 13.047248934486560756, 79.76082039968969184, 106.49603223608210101, + 34.668384517666709144, 61.620294312186160823, 121.18567367279320024, 112.8583420332033711, + 34.708111147690942744, 52.05781264173128875, 34.275557395340001676, 88.701404237861424917, + 16.419268561014177976, 66.640331622464145767, 20.093688482826109976, 91.308159538013569545, + 20.150990325408201898, 124.82005213415322942, 37.797472352282056818, 4.8872587932637543418, + 126.2527640755106404, 1.7616011661521042697, 25.197717205774097238, 55.08317123020242434, + 4.6905573465628549457, 26.392904840489791241, 68.866367809911025688, 69.985455979553080397, + 101.99253643174961326, 107.76289021189222694, 64.741137928514945088, 123.80036437649687286, + 76.85453879151828005, 97.775441233123274287, 91.035373433405766264, 112.71295754543825751, + 22.0661006972186442, 7.6781619363282516133, 117.04931593236324261, 43.619038434844696894, + 73.083645277794857975, 103.66760761852856376, 80.326125701074488461, 53.276440524547069799, + 107.83062760275061009, 11.149817975230689626, 46.597906925700954162, 108.89270512028815574, + 89.056591444874356966, 64.333127750654966803, 28.157675563343218528, 119.97459897272347007, + 51.74117030885827262, 47.395785838994925143, 43.455109647635254078, 97.54114346620553988, + 79.215275683662184747, 101.25383436151969363, 95.973661635369353462, 103.08080925491594826, + 96.913694532548106508, 101.67859532415241119, 68.527503433695528656, 101.11833392648622976, + 3.8530474196631985251, 0.073230955782491946593, 81.067009872895141598, 18.632559751866210718, + 29.384605054572602967, 38.497985430250992067, 87.276540943996224087, 66.871818010789866094, + 35.120746548993338365, 105.0999237646246911, 53.019924943942896789, 52.142616097618883941, + 76.15310294741357211, 55.780810091870080214, 29.919186512976011727, 2.2354780825371562969, + 42.421683939359354554, 37.671779026943113422, 112.29778592294678674, 88.353468601246277103, + 81.256698055480228504, 40.826577873933274532, 56.393901247192843584, 59.300783023285475792, + 18.686155463285103906, 1.5017376470459566917, 113.21220007086594705, 35.77628500314312987, + 96.857720435895316768, 79.879802618095709477, 52.866224013869214104, 51.154425742159219226, + 121.27170845747968997, 98.69085038991397596, 36.143999934287421638, 18.366517283753637457, + 7.2481610046634159517, 9.3016657391708577052, 53.957744316317985067, 29.201385786414903123, + 125.97273101083555957, 28.756494341952929972, 72.27332662780827377, 80.461913179602561286, + 119.50546288392069982, 120.54826070820126915, 31.426612783023301745, 121.37974416668657796, + 125.60341642254570615, 58.577596900504431687, 95.092587497925705975, 111.08064495512007852, + 126.84344910907748272, 104.26049956730639678, 124.48211168888883549, 119.51592055120272562, + 118.65451464184297947, 115.05279843806056306, 85.942535788759414572, 27.998794591727346415, + 73.797874541331111686, 54.32661856967388303, 98.483406807124993065, 120.51257973763131304, + 115.62555945231360965, 98.231533709520590492, 109.85529023908020463, 50.040974378131068079, + 65.312004862829780905, 22.089637562996358611, 125.73344785881272401, 109.38982958064661943, + 104.48765824967631488, 14.765511559377046069, 71.75889108491173829, 42.931066544366331073, + 69.443438375197729329, 78.117525423418555874, 77.173294070238625864, 79.690516366725205444, + 107.10321054067389923, 62.411534060687699821, 77.333305322546948446, 46.188007829925481929, + 19.29161603258762625, 59.530332750346133253, 48.480088537402480142, 73.21916549079833203, + 98.072741302792564966, 59.77116499332987587, 43.570068460114271147, 99.748477220156928524, + 103.85363159150074353, 60.790037000260781497, 127.49498588650749298, 61.02459859774535289, + 55.077089598795282654, 106.12376284204219701, 109.88948876637368812, 60.3135627398842189, + 10.075534376475843601, 86.190293805288092699, 125.87623215272105881, 99.743827582107769558, + 80.29970599944863352, 0.64162717933504609391, 87.980634640567586757, 60.525704482290166197, + 68.211783085153001593, 125.46269293621298857, 40.041818250887445174, 84.753172810087562539, + 15.041231211627746234, 60.225664930028870003, 123.86509646344347857, 91.591795556014403701, + 99.35132274437637534, 82.662945648324239301, 40.158407316183001967, 121.13382749272568617, + 109.09489544645475689, 34.38629584599766531, 95.193115879836113891, 41.791295178620202933, + 127.49681855438757339, 32.966651173228456173, 62.076186294842045754, 124.96248049124551471, + 80.087112055862235138, 89.517936327149072895, 57.754524689640675206, 87.247716755871806527, + 17.796091011568933027, 40.392657969376159599, 103.42026967957644956, 66.809513995467568748, + 39.499303718010196462, 66.450947499088215409, 22.745491230383777292, 62.11711832350192708, + 18.106095899038336938, 19.537398125452455133, 21.621244772370118881, 38.193957246578065678, + 112.08105493714174372, 52.016199854919250356, 73.041571627942175837, 104.28780336979980348, + 125.86160443624612526, 52.989084510063548805, 17.70436595797946211, 65.351172626960760681, + 121.18685350166197168, 47.622779946454102173, 7.9710742582428792957, 43.503058322166907601, + 27.299103535086032934, 98.869682934935553931, 84.272476735386590008, 62.645914838314638473, + 116.11177444864370045, 109.61661355091564474, 33.49842022887969506, 19.45431866189755965, + 101.66874990356518538, 37.419297487544099567, 89.532477508470037719, 84.502235468225990189, + 64.764841075986623764, 84.222490601518074982, 99.867283358667918947, 47.181629656617587898, + 16.887230126085341908, 9.5504424917453434318, 112.8668169433294679, 123.8789886764025141, + 2.0056504014428355731, 73.033331659626128385, 122.96885327994459658, 54.121588761961902492, + 22.271138708791113459, 91.053898706544714514, 64.062575508407462621, 110.66111510187693057, + 108.54465724904002855, 23.575267509018885903, 67.20191297895507887, 29.329904766116669634, + 71.420828567010175902, 50.88449212463456206, 122.17809049796778709, 103.87693583992950153, + 49.002661035792698385, 3.8519980050659796689, 69.735314147819735808, 106.59124072165650432, + 19.700407612523122225, 79.205636343744117767, 66.866674608067114605, 113.55777462874902994, + 95.437296779527969193, 24.542721798410639167, 13.68629112207054277, 73.429868363025889266, + 74.43685280129648163, 122.24145193947697408, 62.460442731200600974, 16.083966347563546151, + 87.172120603710936848, 14.946972987057961291, 88.944174803051282652, 109.82233603519489407, + 4.9268920884132967331, 87.52055612140611629, 65.820545139675232349, 47.044660517101874575, + 18.179409525855589891, 41.825736118295026245, 112.05760130394628504, 55.436363783850538312, + 42.702939839859027416, 22.536858412913716165, 25.548701153100410011, 73.065735563399357488, + 82.012096390753868036, 77.462629209763690596, 118.86689770139491884, 33.428563383473374415, + 104.90105820559620042, 29.406780106393853202, 45.162086504427861655, 96.98147328543200274, + 5.3981423546429141425, 22.859107908556325128, 47.928598395526933018, 18.847378371589002199, + 65.609864206366182771, 116.18744277400401188, 62.1570343602252251, 67.020955542498995783, + 63.620326621046842774, 28.702311389053647872, 20.552616204586229287, 96.524834538518916816, + 73.451602126981015317, 89.530935644419514574, 0.64411044251755811274, 27.669081562249630224, + 72.28726300291964435, 36.690314302966726245, 48.082665649551927345, 33.436191412125481293, + 76.843193350603542058, 2.926902066476031905, 50.114108242476504529, 22.879311933476856211, + 7.8607722311826364603, 59.998348236436868319, 66.828260067111841636, 31.20035181363709853, + 44.760121096096554538, 77.649884257119992981, 62.491239285966003081, 34.958743354603939224, + 113.6567438442070852, 42.500304701326967916, 120.37692393378529232, 41.103564127693971386, + 33.791984002462413628, 43.350163213897758396, 115.02195356630181777, 109.30110199965565698, + 107.06736683116832864, 76.177426033646042924, 72.831311845133313909, 64.744862162155186525, + 69.145723342960991431, 6.3914630146937270183, 94.788900419851415791, 44.66280179475506884, + 50.758594692400947679, 36.166634052420704393, 108.21547434860985959, 70.416038570860109758, + 1.6994853165306267329, 74.46201078268859419, 115.90964344070380321, 12.57577847578068031, + 14.369435392753075575, 98.944161053157586139, 3.7643378007960563991, 12.745768303859222215, + 116.693917965349101, 117.4039631155465031, 62.111446641829388682, 63.645484618136833888, + 41.93958796694278135, 98.937565262425778201, 126.15098455172119429, 97.508074218574620318, + 95.174489671211631503, 118.42131912412878592, 17.776028631222288823, 110.39537580093747238, + 68.011172699632879812, 18.364169135442352854, 88.677845165439066477, 26.094497868976759491, + 31.521640799383021658, 84.992064472164202016, 69.336769035333418287, 123.24058862437595963, + 114.37134734559003846, 97.716684066406742204, 69.416222295381885488, 104.1156252834625775, + 68.551114790683641331, 49.402808475722849835, 32.838537122031993931, 5.2806632449282915331, + 40.18737696565585793, 54.61631907602713909, 40.301980650820041774, 121.64010426830645883, + 75.594944704564113636, 9.7745175865311466623, 124.50552815102128079, 3.5232023323042085394, + 50.395434411548194475, 110.16634246040484868, 9.3811146931257098913, 52.78580968098322046, + 9.7327356198256893549, 11.970911959109798772, 75.985072863502864493, 87.525780423788091866, + 1.4822758570335281547, 119.60072875299738371, 25.709077583040198078, 67.550882466250186553, + 54.070746866815170506, 97.425915090876515023, 44.1322013944372884, 15.356323872660141205, + 106.09863186472648522, 87.238076869693031767, 18.167290555593353929, 79.335215237060765503, + 32.652251402148976922, 106.55288104909777758, 87.661255205501220189, 22.299635950461379252, + 93.195813851405546302, 89.785410240579949459, 50.113182889752351912, 0.66625550130993360654, + 56.315351126690075034, 111.94919794544694014, 103.48234061771654524, 94.791571677989850286, + 86.910219295274146134, 67.082286932414717739, 30.430551367328007473, 74.507668723043025238, + 63.947323270742344903, 78.161618509835534496, 65.827389065099850995, 75.357190648308460368, + 9.0550068673946952913, 74.236667852972459514, 7.7060948393263970502, 0.14646191156862187199, + 34.134019745790283196, 37.265119503732421435, 58.769210109145205934, 76.995970860505622113, + 46.553081887996086152, 5.7436360215797321871, 70.241493097990314709, 82.199847529249382205, + 106.03984988788579358, 104.28523219524140586, 24.30620589482714422, 111.56162018374016043, + 59.838373025952023454, 4.4709561650743125938, 84.843367878718709107, 75.343558053889864823, + 96.59557184589721146, 48.706937202496192185, 34.513396110960457008, 81.653155747866549063, + 112.78780249438568717, 118.60156604657095158, 37.372310926570207812, 3.0034752940955513623, + 98.424400141731894109, 71.552570006289897719, 65.715440871794271516, 31.759605236191418953, + 105.73244802773842821, 102.30885148432207643, 114.54341691496301792, 69.381700779827951919, + 72.287999868574843276, 36.733034567507274915, 14.496322009326831903, 18.60333147834171541, + 107.91548863263597013, 58.402771572833444225, 123.94546202167111915, 57.512988683909497922, + 16.546653255620185519, 32.92382635920876055, 111.01092576784503763, 113.09652141640253831, + 62.853225566050241468, 114.75948833337679389, 123.20683284509141231, 117.15519380101250135, + 62.185174995855049929, 94.161289910243795021, 125.68689821815860341, 80.520999134616431547, + 120.96422337778130895, 111.03184110240908922, 109.30902928368959692, 102.10559687612476409, + 43.885071577518829145, 55.997589183458330808, 19.595749082662223373, 108.65323713935140404, + 68.96681361425362411, 113.02515947526626405, 103.25111890463085729, 68.463067419044818962, + 91.710580478160409257, 100.08194875626577414, 2.6240097256595618092, 44.1792751259963552, + 123.46689571762908599, 90.779659161296876846, 80.975316499352629762, 29.531023118757730117, + 15.517782169823476579, 85.862133088736300124, 10.886876750399096636, 28.235050846840749728, + 26.346588140480889706, 31.381032733454048866, 86.206421081347798463, 124.82306812137903762, + 26.666610645093896892, 92.376015659850963857, 38.583232065175252501, 119.06066550069226651, + 96.960177074808598263, 18.438330981600302039, 68.145482605585129932, 119.54232998665975174, + 87.140136920232180273, 71.496954440317495028, 79.70726318300148705, 121.58007400052520097, + 126.98997177301498596, 122.04919719549070578, 110.15417919759420329, 84.247525684088031994, + 91.778977532747376245, 120.6271254797684378, 20.151068752955325181, 44.380587610579823377, + 123.7524643054457556, 71.487655164219177095, 32.59941199889726704, 1.2832543586737301666, + 47.961269281135173514, 121.05140896458397037, 8.4235661703096411657, 122.92538587242597714, + 80.083636501778528327, 41.506345620175125077, 30.082462423255492467, 120.45132986006137799, + 119.73019292689059512, 55.18359111203244538, 70.702645488756388659, 37.325891296648478601, + 80.316814632369641913, 114.26765498545501032, 90.189790892909513786, 68.772591691998968599, + 62.386231759672227781, 83.582590357244043844, 126.99363710877514677, 65.933302346456912346, + 124.15237258968772949, 121.92496098249466741, 32.174224111728108255, 51.03587265429814579, + 115.50904937928498839, 46.495433511743613053, 35.592182023137866054, 80.785315938755957177, + 78.840539359156537103, 5.6190279909351374954, 78.998607436024030903, 4.9018949981764308177, + 45.490982460767554585, 124.23423664700385416, 36.212191798076673876, 39.074796250904910266, + 43.242489544740237761, 76.387914493159769336, 96.162109874283487443, 104.03239970984213869, + 18.083143255887989653, 80.575606739603244932, 123.72320887249225052, 105.97816902012709761, + 35.408731915962562198, 2.7023452539251593407, 114.37370700332394335, 95.245559892908204347, + 15.942148516485758591, 87.006116644333815202, 54.598207070175703848, 69.73936586987474584, + 40.544953470773180015, 125.29182967663291492, 104.22354889729103888, 91.233227101831289474, + 66.996840457759390119, 38.908637323798757279, 75.337499807130370755, 74.838594975091837114, + 51.064955016943713417, 41.004470936455618357, 1.5296821519768855069, 40.444981203039787943, + 71.734566717335837893, 94.363259313235175796, 33.774460252170683816, 19.100884983494324842, + 97.733633886662573786, 119.7579773528050282, 4.011300802889309125, 18.066663319255894748, + 117.93770655988919316, 108.24317752392380498, 44.542277417585864896, 54.107797413093067007, + 0.12515101681856322102, 93.322230203757499112, 89.089314498080057092, 47.150535018041409785, + 6.4038259579101577401, 58.659809532236977248, 14.841657134020351805, 101.7689842492727621, + 116.35618099593921215, 79.753871679859003052, 98.00532207158539677, 7.7039960101355973165, + 11.470628295643109595, 85.18248144331300864, 39.400815225049882429, 30.411272687491873512, + 5.7333492161378671881, 99.115549257501697866, 62.874593559055938385, 49.085443596821278334, + 27.372582244144723518, 18.859736726055416511, 20.873705602596601238, 116.48290387895394815, + 124.92088546240120195, 32.167932695130730281, 46.344241207421873696, 29.89394597411956056, + 49.888349606106203282, 91.644672070389788132, 9.8537841768302314449, 47.041112242815870559, + 3.6410902793504646979, 94.08932103420374915, 36.358819051711179782, 83.651472236593690468, + 96.115202607892570086, 110.87272756770107662, 85.405879679718054831, 45.073716825827432331, + 51.097402306204458, 18.131471126802352956, 36.024192781511374051, 26.925258419531019172, + 109.73379540278983768, 66.857126766950386809, 81.802116411192400847, 58.813560212787706405, + 90.324173008859361289, 65.96294657086400548, 10.796284709285828285, 45.718215817112650257, + 95.857196791053866036, 37.694756743181642378, 3.21972841273600352, 104.37488554800802376, + 124.31406872045408818, 6.0419110849979915656, 127.24065324209368555, 57.404622778107295744, + 41.105232409176096553, 65.04966907704147161, 18.903204253965668613, 51.061871288839029148, + 1.2882208850351162255, 55.338163124502898427, 16.5745260058392887, 73.380628605933452491, + 96.16533129910385469, 66.872382824254600564, 25.686386701207084116, 5.8538041329520638101, + 100.22821648495300906, 45.758623866953712422, 15.721544462365272921, 119.99669647287737462, + 5.6565201342236832716, 62.400703627274197061, 89.520242192196747055, 27.299768514239985961, + 124.98247857193200616, 69.917486709211516427, 99.313487688414170407, 85.00060940265757381, + 112.75384786757058464, 82.207128255387942772, 67.583968004924827255, 86.700326427799154771, + 102.04390713260727352, 90.602203999314951943, 86.134733662340295268, 24.354852067295723828, + 17.662623690270265797, 1.489724324314011028, 10.291446685921982862, 12.782926029391092015, + 61.577800839702831581, 89.325603589510137681, 101.51718938480189536, 72.333268104845046764, + 88.430948697223357158, 12.832077141720219515, 3.3989706330648914445, 20.92402156538082636, + 103.81928688140760642, 25.15155695156136062, 28.73887078550978913, 69.888322106315172277, + 7.5286756015921127982, 25.491536607722082408, 105.38783593070183997, 106.80792623109300621, + 124.22289328365877736, 127.29096923627366778, 83.879175933889200678, 69.875130524855194381, + 124.30196910344602657, 67.016148437152878614, 62.348979342426900985, 108.84263824825757183, + 35.552057262448215624, 92.790751601878582733, 8.0223453992657596245, 36.728338270888343686, + 49.355690330878132954, 52.188995737953518983, 63.043281598769681295, 41.984128944332042011, + 10.673538070670474553, 118.48117724875555723, 100.74269469118371489, 67.433368132817122387, + 10.832444590767408954, 80.231250566928792978, 9.1022295813672826625, 98.805616951445699669, + 65.677074244063987862, 10.561326489856583066, 80.37475393131171586, 109.23263815205427818, + 80.603961301643721526, 115.28020853661655565, 23.189889409128227271, 19.549035173065931303, + 121.01105630204256158, 7.0464046646084170789, 100.79086882310002693, 92.33268492080969736, + 18.762229386251419783, 105.57161936196644092, 19.46547123965137871, 23.941823918223235523, + 23.970145727009366965, 47.051560847576183733, 2.9645517140706942882, 111.20145750599476742, + 51.418155166084034136, 7.1017649325003731064, 108.14149373363397899, 66.851830181753030047, + 88.2644027888745768, 30.71264774532392039, 84.197263729456608417, 46.476153739386063535, + 36.334581111190345837, 30.670430474121531006, 65.304502804301591823, 85.105762098199193133, + 47.322510411002440378, 44.599271900926396484, 58.391627702814730583, 51.570820481159898918, + 100.22636577950470382, 1.3325110026198672131, 112.63070225338378805, 95.898395890897518257, + 78.964681235436728457, 61.583143355983338552, 45.820438590551930247, 6.1645738648294354789, + 60.861102734659652924, 21.015337446086050477, 127.89464654148832778, 28.323237019674706971, + 3.6547781302033399697, 22.714381296616920736, 18.110013734793028561, 20.473335705944919027, + 15.4121896786527941, 0.29292382313724374399, 68.268039491580566391, 74.530239007464842871, + 117.53842021829404985, 25.991941721011244226, 93.106163775992172305, 11.487272043163102353, + 12.482986195984267397, 36.399695058502402389, 84.079699775775225135, 80.570464390482811723, + 48.61241178965792642, 95.123240367480320856, 119.67674605190404691, 8.9419123301522631664, + 41.686735757441056194, 22.687116107783367625, 65.191143691794422921, 97.41387440499238437, + 69.026792221924551995, 35.306311495736736106, 97.575604988775012316, 109.20313209314190317, + 74.744621853140415624, 6.0069505881947407033, 68.848800283467426198, 15.105140012583433418, + 3.4308817435885430314, 63.519210472386475885, 83.464896055480494397, 76.61770296864779084, + 101.08683382992967381, 10.763401559659541817, 16.575999737149686553, 73.466069135014549829, + 28.992644018653663807, 37.2066629566870688, 87.830977265271940269, 116.80554314567052643, + 119.89092404334223829, 115.02597736781899584, 33.093306511240371037, 65.847652718421159079, + 94.021851535693713231, 98.193042832805076614, 125.70645113210412092, 101.51897666675722576, + 118.4136656901864626, 106.31038760202500271, 124.37034999171373784, 60.32257982049122802, + 123.3737964363208448, 33.041998269236501073, 113.92844675556625589, 94.063682204821816413, + 90.618058567382831825, 76.211193752249528188, 87.770143155037658289, 111.99517836691666162, + 39.191498165328084724, 89.306474278706446057, 9.9336272285108861979, 98.050318950536166085, + 78.502237809265352553, 8.9261348380932759028, 55.421160956324456492, 72.163897512531548273, + 5.2480194513191236183, 88.358550251996348379, 118.93379143526180997, 53.559318322597391671, + 33.950632998705259524, 59.062046237515460234, 31.035564339650591137, 43.724266177472600248, + 21.773753500798193272, 56.470101693681499455, 52.693176280961779412, 62.762065466911735712, + 44.412842162699234905, 121.64613624275807524, 53.333221290191431763, 56.752031319701927714, + 77.166464130354142981, 110.12133100138817099, 65.920354149617196526, 36.876661963204242056, + 8.2909652111738978419, 111.08465997332314146, 46.280273840467998525, 14.993908880638628034, + 31.414526366006612079, 115.16014800105403992, 125.97994354603360989, 116.09839439098504954, + 92.308358395192044554, 40.495051368179701967, 55.557955065498390468, 113.2542509595368756, + 40.302137505910650361, 88.761175221163284732, 119.50492861089514918, 14.97531032843835419, + 65.19882399779453408, 2.5665087173474603333, 95.922538562273985008, 114.10281792916794075, + 16.84713234062292031, 117.85077174485559226, 32.167273003557056654, 83.012691240350250155, + 60.164924846514622914, 112.90265972012639395, 111.46038585378119024, 110.36718222406852874, + 13.405290977512777317, 74.651782593300595181, 32.633629264742921805, 100.53530997091365862, + 52.379581785822665552, 9.5451833839979371987, 124.77246351934809354, 39.165180714491725666, + 125.98727421755393152, 3.8666046929174626712, 120.30474517937909695, 115.84992196498933481, + 64.34844822345621651, 102.07174530859992956, 103.01809875856997678, 92.990867023487226106, + 71.184364046279370086, 33.570631877515552333, 29.681078718313074205, 11.23805598187391297, + 29.997214872048061807, 9.8037899963528616354, 90.981964921538747149, 120.46847329400770832, + 72.424383596153347753, 78.149592501809820533, 86.484979089484113501, 24.77582898632317665, + 64.324219748570612865, 80.064799419684277382, 36.166286511779617285, 33.151213479210127844, + 119.44641774498813902, 83.956338040254195221, 70.817463831925124396, 5.4046905078539566603, + 100.74741400665152469, 62.491119785816408694, 31.884297032975155162, 46.012233288667630404, + 109.19641414035504567, 11.47873173974949168, 81.08990694154999801, 122.58365935326946783, + 80.447097794585715747, 54.466454203666216927, 5.9936809155187802389, 77.817274647601152537, + 22.674999614264379488, 21.677189950183674227, 102.12991003388742683, 82.008941872911236715, + 3.0593643039537710138, 80.889962406083213864, 15.469133434675313765, 60.726518626470351592, + 67.548920504341367632, 38.201769966992287664, 67.467267773328785552, 111.51595470561005641, + 8.02260160577861825, 36.133326638515427476, 107.8754131197820243, 88.486355047847609967, + 89.084554835171729792, 108.21559482618613401, 0.25030203364076442085, 58.644460407518636202, + 50.178628996160114184, 94.30107003608281957, 12.80765191582031548, 117.3196190644739545, + 29.683314268044341588, 75.537968498549162177, 104.71236199188206228, 31.507743359721644083, + 68.010644143170793541, 15.407992020271194633, 22.94125659128985717, 42.36496288662601728, + 78.801630450099764857, 60.822545374983747024, 11.466698432279372355, 70.231098515003395732, + 125.74918711811187677, 98.170887193642556667, 54.745164488289447036, 37.719473452110833023, + 41.747411205196840456, 104.96580775791153428, 121.8417709248024039, 64.335865390261460561, + 92.688482414843747392, 59.78789194823912112, 99.776699212216044543, 55.289344140779576264, + 19.70756835366046289, 94.082224485631741118, 7.2821805587045673747, 60.1786420684074983, + 72.717638103425997542, 39.302944473191018915, 64.23040521578877815, 93.745455135405791225, + 42.811759359436109662, 90.147433651654864661, 102.194804612408916, 36.262942253604705911, + 72.048385563022748102, 53.850516839065676322, 91.46759080558331334, 5.7142535339044115972, + 35.604232822384801693, 117.62712042557905079, 52.648346017722360557, 3.9258931417280109599, + 21.59256941857165657, 91.436431634228938492, 63.714393582107732072, 75.389513486363284755, + 6.4394568254756450187, 80.749771096019685501, 120.62813744090817636, 12.08382216999962111, + 126.4813064841873711, 114.80924555621459149, 82.210464818355831085, 2.0993381540829432197, + 37.806408507931337226, 102.1237425776780583, 2.576441770070232451, 110.67632624900579685, + 33.14905201168221538, 18.76125721187054296, 64.330662598211347358, 5.744765648509201128, + 51.372773402414168231, 11.707608265907765599, 72.456432969906018116, 91.517247733907424845, + 31.44308892473418382, 111.99339294575474923, 11.313040268447366543, 124.8014072545520321, + 51.040484384393494111, 54.599537028483609902, 121.9649571438676503, 11.834973418426670833, + 70.626975376831978792, 42.001218805318785599, 97.507695735144807259, 36.414256510779523524, + 7.1679360098532924894, 45.400652855601947522, 76.087814265218185028, 53.204407998633541865, + 44.269467324680590536, 48.709704134591447655, 35.325247380540531594, 2.9794486486280220561, + 20.582893371843965724, 25.565852058782184031, 123.15560167940930114, 50.651207179023913341, + 75.034378769607428694, 16.666536209693731507, 48.861897394446714316, 25.664154283440439031, + 6.797941266129782889, 41.848043130765290698, 79.638573762815212831, 50.30311390312272124, + 57.477741571023216238, 11.776644212630344555, 15.057351203184225596, 50.983073215447802795, + 82.77567186140731792, 85.615852462189650396, 120.44578656732119271, 126.58193847255097353, + 39.758351867782039335, 11.75026104971402674, 120.60393820689569111, 6.0322968743057572283, + 124.69795868485743995, 89.685276496515143663, 71.104114524900069227, 57.581503203757165466, + 16.044690798531519249, 73.456676541776687372, 98.711380661756265908, 104.37799147590703797, + 126.08656319753936259, 83.968257888664084021, 21.347076141344587086, 108.96235449751475244, + 73.485389382371067768, 6.8667362656342447735, 21.664889181538455887, 32.462501133857585955, + 18.204459162738203304, 69.611233902895037318, 3.3541484881279757246, 21.122652979716804111, + 32.749507862627069699, 90.465276304112194339, 33.207922603291081032, 102.5604170732331113, + 46.379778818256454542, 39.098070346135500586, 114.02211260408512317, 14.092809329220472137, + 73.581737646203691838, 56.66536984161939472, 37.524458772506477544, 83.14323872393288184, + 38.93094247930275742, 47.883647836446471047, 47.94029145401873393, 94.103121695152367465, + 5.9291034281450265553, 94.402915011989534833, 102.83631033216806827, 14.203529865004384192, + 88.28298746727159596, 5.7036603635096980724, 48.528805577749153599, 61.425295490651478758, + 40.394527458913216833, 92.95230747877212707, 72.669162222380691674, 61.340860948246699991, + 2.6090056086068216246, 42.211524196398386266, 94.645020822004880756, 89.198543801852792967, + 116.78325540562946117, 103.14164096232343582, 72.452731559009407647, 2.6650220052433724049, + 97.261404506771214074, 63.796791781798674492, 29.929362470873456914, 123.1662867119666771, + 91.640877181103860494, 12.329147729658870958, 121.72220546931930585, 42.030674892175738933, + 127.78929308297665557, 56.646474039349413943, 7.3095562604066799395, 45.428762593233841471, + 36.220027469586057123, 40.946671411889838055, 30.824379357305588201, 0.58584764627812546678, + 8.5360789831647707615, 21.06047801493332372, 107.07684043658809969, 51.983883442026126431, + 58.212327551984344609, 22.974544086326204706, 24.965972391968534794, 72.799390117008442758, + 40.159399551554088248, 33.140928780965623446, 97.224823579319490818, 62.246480734964279691, + 111.35349210380809382, 17.883824660304526333, 83.373471514882112388, 45.374232215570373228, + 2.3822873835924838204, 66.82774880998840672, 10.053584443849103991, 70.61262299147711019, + 67.151209977553662611, 90.406264186287444318, 21.489243706280831248, 12.013901176393119385, + 9.6976005669348523952, 30.210280025170504814, 6.8617634871770860627, 127.03842094477658975, + 38.929792110964626772, 25.235405937299219659, 74.173667659859347623, 21.526803119319083635, + 33.151999474303011084, 18.932138270029099658, 57.985288037307327613, 74.413325913377775578, + 47.661954530547518516, 105.61108629134469084, 111.78184808668811456, 102.05195473563799169, + 66.186613022484380053, 3.6953054368459561374, 60.043703071391064441, 68.386085665613791207, + 123.41290226421187981, 75.037953333518089494, 108.82733138037656317, 84.620775204053643392, + 120.74069998342747567, 120.64515964098609402, 118.74759287264168961, 66.083996538476640126, + 99.856893511136149755, 60.127364409647270804, 53.236117134769301629, 24.422387504502694355, + 47.540286310078954557, 95.990356733833323233, 78.382996330659807427, 50.612948557412892114, + 19.867254457025410375, 68.100637901075970149, 29.004475618530705106, 17.852269676186551806, + 110.84232191265255096, 16.327795025063096546, 10.496038902641885215, 48.717100503996334737, + 109.86758287052361993, 107.11863664519478334, 67.901265997410519049, 118.12409247503092047, + 62.071128679301182274, 87.448532354945200495, 43.547507001596386544, 112.94020338736299891, + 105.38635256192355882, 125.52413093382347142, 88.825684325402107788, 115.29227248551615048, + 106.66644258038286353, 113.50406263940749341, 26.33292826071192394, 92.242662002779979957, + 3.8407082992343930528, 73.753323926408484112, 16.581930422351433663, 94.169319946646282915, + 92.56054768093599705, 29.987817761277256068, 62.829052732016862137, 102.32029600211171783, + 123.95988709207085776, 104.19678878197373706, 56.616716790384089109, 80.990102736359403934, + 111.11591013100041891, 98.508501919073751196, 80.604275011824938701, 49.522350442330207443, + 111.00985722179029835, 29.95062065688034636, 2.3976479955890681595, 5.1330174346985586453, + 63.845077124551607994, 100.20563585833588149, 33.694264681249478599, 107.70154348971118452, + 64.334546007117751287, 38.025382480700500309, 120.32984969303288381, 97.805319440256425878, + 94.920771707566018449, 92.734364448137057479, 26.810581955029192613, 21.303565186601190362, + 65.267258529489481589, 73.070619941827317234, 104.7591635716453311, 19.090366767999512376, + 121.54492703869618708, 78.330361428987089312, 123.97454843510786304, 7.7332093858385633212, + 112.60949035876183189, 103.6998439299823076, 0.69689644691607099958, 76.143490617203497095, + 78.03619751714359154, 57.981734046978090191, 14.368728092558740173, 67.141263755031104665, + 59.36215743662614841, 22.476111963747825939, 59.994429744096123613, 19.60757999270936125, + 53.963929843081132276, 112.93694658801905462, 16.848767192310333485, 28.299185003623279044, + 44.969958178968227003, 49.551657972649991279, 0.64843949714486370794, 32.129598839368554763, + 72.332573023559234571, 66.302426958423893666, 110.89283548997991602, 39.91267608051202842, + 13.634927663850248791, 10.809381015711551299, 73.494828013303049374, 124.98223957163281739, + 63.768594065950310323, 92.024466577338898787, 90.392828280710091349, 22.95746347950262134, + 34.179813883103633998, 117.16731870654257364, 32.894195589171431493, 108.93290840733243385, + 11.987361831041198457, 27.634549295202305075, 45.349999228528758977, 43.354379900370986434, + 76.259820067778491648, 36.017883745822473429, 6.1187286079111800063, 33.779924812166427728, + 30.93826686935062753, 121.45303725294434116, 7.0978410086827352643, 76.403539933988213306, + 6.9345355466612090822, 95.031909411220112815, 16.0452032115572365, 72.26665327703449293, + 87.750826239567686571, 48.972710095698857913, 50.169109670347097563, 88.431189652372268029, + 0.5006040672815288417, 117.2889208150372724, 100.35725799232386635, 60.60214007216563914, + 25.615303831644268939, 106.63923812894790899, 59.366628536092321156, 23.075936997101962334, + 81.424723983764124569, 63.015486719446926145, 8.0212882863415870816, 30.815984040542389266, + 45.882513182579714339, 84.729925773255672539, 29.603260900199529715, 121.64509074996749405, + 22.933396864562382689, 12.462197030010429444, 123.49837423622739152, 68.341774387285113335, + 109.49032897657889407, 75.438946904221666045, 83.49482241039731889, 81.931615515826706542, + 115.68354184960844577, 0.67173078052655910142, 57.376964829687494785, 119.57578389648188022, + 71.553398424432089087, 110.57868828155915253, 39.415136707324563758, 60.164448971263482235, + 14.564361117409134749, 120.35728413681863458, 17.435276206851995084, 78.605888946385675808, + 0.46081043158119427972, 59.49091027081158245, 85.623518718875857303, 52.294867303313367302, + 76.389609224817832001, 72.525884507213049801, 16.096771126045496203, 107.70103367813499062, + 54.935181611166626681, 11.428507067808823194, 71.208465644773241365, 107.25424085115810158, + 105.29669203544472111, 7.8517862834560219198, 43.185138837146951118, 54.872863268457876984, + 127.42878716421910212, 22.779026972726569511, 12.878913650954928016, 33.499542192043008981, + 113.25627488181635272, 24.167644340002880199, 124.96261296837838017, 101.61849111243282096, + 36.42092963671166217, 4.1986763081658864394, 75.612817015866312431, 76.247485155356116593, + 5.1528835401441028807, 93.352652498011593707, 66.298104023364430759, 37.522514423744723899, + 0.6613251964226947166, 11.489531297018402256, 102.74554680482833646, 23.415216531819169177, + 16.91286593981567421, 55.03449546781484969, 62.886177849472005619, 95.98678589150949847, + 22.626080536898371065, 121.6028145091040642, 102.08096876878698822, 109.19907405697085778, + 115.9299142877353006, 23.669946836856979644, 13.253950753663957585, 84.002437610641209176, + 67.015391470289614517, 72.828513021559047047, 14.335872019706584979, 90.801305711207533022, + 24.175628530436370056, 106.40881599726708373, 88.538934649361181073, 97.41940826918289531, + 70.650494761081063189, 5.9588972972560441121, 41.165786743687931448, 51.131704117568006041, + 118.31120335881860228, 101.30241435805146466, 22.068757539214857388, 33.333072419387463015, + 97.723794788893428631, 51.328308566880878061, 13.595882532259565778, 83.696086261534219375, + 31.277147525630425662, 100.60622780624544248, 114.95548314204643248, 23.55328842526068911, + 30.114702406368451193, 101.96614643089924357, 37.551343722818273818, 43.231704924382938771, + 112.89157313464602339, 125.16387694510194706, 79.51670373556407867, 23.500522099431691458, + 113.20787641379138222, 12.064593748615152435, 121.39591736971851788, 51.370552993033925304, + 14.208229049800138455, 115.16300640751433093, 32.089381597066676477, 18.913353083557012724, + 69.422761323516169796, 80.755982951817713911, 124.17312639508236316, 39.936515777328168042, + 42.69415228269281215, 89.924708995033142855, 18.970778764742135536, 13.733472531268489547, + 43.329778363076911774, 64.925002267715171911, 36.408918325480044587, 11.222467805790074635, + 6.7082969762559514493, 42.245305959433608223, 65.499015725257777376, 52.930552608224388678, + 66.415845206585800042, 77.120834146466222592, 92.759557636512909085, 78.19614069227463915, + 100.04422520817024633, 28.185618658444582252, 19.163475292407383677, 113.33073968323878944, + 75.048917545016593067, 38.286477447865763679, 77.861884958605514839, 95.767295672892942093, + 95.880582908041105838, 60.20624339030473493, 11.858206856293691089, 60.805830023982707644, + 77.672620664336136542, 28.407059730012406362, 48.565974934543191921, 11.407320727019396145, + 97.057611155498307198, 122.85059098130295752, 80.789054917830071645, 57.904614957547892118, + 17.338324444761383347, 122.68172189649339998, 5.2180112172136432491, 84.423048392800410511, + 61.290041644013399491, 50.397087603709223913, 105.56651081126256031, 78.283281924650509609, + 16.905463118018815294, 5.3300440104903827887, 66.522809013542428147, 127.59358356359734898, + 59.858724941750551807, 118.33257342393699219, 55.281754362207720987, 24.658295459321379894, + 115.4444109386386117, 84.061349784355115844, 127.57858616595331114, 113.29294807869882789, + 14.619112520813359879, 90.857525186467682943, 72.440054939172114246, 81.89334282377967611, + 61.648758714611176401, 1.1716952925562509336, 17.072157966329541523, 42.12095602987028542, + 86.153680873176199384, 103.96776688405225286, 116.42465510396868922, 45.949088172652409412, + 49.931944783940707566, 17.598780234016885515, 80.318799103108176496, 66.28185756193488487, + 66.449647158638981637, 124.49296146993219736, 94.706984207616187632, 35.767649320612690644, + 38.746943029764224775, 90.748464431140746456, 4.7645747671886056196, 5.6554976199768134393, + 20.107168887701845961, 13.225245982957858359, 6.3024199551109632012, 52.812528372574888635, + 42.978487412561662495, 24.027802352786238771, 19.39520113386970479, 60.420560050344647607, + 13.723526974357810104, 126.0768418895531795, 77.859584221929253545, 50.470811874602077296, + 20.347335319718695246, 43.05360623863816727, 66.303998948606022168, 37.864276540058199316, + 115.97057607461829321, 20.826651826755551156, 95.323909061098675011, 83.222172582693019649, + 95.563696173379867105, 76.103909471279621357, 4.3732260449687601067, 7.3906108736919122748, + 120.08740614278576686, 8.7721713312312203925, 118.8258045284273976, 22.075906667039816966, + 89.654662760756764328, 41.241550408110924764, 113.48139996685858932, 113.29031928197582602, + 109.4951857452870172, 4.1679930769569182303, 71.713787022272299509, 120.25472881929454161, + 106.47223426953860326, 48.844775009005388711, 95.080572620161547093, 63.980713467670284444, + 28.765992661319614854, 101.22589711482578423, 39.734508914054458728, 8.2012758021519402973, + 58.008951237061410211, 35.70453935237674159, 93.684643825305101927, 32.655590050126193091, + 20.992077805283770431, 97.434201007996307453, 91.735165741050877841, 86.237273290393204661, + 7.802531994824676076, 108.24818495006184094, 124.14225735860600253, 46.897064709890400991, + 87.095014003196411068, 97.880406774729635799, 82.772705123850755626, 123.04826186765058083, + 49.651368650807853555, 102.58454497103593894, 85.332885160769365029, 99.008125278814986814, + 52.665856521427485859, 56.485324005559959915, 7.6814165984724240843, 19.506647852816968225, + 33.163860844706505304, 60.338639893296203809, 57.121095361871994101, 59.975635522554512136, + 125.65810546403736225, 76.64059200422707363, 119.9197741841453535, 80.393577563947474118, + 113.2334335807718162, 33.980205472722445847, 94.231820262004475808, 69.017003838151140371, + 33.208550023649877403, 99.044700884664052865, 94.019714443580596708, 59.901241313760692719, + 4.7952959911781363189, 10.266034869397117291, 127.69015424910685397, 72.411271716671762988, + 67.388529362502595177, 87.403086979426007019, 0.66909201423550257459, 76.050764961404638598, + 112.65969938606940559, 67.610638880516489735, 61.841543415135674877, 57.468728896274114959, + 53.621163910058385227, 42.607130373206018703, 2.5345170589826011565, 18.141239883658272447, + 81.518327143290662207, 38.180733536002662731, 115.08985407739601214, 28.660722857977816602, + 119.94909687021572609, 15.466418771680764621, 97.218980717527301749, 79.3996878599646152, + 1.393792893835779978, 24.286981234410632169, 28.07239503428718308, 115.96346809395618038, + 28.737456185121118324, 6.2825275100622093305, 118.72431487325229682, 44.952223927495651878, + 119.98885948819224723, 39.215159985418722499, 107.92785968616590253, 97.873893176038109232, + 33.69753438462066697, 56.598370007246558089, 89.939916357936454006, 99.103315945299982559, + 1.2968789942897274159, 64.259197678740747506, 16.66514604712210712, 4.6048539168514253106, + 93.785670979959832039, 79.825352161024056841, 27.269855327700497583, 21.618762031426740577, + 18.989656026609736728, 121.96447914326563478, 127.53718813190425863, 56.048933154681435553, + 52.785656561420182697, 45.914926959005242679, 68.359627766210905975, 106.33463741308514727, + 65.788391178346500965, 89.865816814664867707, 23.974723662082396913, 55.26909859040461015, + 90.699998457057517953, 86.708759800745610846, 24.519640135556983296, 72.035767491644946858, + 12.237457215822360013, 67.559849624332855456, 61.87653373870489304, 114.90607450588868232, + 14.195682017369108507, 24.807079867976426613, 13.869071093326056143, 62.063818822440225631, + 32.090406423118110979, 16.53330655407262384, 47.501652479135373142, 97.945420191397715826, + 100.3382193406978331, 48.862379304744536057, 1.0012081345666956622, 106.57784163007818279, + 72.714515984647732694, 121.20428014433127828, 51.230607663292175857, 85.27847625789581798, + 118.73325707218464231, 46.151873994207562646, 34.849447967528249137, 126.03097343889385229, + 16.042576572683174163, 61.631968081084778532, 91.765026365163066657, 41.459851546511345077, + 59.206521800402697409, 115.2901814999349881, 45.866793729124765377, 24.924394060024496866, + 118.99674847245842102, 8.6835487745738646481, 90.980657953161426121, 22.87789380844697007, + 38.989644820798275759, 35.863231031657051062, 103.36708369921689155, 1.3434615610531182028, + 114.75392965937862755, 111.15156779296739842, 15.106796848867816152, 93.157376563118305057, + 78.830273414649127517, 120.32889794252696447, 29.128722234821907477, 112.71456827363726916, + 34.870552413707628148, 29.211777892771351617, 0.92162086316238855943, 118.98182054162680288, + 43.247037437751714606, 104.58973460663037258, 24.77921844963930198, 17.051769014426099602, + 32.193542252094630385, 87.402067356269981246, 109.87036322233325336, 22.857014135621284368, + 14.416931289550120709, 86.508481702319841133, 82.593384070889442228, 15.70357256691204384, + 86.370277674293902237, 109.74572653691939195, 126.85757432843820425, 45.558053945453139022, + 25.757827301909856033, 66.999084384089655941, 98.512549763632705435, 48.335288680009398377, + 121.92522593676039833, 75.236982224865641911, 72.841859273423324339, 8.3973526163354108576, + 23.225634031736262841, 24.494970310712233186, 10.30576708029184374, 58.705304996026825393, + 4.5962080467288615182, 75.045028847489447799, 1.3226503928453894332, 22.979062594040442491, + 77.491093609656672925, 46.830433063638338353, 33.82573187963134842, 110.06899093562969938, + 125.77235569894764922, 63.973571783018996939, 45.252161073800380109, 115.20562901821176638, + 76.161937537577614421, 90.398148113945353543, 103.85982857547060121, 47.339893673713959288, + 26.507901507331553148, 40.00487522128605633, 6.0307829405828670133, 17.657026043118094094, + 28.671744039416807937, 53.602611422415066045, 48.351257060876378091, 84.81763199453780544, + 49.077869298726000125, 66.838816538369428599, 13.300989522162126377, 11.917794594512088224, + 82.331573487375862896, 102.26340823513965006, 108.62240671764084254, 74.60482871610292932, + 44.137515078429714777, 66.666144838778564008, 67.447589577786857262, 102.65661713376175612, + 27.191765064522769535, 39.39217252306843875, 62.554295051264489302, 73.212455612494522939, + 101.91096628409286495, 47.106576850521378219, 60.229404812740540365, 75.932292861798487138, + 75.102687445636547636, 86.46340984876951552, 97.78314626929568476, 122.32775389020753209, + 31.03340747112815734, 47.001044198867020896, 98.415752827582764439, 24.12918749723394285, + 114.79183473943703575, 102.74110598606785061, 28.416458099603914889, 102.32601281502866186, + 64.178763194133352954, 37.826706167117663426, 10.84552264703597757, 33.5119659036390658, + 120.34625279016472632, 79.873031554656336084, 85.388304565389262279, 51.849417990066285711, + 37.941557529484271072, 27.466945062536979094, 86.659556726157461526, 1.8500045354303438216, + 72.817836650960089173, 22.444935611580149271, 13.416593952511902899, 84.490611918870854424, + 2.9980314505155547522, 105.86110521645241533, 4.8316904131752380636, 26.241668292936083162, + 57.519115273029456148, 28.392281384552916279, 72.088450416340492666, 56.371237316889164504, + 38.326950584818405332, 98.661479366481216857, 22.097835090033186134, 76.572954895735165337, + 27.723769917214667657, 63.534591345789522165, 63.761165816082211677, 120.41248678060946986, + 23.716413712587382179, 121.61166004796905327, 27.345241328672273085, 56.814119460024812724, + 97.131949869086383842, 22.814641454042430269, 66.115222311000252375, 117.70118196260955301, + 33.57810983566014329, 115.80922991509578424, 34.676648889526404673, 117.36344379298679996, + 10.436022434430924477, 40.846096785600821022, 122.58008328802679898, 100.7941752074220858, + 83.133021622528758598, 28.566563849301019218, 33.810926236037630588, 10.660088020984403556, + 5.0456180270884942729, 127.18716712719469797, 119.71744988350474159, 108.66514684787398437, + 110.56350872441544197, 49.316590918646397768, 102.88882187728086137, 40.122699568713869667, + 127.15717233191026025, 98.58589615739765577, 29.238225041630357737, 53.715050372939003864, + 16.88010987834786647, 35.786685647559352219, 123.2975174292223528, 2.3433905851125018671, + 34.144315932659083046, 84.241912059744208818, 44.307361746356036747, 79.935533768108143704, + 104.84931020793737844, 91.898176345304818824, 99.863889567881415132, 35.197560468037409009, + 32.637598206219990971, 4.5637151238734077197, 4.899294317281601252, 120.9859229398680327, + 61.413968415232375264, 71.535298641225381289, 77.493886059532087529, 53.496928862281492911, + 9.5291495343772112392, 11.310995239953626879, 40.214337775403691921, 26.450491965915716719, + 12.604839910221926402, 105.62505674514977727, 85.95697482512332499, 48.055604705572477542, + 38.790402267739409581, 120.84112010069293319, 27.447053948719258187, 124.15368377910999698, + 27.719168443858507089, 100.94162374920415459, 40.694670639437390491, 86.107212477279972518, + 4.6079978972120443359, 75.728553080120036611, 103.94115214923658641, 41.65330365351474029, + 62.647818122200988, 38.444345165389677277, 63.127392346763372188, 24.207818942559242714, + 8.7464520899375202134, 14.781221747387462528, 112.17481228557153372, 17.544342662466078764, + 109.6516090568547952, 44.151813334083271911, 51.309325521513528656, 82.483100816225487506, + 98.962799933720816625, 98.58063856395529001, 90.990371490574034397, 8.3359861539174744394, + 15.427574044548236998, 112.5094576385927212, 84.944468539077206515, 97.6895500180144154, + 62.161145240323094185, 127.96142693534056889, 57.531985322642867686, 74.451794229651568457, + 79.469017828108917456, 16.402551604303880595, 116.01790247412282042, 71.409078704757121159, + 59.369287650610203855, 65.311180100252386183, 41.98415561057117884, 66.868402015996252885, + 55.470331482105393661, 44.474546580786409322, 15.605063989652990131, 88.496369900127319852, + 120.28451471721200505, 93.79412941978443996, 46.190028006396460114, 67.760813549462909577, + 37.545410247705149231, 118.09652373530116165, 99.302737301619345089, 77.169089942075515864, + 42.665770321542368038, 70.016250557629973628, 105.33171304285497172, 112.97064801111991983, + 15.362833196944848169, 39.01329570563393645, 66.327721689413010608, 120.67727978659240762, + 114.2421907237439882, 119.95127104511266225, 123.31621092807836249, 25.281184008457785239, + 111.83954836829434498, 32.787155127898586215, 98.466867161543632392, 67.960410945448529674, + 60.463640524012589594, 10.034007676302280743, 66.417100047303392785, 70.089401769331743708, + 60.039428887161193416, 119.80248262752138544, 9.5905919823562726378, 20.53206973879787256, + 127.38030849821734591, 16.822543433347163955, 6.7770587250088283326, 46.806173958852014039, + 1.338184028474643128, 24.101529922812915174, 97.319398772142449161, 7.2212777610329794697, + 123.68308683027134975, 114.93745779254822992, 107.24232782011677045, 85.214260746412037406, + 5.0690341179652023129, 36.282479767320182873, 35.036654286581324413, 76.361467072008963441, + 102.17970815479202429, 57.321445715959271183, 111.89819374043145217, 30.932837543365167221, + 66.437961435058241477, 30.799375719929230399, 2.7875857876715599559, 48.573962468821264338, + 56.144790068578004139, 103.92693618791236077, 57.474912370242236648, 12.56505502012805664, + 109.44862974650459364, 89.904447854994941736, 111.97771897638449445, 78.430319970841082977, + 87.85571937233544304, 67.747786352076218463, 67.395068769241333939, 113.19674001449675416, + 51.87983271587654599, 70.206631890599965118, 2.5937579885830928106, 0.5183953574814950116, + 33.33029209424421424, 9.2097078337064886, 59.571341959923302056, 31.650704322048113681, + 54.539710655400995165, 43.237524062853481155, 37.979312053223111434, 115.92895828653490753, + 127.07437626380851725, 112.09786630936287111, 105.57131312284036539, 91.829853918014123337, + 8.7192555324254499283, 84.669274826173932524, 3.5767823566966399085, 51.731633629329735413, + 47.949447324164793827, 110.53819718081285828, 53.399996914118673885, 45.417519601491221692, + 49.03928027111760457, 16.071534983289893717, 24.474914431648358004, 7.1196992486657109112, + 123.75306747741342406, 101.81214901177736465, 28.391364034738217015, 49.614159735952853225, + 27.738142186652112287, 124.12763764488045126, 64.180812846236221958, 33.066613108145247679, + 95.003304958274384262, 67.89084038279906963, 72.676438681395666208, 97.724758609489072114, + 2.0024162691370293032, 85.155683260160003556, 17.429031969299103366, 114.40856028866255656, + 102.46121532658798969, 42.556952515795273939, 109.46651414436928462, 92.303747988415125292, + 69.698895935060136253, 124.06194687778770458, 32.085153145366348326, 123.26393616217319504, + 55.530052730326133315, 82.919703093022690155, 118.4130436008090328, 102.58036299986997619, + 91.733587458249530755, 49.848788120052631712, 109.99349694491684204, 17.367097549151367275, + 53.961315906322852243, 45.75578761689394014, 77.979289641596551519, 71.726462063317740103, + 78.734167398433783092, 2.6869231221098743845, 101.50785931876089307, 94.303135585934796836, + 30.213593697739270283, 58.314753126240248093, 29.660546829301893013, 112.65779588505392894, + 58.257444469647452934, 97.429136547274538316, 69.741104827415256295, 58.423555785542703234, + 1.8432417263284150977, 109.96364108325360576, 86.49407487550706719, 81.179469213260745164, + 49.55843689927860396, 34.103538028852199204, 64.387084504192898748, 46.804134712543600472, + 91.740726444666506723, 45.714028271242568735, 28.833862579103879398, 45.016963404643320246, + 37.186768141778884456, 31.407145133827725658, 44.740555348591442453, 91.491453073842421873, + 125.7151486568764085, 91.116107890906278044, 51.515654603823350044, 5.9981687681829498615, + 69.02509952726541087, 96.670577360022434732, 115.85045187352443463, 22.4739644497349218, + 17.683718546846648678, 16.794705232670821715, 46.451268063472525682, 48.989940621424466372, + 20.611534160583687481, 117.41060999205365079, 9.1924160934613610152, 22.090057694978895597, + 2.6453007856907788664, 45.958125188084522961, 26.98218721931334585, 93.660866127276676707, + 67.651463759266334819, 92.137981871263036737, 123.54471139789529843, 127.94714356603799388, + 90.504322147604398197, 102.41125803642717074, 24.323875075158866821, 52.796296227894345066, + 79.719657150941202417, 94.679787347427918576, 53.015803014663106296, 80.009750442572112661, + 12.061565881165734027, 35.314052086236188188, 57.343488078833615873, 107.20522284483013209, + 96.702514121756394161, 41.63526398907561088, 98.155738597455638228, 5.6776330767388571985, + 26.601979044324252754, 23.835589189027814427, 36.663146974755363772, 76.526816470282938099, + 89.244813435285323067, 21.20965743220585864, 88.275030156863067532, 5.3322896775607659947, + 6.8951791555773525033, 77.313234267523512244, 54.38353012904553907, 78.7843450461368775, + 125.10859010253261658, 18.424911224992683856, 75.821932568185729906, 94.213153701042756438, + 120.45880962548471871, 23.864585723600612255, 22.205374891276733251, 44.926819697542669019, + 67.5662925385950075, 116.65550778041506419, 62.06681494225631468, 94.00208839773767977, + 68.831505655165528879, 48.258374994471523678, 101.58366947887770948, 77.482211972135701217, + 56.832916199211467756, 76.652025630060961703, 0.35752638826670590788, 75.653412334235326853, + 21.691045294071955141, 67.023931807281769579, 112.69250558033309062, 31.746063109316310147, + 42.776609130778524559, 103.69883598013257142, 75.883115058968542144, 54.933890125077596167, + 45.319113452314923052, 3.7000090708643256221, 17.635673301920178346, 44.889871223160298541, + 26.833187905027443776, 40.981223837741708849, 5.9960629010347474832, 83.722210432904830668, + 9.6633808263504761271, 52.483336585872166324, 115.0382305460589123, 56.784562769109470537, + 16.176900832680985332, 112.74247463377832901, 76.653901169640448643, 69.322958732962433714, + 44.195670180070010247, 25.145909791470330674, 55.447539834429335315, 127.06918269157904433, + 127.52233163216806133, 112.82497356121893972, 47.432827425178402336, 115.22332009593810653, + 54.690482657344546169, 113.62823892005326343, 66.263899738172767684, 45.629282908088498516, + 4.2304446220041427296, 107.40236392521910602, 67.156219671323924558, 103.61845983019156847, + 69.353297779056447325, 106.72688758597359993, 20.872044868861848954, 81.692193571205280023, + 117.16016657605723594, 73.588350414847809589, 38.266043245057517197, 57.133127698602038436, + 67.621852472075261176, 21.320176041968807112, 10.091236054180626525, 126.37433425439303392, + 111.43489976701312116, 89.33029369575160672, 93.12701744883088395, 98.633181837296433514, + 77.777643754561722744, 80.245399137431377312, 126.31434466382415849, 69.17179231479531154, + 58.476450083260715473, 107.43010074587800773, 33.76021975669573294, 71.573371295122342417, + 118.59503485844470561, 4.6867811702250037342, 68.288631865321804071, 40.483824119488417637, + 88.614723492715711473, 31.871067536219925387, 81.698620415878394851, 55.796352690613275627, + 71.727779135762830265, 70.395120936074818019, 65.275196412439981941, 9.1274302477468154393, + 9.7985886345668404829, 113.9718458797360654, 122.82793683046838851, 15.070597282454400556, + 26.987772119064175058, 106.99385772456298582, 19.058299068754422478, 22.621990479907253757, + 80.428675550807383843, 52.900983931831433438, 25.209679820447490783, 83.250113490303192521, + 43.913949650246649981, 96.111209411144955084, 77.58080453548245714, 113.68224020138950436, + 54.894107897442154353, 120.30736755821999395, 55.438336887720652157, 73.883247498408309184, + 81.389341278878418962, 44.214424954559945036, 9.2159957944277266506, 23.457106160243711201, + 79.882304298473172821, 83.30660730702948058, 125.295636244401976, 76.888690330779354554, + 126.25478469352674438, 48.415637885118485428, 17.492904179875040427, 29.562443494778563036, + 96.349624571143067442, 35.088685324935795506, 91.303218113709590398, 88.303626668166543823, + 102.61865104303069529, 36.966201632454612991, 69.925599867445271229, 69.161277127914217999, + 53.980742981148068793, 16.671972307834948879, 30.855148089100111974, 97.018915277189080371, + 41.888937078158051008, 67.3791000360288308, 124.32229048064982635, 127.92285387068113778, + 115.06397064528937335, 20.903588459306774894, 30.938035656217834912, 32.805103208611399168, + 104.03580494824927882, 14.818157409514242318, 118.73857530122404569, 2.6223602005047723651, + 83.96831122114599566, 5.7368040319925057702, 110.94066296421078732, 88.949093161572818644, + 31.21012797930961824, 48.992739800258277683, 112.56902943442764808, 59.588258839568879921, + 92.380056012796558207, 7.5216270989258191548, 75.090820495413936442, 108.19304747060596128, + 70.605474603242328158, 26.338179884151031729, 85.331540643088374054, 12.032501115263585234, + 82.663426085713581415, 97.941296022239839658, 30.725666393889696337, 78.026591411271510879, + 4.6554433788296591956, 113.35455957318845321, 100.48438144749161438, 111.90254209022896248, + 118.63242185615672497, 50.562368016919208458, 95.679096736588689964, 65.57431025580081041, + 68.933734323090902762, 7.9208218908970593475, 120.92728104802517919, 20.068015352608199464, + 4.8342000946104235481, 12.178803538663487416, 120.07885777432602481, 111.60496525504277088, + 19.181183964712545276, 41.064139477599383099, 126.76061699643469183, 33.645086866694327909, + 13.554117450017656665, 93.612347917704028077, 2.676368056949286256, 48.203059845629468327, + 66.638797544284898322, 14.442555522069596918, 119.36617366054633749, 101.87491558510009781, + 86.484655640237178886, 42.428521492824074812, 10.138068235930404626, 72.564959534640365746, + 70.073308573166286806, 24.722934144021564862, 76.359416309584048577, 114.64289143192218035, + 95.79638748086290434, 61.865675086733972421, 4.8759228701164829545, 61.598751439858460799, + 5.5751715753431199118, 97.147924937642528675, 112.28958013715964626, 79.85387237582472153, + 114.9498247404844733, 25.130110040259751258, 90.89725949301282526, 51.80889570999352145, + 95.955437952772626886, 28.860639941685803933, 47.71143874467452406, 7.4955727041560749058, + 6.7901375384863058571, 98.393480028993508313, 103.75966543175672996, 12.413263781199930236, + 5.1875159771661856212, 1.0367907149629900232, 66.660584188488428481, 18.4194156674129772, + 119.14268391984660411, 63.301408644096227363, 109.07942131080199033, 86.47504812570696231, + 75.958624106449860847, 103.85791657307345304, 126.14875252762067248, 96.195732618729380192, + 83.142626245684368769, 55.659707836028246675, 17.438511064854537835, 41.338549652347865049, + 7.153564713393279817, 103.46326725865947083, 95.898894648333225632, 93.076394361625716556, + 106.79999382823734777, 90.835039202982443385, 98.078560542235209141, 32.143069966579787433, + 48.949828863296716008, 14.239398497335059801, 119.50613495483048609, 75.624298023554729298, + 56.78272806947643403, 99.22831947190570645, 55.476284373307862552, 120.2552752897645405, + 0.3616256924724439159, 66.133226216294133337, 62.006609916552406503, 7.7816807656017772388, + 17.352877362794970395, 67.449517218978144228, 4.0048325382776965853, 42.311366520320007112, + 34.858063938601844711, 100.8171205773287511, 76.922430653175979387, 85.113905031594185857, + 90.933028288742207224, 56.607495976833888562, 11.397791870123910485, 120.12389375557540916, + 64.170306290736334631, 118.52787232434639009, 111.06010546065590461, 37.839406186049018288, + 108.82608720162170357, 77.160725999743590364, 55.46717491649906151, 99.697576240108901402, + 91.986993889833684079, 34.73419509830273455, 107.92263181264570449, 91.511575233791518258, + 27.958579283196741017, 15.452924126639118185, 29.468334796867566183, 5.3738462442233867478, + 75.015718637525424128, 60.606271171869593672, 60.427187395478540566, 116.62950625248049619, + 59.321093658607424004, 97.315591770107857883, 116.51488893929854385, 66.85827309455271461, + 11.482209654830512591, 116.84711157108540647, 3.6864834526604681741, 91.927282166510849493, + 44.98814975101777236, 34.358938426521490328, 99.11687379855720792, 68.207076057708036387, + 0.77416900838579749689, 93.608269425090838922, 55.481452889333013445, 91.42805654248513747, + 57.667725158207758795, 90.033926809286640491, 74.373536283557768911, 62.814290267655451316, + 89.481110697186522884, 54.982906147688481724, 123.43029731375645497, 54.232215781812556088, + 103.03130920764670009, 11.996337536369537702, 10.050199054534459719, 65.341154720048507443, + 103.70090374704886926, 44.9479288994698436, 35.367437093693297356, 33.58941046534164343, + 92.902536126945051365, 97.979881242848932743, 41.22306832117101294, 106.82121998410730157, + 18.38483218692272203, 44.180115389957791194, 5.2906015713815577328, 91.916250376169045921, + 53.964374438630329678, 59.321732254556991393, 7.3029275185363076162, 56.275963742529711453, + 119.08942279579423484, 127.89428713207962574, 53.008644295212434372, 76.822516072854341473, + 48.647750150317733642, 105.59259245579232811, 31.439314301886042813, 61.359574694855837151, + 106.03160602932985057, 32.019500885144225322, 24.123131762331468053, 70.628104172472376376, + 114.68697615767086972, 86.410445689663902158, 65.405028243512788322, 83.270527978154859738, + 68.311477194911276456, 11.355266153477714397, 53.203958088648505509, 47.671178378055628855, + 73.326293949514365522, 25.053632940569514176, 50.489626870570646133, 42.41931486441535526, + 48.550060313726135064, 10.664579355121531989, 13.790358311158342985, 26.626468535047024488, + 108.76706025809471612, 29.568690092277392978, 122.21718020506523317, 36.84982244998900569, + 23.643865136375097791, 60.426307402089150855, 112.91761925096943742, 47.72917144720122451, + 44.410749782553466503, 89.853639395088976016, 7.1325850771936529782, 105.31101556083012838, + 124.13362988451626734, 60.004176795478997519, 9.6630113103310577571, 96.516749988946685335, + 75.167338957759056939, 26.964423944271402434, 113.66583239842657349, 25.304051260121923406, + 0.71505277653704979457, 23.306824668470653705, 43.38209058814754826, 6.0478636145671771374, + 97.38501116066618124, 63.492126218632620294, 85.553218261560687097, 79.397671960268780822, + 23.766230117937084287, 109.86778025015519233, 90.638226904629846103, 7.4000181417286512442, + 35.271346603840356693, 89.779742446320597082, 53.666375810054887552, 81.962447675483417697, + 11.992125802073132945, 39.444420865809661336, 19.326761652700952254, 104.96667317174797063, + 102.07646109211782459, 113.56912553821894107, 32.353801665365608642, 97.484949267560295993, + 25.307802339284535265, 10.645917465924867429, 88.391340360140020493, 50.291819582940661348, + 110.89507966886230861, 126.13836538316172664, 127.04466326433976064, 97.649947122437879443, + 94.865654850360442651, 102.44664019187621307, 109.38096531469273032, 99.256477840110164834, + 4.5277994763455353677, 91.258565816176997032, 8.4608892440119234379, 86.804727850441850023, + 6.3124393426514870953, 79.236919660386774922, 10.706595558116532629, 85.453775171947199851, + 41.744089737727335887, 35.384387142414198024, 106.32033315211810987, 19.176700829695619177, + 76.532086490115034394, 114.26625539720771485, 7.2437049441505223513, 42.640352083937614225, + 20.182472108364891028, 124.74866850878970581, 94.869799534029880306, 50.660587391506851418, + 58.254034897665405879, 69.266363674596505007, 27.555287509127083467, 32.490798274866392603, + 124.62868932765195495, 10.343584629590623081, 116.95290016652506893, 86.860201491756015457, + 67.520439513395103859, 15.146742590248322813, 109.19006971688941121, 9.3735623404536454473, + 8.5772637306436081417, 80.967648238980473252, 49.229446985431422945, 63.742135072443488752, + 35.397240831756789703, 111.59270538123018923, 15.455558271529298509, 12.790241872153274016, + 2.5503928248799638823, 18.254860495493630879, 19.597177269137318945, 99.943691759475768777, + 117.65587366093677701, 30.141194564908801112, 53.975544238131988095, 85.987715449125971645, + 38.116598137508844957, 45.243980959818145493, 32.857351101614767686, 105.80196786366286688, + 50.419359640898619546, 38.500226980606385041, 87.82789930049693794, 64.222418822293548146, + 27.16160907096855226, 99.364480402779008728, 109.78821579488794669, 112.61473511643998791, + 110.87667377544494229, 19.766494996820256347, 34.778682557756837923, 88.428849909119890071, + 18.431991588855453301, 46.914212320491060382, 31.764608596949983621, 38.613214614062599139, + 122.59127248880758998, 25.777380661562347086, 124.50956938705348875, 96.831275770236970857, + 34.985808359750080854, 59.12488698956076405, 64.699249142286134884, 70.177370649875228992, + 54.606436227422818774, 48.607253336336725624, 77.237302086061390582, 73.93240326491286396, + 11.851199734894180438, 10.322554255828435998, 107.96148596229613759, 33.343944615669897757, + 61.710296178203861928, 66.037830554378160741, 83.777874156319739996, 6.7582000720612995792, + 120.64458096130329068, 127.84570774136591353, 102.1279412905787467, 41.807176918613549788, + 61.876071312435669824, 65.610206417226436315, 80.071609896498557646, 29.636314819032122614, + 109.47715060244809138, 5.244720401013182709, 39.93662244229199132, 11.473608063988649519, + 93.881325928425212624, 49.898186323145637289, 62.42025595861923648, 97.985479600520193344, + 97.138058868855296168, 119.17651767914139782, 56.760112025593116414, 15.043254197855276288, + 22.181640990831510862, 88.386094941215560539, 13.210949206484656315, 52.676359768305701436, + 42.663081286176748108, 24.065002230530808447, 37.326852171430800809, 67.882592044479679316, + 61.451332787783030653, 28.053182822543021757, 9.31088675766295637, 98.709119146380544407, + 72.968762894986866741, 95.805084180461562937, 109.26484371231344994, 101.12473603384205489, + 63.358193473181017907, 3.1486205116052587982, 9.867468646181805525, 15.841643781797756674, + 113.85456209605035838, 40.136030705216398928, 9.6684001892208470963, 24.35760707733061281, + 112.1577155486556876, 95.209930510085541755, 38.362367929425090551, 82.128278955202404177, + 125.52123399286938366, 67.290173733388655819, 27.108234900038951309, 59.224695835408056155, + 5.352736113898572512, 96.406119691262574634, 5.2775950885697966442, 28.885111044142831815, + 110.73234732109631295, 75.749831170203833608, 44.969311280474357773, 84.857042985648149624, + 20.27613647186444723, 17.129919069284369471, 12.146617146332573611, 49.445868288046767702, + 24.718832619171735132, 101.28578286384799867, 63.59277496172580868, 123.73135017346794484, + 9.7518457402329659089, 123.1975028797169216, 11.150343150689877803, 66.29584987528869533, + 96.579160274322930491, 31.707744751653081039, 101.89964948096894659, 50.260220080523140496, + 53.79451898602565052, 103.61779141999068088, 63.910875905545253772, 57.721279883371607866, + 95.422877489349048119, 14.991145408312149812, 13.580275076976249693, 68.786960057990654605, + 79.519330863513459917, 24.826527562399860471, 10.375031954332371242, 2.0735814299296180252, + 5.3211683769768569618, 36.838831334829592379, 110.28536783969320823, 126.6028172881960927, + 90.158842621607618639, 44.950096251417562598, 23.917248212903359672, 79.715833146150544053, + 124.29750505524498294, 64.391465237462398363, 38.285252491368737537, 111.31941567205649335, + 34.877022129709075671, 82.677099304695730098, 14.307129426790197613, 78.926534517322579632, + 63.797789296670089243, 58.152788723255071091, 85.59998765647833352, 53.670078405968524748, + 68.157121084470418282, 64.286139933159574866, 97.899657726593432017, 28.478796994673757581, + 111.01226990966461017, 23.248596047109458596, 113.56545613895650604, 70.456638943811412901, + 110.95256874661936308, 112.51055057952908101, 0.72325138494852581061, 4.2664524325882666744, + 124.01321983310481301, 15.563361531203554478, 34.705754725593578769, 6.8990344379562884569, + 8.0096650765553931706, 84.622733040640014224, 69.716127877207327401, 73.634241154661140172, + 25.844861306355596753, 42.227810063192009693, 53.866056577484414447, 113.21499195366777712, + 22.795583740251458948, 112.2477875111544563, 0.34061258147630724125, 109.05574464869641815, + 94.120210921311809216, 75.678812372101674555, 89.65217440324704512, 26.321451999487180728, + 110.934349833001761, 71.395152480221440783, 55.973987779667368159, 69.468390196609107079, + 87.84526362529504695, 55.023150467583036516, 55.917158566393482033, 30.905848253278236371, + 58.936669593735132366, 10.747692488450411474, 22.031437275050848257, 121.21254234373918734, + 120.85437479096071911, 105.25901250496099237, 118.64218731721848599, 66.631183540219353745, + 105.02977787860072567, 5.7165461891054292209, 22.96441930966466316, 105.69422314217081293, + 7.3729669053245743271, 55.854564333021698985, 89.97629950203554472, 68.717876853046618635, + 70.233747597118053818, 8.4141521154160727747, 1.5483380167752329726, 59.216538850181677844, + 110.96290577866966487, 54.85611308497027494, 115.33545031641915557, 52.067853618576918961, + 20.747072567115537822, 125.62858053531454061, 50.962221394373045769, 109.96581229538060143, + 118.86059462751290994, 108.46443156362875015, 78.062618415293400176, 23.992675072739075404, + 20.100398109072557418, 2.6823094401006528642, 79.401807494097738527, 89.8958577989396872, + 70.734874187386594713, 67.178820930686924839, 57.805072253893740708, 67.959762485697865486, + 82.446136642345663859, 85.642439968214603141, 36.769664373845444061, 88.360230779915582389, + 10.581203142766753444, 55.832500752338091843, 107.92874887726065936, 118.64346450911398279, + 14.605855037072615232, 112.55192748506306089, 110.17884559159210767, 127.78857426415925147, + 106.01728859042850672, 25.645032145708682947, 97.295500300639105262, 83.18518491158465622, + 62.878628603772085626, 122.71914938971531228, 84.063212058659701142, 64.039001770288450643, + 48.246263524666574085, 13.256208344948390732, 101.37395231534537743, 44.820891379331442295, + 2.8100564870292146225, 38.541055956313357456, 8.6229543898225529119, 22.710532306955428794, + 106.40791617729701102, 95.342356756114895688, 18.652587899028731044, 50.107265881139028352, + 100.97925374114129227, 84.838629728830710519, 97.100120627452270128, 21.329158710243063979, + 27.580716622316685971, 53.252937070097686956, 89.534120516189432237, 59.137380184558423935, + 116.43436041013046633, 73.699644899978011381, 47.287730272750195581, 120.85261480418193969, + 97.835238501938874833, 95.458342894402449019, 88.821499565110570984, 51.707278790177952033, + 14.265170154390943935, 82.622031121663894737, 120.26725976903253468, 120.00835359095799504, + 19.326022620665753493, 65.033499977897008648, 22.334677915518113878, 53.928847888546442846, + 99.331664796853146981, 50.608102520243846811, 1.4301055530740995891, 46.613649336941307411, + 86.76418117629509652, 12.095727229137992254, 66.77002232133236248, 126.98425243726887857, + 43.106436523125012172, 30.795343920537561644, 47.532460235877806554, 91.735560500314022647, + 53.276453809259692207, 14.800036283457302488, 70.542693207684351364, 51.559484892641194165, + 107.33275162011341308, 35.924895350966835395, 23.98425160414626589, 78.888841731619322672, + 38.653523305405542487, 81.933346343499579234, 76.152922184239287162, 99.138251076437882148, + 64.707603330734855263, 66.969898535120591987, 50.615604678569070529, 21.291834931853372836, + 48.782680720280040987, 100.58363916588496068, 93.790159337728255196, 124.27673076632709126, + 126.08932652868315927, 67.299894244879396865, 61.731309700724523282, 76.893280383756064111, + 90.761930629389098613, 70.512955680220329668, 9.0555989526947087143, 54.517131632353994064, + 16.921778488027484855, 45.609455700883700047, 12.624878685306612169, 30.473839320773549844, + 21.413191116236703238, 42.907550343894399703, 83.488179475454671774, 70.768774284832034027, + 84.64066630423621973, 38.353401659394876333, 25.064172980233706767, 100.5325107944154297, + 14.487409888301044703, 85.28070416787522845, 40.364944216733420035, 121.4973370175830496, + 61.739599068059760612, 101.32117478301370284, 116.50806979533444974, 10.532727349193010014, + 55.110575018254166935, 64.981596549736423185, 121.25737865530390991, 20.68716925918488414, + 105.90580033305377583, 45.720402983515668893, 7.0408790267902077176, 30.293485180500283604, + 90.380139433778822422, 18.747124680907290895, 17.154527461290854262, 33.935296477960946504, + 98.45889397086284589, 127.4842701448869775, 70.794481663517217385, 95.185410762460378464, + 30.911116543058597017, 25.580483744306548033, 5.1007856497599277645, 36.509720990987261757, + 39.194354538278275868, 71.887383518955175532, 107.31174732187355403, 60.282389129817602225, + 107.95108847626761417, 43.97543089825194329, 76.233196275017689914, 90.487961919636290986, + 65.71470220323317335, 83.603935727325733751, 100.83871928179723909, 77.000453961216408061, + 47.655798600997513859, 0.44483764458709629253, 54.323218141940742498, 70.728960805558017455, + 91.57643158977953135, 97.229470232883613789, 93.753347550889884587, 39.532989993640512694, + 69.557365115517313825, 48.857699818239780143, 36.863983177710906602, 93.828424640982120764, + 63.529217193899967242, 77.226429228128836257, 117.18254497761517996, 51.554761323128332151, + 121.01913877411061549, 65.662551540473941714, 69.971616719500161707, 118.24977397912516608, + 1.3984982845759077463, 12.354741299750457983, 109.21287245484563755, 97.214506672677089227, + 26.474604172126419144, 19.864806529825727921, 23.702399469788360875, 20.645108511660509976, + 87.922971924592275172, 66.687889231339795515, 123.42059235641136183, 4.0756611087599594612, + 39.555748312639479991, 13.516400144126237137, 113.28916192261021934, 127.69141548273546505, + 76.255882581157493405, 83.614353837227099575, 123.75214262487497763, 3.220412834456510609, + 32.143219792997115292, 59.272629638067883207, 90.954301204896182753, 10.489440802026365418, + 79.873244884583982639, 22.947216127980937017, 59.762651856850425247, 99.796372646291274577, + 124.84051191724211094, 67.970959201044024667, 66.276117737714230316, 110.35303535828279564, + 113.52022405118623283, 30.086508395710552577, 44.363281981666659703, 48.772189882431121077, + 26.421898412969312631, 105.35271953661140287, 85.326162572353496216, 48.130004461061616894, + 74.653704342865239596, 7.7651840889593586326, 122.90266557556606131, 56.106365645086043514, + 18.621773515329550719, 69.418238292764726793, 17.93752578997737146, 63.610168360926763853, + 90.529687424630537862, 74.249472067684109788, 126.71638694636203581, 6.2972410232105175965, + 19.73493729236361105, 31.683287563599151326, 99.709124192100716755, 80.272061410432797857, + 19.336800378441694193, 48.715214154664863599, 96.315431097315013176, 62.41986102017108351, + 76.724735858853819082, 36.256557910408446332, 123.04246798574240529, 6.580347466777311638, + 54.216469800077902619, 118.44939167081611231, 10.705472227800783003, 64.812239382525149267, + 10.555190177139593288, 57.77022208828930161, 93.464694642196263885, 23.499662340407667216, + 89.938622560952353524, 41.714085971296299249, 40.552272943728894461, 34.259838138568738941, + 24.293234292665147223, 98.891736576093535405, 49.437665238347108243, 74.571565727695997339, + 127.18554992345525534, 119.46270034693588968, 19.503691480469569797, 118.3950057594338432, + 22.300686301383393584, 4.5916997505810286384, 65.158320548645860981, 63.415489503309800057, + 75.799298961937893182, 100.52044016104628099, 107.58903797205493902, 79.235582839981361758, + 127.82175181109050754, 115.44255976674685371, 62.845754978698096238, 29.982290816624299623, + 27.160550153956137365, 9.5739201159849471878, 31.038661727026919834, 49.653055124799720943, + 20.750063908664742485, 4.1471628598592360504, 10.642336753953713924, 73.677662669662822736, + 92.570735679390054429, 125.20563457639582339, 52.317685243215237278, 89.900192502835125197, + 47.834496425810357323, 31.431666292304726085, 120.59501011049360386, 0.78293047492479672655, + 76.570504982741113054, 94.638831344112986699, 69.75404425942178932, 37.354198609391460195, + 28.614258853584033204, 29.853069034645159263, 127.59557859334017849, 116.30557744651378016, + 43.19997531295666704, 107.34015681194068748, 8.3142421689444745425, 0.5722798663227877114, + 67.799315453186864033, 56.957593989351153141, 94.024539819329220336, 46.49719209422255517, + 99.130912277916650055, 12.91327788762646378, 93.905137493242364144, 97.021101159058162011, + 1.4465027698970516212, 8.5329048651801713277, 120.02643966620962601, 31.126723062407108955, + 69.411509451187157538, 13.798068875912576914, 16.01933015311442432, 41.245466081283666426, + 11.432255754418292781, 19.268482309322280344, 51.689722612711193506, 84.455620126384019386, + 107.73211315497246687, 98.42998390733555425, 45.591167480506555876, 96.495575022308912594, + 0.6812251629562524613, 90.111489297396474285, 60.24042184262725641, 23.357624744206987089, + 51.30434880649409024, 52.642903998977999436, 93.868699666007159976, 14.790304960442881566, + 111.9479755593383743, 10.936780393221852137, 47.6905272505900939, 110.04630093516607303, + 111.83431713278696407, 61.811696506556472741, 117.87333918747026473, 21.495384976900822949, + 44.062874550105334492, 114.42508468748201267, 113.7087495819250762, 82.518025009925622726, + 109.28437463444060995, 5.2623670804423454683, 82.059555757201451343, 11.433092378210858442, + 45.928838619332964299, 83.388446284341625869, 14.745933810649148654, 111.70912866604703595, + 51.952599004074727418, 9.4357537060968752485, 12.467495194236107636, 16.828304230832145549, + 3.0966760335504659452, 118.43307770036699367, 93.925811557339329738, 109.71222616994418786, + 102.67090063283831114, 104.13570723715383792, 41.494145134234713623, 123.25716107062908122, + 101.92444278874972952, 91.931624590764840832, 109.72118925502945785, 88.928863127261138288, + 28.125236830586800352, 47.985350145478150807, 40.200796218145114835, 5.3646188802049437072, + 30.803614988199115032, 51.791715597883012379, 13.469748374776827404, 6.3576418613738496788, + 115.61014450779111939, 7.9195249713993689511, 36.892273284694965696, 43.284879936429206282, + 73.539328747694526101, 48.720461559831164777, 21.162406285533506889, 111.66500150467982166, + 87.85749775452495669, 109.28692901822796557, 29.211710074148868443, 97.103854970129759749, + 92.357691183187853312, 127.57714852832214092, 84.034577180857013445, 51.290064291421003873, + 66.591000601281848503, 38.37036982316931244, 125.75725720754780923, 117.43829877943426254, + 40.126424117323040264, 0.07800354057690128684, 96.49252704933314817, 26.512416689900419442, + 74.747904630690754857, 89.641782758662884589, 5.6201129740584292449, 77.082111912626714911, + 17.245908779645105824, 45.421064613914495567, 84.815832354597660014, 62.684713512229791377, + 37.305175798057462089, 100.21453176228169468, 73.958507482286222512, 41.677259457665059017, + 66.200241254904540256, 42.658317420486127958, 55.161433244633371942, 106.50587414019901189, + 51.068241032378864475, 118.27476036912048585, 104.86872082026457065, 19.399289799956022762, + 94.575460545504029142, 113.70522960836751736, 67.670477003881387645, 62.916685788808536017, + 49.642999130221141968, 103.41455758035590407, 28.530340308785525849, 37.244062243331427453, + 112.53451953806870733, 112.01670718191599008, 38.652045241335144965, 2.0669999557940172963, + 44.669355831036227755, 107.85769577709652367, 70.663329593706293963, 101.21620504048769362, + 2.8602111061481991783, 93.2272986738862528, 45.528362352590193041, 24.191454458279622486, + 5.5400446426683629397, 125.96850487453775713, 86.212873046250024345, 61.590687841075123288, + 95.064920471759251086, 55.471121000628045294, 106.55290761851938441, 29.600072566918242956, + 13.085386415368702728, 103.11896978528602631, 86.665503240226826165, 71.849790701933670789, + 47.96850320829616976, 29.777683463238645345, 77.307046610814722953, 35.866692687002796447, + 24.305844368482212303, 70.276502152879402274, 1.4152066614733485039, 5.9397970702411839738, + 101.23120935713814106, 42.583669863706745673, 97.565361440563719952, 73.16727833177355933, + 59.58031867546014837, 120.5534615326578205, 124.17865305736995651, 6.5997884897587937303, + 123.46261940145268454, 25.786560767515766202, 53.523861258781835204, 13.025911360440659337, + 18.111197905389417429, 109.03426326470798813, 33.843556976054969709, 91.218911401767400093, + 25.249757370613224339, 60.947678641547099687, 42.826382232473406475, 85.815100687792437384, + 38.976358950912981527, 13.537548569667706033, 41.28133260847243946, 76.706803318789752666, + 50.128345960471051512, 73.0650215888308594, 28.974819776605727384, 42.561408335750456899, + 80.729888433470478049, 114.9946740351660992, 123.4791981361231592, 74.642349566031043651, + 105.01613959066889947, 21.065454698386020027, 110.22115003651197185, 1.963193099476484349, + 114.51475731060781982, 41.374338518373406259, 83.81160066610755166, 91.440805967031337786, + 14.081758053580415435, 60.586970361004205188, 52.760278867557644844, 37.494249361814581789, + 34.309054922581708524, 67.870592955925530987, 68.917787941729329759, 126.96854028977759299, + 13.588963327038072748, 62.370821524920756929, 61.822233086117194034, 51.160967488613096066, + 10.201571299519855529, 73.019441981974523515, 78.388709076560189715, 15.774767037913989043, + 86.623494643747108057, 120.56477825963884243, 87.902176952535228338, 87.950861796507524559, + 24.466392550039017806, 52.975923839276219951, 3.4294044064699846786, 39.207871454655105481, + 73.677438563598116161, 26.000907922432816122, 95.311597201995027717, 0.88967528917419258505, + 108.64643628388512298, 13.45792161111603491, 55.15286317956270068, 66.458940465770865558, + 59.506695101779769175, 79.065979987284663366, 11.11473023103462765, 97.715399636479560286, + 73.727966355425451184, 59.656849281964241527, 127.05843438780357246, 26.452858456261310494, + 106.36508995523035992, 103.10952264626030228, 114.03827754822486895, 3.325103080951521406, + 11.943233439003961394, 108.49954795825033216, 2.7969965691518154927, 24.709482599504553946, + 90.425744909694913076, 66.429013345354178455, 52.949208344252838288, 39.729613059651455842, + 47.40479893957672175, 41.29021702332465793, 47.845943849188188324, 5.3757784626832290087, + 118.84118471282272367, 8.1513222175199189223, 79.111496625278959982, 27.032800288256112253, + 98.578323845224076649, 127.38283096547456807, 24.511765162318624789, 39.228707674457837129, + 119.50428524974995526, 6.440825668913021218, 64.286439585994230583, 118.54525927613940439, + 53.908602409792365506, 20.978881604056368815, 31.746489769167965278, 45.894432255961874034, + 119.52530371370448847, 71.592745292586187134, 121.68102383448785986, 7.9419184020916873123, + 4.5522354754320986103, 92.706070716569229262, 99.040448102372465655, 60.173016791421105154, + 88.726563963333319407, 97.544379764862242155, 52.84379682594226324, 82.705439073226443725, + 42.652325144706992432, 96.260008922126871767, 21.307408685730479192, 15.530368177922355244, + 117.80533115113212261, 112.21273129017208703, 37.243547030662739417, 10.836476585529453587, + 35.87505157995474292, 127.22033672185716568, 53.059374849264713703, 20.498944135371857556, + 125.43277389272407163, 12.594482046421035193, 39.4698745847272221, 63.366575127201940631, + 71.418248384205071488, 32.544122820865595713, 38.673600756883388385, 97.430428309333365178, + 64.630862194630026352, 124.839722040345805, 25.449471717707638163, 72.513115820820530644, + 118.08493597148481058, 13.160694933554623276, 108.43293960015944322, 108.89878334163222462, + 21.410944455605203984, 1.6244787650502985343, 21.110380354279186577, 115.5404441765822412, + 58.92938928439252777, 46.999324680818972411, 51.877245121904707048, 83.428171942592598498, + 81.104545887457788922, 68.519676277137477882, 48.586468585333932424, 69.783473152187070809, + 98.875330476697854465, 21.143131455395632656, 126.37109984691414866, 110.92540069387177937, + 39.007382960942777572, 108.79001151886768639, 44.601372602766787168, 9.1833995011656952556, + 2.3166410972917219624, 126.83097900662323809, 23.598597923879424343, 73.040880322096199961, + 87.178075944113516016, 30.471165679966361495, 127.64350362218465307, 102.88511953349370742, + 125.69150995739619248, 59.964581633248599246, 54.321100307912274729, 19.147840231969894376, + 62.077323454053839669, 99.306110249599441886, 41.500127817329484969, 8.2943257197184721008, + 21.284673507911065826, 19.355325339329283452, 57.141471358783746837, 122.41126915279164677, + 104.63537048643411254, 51.800385005670250393, 95.668992851620714646, 62.863332584613090148, + 113.19002022098720772, 1.5658609498532314319, 25.141009965485864086, 61.277662688229611376, + 11.50808851884357864, 74.70839721878292039, 57.228517707168066408, 59.706138069293956505, + 127.19115718668399495, 104.61115489302756032, 86.399950625916972058, 86.680313623881374951, + 16.628484337888949085, 1.1445597326492134016, 7.5986309063737280667, 113.91518797870594426, + 60.049079638658440672, 92.994384188448748318, 70.26182455583330011, 25.826555775256565539, + 59.810274986488366267, 66.042202318116324022, 2.8930055397941032425, 17.065809730363980634, + 112.05287933241925202, 62.253446124817855889, 10.823018902374315076, 27.596137751825153828, + 32.03866030622884864, 82.490932162567332853, 22.864511508836585563, 38.536964618644560687, + 103.37944522542602499, 40.911240252771676751, 87.464226309948571725, 68.859967814671108499, + 91.18233496101674973, 64.991150044617825188, 1.3624503259161429014, 52.22297859479294857, + 120.48084368525451282, 46.715249488413974177, 102.60869761298818048, 105.28580799795963685, + 59.737399332014319953, 29.58060992088940111, 95.895951118676748592, 21.873560786443704274, + 95.381054501183825778, 92.092601870335784042, 95.668634265573928133, 123.62339301311658346, + 107.74667837494052947, 42.990769953801645897, 88.125749100214306964, 100.85016937496766332, + 99.417499163853790378, 37.036050019854883431, 90.568749268881219905, 10.524734160888328915, + 36.119111514402902685, 22.866184756421716884, 91.857677238669566577, 38.776892568683251739, + 29.491867621301935287, 95.418257332094071899, 103.90519800814945484, 18.871507412193750497, + 24.934990388472215272, 33.656608461664291099, 6.1933520671045698691, 108.86615540073762531, + 59.851623114682297455, 91.424452339892013697, 77.341801265680260258, 80.271414474307675846, + 82.988290268473065225, 118.51432214126180043, 75.848885577503097011, 55.863249181533319643, + 91.442378510062553687, 49.857726254522276577, 56.250473661173600703, 95.970700290956301615, + 80.401592436290229671, 10.729237760409887414, 61.607229976398230065, 103.58343119576602476, + 26.939496749553654809, 12.715283722751337336, 103.22028901558223879, 15.839049942798737902, + 73.784546569389931392, 86.569759872862050543, 19.078657495389052201, 97.440923119662329555, + 42.324812571070651757, 95.330003009363281308, 47.714995509053551359, 90.573858036455931142, + 58.423420148301374866, 66.207709940263157478, 56.715382366379344603, 127.15429705664791982, + 40.069154361714026891, 102.58012858284564572, 5.1820012025636970066, 76.740739646342262859, + 123.51451441509925644, 106.87659755886852508, 80.252848234646080527, 0.15600708115744055249, + 64.985054098666296341, 53.024833379804476863, 21.495809261385147693, 51.283565517325769179, + 11.240225948120496469, 26.164223825253429823, 34.491817559290211648, 90.842129227832629113, + 41.631664709195320029, 125.36942702445958275, 74.610351596118562156, 72.429063524567027343, + 19.917014964572445024, 83.354518915333756013, 4.4004825098090805113, 85.316634840972255915, + 110.32286648927038186, 85.01174828039802378, 102.13648206476136693, 108.54952073824460967, + 81.737441640529141296, 38.798579599915683502, 61.150921091011696262, 99.410459216738672694, + 7.3409540077627752908, 125.83337157761707203, 99.285998260445921915, 78.82911516071180813, + 57.060680617571051698, 74.488124486666492885, 97.069039076141052647, 96.033414363831980154, + 77.30409048267028993, 4.1339999115880345926, 89.338711662076093489, 87.71539155419668532, + 13.326659187416225905, 74.432410080975387245, 5.7204222123000363354, 58.4545973477725056, + 91.056724705180386081, 48.382908916559244972, 11.080089285340363858, 123.93700974907915224, + 44.42574609250004869, 123.18137568215388455, 62.129840943518502172, 110.94224200125972857, + 85.105815237038768828, 59.200145133836485911, 26.170772830741043435, 78.237939570575690595, + 45.331006480457290309, 15.699581403867341578, 95.937006416592339519, 59.555366926480928669, + 26.614093221629445907, 71.733385374005592894, 48.611688736968062585, 12.553004305758804549, + 2.8304133229466970079, 11.879594140486005927, 74.462418714276282117, 85.167339727417129325, + 67.130722881131077884, 18.33455666354711866, 119.16063735092393472, 113.10692306531927898, + 120.35730611473991303, 13.199576979521225439, 118.92523880290536908, 51.573121535031532403, + 107.04772251756367041, 26.051822720881318673, 36.222395810782472836, 90.068526529415976256, + 67.687113952113577398, 54.437822803534800187, 50.499514741226448677, 121.89535728309419937, + 85.652764464950450929, 43.630201375584874768, 77.952717901825963054, 27.075097139335412066, + 82.5626652169485169, 25.413606637579505332, 100.256691920945741, 18.130043177661718801, + 57.949639553211454768, 85.122816671504551778, 33.459776866944594076, 101.98934807033583638, + 118.95839627224995638, 21.28469913206572528, 82.032279181337798946, 42.130909396775678033, + 92.442300073023943696, 3.9263861989566066768, 101.02951462121563964, 82.748677036750450497, + 39.6232013322187413, 54.881611934062675573, 28.16351610716083087, 121.17394072200841038, + 105.52055773511528969, 74.988498723629163578, 68.618109845167055028, 7.7411859118546999525, + 9.8355758834622974973, 125.93708057955518598, 27.177926654076145496, 124.74164304984151386, + 123.64446617223438807, 102.32193497722619213, 20.403142599043349037, 18.038883963952685008, + 28.777418153120379429, 31.549534075831616065, 45.246989287497854093, 113.12955651928132284, + 47.804353905074094655, 47.901723593015049119, 48.932785100078035612, 105.9518476785524399, + 6.8588088129399693571, 78.415742909313848941, 19.354877127196232323, 52.001815844869270222, + 62.623194403990055434, 1.7793505783520231489, 89.292872567770245951, 26.915843222235707799, + 110.30572635912903934, 4.9178809315417311154, 119.01339020356317633, 30.131959974569326732, + 22.229460462072893279, 67.43079927296275855, 19.455932710850902367, 119.31369856393212103, + 126.11686877560714493, 52.905716912526258966, 84.730179910464357818, 78.219045292524242541, + 100.0765550964497379, 6.6502061619030428119, 23.886466878011560766, 88.999095916500664316, + 5.5939931383036309853, 49.41896519901274587, 52.851489819393464131, 4.8580266907083569095, + 105.89841668850567658, 79.459226119302911684, 94.8095978791534435, 82.58043404664931586, + 95.691887698376376648, 10.751556925370095996, 109.68236942564544734, 16.302644435043475823, + 30.222993250557919964, 54.065600576515862485, 69.156647690451791277, 126.76566193094913615, + 49.023530324637249578, 78.457415348919312237, 111.00857049949991051, 12.881651337829680415, + 0.57287917199209914543, 109.09051855227880878, 107.81720481958473101, 41.95776320811273763, + 63.492979538335930556, 91.788864511927386047, 111.05060742741261492, 15.185490585176012246, + 115.36204766897571972, 15.883836804183374625, 9.1044709508678351995, 57.412141433142096503, + 70.08089620474493131, 120.34603358284584829, 49.453127926670276793, 67.08875952972448431, + 105.68759365188816446, 37.410878146452887449, 85.304650289417622844, 64.520017844253743533, + 42.614817371460958384, 31.060736355848348467, 107.61066230226788321, 96.425462580344174057, + 74.487094061325478833, 21.672953171058907174, 71.750103159913123818, 126.44067344371433137, + 106.11874969852942741, 40.99788827074735309, 122.86554778544814326, 25.188964092842070386, + 78.9397491694544442, 126.73315025440751924, 14.836496768410142977, 65.088245641731191427, + 77.347201513770414749, 66.860856618670368334, 1.2617243892636906821, 121.67944408069161, + 50.898943435418914305, 17.026231641644699266, 108.16987194296962116, 26.321389867112884531, + 88.865879200322524412, 89.797566683264449239, 42.821888911210407969, 3.2489575301005970687, + 42.220760708562011132, 103.0808883531644824, 117.85877856878505554, 93.998649361637944821, + 103.75449024381305207, 38.856343885188834975, 34.209091774919215823, 9.0393525542749557644, + 97.172937170671502827, 11.566946304377779597, 69.75066095339570893, 42.286262910794903291, + 124.74219969383193529, 93.850801387743558735, 78.014765921889193123, 89.580023037735372782, + 89.202745205533574335, 18.366799002331390511, 4.6332821945870819036, 125.66195801324647618, + 47.197195847762486665, 18.081760644196037902, 46.356151888227032032, 60.942331359936360968, + 127.28700724437294411, 77.770239066991052823, 123.38301991479238495, 119.92916326649719849, + 108.64220061582454946, 38.295680463939788751, 124.15464690811131732, 70.612220499198883772, + 83.000255634658969939, 16.588651439436944202, 42.569347015822131652, 38.710650678658566903, + 114.28294271757113165, 116.82253830558693153, 81.270740972868225072, 103.60077001134413877, + 63.337985703241429292, 125.72666516922981828, 98.380040441974415444, 3.1317218997064628638, + 50.282019930971728172, 122.55532537645922275, 23.01617703769079526, 21.416794437565840781, + 114.45703541433613282, 119.41227613859155099, 126.38231437337162788, 81.222309786058758618, + 44.799901251837582095, 45.360627247762749903, 33.25696867577789817, 2.2891194652984268032, + 15.197261812751094112, 99.830375957411888521, 120.09815927732051932, 57.988768376901134616, + 12.52364911166660022, 51.653111550513131078, 119.62054997298037051, 4.0844046362326480448, + 5.7860110795882064849, 34.131619460731599247, 96.105758664838504046, 124.50689224963571178, + 21.646037804748630151, 55.192275503650307655, 64.077320612461335259, 36.981864325134665705, + 45.729023017673171125, 77.073929237292759353, 78.75889045085204998, 81.822480505546991481, + 46.928452619900781428, 9.7199356293458549771, 54.364669922037137439, 1.9823000892356503755, + 2.7249006518322858028, 104.44595718958953512, 112.96168737050902564, 93.430498976831586333, + 77.217395225979998941, 82.571615995919273701, 119.47479866402863991, 59.161219841782440199, + 63.791902237353497185, 43.747121572891046526, 62.762109002371289534, 56.185203740675206063, + 63.337268531151494244, 119.2467860262368049, 87.493356749881058931, 85.981539907606929773, + 48.251498200432251906, 73.700338749938964611, 70.834998327707580756, 74.07210003971340484, + 53.13749853776243981, 21.049468321776657831, 72.23822302880580537, 45.732369512847071746, + 55.715354477339133155, 77.553785137366503477, 58.983735242607508553, 62.836514664191781776, + 79.810396016298909672, 37.743014824387500994, 49.869980776944430545, 67.313216923328582197, + 12.386704134212777717, 89.732310801475250628, 119.70324622936823289, 54.848904679787665373, + 26.683602531364158494, 32.542828948618989671, 37.97658053694976843, 109.02864428252723883, + 23.697771155006194022, 111.72649836307027726, 54.884757020125107374, 99.715452509044553153, + 112.50094732235083939, 63.941400581916241208, 32.803184872580459341, 21.458475520819774829, + 123.21445995280009811, 79.166862391532049514, 53.878993499107309617, 25.430567445506312652, + 78.440578031164477579, 31.678099885601113783, 19.569093138783500763, 45.139519745724101085, + 38.157314990781742381, 66.881846239324659109, 84.649625142144941492, 62.660006018726562615, + 95.429991018110740697, 53.147716072911862284, 116.84684029660638771, 4.4154198805263149552, + 113.43076473276232718, 126.30859411329583963, 80.13830872343169176, 77.160257165691291448, + 10.364002405131031992, 25.481479292688163696, 119.02902883020215086, 85.753195117740688147, + 32.505696469292161055, 0.31201416231851908378, 1.9701081973325926811, 106.04966675960895373, + 42.991618522770295385, 102.56713103465153836, 22.480451896240992937, 52.328447650506859645, + 68.983635118584061274, 53.684258455665258225, 83.263329418394278036, 122.73885404892280349, + 21.220703192240762291, 16.858127049134054687, 39.834029929148528026, 38.709037830667512026, + 8.8009650196217990015, 42.63326968194814981, 92.645732978544401703, 42.02349656079968554, + 76.272964129526371835, 89.099041476492857328, 35.474883281058282591, 77.597159199831367005, + 122.3018421820270305, 70.820918433477345388, 14.68190801552918856, 123.66674315523778205, + 70.571996520895481808, 29.65823032142361626, 114.12136123514574138, 20.976248973336623749, + 66.138078152285743272, 64.066828727667598287, 26.60818096534057986, 8.2679998231797071639, + 50.677423324155824957, 47.43078310839337064, 26.653318374836089788, 20.864820161950774491, + 11.440844424600072671, 116.90919469554864918, 54.113449410360772163, 96.765817833118489943, + 22.160178570684365695, 119.87401949815830449, 88.851492185003735358, 118.36275136430776911, + 124.25968188704064232, 93.884484002523095114, 42.211630474077537656, 118.40029026767297182, + 52.34154566148572485, 28.475879141151381191, 90.662012960914580617, 31.399162807738321135, + 63.874012833184679039, 119.11073385296185734, 53.228186443262529792, 15.466770748011185788, + 97.22337747393612517, 25.106008611517609097, 5.6608266458933940157, 23.759188280975649832, + 20.924837428556202212, 42.334679454837896628, 6.2614457622621557675, 36.669113327097875299, + 110.32127470185150742, 98.213846130642195931, 112.71461222947982606, 26.399153959046088858, + 109.85047760581073817, 103.14624307006670278, 86.095445035127340816, 52.103645441762637347, + 72.444791621568583651, 52.137053058835590491, 7.3742279042271547951, 108.87564560706960037, + 100.99902948245653533, 115.79071456619203673, 43.305528929900901858, 87.260402751173387514, + 27.905435803651926108, 54.150194278674462112, 37.125330433897033799, 50.827213275162648642, + 72.513383841891482007, 36.260086355323437601, 115.89927910642654751, 42.245633343009103555, + 66.919553733892826131, 75.978696140675310744, 109.91679254449991276, 42.569398264135088539, + 36.064558362675597891, 84.261818793554994045, 56.884600146047887392, 7.8527723979168513324, + 74.059029242434917251, 37.497354073500900995, 79.246402664437482599, 109.76322386812535115, + 56.327032214325299719, 114.34788144402045873, 83.041115470234217355, 21.976997447261965135, + 9.2362196903341100551, 15.482371823709399905, 19.671151766928232973, 123.87416115911037195, + 54.355853308155928971, 121.48328609968666569, 119.28893234447241412, 76.643869954452384263, + 40.806285198086698074, 36.077767927905370016, 57.554836306240758859, 63.099068151663232129, + 90.493978574999346165, 98.25911303856264567, 95.60870781014818931, 95.803447186030098237, + 97.865570200159709202, 83.903695357104879804, 13.717617625883576693, 28.831485818627697881, + 38.709754254392464645, 104.00363168973854044, 125.24638880798011087, 3.5587011567076842766, + 50.585745135540491901, 0, 92.611452718258078676, 9.8357618630871002097, + 110.02678040712635266, 60.263919949138653465, 44.458920924149424536, 6.8615985459255171008, + 38.911865421705442714, 110.62739712786788004, 124.23373755121428985, 105.81143382505615591, + 41.460359820932353614, 28.43809058505212306, 72.153110192899475805, 13.300412323806085624, + 47.772933756026759511, 49.998191833001328632, 11.187986276607261971, 98.837930398025491741, + 105.70297963878692826, 9.7160533814203517977, 83.796833377014991129, 30.918452238609461347, + 61.61919575831052498, 37.160868093302269699, 63.383775396752753295, 21.503113850743829971, + 91.364738851290894672, 32.605288870086951647, 60.445986501115839928, 108.13120115303536295, + 10.313295380907220533, 125.5313238618982723, 98.047060649278137134, 28.914830697842262452, + 94.017140998999821022, 25.76330267565936083, 1.1457583439878362697, 90.181037104561255546, + 87.634409639169462025, 83.915526416225475259, 126.98595907667549909, 55.577729023858410073, + 94.10121485482522985, 30.370981170355662471, 102.72409533795143943, 31.767673608366749249, + 18.208941901735670399, 114.82428286628783098, 12.1617924094935006, 112.69206716569169657, + 98.906255853344191564, 6.1775190594526065979, 83.375187303776328918, 74.821756292909412878, + 42.609300578838883666, 1.0400356885074870661, 85.229634742921916768, 62.121472711700334912, + 87.22132460453940439, 64.850925160691986093, 20.974188122650957666, 43.345906342121452326, + 15.500206319829885615, 124.88134688743230072, 84.237499397058854811, 81.995776541498344159, + 117.73109557089628652, 50.37792818568777875, 29.879498338912526378, 125.46630050881503848, + 29.672993536823923932, 2.1764912834660208318, 26.694403027544467477, 5.7217132373407366686, + 2.5234487785310193431, 115.35888816138321999, 101.79788687083782861, 34.052463283293036511, + 88.339743885939242318, 52.64277973422940704, 49.731758400648686802, 51.595133366528898478, + 85.643777822420815937, 6.4979150602011941373, 84.441521417127660243, 78.161776706332602771, + 107.71755713757374906, 59.997298723279527621, 79.50898048762610415, 77.712687770377669949, + 68.418183549838431645, 18.078705108553549508, 66.345874341343005653, 23.133892608759197174, + 11.501321906791417859, 84.572525821593444562, 121.48439938766750856, 59.701602775490755448, + 28.029531843782024225, 51.160046075474383542, 50.405490411067148671, 36.733598004662781022, + 9.266564389177801786, 123.32391602649295237, 94.394391695524973329, 36.163521288392075803, + 92.712303776454064064, 121.88466271987635992, 126.57401448874952621, 27.540478133985743625, + 118.76603982958840788, 111.85832653299803496, 89.284401231649098918, 76.591360927883215481, + 120.30929381622627261, 13.224440998401405523, 38.000511269317939878, 33.177302878873888403, + 85.138694031644263305, 77.421301357320771785, 100.56588543514590128, 105.64507661117750104, + 34.541481945740088122, 79.201540022688277531, 126.67597140648649656, 123.45333033846327453, + 68.760080883948830888, 6.2634437994129257277, 100.56403986194709432, 117.11065075291844551, + 46.032354075381590519, 42.83358887513531954, 100.91407082867590361, 110.82455227718673996, + 124.76462874674689374, 34.444619572117517237, 89.599802503675164189, 90.721254495525499806, + 66.51393735155579634, 4.5782389305968536064, 30.394523625505826203, 71.660751914827415021, + 112.19631855464103865, 115.97753675380226923, 25.04729822333320044, 103.30622310102990014, + 111.24109994596074102, 8.1688092724652960896, 11.57202215917641297, 68.263238921466836473, + 64.211517329680646071, 121.01378449927142356, 43.292075609497260302, 110.38455100730425329, + 0.15464122492267051712, 73.963728650269331411, 91.45804603534998023, 26.147858474589156685, + 29.517780901707737939, 35.644961011093982961, 93.856905239801562857, 19.439871258691709954, + 108.72933984407427488, 3.964600178471300751, 5.4498013036682095844, 80.891914379182708217, + 97.92337474102168926, 58.860997953666810645, 26.43479045196363586, 37.14323199184218538, + 110.94959732805727981, 118.3224396835648804, 127.58380447470699437, 87.494243145782093052, + 125.52421800474257907, 112.37040748135041213, 126.67453706230662647, 110.49357205247724778, + 46.986713499765755842, 43.963079815213859547, 96.502996400868141791, 19.400677499881567201, + 13.669996655418799492, 20.14420007942680968, 106.27499707552487962, 42.098936643556953641, + 16.47644605761161074, 91.464739025694143493, 111.43070895468190429, 27.107570274733006954, + 117.96747048521501711, 125.67302932838720153, 31.620792032597819343, 75.486029648775001988, + 99.739961553892499069, 6.6264338466571643949, 24.773408268429193413, 51.464621602954139234, + 111.40649245873646578, 109.69780935957533075, 53.367205062728316989, 65.085657897237979341, + 75.953161073903174838, 90.057288565054477658, 47.395542310016026022, 95.452996726140554529, + 109.76951404025385273, 71.430905018092744285, 97.001894644701678772, 127.88280116383248242, + 65.606369745160918683, 42.916951041643187637, 118.4289199056038342, 30.333724783064099029, + 107.75798699821461923, 50.861134891016263282, 28.881156062328955159, 63.356199771202227566, + 39.138186277567001525, 90.27903949144820217, 76.314629981567122741, 5.763692478652956197, + 41.299250284289882984, 125.32001203745676321, 62.859982036221481394, 106.29543214582736255, + 105.69368059321277542, 8.8308397610562678892, 98.861529465528292349, 124.61718822659531725, + 32.276617446867021499, 26.320514331382582895, 20.728004810262063984, 50.962958585379965371, + 110.05805766040793969, 43.506390235481376294, 65.01139293858432211, 0.62402832463703816757, + 3.9402163946688233409, 84.099333519217907451, 85.983237045544228749, 77.134262069303076714, + 44.960903792481985874, 104.65689530101735727, 9.9672702371681225486, 107.36851691133415443, + 38.526658836792194052, 117.47770809784560697, 42.441406384481524583, 33.716254098268109374, + 79.668059858297056053, 77.418075661335024051, 17.601930039243598003, 85.266539363899937598, + 57.291465957088803407, 84.046993121603009058, 24.545928259056381648, 50.198082952985714655, + 70.949766562120203162, 27.194318399666371988, 116.60368436405769899, 13.641836866954690777, + 29.363816031062015099, 119.33348631047920207, 13.143993041790963616, 59.316460642850870499, + 100.24272247029148275, 41.952497946676885476, 4.2761563045751245227, 0.13365745533519657329, + 53.21636193068115972, 16.535999646359414328, 101.35484664831164991, 94.861566216786741279, + 53.306636749672179576, 41.729640323901548982, 22.88168884920378332, 105.81838939109729836, + 108.2268988207251823, 65.531635666236979887, 44.320357141372369369, 111.74803899632024695, + 49.702984370011108695, 108.7255027286191762, 120.51936377408492262, 59.768968005046190228, + 84.42326094815871329, 108.80058053534594364, 104.6830913229714497, 56.951758282306400361, + 53.324025921829161234, 62.79832561547664227, 127.74802566637299606, 110.22146770592371468, + 106.45637288652505958, 30.933541496026009554, 66.446754947872250341, 50.212017223035218194, + 11.321653291786788031, 47.518376561951299664, 41.849674857112404425, 84.669358909675793257, + 12.522891524524311535, 73.338226654199388577, 92.642549403706652811, 68.42769226128802984, + 97.429224458959652111, 52.798307918095815694, 91.700955211625114316, 78.292486140137043549, + 44.190890070254681632, 104.20729088352891267, 16.889583243137167301, 104.27410611767118098, + 14.748455808457947569, 89.751291214142838726, 73.998058964916708646, 103.58142913238407345, + 86.611057859805441694, 46.520805502346775029, 55.810871607303852215, 108.30038855734892422, + 74.250660867794067599, 101.65442655032893526, 17.026767683782964014, 72.520172710650513181, + 103.79855821285309503, 84.491266686021845089, 5.83910746778929024, 23.957392281354259467, + 91.83358508899982553, 85.138796528270177078, 72.129116725354833761, 40.52363758710998809, + 113.76920029209577478, 15.705544795837340644, 20.118058484869834501, 74.994708147005439969, + 30.492805328878603177, 91.526447736250702292, 112.65406442865423742, 100.69576288804455544, + 38.08223094046843471, 43.95399489452393027, 18.47243938066822011, 30.96474364741879981, + 39.342303533860103926, 119.74832231822074391, 108.71170661631549592, 114.96657219937696937, + 110.57786468894846621, 25.287739908904768527, 81.612570396173396148, 72.155535855810740031, + 115.10967261248151772, 126.19813630333010224, 52.987957150002330309, 68.518226077128929319, + 63.217415620300016599, 63.606894372063834453, 67.731140400323056383, 39.807390714209759608, + 27.435235251767153386, 57.662971637255395763, 77.419508508788567269, 80.007263379480718868, + 122.49277761596022174, 7.1174023134153685533, 101.1714902710809838, 0, + 57.222905436516157351, 19.671523726177838398, 92.053560814252705313, 120.52783989827730693, + 88.917841848298849072, 13.723197091851034202, 77.823730843414523406, 93.254794255739398068, + 120.46747510243221768, 83.622867650112311821, 82.920719641864707228, 56.8761811701078841, + 16.306220385798951611, 26.600824647612171248, 95.545867512053519022, 99.996383666002657264, + 22.37597255321816192, 69.67586079605462146, 83.405959277573856525, 19.432106762844341574, + 39.593666754029982258, 61.836904477218922693, 123.23839151662104996, 74.321736186604539398, + 126.76755079350550659, 43.006227701491297921, 54.729477702581789345, 65.210577740173903294, + 120.89197300223531784, 88.262402306070725899, 20.626590761818079045, 123.06264772380018258, + 68.094121298556274269, 57.829661395688162884, 60.034281997999642044, 51.526605351318721659, + 2.2915166879793105181, 52.362074209126149071, 47.268819278342562029, 39.831052832454588497, + 125.97191815335099818, 111.15545804772045813, 60.202429709650459699, 60.74196234071496292, + 77.448190675902878866, 63.535347216733498499, 36.417883803474978777, 101.64856573257566197, + 24.323584818990639178, 97.384134331387031125, 69.812511706688383128, 12.355038118908851175, + 38.750374607556295814, 21.643512585818825755, 85.218601157677767333, 2.080071377018612111, + 42.459269485843833536, 124.2429454234043078, 46.44264920908244676, 1.7018503213839721866, + 41.948376245301915333, 86.691812684242904652, 31.000412639663409209, 121.76269377486823942, + 40.474998794121347601, 35.991553083000326296, 107.46219114179257303, 100.7558563713755575, + 59.758996677828690736, 122.93260101763007697, 59.345987073647847865, 4.3529825669320416637, + 53.388806055088934954, 11.443426474681473337, 5.0468975570656766649, 102.71777632277007797, + 75.59577374167565722, 68.104926566589711001, 48.679487771878484637, 105.28555946845881408, + 99.463516801297373604, 103.19026673306143493, 43.287555644841631874, 12.995830120406026253, + 40.883042834258958464, 28.323553412668843521, 87.43511427514749812, 119.99459744656269322, + 31.017960975255846279, 27.425375540758977877, 8.8363670996768632904, 36.157410217110736994, + 4.6917486826860113069, 46.267785217518394347, 23.002643813586473698, 41.145051643190527102, + 114.96879877533501713, 119.4032055509815109, 56.05906368756404845, 102.32009215094876708, + 100.81098082213429734, 73.467196009325562045, 18.533128778359241551, 118.64783205298954272, + 60.788783391049946658, 72.327042576787789585, 57.424607552911766106, 115.76932543975635781, + 125.14802897749905242, 55.080956267975125229, 109.53207965918045375, 95.716653065999707906, + 50.568802463301835814, 25.182721855770068942, 112.61858763245254522, 26.448881996802811045, + 76.001022538635879755, 66.354605757751414785, 42.277388063292164588, 26.84260271464518155, + 73.131770870295440545, 83.290153222355002072, 69.082963891483814223, 30.403080045380193042, + 125.3519428129766311, 118.90666067693018704, 9.5201617678976617754, 12.526887598829489434, + 73.128079723897826625, 106.22130150583689101, 92.064708150763181038, 85.667177750274277059, + 73.828141657355445204, 93.649104554377117893, 121.52925749349378748, 68.889239144238672452, + 51.199605007353966357, 53.44250899105463759, 5.0278747031115926802, 9.1564778611937072128, + 60.789047251015290385, 15.321503829658468021, 96.392637109285715269, 103.95507350760453846, + 50.094596446670038858, 78.61244620206343825, 94.482199891921482049, 16.337618544930592179, + 23.144044318356463918, 8.5264778429373109248, 0.42303465936493012123, 114.02756899854284711, + 86.584151218998158583, 92.769102014608506579, 0.30928244984897901304, 19.9274573005423008, + 54.916092070699960459, 52.295716949178313371, 59.035561803415475879, 71.289922022191603901, + 59.713810479603125714, 38.879742517387057887, 89.458679688148549758, 7.9292003569426015019, + 10.899602607340057148, 33.783828758369054412, 67.846749482043378521, 117.72199590733362129, + 52.86958090392727172, 74.286463983688008739, 93.899194656118197599, 108.64487936713339877, + 127.16760894941762672, 46.988486291567824082, 123.04843600948879612, 96.740814962704462232, + 125.34907412461689091, 92.98714410495449556, 93.973426999531511683, 87.926159630431357073, + 65.005992801736283582, 38.801354999763134401, 27.339993310837598983, 40.288400158857257338, + 84.549994151049759239, 84.197873287113907281, 32.95289211522685946, 54.929478051391924964, + 94.861417909363808576, 54.215140549469651887, 107.93494097043367219, 123.34605865677440306, + 63.241584065199276665, 22.972059297553641954, 71.479923107784998138, 13.25286769331432879, + 49.546816536858386826, 102.92924320591191645, 94.812984917476569535, 91.395618719150661491, + 106.73441012546027196, 2.1713157944795966614, 23.906322147809987655, 52.114577130108955316, + 94.791084620035690023, 62.905993452284747036, 91.539028080511343433, 14.861810036189126549, + 66.003789289406995522, 127.76560232766860281, 3.2127394903218373656, 85.833902083290013252, + 108.85783981120766839, 60.667449566131836036, 87.515973996429238468, 101.72226978203252656, + 57.762312124657910317, 126.71239954240445513, 78.276372555137641029, 52.55807898290004232, + 24.629259963134245481, 11.527384957305912394, 82.598500568583403947, 122.64002407491352642, + 125.71996407244660077, 84.590864291658363072, 83.387361186425550841, 17.661679522116173757, + 69.723058931060222676, 121.23437645319063449, 64.553234893734042998, 52.641028662765165791, + 41.456009620524127968, 101.92591717076356872, 92.116115320815879386, 87.012780470966390567, + 2.0227858771686442196, 1.2480566492740763351, 7.8804327893412846606, 40.198667038439452881, + 43.966474091092095478, 26.268524138606153429, 89.921807584967609728, 81.313790602034714539, + 19.934540474339883076, 86.737033822668308858, 77.053317673588026082, 106.95541619569121394, + 84.882812768963049166, 67.432508196539856726, 31.336119716597750084, 26.836151322670048103, + 35.203860078490833985, 42.533078727799875196, 114.58293191418124479, 40.093986243206018116, + 49.091856518112763297, 100.39616590597506729, 13.899533124240406323, 54.388636799336381955, + 105.20736872811539797, 27.283673733909381554, 58.727632062127668178, 110.66697262095840415, + 26.287986083581927232, 118.63292128570537898, 72.485444940582965501, 83.904995893353770953, + 8.5523126091502490453, 0.26731491067039314657, 106.43272386136231944, 33.071999292722466635, + 74.709693296626937808, 61.723132433573482558, 106.61327349934435915, 83.459280647803097963, + 45.763377698411204619, 83.636778782198234694, 88.453797641454002587, 3.0632713324739597738, + 88.640714282748376718, 95.496077992640493903, 99.405968740025855368, 89.451005457241990371, + 113.03872754816984525, 119.53793601009601844, 40.84652189632106456, 89.601161070695525268, + 81.366182645942899399, 113.90351656461280072, 106.64805184365832247, 125.59665123095692252, + 127.49605133274963009, 92.442935411851067329, 84.912745773050119169, 61.867082992055657087, + 4.8935098957445006818, 100.42403444607043639, 22.643306583573576063, 95.036753123902599327, + 83.699349714228446828, 41.338717819351586513, 25.045783049052261049, 18.676453308402415132, + 57.2850988074169436, 8.8553845225796976592, 66.858448917919304222, 105.59661583619526937, + 55.401910423253866611, 28.584972280274087097, 88.381780140513001243, 80.414581767057825346, + 33.779166486277972581, 80.548212235342361964, 29.496911616919533117, 51.50258242828931543, + 19.996117929837055271, 79.162858264771784889, 45.222115719610883389, 93.041611004693550058, + 111.62174321461134241, 88.600777114701486425, 20.501321735591773177, 75.308853100657870527, + 34.053535367569566006, 17.040345421304664342, 79.597116425709828036, 40.982533372043690179, + 11.67821493557858048, 47.914784562712156912, 55.667170178003289038, 42.277593056543992134, + 16.258233450709667522, 81.047275174223614158, 99.538400584191549569, 31.411089591674681287, + 40.236116969743306981, 21.989416294010879938, 60.985610657760844333, 55.052895472505042562, + 97.308128857312112814, 73.391525776089110877, 76.16446188093686942, 87.90798978904786054, + 36.94487876133644022, 61.92948729483759962, 78.68460706772384583, 111.4966446364451258, + 89.423413232634629821, 101.93314439875757671, 93.155729377896932419, 50.575479817813175032, + 35.225140792350430274, 16.311071711625118041, 102.21934522496667341, 124.39627260666020447, + 105.9759143000082986, 9.0364521542578586377, 126.4348312406000332, 127.21378874413130688, + 7.4622808006461127661, 79.614781428419519216, 54.870470503534306772, 115.3259432745144295, + 26.839017017580772517, 32.014526758965075715, 116.98555523192044348, 14.234804626834375085, + 74.342980542165605584, 0, 114.4458108730323147, 39.343047452359314775, + 56.107121628509048605, 113.05567979655825184, 49.835683696597698145, 27.446394183705706382, + 27.647461686832684791, 58.509588511482434114, 112.93495020486807334, 39.245735300228261622, + 37.841439283729414456, 113.7523623402157682, 32.612440771597903222, 53.201649295227980474, + 63.091735024110676022, 71.992767332005314529, 44.751945106439961819, 11.351721592112880899, + 38.81191855514771305, 38.864213525688683148, 79.187333508059964515, 123.67380895444148337, + 118.4767830332457379, 20.643472373212716775, 125.53510158701101318, 86.012455402982595842, + 109.45895540516721667, 2.4211554803514445666, 113.78394600447427365, 48.524804612141451798, + 41.253181523639796069, 118.12529544760400313, 8.1882425971125485376, 115.65932279137632577, + 120.06856399599928409, 103.05321070263744332, 4.5830333759586210363, 104.72414841825229814, + 94.537638556685124058, 79.662105664912814973, 123.94383630670563434, 94.310916095440916251, + 120.4048594193009194, 121.48392468143356382, 26.896381351805757731, 127.070694433466997, + 72.835767606953595532, 75.297131465151323937, 48.647169637984916335, 66.768268662777700229, + 11.625023413376766257, 24.710076237817702349, 77.500749215112591628, 43.287025171641289489, + 42.437202315355534665, 4.160142754037224222, 84.918538971691305051, 120.48589084680861561, + 92.885298418164893519, 3.4037006427679443732, 83.896752490607468644, 45.383625368485809304, + 62.000825279330456397, 115.52538754973647883, 80.949997588242695201, 71.983106166004290571, + 86.924382283588784048, 73.511712742751115002, 119.51799335566101945, 117.86520203526015393, + 118.69197414729569573, 8.7059651338640833274, 106.77761211017786991, 22.886852949362946674, + 10.093795114134991309, 77.435552645543793915, 23.191547483354952419, 8.2098531331794220023, + 97.358975543760607252, 82.57111893692126614, 70.927033602598385187, 78.380533466122869868, + 86.575111289683263749, 25.991660240812052507, 81.766085668517916929, 56.64710682534132502, + 46.870228550298634218, 111.98919489312538644, 62.035921950511692557, 54.850751081517955754, + 17.672734199353726581, 72.314820434221473988, 9.3834973653720226139, 92.535570435036788695, + 46.005287627172947396, 82.290103286384692183, 101.93759755067367223, 110.80641110196302179, + 112.11812737513173488, 76.640184301901172148, 73.621961644272232661, 18.93439201865112409, + 37.06625755672212108, 109.29566410597908543, 121.5775667821035313, 16.65408515357557917, + 114.84921510582717019, 103.5386508795163536, 122.29605795499810483, 110.16191253595388844, + 91.06415931836454547, 63.433306131999415811, 101.13760492660367163, 50.365443711543775862, + 97.237175264905090444, 52.897763993609260069, 24.002045077275397489, 4.7092115155028295703, + 84.554776126584329177, 53.685205429294001078, 18.263541740594519069, 38.580306444713642122, + 10.165927782967628445, 60.806160090764024062, 122.70388562595690018, 109.81332135386037407, + 19.040323535795323551, 25.053775197662616847, 18.256159447799291229, 84.44260301167742, + 56.129416301530000055, 43.334355500552192098, 19.656283314714528387, 59.298209108757873764, + 115.05851498699121294, 9.7784782884773449041, 102.39921001470793271, 106.88501798210927518, + 10.05574940622318536, 18.312955722387414426, 121.57809450203058077, 30.643007659320574021, + 64.785274218575068517, 79.910147015209076926, 100.1891928933437157, 29.224892404130514478, + 60.964399783842964098, 32.675237089861184359, 46.288088636712927837, 17.05295568587462185, + 0.84606931873349822126, 100.0551379970893322, 45.168302437999955146, 57.538204029217013158, + 0.61856489969795802608, 39.8549146010846016, 109.83218414139992092, 104.59143389835662674, + 118.07112360683458974, 14.579844044383207802, 119.42762095920625143, 77.759485034777753754, + 50.917359376297099516, 15.858400713885203004, 21.799205214680114295, 67.567657516741746804, + 7.6934989640903950203, 107.44399181466724258, 105.73916180785818142, 20.572927967379655456, + 59.798389312240033178, 89.289758734270435525, 126.33521789883525344, 93.976972583139286144, + 118.09687201898123021, 65.481629925412562443, 122.6981482492374198, 57.9742882099126291, + 59.946853999066661345, 47.852319260866352124, 2.0119856034725671634, 77.602709999526268803, + 54.679986621675197966, 80.576800317718152655, 41.099988302103156457, 40.395746574227814563, + 65.905784230453718919, 109.85895610278748791, 61.722835818727617152, 108.43028109894294175, + 87.869881940870982362, 118.69211731354880612, 126.48316813039855333, 45.944118595110921888, + 14.959846215569996275, 26.505735386628657579, 99.09363307372041163, 77.858486411827470874, + 61.625969834956777049, 54.791237438304960961, 85.468820250920543913, 4.3426315889591933228, + 47.81264429561997531, 104.22915426022154861, 61.582169240071380045, 125.81198690457313205, + 55.078056161022686865, 29.723620072381891077, 4.0075785788176290225, 127.53120465533720562, + 6.4254789806473127101, 43.667804166583664482, 89.71567962241533678, 121.33489913226731005, + 47.031947992862114916, 75.444539564065053128, 115.52462424931945861, 125.42479908481254824, + 28.552745110275282059, 105.11615796580008464, 49.258519926268490963, 23.054769914615462767, + 37.197001137170445872, 117.28004814983069082, 123.43992814489683951, 41.181728583320364123, + 38.774722372851101682, 35.323359044235985493, 11.446117862124083331, 114.46875290638490696, + 1.1064697874680859968, 105.28205732553033158, 82.912019241051893914, 75.851834341530775419, + 56.232230641635396751, 46.025560941932781134, 4.0455717543372884393, 2.4961132985481526703, + 15.760865578682569321, 80.397334076878905762, 87.932948182184190955, 52.537048277215944836, + 51.843615169938857434, 34.627581204069429077, 39.869080948683404131, 45.474067645340255694, + 26.106635347179690143, 85.910832391386065865, 41.765625537929736311, 6.8650163930797134526, + 62.672239433195500169, 53.672302645340096205, 70.407720156981667969, 85.066157455603388371, + 101.16586382836248958, 80.187972486412036233, 98.183713036229164572, 72.792331811950134579, + 27.799066248480812646, 108.77727359867640189, 82.414737456230795942, 54.567347467818763107, + 117.45526412425897433, 93.3339452419168083, 52.575972167167492444, 109.26584257141439593, + 16.97088988116956898, 39.809991786707541905, 17.104625218300498091, 0.53462982134442427196, + 84.865447722724638879, 66.143998585448571248, 21.419386593253875617, 123.4462648671506031, + 85.226546998692356283, 38.918561295606195927, 91.526755396826047217, 39.273557564400107367, + 48.907595282908005174, 6.1265426649515575264, 49.281428565500391414, 62.992155985284625785, + 70.811937480055348715, 50.90201091448761872, 98.077455096343328478, 111.07587202019203687, + 81.693043792645767098, 51.202322141394688515, 34.732365291889436776, 99.807033129229239421, + 85.296103687320282916, 123.19330246191748301, 126.99210266550289816, 56.885870823705772636, + 41.825491546100238338, 123.73416598411131417, 9.7870197914926393423, 72.848068892140872777, + 45.286613167150790105, 62.073506247808836633, 39.398699428456893656, 82.677435638703173026, + 50.091566098104522098, 37.352906616804830264, 114.5701976148338872, 17.710769045163033297, + 5.7168978358422464225, 83.193231672390538733, 110.80382084650773322, 57.169944560551812174, + 48.763560281029640464, 32.829163534115650691, 67.558332972559583141, 33.096424470684723929, + 58.993823233839066233, 103.00516485657863086, 39.992235859677748522, 30.325716529543569777, + 90.444231439225404756, 58.083222009390738094, 95.243486429226322798, 49.201554229402972851, + 41.002643471187184332, 22.617706201315741055, 68.107070735139132012, 34.080690842612966662, + 31.194232851419656072, 81.965066744087380357, 23.35642987115716096, 95.829569125424313825, + 111.33434035600657808, 84.555186113087984268, 32.516466901422973024, 34.094550348450866295, + 71.076801168383099139, 62.822179183349362575, 80.472233939486613963, 43.978832588021759875, + 121.97122131552168867, 110.1057909450137231, 66.616257714627863606, 18.783051552181859734, + 24.328923761877376819, 47.815979578095721081, 73.889757522672880441, 123.85897458967883722, + 29.369214135451329639, 94.993289272893889574, 50.846826465272897622, 75.866288797518791398, + 58.311458755793864839, 101.15095963562635006, 70.450281584700860549, 32.622143423253874062, + 76.438690449936984805, 120.79254521332404693, 83.951828600016597193, 18.072904308519355254, + 124.86966248120370437, 126.42757748826261377, 14.924561601295863511, 31.229562856839038432, + 109.74094100707225152, 102.65188654902885901, 53.678034035161545034, 64.029053517933789408, + 105.97111046384088695, 28.469609253672388149, 20.685961084334849147, 0, + 100.89162174606462941, 78.68609490471862955, 112.21424325702173519, 98.111359593116503675, + 99.671367393195396289, 54.892788367411412764, 55.294923373665369581, 117.01917702296850621, + 97.869900409736146685, 78.491470600456523243, 75.68287856746246689, 99.504724680431536399, + 65.224881543195806444, 106.40329859045596095, 126.18347004822499002, 15.985534664010629058, + 89.503890212879923638, 22.703443184225761797, 77.6238371102954261, 77.728427051381004276, + 30.374667016123567009, 119.34761790888660471, 108.95356606649147579, 41.286944746429071529, + 123.07020317402566434, 44.024910805968829663, 90.917910810334433336, 4.8423109607065271121, + 99.5678920089485473, 97.049609224282903597, 82.506363047283230117, 108.25059089520800626, + 16.376485194228735054, 103.31864558275628951, 112.13712799200220616, 78.106421405274886638, + 9.1660667519208800513, 81.448296836508234264, 61.075277113373886095, 31.324211329829267925, + 119.88767261341490666, 60.621832190885470482, 112.80971883860547678, 114.96784936286712764, + 53.792762703615153441, 126.14138886693763197, 17.671535213910829043, 22.594262930302647874, + 97.294339275973470649, 5.5365373255554004572, 23.250046826753532514, 49.420152475639042677, + 27.001498430225183256, 86.574050343282578979, 84.874404630711069331, 8.3202855080780864228, + 41.83707794338624808, 112.97178169362086919, 57.770596836329787038, 6.8074012855395267252, + 39.793504981214937288, 90.767250736971618608, 124.00165055866455077, 103.05077509947659564, + 33.899995176489028381, 15.966212332012219122, 45.848764567181206075, 19.023425485505867982, + 111.03598671132567688, 107.73040407052394585, 109.38394829459139146, 17.411930267731804634, + 85.555224220355739817, 45.773705898725893348, 20.187590228273620596, 26.87110529108758783, + 46.383094966709904838, 16.419706266362481983, 66.717951087524852483, 37.14223787384617026, + 13.854067205200408353, 28.761066932249377714, 45.150222579366527498, 51.983320481627742993, + 35.532171337035833858, 113.29421365068265004, 93.740457100600906415, 95.978389786250772886, + 124.07184390102338511, 109.70150216303591151, 35.34546839871109114, 16.629640868442947976, + 18.766994730747683207, 57.071140870073577389, 92.01057525434953277, 36.580206572773022344, + 75.875195101350982441, 93.612822203929681564, 96.236254750267107738, 25.280368603805982275, + 19.243923288544465322, 37.86878403730224818, 74.13251511344788014, 90.591328211961808847, + 115.15513356420706259, 33.308170307154796319, 101.69843021165797836, 79.077301759036345175, + 116.59211590999984764, 92.323825071911414852, 54.12831863672909094, 126.8666122640024696, + 74.275209853207343258, 100.7308874230911897, 66.474350529810180888, 105.79552798721852014, + 48.004090154550794978, 9.4184230310092971195, 41.109552253168658353, 107.37041085858800216, + 36.527083481189038139, 77.160612889427284244, 20.331855565935256891, 121.6123201815316861, + 117.40777125191743835, 91.626642707720748149, 38.080647071590647101, 50.107550395325233694, + 36.512318895602220437, 40.885206023354839999, 112.25883260306000011, 86.668711001104384195, + 39.312566629429056775, 118.59641821751938551, 102.11702997398242587, 19.556956576958327787, + 76.798420029419503408, 85.770035964218550362, 20.111498812446370721, 36.62591144477846683, + 115.15618900406116154, 61.286015318644786021, 1.5705484371537750121, 31.820294030421791831, + 72.378385786687431391, 58.449784808261028957, 121.9287995676859282, 65.350474179722368717, + 92.576177273425855674, 34.105911371749243699, 1.6921386374706344213, 72.110275994178664405, + 90.336604875999910291, 115.07640805843402632, 1.2371297993959160522, 79.709829202172841178, + 91.664368282803479815, 81.182867796716891462, 108.14224721366917947, 29.159688088770053582, + 110.85524191841614083, 27.518970069555507507, 101.83471875259419903, 31.716801427770406008, + 43.598410429363866569, 7.1353150334834936075, 15.386997928184428019, 86.887983629338123137, + 83.478323615716362838, 41.145855934759310912, 119.59677862448370433, 50.579517468544509029, + 124.67043579767414485, 59.953945166282210266, 108.1937440379660984, 2.9632598508287628647, + 117.39629649847483961, 115.9485764198252582, 119.89370799813332269, 95.704638521732704248, + 4.0239712069487723056, 27.205419999052537605, 109.35997324335403391, 33.153600635436305311, + 82.199976604206312913, 80.791493148459267104, 3.8115684609110758174, 91.717912205574975815, + 123.44567163745887228, 88.860562197889521485, 47.739763881745602703, 109.38423462710125023, + 124.96633626079710666, 91.888237190221843775, 29.91969243113999255, 53.011470773260953138, + 70.18726614744446124, 27.716972823654941749, 123.2519396699135541, 109.5824748766135599, + 42.937640501841087826, 8.6852631779183866456, 95.625288591243588598, 80.458308520443097223, + 123.16433848014639807, 123.6239738091462641, 110.15611232204537373, 59.447240144763782155, + 8.0151571576388960239, 127.06240931067441124, 12.85095796129462542, 87.335608333170966944, + 51.431359244834311539, 114.6697982645346201, 94.06389598572786781, 22.889079128133744234, + 103.04924849864255521, 122.84959816962509649, 57.105490220554202097, 82.232315931600169279, + 98.517039852536981925, 46.109539829230925534, 74.394002274344529724, 106.56009629966501961, + 118.87985628979367903, 82.363457166640728246, 77.549444745702203363, 70.646718088471970987, + 22.892235724251804641, 100.93750581276981393, 2.2129395749398099724, 82.564114651064301142, + 37.824038482107425807, 23.703668683061550837, 112.4644612832707935, 92.051121883865562268, + 8.0911435086745768785, 4.9922265970963053405, 31.521731157368776621, 32.794668153761449503, + 47.86589636436838191, 105.07409655443188967, 103.68723033987771487, 69.255162408138858154, + 79.738161897366808262, 90.948135290680511389, 52.213270694363018265, 43.82166478277213173, + 83.531251075859472621, 13.730032786159426905, 125.34447886639100034, 107.34460529068383039, + 12.815440313966973918, 42.132314911210414721, 74.331727656728617148, 32.375944972827710444, + 68.367426072461967124, 17.584663623900269158, 55.598132496965263272, 89.554547197356441757, + 36.829474912461591884, 109.13469493564116419, 106.91052824852158665, 58.667890483833616599, + 105.15194433433862287, 90.531685142828791868, 33.94177976233913796, 79.619983573415083811, + 34.209250436600996181, 1.0692596426924865227, 41.730895445452915737, 4.287997170897142496, + 42.838773186511389213, 118.89252973430484417, 42.453093997384712566, 77.837122591216029832, + 55.053510793652094435, 78.547115128800214734, 97.815190565816010348, 12.253085329903115053, + 98.562857131000782829, 125.98431197057288955, 13.62387496011069743, 101.80402182897887542, + 68.154910192690294934, 94.151744040387711721, 35.386087585291534197, 102.40464428278937703, + 69.46473058378251153, 71.614066258462116821, 42.59220737464420381, 118.38660492383860401, + 125.98420533100579632, 113.77174164741154527, 83.650983092204114655, 119.46833196822262835, + 19.574039582988916663, 17.696137784281745553, 90.573226334301580209, 124.14701249561767327, + 78.797398856917425292, 37.354871277406346053, 100.1831321962090442, 74.705813233613298507, + 101.1403952296677744, 35.421538090326066595, 11.433795671688130824, 38.386463344784715446, + 93.607641693015466444, 114.33988912110362435, 97.527120562059280928, 65.658327068234939361, + 7.1166659451191662811, 66.192848941369447857, 117.98764646768177045, 78.010329713157261722, + 79.984471719355497044, 60.651433059090777533, 52.888462878450809512, 116.16644401878511417, + 62.486972858452645596, 98.403108458805945702, 82.005286942374368664, 45.235412402635120088, + 8.2141414702782640234, 68.161381685225933325, 62.388465702842950122, 35.930133488174760714, + 46.712859742317959899, 63.659138250852265628, 94.668680712016794132, 41.110372226175968535, + 65.032933802845946047, 68.189100696905370569, 14.153602336766198277, 125.64435836670236313, + 32.944467878973227926, 87.957665176047157729, 115.94244263104701531, 92.211581890031084185, + 5.2325154292557272129, 37.566103104363719467, 48.657847523754753638, 95.631959156195080141, + 19.779515045349398861, 119.71794917935767444, 58.738428270906297257, 61.986578545787779149, + 101.69365293054943322, 23.732577595037582796, 116.62291751159136766, 74.301919271256338106, + 12.900563169401721098, 65.244286846511386102, 24.87738089987760759, 113.58509042665173183, + 39.903657200033194385, 36.145808617042348487, 121.73932496241104673, 124.85515497652522754, + 29.849123202591727022, 62.459125713681714842, 91.481882014148141025, 77.303773098057718016, + 107.35606807032672805, 0.058107035871216794476, 83.942220927681773901, 56.939218507344776299, + 41.371922168669698294, 0, 73.78324349213289679, 29.372189809440897079, + 96.428486514047108358, 68.222719186236645328, 71.342734786390792578, 109.78557673482282553, + 110.58984674733437714, 106.03835404594065039, 67.739800819475931348, 28.982941200916684465, + 23.365757134928571759, 71.009449360866710776, 2.4497630863952508662, 84.806597180915559875, + 124.36694009644998005, 31.971069328024896095, 51.007780425759847276, 45.406886368455161573, + 27.24767422059449018, 27.456854102762008552, 60.749334032250771997, 110.6952358177768474, + 89.907132132982951589, 82.573889492861781036, 118.14040634805132868, 88.049821611941297306, + 53.835821620668866672, 9.6846219214166922029, 71.135784017900732579, 66.099218448569445172, + 37.012726094570098212, 88.501181790416012518, 32.752970388461108087, 78.637291165516217006, + 96.274255984008050291, 28.212842810549773276, 18.332133503845398081, 34.896593673016468529, + 122.15055422674777219, 62.648422659662173828, 111.77534522682981333, 121.24366438177457894, + 97.619437677214591531, 101.93569872573425528, 107.58552540723394486, 124.28277773387526395, + 35.343070427821658086, 45.188525860608933726, 66.588678551946941298, 11.073074651110800914, + 46.500093653507065028, 98.840304951278085355, 54.002996860454004491, 45.148100686568795936, + 41.748809261422138661, 16.640571016156172846, 83.674155886776134139, 97.943563387241738383, + 115.54119367265957408, 13.61480257107905345, 79.587009962433512555, 53.534501473946875194, + 120.00330111733273952, 78.101550198953191284, 67.799990352978056762, 31.932424664024438243, + 91.697529134362412151, 38.046850971015373943, 94.071973422654991737, 87.460808141051529674, + 90.767896589182782918, 34.823860535467247246, 43.110448440711479634, 91.547411797451786697, + 40.375180456547241192, 53.742210582175175659, 92.766189933419809677, 32.839412532728601946, + 5.4359021750497049652, 74.284475747692340519, 27.708134410400816705, 57.522133864498755429, + 90.300445158733054996, 103.96664096325548599, 71.064342674075305695, 98.58842730136893806, + 59.480914201205450809, 63.956779572505183751, 120.14368780205040821, 91.403004326071823016, + 70.690936797422182281, 33.259281736885895953, 37.533989461495366413, 114.14228174015079276, + 56.02115050869906554, 73.160413145549682667, 23.75039020270560286, 59.225644407863001106, + 64.472509500534215476, 50.56073720761196455, 38.487846577088930644, 75.737568074608134339, + 20.265030226899398258, 53.182656423927255673, 102.31026712841412518, 66.616340614313230617, + 75.396860423319594702, 30.154603518076328328, 105.18423182000333327, 56.647650143822829705, + 108.25663727346181986, 125.73322452800857718, 20.550419706418324495, 73.461774846186017385, + 4.948701059623999754, 83.591055974437040277, 96.008180309101589955, 18.836846062018594239, + 82.219104506340954686, 86.740821717176004313, 73.054166962381714256, 26.321225778854568489, + 40.663711131874151761, 115.22464036306701018, 106.81554250383851468, 55.253285415441496298, + 76.161294143181294203, 100.21510079065046739, 73.024637791204440873, 81.770412046713317977, + 96.5176652061236382, 45.33742200220876839, 78.625133258861751528, 109.19283643504240899, + 76.234059947964851744, 39.113913153920293553, 25.596840058842644794, 43.540071928437100723, + 40.222997624892741442, 73.251822889560571639, 102.31237800812232308, 122.57203063728957204, + 3.1410968743075500242, 63.640588060847221641, 16.756771573374862783, 116.89956961652569589, + 115.85759913537549437, 2.7009483594483754132, 57.152354546851711348, 68.211822743498487398, + 3.3842772749449068215, 16.220551988360966789, 52.673209752003458561, 102.15281611686805263, + 2.4742595987954700831, 31.419658404349320335, 55.328736565610597609, 34.365735593437420903, + 88.284494427338358946, 58.319376177543745143, 93.710483836832281668, 55.037940139114652993, + 75.669437505188398063, 63.433602855540812016, 87.196820858727733139, 14.270630066966987215, + 30.773995856372494018, 45.775967258679884253, 38.956647231432725675, 82.291711869522259803, + 111.19355724896740867, 101.15903493709265604, 121.3408715953482897, 119.90789033256805851, + 88.387488075932196807, 5.9265197016611637082, 106.7925929969533172, 103.89715283965415438, + 111.78741599627028336, 63.409277043465408497, 8.0479424138975446112, 54.410839998108713189, + 90.719946486708067823, 66.3072012708762486, 36.399953208416263806, 33.582986296918534208, + 7.6231369218257896136, 55.435824411153589608, 118.89134327492138254, 49.72112439577904297, + 95.479527763494843384, 90.76846925420613843, 121.9326725215978513, 55.776474380443687551, + 59.8393848622799851, 106.02294154652554425, 12.374532294888922479, 55.433945647313521476, + 118.50387933983074618, 91.1649497532271198, 85.875281003682175651, 17.37052635584041127, + 63.250577182490815176, 32.916617040889832424, 118.32867696029643412, 119.24794761829616618, + 92.312224644090747461, 118.89448028952756431, 16.030314315281430027, 126.12481862134882249, + 25.701915922592888819, 46.671216666341933887, 102.86271848967226106, 101.33959652907287818, + 60.12779197145573562, 45.778158256271126447, 78.098496997288748389, 117.69919633925019298, + 114.21098044111204217, 36.464631863203976536, 69.034079705073963851, 92.219079658465489047, + 20.788004548692697426, 85.120192599333677208, 109.75971257959099603, 36.726914333285094472, + 27.098889491408044705, 13.293436176943941973, 45.78447144850724726, 73.875011625539627858, + 4.4258791498832579236, 37.128229302128602285, 75.648076964214851614, 47.407337366126739653, + 96.928922566545224981, 56.102243767731124535, 16.182287017349153757, 9.9844531941926106811, + 63.043462314737553243, 65.589336307522899006, 95.731792728740401799, 82.148193108867417322, + 79.374460679759067716, 10.510324816281354288, 31.476323794737254502, 53.896270581361022778, + 104.42654138872603653, 87.643329565547901439, 39.062502151718945242, 27.460065572322491789, + 122.68895773278563865, 86.68921058136766078, 25.630880627933947835, 84.26462982242446742, + 20.663455313457234297, 64.751889945659058867, 8.7348521449239342473, 35.169327247800538316, + 111.19626499393416452, 51.109094394712883513, 73.658949824926821748, 90.269389871285966365, + 85.821056497043173295, 117.33578096767087118, 82.303888668680883711, 53.063370285657583736, + 67.883559524681913899, 31.239967146830167621, 68.418500873201992363, 2.1385192853849730454, + 83.461790890905831475, 8.5759943417942849919, 85.677546373026416404, 109.78505946860968834, + 84.90618799477306311, 27.674245182432059664, 110.10702158730782685, 29.094230257604067447, + 67.630381131632020697, 24.506170659809868084, 69.125714262005203636, 123.9686239411457791, + 27.247749920225032838, 75.608043657961388817, 8.3098203853842278477, 60.303488080775423441, + 70.772175170586706372, 76.809288565582392039, 10.92946116756866104, 15.228132516924233641, + 85.184414749292045599, 108.773209847680846, 123.96841066201523063, 99.543483294826728525, + 39.301966184411867289, 110.9366639364452567, 39.148079165977833327, 35.392275568567129085, + 53.146452668606798397, 120.29402499123898451, 29.594797713834850583, 74.709742554816330085, + 72.36626439242172637, 21.411626467230234994, 74.280790459335548803, 70.843076180652133189, + 22.867591343376261648, 76.77292668957306887, 59.215283386034570867, 100.67977824221088667, + 67.054241124122199835, 3.316654136469878722, 14.233331890241970541, 4.3856978827425336931, + 107.97529293536717887, 28.020659426318161422, 31.968943438710994087, 121.30286611818155507, + 105.776925756905257, 104.33288803757022833, 124.97394571690892917, 68.806216917615529383, + 36.010573884748737328, 90.470824805270240176, 16.428282940560166026, 8.3227633704518666491, + 124.77693140568590024, 71.860266976349521428, 93.425719484635919798, 127.31827650170816923, + 61.337361424033588264, 82.220744452355575049, 2.0658676056955300737, 8.3782013938107411377, + 28.307204673536034534, 123.28871673340472626, 65.88893575795009383, 47.915330352097953437, + 103.8848852620976686, 56.423163780062168371, 10.465030858511454426, 75.132206208727438934, + 97.315695047513145255, 63.263918312390160281, 39.5590300907024357, 111.43589835871534888, + 117.47685654181259451, 123.97315709157919628, 75.387305861098866444, 47.465155190078803571, + 105.24583502318637329, 20.603838542512676213, 25.801126338807080174, 2.4885736930227722041, + 49.754761799758853158, 99.170180853303463664, 79.807314400066388771, 72.291617234088334953, + 115.47864992482573143, 121.71030995305045508, 59.698246405183454044, 124.91825142736706766, + 54.963764028299920028, 26.607546196119074011, 86.712136140653456096, 0.11621407174607156776, + 39.884441855363547802, 113.8784370146895526, 82.743844337343034567, 0, + 19.566486984265793581, 58.744379618885432137, 64.856973028097854694, 8.4454383724769286346, + 14.685469572785223136, 91.571153469649289036, 93.179693494672392262, 84.076708091884938767, + 7.4796016389518626966, 57.965882401833368931, 46.731514269860781496, 14.018898721733421553, + 4.8995261727941397112, 41.613194361834757729, 120.73388019289996009, 63.942138656049792189, + 102.01556085151969455, 90.813772736910323147, 54.49534844118898036, 54.913708205524017103, + 121.49866806450518197, 93.390471635557332775, 51.814264265969541157, 37.147778985727200052, + 108.28081269610629533, 48.099643223882594611, 107.67164324133773334, 19.369243842837022385, + 14.271568035805103136, 4.1984368971388903446, 74.025452189143834403, 49.002363580832025036, + 65.505940776925854152, 29.274582331036071992, 64.548511968016100582, 56.425685621099546552, + 36.664267007690796163, 69.793187346036575036, 116.30110845349554438, 125.29684531932798564, + 95.550690453663264634, 114.48732876355279586, 67.238875354432821041, 75.871397451472148532, + 87.171050814471527701, 120.5655554677505279, 70.686140855643316172, 90.377051721221505431, + 5.177357103893882595, 22.146149302221601829, 93.000187307017768035, 69.680609902556170709, + 108.00599372090800898, 90.296201373137591872, 83.497618522844277322, 33.28114203231598367, + 39.348311773555906257, 67.887126774487114744, 103.08238734531914815, 27.22960514216174488, + 31.174019924867025111, 107.06900294789738837, 112.00660223466911702, 28.203100397910020547, + 7.5999807059561135247, 63.864849328052514466, 55.395058268724824302, 76.093701942034385866, + 60.143946845313621452, 46.921616282106697327, 53.535793178365565836, 69.647721070934494492, + 86.220896881426597247, 55.094823594903573394, 80.750360913094482385, 107.4844211643539893, + 57.532379866839619353, 65.678825065457203891, 10.871804350103047909, 20.568951495384681039, + 55.41626882080163341, 115.04426772900114884, 52.60089031746974797, 79.93328192651460995, + 14.128685348154249368, 69.176854602737876121, 118.96182840241090162, 127.91355914501400548, + 112.2873756041044544, 54.80600865214728401, 13.381873594844364561, 66.518563473771791905, + 75.067978922994370805, 100.28456348030158551, 112.04230101740176906, 18.320826291099365335, + 47.50078040541120572, 118.45128881572964019, 0.94501900106843095273, 101.1214744152239291, + 76.975693154181499267, 23.475136149216268677, 40.530060453798796516, 106.36531284785814933, + 76.620534256831888342, 5.2326812286300992128, 22.793720846639189404, 60.309207036156294635, + 82.368463640006666537, 113.29530028764929739, 88.513274546927277697, 123.46644905601715436, + 41.100839412840286968, 18.92354969237203477, 9.8974021192516374867, 39.182111948877718532, + 64.016360618203179911, 37.673692124040826457, 36.43820901268554735, 45.481643434355646605, + 18.108333924763428513, 52.642451557709136978, 81.3274222637519415, 102.44928072613765835, + 85.631085007677029353, 110.50657083088663057, 24.322588286366226384, 72.430201581304572755, + 18.049275582412519725, 35.540824093430273933, 65.035330412247276399, 90.674844004421174759, + 29.250266517727141036, 90.385672870088455966, 24.468119895929703489, 78.227826307840587106, + 51.193680117685289588, 87.080143856874201447, 80.445995249789120862, 18.503645779124781257, + 76.624756016248284141, 117.14406127457914408, 6.2821937486151000485, 127.28117612169444328, + 33.513543146753363544, 105.79913923305502976, 103.71519827075098874, 5.4018967188967508264, + 114.30470909370706067, 8.4236454869969747961, 6.7685545498898136429, 32.441103976721933577, + 105.3464195040105551, 76.305632233736105263, 4.9485191975909401663, 62.839316808698640671, + 110.65747313122119522, 68.731471186878479784, 48.568988854676717892, 116.63875235509112827, + 59.420967673664563335, 110.07588027823294397, 23.338875010376796126, 126.86720571108526201, + 46.393641717455466278, 28.54126013393397443, 61.547991712744988035, 91.551934517359768506, + 77.91329446286908933, 36.583423739048157586, 94.387114497938455315, 74.318069874188950052, + 114.68174319070021738, 111.815780665139755, 48.774976151864393614, 11.853039403325965395, + 85.585185993910272373, 79.794305679311946733, 95.574831992540566716, 126.81855408693081699, + 16.095884827795089222, 108.82167999622106436, 53.439892973419773625, 4.6144025417524971999, + 72.799906416832527611, 67.165972593837068416, 15.246273843651579227, 110.8716488223108172, + 109.78268654984276509, 99.44224879156172392, 62.959055526993324747, 53.536938508415914839, + 115.8653450431957026, 111.5529487608873751, 119.67876972456360818, 84.045883093051088508, + 24.749064589777844958, 110.86789129463068093, 109.00775867966513033, 54.329899506457877578, + 43.750562007364351302, 34.74105271168082254, 126.50115436498163035, 65.833234081783302827, + 108.65735392059650621, 110.49589523659597035, 56.6244492881851329, 109.78896057905512862, + 32.060628630566498032, 124.24963724269764498, 51.403831845185777638, 93.342433332687505754, + 77.725436979348160094, 74.679193058145756368, 120.25558394291147124, 91.556316512545890873, + 28.196993994581134757, 107.39839267850402393, 100.42196088222408434, 72.929263726411591051, + 10.06815941015156568, 56.438159316930978093, 41.576009097389032831, 42.240385198670992395, + 91.519425159181992058, 73.453828666570188943, 54.19777898281608941, 26.586872353887883946, + 91.568942897018132498, 19.750023251079255715, 8.8517582997665158473, 74.256458604260842549, + 23.296153928429703228, 94.814674732257117284, 65.857845133090449963, 112.20448753546224907, + 32.364574034698307514, 19.968906388385221362, 126.08692462947874446, 3.1786726150494359899, + 63.463585457484441577, 36.296386217738472624, 30.748921359518135432, 21.020649632562708575, + 62.952647589474509005, 107.79254116272568353, 80.853082777455711039, 47.286659131095802877, + 78.125004303437890485, 54.920131144648621557, 117.37791546557491529, 45.378421162735321559, + 51.261761255871533649, 40.52925964484893484, 41.326910626918106573, 1.503779891318117734, + 17.469704289847868495, 70.338654495604714612, 94.392529987868329044, 102.21818878942940501, + 19.317899649857281474, 52.538779742575570708, 43.642112994089984568, 106.67156193534538033, + 36.607777337361767422, 106.12674057131880545, 7.7671190493638277985, 62.479934293663973222, + 8.8370017464039847255, 4.2770385707735840697, 38.92358178181166295, 17.151988683592207963, + 43.355092746056470787, 91.570118937223014655, 41.81237598954612622, 55.348490364867757307, + 92.214043174615653697, 58.188460515211772872, 7.260762263264041394, 49.012341319623374147, + 10.251428524014045252, 119.9372478822915582, 54.495499840453703655, 23.216087315922777634, + 16.619640770768455695, 120.60697616155448486, 13.544350341177050723, 25.618577131164784078, + 21.858922335137322079, 30.456265033852105262, 42.368829498587729177, 89.546419695365329972, + 119.93682132403409923, 71.086966589653457049, 78.603932368827372557, 93.87332787289051339, + 78.296158331955666654, 70.78455113713425817, 106.29290533721723477, 112.58804998247796902, + 59.189595427673339145, 21.419485109636298148, 16.73252878484345274, 42.823252934464107966, + 20.561580918674735585, 13.686152361304266378, 45.735182686756161274, 25.54585337914613774, + 118.43056677207277971, 73.359556484425411327, 6.1084822482443996705, 6.633308272939757444, + 28.466663780483941082, 8.771395765488705365, 87.950585870734357741, 56.041318852636322845, + 63.937886877425626153, 114.60573223636674811, 83.553851513814151986, 80.665776075144094648, + 121.94789143382149632, 9.6124338352310587652, 72.021147769501112634, 52.941649610540480353, + 32.856565881120332051, 16.645526740907371277, 121.55386281137543847, 15.720533952702680836, + 58.851438969275477575, 126.63655300341633847, 122.67472284807081451, 36.441488904711150099, + 4.1317352113910601474, 16.756402787621482275, 56.614409347075707046, 118.57743346681309049, + 3.77787151590018766, 95.830660704199544853, 79.769770524195337202, 112.84632756012433674, + 20.93006171702654683, 22.264412417458515847, 66.63139009502629051, 126.52783662478032056, + 79.118060181408509379, 94.871796717434335733, 106.95371308362882701, 119.94631418316203053, + 22.774611722197732888, 94.930310380161245121, 82.491670046372746583, 41.207677085025352426, + 51.602252677614160348, 4.9771473860455444083, 99.509523599521344295, 70.340361706610565307, + 31.614628800136415521, 16.583234468180307886, 102.95729984965510084, 115.42061990610091016, + 119.39649281037054607, 121.83650285473413533, 109.92752805659984006, 53.215092392241786001, + 45.424272281306912191, 0.23242814349214313552, 79.768883710730733583, 99.756874029382743174, + 37.487688674686069135, 0, 39.132973968531587161, 117.48875923777450225, + 1.7139460561957093887, 16.890876744953857269, 29.37093914557408425, 55.142306939302216051, + 58.359386989348422503, 40.153416183769877534, 14.959203277903725393, 115.93176480366673786, + 93.463028539721562993, 28.037797443466843106, 9.7990523455882794224, 83.226388723673153436, + 113.46776038579992019, 127.88427731210322236, 76.031121703043027082, 53.627545473820646293, + 108.99069688237796072, 109.82741641105167218, 114.99733612901400193, 58.780943271114665549, + 103.62852853193908231, 74.295557971458038082, 88.561625392212590668, 96.199286447768827202, + 87.343286482675466686, 38.738487685674044769, 28.543136071610206272, 8.3968737942814186681, + 20.050904378287668806, 98.004727161667688051, 3.0118815538517083041, 58.549164662075781962, + 1.0970239360322011635, 112.8513712421990931, 73.328534015385230305, 11.586374692076788051, + 104.60221690699472674, 122.59369063865960925, 63.101380907330167247, 100.9746575271092297, + 6.4777507088692800608, 23.742794902947935043, 46.342101628946693381, 113.13111093550469377, + 13.372281711290270323, 52.754103442443010863, 10.35471420778776519, 44.292298604446841637, + 58.000374614039174048, 11.361219805115979398, 88.011987441819655942, 52.592402746278821724, + 38.995237045688554645, 66.56228406463196734, 78.696623547115450492, 7.7742535489778674673, + 78.164774690638296306, 54.459210284323489759, 62.348039849737688201, 86.138005895798414713, + 96.013204469338234048, 56.406200795820041094, 15.199961411912227049, 127.72969865610502893, + 110.79011653745328658, 24.187403884068771731, 120.2878936906272429, 93.843232564213394653, + 107.07158635673476965, 11.295442141872626962, 44.441793762853194494, 110.18964718981078477, + 33.500721826192602748, 86.968842328707978595, 115.06475973368287669, 3.3576501309144077823, + 21.743608700206095818, 41.137902990769362077, 110.8325376416069048, 102.08853545800229767, + 105.20178063494313392, 31.866563853029219899, 28.257370696312136715, 10.353709205479390221, + 109.92365680482544121, 127.82711829003164894, 96.574751208208908793, 109.61201730429456802, + 26.763747189692367101, 5.0371269475472217891, 22.135957845992379589, 72.569126960606809007, + 96.084602034803538118, 36.64165258219873067, 95.001560810826049419, 108.90257763145928038, + 1.8900380021404998843, 74.242948830451496178, 25.951386308362998534, 46.950272298432537355, + 81.060120907601231011, 84.73062569571993663, 25.241068513663776685, 10.465362457260198426, + 45.587441693278378807, 120.61841407231622725, 36.736927280016971054, 98.590600575302232755, + 49.026549093858193373, 118.93289811203430872, 82.201678825680573937, 37.847099384744069539, + 19.794804238503274973, 78.364223897759075044, 0.032721236406359821558, 75.347384248081652913, + 72.8764180253710947, 90.963286868711293209, 36.216667849526857026, 105.28490311542191193, + 34.654844527507520979, 76.898561452278954675, 43.262170015357696684, 93.013141661773261148, + 48.645176572736090748, 16.860403162609145511, 36.09855116482503945, 71.081648186864185845, + 2.0706608244981907774, 53.349688008842349518, 58.50053303545792005, 52.771345740176911931, + 48.936239791863044957, 28.455652615681174211, 102.38736023537421715, 46.160287713752040872, + 32.891990499578241725, 37.007291558253200492, 25.24951203250020626, 106.28812254915828817, + 12.564387497233838076, 126.56235224338888656, 67.027086293510365067, 83.598278466113697505, + 79.430396541501977481, 10.803793437797139632, 100.60941818741412135, 16.847290973993949592, + 13.537109099779627286, 64.882207953447505133, 82.692839008024748182, 24.611264467472210526, + 9.8970383951818803325, 125.67863361740091932, 93.314946262446028413, 9.4629423737569595687, + 97.137977709357073763, 105.27750471018225653, 118.84193534733276465, 92.15176055646588793, + 46.677750020757230232, 125.73441142217052402, 92.787283434910932556, 57.08252026786794886, + 123.09598342549361405, 55.103869034723174991, 27.826588925738178659, 73.16684747809995315, + 60.774228995880548609, 20.636139748381538084, 101.36348638140407274, 95.631561330279510003, + 97.549952303728787228, 23.706078806655568769, 43.170371987824182725, 31.588611358627531445, + 63.149663985084771411, 125.63710817386163399, 32.191769655593816424, 89.643359992442128714, + 106.87978594683954725, 9.2288050835086323787, 17.599812833668693202, 6.3319451876741368324, + 30.492547687306796433, 93.743297644625272369, 91.565373099689168157, 70.884497583123447839, + 125.91811105398664949, 107.07387701683546766, 103.73069008639504318, 95.105897521778388182, + 111.35753944913085434, 40.091766186102177016, 49.498129179559327895, 93.735782589264999842, + 90.01551735933026066, 108.65979901291575516, 87.501124014728702605, 69.482105423365283059, + 125.00230872996689868, 3.6664681635702436324, 89.314707841196650406, 92.991790473191940691, + 113.24889857637390378, 91.577921158110257238, 64.121257261136634042, 120.49927448539528996, + 102.80766369037519326, 58.684866665378649486, 27.450873958699958166, 21.358386116295150714, + 112.51116788582658046, 55.112633025091781747, 56.393987989165907493, 86.796785357011685846, + 72.843921764451806666, 17.858527452823182102, 20.136318820303131361, 112.87631863386195619, + 83.152018194778065663, 84.480770397345622769, 55.038850318367622094, 18.907657333140377887, + 108.39555796563217882, 53.173744707779405871, 55.137885794036264997, 39.50004650215851143, + 17.703516599536669673, 20.512917208521685097, 46.592307856863044435, 61.629349464517872548, + 3.7156902661845379043, 96.408975070924498141, 64.729148069396615028, 39.937812776774080703, + 124.17384925895748893, 6.3573452300988719799, 126.92717091496888315, 72.592772435476945248, + 61.497842719036270864, 42.041299265125417151, 125.90529517895265599, 87.585082325455005048, + 33.706165554911422078, 94.573318262195243733, 28.25000860687578097, 109.84026228930088109, + 106.75583093114983058, 90.756842325470643118, 102.5235225117430673, 81.058519289697869681, + 82.653821253836213145, 3.0075597826362354681, 34.939408579699374968, 12.677308991213067202, + 60.785059975740296068, 76.436377578858810011, 38.635799299714562949, 105.07755948515114142, + 87.284225988183607114, 85.343123870690760668, 73.215554674727172824, 84.253481142637610901, + 15.534238098727655597, 124.95986858732794644, 17.674003492807969451, 8.5540771415471681394, + 77.847163563623325899, 34.303977367184415925, 86.710185492116579553, 55.140237874446029309, + 83.624751979092252441, 110.69698072973915259, 56.428086349231307395, 116.37692103042354574, + 14.521524526528082788, 98.024682639246748295, 20.502857048031728482, 111.8744957645831164, + 108.99099968090740731, 46.432174631845555268, 33.23928154154054937, 113.21395232310896972, + 27.088700682354101446, 51.237154262329568155, 43.717844670274644159, 60.912530067704210524, + 84.737658997179096332, 51.092839390734297922, 111.87364264807183645, 14.173933179310552077, + 29.207864737658383092, 59.746655745784664759, 28.592316663914971286, 13.569102274272154318, + 84.585810674438107526, 97.176099964955938049, 118.37919085534667829, 42.838970219272596296, + 33.465057569686905481, 85.646505868928215932, 41.12316183734947117, 27.372304722608532757, + 91.470365373512322549, 51.09170675829591346, 108.86113354414919741, 18.719112968850822654, + 12.216964496488799341, 13.266616545879514888, 56.933327560967882164, 17.542791530981048709, + 47.901171741468715481, 112.08263770527264569, 127.87577375485489029, 101.2114644727371342, + 39.10770302763194195, 33.331552150291827274, 115.89578286764299264, 19.224867670465755509, + 16.042295539002225269, 105.88329922108096071, 65.713131762240664102, 33.291053481818380533, + 115.10772562275087694, 31.441067905405361671, 117.70287793855459313, 125.27310600683631492, + 117.34944569614162901, 72.882977809422300197, 8.2634704227821202949, 33.512805575242964551, + 113.22881869415505207, 109.15486693362618098, 7.5557430318040132988, 63.661321408402727684, + 31.539541048394312384, 97.692655120248673484, 41.860123434053093661, 44.528824834920669673, + 5.2627801900562189985, 125.0556732495642791, 30.236120362820656737, 61.743593434872309444, + 85.907426167261291994, 111.89262836632406106, 45.549223444399103755, 61.86062076032612822, + 36.983340092745493166, 82.415354170050704852, 103.2045053552283207, 9.9542947720947267953, + 71.019047199046326568, 12.680723413221130613, 63.229257600272831041, 33.16646893636425375, + 77.914599699313839665, 102.84123981220545829, 110.79298562074473011, 115.67300570947190863, + 91.855056113199680112, 106.430184784483572, 90.848544562613824382, 0.46485628698792424984, + 31.537767421465105144, 71.513748058765486348, 74.975377349375776248, 0, + 78.265947937066812301, 106.97751847554900451, 3.4278921123914187774, 33.781753489907714538, + 58.741878291148168501, 110.2846138786044321, 116.71877397869684501, 80.306832367539755069, + 29.918406555811088765, 103.8635296073371137, 58.926057079443125986, 56.075594886933686212, + 19.598104691180196824, 38.45277744734994485, 98.935520771603478352, 127.76855462421008269, + 24.062243406086054165, 107.25509094764493057, 89.981393764759559417, 91.654832822106982348, + 101.99467225802800385, 117.56188654223296908, 79.257057063881802605, 20.591115942919714143, + 49.123250784428819316, 64.398572895541292382, 46.686572965350933373, 77.476975371348089539, + 57.086272143220412545, 16.793747588562837336, 40.10180875657897559, 68.009454323335376102, + 6.0237631077034166083, 117.09832932415156392, 2.1940478720680403057, 97.702742484401824186, + 18.657068030770460609, 23.172749384157214081, 81.204433813993091462, 117.1873812773192185, + 126.20276181466397247, 73.949315054218459409, 12.955501417738560122, 47.485589805895870086, + 92.684203257897024741, 98.262221871009387542, 26.744563422580540646, 105.50820688488602173, + 20.70942841557553038, 88.584597208893683273, 116.0007492280783481, 22.722439610235596774, + 48.023974883639311884, 105.18480549255764345, 77.990474091380747268, 5.1245681292675726581, + 29.393247094230900984, 15.548507097959372913, 28.329549381276592612, 108.91842056864697952, + 124.69607969947901438, 44.276011791600467404, 64.026408938676468097, 112.81240159164008219, + 30.399922823828092078, 127.45939731221369584, 93.580233074906573165, 48.374807768141181441, + 112.57578738125812379, 59.686465128430427285, 86.143172713469539303, 22.590884283745253924, + 88.883587525710026966, 92.379294379621569533, 67.001443652388843475, 45.937684657419595169, + 102.12951946736575337, 6.7153002618288155645, 43.487217400412191637, 82.275805981542362133, + 93.665075283217447577, 76.177070916008233326, 82.403561269886267837, 63.733127706058439799, + 56.514741392624273431, 20.70741841096241842, 91.847313609654520405, 127.65423658006693586, + 65.149502416421455564, 91.224034608589136042, 53.527494379384734202, 10.074253895094443578, + 44.271915691988397157, 17.138253921217255993, 64.169204069607076235, 73.283305164401099319, + 62.003121621655736817, 89.805155262918560766, 3.7800760042846377473, 20.485897660902992357, + 51.902772616725997068, 93.900544596868712688, 34.1202418152061, 41.46125139143987326, + 50.482137027327553369, 20.930724914520396851, 91.174883386560395593, 113.2368281446324545, + 73.473854560037580086, 69.181201150604465511, 98.053098187720024725, 109.86579622407225543, + 36.403357651361147873, 75.694198769488139078, 39.589608477010187926, 28.728447795518150087, + 0.065442472816357621923, 22.694768496166943805, 17.752836050745827379, 53.926573737422586419, + 72.433335699057352031, 82.569806230843823869, 69.309689055018679937, 25.797122904557909351, + 86.524340030719031347, 58.026283323546522297, 97.290353145472181495, 33.720806325218291022, + 72.197102329653716879, 14.163296373728371691, 4.1413216489963815548, 106.69937601768469904, + 117.0010660709158401, 105.54269148035382386, 97.872479583726089913, 56.911305231365986401, + 76.774720470748434309, 92.320575427504081745, 65.783980999156483449, 74.014583116506400984, + 50.499024065004050499, 84.576245098316576332, 25.12877499447131413, 125.12470448678141111, + 6.0541725870243681129, 39.196556932231032988, 30.860793083003954962, 21.607586875597917242, + 73.218836374828242697, 33.694581947987899184, 27.074218199562892551, 1.7644159068986482453, + 37.385678016049496364, 49.222528934944421053, 19.794076790367398644, 123.35726723480547662, + 58.629892524892056827, 18.925884747517557116, 66.275955418717785506, 82.555009420368151041, + 109.68387069466916728, 56.30352111293177586, 93.355500041518098442, 123.46882284434468602, + 57.574566869821865112, 114.1650405357395357, 118.1919668509872281, 110.20773806944634998, + 55.653177851479995297, 18.333694956199906301, 121.54845799176109722, 41.272279496766714146, + 74.726972762811783468, 63.263122660562657984, 67.099904607457574457, 47.412157613311137538, + 86.340743975648365449, 63.177222717255062889, 126.2993279701731808, 123.27421634772326797, + 64.383539311191270826, 51.286719984887895407, 85.759571893679094501, 18.457610167017264757, + 35.199625667337386403, 12.663890375348273665, 60.985095374617230846, 59.486595289254182717, + 55.130746199381974293, 13.768995166250533657, 123.83622210797693697, 86.147754033674573293, + 79.461380172793724341, 62.211795043560414342, 94.715078898261708673, 80.183532372204354033, + 98.996258359122293768, 59.471565178533637663, 52.0310347186641593, 89.319598025835148292, + 47.002248029461043188, 10.964210846734204097, 122.00461745993379736, 7.3329363271441252436, + 50.629415682396938791, 57.983580946387519361, 98.497797152751445537, 55.155842316224152455, + 0.24251452227690606378, 112.99854897079421789, 77.61532738075038651, 117.36973333075729897, + 54.901747917399916332, 42.716772232593939407, 97.022335771653160919, 110.22526605018356349, + 112.78797597833545296, 45.593570714027009672, 17.687843528903613333, 35.717054905646364205, + 40.2726376406099007, 97.752637267727550352, 38.304036389559769304, 40.961540794691245537, + 110.07770063673524419, 37.815314666284393752, 88.791115931264357641, 106.34748941555881174, + 110.27577158807252999, 79.00009300431702286, 35.407033199073339347, 41.025834417043370195, + 93.18461571372608887, 123.2586989290357451, 7.4313805323727137875, 64.81795014185263426, + 1.4582961387932300568, 79.875625553551799385, 120.34769851791497786, 12.714690460201381939, + 125.85434182994140428, 17.185544870953890495, 122.99568543807254173, 84.08259853025447228, + 123.81059035790894995, 47.170164650910010096, 67.412331109826482134, 61.146636524390487466, + 56.500017213755199919, 91.680524578605400166, 85.511661862303299131, 53.513684650944924215, + 77.047045023489772575, 34.11703857939937734, 37.307642507672426291, 6.0151195652724709362, + 69.878817159398749936, 25.354617982426134404, 121.57011995148423011, 24.872755157717620023, + 77.271598599432763876, 82.155118970305920811, 46.568451976370852208, 42.686247741385159316, + 18.431109349457983626, 40.506962285275221802, 31.068476197458949173, 121.91973717465589289, + 35.348006985615938902, 17.108154283097974258, 27.694327127246651798, 68.607954734372469829, + 45.420370984233159106, 110.2804757488956966, 39.24950395818814286, 93.393961459478305187, + 112.85617269846625277, 104.75384206084709149, 29.043049053059803555, 68.049365278493496589, + 41.005714096067094943, 95.748991529169870773, 89.98199936181481462, 92.864349263691110536, + 66.478563083084736718, 98.427904646217939444, 54.177401364708202891, 102.47430852465913631, + 87.435689340549288318, 121.82506013541205903, 41.475317994358192664, 102.18567878147223382, + 95.747285296143672895, 28.347866358621104155, 58.415729475316766184, 119.49331149156932952, + 57.184633327829942573, 27.138204548547946615, 41.171621348879853031, 66.352199929915514076, + 108.75838171069335658, 85.677940438545192592, 66.930115139377448941, 43.293011737856431864, + 82.246323674698942341, 54.744609445220703492, 54.940730747024645098, 102.1834135165954649, + 89.72226708829839481, 37.438225937701645307, 24.433928992977598682, 26.533233091759029776, + 113.86665512193576433, 35.085583061962097418, 95.802343482941068942, 96.165275410548929358, + 127.75154750971341855, 74.422928945474268403, 78.2154060552638839, 66.663104300587292528, + 103.79156573528598528, 38.449735340931511018, 32.084591078008088516, 83.766598442165559391, + 3.4262635244813282043, 66.582106963640399044, 102.21545124550175387, 62.882135810814361321, + 107.40575587711282424, 122.54621201367626782, 106.69889139228689601, 17.765955618844600394, + 16.52694084556424059, 67.025611150489567081, 98.457637388313742122, 90.309733867252361961, + 15.111486063608026598, 127.32264281680545537, 63.079082096792262746, 67.385310240497346967, + 83.720246868106187321, 89.057649669841339346, 10.525560380116075976, 122.11134649912855821, + 60.472240725641313475, 123.48718686974825687, 43.814852334526221966, 95.785256732648122124, + 91.09844688879820751, 123.72124152065225644, 73.966680185494624311, 36.830708340105047682, + 78.409010710456641391, 19.908589544193091569, 14.038094398092653137, 25.361446826442261226, + 126.45851520054566208, 66.332937872732145479, 27.829199398631317308, 77.682479624414554564, + 93.585971241493098205, 103.34601141894745524, 55.710112226402998203, 84.860369568970781984, + 53.697089125227648765, 0.92971257397584849969, 63.075534842933848267, 15.027496117534610676, + 21.950754698755190475, 0, 28.531895874137262581, 85.955036951098009013, + 6.8557842247828375548, 67.563506979815429077, 117.48375658229997498, 92.569227757212502183, + 105.43754795739732799, 32.613664735079510137, 59.836813111625815509, 79.727059214674227405, + 117.85211415888625197, 112.15118977386737242, 39.196209382360393647, 76.90555489470352768, + 69.871041543210594682, 127.53710924842016539, 48.124486812175746309, 86.51018189529349911, + 51.962787529522756813, 55.309665644217602676, 75.989344516059645684, 107.12377308446957613, + 30.514114127763605211, 41.182231885839428287, 98.24650156886127661, 0.79714579108258476481, + 93.373145930705504725, 26.953950742696179077, 114.17254428644082509, 33.587495177125674672, + 80.203617513161589159, 8.018908646670752205, 12.047526215410471195, 106.19665864830312785, + 4.3880957441397185903, 67.405484968803648371, 37.314136061540921219, 46.345498768318066141, + 34.408867627989820903, 106.37476255464207497, 124.40552362933158292, 19.898630108436918817, + 25.911002835477120243, 94.97117961179537815, 57.368406515797687462, 68.524443742018775083, + 53.489126845164719271, 83.016413769772043452, 41.418856831154698739, 49.169194417791004525, + 104.00149845615669619, 45.444879220471193548, 96.047949767282261746, 82.369610985118924873, + 27.980948182761494536, 10.249136258535145316, 58.786494188461801969, 31.097014195918745827, + 56.659098762556823203, 89.836841137297597015, 121.39215939895802876, 88.552023583204572788, + 0.052817877356574172154, 97.624803183280164376, 60.799845647659822134, 126.91879462443102966, + 59.16046614981314633, 96.749615536286000861, 97.151574762516247574, 119.37293025686449255, + 44.286345426939078607, 45.181768567494145827, 49.767175051423691912, 56.758588759246777045, + 6.0028873047776869498, 91.875369314842828317, 76.259038934731506743, 13.430600523657631129, + 86.974434800828021253, 36.551611963088362245, 59.330150566438533133, 24.35414183202010463, + 36.807122539772535674, 127.4662554121168796, 113.02948278524854686, 41.414836821928474819, + 55.69462721931267879, 127.30847316013750969, 2.2990048328465491068, 54.448069217178272083, + 107.0549887587694684, 20.148507790188887157, 88.543831383976794314, 34.276507842438149964, + 0.33840813921779044904, 18.566610328802198637, 124.00624324331511161, 51.610310525837121531, + 7.5601520085692754947, 40.971795321805984713, 103.80554523345563211, 59.801089193737425376, + 68.2404836304122, 82.922502782879746519, 100.96427405465510674, 41.861449829044431681, + 54.349766773124429164, 98.473656289268546971, 18.947709120078798151, 10.362402301212569, + 68.10619637544368743, 91.731592448144510854, 72.806715302725933725, 23.388397538976278156, + 79.179216954020375852, 57.456895591036300175, 0.13088494563271524385, 45.389536992333887611, + 35.505672101491654757, 107.85314747484881082, 16.86667139811834204, 37.139612461691285716, + 10.619378110037359875, 51.59424580911945668, 45.048680061438062694, 116.05256664709668257, + 66.580706290944362991, 67.441612650440220023, 16.394204659307433758, 28.326592747456743382, + 8.2826432979964010883, 85.398752035373036051, 106.00213214183531818, 83.085382960711285705, + 67.744959167452179827, 113.82261046273561078, 25.549440941500506597, 56.641150855011801468, + 3.5679619983166048769, 20.029166233012801968, 100.99804813001173898, 41.152490196633152664, + 50.25754998894626624, 122.24940897356282221, 12.108345174048736226, 78.393113864462065976, + 61.721586166007909924, 43.215173751199472463, 18.437672749656485394, 67.389163895975798368, + 54.148436399125785101, 3.5288318137972964905, 74.771356032098992728, 98.445057869888842106, + 39.588153580738435267, 118.71453446961095324, 117.25978504978411365, 37.851769495038752211, + 4.55191083743920899, 37.11001884073994006, 91.367741389338334557, 112.6070422258671897, + 58.711000083039834863, 118.93764568868937204, 115.1491337396473682, 100.33008107148270938, + 108.38393370197809418, 92.415476138892699964, 111.30635570295999059, 36.66738991240345058, + 115.09691598352219444, 82.544558993537066272, 21.453945525623566937, 126.52624532112895395, + 6.1998092149151489139, 94.824315226625913056, 44.681487951296730898, 126.35444543451376376, + 124.59865594034999958, 118.54843269545017392, 0.76707862238254165277, 102.57343996977942879, + 43.519143787358189002, 36.915220334034529515, 70.399251334674772806, 25.327780750696547329, + 121.97019074923446169, 118.97319057850836543, 110.26149239876394859, 27.537990332504705293, + 119.67244421595751191, 44.295508067352784565, 30.922760345587448683, 124.42359008712446666, + 61.430157796527055325, 32.367064744412346045, 69.992516718244587537, 118.94313035706727533, + 104.06206943733195658, 50.639196051670296583, 94.004496058922086377, 21.928421693472046172, + 116.00923491986759473, 14.665872654288250487, 101.25883136479387758, 115.9671618927786767, + 68.995594305502891075, 110.31168463244830491, 0.48502904455745010637, 97.997097941592073767, + 27.230654761504410999, 106.73946666151459794, 109.80349583479983266, 85.433544465191516792, + 66.044671543309959816, 92.450532100370764965, 97.575951956670905929, 91.187141428054019343, + 35.375687057807226665, 71.434109811292728409, 80.545275281223439379, 67.505274535455100704, + 76.608072779119538609, 81.923081589386129053, 92.155401273470488377, 75.630629332572425483, + 49.582231862532353261, 84.694978831121261464, 92.551543176148697967, 30.00018600863404572, + 70.814066398146678694, 82.051668834090378368, 58.369231427455815719, 118.51739785807149019, + 14.862761064749065554, 1.6359002837052685209, 2.9165922775900980923, 31.751251107107236749, + 112.69539703582995571, 25.429380920406401856, 123.70868365988280857, 34.371089741911418969, + 117.99137087614872144, 40.165197060512582539, 119.62118071581789991, 94.34032930182365817, + 6.8246622196529642679, 122.29327304878097493, 113.00003442751403782, 55.36104915721443831, + 43.023323724606598262, 107.02736930189348641, 26.09409004697954515, 68.234077158798754681, + 74.615285015344852582, 12.030239130548579851, 11.757634318797499873, 50.709235964855906786, + 115.14023990296846023, 49.745510315438878024, 26.543197198869165732, 36.310237940611841623, + 93.136903952741704416, 85.372495482770318631, 36.862218698915967252, 81.013924570550443605, + 62.136952394921536325, 115.83947434931178577, 70.696013971231877804, 34.216308566195948515, + 55.388654254496941576, 9.2159094687449396588, 90.840741968469956191, 92.560951497791393194, + 78.499007916379923699, 58.787922918960248353, 97.712345396936143516, 81.507684121694182977, + 58.086098106123245088, 8.0987305569869931787, 82.011428192137827864, 63.497983058343379525, + 51.963998723633267218, 57.728698527385859052, 4.9571261661731114145, 68.855809292435878888, + 108.35480272942004376, 76.948617049321910599, 46.871378681102214614, 115.65012027082411805, + 82.950635988720023306, 76.371357562948105624, 63.494570592287345789, 56.695732717242208309, + 116.83145895063717035, 110.98662298313865904, 114.36926665565988515, 54.27640909709589323, + 82.34324269776334404, 4.7043998598346661311, 89.516763421390351141, 43.355880877094023162, + 5.8602302787548978813, 86.586023475716501707, 36.492647349397884682, 109.48921889044140698, + 109.88146149405292817, 76.366827033194567775, 51.444534176596789621, 74.876451875403290614, + 48.867857985955197364, 53.066466183521697531, 99.733310243871528655, 70.171166123927832814, + 63.604686965885775862, 64.330550821101496695, 127.50309501943047508, 20.845857890952174785, + 28.430812110531405779, 5.3262086011782230344, 79.583131470571970567, 76.899470681863022037, + 64.169182156019815011, 39.533196884331118781, 6.8525270489662943874, 5.1642139272844360676, + 76.430902491003507748, 125.76427162163236062, 86.811511754229286453, 117.09242402735617361, + 85.397782784573792014, 35.531911237689200789, 33.053881691132119158, 6.0512223009827721398, + 68.915274776631122222, 52.619467734504723921, 30.222972127219691174, 126.64528563361091074, + 126.15816419358816347, 6.7706204809983319137, 39.440493736216012621, 50.115299339682678692, + 21.05112076023578993, 116.22269299825711641, 120.94448145128626493, 118.97437373949651374, + 87.629704669056081912, 63.570513465299882228, 54.196893777600052999, 119.44248304130815086, + 19.933360370989248622, 73.661416680213733343, 28.818021420913282782, 39.817179088386183139, + 28.076188796185306273, 50.722893652888160432, 124.91703040109496214, 4.6658757454642909579, + 55.658398797266272595, 27.364959248832747107, 59.171942482989834389, 78.692022837894910481, + 111.42022445280963439, 41.720739137941563968, 107.39417825045529753, 1.8594251479516969994, + 126.15106968586769653, 30.054992235069221351, 43.901509397514018929, 0, + 57.063791748278163141, 43.910073902196018025, 13.711568449569313088, 7.1270139596344961319, + 106.96751316460358794, 57.138455514428642346, 82.875095914794655982, 65.227329470159020275, + 119.673626223255269, 31.454118429352092789, 107.70422831777614192, 96.302379547734744847, + 78.392418764724425273, 25.811109789410693338, 11.742083086424827343, 127.07421849684033077, + 96.248973624355130596, 45.020363790586998221, 103.92557505904551363, 110.61933128843884333, + 23.978689032122929348, 86.247546168939152267, 61.028228255527210422, 82.364463771682494553, + 68.49300313772255322, 1.5942915821688075084, 58.74629186141100945, 53.907901485395996133, + 100.34508857288165018, 67.174990354254987324, 32.407235026323178317, 16.03781729334150441, + 24.09505243082458037, 84.393317296606255695, 8.7761914882830751594, 6.8109699376072967425, + 74.628272123081842437, 92.690997536636132281, 68.817735255983279785, 84.749525109287787927, + 120.81104725866316585, 39.797260216873837635, 51.822005670957878465, 61.942359223590756301, + 114.7368130315990129, 9.0488874840375501662, 106.97825369033307652, 38.032827539544086903, + 82.837713662309397478, 98.33838883558564703, 80.002996912313392386, 90.889758440946025075, + 64.095899534568161471, 36.739221970237849746, 55.961896365522989072, 20.498272517070290633, + 117.57298837692360394, 62.194028391837491654, 113.31819752511728439, 51.673682274598832009, + 114.7843187979196955, 49.104047166409145575, 0.10563575471678632312, 67.249606366560328752, + 121.59969129532328225, 125.83758924886205932, 118.32093229962993064, 65.499231072575639701, + 66.303149525036133127, 110.7458605137289851, 88.572690853878157213, 90.363537134988291655, + 99.534350102847383823, 113.51717751849355409, 12.005774609559011878, 55.750738629689294612, + 24.518077869463013485, 26.861201047318900237, 45.948869601656042505, 73.10322392617672449, + 118.66030113287706627, 48.70828366404020926, 73.614245079548709327, 126.93251082423739717, + 98.058965570497093722, 82.829673643856949639, 111.38925443862899556, 126.61694632027501939, + 4.5980096656930982135, 108.89613843436018215, 86.109977517538936809, 40.297015580381412292, + 49.087662767953588627, 68.553015684876299929, 0.67681627843558089808, 37.133220657608035253, + 120.01248648663022323, 103.22062105167424306, 15.120304017138550989, 81.943590643615607405, + 79.61109046691126423, 119.60217838747848873, 8.4809672608280379791, 37.845005565763131017, + 73.928548109310213476, 83.722899658088863362, 108.69953354625249631, 68.947312578537093941, + 37.895418240157596301, 20.724804602428775979, 8.2123927508910128381, 55.463184896292659687, + 17.61343060545186745, 46.776795077956194291, 30.358433908040751703, 114.91379118207260035, + 0.26176989126543048769, 90.779073984667775221, 71.011344202986947494, 87.706294949697621632, + 33.73334279623668408, 74.279224923382571433, 21.238756220074719749, 103.18849161823891336, + 90.097360122879763367, 104.10513329419700312, 5.1614125818923639599, 6.8832253008804400451, + 32.788409318614867516, 56.653185494913486764, 16.565286595996440155, 42.797504070749710081, + 84.004264283674274338, 38.170765921426209388, 7.4899183349079976324, 99.645220925471221562, + 51.098881883001013193, 113.28230171002360294, 7.1359239966332097538, 40.058332466029241914, + 73.996096260023477953, 82.304980393266305327, 100.51509997789617046, 116.49881794712564442, + 24.21669034810111043, 28.786227728924131952, 123.44317233201581985, 86.430347502398944926, + 36.875345499316608766, 6.7783277919515967369, 108.2968727982515702, 7.0576636275982309598, + 21.542712064201623434, 68.890115739777684212, 79.176307161480508512, 109.42906893922554445, + 106.51957009956822731, 75.703538990077504423, 9.1038216748784179799, 74.220037681483518099, + 54.735482778680307092, 97.2140844517343794, 117.4220001660833077, 109.87529137738238205, + 102.29826747929837438, 72.660162142969056731, 88.767867403959826333, 56.830952277789037907, + 94.612711405919981189, 73.334779824810539139, 102.19383196704802685, 37.089117987074132543, + 42.907891051250771852, 125.05249064225790789, 12.399618429833935807, 61.648630453251826111, + 89.362975902597099775, 124.70889086903116549, 121.19731188070363714, 109.09686539090034785, + 1.5341572447687212843, 77.146879939558857586, 87.038287574716378003, 73.830440668072697008, + 12.798502669349545613, 50.655561501396732638, 115.94038149847256136, 109.94638115702036885, + 92.522984797527897172, 55.075980665013048565, 111.34488843191502383, 88.591016134705569129, + 61.845520691178535344, 120.84718017424893333, 122.86031559305411065, 64.734129488828330068, + 11.985033436492813053, 109.88626071413818863, 80.124138874663913157, 101.27839210334423115, + 60.008992117844172753, 43.856843386947730323, 104.01846983973518945, 29.331745308580138953, + 74.517662729591393145, 103.93432378556099138, 9.9911886110094201285, 92.62336926489660982, + 0.97005808911853819154, 67.994195883184147533, 54.461309523012459977, 85.478933323032833869, + 91.606991669603303308, 42.867088930386671564, 4.0893430866235576104, 56.901064200745167909, + 67.151903913345449837, 54.374282856108038686, 70.751374115618091309, 14.868219622589094797, + 33.090550562450516736, 7.0105490709138393868, 25.216145558242715197, 35.846163178775896085, + 56.310802546944614733, 23.261258665144850966, 99.164463725068344502, 41.389957662246160908, + 57.103086352297395933, 60.000372017271729419, 13.628132796296995366, 36.103337668180756737, + 116.73846285491526942, 109.03479571614298038, 29.725522129498131108, 3.2718005674105370417, + 5.8331845551801961847, 63.502502214218111476, 97.390794071659911424, 50.858761840816441691, + 119.41736731976561714, 68.742179483826475916, 107.98274175229744287, 80.330394121028803056, + 111.2423614316394378, 60.68065860364731634, 13.649324439309566515, 116.58654609756558784, + 98.000068855028075632, 110.72209831442887662, 86.046647449216834502, 86.054738603786972817, + 52.188180093962728279, 8.4681543176011473406, 21.230570030689705163, 24.060478261097159702, + 23.515268637594999745, 101.41847192971545155, 102.28047980593692046, 99.491020630877756048, + 53.086394397738331463, 72.620475881227321224, 58.27380790548704681, 42.744990965540637262, + 73.724437397835572483, 34.027849141100887209, 124.27390478984671063, 103.67894869862720952, + 13.392027942463755608, 68.43261713239189703, 110.77730850899388315, 18.431818937493517296, + 53.681483936943550361, 57.121902995586424368, 28.998015832759847399, 117.57584583792413468, + 67.42469079387592501, 35.015368243388365954, 116.17219621224649018, 16.197461113977624336, + 36.022856384275655728, 126.99596611668675905, 103.92799744726653444, 115.4573970547717181, + 9.9142523323498608079, 9.7116185848753957544, 88.709605458843725501, 25.897234098643821198, + 93.742757362208067207, 103.30024054165187408, 37.901271977443684591, 24.742715125896211248, + 126.98914118457469158, 113.3914654344880546, 105.66291790127797867, 93.973245966280956054, + 100.73853331131977029, 108.55281819419542444, 36.68648539552668808, 9.4087997196729702409, + 51.033526842780702282, 86.711761754188046325, 11.720460557513433741, 45.172046951433003414, + 72.985294698799407342, 90.978437780886451947, 91.762922988109494327, 24.733654066389135551, + 102.88906835319721722, 21.752903750806581229, 97.735715971910394728, 106.13293236704703304, + 71.466620487746695289, 12.342332247855665628, 127.2093739317751897, 0.66110164220663136803, + 127.00619003886095015, 41.691715781904349569, 56.861624221062811557, 10.652417202360084048, + 31.166262941147579113, 25.798941363729682053, 0.3383643120396300219, 79.066393768662237562, + 13.705054097932588775, 10.328427854572510114, 24.861804982010653475, 123.52854324326835922, + 45.623023508462210884, 106.1848480547159852, 42.795565569147584029, 71.063822475378401577, + 66.107763382264238317, 12.102444601969182258, 9.8305495532622444443, 105.23893546900944784, + 60.445944254443020327, 125.29057126722545945, 124.31632838717632694, 13.541240961996663827, + 78.880987472432025243, 100.23059867936535738, 42.10224152047521784, 104.44538599651787081, + 113.88896290257616783, 109.94874747899666545, 47.259409338112163823, 127.14102693059976446, + 108.39378755520374398, 110.88496608261630172, 39.866720741982135223, 19.322833360427466687, + 57.636042841826565564, 79.634358176772366278, 56.152377592370612547, 101.44578730577995884, + 121.83406080218992429, 9.3317514909285819158, 111.31679759453254519, 54.729918497665494215, + 118.34388496598330676, 29.38404567579345894, 94.840448905619268771, 83.441478275886765914, + 86.788356500910595059, 3.7188502959070319775, 124.30213937173539307, 60.109984470138442703, + 87.803018795028037857, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, +}; diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/quad/sleefquadinline_footer.h.org b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/quad/sleefquadinline_footer.h.org new file mode 100644 index 00000000000..3e7b362ec82 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/quad/sleefquadinline_footer.h.org @@ -0,0 +1,78 @@ + +#if !defined(SLEEF_Q_DEFINED) +#define SLEEF_Q_DEFINED +static inline Sleef_quad sleef_q(int64_t H, uint64_t L, int E) { +#if defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) + struct { uint64_t h, l; } c; +#else + struct { uint64_t l, h; } c; +#endif + c.h = (((int64_t)(H) < 0 ? 1ULL : 0ULL) << 63) | + ((0x7fff & (uint64_t)((E) + 16383)) << 48) | + ((int64_t)(H) < 0 ? -(int64_t)(H) : (int64_t)(H) & 0xffffffffffffULL); + c.l = (uint64_t)(L); + + Sleef_quad q; + memcpy(&q, &c, 16); + return q; +} +#endif + +#ifdef SLEEF_QUAD_C + +#define SLEEF_M_Eq SLEEF_QUAD_C(+0x1.5bf0a8b1457695355fb8ac404e7ap+1) +#define SLEEF_M_LOG2Eq SLEEF_QUAD_C(+0x1.71547652b82fe1777d0ffda0d23ap+0) +#define SLEEF_M_LOG10Eq SLEEF_QUAD_C(+0x1.bcb7b1526e50e32a6ab7555f5a68p-2) +#define SLEEF_M_LN2q SLEEF_QUAD_C(+0x1.62e42fefa39ef35793c7673007e6p-1) +#define SLEEF_M_LN10q SLEEF_QUAD_C(+0x1.26bb1bbb5551582dd4adac5705a6p+1) +#define SLEEF_M_PIq SLEEF_QUAD_C(+0x1.921fb54442d18469898cc51701b8p+1) +#define SLEEF_M_PI_2q SLEEF_QUAD_C(+0x1.921fb54442d18469898cc51701b8p+0) +#define SLEEF_M_PI_4q SLEEF_QUAD_C(+0x1.921fb54442d18469898cc51701b8p-1) +#define SLEEF_M_1_PIq SLEEF_QUAD_C(+0x1.45f306dc9c882a53f84eafa3ea6ap-2) +#define SLEEF_M_2_PIq SLEEF_QUAD_C(+0x1.45f306dc9c882a53f84eafa3ea6ap-1) +#define SLEEF_M_2_SQRTPIq SLEEF_QUAD_C(+0x1.20dd750429b6d11ae3a914fed7fep+0) +#define SLEEF_M_SQRT2q SLEEF_QUAD_C(+0x1.6a09e667f3bcc908b2fb1366ea95p+0) +#define SLEEF_M_SQRT3q SLEEF_QUAD_C(+0x1.bb67ae8584caa73b25742d7078b8p+0) +#define SLEEF_M_INV_SQRT3q SLEEF_QUAD_C(+0x1.279a74590331c4d218f81e4afb25p-1) +#define SLEEF_M_SQRT1_2q SLEEF_QUAD_C(+0x1.6a09e667f3bcc908b2fb1366ea95p-1) +#define SLEEF_M_INV_SQRTPIq SLEEF_QUAD_C(+0x1.20dd750429b6d11ae3a914fed7fep-1) +#define SLEEF_M_EGAMMAq SLEEF_QUAD_C(+0x1.2788cfc6fb618f49a37c7f0202a6p-1) +#define SLEEF_M_PHIq SLEEF_QUAD_C(+0x1.9e3779b97f4a7c15f39cc0605ceep+0) +#define SLEEF_QUAD_MAX SLEEF_QUAD_C(+0x1.ffffffffffffffffffffffffffffp+16383) +#define SLEEF_QUAD_MIN SLEEF_QUAD_C(+0x1p-16382) +#define SLEEF_QUAD_EPSILON SLEEF_QUAD_C(+0x1p-112) +#define SLEEF_QUAD_DENORM_MIN SLEEF_QUAD_C(+0x0.0000000000000000000000000001p-16382) + +#else // #ifdef SLEEF_QUAD_C + +#define SLEEF_M_Eq sleef_q(+0x15bf0a8b14576LL, 0x95355fb8ac404e7aULL, 1) +#define SLEEF_M_LOG2Eq sleef_q(+0x171547652b82fLL, 0xe1777d0ffda0d23aULL, 0) +#define SLEEF_M_LOG10Eq sleef_q(+0x1bcb7b1526e50LL, 0xe32a6ab7555f5a68ULL, -2) +#define SLEEF_M_LN2q sleef_q(+0x162e42fefa39eLL, 0xf35793c7673007e6ULL, -1) +#define SLEEF_M_LN10q sleef_q(+0x126bb1bbb5551LL, 0x582dd4adac5705a6ULL, 1) +#define SLEEF_M_PIq sleef_q(+0x1921fb54442d1LL, 0x8469898cc51701b8ULL, 1) +#define SLEEF_M_PI_2q sleef_q(+0x1921fb54442d1LL, 0x8469898cc51701b8ULL, 0) +#define SLEEF_M_PI_4q sleef_q(+0x1921fb54442d1LL, 0x8469898cc51701b8ULL, -1) +#define SLEEF_M_1_PIq sleef_q(+0x145f306dc9c88LL, 0x2a53f84eafa3ea6aULL, -2) +#define SLEEF_M_2_PIq sleef_q(+0x145f306dc9c88LL, 0x2a53f84eafa3ea6aULL, -1) +#define SLEEF_M_2_SQRTPIq sleef_q(+0x120dd750429b6LL, 0xd11ae3a914fed7feULL, 0) +#define SLEEF_M_SQRT2q sleef_q(+0x16a09e667f3bcLL, 0xc908b2fb1366ea95ULL, 0) +#define SLEEF_M_SQRT3q sleef_q(+0x1bb67ae8584caLL, 0xa73b25742d7078b8ULL, 0) +#define SLEEF_M_INV_SQRT3q sleef_q(+0x1279a74590331LL, 0xc4d218f81e4afb25ULL, -1) +#define SLEEF_M_SQRT1_2q sleef_q(+0x16a09e667f3bcLL, 0xc908b2fb1366ea95ULL, -1) +#define SLEEF_M_INV_SQRTPIq sleef_q(+0x120dd750429b6LL, 0xd11ae3a914fed7feULL, -1) +#define SLEEF_M_EGAMMAq sleef_q(+0x12788cfc6fb61LL, 0x8f49a37c7f0202a6ULL, -1) +#define SLEEF_M_PHIq sleef_q(+0x19e3779b97f4aLL, 0x7c15f39cc0605ceeULL, 0) +#define SLEEF_QUAD_MAX sleef_q(+0x1ffffffffffffLL, 0xffffffffffffffffULL, 16383) +#define SLEEF_QUAD_MIN sleef_q(+0x1000000000000LL, 0x0000000000000000ULL, -16382) +#define SLEEF_QUAD_EPSILON sleef_q(+0x1000000000000LL, 0x0000000000000000ULL, -112) +#define SLEEF_QUAD_DENORM_MIN sleef_q(+0x0000000000000LL, 0x0000000000000001ULL, -16382) + +#endif // #ifdef SLEEF_QUAD_C + +#define SLEEF_QUAD_MANT_DIG 113 +#define SLEEF_QUAD_MIN_EXP (-16381) +#define SLEEF_QUAD_MAX_EXP 16384 +#define SLEEF_QUAD_DIG 33 +#define SLEEF_QUAD_MIN_10_EXP (-4931) +#define SLEEF_QUAD_MAX_10_EXP 4932 diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/quad/sleefquadinline_header.h.org b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/quad/sleefquadinline_header.h.org new file mode 100644 index 00000000000..2001d577aec --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/quad/sleefquadinline_header.h.org @@ -0,0 +1,4216 @@ +// Copyright Naoki Shibata and contributors 2010 - 2021. +// Distributed under the Boost Software License, Version 1.0. +// (See http://www.boost.org/LICENSE_1_0.txt) + +// This file is generated by SLEEF SLEEF_VERSION_SLEEF + +#ifndef SLEEF_ALWAYS_INLINE +#if defined (__GNUC__) || defined (__clang__) || defined(__INTEL_COMPILER) +#define SLEEF_ALWAYS_INLINE inline __attribute__((always_inline)) +#elif defined(_MSC_VER) +#define SLEEF_ALWAYS_INLINE inline __forceinline +#else +#define SLEEF_ALWAYS_INLINE inline +#endif +#endif + +#ifndef SLEEF_INLINE +#define SLEEF_INLINE static inline +#endif + +#ifndef SLEEF_CONST +#define SLEEF_CONST +#endif + +#if defined(_MSC_VER) && !defined (__clang__) +#pragma fp_contract (off) +#else +#pragma STDC FP_CONTRACT OFF +#endif + +#ifndef SLEEF_FP_ILOGB0 +#define SLEEF_FP_ILOGB0 ((int)0x80000000) +#endif + +#ifndef SLEEF_FP_ILOGBNAN +#define SLEEF_FP_ILOGBNAN ((int)2147483647) +#endif + +#define SLEEFQUADINLINE_SLEEF_SIMD_SLEEF_H_INCLUDED + +#ifndef __SLEEF_QREMPITAB__ +#define __SLEEF_QREMPITAB__ +static const double Sleef_rempitabqp[] = { + 0.15915494308865163475, 114.12758349655632628, 87.820147804392036051, 27.423136899138626177, + 14.254027919272630243, 85.935026329207175877, 114.27691102886092267, 37.750191829592949944, + 2.4546589403216785286, 111.34725244651053799, 62.908236858707823558, 87.408456635555921821, + 64.604759095473127672, 28.784837529448850546, 51.622219578821386676, 23.484166172853292665, + 126.14843699368429952, 64.497947248710261192, 90.04072758117763442, 79.851150118094665231, + 93.238662576877686661, 47.957378064249496674, 44.495092337878304534, 122.05645651105805882, + 36.728927543368627084, 8.9860062754451064393, 3.1885831643376150168, 117.4925837228220189, + 107.81580297079563024, 72.690177145766938338, 6.3499807085099746473, 64.814470052646356635, + 32.07563458668300882, 48.190104861652798718, 40.78663459321251139, 17.552382976566150319, + 13.621939875218231464, 21.256544246167322854, 57.381995073275902541, 9.6354705119701975491, + 41.499050218579213833, 113.6220945173263317, 79.59452043374767527, 103.64401134191575693, + 123.88471844718515058, 101.4736260631980258, 18.097774968078738311, 85.95650738066615304, + 76.065655079091811785, 37.675427324622432934, 68.676777671174932038, 32.00599382463042275, + 53.77951688189568813, 0.19179906913632294163, 73.478443940475699492, 111.92379273104597814, + 40.996545034144219244, 107.14597675384720787, 124.38805678367862129, 98.636395050234568771, + 103.347364549201302, 101.568637595839391, 98.20809433281829115, 0.21127150943721062504, + 6.4992127331242954824, 115.19938259065020247, 123.67517849772775662, 108.64186459926349926, + 2.9984621451549173798, 4.6062990500759042334, 93.491721027461608173, 49.145381707759952405, + 52.727074269980221288, 71.068700205698405625, 99.034355036987108178, 24.011549219118023757, + 111.50147725937858922, 49.03615573892602697, 53.722402094637800474, 91.897739203315722989, + 18.206447852357086958, 109.32060226575413253, 97.416567328084056498, 19.228490159101056634, + 125.86502164847843233, 68.117931140997825423, 37.659347287717537256, 94.778508877261629095, + 125.23389264055003878, 9.1960193313898344059, 89.79227686872400227, 44.219955035077873617, + 80.594031160762824584, 98.175325535910815233, 9.1060313697525998577, 1.3536325568711617962, + 74.266441315219708486, 112.02497297326408443, 78.441242103348486125, 30.240608034280739957, + 35.887181287234852789, 31.222180933826166438, 111.20435677495697746, 16.961934521656075958, + 75.690011131529900013, 19.857096218624064932, 39.445799316181364702, 89.399067092508630594, + 9.8946251570741878822, 75.790836480315192603, 41.449609204857551958, 16.424785501782025676, + 110.92636979258531937, 35.2268612109037349, 93.553590155912388582, 60.716867816085141385, + 101.8275823641452007, 0.52353978253449895419, 53.558147969339188421, 14.022688405977532966, + 47.412589899395243265, 67.466685592477006139, 20.558449846765142865, 42.477512440153077478, + 78.376983236481464701, 52.194720245763164712, 80.210266588394006249, 10.32282516378472792, + 13.76645060176088009, 65.576818637229735032, 113.30637098982697353, 33.130573191992880311, + 85.595008141503058141, 40.008528567348548677, 76.341531842852418777, 14.979836669819633244, + 71.290441850942443125, 102.19776376600566437, 98.564603420047205873, 14.271847993266419508, + 80.116664932062121807, 19.992192520050593885, 36.609960786536248634, 73.030199955795978894, + 104.99763589425128885, 48.433380696202220861, 57.572455457851901883, 118.88634466403527767, + 44.860695004797889851, 73.750690998633217532, 13.556655583906831453, 88.593745596503140405, + 14.11532725519646192, 43.085424128406884847, 9.7802314795590064023, 30.352614322964655003, + 90.858137878454726888, 85.039140199140092591, 23.407077980155008845, 18.207643349760473939, + 20.440075362967036199, 109.47096555736425216, 66.428168903472396778, 106.84400033217025339, + 91.750582754768402083, 76.596534958600386744, 17.320324285941751441, 49.535734807919652667, + 113.66190455558171379, 61.225422811843600357, 18.669559649624716258, 76.387663934096053708, + 74.178235974148265086, 85.815782102505181683, 122.10498128451581579, 24.799236859667871613, + 123.2972609065072902, 50.72595180519783753, 121.41778173806596897, 114.39462376141091227, + 90.193730781800695695, 3.0683144895410805475, 26.293759879121353151, 46.076575149436393986, + 19.660881336145394016, 25.597005338699091226, 101.31112300279710325, 103.8807629969487607, + 91.892762314044375671, 57.045969595055794343, 110.15196133002973511, 94.689776863833685638, + 49.182032269411138259, 123.69104138236070867, 113.69436034850150463, 117.72063118611185928, + 1.4682589776566601358, 23.970066872989264084, 91.772521428280015243, 32.248277749331464292, + 74.556784206688462291, 120.01798423568834551, 87.713686773899098625, 80.036939679470378906, + 58.663490617163915886, 21.035325459186424268, 79.868647571121982764, 19.982377222022478236, + 57.246738529793219641, 1.9401161782407143619, 7.9883917663682950661, 108.92261904602855793, + 42.957866646069305716, 55.213983339206606615, 85.734177860773343127, 8.1786861732471152209, + 113.8021284014939738, 6.3038078266908996738, 108.74856571221971535, 13.502748231236182619, + 29.736439245178189594, 66.181101124901033472, 14.021098141827678774, 50.432291116485430393, + 71.692326357551792171, 112.62160509388922947, 46.52251733029333991, 70.328927450136689004, + 82.779915324492321815, 114.20617270459479187, 120.00074403454345884, 27.256265592593990732, + 72.206675336365151452, 105.47692570983417681, 90.069591432285960764, 59.451044258996262215, + 6.5436011348210740834, 11.666369110360392369, 127.00500442843986093, 66.781588143319822848, + 101.71752368163652136, 110.83473463953487226, 9.4843589676565898117, 87.965483504598523723, + 32.660788242061244091, 94.484722863278875593, 121.36131720729463268, 27.298648878622771008, + 105.17309219513481366, 68.000137710059789242, 93.444196628861391218, 44.093294898437306983, + 44.109477207573945634, 104.37636018792545656, 16.936308635202294681, 42.461140061379410326, + 48.120956522194319405, 47.03053727519363747, 74.836943859434541082, 76.560959611877478892, + 70.982041261755512096, 106.17278879548030091, 17.240951762454642449, 116.54761581097409362, + 85.489981931084912503, 19.448874795671144966, 68.055698282205412397, 120.54780957969705923, + 79.357897397254419047, 26.784055884931149194, 8.8652342647874320392, 93.554617017987766303, + 36.863637874987034593, 107.36296787388710072, 114.24380599117284874, 57.996031665523332777, + 107.15169167585190735, 6.8493815877518500201, 70.030736486780369887, 104.34439242449298035, + 32.394922227955248673, 72.045712768554949434, 125.99193223337715608, 79.855994894536706852, + 102.91479410954343621, 19.828504664699721616, 19.423237169754429488, 49.419210917687451001, + 51.794468197291280376, 59.485514724419772392, 78.600481083303748164, 75.802543954887369182, + 49.485430251796060475, 125.97828236915302114, 98.782930868979747174, 83.325835802559595322, + 59.946491932565550087, 73.477066622643178562, 89.105636388390848879, 73.372970791053376161, + 18.817599439345940482, 102.06705368556504254, 45.42352350837609265, 23.440921115026867483, + 90.344093902869644808, 17.970589397602452664, 53.956875561776541872, 55.525845976218988653, + 49.46730813278190908, 77.778136706394434441, 43.505807501616800437, 67.471431943824427435, + 84.265864734097704059, 14.933240975493390579, 24.684664495714969235, 126.41874786355037941, + 1.3222032844169007149, 126.01238007772190031, 83.383431563808699138, 113.72324844212562311, + 21.304834404720168095, 62.332525882295158226, 51.597882727459364105, 0.67672862408289802261, + 30.132787537324475124, 27.410108195865177549, 20.656855709145020228, 49.723609964024944929, + 119.05708648653671844, 91.246047016928059747, 84.369696109431970399, 85.591131138298806036, + 14.127644950760441134, 4.2155267645284766331, 24.204889203938364517, 19.661099106528126867, + 82.477870938018895686, 120.89188850888967863, 122.58114253445455688, 120.63265677435265388, + 27.082481923996965634, 29.761974944867688464, 72.461197358730714768, 84.204483040954073658, + 80.890771993039379595, 99.777925805155973649, 91.8974949579933309, 94.518818676227965625, + 126.28205386120316689, 88.787575110411125934, 93.769932165232603438, 79.733441483964270446, + 38.645666720854933374, 115.27208568365676911, 31.268716353544732556, 112.30475518474486307, + 74.891574611563555663, 115.66812160437984858, 18.66350298186080181, 94.633595189065090381, + 109.45983699533462641, 108.68776993196661351, 58.76809135159055586, 61.680897811242175521, + 38.882956551777169807, 45.576713001821190119, 7.4377005918177019339, 120.60427874347078614, + 120.21996894028052338, 47.606037590059713693, 0.31830988618094124831, 100.25516699311629054, + 47.640295608784072101, 54.846273798277252354, 28.508055838548898464, 43.870052658417989733, + 100.55382205772184534, 75.500383659185899887, 4.9093178806469950359, 94.694504893021075986, + 125.81647371741928509, 46.816913271115481621, 1.2095181909462553449, 57.569675058897701092, + 103.24443915764277335, 46.968332345710223308, 124.29687398737223702, 0.99589449742416036315, + 52.081455162358906819, 31.702300236192968441, 58.477325153755373321, 95.914756128498993348, + 88.990184675760247046, 116.11291302211611765, 73.457855086737254169, 17.972012550890212879, + 6.3771663286788680125, 106.98516744564767578, 87.631605941594898468, 17.380354291533876676, + 12.699961417023587273, 1.6289401052927132696, 64.15126917336601764, 96.380209723305597436, + 81.573269186425022781, 35.104765953132300638, 27.243879750436462928, 42.513088492334645707, + 114.76399014655180508, 19.270941023940395098, 82.998100437162065646, 99.244189034656301374, + 31.189040867498988518, 79.288022683835151838, 119.76943689437393914, 74.947252126396051608, + 36.195549936161114601, 43.913014761335944058, 24.131310158183623571, 75.350854649248503847, + 9.3535553423498640768, 64.011987649260845501, 107.55903376379137626, 0.38359813827628386207, + 18.956887880955036962, 95.847585462091956288, 81.993090068292076467, 86.291953507698053727, + 120.77611356736088055, 69.272790100472775521, 78.694729098406241974, 75.137275191682419972, + 68.4161886656365823, 0.42254301887442125008, 12.998425466252228944, 102.39876518130404293, + 119.35035699545915122, 89.283729198526998516, 5.9969242903098347597, 9.2125981001554464456, + 58.983442054923216347, 98.290763415519904811, 105.45414853996408056, 14.137400411400449229, + 70.068710073974216357, 48.023098438239685493, 95.002954518757178448, 98.07231147785205394, + 107.44480418927923893, 55.795478406631445978, 36.412895704717811896, 90.641204531511903042, + 66.833134656168112997, 38.456980318205751246, 123.73004329696050263, 8.2358622819956508465, + 75.318694575438712491, 61.557017754526896169, 122.46778528110007755, 18.392038662783306791, + 51.58455373744800454, 88.439910070159385214, 33.188062321529287146, 68.350651071821630467, + 18.212062739505199715, 2.7072651137459615711, 20.53288263044305495, 96.04994594653180684, + 28.882484206696972251, 60.481216068561479915, 71.774362574469705578, 62.444361867655970855, + 94.408713549913954921, 33.923869043315789895, 23.380022263059800025, 39.714192437248129863, + 78.891598632366367383, 50.798134185017261188, 19.789250314152013743, 23.581672960630385205, + 82.899218409715103917, 32.849571003567689331, 93.852739585170638748, 70.453722421811107779, + 59.107180311824777164, 121.43373563217392075, 75.655164728290401399, 1.0470795650689979084, + 107.11629593867837684, 28.045376811955065932, 94.825179798794124508, 6.9333711849540122785, + 41.116899693530285731, 84.955024880309792934, 28.753966472962929402, 104.3894404915299674, + 32.420533176788012497, 20.64565032756945584, 27.532901203525398159, 3.1536372744631080423, + 98.612741979653947055, 66.261146383989398601, 43.190016283006116282, 80.017057134700735332, + 24.683063685704837553, 29.959673339642904466, 14.580883701888524229, 76.39552753201496671, + 69.129206840094411746, 28.543695986536476994, 32.233329864124243613, 39.984385040101187769, + 73.219921573076135246, 18.060399911595595768, 81.995271788502577692, 96.866761392404441722, + 115.14491091570744175, 109.77268932807055535, 89.721390009599417681, 19.501381997266435064, + 27.113311167817300884, 49.18749119300628081, 28.230654510392923839, 86.170848256813769694, + 19.560462959118012805, 60.705228645932947984, 53.716275756913091755, 42.078280398280185182, + 46.81415596031001769, 36.415286699520947877, 40.880150725937710376, 90.941931114732142305, + 4.8563378069484315347, 85.688000664344144752, 55.501165509540442144, 25.193069917200773489, + 34.640648571883502882, 99.071469615842943313, 99.323809111163427588, 122.45084562368720071, + 37.339119299253070494, 24.775327868195745395, 20.356471948300168151, 43.631564205014001345, + 116.20996256903163157, 49.598473719339381205, 118.5945218130145804, 101.45190361039931304, + 114.83556347613557591, 100.78924752282546251, 52.38746156360139139, 6.136628979082161095, + 52.587519758242706303, 92.153150298872787971, 39.321762672290788032, 51.194010677401820431, + 74.622246005597844487, 79.761525993901159381, 55.785524628088751342, 114.09193919011522667, + 92.303922660063108196, 61.379553727667371277, 98.364064538825914497, 119.38208276472505531, + 99.388720697006647242, 107.44126237222371856, 2.9365179553133202717, 47.940133745982166147, + 55.545042856560030486, 64.496555498666566564, 21.113568413380562561, 112.03596847138032899, + 47.42737354780183523, 32.073879358940757811, 117.32698123432783177, 42.070650918376486516, + 31.737295142243965529, 39.964754444044956472, 114.49347705958643928, 3.8802323564814287238, + 15.976783532740228111, 89.845238092057115864, 85.915733292138611432, 110.42796667841685121, + 43.468355721546686254, 16.357372346497868421, 99.604256802987947594, 12.607615653385437327, + 89.497131424439430702, 27.005496462472365238, 59.472878490360017167, 4.3622022498020669445, + 28.042196283655357547, 100.86458223297449877, 15.384652715107222321, 97.243210187778458931, + 93.045034660590317799, 12.657854900277015986, 37.559830648988281609, 100.41234540919322171, + 112.00148806908691768, 54.512531185191619443, 16.413350672733940883, 82.953851419671991607, + 52.139182864571921527, 118.90208851799252443, 13.087202269642148167, 23.332738220724422717, + 126.01000885688335984, 5.5631762866432836745, 75.435047363276680699, 93.669469279069744516, + 18.968717935316817602, 47.930967009197047446, 65.321576484126126161, 60.969445726561389165, + 114.72263441458926536, 54.597297757249179995, 82.346184390273265308, 8.0002754201232164633, + 58.888393257722782437, 88.186589796874613967, 88.218954415151529247, 80.752720375850913115, + 33.872617270404589362, 84.922280122758820653, 96.241913044388638809, 94.061074550390912918, + 21.673887718872720143, 25.121919223758595763, 13.964082523514662171, 84.34557759096060181, + 34.481903524912922876, 105.09523162195182522, 42.979963862169825006, 38.897749591345927911, + 8.1113965644144627731, 113.09561915939775645, 30.715794794508838095, 53.568111769862298388, + 17.730468529578502057, 59.109234035975532606, 73.727275749977707164, 86.725935747777839424, + 100.48761198234569747, 115.99206333105030353, 86.303383351703814697, 13.698763175507338019, + 12.061472973564377753, 80.688784848985960707, 64.789844455914135324, 16.091425537113536848, + 123.98386446675795014, 31.711989789077051682, 77.829588219086872414, 39.657009329399443232, + 38.846474339508858975, 98.838421835374902003, 103.58893639458256075, 118.97102944884318276, + 29.200962166611134307, 23.605087909774738364, 98.970860503595758928, 123.95656473830968025, + 69.565861737963132327, 38.651671605119190644, 119.89298386513473815, 18.954133245289995102, + 50.211272776785335736, 18.745941582106752321, 37.635198878695518943, 76.134107371130085085, + 90.8470470167521853, 46.881842230057372944, 52.688187805739289615, 35.941178795204905327, + 107.91375112355308374, 111.05169195243797731, 98.934616265567456139, 27.556273412788868882, + 87.011615003237238852, 6.9428638876524928492, 40.531729468195408117, 29.866481950986781158, + 49.369328991433576448, 124.83749572710075881, 2.6444065688374394085, 124.02476015544743859, + 38.766863127621036256, 99.446496884251246229, 42.60966880944033619, 124.66505176459031645, + 103.19576545491872821, 1.3534572481657960452, 60.265575074648950249, 54.820216391730355099, + 41.313711418290040456, 99.447219928053527838, 110.11417297307707486, 54.492094033859757474, + 40.739392218867578777, 43.182262276597612072, 28.255289901520882268, 8.4310535290569532663, + 48.409778407876729034, 39.322198213059891714, 36.95574187604142935, 113.78377701778299524, + 117.16228506891275174, 113.26531354870530777, 54.164963847993931267, 59.523949889739014907, + 16.922394717465067515, 40.408966081911785295, 33.781543986082397169, 71.555851610315585276, + 55.794989915990299778, 61.037637352459569229, 124.56410772240997176, 49.575150220825889846, + 59.539864330468844855, 31.466882967928540893, 77.291333441713504726, 102.54417136731353821, + 62.53743270709310309, 96.609510369493364124, 21.783149223130749306, 103.33624320875969715, + 37.3270059637252416, 61.26719037813381874, 90.919673990672890795, 89.375539863933227025, + 117.53618270318111172, 123.36179562248435104, 77.765913103554339614, 91.153426003642380238, + 14.875401183639041847, 113.20855748694521026, 112.43993788056104677, 95.212075180119427387, + 0.63661977236552047543, 72.510333986232581083, 95.280591217568144202, 109.69254759655450471, + 57.016111677097796928, 87.740105316839617444, 73.107644115447328659, 23.000767318371799774, + 9.8186357612976280507, 61.389009786045789951, 123.63294743483857019, 93.633826542230963241, + 2.4190363818925106898, 115.13935011779904016, 78.488878315285546705, 93.936664691424084594, + 120.59374797474447405, 1.9917889948483207263, 104.16291032471781364, 63.404600472385936882, + 116.95465030751438462, 63.829512257001624675, 49.980369351524132071, 104.22582604423587327, + 18.915710173474508338, 35.944025101780425757, 12.754332657361374004, 85.970334891298989533, + 47.263211883189796936, 34.760708583067753352, 25.399922834047174547, 3.257880210589064518, + 0.30253834673567325808, 64.76041944661483285, 35.146538372850045562, 70.209531906264601275, + 54.487759500872925855, 85.026176984672929393, 101.52798029310361017, 38.541882047884428175, + 37.99620087432776927, 70.488378069312602747, 62.378081735001615016, 30.576045367673941655, + 111.53887378875151626, 21.894504252792103216, 72.391099872322229203, 87.826029522671888117, + 48.262620316370885121, 22.701709298497007694, 18.707110684703366132, 0.023975298525328980759, + 87.118067527582752518, 0.76719627655256772414, 37.913775761913711904, 63.695170924187550554, + 35.986180136587790912, 44.583907015399745433, 113.55222713472539908, 10.54558020094918902, + 29.389458196816121927, 22.274550383368477924, 8.8323773312731646001, 0.84508603774884250015, + 25.996850932508095866, 76.797530362611723831, 110.70071399092194042, 50.567458397053997032, + 11.993848580619669519, 18.425196200310892891, 117.96688410985007067, 68.581526831043447601, + 82.908297079928161111, 28.274800822804536438, 12.137420147948432714, 96.046196876483008964, + 62.005909037517994875, 68.144622955707745859, 86.889608378558477852, 111.59095681326289196, + 72.82579140943926177, 53.282409063027444063, 5.6662693123362259939, 76.91396063641514047, + 119.46008659392100526, 16.471724563994939672, 22.637389150877424981, 123.11403550905743032, + 116.93557056220015511, 36.784077325566613581, 103.16910747489964706, 48.879820140318770427, + 66.376124643062212272, 8.7013021436432609335, 36.424125479010399431, 5.4145302274919231422, + 41.065765260889747879, 64.099891893063613679, 57.764968413393944502, 120.96243213712659781, + 15.548725148939411156, 124.88872373531557969, 60.817427099827909842, 67.84773808663157979, + 46.76004452611960005, 79.428384874499897705, 29.783197264732734766, 101.59626837003452238, + 39.578500628304027487, 47.163345921264408389, 37.798436819430207834, 65.699142007139016641, + 59.705479170344915474, 12.907444843622215558, 118.21436062365319231, 114.86747126435147948, + 23.310329456580802798, 2.0941591301416337956, 86.232591877356753685, 56.090753623913769843, + 61.650359597588249017, 13.866742369908024557, 82.233799387064209441, 41.910049760619585868, + 57.507932945929496782, 80.778880983059934806, 64.841066353576024994, 41.291300655138911679, + 55.065802407050796319, 6.3072745489298540633, 69.225483959311532089, 4.5222927679787972011, + 86.380032566015870543, 32.034114269401470665, 49.366127371409675106, 59.919346679285808932, + 29.161767403780686436, 24.791055064033571398, 10.258413680188823491, 57.087391973072953988, + 64.466659728248487227, 79.968770080206013517, 18.439843146152270492, 36.120799823194829514, + 35.990543577008793363, 65.733522784812521422, 102.28982183141852147, 91.545378656144748675, + 51.442780019198835362, 39.002763994532870129, 54.226622335634601768, 98.374982386012561619, + 56.461309020789485658, 44.341696513627539389, 39.120925918236025609, 121.41045729186589597, + 107.43255151382618351, 84.156560796560370363, 93.62831192062003538, 72.830573399041895755, + 81.760301451879058732, 53.88386222946428461, 9.7126756139005010482, 43.376001328688289504, + 111.00233101908088429, 50.386139834401546977, 69.281297143770643743, 70.142939231689524604, + 70.647618222330493154, 116.90169124737440143, 74.678238598506140988, 49.550655736391490791, + 40.712943896600336302, 87.263128410031640669, 104.41992513806326315, 99.196947438682400389, + 109.18904362603279878, 74.903807220802264055, 101.6711269522747898, 73.578495045650925022, + 104.77492312720278278, 12.27325795816432219, 105.17503951648905058, 56.306300597745575942, + 78.643525344581576064, 102.38802135480727884, 21.244492011199326953, 31.523051987802318763, + 111.57104925618114066, 100.18387838023409131, 56.607845320126216393, 122.75910745533838053, + 68.728129077655466972, 110.7641655294537486, 70.777441394016932463, 86.882524744447437115, + 5.8730359106266405433, 95.880267491964332294, 111.09008571312369895, 0.99311099733313312754, + 42.2271368267647631, 96.071936942760657985, 94.854747095603670459, 64.147758717885153601, + 106.65396246865566354, 84.141301836752973031, 63.474590284487931058, 79.929508888093550922, + 100.98695411917287856, 7.7604647129628574476, 31.953567065484094201, 51.690476184117869707, + 43.831466584280860843, 92.855933356833702419, 86.936711443093372509, 32.71474469299937482, + 71.208513605975895189, 25.215231306774512632, 50.994262848878861405, 54.010992924944730476, + 118.94575698072003433, 8.7244044996041338891, 56.084392567314353073, 73.729164465948997531, + 30.76930543021808262, 66.48642037556055584, 58.090069321180635598, 25.315709800554031972, + 75.119661297980201198, 72.824690818390081404, 96.002976138173835352, 109.02506237038323889, + 32.826701345471519744, 37.907702839343983214, 104.27836572914748103, 109.80417703598504886, + 26.174404539284296334, 46.665476441452483414, 124.02001771376671968, 11.126352573290205328, + 22.870094726556999376, 59.338938558139489032, 37.937435870633635204, 95.861934018397732871, + 2.6431529682522523217, 121.93889145312641631, 101.44526882917853072, 109.19459551450199797, + 36.692368780546530616, 16.000550840246432927, 117.77678651544920285, 48.373179593752865912, + 48.437908830306696473, 33.50544075170182623, 67.745234540812816704, 41.844560245521279285, + 64.483826088780915597, 60.122149100781825837, 43.347775437745440286, 50.243838447517191526, + 27.92816504703296232, 40.691155181921203621, 68.963807049829483731, 82.190463243903650437, + 85.959927724339650013, 77.795499182691855822, 16.222793128832563525, 98.191238318795512896, + 61.43158958901767619, 107.13622353972459678, 35.460937059157004114, 118.21846807195470319, + 19.454551499959052308, 45.451871495559316827, 72.975223964695032919, 103.98412666210424504, + 44.606766703407629393, 27.397526351014676038, 24.122945947132393485, 33.377569697975559393, + 1.5796889118282706477, 32.182851074230711674, 119.96772893351590028, 63.423979578157741344, + 27.659176438173744828, 79.314018658798886463, 77.692948679021355929, 69.676843670753441984, + 79.177872789168759482, 109.94205889768636553, 58.401924333222268615, 47.210175819553114707, + 69.941721007195155835, 119.91312947662299848, 11.131723475926264655, 77.303343210242019268, + 111.78596773026947631, 37.908266490579990204, 100.42254555357067147, 37.491883164213504642, + 75.270397757394675864, 24.268214742263808148, 53.6940940335043706, 93.763684460114745889, + 105.37637561147857923, 71.882357590413448634, 87.827502247109805467, 94.103383904879592592, + 69.869232531134912279, 55.112546825581375742, 46.023230006474477705, 13.885727775304985698, + 81.063458936390816234, 59.732963901973562315, 98.738657982870790875, 121.67499145420151763, + 5.2888131376785167959, 120.04952031089487718, 77.53372625524571049, 70.892993768502492458, + 85.219337618884310359, 121.33010352918427088, 78.39153090983745642, 2.7069144963315920904, + 120.5311501492979005, 109.6404327834607102, 82.62742283658371889, 70.894439856110693654, + 92.228345946154149715, 108.98418806771951495, 81.478784437735157553, 86.364524553195224144, + 56.510579803041764535, 16.862107058113906533, 96.819556815753458068, 78.644396426119783428, + 73.911483752086496679, 99.567554035569628468, 106.32457013782914146, 98.530627097410615534, + 108.32992769598786253, 119.04789977947802981, 33.84478943493013503, 80.81793216382357059, + 67.563087972168432316, 15.111703220631170552, 111.58997983198059956, 122.07527470492277644, + 121.12821544481994351, 99.150300441651779693, 119.07972866093768971, 62.933765935860719765, + 26.582666883430647431, 77.088342734627076425, 125.07486541418984416, 65.219020738986728247, + 43.56629844626513659, 78.672486417519394308, 74.654011927450483199, 122.53438075627127546, + 53.83934798134941957, 50.751079727870092029, 107.07236540636586142, 118.72359124497234006, + 27.531826207112317206, 54.306852007284760475, 29.750802367281721672, 98.417114973894058494, + 96.879875761125731515, 62.424150360242492752, 1.2732395447346789297, 17.020667972468800144, + 62.561182435139926383, 91.385095193109009415, 114.03222335419923184, 47.480210633682872867, + 18.215288230894657318, 46.001534636743599549, 19.637271522595256101, 122.77801957209521788, + 119.26589486968077836, 59.267653084461926483, 4.8380727637886593584, 102.2787002356017183, + 28.977756630574731389, 59.873329382851807168, 113.1874959494889481, 3.9835779897002794314, + 80.325820649435627274, 126.80920094477551174, 105.90930061502876924, 127.65902451400324935, + 99.960738703051902121, 80.451652088471746538, 37.831420346949016675, 71.888050203560851514, + 25.508665314726385986, 43.940669782597979065, 94.526423766379593872, 69.521417166135506704, + 50.799845668094349094, 6.515760421178129036, 0.60507669347498449497, 1.5208388932296657003, + 70.293076745703729102, 12.419063812529202551, 108.97551900174948969, 42.052353969349496765, + 75.055960586207220331, 77.08376409576885635, 75.992401748659176519, 12.976756138625205494, + 124.75616347000323003, 61.152090735351521289, 95.077747577503032517, 43.789008505587844411, + 16.782199744648096384, 47.652059045343776233, 96.525240632741770241, 45.403418596994015388, + 37.414221369406732265, 0.047950597054295940325, 46.236135055165505037, 1.5343925531051354483, + 75.827551523827423807, 127.39034184837510111, 71.972360273175581824, 89.167814030803128844, + 99.104454269450798165, 21.091160401898378041, 58.778916393632243853, 44.549100766736955848, + 17.6647546625463292, 1.6901720754976850003, 51.993701865019829711, 25.595060725227085641, + 93.401427981843880843, 101.13491679410799406, 23.987697161239339039, 36.850392400625423761, + 107.93376821970377932, 9.1630536620905331802, 37.816594159856322221, 56.549601645609072875, + 24.274840295900503406, 64.092393752966017928, 124.01181807503962773, 8.2892459114191296976, + 45.779216757120593684, 95.18191362652942189, 17.65158281887852354, 106.56481812605488813, + 11.332538624676089967, 25.82792127283391892, 110.92017318784201052, 32.943449127989879344, + 45.274778301758487942, 118.22807101811849861, 105.87114112440031022, 73.568154651136865141, + 78.338214949799294118, 97.759640280641178833, 4.7522492861244245432, 17.402604287286521867, + 72.848250958020798862, 10.829060454983846284, 82.131530521783133736, 0.19978378612722735852, + 115.52993682679152698, 113.92486427425319562, 31.097450297882460291, 121.77744747063115938, + 121.63485419965945766, 7.6954761732631595805, 93.520089052242838079, 30.856769748999795411, + 59.566394529469107511, 75.192536740069044754, 79.157001256608054973, 94.326691842528816778, + 75.596873638864053646, 3.3982840142780332826, 119.41095834068983095, 25.814889687248069094, + 108.42872124731002259, 101.73494252870295895, 46.620658913161605597, 4.18831826028690557, + 44.465183754713507369, 112.18150724782753969, 123.30071919517649803, 27.733484739819687093, + 36.467598774128418881, 83.820099521239171736, 115.01586589186263154, 33.557761966123507591, + 1.6821327071520499885, 82.582601310277823359, 110.13160481410159264, 12.614549097863346105, + 10.450967918623064179, 9.0445855359612323809, 44.760065132031741086, 64.06822853880294133, + 98.732254742819350213, 119.83869335857161786, 58.323534807561372872, 49.582110128067142796, + 20.516827360377646983, 114.17478394614954595, 0.93331945650061243214, 31.937540160412027035, + 36.879686292304540984, 72.241599646389659029, 71.981087154021224706, 3.4670455696286808234, + 76.579643662840680918, 55.090757312289497349, 102.88556003839767072, 78.005527989065740258, + 108.45324467127284152, 68.749964772025123239, 112.92261804157897132, 88.683393027255078778, + 78.241851836475689197, 114.82091458373542991, 86.865103027656004997, 40.313121593124378705, + 59.256623841243708739, 17.661146798087429488, 35.520602903758117463, 107.76772445892856922, + 19.425351227801002096, 86.752002657380216988, 94.004662038161768578, 100.77227966880673193, + 10.562594287544925464, 12.285878463382687187, 13.295236444664624287, 105.80338249475244083, + 21.356477197012281977, 99.101311472782981582, 81.425887793204310583, 46.526256820066919317, + 80.839850276130164275, 70.393894877368438756, 90.378087252069235547, 21.807614441608166089, + 75.342253904553217581, 19.156990091305488022, 81.54984625440556556, 24.546515916332282359, + 82.350079032978101168, 112.61260119549478986, 29.287050689166790107, 76.77604270961455768, + 42.488984022398653906, 63.046103975608275505, 95.142098512365919305, 72.36775676046818262, + 113.21569064025607076, 117.51821491068039904, 9.4562581553145719226, 93.528331058911135187, + 13.554882788037502905, 45.76504948889487423, 11.746071821256919065, 63.760534983932302566, + 94.180171426247397903, 1.9862219946662662551, 84.454273653533164179, 64.143873885524953948, + 61.709494191210978897, 0.2955174357739451807, 85.307924937314965064, 40.282603673505946063, + 126.94918056897950009, 31.859017776190739824, 73.973908238345757127, 15.520929425925714895, + 63.907134130968188401, 103.38095236823573941, 87.662933168565359665, 57.711866713671042817, + 45.873422886186745018, 65.429489386002387619, 14.417027211951790377, 50.430462613549025264, + 101.98852569775772281, 108.02198584989309893, 109.89151396144006867, 17.448808999208267778, + 112.16878513463234412, 19.458328931897995062, 61.538610860439803218, 4.9728407511211116798, + 116.1801386423612712, 50.631419601111701922, 22.239322595964040374, 17.649381636783800786, + 64.005952276351308683, 90.050124740766477771, 65.653402690943039488, 75.815405678691604408, + 80.556731458298600046, 91.608354071970097721, 52.348809078568592668, 93.330952882908604806, + 120.04003542753343936, 22.252705146580410656, 45.740189453113998752, 118.67787711627897806, + 75.874871741270908387, 63.723868036795465741, 5.2863059365081426222, 115.8777829062564706, + 74.890537658360699425, 90.389191029003995936, 73.384737561093061231, 32.001101680496503832, + 107.5535730308984057, 96.746359187505731825, 96.875817660613392945, 67.010881503407290438, + 7.4904690816256334074, 83.689120491046196548, 0.96765217756183119491, 120.24429820156365167, + 86.695550875490880571, 100.48767689503438305, 55.856330094065924641, 81.38231036384604522, + 9.9276140996626054402, 36.380926487810938852, 43.919855448682938004, 27.590998365383711644, + 32.445586257668765029, 68.382476637591025792, 122.86317917803899036, 86.272447079449193552, + 70.921874118317646207, 108.43693614390940638, 38.909102999918104615, 90.903742991122271633, + 17.950447929393703816, 79.968253324208490085, 89.213533406815258786, 54.795052702029352076, + 48.24589189426478697, 66.755139395951118786, 3.1593778236565412953, 64.365702148465061327, + 111.93545786703180056, 126.84795915631548269, 55.318352876351127634, 30.628037317601410905, + 27.385897358046349837, 11.353687341510521946, 30.355745578341156943, 91.884117795372731052, + 116.80384866644453723, 94.420351639109867392, 11.883442014393949648, 111.82625895324599696, + 22.263446951856167288, 26.606686420487676514, 95.571935460538952611, 75.816532981163618388, + 72.845091107141342945, 74.983766328430647263, 22.540795514789351728, 48.536429484527616296, + 107.38818806701237918, 59.527368920233129757, 82.75275122296079644, 15.764715180830535246, + 47.655004494223248912, 60.206767809762823163, 11.738465062269824557, 110.22509365116275148, + 92.046460012948955409, 27.771455550613609375, 34.126917872781632468, 119.46592780395076261, + 69.477315965745219728, 115.34998290840303525, 10.577626275360671571, 112.09904062179339235, + 27.067452510495058959, 13.785987537008622894, 42.438675237772258697, 114.66020705837217974, + 28.78306181967491284, 5.4138289926668221597, 113.06230029859943897, 91.280865566925058374, + 37.254845673171075759, 13.788879712225025287, 56.456691892311937409, 89.968376135442667874, + 34.957568875473953085, 44.729049106390448287, 113.02115960608352907, 33.724214116231451044, + 65.639113631510554114, 29.288792852243204834, 19.822967504176631337, 71.135108071142894914, + 84.649140275661920896, 69.061254194824869046, 88.659855391979363048, 110.09579955895605963, + 67.689578869863908039, 33.63586432765077916, 7.1261759443368646316, 30.223406441265979083, + 95.179959663964837091, 116.15054940984919085, 114.25643088964352501, 70.300600883307197364, + 110.15945732187537942, 125.86753187172143953, 53.165333766864932841, 26.176685469257790828, + 122.1497308283833263, 2.4380414779734564945, 87.132596892533911159, 29.344972835042426595, + 21.308023854904604377, 117.06876151254255092, 107.67869596269883914, 101.50215945574382204, + 86.144730812735360814, 109.44718248994468013, 55.063652414224634413, 108.61370401456952095, + 59.501604734567081323, 68.834229947791754967, 65.75975152225146303, 124.8483007204849855, + 2.5464790894693578593, 34.041335944937600289, 125.12236487028349075, 54.770190386221656809, + 100.06444670839846367, 94.960421267365745734, 36.430576461789314635, 92.003069273487199098, + 39.274543045194150181, 117.55603914419407374, 110.53178973936155671, 118.53530616892385297, + 9.6761455275809566956, 76.557400471203436609, 57.955513261149462778, 119.74665876570725231, + 98.374991898977896199, 7.9671559794041968416, 32.651641298874892527, 125.61840188955466147, + 83.818601230061176466, 127.31804902801013668, 71.921477406107442221, 32.903304176943493076, + 75.66284069390167133, 15.776100407121703029, 51.017330629452771973, 87.881339565199596109, + 61.052847532762825722, 11.042834332271013409, 101.59969133618869819, 13.031520842356258072, + 1.2101533869499689899, 3.0416777864629693795, 12.586153491407458205, 24.83812762506204308, + 89.951038003498979378, 84.104707938702631509, 22.11192117241807864, 26.167528191541350679, + 23.984803497318353038, 25.953512277254048968, 121.51232694000646006, 122.30418147070668056, + 62.155495155006065033, 87.578017011175688822, 33.564399489296192769, 95.304118090691190446, + 65.050481265483540483, 90.806837193988030776, 74.82844273881346453, 0.095901194108591880649, + 92.472270110331010073, 3.0687851062139088754, 23.655103047658485593, 126.7806836967538402, + 15.944720546354801627, 50.335628061609895667, 70.20890853890159633, 42.182320803796756081, + 117.55783278726448771, 89.098201533473911695, 35.329509325092658401, 3.3803441509953700006, + 103.98740373003965942, 51.19012145045780926, 58.802855963691399666, 74.269833588215988129, + 47.975394322478678077, 73.700784801254485501, 87.867536439407558646, 18.32610732418106636, + 75.633188319712644443, 113.09920329121814575, 48.549680591804644791, 0.18478750593567383476, + 120.02363615007925546, 16.578491822838259395, 91.558433514244825346, 62.36382725305884378, + 35.303165637760685058, 85.129636252109776251, 22.665077249352179933, 51.655842545671475818, + 93.840346375684021041, 65.886898255979758687, 90.549556603520613862, 108.45614203624063521, + 83.742282248804258415, 19.136309302277368261, 28.676429899602226214, 67.519280561282357667, + 9.5044985722488490865, 34.805208574576681713, 17.696501916041597724, 21.658120909971330548, + 36.263061043566267472, 0.39956757225809269585, 103.05987365358669194, 99.849728548506391235, + 62.19490059576855856, 115.55489494126595673, 115.26970839931891533, 15.39095234652995714, + 59.040178104485676158, 61.713539497999590822, 119.132789058941853, 22.385073480141727487, + 30.314002513219747925, 60.653383685061271535, 23.193747277728107292, 6.796568028559704544, + 110.8219166813796619, 51.629779374499776168, 88.85744249462368316, 75.469885057405917905, + 93.241317826323211193, 8.3766365205738111399, 88.930367509430652717, 96.363014495658717351, + 118.60143839035299607, 55.466969479639374185, 72.935197548260475742, 39.640199042481981451, + 102.03173178372526309, 67.115523932247015182, 3.3642654143077379558, 37.165202620559284696, + 92.263209628203185275, 25.229098195726692211, 20.901935837246128358, 18.089171071922464762, + 89.520130264067120152, 0.13645707760952063836, 69.464509485642338404, 111.67738671714323573, + 116.64706961512274574, 99.164220256134285592, 41.033654720758931944, 100.34956789229909191, + 1.8666389130012248643, 63.87508032082405407, 73.759372584612719947, 16.483199292782956036, + 15.962174308042449411, 6.9340911392609996255, 25.159287325681361835, 110.18151462458263268, + 77.771120076798979426, 28.011055978135118494, 88.906489342549321009, 9.4999295440538844559, + 97.845236083161580609, 49.366786054513795534, 28.483703672955016373, 101.64182916747449781, + 45.730206055312009994, 80.626243186248757411, 118.51324768248741748, 35.322293596174858976, + 71.041205807519872906, 87.53544891785713844, 38.850702455605642172, 45.504005314764071954, + 60.009324076327175135, 73.544559337613463867, 21.125188575089850929, 24.571756926765374374, + 26.590472889332886552, 83.606764989504881669, 42.712954394028201932, 70.202622945569601143, + 34.851775586408621166, 93.052513640137476614, 33.679700552263966529, 12.787789754740515491, + 52.756174504138471093, 43.615228883219970157, 22.684507809106435161, 38.313980182614614023, + 35.09969250881113112, 49.093031832668202696, 36.700158065959840314, 97.225202390989579726, + 58.574101378337218193, 25.552085419229115359, 84.977968044797307812, 126.09220795122018899, + 62.284197024735476589, 16.735513520940003218, 98.431381280515779508, 107.03642982136079809, + 18.912516310632781824, 59.056662117822270375, 27.109765576075005811, 91.53009897778974846, + 23.492143642513838131, 127.52106996786824311, 60.360342852494795807, 3.972443989336170489, + 40.908547307069966337, 0.28774777104990789667, 123.41898838242195779, 0.59103487155152834021, + 42.615849874629930127, 80.565207347015530104, 125.89836113795900019, 63.718035552385117626, + 19.947816476691514254, 31.04185885185142979, 127.81426826194001478, 78.761904736475116806, + 47.32586633713071933, 115.42373342734208563, 91.746845772377128014, 2.8589787720047752373, + 28.834054423903580755, 100.86092522710168851, 75.977051395519083599, 88.043971699789835839, + 91.783027922880137339, 34.897617998420173535, 96.33757026926468825, 38.916657863795990124, + 123.07722172087960644, 9.9456815022458613385, 104.36027728472254239, 101.26283920222340384, + 44.478645191928080749, 35.298763273571239552, 0.011904552706255344674, 52.100249481536593521, + 3.3068053818897169549, 23.630811357386846794, 33.113462916600838071, 55.216708143940195441, + 104.69761815714082331, 58.661905765820847591, 112.08007085506687872, 44.505410293160821311, + 91.480378906231635483, 109.35575423256159411, 23.749743482541816775, 127.44773607359093148, + 10.572611873019923223, 103.75556581251657917, 21.781075316725036828, 52.778382058011629852, + 18.769475122186122462, 64.002203360996645642, 87.107146061800449388, 65.492718375015101628, + 65.75163532123042387, 6.0217630068145808764, 14.980938163254904794, 39.378240982092393097, + 1.9353043551273003686, 112.48859640313094133, 45.391101750985399121, 72.975353790068766102, + 111.71266018813548726, 34.764620727692090441, 19.85522819932521088, 72.761852975621877704, + 87.839710897365876008, 55.181996730767423287, 64.891172515341168037, 8.7649532751856895629, + 117.72635835608161869, 44.544894158902025083, 13.843748236638930393, 88.873872287818812765, + 77.818205999839847209, 53.807485982244543266, 35.900895858791045612, 31.936506648420618149, + 50.427066813630517572, 109.59010540405870415, 96.491783788533211919, 5.5102787919022375718, + 6.3187556473167205695, 0.73140429693376063369, 95.8709157340672391, 125.69591831263096537, + 110.63670575270225527, 61.25607463520282181, 54.771794716092699673, 22.707374683021043893, + 60.711491156685951864, 55.768235590749100083, 105.60769733289271244, 60.840703278219734784, + 23.766884028791537276, 95.652517906491993926, 44.526893903712334577, 53.213372840978991007, + 63.143870921081543202, 23.633065962330874754, 17.69018221428632387, 21.967532656861294527, + 45.081591029578703456, 97.072858969058870571, 86.776376134024758358, 119.05473784046989749, + 37.50550244592159288, 31.529430361661070492, 95.310008988446497824, 120.41353561952564633, + 23.476930124543287093, 92.450187302329140948, 56.092920025897910818, 55.542911101227218751, + 68.253835745566902915, 110.9318556079051632, 10.954631931494077435, 102.69996581680607051, + 21.15525255072498112, 96.198081243586784694, 54.134905020990117919, 27.571975074017245788, + 84.877350475548155373, 101.32041411674435949, 57.56612363934982568, 10.827657985337282298, + 98.124600597202515928, 54.561731133850116748, 74.509691346342151519, 27.577759424450050574, + 112.9133837846275128, 51.936752270885335747, 69.91513775094790617, 89.458098212784534553, + 98.04231921216705814, 67.448428232466540067, 3.2782272630211082287, 58.577585704486409668, + 39.645935008356900653, 14.270216142289427808, 41.29828055132747977, 10.122508389653376071, + 49.319710783962364076, 92.191599117915757233, 7.3791577397278160788, 67.271728655301558319, + 14.252351888673729263, 60.446812882535596145, 62.359919327933312161, 104.30109881970201968, + 100.51286177929068799, 12.601201766618032707, 92.31891464375439682, 123.73506374344287906, + 106.33066753372986568, 52.353370938519219635, 116.2994616567666526, 4.8760829559505509678, + 46.265193785067822319, 58.689945670084853191, 42.616047709812846733, 106.13752302508873981, + 87.357391925401316257, 75.004318911491282051, 44.289461625474359607, 90.894364979889360256, + 110.1273048284529068, 89.227408029139041901, 119.00320946913780062, 9.668459895587147912, + 3.5195030445065640379, 121.69660144096997101, 5.0929581789387157187, 68.082671889878838556, + 122.24472974056698149, 109.5403807724469516, 72.128893416800565319, 61.920842534731491469, + 72.861152923582267249, 56.006138546974398196, 78.549086090391938342, 107.11207828839178546, + 93.063579478726751404, 109.07061233784770593, 19.35229105516555137, 25.114800942406873219, + 115.91102652230256354, 111.49331753141814261, 68.749983797955792397, 15.934311958808393683, + 65.303282597753423033, 123.23680377911296091, 39.63720246012599091, 126.63609805602391134, + 15.842954812214884441, 65.80660835389062413, 23.325681387803342659, 31.552200814243406057, + 102.03466125890918192, 47.762679130399192218, 122.10569506552565144, 22.085668664545664797, + 75.199382672377396375, 26.063041684712516144, 2.4203067738999379799, 6.083355572925938759, + 25.17230698281491641, 49.676255250127724139, 51.902076007001596736, 40.209415877405263018, + 44.223842344836157281, 52.335056383082701359, 47.969606994636706077, 51.907024554511735914, + 115.02465388001655811, 116.60836294141336111, 124.31099031001576805, 47.156034022351377644, + 67.128798978596023517, 62.60823618138601887, 2.1009625309707189444, 53.613674387979699532, + 21.65688547762692906, 0.19180238822082174011, 56.944540220662020147, 6.1375702124278177507, + 47.310206095320609165, 125.56136739350768039, 31.889441092709603254, 100.67125612322342931, + 12.41781707780319266, 84.364641607597150141, 107.11566557453261339, 50.19640306694782339, + 70.659018650185316801, 6.76068830199437798, 79.974807460079318844, 102.38024290091561852, + 117.60571192738643731, 20.539667176431976259, 95.950788644960994134, 19.401569602512608981, + 47.735072878815117292, 36.652214648365770699, 23.266376639428926865, 98.198406582436291501, + 97.099361183609289583, 0.36957501187498564832, 112.04727230015851092, 33.156983645680156769, + 55.116867028489650693, 124.72765450611768756, 70.606331275525008095, 42.259272504219552502, + 45.330154498704359867, 103.31168509134658962, 59.68069275137168006, 3.7737965119631553534, + 53.099113207044865703, 88.912284072484908393, 39.484564497608516831, 38.272618604554736521, + 57.352859799208090408, 7.0385611225647153333, 19.008997144497698173, 69.610417149153363425, + 35.393003832083195448, 43.316241819942661095, 72.526122087132534944, 0.7991351445198233705, + 78.119747307177021867, 71.699457097012782469, 124.3898011915407551, 103.10978988253555144, + 102.53941679863783065, 30.78190469305991428, 118.08035620897135232, 123.42707899600281962, + 110.265578117883706, 44.770146960283454973, 60.62800502643949585, 121.30676737012254307, + 46.387494555456214584, 13.593136057123047067, 93.643833362759323791, 103.25955874900319031, + 49.714884989251004299, 22.939770114815473789, 58.482635652646422386, 16.753273041151260259, + 49.860735018864943413, 64.726028991321072681, 109.20287678070599213, 110.93393895928238635, + 17.870395096520951483, 79.28039808496760088, 76.063463567454164149, 6.2310478644940303639, + 6.7285308286154759116, 74.330405241122207372, 56.52641925640637055, 50.458196391453384422, + 41.803871674492256716, 36.178342143848567503, 51.040260528134240303, 0.27291415522267925553, + 10.929018971288314788, 95.354773434290109435, 105.29413923024912947, 70.328440512268571183, + 82.067309441521501867, 72.699135784598183818, 3.7332778260024497285, 127.75016064165174612, + 19.518745169225439895, 32.966398585565912072, 31.924348616084898822, 13.868182278521999251, + 50.31857465136636165, 92.363029249168903334, 27.542240153597958852, 56.022111956273874966, + 49.812978685098642018, 18.999859088111406891, 67.690472166323161218, 98.733572109027591068, + 56.967407345913670724, 75.283658334948995616, 91.460412110627657967, 33.2524863725011528, + 109.02649536497483496, 70.644587192353355931, 14.08241161504338379, 47.07089783571427688, + 77.701404911211284343, 91.008010629528143909, 120.01864815265798825, 19.089118675226927735, + 42.250377150179701857, 49.143513853530748747, 53.180945778669411084, 39.213529979009763338, + 85.425908788060041843, 12.405245891139202286, 69.703551172820880311, 58.105027280274953227, + 67.359401104527933057, 25.575579509481030982, 105.51234900827694219, 87.230457766439940315, + 45.369015618212870322, 76.627960365229228046, 70.199385017622262239, 98.186063665336405393, + 73.400316131923318608, 66.450404781979159452, 117.14820275667443639, 51.104170838461868698, + 41.955936089598253602, 124.18441590244037798, 124.56839404947095318, 33.471027041883644415, + 68.862762561035196995, 86.072859642721596174, 37.825032621265563648, 118.11332423564454075, + 54.2195311521536496, 55.06019795557949692, 46.984287285031314241, 127.04213993573648622, + 120.72068570498959161, 7.9448879786723409779, 81.817094614139932673, 0.57549554210345377214, + 118.83797676484391559, 1.1820697431030566804, 85.231699749263498234, 33.130414694034698186, + 123.79672227591800038, 127.43607110477023525, 39.895632953383028507, 62.083717703706497559, + 127.62853652388366754, 29.523809472950233612, 94.651732674265076639, 102.84746685468780925, + 55.493691544754256029, 5.7179575440095504746, 57.668108847810799489, 73.721850454207014991, + 23.954102791041805176, 48.087943399583309656, 55.566055845760274678, 69.795235996843985049, + 64.675140538529376499, 77.833315727595618227, 118.15444344175921287, 19.891363004495360656, + 80.720554569448722759, 74.52567840444680769, 88.957290383856161498, 70.597526547142479103, + 0.023809105412510689348, 104.20049896307318704, 6.6136107637794339098, 47.261622714773693588, + 66.226925833201676141, 110.43341628788402886, 81.395236314281646628, 117.32381153164533316, + 96.160141710133757442, 89.010820586325280601, 54.960757812466908945, 90.711508465123188216, + 47.499486965087271528, 126.89547214718186297, 21.145223746043484425, 79.511131625033158343, + 43.562150633450073656, 105.5567641160232597, 37.538950244375882903, 0.0044067219969292636961, + 46.214292123604536755, 2.9854367500338412356, 3.5032706424608477391, 12.043526013629161753, + 29.961876326509809587, 78.756481964184786193, 3.8706087102582387161, 96.977192806261882652, + 90.782203501974436222, 17.950707580141170183, 95.425320376270974521, 69.529241455384180881, + 39.71045639865405974, 17.523705951247393386, 47.679421794731752016, 110.36399346153848455, + 1.7823450306823360734, 17.529906550375017105, 107.45271671216323739, 89.089788317804050166, + 27.687496473281498766, 49.747744575641263509, 27.636411999679694418, 107.61497196448908653, + 71.801791717582091223, 63.873013296841236297, 100.85413362726467312, 91.180210808121046284, + 64.983567577066423837, 11.020557583804475144, 12.637511294633441139, 1.4628085938711592462, + 63.741831468138116179, 123.39183662526556873, 93.273411505404510535, 122.51214927040564362, + 109.54358943218539935, 45.414749366042087786, 121.42298231337190373, 111.53647118150183815, + 83.215394665785424877, 121.68140655643946957, 47.53376805758671253, 63.305035812983987853, + 89.053787807424669154, 106.42674568195798201, 126.2877418421630864, 47.266131924661749508, + 35.380364428572647739, 43.935065313722589053, 90.16318205916104489, 66.14571793812137912, + 45.552752268053154694, 110.10947568093979498, 75.01100489184318576, 63.058860723325778963, + 62.620017976896633627, 112.82707123905129265, 46.953860249090212164, 56.900374604658281896, + 112.18584005179582164, 111.08582220245807548, 8.5076714911374438088, 93.863711215810326394, + 21.909263862991792848, 77.399931633612141013, 42.310505101453600219, 64.396162487173569389, + 108.26981004198023584, 55.143950148038129555, 41.754700951099948725, 74.640828233488718979, + 115.13224727869965136, 21.655315970678202575, 68.249201194405031856, 109.12346226770387148, + 21.019382692684303038, 55.155518848903739126, 97.826767569255025592, 103.87350454177430947, + 11.830275501899450319, 50.916196425572707085, 68.084638424337754259, 6.8968564649330801331, + 6.5564545260422164574, 117.15517140897281934, 79.291870016713801306, 28.540432284578855615, + 82.596561102654959541, 20.245016779306752142, 98.63942156792836613, 56.383198235831514467, + 14.758315479459270136, 6.543457310603116639, 28.504703777347458526, 120.89362576507119229, + 124.7198386558702623, 80.602197639407677343, 73.025723558581375983, 25.202403533239703393, + 56.63782928751243162, 119.4701274868893961, 84.661335067459731363, 104.70674187704207725, + 104.59892331353330519, 9.7521659119011019357, 92.530387570135644637, 117.37989134016970638, + 85.232095419629331445, 84.275046050181117607, 46.714783850806270493, 22.008637822982564103, + 88.578923250952357193, 53.788729959782358492, 92.254609656909451587, 50.45481605828172178, + 110.00641893827560125, 19.336919791174295824, 7.0390060890167660546, 115.39320288194358, + 10.185916357881069416, 8.1653437797613150906, 116.48945948113760096, 91.080761544897541171, + 16.257786833601130638, 123.84168506946662092, 17.722305847164534498, 112.01227709395243437, + 29.098172180787514662, 86.224156576787208905, 58.127158957457140787, 90.141224675695411861, + 38.70458211033110274, 50.229601884817384416, 103.82205304460876505, 94.986635062839923194, + 9.4999675959115847945, 31.868623917620425345, 2.6065651955104840454, 118.47360755822592182, + 79.2744049202556198, 125.27219611204782268, 31.685909624433406861, 3.6132167077812482603, + 46.651362775606685318, 63.104401628490450094, 76.069322517818363849, 95.525358260802022414, + 116.21139013105130289, 44.171337329094967572, 22.39876534475479275, 52.126083369425032288, + 4.8406135477998759598, 12.166711145851877518, 50.344613965629832819, 99.352510500255448278, + 103.80415201400319347, 80.418831754810526036, 88.447684689672314562, 104.67011276616540272, + 95.939213989273412153, 103.81404910902710981, 102.04930776003675419, 105.21672588283036021, + 120.62198062003153609, 94.312068044706393266, 6.2575979571920470335, 125.21647236277203774, + 4.2019250619414378889, 107.22734877595939906, 43.313770955253858119, 0.38360477644164348021, + 113.88908044132404029, 12.275140424855635501, 94.62041219064485631, 123.12273478701536078, + 63.778882185422844486, 73.342512246446858626, 24.835634155610023299, 40.729283215197938262, + 86.231331149065226782, 100.39280613389928476, 13.318037300370633602, 13.521376603992393939, + 31.949614920162275666, 76.760485801834875019, 107.21142385477287462, 41.079334352867590496, + 63.901577289921988267, 38.803139205025217962, 95.470145757630234584, 73.304429296731541399, + 46.532753278861491708, 68.396813164876220981, 66.198722367218579166, 0.73915002375360927545, + 96.094544600317021832, 66.313967291360313538, 110.23373405698293936, 121.4553090122390131, + 13.212662551050016191, 84.518545008439105004, 90.660308997412357712, 78.623370182693179231, + 119.36138550274336012, 7.5475930239263107069, 106.19822641409336939, 49.824568144969816785, + 78.969128995217033662, 76.545237209109473042, 114.70571959841618082, 14.077122245129430667, + 38.017994288999034325, 11.220834298306726851, 70.786007664166390896, 86.63248363988896017, + 17.052244174265069887, 1.5982702890432847198, 28.239494614357681712, 15.398914194029202918, + 120.77960238308514818, 78.219579765074740862, 77.078833597275661305, 61.563809386123466538, + 108.16071241794634261, 118.85415799200927722, 92.531156235767411999, 89.540293920566909947, + 121.25601005288262968, 114.61353474024508614, 92.774989110912429169, 27.186272114249732113, + 59.28766672552228556, 78.519117498006380629, 99.429769978502008598, 45.879540229630947579, + 116.96527130529284477, 33.506546082302520517, 99.721470037733524805, 1.4520579826457833406, + 90.405753561415622244, 93.867877918564772699, 35.740790193045540946, 30.560796169938839739, + 24.126927134908328298, 12.462095728988060728, 13.457061657234589802, 20.660810482244414743, + 113.0528385128127411, 100.91639278290676884, 83.607743348984513432, 72.356684287697135005, + 102.08052105626848061, 0.54582831044535851106, 21.858037942580267554, 62.709546868583856849, + 82.588278460501896916, 12.656881024540780345, 36.134618883046641713, 17.398271569196367636, + 7.4665556520085374359, 127.50032128330349224, 39.03749033845087979, 65.932797171131824143, + 63.848697232169797644, 27.736364557043998502, 100.63714930273636128, 56.726058498337806668, + 55.084480307195917703, 112.04422391254774993, 99.625957370197284035, 37.99971817622645176, + 7.3809443326499604154, 69.467144218055182137, 113.93481469183097943, 22.567316669901629211, + 54.920824221255315933, 66.50497274500594358, 90.052990729953307891, 13.289174384706711862, + 28.16482323008676758, 94.141795671432191739, 27.402809822426206665, 54.016021259059925796, + 112.0372963053159765, 38.17823735045385547, 84.500754300359403715, 98.287027707061497495, + 106.36189155733882217, 78.427059958023164654, 42.851817576120083686, 24.81049178228204255, + 11.407102345641760621, 116.21005456055354443, 6.7188022090558661148, 51.151159018965699943, + 83.024698016557522351, 46.460915532879880629, 90.738031236429378623, 25.25592073046209407, + 12.398770035248162458, 68.372127330676448764, 18.800632263850275194, 4.9008095639619568828, + 106.29640551334887277, 102.2083416769237374, 83.911872179200145183, 120.36883180488439393, + 121.13678809894190636, 66.942054083770926809, 9.7255251220740319695, 44.145719285443192348, + 75.650065242534765275, 108.2266484712890815, 108.4390623043072992, 110.12039591115899384, + 93.96857457006626646, 126.08427987147661042, 113.44137140997918323, 15.889775957348319935, + 35.634189228279865347, 1.1509910842105455231, 109.67595352968783118, 2.3641394862097513396, + 42.463399498526996467, 66.260829388073034352, 119.59344455183963873, 126.8721422095404705, + 79.791265906766057014, 124.1674354074166331, 127.25707304776733508, 59.047618945904105203, + 61.303465348533791257, 77.694933709375618491, 110.98738308950851206, 11.435915088019100949, + 115.33621769562523696, 19.443700908414029982, 47.908205582083610352, 96.175886799166619312, + 111.13211169152418734, 11.590471993691608077, 1.3502810770623909775, 27.666631455194874434, + 108.30888688351842575, 39.78272600899435929, 33.441109138901083497, 21.051356808897253359, + 49.914580767715960974, 13.195053094284958206, 0.047618210828659357503, 80.400997926146374084, + 13.22722152755886782, 94.523245429551025154, 4.4538516664069902617, 92.866832575771695701, + 34.790472628566931235, 106.6476230632943043, 64.320283420271152863, 50.021641172650561202, + 109.92151562493745587, 53.423016930246376432, 94.998973930178181035, 125.79094429436372593, + 42.290447492090606829, 31.022263250066316687, 87.12430126690378529, 83.113528232046519406, + 75.077900488751765806, 0.0088134439938585273921, 92.42858424720907351, 5.9708735000676824711, + 7.0065412849216954783, 24.087052027258323506, 59.923752653023257153, 29.512963928369572386, + 7.7412174205201154109, 65.954385612527403282, 53.564407003948872443, 35.901415160285978345, + 62.85064075254558702, 11.058482910768361762, 79.42091279730811948, 35.047411902494786773, + 95.35884358946714201, 92.727986923076969106, 3.5646900613646721467, 35.059813100753672188, + 86.905433424330112757, 50.179576635608100332, 55.374992946562997531, 99.495489151282527018, + 55.272823999363026815, 87.229943928981811041, 15.603583435164182447, 127.74602659368611057, + 73.708267254532984225, 54.360421616245730547, 1.9671351541328476742, 22.041115167608950287, + 25.275022589266882278, 2.9256171877423184924, 127.48366293627987034, 118.78367325053477543, + 58.546823010812659049, 117.02429854081492522, 91.087178864370798692, 90.829498732087813551, + 114.84596462674744544, 95.07294236300731427, 38.430789331574487733, 115.36281311287893914, + 95.06753611517342506, 126.61007162597161368, 50.107575614852976287, 84.853491363919602009, + 124.57548368432617281, 94.532263849323499016, 70.760728857145295478, 87.870130627448816085, + 52.326364118325727759, 4.2914358762427582406, 91.105504536109947367, 92.218951361883227946, + 22.02200978368637152, 126.11772144665155793, 125.24003595379690523, 97.654142478102585301, + 93.907720498180424329, 113.80074920932020177, 96.371680103595281253, 94.171644404916150961, + 17.015342982278525596, 59.727422431620652787, 43.818527725987223675, 26.799863267224282026, + 84.621010202910838416, 0.79232497435077675618, 88.539620083960471675, 110.28790029607625911, + 83.509401902203535428, 21.281656466981075937, 102.26449455739930272, 43.310631941360043129, + 8.4984023888137016911, 90.246924535407742951, 42.038765385368606076, 110.31103769781111623, + 67.653535138513689162, 79.747009083548618946, 23.660551003798900638, 101.83239285114905215, + 8.1692768486755085178, 13.793712929866160266, 13.112909052088070894, 106.31034281794927665, + 30.583740033427602611, 57.080864569161349209, 37.193122205309919082, 40.490033558617142262, + 69.27884313585673226, 112.76639647166302893, 29.516630958918540273, 13.086914621206233278, + 57.009407554698555032, 113.78725153014602256, 121.43967731174416258, 33.204395278818992665, + 18.051447117162751965, 50.404807066479406785, 113.27565857502850122, 110.94025497378243017, + 41.322670134923100704, 81.413483754087792477, 81.197846627066610381, 19.50433182380584185, + 57.060775140274927253, 106.75978268034305074, 42.464190839262300869, 40.550092100362235215, + 93.429567701612540986, 44.017275645968766185, 49.157846501904714387, 107.57745991956835496, + 56.509219313818903174, 100.90963211656708154, 92.012837876551202498, 38.673839582348591648, + 14.078012178037170088, 102.78640576389079797, 20.371832715762138832, 16.33068755952626816, + 104.9789189622788399, 54.161523089795082342, 32.515573667205899255, 119.68337013893324183, + 35.444611694332706975, 96.024554187904868741, 58.196344361578667304, 44.448313153574417811, + 116.25431791491791955, 52.282449351390823722, 77.40916422066220548, 100.45920376963840681, + 79.644106089221168077, 61.973270125679846387, 18.999935191823169589, 63.737247835240850691, + 5.2131303910246060695, 108.94721511645548162, 30.548809840514877578, 122.54439222409564536, + 63.371819248866813723, 7.2264334155624965206, 93.302725551213370636, 126.20880325698453817, + 24.138645035640365677, 63.050716521607682807, 104.42278026210260577, 88.342674658189935144, + 44.7975306895095855, 104.25216673885006458, 9.6812270955997519195, 24.333422291703755036, + 100.68922793126330362, 70.705021000514534535, 79.608304028010024922, 32.83766350962469005, + 48.895369379348267103, 81.340225532334443415, 63.878427978550462285, 79.628098218057857594, + 76.098615520077146357, 82.43345176566435839, 113.24396124006671016, 60.624136089412786532, + 12.515195914387732046, 122.43294472554407548, 8.4038501238865137566, 86.454697551918798126, + 86.627541910507716238, 0.76720955288692493923, 99.778160882648080587, 24.550280849714908982, + 61.240824381293350598, 118.24546957403072156, 127.55776437084932695, 18.685024492893717252, + 49.671268311220046598, 81.458566430399514502, 44.462662298134091543, 72.785612267798569519, + 26.636074600741267204, 27.042753207984787878, 63.899229840328189312, 25.520971603673388017, + 86.42284770954574924, 82.158668705735180993, 127.80315457984397653, 77.606278410054073902, + 62.940291515264107147, 18.608858593463082798, 93.065506557726621395, 8.7936263297560799401, + 4.3974447344371583313, 1.4783000475108565297, 64.189089200637681643, 4.6279345827242650557, + 92.467468113969516708, 114.9106180244780262, 26.425325102103670361, 41.037090016881847987, + 53.320617994828353403, 29.246740365389996441, 110.72277100548672024, 15.095186047856259393, + 84.39645282818673877, 99.649136289943271549, 29.938257990437705303, 25.090474418222584063, + 101.41143919683236163, 28.154244490258861333, 76.035988577998068649, 22.44166859661709168, + 13.57201532833641977, 45.264967279777920339, 34.104488348530139774, 3.1965405780865694396, + 56.478989228715363424, 30.797828388062043814, 113.55920476617393433, 28.439159530153119704, + 26.157667194551322609, 123.12761877225057106, 88.321424835896323202, 109.70831598402219242, + 57.062312471538461978, 51.080587841137457872, 114.51202010576889734, 101.22706948049381026, + 57.549978221824858338, 54.372544228499464225, 118.5753334510482091, 29.038234996016399236, + 70.859539957004017197, 91.759080459265533136, 105.93054261058568954, 67.013092164608679013, + 71.44294007546704961, 2.9041159652952046599, 52.811507122834882466, 59.735755837129545398, + 71.481580386091081891, 61.121592339877679478, 48.253854269816656597, 24.924191457976121455, + 26.914123314469179604, 41.321620964492467465, 98.10567702562912018, 73.832785565817175666, + 39.215486697972664842, 16.713368575397907989, 76.161042112536961213, 1.0916566208907170221, + 43.716075885160535108, 125.41909373717135168, 37.176556921003793832, 25.31376204908156069, + 72.269237766093283426, 34.796543138392735273, 14.933111304020712851, 127.00064256660698447, + 78.074980676905397559, 3.8655943422636482865, 127.69739446433959529, 55.472729114091634983, + 73.274298605472722556, 113.45211699667561334, 110.16896061439547339, 96.088447825099137845, + 71.251914740394568071, 75.99943635245290352, 14.76188866530355881, 10.934288436114002252, + 99.869629383661958855, 45.134633339803258423, 109.84164844251426985, 5.009945490015525138, + 52.105981459906615783, 26.578348769413423724, 56.32964646017717314, 60.283591342864383478, + 54.80561964485241333, 108.03204251812348957, 96.074592610631952994, 76.356474700911348918, + 41.001508600722445408, 68.574055414126632968, 84.723783114681282314, 28.854119916046329308, + 85.703635152240167372, 49.6209835645640851, 22.814204691287159221, 104.42010912110708887, + 13.43760441811173223, 102.30231803793503786, 38.049396033115044702, 92.921831065763399238, + 53.476062472858757246, 50.511841460924188141, 24.797540070499962894, 8.7442546613528975286, + 37.601264527700550389, 9.8016191279275517445, 84.592811026701383526, 76.41668335385111277, + 39.823744358403928345, 112.73766360977242584, 114.27357619788745069, 5.8841081675418536179, + 19.451050244148063939, 88.291438570890022675, 23.300130485073168529, 88.453296942581800977, + 88.87812460861823638, 92.240791822321625659, 59.937149140136170899, 124.16855974295685883, + 98.882742819958366454, 31.779551914696639869, 71.268378456559730694, 2.301982168424729025, + 91.351907059375662357, 4.7282789724195026793, 84.926798997057630913, 4.5216587761497066822, + 111.18688910368291545, 125.74428441908457899, 31.582531813535752008, 120.33487081483690417, + 126.51414609553467017, 118.09523789180821041, 122.60693069707122049, 27.389867418754874961, + 93.974766179017024115, 22.871830176041839877, 102.67243539125047391, 38.887401816828059964, + 95.816411164170858683, 64.351773598336876603, 94.264223383048374671, 23.180943987383216154, + 2.700562154124781955, 55.333262910393386846, 88.617773767036851496, 79.56545201798871858, + 66.882218277802166995, 42.102713617794506717, 99.829161535431921948, 26.390106188569916412, + 0.095236421660956693813, 32.801995852292748168, 26.454443055121373618, 61.046490859102050308, + 8.9077033328176185023, 57.733665151543391403, 69.580945257137500448, 85.295246126592246583, + 0.64056684054230572656, 100.04328234530476038, 91.843031249874911737, 106.84603386049639084, + 61.99794786036000005, 123.58188858872745186, 84.580894984181213658, 62.044526500136271352, + 46.248602533811208559, 38.227056464096676791, 22.155800977503531612, 0.017626887991355033591, + 56.85716849441814702, 11.941747000135364942, 14.013082569843390957, 48.174104054516647011, + 119.84750530604651431, 59.025927856739144772, 15.482434841043868801, 3.908771225054806564, + 107.12881400789774489, 71.80283032057195669, 125.70128150509117404, 22.116965821540361503, + 30.841825594616238959, 70.094823804993211525, 62.717687178937921999, 57.455973846153938212, + 7.1293801227293442935, 70.119626201510982355, 45.810866848660225514, 100.35915327121620066, + 110.74998589312963304, 70.990978302565054037, 110.54564799872969161, 46.459887857963622082, + 31.207166870332002873, 127.49205318737585912, 19.41653450906596845, 108.72084323249146109, + 3.9342703082656953484, 44.082230335217900574, 50.550045178533764556, 5.8512343754882749636, + 126.96732587256337865, 109.56734650106955087, 117.09364602162895608, 106.04859708163348841, + 54.174357728745235363, 53.65899746417926508, 101.69192925349852885, 62.145884726014628541, + 76.861578663152613444, 102.72562622576151625, 62.135072230350488098, 125.22014325194322737, + 100.21515122970959055, 41.706982727842841996, 121.15096736865598359, 61.064527698650636012, + 13.521457714294228936, 47.74026125489763217, 104.65272823665145552, 8.5828717524891544599, + 54.211009072223532712, 56.437902723766455892, 44.044019567376381019, 124.23544289330675383, + 122.48007190759744844, 67.30828495620880858, 59.815440996364486637, 99.601498418644041521, + 64.743360207194200484, 60.343288809832301922, 34.030685964557051193, 119.45484486324130557, + 87.637055451974447351, 53.599726534452202031, 41.242020405821676832, 1.5846499487051914912, + 49.079240167924581328, 92.575800592156156199, 39.018803804407070857, 42.563312933965789853, + 76.528989114798605442, 86.621263882720086258, 16.996804777631041361, 52.493849070815485902, + 84.07753077074085013, 92.622075395625870442, 7.3070702770310163032, 31.494018167097237892, + 47.321102007601439254, 75.664785702298104297, 16.338553697351017036, 27.587425859732320532, + 26.225818104179779766, 84.620685635898553301, 61.167480066855205223, 114.16172913832269842, + 74.386244410619838163, 80.980067117237922503, 10.5576862717171025, 97.532792943326057866, + 59.033261917837080546, 26.173829242412466556, 114.01881510940074804, 99.574503060295683099, + 114.87935462348832516, 66.40879055763798533, 36.10289423432550393, 100.80961413296245155, + 98.551317150060640415, 93.88050994756486034, 82.645340269849839387, 34.826967508179222932, + 34.395693254133220762, 39.0086636476116837, 114.12155028055349248, 85.519565360686101485, + 84.928381678524601739, 81.100184200728108408, 58.859135403225081973, 88.034551291937532369, + 98.315693003813066753, 87.154919839136709925, 113.01843862764144433, 73.819264233137801057, + 56.025675753102404997, 77.347679164697183296, 28.156024356077978155, 77.57281152778523392, + 40.743665431524277665, 32.661375119056174299, 81.957837924557679798, 108.32304617959016468, + 65.03114733441543649, 111.36674027786648367, 70.889223388669051928, 64.049108375809737481, + 116.39268872315733461, 88.896626307152473601, 104.5086358298358391, 104.56489870278528542, + 26.818328441328048939, 72.918407539280451601, 31.288212178442336153, 123.94654025135969277, + 37.999870383646339178, 127.47449567048170138, 10.426260782052850118, 89.894430232910963241, + 61.097619681033393135, 117.08878444819129072, 126.74363849773362745, 14.45286683112863102, + 58.605451102430379251, 124.41760651396907633, 48.277290071280731354, 126.10143304321900359, + 80.845560524208849529, 48.685349316379870288, 89.595061379022808978, 80.504333477700129151, + 19.362454191199503839, 48.666844583411148051, 73.378455862530245213, 13.410042001032707049, + 31.216608056020049844, 65.675327019249380101, 97.790738758700172184, 34.680451064668886829, + 127.75685595710456255, 31.256196436119353166, 24.197231040157930693, 36.86690353133235476, + 98.487922480133420322, 121.24827217882557306, 25.03039182877910207, 116.86588945108815096, + 16.807700247776665492, 44.909395103841234231, 45.255083821015432477, 1.5344191057774878573, + 71.556321765296161175, 49.100561699429817963, 122.48164876259033917, 108.4909391480650811, + 127.1155287416986539, 37.370048985787434503, 99.342536622443731176, 34.917132860799029004, + 88.925324596271821065, 17.571224535597139038, 53.272149201482534409, 54.085506415969575755, + 127.79845968065637862, 51.041943207350414013, 44.845695419095136458, 36.317337411473999964, + 127.60630915969159105, 27.212556820108147804, 125.88058303052821429, 37.217717186929803574, + 58.13101311545324279, 17.58725265951215988, 8.7948894688743166625, 2.9566000950253510382, + 0.37817840127536328509, 9.2558691654521680903, 56.934936227942671394, 101.8212360489560524, + 52.850650204207340721, 82.074180033763695974, 106.64123598965670681, 58.493480730783630861, + 93.445542010973440483, 30.190372095716156764, 40.79290565637711552, 71.298272579886543099, + 59.876515980875410605, 50.180948836448806105, 74.822878393664723262, 56.308488980521360645, + 24.071977155996137299, 44.88333719323418336, 27.144030656672839541, 90.529934559555840679, + 68.208976697060279548, 6.3930811561731388792, 112.95797845743072685, 61.595656776127725607, + 99.118409532347868662, 56.878319060306239408, 52.315334389106283197, 118.25523754450478009, + 48.642849671796284383, 91.416631968044384848, 114.12462494307692396, 102.16117568227855372, + 101.02404021154143265, 74.454138960987620521, 115.09995644364971668, 108.74508845700256643, + 109.1506669020964182, 58.076469992036436452, 13.719079914011672372, 55.518160918534704251, + 83.861085221175017068, 6.0261843292209960055, 14.88588015093409922, 5.8082319305904093198, + 105.62301424566976493, 119.47151167426272877, 14.963160772182163782, 122.24318467975535896, + 96.507708539633313194, 49.848382915952242911, 53.828246628938359208, 82.643241928988572909, + 68.21135405126187834, 19.665571131634351332, 78.430973395945329685, 33.426737150799453957, + 24.322084225073922426, 2.1833132417814340442, 87.432151770324708195, 122.83818747434270335, + 74.353113842007587664, 50.627524098166759359, 16.538475532186566852, 69.593086276785470545, + 29.86622260804506368, 126.00128513321760693, 28.149961353810795117, 7.7311886845309345517, + 127.39478892867919058, 110.94545822818690795, 18.548597210949083092, 98.904233993354864651, + 92.337921228794584749, 64.176895650201913668, 14.50382948079277412, 23.998872704905807041, + 29.523777330607117619, 21.868576872231642483, 71.739258767323917709, 90.269266679610154824, + 91.683296885028539691, 10.019890980031050276, 104.21196291981323157, 53.156697538826847449, + 112.65929292035434628, 120.56718268572876696, 109.61123928970846464, 88.064085036250617122, + 64.149185221267543966, 24.712949401822697837, 82.003017201448528795, 9.1481108282569039147, + 41.447566229362564627, 57.708239832096296595, 43.407270304480334744, 99.2419671291281702, + 45.628409382577956421, 80.840218242214177735, 26.875208836227102438, 76.604636075870075729, + 76.098792066233727382, 57.843662131526798476, 106.95212494571751449, 101.02368292184837628, + 49.595080140999925788, 17.488509322705795057, 75.202529055401100777, 19.603238255858741468, + 41.18562205340640503, 24.83336670770222554, 79.647488716811494669, 97.475327219548489666, + 100.54715239577490138, 11.768216335083707236, 38.902100488299765857, 48.582877141780045349, + 46.600260970149975037, 48.906593885167239932, 49.756249217240110738, 56.481583644643251318, + 119.87429828027597978, 120.33711948591735563, 69.765485639916732907, 63.559103829396917718, + 14.536756913119461387, 4.6039643368530960288, 54.703814118751324713, 9.4565579448426433373, + 41.853597994115261827, 9.0433175523030513432, 94.373778207369468873, 123.48856883816915797, + 63.165063627075141994, 112.66974162967744633, 125.02829219107297831, 108.19047578362005879, + 117.21386139414244099, 54.779734837513387902, 59.949532358034048229, 45.743660352087317733, + 77.344870782500947826, 77.774803633659757907, 63.632822328345355345, 0.70354719667739118449, + 60.528446766096749343, 46.361887974766432308, 5.4011243082495639101, 110.66652582079041167, + 49.23554753407734097, 31.13090403598107514, 5.7644365556043339893, 84.205427235592651414, + 71.658323070863843895, 52.780212377139832824, 0.19047284332191338763, 65.603991704585496336, + 52.908886110242747236, 122.09298171820410062, 17.815406665635237005, 115.46733030309042078, + 11.161890514278638875, 42.590492253184493165, 1.2811336810882494319, 72.086564690613158746, + 55.686062499753461452, 85.692067720992781688, 123.99589572072363808, 119.1637771774585417, + 41.161789968362427317, 124.0890530002725427, 92.497205067622417118, 76.454112928193353582, + 44.311601955007063225, 0.035253775982710067183, 113.71433698883629404, 23.883494000270729885, + 28.026165139686781913, 96.348208109036932001, 111.69501061209302861, 118.05185571347828954, + 30.964869682087737601, 7.8175424501132511068, 86.257628015799127752, 15.60566064114755136, + 123.40256301018234808, 44.233931643080723006, 61.683651189236115897, 12.189647609986423049, + 125.435374357875844, 114.91194769230787642, 14.258760245462326566, 12.23925240302196471, + 91.621733697324089007, 72.718306542436039308, 93.499971786262904061, 13.981956605133746052, + 93.091295997459383216, 92.919775715927244164, 62.414333740667643724, 126.98410637475171825, + 38.833069018135574879, 89.441686464982922189, 7.8685406165313906968, 88.164460670435801148, + 101.10009035706752911, 11.702468750980187906, 125.93465174513039528, 91.134693002142739715, + 106.18729204326155013, 84.09719416326697683, 108.34871545749047073, 107.31799492836216814, + 75.383858506997057702, 124.29176945203289506, 25.723157326308864867, 77.451252451523032505, + 124.27014446070461418, 122.44028650389009272, 72.430302459419181105, 83.413965455689321971, + 114.30193473731196718, 122.12905539730127202, 27.042915428588457871, 95.48052250979890232, + 81.305456473302911036, 17.16574350497830892, 108.42201814444706542, 112.87580544753291178, + 88.088039134756400017, 120.47088578661714564, 116.96014381519853487, 6.6165699124176171608, + 119.63088199273261125, 71.202996837291721022, 1.4867204143884009682, 120.68657761966460384, + 68.061371929117740365, 110.90968972648624913, 47.274110903948894702, 107.19945306890440406, + 82.484040811643353663, 3.1692998974103829823, 98.158480335852800636, 57.151601184312312398, + 78.037607608814141713, 85.126625867935217684, 25.057978229600848863, 45.242527765440172516, + 33.993609555262082722, 104.98769814163460978, 40.155061541485338239, 57.244150791251740884, + 14.614140554062032606, 62.988036334194475785, 94.642204015206516488, 23.329571404596208595, + 32.677107394702034071, 55.174851719464641064, 52.451636208363197511, 41.241371271797106601, + 122.33496013371404842, 100.32345827664903481, 20.772488821243314305, 33.960134234475845005, + 21.115372543437842978, 67.065585886652115732, 118.06652383567416109, 52.34765848482857109, + 100.03763021880513406, 71.149006120595004177, 101.7587092469802883, 4.8175811152759706602, + 72.20578846865464584, 73.619228265928541077, 69.102634300124918809, 59.761019895133358659, + 37.290680539699678775, 69.653935016358445864, 68.791386508266441524, 78.017327295227005379, + 100.24310056111062295, 43.039130721375840949, 41.856763357052841457, 34.200368401456216816, + 117.71827080645380192, 48.069102583878702717, 68.631386007629771484, 46.309839678277057828, + 98.036877255286526633, 19.638528466275602113, 112.05135150620844797, 26.695358329394366592, + 56.312048712159594288, 27.145623055570467841, 81.487330863048555329, 65.322750238115986576, + 35.915675849118997576, 88.646092359183967346, 2.0622946688345109578, 94.733480555736605311, + 13.778446777341741836, 0.098216751623112941161, 104.78537744631830719, 49.79325261430858518, + 81.017271659675316187, 81.129797405570570845, 53.636656882659735857, 17.836815078560903203, + 62.576424356888310285, 119.89308050271938555, 75.999740767296316335, 126.94899134096340276, + 20.852521564109338215, 51.788860465821926482, 122.19523936207042425, 106.17756889638621942, + 125.48727699546725489, 28.90573366225726204, 117.21090220486439648, 120.83521302793815266, + 96.554580142565100687, 124.20286608644164517, 33.691121048417699058, 97.370698632763378555, + 51.190122758049255935, 33.008666955400258303, 38.724908382399007678, 97.33368916682593408, + 18.756911725060490426, 26.820084002065414097, 62.433216112043737667, 3.3506540385023981798, + 67.581477517400344368, 69.360902129341411637, 127.5137119142091251, 62.512392872238706332, + 48.394462080315861385, 73.733807062668347498, 68.975844960270478623, 114.49654435765114613, + 50.060783657561842119, 105.73177890217630193, 33.615400495553330984, 89.818790207682468463, + 90.510167642030864954, 3.0688382115586136933, 15.11264353059232235, 98.201123398863273906, + 116.96329752518431633, 88.981878296133800177, 126.23105748339730781, 74.740097971578506986, + 70.685073244887462351, 69.834265721601695986, 49.85064919254364213, 35.142449071194278076, + 106.54429840296506882, 108.17101283194278949, 127.59691936131275725, 102.08388641470082803, + 89.691390838190272916, 72.634674822951637907, 127.2126183193831821, 54.425113640219933586, + 123.76116606105642859, 74.435434373859607149, 116.26202623090648558, 35.174505319024319761, + 17.589778937748633325, 5.9132001900507020764, 0.75635680255072657019, 18.511738330904336181, + 113.86987245588898077, 75.6424720979121048, 105.70130040841831942, 36.148360067531029927, + 85.282471979313413613, 116.9869614615708997, 58.891084021946880966, 60.380744191432313528, + 81.585811312757869018, 14.596545159773086198, 119.75303196175082121, 100.36189767290125019, + 21.645756787329446524, 112.61697796104272129, 48.143954311992274597, 89.76667438646836672, + 54.288061313349317061, 53.059869119115319336, 8.4179533941205590963, 12.786162312349915737, + 97.915956914861453697, 123.19131355225908919, 70.236819064695737325, 113.75663812061247882, + 104.63066877821620437, 108.51047508900956018, 97.285699343596206745, 54.833263936092407675, + 100.24924988615748589, 76.322351364560745424, 74.048080423086503288, 20.908277921978879021, + 102.19991288730307133, 89.490176914008770837, 90.301333804192836396, 116.1529399840728729, + 27.438159828023344744, 111.03632183707304648, 39.722170442350034136, 12.052368658441992011, + 29.771760301868198439, 11.616463861184456619, 83.246028491343167843, 110.94302334852545755, + 29.926321544367965544, 116.48636935951435589, 65.015417079266626388, 99.696765831904485822, + 107.6564932578803564, 37.286483857980783796, 8.4227081025237566791, 39.331142263272340642, + 28.86194679189065937, 66.853474301598907914, 48.644168450147844851, 4.3666264835665060673, + 46.86430354065305437, 117.67637494868904469, 20.706227684015175328, 101.25504819633351872, + 33.076951064376771683, 11.186172553570941091, 59.732445216093765339, 124.00257026643521385, + 56.299922707621590234, 15.462377369065507082, 126.78957785736201913, 93.89091645637381589, + 37.097194421901804162, 69.808467986713367281, 56.675842457592807477, 0.35379130040382733569, + 29.007658961585548241, 47.997745409811614081, 59.047554661214235239, 43.737153744466922944, + 15.478517534651473397, 52.538533359223947627, 55.366593770057079382, 20.039781960065738531, + 80.42392583962646313, 106.31339507765733288, 97.318585840712330537, 113.13436537146117189, + 91.222478579420567257, 48.128170072504872223, 0.2983704425350879319, 49.425898803649033653, + 36.006034402897057589, 18.296221656513807829, 82.895132458725129254, 115.41647966419259319, + 86.814540608964307467, 70.483934258256340399, 91.256818765159550821, 33.68043648442835547, + 53.750417672457842855, 25.209272151743789436, 24.197584132467454765, 115.68732426305723493, + 85.904249891438666964, 74.047365843696752563, 99.190160281999851577, 34.977018645415228093, + 22.405058110802201554, 39.206476511717482936, 82.37124410681281006, 49.666733415408089058, + 31.294977433626627317, 66.95065443910061731, 73.094304791549802758, 23.536432670167414472, + 77.804200976599531714, 97.165754283560090698, 93.200521940299950074, 97.813187770334479865, + 99.512498434480221476, 112.96316728929014062, 111.74859656055559753, 112.67423897183834924, + 11.530971279833465815, 127.11820765879383544, 29.073513826238922775, 9.2079286737061920576, + 109.40762823750264943, 18.913115889685286675, 83.707195988230523653, 18.086635104609740665, + 60.747556414742575726, 118.97713767633831594, 126.33012725415392197, 97.339483259358530631, + 122.0565843821495946, 88.380951567243755562, 106.42772278828488197, 109.5594696750267758, + 119.89906471606809646, 91.487320704178273445, 26.68974156500553363, 27.549607267319515813, + 127.26564465669071069, 1.407094393354782369, 121.05689353219349869, 92.723775949532864615, + 10.802248616502765799, 93.333051641580823343, 98.47109506815468194, 62.261808071962150279, + 11.528873111212305957, 40.410854471188940806, 15.316646141727687791, 105.56042475427966565, + 0.38094568664746475406, 3.2079834091709926724, 105.81777222048913245, 116.18596343640820123, + 35.630813331274111988, 102.93466060618084157, 22.32378102855727775, 85.180984506368986331, + 2.5622673621801368427, 16.173129381226317491, 111.37212499951056088, 43.384135441989201354, + 119.99179144145091414, 110.3275543549170834, 82.323579936728492612, 120.17810600054872339, + 56.994410135248472216, 24.908225856386707164, 88.62320391001412645, 0.070507551969058113173, + 99.42867397767258808, 47.766988000541459769, 56.052330279377201805, 64.696416218077501981, + 95.390021224189695204, 108.10371142695657909, 61.929739364175475203, 15.635084900230140192, + 44.515256031598255504, 31.211321282298740698, 118.80512602036469616, 88.467863286161446013, + 123.36730237847223179, 24.379295219976484077, 122.87074871575532597, 101.82389538461575285, + 28.517520490924653132, 24.478504806047567399, 55.243467394651815994, 17.436613084875716595, + 58.999943572525808122, 27.963913210271130083, 58.18259199492240441, 57.839551431854488328, + 124.82866748133892543, 125.9682127495034365, 77.666138036274787737, 50.883372929965844378, + 15.737081233066419372, 48.328921340875240276, 74.200180714135058224, 23.404937501964013791, + 123.86930349026442855, 54.269386004289117409, 84.374584086526738247, 40.194388326537591638, + 88.697430914984579431, 86.635989856727974257, 22.767717013997753384, 120.58353890406579012, + 51.446314652621367713, 26.902504903049702989, 120.54028892141286633, 116.88057300778382341, + 16.860604918842000188, 38.82793091138228192, 100.60386947462757234, 116.25811079460254405, + 54.085830857180553721, 62.961045019601442618, 34.610912946605822071, 34.331487009960255818, + 88.844036288897768827, 97.751610895069461549, 48.176078269516438013, 112.94177157323792926, + 105.92028763039706973, 13.2331398248388723, 111.26176398546886048, 14.405993674583442044, + 2.9734408287804399151, 113.37315523933284567, 8.1227438582391187083, 93.819379452972498257, + 94.548221807901427383, 86.398906137812446104, 36.968081623286707327, 6.3385997948244039435, + 68.316960671705601271, 114.30320236862826278, 28.075215217631921405, 42.253251735870435368, + 50.115956459201697726, 90.485055530880345032, 67.987219110527803423, 81.975396283269219566, + 80.310123082970676478, 114.48830158250348177, 29.228281108124065213, 125.97607266839258955, + 61.284408030413032975, 46.659142809192417189, 65.354214789404068142, 110.34970343892928213, + 104.90327241672639502, 82.482742543597851181, 116.66992026743173483, 72.64691655329806963, + 41.544977642486628611, 67.920268468951690011, 42.230745086879323935, 6.1311717733078694437, + 108.13304767134832218, 104.69531696966078016, 72.075260437613906106, 14.298012241193646332, + 75.517418493960576598, 9.6351622305555792991, 16.411576937312929658, 19.238456531860720133, + 10.205268600249837618, 119.52203979026671732, 74.581361079402995529, 11.307870032720529707, + 9.5827730165365210269, 28.034654590457648737, 72.486201122221245896, 86.078261442751681898, + 83.713526714105682913, 68.400736802916071611, 107.43654161290760385, 96.138205167761043413, + 9.2627720152595429681, 92.619679356557753636, 68.073754510573053267, 39.277056932554842206, + 96.102703012416895945, 53.390716658788733184, 112.62409742431918858, 54.291246111144573661, + 34.974661726100748638, 2.6455004762319731526, 71.83135169824163313, 49.292184718367934693, + 4.1245893376726598945, 61.466961111473210622, 27.556893554683483671, 0.19643350324986386113, + 81.570754892636614386, 99.586505228620808339, 34.034543319354270352, 34.25959481114114169, + 107.27331376531947171, 35.673630157121806405, 125.15284871378025855, 111.78616100544240908, + 23.999481534596270649, 125.89798268192680553, 41.705043128218676429, 103.57772093164749094, + 116.39047872414448648, 84.355137792776076822, 122.97455399093450978, 57.811467324518162059, + 106.42180440973243094, 113.67042605587994331, 65.109160285133839352, 120.40573217288329033, + 67.382242096839036094, 66.74139726552675711, 102.38024551609851187, 66.017333910800516605, + 77.449816764801653335, 66.667378333651868161, 37.513823450120980851, 53.640168004130828194, + 124.86643222408747533, 6.7013080770084343385, 7.1629550348043267149, 10.721804258686461253, + 127.0274238284182502, 125.02478574447741266, 96.788924160635360749, 19.467614125340332976, + 9.9516899205445952248, 100.99308871530229226, 100.12156731512732222, 83.463557804352603853, + 67.230800991110299947, 51.637580415368574904, 53.020335284061729908, 6.1376764231172273867, + 30.225287061188282678, 68.40224679773018579, 105.92659505037227063, 49.963756592271238333, + 124.46211496679825359, 21.48019594316065195, 13.370146489778562682, 11.668531443203391973, + 99.701298385087284259, 70.284898142392194131, 85.088596805933775613, 88.342025663889216958, + 127.19383872262915247, 76.167772829405294033, 51.382781676384183811, 17.269349645906913793, + 126.42523663876636419, 108.85022728044350515, 119.52233212211649516, 20.870868747722852277, + 104.52405246181297116, 70.349010638048639521, 35.17955787549726665, 11.826400380101404153, + 1.5127136051014531404, 37.02347666181231034, 99.739744911781599512, 23.284944195827847579, + 83.402600816836638842, 72.296720135065697832, 42.564943958630465204, 105.9739229231417994, + 117.78216804389376193, 120.76148838286826503, 35.171622625515738036, 29.193090319549810374, + 111.5060639235052804, 72.723795345802500378, 43.291513574662531028, 97.23395592208544258, + 96.287908623988187173, 51.53334877293673344, 108.57612262669863412, 106.11973823823063867, + 16.835906788241118193, 25.572324624703469453, 67.831913829726545373, 118.38262710452181636, + 12.473638129395112628, 99.513276241228595609, 81.261337556436046725, 89.020950178022758337, + 66.57139868719241349, 109.66652787218845333, 72.498499772318609757, 24.644702729125128826, + 20.096160846173006576, 41.816555843961396022, 76.399825774609780638, 50.980353828021179652, + 52.602667608389310772, 104.30587996814574581, 54.876319656050327467, 94.072643674146092962, + 79.444340884700068273, 24.104737316883984022, 59.543520603736396879, 23.232927722372551216, + 38.492056982689973665, 93.8860466970509151, 59.852643088739569066, 104.97273871903234976, + 2.0308341585368907545, 71.393531663812609622, 87.312986515760712791, 74.572967715961567592, + 16.845416205047513358, 78.662284526544681285, 57.723893583784956718, 5.706948603197815828, + 97.288336900295689702, 8.7332529671330121346, 93.728607081309746718, 107.35274989737808937, + 41.412455368033988634, 74.510096392667037435, 66.153902128753543366, 22.372345107141882181, + 119.46489043219116866, 120.00514053287042771, 112.59984541524318047, 30.924754738134652143, + 125.57915571472767624, 59.781832912747631781, 74.194388843807246303, 11.616935973426734563, + 113.35168491518561495, 0.70758260080765467137, 58.015317923171096481, 95.995490819623228163, + 118.09510932242847048, 87.474307488933845889, 30.957035069302946795, 105.07706671844789525, + 110.73318754011415876, 40.07956392013511504, 32.847851679256564239, 84.626790155318303732, + 66.637171681428299053, 98.268730742925981758, 54.444957158841134515, 96.256340145009744447, + 0.5967408850701758638, 98.851797607298067305, 72.012068805794115178, 36.592443313031253638, + 37.790264917453896487, 102.83295932838882436, 45.629081217932252912, 12.967868516516318778, + 54.513637530319101643, 67.360872968856710941, 107.50083534491568571, 50.418544303487578873, + 48.395168264938547509, 103.37464852611810784, 43.808499782880971907, 20.094731687397143105, + 70.380320563999703154, 69.954037290830456186, 44.810116221604403108, 78.41295302343860385, + 36.742488213625620119, 99.333466830816178117, 62.589954867256892612, 5.9013088782048725989, + 18.188609583099605516, 47.072865340338466922, 27.608401953202701407, 66.331508567123819375, + 58.401043880603538128, 67.626375540672597708, 71.024996868964080932, 97.92633457858391921, + 95.497193121114833048, 97.348477943676698487, 23.061942559670569608, 126.23641531758767087, + 58.14702765247784555, 18.415857347416022094, 90.815256475005298853, 37.826231779374211328, + 39.414391976461047307, 36.17327020921948133, 121.49511282948878943, 109.95427535268026986, + 124.66025450831148191, 66.678966518720699241, 116.11316876430282719, 48.761903134491149103, + 84.855445576573401922, 91.118939350057189586, 111.7981294321398309, 54.97464140835654689, + 53.37948313001106726, 55.099214534642669605, 126.53128931338142138, 2.8141887867132027168, + 114.11378706439063535, 57.447551899065729231, 21.604497233009169577, 58.666103283165284665, + 68.942190136309363879, 124.52361614392430056, 23.057746222424611915, 80.821708942377881613, + 30.633292283459013561, 83.120849508559331298, 0.76189137329492950812, 6.4159668183456233237, + 83.635544440981902881, 104.37192687281640247, 71.261626662551861955, 77.869321212361683138, + 44.647562057118193479, 42.361969012737972662, 5.1245347243602736853, 32.346258762456272962, + 94.744249999021121766, 86.768270883982040687, 111.98358288290546625, 92.655108709837804781, + 36.647159873460623203, 112.35621200109744677, 113.98882027049694443, 49.816451712777052308, + 49.2464078200282529, 0.14101510394175420515, 70.85734795534517616, 95.533976001082919538, + 112.10466055875804159, 1.39283243615864194, 62.780042448383028386, 88.207422853913158178, + 123.85947872835095041, 31.270169800460280385, 89.030512063196511008, 62.422642564601119375, + 109.6102520407330303, 48.935726572326530004, 118.73460475694446359, 48.758590439956606133, + 117.74149743151428993, 75.647790769231505692, 57.035040981849306263, 48.957009612095134798, + 110.48693478930363199, 34.87322616975143319, 117.99988714505161624, 55.927826420542260166, + 116.36518398984480882, 115.67910286371261464, 121.65733496268148883, 123.93642549901051098, + 27.332276072549575474, 101.76674585993168876, 31.474162466132838745, 96.65784268175411853, + 20.400361428270116448, 46.80987500393166556, 119.73860698052885709, 108.5387720085818728, + 40.749168173053476494, 80.388776653078821255, 49.394861829972796841, 45.271979713455948513, + 45.535434027999144746, 113.16707780813158024, 102.89262930524273543, 53.805009806103043957, + 113.08057784282937064, 105.76114601556764683, 33.721209837684000377, 77.655861822768201819, + 73.207738949258782668, 104.51622158920508809, 108.17166171436110744, 125.92209003920288524, + 69.221825893211644143, 68.662974019924149616, 49.688072577799175633, 67.503221790138923097, + 96.352156539036514005, 97.8835431464794965, 83.840575260794139467, 26.46627964968138258, + 94.523527970937720966, 28.811987349166884087, 5.9468816575645178091, 98.746310478665691335, + 16.245487716481875395, 59.638758905948634492, 61.096443615806492744, 44.797812275624892209, + 73.936163246573414654, 12.677199589652445866, 8.6339213434148405213, 100.60640473725652555, + 56.15043043526384281, 84.506503471740870737, 100.23191291840703343, 52.970111061764328042, + 7.9744382210592448246, 35.950792566542077111, 32.620246165944990935, 100.97660316500696354, + 58.456562216251768405, 123.9521453367851791, 122.56881606082606595, 93.318285618388472358, + 2.7084295788117742632, 92.699406877862202236, 81.806544833456428023, 36.965485087199340342, + 105.33984053486710764, 17.29383310659613926, 83.0899552849768952, 7.8405369379033800215, + 84.46149017375864787, 12.262343546619376866, 88.266095342700282345, 81.390633939325198298, + 16.150520875227812212, 28.596024482390930643, 23.034836987921153195, 19.270324461111158598, + 32.823153874625859316, 38.476913063721440267, 20.410537200503313215, 111.04407958053707262, + 21.162722158805991057, 22.615740065441059414, 19.165546033073042054, 56.069309180918935454, + 16.972402244446129771, 44.156522885507001774, 39.427053428215003805, 8.8014736058357811999, + 86.873083225818845676, 64.276410335522086825, 18.525544030522723915, 57.23935871311914525, + 8.1475090211461065337, 78.55411386511332239, 64.205406024833791889, 106.78143331758110435, + 97.248194848638377152, 108.58249222228914732, 69.949323452201497275, 5.291000952467584284, + 15.66270339648326626, 98.584369436735869385, 8.2491786753453197889, 122.93392222294642124, + 55.113787109366967343, 0.39286700650336570106, 35.141509785276866751, 71.173010457241616677, + 68.069086638708540704, 68.519189622285921359, 86.546627530638943426, 71.34726031424725079, + 122.30569742756415508, 95.572322010884818155, 47.998963069196179276, 123.79596536385361105, + 83.410086256440990837, 79.155441863298619865, 104.78095744829261093, 40.710275585555791622, + 117.94910798186901957, 115.6229346490399621, 84.84360881946849986, 99.34085211176352459, + 2.2183205702713166829, 112.81146434577021864, 6.7644841936817101669, 5.4827945310571521986, + 76.760491032200661721, 4.0346678216046711896, 26.899633529606944649, 5.3347566673037363216, + 75.027646900241961703, 107.28033600826529437, 121.73286444817495067, 13.402616154016868677, + 14.32591006960865343, 21.443608517376560485, 126.05484765684013837, 122.04957148895846331, + 65.577848321270721499, 38.935228250680665951, 19.903379841092828428, 73.986177430608222494, + 72.243134630258282414, 38.927115608708845684, 6.4616019822205998935, 103.27516083073714981, + 106.04067056812345982, 12.275352846234454773, 60.450574122380203335, 8.8044935954640095588, + 83.853190100744541269, 99.927513184546114644, 120.92422993359650718, 42.9603918863213039, + 26.740292979557125363, 23.337062886410421925, 71.402596770178206498, 12.569796284788026242, + 42.177193611871189205, 48.684051327782071894, 126.38767744526194292, 24.335545658810588066, + 102.76556335276836762, 34.538699291817465564, 124.85047327753636637, 89.700454560890648281, + 111.04466424423299031, 41.741737495449342532, 81.048104923629580298, 12.698021276097279042, + 70.3591157509945333, 23.652800760202808306, 3.0254272102029062808, 74.046953323628258659, + 71.479489823563199025, 46.569888391659333138, 38.805201633676915662, 16.593440270131395664, + 85.129887917264568387, 83.947845846287236782, 107.56433608779116184, 113.52297676573653007, + 70.343245251031476073, 58.386180639103258727, 95.012127847014198778, 17.447590691605000757, + 86.583027149328700034, 66.467911844174523139, 64.575817247976374347, 103.06669754587710486, + 89.152245253400906222, 84.239476476461277343, 33.671813576482236385, 51.144649249410576886, + 7.6638276594567287248, 108.76525420904363273, 24.947276258793863235, 71.026552482460829196, + 34.522675112875731429, 50.041900356049154652, 5.1427973743884649593, 91.333055744380544638, + 16.996999544637219515, 49.289405458250257652, 40.192321692346013151, 83.633111687926430022, + 24.799651549219561275, 101.9607076560423593, 105.20533521678225952, 80.611759936291491613, + 109.75263931210429291, 60.145287348295823904, 30.888681769400136545, 48.209474633767968044, + 119.08704120747279376, 46.465855444745102432, 76.98411396538358531, 59.772093394101830199, + 119.70528617748277611, 81.945477438064699527, 4.0616683170774194878, 14.787063327628857223, + 46.625973031525063561, 21.145935431923135184, 33.690832410098664695, 29.324569053089362569, + 115.44778716756991344, 11.413897206399269635, 66.576673800591379404, 17.466505934269662248, + 59.457214162623131415, 86.705499794756178744, 82.824910736071615247, 21.020192785337712849, + 4.3078042575070867315, 44.744690214287402341, 110.92978086438597529, 112.01028106574449339, + 97.199690830486360937, 61.849509476272942265, 123.15831142945535248, 119.56366582549890154, + 20.388777687614492606, 23.233871946857107105, 98.703369830371229909, 1.4151652016153093427, + 116.03063584634583094, 63.990981639250094304, 108.19021864486057893, 46.948614977867691778, + 61.914070138609531568, 82.154133436899428489, 93.466375080228317529, 80.159127840270230081, + 65.695703358516766457, 41.253580310640245443, 5.2743433628602360841, 68.537461485851963516, + 108.88991431768590701, 64.512680290019488893, 1.1934817701439897064, 69.703595214599772589, + 16.024137611588230357, 73.184886626062507275, 75.580529834911430953, 77.665918656777648721, + 91.258162435864505824, 25.935737033032637555, 109.02727506064184126, 6.72174593771705986, + 87.001670689831371419, 100.83708860697515775, 96.790336529880732996, 78.749297052236215677, + 87.616999565761943813, 40.189463374797924189, 12.760641128003044287, 11.908074581660912372, + 89.620232443212444196, 28.8259060468772077, 73.484976427254878217, 70.666933661632356234, + 125.17990973451378522, 11.802617756409745198, 36.377219166199211031, 94.145730680676933844, + 55.216803906409040792, 4.6630171342476387508, 116.80208776121071423, 7.2527510813488333952, + 14.049993737931799842, 67.8526691571714764, 62.994386242233304074, 66.696955887353396975, + 46.123885119344777195, 124.47283063517534174, 116.2940553049556911, 36.831714694835682167, + 53.630512950010597706, 75.652463558748422656, 78.828783952922094613, 72.34654041844260064, + 114.99022565898121684, 91.908550705364177702, 121.32050901662660181, 5.3579330374450364616, + 104.22633752860565437, 97.523806268985936185, 41.710891153150441824, 54.23787870011801715, + 95.596258864279661793, 109.94928281671309378, 106.75896626002213452, 110.19842906928897719, + 125.06257862676284276, 5.6283775734300434124, 100.2275741287812707, 114.89510379813145846, + 43.208994466018339153, 117.33220656633420731, 9.8843802726223657373, 121.04723228784860112, + 46.115492444852861809, 33.643417884755763225, 61.2665845669216651, 38.241699017118662596, + 1.5237827465898590162, 12.831933636694884626, 39.27108888196744374, 80.743853745636442909, + 14.523253325107361889, 27.738642424723366275, 89.295124114236386959, 84.723938025475945324, + 10.249069448720547371, 64.692517524916183902, 61.488499998045881512, 45.536541767967719352, + 95.967165765814570477, 57.310217419675609563, 73.294319746924884384, 96.712424002198531525, + 99.977640540993888862, 99.632903425554104615, 98.492815640056505799, 0.28203020788714638911, + 13.714695910693990299, 63.067952002169477055, 96.209321117516083177, 2.78566487231728388, + 125.56008489676969475, 48.414845707829954335, 119.71895745670190081, 62.540339600924198749, + 50.061024126393022016, 124.84528512920587673, 91.220504081466060597, 97.871453144656697987, + 109.46920951388892718, 97.517180879916850245, 107.48299486303221784, 23.295581538463011384, + 114.07008196369861253, 97.914019224193907576, 92.973869578607263975, 69.746452339506504359, + 107.99977429010323249, 111.85565284108815831, 104.73036797969325562, 103.35820572742886725, + 115.31466992536661564, 119.87285099802102195, 54.664552145102788927, 75.533491719863377512, + 62.948324932269315468, 65.31568536350823706, 40.800722856540232897, 93.619750007866969099, + 111.47721396106135217, 89.077544017163745593, 81.498336346110590966, 32.77755330615764251, + 98.789723659945593681, 90.543959426911897026, 91.070868056001927471, 98.334155616266798461, + 77.785258610485470854, 107.61001961220972589, 98.161155685662379256, 83.522292031135293655, + 67.442419675371638732, 27.311723645540041616, 18.415477898521203315, 81.032443178413814167, + 88.343323428725852864, 123.84418007840940845, 10.443651786426926265, 9.3259480398482992314, + 99.376145155601989245, 7.0064435802814841736, 64.704313078076665988, 67.767086292962630978, + 39.681150521588278934, 52.932559299366403138, 61.047055941875441931, 57.623974698333768174, + 11.893763315132673597, 69.49262095733138267, 32.490975432963750791, 119.27751781189726898, + 122.19288723161298549, 89.595624551253422396, 19.872326493146829307, 25.354399179304891732, + 17.267842686833319021, 73.2128094745130511, 112.3008608705313236, 41.013006943485379452, + 72.463825836814066861, 105.94022212352865608, 15.948876442118489649, 71.901585133084154222, + 65.240492331893619848, 73.953206330013927072, 116.91312443250717479, 119.90429067357399617, + 117.13763212165576988, 58.636571236776944716, 5.4168591576271865051, 57.398813755728042452, + 35.613089666912856046, 73.930970174402318662, 82.679681069734215271, 34.587666213195916498, + 38.1799105699537904, 15.681073875810398022, 40.922980347517295741, 24.524687093242391711, + 48.532190685404202668, 34.781267878650396597, 32.301041750455624424, 57.192048964781861287, + 46.06967397584230639, 38.540648922222317196, 65.646307749251718633, 76.953826127442880534, + 40.82107440101026441, 94.088159161074145231, 42.325444317611982115, 45.231480130882118829, + 38.331092066146084107, 112.13861836183787091, 33.944804488892259542, 88.313045771014003549, + 78.85410685643000761, 17.602947211675200379, 45.746166451641329331, 0.55282067104417365044, + 37.05108806104544783, 114.4787174262382905, 16.295018042295851046, 29.108227730230282759, + 0.41081204967122175731, 85.562866635165846674, 66.496389697280392284, 89.164984444578294642, + 11.898646904402994551, 10.582001904935168568, 31.3254067929701705, 69.168738873471738771, + 16.498357350694277557, 117.86784444589284249, 110.22757421873393469, 0.78573401300673140213, + 70.28301957055737148, 14.346020914486871334, 8.138173277420719387, 9.0383792445754806977, + 45.093255061281524831, 14.694520628498139558, 116.61139485513194813, 63.144644021769636311, + 95.997926138395996531, 119.59193072771086008, 38.820172512885619653, 30.310883726600877708, + 81.561914896585221868, 81.420551171115221223, 107.89821596374167711, 103.24586929808356217, + 41.687217638940637698, 70.68170422352704918, 4.4366411405462713446, 97.622928691540437285, + 13.528968387363420334, 10.965589062117942376, 25.520982064401323441, 8.0693356432093423791, + 53.799267059213889297, 10.669513334611110622, 22.055293800487561384, 86.560672016534226714, + 115.46572889634990133, 26.805232308033737354, 28.65182013921730686, 42.887217034756758949, + 124.10969531368391472, 116.09914297792056459, 3.1556966425414429978, 77.870456501361331902, + 39.806759682189294836, 19.972354861220082967, 16.486269260516564827, 77.854231217417691369, + 12.923203964444837766, 78.550321661477937596, 84.081341136246919632, 24.550705692468909547, + 120.90114824476040667, 17.608987190931657096, 39.706380201492720516, 71.855026369095867267, + 113.84845986719301436, 85.920783772642607801, 53.480585959114250727, 46.674125772824481828, + 14.805193540356412996, 25.139592569576052483, 84.35438722374237841, 97.368102655567781767, + 124.77535489052388584, 48.67109131762481411, 77.531126705536735244, 69.077398583638569107, + 121.70094655507637071, 51.400909121784934541, 94.089328488465980627, 83.483474990902323043, + 34.096209847259160597, 25.396042552198196063, 12.718231501989066601, 47.305601520405616611, + 6.0508544204094505403, 20.093906647260155296, 14.958979647126398049, 93.139776783318666276, + 77.610403267353831325, 33.186880540266429307, 42.259775834532774752, 39.895691692578111542, + 87.128672175585961668, 99.045953531476698117, 12.686490502062952146, 116.77236127821015543, + 62.024255694028397556, 34.895181383213639492, 45.166054298661038047, 4.9358236883526842576, + 1.1516344959563866723, 78.133395091757847695, 50.304490506805450423, 40.478952952922554687, + 67.343627152964472771, 102.28929849882115377, 15.327655318917095428, 89.530508418087265454, + 49.894552517591364449, 14.053104964921658393, 69.045350225751462858, 100.0838007120983093, + 10.285594748780567897, 54.666111488761089277, 33.993999089274439029, 98.578810916500515305, + 80.384643384695664281, 39.266223375852860045, 49.599303098442760529, 75.921415312088356586, + 82.410670433568157023, 33.223519872586621204, 91.505278624208585825, 120.29057469659164781, + 61.777363538800273091, 96.418949267539574066, 110.17408241494558752, 92.931710889493842842, + 25.968227930767170619, 119.54418678820729838, 111.4105723549691902, 35.890954876129399054, + 8.1233366341548389755, 29.574126655257714447, 93.251946063050127123, 42.291870863846270368, + 67.381664820197329391, 58.649138106182363117, 102.89557433513982687, 22.827794412802177249, + 5.1533476011827588081, 34.933011868539324496, 118.91442832524990081, 45.410999589515995467, + 37.649821472143230494, 42.040385570675425697, 8.615608515014173463, 89.489380428578442661, + 93.859561728775588563, 96.020562131492624758, 66.399381660972721875, 123.69901895254952251, + 118.31662285891434294, 111.12733165099780308, 40.777555375228985213, 46.467743893717852188, + 69.406739660742459819, 2.8303304032342566643, 104.06127169269166188, 127.98196327850382659, + 88.380437289721157867, 93.897229955735383555, 123.82814027722270112, 36.308266873802494956, + 58.932750160460273037, 32.318255680544098141, 3.3914067170335329138, 82.507160621280490886, + 10.548686725724110147, 9.0749229717075650115, 89.779828635375451995, 1.0253605800389777869, + 2.3869635402916173916, 11.407190429199545179, 32.048275223180098692, 18.36977325212865253, + 23.161059669826499885, 27.331837313558935421, 54.516324871729011647, 51.871474066068913089, + 90.054550121283682529, 13.443491875437757699, 46.003341379666380817, 73.674177213953953469, + 65.580673059765103972, 29.498594104476069333, 47.233999131523887627, 80.378926749595848378, + 25.521282256006088573, 23.816149163325462723, 51.240464886424888391, 57.651812093758053379, + 18.969952854513394414, 13.333867323268350447, 122.35981946902757045, 23.605235512819490395, + 72.754438332402060041, 60.291461361353867687, 110.43360781281808158, 9.3260342684989154804, + 105.60417552242142847, 14.50550216269766679, 28.099987475867237663, 7.7053383143429527991, + 125.98877248447024613, 5.393911774706793949, 92.247770238693192368, 120.94566127035432146, + 104.5881106099113822, 73.663429389671364333, 107.26102590002483339, 23.304927117500483291, + 29.657567905847827205, 16.693080836888839258, 101.98045131796607166, 55.817101410731993383, + 114.64101803325320361, 10.715866074893710902, 80.452675057214946719, 67.047612537971872371, + 83.421782306300883647, 108.47575740023967228, 63.192517728562961565, 91.898565633429825539, + 85.517932520047907019, 92.396858138581592357, 122.12515725352568552, 11.256755146863724804, + 72.455148257566179382, 101.79020759626291692, 86.417988932040316286, 106.66441313266841462, + 19.768760545248369453, 114.09446457569720224, 92.230984889705723617, 67.286835769511526451, + 122.5331691338433302, 76.483398034237325191, 3.0475654931797180325, 25.663867273389769252, + 78.542177763938525459, 33.487707491272885818, 29.046506650214723777, 55.47728484945037053, + 50.590248228476411896, 41.447876050951890647, 20.49813889744473272, 1.3850350498323678039, + 122.97699999609176302, 91.073083535939076683, 63.934331531629140954, 114.6204348393548571, + 18.588639493853406748, 65.424848004400701029, 71.955281081991415704, 71.265806851111847209, + 68.985631280113011599, 0.56406041577429277822, 27.429391821387980599, 126.13590400434259209, + 64.418642235032166354, 5.5713297446382057387, 123.1201697935393895, 96.82969141566354665, + 111.43791491340380162, 125.0806792018483975, 100.12204825278968201, 121.69057025841539144, + 54.441008162935759174, 67.742906289317033952, 90.938419027781492332, 67.034361759837338468, + 86.965989726064435672, 46.591163076929660747, 100.14016392740086303, 67.82803844839145313, + 57.947739157218165928, 11.492904679016646696, 87.999548580210102955, 95.711305682179954601, + 81.460735959390149219, 78.716411454861372476, 102.62933985073686927, 111.7457019960420439, + 109.32910429020921583, 23.066983439726755023, 125.89664986454226892, 2.6313707270164741203, + 81.601445713084103772, 59.239500015737576177, 94.95442792212634231, 50.155088034331129165, + 34.996672692221181933, 65.555106612318922998, 69.579447319894825341, 53.087918853827432031, + 54.14173611200749292, 68.668311232537234901, 27.570517220974579686, 87.220039224423089763, + 68.32231137132839649, 39.044584062274225289, 6.8848393507432774641, 54.623447291080083232, + 36.830955797046044609, 34.064886356831266312, 48.686646857455343707, 119.6883601568188169, + 20.887303572853852529, 18.651896079700236442, 70.75229031120397849, 14.012887160566606326, + 1.4086261561569699552, 7.5341725859252619557, 79.362301043176557869, 105.86511859873280628, + 122.09411188375088386, 115.24794939666753635, 23.787526630268985173, 10.985241914662765339, + 64.98195086593113956, 110.55503562379817595, 116.38577446322960895, 51.191249102506844793, + 39.744652986293658614, 50.708798358609783463, 34.535685373670276022, 18.425618949029740179, + 96.601721741062647197, 82.026013886974396883, 16.9276516736317717, 83.880444247057312168, + 31.897752884240617277, 15.803170266171946423, 2.4809846637908776756, 19.906412660031492123, + 105.82624886501798755, 111.80858134715163033, 106.27526424331153976, 117.27314247355388943, + 10.83371831525437301, 114.7976275114560849, 71.226179333829350071, 19.861940348808275303, + 37.359362139468430541, 69.175332426391832996, 76.3598211399075808, 31.362147751620796043, + 81.845960695034591481, 49.049374186484783422, 97.064381370808405336, 69.562535757300793193, + 64.602083500911248848, 114.38409792956372257, 92.139347951684612781, 77.081297844448272372, + 3.2926154985070752446, 25.907652254885761067, 81.642148802024166798, 60.176318322148290463, + 84.650888635223964229, 90.462960261764237657, 76.662184132295806194, 96.277236723675741814, + 67.889608977788157063, 48.626091542031645076, 29.708213712860015221, 35.205894423350400757, + 91.492332903282658663, 1.1056413420883473009, 74.102176122094533639, 100.957434852476581, + 32.590036084591702092, 58.216455460460565519, 0.82162409934608149342, 43.125733270335331326, + 4.992779394564422546, 50.329968889160227263, 23.797293808805989102, 21.164003809870337136, + 62.650813585943978978, 10.337477746943477541, 32.996714701392193092, 107.73568889178932295, + 92.455148437467869371, 1.5714680260171007831, 12.566039141114742961, 28.692041828973742668, + 16.276346554841438774, 18.076758489150961395, 90.186510122563049663, 29.389041256999917096, + 105.22278971026389627, 126.2892880435429106, 63.995852276795631042, 111.18386145542172017, + 77.640345025771239307, 60.621767453205393394, 35.123829793174081715, 34.841102342234080425, + 87.796431927486992208, 78.491738596167124342, 83.374435277884913376, 13.36340844705409836, + 8.8732822810961806681, 67.24585738308087457, 27.057936774726840667, 21.931178124235884752, + 51.041964128802646883, 16.138671286418684758, 107.59853411842777859, 21.339026669222221244, + 44.110587600978760747, 45.121344033072091406, 102.93145779269980267, 53.610464616067474708, + 57.30364027843461372, 85.774434069517155876, 120.21939062737146742, 104.19828595584112918, + 6.3113932850865239743, 27.740913002722663805, 79.613519364378589671, 39.944709722440165933, + 32.972538521036767634, 27.708462434835382737, 25.84640792889331351, 29.100643322959513171, + 40.162682272493839264, 49.101411384941457072, 113.80229648952081334, 35.217974381863314193, + 79.412760402989079012, 15.710052738195372513, 99.696919734389666701, 43.841567545285215601, + 106.96117191822850145, 93.348251545648963656, 29.610387080712825991, 50.279185139155742945, + 40.708774447488394799, 66.736205311139201513, 121.55070978104777168, 97.342182635253266199, + 27.062253411077108467, 10.154797167280776193, 115.40189311015274143, 102.80181824357350706, + 60.178656976935599232, 38.966949981804646086, 68.192419694518321194, 50.792085104396392126, + 25.436463003978133202, 94.611203040811233222, 12.101708840818901081, 40.187813294520310592, + 29.917959294256434077, 58.27955356664097053, 27.220806534707662649, 66.373761080532858614, + 84.519551669065549504, 79.791383385159861064, 46.257344351175561314, 70.091907062953396235, + 25.372981004129542271, 105.54472255642031087, 124.04851138805679511, 69.790362766427278984, + 90.332108597322076093, 9.8716473767053685151, 2.3032689919164113235, 28.266790183515695389, + 100.60898101361090085, 80.957905905848747352, 6.6872543059325835202, 76.578596997642307542, + 30.655310637837828835, 51.061016836174530908, 99.789105035182728898, 28.106209929846954765, + 10.090700451506563695, 72.167601424196618609, 20.571189497561135795, 109.33222297752217855, + 67.987998178552516038, 69.157621833004668588, 32.769286769391328562, 78.532446751705720089, + 99.198606196889159037, 23.842830624180351151, 36.821340867136314046, 66.447039745176880388, + 55.010557248420809628, 112.58114939318329562, 123.55472707760418416, 64.837898535082786111, + 92.34816482989481301, 57.863421778987685684, 51.936455861537979217, 111.08837357641823473, + 94.821144709938380402, 71.781909752258798108, 16.246673268309677951, 59.148253310519066872, + 58.503892126100254245, 84.583741727696178714, 6.7633296403946587816, 117.29827621236836421, + 77.791148670279653743, 45.655588825604354497, 10.306695202365517616, 69.866023737082286971, + 109.82885665049980162, 90.821999179031990934, 75.299642944286460988, 84.080771141350851394, + 17.231217030031984905, 50.978760857160523301, 59.719123457554815104, 64.041124262988887494, + 4.7987633219490817282, 119.398037905102683, 108.63324571783232386, 94.254663301995606162, + 81.555110750457970425, 92.935487787439342355, 10.813479321484919637, 5.6606608064721513074, + 80.122543385386961745, 127.96392655701129115, 48.760874579445953714, 59.794459911474405089, + 119.65628055444540223, 72.616533747604989912, 117.86550032092054607, 64.636511361088196281, + 6.7828134340707038064, 37.014321242560981773, 21.097373451448220294, 18.149845943418768002, + 51.55965727075090399, 2.0507211600779555738, 4.7739270805832347833, 22.814380858399090357, + 64.096550446360197384, 36.73954650425730506, 46.32211933965299977, 54.663674627117870841, + 109.03264974345802329, 103.74294813214146416, 52.109100242567365058, 26.886983750875515398, + 92.006682759336399613, 19.348354427911544917, 3.1613461195302079432, 58.997188208952138666, + 94.467998263051413232, 32.757853499191696756, 51.042564512012177147, 47.632298326650925446, + 102.48092977284977678, 115.30362418751610676, 37.939905709026788827, 26.667734646540338872, + 116.7196389380551409, 47.21047102564261877, 17.508876664804120082, 120.58292272271137335, + 92.867215625636163168, 18.65206853700146894, 83.208351044842856936, 29.011004325395333581, + 56.199974951734475326, 15.410676628689543577, 123.97754496894049225, 10.787823549417225877, + 56.495540477390022716, 113.8913225407122809, 81.176221219826402375, 19.326858779346366646, + 86.522051800049666781, 46.609854235000966582, 59.315135811695654411, 33.386161673781316495, + 75.960902635932143312, 111.63420282146762474, 101.28203606650640722, 21.431732149791059783, + 32.905350114433531417, 6.0952250759473827202, 38.843564612605405273, 88.951514800479344558, + 126.38503545712956111, 55.797131266863289056, 43.035865040099452017, 56.793716277166822692, + 116.25031450705137104, 22.513510293731087586, 16.910296515135996742, 75.580415192529471824, + 44.83597786408427055, 85.328826265336829238, 39.537521090500376886, 100.18892915139804245, + 56.461969779415085213, 6.5736715390266908798, 117.06633826769029838, 24.966796068474650383, + 6.095130986359436065, 51.327734546783176484, 29.084355527877050918, 66.975414982545771636, + 58.093013300429447554, 110.95456969890074106, 101.18049645695282379, 82.895752101903781295, + 40.99627779488946544, 2.7700700996683735866, 117.95399999218716403, 54.146167071878153365, + 127.86866306326191989, 101.24086967870971421, 37.177278987710451474, 2.8496960088050400373, + 15.910562163986469386, 14.531613702227332396, 9.9712625602260231972, 1.1281208315485855564, + 54.858783642779599177, 124.27180800868882216, 0.83728447006433270872, 11.142659489280049456, + 118.24033958708241698, 65.659382831330731278, 94.875829826811241219, 122.16135840370043297, + 72.244096505583001999, 115.38114051683078287, 108.88201632587515633, 7.485812578637705883, + 53.876838055566622643, 6.0687235196783149149, 45.931979452128871344, 93.182326153862959472, + 72.280327854805364041, 7.6560768967829062603, 115.89547831443633186, 22.985809358036931371, + 47.999097160423843889, 63.422611364363547182, 34.921471918783936417, 29.432822909726382932, + 77.258679701477376511, 95.491403992087725783, 90.658208580418431666, 46.133966879457148025, + 123.79329972908453783, 5.2627414540365862194, 35.202891426168207545, 118.47900003147879033, + 61.908855844252684619, 100.31017606866225833, 69.993345384446001844, 3.1102132246414839756, + 11.158894639789650682, 106.17583770765486406, 108.28347222401862382, 9.336622465074469801, + 55.141034441952797351, 46.440078448849817505, 8.6446227426567929797, 78.089168124548450578, + 13.769678701486554928, 109.24689458216016646, 73.661911594092089217, 68.129772713662532624, + 97.373293714914325392, 111.37672031363763381, 41.774607145707705058, 37.303792159404110862, + 13.50458062240795698, 28.025774321133212652, 2.8172523123139399104, 15.06834517185416189, + 30.724602086356753716, 83.730237197469250532, 116.1882237675054057, 102.4958987933350727, + 47.575053260537970345, 21.970483829329168657, 1.9639017318659170996, 93.110071247599989874, + 104.77154892645921791, 102.38249820501368959, 79.489305972587317228, 101.41759671721956693, + 69.071370747340552043, 36.851237898063118337, 65.203443482128932374, 36.052027773948793765, + 33.85530334726718138, 39.760888494114624336, 63.795505768481234554, 31.606340532343892846, + 4.9619693275817553513, 39.812825320066622226, 83.652497730039613089, 95.617162694306898629, + 84.550528486626717495, 106.54628494710777886, 21.667436630512383999, 101.59525502291580779, + 14.452358667658700142, 39.723880697616550606, 74.718724278940499062, 10.350664852787303971, + 24.719642279815161601, 62.724295503245230066, 35.691921390069182962, 98.098748372973204823, + 66.128762741620448651, 11.125071514605224365, 1.2041670018261356745, 100.76819585913108313, + 56.27869590337286354, 26.162595688896544743, 6.5852309970141504891, 51.815304509775160113, + 35.284297604048333596, 120.3526366443002189, 41.301777270451566437, 52.925920523532113293, + 25.324368264595250366, 64.554473447355121607, 7.7792179555763141252, 97.252183084063290153, + 59.416427425720030442, 70.411788846704439493, 54.984665806565317325, 2.2112826841803325806, + 20.204352244192705257, 73.914869704953162, 65.180072169183404185, 116.43291092092113104, + 1.6432481986921629868, 86.251466540670662653, 9.9855587891288450919, 100.65993777832045453, + 47.594587617611978203, 42.328007619740674272, 125.30162717188795796, 20.674955493886955082, + 65.993429402788024163, 87.471377783582283882, 56.910296874935738742, 3.1429360520342015661, + 25.132078282229485922, 57.384083657947485335, 32.552693109682877548, 36.15351697830556077, + 52.373020245126099326, 58.77808251400347217, 82.445579420531430515, 124.5785760870858212, + 127.99170455359490006, 94.36772291084707831, 27.280690051542478614, 121.24353490641078679, + 70.24765958634816343, 69.682204684471798828, 47.592863854977622395, 28.983477192337886663, + 38.748870555769826751, 26.72681689410819672, 17.746564562195999315, 6.4917147661617491394, + 54.115873549453681335, 43.862356248471769504, 102.08392825760529377, 32.277342572841007495, + 87.197068236855557188, 42.678053338444442488, 88.221175201957521494, 90.242688066147820791, + 77.862915585399605334, 107.22092923213494942, 114.60728055687286542, 43.548868139037949732, + 112.43878125474657281, 80.39657191168225836, 12.622786570173047949, 55.481826005448965589, + 31.227038728757179342, 79.889419444880331866, 65.945077042073535267, 55.416924869670765474, + 51.692815857786627021, 58.201286645919026341, 80.325364544987678528, 98.202822769886552123, + 99.604592979041626677, 70.435948763730266364, 30.825520805978158023, 31.420105476394383004, + 71.393839468779333401, 87.683135090574069181, 85.922343836460640887, 58.696503091297927313, + 59.220774161425651982, 100.55837027831148589, 81.417548894980427576, 5.4724106222820410039, + 115.10141956209918135, 66.684365270506532397, 54.124506822154216934, 20.309594334565190366, + 102.80378622030912084, 77.603636487147014122, 120.35731395387119846, 77.933899963612930151, + 8.3848393890366423875, 101.58417020879278425, 50.872926007959904382, 61.222406081622466445, + 24.203417681637802161, 80.375626589040621184, 59.835918588512868155, 116.55910713328194106, + 54.441613069418963278, 4.7475221610693552066, 41.039103338134736987, 31.582766770319722127, + 92.514688702354760608, 12.183814125906792469, 50.74596200826272252, 83.089445112844259711, + 120.0970227761172282, 11.580725532858195947, 52.664217194644152187, 19.74329475341073703, + 4.6065379838328226469, 56.533580367035028758, 73.21796202722543967, 33.915811811697494704, + 13.374508611868805019, 25.157193995284615085, 61.310621275675657671, 102.1220336723526998, + 71.578210070365457796, 56.21241985969390953, 20.181400903016765369, 16.335202848393237218, + 41.142378995125909569, 90.664445955047995085, 7.975996357108670054, 10.315243666009337176, + 65.538573538786295103, 29.064893503415078158, 70.397212393778318074, 47.685661248360702302, + 73.64268173427626607, 4.8940794903537607752, 110.02111449684525724, 97.162298786370229209, + 119.1094541552120063, 1.6757970701692102011, 56.696329659789626021, 115.72684355797537137, + 103.87291172307959641, 94.176747152840107447, 61.642289419880398782, 15.563819504517596215, + 32.493346536619355902, 118.29650662103813374, 117.00778425220414647, 41.167483455392357428, + 13.526659280792955542, 106.5965524247403664, 27.582297340559307486, 91.311177651208708994, + 20.613390404734673211, 11.73204747416821192, 91.657713301003241213, 53.643998358067619847, + 22.599285888576559955, 40.161542282701702788, 34.46243406006396981, 101.9575217143210466, + 119.43824691511326819, 0.08224852597777498886, 9.5975266439018014353, 110.79607581020900398, + 89.266491435668285703, 60.509326603994850302, 35.11022150091957883, 57.870975574878684711, + 21.626958642969839275, 11.321321612947940594, 32.245086770777561469, 127.9278531140225823, + 97.521749158891907427, 119.58891982295244816, 111.31256110889444244, 17.233067495213617804, + 107.73100064184473013, 1.2730227221763925627, 13.565626868141407613, 74.028642485121963546, + 42.194746902896440588, 36.299691886837536003, 103.11931454150180798, 4.1014423201559111476, + 9.5478541611664695665, 45.628761716801818693, 0.19310089272039476782, 73.479093008514610119, + 92.64423867930599954, 109.32734925423937966, 90.065299486919684568, 79.485896264282928314, + 104.21820048513473012, 53.773967501754668774, 56.013365518672799226, 38.696708855823089834, + 6.3226922390604158863, 117.99437641790791531, 60.935996526102826465, 65.515706998383393511, + 102.08512902402435429, 95.264596653305488871, 76.961859545703191543, 102.60724837503221352, + 75.879811418053577654, 53.335469293084315723, 105.4392778761102818, 94.42094205128523754, + 35.017753329611878144, 113.16584544542638469, 57.734431251272326335, 37.304137074006575858, + 38.416702089685713872, 58.022008650790667161, 112.39994990346895065, 30.821353257382725133, + 119.95508993788098451, 21.575647098834451754, 112.99108095478368341, 99.782645081428199774, + 34.352442439652804751, 38.65371755869637127, 45.044103600099333562, 93.219708470001933165, + 118.63027162339130882, 66.772323347566270968, 23.921805271867924603, 95.268405642938887468, + 74.564072133012814447, 42.863464299582119565, 65.810700228867062833, 12.19045015189476544, + 77.687129225214448525, 49.903029600962327095, 124.77007091425912222, 111.59426253372657811, + 86.071730080198904034, 113.58743255433728336, 104.50062901410274208, 45.027020587462175172, + 33.820593030275631463, 23.160830385058943648, 89.671955728172179079, 42.657652530673658475, + 79.07504218100439175, 72.377858302796084899, 112.92393955883017043, 13.147343078057019738, + 106.13267653538059676, 49.933592136949300766, 12.19026197271887213, 102.65546909356635297, + 58.168711055757739814, 5.9508299650915432721, 116.18602660086253309, 93.909139397805120097, + 74.360992913909285562, 37.79150420380756259, 81.99255558977893088, 5.540140199340385152, + 107.90799998437432805, 108.29233414375994471, 127.73732612652747775, 74.481739357419428416, + 74.354557975420902949, 5.6993920176100800745, 31.821124327972938772, 29.063227404454664793, + 19.942525120452046394, 2.2562416630971711129, 109.71756728556283633, 120.54361601737764431, + 1.6745689401286654174, 22.285318978563736891, 108.48067917416847195, 3.3187656626651005354, + 61.751659653626120416, 116.32271680740450392, 16.488193011169641977, 102.76228103366520372, + 89.764032651750312652, 14.971625157275411766, 107.75367611113324529, 12.13744703935662983, + 91.863958904261380667, 58.364652307729556924, 16.560655709610728081, 15.312153793569450499, + 103.79095662887266371, 45.971618716073862743, 95.998194320847687777, 126.84522272872709436, + 69.842943837567872833, 58.865645819456403842, 26.517359402958391001, 62.982807984179089544, + 53.316417160836863331, 92.267933758917934028, 119.58659945816907566, 10.525482908073172439, + 70.405782852340053068, 108.95800006295758067, 123.81771168850900722, 72.62035213732815464, + 11.986690768892003689, 6.2204264492829679511, 22.317789279582939344, 84.351675415313366102, + 88.566944448037247639, 18.673244930148939602, 110.2820688839055947, 92.88015689769963501, + 17.289245485317223938, 28.178336249096901156, 27.539357402976747835, 90.493789164323970908, + 19.323823188187816413, 8.2595454273287032265, 66.746587429832288763, 94.753440627275267616, + 83.549214291415410116, 74.607584318808221724, 27.00916124481591396, 56.051548642266425304, + 5.6345046246278798208, 30.13669034370832378, 61.449204172717145411, 39.460474394942139043, + 104.37644753501444939, 76.991797586670145392, 95.150106521075940691, 43.940967658658337314, + 3.9278034637354721781, 58.220142495203617727, 81.543097852922073798, 76.764996410031017149, + 30.978611945178272435, 74.835193434442771832, 10.142741494681104086, 73.702475796129874652, + 2.4068869642578647472, 72.10405554789758753, 67.710606694534362759, 79.521776988229248673, + 127.59101153696246911, 63.212681064687785693, 9.9239386551635107026, 79.62565064013688243, + 39.304995460082864156, 63.234325388617435237, 41.101056973257072968, 85.092569894215557724, + 43.334873261028405977, 75.190510045831615571, 28.904717335317400284, 79.44776139523673919, + 21.437448557880998123, 20.701329705574607942, 49.439284559630323201, 125.44859100649046013, + 71.383842780142003903, 68.197496745950047625, 4.2575254832408973016, 22.250143029210448731, + 2.4083340036559093278, 73.53639171826216625, 112.55739180674572708, 52.325191377793089487, + 13.170461994028300978, 103.63060901955032023, 70.568595208100305172, 112.70527328860043781, + 82.603554540903132875, 105.85184104706422659, 50.648736529194138711, 1.1089468947102432139, + 15.558435911156266229, 66.504366168126580305, 118.83285485144369886, 12.823577693408878986, + 109.96933161313063465, 4.4225653683606651612, 40.408704488389048493, 19.829739409909961978, + 2.3601443383704463486, 104.86582184184226207, 3.2864963973879639525, 44.502933081341325305, + 19.971117578261328163, 73.319875556644547032, 95.189175235223956406, 84.656015239484986523, + 122.60325434377591591, 41.349910987777548144, 3.9868588055796863046, 46.942755567164567765, + 113.82059374987147748, 6.2858721040684031323, 50.264156564458971843, 114.76816731589497067, + 65.105386219365755096, 72.307033956611121539, 104.74604049025219865, 117.55616502801058232, + 36.891158841066499008, 121.15715217417528038, 127.9834091071934381, 60.735445821694156621, + 54.561380103088595206, 114.48706981282521156, 12.495319172699964838, 11.364409368943597656, + 95.185727709955244791, 57.966954384675773326, 77.497741111539653502, 53.453633788216393441, + 35.49312912439199863, 12.983429532323498279, 108.23174709890736267, 87.724712496947176987, + 76.167856515210587531, 64.554685145685652969, 46.394136473711114377, 85.356106676892522955, + 48.442350403918680968, 52.485376132299279561, 27.725831170802848646, 86.441858464273536811, + 101.21456111374573084, 87.097736278079537442, 96.877562509496783605, 32.79314382336451672, + 25.245573140346095897, 110.96365201089793118, 62.454077457517996663, 31.778838889764301712, + 3.8901540841470705345, 110.83384973934153095, 103.38563171557325404, 116.40257329184169066, + 32.650729089978995034, 68.405645539776742226, 71.209185958086891333, 12.871897527460532729, + 61.651041611956316046, 62.840210952792403987, 14.787678937562304782, 47.366270181151776342, + 43.844687672921281774, 117.39300618259585463, 118.44154832285494194, 73.116740556626609759, + 34.835097789960855152, 10.944821244567719987, 102.20283912420200068, 5.3687305410130647942, + 108.24901364430843387, 40.61918866913401871, 77.60757244062187965, 27.207272974297666224, + 112.71462790774603491, 27.867799927225860301, 16.769678778076922754, 75.168340417585568503, + 101.74585201591980876, 122.44481216324493289, 48.406835363279242301, 32.751253178081242368, + 119.67183717702937429, 105.11821426656388212, 108.88322613883792656, 9.4950443221387104131, + 82.078206676269473974, 63.165533540643082233, 57.029377404709521215, 24.367628251813584939, + 101.49192401652908302, 38.178890225692157401, 112.19404555223445641, 23.161451065716391895, + 105.32843438928830437, 39.48658950682147406, 9.2130759676656452939, 113.06716073407369549, + 18.435924054450879339, 67.831623623394989409, 26.749017223737610038, 50.314387990569230169, + 122.62124255135495332, 76.24406734470903757, 15.156420140730915591, 112.42483971938781906, + 40.362801806033530738, 32.670405696786474437, 82.284757990255457116, 53.32889191009599017, + 15.951992714217340108, 20.63048733202231233, 3.0771470775725902058, 58.129787006833794294, + 12.794424787556636147, 95.371322496725042583, 19.28536346855253214, 9.7881589807111595292, + 92.04222899369415245, 66.324597572744096396, 110.2189083104240126, 3.3515941403384204023, + 113.39265931958289002, 103.45368711595438072, 79.745823446162830805, 60.353494305680214893, + 123.28457883976079756, 31.12763900903519243, 64.986693073242349783, 108.59301324207990547, + 106.01556850440829294, 82.334966910784714855, 27.053318561589549063, 85.19310484948073281, + 55.16459468112225295, 54.622355302417417988, 41.226780809469346423, 23.464094948340061819, + 55.315426602006482426, 107.28799671613523969, 45.198571777153119911, 80.323084565403405577, + 68.924868120131577598, 75.915043428645731183, 110.87649383022653637, 0.16449705195554997772, + 19.195053287807240849, 93.59215162042164593, 50.532982871336571407, 121.0186532079897006, + 70.22044300183915766, 115.74195114975736942, 43.25391728593967855, 22.642643225895881187, + 64.490173541558760917, 127.85570622804880259, 67.043498317787452834, 111.17783964590853429, + 94.625122217788884882, 34.466134990430873586, 87.462001283689460251, 2.5460454443527851254, + 27.131253736286453204, 20.057284970243927091, 84.389493805792881176, 72.599383773678709986, + 78.23862908300361596, 8.2028846403118222952, 19.095708322332939133, 91.257523433603637386, + 0.38620178544442751445, 18.958186017032858217, 57.288477358615637058, 90.654698508482397301, + 52.130598973843007116, 30.971792528569494607, 80.436400970269460231, 107.54793500350933755, + 112.02673103734559845, 77.393417711646179669, 12.645384478124469751, 107.98875283581583062, + 121.87199305220929091, 3.0314139967704250012, 76.170258048052346567, 62.529193306614615722, + 25.923719091410021065, 77.214496750068065012, 23.759622836107155308, 106.67093858617226942, + 82.878555752224201569, 60.841884102570475079, 70.035506659227394266, 98.331690890852769371, + 115.46886250254465267, 74.608274148013151716, 76.833404179371427745, 116.0440173015849723, + 96.799899806937901303, 61.642706514769088244, 111.91017987576196902, 43.151294197672541486, + 97.982161909571004799, 71.565290162856399547, 68.704884879305609502, 77.307435117392742541, + 90.088207200202305103, 58.439416940007504309, 109.26054324678625562, 5.5446466951325419359, + 47.843610543739487184, 62.536811285881412914, 21.128144266025628895, 85.72692859916787711, + 3.6214004577341256663, 24.38090030379316886, 27.374258450428897049, 99.806059201928292168, + 121.54014182852188242, 95.188525067456794204, 44.143460160401446046, 99.174865108678204706, + 81.001258028205484152, 90.054041174924350344, 67.641186060551262926, 46.321660770121525275, + 51.343911456344358157, 85.315305061350954929, 30.150084362012421479, 16.755716605595807778, + 97.847879117660340853, 26.294686156117677456, 84.265353070761193521, 99.867184273898601532, + 24.380523945441382239, 77.310938187132705934, 116.33742211151547963, 11.901659930186724523, + 104.37205320172870415, 59.818278795613878174, 20.721985827818571124, 75.583008407618763158, + 35.98511117955786176, 11.080280398684408283, 87.81599996875229408, 88.584668287523527397, + 127.47465225305859349, 20.96347871484249481, 20.709115950841805898, 11.398784035220160149, + 63.642248655945877545, 58.126454808909329586, 39.885050240904092789, 4.5124833261979802046, + 91.435134571129310643, 113.08723203475528862, 3.3491378802573308349, 44.570637957131111762, + 88.961358348336943891, 6.6375313253302010708, 123.50331930725587881, 104.64543361480900785, + 32.976386022342921933, 77.524562067334045423, 51.528065303500625305, 29.943250314554461511, + 87.507352222266490571, 24.274894078716897639, 55.727917808522761334, 116.72930461545911385, + 33.121311419221456163, 30.624307587142538978, 79.581913257745327428, 91.943237432151363464, + 63.996388641699013533, 125.69044545745782671, 11.685887675135745667, 117.73129163891280768, + 53.034718805916782003, 125.96561596835817909, 106.63283432167736464, 56.535867517839506036, + 111.17319891633815132, 21.050965816149982857, 12.811565704683744116, 89.916000125918799313, + 119.63542337702165241, 17.240704274656309281, 23.973381537784007378, 12.440852898565935902, + 44.635578559169516666, 40.703350830630370183, 49.133888896074495278, 37.346489860301517183, + 92.564137767814827384, 57.76031379539927002, 34.578490970634447876, 56.356672498193802312, + 55.078714805957133649, 52.987578328647941817, 38.647646376375632826, 16.519090854661044432, + 5.4931748596682155039, 61.506881254554173211, 39.098428582834458211, 21.215168637616443448, + 54.018322489631827921, 112.10309728453285061, 11.269009249255759642, 60.273380687416647561, + 122.89840834543429082, 78.920948789887916064, 80.752895070032536751, 25.983595173343928764, + 62.300213042151881382, 87.881935317316674627, 7.8556069274709443562, 116.44028499041087343, + 35.086195705847785575, 25.529992820062034298, 61.95722389036018285, 21.670386868885543663, + 20.285482989365846151, 19.404951592259749305, 4.8137739285193674732, 16.208111095798813039, + 7.4212133890723634977, 31.043553976462135324, 127.18202307392493822, 126.42536212937557139, + 19.847877310330659384, 31.25130128027376486, 78.609990920165728312, 126.46865077723487047, + 82.202113946517783916, 42.185139788431115448, 86.669746522060449934, 22.381020091663231142, + 57.809434670638438547, 30.895522790473478381, 42.874897115761996247, 41.402659411149215885, + 98.878569119264284382, 122.89718201298455824, 14.767685560287645785, 8.3949934919000952505, + 8.5150509664817946032, 44.500286058420897461, 4.8166680073154566344, 19.07278343652797048, + 97.114783613491454162, 104.65038275558617897, 26.340923988060239935, 79.261218039104278432, + 13.137190416204248322, 97.410546577204513596, 37.207109081809903728, 83.703682094128453173, + 101.29747305838827742, 2.2178937894204864278, 31.116871822316170437, 5.0087323362567985896, + 109.66570970288739773, 25.64715538682139595, 91.938663226261269301, 8.8451307367213303223, + 80.817408976778096985, 39.659478819819923956, 4.7202886767445306759, 81.731643683684524149, + 6.572992794775927905, 89.005866162682650611, 39.942235156526294304, 18.639751113292732043, + 62.378350470451550791, 41.312030478973611025, 117.20650868755183183, 82.699821975555096287, + 7.9737176111593726091, 93.885511134332773509, 99.641187499742954969, 12.571744208136806265, + 100.52831312892158167, 101.53633463179357932, 2.210772438735148171, 16.614067913225881057, + 81.492080980508035282, 107.11233005602116464, 73.782317682136635995, 114.31430434835419874, + 127.96681821438687621, 121.47089164338831324, 109.12276020618082839, 100.97413962565042311, + 24.990638345399929676, 22.72881873789083329, 62.371455419910489582, 115.93390876935518463, + 26.995482223079307005, 106.90726757643278688, 70.98625824878399726, 25.966859064650634537, + 88.463494197818363318, 47.449424993897991953, 24.335713030424813041, 1.1093702913713059388, + 92.788272947425866732, 42.712213353785045911, 96.884700807837361936, 104.97075226459855912, + 55.451662341609335272, 44.8837169285507116, 74.429122227495099651, 46.195472556162712863, + 65.75512501899356721, 65.58628764672903344, 50.491146280695829773, 93.927304021795862354, + 124.90815491503599333, 63.557677779528603423, 7.7803081682977790479, 93.667699478686699877, + 78.771263431150146062, 104.80514658368338132, 65.301458179961628048, 8.8112910795571224298, + 14.418371916173782665, 25.743795054921065457, 123.30208322391263209, 125.68042190558480797, + 29.575357875124609563, 94.732540362303552683, 87.689375345846201526, 106.78601236519534723, + 108.88309664571352187, 18.233481113253219519, 69.670195579921710305, 21.889642489139077952, + 76.405678248404001351, 10.737461082029767567, 88.498027288616867736, 81.238377338271675399, + 27.215144881243759301, 54.414545948598970426, 97.429255815492069814, 55.735599854451720603, + 33.539357556157483486, 22.336680835174774984, 75.491704031843255507, 116.88962432648986578, + 96.813670726558484603, 65.502506356166122714, 111.34367435406238656, 82.236428533131402219, + 89.766452277675853111, 18.990088644281058805, 36.156413352538947947, 126.33106708128616447, + 114.05875480941904243, 48.735256503630807856, 74.983848033058166038, 76.35778045138795278, + 96.388091104468912818, 46.322902131436421769, 82.656868778576608747, 78.973179013642948121, + 18.426151935334928567, 98.134321468147390988, 36.871848108905396657, 7.6632472467899788171, + 53.498034447475220077, 100.62877598114209832, 117.24248510271354462, 24.488134689418075141, + 30.312840281465469161, 96.849679438775638118, 80.725603612067061476, 65.340811393576586852, + 36.569515980510914233, 106.65778382019198034, 31.903985428434680216, 41.26097466404462466, + 6.1542941551451804116, 116.25957401366758859, 25.588849575116910273, 62.742644993450085167, + 38.57072693710506428, 19.576317961425957037, 56.084457987391942879, 4.6491951454918307718, + 92.437816620848025195, 6.7031882806804787833, 98.78531863916941802, 78.907374231912399409, + 31.491646892325661611, 120.70698861136406776, 118.56915767952159513, 62.255278018074022839, + 1.9733861464883375447, 89.186026484163448913, 84.031137008820223855, 36.669933821569429711, + 54.106637123182736104, 42.38620969896146562, 110.3291893622445059, 109.24471060483483598, + 82.453561618938692845, 46.928189896680123638, 110.63085320401660283, 86.575993432270479389, + 90.3971435543098778, 32.646169130810449133, 9.8497362402667931747, 23.830086857295100344, + 93.752987660453072749, 0.32899410391109995544, 38.390106575618119678, 59.18430324084329186, + 101.06596574267678079, 114.03730641598303919, 12.440886003681953298, 103.48390229951473884, + 86.5078345718793571, 45.285286451795400353, 0.98034708312115981244, 127.71141245610124315, + 6.0869966355785436463, 94.355679291820706567, 61.250244435577769764, 68.932269980865385151, + 46.924002567378920503, 5.0920908887055702507, 54.262507472572906408, 40.114569940491492162, + 40.778987611589400331, 17.19876754736105795, 28.477258166007231921, 16.40576928062364459, + 38.191416644669516245, 54.515046867207274772, 0.7724035708888550289, 37.916372034065716434, + 114.5769547172349121, 53.309397016964794602, 104.26119794768601423, 61.943585057142627193, + 32.872801940542558441, 87.095870007022313075, 96.053462074694834882, 26.786835423292359337, + 25.290768956252577482, 87.977505671635299223, 115.74398610441858182, 6.0628279935444879811, + 24.340516096104693133, 125.05838661322923144, 51.847438182823680108, 26.428993500136130024, + 47.519245672217948595, 85.341877172348176828, 37.757111504448403139, 121.68376820514458814, + 12.071013318458426511, 68.663381781709176721, 102.93772500509294332, 21.216548296029941412, + 25.666808358746493468, 104.08803460317358258, 65.599799613875802606, 123.28541302954181447, + 95.82035975152393803, 86.302588395348720951, 67.964323819145647576, 15.130580325716437073, + 9.4097697586148569826, 26.61487023478912306, 52.176414400404610205, 116.8788338800186466, + 90.521086493572511245, 11.089293390265083872, 95.687221087478974368, 125.07362257176282583, + 42.256288532054895768, 43.453857198335754219, 7.2428009154682513326, 48.761800607586337719, + 54.748516900861432077, 71.612118403860222315, 115.08028365704740281, 62.377050134913588408, + 88.286920320806530071, 70.349730217360047391, 34.002516056414606282, 52.108082349852338666, + 7.2823721211025258526, 92.643321540243050549, 102.68782291269235429, 42.630610122701909859, + 60.300168724024842959, 33.511433211195253534, 67.695758235320681706, 52.58937231223899289, + 40.530706141526025021, 71.734368547797203064, 48.761047890886402456, 26.621876374269049847, + 104.67484422303095926, 23.803319860377087025, 80.744106403457408305, 119.63655759122775635, + 41.443971655640780227, 23.166016815237526316, 71.970222359115723521, 22.160560797372454545, + 47.631999937508226139, 49.169336575050692772, 126.94930450611718697, 41.92695742968498962, + 41.418231901683611795, 22.797568070440320298, 127.28449731189175509, 116.25290961781865917, + 79.770100481808185577, 9.024966652399598388, 54.870269142262259265, 98.174464069510577247, + 6.6982757605146616697, 89.141275914265861502, 49.922716696673887782, 13.27506265066404012, + 119.0066386145153956, 81.290867229618015699, 65.952772044689481845, 27.049124134668090846, + 103.05613060700125061, 59.886500629112561001, 47.014704444532981142, 48.549788157433795277, + 111.45583561704916065, 105.45860923091822769, 66.242622838442912325, 61.248615174288715934, + 31.163826515494292835, 55.886474864302726928, 127.99277728340166504, 123.38089091491565341, + 23.371775350275129313, 107.46258327782561537, 106.06943761183720198, 123.93123193671999616, + 85.265668643354729284, 113.07173503568265005, 94.346397832676302642, 42.101931632299965713, + 25.62313140937112621, 51.832000251841236604, 111.27084675404330483, 34.481408549312618561, + 47.946763075568014756, 24.881705797131871805, 89.271157118339033332, 81.406701661260740366, + 98.267777792148990557, 74.692979720606672345, 57.128275535629654769, 115.52062759079854004, + 69.156981941268895753, 112.71334499638760462, 110.1574296119142673, 105.97515665729588363, + 77.295292752751265652, 33.038181709322088864, 10.986349719336431008, 123.01376250910834642, + 78.196857165668916423, 42.430337275232886896, 108.03664497926729382, 96.206194569065701216, + 22.538018498511519283, 120.5467613748369331, 117.79681669087221962, 29.841897579779470107, + 33.505790140065073501, 51.967190346687857527, 124.60042608430740074, 47.763870634633349255, + 15.711213854945526691, 104.88056998082174687, 70.172391411695571151, 51.059985640124068595, + 123.9144477807203657, 43.340773737771087326, 40.570965978731692303, 38.809903184519498609, + 9.6275478570387349464, 32.416222191597626079, 14.842426778144726995, 62.087107952927908627, + 126.36404614785351441, 124.85072425875114277, 39.695754620661318768, 62.502602560551167699, + 29.219981840335094603, 124.93730155447337893, 36.404227893035567831, 84.370279576865868876, + 45.339493044120899867, 44.762040183326462284, 115.61886934127687709, 61.791045580946956761, + 85.749794231523992494, 82.805318822302069748, 69.757138238532206742, 117.79436402596911648, + 29.53537112057529157, 16.789986983800190501, 17.030101932963589206, 89.000572116841794923, + 9.6333360146309132688, 38.145566873059578938, 66.229567226986546302, 81.300765511172357947, + 52.681847976124117849, 30.522436078208556864, 26.274380832412134623, 66.821093154409027193, + 74.414218163623445434, 39.407364188260544324, 74.594946116776554845, 4.4357875788409728557, + 62.233743644632340875, 10.017464672517235158, 91.33141940577479545, 51.29431077364642988, + 55.877326452522538602, 17.690261473446298623, 33.63481795355619397, 79.318957639639847912, + 9.4405773534926993307, 35.463287367369048297, 13.145985589555493789, 50.011732325365301222, + 79.884470313052588608, 37.279502226585464086, 124.75670094090310158, 82.624060957950860029, + 106.41301737510730163, 37.399643951110192575, 15.947435222322383197, 59.771022268669184996, + 71.282374999485909939, 25.143488416277250508, 73.056626257846801309, 75.072669263587158639, + 4.4215448774702963419, 33.228135826455400093, 34.984161961019708542, 86.224660112045967253, + 19.564635364276909968, 100.62860869671203545, 127.93363642877739039, 114.94178328678026446, + 90.24552041236529476, 73.948279251300846227, 49.981276690799859352, 45.457637475781666581, + 124.74291083982461714, 103.86781753871036926, 53.990964446162251988, 85.814535152869211743, + 13.97251649756799452, 51.933718129304907052, 48.926988395636726636, 94.898849987795983907, + 48.671426060849626083, 2.2187405827462498564, 57.576545894851733465, 85.4244267075737298, + 65.76940161567836185, 81.941504529197118245, 110.90332468321867054, 89.767433857105061179, + 20.858244454990199301, 92.390945112329063704, 3.5102500379907723982, 3.1725752934580668807, + 100.98229256139529753, 59.854608043595362687, 121.81630983007198665, 127.11535555905720685, + 15.560616336599196075, 59.335398957377037732, 29.542526862303930102, 81.610293167370400624, + 2.6029163599232560955, 17.62258215911424486, 28.836743832347565331, 51.487590109845768893, + 118.60416644782890216, 123.36084381116961595, 59.150715750252857106, 61.465080724610743346, + 47.378750691696041031, 85.572024730394332437, 89.766193291427043732, 36.466962226510077016, + 11.34039115984342061, 43.779284978281793883, 24.811356496808002703, 21.474922164063173113, + 48.996054577237373451, 34.476754676543350797, 54.430289762487518601, 108.82909189720157883, + 66.858511630984139629, 111.47119970890344121, 67.078715112314966973, 44.673361670353187947, + 22.983408063690148992, 105.77924865298336954, 65.627341453120607184, 3.0050127123358834069, + 94.68734870812841109, 36.472857066266442416, 51.532904555351706222, 37.98017728856211761, + 72.312826705081533873, 124.66213416257596691, 100.11750961883808486, 97.470513007265253691, + 21.967696066119970055, 24.71556090277954354, 64.776182208937825635, 92.645804262876481516, + 37.313737557156855473, 29.946358027285896242, 36.852303870673495112, 68.268642936294781975, + 73.743696217810793314, 15.326494493579957634, 106.99606889495407813, 73.257551962287834613, + 106.48497020542708924, 48.976269378836150281, 60.625680562934576301, 65.699358877554914216, + 33.451207224137760932, 2.6816227871531737037, 73.139031961025466444, 85.315567640383960679, + 63.807970856869360432, 82.52194932808924932, 12.308588310293998802, 104.51914802733517718, + 51.177699150233820546, 125.48528998690017033, 77.141453874210128561, 39.152635922851914074, + 112.16891597478388576, 9.2983902909872995224, 56.875633241696050391, 13.406376561364595545, + 69.570637278342474019, 29.814748463824798819, 62.9832937846549612, 113.41397722273177351, + 109.13831535904319026, 124.51055603614804568, 3.9467722929803130683, 50.372052968330535805, + 40.06227401764044771, 73.339867643138859421, 108.21327424636547221, 84.772419397926569218, + 92.658378724492649781, 90.489421209673309932, 36.907123237877385691, 93.856379793363885256, + 93.261706408036843641, 45.151986864544596756, 52.7942871086197556, 65.292338261620898265, + 19.699472480533586349, 47.660173714593838667, 59.505975320906145498, 0.65798820782219991088, + 76.780213151236239355, 118.3686064816902217, 74.131931485357199563, 100.07461283196607837, + 24.881772007367544575, 78.967804599033115664, 45.015669143758714199, 90.570572903590800706, + 1.9606941662459576037, 127.4228249122024863, 12.173993271160725271, 60.711358583641413134, + 122.50048887115917751, 9.8645399617307703011, 93.848005134757841006, 10.184181777411140501, + 108.52501494514581282, 80.229139880982984323, 81.557975223178800661, 34.3975350947221159, + 56.954516332014463842, 32.811538561247289181, 76.38283328933903249, 109.03009373441454954, + 1.5448071417777100578, 75.832744068135070847, 101.15390943446982419, 106.61879403393322718, + 80.522395895372028463, 123.88717011428525439, 65.745603881088754861, 46.191740014048264129, + 64.106924149389669765, 53.573670846584718674, 50.581537912508792942, 47.955011343274236424, + 103.48797220883716363, 12.125655987088975962, 48.681032192213024246, 122.11677322645846289, + 103.69487636564736022, 52.857987000272260047, 95.038491344439535169, 42.683754344696353655, + 75.514223008900444256, 115.36753641028917627, 24.142026636920491001, 9.3267635634219914209, + 77.87545001018588664, 42.433096592059882823, 51.333616717496624915, 80.176069206350803142, + 3.1995992277552431915, 118.57082605908726691, 63.640719503051514039, 44.605176790701079881, + 7.9286476382912951522, 30.261160651432874147, 18.819539517229713965, 53.22974046957824612, + 104.35282880081285839, 105.75766776004093117, 53.042172987145022489, 22.178586780533805722, + 63.374442174961586716, 122.14724514352565166, 84.512577064109791536, 86.907714396671508439, + 14.485601830936502665, 97.523601215172675438, 109.49703380172650213, 15.22423680772408261, + 102.16056731409480562, 124.7541002698308148, 48.573840641616698122, 12.699460434720094781, + 68.005032112829212565, 104.21616469970467733, 14.564744242208689684, 57.286643080489739077, + 77.375645825384708587, 85.261220245403819717, 120.60033744804968592, 67.022866422394145047, + 7.3915164706413634121, 105.17874462447798578, 81.061412283055688022, 15.468737095594406128, + 97.522095781772804912, 53.243752748541737674, 81.349688446061918512, 47.606639720757812029, + 33.488212806918454589, 111.2731151824555127, 82.887943311281560455, 46.332033630478690611, + 15.940444718231447041, 44.321121594744909089, 95.263999875016452279, 98.338673150105023524, + 125.89860901223437395, 83.85391485936997924, 82.836463803367223591, 45.595136140884278575, + 126.56899462378714816, 104.50581923564095632, 31.540200963616371155, 18.049933304799196776, + 109.74053828452815651, 68.348928139021154493, 13.396551521032961318, 50.282551828531723004, + 99.845433393347775564, 26.550125301331718219, 110.01327722903442918, 34.581734459239669377, + 3.9055440893789636903, 54.098248269339819672, 78.11226121400250122, 119.773001258225122, + 94.029408889065962285, 97.099576314871228533, 94.911671234101959271, 82.917218461840093369, + 4.4852456768858246505, 122.49723034857743187, 62.32765303098858567, 111.77294972860909184, + 127.98555456680696807, 118.76178182983130682, 46.743550700553896604, 86.925166555654868716, + 84.138875223678041948, 119.86246387344363029, 42.531337286713096546, 98.143470071368938079, + 60.692795665352605283, 84.203863264599931426, 51.246262818742252421, 103.66400050368611119, + 94.541693508086609654, 68.962817098625237122, 95.893526151136029512, 49.763411594267381588, + 50.542314236681704642, 34.81340332252511871, 68.535555584301619092, 21.385959441213344689, + 114.25655107126294752, 103.04125518160071806, 10.313963882541429484, 97.426689992778847227, + 92.314859223832172574, 83.950313314595405245, 26.590585505502531305, 66.076363418644177727, + 21.972699438676499994, 118.02752501822033082, 28.393714331337832846, 84.86067455046941177, + 88.073289958538225619, 64.412389138131402433, 45.076036997026676545, 113.09352274967750418, + 107.59363338174443925, 59.683795159558940213, 67.011580280130147003, 103.93438069337935303, + 121.20085216861480149, 95.527741269266698509, 31.422427709894691361, 81.761139961647131713, + 12.344782823391142301, 102.11997128025177517, 119.8288955614407314, 86.681547475542174652, + 81.141931957463384606, 77.619806369038997218, 19.255095714077469893, 64.832444383195252158, + 29.684853556289453991, 124.17421590585945523, 124.7280922957106668, 121.70144851750228554, + 79.391509241322637536, 125.0052051211023354, 58.439963680673827184, 121.87460310894675786, + 72.808455786074773641, 40.740559153731737752, 90.678986088241799735, 89.524080366656562546, + 103.23773868255375419, 123.5820911618975515, 43.499588463051622966, 37.610637644607777474, + 11.514276477068051463, 107.58872805193823297, 59.070742241150583141, 33.579973967600381002, + 34.060203865930816391, 50.001144233683589846, 19.266672029261826538, 76.291133746122795856, + 4.4591344539767305832, 34.601531022344715893, 105.3636959522482357, 61.044872156417113729, + 52.548761664827907225, 5.6421863088216923643, 20.828436327246890869, 78.814728376524726627, + 21.189892233553109691, 8.8715751576819457114, 124.46748728926468175, 20.034929345038108295, + 54.662838811549590901, 102.58862154729285976, 111.7546529050450772, 35.380522946892597247, + 67.269635907116025919, 30.637915279279695824, 18.881154706985398661, 70.926574734738096595, + 26.291971179110987578, 100.02346465073424042, 31.768940626105177216, 74.559004453170928173, + 121.51340188180984114, 37.248121915905358037, 84.826034750214603264, 74.799287902220385149, + 31.894870444644766394, 119.54204453734200797, 14.564749998971819878, 50.286976832558138995, + 18.113252515697240597, 22.145338527174317278, 8.8430897549405926839, 66.456271652910800185, + 69.968323922043055063, 44.449320224091934506, 39.129270728557457915, 73.257217393427708885, + 127.86727285755841876, 101.8835665735641669, 52.491040824734227499, 19.896558502601692453, + 99.962553381599718705, 90.91527495156697114, 121.48582167965287226, 79.735635077420738526, + 107.98192889232814196, 43.629070305738423485, 27.94503299513598904, 103.8674362586098141, + 97.853976791277091252, 61.797699975591967814, 97.342852121699252166, 4.4374811654924997129, + 115.15309178970710491, 42.848853415151097579, 3.5388032313603616785, 35.883009058397874469, + 93.806649366440979065, 51.534867714210122358, 41.716488909984036582, 56.781890224658127408, + 7.0205000759815447964, 6.3451505869197717402, 73.964585122790595051, 119.70921608719436335, + 115.63261966014761128, 126.23071111811441369, 31.121232673198392149, 118.67079791475407546, + 59.085053724611498183, 35.220586334740801249, 5.205832719846512191, 35.245164318228489719, + 57.673487664695130661, 102.97518021969517577, 109.20833289566144231, 118.72168762233923189, + 118.30143150050571421, 122.93016144922148669, 94.75750138339572004, 43.144049460792302852, + 51.532386582854087465, 72.933924453020154033, 22.68078231968684122, 87.558569956563587766, + 49.622712993616005406, 42.949844328126346227, 97.992109154474746902, 68.953509353086701594, + 108.86057952497867518, 89.658183794406795641, 5.7170232619719172362, 94.94239941781052039, + 6.1574302246299339458, 89.346723340706375893, 45.966816127383935964, 83.558497305970377056, + 3.2546829062412143685, 6.0100254246754047927, 61.37469741625682218, 72.945714132532884832, + 103.06580911070341244, 75.960354577127873199, 16.625653410166705726, 121.3242683251555718, + 72.235019237679807702, 66.941026014530507382, 43.935392132239940111, 49.431121805562725058, + 1.552364417879289249, 57.291608525752963033, 74.627475114313710947, 59.892716054571792483, + 73.704607741350628203, 8.5372858725932019297, 19.487392435621586628, 30.652988987163553247, + 85.992137789911794243, 18.515103924579307204, 84.969940410854178481, 97.952538757672300562, + 121.25136112587279058, 3.3987177551098284312, 66.902414448275521863, 5.3632455743099853862, + 18.278063922054570867, 42.631135280767921358, 127.61594171374235884, 37.043898656178498641, + 24.617176620591635583, 81.038296054670354351, 102.35539830047127907, 122.97057997380397865, + 26.282907748420257121, 78.305271845707466127, 96.337831949567771517, 18.596780581974599045, + 113.75126648339210078, 26.81275312273282907, 11.141274556684948038, 59.629496927649597637, + 125.96658756931356038, 98.827954445467184996, 90.27663071809001849, 121.02111207229609136, + 7.8935445859606261365, 100.74410593666107161, 80.124548035284533398, 18.679735286281356821, + 88.426548492734582396, 41.544838795856776414, 57.31675744898893754, 52.978842419346619863, + 73.81424647575840936, 59.71275958673140849, 58.523412816073687281, 90.303973729089193512, + 105.58857421724314918, 2.5846765232417965308, 39.398944961067172699, 95.320347429187677335, + 119.011950641812291, 1.3159764156480378006, 25.560426302476116689, 108.73721296338408138, + 20.263862970718037104, 72.149225663932156749, 49.763544014738727128, 29.935609198066231329, + 90.031338287521066377, 53.141145807181601413, 3.9213883324955531862, 126.84564982440497261, + 24.347986542321450543, 121.42271716728646425, 117.00097774231835501, 19.729079923465178581, + 59.696010269515682012, 20.368363554825918982, 89.050029890295263613, 32.458279761969606625, + 35.115950446357601322, 68.795070189444231801, 113.90903266402892768, 65.62307712249821634, + 24.765666578681702958, 90.060187468829099089, 3.0896142835590580944, 23.665488136273779674, + 74.307818868943286361, 85.237588067870092345, 33.044791790747694904, 119.77434022857414675, + 3.4912077621775097214, 92.383480028100166237, 0.21384829877933952957, 107.14734169316943735, + 101.16307582501758588, 95.910022686552110827, 78.975944417674327269, 24.251311974177951925, + 97.36206438442968647, 116.23354645292056375, 79.389752731294720434, 105.71597400054815807, + 62.076982688879070338, 85.367508689396345289, 23.028446017804526491, 102.73507282057835255, + 48.284053273840982001, 18.653527126847620821, 27.75090002037177328, 84.866193184119765647, + 102.66723343499688781, 32.352138412701606285, 6.3991984555141243618, 109.14165211817453383, + 127.28143900610302808, 89.210353581402159762, 15.857295276582590304, 60.522321302865748294, + 37.63907903445942793, 106.45948093916013022, 80.705657601629354758, 83.515335520081862342, + 106.08434597429004498, 44.357173561067611445, 126.74888434992681141, 116.29449028705494129, + 41.025154128223221051, 45.815428793343016878, 28.971203661876643309, 67.047202430348988855, + 90.994067603453004267, 30.448473615451803198, 76.321134628193249227, 121.50820053966162959, + 97.147681283233396243, 25.398920869443827542, 8.0100642256620631088, 80.432329399409354664, + 29.129488484417379368, 114.57328616098311613, 26.751291650773055153, 42.522440490811277414, + 113.20067489610300981, 6.0457328447882900946, 14.783032941286364803, 82.35748924895960954, + 34.122824566111376043, 30.937474191192450235, 67.044191563545609824, 106.48750549708711333, + 34.699376892123837024, 95.213279441515624058, 66.976425613840547157, 94.546230364914663369, + 37.775886622563120909, 92.664067260957381222, 31.880889436462894082, 88.642243189493456157, + 62.527999750036542537, 68.677346300213685026, 123.79721802447238588, 39.707829718743596459, + 37.672927606734447181, 91.190272281772195129, 125.13798924757793429, 81.011638471281912643, + 63.08040192723274231, 36.099866609602031531, 91.481076569059950998, 8.6978562780423089862, + 26.793103042065922637, 100.56510365706708399, 71.690866786695551127, 53.100250602667074418, + 92.026554458068858366, 69.163468918479338754, 7.8110881787579273805, 108.19649653868327732, + 28.224522428008640418, 111.54600251645388198, 60.058817778135562548, 66.199152629746095045, + 61.823342468207556522, 37.834436923680186737, 8.9704913537752872799, 116.99446069715486374, + 124.65530606198080932, 95.545899457221821649, 127.97110913361757412, 109.52356365966261365, + 93.487101401111431187, 45.850333111313375412, 40.277750447359721875, 111.72492774688726058, + 85.062674573429831071, 68.286940142737876158, 121.38559133070884855, 40.407726529199862853, + 102.49252563748814282, 79.328001007375860354, 61.083387016176857287, 9.9256341972541122232, + 63.787052302272059023, 99.526823188534763176, 101.08462847336340928, 69.6268066450538754, + 9.071111168603238184, 42.771918882430327358, 100.51310214252953301, 78.082510363201436121, + 20.627927765086496947, 66.853379985561332433, 56.629718447667983128, 39.90062662919081049, + 53.181171011008700589, 4.1527268372883554548, 43.945398877356637968, 108.05505003644066164, + 56.78742866267930367, 41.721349100942461519, 48.146579917080089217, 0.82477827626280486584, + 90.152073994056991069, 98.187045499358646339, 87.187266763488878496, 119.36759031912151841, + 6.0231605602639319841, 79.868761386762344046, 114.40170433723324095, 63.055482538533397019, + 62.844855419793020701, 35.522279923294263426, 24.689565646785922581, 76.239942560507188318, + 111.65779112288510078, 45.363094951087987283, 34.283863914930407191, 27.239612738077994436, + 38.510191428158577764, 1.6648887663905043155, 59.36970711258254596, 120.34843181172254845, + 121.45618459142497159, 115.40289703500820906, 30.78301848264891305, 122.01041024220467079, + 116.87992736135129235, 115.74920621789715369, 17.616911572149547283, 81.481118307467113482, + 53.357972176487237448, 51.048160733316763071, 78.475477365111146355, 119.164182323795103, + 86.999176926103245933, 75.221275289215554949, 23.028552954139740905, 87.177456103876465932, + 118.14148448230116628, 67.159947935200762004, 68.120407731861632783, 100.00228846736717969, + 38.533344058527291054, 24.582267492245591711, 8.9182689079534611665, 69.203062044693069765, + 82.727391904496471398, 122.08974431283422746, 105.09752332965581445, 11.284372617643384729, + 41.656872654497419717, 29.629456753049453255, 42.379784467106219381, 17.743150315367529402, + 120.9349745785293635, 40.06985869007621659, 109.32567762310281978, 77.177243094589357497, + 95.509305810090154409, 70.761045893788832473, 6.5392718142320518382, 61.275830558559391648, + 37.762309413974435301, 13.85314946947619319, 52.583942358225613134, 72.046929301468480844, + 63.537881252213992411, 21.118008906345494324, 115.02680376361968229, 74.496243831814354053, + 41.652069500432844507, 21.598575804440770298, 63.789740889293170767, 111.08408907468401594, + 29.129499997943639755, 100.57395366511627799, 36.226505031394481193, 44.290677054348634556, + 17.686179509884823347, 4.9125433058252383489, 11.936647844086110126, 88.898640448183869012, + 78.258541457118553808, 18.514434786859055748, 127.73454571512047551, 75.767133147128333803, + 104.982081649468455, 39.793117005207022885, 71.925106763203075388, 53.830549903137580259, + 114.9716433593093825, 31.47127015484511503, 87.963857784656283911, 87.258140611476846971, + 55.890065990275616059, 79.734872517223266186, 67.707953582554182503, 123.59539995118757361, + 66.685704243398504332, 8.8749623309886374045, 102.30618357941420982, 85.697706830302195158, + 7.0776064627207233571, 71.766018116799386917, 59.613298732881958131, 103.06973542842024472, + 83.432977819968073163, 113.56378044931625482, 14.041000151963089593, 12.690301173843181459, + 19.929170245584828081, 111.41843217439236469, 103.26523932029886055, 124.46142223622882739, + 62.242465346400422277, 109.34159582950815093, 118.17010744922299637, 70.441172669481602497, + 10.411665439693024382, 70.490328636456979439, 115.3469753293938993, 77.950360439393989509, + 90.416665791326522594, 109.44337524468210177, 108.6028630010150664, 117.86032289844661136, + 61.515002766791440081, 86.288098921584605705, 103.06477316571181291, 17.867848906040308066, + 45.361564639377320418, 47.117139913127175532, 99.245425987232010812, 85.899688656256330432, + 67.984218308953131782, 9.9070187061770411674, 89.721159049960988341, 51.316367588813591283, + 11.434046523947472451, 61.88479883562104078, 12.31486044926350587, 50.693446681412751786, + 91.933632254771509906, 39.116994611940754112, 6.509365812482428737, 12.020050849350809585, + 122.74939483251728234, 17.891428265069407644, 78.131618221410462866, 23.920709154255746398, + 33.25130682033704943, 114.64853665031478158, 16.470038475363253383, 5.882052029061014764, + 87.870784264479880221, 98.862243611125450116, 3.1047288357585784979, 114.58321705150956404, + 21.254950228627421893, 119.78543210914722295, 19.409215482701256406, 17.074571745186403859, + 38.974784871243173257, 61.305977974330744473, 43.984275579823588487, 37.030207849162252387, + 41.93988082171199494, 67.905077515348239103, 114.50272225174558116, 6.7974355102232948411, + 5.8048288965510437265, 10.726491148619970772, 36.556127844109141733, 85.262270561539480696, + 127.23188342748471769, 74.087797312356997281, 49.234353241186909145, 34.076592109344346682, + 76.710796600946196122, 117.94115994760795729, 52.565815496844152221, 28.610543691418570234, + 64.675663899135543033, 37.193561163952836068, 99.502532966784201562, 53.625506245465658139, + 22.282549113369896077, 119.25899385530283325, 123.93317513863075874, 69.655908890938007971, + 52.553261436183674959, 114.04222414459218271, 15.787089171924890252, 73.488211873325781198, + 32.249096070569066796, 37.35947057256635162, 48.853096985469164792, 83.089677591713552829, + 114.63351489797787508, 105.9576848386968777, 19.628492951516818721, 119.42551917346281698, + 117.04682563215101254, 52.607947458182025002, 83.177148434486298356, 5.1693530464835930616, + 78.797889922137983376, 62.640694858378992649, 110.02390128362458199, 2.6319528312960756011, + 51.120852604955871357, 89.474425926768162753, 40.527725941439712187, 16.298451327864313498, + 99.527088029477454256, 59.871218396136100637, 52.062676575042132754, 106.28229161436320283, + 7.8427766649947443511, 125.69129964880994521, 48.695973084646539064, 114.84543433457656647, + 106.00195548463671003, 39.458159846930357162, 119.39202053903136402, 40.736727109655475942, + 50.100059780590527225, 64.91655952393921325, 70.231900892718840623, 9.5901403788921015803, + 99.818065328061493346, 3.2461542449964326806, 49.531333157367043896, 52.120374937658198178, + 6.1792285671181161888, 47.330976272551197326, 20.615637737890210701, 42.475176135740184691, + 66.089583581499027787, 111.5486804571482935, 6.9824155243586574215, 56.766960056200332474, + 0.42769659756231703795, 86.294683386342512676, 74.326151650038809748, 63.820045373107859632, + 29.951888835348654538, 48.502623948359541828, 66.724128768863010919, 104.46709290584476548, + 30.779505462593078846, 83.431948001096316148, 124.15396537776177865, 42.735017378792690579, + 46.056892035612690961, 77.470145641156705096, 96.568106547681964003, 37.307054253695241641, + 55.501800040747184539, 41.732386368243169272, 77.334466869993775617, 64.70427682540321257, + 12.798396911031886702, 90.28330423635270563, 126.56287801220969413, 50.420707162804319523, + 31.714590553165180609, 121.04464260573149659, 75.27815806892249384, 84.918961878323898418, + 33.411315203262347495, 39.030671040167362662, 84.168691948580089957, 88.714347122138860868, + 125.4977686998572608, 104.58898057410988258, 82.050308256446442101, 91.630857586686033756, + 57.942407323756924598, 6.0944048607016156893, 53.988135206906008534, 60.896947230907244375, + 24.642269256390136434, 115.01640107932689716, 66.295362566466792487, 50.797841738887655083, + 16.020128451327764196, 32.864658798818709329, 58.258976968838396715, 101.14657232196623227, + 53.502583301546110306, 85.044880981626192806, 98.401349792206019629, 12.091465689576580189, + 29.566065882576367585, 36.71497849791921908, 68.245649132222752087, 61.874948382388538448, + 6.0883831270948576275, 84.975010994174226653, 69.398753784251312027, 62.426558883034886094, + 5.9528512276847322937, 61.092460729829326738, 75.551773245129879797, 57.328134521914762445, + 63.761778872929426143, 49.284486378986912314, 125.05599950007672305, 9.3546926004310080316, + 119.59443604894477176, 79.415659437487192918, 75.345855213472532341, 54.380544563548028236, + 122.27597849515950656, 34.023276942563825287, 126.16080385446548462, 72.19973321920770104, + 54.962153138119901996, 17.395712556084617972, 53.586206084135483252, 73.130207314137805952, + 15.381733573391102254, 106.20050120533778681, 56.053108916141354712, 10.326937836958677508, + 15.62217635751949274, 88.392993077366554644, 56.449044856020918814, 95.092005032907763962, + 120.11763555627476308, 4.3983052594921900891, 123.64668493641511304, 75.668873847360373475, + 17.940982707554212539, 105.98892139431336545, 121.31061212396525661, 63.091798914447281277, + 127.94221826723878621, 91.047127319328865269, 58.974202802222862374, 91.700666222626750823, + 80.555500894723081728, 95.449855493778159143, 42.12534914686330012, 8.5738802854793902952, + 114.77118266141769709, 80.815453058403363684, 76.985051274979923619, 30.656002014751720708, + 122.16677403235371457, 19.851268394508224446, 127.57410460454775603, 71.053646377073164331, + 74.169256946730456548, 11.2536132901077508, 18.142222337206476368, 85.543837764864292694, + 73.026204285062704002, 28.165020726402872242, 41.255855530176631873, 5.7067599711226648651, + 113.25943689533596626, 79.801253258381620981, 106.36234202201740118, 8.3054536745767109096, + 87.890797754716913914, 88.110100072881323285, 113.57485732535860734, 83.442698201884923037, + 96.293159834160178434, 1.6495565525292477105, 52.304147988117620116, 68.374090998720930656, + 46.374533526981394971, 110.73518063824303681, 12.046321120531501947, 31.73752277352832607, + 100.8034086744664819, 126.11096507706679404, 125.6897108395860414, 71.044559846588526852, + 49.379131293575483141, 24.479885121018014615, 95.315582245770201553, 90.726189902175974566, + 68.567727829860814381, 54.479225476155988872, 77.020382856317155529, 3.329777532781008631, + 118.7394142251687299, 112.69686362344873487, 114.91236918285358115, 102.80579407001641812, + 61.566036965301464079, 116.02082048441297957, 105.75985472270622267, 103.49841243579430738, + 35.233823144302732544, 34.962236614934226964, 106.7159443529744749, 102.09632146663716412, + 28.950954730225930689, 110.32836464759384398, 45.998353852210129844, 22.442550578431109898, + 46.057105908283119788, 46.354912207756569842, 108.28296896460597054, 6.3198958704051619861, + 8.2408154637269035447, 72.004576934734359384, 77.066688117054582108, 49.164534984491183423, + 17.836537815910560312, 10.406124089389777509, 37.454783808996580774, 116.17948862567209289, + 82.1950466593116289, 22.568745235286769457, 83.313745308994839434, 59.25891350609890651, + 84.759568934212438762, 35.486300630738696782, 113.869949157058727, 80.139717380156071158, + 90.651355246209277539, 26.354486189182352973, 63.018611620183946798, 13.522091787577664945, + 13.078543628464103676, 122.5516611171187833, 75.524618827948870603, 27.706298938952386379, + 105.16788471645486425, 16.093858602936961688, 127.07576250442798482, 42.236017812694626627, + 102.05360752724300255, 20.992487663628708106, 83.304139000865689013, 43.197151608881540596, + 127.57948177858997951, 94.168178149368031882, 58.258999995890917489, 73.147907330232555978, + 72.453010062788962387, 88.581354108697269112, 35.372359019769646693, 9.8250866116504766978, + 23.873295688175858231, 49.797280896371376002, 28.517082914237107616, 37.028869573721749475, + 127.46909143024458899, 23.534266294260305585, 81.964163298936909996, 79.586234010417683749, + 15.850213526406150777, 107.6610998062787985, 101.94328671861876501, 62.942540309693868039, + 47.927715569316205801, 46.516281222953693941, 111.7801319805548701, 31.469745034450170351, + 7.4159071651120029856, 119.19079990237878519, 5.3714084867970086634, 17.749924661980912788, + 76.612367158832057612, 43.395413660604390316, 14.155212925445084693, 15.532036233598773833, + 119.22659746576755424, 78.139470856844127411, 38.865955639939784305, 99.127560898632509634, + 28.082000303926179186, 25.380602347686362918, 39.85834049117329414, 94.836864348788367352, + 78.530478640601359075, 120.92284447245765477, 124.48493069280448253, 90.683191659019939834, + 108.34021489844963071, 12.882345338963204995, 20.823330879389686743, 12.980657272917596856, + 102.69395065879143658, 27.900720878791616997, 52.833331582656683167, 90.88675048936784151, + 89.205726002033770783, 107.72064579689322272, 123.03000553358651814, 44.576197843172849389, + 78.129546331423625816, 35.735697812080616131, 90.723129278754640836, 94.234279826257989043, + 70.490851974467659602, 43.799377312516298844, 7.9684366179062635638, 19.814037412357720314, + 51.442318099921976682, 102.63273517762718257, 22.868093047894944903, 123.76959767124208156, + 24.629720898527011741, 101.38689336282914155, 55.867264509543019813, 78.233989223881508224, + 13.018731624964857474, 24.040101698705257149, 117.49878966503456468, 35.782856530142453266, + 28.263236442820925731, 47.841418308511492796, 66.502613640677736839, 101.29707330062956316, + 32.940076950726506766, 11.764104058125667507, 47.741568528963398421, 69.724487222250900231, + 6.2094576715207949746, 101.16643410301912809, 42.509900457258481765, 111.57086421829444589, + 38.818430965402512811, 34.149143490372807719, 77.949569742486346513, 122.61195594866148895, + 87.968551159647176974, 74.060415698324504774, 83.87976164342762786, 7.8101550307001161855, + 101.00544450349116232, 13.594871020446589682, 11.609657793102087453, 21.452982297239941545, + 73.112255688221921446, 42.52454112308259937, 126.46376685497307335, 20.175594624713994563, + 98.468706482373818289, 68.153184218692331342, 25.421593201896030223, 107.88231989521591458, + 105.13163099368830444, 57.221087382840778446, 1.351327798271086067, 74.387122327909310116, + 71.005065933568403125, 107.25101249093131628, 44.565098226743430132, 110.51798771060930449, + 119.86635027726515546, 11.311817781876015943, 105.1065228723709879, 100.08444828918436542, + 31.574178343853418482, 18.976423746651562396, 64.498192141138133593, 74.718941145132703241, + 97.706193970941967564, 38.179355183430743637, 101.26702979595938814, 83.91536967739375541, + 39.256985903037275421, 110.85103834692927194, 106.09365126430202508, 105.21589491636768798, + 38.354296868972596712, 10.338706092970824102, 29.595779844275966752, 125.28138971676162328, + 92.047802567249163985, 5.2639056625921512023, 102.24170520991538069, 50.948851853536325507, + 81.055451882879424375, 32.596902655732264975, 71.054176058954908513, 119.74243679227220127, + 104.12535315008790349, 84.56458322872640565, 15.685553329993126681, 123.38259929761989042, + 97.391946169296716107, 101.69086866915677092, 84.003910969273420051, 78.916319693864352303, + 110.78404107806272805, 81.473454219310951885, 100.20011956118469243, 1.8331190478820644785, + 12.463801785437681247, 19.180280757787841139, 71.636130656122986693, 6.4923084899928653613, + 99.062666314734087791, 104.24074987531639636, 12.358457134236232378, 94.661952545102394652, + 41.231275475780421402, 84.95035227148400736, 4.1791671630016935524, 95.097360914296586998, + 13.964831048717314843, 113.53392011240066495, 0.85539319512827205472, 44.589366772688663332, + 20.652303300077619497, 127.64009074621571926, 59.903777670697309077, 97.005247896722721634, + 5.4482575377296598163, 80.934185811689530965, 61.559010925189795671, 38.863896002196270274, + 120.30793075552355731, 85.470034757585381158, 92.113784071229019901, 26.940291282317048172, + 65.136213095363928005, 74.614108507390483283, 111.00360008149436908, 83.464772736489976523, + 26.668933739991189213, 1.4085536508064251393, 25.596793822067411384, 52.566608472709049238, + 125.12575602441938827, 100.84141432560863905, 63.429181106333999196, 114.08928521146663115, + 22.556316137848625658, 41.837923756647796836, 66.82263040652469499, 78.061342080338363303, + 40.337383897163817892, 49.428694244281359715, 122.99553739971815958, 81.177961148223403143, + 36.100616512896522181, 55.261715173372067511, 115.8848146475138492, 12.188809721403231379, + 107.97627041381201707, 121.79389446181448875, 49.284538512783910846, 102.0328021586574323, + 4.5907251329335849732, 101.59568347777531017, 32.040256902655528393, 65.729317597637418658, + 116.51795393768043141, 74.293144643932464533, 107.00516660309585859, 42.089761963256023591, + 68.802699584412039258, 24.182931379153160378, 59.13213176515273517, 73.42995699584207614, + 8.4912982644455041736, 123.7498967647770769, 12.176766254193353234, 41.950021988352091284, + 10.797507568502624054, 124.85311776606977219, 11.905702455369464587, 122.18492145966229145, + 23.103546490259759594, 114.65626904382952489, 127.52355774585885229, 98.568972757977462607, + 122.1119990001534461, 18.709385200865654042, 111.18887209789318149, 30.831318874978023814, + 22.691710426945064683, 108.76108912709969445, 116.55195699031901313, 68.046553885131288553, + 124.32160770893460722, 16.399466438415402081, 109.92430627623980399, 34.791425112169235945, + 107.17241216827460448, 18.260414628275611904, 30.763467146785842488, 84.401002410675573628, + 112.10621783228270942, 20.653875673917355016, 31.244352715042623458, 48.785986154733109288, + 112.89808971204547561, 62.184010065819165902, 112.23527111254952615, 8.796610518988018157, + 119.29336987283386406, 23.337747694720746949, 35.881965415112063056, 83.977842788630368887, + 114.62122424793051323, 126.18359782889820053, 127.8844365344812104, 54.094254638657730538, + 117.94840560444936273, 55.401332445257139625, 33.111001789449801436, 62.899710987556318287, + 84.250698293726600241, 17.147760570962418569, 101.54236532283903216, 33.630906116810365347, + 25.970102549959847238, 61.312004029507079395, 116.33354806470742915, 39.702536789020086871, + 127.14820920909915003, 14.10729275414996664, 20.338513893460913096, 22.507226580215501599, + 36.284444674416590715, 43.087675529732223367, 18.052408570125408005, 56.330041452805744484, + 82.511711060353263747, 11.413519942248967709, 98.51887379067557049, 31.60250651676687994, + 84.724684044034802355, 16.610907349157059798, 47.781595509437465807, 48.22020014576628455, + 99.14971465072085266, 38.885396403773484053, 64.586319668320356868, 3.299113105058495421, + 104.60829597623887821, 8.7481819974418613128, 92.74906705396642792, 93.470361276486073621, + 24.092642241063003894, 63.475045547060290119, 73.606817348936601775, 124.22193015413722605, + 123.37942167917572078, 14.089119693177053705, 98.758262587150966283, 48.95977024203966721, + 62.631164491544041084, 53.452379804355587112, 9.1354556597216287628, 108.95845095231561572, + 26.040765712634311058, 6.6595550655656552408, 109.47882845034109778, 97.393727246901107719, + 101.82473836571080028, 77.611588140032836236, 123.13207393060656614, 104.04164096882959711, + 83.519709445416083327, 78.996824871588614769, 70.467646288605465088, 69.924473229872091906, + 85.43188870595258777, 76.192642933274328243, 57.901909460455499357, 92.656729295187687967, + 91.996707704420259688, 44.885101156862219796, 92.114211816566239577, 92.709824415516777663, + 88.565937929211941082, 12.639791740810323972, 16.481630927457445068, 16.009153869472356746, + 26.133376234109164216, 98.329069968982366845, 35.673075631821120623, 20.812248178779555019, + 74.909567617996799527, 104.35897725134782377, 36.390093318623257801, 45.137490470577176893, + 38.627490617989678867, 118.517827012201451, 41.519137868424877524, 70.972601261481031543, + 99.739898314121091971, 32.279434760315780295, 53.302710492418555077, 52.708972378364705946, + 126.0372232403678936, 27.044183575155329891, 26.157087256931845332, 117.10332223424120457, + 23.049237655897741206, 55.412597877908410737, 82.335769432909728494, 32.187717205877561355, + 126.15152500885596965, 84.472035625392891234, 76.107215054486005101, 41.98497532726105419, + 38.608278001731378026, 86.394303217766719172, 127.158963557183597, 60.336356298736063763, + 116.51799999178547296, 18.295814660468749935, 16.906020125581562752, 49.162708217394538224, + 70.744718039539293386, 19.650173223300953396, 47.746591376351716463, 99.594561792742752004, + 57.034165828474215232, 74.057739147447136929, 126.93818286048917798, 47.068532588524249149, + 35.928326597877457971, 31.172468020835367497, 31.700427052815939533, 87.322199612561234972, + 75.886573437237530015, 125.88508061938773608, 95.855431138632411603, 93.032562445911025861, + 95.560263961109740194, 62.939490068900340702, 14.83181433022764395, 110.38159980475757038, + 10.742816973594017327, 35.499849323965463554, 25.224734317664115224, 86.790827321208780631, + 28.310425850890169386, 31.064072467201185646, 110.45319493153874646, 28.278941713688254822, + 77.731911279883206589, 70.255121797265019268, 56.164000607852358371, 50.761204695372725837, + 79.716680982350226259, 61.673728697580372682, 29.060957281206356129, 113.84568894491894753, + 120.96986138561260304, 53.366383318043517647, 88.680429796899261419, 25.76469067792640999, + 41.646661758779373486, 25.961314545838831691, 77.387901317582873162, 55.801441757583233994, + 105.66666316531700431, 53.773500978739320999, 50.411452004071179545, 87.441291593790083425, + 118.06001106717303628, 89.152395686349336756, 28.259092662847251631, 71.471395624164870242, + 53.446258557512919651, 60.468559652519616066, 12.981703948935319204, 87.598754625032597687, + 15.936873235812527128, 39.628074824715440627, 102.88463619984759134, 77.265470355254365131, + 45.736186095793527784, 119.53919534248416312, 49.259441797057661461, 74.773786725658283103, + 111.7345290190896776, 28.467978447763016447, 26.037463249929714948, 48.080203397414152278, + 106.99757933006912936, 71.565713060284906533, 56.526472885641851462, 95.682836617026623571, + 5.0052272813591116574, 74.594146601259126328, 65.880153901453013532, 23.528208116251335014, + 95.483137057930434821, 11.448974444501800463, 12.418915343045227928, 74.332868206038256176, + 85.019800914520601509, 95.141728436588891782, 77.636861930805025622, 68.298286980749253416, + 27.899139484976331005, 117.22391189732661587, 47.937102319297991926, 20.120831396652647527, + 39.759523286855255719, 15.62031006140387035, 74.010889006982324645, 27.189742040893179365, + 23.219315586204174906, 42.905964594483521068, 18.224511376443842892, 85.049082246168836718, + 124.9275337099461467, 40.351189249431627104, 68.937412964751274558, 8.3063684373846626841, + 50.843186403795698425, 87.764639790435467148, 82.263261987376608886, 114.44217476568155689, + 2.7026555965458101127, 20.77424465582225821, 14.010131867140444228, 86.502024981862632558, + 89.130196453490498243, 93.03597542122224695, 111.73270055453031091, 22.623635563755669864, + 82.213045744745613774, 72.168896578368730843, 63.148356687706836965, 37.952847493306762772, + 0.99638428227990516461, 21.437882290269044461, 67.412387941883935127, 76.358710366865125252, + 74.534059591922414256, 39.83073935478751082, 78.51397180607818882, 93.702076693862181855, + 84.187302528607688146, 82.431789832735375967, 76.708593737945193425, 20.677412185941648204, + 59.191559688555571483, 122.56277943352688453, 56.095605134498327971, 10.527811325187940383, + 76.483410419830761384, 101.89770370707628899, 34.110903765758848749, 65.193805311468167929, + 14.108352117913455004, 111.48487358454804053, 80.250706300179444952, 41.129166457452811301, + 31.371106659989891341, 118.76519859524341882, 66.783892338597070193, 75.38173733831717982, + 40.00782193855047808, 29.832639387732342584, 93.568082156129094074, 34.946908438625541748, + 72.400239122369384859, 3.6662380957641289569, 24.927603570875362493, 38.360561515579320258, + 15.272261312245973386, 12.984616979989368701, 70.125332629471813561, 80.481499750632792711, + 24.716914268476102734, 61.323905090204789303, 82.462550951564480783, 41.900704542968014721, + 8.3583343260070250835, 62.194721828593173996, 27.929662097438267665, 99.067840224801329896, + 1.7107863902565441094, 89.178733545377326664, 41.304606600158876972, 127.28018149243143853, + 119.80755534139825613, 66.010495793445443269, 10.896515075462957611, 33.86837162337906193, + 123.11802185037959134, 77.727792004396178527, 112.6158615110507526, 42.940069515174400294, + 56.227568142458039802, 53.880582564637734322, 2.272426190731493989, 21.228217014784604544, + 94.007200162992376136, 38.929545472979953047, 53.337867479982378427, 2.8171073016128502786, + 51.193587644134822767, 105.13321694542173645, 122.25151204884241452, 73.682828651217278093, + 126.85836221267163637, 100.17857042293326231, 45.112632275697251316, 83.67584751329923165, + 5.6452608130530279595, 28.122684160676726606, 80.674767794327635784, 98.85738848856635741, + 117.99107479943995713, 34.355922296446806286, 72.201233025793044362, 110.523430346747773, + 103.76962929502769839, 24.377619442810100736, 87.952540827627672115, 115.5877889236289775, + 98.569077025571459671, 76.065604317314864602, 9.1814502658708079252, 75.191366955550620332, + 64.080513805314694764, 3.4586351952784752939, 105.0359078753645008, 20.586289287868567044, + 86.010333206191717181, 84.179523926515685162, 9.6053991688240785152, 48.365862758306320757, + 118.26426353030910832, 18.859913991684152279, 16.982596528894646326, 119.49979352955415379, + 24.353532508386706468, 83.900043976704182569, 21.595015137008886086, 121.70623553213954438, + 23.811404910742567154, 116.36984291932458291, 46.207092980523157166, 101.31253808766268776, + 127.04711549172134255, 69.137945515958563192, 116.22399800030689221, 37.418770401734946063, + 94.37774419578636298, 61.662637749956047628, 45.383420853893767344, 89.522178254203026881, + 105.10391398064166424, 8.0931077702662150841, 120.64321541786921443, 32.798932876834442141, + 91.848612552479607984, 69.582850224342109868, 86.344824336549208965, 36.520829256551223807, + 61.526934293575322954, 40.802004821354785236, 96.212435664565418847, 41.307751347834710032, + 62.488705430085246917, 97.571972309469856555, 97.796179424090951215, 124.36802013164196978, + 96.470542225099052303, 17.593221037979674293, 110.58673974566772813, 46.675495389441493899, + 71.763930830227764091, 39.955685577264375752, 101.24244849586466444, 124.36719565780003904, + 127.7688730689624208, 108.18850927731909906, 107.89681120889872545, 110.80266489051427925, + 66.222003578899602871, 125.79942197511627455, 40.501396587453200482, 34.295521141928475117, + 75.08473064567806432, 67.261812233620730694, 51.940205099919694476, 122.62400805901779677, + 104.6670961294148583, 79.405073578043811722, 126.29641841819830006, 28.214585508299933281, + 40.677027786921826191, 45.014453160431003198, 72.56888934883318143, 86.175351059464446735, + 36.10481714025081601, 112.66008290561512695, 37.023422120706527494, 22.827039884501573397, + 69.03774758135114098, 63.20501303353739786, 41.44936808806960471, 33.221814698314119596, + 95.563191018874931615, 96.440400291536207078, 70.29942930144170532, 77.770792807550606085, + 1.1726393366407137364, 6.5982262101206288207, 81.216591952477756422, 17.496363994887360604, + 57.49813410793649382, 58.940722552972147241, 48.185284482126007788, 126.95009109412421822, + 19.213634697876841528, 120.44386030827809009, 118.75884335835144157, 28.178239386357745389, + 69.516525174301932566, 97.919540484079334419, 125.26232898308808217, 106.90475960871117422, + 18.270911319446895504, 89.916901904631231446, 52.081531425268622115, 13.31911013113494846, + 90.957656900685833534, 66.787454493805853417, 75.64947673142523854, 27.223176280069310451, + 118.26414786121677025, 80.083281937662832206, 39.039418890835804632, 29.993649743180867517, + 12.935292577214568155, 11.848946459747821791, 42.863777411908813519, 24.385285866548656486, + 115.80381892091463669, 57.313458590379013913, 55.993415408840519376, 89.77020231372807757, + 56.228423633136117132, 57.419648831037193304, 49.131875858423882164, 25.279583481620647945, + 32.963261854914890137, 32.018307738944713492, 52.26675246822196641, 68.65813993796473369, + 71.346151263642241247, 41.624496357562748017, 21.819135235997237032, 80.717954502695647534, + 72.780186637246515602, 90.274980941154353786, 77.254981235982995713, 109.035654024402902, + 83.038275736853393028, 13.945202522965701064, 71.479796628242183942, 64.55886952063156059, + 106.60542098483711015, 105.41794475673304987, 124.07444648073578719, 54.088367150310659781, + 52.314174513867328642, 106.20664446848240914, 46.098475311795482412, 110.82519575582045945, + 36.671538865819456987, 64.375434411758760689, 124.30305001771557727, 40.944071250785782468, + 24.214430108972010203, 83.96995065452210838, 77.216556003466394031, 44.788606435537076322, + 126.31792711436719401, 120.67271259747576551, 105.03599998357094591, 36.59162932093749987, + 33.812040251163125504, 98.325416434792714426, 13.489436079078586772, 39.300346446601906791, + 95.493182752707070904, 71.189123585485504009, 114.06833165695206844, 20.115478294897911837, + 125.87636572097835597, 94.137065177048498299, 71.856653195754915942, 62.344936041670734994, + 63.400854105635517044, 46.644399225126107922, 23.77314687447869801, 123.77016123877911014, + 63.710862277268461185, 58.065124891825689701, 63.120527922219480388, 125.8789801378006814, + 29.663628660458925879, 92.763199609515140764, 21.485633947188034654, 70.999698647930927109, + 50.449468635331868427, 45.581654642417561263, 56.620851701780338772, 62.12814493440600927, + 92.906389863077492919, 56.557883427380147623, 27.463822559770051157, 12.510243594530038536, + 112.32800121570471674, 101.52240939074908965, 31.433361964700452518, 123.34745739516074536, + 58.121914562416350236, 99.691377889841533033, 113.93972277122520609, 106.73276663609067327, + 49.360859593798522837, 51.529381355852819979, 83.293323517558746971, 51.922629091681301361, + 26.775802635165746324, 111.60288351517010597, 83.333326330634008627, 107.547001957478642, + 100.82290400814599707, 46.882583187583804829, 108.12002213434971054, 50.304791372698673513, + 56.518185325698141241, 14.942791248329740483, 106.8925171150258393, 120.93711930503923213, + 25.963407897874276387, 47.197509250065195374, 31.873746471625054255, 79.256149649434519233, + 77.769272399698820664, 26.530940710508730263, 91.472372191590693546, 111.07839068496832624, + 98.5188835941189609, 21.547573451320204185, 95.469058038179355208, 56.935956895526032895, + 52.074926499859429896, 96.160406794831942534, 85.995158660141896689, 15.131426120569813065, + 113.0529457712873409, 63.365673234053247143, 10.010454562721861294, 21.188293202521890635, + 3.7603078029060270637, 47.056416232506308006, 62.966274115860869642, 22.897948889003600925, + 24.837830686094093835, 20.66573641208015033, 42.039601829044840997, 62.283456873181421543, + 27.273723861613689223, 8.5965739614985068329, 55.798278969956299989, 106.44782379465323174, + 95.874204638595983852, 40.241662793305295054, 79.519046573710511439, 31.240620122811378678, + 20.02177801396464929, 54.379484081786358729, 46.438631172408349812, 85.811929188967042137, + 36.449022752891323762, 42.098164492341311416, 121.8550674198922934, 80.702378498866892187, + 9.8748259295025491156, 16.612736874769325368, 101.68637280759503483, 47.529279580874572275, + 36.52652397475685575, 100.88434953136311378, 5.4053111930916202255, 41.54848931164451642, + 28.020263734284526436, 45.004049963728903094, 50.260392906984634465, 58.07195084244813188, + 95.46540110906062182, 45.247271127514977707, 36.426091489494865527, 16.337793156737461686, + 126.29671337541367393, 75.905694986613525543, 1.9927685645598103292, 42.8757645805417269, + 6.8247758837715082336, 24.717420733733888483, 21.068119183844828513, 79.661478709578659618, + 29.027943612160015618, 59.40415338772800169, 40.37460505721901427, 36.863579665474389913, + 25.41718747589038685, 41.354824371883296408, 118.38311937711478095, 117.12555886705376906, + 112.19121026899665594, 21.055622650379518745, 24.966820839665160747, 75.795407414152577985, + 68.221807531521335477, 2.387610622936335858, 28.216704235830547987, 94.969747169099719031, + 32.501412600358889904, 82.258332914905622602, 62.742213319983420661, 109.53039719049047562, + 5.5677846771977783646, 22.763474676634359639, 80.015643877100956161, 59.665278775468323147, + 59.136164312258188147, 69.893816877254721476, 16.800478244738769718, 7.3324761915282579139, + 49.855207141750724986, 76.721123031158640515, 30.544522624491946772, 25.969233959982375382, + 12.250665258947265102, 32.962999501265585423, 49.433828536952205468, 122.64781018041321659, + 36.925101903128961567, 83.801409085936029442, 16.716668652014050167, 124.38944365718634799, + 55.859324194880173309, 70.135680449602659792, 3.4215727805167261977, 50.357467090754653327, + 82.609213200321391923, 126.56036298486651503, 111.61511068280015024, 4.0209915868908865377, + 21.793030150925915223, 67.736743246761761839, 118.23604370076282066, 27.455584008795995032, + 97.231723022101505194, 85.880139030348800588, 112.4551362849160796, 107.76116512927546864, + 4.544852381462987978, 42.456434029572847066, 60.014400325984752271, 77.859090945959906094, + 106.67573495996475685, 5.6342146032257005572, 102.38717528827328351, 82.266433890847110888, + 116.50302409768846701, 19.365657302438194165, 125.71672442534691072, 72.357140845866524614, + 90.225264551398140611, 39.351695026598463301, 11.290521626106055919, 56.24536832135709119, + 33.349535588658909546, 69.714776977136352798, 107.98214959887991427, 68.71184459289725055, + 16.402466051589726703, 93.046860693499183981, 79.53925859005539678, 48.755238885623839451, + 47.905081655258982209, 103.17557784726159298, 69.138154051146557322, 24.131208634629729204, + 18.362900531745253829, 22.382733911104878644, 0.16102761062938952819, 6.9172703905605885666, + 82.071815750729001593, 41.172578575740772067, 44.020666412387072342, 40.359047853031370323, + 19.21079833764815703, 96.731725516616279492, 108.52852706061821664, 37.719827983368304558, + 33.965193057792930631, 110.99958705910830759, 48.707065016777050914, 39.800087953408365138, + 43.19003027402141015, 115.41247106427908875, 47.622809821488772286, 104.73968583864916582, + 92.414185961049952311, 74.625076175329013495, 126.09423098344632308, 10.275891031920764362, + 104.44799600061378442, 74.837540803473530104, 60.755488391572725959, 123.32527549991209526, + 90.766841707791172666, 51.044356508409691742, 82.207827961283328477, 16.186215540536068147, + 113.28643083573842887, 65.59786575367252226, 55.697225104962853948, 11.165700448687857715, + 44.68964867309841793, 73.041658513102447614, 123.05386858715064591, 81.60400964271320845, + 64.424871329130837694, 82.615502695669420063, 124.97741086017413181, 67.143944618943351088, + 67.59235884818554041, 120.73604026328757755, 64.941084450198104605, 35.186442075962986564, + 93.17347949133545626, 93.350990778886625776, 15.527861660455528181, 79.911371154532389482, + 74.484896991732966853, 120.73439131560371607, 127.53774613792847958, 88.37701855464183609, + 87.793622417801088886, 93.605329781032196479, 4.4440071578028437216, 123.5988439502325491, + 81.002793174906400964, 68.591042283860588213, 22.169461291359766619, 6.5236244672414613888, + 103.88041019984302693, 117.24801611803923151, 81.334192258833354572, 30.810147156091261422, + 124.59283683639660012, 56.429171016599866562, 81.354055573843652382, 90.028906320865644375, + 17.137778697670000838, 44.350702118928893469, 72.209634280505269999, 97.320165811230253894, + 74.046844241413054988, 45.654079769006784773, 10.075495162702281959, 126.41002606707479572, + 82.898736176139209419, 66.443629396631877171, 63.126382037753501208, 64.880800583076052135, + 12.598858602887048619, 27.54158561510121217, 2.3452786732814274728, 13.19645242024489562, + 34.433183904955512844, 34.992727989774721209, 114.99626821587298764, 117.88144510594429448, + 96.370568964255653555, 125.90018218824843643, 38.427269395757321035, 112.88772061655981815, + 109.51768671670288313, 56.356478772719128756, 11.033050348607503111, 67.839080968162306817, + 122.52465796617980232, 85.809519217422348447, 36.541822638897428988, 51.833803809262462892, + 104.16306285053724423, 26.6382202622735349, 53.915313801375305047, 5.5749089876153448131, + 23.298953462850477081, 54.446352560142258881, 108.52829572243717848, 32.166563875325664412, + 78.078837781671609264, 59.987299486361735035, 25.87058515442913631, 23.697892919495643582, + 85.727554823817627039, 48.770571733100950951, 103.60763784182927338, 114.62691718075802783, + 111.98683081768467673, 51.54040462745615514, 112.45684726627223426, 114.83929766207438661, + 98.263751716847764328, 50.559166963241295889, 65.926523709829780273, 64.036615477889426984, + 104.5335049364475708, 9.3162798759331053589, 14.692302527284482494, 83.248992715125496034, + 43.638270471998112043, 33.435909005394933047, 17.560373274496669183, 52.549961882312345551, + 26.509962471969629405, 90.071308048809441971, 38.076551473706786055, 27.890405045935040107, + 14.959593256488005864, 1.117739041266759159, 85.210841969677858287, 82.835889513469737722, + 120.14889296147157438, 108.17673430062131956, 104.62834902773829526, 84.413288936964818276, + 92.196950623594602803, 93.650391511640918907, 73.343077731642551953, 0.75086882352115935646, + 120.60610003543115454, 81.888142501571564935, 48.428860217947658384, 39.939901309047854738, + 26.433112006932788063, 89.577212871077790624, 124.63585422873802599, 113.34542519495516899, + 82.07199996714189183, 73.183258641874999739, 67.624080502329888986, 68.650832869585428853, + 26.978872158157173544, 78.600692893207451561, 62.986365505417779787, 14.378247170974645996, + 100.13666331390413688, 40.230956589799461653, 123.75273144196034991, 60.274130354100634577, + 15.713306391509831883, 124.68987208334146999, 126.80170821127103409, 93.288798450252215844, + 47.546293748961033998, 119.54032247755822027, 127.42172455453692237, 116.1302497836513794, + 126.24105584444259875, 123.75796027560136281, 59.327257320921489736, 57.526399219030281529, + 42.971267894379707286, 13.999397295861854218, 100.89893727066373685, 91.163309284835122526, + 113.24170340356067754, 124.25628986881565652, 57.812779726154985838, 113.11576685476029525, + 54.927645119540102314, 25.02048718906371505, 96.656002431413071463, 75.044818781498179305, + 62.866723929404543014, 118.69491479032149073, 116.24382912483633845, 71.382755779686704045, + 99.879445542454050155, 85.465533272181346547, 98.721719187597045675, 103.05876271170927794, + 38.586647035117493942, 103.84525818336260272, 53.551605270335130626, 95.20576703034384991, + 38.666652661271655234, 87.094003914960921975, 73.645808016291994136, 93.765166375171247637, + 88.240044268699421082, 100.60958274539734703, 113.03637065139628248, 29.885582496663118945, + 85.785034230055316584, 113.87423861007846426, 51.926815795748552773, 94.395018500130390748, + 63.747492943253746489, 30.512299298872676445, 27.538544799397641327, 53.061881421021098504, + 54.944744383185025072, 94.15678136994029046, 69.0377671882379218, 43.095146902644046349, + 62.938116076358710416, 113.87191379105206579, 104.14985299972249777, 64.320813589667523047, + 43.990317320283793379, 30.262852241143264109, 98.105891542574681807, 126.73134646810649429, + 20.020909125443722587, 42.376586405043781269, 7.5206156058120541275, 94.112832465012616012, + 125.93254823172173928, 45.79589777800720185, 49.67566137218818767, 41.331472824160300661, + 84.079203658089681994, 124.56691374636284309, 54.547447723227378447, 17.193147922997013666, + 111.59655793991623796, 84.895647589310101466, 63.748409277191967703, 80.483325586614228087, + 31.038093147421022877, 62.481240245622757357, 40.04355602792929858, 108.75896816357271746, + 92.877262344820337603, 43.623858377934084274, 72.898045505782647524, 84.19632898468626081, + 115.71013483978822478, 33.404756997733784374, 19.749651859005098231, 33.225473749542288715, + 75.372745615190069657, 95.05855916174914455, 73.05304794951734948, 73.768699062726227567, + 10.810622386183240451, 83.096978623289032839, 56.040527468569052871, 90.008099927457806189, + 100.52078581396926893, 116.14390168489990174, 62.930802218121243641, 90.494542255029955413, + 72.852182978989731055, 32.675586313478561351, 124.59342675083098584, 23.811389973227051087, + 3.9855371291196206585, 85.751529161083453801, 13.649551767543016467, 49.434841467467776965, + 42.136238367693295004, 31.322957419157319237, 58.055887224320031237, 118.80830677545600338, + 80.74921011443802854, 73.727159330948779825, 50.834374951780773699, 82.709648743770230794, + 108.76623875423319987, 106.25111773411117611, 96.382420537993311882, 42.111245300759037491, + 49.933641679333959473, 23.590814828308793949, 8.443615063042670954, 4.7752212458726717159, + 56.433408471664733952, 61.939494338199438062, 65.002825200721417787, 36.516665829811245203, + 125.4844266399704793, 91.060794380980951246, 11.135569354395556729, 45.526949353272357257, + 32.031287754201912321, 119.33055755093664629, 118.27232862452001427, 11.787633754509442952, + 33.600956489477539435, 14.664952383056515828, 99.710414283505087951, 25.44224606231728103, + 61.089045248983893543, 51.938467919964750763, 24.501330517894530203, 65.925999002531170845, + 98.867657073908048915, 117.29562036082643317, 73.850203806261561112, 39.602818171872058883, + 33.433337304031738313, 120.77888731437269598, 111.7186483897639846, 12.271360899205319583, + 6.8431455610334523953, 100.71493418151294463, 37.218426400646421826, 125.12072596973666805, + 95.230221365600300487, 8.0419831737817730755, 43.586060301855468424, 7.4734864935271616559, + 108.47208740152564133, 54.911168017595628044, 66.463446044206648367, 43.760278060701239156, + 96.910272569835797185, 87.522330258550937288, 9.089704762925975956, 84.912868059145694133, + 120.02880065197314252, 27.718181891923450166, 85.351469919929513708, 11.268429206455039093, + 76.774350576550205005, 36.532867781697859755, 105.00604819537693402, 38.731314604880026309, + 123.43344885069745942, 16.714281691736687208, 52.450529102796281222, 78.703390053196926601, + 22.581043252212111838, 112.49073664271418238, 66.699071177321457071, 11.429553954276343575, + 87.964299197763466509, 9.4236891857945010997, 32.804932103183091385, 58.09372138700200594, + 31.078517180110793561, 97.510477771247678902, 95.810163310521602398, 78.351155694526823936, + 10.276308102293114644, 48.262417269259458408, 36.725801063490507659, 44.765467822209757287, + 0.32205522125877905637, 13.834540781124815112, 36.143631501458003186, 82.345157151481544133, + 88.041332824774144683, 80.718095706062740646, 38.421596675299952039, 65.463451033236196963, + 89.057054121236433275, 75.439655966736609116, 67.930386115589499241, 93.99917411821661517, + 97.414130033554101828, 79.600175906816730276, 86.38006054804645828, 102.8249421285581775, + 95.245619642981182551, 81.479371677301969612, 56.828371922103542602, 21.250152350661664968, + 124.18846196689264616, 20.551782063845166704, 80.895992001231206814, 21.675081606947060209, + 121.5109767831490899, 118.65055099982782849, 53.533683415582345333, 102.08871301682302146, + 36.415655922566656955, 32.372431081075774273, 98.572861671480495716, 3.1957315073450445198, + 111.3944502099257079, 22.331400897375715431, 89.379297346200473839, 18.083317026208533207, + 118.10773717430492979, 35.208019285430054879, 0.84974265826531336643, 37.231005391342478106, + 121.9548217203519016, 6.287889237890340155, 7.1847176963747187983, 113.47208052657879307, + 1.8821689003962092102, 70.372884151929611107, 58.346958982674550498, 58.701981557773251552, + 31.055723320914694341, 31.822742309068416944, 20.969793983469571685, 113.46878263121107011, + 127.07549227586059715, 48.754037109287310159, 47.587244835605815751, 59.210659562064392958, + 8.888014315609325422, 119.19768790046873619, 34.005586349816439906, 9.1820845677211764269, + 44.338922582719533239, 13.047248934486560756, 79.76082039968969184, 106.49603223608210101, + 34.668384517666709144, 61.620294312186160823, 121.18567367279320024, 112.8583420332033711, + 34.708111147690942744, 52.05781264173128875, 34.275557395340001676, 88.701404237861424917, + 16.419268561014177976, 66.640331622464145767, 20.093688482826109976, 91.308159538013569545, + 20.150990325408201898, 124.82005213415322942, 37.797472352282056818, 4.8872587932637543418, + 126.2527640755106404, 1.7616011661521042697, 25.197717205774097238, 55.08317123020242434, + 4.6905573465628549457, 26.392904840489791241, 68.866367809911025688, 69.985455979553080397, + 101.99253643174961326, 107.76289021189222694, 64.741137928514945088, 123.80036437649687286, + 76.85453879151828005, 97.775441233123274287, 91.035373433405766264, 112.71295754543825751, + 22.0661006972186442, 7.6781619363282516133, 117.04931593236324261, 43.619038434844696894, + 73.083645277794857975, 103.66760761852856376, 80.326125701074488461, 53.276440524547069799, + 107.83062760275061009, 11.149817975230689626, 46.597906925700954162, 108.89270512028815574, + 89.056591444874356966, 64.333127750654966803, 28.157675563343218528, 119.97459897272347007, + 51.74117030885827262, 47.395785838994925143, 43.455109647635254078, 97.54114346620553988, + 79.215275683662184747, 101.25383436151969363, 95.973661635369353462, 103.08080925491594826, + 96.913694532548106508, 101.67859532415241119, 68.527503433695528656, 101.11833392648622976, + 3.8530474196631985251, 0.073230955782491946593, 81.067009872895141598, 18.632559751866210718, + 29.384605054572602967, 38.497985430250992067, 87.276540943996224087, 66.871818010789866094, + 35.120746548993338365, 105.0999237646246911, 53.019924943942896789, 52.142616097618883941, + 76.15310294741357211, 55.780810091870080214, 29.919186512976011727, 2.2354780825371562969, + 42.421683939359354554, 37.671779026943113422, 112.29778592294678674, 88.353468601246277103, + 81.256698055480228504, 40.826577873933274532, 56.393901247192843584, 59.300783023285475792, + 18.686155463285103906, 1.5017376470459566917, 113.21220007086594705, 35.77628500314312987, + 96.857720435895316768, 79.879802618095709477, 52.866224013869214104, 51.154425742159219226, + 121.27170845747968997, 98.69085038991397596, 36.143999934287421638, 18.366517283753637457, + 7.2481610046634159517, 9.3016657391708577052, 53.957744316317985067, 29.201385786414903123, + 125.97273101083555957, 28.756494341952929972, 72.27332662780827377, 80.461913179602561286, + 119.50546288392069982, 120.54826070820126915, 31.426612783023301745, 121.37974416668657796, + 125.60341642254570615, 58.577596900504431687, 95.092587497925705975, 111.08064495512007852, + 126.84344910907748272, 104.26049956730639678, 124.48211168888883549, 119.51592055120272562, + 118.65451464184297947, 115.05279843806056306, 85.942535788759414572, 27.998794591727346415, + 73.797874541331111686, 54.32661856967388303, 98.483406807124993065, 120.51257973763131304, + 115.62555945231360965, 98.231533709520590492, 109.85529023908020463, 50.040974378131068079, + 65.312004862829780905, 22.089637562996358611, 125.73344785881272401, 109.38982958064661943, + 104.48765824967631488, 14.765511559377046069, 71.75889108491173829, 42.931066544366331073, + 69.443438375197729329, 78.117525423418555874, 77.173294070238625864, 79.690516366725205444, + 107.10321054067389923, 62.411534060687699821, 77.333305322546948446, 46.188007829925481929, + 19.29161603258762625, 59.530332750346133253, 48.480088537402480142, 73.21916549079833203, + 98.072741302792564966, 59.77116499332987587, 43.570068460114271147, 99.748477220156928524, + 103.85363159150074353, 60.790037000260781497, 127.49498588650749298, 61.02459859774535289, + 55.077089598795282654, 106.12376284204219701, 109.88948876637368812, 60.3135627398842189, + 10.075534376475843601, 86.190293805288092699, 125.87623215272105881, 99.743827582107769558, + 80.29970599944863352, 0.64162717933504609391, 87.980634640567586757, 60.525704482290166197, + 68.211783085153001593, 125.46269293621298857, 40.041818250887445174, 84.753172810087562539, + 15.041231211627746234, 60.225664930028870003, 123.86509646344347857, 91.591795556014403701, + 99.35132274437637534, 82.662945648324239301, 40.158407316183001967, 121.13382749272568617, + 109.09489544645475689, 34.38629584599766531, 95.193115879836113891, 41.791295178620202933, + 127.49681855438757339, 32.966651173228456173, 62.076186294842045754, 124.96248049124551471, + 80.087112055862235138, 89.517936327149072895, 57.754524689640675206, 87.247716755871806527, + 17.796091011568933027, 40.392657969376159599, 103.42026967957644956, 66.809513995467568748, + 39.499303718010196462, 66.450947499088215409, 22.745491230383777292, 62.11711832350192708, + 18.106095899038336938, 19.537398125452455133, 21.621244772370118881, 38.193957246578065678, + 112.08105493714174372, 52.016199854919250356, 73.041571627942175837, 104.28780336979980348, + 125.86160443624612526, 52.989084510063548805, 17.70436595797946211, 65.351172626960760681, + 121.18685350166197168, 47.622779946454102173, 7.9710742582428792957, 43.503058322166907601, + 27.299103535086032934, 98.869682934935553931, 84.272476735386590008, 62.645914838314638473, + 116.11177444864370045, 109.61661355091564474, 33.49842022887969506, 19.45431866189755965, + 101.66874990356518538, 37.419297487544099567, 89.532477508470037719, 84.502235468225990189, + 64.764841075986623764, 84.222490601518074982, 99.867283358667918947, 47.181629656617587898, + 16.887230126085341908, 9.5504424917453434318, 112.8668169433294679, 123.8789886764025141, + 2.0056504014428355731, 73.033331659626128385, 122.96885327994459658, 54.121588761961902492, + 22.271138708791113459, 91.053898706544714514, 64.062575508407462621, 110.66111510187693057, + 108.54465724904002855, 23.575267509018885903, 67.20191297895507887, 29.329904766116669634, + 71.420828567010175902, 50.88449212463456206, 122.17809049796778709, 103.87693583992950153, + 49.002661035792698385, 3.8519980050659796689, 69.735314147819735808, 106.59124072165650432, + 19.700407612523122225, 79.205636343744117767, 66.866674608067114605, 113.55777462874902994, + 95.437296779527969193, 24.542721798410639167, 13.68629112207054277, 73.429868363025889266, + 74.43685280129648163, 122.24145193947697408, 62.460442731200600974, 16.083966347563546151, + 87.172120603710936848, 14.946972987057961291, 88.944174803051282652, 109.82233603519489407, + 4.9268920884132967331, 87.52055612140611629, 65.820545139675232349, 47.044660517101874575, + 18.179409525855589891, 41.825736118295026245, 112.05760130394628504, 55.436363783850538312, + 42.702939839859027416, 22.536858412913716165, 25.548701153100410011, 73.065735563399357488, + 82.012096390753868036, 77.462629209763690596, 118.86689770139491884, 33.428563383473374415, + 104.90105820559620042, 29.406780106393853202, 45.162086504427861655, 96.98147328543200274, + 5.3981423546429141425, 22.859107908556325128, 47.928598395526933018, 18.847378371589002199, + 65.609864206366182771, 116.18744277400401188, 62.1570343602252251, 67.020955542498995783, + 63.620326621046842774, 28.702311389053647872, 20.552616204586229287, 96.524834538518916816, + 73.451602126981015317, 89.530935644419514574, 0.64411044251755811274, 27.669081562249630224, + 72.28726300291964435, 36.690314302966726245, 48.082665649551927345, 33.436191412125481293, + 76.843193350603542058, 2.926902066476031905, 50.114108242476504529, 22.879311933476856211, + 7.8607722311826364603, 59.998348236436868319, 66.828260067111841636, 31.20035181363709853, + 44.760121096096554538, 77.649884257119992981, 62.491239285966003081, 34.958743354603939224, + 113.6567438442070852, 42.500304701326967916, 120.37692393378529232, 41.103564127693971386, + 33.791984002462413628, 43.350163213897758396, 115.02195356630181777, 109.30110199965565698, + 107.06736683116832864, 76.177426033646042924, 72.831311845133313909, 64.744862162155186525, + 69.145723342960991431, 6.3914630146937270183, 94.788900419851415791, 44.66280179475506884, + 50.758594692400947679, 36.166634052420704393, 108.21547434860985959, 70.416038570860109758, + 1.6994853165306267329, 74.46201078268859419, 115.90964344070380321, 12.57577847578068031, + 14.369435392753075575, 98.944161053157586139, 3.7643378007960563991, 12.745768303859222215, + 116.693917965349101, 117.4039631155465031, 62.111446641829388682, 63.645484618136833888, + 41.93958796694278135, 98.937565262425778201, 126.15098455172119429, 97.508074218574620318, + 95.174489671211631503, 118.42131912412878592, 17.776028631222288823, 110.39537580093747238, + 68.011172699632879812, 18.364169135442352854, 88.677845165439066477, 26.094497868976759491, + 31.521640799383021658, 84.992064472164202016, 69.336769035333418287, 123.24058862437595963, + 114.37134734559003846, 97.716684066406742204, 69.416222295381885488, 104.1156252834625775, + 68.551114790683641331, 49.402808475722849835, 32.838537122031993931, 5.2806632449282915331, + 40.18737696565585793, 54.61631907602713909, 40.301980650820041774, 121.64010426830645883, + 75.594944704564113636, 9.7745175865311466623, 124.50552815102128079, 3.5232023323042085394, + 50.395434411548194475, 110.16634246040484868, 9.3811146931257098913, 52.78580968098322046, + 9.7327356198256893549, 11.970911959109798772, 75.985072863502864493, 87.525780423788091866, + 1.4822758570335281547, 119.60072875299738371, 25.709077583040198078, 67.550882466250186553, + 54.070746866815170506, 97.425915090876515023, 44.1322013944372884, 15.356323872660141205, + 106.09863186472648522, 87.238076869693031767, 18.167290555593353929, 79.335215237060765503, + 32.652251402148976922, 106.55288104909777758, 87.661255205501220189, 22.299635950461379252, + 93.195813851405546302, 89.785410240579949459, 50.113182889752351912, 0.66625550130993360654, + 56.315351126690075034, 111.94919794544694014, 103.48234061771654524, 94.791571677989850286, + 86.910219295274146134, 67.082286932414717739, 30.430551367328007473, 74.507668723043025238, + 63.947323270742344903, 78.161618509835534496, 65.827389065099850995, 75.357190648308460368, + 9.0550068673946952913, 74.236667852972459514, 7.7060948393263970502, 0.14646191156862187199, + 34.134019745790283196, 37.265119503732421435, 58.769210109145205934, 76.995970860505622113, + 46.553081887996086152, 5.7436360215797321871, 70.241493097990314709, 82.199847529249382205, + 106.03984988788579358, 104.28523219524140586, 24.30620589482714422, 111.56162018374016043, + 59.838373025952023454, 4.4709561650743125938, 84.843367878718709107, 75.343558053889864823, + 96.59557184589721146, 48.706937202496192185, 34.513396110960457008, 81.653155747866549063, + 112.78780249438568717, 118.60156604657095158, 37.372310926570207812, 3.0034752940955513623, + 98.424400141731894109, 71.552570006289897719, 65.715440871794271516, 31.759605236191418953, + 105.73244802773842821, 102.30885148432207643, 114.54341691496301792, 69.381700779827951919, + 72.287999868574843276, 36.733034567507274915, 14.496322009326831903, 18.60333147834171541, + 107.91548863263597013, 58.402771572833444225, 123.94546202167111915, 57.512988683909497922, + 16.546653255620185519, 32.92382635920876055, 111.01092576784503763, 113.09652141640253831, + 62.853225566050241468, 114.75948833337679389, 123.20683284509141231, 117.15519380101250135, + 62.185174995855049929, 94.161289910243795021, 125.68689821815860341, 80.520999134616431547, + 120.96422337778130895, 111.03184110240908922, 109.30902928368959692, 102.10559687612476409, + 43.885071577518829145, 55.997589183458330808, 19.595749082662223373, 108.65323713935140404, + 68.96681361425362411, 113.02515947526626405, 103.25111890463085729, 68.463067419044818962, + 91.710580478160409257, 100.08194875626577414, 2.6240097256595618092, 44.1792751259963552, + 123.46689571762908599, 90.779659161296876846, 80.975316499352629762, 29.531023118757730117, + 15.517782169823476579, 85.862133088736300124, 10.886876750399096636, 28.235050846840749728, + 26.346588140480889706, 31.381032733454048866, 86.206421081347798463, 124.82306812137903762, + 26.666610645093896892, 92.376015659850963857, 38.583232065175252501, 119.06066550069226651, + 96.960177074808598263, 18.438330981600302039, 68.145482605585129932, 119.54232998665975174, + 87.140136920232180273, 71.496954440317495028, 79.70726318300148705, 121.58007400052520097, + 126.98997177301498596, 122.04919719549070578, 110.15417919759420329, 84.247525684088031994, + 91.778977532747376245, 120.6271254797684378, 20.151068752955325181, 44.380587610579823377, + 123.7524643054457556, 71.487655164219177095, 32.59941199889726704, 1.2832543586737301666, + 47.961269281135173514, 121.05140896458397037, 8.4235661703096411657, 122.92538587242597714, + 80.083636501778528327, 41.506345620175125077, 30.082462423255492467, 120.45132986006137799, + 119.73019292689059512, 55.18359111203244538, 70.702645488756388659, 37.325891296648478601, + 80.316814632369641913, 114.26765498545501032, 90.189790892909513786, 68.772591691998968599, + 62.386231759672227781, 83.582590357244043844, 126.99363710877514677, 65.933302346456912346, + 124.15237258968772949, 121.92496098249466741, 32.174224111728108255, 51.03587265429814579, + 115.50904937928498839, 46.495433511743613053, 35.592182023137866054, 80.785315938755957177, + 78.840539359156537103, 5.6190279909351374954, 78.998607436024030903, 4.9018949981764308177, + 45.490982460767554585, 124.23423664700385416, 36.212191798076673876, 39.074796250904910266, + 43.242489544740237761, 76.387914493159769336, 96.162109874283487443, 104.03239970984213869, + 18.083143255887989653, 80.575606739603244932, 123.72320887249225052, 105.97816902012709761, + 35.408731915962562198, 2.7023452539251593407, 114.37370700332394335, 95.245559892908204347, + 15.942148516485758591, 87.006116644333815202, 54.598207070175703848, 69.73936586987474584, + 40.544953470773180015, 125.29182967663291492, 104.22354889729103888, 91.233227101831289474, + 66.996840457759390119, 38.908637323798757279, 75.337499807130370755, 74.838594975091837114, + 51.064955016943713417, 41.004470936455618357, 1.5296821519768855069, 40.444981203039787943, + 71.734566717335837893, 94.363259313235175796, 33.774460252170683816, 19.100884983494324842, + 97.733633886662573786, 119.7579773528050282, 4.011300802889309125, 18.066663319255894748, + 117.93770655988919316, 108.24317752392380498, 44.542277417585864896, 54.107797413093067007, + 0.12515101681856322102, 93.322230203757499112, 89.089314498080057092, 47.150535018041409785, + 6.4038259579101577401, 58.659809532236977248, 14.841657134020351805, 101.7689842492727621, + 116.35618099593921215, 79.753871679859003052, 98.00532207158539677, 7.7039960101355973165, + 11.470628295643109595, 85.18248144331300864, 39.400815225049882429, 30.411272687491873512, + 5.7333492161378671881, 99.115549257501697866, 62.874593559055938385, 49.085443596821278334, + 27.372582244144723518, 18.859736726055416511, 20.873705602596601238, 116.48290387895394815, + 124.92088546240120195, 32.167932695130730281, 46.344241207421873696, 29.89394597411956056, + 49.888349606106203282, 91.644672070389788132, 9.8537841768302314449, 47.041112242815870559, + 3.6410902793504646979, 94.08932103420374915, 36.358819051711179782, 83.651472236593690468, + 96.115202607892570086, 110.87272756770107662, 85.405879679718054831, 45.073716825827432331, + 51.097402306204458, 18.131471126802352956, 36.024192781511374051, 26.925258419531019172, + 109.73379540278983768, 66.857126766950386809, 81.802116411192400847, 58.813560212787706405, + 90.324173008859361289, 65.96294657086400548, 10.796284709285828285, 45.718215817112650257, + 95.857196791053866036, 37.694756743181642378, 3.21972841273600352, 104.37488554800802376, + 124.31406872045408818, 6.0419110849979915656, 127.24065324209368555, 57.404622778107295744, + 41.105232409176096553, 65.04966907704147161, 18.903204253965668613, 51.061871288839029148, + 1.2882208850351162255, 55.338163124502898427, 16.5745260058392887, 73.380628605933452491, + 96.16533129910385469, 66.872382824254600564, 25.686386701207084116, 5.8538041329520638101, + 100.22821648495300906, 45.758623866953712422, 15.721544462365272921, 119.99669647287737462, + 5.6565201342236832716, 62.400703627274197061, 89.520242192196747055, 27.299768514239985961, + 124.98247857193200616, 69.917486709211516427, 99.313487688414170407, 85.00060940265757381, + 112.75384786757058464, 82.207128255387942772, 67.583968004924827255, 86.700326427799154771, + 102.04390713260727352, 90.602203999314951943, 86.134733662340295268, 24.354852067295723828, + 17.662623690270265797, 1.489724324314011028, 10.291446685921982862, 12.782926029391092015, + 61.577800839702831581, 89.325603589510137681, 101.51718938480189536, 72.333268104845046764, + 88.430948697223357158, 12.832077141720219515, 3.3989706330648914445, 20.92402156538082636, + 103.81928688140760642, 25.15155695156136062, 28.73887078550978913, 69.888322106315172277, + 7.5286756015921127982, 25.491536607722082408, 105.38783593070183997, 106.80792623109300621, + 124.22289328365877736, 127.29096923627366778, 83.879175933889200678, 69.875130524855194381, + 124.30196910344602657, 67.016148437152878614, 62.348979342426900985, 108.84263824825757183, + 35.552057262448215624, 92.790751601878582733, 8.0223453992657596245, 36.728338270888343686, + 49.355690330878132954, 52.188995737953518983, 63.043281598769681295, 41.984128944332042011, + 10.673538070670474553, 118.48117724875555723, 100.74269469118371489, 67.433368132817122387, + 10.832444590767408954, 80.231250566928792978, 9.1022295813672826625, 98.805616951445699669, + 65.677074244063987862, 10.561326489856583066, 80.37475393131171586, 109.23263815205427818, + 80.603961301643721526, 115.28020853661655565, 23.189889409128227271, 19.549035173065931303, + 121.01105630204256158, 7.0464046646084170789, 100.79086882310002693, 92.33268492080969736, + 18.762229386251419783, 105.57161936196644092, 19.46547123965137871, 23.941823918223235523, + 23.970145727009366965, 47.051560847576183733, 2.9645517140706942882, 111.20145750599476742, + 51.418155166084034136, 7.1017649325003731064, 108.14149373363397899, 66.851830181753030047, + 88.2644027888745768, 30.71264774532392039, 84.197263729456608417, 46.476153739386063535, + 36.334581111190345837, 30.670430474121531006, 65.304502804301591823, 85.105762098199193133, + 47.322510411002440378, 44.599271900926396484, 58.391627702814730583, 51.570820481159898918, + 100.22636577950470382, 1.3325110026198672131, 112.63070225338378805, 95.898395890897518257, + 78.964681235436728457, 61.583143355983338552, 45.820438590551930247, 6.1645738648294354789, + 60.861102734659652924, 21.015337446086050477, 127.89464654148832778, 28.323237019674706971, + 3.6547781302033399697, 22.714381296616920736, 18.110013734793028561, 20.473335705944919027, + 15.4121896786527941, 0.29292382313724374399, 68.268039491580566391, 74.530239007464842871, + 117.53842021829404985, 25.991941721011244226, 93.106163775992172305, 11.487272043163102353, + 12.482986195984267397, 36.399695058502402389, 84.079699775775225135, 80.570464390482811723, + 48.61241178965792642, 95.123240367480320856, 119.67674605190404691, 8.9419123301522631664, + 41.686735757441056194, 22.687116107783367625, 65.191143691794422921, 97.41387440499238437, + 69.026792221924551995, 35.306311495736736106, 97.575604988775012316, 109.20313209314190317, + 74.744621853140415624, 6.0069505881947407033, 68.848800283467426198, 15.105140012583433418, + 3.4308817435885430314, 63.519210472386475885, 83.464896055480494397, 76.61770296864779084, + 101.08683382992967381, 10.763401559659541817, 16.575999737149686553, 73.466069135014549829, + 28.992644018653663807, 37.2066629566870688, 87.830977265271940269, 116.80554314567052643, + 119.89092404334223829, 115.02597736781899584, 33.093306511240371037, 65.847652718421159079, + 94.021851535693713231, 98.193042832805076614, 125.70645113210412092, 101.51897666675722576, + 118.4136656901864626, 106.31038760202500271, 124.37034999171373784, 60.32257982049122802, + 123.3737964363208448, 33.041998269236501073, 113.92844675556625589, 94.063682204821816413, + 90.618058567382831825, 76.211193752249528188, 87.770143155037658289, 111.99517836691666162, + 39.191498165328084724, 89.306474278706446057, 9.9336272285108861979, 98.050318950536166085, + 78.502237809265352553, 8.9261348380932759028, 55.421160956324456492, 72.163897512531548273, + 5.2480194513191236183, 88.358550251996348379, 118.93379143526180997, 53.559318322597391671, + 33.950632998705259524, 59.062046237515460234, 31.035564339650591137, 43.724266177472600248, + 21.773753500798193272, 56.470101693681499455, 52.693176280961779412, 62.762065466911735712, + 44.412842162699234905, 121.64613624275807524, 53.333221290191431763, 56.752031319701927714, + 77.166464130354142981, 110.12133100138817099, 65.920354149617196526, 36.876661963204242056, + 8.2909652111738978419, 111.08465997332314146, 46.280273840467998525, 14.993908880638628034, + 31.414526366006612079, 115.16014800105403992, 125.97994354603360989, 116.09839439098504954, + 92.308358395192044554, 40.495051368179701967, 55.557955065498390468, 113.2542509595368756, + 40.302137505910650361, 88.761175221163284732, 119.50492861089514918, 14.97531032843835419, + 65.19882399779453408, 2.5665087173474603333, 95.922538562273985008, 114.10281792916794075, + 16.84713234062292031, 117.85077174485559226, 32.167273003557056654, 83.012691240350250155, + 60.164924846514622914, 112.90265972012639395, 111.46038585378119024, 110.36718222406852874, + 13.405290977512777317, 74.651782593300595181, 32.633629264742921805, 100.53530997091365862, + 52.379581785822665552, 9.5451833839979371987, 124.77246351934809354, 39.165180714491725666, + 125.98727421755393152, 3.8666046929174626712, 120.30474517937909695, 115.84992196498933481, + 64.34844822345621651, 102.07174530859992956, 103.01809875856997678, 92.990867023487226106, + 71.184364046279370086, 33.570631877515552333, 29.681078718313074205, 11.23805598187391297, + 29.997214872048061807, 9.8037899963528616354, 90.981964921538747149, 120.46847329400770832, + 72.424383596153347753, 78.149592501809820533, 86.484979089484113501, 24.77582898632317665, + 64.324219748570612865, 80.064799419684277382, 36.166286511779617285, 33.151213479210127844, + 119.44641774498813902, 83.956338040254195221, 70.817463831925124396, 5.4046905078539566603, + 100.74741400665152469, 62.491119785816408694, 31.884297032975155162, 46.012233288667630404, + 109.19641414035504567, 11.47873173974949168, 81.08990694154999801, 122.58365935326946783, + 80.447097794585715747, 54.466454203666216927, 5.9936809155187802389, 77.817274647601152537, + 22.674999614264379488, 21.677189950183674227, 102.12991003388742683, 82.008941872911236715, + 3.0593643039537710138, 80.889962406083213864, 15.469133434675313765, 60.726518626470351592, + 67.548920504341367632, 38.201769966992287664, 67.467267773328785552, 111.51595470561005641, + 8.02260160577861825, 36.133326638515427476, 107.8754131197820243, 88.486355047847609967, + 89.084554835171729792, 108.21559482618613401, 0.25030203364076442085, 58.644460407518636202, + 50.178628996160114184, 94.30107003608281957, 12.80765191582031548, 117.3196190644739545, + 29.683314268044341588, 75.537968498549162177, 104.71236199188206228, 31.507743359721644083, + 68.010644143170793541, 15.407992020271194633, 22.94125659128985717, 42.36496288662601728, + 78.801630450099764857, 60.822545374983747024, 11.466698432279372355, 70.231098515003395732, + 125.74918711811187677, 98.170887193642556667, 54.745164488289447036, 37.719473452110833023, + 41.747411205196840456, 104.96580775791153428, 121.8417709248024039, 64.335865390261460561, + 92.688482414843747392, 59.78789194823912112, 99.776699212216044543, 55.289344140779576264, + 19.70756835366046289, 94.082224485631741118, 7.2821805587045673747, 60.1786420684074983, + 72.717638103425997542, 39.302944473191018915, 64.23040521578877815, 93.745455135405791225, + 42.811759359436109662, 90.147433651654864661, 102.194804612408916, 36.262942253604705911, + 72.048385563022748102, 53.850516839065676322, 91.46759080558331334, 5.7142535339044115972, + 35.604232822384801693, 117.62712042557905079, 52.648346017722360557, 3.9258931417280109599, + 21.59256941857165657, 91.436431634228938492, 63.714393582107732072, 75.389513486363284755, + 6.4394568254756450187, 80.749771096019685501, 120.62813744090817636, 12.08382216999962111, + 126.4813064841873711, 114.80924555621459149, 82.210464818355831085, 2.0993381540829432197, + 37.806408507931337226, 102.1237425776780583, 2.576441770070232451, 110.67632624900579685, + 33.14905201168221538, 18.76125721187054296, 64.330662598211347358, 5.744765648509201128, + 51.372773402414168231, 11.707608265907765599, 72.456432969906018116, 91.517247733907424845, + 31.44308892473418382, 111.99339294575474923, 11.313040268447366543, 124.8014072545520321, + 51.040484384393494111, 54.599537028483609902, 121.9649571438676503, 11.834973418426670833, + 70.626975376831978792, 42.001218805318785599, 97.507695735144807259, 36.414256510779523524, + 7.1679360098532924894, 45.400652855601947522, 76.087814265218185028, 53.204407998633541865, + 44.269467324680590536, 48.709704134591447655, 35.325247380540531594, 2.9794486486280220561, + 20.582893371843965724, 25.565852058782184031, 123.15560167940930114, 50.651207179023913341, + 75.034378769607428694, 16.666536209693731507, 48.861897394446714316, 25.664154283440439031, + 6.797941266129782889, 41.848043130765290698, 79.638573762815212831, 50.30311390312272124, + 57.477741571023216238, 11.776644212630344555, 15.057351203184225596, 50.983073215447802795, + 82.77567186140731792, 85.615852462189650396, 120.44578656732119271, 126.58193847255097353, + 39.758351867782039335, 11.75026104971402674, 120.60393820689569111, 6.0322968743057572283, + 124.69795868485743995, 89.685276496515143663, 71.104114524900069227, 57.581503203757165466, + 16.044690798531519249, 73.456676541776687372, 98.711380661756265908, 104.37799147590703797, + 126.08656319753936259, 83.968257888664084021, 21.347076141344587086, 108.96235449751475244, + 73.485389382371067768, 6.8667362656342447735, 21.664889181538455887, 32.462501133857585955, + 18.204459162738203304, 69.611233902895037318, 3.3541484881279757246, 21.122652979716804111, + 32.749507862627069699, 90.465276304112194339, 33.207922603291081032, 102.5604170732331113, + 46.379778818256454542, 39.098070346135500586, 114.02211260408512317, 14.092809329220472137, + 73.581737646203691838, 56.66536984161939472, 37.524458772506477544, 83.14323872393288184, + 38.93094247930275742, 47.883647836446471047, 47.94029145401873393, 94.103121695152367465, + 5.9291034281450265553, 94.402915011989534833, 102.83631033216806827, 14.203529865004384192, + 88.28298746727159596, 5.7036603635096980724, 48.528805577749153599, 61.425295490651478758, + 40.394527458913216833, 92.95230747877212707, 72.669162222380691674, 61.340860948246699991, + 2.6090056086068216246, 42.211524196398386266, 94.645020822004880756, 89.198543801852792967, + 116.78325540562946117, 103.14164096232343582, 72.452731559009407647, 2.6650220052433724049, + 97.261404506771214074, 63.796791781798674492, 29.929362470873456914, 123.1662867119666771, + 91.640877181103860494, 12.329147729658870958, 121.72220546931930585, 42.030674892175738933, + 127.78929308297665557, 56.646474039349413943, 7.3095562604066799395, 45.428762593233841471, + 36.220027469586057123, 40.946671411889838055, 30.824379357305588201, 0.58584764627812546678, + 8.5360789831647707615, 21.06047801493332372, 107.07684043658809969, 51.983883442026126431, + 58.212327551984344609, 22.974544086326204706, 24.965972391968534794, 72.799390117008442758, + 40.159399551554088248, 33.140928780965623446, 97.224823579319490818, 62.246480734964279691, + 111.35349210380809382, 17.883824660304526333, 83.373471514882112388, 45.374232215570373228, + 2.3822873835924838204, 66.82774880998840672, 10.053584443849103991, 70.61262299147711019, + 67.151209977553662611, 90.406264186287444318, 21.489243706280831248, 12.013901176393119385, + 9.6976005669348523952, 30.210280025170504814, 6.8617634871770860627, 127.03842094477658975, + 38.929792110964626772, 25.235405937299219659, 74.173667659859347623, 21.526803119319083635, + 33.151999474303011084, 18.932138270029099658, 57.985288037307327613, 74.413325913377775578, + 47.661954530547518516, 105.61108629134469084, 111.78184808668811456, 102.05195473563799169, + 66.186613022484380053, 3.6953054368459561374, 60.043703071391064441, 68.386085665613791207, + 123.41290226421187981, 75.037953333518089494, 108.82733138037656317, 84.620775204053643392, + 120.74069998342747567, 120.64515964098609402, 118.74759287264168961, 66.083996538476640126, + 99.856893511136149755, 60.127364409647270804, 53.236117134769301629, 24.422387504502694355, + 47.540286310078954557, 95.990356733833323233, 78.382996330659807427, 50.612948557412892114, + 19.867254457025410375, 68.100637901075970149, 29.004475618530705106, 17.852269676186551806, + 110.84232191265255096, 16.327795025063096546, 10.496038902641885215, 48.717100503996334737, + 109.86758287052361993, 107.11863664519478334, 67.901265997410519049, 118.12409247503092047, + 62.071128679301182274, 87.448532354945200495, 43.547507001596386544, 112.94020338736299891, + 105.38635256192355882, 125.52413093382347142, 88.825684325402107788, 115.29227248551615048, + 106.66644258038286353, 113.50406263940749341, 26.33292826071192394, 92.242662002779979957, + 3.8407082992343930528, 73.753323926408484112, 16.581930422351433663, 94.169319946646282915, + 92.56054768093599705, 29.987817761277256068, 62.829052732016862137, 102.32029600211171783, + 123.95988709207085776, 104.19678878197373706, 56.616716790384089109, 80.990102736359403934, + 111.11591013100041891, 98.508501919073751196, 80.604275011824938701, 49.522350442330207443, + 111.00985722179029835, 29.95062065688034636, 2.3976479955890681595, 5.1330174346985586453, + 63.845077124551607994, 100.20563585833588149, 33.694264681249478599, 107.70154348971118452, + 64.334546007117751287, 38.025382480700500309, 120.32984969303288381, 97.805319440256425878, + 94.920771707566018449, 92.734364448137057479, 26.810581955029192613, 21.303565186601190362, + 65.267258529489481589, 73.070619941827317234, 104.7591635716453311, 19.090366767999512376, + 121.54492703869618708, 78.330361428987089312, 123.97454843510786304, 7.7332093858385633212, + 112.60949035876183189, 103.6998439299823076, 0.69689644691607099958, 76.143490617203497095, + 78.03619751714359154, 57.981734046978090191, 14.368728092558740173, 67.141263755031104665, + 59.36215743662614841, 22.476111963747825939, 59.994429744096123613, 19.60757999270936125, + 53.963929843081132276, 112.93694658801905462, 16.848767192310333485, 28.299185003623279044, + 44.969958178968227003, 49.551657972649991279, 0.64843949714486370794, 32.129598839368554763, + 72.332573023559234571, 66.302426958423893666, 110.89283548997991602, 39.91267608051202842, + 13.634927663850248791, 10.809381015711551299, 73.494828013303049374, 124.98223957163281739, + 63.768594065950310323, 92.024466577338898787, 90.392828280710091349, 22.95746347950262134, + 34.179813883103633998, 117.16731870654257364, 32.894195589171431493, 108.93290840733243385, + 11.987361831041198457, 27.634549295202305075, 45.349999228528758977, 43.354379900370986434, + 76.259820067778491648, 36.017883745822473429, 6.1187286079111800063, 33.779924812166427728, + 30.93826686935062753, 121.45303725294434116, 7.0978410086827352643, 76.403539933988213306, + 6.9345355466612090822, 95.031909411220112815, 16.0452032115572365, 72.26665327703449293, + 87.750826239567686571, 48.972710095698857913, 50.169109670347097563, 88.431189652372268029, + 0.5006040672815288417, 117.2889208150372724, 100.35725799232386635, 60.60214007216563914, + 25.615303831644268939, 106.63923812894790899, 59.366628536092321156, 23.075936997101962334, + 81.424723983764124569, 63.015486719446926145, 8.0212882863415870816, 30.815984040542389266, + 45.882513182579714339, 84.729925773255672539, 29.603260900199529715, 121.64509074996749405, + 22.933396864562382689, 12.462197030010429444, 123.49837423622739152, 68.341774387285113335, + 109.49032897657889407, 75.438946904221666045, 83.49482241039731889, 81.931615515826706542, + 115.68354184960844577, 0.67173078052655910142, 57.376964829687494785, 119.57578389648188022, + 71.553398424432089087, 110.57868828155915253, 39.415136707324563758, 60.164448971263482235, + 14.564361117409134749, 120.35728413681863458, 17.435276206851995084, 78.605888946385675808, + 0.46081043158119427972, 59.49091027081158245, 85.623518718875857303, 52.294867303313367302, + 76.389609224817832001, 72.525884507213049801, 16.096771126045496203, 107.70103367813499062, + 54.935181611166626681, 11.428507067808823194, 71.208465644773241365, 107.25424085115810158, + 105.29669203544472111, 7.8517862834560219198, 43.185138837146951118, 54.872863268457876984, + 127.42878716421910212, 22.779026972726569511, 12.878913650954928016, 33.499542192043008981, + 113.25627488181635272, 24.167644340002880199, 124.96261296837838017, 101.61849111243282096, + 36.42092963671166217, 4.1986763081658864394, 75.612817015866312431, 76.247485155356116593, + 5.1528835401441028807, 93.352652498011593707, 66.298104023364430759, 37.522514423744723899, + 0.6613251964226947166, 11.489531297018402256, 102.74554680482833646, 23.415216531819169177, + 16.91286593981567421, 55.03449546781484969, 62.886177849472005619, 95.98678589150949847, + 22.626080536898371065, 121.6028145091040642, 102.08096876878698822, 109.19907405697085778, + 115.9299142877353006, 23.669946836856979644, 13.253950753663957585, 84.002437610641209176, + 67.015391470289614517, 72.828513021559047047, 14.335872019706584979, 90.801305711207533022, + 24.175628530436370056, 106.40881599726708373, 88.538934649361181073, 97.41940826918289531, + 70.650494761081063189, 5.9588972972560441121, 41.165786743687931448, 51.131704117568006041, + 118.31120335881860228, 101.30241435805146466, 22.068757539214857388, 33.333072419387463015, + 97.723794788893428631, 51.328308566880878061, 13.595882532259565778, 83.696086261534219375, + 31.277147525630425662, 100.60622780624544248, 114.95548314204643248, 23.55328842526068911, + 30.114702406368451193, 101.96614643089924357, 37.551343722818273818, 43.231704924382938771, + 112.89157313464602339, 125.16387694510194706, 79.51670373556407867, 23.500522099431691458, + 113.20787641379138222, 12.064593748615152435, 121.39591736971851788, 51.370552993033925304, + 14.208229049800138455, 115.16300640751433093, 32.089381597066676477, 18.913353083557012724, + 69.422761323516169796, 80.755982951817713911, 124.17312639508236316, 39.936515777328168042, + 42.69415228269281215, 89.924708995033142855, 18.970778764742135536, 13.733472531268489547, + 43.329778363076911774, 64.925002267715171911, 36.408918325480044587, 11.222467805790074635, + 6.7082969762559514493, 42.245305959433608223, 65.499015725257777376, 52.930552608224388678, + 66.415845206585800042, 77.120834146466222592, 92.759557636512909085, 78.19614069227463915, + 100.04422520817024633, 28.185618658444582252, 19.163475292407383677, 113.33073968323878944, + 75.048917545016593067, 38.286477447865763679, 77.861884958605514839, 95.767295672892942093, + 95.880582908041105838, 60.20624339030473493, 11.858206856293691089, 60.805830023982707644, + 77.672620664336136542, 28.407059730012406362, 48.565974934543191921, 11.407320727019396145, + 97.057611155498307198, 122.85059098130295752, 80.789054917830071645, 57.904614957547892118, + 17.338324444761383347, 122.68172189649339998, 5.2180112172136432491, 84.423048392800410511, + 61.290041644013399491, 50.397087603709223913, 105.56651081126256031, 78.283281924650509609, + 16.905463118018815294, 5.3300440104903827887, 66.522809013542428147, 127.59358356359734898, + 59.858724941750551807, 118.33257342393699219, 55.281754362207720987, 24.658295459321379894, + 115.4444109386386117, 84.061349784355115844, 127.57858616595331114, 113.29294807869882789, + 14.619112520813359879, 90.857525186467682943, 72.440054939172114246, 81.89334282377967611, + 61.648758714611176401, 1.1716952925562509336, 17.072157966329541523, 42.12095602987028542, + 86.153680873176199384, 103.96776688405225286, 116.42465510396868922, 45.949088172652409412, + 49.931944783940707566, 17.598780234016885515, 80.318799103108176496, 66.28185756193488487, + 66.449647158638981637, 124.49296146993219736, 94.706984207616187632, 35.767649320612690644, + 38.746943029764224775, 90.748464431140746456, 4.7645747671886056196, 5.6554976199768134393, + 20.107168887701845961, 13.225245982957858359, 6.3024199551109632012, 52.812528372574888635, + 42.978487412561662495, 24.027802352786238771, 19.39520113386970479, 60.420560050344647607, + 13.723526974357810104, 126.0768418895531795, 77.859584221929253545, 50.470811874602077296, + 20.347335319718695246, 43.05360623863816727, 66.303998948606022168, 37.864276540058199316, + 115.97057607461829321, 20.826651826755551156, 95.323909061098675011, 83.222172582693019649, + 95.563696173379867105, 76.103909471279621357, 4.3732260449687601067, 7.3906108736919122748, + 120.08740614278576686, 8.7721713312312203925, 118.8258045284273976, 22.075906667039816966, + 89.654662760756764328, 41.241550408110924764, 113.48139996685858932, 113.29031928197582602, + 109.4951857452870172, 4.1679930769569182303, 71.713787022272299509, 120.25472881929454161, + 106.47223426953860326, 48.844775009005388711, 95.080572620161547093, 63.980713467670284444, + 28.765992661319614854, 101.22589711482578423, 39.734508914054458728, 8.2012758021519402973, + 58.008951237061410211, 35.70453935237674159, 93.684643825305101927, 32.655590050126193091, + 20.992077805283770431, 97.434201007996307453, 91.735165741050877841, 86.237273290393204661, + 7.802531994824676076, 108.24818495006184094, 124.14225735860600253, 46.897064709890400991, + 87.095014003196411068, 97.880406774729635799, 82.772705123850755626, 123.04826186765058083, + 49.651368650807853555, 102.58454497103593894, 85.332885160769365029, 99.008125278814986814, + 52.665856521427485859, 56.485324005559959915, 7.6814165984724240843, 19.506647852816968225, + 33.163860844706505304, 60.338639893296203809, 57.121095361871994101, 59.975635522554512136, + 125.65810546403736225, 76.64059200422707363, 119.9197741841453535, 80.393577563947474118, + 113.2334335807718162, 33.980205472722445847, 94.231820262004475808, 69.017003838151140371, + 33.208550023649877403, 99.044700884664052865, 94.019714443580596708, 59.901241313760692719, + 4.7952959911781363189, 10.266034869397117291, 127.69015424910685397, 72.411271716671762988, + 67.388529362502595177, 87.403086979426007019, 0.66909201423550257459, 76.050764961404638598, + 112.65969938606940559, 67.610638880516489735, 61.841543415135674877, 57.468728896274114959, + 53.621163910058385227, 42.607130373206018703, 2.5345170589826011565, 18.141239883658272447, + 81.518327143290662207, 38.180733536002662731, 115.08985407739601214, 28.660722857977816602, + 119.94909687021572609, 15.466418771680764621, 97.218980717527301749, 79.3996878599646152, + 1.393792893835779978, 24.286981234410632169, 28.07239503428718308, 115.96346809395618038, + 28.737456185121118324, 6.2825275100622093305, 118.72431487325229682, 44.952223927495651878, + 119.98885948819224723, 39.215159985418722499, 107.92785968616590253, 97.873893176038109232, + 33.69753438462066697, 56.598370007246558089, 89.939916357936454006, 99.103315945299982559, + 1.2968789942897274159, 64.259197678740747506, 16.66514604712210712, 4.6048539168514253106, + 93.785670979959832039, 79.825352161024056841, 27.269855327700497583, 21.618762031426740577, + 18.989656026609736728, 121.96447914326563478, 127.53718813190425863, 56.048933154681435553, + 52.785656561420182697, 45.914926959005242679, 68.359627766210905975, 106.33463741308514727, + 65.788391178346500965, 89.865816814664867707, 23.974723662082396913, 55.26909859040461015, + 90.699998457057517953, 86.708759800745610846, 24.519640135556983296, 72.035767491644946858, + 12.237457215822360013, 67.559849624332855456, 61.87653373870489304, 114.90607450588868232, + 14.195682017369108507, 24.807079867976426613, 13.869071093326056143, 62.063818822440225631, + 32.090406423118110979, 16.53330655407262384, 47.501652479135373142, 97.945420191397715826, + 100.3382193406978331, 48.862379304744536057, 1.0012081345666956622, 106.57784163007818279, + 72.714515984647732694, 121.20428014433127828, 51.230607663292175857, 85.27847625789581798, + 118.73325707218464231, 46.151873994207562646, 34.849447967528249137, 126.03097343889385229, + 16.042576572683174163, 61.631968081084778532, 91.765026365163066657, 41.459851546511345077, + 59.206521800402697409, 115.2901814999349881, 45.866793729124765377, 24.924394060024496866, + 118.99674847245842102, 8.6835487745738646481, 90.980657953161426121, 22.87789380844697007, + 38.989644820798275759, 35.863231031657051062, 103.36708369921689155, 1.3434615610531182028, + 114.75392965937862755, 111.15156779296739842, 15.106796848867816152, 93.157376563118305057, + 78.830273414649127517, 120.32889794252696447, 29.128722234821907477, 112.71456827363726916, + 34.870552413707628148, 29.211777892771351617, 0.92162086316238855943, 118.98182054162680288, + 43.247037437751714606, 104.58973460663037258, 24.77921844963930198, 17.051769014426099602, + 32.193542252094630385, 87.402067356269981246, 109.87036322233325336, 22.857014135621284368, + 14.416931289550120709, 86.508481702319841133, 82.593384070889442228, 15.70357256691204384, + 86.370277674293902237, 109.74572653691939195, 126.85757432843820425, 45.558053945453139022, + 25.757827301909856033, 66.999084384089655941, 98.512549763632705435, 48.335288680009398377, + 121.92522593676039833, 75.236982224865641911, 72.841859273423324339, 8.3973526163354108576, + 23.225634031736262841, 24.494970310712233186, 10.30576708029184374, 58.705304996026825393, + 4.5962080467288615182, 75.045028847489447799, 1.3226503928453894332, 22.979062594040442491, + 77.491093609656672925, 46.830433063638338353, 33.82573187963134842, 110.06899093562969938, + 125.77235569894764922, 63.973571783018996939, 45.252161073800380109, 115.20562901821176638, + 76.161937537577614421, 90.398148113945353543, 103.85982857547060121, 47.339893673713959288, + 26.507901507331553148, 40.00487522128605633, 6.0307829405828670133, 17.657026043118094094, + 28.671744039416807937, 53.602611422415066045, 48.351257060876378091, 84.81763199453780544, + 49.077869298726000125, 66.838816538369428599, 13.300989522162126377, 11.917794594512088224, + 82.331573487375862896, 102.26340823513965006, 108.62240671764084254, 74.60482871610292932, + 44.137515078429714777, 66.666144838778564008, 67.447589577786857262, 102.65661713376175612, + 27.191765064522769535, 39.39217252306843875, 62.554295051264489302, 73.212455612494522939, + 101.91096628409286495, 47.106576850521378219, 60.229404812740540365, 75.932292861798487138, + 75.102687445636547636, 86.46340984876951552, 97.78314626929568476, 122.32775389020753209, + 31.03340747112815734, 47.001044198867020896, 98.415752827582764439, 24.12918749723394285, + 114.79183473943703575, 102.74110598606785061, 28.416458099603914889, 102.32601281502866186, + 64.178763194133352954, 37.826706167117663426, 10.84552264703597757, 33.5119659036390658, + 120.34625279016472632, 79.873031554656336084, 85.388304565389262279, 51.849417990066285711, + 37.941557529484271072, 27.466945062536979094, 86.659556726157461526, 1.8500045354303438216, + 72.817836650960089173, 22.444935611580149271, 13.416593952511902899, 84.490611918870854424, + 2.9980314505155547522, 105.86110521645241533, 4.8316904131752380636, 26.241668292936083162, + 57.519115273029456148, 28.392281384552916279, 72.088450416340492666, 56.371237316889164504, + 38.326950584818405332, 98.661479366481216857, 22.097835090033186134, 76.572954895735165337, + 27.723769917214667657, 63.534591345789522165, 63.761165816082211677, 120.41248678060946986, + 23.716413712587382179, 121.61166004796905327, 27.345241328672273085, 56.814119460024812724, + 97.131949869086383842, 22.814641454042430269, 66.115222311000252375, 117.70118196260955301, + 33.57810983566014329, 115.80922991509578424, 34.676648889526404673, 117.36344379298679996, + 10.436022434430924477, 40.846096785600821022, 122.58008328802679898, 100.7941752074220858, + 83.133021622528758598, 28.566563849301019218, 33.810926236037630588, 10.660088020984403556, + 5.0456180270884942729, 127.18716712719469797, 119.71744988350474159, 108.66514684787398437, + 110.56350872441544197, 49.316590918646397768, 102.88882187728086137, 40.122699568713869667, + 127.15717233191026025, 98.58589615739765577, 29.238225041630357737, 53.715050372939003864, + 16.88010987834786647, 35.786685647559352219, 123.2975174292223528, 2.3433905851125018671, + 34.144315932659083046, 84.241912059744208818, 44.307361746356036747, 79.935533768108143704, + 104.84931020793737844, 91.898176345304818824, 99.863889567881415132, 35.197560468037409009, + 32.637598206219990971, 4.5637151238734077197, 4.899294317281601252, 120.9859229398680327, + 61.413968415232375264, 71.535298641225381289, 77.493886059532087529, 53.496928862281492911, + 9.5291495343772112392, 11.310995239953626879, 40.214337775403691921, 26.450491965915716719, + 12.604839910221926402, 105.62505674514977727, 85.95697482512332499, 48.055604705572477542, + 38.790402267739409581, 120.84112010069293319, 27.447053948719258187, 124.15368377910999698, + 27.719168443858507089, 100.94162374920415459, 40.694670639437390491, 86.107212477279972518, + 4.6079978972120443359, 75.728553080120036611, 103.94115214923658641, 41.65330365351474029, + 62.647818122200988, 38.444345165389677277, 63.127392346763372188, 24.207818942559242714, + 8.7464520899375202134, 14.781221747387462528, 112.17481228557153372, 17.544342662466078764, + 109.6516090568547952, 44.151813334083271911, 51.309325521513528656, 82.483100816225487506, + 98.962799933720816625, 98.58063856395529001, 90.990371490574034397, 8.3359861539174744394, + 15.427574044548236998, 112.5094576385927212, 84.944468539077206515, 97.6895500180144154, + 62.161145240323094185, 127.96142693534056889, 57.531985322642867686, 74.451794229651568457, + 79.469017828108917456, 16.402551604303880595, 116.01790247412282042, 71.409078704757121159, + 59.369287650610203855, 65.311180100252386183, 41.98415561057117884, 66.868402015996252885, + 55.470331482105393661, 44.474546580786409322, 15.605063989652990131, 88.496369900127319852, + 120.28451471721200505, 93.79412941978443996, 46.190028006396460114, 67.760813549462909577, + 37.545410247705149231, 118.09652373530116165, 99.302737301619345089, 77.169089942075515864, + 42.665770321542368038, 70.016250557629973628, 105.33171304285497172, 112.97064801111991983, + 15.362833196944848169, 39.01329570563393645, 66.327721689413010608, 120.67727978659240762, + 114.2421907237439882, 119.95127104511266225, 123.31621092807836249, 25.281184008457785239, + 111.83954836829434498, 32.787155127898586215, 98.466867161543632392, 67.960410945448529674, + 60.463640524012589594, 10.034007676302280743, 66.417100047303392785, 70.089401769331743708, + 60.039428887161193416, 119.80248262752138544, 9.5905919823562726378, 20.53206973879787256, + 127.38030849821734591, 16.822543433347163955, 6.7770587250088283326, 46.806173958852014039, + 1.338184028474643128, 24.101529922812915174, 97.319398772142449161, 7.2212777610329794697, + 123.68308683027134975, 114.93745779254822992, 107.24232782011677045, 85.214260746412037406, + 5.0690341179652023129, 36.282479767320182873, 35.036654286581324413, 76.361467072008963441, + 102.17970815479202429, 57.321445715959271183, 111.89819374043145217, 30.932837543365167221, + 66.437961435058241477, 30.799375719929230399, 2.7875857876715599559, 48.573962468821264338, + 56.144790068578004139, 103.92693618791236077, 57.474912370242236648, 12.56505502012805664, + 109.44862974650459364, 89.904447854994941736, 111.97771897638449445, 78.430319970841082977, + 87.85571937233544304, 67.747786352076218463, 67.395068769241333939, 113.19674001449675416, + 51.87983271587654599, 70.206631890599965118, 2.5937579885830928106, 0.5183953574814950116, + 33.33029209424421424, 9.2097078337064886, 59.571341959923302056, 31.650704322048113681, + 54.539710655400995165, 43.237524062853481155, 37.979312053223111434, 115.92895828653490753, + 127.07437626380851725, 112.09786630936287111, 105.57131312284036539, 91.829853918014123337, + 8.7192555324254499283, 84.669274826173932524, 3.5767823566966399085, 51.731633629329735413, + 47.949447324164793827, 110.53819718081285828, 53.399996914118673885, 45.417519601491221692, + 49.03928027111760457, 16.071534983289893717, 24.474914431648358004, 7.1196992486657109112, + 123.75306747741342406, 101.81214901177736465, 28.391364034738217015, 49.614159735952853225, + 27.738142186652112287, 124.12763764488045126, 64.180812846236221958, 33.066613108145247679, + 95.003304958274384262, 67.89084038279906963, 72.676438681395666208, 97.724758609489072114, + 2.0024162691370293032, 85.155683260160003556, 17.429031969299103366, 114.40856028866255656, + 102.46121532658798969, 42.556952515795273939, 109.46651414436928462, 92.303747988415125292, + 69.698895935060136253, 124.06194687778770458, 32.085153145366348326, 123.26393616217319504, + 55.530052730326133315, 82.919703093022690155, 118.4130436008090328, 102.58036299986997619, + 91.733587458249530755, 49.848788120052631712, 109.99349694491684204, 17.367097549151367275, + 53.961315906322852243, 45.75578761689394014, 77.979289641596551519, 71.726462063317740103, + 78.734167398433783092, 2.6869231221098743845, 101.50785931876089307, 94.303135585934796836, + 30.213593697739270283, 58.314753126240248093, 29.660546829301893013, 112.65779588505392894, + 58.257444469647452934, 97.429136547274538316, 69.741104827415256295, 58.423555785542703234, + 1.8432417263284150977, 109.96364108325360576, 86.49407487550706719, 81.179469213260745164, + 49.55843689927860396, 34.103538028852199204, 64.387084504192898748, 46.804134712543600472, + 91.740726444666506723, 45.714028271242568735, 28.833862579103879398, 45.016963404643320246, + 37.186768141778884456, 31.407145133827725658, 44.740555348591442453, 91.491453073842421873, + 125.7151486568764085, 91.116107890906278044, 51.515654603823350044, 5.9981687681829498615, + 69.02509952726541087, 96.670577360022434732, 115.85045187352443463, 22.4739644497349218, + 17.683718546846648678, 16.794705232670821715, 46.451268063472525682, 48.989940621424466372, + 20.611534160583687481, 117.41060999205365079, 9.1924160934613610152, 22.090057694978895597, + 2.6453007856907788664, 45.958125188084522961, 26.98218721931334585, 93.660866127276676707, + 67.651463759266334819, 92.137981871263036737, 123.54471139789529843, 127.94714356603799388, + 90.504322147604398197, 102.41125803642717074, 24.323875075158866821, 52.796296227894345066, + 79.719657150941202417, 94.679787347427918576, 53.015803014663106296, 80.009750442572112661, + 12.061565881165734027, 35.314052086236188188, 57.343488078833615873, 107.20522284483013209, + 96.702514121756394161, 41.63526398907561088, 98.155738597455638228, 5.6776330767388571985, + 26.601979044324252754, 23.835589189027814427, 36.663146974755363772, 76.526816470282938099, + 89.244813435285323067, 21.20965743220585864, 88.275030156863067532, 5.3322896775607659947, + 6.8951791555773525033, 77.313234267523512244, 54.38353012904553907, 78.7843450461368775, + 125.10859010253261658, 18.424911224992683856, 75.821932568185729906, 94.213153701042756438, + 120.45880962548471871, 23.864585723600612255, 22.205374891276733251, 44.926819697542669019, + 67.5662925385950075, 116.65550778041506419, 62.06681494225631468, 94.00208839773767977, + 68.831505655165528879, 48.258374994471523678, 101.58366947887770948, 77.482211972135701217, + 56.832916199211467756, 76.652025630060961703, 0.35752638826670590788, 75.653412334235326853, + 21.691045294071955141, 67.023931807281769579, 112.69250558033309062, 31.746063109316310147, + 42.776609130778524559, 103.69883598013257142, 75.883115058968542144, 54.933890125077596167, + 45.319113452314923052, 3.7000090708643256221, 17.635673301920178346, 44.889871223160298541, + 26.833187905027443776, 40.981223837741708849, 5.9960629010347474832, 83.722210432904830668, + 9.6633808263504761271, 52.483336585872166324, 115.0382305460589123, 56.784562769109470537, + 16.176900832680985332, 112.74247463377832901, 76.653901169640448643, 69.322958732962433714, + 44.195670180070010247, 25.145909791470330674, 55.447539834429335315, 127.06918269157904433, + 127.52233163216806133, 112.82497356121893972, 47.432827425178402336, 115.22332009593810653, + 54.690482657344546169, 113.62823892005326343, 66.263899738172767684, 45.629282908088498516, + 4.2304446220041427296, 107.40236392521910602, 67.156219671323924558, 103.61845983019156847, + 69.353297779056447325, 106.72688758597359993, 20.872044868861848954, 81.692193571205280023, + 117.16016657605723594, 73.588350414847809589, 38.266043245057517197, 57.133127698602038436, + 67.621852472075261176, 21.320176041968807112, 10.091236054180626525, 126.37433425439303392, + 111.43489976701312116, 89.33029369575160672, 93.12701744883088395, 98.633181837296433514, + 77.777643754561722744, 80.245399137431377312, 126.31434466382415849, 69.17179231479531154, + 58.476450083260715473, 107.43010074587800773, 33.76021975669573294, 71.573371295122342417, + 118.59503485844470561, 4.6867811702250037342, 68.288631865321804071, 40.483824119488417637, + 88.614723492715711473, 31.871067536219925387, 81.698620415878394851, 55.796352690613275627, + 71.727779135762830265, 70.395120936074818019, 65.275196412439981941, 9.1274302477468154393, + 9.7985886345668404829, 113.9718458797360654, 122.82793683046838851, 15.070597282454400556, + 26.987772119064175058, 106.99385772456298582, 19.058299068754422478, 22.621990479907253757, + 80.428675550807383843, 52.900983931831433438, 25.209679820447490783, 83.250113490303192521, + 43.913949650246649981, 96.111209411144955084, 77.58080453548245714, 113.68224020138950436, + 54.894107897442154353, 120.30736755821999395, 55.438336887720652157, 73.883247498408309184, + 81.389341278878418962, 44.214424954559945036, 9.2159957944277266506, 23.457106160243711201, + 79.882304298473172821, 83.30660730702948058, 125.295636244401976, 76.888690330779354554, + 126.25478469352674438, 48.415637885118485428, 17.492904179875040427, 29.562443494778563036, + 96.349624571143067442, 35.088685324935795506, 91.303218113709590398, 88.303626668166543823, + 102.61865104303069529, 36.966201632454612991, 69.925599867445271229, 69.161277127914217999, + 53.980742981148068793, 16.671972307834948879, 30.855148089100111974, 97.018915277189080371, + 41.888937078158051008, 67.3791000360288308, 124.32229048064982635, 127.92285387068113778, + 115.06397064528937335, 20.903588459306774894, 30.938035656217834912, 32.805103208611399168, + 104.03580494824927882, 14.818157409514242318, 118.73857530122404569, 2.6223602005047723651, + 83.96831122114599566, 5.7368040319925057702, 110.94066296421078732, 88.949093161572818644, + 31.21012797930961824, 48.992739800258277683, 112.56902943442764808, 59.588258839568879921, + 92.380056012796558207, 7.5216270989258191548, 75.090820495413936442, 108.19304747060596128, + 70.605474603242328158, 26.338179884151031729, 85.331540643088374054, 12.032501115263585234, + 82.663426085713581415, 97.941296022239839658, 30.725666393889696337, 78.026591411271510879, + 4.6554433788296591956, 113.35455957318845321, 100.48438144749161438, 111.90254209022896248, + 118.63242185615672497, 50.562368016919208458, 95.679096736588689964, 65.57431025580081041, + 68.933734323090902762, 7.9208218908970593475, 120.92728104802517919, 20.068015352608199464, + 4.8342000946104235481, 12.178803538663487416, 120.07885777432602481, 111.60496525504277088, + 19.181183964712545276, 41.064139477599383099, 126.76061699643469183, 33.645086866694327909, + 13.554117450017656665, 93.612347917704028077, 2.676368056949286256, 48.203059845629468327, + 66.638797544284898322, 14.442555522069596918, 119.36617366054633749, 101.87491558510009781, + 86.484655640237178886, 42.428521492824074812, 10.138068235930404626, 72.564959534640365746, + 70.073308573166286806, 24.722934144021564862, 76.359416309584048577, 114.64289143192218035, + 95.79638748086290434, 61.865675086733972421, 4.8759228701164829545, 61.598751439858460799, + 5.5751715753431199118, 97.147924937642528675, 112.28958013715964626, 79.85387237582472153, + 114.9498247404844733, 25.130110040259751258, 90.89725949301282526, 51.80889570999352145, + 95.955437952772626886, 28.860639941685803933, 47.71143874467452406, 7.4955727041560749058, + 6.7901375384863058571, 98.393480028993508313, 103.75966543175672996, 12.413263781199930236, + 5.1875159771661856212, 1.0367907149629900232, 66.660584188488428481, 18.4194156674129772, + 119.14268391984660411, 63.301408644096227363, 109.07942131080199033, 86.47504812570696231, + 75.958624106449860847, 103.85791657307345304, 126.14875252762067248, 96.195732618729380192, + 83.142626245684368769, 55.659707836028246675, 17.438511064854537835, 41.338549652347865049, + 7.153564713393279817, 103.46326725865947083, 95.898894648333225632, 93.076394361625716556, + 106.79999382823734777, 90.835039202982443385, 98.078560542235209141, 32.143069966579787433, + 48.949828863296716008, 14.239398497335059801, 119.50613495483048609, 75.624298023554729298, + 56.78272806947643403, 99.22831947190570645, 55.476284373307862552, 120.2552752897645405, + 0.3616256924724439159, 66.133226216294133337, 62.006609916552406503, 7.7816807656017772388, + 17.352877362794970395, 67.449517218978144228, 4.0048325382776965853, 42.311366520320007112, + 34.858063938601844711, 100.8171205773287511, 76.922430653175979387, 85.113905031594185857, + 90.933028288742207224, 56.607495976833888562, 11.397791870123910485, 120.12389375557540916, + 64.170306290736334631, 118.52787232434639009, 111.06010546065590461, 37.839406186049018288, + 108.82608720162170357, 77.160725999743590364, 55.46717491649906151, 99.697576240108901402, + 91.986993889833684079, 34.73419509830273455, 107.92263181264570449, 91.511575233791518258, + 27.958579283196741017, 15.452924126639118185, 29.468334796867566183, 5.3738462442233867478, + 75.015718637525424128, 60.606271171869593672, 60.427187395478540566, 116.62950625248049619, + 59.321093658607424004, 97.315591770107857883, 116.51488893929854385, 66.85827309455271461, + 11.482209654830512591, 116.84711157108540647, 3.6864834526604681741, 91.927282166510849493, + 44.98814975101777236, 34.358938426521490328, 99.11687379855720792, 68.207076057708036387, + 0.77416900838579749689, 93.608269425090838922, 55.481452889333013445, 91.42805654248513747, + 57.667725158207758795, 90.033926809286640491, 74.373536283557768911, 62.814290267655451316, + 89.481110697186522884, 54.982906147688481724, 123.43029731375645497, 54.232215781812556088, + 103.03130920764670009, 11.996337536369537702, 10.050199054534459719, 65.341154720048507443, + 103.70090374704886926, 44.9479288994698436, 35.367437093693297356, 33.58941046534164343, + 92.902536126945051365, 97.979881242848932743, 41.22306832117101294, 106.82121998410730157, + 18.38483218692272203, 44.180115389957791194, 5.2906015713815577328, 91.916250376169045921, + 53.964374438630329678, 59.321732254556991393, 7.3029275185363076162, 56.275963742529711453, + 119.08942279579423484, 127.89428713207962574, 53.008644295212434372, 76.822516072854341473, + 48.647750150317733642, 105.59259245579232811, 31.439314301886042813, 61.359574694855837151, + 106.03160602932985057, 32.019500885144225322, 24.123131762331468053, 70.628104172472376376, + 114.68697615767086972, 86.410445689663902158, 65.405028243512788322, 83.270527978154859738, + 68.311477194911276456, 11.355266153477714397, 53.203958088648505509, 47.671178378055628855, + 73.326293949514365522, 25.053632940569514176, 50.489626870570646133, 42.41931486441535526, + 48.550060313726135064, 10.664579355121531989, 13.790358311158342985, 26.626468535047024488, + 108.76706025809471612, 29.568690092277392978, 122.21718020506523317, 36.84982244998900569, + 23.643865136375097791, 60.426307402089150855, 112.91761925096943742, 47.72917144720122451, + 44.410749782553466503, 89.853639395088976016, 7.1325850771936529782, 105.31101556083012838, + 124.13362988451626734, 60.004176795478997519, 9.6630113103310577571, 96.516749988946685335, + 75.167338957759056939, 26.964423944271402434, 113.66583239842657349, 25.304051260121923406, + 0.71505277653704979457, 23.306824668470653705, 43.38209058814754826, 6.0478636145671771374, + 97.38501116066618124, 63.492126218632620294, 85.553218261560687097, 79.397671960268780822, + 23.766230117937084287, 109.86778025015519233, 90.638226904629846103, 7.4000181417286512442, + 35.271346603840356693, 89.779742446320597082, 53.666375810054887552, 81.962447675483417697, + 11.992125802073132945, 39.444420865809661336, 19.326761652700952254, 104.96667317174797063, + 102.07646109211782459, 113.56912553821894107, 32.353801665365608642, 97.484949267560295993, + 25.307802339284535265, 10.645917465924867429, 88.391340360140020493, 50.291819582940661348, + 110.89507966886230861, 126.13836538316172664, 127.04466326433976064, 97.649947122437879443, + 94.865654850360442651, 102.44664019187621307, 109.38096531469273032, 99.256477840110164834, + 4.5277994763455353677, 91.258565816176997032, 8.4608892440119234379, 86.804727850441850023, + 6.3124393426514870953, 79.236919660386774922, 10.706595558116532629, 85.453775171947199851, + 41.744089737727335887, 35.384387142414198024, 106.32033315211810987, 19.176700829695619177, + 76.532086490115034394, 114.26625539720771485, 7.2437049441505223513, 42.640352083937614225, + 20.182472108364891028, 124.74866850878970581, 94.869799534029880306, 50.660587391506851418, + 58.254034897665405879, 69.266363674596505007, 27.555287509127083467, 32.490798274866392603, + 124.62868932765195495, 10.343584629590623081, 116.95290016652506893, 86.860201491756015457, + 67.520439513395103859, 15.146742590248322813, 109.19006971688941121, 9.3735623404536454473, + 8.5772637306436081417, 80.967648238980473252, 49.229446985431422945, 63.742135072443488752, + 35.397240831756789703, 111.59270538123018923, 15.455558271529298509, 12.790241872153274016, + 2.5503928248799638823, 18.254860495493630879, 19.597177269137318945, 99.943691759475768777, + 117.65587366093677701, 30.141194564908801112, 53.975544238131988095, 85.987715449125971645, + 38.116598137508844957, 45.243980959818145493, 32.857351101614767686, 105.80196786366286688, + 50.419359640898619546, 38.500226980606385041, 87.82789930049693794, 64.222418822293548146, + 27.16160907096855226, 99.364480402779008728, 109.78821579488794669, 112.61473511643998791, + 110.87667377544494229, 19.766494996820256347, 34.778682557756837923, 88.428849909119890071, + 18.431991588855453301, 46.914212320491060382, 31.764608596949983621, 38.613214614062599139, + 122.59127248880758998, 25.777380661562347086, 124.50956938705348875, 96.831275770236970857, + 34.985808359750080854, 59.12488698956076405, 64.699249142286134884, 70.177370649875228992, + 54.606436227422818774, 48.607253336336725624, 77.237302086061390582, 73.93240326491286396, + 11.851199734894180438, 10.322554255828435998, 107.96148596229613759, 33.343944615669897757, + 61.710296178203861928, 66.037830554378160741, 83.777874156319739996, 6.7582000720612995792, + 120.64458096130329068, 127.84570774136591353, 102.1279412905787467, 41.807176918613549788, + 61.876071312435669824, 65.610206417226436315, 80.071609896498557646, 29.636314819032122614, + 109.47715060244809138, 5.244720401013182709, 39.93662244229199132, 11.473608063988649519, + 93.881325928425212624, 49.898186323145637289, 62.42025595861923648, 97.985479600520193344, + 97.138058868855296168, 119.17651767914139782, 56.760112025593116414, 15.043254197855276288, + 22.181640990831510862, 88.386094941215560539, 13.210949206484656315, 52.676359768305701436, + 42.663081286176748108, 24.065002230530808447, 37.326852171430800809, 67.882592044479679316, + 61.451332787783030653, 28.053182822543021757, 9.31088675766295637, 98.709119146380544407, + 72.968762894986866741, 95.805084180461562937, 109.26484371231344994, 101.12473603384205489, + 63.358193473181017907, 3.1486205116052587982, 9.867468646181805525, 15.841643781797756674, + 113.85456209605035838, 40.136030705216398928, 9.6684001892208470963, 24.35760707733061281, + 112.1577155486556876, 95.209930510085541755, 38.362367929425090551, 82.128278955202404177, + 125.52123399286938366, 67.290173733388655819, 27.108234900038951309, 59.224695835408056155, + 5.352736113898572512, 96.406119691262574634, 5.2775950885697966442, 28.885111044142831815, + 110.73234732109631295, 75.749831170203833608, 44.969311280474357773, 84.857042985648149624, + 20.27613647186444723, 17.129919069284369471, 12.146617146332573611, 49.445868288046767702, + 24.718832619171735132, 101.28578286384799867, 63.59277496172580868, 123.73135017346794484, + 9.7518457402329659089, 123.1975028797169216, 11.150343150689877803, 66.29584987528869533, + 96.579160274322930491, 31.707744751653081039, 101.89964948096894659, 50.260220080523140496, + 53.79451898602565052, 103.61779141999068088, 63.910875905545253772, 57.721279883371607866, + 95.422877489349048119, 14.991145408312149812, 13.580275076976249693, 68.786960057990654605, + 79.519330863513459917, 24.826527562399860471, 10.375031954332371242, 2.0735814299296180252, + 5.3211683769768569618, 36.838831334829592379, 110.28536783969320823, 126.6028172881960927, + 90.158842621607618639, 44.950096251417562598, 23.917248212903359672, 79.715833146150544053, + 124.29750505524498294, 64.391465237462398363, 38.285252491368737537, 111.31941567205649335, + 34.877022129709075671, 82.677099304695730098, 14.307129426790197613, 78.926534517322579632, + 63.797789296670089243, 58.152788723255071091, 85.59998765647833352, 53.670078405968524748, + 68.157121084470418282, 64.286139933159574866, 97.899657726593432017, 28.478796994673757581, + 111.01226990966461017, 23.248596047109458596, 113.56545613895650604, 70.456638943811412901, + 110.95256874661936308, 112.51055057952908101, 0.72325138494852581061, 4.2664524325882666744, + 124.01321983310481301, 15.563361531203554478, 34.705754725593578769, 6.8990344379562884569, + 8.0096650765553931706, 84.622733040640014224, 69.716127877207327401, 73.634241154661140172, + 25.844861306355596753, 42.227810063192009693, 53.866056577484414447, 113.21499195366777712, + 22.795583740251458948, 112.2477875111544563, 0.34061258147630724125, 109.05574464869641815, + 94.120210921311809216, 75.678812372101674555, 89.65217440324704512, 26.321451999487180728, + 110.934349833001761, 71.395152480221440783, 55.973987779667368159, 69.468390196609107079, + 87.84526362529504695, 55.023150467583036516, 55.917158566393482033, 30.905848253278236371, + 58.936669593735132366, 10.747692488450411474, 22.031437275050848257, 121.21254234373918734, + 120.85437479096071911, 105.25901250496099237, 118.64218731721848599, 66.631183540219353745, + 105.02977787860072567, 5.7165461891054292209, 22.96441930966466316, 105.69422314217081293, + 7.3729669053245743271, 55.854564333021698985, 89.97629950203554472, 68.717876853046618635, + 70.233747597118053818, 8.4141521154160727747, 1.5483380167752329726, 59.216538850181677844, + 110.96290577866966487, 54.85611308497027494, 115.33545031641915557, 52.067853618576918961, + 20.747072567115537822, 125.62858053531454061, 50.962221394373045769, 109.96581229538060143, + 118.86059462751290994, 108.46443156362875015, 78.062618415293400176, 23.992675072739075404, + 20.100398109072557418, 2.6823094401006528642, 79.401807494097738527, 89.8958577989396872, + 70.734874187386594713, 67.178820930686924839, 57.805072253893740708, 67.959762485697865486, + 82.446136642345663859, 85.642439968214603141, 36.769664373845444061, 88.360230779915582389, + 10.581203142766753444, 55.832500752338091843, 107.92874887726065936, 118.64346450911398279, + 14.605855037072615232, 112.55192748506306089, 110.17884559159210767, 127.78857426415925147, + 106.01728859042850672, 25.645032145708682947, 97.295500300639105262, 83.18518491158465622, + 62.878628603772085626, 122.71914938971531228, 84.063212058659701142, 64.039001770288450643, + 48.246263524666574085, 13.256208344948390732, 101.37395231534537743, 44.820891379331442295, + 2.8100564870292146225, 38.541055956313357456, 8.6229543898225529119, 22.710532306955428794, + 106.40791617729701102, 95.342356756114895688, 18.652587899028731044, 50.107265881139028352, + 100.97925374114129227, 84.838629728830710519, 97.100120627452270128, 21.329158710243063979, + 27.580716622316685971, 53.252937070097686956, 89.534120516189432237, 59.137380184558423935, + 116.43436041013046633, 73.699644899978011381, 47.287730272750195581, 120.85261480418193969, + 97.835238501938874833, 95.458342894402449019, 88.821499565110570984, 51.707278790177952033, + 14.265170154390943935, 82.622031121663894737, 120.26725976903253468, 120.00835359095799504, + 19.326022620665753493, 65.033499977897008648, 22.334677915518113878, 53.928847888546442846, + 99.331664796853146981, 50.608102520243846811, 1.4301055530740995891, 46.613649336941307411, + 86.76418117629509652, 12.095727229137992254, 66.77002232133236248, 126.98425243726887857, + 43.106436523125012172, 30.795343920537561644, 47.532460235877806554, 91.735560500314022647, + 53.276453809259692207, 14.800036283457302488, 70.542693207684351364, 51.559484892641194165, + 107.33275162011341308, 35.924895350966835395, 23.98425160414626589, 78.888841731619322672, + 38.653523305405542487, 81.933346343499579234, 76.152922184239287162, 99.138251076437882148, + 64.707603330734855263, 66.969898535120591987, 50.615604678569070529, 21.291834931853372836, + 48.782680720280040987, 100.58363916588496068, 93.790159337728255196, 124.27673076632709126, + 126.08932652868315927, 67.299894244879396865, 61.731309700724523282, 76.893280383756064111, + 90.761930629389098613, 70.512955680220329668, 9.0555989526947087143, 54.517131632353994064, + 16.921778488027484855, 45.609455700883700047, 12.624878685306612169, 30.473839320773549844, + 21.413191116236703238, 42.907550343894399703, 83.488179475454671774, 70.768774284832034027, + 84.64066630423621973, 38.353401659394876333, 25.064172980233706767, 100.5325107944154297, + 14.487409888301044703, 85.28070416787522845, 40.364944216733420035, 121.4973370175830496, + 61.739599068059760612, 101.32117478301370284, 116.50806979533444974, 10.532727349193010014, + 55.110575018254166935, 64.981596549736423185, 121.25737865530390991, 20.68716925918488414, + 105.90580033305377583, 45.720402983515668893, 7.0408790267902077176, 30.293485180500283604, + 90.380139433778822422, 18.747124680907290895, 17.154527461290854262, 33.935296477960946504, + 98.45889397086284589, 127.4842701448869775, 70.794481663517217385, 95.185410762460378464, + 30.911116543058597017, 25.580483744306548033, 5.1007856497599277645, 36.509720990987261757, + 39.194354538278275868, 71.887383518955175532, 107.31174732187355403, 60.282389129817602225, + 107.95108847626761417, 43.97543089825194329, 76.233196275017689914, 90.487961919636290986, + 65.71470220323317335, 83.603935727325733751, 100.83871928179723909, 77.000453961216408061, + 47.655798600997513859, 0.44483764458709629253, 54.323218141940742498, 70.728960805558017455, + 91.57643158977953135, 97.229470232883613789, 93.753347550889884587, 39.532989993640512694, + 69.557365115517313825, 48.857699818239780143, 36.863983177710906602, 93.828424640982120764, + 63.529217193899967242, 77.226429228128836257, 117.18254497761517996, 51.554761323128332151, + 121.01913877411061549, 65.662551540473941714, 69.971616719500161707, 118.24977397912516608, + 1.3984982845759077463, 12.354741299750457983, 109.21287245484563755, 97.214506672677089227, + 26.474604172126419144, 19.864806529825727921, 23.702399469788360875, 20.645108511660509976, + 87.922971924592275172, 66.687889231339795515, 123.42059235641136183, 4.0756611087599594612, + 39.555748312639479991, 13.516400144126237137, 113.28916192261021934, 127.69141548273546505, + 76.255882581157493405, 83.614353837227099575, 123.75214262487497763, 3.220412834456510609, + 32.143219792997115292, 59.272629638067883207, 90.954301204896182753, 10.489440802026365418, + 79.873244884583982639, 22.947216127980937017, 59.762651856850425247, 99.796372646291274577, + 124.84051191724211094, 67.970959201044024667, 66.276117737714230316, 110.35303535828279564, + 113.52022405118623283, 30.086508395710552577, 44.363281981666659703, 48.772189882431121077, + 26.421898412969312631, 105.35271953661140287, 85.326162572353496216, 48.130004461061616894, + 74.653704342865239596, 7.7651840889593586326, 122.90266557556606131, 56.106365645086043514, + 18.621773515329550719, 69.418238292764726793, 17.93752578997737146, 63.610168360926763853, + 90.529687424630537862, 74.249472067684109788, 126.71638694636203581, 6.2972410232105175965, + 19.73493729236361105, 31.683287563599151326, 99.709124192100716755, 80.272061410432797857, + 19.336800378441694193, 48.715214154664863599, 96.315431097315013176, 62.41986102017108351, + 76.724735858853819082, 36.256557910408446332, 123.04246798574240529, 6.580347466777311638, + 54.216469800077902619, 118.44939167081611231, 10.705472227800783003, 64.812239382525149267, + 10.555190177139593288, 57.77022208828930161, 93.464694642196263885, 23.499662340407667216, + 89.938622560952353524, 41.714085971296299249, 40.552272943728894461, 34.259838138568738941, + 24.293234292665147223, 98.891736576093535405, 49.437665238347108243, 74.571565727695997339, + 127.18554992345525534, 119.46270034693588968, 19.503691480469569797, 118.3950057594338432, + 22.300686301383393584, 4.5916997505810286384, 65.158320548645860981, 63.415489503309800057, + 75.799298961937893182, 100.52044016104628099, 107.58903797205493902, 79.235582839981361758, + 127.82175181109050754, 115.44255976674685371, 62.845754978698096238, 29.982290816624299623, + 27.160550153956137365, 9.5739201159849471878, 31.038661727026919834, 49.653055124799720943, + 20.750063908664742485, 4.1471628598592360504, 10.642336753953713924, 73.677662669662822736, + 92.570735679390054429, 125.20563457639582339, 52.317685243215237278, 89.900192502835125197, + 47.834496425810357323, 31.431666292304726085, 120.59501011049360386, 0.78293047492479672655, + 76.570504982741113054, 94.638831344112986699, 69.75404425942178932, 37.354198609391460195, + 28.614258853584033204, 29.853069034645159263, 127.59557859334017849, 116.30557744651378016, + 43.19997531295666704, 107.34015681194068748, 8.3142421689444745425, 0.5722798663227877114, + 67.799315453186864033, 56.957593989351153141, 94.024539819329220336, 46.49719209422255517, + 99.130912277916650055, 12.91327788762646378, 93.905137493242364144, 97.021101159058162011, + 1.4465027698970516212, 8.5329048651801713277, 120.02643966620962601, 31.126723062407108955, + 69.411509451187157538, 13.798068875912576914, 16.01933015311442432, 41.245466081283666426, + 11.432255754418292781, 19.268482309322280344, 51.689722612711193506, 84.455620126384019386, + 107.73211315497246687, 98.42998390733555425, 45.591167480506555876, 96.495575022308912594, + 0.6812251629562524613, 90.111489297396474285, 60.24042184262725641, 23.357624744206987089, + 51.30434880649409024, 52.642903998977999436, 93.868699666007159976, 14.790304960442881566, + 111.9479755593383743, 10.936780393221852137, 47.6905272505900939, 110.04630093516607303, + 111.83431713278696407, 61.811696506556472741, 117.87333918747026473, 21.495384976900822949, + 44.062874550105334492, 114.42508468748201267, 113.7087495819250762, 82.518025009925622726, + 109.28437463444060995, 5.2623670804423454683, 82.059555757201451343, 11.433092378210858442, + 45.928838619332964299, 83.388446284341625869, 14.745933810649148654, 111.70912866604703595, + 51.952599004074727418, 9.4357537060968752485, 12.467495194236107636, 16.828304230832145549, + 3.0966760335504659452, 118.43307770036699367, 93.925811557339329738, 109.71222616994418786, + 102.67090063283831114, 104.13570723715383792, 41.494145134234713623, 123.25716107062908122, + 101.92444278874972952, 91.931624590764840832, 109.72118925502945785, 88.928863127261138288, + 28.125236830586800352, 47.985350145478150807, 40.200796218145114835, 5.3646188802049437072, + 30.803614988199115032, 51.791715597883012379, 13.469748374776827404, 6.3576418613738496788, + 115.61014450779111939, 7.9195249713993689511, 36.892273284694965696, 43.284879936429206282, + 73.539328747694526101, 48.720461559831164777, 21.162406285533506889, 111.66500150467982166, + 87.85749775452495669, 109.28692901822796557, 29.211710074148868443, 97.103854970129759749, + 92.357691183187853312, 127.57714852832214092, 84.034577180857013445, 51.290064291421003873, + 66.591000601281848503, 38.37036982316931244, 125.75725720754780923, 117.43829877943426254, + 40.126424117323040264, 0.07800354057690128684, 96.49252704933314817, 26.512416689900419442, + 74.747904630690754857, 89.641782758662884589, 5.6201129740584292449, 77.082111912626714911, + 17.245908779645105824, 45.421064613914495567, 84.815832354597660014, 62.684713512229791377, + 37.305175798057462089, 100.21453176228169468, 73.958507482286222512, 41.677259457665059017, + 66.200241254904540256, 42.658317420486127958, 55.161433244633371942, 106.50587414019901189, + 51.068241032378864475, 118.27476036912048585, 104.86872082026457065, 19.399289799956022762, + 94.575460545504029142, 113.70522960836751736, 67.670477003881387645, 62.916685788808536017, + 49.642999130221141968, 103.41455758035590407, 28.530340308785525849, 37.244062243331427453, + 112.53451953806870733, 112.01670718191599008, 38.652045241335144965, 2.0669999557940172963, + 44.669355831036227755, 107.85769577709652367, 70.663329593706293963, 101.21620504048769362, + 2.8602111061481991783, 93.2272986738862528, 45.528362352590193041, 24.191454458279622486, + 5.5400446426683629397, 125.96850487453775713, 86.212873046250024345, 61.590687841075123288, + 95.064920471759251086, 55.471121000628045294, 106.55290761851938441, 29.600072566918242956, + 13.085386415368702728, 103.11896978528602631, 86.665503240226826165, 71.849790701933670789, + 47.96850320829616976, 29.777683463238645345, 77.307046610814722953, 35.866692687002796447, + 24.305844368482212303, 70.276502152879402274, 1.4152066614733485039, 5.9397970702411839738, + 101.23120935713814106, 42.583669863706745673, 97.565361440563719952, 73.16727833177355933, + 59.58031867546014837, 120.5534615326578205, 124.17865305736995651, 6.5997884897587937303, + 123.46261940145268454, 25.786560767515766202, 53.523861258781835204, 13.025911360440659337, + 18.111197905389417429, 109.03426326470798813, 33.843556976054969709, 91.218911401767400093, + 25.249757370613224339, 60.947678641547099687, 42.826382232473406475, 85.815100687792437384, + 38.976358950912981527, 13.537548569667706033, 41.28133260847243946, 76.706803318789752666, + 50.128345960471051512, 73.0650215888308594, 28.974819776605727384, 42.561408335750456899, + 80.729888433470478049, 114.9946740351660992, 123.4791981361231592, 74.642349566031043651, + 105.01613959066889947, 21.065454698386020027, 110.22115003651197185, 1.963193099476484349, + 114.51475731060781982, 41.374338518373406259, 83.81160066610755166, 91.440805967031337786, + 14.081758053580415435, 60.586970361004205188, 52.760278867557644844, 37.494249361814581789, + 34.309054922581708524, 67.870592955925530987, 68.917787941729329759, 126.96854028977759299, + 13.588963327038072748, 62.370821524920756929, 61.822233086117194034, 51.160967488613096066, + 10.201571299519855529, 73.019441981974523515, 78.388709076560189715, 15.774767037913989043, + 86.623494643747108057, 120.56477825963884243, 87.902176952535228338, 87.950861796507524559, + 24.466392550039017806, 52.975923839276219951, 3.4294044064699846786, 39.207871454655105481, + 73.677438563598116161, 26.000907922432816122, 95.311597201995027717, 0.88967528917419258505, + 108.64643628388512298, 13.45792161111603491, 55.15286317956270068, 66.458940465770865558, + 59.506695101779769175, 79.065979987284663366, 11.11473023103462765, 97.715399636479560286, + 73.727966355425451184, 59.656849281964241527, 127.05843438780357246, 26.452858456261310494, + 106.36508995523035992, 103.10952264626030228, 114.03827754822486895, 3.325103080951521406, + 11.943233439003961394, 108.49954795825033216, 2.7969965691518154927, 24.709482599504553946, + 90.425744909694913076, 66.429013345354178455, 52.949208344252838288, 39.729613059651455842, + 47.40479893957672175, 41.29021702332465793, 47.845943849188188324, 5.3757784626832290087, + 118.84118471282272367, 8.1513222175199189223, 79.111496625278959982, 27.032800288256112253, + 98.578323845224076649, 127.38283096547456807, 24.511765162318624789, 39.228707674457837129, + 119.50428524974995526, 6.440825668913021218, 64.286439585994230583, 118.54525927613940439, + 53.908602409792365506, 20.978881604056368815, 31.746489769167965278, 45.894432255961874034, + 119.52530371370448847, 71.592745292586187134, 121.68102383448785986, 7.9419184020916873123, + 4.5522354754320986103, 92.706070716569229262, 99.040448102372465655, 60.173016791421105154, + 88.726563963333319407, 97.544379764862242155, 52.84379682594226324, 82.705439073226443725, + 42.652325144706992432, 96.260008922126871767, 21.307408685730479192, 15.530368177922355244, + 117.80533115113212261, 112.21273129017208703, 37.243547030662739417, 10.836476585529453587, + 35.87505157995474292, 127.22033672185716568, 53.059374849264713703, 20.498944135371857556, + 125.43277389272407163, 12.594482046421035193, 39.4698745847272221, 63.366575127201940631, + 71.418248384205071488, 32.544122820865595713, 38.673600756883388385, 97.430428309333365178, + 64.630862194630026352, 124.839722040345805, 25.449471717707638163, 72.513115820820530644, + 118.08493597148481058, 13.160694933554623276, 108.43293960015944322, 108.89878334163222462, + 21.410944455605203984, 1.6244787650502985343, 21.110380354279186577, 115.5404441765822412, + 58.92938928439252777, 46.999324680818972411, 51.877245121904707048, 83.428171942592598498, + 81.104545887457788922, 68.519676277137477882, 48.586468585333932424, 69.783473152187070809, + 98.875330476697854465, 21.143131455395632656, 126.37109984691414866, 110.92540069387177937, + 39.007382960942777572, 108.79001151886768639, 44.601372602766787168, 9.1833995011656952556, + 2.3166410972917219624, 126.83097900662323809, 23.598597923879424343, 73.040880322096199961, + 87.178075944113516016, 30.471165679966361495, 127.64350362218465307, 102.88511953349370742, + 125.69150995739619248, 59.964581633248599246, 54.321100307912274729, 19.147840231969894376, + 62.077323454053839669, 99.306110249599441886, 41.500127817329484969, 8.2943257197184721008, + 21.284673507911065826, 19.355325339329283452, 57.141471358783746837, 122.41126915279164677, + 104.63537048643411254, 51.800385005670250393, 95.668992851620714646, 62.863332584613090148, + 113.19002022098720772, 1.5658609498532314319, 25.141009965485864086, 61.277662688229611376, + 11.50808851884357864, 74.70839721878292039, 57.228517707168066408, 59.706138069293956505, + 127.19115718668399495, 104.61115489302756032, 86.399950625916972058, 86.680313623881374951, + 16.628484337888949085, 1.1445597326492134016, 7.5986309063737280667, 113.91518797870594426, + 60.049079638658440672, 92.994384188448748318, 70.26182455583330011, 25.826555775256565539, + 59.810274986488366267, 66.042202318116324022, 2.8930055397941032425, 17.065809730363980634, + 112.05287933241925202, 62.253446124817855889, 10.823018902374315076, 27.596137751825153828, + 32.03866030622884864, 82.490932162567332853, 22.864511508836585563, 38.536964618644560687, + 103.37944522542602499, 40.911240252771676751, 87.464226309948571725, 68.859967814671108499, + 91.18233496101674973, 64.991150044617825188, 1.3624503259161429014, 52.22297859479294857, + 120.48084368525451282, 46.715249488413974177, 102.60869761298818048, 105.28580799795963685, + 59.737399332014319953, 29.58060992088940111, 95.895951118676748592, 21.873560786443704274, + 95.381054501183825778, 92.092601870335784042, 95.668634265573928133, 123.62339301311658346, + 107.74667837494052947, 42.990769953801645897, 88.125749100214306964, 100.85016937496766332, + 99.417499163853790378, 37.036050019854883431, 90.568749268881219905, 10.524734160888328915, + 36.119111514402902685, 22.866184756421716884, 91.857677238669566577, 38.776892568683251739, + 29.491867621301935287, 95.418257332094071899, 103.90519800814945484, 18.871507412193750497, + 24.934990388472215272, 33.656608461664291099, 6.1933520671045698691, 108.86615540073762531, + 59.851623114682297455, 91.424452339892013697, 77.341801265680260258, 80.271414474307675846, + 82.988290268473065225, 118.51432214126180043, 75.848885577503097011, 55.863249181533319643, + 91.442378510062553687, 49.857726254522276577, 56.250473661173600703, 95.970700290956301615, + 80.401592436290229671, 10.729237760409887414, 61.607229976398230065, 103.58343119576602476, + 26.939496749553654809, 12.715283722751337336, 103.22028901558223879, 15.839049942798737902, + 73.784546569389931392, 86.569759872862050543, 19.078657495389052201, 97.440923119662329555, + 42.324812571070651757, 95.330003009363281308, 47.714995509053551359, 90.573858036455931142, + 58.423420148301374866, 66.207709940263157478, 56.715382366379344603, 127.15429705664791982, + 40.069154361714026891, 102.58012858284564572, 5.1820012025636970066, 76.740739646342262859, + 123.51451441509925644, 106.87659755886852508, 80.252848234646080527, 0.15600708115744055249, + 64.985054098666296341, 53.024833379804476863, 21.495809261385147693, 51.283565517325769179, + 11.240225948120496469, 26.164223825253429823, 34.491817559290211648, 90.842129227832629113, + 41.631664709195320029, 125.36942702445958275, 74.610351596118562156, 72.429063524567027343, + 19.917014964572445024, 83.354518915333756013, 4.4004825098090805113, 85.316634840972255915, + 110.32286648927038186, 85.01174828039802378, 102.13648206476136693, 108.54952073824460967, + 81.737441640529141296, 38.798579599915683502, 61.150921091011696262, 99.410459216738672694, + 7.3409540077627752908, 125.83337157761707203, 99.285998260445921915, 78.82911516071180813, + 57.060680617571051698, 74.488124486666492885, 97.069039076141052647, 96.033414363831980154, + 77.30409048267028993, 4.1339999115880345926, 89.338711662076093489, 87.71539155419668532, + 13.326659187416225905, 74.432410080975387245, 5.7204222123000363354, 58.4545973477725056, + 91.056724705180386081, 48.382908916559244972, 11.080089285340363858, 123.93700974907915224, + 44.42574609250004869, 123.18137568215388455, 62.129840943518502172, 110.94224200125972857, + 85.105815237038768828, 59.200145133836485911, 26.170772830741043435, 78.237939570575690595, + 45.331006480457290309, 15.699581403867341578, 95.937006416592339519, 59.555366926480928669, + 26.614093221629445907, 71.733385374005592894, 48.611688736968062585, 12.553004305758804549, + 2.8304133229466970079, 11.879594140486005927, 74.462418714276282117, 85.167339727417129325, + 67.130722881131077884, 18.33455666354711866, 119.16063735092393472, 113.10692306531927898, + 120.35730611473991303, 13.199576979521225439, 118.92523880290536908, 51.573121535031532403, + 107.04772251756367041, 26.051822720881318673, 36.222395810782472836, 90.068526529415976256, + 67.687113952113577398, 54.437822803534800187, 50.499514741226448677, 121.89535728309419937, + 85.652764464950450929, 43.630201375584874768, 77.952717901825963054, 27.075097139335412066, + 82.5626652169485169, 25.413606637579505332, 100.256691920945741, 18.130043177661718801, + 57.949639553211454768, 85.122816671504551778, 33.459776866944594076, 101.98934807033583638, + 118.95839627224995638, 21.28469913206572528, 82.032279181337798946, 42.130909396775678033, + 92.442300073023943696, 3.9263861989566066768, 101.02951462121563964, 82.748677036750450497, + 39.6232013322187413, 54.881611934062675573, 28.16351610716083087, 121.17394072200841038, + 105.52055773511528969, 74.988498723629163578, 68.618109845167055028, 7.7411859118546999525, + 9.8355758834622974973, 125.93708057955518598, 27.177926654076145496, 124.74164304984151386, + 123.64446617223438807, 102.32193497722619213, 20.403142599043349037, 18.038883963952685008, + 28.777418153120379429, 31.549534075831616065, 45.246989287497854093, 113.12955651928132284, + 47.804353905074094655, 47.901723593015049119, 48.932785100078035612, 105.9518476785524399, + 6.8588088129399693571, 78.415742909313848941, 19.354877127196232323, 52.001815844869270222, + 62.623194403990055434, 1.7793505783520231489, 89.292872567770245951, 26.915843222235707799, + 110.30572635912903934, 4.9178809315417311154, 119.01339020356317633, 30.131959974569326732, + 22.229460462072893279, 67.43079927296275855, 19.455932710850902367, 119.31369856393212103, + 126.11686877560714493, 52.905716912526258966, 84.730179910464357818, 78.219045292524242541, + 100.0765550964497379, 6.6502061619030428119, 23.886466878011560766, 88.999095916500664316, + 5.5939931383036309853, 49.41896519901274587, 52.851489819393464131, 4.8580266907083569095, + 105.89841668850567658, 79.459226119302911684, 94.8095978791534435, 82.58043404664931586, + 95.691887698376376648, 10.751556925370095996, 109.68236942564544734, 16.302644435043475823, + 30.222993250557919964, 54.065600576515862485, 69.156647690451791277, 126.76566193094913615, + 49.023530324637249578, 78.457415348919312237, 111.00857049949991051, 12.881651337829680415, + 0.57287917199209914543, 109.09051855227880878, 107.81720481958473101, 41.95776320811273763, + 63.492979538335930556, 91.788864511927386047, 111.05060742741261492, 15.185490585176012246, + 115.36204766897571972, 15.883836804183374625, 9.1044709508678351995, 57.412141433142096503, + 70.08089620474493131, 120.34603358284584829, 49.453127926670276793, 67.08875952972448431, + 105.68759365188816446, 37.410878146452887449, 85.304650289417622844, 64.520017844253743533, + 42.614817371460958384, 31.060736355848348467, 107.61066230226788321, 96.425462580344174057, + 74.487094061325478833, 21.672953171058907174, 71.750103159913123818, 126.44067344371433137, + 106.11874969852942741, 40.99788827074735309, 122.86554778544814326, 25.188964092842070386, + 78.9397491694544442, 126.73315025440751924, 14.836496768410142977, 65.088245641731191427, + 77.347201513770414749, 66.860856618670368334, 1.2617243892636906821, 121.67944408069161, + 50.898943435418914305, 17.026231641644699266, 108.16987194296962116, 26.321389867112884531, + 88.865879200322524412, 89.797566683264449239, 42.821888911210407969, 3.2489575301005970687, + 42.220760708562011132, 103.0808883531644824, 117.85877856878505554, 93.998649361637944821, + 103.75449024381305207, 38.856343885188834975, 34.209091774919215823, 9.0393525542749557644, + 97.172937170671502827, 11.566946304377779597, 69.75066095339570893, 42.286262910794903291, + 124.74219969383193529, 93.850801387743558735, 78.014765921889193123, 89.580023037735372782, + 89.202745205533574335, 18.366799002331390511, 4.6332821945870819036, 125.66195801324647618, + 47.197195847762486665, 18.081760644196037902, 46.356151888227032032, 60.942331359936360968, + 127.28700724437294411, 77.770239066991052823, 123.38301991479238495, 119.92916326649719849, + 108.64220061582454946, 38.295680463939788751, 124.15464690811131732, 70.612220499198883772, + 83.000255634658969939, 16.588651439436944202, 42.569347015822131652, 38.710650678658566903, + 114.28294271757113165, 116.82253830558693153, 81.270740972868225072, 103.60077001134413877, + 63.337985703241429292, 125.72666516922981828, 98.380040441974415444, 3.1317218997064628638, + 50.282019930971728172, 122.55532537645922275, 23.01617703769079526, 21.416794437565840781, + 114.45703541433613282, 119.41227613859155099, 126.38231437337162788, 81.222309786058758618, + 44.799901251837582095, 45.360627247762749903, 33.25696867577789817, 2.2891194652984268032, + 15.197261812751094112, 99.830375957411888521, 120.09815927732051932, 57.988768376901134616, + 12.52364911166660022, 51.653111550513131078, 119.62054997298037051, 4.0844046362326480448, + 5.7860110795882064849, 34.131619460731599247, 96.105758664838504046, 124.50689224963571178, + 21.646037804748630151, 55.192275503650307655, 64.077320612461335259, 36.981864325134665705, + 45.729023017673171125, 77.073929237292759353, 78.75889045085204998, 81.822480505546991481, + 46.928452619900781428, 9.7199356293458549771, 54.364669922037137439, 1.9823000892356503755, + 2.7249006518322858028, 104.44595718958953512, 112.96168737050902564, 93.430498976831586333, + 77.217395225979998941, 82.571615995919273701, 119.47479866402863991, 59.161219841782440199, + 63.791902237353497185, 43.747121572891046526, 62.762109002371289534, 56.185203740675206063, + 63.337268531151494244, 119.2467860262368049, 87.493356749881058931, 85.981539907606929773, + 48.251498200432251906, 73.700338749938964611, 70.834998327707580756, 74.07210003971340484, + 53.13749853776243981, 21.049468321776657831, 72.23822302880580537, 45.732369512847071746, + 55.715354477339133155, 77.553785137366503477, 58.983735242607508553, 62.836514664191781776, + 79.810396016298909672, 37.743014824387500994, 49.869980776944430545, 67.313216923328582197, + 12.386704134212777717, 89.732310801475250628, 119.70324622936823289, 54.848904679787665373, + 26.683602531364158494, 32.542828948618989671, 37.97658053694976843, 109.02864428252723883, + 23.697771155006194022, 111.72649836307027726, 54.884757020125107374, 99.715452509044553153, + 112.50094732235083939, 63.941400581916241208, 32.803184872580459341, 21.458475520819774829, + 123.21445995280009811, 79.166862391532049514, 53.878993499107309617, 25.430567445506312652, + 78.440578031164477579, 31.678099885601113783, 19.569093138783500763, 45.139519745724101085, + 38.157314990781742381, 66.881846239324659109, 84.649625142144941492, 62.660006018726562615, + 95.429991018110740697, 53.147716072911862284, 116.84684029660638771, 4.4154198805263149552, + 113.43076473276232718, 126.30859411329583963, 80.13830872343169176, 77.160257165691291448, + 10.364002405131031992, 25.481479292688163696, 119.02902883020215086, 85.753195117740688147, + 32.505696469292161055, 0.31201416231851908378, 1.9701081973325926811, 106.04966675960895373, + 42.991618522770295385, 102.56713103465153836, 22.480451896240992937, 52.328447650506859645, + 68.983635118584061274, 53.684258455665258225, 83.263329418394278036, 122.73885404892280349, + 21.220703192240762291, 16.858127049134054687, 39.834029929148528026, 38.709037830667512026, + 8.8009650196217990015, 42.63326968194814981, 92.645732978544401703, 42.02349656079968554, + 76.272964129526371835, 89.099041476492857328, 35.474883281058282591, 77.597159199831367005, + 122.3018421820270305, 70.820918433477345388, 14.68190801552918856, 123.66674315523778205, + 70.571996520895481808, 29.65823032142361626, 114.12136123514574138, 20.976248973336623749, + 66.138078152285743272, 64.066828727667598287, 26.60818096534057986, 8.2679998231797071639, + 50.677423324155824957, 47.43078310839337064, 26.653318374836089788, 20.864820161950774491, + 11.440844424600072671, 116.90919469554864918, 54.113449410360772163, 96.765817833118489943, + 22.160178570684365695, 119.87401949815830449, 88.851492185003735358, 118.36275136430776911, + 124.25968188704064232, 93.884484002523095114, 42.211630474077537656, 118.40029026767297182, + 52.34154566148572485, 28.475879141151381191, 90.662012960914580617, 31.399162807738321135, + 63.874012833184679039, 119.11073385296185734, 53.228186443262529792, 15.466770748011185788, + 97.22337747393612517, 25.106008611517609097, 5.6608266458933940157, 23.759188280975649832, + 20.924837428556202212, 42.334679454837896628, 6.2614457622621557675, 36.669113327097875299, + 110.32127470185150742, 98.213846130642195931, 112.71461222947982606, 26.399153959046088858, + 109.85047760581073817, 103.14624307006670278, 86.095445035127340816, 52.103645441762637347, + 72.444791621568583651, 52.137053058835590491, 7.3742279042271547951, 108.87564560706960037, + 100.99902948245653533, 115.79071456619203673, 43.305528929900901858, 87.260402751173387514, + 27.905435803651926108, 54.150194278674462112, 37.125330433897033799, 50.827213275162648642, + 72.513383841891482007, 36.260086355323437601, 115.89927910642654751, 42.245633343009103555, + 66.919553733892826131, 75.978696140675310744, 109.91679254449991276, 42.569398264135088539, + 36.064558362675597891, 84.261818793554994045, 56.884600146047887392, 7.8527723979168513324, + 74.059029242434917251, 37.497354073500900995, 79.246402664437482599, 109.76322386812535115, + 56.327032214325299719, 114.34788144402045873, 83.041115470234217355, 21.976997447261965135, + 9.2362196903341100551, 15.482371823709399905, 19.671151766928232973, 123.87416115911037195, + 54.355853308155928971, 121.48328609968666569, 119.28893234447241412, 76.643869954452384263, + 40.806285198086698074, 36.077767927905370016, 57.554836306240758859, 63.099068151663232129, + 90.493978574999346165, 98.25911303856264567, 95.60870781014818931, 95.803447186030098237, + 97.865570200159709202, 83.903695357104879804, 13.717617625883576693, 28.831485818627697881, + 38.709754254392464645, 104.00363168973854044, 125.24638880798011087, 3.5587011567076842766, + 50.585745135540491901, 0, 92.611452718258078676, 9.8357618630871002097, + 110.02678040712635266, 60.263919949138653465, 44.458920924149424536, 6.8615985459255171008, + 38.911865421705442714, 110.62739712786788004, 124.23373755121428985, 105.81143382505615591, + 41.460359820932353614, 28.43809058505212306, 72.153110192899475805, 13.300412323806085624, + 47.772933756026759511, 49.998191833001328632, 11.187986276607261971, 98.837930398025491741, + 105.70297963878692826, 9.7160533814203517977, 83.796833377014991129, 30.918452238609461347, + 61.61919575831052498, 37.160868093302269699, 63.383775396752753295, 21.503113850743829971, + 91.364738851290894672, 32.605288870086951647, 60.445986501115839928, 108.13120115303536295, + 10.313295380907220533, 125.5313238618982723, 98.047060649278137134, 28.914830697842262452, + 94.017140998999821022, 25.76330267565936083, 1.1457583439878362697, 90.181037104561255546, + 87.634409639169462025, 83.915526416225475259, 126.98595907667549909, 55.577729023858410073, + 94.10121485482522985, 30.370981170355662471, 102.72409533795143943, 31.767673608366749249, + 18.208941901735670399, 114.82428286628783098, 12.1617924094935006, 112.69206716569169657, + 98.906255853344191564, 6.1775190594526065979, 83.375187303776328918, 74.821756292909412878, + 42.609300578838883666, 1.0400356885074870661, 85.229634742921916768, 62.121472711700334912, + 87.22132460453940439, 64.850925160691986093, 20.974188122650957666, 43.345906342121452326, + 15.500206319829885615, 124.88134688743230072, 84.237499397058854811, 81.995776541498344159, + 117.73109557089628652, 50.37792818568777875, 29.879498338912526378, 125.46630050881503848, + 29.672993536823923932, 2.1764912834660208318, 26.694403027544467477, 5.7217132373407366686, + 2.5234487785310193431, 115.35888816138321999, 101.79788687083782861, 34.052463283293036511, + 88.339743885939242318, 52.64277973422940704, 49.731758400648686802, 51.595133366528898478, + 85.643777822420815937, 6.4979150602011941373, 84.441521417127660243, 78.161776706332602771, + 107.71755713757374906, 59.997298723279527621, 79.50898048762610415, 77.712687770377669949, + 68.418183549838431645, 18.078705108553549508, 66.345874341343005653, 23.133892608759197174, + 11.501321906791417859, 84.572525821593444562, 121.48439938766750856, 59.701602775490755448, + 28.029531843782024225, 51.160046075474383542, 50.405490411067148671, 36.733598004662781022, + 9.266564389177801786, 123.32391602649295237, 94.394391695524973329, 36.163521288392075803, + 92.712303776454064064, 121.88466271987635992, 126.57401448874952621, 27.540478133985743625, + 118.76603982958840788, 111.85832653299803496, 89.284401231649098918, 76.591360927883215481, + 120.30929381622627261, 13.224440998401405523, 38.000511269317939878, 33.177302878873888403, + 85.138694031644263305, 77.421301357320771785, 100.56588543514590128, 105.64507661117750104, + 34.541481945740088122, 79.201540022688277531, 126.67597140648649656, 123.45333033846327453, + 68.760080883948830888, 6.2634437994129257277, 100.56403986194709432, 117.11065075291844551, + 46.032354075381590519, 42.83358887513531954, 100.91407082867590361, 110.82455227718673996, + 124.76462874674689374, 34.444619572117517237, 89.599802503675164189, 90.721254495525499806, + 66.51393735155579634, 4.5782389305968536064, 30.394523625505826203, 71.660751914827415021, + 112.19631855464103865, 115.97753675380226923, 25.04729822333320044, 103.30622310102990014, + 111.24109994596074102, 8.1688092724652960896, 11.57202215917641297, 68.263238921466836473, + 64.211517329680646071, 121.01378449927142356, 43.292075609497260302, 110.38455100730425329, + 0.15464122492267051712, 73.963728650269331411, 91.45804603534998023, 26.147858474589156685, + 29.517780901707737939, 35.644961011093982961, 93.856905239801562857, 19.439871258691709954, + 108.72933984407427488, 3.964600178471300751, 5.4498013036682095844, 80.891914379182708217, + 97.92337474102168926, 58.860997953666810645, 26.43479045196363586, 37.14323199184218538, + 110.94959732805727981, 118.3224396835648804, 127.58380447470699437, 87.494243145782093052, + 125.52421800474257907, 112.37040748135041213, 126.67453706230662647, 110.49357205247724778, + 46.986713499765755842, 43.963079815213859547, 96.502996400868141791, 19.400677499881567201, + 13.669996655418799492, 20.14420007942680968, 106.27499707552487962, 42.098936643556953641, + 16.47644605761161074, 91.464739025694143493, 111.43070895468190429, 27.107570274733006954, + 117.96747048521501711, 125.67302932838720153, 31.620792032597819343, 75.486029648775001988, + 99.739961553892499069, 6.6264338466571643949, 24.773408268429193413, 51.464621602954139234, + 111.40649245873646578, 109.69780935957533075, 53.367205062728316989, 65.085657897237979341, + 75.953161073903174838, 90.057288565054477658, 47.395542310016026022, 95.452996726140554529, + 109.76951404025385273, 71.430905018092744285, 97.001894644701678772, 127.88280116383248242, + 65.606369745160918683, 42.916951041643187637, 118.4289199056038342, 30.333724783064099029, + 107.75798699821461923, 50.861134891016263282, 28.881156062328955159, 63.356199771202227566, + 39.138186277567001525, 90.27903949144820217, 76.314629981567122741, 5.763692478652956197, + 41.299250284289882984, 125.32001203745676321, 62.859982036221481394, 106.29543214582736255, + 105.69368059321277542, 8.8308397610562678892, 98.861529465528292349, 124.61718822659531725, + 32.276617446867021499, 26.320514331382582895, 20.728004810262063984, 50.962958585379965371, + 110.05805766040793969, 43.506390235481376294, 65.01139293858432211, 0.62402832463703816757, + 3.9402163946688233409, 84.099333519217907451, 85.983237045544228749, 77.134262069303076714, + 44.960903792481985874, 104.65689530101735727, 9.9672702371681225486, 107.36851691133415443, + 38.526658836792194052, 117.47770809784560697, 42.441406384481524583, 33.716254098268109374, + 79.668059858297056053, 77.418075661335024051, 17.601930039243598003, 85.266539363899937598, + 57.291465957088803407, 84.046993121603009058, 24.545928259056381648, 50.198082952985714655, + 70.949766562120203162, 27.194318399666371988, 116.60368436405769899, 13.641836866954690777, + 29.363816031062015099, 119.33348631047920207, 13.143993041790963616, 59.316460642850870499, + 100.24272247029148275, 41.952497946676885476, 4.2761563045751245227, 0.13365745533519657329, + 53.21636193068115972, 16.535999646359414328, 101.35484664831164991, 94.861566216786741279, + 53.306636749672179576, 41.729640323901548982, 22.88168884920378332, 105.81838939109729836, + 108.2268988207251823, 65.531635666236979887, 44.320357141372369369, 111.74803899632024695, + 49.702984370011108695, 108.7255027286191762, 120.51936377408492262, 59.768968005046190228, + 84.42326094815871329, 108.80058053534594364, 104.6830913229714497, 56.951758282306400361, + 53.324025921829161234, 62.79832561547664227, 127.74802566637299606, 110.22146770592371468, + 106.45637288652505958, 30.933541496026009554, 66.446754947872250341, 50.212017223035218194, + 11.321653291786788031, 47.518376561951299664, 41.849674857112404425, 84.669358909675793257, + 12.522891524524311535, 73.338226654199388577, 92.642549403706652811, 68.42769226128802984, + 97.429224458959652111, 52.798307918095815694, 91.700955211625114316, 78.292486140137043549, + 44.190890070254681632, 104.20729088352891267, 16.889583243137167301, 104.27410611767118098, + 14.748455808457947569, 89.751291214142838726, 73.998058964916708646, 103.58142913238407345, + 86.611057859805441694, 46.520805502346775029, 55.810871607303852215, 108.30038855734892422, + 74.250660867794067599, 101.65442655032893526, 17.026767683782964014, 72.520172710650513181, + 103.79855821285309503, 84.491266686021845089, 5.83910746778929024, 23.957392281354259467, + 91.83358508899982553, 85.138796528270177078, 72.129116725354833761, 40.52363758710998809, + 113.76920029209577478, 15.705544795837340644, 20.118058484869834501, 74.994708147005439969, + 30.492805328878603177, 91.526447736250702292, 112.65406442865423742, 100.69576288804455544, + 38.08223094046843471, 43.95399489452393027, 18.47243938066822011, 30.96474364741879981, + 39.342303533860103926, 119.74832231822074391, 108.71170661631549592, 114.96657219937696937, + 110.57786468894846621, 25.287739908904768527, 81.612570396173396148, 72.155535855810740031, + 115.10967261248151772, 126.19813630333010224, 52.987957150002330309, 68.518226077128929319, + 63.217415620300016599, 63.606894372063834453, 67.731140400323056383, 39.807390714209759608, + 27.435235251767153386, 57.662971637255395763, 77.419508508788567269, 80.007263379480718868, + 122.49277761596022174, 7.1174023134153685533, 101.1714902710809838, 0, + 57.222905436516157351, 19.671523726177838398, 92.053560814252705313, 120.52783989827730693, + 88.917841848298849072, 13.723197091851034202, 77.823730843414523406, 93.254794255739398068, + 120.46747510243221768, 83.622867650112311821, 82.920719641864707228, 56.8761811701078841, + 16.306220385798951611, 26.600824647612171248, 95.545867512053519022, 99.996383666002657264, + 22.37597255321816192, 69.67586079605462146, 83.405959277573856525, 19.432106762844341574, + 39.593666754029982258, 61.836904477218922693, 123.23839151662104996, 74.321736186604539398, + 126.76755079350550659, 43.006227701491297921, 54.729477702581789345, 65.210577740173903294, + 120.89197300223531784, 88.262402306070725899, 20.626590761818079045, 123.06264772380018258, + 68.094121298556274269, 57.829661395688162884, 60.034281997999642044, 51.526605351318721659, + 2.2915166879793105181, 52.362074209126149071, 47.268819278342562029, 39.831052832454588497, + 125.97191815335099818, 111.15545804772045813, 60.202429709650459699, 60.74196234071496292, + 77.448190675902878866, 63.535347216733498499, 36.417883803474978777, 101.64856573257566197, + 24.323584818990639178, 97.384134331387031125, 69.812511706688383128, 12.355038118908851175, + 38.750374607556295814, 21.643512585818825755, 85.218601157677767333, 2.080071377018612111, + 42.459269485843833536, 124.2429454234043078, 46.44264920908244676, 1.7018503213839721866, + 41.948376245301915333, 86.691812684242904652, 31.000412639663409209, 121.76269377486823942, + 40.474998794121347601, 35.991553083000326296, 107.46219114179257303, 100.7558563713755575, + 59.758996677828690736, 122.93260101763007697, 59.345987073647847865, 4.3529825669320416637, + 53.388806055088934954, 11.443426474681473337, 5.0468975570656766649, 102.71777632277007797, + 75.59577374167565722, 68.104926566589711001, 48.679487771878484637, 105.28555946845881408, + 99.463516801297373604, 103.19026673306143493, 43.287555644841631874, 12.995830120406026253, + 40.883042834258958464, 28.323553412668843521, 87.43511427514749812, 119.99459744656269322, + 31.017960975255846279, 27.425375540758977877, 8.8363670996768632904, 36.157410217110736994, + 4.6917486826860113069, 46.267785217518394347, 23.002643813586473698, 41.145051643190527102, + 114.96879877533501713, 119.4032055509815109, 56.05906368756404845, 102.32009215094876708, + 100.81098082213429734, 73.467196009325562045, 18.533128778359241551, 118.64783205298954272, + 60.788783391049946658, 72.327042576787789585, 57.424607552911766106, 115.76932543975635781, + 125.14802897749905242, 55.080956267975125229, 109.53207965918045375, 95.716653065999707906, + 50.568802463301835814, 25.182721855770068942, 112.61858763245254522, 26.448881996802811045, + 76.001022538635879755, 66.354605757751414785, 42.277388063292164588, 26.84260271464518155, + 73.131770870295440545, 83.290153222355002072, 69.082963891483814223, 30.403080045380193042, + 125.3519428129766311, 118.90666067693018704, 9.5201617678976617754, 12.526887598829489434, + 73.128079723897826625, 106.22130150583689101, 92.064708150763181038, 85.667177750274277059, + 73.828141657355445204, 93.649104554377117893, 121.52925749349378748, 68.889239144238672452, + 51.199605007353966357, 53.44250899105463759, 5.0278747031115926802, 9.1564778611937072128, + 60.789047251015290385, 15.321503829658468021, 96.392637109285715269, 103.95507350760453846, + 50.094596446670038858, 78.61244620206343825, 94.482199891921482049, 16.337618544930592179, + 23.144044318356463918, 8.5264778429373109248, 0.42303465936493012123, 114.02756899854284711, + 86.584151218998158583, 92.769102014608506579, 0.30928244984897901304, 19.9274573005423008, + 54.916092070699960459, 52.295716949178313371, 59.035561803415475879, 71.289922022191603901, + 59.713810479603125714, 38.879742517387057887, 89.458679688148549758, 7.9292003569426015019, + 10.899602607340057148, 33.783828758369054412, 67.846749482043378521, 117.72199590733362129, + 52.86958090392727172, 74.286463983688008739, 93.899194656118197599, 108.64487936713339877, + 127.16760894941762672, 46.988486291567824082, 123.04843600948879612, 96.740814962704462232, + 125.34907412461689091, 92.98714410495449556, 93.973426999531511683, 87.926159630431357073, + 65.005992801736283582, 38.801354999763134401, 27.339993310837598983, 40.288400158857257338, + 84.549994151049759239, 84.197873287113907281, 32.95289211522685946, 54.929478051391924964, + 94.861417909363808576, 54.215140549469651887, 107.93494097043367219, 123.34605865677440306, + 63.241584065199276665, 22.972059297553641954, 71.479923107784998138, 13.25286769331432879, + 49.546816536858386826, 102.92924320591191645, 94.812984917476569535, 91.395618719150661491, + 106.73441012546027196, 2.1713157944795966614, 23.906322147809987655, 52.114577130108955316, + 94.791084620035690023, 62.905993452284747036, 91.539028080511343433, 14.861810036189126549, + 66.003789289406995522, 127.76560232766860281, 3.2127394903218373656, 85.833902083290013252, + 108.85783981120766839, 60.667449566131836036, 87.515973996429238468, 101.72226978203252656, + 57.762312124657910317, 126.71239954240445513, 78.276372555137641029, 52.55807898290004232, + 24.629259963134245481, 11.527384957305912394, 82.598500568583403947, 122.64002407491352642, + 125.71996407244660077, 84.590864291658363072, 83.387361186425550841, 17.661679522116173757, + 69.723058931060222676, 121.23437645319063449, 64.553234893734042998, 52.641028662765165791, + 41.456009620524127968, 101.92591717076356872, 92.116115320815879386, 87.012780470966390567, + 2.0227858771686442196, 1.2480566492740763351, 7.8804327893412846606, 40.198667038439452881, + 43.966474091092095478, 26.268524138606153429, 89.921807584967609728, 81.313790602034714539, + 19.934540474339883076, 86.737033822668308858, 77.053317673588026082, 106.95541619569121394, + 84.882812768963049166, 67.432508196539856726, 31.336119716597750084, 26.836151322670048103, + 35.203860078490833985, 42.533078727799875196, 114.58293191418124479, 40.093986243206018116, + 49.091856518112763297, 100.39616590597506729, 13.899533124240406323, 54.388636799336381955, + 105.20736872811539797, 27.283673733909381554, 58.727632062127668178, 110.66697262095840415, + 26.287986083581927232, 118.63292128570537898, 72.485444940582965501, 83.904995893353770953, + 8.5523126091502490453, 0.26731491067039314657, 106.43272386136231944, 33.071999292722466635, + 74.709693296626937808, 61.723132433573482558, 106.61327349934435915, 83.459280647803097963, + 45.763377698411204619, 83.636778782198234694, 88.453797641454002587, 3.0632713324739597738, + 88.640714282748376718, 95.496077992640493903, 99.405968740025855368, 89.451005457241990371, + 113.03872754816984525, 119.53793601009601844, 40.84652189632106456, 89.601161070695525268, + 81.366182645942899399, 113.90351656461280072, 106.64805184365832247, 125.59665123095692252, + 127.49605133274963009, 92.442935411851067329, 84.912745773050119169, 61.867082992055657087, + 4.8935098957445006818, 100.42403444607043639, 22.643306583573576063, 95.036753123902599327, + 83.699349714228446828, 41.338717819351586513, 25.045783049052261049, 18.676453308402415132, + 57.2850988074169436, 8.8553845225796976592, 66.858448917919304222, 105.59661583619526937, + 55.401910423253866611, 28.584972280274087097, 88.381780140513001243, 80.414581767057825346, + 33.779166486277972581, 80.548212235342361964, 29.496911616919533117, 51.50258242828931543, + 19.996117929837055271, 79.162858264771784889, 45.222115719610883389, 93.041611004693550058, + 111.62174321461134241, 88.600777114701486425, 20.501321735591773177, 75.308853100657870527, + 34.053535367569566006, 17.040345421304664342, 79.597116425709828036, 40.982533372043690179, + 11.67821493557858048, 47.914784562712156912, 55.667170178003289038, 42.277593056543992134, + 16.258233450709667522, 81.047275174223614158, 99.538400584191549569, 31.411089591674681287, + 40.236116969743306981, 21.989416294010879938, 60.985610657760844333, 55.052895472505042562, + 97.308128857312112814, 73.391525776089110877, 76.16446188093686942, 87.90798978904786054, + 36.94487876133644022, 61.92948729483759962, 78.68460706772384583, 111.4966446364451258, + 89.423413232634629821, 101.93314439875757671, 93.155729377896932419, 50.575479817813175032, + 35.225140792350430274, 16.311071711625118041, 102.21934522496667341, 124.39627260666020447, + 105.9759143000082986, 9.0364521542578586377, 126.4348312406000332, 127.21378874413130688, + 7.4622808006461127661, 79.614781428419519216, 54.870470503534306772, 115.3259432745144295, + 26.839017017580772517, 32.014526758965075715, 116.98555523192044348, 14.234804626834375085, + 74.342980542165605584, 0, 114.4458108730323147, 39.343047452359314775, + 56.107121628509048605, 113.05567979655825184, 49.835683696597698145, 27.446394183705706382, + 27.647461686832684791, 58.509588511482434114, 112.93495020486807334, 39.245735300228261622, + 37.841439283729414456, 113.7523623402157682, 32.612440771597903222, 53.201649295227980474, + 63.091735024110676022, 71.992767332005314529, 44.751945106439961819, 11.351721592112880899, + 38.81191855514771305, 38.864213525688683148, 79.187333508059964515, 123.67380895444148337, + 118.4767830332457379, 20.643472373212716775, 125.53510158701101318, 86.012455402982595842, + 109.45895540516721667, 2.4211554803514445666, 113.78394600447427365, 48.524804612141451798, + 41.253181523639796069, 118.12529544760400313, 8.1882425971125485376, 115.65932279137632577, + 120.06856399599928409, 103.05321070263744332, 4.5830333759586210363, 104.72414841825229814, + 94.537638556685124058, 79.662105664912814973, 123.94383630670563434, 94.310916095440916251, + 120.4048594193009194, 121.48392468143356382, 26.896381351805757731, 127.070694433466997, + 72.835767606953595532, 75.297131465151323937, 48.647169637984916335, 66.768268662777700229, + 11.625023413376766257, 24.710076237817702349, 77.500749215112591628, 43.287025171641289489, + 42.437202315355534665, 4.160142754037224222, 84.918538971691305051, 120.48589084680861561, + 92.885298418164893519, 3.4037006427679443732, 83.896752490607468644, 45.383625368485809304, + 62.000825279330456397, 115.52538754973647883, 80.949997588242695201, 71.983106166004290571, + 86.924382283588784048, 73.511712742751115002, 119.51799335566101945, 117.86520203526015393, + 118.69197414729569573, 8.7059651338640833274, 106.77761211017786991, 22.886852949362946674, + 10.093795114134991309, 77.435552645543793915, 23.191547483354952419, 8.2098531331794220023, + 97.358975543760607252, 82.57111893692126614, 70.927033602598385187, 78.380533466122869868, + 86.575111289683263749, 25.991660240812052507, 81.766085668517916929, 56.64710682534132502, + 46.870228550298634218, 111.98919489312538644, 62.035921950511692557, 54.850751081517955754, + 17.672734199353726581, 72.314820434221473988, 9.3834973653720226139, 92.535570435036788695, + 46.005287627172947396, 82.290103286384692183, 101.93759755067367223, 110.80641110196302179, + 112.11812737513173488, 76.640184301901172148, 73.621961644272232661, 18.93439201865112409, + 37.06625755672212108, 109.29566410597908543, 121.5775667821035313, 16.65408515357557917, + 114.84921510582717019, 103.5386508795163536, 122.29605795499810483, 110.16191253595388844, + 91.06415931836454547, 63.433306131999415811, 101.13760492660367163, 50.365443711543775862, + 97.237175264905090444, 52.897763993609260069, 24.002045077275397489, 4.7092115155028295703, + 84.554776126584329177, 53.685205429294001078, 18.263541740594519069, 38.580306444713642122, + 10.165927782967628445, 60.806160090764024062, 122.70388562595690018, 109.81332135386037407, + 19.040323535795323551, 25.053775197662616847, 18.256159447799291229, 84.44260301167742, + 56.129416301530000055, 43.334355500552192098, 19.656283314714528387, 59.298209108757873764, + 115.05851498699121294, 9.7784782884773449041, 102.39921001470793271, 106.88501798210927518, + 10.05574940622318536, 18.312955722387414426, 121.57809450203058077, 30.643007659320574021, + 64.785274218575068517, 79.910147015209076926, 100.1891928933437157, 29.224892404130514478, + 60.964399783842964098, 32.675237089861184359, 46.288088636712927837, 17.05295568587462185, + 0.84606931873349822126, 100.0551379970893322, 45.168302437999955146, 57.538204029217013158, + 0.61856489969795802608, 39.8549146010846016, 109.83218414139992092, 104.59143389835662674, + 118.07112360683458974, 14.579844044383207802, 119.42762095920625143, 77.759485034777753754, + 50.917359376297099516, 15.858400713885203004, 21.799205214680114295, 67.567657516741746804, + 7.6934989640903950203, 107.44399181466724258, 105.73916180785818142, 20.572927967379655456, + 59.798389312240033178, 89.289758734270435525, 126.33521789883525344, 93.976972583139286144, + 118.09687201898123021, 65.481629925412562443, 122.6981482492374198, 57.9742882099126291, + 59.946853999066661345, 47.852319260866352124, 2.0119856034725671634, 77.602709999526268803, + 54.679986621675197966, 80.576800317718152655, 41.099988302103156457, 40.395746574227814563, + 65.905784230453718919, 109.85895610278748791, 61.722835818727617152, 108.43028109894294175, + 87.869881940870982362, 118.69211731354880612, 126.48316813039855333, 45.944118595110921888, + 14.959846215569996275, 26.505735386628657579, 99.09363307372041163, 77.858486411827470874, + 61.625969834956777049, 54.791237438304960961, 85.468820250920543913, 4.3426315889591933228, + 47.81264429561997531, 104.22915426022154861, 61.582169240071380045, 125.81198690457313205, + 55.078056161022686865, 29.723620072381891077, 4.0075785788176290225, 127.53120465533720562, + 6.4254789806473127101, 43.667804166583664482, 89.71567962241533678, 121.33489913226731005, + 47.031947992862114916, 75.444539564065053128, 115.52462424931945861, 125.42479908481254824, + 28.552745110275282059, 105.11615796580008464, 49.258519926268490963, 23.054769914615462767, + 37.197001137170445872, 117.28004814983069082, 123.43992814489683951, 41.181728583320364123, + 38.774722372851101682, 35.323359044235985493, 11.446117862124083331, 114.46875290638490696, + 1.1064697874680859968, 105.28205732553033158, 82.912019241051893914, 75.851834341530775419, + 56.232230641635396751, 46.025560941932781134, 4.0455717543372884393, 2.4961132985481526703, + 15.760865578682569321, 80.397334076878905762, 87.932948182184190955, 52.537048277215944836, + 51.843615169938857434, 34.627581204069429077, 39.869080948683404131, 45.474067645340255694, + 26.106635347179690143, 85.910832391386065865, 41.765625537929736311, 6.8650163930797134526, + 62.672239433195500169, 53.672302645340096205, 70.407720156981667969, 85.066157455603388371, + 101.16586382836248958, 80.187972486412036233, 98.183713036229164572, 72.792331811950134579, + 27.799066248480812646, 108.77727359867640189, 82.414737456230795942, 54.567347467818763107, + 117.45526412425897433, 93.3339452419168083, 52.575972167167492444, 109.26584257141439593, + 16.97088988116956898, 39.809991786707541905, 17.104625218300498091, 0.53462982134442427196, + 84.865447722724638879, 66.143998585448571248, 21.419386593253875617, 123.4462648671506031, + 85.226546998692356283, 38.918561295606195927, 91.526755396826047217, 39.273557564400107367, + 48.907595282908005174, 6.1265426649515575264, 49.281428565500391414, 62.992155985284625785, + 70.811937480055348715, 50.90201091448761872, 98.077455096343328478, 111.07587202019203687, + 81.693043792645767098, 51.202322141394688515, 34.732365291889436776, 99.807033129229239421, + 85.296103687320282916, 123.19330246191748301, 126.99210266550289816, 56.885870823705772636, + 41.825491546100238338, 123.73416598411131417, 9.7870197914926393423, 72.848068892140872777, + 45.286613167150790105, 62.073506247808836633, 39.398699428456893656, 82.677435638703173026, + 50.091566098104522098, 37.352906616804830264, 114.5701976148338872, 17.710769045163033297, + 5.7168978358422464225, 83.193231672390538733, 110.80382084650773322, 57.169944560551812174, + 48.763560281029640464, 32.829163534115650691, 67.558332972559583141, 33.096424470684723929, + 58.993823233839066233, 103.00516485657863086, 39.992235859677748522, 30.325716529543569777, + 90.444231439225404756, 58.083222009390738094, 95.243486429226322798, 49.201554229402972851, + 41.002643471187184332, 22.617706201315741055, 68.107070735139132012, 34.080690842612966662, + 31.194232851419656072, 81.965066744087380357, 23.35642987115716096, 95.829569125424313825, + 111.33434035600657808, 84.555186113087984268, 32.516466901422973024, 34.094550348450866295, + 71.076801168383099139, 62.822179183349362575, 80.472233939486613963, 43.978832588021759875, + 121.97122131552168867, 110.1057909450137231, 66.616257714627863606, 18.783051552181859734, + 24.328923761877376819, 47.815979578095721081, 73.889757522672880441, 123.85897458967883722, + 29.369214135451329639, 94.993289272893889574, 50.846826465272897622, 75.866288797518791398, + 58.311458755793864839, 101.15095963562635006, 70.450281584700860549, 32.622143423253874062, + 76.438690449936984805, 120.79254521332404693, 83.951828600016597193, 18.072904308519355254, + 124.86966248120370437, 126.42757748826261377, 14.924561601295863511, 31.229562856839038432, + 109.74094100707225152, 102.65188654902885901, 53.678034035161545034, 64.029053517933789408, + 105.97111046384088695, 28.469609253672388149, 20.685961084334849147, 0, + 100.89162174606462941, 78.68609490471862955, 112.21424325702173519, 98.111359593116503675, + 99.671367393195396289, 54.892788367411412764, 55.294923373665369581, 117.01917702296850621, + 97.869900409736146685, 78.491470600456523243, 75.68287856746246689, 99.504724680431536399, + 65.224881543195806444, 106.40329859045596095, 126.18347004822499002, 15.985534664010629058, + 89.503890212879923638, 22.703443184225761797, 77.6238371102954261, 77.728427051381004276, + 30.374667016123567009, 119.34761790888660471, 108.95356606649147579, 41.286944746429071529, + 123.07020317402566434, 44.024910805968829663, 90.917910810334433336, 4.8423109607065271121, + 99.5678920089485473, 97.049609224282903597, 82.506363047283230117, 108.25059089520800626, + 16.376485194228735054, 103.31864558275628951, 112.13712799200220616, 78.106421405274886638, + 9.1660667519208800513, 81.448296836508234264, 61.075277113373886095, 31.324211329829267925, + 119.88767261341490666, 60.621832190885470482, 112.80971883860547678, 114.96784936286712764, + 53.792762703615153441, 126.14138886693763197, 17.671535213910829043, 22.594262930302647874, + 97.294339275973470649, 5.5365373255554004572, 23.250046826753532514, 49.420152475639042677, + 27.001498430225183256, 86.574050343282578979, 84.874404630711069331, 8.3202855080780864228, + 41.83707794338624808, 112.97178169362086919, 57.770596836329787038, 6.8074012855395267252, + 39.793504981214937288, 90.767250736971618608, 124.00165055866455077, 103.05077509947659564, + 33.899995176489028381, 15.966212332012219122, 45.848764567181206075, 19.023425485505867982, + 111.03598671132567688, 107.73040407052394585, 109.38394829459139146, 17.411930267731804634, + 85.555224220355739817, 45.773705898725893348, 20.187590228273620596, 26.87110529108758783, + 46.383094966709904838, 16.419706266362481983, 66.717951087524852483, 37.14223787384617026, + 13.854067205200408353, 28.761066932249377714, 45.150222579366527498, 51.983320481627742993, + 35.532171337035833858, 113.29421365068265004, 93.740457100600906415, 95.978389786250772886, + 124.07184390102338511, 109.70150216303591151, 35.34546839871109114, 16.629640868442947976, + 18.766994730747683207, 57.071140870073577389, 92.01057525434953277, 36.580206572773022344, + 75.875195101350982441, 93.612822203929681564, 96.236254750267107738, 25.280368603805982275, + 19.243923288544465322, 37.86878403730224818, 74.13251511344788014, 90.591328211961808847, + 115.15513356420706259, 33.308170307154796319, 101.69843021165797836, 79.077301759036345175, + 116.59211590999984764, 92.323825071911414852, 54.12831863672909094, 126.8666122640024696, + 74.275209853207343258, 100.7308874230911897, 66.474350529810180888, 105.79552798721852014, + 48.004090154550794978, 9.4184230310092971195, 41.109552253168658353, 107.37041085858800216, + 36.527083481189038139, 77.160612889427284244, 20.331855565935256891, 121.6123201815316861, + 117.40777125191743835, 91.626642707720748149, 38.080647071590647101, 50.107550395325233694, + 36.512318895602220437, 40.885206023354839999, 112.25883260306000011, 86.668711001104384195, + 39.312566629429056775, 118.59641821751938551, 102.11702997398242587, 19.556956576958327787, + 76.798420029419503408, 85.770035964218550362, 20.111498812446370721, 36.62591144477846683, + 115.15618900406116154, 61.286015318644786021, 1.5705484371537750121, 31.820294030421791831, + 72.378385786687431391, 58.449784808261028957, 121.9287995676859282, 65.350474179722368717, + 92.576177273425855674, 34.105911371749243699, 1.6921386374706344213, 72.110275994178664405, + 90.336604875999910291, 115.07640805843402632, 1.2371297993959160522, 79.709829202172841178, + 91.664368282803479815, 81.182867796716891462, 108.14224721366917947, 29.159688088770053582, + 110.85524191841614083, 27.518970069555507507, 101.83471875259419903, 31.716801427770406008, + 43.598410429363866569, 7.1353150334834936075, 15.386997928184428019, 86.887983629338123137, + 83.478323615716362838, 41.145855934759310912, 119.59677862448370433, 50.579517468544509029, + 124.67043579767414485, 59.953945166282210266, 108.1937440379660984, 2.9632598508287628647, + 117.39629649847483961, 115.9485764198252582, 119.89370799813332269, 95.704638521732704248, + 4.0239712069487723056, 27.205419999052537605, 109.35997324335403391, 33.153600635436305311, + 82.199976604206312913, 80.791493148459267104, 3.8115684609110758174, 91.717912205574975815, + 123.44567163745887228, 88.860562197889521485, 47.739763881745602703, 109.38423462710125023, + 124.96633626079710666, 91.888237190221843775, 29.91969243113999255, 53.011470773260953138, + 70.18726614744446124, 27.716972823654941749, 123.2519396699135541, 109.5824748766135599, + 42.937640501841087826, 8.6852631779183866456, 95.625288591243588598, 80.458308520443097223, + 123.16433848014639807, 123.6239738091462641, 110.15611232204537373, 59.447240144763782155, + 8.0151571576388960239, 127.06240931067441124, 12.85095796129462542, 87.335608333170966944, + 51.431359244834311539, 114.6697982645346201, 94.06389598572786781, 22.889079128133744234, + 103.04924849864255521, 122.84959816962509649, 57.105490220554202097, 82.232315931600169279, + 98.517039852536981925, 46.109539829230925534, 74.394002274344529724, 106.56009629966501961, + 118.87985628979367903, 82.363457166640728246, 77.549444745702203363, 70.646718088471970987, + 22.892235724251804641, 100.93750581276981393, 2.2129395749398099724, 82.564114651064301142, + 37.824038482107425807, 23.703668683061550837, 112.4644612832707935, 92.051121883865562268, + 8.0911435086745768785, 4.9922265970963053405, 31.521731157368776621, 32.794668153761449503, + 47.86589636436838191, 105.07409655443188967, 103.68723033987771487, 69.255162408138858154, + 79.738161897366808262, 90.948135290680511389, 52.213270694363018265, 43.82166478277213173, + 83.531251075859472621, 13.730032786159426905, 125.34447886639100034, 107.34460529068383039, + 12.815440313966973918, 42.132314911210414721, 74.331727656728617148, 32.375944972827710444, + 68.367426072461967124, 17.584663623900269158, 55.598132496965263272, 89.554547197356441757, + 36.829474912461591884, 109.13469493564116419, 106.91052824852158665, 58.667890483833616599, + 105.15194433433862287, 90.531685142828791868, 33.94177976233913796, 79.619983573415083811, + 34.209250436600996181, 1.0692596426924865227, 41.730895445452915737, 4.287997170897142496, + 42.838773186511389213, 118.89252973430484417, 42.453093997384712566, 77.837122591216029832, + 55.053510793652094435, 78.547115128800214734, 97.815190565816010348, 12.253085329903115053, + 98.562857131000782829, 125.98431197057288955, 13.62387496011069743, 101.80402182897887542, + 68.154910192690294934, 94.151744040387711721, 35.386087585291534197, 102.40464428278937703, + 69.46473058378251153, 71.614066258462116821, 42.59220737464420381, 118.38660492383860401, + 125.98420533100579632, 113.77174164741154527, 83.650983092204114655, 119.46833196822262835, + 19.574039582988916663, 17.696137784281745553, 90.573226334301580209, 124.14701249561767327, + 78.797398856917425292, 37.354871277406346053, 100.1831321962090442, 74.705813233613298507, + 101.1403952296677744, 35.421538090326066595, 11.433795671688130824, 38.386463344784715446, + 93.607641693015466444, 114.33988912110362435, 97.527120562059280928, 65.658327068234939361, + 7.1166659451191662811, 66.192848941369447857, 117.98764646768177045, 78.010329713157261722, + 79.984471719355497044, 60.651433059090777533, 52.888462878450809512, 116.16644401878511417, + 62.486972858452645596, 98.403108458805945702, 82.005286942374368664, 45.235412402635120088, + 8.2141414702782640234, 68.161381685225933325, 62.388465702842950122, 35.930133488174760714, + 46.712859742317959899, 63.659138250852265628, 94.668680712016794132, 41.110372226175968535, + 65.032933802845946047, 68.189100696905370569, 14.153602336766198277, 125.64435836670236313, + 32.944467878973227926, 87.957665176047157729, 115.94244263104701531, 92.211581890031084185, + 5.2325154292557272129, 37.566103104363719467, 48.657847523754753638, 95.631959156195080141, + 19.779515045349398861, 119.71794917935767444, 58.738428270906297257, 61.986578545787779149, + 101.69365293054943322, 23.732577595037582796, 116.62291751159136766, 74.301919271256338106, + 12.900563169401721098, 65.244286846511386102, 24.87738089987760759, 113.58509042665173183, + 39.903657200033194385, 36.145808617042348487, 121.73932496241104673, 124.85515497652522754, + 29.849123202591727022, 62.459125713681714842, 91.481882014148141025, 77.303773098057718016, + 107.35606807032672805, 0.058107035871216794476, 83.942220927681773901, 56.939218507344776299, + 41.371922168669698294, 0, 73.78324349213289679, 29.372189809440897079, + 96.428486514047108358, 68.222719186236645328, 71.342734786390792578, 109.78557673482282553, + 110.58984674733437714, 106.03835404594065039, 67.739800819475931348, 28.982941200916684465, + 23.365757134928571759, 71.009449360866710776, 2.4497630863952508662, 84.806597180915559875, + 124.36694009644998005, 31.971069328024896095, 51.007780425759847276, 45.406886368455161573, + 27.24767422059449018, 27.456854102762008552, 60.749334032250771997, 110.6952358177768474, + 89.907132132982951589, 82.573889492861781036, 118.14040634805132868, 88.049821611941297306, + 53.835821620668866672, 9.6846219214166922029, 71.135784017900732579, 66.099218448569445172, + 37.012726094570098212, 88.501181790416012518, 32.752970388461108087, 78.637291165516217006, + 96.274255984008050291, 28.212842810549773276, 18.332133503845398081, 34.896593673016468529, + 122.15055422674777219, 62.648422659662173828, 111.77534522682981333, 121.24366438177457894, + 97.619437677214591531, 101.93569872573425528, 107.58552540723394486, 124.28277773387526395, + 35.343070427821658086, 45.188525860608933726, 66.588678551946941298, 11.073074651110800914, + 46.500093653507065028, 98.840304951278085355, 54.002996860454004491, 45.148100686568795936, + 41.748809261422138661, 16.640571016156172846, 83.674155886776134139, 97.943563387241738383, + 115.54119367265957408, 13.61480257107905345, 79.587009962433512555, 53.534501473946875194, + 120.00330111733273952, 78.101550198953191284, 67.799990352978056762, 31.932424664024438243, + 91.697529134362412151, 38.046850971015373943, 94.071973422654991737, 87.460808141051529674, + 90.767896589182782918, 34.823860535467247246, 43.110448440711479634, 91.547411797451786697, + 40.375180456547241192, 53.742210582175175659, 92.766189933419809677, 32.839412532728601946, + 5.4359021750497049652, 74.284475747692340519, 27.708134410400816705, 57.522133864498755429, + 90.300445158733054996, 103.96664096325548599, 71.064342674075305695, 98.58842730136893806, + 59.480914201205450809, 63.956779572505183751, 120.14368780205040821, 91.403004326071823016, + 70.690936797422182281, 33.259281736885895953, 37.533989461495366413, 114.14228174015079276, + 56.02115050869906554, 73.160413145549682667, 23.75039020270560286, 59.225644407863001106, + 64.472509500534215476, 50.56073720761196455, 38.487846577088930644, 75.737568074608134339, + 20.265030226899398258, 53.182656423927255673, 102.31026712841412518, 66.616340614313230617, + 75.396860423319594702, 30.154603518076328328, 105.18423182000333327, 56.647650143822829705, + 108.25663727346181986, 125.73322452800857718, 20.550419706418324495, 73.461774846186017385, + 4.948701059623999754, 83.591055974437040277, 96.008180309101589955, 18.836846062018594239, + 82.219104506340954686, 86.740821717176004313, 73.054166962381714256, 26.321225778854568489, + 40.663711131874151761, 115.22464036306701018, 106.81554250383851468, 55.253285415441496298, + 76.161294143181294203, 100.21510079065046739, 73.024637791204440873, 81.770412046713317977, + 96.5176652061236382, 45.33742200220876839, 78.625133258861751528, 109.19283643504240899, + 76.234059947964851744, 39.113913153920293553, 25.596840058842644794, 43.540071928437100723, + 40.222997624892741442, 73.251822889560571639, 102.31237800812232308, 122.57203063728957204, + 3.1410968743075500242, 63.640588060847221641, 16.756771573374862783, 116.89956961652569589, + 115.85759913537549437, 2.7009483594483754132, 57.152354546851711348, 68.211822743498487398, + 3.3842772749449068215, 16.220551988360966789, 52.673209752003458561, 102.15281611686805263, + 2.4742595987954700831, 31.419658404349320335, 55.328736565610597609, 34.365735593437420903, + 88.284494427338358946, 58.319376177543745143, 93.710483836832281668, 55.037940139114652993, + 75.669437505188398063, 63.433602855540812016, 87.196820858727733139, 14.270630066966987215, + 30.773995856372494018, 45.775967258679884253, 38.956647231432725675, 82.291711869522259803, + 111.19355724896740867, 101.15903493709265604, 121.3408715953482897, 119.90789033256805851, + 88.387488075932196807, 5.9265197016611637082, 106.7925929969533172, 103.89715283965415438, + 111.78741599627028336, 63.409277043465408497, 8.0479424138975446112, 54.410839998108713189, + 90.719946486708067823, 66.3072012708762486, 36.399953208416263806, 33.582986296918534208, + 7.6231369218257896136, 55.435824411153589608, 118.89134327492138254, 49.72112439577904297, + 95.479527763494843384, 90.76846925420613843, 121.9326725215978513, 55.776474380443687551, + 59.8393848622799851, 106.02294154652554425, 12.374532294888922479, 55.433945647313521476, + 118.50387933983074618, 91.1649497532271198, 85.875281003682175651, 17.37052635584041127, + 63.250577182490815176, 32.916617040889832424, 118.32867696029643412, 119.24794761829616618, + 92.312224644090747461, 118.89448028952756431, 16.030314315281430027, 126.12481862134882249, + 25.701915922592888819, 46.671216666341933887, 102.86271848967226106, 101.33959652907287818, + 60.12779197145573562, 45.778158256271126447, 78.098496997288748389, 117.69919633925019298, + 114.21098044111204217, 36.464631863203976536, 69.034079705073963851, 92.219079658465489047, + 20.788004548692697426, 85.120192599333677208, 109.75971257959099603, 36.726914333285094472, + 27.098889491408044705, 13.293436176943941973, 45.78447144850724726, 73.875011625539627858, + 4.4258791498832579236, 37.128229302128602285, 75.648076964214851614, 47.407337366126739653, + 96.928922566545224981, 56.102243767731124535, 16.182287017349153757, 9.9844531941926106811, + 63.043462314737553243, 65.589336307522899006, 95.731792728740401799, 82.148193108867417322, + 79.374460679759067716, 10.510324816281354288, 31.476323794737254502, 53.896270581361022778, + 104.42654138872603653, 87.643329565547901439, 39.062502151718945242, 27.460065572322491789, + 122.68895773278563865, 86.68921058136766078, 25.630880627933947835, 84.26462982242446742, + 20.663455313457234297, 64.751889945659058867, 8.7348521449239342473, 35.169327247800538316, + 111.19626499393416452, 51.109094394712883513, 73.658949824926821748, 90.269389871285966365, + 85.821056497043173295, 117.33578096767087118, 82.303888668680883711, 53.063370285657583736, + 67.883559524681913899, 31.239967146830167621, 68.418500873201992363, 2.1385192853849730454, + 83.461790890905831475, 8.5759943417942849919, 85.677546373026416404, 109.78505946860968834, + 84.90618799477306311, 27.674245182432059664, 110.10702158730782685, 29.094230257604067447, + 67.630381131632020697, 24.506170659809868084, 69.125714262005203636, 123.9686239411457791, + 27.247749920225032838, 75.608043657961388817, 8.3098203853842278477, 60.303488080775423441, + 70.772175170586706372, 76.809288565582392039, 10.92946116756866104, 15.228132516924233641, + 85.184414749292045599, 108.773209847680846, 123.96841066201523063, 99.543483294826728525, + 39.301966184411867289, 110.9366639364452567, 39.148079165977833327, 35.392275568567129085, + 53.146452668606798397, 120.29402499123898451, 29.594797713834850583, 74.709742554816330085, + 72.36626439242172637, 21.411626467230234994, 74.280790459335548803, 70.843076180652133189, + 22.867591343376261648, 76.77292668957306887, 59.215283386034570867, 100.67977824221088667, + 67.054241124122199835, 3.316654136469878722, 14.233331890241970541, 4.3856978827425336931, + 107.97529293536717887, 28.020659426318161422, 31.968943438710994087, 121.30286611818155507, + 105.776925756905257, 104.33288803757022833, 124.97394571690892917, 68.806216917615529383, + 36.010573884748737328, 90.470824805270240176, 16.428282940560166026, 8.3227633704518666491, + 124.77693140568590024, 71.860266976349521428, 93.425719484635919798, 127.31827650170816923, + 61.337361424033588264, 82.220744452355575049, 2.0658676056955300737, 8.3782013938107411377, + 28.307204673536034534, 123.28871673340472626, 65.88893575795009383, 47.915330352097953437, + 103.8848852620976686, 56.423163780062168371, 10.465030858511454426, 75.132206208727438934, + 97.315695047513145255, 63.263918312390160281, 39.5590300907024357, 111.43589835871534888, + 117.47685654181259451, 123.97315709157919628, 75.387305861098866444, 47.465155190078803571, + 105.24583502318637329, 20.603838542512676213, 25.801126338807080174, 2.4885736930227722041, + 49.754761799758853158, 99.170180853303463664, 79.807314400066388771, 72.291617234088334953, + 115.47864992482573143, 121.71030995305045508, 59.698246405183454044, 124.91825142736706766, + 54.963764028299920028, 26.607546196119074011, 86.712136140653456096, 0.11621407174607156776, + 39.884441855363547802, 113.8784370146895526, 82.743844337343034567, 0, + 19.566486984265793581, 58.744379618885432137, 64.856973028097854694, 8.4454383724769286346, + 14.685469572785223136, 91.571153469649289036, 93.179693494672392262, 84.076708091884938767, + 7.4796016389518626966, 57.965882401833368931, 46.731514269860781496, 14.018898721733421553, + 4.8995261727941397112, 41.613194361834757729, 120.73388019289996009, 63.942138656049792189, + 102.01556085151969455, 90.813772736910323147, 54.49534844118898036, 54.913708205524017103, + 121.49866806450518197, 93.390471635557332775, 51.814264265969541157, 37.147778985727200052, + 108.28081269610629533, 48.099643223882594611, 107.67164324133773334, 19.369243842837022385, + 14.271568035805103136, 4.1984368971388903446, 74.025452189143834403, 49.002363580832025036, + 65.505940776925854152, 29.274582331036071992, 64.548511968016100582, 56.425685621099546552, + 36.664267007690796163, 69.793187346036575036, 116.30110845349554438, 125.29684531932798564, + 95.550690453663264634, 114.48732876355279586, 67.238875354432821041, 75.871397451472148532, + 87.171050814471527701, 120.5655554677505279, 70.686140855643316172, 90.377051721221505431, + 5.177357103893882595, 22.146149302221601829, 93.000187307017768035, 69.680609902556170709, + 108.00599372090800898, 90.296201373137591872, 83.497618522844277322, 33.28114203231598367, + 39.348311773555906257, 67.887126774487114744, 103.08238734531914815, 27.22960514216174488, + 31.174019924867025111, 107.06900294789738837, 112.00660223466911702, 28.203100397910020547, + 7.5999807059561135247, 63.864849328052514466, 55.395058268724824302, 76.093701942034385866, + 60.143946845313621452, 46.921616282106697327, 53.535793178365565836, 69.647721070934494492, + 86.220896881426597247, 55.094823594903573394, 80.750360913094482385, 107.4844211643539893, + 57.532379866839619353, 65.678825065457203891, 10.871804350103047909, 20.568951495384681039, + 55.41626882080163341, 115.04426772900114884, 52.60089031746974797, 79.93328192651460995, + 14.128685348154249368, 69.176854602737876121, 118.96182840241090162, 127.91355914501400548, + 112.2873756041044544, 54.80600865214728401, 13.381873594844364561, 66.518563473771791905, + 75.067978922994370805, 100.28456348030158551, 112.04230101740176906, 18.320826291099365335, + 47.50078040541120572, 118.45128881572964019, 0.94501900106843095273, 101.1214744152239291, + 76.975693154181499267, 23.475136149216268677, 40.530060453798796516, 106.36531284785814933, + 76.620534256831888342, 5.2326812286300992128, 22.793720846639189404, 60.309207036156294635, + 82.368463640006666537, 113.29530028764929739, 88.513274546927277697, 123.46644905601715436, + 41.100839412840286968, 18.92354969237203477, 9.8974021192516374867, 39.182111948877718532, + 64.016360618203179911, 37.673692124040826457, 36.43820901268554735, 45.481643434355646605, + 18.108333924763428513, 52.642451557709136978, 81.3274222637519415, 102.44928072613765835, + 85.631085007677029353, 110.50657083088663057, 24.322588286366226384, 72.430201581304572755, + 18.049275582412519725, 35.540824093430273933, 65.035330412247276399, 90.674844004421174759, + 29.250266517727141036, 90.385672870088455966, 24.468119895929703489, 78.227826307840587106, + 51.193680117685289588, 87.080143856874201447, 80.445995249789120862, 18.503645779124781257, + 76.624756016248284141, 117.14406127457914408, 6.2821937486151000485, 127.28117612169444328, + 33.513543146753363544, 105.79913923305502976, 103.71519827075098874, 5.4018967188967508264, + 114.30470909370706067, 8.4236454869969747961, 6.7685545498898136429, 32.441103976721933577, + 105.3464195040105551, 76.305632233736105263, 4.9485191975909401663, 62.839316808698640671, + 110.65747313122119522, 68.731471186878479784, 48.568988854676717892, 116.63875235509112827, + 59.420967673664563335, 110.07588027823294397, 23.338875010376796126, 126.86720571108526201, + 46.393641717455466278, 28.54126013393397443, 61.547991712744988035, 91.551934517359768506, + 77.91329446286908933, 36.583423739048157586, 94.387114497938455315, 74.318069874188950052, + 114.68174319070021738, 111.815780665139755, 48.774976151864393614, 11.853039403325965395, + 85.585185993910272373, 79.794305679311946733, 95.574831992540566716, 126.81855408693081699, + 16.095884827795089222, 108.82167999622106436, 53.439892973419773625, 4.6144025417524971999, + 72.799906416832527611, 67.165972593837068416, 15.246273843651579227, 110.8716488223108172, + 109.78268654984276509, 99.44224879156172392, 62.959055526993324747, 53.536938508415914839, + 115.8653450431957026, 111.5529487608873751, 119.67876972456360818, 84.045883093051088508, + 24.749064589777844958, 110.86789129463068093, 109.00775867966513033, 54.329899506457877578, + 43.750562007364351302, 34.74105271168082254, 126.50115436498163035, 65.833234081783302827, + 108.65735392059650621, 110.49589523659597035, 56.6244492881851329, 109.78896057905512862, + 32.060628630566498032, 124.24963724269764498, 51.403831845185777638, 93.342433332687505754, + 77.725436979348160094, 74.679193058145756368, 120.25558394291147124, 91.556316512545890873, + 28.196993994581134757, 107.39839267850402393, 100.42196088222408434, 72.929263726411591051, + 10.06815941015156568, 56.438159316930978093, 41.576009097389032831, 42.240385198670992395, + 91.519425159181992058, 73.453828666570188943, 54.19777898281608941, 26.586872353887883946, + 91.568942897018132498, 19.750023251079255715, 8.8517582997665158473, 74.256458604260842549, + 23.296153928429703228, 94.814674732257117284, 65.857845133090449963, 112.20448753546224907, + 32.364574034698307514, 19.968906388385221362, 126.08692462947874446, 3.1786726150494359899, + 63.463585457484441577, 36.296386217738472624, 30.748921359518135432, 21.020649632562708575, + 62.952647589474509005, 107.79254116272568353, 80.853082777455711039, 47.286659131095802877, + 78.125004303437890485, 54.920131144648621557, 117.37791546557491529, 45.378421162735321559, + 51.261761255871533649, 40.52925964484893484, 41.326910626918106573, 1.503779891318117734, + 17.469704289847868495, 70.338654495604714612, 94.392529987868329044, 102.21818878942940501, + 19.317899649857281474, 52.538779742575570708, 43.642112994089984568, 106.67156193534538033, + 36.607777337361767422, 106.12674057131880545, 7.7671190493638277985, 62.479934293663973222, + 8.8370017464039847255, 4.2770385707735840697, 38.92358178181166295, 17.151988683592207963, + 43.355092746056470787, 91.570118937223014655, 41.81237598954612622, 55.348490364867757307, + 92.214043174615653697, 58.188460515211772872, 7.260762263264041394, 49.012341319623374147, + 10.251428524014045252, 119.9372478822915582, 54.495499840453703655, 23.216087315922777634, + 16.619640770768455695, 120.60697616155448486, 13.544350341177050723, 25.618577131164784078, + 21.858922335137322079, 30.456265033852105262, 42.368829498587729177, 89.546419695365329972, + 119.93682132403409923, 71.086966589653457049, 78.603932368827372557, 93.87332787289051339, + 78.296158331955666654, 70.78455113713425817, 106.29290533721723477, 112.58804998247796902, + 59.189595427673339145, 21.419485109636298148, 16.73252878484345274, 42.823252934464107966, + 20.561580918674735585, 13.686152361304266378, 45.735182686756161274, 25.54585337914613774, + 118.43056677207277971, 73.359556484425411327, 6.1084822482443996705, 6.633308272939757444, + 28.466663780483941082, 8.771395765488705365, 87.950585870734357741, 56.041318852636322845, + 63.937886877425626153, 114.60573223636674811, 83.553851513814151986, 80.665776075144094648, + 121.94789143382149632, 9.6124338352310587652, 72.021147769501112634, 52.941649610540480353, + 32.856565881120332051, 16.645526740907371277, 121.55386281137543847, 15.720533952702680836, + 58.851438969275477575, 126.63655300341633847, 122.67472284807081451, 36.441488904711150099, + 4.1317352113910601474, 16.756402787621482275, 56.614409347075707046, 118.57743346681309049, + 3.77787151590018766, 95.830660704199544853, 79.769770524195337202, 112.84632756012433674, + 20.93006171702654683, 22.264412417458515847, 66.63139009502629051, 126.52783662478032056, + 79.118060181408509379, 94.871796717434335733, 106.95371308362882701, 119.94631418316203053, + 22.774611722197732888, 94.930310380161245121, 82.491670046372746583, 41.207677085025352426, + 51.602252677614160348, 4.9771473860455444083, 99.509523599521344295, 70.340361706610565307, + 31.614628800136415521, 16.583234468180307886, 102.95729984965510084, 115.42061990610091016, + 119.39649281037054607, 121.83650285473413533, 109.92752805659984006, 53.215092392241786001, + 45.424272281306912191, 0.23242814349214313552, 79.768883710730733583, 99.756874029382743174, + 37.487688674686069135, 0, 39.132973968531587161, 117.48875923777450225, + 1.7139460561957093887, 16.890876744953857269, 29.37093914557408425, 55.142306939302216051, + 58.359386989348422503, 40.153416183769877534, 14.959203277903725393, 115.93176480366673786, + 93.463028539721562993, 28.037797443466843106, 9.7990523455882794224, 83.226388723673153436, + 113.46776038579992019, 127.88427731210322236, 76.031121703043027082, 53.627545473820646293, + 108.99069688237796072, 109.82741641105167218, 114.99733612901400193, 58.780943271114665549, + 103.62852853193908231, 74.295557971458038082, 88.561625392212590668, 96.199286447768827202, + 87.343286482675466686, 38.738487685674044769, 28.543136071610206272, 8.3968737942814186681, + 20.050904378287668806, 98.004727161667688051, 3.0118815538517083041, 58.549164662075781962, + 1.0970239360322011635, 112.8513712421990931, 73.328534015385230305, 11.586374692076788051, + 104.60221690699472674, 122.59369063865960925, 63.101380907330167247, 100.9746575271092297, + 6.4777507088692800608, 23.742794902947935043, 46.342101628946693381, 113.13111093550469377, + 13.372281711290270323, 52.754103442443010863, 10.35471420778776519, 44.292298604446841637, + 58.000374614039174048, 11.361219805115979398, 88.011987441819655942, 52.592402746278821724, + 38.995237045688554645, 66.56228406463196734, 78.696623547115450492, 7.7742535489778674673, + 78.164774690638296306, 54.459210284323489759, 62.348039849737688201, 86.138005895798414713, + 96.013204469338234048, 56.406200795820041094, 15.199961411912227049, 127.72969865610502893, + 110.79011653745328658, 24.187403884068771731, 120.2878936906272429, 93.843232564213394653, + 107.07158635673476965, 11.295442141872626962, 44.441793762853194494, 110.18964718981078477, + 33.500721826192602748, 86.968842328707978595, 115.06475973368287669, 3.3576501309144077823, + 21.743608700206095818, 41.137902990769362077, 110.8325376416069048, 102.08853545800229767, + 105.20178063494313392, 31.866563853029219899, 28.257370696312136715, 10.353709205479390221, + 109.92365680482544121, 127.82711829003164894, 96.574751208208908793, 109.61201730429456802, + 26.763747189692367101, 5.0371269475472217891, 22.135957845992379589, 72.569126960606809007, + 96.084602034803538118, 36.64165258219873067, 95.001560810826049419, 108.90257763145928038, + 1.8900380021404998843, 74.242948830451496178, 25.951386308362998534, 46.950272298432537355, + 81.060120907601231011, 84.73062569571993663, 25.241068513663776685, 10.465362457260198426, + 45.587441693278378807, 120.61841407231622725, 36.736927280016971054, 98.590600575302232755, + 49.026549093858193373, 118.93289811203430872, 82.201678825680573937, 37.847099384744069539, + 19.794804238503274973, 78.364223897759075044, 0.032721236406359821558, 75.347384248081652913, + 72.8764180253710947, 90.963286868711293209, 36.216667849526857026, 105.28490311542191193, + 34.654844527507520979, 76.898561452278954675, 43.262170015357696684, 93.013141661773261148, + 48.645176572736090748, 16.860403162609145511, 36.09855116482503945, 71.081648186864185845, + 2.0706608244981907774, 53.349688008842349518, 58.50053303545792005, 52.771345740176911931, + 48.936239791863044957, 28.455652615681174211, 102.38736023537421715, 46.160287713752040872, + 32.891990499578241725, 37.007291558253200492, 25.24951203250020626, 106.28812254915828817, + 12.564387497233838076, 126.56235224338888656, 67.027086293510365067, 83.598278466113697505, + 79.430396541501977481, 10.803793437797139632, 100.60941818741412135, 16.847290973993949592, + 13.537109099779627286, 64.882207953447505133, 82.692839008024748182, 24.611264467472210526, + 9.8970383951818803325, 125.67863361740091932, 93.314946262446028413, 9.4629423737569595687, + 97.137977709357073763, 105.27750471018225653, 118.84193534733276465, 92.15176055646588793, + 46.677750020757230232, 125.73441142217052402, 92.787283434910932556, 57.08252026786794886, + 123.09598342549361405, 55.103869034723174991, 27.826588925738178659, 73.16684747809995315, + 60.774228995880548609, 20.636139748381538084, 101.36348638140407274, 95.631561330279510003, + 97.549952303728787228, 23.706078806655568769, 43.170371987824182725, 31.588611358627531445, + 63.149663985084771411, 125.63710817386163399, 32.191769655593816424, 89.643359992442128714, + 106.87978594683954725, 9.2288050835086323787, 17.599812833668693202, 6.3319451876741368324, + 30.492547687306796433, 93.743297644625272369, 91.565373099689168157, 70.884497583123447839, + 125.91811105398664949, 107.07387701683546766, 103.73069008639504318, 95.105897521778388182, + 111.35753944913085434, 40.091766186102177016, 49.498129179559327895, 93.735782589264999842, + 90.01551735933026066, 108.65979901291575516, 87.501124014728702605, 69.482105423365283059, + 125.00230872996689868, 3.6664681635702436324, 89.314707841196650406, 92.991790473191940691, + 113.24889857637390378, 91.577921158110257238, 64.121257261136634042, 120.49927448539528996, + 102.80766369037519326, 58.684866665378649486, 27.450873958699958166, 21.358386116295150714, + 112.51116788582658046, 55.112633025091781747, 56.393987989165907493, 86.796785357011685846, + 72.843921764451806666, 17.858527452823182102, 20.136318820303131361, 112.87631863386195619, + 83.152018194778065663, 84.480770397345622769, 55.038850318367622094, 18.907657333140377887, + 108.39555796563217882, 53.173744707779405871, 55.137885794036264997, 39.50004650215851143, + 17.703516599536669673, 20.512917208521685097, 46.592307856863044435, 61.629349464517872548, + 3.7156902661845379043, 96.408975070924498141, 64.729148069396615028, 39.937812776774080703, + 124.17384925895748893, 6.3573452300988719799, 126.92717091496888315, 72.592772435476945248, + 61.497842719036270864, 42.041299265125417151, 125.90529517895265599, 87.585082325455005048, + 33.706165554911422078, 94.573318262195243733, 28.25000860687578097, 109.84026228930088109, + 106.75583093114983058, 90.756842325470643118, 102.5235225117430673, 81.058519289697869681, + 82.653821253836213145, 3.0075597826362354681, 34.939408579699374968, 12.677308991213067202, + 60.785059975740296068, 76.436377578858810011, 38.635799299714562949, 105.07755948515114142, + 87.284225988183607114, 85.343123870690760668, 73.215554674727172824, 84.253481142637610901, + 15.534238098727655597, 124.95986858732794644, 17.674003492807969451, 8.5540771415471681394, + 77.847163563623325899, 34.303977367184415925, 86.710185492116579553, 55.140237874446029309, + 83.624751979092252441, 110.69698072973915259, 56.428086349231307395, 116.37692103042354574, + 14.521524526528082788, 98.024682639246748295, 20.502857048031728482, 111.8744957645831164, + 108.99099968090740731, 46.432174631845555268, 33.23928154154054937, 113.21395232310896972, + 27.088700682354101446, 51.237154262329568155, 43.717844670274644159, 60.912530067704210524, + 84.737658997179096332, 51.092839390734297922, 111.87364264807183645, 14.173933179310552077, + 29.207864737658383092, 59.746655745784664759, 28.592316663914971286, 13.569102274272154318, + 84.585810674438107526, 97.176099964955938049, 118.37919085534667829, 42.838970219272596296, + 33.465057569686905481, 85.646505868928215932, 41.12316183734947117, 27.372304722608532757, + 91.470365373512322549, 51.09170675829591346, 108.86113354414919741, 18.719112968850822654, + 12.216964496488799341, 13.266616545879514888, 56.933327560967882164, 17.542791530981048709, + 47.901171741468715481, 112.08263770527264569, 127.87577375485489029, 101.2114644727371342, + 39.10770302763194195, 33.331552150291827274, 115.89578286764299264, 19.224867670465755509, + 16.042295539002225269, 105.88329922108096071, 65.713131762240664102, 33.291053481818380533, + 115.10772562275087694, 31.441067905405361671, 117.70287793855459313, 125.27310600683631492, + 117.34944569614162901, 72.882977809422300197, 8.2634704227821202949, 33.512805575242964551, + 113.22881869415505207, 109.15486693362618098, 7.5557430318040132988, 63.661321408402727684, + 31.539541048394312384, 97.692655120248673484, 41.860123434053093661, 44.528824834920669673, + 5.2627801900562189985, 125.0556732495642791, 30.236120362820656737, 61.743593434872309444, + 85.907426167261291994, 111.89262836632406106, 45.549223444399103755, 61.86062076032612822, + 36.983340092745493166, 82.415354170050704852, 103.2045053552283207, 9.9542947720947267953, + 71.019047199046326568, 12.680723413221130613, 63.229257600272831041, 33.16646893636425375, + 77.914599699313839665, 102.84123981220545829, 110.79298562074473011, 115.67300570947190863, + 91.855056113199680112, 106.430184784483572, 90.848544562613824382, 0.46485628698792424984, + 31.537767421465105144, 71.513748058765486348, 74.975377349375776248, 0, + 78.265947937066812301, 106.97751847554900451, 3.4278921123914187774, 33.781753489907714538, + 58.741878291148168501, 110.2846138786044321, 116.71877397869684501, 80.306832367539755069, + 29.918406555811088765, 103.8635296073371137, 58.926057079443125986, 56.075594886933686212, + 19.598104691180196824, 38.45277744734994485, 98.935520771603478352, 127.76855462421008269, + 24.062243406086054165, 107.25509094764493057, 89.981393764759559417, 91.654832822106982348, + 101.99467225802800385, 117.56188654223296908, 79.257057063881802605, 20.591115942919714143, + 49.123250784428819316, 64.398572895541292382, 46.686572965350933373, 77.476975371348089539, + 57.086272143220412545, 16.793747588562837336, 40.10180875657897559, 68.009454323335376102, + 6.0237631077034166083, 117.09832932415156392, 2.1940478720680403057, 97.702742484401824186, + 18.657068030770460609, 23.172749384157214081, 81.204433813993091462, 117.1873812773192185, + 126.20276181466397247, 73.949315054218459409, 12.955501417738560122, 47.485589805895870086, + 92.684203257897024741, 98.262221871009387542, 26.744563422580540646, 105.50820688488602173, + 20.70942841557553038, 88.584597208893683273, 116.0007492280783481, 22.722439610235596774, + 48.023974883639311884, 105.18480549255764345, 77.990474091380747268, 5.1245681292675726581, + 29.393247094230900984, 15.548507097959372913, 28.329549381276592612, 108.91842056864697952, + 124.69607969947901438, 44.276011791600467404, 64.026408938676468097, 112.81240159164008219, + 30.399922823828092078, 127.45939731221369584, 93.580233074906573165, 48.374807768141181441, + 112.57578738125812379, 59.686465128430427285, 86.143172713469539303, 22.590884283745253924, + 88.883587525710026966, 92.379294379621569533, 67.001443652388843475, 45.937684657419595169, + 102.12951946736575337, 6.7153002618288155645, 43.487217400412191637, 82.275805981542362133, + 93.665075283217447577, 76.177070916008233326, 82.403561269886267837, 63.733127706058439799, + 56.514741392624273431, 20.70741841096241842, 91.847313609654520405, 127.65423658006693586, + 65.149502416421455564, 91.224034608589136042, 53.527494379384734202, 10.074253895094443578, + 44.271915691988397157, 17.138253921217255993, 64.169204069607076235, 73.283305164401099319, + 62.003121621655736817, 89.805155262918560766, 3.7800760042846377473, 20.485897660902992357, + 51.902772616725997068, 93.900544596868712688, 34.1202418152061, 41.46125139143987326, + 50.482137027327553369, 20.930724914520396851, 91.174883386560395593, 113.2368281446324545, + 73.473854560037580086, 69.181201150604465511, 98.053098187720024725, 109.86579622407225543, + 36.403357651361147873, 75.694198769488139078, 39.589608477010187926, 28.728447795518150087, + 0.065442472816357621923, 22.694768496166943805, 17.752836050745827379, 53.926573737422586419, + 72.433335699057352031, 82.569806230843823869, 69.309689055018679937, 25.797122904557909351, + 86.524340030719031347, 58.026283323546522297, 97.290353145472181495, 33.720806325218291022, + 72.197102329653716879, 14.163296373728371691, 4.1413216489963815548, 106.69937601768469904, + 117.0010660709158401, 105.54269148035382386, 97.872479583726089913, 56.911305231365986401, + 76.774720470748434309, 92.320575427504081745, 65.783980999156483449, 74.014583116506400984, + 50.499024065004050499, 84.576245098316576332, 25.12877499447131413, 125.12470448678141111, + 6.0541725870243681129, 39.196556932231032988, 30.860793083003954962, 21.607586875597917242, + 73.218836374828242697, 33.694581947987899184, 27.074218199562892551, 1.7644159068986482453, + 37.385678016049496364, 49.222528934944421053, 19.794076790367398644, 123.35726723480547662, + 58.629892524892056827, 18.925884747517557116, 66.275955418717785506, 82.555009420368151041, + 109.68387069466916728, 56.30352111293177586, 93.355500041518098442, 123.46882284434468602, + 57.574566869821865112, 114.1650405357395357, 118.1919668509872281, 110.20773806944634998, + 55.653177851479995297, 18.333694956199906301, 121.54845799176109722, 41.272279496766714146, + 74.726972762811783468, 63.263122660562657984, 67.099904607457574457, 47.412157613311137538, + 86.340743975648365449, 63.177222717255062889, 126.2993279701731808, 123.27421634772326797, + 64.383539311191270826, 51.286719984887895407, 85.759571893679094501, 18.457610167017264757, + 35.199625667337386403, 12.663890375348273665, 60.985095374617230846, 59.486595289254182717, + 55.130746199381974293, 13.768995166250533657, 123.83622210797693697, 86.147754033674573293, + 79.461380172793724341, 62.211795043560414342, 94.715078898261708673, 80.183532372204354033, + 98.996258359122293768, 59.471565178533637663, 52.0310347186641593, 89.319598025835148292, + 47.002248029461043188, 10.964210846734204097, 122.00461745993379736, 7.3329363271441252436, + 50.629415682396938791, 57.983580946387519361, 98.497797152751445537, 55.155842316224152455, + 0.24251452227690606378, 112.99854897079421789, 77.61532738075038651, 117.36973333075729897, + 54.901747917399916332, 42.716772232593939407, 97.022335771653160919, 110.22526605018356349, + 112.78797597833545296, 45.593570714027009672, 17.687843528903613333, 35.717054905646364205, + 40.2726376406099007, 97.752637267727550352, 38.304036389559769304, 40.961540794691245537, + 110.07770063673524419, 37.815314666284393752, 88.791115931264357641, 106.34748941555881174, + 110.27577158807252999, 79.00009300431702286, 35.407033199073339347, 41.025834417043370195, + 93.18461571372608887, 123.2586989290357451, 7.4313805323727137875, 64.81795014185263426, + 1.4582961387932300568, 79.875625553551799385, 120.34769851791497786, 12.714690460201381939, + 125.85434182994140428, 17.185544870953890495, 122.99568543807254173, 84.08259853025447228, + 123.81059035790894995, 47.170164650910010096, 67.412331109826482134, 61.146636524390487466, + 56.500017213755199919, 91.680524578605400166, 85.511661862303299131, 53.513684650944924215, + 77.047045023489772575, 34.11703857939937734, 37.307642507672426291, 6.0151195652724709362, + 69.878817159398749936, 25.354617982426134404, 121.57011995148423011, 24.872755157717620023, + 77.271598599432763876, 82.155118970305920811, 46.568451976370852208, 42.686247741385159316, + 18.431109349457983626, 40.506962285275221802, 31.068476197458949173, 121.91973717465589289, + 35.348006985615938902, 17.108154283097974258, 27.694327127246651798, 68.607954734372469829, + 45.420370984233159106, 110.2804757488956966, 39.24950395818814286, 93.393961459478305187, + 112.85617269846625277, 104.75384206084709149, 29.043049053059803555, 68.049365278493496589, + 41.005714096067094943, 95.748991529169870773, 89.98199936181481462, 92.864349263691110536, + 66.478563083084736718, 98.427904646217939444, 54.177401364708202891, 102.47430852465913631, + 87.435689340549288318, 121.82506013541205903, 41.475317994358192664, 102.18567878147223382, + 95.747285296143672895, 28.347866358621104155, 58.415729475316766184, 119.49331149156932952, + 57.184633327829942573, 27.138204548547946615, 41.171621348879853031, 66.352199929915514076, + 108.75838171069335658, 85.677940438545192592, 66.930115139377448941, 43.293011737856431864, + 82.246323674698942341, 54.744609445220703492, 54.940730747024645098, 102.1834135165954649, + 89.72226708829839481, 37.438225937701645307, 24.433928992977598682, 26.533233091759029776, + 113.86665512193576433, 35.085583061962097418, 95.802343482941068942, 96.165275410548929358, + 127.75154750971341855, 74.422928945474268403, 78.2154060552638839, 66.663104300587292528, + 103.79156573528598528, 38.449735340931511018, 32.084591078008088516, 83.766598442165559391, + 3.4262635244813282043, 66.582106963640399044, 102.21545124550175387, 62.882135810814361321, + 107.40575587711282424, 122.54621201367626782, 106.69889139228689601, 17.765955618844600394, + 16.52694084556424059, 67.025611150489567081, 98.457637388313742122, 90.309733867252361961, + 15.111486063608026598, 127.32264281680545537, 63.079082096792262746, 67.385310240497346967, + 83.720246868106187321, 89.057649669841339346, 10.525560380116075976, 122.11134649912855821, + 60.472240725641313475, 123.48718686974825687, 43.814852334526221966, 95.785256732648122124, + 91.09844688879820751, 123.72124152065225644, 73.966680185494624311, 36.830708340105047682, + 78.409010710456641391, 19.908589544193091569, 14.038094398092653137, 25.361446826442261226, + 126.45851520054566208, 66.332937872732145479, 27.829199398631317308, 77.682479624414554564, + 93.585971241493098205, 103.34601141894745524, 55.710112226402998203, 84.860369568970781984, + 53.697089125227648765, 0.92971257397584849969, 63.075534842933848267, 15.027496117534610676, + 21.950754698755190475, 0, 28.531895874137262581, 85.955036951098009013, + 6.8557842247828375548, 67.563506979815429077, 117.48375658229997498, 92.569227757212502183, + 105.43754795739732799, 32.613664735079510137, 59.836813111625815509, 79.727059214674227405, + 117.85211415888625197, 112.15118977386737242, 39.196209382360393647, 76.90555489470352768, + 69.871041543210594682, 127.53710924842016539, 48.124486812175746309, 86.51018189529349911, + 51.962787529522756813, 55.309665644217602676, 75.989344516059645684, 107.12377308446957613, + 30.514114127763605211, 41.182231885839428287, 98.24650156886127661, 0.79714579108258476481, + 93.373145930705504725, 26.953950742696179077, 114.17254428644082509, 33.587495177125674672, + 80.203617513161589159, 8.018908646670752205, 12.047526215410471195, 106.19665864830312785, + 4.3880957441397185903, 67.405484968803648371, 37.314136061540921219, 46.345498768318066141, + 34.408867627989820903, 106.37476255464207497, 124.40552362933158292, 19.898630108436918817, + 25.911002835477120243, 94.97117961179537815, 57.368406515797687462, 68.524443742018775083, + 53.489126845164719271, 83.016413769772043452, 41.418856831154698739, 49.169194417791004525, + 104.00149845615669619, 45.444879220471193548, 96.047949767282261746, 82.369610985118924873, + 27.980948182761494536, 10.249136258535145316, 58.786494188461801969, 31.097014195918745827, + 56.659098762556823203, 89.836841137297597015, 121.39215939895802876, 88.552023583204572788, + 0.052817877356574172154, 97.624803183280164376, 60.799845647659822134, 126.91879462443102966, + 59.16046614981314633, 96.749615536286000861, 97.151574762516247574, 119.37293025686449255, + 44.286345426939078607, 45.181768567494145827, 49.767175051423691912, 56.758588759246777045, + 6.0028873047776869498, 91.875369314842828317, 76.259038934731506743, 13.430600523657631129, + 86.974434800828021253, 36.551611963088362245, 59.330150566438533133, 24.35414183202010463, + 36.807122539772535674, 127.4662554121168796, 113.02948278524854686, 41.414836821928474819, + 55.69462721931267879, 127.30847316013750969, 2.2990048328465491068, 54.448069217178272083, + 107.0549887587694684, 20.148507790188887157, 88.543831383976794314, 34.276507842438149964, + 0.33840813921779044904, 18.566610328802198637, 124.00624324331511161, 51.610310525837121531, + 7.5601520085692754947, 40.971795321805984713, 103.80554523345563211, 59.801089193737425376, + 68.2404836304122, 82.922502782879746519, 100.96427405465510674, 41.861449829044431681, + 54.349766773124429164, 98.473656289268546971, 18.947709120078798151, 10.362402301212569, + 68.10619637544368743, 91.731592448144510854, 72.806715302725933725, 23.388397538976278156, + 79.179216954020375852, 57.456895591036300175, 0.13088494563271524385, 45.389536992333887611, + 35.505672101491654757, 107.85314747484881082, 16.86667139811834204, 37.139612461691285716, + 10.619378110037359875, 51.59424580911945668, 45.048680061438062694, 116.05256664709668257, + 66.580706290944362991, 67.441612650440220023, 16.394204659307433758, 28.326592747456743382, + 8.2826432979964010883, 85.398752035373036051, 106.00213214183531818, 83.085382960711285705, + 67.744959167452179827, 113.82261046273561078, 25.549440941500506597, 56.641150855011801468, + 3.5679619983166048769, 20.029166233012801968, 100.99804813001173898, 41.152490196633152664, + 50.25754998894626624, 122.24940897356282221, 12.108345174048736226, 78.393113864462065976, + 61.721586166007909924, 43.215173751199472463, 18.437672749656485394, 67.389163895975798368, + 54.148436399125785101, 3.5288318137972964905, 74.771356032098992728, 98.445057869888842106, + 39.588153580738435267, 118.71453446961095324, 117.25978504978411365, 37.851769495038752211, + 4.55191083743920899, 37.11001884073994006, 91.367741389338334557, 112.6070422258671897, + 58.711000083039834863, 118.93764568868937204, 115.1491337396473682, 100.33008107148270938, + 108.38393370197809418, 92.415476138892699964, 111.30635570295999059, 36.66738991240345058, + 115.09691598352219444, 82.544558993537066272, 21.453945525623566937, 126.52624532112895395, + 6.1998092149151489139, 94.824315226625913056, 44.681487951296730898, 126.35444543451376376, + 124.59865594034999958, 118.54843269545017392, 0.76707862238254165277, 102.57343996977942879, + 43.519143787358189002, 36.915220334034529515, 70.399251334674772806, 25.327780750696547329, + 121.97019074923446169, 118.97319057850836543, 110.26149239876394859, 27.537990332504705293, + 119.67244421595751191, 44.295508067352784565, 30.922760345587448683, 124.42359008712446666, + 61.430157796527055325, 32.367064744412346045, 69.992516718244587537, 118.94313035706727533, + 104.06206943733195658, 50.639196051670296583, 94.004496058922086377, 21.928421693472046172, + 116.00923491986759473, 14.665872654288250487, 101.25883136479387758, 115.9671618927786767, + 68.995594305502891075, 110.31168463244830491, 0.48502904455745010637, 97.997097941592073767, + 27.230654761504410999, 106.73946666151459794, 109.80349583479983266, 85.433544465191516792, + 66.044671543309959816, 92.450532100370764965, 97.575951956670905929, 91.187141428054019343, + 35.375687057807226665, 71.434109811292728409, 80.545275281223439379, 67.505274535455100704, + 76.608072779119538609, 81.923081589386129053, 92.155401273470488377, 75.630629332572425483, + 49.582231862532353261, 84.694978831121261464, 92.551543176148697967, 30.00018600863404572, + 70.814066398146678694, 82.051668834090378368, 58.369231427455815719, 118.51739785807149019, + 14.862761064749065554, 1.6359002837052685209, 2.9165922775900980923, 31.751251107107236749, + 112.69539703582995571, 25.429380920406401856, 123.70868365988280857, 34.371089741911418969, + 117.99137087614872144, 40.165197060512582539, 119.62118071581789991, 94.34032930182365817, + 6.8246622196529642679, 122.29327304878097493, 113.00003442751403782, 55.36104915721443831, + 43.023323724606598262, 107.02736930189348641, 26.09409004697954515, 68.234077158798754681, + 74.615285015344852582, 12.030239130548579851, 11.757634318797499873, 50.709235964855906786, + 115.14023990296846023, 49.745510315438878024, 26.543197198869165732, 36.310237940611841623, + 93.136903952741704416, 85.372495482770318631, 36.862218698915967252, 81.013924570550443605, + 62.136952394921536325, 115.83947434931178577, 70.696013971231877804, 34.216308566195948515, + 55.388654254496941576, 9.2159094687449396588, 90.840741968469956191, 92.560951497791393194, + 78.499007916379923699, 58.787922918960248353, 97.712345396936143516, 81.507684121694182977, + 58.086098106123245088, 8.0987305569869931787, 82.011428192137827864, 63.497983058343379525, + 51.963998723633267218, 57.728698527385859052, 4.9571261661731114145, 68.855809292435878888, + 108.35480272942004376, 76.948617049321910599, 46.871378681102214614, 115.65012027082411805, + 82.950635988720023306, 76.371357562948105624, 63.494570592287345789, 56.695732717242208309, + 116.83145895063717035, 110.98662298313865904, 114.36926665565988515, 54.27640909709589323, + 82.34324269776334404, 4.7043998598346661311, 89.516763421390351141, 43.355880877094023162, + 5.8602302787548978813, 86.586023475716501707, 36.492647349397884682, 109.48921889044140698, + 109.88146149405292817, 76.366827033194567775, 51.444534176596789621, 74.876451875403290614, + 48.867857985955197364, 53.066466183521697531, 99.733310243871528655, 70.171166123927832814, + 63.604686965885775862, 64.330550821101496695, 127.50309501943047508, 20.845857890952174785, + 28.430812110531405779, 5.3262086011782230344, 79.583131470571970567, 76.899470681863022037, + 64.169182156019815011, 39.533196884331118781, 6.8525270489662943874, 5.1642139272844360676, + 76.430902491003507748, 125.76427162163236062, 86.811511754229286453, 117.09242402735617361, + 85.397782784573792014, 35.531911237689200789, 33.053881691132119158, 6.0512223009827721398, + 68.915274776631122222, 52.619467734504723921, 30.222972127219691174, 126.64528563361091074, + 126.15816419358816347, 6.7706204809983319137, 39.440493736216012621, 50.115299339682678692, + 21.05112076023578993, 116.22269299825711641, 120.94448145128626493, 118.97437373949651374, + 87.629704669056081912, 63.570513465299882228, 54.196893777600052999, 119.44248304130815086, + 19.933360370989248622, 73.661416680213733343, 28.818021420913282782, 39.817179088386183139, + 28.076188796185306273, 50.722893652888160432, 124.91703040109496214, 4.6658757454642909579, + 55.658398797266272595, 27.364959248832747107, 59.171942482989834389, 78.692022837894910481, + 111.42022445280963439, 41.720739137941563968, 107.39417825045529753, 1.8594251479516969994, + 126.15106968586769653, 30.054992235069221351, 43.901509397514018929, 0, + 57.063791748278163141, 43.910073902196018025, 13.711568449569313088, 7.1270139596344961319, + 106.96751316460358794, 57.138455514428642346, 82.875095914794655982, 65.227329470159020275, + 119.673626223255269, 31.454118429352092789, 107.70422831777614192, 96.302379547734744847, + 78.392418764724425273, 25.811109789410693338, 11.742083086424827343, 127.07421849684033077, + 96.248973624355130596, 45.020363790586998221, 103.92557505904551363, 110.61933128843884333, + 23.978689032122929348, 86.247546168939152267, 61.028228255527210422, 82.364463771682494553, + 68.49300313772255322, 1.5942915821688075084, 58.74629186141100945, 53.907901485395996133, + 100.34508857288165018, 67.174990354254987324, 32.407235026323178317, 16.03781729334150441, + 24.09505243082458037, 84.393317296606255695, 8.7761914882830751594, 6.8109699376072967425, + 74.628272123081842437, 92.690997536636132281, 68.817735255983279785, 84.749525109287787927, + 120.81104725866316585, 39.797260216873837635, 51.822005670957878465, 61.942359223590756301, + 114.7368130315990129, 9.0488874840375501662, 106.97825369033307652, 38.032827539544086903, + 82.837713662309397478, 98.33838883558564703, 80.002996912313392386, 90.889758440946025075, + 64.095899534568161471, 36.739221970237849746, 55.961896365522989072, 20.498272517070290633, + 117.57298837692360394, 62.194028391837491654, 113.31819752511728439, 51.673682274598832009, + 114.7843187979196955, 49.104047166409145575, 0.10563575471678632312, 67.249606366560328752, + 121.59969129532328225, 125.83758924886205932, 118.32093229962993064, 65.499231072575639701, + 66.303149525036133127, 110.7458605137289851, 88.572690853878157213, 90.363537134988291655, + 99.534350102847383823, 113.51717751849355409, 12.005774609559011878, 55.750738629689294612, + 24.518077869463013485, 26.861201047318900237, 45.948869601656042505, 73.10322392617672449, + 118.66030113287706627, 48.70828366404020926, 73.614245079548709327, 126.93251082423739717, + 98.058965570497093722, 82.829673643856949639, 111.38925443862899556, 126.61694632027501939, + 4.5980096656930982135, 108.89613843436018215, 86.109977517538936809, 40.297015580381412292, + 49.087662767953588627, 68.553015684876299929, 0.67681627843558089808, 37.133220657608035253, + 120.01248648663022323, 103.22062105167424306, 15.120304017138550989, 81.943590643615607405, + 79.61109046691126423, 119.60217838747848873, 8.4809672608280379791, 37.845005565763131017, + 73.928548109310213476, 83.722899658088863362, 108.69953354625249631, 68.947312578537093941, + 37.895418240157596301, 20.724804602428775979, 8.2123927508910128381, 55.463184896292659687, + 17.61343060545186745, 46.776795077956194291, 30.358433908040751703, 114.91379118207260035, + 0.26176989126543048769, 90.779073984667775221, 71.011344202986947494, 87.706294949697621632, + 33.73334279623668408, 74.279224923382571433, 21.238756220074719749, 103.18849161823891336, + 90.097360122879763367, 104.10513329419700312, 5.1614125818923639599, 6.8832253008804400451, + 32.788409318614867516, 56.653185494913486764, 16.565286595996440155, 42.797504070749710081, + 84.004264283674274338, 38.170765921426209388, 7.4899183349079976324, 99.645220925471221562, + 51.098881883001013193, 113.28230171002360294, 7.1359239966332097538, 40.058332466029241914, + 73.996096260023477953, 82.304980393266305327, 100.51509997789617046, 116.49881794712564442, + 24.21669034810111043, 28.786227728924131952, 123.44317233201581985, 86.430347502398944926, + 36.875345499316608766, 6.7783277919515967369, 108.2968727982515702, 7.0576636275982309598, + 21.542712064201623434, 68.890115739777684212, 79.176307161480508512, 109.42906893922554445, + 106.51957009956822731, 75.703538990077504423, 9.1038216748784179799, 74.220037681483518099, + 54.735482778680307092, 97.2140844517343794, 117.4220001660833077, 109.87529137738238205, + 102.29826747929837438, 72.660162142969056731, 88.767867403959826333, 56.830952277789037907, + 94.612711405919981189, 73.334779824810539139, 102.19383196704802685, 37.089117987074132543, + 42.907891051250771852, 125.05249064225790789, 12.399618429833935807, 61.648630453251826111, + 89.362975902597099775, 124.70889086903116549, 121.19731188070363714, 109.09686539090034785, + 1.5341572447687212843, 77.146879939558857586, 87.038287574716378003, 73.830440668072697008, + 12.798502669349545613, 50.655561501396732638, 115.94038149847256136, 109.94638115702036885, + 92.522984797527897172, 55.075980665013048565, 111.34488843191502383, 88.591016134705569129, + 61.845520691178535344, 120.84718017424893333, 122.86031559305411065, 64.734129488828330068, + 11.985033436492813053, 109.88626071413818863, 80.124138874663913157, 101.27839210334423115, + 60.008992117844172753, 43.856843386947730323, 104.01846983973518945, 29.331745308580138953, + 74.517662729591393145, 103.93432378556099138, 9.9911886110094201285, 92.62336926489660982, + 0.97005808911853819154, 67.994195883184147533, 54.461309523012459977, 85.478933323032833869, + 91.606991669603303308, 42.867088930386671564, 4.0893430866235576104, 56.901064200745167909, + 67.151903913345449837, 54.374282856108038686, 70.751374115618091309, 14.868219622589094797, + 33.090550562450516736, 7.0105490709138393868, 25.216145558242715197, 35.846163178775896085, + 56.310802546944614733, 23.261258665144850966, 99.164463725068344502, 41.389957662246160908, + 57.103086352297395933, 60.000372017271729419, 13.628132796296995366, 36.103337668180756737, + 116.73846285491526942, 109.03479571614298038, 29.725522129498131108, 3.2718005674105370417, + 5.8331845551801961847, 63.502502214218111476, 97.390794071659911424, 50.858761840816441691, + 119.41736731976561714, 68.742179483826475916, 107.98274175229744287, 80.330394121028803056, + 111.2423614316394378, 60.68065860364731634, 13.649324439309566515, 116.58654609756558784, + 98.000068855028075632, 110.72209831442887662, 86.046647449216834502, 86.054738603786972817, + 52.188180093962728279, 8.4681543176011473406, 21.230570030689705163, 24.060478261097159702, + 23.515268637594999745, 101.41847192971545155, 102.28047980593692046, 99.491020630877756048, + 53.086394397738331463, 72.620475881227321224, 58.27380790548704681, 42.744990965540637262, + 73.724437397835572483, 34.027849141100887209, 124.27390478984671063, 103.67894869862720952, + 13.392027942463755608, 68.43261713239189703, 110.77730850899388315, 18.431818937493517296, + 53.681483936943550361, 57.121902995586424368, 28.998015832759847399, 117.57584583792413468, + 67.42469079387592501, 35.015368243388365954, 116.17219621224649018, 16.197461113977624336, + 36.022856384275655728, 126.99596611668675905, 103.92799744726653444, 115.4573970547717181, + 9.9142523323498608079, 9.7116185848753957544, 88.709605458843725501, 25.897234098643821198, + 93.742757362208067207, 103.30024054165187408, 37.901271977443684591, 24.742715125896211248, + 126.98914118457469158, 113.3914654344880546, 105.66291790127797867, 93.973245966280956054, + 100.73853331131977029, 108.55281819419542444, 36.68648539552668808, 9.4087997196729702409, + 51.033526842780702282, 86.711761754188046325, 11.720460557513433741, 45.172046951433003414, + 72.985294698799407342, 90.978437780886451947, 91.762922988109494327, 24.733654066389135551, + 102.88906835319721722, 21.752903750806581229, 97.735715971910394728, 106.13293236704703304, + 71.466620487746695289, 12.342332247855665628, 127.2093739317751897, 0.66110164220663136803, + 127.00619003886095015, 41.691715781904349569, 56.861624221062811557, 10.652417202360084048, + 31.166262941147579113, 25.798941363729682053, 0.3383643120396300219, 79.066393768662237562, + 13.705054097932588775, 10.328427854572510114, 24.861804982010653475, 123.52854324326835922, + 45.623023508462210884, 106.1848480547159852, 42.795565569147584029, 71.063822475378401577, + 66.107763382264238317, 12.102444601969182258, 9.8305495532622444443, 105.23893546900944784, + 60.445944254443020327, 125.29057126722545945, 124.31632838717632694, 13.541240961996663827, + 78.880987472432025243, 100.23059867936535738, 42.10224152047521784, 104.44538599651787081, + 113.88896290257616783, 109.94874747899666545, 47.259409338112163823, 127.14102693059976446, + 108.39378755520374398, 110.88496608261630172, 39.866720741982135223, 19.322833360427466687, + 57.636042841826565564, 79.634358176772366278, 56.152377592370612547, 101.44578730577995884, + 121.83406080218992429, 9.3317514909285819158, 111.31679759453254519, 54.729918497665494215, + 118.34388496598330676, 29.38404567579345894, 94.840448905619268771, 83.441478275886765914, + 86.788356500910595059, 3.7188502959070319775, 124.30213937173539307, 60.109984470138442703, + 87.803018795028037857, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }; +#endif // #ifndef __SLEEF_QREMPITAB__ diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/quad/sleefsimdqp.c b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/quad/sleefsimdqp.c new file mode 100644 index 00000000000..781b55132a2 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/src/quad/sleefsimdqp.c @@ -0,0 +1,4521 @@ +// Copyright Naoki Shibata and contributors 2010 - 2024. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// Always use -ffp-contract=off option to compile SLEEF. + +#if !defined(SLEEF_GENHEADER) +#include +#include +#include +#include +#endif + +#include "quaddef.h" +#include "misc.h" + +#ifndef SLEEF_ENABLE_CUDA +extern const double Sleef_rempitabqp[]; +#endif + +#define __SLEEFSIMDQP_C__ + +#if defined(_MSC_VER) && !defined (__clang__) +#pragma fp_contract (off) +#else +#pragma STDC FP_CONTRACT OFF +#endif + +#ifdef ENABLE_PUREC_SCALAR +#define CONFIG 1 +#include "helperpurec_scalar.h" +#ifdef DORENAME +#include "qrenamepurec_scalar.h" +#endif +#endif + +#ifdef ENABLE_PURECFMA_SCALAR +#define CONFIG 2 +#include "helperpurec_scalar.h" +#ifdef DORENAME +#include "qrenamepurecfma_scalar.h" +#endif + +#if defined(_MSC_VER) && !defined (__clang__) +#pragma optimize("", off) +#endif +#endif + +#ifdef SLEEF_ENABLE_CUDA +#define CONFIG 3 +#include "helperpurec_scalar.h" +#ifdef DORENAME +#include "qrenamecuda.h" +#endif +typedef vquad Sleef_quadx1; +#endif + +#ifdef ENABLE_SSE2 +#define CONFIG 2 +#include "helpersse2.h" +#ifdef DORENAME +#include "qrenamesse2.h" +#endif +typedef vquad Sleef_quadx2; +#endif + +#ifdef ENABLE_AVX2128 +#define CONFIG 1 +#include "helperavx2_128.h" +#ifdef DORENAME +#include "qrenameavx2128.h" +#endif +typedef vquad Sleef_quadx2; +#endif + +#ifdef ENABLE_AVX2 +#define CONFIG 1 +#include "helperavx2.h" +#ifdef DORENAME +#include "qrenameavx2.h" +#endif +typedef vquad Sleef_quadx4; +#endif + +#ifdef ENABLE_AVX512F +#define CONFIG 1 +#include "helperavx512f.h" +#ifdef DORENAME +#include "qrenameavx512f.h" +#endif +typedef vquad Sleef_quadx8; +#endif + +#ifdef ENABLE_ADVSIMD +#define CONFIG 1 +#include "helperadvsimd.h" +#ifdef DORENAME +#include "qrenameadvsimd.h" +#endif +typedef vquad Sleef_quadx2; +#endif + +#ifdef ENABLE_SVE +#define CONFIG 1 +#include "helpersve.h" +#ifdef DORENAME +#include "qrenamesve.h" +#endif +typedef vquad Sleef_svquad; +#endif + +#ifdef ENABLE_VSX +#define CONFIG 1 +#include "helperpower_128.h" +#ifdef DORENAME +#include "qrenamevsx.h" +#endif +typedef vquad Sleef_quadx2; +#endif + +#ifdef ENABLE_VSX3 +#define CONFIG 3 +#include "helperpower_128.h" +#ifdef DORENAME +#include "qrenamevsx3.h" +#endif +#endif + +#ifdef ENABLE_VXE +#define CONFIG 140 +#include "helpers390x_128.h" +#ifdef DORENAME +#include "qrenamevxe.h" +#endif +typedef vquad Sleef_quadx2; +#endif + +#ifdef ENABLE_VXE2 +#define CONFIG 150 +#include "helpers390x_128.h" +#ifdef DORENAME +#include "qrenamevxe2.h" +#endif +typedef vquad Sleef_quadx2; +#endif + +// RISC-V +#ifdef ENABLE_RVVM1 +#define CONFIG 1 +#define ENABLE_RVV_DP +#include "helperrvv.h" +#ifdef DORENAME +#include "qrenamervvm1.h" +#endif +typedef vquad Sleef_rvvm1quad; +#endif + +#ifdef ENABLE_RVVM2 +#define CONFIG 1 +#define ENABLE_RVV_DP +#include "helperrvv.h" +#ifdef DORENAME +#include "qrenamervvm2.h" +#endif +typedef vquad Sleef_rvvm2quad; +#endif + +#include "dd.h" +#include "commonfuncs.h" + +// + +static INLINE CONST VECTOR_CC vopmask isnonfinite_vo_vq(vquad a) { + return veq64_vo_vm_vm(vand_vm_vm_vm(vqgety_vm_vq(a), vcast_vm_u64(UINT64_C(0x7fff000000000000))), vcast_vm_u64(UINT64_C(0x7fff000000000000))); +} + +static INLINE CONST VECTOR_CC vopmask isnonfinite_vo_vq_vq(vquad a, vquad b) { + vmask ma = vxor_vm_vm_vm(vand_vm_vm_vm(vqgety_vm_vq(a), vcast_vm_u64(UINT64_C(0x7fff000000000000))), vcast_vm_u64(UINT64_C(0x7fff000000000000))); + vmask mb = vxor_vm_vm_vm(vand_vm_vm_vm(vqgety_vm_vq(b), vcast_vm_u64(UINT64_C(0x7fff000000000000))), vcast_vm_u64(UINT64_C(0x7fff000000000000))); + return veq64_vo_vm_vm(vand_vm_vm_vm(ma, mb), vcast_vm_u64(0)); +} + +static INLINE CONST VECTOR_CC vopmask isnonfinite_vo_vq_vq_vq(vquad a, vquad b, vquad c) { + vmask ma = vxor_vm_vm_vm(vand_vm_vm_vm(vqgety_vm_vq(a), vcast_vm_u64(UINT64_C(0x7fff000000000000))), vcast_vm_u64(UINT64_C(0x7fff000000000000))); + vmask mb = vxor_vm_vm_vm(vand_vm_vm_vm(vqgety_vm_vq(b), vcast_vm_u64(UINT64_C(0x7fff000000000000))), vcast_vm_u64(UINT64_C(0x7fff000000000000))); + vmask mc = vxor_vm_vm_vm(vand_vm_vm_vm(vqgety_vm_vq(c), vcast_vm_u64(UINT64_C(0x7fff000000000000))), vcast_vm_u64(UINT64_C(0x7fff000000000000))); + return veq64_vo_vm_vm(vand_vm_vm_vm(vand_vm_vm_vm(ma, mb), mc), vcast_vm_u64(0)); +} + +static INLINE CONST VECTOR_CC vopmask isinf_vo_vq(vquad a) { + vopmask o = veq64_vo_vm_vm(vand_vm_vm_vm(vqgety_vm_vq(a), vcast_vm_u64(UINT64_C(0x7fffffffffffffff))), vcast_vm_u64(UINT64_C(0x7fff000000000000))); + return vand_vo_vo_vo(o, veq64_vo_vm_vm(vqgetx_vm_vq(a), vcast_vm_u64(0))); +} + +static INLINE CONST VECTOR_CC vopmask ispinf_vo_vq(vquad a) { + return vand_vo_vo_vo(veq64_vo_vm_vm(vqgety_vm_vq(a), vcast_vm_u64(UINT64_C(0x7fff000000000000))), veq64_vo_vm_vm(vqgetx_vm_vq(a), vcast_vm_u64(0))); +} + +static INLINE CONST VECTOR_CC vopmask isminf_vo_vq(vquad a) { + return vand_vo_vo_vo(veq64_vo_vm_vm(vqgety_vm_vq(a), vcast_vm_u64(UINT64_C(0xffff000000000000))), veq64_vo_vm_vm(vqgetx_vm_vq(a), vcast_vm_u64(0))); +} + +static INLINE CONST VECTOR_CC vopmask isnan_vo_vq(vquad a) { + return vandnot_vo_vo_vo(isinf_vo_vq(a), isnonfinite_vo_vq(a)); +} + +static INLINE CONST VECTOR_CC vopmask iszero_vo_vq(vquad a) { + return veq64_vo_vm_vm(vor_vm_vm_vm(vand_vm_vm_vm(vqgety_vm_vq(a), vcast_vm_u64(~UINT64_C(0x8000000000000000))), vqgetx_vm_vq(a)), vcast_vm_i64(0)); +} + +static INLINE CONST VECTOR_CC vquad mulsign_vq_vq_vq(vquad a, vquad b) { + vmask m = vxor_vm_vm_vm(vand_vm_vm_vm(vqgety_vm_vq(b), vcast_vm_u64(UINT64_C(0x8000000000000000))), vqgety_vm_vq(a)); + return vqsety_vq_vq_vm(a, m); +} + +static INLINE CONST VECTOR_CC vquad cmpcnv_vq_vq(vquad x) { + vquad t = vqsetxy_vq_vm_vm(vxor_vm_vm_vm(vqgetx_vm_vq(x), vcast_vm_u64(UINT64_C(0xffffffffffffffff))), + vxor_vm_vm_vm(vqgety_vm_vq(x), vcast_vm_u64(UINT64_C(0x7fffffffffffffff)))); + t = vqsetx_vq_vq_vm(t, vadd64_vm_vm_vm(vqgetx_vm_vq(t), vcast_vm_i64(1))); + t = vqsety_vq_vq_vm(t, vadd64_vm_vm_vm(vqgety_vm_vq(t), vand_vm_vo64_vm(veq64_vo_vm_vm(vqgetx_vm_vq(t), vcast_vm_i64(0)), vcast_vm_i64(1)))); + + return sel_vq_vo_vq_vq(veq64_vo_vm_vm(vand_vm_vm_vm(vqgety_vm_vq(x), vcast_vm_u64(UINT64_C(0x8000000000000000))), vcast_vm_u64(UINT64_C(0x8000000000000000))), + t, x); +} + +// double3 functions ------------------------------------------------------------------------------------------------------------ + +static INLINE CONST VECTOR_CC vdouble3 cast_vd3_vd_vd_vd(vdouble d0, vdouble d1, vdouble d2) { + return vd3setxyz_vd3_vd_vd_vd(d0, d1, d2); +} + +static INLINE CONST VECTOR_CC vdouble3 cast_vd3_d_d_d(double d0, double d1, double d2) { + return vd3setxyz_vd3_vd_vd_vd(vcast_vd_d(d0), vcast_vd_d(d1), vcast_vd_d(d2)); +} + +static INLINE CONST VECTOR_CC vdouble3 mulsign_vd3_vd3_vd(vdouble3 d, vdouble s) { + return cast_vd3_vd_vd_vd(vmulsign_vd_vd_vd(vd3getx_vd_vd3(d), s), vmulsign_vd_vd_vd(vd3gety_vd_vd3(d), s), vmulsign_vd_vd_vd(vd3getz_vd_vd3(d), s)); +} + +static INLINE CONST VECTOR_CC vdouble3 abs_vd3_vd3(vdouble3 d) { return mulsign_vd3_vd3_vd(d, vd3getx_vd_vd3(d)); } + +static INLINE CONST VECTOR_CC vdouble3 sel_vd3_vo_vd3_vd3(vopmask m, vdouble3 x, vdouble3 y) { + return vd3setxyz_vd3_vd_vd_vd(vsel_vd_vo_vd_vd(m, vd3getx_vd_vd3(x), vd3getx_vd_vd3(y)), + vsel_vd_vo_vd_vd(m, vd3gety_vd_vd3(x), vd3gety_vd_vd3(y)), + vsel_vd_vo_vd_vd(m, vd3getz_vd_vd3(x), vd3getz_vd_vd3(y))); +} + +// TD algorithms are based on Y. Hida et al., Library for double-double and quad-double arithmetic (2007). +static INLINE CONST VECTOR_CC vdouble2 twosum_vd2_vd_vd(vdouble x, vdouble y) { + vdouble rx = vadd_vd_vd_vd(x, y); + vdouble v = vsub_vd_vd_vd(rx, x); + return vd2setxy_vd2_vd_vd(rx, vadd_vd_vd_vd(vsub_vd_vd_vd(x, vsub_vd_vd_vd(rx, v)), vsub_vd_vd_vd(y, v))); +} + +static INLINE CONST VECTOR_CC vdouble2 twosub_vd2_vd_vd(vdouble x, vdouble y) { + vdouble rx = vsub_vd_vd_vd(x, y); + vdouble v = vsub_vd_vd_vd(rx, x); + return vd2setxy_vd2_vd_vd(rx, vsub_vd_vd_vd(vsub_vd_vd_vd(x, vsub_vd_vd_vd(rx, v)), vadd_vd_vd_vd(y, v))); +} + +static INLINE CONST VECTOR_CC vdouble2 twosumx_vd2_vd_vd_vd(vdouble x, vdouble y, vdouble s) { + vdouble rx = vmla_vd_vd_vd_vd(y, s, x); + vdouble v = vsub_vd_vd_vd(rx, x); + return vd2setxy_vd2_vd_vd(rx, vadd_vd_vd_vd(vsub_vd_vd_vd(x, vsub_vd_vd_vd(rx, v)), vmlapn_vd_vd_vd_vd(y, s, v))); +} + +static INLINE CONST VECTOR_CC vdouble2 twosubx_vd2_vd_vd_vd(vdouble x, vdouble y, vdouble s) { + vdouble rx = vmlanp_vd_vd_vd_vd(y, s, x); + vdouble v = vsub_vd_vd_vd(rx, x); + return vd2setxy_vd2_vd_vd(rx, vsub_vd_vd_vd(vsub_vd_vd_vd(x, vsub_vd_vd_vd(rx, v)), vmla_vd_vd_vd_vd(y, s, v))); +} + +static INLINE CONST VECTOR_CC vdouble2 quicktwosum_vd2_vd_vd(vdouble x, vdouble y) { + vdouble rx = vadd_vd_vd_vd(x, y); + return vd2setxy_vd2_vd_vd(rx, vadd_vd_vd_vd(vsub_vd_vd_vd(x, rx), y)); +} + +static INLINE CONST VECTOR_CC vdouble2 twoprod_vd2_vd_vd(vdouble x, vdouble y) { +#ifdef ENABLE_FMA_DP + vdouble rx = vmul_vd_vd_vd(x, y); + return vd2setxy_vd2_vd_vd(rx, vfmapn_vd_vd_vd_vd(x, y, rx)); +#else + vdouble xh = vmul_vd_vd_vd(x, vcast_vd_d((1 << 27)+1)); + xh = vsub_vd_vd_vd(xh, vsub_vd_vd_vd(xh, x)); + vdouble xl = vsub_vd_vd_vd(x, xh); + vdouble yh = vmul_vd_vd_vd(y, vcast_vd_d((1 << 27)+1)); + yh = vsub_vd_vd_vd(yh, vsub_vd_vd_vd(yh, y)); + vdouble yl = vsub_vd_vd_vd(y, yh); + + vdouble rx = vmul_vd_vd_vd(x, y); + return vd2setxy_vd2_vd_vd(rx, vadd_vd_5vd(vmul_vd_vd_vd(xh, yh), vneg_vd_vd(rx), vmul_vd_vd_vd(xl, yh), vmul_vd_vd_vd(xh, yl), vmul_vd_vd_vd(xl, yl))); +#endif +} + +static INLINE CONST VECTOR_CC vdouble3 scale_vd3_vd3_vd(vdouble3 d, vdouble s) { + return cast_vd3_vd_vd_vd(vmul_vd_vd_vd(vd3getx_vd_vd3(d), s), vmul_vd_vd_vd(vd3gety_vd_vd3(d), s), vmul_vd_vd_vd(vd3getz_vd_vd3(d), s)); +} + +static INLINE CONST VECTOR_CC vdouble3 scale_vd3_vd3_d(vdouble3 d, double s) { return scale_vd3_vd3_vd(d, vcast_vd_d(s)); } + +static INLINE CONST VECTOR_CC vdouble3 quickrenormalize_vd3_vd3(vdouble3 td) { + vdouble2 u = quicktwosum_vd2_vd_vd(vd3getx_vd_vd3(td), vd3gety_vd_vd3(td)); + vdouble2 v = quicktwosum_vd2_vd_vd(vd2gety_vd_vd2(u), vd3getz_vd_vd3(td)); + return cast_vd3_vd_vd_vd(vd2getx_vd_vd2(u), vd2getx_vd_vd2(v), vd2gety_vd_vd2(v)); +} + +static INLINE CONST VECTOR_CC vdouble3 normalize_vd3_vd3(vdouble3 td) { + vdouble2 u = quicktwosum_vd2_vd_vd(vd3getx_vd_vd3(td), vd3gety_vd_vd3(td)); + vdouble2 v = quicktwosum_vd2_vd_vd(vd2gety_vd_vd2(u), vd3getz_vd_vd3(td)); + td = vd3setxyz_vd3_vd_vd_vd(vd2getx_vd_vd2(u), vd2getx_vd_vd2(v), vd2gety_vd_vd2(v)); + u = quicktwosum_vd2_vd_vd(vd3getx_vd_vd3(td), vd3gety_vd_vd3(td)); + return vd3setxyz_vd3_vd_vd_vd(vd2getx_vd_vd2(u), vd2gety_vd_vd2(u), vd3getz_vd_vd3(td)); +} + +static INLINE CONST VECTOR_CC vdouble3 add2_vd3_vd3_vd3(vdouble3 x, vdouble3 y) { + vdouble2 d0 = twosum_vd2_vd_vd(vd3getx_vd_vd3(x), vd3getx_vd_vd3(y)); + vdouble2 d1 = twosum_vd2_vd_vd(vd3gety_vd_vd3(x), vd3gety_vd_vd3(y)); + vdouble2 d3 = twosum_vd2_vd_vd(vd2gety_vd_vd2(d0), vd2getx_vd_vd2(d1)); + return normalize_vd3_vd3(vd3setxyz_vd3_vd_vd_vd(vd2getx_vd_vd2(d0), vd2getx_vd_vd2(d3), vadd_vd_4vd(vd3getz_vd_vd3(x), vd3getz_vd_vd3(y), vd2gety_vd_vd2(d1), vd2gety_vd_vd2(d3)))); +} + +static INLINE CONST VECTOR_CC vdouble3 sub2_vd3_vd3_vd3(vdouble3 x, vdouble3 y) { + vdouble2 d0 = twosub_vd2_vd_vd(vd3getx_vd_vd3(x), vd3getx_vd_vd3(y)); + vdouble2 d1 = twosub_vd2_vd_vd(vd3gety_vd_vd3(x), vd3gety_vd_vd3(y)); + vdouble2 d3 = twosum_vd2_vd_vd(vd2gety_vd_vd2(d0), vd2getx_vd_vd2(d1)); + return normalize_vd3_vd3(vd3setxyz_vd3_vd_vd_vd(vd2getx_vd_vd2(d0), vd2getx_vd_vd2(d3), vadd_vd_4vd(vd3getz_vd_vd3(x), vneg_vd_vd(vd3getz_vd_vd3(y)), vd2gety_vd_vd2(d1), vd2gety_vd_vd2(d3)))); +} + +static INLINE CONST VECTOR_CC vdouble3 add2_vd3_vd2_vd3(vdouble2 x, vdouble3 y) { + vdouble2 d0 = twosum_vd2_vd_vd(vd2getx_vd_vd2(x), vd3getx_vd_vd3(y)); + vdouble2 d1 = twosum_vd2_vd_vd(vd2gety_vd_vd2(x), vd3gety_vd_vd3(y)); + vdouble2 d3 = twosum_vd2_vd_vd(vd2gety_vd_vd2(d0), vd2getx_vd_vd2(d1)); + return normalize_vd3_vd3(vd3setxyz_vd3_vd_vd_vd(vd2getx_vd_vd2(d0), vd2getx_vd_vd2(d3), vadd_vd_3vd(vd2gety_vd_vd2(d1), vd2gety_vd_vd2(d3), vd3getz_vd_vd3(y)))); +} + +static INLINE CONST VECTOR_CC vdouble3 add_vd3_vd2_vd3(vdouble2 x, vdouble3 y) { + vdouble2 d0 = twosum_vd2_vd_vd(vd2getx_vd_vd2(x), vd3getx_vd_vd3(y)); + vdouble2 d1 = twosum_vd2_vd_vd(vd2gety_vd_vd2(x), vd3gety_vd_vd3(y)); + vdouble2 d3 = twosum_vd2_vd_vd(vd2gety_vd_vd2(d0), vd2getx_vd_vd2(d1)); + return vd3setxyz_vd3_vd_vd_vd(vd2getx_vd_vd2(d0), vd2getx_vd_vd2(d3), vadd_vd_3vd(vd2gety_vd_vd2(d1), vd2gety_vd_vd2(d3), vd3getz_vd_vd3(y))); +} + +static INLINE CONST VECTOR_CC vdouble3 add2_vd3_vd_vd3(vdouble x, vdouble3 y) { + vdouble2 d0 = twosum_vd2_vd_vd(x, vd3getx_vd_vd3(y)); + vdouble2 d3 = twosum_vd2_vd_vd(vd2gety_vd_vd2(d0), vd3gety_vd_vd3(y)); + return normalize_vd3_vd3(vd3setxyz_vd3_vd_vd_vd(vd2getx_vd_vd2(d0), vd2getx_vd_vd2(d3), vadd_vd_vd_vd(vd2gety_vd_vd2(d3), vd3getz_vd_vd3(y)))); +} + +static INLINE CONST VECTOR_CC vdouble3 add_vd3_vd_vd3(vdouble x, vdouble3 y) { + vdouble2 d0 = twosum_vd2_vd_vd(x, vd3getx_vd_vd3(y)); + vdouble2 d3 = twosum_vd2_vd_vd(vd2gety_vd_vd2(d0), vd3gety_vd_vd3(y)); + return vd3setxyz_vd3_vd_vd_vd(vd2getx_vd_vd2(d0), vd2getx_vd_vd2(d3), vadd_vd_vd_vd(vd2gety_vd_vd2(d3), vd3getz_vd_vd3(y))); +} + +static INLINE CONST VECTOR_CC vdouble3 scaleadd2_vd3_vd3_vd3_vd(vdouble3 x, vdouble3 y, vdouble s) { + vdouble2 d0 = twosumx_vd2_vd_vd_vd(vd3getx_vd_vd3(x), vd3getx_vd_vd3(y), s); + vdouble2 d1 = twosumx_vd2_vd_vd_vd(vd3gety_vd_vd3(x), vd3gety_vd_vd3(y), s); + vdouble2 d3 = twosum_vd2_vd_vd(vd2gety_vd_vd2(d0), vd2getx_vd_vd2(d1)); + return normalize_vd3_vd3(vd3setxyz_vd3_vd_vd_vd(vd2getx_vd_vd2(d0), vd2getx_vd_vd2(d3), vadd_vd_3vd(vmla_vd_vd_vd_vd(vd3getz_vd_vd3(y), s, vd3getz_vd_vd3(x)), vd2gety_vd_vd2(d1), vd2gety_vd_vd2(d3)))); +} + +static INLINE CONST VECTOR_CC vdouble3 scalesub2_vd3_vd3_vd3_vd(vdouble3 x, vdouble3 y, vdouble s) { + vdouble2 d0 = twosubx_vd2_vd_vd_vd(vd3getx_vd_vd3(x), vd3getx_vd_vd3(y), s); + vdouble2 d1 = twosubx_vd2_vd_vd_vd(vd3gety_vd_vd3(x), vd3gety_vd_vd3(y), s); + vdouble2 d3 = twosum_vd2_vd_vd(vd2gety_vd_vd2(d0), vd2getx_vd_vd2(d1)); + return normalize_vd3_vd3(vd3setxyz_vd3_vd_vd_vd(vd2getx_vd_vd2(d0), vd2getx_vd_vd2(d3), vadd_vd_3vd(vmlanp_vd_vd_vd_vd(vd3getz_vd_vd3(y), s, vd3getz_vd_vd3(x)), vd2gety_vd_vd2(d1), vd2gety_vd_vd2(d3)))); +} + +static INLINE CONST VECTOR_CC vdouble3 mul2_vd3_vd3_vd3(vdouble3 x, vdouble3 y) { + vdouble2 d0 = twoprod_vd2_vd_vd(vd3getx_vd_vd3(x), vd3getx_vd_vd3(y)); + vdouble2 d1 = twoprod_vd2_vd_vd(vd3getx_vd_vd3(x), vd3gety_vd_vd3(y)); + vdouble2 d2 = twoprod_vd2_vd_vd(vd3gety_vd_vd3(x), vd3getx_vd_vd3(y)); + vdouble2 d4 = twosum_vd2_vd_vd(vd2gety_vd_vd2(d0), vd2getx_vd_vd2(d1)); + vdouble2 d5 = twosum_vd2_vd_vd(vd2getx_vd_vd2(d4), vd2getx_vd_vd2(d2)); + + vdouble t2 = vadd_vd_3vd(vmla_vd_vd_vd_vd(vd3getz_vd_vd3(x), vd3getx_vd_vd3(y), vmla_vd_vd_vd_vd(vd3gety_vd_vd3(x), vd3gety_vd_vd3(y), vmla_vd_vd_vd_vd(vd3getx_vd_vd3(x), vd3getz_vd_vd3(y), vadd_vd_vd_vd(vd2gety_vd_vd2(d1), vd2gety_vd_vd2(d2))))), vd2gety_vd_vd2(d4), vd2gety_vd_vd2(d5)); + + return normalize_vd3_vd3(vd3setxyz_vd3_vd_vd_vd(vd2getx_vd_vd2(d0), vd2getx_vd_vd2(d5), t2)); +} + +static INLINE CONST VECTOR_CC vdouble3 mul_vd3_vd3_vd3(vdouble3 x, vdouble3 y) { + vdouble2 d0 = twoprod_vd2_vd_vd(vd3getx_vd_vd3(x), vd3getx_vd_vd3(y)); + vdouble2 d1 = twoprod_vd2_vd_vd(vd3getx_vd_vd3(x), vd3gety_vd_vd3(y)); + vdouble2 d2 = twoprod_vd2_vd_vd(vd3gety_vd_vd3(x), vd3getx_vd_vd3(y)); + vdouble2 d4 = twosum_vd2_vd_vd(vd2gety_vd_vd2(d0), vd2getx_vd_vd2(d1)); + vdouble2 d5 = twosum_vd2_vd_vd(vd2getx_vd_vd2(d4), vd2getx_vd_vd2(d2)); + + vdouble t2 = vadd_vd_3vd(vmla_vd_vd_vd_vd(vd3getz_vd_vd3(x), vd3getx_vd_vd3(y), vmla_vd_vd_vd_vd(vd3gety_vd_vd3(x), vd3gety_vd_vd3(y), vmla_vd_vd_vd_vd(vd3getx_vd_vd3(x), vd3getz_vd_vd3(y), vadd_vd_vd_vd(vd2gety_vd_vd2(d1), vd2gety_vd_vd2(d2))))), vd2gety_vd_vd2(d4), vd2gety_vd_vd2(d5)); + + return quickrenormalize_vd3_vd3(vd3setxyz_vd3_vd_vd_vd(vd2getx_vd_vd2(d0), vd2getx_vd_vd2(d5), t2)); +} + +static INLINE CONST VECTOR_CC vdouble3 squ_vd3_vd3(vdouble3 x) { return mul_vd3_vd3_vd3(x, x); } + +static INLINE CONST VECTOR_CC vdouble3 mul_vd3_vd2_vd3(vdouble2 x, vdouble3 y) { + vdouble2 d0 = twoprod_vd2_vd_vd(vd2getx_vd_vd2(x), vd3getx_vd_vd3(y)); + vdouble2 d1 = twoprod_vd2_vd_vd(vd2getx_vd_vd2(x), vd3gety_vd_vd3(y)); + vdouble2 d2 = twoprod_vd2_vd_vd(vd2gety_vd_vd2(x), vd3getx_vd_vd3(y)); + vdouble2 d4 = twosum_vd2_vd_vd(vd2gety_vd_vd2(d0), vd2getx_vd_vd2(d1)); + vdouble2 d5 = twosum_vd2_vd_vd(vd2getx_vd_vd2(d4), vd2getx_vd_vd2(d2)); + + vdouble t2 = vadd_vd_3vd(vmla_vd_vd_vd_vd(vd2gety_vd_vd2(x), vd3gety_vd_vd3(y), vmla_vd_vd_vd_vd(vd2getx_vd_vd2(x), vd3getz_vd_vd3(y), vadd_vd_vd_vd(vd2gety_vd_vd2(d1), vd2gety_vd_vd2(d2)))), vd2gety_vd_vd2(d4), vd2gety_vd_vd2(d5)); + + return vd3setxyz_vd3_vd_vd_vd(vd2getx_vd_vd2(d0), vd2getx_vd_vd2(d5), t2); +} + +static INLINE CONST VECTOR_CC vdouble3 mul_vd3_vd3_vd2(vdouble3 x, vdouble2 y) { + vdouble2 d0 = twoprod_vd2_vd_vd(vd2getx_vd_vd2(y), vd3getx_vd_vd3(x)); + vdouble2 d1 = twoprod_vd2_vd_vd(vd2getx_vd_vd2(y), vd3gety_vd_vd3(x)); + vdouble2 d2 = twoprod_vd2_vd_vd(vd2gety_vd_vd2(y), vd3getx_vd_vd3(x)); + vdouble2 d4 = twosum_vd2_vd_vd(vd2gety_vd_vd2(d0), vd2getx_vd_vd2(d1)); + vdouble2 d5 = twosum_vd2_vd_vd(vd2getx_vd_vd2(d4), vd2getx_vd_vd2(d2)); + + vdouble t2 = vadd_vd_3vd(vmla_vd_vd_vd_vd(vd2gety_vd_vd2(y), vd3gety_vd_vd3(x), vmla_vd_vd_vd_vd(vd2getx_vd_vd2(y), vd3getz_vd_vd3(x), vadd_vd_vd_vd(vd2gety_vd_vd2(d1), vd2gety_vd_vd2(d2)))), vd2gety_vd_vd2(d4), vd2gety_vd_vd2(d5)); + + return vd3setxyz_vd3_vd_vd_vd(vd2getx_vd_vd2(d0), vd2getx_vd_vd2(d5), t2); +} + +static INLINE CONST VECTOR_CC vdouble3 mul_vd3_vd3_vd(vdouble3 x, vdouble y) { + vdouble2 d0 = twoprod_vd2_vd_vd(y, vd3getx_vd_vd3(x)); + vdouble2 d1 = twoprod_vd2_vd_vd(y, vd3gety_vd_vd3(x)); + vdouble2 d4 = twosum_vd2_vd_vd(vd2gety_vd_vd2(d0), vd2getx_vd_vd2(d1)); + + return vd3setxyz_vd3_vd_vd_vd(vd2getx_vd_vd2(d0), vd2getx_vd_vd2(d4), vadd_vd_vd_vd(vmla_vd_vd_vd_vd(y, vd3getz_vd_vd3(x), vd2gety_vd_vd2(d1)), vd2gety_vd_vd2(d4))); +} + +static INLINE CONST VECTOR_CC vdouble3 mul_vd3_vd2_vd2(vdouble2 x, vdouble2 y) { + vdouble2 d0 = twoprod_vd2_vd_vd(vd2getx_vd_vd2(x), vd2getx_vd_vd2(y)); + vdouble2 d1 = twoprod_vd2_vd_vd(vd2getx_vd_vd2(x), vd2gety_vd_vd2(y)); + vdouble2 d2 = twoprod_vd2_vd_vd(vd2gety_vd_vd2(x), vd2getx_vd_vd2(y)); + vdouble2 d4 = twosum_vd2_vd_vd(vd2gety_vd_vd2(d0), vd2getx_vd_vd2(d1)); + vdouble2 d5 = twosum_vd2_vd_vd(vd2getx_vd_vd2(d4), vd2getx_vd_vd2(d2)); + + vdouble t2 = vadd_vd_3vd(vmla_vd_vd_vd_vd(vd2gety_vd_vd2(x), vd2gety_vd_vd2(y), vadd_vd_vd_vd(vd2gety_vd_vd2(d1), vd2gety_vd_vd2(d2))), vd2gety_vd_vd2(d4), vd2gety_vd_vd2(d5)); + + return vd3setxyz_vd3_vd_vd_vd(vd2getx_vd_vd2(d0), vd2getx_vd_vd2(d5), t2); +} + +static INLINE CONST VECTOR_CC vdouble3 div2_vd3_vd3_vd3(vdouble3 n, vdouble3 q) { + vdouble2 d = ddrec_vd2_vd2(vcast_vd2_vd_vd(vd3getx_vd_vd3(q), vd3gety_vd_vd3(q))); + return mul2_vd3_vd3_vd3(n, add_vd3_vd2_vd3(d, mul_vd3_vd2_vd3(ddscale_vd2_vd2_d(d, -1), + add_vd3_vd_vd3(vcast_vd_d(-1), mul_vd3_vd2_vd3(d, q))))); +} + +static INLINE CONST VECTOR_CC vdouble3 div_vd3_vd3_vd3(vdouble3 n, vdouble3 q) { + vdouble2 d = ddrec_vd2_vd2(vcast_vd2_vd_vd(vd3getx_vd_vd3(q), vd3gety_vd_vd3(q))); + return mul_vd3_vd3_vd3(n, add_vd3_vd2_vd3(d, mul_vd3_vd2_vd3(ddscale_vd2_vd2_d(d, -1), + add_vd3_vd_vd3(vcast_vd_d(-1), mul_vd3_vd2_vd3(d, q))))); +} + +static INLINE CONST VECTOR_CC vdouble3 rec_vd3_vd3(vdouble3 q) { + vdouble2 d = ddrec_vd2_vd2(vcast_vd2_vd_vd(vd3getx_vd_vd3(q), vd3gety_vd_vd3(q))); + return add2_vd3_vd2_vd3(d, mul_vd3_vd2_vd3(ddscale_vd2_vd2_d(d, -1), + add_vd3_vd_vd3(vcast_vd_d(-1), mul_vd3_vd2_vd3(d, q)))); +} + +static INLINE CONST VECTOR_CC vdouble3 rec_vd3_vd2(vdouble2 q) { + vdouble2 d = ddrec_vd2_vd2(vcast_vd2_vd_vd(vd2getx_vd_vd2(q), vd2gety_vd_vd2(q))); + return add2_vd3_vd2_vd3(d, mul_vd3_vd2_vd3(ddscale_vd2_vd2_d(d, -1), + add_vd3_vd_vd3(vcast_vd_d(-1), mul_vd3_vd2_vd2(d, q)))); +} + +static INLINE CONST VECTOR_CC vdouble3 sqrt_vd3_vd3(vdouble3 d) { + vdouble2 t = ddsqrt_vd2_vd2(vcast_vd2_vd_vd(vd3getx_vd_vd3(d), vd3gety_vd_vd3(d))); + vdouble3 r = mul2_vd3_vd3_vd3(add2_vd3_vd3_vd3(d, mul_vd3_vd2_vd2(t, t)), rec_vd3_vd2(t)); + r = sel_vd3_vo_vd3_vd3(veq_vo_vd_vd(vd3getx_vd_vd3(d), vcast_vd_d(0)), cast_vd3_d_d_d(0, 0, 0), scale_vd3_vd3_d(r, 0.5)); + return r; +} + +static INLINE CONST VECTOR_CC vdouble3 neg_vd3_vd3(vdouble3 d) { + return vd3setxyz_vd3_vd_vd_vd(vneg_vd_vd(vd3getx_vd_vd3(d)), + vneg_vd_vd(vd3gety_vd_vd3(d)), + vneg_vd_vd(vd3getz_vd_vd3(d))); +} + +// + +static INLINE CONST VECTOR_CC vdouble poly2d(vdouble x, double c1, double c0) { return vmla_vd_vd_vd_vd(x, vcast_vd_d(c1), vcast_vd_d(c0)); } +static INLINE CONST VECTOR_CC vdouble poly3d(vdouble x, double c2, double c1, double c0) { return vmla_vd_vd_vd_vd(vmul_vd_vd_vd(x, x), vcast_vd_d(c2), poly2d(x, c1, c0)); } +static INLINE CONST VECTOR_CC vdouble poly4d(vdouble x, double c3, double c2, double c1, double c0) { + return vmla_vd_vd_vd_vd(vmul_vd_vd_vd(x, x), poly2d(x, c3, c2), poly2d(x, c1, c0)); +} +static INLINE CONST VECTOR_CC vdouble poly5d(vdouble x, double c4, double c3, double c2, double c1, double c0) { + return vmla_vd_vd_vd_vd(vmul_vd_vd_vd(vmul_vd_vd_vd(x, x),vmul_vd_vd_vd(x, x)), vcast_vd_d(c4), poly4d(x, c3, c2, c1, c0)); +} +static INLINE CONST VECTOR_CC vdouble poly6d(vdouble x, double c5, double c4, double c3, double c2, double c1, double c0) { + return vmla_vd_vd_vd_vd(vmul_vd_vd_vd(vmul_vd_vd_vd(x, x),vmul_vd_vd_vd(x, x)), poly2d(x, c5, c4), poly4d(x, c3, c2, c1, c0)); +} +static INLINE CONST VECTOR_CC vdouble poly7d(vdouble x, double c6, double c5, double c4, double c3, double c2, double c1, double c0) { + return vmla_vd_vd_vd_vd(vmul_vd_vd_vd(vmul_vd_vd_vd(x, x),vmul_vd_vd_vd(x, x)), poly3d(x, c6, c5, c4), poly4d(x, c3, c2, c1, c0)); +} +static INLINE CONST VECTOR_CC vdouble poly8d(vdouble x, double c7, double c6, double c5, double c4, double c3, double c2, double c1, double c0) { + return vmla_vd_vd_vd_vd(vmul_vd_vd_vd(vmul_vd_vd_vd(x, x),vmul_vd_vd_vd(x, x)), poly4d(x, c7, c6, c5, c4), poly4d(x, c3, c2, c1, c0)); +} + +// + +static INLINE CONST VECTOR_CC vdouble2 poly2dd_b(vdouble2 x, double2 c1, double2 c0) { return ddmla_vd2_vd2_vd2_vd2(x, vcast_vd2_d2(c1), vcast_vd2_d2(c0)); } +static INLINE CONST VECTOR_CC vdouble2 poly2dd(vdouble2 x, vdouble c1, double2 c0) { return ddmla_vd2_vd2_vd2_vd2(x, vcast_vd2_vd_vd(c1, vcast_vd_d(0)), vcast_vd2_d2(c0)); } +static INLINE CONST VECTOR_CC vdouble2 poly3dd_b(vdouble2 x, double2 c2, double2 c1, double2 c0) { return ddmla_vd2_vd2_vd2_vd2(ddsqu_vd2_vd2(x), vcast_vd2_d2(c2), poly2dd_b(x, c1, c0)); } +static INLINE CONST VECTOR_CC vdouble2 poly3dd(vdouble2 x, vdouble c2, double2 c1, double2 c0) { + return ddmla_vd2_vd2_vd2_vd2(ddsqu_vd2_vd2(x), vcast_vd2_vd_vd(c2, vcast_vd_d(0)), poly2dd_b(x, c1, c0)); +} +static INLINE CONST VECTOR_CC vdouble2 poly4dd_b(vdouble2 x, double2 c3, double2 c2, double2 c1, double2 c0) { + return ddmla_vd2_vd2_vd2_vd2(ddsqu_vd2_vd2(x), poly2dd_b(x, c3, c2), poly2dd_b(x, c1, c0)); +} +static INLINE CONST VECTOR_CC vdouble2 poly4dd(vdouble2 x, vdouble c3, double2 c2, double2 c1, double2 c0) { + return ddmla_vd2_vd2_vd2_vd2(ddsqu_vd2_vd2(x), poly2dd(x, c3, c2), poly2dd_b(x, c1, c0)); +} +static INLINE CONST VECTOR_CC vdouble2 poly5dd_b(vdouble2 x, double2 c4, double2 c3, double2 c2, double2 c1, double2 c0) { + return ddmla_vd2_vd2_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(x)), vcast_vd2_d2(c4), poly4dd_b(x, c3, c2, c1, c0)); +} +static INLINE CONST VECTOR_CC vdouble2 poly5dd(vdouble2 x, vdouble c4, double2 c3, double2 c2, double2 c1, double2 c0) { + return ddmla_vd2_vd2_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(x)), vcast_vd2_vd_vd(c4, vcast_vd_d(0)), poly4dd_b(x, c3, c2, c1, c0)); +} +static INLINE CONST VECTOR_CC vdouble2 poly6dd_b(vdouble2 x, double2 c5, double2 c4, double2 c3, double2 c2, double2 c1, double2 c0) { + return ddmla_vd2_vd2_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(x)), poly2dd_b(x, c5, c4), poly4dd_b(x, c3, c2, c1, c0)); +} +static INLINE CONST VECTOR_CC vdouble2 poly6dd(vdouble2 x, vdouble c5, double2 c4, double2 c3, double2 c2, double2 c1, double2 c0) { + return ddmla_vd2_vd2_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(x)), poly2dd(x, c5, c4), poly4dd_b(x, c3, c2, c1, c0)); +} +static INLINE CONST VECTOR_CC vdouble2 poly7dd_b(vdouble2 x, double2 c6, double2 c5, double2 c4, double2 c3, double2 c2, double2 c1, double2 c0) { + return ddmla_vd2_vd2_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(x)), poly3dd_b(x, c6, c5, c4), poly4dd_b(x, c3, c2, c1, c0)); +} +static INLINE CONST VECTOR_CC vdouble2 poly7dd(vdouble2 x, vdouble c6, double2 c5, double2 c4, double2 c3, double2 c2, double2 c1, double2 c0) { + return ddmla_vd2_vd2_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(x)), poly3dd(x, c6, c5, c4), poly4dd_b(x, c3, c2, c1, c0)); +} +static INLINE CONST VECTOR_CC vdouble2 poly8dd_b(vdouble2 x, double2 c7, double2 c6, double2 c5, double2 c4, double2 c3, double2 c2, double2 c1, double2 c0) { + return ddmla_vd2_vd2_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(x)), poly4dd_b(x, c7, c6, c5, c4), poly4dd_b(x, c3, c2, c1, c0)); +} +static INLINE CONST VECTOR_CC vdouble2 poly8dd(vdouble2 x, vdouble c7, double2 c6, double2 c5, double2 c4, double2 c3, double2 c2, double2 c1, double2 c0) { + return ddmla_vd2_vd2_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(x)), poly4dd(x, c7, c6, c5, c4), poly4dd_b(x, c3, c2, c1, c0)); +} +static INLINE CONST VECTOR_CC vdouble2 poly9dd_b(vdouble2 x, double2 c8, + double2 c7, double2 c6, double2 c5, double2 c4, double2 c3, double2 c2, double2 c1, double2 c0) { + return ddmla_vd2_vd2_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(x))), vcast_vd2_d2(c8), poly8dd_b(x, c7, c6, c5, c4, c3, c2, c1, c0)); +} +static INLINE CONST VECTOR_CC vdouble2 poly9dd(vdouble2 x, vdouble c8, + double2 c7, double2 c6, double2 c5, double2 c4, double2 c3, double2 c2, double2 c1, double2 c0) { + return ddmla_vd2_vd2_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(x))), vcast_vd2_vd_vd(c8, vcast_vd_d(0)), poly8dd_b(x, c7, c6, c5, c4, c3, c2, c1, c0)); +} +static INLINE CONST VECTOR_CC vdouble2 poly10dd_b(vdouble2 x, double2 c9, double2 c8, + double2 c7, double2 c6, double2 c5, double2 c4, double2 c3, double2 c2, double2 c1, double2 c0) { + return ddmla_vd2_vd2_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(x))), poly2dd_b(x, c9, c8), poly8dd_b(x, c7, c6, c5, c4, c3, c2, c1, c0)); +} +static INLINE CONST VECTOR_CC vdouble2 poly10dd(vdouble2 x, vdouble c9, double2 c8, + double2 c7, double2 c6, double2 c5, double2 c4, double2 c3, double2 c2, double2 c1, double2 c0) { + return ddmla_vd2_vd2_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(x))), poly2dd(x, c9, c8), poly8dd_b(x, c7, c6, c5, c4, c3, c2, c1, c0)); +} +static INLINE CONST VECTOR_CC vdouble2 poly11dd_b(vdouble2 x, double2 c10, double2 c9, double2 c8, + double2 c7, double2 c6, double2 c5, double2 c4, double2 c3, double2 c2, double2 c1, double2 c0) { + return ddmla_vd2_vd2_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(x))), poly3dd_b(x, c10, c9, c8), poly8dd_b(x, c7, c6, c5, c4, c3, c2, c1, c0)); +} +static INLINE CONST VECTOR_CC vdouble2 poly11dd(vdouble2 x, vdouble c10, double2 c9, double2 c8, + double2 c7, double2 c6, double2 c5, double2 c4, double2 c3, double2 c2, double2 c1, double2 c0) { + return ddmla_vd2_vd2_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(x))), poly3dd(x, c10, c9, c8), poly8dd_b(x, c7, c6, c5, c4, c3, c2, c1, c0)); +} +static INLINE CONST VECTOR_CC vdouble2 poly12dd_b(vdouble2 x, double2 c11, double2 c10, double2 c9, double2 c8, + double2 c7, double2 c6, double2 c5, double2 c4, double2 c3, double2 c2, double2 c1, double2 c0) { + return ddmla_vd2_vd2_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(x))), poly4dd_b(x, c11, c10, c9, c8), poly8dd_b(x, c7, c6, c5, c4, c3, c2, c1, c0)); +} +static INLINE CONST VECTOR_CC vdouble2 poly12dd(vdouble2 x, vdouble c11, double2 c10, double2 c9, double2 c8, + double2 c7, double2 c6, double2 c5, double2 c4, double2 c3, double2 c2, double2 c1, double2 c0) { + return ddmla_vd2_vd2_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(x))), poly4dd(x, c11, c10, c9, c8), poly8dd_b(x, c7, c6, c5, c4, c3, c2, c1, c0)); +} +static INLINE CONST VECTOR_CC vdouble2 poly13dd_b(vdouble2 x, double2 c12, double2 c11, double2 c10, double2 c9, double2 c8, + double2 c7, double2 c6, double2 c5, double2 c4, double2 c3, double2 c2, double2 c1, double2 c0) { + return ddmla_vd2_vd2_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(x))), poly5dd_b(x, c12, c11, c10, c9, c8), poly8dd_b(x, c7, c6, c5, c4, c3, c2, c1, c0)); +} +static INLINE CONST VECTOR_CC vdouble2 poly13dd(vdouble2 x, vdouble c12, double2 c11, double2 c10, double2 c9, double2 c8, + double2 c7, double2 c6, double2 c5, double2 c4, double2 c3, double2 c2, double2 c1, double2 c0) { + return ddmla_vd2_vd2_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(x))), poly5dd(x, c12, c11, c10, c9, c8), poly8dd_b(x, c7, c6, c5, c4, c3, c2, c1, c0)); +} +static INLINE CONST VECTOR_CC vdouble2 poly14dd_b(vdouble2 x, double2 c13, double2 c12, double2 c11, double2 c10, double2 c9, double2 c8, + double2 c7, double2 c6, double2 c5, double2 c4, double2 c3, double2 c2, double2 c1, double2 c0) { + return ddmla_vd2_vd2_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(x))), poly6dd_b(x, c13, c12, c11, c10, c9, c8), poly8dd_b(x, c7, c6, c5, c4, c3, c2, c1, c0)); +} +static INLINE CONST VECTOR_CC vdouble2 poly14dd(vdouble2 x, vdouble c13, double2 c12, double2 c11, double2 c10, double2 c9, double2 c8, + double2 c7, double2 c6, double2 c5, double2 c4, double2 c3, double2 c2, double2 c1, double2 c0) { + return ddmla_vd2_vd2_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(x))), poly6dd(x, c13, c12, c11, c10, c9, c8), poly8dd_b(x, c7, c6, c5, c4, c3, c2, c1, c0)); +} +static INLINE CONST VECTOR_CC vdouble2 poly15dd_b(vdouble2 x, double2 c14, double2 c13, double2 c12, double2 c11, double2 c10, double2 c9, double2 c8, + double2 c7, double2 c6, double2 c5, double2 c4, double2 c3, double2 c2, double2 c1, double2 c0) { + return ddmla_vd2_vd2_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(x))), poly7dd_b(x, c14, c13, c12, c11, c10, c9, c8), poly8dd_b(x, c7, c6, c5, c4, c3, c2, c1, c0)); +} +static INLINE CONST VECTOR_CC vdouble2 poly15dd(vdouble2 x, vdouble c14, double2 c13, double2 c12, double2 c11, double2 c10, double2 c9, double2 c8, + double2 c7, double2 c6, double2 c5, double2 c4, double2 c3, double2 c2, double2 c1, double2 c0) { + return ddmla_vd2_vd2_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(x))), poly7dd(x, c14, c13, c12, c11, c10, c9, c8), poly8dd_b(x, c7, c6, c5, c4, c3, c2, c1, c0)); +} +static INLINE CONST VECTOR_CC vdouble2 poly16dd_b(vdouble2 x, double2 c15, double2 c14, double2 c13, double2 c12, double2 c11, double2 c10, double2 c9, double2 c8, + double2 c7, double2 c6, double2 c5, double2 c4, double2 c3, double2 c2, double2 c1, double2 c0) { + return ddmla_vd2_vd2_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(x))), poly8dd_b(x, c15, c14, c13, c12, c11, c10, c9, c8), poly8dd_b(x, c7, c6, c5, c4, c3, c2, c1, c0)); +} +static INLINE CONST VECTOR_CC vdouble2 poly16dd(vdouble2 x, vdouble c15, double2 c14, double2 c13, double2 c12, double2 c11, double2 c10, double2 c9, double2 c8, + double2 c7, double2 c6, double2 c5, double2 c4, double2 c3, double2 c2, double2 c1, double2 c0) { + return ddmla_vd2_vd2_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(x))), poly8dd(x, c15, c14, c13, c12, c11, c10, c9, c8), poly8dd_b(x, c7, c6, c5, c4, c3, c2, c1, c0)); +} +static INLINE CONST VECTOR_CC vdouble2 poly17dd_b(vdouble2 x, double2 c16, + double2 c15, double2 c14, double2 c13, double2 c12, double2 c11, double2 c10, double2 c9, double2 c8, + double2 c7, double2 c6, double2 c5, double2 c4, double2 c3, double2 c2, double2 c1, double2 c0) { + return ddmla_vd2_vd2_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(x)))), vcast_vd2_d2(c16), + poly16dd_b(x, c15, c14, c13, c12, c11, c10, c9, c8, c7, c6, c5, c4, c3, c2, c1, c0)); +} +static INLINE CONST VECTOR_CC vdouble2 poly17dd(vdouble2 x, vdouble c16, + double2 c15, double2 c14, double2 c13, double2 c12, double2 c11, double2 c10, double2 c9, double2 c8, + double2 c7, double2 c6, double2 c5, double2 c4, double2 c3, double2 c2, double2 c1, double2 c0) { + return ddmla_vd2_vd2_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(x)))), vcast_vd2_vd_vd(c16, vcast_vd_d(0)), + poly16dd_b(x, c15, c14, c13, c12, c11, c10, c9, c8, c7, c6, c5, c4, c3, c2, c1, c0)); +} +static INLINE CONST VECTOR_CC vdouble2 poly18dd_b(vdouble2 x, double2 c17, double2 c16, + double2 c15, double2 c14, double2 c13, double2 c12, double2 c11, double2 c10, double2 c9, double2 c8, + double2 c7, double2 c6, double2 c5, double2 c4, double2 c3, double2 c2, double2 c1, double2 c0) { + return ddmla_vd2_vd2_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(x)))), poly2dd_b(x, c17, c16), + poly16dd_b(x, c15, c14, c13, c12, c11, c10, c9, c8, c7, c6, c5, c4, c3, c2, c1, c0)); +} +static INLINE CONST VECTOR_CC vdouble2 poly18dd(vdouble2 x, vdouble c17, double2 c16, + double2 c15, double2 c14, double2 c13, double2 c12, double2 c11, double2 c10, double2 c9, double2 c8, + double2 c7, double2 c6, double2 c5, double2 c4, double2 c3, double2 c2, double2 c1, double2 c0) { + return ddmla_vd2_vd2_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(x)))), poly2dd(x, c17, c16), + poly16dd_b(x, c15, c14, c13, c12, c11, c10, c9, c8, c7, c6, c5, c4, c3, c2, c1, c0)); +} +static INLINE CONST VECTOR_CC vdouble2 poly19dd_b(vdouble2 x, double2 c18, double2 c17, double2 c16, + double2 c15, double2 c14, double2 c13, double2 c12, double2 c11, double2 c10, double2 c9, double2 c8, + double2 c7, double2 c6, double2 c5, double2 c4, double2 c3, double2 c2, double2 c1, double2 c0) { + return ddmla_vd2_vd2_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(x)))), poly3dd_b(x, c18, c17, c16), + poly16dd_b(x, c15, c14, c13, c12, c11, c10, c9, c8, c7, c6, c5, c4, c3, c2, c1, c0)); +} +static INLINE CONST VECTOR_CC vdouble2 poly19dd(vdouble2 x, vdouble c18, double2 c17, double2 c16, + double2 c15, double2 c14, double2 c13, double2 c12, double2 c11, double2 c10, double2 c9, double2 c8, + double2 c7, double2 c6, double2 c5, double2 c4, double2 c3, double2 c2, double2 c1, double2 c0) { + return ddmla_vd2_vd2_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(x)))), poly3dd(x, c18, c17, c16), + poly16dd_b(x, c15, c14, c13, c12, c11, c10, c9, c8, c7, c6, c5, c4, c3, c2, c1, c0)); +} +static INLINE CONST VECTOR_CC vdouble2 poly20dd_b(vdouble2 x, double2 c19, double2 c18, double2 c17, double2 c16, + double2 c15, double2 c14, double2 c13, double2 c12, double2 c11, double2 c10, double2 c9, double2 c8, + double2 c7, double2 c6, double2 c5, double2 c4, double2 c3, double2 c2, double2 c1, double2 c0) { + return ddmla_vd2_vd2_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(x)))), poly4dd_b(x, c19, c18, c17, c16), + poly16dd_b(x, c15, c14, c13, c12, c11, c10, c9, c8, c7, c6, c5, c4, c3, c2, c1, c0)); +} +static INLINE CONST VECTOR_CC vdouble2 poly20dd(vdouble2 x, vdouble c19, double2 c18, double2 c17, double2 c16, + double2 c15, double2 c14, double2 c13, double2 c12, double2 c11, double2 c10, double2 c9, double2 c8, + double2 c7, double2 c6, double2 c5, double2 c4, double2 c3, double2 c2, double2 c1, double2 c0) { + return ddmla_vd2_vd2_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(x)))), poly4dd(x, c19, c18, c17, c16), + poly16dd_b(x, c15, c14, c13, c12, c11, c10, c9, c8, c7, c6, c5, c4, c3, c2, c1, c0)); +} +static INLINE CONST VECTOR_CC vdouble2 poly21dd_b(vdouble2 x, double2 c20, double2 c19, double2 c18, double2 c17, double2 c16, + double2 c15, double2 c14, double2 c13, double2 c12, double2 c11, double2 c10, double2 c9, double2 c8, + double2 c7, double2 c6, double2 c5, double2 c4, double2 c3, double2 c2, double2 c1, double2 c0) { + return ddmla_vd2_vd2_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(x)))), poly5dd_b(x, c20, c19, c18, c17, c16), + poly16dd_b(x, c15, c14, c13, c12, c11, c10, c9, c8, c7, c6, c5, c4, c3, c2, c1, c0)); +} +static INLINE CONST VECTOR_CC vdouble2 poly21dd(vdouble2 x, vdouble c20, double2 c19, double2 c18, double2 c17, double2 c16, + double2 c15, double2 c14, double2 c13, double2 c12, double2 c11, double2 c10, double2 c9, double2 c8, + double2 c7, double2 c6, double2 c5, double2 c4, double2 c3, double2 c2, double2 c1, double2 c0) { + return ddmla_vd2_vd2_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(x)))), poly5dd(x, c20, c19, c18, c17, c16), + poly16dd_b(x, c15, c14, c13, c12, c11, c10, c9, c8, c7, c6, c5, c4, c3, c2, c1, c0)); +} +static INLINE CONST VECTOR_CC vdouble2 poly22dd_b(vdouble2 x, double2 c21, double2 c20, double2 c19, double2 c18, double2 c17, double2 c16, + double2 c15, double2 c14, double2 c13, double2 c12, double2 c11, double2 c10, double2 c9, double2 c8, + double2 c7, double2 c6, double2 c5, double2 c4, double2 c3, double2 c2, double2 c1, double2 c0) { + return ddmla_vd2_vd2_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(x)))), poly6dd_b(x, c21, c20, c19, c18, c17, c16), + poly16dd_b(x, c15, c14, c13, c12, c11, c10, c9, c8, c7, c6, c5, c4, c3, c2, c1, c0)); +} +static INLINE CONST VECTOR_CC vdouble2 poly22dd(vdouble2 x, vdouble c21, double2 c20, double2 c19, double2 c18, double2 c17, double2 c16, + double2 c15, double2 c14, double2 c13, double2 c12, double2 c11, double2 c10, double2 c9, double2 c8, + double2 c7, double2 c6, double2 c5, double2 c4, double2 c3, double2 c2, double2 c1, double2 c0) { + return ddmla_vd2_vd2_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(x)))), poly6dd(x, c21, c20, c19, c18, c17, c16), + poly16dd_b(x, c15, c14, c13, c12, c11, c10, c9, c8, c7, c6, c5, c4, c3, c2, c1, c0)); +} +static INLINE CONST VECTOR_CC vdouble2 poly23dd_b(vdouble2 x, double2 c22, double2 c21, double2 c20, double2 c19, double2 c18, double2 c17, double2 c16, + double2 c15, double2 c14, double2 c13, double2 c12, double2 c11, double2 c10, double2 c9, double2 c8, + double2 c7, double2 c6, double2 c5, double2 c4, double2 c3, double2 c2, double2 c1, double2 c0) { + return ddmla_vd2_vd2_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(x)))), poly7dd_b(x, c22, c21, c20, c19, c18, c17, c16), + poly16dd_b(x, c15, c14, c13, c12, c11, c10, c9, c8, c7, c6, c5, c4, c3, c2, c1, c0)); +} +static INLINE CONST VECTOR_CC vdouble2 poly23dd(vdouble2 x, vdouble c22, double2 c21, double2 c20, double2 c19, double2 c18, double2 c17, double2 c16, + double2 c15, double2 c14, double2 c13, double2 c12, double2 c11, double2 c10, double2 c9, double2 c8, + double2 c7, double2 c6, double2 c5, double2 c4, double2 c3, double2 c2, double2 c1, double2 c0) { + return ddmla_vd2_vd2_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(x)))), poly7dd(x, c22, c21, c20, c19, c18, c17, c16), + poly16dd_b(x, c15, c14, c13, c12, c11, c10, c9, c8, c7, c6, c5, c4, c3, c2, c1, c0)); +} +static INLINE CONST VECTOR_CC vdouble2 poly24dd_b(vdouble2 x, double2 c23, double2 c22, double2 c21, double2 c20, double2 c19, double2 c18, double2 c17, double2 c16, + double2 c15, double2 c14, double2 c13, double2 c12, double2 c11, double2 c10, double2 c9, double2 c8, + double2 c7, double2 c6, double2 c5, double2 c4, double2 c3, double2 c2, double2 c1, double2 c0) { + return ddmla_vd2_vd2_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(x)))), poly8dd_b(x, c23, c22, c21, c20, c19, c18, c17, c16), + poly16dd_b(x, c15, c14, c13, c12, c11, c10, c9, c8, c7, c6, c5, c4, c3, c2, c1, c0)); +} +static INLINE CONST VECTOR_CC vdouble2 poly24dd(vdouble2 x, vdouble c23, double2 c22, double2 c21, double2 c20, double2 c19, double2 c18, double2 c17, double2 c16, + double2 c15, double2 c14, double2 c13, double2 c12, double2 c11, double2 c10, double2 c9, double2 c8, + double2 c7, double2 c6, double2 c5, double2 c4, double2 c3, double2 c2, double2 c1, double2 c0) { + return ddmla_vd2_vd2_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(x)))), poly8dd(x, c23, c22, c21, c20, c19, c18, c17, c16), + poly16dd_b(x, c15, c14, c13, c12, c11, c10, c9, c8, c7, c6, c5, c4, c3, c2, c1, c0)); +} +static INLINE CONST VECTOR_CC vdouble2 poly25dd_b(vdouble2 x, double2 c24, + double2 c23, double2 c22, double2 c21, double2 c20, double2 c19, double2 c18, double2 c17, double2 c16, + double2 c15, double2 c14, double2 c13, double2 c12, double2 c11, double2 c10, double2 c9, double2 c8, + double2 c7, double2 c6, double2 c5, double2 c4, double2 c3, double2 c2, double2 c1, double2 c0) { + return ddmla_vd2_vd2_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(x)))), poly9dd_b(x, c24, c23, c22, c21, c20, c19, c18, c17, c16), + poly16dd_b(x, c15, c14, c13, c12, c11, c10, c9, c8, c7, c6, c5, c4, c3, c2, c1, c0)); +} +static INLINE CONST VECTOR_CC vdouble2 poly25dd(vdouble2 x, vdouble c24, + double2 c23, double2 c22, double2 c21, double2 c20, double2 c19, double2 c18, double2 c17, double2 c16, + double2 c15, double2 c14, double2 c13, double2 c12, double2 c11, double2 c10, double2 c9, double2 c8, + double2 c7, double2 c6, double2 c5, double2 c4, double2 c3, double2 c2, double2 c1, double2 c0) { + return ddmla_vd2_vd2_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(x)))), poly9dd(x, c24, c23, c22, c21, c20, c19, c18, c17, c16), + poly16dd_b(x, c15, c14, c13, c12, c11, c10, c9, c8, c7, c6, c5, c4, c3, c2, c1, c0)); +} +static INLINE CONST VECTOR_CC vdouble2 poly26dd_b(vdouble2 x, double2 c25, double2 c24, + double2 c23, double2 c22, double2 c21, double2 c20, double2 c19, double2 c18, double2 c17, double2 c16, + double2 c15, double2 c14, double2 c13, double2 c12, double2 c11, double2 c10, double2 c9, double2 c8, + double2 c7, double2 c6, double2 c5, double2 c4, double2 c3, double2 c2, double2 c1, double2 c0) { + return ddmla_vd2_vd2_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(x)))), poly10dd_b(x, c25, c24, c23, c22, c21, c20, c19, c18, c17, c16), + poly16dd_b(x, c15, c14, c13, c12, c11, c10, c9, c8, c7, c6, c5, c4, c3, c2, c1, c0)); +} +static INLINE CONST VECTOR_CC vdouble2 poly26dd(vdouble2 x, vdouble c25, double2 c24, + double2 c23, double2 c22, double2 c21, double2 c20, double2 c19, double2 c18, double2 c17, double2 c16, + double2 c15, double2 c14, double2 c13, double2 c12, double2 c11, double2 c10, double2 c9, double2 c8, + double2 c7, double2 c6, double2 c5, double2 c4, double2 c3, double2 c2, double2 c1, double2 c0) { + return ddmla_vd2_vd2_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(x)))), poly10dd(x, c25, c24, c23, c22, c21, c20, c19, c18, c17, c16), + poly16dd_b(x, c15, c14, c13, c12, c11, c10, c9, c8, c7, c6, c5, c4, c3, c2, c1, c0)); +} +static INLINE CONST VECTOR_CC vdouble2 poly27dd_b(vdouble2 x, double2 c26, double2 c25, double2 c24, + double2 c23, double2 c22, double2 c21, double2 c20, double2 c19, double2 c18, double2 c17, double2 c16, + double2 c15, double2 c14, double2 c13, double2 c12, double2 c11, double2 c10, double2 c9, double2 c8, + double2 c7, double2 c6, double2 c5, double2 c4, double2 c3, double2 c2, double2 c1, double2 c0) { + return ddmla_vd2_vd2_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(x)))), poly11dd_b(x, c26, c25, c24, c23, c22, c21, c20, c19, c18, c17, c16), + poly16dd_b(x, c15, c14, c13, c12, c11, c10, c9, c8, c7, c6, c5, c4, c3, c2, c1, c0)); +} +static INLINE CONST VECTOR_CC vdouble2 poly27dd(vdouble2 x, vdouble c26, double2 c25, double2 c24, + double2 c23, double2 c22, double2 c21, double2 c20, double2 c19, double2 c18, double2 c17, double2 c16, + double2 c15, double2 c14, double2 c13, double2 c12, double2 c11, double2 c10, double2 c9, double2 c8, + double2 c7, double2 c6, double2 c5, double2 c4, double2 c3, double2 c2, double2 c1, double2 c0) { + return ddmla_vd2_vd2_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(ddsqu_vd2_vd2(x)))), poly11dd(x, c26, c25, c24, c23, c22, c21, c20, c19, c18, c17, c16), + poly16dd_b(x, c15, c14, c13, c12, c11, c10, c9, c8, c7, c6, c5, c4, c3, c2, c1, c0)); +} + +// + +#ifndef SLEEF_ENABLE_CUDA +typedef struct { + double x, y, z; +} double3; +#endif + +static INLINE CONST VECTOR_CC vdouble3 cast_vd3_d3(double3 td) { + return vd3setxyz_vd3_vd_vd_vd(vcast_vd_d(td.x), vcast_vd_d(td.y), vcast_vd_d(td.z)); +} + +static INLINE CONST double3 td(double x, double y, double z) { + double3 ret = { x, y, z }; + return ret; +} + +static INLINE CONST VECTOR_CC vdouble3 mla_vd3_vd3_vd3_vd3(vdouble3 x, vdouble3 y, vdouble3 z) { return add2_vd3_vd3_vd3(z, mul_vd3_vd3_vd3(x, y)); } +static INLINE CONST VECTOR_CC vdouble3 poly2td_b(vdouble3 x, double3 c1, double3 c0) { + if (c0.y == 0 && c0.z == 0) { + if (c1.x == 1 && c1.y == 0 && c1.z == 0) return add2_vd3_vd_vd3(vcast_vd_d(c0.x), x); + return add2_vd3_vd_vd3(vcast_vd_d(c0.x), mul_vd3_vd3_vd3(x, cast_vd3_d3(c1))); + } + return mla_vd3_vd3_vd3_vd3(x, cast_vd3_d3(c1), cast_vd3_d3(c0)); +} +static INLINE CONST VECTOR_CC vdouble3 poly2td(vdouble3 x, vdouble2 c1, double3 c0) { + return add2_vd3_vd3_vd3(cast_vd3_d3(c0), mul_vd3_vd3_vd2(x, c1)); +} +static INLINE CONST VECTOR_CC vdouble3 poly3td_b(vdouble3 x, double3 c2, double3 c1, double3 c0) { + return mla_vd3_vd3_vd3_vd3(squ_vd3_vd3(x), cast_vd3_d3(c2), poly2td_b(x, c1, c0)); +} +static INLINE CONST VECTOR_CC vdouble3 poly3td(vdouble3 x, vdouble2 c2, double3 c1, double3 c0) { + return add2_vd3_vd3_vd3(poly2td_b(x, c1, c0), mul_vd3_vd3_vd2(squ_vd3_vd3(x), c2)); +} +static INLINE CONST VECTOR_CC vdouble3 poly4td_b(vdouble3 x, double3 c3, double3 c2, double3 c1, double3 c0) { + return mla_vd3_vd3_vd3_vd3(squ_vd3_vd3(x), poly2td_b(x, c3, c2), poly2td_b(x, c1, c0)); +} +static INLINE CONST VECTOR_CC vdouble3 poly4td(vdouble3 x, vdouble2 c3, double3 c2, double3 c1, double3 c0) { + return mla_vd3_vd3_vd3_vd3(squ_vd3_vd3(x), poly2td(x, c3, c2), poly2td_b(x, c1, c0)); +} +static INLINE CONST VECTOR_CC vdouble3 poly5td_b(vdouble3 x, double3 c4, double3 c3, double3 c2, double3 c1, double3 c0) { + return mla_vd3_vd3_vd3_vd3(squ_vd3_vd3(squ_vd3_vd3(x)), cast_vd3_d3(c4), poly4td_b(x, c3, c2, c1, c0)); +} +static INLINE CONST VECTOR_CC vdouble3 poly5td(vdouble3 x, vdouble2 c4, double3 c3, double3 c2, double3 c1, double3 c0) { + return add2_vd3_vd3_vd3(poly4td_b(x, c3, c2, c1, c0), mul_vd3_vd3_vd2(squ_vd3_vd3(squ_vd3_vd3(x)), c4)); +} +static INLINE CONST VECTOR_CC vdouble3 poly6td_b(vdouble3 x, double3 c5, double3 c4, double3 c3, double3 c2, double3 c1, double3 c0) { + return mla_vd3_vd3_vd3_vd3(squ_vd3_vd3(squ_vd3_vd3(x)), poly2td_b(x, c5, c4), poly4td_b(x, c3, c2, c1, c0)); +} +static INLINE CONST VECTOR_CC vdouble3 poly6td(vdouble3 x, vdouble2 c5, double3 c4, double3 c3, double3 c2, double3 c1, double3 c0) { + return mla_vd3_vd3_vd3_vd3(squ_vd3_vd3(squ_vd3_vd3(x)), poly2td(x, c5, c4), poly4td_b(x, c3, c2, c1, c0)); +} +static INLINE CONST VECTOR_CC vdouble3 poly7td_b(vdouble3 x, double3 c6, double3 c5, double3 c4, double3 c3, double3 c2, double3 c1, double3 c0) { + return mla_vd3_vd3_vd3_vd3(squ_vd3_vd3(squ_vd3_vd3(x)), poly3td_b(x, c6, c5, c4), poly4td_b(x, c3, c2, c1, c0)); +} +static INLINE CONST VECTOR_CC vdouble3 poly7td(vdouble3 x, vdouble2 c6, double3 c5, double3 c4, double3 c3, double3 c2, double3 c1, double3 c0) { + return mla_vd3_vd3_vd3_vd3(squ_vd3_vd3(squ_vd3_vd3(x)), poly3td(x, c6, c5, c4), poly4td_b(x, c3, c2, c1, c0)); +} +static INLINE CONST VECTOR_CC vdouble3 poly8td_b(vdouble3 x, double3 c7, double3 c6, double3 c5, double3 c4, double3 c3, double3 c2, double3 c1, double3 c0) { + return mla_vd3_vd3_vd3_vd3(squ_vd3_vd3(squ_vd3_vd3(x)), poly4td_b(x, c7, c6, c5, c4), poly4td_b(x, c3, c2, c1, c0)); +} +static INLINE CONST VECTOR_CC vdouble3 poly8td(vdouble3 x, vdouble2 c7, double3 c6, double3 c5, double3 c4, double3 c3, double3 c2, double3 c1, double3 c0) { + return mla_vd3_vd3_vd3_vd3(squ_vd3_vd3(squ_vd3_vd3(x)), poly4td(x, c7, c6, c5, c4), poly4td_b(x, c3, c2, c1, c0)); +} + +// TDX functions ------------------------------------------------------------------------------------------------------------ + +// TDX Cast operators + +static INLINE CONST VECTOR_CC tdx cast_tdx_vd(vdouble d) { + tdx r = tdxsetexyz_tdx_vm_vd_vd_vd(vilogbk_vm_vd(d), d, vcast_vd_d(0), vcast_vd_d(0)); + r = tdxsetx_tdx_tdx_vd(r, vsel_vd_vo_vd_vd(visnonfinite_vo_vd(tdxgetd3x_vd_tdx(r)), tdxgetd3x_vd_tdx(r), vldexp2_vd_vd_vm(tdxgetd3x_vd_tdx(r), vneg64_vm_vm(tdxgete_vm_tdx(r))))); + r = tdxsete_tdx_tdx_vm(r, vadd64_vm_vm_vm(tdxgete_vm_tdx(r), vcast_vm_i64(16383))); + return r; +} + +static INLINE CONST VECTOR_CC tdx cast_tdx_d(double d) { + return cast_tdx_vd(vcast_vd_d(d)); +} + +static INLINE CONST VECTOR_CC tdx cast_tdx_vd3(vdouble3 d) { + vmask re = vilogbk_vm_vd(vd3getx_vd_vd3(d)); + vdouble3 rd3 = vd3setxyz_vd3_vd_vd_vd(vldexp2_vd_vd_vm(vd3getx_vd_vd3(d), vneg64_vm_vm(re)), + vldexp2_vd_vd_vm(vd3gety_vd_vd3(d), vneg64_vm_vm(re)), + vldexp2_vd_vd_vm(vd3getz_vd_vd3(d), vneg64_vm_vm(re))); + re = vadd64_vm_vm_vm(re, vcast_vm_i64(16383)); + return tdxseted3_tdx_vm_vd3(re, rd3); +} + +static INLINE CONST VECTOR_CC tdx cast_tdx_d_d_d(double d0, double d1, double d2) { + return cast_tdx_vd3(cast_vd3_d_d_d(d0, d1, d2)); +} + +static INLINE CONST VECTOR_CC tdx fastcast_tdx_vd3(vdouble3 d) { + vmask re = vadd64_vm_vm_vm(vilogb2k_vm_vd(vd3getx_vd_vd3(d)), vcast_vm_i64(16383)); + vdouble t = vldexp3_vd_vd_vm(vcast_vd_d(0.5), vneg64_vm_vm(re)); + return tdxsetexyz_tdx_vm_vd_vd_vd(re, + vmul_vd_vd_vd(vd3getx_vd_vd3(d), t), + vmul_vd_vd_vd(vd3gety_vd_vd3(d), t), + vmul_vd_vd_vd(vd3getz_vd_vd3(d), t)); +} + +static INLINE CONST VECTOR_CC vdouble cast_vd_tdx(tdx t) { + vdouble ret = vldexp2_vd_vd_vm(tdxgetd3x_vd_tdx(t), vadd64_vm_vm_vm(tdxgete_vm_tdx(t), vcast_vm_i64(-16383))); + + vopmask o = vor_vo_vo_vo(veq_vo_vd_vd(tdxgetd3x_vd_tdx(t), vcast_vd_d(0)), + vlt64_vo_vm_vm(tdxgete_vm_tdx(t), vcast_vm_i64(16383 - 0x500))); + ret = vsel_vd_vo_vd_vd(o, vmulsign_vd_vd_vd(vcast_vd_d(0), tdxgetd3x_vd_tdx(t)), ret); + + o = vgt64_vo_vm_vm(tdxgete_vm_tdx(t), vcast_vm_i64(16383 + 0x400)); + ret = vsel_vd_vo_vd_vd(o, vmulsign_vd_vd_vd(vcast_vd_d(SLEEF_INFINITY), tdxgetd3x_vd_tdx(t)), ret); + + return vsel_vd_vo_vd_vd(visnonfinite_vo_vd(tdxgetd3x_vd_tdx(t)), tdxgetd3x_vd_tdx(t), ret); +} + +static INLINE CONST VECTOR_CC vdouble3 cast_vd3_tdx(tdx t) { + vmask e = vadd64_vm_vm_vm(tdxgete_vm_tdx(t), vcast_vm_i64(-16383)); + vdouble3 r = cast_vd3_vd_vd_vd(vldexp2_vd_vd_vm(tdxgetd3x_vd_tdx(t), e), + vldexp2_vd_vd_vm(tdxgetd3y_vd_tdx(t), e), + vldexp2_vd_vd_vm(tdxgetd3z_vd_tdx(t), e)); + + vopmask o = vor_vo_vo_vo(veq_vo_vd_vd(tdxgetd3x_vd_tdx(t), vcast_vd_d(0)), + vlt64_vo_vm_vm(tdxgete_vm_tdx(t), vcast_vm_i64(16383 - 0x500))); + r = sel_vd3_vo_vd3_vd3(o, cast_vd3_vd_vd_vd(vmulsign_vd_vd_vd(vcast_vd_d(0), tdxgetd3x_vd_tdx(t)), vcast_vd_d(0), vcast_vd_d(0)), r); + + o = vgt64_vo_vm_vm(tdxgete_vm_tdx(t), vcast_vm_i64(16383 + 0x400)); + r = sel_vd3_vo_vd3_vd3(o, cast_vd3_vd_vd_vd(vmulsign_vd_vd_vd(vcast_vd_d(SLEEF_INFINITY), tdxgetd3x_vd_tdx(t)), vcast_vd_d(0), vcast_vd_d(0)), r); + + r = sel_vd3_vo_vd3_vd3(visnonfinite_vo_vd(tdxgetd3x_vd_tdx(t)), tdxgetd3_vd3_tdx(t), r); + + return r; +} + +// TDX Compare and select functions + +static INLINE CONST VECTOR_CC tdx sel_tdx_vo_tdx_tdx(vopmask o, tdx x, tdx y) { + return tdxseted3_tdx_vm_vd3(vsel_vm_vo64_vm_vm(o, tdxgete_vm_tdx(x), tdxgete_vm_tdx(y)), + sel_vd3_vo_vd3_vd3(o, tdxgetd3_vd3_tdx(x), tdxgetd3_vd3_tdx(y))); +} + +static INLINE CONST VECTOR_CC vmask cmp_vm_tdx_tdx(tdx t0, tdx t1) { + vmask r = vcast_vm_i64(0); + r = vsel_vm_vo64_vm_vm(vlt_vo_vd_vd(tdxgetd3z_vd_tdx(t0), tdxgetd3z_vd_tdx(t1)), vcast_vm_i64(-1), r); + r = vsel_vm_vo64_vm_vm(vgt_vo_vd_vd(tdxgetd3z_vd_tdx(t0), tdxgetd3z_vd_tdx(t1)), vcast_vm_i64( 1), r); + r = vsel_vm_vo64_vm_vm(vlt_vo_vd_vd(tdxgetd3y_vd_tdx(t0), tdxgetd3y_vd_tdx(t1)), vcast_vm_i64(-1), r); + r = vsel_vm_vo64_vm_vm(vgt_vo_vd_vd(tdxgetd3y_vd_tdx(t0), tdxgetd3y_vd_tdx(t1)), vcast_vm_i64( 1), r); + r = vsel_vm_vo64_vm_vm(vlt_vo_vd_vd(tdxgetd3x_vd_tdx(t0), tdxgetd3x_vd_tdx(t1)), vcast_vm_i64(-1), r); + r = vsel_vm_vo64_vm_vm(vgt_vo_vd_vd(tdxgetd3x_vd_tdx(t0), tdxgetd3x_vd_tdx(t1)), vcast_vm_i64( 1), r); + r = vsel_vm_vo64_vm_vm(vand_vo_vo_vo(vgt64_vo_vm_vm(tdxgete_vm_tdx(t1), tdxgete_vm_tdx(t0)), + veq64_vo_vm_vm(vsignbit_vm_vd(tdxgetd3x_vd_tdx(t0)), vsignbit_vm_vd(tdxgetd3x_vd_tdx(t1)))), + vsel_vm_vo64_vm_vm(vsignbit_vo_vd(tdxgetd3x_vd_tdx(t0)), vcast_vm_i64(+1), vcast_vm_i64(-1)), r); + r = vsel_vm_vo64_vm_vm(vand_vo_vo_vo(vgt64_vo_vm_vm(tdxgete_vm_tdx(t0), tdxgete_vm_tdx(t1)), + veq64_vo_vm_vm(vsignbit_vm_vd(tdxgetd3x_vd_tdx(t0)), vsignbit_vm_vd(tdxgetd3x_vd_tdx(t1)))), + vsel_vm_vo64_vm_vm(vsignbit_vo_vd(tdxgetd3x_vd_tdx(t0)), vcast_vm_i64(-1), vcast_vm_i64(+1)), r); + r = vsel_vm_vo64_vm_vm(vand_vo_vo_vo(veq_vo_vd_vd(tdxgetd3x_vd_tdx(t0), vcast_vd_d(0)), veq_vo_vd_vd(tdxgetd3x_vd_tdx(t1), vcast_vd_d(0))), + vcast_vm_i64( 0), r); + r = vsel_vm_vo64_vm_vm(vand_vo_vo_vo(vlt_vo_vd_vd(tdxgetd3x_vd_tdx(t0), vcast_vd_d(0)), vge_vo_vd_vd(tdxgetd3x_vd_tdx(t1), vcast_vd_d(0))), + vcast_vm_i64(-1), r); + r = vsel_vm_vo64_vm_vm(vand_vo_vo_vo(vge_vo_vd_vd(tdxgetd3x_vd_tdx(t0), vcast_vd_d(0)), vlt_vo_vd_vd(tdxgetd3x_vd_tdx(t1), vcast_vd_d(0))), + vcast_vm_i64( 1), r); + return r; +} + +static INLINE CONST VECTOR_CC vopmask signbit_vo_tdx(tdx x) { + return vsignbit_vo_vd(tdxgetd3x_vd_tdx(x)); +} + +static INLINE CONST VECTOR_CC vopmask isnan_vo_tdx(tdx x) { + return visnan_vo_vd(tdxgetd3x_vd_tdx(x)); +} + +static INLINE CONST VECTOR_CC vopmask isinf_vo_tdx(tdx x) { + return visinf_vo_vd(tdxgetd3x_vd_tdx(x)); +} + +static INLINE CONST VECTOR_CC vopmask iszero_vo_tdx(tdx x) { + return vandnot_vo_vo_vo(visnan_vo_vd(tdxgetd3x_vd_tdx(x)), veq_vo_vd_vd(tdxgetd3x_vd_tdx(x), vcast_vd_d(0))); +} + +static INLINE CONST VECTOR_CC vopmask eq_vo_tdx_tdx(tdx x, tdx y) { + return vandnot_vo_vo_vo(visnan_vo_vd(tdxgetd3x_vd_tdx(x)), veq64_vo_vm_vm(cmp_vm_tdx_tdx(x, y), vcast_vm_i64(0))); +} + +static INLINE CONST VECTOR_CC vopmask neq_vo_tdx_tdx(tdx x, tdx y) { + return vandnot_vo_vo_vo(visnan_vo_vd(tdxgetd3x_vd_tdx(x)), vnot_vo64_vo64(veq64_vo_vm_vm(cmp_vm_tdx_tdx(x, y), vcast_vm_i64(0)))); +} + +static INLINE CONST VECTOR_CC vopmask gt_vo_tdx_tdx(tdx x, tdx y) { + return vandnot_vo_vo_vo(visnan_vo_vd(tdxgetd3x_vd_tdx(x)), vgt64_vo_vm_vm(cmp_vm_tdx_tdx(x, y), vcast_vm_i64(0))); +} + +static INLINE CONST VECTOR_CC vopmask lt_vo_tdx_tdx(tdx x, tdx y) { + return vandnot_vo_vo_vo(visnan_vo_vd(tdxgetd3x_vd_tdx(x)), vgt64_vo_vm_vm(cmp_vm_tdx_tdx(y, x), vcast_vm_i64(0))); +} + +static INLINE CONST VECTOR_CC vopmask ge_vo_tdx_tdx(tdx x, tdx y) { + return vandnot_vo_vo_vo(visnan_vo_vd(tdxgetd3x_vd_tdx(x)), vgt64_vo_vm_vm(cmp_vm_tdx_tdx(x, y), vcast_vm_i64(-1))); +} + +static INLINE CONST VECTOR_CC vopmask le_vo_tdx_tdx(tdx x, tdx y) { + return vandnot_vo_vo_vo(visnan_vo_vd(tdxgetd3x_vd_tdx(x)), vgt64_vo_vm_vm(cmp_vm_tdx_tdx(y, x), vcast_vm_i64(-1))); +} + +static INLINE CONST VECTOR_CC vopmask isint_vo_tdx(tdx t) { + vdouble3 d = cast_vd3_tdx(t); + vopmask o0 = vand_vo_vo_vo(vlt64_vo_vm_vm(tdxgete_vm_tdx(t), vcast_vm_i64(15400)), vneq_vo_vd_vd(tdxgetd3x_vd_tdx(t), vcast_vd_d(0))); + vopmask o1 = vor_vo_vo_vo(vgt64_vo_vm_vm(tdxgete_vm_tdx(t), vcast_vm_i64(17000)), + vand_vo_vo_vo(vand_vo_vo_vo(visint_vo_vd(vd3getx_vd_vd3(d)), visint_vo_vd(vd3gety_vd_vd3(d))), + visint_vo_vd(vd3getz_vd_vd3(d)))); + return vandnot_vo_vo_vo(o0, o1); +} + +static INLINE CONST VECTOR_CC vopmask isodd_vo_tdx(tdx t) { + t = tdxsete_tdx_tdx_vm(t, vadd64_vm_vm_vm(tdxgete_vm_tdx(t), vcast_vm_i64(-1))); + return vnot_vo64_vo64(isint_vo_tdx(t)); +} + +// TDX Arithmetic functions + +static INLINE CONST VECTOR_CC tdx neg_tdx_tdx(tdx x) { + return tdxsetd3_tdx_tdx_vd3(x, neg_vd3_vd3(tdxgetd3_vd3_tdx(x))); +} + +static INLINE CONST VECTOR_CC tdx abs_tdx_tdx(tdx x) { + return tdxsetd3_tdx_tdx_vd3(x, abs_vd3_vd3(tdxgetd3_vd3_tdx(x))); +} + +static INLINE CONST VECTOR_CC tdx mulsign_tdx_tdx_vd(tdx x, vdouble d) { + return tdxsetd3_tdx_tdx_vd3(x, mulsign_vd3_vd3_vd(tdxgetd3_vd3_tdx(x), d)); +} + +static INLINE CONST VECTOR_CC vmask ilogb_vm_tdx(tdx t) { + vmask e = vadd64_vm_vm_vm(tdxgete_vm_tdx(t), vcast_vm_i64(-16383)); + e = vsel_vm_vo64_vm_vm(vor_vo_vo_vo(veq_vo_vd_vd(tdxgetd3x_vd_tdx(t), vcast_vd_d(1.0)), vlt_vo_vd_vd(tdxgetd3y_vd_tdx(t), vcast_vd_d(0))), + vadd64_vm_vm_vm(e, vcast_vm_i64(-1)), e); + return e; +} + +static INLINE CONST VECTOR_CC tdx add_tdx_tdx_tdx(tdx dd0, tdx dd1) { // finite numbers only + vmask ed = vsub64_vm_vm_vm(tdxgete_vm_tdx(dd1), tdxgete_vm_tdx(dd0)); + vdouble t = vldexp3_vd_vd_vm(vcast_vd_d(1), ed); + + vdouble3 rd3 = scaleadd2_vd3_vd3_vd3_vd(tdxgetd3_vd3_tdx(dd0), tdxgetd3_vd3_tdx(dd1), t); + tdx r = tdxseted3_tdx_vm_vd3(vilogb2k_vm_vd(vd3getx_vd_vd3(rd3)), rd3); + t = vldexp3_vd_vd_vm(vcast_vd_d(1), vneg64_vm_vm(tdxgete_vm_tdx(r))); + + vopmask o = veq_vo_vd_vd(tdxgetd3x_vd_tdx(dd0), vcast_vd_d(0)); + r = tdxsete_tdx_tdx_vm(r, vsel_vm_vo64_vm_vm(o, tdxgete_vm_tdx(dd1), vadd64_vm_vm_vm(tdxgete_vm_tdx(r), tdxgete_vm_tdx(dd0)))); + r = tdxsetd3_tdx_tdx_vd3(r, scale_vd3_vd3_vd(tdxgetd3_vd3_tdx(r), t)); + + r = sel_tdx_vo_tdx_tdx(vgt64_vo_vm_vm(ed, vcast_vm_i64(200)), dd1, r); + r = sel_tdx_vo_tdx_tdx(vgt64_vo_vm_vm(vcast_vm_i64(-200), ed), dd0, r); + + return r; +} + +static INLINE CONST VECTOR_CC tdx sub_tdx_tdx_tdx(tdx dd0, tdx dd1) { + vmask ed = vsub64_vm_vm_vm(tdxgete_vm_tdx(dd1), tdxgete_vm_tdx(dd0)); + vdouble t = vldexp3_vd_vd_vm(vcast_vd_d(1), ed); + + vdouble3 rd3 = scalesub2_vd3_vd3_vd3_vd(tdxgetd3_vd3_tdx(dd0), tdxgetd3_vd3_tdx(dd1), t); + tdx r = tdxseted3_tdx_vm_vd3(vilogb2k_vm_vd(vd3getx_vd_vd3(rd3)), rd3); + t = vldexp3_vd_vd_vm(vcast_vd_d(1), vneg64_vm_vm(tdxgete_vm_tdx(r))); + + vopmask o = veq_vo_vd_vd(tdxgetd3x_vd_tdx(dd0), vcast_vd_d(0)); + r = tdxsete_tdx_tdx_vm(r, vsel_vm_vo64_vm_vm(o, tdxgete_vm_tdx(dd1), vadd64_vm_vm_vm(tdxgete_vm_tdx(r), tdxgete_vm_tdx(dd0)))); + r = tdxsetd3_tdx_tdx_vd3(r, scale_vd3_vd3_vd(tdxgetd3_vd3_tdx(r), t)); + + r = sel_tdx_vo_tdx_tdx(vgt64_vo_vm_vm(ed, vcast_vm_i64(200)), neg_tdx_tdx(dd1), r); + r = sel_tdx_vo_tdx_tdx(vgt64_vo_vm_vm(vcast_vm_i64(-200), ed), dd0, r); + + return r; +} + +static INLINE CONST VECTOR_CC tdx mul_tdx_tdx_tdx(tdx dd0, tdx dd1) { + vdouble3 rd3 = mul2_vd3_vd3_vd3(tdxgetd3_vd3_tdx(dd0), tdxgetd3_vd3_tdx(dd1)); + tdx r = tdxseted3_tdx_vm_vd3(vilogb2k_vm_vd(vd3getx_vd_vd3(rd3)), rd3); + vdouble t = vldexp3_vd_vd_vm(vcast_vd_d(1), vneg64_vm_vm(tdxgete_vm_tdx(r))); + r = tdxsetd3_tdx_tdx_vd3(r, scale_vd3_vd3_vd(tdxgetd3_vd3_tdx(r), t)); + vmask e = vadd64_vm_vm_vm(vadd64_vm_vm_vm(vadd64_vm_vm_vm(tdxgete_vm_tdx(dd0), tdxgete_vm_tdx(dd1)), vcast_vm_i64(-16383)), tdxgete_vm_tdx(r)); + e = vsel_vm_vo64_vm_vm(veq_vo_vd_vd(tdxgetd3x_vd_tdx(r), vcast_vd_d(0)), vcast_vm_i64(0), e); + r = tdxsete_tdx_tdx_vm(r, e); + return r; +} + +static INLINE CONST VECTOR_CC tdx div_tdx_tdx_tdx(tdx dd0, tdx dd1) { + vdouble3 rd3 = div2_vd3_vd3_vd3(tdxgetd3_vd3_tdx(dd0), tdxgetd3_vd3_tdx(dd1)); + tdx r = tdxseted3_tdx_vm_vd3(vilogb2k_vm_vd(vd3getx_vd_vd3(rd3)), rd3); + vdouble t = vldexp3_vd_vd_vm(vcast_vd_d(1), vneg64_vm_vm(tdxgete_vm_tdx(r))); + r = tdxsetd3_tdx_tdx_vd3(r, scale_vd3_vd3_vd(tdxgetd3_vd3_tdx(r), t)); + vmask e = vadd64_vm_vm_vm(vadd64_vm_vm_vm(vsub64_vm_vm_vm(tdxgete_vm_tdx(dd0), tdxgete_vm_tdx(dd1)), vcast_vm_i64(16383)), tdxgete_vm_tdx(r)); + e = vsel_vm_vo64_vm_vm(veq_vo_vd_vd(tdxgetd3x_vd_tdx(r), vcast_vd_d(0)), vcast_vm_i64(0), e); + r = tdxsete_tdx_tdx_vm(r, e); + return r; +} + +// TDX math functions + +static INLINE CONST VECTOR_CC tdx sqrt_tdx_tdx(tdx dd0) { + vopmask o = veq64_vo_vm_vm(vand_vm_vm_vm(tdxgete_vm_tdx(dd0), vcast_vm_i64(1)), vcast_vm_i64(1)); + dd0 = tdxsetd3_tdx_tdx_vd3(dd0, scale_vd3_vd3_vd(tdxgetd3_vd3_tdx(dd0), vsel_vd_vo_vd_vd(o, vcast_vd_d(1), vcast_vd_d(2)))); + vdouble3 rd3 = sqrt_vd3_vd3(tdxgetd3_vd3_tdx(dd0)); + tdx r = tdxseted3_tdx_vm_vd3(vilogb2k_vm_vd(vd3getx_vd_vd3(rd3)), rd3); + r = tdxsetd3_tdx_tdx_vd3(r, scale_vd3_vd3_vd(tdxgetd3_vd3_tdx(r), vldexp3_vd_vd_vm(vcast_vd_d(1), vneg64_vm_vm(tdxgete_vm_tdx(r))))); + r = tdxsete_tdx_tdx_vm(r, vadd64_vm_vm_vm(vsub64_vm_vm_vm(vsrl64_vm_vm_i(vadd64_vm_vm_vm(tdxgete_vm_tdx(dd0), vcast_vm_i64(16383+(1 << 21))), 1), vcast_vm_i64(1 << 20)), + tdxgete_vm_tdx(r))); + o = vneq_vo_vd_vd(tdxgetd3x_vd_tdx(dd0), vcast_vd_d(0)); + return tdxsetxyz_tdx_tdx_vd_vd_vd(r, + vreinterpret_vd_vm(vand_vm_vo64_vm(o, vreinterpret_vm_vd(tdxgetd3x_vd_tdx(r)))), + vreinterpret_vd_vm(vand_vm_vo64_vm(o, vreinterpret_vm_vd(tdxgetd3y_vd_tdx(r)))), + vreinterpret_vd_vm(vand_vm_vo64_vm(o, vreinterpret_vm_vd(tdxgetd3z_vd_tdx(r))))); +} + +static INLINE CONST VECTOR_CC tdx cbrt_tdx_tdx(tdx d) { + vmask e = vadd64_vm_vm_vm(tdxgete_vm_tdx(d), vcast_vm_i64(-16382)); + d = tdxsete_tdx_tdx_vm(d, vsub64_vm_vm_vm(tdxgete_vm_tdx(d), e)); + + vdouble t = vadd_vd_vd_vd(vcast_vd_vm(e), vcast_vd_d(60000)); + vint qu = vtruncate_vi_vd(vmul_vd_vd_vd(t, vcast_vd_d(1.0/3.0))); + vint re = vtruncate_vi_vd(vsub_vd_vd_vd(t, vmul_vd_vd_vd(vcast_vd_vi(qu), vcast_vd_d(3)))); + + tdx q = cast_tdx_d(1); + q = sel_tdx_vo_tdx_tdx(vcast_vo64_vo32(veq_vo_vi_vi(re, vcast_vi_i(1))), + cast_tdx_d_d_d(1.2599210498948731907, -2.5899333753005069177e-17, 9.7278081561563724019e-34), q); + q = sel_tdx_vo_tdx_tdx(vcast_vo64_vo32(veq_vo_vi_vi(re, vcast_vi_i(2))), + cast_tdx_d_d_d(1.5874010519681995834, -1.0869008194197822986e-16, 9.380961956715938535e-34), q); + q = tdxsete_tdx_tdx_vm(q, vadd64_vm_vm_vm(tdxgete_vm_tdx(q), vcast_vm_vi(vsub_vi_vi_vi(qu, vcast_vi_i(20000))))); + q = mulsign_tdx_tdx_vd(q, tdxgetd3x_vd_tdx(d)); + + vdouble3 d3 = abs_vd3_vd3(cast_vd3_tdx(d)); + + vdouble x = vcast_vd_d(-0.640245898480692909870982), y; + x = vmla_vd_vd_vd_vd(x, vd3getx_vd_vd3(d3), vcast_vd_d(2.96155103020039511818595)); + x = vmla_vd_vd_vd_vd(x, vd3getx_vd_vd3(d3), vcast_vd_d(-5.73353060922947843636166)); + x = vmla_vd_vd_vd_vd(x, vd3getx_vd_vd3(d3), vcast_vd_d(6.03990368989458747961407)); + x = vmla_vd_vd_vd_vd(x, vd3getx_vd_vd3(d3), vcast_vd_d(-3.85841935510444988821632)); + x = vmla_vd_vd_vd_vd(x, vd3getx_vd_vd3(d3), vcast_vd_d(2.2307275302496609725722)); + + y = vmul_vd_vd_vd(x, x); y = vmul_vd_vd_vd(y, y); + x = vsub_vd_vd_vd(x, vmul_vd_vd_vd(vmlapn_vd_vd_vd_vd(vd3getx_vd_vd3(d3), y, x), vcast_vd_d(1.0 / 3.0))); + y = vmul_vd_vd_vd(x, x); y = vmul_vd_vd_vd(y, y); + x = vsub_vd_vd_vd(x, vmul_vd_vd_vd(vmlapn_vd_vd_vd_vd(vd3getx_vd_vd3(d3), y, x), vcast_vd_d(1.0 / 3.0))); + + vdouble2 y2 = ddmul_vd2_vd_vd(x, x); + y2 = ddsqu_vd2_vd2(y2); + vdouble2 x2 = vcast_vd2_vd_vd(vd3getx_vd_vd3(d3), vd3gety_vd_vd3(d3)); + x2 = ddadd_vd2_vd_vd2(x, ddmul_vd2_vd2_vd2(ddadd2_vd2_vd2_vd(ddmul_vd2_vd2_vd2(x2, y2), vneg_vd_vd(x)), + vcast_vd2_d_d(-0.33333333333333331483, -1.8503717077085941313e-17))); + + vdouble3 y3 = mul_vd3_vd3_vd3(d3, mul_vd3_vd2_vd2(x2, x2)); + vdouble3 x3 = cast_vd3_d_d_d(-0.66666666666666662966, -3.7007434154171882626e-17, -2.0543252740130514626e-33); + x3 = mul_vd3_vd3_vd3(mul_vd3_vd3_vd3(x3, y3), add2_vd3_vd_vd3(vcast_vd_d(-1), mul_vd3_vd2_vd3(x2, y3))); + y3 = add2_vd3_vd3_vd3(y3, x3); + + return sel_tdx_vo_tdx_tdx(vor_vo_vo_vo(isinf_vo_tdx(d), iszero_vo_tdx(d)), d, mul_tdx_tdx_tdx(q, cast_tdx_vd3(y3))); +} + +static CONST VECTOR_CC tdi_t rempio2q(tdx a) { + const int N = 8, B = 8; + const int NCOL = 53-B, NROW = (16385+(53-B)*N-106)/NCOL+1; + + vmask e = ilogb_vm_tdx(a); + e = vsel_vm_vo64_vm_vm(vgt64_vo_vm_vm(e, vcast_vm_i64(106)), e, vcast_vm_i64(106)); + a = tdxsete_tdx_tdx_vm(a, vadd64_vm_vm_vm(tdxgete_vm_tdx(a), vsub64_vm_vm_vm(vcast_vm_i64(106), e))); + + vdouble row = vtruncate_vd_vd(vmul_vd_vd_vd(vcast_vd_vm(vsub64_vm_vm_vm(e, vcast_vm_i64(106))), vcast_vd_d(1.0 / NCOL))); // (e - 106) / NCOL; + vdouble col = vsub_vd_vd_vd(vcast_vd_vm(vsub64_vm_vm_vm(e, vcast_vm_i64(106))), vmul_vd_vd_vd(row, vcast_vd_d(NCOL))); // (e - 106) % NCOL; + vint p = vtruncate_vi_vd(vmla_vd_vd_vd_vd(col, vcast_vd_d(NROW), row)); + + vint q = vcast_vi_i(0); + vdouble3 d = normalize_vd3_vd3(cast_vd3_tdx(a)), x = cast_vd3_d_d_d(0, 0, 0); + + for(int i=0;i +#include +#include +#include +#include +#include +#endif + +static const tdx exp10tab[14] = { + { 16386, { 1.25, 0, 0 } }, // 10 + { 16389, { 1.5625, 0, 0 } }, // 100 + { 16396, { 1.220703125, 0, 0 } }, // 10000 + { 16409, { 1.490116119384765625, 0, 0 } }, // 1e+08 + { 16436, { 1.1102230246251565404, 0, 0 } }, // 1e+16 + { 16489, { 1.2325951644078310121, -6.6143055845634601483e-17, 0 } }, // 1e+32 + { 16595, { 1.519290839321567832, -3.2391917291561477915e-17, -1.8687814275678753633e-33 } }, // 1e+64 + { 16808, { 1.1541223272232170594, -8.6760553787903265289e-17, -5.7759618887794337486e-33 } }, // 1e+128 + { 17233, { 1.3319983461951343529, -4.0129993161716667573e-17, -4.1720927621797370111e-34 } }, // 1e+256 + { 18083, { 1.7742195942665728303, 4.9309343678620668082e-17, 1.3386888736008621608e-34 } }, // 1e+512 + { 19784, { 1.5739275843397213528, -1.0848584040002990893e-16, 4.3586291506346591213e-33 } }, // 1e+1024 + { 23186, { 1.2386240203727352238, -5.8476062413608067671e-17, -2.0006771920677486581e-33 } }, // 1e+2048 + { 29989, { 1.5341894638443178689, -1.0973609479387666102e-17, -6.5816871252891901643e-34 } }, // 1e+4096 + { 43596, { 1.1768686554854577153, 3.0579788864750933707e-17, -2.6771867381968692559e-34 } }, // 1e+8192 +}; + +static CONST tdx exp10i(int n) { + int neg = 0; + if (n < 0) { neg = 1; n = -n; } + tdx r = cast_tdx_d(1); + for(int i=0;i<14;i++) + if ((n & (1 << i)) != 0) r = mul_tdx_tdx_tdx(r, exp10tab[i]); + if (neg) r = div_tdx_tdx_tdx(cast_tdx_d(1), r); + return r; +} + +static CONST int ilog10(tdx t) { + int r = 0, p = 1; + if ((int)cmp_vm_tdx_tdx(t, cast_tdx_d(1)) < 0) { + t = div_tdx_tdx_tdx(cast_tdx_d(1), t); + p = -1; + } + for(int i=12;i>=0;i--) { + int c = cmp_vm_tdx_tdx(t, exp10tab[i]); + if ((p > 0 && c >= 0) || (p < 0 && c > 0)) { + t = div_tdx_tdx_tdx(t, exp10tab[i]); + r |= (1 << i); + } + } + if (p < 0) r++; + return r * p; +} + +static CONST vquad xsll128(vquad m, int c) { + if (c == 0) return m; + if (c >= 128) return imdvq_vq_vm_vm(0, 0); + + if (c < 64) { + return imdvq_vq_vm_vm(vsll64_vm_vm_i(vqgetx_vm_vq(m), c), + vor_vm_vm_vm(vsll64_vm_vm_i(vqgety_vm_vq(m), c), vsrl64_vm_vm_i(vqgetx_vm_vq(m), 64 - c))); + } + + return imdvq_vq_vm_vm(0, vsll64_vm_vm_i(vqgetx_vm_vq(m), c - 64)); +} + +static CONST vquad xsrl128(vquad m, int c) { + if (c == 0) return m; + if (c >= 128) return imdvq_vq_vm_vm(0, 0); + + if (c < 64) { + return imdvq_vq_vm_vm(vor_vm_vm_vm(vsrl64_vm_vm_i(vqgetx_vm_vq(m), c), vsll64_vm_vm_i(vqgety_vm_vq(m), 64 - c)), + vsrl64_vm_vm_i(vqgety_vm_vq(m), c)); + } + + return imdvq_vq_vm_vm(vsrl64_vm_vm_i(vqgety_vm_vq(m), c - 64), 0); +} + +static int xclz128(vquad m) { + int n = m.y == 0 ? 128 : 64; + uint64_t u = m.y == 0 ? m.x : m.y, v; + v = u >> 32; if (v != 0) { n -= 32; u = v; } + v = u >> 16; if (v != 0) { n -= 16; u = v; } + v = u >> 8; if (v != 0) { n -= 8; u = v; } + v = u >> 4; if (v != 0) { n -= 4; u = v; } + v = u >> 2; if (v != 0) { n -= 2; u = v; } + v = u >> 1; if (v != 0) return n - 2; + return n - u; +} + +// Float128 string functions + +EXPORT vargquad Sleef_strtoq(const char *str, const char **endptr) { + while(isspace((int)*str)) str++; + const char *p = str; + + int positive = 1, bp = 0, e = 0, mf = 0; + tdx n = cast_tdx_d(0), d = cast_tdx_d(1); + + if (*p == '-') { + positive = 0; + p++; + } else if (*p == '+') p++; + + if (tolower(p[0]) == 'n' && tolower(p[1]) == 'a' && tolower(p[2]) == 'n') { + if (endptr != NULL) *endptr = p+3; + vquad r = { vcast_vm_i64(-1), vcast_vm_u64(UINT64_C(0x7fffffffffffffff)) }; + r.y |= ((uint64_t)!positive) << 63; + return cast_aq_vq(r); + } + + if (tolower(p[0]) == 'i' && tolower(p[1]) == 'n' && tolower(p[2]) == 'f') { + if (endptr != NULL) *endptr = p+3; + if (tolower(p[3]) == 'i' && tolower(p[4]) == 'n' && tolower(p[5]) == 'i' && + tolower(p[6]) == 't' && tolower(p[7]) == 'y' && endptr != NULL) *endptr = p+8; + vquad r = { vcast_vm_i64(0), vcast_vm_u64(UINT64_C(0x7fff000000000000)) }; + r.y |= ((uint64_t)!positive) << 63; + return cast_aq_vq(r); + } + + if (*p == '0' && *(p+1) == 'x') { + p += 2; + vquad m = { 0, 0 }; + int pp = 0; + + while(*p != '\0') { + int d = 0; + if (('0' <= *p && *p <= '9')) { + d = *p++ - '0'; + } else if ('a' <= *p && *p <= 'f') { + d = *p++ - 'a' + 10; + } else if ('A' <= *p && *p <= 'F') { + d = *p++ - 'A' + 10; + } else if (*p == '.') { + if (bp) break; + bp = 1; + p++; + continue; + } else break; + + mf = 1; + m = xsll128(m, 4); + m.x += d; + pp += bp * 4; + if (m.y >> 60) break; + } + + while(('0' <= *p && *p <= '9') || ('a' <= *p && *p <= 'f') || ('A' <= *p && *p <= 'F')) p++; + if (*p == '.' && !bp) p++; + while(('0' <= *p && *p <= '9') || ('a' <= *p && *p <= 'f') || ('A' <= *p && *p <= 'F')) p++; + + if (*p == 'p' || *p == 'P') { + char *q; + e = strtol(p+1, &q, 10); + if (p+1 == q || isspace((int)*(p+1))) { + e = 0; + } else { + p = q; + } + } + + int nsl = xclz128(m) - 15; + e = e - pp - nsl + 0x3fff + 112; + + if (e <= 0 || nsl == 128 - 15) { + nsl += e - 1; + e = 0; + } + + if (nsl >= 0) { + m = xsll128(m, nsl); + } else { + if (-nsl-1 < 64) { + uint64_t u = m.x + ((1ULL) << (-nsl - 1)); + if (u < m.x) m.y++; + m.x = u; + } else { + m.y += ((1ULL) << (-nsl - 1 - 64)); + } + m = xsrl128(m, -nsl); + } + + m.y &= 0x0000ffffffffffff; + m.y |= (((uint64_t)!positive) << 63) | ((((uint64_t)e) & 0x7fff) << 48); + + if (endptr != NULL) *endptr = p; + return cast_aq_vq(m); + } + + while(*p != '\0') { + if ('0' <= *p && *p <= '9') { + n = add_tdx_tdx_tdx(mul_tdx_tdx_tdx(n, cast_tdx_d(10)), cast_tdx_d(*p - '0')); + if (bp) d = mul_tdx_tdx_tdx(d, cast_tdx_d(10)); + p++; + mf = 1; + continue; + } + + if (*p == '.') { + if (bp) break; + bp = 1; + p++; + continue; + } + + if (*p == 'e' || *p == 'E') { + char *q; + e = strtol(p+1, &q, 10); + if (p+1 == q || isspace((int)*(p+1))) { + e = 0; + } else { + p = q; + } + } + + break; + } + + if (!mf && !bp) { + if (endptr != NULL) *endptr = str; + vquad r = { vcast_vm_i64(0), vcast_vm_i64(0) }; + return cast_aq_vq(r); + } + + n = div_tdx_tdx_tdx(n, d); + if (e > 0) n = mul_tdx_tdx_tdx(n, exp10i(+e)); + if (e < 0) n = div_tdx_tdx_tdx(n, exp10i(-e)); + if (!positive) n = neg_tdx_tdx(n); + + if (endptr != NULL) *endptr = p; + + return cast_aq_vq(cast_vq_tdx(n)); +} + +// + +#define FLAG_SIGN (1 << 0) +#define FLAG_BLANK (1 << 1) +#define FLAG_ALT (1 << 2) +#define FLAG_LEFT (1 << 3) +#define FLAG_ZERO (1 << 4) +#define FLAG_UPPER (1 << 5) + +static int snprintquad(char *buf, size_t bufsize, vargquad argvalue, int typespec, int width, int precision, int flags) { + if (width > bufsize) width = bufsize; + + vquad c128 = cast_vq_aq(argvalue); + + char *ptr = buf; + char prefix = 0; + int length = 0, flag_rtz = 0; + + assert(typespec == 'e' || typespec == 'f' || typespec == 'g'); + + if ((c128.y & UINT64_C(0x8000000000000000)) != 0) { + c128.y ^= UINT64_C(0x8000000000000000); + prefix = '-'; + } else if (flags & FLAG_SIGN) { + prefix = '+'; + } else if (flags & FLAG_BLANK) { + prefix = ' '; + } + + tdx value = cast_tdx_vq(c128); + + if (isnan_vo_vq(c128)) { + if (prefix) *ptr++ = prefix; + ptr += snprintf(ptr, buf + bufsize - ptr, (flags & FLAG_UPPER) ? "NAN" : "nan"); + flags &= ~FLAG_ZERO; + } else if (isinf_vo_vq(c128)) { + if (prefix) *ptr++ = prefix; + ptr += snprintf(ptr, buf + bufsize - ptr, (flags & FLAG_UPPER) ? "INF" : "inf"); + flags &= ~FLAG_ZERO; + } else { + if (precision < 0) precision = 6; + if (precision > bufsize/2 - 10) precision = bufsize/2 - 10; + if (typespec == 'g' && precision > 0) precision--; + + tdx rounder = mul_tdx_tdx_tdx(cast_tdx_d(0.5), exp10i(-precision)); + + if (typespec == 'f') value = add_tdx_tdx_tdx(value, rounder); + + int exp = 0, e2 = 0; + if (!iszero_vo_vq(c128)) { + exp = ilog10(value); + value = mul_tdx_tdx_tdx(value, exp10i(-exp)); + } + + int flag_exp = typespec == 'e'; + + if (typespec != 'f') { + value = add_tdx_tdx_tdx(value, rounder); + } + + if ((int)cmp_vm_tdx_tdx(value, cast_tdx_d(10.0)) >= 0) { + value = div_tdx_tdx_tdx(value, cast_tdx_d(10)); + exp++; + } + + if (typespec == 'g') { + flag_rtz = !(flags & FLAG_ALT); + if (exp < -4 || exp > precision) { + typespec = 'e'; + } else { + precision = precision - exp; + typespec = 'f'; + } + } + + if (typespec != 'e') e2 = exp; + + int flag_dp = (precision > 0) | (flags & FLAG_ALT); + + if (prefix) *ptr++ = prefix; + + if (e2 < 0) { + *ptr++ = '0'; + } else { + for(;e2>=0;e2--) { + int digit = (int)cast_vd_tdx(value); + if ((int)cmp_vm_tdx_tdx(value, cast_tdx_d(digit)) < 0) digit--; + if (ptr - buf >= (ptrdiff_t)bufsize-1) { *ptr = '\0'; return -1; } + *ptr++ = digit + '0'; + value = mul_tdx_tdx_tdx(add_tdx_tdx_tdx(value, cast_tdx_d(-digit)), cast_tdx_d(10)); + } + } + + if (flag_dp) { + if (ptr - buf >= (ptrdiff_t)bufsize-1) { *ptr = '\0'; return -1; } + *ptr++ = '.'; + } + + for(e2++;e2 < 0 && precision > 0;precision--, e2++) { + if (ptr - buf >= (ptrdiff_t)bufsize-1) { *ptr = '\0'; return -1; } + *ptr++ = '0'; + } + + while (precision-- > 0) { + int digit = (int)cast_vd_tdx(value); + if ((int)cmp_vm_tdx_tdx(value, cast_tdx_d(digit)) < 0) digit--; + if (ptr - buf >= (ptrdiff_t)bufsize-1) { *ptr = '\0'; return -1; } + *ptr++ = digit + '0'; + value = mul_tdx_tdx_tdx(add_tdx_tdx_tdx(value, cast_tdx_d(-digit)), cast_tdx_d(10)); + } + + if (flag_rtz && flag_dp) { + while(ptr[-1] == '0') *(--ptr) = 0; + assert(ptr > buf); + if (ptr[-1] == '.') *(--ptr) = 0; + } + + if (flag_exp || (typespec == 'e' && exp)) { + if (ptr - buf >= (ptrdiff_t)bufsize-8) { *ptr = '\0'; return -1; } + *ptr++ = (flags & FLAG_UPPER) ? 'E' : 'e'; + if (exp < 0){ + *ptr++ = '-'; exp = -exp; + } else { + *ptr++ = '+'; + } + if (exp >= 1000) { + *ptr++ = exp / 1000 + '0'; + exp %= 1000; + *ptr++ = exp / 100 + '0'; + exp %= 100; + } else if (exp >= 100) { + *ptr++ = exp / 100 + '0'; + exp %= 100; + } + *ptr++ = exp / 10 + '0'; + *ptr++ = exp % 10 + '0'; + } + } + + *ptr = 0; + + length = ptr - buf; + ptr = buf; + + if (!(flags & FLAG_LEFT) && length < width) { + int i; + int nPad = width - length; + for(i=width; i>=nPad; i--) { + ptr[i] = ptr[i-nPad]; + } + i = prefix != 0 && (flags & FLAG_ZERO); + while (nPad--) { + ptr[i++] = (flags & FLAG_ZERO) ? '0' : ' '; + } + length = width; + } + + if (flags & FLAG_LEFT) { + while (length < width) { + ptr[length++] = ' '; + } + ptr[length] = '\0'; + } + + return length; +} + +static int snprintquadhex(char *buf, size_t bufsize, vargquad argvalue, int width, int precision, int flags) { + if (width > bufsize) width = bufsize; + char *bufend = buf + bufsize, *ptr = buf; + + vquad c128 = cast_vq_aq(argvalue); + + int mainpos = 0; + + if (c128.y >> 63) { + ptr += snprintf(ptr, bufend - ptr, "-"); + } else if (flags & FLAG_SIGN) { + ptr += snprintf(ptr, bufend - ptr, "+"); + } else if (flags & FLAG_BLANK) { + ptr += snprintf(ptr, bufend - ptr, " "); + } + + if (isnan_vo_vq(c128)) { + ptr += snprintf(ptr, bufend - ptr, (flags & FLAG_UPPER) ? "NAN" : "nan"); + flags &= ~FLAG_ZERO; + } else if (isinf_vo_vq(c128)) { + ptr += snprintf(ptr, bufend - ptr, (flags & FLAG_UPPER) ? "INF" : "inf"); + flags &= ~FLAG_ZERO; + } else { + int iszero = iszero_vo_vq(c128); + if (precision >= 0 && precision < 28) { + int s = (28 - precision) * 4 - 1; + if (s < 64) { + uint64_t u = c128.x + (((uint64_t)1) << s); + if (u < c128.x) c128.y++; + c128.x = u; + } else { + c128.y += ((uint64_t)1) << (s - 64); + } + } + + int exp = (c128.y >> 48) & 0x7fff; + uint64_t h = c128.y << 16, l = c128.x; + + ptr += snprintf(ptr, bufend - ptr, (flags & FLAG_UPPER) ? "0X" :"0x"); + mainpos = ptr - buf; + ptr += snprintf(ptr, bufend - ptr, exp != 0 ? "1" : "0"); + + if ((!(h == 0 && l == 0 && precision < 0) && precision != 0) || (flags & FLAG_ALT)) ptr += snprintf(ptr, bufend - ptr, "."); + + const char *digits = (flags & FLAG_UPPER) ? "0123456789ABCDEF" : "0123456789abcdef"; + + int niter = (precision < 0 || precision > 28) ? 28 : precision; + + for(int i=0;i<12 && i < niter;i++) { + if (h == 0 && l == 0 && precision < 0) break; + ptr += snprintf(ptr, bufend - ptr, "%c", digits[(h >> 60) & 0xf]); + h <<= 4; + } + + for(int i=0;i<16 && i < niter-12;i++) { + if (l == 0 && precision < 0) break; + ptr += snprintf(ptr, bufend - ptr, "%c", digits[(l >> 60) & 0xf]); + l <<= 4; + } + + if (exp == 0) exp++; + if (iszero) exp = 0x3fff; + + ptr += snprintf(ptr, bufend - ptr, "%c%+d", (flags & FLAG_UPPER) ? 'P' : 'p', exp - 0x3fff); + } + + int length = ptr - buf; + ptr = buf; + + if (!(flags & FLAG_ZERO)) mainpos = 0; + + if (!(flags & FLAG_LEFT) && length < width) { + int i; + int nPad = width - length; + for(i=width;i-nPad>=mainpos; i--) { + ptr[i] = ptr[i-nPad]; + } + i = mainpos; + while (nPad--) { + ptr[i++] = (flags & FLAG_ZERO) ? '0' : ' '; + } + length = width; + } + + if (flags & FLAG_LEFT) { + while (length < width) { + ptr[length++] = ' '; + } + ptr[length] = '\0'; + } + + return length; +} + +#define XBUFSIZE 5000 + +static int xvprintf(size_t (*consumer)(const char *ptr, size_t size, void *arg), void *arg, const char *fmt, va_list ap) { + char *xbuf = (char *)malloc(XBUFSIZE+10); + + int outlen = 0, errorflag = 0; + + while(*fmt != '\0' && !errorflag) { + // Copy the format string until a '%' is read + + if (*fmt != '%') { + do { + outlen += (*consumer)(fmt++, 1, arg); + } while(*fmt != '%' && *fmt != '\0'); + + if (*fmt == '\0') break; + } + + const char *subfmtstart = fmt; + + if ((*++fmt) == '\0') { + errorflag = 1; + outlen += (*consumer)("%", 1, arg); + break; + } + + // Read flags + + int flags = 0, done = 0; + do { + switch(*fmt) { + case '-': flags |= FLAG_LEFT; break; + case '+': flags |= FLAG_SIGN; break; + case ' ': flags |= FLAG_BLANK; break; + case '#': flags |= FLAG_ALT; break; + case '0': flags |= FLAG_ZERO; break; + default: done = 1; break; + } + } while(!done && (*++fmt) != 0); + + // Read width + + int width = 0; + + if (*fmt == '*') { + width = va_arg(ap, int); + if (width < 0) { + flags |= FLAG_LEFT; + width = -width; + } + fmt++; + } else { + while(*fmt >= '0' && *fmt <= '9') { + width = width*10 + *fmt - '0'; + fmt++; + } + } + + // Read precision + + int precision = -1; + + if (*fmt == '.') { + precision = 0; + fmt++; + if (*fmt == '*') { + precision = va_arg(ap, int); + if (precision < 0) precision = -precision; + fmt++; + } else { + while(*fmt >= '0' && *fmt <= '9') { + precision = precision*10 + *fmt - '0'; + fmt++; + } + } + } + + // Read size prefix + + int flag_quad = 0, flag_ptrquad = 0; + int size_prefix = 0, subfmt_processed = 0; + + if (*fmt == 'Q') { + flag_quad = 1; + fmt++; + } else if (*fmt == 'P') { + flag_ptrquad = 1; + fmt++; + } else { + int pl = 0; + if (*fmt == 'h' || *fmt == 'l' || *fmt == 'j' || *fmt == 'z' || *fmt == 't' || *fmt == 'L') { + size_prefix = *fmt; + pl = 1; + } + if ((*fmt == 'h' && *(fmt+1) == 'h') || (*fmt == 'l' && *(fmt+1) == 'l')) { + size_prefix = *fmt + 256 * *(fmt+1); + pl = 2; + } + fmt += pl; + } + + // Call type-specific function + + va_list ap2; + va_copy(ap2, ap); + + switch(*fmt) { + case 'E': case 'F': case 'G': case 'A': + flags |= FLAG_UPPER; + // fall through + case 'e': case 'f': case 'g': case 'a': + { + vargquad value; + if (flag_quad || flag_ptrquad) { + if (flag_quad) { + value = va_arg(ap, vargquad); + } else { + value = *(vargquad *)va_arg(ap, vargquad *); + } + if (tolower(*fmt) == 'a') { + snprintquadhex(xbuf, XBUFSIZE, value, width, precision, flags); + } else { + snprintquad(xbuf, XBUFSIZE, value, tolower(*fmt), width, precision, flags); + } + outlen += (*consumer)(xbuf, strlen(xbuf), arg); + subfmt_processed = 1; + break; + } + + if (size_prefix == 0) { // double and long double + va_arg(ap, double); + } else if (size_prefix == 'L') { + va_arg(ap, long double); + } else errorflag = 1; + } + break; + + case 'd': case 'i': case 'u': case 'o': case 'x': case 'X': + { + switch(size_prefix) { + case 0: case 'h': case 'h' + 256*'h': va_arg(ap, int); break; + case 'l': va_arg(ap, long int); break; + case 'j': va_arg(ap, intmax_t); break; + case 'z': va_arg(ap, size_t); break; + case 't': va_arg(ap, ptrdiff_t); break; + case 'l' + 256*'l': va_arg(ap, long long int); break; + default: errorflag = 1; break; + } + } + break; + + case 'c': + if (size_prefix == 0) { + va_arg(ap, int); + } else +#if 0 + if (size_prefix == 'l') { + va_arg(ap, wint_t); // wint_t is not defined + } else +#endif + errorflag = 1; + break; + + case 's': + if (size_prefix == 0 || size_prefix == 'l') { + va_arg(ap, void *); + } else errorflag = 1; + break; + + case 'p': case 'n': + { + if ((*fmt == 'p' && size_prefix != 0) || size_prefix == 'L') { errorflag = 1; break; } + va_arg(ap, void *); + } + break; + + default: + errorflag = 1; + } + + if (!subfmt_processed) { + char *subfmt = (char *)malloc(fmt - subfmtstart + 2); + memcpy(subfmt, subfmtstart, fmt - subfmtstart + 1); + subfmt[fmt - subfmtstart + 1] = 0; + int ret = vsnprintf(xbuf, XBUFSIZE, subfmt, ap2); + free(subfmt); + if (ret < 0) { errorflag = 1; break; } + outlen += (*consumer)(xbuf, strlen(xbuf), arg); + } + + fmt++; + } + + free(xbuf); + + return errorflag ? -1 : outlen; +} + +// + +typedef struct { FILE *fp; } stream_consumer_t; + +static size_t stream_consumer(const char *ptr, size_t size, void *varg) { + stream_consumer_t *arg = (stream_consumer_t *)varg; + return fwrite(ptr, size, 1, arg->fp); +} + +EXPORT int Sleef_vfprintf(FILE *fp, const char *fmt, va_list ap) { + stream_consumer_t arg = { fp }; + return xvprintf(stream_consumer, &arg, fmt, ap); +} + +EXPORT int Sleef_vprintf(const char *fmt, va_list ap) { return Sleef_vfprintf(stdout, fmt, ap); } + +EXPORT int Sleef_fprintf(FILE *fp, const char *fmt, ...) { + va_list ap; + va_start(ap, fmt); + int ret = Sleef_vfprintf(fp, fmt, ap); + va_end(ap); + return ret; +} + +EXPORT int Sleef_printf(const char *fmt, ...) { + va_list ap; + va_start(ap, fmt); + int ret = Sleef_vfprintf(stdout, fmt, ap); + va_end(ap); + return ret; +} + +typedef struct { + char *buf; + size_t pos, size; +} buf_consumer_t; + +static size_t buf_consumer(const char *ptr, size_t size, void *varg) { + buf_consumer_t *arg = (buf_consumer_t *)varg; + + size_t p = 0; + while(p < size) { + if (arg->pos >= arg->size - 1) break; + arg->buf[arg->pos++] = ptr[p++]; + } + + arg->buf[arg->pos] = '\0'; + + return p; +} + +EXPORT int Sleef_vsnprintf(char *str, size_t size, const char *fmt, va_list ap) { + buf_consumer_t arg = { str, 0, size }; + return xvprintf(buf_consumer, &arg, fmt, ap); +} + +EXPORT int Sleef_snprintf(char *str, size_t size, const char *fmt, ...) { + va_list ap; + va_start(ap, fmt); + int ret = Sleef_vsnprintf(str, size, fmt, ap); + va_end(ap); + return ret; +} + +#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 13) +#include + +static int pa_quad = -1, printf_Qmodifier = -1, printf_Pmodifier = -1; + +static void Sleef_quad_va(void *ptr, va_list *ap) { + *(Sleef_quad *)ptr = va_arg(*ap, Sleef_quad); +} + +static int printf_arginfo(const struct printf_info *info, size_t n, int *argtypes, int *s) { + if (info->user & printf_Qmodifier) { + argtypes[0] = pa_quad; + return 1; + } else if (info->user & printf_Pmodifier) { + argtypes[0] = PA_FLAG_PTR | pa_quad; + return 1; + } + return -1; +} + +static int printf_output(FILE *fp, const struct printf_info *info, const void *const *args) { + if (!(info->user & printf_Qmodifier || info->user & printf_Pmodifier)) return -2; + + int flags = 0; + if (info->showsign) flags |= FLAG_SIGN; + if (info->space) flags |= FLAG_BLANK; + if (info->alt) flags |= FLAG_ALT; + if (info->left) flags |= FLAG_LEFT; + if (isupper(info->spec)) flags |= FLAG_UPPER; + + vargquad q = **(const vargquad **)args[0]; + + char *xbuf = (char *)malloc(XBUFSIZE+10); + + int len = 0; + if (tolower(info->spec) == 'a') { + len = snprintquadhex(xbuf, XBUFSIZE, q, info->width, info->prec, flags); + } else { + len = snprintquad(xbuf, XBUFSIZE, q, tolower(info->spec), info->width, info->prec, flags); + } + + size_t wlen = fwrite(xbuf, len, 1, fp); + + free(xbuf); + + return (int)wlen; +} + +EXPORT int Sleef_registerPrintfHook() { + printf_Qmodifier = register_printf_modifier(L"Q"); + printf_Pmodifier = register_printf_modifier(L"P"); + if (printf_Qmodifier == -1 || printf_Pmodifier == -1) return -1; + + pa_quad = register_printf_type(Sleef_quad_va); + if (pa_quad == -1) return -2; + + if (register_printf_specifier('a', printf_output, printf_arginfo)) return -3; + if (register_printf_specifier('e', printf_output, printf_arginfo)) return -4; + if (register_printf_specifier('f', printf_output, printf_arginfo)) return -5; + if (register_printf_specifier('g', printf_output, printf_arginfo)) return -6; + if (register_printf_specifier('A', printf_output, printf_arginfo)) return -7; + if (register_printf_specifier('E', printf_output, printf_arginfo)) return -8; + if (register_printf_specifier('F', printf_output, printf_arginfo)) return -9; + if (register_printf_specifier('G', printf_output, printf_arginfo)) return -10; + + return 0; +} + +EXPORT void Sleef_unregisterPrintfHook() { + register_printf_specifier('a', NULL, NULL); + register_printf_specifier('e', NULL, NULL); + register_printf_specifier('f', NULL, NULL); + register_printf_specifier('g', NULL, NULL); + register_printf_specifier('A', NULL, NULL); + register_printf_specifier('E', NULL, NULL); + register_printf_specifier('F', NULL, NULL); + register_printf_specifier('G', NULL, NULL); +} +#endif // #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 13) + +#endif // #ifdef ENABLE_PUREC_SCALAR + +// Functions for debugging ------------------------------------------------------------------------------------------------------------ + +#ifdef ENABLE_MAIN +// gcc -DENABLE_MAIN -DENABLEFLOAT128 -Wno-attributes -I../libm -I../quad-tester -I../common -I../arch -DUSEMPFR -DENABLE_AVX2 -mavx2 -mfma sleefsimdqp.c rempitabqp.c ../common/common.c ../quad-tester/qtesterutil.c -lm -lmpfr +// gcc-10.2.0 -DENABLE_MAIN -Wno-attributes -I../libm -I../quad-tester -I../common -I../arch -DUSEMPFR -DENABLE_SVE -march=armv8-a+sve sleefsimdqp.c rempitabqp.c ../common/common.c ../quad-tester/qtesterutil.c -lm -lmpfr +#include +#include +#include +#include +#include +#include +#include +#include + +#include "qtesterutil.h" + +#if 0 +int main(int argc, char **argv) { + Sleef_quad q0 = atof(argv[1]); + + int lane = 0; + vargquad a0; + memset(&a0, 0, sizeof(vargquad)); + a0 = xsetq(a0, lane, q0); + + tdx t = cast_tdx_vq(cast_vq_aq(a0)); + + printvdouble("t.d3.x", t.d3.x); +} +#endif + +#if 1 +int main(int argc, char **argv) { + xsrand(time(NULL) + (int)getpid()); + int lane = xrand() % VECTLENDP; + printf("lane = %d\n", lane); + + char s[200]; + double ad[32]; + mpfr_set_default_prec(18000); + mpfr_t fr0, fr1, fr2, fr3; + mpfr_inits(fr0, fr1, fr2, fr3, NULL); + + mpfr_set_d(fr0, 0, GMP_RNDN); + if (argc >= 2) mpfr_set_str(fr0, argv[1], 10, GMP_RNDN); + Sleef_quad q0 = mpfr_get_f128(fr0, GMP_RNDN); + mpfr_set_f128(fr0, q0, GMP_RNDN); + if (argc >= 2) printf("arg0 : %s\n", sprintfr(fr0)); + vargquad a0; +#if 0 + memrand(&a0, sizeof(vargquad)); +#elif 0 + memset(&a0, 0, sizeof(vargquad)); +#endif + a0 = xsetq(a0, lane, q0); + + mpfr_set_d(fr1, 0, GMP_RNDN); + if (argc >= 3) mpfr_set_str(fr1, argv[2], 10, GMP_RNDN); + Sleef_quad q1 = mpfr_get_f128(fr1, GMP_RNDN); + mpfr_set_f128(fr1, q1, GMP_RNDN); + if (argc >= 3) printf("arg1 : %s\n", sprintfr(fr1)); + vargquad a1; +#if 0 + memrand(&a1, sizeof(vargquad)); +#elif 0 + memset(&a1, 0, sizeof(vargquad)); +#endif + a1 = xsetq(a1, lane, q1); + + mpfr_set_d(fr2, 0, GMP_RNDN); + if (argc >= 4) mpfr_set_str(fr2, argv[3], 10, GMP_RNDN); + Sleef_quad q2 = mpfr_get_f128(fr2, GMP_RNDN); + mpfr_set_f128(fr2, q2, GMP_RNDN); + if (argc >= 4) printf("arg2 : %s\n", sprintfr(fr2)); + vargquad a2; +#if 0 + memrand(&a2, sizeof(vargquad)); +#elif 0 + memset(&a2, 0, sizeof(vargquad)); +#endif + a2 = xsetq(a2, lane, q2); + + // + + vargquad a3; + +#if 0 + a3 = xaddq_u05(a0, a1); + mpfr_add(fr3, fr0, fr1, GMP_RNDN); + + printf("\nadd\n"); + mpfr_set_f128(fr3, mpfr_get_f128(fr3, GMP_RNDN), GMP_RNDN); + printf("corr : %s\n", sprintfr(fr3)); + mpfr_set_f128(fr3, xgetq(a3, lane), GMP_RNDN); + printf("test : %s\n", sprintfr(fr3)); +#endif + +#if 0 + a3 = xsubq_u05(a0, a1); + mpfr_sub(fr3, fr0, fr1, GMP_RNDN); + + printf("\nsub\n"); + mpfr_set_f128(fr3, mpfr_get_f128(fr3, GMP_RNDN), GMP_RNDN); + printf("corr : %s\n", sprintfr(fr3)); + mpfr_set_f128(fr3, xgetq(a3, lane), GMP_RNDN); + printf("test : %s\n", sprintfr(fr3)); +#endif + +#if 0 + a3 = xmulq_u05(a0, a1); + mpfr_mul(fr3, fr0, fr1, GMP_RNDN); + + printf("\nmul\n"); + mpfr_set_f128(fr3, mpfr_get_f128(fr3, GMP_RNDN), GMP_RNDN); + printf("corr : %s\n", sprintfr(fr3)); + mpfr_set_f128(fr3, xgetq(a3, lane), GMP_RNDN); + printf("test : %s\n", sprintfr(fr3)); +#endif + +#if 0 + a3 = xdivq_u05(a0, a1); + mpfr_div(fr3, fr0, fr1, GMP_RNDN); + + printf("\ndiv\n"); + mpfr_set_f128(fr3, mpfr_get_f128(fr3, GMP_RNDN), GMP_RNDN); + printf("corr : %s\n", sprintfr(fr3)); + mpfr_set_f128(fr3, xgetq(a3, lane), GMP_RNDN); + printf("test : %s\n", sprintfr(fr3)); +#endif + +#if 0 + a3 = xsqrtq_u05(a0); + mpfr_sqrt(fr3, fr0, GMP_RNDN); + + printf("\nsqrt\n"); + mpfr_set_f128(fr3, mpfr_get_f128(fr3, GMP_RNDN), GMP_RNDN); + printf("corr : %s\n", sprintfr(fr3)); + mpfr_set_f128(fr3, xgetq(a3, lane), GMP_RNDN); + printf("test : %s\n", sprintfr(fr3)); +#endif + +#if 0 + a3 = xsinq_u10(a0); + mpfr_sin(fr3, fr0, GMP_RNDN); + + printf("\nsin\n"); + mpfr_set_f128(fr3, mpfr_get_f128(fr3, GMP_RNDN), GMP_RNDN); + printf("corr : %s\n", sprintfr(fr3)); + mpfr_set_f128(fr3, xgetq(a3, lane), GMP_RNDN); + printf("test : %s\n", sprintfr(fr3)); +#endif + +#if 0 + a3 = xfabsq(a0); + mpfr_abs(fr3, fr0, GMP_RNDN); + + printf("\nfabs\n"); + mpfr_set_f128(fr3, mpfr_get_f128(fr3, GMP_RNDN), GMP_RNDN); + printf("corr : %s\n", sprintfr(fr3)); + mpfr_set_f128(fr3, xgetq(a3, lane), GMP_RNDN); + printf("test : %s\n", sprintfr(fr3)); +#endif + +#if 0 + a3 = xcopysignq(a0, a1); + mpfr_copysign(fr3, fr0, fr1, GMP_RNDN); + + printf("\ncopysign\n"); + mpfr_set_f128(fr3, mpfr_get_f128(fr3, GMP_RNDN), GMP_RNDN); + printf("corr : %s\n", sprintfr(fr3)); + mpfr_set_f128(fr3, xgetq(a3, lane), GMP_RNDN); + printf("test : %s\n", sprintfr(fr3)); +#endif + +#if 0 + a3 = xfmaxq(a0, a1); + mpfr_max(fr3, fr0, fr1, GMP_RNDN); + + printf("\nmax\n"); + mpfr_set_f128(fr3, mpfr_get_f128(fr3, GMP_RNDN), GMP_RNDN); + printf("corr : %s\n", sprintfr(fr3)); + mpfr_set_f128(fr3, xgetq(a3, lane), GMP_RNDN); + printf("test : %s\n", sprintfr(fr3)); +#endif + +#if 0 + a3 = xfminq(a0, a1); + mpfr_min(fr3, fr0, fr1, GMP_RNDN); + + printf("\nmin\n"); + mpfr_set_f128(fr3, mpfr_get_f128(fr3, GMP_RNDN), GMP_RNDN); + printf("corr : %s\n", sprintfr(fr3)); + mpfr_set_f128(fr3, xgetq(a3, lane), GMP_RNDN); + printf("test : %s\n", sprintfr(fr3)); +#endif + +#if 0 + a3 = xfdimq_u05(a0, a1); + mpfr_dim(fr3, fr0, fr1, GMP_RNDN); + + printf("\nfdim\n"); + mpfr_set_f128(fr3, mpfr_get_f128(fr3, GMP_RNDN), GMP_RNDN); + printf("corr : %s\n", sprintfr(fr3)); + mpfr_set_f128(fr3, xgetq(a3, lane), GMP_RNDN); + printf("test : %s\n", sprintfr(fr3)); +#endif + +#if 0 + a3 = xsinhq_u10(a0); + mpfr_sinh(fr3, fr0, GMP_RNDN); + + printf("\nsinh\n"); + mpfr_set_f128(fr3, mpfr_get_f128(fr3, GMP_RNDN), GMP_RNDN); + printf("corr : %s\n", sprintfr(fr3)); + mpfr_set_f128(fr3, xgetq(a3, lane), GMP_RNDN); + printf("test : %s\n", sprintfr(fr3)); +#endif + +#if 0 + a3 = xcoshq_u10(a0); + mpfr_cosh(fr3, fr0, GMP_RNDN); + + printf("\ncosh\n"); + mpfr_set_f128(fr3, mpfr_get_f128(fr3, GMP_RNDN), GMP_RNDN); + printf("corr : %s\n", sprintfr(fr3)); + mpfr_set_f128(fr3, xgetq(a3, lane), GMP_RNDN); + printf("test : %s\n", sprintfr(fr3)); +#endif + +#if 0 + a3 = xtanhq_u10(a0); + mpfr_tanh(fr3, fr0, GMP_RNDN); + + printf("\ntanh\n"); + mpfr_set_f128(fr3, mpfr_get_f128(fr3, GMP_RNDN), GMP_RNDN); + printf("corr : %s\n", sprintfr(fr3)); + mpfr_set_f128(fr3, xgetq(a3, lane), GMP_RNDN); + printf("test : %s\n", sprintfr(fr3)); +#endif + +#if 0 + a3 = xatan2q_u10(a0, a1); + mpfr_atan2(fr3, fr0, fr1, GMP_RNDN); + + printf("\natan2\n"); + mpfr_set_f128(fr3, mpfr_get_f128(fr3, GMP_RNDN), GMP_RNDN); + printf("corr : %s\n", sprintfr(fr3)); + mpfr_set_f128(fr3, xgetq(a3, lane), GMP_RNDN); + printf("test : %s\n", sprintfr(fr3)); +#endif + +#if 0 + a3 = xpowq_u10(a0, a1); + mpfr_pow(fr3, fr0, fr1, GMP_RNDN); + + printf("\npow\n"); + mpfr_set_f128(fr3, mpfr_get_f128(fr3, GMP_RNDN), GMP_RNDN); + printf("corr : %s\n", sprintfr(fr3)); + mpfr_set_f128(fr3, xgetq(a3, lane), GMP_RNDN); + printf("test : %s\n", sprintfr(fr3)); +#endif + +#if 0 + a3 = xtruncq(a0); + mpfr_trunc(fr3, fr0); + + printf("\ntrunc\n"); + mpfr_set_f128(fr3, mpfr_get_f128(fr3, GMP_RNDN), GMP_RNDN); + printf("corr : %s\n", sprintfr(fr3)); + mpfr_set_f128(fr3, xgetq(a3, lane), GMP_RNDN); + printf("test : %s\n", sprintfr(fr3)); +#endif + +#if 0 + a3 = xfloorq(a0); + mpfr_floor(fr3, fr0); + + printf("\nfloor\n"); + mpfr_set_f128(fr3, mpfr_get_f128(fr3, GMP_RNDN), GMP_RNDN); + printf("corr : %s\n", sprintfr(fr3)); + mpfr_set_f128(fr3, xgetq(a3, lane), GMP_RNDN); + printf("test : %s\n", sprintfr(fr3)); +#endif + +#if 0 + a3 = xceilq(a0); + mpfr_ceil(fr3, fr0); + + printf("\nceil\n"); + mpfr_set_f128(fr3, mpfr_get_f128(fr3, GMP_RNDN), GMP_RNDN); + printf("corr : %s\n", sprintfr(fr3)); + mpfr_set_f128(fr3, xgetq(a3, lane), GMP_RNDN); + printf("test : %s\n", sprintfr(fr3)); +#endif + +#if 0 + a3 = xfmodq(a0, a1); + mpfr_fmod(fr3, fr0, fr1, GMP_RNDN); + + printf("\nfmod\n"); + mpfr_set_f128(fr3, mpfr_get_f128(fr3, GMP_RNDN), GMP_RNDN); + printf("corr : %s\n", sprintfr(fr3)); + mpfr_set_f128(fr3, xgetq(a3, lane), GMP_RNDN); + printf("test : %s\n", sprintfr(fr3)); +#endif + +#if 0 + a3 = xremainderq(a0, a1); + mpfr_remainder(fr3, fr0, fr1, GMP_RNDN); + + printf("\nremainder\n"); + mpfr_set_f128(fr3, mpfr_get_f128(fr3, GMP_RNDN), GMP_RNDN); + printf("corr : %s\n", sprintfr(fr3)); + mpfr_set_f128(fr3, xgetq(a3, lane), GMP_RNDN); + printf("test : %s\n", sprintfr(fr3)); +#endif + +#if 0 + a3 = xcbrtq_u10(a0); + mpfr_cbrt(fr3, fr0, GMP_RNDN); + + printf("\ncbrt\n"); + mpfr_set_f128(fr3, mpfr_get_f128(fr3, GMP_RNDN), GMP_RNDN); + printf("corr : %s\n", sprintfr(fr3)); + mpfr_set_f128(fr3, xgetq(a3, lane), GMP_RNDN); + printf("test : %s\n", sprintfr(fr3)); +#endif + +#if 1 + a3 = xfmaq_u05(a0, a1, a2); + mpfr_fma(fr3, fr0, fr1, fr2, GMP_RNDN); + + printf("\nfma\n"); + mpfr_set_f128(fr3, mpfr_get_f128(fr3, GMP_RNDN), GMP_RNDN); + printf("corr : %s\n", sprintfr(fr3)); + mpfr_set_f128(fr3, xgetq(a3, lane), GMP_RNDN); + printf("test : %s\n", sprintfr(fr3)); +#endif + +#if 0 + a3 = xhypotq_u05(a0, a1); + mpfr_hypot(fr3, fr0, fr1, GMP_RNDN); + + printf("\nhypot\n"); + mpfr_set_f128(fr3, mpfr_get_f128(fr3, GMP_RNDN), GMP_RNDN); + printf("corr : %s\n", sprintfr(fr3)); + mpfr_set_f128(fr3, xgetq(a3, lane), GMP_RNDN); + printf("test : %s\n", sprintfr(fr3)); +#endif + +#if 0 + vint vi = xilogbq(a0); + + printf("\nilogb\n"); + printf("corr : %d\n", ilogb((double)q0)); + printf("test : %d\n", vi); +#endif + +#if 0 + a3 = xldexpq(a0, vcast_vi_i(atoi(argv[2]))); + + printf("\nldexp\n"); + printf("corr : %.20g\n", ldexp((double)q0, atoi(argv[2]))); + mpfr_set_f128(fr3, xgetq(a3, lane), GMP_RNDN); + printf("test : %s\n", sprintfr(fr3)); +#endif + mpfr_clears(fr0, fr1, fr2, fr3, NULL); +} +#endif +#endif diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/toolchains/aarch64-gcc.cmake b/src/jdk.incubator.vector/linux/native/libsleef/upstream/toolchains/aarch64-gcc.cmake new file mode 100644 index 00000000000..c3594551ee1 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/toolchains/aarch64-gcc.cmake @@ -0,0 +1,11 @@ +SET (CMAKE_CROSSCOMPILING TRUE) +SET (CMAKE_SYSTEM_NAME "Linux") +SET (CMAKE_SYSTEM_PROCESSOR "aarch64") + +SET(CMAKE_FIND_ROOT_PATH /usr/aarch64-linux-gnu /usr/include/aarch64-linux-gnu /usr/lib/aarch64-linux-gnu /lib/aarch64-linux-gnu) + +find_program(CMAKE_C_COMPILER NAMES aarch64-linux-gnu-gcc-11 aarch64-linux-gnu-gcc-8 aarch64-linux-gnu-gcc-7 aarch64-linux-gnu-gcc-6 aarch64-linux-gnu-gcc-5 aarch64-linux-gnu-gcc) + +SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH) +SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/toolchains/aarch64-llvm.cmake b/src/jdk.incubator.vector/linux/native/libsleef/upstream/toolchains/aarch64-llvm.cmake new file mode 100644 index 00000000000..d9c11ae0096 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/toolchains/aarch64-llvm.cmake @@ -0,0 +1,12 @@ +SET (CMAKE_CROSSCOMPILING TRUE) +SET (CMAKE_SYSTEM_NAME "Linux") +SET (CMAKE_SYSTEM_PROCESSOR "aarch64") + +SET(CMAKE_FIND_ROOT_PATH /usr/aarch64-linux-gnu /usr/include/aarch64-linux-gnu /usr/lib/aarch64-linux-gnu /lib/aarch64-linux-gnu) + +find_program(CMAKE_C_COMPILER NAMES clang-17 clang-16 clang-15 clang-14 clang-13 clang) +set(CMAKE_C_COMPILER_TARGET aarch64-linux-gnu) + +SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH) +SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/toolchains/armhf-gcc.cmake b/src/jdk.incubator.vector/linux/native/libsleef/upstream/toolchains/armhf-gcc.cmake new file mode 100644 index 00000000000..24e160b965b --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/toolchains/armhf-gcc.cmake @@ -0,0 +1,11 @@ +SET (CMAKE_CROSSCOMPILING TRUE) +SET (CMAKE_SYSTEM_NAME "Linux") +SET (CMAKE_SYSTEM_PROCESSOR "armhf") + +SET(CMAKE_FIND_ROOT_PATH /usr/arm-linux-gnueabihf /usr/include/arm-linux-gnueabihf /usr/lib/arm-linux-gnueabihf) + +find_program(CMAKE_C_COMPILER NAMES arm-linux-gnueabihf-gcc-11 arm-linux-gnueabihf-gcc-8 arm-linux-gnueabihf-gcc-7 arm-linux-gnueabihf-gcc-6 arm-linux-gnueabihf-gcc-5 arm-linux-gnueabihf-gcc) + +SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH) +SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/toolchains/armhf-llvm.cmake b/src/jdk.incubator.vector/linux/native/libsleef/upstream/toolchains/armhf-llvm.cmake new file mode 100644 index 00000000000..6c157289e41 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/toolchains/armhf-llvm.cmake @@ -0,0 +1,12 @@ +SET (CMAKE_CROSSCOMPILING TRUE) +SET (CMAKE_SYSTEM_NAME "Linux") +SET (CMAKE_SYSTEM_PROCESSOR "armhf") + +SET(CMAKE_FIND_ROOT_PATH /usr/arm-linux-gnueabihf /usr/include/arm-linux-gnueabihf /usr/lib/arm-linux-gnueabihf) + +find_program(CMAKE_C_COMPILER NAMES clang-17 clang-16 clang-15 clang-14 clang-13 clang) +set(CMAKE_C_COMPILER_TARGET arm-linux-gnueabihf) + +SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH) +SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/toolchains/native-gcc.cmake b/src/jdk.incubator.vector/linux/native/libsleef/upstream/toolchains/native-gcc.cmake new file mode 100644 index 00000000000..07ea294d378 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/toolchains/native-gcc.cmake @@ -0,0 +1 @@ +find_program(CMAKE_C_COMPILER gcc) diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/toolchains/native-llvm.cmake b/src/jdk.incubator.vector/linux/native/libsleef/upstream/toolchains/native-llvm.cmake new file mode 100644 index 00000000000..6f8e7121afa --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/toolchains/native-llvm.cmake @@ -0,0 +1 @@ +find_program(CMAKE_C_COMPILER NAMES clang-17 clang-16 clang-15 clang-14 clang-13 clang) diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/toolchains/ppc64el-gcc.cmake b/src/jdk.incubator.vector/linux/native/libsleef/upstream/toolchains/ppc64el-gcc.cmake new file mode 100644 index 00000000000..7d6c96ae203 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/toolchains/ppc64el-gcc.cmake @@ -0,0 +1,13 @@ +SET (CMAKE_CROSSCOMPILING TRUE) +SET (CMAKE_SYSTEM_NAME "Linux") +SET (CMAKE_SYSTEM_PROCESSOR "ppc64") + +SET(CMAKE_FIND_ROOT_PATH /usr/powerpc64le-linux-gnu /usr/include/powerpc64le-linux-gnu /usr/lib/powerpc64le-linux-gnu) + +find_program(CMAKE_C_COMPILER NAMES powerpc64le-linux-gnu-gcc-11 powerpc64le-linux-gnu-gcc ppc64el-cc) + +SET(CMAKE_AR /usr/powerpc64le-linux-gnu/bin/ar) + +SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH) +SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/toolchains/ppc64el-llvm.cmake b/src/jdk.incubator.vector/linux/native/libsleef/upstream/toolchains/ppc64el-llvm.cmake new file mode 100644 index 00000000000..531b36f35f8 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/toolchains/ppc64el-llvm.cmake @@ -0,0 +1,14 @@ +SET (CMAKE_CROSSCOMPILING TRUE) +SET (CMAKE_SYSTEM_NAME "Linux") +SET (CMAKE_SYSTEM_PROCESSOR "ppc64") + +SET(CMAKE_FIND_ROOT_PATH /usr/powerpc64le-linux-gnu /usr/include/powerpc64le-linux-gnu /usr/lib/powerpc64le-linux-gnu) + +find_program(CMAKE_C_COMPILER NAMES clang-17 clang-16 clang-15 clang-14 clang-13 clang) +set(CMAKE_C_COMPILER_TARGET powerpc64le-linux-gnu) + +SET(CMAKE_AR /usr/powerpc64le-linux-gnu/bin/ar) + +SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH) +SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/toolchains/riscv64-gcc.cmake b/src/jdk.incubator.vector/linux/native/libsleef/upstream/toolchains/riscv64-gcc.cmake new file mode 100644 index 00000000000..b08409987eb --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/toolchains/riscv64-gcc.cmake @@ -0,0 +1,11 @@ +SET (CMAKE_CROSSCOMPILING TRUE) +SET (CMAKE_SYSTEM_NAME "Linux") +SET (CMAKE_SYSTEM_PROCESSOR "riscv64") + +SET(CMAKE_FIND_ROOT_PATH /usr/riscv64-linux-gnu /usr/include/riscv64-linux-gnu /usr/lib/riscv64-linux-gnu /lib/riscv64-linux-gnu) + +find_program(CMAKE_C_COMPILER NAMES riscv64-linux-gnu-gcc-14 riscv64-linux-gnu-gcc) + +SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH) +SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/toolchains/riscv64-llvm.cmake b/src/jdk.incubator.vector/linux/native/libsleef/upstream/toolchains/riscv64-llvm.cmake new file mode 100644 index 00000000000..1821770a50b --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/toolchains/riscv64-llvm.cmake @@ -0,0 +1,12 @@ +SET (CMAKE_CROSSCOMPILING TRUE) +SET (CMAKE_SYSTEM_NAME "Linux") +SET (CMAKE_SYSTEM_PROCESSOR "riscv64") + +SET(CMAKE_FIND_ROOT_PATH /usr/riscv64-linux-gnu /usr/include/riscv64-linux-gnu /usr/lib/riscv64-linux-gnu /lib/riscv64-linux-gnu) + +find_program(CMAKE_C_COMPILER NAMES clang-17 clang) +set(CMAKE_C_COMPILER_TARGET riscv64-linux-gnu) + +SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH) +SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/toolchains/s390x-gcc.cmake b/src/jdk.incubator.vector/linux/native/libsleef/upstream/toolchains/s390x-gcc.cmake new file mode 100644 index 00000000000..4aa9f12cfb1 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/toolchains/s390x-gcc.cmake @@ -0,0 +1,11 @@ +SET (CMAKE_CROSSCOMPILING TRUE) +SET (CMAKE_SYSTEM_NAME "Linux") +SET (CMAKE_SYSTEM_PROCESSOR "s390x") + +SET(CMAKE_FIND_ROOT_PATH /usr/s390x-linux-gnu /usr/include/s390x-linux-gnu /usr/lib/s390x-linux-gnu) + +find_program(CMAKE_C_COMPILER NAMES s390x-linux-gnu-gcc-11 s390x-linux-gnu-gcc) + +SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH) +SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) diff --git a/src/jdk.incubator.vector/linux/native/libsleef/upstream/toolchains/s390x-llvm.cmake b/src/jdk.incubator.vector/linux/native/libsleef/upstream/toolchains/s390x-llvm.cmake new file mode 100644 index 00000000000..ca5e96878d1 --- /dev/null +++ b/src/jdk.incubator.vector/linux/native/libsleef/upstream/toolchains/s390x-llvm.cmake @@ -0,0 +1,12 @@ +SET (CMAKE_CROSSCOMPILING TRUE) +SET (CMAKE_SYSTEM_NAME "Linux") +SET (CMAKE_SYSTEM_PROCESSOR "s390x") + +SET(CMAKE_FIND_ROOT_PATH /usr/s390x-linux-gnu /usr/include/s390x-linux-gnu /usr/lib/s390x-linux-gnu) + +find_program(CMAKE_C_COMPILER NAMES clang-17 clang-16 clang-15 clang-14 clang-13 clang) +set(CMAKE_C_COMPILER_TARGET s390x-linux-gnu) + +SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH) +SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/AbstractShuffle.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/AbstractShuffle.java index d648fd86484..fc39cb6adac 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/AbstractShuffle.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/AbstractShuffle.java @@ -133,7 +133,7 @@ abstract class AbstractShuffle extends VectorShuffle { } @ForceInline - public final VectorShuffle wrapIndexes() { + public final VectorShuffle wrapIndexesTemplate() { Vector shufvec = this.toVector(); VectorMask vecmask = shufvec.compare(VectorOperators.LT, vspecies().zero()); if (vecmask.anyTrue()) { diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte128Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte128Vector.java index a889d10fb43..0bc25958a76 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte128Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte128Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -503,7 +503,7 @@ final class Byte128Vector extends ByteVector { VectorMask m) { return (Byte128Vector) super.selectFromTemplate((Byte128Vector) v, - (Byte128Mask) m); // specialize + Byte128Mask.class, (Byte128Mask) m); // specialize } @@ -860,6 +860,13 @@ final class Byte128Vector extends ByteVector { return s.shuffleFromArray(shuffleArray, 0).check(s); } + @Override + @ForceInline + public Byte128Shuffle wrapIndexes() { + return VectorSupport.wrapShuffleIndexes(ETYPE, Byte128Shuffle.class, this, VLENGTH, + (s) -> ((Byte128Shuffle)(((AbstractShuffle)(s)).wrapIndexesTemplate()))); + } + @ForceInline @Override public Byte128Shuffle rearrange(VectorShuffle shuffle) { diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte256Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte256Vector.java index 7f07c32ab13..639646aa77a 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte256Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte256Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -503,7 +503,7 @@ final class Byte256Vector extends ByteVector { VectorMask m) { return (Byte256Vector) super.selectFromTemplate((Byte256Vector) v, - (Byte256Mask) m); // specialize + Byte256Mask.class, (Byte256Mask) m); // specialize } @@ -892,6 +892,13 @@ final class Byte256Vector extends ByteVector { return s.shuffleFromArray(shuffleArray, 0).check(s); } + @Override + @ForceInline + public Byte256Shuffle wrapIndexes() { + return VectorSupport.wrapShuffleIndexes(ETYPE, Byte256Shuffle.class, this, VLENGTH, + (s) -> ((Byte256Shuffle)(((AbstractShuffle)(s)).wrapIndexesTemplate()))); + } + @ForceInline @Override public Byte256Shuffle rearrange(VectorShuffle shuffle) { diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte512Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte512Vector.java index 20bf261999a..2d8151f6800 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte512Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte512Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -503,7 +503,7 @@ final class Byte512Vector extends ByteVector { VectorMask m) { return (Byte512Vector) super.selectFromTemplate((Byte512Vector) v, - (Byte512Mask) m); // specialize + Byte512Mask.class, (Byte512Mask) m); // specialize } @@ -956,6 +956,13 @@ final class Byte512Vector extends ByteVector { return s.shuffleFromArray(shuffleArray, 0).check(s); } + @Override + @ForceInline + public Byte512Shuffle wrapIndexes() { + return VectorSupport.wrapShuffleIndexes(ETYPE, Byte512Shuffle.class, this, VLENGTH, + (s) -> ((Byte512Shuffle)(((AbstractShuffle)(s)).wrapIndexesTemplate()))); + } + @ForceInline @Override public Byte512Shuffle rearrange(VectorShuffle shuffle) { diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte64Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte64Vector.java index 2756128b469..bc8ed7d704d 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte64Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte64Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -503,7 +503,7 @@ final class Byte64Vector extends ByteVector { VectorMask m) { return (Byte64Vector) super.selectFromTemplate((Byte64Vector) v, - (Byte64Mask) m); // specialize + Byte64Mask.class, (Byte64Mask) m); // specialize } @@ -844,6 +844,13 @@ final class Byte64Vector extends ByteVector { return s.shuffleFromArray(shuffleArray, 0).check(s); } + @Override + @ForceInline + public Byte64Shuffle wrapIndexes() { + return VectorSupport.wrapShuffleIndexes(ETYPE, Byte64Shuffle.class, this, VLENGTH, + (s) -> ((Byte64Shuffle)(((AbstractShuffle)(s)).wrapIndexesTemplate()))); + } + @ForceInline @Override public Byte64Shuffle rearrange(VectorShuffle shuffle) { diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteMaxVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteMaxVector.java index c2f5e6f85a9..597afd8d165 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteMaxVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteMaxVector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -503,7 +503,7 @@ final class ByteMaxVector extends ByteVector { VectorMask m) { return (ByteMaxVector) super.selectFromTemplate((ByteMaxVector) v, - (ByteMaxMask) m); // specialize + ByteMaxMask.class, (ByteMaxMask) m); // specialize } @@ -830,6 +830,13 @@ final class ByteMaxVector extends ByteVector { return s.shuffleFromArray(shuffleArray, 0).check(s); } + @Override + @ForceInline + public ByteMaxShuffle wrapIndexes() { + return VectorSupport.wrapShuffleIndexes(ETYPE, ByteMaxShuffle.class, this, VLENGTH, + (s) -> ((ByteMaxShuffle)(((AbstractShuffle)(s)).wrapIndexesTemplate()))); + } + @ForceInline @Override public ByteMaxShuffle rearrange(VectorShuffle shuffle) { diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector.java index 8fae8d71b04..a23bbc7f709 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector.java @@ -2393,17 +2393,18 @@ public abstract class ByteVector extends AbstractVector { */ @Override public abstract - ByteVector rearrange(VectorShuffle m); + ByteVector rearrange(VectorShuffle shuffle); /*package-private*/ @ForceInline final > ByteVector rearrangeTemplate(Class shuffletype, S shuffle) { - shuffle.checkIndexes(); + @SuppressWarnings("unchecked") + S ws = (S) shuffle.wrapIndexes(); return VectorSupport.rearrangeOp( getClass(), shuffletype, null, byte.class, length(), - this, shuffle, null, + this, ws, null, (v1, s_, m_) -> v1.uOp((i, a) -> { int ei = s_.laneSource(i); return v1.lane(ei); @@ -2428,17 +2429,14 @@ public abstract class ByteVector extends AbstractVector { M m) { m.check(masktype, this); - VectorMask valid = shuffle.laneIsValid(); - if (m.andNot(valid).anyTrue()) { - shuffle.checkIndexes(); - throw new AssertionError(); - } + @SuppressWarnings("unchecked") + S ws = (S) shuffle.wrapIndexes(); return VectorSupport.rearrangeOp( getClass(), shuffletype, masktype, byte.class, length(), - this, shuffle, m, + this, ws, m, (v1, s_, m_) -> v1.uOp((i, a) -> { int ei = s_.laneSource(i); - return ei < 0 || !m_.laneIsSet(i) ? 0 : v1.lane(ei); + return !m_.laneIsSet(i) ? 0 : v1.lane(ei); })); } @@ -2551,7 +2549,10 @@ public abstract class ByteVector extends AbstractVector { /*package-private*/ @ForceInline final ByteVector selectFromTemplate(ByteVector v) { - return v.rearrange(this.toShuffle()); + return (ByteVector)VectorSupport.selectFromOp(getClass(), null, byte.class, + length(), this, v, null, + (v1, v2, _m) -> + v2.rearrange(v1.toShuffle())); } /** @@ -2563,9 +2564,15 @@ public abstract class ByteVector extends AbstractVector { /*package-private*/ @ForceInline - final ByteVector selectFromTemplate(ByteVector v, - AbstractMask m) { - return v.rearrange(this.toShuffle(), m); + final + > + ByteVector selectFromTemplate(ByteVector v, + Class masktype, M m) { + m.check(masktype, this); + return (ByteVector)VectorSupport.selectFromOp(getClass(), masktype, byte.class, + length(), this, v, m, + (v1, v2, _m) -> + v2.rearrange(v1.toShuffle(), _m)); } /// Ternary operations diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double128Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double128Vector.java index 385fbba55a3..00840026fff 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double128Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double128Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -490,7 +490,7 @@ final class Double128Vector extends DoubleVector { VectorMask m) { return (Double128Vector) super.selectFromTemplate((Double128Vector) v, - (Double128Mask) m); // specialize + Double128Mask.class, (Double128Mask) m); // specialize } @@ -512,7 +512,7 @@ final class Double128Vector extends DoubleVector { this, i, (vec, ix) -> { double[] vecarr = vec.vec(); - return (long)Double.doubleToLongBits(vecarr[ix]); + return (long)Double.doubleToRawLongBits(vecarr[ix]); }); } @@ -529,7 +529,7 @@ final class Double128Vector extends DoubleVector { public Double128Vector withLaneHelper(int i, double e) { return VectorSupport.insert( VCLASS, ETYPE, VLENGTH, - this, i, (long)Double.doubleToLongBits(e), + this, i, (long)Double.doubleToRawLongBits(e), (v, ix, bits) -> { double[] res = v.vec().clone(); res[ix] = Double.longBitsToDouble((long)bits); @@ -821,6 +821,13 @@ final class Double128Vector extends DoubleVector { return s.shuffleFromArray(shuffleArray, 0).check(s); } + @Override + @ForceInline + public Double128Shuffle wrapIndexes() { + return VectorSupport.wrapShuffleIndexes(ETYPE, Double128Shuffle.class, this, VLENGTH, + (s) -> ((Double128Shuffle)(((AbstractShuffle)(s)).wrapIndexesTemplate()))); + } + @ForceInline @Override public Double128Shuffle rearrange(VectorShuffle shuffle) { diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double256Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double256Vector.java index e73ada8a088..4b42deba738 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double256Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double256Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -490,7 +490,7 @@ final class Double256Vector extends DoubleVector { VectorMask m) { return (Double256Vector) super.selectFromTemplate((Double256Vector) v, - (Double256Mask) m); // specialize + Double256Mask.class, (Double256Mask) m); // specialize } @@ -514,7 +514,7 @@ final class Double256Vector extends DoubleVector { this, i, (vec, ix) -> { double[] vecarr = vec.vec(); - return (long)Double.doubleToLongBits(vecarr[ix]); + return (long)Double.doubleToRawLongBits(vecarr[ix]); }); } @@ -533,7 +533,7 @@ final class Double256Vector extends DoubleVector { public Double256Vector withLaneHelper(int i, double e) { return VectorSupport.insert( VCLASS, ETYPE, VLENGTH, - this, i, (long)Double.doubleToLongBits(e), + this, i, (long)Double.doubleToRawLongBits(e), (v, ix, bits) -> { double[] res = v.vec().clone(); res[ix] = Double.longBitsToDouble((long)bits); @@ -825,6 +825,13 @@ final class Double256Vector extends DoubleVector { return s.shuffleFromArray(shuffleArray, 0).check(s); } + @Override + @ForceInline + public Double256Shuffle wrapIndexes() { + return VectorSupport.wrapShuffleIndexes(ETYPE, Double256Shuffle.class, this, VLENGTH, + (s) -> ((Double256Shuffle)(((AbstractShuffle)(s)).wrapIndexesTemplate()))); + } + @ForceInline @Override public Double256Shuffle rearrange(VectorShuffle shuffle) { diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double512Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double512Vector.java index 5f239d2a527..c188f990c33 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double512Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double512Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -490,7 +490,7 @@ final class Double512Vector extends DoubleVector { VectorMask m) { return (Double512Vector) super.selectFromTemplate((Double512Vector) v, - (Double512Mask) m); // specialize + Double512Mask.class, (Double512Mask) m); // specialize } @@ -518,7 +518,7 @@ final class Double512Vector extends DoubleVector { this, i, (vec, ix) -> { double[] vecarr = vec.vec(); - return (long)Double.doubleToLongBits(vecarr[ix]); + return (long)Double.doubleToRawLongBits(vecarr[ix]); }); } @@ -541,7 +541,7 @@ final class Double512Vector extends DoubleVector { public Double512Vector withLaneHelper(int i, double e) { return VectorSupport.insert( VCLASS, ETYPE, VLENGTH, - this, i, (long)Double.doubleToLongBits(e), + this, i, (long)Double.doubleToRawLongBits(e), (v, ix, bits) -> { double[] res = v.vec().clone(); res[ix] = Double.longBitsToDouble((long)bits); @@ -833,6 +833,13 @@ final class Double512Vector extends DoubleVector { return s.shuffleFromArray(shuffleArray, 0).check(s); } + @Override + @ForceInline + public Double512Shuffle wrapIndexes() { + return VectorSupport.wrapShuffleIndexes(ETYPE, Double512Shuffle.class, this, VLENGTH, + (s) -> ((Double512Shuffle)(((AbstractShuffle)(s)).wrapIndexesTemplate()))); + } + @ForceInline @Override public Double512Shuffle rearrange(VectorShuffle shuffle) { diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double64Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double64Vector.java index cd5f14c47db..032fa1ac277 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double64Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double64Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -490,7 +490,7 @@ final class Double64Vector extends DoubleVector { VectorMask m) { return (Double64Vector) super.selectFromTemplate((Double64Vector) v, - (Double64Mask) m); // specialize + Double64Mask.class, (Double64Mask) m); // specialize } @@ -511,7 +511,7 @@ final class Double64Vector extends DoubleVector { this, i, (vec, ix) -> { double[] vecarr = vec.vec(); - return (long)Double.doubleToLongBits(vecarr[ix]); + return (long)Double.doubleToRawLongBits(vecarr[ix]); }); } @@ -527,7 +527,7 @@ final class Double64Vector extends DoubleVector { public Double64Vector withLaneHelper(int i, double e) { return VectorSupport.insert( VCLASS, ETYPE, VLENGTH, - this, i, (long)Double.doubleToLongBits(e), + this, i, (long)Double.doubleToRawLongBits(e), (v, ix, bits) -> { double[] res = v.vec().clone(); res[ix] = Double.longBitsToDouble((long)bits); @@ -819,6 +819,13 @@ final class Double64Vector extends DoubleVector { return s.shuffleFromArray(shuffleArray, 0).check(s); } + @Override + @ForceInline + public Double64Shuffle wrapIndexes() { + return VectorSupport.wrapShuffleIndexes(ETYPE, Double64Shuffle.class, this, VLENGTH, + (s) -> ((Double64Shuffle)(((AbstractShuffle)(s)).wrapIndexesTemplate()))); + } + @ForceInline @Override public Double64Shuffle rearrange(VectorShuffle shuffle) { diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleMaxVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleMaxVector.java index 84b0b240ca5..7251ec82aa6 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleMaxVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleMaxVector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -490,7 +490,7 @@ final class DoubleMaxVector extends DoubleVector { VectorMask m) { return (DoubleMaxVector) super.selectFromTemplate((DoubleMaxVector) v, - (DoubleMaxMask) m); // specialize + DoubleMaxMask.class, (DoubleMaxMask) m); // specialize } @@ -510,7 +510,7 @@ final class DoubleMaxVector extends DoubleVector { this, i, (vec, ix) -> { double[] vecarr = vec.vec(); - return (long)Double.doubleToLongBits(vecarr[ix]); + return (long)Double.doubleToRawLongBits(vecarr[ix]); }); } @@ -526,7 +526,7 @@ final class DoubleMaxVector extends DoubleVector { public DoubleMaxVector withLaneHelper(int i, double e) { return VectorSupport.insert( VCLASS, ETYPE, VLENGTH, - this, i, (long)Double.doubleToLongBits(e), + this, i, (long)Double.doubleToRawLongBits(e), (v, ix, bits) -> { double[] res = v.vec().clone(); res[ix] = Double.longBitsToDouble((long)bits); @@ -818,6 +818,13 @@ final class DoubleMaxVector extends DoubleVector { return s.shuffleFromArray(shuffleArray, 0).check(s); } + @Override + @ForceInline + public DoubleMaxShuffle wrapIndexes() { + return VectorSupport.wrapShuffleIndexes(ETYPE, DoubleMaxShuffle.class, this, VLENGTH, + (s) -> ((DoubleMaxShuffle)(((AbstractShuffle)(s)).wrapIndexesTemplate()))); + } + @ForceInline @Override public DoubleMaxShuffle rearrange(VectorShuffle shuffle) { diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleVector.java index 59e67195732..6cc12048d46 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleVector.java @@ -2235,17 +2235,18 @@ public abstract class DoubleVector extends AbstractVector { */ @Override public abstract - DoubleVector rearrange(VectorShuffle m); + DoubleVector rearrange(VectorShuffle shuffle); /*package-private*/ @ForceInline final > DoubleVector rearrangeTemplate(Class shuffletype, S shuffle) { - shuffle.checkIndexes(); + @SuppressWarnings("unchecked") + S ws = (S) shuffle.wrapIndexes(); return VectorSupport.rearrangeOp( getClass(), shuffletype, null, double.class, length(), - this, shuffle, null, + this, ws, null, (v1, s_, m_) -> v1.uOp((i, a) -> { int ei = s_.laneSource(i); return v1.lane(ei); @@ -2270,17 +2271,14 @@ public abstract class DoubleVector extends AbstractVector { M m) { m.check(masktype, this); - VectorMask valid = shuffle.laneIsValid(); - if (m.andNot(valid).anyTrue()) { - shuffle.checkIndexes(); - throw new AssertionError(); - } + @SuppressWarnings("unchecked") + S ws = (S) shuffle.wrapIndexes(); return VectorSupport.rearrangeOp( getClass(), shuffletype, masktype, double.class, length(), - this, shuffle, m, + this, ws, m, (v1, s_, m_) -> v1.uOp((i, a) -> { int ei = s_.laneSource(i); - return ei < 0 || !m_.laneIsSet(i) ? 0 : v1.lane(ei); + return !m_.laneIsSet(i) ? 0 : v1.lane(ei); })); } @@ -2393,7 +2391,10 @@ public abstract class DoubleVector extends AbstractVector { /*package-private*/ @ForceInline final DoubleVector selectFromTemplate(DoubleVector v) { - return v.rearrange(this.toShuffle()); + return (DoubleVector)VectorSupport.selectFromOp(getClass(), null, double.class, + length(), this, v, null, + (v1, v2, _m) -> + v2.rearrange(v1.toShuffle())); } /** @@ -2405,9 +2406,15 @@ public abstract class DoubleVector extends AbstractVector { /*package-private*/ @ForceInline - final DoubleVector selectFromTemplate(DoubleVector v, - AbstractMask m) { - return v.rearrange(this.toShuffle(), m); + final + > + DoubleVector selectFromTemplate(DoubleVector v, + Class masktype, M m) { + m.check(masktype, this); + return (DoubleVector)VectorSupport.selectFromOp(getClass(), masktype, double.class, + length(), this, v, m, + (v1, v2, _m) -> + v2.rearrange(v1.toShuffle(), _m)); } /// Ternary operations diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float128Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float128Vector.java index d6b66f77431..2e016725f81 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float128Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float128Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -490,7 +490,7 @@ final class Float128Vector extends FloatVector { VectorMask m) { return (Float128Vector) super.selectFromTemplate((Float128Vector) v, - (Float128Mask) m); // specialize + Float128Mask.class, (Float128Mask) m); // specialize } @@ -514,7 +514,7 @@ final class Float128Vector extends FloatVector { this, i, (vec, ix) -> { float[] vecarr = vec.vec(); - return (long)Float.floatToIntBits(vecarr[ix]); + return (long)Float.floatToRawIntBits(vecarr[ix]); }); } @@ -533,7 +533,7 @@ final class Float128Vector extends FloatVector { public Float128Vector withLaneHelper(int i, float e) { return VectorSupport.insert( VCLASS, ETYPE, VLENGTH, - this, i, (long)Float.floatToIntBits(e), + this, i, (long)Float.floatToRawIntBits(e), (v, ix, bits) -> { float[] res = v.vec().clone(); res[ix] = Float.intBitsToFloat((int)bits); @@ -825,6 +825,13 @@ final class Float128Vector extends FloatVector { return s.shuffleFromArray(shuffleArray, 0).check(s); } + @Override + @ForceInline + public Float128Shuffle wrapIndexes() { + return VectorSupport.wrapShuffleIndexes(ETYPE, Float128Shuffle.class, this, VLENGTH, + (s) -> ((Float128Shuffle)(((AbstractShuffle)(s)).wrapIndexesTemplate()))); + } + @ForceInline @Override public Float128Shuffle rearrange(VectorShuffle shuffle) { diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float256Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float256Vector.java index 38e5bee8a97..00e60835883 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float256Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float256Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -490,7 +490,7 @@ final class Float256Vector extends FloatVector { VectorMask m) { return (Float256Vector) super.selectFromTemplate((Float256Vector) v, - (Float256Mask) m); // specialize + Float256Mask.class, (Float256Mask) m); // specialize } @@ -518,7 +518,7 @@ final class Float256Vector extends FloatVector { this, i, (vec, ix) -> { float[] vecarr = vec.vec(); - return (long)Float.floatToIntBits(vecarr[ix]); + return (long)Float.floatToRawIntBits(vecarr[ix]); }); } @@ -541,7 +541,7 @@ final class Float256Vector extends FloatVector { public Float256Vector withLaneHelper(int i, float e) { return VectorSupport.insert( VCLASS, ETYPE, VLENGTH, - this, i, (long)Float.floatToIntBits(e), + this, i, (long)Float.floatToRawIntBits(e), (v, ix, bits) -> { float[] res = v.vec().clone(); res[ix] = Float.intBitsToFloat((int)bits); @@ -833,6 +833,13 @@ final class Float256Vector extends FloatVector { return s.shuffleFromArray(shuffleArray, 0).check(s); } + @Override + @ForceInline + public Float256Shuffle wrapIndexes() { + return VectorSupport.wrapShuffleIndexes(ETYPE, Float256Shuffle.class, this, VLENGTH, + (s) -> ((Float256Shuffle)(((AbstractShuffle)(s)).wrapIndexesTemplate()))); + } + @ForceInline @Override public Float256Shuffle rearrange(VectorShuffle shuffle) { diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float512Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float512Vector.java index 3a398976d98..1f2a792c52c 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float512Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float512Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -490,7 +490,7 @@ final class Float512Vector extends FloatVector { VectorMask m) { return (Float512Vector) super.selectFromTemplate((Float512Vector) v, - (Float512Mask) m); // specialize + Float512Mask.class, (Float512Mask) m); // specialize } @@ -526,7 +526,7 @@ final class Float512Vector extends FloatVector { this, i, (vec, ix) -> { float[] vecarr = vec.vec(); - return (long)Float.floatToIntBits(vecarr[ix]); + return (long)Float.floatToRawIntBits(vecarr[ix]); }); } @@ -557,7 +557,7 @@ final class Float512Vector extends FloatVector { public Float512Vector withLaneHelper(int i, float e) { return VectorSupport.insert( VCLASS, ETYPE, VLENGTH, - this, i, (long)Float.floatToIntBits(e), + this, i, (long)Float.floatToRawIntBits(e), (v, ix, bits) -> { float[] res = v.vec().clone(); res[ix] = Float.intBitsToFloat((int)bits); @@ -849,6 +849,13 @@ final class Float512Vector extends FloatVector { return s.shuffleFromArray(shuffleArray, 0).check(s); } + @Override + @ForceInline + public Float512Shuffle wrapIndexes() { + return VectorSupport.wrapShuffleIndexes(ETYPE, Float512Shuffle.class, this, VLENGTH, + (s) -> ((Float512Shuffle)(((AbstractShuffle)(s)).wrapIndexesTemplate()))); + } + @ForceInline @Override public Float512Shuffle rearrange(VectorShuffle shuffle) { diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float64Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float64Vector.java index 867b3e284ae..6c913ce84a9 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float64Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float64Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -490,7 +490,7 @@ final class Float64Vector extends FloatVector { VectorMask m) { return (Float64Vector) super.selectFromTemplate((Float64Vector) v, - (Float64Mask) m); // specialize + Float64Mask.class, (Float64Mask) m); // specialize } @@ -512,7 +512,7 @@ final class Float64Vector extends FloatVector { this, i, (vec, ix) -> { float[] vecarr = vec.vec(); - return (long)Float.floatToIntBits(vecarr[ix]); + return (long)Float.floatToRawIntBits(vecarr[ix]); }); } @@ -529,7 +529,7 @@ final class Float64Vector extends FloatVector { public Float64Vector withLaneHelper(int i, float e) { return VectorSupport.insert( VCLASS, ETYPE, VLENGTH, - this, i, (long)Float.floatToIntBits(e), + this, i, (long)Float.floatToRawIntBits(e), (v, ix, bits) -> { float[] res = v.vec().clone(); res[ix] = Float.intBitsToFloat((int)bits); @@ -821,6 +821,13 @@ final class Float64Vector extends FloatVector { return s.shuffleFromArray(shuffleArray, 0).check(s); } + @Override + @ForceInline + public Float64Shuffle wrapIndexes() { + return VectorSupport.wrapShuffleIndexes(ETYPE, Float64Shuffle.class, this, VLENGTH, + (s) -> ((Float64Shuffle)(((AbstractShuffle)(s)).wrapIndexesTemplate()))); + } + @ForceInline @Override public Float64Shuffle rearrange(VectorShuffle shuffle) { diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatMaxVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatMaxVector.java index 242d405eafb..b9a0a93f912 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatMaxVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatMaxVector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -490,7 +490,7 @@ final class FloatMaxVector extends FloatVector { VectorMask m) { return (FloatMaxVector) super.selectFromTemplate((FloatMaxVector) v, - (FloatMaxMask) m); // specialize + FloatMaxMask.class, (FloatMaxMask) m); // specialize } @@ -510,7 +510,7 @@ final class FloatMaxVector extends FloatVector { this, i, (vec, ix) -> { float[] vecarr = vec.vec(); - return (long)Float.floatToIntBits(vecarr[ix]); + return (long)Float.floatToRawIntBits(vecarr[ix]); }); } @@ -526,7 +526,7 @@ final class FloatMaxVector extends FloatVector { public FloatMaxVector withLaneHelper(int i, float e) { return VectorSupport.insert( VCLASS, ETYPE, VLENGTH, - this, i, (long)Float.floatToIntBits(e), + this, i, (long)Float.floatToRawIntBits(e), (v, ix, bits) -> { float[] res = v.vec().clone(); res[ix] = Float.intBitsToFloat((int)bits); @@ -818,6 +818,13 @@ final class FloatMaxVector extends FloatVector { return s.shuffleFromArray(shuffleArray, 0).check(s); } + @Override + @ForceInline + public FloatMaxShuffle wrapIndexes() { + return VectorSupport.wrapShuffleIndexes(ETYPE, FloatMaxShuffle.class, this, VLENGTH, + (s) -> ((FloatMaxShuffle)(((AbstractShuffle)(s)).wrapIndexesTemplate()))); + } + @ForceInline @Override public FloatMaxShuffle rearrange(VectorShuffle shuffle) { diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatVector.java index 45427817e3d..b962dc55ce3 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatVector.java @@ -2247,17 +2247,18 @@ public abstract class FloatVector extends AbstractVector { */ @Override public abstract - FloatVector rearrange(VectorShuffle m); + FloatVector rearrange(VectorShuffle shuffle); /*package-private*/ @ForceInline final > FloatVector rearrangeTemplate(Class shuffletype, S shuffle) { - shuffle.checkIndexes(); + @SuppressWarnings("unchecked") + S ws = (S) shuffle.wrapIndexes(); return VectorSupport.rearrangeOp( getClass(), shuffletype, null, float.class, length(), - this, shuffle, null, + this, ws, null, (v1, s_, m_) -> v1.uOp((i, a) -> { int ei = s_.laneSource(i); return v1.lane(ei); @@ -2282,17 +2283,14 @@ public abstract class FloatVector extends AbstractVector { M m) { m.check(masktype, this); - VectorMask valid = shuffle.laneIsValid(); - if (m.andNot(valid).anyTrue()) { - shuffle.checkIndexes(); - throw new AssertionError(); - } + @SuppressWarnings("unchecked") + S ws = (S) shuffle.wrapIndexes(); return VectorSupport.rearrangeOp( getClass(), shuffletype, masktype, float.class, length(), - this, shuffle, m, + this, ws, m, (v1, s_, m_) -> v1.uOp((i, a) -> { int ei = s_.laneSource(i); - return ei < 0 || !m_.laneIsSet(i) ? 0 : v1.lane(ei); + return !m_.laneIsSet(i) ? 0 : v1.lane(ei); })); } @@ -2405,7 +2403,10 @@ public abstract class FloatVector extends AbstractVector { /*package-private*/ @ForceInline final FloatVector selectFromTemplate(FloatVector v) { - return v.rearrange(this.toShuffle()); + return (FloatVector)VectorSupport.selectFromOp(getClass(), null, float.class, + length(), this, v, null, + (v1, v2, _m) -> + v2.rearrange(v1.toShuffle())); } /** @@ -2417,9 +2418,15 @@ public abstract class FloatVector extends AbstractVector { /*package-private*/ @ForceInline - final FloatVector selectFromTemplate(FloatVector v, - AbstractMask m) { - return v.rearrange(this.toShuffle(), m); + final + > + FloatVector selectFromTemplate(FloatVector v, + Class masktype, M m) { + m.check(masktype, this); + return (FloatVector)VectorSupport.selectFromOp(getClass(), masktype, float.class, + length(), this, v, m, + (v1, v2, _m) -> + v2.rearrange(v1.toShuffle(), _m)); } /// Ternary operations diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int128Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int128Vector.java index 0c83b037454..f7135e19cb6 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int128Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int128Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -503,7 +503,7 @@ final class Int128Vector extends IntVector { VectorMask m) { return (Int128Vector) super.selectFromTemplate((Int128Vector) v, - (Int128Mask) m); // specialize + Int128Mask.class, (Int128Mask) m); // specialize } @@ -836,6 +836,13 @@ final class Int128Vector extends IntVector { return s.shuffleFromArray(shuffleArray, 0).check(s); } + @Override + @ForceInline + public Int128Shuffle wrapIndexes() { + return VectorSupport.wrapShuffleIndexes(ETYPE, Int128Shuffle.class, this, VLENGTH, + (s) -> ((Int128Shuffle)(((AbstractShuffle)(s)).wrapIndexesTemplate()))); + } + @ForceInline @Override public Int128Shuffle rearrange(VectorShuffle shuffle) { diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int256Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int256Vector.java index abb10696ba4..474ff974b31 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int256Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int256Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -503,7 +503,7 @@ final class Int256Vector extends IntVector { VectorMask m) { return (Int256Vector) super.selectFromTemplate((Int256Vector) v, - (Int256Mask) m); // specialize + Int256Mask.class, (Int256Mask) m); // specialize } @@ -844,6 +844,13 @@ final class Int256Vector extends IntVector { return s.shuffleFromArray(shuffleArray, 0).check(s); } + @Override + @ForceInline + public Int256Shuffle wrapIndexes() { + return VectorSupport.wrapShuffleIndexes(ETYPE, Int256Shuffle.class, this, VLENGTH, + (s) -> ((Int256Shuffle)(((AbstractShuffle)(s)).wrapIndexesTemplate()))); + } + @ForceInline @Override public Int256Shuffle rearrange(VectorShuffle shuffle) { diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int512Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int512Vector.java index 7b6435e4c0a..9fec8c0c99f 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int512Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int512Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -503,7 +503,7 @@ final class Int512Vector extends IntVector { VectorMask m) { return (Int512Vector) super.selectFromTemplate((Int512Vector) v, - (Int512Mask) m); // specialize + Int512Mask.class, (Int512Mask) m); // specialize } @@ -860,6 +860,13 @@ final class Int512Vector extends IntVector { return s.shuffleFromArray(shuffleArray, 0).check(s); } + @Override + @ForceInline + public Int512Shuffle wrapIndexes() { + return VectorSupport.wrapShuffleIndexes(ETYPE, Int512Shuffle.class, this, VLENGTH, + (s) -> ((Int512Shuffle)(((AbstractShuffle)(s)).wrapIndexesTemplate()))); + } + @ForceInline @Override public Int512Shuffle rearrange(VectorShuffle shuffle) { diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int64Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int64Vector.java index 491010be90e..3b3c0723ee1 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int64Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int64Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -503,7 +503,7 @@ final class Int64Vector extends IntVector { VectorMask m) { return (Int64Vector) super.selectFromTemplate((Int64Vector) v, - (Int64Mask) m); // specialize + Int64Mask.class, (Int64Mask) m); // specialize } @@ -832,6 +832,13 @@ final class Int64Vector extends IntVector { return s.shuffleFromArray(shuffleArray, 0).check(s); } + @Override + @ForceInline + public Int64Shuffle wrapIndexes() { + return VectorSupport.wrapShuffleIndexes(ETYPE, Int64Shuffle.class, this, VLENGTH, + (s) -> ((Int64Shuffle)(((AbstractShuffle)(s)).wrapIndexesTemplate()))); + } + @ForceInline @Override public Int64Shuffle rearrange(VectorShuffle shuffle) { diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntMaxVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntMaxVector.java index e20829f7c4f..5738cb7a4bc 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntMaxVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntMaxVector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -503,7 +503,7 @@ final class IntMaxVector extends IntVector { VectorMask m) { return (IntMaxVector) super.selectFromTemplate((IntMaxVector) v, - (IntMaxMask) m); // specialize + IntMaxMask.class, (IntMaxMask) m); // specialize } @@ -841,6 +841,13 @@ final class IntMaxVector extends IntVector { return s.shuffleFromArray(shuffleArray, 0).check(s); } + @Override + @ForceInline + public IntMaxShuffle wrapIndexes() { + return VectorSupport.wrapShuffleIndexes(ETYPE, IntMaxShuffle.class, this, VLENGTH, + (s) -> ((IntMaxShuffle)(((AbstractShuffle)(s)).wrapIndexesTemplate()))); + } + @ForceInline @Override public IntMaxShuffle rearrange(VectorShuffle shuffle) { diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVector.java index 3317e25e73e..16b5ceecba3 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVector.java @@ -2378,17 +2378,18 @@ public abstract class IntVector extends AbstractVector { */ @Override public abstract - IntVector rearrange(VectorShuffle m); + IntVector rearrange(VectorShuffle shuffle); /*package-private*/ @ForceInline final > IntVector rearrangeTemplate(Class shuffletype, S shuffle) { - shuffle.checkIndexes(); + @SuppressWarnings("unchecked") + S ws = (S) shuffle.wrapIndexes(); return VectorSupport.rearrangeOp( getClass(), shuffletype, null, int.class, length(), - this, shuffle, null, + this, ws, null, (v1, s_, m_) -> v1.uOp((i, a) -> { int ei = s_.laneSource(i); return v1.lane(ei); @@ -2413,17 +2414,14 @@ public abstract class IntVector extends AbstractVector { M m) { m.check(masktype, this); - VectorMask valid = shuffle.laneIsValid(); - if (m.andNot(valid).anyTrue()) { - shuffle.checkIndexes(); - throw new AssertionError(); - } + @SuppressWarnings("unchecked") + S ws = (S) shuffle.wrapIndexes(); return VectorSupport.rearrangeOp( getClass(), shuffletype, masktype, int.class, length(), - this, shuffle, m, + this, ws, m, (v1, s_, m_) -> v1.uOp((i, a) -> { int ei = s_.laneSource(i); - return ei < 0 || !m_.laneIsSet(i) ? 0 : v1.lane(ei); + return !m_.laneIsSet(i) ? 0 : v1.lane(ei); })); } @@ -2536,7 +2534,10 @@ public abstract class IntVector extends AbstractVector { /*package-private*/ @ForceInline final IntVector selectFromTemplate(IntVector v) { - return v.rearrange(this.toShuffle()); + return (IntVector)VectorSupport.selectFromOp(getClass(), null, int.class, + length(), this, v, null, + (v1, v2, _m) -> + v2.rearrange(v1.toShuffle())); } /** @@ -2548,9 +2549,15 @@ public abstract class IntVector extends AbstractVector { /*package-private*/ @ForceInline - final IntVector selectFromTemplate(IntVector v, - AbstractMask m) { - return v.rearrange(this.toShuffle(), m); + final + > + IntVector selectFromTemplate(IntVector v, + Class masktype, M m) { + m.check(masktype, this); + return (IntVector)VectorSupport.selectFromOp(getClass(), masktype, int.class, + length(), this, v, m, + (v1, v2, _m) -> + v2.rearrange(v1.toShuffle(), _m)); } /// Ternary operations diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long128Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long128Vector.java index cf552c23a80..567789627c6 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long128Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long128Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -493,7 +493,7 @@ final class Long128Vector extends LongVector { VectorMask m) { return (Long128Vector) super.selectFromTemplate((Long128Vector) v, - (Long128Mask) m); // specialize + Long128Mask.class, (Long128Mask) m); // specialize } @@ -822,6 +822,13 @@ final class Long128Vector extends LongVector { return s.shuffleFromArray(shuffleArray, 0).check(s); } + @Override + @ForceInline + public Long128Shuffle wrapIndexes() { + return VectorSupport.wrapShuffleIndexes(ETYPE, Long128Shuffle.class, this, VLENGTH, + (s) -> ((Long128Shuffle)(((AbstractShuffle)(s)).wrapIndexesTemplate()))); + } + @ForceInline @Override public Long128Shuffle rearrange(VectorShuffle shuffle) { diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long256Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long256Vector.java index ffa1029bdd8..5ef0f121464 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long256Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long256Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -493,7 +493,7 @@ final class Long256Vector extends LongVector { VectorMask m) { return (Long256Vector) super.selectFromTemplate((Long256Vector) v, - (Long256Mask) m); // specialize + Long256Mask.class, (Long256Mask) m); // specialize } @@ -826,6 +826,13 @@ final class Long256Vector extends LongVector { return s.shuffleFromArray(shuffleArray, 0).check(s); } + @Override + @ForceInline + public Long256Shuffle wrapIndexes() { + return VectorSupport.wrapShuffleIndexes(ETYPE, Long256Shuffle.class, this, VLENGTH, + (s) -> ((Long256Shuffle)(((AbstractShuffle)(s)).wrapIndexesTemplate()))); + } + @ForceInline @Override public Long256Shuffle rearrange(VectorShuffle shuffle) { diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long512Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long512Vector.java index aea8fe0fe6c..acdb471609f 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long512Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long512Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -493,7 +493,7 @@ final class Long512Vector extends LongVector { VectorMask m) { return (Long512Vector) super.selectFromTemplate((Long512Vector) v, - (Long512Mask) m); // specialize + Long512Mask.class, (Long512Mask) m); // specialize } @@ -834,6 +834,13 @@ final class Long512Vector extends LongVector { return s.shuffleFromArray(shuffleArray, 0).check(s); } + @Override + @ForceInline + public Long512Shuffle wrapIndexes() { + return VectorSupport.wrapShuffleIndexes(ETYPE, Long512Shuffle.class, this, VLENGTH, + (s) -> ((Long512Shuffle)(((AbstractShuffle)(s)).wrapIndexesTemplate()))); + } + @ForceInline @Override public Long512Shuffle rearrange(VectorShuffle shuffle) { diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long64Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long64Vector.java index ffb07535d65..627f7437367 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long64Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long64Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -493,7 +493,7 @@ final class Long64Vector extends LongVector { VectorMask m) { return (Long64Vector) super.selectFromTemplate((Long64Vector) v, - (Long64Mask) m); // specialize + Long64Mask.class, (Long64Mask) m); // specialize } @@ -820,6 +820,13 @@ final class Long64Vector extends LongVector { return s.shuffleFromArray(shuffleArray, 0).check(s); } + @Override + @ForceInline + public Long64Shuffle wrapIndexes() { + return VectorSupport.wrapShuffleIndexes(ETYPE, Long64Shuffle.class, this, VLENGTH, + (s) -> ((Long64Shuffle)(((AbstractShuffle)(s)).wrapIndexesTemplate()))); + } + @ForceInline @Override public Long64Shuffle rearrange(VectorShuffle shuffle) { diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongMaxVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongMaxVector.java index e4197cb7f2e..aec3bb89fcd 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongMaxVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongMaxVector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -493,7 +493,7 @@ final class LongMaxVector extends LongVector { VectorMask m) { return (LongMaxVector) super.selectFromTemplate((LongMaxVector) v, - (LongMaxMask) m); // specialize + LongMaxMask.class, (LongMaxMask) m); // specialize } @@ -820,6 +820,13 @@ final class LongMaxVector extends LongVector { return s.shuffleFromArray(shuffleArray, 0).check(s); } + @Override + @ForceInline + public LongMaxShuffle wrapIndexes() { + return VectorSupport.wrapShuffleIndexes(ETYPE, LongMaxShuffle.class, this, VLENGTH, + (s) -> ((LongMaxShuffle)(((AbstractShuffle)(s)).wrapIndexesTemplate()))); + } + @ForceInline @Override public LongMaxShuffle rearrange(VectorShuffle shuffle) { diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongVector.java index 9dd3f2eb136..15ac2bc7b7f 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongVector.java @@ -2244,17 +2244,18 @@ public abstract class LongVector extends AbstractVector { */ @Override public abstract - LongVector rearrange(VectorShuffle m); + LongVector rearrange(VectorShuffle shuffle); /*package-private*/ @ForceInline final > LongVector rearrangeTemplate(Class shuffletype, S shuffle) { - shuffle.checkIndexes(); + @SuppressWarnings("unchecked") + S ws = (S) shuffle.wrapIndexes(); return VectorSupport.rearrangeOp( getClass(), shuffletype, null, long.class, length(), - this, shuffle, null, + this, ws, null, (v1, s_, m_) -> v1.uOp((i, a) -> { int ei = s_.laneSource(i); return v1.lane(ei); @@ -2279,17 +2280,14 @@ public abstract class LongVector extends AbstractVector { M m) { m.check(masktype, this); - VectorMask valid = shuffle.laneIsValid(); - if (m.andNot(valid).anyTrue()) { - shuffle.checkIndexes(); - throw new AssertionError(); - } + @SuppressWarnings("unchecked") + S ws = (S) shuffle.wrapIndexes(); return VectorSupport.rearrangeOp( getClass(), shuffletype, masktype, long.class, length(), - this, shuffle, m, + this, ws, m, (v1, s_, m_) -> v1.uOp((i, a) -> { int ei = s_.laneSource(i); - return ei < 0 || !m_.laneIsSet(i) ? 0 : v1.lane(ei); + return !m_.laneIsSet(i) ? 0 : v1.lane(ei); })); } @@ -2402,7 +2400,10 @@ public abstract class LongVector extends AbstractVector { /*package-private*/ @ForceInline final LongVector selectFromTemplate(LongVector v) { - return v.rearrange(this.toShuffle()); + return (LongVector)VectorSupport.selectFromOp(getClass(), null, long.class, + length(), this, v, null, + (v1, v2, _m) -> + v2.rearrange(v1.toShuffle())); } /** @@ -2414,9 +2415,15 @@ public abstract class LongVector extends AbstractVector { /*package-private*/ @ForceInline - final LongVector selectFromTemplate(LongVector v, - AbstractMask m) { - return v.rearrange(this.toShuffle(), m); + final + > + LongVector selectFromTemplate(LongVector v, + Class masktype, M m) { + m.check(masktype, this); + return (LongVector)VectorSupport.selectFromOp(getClass(), masktype, long.class, + length(), this, v, m, + (v1, v2, _m) -> + v2.rearrange(v1.toShuffle(), _m)); } /// Ternary operations diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short128Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short128Vector.java index 3930826aa09..fe34886512a 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short128Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short128Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -503,7 +503,7 @@ final class Short128Vector extends ShortVector { VectorMask m) { return (Short128Vector) super.selectFromTemplate((Short128Vector) v, - (Short128Mask) m); // specialize + Short128Mask.class, (Short128Mask) m); // specialize } @@ -844,6 +844,13 @@ final class Short128Vector extends ShortVector { return s.shuffleFromArray(shuffleArray, 0).check(s); } + @Override + @ForceInline + public Short128Shuffle wrapIndexes() { + return VectorSupport.wrapShuffleIndexes(ETYPE, Short128Shuffle.class, this, VLENGTH, + (s) -> ((Short128Shuffle)(((AbstractShuffle)(s)).wrapIndexesTemplate()))); + } + @ForceInline @Override public Short128Shuffle rearrange(VectorShuffle shuffle) { diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short256Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short256Vector.java index e39e89f6137..243e24ad26b 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short256Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short256Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -503,7 +503,7 @@ final class Short256Vector extends ShortVector { VectorMask m) { return (Short256Vector) super.selectFromTemplate((Short256Vector) v, - (Short256Mask) m); // specialize + Short256Mask.class, (Short256Mask) m); // specialize } @@ -860,6 +860,13 @@ final class Short256Vector extends ShortVector { return s.shuffleFromArray(shuffleArray, 0).check(s); } + @Override + @ForceInline + public Short256Shuffle wrapIndexes() { + return VectorSupport.wrapShuffleIndexes(ETYPE, Short256Shuffle.class, this, VLENGTH, + (s) -> ((Short256Shuffle)(((AbstractShuffle)(s)).wrapIndexesTemplate()))); + } + @ForceInline @Override public Short256Shuffle rearrange(VectorShuffle shuffle) { diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short512Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short512Vector.java index 1caea78f748..41147836089 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short512Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short512Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -503,7 +503,7 @@ final class Short512Vector extends ShortVector { VectorMask m) { return (Short512Vector) super.selectFromTemplate((Short512Vector) v, - (Short512Mask) m); // specialize + Short512Mask.class, (Short512Mask) m); // specialize } @@ -892,6 +892,13 @@ final class Short512Vector extends ShortVector { return s.shuffleFromArray(shuffleArray, 0).check(s); } + @Override + @ForceInline + public Short512Shuffle wrapIndexes() { + return VectorSupport.wrapShuffleIndexes(ETYPE, Short512Shuffle.class, this, VLENGTH, + (s) -> ((Short512Shuffle)(((AbstractShuffle)(s)).wrapIndexesTemplate()))); + } + @ForceInline @Override public Short512Shuffle rearrange(VectorShuffle shuffle) { diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short64Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short64Vector.java index 640be746f15..d80d4c4e2ec 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short64Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short64Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -503,7 +503,7 @@ final class Short64Vector extends ShortVector { VectorMask m) { return (Short64Vector) super.selectFromTemplate((Short64Vector) v, - (Short64Mask) m); // specialize + Short64Mask.class, (Short64Mask) m); // specialize } @@ -836,6 +836,13 @@ final class Short64Vector extends ShortVector { return s.shuffleFromArray(shuffleArray, 0).check(s); } + @Override + @ForceInline + public Short64Shuffle wrapIndexes() { + return VectorSupport.wrapShuffleIndexes(ETYPE, Short64Shuffle.class, this, VLENGTH, + (s) -> ((Short64Shuffle)(((AbstractShuffle)(s)).wrapIndexesTemplate()))); + } + @ForceInline @Override public Short64Shuffle rearrange(VectorShuffle shuffle) { diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortMaxVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortMaxVector.java index 96683ac53c4..799483a6675 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortMaxVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortMaxVector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -503,7 +503,7 @@ final class ShortMaxVector extends ShortVector { VectorMask m) { return (ShortMaxVector) super.selectFromTemplate((ShortMaxVector) v, - (ShortMaxMask) m); // specialize + ShortMaxMask.class, (ShortMaxMask) m); // specialize } @@ -830,6 +830,13 @@ final class ShortMaxVector extends ShortVector { return s.shuffleFromArray(shuffleArray, 0).check(s); } + @Override + @ForceInline + public ShortMaxShuffle wrapIndexes() { + return VectorSupport.wrapShuffleIndexes(ETYPE, ShortMaxShuffle.class, this, VLENGTH, + (s) -> ((ShortMaxShuffle)(((AbstractShuffle)(s)).wrapIndexesTemplate()))); + } + @ForceInline @Override public ShortMaxShuffle rearrange(VectorShuffle shuffle) { diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVector.java index ba21e8a9e95..fb0512fd5b9 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVector.java @@ -2394,17 +2394,18 @@ public abstract class ShortVector extends AbstractVector { */ @Override public abstract - ShortVector rearrange(VectorShuffle m); + ShortVector rearrange(VectorShuffle shuffle); /*package-private*/ @ForceInline final > ShortVector rearrangeTemplate(Class shuffletype, S shuffle) { - shuffle.checkIndexes(); + @SuppressWarnings("unchecked") + S ws = (S) shuffle.wrapIndexes(); return VectorSupport.rearrangeOp( getClass(), shuffletype, null, short.class, length(), - this, shuffle, null, + this, ws, null, (v1, s_, m_) -> v1.uOp((i, a) -> { int ei = s_.laneSource(i); return v1.lane(ei); @@ -2429,17 +2430,14 @@ public abstract class ShortVector extends AbstractVector { M m) { m.check(masktype, this); - VectorMask valid = shuffle.laneIsValid(); - if (m.andNot(valid).anyTrue()) { - shuffle.checkIndexes(); - throw new AssertionError(); - } + @SuppressWarnings("unchecked") + S ws = (S) shuffle.wrapIndexes(); return VectorSupport.rearrangeOp( getClass(), shuffletype, masktype, short.class, length(), - this, shuffle, m, + this, ws, m, (v1, s_, m_) -> v1.uOp((i, a) -> { int ei = s_.laneSource(i); - return ei < 0 || !m_.laneIsSet(i) ? 0 : v1.lane(ei); + return !m_.laneIsSet(i) ? 0 : v1.lane(ei); })); } @@ -2552,7 +2550,10 @@ public abstract class ShortVector extends AbstractVector { /*package-private*/ @ForceInline final ShortVector selectFromTemplate(ShortVector v) { - return v.rearrange(this.toShuffle()); + return (ShortVector)VectorSupport.selectFromOp(getClass(), null, short.class, + length(), this, v, null, + (v1, v2, _m) -> + v2.rearrange(v1.toShuffle())); } /** @@ -2564,9 +2565,15 @@ public abstract class ShortVector extends AbstractVector { /*package-private*/ @ForceInline - final ShortVector selectFromTemplate(ShortVector v, - AbstractMask m) { - return v.rearrange(this.toShuffle(), m); + final + > + ShortVector selectFromTemplate(ShortVector v, + Class masktype, M m) { + m.check(masktype, this); + return (ShortVector)VectorSupport.selectFromOp(getClass(), masktype, short.class, + length(), this, v, m, + (v1, v2, _m) -> + v2.rearrange(v1.toShuffle(), _m)); } /// Ternary operations diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Vector.java index d34ac79e7c3..fda073f6863 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Vector.java @@ -2614,17 +2614,14 @@ public abstract class Vector extends jdk.internal.vm.vector.VectorSupport.Vec * elements of this vector. * * For each lane {@code N} of the shuffle, and for each lane - * source index {@code I=s.laneSource(N)} in the shuffle, + * source index {@code I=s.wrapIndex(s.laneSource(N))} in the shuffle, * the output lane {@code N} obtains the value from * the input vector at lane {@code I}. * * @param s the shuffle controlling lane index selection * @return the rearrangement of the lane elements of this vector - * @throws IndexOutOfBoundsException if there are any exceptional - * source indexes in the shuffle * @see #rearrange(VectorShuffle,VectorMask) * @see #rearrange(VectorShuffle,Vector) - * @see VectorShuffle#laneIsValid() */ public abstract Vector rearrange(VectorShuffle s); @@ -2636,27 +2633,22 @@ public abstract class Vector extends jdk.internal.vm.vector.VectorSupport.Vec * elements of this vector. * * For each lane {@code N} of the shuffle, and for each lane - * source index {@code I=s.laneSource(N)} in the shuffle, + * source index {@code I=s.wrapIndex(s.laneSource(N))} in the shuffle, * the output lane {@code N} obtains the value from * the input vector at lane {@code I} if the mask is set. * Otherwise the output lane {@code N} is set to zero. * *

                  This method returns the value of this pseudocode: *

                  {@code
                  -     * Vector r = this.rearrange(s.wrapIndexes());
                  -     * VectorMask valid = s.laneIsValid();
                  -     * if (m.andNot(valid).anyTrue()) throw ...;
                  +     * Vector r = this.rearrange(s);
                        * return broadcast(0).blend(r, m);
                        * }
                  * * @param s the shuffle controlling lane index selection * @param m the mask controlling application of the shuffle * @return the rearrangement of the lane elements of this vector - * @throws IndexOutOfBoundsException if there are any exceptional - * source indexes in the shuffle where the mask is set * @see #rearrange(VectorShuffle) * @see #rearrange(VectorShuffle,Vector) - * @see VectorShuffle#laneIsValid() */ public abstract Vector rearrange(VectorShuffle s, VectorMask m); @@ -2747,7 +2739,7 @@ public abstract class Vector extends jdk.internal.vm.vector.VectorSupport.Vec * this vector. * * For each lane {@code N} of this vector, and for each lane - * value {@code I=this.lane(N)} in this vector, + * value {@code I=wrapIndex(this.lane(N))} in this vector, * the output lane {@code N} obtains the value from * the argument vector at lane {@code I}. * @@ -2760,8 +2752,6 @@ public abstract class Vector extends jdk.internal.vm.vector.VectorSupport.Vec * * @param v the vector supplying the result values * @return the rearrangement of the lane elements of {@code v} - * @throws IndexOutOfBoundsException if any invalid - * source indexes are found in {@code this} * @see #rearrange(VectorShuffle) */ public abstract Vector selectFrom(Vector v); @@ -2787,9 +2777,6 @@ public abstract class Vector extends jdk.internal.vm.vector.VectorSupport.Vec * @param v the vector supplying the result values * @param m the mask controlling selection from {@code v} * @return the rearrangement of the lane elements of {@code v} - * @throws IndexOutOfBoundsException if any invalid - * source indexes are found in {@code this}, - * in a lane which is set in the mask * @see #selectFrom(Vector) * @see #rearrange(VectorShuffle,VectorMask) */ diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template index d7562bae475..fcc128ea8c7 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template @@ -2770,17 +2770,18 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { */ @Override public abstract - $abstractvectortype$ rearrange(VectorShuffle<$Boxtype$> m); + $abstractvectortype$ rearrange(VectorShuffle<$Boxtype$> shuffle); /*package-private*/ @ForceInline final > $abstractvectortype$ rearrangeTemplate(Class shuffletype, S shuffle) { - shuffle.checkIndexes(); + @SuppressWarnings("unchecked") + S ws = (S) shuffle.wrapIndexes(); return VectorSupport.rearrangeOp( getClass(), shuffletype, null, $type$.class, length(), - this, shuffle, null, + this, ws, null, (v1, s_, m_) -> v1.uOp((i, a) -> { int ei = s_.laneSource(i); return v1.lane(ei); @@ -2805,17 +2806,14 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { M m) { m.check(masktype, this); - VectorMask<$Boxtype$> valid = shuffle.laneIsValid(); - if (m.andNot(valid).anyTrue()) { - shuffle.checkIndexes(); - throw new AssertionError(); - } + @SuppressWarnings("unchecked") + S ws = (S) shuffle.wrapIndexes(); return VectorSupport.rearrangeOp( getClass(), shuffletype, masktype, $type$.class, length(), - this, shuffle, m, + this, ws, m, (v1, s_, m_) -> v1.uOp((i, a) -> { int ei = s_.laneSource(i); - return ei < 0 || !m_.laneIsSet(i) ? 0 : v1.lane(ei); + return !m_.laneIsSet(i) ? 0 : v1.lane(ei); })); } @@ -2928,7 +2926,10 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { /*package-private*/ @ForceInline final $abstractvectortype$ selectFromTemplate($abstractvectortype$ v) { - return v.rearrange(this.toShuffle()); + return ($Type$Vector)VectorSupport.selectFromOp(getClass(), null, $type$.class, + length(), this, v, null, + (v1, v2, _m) -> + v2.rearrange(v1.toShuffle())); } /** @@ -2940,9 +2941,15 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { /*package-private*/ @ForceInline - final $abstractvectortype$ selectFromTemplate($abstractvectortype$ v, - AbstractMask<$Boxtype$> m) { - return v.rearrange(this.toShuffle(), m); + final + > + $abstractvectortype$ selectFromTemplate($abstractvectortype$ v, + Class masktype, M m) { + m.check(masktype, this); + return ($Type$Vector)VectorSupport.selectFromOp(getClass(), masktype, $type$.class, + length(), this, v, m, + (v1, v2, _m) -> + v2.rearrange(v1.toShuffle(), _m)); } /// Ternary operations diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-VectorBits.java.template b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-VectorBits.java.template index cebdc7594d6..483962b4e06 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-VectorBits.java.template +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-VectorBits.java.template @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -509,7 +509,7 @@ final class $vectortype$ extends $abstractvectortype$ { VectorMask<$Boxtype$> m) { return ($vectortype$) super.selectFromTemplate(($vectortype$) v, - ($masktype$) m); // specialize + $masktype$.class, ($masktype$) m); // specialize } @@ -561,7 +561,7 @@ final class $vectortype$ extends $abstractvectortype$ { this, i, (vec, ix) -> { $type$[] vecarr = vec.vec(); - return (long)$Type$.$type$To$Bitstype$Bits(vecarr[ix]); + return (long)$Type$.$type$ToRaw$Bitstype$Bits(vecarr[ix]); }); } @@ -607,7 +607,7 @@ final class $vectortype$ extends $abstractvectortype$ { public $vectortype$ withLaneHelper(int i, $type$ e) { return VectorSupport.insert( VCLASS, ETYPE, VLENGTH, - this, i, (long)$Type$.$type$To$Bitstype$Bits(e), + this, i, (long)$Type$.$type$ToRaw$Bitstype$Bits(e), (v, ix, bits) -> { $type$[] res = v.vec().clone(); res[ix] = $Type$.$bitstype$BitsTo$Type$(($bitstype$)bits); @@ -1118,6 +1118,13 @@ final class $vectortype$ extends $abstractvectortype$ { return s.shuffleFromArray(shuffleArray, 0).check(s); } + @Override + @ForceInline + public $shuffletype$ wrapIndexes() { + return VectorSupport.wrapShuffleIndexes(ETYPE, $shuffletype$.class, this, VLENGTH, + (s) -> (($shuffletype$)(((AbstractShuffle<$Boxtype$>)(s)).wrapIndexesTemplate()))); + } + @ForceInline @Override public $shuffletype$ rearrange(VectorShuffle<$Boxtype$> shuffle) { diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotJVMCICompilerConfig.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotJVMCICompilerConfig.java index 9a1fef061e3..d25a7c974a5 100644 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotJVMCICompilerConfig.java +++ b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotJVMCICompilerConfig.java @@ -104,12 +104,15 @@ final class HotSpotJVMCICompilerConfig { } } if (factory == null) { + String reason; if (Services.IS_IN_NATIVE_IMAGE) { - throw runtime.exitHotSpotWithMessage(1, "JVMCI compiler '%s' not found in JVMCI native library.%n" + + reason = String.format("JVMCI compiler '%s' not found in JVMCI native library.%n" + "Use -XX:-UseJVMCINativeLibrary when specifying a JVMCI compiler available on a class path with %s.%n", compilerName, compPropertyName); + } else { + reason = String.format("JVMCI compiler '%s' specified by %s not found%n", compilerName, compPropertyName); } - throw runtime.exitHotSpotWithMessage(1, "JVMCI compiler '%s' specified by %s not found%n", compilerName, compPropertyName); + factory = new DummyCompilerFactory(reason, runtime); } } } else { diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl.java index 46e7280bbb7..91c9e73b532 100644 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl.java +++ b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -170,6 +170,11 @@ final class HotSpotResolvedObjectTypeImpl extends HotSpotResolvedJavaType implem return UNSAFE.getInt(getKlassPointer() + config.klassAccessFlagsOffset); } + public int getMiscFlags() { + HotSpotVMConfig config = config(); + return UNSAFE.getInt(getKlassPointer() + config.klassMiscFlagsOffset); + } + @Override public ResolvedJavaType getComponentType() { if (componentType == null) { @@ -373,7 +378,7 @@ final class HotSpotResolvedObjectTypeImpl extends HotSpotResolvedJavaType implem @Override public boolean hasFinalizer() { - return (getAccessFlags() & config().jvmAccHasFinalizer) != 0; + return (getMiscFlags() & config().jvmAccHasFinalizer) != 0; } @Override @@ -1110,7 +1115,7 @@ final class HotSpotResolvedObjectTypeImpl extends HotSpotResolvedJavaType implem @Override public boolean isCloneableWithAllocation() { - return (getAccessFlags() & config().jvmAccIsCloneableFast) != 0; + return (getMiscFlags() & config().jvmAccIsCloneableFast) != 0; } @Override diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotVMConfig.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotVMConfig.java index 954e1f6b201..16d9cf3625e 100644 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotVMConfig.java +++ b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotVMConfig.java @@ -98,6 +98,7 @@ class HotSpotVMConfig extends HotSpotVMConfigAccess { final int instanceKlassFieldInfoStreamOffset = getFieldOffset("InstanceKlass::_fieldinfo_stream", Integer.class, "Array*"); final int instanceKlassAnnotationsOffset = getFieldOffset("InstanceKlass::_annotations", Integer.class, "Annotations*"); final int instanceKlassMiscFlagsOffset = getFieldOffset("InstanceKlass::_misc_flags._flags", Integer.class, "u2"); + final int klassMiscFlagsOffset = getFieldOffset("Klass::_misc_flags._flags", Integer.class, "u1"); final int klassVtableStartOffset = getFieldValue("CompilerToVM::Data::Klass_vtable_start_offset", Integer.class, "int"); final int klassVtableLengthOffset = getFieldValue("CompilerToVM::Data::Klass_vtable_length_offset", Integer.class, "int"); @@ -113,10 +114,10 @@ class HotSpotVMConfig extends HotSpotVMConfigAccess { final int arrayU1DataOffset = getFieldOffset("Array::_data", Integer.class); final int arrayU2DataOffset = getFieldOffset("Array::_data", Integer.class); - final int jvmAccHasFinalizer = getConstant("JVM_ACC_HAS_FINALIZER", Integer.class); + final int jvmAccHasFinalizer = getConstant("KlassFlags::_misc_has_finalizer", Integer.class); final int jvmFieldFlagInternalShift = getConstant("FieldInfo::FieldFlags::_ff_injected", Integer.class); final int jvmFieldFlagStableShift = getConstant("FieldInfo::FieldFlags::_ff_stable", Integer.class); - final int jvmAccIsCloneableFast = getConstant("JVM_ACC_IS_CLONEABLE_FAST", Integer.class); + final int jvmAccIsCloneableFast = getConstant("KlassFlags::_misc_is_cloneable_fast", Integer.class); // These modifiers are not public in Modifier so we get them via vmStructs. final int jvmAccSynthetic = getConstant("JVM_ACC_SYNTHETIC", Integer.class); diff --git a/src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Main.java b/src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Main.java index 78a03a4332d..014b420e1a2 100644 --- a/src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Main.java +++ b/src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Main.java @@ -197,6 +197,7 @@ public class Main { private boolean hasExpiringCert = false; private boolean hasExpiringTsaCert = false; private boolean noTimestamp = true; + private boolean hasNonexistentEntries = false; // Expiration date. The value could be null if signed by a trusted cert. private Date expireDate = null; @@ -735,6 +736,7 @@ public class Main { Map sigMap = new HashMap<>(); Map sigNameMap = new HashMap<>(); Map unparsableSignatures = new HashMap<>(); + Map> entriesInSF = new HashMap<>(); try { jf = new JarFile(jarName, true); @@ -782,6 +784,7 @@ public class Main { break; } } + entriesInSF.put(alias, sf.getEntries().keySet()); if (!found) { unparsableSignatures.putIfAbsent(alias, String.format( @@ -881,6 +884,9 @@ public class Main { sb.append('\n'); } } + for (var signed : entriesInSF.values()) { + signed.remove(name); + } } else if (showcerts && !verbose.equals("all")) { // Print no info for unsigned entries when -verbose:all, // to be consistent with old behavior. @@ -1076,6 +1082,13 @@ public class Main { if (verbose != null) { System.out.println(history); } + var signed = entriesInSF.get(s); + if (!signed.isEmpty()) { + if (verbose != null) { + System.out.println(rb.getString("history.nonexistent.entries") + signed); + } + hasNonexistentEntries = true; + } } else { unparsableSignatures.putIfAbsent(s, String.format( rb.getString("history.nobk"), s)); @@ -1311,6 +1324,9 @@ public class Main { } } + if (hasNonexistentEntries) { + warnings.add(rb.getString("nonexistent.entries.found")); + } if (externalFileAttributesDetected) { warnings.add(rb.getString("external.file.attributes.detected")); } diff --git a/src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Resources.java b/src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Resources.java index 6a86b72ad1b..810bd107bde 100644 --- a/src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Resources.java +++ b/src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Resources.java @@ -164,6 +164,7 @@ public class Resources extends java.util.ListResourceBundle { {"history.with.ts", "- Signed by \"%1$s\"\n Digest algorithm: %2$s\n Signature algorithm: %3$s, %4$s\n Timestamped by \"%6$s\" on %5$tc\n Timestamp digest algorithm: %7$s\n Timestamp signature algorithm: %8$s, %9$s"}, {"history.without.ts", "- Signed by \"%1$s\"\n Digest algorithm: %2$s\n Signature algorithm: %3$s, %4$s"}, + {"history.nonexistent.entries", " Warning: nonexistent signed entries: "}, {"history.unparsable", "- Unparsable signature-related file %s"}, {"history.nosf", "- Missing signature-related file META-INF/%s.SF"}, {"history.nobk", "- Missing block file for signature-related file META-INF/%s.SF"}, @@ -178,6 +179,7 @@ public class Resources extends java.util.ListResourceBundle { {"key.bit.disabled", "%d-bit key (disabled)"}, {"key.bit.eccurve.disabled", "%1$d-bit %2$s key (disabled)"}, {"unknown.size", "unknown size"}, + {"nonexistent.entries.found", "This jar contains signed entries for files that do not exist. See the -verbose output for more details."}, {"external.file.attributes.detected", "POSIX file permission and/or symlink attributes detected. These attributes are ignored when signing and are not protected by the signature."}, {"jarsigner.", "jarsigner: "}, diff --git a/src/jdk.jartool/share/classes/sun/tools/jar/Main.java b/src/jdk.jartool/share/classes/sun/tools/jar/Main.java index 6163ef82647..551568ca86f 100644 --- a/src/jdk.jartool/share/classes/sun/tools/jar/Main.java +++ b/src/jdk.jartool/share/classes/sun/tools/jar/Main.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -251,7 +251,7 @@ public class Main { * Starts main program with the specified arguments. */ @SuppressWarnings({"removal"}) - public synchronized boolean run(String args[]) { + public synchronized boolean run(String[] args) { ok = true; if (!parseArgs(args)) { return false; @@ -366,11 +366,9 @@ public class Main { if (fname != null) { list(fname, files); } else { - InputStream in = new FileInputStream(FileDescriptor.in); - try { - list(new BufferedInputStream(in), files); - } finally { - in.close(); + try (InputStream in = new FileInputStream(FileDescriptor.in); + BufferedInputStream bis = new BufferedInputStream(in)) { + list(bis, files); } } } else if (xflag) { @@ -386,18 +384,12 @@ public class Main { // latter can handle it. String[] files = filesMapToFiles(filesMap); - if (fname != null && files != null) { + if (fname != null) { extract(fname, files); } else { - InputStream in = (fname == null) - ? new FileInputStream(FileDescriptor.in) - : new FileInputStream(fname); - try { - if (!extract(new BufferedInputStream(in), files) && fname != null) { - extract(fname, files); - } - } finally { - in.close(); + try (InputStream in = new FileInputStream(FileDescriptor.in); + BufferedInputStream bis = new BufferedInputStream(in)) { + extract(bis, files); } } } else if (iflag) { @@ -503,7 +495,7 @@ public class Main { /** * Parses command line arguments. */ - boolean parseArgs(String args[]) { + boolean parseArgs(String[] args) { /* Preprocess and expand @file arguments */ try { args = CommandLine.parse(args); @@ -935,118 +927,116 @@ public class Main { Map moduleInfos, JarIndex jarIndex) throws IOException { - ZipInputStream zis = new ZipInputStream(in); - ZipOutputStream zos = new JarOutputStream(out); - ZipEntry e = null; - boolean foundManifest = false; boolean updateOk = true; + try (ZipInputStream zis = new ZipInputStream(in); + ZipOutputStream zos = new JarOutputStream(out)) { - // All actual entries added/updated/existing, in the jar file (excl manifest - // and module-info.class ). - Set jentries = new HashSet<>(); + if (jarIndex != null) { + addIndex(jarIndex, zos); + } + ZipEntry e = null; + boolean foundManifest = false; + // All actual entries added/updated/existing, in the jar file (excl manifest + // and module-info.class ). + Set jentries = new HashSet<>(); - if (jarIndex != null) { - addIndex(jarIndex, zos); - } + // put the old entries first, replace if necessary + while ((e = zis.getNextEntry()) != null) { + String name = e.getName(); - // put the old entries first, replace if necessary - while ((e = zis.getNextEntry()) != null) { - String name = e.getName(); + boolean isManifestEntry = equalsIgnoreCase(name, MANIFEST_NAME); + boolean isModuleInfoEntry = isModuleInfoEntry(name); - boolean isManifestEntry = equalsIgnoreCase(name, MANIFEST_NAME); - boolean isModuleInfoEntry = isModuleInfoEntry(name); - - if ((jarIndex != null && equalsIgnoreCase(name, INDEX_NAME)) - || (Mflag && isManifestEntry)) { - continue; - } else if (isManifestEntry && ((newManifest != null) || + if ((jarIndex != null && equalsIgnoreCase(name, INDEX_NAME)) + || (Mflag && isManifestEntry)) { + continue; + } else if (isManifestEntry && ((newManifest != null) || (ename != null) || isMultiRelease)) { - foundManifest = true; - if (newManifest != null) { - // Don't read from the newManifest InputStream, as we - // might need it below, and we can't re-read the same data - // twice. - try (FileInputStream fis = new FileInputStream(mname)) { - if (isAmbiguousMainClass(new Manifest(fis))) { - return false; + foundManifest = true; + if (newManifest != null) { + // Don't read from the newManifest InputStream, as we + // might need it below, and we can't re-read the same data + // twice. + try (FileInputStream fis = new FileInputStream(mname)) { + if (isAmbiguousMainClass(new Manifest(fis))) { + return false; + } } } - } - // Update the manifest. - Manifest old = new Manifest(zis); - if (newManifest != null) { - old.read(newManifest); - } - if (!updateManifest(old, zos)) { - return false; - } - } else if (moduleInfos != null && isModuleInfoEntry) { - moduleInfos.putIfAbsent(name, new StreamedModuleInfoEntry(name, zis.readAllBytes(), e.getLastModifiedTime())); - } else { - boolean isDir = e.isDirectory(); - if (!entryMap.containsKey(name)) { // copy the old stuff - // do our own compression - ZipEntry e2 = new ZipEntry(name); - e2.setMethod(e.getMethod()); - setZipEntryTime(e2, e.getTime()); - e2.setComment(e.getComment()); - e2.setExtra(e.getExtra()); - if (e.getMethod() == ZipEntry.STORED) { - e2.setSize(e.getSize()); - e2.setCrc(e.getCrc()); + // Update the manifest. + Manifest old = new Manifest(zis); + if (newManifest != null) { + old.read(newManifest); + } + if (!updateManifest(old, zos)) { + return false; + } + } else if (moduleInfos != null && isModuleInfoEntry) { + moduleInfos.putIfAbsent(name, new StreamedModuleInfoEntry(name, zis.readAllBytes(), e.getLastModifiedTime())); + } else { + boolean isDir = e.isDirectory(); + if (!entryMap.containsKey(name)) { // copy the old stuff + // do our own compression + ZipEntry e2 = new ZipEntry(name); + e2.setMethod(e.getMethod()); + setZipEntryTime(e2, e.getTime()); + e2.setComment(e.getComment()); + e2.setExtra(e.getExtra()); + if (e.getMethod() == ZipEntry.STORED) { + e2.setSize(e.getSize()); + e2.setCrc(e.getCrc()); + } + zos.putNextEntry(e2); + copy(zis, zos); + } else { // replace with the new files + Entry ent = entryMap.get(name); + addFile(zos, ent); + entryMap.remove(name); + entries.remove(ent); + isDir = ent.isDir; + } + if (!isDir) { + jentries.add(name); } - zos.putNextEntry(e2); - copy(zis, zos); - } else { // replace with the new files - Entry ent = entryMap.get(name); - addFile(zos, ent); - entryMap.remove(name); - entries.remove(ent); - isDir = ent.isDir; - } - if (!isDir) { - jentries.add(name); } } - } - // add the remaining new files - for (Entry entry : entries) { - addFile(zos, entry); - if (!entry.isDir) { - jentries.add(entry.name); + // add the remaining new files + for (Entry entry : entries) { + addFile(zos, entry); + if (!entry.isDir) { + jentries.add(entry.name); + } } - } - if (!foundManifest) { - if (newManifest != null) { - Manifest m = new Manifest(newManifest); - updateOk = !isAmbiguousMainClass(m); - if (updateOk) { - if (!updateManifest(m, zos)) { + if (!foundManifest) { + if (newManifest != null) { + Manifest m = new Manifest(newManifest); + updateOk = !isAmbiguousMainClass(m); + if (updateOk) { + if (!updateManifest(m, zos)) { + updateOk = false; + } + } + } else if (ename != null) { + if (!updateManifest(new Manifest(), zos)) { updateOk = false; } } - } else if (ename != null) { - if (!updateManifest(new Manifest(), zos)) { + } + if (updateOk) { + if (moduleInfos != null && !moduleInfos.isEmpty()) { + Set pkgs = new HashSet<>(); + jentries.forEach(je -> addPackageIfNamed(pkgs, je)); + addExtendedModuleAttributes(moduleInfos, pkgs); + updateOk = checkModuleInfo(moduleInfos.get(MODULE_INFO), jentries); + updateModuleInfo(moduleInfos, zos); + // TODO: check manifest main classes, etc + } else if (moduleVersion != null || modulesToHash != null) { + error(getMsg("error.module.options.without.info")); updateOk = false; } } } - if (updateOk) { - if (moduleInfos != null && !moduleInfos.isEmpty()) { - Set pkgs = new HashSet<>(); - jentries.forEach( je -> addPackageIfNamed(pkgs, je)); - addExtendedModuleAttributes(moduleInfos, pkgs); - updateOk = checkModuleInfo(moduleInfos.get(MODULE_INFO), jentries); - updateModuleInfo(moduleInfos, zos); - // TODO: check manifest main classes, etc - } else if (moduleVersion != null || modulesToHash != null) { - error(getMsg("error.module.options.without.info")); - updateOk = false; - } - } - zis.close(); - zos.close(); return updateOk; } @@ -1374,19 +1364,12 @@ public class Main { /** * Extracts specified entries from JAR file. - * - * @return whether entries were found and successfully extracted - * (indicating this was a zip file without "leading garbage") */ - boolean extract(InputStream in, String files[]) throws IOException { + void extract(InputStream in, String[] files) throws IOException { ZipInputStream zis = new ZipInputStream(in); ZipEntry e; - // Set of all directory entries specified in archive. Disallows - // null entries. Disallows all entries if using pre-6.0 behavior. - boolean entriesFound = false; Set dirs = newDirSet(); while ((e = zis.getNextEntry()) != null) { - entriesFound = true; if (files == null) { dirs.add(extractFile(zis, e)); } else { @@ -1405,32 +1388,31 @@ public class Main { // instead of during, because creating a file in a directory changes // that directory's timestamp. updateLastModifiedTime(dirs); - - return entriesFound; } /** * Extracts specified entries from JAR file, via ZipFile. */ - void extract(String fname, String files[]) throws IOException { - ZipFile zf = new ZipFile(fname); - Set dirs = newDirSet(); - Enumeration zes = zf.entries(); - while (zes.hasMoreElements()) { - ZipEntry e = zes.nextElement(); - if (files == null) { - dirs.add(extractFile(zf.getInputStream(e), e)); - } else { - String name = e.getName(); - for (String file : files) { - if (name.startsWith(file)) { - dirs.add(extractFile(zf.getInputStream(e), e)); - break; + void extract(String fname, String[] files) throws IOException { + final Set dirs; + try (ZipFile zf = new ZipFile(fname)) { + dirs = newDirSet(); + Enumeration zes = zf.entries(); + while (zes.hasMoreElements()) { + ZipEntry e = zes.nextElement(); + if (files == null) { + dirs.add(extractFile(zf.getInputStream(e), e)); + } else { + String name = e.getName(); + for (String file : files) { + if (name.startsWith(file)) { + dirs.add(extractFile(zf.getInputStream(e), e)); + break; + } } } } } - zf.close(); updateLastModifiedTime(dirs); } @@ -1505,7 +1487,7 @@ public class Main { /** * Lists contents of JAR file. */ - void list(InputStream in, String files[]) throws IOException { + void list(InputStream in, String[] files) throws IOException { ZipInputStream zis = new ZipInputStream(in); ZipEntry e; while ((e = zis.getNextEntry()) != null) { @@ -1523,13 +1505,13 @@ public class Main { /** * Lists contents of JAR file, via ZipFile. */ - void list(String fname, String files[]) throws IOException { - ZipFile zf = new ZipFile(fname); - Enumeration zes = zf.entries(); - while (zes.hasMoreElements()) { - printEntry(zes.nextElement(), files); + void list(String fname, String[] files) throws IOException { + try (ZipFile zf = new ZipFile(fname)) { + Enumeration zes = zf.entries(); + while (zes.hasMoreElements()) { + printEntry(zes.nextElement(), files); + } } - zf.close(); } /** @@ -1572,10 +1554,8 @@ public class Main { // class path attribute will give us jar file name with // '/' as separators, so we need to change them to the // appropriate one before we open the jar file. - JarFile rf = new JarFile(jar.replace('/', File.separatorChar)); - - if (rf != null) { - Manifest man = rf.getManifest(); + try (JarFile jarFile = new JarFile(jar.replace('/', File.separatorChar))) { + Manifest man = jarFile.getManifest(); if (man != null) { Attributes attr = man.getMainAttributes(); if (attr != null) { @@ -1596,7 +1576,6 @@ public class Main { } } } - rf.close(); return files; } @@ -1703,7 +1682,7 @@ public class Main { /** * Main routine to start program. */ - public static void main(String args[]) { + public static void main(String[] args) { Main jartool = new Main(System.out, System.err, "jar"); System.exit(jartool.run(args) ? 0 : 1); } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/doclet/StandardDoclet.java b/src/jdk.javadoc/share/classes/jdk/javadoc/doclet/StandardDoclet.java index 82cac37012b..69db8f0800c 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/doclet/StandardDoclet.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/doclet/StandardDoclet.java @@ -36,7 +36,10 @@ import jdk.javadoc.internal.doclets.formats.html.HtmlDoclet; /** * This doclet generates HTML-formatted documentation for the specified modules, - * packages and types. + * packages and types. It is the doclet that is used by the + * javadoc tool + * and the {@linkplain javax.tools.ToolProvider#getSystemDocumentationTool + * system documentation tool} when no other doclet is specified to be used. * *

                  User-Defined Taglets

                  * diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractExecutableMemberWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractExecutableMemberWriter.java index 84672926cf8..7efaec87692 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractExecutableMemberWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractExecutableMemberWriter.java @@ -109,7 +109,7 @@ public abstract class AbstractExecutableMemberWriter extends AbstractMemberWrite } String signature = utils.flatSignature((ExecutableElement) member, typeElement); if (signature.length() > 2) { - content.add(new HtmlTree(HtmlTag.WBR)); + content.add(HtmlTree.WBR()); } content.add(signature); @@ -144,7 +144,7 @@ public abstract class AbstractExecutableMemberWriter extends AbstractMemberWrite // Add explicit line break between method type parameters and // return type in member summary table to avoid random wrapping. if (typeParameters.charCount() > 10) { - target.add(new HtmlTree(HtmlTag.BR)); + target.add(HtmlTree.BR()); } else { target.add(Entity.NO_BREAK_SPACE); } @@ -233,7 +233,7 @@ public abstract class AbstractExecutableMemberWriter extends AbstractMemberWrite Content params = getParameters(member, false); if (params.charCount() > 2) { // only add for non-empty parameters - target.add(new HtmlTree(HtmlTag.WBR)); + target.add(HtmlTree.WBR()); } target.add(params); } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractMemberWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractMemberWriter.java index e2b81bb3982..59a8f589230 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractMemberWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractMemberWriter.java @@ -451,7 +451,7 @@ public abstract class AbstractMemberWriter { */ protected void addModifiersAndType(Element member, TypeMirror type, Content target) { - var code = new HtmlTree(HtmlTag.CODE); + var code = HtmlTree.CODE(); addModifiers(member, code); if (type == null) { code.add(switch (member.getKind()) { @@ -670,7 +670,7 @@ public abstract class AbstractMemberWriter { * @return the inherited summary links */ public Content getInheritedSummaryLinks() { - return new HtmlTree(HtmlTag.CODE); + return HtmlTree.CODE(); } /** diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractTreeWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractTreeWriter.java index 594132743eb..915dbd7627a 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractTreeWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractTreeWriter.java @@ -79,10 +79,9 @@ public abstract class AbstractTreeWriter extends HtmlDocletWriter { protected void addLevelInfo(TypeElement parent, Collection collection, Hierarchy hierarchy, Content content) { if (!collection.isEmpty()) { - var ul = new HtmlTree(HtmlTag.UL); + var ul = HtmlTree.UL(); for (TypeElement local : collection) { - var li = new HtmlTree(HtmlTag.LI); - li.setStyle(HtmlStyles.circle); + var li = HtmlTree.LI(HtmlStyles.circle); addPartialInfo(local, li); addExtendsImplements(parent, local, li); addLevelInfo(local, hierarchy.subtypes(local), hierarchy, li); // Recurse diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassUseWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassUseWriter.java index ac953dccb55..d10478fb3ba 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassUseWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassUseWriter.java @@ -423,7 +423,7 @@ public class ClassUseWriter extends SubWriterHolderWriter { HtmlTree body = getBody(getWindowTitle(title)); ContentBuilder headingContent = new ContentBuilder(); headingContent.add(contents.getContent("doclet.ClassUse_Title", cltype)); - headingContent.add(new HtmlTree(HtmlTag.BR)); + headingContent.add(HtmlTree.BR()); headingContent.add(clname); var heading = HtmlTree.HEADING_TITLE(Headings.PAGE_TITLE_HEADING, HtmlStyles.title, headingContent); diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriter.java index 8218e5128be..7b271485f1f 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriter.java @@ -165,7 +165,7 @@ public class ClassWriter extends SubWriterHolderWriter { buildInterfaceUsageInfo(c); buildNestedClassInfo(c); buildFunctionalInterfaceInfo(c); - c.add(new HtmlTree(HtmlTag.HR)); + c.add(HtmlTree.HR()); var div = HtmlTree.DIV(HtmlStyles.horizontalScroll); buildClassSignature(div); buildDeprecationInfo(div); @@ -461,7 +461,7 @@ public class ClassWriter extends SubWriterHolderWriter { var first = true; for (TypeParameterElement t : typeParams) { if (!first) { - content.add(",").add(new HtmlTree(HtmlTag.WBR)); + content.add(",").add(HtmlTree.WBR()); } var typeParamLink = getLink(linkInfo.forType(t.asType())); content.add(needsId @@ -689,11 +689,9 @@ public class ClassWriter extends SubWriterHolderWriter { protected void addFunctionalInterfaceInfo (Content target) { if (utils.isFunctionalInterface(typeElement)) { - var dl = HtmlTree.DL(HtmlStyles.notes); - dl.add(HtmlTree.DT(contents.functionalInterface)); - var dd = new HtmlTree(HtmlTag.DD); - dd.add(contents.functionalInterfaceMessage); - dl.add(dd); + var dl = HtmlTree.DL(HtmlStyles.notes) + .add(HtmlTree.DT(contents.functionalInterface)) + .add(HtmlTree.DD(contents.functionalInterfaceMessage)); target.add(dl); } } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstantsSummaryWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstantsSummaryWriter.java index cdae0e8d911..9731cd14e88 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstantsSummaryWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstantsSummaryWriter.java @@ -414,7 +414,7 @@ public class ConstantsSummaryWriter extends HtmlDocletWriter { */ private Content getTypeColumn(VariableElement member) { Content typeContent = new ContentBuilder(); - var code = new HtmlTree(HtmlTag.CODE) + var code = HtmlTree.CODE() .setId(htmlIds.forMember(currentTypeElement, member)); for (Modifier mod : member.getModifiers()) { code.add(Text.of(mod.toString())) diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstructorWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstructorWriter.java index 11975404a55..d1d04d4f7f1 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstructorWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstructorWriter.java @@ -300,7 +300,7 @@ public class ConstructorWriter extends AbstractExecutableMemberWriter { @Override protected void addSummaryType(Element member, Content content) { if (threeColumnSummary()) { - var code = new HtmlTree(HtmlTag.CODE); + var code = HtmlTree.CODE(); if (utils.isProtected(member)) { code.add("protected "); } else if (utils.isPrivate(member)) { diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HelpWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HelpWriter.java index 22e778d3986..1687f891896 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HelpWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HelpWriter.java @@ -105,11 +105,11 @@ public class HelpWriter extends HtmlDocletWriter { tableOfContents.addLink(HtmlIds.TOP_OF_PAGE, mainHeading); tableOfContents.pushNestedList(); content.add(HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, HtmlStyles.title, mainHeading)) - .add(new HtmlTree(HtmlTag.HR)) + .add(HtmlTree.HR()) .add(getNavigationSection()) - .add(new HtmlTree(HtmlTag.HR)) + .add(HtmlTree.HR()) .add(getPageKindSection()) - .add(new HtmlTree(HtmlTag.HR)) + .add(HtmlTree.HR()) .add(HtmlTree.SPAN(HtmlStyles.helpFootnote, getContent("doclet.help.footnote"))); tableOfContents.popNestedList(); @@ -255,7 +255,7 @@ public class HelpWriter extends HtmlDocletWriter { getContent("doclet.help.class_interface.implementations"), getContent("doclet.help.class_interface.declaration"), getContent("doclet.help.class_interface.description"))) - .add(new HtmlTree(HtmlTag.BR)) + .add(HtmlTree.BR()) .add(newHelpSectionList( contents.nestedClassSummary, contents.enumConstantSummary, @@ -265,7 +265,7 @@ public class HelpWriter extends HtmlDocletWriter { contents.methodSummary, contents.annotateTypeRequiredMemberSummaryLabel, contents.annotateTypeOptionalMemberSummaryLabel)) - .add(new HtmlTree(HtmlTag.BR)) + .add(HtmlTree.BR()) .add(newHelpSectionList( contents.enumConstantDetailLabel, contents.fieldDetailsLabel, diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java index 235a0361b92..9bb1ebaaf62 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java @@ -685,7 +685,7 @@ public abstract class HtmlDocletWriter { return (bottom == null || bottom.isEmpty()) ? null : HtmlTree.FOOTER() - .add(new HtmlTree(HtmlTag.HR)) + .add(HtmlTree.HR()) .add(HtmlTree.P(HtmlStyles.legalCopy, HtmlTree.SMALL( RawHtml.of(replaceDocRootDir(bottom))))); @@ -2405,7 +2405,7 @@ public abstract class HtmlDocletWriter { * @return an HtmlTree for the BODY tag */ public HtmlTree getBody(String title) { - var body = new HtmlTree(HtmlTag.BODY).setStyle(getBodyStyle()); + var body = HtmlTree.BODY(getBodyStyle()); this.winTitle = title; // Don't print windowtitle script for overview-frame, allclasses-frame @@ -2601,7 +2601,7 @@ public abstract class HtmlDocletWriter { }); return contents.getContent(key, HtmlTree.CODE(Text.of(className)), - new HtmlTree(HtmlTag.EM).add(featureName), + HtmlTree.EM(featureName), featureCodes); } @@ -2642,19 +2642,31 @@ public abstract class HtmlDocletWriter { //in Java platform: var restrictedDiv = HtmlTree.DIV(HtmlStyles.restrictedBlock); restrictedDiv.setId(htmlIds.forRestrictedSection(forWhat)); - String name = forWhat.getSimpleName().toString(); + var name = forWhat.getSimpleName().toString(); var nameCode = HtmlTree.CODE(Text.of(name)); - String leadingNoteKey = "doclet.RestrictedLeadingNote"; - Content leadingNote = - contents.getContent(leadingNoteKey, nameCode); - restrictedDiv.add(HtmlTree.SPAN(HtmlStyles.restrictedLabel, - leadingNote)); - Content note1 = contents.getContent("doclet.RestrictedTrailingNote1", nameCode); + var restrictedMethodLink = getRestrictedMethodDocLink(); + var leadingNoteKey = "doclet.RestrictedLeadingNote"; + var leadingNote = contents.getContent(leadingNoteKey, nameCode, restrictedMethodLink); + restrictedDiv.add(HtmlTree.SPAN(HtmlStyles.restrictedLabel, leadingNote)); + var note1 = contents.getContent("doclet.RestrictedTrailingNote1", nameCode); restrictedDiv.add(HtmlTree.DIV(HtmlStyles.restrictedComment, note1)); - Content note2 = contents.getContent("doclet.RestrictedTrailingNote2", nameCode); + var note2 = contents.getContent("doclet.RestrictedTrailingNote2", nameCode); restrictedDiv.add(HtmlTree.DIV(HtmlStyles.restrictedComment, note2)); target.add(restrictedDiv); } } + private Content getRestrictedMethodDocLink() { + var restrictedMethodLabel = contents.getContent("doclet.RestrictedMethod"); + var javaLang = utils.elementUtils.getPackageElement("java.lang"); + if (utils.isIncluded(javaLang)) { + var restrictedDocPath = pathToRoot + .resolve(docPaths.forPackage(javaLang)) + .resolve(DocPaths.DOC_FILES) + .resolve(DocPaths.RESTRICTED_DOC); + return links.createLink(restrictedDocPath, restrictedMethodLabel); + } + return restrictedMethodLabel; + } + } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlLinkFactory.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlLinkFactory.java index 494d5e22d6e..bf210b91ea6 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlLinkFactory.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlLinkFactory.java @@ -395,14 +395,14 @@ public class HtmlLinkFactory { } if (!vars.isEmpty()) { if (linkInfo.addLineBreakOpportunitiesInTypeParameters()) { - links.add(new HtmlTree(HtmlTag.WBR)); + links.add(HtmlTree.WBR()); } links.add("<"); boolean many = false; for (TypeMirror t : vars) { if (many) { links.add(","); - links.add(new HtmlTree(HtmlTag.WBR)); + links.add(HtmlTree.WBR()); if (linkInfo.addLineBreaksInTypeParameters()) { links.add(Text.NL); } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/IndexRedirectWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/IndexRedirectWriter.java index e449ecebf40..a7afd9db85d 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/IndexRedirectWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/IndexRedirectWriter.java @@ -92,7 +92,7 @@ public class IndexRedirectWriter extends HtmlDocletWriter { Script script = new Script("window.location.replace(") .appendStringLiteral(targetPath, '\'') .append(")"); - var metaRefresh = new HtmlTree(HtmlTag.META) + var metaRefresh = HtmlTree.of(HtmlTag.META) .put(HtmlAttr.HTTP_EQUIV, "Refresh") .put(HtmlAttr.CONTENT, "0;" + targetPath); head.addContent(script.asContent(), HtmlTree.NOSCRIPT(metaRefresh)); @@ -103,9 +103,8 @@ public class IndexRedirectWriter extends HtmlDocletWriter { bodyContent.add(HtmlTree.P(HtmlTree.A(targetPath, Text.of(targetPath)))); - var body = new HtmlTree(HtmlTag.BODY).setStyle(HtmlStyles.indexRedirectPage); - var main = HtmlTree.MAIN(bodyContent); - body.add(main); + var body = HtmlTree.BODY(HtmlStyles.indexRedirectPage) + .add(HtmlTree.MAIN(bodyContent)); HtmlDocument htmlDocument = new HtmlDocument( HtmlTree.HTML(configuration.getLocale().getLanguage(), head, body)); diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/IndexWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/IndexWriter.java index ecf11143642..87d0fa95bf3 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/IndexWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/IndexWriter.java @@ -224,7 +224,7 @@ public class IndexWriter extends HtmlDocletWriter { default -> throw new Error(); } target.add(dt); - var dd = new HtmlTree(HtmlTag.DD); + var dd = HtmlTree.DD(); if (element.getKind() == ElementKind.MODULE || element.getKind() == ElementKind.PACKAGE) { addSummaryComment(element, dd); } else { @@ -261,7 +261,7 @@ public class IndexWriter extends HtmlDocletWriter { dt.add(" - "); dt.add(contents.getContent("doclet.Search_tag_in", item.getHolder())); target.add(dt); - var dd = new HtmlTree(HtmlTag.DD); + var dd = HtmlTree.DD(); if (item.getDescription().isEmpty()) { dd.add(Entity.NO_BREAK_SPACE); } else { @@ -348,7 +348,7 @@ public class IndexWriter extends HtmlDocletWriter { content.add(Entity.NO_BREAK_SPACE); } - content.add(new HtmlTree(HtmlTag.BR)); + content.add(HtmlTree.BR()); var pageLinks = Stream.of(IndexItem.Category.values()) .flatMap(c -> mainIndex.getItems(c).stream()) .filter(i -> !(i.isElementItem() || i.isTagItem())) diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriter.java index bd0ab2958d4..b688420681f 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriter.java @@ -194,7 +194,7 @@ public class ModuleWriter extends HtmlDocletWriter { */ protected void buildContent() { Content moduleContent = getContentHeader(); - moduleContent.add(new HtmlTree(HtmlTag.HR)); + moduleContent.add(HtmlTree.HR()); Content div = HtmlTree.DIV(HtmlStyles.horizontalScroll); addModuleSignature(div); buildModuleDescription(div); @@ -825,7 +825,7 @@ public class ModuleWriter extends HtmlDocletWriter { } // Only display the implementation details in the "all" mode. if (moduleMode == ModuleMode.ALL && !implSet.isEmpty()) { - desc.add(new HtmlTree(HtmlTag.BR)); + desc.add(HtmlTree.BR()); desc.add("("); var implSpan = HtmlTree.SPAN(HtmlStyles.implementationLabel, contents.implementation); desc.add(implSpan); diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/Navigation.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/Navigation.java index 293a6453925..9d12d3bb23d 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/Navigation.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/Navigation.java @@ -516,14 +516,14 @@ public class Navigation { } var navigationBar = HtmlTree.NAV(); - var navContent = new HtmlTree(HtmlTag.DIV); + var navContent = HtmlTree.DIV(HtmlStyles.navContent); Content skipNavLinks = contents.getContent("doclet.Skip_navigation_links"); String toggleNavLinks = configuration.getDocResources().getText("doclet.Toggle_navigation_links"); navigationBar.add(MarkerComments.START_OF_TOP_NAVBAR); // The mobile menu button uses three empty spans to produce its animated icon HtmlTree iconSpan = HtmlTree.SPAN(HtmlStyles.navBarToggleIcon).add(Entity.NO_BREAK_SPACE); - navContent.setStyle(HtmlStyles.navContent).add(HtmlTree.DIV(HtmlStyles.navMenuButton, - new HtmlTree(HtmlTag.BUTTON).setId(HtmlIds.NAVBAR_TOGGLE_BUTTON) + navContent.add(HtmlTree.DIV(HtmlStyles.navMenuButton, + HtmlTree.BUTTON(HtmlIds.NAVBAR_TOGGLE_BUTTON) .put(HtmlAttr.ARIA_CONTROLS, HtmlIds.NAVBAR_TOP.name()) .put(HtmlAttr.ARIA_EXPANDED, String.valueOf(false)) .put(HtmlAttr.ARIA_LABEL, toggleNavLinks) @@ -535,9 +535,7 @@ public class Navigation { skipNavLinks.toString()))); Content aboutContent = userHeader; - var navList = new HtmlTree(HtmlTag.UL) - .setId(HtmlIds.NAVBAR_TOP_FIRSTROW) - .setStyle(HtmlStyles.navList) + var navList = HtmlTree.UL(HtmlIds.NAVBAR_TOP_FIRSTROW, HtmlStyles.navList) .put(HtmlAttr.TITLE, rowListTitle); addMainNavLinks(navList); navContent.add(navList); diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageUseWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageUseWriter.java index b28b44d4cd3..078f5246de7 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageUseWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageUseWriter.java @@ -204,7 +204,7 @@ public class PackageUseWriter extends SubWriterHolderWriter { HtmlTree body = getBody(getWindowTitle(title)); ContentBuilder headingContent = new ContentBuilder(); headingContent.add(contents.getContent("doclet.ClassUse_Title", packageText)); - headingContent.add(new HtmlTree(HtmlTag.BR)); + headingContent.add(HtmlTree.BR()); headingContent.add(name); var heading = HtmlTree.HEADING_TITLE(Headings.PAGE_TITLE_HEADING, HtmlStyles.title, headingContent); diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageWriter.java index ee022144fea..d5683ec6e3c 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageWriter.java @@ -128,7 +128,7 @@ public class PackageWriter extends HtmlDocletWriter { */ protected void buildContent() { Content packageContent = getContentHeader(); - packageContent.add(new HtmlTree(HtmlTag.HR)); + packageContent.add(HtmlTree.HR()); Content div = HtmlTree.DIV(HtmlStyles.horizontalScroll); addPackageSignature(div); buildPackageDescription(div); diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SearchWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SearchWriter.java index 0bd173df3d5..c30dae6bc65 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SearchWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SearchWriter.java @@ -97,24 +97,21 @@ public class SearchWriter extends HtmlDocletWriter { .add(HtmlTree.P(contents.getContent("doclet.search.browser_info"))) .add(HtmlTree.SPAN(Text.of("link")) .setId(HtmlId.of("page-search-link"))) - .add(new HtmlTree(HtmlTag.BUTTON) - .add(new HtmlTree(HtmlTag.IMG) + .add(HtmlTree.BUTTON(HtmlId.of("page-search-copy")) + .add(HtmlTree.of(HtmlTag.IMG) .put(HtmlAttr.SRC, pathToRoot.resolve(DocPaths.RESOURCE_FILES) .resolve(DocPaths.CLIPBOARD_SVG).getPath()) .put(HtmlAttr.ALT, copyUrlText)) .add(HtmlTree.SPAN(Text.of(copyText)) .put(HtmlAttr.DATA_COPIED, copiedText)) .addStyle(HtmlStyles.copy) - .put(HtmlAttr.ARIA_LABEL, copyUrlText) - .setId(HtmlId.of("page-search-copy"))) + .put(HtmlAttr.ARIA_LABEL, copyUrlText)) .add(HtmlTree.P(HtmlTree.INPUT(HtmlAttr.InputType.CHECKBOX, HtmlId.of("search-redirect"))) .add(HtmlTree.LABEL("search-redirect", contents.getContent("doclet.search.redirect"))))) - .add(new HtmlTree(HtmlTag.P) - .setId(HtmlId.of("page-search-notify")) - .add(contents.getContent("doclet.search.loading"))) - .add(HtmlTree.DIV(new HtmlTree(HtmlTag.DIV) - .setId(HtmlId.of("result-container")) + .add(HtmlTree.P(contents.getContent("doclet.search.loading")) + .setId(HtmlId.of("page-search-notify"))) + .add(HtmlTree.DIV(HtmlTree.DIV(HtmlId.of("result-container")) .addUnchecked(Text.EMPTY)) .setId(HtmlId.of("result-section")) .put(HtmlAttr.STYLE, "display: none;") diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SerialFieldWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SerialFieldWriter.java index c3d1cc582f3..ef9810f7374 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SerialFieldWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SerialFieldWriter.java @@ -58,7 +58,7 @@ public class SerialFieldWriter extends FieldWriter { } protected Content getFieldsContentHeader() { - return new HtmlTree(HtmlTag.LI).setStyle(HtmlStyles.blockList); + return HtmlTree.LI(HtmlStyles.blockList); } protected Content getSerializableFields(String heading, Content source) { @@ -76,12 +76,12 @@ public class SerialFieldWriter extends FieldWriter { Content nameContent = Text.of(fieldName); var heading = HtmlTree.HEADING(Headings.SerializedForm.MEMBER_HEADING, nameContent); content.add(heading); - var pre = new HtmlTree(HtmlTag.PRE); Content fieldContent = writer.getLink(new HtmlLinkInfo( configuration, HtmlLinkInfo.Kind.LINK_TYPE_PARAMS_AND_BOUNDS, fieldType)); - pre.add(fieldContent); - pre.add(" "); - pre.add(fieldName); + var pre = HtmlTree.PRE() + .add(fieldContent) + .add(" ") + .add(fieldName); content.add(pre); } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SerialMethodWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SerialMethodWriter.java index d9b888f2ee1..4ce7d662abb 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SerialMethodWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SerialMethodWriter.java @@ -51,7 +51,7 @@ public class SerialMethodWriter extends MethodWriter { } protected Content getMethodsContentHeader() { - return new HtmlTree(HtmlTag.LI); + return HtmlTree.LI(); } /** diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/Signatures.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/Signatures.java index 9059efcf814..f1e26879ef4 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/Signatures.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/Signatures.java @@ -569,7 +569,7 @@ public class Signatures { // empty parameters are added without packing target.add(parameters); } else { - target.add(new HtmlTree(HtmlTag.WBR)) + target.add(HtmlTree.WBR()) .add(HtmlTree.SPAN(HtmlStyles.parameters, parameters)); } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SourceToHTMLConverter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SourceToHTMLConverter.java index 070b3842122..aa20fc8c9ae 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SourceToHTMLConverter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SourceToHTMLConverter.java @@ -201,7 +201,7 @@ public class SourceToHTMLConverter { .resolve(configuration.docPaths.forPackage(te)) .invert(); Content body = getHeader(); - var pre = new HtmlTree(HtmlTag.PRE); + var pre = HtmlTree.PRE(); try (var reader = new LineNumberReader(r)) { while ((line = reader.readLine()) != null) { addLineNo(pre, lineno); @@ -246,7 +246,7 @@ public class SourceToHTMLConverter { * @return the header content for the HTML file */ private static Content getHeader() { - return new HtmlTree(HtmlTag.BODY).setStyle(HtmlStyles.sourcePage); + return HtmlTree.BODY(HtmlStyles.sourcePage); } /** diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/Table.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/Table.java index 5d09682d492..0e09920b7b1 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/Table.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/Table.java @@ -361,7 +361,7 @@ public class Table extends Content { private Content toContent() { Content main; if (id != null) { - main = new HtmlTree(HtmlTag.DIV).setId(id); + main = HtmlTree.DIV(id); } else { main = new ContentBuilder(); } @@ -403,8 +403,7 @@ public class Table extends Content { if (id == null) { throw new IllegalStateException("no id set for table"); } - var tabpanel = new HtmlTree(HtmlTag.DIV) - .setId(HtmlIds.forTabPanel(id)) + var tabpanel = HtmlTree.DIV(HtmlIds.forTabPanel(id)) .put(HtmlAttr.ROLE, "tabpanel") .put(HtmlAttr.ARIA_LABELLEDBY, defaultTabId.name()); table.add(getTableBody()); @@ -416,8 +415,7 @@ public class Table extends Content { } private HtmlTree createTab(HtmlId tabId, HtmlStyle style, boolean defaultTab, Content tabLabel) { - var tab = new HtmlTree(HtmlTag.BUTTON) - .setId(tabId) + var tab = HtmlTree.BUTTON(tabId) .put(HtmlAttr.ROLE, "tab") .put(HtmlAttr.ARIA_SELECTED, defaultTab ? "true" : "false") .put(HtmlAttr.ARIA_CONTROLS, HtmlIds.forTabPanel(id).name()) diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TableOfContents.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TableOfContents.java index a9036d7dcd8..cfb8f7260d0 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TableOfContents.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TableOfContents.java @@ -101,10 +101,10 @@ public class TableOfContents { .put(HtmlAttr.VALUE, writer.resources.getText("doclet.filter_reset"))); } content.add(header); - content.add(new HtmlTree(HtmlTag.BUTTON).addStyle(HtmlStyles.hideSidebar) + content.add(HtmlTree.BUTTON(HtmlStyles.hideSidebar) .add(HtmlTree.SPAN(writer.contents.hideSidebar).add(Entity.NO_BREAK_SPACE)) .add(Entity.LEFT_POINTING_ANGLE)); - content.add(new HtmlTree(HtmlTag.BUTTON).addStyle(HtmlStyles.showSidebar) + content.add(HtmlTree.BUTTON(HtmlStyles.showSidebar) .add(Entity.RIGHT_POINTING_ANGLE) .add(HtmlTree.SPAN(Entity.NO_BREAK_SPACE).add(writer.contents.showSidebar))); return content.add(listBuilder); diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Head.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Head.java index 3d5b1a494ba..9b6b1c831b1 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Head.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Head.java @@ -272,9 +272,9 @@ public class Head extends Content { * @return the HTML */ private Content toContent() { - var head = new HtmlTree(HtmlTag.HEAD); - head.add(getGeneratedBy(showTimestamp, generatedDate)); - head.add(HtmlTree.TITLE(title)); + var head = HtmlTree.of(HtmlTag.HEAD) + .add(getGeneratedBy(showTimestamp, generatedDate)) + .add(HtmlTree.TITLE(title)); head.add(HtmlTree.META("viewport", "width=device-width, initial-scale=1")); @@ -300,9 +300,9 @@ public class Head extends Content { } if (canonicalLink != null) { - var link = new HtmlTree(HtmlTag.LINK); - link.put(HtmlAttr.REL, "canonical"); - link.put(HtmlAttr.HREF, canonicalLink.getPath()); + var link = HtmlTree.of(HtmlTag.LINK) + .put(HtmlAttr.REL, "canonical") + .put(HtmlAttr.HREF, canonicalLink.getPath()); head.add(link); } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/script.js.template b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/script.js.template index 633f453bc43..2185b1c951f 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/script.js.template +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/script.js.template @@ -300,6 +300,7 @@ document.addEventListener("DOMContentLoaded", function(e) { }); var expanded = false; var windowWidth; + var bodyHeight; function collapse(e) { if (expanded) { mainnav.removeAttribute("style"); @@ -365,6 +366,7 @@ document.addEventListener("DOMContentLoaded", function(e) { var scrollTimeoutNeeded; var prevHash; function initSectionData() { + bodyHeight = document.body.offsetHeight; sections = [{ id: "", top: 0 }].concat(Array.from(main.querySelectorAll("section[id], h2[id], h2 a[id], div[id]")) .filter((e) => { return sidebar.querySelector("a[href=\"#" + encodeURI(e.getAttribute("id")) + "\"]") !== null @@ -469,7 +471,7 @@ document.addEventListener("DOMContentLoaded", function(e) { expand(); } } - if (sections) { + if (sections && document.body.offsetHeight !== bodyHeight) { initSectionData(); prevHash = null; handleScroll(); diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/standard.properties b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/standard.properties index 6141ce46fe8..bb001912229 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/standard.properties +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/standard.properties @@ -424,7 +424,8 @@ doclet.ReflectivePreviewAPI={0} refers to one or more reflective preview APIs: doclet.UsesDeclaredUsingPreview={0} refers to one or more types which are declared using a preview feature of the Java language: {1}. doclet.PreviewTrailingNote1=Programs can only use {0} when preview features are enabled. doclet.PreviewTrailingNote2=Preview features may be removed in a future release, or upgraded to permanent features of the Java platform. -doclet.RestrictedLeadingNote={0} is a restricted method of the Java platform. +doclet.RestrictedMethod=restricted method +doclet.RestrictedLeadingNote={0} is a {1} of the Java platform. doclet.RestrictedTrailingNote1=Programs can only use {0} when access to restricted methods is enabled. doclet.RestrictedTrailingNote2=Restricted methods are unsafe, and, if used incorrectly, might crash \ the JVM or result in memory corruption. diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/stylesheet.css b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/stylesheet.css index 1130f14dc35..641a6684444 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/stylesheet.css +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/stylesheet.css @@ -28,8 +28,8 @@ /* Line height for continuous text blocks */ --block-line-height: 1.4em; /* Text colors for body and block elements */ - --body-text-color: #353833; - --block-text-color: #474747; + --body-text-color: #282828; + --block-text-color: #282828; /* Background colors for various structural elements */ --body-background-color: #ffffff; --section-background-color: #f8f8f8; @@ -49,8 +49,11 @@ /* Text color for page title */ --title-color: #2c4557; /* Text colors for links */ - --link-color: #4A6782; + --link-color: #437291; --link-color-active: #bb7a2a; + /* Table of contents */ + --toc-background-color: var(--section-background-color); + --toc-link-color: #4a698a; /* Snippet colors */ --snippet-background-color: #ebecee; --snippet-text-color: var(--block-text-color); @@ -99,6 +102,9 @@ a:link, a:visited { text-decoration:none; color:var(--link-color); } +nav a:link, nav a:visited { + color: var(--toc-link-color); +} a[href]:hover, a[href]:active { text-decoration:none; color:var(--link-color-active); @@ -360,8 +366,11 @@ main { padding:10px 20px; position:relative; } -section[id$=-description] :is(dl, ol, ul, p, div, blockquote, pre):last-child, -section[id$=-description] :is(dl, ol, ul):last-child > :is(li, dd):last-child { +/* Compensate for non-collapsing margins between element description and summary tables */ +div.horizontal-scroll > section[id$=-description] > :is(dl, ol, ul, p, div, blockquote, pre):last-child, +div.horizontal-scroll > section[id$=-description] > :last-child > :is(li, dd):last-child, +section.class-description > div.horizontal-scroll > :is(dl, ol, ul, p, div, blockquote, pre):last-child, +section.class-description > div.horizontal-scroll > :last-child > :is(li, dd):last-child { margin-bottom:4px; } dl.notes > dt { @@ -395,7 +404,7 @@ dl.name-value > dd { * Styles for table of contents. */ .main-grid nav.toc { - background-color: var(--section-background-color); + background-color: var(--toc-background-color); border-right: 1px solid var(--border-color); position: sticky; top: calc(var(--nav-height)); @@ -406,8 +415,6 @@ dl.name-value > dd { z-index: 1; } .main-grid nav.toc div.toc-header { - background-color: var(--section-background-color); - border-right: 1px solid var(--border-color); top: var(--nav-height); z-index: 1; padding: 15px 20px; @@ -470,7 +477,6 @@ nav.toc div.toc-header { display: inline-flex; align-items: center; color: var(--body-text-color); - background-color: var(--body-background-color); font-size: 0.856em; font-weight: bold; white-space: nowrap; diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/taglets/SnippetTaglet.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/taglets/SnippetTaglet.java index af2378c0351..93f83c5ba90 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/taglets/SnippetTaglet.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/taglets/SnippetTaglet.java @@ -122,13 +122,13 @@ public class SnippetTaglet extends BaseTaglet { private Content snippetTagOutput(Element element, SnippetTree tag, StyledText content, String id, String lang) { var pathToRoot = tagletWriter.htmlWriter.pathToRoot; - var pre = new HtmlTree(HtmlTag.PRE).setStyle(HtmlStyles.snippet); + var pre = HtmlTree.PRE(HtmlStyles.snippet); if (id != null && !id.isBlank()) { pre.put(HtmlAttr.ID, id); } else { pre.put(HtmlAttr.ID, config.htmlIds.forSnippet(element, ids).name()); } - var code = new HtmlTree(HtmlTag.CODE) + var code = HtmlTree.CODE() .addUnchecked(Text.EMPTY); // Make sure the element is always rendered if (lang != null && !lang.isBlank()) { code.addStyle("language-" + lang); @@ -197,10 +197,10 @@ public class SnippetTaglet extends BaseTaglet { String copiedText = resources.getText("doclet.Copied_to_clipboard"); String copySnippetText = resources.getText("doclet.Copy_snippet_to_clipboard"); var snippetContainer = HtmlTree.DIV(HtmlStyles.snippetContainer, - new HtmlTree(HtmlTag.BUTTON) + HtmlTree.of(HtmlTag.BUTTON) .add(HtmlTree.SPAN(Text.of(copyText)) .put(HtmlAttr.DATA_COPIED, copiedText)) - .add(new HtmlTree(HtmlTag.IMG) + .add(HtmlTree.of(HtmlTag.IMG) .put(HtmlAttr.SRC, pathToRoot.resolve(DocPaths.RESOURCE_FILES) .resolve(DocPaths.CLIPBOARD_SVG).getPath()) .put(HtmlAttr.ALT, copySnippetText)) diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DocPaths.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DocPaths.java index 5ae2d159072..47cf3e81ebe 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DocPaths.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DocPaths.java @@ -163,6 +163,9 @@ public class DocPaths { /** The name of the file for restricted methods. */ public static final DocPath RESTRICTED_LIST = DocPath.create("restricted-list.html"); + /** The name of the doc-file for restricted methods. */ + public static final DocPath RESTRICTED_DOC = DocPath.create("RestrictedMethods.html"); + /** The name of the directory for the resource files. */ public static final DocPath RESOURCE_FILES = DocPath.create("resource-files"); diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/html/HtmlTree.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/html/HtmlTree.java index f6053751174..f1ca45cc040 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/html/HtmlTree.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/html/HtmlTree.java @@ -83,7 +83,17 @@ public class HtmlTree extends Content { * * @param tag the name */ - public HtmlTree(HtmlTag tag) { + public static HtmlTree of(HtmlTag tag) { + return new HtmlTree(tag); + } + + /** + * Creates an {@code HTMLTree} object representing an HTML element + * with the given name. + * + * @param tag the name + */ + HtmlTree(HtmlTag tag) { this.tag = Objects.requireNonNull(tag); } @@ -365,6 +375,46 @@ public class HtmlTree extends Content { .add(body); } + /** + * Creates an HTML {@code BODY} element with the given style. + * + * @param style the style + * @return the element + */ + public static HtmlTree BODY(HtmlStyle style) { + return new HtmlTree(HtmlTag.BODY) + .setStyle(style); + } + + private static final HtmlTree BR_INSTANCE = unmodifiableTree(HtmlTag.BR); + + /** + * {@return an HTML {@code BR} element} + */ + public static HtmlTree BR() { + return BR_INSTANCE; + } + + /** + * Creates an HTML {@code BUTTON} element with the given id. + * + * @param id the id + * @return the element + */ + public static HtmlTree BUTTON(HtmlId id) { + return new HtmlTree(HtmlTag.BUTTON).setId(id); + } + + /** + * Creates an HTML {@code BUTTON} element with the given style. + * + * @param style the style + * @return the element + */ + public static HtmlTree BUTTON(HtmlStyle style) { + return new HtmlTree(HtmlTag.BUTTON).setStyle(style); + } + /** * Creates an HTML {@code CAPTION} element with the given content. * @@ -376,6 +426,15 @@ public class HtmlTree extends Content { .add(body); } + /** + * Creates an empty HTML {@code CODE} element. + * + * @return the element + */ + public static HtmlTree CODE() { + return new HtmlTree(HtmlTag.CODE); + } + /** * Creates an HTML {@code CODE} element with the given content. * @@ -387,6 +446,15 @@ public class HtmlTree extends Content { .add(body); } + /** + * Creates an empty HTML {@code DD} element. + * + * @return the element + */ + public static HtmlTree DD() { + return new HtmlTree(HtmlTag.DD); + } + /** * Creates an HTML {@code DD} element with the given content. * @@ -418,27 +486,14 @@ public class HtmlTree extends Content { } /** - * Creates an HTML {@code DL} element with the given style. + * Creates an HTML {@code DIV} element with the given id. * - * @param style the style + * @param id the id * @return the element */ - public static HtmlTree DL(HtmlStyle style) { - return new HtmlTree(HtmlTag.DL) - .setStyle(style); - } - - /** - * Creates an HTML {@code DL} element with the given style and content. - * - * @param style the style - * @param body the content - * @return the element - */ - public static HtmlTree DL(HtmlStyle style, Content body) { - return new HtmlTree(HtmlTag.DL) - .setStyle(style) - .add(body); + public static HtmlTree DIV(HtmlId id) { + return new HtmlTree(HtmlTag.DIV) + .setId(id); } /** @@ -476,6 +531,30 @@ public class HtmlTree extends Content { .add(body); } + /** + * Creates an HTML {@code DL} element with the given style. + * + * @param style the style + * @return the element + */ + public static HtmlTree DL(HtmlStyle style) { + return new HtmlTree(HtmlTag.DL) + .setStyle(style); + } + + /** + * Creates an HTML {@code DL} element with the given style and content. + * + * @param style the style + * @param body the content + * @return the element + */ + public static HtmlTree DL(HtmlStyle style, Content body) { + return new HtmlTree(HtmlTag.DL) + .setStyle(style) + .add(body); + } + /** * Creates an HTML {@code DT} element with the given content. * @@ -487,6 +566,17 @@ public class HtmlTree extends Content { .add(body); } + /** + * Creates an HTML {@code EM} element with the given content. + * + * @param body content for the element + * @return the element + */ + public static HtmlTree EM(String body) { + return new HtmlTree(HtmlTag.EM) + .add(body); + } + /** * Creates an HTML {@code FOOTER} element. * The role is set to {@code contentinfo}. @@ -573,6 +663,15 @@ public class HtmlTree extends Content { }; } + private static final HtmlTree HR_INSTANCE = unmodifiableTree(HtmlTag.HR); + + /** + * {@return an HTML {@code HR} element} + */ + public static HtmlTree HR() { + return HR_INSTANCE; + } + /** * Creates an HTML {@code HTML} element with the given {@code lang} attribute, * and {@code HEAD} and {@code BODY} contents. @@ -630,6 +729,27 @@ public class HtmlTree extends Content { .add(body); } + /** + * Creates an empty HTML {@code LI} element. + * + * @return the element + */ + public static HtmlTree LI() { + return new HtmlTree(HtmlTag.LI); + } + + + /** + * Creates an HTML {@code LI} element with the given style. + * + * @param style the style + * @return the element + */ + public static HtmlTree LI(HtmlStyle style) { + return new HtmlTree(HtmlTag.LI) + .setStyle(style); + } + /** * Creates an HTML {@code LI} element with the given content. * @@ -776,6 +896,25 @@ public class HtmlTree extends Content { .setStyle(style); } + /** + * Creates an empty HTML {@code PRE} element. + * + * @return the element + */ + public static HtmlTree PRE() { + return new HtmlTree(HtmlTag.PRE); + } + + /** + * Creates an HTML {@code PRE} element with the given style + * + * @param style the style + * @return the element + */ + public static HtmlTree PRE(HtmlStyle style) { + return new HtmlTree(HtmlTag.PRE).setStyle(style); + } + /** * Creates an HTML {@code PRE} element with some content. * @@ -971,6 +1110,15 @@ public class HtmlTree extends Content { .add(body); } + /** + * Creates an empty HTML {@code UL} element. + * + * @return the element + */ + public static HtmlTree UL() { + return new HtmlTree(HtmlTag.UL); + } + /** * Creates an HTML {@code UL} element with the given style. * @@ -982,6 +1130,19 @@ public class HtmlTree extends Content { .setStyle(style); } + /** + * Creates an HTML {@code UL} element with the given id and style. + * + * @param id the id + * @param style the style + * @return the element + */ + public static HtmlTree UL(HtmlId id, HtmlStyle style) { + return new HtmlTree(HtmlTag.UL) + .setId(id) + .setStyle(style); + } + /** * Creates an HTML {@code UL} element with the given style and some content. * @@ -1015,6 +1176,15 @@ public class HtmlTree extends Content { .addAll(items, mapper); } + private static final HtmlTree WBR_INSTANCE = unmodifiableTree(HtmlTag.WBR); + + /** + * {@return an HTML {@code WBR} element} + */ + public static HtmlTree WBR() { + return WBR_INSTANCE; + } + @Override public boolean isEmpty() { return (!hasContent() && !hasAttrs()); @@ -1152,4 +1322,17 @@ public class HtmlTree extends Content { // remove extra whitespaces return rawString.trim(); } + + private static HtmlTree unmodifiableTree(HtmlTag tag) { + return new HtmlTree(tag) { + @Override + public HtmlTree add(Content c) { + throw new UnsupportedOperationException(this.tag + " add"); + } + @Override + public HtmlTree put(HtmlAttr attrName, String attrValue) { + throw new UnsupportedOperationException(this.tag + " put"); + } + }; + } } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ElementsTable.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ElementsTable.java index a531a987f0d..0ec72e4ae1c 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ElementsTable.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ElementsTable.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -870,10 +870,12 @@ public class ElementsTable { private ModuleSymbol findModuleOfPackageName(String packageName) { Name pack = names.fromString(packageName); - for (ModuleSymbol msym : modules.allModules()) { - PackageSymbol p = syms.getPackage(msym, pack); - if (p != null && !p.members().isEmpty()) { - return msym; + if (modules.modulesInitialized()) { + for (ModuleSymbol msym : modules.allModules()) { + PackageSymbol p = syms.getPackage(msym, pack); + if (p != null && !p.members().isEmpty()) { + return msym; + } } } return null; diff --git a/src/jdk.jdeps/share/classes/com/sun/tools/javap/AttributeWriter.java b/src/jdk.jdeps/share/classes/com/sun/tools/javap/AttributeWriter.java index 3b9336c499d..cccbaf14f53 100644 --- a/src/jdk.jdeps/share/classes/com/sun/tools/javap/AttributeWriter.java +++ b/src/jdk.jdeps/share/classes/com/sun/tools/javap/AttributeWriter.java @@ -35,6 +35,7 @@ import java.lang.classfile.constantpool.*; import java.lang.classfile.attribute.*; import static java.lang.classfile.ClassFile.*; import static java.lang.classfile.attribute.StackMapFrameInfo.*; +import static java.lang.classfile.instruction.CharacterRange.*; /* * A writer for writing Attributes as text. @@ -144,23 +145,23 @@ public class AttributeWriter extends BasicWriter { (e.characterRangeStart() & 0x3ff), (e.characterRangeEnd() >> 10), (e.characterRangeEnd() & 0x3ff))); - if ((e.flags() & CRT_STATEMENT) != 0) + if ((e.flags() & FLAG_STATEMENT) != 0) print(", statement"); - if ((e.flags() & CRT_BLOCK) != 0) + if ((e.flags() & FLAG_BLOCK) != 0) print(", block"); - if ((e.flags() & CRT_ASSIGNMENT) != 0) + if ((e.flags() & FLAG_ASSIGNMENT) != 0) print(", assignment"); - if ((e.flags() & CRT_FLOW_CONTROLLER) != 0) + if ((e.flags() & FLAG_FLOW_CONTROLLER) != 0) print(", flow-controller"); - if ((e.flags() & CRT_FLOW_TARGET) != 0) + if ((e.flags() & FLAG_FLOW_TARGET) != 0) print(", flow-target"); - if ((e.flags() & CRT_INVOKE) != 0) + if ((e.flags() & FLAG_INVOKE) != 0) print(", invoke"); - if ((e.flags() & CRT_CREATE) != 0) + if ((e.flags() & FLAG_CREATE) != 0) print(", create"); - if ((e.flags() & CRT_BRANCH_TRUE) != 0) + if ((e.flags() & FLAG_BRANCH_TRUE) != 0) print(", branch-true"); - if ((e.flags() & CRT_BRANCH_FALSE) != 0) + if ((e.flags() & FLAG_BRANCH_FALSE) != 0) print(", branch-false"); println(); } @@ -705,13 +706,13 @@ public class AttributeWriter extends BasicWriter { String mapTypeName(SimpleVerificationTypeInfo type) { return switch (type) { - case ITEM_TOP -> "top"; - case ITEM_INTEGER -> "int"; - case ITEM_FLOAT -> "float"; - case ITEM_LONG -> "long"; - case ITEM_DOUBLE -> "double"; - case ITEM_NULL -> "null"; - case ITEM_UNINITIALIZED_THIS -> "this"; + case TOP -> "top"; + case INTEGER -> "int"; + case FLOAT -> "float"; + case LONG -> "long"; + case DOUBLE -> "double"; + case NULL -> "null"; + case UNINITIALIZED_THIS -> "this"; }; } diff --git a/src/jdk.jdeps/share/classes/com/sun/tools/javap/ClassWriter.java b/src/jdk.jdeps/share/classes/com/sun/tools/javap/ClassWriter.java index 764f93bd54a..77fbce8839e 100644 --- a/src/jdk.jdeps/share/classes/com/sun/tools/javap/ClassWriter.java +++ b/src/jdk.jdeps/share/classes/com/sun/tools/javap/ClassWriter.java @@ -741,7 +741,7 @@ public class ClassWriter extends BasicWriter { */ String getConstantValue(ClassDesc d, ConstantValueEntry cpInfo) { switch (cpInfo.tag()) { - case ClassFile.TAG_INTEGER: { + case PoolEntry.TAG_INTEGER: { var val = (Integer)cpInfo.constantValue(); switch (d.descriptorString()) { case "C": @@ -755,7 +755,7 @@ public class ClassWriter extends BasicWriter { return String.valueOf(val); } } - case ClassFile.TAG_STRING: + case PoolEntry.TAG_STRING: return getConstantStringValue(cpInfo.constantValue().toString()); default: return constantWriter.stringValue(cpInfo); diff --git a/src/jdk.jdeps/share/classes/com/sun/tools/javap/CodeWriter.java b/src/jdk.jdeps/share/classes/com/sun/tools/javap/CodeWriter.java index 519a5adcf62..8f6b9b1d2ed 100644 --- a/src/jdk.jdeps/share/classes/com/sun/tools/javap/CodeWriter.java +++ b/src/jdk.jdeps/share/classes/com/sun/tools/javap/CodeWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -92,20 +92,22 @@ public class CodeWriter extends BasicWriter { public void writeInstrs(CodeAttribute attr) { List detailWriters = getDetailWriters(attr); - int pc = 0; + int[] pcState = {0}; try { - for (var coe: attr) { + attr.forEach(coe -> { if (coe instanceof Instruction instr) { - for (InstructionDetailWriter w: detailWriters) + int pc = pcState[0]; + for (InstructionDetailWriter w : detailWriters) w.writeDetails(pc, instr); writeInstr(pc, instr, attr); - pc += instr.sizeInBytes(); + pcState[0] = pc + instr.sizeInBytes(); } - } + }); } catch (IllegalArgumentException e) { - report("error at or after byte " + pc); + report("error at or after address " + pcState[0] + ": " + e.getMessage()); } + int pc = pcState[0]; for (InstructionDetailWriter w: detailWriters) w.flush(pc); } diff --git a/src/jdk.jdeps/share/classes/com/sun/tools/javap/ConstantWriter.java b/src/jdk.jdeps/share/classes/com/sun/tools/javap/ConstantWriter.java index c649ce98296..b3c6b5b6c64 100644 --- a/src/jdk.jdeps/share/classes/com/sun/tools/javap/ConstantWriter.java +++ b/src/jdk.jdeps/share/classes/com/sun/tools/javap/ConstantWriter.java @@ -26,7 +26,8 @@ package com.sun.tools.javap; import java.lang.classfile.constantpool.*; -import static java.lang.classfile.ClassFile.*; + +import static java.lang.classfile.constantpool.PoolEntry.*; /* * Write a constant pool entry. @@ -156,13 +157,13 @@ public class ConstantWriter extends BasicWriter { case TAG_CLASS -> "Class"; case TAG_STRING -> "String"; case TAG_FIELDREF -> "Fieldref"; - case TAG_METHODHANDLE -> "MethodHandle"; - case TAG_METHODTYPE -> "MethodType"; + case TAG_METHOD_HANDLE -> "MethodHandle"; + case TAG_METHOD_TYPE -> "MethodType"; case TAG_METHODREF -> "Methodref"; - case TAG_INTERFACEMETHODREF -> "InterfaceMethodref"; - case TAG_INVOKEDYNAMIC -> "InvokeDynamic"; - case TAG_CONSTANTDYNAMIC -> "Dynamic"; - case TAG_NAMEANDTYPE -> "NameAndType"; + case TAG_INTERFACE_METHODREF -> "InterfaceMethodref"; + case TAG_INVOKE_DYNAMIC -> "InvokeDynamic"; + case TAG_DYNAMIC -> "Dynamic"; + case TAG_NAME_AND_TYPE -> "NameAndType"; default -> "Unknown"; }; } @@ -177,13 +178,13 @@ public class ConstantWriter extends BasicWriter { case TAG_CLASS -> "class"; case TAG_STRING -> "String"; case TAG_FIELDREF -> "Field"; - case TAG_METHODHANDLE -> "MethodHandle"; - case TAG_METHODTYPE -> "MethodType"; + case TAG_METHOD_HANDLE -> "MethodHandle"; + case TAG_METHOD_TYPE -> "MethodType"; case TAG_METHODREF -> "Method"; - case TAG_INTERFACEMETHODREF -> "InterfaceMethod"; - case TAG_INVOKEDYNAMIC -> "InvokeDynamic"; - case TAG_CONSTANTDYNAMIC -> "Dynamic"; - case TAG_NAMEANDTYPE -> "NameAndType"; + case TAG_INTERFACE_METHODREF -> "InterfaceMethod"; + case TAG_INVOKE_DYNAMIC -> "InvokeDynamic"; + case TAG_DYNAMIC -> "Dynamic"; + case TAG_NAME_AND_TYPE -> "NameAndType"; default -> "(unknown tag " + tag + ")"; }; } diff --git a/src/jdk.jdeps/share/classes/com/sun/tools/javap/StackMapWriter.java b/src/jdk.jdeps/share/classes/com/sun/tools/javap/StackMapWriter.java index a1d939bcc4f..d899569724e 100644 --- a/src/jdk.jdeps/share/classes/com/sun/tools/javap/StackMapWriter.java +++ b/src/jdk.jdeps/share/classes/com/sun/tools/javap/StackMapWriter.java @@ -122,25 +122,25 @@ public class StackMapWriter extends InstructionDetailWriter { switch (entry) { case StackMapFrameInfo.SimpleVerificationTypeInfo s -> { switch (s) { - case ITEM_TOP -> + case TOP -> print("top"); - case ITEM_INTEGER -> + case INTEGER -> print("int"); - case ITEM_FLOAT -> + case FLOAT -> print("float"); - case ITEM_LONG -> + case LONG -> print("long"); - case ITEM_DOUBLE -> + case DOUBLE -> print("double"); - case ITEM_NULL -> + case NULL -> print("null"); - case ITEM_UNINITIALIZED_THIS -> + case UNINITIALIZED_THIS -> print("uninit_this"); } } diff --git a/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTY.java b/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTY.java index fcf9ed12166..acdd6c45f6e 100644 --- a/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTY.java +++ b/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTY.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -980,7 +980,6 @@ public class TTY implements EventNotifier { return; } else if ( // Standard VM options passed on - token.equals("-v") || token.startsWith("-v:") || // -v[:...] token.startsWith("-verbose") || // -verbose[:...] token.startsWith("-D") || // -classpath handled below @@ -988,12 +987,9 @@ public class TTY implements EventNotifier { token.startsWith("-X") || // Old-style options (These should remain in place as long as // the standard VM accepts them) - token.equals("-noasyncgc") || token.equals("-prof") || token.equals("-verify") || token.equals("-verifyremote") || - token.equals("-verbosegc") || - token.startsWith("-ms") || token.startsWith("-mx") || - token.startsWith("-ss") || token.startsWith("-oss") ) { + token.equals("-verbosegc")) { javaArgs = addArgument(javaArgs, token); } else if (token.startsWith("-R")) { diff --git a/src/jdk.jdi/share/classes/com/sun/tools/jdi/TargetVM.java b/src/jdk.jdi/share/classes/com/sun/tools/jdi/TargetVM.java index 2a9e4555099..5023a03d514 100644 --- a/src/jdk.jdi/share/classes/com/sun/tools/jdi/TargetVM.java +++ b/src/jdk.jdi/share/classes/com/sun/tools/jdi/TargetVM.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -123,8 +123,9 @@ public class TargetVM implements Runnable { byte b[] = connection.readPacket(); if (b.length == 0) { done = true; + } else { + p = Packet.fromByteArray(b); } - p = Packet.fromByteArray(b); } catch (IOException e) { done = true; } diff --git a/src/jdk.jdi/share/native/libdt_shmem/SharedMemoryConnection.c b/src/jdk.jdi/share/native/libdt_shmem/SharedMemoryConnection.c index af78969e316..b6d246d0433 100644 --- a/src/jdk.jdi/share/native/libdt_shmem/SharedMemoryConnection.c +++ b/src/jdk.jdi/share/native/libdt_shmem/SharedMemoryConnection.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -115,7 +115,7 @@ packetToByteArray(JNIEnv *env, jdwpPacket *str) /* total packet length is header + data */ array = (*env)->NewByteArray(env, total_length); - if ((*env)->ExceptionOccurred(env)) { + if ((*env)->ExceptionCheck(env)) { return NULL; } @@ -144,7 +144,7 @@ packetToByteArray(JNIEnv *env, jdwpPacket *str) if (data_length > 0) { (*env)->SetByteArrayRegion(env, array, JDWP_HEADER_SIZE, data_length, str->type.cmd.data); - if ((*env)->ExceptionOccurred(env)) { + if ((*env)->ExceptionCheck(env)) { return NULL; } } @@ -174,7 +174,7 @@ byteArrayToPacket(JNIEnv *env, jbyteArray b, jdwpPacket *str) * Get the packet header */ (*env)->GetByteArrayRegion(env, b, 0, sizeof(pktHeader), pktHeader); - if ((*env)->ExceptionOccurred(env)) { + if ((*env)->ExceptionCheck(env)) { /* b shorter than sizeof(pktHeader) */ return; } @@ -221,7 +221,7 @@ byteArrayToPacket(JNIEnv *env, jbyteArray b, jdwpPacket *str) } (*env)->GetByteArrayRegion(env, b, sizeof(pktHeader), /*sizeof(CmdPacket)+4*/ data_length, data); - if ((*env)->ExceptionOccurred(env)) { + if ((*env)->ExceptionCheck(env)) { free(data); return; } @@ -326,7 +326,7 @@ JNIEXPORT void JNICALL Java_com_sun_tools_jdi_SharedMemoryConnection_sendPacket0 jint rc; byteArrayToPacket(env, b, &packet); - if ((*env)->ExceptionOccurred(env)) { + if ((*env)->ExceptionCheck(env)) { return; } diff --git a/src/jdk.jdi/share/native/libdt_shmem/SharedMemoryTransport.c b/src/jdk.jdi/share/native/libdt_shmem/SharedMemoryTransport.c index 7258503f7e1..867ed1d8567 100644 --- a/src/jdk.jdi/share/native/libdt_shmem/SharedMemoryTransport.c +++ b/src/jdk.jdi/share/native/libdt_shmem/SharedMemoryTransport.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -51,7 +51,7 @@ void throwException(JNIEnv *env, char *exceptionClassName, char *message) { jclass excClass = (*env)->FindClass(env, exceptionClassName); - if ((*env)->ExceptionOccurred(env)) { + if ((*env)->ExceptionCheck(env)) { return; } (*env)->ThrowNew(env, excClass, message); @@ -109,7 +109,7 @@ JNIEXPORT jlong JNICALL Java_com_sun_tools_jdi_SharedMemoryTransportService_atta const char *addrChars; addrChars = (*env)->GetStringUTFChars(env, address, NULL); - if ((*env)->ExceptionOccurred(env)) { + if ((*env)->ExceptionCheck(env)) { return CONNECTION_TO_ID(connection); } else if (addrChars == NULL) { throwException(env, "java/lang/InternalError", "GetStringUTFChars failed"); @@ -143,7 +143,7 @@ JNIEXPORT jstring JNICALL Java_com_sun_tools_jdi_SharedMemoryTransportService_na throwShmemException(env, "shmemBase_name failed", rc); } else { nameString = (*env)->NewStringUTF(env, namePtr); - if ((nameString == NULL) && !(*env)->ExceptionOccurred(env)) { + if ((nameString == NULL) && !(*env)->ExceptionCheck(env)) { throwException(env, "java/lang/InternalError", "Unable to create string"); } } @@ -190,7 +190,7 @@ JNIEXPORT jlong JNICALL Java_com_sun_tools_jdi_SharedMemoryTransportService_star if (address != NULL) { addrChars = (*env)->GetStringUTFChars(env, address, NULL); - if ((*env)->ExceptionOccurred(env)) { + if ((*env)->ExceptionCheck(env)) { return TRANSPORT_TO_ID(transport); } else if (addrChars == NULL) { throwException(env, "java/lang/InternalError", "GetStringUTFChars failed"); diff --git a/src/jdk.jdwp.agent/share/native/libjdwp/util.c b/src/jdk.jdwp.agent/share/native/libjdwp/util.c index 7e198be9a46..335acc62dcf 100644 --- a/src/jdk.jdwp.agent/share/native/libjdwp/util.c +++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.c @@ -1652,6 +1652,185 @@ setAgentPropertyValue(JNIEnv *env, char *propertyName, char* propertyValue) } } +#ifdef DEBUG +// APIs that can be called when debugging the debug agent + +#define check_jvmti_status(err, msg) \ + if (err != JVMTI_ERROR_NONE) { \ + EXIT_ERROR(err, msg); \ + } + +char* +translateThreadState(jint flags) { + char str[15 * 20]; + str[0] = '\0'; + + if (flags & JVMTI_THREAD_STATE_ALIVE) { + strcat(str, " ALIVE"); + } + if (flags & JVMTI_THREAD_STATE_TERMINATED) { + strcat(str, " TERMINATED"); + } + if (flags & JVMTI_THREAD_STATE_RUNNABLE) { + strcat(str, " RUNNABLE"); + } + if (flags & JVMTI_THREAD_STATE_WAITING) { + strcat(str, " WAITING"); + } + if (flags & JVMTI_THREAD_STATE_WAITING_INDEFINITELY) { + strcat(str, " WAITING_INDEFINITELY"); + } + if (flags & JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT) { + strcat(str, " WAITING_WITH_TIMEOUT"); + } + if (flags & JVMTI_THREAD_STATE_SLEEPING) { + strcat(str, " SLEEPING"); + } + if (flags & JVMTI_THREAD_STATE_IN_OBJECT_WAIT) { + strcat(str, " IN_OBJECT_WAIT"); + } + if (flags & JVMTI_THREAD_STATE_PARKED) { + strcat(str, " PARKED"); + } + if (flags & JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER) { + strcat(str, " BLOCKED_ON_MONITOR_ENTER"); + } + if (flags & JVMTI_THREAD_STATE_SUSPENDED) { + strcat(str, " SUSPENDED"); + } + if (flags & JVMTI_THREAD_STATE_INTERRUPTED) { + strcat(str, " INTERRUPTED"); + } + if (flags & JVMTI_THREAD_STATE_IN_NATIVE) { + strcat(str, " IN_NATIVE"); + } + + if (strlen(str) == 0) { + strcpy(str, ""); + } + + char* tstate = (char*)jvmtiAllocate((int)strlen(str) + 1); + strcpy(tstate, str); + + return tstate; +} + +char* +getThreadName(jthread thread) { + jvmtiThreadInfo thr_info; + jvmtiError err; + + memset(&thr_info, 0, sizeof(thr_info)); + err = JVMTI_FUNC_PTR(gdata->jvmti,GetThreadInfo) + (gdata->jvmti, thread, &thr_info); + if (err == JVMTI_ERROR_WRONG_PHASE || err == JVMTI_ERROR_THREAD_NOT_ALIVE) { + return NULL; // VM or target thread completed its work + } + check_jvmti_status(err, "getThreadName: error in JVMTI GetThreadInfo call"); + + char* tname = thr_info.name; + if (tname == NULL) { + const char* UNNAMED_STR = ""; + size_t UNNAMED_LEN = strlen(UNNAMED_STR); + tname = (char*)jvmtiAllocate((int)UNNAMED_LEN + 1); + strcpy(tname, UNNAMED_STR); + } + return tname; +} + +char* +getMethodName(jmethodID method) { + char* mname = NULL; + jvmtiError err; + + err = JVMTI_FUNC_PTR(gdata->jvmti,GetMethodName) + (gdata->jvmti, method, &mname, NULL, NULL); + check_jvmti_status(err, "getMethodName: error in JVMTI GetMethodName call"); + + return mname; +} + +static char* +get_method_class_name(jmethodID method) { + jclass klass = NULL; + char* cname = NULL; + char* result = NULL; + jvmtiError err; + + err = JVMTI_FUNC_PTR(gdata->jvmti,GetMethodDeclaringClass) + (gdata->jvmti, method, &klass); + check_jvmti_status(err, "get_method_class_name: error in JVMTI GetMethodDeclaringClass"); + + err = JVMTI_FUNC_PTR(gdata->jvmti,GetClassSignature) + (gdata->jvmti, klass, &cname, NULL); + check_jvmti_status(err, "get_method_class_name: error in JVMTI GetClassSignature"); + + size_t len = strlen(cname) - 2; // get rid of leading 'L' and trailing ';' + result = (char*)jvmtiAllocate((int)len + 1); + strncpy(result, cname + 1, len); // skip leading 'L' + result[len] = '\0'; + jvmtiDeallocate((void*)cname); + return result; +} + +static void +print_method(jmethodID method, jint depth) { + char* cname = NULL; + char* mname = NULL; + char* msign = NULL; + jvmtiError err; + + cname = get_method_class_name(method); + + err = JVMTI_FUNC_PTR(gdata->jvmti,GetMethodName) + (gdata->jvmti, method, &mname, &msign, NULL); + check_jvmti_status(err, "print_method: error in JVMTI GetMethodName"); + + tty_message("%2d: %s: %s%s", depth, cname, mname, msign); + jvmtiDeallocate((void*)cname); + jvmtiDeallocate((void*)mname); + jvmtiDeallocate((void*)msign); +} + +#define MAX_FRAME_COUNT_PRINT_STACK_TRACE 200 + +void +printStackTrace(jthread thread) { + jvmtiFrameInfo frames[MAX_FRAME_COUNT_PRINT_STACK_TRACE]; + char* tname = getThreadName(thread); + jint count = 0; + + jvmtiError err = JVMTI_FUNC_PTR(gdata->jvmti,GetStackTrace) + (gdata->jvmti, thread, 0, MAX_FRAME_COUNT_PRINT_STACK_TRACE, frames, &count); + check_jvmti_status(err, "printStackTrace: error in JVMTI GetStackTrace"); + + tty_message("JVMTI Stack Trace for thread %s: frame count: %d", tname, count); + for (int depth = 0; depth < count; depth++) { + print_method(frames[depth].method, depth); + } + jvmtiDeallocate((void*)tname); +} + +void +printThreadInfo(jthread thread) { + jvmtiThreadInfo thread_info; + jint thread_state; + jvmtiError err; + err = JVMTI_FUNC_PTR(gdata->jvmti,GetThreadInfo) + (gdata->jvmti, thread, &thread_info); + check_jvmti_status(err, "Error in GetThreadInfo"); + err = JVMTI_FUNC_PTR(gdata->jvmti,GetThreadState) + (gdata->jvmti, thread, &thread_state); + check_jvmti_status(err, "Error in GetThreadState"); + const char* state = translateThreadState(thread_state); + tty_message("Thread: %p, name: %s, state(%x): %s, attrs: %s %s", + thread, thread_info.name, thread_state, state, + (isVThread(thread) ? "virtual": "platform"), + (thread_info.is_daemon ? "daemon": "")); +} + +#endif /* DEBUG*/ + /** * Return property value as JDWP allocated string in UTF8 encoding */ diff --git a/src/jdk.jdwp.agent/share/native/libjdwp/util.h b/src/jdk.jdwp.agent/share/native/libjdwp/util.h index 75281813709..3d499d7d569 100644 --- a/src/jdk.jdwp.agent/share/native/libjdwp/util.h +++ b/src/jdk.jdwp.agent/share/native/libjdwp/util.h @@ -386,6 +386,15 @@ jvmtiError allNestedClasses(jclass clazz, jclass **ppnested, jint *pcount); void setAgentPropertyValue(JNIEnv *env, char *propertyName, char* propertyValue); +#ifdef DEBUG +// APIs that can be called when debugging the debug agent +char* translateThreadState(jint flags); +char* getThreadName(jthread thread); +char* getMethodName(jmethodID method); +void printStackTrace(jthread thread); +void printThreadInfo(jthread thread); +#endif + void *jvmtiAllocate(jint numBytes); void jvmtiDeallocate(void *buffer); diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/EventClassBuilder.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/EventClassBuilder.java index 52362208484..1373c3ca496 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/EventClassBuilder.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/EventClassBuilder.java @@ -84,7 +84,7 @@ public final class EventClassBuilder { int index = 0; for (ValueDescriptor v : fields) { codeBuilder.iload(1); - codeBuilder.ldc(index); + codeBuilder.loadConstant(index); Label notEqual = codeBuilder.newLabel(); codeBuilder.if_icmpne(notEqual); codeBuilder.aload(0); // this diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/EventInstrumentation.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/EventInstrumentation.java index 71dc97d114e..d962a535829 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/EventInstrumentation.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/EventInstrumentation.java @@ -499,7 +499,7 @@ final class EventInstrumentation { // if (!settingsMethod(eventConfiguration.settingX)) goto fail; codeBuilder.aload(0); getEventConfiguration(codeBuilder); - codeBuilder.ldc(index); + codeBuilder.loadConstant(index); invokevirtual(codeBuilder, TYPE_EVENT_CONFIGURATION, METHOD_EVENT_CONFIGURATION_GET_SETTING); MethodTypeDesc mdesc = MethodTypeDesc.ofDescriptor("(" + sd.paramType().descriptorString() + ")Z"); codeBuilder.checkcast(sd.paramType()); diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecorder.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecorder.java index 24b98bb629f..b33a8943042 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecorder.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecorder.java @@ -657,7 +657,7 @@ public final class PlatformRecorder { } target.setStartTime(startTime); target.setStopTime(endTime); - target.setInternalDuration(Duration.between(startTime, endTime)); + target.setInternalDuration(startTime.until(endTime)); } public synchronized void migrate(SafePath repo) throws IOException { diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/AbstractDCmd.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/AbstractDCmd.java index d0b95df8484..516d094b5da 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/AbstractDCmd.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/AbstractDCmd.java @@ -30,7 +30,6 @@ import java.nio.file.InvalidPathException; import java.nio.file.Path; import java.nio.file.Paths; import java.time.Duration; -import java.time.LocalDateTime; import java.util.ArrayList; import java.util.Comparator; import java.util.List; @@ -288,41 +287,4 @@ abstract class AbstractDCmd { return "/directory/recordings"; } } - - static String expandFilename(String filename) { - if (filename == null || filename.indexOf('%') == -1) { - return filename; - } - - String pid = null; - String time = null; - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < filename.length(); i++) { - char c = filename.charAt(i); - if (c == '%' && i < filename.length() - 1) { - char nc = filename.charAt(i + 1); - if (nc == '%') { // %% ==> % - sb.append('%'); - i++; - } else if (nc == 'p') { - if (pid == null) { - pid = JVM.getPid(); - } - sb.append(pid); - i++; - } else if (nc == 't') { - if (time == null) { - time = ValueFormatter.formatDateTime(LocalDateTime.now()); - } - sb.append(time); - i++; - } else { - sb.append('%'); - } - } else { - sb.append(c); - } - } - return sb.toString(); - } } diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/ArgumentParser.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/ArgumentParser.java index c14ce6025ce..151456745b0 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/ArgumentParser.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/ArgumentParser.java @@ -25,14 +25,18 @@ package jdk.jfr.internal.dcmd; +import java.time.LocalDateTime; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; import java.util.StringJoiner; + +import jdk.jfr.internal.JVM; import jdk.jfr.internal.util.SpellChecker; import jdk.jfr.internal.util.TimespanUnit; +import jdk.jfr.internal.util.ValueFormatter; final class ArgumentParser { private final Map options = new HashMap<>(); @@ -221,15 +225,59 @@ final class ArgumentParser { private Object value(String name, String type, String text) { return switch (type) { - case "JULONG" -> parseLong(name, text); + case "INT" -> parseLong(name, text); case "STRING", "STRING SET" -> text == null ? "" : text; case "BOOLEAN" -> parseBoolean(name, text); case "NANOTIME" -> parseNanotime(name, text); case "MEMORY SIZE" -> parseMemorySize(name, text); + case "FILE" -> text == null ? "" : parseFilename(text); default -> throw new InternalError("Unknown type: " + type); }; } + /** + * Expands filename arguments replacing '%p' with the PID + * and '%t' with the time in 'yyyy_MM_dd_HH_mm_ss' format. + * @param filename a filename to be expanded + * @return filename with expanded arguments + */ + private String parseFilename(String filename) { + if (filename == null || filename.indexOf('%') == -1) { + return filename; + } + + String pid = null; + String time = null; + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < filename.length(); i++) { + char c = filename.charAt(i); + if (c == '%' && i < filename.length() - 1) { + char nc = filename.charAt(i + 1); + if (nc == '%') { // %% ==> % + sb.append('%'); + i++; + } else if (nc == 'p') { + if (pid == null) { + pid = JVM.getPid(); + } + sb.append(pid); + i++; + } else if (nc == 't') { + if (time == null) { + time = ValueFormatter.formatDateTime(LocalDateTime.now()); + } + sb.append(time); + i++; + } else { + sb.append('%'); + } + } else { + sb.append(c); + } + } + return sb.toString(); + } + private Long parseLong(String name, String text) { if (text == null) { throw new IllegalArgumentException("Parsing error long value: syntax error, value is null"); @@ -361,4 +409,4 @@ final class ArgumentParser { } } } -} \ No newline at end of file +} diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdDump.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdDump.java index 605eb4bc745..7f68ba7ee79 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdDump.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdDump.java @@ -55,7 +55,7 @@ final class DCmdDump extends AbstractDCmd { public void execute(ArgumentParser parser) throws DCmdException { parser.checkUnknownArguments(); String name = parser.getOption("name"); - String filename = expandFilename(parser.getOption("filename")); + String filename = parser.getOption("filename"); Long maxAge = parser.getOption("maxage"); Long maxSize = parser.getOption("maxsize"); String begin = parser.getOption("begin"); @@ -230,14 +230,14 @@ final class DCmdDump extends AbstractDCmd { dumped. If no filename is given, a filename is generated from the PID and the current date. The filename may also be a directory in which case, the filename is generated from the PID and the current date in - the specified directory. (STRING, no default value) + the specified directory. (FILE, no default value) Note: If a filename is given, '%%p' in the filename will be replaced by the PID, and '%%t' will be replaced by the time in 'yyyy_MM_dd_HH_mm_ss' format. maxage (Optional) Length of time for dumping the flight recording data to a - file. (INTEGER followed by 's' for seconds 'm' for minutes or 'h' for + file. (INT followed by 's' for seconds 'm' for minutes or 'h' for hours, no default value) maxsize (Optional) Maximum size for the amount of data to dump from a flight @@ -284,7 +284,7 @@ final class DCmdDump extends AbstractDCmd { "STRING", false, true, null, false), new Argument("filename", "Copy recording data to file, e.g. \\\"" + exampleFilename() + "\\\"", - "STRING", false, true, null, false), + "FILE", false, true, null, false), new Argument("maxage", "Maximum duration to dump, in (s)econds, (m)inutes, (h)ours, or (d)ays, e.g. 60m, or 0 for no limit", "NANOTIME", false, true, null, false), diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdQuery.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdQuery.java index 4c296d8a78f..b2e9aecda38 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdQuery.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdQuery.java @@ -141,7 +141,7 @@ public final class DCmdQuery extends AbstractDCmd { Options: - maxage (Optional) Length of time for the query to span. (INTEGER followed by + maxage (Optional) Length of time for the query to span. (INT followed by 's' for seconds 'm' for minutes or 'h' for hours, no default value) maxsize (Optional) Maximum size for the query to span in bytes if one of @@ -154,7 +154,7 @@ public final class DCmdQuery extends AbstractDCmd { verbose (Optional) Display additional information about the query execution. (BOOLEAN, false) - width (Optional) Maximum number of horizontal characters. (BOOLEAN, false)"""; + width (Optional) Maximum number of horizontal characters. (INT, default value is 100)"""; } @Override @@ -170,7 +170,7 @@ public final class DCmdQuery extends AbstractDCmd { null, false), new Argument("verbose", "Display additional information about the query execution", "BOOLEAN", false, true, "false", false), - new Argument("width", "Maximum number of horizontal characters", "JULONG", false, true, "100", + new Argument("width", "Maximum number of horizontal characters", "INT", false, true, "100", false), }; } } diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdStart.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdStart.java index d115b9f5b62..26c095541b6 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdStart.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdStart.java @@ -80,7 +80,7 @@ final class DCmdStart extends AbstractDCmd { Long delay = parser.getOption("delay"); Long duration = parser.getOption("duration"); Boolean disk = parser.getOption("disk"); - String path = expandFilename(parser.getOption("filename")); + String path = parser.getOption("filename"); Long maxAge = parser.getOption("maxage"); Long maxSize = parser.getOption("maxsize"); Long flush = parser.getOption("flush-interval"); @@ -353,7 +353,7 @@ final class DCmdStart extends AbstractDCmd { Options: delay (Optional) Length of time to wait before starting to record - (INTEGER followed by 's' for seconds 'm' for minutes or h' for + (INT followed by 's' for seconds 'm' for minutes or h' for hours, 0s) disk (Optional) Flag for also writing the data to disk while recording @@ -368,7 +368,7 @@ final class DCmdStart extends AbstractDCmd { id-1-2021_09_14_09_00.jfr) (BOOLEAN, false) duration (Optional) Length of time to record. Note that 0s means forever - (INTEGER followed by 's' for seconds 'm' for minutes or 'h' for + (INT followed by 's' for seconds 'm' for minutes or 'h' for hours, 0s) filename (Optional) Name of the file to which the flight recording data is @@ -377,7 +377,7 @@ final class DCmdStart extends AbstractDCmd { placed in the directory where the process was started. The filename may also be a directory in which case, the filename is generated from the PID and the current date in the specified - directory. (STRING, no default value) + directory. (FILE, no default value) Note: If a filename is given, '%p' in the filename will be replaced by the PID, and '%t' will be replaced by the time in @@ -385,7 +385,7 @@ final class DCmdStart extends AbstractDCmd { maxage (Optional) Maximum time to keep the recorded data on disk. This parameter is valid only when the disk parameter is set to true. - Note 0s means forever. (INTEGER followed by 's' for seconds 'm' + Note 0s means forever. (INT followed by 's' for seconds 'm' for minutes or 'h' for hours, 0s) maxsize (Optional) Maximum size of the data to keep on disk in bytes if @@ -501,7 +501,7 @@ final class DCmdStart extends AbstractDCmd { "BOOLEAN", false, true, "true", false), new Argument("filename", "Resulting recording filename, e.g. \\\"" + exampleFilename() + "\\\"", - "STRING", false, true, "hotspot-pid-xxxxx-id-y-YYYY_MM_dd_HH_mm_ss.jfr", false), + "FILE", false, true, "hotspot-pid-xxxxx-id-y-YYYY_MM_dd_HH_mm_ss.jfr", false), new Argument("maxage", "Maximum time to keep recorded data (on disk) in (s)econds, (m)inutes, (h)ours, or (d)ays, e.g. 60m, or 0 for no limit", "NANOTIME", false, true, "0", false), diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdStop.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdStop.java index 92d2d28b472..5cf983645c6 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdStop.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdStop.java @@ -44,7 +44,7 @@ final class DCmdStop extends AbstractDCmd { protected void execute(ArgumentParser parser) throws DCmdException { parser.checkUnknownArguments(); String name = parser.getOption("name"); - String filename = expandFilename(parser.getOption("filename")); + String filename = parser.getOption("filename"); try { Recording recording = findRecording(name); WriteableUserPath path = PrivateAccess.getInstance().getPlatformRecording(recording).getDestination(); @@ -80,7 +80,7 @@ final class DCmdStop extends AbstractDCmd { filename (Optional) Name of the file to which the recording is written when the recording is stopped. If no path is provided, the data from the recording - is discarded. (STRING, no default value) + is discarded. (FILE, no default value) Note: If a path is given, '%%p' in the path will be replaced by the PID, and '%%t' will be replaced by the time in 'yyyy_MM_dd_HH_mm_ss' format. @@ -107,7 +107,7 @@ final class DCmdStop extends AbstractDCmd { "STRING", true, true, null, false), new Argument("filename", "Copy recording data to file, e.g. \\\"" + exampleFilename() + "\\\"", - "STRING", false, true, null, false) + "FILE", false, true, null, false) }; } } diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdView.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdView.java index 1d6f6e3dd23..8d1c45b64c9 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdView.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdView.java @@ -108,9 +108,9 @@ public class DCmdView extends AbstractDCmd { return """ Options: - cell-height (Optional) Maximum number of rows in a table cell. (INTEGER, no default value) + cell-height (Optional) Maximum number of rows in a table cell. (INT, no default value) - maxage (Optional) Length of time for the view to span. (INTEGER followed by + maxage (Optional) Length of time for the view to span. (INT followed by 's' for seconds 'm' for minutes or 'h' for hours, default value is 10m) maxsize (Optional) Maximum size for the view to span in bytes if one of @@ -127,7 +127,7 @@ public class DCmdView extends AbstractDCmd { See list below for available views. (STRING, no default value) width (Optional) The width of the view in characters - (INTEGER, no default value)"""; + (INT, default value is 100)"""; } public String getExamples() { @@ -136,7 +136,7 @@ public class DCmdView extends AbstractDCmd { $ jcmd JFR.view gc - $ jcmd JFR.view width=160 hot-methods $ jcmd JFR.view verbose=true allocation-by-class @@ -154,7 +154,7 @@ public class DCmdView extends AbstractDCmd { return new Argument[] { new Argument("cell-height", "Maximum heigth of a table cell", - "JULONG", false, true, "1", false), + "INT", false, true, "1", false), new Argument("maxage", "Maximum duration of data to view, in (s)econds, (m)inutes, (h)ours, or (d)ays, e.g. 60m, or 0 for no limit", "NANOTIME", false, true, "10m", false), @@ -172,7 +172,7 @@ public class DCmdView extends AbstractDCmd { "STRING", true, false, null, false), new Argument("width", "Maximum number of horizontal characters", - "JULONG", false, true, "100", false) + "INT", false, true, "100", false) }; } } diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/query/Function.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/query/Function.java index 9540834b87a..29d55e95673 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/query/Function.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/query/Function.java @@ -472,7 +472,7 @@ abstract class Function { if (last == null) { return ChronoUnit.FOREVER.getDuration(); } - return Duration.between(first, last); + return first.until(last); } } diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/util/StopWatch.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/util/StopWatch.java index 24bf3d16b01..cf775f7d995 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/util/StopWatch.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/util/StopWatch.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -62,7 +62,7 @@ public final class StopWatch { for (int i = 0; i < timings.size() - 1; i++) { Timing current = timings.get(i); Timing next = timings.get(i + 1); - Duration d = Duration.between(current.start(), next.start()); + Duration d = current.start().until(next.start()); sb.add(current.name() + "=" + ValueFormatter.formatDuration(d)); } return sb.toString(); diff --git a/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/IncludeLocalesPlugin.java b/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/IncludeLocalesPlugin.java index 4edc90a97b7..9b9e7ad1ce8 100644 --- a/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/IncludeLocalesPlugin.java +++ b/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/IncludeLocalesPlugin.java @@ -33,6 +33,8 @@ import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; + +import static java.lang.classfile.constantpool.PoolEntry.*; import static java.util.ResourceBundle.Control; import java.util.Set; import java.util.function.IntUnaryOperator; @@ -41,7 +43,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; import java.util.stream.Stream; -import static java.lang.classfile.ClassFile.*; + import jdk.tools.jlink.internal.ResourcePrevisitor; import jdk.tools.jlink.internal.StringTable; import jdk.tools.jlink.plugin.ResourcePoolModule; @@ -300,18 +302,18 @@ public final class IncludeLocalesPlugin extends AbstractPlugin implements Resour } case TAG_CLASS, TAG_STRING, - TAG_METHODTYPE, + TAG_METHOD_TYPE, TAG_MODULE, TAG_PACKAGE -> offset += 3; - case TAG_METHODHANDLE -> offset += 4; + case TAG_METHOD_HANDLE -> offset += 4; case TAG_INTEGER, TAG_FLOAT, TAG_FIELDREF, TAG_METHODREF, - TAG_INTERFACEMETHODREF, - TAG_NAMEANDTYPE, - TAG_CONSTANTDYNAMIC, - TAG_INVOKEDYNAMIC -> offset += 5; + TAG_INTERFACE_METHODREF, + TAG_NAME_AND_TYPE, + TAG_DYNAMIC, + TAG_INVOKE_DYNAMIC -> offset += 5; case TAG_LONG, TAG_DOUBLE -> {offset += 9; cpSlot++;} //additional slot for double and long entries default -> throw new IllegalArgumentException("Unknown constant pool entry: 0x" diff --git a/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StringSharingPlugin.java b/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StringSharingPlugin.java index 6f8bc9b7779..71c509e7dea 100644 --- a/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StringSharingPlugin.java +++ b/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StringSharingPlugin.java @@ -51,6 +51,8 @@ import jdk.tools.jlink.internal.ResourcePoolManager; import jdk.tools.jlink.internal.ResourcePrevisitor; import jdk.tools.jlink.internal.StringTable; +import static java.lang.classfile.constantpool.PoolEntry.*; + /** * * A Plugin that stores the image classes constant pool UTF_8 entries into the @@ -214,7 +216,7 @@ public class StringSharingPlugin extends AbstractPlugin implements ResourcePrevi int tag = stream.readUnsignedByte(); byte[] arr; switch (tag) { - case ClassFile.TAG_UTF8: { + case TAG_UTF8: { String original = stream.readUTF(); // 2 cases, a Descriptor or a simple String if (descriptorIndexes.contains(i)) { @@ -238,8 +240,8 @@ public class StringSharingPlugin extends AbstractPlugin implements ResourcePrevi break; } - case ClassFile.TAG_LONG: - case ClassFile.TAG_DOUBLE: + case TAG_LONG: + case TAG_DOUBLE: i++; default: { out.write(tag); diff --git a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/I18N.java b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/I18N.java index bed20ec1190..2e37a5c91af 100644 --- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/I18N.java +++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/I18N.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,36 +24,64 @@ */ package jdk.jpackage.internal; +import java.util.ArrayList; +import java.util.List; +import java.util.ListResourceBundle; +import java.util.Map; import jdk.internal.util.OperatingSystem; import java.util.ResourceBundle; +import static java.util.stream.Collectors.toMap; +import java.util.stream.Stream; class I18N { static String getString(String key) { - if (PLATFORM.containsKey(key)) { - return PLATFORM.getString(key); - } - return SHARED.getString(key); + return BUNDLE.getString(key); } - private static final ResourceBundle SHARED = ResourceBundle.getBundle( - "jdk.jpackage.internal.resources.MainResources"); + private static class MultiResourceBundle extends ListResourceBundle { - private static final ResourceBundle PLATFORM; + MultiResourceBundle(ResourceBundle... bundles) { + contents = Stream.of(bundles).map(bundle -> { + return bundle.keySet().stream().map(key -> { + return Map.entry(key, bundle.getObject(key)); + }); + }).flatMap(x -> x).collect(toMap(Map.Entry::getKey, Map.Entry::getValue, (o, n) -> { + // Override old value with the new one + return n; + })).entrySet().stream().map(e -> { + return new Object[]{e.getKey(), e.getValue()}; + }).toArray(Object[][]::new); + } + + @Override + protected Object[][] getContents() { + return contents; + } + + private final Object[][] contents; + } + + private static final MultiResourceBundle BUNDLE; static { + List bundleNames = new ArrayList<>(); + + bundleNames.add("jdk.jpackage.internal.resources.MainResources"); + if (OperatingSystem.isLinux()) { - PLATFORM = ResourceBundle.getBundle( - "jdk.jpackage.internal.resources.LinuxResources"); + bundleNames.add("jdk.jpackage.internal.resources.LinuxResources"); } else if (OperatingSystem.isWindows()) { - PLATFORM = ResourceBundle.getBundle( - "jdk.jpackage.internal.resources.WinResources"); + bundleNames.add("jdk.jpackage.internal.resources.WinResources"); + bundleNames.add("jdk.jpackage.internal.resources.WinResourcesNoL10N"); } else if (OperatingSystem.isMacOS()) { - PLATFORM = ResourceBundle.getBundle( - "jdk.jpackage.internal.resources.MacResources"); + bundleNames.add("jdk.jpackage.internal.resources.MacResources"); } else { throw new IllegalStateException("Unknown platform"); } + + BUNDLE = new MultiResourceBundle(bundleNames.stream().map(ResourceBundle::getBundle) + .toArray(ResourceBundle[]::new)); } } diff --git a/src/jdk.jpackage/share/man/jpackage.1 b/src/jdk.jpackage/share/man/jpackage.1 index 13d9c41c31d..09d340ec033 100644 --- a/src/jdk.jpackage/share/man/jpackage.1 +++ b/src/jdk.jpackage/share/man/jpackage.1 @@ -111,6 +111,16 @@ Path where generated output file is placed Defaults to the current working directory. .RE .TP +\f[V]--resource-dir\f[R] \f[I]path\f[R] +Path to override jpackage resources +.RS +.PP +(absolute path or relative to the current directory) +.PP +Icons, template files, and other resources of jpackage can be +over-ridden by adding replacement resources to this directory. +.RE +.TP \f[V]--temp\f[R] \f[I]directory\f[R] Path of a new or empty directory used to create temporary files .RS @@ -207,9 +217,9 @@ of key, value pairs .PP The keys \[dq]module\[dq], \[dq]main-jar\[dq], \[dq]main-class\[dq], \[dq]description\[dq], \[dq]arguments\[dq], \[dq]java-options\[dq], -\[dq]app-version\[dq], \[dq]icon\[dq], \[dq]launcher-as-service\[dq], -\[dq]win-console\[dq], \[dq]win-shortcut\[dq], \[dq]win-menu\[dq], -\[dq]linux-app-category\[dq], and \[dq]linux-shortcut\[dq] can be used. +\[dq]icon\[dq], \[dq]launcher-as-service\[dq], \[dq]win-console\[dq], +\[dq]win-shortcut\[dq], \[dq]win-menu\[dq], and \[dq]linux-shortcut\[dq] +can be used. .PP These options are added to, or used to overwrite, the original command line options to build an additional alternative launcher. @@ -260,7 +270,7 @@ When this option is specified, the main module will be linked in the Java runtime image. Either --module or --main-jar option can be specified but not both. .RE -.SS Platform dependent option for creating the application launcher: +.SS Platform dependent options for creating the application launcher: .SS Windows platform options (available only when running on Windows): .TP \f[V]--win-console\f[R] @@ -357,16 +367,6 @@ Path to the license file (absolute path or relative to the current directory) .RE .TP -\f[V]--resource-dir\f[R] \f[I]path\f[R] -Path to override jpackage resources -.RS -.PP -(absolute path or relative to the current directory) -.PP -Icons, template files, and other resources of jpackage can be -over-ridden by adding replacement resources to this directory. -.RE -.TP \f[V]--runtime-image\f[R] \f[I]path\f[R] Path of the predefined runtime image to install .RS diff --git a/src/jdk.jpackage/share/native/common/Log.cpp b/src/jdk.jpackage/share/native/common/Log.cpp index 66154ee8247..8227bb1cce4 100644 --- a/src/jdk.jpackage/share/native/common/Log.cpp +++ b/src/jdk.jpackage/share/native/common/Log.cpp @@ -40,10 +40,6 @@ namespace { // variables are initialized if any. This will result in AV. To avoid such // use cases keep logging module free from static variables that require // initialization with functions called by CRT. - // - - // by default log everything - const Logger::LogLevel defaultLogLevel = Logger::LOG_TRACE; char defaultLogAppenderMemory[sizeof(StreamLogAppender)] = {}; diff --git a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/WinResources.properties b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/WinResources.properties index 5843a750ade..9e7504364d3 100644 --- a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/WinResources.properties +++ b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/WinResources.properties @@ -35,7 +35,6 @@ resource.setup-icon=setup dialog icon resource.post-app-image-script=script to run after application image is populated resource.post-msi-script=script to run after msi file for exe installer is created resource.wxl-file=WiX localization file -resource.wxl-file-name=MsiInstallerStrings_en.wxl resource.main-wix-file=Main WiX project file resource.overrides-wix-file=Overrides WiX project file resource.shortcutpromptdlg-wix-file=Shortcut prompt dialog WiX project file diff --git a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/WinResourcesNoL10N.properties b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/WinResourcesNoL10N.properties new file mode 100644 index 00000000000..9bb545b942f --- /dev/null +++ b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/WinResourcesNoL10N.properties @@ -0,0 +1,28 @@ +# +# Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# 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. +# +# + + +resource.wxl-file-name=MsiInstallerStrings_en.wxl diff --git a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/WinResourcesNoL10N_de.properties b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/WinResourcesNoL10N_de.properties new file mode 100644 index 00000000000..aa3aebf8cc4 --- /dev/null +++ b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/WinResourcesNoL10N_de.properties @@ -0,0 +1,28 @@ +# +# Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# 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. +# +# + + +resource.wxl-file-name=MsiInstallerStrings_de.wxl diff --git a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/WinResourcesNoL10N_ja.properties b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/WinResourcesNoL10N_ja.properties new file mode 100644 index 00000000000..3162e29f4ca --- /dev/null +++ b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/WinResourcesNoL10N_ja.properties @@ -0,0 +1,28 @@ +# +# Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# 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. +# +# + + +resource.wxl-file-name=MsiInstallerStrings_ja.wxl diff --git a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/WinResourcesNoL10N_zh_CN.properties b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/WinResourcesNoL10N_zh_CN.properties new file mode 100644 index 00000000000..cc96dba78db --- /dev/null +++ b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/WinResourcesNoL10N_zh_CN.properties @@ -0,0 +1,28 @@ +# +# Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# 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. +# +# + + +resource.wxl-file-name=MsiInstallerStrings_zh_CN.wxl diff --git a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/WinResources_de.properties b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/WinResources_de.properties index e0c15bfb8fb..a7212d9640a 100644 --- a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/WinResources_de.properties +++ b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/WinResources_de.properties @@ -35,7 +35,6 @@ resource.setup-icon=Symbol für Dialogfeld "Setup" resource.post-app-image-script=Auszuführendes Skript nach dem Auffüllen des Anwendungsimages resource.post-msi-script=Auszuführendes Skript nach dem Erstellen der MSI-Datei für das EXE-Installationsprogramm resource.wxl-file=WiX-Lokalisierungsdatei -resource.wxl-file-name=MsiInstallerStrings_de.wxl resource.main-wix-file=Haupt-WiX-Projektdatei resource.overrides-wix-file=Überschreibt WiX-Projektdatei resource.shortcutpromptdlg-wix-file=Dialogfeld für Verknüpfungs-Prompt der WiX-Projektdatei diff --git a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/WinResources_ja.properties b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/WinResources_ja.properties index e0bcd18c811..352aab7a493 100644 --- a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/WinResources_ja.properties +++ b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/WinResources_ja.properties @@ -35,7 +35,6 @@ resource.setup-icon=設定ダイアログ・アイコン resource.post-app-image-script=アプリケーション・イメージを移入した後に実行するスクリプト resource.post-msi-script=exeインストーラのmsiファイルが作成された後に実行するスクリプト resource.wxl-file=WiXローカリゼーション・ファイル -resource.wxl-file-name=MsiInstallerStrings_ja.wxl resource.main-wix-file=メインWiXプロジェクト・ファイル resource.overrides-wix-file=WiXプロジェクト・ファイルのオーバーライド resource.shortcutpromptdlg-wix-file=ショートカット・プロンプト・ダイアログWiXプロジェクト・ファイル diff --git a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/WinResources_zh_CN.properties b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/WinResources_zh_CN.properties index e2b8bd37135..a8d4a4471d6 100644 --- a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/WinResources_zh_CN.properties +++ b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/WinResources_zh_CN.properties @@ -35,7 +35,6 @@ resource.setup-icon=设置对话框图标 resource.post-app-image-script=要在填充应用程序映像之后运行的脚本 resource.post-msi-script=在为 exe 安装程序创建 msi 文件之后要运行的脚本 resource.wxl-file=WiX 本地化文件 -resource.wxl-file-name=MsiInstallerStrings_zh_CN.wxl resource.main-wix-file=主 WiX 项目文件 resource.overrides-wix-file=覆盖 WiX 项目文件 resource.shortcutpromptdlg-wix-file=快捷方式提示对话框 WiX 项目文件 diff --git a/src/jdk.jshell/share/classes/jdk/jshell/Snippet.java b/src/jdk.jshell/share/classes/jdk/jshell/Snippet.java index b0f20a84ec6..4e72fed10fc 100644 --- a/src/jdk.jshell/share/classes/jdk/jshell/Snippet.java +++ b/src/jdk.jshell/share/classes/jdk/jshell/Snippet.java @@ -96,7 +96,7 @@ public abstract class Snippet { *

                  * A type declaration is {@linkplain Kind#isPersistent() persistent}. * - * @jls 7.6 Top Level Type Declarations + * @jls 7.6 Top Level Class and Interface Declarations */ TYPE_DECL(true), @@ -241,14 +241,14 @@ public abstract class Snippet { /** * An enum declaration. * A {@code SubKind} of {@link Kind#TYPE_DECL}. - * @jls 8.9 Enum Types + * @jls 8.9 Enum Classes */ ENUM_SUBKIND(Kind.TYPE_DECL), /** * A record declaration. * A {@code SubKind} of {@link Kind#TYPE_DECL}. - * @jls 8.10 Record Types + * @jls 8.10 Record Classes * * @since 17 */ @@ -257,7 +257,7 @@ public abstract class Snippet { /** * An annotation interface declaration. A {@code SubKind} of * {@link Kind#TYPE_DECL}. - * @jls 9.6 Annotation Types + * @jls 9.6 Annotation Interfaces */ ANNOTATION_TYPE_SUBKIND(Kind.TYPE_DECL), diff --git a/src/jdk.management/share/classes/com/sun/management/OperatingSystemMXBean.java b/src/jdk.management/share/classes/com/sun/management/OperatingSystemMXBean.java index bd9009cff15..d20d1ead35f 100644 --- a/src/jdk.management/share/classes/com/sun/management/OperatingSystemMXBean.java +++ b/src/jdk.management/share/classes/com/sun/management/OperatingSystemMXBean.java @@ -130,18 +130,27 @@ public interface OperatingSystemMXBean extends public long getTotalMemorySize(); /** - * Returns the "recent cpu usage" for the whole system. This value is a + * Returns the "recent CPU usage" for the whole system. This value is a * double in the [0.0,1.0] interval. A value of 0.0 means that all CPUs * were idle during the recent period of time observed, while a value * of 1.0 means that all CPUs were actively running 100% of the time - * during the recent period being observed. All values between 0.0 and - * 1.0 are possible depending of the activities going on in the system. - * If the system recent cpu usage is not available, the method returns a + * during the recent period being observed. + * + * The recent period of observation is implementation-specific, and + * typically relates to the duration since the last call made to this + * method, or {@link #getCpuLoad()}. For the very first invocation, the + * recent period of observation is undefined. + * + * All values between 0.0 and 1.0 are possible dependent on the activities + * going on. If the recent CPU usage is not available, the method returns a * negative value. * * @deprecated Use {@link #getCpuLoad()} instead of * this historically named method. * + * @apiNote Callers should be aware of the possibility of other callers + * affecting the observation period and the result. + * * @implSpec This implementation must return the same value * as {@link #getCpuLoad()}. * @@ -153,15 +162,24 @@ public interface OperatingSystemMXBean extends public default double getSystemCpuLoad() { return getCpuLoad(); } /** - * Returns the "recent cpu usage" for the operating environment. This value + * Returns the "recent CPU usage" for the operating environment. This value * is a double in the [0.0,1.0] interval. A value of 0.0 means that all CPUs * were idle during the recent period of time observed, while a value * of 1.0 means that all CPUs were actively running 100% of the time - * during the recent period being observed. All values between 0.0 and - * 1.0 are possible depending of the activities going on. - * If the recent cpu usage is not available, the method returns a + * during the recent period being observed. + * + * The recent period of observation is implementation-specific, and + * typically relates to the duration since the last call made to this + * method, or {@link #getSystemCpuLoad()}. For the very first invocation, + * the recent period of observation is undefined. + * + * All values between 0.0 and 1.0 are possible dependent on the activities + * going on. If the recent CPU usage is not available, the method returns a * negative value. * + * @apiNote Callers should be aware of the possibility of other callers + * affecting the observation period and the result. + * * @return the "recent cpu usage" for the whole operating environment; * a negative value if not available. * @since 14 @@ -169,16 +187,26 @@ public interface OperatingSystemMXBean extends public double getCpuLoad(); /** - * Returns the "recent cpu usage" for the Java Virtual Machine process. + * Returns the "recent CPU usage" for the Java Virtual Machine process. * This value is a double in the [0.0,1.0] interval. A value of 0.0 means * that none of the CPUs were running threads from the JVM process during * the recent period of time observed, while a value of 1.0 means that all * CPUs were actively running threads from the JVM 100% of the time * during the recent period being observed. Threads from the JVM include - * the application threads as well as the JVM internal threads. All values - * between 0.0 and 1.0 are possible depending of the activities going on - * in the JVM process and the whole system. If the Java Virtual Machine - * recent CPU usage is not available, the method returns a negative value. + * the application threads as well as the JVM internal threads. + * + * The recent period of observation is implementation-specific, and + * typically relates to the duration since the last call made to this + * method. For the very first invocation, the recent period of observation + * is undefined. + * + * All values between 0.0 and 1.0 are possible dependent on the activities + * going on in the JVM process and the whole system. If the Java Virtual + * Machine recent CPU usage is not available, the method returns a negative + * value. + * + * @apiNote Callers should be aware of the possibility of other callers + * affecting the observation period and the result. * * @return the "recent cpu usage" for the Java Virtual Machine process; * a negative value if not available. diff --git a/src/jdk.management/share/classes/com/sun/management/internal/DiagnosticCommandImpl.java b/src/jdk.management/share/classes/com/sun/management/internal/DiagnosticCommandImpl.java index be84beb03bb..eee0ea051d4 100644 --- a/src/jdk.management/share/classes/com/sun/management/internal/DiagnosticCommandImpl.java +++ b/src/jdk.management/share/classes/com/sun/management/internal/DiagnosticCommandImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -317,7 +317,7 @@ public class DiagnosticCommandImpl extends NotificationEmitterSupport for (DiagnosticCommandArgumentInfo arginfo : w.info.getArgumentsInfo()) { HashMap argmap = new HashMap<>(); argmap.put("dcmd.arg.name", arginfo.getName()); - argmap.put("dcmd.arg.type", arginfo.getType()); + argmap.put("dcmd.arg.type", sanitiseType(arginfo.getType())); argmap.put("dcmd.arg.description", arginfo.getDescription()); argmap.put("dcmd.arg.isMandatory", arginfo.isMandatory()); argmap.put("dcmd.arg.isMultiple", arginfo.isMultiple()); @@ -335,6 +335,22 @@ public class DiagnosticCommandImpl extends NotificationEmitterSupport return new ImmutableDescriptor(map); } + // Type names that will be published in dcmd.arg.type: + private static final String [] publicTypes = new String [] { "INT", "STRING", "BOOLEAN", "STRING SET", "MEMORY SIZE", "NANOTIME" }; + + private static final String sanitiseType(String typeName) { + // For any typeName not in the set to be made public, return "STRING". + if (typeName == null) { + return null; + } + for (String t : publicTypes) { + if (typeName.equals(t)) { + return t; + } + } + return "STRING"; + } + private static final String notifName = "javax.management.Notification"; diff --git a/src/jdk.management/share/classes/com/sun/management/internal/PlatformMBeanProviderImpl.java b/src/jdk.management/share/classes/com/sun/management/internal/PlatformMBeanProviderImpl.java index cdc5998426d..721f03e7de1 100644 --- a/src/jdk.management/share/classes/com/sun/management/internal/PlatformMBeanProviderImpl.java +++ b/src/jdk.management/share/classes/com/sun/management/internal/PlatformMBeanProviderImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,6 +41,7 @@ import java.util.Set; import java.util.stream.Collectors; import java.util.stream.Stream; import javax.management.DynamicMBean; +import jdk.management.VirtualThreadSchedulerMXBean; import sun.management.ManagementFactoryHelper; import sun.management.spi.PlatformMBeanProvider; @@ -163,6 +164,41 @@ public final class PlatformMBeanProviderImpl extends PlatformMBeanProvider { } }); + /** + * VirtualThreadSchedulerMXBean. + */ + initMBeanList.add(new PlatformComponent() { + private final Set> mbeanInterfaces = + Set.of(VirtualThreadSchedulerMXBean.class); + private final Set mbeanInterfaceNames = + Set.of(VirtualThreadSchedulerMXBean.class.getName()); + private VirtualThreadSchedulerMXBean impl; + + @Override + public Set> mbeanInterfaces() { + return mbeanInterfaces; + } + + @Override + public Set mbeanInterfaceNames() { + return mbeanInterfaceNames; + } + + @Override + public String getObjectNamePattern() { + return "jdk.management:type=VirtualThreadScheduler"; + } + + @Override + public Map nameToMBeanMap() { + VirtualThreadSchedulerMXBean impl = this.impl; + if (impl == null) { + this.impl = impl = VirtualThreadSchedulerImpls.create(); + } + return Map.of("jdk.management:type=VirtualThreadScheduler", impl); + } + }); + /** * OperatingSystemMXBean */ diff --git a/src/jdk.management/share/classes/com/sun/management/internal/VirtualThreadSchedulerImpls.java b/src/jdk.management/share/classes/com/sun/management/internal/VirtualThreadSchedulerImpls.java new file mode 100644 index 00000000000..8787237f903 --- /dev/null +++ b/src/jdk.management/share/classes/com/sun/management/internal/VirtualThreadSchedulerImpls.java @@ -0,0 +1,185 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ +package com.sun.management.internal; + +import java.util.concurrent.Executor; +import java.util.concurrent.ForkJoinPool; +import javax.management.ObjectName; +import jdk.management.VirtualThreadSchedulerMXBean; +import jdk.internal.access.JavaLangAccess; +import jdk.internal.access.SharedSecrets; +import jdk.internal.vm.ContinuationSupport; +import sun.management.Util; + +/** + * Provides the implementation of the management interface for the JDK's default virtual + * thread scheduler. + */ +public class VirtualThreadSchedulerImpls { + private VirtualThreadSchedulerImpls() { + } + + public static VirtualThreadSchedulerMXBean create() { + if (ContinuationSupport.isSupported()) { + return new VirtualThreadSchedulerImpl(); + } else { + return new BoundVirtualThreadSchedulerImpl(); + } + } + + /** + * Base implementation of VirtualThreadSchedulerMXBean. + */ + private abstract static class BaseVirtualThreadSchedulerImpl + implements VirtualThreadSchedulerMXBean { + + abstract void implSetParallelism(int size); + + @Override + public final void setParallelism(int size) { + Util.checkControlAccess(); + implSetParallelism(size); + } + + @Override + public final ObjectName getObjectName() { + return Util.newObjectName("jdk.management:type=VirtualThreadScheduler"); + } + + @Override + public String toString() { + var sb = new StringBuilder("[parallelism="); + sb.append(getParallelism()); + append(sb, "size", getPoolSize()); + append(sb, "mounted", getMountedVirtualThreadCount()); + append(sb, "queued", getQueuedVirtualThreadCount()); + sb.append(']'); + return sb.toString(); + } + + private void append(StringBuilder sb, String name, long value) { + sb.append(", ").append(name).append('='); + if (value >= 0) { + sb.append(value); + } else { + sb.append(""); + } + } + } + + /** + * Implementation of VirtualThreadSchedulerMXBean when virtual threads are + * implemented with continuations + scheduler. + */ + private static final class VirtualThreadSchedulerImpl extends BaseVirtualThreadSchedulerImpl { + /** + * Holder class for scheduler. + */ + private static class Scheduler { + private static final Executor scheduler = + SharedSecrets.getJavaLangAccess().virtualThreadDefaultScheduler(); + static Executor instance() { + return scheduler; + } + } + + @Override + public int getParallelism() { + if (Scheduler.instance() instanceof ForkJoinPool pool) { + return pool.getParallelism(); + } + throw new InternalError(); // should not get here + } + + @Override + void implSetParallelism(int size) { + if (Scheduler.instance() instanceof ForkJoinPool pool) { + pool.setParallelism(size); + if (pool.getPoolSize() < size) { + // FJ worker thread creation is on-demand + Thread.startVirtualThread(() -> { }); + } + + return; + } + throw new UnsupportedOperationException(); // should not get here + } + + @Override + public int getPoolSize() { + if (Scheduler.instance() instanceof ForkJoinPool pool) { + return pool.getPoolSize(); + } + return -1; // should not get here + } + + @Override + public int getMountedVirtualThreadCount() { + if (Scheduler.instance() instanceof ForkJoinPool pool) { + return pool.getActiveThreadCount(); + } + return -1; // should not get here + } + + @Override + public long getQueuedVirtualThreadCount() { + if (Scheduler.instance() instanceof ForkJoinPool pool) { + return pool.getQueuedTaskCount() + pool.getQueuedSubmissionCount(); + } + return -1L; // should not get here + } + } + + /** + * Implementation of VirtualThreadSchedulerMXBean when virtual threads are backed + * by platform threads. + */ + private static final class BoundVirtualThreadSchedulerImpl extends BaseVirtualThreadSchedulerImpl { + @Override + public int getParallelism() { + return Integer.MAX_VALUE; + } + + @Override + void implSetParallelism(int size) { + throw new UnsupportedOperationException(); + } + + @Override + public int getPoolSize() { + return -1; + } + + @Override + public int getMountedVirtualThreadCount() { + return -1; + } + + @Override + public long getQueuedVirtualThreadCount() { + return -1L; + } + } +} \ No newline at end of file diff --git a/src/jdk.management/share/classes/com/sun/management/package-info.java b/src/jdk.management/share/classes/com/sun/management/package-info.java index 0af2f33e8c7..453b4c1517f 100644 --- a/src/jdk.management/share/classes/com/sun/management/package-info.java +++ b/src/jdk.management/share/classes/com/sun/management/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,9 +24,8 @@ */ /** - * This package contains the JDK's extension to - * the standard implementation of the - * {@link java.lang.management} API and also defines the management + * This package contains JDK extensions to the standard implementation of + * the {@link java.lang.management} API and also defines the management * interface for some other components of the platform. * *

                  diff --git a/src/jdk.management/share/classes/jdk/management/VirtualThreadSchedulerMXBean.java b/src/jdk.management/share/classes/jdk/management/VirtualThreadSchedulerMXBean.java new file mode 100644 index 00000000000..556c5184ffe --- /dev/null +++ b/src/jdk.management/share/classes/jdk/management/VirtualThreadSchedulerMXBean.java @@ -0,0 +1,117 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ +package jdk.management; + +import java.lang.management.ManagementFactory; +import java.lang.management.PlatformManagedObject; +import java.util.concurrent.ForkJoinPool; +import javax.management.MBeanServer; +import javax.management.ObjectName; + +/** + * Management interface for the JDK's {@linkplain Thread##virtual-threads virtual thread} + * scheduler. + * + *

                  {@code VirtualThreadSchedulerMXBean} supports monitoring of the virtual thread + * scheduler's target parallelism, the {@linkplain Thread##platform-threads platform threads} + * used by the scheduler, and the number of virtual threads queued to the scheduler. It + * also supports dynamically changing the scheduler's target parallelism. + * + *

                  The management interface is registered with the platform {@link MBeanServer + * MBeanServer}. The {@link ObjectName ObjectName} that uniquely identifies the management + * interface within the {@code MBeanServer} is: "jdk.management:type=VirtualThreadScheduler". + * + *

                  Direct access to the MXBean interface can be obtained with + * {@link ManagementFactory#getPlatformMXBean(Class)}. + * + * @since 24 + */ +public interface VirtualThreadSchedulerMXBean extends PlatformManagedObject { + + /** + * {@return the scheduler's target parallelism} + * + * @see ForkJoinPool#getParallelism() + */ + int getParallelism(); + + /** + * Sets the scheduler's target parallelism. + * + *

                  Increasing the target parallelism allows the scheduler to use more platform + * threads to carry virtual threads if required. Decreasing the target parallelism + * reduces the number of threads that the scheduler may use to carry virtual threads. + * + * @apiNote If virtual threads are mounting and unmounting frequently then downward + * adjustment of the target parallelism will likely come into effect quickly. + * + * @implNote The JDK's virtual thread scheduler is a {@link ForkJoinPool}. Target + * parallelism defaults to the number of {@linkplain Runtime#availableProcessors() + * available processors}. The minimum target parallelism is 1, the maximum target + * parallelism is 32767. + * + * @param size the target parallelism level + * @throws IllegalArgumentException if size is less than the minimum, or + * greater than the maximum, supported by the scheduler + * @throws UnsupportedOperationException if changing the target + * parallelism is not suppored by the scheduler + * + * @see ForkJoinPool#setParallelism(int) + */ + void setParallelism(int size); + + /** + * {@return the current number of platform threads that the scheduler has started + * but have not terminated; {@code -1} if not known} + * + *

                  The count includes the platform threads that are currently carrying + * virtual threads and the platform threads that are not currently carrying virtual + * threads. The thread count may be greater than the scheduler's target parallelism. + * + * @implNote The JDK's virtual thread scheduler is a {@link ForkJoinPool}. The pool + * size is the {@linkplain ForkJoinPool#getPoolSize() number of worker threads}. + */ + int getPoolSize(); + + /** + * {@return an estimate of the number of virtual threads that are currently + * mounted by the scheduler; {@code -1} if not known} + * + *

                  The number of mounted virtual threads is equal to the number of platform + * threads carrying virtual threads. + * + * @implNote This method may overestimate the number of virtual threads that are mounted. + */ + int getMountedVirtualThreadCount(); + + /** + * {@return an estimate of the number of virtual threads that are queued to + * the scheduler to start or continue execution; {@code -1} if not known} + * + * @implNote This method may overestimate the number of virtual threads that are + * queued to execute. + */ + long getQueuedVirtualThreadCount(); +} \ No newline at end of file diff --git a/src/java.base/share/classes/sun/security/provider/SHAKE128.java b/src/jdk.management/share/classes/jdk/management/package-info.java similarity index 67% rename from src/java.base/share/classes/sun/security/provider/SHAKE128.java rename to src/jdk.management/share/classes/jdk/management/package-info.java index 0d62497b3b4..f34a8e76373 100644 --- a/src/java.base/share/classes/sun/security/provider/SHAKE128.java +++ b/src/jdk.management/share/classes/jdk/management/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,28 +22,12 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package sun.security.provider; -/* - * The SHAKE128 extendable output function. +/** + * This package contains JDK extensions to the standard implementation of the + * {@link java.lang.management} API. + * + * @since 24 */ -public final class SHAKE128 extends SHA3 { - public SHAKE128(int d) { - super("SHAKE128", d, (byte) 0x1F, 32); - } - public void update(byte in) { - engineUpdate(in); - } - public void update(byte[] in, int off, int len) { - engineUpdate(in, off, len); - } - - public byte[] digest() { - return engineDigest(); - } - - public void reset() { - engineReset(); - } -} +package jdk.management; \ No newline at end of file diff --git a/src/jdk.management/share/classes/module-info.java b/src/jdk.management/share/classes/module-info.java index 092480de9e5..4fc747f55d4 100644 --- a/src/jdk.management/share/classes/module-info.java +++ b/src/jdk.management/share/classes/module-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,9 +23,18 @@ * questions. */ +import java.lang.management.ManagementFactory; + /** * Defines JDK-specific management interfaces for the JVM. * + *

                  This module contains the JDK's extensions to the standard implementation + * of the {@link java.lang.management} API and also defines the management + * interfaces for some other components of the platform. + * + *

                  All platform MBeans are registered in the platform MBeanServer + * which can be obtained with {@link ManagementFactory#getPlatformMBeanServer}. + * * @moduleGraph * @since 9 */ @@ -33,6 +42,7 @@ module jdk.management { requires transitive java.management; exports com.sun.management; + exports jdk.management; provides sun.management.spi.PlatformMBeanProvider with com.sun.management.internal.PlatformMBeanProviderImpl; diff --git a/src/jdk.naming.dns/share/classes/com/sun/jndi/dns/DnsClient.java b/src/jdk.naming.dns/share/classes/com/sun/jndi/dns/DnsClient.java index 0d5ca39c6f7..3d55186bac8 100644 --- a/src/jdk.naming.dns/share/classes/com/sun/jndi/dns/DnsClient.java +++ b/src/jdk.naming.dns/share/classes/com/sun/jndi/dns/DnsClient.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,11 +46,15 @@ import javax.naming.NamingException; import javax.naming.OperationNotSupportedException; import javax.naming.ServiceUnavailableException; +import java.time.Duration; import java.util.Arrays; import java.util.Collections; import java.util.Map; import java.util.HashMap; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.locks.ReentrantLock; +import java.util.stream.IntStream; import jdk.internal.ref.CleanerFactory; import sun.security.jca.JCAUtil; @@ -95,7 +99,7 @@ public class DnsClient { private static final int DEFAULT_PORT = 53; private static final int TRANSACTION_ID_BOUND = 0x10000; - private static final int MIN_TIMEOUT = 50; // msec after which there are no retries. + private static final int MIN_TIMEOUT = 0; // msec after which there are no retries. private static final SecureRandom random = JCAUtil.getSecureRandom(); private InetAddress[] servers; private int[] serverPorts; @@ -223,20 +227,28 @@ public class DnsClient { Exception caughtException = null; boolean[] doNotRetry = new boolean[servers.length]; - + // Holder for unfulfilled timeouts left for each server + AtomicLong[] unfulfilledUdpTimeouts = IntStream.range(0, servers.length) + .mapToObj(_ -> new AtomicLong()) + .toArray(AtomicLong[]::new); try { // // The UDP retry strategy is to try the 1st server, and then // each server in order. If no answer, double the timeout // and try each server again. // - for (int retry = 0; retry < retries; retry++) { - + for (int retry = 0; retry <= retries; retry++) { + boolean isLastRetry = retry == retries; // Try each name server. for (int i = 0; i < servers.length; i++) { if (doNotRetry[i]) { continue; } + // unfulfilledServerTimeout is always >= 0 + AtomicLong unfulfilledServerTimeout = unfulfilledUdpTimeouts[i]; + if (isLastRetry && unfulfilledServerTimeout.get() == 0) { + continue; + } // send the request packet and wait for a response. try { @@ -245,7 +257,7 @@ public class DnsClient { } byte[] msg = doUdpQuery(pkt, servers[i], serverPorts[i], - retry, xid); + retry, xid, unfulfilledServerTimeout, isLastRetry); assert msg != null; Header hdr = new Header(msg, msg.length); @@ -259,7 +271,12 @@ public class DnsClient { // Try each server, starting with the one that just // provided the truncated message. - int retryTimeout = (timeout * (1 << retry)); + long retryTimeout = Math.clamp( + timeout * (1L << (isLastRetry + ? retry - 1 + : retry)), + 0L, Integer.MAX_VALUE); + ; for (int j = 0; j < servers.length; j++) { int ij = (i + j) % servers.length; if (doNotRetry[ij]) { @@ -301,15 +318,23 @@ public class DnsClient { if (debug) { dprint("Caught Exception:" + ex); } - if (caughtException == null) { + if (caughtException == null || servers.length == 1) { + // If there are several servers we continue trying with other + // servers, otherwise this exception will be reported caughtException = ex; + } else { + // Best reporting effort + caughtException.addSuppressed(ex); } doNotRetry[i] = true; } catch (IOException e) { if (debug) { dprint("Caught IOException:" + e); } - if (caughtException == null) { + if (caughtException instanceof CommunicationException ce) { + e.addSuppressed(ce); + caughtException = e; + } else if (caughtException == null) { caughtException = e; } } catch (ClosedSelectorException e) { @@ -327,8 +352,13 @@ public class DnsClient { caughtException = e; } } catch (NamingException e) { - if (caughtException == null) { + if (caughtException == null || servers.length == 1) { + // If there are several servers we continue trying with other + // servers, otherwise this exception will be reported caughtException = e; + } else { + // Best reporting effort + caughtException.addSuppressed(e); } doNotRetry[i] = true; } @@ -339,8 +369,8 @@ public class DnsClient { reqs.remove(xid); // cleanup } - if (caughtException instanceof NamingException) { - throw (NamingException) caughtException; + if (caughtException instanceof NamingException ne) { + throw ne; } // A network timeout or other error occurred. NamingException ne = new CommunicationException("DNS error"); @@ -424,10 +454,32 @@ public class DnsClient { * is enqueued with the corresponding xid in 'resps'. */ private byte[] doUdpQuery(Packet pkt, InetAddress server, - int port, int retry, int xid) + int port, int retry, int xid, + AtomicLong unfulfilledTimeout, + boolean unfulfilledOnly) throws IOException, NamingException { udpChannelLock.lock(); + + + // use 1L below to ensure conversion to long and avoid potential + // integer overflow (timeout is an int). + // no point in supporting timeout > Integer.MAX_VALUE, clamp if needed + // timeout remaining after successive 'blockingReceive()'. + long thisIterationTimeout = unfulfilledOnly + ? 0L + : Math.clamp(timeout * (1L << retry), 0L, Integer.MAX_VALUE); + + // Compensate with server's positive unfulfilled timeout. + // Calling method never supplies zero 'unfulfilledTimeout' when + // 'unfulfilledOnly' is 'true', therefore 'thisIterationTimeout' + // will always be a positive number, ie infinite timeout + // is not possible. + thisIterationTimeout += unfulfilledTimeout.get(); + + // Track left timeout for the current retry + long timeoutLeft = thisIterationTimeout; + long start = 0; try { try (DatagramChannel udpChannel = getDatagramChannel()) { ByteBuffer opkt = ByteBuffer.wrap(pkt.getData(), 0, pkt.length()); @@ -436,13 +488,11 @@ public class DnsClient { // Packets may only be sent to or received from this server address InetSocketAddress target = new InetSocketAddress(server, port); udpChannel.connect(target); - int pktTimeout = (timeout * (1 << retry)); udpChannel.write(opkt); - // timeout remaining after successive 'blockingReceive()' - int timeoutLeft = pktTimeout; int cnt = 0; boolean gotData = false; + start = System.nanoTime(); do { // prepare for retry if (gotData) { @@ -456,9 +506,7 @@ public class DnsClient { ") for:" + xid + " sock-timeout:" + timeoutLeft + " ms."); } - long start = System.currentTimeMillis(); - gotData = blockingReceive(udpChannel, ipkt, timeoutLeft); - long end = System.currentTimeMillis(); + gotData = blockingReceive(udpChannel, target, ipkt, timeoutLeft); assert gotData || ipkt.position() == 0; if (gotData && isMatchResponse(data, xid)) { return data; @@ -471,17 +519,23 @@ public class DnsClient { return cachedMsg; } } - timeoutLeft = pktTimeout - ((int) (end - start)); + long elapsedMillis = TimeUnit.NANOSECONDS + .toMillis(System.nanoTime() - start); + timeoutLeft = thisIterationTimeout - elapsedMillis; } while (timeoutLeft > MIN_TIMEOUT); // no matching packets received within the timeout throw new SocketTimeoutException(); } } finally { + long carryoverTimeout = thisIterationTimeout - + TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start); + unfulfilledTimeout.set(Math.max(0, carryoverTimeout)); udpChannelLock.unlock(); } } - boolean blockingReceive(DatagramChannel dc, ByteBuffer buffer, long timeout) throws IOException { + boolean blockingReceive(DatagramChannel dc, InetSocketAddress target, + ByteBuffer buffer, long timeout) throws IOException { boolean dataReceived = false; // The provided datagram channel will be used by the caller only to receive data after // it is put to non-blocking mode @@ -491,10 +545,15 @@ public class DnsClient { udpChannelSelector.select(timeout); var keys = udpChannelSelector.selectedKeys(); if (keys.contains(selectionKey) && selectionKey.isReadable()) { - dc.receive(buffer); - dataReceived = true; + int before = buffer.position(); + var senderAddress = dc.receive(buffer); + // Empty packets are ignored + dataReceived = target.equals(senderAddress) && buffer.position() > before; + } + // Avoid contention with Selector.close() if called by a clean-up thread + synchronized (keys) { + keys.clear(); } - keys.clear(); } finally { selectionKey.cancel(); // Flush the canceled key out of the selected key set @@ -750,14 +809,19 @@ class Tcp { private final Socket sock; private final java.io.InputStream in; final java.io.OutputStream out; - private int timeoutLeft; + private long timeoutLeft; - Tcp(InetAddress server, int port, int timeout) throws IOException { + Tcp(InetAddress server, int port, long timeout) throws IOException { sock = new Socket(); try { - long start = System.currentTimeMillis(); - sock.connect(new InetSocketAddress(server, port), timeout); - timeoutLeft = (int) (timeout - (System.currentTimeMillis() - start)); + long start = System.nanoTime(); + // It is safe to cast to int since the value is + // clamped by the caller + int intTimeout = (int) timeout; + sock.connect(new InetSocketAddress(server, port), intTimeout); + timeoutLeft = Duration.ofMillis(timeout) + .minus(Duration.ofNanos((System.nanoTime() - start))) + .toMillis(); if (timeoutLeft <= 0) throw new SocketTimeoutException(); @@ -785,14 +849,16 @@ class Tcp { private int readWithTimeout(SocketReadOp reader) throws IOException { if (timeoutLeft <= 0) throw new SocketTimeoutException(); - - sock.setSoTimeout(timeoutLeft); - long start = System.currentTimeMillis(); + // It is safe to cast to int since the value is clamped + int intTimeout = (int) timeoutLeft; + sock.setSoTimeout(intTimeout); + long start = System.nanoTime(); try { return reader.read(); } finally { - timeoutLeft -= (int) (System.currentTimeMillis() - start); + timeoutLeft -= TimeUnit.NANOSECONDS.toMillis( + System.nanoTime() - start); } } diff --git a/src/jdk.naming.dns/share/classes/com/sun/jndi/dns/DnsContext.java b/src/jdk.naming.dns/share/classes/com/sun/jndi/dns/DnsContext.java index 028108494af..fe35a4979cc 100644 --- a/src/jdk.naming.dns/share/classes/com/sun/jndi/dns/DnsContext.java +++ b/src/jdk.naming.dns/share/classes/com/sun/jndi/dns/DnsContext.java @@ -176,13 +176,13 @@ public class DnsContext extends ComponentDirContext { } else if (propName.equals(INIT_TIMEOUT)) { int val = Integer.parseInt((String) propVal); if (timeout != val) { - timeout = val; + timeout = Math.max(val, 0); resolver = null; } } else if (propName.equals(RETRIES)) { int val = Integer.parseInt((String) propVal); if (retries != val) { - retries = val; + retries = Math.clamp(val, 1, 30); resolver = null; } } @@ -257,11 +257,11 @@ public class DnsContext extends ComponentDirContext { val = (String) environment.get(INIT_TIMEOUT); timeout = (val == null) ? DEFAULT_INIT_TIMEOUT - : Integer.parseInt(val); + : Math.max(Integer.parseInt(val), 0); val = (String) environment.get(RETRIES); retries = (val == null) ? DEFAULT_RETRIES - : Integer.parseInt(val); + : Math.clamp(Integer.parseInt(val), 1, 30); } private CT getLookupCT(String attrId) diff --git a/src/utils/hsdis/binutils/hsdis-binutils.c b/src/utils/hsdis/binutils/hsdis-binutils.c index fda6a53a6d3..3e3362cac94 100644 --- a/src/utils/hsdis/binutils/hsdis-binutils.c +++ b/src/utils/hsdis/binutils/hsdis-binutils.c @@ -61,14 +61,10 @@ #include #include +#include #include "hsdis.h" -#ifndef bool -#define bool int -#define true 1 -#define false 0 -#endif /*bool*/ /* short names for stuff in hsdis.h */ typedef decode_instructions_event_callback_ftype event_callback_t; diff --git a/test/hotspot/gtest/gc/shared/test_oopStorage.cpp b/test/hotspot/gtest/gc/shared/test_oopStorage.cpp index a4ac2fee66b..d55d6dbfc23 100644 --- a/test/hotspot/gtest/gc/shared/test_oopStorage.cpp +++ b/test/hotspot/gtest/gc/shared/test_oopStorage.cpp @@ -93,6 +93,18 @@ public: static void block_array_set_block_count(ActiveArray* blocks, size_t count) { blocks->_block_count = count; } + + static const oop* get_block_pointer(const Block& block, unsigned index) { + return block.get_pointer(index); + } + + static Block* new_block(const OopStorage& owner) { + return Block::new_block(&owner); + } + + static void delete_block(const Block& block) { + Block::delete_block(block); + } }; typedef OopStorage::TestAccess TestAccess; @@ -518,24 +530,35 @@ TEST_VM_F(OopStorageTest, bulk_allocation) { } } -#ifndef DISABLE_GARBAGE_ALLOCATION_STATUS_TESTS -TEST_VM_F(OopStorageTest, invalid_pointer) { - { - char* mem = NEW_C_HEAP_ARRAY(char, 1000, mtInternal); - oop* ptr = reinterpret_cast(align_down(mem + 250, sizeof(oop))); - // Predicate returns false for some malloc'ed block. - EXPECT_EQ(OopStorage::INVALID_ENTRY, storage().allocation_status(ptr)); - FREE_C_HEAP_ARRAY(char, mem); - } - - { - oop obj; - oop* ptr = &obj; - // Predicate returns false for some "random" location. - EXPECT_EQ(OopStorage::INVALID_ENTRY, storage().allocation_status(ptr)); - } +TEST_VM_F(OopStorageTest, invalid_malloc_pointer) { + char* mem = NEW_C_HEAP_ARRAY(char, 1000, mtInternal); + oop* ptr = reinterpret_cast(align_down(mem + 250, sizeof(oop))); + // Predicate returns false for some malloc'ed block. + EXPECT_EQ(OopStorage::INVALID_ENTRY, storage().allocation_status(ptr)); + FREE_C_HEAP_ARRAY(char, mem); +} + +TEST_VM_F(OopStorageTest, invalid_random_pointer) { + oop obj; + oop* ptr = &obj; + // Predicate returns false for some "random" location. + EXPECT_EQ(OopStorage::INVALID_ENTRY, storage().allocation_status(ptr)); +} + +TEST_VM_F(OopStorageTest, invalid_block_pointer) { + // Allocate a block for storage, but don't insert it into the storage. This + // also tests the false positive case of block_for_ptr where we have a + // reference to storage at just the "right" place. + const OopBlock* block = TestAccess::new_block(storage()); + ASSERT_NE(block, NULL_BLOCK); + const oop* ptr = TestAccess::get_block_pointer(*block, 0); + EXPECT_EQ(OopStorage::INVALID_ENTRY, storage().allocation_status(ptr)); + TestAccess::delete_block(*block); +} + +TEST_VM_F(OopStorageTest, invalid_null_pointer) { + EXPECT_EQ(OopStorage::INVALID_ENTRY, storage().allocation_status(nullptr)); } -#endif // DISABLE_GARBAGE_ALLOCATION_STATUS_TESTS class OopStorageTest::CountingIterateClosure { public: diff --git a/test/hotspot/gtest/gc/shared/test_oopStorageSet.cpp b/test/hotspot/gtest/gc/shared/test_oopStorageSet.cpp index c8ada2574c0..947ff120d15 100644 --- a/test/hotspot/gtest/gc/shared/test_oopStorageSet.cpp +++ b/test/hotspot/gtest/gc/shared/test_oopStorageSet.cpp @@ -23,15 +23,21 @@ */ #include "precompiled.hpp" -#include "gc/shared/oopStorage.hpp" +#include "gc/shared/oopStorage.inline.hpp" #include "gc/shared/oopStorageSet.hpp" #include "memory/allocation.inline.hpp" +#include "runtime/interfaceSupport.inline.hpp" +#include "runtime/vmOperations.hpp" +#include "runtime/vmThread.hpp" #include "utilities/debug.hpp" #include "utilities/enumIterator.hpp" #include "utilities/globalDefinitions.hpp" #include "utilities/macros.hpp" #include "unittest.hpp" +using ::testing::HasSubstr; +using ::testing::Not; + class OopStorageSetTest : public ::testing::Test { protected: // Returns index of s in storages, or size if not found. @@ -83,6 +89,8 @@ protected: EnumRange(), &OopStorageSet::fill_all); } + + class VM_PrintAtSafepoint; }; TEST_VM_F(OopStorageSetTest, strong_iteration) { @@ -96,3 +104,77 @@ TEST_VM_F(OopStorageSetTest, weak_iteration) { TEST_VM_F(OopStorageSetTest, all_iteration) { test_all_iteration(); } + +class OopStorageSetTest::VM_PrintAtSafepoint : public VM_GTestExecuteAtSafepoint { +private: + class PrintContainingClosure : public Closure { + public: + void do_oop(oop* addr) { + // Direct slot hit. + { + stringStream ss; + bool printed = OopStorageSet::print_containing(addr, &ss); + ASSERT_TRUE(printed); + ASSERT_THAT(ss.freeze(), HasSubstr("is a pointer")); + ASSERT_THAT(ss.freeze(), HasSubstr("into block")); + ASSERT_THAT(ss.freeze(), HasSubstr("in oop storage")); + ASSERT_THAT(ss.freeze(), Not(HasSubstr("(unaligned)"))); + } + + // Unaligned pointer to adjacent slot, should still be in oop storage range. + { + char* unaligned_addr = (char*)addr + 1; + stringStream ss; + bool printed = OopStorageSet::print_containing(unaligned_addr, &ss); + ASSERT_TRUE(printed); + ASSERT_THAT(ss.freeze(), HasSubstr("is a pointer")); + ASSERT_THAT(ss.freeze(), HasSubstr("into block")); + ASSERT_THAT(ss.freeze(), HasSubstr("in oop storage")); + ASSERT_THAT(ss.freeze(), HasSubstr("(unaligned)")); + } + } + }; + +public: + void doit() { + PrintContainingClosure cl; + for (OopStorage* storage : OopStorageSet::Range()) { + storage->oops_do(&cl); + } + } +}; + +TEST_VM_F(OopStorageSetTest, print_containing) { + // nullptrs print nothing + { + stringStream ss; + bool printed = OopStorageSet::print_containing(nullptr, &ss); + ASSERT_FALSE(printed); + EXPECT_STREQ("", ss.freeze()); + } + + // Goofy values print nothing: unaligned out of storage pointer. + { + stringStream ss; + bool printed = OopStorageSet::print_containing((char*)0x1, &ss); + ASSERT_FALSE(printed); + EXPECT_STREQ("", ss.freeze()); + } + + // Goofy values print nothing: aligned out of storage pointer. + { + stringStream ss; + bool printed = OopStorageSet::print_containing((char*)alignof(oop), &ss); + ASSERT_FALSE(printed); + EXPECT_STREQ("", ss.freeze()); + } + + // All slot addresses should print well. + { + VM_PrintAtSafepoint op; + { + ThreadInVMfromNative invm(JavaThread::current()); + VMThread::execute(&op); + } + } +} diff --git a/test/hotspot/gtest/gc/z/test_zForwarding.cpp b/test/hotspot/gtest/gc/z/test_zForwarding.cpp index 622c6d9d8f4..ff2b3ee01e1 100644 --- a/test/hotspot/gtest/gc/z/test_zForwarding.cpp +++ b/test/hotspot/gtest/gc/z/test_zForwarding.cpp @@ -225,7 +225,7 @@ public: const ZPhysicalMemory pmem(ZPhysicalMemorySegment(zoffset(0), ZPageSizeSmall, true)); ZPage page(ZPageType::small, vmem, pmem); - page.reset(ZPageAge::eden, ZPageResetType::Allocation); + page.reset(ZPageAge::eden); const size_t object_size = 16; const zaddress object = page.alloc_object(object_size); diff --git a/test/hotspot/gtest/nmt/test_arrayWithFreeList.cpp b/test/hotspot/gtest/nmt/test_arrayWithFreeList.cpp index a2110e9e22e..e1b00850582 100644 --- a/test/hotspot/gtest/nmt/test_arrayWithFreeList.cpp +++ b/test/hotspot/gtest/nmt/test_arrayWithFreeList.cpp @@ -74,7 +74,7 @@ struct LL { // That's a very fancy word that means that a templated type like Foo can be passed around like only Foo at first // and then be 'applied' to some E. Think of it like passing around a lambda or function pointer, but on a template level, // where Foo is a function that can be called on some type with the return type being Foo. -template class Allocator> +template class Allocator> struct LL2 { struct Node; using NodeAllocator = Allocator; diff --git a/test/hotspot/gtest/nmt/test_nmt_cornercases.cpp b/test/hotspot/gtest/nmt/test_nmt_cornercases.cpp index f735022ea2b..84ed2858952 100644 --- a/test/hotspot/gtest/nmt/test_nmt_cornercases.cpp +++ b/test/hotspot/gtest/nmt/test_nmt_cornercases.cpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2022, 2023 SAP SE. All rights reserved. - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,10 +33,10 @@ #include "unittest.hpp" // Check NMT header for integrity, as well as expected type and size. -static void check_expected_malloc_header(const void* payload, MEMFLAGS type, size_t size) { +static void check_expected_malloc_header(const void* payload, MemTag mem_tag, size_t size) { const MallocHeader* hdr = MallocHeader::resolve_checked(payload); EXPECT_EQ(hdr->size(), size); - EXPECT_EQ(hdr->flags(), type); + EXPECT_EQ(hdr->mem_tag(), mem_tag); } // ASAN complains about allocating very large sizes diff --git a/test/hotspot/gtest/nmt/test_nmt_malloclimit.cpp b/test/hotspot/gtest/nmt/test_nmt_malloclimit.cpp index 7f6000b1212..c054ed0e676 100644 --- a/test/hotspot/gtest/nmt/test_nmt_malloclimit.cpp +++ b/test/hotspot/gtest/nmt/test_nmt_malloclimit.cpp @@ -42,9 +42,9 @@ static bool compare_limits(const malloclimit* a, const malloclimit* b) { static bool compare_sets(const MallocLimitSet* a, const MallocLimitSet* b) { if (compare_limits(a->global_limit(), b->global_limit())) { - for (int i = 0; i < mt_number_of_types; i++) { - if (!compare_limits(a->category_limit(NMTUtil::index_to_flag(i)), - b->category_limit(NMTUtil::index_to_flag(i)))) { + for (int i = 0; i < mt_number_of_tags; i++) { + if (!compare_limits(a->category_limit(NMTUtil::index_to_tag(i)), + b->category_limit(NMTUtil::index_to_tag(i)))) { return false; } } @@ -96,11 +96,11 @@ TEST(NMT, MallocLimitPerCategory) { TEST(NMT, MallocLimitCategoryEnumNames) { MallocLimitSet expected; stringStream option; - for (int i = 0; i < mt_number_of_types; i++) { - MEMFLAGS f = NMTUtil::index_to_flag(i); - if (f != MEMFLAGS::mtNone) { - expected.set_category_limit(f, (i + 1) * M, MallocLimitMode::trigger_fatal); - option.print("%s%s:%dM", (i > 0 ? "," : ""), NMTUtil::flag_to_enum_name(f), i + 1); + for (int i = 0; i < mt_number_of_tags; i++) { + MemTag mem_tag = NMTUtil::index_to_tag(i); + if (mem_tag != MemTag::mtNone) { + expected.set_category_limit(mem_tag, (i + 1) * M, MallocLimitMode::trigger_fatal); + option.print("%s%s:%dM", (i > 0 ? "," : ""), NMTUtil::tag_to_enum_name(mem_tag), i + 1); } } test(option.base(), expected); @@ -109,11 +109,11 @@ TEST(NMT, MallocLimitCategoryEnumNames) { TEST(NMT, MallocLimitAllCategoriesHaveHumanReadableNames) { MallocLimitSet expected; stringStream option; - for (int i = 0; i < mt_number_of_types; i++) { - MEMFLAGS f = NMTUtil::index_to_flag(i); - if (f != MEMFLAGS::mtNone) { - expected.set_category_limit(f, (i + 1) * M, MallocLimitMode::trigger_fatal); - option.print("%s%s:%dM", (i > 0 ? "," : ""), NMTUtil::flag_to_name(f), i + 1); + for (int i = 0; i < mt_number_of_tags; i++) { + MemTag mem_tag = NMTUtil::index_to_tag(i); + if (mem_tag != MemTag::mtNone) { + expected.set_category_limit(mem_tag, (i + 1) * M, MallocLimitMode::trigger_fatal); + option.print("%s%s:%dM", (i > 0 ? "," : ""), NMTUtil::tag_to_name(mem_tag), i + 1); } } test(option.base(), expected); diff --git a/test/hotspot/gtest/nmt/test_nmt_reserved_region.cpp b/test/hotspot/gtest/nmt/test_nmt_reserved_region.cpp index 0708ce5f300..b5f88990346 100644 --- a/test/hotspot/gtest/nmt/test_nmt_reserved_region.cpp +++ b/test/hotspot/gtest/nmt/test_nmt_reserved_region.cpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2023 SAP SE. All rights reserved. - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,6 +23,7 @@ */ #include "precompiled.hpp" +#include "nmt/nmtCommon.hpp" #include "nmt/memTracker.hpp" #include "nmt/virtualMemoryTracker.hpp" #include "runtime/os.hpp" @@ -33,12 +34,12 @@ TEST_VM(NMT, ReservedRegionCopy) { address dummy1 = (address)0x10000000; NativeCallStack stack1(&dummy1, 1); ReservedMemoryRegion region1(dummy1, os::vm_page_size(), stack1, mtThreadStack); - VirtualMemorySummary::record_reserved_memory(os::vm_page_size(), region1.flag()); + VirtualMemorySummary::record_reserved_memory(os::vm_page_size(), region1.mem_tag()); region1.add_committed_region(dummy1, os::vm_page_size(), stack1); address dummy2 = (address)0x20000000; NativeCallStack stack2(&dummy2, 1); ReservedMemoryRegion region2(dummy2, os::vm_page_size(), stack2, mtCode); - VirtualMemorySummary::record_reserved_memory(os::vm_page_size(), region2.flag()); + VirtualMemorySummary::record_reserved_memory(os::vm_page_size(), region2.mem_tag()); region2.add_committed_region(dummy2, os::vm_page_size(), stack2); region2 = region1; @@ -46,7 +47,7 @@ TEST_VM(NMT, ReservedRegionCopy) { CommittedRegionIterator itr = region2.iterate_committed_regions(); const CommittedMemoryRegion* rgn = itr.next(); ASSERT_EQ(rgn->base(), dummy1); // Now we should see dummy1 - ASSERT_EQ(region2.flag(), mtThreadStack); // Should be correct flag + ASSERT_EQ(region2.mem_tag(), mtThreadStack); // Should be correct memory tag ASSERT_EQ(region2.call_stack()->get_frame(0), dummy1); // Check the stack rgn = itr.next(); ASSERT_EQ(rgn, (const CommittedMemoryRegion*)nullptr); // and nothing else diff --git a/test/hotspot/gtest/nmt/test_nmt_totals.cpp b/test/hotspot/gtest/nmt/test_nmt_totals.cpp index bf2c1397e7d..01ffc7c0ce3 100644 --- a/test/hotspot/gtest/nmt/test_nmt_totals.cpp +++ b/test/hotspot/gtest/nmt/test_nmt_totals.cpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2022 SAP SE. All rights reserved. - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -89,8 +89,8 @@ TEST_VM(NMTNumbers, totals) { void* p[NUM_ALLOCS]; for (int i = 0; i < NUM_ALLOCS; i ++) { // spread over categories - int category = i % (mt_number_of_types - 1); - p[i] = NEW_C_HEAP_ARRAY(char, ALLOC_SIZE, (MEMFLAGS)category); + int category = i % (mt_number_of_tags - 1); + p[i] = NEW_C_HEAP_ARRAY(char, ALLOC_SIZE, (MemTag)category); } const totals_t t2 = get_totals(); diff --git a/test/hotspot/gtest/nmt/test_vmatree.cpp b/test/hotspot/gtest/nmt/test_vmatree.cpp index 1c1bc31b5b4..7a5a98b7863 100644 --- a/test/hotspot/gtest/nmt/test_vmatree.cpp +++ b/test/hotspot/gtest/nmt/test_vmatree.cpp @@ -24,7 +24,7 @@ #include "precompiled.hpp" #include "memory/allocation.hpp" -#include "nmt/memflags.hpp" +#include "nmt/memTag.hpp" #include "nmt/nmtNativeCallStackStorage.hpp" #include "nmt/vmatree.hpp" #include "runtime/os.hpp" @@ -171,7 +171,6 @@ public: }; - TEST_VM_F(NMTVMATreeTest, OverlappingReservationsResultInTwoNodes) { VMATree::RegionData rd{si[0], mtTest}; Tree tree; @@ -181,6 +180,23 @@ TEST_VM_F(NMTVMATreeTest, OverlappingReservationsResultInTwoNodes) { EXPECT_EQ(2, count_nodes(tree)); } +TEST_VM_F(NMTVMATreeTest, UseFlagInplace) { + Tree tree; + VMATree::RegionData rd1(si[0], mtTest); + VMATree::RegionData rd2(si[1], mtNone); + tree.reserve_mapping(0, 100, rd1); + tree.commit_mapping(20, 50, rd2, true); + tree.uncommit_mapping(30, 10, rd2); + tree.visit_in_order([&](Node* node) { + if (node->key() != 100) { + EXPECT_EQ(mtTest, node->val().out.mem_tag()) << "failed at: " << node->key(); + if (node->key() != 20 && node->key() != 40) { + EXPECT_EQ(VMATree::StateType::Reserved, node->val().out.type()); + } + } + }); +} + // Low-level tests inspecting the state of the tree. TEST_VM_F(NMTVMATreeTest, LowLevel) { adjacent_2_nodes(VMATree::empty_regiondata); @@ -214,7 +230,7 @@ TEST_VM_F(NMTVMATreeTest, LowLevel) { treap(tree).visit_in_order([&](Node* x) { EXPECT_TRUE(x->key() == 0 || x->key() == 100); if (x->key() == 0) { - EXPECT_EQ(x->val().out.regiondata().flag, mtTest); + EXPECT_EQ(x->val().out.regiondata().mem_tag, mtTest); } }); @@ -240,6 +256,7 @@ TEST_VM_F(NMTVMATreeTest, LowLevel) { EXPECT_EQ(nullptr, treap_root(tree)); } + { // A committed region inside of/replacing a reserved region // should replace the reserved region's metadata. Tree::RegionData rd{si[0], mtNMT}; @@ -249,10 +266,10 @@ TEST_VM_F(NMTVMATreeTest, LowLevel) { tree.commit_mapping(0, 100, rd2); treap(tree).visit_range_in_order(0, 99999, [&](Node* x) { if (x->key() == 0) { - EXPECT_EQ(mtTest, x->val().out.regiondata().flag); + EXPECT_EQ(mtTest, x->val().out.regiondata().mem_tag); } if (x->key() == 100) { - EXPECT_EQ(mtTest, x->val().in.regiondata().flag); + EXPECT_EQ(mtTest, x->val().in.regiondata().mem_tag); } }); } @@ -274,11 +291,11 @@ TEST_VM_F(NMTVMATreeTest, SummaryAccounting) { Tree::RegionData rd2(NCS::StackIndex(), mtNMT); Tree tree; VMATree::SummaryDiff all_diff = tree.reserve_mapping(0, 100, rd); - VMATree::SingleDiff diff = all_diff.flag[NMTUtil::flag_to_index(mtTest)]; + VMATree::SingleDiff diff = all_diff.tag[NMTUtil::tag_to_index(mtTest)]; EXPECT_EQ(100, diff.reserve); all_diff = tree.reserve_mapping(50, 25, rd2); - diff = all_diff.flag[NMTUtil::flag_to_index(mtTest)]; - VMATree::SingleDiff diff2 = all_diff.flag[NMTUtil::flag_to_index(mtNMT)]; + diff = all_diff.tag[NMTUtil::tag_to_index(mtTest)]; + VMATree::SingleDiff diff2 = all_diff.tag[NMTUtil::tag_to_index(mtNMT)]; EXPECT_EQ(-25, diff.reserve); EXPECT_EQ(25, diff2.reserve); } @@ -286,31 +303,31 @@ TEST_VM_F(NMTVMATreeTest, SummaryAccounting) { Tree::RegionData rd(NCS::StackIndex(), mtTest); Tree tree; VMATree::SummaryDiff all_diff = tree.reserve_mapping(0, 100, rd); - VMATree::SingleDiff diff = all_diff.flag[NMTUtil::flag_to_index(mtTest)]; + VMATree::SingleDiff diff = all_diff.tag[NMTUtil::tag_to_index(mtTest)]; EXPECT_EQ(100, diff.reserve); all_diff = tree.release_mapping(0, 100); - diff = all_diff.flag[NMTUtil::flag_to_index(mtTest)]; + diff = all_diff.tag[NMTUtil::tag_to_index(mtTest)]; EXPECT_EQ(-100, diff.reserve); } { // Convert some of a released mapping to a committed one Tree::RegionData rd(NCS::StackIndex(), mtTest); Tree tree; VMATree::SummaryDiff all_diff = tree.reserve_mapping(0, 100, rd); - VMATree::SingleDiff diff = all_diff.flag[NMTUtil::flag_to_index(mtTest)]; + VMATree::SingleDiff diff = all_diff.tag[NMTUtil::tag_to_index(mtTest)]; EXPECT_EQ(diff.reserve, 100); all_diff = tree.commit_mapping(0, 100, rd); - diff = all_diff.flag[NMTUtil::flag_to_index(mtTest)]; + diff = all_diff.tag[NMTUtil::tag_to_index(mtTest)]; EXPECT_EQ(0, diff.reserve); EXPECT_EQ(100, diff.commit); } - { // Adjacent reserved mappings with same flag + { // Adjacent reserved mappings with same type Tree::RegionData rd(NCS::StackIndex(), mtTest); Tree tree; VMATree::SummaryDiff all_diff = tree.reserve_mapping(0, 100, rd); - VMATree::SingleDiff diff = all_diff.flag[NMTUtil::flag_to_index(mtTest)]; + VMATree::SingleDiff diff = all_diff.tag[NMTUtil::tag_to_index(mtTest)]; EXPECT_EQ(diff.reserve, 100); all_diff = tree.reserve_mapping(100, 100, rd); - diff = all_diff.flag[NMTUtil::flag_to_index(mtTest)]; + diff = all_diff.tag[NMTUtil::tag_to_index(mtTest)]; EXPECT_EQ(100, diff.reserve); } { // Adjacent reserved mappings with different flags @@ -318,12 +335,12 @@ TEST_VM_F(NMTVMATreeTest, SummaryAccounting) { Tree::RegionData rd2(NCS::StackIndex(), mtNMT); Tree tree; VMATree::SummaryDiff all_diff = tree.reserve_mapping(0, 100, rd); - VMATree::SingleDiff diff = all_diff.flag[NMTUtil::flag_to_index(mtTest)]; + VMATree::SingleDiff diff = all_diff.tag[NMTUtil::tag_to_index(mtTest)]; EXPECT_EQ(diff.reserve, 100); all_diff = tree.reserve_mapping(100, 100, rd2); - diff = all_diff.flag[NMTUtil::flag_to_index(mtTest)]; + diff = all_diff.tag[NMTUtil::tag_to_index(mtTest)]; EXPECT_EQ(0, diff.reserve); - diff = all_diff.flag[NMTUtil::flag_to_index(mtNMT)]; + diff = all_diff.tag[NMTUtil::tag_to_index(mtNMT)]; EXPECT_EQ(100, diff.reserve); } @@ -334,27 +351,27 @@ TEST_VM_F(NMTVMATreeTest, SummaryAccounting) { tree.commit_mapping(128, 128, rd); tree.commit_mapping(512, 128, rd); VMATree::SummaryDiff diff = tree.commit_mapping(0, 1024, rd); - EXPECT_EQ(768, diff.flag[NMTUtil::flag_to_index(mtTest)].commit); - EXPECT_EQ(768, diff.flag[NMTUtil::flag_to_index(mtTest)].reserve); + EXPECT_EQ(768, diff.tag[NMTUtil::tag_to_index(mtTest)].commit); + EXPECT_EQ(768, diff.tag[NMTUtil::tag_to_index(mtTest)].reserve); } } // Exceedingly simple tracker for page-granular allocations // Use it for testing consistency with VMATree. -struct SimpleVMATracker : public CHeapObj { + struct SimpleVMATracker : public CHeapObj { const size_t page_size = 4096; - enum Type { Reserved, Committed, Free }; + enum Kind { Reserved, Committed, Free }; struct Info { - Type type; - MEMFLAGS flag; + Kind kind; + MemTag mem_tag; NativeCallStack stack; - Info() : type(Free), flag(mtNone), stack() {} + Info() : kind(Free), mem_tag(mtNone), stack() {} - Info(Type type, NativeCallStack stack, MEMFLAGS flag) - : type(type), flag(flag), stack(stack) {} + Info(Kind kind, NativeCallStack stack, MemTag mem_tag) + : kind(kind), mem_tag(mem_tag), stack(stack) {} bool eq(Info other) { - return flag == other.flag && stack.equals(other.stack); + return kind == other.kind && stack.equals(other.stack); } }; // Page (4KiB) granular array @@ -368,7 +385,7 @@ struct SimpleVMATracker : public CHeapObj { } } - VMATree::SummaryDiff do_it(Type type, size_t start, size_t size, NativeCallStack stack, MEMFLAGS flag) { + VMATree::SummaryDiff do_it(Kind kind, size_t start, size_t size, NativeCallStack stack, MemTag mem_tag) { assert(is_aligned(size, page_size) && is_aligned(start, page_size), "page alignment"); VMATree::SummaryDiff diff; @@ -377,23 +394,23 @@ struct SimpleVMATracker : public CHeapObj { const size_t end_idx = start_idx + page_count; assert(end_idx < SimpleVMATracker::num_pages, ""); - Info new_info(type, stack, flag); + Info new_info(kind, stack, mem_tag); for (size_t i = start_idx; i < end_idx; i++) { Info& old_info = pages[i]; // Register diff - if (old_info.type == Reserved) { - diff.flag[(int)old_info.flag].reserve -= page_size; - } else if (old_info.type == Committed) { - diff.flag[(int)old_info.flag].reserve -= page_size; - diff.flag[(int)old_info.flag].commit -= page_size; + if (old_info.kind == Reserved) { + diff.tag[(int)old_info.mem_tag].reserve -= page_size; + } else if (old_info.kind == Committed) { + diff.tag[(int)old_info.mem_tag].reserve -= page_size; + diff.tag[(int)old_info.mem_tag].commit -= page_size; } - if (type == Reserved) { - diff.flag[(int)new_info.flag].reserve += page_size; - } else if(type == Committed) { - diff.flag[(int)new_info.flag].reserve += page_size; - diff.flag[(int)new_info.flag].commit += page_size; + if (kind == Reserved) { + diff.tag[(int)new_info.mem_tag].reserve += page_size; + } else if (kind == Committed) { + diff.tag[(int)new_info.mem_tag].reserve += page_size; + diff.tag[(int)new_info.mem_tag].commit += page_size; } // Overwrite old one with new pages[i] = new_info; @@ -401,12 +418,12 @@ struct SimpleVMATracker : public CHeapObj { return diff; } - VMATree::SummaryDiff reserve(size_t start, size_t size, NativeCallStack stack, MEMFLAGS flag) { - return do_it(Reserved, start, size, stack, flag); + VMATree::SummaryDiff reserve(size_t start, size_t size, NativeCallStack stack, MemTag mem_tag) { + return do_it(Reserved, start, size, stack, mem_tag); } - VMATree::SummaryDiff commit(size_t start, size_t size, NativeCallStack stack, MEMFLAGS flag) { - return do_it(Committed, start, size, stack, flag); + VMATree::SummaryDiff commit(size_t start, size_t size, NativeCallStack stack, MemTag mem_tag) { + return do_it(Committed, start, size, stack, mem_tag); } VMATree::SummaryDiff release(size_t start, size_t size) { @@ -423,7 +440,7 @@ TEST_VM_F(NMTVMATreeTest, TestConsistencyWithSimpleTracker) { const size_t page_size = tr->page_size; VMATree tree; NCS ncss(true); - constexpr const int candidates_len_flags = 4; + constexpr const int candidates_len_tags = 4; constexpr const int candidates_len_stacks = 2; NativeCallStack candidate_stacks[candidates_len_stacks] = { @@ -431,7 +448,7 @@ TEST_VM_F(NMTVMATreeTest, TestConsistencyWithSimpleTracker) { make_stack(0xB), }; - const MEMFLAGS candidate_flags[candidates_len_flags] = { + const MemTag candidate_tags[candidates_len_tags] = { mtNMT, mtTest, }; @@ -455,30 +472,30 @@ TEST_VM_F(NMTVMATreeTest, TestConsistencyWithSimpleTracker) { const size_t start = page_start * page_size; const size_t size = num_pages * page_size; - const MEMFLAGS flag = candidate_flags[os::random() % candidates_len_flags]; + const MemTag mem_tag = candidate_tags[os::random() % candidates_len_tags]; const NativeCallStack stack = candidate_stacks[os::random() % candidates_len_stacks]; const NCS::StackIndex si = ncss.push(stack); - VMATree::RegionData data(si, flag); + VMATree::RegionData data(si, mem_tag); - const SimpleVMATracker::Type type = (SimpleVMATracker::Type)(os::random() % 3); + const SimpleVMATracker::Kind kind = (SimpleVMATracker::Kind)(os::random() % 3); VMATree::SummaryDiff tree_diff; VMATree::SummaryDiff simple_diff; - if (type == SimpleVMATracker::Reserved) { - simple_diff = tr->reserve(start, size, stack, flag); + if (kind == SimpleVMATracker::Reserved) { + simple_diff = tr->reserve(start, size, stack, mem_tag); tree_diff = tree.reserve_mapping(start, size, data); - } else if (type == SimpleVMATracker::Committed) { - simple_diff = tr->commit(start, size, stack, flag); + } else if (kind == SimpleVMATracker::Committed) { + simple_diff = tr->commit(start, size, stack, mem_tag); tree_diff = tree.commit_mapping(start, size, data); } else { simple_diff = tr->release(start, size); tree_diff = tree.release_mapping(start, size); } - for (int j = 0; j < mt_number_of_types; j++) { - VMATree::SingleDiff td = tree_diff.flag[j]; - VMATree::SingleDiff sd = simple_diff.flag[j]; + for (int j = 0; j < mt_number_of_tags; j++) { + VMATree::SingleDiff td = tree_diff.tag[j]; + VMATree::SingleDiff sd = simple_diff.tag[j]; ASSERT_EQ(td.reserve, sd.reserve); ASSERT_EQ(td.commit, sd.commit); } @@ -489,7 +506,7 @@ TEST_VM_F(NMTVMATreeTest, TestConsistencyWithSimpleTracker) { size_t j = 0; while (j < SimpleVMATracker::num_pages) { while (j < SimpleVMATracker::num_pages && - tr->pages[j].type == SimpleVMATracker::Free) { + tr->pages[j].kind == SimpleVMATracker::Free) { j++; } @@ -520,8 +537,8 @@ TEST_VM_F(NMTVMATreeTest, TestConsistencyWithSimpleTracker) { ASSERT_TRUE(starti.stack.equals(start_stack)); ASSERT_TRUE(endi.stack.equals(end_stack)); - ASSERT_EQ(starti.flag, startn->val().out.flag()); - ASSERT_EQ(endi.flag, endn->val().in.flag()); + ASSERT_EQ(starti.mem_tag, startn->val().out.mem_tag()); + ASSERT_EQ(endi.mem_tag, endn->val().in.mem_tag()); } } } diff --git a/test/hotspot/gtest/oops/test_compressedKlass.cpp b/test/hotspot/gtest/oops/test_compressedKlass.cpp new file mode 100644 index 00000000000..b2fc5064581 --- /dev/null +++ b/test/hotspot/gtest/oops/test_compressedKlass.cpp @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2024, Red Hat, Inc. All rights reserved. + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +#include "precompiled.hpp" +#include "oops/compressedKlass.inline.hpp" +#include "utilities/globalDefinitions.hpp" + +#include "unittest.hpp" + +TEST_VM(CompressedKlass, basics) { + if (!UseCompressedClassPointers) { + return; + } + ASSERT_LE((address)0, CompressedKlassPointers::base()); + ASSERT_LE(CompressedKlassPointers::base(), CompressedKlassPointers::klass_range_start()); + ASSERT_LT(CompressedKlassPointers::klass_range_start(), CompressedKlassPointers::klass_range_end()); + ASSERT_LE(CompressedKlassPointers::klass_range_end(), CompressedKlassPointers::encoding_range_end()); + switch (CompressedKlassPointers::shift()) { + case 0: + ASSERT_EQ(CompressedKlassPointers::encoding_range_end() - CompressedKlassPointers::base(), (ptrdiff_t)(4 * G)); + break; + case 3: + ASSERT_EQ(CompressedKlassPointers::encoding_range_end() - CompressedKlassPointers::base(), (ptrdiff_t)(32 * G)); + break; + default: + ShouldNotReachHere(); + } +} + +TEST_VM(CompressedKlass, test_too_low_address) { + if (!UseCompressedClassPointers) { + return; + } + address really_low = (address) 32; + ASSERT_FALSE(CompressedKlassPointers::is_encodable(really_low)); + address low = CompressedKlassPointers::klass_range_start() - 1; + ASSERT_FALSE(CompressedKlassPointers::is_encodable(low)); +} + +TEST_VM(CompressedKlass, test_too_high_address) { + if (!UseCompressedClassPointers) { + return; + } + address really_high = (address) UINTPTR_MAX; + ASSERT_FALSE(CompressedKlassPointers::is_encodable(really_high)); + address high = CompressedKlassPointers::klass_range_end(); + ASSERT_FALSE(CompressedKlassPointers::is_encodable(high)); +} + +TEST_VM(CompressedKlass, test_good_address) { + if (!UseCompressedClassPointers) { + return; + } + address addr = CompressedKlassPointers::klass_range_start(); + ASSERT_TRUE(CompressedKlassPointers::is_encodable(addr)); + addr = CompressedKlassPointers::klass_range_end() - 1; + ASSERT_TRUE(CompressedKlassPointers::is_encodable(addr)); +} diff --git a/test/hotspot/gtest/runtime/test_cgroupSubsystem_linux.cpp b/test/hotspot/gtest/runtime/test_cgroupSubsystem_linux.cpp index 0f054a3bd72..f2af6372aa4 100644 --- a/test/hotspot/gtest/runtime/test_cgroupSubsystem_linux.cpp +++ b/test/hotspot/gtest/runtime/test_cgroupSubsystem_linux.cpp @@ -75,7 +75,7 @@ private: char* _path; public: TestController(char* p): _path(p) {} - char* subsystem_path() override { + const char* subsystem_path() override { return _path; }; bool is_read_only() override { @@ -470,4 +470,88 @@ TEST(cgroupTest, set_cgroupv2_subsystem_path) { } } +TEST(cgroupTest, cgroupv2_is_hierarchy_walk_needed) { + bool controller_read_only = false; // value irrelevant; + CgroupV2Controller* test = new CgroupV2Controller((char*)"/sys/fs/cgroup", + (char*)"/" /* cgroup_path */, + controller_read_only); + EXPECT_FALSE(test->needs_hierarchy_adjustment()); + test = new CgroupV2Controller((char*)"/sys/fs/cgroup", + (char*)"/bar" /* cgroup_path */, + controller_read_only); + EXPECT_TRUE(test->needs_hierarchy_adjustment()); + test = new CgroupV2Controller((char*)"/sys/fs/cgroup/b", + (char*)"/a/b" /* cgroup_path */, + controller_read_only); + EXPECT_TRUE(test->needs_hierarchy_adjustment()); + + CgroupCpuController* test2 = new CgroupV2CpuController(CgroupV2Controller((char*)"/sys/fs/cgroup", + (char*)"/" /* cgroup_path */, + controller_read_only)); + EXPECT_FALSE(test2->needs_hierarchy_adjustment()); + test2 = new CgroupV2CpuController(CgroupV2Controller((char*)"/sys/fs/cgroup", + (char*)"/bar" /* cgroup_path */, + controller_read_only)); + EXPECT_TRUE(test2->needs_hierarchy_adjustment()); + test2 = new CgroupV2CpuController(CgroupV2Controller((char*)"/sys/fs/cgroup/b", + (char*)"/a/b" /* cgroup_path */, + controller_read_only)); + EXPECT_TRUE(test2->needs_hierarchy_adjustment()); + + CgroupMemoryController* test3 = new CgroupV2MemoryController(CgroupV2Controller((char*)"/sys/fs/cgroup", + (char*)"/" /* cgroup_path */, + controller_read_only)); + EXPECT_FALSE(test3->needs_hierarchy_adjustment()); + test3 = new CgroupV2MemoryController(CgroupV2Controller((char*)"/sys/fs/cgroup", + (char*)"/bar" /* cgroup_path */, + controller_read_only)); + EXPECT_TRUE(test3->needs_hierarchy_adjustment()); + test3 = new CgroupV2MemoryController(CgroupV2Controller((char*)"/sys/fs/cgroup/b", + (char*)"/a/b" /* cgroup_path */, + controller_read_only)); + EXPECT_TRUE(test3->needs_hierarchy_adjustment()); +} + +TEST(cgroupTest, cgroupv1_is_hierarchy_walk_needed) { + bool controller_read_only = true; // shouldn't matter; + CgroupV1Controller* test = new CgroupV1Controller((char*)"/a/b/c" /* root */, + (char*)"/sys/fs/cgroup/memory" /* mount_path */, + controller_read_only); + test->set_subsystem_path((char*)"/a/b/c"); + EXPECT_FALSE(test->needs_hierarchy_adjustment()); + test->set_subsystem_path((char*)"/"); + EXPECT_TRUE(test->needs_hierarchy_adjustment()); + test = new CgroupV1Controller((char*)"/a/b/c" /* root */, + (char*)"/"/* mount_path */, + controller_read_only); + test->set_subsystem_path((char*)"/"); + EXPECT_TRUE(test->needs_hierarchy_adjustment()); + + CgroupCpuController* test2 = new CgroupV1CpuController(CgroupV1Controller((char*)"/a/b/c" /* root */, + (char*)"/sys/fs/cgroup/memory" /* mount_path */, + controller_read_only)); + static_cast(test2)->set_subsystem_path((char*)"/a/b/c"); + EXPECT_FALSE(test2->needs_hierarchy_adjustment()); + static_cast(test2)->set_subsystem_path((char*)"/"); + EXPECT_TRUE(test2->needs_hierarchy_adjustment()); + test2 = new CgroupV1CpuController(CgroupV1Controller((char*)"/a/b/c" /* root */, + (char*)"/"/* mount_path */, + controller_read_only)); + static_cast(test2)->set_subsystem_path((char*)"/"); + EXPECT_TRUE(test2->needs_hierarchy_adjustment()); + + CgroupMemoryController* test3 = new CgroupV1MemoryController(CgroupV1Controller((char*)"/a/b/c" /* root */, + (char*)"/sys/fs/cgroup/memory" /* mount_path */, + controller_read_only)); + static_cast(test3)->set_subsystem_path((char*)"/a/b/c"); + EXPECT_FALSE(test3->needs_hierarchy_adjustment()); + static_cast(test3)->set_subsystem_path((char*)"/"); + EXPECT_TRUE(test3->needs_hierarchy_adjustment()); + test3 = new CgroupV1MemoryController(CgroupV1Controller((char*)"/a/b/c" /* root */, + (char*)"/"/* mount_path */, + controller_read_only)); + static_cast(test3)->set_subsystem_path((char*)"/"); + EXPECT_TRUE(test3->needs_hierarchy_adjustment()); +} + #endif // LINUX diff --git a/test/hotspot/gtest/runtime/test_os_linux.cpp b/test/hotspot/gtest/runtime/test_os_linux.cpp index 69c3d991b2a..387940afdf2 100644 --- a/test/hotspot/gtest/runtime/test_os_linux.cpp +++ b/test/hotspot/gtest/runtime/test_os_linux.cpp @@ -360,10 +360,10 @@ TEST_VM(os_linux, pretouch_thp_and_use_concurrent) { EXPECT_TRUE(os::commit_memory(heap, size, false)); { - auto pretouch = [heap, size](Thread*, int) { + auto pretouch = [heap](Thread*, int) { os::pretouch_memory(heap, heap + size, os::vm_page_size()); }; - auto useMemory = [heap, size](Thread*, int) { + auto useMemory = [heap](Thread*, int) { int* iptr = reinterpret_cast(heap); for (int i = 0; i < 1000; i++) *iptr++ = i; }; diff --git a/test/hotspot/gtest/runtime/test_os_windows.cpp b/test/hotspot/gtest/runtime/test_os_windows.cpp index d611b5287a9..c7e99bcdbc5 100644 --- a/test/hotspot/gtest/runtime/test_os_windows.cpp +++ b/test/hotspot/gtest/runtime/test_os_windows.cpp @@ -722,6 +722,114 @@ TEST_VM(os_windows, processor_count) { } } +TEST_VM(os_windows, large_page_init_multiple_sizes) { + // Call request_lock_memory_privilege() and check the result + if (!os::win32::request_lock_memory_privilege()) { + GTEST_SKIP() << "Skipping test because lock memory privilege is not granted."; + } + // Set globals to make sure we hit the correct code path + AutoSaveRestore guardUseLargePages(UseLargePages); + AutoSaveRestore guardEnableAllLargePageSizesForWindows(EnableAllLargePageSizesForWindows); + AutoSaveRestore guardLargePageSizeInBytes(LargePageSizeInBytes); + FLAG_SET_CMDLINE(UseLargePages, true); + FLAG_SET_CMDLINE(EnableAllLargePageSizesForWindows, true); + + // Determine the minimum page size + const size_t min_size = GetLargePageMinimum(); + + // End the test if GetLargePageMinimum returns 0 + if (min_size == 0) { + GTEST_SKIP() << "Large pages are not supported on this system."; + return; + } + + // Set LargePageSizeInBytes to 4 times the minimum page size + FLAG_SET_CMDLINE(LargePageSizeInBytes, 4 * min_size); // Set a value for multiple page sizes + + // Initialize large page settings + os::large_page_init(); + + // Verify that large pages are enabled + EXPECT_TRUE(UseLargePages) << "UseLargePages should be true after initialization for LargePageSizeInBytes = 4 * min_size"; + + // Verify that decided_large_page_size is greater than the default page size + const size_t default_page_size = os::vm_page_size(); + size_t decided_large_page_size = os::win32::large_page_init_decide_size(); + EXPECT_GT(decided_large_page_size, default_page_size) << "Large page size should be greater than the default page size for LargePageSizeInBytes = 4 * min_size"; + +#if !defined(IA32) + size_t page_size_count = 0; + size_t page_size = os::page_sizes().largest(); + + do { + ++page_size_count; + page_size = os::page_sizes().next_smaller(page_size); + } while (page_size >= os::page_sizes().smallest()); + + EXPECT_GT(page_size_count, 1u) << "There should be multiple large page sizes available."; + + size_t large_page_size = decided_large_page_size; + + for (size_t page_size = os::page_sizes().largest(); page_size >= min_size; page_size = os::page_sizes().next_smaller(page_size)) { + EXPECT_TRUE(page_size % min_size == 0) << "Each page size should be a multiple of the minimum large page size."; + EXPECT_LE(page_size, large_page_size) << "Page size should not exceed the determined large page size."; + } +#endif +} + +TEST_VM(os_windows, large_page_init_decide_size) { + // Initial setup + // Call request_lock_memory_privilege() and check the result + if (!os::win32::request_lock_memory_privilege()) { + GTEST_SKIP() << "Skipping test because lock memory privilege is not granted."; + } + AutoSaveRestore guardUseLargePages(UseLargePages); + AutoSaveRestore guardLargePageSizeInBytes(LargePageSizeInBytes); + FLAG_SET_CMDLINE(UseLargePages, true); + FLAG_SET_CMDLINE(LargePageSizeInBytes, 0); // Reset to default + + // Test for large page support + size_t decided_size = os::win32::large_page_init_decide_size(); + size_t min_size = GetLargePageMinimum(); + if (min_size == 0) { + EXPECT_EQ(decided_size, 0) << "Expected decided size to be 0 when large page is not supported by the processor"; + return; + } + + // Scenario 1: Test with 2MB large page size + if (min_size == 2 * M) { + FLAG_SET_CMDLINE(LargePageSizeInBytes, 2 * M); // Set large page size to 2MB + decided_size = os::win32::large_page_init_decide_size(); // Recalculate decided size + EXPECT_EQ(decided_size, 2 * M) << "Expected decided size to be 2M when large page and OS reported size are both 2M"; + } + + // Scenario 2: Test with 1MB large page size + if (min_size == 2 * M) { + FLAG_SET_CMDLINE(LargePageSizeInBytes, 1 * M); // Set large page size to 1MB + decided_size = os::win32::large_page_init_decide_size(); // Recalculate decided size + EXPECT_EQ(decided_size, 2 * M) << "Expected decided size to be 2M when large page is 1M and OS reported size is 2M"; + } + +#if defined(IA32) || defined(AMD64) + FLAG_SET_CMDLINE(LargePageSizeInBytes, 5 * M); // Set large page size to 5MB + if (!EnableAllLargePageSizesForWindows) { + decided_size = os::win32::large_page_init_decide_size(); // Recalculate decided size + EXPECT_EQ(decided_size, 0) << "Expected decided size to be 0 for large pages bigger than 4mb on IA32 or AMD64"; + } +#endif + + // Additional check for non-multiple of minimum size + // Set an arbitrary large page size which is not a multiple of min_size + FLAG_SET_CMDLINE(LargePageSizeInBytes, 5 * min_size + 1); + + // Recalculate decided size + decided_size = os::win32::large_page_init_decide_size(); + + // Assert that the decided size defaults to minimum page size when LargePageSizeInBytes + // is not a multiple of the minimum size, assuming conditions are always met + EXPECT_EQ(decided_size, 0) << "Expected decided size to default to 0 when LargePageSizeInBytes is not a multiple of minimum size"; +} + class ReserveMemorySpecialRunnable : public TestRunnable { public: void runUnitTest() const { diff --git a/test/hotspot/gtest/utilities/test_growableArray.cpp b/test/hotspot/gtest/utilities/test_growableArray.cpp index 74eb354cb2e..cc8d49cd6b5 100644 --- a/test/hotspot/gtest/utilities/test_growableArray.cpp +++ b/test/hotspot/gtest/utilities/test_growableArray.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,8 +35,8 @@ struct WithEmbeddedArray { // Arena allocated data array WithEmbeddedArray(Arena* arena, int initial_max) : _a(arena, initial_max, 0, 0) {} // CHeap allocated data array - WithEmbeddedArray(int initial_max, MEMFLAGS memflags) : _a(initial_max, memflags) { - assert(memflags != mtNone, "test requirement"); + WithEmbeddedArray(int initial_max, MemTag mem_tag) : _a(initial_max, mem_tag) { + assert(mem_tag != mtNone, "test requirement"); } WithEmbeddedArray(const GrowableArray& other) : _a(other) {} }; diff --git a/test/hotspot/gtest/utilities/test_resourceHash.cpp b/test/hotspot/gtest/utilities/test_resourceHash.cpp index 9124f4b977c..e9834ef6e2e 100644 --- a/test/hotspot/gtest/utilities/test_resourceHash.cpp +++ b/test/hotspot/gtest/utilities/test_resourceHash.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,6 +23,7 @@ #include "precompiled.hpp" #include "classfile/symbolTable.hpp" +#include "nmt/nmtCommon.hpp" #include "memory/allocation.hpp" #include "memory/resourceArea.hpp" #include "oops/symbolHandle.hpp" @@ -35,7 +36,7 @@ class CommonResourceHashtableTest : public ::testing::Test { protected: typedef void* K; typedef uintx V; - const static MEMFLAGS MEM_TYPE = mtInternal; + const static MemTag MEM_TAG = mtInternal; static unsigned identity_hash(const K& k) { return (unsigned) (uintptr_t) k; @@ -93,7 +94,7 @@ class SmallResourceHashtableTest : public CommonResourceHashtableTest { static void test(V step) { EqualityTestIter et; - ResourceHashtable rh; + ResourceHashtable rh; ASSERT_FALSE(rh.contains(as_K(step))); @@ -225,7 +226,7 @@ class GenericResourceHashtableTest : public CommonResourceHashtableTest { static void test(unsigned num_elements = SIZE) { EqualityTestIter et; - ResourceHashtable rh; + ResourceHashtable rh; for (uintptr_t i = 0; i < num_elements; ++i) { ASSERT_TRUE(rh.put(as_K(i), i)); diff --git a/test/hotspot/gtest/utilities/test_utf8.cpp b/test/hotspot/gtest/utilities/test_utf8.cpp index 80f6671207b..1636862f767 100644 --- a/test/hotspot/gtest/utilities/test_utf8.cpp +++ b/test/hotspot/gtest/utilities/test_utf8.cpp @@ -22,7 +22,7 @@ */ #include "precompiled.hpp" -#include "nmt/memflags.hpp" +#include "nmt/memTag.hpp" #include "runtime/os.hpp" #include "utilities/utf8.hpp" #include "unittest.hpp" diff --git a/test/hotspot/jtreg/ProblemList-Xcomp.txt b/test/hotspot/jtreg/ProblemList-Xcomp.txt index 8d6b74c8132..2e9b6da3828 100644 --- a/test/hotspot/jtreg/ProblemList-Xcomp.txt +++ b/test/hotspot/jtreg/ProblemList-Xcomp.txt @@ -39,9 +39,11 @@ serviceability/jvmti/vthread/SuspendWithInterruptLock/SuspendWithInterruptLock.j serviceability/sa/ClhsdbInspect.java 8283578 windows-x64 -vmTestbase/vm/mlvm/indy/func/jvmti/mergeCP_indy2manyDiff_a/TestDescription.java 8308367 windows-x64 -vmTestbase/vm/mlvm/indy/func/jvmti/mergeCP_indy2manySame_a/TestDescription.java 8308367 windows-x64 -vmTestbase/vm/mlvm/indy/func/jvmti/redefineClassInTarget/TestDescription.java 8308367 windows-x64 +vmTestbase/vm/mlvm/indy/func/jvmti/mergeCP_indy2manyDiff_a/TestDescription.java 8308367 generic-all +vmTestbase/vm/mlvm/indy/func/jvmti/mergeCP_indy2manySame_a/TestDescription.java 8308367 generic-all +vmTestbase/vm/mlvm/indy/func/jvmti/mergeCP_indy2none_b/TestDescription.java 8308367 generic-all +vmTestbase/vm/mlvm/indy/func/jvmti/mergeCP_none2indy_b/TestDescription.java 8308367 generic-all +vmTestbase/vm/mlvm/indy/func/jvmti/redefineClassInTarget/TestDescription.java 8308367 generic-all vmTestbase/nsk/jdi/StepRequest/addClassFilter_rt/filter_rt001/TestDescription.java 8043571 generic-all vmTestbase/nsk/jdi/StepRequest/addClassFilter_rt/filter_rt003/TestDescription.java 8043571 generic-all @@ -50,6 +52,10 @@ vmTestbase/nsk/jvmti/scenarios/capability/CM03/cm03t001/TestDescription.java 829 vmTestbase/nsk/stress/thread/thread006.java 8321476 linux-all +compiler/cha/TypeProfileFinalMethod.java 8341039 generic-all + gc/arguments/TestNewSizeFlags.java 8299116 macosx-aarch64 -runtime/interpreter/LastJsrTest.java 8338924 generic-all +runtime/cds/appcds/DumpRuntimeClassesTest.java 8341452 generic-all + +runtime/condy/escapeAnalysis/TestEscapeCondy.java 8339694 generic-all diff --git a/test/hotspot/jtreg/ProblemList-generational-zgc.txt b/test/hotspot/jtreg/ProblemList-generational-zgc.txt index db8182641ac..801328ec4ae 100644 --- a/test/hotspot/jtreg/ProblemList-generational-zgc.txt +++ b/test/hotspot/jtreg/ProblemList-generational-zgc.txt @@ -92,6 +92,7 @@ serviceability/sa/TestIntConstant.java 8307393 generic- serviceability/sa/TestJhsdbJstackLineNumbers.java 8307393 generic-all serviceability/sa/TestJhsdbJstackLock.java 8307393 generic-all serviceability/sa/TestJhsdbJstackMixed.java 8307393 generic-all +serviceability/sa/TestJhsdbJstackUpcall.java 8307393 generic-all serviceability/sa/TestJmapCore.java 8307393 generic-all serviceability/sa/TestJmapCoreMetaspace.java 8307393 generic-all serviceability/sa/TestObjectAlignment.java 8307393 generic-all diff --git a/test/hotspot/jtreg/ProblemList.txt b/test/hotspot/jtreg/ProblemList.txt index 1b139063b5d..3ff450dc3ad 100644 --- a/test/hotspot/jtreg/ProblemList.txt +++ b/test/hotspot/jtreg/ProblemList.txt @@ -53,7 +53,6 @@ compiler/loopopts/TestUnreachableInnerLoop.java 8288981 linux-s390x compiler/c2/Test8004741.java 8235801 generic-all compiler/c2/irTests/TestDuplicateBackedge.java 8318904 generic-all -compiler/c2/irTests/TestIfMinMax.java 8339220 linux-s390x compiler/codecache/jmx/PoolsIndependenceTest.java 8264632 macosx-all compiler/codecache/CheckLargePages.java 8332654 linux-x64 @@ -114,18 +113,15 @@ runtime/os/TestTracePageSizes.java#Parallel 8267460 linux-aarch64 runtime/os/TestTracePageSizes.java#Serial 8267460 linux-aarch64 runtime/ErrorHandling/CreateCoredumpOnCrash.java 8267433 macosx-x64 runtime/StackGuardPages/TestStackGuardPagesNative.java 8303612 linux-all -runtime/ErrorHandling/TestDwarf.java#checkDecoder 8305489 linux-all runtime/ErrorHandling/MachCodeFramesInErrorFile.java 8313315 linux-ppc64le -runtime/Thread/TestAlwaysPreTouchStacks.java 8335167 macosx-aarch64 runtime/cds/appcds/customLoader/HelloCustom_JFR.java 8241075 linux-all,windows-x64 -runtime/exceptionMsgs/NoClassDefFoundError/NoClassDefFoundErrorTest.java 8339316 generic-all - applications/jcstress/copy.java 8229852 linux-all containers/docker/TestJcmd.java 8278102 linux-all containers/docker/TestMemoryAwareness.java 8303470 linux-all containers/docker/TestJFREvents.java 8327723 linux-x64 +containers/docker/TestJcmdWithSideCar.java 8341518 linux-x64 ############################################################################# @@ -139,6 +135,8 @@ serviceability/jvmti/vthread/GetThreadStateMountedTest/GetThreadStateMountedTest serviceability/jvmti/vthread/GetSetLocalTest/GetSetLocalTest.java 8286836 generic-all serviceability/jvmti/vthread/CarrierThreadEventNotification/CarrierThreadEventNotification.java 8333681 generic-all serviceability/dcmd/gc/RunFinalizationTest.java 8227120 generic-all +serviceability/dcmd/vm/SystemDumpMapTest.java 8340401 windows-all +serviceability/dcmd/vm/SystemMapTest.java 8340401 windows-all serviceability/sa/ClhsdbCDSCore.java 8267433,8318754 macosx-x64,macosx-aarch64 serviceability/sa/ClhsdbFindPC.java#xcomp-core 8267433,8318754 macosx-x64,macosx-aarch64 @@ -175,6 +173,7 @@ vmTestbase/nsk/jvmti/scenarios/capability/CM03/cm03t001/TestDescription.java 807 vmTestbase/nsk/jvmti/InterruptThread/intrpthrd003/TestDescription.java 8288911 macosx-all vmTestbase/gc/lock/jni/jnilock002/TestDescription.java 8192647 generic-all +vmTestbase/gc/memory/Nio/Nio.java 8340728 generic-all vmTestbase/jit/escape/LockCoarsening/LockCoarsening001.java 8148743 generic-all vmTestbase/jit/escape/LockCoarsening/LockCoarsening002.java 8208259 generic-all diff --git a/test/hotspot/jtreg/TEST.ROOT b/test/hotspot/jtreg/TEST.ROOT index 5f4c52186a7..962fc36838c 100644 --- a/test/hotspot/jtreg/TEST.ROOT +++ b/test/hotspot/jtreg/TEST.ROOT @@ -81,12 +81,13 @@ requires.properties= \ vm.jvmti \ vm.graal.enabled \ jdk.hasLibgraal \ - vm.libgraal.enabled \ + vm.libgraal.jit \ vm.compiler1.enabled \ vm.compiler2.enabled \ vm.musl \ vm.flagless \ - docker.support \ + container.support \ + systemd.support \ jdk.containerized # Minimum jtreg version diff --git a/test/hotspot/jtreg/TEST.groups b/test/hotspot/jtreg/TEST.groups index 101cbe76afd..f54dc79fcfc 100644 --- a/test/hotspot/jtreg/TEST.groups +++ b/test/hotspot/jtreg/TEST.groups @@ -435,8 +435,11 @@ hotspot_cds_only = \ hotspot_appcds_dynamic = \ runtime/cds/appcds/ \ -runtime/cds/appcds/cacheObject \ + -runtime/cds/appcds/complexURI \ -runtime/cds/appcds/customLoader \ -runtime/cds/appcds/dynamicArchive \ + -runtime/cds/appcds/jigsaw/modulepath/ModulePathAndFMG.java \ + -runtime/cds/appcds/jigsaw/modulepath/OptimizeModuleHandlingTest.java \ -runtime/cds/appcds/loaderConstraints/DynamicLoaderConstraintsTest.java \ -runtime/cds/appcds/javaldr/ArrayTest.java \ -runtime/cds/appcds/javaldr/ExceptionDuringDumpAtObjectsInitPhase.java \ @@ -453,6 +456,7 @@ hotspot_appcds_dynamic = \ -runtime/cds/appcds/BadBSM.java \ -runtime/cds/appcds/DumpClassList.java \ -runtime/cds/appcds/DumpClassListWithLF.java \ + -runtime/cds/appcds/DumpRuntimeClassesTest.java \ -runtime/cds/appcds/DumpingWithNoCoops.java \ -runtime/cds/appcds/ExtraSymbols.java \ -runtime/cds/appcds/LambdaContainsOldInf.java \ diff --git a/test/hotspot/jtreg/compiler/arguments/TestStressOptions.java b/test/hotspot/jtreg/compiler/arguments/TestStressOptions.java index 544f84c9b27..ccf4822e676 100644 --- a/test/hotspot/jtreg/compiler/arguments/TestStressOptions.java +++ b/test/hotspot/jtreg/compiler/arguments/TestStressOptions.java @@ -24,7 +24,7 @@ /* * @test * @key stress randomness - * @bug 8252219 8256535 8317349 + * @bug 8252219 8256535 8317349 8319879 8335334 * @requires vm.compiler2.enabled * @summary Tests that different combinations of stress options and * -XX:StressSeed=N are accepted. @@ -48,6 +48,14 @@ * compiler.arguments.TestStressOptions * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+StressMacroExpansion -XX:StressSeed=42 * compiler.arguments.TestStressOptions + * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+StressIncrementalInlining + * compiler.arguments.TestStressOptions + * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+StressIncrementalInlining -XX:StressSeed=42 + * compiler.arguments.TestStressOptions + * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+StressUnstableIfTraps + * compiler.arguments.TestStressOptions + * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+StressUnstableIfTraps -XX:StressSeed=42 + * compiler.arguments.TestStressOptions */ package compiler.arguments; diff --git a/test/hotspot/jtreg/compiler/blackhole/BlackholeExperimentalUnlockTest.java b/test/hotspot/jtreg/compiler/blackhole/BlackholeExperimentalUnlockTest.java index 6597b2186f2..0a403a78450 100644 --- a/test/hotspot/jtreg/compiler/blackhole/BlackholeExperimentalUnlockTest.java +++ b/test/hotspot/jtreg/compiler/blackhole/BlackholeExperimentalUnlockTest.java @@ -25,6 +25,7 @@ * @test * @library /test/lib / * @requires vm.flagless + * @requires ! vm.opt.final.UnlockExperimentalVMOptions * @requires vm.compMode != "Xint" * @run driver compiler.blackhole.BlackholeExperimentalUnlockTest */ diff --git a/test/hotspot/jtreg/compiler/c2/TestCallDevirtualizationWithInfiniteLoop.java b/test/hotspot/jtreg/compiler/c2/TestCallDevirtualizationWithInfiniteLoop.java new file mode 100644 index 00000000000..1afbe8d9465 --- /dev/null +++ b/test/hotspot/jtreg/compiler/c2/TestCallDevirtualizationWithInfiniteLoop.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8336726 + * @summary Test that post-parse call devirtualization works when call does not have an IO projection. + * @run main/othervm -XX:-TieredCompilation -Xcomp -XX:CompileCommand=compileonly,TestCallDevirtualizationWithInfiniteLoop::test + * TestCallDevirtualizationWithInfiniteLoop + */ + +public class TestCallDevirtualizationWithInfiniteLoop { + + static interface I { + public void method(); + } + + static final class A implements I { + @Override + public void method() { }; + } + + static final class B implements I { + @Override + public void method() { }; + } + + static final A a = new A(); + static final B b = new B(); + + public static void test(boolean flag) { + // Avoid executing endless loop + if (flag) { + return; + } + + // We only know after loop opts that the receiver type is B. + I recv = a; + for (int i = 0; i < 3; ++i) { + if (i > 1) { + recv = b; + } + } + // Post-parse call devirtualization will then convert below + // virtual call to a static call. + recv.method(); + + // Endless loop which does not use IO. As a result the IO + // projection of the call is removed unexpectedly. + while (true) { } + } + + public static void main(String[] args) { + test(true); + } +} diff --git a/test/hotspot/jtreg/compiler/c2/TestDivModNodes.java b/test/hotspot/jtreg/compiler/c2/TestDivModNodes.java new file mode 100644 index 00000000000..be7cf0a3836 --- /dev/null +++ b/test/hotspot/jtreg/compiler/c2/TestDivModNodes.java @@ -0,0 +1,178 @@ +/* + * Copyright (c) 2024 Red Hat 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. + */ + +package compiler.c2; + +import compiler.lib.ir_framework.*; +import compiler.lib.ir_framework.Test; + +import java.util.Random; + +/* + * @test + * @bug 8332442 + * @summary Test that DIV and MOD nodes are converted into DIVMOD where possible + * @library /test/lib / + * @run driver compiler.c2.TestDivModNodes + */ +public class TestDivModNodes { + private static final Random RANDOM = AbstractInfo.getRandom(); + + private static int intQuotient; + private static int intRemainder; + private static long longQuotient; + private static long longRemainder; + + public static void main(String[] args) { + TestFramework.runWithFlags("-XX:-UseDivMod"); + TestFramework.runWithFlags("-XX:+UseDivMod"); + } + + private static int nextNonZeroInt() { + int i; + do { + i = RANDOM.nextInt(); + } while (i == 0); + return i; + } + + private static long nextNonZeroLong() { + long i; + do { + i = RANDOM.nextLong(); + } while (i == 0); + return i; + } + + @Test + @IR(applyIf = {"UseDivMod", "true"}, applyIfPlatform = {"x64", "true"}, + counts = {IRNode.DIV_MOD_I, "1"}, + failOn = {IRNode.DIV_I, IRNode.MOD_I}) + @IR(applyIf = {"UseDivMod", "true"}, applyIfPlatform = {"aarch64", "true"}, + counts = {IRNode.DIV_I, "1", IRNode.MUL_I, "1", IRNode.SUB_I, "1"}, + failOn = {IRNode.MOD_I}) + @IR(applyIf = {"UseDivMod", "false"}, + counts = {IRNode.DIV_I, "1", IRNode.MOD_I, "1"}) + private static void testSignedIntDivMod(int dividend, int divisor) { + intQuotient = dividend / divisor; + intRemainder = dividend % divisor; + } + + @Run(test = "testSignedIntDivMod") + private static void runSignedIntDivMod() { + int dividend = RANDOM.nextInt(); + int divisor = nextNonZeroInt(); + testSignedIntDivMod(dividend, divisor); + + verifyResult(dividend, divisor, + intQuotient, intRemainder, + dividend / divisor, dividend % divisor); + } + + + @Test + @IR(applyIf = {"UseDivMod", "true"}, applyIfPlatform = {"x64", "true"}, + counts = {IRNode.DIV_MOD_L, "1"}, + failOn = {IRNode.DIV_L, IRNode.MOD_L}) + @IR(applyIf = {"UseDivMod", "true"}, applyIfPlatform = {"aarch64", "true"}, + counts = {IRNode.DIV_L, "1", IRNode.MUL_L, "1", IRNode.SUB_L, "1"}, + failOn = {IRNode.MOD_L}) + @IR(applyIf = {"UseDivMod", "false"}, + counts = {IRNode.DIV_L, "1", IRNode.MOD_L, "1"}) + private static void testSignedLongDivMod(long dividend, long divisor) { + longQuotient = dividend / divisor; + longRemainder = dividend % divisor; + } + + @Run(test = "testSignedLongDivMod") + private static void runSignedLongDivMod() { + long dividend = RANDOM.nextLong(); + long divisor = nextNonZeroLong(); + testSignedLongDivMod(dividend, divisor); + + verifyResult(dividend, divisor, + longQuotient, longRemainder, + dividend / divisor, dividend % divisor); + } + + @Test + @IR(applyIf = {"UseDivMod", "true"}, applyIfPlatform = {"x64", "true"}, + counts = {IRNode.UDIV_MOD_I, "1"}, + failOn = {IRNode.UDIV_I, IRNode.UMOD_I}) + @IR(applyIf = {"UseDivMod", "true"}, applyIfPlatform = {"aarch64", "true"}, + counts = {IRNode.UDIV_I, "1", IRNode.MUL_I, "1", IRNode.SUB_I, "1"}, + failOn = {IRNode.UMOD_I}) + @IR(applyIf = {"UseDivMod", "false"}, + counts = {IRNode.UDIV_I, "1", IRNode.UMOD_I, "1"}) + private static void testUnsignedIntDivMod(int dividend, int divisor) { + intQuotient = Integer.divideUnsigned(dividend, divisor); // intrinsified on x86 + intRemainder = Integer.remainderUnsigned(dividend, divisor); // intrinsified on x86 + } + + @Run(test = "testUnsignedIntDivMod") + private static void runUnsignedIntDivMod() { + int dividend = RANDOM.nextInt(); + int divisor = nextNonZeroInt(); + testUnsignedIntDivMod(dividend, divisor); + + verifyResult(dividend, divisor, + intQuotient, intRemainder, + Integer.divideUnsigned(dividend, divisor), Integer.remainderUnsigned(dividend, divisor)); + } + + @Test + @IR(applyIf = {"UseDivMod", "true"}, applyIfPlatform = {"x64", "true"}, + counts = {IRNode.UDIV_MOD_L, "1"}, + failOn = {IRNode.UDIV_L, IRNode.UMOD_L}) + @IR(applyIf = {"UseDivMod", "true"}, applyIfPlatform = {"aarch64", "true"}, + counts = {IRNode.UDIV_L, "1", IRNode.MUL_L, "1", IRNode.SUB_L, "1"}, + failOn = {IRNode.MOD_L}) + @IR(applyIf = {"UseDivMod", "false"}, + counts = {IRNode.UDIV_L, "1", IRNode.UMOD_L, "1"}) + private static void testUnsignedLongDivMod(long dividend, long divisor) { + longQuotient = Long.divideUnsigned(dividend, divisor); // intrinsified on x86 + longRemainder = Long.remainderUnsigned(dividend, divisor); // intrinsified on x86 + } + + @Run(test = "testUnsignedLongDivMod") + private static void runUnsignedLongDivMod() { + long dividend = RANDOM.nextLong(); + long divisor = nextNonZeroLong(); + testUnsignedLongDivMod(dividend, divisor); + + verifyResult(dividend, divisor, + longQuotient, longRemainder, + Long.divideUnsigned(dividend, divisor), Long.remainderUnsigned(dividend, divisor)); + } + + private static void verifyResult(T dividend, T divisor, + T quotient, T remainder, + T expectedQ, T expectedR) { + if (!expectedQ.equals(quotient) || !expectedR.equals(remainder)) { + throw new AssertionError(String.format("Mismatched result from %d / %d. " + + "Expected: quotient = %d remainder = %d, " + + "but got: quotient = %d remainder = %d", + dividend, divisor, expectedQ, expectedR, quotient, remainder)); + } + } +} diff --git a/test/hotspot/jtreg/compiler/c2/TestSerialAdditions.java b/test/hotspot/jtreg/compiler/c2/TestSerialAdditions.java new file mode 100644 index 00000000000..c52f17dd975 --- /dev/null +++ b/test/hotspot/jtreg/compiler/c2/TestSerialAdditions.java @@ -0,0 +1,257 @@ +/* + * Copyright (c) 2024 Red Hat 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. + */ + +package compiler.c2; + +import compiler.lib.ir_framework.Test; +import compiler.lib.ir_framework.*; +import jdk.test.lib.Asserts; +import jdk.test.lib.Utils; + +import java.util.Random; + +/* + * @test + * @bug 8325495 + * @summary C2 should optimize for series of Add of unique value. e.g., a + a + ... + a => a*n + * @library /test/lib / + * @run driver compiler.c2.TestSerialAdditions + */ +public class TestSerialAdditions { + private static final Random RNG = Utils.getRandomInstance(); + + public static void main(String[] args) { + TestFramework.run(); + } + + @Run(test = { + "addTo2", + "addTo3", + "addTo4", + "shiftAndAddTo4", + "mulAndAddTo4", + "addTo5", + "addTo6", + "addTo7", + "addTo8", + "addTo16", + "addAndShiftTo16", + "addTo42", + "mulAndAddTo42", + "mulAndAddToMax", + "mulAndAddToOverflow", + "mulAndAddToZero", + "mulAndAddToMinus1", + "mulAndAddToMinus42" + }) + private void runIntTests() { + for (int a : new int[] { 0, 1, Integer.MIN_VALUE, Integer.MAX_VALUE, RNG.nextInt() }) { + Asserts.assertEQ(a * 2, addTo2(a)); + Asserts.assertEQ(a * 3, addTo3(a)); + Asserts.assertEQ(a * 4, addTo4(a)); + Asserts.assertEQ(a * 4, shiftAndAddTo4(a)); + Asserts.assertEQ(a * 4, mulAndAddTo4(a)); + Asserts.assertEQ(a * 5, addTo5(a)); + Asserts.assertEQ(a * 6, addTo6(a)); + Asserts.assertEQ(a * 7, addTo7(a)); + Asserts.assertEQ(a * 8, addTo8(a)); + Asserts.assertEQ(a * 16, addTo16(a)); + Asserts.assertEQ(a * 16, addAndShiftTo16(a)); + Asserts.assertEQ(a * 42, addTo42(a)); + Asserts.assertEQ(a * 42, mulAndAddTo42(a)); + Asserts.assertEQ(a * Integer.MAX_VALUE, mulAndAddToMax(a)); + Asserts.assertEQ(a * Integer.MIN_VALUE, mulAndAddToOverflow(a)); + Asserts.assertEQ(0, mulAndAddToZero(a)); + Asserts.assertEQ(a * -1, mulAndAddToMinus1(a)); + Asserts.assertEQ(a * -42, mulAndAddToMinus42(a)); + } + } + + @Run(test = { + "mulAndAddToIntOverflowL", + "mulAndAddToMaxL", + "mulAndAddToOverflowL" + }) + private void runLongTests() { + for (long a : new long[] { 0, 1, Long.MIN_VALUE, Long.MAX_VALUE, RNG.nextLong() }) { + Asserts.assertEQ(a * (Integer.MAX_VALUE + 1L), mulAndAddToIntOverflowL(a)); + Asserts.assertEQ(a * Long.MAX_VALUE, mulAndAddToMaxL(a)); + Asserts.assertEQ(a * Long.MIN_VALUE, mulAndAddToOverflowL(a)); + } + } + + // ----- integer tests ----- + @Test + @IR(counts = { IRNode.ADD_I, "1" }) + @IR(failOn = IRNode.LSHIFT_I) + private static int addTo2(int a) { + return a + a; // Simple additions like a + a should be kept as-is + } + + @Test + @IR(counts = { IRNode.ADD_I, "1", IRNode.LSHIFT_I, "1" }) + private static int addTo3(int a) { + return a + a + a; // a*3 => (a<<1) + a + } + + @Test + @IR(failOn = IRNode.ADD_I) + @IR(counts = { IRNode.LSHIFT_I, "1" }) + private static int addTo4(int a) { + return a + a + a + a; // a*4 => a<<2 + } + + @Test + @IR(failOn = IRNode.ADD_I) + @IR(counts = { IRNode.LSHIFT_I, "1" }) + private static int shiftAndAddTo4(int a) { + return (a << 1) + a + a; // a*2 + a + a => a*3 + a => a*4 => a<<2 + } + + @Test + @IR(failOn = IRNode.ADD_I) + @IR(counts = { IRNode.LSHIFT_I, "1" }) + private static int mulAndAddTo4(int a) { + return a * 3 + a; // a*4 => a<<2 + } + + @Test + @IR(counts = { IRNode.ADD_I, "1", IRNode.LSHIFT_I, "1" }) + private static int addTo5(int a) { + return a + a + a + a + a; // a*5 => (a<<2) + a + } + + @Test + @IR(counts = { IRNode.ADD_I, "1", IRNode.LSHIFT_I, "2" }) + private static int addTo6(int a) { + return a + a + a + a + a + a; // a*6 => (a<<1) + (a<<2) + } + + @Test + @IR(failOn = IRNode.ADD_I) + @IR(counts = { IRNode.LSHIFT_I, "1", IRNode.SUB_I, "1" }) + private static int addTo7(int a) { + return a + a + a + a + a + a + a; // a*7 => (a<<3) - a + } + + @Test + @IR(failOn = IRNode.ADD_I) + @IR(counts = { IRNode.LSHIFT_I, "1" }) + private static int addTo8(int a) { + return a + a + a + a + a + a + a + a; // a*8 => a<<3 + } + + @Test + @IR(failOn = IRNode.ADD_I) + @IR(counts = { IRNode.LSHIFT_I, "1" }) + private static int addTo16(int a) { + return a + a + a + a + a + a + a + a + a + a + + a + a + a + a + a + a; // a*16 => a<<4 + } + + @Test + @IR(failOn = IRNode.ADD_I) + @IR(counts = { IRNode.LSHIFT_I, "1" }) + private static int addAndShiftTo16(int a) { + return (a + a) << 3; // a<<(3 + 1) => a<<4 + } + + @Test + @IR(failOn = IRNode.ADD_I) + @IR(counts = { IRNode.MUL_I, "1" }) + private static int addTo42(int a) { + return a + a + a + a + a + a + a + a + a + a + + a + a + a + a + a + a + a + a + a + a + + a + a + a + a + a + a + a + a + a + a + + a + a + a + a + a + a + a + a + a + a + + a + a; // a*42 + } + + @Test + @IR(failOn = IRNode.ADD_I) + @IR(counts = { IRNode.MUL_I, "1" }) + private static int mulAndAddTo42(int a) { + return a * 40 + a + a; // a*41 + a => a*42 + } + + private static final int INT_MAX_MINUS_ONE = Integer.MAX_VALUE - 1; + + @Test + @IR(failOn = IRNode.ADD_I) + @IR(counts = { IRNode.LSHIFT_I, "1", IRNode.SUB_I, "1" }) + private static int mulAndAddToMax(int a) { + return a * INT_MAX_MINUS_ONE + a; // a*MAX => a*(MIN-1) => a*MIN - a => (a<<31) - a + } + + @Test + @IR(failOn = IRNode.ADD_I) + @IR(counts = { IRNode.LSHIFT_I, "1" }) + private static int mulAndAddToOverflow(int a) { + return a * Integer.MAX_VALUE + a; // a*(MAX+1) => a*(MIN) => a<<31 + } + + @Test + @IR(failOn = IRNode.ADD_I) + @IR(counts = { IRNode.CON_I, "1" }) + private static int mulAndAddToZero(int a) { + return a * -1 + a; // 0 + } + + @Test + @IR(failOn = IRNode.ADD_I) + @IR(counts = { IRNode.LSHIFT_I, "1", IRNode.SUB_I, "1" }) + private static int mulAndAddToMinus1(int a) { + return a * -2 + a; // a*-1 => a - (a<<1) + } + + @Test + @IR(failOn = IRNode.ADD_I) + @IR(counts = { IRNode.MUL_I, "1" }) + private static int mulAndAddToMinus42(int a) { + return a * -43 + a; // a*-42 + } + + // --- long tests --- + @Test + @IR(failOn = IRNode.ADD_L) + @IR(counts = { IRNode.LSHIFT_L, "1" }) + private static long mulAndAddToIntOverflowL(long a) { + return a * Integer.MAX_VALUE + a; // a*(INT_MAX+1) + } + + private static final long LONG_MAX_MINUS_ONE = Long.MAX_VALUE - 1; + + @Test + @IR(failOn = IRNode.ADD_L) + @IR(counts = { IRNode.LSHIFT_L, "1", IRNode.SUB_L, "1" }) + private static long mulAndAddToMaxL(long a) { + return a * LONG_MAX_MINUS_ONE + a; // a*MAX => a*(MIN-1) => a*MIN - 1 => (a<<63) - 1 + } + + @Test + @IR(failOn = IRNode.ADD_L) + @IR(counts = { IRNode.LSHIFT_L, "1" }) + private static long mulAndAddToOverflowL(long a) { + return a * Long.MAX_VALUE + a; // a*(MAX+1) => a*(MIN) => a<<63 + } +} diff --git a/test/hotspot/jtreg/compiler/c2/TestUnalignedAccess.java b/test/hotspot/jtreg/compiler/c2/TestUnalignedAccess.java index 033ea49e609..d05dbad4a73 100644 --- a/test/hotspot/jtreg/compiler/c2/TestUnalignedAccess.java +++ b/test/hotspot/jtreg/compiler/c2/TestUnalignedAccess.java @@ -46,11 +46,20 @@ public class TestUnalignedAccess { static final Unsafe UNSAFE = Unsafe.getUnsafe(); static void sink(int x) {} + public static long lseed = 1; + public static int iseed = 2; + public static short sseed = 3; + public static byte bseed = 4; + public static long lres = lseed; + public static int ires = iseed; + public static short sres = sseed; + public static byte bres = bseed; + public static class TestLong { private static final byte[] BYTES = new byte[LEN]; private static final long rawdata = 0xbeef; - private static final long lseed = 1; + private static final long data; static { sink(2); @@ -60,10 +69,13 @@ public class TestUnalignedAccess { // 1030 can't be encoded as "base + offset" mode into the instruction field. UNSAFE.putLongUnaligned(BYTES, 1030, rawdata); + lres += UNSAFE.getLongUnaligned(BYTES, 1030); // 127 can be encoded into simm9 field. - UNSAFE.putLongUnaligned(BYTES, 127, rawdata+lseed); + UNSAFE.putLongUnaligned(BYTES, 127, lres); + lres += UNSAFE.getLongUnaligned(BYTES, 127); // 1096 can be encoded into uimm12 field. - UNSAFE.putLongUnaligned(BYTES, 1096, rawdata-lseed); + UNSAFE.putLongUnaligned(BYTES, 1096, lres); + data = UNSAFE.getLongUnaligned(BYTES, 1096); } } @@ -72,7 +84,7 @@ public class TestUnalignedAccess { private static final byte[] BYTES = new byte[LEN]; private static final int rawdata = 0xbeef; - private static final int iseed = 2; + private static final int data; static { sink(2); // Signed immediate byte offset: range -256 to 255 @@ -81,10 +93,13 @@ public class TestUnalignedAccess { // 274 can't be encoded as "base + offset" mode into the instruction field. UNSAFE.putIntUnaligned(BYTES, 274, rawdata); + ires += UNSAFE.getIntUnaligned(BYTES, 274); // 255 can be encoded into simm9 field. - UNSAFE.putIntUnaligned(BYTES, 255, rawdata + iseed); + UNSAFE.putIntUnaligned(BYTES, 255, ires); + ires += UNSAFE.getIntUnaligned(BYTES, 255); // 528 can be encoded into uimm12 field. - UNSAFE.putIntUnaligned(BYTES, 528, rawdata - iseed); + UNSAFE.putIntUnaligned(BYTES, 528, ires); + data = UNSAFE.getIntUnaligned(BYTES, 528); } } @@ -93,7 +108,7 @@ public class TestUnalignedAccess { private static final byte[] BYTES = new byte[LEN]; private static final short rawdata = (short)0xbeef; - private static final short sseed = 3; + private static final short data; static { sink(2); // Signed immediate byte offset: range -256 to 255 @@ -102,10 +117,13 @@ public class TestUnalignedAccess { // 257 can't be encoded as "base + offset" mode into the instruction field. UNSAFE.putShortUnaligned(BYTES, 257, rawdata); + sres = (short) (sres + UNSAFE.getShortUnaligned(BYTES, 257)); // 253 can be encoded into simm9 field. - UNSAFE.putShortUnaligned(BYTES, 253, (short) (rawdata + sseed)); + UNSAFE.putShortUnaligned(BYTES, 253, sres); + sres = (short) (sres + UNSAFE.getShortUnaligned(BYTES, 253)); // 272 can be encoded into uimm12 field. - UNSAFE.putShortUnaligned(BYTES, 272, (short) (rawdata - sseed)); + UNSAFE.putShortUnaligned(BYTES, 272, sres); + data = UNSAFE.getShortUnaligned(BYTES, 272); } } @@ -114,7 +132,7 @@ public class TestUnalignedAccess { private static final byte[] BYTES = new byte[LEN]; private static final byte rawdata = (byte)0x3f; - private static final byte bseed = 4; + private static final byte data; static { sink(2); // Signed immediate byte offset: range -256 to 255 @@ -123,34 +141,29 @@ public class TestUnalignedAccess { // 272 can be encoded into simm9 field. UNSAFE.putByte(BYTES, 272, rawdata); + bres = (byte) (bres + UNSAFE.getByte(BYTES, 272)); // 53 can be encoded into simm9 field. - UNSAFE.putByte(BYTES, 53, (byte) (rawdata + bseed)); + UNSAFE.putByte(BYTES, 53, bres); + bres = (byte) (bres + UNSAFE.getByte(BYTES, 53)); // 1027 can be encoded into uimm12 field. - UNSAFE.putByte(BYTES, 1027, (byte) (rawdata - bseed)); + UNSAFE.putByte(BYTES, 1027, bres); + data = UNSAFE.getByte(BYTES, 1027); } } static void test() { TestLong ta = new TestLong(); - Asserts.assertEquals(UNSAFE.getLongUnaligned(ta.BYTES, 1030), ta.rawdata, "putUnaligned long failed!"); - Asserts.assertEquals(UNSAFE.getLongUnaligned(ta.BYTES, 127), ta.rawdata + ta.lseed, "putUnaligned long failed!"); - Asserts.assertEquals(UNSAFE.getLongUnaligned(ta.BYTES, 1096), ta.rawdata - ta.lseed, "putUnaligned long failed!"); + Asserts.assertEquals(ta.data, (ta.rawdata + lseed) * 2, "putUnaligned long failed!"); TestInt tb = new TestInt(); - Asserts.assertEquals(UNSAFE.getIntUnaligned(tb.BYTES, 274), tb.rawdata, "putUnaligned int failed!"); - Asserts.assertEquals(UNSAFE.getIntUnaligned(tb.BYTES, 255), tb.rawdata + tb.iseed, "putUnaligned int failed!"); - Asserts.assertEquals(UNSAFE.getIntUnaligned(tb.BYTES, 528), tb.rawdata - tb.iseed, "putUnaligned int failed!"); + Asserts.assertEquals(tb.data, (tb.rawdata + iseed) * 2, "putUnaligned int failed!"); TestShort tc = new TestShort(); - Asserts.assertEquals(UNSAFE.getShortUnaligned(tc.BYTES, 257), tc.rawdata, "putUnaligned short failed!"); - Asserts.assertEquals(UNSAFE.getShortUnaligned(tc.BYTES, 253), (short) (tc.rawdata + tc.sseed), "putUnaligned short failed!"); - Asserts.assertEquals(UNSAFE.getShortUnaligned(tc.BYTES, 272), (short) (tc.rawdata - tc.sseed), "putUnaligned short failed!"); + Asserts.assertEquals(tc.data, (short) (((short) (tc.rawdata + sseed)) * 2), "putUnaligned short failed!"); TestByte td = new TestByte(); - Asserts.assertEquals(UNSAFE.getByte(td.BYTES, 272), td.rawdata, "put byte failed!"); - Asserts.assertEquals(UNSAFE.getByte(td.BYTES, 53), (byte) (td.rawdata + td.bseed), "put byte failed!"); - Asserts.assertEquals(UNSAFE.getByte(td.BYTES, 1027), (byte) (td.rawdata - td.bseed), "put byte failed!"); + Asserts.assertEquals(td.data, (byte) (((byte) (td.rawdata + bseed)) * 2), "put byte failed!"); } public static void main(String[] strArr) { diff --git a/test/hotspot/jtreg/compiler/c2/aarch64/TestVolatiles.java b/test/hotspot/jtreg/compiler/c2/aarch64/TestVolatiles.java index 23b9321fc35..3f82c3e00b3 100644 --- a/test/hotspot/jtreg/compiler/c2/aarch64/TestVolatiles.java +++ b/test/hotspot/jtreg/compiler/c2/aarch64/TestVolatiles.java @@ -261,20 +261,11 @@ public class TestVolatiles { }; break; case "G1": - // a card mark volatile barrier should be generated - // before the card mark strb - // - // following the fix for 8225776 the G1 barrier is now - // scheduled out of line after the membar volatile and - // and subsequent return matches = new String[] { "membar_release \\(elided\\)", useCompressedOops ? "stlrw?" : "stlr", "membar_volatile \\(elided\\)", - "ret", - "membar_volatile", - "dmb ish", - "strb" + "ret" }; break; case "Shenandoah": @@ -332,20 +323,11 @@ public class TestVolatiles { }; break; case "G1": - // a card mark volatile barrier should be generated - // before the card mark strb - // - // following the fix for 8225776 the G1 barrier is now - // scheduled out of line after the membar acquire and - // and subsequent return matches = new String[] { "membar_release \\(elided\\)", useCompressedOops ? "cmpxchgw?_acq" : "cmpxchg_acq", "membar_acquire \\(elided\\)", - "ret", - "membar_volatile", - "dmb ish", - "strb" + "ret" }; break; case "Shenandoah": @@ -418,20 +400,11 @@ public class TestVolatiles { return; case "G1": - // a card mark volatile barrier should be generated - // before the card mark strb - // - // following the fix for 8225776 the G1 barrier is now - // scheduled out of line after the membar acquire and - // and subsequent return matches = new String[] { "membar_release \\(elided\\)", useCompressedOops ? "cmpxchgw?_acq" : "cmpxchg_acq", "membar_acquire \\(elided\\)", - "ret", - "membar_volatile", - "dmb ish", - "strb" + "ret" }; break; case "Shenandoah": @@ -484,20 +457,11 @@ public class TestVolatiles { }; break; case "G1": - // a card mark volatile barrier should be generated - // before the card mark strb - // - // following the fix for 8225776 the G1 barrier is now - // scheduled out of line after the membar acquire and - // and subsequent return matches = new String[] { "membar_release \\(elided\\)", useCompressedOops ? "atomic_xchgw?_acq" : "atomic_xchg_acq", "membar_acquire \\(elided\\)", - "ret", - "membar_volatile", - "dmb ish", - "strb" + "ret" }; break; case "Shenandoah": diff --git a/test/hotspot/jtreg/compiler/c2/irTests/AndINodeIdealizationTests.java b/test/hotspot/jtreg/compiler/c2/irTests/AndINodeIdealizationTests.java index f20c28e321d..1e90c22ddab 100644 --- a/test/hotspot/jtreg/compiler/c2/irTests/AndINodeIdealizationTests.java +++ b/test/hotspot/jtreg/compiler/c2/irTests/AndINodeIdealizationTests.java @@ -27,7 +27,8 @@ import compiler.lib.ir_framework.*; /* * @test - * @bug 8297384 + * @bug 8297384 8335444 + * @key randomness * @summary Test that Ideal transformations of AndINode* are being performed as expected. * @library /test/lib / * @run driver compiler.c2.irTests.AndINodeIdealizationTests @@ -38,7 +39,7 @@ public class AndINodeIdealizationTests { TestFramework.run(); } - @Run(test = { "test1", "test2" }) + @Run(test = { "test1", "test2", "test3", "test4", "test5", "test6", "test7", "test8", "test9", "test10" }) public void runMethod() { int a = RunInfo.getRandom().nextInt(); int b = RunInfo.getRandom().nextInt(); @@ -47,7 +48,12 @@ public class AndINodeIdealizationTests { int max = Integer.MAX_VALUE; assertResult(0, 0); + assertResult(10, 20); + assertResult(10, -20); + assertResult(-10, 20); + assertResult(-10, -20); assertResult(a, b); + assertResult(b, a); assertResult(min, min); assertResult(max, max); } @@ -56,6 +62,14 @@ public class AndINodeIdealizationTests { public void assertResult(int a, int b) { Asserts.assertEQ((0 - a) & 1, test1(a)); Asserts.assertEQ((~a) & (~b), test2(a, b)); + Asserts.assertEQ((a & 15) >= 0, test3(a, b)); + Asserts.assertEQ((a & 15) > 15, test4(a, b)); + Asserts.assertEQ((a & (b >>> 1)) >= 0, test5(a, b)); + Asserts.assertEQ((a & (b >>> 30)) > 3, test6(a, b)); + Asserts.assertEQ(((byte)a & -8) >= -128, test7(a, b)); + Asserts.assertEQ(((byte)a & -8) <= 127, test8(a, b)); + Asserts.assertEQ(((a & 255) & (char)b) > 255, test9(a, b)); + Asserts.assertEQ((((a & 1) - 3) & ((b & 2) - 10)) > -8, test10(a, b)); } @Test @@ -74,4 +88,60 @@ public class AndINodeIdealizationTests { public int test2(int a, int b) { return (~a) & (~b); } + + @Test + @IR(failOn = { IRNode.AND }) + // Checks a & 15 => [0, 15] + public boolean test3(int a, int b) { + return (a & 15) >= 0; + } + + @Test + @IR(failOn = { IRNode.AND }) + // Checks a & 15 => [0, 15] + public boolean test4(int a, int b) { + return (a & 15) > 15; + } + + @Test + @IR(failOn = { IRNode.AND }) + // Checks a & [0, int_max] => [0, int_max] + public boolean test5(int a, int b) { + return (a & (b >>> 1)) >= 0; + } + + @Test + @IR(failOn = { IRNode.AND }) + // Checks a & [0, 3] => [0, 3] + public boolean test6(int a, int b) { + return (a & (b >>> 30)) > 3; + } + + @Test + @IR(failOn = { IRNode.AND }) + // Checks [-128, 127] & -8 => [-128, 127] + public boolean test7(int a, int b) { + return ((byte)a & -8) >= -128; + } + + @Test + @IR(failOn = { IRNode.AND }) + // Checks [-128, 127] & -8 => [-128, 127] + public boolean test8(int a, int b) { + return ((byte)a & -8) <= 127; + } + + @Test + @IR(failOn = { IRNode.AND }) + // Checks that [0, 255] & [0, 65535] => [0, 255] + public boolean test9(int a, int b) { + return ((a & 255) & (char)b) > 255; + } + + @Test + @IR(failOn = { IRNode.AND }) + // Checks that [-3, -2] & [-10, -8] => [-16, -8] + public boolean test10(int a, int b) { + return (((a & 1) - 3) & ((b & 2) - 10)) > -8; + } } diff --git a/test/hotspot/jtreg/compiler/c2/irTests/AndLNodeIdealizationTests.java b/test/hotspot/jtreg/compiler/c2/irTests/AndLNodeIdealizationTests.java index 9aa1b62be97..a32172b2015 100644 --- a/test/hotspot/jtreg/compiler/c2/irTests/AndLNodeIdealizationTests.java +++ b/test/hotspot/jtreg/compiler/c2/irTests/AndLNodeIdealizationTests.java @@ -27,7 +27,8 @@ import compiler.lib.ir_framework.*; /* * @test - * @bug 8322589 + * @bug 8322589 8335444 + * @key randomness * @summary Test that Ideal transformations of AndLNode* are being performed as expected. * @library /test/lib / * @run driver compiler.c2.irTests.AndLNodeIdealizationTests @@ -38,7 +39,7 @@ public class AndLNodeIdealizationTests { TestFramework.run(); } - @Run(test = { "test1" }) + @Run(test = { "test1", "test2", "test3", "test4", "test5", "test6", "test7", "test8", "test9" }) public void runMethod() { long a = RunInfo.getRandom().nextLong(); long b = RunInfo.getRandom().nextLong(); @@ -47,7 +48,12 @@ public class AndLNodeIdealizationTests { long max = Long.MAX_VALUE; assertResult(0, 0); + assertResult(10, 20); + assertResult(10, -20); + assertResult(-10, 20); + assertResult(-10, -20); assertResult(a, b); + assertResult(b, a); assertResult(min, min); assertResult(max, max); } @@ -55,6 +61,14 @@ public class AndLNodeIdealizationTests { @DontCompile public void assertResult(long a, long b) { Asserts.assertEQ((~a) & (~b), test1(a, b)); + Asserts.assertEQ((a & 15) >= 0, test2(a, b)); + Asserts.assertEQ((a & 15) > 15, test3(a, b)); + Asserts.assertEQ((a & (b >>> 1)) >= 0, test4(a, b)); + Asserts.assertEQ((a & (b >>> 62)) > 3, test5(a, b)); + Asserts.assertEQ(((byte)a & -8L) >= -128, test6(a, b)); + Asserts.assertEQ(((byte)a & -8L) <= 127, test7(a, b)); + Asserts.assertEQ(((a & 255) & (char)b) > 255, test8(a, b)); + Asserts.assertEQ((((a & 1) - 3) & ((b & 2) - 10)) > -8, test9(a, b)); } @Test @@ -65,4 +79,60 @@ public class AndLNodeIdealizationTests { public long test1(long a, long b) { return (~a) & (~b); } + + @Test + @IR(failOn = { IRNode.AND }) + // Checks a & 15 => [0, 15] + public boolean test2(long a, long b) { + return (a & 15) >= 0; + } + + @Test + @IR(failOn = { IRNode.AND }) + // Checks a & 15 => [0, 15] + public boolean test3(long a, long b) { + return (a & 15) > 15; + } + + @Test + @IR(failOn = { IRNode.AND }) + // Checks a & [0, long_max] => [0, long_max] + public boolean test4(long a, long b) { + return (a & (b >>> 1)) >= 0; + } + + @Test + @IR(failOn = { IRNode.AND }) + // Checks a & [0, 3] => [0, 3] + public boolean test5(long a, long b) { + return (a & (b >>> 62)) > 3; + } + + @Test + @IR(failOn = { IRNode.AND }) + // Checks [-128, 127] & -8 => [-128, 127] + public boolean test6(long a, long b) { + return ((byte)a & -8L) >= -128; + } + + @Test + @IR(failOn = { IRNode.AND }) + // Checks [-128, 127] & -8 => [-128, 127] + public boolean test7(long a, long b) { + return ((byte)a & -8L) <= 127; + } + + @Test + @IR(failOn = { IRNode.AND }) + // Checks that [0, 255] & [0, 65535] => [0, 255] + public boolean test8(long a, long b) { + return ((a & 255) & (char)b) > 255; + } + + @Test + @IR(failOn = { IRNode.AND }) + // Checks that [-3, -2] & [-10, -8] => [-16, -8] + public boolean test9(long a, long b) { + return (((a & 1) - 3) & ((b & 2) - 10)) > -8; + } } diff --git a/test/hotspot/jtreg/compiler/c2/irTests/CMoveLConstants.java b/test/hotspot/jtreg/compiler/c2/irTests/CMoveLConstants.java new file mode 100644 index 00000000000..e62e1adc8d0 --- /dev/null +++ b/test/hotspot/jtreg/compiler/c2/irTests/CMoveLConstants.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package compiler.c2.irTests; + +import jdk.test.lib.Asserts; +import compiler.lib.ir_framework.*; + +/* + * @test + * bug 8336860 + * @summary Verify codegen for CMoveL with constants 0 and 1 + * @library /test/lib / + * @run driver compiler.c2.irTests.CMoveLConstants + */ +public class CMoveLConstants { + public static void main(String[] args) { + TestFramework.run(); + } + + @Test + @IR(applyIfPlatform = {"x64", "true"}, counts = {IRNode.X86_CMOVEL_IMM01, "1"}, phase = CompilePhase.FINAL_CODE) + public static long testSigned(int a, int b) { + return a > b ? 1L : 0L; + } + + @Test + @IR(applyIfPlatform = {"x64", "true"}, counts = {IRNode.X86_CMOVEL_IMM01U, "1"}, phase = CompilePhase.FINAL_CODE) + public static long testUnsigned(int a, int b) { + return Integer.compareUnsigned(a, b) > 0 ? 1L : 0L; + } + + @Test + @IR(applyIfPlatform = {"x64", "true"}, counts = {IRNode.X86_CMOVEL_IMM01UCF, "1"}, phase = CompilePhase.FINAL_CODE) + public static long testFloat(float a, float b) { + return a > b ? 1L : 0L; + } + + @DontCompile + public void assertResults(int a, int b) { + Asserts.assertEQ(a > b ? 1L : 0L, testSigned(a, b)); + Asserts.assertEQ(Integer.compareUnsigned(a, b) > 0 ? 1L : 0L, testUnsigned(a, b)); + Asserts.assertEQ((float) a > (float) b ? 1L : 0L, testFloat(a, b)); + } + + @Run(test = {"testSigned", "testUnsigned", "testFloat"}) + public void runMethod() { + assertResults(10, 20); + assertResults(20, 10); + } +} diff --git a/test/hotspot/jtreg/compiler/c2/irTests/TestPadding.java b/test/hotspot/jtreg/compiler/c2/irTests/TestPadding.java index 25225e86b28..17b2817a9a2 100644 --- a/test/hotspot/jtreg/compiler/c2/irTests/TestPadding.java +++ b/test/hotspot/jtreg/compiler/c2/irTests/TestPadding.java @@ -48,7 +48,7 @@ public class TestPadding { } @Test - @IR(counts = { IRNode.NOP, "1" }) + @IR(counts = { IRNode.NOP, "<=1" }) static int test(int i) { TestPadding tp = tpf; if (tp.b1 > 42) { // Big 'cmpb' instruction at offset 0x30 diff --git a/test/hotspot/jtreg/compiler/c2/irTests/TestPrunedExHandler.java b/test/hotspot/jtreg/compiler/c2/irTests/TestPrunedExHandler.java index 9b91375acb7..b5a27f3f714 100644 --- a/test/hotspot/jtreg/compiler/c2/irTests/TestPrunedExHandler.java +++ b/test/hotspot/jtreg/compiler/c2/irTests/TestPrunedExHandler.java @@ -29,6 +29,7 @@ import compiler.lib.ir_framework.*; * @test * @bug 8267532 * @summary check that uncommon trap is generated for unhandled catch block + * @requires vm.opt.StressUnstableIfTraps == null | !vm.opt.StressUnstableIfTraps * @library /test/lib / * @requires vm.opt.DeoptimizeALot != true * @run driver compiler.c2.irTests.TestPrunedExHandler diff --git a/test/hotspot/jtreg/compiler/c2/irTests/scalarReplacement/AllocationMergesTests.java b/test/hotspot/jtreg/compiler/c2/irTests/scalarReplacement/AllocationMergesTests.java index cd3d5329771..69b3cb5274b 100644 --- a/test/hotspot/jtreg/compiler/c2/irTests/scalarReplacement/AllocationMergesTests.java +++ b/test/hotspot/jtreg/compiler/c2/irTests/scalarReplacement/AllocationMergesTests.java @@ -1355,9 +1355,12 @@ public class AllocationMergesTests { } @Test - @IR(counts = { IRNode.ALLOC, "1" }) - // The last allocation won't be reduced because it would cause the creation - // of a nested SafePointScalarMergeNode. + // Using G1, all allocations are reduced. + @IR(applyIf = {"UseG1GC", "true"}, failOn = { IRNode.ALLOC }) + // Otherwise, the last allocation won't be reduced because it would cause + // the creation of a nested SafePointScalarMergeNode. This is caused by the + // store barrier corresponding to 'C.other = B'. + @IR(applyIf = {"UseG1GC", "false"}, counts = { IRNode.ALLOC, "1" }) int testReReduce_C2(boolean cond1, int x, int y) { return testReReduce(cond1, x, y); } @DontCompile diff --git a/test/hotspot/jtreg/compiler/calls/TestManyArgs.java b/test/hotspot/jtreg/compiler/calls/TestManyArgs.java new file mode 100644 index 00000000000..fbd9c13d7c9 --- /dev/null +++ b/test/hotspot/jtreg/compiler/calls/TestManyArgs.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, Rivos 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 + * @summary Pass values on stack. + * @requires os.arch == "riscv64" + * @run main/native compiler.calls.TestManyArgs + */ + +package compiler.calls; + +public class TestManyArgs { + static { + System.loadLibrary("TestManyArgs"); + } + + native static void scramblestack(); + + native static int checkargs(int arg0, short arg1, byte arg2, + int arg3, short arg4, byte arg5, + int arg6, short arg7, byte arg8, + int arg9, short arg10, byte arg11); + + static int compiledbridge(int arg0, short arg1, byte arg2, + int arg3, short arg4, byte arg5, + int arg6, short arg7, byte arg8, + int arg9, short arg10, byte arg11) { + return checkargs(arg0, arg1, arg2, arg3, arg4, arg5, + arg6, arg7, arg8, arg9, arg10, arg11); + } + + static public void main(String[] args) { + scramblestack(); + for (int i = 0; i < 20000; i++) { + int res = compiledbridge((int)0xf, (short)0xf, (byte)0xf, + (int)0xf, (short)0xf, (byte)0xf, + (int)0xf, (short)0xf, (byte)0xf, + (int)0xf, (short)0xf, (byte)0xf); + if (res != 0) { + throw new RuntimeException("Test failed"); + } + } + } +} diff --git a/test/hotspot/jtreg/compiler/calls/libTestManyArgs.c b/test/hotspot/jtreg/compiler/calls/libTestManyArgs.c new file mode 100644 index 00000000000..8836c79e43e --- /dev/null +++ b/test/hotspot/jtreg/compiler/calls/libTestManyArgs.c @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, Rivos 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. + */ + +#include "jni.h" + +#ifdef riscv64 +/* RV64 ABI pass all integers as 64-bit, in registers or on stack + * As compiler may choose to load smaller width than 64-bit if passed on stack, + * this test may not find any bugs. + * Therefore we trick the compiler todo 64-bit loads, + * by saying these args are jlongs. + */ +JNIEXPORT jint JNICALL Java_compiler_calls_TestManyArgs_checkargs(JNIEnv* env, jclass jclazz, + jlong arg0, jlong arg1, jlong arg2, + jlong arg3, jlong arg4, jlong arg5, + jlong arg6, jlong arg7, jlong arg8, + jlong arg9, jlong arg10, jlong arg11) +#else +JNIEXPORT jint JNICALL Java_compiler_calls_TestManyArgs_checkargs(JNIEnv* env, jclass jclazz, + jint arg0, jshort arg1, jbyte arg2, + jint arg3, jshort arg4, jbyte arg5, + jint arg6, jshort arg7, jbyte arg8, + jint arg9, jshort arg10, jbyte arg11) +#endif +{ + if (arg0 != 0xf) return 1; + if (arg1 != 0xf) return 1; + if (arg2 != 0xf) return 1; + if (arg3 != 0xf) return 1; + if (arg4 != 0xf) return 1; + if (arg5 != 0xf) return 1; + if (arg6 != 0xf) return 1; + if (arg7 != 0xf) return 1; + if (arg8 != 0xf) return 1; + if (arg9 != 0xf) return 1; + if (arg10 != 0xf) return 1; + if (arg11 != 0xf) return 1; + return 0; +} + +JNIEXPORT +void JNICALL Java_compiler_calls_TestManyArgs_scramblestack(JNIEnv* env, jclass jclazz) +{ + volatile char stack[12*8]; + for (unsigned int i = 0; i < sizeof(stack); i++) { + stack[i] = (char)0xff; + } +} diff --git a/test/hotspot/jtreg/compiler/cha/StrengthReduceInterfaceCall.java b/test/hotspot/jtreg/compiler/cha/StrengthReduceInterfaceCall.java index 068da4100bd..87ce9a313a8 100644 --- a/test/hotspot/jtreg/compiler/cha/StrengthReduceInterfaceCall.java +++ b/test/hotspot/jtreg/compiler/cha/StrengthReduceInterfaceCall.java @@ -24,6 +24,7 @@ /* * @test * @requires !vm.graal.enabled + * @requires vm.opt.StressUnstableIfTraps == null | !vm.opt.StressUnstableIfTraps * @modules java.base/jdk.internal.org.objectweb.asm * java.base/jdk.internal.misc * java.base/jdk.internal.vm.annotation diff --git a/test/hotspot/jtreg/compiler/cha/TypeProfileFinalMethod.java b/test/hotspot/jtreg/compiler/cha/TypeProfileFinalMethod.java new file mode 100644 index 00000000000..a81ba53af52 --- /dev/null +++ b/test/hotspot/jtreg/compiler/cha/TypeProfileFinalMethod.java @@ -0,0 +1,147 @@ +/* + * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, Alibaba Group Holding Limited. 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 + * @summary test c1 to record type profile with CHA optimization + * @requires vm.flavor == "server" & (vm.opt.TieredStopAtLevel == null | vm.opt.TieredStopAtLevel == 4) + * @library /test/lib + * @build jdk.test.whitebox.WhiteBox + * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox + * @run driver compiler.cha.TypeProfileFinalMethod + */ +package compiler.cha; + +import java.io.File; +import java.util.regex.Pattern; +import java.util.regex.Matcher; +import jdk.test.lib.Asserts; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; +import jdk.test.whitebox.WhiteBox; + +public class TypeProfileFinalMethod { + public static void main(String[] args) throws Exception { + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder( + "-Xbootclasspath/a:.", + "-Xbatch", "-XX:-UseOnStackReplacement", + "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", + "-XX:Tier3InvocationThreshold=200", "-XX:Tier4InvocationThreshold=5000", + Launcher.class.getName()); + OutputAnalyzer output = ProcessTools.executeProcess(pb); + System.out.println("debug output"); + System.out.println(output.getOutput()); + System.out.println("debug output end"); + output.shouldHaveExitValue(0); + output.shouldNotContain("failed to inline: virtual call"); + Pattern pattern = Pattern.compile("Child1::m.* inline "); + Matcher matcher = pattern.matcher(output.getOutput()); + int matchCnt = 0; + while (matcher.find()) { + matchCnt++; + } + Asserts.assertEquals(matchCnt, 2); // inline Child1::m() twice + } + + static class Launcher { + public static void main(String[] args) throws Exception { + addCompilerDirectives(); + int cnt = 5300; + // warmup test1 to be compiled with c1 and c2 + // and only compile test2 with c1 + for (int i = 0; i < cnt; i++) { + test1(i); + } + for (int i = 0; i < cnt; i++) { + test2(i); + } + Parent c = new TypeProfileFinalMethod.Child2(); + System.out.println("======== break CHA"); + // trigger c2 to compile test2 + for (int i = 0; i < 100; i++) { + test2(i); + } + } + + static void addCompilerDirectives() { + WhiteBox WB = WhiteBox.getWhiteBox(); + // do not inline getInstance() for test1() and test2() + String directive = "[{ match: [\"" + Launcher.class.getName() + "::test1\"]," + + "inline:[\"-" + Launcher.class.getName()+"::getInstance()\"] }]"; + WB.addCompilerDirective(directive); + + directive = "[{ match: [\"" + Launcher.class.getName() + "::test2\"]," + + "inline:[\"-" + Launcher.class.getName()+"::getInstance()\"] }]"; + WB.addCompilerDirective(directive); + + // do not inline test1() for test2() in c1 compilation + directive = "[{ match: [\"" + Launcher.class.getName() + "::test2\"]," + + "c1: { inline:[\"-" + Launcher.class.getName()+"::test1()\"] } }]"; + WB.addCompilerDirective(directive); + + // print inline tree for checking + directive = "[{ match: [\"" + Launcher.class.getName() + "::test2\"]," + + "c2: { PrintInlining: true } }]"; + WB.addCompilerDirective(directive); + } + + static int test1(int i) { + int ret = 0; + Parent ix = getInstance(); + if (i<200) { + return ix.m(); + } + for (int j = 0; j < 50; j++) { + ret += ix.m(); // the callsite we are interesting + } + return ret; + } + + static int test2(int i) { + return test1(i); + } + + static Parent getInstance() { + return new TypeProfileFinalMethod.Child1(); + } + } + + static abstract class Parent { + abstract public int m(); + } + + final static class Child1 extends Parent { + public int m() { + return 1; + } + } + + final static class Child2 extends Parent { + public int m() { + return 2; + } + } +} + + diff --git a/test/hotspot/jtreg/compiler/codecache/CheckSegmentedCodeCache.java b/test/hotspot/jtreg/compiler/codecache/CheckSegmentedCodeCache.java index d0b45333fb8..ecdb415843b 100644 --- a/test/hotspot/jtreg/compiler/codecache/CheckSegmentedCodeCache.java +++ b/test/hotspot/jtreg/compiler/codecache/CheckSegmentedCodeCache.java @@ -179,7 +179,9 @@ public class CheckSegmentedCodeCache { // Fails if code heap sizes do not add up pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+SegmentedCodeCache", "-XX:ReservedCodeCacheSize=10M", - "-XX:NonNMethodCodeHeapSize=5M", + // After fixing a round_down issue with large page sizes (JDK-8334564), + // 5M is a bit too small for NonNMethodCodeHeap + "-XX:NonNMethodCodeHeapSize=6M", "-XX:ProfiledCodeHeapSize=5M", "-XX:NonProfiledCodeHeapSize=5M", "-version"); diff --git a/test/hotspot/jtreg/compiler/codegen/TestAntiDependenciesHighMemUsage.java b/test/hotspot/jtreg/compiler/codegen/TestAntiDependenciesHighMemUsage.java new file mode 100644 index 00000000000..b8db6581b61 --- /dev/null +++ b/test/hotspot/jtreg/compiler/codegen/TestAntiDependenciesHighMemUsage.java @@ -0,0 +1,2443 @@ +/* + * Copyright (c) 2024, 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 8333258 + * @summary C2: high memory usage in PhaseCFG::insert_anti_dependences() + * @run main/othervm -XX:CompileOnly=TestAntiDependenciesHighMemUsage::test1 -Xcomp TestAntiDependenciesHighMemUsage + */ + +public class TestAntiDependenciesHighMemUsage { + + public static void main(String[] args) { + test1(0); + } + + private static int test1(int i) { + int v = field0000 + + field0001 + + field0002 + + field0003 + + field0004 + + field0005 + + field0006 + + field0007 + + field0008 + + field0009 + + field0010 + + field0011 + + field0012 + + field0013 + + field0014 + + field0015 + + field0016 + + field0017 + + field0018 + + field0019 + + field0020 + + field0021 + + field0022 + + field0023 + + field0024 + + field0025 + + field0026 + + field0027 + + field0028 + + field0029 + + field0030 + + field0031 + + field0032 + + field0033 + + field0034 + + field0035 + + field0036 + + field0037 + + field0038 + + field0039 + + field0040 + + field0041 + + field0042 + + field0043 + + field0044 + + field0045 + + field0046 + + field0047 + + field0048 + + field0049 + + field0050 + + field0051 + + field0052 + + field0053 + + field0054 + + field0055 + + field0056 + + field0057 + + field0058 + + field0059; + + switch (i) { + case -2140710406: + field0000 = 42; + field0001 = 42; + field0002 = 42; + field0003 = 42; + field0004 = 42; + field0005 = 42; + field0006 = 42; + field0007 = 42; + field0008 = 42; + field0009 = 42; + field0010 = 42; + field0011 = 42; + field0012 = 42; + field0013 = 42; + field0014 = 42; + field0015 = 42; + field0016 = 42; + field0017 = 42; + field0018 = 42; + field0019 = 42; + field0020 = 42; + field0021 = 42; + field0022 = 42; + field0023 = 42; + field0024 = 42; + field0025 = 42; + field0026 = 42; + field0027 = 42; + field0028 = 42; + field0029 = 42; + field0030 = 42; + field0031 = 42; + field0032 = 42; + field0033 = 42; + field0034 = 42; + field0035 = 42; + field0036 = 42; + field0037 = 42; + field0038 = 42; + field0039 = 42; + field0040 = 42; + field0041 = 42; + field0042 = 42; + field0043 = 42; + field0044 = 42; + field0045 = 42; + field0046 = 42; + field0047 = 42; + field0048 = 42; + field0049 = 42; + field0050 = 42; + field0051 = 42; + field0052 = 42; + field0053 = 42; + field0054 = 42; + field0055 = 42; + field0056 = 42; + field0057 = 42; + field0058 = 42; + field0059 = 42; + field0060 = 42; + field0061 = 42; + field0062 = 42; + field0063 = 42; + field0064 = 42; + field0065 = 42; + field0066 = 42; + field0067 = 42; + field0068 = 42; + field0069 = 42; + field0070 = 42; + field0071 = 42; + field0072 = 42; + field0073 = 42; + field0074 = 42; + field0075 = 42; + field0076 = 42; + field0077 = 42; + field0078 = 42; + field0079 = 42; + field0080 = 42; + field0081 = 42; + field0082 = 42; + field0083 = 42; + field0084 = 42; + field0085 = 42; + field0086 = 42; + field0087 = 42; + field0088 = 42; + field0089 = 42; + field0090 = 42; + field0091 = 42; + field0092 = 42; + field0093 = 42; + field0094 = 42; + field0095 = 42; + field0096 = 42; + field0097 = 42; + field0098 = 42; + field0099 = 42; + field0100 = 42; + field0101 = 42; + field0102 = 42; + field0103 = 42; + field0104 = 42; + field0105 = 42; + field0106 = 42; + field0107 = 42; + field0108 = 42; + field0109 = 42; + field0110 = 42; + field0111 = 42; + field0112 = 42; + field0113 = 42; + field0114 = 42; + field0115 = 42; + field0116 = 42; + field0117 = 42; + field0118 = 42; + field0119 = 42; + field0120 = 42; + field0121 = 42; + field0122 = 42; + field0123 = 42; + field0124 = 42; + field0125 = 42; + field0126 = 42; + field0127 = 42; + field0128 = 42; + field0129 = 42; + field0130 = 42; + field0131 = 42; + field0132 = 42; + field0133 = 42; + field0134 = 42; + field0135 = 42; + field0136 = 42; + field0137 = 42; + field0138 = 42; + field0139 = 42; + field0140 = 42; + field0141 = 42; + field0142 = 42; + field0143 = 42; + field0144 = 42; + field0145 = 42; + field0146 = 42; + field0147 = 42; + field0148 = 42; + field0149 = 42; + field0150 = 42; + field0151 = 42; + field0152 = 42; + field0153 = 42; + field0154 = 42; + field0155 = 42; + field0156 = 42; + field0157 = 42; + field0158 = 42; + field0159 = 42; + field0160 = 42; + field0161 = 42; + field0162 = 42; + field0163 = 42; + field0164 = 42; + field0165 = 42; + field0166 = 42; + field0167 = 42; + field0168 = 42; + field0169 = 42; + field0170 = 42; + field0171 = 42; + field0172 = 42; + field0173 = 42; + field0174 = 42; + field0175 = 42; + field0176 = 42; + field0177 = 42; + field0178 = 42; + field0179 = 42; + field0180 = 42; + field0181 = 42; + field0182 = 42; + field0183 = 42; + field0184 = 42; + field0185 = 42; + field0186 = 42; + field0187 = 42; + field0188 = 42; + field0189 = 42; + field0190 = 42; + field0191 = 42; + field0192 = 42; + field0193 = 42; + field0194 = 42; + field0195 = 42; + field0196 = 42; + field0197 = 42; + field0198 = 42; + field0199 = 42; + field0200 = 42; + field0201 = 42; + field0202 = 42; + field0203 = 42; + field0204 = 42; + field0205 = 42; + field0206 = 42; + field0207 = 42; + field0208 = 42; + field0209 = 42; + field0210 = 42; + field0211 = 42; + field0212 = 42; + field0213 = 42; + field0214 = 42; + field0215 = 42; + field0216 = 42; + field0217 = 42; + field0218 = 42; + field0219 = 42; + field0220 = 42; + field0221 = 42; + field0222 = 42; + field0223 = 42; + field0224 = 42; + field0225 = 42; + field0226 = 42; + field0227 = 42; + field0228 = 42; + field0229 = 42; + field0230 = 42; + field0231 = 42; + field0232 = 42; + field0233 = 42; + field0234 = 42; + field0235 = 42; + field0236 = 42; + field0237 = 42; + field0238 = 42; + field0239 = 42; + field0240 = 42; + field0241 = 42; + field0242 = 42; + field0243 = 42; + field0244 = 42; + field0245 = 42; + field0246 = 42; + field0247 = 42; + field0248 = 42; + field0249 = 42; + field0250 = 42; + field0251 = 42; + field0252 = 42; + field0253 = 42; + field0254 = 42; + field0255 = 42; + field0256 = 42; + field0257 = 42; + field0258 = 42; + field0259 = 42; + field0260 = 42; + field0261 = 42; + field0262 = 42; + field0263 = 42; + field0264 = 42; + field0265 = 42; + field0266 = 42; + field0267 = 42; + field0268 = 42; + field0269 = 42; + field0270 = 42; + field0271 = 42; + field0272 = 42; + field0273 = 42; + field0274 = 42; + field0275 = 42; + field0276 = 42; + field0277 = 42; + field0278 = 42; + field0279 = 42; + field0280 = 42; + field0281 = 42; + field0282 = 42; + field0283 = 42; + field0284 = 42; + field0285 = 42; + field0286 = 42; + field0287 = 42; + field0288 = 42; + field0289 = 42; + field0290 = 42; + field0291 = 42; + field0292 = 42; + field0293 = 42; + field0294 = 42; + field0295 = 42; + field0296 = 42; + field0297 = 42; + field0298 = 42; + field0299 = 42; + field0300 = 42; + field0301 = 42; + field0302 = 42; + field0303 = 42; + field0304 = 42; + field0305 = 42; + field0306 = 42; + field0307 = 42; + field0308 = 42; + field0309 = 42; + field0310 = 42; + field0311 = 42; + field0312 = 42; + field0313 = 42; + field0314 = 42; + field0315 = 42; + field0316 = 42; + field0317 = 42; + field0318 = 42; + field0319 = 42; + field0320 = 42; + field0321 = 42; + field0322 = 42; + field0323 = 42; + field0324 = 42; + field0325 = 42; + field0326 = 42; + field0327 = 42; + field0328 = 42; + field0329 = 42; + field0330 = 42; + field0331 = 42; + field0332 = 42; + field0333 = 42; + field0334 = 42; + field0335 = 42; + field0336 = 42; + field0337 = 42; + field0338 = 42; + field0339 = 42; + field0340 = 42; + field0341 = 42; + field0342 = 42; + field0343 = 42; + field0344 = 42; + field0345 = 42; + field0346 = 42; + field0347 = 42; + field0348 = 42; + field0349 = 42; + field0350 = 42; + field0351 = 42; + field0352 = 42; + field0353 = 42; + field0354 = 42; + field0355 = 42; + field0356 = 42; + field0357 = 42; + field0358 = 42; + field0359 = 42; + field0360 = 42; + field0361 = 42; + field0362 = 42; + field0363 = 42; + field0364 = 42; + field0365 = 42; + field0366 = 42; + field0367 = 42; + field0368 = 42; + field0369 = 42; + field0370 = 42; + field0371 = 42; + field0372 = 42; + field0373 = 42; + field0374 = 42; + field0375 = 42; + field0376 = 42; + field0377 = 42; + field0378 = 42; + field0379 = 42; + field0380 = 42; + field0381 = 42; + field0382 = 42; + field0383 = 42; + field0384 = 42; + field0385 = 42; + field0386 = 42; + field0387 = 42; + field0388 = 42; + field0389 = 42; + field0390 = 42; + field0391 = 42; + field0392 = 42; + field0393 = 42; + field0394 = 42; + field0395 = 42; + field0396 = 42; + field0397 = 42; + field0398 = 42; + field0399 = 42; + field0400 = 42; + field0401 = 42; + field0402 = 42; + field0403 = 42; + field0404 = 42; + field0405 = 42; + field0406 = 42; + field0407 = 42; + field0408 = 42; + field0409 = 42; + field0410 = 42; + field0411 = 42; + field0412 = 42; + field0413 = 42; + field0414 = 42; + field0415 = 42; + field0416 = 42; + field0417 = 42; + field0418 = 42; + field0419 = 42; + field0420 = 42; + field0421 = 42; + field0422 = 42; + field0423 = 42; + field0424 = 42; + field0425 = 42; + field0426 = 42; + field0427 = 42; + field0428 = 42; + field0429 = 42; + field0430 = 42; + field0431 = 42; + field0432 = 42; + field0433 = 42; + field0434 = 42; + field0435 = 42; + field0436 = 42; + field0437 = 42; + field0438 = 42; + field0439 = 42; + field0440 = 42; + field0441 = 42; + field0442 = 42; + field0443 = 42; + field0444 = 42; + field0445 = 42; + field0446 = 42; + field0447 = 42; + field0448 = 42; + field0449 = 42; + field0450 = 42; + field0451 = 42; + field0452 = 42; + field0453 = 42; + field0454 = 42; + field0455 = 42; + field0456 = 42; + field0457 = 42; + field0458 = 42; + field0459 = 42; + field0460 = 42; + field0461 = 42; + field0462 = 42; + field0463 = 42; + field0464 = 42; + field0465 = 42; + field0466 = 42; + field0467 = 42; + field0468 = 42; + field0469 = 42; + field0470 = 42; + field0471 = 42; + field0472 = 42; + field0473 = 42; + field0474 = 42; + field0475 = 42; + field0476 = 42; + field0477 = 42; + field0478 = 42; + field0479 = 42; + field0480 = 42; + field0481 = 42; + field0482 = 42; + field0483 = 42; + field0484 = 42; + field0485 = 42; + field0486 = 42; + field0487 = 42; + field0488 = 42; + field0489 = 42; + field0490 = 42; + field0491 = 42; + field0492 = 42; + field0493 = 42; + field0494 = 42; + field0495 = 42; + field0496 = 42; + field0497 = 42; + field0498 = 42; + field0499 = 42; + field0500 = 42; + field0501 = 42; + field0502 = 42; + field0503 = 42; + field0504 = 42; + field0505 = 42; + field0506 = 42; + field0507 = 42; + field0508 = 42; + field0509 = 42; + field0510 = 42; + field0511 = 42; + field0512 = 42; + field0513 = 42; + field0514 = 42; + field0515 = 42; + field0516 = 42; + field0517 = 42; + field0518 = 42; + field0519 = 42; + field0520 = 42; + field0521 = 42; + field0522 = 42; + field0523 = 42; + field0524 = 42; + field0525 = 42; + field0526 = 42; + field0527 = 42; + field0528 = 42; + field0529 = 42; + field0530 = 42; + field0531 = 42; + field0532 = 42; + field0533 = 42; + field0534 = 42; + field0535 = 42; + field0536 = 42; + field0537 = 42; + field0538 = 42; + field0539 = 42; + field0540 = 42; + field0541 = 42; + field0542 = 42; + field0543 = 42; + field0544 = 42; + field0545 = 42; + field0546 = 42; + field0547 = 42; + field0548 = 42; + field0549 = 42; + field0550 = 42; + field0551 = 42; + field0552 = 42; + field0553 = 42; + field0554 = 42; + field0555 = 42; + field0556 = 42; + field0557 = 42; + field0558 = 42; + field0559 = 42; + field0560 = 42; + field0561 = 42; + field0562 = 42; + field0563 = 42; + field0564 = 42; + field0565 = 42; + field0566 = 42; + field0567 = 42; + field0568 = 42; + field0569 = 42; + field0570 = 42; + field0571 = 42; + field0572 = 42; + field0573 = 42; + field0574 = 42; + field0575 = 42; + field0576 = 42; + field0577 = 42; + field0578 = 42; + field0579 = 42; + field0580 = 42; + field0581 = 42; + field0582 = 42; + field0583 = 42; + field0584 = 42; + field0585 = 42; + field0586 = 42; + field0587 = 42; + field0588 = 42; + field0589 = 42; + field0590 = 42; + field0591 = 42; + field0592 = 42; + field0593 = 42; + field0594 = 42; + field0595 = 42; + field0596 = 42; + field0597 = 42; + field0598 = 42; + field0599 = 42; + field0600 = 42; + field0601 = 42; + field0602 = 42; + field0603 = 42; + field0604 = 42; + field0605 = 42; + field0606 = 42; + field0607 = 42; + field0608 = 42; + field0609 = 42; + field0610 = 42; + field0611 = 42; + field0612 = 42; + field0613 = 42; + field0614 = 42; + field0615 = 42; + field0616 = 42; + field0617 = 42; + field0618 = 42; + field0619 = 42; + field0620 = 42; + field0621 = 42; + field0622 = 42; + field0623 = 42; + field0624 = 42; + field0625 = 42; + field0626 = 42; + field0627 = 42; + field0628 = 42; + field0629 = 42; + field0630 = 42; + field0631 = 42; + field0632 = 42; + field0633 = 42; + field0634 = 42; + field0635 = 42; + field0636 = 42; + field0637 = 42; + field0638 = 42; + field0639 = 42; + field0640 = 42; + field0641 = 42; + field0642 = 42; + field0643 = 42; + field0644 = 42; + field0645 = 42; + field0646 = 42; + field0647 = 42; + field0648 = 42; + field0649 = 42; + field0650 = 42; + field0651 = 42; + field0652 = 42; + field0653 = 42; + field0654 = 42; + field0655 = 42; + field0656 = 42; + field0657 = 42; + field0658 = 42; + field0659 = 42; + field0660 = 42; + field0661 = 42; + field0662 = 42; + field0663 = 42; + field0664 = 42; + field0665 = 42; + field0666 = 42; + field0667 = 42; + field0668 = 42; + field0669 = 42; + field0670 = 42; + field0671 = 42; + field0672 = 42; + field0673 = 42; + field0674 = 42; + field0675 = 42; + field0676 = 42; + field0677 = 42; + field0678 = 42; + field0679 = 42; + field0680 = 42; + field0681 = 42; + field0682 = 42; + field0683 = 42; + field0684 = 42; + field0685 = 42; + field0686 = 42; + field0687 = 42; + field0688 = 42; + field0689 = 42; + field0690 = 42; + field0691 = 42; + field0692 = 42; + field0693 = 42; + field0694 = 42; + field0695 = 42; + field0696 = 42; + field0697 = 42; + field0698 = 42; + field0699 = 42; + field0700 = 42; + field0701 = 42; + field0702 = 42; + field0703 = 42; + field0704 = 42; + field0705 = 42; + field0706 = 42; + field0707 = 42; + field0708 = 42; + field0709 = 42; + field0710 = 42; + field0711 = 42; + field0712 = 42; + field0713 = 42; + field0714 = 42; + field0715 = 42; + field0716 = 42; + field0717 = 42; + field0718 = 42; + field0719 = 42; + field0720 = 42; + field0721 = 42; + field0722 = 42; + field0723 = 42; + field0724 = 42; + field0725 = 42; + field0726 = 42; + field0727 = 42; + field0728 = 42; + field0729 = 42; + field0730 = 42; + field0731 = 42; + field0732 = 42; + field0733 = 42; + field0734 = 42; + field0735 = 42; + field0736 = 42; + field0737 = 42; + field0738 = 42; + field0739 = 42; + field0740 = 42; + field0741 = 42; + field0742 = 42; + field0743 = 42; + field0744 = 42; + field0745 = 42; + field0746 = 42; + field0747 = 42; + field0748 = 42; + field0749 = 42; + field0750 = 42; + field0751 = 42; + field0752 = 42; + field0753 = 42; + field0754 = 42; + field0755 = 42; + field0756 = 42; + field0757 = 42; + field0758 = 42; + field0759 = 42; + field0760 = 42; + field0761 = 42; + field0762 = 42; + field0763 = 42; + field0764 = 42; + field0765 = 42; + field0766 = 42; + field0767 = 42; + field0768 = 42; + field0769 = 42; + field0770 = 42; + field0771 = 42; + field0772 = 42; + field0773 = 42; + field0774 = 42; + field0775 = 42; + field0776 = 42; + field0777 = 42; + field0778 = 42; + field0779 = 42; + field0780 = 42; + field0781 = 42; + field0782 = 42; + field0783 = 42; + field0784 = 42; + field0785 = 42; + field0786 = 42; + field0787 = 42; + field0788 = 42; + field0789 = 42; + field0790 = 42; + field0791 = 42; + field0792 = 42; + field0793 = 42; + field0794 = 42; + field0795 = 42; + field0796 = 42; + field0797 = 42; + field0798 = 42; + field0799 = 42; + field0800 = 42; + field0801 = 42; + field0802 = 42; + field0803 = 42; + field0804 = 42; + field0805 = 42; + field0806 = 42; + field0807 = 42; + field0808 = 42; + field0809 = 42; + field0810 = 42; + field0811 = 42; + field0812 = 42; + field0813 = 42; + field0814 = 42; + field0815 = 42; + field0816 = 42; + field0817 = 42; + field0818 = 42; + field0819 = 42; + field0820 = 42; + field0821 = 42; + field0822 = 42; + field0823 = 42; + field0824 = 42; + field0825 = 42; + field0826 = 42; + field0827 = 42; + field0828 = 42; + field0829 = 42; + field0830 = 42; + field0831 = 42; + field0832 = 42; + field0833 = 42; + field0834 = 42; + field0835 = 42; + field0836 = 42; + field0837 = 42; + field0838 = 42; + field0839 = 42; + field0840 = 42; + field0841 = 42; + field0842 = 42; + field0843 = 42; + field0844 = 42; + field0845 = 42; + field0846 = 42; + field0847 = 42; + field0848 = 42; + field0849 = 42; + field0850 = 42; + field0851 = 42; + field0852 = 42; + field0853 = 42; + field0854 = 42; + field0855 = 42; + field0856 = 42; + field0857 = 42; + field0858 = 42; + field0859 = 42; + field0860 = 42; + field0861 = 42; + field0862 = 42; + field0863 = 42; + field0864 = 42; + field0865 = 42; + field0866 = 42; + field0867 = 42; + field0868 = 42; + field0869 = 42; + field0870 = 42; + field0871 = 42; + field0872 = 42; + field0873 = 42; + field0874 = 42; + field0875 = 42; + field0876 = 42; + field0877 = 42; + field0878 = 42; + field0879 = 42; + field0880 = 42; + field0881 = 42; + field0882 = 42; + field0883 = 42; + field0884 = 42; + field0885 = 42; + field0886 = 42; + field0887 = 42; + field0888 = 42; + field0889 = 42; + field0890 = 42; + field0891 = 42; + field0892 = 42; + field0893 = 42; + field0894 = 42; + field0895 = 42; + field0896 = 42; + field0897 = 42; + field0898 = 42; + field0899 = 42; + field0900 = 42; + field0901 = 42; + field0902 = 42; + field0903 = 42; + field0904 = 42; + field0905 = 42; + field0906 = 42; + field0907 = 42; + field0908 = 42; + field0909 = 42; + field0910 = 42; + field0911 = 42; + field0912 = 42; + field0913 = 42; + field0914 = 42; + field0915 = 42; + field0916 = 42; + field0917 = 42; + field0918 = 42; + field0919 = 42; + field0920 = 42; + field0921 = 42; + field0922 = 42; + field0923 = 42; + field0924 = 42; + field0925 = 42; + field0926 = 42; + field0927 = 42; + field0928 = 42; + field0929 = 42; + field0930 = 42; + field0931 = 42; + field0932 = 42; + field0933 = 42; + field0934 = 42; + field0935 = 42; + field0936 = 42; + field0937 = 42; + field0938 = 42; + field0939 = 42; + field0940 = 42; + field0941 = 42; + field0942 = 42; + field0943 = 42; + field0944 = 42; + field0945 = 42; + field0946 = 42; + field0947 = 42; + field0948 = 42; + field0949 = 42; + field0950 = 42; + field0951 = 42; + field0952 = 42; + field0953 = 42; + field0954 = 42; + field0955 = 42; + field0956 = 42; + field0957 = 42; + field0958 = 42; + field0959 = 42; + field0960 = 42; + field0961 = 42; + field0962 = 42; + field0963 = 42; + field0964 = 42; + field0965 = 42; + field0966 = 42; + field0967 = 42; + field0968 = 42; + field0969 = 42; + field0970 = 42; + field0971 = 42; + field0972 = 42; + field0973 = 42; + field0974 = 42; + field0975 = 42; + field0976 = 42; + field0977 = 42; + field0978 = 42; + field0979 = 42; + field0980 = 42; + field0981 = 42; + field0982 = 42; + field0983 = 42; + field0984 = 42; + field0985 = 42; + field0986 = 42; + field0987 = 42; + field0988 = 42; + field0989 = 42; + field0990 = 42; + field0991 = 42; + field0992 = 42; + field0993 = 42; + field0994 = 42; + field0995 = 42; + field0996 = 42; + field0997 = 42; + field0998 = 42; + field0999 = 42; + break; + case -2097348800: + break; + case -2068224216: + break; + case -2037697382: + break; + case -2004863454: + break; + case -1927368268: + break; + case -1907858975: + break; + case -1907849355: + break; + case -1874423303: + break; + case -1842766326: + break; + case -1789797270: + break; + case -1760959152: + break; + case -1691992770: + break; + case -1678813190: + break; + case -1605049009: + break; + case -1476174894: + break; + case -1377846581: + break; + case -1345530543: + break; + case -1307317230: + break; + case -1268501092: + break; + case -1220360021: + break; + case -1217415016: + break; + case -1216012752: + break; + case -1202791344: + break; + case -1197000094: + break; + case -1153521791: + break; + case -1136815094: + break; + case -1122842661: + break; + case -1097468803: + break; + case -1093178557: + break; + case -1087398572: + break; + case -1008013583: + break; + case -1001676601: + break; + case -949306426: + break; + case -912457023: + break; + case -891985903: + break; + case -883723257: + break; + case -871422185: + break; + case -766867181: + break; + case -766422255: + break; + case -650580623: + break; + case -633276745: + break; + case -632949857: + break; + case -621058352: + break; + case -616289146: + break; + case -589453283: + break; + case -555387838: + break; + case -540546990: + break; + case -526550005: + break; + case -502303438: + break; + case -408244884: + break; + case -367870439: + break; + case -342579923: + break; + case -330210563: + break; + case -329624856: + break; + case -302536977: + break; + case -287122936: + break; + case -236322890: + break; + case -227407685: + break; + case -218088061: + break; + case -180371167: + break; + case -131262666: + break; + case -5812857: + break; + case 3355: + break; + case 65759: + break; + case 110026: + break; + case 116076: + break; + case 2192268: + break; + case 2224947: + break; + case 2368702: + break; + case 2394661: + break; + case 2579998: + break; + case 2599333: + break; + case 3059181: + break; + case 3076014: + break; + case 3560141: + break; + case 3601339: + break; + case 8777024: + break; + case 28778089: + break; + case 29963587: + break; + case 57185780: + break; + case 57208314: + break; + case 57320750: + break; + case 63955982: + break; + case 64711720: + break; + case 65189916: + break; + case 65298671: + break; + case 69076575: + break; + case 74219460: + break; + case 74526880: + break; + case 78727453: + break; + case 78733291: + break; + case 192873343: + break; + case 194378184: + break; + case 246938863: + break; + case 269058788: + break; + case 289362821: + break; + case 325021616: + break; + case 353103893: + break; + case 369315063: + break; + case 375032009: + break; + case 383030819: + break; + case 438421327: + break; + case 487334413: + break; + case 491858238: + break; + case 505523517: + break; + case 516961236: + break; + case 665843328: + break; + case 671337916: + break; + case 737478748: + break; + case 738893626: + break; + case 745969447: + break; + case 770498827: + break; + case 776138553: + break; + case 828944778: + break; + case 846088000: + break; + case 850563927: + break; + case 851278306: + break; + case 873235173: + break; + case 908763827: + break; + case 933423720: + break; + case 973193329: + break; + case 997117913: + break; + case 1071332590: + break; + case 1076953756: + break; + case 1078812459: + break; + case 1133777670: + break; + case 1142656251: + break; + case 1145198778: + break; + case 1247831734: + break; + case 1260711798: + break; + case 1287805733: + break; + case 1312904398: + break; + case 1343242579: + break; + case 1391410207: + break; + case 1401244028: + break; + case 1410262602: + break; + case 1414192097: + break; + case 1428236656: + break; + case 1445374288: + break; + case 1488475261: + break; + case 1542263633: + break; + case 1592332600: + break; + case 1600636622: + break; + case 1627523232: + break; + case 1681397778: + break; + case 1721380104: + break; + case 1728372347: + break; + case 1733332192: + break; + case 1767264297: + break; + case 1790214156: + break; + case 1792749467: + break; + case 1805746613: + break; + case 1824308900: + break; + case 1830861979: + break; + case 1841735333: + break; + case 1922784394: + break; + case 1957570017: + break; + case 1958052158: + break; + case 1958247177: + break; + case 1965687765: + break; + case 1989867553: + break; + case 2000952482: + break; + case 2023747466: + break; + case 2043677302: + break; + case 2052815575: + break; + case 2082457694: + break; + case 2093211201: + break; + default: + break; + } + + return v; + } + + private static int field0000; + private static int field0001; + private static int field0002; + private static int field0003; + private static int field0004; + private static int field0005; + private static int field0006; + private static int field0007; + private static int field0008; + private static int field0009; + private static int field0010; + private static int field0011; + private static int field0012; + private static int field0013; + private static int field0014; + private static int field0015; + private static int field0016; + private static int field0017; + private static int field0018; + private static int field0019; + private static int field0020; + private static int field0021; + private static int field0022; + private static int field0023; + private static int field0024; + private static int field0025; + private static int field0026; + private static int field0027; + private static int field0028; + private static int field0029; + private static int field0030; + private static int field0031; + private static int field0032; + private static int field0033; + private static int field0034; + private static int field0035; + private static int field0036; + private static int field0037; + private static int field0038; + private static int field0039; + private static int field0040; + private static int field0041; + private static int field0042; + private static int field0043; + private static int field0044; + private static int field0045; + private static int field0046; + private static int field0047; + private static int field0048; + private static int field0049; + private static int field0050; + private static int field0051; + private static int field0052; + private static int field0053; + private static int field0054; + private static int field0055; + private static int field0056; + private static int field0057; + private static int field0058; + private static int field0059; + private static int field0060; + private static int field0061; + private static int field0062; + private static int field0063; + private static int field0064; + private static int field0065; + private static int field0066; + private static int field0067; + private static int field0068; + private static int field0069; + private static int field0070; + private static int field0071; + private static int field0072; + private static int field0073; + private static int field0074; + private static int field0075; + private static int field0076; + private static int field0077; + private static int field0078; + private static int field0079; + private static int field0080; + private static int field0081; + private static int field0082; + private static int field0083; + private static int field0084; + private static int field0085; + private static int field0086; + private static int field0087; + private static int field0088; + private static int field0089; + private static int field0090; + private static int field0091; + private static int field0092; + private static int field0093; + private static int field0094; + private static int field0095; + private static int field0096; + private static int field0097; + private static int field0098; + private static int field0099; + private static int field0100; + private static int field0101; + private static int field0102; + private static int field0103; + private static int field0104; + private static int field0105; + private static int field0106; + private static int field0107; + private static int field0108; + private static int field0109; + private static int field0110; + private static int field0111; + private static int field0112; + private static int field0113; + private static int field0114; + private static int field0115; + private static int field0116; + private static int field0117; + private static int field0118; + private static int field0119; + private static int field0120; + private static int field0121; + private static int field0122; + private static int field0123; + private static int field0124; + private static int field0125; + private static int field0126; + private static int field0127; + private static int field0128; + private static int field0129; + private static int field0130; + private static int field0131; + private static int field0132; + private static int field0133; + private static int field0134; + private static int field0135; + private static int field0136; + private static int field0137; + private static int field0138; + private static int field0139; + private static int field0140; + private static int field0141; + private static int field0142; + private static int field0143; + private static int field0144; + private static int field0145; + private static int field0146; + private static int field0147; + private static int field0148; + private static int field0149; + private static int field0150; + private static int field0151; + private static int field0152; + private static int field0153; + private static int field0154; + private static int field0155; + private static int field0156; + private static int field0157; + private static int field0158; + private static int field0159; + private static int field0160; + private static int field0161; + private static int field0162; + private static int field0163; + private static int field0164; + private static int field0165; + private static int field0166; + private static int field0167; + private static int field0168; + private static int field0169; + private static int field0170; + private static int field0171; + private static int field0172; + private static int field0173; + private static int field0174; + private static int field0175; + private static int field0176; + private static int field0177; + private static int field0178; + private static int field0179; + private static int field0180; + private static int field0181; + private static int field0182; + private static int field0183; + private static int field0184; + private static int field0185; + private static int field0186; + private static int field0187; + private static int field0188; + private static int field0189; + private static int field0190; + private static int field0191; + private static int field0192; + private static int field0193; + private static int field0194; + private static int field0195; + private static int field0196; + private static int field0197; + private static int field0198; + private static int field0199; + private static int field0200; + private static int field0201; + private static int field0202; + private static int field0203; + private static int field0204; + private static int field0205; + private static int field0206; + private static int field0207; + private static int field0208; + private static int field0209; + private static int field0210; + private static int field0211; + private static int field0212; + private static int field0213; + private static int field0214; + private static int field0215; + private static int field0216; + private static int field0217; + private static int field0218; + private static int field0219; + private static int field0220; + private static int field0221; + private static int field0222; + private static int field0223; + private static int field0224; + private static int field0225; + private static int field0226; + private static int field0227; + private static int field0228; + private static int field0229; + private static int field0230; + private static int field0231; + private static int field0232; + private static int field0233; + private static int field0234; + private static int field0235; + private static int field0236; + private static int field0237; + private static int field0238; + private static int field0239; + private static int field0240; + private static int field0241; + private static int field0242; + private static int field0243; + private static int field0244; + private static int field0245; + private static int field0246; + private static int field0247; + private static int field0248; + private static int field0249; + private static int field0250; + private static int field0251; + private static int field0252; + private static int field0253; + private static int field0254; + private static int field0255; + private static int field0256; + private static int field0257; + private static int field0258; + private static int field0259; + private static int field0260; + private static int field0261; + private static int field0262; + private static int field0263; + private static int field0264; + private static int field0265; + private static int field0266; + private static int field0267; + private static int field0268; + private static int field0269; + private static int field0270; + private static int field0271; + private static int field0272; + private static int field0273; + private static int field0274; + private static int field0275; + private static int field0276; + private static int field0277; + private static int field0278; + private static int field0279; + private static int field0280; + private static int field0281; + private static int field0282; + private static int field0283; + private static int field0284; + private static int field0285; + private static int field0286; + private static int field0287; + private static int field0288; + private static int field0289; + private static int field0290; + private static int field0291; + private static int field0292; + private static int field0293; + private static int field0294; + private static int field0295; + private static int field0296; + private static int field0297; + private static int field0298; + private static int field0299; + private static int field0300; + private static int field0301; + private static int field0302; + private static int field0303; + private static int field0304; + private static int field0305; + private static int field0306; + private static int field0307; + private static int field0308; + private static int field0309; + private static int field0310; + private static int field0311; + private static int field0312; + private static int field0313; + private static int field0314; + private static int field0315; + private static int field0316; + private static int field0317; + private static int field0318; + private static int field0319; + private static int field0320; + private static int field0321; + private static int field0322; + private static int field0323; + private static int field0324; + private static int field0325; + private static int field0326; + private static int field0327; + private static int field0328; + private static int field0329; + private static int field0330; + private static int field0331; + private static int field0332; + private static int field0333; + private static int field0334; + private static int field0335; + private static int field0336; + private static int field0337; + private static int field0338; + private static int field0339; + private static int field0340; + private static int field0341; + private static int field0342; + private static int field0343; + private static int field0344; + private static int field0345; + private static int field0346; + private static int field0347; + private static int field0348; + private static int field0349; + private static int field0350; + private static int field0351; + private static int field0352; + private static int field0353; + private static int field0354; + private static int field0355; + private static int field0356; + private static int field0357; + private static int field0358; + private static int field0359; + private static int field0360; + private static int field0361; + private static int field0362; + private static int field0363; + private static int field0364; + private static int field0365; + private static int field0366; + private static int field0367; + private static int field0368; + private static int field0369; + private static int field0370; + private static int field0371; + private static int field0372; + private static int field0373; + private static int field0374; + private static int field0375; + private static int field0376; + private static int field0377; + private static int field0378; + private static int field0379; + private static int field0380; + private static int field0381; + private static int field0382; + private static int field0383; + private static int field0384; + private static int field0385; + private static int field0386; + private static int field0387; + private static int field0388; + private static int field0389; + private static int field0390; + private static int field0391; + private static int field0392; + private static int field0393; + private static int field0394; + private static int field0395; + private static int field0396; + private static int field0397; + private static int field0398; + private static int field0399; + private static int field0400; + private static int field0401; + private static int field0402; + private static int field0403; + private static int field0404; + private static int field0405; + private static int field0406; + private static int field0407; + private static int field0408; + private static int field0409; + private static int field0410; + private static int field0411; + private static int field0412; + private static int field0413; + private static int field0414; + private static int field0415; + private static int field0416; + private static int field0417; + private static int field0418; + private static int field0419; + private static int field0420; + private static int field0421; + private static int field0422; + private static int field0423; + private static int field0424; + private static int field0425; + private static int field0426; + private static int field0427; + private static int field0428; + private static int field0429; + private static int field0430; + private static int field0431; + private static int field0432; + private static int field0433; + private static int field0434; + private static int field0435; + private static int field0436; + private static int field0437; + private static int field0438; + private static int field0439; + private static int field0440; + private static int field0441; + private static int field0442; + private static int field0443; + private static int field0444; + private static int field0445; + private static int field0446; + private static int field0447; + private static int field0448; + private static int field0449; + private static int field0450; + private static int field0451; + private static int field0452; + private static int field0453; + private static int field0454; + private static int field0455; + private static int field0456; + private static int field0457; + private static int field0458; + private static int field0459; + private static int field0460; + private static int field0461; + private static int field0462; + private static int field0463; + private static int field0464; + private static int field0465; + private static int field0466; + private static int field0467; + private static int field0468; + private static int field0469; + private static int field0470; + private static int field0471; + private static int field0472; + private static int field0473; + private static int field0474; + private static int field0475; + private static int field0476; + private static int field0477; + private static int field0478; + private static int field0479; + private static int field0480; + private static int field0481; + private static int field0482; + private static int field0483; + private static int field0484; + private static int field0485; + private static int field0486; + private static int field0487; + private static int field0488; + private static int field0489; + private static int field0490; + private static int field0491; + private static int field0492; + private static int field0493; + private static int field0494; + private static int field0495; + private static int field0496; + private static int field0497; + private static int field0498; + private static int field0499; + private static int field0500; + private static int field0501; + private static int field0502; + private static int field0503; + private static int field0504; + private static int field0505; + private static int field0506; + private static int field0507; + private static int field0508; + private static int field0509; + private static int field0510; + private static int field0511; + private static int field0512; + private static int field0513; + private static int field0514; + private static int field0515; + private static int field0516; + private static int field0517; + private static int field0518; + private static int field0519; + private static int field0520; + private static int field0521; + private static int field0522; + private static int field0523; + private static int field0524; + private static int field0525; + private static int field0526; + private static int field0527; + private static int field0528; + private static int field0529; + private static int field0530; + private static int field0531; + private static int field0532; + private static int field0533; + private static int field0534; + private static int field0535; + private static int field0536; + private static int field0537; + private static int field0538; + private static int field0539; + private static int field0540; + private static int field0541; + private static int field0542; + private static int field0543; + private static int field0544; + private static int field0545; + private static int field0546; + private static int field0547; + private static int field0548; + private static int field0549; + private static int field0550; + private static int field0551; + private static int field0552; + private static int field0553; + private static int field0554; + private static int field0555; + private static int field0556; + private static int field0557; + private static int field0558; + private static int field0559; + private static int field0560; + private static int field0561; + private static int field0562; + private static int field0563; + private static int field0564; + private static int field0565; + private static int field0566; + private static int field0567; + private static int field0568; + private static int field0569; + private static int field0570; + private static int field0571; + private static int field0572; + private static int field0573; + private static int field0574; + private static int field0575; + private static int field0576; + private static int field0577; + private static int field0578; + private static int field0579; + private static int field0580; + private static int field0581; + private static int field0582; + private static int field0583; + private static int field0584; + private static int field0585; + private static int field0586; + private static int field0587; + private static int field0588; + private static int field0589; + private static int field0590; + private static int field0591; + private static int field0592; + private static int field0593; + private static int field0594; + private static int field0595; + private static int field0596; + private static int field0597; + private static int field0598; + private static int field0599; + private static int field0600; + private static int field0601; + private static int field0602; + private static int field0603; + private static int field0604; + private static int field0605; + private static int field0606; + private static int field0607; + private static int field0608; + private static int field0609; + private static int field0610; + private static int field0611; + private static int field0612; + private static int field0613; + private static int field0614; + private static int field0615; + private static int field0616; + private static int field0617; + private static int field0618; + private static int field0619; + private static int field0620; + private static int field0621; + private static int field0622; + private static int field0623; + private static int field0624; + private static int field0625; + private static int field0626; + private static int field0627; + private static int field0628; + private static int field0629; + private static int field0630; + private static int field0631; + private static int field0632; + private static int field0633; + private static int field0634; + private static int field0635; + private static int field0636; + private static int field0637; + private static int field0638; + private static int field0639; + private static int field0640; + private static int field0641; + private static int field0642; + private static int field0643; + private static int field0644; + private static int field0645; + private static int field0646; + private static int field0647; + private static int field0648; + private static int field0649; + private static int field0650; + private static int field0651; + private static int field0652; + private static int field0653; + private static int field0654; + private static int field0655; + private static int field0656; + private static int field0657; + private static int field0658; + private static int field0659; + private static int field0660; + private static int field0661; + private static int field0662; + private static int field0663; + private static int field0664; + private static int field0665; + private static int field0666; + private static int field0667; + private static int field0668; + private static int field0669; + private static int field0670; + private static int field0671; + private static int field0672; + private static int field0673; + private static int field0674; + private static int field0675; + private static int field0676; + private static int field0677; + private static int field0678; + private static int field0679; + private static int field0680; + private static int field0681; + private static int field0682; + private static int field0683; + private static int field0684; + private static int field0685; + private static int field0686; + private static int field0687; + private static int field0688; + private static int field0689; + private static int field0690; + private static int field0691; + private static int field0692; + private static int field0693; + private static int field0694; + private static int field0695; + private static int field0696; + private static int field0697; + private static int field0698; + private static int field0699; + private static int field0700; + private static int field0701; + private static int field0702; + private static int field0703; + private static int field0704; + private static int field0705; + private static int field0706; + private static int field0707; + private static int field0708; + private static int field0709; + private static int field0710; + private static int field0711; + private static int field0712; + private static int field0713; + private static int field0714; + private static int field0715; + private static int field0716; + private static int field0717; + private static int field0718; + private static int field0719; + private static int field0720; + private static int field0721; + private static int field0722; + private static int field0723; + private static int field0724; + private static int field0725; + private static int field0726; + private static int field0727; + private static int field0728; + private static int field0729; + private static int field0730; + private static int field0731; + private static int field0732; + private static int field0733; + private static int field0734; + private static int field0735; + private static int field0736; + private static int field0737; + private static int field0738; + private static int field0739; + private static int field0740; + private static int field0741; + private static int field0742; + private static int field0743; + private static int field0744; + private static int field0745; + private static int field0746; + private static int field0747; + private static int field0748; + private static int field0749; + private static int field0750; + private static int field0751; + private static int field0752; + private static int field0753; + private static int field0754; + private static int field0755; + private static int field0756; + private static int field0757; + private static int field0758; + private static int field0759; + private static int field0760; + private static int field0761; + private static int field0762; + private static int field0763; + private static int field0764; + private static int field0765; + private static int field0766; + private static int field0767; + private static int field0768; + private static int field0769; + private static int field0770; + private static int field0771; + private static int field0772; + private static int field0773; + private static int field0774; + private static int field0775; + private static int field0776; + private static int field0777; + private static int field0778; + private static int field0779; + private static int field0780; + private static int field0781; + private static int field0782; + private static int field0783; + private static int field0784; + private static int field0785; + private static int field0786; + private static int field0787; + private static int field0788; + private static int field0789; + private static int field0790; + private static int field0791; + private static int field0792; + private static int field0793; + private static int field0794; + private static int field0795; + private static int field0796; + private static int field0797; + private static int field0798; + private static int field0799; + private static int field0800; + private static int field0801; + private static int field0802; + private static int field0803; + private static int field0804; + private static int field0805; + private static int field0806; + private static int field0807; + private static int field0808; + private static int field0809; + private static int field0810; + private static int field0811; + private static int field0812; + private static int field0813; + private static int field0814; + private static int field0815; + private static int field0816; + private static int field0817; + private static int field0818; + private static int field0819; + private static int field0820; + private static int field0821; + private static int field0822; + private static int field0823; + private static int field0824; + private static int field0825; + private static int field0826; + private static int field0827; + private static int field0828; + private static int field0829; + private static int field0830; + private static int field0831; + private static int field0832; + private static int field0833; + private static int field0834; + private static int field0835; + private static int field0836; + private static int field0837; + private static int field0838; + private static int field0839; + private static int field0840; + private static int field0841; + private static int field0842; + private static int field0843; + private static int field0844; + private static int field0845; + private static int field0846; + private static int field0847; + private static int field0848; + private static int field0849; + private static int field0850; + private static int field0851; + private static int field0852; + private static int field0853; + private static int field0854; + private static int field0855; + private static int field0856; + private static int field0857; + private static int field0858; + private static int field0859; + private static int field0860; + private static int field0861; + private static int field0862; + private static int field0863; + private static int field0864; + private static int field0865; + private static int field0866; + private static int field0867; + private static int field0868; + private static int field0869; + private static int field0870; + private static int field0871; + private static int field0872; + private static int field0873; + private static int field0874; + private static int field0875; + private static int field0876; + private static int field0877; + private static int field0878; + private static int field0879; + private static int field0880; + private static int field0881; + private static int field0882; + private static int field0883; + private static int field0884; + private static int field0885; + private static int field0886; + private static int field0887; + private static int field0888; + private static int field0889; + private static int field0890; + private static int field0891; + private static int field0892; + private static int field0893; + private static int field0894; + private static int field0895; + private static int field0896; + private static int field0897; + private static int field0898; + private static int field0899; + private static int field0900; + private static int field0901; + private static int field0902; + private static int field0903; + private static int field0904; + private static int field0905; + private static int field0906; + private static int field0907; + private static int field0908; + private static int field0909; + private static int field0910; + private static int field0911; + private static int field0912; + private static int field0913; + private static int field0914; + private static int field0915; + private static int field0916; + private static int field0917; + private static int field0918; + private static int field0919; + private static int field0920; + private static int field0921; + private static int field0922; + private static int field0923; + private static int field0924; + private static int field0925; + private static int field0926; + private static int field0927; + private static int field0928; + private static int field0929; + private static int field0930; + private static int field0931; + private static int field0932; + private static int field0933; + private static int field0934; + private static int field0935; + private static int field0936; + private static int field0937; + private static int field0938; + private static int field0939; + private static int field0940; + private static int field0941; + private static int field0942; + private static int field0943; + private static int field0944; + private static int field0945; + private static int field0946; + private static int field0947; + private static int field0948; + private static int field0949; + private static int field0950; + private static int field0951; + private static int field0952; + private static int field0953; + private static int field0954; + private static int field0955; + private static int field0956; + private static int field0957; + private static int field0958; + private static int field0959; + private static int field0960; + private static int field0961; + private static int field0962; + private static int field0963; + private static int field0964; + private static int field0965; + private static int field0966; + private static int field0967; + private static int field0968; + private static int field0969; + private static int field0970; + private static int field0971; + private static int field0972; + private static int field0973; + private static int field0974; + private static int field0975; + private static int field0976; + private static int field0977; + private static int field0978; + private static int field0979; + private static int field0980; + private static int field0981; + private static int field0982; + private static int field0983; + private static int field0984; + private static int field0985; + private static int field0986; + private static int field0987; + private static int field0988; + private static int field0989; + private static int field0990; + private static int field0991; + private static int field0992; + private static int field0993; + private static int field0994; + private static int field0995; + private static int field0996; + private static int field0997; + private static int field0998; + private static int field0999; +} diff --git a/test/hotspot/jtreg/compiler/codegen/TestAntiDependenciesHighMemUsage2.java b/test/hotspot/jtreg/compiler/codegen/TestAntiDependenciesHighMemUsage2.java new file mode 100644 index 00000000000..3f7dbf9918b --- /dev/null +++ b/test/hotspot/jtreg/compiler/codegen/TestAntiDependenciesHighMemUsage2.java @@ -0,0 +1,8444 @@ +/* + * Copyright (c) 2024, 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 8333258 + * @summary C2: high memory usage in PhaseCFG::insert_anti_dependences() + * @run main/othervm -XX:CompileOnly=TestAntiDependenciesHighMemUsage2::test1 -XX:-ClipInlining + * -XX:-BackgroundCompilation -XX:-TieredCompilation -XX:-UseOnStackReplacement TestAntiDependenciesHighMemUsage2 + */ + +public class TestAntiDependenciesHighMemUsage2 { + + public static void main(String[] args) { + for (int i = 0; i < 20_000; i++) { + test1(); + } + } + + private static void test1_field0000() { + int v = field0000; + v += field0001; + v += field0002; + v += field0003; + v += field0004; + v += field0005; + v += field0006; + v += field0007; + v += field0008; + v += field0009; + v += field0010; + v += field0011; + v += field0012; + v += field0013; + v += field0014; + v += field0015; + v += field0016; + v += field0017; + v += field0018; + v += field0019; + v += field0020; + v += field0021; + v += field0022; + v += field0023; + v += field0024; + v += field0025; + v += field0026; + v += field0027; + v += field0028; + v += field0029; + v += field0030; + v += field0031; + v += field0032; + v += field0033; + v += field0034; + v += field0035; + v += field0036; + v += field0037; + v += field0038; + v += field0039; + v += field0040; + v += field0041; + v += field0042; + v += field0043; + v += field0044; + v += field0045; + v += field0046; + v += field0047; + v += field0048; + v += field0049; + field0049 = v; + } + + private static void test1_field0050() { + int v = field0050; + v += field0051; + v += field0052; + v += field0053; + v += field0054; + v += field0055; + v += field0056; + v += field0057; + v += field0058; + v += field0059; + v += field0060; + v += field0061; + v += field0062; + v += field0063; + v += field0064; + v += field0065; + v += field0066; + v += field0067; + v += field0068; + v += field0069; + v += field0070; + v += field0071; + v += field0072; + v += field0073; + v += field0074; + v += field0075; + v += field0076; + v += field0077; + v += field0078; + v += field0079; + v += field0080; + v += field0081; + v += field0082; + v += field0083; + v += field0084; + v += field0085; + v += field0086; + v += field0087; + v += field0088; + v += field0089; + v += field0090; + v += field0091; + v += field0092; + v += field0093; + v += field0094; + v += field0095; + v += field0096; + v += field0097; + v += field0098; + v += field0099; + field0099 = v; + } + + private static void test1_field0100() { + int v = field0100; + v += field0101; + v += field0102; + v += field0103; + v += field0104; + v += field0105; + v += field0106; + v += field0107; + v += field0108; + v += field0109; + v += field0110; + v += field0111; + v += field0112; + v += field0113; + v += field0114; + v += field0115; + v += field0116; + v += field0117; + v += field0118; + v += field0119; + v += field0120; + v += field0121; + v += field0122; + v += field0123; + v += field0124; + v += field0125; + v += field0126; + v += field0127; + v += field0128; + v += field0129; + v += field0130; + v += field0131; + v += field0132; + v += field0133; + v += field0134; + v += field0135; + v += field0136; + v += field0137; + v += field0138; + v += field0139; + v += field0140; + v += field0141; + v += field0142; + v += field0143; + v += field0144; + v += field0145; + v += field0146; + v += field0147; + v += field0148; + v += field0149; + field0149 = v; + } + + private static void test1_field0150() { + int v = field0150; + v += field0151; + v += field0152; + v += field0153; + v += field0154; + v += field0155; + v += field0156; + v += field0157; + v += field0158; + v += field0159; + v += field0160; + v += field0161; + v += field0162; + v += field0163; + v += field0164; + v += field0165; + v += field0166; + v += field0167; + v += field0168; + v += field0169; + v += field0170; + v += field0171; + v += field0172; + v += field0173; + v += field0174; + v += field0175; + v += field0176; + v += field0177; + v += field0178; + v += field0179; + v += field0180; + v += field0181; + v += field0182; + v += field0183; + v += field0184; + v += field0185; + v += field0186; + v += field0187; + v += field0188; + v += field0189; + v += field0190; + v += field0191; + v += field0192; + v += field0193; + v += field0194; + v += field0195; + v += field0196; + v += field0197; + v += field0198; + v += field0199; + field0199 = v; + } + + private static void test1_field0200() { + int v = field0200; + v += field0201; + v += field0202; + v += field0203; + v += field0204; + v += field0205; + v += field0206; + v += field0207; + v += field0208; + v += field0209; + v += field0210; + v += field0211; + v += field0212; + v += field0213; + v += field0214; + v += field0215; + v += field0216; + v += field0217; + v += field0218; + v += field0219; + v += field0220; + v += field0221; + v += field0222; + v += field0223; + v += field0224; + v += field0225; + v += field0226; + v += field0227; + v += field0228; + v += field0229; + v += field0230; + v += field0231; + v += field0232; + v += field0233; + v += field0234; + v += field0235; + v += field0236; + v += field0237; + v += field0238; + v += field0239; + v += field0240; + v += field0241; + v += field0242; + v += field0243; + v += field0244; + v += field0245; + v += field0246; + v += field0247; + v += field0248; + v += field0249; + field0249 = v; + } + + private static void test1_field0250() { + int v = field0250; + v += field0251; + v += field0252; + v += field0253; + v += field0254; + v += field0255; + v += field0256; + v += field0257; + v += field0258; + v += field0259; + v += field0260; + v += field0261; + v += field0262; + v += field0263; + v += field0264; + v += field0265; + v += field0266; + v += field0267; + v += field0268; + v += field0269; + v += field0270; + v += field0271; + v += field0272; + v += field0273; + v += field0274; + v += field0275; + v += field0276; + v += field0277; + v += field0278; + v += field0279; + v += field0280; + v += field0281; + v += field0282; + v += field0283; + v += field0284; + v += field0285; + v += field0286; + v += field0287; + v += field0288; + v += field0289; + v += field0290; + v += field0291; + v += field0292; + v += field0293; + v += field0294; + v += field0295; + v += field0296; + v += field0297; + v += field0298; + v += field0299; + field0299 = v; + } + + private static void test1_field0300() { + int v = field0300; + v += field0301; + v += field0302; + v += field0303; + v += field0304; + v += field0305; + v += field0306; + v += field0307; + v += field0308; + v += field0309; + v += field0310; + v += field0311; + v += field0312; + v += field0313; + v += field0314; + v += field0315; + v += field0316; + v += field0317; + v += field0318; + v += field0319; + v += field0320; + v += field0321; + v += field0322; + v += field0323; + v += field0324; + v += field0325; + v += field0326; + v += field0327; + v += field0328; + v += field0329; + v += field0330; + v += field0331; + v += field0332; + v += field0333; + v += field0334; + v += field0335; + v += field0336; + v += field0337; + v += field0338; + v += field0339; + v += field0340; + v += field0341; + v += field0342; + v += field0343; + v += field0344; + v += field0345; + v += field0346; + v += field0347; + v += field0348; + v += field0349; + field0349 = v; + } + + private static void test1_field0350() { + int v = field0350; + v += field0351; + v += field0352; + v += field0353; + v += field0354; + v += field0355; + v += field0356; + v += field0357; + v += field0358; + v += field0359; + v += field0360; + v += field0361; + v += field0362; + v += field0363; + v += field0364; + v += field0365; + v += field0366; + v += field0367; + v += field0368; + v += field0369; + v += field0370; + v += field0371; + v += field0372; + v += field0373; + v += field0374; + v += field0375; + v += field0376; + v += field0377; + v += field0378; + v += field0379; + v += field0380; + v += field0381; + v += field0382; + v += field0383; + v += field0384; + v += field0385; + v += field0386; + v += field0387; + v += field0388; + v += field0389; + v += field0390; + v += field0391; + v += field0392; + v += field0393; + v += field0394; + v += field0395; + v += field0396; + v += field0397; + v += field0398; + v += field0399; + field0399 = v; + } + + private static void test1_field0400() { + int v = field0400; + v += field0401; + v += field0402; + v += field0403; + v += field0404; + v += field0405; + v += field0406; + v += field0407; + v += field0408; + v += field0409; + v += field0410; + v += field0411; + v += field0412; + v += field0413; + v += field0414; + v += field0415; + v += field0416; + v += field0417; + v += field0418; + v += field0419; + v += field0420; + v += field0421; + v += field0422; + v += field0423; + v += field0424; + v += field0425; + v += field0426; + v += field0427; + v += field0428; + v += field0429; + v += field0430; + v += field0431; + v += field0432; + v += field0433; + v += field0434; + v += field0435; + v += field0436; + v += field0437; + v += field0438; + v += field0439; + v += field0440; + v += field0441; + v += field0442; + v += field0443; + v += field0444; + v += field0445; + v += field0446; + v += field0447; + v += field0448; + v += field0449; + field0449 = v; + } + + private static void test1_field0450() { + int v = field0450; + v += field0451; + v += field0452; + v += field0453; + v += field0454; + v += field0455; + v += field0456; + v += field0457; + v += field0458; + v += field0459; + v += field0460; + v += field0461; + v += field0462; + v += field0463; + v += field0464; + v += field0465; + v += field0466; + v += field0467; + v += field0468; + v += field0469; + v += field0470; + v += field0471; + v += field0472; + v += field0473; + v += field0474; + v += field0475; + v += field0476; + v += field0477; + v += field0478; + v += field0479; + v += field0480; + v += field0481; + v += field0482; + v += field0483; + v += field0484; + v += field0485; + v += field0486; + v += field0487; + v += field0488; + v += field0489; + v += field0490; + v += field0491; + v += field0492; + v += field0493; + v += field0494; + v += field0495; + v += field0496; + v += field0497; + v += field0498; + v += field0499; + field0499 = v; + } + + private static void test1_field0500() { + int v = field0500; + v += field0501; + v += field0502; + v += field0503; + v += field0504; + v += field0505; + v += field0506; + v += field0507; + v += field0508; + v += field0509; + v += field0510; + v += field0511; + v += field0512; + v += field0513; + v += field0514; + v += field0515; + v += field0516; + v += field0517; + v += field0518; + v += field0519; + v += field0520; + v += field0521; + v += field0522; + v += field0523; + v += field0524; + v += field0525; + v += field0526; + v += field0527; + v += field0528; + v += field0529; + v += field0530; + v += field0531; + v += field0532; + v += field0533; + v += field0534; + v += field0535; + v += field0536; + v += field0537; + v += field0538; + v += field0539; + v += field0540; + v += field0541; + v += field0542; + v += field0543; + v += field0544; + v += field0545; + v += field0546; + v += field0547; + v += field0548; + v += field0549; + field0549 = v; + } + + private static void test1_field0550() { + int v = field0550; + v += field0551; + v += field0552; + v += field0553; + v += field0554; + v += field0555; + v += field0556; + v += field0557; + v += field0558; + v += field0559; + v += field0560; + v += field0561; + v += field0562; + v += field0563; + v += field0564; + v += field0565; + v += field0566; + v += field0567; + v += field0568; + v += field0569; + v += field0570; + v += field0571; + v += field0572; + v += field0573; + v += field0574; + v += field0575; + v += field0576; + v += field0577; + v += field0578; + v += field0579; + v += field0580; + v += field0581; + v += field0582; + v += field0583; + v += field0584; + v += field0585; + v += field0586; + v += field0587; + v += field0588; + v += field0589; + v += field0590; + v += field0591; + v += field0592; + v += field0593; + v += field0594; + v += field0595; + v += field0596; + v += field0597; + v += field0598; + v += field0599; + field0599 = v; + } + + private static void test1_field0600() { + int v = field0600; + v += field0601; + v += field0602; + v += field0603; + v += field0604; + v += field0605; + v += field0606; + v += field0607; + v += field0608; + v += field0609; + v += field0610; + v += field0611; + v += field0612; + v += field0613; + v += field0614; + v += field0615; + v += field0616; + v += field0617; + v += field0618; + v += field0619; + v += field0620; + v += field0621; + v += field0622; + v += field0623; + v += field0624; + v += field0625; + v += field0626; + v += field0627; + v += field0628; + v += field0629; + v += field0630; + v += field0631; + v += field0632; + v += field0633; + v += field0634; + v += field0635; + v += field0636; + v += field0637; + v += field0638; + v += field0639; + v += field0640; + v += field0641; + v += field0642; + v += field0643; + v += field0644; + v += field0645; + v += field0646; + v += field0647; + v += field0648; + v += field0649; + field0649 = v; + } + + private static void test1_field0650() { + int v = field0650; + v += field0651; + v += field0652; + v += field0653; + v += field0654; + v += field0655; + v += field0656; + v += field0657; + v += field0658; + v += field0659; + v += field0660; + v += field0661; + v += field0662; + v += field0663; + v += field0664; + v += field0665; + v += field0666; + v += field0667; + v += field0668; + v += field0669; + v += field0670; + v += field0671; + v += field0672; + v += field0673; + v += field0674; + v += field0675; + v += field0676; + v += field0677; + v += field0678; + v += field0679; + v += field0680; + v += field0681; + v += field0682; + v += field0683; + v += field0684; + v += field0685; + v += field0686; + v += field0687; + v += field0688; + v += field0689; + v += field0690; + v += field0691; + v += field0692; + v += field0693; + v += field0694; + v += field0695; + v += field0696; + v += field0697; + v += field0698; + v += field0699; + field0699 = v; + } + + private static void test1_field0700() { + int v = field0700; + v += field0701; + v += field0702; + v += field0703; + v += field0704; + v += field0705; + v += field0706; + v += field0707; + v += field0708; + v += field0709; + v += field0710; + v += field0711; + v += field0712; + v += field0713; + v += field0714; + v += field0715; + v += field0716; + v += field0717; + v += field0718; + v += field0719; + v += field0720; + v += field0721; + v += field0722; + v += field0723; + v += field0724; + v += field0725; + v += field0726; + v += field0727; + v += field0728; + v += field0729; + v += field0730; + v += field0731; + v += field0732; + v += field0733; + v += field0734; + v += field0735; + v += field0736; + v += field0737; + v += field0738; + v += field0739; + v += field0740; + v += field0741; + v += field0742; + v += field0743; + v += field0744; + v += field0745; + v += field0746; + v += field0747; + v += field0748; + v += field0749; + field0749 = v; + } + + private static void test1_field0750() { + int v = field0750; + v += field0751; + v += field0752; + v += field0753; + v += field0754; + v += field0755; + v += field0756; + v += field0757; + v += field0758; + v += field0759; + v += field0760; + v += field0761; + v += field0762; + v += field0763; + v += field0764; + v += field0765; + v += field0766; + v += field0767; + v += field0768; + v += field0769; + v += field0770; + v += field0771; + v += field0772; + v += field0773; + v += field0774; + v += field0775; + v += field0776; + v += field0777; + v += field0778; + v += field0779; + v += field0780; + v += field0781; + v += field0782; + v += field0783; + v += field0784; + v += field0785; + v += field0786; + v += field0787; + v += field0788; + v += field0789; + v += field0790; + v += field0791; + v += field0792; + v += field0793; + v += field0794; + v += field0795; + v += field0796; + v += field0797; + v += field0798; + v += field0799; + field0799 = v; + } + + private static void test1_field0800() { + int v = field0800; + v += field0801; + v += field0802; + v += field0803; + v += field0804; + v += field0805; + v += field0806; + v += field0807; + v += field0808; + v += field0809; + v += field0810; + v += field0811; + v += field0812; + v += field0813; + v += field0814; + v += field0815; + v += field0816; + v += field0817; + v += field0818; + v += field0819; + v += field0820; + v += field0821; + v += field0822; + v += field0823; + v += field0824; + v += field0825; + v += field0826; + v += field0827; + v += field0828; + v += field0829; + v += field0830; + v += field0831; + v += field0832; + v += field0833; + v += field0834; + v += field0835; + v += field0836; + v += field0837; + v += field0838; + v += field0839; + v += field0840; + v += field0841; + v += field0842; + v += field0843; + v += field0844; + v += field0845; + v += field0846; + v += field0847; + v += field0848; + v += field0849; + field0849 = v; + } + + private static void test1_field0850() { + int v = field0850; + v += field0851; + v += field0852; + v += field0853; + v += field0854; + v += field0855; + v += field0856; + v += field0857; + v += field0858; + v += field0859; + v += field0860; + v += field0861; + v += field0862; + v += field0863; + v += field0864; + v += field0865; + v += field0866; + v += field0867; + v += field0868; + v += field0869; + v += field0870; + v += field0871; + v += field0872; + v += field0873; + v += field0874; + v += field0875; + v += field0876; + v += field0877; + v += field0878; + v += field0879; + v += field0880; + v += field0881; + v += field0882; + v += field0883; + v += field0884; + v += field0885; + v += field0886; + v += field0887; + v += field0888; + v += field0889; + v += field0890; + v += field0891; + v += field0892; + v += field0893; + v += field0894; + v += field0895; + v += field0896; + v += field0897; + v += field0898; + v += field0899; + field0899 = v; + } + + private static void test1_field0900() { + int v = field0900; + v += field0901; + v += field0902; + v += field0903; + v += field0904; + v += field0905; + v += field0906; + v += field0907; + v += field0908; + v += field0909; + v += field0910; + v += field0911; + v += field0912; + v += field0913; + v += field0914; + v += field0915; + v += field0916; + v += field0917; + v += field0918; + v += field0919; + v += field0920; + v += field0921; + v += field0922; + v += field0923; + v += field0924; + v += field0925; + v += field0926; + v += field0927; + v += field0928; + v += field0929; + v += field0930; + v += field0931; + v += field0932; + v += field0933; + v += field0934; + v += field0935; + v += field0936; + v += field0937; + v += field0938; + v += field0939; + v += field0940; + v += field0941; + v += field0942; + v += field0943; + v += field0944; + v += field0945; + v += field0946; + v += field0947; + v += field0948; + v += field0949; + field0949 = v; + } + + private static void test1_field0950() { + int v = field0950; + v += field0951; + v += field0952; + v += field0953; + v += field0954; + v += field0955; + v += field0956; + v += field0957; + v += field0958; + v += field0959; + v += field0960; + v += field0961; + v += field0962; + v += field0963; + v += field0964; + v += field0965; + v += field0966; + v += field0967; + v += field0968; + v += field0969; + v += field0970; + v += field0971; + v += field0972; + v += field0973; + v += field0974; + v += field0975; + v += field0976; + v += field0977; + v += field0978; + v += field0979; + v += field0980; + v += field0981; + v += field0982; + v += field0983; + v += field0984; + v += field0985; + v += field0986; + v += field0987; + v += field0988; + v += field0989; + v += field0990; + v += field0991; + v += field0992; + v += field0993; + v += field0994; + v += field0995; + v += field0996; + v += field0997; + v += field0998; + v += field0999; + field0999 = v; + } + + private static void test1_field1000() { + int v = field1000; + v += field1001; + v += field1002; + v += field1003; + v += field1004; + v += field1005; + v += field1006; + v += field1007; + v += field1008; + v += field1009; + v += field1010; + v += field1011; + v += field1012; + v += field1013; + v += field1014; + v += field1015; + v += field1016; + v += field1017; + v += field1018; + v += field1019; + v += field1020; + v += field1021; + v += field1022; + v += field1023; + v += field1024; + v += field1025; + v += field1026; + v += field1027; + v += field1028; + v += field1029; + v += field1030; + v += field1031; + v += field1032; + v += field1033; + v += field1034; + v += field1035; + v += field1036; + v += field1037; + v += field1038; + v += field1039; + v += field1040; + v += field1041; + v += field1042; + v += field1043; + v += field1044; + v += field1045; + v += field1046; + v += field1047; + v += field1048; + v += field1049; + field1049 = v; + } + + private static void test1_field1050() { + int v = field1050; + v += field1051; + v += field1052; + v += field1053; + v += field1054; + v += field1055; + v += field1056; + v += field1057; + v += field1058; + v += field1059; + v += field1060; + v += field1061; + v += field1062; + v += field1063; + v += field1064; + v += field1065; + v += field1066; + v += field1067; + v += field1068; + v += field1069; + v += field1070; + v += field1071; + v += field1072; + v += field1073; + v += field1074; + v += field1075; + v += field1076; + v += field1077; + v += field1078; + v += field1079; + v += field1080; + v += field1081; + v += field1082; + v += field1083; + v += field1084; + v += field1085; + v += field1086; + v += field1087; + v += field1088; + v += field1089; + v += field1090; + v += field1091; + v += field1092; + v += field1093; + v += field1094; + v += field1095; + v += field1096; + v += field1097; + v += field1098; + v += field1099; + field1099 = v; + } + + private static void test1_field1100() { + int v = field1100; + v += field1101; + v += field1102; + v += field1103; + v += field1104; + v += field1105; + v += field1106; + v += field1107; + v += field1108; + v += field1109; + v += field1110; + v += field1111; + v += field1112; + v += field1113; + v += field1114; + v += field1115; + v += field1116; + v += field1117; + v += field1118; + v += field1119; + v += field1120; + v += field1121; + v += field1122; + v += field1123; + v += field1124; + v += field1125; + v += field1126; + v += field1127; + v += field1128; + v += field1129; + v += field1130; + v += field1131; + v += field1132; + v += field1133; + v += field1134; + v += field1135; + v += field1136; + v += field1137; + v += field1138; + v += field1139; + v += field1140; + v += field1141; + v += field1142; + v += field1143; + v += field1144; + v += field1145; + v += field1146; + v += field1147; + v += field1148; + v += field1149; + field1149 = v; + } + + private static void test1_field1150() { + int v = field1150; + v += field1151; + v += field1152; + v += field1153; + v += field1154; + v += field1155; + v += field1156; + v += field1157; + v += field1158; + v += field1159; + v += field1160; + v += field1161; + v += field1162; + v += field1163; + v += field1164; + v += field1165; + v += field1166; + v += field1167; + v += field1168; + v += field1169; + v += field1170; + v += field1171; + v += field1172; + v += field1173; + v += field1174; + v += field1175; + v += field1176; + v += field1177; + v += field1178; + v += field1179; + v += field1180; + v += field1181; + v += field1182; + v += field1183; + v += field1184; + v += field1185; + v += field1186; + v += field1187; + v += field1188; + v += field1189; + v += field1190; + v += field1191; + v += field1192; + v += field1193; + v += field1194; + v += field1195; + v += field1196; + v += field1197; + v += field1198; + v += field1199; + field1199 = v; + } + + private static void test1_field1200() { + int v = field1200; + v += field1201; + v += field1202; + v += field1203; + v += field1204; + v += field1205; + v += field1206; + v += field1207; + v += field1208; + v += field1209; + v += field1210; + v += field1211; + v += field1212; + v += field1213; + v += field1214; + v += field1215; + v += field1216; + v += field1217; + v += field1218; + v += field1219; + v += field1220; + v += field1221; + v += field1222; + v += field1223; + v += field1224; + v += field1225; + v += field1226; + v += field1227; + v += field1228; + v += field1229; + v += field1230; + v += field1231; + v += field1232; + v += field1233; + v += field1234; + v += field1235; + v += field1236; + v += field1237; + v += field1238; + v += field1239; + v += field1240; + v += field1241; + v += field1242; + v += field1243; + v += field1244; + v += field1245; + v += field1246; + v += field1247; + v += field1248; + v += field1249; + field1249 = v; + } + + private static void test1_field1250() { + int v = field1250; + v += field1251; + v += field1252; + v += field1253; + v += field1254; + v += field1255; + v += field1256; + v += field1257; + v += field1258; + v += field1259; + v += field1260; + v += field1261; + v += field1262; + v += field1263; + v += field1264; + v += field1265; + v += field1266; + v += field1267; + v += field1268; + v += field1269; + v += field1270; + v += field1271; + v += field1272; + v += field1273; + v += field1274; + v += field1275; + v += field1276; + v += field1277; + v += field1278; + v += field1279; + v += field1280; + v += field1281; + v += field1282; + v += field1283; + v += field1284; + v += field1285; + v += field1286; + v += field1287; + v += field1288; + v += field1289; + v += field1290; + v += field1291; + v += field1292; + v += field1293; + v += field1294; + v += field1295; + v += field1296; + v += field1297; + v += field1298; + v += field1299; + field1299 = v; + } + + private static void test1_field1300() { + int v = field1300; + v += field1301; + v += field1302; + v += field1303; + v += field1304; + v += field1305; + v += field1306; + v += field1307; + v += field1308; + v += field1309; + v += field1310; + v += field1311; + v += field1312; + v += field1313; + v += field1314; + v += field1315; + v += field1316; + v += field1317; + v += field1318; + v += field1319; + v += field1320; + v += field1321; + v += field1322; + v += field1323; + v += field1324; + v += field1325; + v += field1326; + v += field1327; + v += field1328; + v += field1329; + v += field1330; + v += field1331; + v += field1332; + v += field1333; + v += field1334; + v += field1335; + v += field1336; + v += field1337; + v += field1338; + v += field1339; + v += field1340; + v += field1341; + v += field1342; + v += field1343; + v += field1344; + v += field1345; + v += field1346; + v += field1347; + v += field1348; + v += field1349; + field1349 = v; + } + + private static void test1_field1350() { + int v = field1350; + v += field1351; + v += field1352; + v += field1353; + v += field1354; + v += field1355; + v += field1356; + v += field1357; + v += field1358; + v += field1359; + v += field1360; + v += field1361; + v += field1362; + v += field1363; + v += field1364; + v += field1365; + v += field1366; + v += field1367; + v += field1368; + v += field1369; + v += field1370; + v += field1371; + v += field1372; + v += field1373; + v += field1374; + v += field1375; + v += field1376; + v += field1377; + v += field1378; + v += field1379; + v += field1380; + v += field1381; + v += field1382; + v += field1383; + v += field1384; + v += field1385; + v += field1386; + v += field1387; + v += field1388; + v += field1389; + v += field1390; + v += field1391; + v += field1392; + v += field1393; + v += field1394; + v += field1395; + v += field1396; + v += field1397; + v += field1398; + v += field1399; + field1399 = v; + } + + private static void test1_field1400() { + int v = field1400; + v += field1401; + v += field1402; + v += field1403; + v += field1404; + v += field1405; + v += field1406; + v += field1407; + v += field1408; + v += field1409; + v += field1410; + v += field1411; + v += field1412; + v += field1413; + v += field1414; + v += field1415; + v += field1416; + v += field1417; + v += field1418; + v += field1419; + v += field1420; + v += field1421; + v += field1422; + v += field1423; + v += field1424; + v += field1425; + v += field1426; + v += field1427; + v += field1428; + v += field1429; + v += field1430; + v += field1431; + v += field1432; + v += field1433; + v += field1434; + v += field1435; + v += field1436; + v += field1437; + v += field1438; + v += field1439; + v += field1440; + v += field1441; + v += field1442; + v += field1443; + v += field1444; + v += field1445; + v += field1446; + v += field1447; + v += field1448; + v += field1449; + field1449 = v; + } + + private static void test1_field1450() { + int v = field1450; + v += field1451; + v += field1452; + v += field1453; + v += field1454; + v += field1455; + v += field1456; + v += field1457; + v += field1458; + v += field1459; + v += field1460; + v += field1461; + v += field1462; + v += field1463; + v += field1464; + v += field1465; + v += field1466; + v += field1467; + v += field1468; + v += field1469; + v += field1470; + v += field1471; + v += field1472; + v += field1473; + v += field1474; + v += field1475; + v += field1476; + v += field1477; + v += field1478; + v += field1479; + v += field1480; + v += field1481; + v += field1482; + v += field1483; + v += field1484; + v += field1485; + v += field1486; + v += field1487; + v += field1488; + v += field1489; + v += field1490; + v += field1491; + v += field1492; + v += field1493; + v += field1494; + v += field1495; + v += field1496; + v += field1497; + v += field1498; + v += field1499; + field1499 = v; + } + + private static void test1_field1500() { + int v = field1500; + v += field1501; + v += field1502; + v += field1503; + v += field1504; + v += field1505; + v += field1506; + v += field1507; + v += field1508; + v += field1509; + v += field1510; + v += field1511; + v += field1512; + v += field1513; + v += field1514; + v += field1515; + v += field1516; + v += field1517; + v += field1518; + v += field1519; + v += field1520; + v += field1521; + v += field1522; + v += field1523; + v += field1524; + v += field1525; + v += field1526; + v += field1527; + v += field1528; + v += field1529; + v += field1530; + v += field1531; + v += field1532; + v += field1533; + v += field1534; + v += field1535; + v += field1536; + v += field1537; + v += field1538; + v += field1539; + v += field1540; + v += field1541; + v += field1542; + v += field1543; + v += field1544; + v += field1545; + v += field1546; + v += field1547; + v += field1548; + v += field1549; + field1549 = v; + } + + private static void test1_field1550() { + int v = field1550; + v += field1551; + v += field1552; + v += field1553; + v += field1554; + v += field1555; + v += field1556; + v += field1557; + v += field1558; + v += field1559; + v += field1560; + v += field1561; + v += field1562; + v += field1563; + v += field1564; + v += field1565; + v += field1566; + v += field1567; + v += field1568; + v += field1569; + v += field1570; + v += field1571; + v += field1572; + v += field1573; + v += field1574; + v += field1575; + v += field1576; + v += field1577; + v += field1578; + v += field1579; + v += field1580; + v += field1581; + v += field1582; + v += field1583; + v += field1584; + v += field1585; + v += field1586; + v += field1587; + v += field1588; + v += field1589; + v += field1590; + v += field1591; + v += field1592; + v += field1593; + v += field1594; + v += field1595; + v += field1596; + v += field1597; + v += field1598; + v += field1599; + field1599 = v; + } + + private static void test1_field1600() { + int v = field1600; + v += field1601; + v += field1602; + v += field1603; + v += field1604; + v += field1605; + v += field1606; + v += field1607; + v += field1608; + v += field1609; + v += field1610; + v += field1611; + v += field1612; + v += field1613; + v += field1614; + v += field1615; + v += field1616; + v += field1617; + v += field1618; + v += field1619; + v += field1620; + v += field1621; + v += field1622; + v += field1623; + v += field1624; + v += field1625; + v += field1626; + v += field1627; + v += field1628; + v += field1629; + v += field1630; + v += field1631; + v += field1632; + v += field1633; + v += field1634; + v += field1635; + v += field1636; + v += field1637; + v += field1638; + v += field1639; + v += field1640; + v += field1641; + v += field1642; + v += field1643; + v += field1644; + v += field1645; + v += field1646; + v += field1647; + v += field1648; + v += field1649; + field1649 = v; + } + + private static void test1_field1650() { + int v = field1650; + v += field1651; + v += field1652; + v += field1653; + v += field1654; + v += field1655; + v += field1656; + v += field1657; + v += field1658; + v += field1659; + v += field1660; + v += field1661; + v += field1662; + v += field1663; + v += field1664; + v += field1665; + v += field1666; + v += field1667; + v += field1668; + v += field1669; + v += field1670; + v += field1671; + v += field1672; + v += field1673; + v += field1674; + v += field1675; + v += field1676; + v += field1677; + v += field1678; + v += field1679; + v += field1680; + v += field1681; + v += field1682; + v += field1683; + v += field1684; + v += field1685; + v += field1686; + v += field1687; + v += field1688; + v += field1689; + v += field1690; + v += field1691; + v += field1692; + v += field1693; + v += field1694; + v += field1695; + v += field1696; + v += field1697; + v += field1698; + v += field1699; + field1699 = v; + } + + private static void test1_field1700() { + int v = field1700; + v += field1701; + v += field1702; + v += field1703; + v += field1704; + v += field1705; + v += field1706; + v += field1707; + v += field1708; + v += field1709; + v += field1710; + v += field1711; + v += field1712; + v += field1713; + v += field1714; + v += field1715; + v += field1716; + v += field1717; + v += field1718; + v += field1719; + v += field1720; + v += field1721; + v += field1722; + v += field1723; + v += field1724; + v += field1725; + v += field1726; + v += field1727; + v += field1728; + v += field1729; + v += field1730; + v += field1731; + v += field1732; + v += field1733; + v += field1734; + v += field1735; + v += field1736; + v += field1737; + v += field1738; + v += field1739; + v += field1740; + v += field1741; + v += field1742; + v += field1743; + v += field1744; + v += field1745; + v += field1746; + v += field1747; + v += field1748; + v += field1749; + field1749 = v; + } + + private static void test1_field1750() { + int v = field1750; + v += field1751; + v += field1752; + v += field1753; + v += field1754; + v += field1755; + v += field1756; + v += field1757; + v += field1758; + v += field1759; + v += field1760; + v += field1761; + v += field1762; + v += field1763; + v += field1764; + v += field1765; + v += field1766; + v += field1767; + v += field1768; + v += field1769; + v += field1770; + v += field1771; + v += field1772; + v += field1773; + v += field1774; + v += field1775; + v += field1776; + v += field1777; + v += field1778; + v += field1779; + v += field1780; + v += field1781; + v += field1782; + v += field1783; + v += field1784; + v += field1785; + v += field1786; + v += field1787; + v += field1788; + v += field1789; + v += field1790; + v += field1791; + v += field1792; + v += field1793; + v += field1794; + v += field1795; + v += field1796; + v += field1797; + v += field1798; + v += field1799; + field1799 = v; + } + + private static void test1_field1800() { + int v = field1800; + v += field1801; + v += field1802; + v += field1803; + v += field1804; + v += field1805; + v += field1806; + v += field1807; + v += field1808; + v += field1809; + v += field1810; + v += field1811; + v += field1812; + v += field1813; + v += field1814; + v += field1815; + v += field1816; + v += field1817; + v += field1818; + v += field1819; + v += field1820; + v += field1821; + v += field1822; + v += field1823; + v += field1824; + v += field1825; + v += field1826; + v += field1827; + v += field1828; + v += field1829; + v += field1830; + v += field1831; + v += field1832; + v += field1833; + v += field1834; + v += field1835; + v += field1836; + v += field1837; + v += field1838; + v += field1839; + v += field1840; + v += field1841; + v += field1842; + v += field1843; + v += field1844; + v += field1845; + v += field1846; + v += field1847; + v += field1848; + v += field1849; + field1849 = v; + } + + private static void test1_field1850() { + int v = field1850; + v += field1851; + v += field1852; + v += field1853; + v += field1854; + v += field1855; + v += field1856; + v += field1857; + v += field1858; + v += field1859; + v += field1860; + v += field1861; + v += field1862; + v += field1863; + v += field1864; + v += field1865; + v += field1866; + v += field1867; + v += field1868; + v += field1869; + v += field1870; + v += field1871; + v += field1872; + v += field1873; + v += field1874; + v += field1875; + v += field1876; + v += field1877; + v += field1878; + v += field1879; + v += field1880; + v += field1881; + v += field1882; + v += field1883; + v += field1884; + v += field1885; + v += field1886; + v += field1887; + v += field1888; + v += field1889; + v += field1890; + v += field1891; + v += field1892; + v += field1893; + v += field1894; + v += field1895; + v += field1896; + v += field1897; + v += field1898; + v += field1899; + field1899 = v; + } + + private static void test1_field1900() { + int v = field1900; + v += field1901; + v += field1902; + v += field1903; + v += field1904; + v += field1905; + v += field1906; + v += field1907; + v += field1908; + v += field1909; + v += field1910; + v += field1911; + v += field1912; + v += field1913; + v += field1914; + v += field1915; + v += field1916; + v += field1917; + v += field1918; + v += field1919; + v += field1920; + v += field1921; + v += field1922; + v += field1923; + v += field1924; + v += field1925; + v += field1926; + v += field1927; + v += field1928; + v += field1929; + v += field1930; + v += field1931; + v += field1932; + v += field1933; + v += field1934; + v += field1935; + v += field1936; + v += field1937; + v += field1938; + v += field1939; + v += field1940; + v += field1941; + v += field1942; + v += field1943; + v += field1944; + v += field1945; + v += field1946; + v += field1947; + v += field1948; + v += field1949; + field1949 = v; + } + + private static void test1_field1950() { + int v = field1950; + v += field1951; + v += field1952; + v += field1953; + v += field1954; + v += field1955; + v += field1956; + v += field1957; + v += field1958; + v += field1959; + v += field1960; + v += field1961; + v += field1962; + v += field1963; + v += field1964; + v += field1965; + v += field1966; + v += field1967; + v += field1968; + v += field1969; + v += field1970; + v += field1971; + v += field1972; + v += field1973; + v += field1974; + v += field1975; + v += field1976; + v += field1977; + v += field1978; + v += field1979; + v += field1980; + v += field1981; + v += field1982; + v += field1983; + v += field1984; + v += field1985; + v += field1986; + v += field1987; + v += field1988; + v += field1989; + v += field1990; + v += field1991; + v += field1992; + v += field1993; + v += field1994; + v += field1995; + v += field1996; + v += field1997; + v += field1998; + v += field1999; + field1999 = v; + } + + private static void test1_field2000() { + int v = field2000; + v += field2001; + v += field2002; + v += field2003; + v += field2004; + v += field2005; + v += field2006; + v += field2007; + v += field2008; + v += field2009; + v += field2010; + v += field2011; + v += field2012; + v += field2013; + v += field2014; + v += field2015; + v += field2016; + v += field2017; + v += field2018; + v += field2019; + v += field2020; + v += field2021; + v += field2022; + v += field2023; + v += field2024; + v += field2025; + v += field2026; + v += field2027; + v += field2028; + v += field2029; + v += field2030; + v += field2031; + v += field2032; + v += field2033; + v += field2034; + v += field2035; + v += field2036; + v += field2037; + v += field2038; + v += field2039; + v += field2040; + v += field2041; + v += field2042; + v += field2043; + v += field2044; + v += field2045; + v += field2046; + v += field2047; + v += field2048; + v += field2049; + field2049 = v; + } + + private static void test1_field2050() { + int v = field2050; + v += field2051; + v += field2052; + v += field2053; + v += field2054; + v += field2055; + v += field2056; + v += field2057; + v += field2058; + v += field2059; + v += field2060; + v += field2061; + v += field2062; + v += field2063; + v += field2064; + v += field2065; + v += field2066; + v += field2067; + v += field2068; + v += field2069; + v += field2070; + v += field2071; + v += field2072; + v += field2073; + v += field2074; + v += field2075; + v += field2076; + v += field2077; + v += field2078; + v += field2079; + v += field2080; + v += field2081; + v += field2082; + v += field2083; + v += field2084; + v += field2085; + v += field2086; + v += field2087; + v += field2088; + v += field2089; + v += field2090; + v += field2091; + v += field2092; + v += field2093; + v += field2094; + v += field2095; + v += field2096; + v += field2097; + v += field2098; + v += field2099; + field2099 = v; + } + + private static void test1_field2100() { + int v = field2100; + v += field2101; + v += field2102; + v += field2103; + v += field2104; + v += field2105; + v += field2106; + v += field2107; + v += field2108; + v += field2109; + v += field2110; + v += field2111; + v += field2112; + v += field2113; + v += field2114; + v += field2115; + v += field2116; + v += field2117; + v += field2118; + v += field2119; + v += field2120; + v += field2121; + v += field2122; + v += field2123; + v += field2124; + v += field2125; + v += field2126; + v += field2127; + v += field2128; + v += field2129; + v += field2130; + v += field2131; + v += field2132; + v += field2133; + v += field2134; + v += field2135; + v += field2136; + v += field2137; + v += field2138; + v += field2139; + v += field2140; + v += field2141; + v += field2142; + v += field2143; + v += field2144; + v += field2145; + v += field2146; + v += field2147; + v += field2148; + v += field2149; + field2149 = v; + } + + private static void test1_field2150() { + int v = field2150; + v += field2151; + v += field2152; + v += field2153; + v += field2154; + v += field2155; + v += field2156; + v += field2157; + v += field2158; + v += field2159; + v += field2160; + v += field2161; + v += field2162; + v += field2163; + v += field2164; + v += field2165; + v += field2166; + v += field2167; + v += field2168; + v += field2169; + v += field2170; + v += field2171; + v += field2172; + v += field2173; + v += field2174; + v += field2175; + v += field2176; + v += field2177; + v += field2178; + v += field2179; + v += field2180; + v += field2181; + v += field2182; + v += field2183; + v += field2184; + v += field2185; + v += field2186; + v += field2187; + v += field2188; + v += field2189; + v += field2190; + v += field2191; + v += field2192; + v += field2193; + v += field2194; + v += field2195; + v += field2196; + v += field2197; + v += field2198; + v += field2199; + field2199 = v; + } + + private static void test1_field2200() { + int v = field2200; + v += field2201; + v += field2202; + v += field2203; + v += field2204; + v += field2205; + v += field2206; + v += field2207; + v += field2208; + v += field2209; + v += field2210; + v += field2211; + v += field2212; + v += field2213; + v += field2214; + v += field2215; + v += field2216; + v += field2217; + v += field2218; + v += field2219; + v += field2220; + v += field2221; + v += field2222; + v += field2223; + v += field2224; + v += field2225; + v += field2226; + v += field2227; + v += field2228; + v += field2229; + v += field2230; + v += field2231; + v += field2232; + v += field2233; + v += field2234; + v += field2235; + v += field2236; + v += field2237; + v += field2238; + v += field2239; + v += field2240; + v += field2241; + v += field2242; + v += field2243; + v += field2244; + v += field2245; + v += field2246; + v += field2247; + v += field2248; + v += field2249; + field2249 = v; + } + + private static void test1_field2250() { + int v = field2250; + v += field2251; + v += field2252; + v += field2253; + v += field2254; + v += field2255; + v += field2256; + v += field2257; + v += field2258; + v += field2259; + v += field2260; + v += field2261; + v += field2262; + v += field2263; + v += field2264; + v += field2265; + v += field2266; + v += field2267; + v += field2268; + v += field2269; + v += field2270; + v += field2271; + v += field2272; + v += field2273; + v += field2274; + v += field2275; + v += field2276; + v += field2277; + v += field2278; + v += field2279; + v += field2280; + v += field2281; + v += field2282; + v += field2283; + v += field2284; + v += field2285; + v += field2286; + v += field2287; + v += field2288; + v += field2289; + v += field2290; + v += field2291; + v += field2292; + v += field2293; + v += field2294; + v += field2295; + v += field2296; + v += field2297; + v += field2298; + v += field2299; + field2299 = v; + } + + private static void test1_field2300() { + int v = field2300; + v += field2301; + v += field2302; + v += field2303; + v += field2304; + v += field2305; + v += field2306; + v += field2307; + v += field2308; + v += field2309; + v += field2310; + v += field2311; + v += field2312; + v += field2313; + v += field2314; + v += field2315; + v += field2316; + v += field2317; + v += field2318; + v += field2319; + v += field2320; + v += field2321; + v += field2322; + v += field2323; + v += field2324; + v += field2325; + v += field2326; + v += field2327; + v += field2328; + v += field2329; + v += field2330; + v += field2331; + v += field2332; + v += field2333; + v += field2334; + v += field2335; + v += field2336; + v += field2337; + v += field2338; + v += field2339; + v += field2340; + v += field2341; + v += field2342; + v += field2343; + v += field2344; + v += field2345; + v += field2346; + v += field2347; + v += field2348; + v += field2349; + field2349 = v; + } + + private static void test1_field2350() { + int v = field2350; + v += field2351; + v += field2352; + v += field2353; + v += field2354; + v += field2355; + v += field2356; + v += field2357; + v += field2358; + v += field2359; + v += field2360; + v += field2361; + v += field2362; + v += field2363; + v += field2364; + v += field2365; + v += field2366; + v += field2367; + v += field2368; + v += field2369; + v += field2370; + v += field2371; + v += field2372; + v += field2373; + v += field2374; + v += field2375; + v += field2376; + v += field2377; + v += field2378; + v += field2379; + v += field2380; + v += field2381; + v += field2382; + v += field2383; + v += field2384; + v += field2385; + v += field2386; + v += field2387; + v += field2388; + v += field2389; + v += field2390; + v += field2391; + v += field2392; + v += field2393; + v += field2394; + v += field2395; + v += field2396; + v += field2397; + v += field2398; + v += field2399; + field2399 = v; + } + + private static void test1_field2400() { + int v = field2400; + v += field2401; + v += field2402; + v += field2403; + v += field2404; + v += field2405; + v += field2406; + v += field2407; + v += field2408; + v += field2409; + v += field2410; + v += field2411; + v += field2412; + v += field2413; + v += field2414; + v += field2415; + v += field2416; + v += field2417; + v += field2418; + v += field2419; + v += field2420; + v += field2421; + v += field2422; + v += field2423; + v += field2424; + v += field2425; + v += field2426; + v += field2427; + v += field2428; + v += field2429; + v += field2430; + v += field2431; + v += field2432; + v += field2433; + v += field2434; + v += field2435; + v += field2436; + v += field2437; + v += field2438; + v += field2439; + v += field2440; + v += field2441; + v += field2442; + v += field2443; + v += field2444; + v += field2445; + v += field2446; + v += field2447; + v += field2448; + v += field2449; + field2449 = v; + } + + private static void test1_field2450() { + int v = field2450; + v += field2451; + v += field2452; + v += field2453; + v += field2454; + v += field2455; + v += field2456; + v += field2457; + v += field2458; + v += field2459; + v += field2460; + v += field2461; + v += field2462; + v += field2463; + v += field2464; + v += field2465; + v += field2466; + v += field2467; + v += field2468; + v += field2469; + v += field2470; + v += field2471; + v += field2472; + v += field2473; + v += field2474; + v += field2475; + v += field2476; + v += field2477; + v += field2478; + v += field2479; + v += field2480; + v += field2481; + v += field2482; + v += field2483; + v += field2484; + v += field2485; + v += field2486; + v += field2487; + v += field2488; + v += field2489; + v += field2490; + v += field2491; + v += field2492; + v += field2493; + v += field2494; + v += field2495; + v += field2496; + v += field2497; + v += field2498; + v += field2499; + field2499 = v; + } + + private static void test1_field2500() { + int v = field2500; + v += field2501; + v += field2502; + v += field2503; + v += field2504; + v += field2505; + v += field2506; + v += field2507; + v += field2508; + v += field2509; + v += field2510; + v += field2511; + v += field2512; + v += field2513; + v += field2514; + v += field2515; + v += field2516; + v += field2517; + v += field2518; + v += field2519; + v += field2520; + v += field2521; + v += field2522; + v += field2523; + v += field2524; + v += field2525; + v += field2526; + v += field2527; + v += field2528; + v += field2529; + v += field2530; + v += field2531; + v += field2532; + v += field2533; + v += field2534; + v += field2535; + v += field2536; + v += field2537; + v += field2538; + v += field2539; + v += field2540; + v += field2541; + v += field2542; + v += field2543; + v += field2544; + v += field2545; + v += field2546; + v += field2547; + v += field2548; + v += field2549; + field2549 = v; + } + + private static void test1_field2550() { + int v = field2550; + v += field2551; + v += field2552; + v += field2553; + v += field2554; + v += field2555; + v += field2556; + v += field2557; + v += field2558; + v += field2559; + v += field2560; + v += field2561; + v += field2562; + v += field2563; + v += field2564; + v += field2565; + v += field2566; + v += field2567; + v += field2568; + v += field2569; + v += field2570; + v += field2571; + v += field2572; + v += field2573; + v += field2574; + v += field2575; + v += field2576; + v += field2577; + v += field2578; + v += field2579; + v += field2580; + v += field2581; + v += field2582; + v += field2583; + v += field2584; + v += field2585; + v += field2586; + v += field2587; + v += field2588; + v += field2589; + v += field2590; + v += field2591; + v += field2592; + v += field2593; + v += field2594; + v += field2595; + v += field2596; + v += field2597; + v += field2598; + v += field2599; + field2599 = v; + } + + private static void test1_field2600() { + int v = field2600; + v += field2601; + v += field2602; + v += field2603; + v += field2604; + v += field2605; + v += field2606; + v += field2607; + v += field2608; + v += field2609; + v += field2610; + v += field2611; + v += field2612; + v += field2613; + v += field2614; + v += field2615; + v += field2616; + v += field2617; + v += field2618; + v += field2619; + v += field2620; + v += field2621; + v += field2622; + v += field2623; + v += field2624; + v += field2625; + v += field2626; + v += field2627; + v += field2628; + v += field2629; + v += field2630; + v += field2631; + v += field2632; + v += field2633; + v += field2634; + v += field2635; + v += field2636; + v += field2637; + v += field2638; + v += field2639; + v += field2640; + v += field2641; + v += field2642; + v += field2643; + v += field2644; + v += field2645; + v += field2646; + v += field2647; + v += field2648; + v += field2649; + field2649 = v; + } + + private static void test1_field2650() { + int v = field2650; + v += field2651; + v += field2652; + v += field2653; + v += field2654; + v += field2655; + v += field2656; + v += field2657; + v += field2658; + v += field2659; + v += field2660; + v += field2661; + v += field2662; + v += field2663; + v += field2664; + v += field2665; + v += field2666; + v += field2667; + v += field2668; + v += field2669; + v += field2670; + v += field2671; + v += field2672; + v += field2673; + v += field2674; + v += field2675; + v += field2676; + v += field2677; + v += field2678; + v += field2679; + v += field2680; + v += field2681; + v += field2682; + v += field2683; + v += field2684; + v += field2685; + v += field2686; + v += field2687; + v += field2688; + v += field2689; + v += field2690; + v += field2691; + v += field2692; + v += field2693; + v += field2694; + v += field2695; + v += field2696; + v += field2697; + v += field2698; + v += field2699; + field2699 = v; + } + + private static void test1_field2700() { + int v = field2700; + v += field2701; + v += field2702; + v += field2703; + v += field2704; + v += field2705; + v += field2706; + v += field2707; + v += field2708; + v += field2709; + v += field2710; + v += field2711; + v += field2712; + v += field2713; + v += field2714; + v += field2715; + v += field2716; + v += field2717; + v += field2718; + v += field2719; + v += field2720; + v += field2721; + v += field2722; + v += field2723; + v += field2724; + v += field2725; + v += field2726; + v += field2727; + v += field2728; + v += field2729; + v += field2730; + v += field2731; + v += field2732; + v += field2733; + v += field2734; + v += field2735; + v += field2736; + v += field2737; + v += field2738; + v += field2739; + v += field2740; + v += field2741; + v += field2742; + v += field2743; + v += field2744; + v += field2745; + v += field2746; + v += field2747; + v += field2748; + v += field2749; + field2749 = v; + } + + private static void test1_field2750() { + int v = field2750; + v += field2751; + v += field2752; + v += field2753; + v += field2754; + v += field2755; + v += field2756; + v += field2757; + v += field2758; + v += field2759; + v += field2760; + v += field2761; + v += field2762; + v += field2763; + v += field2764; + v += field2765; + v += field2766; + v += field2767; + v += field2768; + v += field2769; + v += field2770; + v += field2771; + v += field2772; + v += field2773; + v += field2774; + v += field2775; + v += field2776; + v += field2777; + v += field2778; + v += field2779; + v += field2780; + v += field2781; + v += field2782; + v += field2783; + v += field2784; + v += field2785; + v += field2786; + v += field2787; + v += field2788; + v += field2789; + v += field2790; + v += field2791; + v += field2792; + v += field2793; + v += field2794; + v += field2795; + v += field2796; + v += field2797; + v += field2798; + v += field2799; + field2799 = v; + } + + private static void test1_field2800() { + int v = field2800; + v += field2801; + v += field2802; + v += field2803; + v += field2804; + v += field2805; + v += field2806; + v += field2807; + v += field2808; + v += field2809; + v += field2810; + v += field2811; + v += field2812; + v += field2813; + v += field2814; + v += field2815; + v += field2816; + v += field2817; + v += field2818; + v += field2819; + v += field2820; + v += field2821; + v += field2822; + v += field2823; + v += field2824; + v += field2825; + v += field2826; + v += field2827; + v += field2828; + v += field2829; + v += field2830; + v += field2831; + v += field2832; + v += field2833; + v += field2834; + v += field2835; + v += field2836; + v += field2837; + v += field2838; + v += field2839; + v += field2840; + v += field2841; + v += field2842; + v += field2843; + v += field2844; + v += field2845; + v += field2846; + v += field2847; + v += field2848; + v += field2849; + field2849 = v; + } + + private static void test1_field2850() { + int v = field2850; + v += field2851; + v += field2852; + v += field2853; + v += field2854; + v += field2855; + v += field2856; + v += field2857; + v += field2858; + v += field2859; + v += field2860; + v += field2861; + v += field2862; + v += field2863; + v += field2864; + v += field2865; + v += field2866; + v += field2867; + v += field2868; + v += field2869; + v += field2870; + v += field2871; + v += field2872; + v += field2873; + v += field2874; + v += field2875; + v += field2876; + v += field2877; + v += field2878; + v += field2879; + v += field2880; + v += field2881; + v += field2882; + v += field2883; + v += field2884; + v += field2885; + v += field2886; + v += field2887; + v += field2888; + v += field2889; + v += field2890; + v += field2891; + v += field2892; + v += field2893; + v += field2894; + v += field2895; + v += field2896; + v += field2897; + v += field2898; + v += field2899; + field2899 = v; + } + + private static void test1_field2900() { + int v = field2900; + v += field2901; + v += field2902; + v += field2903; + v += field2904; + v += field2905; + v += field2906; + v += field2907; + v += field2908; + v += field2909; + v += field2910; + v += field2911; + v += field2912; + v += field2913; + v += field2914; + v += field2915; + v += field2916; + v += field2917; + v += field2918; + v += field2919; + v += field2920; + v += field2921; + v += field2922; + v += field2923; + v += field2924; + v += field2925; + v += field2926; + v += field2927; + v += field2928; + v += field2929; + v += field2930; + v += field2931; + v += field2932; + v += field2933; + v += field2934; + v += field2935; + v += field2936; + v += field2937; + v += field2938; + v += field2939; + v += field2940; + v += field2941; + v += field2942; + v += field2943; + v += field2944; + v += field2945; + v += field2946; + v += field2947; + v += field2948; + v += field2949; + field2949 = v; + } + + private static void test1_field2950() { + int v = field2950; + v += field2951; + v += field2952; + v += field2953; + v += field2954; + v += field2955; + v += field2956; + v += field2957; + v += field2958; + v += field2959; + v += field2960; + v += field2961; + v += field2962; + v += field2963; + v += field2964; + v += field2965; + v += field2966; + v += field2967; + v += field2968; + v += field2969; + v += field2970; + v += field2971; + v += field2972; + v += field2973; + v += field2974; + v += field2975; + v += field2976; + v += field2977; + v += field2978; + v += field2979; + v += field2980; + v += field2981; + v += field2982; + v += field2983; + v += field2984; + v += field2985; + v += field2986; + v += field2987; + v += field2988; + v += field2989; + v += field2990; + v += field2991; + v += field2992; + v += field2993; + v += field2994; + v += field2995; + v += field2996; + v += field2997; + v += field2998; + v += field2999; + field2999 = v; + } + + private static void test1_field3000() { + int v = field3000; + v += field3001; + v += field3002; + v += field3003; + v += field3004; + v += field3005; + v += field3006; + v += field3007; + v += field3008; + v += field3009; + v += field3010; + v += field3011; + v += field3012; + v += field3013; + v += field3014; + v += field3015; + v += field3016; + v += field3017; + v += field3018; + v += field3019; + v += field3020; + v += field3021; + v += field3022; + v += field3023; + v += field3024; + v += field3025; + v += field3026; + v += field3027; + v += field3028; + v += field3029; + v += field3030; + v += field3031; + v += field3032; + v += field3033; + v += field3034; + v += field3035; + v += field3036; + v += field3037; + v += field3038; + v += field3039; + v += field3040; + v += field3041; + v += field3042; + v += field3043; + v += field3044; + v += field3045; + v += field3046; + v += field3047; + v += field3048; + v += field3049; + field3049 = v; + } + + private static void test1_field3050() { + int v = field3050; + v += field3051; + v += field3052; + v += field3053; + v += field3054; + v += field3055; + v += field3056; + v += field3057; + v += field3058; + v += field3059; + v += field3060; + v += field3061; + v += field3062; + v += field3063; + v += field3064; + v += field3065; + v += field3066; + v += field3067; + v += field3068; + v += field3069; + v += field3070; + v += field3071; + v += field3072; + v += field3073; + v += field3074; + v += field3075; + v += field3076; + v += field3077; + v += field3078; + v += field3079; + v += field3080; + v += field3081; + v += field3082; + v += field3083; + v += field3084; + v += field3085; + v += field3086; + v += field3087; + v += field3088; + v += field3089; + v += field3090; + v += field3091; + v += field3092; + v += field3093; + v += field3094; + v += field3095; + v += field3096; + v += field3097; + v += field3098; + v += field3099; + field3099 = v; + } + + private static void test1_field3100() { + int v = field3100; + v += field3101; + v += field3102; + v += field3103; + v += field3104; + v += field3105; + v += field3106; + v += field3107; + v += field3108; + v += field3109; + v += field3110; + v += field3111; + v += field3112; + v += field3113; + v += field3114; + v += field3115; + v += field3116; + v += field3117; + v += field3118; + v += field3119; + v += field3120; + v += field3121; + v += field3122; + v += field3123; + v += field3124; + v += field3125; + v += field3126; + v += field3127; + v += field3128; + v += field3129; + v += field3130; + v += field3131; + v += field3132; + v += field3133; + v += field3134; + v += field3135; + v += field3136; + v += field3137; + v += field3138; + v += field3139; + v += field3140; + v += field3141; + v += field3142; + v += field3143; + v += field3144; + v += field3145; + v += field3146; + v += field3147; + v += field3148; + v += field3149; + field3149 = v; + } + + private static void test1_field3150() { + int v = field3150; + v += field3151; + v += field3152; + v += field3153; + v += field3154; + v += field3155; + v += field3156; + v += field3157; + v += field3158; + v += field3159; + v += field3160; + v += field3161; + v += field3162; + v += field3163; + v += field3164; + v += field3165; + v += field3166; + v += field3167; + v += field3168; + v += field3169; + v += field3170; + v += field3171; + v += field3172; + v += field3173; + v += field3174; + v += field3175; + v += field3176; + v += field3177; + v += field3178; + v += field3179; + v += field3180; + v += field3181; + v += field3182; + v += field3183; + v += field3184; + v += field3185; + v += field3186; + v += field3187; + v += field3188; + v += field3189; + v += field3190; + v += field3191; + v += field3192; + v += field3193; + v += field3194; + v += field3195; + v += field3196; + v += field3197; + v += field3198; + v += field3199; + field3199 = v; + } + + private static void test1_field3200() { + int v = field3200; + v += field3201; + v += field3202; + v += field3203; + v += field3204; + v += field3205; + v += field3206; + v += field3207; + v += field3208; + v += field3209; + v += field3210; + v += field3211; + v += field3212; + v += field3213; + v += field3214; + v += field3215; + v += field3216; + v += field3217; + v += field3218; + v += field3219; + v += field3220; + v += field3221; + v += field3222; + v += field3223; + v += field3224; + v += field3225; + v += field3226; + v += field3227; + v += field3228; + v += field3229; + v += field3230; + v += field3231; + v += field3232; + v += field3233; + v += field3234; + v += field3235; + v += field3236; + v += field3237; + v += field3238; + v += field3239; + v += field3240; + v += field3241; + v += field3242; + v += field3243; + v += field3244; + v += field3245; + v += field3246; + v += field3247; + v += field3248; + v += field3249; + field3249 = v; + } + + private static void test1_field3250() { + int v = field3250; + v += field3251; + v += field3252; + v += field3253; + v += field3254; + v += field3255; + v += field3256; + v += field3257; + v += field3258; + v += field3259; + v += field3260; + v += field3261; + v += field3262; + v += field3263; + v += field3264; + v += field3265; + v += field3266; + v += field3267; + v += field3268; + v += field3269; + v += field3270; + v += field3271; + v += field3272; + v += field3273; + v += field3274; + v += field3275; + v += field3276; + v += field3277; + v += field3278; + v += field3279; + v += field3280; + v += field3281; + v += field3282; + v += field3283; + v += field3284; + v += field3285; + v += field3286; + v += field3287; + v += field3288; + v += field3289; + v += field3290; + v += field3291; + v += field3292; + v += field3293; + v += field3294; + v += field3295; + v += field3296; + v += field3297; + v += field3298; + v += field3299; + field3299 = v; + } + + private static void test1_field3300() { + int v = field3300; + v += field3301; + v += field3302; + v += field3303; + v += field3304; + v += field3305; + v += field3306; + v += field3307; + v += field3308; + v += field3309; + v += field3310; + v += field3311; + v += field3312; + v += field3313; + v += field3314; + v += field3315; + v += field3316; + v += field3317; + v += field3318; + v += field3319; + v += field3320; + v += field3321; + v += field3322; + v += field3323; + v += field3324; + v += field3325; + v += field3326; + v += field3327; + v += field3328; + v += field3329; + v += field3330; + v += field3331; + v += field3332; + v += field3333; + v += field3334; + v += field3335; + v += field3336; + v += field3337; + v += field3338; + v += field3339; + v += field3340; + v += field3341; + v += field3342; + v += field3343; + v += field3344; + v += field3345; + v += field3346; + v += field3347; + v += field3348; + v += field3349; + field3349 = v; + } + + private static void test1_field3350() { + int v = field3350; + v += field3351; + v += field3352; + v += field3353; + v += field3354; + v += field3355; + v += field3356; + v += field3357; + v += field3358; + v += field3359; + v += field3360; + v += field3361; + v += field3362; + v += field3363; + v += field3364; + v += field3365; + v += field3366; + v += field3367; + v += field3368; + v += field3369; + v += field3370; + v += field3371; + v += field3372; + v += field3373; + v += field3374; + v += field3375; + v += field3376; + v += field3377; + v += field3378; + v += field3379; + v += field3380; + v += field3381; + v += field3382; + v += field3383; + v += field3384; + v += field3385; + v += field3386; + v += field3387; + v += field3388; + v += field3389; + v += field3390; + v += field3391; + v += field3392; + v += field3393; + v += field3394; + v += field3395; + v += field3396; + v += field3397; + v += field3398; + v += field3399; + field3399 = v; + } + + private static void test1_field3400() { + int v = field3400; + v += field3401; + v += field3402; + v += field3403; + v += field3404; + v += field3405; + v += field3406; + v += field3407; + v += field3408; + v += field3409; + v += field3410; + v += field3411; + v += field3412; + v += field3413; + v += field3414; + v += field3415; + v += field3416; + v += field3417; + v += field3418; + v += field3419; + v += field3420; + v += field3421; + v += field3422; + v += field3423; + v += field3424; + v += field3425; + v += field3426; + v += field3427; + v += field3428; + v += field3429; + v += field3430; + v += field3431; + v += field3432; + v += field3433; + v += field3434; + v += field3435; + v += field3436; + v += field3437; + v += field3438; + v += field3439; + v += field3440; + v += field3441; + v += field3442; + v += field3443; + v += field3444; + v += field3445; + v += field3446; + v += field3447; + v += field3448; + v += field3449; + field3449 = v; + } + + private static void test1_field3450() { + int v = field3450; + v += field3451; + v += field3452; + v += field3453; + v += field3454; + v += field3455; + v += field3456; + v += field3457; + v += field3458; + v += field3459; + v += field3460; + v += field3461; + v += field3462; + v += field3463; + v += field3464; + v += field3465; + v += field3466; + v += field3467; + v += field3468; + v += field3469; + v += field3470; + v += field3471; + v += field3472; + v += field3473; + v += field3474; + v += field3475; + v += field3476; + v += field3477; + v += field3478; + v += field3479; + v += field3480; + v += field3481; + v += field3482; + v += field3483; + v += field3484; + v += field3485; + v += field3486; + v += field3487; + v += field3488; + v += field3489; + v += field3490; + v += field3491; + v += field3492; + v += field3493; + v += field3494; + v += field3495; + v += field3496; + v += field3497; + v += field3498; + v += field3499; + field3499 = v; + } + + private static void test1_field3500() { + int v = field3500; + v += field3501; + v += field3502; + v += field3503; + v += field3504; + v += field3505; + v += field3506; + v += field3507; + v += field3508; + v += field3509; + v += field3510; + v += field3511; + v += field3512; + v += field3513; + v += field3514; + v += field3515; + v += field3516; + v += field3517; + v += field3518; + v += field3519; + v += field3520; + v += field3521; + v += field3522; + v += field3523; + v += field3524; + v += field3525; + v += field3526; + v += field3527; + v += field3528; + v += field3529; + v += field3530; + v += field3531; + v += field3532; + v += field3533; + v += field3534; + v += field3535; + v += field3536; + v += field3537; + v += field3538; + v += field3539; + v += field3540; + v += field3541; + v += field3542; + v += field3543; + v += field3544; + v += field3545; + v += field3546; + v += field3547; + v += field3548; + v += field3549; + field3549 = v; + } + + private static void test1_field3550() { + int v = field3550; + v += field3551; + v += field3552; + v += field3553; + v += field3554; + v += field3555; + v += field3556; + v += field3557; + v += field3558; + v += field3559; + v += field3560; + v += field3561; + v += field3562; + v += field3563; + v += field3564; + v += field3565; + v += field3566; + v += field3567; + v += field3568; + v += field3569; + v += field3570; + v += field3571; + v += field3572; + v += field3573; + v += field3574; + v += field3575; + v += field3576; + v += field3577; + v += field3578; + v += field3579; + v += field3580; + v += field3581; + v += field3582; + v += field3583; + v += field3584; + v += field3585; + v += field3586; + v += field3587; + v += field3588; + v += field3589; + v += field3590; + v += field3591; + v += field3592; + v += field3593; + v += field3594; + v += field3595; + v += field3596; + v += field3597; + v += field3598; + v += field3599; + field3599 = v; + } + + private static void test1_field3600() { + int v = field3600; + v += field3601; + v += field3602; + v += field3603; + v += field3604; + v += field3605; + v += field3606; + v += field3607; + v += field3608; + v += field3609; + v += field3610; + v += field3611; + v += field3612; + v += field3613; + v += field3614; + v += field3615; + v += field3616; + v += field3617; + v += field3618; + v += field3619; + v += field3620; + v += field3621; + v += field3622; + v += field3623; + v += field3624; + v += field3625; + v += field3626; + v += field3627; + v += field3628; + v += field3629; + v += field3630; + v += field3631; + v += field3632; + v += field3633; + v += field3634; + v += field3635; + v += field3636; + v += field3637; + v += field3638; + v += field3639; + v += field3640; + v += field3641; + v += field3642; + v += field3643; + v += field3644; + v += field3645; + v += field3646; + v += field3647; + v += field3648; + v += field3649; + field3649 = v; + } + + private static void test1_field3650() { + int v = field3650; + v += field3651; + v += field3652; + v += field3653; + v += field3654; + v += field3655; + v += field3656; + v += field3657; + v += field3658; + v += field3659; + v += field3660; + v += field3661; + v += field3662; + v += field3663; + v += field3664; + v += field3665; + v += field3666; + v += field3667; + v += field3668; + v += field3669; + v += field3670; + v += field3671; + v += field3672; + v += field3673; + v += field3674; + v += field3675; + v += field3676; + v += field3677; + v += field3678; + v += field3679; + v += field3680; + v += field3681; + v += field3682; + v += field3683; + v += field3684; + v += field3685; + v += field3686; + v += field3687; + v += field3688; + v += field3689; + v += field3690; + v += field3691; + v += field3692; + v += field3693; + v += field3694; + v += field3695; + v += field3696; + v += field3697; + v += field3698; + v += field3699; + field3699 = v; + } + + private static void test1_field3700() { + int v = field3700; + v += field3701; + v += field3702; + v += field3703; + v += field3704; + v += field3705; + v += field3706; + v += field3707; + v += field3708; + v += field3709; + v += field3710; + v += field3711; + v += field3712; + v += field3713; + v += field3714; + v += field3715; + v += field3716; + v += field3717; + v += field3718; + v += field3719; + v += field3720; + v += field3721; + v += field3722; + v += field3723; + v += field3724; + v += field3725; + v += field3726; + v += field3727; + v += field3728; + v += field3729; + v += field3730; + v += field3731; + v += field3732; + v += field3733; + v += field3734; + v += field3735; + v += field3736; + v += field3737; + v += field3738; + v += field3739; + v += field3740; + v += field3741; + v += field3742; + v += field3743; + v += field3744; + v += field3745; + v += field3746; + v += field3747; + v += field3748; + v += field3749; + field3749 = v; + } + + private static void test1_field3750() { + int v = field3750; + v += field3751; + v += field3752; + v += field3753; + v += field3754; + v += field3755; + v += field3756; + v += field3757; + v += field3758; + v += field3759; + v += field3760; + v += field3761; + v += field3762; + v += field3763; + v += field3764; + v += field3765; + v += field3766; + v += field3767; + v += field3768; + v += field3769; + v += field3770; + v += field3771; + v += field3772; + v += field3773; + v += field3774; + v += field3775; + v += field3776; + v += field3777; + v += field3778; + v += field3779; + v += field3780; + v += field3781; + v += field3782; + v += field3783; + v += field3784; + v += field3785; + v += field3786; + v += field3787; + v += field3788; + v += field3789; + v += field3790; + v += field3791; + v += field3792; + v += field3793; + v += field3794; + v += field3795; + v += field3796; + v += field3797; + v += field3798; + v += field3799; + field3799 = v; + } + + private static void test1_field3800() { + int v = field3800; + v += field3801; + v += field3802; + v += field3803; + v += field3804; + v += field3805; + v += field3806; + v += field3807; + v += field3808; + v += field3809; + v += field3810; + v += field3811; + v += field3812; + v += field3813; + v += field3814; + v += field3815; + v += field3816; + v += field3817; + v += field3818; + v += field3819; + v += field3820; + v += field3821; + v += field3822; + v += field3823; + v += field3824; + v += field3825; + v += field3826; + v += field3827; + v += field3828; + v += field3829; + v += field3830; + v += field3831; + v += field3832; + v += field3833; + v += field3834; + v += field3835; + v += field3836; + v += field3837; + v += field3838; + v += field3839; + v += field3840; + v += field3841; + v += field3842; + v += field3843; + v += field3844; + v += field3845; + v += field3846; + v += field3847; + v += field3848; + v += field3849; + field3849 = v; + } + + private static void test1_field3850() { + int v = field3850; + v += field3851; + v += field3852; + v += field3853; + v += field3854; + v += field3855; + v += field3856; + v += field3857; + v += field3858; + v += field3859; + v += field3860; + v += field3861; + v += field3862; + v += field3863; + v += field3864; + v += field3865; + v += field3866; + v += field3867; + v += field3868; + v += field3869; + v += field3870; + v += field3871; + v += field3872; + v += field3873; + v += field3874; + v += field3875; + v += field3876; + v += field3877; + v += field3878; + v += field3879; + v += field3880; + v += field3881; + v += field3882; + v += field3883; + v += field3884; + v += field3885; + v += field3886; + v += field3887; + v += field3888; + v += field3889; + v += field3890; + v += field3891; + v += field3892; + v += field3893; + v += field3894; + v += field3895; + v += field3896; + v += field3897; + v += field3898; + v += field3899; + field3899 = v; + } + + private static void test1_field3900() { + int v = field3900; + v += field3901; + v += field3902; + v += field3903; + v += field3904; + v += field3905; + v += field3906; + v += field3907; + v += field3908; + v += field3909; + v += field3910; + v += field3911; + v += field3912; + v += field3913; + v += field3914; + v += field3915; + v += field3916; + v += field3917; + v += field3918; + v += field3919; + v += field3920; + v += field3921; + v += field3922; + v += field3923; + v += field3924; + v += field3925; + v += field3926; + v += field3927; + v += field3928; + v += field3929; + v += field3930; + v += field3931; + v += field3932; + v += field3933; + v += field3934; + v += field3935; + v += field3936; + v += field3937; + v += field3938; + v += field3939; + v += field3940; + v += field3941; + v += field3942; + v += field3943; + v += field3944; + v += field3945; + v += field3946; + v += field3947; + v += field3948; + v += field3949; + field3949 = v; + } + + private static void test1_field3950() { + int v = field3950; + v += field3951; + v += field3952; + v += field3953; + v += field3954; + v += field3955; + v += field3956; + v += field3957; + v += field3958; + v += field3959; + v += field3960; + v += field3961; + v += field3962; + v += field3963; + v += field3964; + v += field3965; + v += field3966; + v += field3967; + v += field3968; + v += field3969; + v += field3970; + v += field3971; + v += field3972; + v += field3973; + v += field3974; + v += field3975; + v += field3976; + v += field3977; + v += field3978; + v += field3979; + v += field3980; + v += field3981; + v += field3982; + v += field3983; + v += field3984; + v += field3985; + v += field3986; + v += field3987; + v += field3988; + v += field3989; + v += field3990; + v += field3991; + v += field3992; + v += field3993; + v += field3994; + v += field3995; + v += field3996; + v += field3997; + v += field3998; + v += field3999; + field3999 = v; + } + + private static void test1() { + int v = 0; + test1_field0000(); + test1_field0050(); + test1_field0100(); + test1_field0150(); + test1_field0200(); + test1_field0250(); + test1_field0300(); + test1_field0350(); + test1_field0400(); + test1_field0450(); + test1_field0500(); + test1_field0550(); + test1_field0600(); + test1_field0650(); + test1_field0700(); + test1_field0750(); + test1_field0800(); + test1_field0850(); + test1_field0900(); + test1_field0950(); + test1_field1000(); + test1_field1050(); + test1_field1100(); + test1_field1150(); + test1_field1200(); + test1_field1250(); + test1_field1300(); + test1_field1350(); + test1_field1400(); + test1_field1450(); + test1_field1500(); + test1_field1550(); + test1_field1600(); + test1_field1650(); + test1_field1700(); + test1_field1750(); + test1_field1800(); + test1_field1850(); + test1_field1900(); + test1_field1950(); + test1_field2000(); + test1_field2050(); + test1_field2100(); + test1_field2150(); + test1_field2200(); + test1_field2250(); + test1_field2300(); + test1_field2350(); + test1_field2400(); + test1_field2450(); + test1_field2500(); + test1_field2550(); + test1_field2600(); + test1_field2650(); + test1_field2700(); + test1_field2750(); + test1_field2800(); + test1_field2850(); + test1_field2900(); + test1_field2950(); + test1_field3000(); + test1_field3050(); + test1_field3100(); + test1_field3150(); + test1_field3200(); + test1_field3250(); + test1_field3300(); + test1_field3350(); + test1_field3400(); + test1_field3450(); + test1_field3500(); + test1_field3550(); + test1_field3600(); + test1_field3650(); + test1_field3700(); + test1_field3750(); + test1_field3800(); + test1_field3850(); + test1_field3900(); + test1_field3950(); + } + + private static int field0000; + private static int field0001; + private static int field0002; + private static int field0003; + private static int field0004; + private static int field0005; + private static int field0006; + private static int field0007; + private static int field0008; + private static int field0009; + private static int field0010; + private static int field0011; + private static int field0012; + private static int field0013; + private static int field0014; + private static int field0015; + private static int field0016; + private static int field0017; + private static int field0018; + private static int field0019; + private static int field0020; + private static int field0021; + private static int field0022; + private static int field0023; + private static int field0024; + private static int field0025; + private static int field0026; + private static int field0027; + private static int field0028; + private static int field0029; + private static int field0030; + private static int field0031; + private static int field0032; + private static int field0033; + private static int field0034; + private static int field0035; + private static int field0036; + private static int field0037; + private static int field0038; + private static int field0039; + private static int field0040; + private static int field0041; + private static int field0042; + private static int field0043; + private static int field0044; + private static int field0045; + private static int field0046; + private static int field0047; + private static int field0048; + private static int field0049; + private static int field0050; + private static int field0051; + private static int field0052; + private static int field0053; + private static int field0054; + private static int field0055; + private static int field0056; + private static int field0057; + private static int field0058; + private static int field0059; + private static int field0060; + private static int field0061; + private static int field0062; + private static int field0063; + private static int field0064; + private static int field0065; + private static int field0066; + private static int field0067; + private static int field0068; + private static int field0069; + private static int field0070; + private static int field0071; + private static int field0072; + private static int field0073; + private static int field0074; + private static int field0075; + private static int field0076; + private static int field0077; + private static int field0078; + private static int field0079; + private static int field0080; + private static int field0081; + private static int field0082; + private static int field0083; + private static int field0084; + private static int field0085; + private static int field0086; + private static int field0087; + private static int field0088; + private static int field0089; + private static int field0090; + private static int field0091; + private static int field0092; + private static int field0093; + private static int field0094; + private static int field0095; + private static int field0096; + private static int field0097; + private static int field0098; + private static int field0099; + private static int field0100; + private static int field0101; + private static int field0102; + private static int field0103; + private static int field0104; + private static int field0105; + private static int field0106; + private static int field0107; + private static int field0108; + private static int field0109; + private static int field0110; + private static int field0111; + private static int field0112; + private static int field0113; + private static int field0114; + private static int field0115; + private static int field0116; + private static int field0117; + private static int field0118; + private static int field0119; + private static int field0120; + private static int field0121; + private static int field0122; + private static int field0123; + private static int field0124; + private static int field0125; + private static int field0126; + private static int field0127; + private static int field0128; + private static int field0129; + private static int field0130; + private static int field0131; + private static int field0132; + private static int field0133; + private static int field0134; + private static int field0135; + private static int field0136; + private static int field0137; + private static int field0138; + private static int field0139; + private static int field0140; + private static int field0141; + private static int field0142; + private static int field0143; + private static int field0144; + private static int field0145; + private static int field0146; + private static int field0147; + private static int field0148; + private static int field0149; + private static int field0150; + private static int field0151; + private static int field0152; + private static int field0153; + private static int field0154; + private static int field0155; + private static int field0156; + private static int field0157; + private static int field0158; + private static int field0159; + private static int field0160; + private static int field0161; + private static int field0162; + private static int field0163; + private static int field0164; + private static int field0165; + private static int field0166; + private static int field0167; + private static int field0168; + private static int field0169; + private static int field0170; + private static int field0171; + private static int field0172; + private static int field0173; + private static int field0174; + private static int field0175; + private static int field0176; + private static int field0177; + private static int field0178; + private static int field0179; + private static int field0180; + private static int field0181; + private static int field0182; + private static int field0183; + private static int field0184; + private static int field0185; + private static int field0186; + private static int field0187; + private static int field0188; + private static int field0189; + private static int field0190; + private static int field0191; + private static int field0192; + private static int field0193; + private static int field0194; + private static int field0195; + private static int field0196; + private static int field0197; + private static int field0198; + private static int field0199; + private static int field0200; + private static int field0201; + private static int field0202; + private static int field0203; + private static int field0204; + private static int field0205; + private static int field0206; + private static int field0207; + private static int field0208; + private static int field0209; + private static int field0210; + private static int field0211; + private static int field0212; + private static int field0213; + private static int field0214; + private static int field0215; + private static int field0216; + private static int field0217; + private static int field0218; + private static int field0219; + private static int field0220; + private static int field0221; + private static int field0222; + private static int field0223; + private static int field0224; + private static int field0225; + private static int field0226; + private static int field0227; + private static int field0228; + private static int field0229; + private static int field0230; + private static int field0231; + private static int field0232; + private static int field0233; + private static int field0234; + private static int field0235; + private static int field0236; + private static int field0237; + private static int field0238; + private static int field0239; + private static int field0240; + private static int field0241; + private static int field0242; + private static int field0243; + private static int field0244; + private static int field0245; + private static int field0246; + private static int field0247; + private static int field0248; + private static int field0249; + private static int field0250; + private static int field0251; + private static int field0252; + private static int field0253; + private static int field0254; + private static int field0255; + private static int field0256; + private static int field0257; + private static int field0258; + private static int field0259; + private static int field0260; + private static int field0261; + private static int field0262; + private static int field0263; + private static int field0264; + private static int field0265; + private static int field0266; + private static int field0267; + private static int field0268; + private static int field0269; + private static int field0270; + private static int field0271; + private static int field0272; + private static int field0273; + private static int field0274; + private static int field0275; + private static int field0276; + private static int field0277; + private static int field0278; + private static int field0279; + private static int field0280; + private static int field0281; + private static int field0282; + private static int field0283; + private static int field0284; + private static int field0285; + private static int field0286; + private static int field0287; + private static int field0288; + private static int field0289; + private static int field0290; + private static int field0291; + private static int field0292; + private static int field0293; + private static int field0294; + private static int field0295; + private static int field0296; + private static int field0297; + private static int field0298; + private static int field0299; + private static int field0300; + private static int field0301; + private static int field0302; + private static int field0303; + private static int field0304; + private static int field0305; + private static int field0306; + private static int field0307; + private static int field0308; + private static int field0309; + private static int field0310; + private static int field0311; + private static int field0312; + private static int field0313; + private static int field0314; + private static int field0315; + private static int field0316; + private static int field0317; + private static int field0318; + private static int field0319; + private static int field0320; + private static int field0321; + private static int field0322; + private static int field0323; + private static int field0324; + private static int field0325; + private static int field0326; + private static int field0327; + private static int field0328; + private static int field0329; + private static int field0330; + private static int field0331; + private static int field0332; + private static int field0333; + private static int field0334; + private static int field0335; + private static int field0336; + private static int field0337; + private static int field0338; + private static int field0339; + private static int field0340; + private static int field0341; + private static int field0342; + private static int field0343; + private static int field0344; + private static int field0345; + private static int field0346; + private static int field0347; + private static int field0348; + private static int field0349; + private static int field0350; + private static int field0351; + private static int field0352; + private static int field0353; + private static int field0354; + private static int field0355; + private static int field0356; + private static int field0357; + private static int field0358; + private static int field0359; + private static int field0360; + private static int field0361; + private static int field0362; + private static int field0363; + private static int field0364; + private static int field0365; + private static int field0366; + private static int field0367; + private static int field0368; + private static int field0369; + private static int field0370; + private static int field0371; + private static int field0372; + private static int field0373; + private static int field0374; + private static int field0375; + private static int field0376; + private static int field0377; + private static int field0378; + private static int field0379; + private static int field0380; + private static int field0381; + private static int field0382; + private static int field0383; + private static int field0384; + private static int field0385; + private static int field0386; + private static int field0387; + private static int field0388; + private static int field0389; + private static int field0390; + private static int field0391; + private static int field0392; + private static int field0393; + private static int field0394; + private static int field0395; + private static int field0396; + private static int field0397; + private static int field0398; + private static int field0399; + private static int field0400; + private static int field0401; + private static int field0402; + private static int field0403; + private static int field0404; + private static int field0405; + private static int field0406; + private static int field0407; + private static int field0408; + private static int field0409; + private static int field0410; + private static int field0411; + private static int field0412; + private static int field0413; + private static int field0414; + private static int field0415; + private static int field0416; + private static int field0417; + private static int field0418; + private static int field0419; + private static int field0420; + private static int field0421; + private static int field0422; + private static int field0423; + private static int field0424; + private static int field0425; + private static int field0426; + private static int field0427; + private static int field0428; + private static int field0429; + private static int field0430; + private static int field0431; + private static int field0432; + private static int field0433; + private static int field0434; + private static int field0435; + private static int field0436; + private static int field0437; + private static int field0438; + private static int field0439; + private static int field0440; + private static int field0441; + private static int field0442; + private static int field0443; + private static int field0444; + private static int field0445; + private static int field0446; + private static int field0447; + private static int field0448; + private static int field0449; + private static int field0450; + private static int field0451; + private static int field0452; + private static int field0453; + private static int field0454; + private static int field0455; + private static int field0456; + private static int field0457; + private static int field0458; + private static int field0459; + private static int field0460; + private static int field0461; + private static int field0462; + private static int field0463; + private static int field0464; + private static int field0465; + private static int field0466; + private static int field0467; + private static int field0468; + private static int field0469; + private static int field0470; + private static int field0471; + private static int field0472; + private static int field0473; + private static int field0474; + private static int field0475; + private static int field0476; + private static int field0477; + private static int field0478; + private static int field0479; + private static int field0480; + private static int field0481; + private static int field0482; + private static int field0483; + private static int field0484; + private static int field0485; + private static int field0486; + private static int field0487; + private static int field0488; + private static int field0489; + private static int field0490; + private static int field0491; + private static int field0492; + private static int field0493; + private static int field0494; + private static int field0495; + private static int field0496; + private static int field0497; + private static int field0498; + private static int field0499; + private static int field0500; + private static int field0501; + private static int field0502; + private static int field0503; + private static int field0504; + private static int field0505; + private static int field0506; + private static int field0507; + private static int field0508; + private static int field0509; + private static int field0510; + private static int field0511; + private static int field0512; + private static int field0513; + private static int field0514; + private static int field0515; + private static int field0516; + private static int field0517; + private static int field0518; + private static int field0519; + private static int field0520; + private static int field0521; + private static int field0522; + private static int field0523; + private static int field0524; + private static int field0525; + private static int field0526; + private static int field0527; + private static int field0528; + private static int field0529; + private static int field0530; + private static int field0531; + private static int field0532; + private static int field0533; + private static int field0534; + private static int field0535; + private static int field0536; + private static int field0537; + private static int field0538; + private static int field0539; + private static int field0540; + private static int field0541; + private static int field0542; + private static int field0543; + private static int field0544; + private static int field0545; + private static int field0546; + private static int field0547; + private static int field0548; + private static int field0549; + private static int field0550; + private static int field0551; + private static int field0552; + private static int field0553; + private static int field0554; + private static int field0555; + private static int field0556; + private static int field0557; + private static int field0558; + private static int field0559; + private static int field0560; + private static int field0561; + private static int field0562; + private static int field0563; + private static int field0564; + private static int field0565; + private static int field0566; + private static int field0567; + private static int field0568; + private static int field0569; + private static int field0570; + private static int field0571; + private static int field0572; + private static int field0573; + private static int field0574; + private static int field0575; + private static int field0576; + private static int field0577; + private static int field0578; + private static int field0579; + private static int field0580; + private static int field0581; + private static int field0582; + private static int field0583; + private static int field0584; + private static int field0585; + private static int field0586; + private static int field0587; + private static int field0588; + private static int field0589; + private static int field0590; + private static int field0591; + private static int field0592; + private static int field0593; + private static int field0594; + private static int field0595; + private static int field0596; + private static int field0597; + private static int field0598; + private static int field0599; + private static int field0600; + private static int field0601; + private static int field0602; + private static int field0603; + private static int field0604; + private static int field0605; + private static int field0606; + private static int field0607; + private static int field0608; + private static int field0609; + private static int field0610; + private static int field0611; + private static int field0612; + private static int field0613; + private static int field0614; + private static int field0615; + private static int field0616; + private static int field0617; + private static int field0618; + private static int field0619; + private static int field0620; + private static int field0621; + private static int field0622; + private static int field0623; + private static int field0624; + private static int field0625; + private static int field0626; + private static int field0627; + private static int field0628; + private static int field0629; + private static int field0630; + private static int field0631; + private static int field0632; + private static int field0633; + private static int field0634; + private static int field0635; + private static int field0636; + private static int field0637; + private static int field0638; + private static int field0639; + private static int field0640; + private static int field0641; + private static int field0642; + private static int field0643; + private static int field0644; + private static int field0645; + private static int field0646; + private static int field0647; + private static int field0648; + private static int field0649; + private static int field0650; + private static int field0651; + private static int field0652; + private static int field0653; + private static int field0654; + private static int field0655; + private static int field0656; + private static int field0657; + private static int field0658; + private static int field0659; + private static int field0660; + private static int field0661; + private static int field0662; + private static int field0663; + private static int field0664; + private static int field0665; + private static int field0666; + private static int field0667; + private static int field0668; + private static int field0669; + private static int field0670; + private static int field0671; + private static int field0672; + private static int field0673; + private static int field0674; + private static int field0675; + private static int field0676; + private static int field0677; + private static int field0678; + private static int field0679; + private static int field0680; + private static int field0681; + private static int field0682; + private static int field0683; + private static int field0684; + private static int field0685; + private static int field0686; + private static int field0687; + private static int field0688; + private static int field0689; + private static int field0690; + private static int field0691; + private static int field0692; + private static int field0693; + private static int field0694; + private static int field0695; + private static int field0696; + private static int field0697; + private static int field0698; + private static int field0699; + private static int field0700; + private static int field0701; + private static int field0702; + private static int field0703; + private static int field0704; + private static int field0705; + private static int field0706; + private static int field0707; + private static int field0708; + private static int field0709; + private static int field0710; + private static int field0711; + private static int field0712; + private static int field0713; + private static int field0714; + private static int field0715; + private static int field0716; + private static int field0717; + private static int field0718; + private static int field0719; + private static int field0720; + private static int field0721; + private static int field0722; + private static int field0723; + private static int field0724; + private static int field0725; + private static int field0726; + private static int field0727; + private static int field0728; + private static int field0729; + private static int field0730; + private static int field0731; + private static int field0732; + private static int field0733; + private static int field0734; + private static int field0735; + private static int field0736; + private static int field0737; + private static int field0738; + private static int field0739; + private static int field0740; + private static int field0741; + private static int field0742; + private static int field0743; + private static int field0744; + private static int field0745; + private static int field0746; + private static int field0747; + private static int field0748; + private static int field0749; + private static int field0750; + private static int field0751; + private static int field0752; + private static int field0753; + private static int field0754; + private static int field0755; + private static int field0756; + private static int field0757; + private static int field0758; + private static int field0759; + private static int field0760; + private static int field0761; + private static int field0762; + private static int field0763; + private static int field0764; + private static int field0765; + private static int field0766; + private static int field0767; + private static int field0768; + private static int field0769; + private static int field0770; + private static int field0771; + private static int field0772; + private static int field0773; + private static int field0774; + private static int field0775; + private static int field0776; + private static int field0777; + private static int field0778; + private static int field0779; + private static int field0780; + private static int field0781; + private static int field0782; + private static int field0783; + private static int field0784; + private static int field0785; + private static int field0786; + private static int field0787; + private static int field0788; + private static int field0789; + private static int field0790; + private static int field0791; + private static int field0792; + private static int field0793; + private static int field0794; + private static int field0795; + private static int field0796; + private static int field0797; + private static int field0798; + private static int field0799; + private static int field0800; + private static int field0801; + private static int field0802; + private static int field0803; + private static int field0804; + private static int field0805; + private static int field0806; + private static int field0807; + private static int field0808; + private static int field0809; + private static int field0810; + private static int field0811; + private static int field0812; + private static int field0813; + private static int field0814; + private static int field0815; + private static int field0816; + private static int field0817; + private static int field0818; + private static int field0819; + private static int field0820; + private static int field0821; + private static int field0822; + private static int field0823; + private static int field0824; + private static int field0825; + private static int field0826; + private static int field0827; + private static int field0828; + private static int field0829; + private static int field0830; + private static int field0831; + private static int field0832; + private static int field0833; + private static int field0834; + private static int field0835; + private static int field0836; + private static int field0837; + private static int field0838; + private static int field0839; + private static int field0840; + private static int field0841; + private static int field0842; + private static int field0843; + private static int field0844; + private static int field0845; + private static int field0846; + private static int field0847; + private static int field0848; + private static int field0849; + private static int field0850; + private static int field0851; + private static int field0852; + private static int field0853; + private static int field0854; + private static int field0855; + private static int field0856; + private static int field0857; + private static int field0858; + private static int field0859; + private static int field0860; + private static int field0861; + private static int field0862; + private static int field0863; + private static int field0864; + private static int field0865; + private static int field0866; + private static int field0867; + private static int field0868; + private static int field0869; + private static int field0870; + private static int field0871; + private static int field0872; + private static int field0873; + private static int field0874; + private static int field0875; + private static int field0876; + private static int field0877; + private static int field0878; + private static int field0879; + private static int field0880; + private static int field0881; + private static int field0882; + private static int field0883; + private static int field0884; + private static int field0885; + private static int field0886; + private static int field0887; + private static int field0888; + private static int field0889; + private static int field0890; + private static int field0891; + private static int field0892; + private static int field0893; + private static int field0894; + private static int field0895; + private static int field0896; + private static int field0897; + private static int field0898; + private static int field0899; + private static int field0900; + private static int field0901; + private static int field0902; + private static int field0903; + private static int field0904; + private static int field0905; + private static int field0906; + private static int field0907; + private static int field0908; + private static int field0909; + private static int field0910; + private static int field0911; + private static int field0912; + private static int field0913; + private static int field0914; + private static int field0915; + private static int field0916; + private static int field0917; + private static int field0918; + private static int field0919; + private static int field0920; + private static int field0921; + private static int field0922; + private static int field0923; + private static int field0924; + private static int field0925; + private static int field0926; + private static int field0927; + private static int field0928; + private static int field0929; + private static int field0930; + private static int field0931; + private static int field0932; + private static int field0933; + private static int field0934; + private static int field0935; + private static int field0936; + private static int field0937; + private static int field0938; + private static int field0939; + private static int field0940; + private static int field0941; + private static int field0942; + private static int field0943; + private static int field0944; + private static int field0945; + private static int field0946; + private static int field0947; + private static int field0948; + private static int field0949; + private static int field0950; + private static int field0951; + private static int field0952; + private static int field0953; + private static int field0954; + private static int field0955; + private static int field0956; + private static int field0957; + private static int field0958; + private static int field0959; + private static int field0960; + private static int field0961; + private static int field0962; + private static int field0963; + private static int field0964; + private static int field0965; + private static int field0966; + private static int field0967; + private static int field0968; + private static int field0969; + private static int field0970; + private static int field0971; + private static int field0972; + private static int field0973; + private static int field0974; + private static int field0975; + private static int field0976; + private static int field0977; + private static int field0978; + private static int field0979; + private static int field0980; + private static int field0981; + private static int field0982; + private static int field0983; + private static int field0984; + private static int field0985; + private static int field0986; + private static int field0987; + private static int field0988; + private static int field0989; + private static int field0990; + private static int field0991; + private static int field0992; + private static int field0993; + private static int field0994; + private static int field0995; + private static int field0996; + private static int field0997; + private static int field0998; + private static int field0999; + private static int field1000; + private static int field1001; + private static int field1002; + private static int field1003; + private static int field1004; + private static int field1005; + private static int field1006; + private static int field1007; + private static int field1008; + private static int field1009; + private static int field1010; + private static int field1011; + private static int field1012; + private static int field1013; + private static int field1014; + private static int field1015; + private static int field1016; + private static int field1017; + private static int field1018; + private static int field1019; + private static int field1020; + private static int field1021; + private static int field1022; + private static int field1023; + private static int field1024; + private static int field1025; + private static int field1026; + private static int field1027; + private static int field1028; + private static int field1029; + private static int field1030; + private static int field1031; + private static int field1032; + private static int field1033; + private static int field1034; + private static int field1035; + private static int field1036; + private static int field1037; + private static int field1038; + private static int field1039; + private static int field1040; + private static int field1041; + private static int field1042; + private static int field1043; + private static int field1044; + private static int field1045; + private static int field1046; + private static int field1047; + private static int field1048; + private static int field1049; + private static int field1050; + private static int field1051; + private static int field1052; + private static int field1053; + private static int field1054; + private static int field1055; + private static int field1056; + private static int field1057; + private static int field1058; + private static int field1059; + private static int field1060; + private static int field1061; + private static int field1062; + private static int field1063; + private static int field1064; + private static int field1065; + private static int field1066; + private static int field1067; + private static int field1068; + private static int field1069; + private static int field1070; + private static int field1071; + private static int field1072; + private static int field1073; + private static int field1074; + private static int field1075; + private static int field1076; + private static int field1077; + private static int field1078; + private static int field1079; + private static int field1080; + private static int field1081; + private static int field1082; + private static int field1083; + private static int field1084; + private static int field1085; + private static int field1086; + private static int field1087; + private static int field1088; + private static int field1089; + private static int field1090; + private static int field1091; + private static int field1092; + private static int field1093; + private static int field1094; + private static int field1095; + private static int field1096; + private static int field1097; + private static int field1098; + private static int field1099; + private static int field1100; + private static int field1101; + private static int field1102; + private static int field1103; + private static int field1104; + private static int field1105; + private static int field1106; + private static int field1107; + private static int field1108; + private static int field1109; + private static int field1110; + private static int field1111; + private static int field1112; + private static int field1113; + private static int field1114; + private static int field1115; + private static int field1116; + private static int field1117; + private static int field1118; + private static int field1119; + private static int field1120; + private static int field1121; + private static int field1122; + private static int field1123; + private static int field1124; + private static int field1125; + private static int field1126; + private static int field1127; + private static int field1128; + private static int field1129; + private static int field1130; + private static int field1131; + private static int field1132; + private static int field1133; + private static int field1134; + private static int field1135; + private static int field1136; + private static int field1137; + private static int field1138; + private static int field1139; + private static int field1140; + private static int field1141; + private static int field1142; + private static int field1143; + private static int field1144; + private static int field1145; + private static int field1146; + private static int field1147; + private static int field1148; + private static int field1149; + private static int field1150; + private static int field1151; + private static int field1152; + private static int field1153; + private static int field1154; + private static int field1155; + private static int field1156; + private static int field1157; + private static int field1158; + private static int field1159; + private static int field1160; + private static int field1161; + private static int field1162; + private static int field1163; + private static int field1164; + private static int field1165; + private static int field1166; + private static int field1167; + private static int field1168; + private static int field1169; + private static int field1170; + private static int field1171; + private static int field1172; + private static int field1173; + private static int field1174; + private static int field1175; + private static int field1176; + private static int field1177; + private static int field1178; + private static int field1179; + private static int field1180; + private static int field1181; + private static int field1182; + private static int field1183; + private static int field1184; + private static int field1185; + private static int field1186; + private static int field1187; + private static int field1188; + private static int field1189; + private static int field1190; + private static int field1191; + private static int field1192; + private static int field1193; + private static int field1194; + private static int field1195; + private static int field1196; + private static int field1197; + private static int field1198; + private static int field1199; + private static int field1200; + private static int field1201; + private static int field1202; + private static int field1203; + private static int field1204; + private static int field1205; + private static int field1206; + private static int field1207; + private static int field1208; + private static int field1209; + private static int field1210; + private static int field1211; + private static int field1212; + private static int field1213; + private static int field1214; + private static int field1215; + private static int field1216; + private static int field1217; + private static int field1218; + private static int field1219; + private static int field1220; + private static int field1221; + private static int field1222; + private static int field1223; + private static int field1224; + private static int field1225; + private static int field1226; + private static int field1227; + private static int field1228; + private static int field1229; + private static int field1230; + private static int field1231; + private static int field1232; + private static int field1233; + private static int field1234; + private static int field1235; + private static int field1236; + private static int field1237; + private static int field1238; + private static int field1239; + private static int field1240; + private static int field1241; + private static int field1242; + private static int field1243; + private static int field1244; + private static int field1245; + private static int field1246; + private static int field1247; + private static int field1248; + private static int field1249; + private static int field1250; + private static int field1251; + private static int field1252; + private static int field1253; + private static int field1254; + private static int field1255; + private static int field1256; + private static int field1257; + private static int field1258; + private static int field1259; + private static int field1260; + private static int field1261; + private static int field1262; + private static int field1263; + private static int field1264; + private static int field1265; + private static int field1266; + private static int field1267; + private static int field1268; + private static int field1269; + private static int field1270; + private static int field1271; + private static int field1272; + private static int field1273; + private static int field1274; + private static int field1275; + private static int field1276; + private static int field1277; + private static int field1278; + private static int field1279; + private static int field1280; + private static int field1281; + private static int field1282; + private static int field1283; + private static int field1284; + private static int field1285; + private static int field1286; + private static int field1287; + private static int field1288; + private static int field1289; + private static int field1290; + private static int field1291; + private static int field1292; + private static int field1293; + private static int field1294; + private static int field1295; + private static int field1296; + private static int field1297; + private static int field1298; + private static int field1299; + private static int field1300; + private static int field1301; + private static int field1302; + private static int field1303; + private static int field1304; + private static int field1305; + private static int field1306; + private static int field1307; + private static int field1308; + private static int field1309; + private static int field1310; + private static int field1311; + private static int field1312; + private static int field1313; + private static int field1314; + private static int field1315; + private static int field1316; + private static int field1317; + private static int field1318; + private static int field1319; + private static int field1320; + private static int field1321; + private static int field1322; + private static int field1323; + private static int field1324; + private static int field1325; + private static int field1326; + private static int field1327; + private static int field1328; + private static int field1329; + private static int field1330; + private static int field1331; + private static int field1332; + private static int field1333; + private static int field1334; + private static int field1335; + private static int field1336; + private static int field1337; + private static int field1338; + private static int field1339; + private static int field1340; + private static int field1341; + private static int field1342; + private static int field1343; + private static int field1344; + private static int field1345; + private static int field1346; + private static int field1347; + private static int field1348; + private static int field1349; + private static int field1350; + private static int field1351; + private static int field1352; + private static int field1353; + private static int field1354; + private static int field1355; + private static int field1356; + private static int field1357; + private static int field1358; + private static int field1359; + private static int field1360; + private static int field1361; + private static int field1362; + private static int field1363; + private static int field1364; + private static int field1365; + private static int field1366; + private static int field1367; + private static int field1368; + private static int field1369; + private static int field1370; + private static int field1371; + private static int field1372; + private static int field1373; + private static int field1374; + private static int field1375; + private static int field1376; + private static int field1377; + private static int field1378; + private static int field1379; + private static int field1380; + private static int field1381; + private static int field1382; + private static int field1383; + private static int field1384; + private static int field1385; + private static int field1386; + private static int field1387; + private static int field1388; + private static int field1389; + private static int field1390; + private static int field1391; + private static int field1392; + private static int field1393; + private static int field1394; + private static int field1395; + private static int field1396; + private static int field1397; + private static int field1398; + private static int field1399; + private static int field1400; + private static int field1401; + private static int field1402; + private static int field1403; + private static int field1404; + private static int field1405; + private static int field1406; + private static int field1407; + private static int field1408; + private static int field1409; + private static int field1410; + private static int field1411; + private static int field1412; + private static int field1413; + private static int field1414; + private static int field1415; + private static int field1416; + private static int field1417; + private static int field1418; + private static int field1419; + private static int field1420; + private static int field1421; + private static int field1422; + private static int field1423; + private static int field1424; + private static int field1425; + private static int field1426; + private static int field1427; + private static int field1428; + private static int field1429; + private static int field1430; + private static int field1431; + private static int field1432; + private static int field1433; + private static int field1434; + private static int field1435; + private static int field1436; + private static int field1437; + private static int field1438; + private static int field1439; + private static int field1440; + private static int field1441; + private static int field1442; + private static int field1443; + private static int field1444; + private static int field1445; + private static int field1446; + private static int field1447; + private static int field1448; + private static int field1449; + private static int field1450; + private static int field1451; + private static int field1452; + private static int field1453; + private static int field1454; + private static int field1455; + private static int field1456; + private static int field1457; + private static int field1458; + private static int field1459; + private static int field1460; + private static int field1461; + private static int field1462; + private static int field1463; + private static int field1464; + private static int field1465; + private static int field1466; + private static int field1467; + private static int field1468; + private static int field1469; + private static int field1470; + private static int field1471; + private static int field1472; + private static int field1473; + private static int field1474; + private static int field1475; + private static int field1476; + private static int field1477; + private static int field1478; + private static int field1479; + private static int field1480; + private static int field1481; + private static int field1482; + private static int field1483; + private static int field1484; + private static int field1485; + private static int field1486; + private static int field1487; + private static int field1488; + private static int field1489; + private static int field1490; + private static int field1491; + private static int field1492; + private static int field1493; + private static int field1494; + private static int field1495; + private static int field1496; + private static int field1497; + private static int field1498; + private static int field1499; + private static int field1500; + private static int field1501; + private static int field1502; + private static int field1503; + private static int field1504; + private static int field1505; + private static int field1506; + private static int field1507; + private static int field1508; + private static int field1509; + private static int field1510; + private static int field1511; + private static int field1512; + private static int field1513; + private static int field1514; + private static int field1515; + private static int field1516; + private static int field1517; + private static int field1518; + private static int field1519; + private static int field1520; + private static int field1521; + private static int field1522; + private static int field1523; + private static int field1524; + private static int field1525; + private static int field1526; + private static int field1527; + private static int field1528; + private static int field1529; + private static int field1530; + private static int field1531; + private static int field1532; + private static int field1533; + private static int field1534; + private static int field1535; + private static int field1536; + private static int field1537; + private static int field1538; + private static int field1539; + private static int field1540; + private static int field1541; + private static int field1542; + private static int field1543; + private static int field1544; + private static int field1545; + private static int field1546; + private static int field1547; + private static int field1548; + private static int field1549; + private static int field1550; + private static int field1551; + private static int field1552; + private static int field1553; + private static int field1554; + private static int field1555; + private static int field1556; + private static int field1557; + private static int field1558; + private static int field1559; + private static int field1560; + private static int field1561; + private static int field1562; + private static int field1563; + private static int field1564; + private static int field1565; + private static int field1566; + private static int field1567; + private static int field1568; + private static int field1569; + private static int field1570; + private static int field1571; + private static int field1572; + private static int field1573; + private static int field1574; + private static int field1575; + private static int field1576; + private static int field1577; + private static int field1578; + private static int field1579; + private static int field1580; + private static int field1581; + private static int field1582; + private static int field1583; + private static int field1584; + private static int field1585; + private static int field1586; + private static int field1587; + private static int field1588; + private static int field1589; + private static int field1590; + private static int field1591; + private static int field1592; + private static int field1593; + private static int field1594; + private static int field1595; + private static int field1596; + private static int field1597; + private static int field1598; + private static int field1599; + private static int field1600; + private static int field1601; + private static int field1602; + private static int field1603; + private static int field1604; + private static int field1605; + private static int field1606; + private static int field1607; + private static int field1608; + private static int field1609; + private static int field1610; + private static int field1611; + private static int field1612; + private static int field1613; + private static int field1614; + private static int field1615; + private static int field1616; + private static int field1617; + private static int field1618; + private static int field1619; + private static int field1620; + private static int field1621; + private static int field1622; + private static int field1623; + private static int field1624; + private static int field1625; + private static int field1626; + private static int field1627; + private static int field1628; + private static int field1629; + private static int field1630; + private static int field1631; + private static int field1632; + private static int field1633; + private static int field1634; + private static int field1635; + private static int field1636; + private static int field1637; + private static int field1638; + private static int field1639; + private static int field1640; + private static int field1641; + private static int field1642; + private static int field1643; + private static int field1644; + private static int field1645; + private static int field1646; + private static int field1647; + private static int field1648; + private static int field1649; + private static int field1650; + private static int field1651; + private static int field1652; + private static int field1653; + private static int field1654; + private static int field1655; + private static int field1656; + private static int field1657; + private static int field1658; + private static int field1659; + private static int field1660; + private static int field1661; + private static int field1662; + private static int field1663; + private static int field1664; + private static int field1665; + private static int field1666; + private static int field1667; + private static int field1668; + private static int field1669; + private static int field1670; + private static int field1671; + private static int field1672; + private static int field1673; + private static int field1674; + private static int field1675; + private static int field1676; + private static int field1677; + private static int field1678; + private static int field1679; + private static int field1680; + private static int field1681; + private static int field1682; + private static int field1683; + private static int field1684; + private static int field1685; + private static int field1686; + private static int field1687; + private static int field1688; + private static int field1689; + private static int field1690; + private static int field1691; + private static int field1692; + private static int field1693; + private static int field1694; + private static int field1695; + private static int field1696; + private static int field1697; + private static int field1698; + private static int field1699; + private static int field1700; + private static int field1701; + private static int field1702; + private static int field1703; + private static int field1704; + private static int field1705; + private static int field1706; + private static int field1707; + private static int field1708; + private static int field1709; + private static int field1710; + private static int field1711; + private static int field1712; + private static int field1713; + private static int field1714; + private static int field1715; + private static int field1716; + private static int field1717; + private static int field1718; + private static int field1719; + private static int field1720; + private static int field1721; + private static int field1722; + private static int field1723; + private static int field1724; + private static int field1725; + private static int field1726; + private static int field1727; + private static int field1728; + private static int field1729; + private static int field1730; + private static int field1731; + private static int field1732; + private static int field1733; + private static int field1734; + private static int field1735; + private static int field1736; + private static int field1737; + private static int field1738; + private static int field1739; + private static int field1740; + private static int field1741; + private static int field1742; + private static int field1743; + private static int field1744; + private static int field1745; + private static int field1746; + private static int field1747; + private static int field1748; + private static int field1749; + private static int field1750; + private static int field1751; + private static int field1752; + private static int field1753; + private static int field1754; + private static int field1755; + private static int field1756; + private static int field1757; + private static int field1758; + private static int field1759; + private static int field1760; + private static int field1761; + private static int field1762; + private static int field1763; + private static int field1764; + private static int field1765; + private static int field1766; + private static int field1767; + private static int field1768; + private static int field1769; + private static int field1770; + private static int field1771; + private static int field1772; + private static int field1773; + private static int field1774; + private static int field1775; + private static int field1776; + private static int field1777; + private static int field1778; + private static int field1779; + private static int field1780; + private static int field1781; + private static int field1782; + private static int field1783; + private static int field1784; + private static int field1785; + private static int field1786; + private static int field1787; + private static int field1788; + private static int field1789; + private static int field1790; + private static int field1791; + private static int field1792; + private static int field1793; + private static int field1794; + private static int field1795; + private static int field1796; + private static int field1797; + private static int field1798; + private static int field1799; + private static int field1800; + private static int field1801; + private static int field1802; + private static int field1803; + private static int field1804; + private static int field1805; + private static int field1806; + private static int field1807; + private static int field1808; + private static int field1809; + private static int field1810; + private static int field1811; + private static int field1812; + private static int field1813; + private static int field1814; + private static int field1815; + private static int field1816; + private static int field1817; + private static int field1818; + private static int field1819; + private static int field1820; + private static int field1821; + private static int field1822; + private static int field1823; + private static int field1824; + private static int field1825; + private static int field1826; + private static int field1827; + private static int field1828; + private static int field1829; + private static int field1830; + private static int field1831; + private static int field1832; + private static int field1833; + private static int field1834; + private static int field1835; + private static int field1836; + private static int field1837; + private static int field1838; + private static int field1839; + private static int field1840; + private static int field1841; + private static int field1842; + private static int field1843; + private static int field1844; + private static int field1845; + private static int field1846; + private static int field1847; + private static int field1848; + private static int field1849; + private static int field1850; + private static int field1851; + private static int field1852; + private static int field1853; + private static int field1854; + private static int field1855; + private static int field1856; + private static int field1857; + private static int field1858; + private static int field1859; + private static int field1860; + private static int field1861; + private static int field1862; + private static int field1863; + private static int field1864; + private static int field1865; + private static int field1866; + private static int field1867; + private static int field1868; + private static int field1869; + private static int field1870; + private static int field1871; + private static int field1872; + private static int field1873; + private static int field1874; + private static int field1875; + private static int field1876; + private static int field1877; + private static int field1878; + private static int field1879; + private static int field1880; + private static int field1881; + private static int field1882; + private static int field1883; + private static int field1884; + private static int field1885; + private static int field1886; + private static int field1887; + private static int field1888; + private static int field1889; + private static int field1890; + private static int field1891; + private static int field1892; + private static int field1893; + private static int field1894; + private static int field1895; + private static int field1896; + private static int field1897; + private static int field1898; + private static int field1899; + private static int field1900; + private static int field1901; + private static int field1902; + private static int field1903; + private static int field1904; + private static int field1905; + private static int field1906; + private static int field1907; + private static int field1908; + private static int field1909; + private static int field1910; + private static int field1911; + private static int field1912; + private static int field1913; + private static int field1914; + private static int field1915; + private static int field1916; + private static int field1917; + private static int field1918; + private static int field1919; + private static int field1920; + private static int field1921; + private static int field1922; + private static int field1923; + private static int field1924; + private static int field1925; + private static int field1926; + private static int field1927; + private static int field1928; + private static int field1929; + private static int field1930; + private static int field1931; + private static int field1932; + private static int field1933; + private static int field1934; + private static int field1935; + private static int field1936; + private static int field1937; + private static int field1938; + private static int field1939; + private static int field1940; + private static int field1941; + private static int field1942; + private static int field1943; + private static int field1944; + private static int field1945; + private static int field1946; + private static int field1947; + private static int field1948; + private static int field1949; + private static int field1950; + private static int field1951; + private static int field1952; + private static int field1953; + private static int field1954; + private static int field1955; + private static int field1956; + private static int field1957; + private static int field1958; + private static int field1959; + private static int field1960; + private static int field1961; + private static int field1962; + private static int field1963; + private static int field1964; + private static int field1965; + private static int field1966; + private static int field1967; + private static int field1968; + private static int field1969; + private static int field1970; + private static int field1971; + private static int field1972; + private static int field1973; + private static int field1974; + private static int field1975; + private static int field1976; + private static int field1977; + private static int field1978; + private static int field1979; + private static int field1980; + private static int field1981; + private static int field1982; + private static int field1983; + private static int field1984; + private static int field1985; + private static int field1986; + private static int field1987; + private static int field1988; + private static int field1989; + private static int field1990; + private static int field1991; + private static int field1992; + private static int field1993; + private static int field1994; + private static int field1995; + private static int field1996; + private static int field1997; + private static int field1998; + private static int field1999; + private static int field2000; + private static int field2001; + private static int field2002; + private static int field2003; + private static int field2004; + private static int field2005; + private static int field2006; + private static int field2007; + private static int field2008; + private static int field2009; + private static int field2010; + private static int field2011; + private static int field2012; + private static int field2013; + private static int field2014; + private static int field2015; + private static int field2016; + private static int field2017; + private static int field2018; + private static int field2019; + private static int field2020; + private static int field2021; + private static int field2022; + private static int field2023; + private static int field2024; + private static int field2025; + private static int field2026; + private static int field2027; + private static int field2028; + private static int field2029; + private static int field2030; + private static int field2031; + private static int field2032; + private static int field2033; + private static int field2034; + private static int field2035; + private static int field2036; + private static int field2037; + private static int field2038; + private static int field2039; + private static int field2040; + private static int field2041; + private static int field2042; + private static int field2043; + private static int field2044; + private static int field2045; + private static int field2046; + private static int field2047; + private static int field2048; + private static int field2049; + private static int field2050; + private static int field2051; + private static int field2052; + private static int field2053; + private static int field2054; + private static int field2055; + private static int field2056; + private static int field2057; + private static int field2058; + private static int field2059; + private static int field2060; + private static int field2061; + private static int field2062; + private static int field2063; + private static int field2064; + private static int field2065; + private static int field2066; + private static int field2067; + private static int field2068; + private static int field2069; + private static int field2070; + private static int field2071; + private static int field2072; + private static int field2073; + private static int field2074; + private static int field2075; + private static int field2076; + private static int field2077; + private static int field2078; + private static int field2079; + private static int field2080; + private static int field2081; + private static int field2082; + private static int field2083; + private static int field2084; + private static int field2085; + private static int field2086; + private static int field2087; + private static int field2088; + private static int field2089; + private static int field2090; + private static int field2091; + private static int field2092; + private static int field2093; + private static int field2094; + private static int field2095; + private static int field2096; + private static int field2097; + private static int field2098; + private static int field2099; + private static int field2100; + private static int field2101; + private static int field2102; + private static int field2103; + private static int field2104; + private static int field2105; + private static int field2106; + private static int field2107; + private static int field2108; + private static int field2109; + private static int field2110; + private static int field2111; + private static int field2112; + private static int field2113; + private static int field2114; + private static int field2115; + private static int field2116; + private static int field2117; + private static int field2118; + private static int field2119; + private static int field2120; + private static int field2121; + private static int field2122; + private static int field2123; + private static int field2124; + private static int field2125; + private static int field2126; + private static int field2127; + private static int field2128; + private static int field2129; + private static int field2130; + private static int field2131; + private static int field2132; + private static int field2133; + private static int field2134; + private static int field2135; + private static int field2136; + private static int field2137; + private static int field2138; + private static int field2139; + private static int field2140; + private static int field2141; + private static int field2142; + private static int field2143; + private static int field2144; + private static int field2145; + private static int field2146; + private static int field2147; + private static int field2148; + private static int field2149; + private static int field2150; + private static int field2151; + private static int field2152; + private static int field2153; + private static int field2154; + private static int field2155; + private static int field2156; + private static int field2157; + private static int field2158; + private static int field2159; + private static int field2160; + private static int field2161; + private static int field2162; + private static int field2163; + private static int field2164; + private static int field2165; + private static int field2166; + private static int field2167; + private static int field2168; + private static int field2169; + private static int field2170; + private static int field2171; + private static int field2172; + private static int field2173; + private static int field2174; + private static int field2175; + private static int field2176; + private static int field2177; + private static int field2178; + private static int field2179; + private static int field2180; + private static int field2181; + private static int field2182; + private static int field2183; + private static int field2184; + private static int field2185; + private static int field2186; + private static int field2187; + private static int field2188; + private static int field2189; + private static int field2190; + private static int field2191; + private static int field2192; + private static int field2193; + private static int field2194; + private static int field2195; + private static int field2196; + private static int field2197; + private static int field2198; + private static int field2199; + private static int field2200; + private static int field2201; + private static int field2202; + private static int field2203; + private static int field2204; + private static int field2205; + private static int field2206; + private static int field2207; + private static int field2208; + private static int field2209; + private static int field2210; + private static int field2211; + private static int field2212; + private static int field2213; + private static int field2214; + private static int field2215; + private static int field2216; + private static int field2217; + private static int field2218; + private static int field2219; + private static int field2220; + private static int field2221; + private static int field2222; + private static int field2223; + private static int field2224; + private static int field2225; + private static int field2226; + private static int field2227; + private static int field2228; + private static int field2229; + private static int field2230; + private static int field2231; + private static int field2232; + private static int field2233; + private static int field2234; + private static int field2235; + private static int field2236; + private static int field2237; + private static int field2238; + private static int field2239; + private static int field2240; + private static int field2241; + private static int field2242; + private static int field2243; + private static int field2244; + private static int field2245; + private static int field2246; + private static int field2247; + private static int field2248; + private static int field2249; + private static int field2250; + private static int field2251; + private static int field2252; + private static int field2253; + private static int field2254; + private static int field2255; + private static int field2256; + private static int field2257; + private static int field2258; + private static int field2259; + private static int field2260; + private static int field2261; + private static int field2262; + private static int field2263; + private static int field2264; + private static int field2265; + private static int field2266; + private static int field2267; + private static int field2268; + private static int field2269; + private static int field2270; + private static int field2271; + private static int field2272; + private static int field2273; + private static int field2274; + private static int field2275; + private static int field2276; + private static int field2277; + private static int field2278; + private static int field2279; + private static int field2280; + private static int field2281; + private static int field2282; + private static int field2283; + private static int field2284; + private static int field2285; + private static int field2286; + private static int field2287; + private static int field2288; + private static int field2289; + private static int field2290; + private static int field2291; + private static int field2292; + private static int field2293; + private static int field2294; + private static int field2295; + private static int field2296; + private static int field2297; + private static int field2298; + private static int field2299; + private static int field2300; + private static int field2301; + private static int field2302; + private static int field2303; + private static int field2304; + private static int field2305; + private static int field2306; + private static int field2307; + private static int field2308; + private static int field2309; + private static int field2310; + private static int field2311; + private static int field2312; + private static int field2313; + private static int field2314; + private static int field2315; + private static int field2316; + private static int field2317; + private static int field2318; + private static int field2319; + private static int field2320; + private static int field2321; + private static int field2322; + private static int field2323; + private static int field2324; + private static int field2325; + private static int field2326; + private static int field2327; + private static int field2328; + private static int field2329; + private static int field2330; + private static int field2331; + private static int field2332; + private static int field2333; + private static int field2334; + private static int field2335; + private static int field2336; + private static int field2337; + private static int field2338; + private static int field2339; + private static int field2340; + private static int field2341; + private static int field2342; + private static int field2343; + private static int field2344; + private static int field2345; + private static int field2346; + private static int field2347; + private static int field2348; + private static int field2349; + private static int field2350; + private static int field2351; + private static int field2352; + private static int field2353; + private static int field2354; + private static int field2355; + private static int field2356; + private static int field2357; + private static int field2358; + private static int field2359; + private static int field2360; + private static int field2361; + private static int field2362; + private static int field2363; + private static int field2364; + private static int field2365; + private static int field2366; + private static int field2367; + private static int field2368; + private static int field2369; + private static int field2370; + private static int field2371; + private static int field2372; + private static int field2373; + private static int field2374; + private static int field2375; + private static int field2376; + private static int field2377; + private static int field2378; + private static int field2379; + private static int field2380; + private static int field2381; + private static int field2382; + private static int field2383; + private static int field2384; + private static int field2385; + private static int field2386; + private static int field2387; + private static int field2388; + private static int field2389; + private static int field2390; + private static int field2391; + private static int field2392; + private static int field2393; + private static int field2394; + private static int field2395; + private static int field2396; + private static int field2397; + private static int field2398; + private static int field2399; + private static int field2400; + private static int field2401; + private static int field2402; + private static int field2403; + private static int field2404; + private static int field2405; + private static int field2406; + private static int field2407; + private static int field2408; + private static int field2409; + private static int field2410; + private static int field2411; + private static int field2412; + private static int field2413; + private static int field2414; + private static int field2415; + private static int field2416; + private static int field2417; + private static int field2418; + private static int field2419; + private static int field2420; + private static int field2421; + private static int field2422; + private static int field2423; + private static int field2424; + private static int field2425; + private static int field2426; + private static int field2427; + private static int field2428; + private static int field2429; + private static int field2430; + private static int field2431; + private static int field2432; + private static int field2433; + private static int field2434; + private static int field2435; + private static int field2436; + private static int field2437; + private static int field2438; + private static int field2439; + private static int field2440; + private static int field2441; + private static int field2442; + private static int field2443; + private static int field2444; + private static int field2445; + private static int field2446; + private static int field2447; + private static int field2448; + private static int field2449; + private static int field2450; + private static int field2451; + private static int field2452; + private static int field2453; + private static int field2454; + private static int field2455; + private static int field2456; + private static int field2457; + private static int field2458; + private static int field2459; + private static int field2460; + private static int field2461; + private static int field2462; + private static int field2463; + private static int field2464; + private static int field2465; + private static int field2466; + private static int field2467; + private static int field2468; + private static int field2469; + private static int field2470; + private static int field2471; + private static int field2472; + private static int field2473; + private static int field2474; + private static int field2475; + private static int field2476; + private static int field2477; + private static int field2478; + private static int field2479; + private static int field2480; + private static int field2481; + private static int field2482; + private static int field2483; + private static int field2484; + private static int field2485; + private static int field2486; + private static int field2487; + private static int field2488; + private static int field2489; + private static int field2490; + private static int field2491; + private static int field2492; + private static int field2493; + private static int field2494; + private static int field2495; + private static int field2496; + private static int field2497; + private static int field2498; + private static int field2499; + private static int field2500; + private static int field2501; + private static int field2502; + private static int field2503; + private static int field2504; + private static int field2505; + private static int field2506; + private static int field2507; + private static int field2508; + private static int field2509; + private static int field2510; + private static int field2511; + private static int field2512; + private static int field2513; + private static int field2514; + private static int field2515; + private static int field2516; + private static int field2517; + private static int field2518; + private static int field2519; + private static int field2520; + private static int field2521; + private static int field2522; + private static int field2523; + private static int field2524; + private static int field2525; + private static int field2526; + private static int field2527; + private static int field2528; + private static int field2529; + private static int field2530; + private static int field2531; + private static int field2532; + private static int field2533; + private static int field2534; + private static int field2535; + private static int field2536; + private static int field2537; + private static int field2538; + private static int field2539; + private static int field2540; + private static int field2541; + private static int field2542; + private static int field2543; + private static int field2544; + private static int field2545; + private static int field2546; + private static int field2547; + private static int field2548; + private static int field2549; + private static int field2550; + private static int field2551; + private static int field2552; + private static int field2553; + private static int field2554; + private static int field2555; + private static int field2556; + private static int field2557; + private static int field2558; + private static int field2559; + private static int field2560; + private static int field2561; + private static int field2562; + private static int field2563; + private static int field2564; + private static int field2565; + private static int field2566; + private static int field2567; + private static int field2568; + private static int field2569; + private static int field2570; + private static int field2571; + private static int field2572; + private static int field2573; + private static int field2574; + private static int field2575; + private static int field2576; + private static int field2577; + private static int field2578; + private static int field2579; + private static int field2580; + private static int field2581; + private static int field2582; + private static int field2583; + private static int field2584; + private static int field2585; + private static int field2586; + private static int field2587; + private static int field2588; + private static int field2589; + private static int field2590; + private static int field2591; + private static int field2592; + private static int field2593; + private static int field2594; + private static int field2595; + private static int field2596; + private static int field2597; + private static int field2598; + private static int field2599; + private static int field2600; + private static int field2601; + private static int field2602; + private static int field2603; + private static int field2604; + private static int field2605; + private static int field2606; + private static int field2607; + private static int field2608; + private static int field2609; + private static int field2610; + private static int field2611; + private static int field2612; + private static int field2613; + private static int field2614; + private static int field2615; + private static int field2616; + private static int field2617; + private static int field2618; + private static int field2619; + private static int field2620; + private static int field2621; + private static int field2622; + private static int field2623; + private static int field2624; + private static int field2625; + private static int field2626; + private static int field2627; + private static int field2628; + private static int field2629; + private static int field2630; + private static int field2631; + private static int field2632; + private static int field2633; + private static int field2634; + private static int field2635; + private static int field2636; + private static int field2637; + private static int field2638; + private static int field2639; + private static int field2640; + private static int field2641; + private static int field2642; + private static int field2643; + private static int field2644; + private static int field2645; + private static int field2646; + private static int field2647; + private static int field2648; + private static int field2649; + private static int field2650; + private static int field2651; + private static int field2652; + private static int field2653; + private static int field2654; + private static int field2655; + private static int field2656; + private static int field2657; + private static int field2658; + private static int field2659; + private static int field2660; + private static int field2661; + private static int field2662; + private static int field2663; + private static int field2664; + private static int field2665; + private static int field2666; + private static int field2667; + private static int field2668; + private static int field2669; + private static int field2670; + private static int field2671; + private static int field2672; + private static int field2673; + private static int field2674; + private static int field2675; + private static int field2676; + private static int field2677; + private static int field2678; + private static int field2679; + private static int field2680; + private static int field2681; + private static int field2682; + private static int field2683; + private static int field2684; + private static int field2685; + private static int field2686; + private static int field2687; + private static int field2688; + private static int field2689; + private static int field2690; + private static int field2691; + private static int field2692; + private static int field2693; + private static int field2694; + private static int field2695; + private static int field2696; + private static int field2697; + private static int field2698; + private static int field2699; + private static int field2700; + private static int field2701; + private static int field2702; + private static int field2703; + private static int field2704; + private static int field2705; + private static int field2706; + private static int field2707; + private static int field2708; + private static int field2709; + private static int field2710; + private static int field2711; + private static int field2712; + private static int field2713; + private static int field2714; + private static int field2715; + private static int field2716; + private static int field2717; + private static int field2718; + private static int field2719; + private static int field2720; + private static int field2721; + private static int field2722; + private static int field2723; + private static int field2724; + private static int field2725; + private static int field2726; + private static int field2727; + private static int field2728; + private static int field2729; + private static int field2730; + private static int field2731; + private static int field2732; + private static int field2733; + private static int field2734; + private static int field2735; + private static int field2736; + private static int field2737; + private static int field2738; + private static int field2739; + private static int field2740; + private static int field2741; + private static int field2742; + private static int field2743; + private static int field2744; + private static int field2745; + private static int field2746; + private static int field2747; + private static int field2748; + private static int field2749; + private static int field2750; + private static int field2751; + private static int field2752; + private static int field2753; + private static int field2754; + private static int field2755; + private static int field2756; + private static int field2757; + private static int field2758; + private static int field2759; + private static int field2760; + private static int field2761; + private static int field2762; + private static int field2763; + private static int field2764; + private static int field2765; + private static int field2766; + private static int field2767; + private static int field2768; + private static int field2769; + private static int field2770; + private static int field2771; + private static int field2772; + private static int field2773; + private static int field2774; + private static int field2775; + private static int field2776; + private static int field2777; + private static int field2778; + private static int field2779; + private static int field2780; + private static int field2781; + private static int field2782; + private static int field2783; + private static int field2784; + private static int field2785; + private static int field2786; + private static int field2787; + private static int field2788; + private static int field2789; + private static int field2790; + private static int field2791; + private static int field2792; + private static int field2793; + private static int field2794; + private static int field2795; + private static int field2796; + private static int field2797; + private static int field2798; + private static int field2799; + private static int field2800; + private static int field2801; + private static int field2802; + private static int field2803; + private static int field2804; + private static int field2805; + private static int field2806; + private static int field2807; + private static int field2808; + private static int field2809; + private static int field2810; + private static int field2811; + private static int field2812; + private static int field2813; + private static int field2814; + private static int field2815; + private static int field2816; + private static int field2817; + private static int field2818; + private static int field2819; + private static int field2820; + private static int field2821; + private static int field2822; + private static int field2823; + private static int field2824; + private static int field2825; + private static int field2826; + private static int field2827; + private static int field2828; + private static int field2829; + private static int field2830; + private static int field2831; + private static int field2832; + private static int field2833; + private static int field2834; + private static int field2835; + private static int field2836; + private static int field2837; + private static int field2838; + private static int field2839; + private static int field2840; + private static int field2841; + private static int field2842; + private static int field2843; + private static int field2844; + private static int field2845; + private static int field2846; + private static int field2847; + private static int field2848; + private static int field2849; + private static int field2850; + private static int field2851; + private static int field2852; + private static int field2853; + private static int field2854; + private static int field2855; + private static int field2856; + private static int field2857; + private static int field2858; + private static int field2859; + private static int field2860; + private static int field2861; + private static int field2862; + private static int field2863; + private static int field2864; + private static int field2865; + private static int field2866; + private static int field2867; + private static int field2868; + private static int field2869; + private static int field2870; + private static int field2871; + private static int field2872; + private static int field2873; + private static int field2874; + private static int field2875; + private static int field2876; + private static int field2877; + private static int field2878; + private static int field2879; + private static int field2880; + private static int field2881; + private static int field2882; + private static int field2883; + private static int field2884; + private static int field2885; + private static int field2886; + private static int field2887; + private static int field2888; + private static int field2889; + private static int field2890; + private static int field2891; + private static int field2892; + private static int field2893; + private static int field2894; + private static int field2895; + private static int field2896; + private static int field2897; + private static int field2898; + private static int field2899; + private static int field2900; + private static int field2901; + private static int field2902; + private static int field2903; + private static int field2904; + private static int field2905; + private static int field2906; + private static int field2907; + private static int field2908; + private static int field2909; + private static int field2910; + private static int field2911; + private static int field2912; + private static int field2913; + private static int field2914; + private static int field2915; + private static int field2916; + private static int field2917; + private static int field2918; + private static int field2919; + private static int field2920; + private static int field2921; + private static int field2922; + private static int field2923; + private static int field2924; + private static int field2925; + private static int field2926; + private static int field2927; + private static int field2928; + private static int field2929; + private static int field2930; + private static int field2931; + private static int field2932; + private static int field2933; + private static int field2934; + private static int field2935; + private static int field2936; + private static int field2937; + private static int field2938; + private static int field2939; + private static int field2940; + private static int field2941; + private static int field2942; + private static int field2943; + private static int field2944; + private static int field2945; + private static int field2946; + private static int field2947; + private static int field2948; + private static int field2949; + private static int field2950; + private static int field2951; + private static int field2952; + private static int field2953; + private static int field2954; + private static int field2955; + private static int field2956; + private static int field2957; + private static int field2958; + private static int field2959; + private static int field2960; + private static int field2961; + private static int field2962; + private static int field2963; + private static int field2964; + private static int field2965; + private static int field2966; + private static int field2967; + private static int field2968; + private static int field2969; + private static int field2970; + private static int field2971; + private static int field2972; + private static int field2973; + private static int field2974; + private static int field2975; + private static int field2976; + private static int field2977; + private static int field2978; + private static int field2979; + private static int field2980; + private static int field2981; + private static int field2982; + private static int field2983; + private static int field2984; + private static int field2985; + private static int field2986; + private static int field2987; + private static int field2988; + private static int field2989; + private static int field2990; + private static int field2991; + private static int field2992; + private static int field2993; + private static int field2994; + private static int field2995; + private static int field2996; + private static int field2997; + private static int field2998; + private static int field2999; + private static int field3000; + private static int field3001; + private static int field3002; + private static int field3003; + private static int field3004; + private static int field3005; + private static int field3006; + private static int field3007; + private static int field3008; + private static int field3009; + private static int field3010; + private static int field3011; + private static int field3012; + private static int field3013; + private static int field3014; + private static int field3015; + private static int field3016; + private static int field3017; + private static int field3018; + private static int field3019; + private static int field3020; + private static int field3021; + private static int field3022; + private static int field3023; + private static int field3024; + private static int field3025; + private static int field3026; + private static int field3027; + private static int field3028; + private static int field3029; + private static int field3030; + private static int field3031; + private static int field3032; + private static int field3033; + private static int field3034; + private static int field3035; + private static int field3036; + private static int field3037; + private static int field3038; + private static int field3039; + private static int field3040; + private static int field3041; + private static int field3042; + private static int field3043; + private static int field3044; + private static int field3045; + private static int field3046; + private static int field3047; + private static int field3048; + private static int field3049; + private static int field3050; + private static int field3051; + private static int field3052; + private static int field3053; + private static int field3054; + private static int field3055; + private static int field3056; + private static int field3057; + private static int field3058; + private static int field3059; + private static int field3060; + private static int field3061; + private static int field3062; + private static int field3063; + private static int field3064; + private static int field3065; + private static int field3066; + private static int field3067; + private static int field3068; + private static int field3069; + private static int field3070; + private static int field3071; + private static int field3072; + private static int field3073; + private static int field3074; + private static int field3075; + private static int field3076; + private static int field3077; + private static int field3078; + private static int field3079; + private static int field3080; + private static int field3081; + private static int field3082; + private static int field3083; + private static int field3084; + private static int field3085; + private static int field3086; + private static int field3087; + private static int field3088; + private static int field3089; + private static int field3090; + private static int field3091; + private static int field3092; + private static int field3093; + private static int field3094; + private static int field3095; + private static int field3096; + private static int field3097; + private static int field3098; + private static int field3099; + private static int field3100; + private static int field3101; + private static int field3102; + private static int field3103; + private static int field3104; + private static int field3105; + private static int field3106; + private static int field3107; + private static int field3108; + private static int field3109; + private static int field3110; + private static int field3111; + private static int field3112; + private static int field3113; + private static int field3114; + private static int field3115; + private static int field3116; + private static int field3117; + private static int field3118; + private static int field3119; + private static int field3120; + private static int field3121; + private static int field3122; + private static int field3123; + private static int field3124; + private static int field3125; + private static int field3126; + private static int field3127; + private static int field3128; + private static int field3129; + private static int field3130; + private static int field3131; + private static int field3132; + private static int field3133; + private static int field3134; + private static int field3135; + private static int field3136; + private static int field3137; + private static int field3138; + private static int field3139; + private static int field3140; + private static int field3141; + private static int field3142; + private static int field3143; + private static int field3144; + private static int field3145; + private static int field3146; + private static int field3147; + private static int field3148; + private static int field3149; + private static int field3150; + private static int field3151; + private static int field3152; + private static int field3153; + private static int field3154; + private static int field3155; + private static int field3156; + private static int field3157; + private static int field3158; + private static int field3159; + private static int field3160; + private static int field3161; + private static int field3162; + private static int field3163; + private static int field3164; + private static int field3165; + private static int field3166; + private static int field3167; + private static int field3168; + private static int field3169; + private static int field3170; + private static int field3171; + private static int field3172; + private static int field3173; + private static int field3174; + private static int field3175; + private static int field3176; + private static int field3177; + private static int field3178; + private static int field3179; + private static int field3180; + private static int field3181; + private static int field3182; + private static int field3183; + private static int field3184; + private static int field3185; + private static int field3186; + private static int field3187; + private static int field3188; + private static int field3189; + private static int field3190; + private static int field3191; + private static int field3192; + private static int field3193; + private static int field3194; + private static int field3195; + private static int field3196; + private static int field3197; + private static int field3198; + private static int field3199; + private static int field3200; + private static int field3201; + private static int field3202; + private static int field3203; + private static int field3204; + private static int field3205; + private static int field3206; + private static int field3207; + private static int field3208; + private static int field3209; + private static int field3210; + private static int field3211; + private static int field3212; + private static int field3213; + private static int field3214; + private static int field3215; + private static int field3216; + private static int field3217; + private static int field3218; + private static int field3219; + private static int field3220; + private static int field3221; + private static int field3222; + private static int field3223; + private static int field3224; + private static int field3225; + private static int field3226; + private static int field3227; + private static int field3228; + private static int field3229; + private static int field3230; + private static int field3231; + private static int field3232; + private static int field3233; + private static int field3234; + private static int field3235; + private static int field3236; + private static int field3237; + private static int field3238; + private static int field3239; + private static int field3240; + private static int field3241; + private static int field3242; + private static int field3243; + private static int field3244; + private static int field3245; + private static int field3246; + private static int field3247; + private static int field3248; + private static int field3249; + private static int field3250; + private static int field3251; + private static int field3252; + private static int field3253; + private static int field3254; + private static int field3255; + private static int field3256; + private static int field3257; + private static int field3258; + private static int field3259; + private static int field3260; + private static int field3261; + private static int field3262; + private static int field3263; + private static int field3264; + private static int field3265; + private static int field3266; + private static int field3267; + private static int field3268; + private static int field3269; + private static int field3270; + private static int field3271; + private static int field3272; + private static int field3273; + private static int field3274; + private static int field3275; + private static int field3276; + private static int field3277; + private static int field3278; + private static int field3279; + private static int field3280; + private static int field3281; + private static int field3282; + private static int field3283; + private static int field3284; + private static int field3285; + private static int field3286; + private static int field3287; + private static int field3288; + private static int field3289; + private static int field3290; + private static int field3291; + private static int field3292; + private static int field3293; + private static int field3294; + private static int field3295; + private static int field3296; + private static int field3297; + private static int field3298; + private static int field3299; + private static int field3300; + private static int field3301; + private static int field3302; + private static int field3303; + private static int field3304; + private static int field3305; + private static int field3306; + private static int field3307; + private static int field3308; + private static int field3309; + private static int field3310; + private static int field3311; + private static int field3312; + private static int field3313; + private static int field3314; + private static int field3315; + private static int field3316; + private static int field3317; + private static int field3318; + private static int field3319; + private static int field3320; + private static int field3321; + private static int field3322; + private static int field3323; + private static int field3324; + private static int field3325; + private static int field3326; + private static int field3327; + private static int field3328; + private static int field3329; + private static int field3330; + private static int field3331; + private static int field3332; + private static int field3333; + private static int field3334; + private static int field3335; + private static int field3336; + private static int field3337; + private static int field3338; + private static int field3339; + private static int field3340; + private static int field3341; + private static int field3342; + private static int field3343; + private static int field3344; + private static int field3345; + private static int field3346; + private static int field3347; + private static int field3348; + private static int field3349; + private static int field3350; + private static int field3351; + private static int field3352; + private static int field3353; + private static int field3354; + private static int field3355; + private static int field3356; + private static int field3357; + private static int field3358; + private static int field3359; + private static int field3360; + private static int field3361; + private static int field3362; + private static int field3363; + private static int field3364; + private static int field3365; + private static int field3366; + private static int field3367; + private static int field3368; + private static int field3369; + private static int field3370; + private static int field3371; + private static int field3372; + private static int field3373; + private static int field3374; + private static int field3375; + private static int field3376; + private static int field3377; + private static int field3378; + private static int field3379; + private static int field3380; + private static int field3381; + private static int field3382; + private static int field3383; + private static int field3384; + private static int field3385; + private static int field3386; + private static int field3387; + private static int field3388; + private static int field3389; + private static int field3390; + private static int field3391; + private static int field3392; + private static int field3393; + private static int field3394; + private static int field3395; + private static int field3396; + private static int field3397; + private static int field3398; + private static int field3399; + private static int field3400; + private static int field3401; + private static int field3402; + private static int field3403; + private static int field3404; + private static int field3405; + private static int field3406; + private static int field3407; + private static int field3408; + private static int field3409; + private static int field3410; + private static int field3411; + private static int field3412; + private static int field3413; + private static int field3414; + private static int field3415; + private static int field3416; + private static int field3417; + private static int field3418; + private static int field3419; + private static int field3420; + private static int field3421; + private static int field3422; + private static int field3423; + private static int field3424; + private static int field3425; + private static int field3426; + private static int field3427; + private static int field3428; + private static int field3429; + private static int field3430; + private static int field3431; + private static int field3432; + private static int field3433; + private static int field3434; + private static int field3435; + private static int field3436; + private static int field3437; + private static int field3438; + private static int field3439; + private static int field3440; + private static int field3441; + private static int field3442; + private static int field3443; + private static int field3444; + private static int field3445; + private static int field3446; + private static int field3447; + private static int field3448; + private static int field3449; + private static int field3450; + private static int field3451; + private static int field3452; + private static int field3453; + private static int field3454; + private static int field3455; + private static int field3456; + private static int field3457; + private static int field3458; + private static int field3459; + private static int field3460; + private static int field3461; + private static int field3462; + private static int field3463; + private static int field3464; + private static int field3465; + private static int field3466; + private static int field3467; + private static int field3468; + private static int field3469; + private static int field3470; + private static int field3471; + private static int field3472; + private static int field3473; + private static int field3474; + private static int field3475; + private static int field3476; + private static int field3477; + private static int field3478; + private static int field3479; + private static int field3480; + private static int field3481; + private static int field3482; + private static int field3483; + private static int field3484; + private static int field3485; + private static int field3486; + private static int field3487; + private static int field3488; + private static int field3489; + private static int field3490; + private static int field3491; + private static int field3492; + private static int field3493; + private static int field3494; + private static int field3495; + private static int field3496; + private static int field3497; + private static int field3498; + private static int field3499; + private static int field3500; + private static int field3501; + private static int field3502; + private static int field3503; + private static int field3504; + private static int field3505; + private static int field3506; + private static int field3507; + private static int field3508; + private static int field3509; + private static int field3510; + private static int field3511; + private static int field3512; + private static int field3513; + private static int field3514; + private static int field3515; + private static int field3516; + private static int field3517; + private static int field3518; + private static int field3519; + private static int field3520; + private static int field3521; + private static int field3522; + private static int field3523; + private static int field3524; + private static int field3525; + private static int field3526; + private static int field3527; + private static int field3528; + private static int field3529; + private static int field3530; + private static int field3531; + private static int field3532; + private static int field3533; + private static int field3534; + private static int field3535; + private static int field3536; + private static int field3537; + private static int field3538; + private static int field3539; + private static int field3540; + private static int field3541; + private static int field3542; + private static int field3543; + private static int field3544; + private static int field3545; + private static int field3546; + private static int field3547; + private static int field3548; + private static int field3549; + private static int field3550; + private static int field3551; + private static int field3552; + private static int field3553; + private static int field3554; + private static int field3555; + private static int field3556; + private static int field3557; + private static int field3558; + private static int field3559; + private static int field3560; + private static int field3561; + private static int field3562; + private static int field3563; + private static int field3564; + private static int field3565; + private static int field3566; + private static int field3567; + private static int field3568; + private static int field3569; + private static int field3570; + private static int field3571; + private static int field3572; + private static int field3573; + private static int field3574; + private static int field3575; + private static int field3576; + private static int field3577; + private static int field3578; + private static int field3579; + private static int field3580; + private static int field3581; + private static int field3582; + private static int field3583; + private static int field3584; + private static int field3585; + private static int field3586; + private static int field3587; + private static int field3588; + private static int field3589; + private static int field3590; + private static int field3591; + private static int field3592; + private static int field3593; + private static int field3594; + private static int field3595; + private static int field3596; + private static int field3597; + private static int field3598; + private static int field3599; + private static int field3600; + private static int field3601; + private static int field3602; + private static int field3603; + private static int field3604; + private static int field3605; + private static int field3606; + private static int field3607; + private static int field3608; + private static int field3609; + private static int field3610; + private static int field3611; + private static int field3612; + private static int field3613; + private static int field3614; + private static int field3615; + private static int field3616; + private static int field3617; + private static int field3618; + private static int field3619; + private static int field3620; + private static int field3621; + private static int field3622; + private static int field3623; + private static int field3624; + private static int field3625; + private static int field3626; + private static int field3627; + private static int field3628; + private static int field3629; + private static int field3630; + private static int field3631; + private static int field3632; + private static int field3633; + private static int field3634; + private static int field3635; + private static int field3636; + private static int field3637; + private static int field3638; + private static int field3639; + private static int field3640; + private static int field3641; + private static int field3642; + private static int field3643; + private static int field3644; + private static int field3645; + private static int field3646; + private static int field3647; + private static int field3648; + private static int field3649; + private static int field3650; + private static int field3651; + private static int field3652; + private static int field3653; + private static int field3654; + private static int field3655; + private static int field3656; + private static int field3657; + private static int field3658; + private static int field3659; + private static int field3660; + private static int field3661; + private static int field3662; + private static int field3663; + private static int field3664; + private static int field3665; + private static int field3666; + private static int field3667; + private static int field3668; + private static int field3669; + private static int field3670; + private static int field3671; + private static int field3672; + private static int field3673; + private static int field3674; + private static int field3675; + private static int field3676; + private static int field3677; + private static int field3678; + private static int field3679; + private static int field3680; + private static int field3681; + private static int field3682; + private static int field3683; + private static int field3684; + private static int field3685; + private static int field3686; + private static int field3687; + private static int field3688; + private static int field3689; + private static int field3690; + private static int field3691; + private static int field3692; + private static int field3693; + private static int field3694; + private static int field3695; + private static int field3696; + private static int field3697; + private static int field3698; + private static int field3699; + private static int field3700; + private static int field3701; + private static int field3702; + private static int field3703; + private static int field3704; + private static int field3705; + private static int field3706; + private static int field3707; + private static int field3708; + private static int field3709; + private static int field3710; + private static int field3711; + private static int field3712; + private static int field3713; + private static int field3714; + private static int field3715; + private static int field3716; + private static int field3717; + private static int field3718; + private static int field3719; + private static int field3720; + private static int field3721; + private static int field3722; + private static int field3723; + private static int field3724; + private static int field3725; + private static int field3726; + private static int field3727; + private static int field3728; + private static int field3729; + private static int field3730; + private static int field3731; + private static int field3732; + private static int field3733; + private static int field3734; + private static int field3735; + private static int field3736; + private static int field3737; + private static int field3738; + private static int field3739; + private static int field3740; + private static int field3741; + private static int field3742; + private static int field3743; + private static int field3744; + private static int field3745; + private static int field3746; + private static int field3747; + private static int field3748; + private static int field3749; + private static int field3750; + private static int field3751; + private static int field3752; + private static int field3753; + private static int field3754; + private static int field3755; + private static int field3756; + private static int field3757; + private static int field3758; + private static int field3759; + private static int field3760; + private static int field3761; + private static int field3762; + private static int field3763; + private static int field3764; + private static int field3765; + private static int field3766; + private static int field3767; + private static int field3768; + private static int field3769; + private static int field3770; + private static int field3771; + private static int field3772; + private static int field3773; + private static int field3774; + private static int field3775; + private static int field3776; + private static int field3777; + private static int field3778; + private static int field3779; + private static int field3780; + private static int field3781; + private static int field3782; + private static int field3783; + private static int field3784; + private static int field3785; + private static int field3786; + private static int field3787; + private static int field3788; + private static int field3789; + private static int field3790; + private static int field3791; + private static int field3792; + private static int field3793; + private static int field3794; + private static int field3795; + private static int field3796; + private static int field3797; + private static int field3798; + private static int field3799; + private static int field3800; + private static int field3801; + private static int field3802; + private static int field3803; + private static int field3804; + private static int field3805; + private static int field3806; + private static int field3807; + private static int field3808; + private static int field3809; + private static int field3810; + private static int field3811; + private static int field3812; + private static int field3813; + private static int field3814; + private static int field3815; + private static int field3816; + private static int field3817; + private static int field3818; + private static int field3819; + private static int field3820; + private static int field3821; + private static int field3822; + private static int field3823; + private static int field3824; + private static int field3825; + private static int field3826; + private static int field3827; + private static int field3828; + private static int field3829; + private static int field3830; + private static int field3831; + private static int field3832; + private static int field3833; + private static int field3834; + private static int field3835; + private static int field3836; + private static int field3837; + private static int field3838; + private static int field3839; + private static int field3840; + private static int field3841; + private static int field3842; + private static int field3843; + private static int field3844; + private static int field3845; + private static int field3846; + private static int field3847; + private static int field3848; + private static int field3849; + private static int field3850; + private static int field3851; + private static int field3852; + private static int field3853; + private static int field3854; + private static int field3855; + private static int field3856; + private static int field3857; + private static int field3858; + private static int field3859; + private static int field3860; + private static int field3861; + private static int field3862; + private static int field3863; + private static int field3864; + private static int field3865; + private static int field3866; + private static int field3867; + private static int field3868; + private static int field3869; + private static int field3870; + private static int field3871; + private static int field3872; + private static int field3873; + private static int field3874; + private static int field3875; + private static int field3876; + private static int field3877; + private static int field3878; + private static int field3879; + private static int field3880; + private static int field3881; + private static int field3882; + private static int field3883; + private static int field3884; + private static int field3885; + private static int field3886; + private static int field3887; + private static int field3888; + private static int field3889; + private static int field3890; + private static int field3891; + private static int field3892; + private static int field3893; + private static int field3894; + private static int field3895; + private static int field3896; + private static int field3897; + private static int field3898; + private static int field3899; + private static int field3900; + private static int field3901; + private static int field3902; + private static int field3903; + private static int field3904; + private static int field3905; + private static int field3906; + private static int field3907; + private static int field3908; + private static int field3909; + private static int field3910; + private static int field3911; + private static int field3912; + private static int field3913; + private static int field3914; + private static int field3915; + private static int field3916; + private static int field3917; + private static int field3918; + private static int field3919; + private static int field3920; + private static int field3921; + private static int field3922; + private static int field3923; + private static int field3924; + private static int field3925; + private static int field3926; + private static int field3927; + private static int field3928; + private static int field3929; + private static int field3930; + private static int field3931; + private static int field3932; + private static int field3933; + private static int field3934; + private static int field3935; + private static int field3936; + private static int field3937; + private static int field3938; + private static int field3939; + private static int field3940; + private static int field3941; + private static int field3942; + private static int field3943; + private static int field3944; + private static int field3945; + private static int field3946; + private static int field3947; + private static int field3948; + private static int field3949; + private static int field3950; + private static int field3951; + private static int field3952; + private static int field3953; + private static int field3954; + private static int field3955; + private static int field3956; + private static int field3957; + private static int field3958; + private static int field3959; + private static int field3960; + private static int field3961; + private static int field3962; + private static int field3963; + private static int field3964; + private static int field3965; + private static int field3966; + private static int field3967; + private static int field3968; + private static int field3969; + private static int field3970; + private static int field3971; + private static int field3972; + private static int field3973; + private static int field3974; + private static int field3975; + private static int field3976; + private static int field3977; + private static int field3978; + private static int field3979; + private static int field3980; + private static int field3981; + private static int field3982; + private static int field3983; + private static int field3984; + private static int field3985; + private static int field3986; + private static int field3987; + private static int field3988; + private static int field3989; + private static int field3990; + private static int field3991; + private static int field3992; + private static int field3993; + private static int field3994; + private static int field3995; + private static int field3996; + private static int field3997; + private static int field3998; + private static int field3999; +} diff --git a/test/hotspot/jtreg/compiler/controldependency/TestAntiDependencyForPinnedLoads.java b/test/hotspot/jtreg/compiler/controldependency/TestAntiDependencyForPinnedLoads.java new file mode 100644 index 00000000000..05673015ebe --- /dev/null +++ b/test/hotspot/jtreg/compiler/controldependency/TestAntiDependencyForPinnedLoads.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8337066 + * @summary Test that MergeMem is skipped when looking for stores + * @run main/othervm -Xbatch -XX:-TieredCompilation + * -XX:CompileCommand=compileonly,java.lang.StringUTF16::reverse + * compiler.controldependency.TestAntiDependencyForPinnedLoads + */ + +package compiler.controldependency; + +public class TestAntiDependencyForPinnedLoads { + public static void main(String[] args) { + for(int i = 0; i < 50_000; i++) { + String str = "YYYY年MM月DD日"; + StringBuffer strBuffer = new StringBuffer(str); + String revStr = strBuffer.reverse().toString(); + if (!revStr.equals("日DD月MM年YYYY")) throw new InternalError("FAIL"); + } + } +} diff --git a/test/hotspot/jtreg/compiler/debug/TestStressBailout.java b/test/hotspot/jtreg/compiler/debug/TestStressBailout.java new file mode 100644 index 00000000000..68610576a39 --- /dev/null +++ b/test/hotspot/jtreg/compiler/debug/TestStressBailout.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package compiler.debug; + +import java.util.Random; + +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; +import jdk.test.lib.Utils; + +/* + * @test + * @key stress randomness + * @bug 8330157 + * @requires vm.debug == true & vm.compiler2.enabled & (vm.opt.AbortVMOnCompilationFailure == "null" | !vm.opt.AbortVMOnCompilationFailure) + * @summary Basic tests for bailout stress flag. + * @library /test/lib / + * @run driver compiler.debug.TestStressBailout + */ + +public class TestStressBailout { + + static void runTest(int invprob) throws Exception { + String[] procArgs = {"-Xcomp", "-XX:-TieredCompilation", "-XX:+StressBailout", + "-XX:StressBailoutMean=" + invprob, "-version"}; + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(procArgs); + OutputAnalyzer out = new OutputAnalyzer(pb.start()); + out.shouldHaveExitValue(0); + } + + public static void main(String[] args) throws Exception { + Random r = Utils.getRandomInstance(); + // Likely bail out on -version, for some low Mean value. + runTest(r.nextInt(1, 10)); + // Higher value + runTest(r.nextInt(10, 1_000_000)); + } +} diff --git a/test/hotspot/jtreg/compiler/floatingpoint/TestRoundFloatAll.java b/test/hotspot/jtreg/compiler/floatingpoint/TestRoundFloatAll.java new file mode 100644 index 00000000000..2ba60fd8e31 --- /dev/null +++ b/test/hotspot/jtreg/compiler/floatingpoint/TestRoundFloatAll.java @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, Rivos 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 8321010 + * @summary Test intrinsic for Math.round(float) in full 32 bits range + * + * @library /test/lib / + * @modules java.base/jdk.internal.math + * @requires os.arch == "riscv64" + * @run main/othervm -XX:-TieredCompilation -Xbatch -XX:CompileThresholdScaling=0.3 -XX:-UseSuperWord + * -XX:CompileCommand=compileonly,compiler.floatingpoint.TestRoundFloatAll::test* + * compiler.floatingpoint.TestRoundFloatAll + */ + +package compiler.floatingpoint; + +import static compiler.lib.golden.GoldenRound.golden_round; + +public class TestRoundFloatAll { + + public static void main(String args[]) { + test(); + } + + // return true when test fails + static boolean test(int n, float f) { + int actual = Math.round(f); + int expected = golden_round(f); + if (actual != expected) { + System.err.println("round error, input: " + f + ", res: " + actual + "expected: " + expected + ", input hex: " + n); + return true; + } + return false; + } + + static void test() { + final int ITERS = 11000; + boolean fail = false; + + // Warmup + System.out.println("Warmup"); + for (int i=0; i ref) { + return ref.get(); + } + + @Test + @IR(applyIf = {"UseCompressedOops", "false"}, + counts = {IRNode.G1_LOAD_P_WITH_BARRIER_FLAG, PRE_ONLY, "1"}, + phase = CompilePhase.FINAL_CODE) + @IR(applyIf = {"UseCompressedOops", "true"}, + counts = {IRNode.G1_LOAD_N_WITH_BARRIER_FLAG, PRE_ONLY, "1"}, + phase = CompilePhase.FINAL_CODE) + static Object testLoadWeakReference(WeakReference ref) { + return ref.get(); + } + + @Run(test = {"testLoadSoftReference", + "testLoadWeakReference"}) + public void runReferenceTests() { + { + Object o1 = new Object(); + SoftReference sref = new SoftReference(o1); + Object o2 = testLoadSoftReference(sref); + Asserts.assertTrue(o2 == o1 || o2 == null); + } + { + Object o1 = new Object(); + WeakReference wref = new WeakReference(o1); + Object o2 = testLoadWeakReference(wref); + Asserts.assertTrue(o2 == o1 || o2 == null); + } + } +} diff --git a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest.java b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest.java index 5855440d0b2..1dcef0c96cd 100644 --- a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest.java +++ b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest.java @@ -27,6 +27,7 @@ * * @requires vm.jvmci & vm.compMode == "Xmixed" * @requires vm.opt.final.EliminateAllocations == true + * @requires vm.opt.StressUnstableIfTraps == null | !vm.opt.StressUnstableIfTraps * * @comment no "-Xcomp -XX:-TieredCompilation" combination allowed until JDK-8140018 is resolved * @requires vm.opt.TieredCompilation == null | vm.opt.TieredCompilation == true diff --git a/test/hotspot/jtreg/compiler/lib/golden/GoldenRound.java b/test/hotspot/jtreg/compiler/lib/golden/GoldenRound.java new file mode 100644 index 00000000000..38bceeafe26 --- /dev/null +++ b/test/hotspot/jtreg/compiler/lib/golden/GoldenRound.java @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, Rivos 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. + */ + +package compiler.lib.golden; + +import jdk.internal.math.DoubleConsts; +import jdk.internal.math.FloatConsts; + +public class GoldenRound { + public static int golden_round(float a) { + // below code is copied from java.base/share/classes/java/lang/Math.java + // public static int round(float a) { ... } + + int intBits = Float.floatToRawIntBits(a); + int biasedExp = (intBits & FloatConsts.EXP_BIT_MASK) + >> (FloatConsts.SIGNIFICAND_WIDTH - 1); + int shift = (FloatConsts.SIGNIFICAND_WIDTH - 2 + + FloatConsts.EXP_BIAS) - biasedExp; + if ((shift & -32) == 0) { // shift >= 0 && shift < 32 + // a is a finite number such that pow(2,-32) <= ulp(a) < 1 + int r = ((intBits & FloatConsts.SIGNIF_BIT_MASK) + | (FloatConsts.SIGNIF_BIT_MASK + 1)); + if (intBits < 0) { + r = -r; + } + // In the comments below each Java expression evaluates to the value + // the corresponding mathematical expression: + // (r) evaluates to a / ulp(a) + // (r >> shift) evaluates to floor(a * 2) + // ((r >> shift) + 1) evaluates to floor((a + 1/2) * 2) + // (((r >> shift) + 1) >> 1) evaluates to floor(a + 1/2) + return ((r >> shift) + 1) >> 1; + } else { + // a is either + // - a finite number with abs(a) < exp(2,FloatConsts.SIGNIFICAND_WIDTH-32) < 1/2 + // - a finite number with ulp(a) >= 1 and hence a is a mathematical integer + // - an infinity or NaN + return (int) a; + } + } + + + public static long golden_round(double a) { + // below code is copied from java.base/share/classes/java/lang/Math.java + // public static int round(double a) { ... } + + long longBits = Double.doubleToRawLongBits(a); + long biasedExp = (longBits & DoubleConsts.EXP_BIT_MASK) + >> (DoubleConsts.SIGNIFICAND_WIDTH - 1); + long shift = (DoubleConsts.SIGNIFICAND_WIDTH - 2 + + DoubleConsts.EXP_BIAS) - biasedExp; + if ((shift & -64) == 0) { // shift >= 0 && shift < 64 + // a is a finite number such that pow(2,-64) <= ulp(a) < 1 + long r = ((longBits & DoubleConsts.SIGNIF_BIT_MASK) + | (DoubleConsts.SIGNIF_BIT_MASK + 1)); + if (longBits < 0) { + r = -r; + } + // In the comments below each Java expression evaluates to the value + // the corresponding mathematical expression: + // (r) evaluates to a / ulp(a) + // (r >> shift) evaluates to floor(a * 2) + // ((r >> shift) + 1) evaluates to floor((a + 1/2) * 2) + // (((r >> shift) + 1) >> 1) evaluates to floor(a + 1/2) + return ((r >> shift) + 1) >> 1; + } else { + // a is either + // - a finite number with abs(a) < exp(2,DoubleConsts.SIGNIFICAND_WIDTH-64) < 1/2 + // - a finite number with ulp(a) >= 1 and hence a is a mathematical integer + // - an infinity or NaN + return (long) a; + } + } +} diff --git a/test/hotspot/jtreg/compiler/lib/ir_framework/IRNode.java b/test/hotspot/jtreg/compiler/lib/ir_framework/IRNode.java index 1b554df9e67..8c4b3c93343 100644 --- a/test/hotspot/jtreg/compiler/lib/ir_framework/IRNode.java +++ b/test/hotspot/jtreg/compiler/lib/ir_framework/IRNode.java @@ -119,13 +119,13 @@ public class IRNode { public static final String VECTOR_SIZE_32 = VECTOR_SIZE + "32"; public static final String VECTOR_SIZE_64 = VECTOR_SIZE + "64"; - private static final String TYPE_BYTE = "byte"; - private static final String TYPE_CHAR = "char"; - private static final String TYPE_SHORT = "short"; - private static final String TYPE_INT = "int"; - private static final String TYPE_LONG = "long"; - private static final String TYPE_FLOAT = "float"; - private static final String TYPE_DOUBLE = "double"; + private static final String TYPE_BYTE = "B"; + private static final String TYPE_CHAR = "C"; + private static final String TYPE_SHORT = "S"; + private static final String TYPE_INT = "I"; + private static final String TYPE_LONG = "J"; + private static final String TYPE_FLOAT = "F"; + private static final String TYPE_DOUBLE = "D"; /** * IR placeholder string to regex-for-compile-phase map. @@ -276,25 +276,25 @@ public class IRNode { public static final String ALLOC = PREFIX + "ALLOC" + POSTFIX; static { - String optoRegex = "(.*precise .*\\R((.*(?i:mov|mv|xorl|nop|spill).*|\\s*)\\R)*.*(?i:call,static).*wrapper for: _new_instance_Java" + END; + String optoRegex = "(.*precise .*\\R((.*(?i:mov|mv|xorl|nop|spill).*|\\s*)\\R)*.*(?i:call,static).*wrapper for: C2 Runtime new_instance" + END; allocNodes(ALLOC, "Allocate", optoRegex); } public static final String ALLOC_OF = COMPOSITE_PREFIX + "ALLOC_OF" + POSTFIX; static { - String regex = "(.*precise .*" + IS_REPLACED + ":.*\\R((.*(?i:mov|mv|xorl|nop|spill).*|\\s*)\\R)*.*(?i:call,static).*wrapper for: _new_instance_Java" + END; + String regex = "(.*precise .*" + IS_REPLACED + ":.*\\R((.*(?i:mov|mv|xorl|nop|spill).*|\\s*)\\R)*.*(?i:call,static).*wrapper for: C2 Runtime new_instance" + END; optoOnly(ALLOC_OF, regex); } public static final String ALLOC_ARRAY = PREFIX + "ALLOC_ARRAY" + POSTFIX; static { - String optoRegex = "(.*precise \\[.*\\R((.*(?i:mov|mv|xor|nop|spill).*|\\s*|.*(LGHI|LI).*)\\R)*.*(?i:call,static).*wrapper for: _new_array_Java" + END; + String optoRegex = "(.*precise \\[.*\\R((.*(?i:mov|mv|xor|nop|spill).*|\\s*|.*(LGHI|LI).*)\\R)*.*(?i:call,static).*wrapper for: C2 Runtime new_array" + END; allocNodes(ALLOC_ARRAY, "AllocateArray", optoRegex); } public static final String ALLOC_ARRAY_OF = COMPOSITE_PREFIX + "ALLOC_ARRAY_OF" + POSTFIX; static { - String regex = "(.*precise \\[.*" + IS_REPLACED + ":.*\\R((.*(?i:mov|mv|xorl|nop|spill).*|\\s*|.*(LGHI|LI).*)\\R)*.*(?i:call,static).*wrapper for: _new_array_Java" + END; + String regex = "(.*precise \\[.*" + IS_REPLACED + ":.*\\R((.*(?i:mov|mv|xorl|nop|spill).*|\\s*|.*(LGHI|LI).*)\\R)*.*(?i:call,static).*wrapper for: C2 Runtime new_array" + END; optoOnly(ALLOC_ARRAY_OF, regex); } @@ -358,6 +358,11 @@ public class IRNode { beforeMatchingNameRegex(CALL, "Call.*Java"); } + public static final String CALL_OF = COMPOSITE_PREFIX + "CALL_OF" + POSTFIX; + static { + callOfNodes(CALL_OF, "Call.*"); + } + public static final String CALL_OF_METHOD = COMPOSITE_PREFIX + "CALL_OF_METHOD" + POSTFIX; static { callOfNodes(CALL_OF_METHOD, "Call.*Java"); @@ -514,11 +519,26 @@ public class IRNode { trapNodes(DIV_BY_ZERO_TRAP, "div0_check"); } + public static final String DIV_I = PREFIX + "DIV_I" + POSTFIX; + static { + beforeMatchingNameRegex(DIV_I, "DivI"); + } + public static final String DIV_L = PREFIX + "DIV_L" + POSTFIX; static { beforeMatchingNameRegex(DIV_L, "DivL"); } + public static final String DIV_MOD_I = PREFIX + "DIV_MOD_I" + POSTFIX; + static { + beforeMatchingNameRegex(DIV_MOD_I, "DivModI"); + } + + public static final String DIV_MOD_L = PREFIX + "DIV_MOD_L" + POSTFIX; + static { + beforeMatchingNameRegex(DIV_MOD_L, "DivModL"); + } + public static final String DIV_VF = VECTOR_PREFIX + "DIV_VF" + POSTFIX; static { vectorNode(DIV_VF, "DivVF", TYPE_FLOAT); @@ -566,6 +586,92 @@ public class IRNode { vectorNode(FMA_VD, "FmaVD", TYPE_DOUBLE); } + public static final String G1_COMPARE_AND_EXCHANGE_N_WITH_BARRIER_FLAG = COMPOSITE_PREFIX + "G1_COMPARE_AND_EXCHANGE_N_WITH_BARRIER_FLAG" + POSTFIX; + static { + String regex = START + "g1CompareAndExchangeN\\S*" + MID + "barrier\\(\\s*" + IS_REPLACED + "\\s*\\)" + END; + machOnly(G1_COMPARE_AND_EXCHANGE_N_WITH_BARRIER_FLAG, regex); + } + + public static final String G1_COMPARE_AND_EXCHANGE_P_WITH_BARRIER_FLAG = COMPOSITE_PREFIX + "G1_COMPARE_AND_EXCHANGE_P_WITH_BARRIER_FLAG" + POSTFIX; + static { + String regex = START + "g1CompareAndExchangeP\\S*" + MID + "barrier\\(\\s*" + IS_REPLACED + "\\s*\\)" + END; + machOnly(G1_COMPARE_AND_EXCHANGE_P_WITH_BARRIER_FLAG, regex); + } + + public static final String G1_COMPARE_AND_SWAP_N_WITH_BARRIER_FLAG = COMPOSITE_PREFIX + "G1_COMPARE_AND_SWAP_N_WITH_BARRIER_FLAG" + POSTFIX; + static { + String regex = START + "g1CompareAndSwapN\\S*" + MID + "barrier\\(\\s*" + IS_REPLACED + "\\s*\\)" + END; + machOnly(G1_COMPARE_AND_SWAP_N_WITH_BARRIER_FLAG, regex); + } + + public static final String G1_COMPARE_AND_SWAP_P_WITH_BARRIER_FLAG = COMPOSITE_PREFIX + "G1_COMPARE_AND_SWAP_P_WITH_BARRIER_FLAG" + POSTFIX; + static { + String regex = START + "g1CompareAndSwapP\\S*" + MID + "barrier\\(\\s*" + IS_REPLACED + "\\s*\\)" + END; + machOnly(G1_COMPARE_AND_SWAP_P_WITH_BARRIER_FLAG, regex); + } + + public static final String G1_ENCODE_P_AND_STORE_N = PREFIX + "G1_ENCODE_P_AND_STORE_N" + POSTFIX; + static { + machOnlyNameRegex(G1_ENCODE_P_AND_STORE_N, "g1EncodePAndStoreN"); + } + + public static final String G1_ENCODE_P_AND_STORE_N_WITH_BARRIER_FLAG = COMPOSITE_PREFIX + "G1_ENCODE_P_AND_STORE_N_WITH_BARRIER_FLAG" + POSTFIX; + static { + String regex = START + "g1EncodePAndStoreN\\S*" + MID + "barrier\\(\\s*" + IS_REPLACED + "\\s*\\)" + END; + machOnly(G1_ENCODE_P_AND_STORE_N_WITH_BARRIER_FLAG, regex); + } + + public static final String G1_GET_AND_SET_N_WITH_BARRIER_FLAG = COMPOSITE_PREFIX + "G1_GET_AND_SET_N_WITH_BARRIER_FLAG" + POSTFIX; + static { + String regex = START + "g1GetAndSetN\\S*" + MID + "barrier\\(\\s*" + IS_REPLACED + "\\s*\\)" + END; + machOnly(G1_GET_AND_SET_N_WITH_BARRIER_FLAG, regex); + } + + public static final String G1_GET_AND_SET_P_WITH_BARRIER_FLAG = COMPOSITE_PREFIX + "G1_GET_AND_SET_P_WITH_BARRIER_FLAG" + POSTFIX; + static { + String regex = START + "g1GetAndSetP\\S*" + MID + "barrier\\(\\s*" + IS_REPLACED + "\\s*\\)" + END; + machOnly(G1_GET_AND_SET_P_WITH_BARRIER_FLAG, regex); + } + + public static final String G1_LOAD_N = PREFIX + "G1_LOAD_N" + POSTFIX; + static { + machOnlyNameRegex(G1_LOAD_N, "g1LoadN"); + } + + public static final String G1_LOAD_N_WITH_BARRIER_FLAG = COMPOSITE_PREFIX + "G1_LOAD_N_WITH_BARRIER_FLAG" + POSTFIX; + static { + String regex = START + "g1LoadN\\S*" + MID + "barrier\\(\\s*" + IS_REPLACED + "\\s*\\)" + END; + machOnly(G1_LOAD_N_WITH_BARRIER_FLAG, regex); + } + + public static final String G1_LOAD_P_WITH_BARRIER_FLAG = COMPOSITE_PREFIX + "G1_LOAD_P_WITH_BARRIER_FLAG" + POSTFIX; + static { + String regex = START + "g1LoadP\\S*" + MID + "barrier\\(\\s*" + IS_REPLACED + "\\s*\\)" + END; + machOnly(G1_LOAD_P_WITH_BARRIER_FLAG, regex); + } + + public static final String G1_STORE_N = PREFIX + "G1_STORE_N" + POSTFIX; + static { + machOnlyNameRegex(G1_STORE_N, "g1StoreN"); + } + + public static final String G1_STORE_N_WITH_BARRIER_FLAG = COMPOSITE_PREFIX + "G1_STORE_N_WITH_BARRIER_FLAG" + POSTFIX; + static { + String regex = START + "g1StoreN\\S*" + MID + "barrier\\(\\s*" + IS_REPLACED + "\\s*\\)" + END; + machOnly(G1_STORE_N_WITH_BARRIER_FLAG, regex); + } + + public static final String G1_STORE_P = PREFIX + "G1_STORE_P" + POSTFIX; + static { + machOnlyNameRegex(G1_STORE_P, "g1StoreP"); + } + + public static final String G1_STORE_P_WITH_BARRIER_FLAG = COMPOSITE_PREFIX + "G1_STORE_P_WITH_BARRIER_FLAG" + POSTFIX; + static { + String regex = START + "g1StoreP\\S*" + MID + "barrier\\(\\s*" + IS_REPLACED + "\\s*\\)" + END; + machOnly(G1_STORE_P_WITH_BARRIER_FLAG, regex); + } + public static final String IF = PREFIX + "IF" + POSTFIX; static { beforeMatchingNameRegex(IF, "If\\b"); @@ -837,6 +943,11 @@ public class IRNode { vectorNode(LSHIFT_VL, "LShiftVL", TYPE_LONG); } + public static final String MACH_TEMP = PREFIX + "MACH_TEMP" + POSTFIX; + static { + machOnlyNameRegex(MACH_TEMP, "MachTemp"); + } + public static final String MACRO_LOGIC_V = PREFIX + "MACRO_LOGIC_V" + POSTFIX; static { afterBarrierExpansionToBeforeMatching(MACRO_LOGIC_V, "MacroLogicV"); @@ -997,6 +1108,16 @@ public class IRNode { vectorNode(MIN_VL, "MinV", TYPE_LONG); } + public static final String MOD_I = PREFIX + "MOD_I" + POSTFIX; + static { + beforeMatchingNameRegex(MOD_I, "ModI"); + } + + public static final String MOD_L = PREFIX + "MOD_L" + POSTFIX; + static { + beforeMatchingNameRegex(MOD_L, "ModL"); + } + public static final String MUL = PREFIX + "MUL" + POSTFIX; static { beforeMatchingNameRegex(MUL, "Mul(I|L|F|D)"); @@ -1123,6 +1244,12 @@ public class IRNode { trapNodes(NULL_CHECK_TRAP, "null_check"); } + public static final String OOPMAP_WITH = COMPOSITE_PREFIX + "OOPMAP_WITH" + POSTFIX; + static { + String regex = "(#\\s*OopMap\\s*\\{.*" + IS_REPLACED + ".*\\})"; + optoOnly(OOPMAP_WITH, regex); + } + public static final String OR_VB = VECTOR_PREFIX + "OR_VB" + POSTFIX; static { vectorNode(OR_VB, "OrV", TYPE_BYTE); @@ -2233,6 +2360,21 @@ public class IRNode { machOnlyNameRegex(X86_TESTL_REG, "testL_reg"); } + public static final String X86_CMOVEL_IMM01 = PREFIX + "X86_CMOVEL_IMM01" + POSTFIX; + static { + machOnlyNameRegex(X86_CMOVEL_IMM01, "cmovL_imm_01"); + } + + public static final String X86_CMOVEL_IMM01U = PREFIX + "X86_CMOVEL_IMM01U" + POSTFIX; + static { + machOnlyNameRegex(X86_CMOVEL_IMM01U, "cmovL_imm_01U"); + } + + public static final String X86_CMOVEL_IMM01UCF = PREFIX + "X86_CMOVEL_IMM01UCF" + POSTFIX; + static { + machOnlyNameRegex(X86_CMOVEL_IMM01UCF, "cmovL_imm_01UCF"); + } + /* * Utility methods to set up IR_NODE_MAPPINGS. */ diff --git a/test/hotspot/jtreg/compiler/lib/ir_framework/driver/irmatching/irrule/checkattribute/parsing/RawIRNode.java b/test/hotspot/jtreg/compiler/lib/ir_framework/driver/irmatching/irrule/checkattribute/parsing/RawIRNode.java index e7db6c4844c..bf3021a6868 100644 --- a/test/hotspot/jtreg/compiler/lib/ir_framework/driver/irmatching/irrule/checkattribute/parsing/RawIRNode.java +++ b/test/hotspot/jtreg/compiler/lib/ir_framework/driver/irmatching/irrule/checkattribute/parsing/RawIRNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -133,7 +133,6 @@ public class RawIRNode { } } String sizeRegex = IRNode.parseVectorNodeSize(size, type, vmInfo); - return nodeRegex.replaceAll(IRNode.IS_REPLACED, - "vector[A-Za-z]\\\\[" + sizeRegex + "\\\\]:\\\\{" + type + "\\\\}"); + return nodeRegex.replaceAll(IRNode.IS_REPLACED, "vector[A-Za-z]<" + type + "," + sizeRegex + ">"); } } diff --git a/test/hotspot/jtreg/compiler/longcountedloops/TestSafePointWithEAState.java b/test/hotspot/jtreg/compiler/longcountedloops/TestSafePointWithEAState.java new file mode 100644 index 00000000000..a04af09570f --- /dev/null +++ b/test/hotspot/jtreg/compiler/longcountedloops/TestSafePointWithEAState.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2024, 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 8336702 + * @summary C2 compilation fails with "all memory state should have been processed" assert + * + * @run main/othervm TestSafePointWithEAState + * + */ + +public class TestSafePointWithEAState { + int[] b = new int[400]; + + void c() { + int e; + float f; + for (long d = 0; d < 5000; d++) { + e = 1; + while ((e += 3) < 200) { + if (d < b.length) { + for (int g = 0; g < 10000; ++g) ; + } + } + synchronized (TestSafePointWithEAState.class) { + f = new h(e).n; + } + } + } + + public static void main(String[] m) { + TestSafePointWithEAState o = new TestSafePointWithEAState(); + o.c(); + } +} + +class h { + float n; + h(float n) { + this.n = n; + } +} diff --git a/test/hotspot/jtreg/compiler/loopopts/LongCountedLoopInInfiniteLoop.jasm b/test/hotspot/jtreg/compiler/loopopts/LongCountedLoopInInfiniteLoop.jasm new file mode 100644 index 00000000000..e7f75d46b5b --- /dev/null +++ b/test/hotspot/jtreg/compiler/loopopts/LongCountedLoopInInfiniteLoop.jasm @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +super public class LongCountedLoopInInfiniteLoop +{ + public Method "":"()V" + stack 1 locals 1 + { + aload_0; + invokespecial Method java/lang/Object."":"()V"; + return; + } + Method test:"()V" + stack 3 locals 3 + { + // #1 = 0; + iconst_0; + istore_1; + + LOOPa: + // if #1 >= 10: goto END + iload_1; + bipush 10; + if_icmpge END; + + // if #1 > 1: goto LOOPc + iload_1; + iconst_1; + if_icmpgt LOOPc; + + // #2 = 0; + iconst_0; + istore_2; + + LOOPb: + // if #2 > 2: goto LOOPa + iload_2; + iconst_2; + if_icmpgt LOOPa; + + // #2 ++ + iinc 2, 1; + + goto LOOPb; + + LOOPc: + // #1 ++ + iinc 1, 1; + + goto LOOPa; + + END: + return; + + } +} diff --git a/test/hotspot/jtreg/compiler/loopopts/MoveStoreAfterInfiniteLoop.jasm b/test/hotspot/jtreg/compiler/loopopts/MoveStoreAfterInfiniteLoop.jasm new file mode 100644 index 00000000000..f93a2aa1170 --- /dev/null +++ b/test/hotspot/jtreg/compiler/loopopts/MoveStoreAfterInfiniteLoop.jasm @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +super public class MoveStoreAfterInfiniteLoop +{ + static Field a:I; + static Field b:I; + static Field c:S; + + public Method "":"()V" + stack 1 locals 1 + { + aload_0; + invokespecial Method java/lang/Object."":"()V"; + return; + } + +public static Method test:"()V" + stack 3 locals 3 + { + LTOP: + iconst_0; + istore_1; + + LOUTER: + iload_1; + bipush 10; + if_icmpge LTOP; + + getstatic Field c:"S"; + putstatic Field a:"I"; + + iconst_0; + istore_2; + + LINNER: + iload_2; + iconst_2; + if_icmpge LBOTTOM; + + getstatic Field b:"I"; + i2s; + putstatic Field c:"S"; + + iinc 2, 1; + + goto LINNER; + + LBOTTOM: + iinc 1, 1; + + goto LOUTER; + } +} diff --git a/test/hotspot/jtreg/compiler/loopopts/TestLongCountedLoopInInfiniteLoop.java b/test/hotspot/jtreg/compiler/loopopts/TestLongCountedLoopInInfiniteLoop.java new file mode 100644 index 00000000000..4dc16797258 --- /dev/null +++ b/test/hotspot/jtreg/compiler/loopopts/TestLongCountedLoopInInfiniteLoop.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024, 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 8336478 + * @summary C2: assert(!n->as_Loop()->is_loop_nest_inner_loop() || _loop_opts_cnt == 0) failed: should have been turned into a counted loop + * @compile LongCountedLoopInInfiniteLoop.jasm + * @run main/othervm -XX:+UnlockExperimentalVMOptions -Xcomp -XX:PerMethodTrapLimit=0 -XX:PerMethodSpecTrapLimit=0 + * -XX:+IgnoreUnrecognizedVMOptions -XX:StressLongCountedLoop=2000000 + * -XX:CompileCommand=compileonly,TestLongCountedLoopInInfiniteLoop::test TestLongCountedLoopInInfiniteLoop + */ + +public class TestLongCountedLoopInInfiniteLoop { + public static void main(String[] args) { + LongCountedLoopInInfiniteLoop obj = new LongCountedLoopInInfiniteLoop(); + test(false, obj); + } + + private static void test(boolean flag, LongCountedLoopInInfiniteLoop obj) { + if (flag) { + obj.test(); + } + } +} diff --git a/test/hotspot/jtreg/compiler/loopopts/TestMoveStoreAfterInfiniteLoop.java b/test/hotspot/jtreg/compiler/loopopts/TestMoveStoreAfterInfiniteLoop.java new file mode 100644 index 00000000000..322e7a5053c --- /dev/null +++ b/test/hotspot/jtreg/compiler/loopopts/TestMoveStoreAfterInfiniteLoop.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024, 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 8338100 + * @summary C2: assert(!n_loop->is_member(get_loop(lca))) failed: control must not be back in the loop + * @compile MoveStoreAfterInfiniteLoop.jasm + * @run main/othervm -Xcomp -XX:-TieredCompilation -XX:CompileOnly=TestMoveStoreAfterInfiniteLoop::test + * -XX:CompileCommand=inline,MoveStoreAfterInfiniteLoop::test TestMoveStoreAfterInfiniteLoop + */ + +public class TestMoveStoreAfterInfiniteLoop { + public static void main(String[] args) { + new MoveStoreAfterInfiniteLoop(); + test(false); + } + + private static void test(boolean flag) { + if (flag) { + MoveStoreAfterInfiniteLoop.test(); + } + } +} diff --git a/test/hotspot/jtreg/compiler/parsing/TestUnsafeArrayAccessWithNullBase.java b/test/hotspot/jtreg/compiler/parsing/TestUnsafeArrayAccessWithNullBase.java new file mode 100644 index 00000000000..28eb4f3c165 --- /dev/null +++ b/test/hotspot/jtreg/compiler/parsing/TestUnsafeArrayAccessWithNullBase.java @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8320308 + * @summary Unsafe::getShortUnaligned with base null hidden behind CheckCastPP nodes + * @library /test/lib + * @modules java.base/jdk.internal.misc + * @run main/othervm -Xbatch -XX:CompileCommand=quiet -XX:TypeProfileLevel=222 + * -XX:+IgnoreUnrecognizedVMOptions -XX:+AlwaysIncrementalInline + * -XX:CompileCommand=compileonly,compiler.parsing.TestUnsafeArrayAccessWithNullBase::test* + * -XX:-TieredCompilation compiler.parsing.TestUnsafeArrayAccessWithNullBase + * @run main compiler.parsing.TestUnsafeArrayAccessWithNullBase + */ + +package compiler.parsing; + +import java.lang.reflect.*; +import jdk.internal.misc.Unsafe; + +public class TestUnsafeArrayAccessWithNullBase { + + /* + Trigger bug when handling Unsafe.getShortUnaligned with null checks and inlined methods. + The bug appears when the method is incrementally inlined and optimized based on the argument profile information. + + Warmup Phase: By warming up with non-null values, the argument profile for the helper methods records non-null types. + - insert CheckCastPP: speculative=byte[int:>=0] for return of getSmall/getLarge + - insert CheckCastPP: speculative=byte[int:>=0] for argument `Object array` in helperSmall/helperLarge + Trigger Phase: Calling test causes LibraryCallKit::inline_unsafe_access(..) for Unsafe::getShortUnaligned to fail: + Reason: UNSAFE.getShortUnaligned(array, offset) is called with array=null, + but ConP null is now hidden by two CheckCastPP with speculative=byte[int:>=0] in the graph + */ + + private static final Unsafe UNSAFE = Unsafe.getUnsafe(); + + private static final Object byteArray = new byte[1_050_000]; + + public static Object getLarge(boolean useNull) { + return useNull ? null : byteArray; + } + + public static Object getSmall(boolean useNull) { + return useNull ? null : new byte[10]; + } + + // use a helper to delay inlining of UNSAFE.getShortUnaligned + public static int helperLarge(Object array, boolean run) { + // offset >= os::vm_page_size(): LibraryCallKit::classify_unsafe_addr returns Type::AnyPtr + return run ? UNSAFE.getShortUnaligned(array, 1_049_000) : 0; // after warmup CheckCastPP: speculative=byte[int:>=0] + } + + public static int accessLargeArray(boolean useNull, boolean run) { + Object array = getLarge(useNull); // after warmup CheckCastPP: speculative=byte[int:>=0] + // getLarge() ensures null is only visible after helperLarge was (incrementally) inlined + return helperLarge(array, run); + } + + // use a helper to delay inlining of UNSAFE.getShortUnaligned + // warmup adds argument profile information for array: CheckCastPP with type non null + public static int helperSmall(Object array, boolean run) { + // 0 <= offset < os::vm_page_size(): LibraryCallKit::classify_unsafe_addr returns Type::OopPtr + return run ? UNSAFE.getShortUnaligned(array, 1) : 0; // after warmup CheckCastPP: speculative=byte[int:>=0] + } + + public static int accessSmallArray(boolean useNull, boolean run) { + Object array = getSmall(useNull); // after warmup CheckCastPP: speculative=byte[int:>=0] + return helperSmall(array, run); + } + + public static int test1(boolean run) { + return accessLargeArray(true, run); + } + + public static int test2(boolean run) { + return accessSmallArray(true, run); + } + + public static void main(String[] args) { + // Warmup to collect speculative types + for (int i = 0; i < 10_000; i++) { + accessLargeArray(false, true); + accessSmallArray(false, true); + } + + // Trigger Compilation + for (int i = 0; i < 10_000; ++i) { + test1(false); + test2(false); + } + } +} diff --git a/test/hotspot/jtreg/compiler/rangechecks/TestExplicitRangeChecks.java b/test/hotspot/jtreg/compiler/rangechecks/TestExplicitRangeChecks.java index ba045814fc2..83bfd63c629 100644 --- a/test/hotspot/jtreg/compiler/rangechecks/TestExplicitRangeChecks.java +++ b/test/hotspot/jtreg/compiler/rangechecks/TestExplicitRangeChecks.java @@ -25,6 +25,7 @@ * @test * @bug 8073480 * @summary explicit range checks should be recognized by C2 + * @requires vm.opt.StressUnstableIfTraps == null | !vm.opt.StressUnstableIfTraps * @library /test/lib / * @modules java.base/jdk.internal.misc:+open * @build jdk.test.whitebox.WhiteBox diff --git a/test/hotspot/jtreg/compiler/runtime/safepoints/TestMachTempsAcrossSafepoints.java b/test/hotspot/jtreg/compiler/runtime/safepoints/TestMachTempsAcrossSafepoints.java new file mode 100644 index 00000000000..ecd8f58c5ed --- /dev/null +++ b/test/hotspot/jtreg/compiler/runtime/safepoints/TestMachTempsAcrossSafepoints.java @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package compiler.runtime.safepoints; + +import compiler.lib.ir_framework.*; +import java.lang.ref.SoftReference; + +/** + * @test + * @summary Test that undefined values generated by MachTemp nodes (in this + * case, derived from G1 barriers) are not included in OopMaps. + * Extracted from java.lang.invoke.LambdaFormEditor::getInCache. + * @key randomness + * @library /test/lib / + * @requires vm.gc.G1 & vm.bits == 64 & vm.opt.final.UseCompressedOops == true + * @run driver compiler.runtime.safepoints.TestMachTempsAcrossSafepoints + */ + +public class TestMachTempsAcrossSafepoints { + + static class RefWithKey extends SoftReference { + final int key; + + public RefWithKey(int key) { + super(new Object()); + this.key = key; + } + + @DontInline + @Override + public boolean equals(Object obj) { + return obj instanceof RefWithKey that && this.key == that.key; + } + } + + public static void main(String[] args) throws Exception { + String inlineCmd = "-XX:CompileCommand=inline,java.lang.ref.SoftReference::get"; + TestFramework.runWithFlags(inlineCmd, "-XX:+StressGCM", "-XX:+StressLCM", "-XX:StressSeed=1"); + TestFramework.runWithFlags(inlineCmd, "-XX:+StressGCM", "-XX:+StressLCM"); + } + + @Test + @IR(counts = {IRNode.G1_LOAD_N, "1"}, phase = CompilePhase.FINAL_CODE) + @IR(counts = {IRNode.MACH_TEMP, ">= 1"}, phase = CompilePhase.FINAL_CODE) + @IR(counts = {IRNode.STATIC_CALL_OF_METHOD, "equals", "2"}) + @IR(failOn = {IRNode.OOPMAP_WITH, "NarrowOop"}) + static private Object test(RefWithKey key, RefWithKey[] refs) { + RefWithKey k = null; + // This loop causes the register allocator to not "rematerialize" all + // MachTemp nodes generated for the reference g1LoadN instruction below. + for (int i = 0; i < refs.length; i++) { + RefWithKey k0 = refs[0]; + if (k0.equals(key)) { + k = k0; + } + } + if (k != null && !key.equals(k)) { + return null; + } + // The MachTemp node implementing the dst TEMP operand in the g1LoadN + // instruction corresponding to k.get() can be scheduled across the + // above call to RefWithKey::equals(), due to an unfortunate interaction + // of inaccurate basic block frequency estimation (emulated in this test + // by randomizing the GCM and LCM heuristics) and call-catch cleanup. + // Since narrow pointer MachTemp nodes are typed as narrow OOPs, this + // causes the oopmap builder to include the MachTemp node definition in + // the RefWithKey::equals() return oopmap. + return (k != null) ? k.get() : null; + } + + @Run(test = "test") + @Warmup(0) + public void run() { + RefWithKey ref = new RefWithKey(42); + test(ref, new RefWithKey[]{ref}); + } +} diff --git a/test/hotspot/jtreg/compiler/types/TestBadMemSliceWithInterfaces.java b/test/hotspot/jtreg/compiler/types/TestBadMemSliceWithInterfaces.java new file mode 100644 index 00000000000..5090c2dd6cf --- /dev/null +++ b/test/hotspot/jtreg/compiler/types/TestBadMemSliceWithInterfaces.java @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2024, 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 8340214 + * @summary C2 compilation asserts with "no node with a side effect" in PhaseIdealLoop::try_sink_out_of_loop + * + * @run main/othervm -XX:-BackgroundCompilation TestBadMemSliceWithInterfaces + * + */ + +public class TestBadMemSliceWithInterfaces { + public static void main(String[] args) { + B b = new B(); + C c = new C(); + for (int i = 0; i < 20_000; i++) { + test1(b, c, true); + test1(b, c, false); + b.field = 0; + c.field = 0; + int res = test2(b, c, true); + if (res != 42) { + throw new RuntimeException("incorrect result " + res); + } + res = test2(b, c, false); + if (res != 42) { + throw new RuntimeException("incorrect result " + res); + } + } + } + + private static void test1(B b, C c, boolean flag) { + A a; + if (flag) { + a = b; + } else { + a = c; + } + for (int i = 0; i < 1000; i++) { + a.field = 42; + } + } + + private static int test2(B b, C c, boolean flag) { + A a; + if (flag) { + a = b; + } else { + a = c; + } + int v = 0; + for (int i = 0; i < 2; i++) { + v += a.field; + a.field = 42; + } + return v; + } + + interface I { + void m(); + } + + static class A { + int field; + } + + static class B extends A implements I { + @Override + public void m() { + + } + } + + static class C extends A implements I { + @Override + public void m() { + + } + } +} diff --git a/test/hotspot/jtreg/compiler/uncommontrap/TestUnstableIfTrap.java b/test/hotspot/jtreg/compiler/uncommontrap/TestUnstableIfTrap.java index 5fee59c7510..626f4c9b1f6 100644 --- a/test/hotspot/jtreg/compiler/uncommontrap/TestUnstableIfTrap.java +++ b/test/hotspot/jtreg/compiler/uncommontrap/TestUnstableIfTrap.java @@ -24,7 +24,7 @@ /* * @test * @bug 8030976 8059226 - * @requires !vm.graal.enabled + * @requires !vm.graal.enabled & (vm.opt.StressUnstableIfTraps == null | !vm.opt.StressUnstableIfTraps) * @library /test/lib / * @modules java.base/jdk.internal.org.objectweb.asm * java.base/jdk.internal.misc diff --git a/test/hotspot/jtreg/compiler/unsafe/UnsafeGetStableArrayElement.java b/test/hotspot/jtreg/compiler/unsafe/UnsafeGetStableArrayElement.java index 931b1a10e0b..bef57605f5f 100644 --- a/test/hotspot/jtreg/compiler/unsafe/UnsafeGetStableArrayElement.java +++ b/test/hotspot/jtreg/compiler/unsafe/UnsafeGetStableArrayElement.java @@ -244,9 +244,9 @@ public class UnsafeGetStableArrayElement { testMismatched(Test::testZ_S, Test::changeZ); testMismatched(Test::testZ_C, Test::changeZ); testMismatched(Test::testZ_I, Test::changeZ); - testMismatched(Test::testZ_J, Test::changeZ); + testMismatched(Test::testZ_J, Test::changeZ, false, ARRAY_BOOLEAN_BASE_OFFSET == ARRAY_LONG_BASE_OFFSET); testMismatched(Test::testZ_F, Test::changeZ); - testMismatched(Test::testZ_D, Test::changeZ); + testMismatched(Test::testZ_D, Test::changeZ, false, ARRAY_BOOLEAN_BASE_OFFSET == ARRAY_DOUBLE_BASE_OFFSET); // byte[], aligned accesses testMismatched(Test::testB_Z, Test::changeB); @@ -254,9 +254,9 @@ public class UnsafeGetStableArrayElement { testMismatched(Test::testB_S, Test::changeB); testMismatched(Test::testB_C, Test::changeB); testMismatched(Test::testB_I, Test::changeB); - testMismatched(Test::testB_J, Test::changeB); + testMismatched(Test::testB_J, Test::changeB, false, ARRAY_BYTE_BASE_OFFSET == ARRAY_LONG_BASE_OFFSET); testMismatched(Test::testB_F, Test::changeB); - testMismatched(Test::testB_D, Test::changeB); + testMismatched(Test::testB_D, Test::changeB, false, ARRAY_BYTE_BASE_OFFSET == ARRAY_DOUBLE_BASE_OFFSET); // short[], aligned accesses testMismatched(Test::testS_Z, Test::changeS); @@ -264,9 +264,9 @@ public class UnsafeGetStableArrayElement { testMatched( Test::testS_S, Test::changeS); testMismatched(Test::testS_C, Test::changeS); testMismatched(Test::testS_I, Test::changeS); - testMismatched(Test::testS_J, Test::changeS); + testMismatched(Test::testS_J, Test::changeS, false, ARRAY_SHORT_BASE_OFFSET == ARRAY_LONG_BASE_OFFSET); testMismatched(Test::testS_F, Test::changeS); - testMismatched(Test::testS_D, Test::changeS); + testMismatched(Test::testS_D, Test::changeS, false, ARRAY_SHORT_BASE_OFFSET == ARRAY_DOUBLE_BASE_OFFSET); // char[], aligned accesses testMismatched(Test::testC_Z, Test::changeC); @@ -274,9 +274,9 @@ public class UnsafeGetStableArrayElement { testMismatched(Test::testC_S, Test::changeC); testMatched( Test::testC_C, Test::changeC); testMismatched(Test::testC_I, Test::changeC); - testMismatched(Test::testC_J, Test::changeC); + testMismatched(Test::testC_J, Test::changeC, false, ARRAY_CHAR_BASE_OFFSET == ARRAY_LONG_BASE_OFFSET); testMismatched(Test::testC_F, Test::changeC); - testMismatched(Test::testC_D, Test::changeC); + testMismatched(Test::testC_D, Test::changeC, false, ARRAY_CHAR_BASE_OFFSET == ARRAY_DOUBLE_BASE_OFFSET); // int[], aligned accesses testMismatched(Test::testI_Z, Test::changeI); @@ -284,9 +284,9 @@ public class UnsafeGetStableArrayElement { testMismatched(Test::testI_S, Test::changeI); testMismatched(Test::testI_C, Test::changeI); testMatched( Test::testI_I, Test::changeI); - testMismatched(Test::testI_J, Test::changeI); + testMismatched(Test::testI_J, Test::changeI, false, ARRAY_INT_BASE_OFFSET == ARRAY_LONG_BASE_OFFSET); testMismatched(Test::testI_F, Test::changeI); - testMismatched(Test::testI_D, Test::changeI); + testMismatched(Test::testI_D, Test::changeI, false, ARRAY_INT_BASE_OFFSET == ARRAY_DOUBLE_BASE_OFFSET); // long[], aligned accesses testMismatched(Test::testJ_Z, Test::changeJ); @@ -304,9 +304,9 @@ public class UnsafeGetStableArrayElement { testMismatched(Test::testF_S, Test::changeF); testMismatched(Test::testF_C, Test::changeF); testMismatched(Test::testF_I, Test::changeF); - testMismatched(Test::testF_J, Test::changeF); + testMismatched(Test::testF_J, Test::changeF, false, ARRAY_FLOAT_BASE_OFFSET == ARRAY_LONG_BASE_OFFSET); testMatched( Test::testF_F, Test::changeF); - testMismatched(Test::testF_D, Test::changeF); + testMismatched(Test::testF_D, Test::changeF, false, ARRAY_FLOAT_BASE_OFFSET == ARRAY_DOUBLE_BASE_OFFSET); // double[], aligned accesses testMismatched(Test::testD_Z, Test::changeD); diff --git a/test/hotspot/jtreg/compiler/vectorization/TestRoundVectRiscv64.java b/test/hotspot/jtreg/compiler/vectorization/TestRoundVectRiscv64.java new file mode 100644 index 00000000000..530befbe2bc --- /dev/null +++ b/test/hotspot/jtreg/compiler/vectorization/TestRoundVectRiscv64.java @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, Rivos 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 1234567 + * @summary Auto-vectorize Math.round API + * @requires vm.compiler2.enabled + * @requires os.arch == "riscv64" + * @requires vm.cpu.features ~= ".*rvv.*" + * @library /test/lib / + * @run driver compiler.vectorization.TestRoundVectRiscv64 + */ + +package compiler.vectorization; + +import compiler.lib.ir_framework.*; + +public class TestRoundVectRiscv64 { + private static final int ARRLEN = 1024; + private static final int ITERS = 11000; + + private static double [] dinp; + private static long [] lout; + private static float [] finp; + private static int [] iout; + + public static void main(String args[]) { + TestFramework.runWithFlags("-XX:-TieredCompilation", + "-XX:CompileThresholdScaling=0.3"); + System.out.println("PASSED"); + } + + @Test + @IR(counts = {IRNode.ROUND_VD, "> 0"}) + public void test_round_double(long[] lout, double[] dinp) { + for (int i = 0; i < lout.length; i+=1) { + lout[i] = Math.round(dinp[i]); + } + } + + @Run(test = {"test_round_double"}, mode = RunMode.STANDALONE) + public void kernel_test_round_double() { + dinp = new double[ARRLEN]; + lout = new long[ARRLEN]; + for (int i = 0 ; i < ARRLEN; i++) { + dinp[i] = (double)i*1.4; + } + for (int i = 0; i < ITERS; i++) { + test_round_double(lout , dinp); + } + } + + @Test + @IR(counts = {IRNode.ROUND_VF, "> 0"}) + public void test_round_float(int[] iout, float[] finp) { + for (int i = 0; i < finp.length; i+=1) { + iout[i] = Math.round(finp[i]); + } + } + + @Run(test = {"test_round_float"}, mode = RunMode.STANDALONE) + public void kernel_test_round() { + finp = new float[ARRLEN]; + iout = new int[ARRLEN]; + for (int i = 0 ; i < ARRLEN; i++) { + finp[i] = (float)i*1.4f; + } + for (int i = 0; i < ITERS; i++) { + test_round_float(iout , finp); + } + } +} diff --git a/test/hotspot/jtreg/compiler/vectorization/TestRoundVectorDoubleRandom.java b/test/hotspot/jtreg/compiler/vectorization/TestRoundVectorDoubleRandom.java new file mode 100644 index 00000000000..cd1a59c6d24 --- /dev/null +++ b/test/hotspot/jtreg/compiler/vectorization/TestRoundVectorDoubleRandom.java @@ -0,0 +1,229 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, Rivos 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 + * @key randomness + * @bug 8321011 + * @summary Test vector intrinsic for Math.round(double) with random input in 64 bits range, verify IR at the same time. + * + * @library /test/lib / + * @modules java.base/jdk.internal.math + * @requires os.arch == "riscv64" & vm.cpu.features ~= ".*rvv.*" + * @run main compiler.vectorization.TestRoundVectorDoubleRandom + */ + +package compiler.vectorization; + +import java.util.Random; +import static compiler.lib.golden.GoldenRound.golden_round; +import compiler.lib.ir_framework.IR; +import compiler.lib.ir_framework.IRNode; +import compiler.lib.ir_framework.Run; +import compiler.lib.ir_framework.RunInfo; +import compiler.lib.ir_framework.Test; +import compiler.lib.ir_framework.TestFramework; +import compiler.lib.ir_framework.Warmup; + +public class TestRoundVectorDoubleRandom { + private static final Random rand = new Random(); + + private static final int ITERS = 11000; + private static final int ARRLEN = rand.nextInt(4096-997) + 997; + private static final double ADD_INIT = -7500.; + + private static final double[] input = new double[ARRLEN]; + private static final long [] res = new long[ARRLEN]; + + public static void main(String args[]) { + TestFramework.runWithFlags("-XX:-TieredCompilation", "-XX:CompileThresholdScaling=0.3"); + TestFramework.runWithFlags("-XX:-TieredCompilation", "-XX:CompileThresholdScaling=0.3", "-XX:MaxVectorSize=8"); + TestFramework.runWithFlags("-XX:-TieredCompilation", "-XX:CompileThresholdScaling=0.3", "-XX:MaxVectorSize=16"); + TestFramework.runWithFlags("-XX:-TieredCompilation", "-XX:CompileThresholdScaling=0.3", "-XX:MaxVectorSize=32"); + } + + @Test + @IR(counts = {IRNode.ROUND_VD, "> 0"}, + applyIf = {"MaxVectorSize", ">= 64"}) + static void test_round(long[] a0, double[] a1) { + for (int i = 0; i < a0.length; i+=1) { + a0[i] = Math.round(a1[i]); + } + } + + @Run(test = "test_round") + @Warmup(ITERS) + static void test_rounds(RunInfo runInfo) { + // Initialize + for (int i = 0; i < ARRLEN; i++) { + double val = ADD_INIT+(double)i; + input[i] = val; + } + + test_round(res, input); + // skip test/verify when warming up + if (runInfo.isWarmUp()) { + return; + } + + int errn = 0; + // a double precise float point is composed of 3 parts: sign/exponent/signicand + // exponent part of a float value + final int exponentShift = 52; + final int exponentWidth = 11; + final int exponentBound = 1 << exponentWidth; + // significant part of a float value + final int signicandWidth = exponentShift; + final long signicandBound = 1L << signicandWidth; + final int signicandNum = 256; + + // prepare for data of significand part + long signicandValues[] = new long[signicandNum]; + int signicandIdx = 0; + for (; signicandIdx < signicandWidth; signicandIdx++) { + signicandValues[signicandIdx] = 1L << signicandIdx; + } + for (; signicandIdx < signicandNum; signicandIdx++) { + signicandValues[signicandIdx] = rand.nextLong(signicandBound); + } + signicandValues[rand.nextInt(signicandNum)] = 0; + + // generate input arrays for testing, then run tests & verify results + + // generate input arrays by combining different parts + for (long sv : signicandValues) { + // generate test input by combining different parts: + // previously generated significand values, + // random value in exponent range, + // both positive and negative of previous combined values (exponent+significand) + final int exponentStart = rand.nextInt(9); + final int exponentStep = (1 << 3) + rand.nextInt(3); + // Here, we could have iterated the whole range of exponent values, but it would + // take more time to run the test, so just randomly choose some of exponent values. + int ev = exponentStart; + int inputIdx = 0; + for (; ev < exponentBound; ev += exponentStep) { + inputIdx = ev/exponentStep; + // combine exponent and significand + long bits = ((long)ev << exponentShift) + sv; + // combine sign(+/-) with exponent and significand + // positive values + input[inputIdx*2] = Double.longBitsToDouble(bits); + // negative values + bits = bits | (1L << 63); + input[inputIdx*2+1] = Double.longBitsToDouble(bits); + } + // add specific test cases where it looks like in binary format: + // s111 1111 1111 xxxx xxxx xxxx xxxx xxxx ... + // these are for the NaN and Inf. + inputIdx = inputIdx*2+2; + long bits = (1L << exponentWidth) - 1L; + bits <<= exponentShift; + input[inputIdx++] = Double.longBitsToDouble(bits); + bits = bits | (1L << 63); + input[inputIdx] = Double.longBitsToDouble(bits); + + // run tests + test_round(res, input); + + // verify results + ev = exponentStart; + inputIdx = ev/exponentStep; + for (; ev < exponentBound; ev += exponentStep) { + for (int sign = 0; sign < 2; sign++) { + int idx = inputIdx * 2 + sign; + if (res[idx] != golden_round(input[idx])) { + errn++; + System.err.println("round error, input: " + input[idx] + + ", res: " + res[idx] + "expected: " + golden_round(input[idx]) + + ", input hex: " + Double.doubleToLongBits(input[idx]) + + ", fi: " + sv + ", ei: " + ev + ", sign: " + sign); + } + } + } + } + + // generate pure random input arrays, which does not depend on significand/exponent values + for(int i = 0; i < 128; i++) { + for (int j = 0; j < ARRLEN; j++) { + input[j] = rand.nextDouble(); + } + + // run tests + test_round(res, input); + + // verify results + for (int j = 0; j < ARRLEN; j++) { + if (res[j] != golden_round(input[j])) { + errn++; + System.err.println("round error, input: " + input[j] + + ", res: " + res[j] + "expected: " + golden_round(input[j]) + + ", input hex: " + Double.doubleToLongBits(input[j])); + } + } + } + + // test cases for NaN, Inf, subnormal, and so on + { + Double[] dv = new Double[] { + +0.0, + -0.0, + Double.MAX_VALUE, + Double.MIN_VALUE, + Double.NEGATIVE_INFINITY, + Double.POSITIVE_INFINITY, + Double.NaN, + Double.longBitsToDouble(0x7ff0000000000001L), // another NaN + Double.MIN_NORMAL, + 0x0.fffffffffffffp-1022, // Maximum Subnormal Value + 1.5, + 100.5, + 10000.5, + -1.5, + -100.5, + -10000.5 + }; + for (int j = 0; j < ARRLEN; j++) { + input[j] = dv[rand.nextInt(dv.length)]; + } + + // run tests + test_round(res, input); + + // verify results + for (int j = 0; j < ARRLEN; j++) { + if (res[j] != golden_round(input[j])) { + errn++; + System.err.println("round error, input: " + input[j] + + ", res: " + res[j] + "expected: " + golden_round(input[j]) + + ", input hex: " + Double.doubleToLongBits(input[j])); + } + } + } + + if (errn > 0) { + throw new RuntimeException("There are some round error detected!"); + } + } +} diff --git a/test/hotspot/jtreg/compiler/vectorization/TestRoundVectorFloatAll.java b/test/hotspot/jtreg/compiler/vectorization/TestRoundVectorFloatAll.java new file mode 100644 index 00000000000..a85ac3eaa22 --- /dev/null +++ b/test/hotspot/jtreg/compiler/vectorization/TestRoundVectorFloatAll.java @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, Rivos 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 8321010 + * @summary Test vector intrinsic for Math.round(float) in full 32 bits range + * + * @library /test/lib / + * @modules java.base/jdk.internal.math + * @requires os.arch == "riscv64" & vm.cpu.features ~= ".*rvv.*" + * @run main/othervm -XX:-TieredCompilation -XX:CompileThresholdScaling=0.3 -XX:+UseSuperWord -XX:CompileCommand=compileonly,compiler.vectorization.TestRoundVectorFloatAll::test* compiler.vectorization.TestRoundVectorFloatAll + * @run main/othervm -XX:-TieredCompilation -XX:CompileThresholdScaling=0.3 -XX:MaxVectorSize=32 -XX:+UseSuperWord -XX:CompileCommand=compileonly,compiler.vectorization.TestRoundVectorFloatAll::test* compiler.vectorization.TestRoundVectorFloatAll + */ + +package compiler.vectorization; + +import java.util.Random; +import static compiler.lib.golden.GoldenRound.golden_round; + +public class TestRoundVectorFloatAll { + private static final Random rand = new Random(); + + private static final int ITERS = 11000; + private static final int ARRLEN = rand.nextInt(4096-997) + 997; + private static final float ADD_INIT = -7500.f; + + public static void main(String args[]) { + test(); + } + + static void test() { + float[] input = new float[ARRLEN]; + int [] res = new int[ARRLEN]; + + // Warmup + System.out.println("Warmup"); + for (int i=0; i 0) { + throw new RuntimeException("There are some round error detected!"); + } + } + + static void test_round(int[] a0, float[] a1) { + for (int i = 0; i < a0.length; i+=1) { + a0[i] = Math.round(a1[i]); + } + } +} diff --git a/test/hotspot/jtreg/compiler/vectorization/TestRoundVectorFloatRandom.java b/test/hotspot/jtreg/compiler/vectorization/TestRoundVectorFloatRandom.java new file mode 100644 index 00000000000..7288e4d9f63 --- /dev/null +++ b/test/hotspot/jtreg/compiler/vectorization/TestRoundVectorFloatRandom.java @@ -0,0 +1,212 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, Rivos 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 + * @key randomness + * @bug 8321010 + * @summary Test vector intrinsic for Math.round(float) with random input in 32 bits range, verify IR at the same time. + * + * @library /test/lib / + * @modules java.base/jdk.internal.math + * @requires os.arch == "riscv64" & vm.cpu.features ~= ".*rvv.*" + * @run main compiler.vectorization.TestRoundVectorFloatRandom + */ + +package compiler.vectorization; + +import java.util.Random; +import static compiler.lib.golden.GoldenRound.golden_round; +import compiler.lib.ir_framework.IR; +import compiler.lib.ir_framework.IRNode; +import compiler.lib.ir_framework.Run; +import compiler.lib.ir_framework.RunInfo; +import compiler.lib.ir_framework.Test; +import compiler.lib.ir_framework.TestFramework; +import compiler.lib.ir_framework.Warmup; + +public class TestRoundVectorFloatRandom { + private static final Random rand = new Random(); + + private static final int ITERS = 11000; + private static final int ARRLEN = rand.nextInt(4096-997) + 997; + private static final float ADD_INIT = -7500.f; + + private static final float[] input = new float[ARRLEN]; + private static final int[] res = new int[ARRLEN]; + + public static void main(String args[]) { + TestFramework.runWithFlags("-XX:-TieredCompilation", "-XX:CompileThresholdScaling=0.3"); + TestFramework.runWithFlags("-XX:-TieredCompilation", "-XX:CompileThresholdScaling=0.3", "-XX:MaxVectorSize=8"); + TestFramework.runWithFlags("-XX:-TieredCompilation", "-XX:CompileThresholdScaling=0.3", "-XX:MaxVectorSize=16"); + TestFramework.runWithFlags("-XX:-TieredCompilation", "-XX:CompileThresholdScaling=0.3", "-XX:MaxVectorSize=32"); + } + + @Test + @IR(counts = {IRNode.ROUND_VF, "> 0"}, + applyIf = {"MaxVectorSize", ">= 32"}) + static void test_round(int[] a0, float[] a1) { + for (int i = 0; i < a0.length; i+=1) { + a0[i] = Math.round(a1[i]); + } + } + + @Run(test = "test_round") + @Warmup(ITERS) + static void test_rounds(RunInfo runInfo) { + // Initialize + for (int i = 0; i < ARRLEN; i++) { + float val = ADD_INIT+(float)i; + input[i] = val; + } + + test_round(res, input); + // skip test/verify when warming up + if (runInfo.isWarmUp()) { + return; + } + + int errn = 0; + // a single precise float point is composed of 3 parts: sign/exponent/signicand + // exponent part of a float value + final int exponentStart = 0; + final int exponentShift = 23; + final int exponentWidth = 8; + final int exponentBound = 1 << exponentWidth; + // significant part of a float value + final int signicandWidth = exponentShift; + final int signicandBound = 1 << signicandWidth; + final int signicandNum = 128; + + // prepare for data of significand part + int signicandValues[] = new int[signicandNum]; + int signicandIdx = 0; + for (; signicandIdx < signicandWidth; signicandIdx++) { + signicandValues[signicandIdx] = 1 << signicandIdx; + } + for (; signicandIdx < signicandNum; signicandIdx++) { + signicandValues[signicandIdx] = rand.nextInt(signicandBound); + } + signicandValues[rand.nextInt(signicandNum)] = 0; + + // generate input arrays for testing, then run tests & verify results + + // generate input arrays by combining different parts + for (int sv : signicandValues) { + // generate test input by combining different parts: + // previously generated significand values, + // all values in exponent range, + // both positive and negative of previous combined values (exponent+significand) + for (int ev = exponentStart; ev < exponentBound; ev++) { + // combine exponent and significand + int bits = (ev << exponentShift) + sv; + // combine sign(+/-) with exponent and significand + // positive values + input[ev*2] = Float.intBitsToFloat(bits); + // negative values + bits = bits | (1 << 31); + input[ev*2+1] = Float.intBitsToFloat(bits); + } + + // run tests + test_round(res, input); + + // verify results + for (int ev = exponentStart; ev < exponentBound; ev++) { + for (int sign = 0; sign < 2; sign++) { + int idx = ev * 2 + sign; + if (res[idx] != golden_round(input[idx])) { + errn++; + System.err.println("round error, input: " + input[idx] + + ", res: " + res[idx] + "expected: " + golden_round(input[idx]) + + ", input hex: " + Float.floatToIntBits(input[idx]) + + ", fi: " + sv + ", ei: " + ev + ", sign: " + sign); + } + } + } + } + + // generate pure random input arrays, which does not depend on significand/exponent values + for(int i = 0; i < 128; i++) { + for (int j = 0; j < ARRLEN; j++) { + input[j] = rand.nextFloat(); + } + + // run tests + test_round(res, input); + + // verify results + for (int j = 0; j < ARRLEN; j++) { + if (res[j] != golden_round(input[j])) { + errn++; + System.err.println("round error, input: " + input[j] + + ", res: " + res[j] + "expected: " + golden_round(input[j]) + + ", input hex: " + Float.floatToIntBits(input[j])); + } + } + } + + // test cases for NaN, Inf, subnormal, and so on + { + Float[] dv = new Float[] { + +0.0f, + -0.0f, + Float.MAX_VALUE, + Float.MIN_VALUE, + Float.NEGATIVE_INFINITY, + Float.POSITIVE_INFINITY, + Float.NaN, + Float.intBitsToFloat(0x7f800001), // another NaN + Float.MIN_NORMAL, + 0x0.fffffep-126f, // Maximum Subnormal Value + 1.5f, + 100.5f, + 10000.5f, + -1.5f, + -100.5f, + -10000.5f + }; + for (int j = 0; j < ARRLEN; j++) { + input[j] = dv[rand.nextInt(dv.length)]; + } + + // run tests + test_round(res, input); + + // verify results + for (int j = 0; j < ARRLEN; j++) { + if (res[j] != golden_round(input[j])) { + errn++; + System.err.println("round error, input: " + input[j] + + ", res: " + res[j] + "expected: " + golden_round(input[j]) + + ", input hex: " + Float.floatToIntBits(input[j])); + } + } + } + + if (errn > 0) { + throw new RuntimeException("There are some round error detected!"); + } + } +} diff --git a/test/hotspot/jtreg/compiler/vectorization/runner/BasicBooleanOpTest.java b/test/hotspot/jtreg/compiler/vectorization/runner/BasicBooleanOpTest.java index d1a61538f2e..18e7721e0d6 100644 --- a/test/hotspot/jtreg/compiler/vectorization/runner/BasicBooleanOpTest.java +++ b/test/hotspot/jtreg/compiler/vectorization/runner/BasicBooleanOpTest.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2022, 2023, Arm Limited. All rights reserved. + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +25,7 @@ /* * @test * @summary Vectorization test on basic boolean operations + * @requires vm.opt.StressUnstableIfTraps == null | !vm.opt.StressUnstableIfTraps * @library /test/lib / * * @build jdk.test.whitebox.WhiteBox @@ -71,12 +73,9 @@ public class BasicBooleanOpTest extends VectorizationTestRunner { } @Test - @IR(applyIfCPUFeature = {"asimd", "true"}, + @IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"}, + phase = CompilePhase.BEFORE_MACRO_EXPANSION, counts = {IRNode.AND_VB, ">0"}) - @IR(applyIfCPUFeatureAnd = {"avx512f", "false", "sse2", "true"}, - counts = {IRNode.AND_VB, ">0"}) - @IR(applyIfCPUFeature = {"avx512f", "true"}, - counts = {IRNode.MACRO_LOGIC_V, ">0"}) public boolean[] vectorAnd() { boolean[] res = new boolean[SIZE]; for (int i = 0; i < SIZE; i++) { diff --git a/test/hotspot/jtreg/compiler/whitebox/DeoptimizeFramesTest.java b/test/hotspot/jtreg/compiler/whitebox/DeoptimizeFramesTest.java index 1d9c8169d04..91601479881 100644 --- a/test/hotspot/jtreg/compiler/whitebox/DeoptimizeFramesTest.java +++ b/test/hotspot/jtreg/compiler/whitebox/DeoptimizeFramesTest.java @@ -25,6 +25,7 @@ * @test DeoptimizeFramesTest * @bug 8028595 * @summary testing of WB::deoptimizeFrames() + * @requires vm.opt.StressUnstableIfTraps == null | !vm.opt.StressUnstableIfTraps * @library /test/lib / * @modules java.base/jdk.internal.misc * java.management diff --git a/test/hotspot/jtreg/containers/docker/DockerBasicTest.java b/test/hotspot/jtreg/containers/docker/DockerBasicTest.java index 357eb3db497..9233b199532 100644 --- a/test/hotspot/jtreg/containers/docker/DockerBasicTest.java +++ b/test/hotspot/jtreg/containers/docker/DockerBasicTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,7 @@ /* * @test * @summary Basic (sanity) test for JDK-under-test inside a docker image. - * @requires docker.support + * @requires container.support * @library /test/lib * @modules java.base/jdk.internal.misc * java.management diff --git a/test/hotspot/jtreg/containers/docker/ShareTmpDir.java b/test/hotspot/jtreg/containers/docker/ShareTmpDir.java index 08493a75398..43cd6ec5152 100644 --- a/test/hotspot/jtreg/containers/docker/ShareTmpDir.java +++ b/test/hotspot/jtreg/containers/docker/ShareTmpDir.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,7 +27,7 @@ * @bug 8286030 * @key cgroups * @summary Test for hsperfdata file name conflict when two containers share the same /tmp directory - * @requires docker.support + * @requires container.support * @library /test/lib * @build WaitForFlagFile * @run driver ShareTmpDir diff --git a/test/hotspot/jtreg/containers/docker/TestCPUAwareness.java b/test/hotspot/jtreg/containers/docker/TestCPUAwareness.java index a41dc9c3939..c51bfa1abbb 100644 --- a/test/hotspot/jtreg/containers/docker/TestCPUAwareness.java +++ b/test/hotspot/jtreg/containers/docker/TestCPUAwareness.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,7 @@ * @test * @key cgroups * @summary Test JVM's CPU resource awareness when running inside docker container - * @requires docker.support + * @requires container.support * @library /test/lib * @modules java.base/jdk.internal.misc * java.base/jdk.internal.platform diff --git a/test/hotspot/jtreg/containers/docker/TestCPUSets.java b/test/hotspot/jtreg/containers/docker/TestCPUSets.java index de35388f5a8..aabe82e131f 100644 --- a/test/hotspot/jtreg/containers/docker/TestCPUSets.java +++ b/test/hotspot/jtreg/containers/docker/TestCPUSets.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,7 @@ * @test * @key cgroups * @summary Test JVM's awareness of cpu sets (cpus and mems) - * @requires docker.support + * @requires container.support * @requires (os.arch != "s390x") * @library /test/lib * @modules java.base/jdk.internal.misc diff --git a/test/hotspot/jtreg/containers/docker/TestContainerInfo.java b/test/hotspot/jtreg/containers/docker/TestContainerInfo.java index 6bcb706fa7a..5db3c2af098 100644 --- a/test/hotspot/jtreg/containers/docker/TestContainerInfo.java +++ b/test/hotspot/jtreg/containers/docker/TestContainerInfo.java @@ -27,7 +27,7 @@ * @test * @summary Test container info for cgroup v2 * @key cgroups - * @requires docker.support + * @requires container.support * @library /test/lib * @modules java.base/jdk.internal.misc * java.management diff --git a/test/hotspot/jtreg/containers/docker/TestJFREvents.java b/test/hotspot/jtreg/containers/docker/TestJFREvents.java index abc9de45db8..77c735cde00 100644 --- a/test/hotspot/jtreg/containers/docker/TestJFREvents.java +++ b/test/hotspot/jtreg/containers/docker/TestJFREvents.java @@ -29,7 +29,7 @@ * when run inside Docker container, such as available CPU and memory. * Also make sure that PIDs are based on value provided by container, * not by the host system. - * @requires (docker.support & os.maxMemory >= 2g) + * @requires (container.support & os.maxMemory >= 2g) * @modules java.base/jdk.internal.platform * @library /test/lib * @modules java.base/jdk.internal.misc diff --git a/test/hotspot/jtreg/containers/docker/TestJFRNetworkEvents.java b/test/hotspot/jtreg/containers/docker/TestJFRNetworkEvents.java index 54ffff4e60e..9f9497d9c63 100644 --- a/test/hotspot/jtreg/containers/docker/TestJFRNetworkEvents.java +++ b/test/hotspot/jtreg/containers/docker/TestJFRNetworkEvents.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,7 +27,7 @@ * @summary Test JFR network related events inside a container; make sure * the reported host ip and host name are correctly reported within * the container. - * @requires docker.support + * @requires container.support * @library /test/lib * @modules java.base/jdk.internal.misc * java.management diff --git a/test/hotspot/jtreg/containers/docker/TestJFRWithJMX.java b/test/hotspot/jtreg/containers/docker/TestJFRWithJMX.java index 61fad4f86be..b7517254281 100644 --- a/test/hotspot/jtreg/containers/docker/TestJFRWithJMX.java +++ b/test/hotspot/jtreg/containers/docker/TestJFRWithJMX.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,7 @@ /* * @test * @summary Test JFR recording controlled via JMX across container boundary. - * @requires docker.support + * @requires container.support * @library /test/lib * @modules java.base/jdk.internal.misc * java.management diff --git a/test/hotspot/jtreg/containers/docker/TestJcmd.java b/test/hotspot/jtreg/containers/docker/TestJcmd.java index 60d4f4a9e5b..ca8f1659fe9 100644 --- a/test/hotspot/jtreg/containers/docker/TestJcmd.java +++ b/test/hotspot/jtreg/containers/docker/TestJcmd.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,7 @@ * @test * @summary Test JCMD across container boundary. The JCMD runs on a host system, * while sending commands to a JVM that runs inside a container. - * @requires docker.support + * @requires container.support * @requires vm.flagless * @modules java.base/jdk.internal.misc * java.management diff --git a/test/hotspot/jtreg/containers/docker/TestJcmdWithSideCar.java b/test/hotspot/jtreg/containers/docker/TestJcmdWithSideCar.java index 0aa16e8479b..de27f4d24e2 100644 --- a/test/hotspot/jtreg/containers/docker/TestJcmdWithSideCar.java +++ b/test/hotspot/jtreg/containers/docker/TestJcmdWithSideCar.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,7 +29,7 @@ * and other uses. In side car pattern the main application/service container * is paired with a sidecar container by sharing certain aspects of container * namespace such as PID namespace, specific sub-directories, IPC and more. - * @requires docker.support + * @requires container.support * @requires vm.flagless * @modules java.base/jdk.internal.misc * java.management @@ -38,14 +38,23 @@ * @build EventGeneratorLoop * @run driver TestJcmdWithSideCar */ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; import java.nio.file.Paths; -import java.util.Arrays; import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.EnumSet; import java.util.List; +import java.util.Optional; import java.util.concurrent.TimeUnit; import java.util.function.Consumer; +import java.util.regex.Pattern; import java.util.stream.Collectors; + import jdk.test.lib.Container; +import jdk.test.lib.Platform; import jdk.test.lib.Utils; import jdk.test.lib.containers.docker.Common; import jdk.test.lib.containers.docker.DockerRunOptions; @@ -60,6 +69,31 @@ public class TestJcmdWithSideCar { private static final long TIME_TO_WAIT_FOR_MAIN_METHOD_START = 50 * 1000; // milliseconds private static final String MAIN_CONTAINER_NAME = "test-container-main"; + private static final String UID = "uid"; + private static final String GID = "gid"; + + private static final Pattern ID_PATTERN = Pattern.compile("uid=(?<" + UID + ">\\d+)\\([^\\)]+\\)\\s+gid=(?<" + GID + ">\\d+).*"); + + private static final Optional USER = ProcessHandle.current().info().user().map( + user -> { + try (var br = new BufferedReader(new InputStreamReader(new ProcessBuilder("id", user).start().getInputStream()))) { + for (final var line : br.lines().toList()) { + final var m = ID_PATTERN.matcher(line); + + if (m.matches()) { + return "--user=" + m.group(UID) + ":" + m.group(GID); + } + } + } catch (IOException e) { + // do nothing... + } + + return null; + } + ); + + private static final String NET_BIND_SERVICE = "--cap-add=NET_BIND_SERVICE"; + public static void main(String[] args) throws Exception { if (!DockerTestUtils.canTestDocker()) { return; @@ -68,24 +102,33 @@ public class TestJcmdWithSideCar { DockerTestUtils.buildJdkContainerImage(IMAGE_NAME); try { - // Start the loop process in the "main" container, then run test cases - // using a sidecar container. - MainContainer mainContainer = new MainContainer(); - mainContainer.start(); - mainContainer.waitForMainMethodStart(TIME_TO_WAIT_FOR_MAIN_METHOD_START); + for (final boolean elevated : USER.isPresent() ? new Boolean[] { false, true } : new Boolean[] { false }) { + // Start the loop process in the "main" container, then run test cases + // using a sidecar container. + MainContainer mainContainer = new MainContainer(); + mainContainer.start(elevated); + mainContainer.waitForMainMethodStart(TIME_TO_WAIT_FOR_MAIN_METHOD_START); - long mainProcPid = testCase01(); + for (AttachStrategy attachStrategy : EnumSet.allOf(AttachStrategy.class)) { + if (attachStrategy == AttachStrategy.ACCESS_TMP_VIA_PROC_ROOT && + elevated && !Platform.isRoot()) { + // Elevated attach via proc/root not yet supported. + continue; + } + long mainProcPid = testCase01(attachStrategy, elevated); - // Excluding the test case below until JDK-8228850 is fixed - // JDK-8228850: jhsdb jinfo fails with ClassCastException: - // s.j.h.oops.TypeArray cannot be cast to s.j.h.oops.Instance - // mainContainer.assertIsAlive(); - // testCase02(mainProcPid); + // Excluding the test case below until JDK-8228850 is fixed + // JDK-8228850: jhsdb jinfo fails with ClassCastException: + // s.j.h.oops.TypeArray cannot be cast to s.j.h.oops.Instance + // mainContainer.assertIsAlive(); + // testCase02(mainProcPid, attachStrategy, elevated); - mainContainer.assertIsAlive(); - testCase03(mainProcPid); + mainContainer.assertIsAlive(); + testCase03(mainProcPid, attachStrategy, elevated); + } - mainContainer.waitForAndCheck(TIME_TO_RUN_MAIN_PROCESS * 1000); + mainContainer.waitForAndCheck(TIME_TO_RUN_MAIN_PROCESS * 1000); + } } finally { DockerTestUtils.removeDockerImage(IMAGE_NAME); } @@ -93,21 +136,21 @@ public class TestJcmdWithSideCar { // Run "jcmd -l" in a sidecar container, find a target process. - private static long testCase01() throws Exception { - OutputAnalyzer out = runSideCar(MAIN_CONTAINER_NAME, "/jdk/bin/jcmd", "-l") + private static long testCase01(AttachStrategy attachStrategy, boolean elevated) throws Exception { + OutputAnalyzer out = runSideCar(MAIN_CONTAINER_NAME, attachStrategy, elevated, "/jdk/bin/jcmd", "-l") .shouldHaveExitValue(0) .shouldContain("sun.tools.jcmd.JCmd"); long pid = findProcess(out, "EventGeneratorLoop"); if (pid == -1) { - throw new RuntimeException("Could not find specified process"); + throw new RuntimeException(attachStrategy + ": Could not find specified process"); } return pid; } // run jhsdb jinfo (jhsdb uses PTRACE) - private static void testCase02(long pid) throws Exception { - runSideCar(MAIN_CONTAINER_NAME, "/jdk/bin/jhsdb", "jinfo", "--pid", "" + pid) + private static void testCase02(long pid, AttachStrategy attachStrategy, boolean elevated) throws Exception { + runSideCar(MAIN_CONTAINER_NAME, attachStrategy, elevated, "/jdk/bin/jhsdb", "jinfo", "--pid", "" + pid) .shouldHaveExitValue(0) .shouldContain("Java System Properties") .shouldContain("VM Flags"); @@ -115,11 +158,11 @@ public class TestJcmdWithSideCar { // test jcmd with some commands (help, start JFR recording) // JCMD will use signal mechanism and Unix Socket - private static void testCase03(long pid) throws Exception { - runSideCar(MAIN_CONTAINER_NAME, "/jdk/bin/jcmd", "" + pid, "help") + private static void testCase03(long pid, AttachStrategy attachStrategy, boolean elevated) throws Exception { + runSideCar(MAIN_CONTAINER_NAME, attachStrategy, elevated, "/jdk/bin/jcmd", "" + pid, "help") .shouldHaveExitValue(0) .shouldContain("VM.version"); - runSideCar(MAIN_CONTAINER_NAME, "/jdk/bin/jcmd", "" + pid, "JFR.start") + runSideCar(MAIN_CONTAINER_NAME, attachStrategy, elevated, "/jdk/bin/jcmd", "" + pid, "JFR.start") .shouldHaveExitValue(0) .shouldContain("Started recording"); } @@ -127,21 +170,36 @@ public class TestJcmdWithSideCar { // JCMD relies on the attach mechanism (com.sun.tools.attach), // which in turn relies on JVMSTAT mechanism, which puts its mapped - // buffers in /tmp directory (hsperfdata_). Thus, in sidecar - // we mount /tmp via --volumes-from from the main container. - private static OutputAnalyzer runSideCar(String mainContainerName, String whatToRun, - String... args) throws Exception { - List cmd = new ArrayList<>(); - String[] command = new String[] { + // buffers in /tmp directory (hsperfdata_). Thus, in the sidecar + // we have two options: + // 1. mount /tmp from the main container using --volumes-from. + // 2. access /tmp from the main container via /proc//root/tmp. + private static OutputAnalyzer runSideCar(String mainContainerName, AttachStrategy attachStrategy, boolean elevated, String whatToRun, String... args) throws Exception { + System.out.println("Attach strategy " + attachStrategy); + + List initialCommands = List.of( Container.ENGINE_COMMAND, "run", "--tty=true", "--rm", "--cap-add=SYS_PTRACE", "--sig-proxy=true", - "--pid=container:" + mainContainerName, - "--volumes-from", mainContainerName, - IMAGE_NAME, whatToRun + "--pid=container:" + mainContainerName + ); + + List attachStrategyCommands = switch (attachStrategy) { + case TMP_MOUNTED_INTO_SIDECAR -> List.of("--volumes-from", mainContainerName); + case ACCESS_TMP_VIA_PROC_ROOT -> List.of(); }; - cmd.addAll(Arrays.asList(command)); + List elevatedOpts = elevated && USER.isPresent() ? List.of(NET_BIND_SERVICE, USER.get()) : Collections.emptyList(); + + List imageAndCommand = List.of( + IMAGE_NAME, whatToRun + ); + + List cmd = new ArrayList<>(); + cmd.addAll(initialCommands); + cmd.addAll(elevatedOpts); + cmd.addAll(attachStrategyCommands); + cmd.addAll(imageAndCommand); cmd.addAll(Arrays.asList(args)); return DockerTestUtils.execute(cmd); } @@ -188,9 +246,15 @@ public class TestJcmdWithSideCar { } }; - public Process start() throws Exception { + public Process start(final boolean elevated) throws Exception { // start "main" container (the observee) DockerRunOptions opts = commonDockerOpts("EventGeneratorLoop"); + + if (elevated && USER.isPresent()) { + opts.addDockerOpts(USER.get()); + opts.addDockerOpts(NET_BIND_SERVICE); + } + opts.addDockerOpts("--cap-add=SYS_PTRACE") .addDockerOpts("--name", MAIN_CONTAINER_NAME) .addDockerOpts("--volume", "/tmp") @@ -241,7 +305,7 @@ public class TestJcmdWithSideCar { try { exitValue = p.exitValue(); } catch(IllegalThreadStateException ex) { - System.out.println("IllegalThreadStateException occured when calling exitValue()"); + System.out.println("IllegalThreadStateException occurred when calling exitValue()"); retryCount--; } } while (exitValue == -1 && retryCount > 0); @@ -253,4 +317,8 @@ public class TestJcmdWithSideCar { } + private enum AttachStrategy { + TMP_MOUNTED_INTO_SIDECAR, + ACCESS_TMP_VIA_PROC_ROOT + } } diff --git a/test/hotspot/jtreg/containers/docker/TestLimitsUpdating.java b/test/hotspot/jtreg/containers/docker/TestLimitsUpdating.java index e15ab9b2b81..14227a71068 100644 --- a/test/hotspot/jtreg/containers/docker/TestLimitsUpdating.java +++ b/test/hotspot/jtreg/containers/docker/TestLimitsUpdating.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2023, Red Hat, Inc. + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -28,7 +29,7 @@ * @bug 8308090 * @key cgroups * @summary Test container limits updating as they get updated at runtime without restart - * @requires docker.support + * @requires container.support * @library /test/lib * @build jdk.test.whitebox.WhiteBox LimitUpdateChecker * @run driver jdk.test.lib.helpers.ClassFileInstaller -jar whitebox.jar jdk.test.whitebox.WhiteBox diff --git a/test/hotspot/jtreg/containers/docker/TestMemoryAwareness.java b/test/hotspot/jtreg/containers/docker/TestMemoryAwareness.java index 20354cf934d..06a874e008a 100644 --- a/test/hotspot/jtreg/containers/docker/TestMemoryAwareness.java +++ b/test/hotspot/jtreg/containers/docker/TestMemoryAwareness.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,7 +27,7 @@ * @bug 8146115 8292083 * @key cgroups * @summary Test JVM's memory resource awareness when running inside docker container - * @requires docker.support + * @requires container.support * @library /test/lib * @modules java.base/jdk.internal.misc * java.base/jdk.internal.platform diff --git a/test/hotspot/jtreg/containers/docker/TestMisc.java b/test/hotspot/jtreg/containers/docker/TestMisc.java index 5b7f96112b9..a811666999b 100644 --- a/test/hotspot/jtreg/containers/docker/TestMisc.java +++ b/test/hotspot/jtreg/containers/docker/TestMisc.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,7 @@ /* * @test * @summary Test miscellanous functionality related to JVM running in docker container - * @requires docker.support + * @requires container.support * @library /test/lib * @modules java.base/jdk.internal.misc * java.management diff --git a/test/hotspot/jtreg/containers/docker/TestPids.java b/test/hotspot/jtreg/containers/docker/TestPids.java index 2b3b2594cfa..9b65a1b1ee8 100644 --- a/test/hotspot/jtreg/containers/docker/TestPids.java +++ b/test/hotspot/jtreg/containers/docker/TestPids.java @@ -27,7 +27,7 @@ * @test * @key cgroups * @summary Test JVM's awareness of pids controller - * @requires docker.support + * @requires container.support * @library /test/lib * @modules java.base/jdk.internal.misc * java.management diff --git a/test/hotspot/jtreg/containers/systemd/HelloSystemd.java b/test/hotspot/jtreg/containers/systemd/HelloSystemd.java new file mode 100644 index 00000000000..1b320131bf5 --- /dev/null +++ b/test/hotspot/jtreg/containers/systemd/HelloSystemd.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024, Red Hat, Inc. + * 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. + */ + +public class HelloSystemd { + public static void main(String args[]) { + System.out.println("Hello Systemd"); + } +} diff --git a/test/hotspot/jtreg/containers/systemd/SystemdMemoryAwarenessTest.java b/test/hotspot/jtreg/containers/systemd/SystemdMemoryAwarenessTest.java new file mode 100644 index 00000000000..2c06d48bb1c --- /dev/null +++ b/test/hotspot/jtreg/containers/systemd/SystemdMemoryAwarenessTest.java @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2024, Red Hat, Inc. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import jdk.test.lib.containers.systemd.SystemdRunOptions; +import jdk.test.lib.containers.systemd.SystemdTestUtils; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.whitebox.WhiteBox; +import jtreg.SkippedException; + +/* + * @test + * @bug 8322420 8217338 + * @summary Memory/CPU awareness test for JDK-under-test inside a systemd slice. + * @requires systemd.support + * @library /test/lib + * @modules java.base/jdk.internal.platform + * @build HelloSystemd jdk.test.whitebox.WhiteBox + * @run driver jdk.test.lib.helpers.ClassFileInstaller -jar whitebox.jar jdk.test.whitebox.WhiteBox + * @run main/othervm -Xbootclasspath/a:whitebox.jar -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI SystemdMemoryAwarenessTest + */ +public class SystemdMemoryAwarenessTest { + + private static final int MB = 1024 * 1024; + private static final WhiteBox wb = WhiteBox.getWhiteBox(); + private static final String TEST_SLICE_NAME = SystemdMemoryAwarenessTest.class.getSimpleName() + "HS"; + + public static void main(String[] args) throws Exception { + testHelloSystemd(); + } + + private static void testHelloSystemd() throws Exception { + SystemdRunOptions opts = SystemdTestUtils.newOpts("HelloSystemd"); + // 1 GB memory, but the limit in the lower hierarchy is 512M + opts.memoryLimit("1024M"); + int expectedMemLimit = 512; + // expected detected limit we test for, 512MB + opts.sliceDMemoryLimit(String.format("%dM", expectedMemLimit)); + int physicalCpus = wb.hostCPUs(); + if (physicalCpus < 2) { + System.err.println("WARNING: host system only has " + physicalCpus + " cpus. Expected >= 2"); + System.err.println("The active_processor_count assertion will trivially pass."); + } + // Use a CPU core limit of 1 for best coverage + int coreLimit = 1; + System.out.println("DEBUG: Running test with a CPU limit of " + coreLimit); + opts.cpuLimit(String.format("%d%%", coreLimit * 100)); + opts.sliceName(TEST_SLICE_NAME); + + OutputAnalyzer out = SystemdTestUtils.buildAndRunSystemdJava(opts); + out.shouldHaveExitValue(0) + .shouldContain("Hello Systemd") + .shouldContain(String.format("Memory Limit is: %d", (expectedMemLimit * MB))); + try { + out.shouldContain("OSContainer::active_processor_count: " + coreLimit); + } catch (RuntimeException e) { + // CPU delegation needs to be enabled when run as user on cg v2 + if (SystemdTestUtils.RUN_AS_USER) { + String hint = "When run as user on cg v2 cpu delegation needs to be configured!"; + throw new SkippedException(hint); + } + throw e; + } + } + +} diff --git a/test/hotspot/jtreg/containers/systemd/TEST.properties b/test/hotspot/jtreg/containers/systemd/TEST.properties new file mode 100644 index 00000000000..d563e5f1664 --- /dev/null +++ b/test/hotspot/jtreg/containers/systemd/TEST.properties @@ -0,0 +1,24 @@ +# +# Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +exclusiveAccess.dirs=. diff --git a/test/hotspot/jtreg/gc/arguments/TestG1HeapSizeFlags.java b/test/hotspot/jtreg/gc/arguments/TestG1HeapSizeFlags.java index 24e542881c0..4b69421e6e3 100644 --- a/test/hotspot/jtreg/gc/arguments/TestG1HeapSizeFlags.java +++ b/test/hotspot/jtreg/gc/arguments/TestG1HeapSizeFlags.java @@ -29,6 +29,7 @@ package gc.arguments; * @summary Tests argument processing for initial and maximum heap size for the G1 collector * @key flag-sensitive * @requires vm.gc.G1 & vm.opt.MinHeapSize == null & vm.opt.MaxHeapSize == null & vm.opt.InitialHeapSize == null + * @requires vm.compMode != "Xcomp" * @library /test/lib * @library / * @modules java.base/jdk.internal.misc diff --git a/test/hotspot/jtreg/gc/arguments/TestParallelHeapSizeFlags.java b/test/hotspot/jtreg/gc/arguments/TestParallelHeapSizeFlags.java index 544064953df..ca8d1e74895 100644 --- a/test/hotspot/jtreg/gc/arguments/TestParallelHeapSizeFlags.java +++ b/test/hotspot/jtreg/gc/arguments/TestParallelHeapSizeFlags.java @@ -30,6 +30,7 @@ package gc.arguments; * parallel collectors. * @key flag-sensitive * @requires vm.gc.Parallel & vm.opt.MinHeapSize == null & vm.opt.MaxHeapSize == null & vm.opt.InitialHeapSize == null + * @requires vm.compMode != "Xcomp" * @library /test/lib * @library / * @modules java.base/jdk.internal.misc diff --git a/test/hotspot/jtreg/gc/arguments/TestSerialHeapSizeFlags.java b/test/hotspot/jtreg/gc/arguments/TestSerialHeapSizeFlags.java index c580245a2a3..b9cc0f231f2 100644 --- a/test/hotspot/jtreg/gc/arguments/TestSerialHeapSizeFlags.java +++ b/test/hotspot/jtreg/gc/arguments/TestSerialHeapSizeFlags.java @@ -29,6 +29,7 @@ package gc.arguments; * @summary Tests argument processing for initial and maximum heap size for the Serial collector * @key flag-sensitive * @requires vm.gc.Serial & vm.opt.MinHeapSize == null & vm.opt.MaxHeapSize == null & vm.opt.InitialHeapSize == null + * @requires vm.compMode != "Xcomp" * @library /test/lib * @library / * @modules java.base/jdk.internal.misc diff --git a/test/hotspot/jtreg/gc/shenandoah/oom/TestClassLoaderLeak.java b/test/hotspot/jtreg/gc/shenandoah/oom/TestClassLoaderLeak.java index 1a3d07bf80d..00e32a4136e 100644 --- a/test/hotspot/jtreg/gc/shenandoah/oom/TestClassLoaderLeak.java +++ b/test/hotspot/jtreg/gc/shenandoah/oom/TestClassLoaderLeak.java @@ -27,7 +27,7 @@ * @summary Test OOME in due to classloader leak * @requires vm.gc.Shenandoah * @library /test/lib - * @run driver TestClassLoaderLeak + * @run driver/timeout=600 TestClassLoaderLeak */ import java.util.*; diff --git a/test/hotspot/jtreg/gc/x/TestAllocateHeapAt.java b/test/hotspot/jtreg/gc/x/TestAllocateHeapAt.java index 3bf83d90768..6a9768de7e6 100644 --- a/test/hotspot/jtreg/gc/x/TestAllocateHeapAt.java +++ b/test/hotspot/jtreg/gc/x/TestAllocateHeapAt.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ package gc.x; /* * @test TestAllocateHeapAt * @requires vm.gc.ZSinglegen & os.family == "linux" + * @requires !vm.opt.final.UseLargePages * @summary Test ZGC with -XX:AllocateHeapAt * @library /test/lib * @run main/othervm gc.x.TestAllocateHeapAt . true @@ -41,7 +42,7 @@ public class TestAllocateHeapAt { final String heapBackingFile = "Heap Backing File: " + directory; final String failedToCreateFile = "Failed to create file " + directory; - ProcessTools.executeLimitedTestJava( + ProcessTools.executeTestJava( "-XX:+UseZGC", "-XX:-ZGenerational", "-Xlog:gc*", diff --git a/test/hotspot/jtreg/gc/x/TestPageCacheFlush.java b/test/hotspot/jtreg/gc/x/TestPageCacheFlush.java index cb8685d0d09..a48b6f77e17 100644 --- a/test/hotspot/jtreg/gc/x/TestPageCacheFlush.java +++ b/test/hotspot/jtreg/gc/x/TestPageCacheFlush.java @@ -68,7 +68,7 @@ public class TestPageCacheFlush { } public static void main(String[] args) throws Exception { - ProcessTools.executeLimitedTestJava( + ProcessTools.executeTestJava( "-XX:+UseZGC", "-XX:-ZGenerational", "-Xms128M", diff --git a/test/hotspot/jtreg/gc/x/TestSmallHeap.java b/test/hotspot/jtreg/gc/x/TestSmallHeap.java index 8fc6f07be39..a7e8042f924 100644 --- a/test/hotspot/jtreg/gc/x/TestSmallHeap.java +++ b/test/hotspot/jtreg/gc/x/TestSmallHeap.java @@ -53,7 +53,7 @@ public class TestSmallHeap { public static void main(String[] args) throws Exception { for (var maxCapacity: args) { - ProcessTools.executeLimitedTestJava( + ProcessTools.executeTestJava( "-XX:+UseZGC", "-XX:-ZGenerational", "-Xlog:gc,gc+init,gc+reloc,gc+heap", diff --git a/test/hotspot/jtreg/gc/z/TestAllocateHeapAt.java b/test/hotspot/jtreg/gc/z/TestAllocateHeapAt.java index 9f47c4b60d3..2fb040840b4 100644 --- a/test/hotspot/jtreg/gc/z/TestAllocateHeapAt.java +++ b/test/hotspot/jtreg/gc/z/TestAllocateHeapAt.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ package gc.z; /* * @test TestAllocateHeapAt * @requires vm.gc.ZGenerational & os.family == "linux" + * @requires !vm.opt.final.UseLargePages * @summary Test ZGC with -XX:AllocateHeapAt * @library /test/lib * @run main/othervm gc.z.TestAllocateHeapAt . true @@ -41,7 +42,7 @@ public class TestAllocateHeapAt { final String heapBackingFile = "Heap Backing File: " + directory; final String failedToCreateFile = "Failed to create file " + directory; - ProcessTools.executeLimitedTestJava( + ProcessTools.executeTestJava( "-XX:+UseZGC", "-XX:+ZGenerational", "-Xlog:gc*", diff --git a/test/hotspot/jtreg/gc/z/TestAllocateHeapAtWithHugeTLBFS.java b/test/hotspot/jtreg/gc/z/TestAllocateHeapAtWithHugeTLBFS.java new file mode 100644 index 00000000000..ac647bbd013 --- /dev/null +++ b/test/hotspot/jtreg/gc/z/TestAllocateHeapAtWithHugeTLBFS.java @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package gc.z; + +/* + * @test TestAllocateHeapAtWithHugeTLBFS + * @requires vm.gc.ZGenerational & os.family == "linux" + * @summary Test ZGC with -XX:AllocateHeapAt and -XX:+UseLargePages + * @library /test/lib + * @run driver gc.z.TestAllocateHeapAtWithHugeTLBFS true + * @run driver gc.z.TestAllocateHeapAtWithHugeTLBFS false + */ + +import jdk.test.lib.process.ProcessTools; +import jtreg.SkippedException; + +import java.io.File; +import java.io.FileNotFoundException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.nio.file.Path; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.Scanner; + +public class TestAllocateHeapAtWithHugeTLBFS { + static String find_hugetlbfs_mountpoint() { + Pattern pat = Pattern.compile("\\d+ \\d+ \\d+:\\d+ \\S+ (\\S+) [^-]*- hugetlbfs (.+)"); + try (Scanner scanner = new Scanner(new File("/proc/self/mountinfo"))) { + while (scanner.hasNextLine()) { + final Matcher mat = pat.matcher(scanner.nextLine()); + if (mat.matches() && mat.group(2).contains("pagesize=2M")) { + final Path path = Paths.get(mat.group(1)); + if (Files.isReadable(path) && + Files.isWritable(path) && + Files.isExecutable(path)) { + // Found a usable mount point. + return path.toString(); + } + } + } + } catch (FileNotFoundException e) { + System.out.println("Could not open /proc/self/mountinfo"); + } + return null; + } + public static void main(String[] args) throws Exception { + final boolean exists = Boolean.parseBoolean(args[0]); + final String directory = exists ? find_hugetlbfs_mountpoint() + : "non-existing-directory"; + if (directory == null) { + throw new SkippedException("No valid hugetlbfs mount point found"); + } + final String heapBackingFile = "Heap Backing File: " + directory; + final String failedToCreateFile = "Failed to create file " + directory; + + ProcessTools.executeTestJava( + "-XX:+UseZGC", + "-XX:+ZGenerational", + "-Xlog:gc*", + "-Xms32M", + "-Xmx32M", + "-XX:+UseLargePages", + "-XX:AllocateHeapAt=" + directory, + "-version") + .shouldContain(exists ? heapBackingFile : failedToCreateFile) + .shouldNotContain(exists ? failedToCreateFile : heapBackingFile) + .shouldHaveExitValue(exists ? 0 : 1); + } +} diff --git a/test/hotspot/jtreg/gc/z/TestPageCacheFlush.java b/test/hotspot/jtreg/gc/z/TestPageCacheFlush.java index 387053b580a..3b666ddc2c8 100644 --- a/test/hotspot/jtreg/gc/z/TestPageCacheFlush.java +++ b/test/hotspot/jtreg/gc/z/TestPageCacheFlush.java @@ -68,7 +68,7 @@ public class TestPageCacheFlush { } public static void main(String[] args) throws Exception { - ProcessTools.executeLimitedTestJava( + ProcessTools.executeTestJava( "-XX:+UseZGC", "-XX:+ZGenerational", "-Xms128M", diff --git a/test/hotspot/jtreg/gc/z/TestSmallHeap.java b/test/hotspot/jtreg/gc/z/TestSmallHeap.java index 354cd4164f1..67d9d33d281 100644 --- a/test/hotspot/jtreg/gc/z/TestSmallHeap.java +++ b/test/hotspot/jtreg/gc/z/TestSmallHeap.java @@ -53,7 +53,7 @@ public class TestSmallHeap { public static void main(String[] args) throws Exception { for (var maxCapacity: args) { - ProcessTools.executeLimitedTestJava( + ProcessTools.executeTestJava( "-XX:+UseZGC", "-XX:+ZGenerational", "-Xlog:gc,gc+init,gc+reloc,gc+heap", diff --git a/test/hotspot/jtreg/gtest/CompressedKlassGtest.java b/test/hotspot/jtreg/gtest/CompressedKlassGtest.java new file mode 100644 index 00000000000..e6377a8570d --- /dev/null +++ b/test/hotspot/jtreg/gtest/CompressedKlassGtest.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024, Red Hat, Inc. All rights reserved. + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +/* + * This runs the "compressedKlass" class of gtests. + * Note: we try to trigger bugs by enforcing the JVM to use zero-based mode. To increase the chance of zero-based + * mode, we start with CDS disabled, a small class space and a large (albeit uncommitted, to save memory) heap. The + * JVM will likely place the class space in low-address territory. + * (If it does not manage to do this, the test will still succeed, but it won't alert us on regressions) + */ + +/* @test id=use-zero-based-encoding + * @library /test/lib + * @modules java.base/jdk.internal.misc + * java.xml + * @run main/native GTestWrapper --gtest_filter=CompressedKlass* -Xlog:metaspace* -Xmx6g -Xms128m -Xshare:off -XX:CompressedClassSpaceSize=128m + */ diff --git a/test/hotspot/jtreg/resourcehogs/compiler/intrinsics/string/TestStringIntrinsics2LargeArray.java b/test/hotspot/jtreg/resourcehogs/compiler/intrinsics/string/TestStringIntrinsics2LargeArray.java index 598633d307f..6ed778e6e0b 100644 --- a/test/hotspot/jtreg/resourcehogs/compiler/intrinsics/string/TestStringIntrinsics2LargeArray.java +++ b/test/hotspot/jtreg/resourcehogs/compiler/intrinsics/string/TestStringIntrinsics2LargeArray.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016 SAP SE. All rights reserved. * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -35,7 +35,7 @@ * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox * * @run main/othervm - * -mx8G + * -Xmx8G * -Xbootclasspath/a:. * -Xmixed * -XX:+UnlockDiagnosticVMOptions diff --git a/test/hotspot/jtreg/runtime/Annotations/BadContendedGroupBadCPIndex.jcod b/test/hotspot/jtreg/runtime/Annotations/BadContendedGroupBadCPIndex.jcod new file mode 100644 index 00000000000..4802548926b --- /dev/null +++ b/test/hotspot/jtreg/runtime/Annotations/BadContendedGroupBadCPIndex.jcod @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* Based on source: + * public class ContendedField { + * @Contended("group1") + * public int field; + * } + * + * We change the value of "value" so it refers to an invalid CP entry + */ + +class BadContendedGroupBadCPIndex { + 0xCAFEBABE; + 0; // minor version + 65; // version + [19] { // Constant Pool + ; // first element is empty + Method #2 #3; // #1 at 0x0A + class #4; // #2 at 0x0F + NameAndType #5 #6; // #3 at 0x12 + Utf8 "java/lang/Object"; // #4 at 0x17 + Utf8 ""; // #5 at 0x2A + Utf8 "()V"; // #6 at 0x33 + class #8; // #7 at 0x39 + Utf8 "BadContendedGroupBadCPIndex"; // #8 at 0x3C + Utf8 "field"; // #9 at 0x4D + Utf8 "I"; // #10 at 0x55 + Utf8 "RuntimeVisibleAnnotations"; // #11 at 0x59 + Utf8 "Ljdk/internal/vm/annotation/Contended;"; // #12 at 0x75 + Utf8 "value"; // #13 at 0x9E + Utf8 "group1"; // #14 at 0xA6 + Utf8 "Code"; // #15 at 0xAF + Utf8 "LineNumberTable"; // #16 at 0xB6 + Utf8 "SourceFile"; // #17 at 0xC8 + Utf8 "BadContendedGroupBadCPIndex.java"; // #18 at 0xD5 + } // Constant Pool + + 0x0021; // access [ ACC_PUBLIC ACC_SUPER ] + #7;// this_cpx + #2;// super_cpx + + [0] { // Interfaces + } // Interfaces + + [1] { // Fields + { // field at 0xF5 + 0x0001; // access + #9; // name_index : field + #10; // descriptor_index : I + [1] { // Attributes + Attr(#11, 11) { // RuntimeVisibleAnnotations at 0xFD + [1] { // annotations + { // annotation + #12; + [1] { // element_value_pairs + { // element value pair + #13; + { // element_value + 's'; + #1400; // Changed from #14 to #1400 + } // element_value + } // element value pair + } // element_value_pairs + } // annotation + } + } // end RuntimeVisibleAnnotations + } // Attributes + } + } // Fields + + [1] { // Methods + { // method at 0x0110 + 0x0001; // access + #5; // name_index : + #6; // descriptor_index : ()V + [1] { // Attributes + Attr(#15, 29) { // Code at 0x0118 + 1; // max_stack + 1; // max_locals + Bytes[5]{ + 0x2AB70001B1; + } + [0] { // Traps + } // end Traps + [1] { // Attributes + Attr(#16, 6) { // LineNumberTable at 0x012F + [1] { // line_number_table + 0 2; // at 0x013B + } + } // end LineNumberTable + } // Attributes + } // end Code + } // Attributes + } + } // Methods + + [1] { // Attributes + Attr(#17, 2) { // SourceFile at 0x013D + #18; + } // end SourceFile + } // Attributes +} // end class BadContendedGroupBadCPIndex diff --git a/test/hotspot/jtreg/runtime/Annotations/BadContendedGroupWrongType.jcod b/test/hotspot/jtreg/runtime/Annotations/BadContendedGroupWrongType.jcod new file mode 100644 index 00000000000..6fa53f939b3 --- /dev/null +++ b/test/hotspot/jtreg/runtime/Annotations/BadContendedGroupWrongType.jcod @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* Based on source: + * public class ContendedField { + * @Contended("group1") + * public int field; + * } + * + * We change the value of "value" so it refers to the wrong type of CP entry + */ + +class BadContendedGroupWrongType { + 0xCAFEBABE; + 0; // minor version + 65; // version + [19] { // Constant Pool + ; // first element is empty + Method #2 #3; // #1 at 0x0A + class #4; // #2 at 0x0F + NameAndType #5 #6; // #3 at 0x12 + Utf8 "java/lang/Object"; // #4 at 0x17 + Utf8 ""; // #5 at 0x2A + Utf8 "()V"; // #6 at 0x33 + class #8; // #7 at 0x39 + Utf8 "BadContendedGroupWrongType"; // #8 at 0x3C + Utf8 "field"; // #9 at 0x4D + Utf8 "I"; // #10 at 0x55 + Utf8 "RuntimeVisibleAnnotations"; // #11 at 0x59 + Utf8 "Ljdk/internal/vm/annotation/Contended;"; // #12 at 0x75 + Utf8 "value"; // #13 at 0x9E + Utf8 "group1"; // #14 at 0xA6 + Utf8 "Code"; // #15 at 0xAF + Utf8 "LineNumberTable"; // #16 at 0xB6 + Utf8 "SourceFile"; // #17 at 0xC8 + Utf8 "BadContendedGroupWrongType.java"; // #18 at 0xD5 + } // Constant Pool + + 0x0021; // access [ ACC_PUBLIC ACC_SUPER ] + #7;// this_cpx + #2;// super_cpx + + [0] { // Interfaces + } // Interfaces + + [1] { // Fields + { // field at 0xF5 + 0x0001; // access + #9; // name_index : field + #10; // descriptor_index : I + [1] { // Attributes + Attr(#11, 11) { // RuntimeVisibleAnnotations at 0xFD + [1] { // annotations + { // annotation + #12; + [1] { // element_value_pairs + { // element value pair + #13; + { // element_value + 's'; + #7; // Changed from #14 (utf8) to #7 (class) + } // element_value + } // element value pair + } // element_value_pairs + } // annotation + } + } // end RuntimeVisibleAnnotations + } // Attributes + } + } // Fields + + [1] { // Methods + { // method at 0x0110 + 0x0001; // access + #5; // name_index : + #6; // descriptor_index : ()V + [1] { // Attributes + Attr(#15, 29) { // Code at 0x0118 + 1; // max_stack + 1; // max_locals + Bytes[5]{ + 0x2AB70001B1; + } + [0] { // Traps + } // end Traps + [1] { // Attributes + Attr(#16, 6) { // LineNumberTable at 0x012F + [1] { // line_number_table + 0 2; // at 0x013B + } + } // end LineNumberTable + } // Attributes + } // end Code + } // Attributes + } + } // Methods + + [1] { // Attributes + Attr(#17, 2) { // SourceFile at 0x013D + #18; + } // end SourceFile + } // Attributes +} // end class BadContendedGroupWrongType diff --git a/test/hotspot/jtreg/runtime/Annotations/BadDeprecatedExtraMemberAtEnd.jcod b/test/hotspot/jtreg/runtime/Annotations/BadDeprecatedExtraMemberAtEnd.jcod new file mode 100644 index 00000000000..991c4c832b3 --- /dev/null +++ b/test/hotspot/jtreg/runtime/Annotations/BadDeprecatedExtraMemberAtEnd.jcod @@ -0,0 +1,163 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* Based on source: + * + * public class DeprecatedMethod { + * @Deprecated(forRemoval=true, since="now") + * public static void m() {} + * } + * + * We add an extra junk member at the end. + */ + +class BadDeprecatedExtraMemberAtEnd { + 0xCAFEBABE; + 0; // minor version + 65; // version + [21] { // Constant Pool + ; // first element is empty + Method #2 #3; // #1 at 0x0A + class #4; // #2 at 0x0F + NameAndType #5 #6; // #3 at 0x12 + Utf8 "java/lang/Object"; // #4 at 0x17 + Utf8 ""; // #5 at 0x2A + Utf8 "()V"; // #6 at 0x33 + class #8; // #7 at 0x39 + Utf8 "BadDeprecatedExtraMemberAtEnd"; // #8 at 0x3C + Utf8 "Code"; // #9 at 0x4F + Utf8 "LineNumberTable"; // #10 at 0x56 + Utf8 "m"; // #11 at 0x68 + Utf8 "Deprecated"; // #12 at 0x6C + Utf8 "RuntimeVisibleAnnotations"; // #13 at 0x79 + Utf8 "Ljava/lang/Deprecated;"; // #14 at 0x95 + Utf8 "forRemoval"; // #15 at 0xAE + int 0x00000001; // #16 at 0xBB + Utf8 "since"; // #17 at 0xC0 + Utf8 "now"; // #18 at 0xC8 + Utf8 "SourceFile"; // #19 at 0xCE + Utf8 "BadDeprecatedExtraMemberAtEnd.java"; // #20 at 0xDB + } // Constant Pool + + 0x0021; // access [ ACC_PUBLIC ACC_SUPER ] + #7;// this_cpx + #2;// super_cpx + + [0] { // Interfaces + } // Interfaces + + [0] { // Fields + } // Fields + + [2] { // Methods + { // method at 0xFF + 0x0001; // access + #5; // name_index : + #6; // descriptor_index : ()V + [1] { // Attributes + Attr(#9, 29) { // Code at 0x0107 + 1; // max_stack + 1; // max_locals + Bytes[5]{ + 0x2AB70001B1; + } + [0] { // Traps + } // end Traps + [1] { // Attributes + Attr(#10, 6) { // LineNumberTable at 0x011E + [1] { // line_number_table + 0 1; // at 0x012A + } + } // end LineNumberTable + } // Attributes + } // end Code + } // Attributes + } + ; + { // method at 0x012A + 0x0009; // access + #11; // name_index : m + #6; // descriptor_index : ()V + [3] { // Attributes + Attr(#9, 25) { // Code at 0x0132 + 0; // max_stack + 0; // max_locals + Bytes[1]{ + 0xB1; + } + [0] { // Traps + } // end Traps + [1] { // Attributes + Attr(#10, 6) { // LineNumberTable at 0x0145 + [1] { // line_number_table + 0 4; // at 0x0151 + } + } // end LineNumberTable + } // Attributes + } // end Code + ; + Attr(#12, 0) { // Deprecated at 0x0151 + } // end Deprecated + ; + Attr(#13, 21) { // RuntimeVisibleAnnotations at 0x0157 (length changed from 16 to 21) + [1] { // annotations + { // annotation + #14; + [3] { // element_value_pairs <= extra pair added + { // element value pair + #15; + { // element_value + 'Z'; + #16; + } // element_value + } // element value pair + ; + { // element value pair + #17; + { // element_value + 's'; + #18; + } // element_value + } // element value pair + ; + { // Extra element value pair: now=true + #18; + { // element_value + 'Z'; + #16; + } // element_value + } // element value pair + } // element_value_pairs + } // annotation + } + } // end RuntimeVisibleAnnotations + } // Attributes + } + } // Methods + + [1] { // Attributes + Attr(#19, 2) { // SourceFile at 0x016F + #20; + } // end SourceFile + } // Attributes +} // end class BadDeprecatedExtraMemberAtEnd diff --git a/test/hotspot/jtreg/runtime/Annotations/BadDeprecatedExtraMemberAtStart.jcod b/test/hotspot/jtreg/runtime/Annotations/BadDeprecatedExtraMemberAtStart.jcod new file mode 100644 index 00000000000..0adf08049fd --- /dev/null +++ b/test/hotspot/jtreg/runtime/Annotations/BadDeprecatedExtraMemberAtStart.jcod @@ -0,0 +1,163 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* Based on source: + * + * public class DeprecatedMethod { + * @Deprecated(forRemoval=true, since="now") + * public static void m() {} + * } + * + * We add an extra junk member at the start. + */ + +class BadDeprecatedExtraMemberAtStart { + 0xCAFEBABE; + 0; // minor version + 65; // version + [21] { // Constant Pool + ; // first element is empty + Method #2 #3; // #1 at 0x0A + class #4; // #2 at 0x0F + NameAndType #5 #6; // #3 at 0x12 + Utf8 "java/lang/Object"; // #4 at 0x17 + Utf8 ""; // #5 at 0x2A + Utf8 "()V"; // #6 at 0x33 + class #8; // #7 at 0x39 + Utf8 "BadDeprecatedExtraMemberAtStart"; // #8 at 0x3C + Utf8 "Code"; // #9 at 0x4F + Utf8 "LineNumberTable"; // #10 at 0x56 + Utf8 "m"; // #11 at 0x68 + Utf8 "Deprecated"; // #12 at 0x6C + Utf8 "RuntimeVisibleAnnotations"; // #13 at 0x79 + Utf8 "Ljava/lang/Deprecated;"; // #14 at 0x95 + Utf8 "forRemoval"; // #15 at 0xAE + int 0x00000001; // #16 at 0xBB + Utf8 "since"; // #17 at 0xC0 + Utf8 "now"; // #18 at 0xC8 + Utf8 "SourceFile"; // #19 at 0xCE + Utf8 "BadDeprecatedExtraMemberAtStart.java"; // #20 at 0xDB + } // Constant Pool + + 0x0021; // access [ ACC_PUBLIC ACC_SUPER ] + #7;// this_cpx + #2;// super_cpx + + [0] { // Interfaces + } // Interfaces + + [0] { // Fields + } // Fields + + [2] { // Methods + { // method at 0xFF + 0x0001; // access + #5; // name_index : + #6; // descriptor_index : ()V + [1] { // Attributes + Attr(#9, 29) { // Code at 0x0107 + 1; // max_stack + 1; // max_locals + Bytes[5]{ + 0x2AB70001B1; + } + [0] { // Traps + } // end Traps + [1] { // Attributes + Attr(#10, 6) { // LineNumberTable at 0x011E + [1] { // line_number_table + 0 1; // at 0x012A + } + } // end LineNumberTable + } // Attributes + } // end Code + } // Attributes + } + ; + { // method at 0x012A + 0x0009; // access + #11; // name_index : m + #6; // descriptor_index : ()V + [3] { // Attributes + Attr(#9, 25) { // Code at 0x0132 + 0; // max_stack + 0; // max_locals + Bytes[1]{ + 0xB1; + } + [0] { // Traps + } // end Traps + [1] { // Attributes + Attr(#10, 6) { // LineNumberTable at 0x0145 + [1] { // line_number_table + 0 4; // at 0x0151 + } + } // end LineNumberTable + } // Attributes + } // end Code + ; + Attr(#12, 0) { // Deprecated at 0x0151 + } // end Deprecated + ; + Attr(#13, 21) { // RuntimeVisibleAnnotations at 0x0157 (length changed from 16 to 21) + [1] { // annotations + { // annotation + #14; + [3] { // element_value_pairs <= extra pair added + { // Extra element value pair: now=true + #18; + { // element_value + 'Z'; + #16; + } // element_value + } // element value pair + ; + { // element value pair + #15; + { // element_value + 'Z'; + #16; + } // element_value + } // element value pair + ; + { // element value pair + #17; + { // element_value + 's'; + #18; + } // element_value + } // element value pair + } // element_value_pairs + } // annotation + } + } // end RuntimeVisibleAnnotations + } // Attributes + } + } // Methods + + [1] { // Attributes + Attr(#19, 2) { // SourceFile at 0x016F + #20; + } // end SourceFile + } // Attributes +} // end class BadDeprecatedExtraMemberAtStart diff --git a/test/hotspot/jtreg/runtime/Annotations/BadDeprecatedForRemovalBadCPIndex.jcod b/test/hotspot/jtreg/runtime/Annotations/BadDeprecatedForRemovalBadCPIndex.jcod new file mode 100644 index 00000000000..e8648e0c705 --- /dev/null +++ b/test/hotspot/jtreg/runtime/Annotations/BadDeprecatedForRemovalBadCPIndex.jcod @@ -0,0 +1,155 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* Based on source: + * + * public class DeprecatedMethod { + * @Deprecated(forRemoval=true, since="now") + * public static void m() {} + * } + * + * We change the CP index for the value of forRemoval to a junk value + */ + +class BadDeprecatedForRemovalBadCPIndex { + 0xCAFEBABE; + 0; // minor version + 65; // version + [21] { // Constant Pool + ; // first element is empty + Method #2 #3; // #1 at 0x0A + class #4; // #2 at 0x0F + NameAndType #5 #6; // #3 at 0x12 + Utf8 "java/lang/Object"; // #4 at 0x17 + Utf8 ""; // #5 at 0x2A + Utf8 "()V"; // #6 at 0x33 + class #8; // #7 at 0x39 + Utf8 "BadDeprecatedForRemovalBadCPIndex"; // #8 at 0x3C + Utf8 "Code"; // #9 at 0x4F + Utf8 "LineNumberTable"; // #10 at 0x56 + Utf8 "m"; // #11 at 0x68 + Utf8 "Deprecated"; // #12 at 0x6C + Utf8 "RuntimeVisibleAnnotations"; // #13 at 0x79 + Utf8 "Ljava/lang/Deprecated;"; // #14 at 0x95 + Utf8 "forRemoval"; // #15 at 0xAE + int 0x00000001; // #16 at 0xBB + Utf8 "since"; // #17 at 0xC0 + Utf8 "now"; // #18 at 0xC8 + Utf8 "SourceFile"; // #19 at 0xCE + Utf8 "BadDeprecatedForRemovalBadCPIndex.java"; // #20 at 0xDB + } // Constant Pool + + 0x0021; // access [ ACC_PUBLIC ACC_SUPER ] + #7;// this_cpx + #2;// super_cpx + + [0] { // Interfaces + } // Interfaces + + [0] { // Fields + } // Fields + + [2] { // Methods + { // method at 0xFF + 0x0001; // access + #5; // name_index : + #6; // descriptor_index : ()V + [1] { // Attributes + Attr(#9, 29) { // Code at 0x0107 + 1; // max_stack + 1; // max_locals + Bytes[5]{ + 0x2AB70001B1; + } + [0] { // Traps + } // end Traps + [1] { // Attributes + Attr(#10, 6) { // LineNumberTable at 0x011E + [1] { // line_number_table + 0 1; // at 0x012A + } + } // end LineNumberTable + } // Attributes + } // end Code + } // Attributes + } + ; + { // method at 0x012A + 0x0009; // access + #11; // name_index : m + #6; // descriptor_index : ()V + [3] { // Attributes + Attr(#9, 25) { // Code at 0x0132 + 0; // max_stack + 0; // max_locals + Bytes[1]{ + 0xB1; + } + [0] { // Traps + } // end Traps + [1] { // Attributes + Attr(#10, 6) { // LineNumberTable at 0x0145 + [1] { // line_number_table + 0 4; // at 0x0151 + } + } // end LineNumberTable + } // Attributes + } // end Code + ; + Attr(#12, 0) { // Deprecated at 0x0151 + } // end Deprecated + ; + Attr(#13, 16) { // RuntimeVisibleAnnotations at 0x0157 + [1] { // annotations + { // annotation + #14; + [2] { // element_value_pairs + { // element value pair + #17; + { // element_value + 's'; + #18; + } // element_value + } // element value pair + ; + { // element value pair + #15; + { // element_value + 'Z'; + #1600; // Changed from #16 to #1600 + } // element_value + } // element value pair + } // element_value_pairs + } // annotation + } + } // end RuntimeVisibleAnnotations + } // Attributes + } + } // Methods + + [1] { // Attributes + Attr(#19, 2) { // SourceFile at 0x016F + #20; + } // end SourceFile + } // Attributes +} // end class BadDeprecatedForRemovalBadCPIndex diff --git a/test/hotspot/jtreg/runtime/Annotations/BadDeprecatedForRemovalWrongType.jcod b/test/hotspot/jtreg/runtime/Annotations/BadDeprecatedForRemovalWrongType.jcod new file mode 100644 index 00000000000..9a2a536d664 --- /dev/null +++ b/test/hotspot/jtreg/runtime/Annotations/BadDeprecatedForRemovalWrongType.jcod @@ -0,0 +1,155 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* Based on source: + * + * public class DeprecatedMethod { + * @Deprecated(forRemoval=true, since="now") + * public static void m() {} + * } + * + * We change the type of forRemoval from 'Z' to 's' but don't change the value + */ + +class BadDeprecatedForRemovalWrongType { + 0xCAFEBABE; + 0; // minor version + 65; // version + [21] { // Constant Pool + ; // first element is empty + Method #2 #3; // #1 at 0x0A + class #4; // #2 at 0x0F + NameAndType #5 #6; // #3 at 0x12 + Utf8 "java/lang/Object"; // #4 at 0x17 + Utf8 ""; // #5 at 0x2A + Utf8 "()V"; // #6 at 0x33 + class #8; // #7 at 0x39 + Utf8 "BadDeprecatedForRemovalWrongType"; // #8 at 0x3C + Utf8 "Code"; // #9 at 0x4F + Utf8 "LineNumberTable"; // #10 at 0x56 + Utf8 "m"; // #11 at 0x68 + Utf8 "Deprecated"; // #12 at 0x6C + Utf8 "RuntimeVisibleAnnotations"; // #13 at 0x79 + Utf8 "Ljava/lang/Deprecated;"; // #14 at 0x95 + Utf8 "forRemoval"; // #15 at 0xAE + int 0x00000001; // #16 at 0xBB + Utf8 "since"; // #17 at 0xC0 + Utf8 "now"; // #18 at 0xC8 + Utf8 "SourceFile"; // #19 at 0xCE + Utf8 "BadDeprecatedForRemovalWrongType.java"; // #20 at 0xDB + } // Constant Pool + + 0x0021; // access [ ACC_PUBLIC ACC_SUPER ] + #7;// this_cpx + #2;// super_cpx + + [0] { // Interfaces + } // Interfaces + + [0] { // Fields + } // Fields + + [2] { // Methods + { // method at 0xFF + 0x0001; // access + #5; // name_index : + #6; // descriptor_index : ()V + [1] { // Attributes + Attr(#9, 29) { // Code at 0x0107 + 1; // max_stack + 1; // max_locals + Bytes[5]{ + 0x2AB70001B1; + } + [0] { // Traps + } // end Traps + [1] { // Attributes + Attr(#10, 6) { // LineNumberTable at 0x011E + [1] { // line_number_table + 0 1; // at 0x012A + } + } // end LineNumberTable + } // Attributes + } // end Code + } // Attributes + } + ; + { // method at 0x012A + 0x0009; // access + #11; // name_index : m + #6; // descriptor_index : ()V + [3] { // Attributes + Attr(#9, 25) { // Code at 0x0132 + 0; // max_stack + 0; // max_locals + Bytes[1]{ + 0xB1; + } + [0] { // Traps + } // end Traps + [1] { // Attributes + Attr(#10, 6) { // LineNumberTable at 0x0145 + [1] { // line_number_table + 0 4; // at 0x0151 + } + } // end LineNumberTable + } // Attributes + } // end Code + ; + Attr(#12, 0) { // Deprecated at 0x0151 + } // end Deprecated + ; + Attr(#13, 16) { // RuntimeVisibleAnnotations at 0x0157 + [1] { // annotations + { // annotation + #14; + [2] { // element_value_pairs + { // element value pair + #17; + { // element_value + 's'; + #18; + } // element_value + } // element value pair + ; + { // element value pair + #15; + { // element_value + 's'; // Changed from Z to s + #16; + } // element_value + } // element value pair + } // element_value_pairs + } // annotation + } + } // end RuntimeVisibleAnnotations + } // Attributes + } + } // Methods + + [1] { // Attributes + Attr(#19, 2) { // SourceFile at 0x016F + #20; + } // end SourceFile + } // Attributes +} // end class BadDeprecatedForRemovalWrongType diff --git a/test/hotspot/jtreg/runtime/Annotations/BadDeprecatedSinceWrongType.jcod b/test/hotspot/jtreg/runtime/Annotations/BadDeprecatedSinceWrongType.jcod new file mode 100644 index 00000000000..85863ea3b86 --- /dev/null +++ b/test/hotspot/jtreg/runtime/Annotations/BadDeprecatedSinceWrongType.jcod @@ -0,0 +1,155 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* Based on source: + * + * public class DeprecatedMethod { + * @Deprecated(forRemoval=true, since="now") + * public static void m() {} + * } + * + * We change the type of since from 's' to 'Z' + */ + +class BadDeprecatedSinceWrongType { + 0xCAFEBABE; + 0; // minor version + 65; // version + [21] { // Constant Pool + ; // first element is empty + Method #2 #3; // #1 at 0x0A + class #4; // #2 at 0x0F + NameAndType #5 #6; // #3 at 0x12 + Utf8 "java/lang/Object"; // #4 at 0x17 + Utf8 ""; // #5 at 0x2A + Utf8 "()V"; // #6 at 0x33 + class #8; // #7 at 0x39 + Utf8 "BadDeprecatedSinceWrongType"; // #8 at 0x3C + Utf8 "Code"; // #9 at 0x4F + Utf8 "LineNumberTable"; // #10 at 0x56 + Utf8 "m"; // #11 at 0x68 + Utf8 "Deprecated"; // #12 at 0x6C + Utf8 "RuntimeVisibleAnnotations"; // #13 at 0x79 + Utf8 "Ljava/lang/Deprecated;"; // #14 at 0x95 + Utf8 "forRemoval"; // #15 at 0xAE + int 0x00000001; // #16 at 0xBB + Utf8 "since"; // #17 at 0xC0 + Utf8 "now"; // #18 at 0xC8 + Utf8 "SourceFile"; // #19 at 0xCE + Utf8 "BadDeprecatedSinceWrongType.java"; // #20 at 0xDB + } // Constant Pool + + 0x0021; // access [ ACC_PUBLIC ACC_SUPER ] + #7;// this_cpx + #2;// super_cpx + + [0] { // Interfaces + } // Interfaces + + [0] { // Fields + } // Fields + + [2] { // Methods + { // method at 0xFF + 0x0001; // access + #5; // name_index : + #6; // descriptor_index : ()V + [1] { // Attributes + Attr(#9, 29) { // Code at 0x0107 + 1; // max_stack + 1; // max_locals + Bytes[5]{ + 0x2AB70001B1; + } + [0] { // Traps + } // end Traps + [1] { // Attributes + Attr(#10, 6) { // LineNumberTable at 0x011E + [1] { // line_number_table + 0 1; // at 0x012A + } + } // end LineNumberTable + } // Attributes + } // end Code + } // Attributes + } + ; + { // method at 0x012A + 0x0009; // access + #11; // name_index : m + #6; // descriptor_index : ()V + [3] { // Attributes + Attr(#9, 25) { // Code at 0x0132 + 0; // max_stack + 0; // max_locals + Bytes[1]{ + 0xB1; + } + [0] { // Traps + } // end Traps + [1] { // Attributes + Attr(#10, 6) { // LineNumberTable at 0x0145 + [1] { // line_number_table + 0 4; // at 0x0151 + } + } // end LineNumberTable + } // Attributes + } // end Code + ; + Attr(#12, 0) { // Deprecated at 0x0151 + } // end Deprecated + ; + Attr(#13, 16) { // RuntimeVisibleAnnotations at 0x0157 + [1] { // annotations + { // annotation + #14; + [2] { // element_value_pairs + { // element value pair + #17; + { // element_value + 'Z'; // Changed from 's' to 'Z' + #18; + } // element_value + } // element value pair + ; + { // element value pair + #15; + { // element_value + 'Z'; + #16; + } // element_value + } // element value pair + } // element_value_pairs + } // annotation + } + } // end RuntimeVisibleAnnotations + } // Attributes + } + } // Methods + + [1] { // Attributes + Attr(#19, 2) { // SourceFile at 0x016F + #20; + } // end SourceFile + } // Attributes +} // end class BadDeprecatedSinceWrongType diff --git a/test/hotspot/jtreg/runtime/Annotations/TestBadAnnotations.java b/test/hotspot/jtreg/runtime/Annotations/TestBadAnnotations.java new file mode 100644 index 00000000000..6617858d61b --- /dev/null +++ b/test/hotspot/jtreg/runtime/Annotations/TestBadAnnotations.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8339192 + * @summary Check that malformed annotations don't cause crashes + * @compile BadDeprecatedExtraMemberAtEnd.jcod + * BadDeprecatedExtraMemberAtStart.jcod + * BadDeprecatedSinceWrongType.jcod + * BadDeprecatedForRemovalWrongType.jcod + * BadDeprecatedForRemovalBadCPIndex.jcod + * BadContendedGroupBadCPIndex.jcod + * BadContendedGroupWrongType.jcod + * @modules java.base/jdk.internal.vm.annotation + * @run main/othervm -XX:-RestrictContended TestBadAnnotations + */ +import java.lang.annotation.Annotation; +import java.lang.reflect.*; + +// None of the malformed nnotations should cause assertion failures or +// other crashes, nor exceptions - we simply don't process them. Note that +// even if the annotation is malformed the class will still be marked as having +// that annotation; it is only the "forRemoval" state of @Deprecated, and +// the "group" value of @Contended that is potentially afffected. +// There is no API to query what annotations the VM considers applied +// to a class/field/method, so we don't try to read anything back. + +// The testcases defined reflect the changes that were made to the code under +// 8339192 - we do not try to define exhaustive tests for every potential +// malformation. Each of these test case will trigger an assert prior to +// the fix. + +public class TestBadAnnotations { + public static void main(String[] args) throws Throwable { + Class c = Class.forName("BadDeprecatedExtraMemberAtEnd"); + c = Class.forName("BadDeprecatedExtraMemberAtStart"); + c = Class.forName("BadDeprecatedSinceWrongType"); + c = Class.forName("BadDeprecatedForRemovalWrongType"); + c = Class.forName("BadDeprecatedForRemovalBadCPIndex"); + c = Class.forName("BadContendedGroupBadCPIndex"); + c = Class.forName("BadContendedGroupWrongType"); + } +} diff --git a/test/hotspot/jtreg/runtime/CommandLine/VMOptionWarning.java b/test/hotspot/jtreg/runtime/CommandLine/VMOptionWarning.java index aaee80169eb..90b309069ac 100644 --- a/test/hotspot/jtreg/runtime/CommandLine/VMOptionWarning.java +++ b/test/hotspot/jtreg/runtime/CommandLine/VMOptionWarning.java @@ -22,14 +22,37 @@ */ /* - * @test + * @test VMOptionWarningExperimental * @bug 8027314 - * @summary Warn if diagnostic or experimental vm option is used and -XX:+UnlockDiagnosticVMOptions or -XX:+UnlockExperimentalVMOptions, respectively, isn't specified. Warn if develop vm option is used with product version of VM. + * @summary Warn if experimental vm option is used and -XX:+UnlockExperimentalVMOptions isn't specified. * @requires vm.flagless + * @requires ! vm.opt.final.UnlockExperimentalVMOptions * @library /test/lib * @modules java.base/jdk.internal.misc * java.management - * @run driver VMOptionWarning + * @run driver VMOptionWarning Experimental + */ + +/* @test VMOptionWarningDiagnostic + * @bug 8027314 + * @summary Warn if diagnostic vm option is used and -XX:+UnlockDiagnosticVMOptions isn't specified. + * @requires vm.flagless + * @requires ! vm.debug + * @library /test/lib + * @modules java.base/jdk.internal.misc + * java.management + * @run driver VMOptionWarning Diagnostic + */ + +/* @test VMOptionWarningDevelop + * @bug 8027314 + * @summary Warn if develop vm option is used with product version of VM. + * @requires vm.flagless + * @requires ! vm.debug + * @library /test/lib + * @modules java.base/jdk.internal.misc + * java.management + * @run driver VMOptionWarning Develop */ import jdk.test.lib.process.ProcessTools; @@ -38,24 +61,37 @@ import jdk.test.lib.Platform; public class VMOptionWarning { public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+AlwaysSafeConstructors", "-version"); - OutputAnalyzer output = new OutputAnalyzer(pb.start()); - output.shouldNotHaveExitValue(0); - output.shouldContain("Error: VM option 'AlwaysSafeConstructors' is experimental and must be enabled via -XX:+UnlockExperimentalVMOptions."); - - if (Platform.isDebugBuild()) { - System.out.println("Skip the rest of the tests on debug builds since diagnostic, and develop options are available on debug builds."); - return; + if (args.length != 1) { + throw new RuntimeException("wrong number of args: " + args.length); } - pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+PrintInlining", "-version"); - output = new OutputAnalyzer(pb.start()); - output.shouldNotHaveExitValue(0); - output.shouldContain("Error: VM option 'PrintInlining' is diagnostic and must be enabled via -XX:+UnlockDiagnosticVMOptions."); - - pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+VerifyStack", "-version"); - output = new OutputAnalyzer(pb.start()); - output.shouldNotHaveExitValue(0); - output.shouldContain("Error: VM option 'VerifyStack' is develop and is available only in debug version of VM."); + ProcessBuilder pb; + OutputAnalyzer output; + switch (args[0]) { + case "Experimental": { + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+AlwaysSafeConstructors", "-version"); + output = new OutputAnalyzer(pb.start()); + output.shouldNotHaveExitValue(0); + output.shouldContain("Error: VM option 'AlwaysSafeConstructors' is experimental and must be enabled via -XX:+UnlockExperimentalVMOptions."); + break; + } + case "Diagnostic": { + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+PrintInlining", "-version"); + output = new OutputAnalyzer(pb.start()); + output.shouldNotHaveExitValue(0); + output.shouldContain("Error: VM option 'PrintInlining' is diagnostic and must be enabled via -XX:+UnlockDiagnosticVMOptions."); + break; + } + case "Develop": { + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+VerifyStack", "-version"); + output = new OutputAnalyzer(pb.start()); + output.shouldNotHaveExitValue(0); + output.shouldContain("Error: VM option 'VerifyStack' is develop and is available only in debug version of VM."); + break; + } + default: { + throw new RuntimeException("Invalid argument: " + args[0]); + } + } } } diff --git a/test/hotspot/jtreg/runtime/ErrorHandling/TestDwarf.java b/test/hotspot/jtreg/runtime/ErrorHandling/TestDwarf.java index 80ded6f898d..00b5becdbfa 100644 --- a/test/hotspot/jtreg/runtime/ErrorHandling/TestDwarf.java +++ b/test/hotspot/jtreg/runtime/ErrorHandling/TestDwarf.java @@ -22,7 +22,7 @@ */ /* - * @test id=checkDecoder + * @test * @bug 8242181 * @library / /test/lib * @summary Test DWARF parser with various crashes if debug symbols are available. If the libjvm debug symbols are not @@ -30,15 +30,7 @@ * by the environment variable _JVM_DWARF_PATH, then no verification of the hs_err_file is done for libjvm.so. * @requires vm.debug == true & vm.flagless & vm.compMode != "Xint" & os.family == "linux" & !vm.graal.enabled & vm.gc.G1 * @modules java.base/jdk.internal.misc - * @run main/native/othervm -Xbootclasspath/a:. -XX:-CreateCoredumpOnCrash -DcheckDecoder=true TestDwarf - */ - -/* - * @test id=dontCheckDecoder - * @library / /test/lib - * @requires vm.debug == true & vm.flagless & vm.compMode != "Xint" & os.family == "linux" & !vm.graal.enabled & vm.gc.G1 - * @modules java.base/jdk.internal.misc - * @run main/native/othervm -Xbootclasspath/a:. -XX:-CreateCoredumpOnCrash -DcheckDecoder=false TestDwarf + * @run main/native/othervm -Xbootclasspath/a:. -XX:-CreateCoredumpOnCrash TestDwarf */ import jdk.test.lib.Asserts; @@ -63,8 +55,6 @@ public class TestDwarf { System.loadLibrary("TestDwarf"); } - static boolean checkDecoder = Boolean.getBoolean("checkDecoder"); - public static void main(String[] args) throws Exception { if (args.length != 0) { switch (args[0]) { @@ -127,11 +117,11 @@ public class TestDwarf { new DwarfConstraint(0, "dereference_null", "libTestDwarfHelper.h", 46)); } - // The full pattern accepts lines like: + // A full pattern could check for lines like: // V [libjvm.so+0x8f4ed8] report_fatal(VMErrorType, char const*, int, char const*, ...)+0x78 (debug.cpp:212) - // but if the decoder is not available we only get + // but the decoder is not reliably working at the moment (see JDK-8305489). We therefore use a pattern that only + // checks that lines have the following structure with source information: // V [libjvm.so+0x8f4ed8] (debug.cpp:212) - private static final String FULL_PATTERN ="[CV][\\s\\t]+\\[([a-zA-Z0-9_.]+)\\+0x.+][\\s\\t]+.*\\+0x.+[\\s\\t]+\\([a-zA-Z0-9_.]+\\.[a-z]+:[1-9][0-9]*\\)"; private static final String NO_DECODER_PATTERN ="[CV][\\s\\t]+\\[([a-zA-Z0-9_.]+)\\+0x.+].*\\([a-zA-Z0-9_.]+\\.[a-z]+:[1-9][0-9]*\\)"; private static void runAndCheck(Flags flags, DwarfConstraint... constraints) throws Exception { @@ -149,7 +139,7 @@ public class TestDwarf { int matches = 0; int frameIdx = 0; - Pattern pattern = Pattern.compile(checkDecoder ? FULL_PATTERN : NO_DECODER_PATTERN); + Pattern pattern = Pattern.compile(NO_DECODER_PATTERN); // Check all stack entries after the line starting with "Native frames" in the hs_err_file until an empty line // is found which denotes the end of the stack frames. @@ -202,14 +192,6 @@ public class TestDwarf { pattern = Pattern.compile("Failed to load DWARF file for library.*" + library + ".*or find DWARF sections directly inside it"); matcher = pattern.matcher(crashOutputString); if (!matcher.find()) { - // Symbols were fine so check if we expected decoder output and didn't find it. - if (checkDecoder) { - pattern = Pattern.compile(NO_DECODER_PATTERN); - matcher = pattern.matcher(line); - if (matcher.find()) { - Asserts.fail("Could not find decoded method signature in \"" + line + "\""); - } - } bailoutIfUnsupportedDwarfVersion(crashOutputString); Asserts.fail("Could not find filename or line number in \"" + line + "\""); } diff --git a/test/hotspot/jtreg/runtime/FieldLayout/TestFieldLayout.java b/test/hotspot/jtreg/runtime/FieldLayout/TestFieldLayout.java new file mode 100644 index 00000000000..4066d6dd743 --- /dev/null +++ b/test/hotspot/jtreg/runtime/FieldLayout/TestFieldLayout.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2024, Arm Limited. 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 java.lang.reflect.Field; +import jdk.internal.misc.Unsafe; + +/* + * @test + * @bug 8341471 + * @summary Reversed field layout caused by unstable sorting + * @modules java.base/jdk.internal.misc + * @run main/othervm TestFieldLayout + */ + +public class TestFieldLayout { + + private static final Unsafe U = Unsafe.getUnsafe(); + + public static void main(String[] args) throws Exception { + + boolean endResult = true; + long previous = 0; + + for (Field f : Test.class.getDeclaredFields()) { + long current = U.objectFieldOffset(f); + if (current < previous) { + System.out.printf("FAILED: field %s offset %d previous %d\n", + f.getName(), current, previous); + endResult = false; + } + previous = current; + } + + System.out.println(endResult ? "Test PASSES" : "Test FAILS"); + if (!endResult) { + throw new Error("Test failed"); + } + } + + public class Test { + char a000; + char a001; + char a002; + char a003; + char a004; + char a005; + char a006; + char a007; + char a008; + char a009; + char a00a; + char a00b; + } + +} + diff --git a/test/hotspot/jtreg/runtime/Thread/TestAlwaysPreTouchStacks.java b/test/hotspot/jtreg/runtime/Thread/TestAlwaysPreTouchStacks.java index f16e0ff9da4..d47a07d2dec 100644 --- a/test/hotspot/jtreg/runtime/Thread/TestAlwaysPreTouchStacks.java +++ b/test/hotspot/jtreg/runtime/Thread/TestAlwaysPreTouchStacks.java @@ -36,7 +36,7 @@ import static jdk.test.lib.Platform.isLinux; import static jdk.test.lib.Platform.isWindows; /* - * @test id=preTouch + * @test id=preTouchTest * @summary Test AlwaysPreTouchThreadStacks * @requires os.family != "aix" * @library /test/lib @@ -45,23 +45,16 @@ import static jdk.test.lib.Platform.isWindows; * @run driver TestAlwaysPreTouchStacks preTouch */ -/* - * @test id=noPreTouch - * @summary Test that only touched committed memory is reported as thread stack usage. - * @requires os.family != "aix" - * @library /test/lib - * @modules java.base/jdk.internal.misc - * java.management - * @run driver TestAlwaysPreTouchStacks noPreTouch - */ - public class TestAlwaysPreTouchStacks { // We will create a bunch of large-stacked threads to make a significant imprint on combined thread stack size - final static int MB = 1024*1024; + final static int MB = 1024 * 1024; static int memoryCeilingMB = 128; static int threadStackSizeMB = 8; static int numThreads = memoryCeilingMB / threadStackSizeMB; + static long min_stack_usage_with_pretouch = 1 * MB; + static long max_stack_usage_with_pretouch = (long)(0.75 * threadStackSizeMB * MB); + static CyclicBarrier gate = new CyclicBarrier(numThreads + 1); static private final Thread createTestThread(int num) { @@ -79,10 +72,76 @@ public class TestAlwaysPreTouchStacks { } }, "TestThread-" + num, threadStackSizeMB * MB); + // Let test threads run as daemons to ensure that they are still running and + // that their stacks are still allocated when the JVM shuts down and the final + // NMT report is printed. t.setDaemon(true); return t; } + private static long runPreTouchTest(boolean preTouch) throws Exception { + long reserved = 0L, committed = 0L; + ArrayList vmArgs = new ArrayList<>(); + Collections.addAll(vmArgs, + "-XX:+UnlockDiagnosticVMOptions", + "-Xmx100M", + "-XX:NativeMemoryTracking=summary", "-XX:+PrintNMTStatistics"); + if (preTouch){ + vmArgs.add("-XX:+AlwaysPreTouchStacks"); + } + if (System.getProperty("os.name").contains("Linux")) { + vmArgs.add("-XX:-UseMadvPopulateWrite"); + } + Collections.addAll(vmArgs, "TestAlwaysPreTouchStacks", "test"); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(vmArgs); + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + + output.shouldHaveExitValue(0); + + for (int i = 0; i < numThreads; i++) { + output.shouldContain("Alive: " + i); + } + + // If using -XX:+AlwaysPreTouchStacks, we want to see, in the final NMT printout, + // a committed thread stack size very close to reserved stack size. Like this: + // - Thread (reserved=10332400KB, committed=10284360KB) + // (thread #10021) + // (stack: reserved=10301560KB, committed=10253520KB) <<<< + // + // ... without -XX:+AlwaysPreTouchStacks, the committed/reserved ratio for thread stacks should be + // a lot lower, e.g.: + // - Thread (reserved=10332400KB, committed=331828KB) + // (thread #10021) + // (stack: reserved=10301560KB, committed=300988KB) <<< + + output.shouldMatch("- *Thread.*reserved.*committed"); + output.reportDiagnosticSummary(); + Pattern pat = Pattern.compile(".*stack: reserved=(\\d+), committed=(\\d+).*"); + boolean foundLine = false; + for (String line : output.asLines()) { + Matcher m = pat.matcher(line); + if (m.matches()) { + reserved = Long.parseLong(m.group(1)); + committed = Long.parseLong(m.group(2)); + System.out.println(">>>>> " + line + ": " + reserved + " - " + committed); + // Added sanity tests: we expect our test threads to be still alive when NMT prints its final + // report, so their stacks should dominate the NMT-reported total stack size. + long max_reserved = memoryCeilingMB * 3 * MB; + long min_reserved = memoryCeilingMB * MB; + if (reserved >= max_reserved || reserved < min_reserved) { + throw new RuntimeException("Total reserved stack sizes outside of our expectations (" + reserved + + ", expected " + min_reserved + ".." + max_reserved + ")"); + } + foundLine = true; + break; + } + } + if (!foundLine) { + throw new RuntimeException("Did not find expected NMT output"); + } + return committed; + } + public static void main(String[] args) throws Exception { if (args.length == 1 && args[0].equals("test")) { @@ -103,83 +162,23 @@ public class TestAlwaysPreTouchStacks { // should show up with fully - or almost fully - committed thread stacks. } else { - boolean preTouch; - if (args.length == 1 && args[0].equals("noPreTouch")){ - preTouch = false; - } else if (args.length == 1 && args[0].equals("preTouch")){ - preTouch = true; - } else { - throw new RuntimeException("Invalid test input. Must be 'preTouch' or 'noPreTouch'."); - } - ArrayList vmArgs = new ArrayList<>(); - Collections.addAll(vmArgs, - "-XX:+UnlockDiagnosticVMOptions", - "-Xmx100M", - "-XX:NativeMemoryTracking=summary", "-XX:+PrintNMTStatistics"); - if (preTouch){ - vmArgs.add("-XX:+AlwaysPreTouchStacks"); - } - if (System.getProperty("os.name").contains("Linux")) { - vmArgs.add("-XX:-UseMadvPopulateWrite"); - } - Collections.addAll(vmArgs, "TestAlwaysPreTouchStacks", "test"); - ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(vmArgs); - OutputAnalyzer output = new OutputAnalyzer(pb.start()); - output.reportDiagnosticSummary(); - - output.shouldHaveExitValue(0); - - for (int i = 0; i < numThreads; i++) { - output.shouldContain("Alive: " + i); - } - - // If using -XX:+AlwaysPreTouchStacks, we want to see, in the final NMT printout, - // a committed thread stack size very close to reserved stack size. Like this: - // - Thread (reserved=10332400KB, committed=10284360KB) - // (thread #10021) - // (stack: reserved=10301560KB, committed=10253520KB) <<<< - // - // ... without -XX:+AlwaysPreTouchStacks, the committed/reserved ratio for thread stacks should be - // a lot lower, e.g.: - // - Thread (reserved=10332400KB, committed=331828KB) - // (thread #10021) - // (stack: reserved=10301560KB, committed=300988KB) <<< - - output.shouldMatch("- *Thread.*reserved.*committed"); - Pattern pat = Pattern.compile(".*stack: reserved=(\\d+), committed=(\\d+).*"); - boolean foundLine = false; - for (String line : output.asLines()) { - Matcher m = pat.matcher(line); - if (m.matches()) { - long reserved = Long.parseLong(m.group(1)); - long committed = Long.parseLong(m.group(2)); - System.out.println(">>>>> " + line + ": " + reserved + " - " + committed); - // This is a bit fuzzy: even with PreTouch we don't commit the full range of what NMT counts - // as thread stack. But without pre-touching, the thread stacks would be committed to about 1/5th - // of their reserved size. Requiring them to be committed for over 3/4th shows that pretouch is - // really working. - if (preTouch && (double)committed < ((double)reserved * 0.75)) { - throw new RuntimeException("Expected a higher ratio between stack committed and reserved."); - } else if (!preTouch && (double)committed > ((double)reserved * 0.50)){ - throw new RuntimeException("Expected a lower ratio between stack committed and reserved."); - } - // Added sanity tests: we expect our test threads to be still alive when NMT prints its final - // report, so their stacks should dominate the NMT-reported total stack size. - long max_reserved = memoryCeilingMB * 3 * MB; - long min_reserved = memoryCeilingMB * MB; - if (reserved >= max_reserved || reserved < min_reserved) { - throw new RuntimeException("Total reserved stack sizes outside of our expectations (" + reserved + - ", expected " + min_reserved + ".." + max_reserved + ")"); - } - foundLine = true; - break; - } - } - if (!foundLine) { - throw new RuntimeException("Did not find expected NMT output"); - } - } - + long pretouch_committed = runPreTouchTest(true); + long no_pretouch_committed = runPreTouchTest(false); + if (pretouch_committed == 0 || no_pretouch_committed == 0) { + throw new RuntimeException("Could not run with PreTouch flag."); + } + long expected_delta = numThreads * (max_stack_usage_with_pretouch - min_stack_usage_with_pretouch); + long actual_delta = pretouch_committed - no_pretouch_committed; + if (pretouch_committed <= (no_pretouch_committed + expected_delta)) { + throw new RuntimeException("Expected a higher amount of committed with pretouch stacks" + + "PreTouch amount: " + pretouch_committed + + "NoPreTouch amount: " + (no_pretouch_committed + expected_delta)); + } + if (actual_delta < expected_delta) { + throw new RuntimeException("Expected a higher delta between stack committed of with and without pretouch." + + "Expected: " + expected_delta + " Actual: " + actual_delta); + } + } } } diff --git a/test/hotspot/jtreg/runtime/Unsafe/InternalErrorTest.java b/test/hotspot/jtreg/runtime/Unsafe/InternalErrorTest.java index fcf48a7a2d7..01b051af8e5 100644 --- a/test/hotspot/jtreg/runtime/Unsafe/InternalErrorTest.java +++ b/test/hotspot/jtreg/runtime/Unsafe/InternalErrorTest.java @@ -147,7 +147,8 @@ public class InternalErrorTest { break; case 1: // testing Unsafe.copySwapMemory, trying to access next page after truncation. - unsafe.copySwapMemory(null, mapAddr + pageSize, new byte[4000], 16, 2000, 2); + int destOffset = Unsafe.ARRAY_BYTE_BASE_OFFSET; + unsafe.copySwapMemory(null, mapAddr + pageSize, new byte[4000], destOffset, 2000, 2); break; case 2: // testing Unsafe.copySwapMemory, trying to access next page after truncation. diff --git a/test/hotspot/jtreg/runtime/cds/appcds/ClassPathAttr.java b/test/hotspot/jtreg/runtime/cds/appcds/ClassPathAttr.java index f0d797c09ae..fe618256f65 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/ClassPathAttr.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/ClassPathAttr.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,9 +27,11 @@ * @summary Class-Path: attribute in MANIFEST file * @requires vm.cds * @library /test/lib + * @compile test-classes/Hello.java * @run driver/timeout=240 ClassPathAttr */ +import jdk.test.lib.Platform; import jdk.test.lib.cds.CDSTestUtils; import jdk.test.lib.process.OutputAnalyzer; import java.io.File; @@ -44,6 +46,7 @@ public class ClassPathAttr { public static void main(String[] args) throws Exception { testNormalOps(); testNonExistentJars(); + testClassPathAttrJarOnCP(); } static void testNormalOps() throws Exception { @@ -82,6 +85,76 @@ public class ClassPathAttr { output.shouldMatch("checking shared classpath entry: .*cpattr2.jar"); output.shouldMatch("checking shared classpath entry: .*cpattr3.jar"); }); + + // Test handling of forward slash ('/') file separator when locating entries + // in the classpath entry on Windows. + // Skip the following test when CDS dynamic dump is enabled due to some + // issue when converting a relative path to real path. + if (Platform.isWindows() && !CDSTestUtils.DYNAMIC_DUMP) { + // Test with relative path + // Find the index to the dir before the jar file. + int idx = jar1.lastIndexOf(File.separator); + idx = jar1.substring(0, idx - 1).lastIndexOf(File.separator); + // Setup jar directory and names. + String jarDir = jar1.substring(0, idx); + String jar1Name = jar1.substring(idx + 1); + String jar4Name = jar4.substring(idx + 1); + String newCp = jar1Name.replace("\\", "/") + File.pathSeparator + jar4Name.replace("\\", "/"); + + OutputAnalyzer out = TestCommon.testDump(jarDir, newCp, classlist, "-Xlog:class+path=info"); + if (i == 1) { + out.shouldMatch("opened:.*cpattr1.jar"); // first jar on -cp + } else { + // first jar on -cp with long Class-Path: attribute + out.shouldMatch("opened:.*cpattr1_long.jar"); + } + // one of the jar in the Class-Path: attribute of cpattr1.jar + out.shouldMatch("opened:.*cpattr2.jar"); + + TestCommon.runWithRelativePath( + jarDir.replace("\\", "/"), + "-Xlog:class+path,class+load", + "-cp", newCp, + "CpAttr1") + .assertNormalExit(output -> { + output.shouldMatch("checking shared classpath entry: .*cpattr2.jar"); + output.shouldMatch("checking shared classpath entry: .*cpattr3.jar"); + }); + + // Go one directory up. + int idx2 = jar1.substring(0, idx - 1).lastIndexOf(File.separator); + if (idx2 != -1) { + // Setup jar directory and names. + jarDir = jar1.substring(0, idx2); + // Set relative path to jar containing '\' and '/' file separators + // e.g. d1\d2/A.jar + jar1Name = jar1.substring(idx2 + 1).replace("\\", "/"); + jar4Name = jar4.substring(idx2 + 1).replace("\\", "/"); + jar1Name = jar1Name.replaceFirst("/", "\\\\"); + jar4Name = jar4Name.replaceFirst("/", "\\\\"); + + newCp = jar1Name + File.pathSeparator + jar4Name; + out = TestCommon.testDump(jarDir, newCp, classlist, "-Xlog:class+path=info"); + if (i == 1) { + out.shouldMatch("opened:.*cpattr1.jar"); // first jar on -cp + } else { + // first jar on -cp with long Class-Path: attribute + out.shouldMatch("opened:.*cpattr1_long.jar"); + } + // one of the jar in the Class-Path: attribute of cpattr1.jar + out.shouldMatch("opened:.*cpattr2.jar"); + + TestCommon.runWithRelativePath( + jarDir.replace("\\", "/"), + "-Xlog:class+path,class+load", + "-cp", newCp, + "CpAttr1") + .assertNormalExit(output -> { + output.shouldMatch("checking shared classpath entry: .*cpattr2.jar"); + output.shouldMatch("checking shared classpath entry: .*cpattr3.jar"); + }); + } + } } // test duplicate jars in the "Class-path" attribute in the jar manifest @@ -126,6 +199,62 @@ public class ClassPathAttr { }); } + static void testClassPathAttrJarOnCP() throws Exception { + String helloJar = JarBuilder.getOrCreateHelloJar(); + String jar1 = TestCommon.getTestJar("cpattr1.jar"); + String cp = jar1 + File.pathSeparator + helloJar; + + // The cpattr1.jar contains "Class-Path: cpattr2.jar". + // The cpattr2.jar contains "Class-Path: cpattr3.jar cpattr5_123456789_223456789_323456789_42345678.jar". + // With -cp cpattr1:hello.jar, the following shared paths should be stored in the CDS archive: + // cpattr1.jar:cpattr2.jar:cpattr3.jar:cpattr5_123456789_223456789_323456789_42345678.jari:hello.jar + TestCommon.testDump(cp, TestCommon.list("Hello"), "-Xlog:class+path"); + + // Run with the same -cp apattr1.jar:hello.jar. The Hello class should be + // loaded from the archive. + TestCommon.run("-Xlog:class+path,class+load", + "-cp", cp, + "Hello") + .assertNormalExit(output -> { + output.shouldContain("Hello source: shared objects file"); + }); + + // Run with -cp apattr1.jar:cpattr2.jar:hello.jar. App classpath mismatch should be detected. + String jar2 = TestCommon.getTestJar("cpattr2.jar"); + cp = jar1 + File.pathSeparator + jar2 + File.pathSeparator + helloJar; + TestCommon.run("-Xlog:class+path,class+load", + "-cp", cp, + "Hello") + .assertAbnormalExit(output -> { + output.shouldMatch(".*APP classpath mismatch, actual: -Djava.class.path=.*cpattr1.jar.*cpattr2.jar.*hello.jar") + .shouldContain("Unable to use shared archive."); + }); + + // Run with different -cp cpattr2.jar:hello.jar. App classpath mismatch should be detected. + cp = jar2 + File.pathSeparator + helloJar; + TestCommon.run("-Xlog:class+path,class+load", + "-cp", cp, + "Hello") + .assertAbnormalExit(output -> { + output.shouldMatch(".*APP classpath mismatch, actual: -Djava.class.path=.*cpattr2.jar.*hello.jar") + .shouldContain("Unable to use shared archive."); + }); + + // Dumping with -cp cpattr1.jar:cpattr2.jar:hello.jar + // The cpattr2.jar is from the Class-Path: attribute of cpattr1.jar. + cp = jar1 + File.pathSeparator + jar2 + File.pathSeparator + helloJar; + TestCommon.testDump(cp, TestCommon.list("Hello"), "-Xlog:class+path"); + + // Run with the same -cp as dump time. The Hello class should be loaded from the archive. + TestCommon.run("-Xlog:class+path,class+load", + "-cp", cp, + "Hello") + .assertNormalExit(output -> { + output.shouldContain("Hello source: shared objects file"); + }); + + } + private static void buildCpAttr(String jarName, String manifest, String enclosingClassName, String ...testClassNames) throws Exception { String jarClassesDir = CDSTestUtils.getOutputDir() + File.separator + jarName + "_classes"; try { Files.createDirectory(Paths.get(jarClassesDir)); } catch (FileAlreadyExistsException e) { } diff --git a/test/hotspot/jtreg/runtime/cds/appcds/DumpRuntimeClassesTest.java b/test/hotspot/jtreg/runtime/cds/appcds/DumpRuntimeClassesTest.java new file mode 100644 index 00000000000..2e530a8d6dd --- /dev/null +++ b/test/hotspot/jtreg/runtime/cds/appcds/DumpRuntimeClassesTest.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +/* + * @test + * @summary Classes used by CDS at runtime should be in the archived + * @bug 8324259 + * @requires vm.cds + * @library /test/lib + * @compile test-classes/Hello.java + * @run driver DumpRuntimeClassesTest + */ + +import jdk.test.lib.cds.CDSOptions; +import jdk.test.lib.cds.CDSTestUtils; + +public class DumpRuntimeClassesTest { + public static void main(String[] args) throws Exception { + // build The app + String appClass = "Hello"; + String classList = "hello.classlist"; + String archiveName = "hello.jsa"; + JarBuilder.build("hello", appClass); + String appJar = TestCommon.getTestJar("hello.jar"); + + // Dump class list + CDSTestUtils.dumpClassList(classList, "-cp", appJar, appClass); + + // Dump archive + CDSOptions opts = (new CDSOptions()) + .addPrefix("-cp", appJar, "-XX:SharedClassListFile=" + classList) + .setArchiveName(archiveName); + CDSTestUtils.createArchive(opts); + + // Run with archive and ensure all the classes used were in the archive + CDSOptions runOpts = (new CDSOptions()) + .addPrefix("-cp", appJar, "-Xlog:class+load,cds=debug") + .setArchiveName(archiveName) + .setUseVersion(false) + .addSuffix(appClass); + CDSTestUtils.runWithArchive(runOpts) + .shouldNotContain("source: jrt:/java.base"); + } +} diff --git a/test/hotspot/jtreg/runtime/cds/appcds/StaticArchiveWithLambda.java b/test/hotspot/jtreg/runtime/cds/appcds/StaticArchiveWithLambda.java index 67530467cf8..9bab98a5d2c 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/StaticArchiveWithLambda.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/StaticArchiveWithLambda.java @@ -52,7 +52,8 @@ public class StaticArchiveWithLambda { "-cp", appJar, "-Xlog:class+load,cds") .setArchiveName(archiveName); - CDSTestUtils.createArchiveAndCheck(opts); + CDSTestUtils.createArchiveAndCheck(opts) + .shouldContain("Skipping java/lang/invoke/BoundMethodHandle$Species_LLLL because it is dynamically generated"); // run with archive CDSOptions runOpts = (new CDSOptions()) diff --git a/test/hotspot/jtreg/runtime/cds/appcds/complexURI/ComplexURITest.java b/test/hotspot/jtreg/runtime/cds/appcds/complexURI/ComplexURITest.java new file mode 100644 index 00000000000..409e37e10a1 --- /dev/null +++ b/test/hotspot/jtreg/runtime/cds/appcds/complexURI/ComplexURITest.java @@ -0,0 +1,167 @@ +/* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024 JetBrains s.r.o. + * 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 + * @summary Verifies that CDS works with jar located in directories + * with names that need escaping + * @bug 8339460 + * @requires vm.cds + * @requires vm.cds.custom.loaders + * @requires vm.flagless + * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds + * @compile mypackage/Main.java mypackage/Another.java + * @run main/othervm ComplexURITest + */ + +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; +import jdk.test.lib.Platform; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; + +public class ComplexURITest { + final static String moduleName = "mymodule"; + + public static void main(String[] args) throws Exception { + System.setProperty("test.noclasspath", "true"); + String jarFile = JarBuilder.build(moduleName, "mypackage/Main", "mypackage/Another"); + + Path subDir = Path.of(".", "dir with space"); + Files.createDirectory(subDir); + Path newJarFilePath = subDir.resolve(moduleName + ".jar"); + Files.move(Path.of(jarFile), newJarFilePath); + jarFile = newJarFilePath.toString(); + + final String listFileName = "test-classlist.txt"; + final String staticArchiveName = "test-static.jsa"; + final String dynamicArchiveName = "test-dynamic.jsa"; + + // Verify static archive creation and use + File fileList = new File(listFileName); + delete(fileList.toPath()); + File staticArchive = new File(staticArchiveName); + delete(staticArchive.toPath()); + + createClassList(jarFile, listFileName); + if (!fileList.exists()) { + throw new RuntimeException("No class list created at " + fileList); + } + + createArchive(jarFile, listFileName, staticArchiveName); + if (!staticArchive.exists()) { + throw new RuntimeException("No shared classes archive created at " + staticArchive); + } + + useArchive(jarFile, staticArchiveName); + + // Verify dynamic archive creation and use + File dynamicArchive = new File(dynamicArchiveName); + delete(dynamicArchive.toPath()); + + createDynamicArchive(jarFile, dynamicArchiveName); + if (!dynamicArchive.exists()) { + throw new RuntimeException("No dynamic archive created at " + dynamicArchive); + } + + testDynamicArchive(jarFile, dynamicArchiveName); + } + + private static void delete(Path path) throws Exception { + if (Files.exists(path)) { + if (Platform.isWindows()) { + Files.setAttribute(path, "dos:readonly", false); + } + Files.delete(path); + } + } + + private static void createClassList(String jarFile, String list) throws Exception { + String[] launchArgs = { + "-XX:DumpLoadedClassList=" + list, + "--module-path", + jarFile, + "--module", + moduleName + "/mypackage.Main"}; + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(launchArgs); + OutputAnalyzer output = TestCommon.executeAndLog(pb, "create-list"); + output.shouldHaveExitValue(0); + } + + private static void createArchive(String jarFile, String list, String archive) throws Exception { + String[] launchArgs = { + "-Xshare:dump", + "-XX:SharedClassListFile=" + list, + "-XX:SharedArchiveFile=" + archive, + "--module-path", + jarFile, + "--module", + moduleName + "/mypackage.Main"}; + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(launchArgs); + OutputAnalyzer output = TestCommon.executeAndLog(pb, "dump-archive"); + output.shouldHaveExitValue(0); + } + + private static void useArchive(String jarFile, String archive) throws Exception { + String[] launchArgs = { + "-Xshare:on", + "-XX:SharedArchiveFile=" + archive, + "--module-path", + jarFile, + "--module", + moduleName + "/mypackage.Main"}; + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(launchArgs); + OutputAnalyzer output = TestCommon.executeAndLog(pb, "use-archive"); + output.shouldHaveExitValue(0); + } + + private static void createDynamicArchive(String jarFile, String archive) throws Exception { + String[] launchArgs = { + "-XX:ArchiveClassesAtExit=" + archive, + "--module-path", + jarFile, + "--module", + moduleName + "/mypackage.Main"}; + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(launchArgs); + OutputAnalyzer output = TestCommon.executeAndLog(pb, "dynamic-archive"); + output.shouldHaveExitValue(0); + } + + private static void testDynamicArchive(String jarFile, String archive) throws Exception { + String[] launchArgs = { + "-XX:SharedArchiveFile=" + archive, + "-XX:+PrintSharedArchiveAndExit", + "--module-path", + jarFile, + "--module", + moduleName + "/mypackage.Main"}; + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(launchArgs); + OutputAnalyzer output = TestCommon.executeAndLog(pb, "dynamic-archive"); + output.shouldHaveExitValue(0); + output.shouldContain("archive is valid"); + output.shouldContain(": mypackage.Main app_loader"); + output.shouldContain(": mypackage.Another unregistered_loader"); + } +} diff --git a/test/hotspot/jtreg/runtime/cds/appcds/complexURI/mypackage/Another.java b/test/hotspot/jtreg/runtime/cds/appcds/complexURI/mypackage/Another.java new file mode 100644 index 00000000000..106dfd4904c --- /dev/null +++ b/test/hotspot/jtreg/runtime/cds/appcds/complexURI/mypackage/Another.java @@ -0,0 +1,27 @@ +/* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024 JetBrains s.r.o. + * 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. + */ + +package mypackage; + +public class Another { +} diff --git a/test/hotspot/jtreg/runtime/cds/appcds/complexURI/mypackage/Main.java b/test/hotspot/jtreg/runtime/cds/appcds/complexURI/mypackage/Main.java new file mode 100644 index 00000000000..fdb79e895d2 --- /dev/null +++ b/test/hotspot/jtreg/runtime/cds/appcds/complexURI/mypackage/Main.java @@ -0,0 +1,37 @@ +/* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024 JetBrains s.r.o. + * 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. + */ + +package mypackage; + +import java.net.URL; +import java.net.URLClassLoader; + +public class Main { + public static void main(String[] args) throws Exception { + URL url1 = Main.class.getProtectionDomain().getCodeSource().getLocation(); + System.out.println("Will load Another from " + url1); + ClassLoader cl = URLClassLoader.newInstance(new URL[] { url1 }, null); + var anotherClass = cl.loadClass("mypackage.Another"); + System.out.println("Class " + anotherClass + " loaded successfully"); + } +} diff --git a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/MainModuleOnly.java b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/MainModuleOnly.java index 0dd4af2e450..e74229869ed 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/MainModuleOnly.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/MainModuleOnly.java @@ -213,8 +213,10 @@ public class MainModuleOnly extends DynamicArchiveTestBase { "-cp", destJar.toString(), "--module-path", MODS_DIR.toString(), "-m", TEST_MODULE1 + "/" + MAIN_CLASS) - .assertAbnormalExit(output -> { - output.shouldMatch("Error: non-empty directory.*com.simple"); + // After JDK-8328313, non-empty module path directory won't be included + // in the shared paths table. + .assertNormalExit(output -> { + output.shouldNotMatch("Error: non-empty directory.*com.simple"); }); // test module path with very long length diff --git a/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/modulepath/MainModuleOnly.java b/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/modulepath/MainModuleOnly.java index 50191b91e1e..ac9bb5adc00 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/modulepath/MainModuleOnly.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/modulepath/MainModuleOnly.java @@ -194,8 +194,10 @@ public class MainModuleOnly { output = TestCommon.createArchive(destJar.toString(), appClasses, "--module-path", MODS_DIR.toString(), "-m", mainModule); - output.shouldHaveExitValue(1) - .shouldMatch("Error: non-empty directory.*com.simple"); + // After JDK-8328313, non-empty module path directory won't be included + // in the shared paths table. + output.shouldHaveExitValue(0) + .shouldNotMatch("Error: non-empty directory.*com.simple"); // test module path with very long length // diff --git a/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/modulepath/ModulePathAndFMG.java b/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/modulepath/ModulePathAndFMG.java new file mode 100644 index 00000000000..fe777142046 --- /dev/null +++ b/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/modulepath/ModulePathAndFMG.java @@ -0,0 +1,385 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +/** + * @test + * @bug 8328313 + * @requires vm.cds & !vm.graal.enabled & vm.cds.write.archived.java.heap + * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds + * @run driver ModulePathAndFMG + * @summary test module path changes for full module graph handling. + * + */ + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; + +import jdk.test.lib.cds.CDSTestUtils; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; + +public class ModulePathAndFMG { + private static final String JAVA_HOME = System.getProperty("java.home"); + + private static final Path USER_DIR = Paths.get(CDSTestUtils.getOutputDir()); + + private static final String TEST_SRC = System.getProperty("test.src"); + + private static final Path SRC_DIR = Paths.get(TEST_SRC, "src"); + private static final Path MODS_DIR = Paths.get("mody"); + private static final Path JMOD_DIR = Paths.get("jmod_dir"); + + // the module name of the test module + private static final String MAIN_MODULE = "com.bars"; + private static final String TEST_MODULE = "com.foos"; + private static final String DUP_MODULE = "com.foos3"; + + // the module main class + private static final String MAIN_CLASS = "com.bars.Main"; + private static final String TEST_CLASS = "com.foos.Test"; + + private static String PATH_LIBS = "modylibs"; + private static String DUP_LIBS = "duplibs"; + private static Path libsDir = null; + private static Path dupDir = null; + private static Path jmodDir = null; + private static Path mainJar = null; + private static Path testJar = null; + private static Path dupJar = null; + private static Path badJar = null; + + private static String CLASS_FOUND_MESSAGE = "com.foos.Test found"; + private static String CLASS_NOT_FOUND_MESSAGE = "java.lang.ClassNotFoundException: com.foos.Test"; + private static String FIND_EXCEPTION_MESSAGE = "java.lang.module.FindException: Module com.foos not found, required by com.bars"; + private static String MODULE_NOT_RECOGNIZED = "Module format not recognized:.*modylibs.*com.bars.JAR"; + private static String OPTIMIZE_ENABLED = "] optimized module handling: enabled"; + private static String OPTIMIZE_DISABLED = "] optimized module handling: disabled"; + private static String FMG_ENABLED = "] full module graph: enabled"; + private static String FMG_DISABLED = "] full module graph: disabled"; + private static String MAIN_FROM_JAR = "class,load.*com.bars.Main.*[.]jar"; + private static String MAIN_FROM_CDS = "class,load.*com.bars.Main.*shared objects file"; + private static String MAIN_FROM_MODULE = "class,load.*com.bars.Main.*mody/com.bars"; + private static String TEST_FROM_JAR = "class,load.*com.foos.Test.*[.]jar"; + private static String TEST_FROM_CDS = "class,load.*com.foos.Test.*shared objects file"; + private static String MAP_FAILED = "Unable to use shared archive"; + private static String PATH_SEPARATOR = File.pathSeparator; + private static String appClasses[] = {MAIN_CLASS, TEST_CLASS}; + private static String prefix[] = {"-Djava.class.path=", "-Xlog:cds,class+load,class+path=info"}; + + public static void buildTestModule() throws Exception { + + // javac -d mods/$TESTMODULE src/$TESTMODULE/** + JarBuilder.compileModule(SRC_DIR.resolve(TEST_MODULE), + MODS_DIR.resolve(TEST_MODULE), + null); + + // javac -d mods/$TESTMODULE --module-path MOD_DIR src/$TESTMODULE/** + JarBuilder.compileModule(SRC_DIR.resolve(MAIN_MODULE), + MODS_DIR.resolve(MAIN_MODULE), + MODS_DIR.toString()); + + libsDir = Files.createTempDirectory(USER_DIR, PATH_LIBS); + mainJar = libsDir.resolve(MAIN_MODULE + ".jar"); + testJar = libsDir.resolve(TEST_MODULE + ".jar"); + + // modylibs contains both modules com.foos.jar, com.bars.jar + // build com.foos.jar + String classes = MODS_DIR.resolve(TEST_MODULE).toString(); + JarBuilder.createModularJar(testJar.toString(), classes, TEST_CLASS); + + // build com.bars.jar + classes = MODS_DIR.resolve(MAIN_MODULE).toString(); + JarBuilder.createModularJar(mainJar.toString(), classes, MAIN_CLASS); + + dupDir = Files.createTempDirectory(USER_DIR, DUP_LIBS); + dupJar = dupDir.resolve(DUP_MODULE + ".jar"); + Files.copy(testJar, dupJar, StandardCopyOption.REPLACE_EXISTING); + + badJar = libsDir.resolve(MAIN_MODULE + ".JAR"); + Files.copy(mainJar, badJar, StandardCopyOption.REPLACE_EXISTING); + } + + public static void buildJmod() throws Exception { + Path jmod = Paths.get(JAVA_HOME, "bin", "jmod"); + jmodDir = Files.createDirectory(Paths.get(USER_DIR.toString() + File.separator + JMOD_DIR.toString())); + OutputAnalyzer output = ProcessTools.executeProcess(jmod.toString(), + "create", + "--class-path", Paths.get(USER_DIR.toString(), MODS_DIR.toString(), TEST_MODULE).toString(), + "--module-version", "1.0", + "--main-class", TEST_CLASS, + jmodDir.toString() + File.separator + TEST_MODULE + ".jmod"); + output.shouldHaveExitValue(0); + } + + public static void main(String... args) throws Exception { + runWithModulePath(); + runWithExplodedModule(); + runWithJmodAndBadJar(); + } + + private static void tty(String... args) { + for (String s : args) { + System.out.print(s + " "); + } + System.out.print("\n"); + } + + public static void runWithModulePath() throws Exception { + // compile the modules and create the modular jar files + buildTestModule(); + // create an archive with the classes in the modules built in the + // previous step + OutputAnalyzer output = TestCommon.createArchive( + null, appClasses, + "--module-path", + libsDir.toString(), + "-m", MAIN_MODULE); + TestCommon.checkDump(output); + + tty("1. run with CDS on, with module path same as dump time"); + TestCommon.runWithModules(prefix, + null, // --upgrade-module-path + libsDir.toString(), // --module-path + MAIN_MODULE) // -m + .assertNormalExit(out -> { + out.shouldNotContain(OPTIMIZE_DISABLED) + .shouldContain(OPTIMIZE_ENABLED) + .shouldNotContain(FMG_DISABLED) + .shouldContain(FMG_ENABLED) + .shouldMatch(MAIN_FROM_CDS) // archived Main class is for module only + .shouldContain(CLASS_FOUND_MESSAGE); + }); + + tty("2. run with CDS on, with jar on path"); + TestCommon.run("-Xlog:cds", + "-Xlog:class+load", + "-cp", mainJar.toString() + PATH_SEPARATOR + testJar.toString(), + MAIN_CLASS) + .assertNormalExit(out -> { + out.shouldContain(CLASS_FOUND_MESSAGE) + .shouldMatch(MAIN_FROM_JAR) + .shouldMatch(TEST_FROM_JAR) + .shouldContain(OPTIMIZE_DISABLED) + .shouldNotContain(OPTIMIZE_ENABLED) + .shouldContain(FMG_DISABLED) + .shouldNotContain(FMG_ENABLED); + }); + + tty("3. run with CDS on, with --module-path, with jar should fail"); + TestCommon.run("-Xlog:cds", + "-Xlog:class+load", + "-p", libsDir.toString(), + "-cp", mainJar.toString(), + MAIN_CLASS) + .assertNormalExit(out -> { + out.shouldContain(CLASS_NOT_FOUND_MESSAGE) + .shouldMatch(MAIN_FROM_JAR) + .shouldNotContain(FMG_ENABLED) + .shouldNotContain(OPTIMIZE_ENABLED); + }); + + final String modularJarPath = mainJar.toString() + PATH_SEPARATOR + testJar.toString(); + + tty("4. run with CDS on, with modular jars specified --module-path, should pass"); + TestCommon.runWithModules(prefix, + null, // --upgrade-module-path + modularJarPath, // --module-path + MAIN_MODULE) // -m + .assertNormalExit(out -> { + out.shouldNotContain(OPTIMIZE_DISABLED) + .shouldContain(OPTIMIZE_ENABLED) + .shouldNotContain(FMG_DISABLED) + .shouldContain(FMG_ENABLED) + .shouldMatch(MAIN_FROM_CDS); // archived Main class is for module only + }); + + final String extraModulePath = libsDir.toString() + PATH_SEPARATOR + dupDir.toString(); + // create an archive with an extra module which is not referenced + output = TestCommon.createArchive( + null, appClasses, + "--module-path", + extraModulePath, + "-m", MAIN_MODULE); + TestCommon.checkDump(output); + + tty("5. run with CDS on, without the extra module specified in dump time, should pass"); + TestCommon.runWithModules(prefix, + null, // --upgrade-module-path + libsDir.toString(), // --module-path + MAIN_MODULE) // -m + .assertNormalExit(out -> { + out.shouldNotContain(OPTIMIZE_DISABLED) + .shouldContain(OPTIMIZE_ENABLED) + .shouldNotContain(FMG_DISABLED) + .shouldContain(FMG_ENABLED) + .shouldMatch(MAIN_FROM_CDS) // archived Main class is for module only + .shouldContain(CLASS_FOUND_MESSAGE); + }); + tty("6. run with CDS on, with the extra module specified in dump time"); + TestCommon.runWithModules(prefix, + null, // --upgrade-module-path + extraModulePath, // --module-path + MAIN_MODULE) // -m + .assertNormalExit(out -> { + out.shouldNotContain(OPTIMIZE_ENABLED) + .shouldContain(OPTIMIZE_DISABLED) + .shouldNotContain(FMG_ENABLED) + .shouldContain(FMG_DISABLED) + .shouldMatch(MAIN_FROM_CDS) // archived Main class is for module only + .shouldContain(CLASS_FOUND_MESSAGE); + }); + + final String extraJarPath = modularJarPath + PATH_SEPARATOR + dupJar.toString(); + + // create an archive by specifying modular jars in the --module-path with an extra module which is not referenced + output = TestCommon.createArchive( + null, appClasses, + "--module-path", + extraJarPath, + "-m", MAIN_MODULE); + TestCommon.checkDump(output); + tty("7. run with CDS on, without the extra module specified in dump time, should pass"); + TestCommon.runWithModules(prefix, + null, // --upgrade-module-path + modularJarPath, // --module-path + MAIN_MODULE) // -m + .assertNormalExit(out -> { + out.shouldNotContain(OPTIMIZE_DISABLED) + .shouldContain(OPTIMIZE_ENABLED) + .shouldNotContain(FMG_DISABLED) + .shouldContain(FMG_ENABLED) + .shouldMatch(MAIN_FROM_CDS) // archived Main class is for module only + .shouldContain(CLASS_FOUND_MESSAGE); + }); + + tty("8. run with CDS on, with the extra module specified in dump time"); + TestCommon.runWithModules(prefix, + null, // --upgrade-module-path + extraJarPath, // --module-path + MAIN_MODULE) // -m + .assertNormalExit(out -> { + out.shouldNotContain(OPTIMIZE_ENABLED) + .shouldContain(OPTIMIZE_DISABLED) + .shouldNotContain(FMG_ENABLED) + .shouldContain(FMG_DISABLED) + .shouldMatch(MAIN_FROM_CDS) // archived Main class is for module only + .shouldContain(CLASS_FOUND_MESSAGE); + }); + tty("9. same as test case 8 but with paths instead of modular jars in the --module-path"); + TestCommon.runWithModules(prefix, + null, // --upgrade-module-path + extraModulePath, // --module-path + MAIN_MODULE) // -m + .assertNormalExit(out -> { + out.shouldNotContain(OPTIMIZE_ENABLED) + .shouldContain(OPTIMIZE_DISABLED) + .shouldNotContain(FMG_ENABLED) + .shouldContain(FMG_DISABLED) + .shouldMatch(MAIN_FROM_CDS) // archived Main class is for module only + .shouldContain(CLASS_FOUND_MESSAGE); + }); + } + + public static void runWithExplodedModule() throws Exception { + // create an archive with an exploded module in the module path. + OutputAnalyzer output = TestCommon.createArchive( + null, appClasses, + "--module-path", + MODS_DIR.toString(), + "-m", MAIN_MODULE + "/" + MAIN_CLASS); + TestCommon.checkDump(output); + + tty("10. run with CDS on, with exploded module in the module path"); + TestCommon.runWithModules(prefix, + null, // --upgrade-module-path + MODS_DIR.toString(), // --module-path + MAIN_MODULE + "/" + MAIN_CLASS) // -m + .assertNormalExit(out -> { + out.shouldContain(FMG_DISABLED) + .shouldMatch(MAIN_FROM_MODULE) // Main class loaded from the exploded module + .shouldContain(CLASS_FOUND_MESSAGE); + }); + } + + public static void runWithJmodAndBadJar() throws Exception { + buildJmod(); + + final String modularJarPath = mainJar.toString() + PATH_SEPARATOR + testJar.toString(); + // create an archive with --module-path com.bars.jar:com.foos.jar + OutputAnalyzer output = TestCommon.createArchive( + null, appClasses, + "--module-path", + modularJarPath, + "-m", MAIN_MODULE); + TestCommon.checkDump(output); + + String runModulePath = mainJar.toString() + PATH_SEPARATOR + + jmodDir.toString() + TEST_MODULE + ".jmod"; + tty("11. run with CDS on, with module path com.bars.jar:com.foos.jmod"); + TestCommon.runWithModules(prefix, + null, // --upgrade-module-path + runModulePath, // --module-path + MAIN_MODULE) // -m + .assertAbnormalExit(out -> { + out.shouldContain(OPTIMIZE_DISABLED) + .shouldNotContain(OPTIMIZE_ENABLED) + .shouldContain(FMG_DISABLED) + .shouldNotContain(FMG_ENABLED) + .shouldContain(FIND_EXCEPTION_MESSAGE); + }); + + runModulePath += PATH_SEPARATOR + testJar.toString(); + tty("12. run with CDS on, with module path com.bars.jar:com.foos.jmod:com.foos.jar"); + TestCommon.runWithModules(prefix, + null, // --upgrade-module-path + runModulePath, // --module-path + MAIN_MODULE) // -m + .assertNormalExit(out -> { + out.shouldNotContain(OPTIMIZE_DISABLED) + .shouldContain(OPTIMIZE_ENABLED) + .shouldNotContain(FMG_DISABLED) + .shouldContain(FMG_ENABLED) + .shouldMatch(TEST_FROM_CDS) + .shouldMatch(MAIN_FROM_CDS) + .shouldContain(CLASS_FOUND_MESSAGE); + }); + + runModulePath = badJar.toString() + PATH_SEPARATOR + testJar.toString(); + tty("13. run with CDS on, with module path com.bars.JAR:com.foos.jar"); + TestCommon.runWithModules(prefix, + null, // --upgrade-module-path + runModulePath, // --module-path + TEST_MODULE) // -m + .assertAbnormalExit(out -> { + out.shouldContain(OPTIMIZE_DISABLED) + .shouldNotContain(OPTIMIZE_ENABLED) + .shouldContain(FMG_DISABLED) + .shouldNotContain(FMG_ENABLED) + .shouldMatch(MODULE_NOT_RECOGNIZED); + }); + } +} diff --git a/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/modulepath/OptimizeModuleHandlingTest.java b/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/modulepath/OptimizeModuleHandlingTest.java index aeb5696830d..cf6f4cd7fd3 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/modulepath/OptimizeModuleHandlingTest.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/modulepath/OptimizeModuleHandlingTest.java @@ -24,7 +24,7 @@ /** * @test - * @requires vm.cds & !vm.graal.enabled + * @requires vm.cds & !vm.graal.enabled & vm.cds.write.archived.java.heap * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds * @run driver OptimizeModuleHandlingTest * @summary test module path changes for optimization of @@ -64,8 +64,8 @@ public class OptimizeModuleHandlingTest { private static String CLASS_FOUND_MESSAGE = "com.foos.Test found"; private static String CLASS_NOT_FOUND_MESSAGE = "java.lang.ClassNotFoundException: com.foos.Test"; - private static String OPTIMIZE_ENABLED = "optimized module handling: enabled"; - private static String OPTIMIZE_DISABLED = "optimized module handling: disabled"; + private static String OPTIMIZE_ENABLED = "] optimized module handling: enabled"; + private static String OPTIMIZE_DISABLED = "] optimized module handling: disabled"; private static String MAIN_FROM_JAR = "class,load.*com.bars.Main.*[.]jar"; private static String MAIN_FROM_CDS = "class,load.*com.bars.Main.*shared objects file"; private static String TEST_FROM_JAR = "class,load.*com.foos.Test.*[.]jar"; @@ -154,14 +154,14 @@ public class OptimizeModuleHandlingTest { // Following 5 - 10 test with CDS on tty("5. run with CDS on, with module path"); - String prefix[] = {"-Djava.class.path=", "-Xlog:cds", "-Xlog:class+load"}; + String prefix[] = {"-Djava.class.path=", "-Xlog:cds,class+load,class+path=info"}; TestCommon.runWithModules(prefix, null, // --upgrade-module-path libsDir.toString(), // --module-path MAIN_MODULE) // -m .assertNormalExit(out -> { - out.shouldNotContain(OPTIMIZE_ENABLED) - .shouldContain(OPTIMIZE_DISABLED) + out.shouldNotContain(OPTIMIZE_DISABLED) + .shouldContain(OPTIMIZE_ENABLED) .shouldMatch(MAIN_FROM_CDS) // // archived Main class is for module only .shouldContain(CLASS_FOUND_MESSAGE); }); @@ -174,8 +174,8 @@ public class OptimizeModuleHandlingTest { out.shouldContain(CLASS_FOUND_MESSAGE) .shouldMatch(MAIN_FROM_CDS) .shouldMatch(TEST_FROM_CDS) - .shouldContain(OPTIMIZE_DISABLED) - .shouldNotContain(OPTIMIZE_ENABLED); + .shouldContain(OPTIMIZE_ENABLED) + .shouldNotContain(OPTIMIZE_DISABLED); }); tty("7. run with CDS on, with jar on path"); TestCommon.run("-Xlog:cds", @@ -231,7 +231,6 @@ public class OptimizeModuleHandlingTest { MAIN_CLASS) .assertAbnormalExit(out -> { out.shouldNotContain(CLASS_FOUND_MESSAGE) - .shouldContain(OPTIMIZE_DISABLED) // mapping info .shouldContain("shared class paths mismatch"); }); } diff --git a/test/hotspot/jtreg/runtime/cds/appcds/jvmti/dumpingWithAgent/DumpingWithJavaAgent.java b/test/hotspot/jtreg/runtime/cds/appcds/jvmti/dumpingWithAgent/DumpingWithJavaAgent.java index c814a9a4065..7d68fdf0fc8 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/jvmti/dumpingWithAgent/DumpingWithJavaAgent.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/jvmti/dumpingWithAgent/DumpingWithJavaAgent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/IncompatibleOptions.java b/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/IncompatibleOptions.java index 86b2c8fd425..2ad257476d0 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/IncompatibleOptions.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/IncompatibleOptions.java @@ -108,9 +108,9 @@ public class IncompatibleOptions { testDump(1, "-XX:+UseZGC", "-XX:-UseCompressedOops", null, false); } - // incompatible GCs - testDump(2, "-XX:+UseParallelGC", "", GC_WARNING, false); - testDump(3, "-XX:+UseSerialGC", "", GC_WARNING, false); + // Dump heap objects with ParallelGC and SerialGC + testDump(2, "-XX:+UseParallelGC", "", "", false); + testDump(3, "-XX:+UseSerialGC", "", "", false); // Explicitly archive with compressed oops, run without. testDump(5, "-XX:+UseG1GC", "-XX:+UseCompressedOops", null, false); diff --git a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/SharedStringsHumongous.java b/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/SharedStringsHumongous.java index 01cebb29f91..3e2145c7821 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/SharedStringsHumongous.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/SharedStringsHumongous.java @@ -27,6 +27,7 @@ * @summary Use a shared string allocated in a humongous G1 region. * @comment -- the following implies that G1 is used (by command-line or by default) * @requires vm.cds.write.archived.java.heap + * @requires vm.gc.G1 * * @library /test/hotspot/jtreg/runtime/cds/appcds /test/lib * @build HelloString diff --git a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/SharedStringsUtils.java b/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/SharedStringsUtils.java index 57e39b5177a..4026f1d4f84 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/SharedStringsUtils.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/SharedStringsUtils.java @@ -96,7 +96,7 @@ public class SharedStringsUtils { String appJar = TestCommon.getTestJar(TEST_JAR_NAME_FULL); String[] args = - TestCommon.concat(extraOptions, "-XX:+UseCompressedOops", "-XX:+UseG1GC", + TestCommon.concat(extraOptions, "-XX:+UseCompressedOops", "-XX:SharedArchiveConfigFile=" + TestCommon.getSourceFile(sharedDataFile)); args = TestCommon.concat(childVMOptionsPrefix, args); @@ -124,7 +124,7 @@ public class SharedStringsUtils { String appJar = TestCommon.getTestJar(TEST_JAR_NAME_FULL); String[] args = TestCommon.concat(extraOptions, - "-cp", appJar, "-XX:+UseCompressedOops", "-XX:+UseG1GC", className); + "-cp", appJar, "-XX:+UseCompressedOops", className); args = TestCommon.concat(childVMOptionsPrefix, args); OutputAnalyzer output = TestCommon.execAuto(args); @@ -143,7 +143,7 @@ public class SharedStringsUtils { String appJar = TestCommon.getTestJar(TEST_JAR_NAME_FULL); String[] args = TestCommon.concat(extraOptions, - "-XX:+UseCompressedOops", "-XX:+UseG1GC", className); + "-XX:+UseCompressedOops", className); args = TestCommon.concat(childVMOptionsPrefix, args); OutputAnalyzer output = TestCommon.exec(appJar, args); diff --git a/test/hotspot/jtreg/runtime/condy/BadBSMUseTest.java b/test/hotspot/jtreg/runtime/condy/BadBSMUseTest.java index a07c98caa66..3e36d1aebd9 100644 --- a/test/hotspot/jtreg/runtime/condy/BadBSMUseTest.java +++ b/test/hotspot/jtreg/runtime/condy/BadBSMUseTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,6 @@ * @test * @bug 8186211 * @summary CONSTANT_Dynamic_info structure's tries to use a BSM index whose signature is for an invokedynamic and vice versa. - * @requires vm.flagless * @modules java.base/jdk.internal.misc * @library /test/lib * @compile CondyUsesIndyBSM.jcod @@ -42,7 +41,7 @@ public class BadBSMUseTest { public static void main(String args[]) throws Throwable { // 1. Test a CONSTANT_Dynamic_info's bootstrap_method_attr_index points // at a BSM meant for a CONSTANT_InvokeDynamic_info - ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("CondyUsesIndyBSM"); + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder("CondyUsesIndyBSM"); OutputAnalyzer oa = new OutputAnalyzer(pb.start()); oa.shouldContain("In Indybsm target CallSite method foo"); oa.shouldContain("BootstrapMethodError: bootstrap method initialization exception"); @@ -50,7 +49,7 @@ public class BadBSMUseTest { // 2. Test a CONSTANT_InvokeDynamic_info's bootstrap_method_attr_index points // at a BSM meant for a CONSTANT_Dynamic_info - pb = ProcessTools.createLimitedTestJavaProcessBuilder("IndyUsesCondyBSM"); + pb = ProcessTools.createTestJavaProcessBuilder("IndyUsesCondyBSM"); oa = new OutputAnalyzer(pb.start()); oa.shouldContain("In Condybsm"); oa.shouldContain("BootstrapMethodError: bootstrap method initialization exception"); diff --git a/test/hotspot/jtreg/runtime/condy/CondyExtendedNullPointer.jasm b/test/hotspot/jtreg/runtime/condy/CondyExtendedNullPointer.jasm new file mode 100644 index 00000000000..7697b0c46da --- /dev/null +++ b/test/hotspot/jtreg/runtime/condy/CondyExtendedNullPointer.jasm @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * This test generates an extended NullPointerException inside a method with + * a condy ldc. We add two ldc instructions and a pop around the real null + * value to stress the stack handling of the NPE message generator. + */ +class CondyExtendedNullPointer + version 55:0 +{ + +static Field nullObject:"Ljava/lang/Object;"; + +public static Method condy:"(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/Class;)I" + stack 1 locals 3 +{ + bipush 123; + ireturn; +} + +public static Method main:"([Ljava/lang/String;)V" + stack 3 locals 1 +{ + ldc Dynamic REF_invokeStatic:CondyExtendedNullPointer.condy:"(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/Class;)I":I:"I"; + getstatic Field nullObject:"Ljava/lang/Object;"; + ldc Dynamic REF_invokeStatic:CondyExtendedNullPointer.condy:"(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/Class;)I":I:"I"; + pop; + invokevirtual Method java/lang/Object.notify:"()V"; + return; +} + +} // end Class CondyExtendedNullPointer diff --git a/test/hotspot/jtreg/runtime/condy/CondyExtendedNullPointerTest.java b/test/hotspot/jtreg/runtime/condy/CondyExtendedNullPointerTest.java new file mode 100644 index 00000000000..665633796f6 --- /dev/null +++ b/test/hotspot/jtreg/runtime/condy/CondyExtendedNullPointerTest.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8339488 + * @summary Test extended NullPointerException message in method with CONSTANT_Dynamic. + * @modules java.base/jdk.internal.misc + * @library /test/lib + * @compile CondyExtendedNullPointer.jasm + * @run driver CondyExtendedNullPointerTest + */ + +import jdk.test.lib.process.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; + +public class CondyExtendedNullPointerTest { + public static void main(String args[]) throws Throwable { + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder("-Xverify:all", + "CondyExtendedNullPointer"); + OutputAnalyzer oa = new OutputAnalyzer(pb.start()); + oa.shouldContain("Cannot invoke \"Object.notify()\" because \"CondyExtendedNullPointer.nullObject\" is null"); + oa.shouldHaveExitValue(1); + } +} diff --git a/test/hotspot/jtreg/runtime/condy/CondyLDCTest.java b/test/hotspot/jtreg/runtime/condy/CondyLDCTest.java index 22cfb727eb8..1b045d1e36e 100644 --- a/test/hotspot/jtreg/runtime/condy/CondyLDCTest.java +++ b/test/hotspot/jtreg/runtime/condy/CondyLDCTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,6 @@ * @test * @bug 8186211 * @summary Tests various ldc, ldc_w, ldc2_w instructions of CONSTANT_Dynamic. - * @requires vm.flagless * @modules java.base/jdk.internal.misc * @library /test/lib * @compile CondyUseLDC_W.jasm @@ -42,7 +41,7 @@ public class CondyLDCTest { public static void main(String args[]) throws Throwable { // 1. Test a ldc_w instruction can be used with condy's which generate // loadable constants of the following types: byte, char, short, float, integer, boolean. - ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xverify:all", + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder("-Xverify:all", "CondyUseLDC_W"); OutputAnalyzer oa = new OutputAnalyzer(pb.start()); oa.shouldNotContain("VerifyError"); @@ -50,7 +49,7 @@ public class CondyLDCTest { // 2. Test ldc2_w of a condy which returns a dynamically generated // float constant, generates a VerifyError. - pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xverify:all", + pb = ProcessTools.createTestJavaProcessBuilder("-Xverify:all", "CondyBadLDC2_W"); oa = new OutputAnalyzer(pb.start()); oa.shouldContain("java.lang.VerifyError: Illegal type at constant pool entry"); @@ -59,7 +58,7 @@ public class CondyLDCTest { // 3. Test a ldc of a condy which returns a dynamically generated // double constant, generates a VerifyError. - pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xverify:all", + pb = ProcessTools.createTestJavaProcessBuilder("-Xverify:all", "CondyBadLDC"); oa = new OutputAnalyzer(pb.start()); oa.shouldContain("java.lang.VerifyError: Illegal type at constant pool entry"); diff --git a/test/hotspot/jtreg/runtime/condy/CondyNewInvokeSpecialTest.java b/test/hotspot/jtreg/runtime/condy/CondyNewInvokeSpecialTest.java index 6e810d0d3b8..ddada0edbf7 100644 --- a/test/hotspot/jtreg/runtime/condy/CondyNewInvokeSpecialTest.java +++ b/test/hotspot/jtreg/runtime/condy/CondyNewInvokeSpecialTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,6 @@ * @test * @bug 8186211 * @summary Test CONSTANT_Dynamic where the BSM is invoked via a REF_newInvokeSpecial. - * @requires vm.flagless * @modules java.base/jdk.internal.misc * @library /test/lib * @compile CondyNewInvokeSpecial.jasm @@ -38,7 +37,7 @@ import jdk.test.lib.compiler.InMemoryJavaCompiler; public class CondyNewInvokeSpecialTest { public static void main(String args[]) throws Throwable { - ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xverify:all", + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder("-Xverify:all", "CondyNewInvokeSpecial"); OutputAnalyzer oa = new OutputAnalyzer(pb.start()); oa.shouldContain("In CondyNewInvokeSpecial method"); diff --git a/test/hotspot/jtreg/runtime/condy/escapeAnalysis/TestEscapeCondy.java b/test/hotspot/jtreg/runtime/condy/escapeAnalysis/TestEscapeCondy.java index 877a805c445..a90b987db14 100644 --- a/test/hotspot/jtreg/runtime/condy/escapeAnalysis/TestEscapeCondy.java +++ b/test/hotspot/jtreg/runtime/condy/escapeAnalysis/TestEscapeCondy.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,6 @@ * @bug 8216970 * @summary Ensure escape analysis can handle an ldc of a dynamic * constant whose return type is an array of boolean. - * @requires vm.flagless * @modules java.base/jdk.internal.misc * @library /test/lib * @compile TestEscapeThroughInvokeWithCondy$A.jasm @@ -43,7 +42,7 @@ public class TestEscapeCondy { public static void main(String args[]) throws Throwable { // 1. Test escape analysis of a method that contains // a ldc instruction of a condy whose return type is an array of boolean - ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder( "-XX:CompileCommand=dontinline,runtime.condy.TestEscapeThroughInvokeWithCondy::create", "runtime.condy.TestEscapeThroughInvokeWithCondy"); OutputAnalyzer oa = new OutputAnalyzer(pb.start()); diff --git a/test/hotspot/jtreg/runtime/condy/staticInit/TestInitException.java b/test/hotspot/jtreg/runtime/condy/staticInit/TestInitException.java index 2b572edb66f..412a1639e69 100644 --- a/test/hotspot/jtreg/runtime/condy/staticInit/TestInitException.java +++ b/test/hotspot/jtreg/runtime/condy/staticInit/TestInitException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,6 @@ * @test * @bug 8228485 * @summary Correctly handle initialization error for Condy BSM. - * @requires vm.flagless * @modules java.base/jdk.internal.misc * @library /test/lib * @compile Example.jasm @@ -38,7 +37,7 @@ import jdk.test.lib.process.OutputAnalyzer; public class TestInitException { public static void main(java.lang.String[] unused) throws Exception { - ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("Example"); + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder("Example"); OutputAnalyzer oa = new OutputAnalyzer(pb.start()); // First call stack trace // shouldMatch is used to workaround CODETOOLS-7902686 @@ -52,4 +51,3 @@ public class TestInitException { oa.shouldHaveExitValue(1); } } - diff --git a/test/hotspot/jtreg/runtime/interpreter/LastJsrTest.java b/test/hotspot/jtreg/runtime/interpreter/LastJsrTest.java index 913a304ae38..fd9cffe002d 100644 --- a/test/hotspot/jtreg/runtime/interpreter/LastJsrTest.java +++ b/test/hotspot/jtreg/runtime/interpreter/LastJsrTest.java @@ -23,18 +23,20 @@ /* * @test - * @bug 8335664 + * @bug 8335664 8338924 * @summary Ensure a program that ends with a JSR does not crash * @library /test/lib * @compile LastJsr.jasm * @compile LastJsrReachable.jasm - * @run main/othervm LastJsrTest + * @run main/othervm -Xbatch LastJsrTest */ public class LastJsrTest { public static void main(String[] args) { - LastJsr.test(); - LastJsrReachable.test(); + for (int i = 0; i < 1000; ++i) { + LastJsr.test(); + LastJsrReachable.test(); + } System.out.println("PASSED"); } } diff --git a/test/hotspot/jtreg/runtime/reflect/ReflectOutOfMemoryError.java b/test/hotspot/jtreg/runtime/reflect/ReflectOutOfMemoryError.java index 2d23358e96b..09646d07358 100644 --- a/test/hotspot/jtreg/runtime/reflect/ReflectOutOfMemoryError.java +++ b/test/hotspot/jtreg/runtime/reflect/ReflectOutOfMemoryError.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -88,15 +88,24 @@ public class ReflectOutOfMemoryError { Object junk = testMethod.invoke(null, new Object [0]); throw new RuntimeException("InvocationTargetException should be thrown"); } catch (InvocationTargetException ite) { - Throwable targetException = ite.getTargetException(); - if (targetException instanceof OutOfMemoryError) { - System.out.println("OutOfMemoryError thrown as expected."); - System.out.println("Test passed."); - } else { - throw new RuntimeException("Unexpected InvocationTargetException: " + targetException); + // We may not directly get OOME but it could have caused + // secondary exceptions, so walk the chain of exceptions + // and see if there is an OOME somewhere. + for (Throwable cause = ite.getTargetException(); + cause != null; + cause = cause.getCause()) { + if (cause instanceof OutOfMemoryError) { + System.out.println("OutOfMemoryError thrown as expected."); + ite.printStackTrace(System.out); + System.out.println("Test passed."); + return; + } } + + throw new RuntimeException("Unexpected InvocationTargetException: ", + ite.getTargetException()); } catch (Exception exception) { - throw new RuntimeException("Unexpected exception: " + exception); + throw new RuntimeException("Unexpected exception: ", exception); } } } diff --git a/test/hotspot/jtreg/serviceability/dcmd/vm/EventsTest.java b/test/hotspot/jtreg/serviceability/dcmd/vm/EventsTest.java index b5fca58a5c5..9828a8990e0 100644 --- a/test/hotspot/jtreg/serviceability/dcmd/vm/EventsTest.java +++ b/test/hotspot/jtreg/serviceability/dcmd/vm/EventsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ import jdk.test.lib.dcmd.CommandExecutor; import jdk.test.lib.dcmd.JMXExecutor; import jdk.test.lib.process.OutputAnalyzer; import org.testng.annotations.Test; +import org.testng.Assert; /* * @test @@ -38,6 +39,9 @@ import org.testng.annotations.Test; */ public class EventsTest { + // MAX should be less than number of actually recorded events + private static int MAX = 9; + static String buildHeaderPattern(String logname) { return "^" + logname + ".*\\(\\d+ events\\):"; } @@ -64,9 +68,27 @@ public class EventsTest { output.stdoutShouldNotMatch(buildHeaderPattern("Classes unloaded")); } + public void run_max(CommandExecutor executor) { + OutputAnalyzer output = executor.execute("VM.events max=" + MAX); + long lines = output.asLines().stream().filter(x -> x.contains("Loading class")).count(); + Assert.assertTrue(lines == MAX, "There are should be " + MAX + " lines"); + } + + public void run_max_selected(CommandExecutor executor) { + OutputAnalyzer output = executor.execute("VM.events log=load max=" + MAX); + output.stdoutShouldMatch(buildHeaderPattern("Classes loaded")); + long lines = output.asLines().stream().filter(x -> x.contains("Loading class")).count(); + Assert.assertTrue(lines == MAX, "There are should be " + MAX + " lines"); + output.stdoutShouldNotMatch(buildHeaderPattern("Events")); + output.stdoutShouldNotMatch(buildHeaderPattern("Compilation")); + } + + @Test public void jmx() { run_all(new JMXExecutor()); run_selected(new JMXExecutor()); + run_max(new JMXExecutor()); + run_max_selected(new JMXExecutor()); } } diff --git a/test/hotspot/jtreg/serviceability/dcmd/vm/SystemDumpMapTest.java b/test/hotspot/jtreg/serviceability/dcmd/vm/SystemDumpMapTest.java index eb0b6bd8566..eab69de0a51 100644 --- a/test/hotspot/jtreg/serviceability/dcmd/vm/SystemDumpMapTest.java +++ b/test/hotspot/jtreg/serviceability/dcmd/vm/SystemDumpMapTest.java @@ -35,7 +35,7 @@ import java.util.regex.Pattern; * @test * @summary Test of diagnostic command System.map * @library /test/lib - * @requires (os.family=="linux") + * @requires (os.family == "linux" | os.family == "windows") * @modules java.base/jdk.internal.misc * java.compiler * java.management @@ -63,11 +63,11 @@ public class SystemDumpMapTest extends SystemMapTestBase { boolean NMTOff = output.contains("NMT is disabled"); String regexBase = ".*0x\\p{XDigit}+ - 0x\\p{XDigit}+ +\\d+"; HashSet patterns = new HashSet<>(); - for (String s: shouldMatchUnconditionally) { + for (String s: shouldMatchUnconditionally()) { patterns.add(Pattern.compile(s)); } if (!NMTOff) { // expect VM annotations if NMT is on - for (String s: shouldMatchIfNMTIsEnabled) { + for (String s: shouldMatchIfNMTIsEnabled()) { patterns.add(Pattern.compile(s)); } } diff --git a/test/hotspot/jtreg/serviceability/dcmd/vm/SystemMapTest.java b/test/hotspot/jtreg/serviceability/dcmd/vm/SystemMapTest.java index 43857a1f039..6d589d17f8a 100644 --- a/test/hotspot/jtreg/serviceability/dcmd/vm/SystemMapTest.java +++ b/test/hotspot/jtreg/serviceability/dcmd/vm/SystemMapTest.java @@ -31,7 +31,7 @@ import jdk.test.lib.process.OutputAnalyzer; * @test * @summary Test of diagnostic command System.map * @library /test/lib - * @requires (os.family=="linux") + * @requires (os.family == "linux" | os.family == "windows") * @modules java.base/jdk.internal.misc * java.compiler * java.management @@ -42,11 +42,11 @@ public class SystemMapTest extends SystemMapTestBase { public void run(CommandExecutor executor) { OutputAnalyzer output = executor.execute("System.map"); boolean NMTOff = output.contains("NMT is disabled"); - for (String s: shouldMatchUnconditionally) { + for (String s: shouldMatchUnconditionally()) { output.shouldMatch(s); } if (!NMTOff) { // expect VM annotations if NMT is on - for (String s: shouldMatchIfNMTIsEnabled) { + for (String s: shouldMatchIfNMTIsEnabled()) { output.shouldMatch(s); } } diff --git a/test/hotspot/jtreg/serviceability/dcmd/vm/SystemMapTestBase.java b/test/hotspot/jtreg/serviceability/dcmd/vm/SystemMapTestBase.java index 3d1284b09ee..6507117df35 100644 --- a/test/hotspot/jtreg/serviceability/dcmd/vm/SystemMapTestBase.java +++ b/test/hotspot/jtreg/serviceability/dcmd/vm/SystemMapTestBase.java @@ -22,6 +22,8 @@ * questions. */ +import jdk.test.lib.Platform; + public class SystemMapTestBase { // e.g. @@ -29,6 +31,7 @@ public class SystemMapTestBase { private static final String range = "0x\\p{XDigit}+-0x\\p{XDigit}+"; private static final String space = " +"; private static final String someSize = "\\d+"; + private static final String someNumber = "(0x\\p{XDigit}+|\\d+)"; private static final String pagesize = "(4K|8K|16K|64K|2M|16M|64M)"; private static final String prot = "[rwsxp-]+"; @@ -44,7 +47,8 @@ public class SystemMapTestBase { // java heap is either committed, non-shared, or - in case of ZGC - committed and shared. private static final String regexBase_java_heap = regexBase + "(shrd,)?com.*"; - protected static final String shouldMatchUnconditionally[] = { + + private static final String shouldMatchUnconditionally_linux[] = { // java launcher regexBase_committed + "/bin/java", // libjvm @@ -55,7 +59,7 @@ public class SystemMapTestBase { regexBase_shared_and_committed + "hsperfdata_.*" }; - protected static final String shouldMatchIfNMTIsEnabled[] = { + private static final String shouldMatchIfNMTIsEnabled_linux[] = { regexBase_java_heap + "JAVAHEAP.*", // metaspace regexBase_committed + "META.*", @@ -66,4 +70,43 @@ public class SystemMapTestBase { // Main thread stack regexBase_committed + "STACK.*main.*" }; + + // windows: + private static final String winprot = "[\\-rwxcin]*"; + private static final String wintype = "[rc]-(img|map|pvt)"; + + private static final String winbase = range + space + someSize + space + winprot + space; + + private static final String winimage = winbase + "c-img" + space + someNumber + space; + private static final String wincommitted = winbase + "(c-pvt|c-map)" + space + someNumber + space; + private static final String winreserved = winbase + "r-pvt" + space + someNumber + space; + + private static final String shouldMatchUnconditionally_windows[] = { + // java launcher + winimage + ".*[\\/\\\\]bin[\\/\\\\]java[.]exe", + // libjvm + winimage + ".*[\\/\\\\]bin[\\/\\\\].*[\\/\\\\]jvm.dll" + }; + + private static final String shouldMatchIfNMTIsEnabled_windows[] = { + wincommitted + "JAVAHEAP.*", + // metaspace + wincommitted + "META.*", + // parts of metaspace should be uncommitted + winreserved + "META.*", + // code cache + wincommitted + "CODE.*", + // Main thread stack + wincommitted + "STACK-\\d+-main.*" + }; + + private static final boolean isWindows = Platform.isWindows(); + + protected static String[] shouldMatchUnconditionally() { + return isWindows ? shouldMatchUnconditionally_windows : shouldMatchUnconditionally_linux; + } + protected static String[] shouldMatchIfNMTIsEnabled() { + return isWindows ? shouldMatchIfNMTIsEnabled_windows : shouldMatchIfNMTIsEnabled_linux; + } + } diff --git a/test/hotspot/jtreg/serviceability/jvmti/GetMethodDeclaringClass/TestUnloadedClass.java b/test/hotspot/jtreg/serviceability/jvmti/GetMethodDeclaringClass/TestUnloadedClass.java new file mode 100644 index 00000000000..dafec97111e --- /dev/null +++ b/test/hotspot/jtreg/serviceability/jvmti/GetMethodDeclaringClass/TestUnloadedClass.java @@ -0,0 +1,106 @@ +/* + * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. + * Copyright (c) 2024, Alibaba Group Holding Limited. 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 8339725 + * @summary Stress test GetMethodDeclaringClass + * @requires vm.jvmti + * @requires (os.family == "linux") + * @library /test/lib + * @run driver/timeout=300 TestUnloadedClass + */ + +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.Utils; +import jdk.test.lib.process.ProcessTools; +import jdk.test.lib.Platform; + +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.InputStream; +import java.lang.reflect.Constructor; + +public class TestUnloadedClass { + public static void main(String[] args) throws Exception { + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder( + "-agentpath:" + Utils.TEST_NATIVE_PATH + File.separator + System.mapLibraryName("TestUnloadedClass"), + "-Xmx50m", + "Test"); + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + if (!Platform.isDebugBuild()) { + output.shouldContain("OutOfMemoryError"); + } + } +} + +class Test { + public static void main(String[] args) throws Exception { + long last = System.nanoTime(); + for (int i = 0;;i++) { + if (Platform.isDebugBuild() && i >= 1000) { + // Debug build costs too much time to OOM so limit the loop iteration + break; + } + CustomClassLoader loader = new CustomClassLoader(); + Class k = loader.findClass("MyClass"); + Constructor c = k.getDeclaredConstructor(); + c.setAccessible(true); + c.newInstance(); + + // call gc every ~1 second. + if ((System.nanoTime() - last) >= 1e9) { + System.gc(); + last = System.nanoTime(); + } + } + } +} + +class CustomClassLoader extends ClassLoader { + static byte[] BYTES; + + static { + try (InputStream in = CustomClassLoader.class.getResourceAsStream("MyClass.class")) { + try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) { + byte[] buf = new byte[4096]; + int len; + while ((len = in.read(buf)) != -1) { + baos.write(buf, 0, len); + } + BYTES = baos.toByteArray(); + } + } catch (Throwable t) { + throw new RuntimeException(t); + } + } + + @Override + public Class findClass(String name) throws ClassNotFoundException { + return defineClass(name, BYTES, 0, BYTES.length); + } +} + +class MyClass { +} diff --git a/test/hotspot/jtreg/serviceability/jvmti/GetMethodDeclaringClass/libTestUnloadedClass.cpp b/test/hotspot/jtreg/serviceability/jvmti/GetMethodDeclaringClass/libTestUnloadedClass.cpp new file mode 100644 index 00000000000..c32b787d578 --- /dev/null +++ b/test/hotspot/jtreg/serviceability/jvmti/GetMethodDeclaringClass/libTestUnloadedClass.cpp @@ -0,0 +1,129 @@ +/* + * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. + * Copyright (c) 2024, Alibaba Group Holding Limited. 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. + */ + +#include + +#include +#include +#include +#include +#include +#include + +static jvmtiEnv *_jvmti; +static JavaVM *_jvm; + +#define BUFFER_SIZE 100000 +static std::atomic ring_buffer[BUFFER_SIZE]; + +void get_method_details(jmethodID method) { + jclass method_class; + char *class_name = NULL; + if (_jvmti->GetMethodDeclaringClass(method, &method_class) == JVMTI_ERROR_NONE) { + if (_jvmti->GetClassSignature(method_class, &class_name, NULL) == JVMTI_ERROR_NONE) { + _jvmti->Deallocate((unsigned char *)class_name); + } + } +} + +void* read_ringbuffer(void* arg) { + JNIEnv *env; + _jvm->AttachCurrentThreadAsDaemon((void **)&env, NULL); + for (;;) { + jmethodID id = ring_buffer[rand() % BUFFER_SIZE].load(std::memory_order_relaxed); + if (id != (jmethodID)0) { + get_method_details(id); + } + } + return NULL; +} + +static void JNICALL ClassPrepareCallback(jvmtiEnv *jvmti_env, + JNIEnv *jni_env, + jthread thread, + jclass klass) { + static bool reader_created = false; + static int ring_buffer_idx = 0; + + char *class_name = NULL; + if (jvmti_env->GetClassSignature(klass, &class_name, NULL) != JVMTI_ERROR_NONE) { + return; + } + // We only care MyClass and only one thread loads it + bool is_my_class = strcmp(class_name, "LMyClass;") == 0; + jvmti_env->Deallocate((unsigned char *)class_name); + if (!is_my_class) { + return; + } + + if (!reader_created) { + pthread_t tid; + pthread_create(&tid, NULL, read_ringbuffer, NULL); + reader_created = true; + } + + jint method_count; + jmethodID *methods; + if (jvmti_env->GetClassMethods(klass, &method_count, &methods) == JVMTI_ERROR_NONE) { + ring_buffer[ring_buffer_idx++].store(methods[0], std::memory_order_relaxed); + ring_buffer_idx = ring_buffer_idx % BUFFER_SIZE; + jvmti_env->Deallocate((unsigned char *)methods); + } +} + +JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { + for (int i = 0; i < BUFFER_SIZE; i++) { + ring_buffer[i].store(0, std::memory_order_relaxed); + } + + jvmtiEventCallbacks callbacks; + jvmtiError error; + + _jvm = jvm; + + if (jvm->GetEnv((void **)&_jvmti, JVMTI_VERSION_1_0) != JNI_OK) { + fprintf(stderr, "Unable to access JVMTI!\n"); + return JNI_ERR; + } + + // Set up the event callbacks + memset(&callbacks, 0, sizeof(callbacks)); + callbacks.ClassPrepare = &ClassPrepareCallback; + + // Register the callbacks + error = _jvmti->SetEventCallbacks(&callbacks, sizeof(callbacks)); + if (error != JVMTI_ERROR_NONE) { + fprintf(stderr, "Error setting event callbacks: %d\n", error); + return JNI_ERR; + } + + // Enable the ClassPrepare event + error = _jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_PREPARE, NULL); + if (error != JVMTI_ERROR_NONE) { + fprintf(stderr, "Error enabling ClassPrepare event: %d\n", error); + return JNI_ERR; + } + + return JNI_OK; +} diff --git a/test/hotspot/jtreg/serviceability/jvmti/vthread/GetThreadState/GetThreadStateTest.java b/test/hotspot/jtreg/serviceability/jvmti/vthread/GetThreadState/GetThreadStateTest.java index cc8f5638c76..9ec9ca1b8c2 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/vthread/GetThreadState/GetThreadStateTest.java +++ b/test/hotspot/jtreg/serviceability/jvmti/vthread/GetThreadState/GetThreadStateTest.java @@ -25,7 +25,7 @@ * @test id=default * @bug 8312498 * @summary Basic test for JVMTI GetThreadState with virtual threads - * @modules java.base/java.lang:+open + * @modules jdk.management * @library /test/lib * @run junit/othervm/native --enable-native-access=ALL-UNNAMED GetThreadStateTest */ @@ -33,7 +33,7 @@ /* * @test id=no-vmcontinuations * @requires vm.continuations - * @modules java.base/java.lang:+open + * @modules jdk.management * @library /test/lib * @run junit/othervm/native -XX:+UnlockExperimentalVMOptions -XX:-VMContinuations --enable-native-access=ALL-UNNAMED GetThreadStateTest */ @@ -42,7 +42,7 @@ import java.util.StringJoiner; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.locks.LockSupport; -import jdk.test.lib.thread.VThreadRunner; +import jdk.test.lib.thread.VThreadRunner; // ensureParallelism requires jdk.management import jdk.test.lib.thread.VThreadPinner; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; diff --git a/test/hotspot/jtreg/serviceability/jvmti/vthread/VThreadEventTest/VThreadEventTest.java b/test/hotspot/jtreg/serviceability/jvmti/vthread/VThreadEventTest/VThreadEventTest.java index 845e9adba01..5b4f6ac2a48 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/vthread/VThreadEventTest/VThreadEventTest.java +++ b/test/hotspot/jtreg/serviceability/jvmti/vthread/VThreadEventTest/VThreadEventTest.java @@ -28,7 +28,7 @@ * @requires vm.continuations * @requires vm.jvmti * @requires vm.compMode != "Xcomp" - * @modules java.base/java.lang:+open + * @modules jdk.management * @library /test/lib * @run main/othervm/native * -Djdk.attach.allowAttachSelf=true -XX:+EnableDynamicAgentLoading VThreadEventTest attach diff --git a/test/hotspot/jtreg/serviceability/sa/LingeredAppWithFFMUpcall.java b/test/hotspot/jtreg/serviceability/sa/LingeredAppWithFFMUpcall.java new file mode 100644 index 00000000000..d2977c491ab --- /dev/null +++ b/test/hotspot/jtreg/serviceability/sa/LingeredAppWithFFMUpcall.java @@ -0,0 +1,75 @@ + +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.lang.invoke.MethodHandles; +import java.lang.invoke.MethodType; +import java.lang.foreign.Arena; +import java.lang.foreign.FunctionDescriptor; +import java.lang.foreign.Linker; +import java.util.concurrent.CountDownLatch; + +import jdk.test.lib.apps.LingeredApp; + +public class LingeredAppWithFFMUpcall extends LingeredApp { + + public static final String THREAD_NAME = "Upcall thread"; + + private static final Object lockObj = new Object(); + + private static final CountDownLatch signal = new CountDownLatch(1); + + static { + System.loadLibrary("upcall"); + } + + public static void upcall() { + signal.countDown(); + synchronized(lockObj) { + } + } + + public static long createFunctionPointerForUpcall() throws NoSuchMethodException, IllegalAccessException { + var mh = MethodHandles.lookup() + .findStatic(LingeredAppWithFFMUpcall.class, "upcall", MethodType.methodType(void.class)); + var stub = Linker.nativeLinker() + .upcallStub(mh, FunctionDescriptor.ofVoid(), Arena.global()); + return stub.address(); + } + + public static native void callJNI(long upcallAddr); + + public static void main(String[] args) { + try { + long upcallAddr = createFunctionPointerForUpcall(); + var upcallThread = new Thread(() -> callJNI(upcallAddr), THREAD_NAME); + synchronized(lockObj) { + upcallThread.start(); + signal.await(); + LingeredApp.main(args); + } + } catch (Exception e) { + throw new RuntimeException(e); + } + } +} diff --git a/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackUpcall.java b/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackUpcall.java new file mode 100644 index 00000000000..924f56c9b44 --- /dev/null +++ b/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackUpcall.java @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import jdk.test.lib.JDKToolLauncher; +import jdk.test.lib.SA.SATestUtils; +import jdk.test.lib.Utils; +import jdk.test.lib.apps.LingeredApp; +import jdk.test.lib.process.OutputAnalyzer; + +/** + * @test + * @bug 8339307 + * @requires vm.hasSA + * @library /test/lib + * @run driver TestJhsdbJstackUpcall + */ +public class TestJhsdbJstackUpcall { + + private static void runJstack(LingeredApp app) throws Exception { + JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jhsdb"); + launcher.addVMArgs(Utils.getTestJavaOpts()); + launcher.addToolArg("jstack"); + launcher.addToolArg("--pid"); + launcher.addToolArg(Long.toString(app.getPid())); + + ProcessBuilder pb = SATestUtils.createProcessBuilder(launcher); + Process jhsdb = pb.start(); + OutputAnalyzer out = new OutputAnalyzer(jhsdb); + + jhsdb.waitFor(); + + System.out.println(out.getStdout()); + System.err.println(out.getStderr()); + + out.shouldContain(LingeredAppWithFFMUpcall.THREAD_NAME); + out.shouldContain("LingeredAppWithFFMUpcall.upcall()"); + out.shouldContain("jdk.internal.foreign.abi.UpcallStub"); + out.shouldContain("LingeredAppWithFFMUpcall.callJNI"); + } + + public static void main(String... args) throws Exception { + SATestUtils.skipIfCannotAttach(); // throws SkippedException if attach not expected to work. + LingeredApp app = null; + + try { + // Needed for LingeredAppWithFFMUpcall to be able to resolve native library. + String libPath = System.getProperty("java.library.path"); + String[] vmArgs = (libPath != null) + ? Utils.prependTestJavaOpts("-Djava.library.path=" + libPath) + : Utils.getTestJavaOpts(); + + app = new LingeredAppWithFFMUpcall(); + LingeredApp.startAppExactJvmOpts(app, vmArgs); + System.out.println("Started LingeredAppWithFFMUpcall with pid " + app.getPid()); + runJstack(app); + System.out.println("Test Completed"); + } catch (Throwable e) { + e.printStackTrace(); + throw e; + } finally { + LingeredApp.stopApp(app); + } + } +} diff --git a/test/hotspot/jtreg/serviceability/sa/libupcall.c b/test/hotspot/jtreg/serviceability/sa/libupcall.c new file mode 100644 index 00000000000..2139e717fef --- /dev/null +++ b/test/hotspot/jtreg/serviceability/sa/libupcall.c @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +#include + +typedef void (*upcall_func)(void); + +JNIEXPORT void JNICALL +Java_LingeredAppWithFFMUpcall_callJNI(JNIEnv *env, jclass cls, jlong upcallAddr) { + upcall_func upcall = (upcall_func)upcallAddr; + upcall(); +} diff --git a/test/hotspot/jtreg/testlibrary/ctw/src/sun/hotspot/tools/ctw/CtwRunner.java b/test/hotspot/jtreg/testlibrary/ctw/src/sun/hotspot/tools/ctw/CtwRunner.java index df4f9063586..e2c7230bc0d 100644 --- a/test/hotspot/jtreg/testlibrary/ctw/src/sun/hotspot/tools/ctw/CtwRunner.java +++ b/test/hotspot/jtreg/testlibrary/ctw/src/sun/hotspot/tools/ctw/CtwRunner.java @@ -304,7 +304,17 @@ public class CtwRunner { "-XX:+StressMacroExpansion", "-XX:+StressIncrementalInlining", // StressSeed is uint - "-XX:StressSeed=" + rng.nextInt(Integer.MAX_VALUE))); + "-XX:StressSeed=" + rng.nextInt(Integer.MAX_VALUE), + // Do not fail on huge methods where StressGCM makes register + // allocation allocate lots of memory + "-XX:CompileCommand=memlimit,*.*,0")); + + // Use this stress mode 10% of the time as it could make some long-running compilations likely to abort. + if (rng.nextInt(10) == 0) { + Args.add("-XX:+StressBailout"); + Args.add("-XX:StressBailoutMean=100000"); + Args.add("-XX:+CaptureBailoutInformation"); + } for (String arg : CTW_EXTRA_ARGS.split(",")) { Args.add(arg); diff --git a/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/Automatic.java b/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/Automatic.java index c74c01f1bf7..61ec487c7ff 100644 --- a/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/Automatic.java +++ b/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/Automatic.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,13 +23,6 @@ package jdk.test.lib.jittester; -import jdk.test.lib.util.Pair; -import jdk.test.lib.jittester.factories.IRNodeBuilder; -import jdk.test.lib.jittester.types.TypeKlass; -import jdk.test.lib.jittester.utils.FixedTrees; -import jdk.test.lib.jittester.utils.OptionResolver; -import jdk.test.lib.jittester.utils.OptionResolver.Option; -import jdk.test.lib.jittester.utils.PseudoRandom; import java.time.LocalTime; import java.util.ArrayList; import java.util.List; @@ -39,57 +32,6 @@ import java.util.function.Function; public class Automatic { public static final int MINUTES_TO_WAIT = Integer.getInteger("jdk.test.lib.jittester", 3); - private static Pair generateIRTree(String name) { - ProductionLimiter.resetTimer(); - SymbolTable.removeAll(); - TypeList.removeAll(); - - IRNodeBuilder builder = new IRNodeBuilder() - .setPrefix(name) - .setName(name) - .setLevel(0); - - Long complexityLimit = ProductionParams.complexityLimit.value(); - IRNode privateClasses = null; - if (!ProductionParams.disableClasses.value()) { - long privateClassComlexity = (long) (complexityLimit * PseudoRandom.random()); - try { - privateClasses = builder.setComplexityLimit(privateClassComlexity) - .getClassDefinitionBlockFactory() - .produce(); - } catch (ProductionFailedException ex) { - ex.printStackTrace(System.out); - } - } - long mainClassComplexity = (long) (complexityLimit * PseudoRandom.random()); - IRNode mainClass = null; - try { - mainClass = builder.setComplexityLimit(mainClassComplexity) - .getMainKlassFactory() - .produce(); - TypeKlass aClass = new TypeKlass(name); - mainClass.getChild(1).addChild(FixedTrees.generateMainOrExecuteMethod(aClass, true)); - mainClass.getChild(1).addChild(FixedTrees.generateMainOrExecuteMethod(aClass, false)); - } catch (ProductionFailedException ex) { - ex.printStackTrace(System.out); - } - return new Pair<>(mainClass, privateClasses); - } - - private static void initializeTestGenerator(String[] params) { - OptionResolver parser = new OptionResolver(); - Option propertyFileOpt = parser.addStringOption('p', "property-file", - "conf/default.properties", "File to read properties from"); - ProductionParams.register(parser); - parser.parse(params, propertyFileOpt); - PseudoRandom.reset(ProductionParams.seed.value()); - TypesParser.parseTypesAndMethods(ProductionParams.classesFile.value(), - ProductionParams.excludeMethodsFile.value()); - if (ProductionParams.specificSeed.isSet()) { - PseudoRandom.setCurrentSeed(ProductionParams.specificSeed.value()); - } - } - private static List getTestGenerators() { List result = new ArrayList<>(); Class factoryClass; @@ -109,7 +51,9 @@ public class Automatic { } public static void main(String[] args) { - initializeTestGenerator(args); + ProductionParams.initializeFromCmdline(args); + IRTreeGenerator.initializeWithProductionParams(); + int counter = 0; System.out.printf("Generating %d tests...%n", ProductionParams.numberOfTests.value()); System.out.printf(" %13s | %8s | %8s | %8s |%n", "start time", "count", "generat", @@ -121,7 +65,7 @@ public class Automatic { try { System.out.print("[" + LocalTime.now() + "] |"); String name = "Test_" + counter; - Pair irTree = generateIRTree(name); + var test = IRTreeGenerator.generateIRTree(name); System.out.printf(" %8d |", counter); long maxWaitTime = TimeUnit.MINUTES.toMillis(MINUTES_TO_WAIT); double generationTime = System.currentTimeMillis() - start; @@ -129,7 +73,7 @@ public class Automatic { start = System.currentTimeMillis(); Thread generatorThread = new Thread(() -> { for (TestsGenerator generator : generators) { - generator.accept(irTree.first, irTree.second); + generator.accept(test); } }); generatorThread.start(); diff --git a/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/ByteCodeGenerator.java b/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/ByteCodeGenerator.java index 87ca48c5acb..fac88a1833e 100644 --- a/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/ByteCodeGenerator.java +++ b/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/ByteCodeGenerator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,16 +47,17 @@ class ByteCodeGenerator extends TestsGenerator { } @Override - public void accept(IRNode mainClass, IRNode privateClasses) { - generateClassFiles(mainClass, privateClasses); - generateSeparateJtregHeader(mainClass); + public void accept(IRTreeGenerator.Test test) { + IRNode mainClass = test.mainClass(); + generateClassFiles(mainClass, test.privateClasses()); + generateSeparateJtregHeader(test.seed(), mainClass); compilePrinter(); generateGoldenOut(mainClass.getName()); } - private void generateSeparateJtregHeader(IRNode mainClass) { + private void generateSeparateJtregHeader(long seed, IRNode mainClass) { String mainClassName = mainClass.getName(); - writeFile(generatorDir, mainClassName + ".java", getJtregHeader(mainClassName)); + writeFile(generatorDir, mainClassName + ".java", getJtregHeader(mainClassName, seed)); } private void generateClassFiles(IRNode mainClass, IRNode privateClasses) { @@ -94,4 +95,17 @@ class ByteCodeGenerator extends TestsGenerator { ex.printStackTrace(); } } + + public static void main(String[] args) throws Exception { + ProductionParams.initializeFromCmdline(args); + IRTreeGenerator.initializeWithProductionParams(); + + ByteCodeGenerator generator = new ByteCodeGenerator(); + + for (String mainClass : ProductionParams.mainClassNames.value()) { + var test = IRTreeGenerator.generateIRTree(mainClass); + generator.generateClassFiles(test.mainClass(), test.privateClasses()); + generator.generateSeparateJtregHeader(test.seed(), test.mainClass()); + } + } } diff --git a/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/IRTreeGenerator.java b/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/IRTreeGenerator.java new file mode 100644 index 00000000000..b748fadde59 --- /dev/null +++ b/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/IRTreeGenerator.java @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.test.lib.jittester; + +import jdk.test.lib.jittester.factories.IRNodeBuilder; +import jdk.test.lib.jittester.types.TypeKlass; +import jdk.test.lib.jittester.utils.FixedTrees; +import jdk.test.lib.jittester.utils.PseudoRandom; + +/** + * Generates IR trees for fuzzy test classes. + */ +public class IRTreeGenerator { + + /** + * Generated Test - main and private classes trees along with random seed used for generation. + */ + public record Test (long seed, IRNode mainClass, IRNode privateClasses) {}; + + /** + * Generates IR trees for main and private classes. + * + * @param name main class name + * @return a pair (main class; private classes) + */ + public static Test generateIRTree(String name) { + long seed = PseudoRandom.getCurrentSeed(); + ProductionLimiter.resetTimer(); + //NB: SymbolTable is a widely-used singleton, hence all the locking. + SymbolTable.removeAll(); + TypeList.removeAll(); + + IRNodeBuilder builder = new IRNodeBuilder() + .setPrefix(name) + .setName(name) + .setLevel(0); + + Long complexityLimit = ProductionParams.complexityLimit.value(); + IRNode privateClasses = null; + if (!ProductionParams.disableClasses.value()) { + long privateClassComlexity = (long) (complexityLimit * PseudoRandom.random()); + try { + privateClasses = builder.setComplexityLimit(privateClassComlexity) + .getClassDefinitionBlockFactory() + .produce(); + } catch (ProductionFailedException ex) { + ex.printStackTrace(System.out); + } + } + long mainClassComplexity = (long) (complexityLimit * PseudoRandom.random()); + IRNode mainClass = null; + try { + mainClass = builder.setComplexityLimit(mainClassComplexity) + .getMainKlassFactory() + .produce(); + TypeKlass aClass = new TypeKlass(name); + mainClass.getChild(1).addChild(FixedTrees.generateMainOrExecuteMethod(aClass, true)); + mainClass.getChild(1).addChild(FixedTrees.generateMainOrExecuteMethod(aClass, false)); + } catch (ProductionFailedException ex) { + ex.printStackTrace(System.out); + } + return new Test(seed, mainClass, privateClasses); + } + + /** + * Initializes the generator from ProductionParams static class. + */ + public static void initializeWithProductionParams() { + TypesParser.parseTypesAndMethods(ProductionParams.classesFile.value(), + ProductionParams.excludeMethodsFile.value()); + if (ProductionParams.specificSeed.isSet()) { + PseudoRandom.setCurrentSeed(ProductionParams.specificSeed.value()); + } + } + +} diff --git a/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/JavaCodeGenerator.java b/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/JavaCodeGenerator.java index 7ca940fe531..16d02f91d8e 100644 --- a/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/JavaCodeGenerator.java +++ b/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/JavaCodeGenerator.java @@ -42,19 +42,20 @@ public class JavaCodeGenerator extends TestsGenerator { } @Override - public void accept(IRNode mainClass, IRNode privateClasses) { + public void accept(IRTreeGenerator.Test test) { + IRNode mainClass = test.mainClass(); String mainClassName = mainClass.getName(); - generateSources(mainClass, privateClasses); + generateSources(test.seed(), mainClass, test.privateClasses()); compilePrinter(); compileJavaFile(mainClassName); generateGoldenOut(mainClassName); } - private void generateSources(IRNode mainClass, IRNode privateClasses) { + private void generateSources(long seed, IRNode mainClass, IRNode privateClasses) { String mainClassName = mainClass.getName(); StringBuilder code = new StringBuilder(); JavaCodeVisitor vis = new JavaCodeVisitor(); - code.append(getJtregHeader(mainClassName)); + code.append(getJtregHeader(mainClassName, seed)); if (privateClasses != null) { code.append(privateClasses.accept(vis)); } @@ -79,7 +80,19 @@ public class JavaCodeGenerator extends TestsGenerator { } } - private static String[] generatePrerunAction(String mainClassName) { + protected static String[] generatePrerunAction(String mainClassName) { return new String[] {"@compile " + mainClassName + ".java"}; } + + public static void main(String[] args) throws Exception { + ProductionParams.initializeFromCmdline(args); + IRTreeGenerator.initializeWithProductionParams(); + + JavaCodeGenerator generator = new JavaCodeGenerator(); + + for (String mainClass : ProductionParams.mainClassNames.value()) { + var test = IRTreeGenerator.generateIRTree(mainClass); + generator.generateSources(test.seed(), test.mainClass(), test.privateClasses()); + } + } } diff --git a/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/ProductionParams.java b/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/ProductionParams.java index 69d489bf00d..afc526e81c7 100644 --- a/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/ProductionParams.java +++ b/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/ProductionParams.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,11 +23,15 @@ package jdk.test.lib.jittester; +import java.util.List; + import jdk.test.lib.jittester.utils.OptionResolver; import jdk.test.lib.jittester.utils.OptionResolver.Option; +import jdk.test.lib.jittester.utils.PseudoRandom; public class ProductionParams { + public static Option> mainClassNames = null; public static Option productionLimit = null; public static Option productionLimitSeconds = null; public static Option dataMemberLimit = null; @@ -72,6 +76,7 @@ public class ProductionParams { // workaraound: to reduce chance throwing ArrayIndexOutOfBoundsException public static Option chanceExpressionIndex = null; public static Option testbaseDir = null; + public static Option tempDir = null; public static Option numberOfTests = null; public static Option seed = null; public static Option specificSeed = null; @@ -81,6 +86,7 @@ public class ProductionParams { public static Option generatorsFactories = null; public static void register(OptionResolver optionResolver) { + mainClassNames = optionResolver.addRepeatingOption('k', "main-class", "", "Main class name"); productionLimit = optionResolver.addIntegerOption('l', "production-limit", 100, "Limit on steps in the production of an expression"); productionLimitSeconds = optionResolver.addIntegerOption("production-limit-seconds", 600, "Limit the time a test generation may take"); dataMemberLimit = optionResolver.addIntegerOption('v', "data-member-limit", 10, "Upper limit on data members"); @@ -124,6 +130,7 @@ public class ProductionParams { enableFinalizers = optionResolver.addBooleanOption("enable-finalizers", "Enable finalizers (for stress testing)"); chanceExpressionIndex = optionResolver.addIntegerOption("chance-expression-index", 0, "A non negative decimal integer used to restrict chane of generating expression in array index while creating or accessing by index"); testbaseDir = optionResolver.addStringOption("testbase-dir", ".", "Testbase dir"); + tempDir = optionResolver.addStringOption("temp-dir", ".", "Temp dir path"); numberOfTests = optionResolver.addIntegerOption('n', "number-of-tests", 0, "Number of test classes to generate"); seed = optionResolver.addStringOption("seed", "", "Random seed"); specificSeed = optionResolver.addLongOption('z', "specificSeed", 0L, "A seed to be set for specific test generation(regular seed still needed for initialization)"); @@ -132,4 +139,18 @@ public class ProductionParams { generators = optionResolver.addStringOption("generators", "", "Comma-separated list of generator names"); generatorsFactories = optionResolver.addStringOption("generatorsFactories", "", "Comma-separated list of generators factories class names"); } + + /** + * Initializes from the given command-line args + * + * @param args command-line arguments to use for initialization + */ + public static void initializeFromCmdline(String[] args) { + OptionResolver parser = new OptionResolver(); + Option propertyFileOpt = parser.addStringOption('p', "property-file", + "conf/default.properties", "File to read properties from"); + ProductionParams.register(parser); + parser.parse(args, propertyFileOpt); + PseudoRandom.reset(ProductionParams.seed.value()); + } } diff --git a/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/TestsGenerator.java b/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/TestsGenerator.java index 5d8ac107d6a..3eee8e5a021 100644 --- a/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/TestsGenerator.java +++ b/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/TestsGenerator.java @@ -30,13 +30,12 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.concurrent.TimeUnit; -import java.util.function.BiConsumer; +import java.util.function.Consumer; import java.util.function.Function; import java.util.stream.Collectors; import jdk.test.lib.jittester.types.TypeKlass; -import jdk.test.lib.jittester.utils.PseudoRandom; -public abstract class TestsGenerator implements BiConsumer { +public abstract class TestsGenerator implements Consumer { private static final int DEFAULT_JTREG_TIMEOUT = 120; protected static final String JAVA_BIN = getJavaPath(); protected static final String JAVAC = Paths.get(JAVA_BIN, "javac").toString(); @@ -121,9 +120,9 @@ public abstract class TestsGenerator implements BiConsumer { } } - protected String getJtregHeader(String mainClassName) { + protected String getJtregHeader(String mainClassName, long seed) { String synopsis = "seed = '" + ProductionParams.seed.value() + "'" - + ", specificSeed = '" + PseudoRandom.getCurrentSeed() + "'"; + + ", specificSeed = '" + seed + "'"; StringBuilder header = new StringBuilder(); header.append("/*\n * @test\n * @summary ") .append(synopsis) diff --git a/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/utils/OptionResolver.java b/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/utils/OptionResolver.java index 09f7f20695c..87207628df3 100644 --- a/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/utils/OptionResolver.java +++ b/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/utils/OptionResolver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -156,6 +156,12 @@ public class OptionResolver { return addBooleanOption(null, name, false, description); } + public Option> addRepeatingOption(Character key, String name, String defaultValue, String description) { + final Option> option = new RepeatingOption(key, name, defaultValue, description); + register(option); + return option; + } + private void register(Option option) { if (options.put("--" + option.longName, option) != null) { throw new RuntimeException("Option is already registered for key " + option.longName); @@ -264,6 +270,20 @@ public class OptionResolver { } } + private class RepeatingOption extends Option> { + List accumulated = new ArrayList(); + + RepeatingOption(Character s, String l, String v, String d) { + super(s, l, List.of(v), d); + } + + @Override + public List parseFromString(String arg) { + accumulated.add(arg); + return accumulated; + } + } + public Collection> getRegisteredOptions() { return Collections.unmodifiableSet(new LinkedHashSet<>(options.values())); } diff --git a/test/hotspot/jtreg/testlibrary_tests/ir_framework/tests/TestIRMatching.java b/test/hotspot/jtreg/testlibrary_tests/ir_framework/tests/TestIRMatching.java index f77be989421..f45f708070a 100644 --- a/test/hotspot/jtreg/testlibrary_tests/ir_framework/tests/TestIRMatching.java +++ b/test/hotspot/jtreg/testlibrary_tests/ir_framework/tests/TestIRMatching.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -75,7 +75,7 @@ public class TestIRMatching { runCheck(new String[] {"-XX:TLABRefillWasteFraction=50", "-XX:+UsePerfData", "-XX:+UseTLAB"}, BadFailOnConstraint.create(AndOr1.class, "test1(int)", 1, "CallStaticJava")); runCheck(new String[] {"-XX:TLABRefillWasteFraction=50", "-XX:-UsePerfData", "-XX:+UseTLAB"}, BadFailOnConstraint.create(AndOr1.class, "test2()", 1, "CallStaticJava")); - String[] allocMatches = { "MyClass", "wrapper for: _new_instance_Java" }; + String[] allocMatches = { "MyClass", "wrapper for: C2 Runtime new_instance" }; runCheck(BadFailOnConstraint.create(MultipleFailOnBad.class, "fail1()", 1, 1, "Store"), BadFailOnConstraint.create(MultipleFailOnBad.class, "fail1()", 1, 3, "Store"), GoodFailOnRegexConstraint.create(MultipleFailOnBad.class, "fail1()", 1, 2, 4), @@ -114,7 +114,7 @@ public class TestIRMatching { GoodRuleConstraint.create(Calls.class, "calls()", 3) ); - String[] allocArrayMatches = { "MyClass", "wrapper for: _new_array_Java"}; + String[] allocArrayMatches = { "MyClass", "wrapper for: C2 Runtime new_array"}; runCheck(BadFailOnConstraint.create(AllocArray.class, "allocArray()", 1, allocArrayMatches), BadFailOnConstraint.create(AllocArray.class, "allocArray()", 2, allocArrayMatches), GoodFailOnConstraint.create(AllocArray.class, "allocArray()", 3), diff --git a/test/hotspot/jtreg/vmTestbase/jit/escape/LockElision/MatMul/MatMul.java b/test/hotspot/jtreg/vmTestbase/jit/escape/LockElision/MatMul/MatMul.java index cf20b0df8a0..8d1a5fac9ae 100644 --- a/test/hotspot/jtreg/vmTestbase/jit/escape/LockElision/MatMul/MatMul.java +++ b/test/hotspot/jtreg/vmTestbase/jit/escape/LockElision/MatMul/MatMul.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -85,7 +85,7 @@ public class MatMul { } public int run() { - log = new Log(System.out, verbose); + log = new Log(System.out); log.display("Parallel matrix multiplication test"); Matrix a = Matrix.randomMatrix(dim); diff --git a/test/hotspot/jtreg/vmTestbase/metaspace/shrink_grow/ShrinkGrowTest/ShrinkGrowTest.java b/test/hotspot/jtreg/vmTestbase/metaspace/shrink_grow/ShrinkGrowTest/ShrinkGrowTest.java index f8a61c82d61..fffb10bbb3a 100644 --- a/test/hotspot/jtreg/vmTestbase/metaspace/shrink_grow/ShrinkGrowTest/ShrinkGrowTest.java +++ b/test/hotspot/jtreg/vmTestbase/metaspace/shrink_grow/ShrinkGrowTest/ShrinkGrowTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ * @library /vmTestbase /test/lib * @run main/othervm * -XX:MetaspaceSize=10m - * -XX:MaxMetaspaceSize=20m + * -XX:MaxMetaspaceSize=10m * -Xlog:gc*:gc.log * metaspace.shrink_grow.ShrinkGrowTest.ShrinkGrowTest */ @@ -52,7 +52,7 @@ import java.util.Map; /** * This is the main test in the metaspace shrink/grow series. * - * It tries to allocate all available metespace (loads new classes and keeps + * It tries to allocate all available metaspace (loads new classes and keeps * them in map), then checks that loading new classes causes OOM. * After that it does cleanup loaded classes and then expect the new classes * could be loaded again. @@ -87,7 +87,7 @@ public class ShrinkGrowTest { * @param classesToLoad - the limit of classes to load expecting OOM */ public ShrinkGrowTest(String name, int classesToLoad) { - whoAmI = name; + whoAmI = "%" + name + "%"; maxClassesToLoad = classesToLoad; } @@ -98,15 +98,15 @@ public class ShrinkGrowTest { * @param message text to print out */ void log(String message) { - System.out.println("%" + whoAmI + "% " + message); + System.out.println(whoAmI + message); } void throwFault(String message) { - throw new TestFault("%" + whoAmI + "% " + message); + throw new TestFault(whoAmI + message); } void throwFault(String message, Throwable t) { - throw new TestFault("%" + whoAmI + "% " + message, t); + throw new TestFault(whoAmI + message, t); } /** @@ -116,12 +116,12 @@ public class ShrinkGrowTest { public void run() { if (System.getProperty("requiresCompressedClassSpace") != null && !isCompressedClassSpaceAvailable()) { - System.out.println("Not applicalbe, Compressed Class Space is required"); + System.out.println("Not applicable, Compressed Class Space is required"); return; } try { - log("Bootstrapping string concatenation for " + whoAmI ); + log("Bootstrapping string concatenation"); go(); // The quest completed! Yahoo! setErrorMessage(null); @@ -150,7 +150,17 @@ public class ShrinkGrowTest { throwFault("We haven't cleaned metaspace yet!"); } catch (OutOfMemoryError error) { if (!isMetaspaceError(error)) { - throwFault("Hmm, we ran out metaspace. Metaspace error is still excpected here " + error, error); + throwFault("Hmm, we ran out metaspace. Metaspace error is still expected here " + error, error); + } + } catch(BootstrapMethodError bsme) { + Throwable cause = bsme.getCause(); + if (cause instanceof OutOfMemoryError) { + OutOfMemoryError error = (OutOfMemoryError)cause; + if (!isMetaspaceError(error)) { + throwFault("Hmm, we got BootstrapMethodError. Metaspace error is still expected as the cause " + error, bsme); + } + } else { + throwFault("We should be out of metaspace but got " + cause, bsme); } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/threadStartRequests/thrstartreq002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/threadStartRequests/thrstartreq002.java index 29d69b3174c..f7607b22e08 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/threadStartRequests/thrstartreq002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/threadStartRequests/thrstartreq002.java @@ -127,6 +127,7 @@ public class thrstartreq002 extends JDIBase { log2("debuggee launched"); } catch ( Exception e ) { log3("ERROR: Exception : " + e); + e.printStackTrace(System.out); log2(" test cancelled"); return FAILED; } @@ -170,6 +171,7 @@ public class thrstartreq002 extends JDIBase { vm.exit(PASS_BASE); } catch ( Exception e ) { log3("ERROR: Exception : " + e); + e.printStackTrace(System.out); } break; @@ -183,6 +185,7 @@ public class thrstartreq002 extends JDIBase { } } catch ( Exception e ) { log3("ERROR: Exception : " + e); + e.printStackTrace(System.out); } break; } @@ -211,9 +214,11 @@ public class thrstartreq002 extends JDIBase { return 1; } catch ( VMDisconnectedException e ) { log3("ERROR: VMDisconnectedException : " + e); + e.printStackTrace(System.out); return 2; } catch ( Exception e ) { log3("ERROR: Exception : " + e); + e.printStackTrace(System.out); return 1; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/LaunchingConnector/launchnosuspend/launchnosuspend001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/LaunchingConnector/launchnosuspend/launchnosuspend001.java index 015643f3a18..142d6387610 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/LaunchingConnector/launchnosuspend/launchnosuspend001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/LaunchingConnector/launchnosuspend/launchnosuspend001.java @@ -73,7 +73,6 @@ public class launchnosuspend001 { argHandler = new ArgumentHandler(args); log = new Log(this.out, argHandler); - //log.enableVerbose(true); } private PrintStream out; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClearFieldAccessWatch/clrfldw001.java b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClearFieldAccessWatch/clrfldw001.java index 5724f0ea9f4..ffdc26b7cb1 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClearFieldAccessWatch/clrfldw001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClearFieldAccessWatch/clrfldw001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,6 +23,8 @@ package nsk.jvmti.ClearFieldAccessWatch; +import jdk.test.lib.thread.TestThreadFactory; + import java.io.PrintStream; public class clrfldw001 { @@ -58,7 +60,7 @@ public class clrfldw001 { public static int run(String argv[], PrintStream ref) { clrfldw001 t = new clrfldw001(); clrfldw001a t_a = new clrfldw001a(); - clrfldw001b t_b = new clrfldw001b(); + Thread t_b = TestThreadFactory.newThread(new clrfldw001b()); for (int i = 0; i < 5; i++) { setWatch(i); } @@ -91,7 +93,7 @@ class clrfldw001a { int fld = 2; } -class clrfldw001b extends Thread { +class clrfldw001b implements Runnable { float fld4 = 6.0f; public void run() { clrfldw001.clearWatch(4); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClearFieldModificationWatch/clrfmodw001.java b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClearFieldModificationWatch/clrfmodw001.java index 9861f755f8f..7e1163d9102 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClearFieldModificationWatch/clrfmodw001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClearFieldModificationWatch/clrfmodw001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,6 +23,8 @@ package nsk.jvmti.ClearFieldModificationWatch; +import jdk.test.lib.thread.TestThreadFactory; + import java.io.PrintStream; public class clrfmodw001 { @@ -58,7 +60,7 @@ public class clrfmodw001 { public static int run(String argv[], PrintStream ref) { clrfmodw001 t = new clrfmodw001(); clrfmodw001a t_a = new clrfmodw001a(); - clrfmodw001b t_b = new clrfmodw001b(); + Thread t_b = TestThreadFactory.newThread(new clrfmodw001b()); for (int i = 0; i < 5; i++) { setWatch(i); } @@ -91,7 +93,7 @@ class clrfmodw001a { int fld = 2; } -class clrfmodw001b extends Thread { +class clrfmodw001b implements Runnable { float fld4; public void run() { clrfmodw001.clearWatch(4); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateThroughHeap/filter_tagged/HeapFilter.java b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateThroughHeap/filter_tagged/HeapFilter.java index 91f315ee7a9..b690955307e 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateThroughHeap/filter_tagged/HeapFilter.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateThroughHeap/filter_tagged/HeapFilter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -49,7 +49,6 @@ public class HeapFilter extends DebugeeClass { log = new Log(out, argHandler); testObjects = new Object[]{new TaggedClass(), new UntaggedClass()}; - log.enableVerbose(true); log.display("Verifying reachable objects."); status = checkStatus(status); testObjects = null; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldAccessWatch/setfldw001.java b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldAccessWatch/setfldw001.java index 03951bf9769..fd64c4d3323 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldAccessWatch/setfldw001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldAccessWatch/setfldw001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,6 +23,8 @@ package nsk.jvmti.SetFieldAccessWatch; +import jdk.test.lib.thread.TestThreadFactory; + import java.io.PrintStream; public class setfldw001 { @@ -62,7 +64,7 @@ public class setfldw001 { public static int run(String argv[], PrintStream ref) { setfldw001 t = new setfldw001(); setfldw001a t_a = new setfldw001a(); - setfldw001b t_b = new setfldw001b(); + Thread t_b = TestThreadFactory.newThread(new setfldw001b()); t_b.start(); synchronized (lock) { fld = fld1 + 1; @@ -111,7 +113,7 @@ class setfldw001a { int fld = 2; } -class setfldw001b extends Thread { +class setfldw001b implements Runnable { float fld4 = 6.0f; public void run() { synchronized (setfldw001.lock) { diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldModificationWatch/setfmodw001.java b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldModificationWatch/setfmodw001.java index a545a41f2fd..b79120e404c 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldModificationWatch/setfmodw001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetFieldModificationWatch/setfmodw001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,6 +23,8 @@ package nsk.jvmti.SetFieldModificationWatch; +import jdk.test.lib.thread.TestThreadFactory; + import java.io.PrintStream; public class setfmodw001 { @@ -62,7 +64,7 @@ public class setfmodw001 { public static int run(String argv[], PrintStream ref) { setfmodw001 t = new setfmodw001(); setfmodw001a t_a = new setfmodw001a(); - setfmodw001b t_b = new setfmodw001b(); + Thread t_b = TestThreadFactory.newThread(new setfmodw001b()); t_b.start(); synchronized (lock) { fld1 = fld1 + 1; @@ -111,7 +113,7 @@ class setfmodw001a { int fld = 2; } -class setfmodw001b extends Thread { +class setfmodw001b implements Runnable { float fld4; public void run() { synchronized (setfmodw001.lock) { diff --git a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/isCollectionUsageThresholdExceeded/isexceeded001.java b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/isCollectionUsageThresholdExceeded/isexceeded001.java index 702a5a79379..a9e75bb7cec 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/isCollectionUsageThresholdExceeded/isexceeded001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/isCollectionUsageThresholdExceeded/isexceeded001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,7 +40,6 @@ public class isexceeded001 { public static int run(String[] argv, PrintStream out) { ArgumentHandler argHandler = new ArgumentHandler(argv); Log log = new Log(out, argHandler); - log.enableVerbose(true); monitor = Monitor.getMemoryMonitor(log, argHandler); List pools = monitor.getMemoryPoolMBeans(); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdExceeded/isexceeded001.java b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdExceeded/isexceeded001.java index 390bfdd6251..a684c03e67a 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdExceeded/isexceeded001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdExceeded/isexceeded001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,7 +47,6 @@ public class isexceeded001 { public static int run(String[] argv, PrintStream out) { ArgumentHandler argHandler = new ArgumentHandler(argv); Log log = new Log(out, argHandler); - log.enableVerbose(true); // show log output MemoryMonitor monitor = Monitor.getMemoryMonitor(log, argHandler); List pools = monitor.getMemoryPoolMBeans(); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/ThreadController.java b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/ThreadController.java index 871b6d26aff..9d121b9a94f 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/ThreadController.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/ThreadController.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -663,9 +663,11 @@ class SleepingThread extends BaseThread { expectedMethods.add(Thread.class.getName() + ".currentCarrierThread"); expectedMethods.add(Thread.class.getName() + ".currentThread"); // jdk.internal.event.ThreadSleepEvent not accessible + expectedMethods.add("java.lang.Object."); + expectedMethods.add("jdk.internal.event.Event."); + expectedMethods.add("jdk.internal.event.ThreadSleepEvent."); expectedMethods.add("jdk.internal.event.ThreadSleepEvent."); expectedMethods.add("jdk.internal.event.ThreadSleepEvent.isEnabled"); - expectedMethods.add("jdk.internal.event.ThreadSleepEvent.isTurnedOn"); expectedMethods.add(SleepingThread.class.getName() + ".run"); switch (controller.invocationType) { diff --git a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/thread/SleepingThread.java b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/thread/SleepingThread.java index f23c16cd047..217c2cdfdc8 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/thread/SleepingThread.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/thread/SleepingThread.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,8 +41,10 @@ public class SleepingThread extends RecursiveMonitoringThread { "java.lang.Thread.beforeSleep", "java.lang.Thread.afterSleep", "java.util.concurrent.TimeUnit.toNanos", + "java.lang.Object.", + "jdk.internal.event.Event.", + "jdk.internal.event.ThreadSleepEvent.", "jdk.internal.event.ThreadSleepEvent.", - "jdk.internal.event.ThreadSleepEvent.isTurnedOn", "jdk.internal.event.ThreadSleepEvent.isEnabled", "nsk.monitoring.share.thread.SleepingThread.runInside" }; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem001.java b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem001.java index d698e5aec83..67f0d17f561 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/lowmem/lowmem001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -58,7 +58,7 @@ public class lowmem001 extends ThreadedGCTest { @Override public void run() { - Log log = new Log(System.out, true); + Log log = new Log(System.out); // System.err is duplicated into buffer // it should be empty MyStream stream = new MyStream(System.err); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/thread/strace001.java b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/thread/strace001.java index 632cebae8f8..0700032f6a7 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/thread/strace001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/thread/strace001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -150,8 +150,9 @@ public class strace001 { "java.lang.Thread.currentThread", "java.util.concurrent.TimeUnit.toNanos", "jdk.internal.event.ThreadSleepEvent.", + "java.lang.Object.", + "jdk.internal.event.Event.", "jdk.internal.event.ThreadSleepEvent.", - "jdk.internal.event.ThreadSleepEvent.isTurnedOn", "jdk.internal.event.ThreadSleepEvent.isEnabled" }; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/Log.java b/test/hotspot/jtreg/vmTestbase/nsk/share/Log.java index e5750182495..99467fc0334 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/share/Log.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/share/Log.java @@ -29,22 +29,15 @@ import java.io.IOException; import java.io.PrintStream; import java.io.PrintWriter; import java.io.StringReader; -import java.util.Enumeration; import java.util.HashMap; import java.util.Map; import java.util.Set; import java.util.HashSet; import java.util.Vector; -import nsk.share.test.LazyFormatString; /** - * This class helps to print test-execution trace messages - * and filter them when execution mode is not verbose. - *

                  - * Verbose mode if defined by providing -verbose command line - * option, handled by ArgumentParser. Use verbose() - * method to determine which mode is used. + * This class helps to print test-execution trace messages. *

                  * Log provides with two main methods to print messages: *

                    @@ -60,7 +53,6 @@ import nsk.share.test.LazyFormatString; * To provide printing messages from different sources into one log * with distinct prefixes use internal Log.Logger class. * - * @see #verbose() * @see #complain(String) * @see #display(String) * @see ArgumentParser @@ -72,18 +64,6 @@ public class Log { */ private PrintStream out = null; - /** - * Is log-mode verbose? - * Always enabled. - */ - private final boolean verbose = true; - - /** - * Should log messages prefixed with timestamps? - * Always enabled. - */ - private final boolean timestamp = true; - /** * Names for trace levels */ @@ -188,41 +168,15 @@ public class Log { /** * Incarnate new Log for the given stream; and - * either for verbose or for non-verbose mode accordingly to - * the given verbose key. - */ - public Log(PrintStream stream, boolean verbose) { - this(stream); - } - - /** - * Incarnate new Log for the given stream; and - * either for verbose or for non-verbose mode accordingly to * the given argsHandler. */ public Log(PrintStream stream, ArgumentParser argsParser) { - this(stream, argsParser.verbose()); + this(stream); traceLevel = argsParser.getTraceLevel(); } ///////////////////////////////////////////////////////////////// - /** - * Return true if log mode is verbose. - */ - public boolean verbose() { - return verbose; - } - - /** - * Enable or disable verbose mode for printing messages. - */ - public void enableVerbose(boolean enable) { - if (!enable) { - throw new RuntimeException("The non-verbose logging is not supported."); - } - } - public int getTraceLevel() { return traceLevel; } @@ -266,9 +220,6 @@ public class Log { @Deprecated public synchronized void println(String message) { doPrint(message); - if (!verbose()) { - keepLog(composeLine(message)); - } } /** @@ -282,9 +233,6 @@ public class Log { */ @Deprecated public synchronized void comment(String message) { - if (!verbose()) { - doPrint(message); - } } /** @@ -314,17 +262,10 @@ public class Log { } /** - * Print message to the assigned output stream, - * if log mode is verbose. The message will be lost, - * if execution mode is non-verbose, and there is no error messages - * printed. + * Print message to the assigned output stream. */ public synchronized void display(Object message) { - if (verbose()) { - doPrint(message.toString()); - } else { - keepLog(composeLine(message.toString())); - } + doPrint(message.toString()); } /** @@ -333,15 +274,6 @@ public class Log { * into errorsBuffer. */ public synchronized void complain(Object message) { - if (!verbose()) { - PrintStream stream = findOutStream(); - stream.println("#> "); - stream.println("#> WARNING: switching log to verbose mode,"); - stream.println("#> because error is complained"); - stream.println("#> "); - stream.flush(); - enableVerbose(true); - } String msgStr = message.toString(); printError(msgStr); @@ -406,10 +338,7 @@ public class Log { ///////////////////////////////////////////////////////////////// /** - * Redirect log to the given stream, and switch - * log mode to verbose. - * Prints errors summary to current stream, cancel current stream - * and switches to new stream. Turns on verbose mode for new stream. + * Redirect log to the given stream. * * @deprecated This method is obsolete. */ @@ -430,20 +359,6 @@ public class Log { logBuffer.clear(); } - /** - * Print all messages from log buffer which were hidden because - * of non-verbose mode, - */ - private synchronized void flushLogBuffer() { - if (!logBuffer.isEmpty()) { - PrintStream stream = findOutStream(); - for (int i = 0; i < logBuffer.size(); i++) { - stream.println(logBuffer.elementAt(i)); - } - stream.flush(); - } - } - /** * Return out stream if defined or Sytem.err otherwise; * print a warning message when System.err is used first time. @@ -468,18 +383,15 @@ public class Log { * Compose line to print possible prefixing it with timestamp. */ private String composeLine(String message) { - if (timestamp) { - long time = System.currentTimeMillis(); - long ms = time % 1000; - time /= 1000; - long secs = time % 60; - time /= 60; - long mins = time % 60; - time /= 60; - long hours = time % 24; - return "[" + hours + ":" + mins + ":" + secs + "." + ms + "] " + message; - } - return message; + long time = System.currentTimeMillis(); + long ms = time % 1000; + time /= 1000; + long secs = time % 60; + time /= 60; + long mins = time % 60; + time /= 60; + long hours = time % 24; + return "[" + hours + ":" + mins + ":" + secs + "." + ms + "] " + message; } /** @@ -513,13 +425,6 @@ public class Log { } } - /** - * Keep the given log message into logBuffer. - */ - private synchronized void keepLog(String message) { - logBuffer.addElement(message); - } - /** * This class can be used as a base for each class that use Log * for print messages and errors. diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/aod/AODTestRunner.java b/test/hotspot/jtreg/vmTestbase/nsk/share/aod/AODTestRunner.java index bde40cc7e20..9899c762a7a 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/share/aod/AODTestRunner.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/share/aod/AODTestRunner.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -68,7 +68,7 @@ public class AODTestRunner { protected AODRunnerArgParser argParser; protected AODTestRunner(String[] args) { - log = new Log(System.out, true); + log = new Log(System.out); argParser = createArgParser(args); } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/aod/AbstractJarAgent.java b/test/hotspot/jtreg/vmTestbase/nsk/share/aod/AbstractJarAgent.java index 3fa3141a8cd..fb02327a422 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/share/aod/AbstractJarAgent.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/share/aod/AbstractJarAgent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -157,7 +157,7 @@ abstract public class AbstractJarAgent { if (name == null) throw new TestBug("Agent name wasn't specified"); - log = new Log(System.out, true); + log = new Log(System.out); } /* diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/aod/DummyTargetApplication.java b/test/hotspot/jtreg/vmTestbase/nsk/share/aod/DummyTargetApplication.java index bb726453e9b..c8fb3bf2663 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/share/aod/DummyTargetApplication.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/share/aod/DummyTargetApplication.java @@ -39,7 +39,7 @@ it sends signal that it is ready for test and waits for signal permitting finish */ public class DummyTargetApplication { - protected Log log = new Log(System.out, true); + protected Log log = new Log(System.out); protected AODTargetArgParser argParser; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/aod/TargetApplicationWaitingAgents.java b/test/hotspot/jtreg/vmTestbase/nsk/share/aod/TargetApplicationWaitingAgents.java index 6f80033dff5..0b5acfb24ba 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/share/aod/TargetApplicationWaitingAgents.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/share/aod/TargetApplicationWaitingAgents.java @@ -213,7 +213,7 @@ public class TargetApplicationWaitingAgents { if (targetApplicationInitialized) throw new TestBug("TargetApplication already initialized"); - log = new Log(System.out, true); + log = new Log(System.out); argParser = createArgParser(args); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/Memory.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/Memory.java index f5c70671e5e..244bcf423c5 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/Memory.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/Memory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -150,12 +150,9 @@ public final class Memory { * @return length of array */ public static int getArrayLength(long memory, long objectSize) { - int referenceSize = getReferenceSize(); int arrayExtraSize = getArrayExtraSize(); - return (int) Math.min( - (memory - arrayExtraSize) / (objectSize + referenceSize), - Integer.MAX_VALUE - ); + return (int) Math.min((memory - arrayExtraSize) / objectSize, + Integer.MAX_VALUE); } /** @@ -166,7 +163,7 @@ public final class Memory { * @return size of array */ public static long getArraySize(int length, long objectSize) { - return getObjectExtraSize() + length * (objectSize + getReferenceSize()); + return getArrayExtraSize() + length * objectSize; } /** diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/jvmti/JVMTITest.java b/test/hotspot/jtreg/vmTestbase/nsk/share/jvmti/JVMTITest.java index c8d26b6ea1f..d9b847e110d 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/share/jvmti/JVMTITest.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/share/jvmti/JVMTITest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -87,7 +87,7 @@ public class JVMTITest { AgentsAttacher attacher = new AgentsAttacher(Utils.findCurrentVMIdUsingJPS(jdkPath), agents, - new Log(System.out, true)); + new Log(System.out)); attacher.attachAgents(); } } diff --git a/test/hotspot/jtreg/vmTestbase/vm/compiler/coverage/parentheses/Parentheses.java b/test/hotspot/jtreg/vmTestbase/vm/compiler/coverage/parentheses/Parentheses.java index 66546e9b13f..219af51045a 100644 --- a/test/hotspot/jtreg/vmTestbase/vm/compiler/coverage/parentheses/Parentheses.java +++ b/test/hotspot/jtreg/vmTestbase/vm/compiler/coverage/parentheses/Parentheses.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -69,7 +69,7 @@ public class Parentheses { public void run() throws IOException, ReflectiveOperationException { - log = new Log(System.out, verbose); + log = new Log(System.out); InstructionSequence instructionSequence = null; for (int i = 0; i < iterations * stressOptions.getIterationsFactor(); i++) { diff --git a/test/jdk/ProblemList-Xcomp.txt b/test/jdk/ProblemList-Xcomp.txt index 6e8953c521e..8963ead2bce 100644 --- a/test/jdk/ProblemList-Xcomp.txt +++ b/test/jdk/ProblemList-Xcomp.txt @@ -1,5 +1,5 @@ # -# Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -28,5 +28,5 @@ ############################################################################# java/lang/invoke/MethodHandles/CatchExceptionTest.java 8146623 generic-all -java/lang/management/MemoryMXBean/CollectionUsageThreshold.java 8318668 generic-all -com/sun/jdi/InterruptHangTest.java 8306679,8043571 generic-all +java/foreign/TestUpcallStress.java 8341584 generic-all +com/sun/jdi/InterruptHangTest.java 8043571 generic-all diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index 697fe82187c..034830a2575 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -121,11 +121,17 @@ java/awt/Focus/AutoRequestFocusTest/AutoRequestFocusToFrontTest.java 6848406 gen java/awt/Focus/AutoRequestFocusTest/AutoRequestFocusSetVisibleTest.java 6848407 generic-all java/awt/Frame/MaximizedUndecorated/MaximizedUndecorated.java 8022302 generic-all java/awt/Frame/RestoreToOppositeScreen/RestoreToOppositeScreen.java 8286840 linux-all +java/awt/Frame/InitialIconifiedTest.java 7144049,8203920 macosx-all,linux-all +java/awt/Frame/ShapeNotSetSometimes/ShapeNotSetSometimes.java 8341370 macosx-all +java/awt/Frame/FocusTest.java 8341480 macosx-all java/awt/FileDialog/FileDialogIconTest/FileDialogIconTest.java 8160558 windows-all java/awt/event/MouseWheelEvent/InfiniteRecursion/InfiniteRecursion.java 8060176 windows-all,macosx-all java/awt/event/MouseWheelEvent/InfiniteRecursion/InfiniteRecursion_1.java 8060176 windows-all,macosx-all java/awt/dnd/URIListBetweenJVMsTest/URIListBetweenJVMsTest.java 8171510 macosx-all java/awt/dnd/MissingDragExitEventTest/MissingDragExitEventTest.java 8288839 windows-x64 +java/awt/dnd/DragExitBeforeDropTest.java 8242805 macosx-all +java/awt/dnd/DragThresholdTest.java 8076299 macosx-all +java/awt/dnd/CustomDragCursorTest.java 8242805 macosx-all java/awt/Focus/ChoiceFocus/ChoiceFocus.java 8169103 windows-all,macosx-all java/awt/Focus/ClearLwQueueBreakTest/ClearLwQueueBreakTest.java 8198618 macosx-all java/awt/Focus/ConsumeNextKeyTypedOnModalShowTest/ConsumeNextKeyTypedOnModalShowTest.java 6986252 macosx-all @@ -133,7 +139,12 @@ java/awt/Focus/MouseClickRequestFocusRaceTest/MouseClickRequestFocusRaceTest.jav java/awt/Focus/NoAutotransferToDisabledCompTest/NoAutotransferToDisabledCompTest.java 7152980 macosx-all java/awt/Focus/ToFrontFocusTest/ToFrontFocus.java 7156130 linux-all java/awt/Focus/WrongKeyTypedConsumedTest/WrongKeyTypedConsumedTest.java 8169096 macosx-all +java/awt/Focus/TestDisabledAutoTransfer.java 8159871 macosx-all,windows-all +java/awt/Focus/TestDisabledAutoTransferSwing.java 6962362 windows-all +java/awt/Focus/ActivateOnProperAppContextTest.java 8136516 macosx-all +java/awt/Focus/FocusPolicyTest.java 7160904 linux-all java/awt/EventQueue/6980209/bug6980209.java 8198615 macosx-all +java/awt/EventQueue/PushPopDeadlock/PushPopDeadlock.java 8024034 generic-all java/awt/grab/EmbeddedFrameTest1/EmbeddedFrameTest1.java 7080150 macosx-all java/awt/event/InputEvent/EventWhenTest/EventWhenTest.java 8168646 generic-all java/awt/Mixing/AWT_Mixing/HierarchyBoundsListenerMixingTest.java 8049405 macosx-all @@ -190,6 +201,9 @@ java/awt/event/KeyEvent/ExtendedKeyCode/ExtendedKeyCodeTest.java 8169476 windows java/awt/event/KeyEvent/KeyChar/KeyCharTest.java 8169474,8224055 macosx-all,windows-all java/awt/event/KeyEvent/KeyTyped/CtrlASCII.java 8298910 linux-all +java/awt/dnd/DnDRemoveFocusOwnerCrashTest.java 8242805 macosx-all +java/awt/dnd/DnDCursorCrashTest.java 8242805 macosx-all +java/awt/dnd/DnDClipboardDeadlockTest.java 8079553 linux-all java/awt/dnd/URIListToFileListBetweenJVMsTest/URIListToFileListBetweenJVMsTest.java 8194947 generic-all java/awt/Frame/FramesGC/FramesGC.java 8079069 macosx-all java/awt/TrayIcon/ActionCommand/ActionCommand.java 8150540 windows-all @@ -204,6 +218,9 @@ java/awt/TrayIcon/TrayIconEvents/TrayIconEventsTest.java 8150540,8295300 windows java/awt/TrayIcon/TrayIconMouseTest/TrayIconMouseTest.java 8150540 windows-all java/awt/TrayIcon/TrayIconPopup/TrayIconPopupClickTest.java 8150540 windows-all,macosx-all java/awt/TrayIcon/TrayIconPopup/TrayIconPopupTest.java 8150540 windows-all +java/awt/TrayIcon/MouseMoveTest.java 8203053 linux-all +java/awt/TrayIcon/TrayIconKeySelectTest.java 8341557 windows-all +java/awt/TrayIcon/TrayIconTest.java 8341559 generic-all java/awt/Window/ShapedAndTranslucentWindows/SetShapeAndClick.java 8197936 macosx-all java/awt/Window/ShapedAndTranslucentWindows/SetShapeDynamicallyAndClick.java 8013450 macosx-all @@ -427,6 +444,7 @@ java/awt/SplashScreen/MultiResolutionSplash/unix/UnixMultiResolutionSplashTest.j java/awt/Robot/AcceptExtraMouseButtons/AcceptExtraMouseButtons.java 7107528 linux-all,macosx-all java/awt/Mouse/MouseDragEvent/MouseDraggedTest.java 8080676 linux-all java/awt/Mouse/MouseModifiersUnitTest/MouseModifiersInKeyEvent.java 8157147 linux-all,windows-all,macosx-all +java/awt/Mouse/MouseClickCount.java 8017182 macosx-all java/awt/Toolkit/ToolkitPropertyTest/ToolkitPropertyTest_Enable.java 6847163 linux-all java/awt/xembed/server/RunTestXEmbed.java 7034201 linux-all java/awt/Modal/ModalFocusTransferTests/FocusTransferDialogsDocModalTest.java 8164473 linux-all @@ -460,7 +478,12 @@ java/awt/KeyboardFocusmanager/ConsumeNextMnemonicKeyTypedTest/ConsumeNextMnemoni java/awt/Window/GetScreenLocation/GetScreenLocationTest.java 8225787 linux-x64 java/awt/Dialog/MakeWindowAlwaysOnTop/MakeWindowAlwaysOnTop.java 8266243 macosx-aarch64 +java/awt/Dialog/FileDialogUserFilterTest.java 8001142 generic-all + java/awt/dnd/BadSerializationTest/BadSerializationTest.java 8277817 linux-x64,windows-x64 +java/awt/dnd/DragSourceMotionListenerTest.java 8225131 windows-all +java/awt/dnd/RejectDragTest.java 7124259 macosx-all +java/awt/dnd/DnDHTMLToOutlookTest/DnDHTMLToOutlookTest.java 8027424 generic-all java/awt/GraphicsDevice/DisplayModes/UnknownRefrshRateTest.java 8286436 macosx-aarch64 java/awt/image/multiresolution/MultiresolutionIconTest.java 8291979 linux-x64,windows-all java/awt/event/SequencedEvent/MultipleContextsFunctionalTest.java 8305061 macosx-x64 @@ -470,9 +493,6 @@ sun/java2d/DirectX/OnScreenRenderingResizeTest/OnScreenRenderingResizeTest.java java/awt/Window/8159168/SetShapeTest.java 8274106 macosx-aarch64 java/awt/image/multiresolution/MultiResolutionJOptionPaneIconTest.java 8274106 macosx-aarch64 -# This test fails on macOS 14 -java/awt/Choice/SelectNewItemTest/SelectNewItemTest.java 8324782 macosx-all - # Wayland related java/awt/FullScreen/FullscreenWindowProps/FullscreenWindowProps.java 8280991 linux-x64 @@ -515,6 +535,8 @@ java/io/pathNames/GeneralWin32.java 8180264 windows- com/sun/management/OperatingSystemMXBean/GetProcessCpuLoad.java 8030957 aix-all com/sun/management/OperatingSystemMXBean/GetSystemCpuLoad.java 8030957 aix-all +com/sun/management/DiagnosticCommandMBean/DcmdMBeanPermissionsTest.java 8340401 windows-all + java/lang/management/MemoryMXBean/Pending.java 8158837 generic-all java/lang/management/MemoryMXBean/PendingAllGC.sh 8158837 generic-all @@ -560,16 +582,19 @@ java/net/Socket/asyncClose/Race.java 8317801 aix-ppc6 # jdk_nio +java/nio/Buffer/LimitDirectMemory.java 8340728 generic-all + java/nio/channels/AsynchronousSocketChannel/StressLoopback.java 8211851 aix-ppc64 java/nio/channels/Channels/SocketChannelStreams.java 8317838 aix-ppc64 -java/nio/channels/DatagramChannel/AdaptorMulticasting.java 8308807 aix-ppc64 +java/nio/channels/DatagramChannel/AdaptorMulticasting.java 8308807,8144003 aix-ppc64,macosx-all java/nio/channels/DatagramChannel/AfterDisconnect.java 8308807 aix-ppc64 java/nio/channels/DatagramChannel/ManySourcesAndTargets.java 8264385 macosx-aarch64 java/nio/channels/DatagramChannel/Unref.java 8233437 generic-all - -java/nio/file/Path/ToRealPath.java 8315273 windows-all +java/nio/channels/DatagramChannel/BasicMulticastTests.java 8144003 macosx-all +java/nio/channels/DatagramChannel/MulticastSendReceiveTests.java 8144003 macosx-all +java/nio/channels/DatagramChannel/Promiscuous.java 8144003 macosx-all ############################################################################ @@ -659,7 +684,6 @@ javax/swing/AbstractButton/6711682/bug6711682.java 8060765 windows-all,macosx-al javax/swing/JFileChooser/6396844/TwentyThousandTest.java 8198003 generic-all javax/swing/JFileChooser/8194044/FileSystemRootTest.java 8327236 windows-all javax/swing/JPopupMenu/6800513/bug6800513.java 7184956 macosx-all -javax/swing/JTabbedPane/8007563/Test8007563.java 8051591 generic-all javax/swing/JTabbedPane/4624207/bug4624207.java 8064922 macosx-all javax/swing/SwingUtilities/TestBadBreak/TestBadBreak.java 8160720 generic-all javax/swing/JFileChooser/6798062/bug6798062.java 8146446 windows-all @@ -716,6 +740,7 @@ com/sun/jdi/InvokeHangTest.java 8218463 linux-al ############################################################################ # jdk_util +java/util/zip/CloseInflaterDeflaterTest.java 8339216 linux-s390x ############################################################################ @@ -787,3 +812,11 @@ java/awt/Focus/AppletInitialFocusTest/AppletInitialFocusTest1.java 8256289 windo java/awt/FullScreen/TranslucentWindow/TranslucentWindow.java 8258103 linux-all java/awt/Focus/FrameMinimizeTest/FrameMinimizeTest.java 8016266 linux-x64 java/awt/Frame/SizeMinimizedTest.java 8305915 linux-x64 +java/awt/PopupMenu/PopupHangTest.java 8340022 windows-all +java/awt/Focus/MinimizeNonfocusableWindowTest.java 8024487 windows-all +java/awt/Focus/InactiveFocusRace.java 8023263 linux-all +java/awt/List/HandlingKeyEventIfMousePressedTest.java 6848358 macosx-all,windows-all +java/awt/Checkbox/CheckboxBoxSizeTest.java 8340870 windows-all +java/awt/Checkbox/CheckboxIndicatorSizeTest.java 8340870 windows-all +java/awt/Checkbox/CheckboxNullLabelTest.java 8340870 windows-all +java/awt/dnd/WinMoveFileToShellTest.java 8341665 windows-all diff --git a/test/jdk/TEST.ROOT b/test/jdk/TEST.ROOT index 67eceaa5a3e..c8db6b89a71 100644 --- a/test/jdk/TEST.ROOT +++ b/test/jdk/TEST.ROOT @@ -100,7 +100,8 @@ requires.properties= \ vm.jvmci.enabled \ vm.jvmti \ vm.cpu.features \ - docker.support \ + container.support \ + systemd.support \ release.implementor \ jdk.containerized \ jdk.foreign.linker diff --git a/test/jdk/TEST.groups b/test/jdk/TEST.groups index 97b355fbea6..d51fcec733b 100644 --- a/test/jdk/TEST.groups +++ b/test/jdk/TEST.groups @@ -262,6 +262,7 @@ jdk_text = \ jdk_management = \ java/lang/management \ + jdk/management \ com/sun/management \ sun/management \ jdk/internal/agent @@ -287,6 +288,7 @@ jdk_launcher = \ jdk_loom = \ com/sun/management/HotSpotDiagnosticMXBean \ com/sun/management/ThreadMXBean \ + jdk/management/VirtualThreadSchedulerMXBean \ java/lang/Thread \ java/lang/ThreadGroup \ java/lang/management/ThreadMXBean \ @@ -379,7 +381,8 @@ jdk_svc = \ jdk_foreign = \ java/foreign \ jdk/internal/reflect/CallerSensitive/CheckCSMs.java \ - -java/foreign/TestMatrix.java + -java/foreign/TestMatrix.java \ + -java/foreign/TestUpcallStress.java jdk_vector = \ jdk/incubator/vector diff --git a/test/jdk/build/AbsPathsInImage.java b/test/jdk/build/AbsPathsInImage.java index 712f990507d..229094a0920 100644 --- a/test/jdk/build/AbsPathsInImage.java +++ b/test/jdk/build/AbsPathsInImage.java @@ -40,7 +40,7 @@ import java.util.zip.ZipInputStream; * @bug 8226346 * @summary Check all output files for absolute path fragments * @requires !vm.debug - * @run main AbsPathsInImage + * @run main/othervm -Xmx900m AbsPathsInImage */ public class AbsPathsInImage { diff --git a/test/jdk/com/sun/jdi/EATests.java b/test/jdk/com/sun/jdi/EATests.java index adeb2174143..b2a2cad49db 100644 --- a/test/jdk/com/sun/jdi/EATests.java +++ b/test/jdk/com/sun/jdi/EATests.java @@ -158,6 +158,19 @@ * -XX:+DoEscapeAnalysis -XX:+EliminateAllocations -XX:+EliminateLocks -XX:+EliminateNestedLocks * -XX:LockingMode=0 * -XX:GuaranteedAsyncDeflationInterval=1000 + * + * @bug 8341819 + * @comment Regression test for re-locking racing with deflation with LM_LIGHTWEIGHT. + * @run driver EATests + * -XX:+UnlockDiagnosticVMOptions + * -Xms256m -Xmx256m + * -Xbootclasspath/a:. + * -XX:CompileCommand=dontinline,*::dontinline_* + * -XX:+WhiteBoxAPI + * -Xbatch + * -XX:+DoEscapeAnalysis -XX:+EliminateAllocations -XX:+EliminateLocks -XX:+EliminateNestedLocks + * -XX:LockingMode=2 + * -XX:GuaranteedAsyncDeflationInterval=1 */ /** diff --git a/test/jdk/com/sun/jndi/dns/ConfigTests/Timeout.java b/test/jdk/com/sun/jndi/dns/ConfigTests/Timeout.java index 90a2a7b9815..e03923b6c34 100644 --- a/test/jdk/com/sun/jndi/dns/ConfigTests/Timeout.java +++ b/test/jdk/com/sun/jndi/dns/ConfigTests/Timeout.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,7 +29,6 @@ import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.SocketTimeoutException; import java.time.Duration; -import java.time.Instant; import jdk.test.lib.net.URIBuilder; @@ -40,7 +39,7 @@ import jdk.test.lib.net.URIBuilder; * number of retries. * @library ../lib/ /test/lib * @modules java.base/sun.security.util - * @run main Timeout + * @run main/othervm Timeout */ public class Timeout extends DNSTestBase { @@ -48,8 +47,12 @@ public class Timeout extends DNSTestBase { private static final int TIMEOUT = 250; // try 5 times per server private static final int RETRIES = 5; + // DnsClient retries again with increased timeout if left + // timeout is less than this value, and max retry attempts + // is not reached + private static final int DNS_CLIENT_MIN_TIMEOUT = 0; - private Instant startTime; + private long startTime; public Timeout() { setLocalServer(false); @@ -81,7 +84,7 @@ public class Timeout extends DNSTestBase { setContext(new InitialDirContext(env())); // Any request should fail after timeouts have expired. - startTime = Instant.now(); + startTime = System.nanoTime(); context().getAttributes(""); throw new RuntimeException( @@ -92,28 +95,35 @@ public class Timeout extends DNSTestBase { @Override public boolean handleException(Exception e) { if (e instanceof CommunicationException) { - Duration elapsedTime = Duration.between(startTime, Instant.now()); + Duration elapsedTime = Duration.ofNanos(System.nanoTime() - startTime); if (!(((CommunicationException) e) .getRootCause() instanceof SocketTimeoutException)) { return false; } - Duration expectedTime = Duration.ofMillis(TIMEOUT) - .multipliedBy((1 << RETRIES) - 1); + Duration minAllowedTime = Duration.ofMillis(TIMEOUT) + .multipliedBy((1 << RETRIES) - 1) + .minus(Duration.ofMillis(DNS_CLIENT_MIN_TIMEOUT * RETRIES)); + Duration maxAllowedTime = Duration.ofMillis(TIMEOUT) + .multipliedBy((1 << RETRIES) - 1) + // max allowed timeout value is set to 2 * expected timeout + .multipliedBy(2); + DNSTestUtils.debug("Elapsed (ms): " + elapsedTime.toMillis()); - DNSTestUtils.debug("Expected (ms): " + expectedTime.toMillis()); + String expectedRangeMsg = "%s - %s" + .formatted(minAllowedTime.toMillis(), maxAllowedTime.toMillis()); + DNSTestUtils.debug("Expected range (ms): " + expectedRangeMsg); // Check that elapsed time is as long as expected, and - // not more than 50% greater. - if (elapsedTime.compareTo(expectedTime) >= 0 && - elapsedTime.multipliedBy(2) - .compareTo(expectedTime.multipliedBy(3)) <= 0) { + // not more than 2 times greater. + if (elapsedTime.compareTo(minAllowedTime) >= 0 && + elapsedTime.compareTo(maxAllowedTime) <= 0) { System.out.println("elapsed time is as long as expected."); return true; } throw new RuntimeException( - "Failed: timeout in " + elapsedTime.toMillis() - + " ms, expected" + expectedTime.toMillis() + "ms"); + "Failed: timeout in " + elapsedTime.toMillis() + + " ms, expected to be in a range (ms): " + expectedRangeMsg); } return super.handleException(e); diff --git a/test/jdk/com/sun/jndi/dns/ConfigTests/TimeoutWithEmptyDatagrams.java b/test/jdk/com/sun/jndi/dns/ConfigTests/TimeoutWithEmptyDatagrams.java new file mode 100644 index 00000000000..9fb8954c99c --- /dev/null +++ b/test/jdk/com/sun/jndi/dns/ConfigTests/TimeoutWithEmptyDatagrams.java @@ -0,0 +1,196 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import jdk.test.lib.net.URIBuilder; + +import javax.naming.CommunicationException; +import javax.naming.Context; +import javax.naming.directory.InitialDirContext; +import java.io.IOException; +import java.net.DatagramPacket; +import java.net.DatagramSocket; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.net.SocketAddress; +import java.net.SocketTimeoutException; +import java.time.Duration; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicReference; + +/* + * @test + * @bug 8339538 + * @summary Tests that DnsClient correctly calculates left timeout in + * presence of empty datagram packets. + * @library ../lib /test/lib + * @modules java.base/sun.security.util + * @run main/othervm TimeoutWithEmptyDatagrams + */ + +public class TimeoutWithEmptyDatagrams extends DNSTestBase { + // initial timeout = 1/4 sec + private static final int TIMEOUT = 250; + // try 5 times per server + private static final int RETRIES = 5; + // DnsClient retries again with increased timeout if left + // timeout is less than this value, and max retry attempts + // is not reached + private static final int DNS_CLIENT_MIN_TIMEOUT = 0; + + public TimeoutWithEmptyDatagrams() { + setLocalServer(false); + } + + public static void main(String[] args) throws Exception { + new TimeoutWithEmptyDatagrams().run(args); + } + + /* + * Tests that we can set the initial UDP timeout interval and the + * number of retries. + */ + @Override + public void runTest() throws Exception { + // Create a DatagramSocket and bind it to the loopback address to simulate + // UDP DNS server that doesn't respond + try (DatagramSocket ds = new DatagramSocket(new InetSocketAddress( + InetAddress.getLoopbackAddress(), 0))) { + CountDownLatch gotClientAddress = new CountDownLatch(1); + AtomicReference clientAddress = new AtomicReference<>(); + AtomicBoolean stopTestThreads = new AtomicBoolean(); + + String allQuietUrl = URIBuilder.newBuilder() + .scheme("dns") + .loopback() + .port(ds.getLocalPort()) + .build() + .toString(); + + // Run a virtual thread that receives client request packets and extracts + // sender address from them. + Thread receiverThread = Thread.ofVirtual().start(() -> { + while (!stopTestThreads.get()) { + try { + DatagramPacket packet = new DatagramPacket(new byte[1024], 1024); + ds.receive(packet); + System.err.println("Got packet from " + packet.getSocketAddress()); + boolean hasClientAddress = clientAddress.get() != null; + clientAddress.set(packet.getSocketAddress()); + if (!hasClientAddress) { + gotClientAddress.countDown(); + } + } catch (IOException e) { + if (!stopTestThreads.get()) { + throw new RuntimeException(e); + } else { + return; + } + } + } + }); + + // Run a virtual thread that will send an empty packets via server socket + // that should wake up the selector on a client side. + Thread wakeupThread = Thread.ofVirtual().start(() -> { + try { + long timeout = Math.max(1, TIMEOUT / 4); + // wait for a first packet on a server socket + gotClientAddress.await(); + + // Now start sending empty packets until we get a notification + // from client part to stop sending + while (!stopTestThreads.get()) { + System.err.println("Server timeout = " + timeout); + TimeUnit.MILLISECONDS.sleep(timeout); + System.err.println("Sending wakeup packet to " + clientAddress.get()); + var wakeupPacket = new DatagramPacket(new byte[0], 0); + wakeupPacket.setSocketAddress(clientAddress.get()); + ds.send(wakeupPacket); + timeout += Math.max(1, timeout / 2); + } + } catch (IOException ioe) { + throw new RuntimeException("Test machinery failure", ioe); + } catch (InterruptedException e) { + throw new RuntimeException("Interrupted during wakeup packets sending"); + } finally { + System.err.println("Server thread exiting"); + } + }); + + long startTime = 0; + try { + env().put(Context.PROVIDER_URL, allQuietUrl); + env().put("com.sun.jndi.dns.timeout.initial", String.valueOf(TIMEOUT)); + env().put("com.sun.jndi.dns.timeout.retries", String.valueOf(RETRIES)); + setContext(new InitialDirContext(env())); + + startTime = System.nanoTime(); + context().getAttributes(""); + + // Any request should fail after timeouts have expired. + throw new RuntimeException("Failed: getAttributes succeeded unexpectedly"); + } catch (CommunicationException ce) { + // We need to catch CommunicationException outside the test framework + // flow because wakeupThread.join() can take some time that could + // increase measured timeout + long endTime = System.nanoTime(); + Duration elapsedTime = Duration.ofNanos(endTime - startTime); + if (ce.getRootCause() instanceof SocketTimeoutException) { + + Duration minAllowedTime = Duration.ofMillis(TIMEOUT) + .multipliedBy((1 << RETRIES) - 1) + .minus(Duration.ofMillis(DNS_CLIENT_MIN_TIMEOUT * RETRIES)); + Duration maxAllowedTime = Duration.ofMillis(TIMEOUT) + .multipliedBy((1 << RETRIES) - 1) + // max allowed timeout value is set to 2 * expected timeout + .multipliedBy(2); + + DNSTestUtils.debug("Elapsed (ms): " + elapsedTime.toMillis()); + String expectedRangeMsg = "%s - %s" + .formatted(minAllowedTime.toMillis(), maxAllowedTime.toMillis()); + DNSTestUtils.debug("Expected range (ms): " + expectedRangeMsg); + + // Check that elapsed time is as long as expected, and + // not more than 2 times greater. + if (elapsedTime.compareTo(minAllowedTime) >= 0 && + elapsedTime.compareTo(maxAllowedTime) <= 0) { + System.out.println("elapsed time is as long as expected."); + } else { + throw new RuntimeException( + "Failed: timeout in " + elapsedTime.toMillis() + + " ms, expected to be in a range (ms): " + expectedRangeMsg); + } + } else { + throw ce; + } + } finally { + stopTestThreads.set(true); + wakeupThread.join(); + ds.close(); + receiverThread.join(); + } + } + } +} diff --git a/test/jdk/com/sun/management/DiagnosticCommandMBean/DcmdMBeanTest.java b/test/jdk/com/sun/management/DiagnosticCommandMBean/DcmdMBeanTest.java index 3cc9f40b895..ba6fffd0670 100644 --- a/test/jdk/com/sun/management/DiagnosticCommandMBean/DcmdMBeanTest.java +++ b/test/jdk/com/sun/management/DiagnosticCommandMBean/DcmdMBeanTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 7150256 + * @bug 7150256 8338603 * @summary Basic Test for the DiagnosticCommandMBean * @author Frederic Parain, Shanliang JIANG * @@ -68,10 +68,14 @@ public class DcmdMBeanTest { System.out.println("Description:" + info.getDescription()); MBeanOperationInfo[] opInfo = info.getOperations(); System.out.println("Operations:"); + int operationFailures = 0; for (int i = 0; i < opInfo.length; i++) { - printOperation(opInfo[i]); + operationFailures += printOperation(opInfo[i]); System.out.println("\n@@@@@@\n"); } + if (operationFailures > 0) { + throw new RuntimeException("FAILED. " + operationFailures + " operations found with non-standard parameter types."); + } } finally { try { cc.close(); @@ -83,7 +87,12 @@ public class DcmdMBeanTest { System.out.println("Test passed"); } - static void printOperation(MBeanOperationInfo info) { + /** + * Print an Operation, and check for any non-standard parameter types. + * Return the number of failed parameters, so the caller can signal to fail the test. + */ + static int printOperation(MBeanOperationInfo info) { + int failures = 0; System.out.println("Name: "+info.getName()); System.out.println("Description: "+info.getDescription()); System.out.println("Return Type: "+info.getReturnType()); @@ -100,8 +109,16 @@ public class DcmdMBeanTest { Descriptor desc3 = (Descriptor)desc2.getFieldValue(desc2.getFieldNames()[j]); for(int k=0; k */ - permission java.io.FilePermission "<>", "read,write,delete"; + /* + * To read configuration file in META-INF/services, write/delete .attach_pid, + * and read symbolic link of /proc/self/ns/mnt. + */ + permission java.io.FilePermission "<>", "read,write,delete,readlink"; }; diff --git a/test/jdk/java/awt/Button/BadActionEventTest/BadActionEventTest.java b/test/jdk/java/awt/Button/BadActionEventTest/BadActionEventTest.java new file mode 100644 index 00000000000..53aac7ab787 --- /dev/null +++ b/test/jdk/java/awt/Button/BadActionEventTest/BadActionEventTest.java @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 4530087 + * @summary Test if double-clicking causes ActionEvent on underlying button + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual BadActionEventTest + */ + +import java.awt.Button; +import java.awt.Color; +import java.awt.FileDialog; +import java.awt.Frame; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public class BadActionEventTest implements ActionListener { + private static Button showBtn; + private static Button listBtn; + + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + 1) Click on 'Show File Dialog' to bring up the FileDialog window. + (If necessary, change to a directory with files (not just directories) in it.) + 2) Move the FileDialog so that one of the file names (again, a file, NOT a directory) in the list is + directly over the 'ActionListener' button. + 3) Double-click on the file name over the button. The FileDialog will disappear. + 4) If the 'ActionListener' button receives an ActionEvent, the test fails and a + message to that effect will be printed. + Otherwise, the test passes. + """; + + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .columns(45) + .testUI(BadActionEventTest::createUI) + .logArea(2) + .build() + .awaitAndCheck(); + } + + private static Frame createUI() { + Frame frame = new Frame("BadActionEventTest"); + frame.setLayout(new GridLayout(1, 2)); + frame.setSize(400, 200); + showBtn = new Button("Show File Dialog"); + listBtn = new Button("ActionListener"); + showBtn.setSize(200, 200); + listBtn.setSize(200, 200); + showBtn.addActionListener(new BadActionEventTest()); + listBtn.addActionListener(new BadActionEventTest()); + frame.add(showBtn); + frame.add(listBtn); + return frame; + } + + @Override + public void actionPerformed(ActionEvent e) { + if (e.getSource() == showBtn) { + FileDialog fd = new FileDialog(new Frame()); + fd.setVisible(true); + } else if (e.getSource() == listBtn) { + listBtn.setBackground(Color.red); + listBtn.setLabel("TEST FAILS!"); + PassFailJFrame.log("*TEST FAILS!* ActionListener got ActionEvent! *TEST FAILS!*"); + } + } +} diff --git a/test/jdk/java/awt/CardLayout/RemoveComponentTest/RemoveComponentTest.java b/test/jdk/java/awt/CardLayout/RemoveComponentTest/RemoveComponentTest.java new file mode 100644 index 00000000000..0a23a989533 --- /dev/null +++ b/test/jdk/java/awt/CardLayout/RemoveComponentTest/RemoveComponentTest.java @@ -0,0 +1,166 @@ +/* + * Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4546123 + * @summary CardLayout becomes unusable after deleting an element + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual RemoveComponentTest + */ + +import java.awt.BorderLayout; +import java.awt.CardLayout; +import java.awt.Color; +import java.awt.Frame; +import java.awt.Insets; +import java.awt.Menu; +import java.awt.MenuBar; +import java.awt.MenuItem; +import java.awt.Panel; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.JLabel; +import javax.swing.JPanel; + +public class RemoveComponentTest { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + You should see a frame titled "Test Frame For + RemoveComponentTest". Try to select a few different panels from + the second menu. Make sure your last choice is the red panel. + Then click close (in first menu). After that you should be able + to select any panels except red one. + If that is the case, the test passes. Otherwise, the test failed. + """; + + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .columns(35) + .testUI(RemoveComponentTest::createUI) + .logArea(5) + .build() + .awaitAndCheck(); + } + + public static Frame createUI() { + TestFrame frame = new TestFrame(); + frame.setSize(200, 200); + return frame; + } +} + +class TestFrame extends Frame implements ActionListener { + public Panel aPanel; + public TestPanel pageRed; + public TestPanel pageGreen; + public TestPanel pageBlue; + public String currentSelection = ""; + + public MenuItem mi; + public CardLayout theCardLayout; + + + public TestFrame() { + super("Test Frame For RemoveComponentTest"); + + setBackground(Color.black); + setLayout(new BorderLayout(5, 5)); + + MenuBar mb = new MenuBar(); + + Menu fileMenu = new Menu("File"); + Menu pageMenu = new Menu("Pages"); + + mi = new MenuItem("Close"); + mi.addActionListener(this); + fileMenu.add(mi); + + mi = new MenuItem("Red"); + mi.addActionListener(this); + pageMenu.add(mi); + + mi = new MenuItem("Green"); + mi.addActionListener(this); + pageMenu.add(mi); + + mi = new MenuItem("Blue"); + mi.addActionListener(this); + pageMenu.add(mi); + + mb.add(fileMenu); + mb.add(pageMenu); + + setMenuBar(mb); + + aPanel = new Panel(); + theCardLayout = new CardLayout(); + + aPanel.setLayout(theCardLayout); + + pageRed = new TestPanel("PageRed", Color.red); + pageGreen = new TestPanel("PageGreen", Color.green); + pageBlue = new TestPanel("PageBlue", Color.blue); + + aPanel.add("PageRed", pageRed); + aPanel.add("PageGreen", pageGreen); + aPanel.add("PageBlue", pageBlue); + + add("Center", aPanel); + setSize(getPreferredSize()); + } + + public Insets getInsets() { + return new Insets(47, 9, 9, 9); + } + + public void actionPerformed(ActionEvent e) { + if (e.getActionCommand().equals("Red")) { + theCardLayout.show(aPanel, "PageRed"); + currentSelection = "PageRed"; + } else if (e.getActionCommand().equals("Green")) { + theCardLayout.show(aPanel, "PageGreen"); + } else if (e.getActionCommand().equals("Blue")) { + theCardLayout.show(aPanel, "PageBlue"); + } else if (e.getActionCommand().equals("Close")) { + PassFailJFrame.log("Closing"); + + if (currentSelection.equals("PageRed")) { + PassFailJFrame.log("Remove page red"); + theCardLayout.removeLayoutComponent(pageRed); + } + } + } +} + +class TestPanel extends JPanel { + private String pageName; + + TestPanel(String pageName, Color color) { + setBackground(color); + add(new JLabel(pageName)); + } +} diff --git a/test/jdk/java/awt/Checkbox/CheckboxBoxSizeTest.java b/test/jdk/java/awt/Checkbox/CheckboxBoxSizeTest.java new file mode 100644 index 00000000000..0d500e5daa1 --- /dev/null +++ b/test/jdk/java/awt/Checkbox/CheckboxBoxSizeTest.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 java.awt.Checkbox; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.Panel; + +/* + * @test + * @bug 4410522 + * @requires (os.family == "windows") + * @summary The box size of the Checkbox control should be the same as + * in Windows native applications. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual CheckboxBoxSizeTest + */ + +public class CheckboxBoxSizeTest { + private static final String INSTRUCTIONS = """ + This test must be run at UI Scale of 100% AND + 150% or greater. + Compare the size of box to any of native apps on Windows + (Eg. Font Dialog Settings on Word). + They should be the same. + + If the sizes are same Press PASS, else Press FAIL. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("CheckboxBoxSizeTest Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(35) + .testUI(CheckboxBoxSizeTest::createTestUI) + .build() + .awaitAndCheck(); + } + + private static Frame createTestUI() { + Frame frame = new Frame("CheckboxBoxSizeTest"); + Panel panel = new Panel(new FlowLayout()); + Checkbox checkbox = new Checkbox("Compare the box size"); + panel.add(checkbox); + frame.add(panel); + frame.pack(); + return frame; + } +} diff --git a/test/jdk/java/awt/Checkbox/CheckboxCheckerScalingTest.java b/test/jdk/java/awt/Checkbox/CheckboxCheckerScalingTest.java index a07620dbd38..f2ceba47d0d 100644 --- a/test/jdk/java/awt/Checkbox/CheckboxCheckerScalingTest.java +++ b/test/jdk/java/awt/Checkbox/CheckboxCheckerScalingTest.java @@ -46,40 +46,47 @@ import javax.imageio.ImageIO; public class CheckboxCheckerScalingTest { private static Frame frame; private static Checkbox checkbox; - private static BufferedImage imageAfterChecked; - private static volatile boolean checkmarkFound = false; + private static volatile Point point; + private static boolean checkmarkFound = false; + private static final int TOLERANCE = 5; + private static final int COLOR_CHECK_THRESHOLD = 8; + private static int colorCounter = 0; public static void main(String[] args) throws Exception { System.setProperty("sun.java2d.uiScale", "2"); Robot robot = new Robot(); + try { EventQueue.invokeAndWait(() -> { - frame = new Frame("ComboBox checker scaling test"); + frame = new Frame("CheckBox checker scaling test"); checkbox = new Checkbox("one"); checkbox.setState(true); frame.add(checkbox); + frame.setLocationRelativeTo(null); frame.pack(); frame.setVisible(true); }); robot.waitForIdle(); robot.delay(100); - EventQueue.invokeAndWait(() -> { - Point point = checkbox.getLocationOnScreen(); - Rectangle rect = new Rectangle(point.x + 5, point.y + 7, 8, 8); - imageAfterChecked = robot.createScreenCapture(rect); - - check: { - for (int i = 0; i < imageAfterChecked.getHeight(); i++) { - for (int j = 0; j < imageAfterChecked.getWidth(); j++) { - if (Color.black.getRGB() == imageAfterChecked.getRGB(i, j)) { + EventQueue.invokeAndWait(() -> point = checkbox.getLocationOnScreen()); + Rectangle rect = new Rectangle(point.x + 5, point.y + 7, 8, 8); + BufferedImage imageAfterChecked = robot.createScreenCapture(rect); + check: + { + for (int i = 0; i < imageAfterChecked.getHeight(); i++) { + for (int j = 0; j < imageAfterChecked.getWidth(); j++) { + Color pixelColor = new Color(imageAfterChecked.getRGB(i, j)); + if (compareColor(pixelColor)) { + if (++colorCounter >= COLOR_CHECK_THRESHOLD) { checkmarkFound = true; break check; } } + } } - }); + } if (!checkmarkFound) { try { @@ -99,4 +106,10 @@ public class CheckboxCheckerScalingTest { }); } } + + private static boolean compareColor(Color c) { + return Math.abs(Color.black.getRed() - c.getRed()) < TOLERANCE && + Math.abs(Color.black.getGreen() - c.getGreen()) < TOLERANCE && + Math.abs(Color.black.getBlue() - c.getBlue()) < TOLERANCE; + } } diff --git a/test/jdk/java/awt/Checkbox/CheckboxIndicatorSizeTest.java b/test/jdk/java/awt/Checkbox/CheckboxIndicatorSizeTest.java new file mode 100644 index 00000000000..3456e7e040d --- /dev/null +++ b/test/jdk/java/awt/Checkbox/CheckboxIndicatorSizeTest.java @@ -0,0 +1,168 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Checkbox; +import java.awt.CheckboxGroup; +import java.awt.Color; +import java.awt.Font; +import java.awt.Frame; +import java.awt.GridLayout; +import java.awt.Label; +import java.awt.Menu; +import java.awt.MenuBar; +import java.awt.MenuItem; +import java.awt.Panel; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +/* + * @test + * @bug 4090493 + * @summary Test for Checkbox indicator size + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual CheckboxIndicatorSizeTest + */ + +public class CheckboxIndicatorSizeTest implements ActionListener { + private static final String INSTRUCTIONS = """ + Indicator size of Checkbox depends + on the platform font used to render the label. + + In the frame you can see a group of checkboxes + and radio buttons. + Verify that all checkboxes and radio buttons have + indicators of the same size and proportional to + the uiScale and/or font-size. + + Use menu to change the font size and the indicators + should scale proportionally. + + If there is a bug, the checkbox/radiobutton with + dingbats label will have a smaller indicator. + + Press PASS if the above conditions are true else Press FAIL. + """; + private static Frame frame; + private static Panel testPanel; + + public static void main(String[] args) throws Exception { + + CheckboxIndicatorSizeTest obj = new CheckboxIndicatorSizeTest(); + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 3) + .columns(60) + .testUI(obj::createAndShowUI) + .build() + .awaitAndCheck(); + } + + private Frame createAndShowUI() { + frame = new Frame("CheckboxIndicatorSizeTest"); + + testPanel = new Panel(new GridLayout(0, 1)); + testPanel.setFont(new Font("Dialog", Font.PLAIN, 12)); + frame.add(testPanel); + + MenuBar menuBar = new MenuBar(); + Menu fontSizeMenu = new Menu("FontSize"); + + MenuItem size10 = new MenuItem("10"); + size10.addActionListener(this); + fontSizeMenu.add(size10); + + MenuItem size12 = new MenuItem("12"); + size12.addActionListener(this); + fontSizeMenu.add(size12); + + MenuItem size14 = new MenuItem("14"); + size14.addActionListener(this); + fontSizeMenu.add(size14); + + MenuItem size18 = new MenuItem("18"); + size18.addActionListener(this); + fontSizeMenu.add(size18); + + MenuItem size24 = new MenuItem("24"); + size24.addActionListener(this); + fontSizeMenu.add(size24); + + MenuItem size36 = new MenuItem("36"); + size36.addActionListener(this); + fontSizeMenu.add(size36); + + menuBar.add(fontSizeMenu); + frame.setMenuBar(menuBar); + + Checkbox cbEnglishOnly + = new Checkbox("Toggle", true); + Checkbox cbDingbatsOnly + = new Checkbox("\u274a\u274b\u274c\u274d", true); + Checkbox cbEnglishDingbats + = new Checkbox("Toggle \u274a\u274d", true); + Checkbox cbDingbatsEnglish + = new Checkbox("\u274a\u274d toggle", true); + + CheckboxGroup radioGroup = new CheckboxGroup(); + Checkbox rbEnglishOnly + = new Checkbox("Radio", true, radioGroup); + Checkbox rbDingbatsOnly + = new Checkbox("\u274a\u274b\u274c\u274d", false, radioGroup); + Checkbox rbEnglishDingbats + = new Checkbox("Radio \u274a\u274d", false, radioGroup); + Checkbox rbDingbatsEnglish + = new Checkbox("\u274a\u274d radio", false, radioGroup); + + Label cbLabel = new Label("Checkboxes"); + cbLabel.setBackground(Color.YELLOW); + testPanel.add(cbLabel); + testPanel.add(cbEnglishOnly); + testPanel.add(cbDingbatsOnly); + testPanel.add(cbEnglishDingbats); + testPanel.add(cbDingbatsEnglish); + + Label rbLabel = new Label("Radio buttons"); + rbLabel.setBackground(Color.YELLOW); + testPanel.add(rbLabel); + testPanel.add(rbEnglishOnly); + testPanel.add(rbDingbatsOnly); + testPanel.add(rbEnglishDingbats); + testPanel.add(rbDingbatsEnglish); + + frame.pack(); + return frame; + } + + @Override + public void actionPerformed(ActionEvent e) { + String sizeStr = e.getActionCommand(); + int size = Integer.parseInt(sizeStr); + Font oldFont = testPanel.getFont(); + Font newFont = new Font(oldFont.getName(), oldFont.getStyle(), size); + testPanel.setFont(newFont); + frame.pack(); + frame.setVisible(true); + } +} diff --git a/test/jdk/java/awt/Checkbox/CheckboxNullLabelTest.java b/test/jdk/java/awt/Checkbox/CheckboxNullLabelTest.java new file mode 100644 index 00000000000..c5cb7c27829 --- /dev/null +++ b/test/jdk/java/awt/Checkbox/CheckboxNullLabelTest.java @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.BorderLayout; +import java.awt.Checkbox; +import java.awt.CheckboxGroup; +import java.awt.Color; +import java.awt.Font; +import java.awt.Frame; +import java.awt.Panel; + +/* + * @test + * @bug 4383735 + * @summary Checkbox buttons are too small with java 1.3 and 1.4 + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual CheckboxNullLabelTest + */ + +public class CheckboxNullLabelTest { + private static final String INSTRUCTIONS = """ + Please look at the frame titled 'CheckboxNullLabelTest'. + Check if all the check boxes in each group + (of 3 check boxes) have the same size. + + If the size of labeled check box is NOT the same as + the size of non-labeled Press FAIL otherwise Press PASS. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 1) + .columns(35) + .testUI(CheckboxNullLabelTest::createAndShowUI) + .build() + .awaitAndCheck(); + } + + private static Frame createAndShowUI() { + Frame f = new Frame("CheckboxNullLabelTest"); + f.setLayout(new BorderLayout()); + f.add(new CheckboxTest(Color.gray, new Font(null, 0, 12)), "North"); + f.add(new CheckboxTest(Color.green, new Font(null, 0, 18)), "South"); + f.add(new CheckboxTest(Color.red, new Font(null, 0, 24)), "East"); + f.add(new CheckboxTest(Color.white, new Font(null, 0, 30)), "West"); + f.add(new CheckboxTest(f.getBackground(), new Font(null, 0, 36)), "Center"); + f.setSize(600, 450); + return f; + } + + private static class CheckboxTest extends Panel { + Checkbox cb1, cb2, cb3; + + CheckboxTest(Color background, Font font) { + setBackground(background); + CheckboxGroup cbg = new CheckboxGroup(); + + cb1 = new Checkbox(null, cbg, true); + cb1.setFont(font); + + cb2 = new Checkbox("", cbg, true); + cb2.setFont(font); + + cb3 = new Checkbox("Label", cbg, false); + cb3.setFont(font); + + add(cb1); + add(cb2); + add(cb3); + } + } +} diff --git a/test/jdk/java/awt/Checkbox/CheckboxPreferredSizeTest.java b/test/jdk/java/awt/Checkbox/CheckboxPreferredSizeTest.java new file mode 100644 index 00000000000..dd61b52aaed --- /dev/null +++ b/test/jdk/java/awt/Checkbox/CheckboxPreferredSizeTest.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Checkbox; +import java.awt.Color; +import java.awt.Font; +import java.awt.Frame; + +/* + * @test + * @bug 4304049 + * @summary tests that Checkbox fits into its preferred size entirely + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual CheckboxPreferredSizeTest + */ + +public class CheckboxPreferredSizeTest { + private static final String INSTRUCTIONS = """ + As the test starts, ensure that the + whole checkbox with all its text is visible. + If the checkbox is entirely visible, press PASS else, + press FAIL. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 1) + .columns(35) + .testUI(CheckboxPreferredSizeTest::createAndShowUI) + .build() + .awaitAndCheck(); + } + + private static Frame createAndShowUI() { + Frame frame = new Frame("Checkbox Preferred Size Test"); + frame.setBackground(Color.BLUE); + Checkbox box = new Checkbox("Checkbox_With_Some_Size"); + box.setFont(new Font("Helvetica", Font.PLAIN, 36)); + box.setBackground(Color.RED); + frame.add(box); + frame.pack(); + return frame; + } +} diff --git a/test/jdk/java/awt/Checkbox/DynamicChangeTest/DynamicChangeTest.java b/test/jdk/java/awt/Checkbox/DynamicChangeTest/DynamicChangeTest.java new file mode 100644 index 00000000000..b62255efa45 --- /dev/null +++ b/test/jdk/java/awt/Checkbox/DynamicChangeTest/DynamicChangeTest.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6225679 + * @summary Tests that checkbox changes into radiobutton dynamically + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual DynamicChangeTest + */ + +import java.awt.Checkbox; +import java.awt.CheckboxGroup; +import java.awt.Frame; +import java.awt.GridLayout; + +public class DynamicChangeTest { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + This test is primarily for Windows platform, but should pass + on other platforms as well. Ensure that 'This is checkbox' is + checkbox, and 'This is radiobutton' is radiobutton. + If it is so, press pass else fail. + """; + + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(35) + .testUI(DynamicChangeTest::createUI) + .build() + .awaitAndCheck(); + } + + public static Frame createUI() { + Frame f = new Frame("Dynamic Change Checkbox Test"); + f.setSize(200, 200); + + f.setLayout(new GridLayout(2, 1)); + Checkbox ch1 = new Checkbox("This is checkbox", + new CheckboxGroup(), true); + f.add(ch1); + Checkbox ch2 = new Checkbox("This is radiobutton", null, true); + f.add(ch2); + + ch1.setCheckboxGroup(null); + ch2.setCheckboxGroup(new CheckboxGroup()); + return f; + } +} diff --git a/test/jdk/java/awt/Choice/CheckChoiceTest.java b/test/jdk/java/awt/Choice/CheckChoiceTest.java new file mode 100644 index 00000000000..3e2e06b1c95 --- /dev/null +++ b/test/jdk/java/awt/Choice/CheckChoiceTest.java @@ -0,0 +1,92 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.BorderLayout; +import java.awt.Choice; +import java.awt.Frame; +import javax.swing.JComponent; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; + +/* + * @test + * @bug 4151949 + * @summary Verifies that Components are reshaped to their preferred size + * when their Container is packed. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual CheckChoiceTest + */ + +public class CheckChoiceTest { + + private static JComponent componentToFocus; + + private static final String INSTRUCTIONS = """ + Verify that the widths of the Choice components are all the same + and that none is the minimum possible size. + (The Choices should be at least as wide as the Frame.) + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame passFailJFrame = PassFailJFrame.builder() + .title("CheckChoiceTest Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 3) + .columns(45) + .testUI(CheckChoiceTest::createAndShowUI) + .splitUIBottom(CheckChoiceTest::createComponentToFocus) + .build(); + + // focus away from the window with choices + Thread.sleep(300); + SwingUtilities.invokeAndWait(() -> componentToFocus.requestFocus()); + + passFailJFrame.awaitAndCheck(); + } + + private static JComponent createComponentToFocus() { + componentToFocus = new JPanel(); + return componentToFocus; + } + + private static Frame createAndShowUI() { + Frame f = new Frame("Check Choice"); + f.setLayout(new BorderLayout()); + + Choice choice1 = new Choice(); + Choice choice2 = new Choice(); + Choice choice3 = new Choice(); + + f.add(choice1, BorderLayout.NORTH); + f.add(choice3, BorderLayout.CENTER); + f.add(choice2, BorderLayout.SOUTH); + f.pack(); + + choice1.add("I am Choice, yes I am : 0"); + choice2.add("I am the same, yes I am : 0"); + choice3.add("I am the same, yes I am : 0"); + + return f; + } +} diff --git a/test/jdk/java/awt/Choice/ChoiceBigTest.java b/test/jdk/java/awt/Choice/ChoiceBigTest.java new file mode 100644 index 00000000000..be82ed2a40d --- /dev/null +++ b/test/jdk/java/awt/Choice/ChoiceBigTest.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 java.awt.Choice; +import java.awt.Frame; +import java.awt.FlowLayout; +import java.awt.Window; + +/* + * @test + * @bug 4288285 + * @summary Verifies choice works with many items + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual ChoiceBigTest + */ + +public class ChoiceBigTest { + private static final String INSTRUCTIONS = """ + Click the Choice button, press Pass if: + + - all looks good. + - if you can select the item 1000 + + Otherwise press Fail. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("ChoiceBigTest Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 3) + .columns(45) + .testUI(ChoiceBigTest::createAndShowUI) + .build() + .awaitAndCheck(); + } + + private static Window createAndShowUI() { + Frame frame = new Frame("Check Choice"); + frame.setLayout(new FlowLayout()); + Choice choice = new Choice(); + frame.setSize(400, 200); + for (int i = 1; i < 1001; ++i) { + choice.add("I am Choice, yes I am : " + i); + } + frame.add(choice); + return frame; + } +} diff --git a/test/jdk/java/awt/Choice/ChoiceDragEventsInside.java b/test/jdk/java/awt/Choice/ChoiceDragEventsInside.java new file mode 100644 index 00000000000..dde773f1928 --- /dev/null +++ b/test/jdk/java/awt/Choice/ChoiceDragEventsInside.java @@ -0,0 +1,210 @@ +/* + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6251983 6722236 + * @summary MouseDragged events not triggered for Choice when dragging it with left mouse button + * @key headful + * @run main ChoiceDragEventsInside + */ + +import java.awt.Choice; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.Point; +import java.awt.Robot; +import java.awt.event.InputEvent; +import java.awt.event.KeyEvent; +import java.awt.event.MouseEvent; +import java.awt.event.MouseMotionAdapter; +import java.lang.reflect.InvocationTargetException; + +public class ChoiceDragEventsInside extends Frame { + Robot robot; + Choice choice1; + Point pt; + Dimension size; + volatile boolean mouseDragged = false; + volatile boolean mouseDraggedOutside = false; + + public void setupUI() { + setTitle("Choce Drag Events Inside"); + choice1 = new Choice(); + for (int i = 1; i < 50; i++) { + choice1.add("item-0" + i); + } + choice1.setForeground(Color.red); + choice1.setBackground(Color.red); + choice1.addMouseMotionListener(new MouseMotionAdapter() { + public void mouseMoved(MouseEvent me) { + System.out.println(me); + } + + public void mouseDragged(MouseEvent me) { + System.out.println(me); + mouseDragged = true; + if (me.getY() < 0) { + mouseDraggedOutside = true; + } + } + } + ); + add(choice1); + setLayout(new FlowLayout()); + setSize(200, 200); + setLocationRelativeTo(null); + setVisible(true); + validate(); + } + + public void start() { + try { + robot = new Robot(); + robot.setAutoWaitForIdle(true); + robot.setAutoDelay(50); + robot.delay(100); + EventQueue.invokeAndWait(() -> { + pt = choice1.getLocationOnScreen(); + size = choice1.getSize(); + }); + testDragInsideChoice(InputEvent.BUTTON1_MASK); + testDragInsideChoiceList(InputEvent.BUTTON1_MASK); + testDragOutsideChoice(InputEvent.BUTTON1_MASK); + } catch (Throwable e) { + throw new RuntimeException("Test failed. Exception thrown: " + e); + } + } + + public void testDragInsideChoice(int button) { + robot.mouseMove(pt.x + size.width / 2, pt.y + size.height / 2); + robot.delay(100); + robot.mousePress(button); + robot.mouseRelease(button); + robot.delay(200); + robot.mousePress(button); + robot.mouseRelease(button); + robot.delay(200); + + //close opened choice + robot.keyPress(KeyEvent.VK_ESCAPE); + robot.keyRelease(KeyEvent.VK_ESCAPE); + robot.delay(200); + + robot.mouseMove(pt.x + size.width / 4, pt.y + size.height / 2); + robot.mousePress(button); + + dragMouse(pt.x + size.width / 4, pt.y + size.height / 2, + pt.x + size.width * 3 / 4, pt.y + size.height / 2); + robot.mouseRelease(button); + robot.delay(200); + if (!mouseDragged) { + throw new RuntimeException("Test failed. Choice should generate MouseDragged events inside Choice itself"); + } else { + System.out.println("Stage 1 passed. Choice generates MouseDragged events inside Choice itself"); + } + mouseDragged = false; + //close opened choice + robot.keyPress(KeyEvent.VK_ESCAPE); + robot.keyRelease(KeyEvent.VK_ESCAPE); + robot.delay(200); + } + + public void testDragInsideChoiceList(int button) { + robot.mouseMove(pt.x + size.width / 2, pt.y + size.height / 2); + robot.delay(100); + robot.mousePress(button); + robot.mouseRelease(button); + robot.delay(200); + + robot.mouseMove(pt.x + size.width / 2, pt.y + 5 * size.height); + robot.delay(200); + robot.mousePress(button); + + dragMouse(pt.x + size.width / 2, pt.y + 5 * size.height, + pt.x + size.width / 2, pt.y + 8 * size.height); + robot.mouseRelease(button); + robot.delay(200); + if (mouseDragged) { + throw new RuntimeException("Test failed. Choice shouldn't generate MouseDragged events inside Choice's list"); + } else { + System.out.println("Stage 2 passed. Choice doesn't generate MouseDragged events inside Choice's list"); + } + robot.keyPress(KeyEvent.VK_ESCAPE); + robot.keyRelease(KeyEvent.VK_ESCAPE); + robot.delay(200); + mouseDragged = false; + } + + public void testDragOutsideChoice(int button) { + pt = choice1.getLocationOnScreen(); + robot.mouseMove(pt.x + size.width / 2, pt.y + size.height / 2); + robot.delay(100); + + robot.mousePress(button); + //drag mouse outside of Choice + dragMouse(pt.x + size.width / 2, pt.y + size.height / 2, + pt.x + size.width / 2, pt.y - 3 * size.height); + robot.mouseRelease(button); + robot.delay(200); + if (!mouseDragged || !mouseDraggedOutside) { + throw new RuntimeException("Test failed. Choice should generate MouseDragged events outside Choice"); + } else { + System.out.println("Stage 3 passed. Choice generates MouseDragged events outside Choice"); + } + robot.keyPress(KeyEvent.VK_ESCAPE); + robot.keyRelease(KeyEvent.VK_ESCAPE); + robot.delay(200); + mouseDragged = false; + } + + public void dragMouse(int x0, int y0, int x1, int y1) { + int curX = x0; + int curY = y0; + int dx = x0 < x1 ? 1 : -1; + int dy = y0 < y1 ? 1 : -1; + + while (curX != x1) { + curX += dx; + robot.mouseMove(curX, curY); + } + while (curY != y1) { + curY += dy; + robot.mouseMove(curX, curY); + } + } + + public static void main(final String[] args) throws InterruptedException, + InvocationTargetException { + ChoiceDragEventsInside app = new ChoiceDragEventsInside(); + try { + EventQueue.invokeAndWait(app::setupUI); + app.start(); + } finally { + EventQueue.invokeAndWait(app::dispose); + } + } +} diff --git a/test/jdk/java/awt/Choice/ChoiceFocusTest.java b/test/jdk/java/awt/Choice/ChoiceFocusTest.java new file mode 100644 index 00000000000..3ca895f88e6 --- /dev/null +++ b/test/jdk/java/awt/Choice/ChoiceFocusTest.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 java.awt.Button; +import java.awt.Choice; +import java.awt.Frame; +import java.awt.Panel; +import java.awt.Window; + +/* + * @test + * @bug 4927930 + * @summary Verify that the focus is set to the selected item after calling the java.awt.Choice.select() method + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual ChoiceFocusTest + */ + +public class ChoiceFocusTest { + + private static final String INSTRUCTIONS = """ + 1. Use the mouse to select Item 5 in the Choice list. + 2. Click on the Choice. Item5 is now selected and highlighted. This is the correct behavior. + 3. Select Item 1 in the Choice list. + 4. Click the "choice.select(5)" button. This causes a call to Choice.select(5). Item 5 is now selected. + 5. Click on the Choice. + 6. If the cursor and focus are on item 5, the test passes. Otherwise, it fails. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("ChoiceFocusTest Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 3) + .columns(50) + .testUI(ChoiceFocusTest::createAndShowUI) + .build() + .awaitAndCheck(); + } + + private static Window createAndShowUI() { + Panel panel = new Panel(); + Choice choice = new Choice(); + Button button = new Button("choice.select(5);"); + + for (int i = 0; i < 10; i++) { + choice.add(String.valueOf(i)); + } + + button.addActionListener(e -> choice.select(5)); + + panel.add(button); + panel.add(choice); + + Frame frame = new Frame("ChoiceFocusTest"); + frame.add(panel); + frame.pack(); + + return frame; + } +} diff --git a/test/jdk/java/awt/Choice/ChoiceInLWTest/ChoiceInLWTest.java b/test/jdk/java/awt/Choice/ChoiceInLWTest/ChoiceInLWTest.java new file mode 100644 index 00000000000..9d1ad195491 --- /dev/null +++ b/test/jdk/java/awt/Choice/ChoiceInLWTest/ChoiceInLWTest.java @@ -0,0 +1,96 @@ +/* + * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4130788 + * @summary Choice components move unexpectedly when in lightweight containers + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual ChoiceInLWTest + */ + +import java.awt.BorderLayout; +import java.awt.Choice; +import java.awt.Container; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.Label; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.lang.reflect.InvocationTargetException; + +public class ChoiceInLWTest extends Frame implements Runnable { + private final Choice choices; + static final String INSTRUCTIONS = """ + After test starts wait for two seconds and open a choice. + If choice's popup obscures the label above it press Fail. + Otherwise press Pass. + """; + + public ChoiceInLWTest() { + setLayout(new BorderLayout()); + Container lwCont = new Container(); + lwCont.setLayout(new FlowLayout()); + choices = new Choice(); + choices.add("This is just a token item to get a nice width."); + lwCont.add(choices); + add("Center", lwCont); + Label label = new Label("You should see an unobscured Choice below."); + label.setAlignment(Label.CENTER); + add("North", label); + addChoiceItem(); + addWindowListener(new WindowAdapter() { + @Override + public void windowOpened(WindowEvent e) { + super.windowOpened(e); + new Thread(ChoiceInLWTest.this).start(); + } + }); + pack(); + } + + private void addChoiceItem() { + choices.add("Adding an item used to move the Choice!"); + } + + public void run() { + try { + Thread.sleep(1000); + } catch (InterruptedException ignore) { + } + addChoiceItem(); + } + + public static void main(String[] args) throws InterruptedException, + InvocationTargetException { + PassFailJFrame.builder() + .title("Choice in LW Container Test") + .testUI(ChoiceInLWTest::new) + .instructions(INSTRUCTIONS) + .columns(40) + .build() + .awaitAndCheck(); + + } +} diff --git a/test/jdk/java/awt/Choice/ChoiceInsertTest.java b/test/jdk/java/awt/Choice/ChoiceInsertTest.java new file mode 100644 index 00000000000..5eafa83a139 --- /dev/null +++ b/test/jdk/java/awt/Choice/ChoiceInsertTest.java @@ -0,0 +1,89 @@ +/* + * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Choice; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.GridLayout; +import java.awt.Label; +import java.awt.Robot; + +/* + * @test + * @bug 4082078 + * @summary Test for bug(s): 4082078, Multiple calls to Choice.insert cause core dump + * @key headful + * @run main ChoiceInsertTest + */ + +public class ChoiceInsertTest extends Frame { + Choice c; + Label l; + + private static ChoiceInsertTest choiceInsertTest; + + public ChoiceInsertTest() { + c = new Choice(); + l = new Label("If you see this, the choice insert bug is fixed!"); + c.add("Initial choice"); + add(c); + } + + public void testInsertion() { + // inserting 30 or so items aborts Solaris VM + // in JDK's before 1.1.5 + for (int nchoice = 0; nchoice < 30; nchoice++) { + c.insert("new choice", 0); + } + // if you made it to here the bug is not there anymore... + remove(l); + add(l); + validate(); + } + + public static void main(String[] args) throws Exception { + Robot robot = new Robot(); + try { + EventQueue.invokeAndWait(() ->{ + choiceInsertTest = new ChoiceInsertTest(); + choiceInsertTest.setTitle("ChoiceInsertTest"); + choiceInsertTest.setLocationRelativeTo(null); + choiceInsertTest.setSize(500, 300); + choiceInsertTest.setLayout(new GridLayout()); + choiceInsertTest.setVisible(true); + }); + robot.waitForIdle(); + robot.delay(500); + EventQueue.invokeAndWait(choiceInsertTest::testInsertion); + robot.delay(1000); + } finally { + EventQueue.invokeAndWait(() -> { + if (choiceInsertTest != null) { + choiceInsertTest.dispose(); + } + }); + } + + System.err.println("ChoiceInsertTest: Didn't abort VM inserting 30 items, so we passed!"); + } +} diff --git a/test/jdk/java/awt/Choice/ChoiceMouseDragTest.java b/test/jdk/java/awt/Choice/ChoiceMouseDragTest.java new file mode 100644 index 00000000000..0c0c059032d --- /dev/null +++ b/test/jdk/java/awt/Choice/ChoiceMouseDragTest.java @@ -0,0 +1,138 @@ +/* + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + + +import java.awt.BorderLayout; +import java.awt.Choice; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.Point; +import java.awt.event.InputEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +/* + * @test + * @bug 4328557 + * @summary Tests that MouseDragged and MouseReleased are triggered on choice + * @library /lib/client + * @build ExtendedRobot + * @key headful + * @run main ChoiceMouseDragTest + */ + + +public class ChoiceMouseDragTest extends Frame { + private static final Choice choice = new Choice(); + + private static ExtendedRobot robot; + private volatile boolean isDragged; + private volatile boolean isReleased; + + private static volatile ChoiceMouseDragTest choiceMouseDragTest; + + public ChoiceMouseDragTest() { + super("ChoiceMouseDragTest"); + this.setLayout(new BorderLayout()); + choice.add("item-1"); + choice.add("item-2"); + choice.add("item-3"); + choice.add("item-4"); + add("Center", choice); + choice.addMouseListener(new MouseEventHandler()); + choice.addMouseMotionListener(new MouseMotionEventHandler()); + setSize(400, 200); + setLocationRelativeTo(null); + setVisible(true); + } + + public static void main(String[] args) throws Exception { + try { + EventQueue.invokeAndWait(() -> + choiceMouseDragTest = new ChoiceMouseDragTest()); + + robot = new ExtendedRobot(); + robot.waitForIdle(); + robot.delay(500); + + Point pointToDrag = choice.getLocationOnScreen(); + pointToDrag.x += choice.getWidth() - 10; + pointToDrag.y += choice.getHeight() / 2 ; + + choiceMouseDragTest.test(InputEvent.BUTTON3_DOWN_MASK, pointToDrag); + choiceMouseDragTest.test(InputEvent.BUTTON1_DOWN_MASK, pointToDrag); + } finally { + EventQueue.invokeAndWait(() -> { + if (choiceMouseDragTest != null) { + choiceMouseDragTest.dispose(); + } + }); + } + } + + void test(int buttonToTest, Point pointToDrag) { + isDragged = false; + isReleased = false; + + robot.mouseMove(pointToDrag.x, pointToDrag.y); + robot.waitForIdle(); + + robot.mousePress(buttonToTest); + + robot.glide(pointToDrag.x + 100, pointToDrag.y); + robot.waitForIdle(); + + robot.mouseRelease(buttonToTest); + robot.waitForIdle(); + + if (!isReleased || !isDragged) { + throw new RuntimeException(("Test failed: button %d dragged(received %b) or " + + "released(received %b)") + .formatted(buttonToTest, isDragged, isReleased)); + } + + robot.delay(500); + } + + class MouseEventHandler extends MouseAdapter { + public void mousePressed(MouseEvent me) { + System.out.println(me.paramString()); + } + + public void mouseReleased(MouseEvent me) { + System.out.println(me.paramString()); + isReleased = true; + } + + public void mouseClicked(MouseEvent me) { + System.out.println(me.paramString()); + } + } + + class MouseMotionEventHandler extends MouseAdapter { + public void mouseDragged(MouseEvent me) { + System.out.println(me.paramString()); + isDragged = true; + } + } +} diff --git a/test/jdk/java/awt/Choice/ChoiceMouseEventTest.java b/test/jdk/java/awt/Choice/ChoiceMouseEventTest.java new file mode 100644 index 00000000000..9603d5c763d --- /dev/null +++ b/test/jdk/java/awt/Choice/ChoiceMouseEventTest.java @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4319246 + * @summary Tests that MouseReleased, MouseClicked and MouseDragged are triggered on choice + * @key headful + * @run main ChoiceMouseEventTest + */ + +import java.awt.AWTException; +import java.awt.BorderLayout; +import java.awt.Choice; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.Point; +import java.awt.Robot; +import java.awt.event.InputEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.lang.reflect.InvocationTargetException; + + +public class ChoiceMouseEventTest extends Frame { + static volatile boolean mousePressed = false; + static volatile boolean mouseReleased = false; + static volatile boolean mouseClicked = false; + Choice choice = new Choice(); + static Point location; + static Dimension size; + + public void setupGUI() { + setTitle("Choice Mouse Event Test"); + this.setLayout(new BorderLayout()); + choice.add("item-1"); + choice.add("item-2"); + choice.add("item-3"); + choice.add("item-4"); + add("Center", choice); + choice.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + mouseClicked = true; + } + + @Override + public void mousePressed(MouseEvent e) { + mousePressed = true; + } + + @Override + public void mouseReleased(MouseEvent e) { + mouseReleased = true; + } + }); + setLocationRelativeTo(null); + setSize(400, 200); + setVisible(true); + } + + public Point _location() { + return choice.getLocationOnScreen(); + } + + public Dimension _size() { + return choice.getSize(); + } + + public static void main(String[] args) throws InterruptedException, + InvocationTargetException, AWTException { + ChoiceMouseEventTest test = new ChoiceMouseEventTest(); + try { + EventQueue.invokeAndWait(test::setupGUI); + Robot robot = new Robot(); + robot.setAutoDelay(50); + robot.delay(1000); + robot.waitForIdle(); + EventQueue.invokeAndWait(() -> { + location = test._location(); + size = test._size(); + }); + robot.waitForIdle(); + robot.mouseMove(location.x + size.width - 10, location.y + (size.height / 2)); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.delay(2000); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.delay(2000); + robot.waitForIdle(); + if (!mouseClicked || !mousePressed || !mouseReleased) { + throw new RuntimeException(String.format("One of the events not arrived: " + + "mouseClicked = %b, mousePressed = %b, mouseReleased = %b", + mouseClicked, mousePressed, mouseReleased)); + } + } finally { + if (test != null) { + EventQueue.invokeAndWait(test::dispose); + } + } + } +} + diff --git a/test/jdk/java/awt/Choice/ChoicePosTest.java b/test/jdk/java/awt/Choice/ChoicePosTest.java new file mode 100644 index 00000000000..c585e4709bb --- /dev/null +++ b/test/jdk/java/awt/Choice/ChoicePosTest.java @@ -0,0 +1,137 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Choice; +import java.awt.Color; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.Insets; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.Robot; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; +import javax.imageio.ImageIO; + +/* + * @test + * @bug 4075194 + * @summary 4075194, Choice may not be displayed at the location requested + * @key headful + */ + +public class ChoicePosTest { + + private static Robot robot; + private static Frame frame; + private static final int GAP = 10; + private static volatile Choice c1,c2; + + public static void main(String[] args) throws Exception { + try { + EventQueue.invokeAndWait(ChoicePosTest::createAndShowGUI); + + robot = new Robot(); + robot.waitForIdle(); + robot.delay(500); + + captureAndTestChoices(); + } finally { + EventQueue.invokeAndWait(frame::dispose); + } + + System.out.println("Passed"); + } + + private static void createAndShowGUI() { + frame = new Frame("ChoicePosTest"); + Insets insets = frame.getInsets(); + frame.setSize( insets.left + 400 + insets.right, insets.top + 400 + insets.bottom ); + frame.setBackground(Color.RED); + frame.setLayout(null); + frame.setLocationRelativeTo(null); + + c1 = new Choice(); + c1.setBackground(Color.GREEN); + frame.add( c1 ); + c1.setBounds( 20, 50, 100, 100 ); + + c2 = new Choice(); + c2.setBackground(Color.GREEN); + frame.add(c2); + c2.addItem("One"); + c2.addItem("Two"); + c2.addItem("Three"); + c2.setBounds( 125, 50, 100, 100 ); + + frame.validate(); + frame.setVisible(true); + } + + private static void captureAndTestChoices() { + Point c1loc = c1.getLocationOnScreen(); + Point c2loc = c2.getLocationOnScreen(); + + int startX = c1loc.x - GAP; + int startY = c1loc.y - GAP; + int captureWidth = c2loc.x + c2.getWidth() + GAP - startX; + int captureHeight = c2loc.y + c2.getHeight() + GAP - startY; + + BufferedImage bi = robot.createScreenCapture( + new Rectangle(startX, startY, captureWidth, captureHeight) + ); + + int redPix = Color.RED.getRGB(); + + int lastNonRedCount = 0; + + for (int y = 0; y < captureHeight; y++) { + int nonRedCount = 0; + for (int x = 0; x < captureWidth; x++) { + int pix = bi.getRGB(x, y); + if (pix != redPix) { + nonRedCount++; + } + } + + if (nonRedCount > 0 && lastNonRedCount > 0) { + if (lastNonRedCount - nonRedCount > 0) { + System.err.printf( + "Failed at %d, nonRedCount: %d lastNonRedCount: %d\n", + y, nonRedCount, lastNonRedCount + ); + + try { + ImageIO.write(bi, "png", new File("choices.png")); + } catch (IOException ignored) { + } + + throw new RuntimeException("Choices are not aligned"); + } + } + + lastNonRedCount = nonRedCount; + } + } +} diff --git a/test/jdk/java/awt/Choice/ChoiceRemoveTest.java b/test/jdk/java/awt/Choice/ChoiceRemoveTest.java new file mode 100644 index 00000000000..6de66db9362 --- /dev/null +++ b/test/jdk/java/awt/Choice/ChoiceRemoveTest.java @@ -0,0 +1,111 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4079027 + * @summary Removing an item dynamically from a Choice object breaks lower items. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual ChoiceRemoveTest + */ + +import java.awt.Choice; +import java.awt.Frame; +import java.awt.GridLayout; +import java.awt.Label; +import java.awt.Panel; +import java.awt.event.ItemEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.lang.reflect.InvocationTargetException; + +public class ChoiceRemoveTest extends Frame { + Choice selector; + static final String INSTRUCTIONS = """ + After window 'Choice Remove Test' appears wait for three seconds + and then click on the choice. In popup there should be no + 'Choice A' variant. Try selecting each variant with mouse + and verify by the log that the correct variant gets selected. + If after selecting item in the list the correct item gets selected + and correct item name appears in the log press Pass otherwise press Fail. + """; + + public static void main(String[] argv) throws InterruptedException, + InvocationTargetException { + PassFailJFrame.builder() + .title("Test Instructions") + .testUI(ChoiceRemoveTest::new) + .instructions(INSTRUCTIONS) + .columns(40) + .logArea() + .build() + .awaitAndCheck(); + } + + public ChoiceRemoveTest() { + super("Choice Remove Test"); + Panel p; + Label prompt; + + addWindowListener(new WindowAdapter() { + @Override + public void windowOpened(WindowEvent e) { + super.windowOpened(e); + new Thread(() -> { + try { + Thread.sleep(2000); + } catch (InterruptedException ignore) { + } + removeFirst(); + }).start(); + } + }); + + setLayout(new GridLayout()); + p = new Panel(); + + prompt = new Label("Select different items including the last one"); + p.add(prompt); + + selector = new Choice(); + selector.add("Choice A"); + selector.add("Choice B"); + selector.add("Choice C"); + selector.add("Choice D"); + selector.add("Choice E"); + selector.addItemListener(e -> { + if (e.getStateChange() == ItemEvent.SELECTED) { + Object selected = e.getItem(); + PassFailJFrame.log(selected.toString()); + } + }); + p.add(selector); + add(p); + pack(); + } + + public void removeFirst() { + selector.remove("Choice A"); + } +} diff --git a/test/jdk/java/awt/Choice/DeadlockTest.java b/test/jdk/java/awt/Choice/DeadlockTest.java new file mode 100644 index 00000000000..fdc6d94e6ba --- /dev/null +++ b/test/jdk/java/awt/Choice/DeadlockTest.java @@ -0,0 +1,113 @@ +/* + * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.BorderLayout; +import java.awt.Choice; +import java.awt.Frame; +import jdk.test.lib.Platform; + +/* + * @test + * @bug 4134619 + * @summary Tests that the EventDispatchThread doesn't deadlock with + * user threads which are modifying a Choice component. + * @library /java/awt/regtesthelpers /test/lib + * @build PassFailJFrame jdk.test.lib.Platform + * @run main/manual DeadlockTest + */ + +public class DeadlockTest extends Thread { + + static volatile Choice choice1; + static volatile Choice choice2; + static volatile Choice choice3; + static volatile Frame frame; + static int itemCount = 0; + + private static final boolean isWindows = Platform.isWindows(); + + private static final String INSTRUCTIONS = """ + Click on the top Choice component and hold the mouse still briefly. + Then, without releasing the mouse button, move the cursor to a menu + item and then again hold the mouse still briefly. + %s + Release the button and repeat this process. + + Verify that this does not cause a deadlock + or crash within a reasonable amount of time. + """.formatted( + isWindows + ? "(menu can automatically collapse sometimes, this is ok)\n" + : "" + + ) ; + + public static void main(String[] args) throws Exception { + DeadlockTest deadlockTest = new DeadlockTest(); + PassFailJFrame passFailJFrame = PassFailJFrame.builder() + .title("DeadlockTest Instructions") + .instructions(INSTRUCTIONS) + .columns(45) + .testUI(deadlockTest::createAndShowUI) + .build(); + + deadlockTest.start(); + + passFailJFrame.awaitAndCheck(); + } + + public Frame createAndShowUI() { + frame = new Frame("Check Choice"); + frame.setLayout(new BorderLayout()); + choice1 = new Choice(); + choice2 = new Choice(); + choice3 = new Choice(); + frame.add(choice1, BorderLayout.NORTH); + frame.add(choice3, BorderLayout.CENTER); + frame.add(choice2, BorderLayout.SOUTH); + frame.pack(); + return frame; + } + + public void run() { + while (true) { + if (choice1 != null && itemCount < 40) { + choice1.add("I am Choice, yes I am : " + itemCount * itemCount); + choice2.add("I am the same, yes I am : " + itemCount * itemCount); + choice3.add("I am the same, yes I am : " + itemCount * itemCount); + itemCount++; + } + if (itemCount >= 20 && choice1 != null && + choice1.getItemCount() > 0) { + choice1.removeAll(); + choice2.removeAll(); + choice3.removeAll(); + itemCount = 0; + } + frame.validate(); + try { + Thread.sleep(1000); + } catch (Exception ignored) {} + } + } +} diff --git a/test/jdk/java/awt/Choice/DisabledList.java b/test/jdk/java/awt/Choice/DisabledList.java new file mode 100644 index 00000000000..d028527303f --- /dev/null +++ b/test/jdk/java/awt/Choice/DisabledList.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.BorderLayout; +import java.awt.Checkbox; +import java.awt.Choice; +import java.awt.Frame; +import java.awt.Window; +import java.awt.event.ItemEvent; + +/* + * @test + * @bug 6476183 + * @summary Drop down of a Choice changed to enabled state has a disabled like appearance + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual DisabledList + */ + +public class DisabledList { + + private static final String INSTRUCTIONS = """ + 1) Select the checkbox + 2) Open Choice + 3) Drag mouse over the scrollbar or drag out it the choice + 4) If choice's items become disabled press fail, otherwise pass + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("DisabledList Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 3) + .columns(45) + .testUI(DisabledList::createAndShowUI) + .logArea(4) + .build() + .awaitAndCheck(); + } + + private static Window createAndShowUI() { + Frame frame = new Frame("DisabledList"); + frame.setSize(200, 200); + frame.validate(); + Checkbox checkbox = new Checkbox("checkbox"); + final Choice choice = new Choice(); + choice.setEnabled(false); + for (int i = 0; i < 15; i++) { + choice.addItem("Item" + i); + } + checkbox.addItemListener(event -> { + PassFailJFrame.log("CheckBox.itemStateChanged occurred"); + choice.setEnabled(event.getStateChange() == ItemEvent.SELECTED); + }); + frame.add(BorderLayout.NORTH, checkbox); + frame.add(BorderLayout.CENTER, choice); + return frame; + } +} diff --git a/test/jdk/java/awt/Choice/MultiItemSelected/MultiItemSelected_DragOut.java b/test/jdk/java/awt/Choice/MultiItemSelected/MultiItemSelected_DragOut.java new file mode 100644 index 00000000000..aed15437745 --- /dev/null +++ b/test/jdk/java/awt/Choice/MultiItemSelected/MultiItemSelected_DragOut.java @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6367251 + * @summary 2 items are highlighted when pressing, dragging the mouse inside the choice, XToolkit + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual MultiItemSelected_DragOut + */ + +import java.awt.Choice; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.lang.reflect.InvocationTargetException; + +public class MultiItemSelected_DragOut extends Frame { + static final String INSTRUCTIONS = """ + 1) Open Choice. + 2) Start drag from first item to second or third one. + 3) Without releasing left mouse button + press and release right mouse button. + 4) Release left mouse button. + 5) Open choice again. + 6) If there is only one selection cursor + in the dropdown list press Pass otherwise press Fail. + """; + + public MultiItemSelected_DragOut() { + Choice choice = new Choice(); + + for (int i = 1; i < 10; i++) { + choice.add("item " + i); + } + add(choice); + choice.addItemListener(ie -> System.out.println(ie)); + + setLayout(new FlowLayout()); + setSize(200, 200); + validate(); + } + + public static void main(String[] args) throws InterruptedException, + InvocationTargetException { + PassFailJFrame.builder() + .title("MultiItemSelected Drag Out Test") + .testUI(MultiItemSelected_DragOut::new) + .instructions(INSTRUCTIONS) + .columns(40) + .build() + .awaitAndCheck(); + } +} diff --git a/test/jdk/java/awt/Choice/MultiItemSelected/MultiItemSelected_KeySelect.java b/test/jdk/java/awt/Choice/MultiItemSelected/MultiItemSelected_KeySelect.java new file mode 100644 index 00000000000..9e930f9923b --- /dev/null +++ b/test/jdk/java/awt/Choice/MultiItemSelected/MultiItemSelected_KeySelect.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6367251 + * @summary 2 items are highlighted when dragging inside and press ESC or ENTER + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual MultiItemSelected_KeySelect + */ + +import java.awt.Choice; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.lang.reflect.InvocationTargetException; + +public class MultiItemSelected_KeySelect extends Frame { + static final String INSTRUCTIONS = """ + 1) Open Choice. + 2) Start drag from first item to another one. + 3) Without releasing the mouse button press ESC key. + 4) Open choice again. + 5) Verify that there is only one + selection cursor in the dropdown list. + 6) Repeat steps 2-5 once again but this time + press ENTER key instead of ESC. + 7) If in both scenarios there is only one selection cursor + press Pass otherwise press Fail. + """; + + public MultiItemSelected_KeySelect() { + Choice choice = new Choice(); + + for (int i = 1; i < 10; i++) { + choice.add("item " + i); + } + add(choice); + choice.addItemListener(ie -> System.out.println(ie)); + setLayout(new FlowLayout()); + setSize(200, 200); + validate(); + } + + public static void main(String[] args) throws InterruptedException, + InvocationTargetException { + PassFailJFrame.builder() + .title("MultiItemSelected Key Select Test") + .testUI(MultiItemSelected_KeySelect::new) + .instructions(INSTRUCTIONS) + .columns(40) + .build() + .awaitAndCheck(); + } +} diff --git a/test/jdk/java/awt/Choice/MultiItemSelected/MultiItemSelected_UpDown.java b/test/jdk/java/awt/Choice/MultiItemSelected/MultiItemSelected_UpDown.java new file mode 100644 index 00000000000..5904d98a908 --- /dev/null +++ b/test/jdk/java/awt/Choice/MultiItemSelected/MultiItemSelected_UpDown.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6367251 + * @summary 2 items are highlighted when dragging outside and press UP or DOWN + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual MultiItemSelected_UpDown + */ + +import java.awt.Choice; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.lang.reflect.InvocationTargetException; + +public class MultiItemSelected_UpDown extends Frame { + static final String INSTRUCTIONS = """ + 1) Open Choice. + 2) Start drag from first item to another one. + 3) Without interrupting drag + move mouse cursor outside the choice popup. + 4) Press UP, DOWN key several times to position + selection cursor to a different item. + 5) Release mouse button. + 6) If popup is closed upon mouse button release open Choice again. + 7) Verify that there is only one + selection cursor in the dropdown list. + 8) If true then press Pass, otherwise press Fail. + """; + + public MultiItemSelected_UpDown() { + Choice choice = new Choice(); + + for (int i = 1; i < 20; i++) { + choice.add(" item " + i); + } + add(choice); + choice.addItemListener(ie -> System.out.println(ie)); + setLayout(new FlowLayout()); + setSize(200, 200); + validate(); + } + + public static void main(String[] args) throws InterruptedException, + InvocationTargetException { + PassFailJFrame.builder() + .title("MultiItemSelected Up/Down Test") + .testUI(MultiItemSelected_UpDown::new) + .instructions(INSTRUCTIONS) + .columns(40) + .build() + .awaitAndCheck(); + } +} diff --git a/test/jdk/java/awt/Choice/PopupMenuOnChoiceArea.java b/test/jdk/java/awt/Choice/PopupMenuOnChoiceArea.java new file mode 100644 index 00000000000..2a56d7281ee --- /dev/null +++ b/test/jdk/java/awt/Choice/PopupMenuOnChoiceArea.java @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6240046 + * @summary REG:Choice's Drop-down does not disappear when clicking somewhere, after popup menu is disposed-XTkt + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual PopupMenuOnChoiceArea + */ + + +import java.awt.CheckboxMenuItem; +import java.awt.Choice; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.Menu; +import java.awt.PopupMenu; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.lang.reflect.InvocationTargetException; + +public class PopupMenuOnChoiceArea extends Frame { + static final String INSTRUCTIONS = """ + You would see a window named 'Popup menu on choice area' + with Choice in it. Move the mouse pointer to the choice. + Click right mouse button on it. + You should see a popup menu with 'File' in it. + Close this popup menu by pressing Esc. + Click the left mouse button on the Choice. + You should see a Choice drop-down menu. + Move mouse pointer into drop-down menu. + Click right mouse button on any item in it. + If you see a 'File' popup menu press Fail. + If Choice drop-down closes instead press Pass. + """; + + public PopupMenuOnChoiceArea() { + super("Popup menu on choice area"); + this.setLayout(new FlowLayout()); + Choice choice = new Choice(); + choice.add("item-1"); + choice.add("item-2"); + choice.add("item-3"); + choice.add("item-4"); + add("Center", choice); + Menu fileMenu = new Menu("File"); + Menu open = new Menu("Open"); + Menu save = new Menu("save"); + CheckboxMenuItem exit = new CheckboxMenuItem("Exit"); + fileMenu.add(open); + fileMenu.add(save); + fileMenu.add(exit); + final PopupMenu pop = new PopupMenu(); + pop.setLabel("This is a popup menu"); + pop.setName("a menu"); + pop.add(fileMenu); + choice.add(pop); + choice.addMouseListener(new MouseAdapter() { + public void mousePressed(MouseEvent me) { + if (me.isPopupTrigger()) { + pop.show(me.getComponent(), me.getX(), me.getY()); + } + } + + public void mouseReleased(MouseEvent me) { + if (me.isPopupTrigger()) { + pop.show(me.getComponent(), me.getX(), me.getY()); + } + } + }); + setSize(200, 200); + } + + public static void main(String[] args) throws InterruptedException, + InvocationTargetException { + PassFailJFrame.builder() + .title("Test Instructions") + .testUI(PopupMenuOnChoiceArea::new) + .instructions(INSTRUCTIONS) + .columns(40) + .build() + .awaitAndCheck(); + } +} diff --git a/test/jdk/java/awt/Choice/RepaintAfterRemoveLastItemTest/RepaintAfterRemoveLastItemTest.java b/test/jdk/java/awt/Choice/RepaintAfterRemoveLastItemTest/RepaintAfterRemoveLastItemTest.java new file mode 100644 index 00000000000..20acc66b6bd --- /dev/null +++ b/test/jdk/java/awt/Choice/RepaintAfterRemoveLastItemTest/RepaintAfterRemoveLastItemTest.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6292186 + * @summary Choice is not refreshed properly when the last item gets removed + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual RepaintAfterRemoveLastItemTest + */ + +import java.awt.Button; +import java.awt.Choice; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.lang.reflect.InvocationTargetException; + +public class RepaintAfterRemoveLastItemTest extends Frame implements ActionListener { + Choice ch = new Choice(); + + static final String INSTRUCTIONS = """ + Press on the 'remove' button after that if the choice does not display + 'only item' press Pass. If 'only item' is still displayed press Fail. + """; + + public RepaintAfterRemoveLastItemTest() { + ch.add("only item"); + add(ch); + + Button b = new Button("remove"); + add(b); + b.addActionListener(this); + setLayout(new FlowLayout()); + setSize(200, 200); + validate(); + } + + public void actionPerformed(ActionEvent ae) { + if (ch.getItemCount() != 0) { + ch.remove(0); + } + } + + public static void main(String[] args) throws InterruptedException, + InvocationTargetException { + PassFailJFrame.builder() + .title("Repaint After Remove Test") + .testUI(RepaintAfterRemoveLastItemTest::new) + .instructions(INSTRUCTIONS) + .columns(40) + .build() + .awaitAndCheck(); + } +} diff --git a/test/jdk/java/awt/Choice/ScrollbarFlickers.java b/test/jdk/java/awt/Choice/ScrollbarFlickers.java new file mode 100644 index 00000000000..c35d4900134 --- /dev/null +++ b/test/jdk/java/awt/Choice/ScrollbarFlickers.java @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2006, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6405707 + * @summary Choice popup & scrollbar gets Flickering when mouse is pressed & drag on the scrollbar + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual ScrollbarFlickers + */ + +import java.awt.BorderLayout; +import java.awt.Choice; +import java.awt.Frame; +import java.lang.reflect.InvocationTargetException; + +public class ScrollbarFlickers extends Frame { + static final String INSTRUCTIONS = """ + Open the choice popup. Select any item in it and + drag it with the mouse above or below the choice. + Keep the choice opened. + Continue dragging the mouse outside of the choice + making content of the popup scroll. + If you see that scrollbar flickers press Fail. + Otherwise press Pass. + """; + + public ScrollbarFlickers() { + super("Scrollbar Flickering Test"); + Choice ch = new Choice(); + setLayout(new BorderLayout()); + ch.add("Praveen"); + ch.add("Mohan"); + ch.add("Rakesh"); + ch.add("Menon"); + ch.add("Girish"); + ch.add("Ramachandran"); + ch.add("Elancheran"); + ch.add("Subramanian"); + ch.add("Raju"); + ch.add("Pallath"); + ch.add("Mayank"); + ch.add("Joshi"); + ch.add("Sundar"); + ch.add("Srinivas"); + ch.add("Mandalika"); + ch.add("Suresh"); + ch.add("Chandar"); + add(ch); + setSize(200, 200); + validate(); + } + + public static void main(String[] args) throws InterruptedException, + InvocationTargetException { + PassFailJFrame.builder() + .title("Test Instructions") + .testUI(ScrollbarFlickers::new) + .instructions(INSTRUCTIONS) + .columns(40) + .build() + .awaitAndCheck(); + } +} diff --git a/test/jdk/java/awt/Choice/SelectCurrentItemTest/SelectCurrentItemTest.java b/test/jdk/java/awt/Choice/SelectCurrentItemTest/SelectCurrentItemTest.java deleted file mode 100644 index 3d3f8c80793..00000000000 --- a/test/jdk/java/awt/Choice/SelectCurrentItemTest/SelectCurrentItemTest.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright (c) 2002, 2018, 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. - */ -/* - @test - @bug 4902933 8197810 - @summary Test that selecting the current item doesnot send an ItemEvent - @key headful - @run main SelectCurrentItemTest -*/ - -import java.awt.Choice; -import java.awt.Robot; -import java.awt.Frame; -import java.awt.BorderLayout; -import java.awt.AWTException; -import java.awt.Point; -import java.awt.Dimension; -import java.awt.event.InputEvent; -import java.awt.event.ItemListener; -import java.awt.event.WindowListener; -import java.awt.event.ItemEvent; -import java.awt.event.WindowEvent; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -public class SelectCurrentItemTest implements ItemListener, WindowListener { - //Declare things used in the test, like buttons and labels here - private Frame frame; - private Choice theChoice; - private Robot robot; - - private CountDownLatch latch = new CountDownLatch(1); - private volatile boolean passed = true; - - private void init() - { - try { - robot = new Robot(); - robot.setAutoDelay(500); - } catch (AWTException e) { - throw new RuntimeException("Unable to create Robot. Test fails."); - } - - frame = new Frame("SelectCurrentItemTest"); - frame.setLayout(new BorderLayout()); - theChoice = new Choice(); - for (int i = 0; i < 10; i++) { - theChoice.add(new String("Choice Item " + i)); - } - theChoice.addItemListener(this); - frame.add(theChoice); - frame.addWindowListener(this); - - frame.setLocation(1,20); - robot.mouseMove(10, 30); - frame.pack(); - frame.setVisible(true); - } - - public static void main(String... args) { - SelectCurrentItemTest test = new SelectCurrentItemTest(); - test.init(); - try { - test.latch.await(12000, TimeUnit.MILLISECONDS); - } catch (InterruptedException e) {} - test.robot.waitForIdle(); - - try { - if (!test.passed) { - throw new RuntimeException("TEST FAILED."); - } - } finally { - test.frame.dispose(); - } - } - - private void run() { - try {Thread.sleep(1000);} catch (InterruptedException e){} - // get loc of Choice on screen - Point loc = theChoice.getLocationOnScreen(); - // get bounds of Choice - Dimension size = theChoice.getSize(); - robot.mouseMove(loc.x + size.width - 10, loc.y + size.height / 2); - - robot.setAutoDelay(250); - robot.mousePress(InputEvent.BUTTON1_MASK); - robot.mouseRelease(InputEvent.BUTTON1_MASK); - - robot.delay(1000); - - robot.mouseMove(loc.x + size.width / 2, loc.y + size.height); - robot.mousePress(InputEvent.BUTTON1_MASK); - robot.mouseRelease(InputEvent.BUTTON1_MASK); - robot.waitForIdle(); - latch.countDown(); - } - - @Override public void itemStateChanged(ItemEvent e) { - System.out.println("ItemEvent received. Test fails"); - passed = false; - } - - @Override public void windowOpened(WindowEvent e) { - System.out.println("windowActivated()"); - (new Thread(this::run)).start(); - } - - @Override public void windowActivated(WindowEvent e) {} - @Override public void windowDeactivated(WindowEvent e) {} - @Override public void windowClosed(WindowEvent e) {} - @Override public void windowClosing(WindowEvent e) {} - @Override public void windowIconified(WindowEvent e) {} - @Override public void windowDeiconified(WindowEvent e) {} -} diff --git a/test/jdk/java/awt/Choice/SelectItem/SelectCurrentItemTest.java b/test/jdk/java/awt/Choice/SelectItem/SelectCurrentItemTest.java new file mode 100644 index 00000000000..9bfcfeb9a97 --- /dev/null +++ b/test/jdk/java/awt/Choice/SelectItem/SelectCurrentItemTest.java @@ -0,0 +1,207 @@ +/* + * Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.AWTException; +import java.awt.BorderLayout; +import java.awt.Choice; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.Robot; +import java.awt.event.InputEvent; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.lang.reflect.InvocationTargetException; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicReference; + +/* + * @test + * @bug 4902933 8197810 + * @summary Test that selecting the current item does not send an ItemEvent + * @key headful + * @run main SelectCurrentItemTest +*/ +public class SelectCurrentItemTest + extends WindowAdapter + implements ItemListener { + private static Frame frame; + private static Choice choice; + + private final Robot robot; + + private final CountDownLatch windowOpened = new CountDownLatch(1); + private final CountDownLatch mouseClicked = new CountDownLatch(1); + + protected final CountDownLatch itemStateChanged = new CountDownLatch(1); + + protected SelectCurrentItemTest() throws AWTException { + robot = new Robot(); + robot.setAutoDelay(250); + } + + private void createUI() { + frame = new Frame(getClass().getName()); + frame.setLayout(new BorderLayout()); + + choice = new Choice(); + for (int i = 0; i < 10; i++) { + choice.add("Choice Item " + i); + } + choice.addItemListener(this); + choice.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + System.out.println("mouseClicked()"); + mouseClicked.countDown(); + } + }); + + frame.add(choice, BorderLayout.CENTER); + + frame.addWindowListener(this); + + frame.setLocationRelativeTo(null); + frame.setResizable(false); + frame.pack(); + frame.setVisible(true); + } + + protected final void runTest() + throws InterruptedException, InvocationTargetException { + try { + doTest(); + } finally { + EventQueue.invokeAndWait(this::dispose); + } + } + + private void doTest() + throws InterruptedException, InvocationTargetException { + EventQueue.invokeAndWait(this::createUI); + + if (!windowOpened.await(2, TimeUnit.SECONDS)) { + throw new RuntimeException("Frame is not open in time"); + } + robot.waitForIdle(); + + final int initialIndex = getSelectedIndex(); + + final Rectangle choiceRect = getChoiceRect(); + + // Open the choice popup + robot.mouseMove(choiceRect.x + choiceRect.width - 10, + choiceRect.y + choiceRect.height / 2); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + + if (!mouseClicked.await(500, TimeUnit.MILLISECONDS)) { + throw new RuntimeException("Mouse is not clicked in time"); + } + robot.waitForIdle(); + + // Click an item in the choice popup + final Point pt = getClickLocation(choiceRect); + robot.mouseMove(pt.x, pt.y); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + + robot.waitForIdle(); + + checkItemStateChanged(); + + final int currentIndex = getSelectedIndex(); + System.out.println("initialIndex = " + initialIndex); + System.out.println("currentIndex = " + currentIndex); + checkSelectedIndex(initialIndex, currentIndex); + } + + protected void checkItemStateChanged() throws InterruptedException { + if (itemStateChanged.await(500, TimeUnit.MILLISECONDS)) { + throw new RuntimeException("ItemEvent is received but unexpected"); + } + } + + protected void checkSelectedIndex(final int initialIndex, + final int currentIndex) { + if (initialIndex != currentIndex) { + throw new RuntimeException("Selected index in Choice should not change"); + } + } + + /** + * {@return the location for clicking choice popup to select an item} + * @param choiceRect the bounds of the Choice component + */ + protected Point getClickLocation(final Rectangle choiceRect) { + // Click on the first item in the popup, it's the selected item + return new Point(choiceRect.x + choiceRect.width / 2, + choiceRect.y + choiceRect.height + 3); + } + + private int getSelectedIndex() + throws InterruptedException, InvocationTargetException { + AtomicInteger index = new AtomicInteger(); + EventQueue.invokeAndWait(() -> index.set(choice.getSelectedIndex())); + return index.get(); + } + + private Rectangle getChoiceRect() + throws InterruptedException, InvocationTargetException { + AtomicReference rect = new AtomicReference<>(); + EventQueue.invokeAndWait( + () -> rect.set(new Rectangle(choice.getLocationOnScreen(), + choice.getSize()))); + return rect.get(); + } + + public static void main(String... args) throws Exception { + new SelectCurrentItemTest().runTest(); + } + + private void dispose() { + if (frame != null) { + frame.dispose(); + } + } + + @Override + public final void itemStateChanged(ItemEvent e) { + System.out.println("itemStateChanged: " + e); + itemStateChanged.countDown(); + } + + @Override + public final void windowOpened(WindowEvent e) { + System.out.println("windowActivated()"); + windowOpened.countDown(); + } + +} diff --git a/test/jdk/java/awt/Choice/SelectItem/SelectNewItemTest.java b/test/jdk/java/awt/Choice/SelectItem/SelectNewItemTest.java new file mode 100644 index 00000000000..1dba3fd905b --- /dev/null +++ b/test/jdk/java/awt/Choice/SelectItem/SelectNewItemTest.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.AWTException; +import java.awt.Point; +import java.awt.Rectangle; +import java.util.concurrent.TimeUnit; + +/* + * @test + * @bug 8215921 + * @summary Test that selecting a different item does send an ItemEvent + * @key headful + * @run main SelectNewItemTest +*/ +public final class SelectNewItemTest + extends SelectCurrentItemTest { + + private SelectNewItemTest() throws AWTException { + super(); + } + + @Override + protected void checkItemStateChanged() throws InterruptedException { + if (!itemStateChanged.await(500, TimeUnit.MILLISECONDS)) { + throw new RuntimeException("ItemEvent is not received"); + } + } + + @Override + protected void checkSelectedIndex(final int initialIndex, + final int currentIndex) { + if (initialIndex == currentIndex) { + throw new RuntimeException("Selected index in Choice should've changed"); + } + } + + @Override + protected Point getClickLocation(final Rectangle choiceRect) { + // Click a different item the popup, not the first one + return new Point(choiceRect.x + choiceRect.width / 2, + choiceRect.y + choiceRect.height * 3); + } + + public static void main(String... args) throws Exception { + new SelectNewItemTest().runTest(); + } + +} diff --git a/test/jdk/java/awt/Choice/SelectNewItemTest/SelectNewItemTest.java b/test/jdk/java/awt/Choice/SelectNewItemTest/SelectNewItemTest.java deleted file mode 100644 index 502c5a161df..00000000000 --- a/test/jdk/java/awt/Choice/SelectNewItemTest/SelectNewItemTest.java +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Copyright (c) 2019, 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. - */ -/* - @test - @bug 8215921 - @summary Test that selecting a different item does send an ItemEvent - @key headful - @run main SelectNewItemTest -*/ - -import java.awt.Choice; -import java.awt.Robot; -import java.awt.Frame; -import java.awt.BorderLayout; -import java.awt.AWTException; -import java.awt.Point; -import java.awt.Dimension; -import java.awt.event.InputEvent; -import java.awt.event.ItemListener; -import java.awt.event.WindowListener; -import java.awt.event.ItemEvent; -import java.awt.event.WindowEvent; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -public class SelectNewItemTest implements ItemListener, WindowListener { - //Declare things used in the test, like buttons and labels here - private Frame frame; - private Choice theChoice; - private Robot robot; - - private CountDownLatch latch = new CountDownLatch(1); - private volatile boolean passed = false; - - private void init() - { - try { - robot = new Robot(); - robot.setAutoDelay(500); - } catch (AWTException e) { - throw new RuntimeException("Unable to create Robot. Test fails."); - } - - frame = new Frame("SelectNewItemTest"); - frame.setLayout(new BorderLayout()); - theChoice = new Choice(); - for (int i = 0; i < 10; i++) { - theChoice.add(new String("Choice Item " + i)); - } - theChoice.addItemListener(this); - frame.add(theChoice); - frame.addWindowListener(this); - - frame.setLocation(1,20); - frame.setSize(200, 50); - robot.mouseMove(10, 30); - frame.pack(); - frame.setVisible(true); - } - - public static void main(String... args) { - SelectNewItemTest test = new SelectNewItemTest(); - test.init(); - try { - test.latch.await(12000, TimeUnit.MILLISECONDS); - } catch (InterruptedException e) {} - test.robot.waitForIdle(); - - try { - if (!test.passed) { - throw new RuntimeException("TEST FAILED."); - } - } finally { - test.frame.dispose(); - } - } - - private void run() { - try { - Thread.sleep(1000); - - Point loc = theChoice.getLocationOnScreen(); - int selectedIndex = theChoice.getSelectedIndex(); - Dimension size = theChoice.getSize(); - - robot.mouseMove(loc.x + size.width - 10, loc.y + size.height / 2); - - robot.setAutoDelay(250); - robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); - robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); - - robot.delay(1000); - - //make sure that the mouse moves to a different item, so that - //itemStateChanged is called. - robot.mouseMove(loc.x + size.width / 2, loc.y + 3 * size.height); - robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); - robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); - robot.waitForIdle(); - - if (selectedIndex == theChoice.getSelectedIndex()) - throw new RuntimeException("Test case failed - expected to select" + - " a different item than " + selectedIndex); - - selectedIndex = theChoice.getSelectedIndex(); - //now click on the same item and make sure that item event is - //not generated. - robot.delay(1000); - robot.mouseMove(loc.x + size.width - 10, loc.y + size.height / 2); - - robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); - //Make sure that the popup menu scrolls back to show the index from - //beginning, so that the second mouse click happens on the previously - //selected item. - //For example, on windows, it automatically scrolls the list to show - //the currently selected item just below the choice, which can - //throw off the test. - if (System.getProperty("os.name").toLowerCase().startsWith("win")) { - robot.mouseWheel(-100); - } - robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); - - robot.delay(1000); - robot.mouseMove(loc.x + size.width / 2, loc.y + 3 * size.height); - robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); - robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); - robot.waitForIdle(); - - if (selectedIndex != theChoice.getSelectedIndex()) - throw new RuntimeException("Test failed. Expected to select the same item " + - "located at: " + selectedIndex + " but got an item selected at: " + theChoice.getSelectedIndex()); - } catch(InterruptedException e) { - throw new RuntimeException(e.getCause()); - } finally { - latch.countDown(); - } - } - - @Override public void itemStateChanged(ItemEvent e) { - if (!passed) { - System.out.println("ItemEvent received. Test passes"); - passed = true; - } else { - System.out.println("ItemEvent received for second click. Test fails"); - passed = false; - } - } - - @Override public void windowOpened(WindowEvent e) { - System.out.println("windowActivated()"); - (new Thread(this::run)).start(); - } - - @Override public void windowActivated(WindowEvent e) {} - @Override public void windowDeactivated(WindowEvent e) {} - @Override public void windowClosed(WindowEvent e) {} - @Override public void windowClosing(WindowEvent e) {} - @Override public void windowIconified(WindowEvent e) {} - @Override public void windowDeiconified(WindowEvent e) {} -} diff --git a/test/jdk/java/awt/Choice/SetFontTest.java b/test/jdk/java/awt/Choice/SetFontTest.java new file mode 100644 index 00000000000..f38a34a7ed2 --- /dev/null +++ b/test/jdk/java/awt/Choice/SetFontTest.java @@ -0,0 +1,91 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.BorderLayout; +import java.awt.Choice; +import java.awt.Font; +import java.awt.Frame; +import java.awt.Panel; + +/* + * @test + * @bug 4293346 + * @summary Checks that Choice does update its dimensions on font change + * @requires (os.family == "windows") + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual SetFontTest + */ + +public class SetFontTest { + + private static final String INSTRUCTIONS = """ + Choice component used to not update its dimension on font change. + Select one of fonts on the choice pull down list. + Pull down the list after the font change; if items in the list are + shown correctly the test is passed, otherwise it failed. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("SetFontTest Instructions") + .instructions(INSTRUCTIONS) + .columns(45) + .testUI(SetFontTest::createAndShowUI) + .build() + .awaitAndCheck(); + } + + private static Frame createAndShowUI() { + Frame frame = new Frame("SetFontTest"); + Choice choice = new Choice(); + frame.setBounds(100, 400, 400, 100); + choice.addItem("dummy"); + choice.addItem("Set LARGE Font"); + choice.addItem("Set small Font"); + choice.addItem("addNewItem"); + choice.addItem("deleteItem"); + + choice.addItemListener(e -> { + if (e.getItem().toString().equals("addNewItem")) { + choice.addItem("very very very very long item"); + frame.validate(); + } else if (e.getItem().toString().equals("deleteItem")) { + if (choice.getItemCount() > 4) { + choice.remove(4); + frame.validate(); + } + } else if (e.getItem().toString().equals("Set LARGE Font")) { + choice.setFont(new Font("Dialog", Font.PLAIN, 24)); + frame.validate(); + } else if (e.getItem().toString().equals("Set small Font")) { + choice.setFont(new Font("Dialog", Font.PLAIN, 10)); + frame.validate(); + } + }); + Panel panel = new Panel(); + panel.add(choice); + frame.add(panel, BorderLayout.CENTER); + return frame; + } +} diff --git a/test/jdk/java/awt/Choice/WheelEventsConsumed.java b/test/jdk/java/awt/Choice/WheelEventsConsumed.java new file mode 100644 index 00000000000..37200214734 --- /dev/null +++ b/test/jdk/java/awt/Choice/WheelEventsConsumed.java @@ -0,0 +1,156 @@ +/* + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Choice; +import java.awt.EventQueue; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.Point; +import java.awt.Robot; +import java.awt.Toolkit; +import java.awt.event.InputEvent; +import java.awt.event.KeyEvent; +import java.awt.event.MouseWheelEvent; +import java.awt.event.MouseWheelListener; + +/* + * @test + * @bug 6253211 + * @summary PIT: MouseWheel events not triggered for Choice drop down in XAWT + * @requires (os.family == "linux") + * @key headful + * @run main WheelEventsConsumed + */ + +public class WheelEventsConsumed extends Frame implements MouseWheelListener +{ + Robot robot; + Choice choice1 = new Choice(); + Point pt; + final static int delay = 100; + boolean mouseWheeled = false; + final static int OUTSIDE_CHOICE = 1; + final static int INSIDE_LIST_OF_CHOICE = 2; + final static int INSIDE_CHOICE_COMPONENT = 3; + static String toolkit; + + private static volatile WheelEventsConsumed frame = null; + + public static void main(String[] args) throws Exception { + toolkit = Toolkit.getDefaultToolkit().getClass().getName(); + try { + EventQueue.invokeAndWait(() -> { + frame = new WheelEventsConsumed(); + frame.initAndShow(); + }); + frame.test(); + } finally { + EventQueue.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } + + public void mouseWheelMoved(MouseWheelEvent me) { + mouseWheeled = true; + System.out.println(me); + } + + public void initAndShow() { + setTitle("WheelEventsConsumed test"); + for (int i = 1; i < 10; i++) { + choice1.add("item-0" + i); + } + + choice1.addMouseWheelListener(this); + add(choice1); + setLayout(new FlowLayout()); + setSize(200, 200); + setLocationRelativeTo(null); + setVisible(true); + validate(); + } + + public void test() { + try { + robot = new Robot(); + robot.setAutoWaitForIdle(true); + robot.setAutoDelay(50); + robot.waitForIdle(); + robot.delay(delay * 5); + testMouseWheel(1, OUTSIDE_CHOICE); + robot.delay(delay); + testMouseWheel(-1, INSIDE_LIST_OF_CHOICE); + robot.delay(delay); + testMouseWheel(1, INSIDE_CHOICE_COMPONENT); + robot.delay(delay); + } catch (Throwable e) { + throw new RuntimeException("Test failed. Exception thrown: " + e); + } + } + + public void testMouseWheel(int amt, int mousePosition) { + pt = choice1.getLocationOnScreen(); + robot.mouseMove(pt.x + choice1.getWidth() / 2, pt.y + choice1.getHeight() / 2); + + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.delay(50); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.delay(50); + + switch (mousePosition) { + case OUTSIDE_CHOICE: + robot.mouseMove(pt.x + choice1.getWidth() * 3 / 2, pt.y + choice1.getHeight() / 2); + break; + case INSIDE_LIST_OF_CHOICE: + robot.mouseMove(pt.x + choice1.getWidth() / 2, pt.y + choice1.getHeight() * 4); + break; + case INSIDE_CHOICE_COMPONENT: + robot.mouseMove(pt.x + choice1.getWidth() / 2, pt.y + choice1.getHeight() / 2); + break; + } + + robot.delay(delay); + for (int i = 0; i < 10; i++) { + robot.mouseWheel(amt); + robot.delay(delay); + } + + if (!mouseWheeled) { + if (toolkit.equals("sun.awt.windows.WToolkit") && mousePosition == OUTSIDE_CHOICE) { + System.out.println("Passed. Separate case on Win32. Choice generated MouseWheel events" + mousePosition); + } else { + throw new RuntimeException("Test failed. Choice should generate MOUSE_WHEEL events." + mousePosition); + } + } else { + System.out.println("Passed. Choice generated MouseWheel events" + mousePosition); + } + robot.keyPress(KeyEvent.VK_ESCAPE); + robot.delay(10); + robot.keyRelease(KeyEvent.VK_ESCAPE); + robot.delay(200); + mouseWheeled = false; + } +} diff --git a/test/jdk/java/awt/Component/BackgroundColorTest/InitialBackgroundSettingTest.java b/test/jdk/java/awt/Component/BackgroundColorTest/InitialBackgroundSettingTest.java new file mode 100644 index 00000000000..3bed6f106c5 --- /dev/null +++ b/test/jdk/java/awt/Component/BackgroundColorTest/InitialBackgroundSettingTest.java @@ -0,0 +1,132 @@ +/* + * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4148334 + * @summary tests that background color is initially set correctly. + * @requires os.family == "windows" + * @key headful + * @run main InitialBackgroundSettingTest + */ +import java.awt.Button; +import java.awt.Choice; +import java.awt.Color; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.GridLayout; +import java.awt.List; +import java.awt.TextArea; +import java.awt.TextField; +import java.awt.Scrollbar; +import java.lang.reflect.InvocationTargetException; + +public class InitialBackgroundSettingTest { + Frame frame; + TextField tf; + TextArea ta; + Choice choice; + List list; + Scrollbar bar; + Button button; + + public static void main(String[] args) throws InterruptedException, + InvocationTargetException { + InitialBackgroundSettingTest test= new InitialBackgroundSettingTest(); + try { + EventQueue.invokeAndWait(test::setupGUI); + EventQueue.invokeAndWait(test::test); + } finally { + EventQueue.invokeAndWait(test::dispose); + } + } + + public void setupGUI () { + frame = new Frame("InitialBackgroundSettingTest frame"); + tf = new TextField("I am the TextField"); + ta = new TextArea("I am the TextArea"); + choice = new Choice(); + list = new List(); + bar = new Scrollbar(Scrollbar.HORIZONTAL); + button = new Button("I am the button"); + frame.setBackground(Color.red); + frame.setLayout(new GridLayout(7, 1)); + frame.add(button); + frame.add(bar); + frame.add(choice); + frame.add(list); + frame.add(tf); + frame.add(ta); + frame.setVisible(true); + frame.setBounds (400, 0, 300, 300); + } + + public void test() { + boolean passed = true; + System.out.println("Button background color is:" + + button.getBackground()); + if (Color.red.equals(button.getBackground())) { + System.err.println("Button background is red"); + passed = false; + } + System.out.println("Scrollbar background color is:" + + bar.getBackground()); + if (Color.red.equals(bar.getBackground())) { + System.err.println("ScrollBar background is red"); + passed = false; + } + System.out.println("Choice background color is:" + + choice.getBackground()); + if (Color.red.equals(choice.getBackground())) { + System.err.println("Choice background is red"); + passed = false; + } + System.out.println("List background color is:" + + list.getBackground()); + if (Color.red.equals(list.getBackground())) { + System.err.println("List background is red"); + passed = false; + } + System.out.println("TextField background color is:" + + tf.getBackground()); + if (Color.red.equals(tf.getBackground())) { + System.err.println("TextField background is red"); + passed = false; + } + System.out.println("TextArea background color is:" + + ta.getBackground()); + if (Color.red.equals(ta.getBackground())) { + System.err.println("TextArea background is red"); + passed = false; + } + + if (!passed) { + throw new RuntimeException("One or more component inherited" + + " background from a Frame"); + } + } + + public void dispose() { + frame.dispose(); + } +} diff --git a/test/jdk/java/awt/Component/ComponentEventTest.java b/test/jdk/java/awt/Component/ComponentEventTest.java new file mode 100644 index 00000000000..bfbfed336a0 --- /dev/null +++ b/test/jdk/java/awt/Component/ComponentEventTest.java @@ -0,0 +1,357 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Button; +import java.awt.Checkbox; +import java.awt.Choice; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.Label; +import java.awt.List; +import java.awt.Panel; +import java.awt.Point; +import java.awt.Robot; +import java.awt.Scrollbar; +import java.awt.TextArea; +import java.awt.TextField; +import java.awt.event.ComponentEvent; +import java.awt.event.ComponentListener; +import java.awt.event.InputEvent; +import java.lang.reflect.InvocationTargetException; + +import jdk.test.lib.Platform; + +/* + * @test + * @key headful + * @bug 8333403 + * @summary Test performs various operations to check components events are triggered properly. + * @library /test/lib + * @build jdk.test.lib.Platform + * @run main ComponentEventTest + */ +public class ComponentEventTest { + + private static final int DELAY = 500; + + private static Frame frame; + private static Robot robot; + + private static Component[] components; + + private static volatile Point centerPoint; + + private static volatile boolean componentHidden; + private static volatile boolean componentShown; + private static volatile boolean componentMoved; + private static volatile boolean componentResized; + + private static final ComponentListener componentListener = + new ComponentListener() { + + @Override + public void componentShown(ComponentEvent e) { + System.out.println("ComponentShown: " + e.getSource()); + componentShown = true; + } + + @Override + public void componentResized(ComponentEvent e) { + System.out.println("ComponentResized: " + e.getSource()); + componentResized = true; + } + + @Override + public void componentMoved(ComponentEvent e) { + System.out.println("ComponentMoved: " + e.getSource()); + componentMoved = true; + } + + @Override + public void componentHidden(ComponentEvent e) { + System.out.println("ComponentHidden: " + e.getSource()); + componentHidden = true; + } + }; + + private static void initializeGUI() { + frame = new Frame("Component Event Test"); + frame.setLayout(new FlowLayout()); + + Panel panel = new Panel(); + Button button = new Button("Button"); + Label label = new Label("Label"); + List list = new List(); + list.add("One"); + list.add("Two"); + list.add("Three"); + Choice choice = new Choice(); + choice.add("Red"); + choice.add("Orange"); + choice.add("Yellow"); + Checkbox checkbox = new Checkbox("Checkbox"); + Scrollbar scrollbar = new Scrollbar(Scrollbar.HORIZONTAL, 0, 1, 0, 255); + TextField textfield = new TextField(15); + TextArea textarea = new TextArea(5, 15); + + components = new Component[] { panel, button, label, list, choice, + checkbox, scrollbar, textfield, textarea, frame }; + + for (int i = 0; i < components.length - 1; i++) { + components[i].addComponentListener(componentListener); + frame.add(components[i]); + } + frame.addComponentListener(componentListener); + + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } + + public static void main(String[] args) throws Exception { + try { + robot = new Robot(); + robot.setAutoWaitForIdle(true); + + EventQueue.invokeAndWait(ComponentEventTest::initializeGUI); + robot.waitForIdle(); + robot.delay(DELAY); + + doTest(); + + System.out.println("Test PASSED"); + } finally { + EventQueue.invokeAndWait(ComponentEventTest::disposeFrame); + } + } + + private static void doTest() + throws InvocationTargetException, InterruptedException { + // Click the frame to ensure it gains focus + clickFrame(); + + robot.delay(DELAY); + + for (int i = 0; i < components.length; i++) { + for (boolean state : new boolean[] { true, false }) { + doTest(components[i], state); + } + } + + robot.delay(DELAY); + + System.out.println("Iconify frame"); + resetValues(); + testIconifyFrame(); + + System.out.println("Deiconify frame"); + resetValues(); + testDeiconifyFrame(); + } + + private static void clickFrame() + throws InvocationTargetException, InterruptedException { + EventQueue.invokeAndWait(() -> { + Point location = frame.getLocationOnScreen(); + Dimension size = frame.getSize(); + centerPoint = new Point(location.x + size.width / 2, + location.y + size.height / 2); + }); + + robot.mouseMove(centerPoint.x, centerPoint.y); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + } + + private static void testIconifyFrame() + throws InvocationTargetException, InterruptedException { + EventQueue.invokeAndWait(() -> frame.setExtendedState(Frame.ICONIFIED)); + + robot.waitForIdle(); + robot.delay(DELAY); + if (componentShown || componentHidden || componentMoved + || componentResized) { + throw new RuntimeException( + "ComponentEvent triggered when frame is iconified"); + } + } + + private static void testDeiconifyFrame() + throws InvocationTargetException, InterruptedException { + EventQueue.invokeAndWait(() -> frame.setExtendedState(Frame.NORMAL)); + + robot.waitForIdle(); + robot.delay(DELAY); + + /* + * Because of the different behavior between MS Windows and other OS, we + * receive native events WM_SIZE and WM_MOVE on Windows when the frame + * state changes from iconified to normal. AWT sends these events to + * components when it receives the events from the native system. See + * JDK-6754618 for more information. + */ + + if (componentShown || componentHidden) { + throw new RuntimeException( + "FAIL: componentShown or componentHidden triggered " + + "when frame set to normal"); + } + + if (Platform.isWindows() && (!componentMoved || !componentResized)) { + throw new RuntimeException( + "FAIL: componentMoved or componentResized wasn't triggered " + + "when frame set to normal"); + } + if (!Platform.isWindows() && (componentMoved || componentResized)) { + throw new RuntimeException( + "FAIL: componentMoved or componentResized triggered " + + "when frame set to normal"); + } + } + + private static void doTest(final Component currentComponent, boolean enable) + throws InvocationTargetException, InterruptedException { + + System.out.println("Component " + currentComponent); + System.out.println(" enabled " + enable); + + EventQueue.invokeAndWait(() -> { + currentComponent.setEnabled(enable); + revalidateFrame(); + }); + + robot.delay(DELAY); + + resetValues(); + EventQueue.invokeAndWait(() -> { + currentComponent.setVisible(false); + revalidateFrame(); + }); + + robot.delay(DELAY); + if (!componentHidden) { + throw new RuntimeException("FAIL: ComponentHidden not triggered for" + + currentComponent.getClass()); + } + + resetValues(); + EventQueue.invokeAndWait(() -> { + currentComponent.setVisible(false); + revalidateFrame(); + }); + + robot.delay(DELAY); + if (componentHidden) { + throw new RuntimeException("FAIL: ComponentHidden triggered when " + + "setVisible(false) called for a hidden " + + currentComponent.getClass()); + } + + resetValues(); + EventQueue.invokeAndWait(() -> { + currentComponent.setVisible(true); + revalidateFrame(); + }); + + robot.delay(DELAY); + if (!componentShown) { + throw new RuntimeException("FAIL: ComponentShown not triggered for " + + currentComponent.getClass()); + } + + resetValues(); + EventQueue.invokeAndWait(() -> { + currentComponent.setVisible(true); + revalidateFrame(); + }); + + robot.delay(DELAY); + if (componentShown) { + throw new RuntimeException("FAIL: ComponentShown triggered when " + + "setVisible(true) called for a shown " + + currentComponent.getClass()); + } + + resetValues(); + EventQueue.invokeAndWait(() -> { + currentComponent.setLocation(currentComponent.getLocation().x + 1, + currentComponent.getLocation().y); + revalidateFrame(); + }); + + robot.delay(DELAY); + if (!componentMoved) { + throw new RuntimeException("FAIL: ComponentMoved not triggered for " + + currentComponent.getClass()); + } + + resetValues(); + EventQueue.invokeAndWait(() -> { + currentComponent.setSize(currentComponent.getSize().width + 1, + currentComponent.getSize().height); + revalidateFrame(); + }); + + robot.delay(DELAY); + if (!componentResized) { + throw new RuntimeException("FAIL: ComponentResized not triggered " + + "when size increases for " + currentComponent.getClass()); + } + + resetValues(); + EventQueue.invokeAndWait(() -> { + currentComponent.setSize(currentComponent.getSize().width - 1, + currentComponent.getSize().height); + revalidateFrame(); + }); + + robot.delay(DELAY); + if (!componentResized) { + throw new RuntimeException("FAIL: ComponentResized not triggered " + + "when size decreases for " + currentComponent.getClass()); + } + + System.out.println("\n"); + } + + private static void revalidateFrame() { + frame.invalidate(); + frame.validate(); + } + + private static void resetValues() { + componentShown = false; + componentHidden = false; + componentMoved = false; + componentResized = false; + } + + private static void disposeFrame() { + if (frame != null) { + frame.dispose(); + } + } +} diff --git a/test/jdk/java/awt/Component/ComponentLeakTest/ComponentLeakTest.java b/test/jdk/java/awt/Component/ComponentLeakTest/ComponentLeakTest.java new file mode 100644 index 00000000000..2936880dde6 --- /dev/null +++ b/test/jdk/java/awt/Component/ComponentLeakTest/ComponentLeakTest.java @@ -0,0 +1,769 @@ +/* + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @key headful + * @requires (os.family != "linux") + * @bug 4119609 4149812 4136116 4171960 4170095 4294016 4343272 + * @summary This test verifies that java.awt objects are being garbage + * collected correctly. That is, it ensures that unneeded + * references (such as JNI global refs or refs in static arrays) + * do not remain after the object is disposed. + * @run main/othervm ComponentLeakTest + */ + +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.Canvas; +import java.awt.CardLayout; +import java.awt.Checkbox; +import java.awt.CheckboxGroup; +import java.awt.CheckboxMenuItem; +import java.awt.Choice; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dialog; +import java.awt.Dimension; +import java.awt.FileDialog; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.GraphicsConfiguration; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.GridLayout; +import java.awt.Label; +import java.awt.LayoutManager; +import java.awt.List; +import java.awt.Menu; +import java.awt.MenuBar; +import java.awt.MenuItem; +import java.awt.MenuShortcut; +import java.awt.Panel; +import java.awt.PopupMenu; +import java.awt.ScrollPane; +import java.awt.Scrollbar; +import java.awt.TextArea; +import java.awt.TextField; +import java.awt.Window; +import java.awt.dnd.DropTarget; +import java.awt.dnd.DropTargetDragEvent; +import java.awt.dnd.DropTargetDropEvent; +import java.awt.dnd.DropTargetEvent; +import java.awt.dnd.DropTargetListener; +import java.lang.ref.PhantomReference; +import java.lang.ref.Reference; +import java.lang.ref.ReferenceQueue; +import java.util.Map; +import java.util.HashMap; + +public class ComponentLeakTest { + + public static void main(String[] args) { + final int iter = 5; + + for(int count = 0; count < iter; count++) { + MainFrame f = new MainFrame(); + MainWindow w = new MainWindow(f); + MainDialog d = new MainDialog(f); + TestFileDialog fd = new TestFileDialog(f, "TestFileDialog"); + fd.addNotify(); // fd.show() hangs + + fd.dispose(); + d.dispose(); + w.dispose(); + f.dispose(); + } + + // Test layout managers + Frame border = new Frame(); + border.setLayout(new BorderLayout()); + Frame card = new Frame(); + card.setLayout(new CardLayout()); + Frame flow = new Frame(); + flow.setLayout(new FlowLayout()); + Frame gridBag = new Frame(); + gridBag.setLayout(new GridBagLayout()); + Frame grid = new Frame(); + grid.setLayout(new GridLayout(1, 2)); + + for (int count = 0; count < iter; count++) { + border.add(new BorderTestButton("BorderTest"), + BorderLayout.WEST); + border.add(new BorderTestButton("BorderTest"), + BorderLayout.EAST); + card.add(new CardTestButton("CardTest"), "card0"); + card.add(new CardTestButton("CardTest"), "card1"); + flow.add(new FlowTestButton()); + flow.add(new FlowTestButton()); + gridBag.add(new GridBagTestButton(), new GridBagConstraints()); + gridBag.add(new GridBagTestButton(), new GridBagConstraints()); + grid.add(new GridTestButton()); + grid.add(new GridTestButton()); + + border.removeAll(); + card.removeAll(); + flow.removeAll(); + gridBag.removeAll(); + grid.removeAll(); + } + + gc(5); + try { + Thread.sleep(1000); + } catch (InterruptedException ie) { + } + + freeReferences(); + reportLeaks(); + System.err.println("Test passed."); + } + + public static void initWindow(Window w) { + w.setSize(600, 400); + w.setLayout(new FlowLayout()); + + // peered components + w.add(new TestButton("Button")); + w.add(new TestCanvas()); + w.add(new TestCheckbox("Checkbox", true)); + TestChoice choice = new TestChoice(); + choice.add("Choice 1"); + choice.add("Choice Two"); + w.add(choice); + w.add(new TestLabel("Label")); + TestList list = new TestList(); + list.add("List 1"); + list.add("List Two"); + w.add(list); + w.add(new TestScrollbar(Scrollbar.VERTICAL)); + w.add(new TestScrollbar(Scrollbar.HORIZONTAL)); + TestScrollPane scrollpane = new TestScrollPane(); + scrollpane.add(new TestButton("Button in a scrollpane")); + w.add(scrollpane); + w.add(new TestTextArea("TextArea", 3, 30)); + w.add(new TestTextField("TextField")); + + // nested components + TestPanel panel1 = new TestPanel(); + panel1.setLayout(new FlowLayout()); + panel1.setBackground(Color.red); + w.add(panel1); + + panel1.add(new TestButton("level 2")); + + Panel panel2 = new Panel(); + panel2.setLayout(new FlowLayout()); + panel2.setBackground(Color.green); + panel1.add(panel2); + + panel2.add(new TestButton("level 3")); + + w.add(new TestLightweight("Lightweight")); + } + + private static ReferenceQueue queue = new ReferenceQueue(); + private static Map refs = new HashMap(); + + public static void register(Object obj) { + PhantomReference ref = new PhantomReference(obj, queue); + refs.put(ref, obj.getClass().getName()); + } + + private static void gc() { + System.gc(); + try { + Thread.sleep(100); + } catch (InterruptedException ie) { + throw new RuntimeException("Test was interrupted"); + } + } + + private static void gc(int num) { + for (; num > 0; num--) { + gc(); + } + } + + public static void freeReferences() { + System.err.println("Total references: " + refs.size()); + boolean wasFreed = false; + do { + Object[] arr = new Object[2000]; + gc(5); + Reference ref = null; + wasFreed = false; + while ((ref = queue.poll()) != null) { + refs.remove(ref); + wasFreed = true; + gc(); + } + } while (wasFreed); + } + + public static void reportLeaks() { + for (Reference ref : refs.keySet()) { + System.err.println("Leaked " + refs.get(ref)); + } + + if (refs.size() > 0) { + throw new RuntimeException("Some references remained: " + refs.size()); + } + } +} + +class TestFrame extends Frame { + public TestFrame() { + ComponentLeakTest.register(this); + setDropTarget(new TestDropTarget(this)); + } + + public TestFrame(String title) { + super(title); + ComponentLeakTest.register(this); + setDropTarget(new TestDropTarget(this)); + } +} + +class TestWindow extends Window { + public TestWindow(Frame owner) { + super(owner); + ComponentLeakTest.register(this); + setDropTarget(new TestDropTarget(this)); + } + + public TestWindow(Window owner) { + super(owner); + ComponentLeakTest.register(this); + setDropTarget(new TestDropTarget(this)); + } +} + +class TestDialogL extends Dialog { + public TestDialogL(Frame owner) { + super(owner); + ComponentLeakTest.register(this); + setDropTarget(new TestDropTarget(this)); + } + + public TestDialogL(Frame owner, boolean modal) { + super(owner, modal); + ComponentLeakTest.register(this); + setDropTarget(new TestDropTarget(this)); + } + + public TestDialogL(Frame owner, String title) { + super(owner, title); + ComponentLeakTest.register(this); + setDropTarget(new TestDropTarget(this)); + } + + public TestDialogL(Frame owner, String title, boolean modal) { + super(owner, title, modal); + ComponentLeakTest.register(this); + setDropTarget(new TestDropTarget(this)); + } + + public TestDialogL(Dialog owner) { + super(owner); + ComponentLeakTest.register(this); + setDropTarget(new TestDropTarget(this)); + } + + public TestDialogL(Dialog owner, String title) { + super(owner, title); + ComponentLeakTest.register(this); + setDropTarget(new TestDropTarget(this)); + } + + public TestDialogL(Dialog owner, String title, boolean modal) { + super(owner, title, modal); + ComponentLeakTest.register(this); + setDropTarget(new TestDropTarget(this)); + } +} + +class TestFileDialog extends FileDialog { + public TestFileDialog(Frame parent) { + super(parent); + ComponentLeakTest.register(this); + setDropTarget(new TestDropTarget(this)); + } + + public TestFileDialog(Frame parent, String title) { + super(parent, title); + ComponentLeakTest.register(this); + setDropTarget(new TestDropTarget(this)); + } + + public TestFileDialog(Frame parent, String title, int mode) { + super(parent, title, mode); + ComponentLeakTest.register(this); + setDropTarget(new TestDropTarget(this)); + } +} + +class TestButton extends Button { + public TestButton() { + ComponentLeakTest.register(this); + setDropTarget(new TestDropTarget(this)); + } + + public TestButton(String title) { + super(title); + ComponentLeakTest.register(this); + setDropTarget(new TestDropTarget(this)); + } +} + +class TestCanvas extends Canvas { + int width = 100; + int height = 100; + + public TestCanvas() { + ComponentLeakTest.register(this); + setDropTarget(new TestDropTarget(this)); + } + + public TestCanvas(GraphicsConfiguration config) { + super(config); + ComponentLeakTest.register(this); + setDropTarget(new TestDropTarget(this)); + } + + public void paint(Graphics g) { + g.setColor(Color.blue); + g.fillRoundRect(10, 10, 50, 50, 15, 30); + g.setColor(Color.red); + g.fillOval(70, 70, 25, 25); + } + + public Dimension getPreferredSize() { + return new Dimension(width, height); + } +} + +class TestCheckbox extends Checkbox { + public TestCheckbox() { + ComponentLeakTest.register(this); + setDropTarget(new TestDropTarget(this)); + } + + public TestCheckbox(String label) { + super(label); + ComponentLeakTest.register(this); + setDropTarget(new TestDropTarget(this)); + } + + public TestCheckbox(String label, boolean state) { + super(label, state); + ComponentLeakTest.register(this); + setDropTarget(new TestDropTarget(this)); + } + + public TestCheckbox(String label, boolean state, CheckboxGroup group) { + super(label, state, group); + ComponentLeakTest.register(this); + setDropTarget(new TestDropTarget(this)); + } + + public TestCheckbox(String label, CheckboxGroup group, boolean state) { + super(label, group, state); + ComponentLeakTest.register(this); + setDropTarget(new TestDropTarget(this)); + } +} + +class TestChoice extends Choice { + public TestChoice() { + ComponentLeakTest.register(this); + setDropTarget(new TestDropTarget(this)); + } +} + +class TestLabel extends Label { + public TestLabel() { + ComponentLeakTest.register(this); + setDropTarget(new TestDropTarget(this)); + } + + public TestLabel(String text) { + super(text); + ComponentLeakTest.register(this); + setDropTarget(new TestDropTarget(this)); + } + + public TestLabel(String text, int align) { + super(text, align); + ComponentLeakTest.register(this); + setDropTarget(new TestDropTarget(this)); + } +} + +class TestList extends List { + public TestList() { + ComponentLeakTest.register(this); + setDropTarget(new TestDropTarget(this)); + } + + public TestList(int rows) { + super(rows); + ComponentLeakTest.register(this); + setDropTarget(new TestDropTarget(this)); + } + + public TestList(int rows, boolean multipleMode) { + super(rows, multipleMode); + ComponentLeakTest.register(this); + setDropTarget(new TestDropTarget(this)); + } +} + +class TestScrollbar extends Scrollbar { + public TestScrollbar() { + ComponentLeakTest.register(this); + setDropTarget(new TestDropTarget(this)); + } + + public TestScrollbar(int orientation) { + super(orientation); + ComponentLeakTest.register(this); + setDropTarget(new TestDropTarget(this)); + } + + public TestScrollbar(int orient, int val, int visible, int min, int max) { + super(orient, val, visible, min, max); + ComponentLeakTest.register(this); + setDropTarget(new TestDropTarget(this)); + } +} + +class TestScrollPane extends ScrollPane { + public TestScrollPane() { + ComponentLeakTest.register(this); + setDropTarget(new TestDropTarget(this)); + } + + public TestScrollPane(int policy) { + super(policy); + ComponentLeakTest.register(this); + setDropTarget(new TestDropTarget(this)); + } +} + +class TestTextField extends TextField { + public TestTextField() { + ComponentLeakTest.register(this); + requestFocus(); + setDropTarget(new TestDropTarget(this)); + } + + public TestTextField(String text) { + super(text); + ComponentLeakTest.register(this); + requestFocus(); + setDropTarget(new TestDropTarget(this)); + } + + public TestTextField(int columns) { + super(columns); + ComponentLeakTest.register(this); + requestFocus(); + setDropTarget(new TestDropTarget(this)); + } + + public TestTextField(String text, int columns) { + super(text, columns); + ComponentLeakTest.register(this); + requestFocus(); + setDropTarget(new TestDropTarget(this)); + } +} + +class TestTextArea extends TextArea { + public TestTextArea() { + ComponentLeakTest.register(this); + requestFocus(); + setDropTarget(new TestDropTarget(this)); + } + + public TestTextArea(String text) { + super(text); + ComponentLeakTest.register(this); + requestFocus(); + setDropTarget(new TestDropTarget(this)); + } + + public TestTextArea(int rows, int columns) { + super(rows, columns); + ComponentLeakTest.register(this); + requestFocus(); + setDropTarget(new TestDropTarget(this)); + } + + public TestTextArea(String text, int rows, int columns) { + super(text, rows, columns); + ComponentLeakTest.register(this); + requestFocus(); + setDropTarget(new TestDropTarget(this)); + } + + public TestTextArea(String text, int rows, int columns, int bars) { + super(text, rows, columns, bars); + ComponentLeakTest.register(this); + requestFocus(); + setDropTarget(new TestDropTarget(this)); + } +} + +class TestPanel extends Panel { + public TestPanel() { + ComponentLeakTest.register(this); + setDropTarget(new TestDropTarget(this)); + } + + public TestPanel(LayoutManager layout) { + super(layout); + ComponentLeakTest.register(this); + setDropTarget(new TestDropTarget(this)); + } +} +class TestMenu extends Menu { + public TestMenu() { + ComponentLeakTest.register(this); + } + + public TestMenu(String label) { + super(label); + ComponentLeakTest.register(this); + } + + public TestMenu(String label, boolean tearOff) { + super(label, tearOff); + ComponentLeakTest.register(this); + } +} + +class TestMenuItem extends MenuItem { + public TestMenuItem() { + ComponentLeakTest.register(this); + } + public TestMenuItem(String label) { + super(label); + ComponentLeakTest.register(this); + } + + public TestMenuItem(String label, MenuShortcut s) { + super(label, s); + ComponentLeakTest.register(this); + } +} + +class TestMenuBar extends MenuBar { + public TestMenuBar() { + ComponentLeakTest.register(this); + } +} + +class TestPopupMenu extends PopupMenu { + public TestPopupMenu() { + ComponentLeakTest.register(this); + } + + public TestPopupMenu(String label) { + super(label); + ComponentLeakTest.register(this); + } +} + +class TestCheckboxMenuItem extends CheckboxMenuItem { + public TestCheckboxMenuItem() { + ComponentLeakTest.register(this); + } + + public TestCheckboxMenuItem(String label) { + super(label); + ComponentLeakTest.register(this); + } + + public TestCheckboxMenuItem(String label, boolean state) { + super(label, state); + ComponentLeakTest.register(this); + } +} + +class BorderTestButton extends Button { + public BorderTestButton() { + ComponentLeakTest.register(this); + } + + public BorderTestButton(String title) { + super(title); + ComponentLeakTest.register(this); + } +} + +class CardTestButton extends Button { + public CardTestButton() { + ComponentLeakTest.register(this); + } + + public CardTestButton(String title) { + super(title); + ComponentLeakTest.register(this); + } +} + +class FlowTestButton extends Button { + public FlowTestButton() { + ComponentLeakTest.register(this); + } + + public FlowTestButton(String title) { + super(title); + ComponentLeakTest.register(this); + } +} + +class GridBagTestButton extends Button { + public GridBagTestButton() { + ComponentLeakTest.register(this); + } + + public GridBagTestButton(String title) { + super(title); + ComponentLeakTest.register(this); + } +} + +class GridTestButton extends Button { + public GridTestButton() { + ComponentLeakTest.register(this); + } + + public GridTestButton(String title) { + super(title); + ComponentLeakTest.register(this); + } +} + +class TestLightweight extends Component { + String label; + int width = 100; + int height = 30; + + public TestLightweight(String label) { + this.label = label; + ComponentLeakTest.register(this); + } + + public void paint(Graphics g) { + Dimension d = getSize(); + g.setColor(Color.orange); + g.fillRect(0, 0, d.width, d.height); + g.setColor(Color.black); + int x = 5; + int y = (d.height - 5); + g.drawString(label, x, y); + } + + public Dimension getPreferredSize() { + return new Dimension(width,height); + } +} + +class TestDropTarget extends DropTarget { + public TestDropTarget(Component comp) { + super(comp, new DropTargetListener() { + public void dragEnter(DropTargetDragEvent dtde) {} + public void dragOver(DropTargetDragEvent dtde) {} + public void dropActionChanged(DropTargetDragEvent dtde) {} + public void dragExit(DropTargetEvent dte) {} + public void drop(DropTargetDropEvent dtde) {} + }); + ComponentLeakTest.register(this); + } +} + +class MainWindow extends TestWindow { + public MainWindow(Frame f) { + super(f); + ComponentLeakTest.initWindow(this); + setVisible(true); + + TestPopupMenu popup = new TestPopupMenu("hi"); + add(popup); + popup.show(this, 5, 5); + } +} + +class MainDialog extends TestDialogL { + public MainDialog(Frame f) { + super(f, "MainDialog", false); + ComponentLeakTest.initWindow(this); + setVisible(true); + + TestPopupMenu popup = new TestPopupMenu("hi"); + add(popup); + popup.show(this, 5, 5); + } +} + +class MainFrame extends TestFrame { + public MainFrame(){ + super("Component Leak Test MainFrame"); + + ComponentLeakTest.initWindow(this); + + TestMenu menu = new TestMenu("Print"); + TestMenu menu2 = new TestMenu("File"); + TestMenu menu3 = new TestMenu("Edit"); + TestMenu menu4 = new TestMenu("ReallyReallyReallyReallyReallyReallyReallyReally" + + "ReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyLong"); + menu2.setFont(new Font("SansSerif", Font.BOLD, 20)); + menu2.setEnabled(false); + menu3.setFont(new Font("Monospaced", Font.ITALIC, 18)); + menu3.setEnabled(false); + menu4.setEnabled(false); + TestMenuItem itemPrinter = new TestMenuItem("foobar"); + TestMenuItem itemScreen = new TestMenuItem("baz"); + TestCheckboxMenuItem itemCheck = new TestCheckboxMenuItem("yep"); + menu.add(itemPrinter); + menu.add(itemScreen); + menu.add(itemCheck); + TestMenuBar menuBar = new TestMenuBar(); + menuBar.add( menu ); + menuBar.add( menu2 ); + menuBar.add( menu3 ); + menuBar.add( menu4 ); + setMenuBar(menuBar); + + setVisible(true); + + TestPopupMenu popup = new TestPopupMenu("hi"); + add(popup); + popup.show(this, 5, 5); + } +} diff --git a/test/jdk/java/awt/Component/ComponentSerializationTest/ComponentSerializationTest.java b/test/jdk/java/awt/Component/ComponentSerializationTest/ComponentSerializationTest.java new file mode 100644 index 00000000000..ddf7efffdbd --- /dev/null +++ b/test/jdk/java/awt/Component/ComponentSerializationTest/ComponentSerializationTest.java @@ -0,0 +1,354 @@ +/* + * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4146452 + * @summary Tests serialization of peered and lightweight Components. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual ComponentSerializationTest + */ + +import java.awt.Button; +import java.awt.Canvas; +import java.awt.Checkbox; +import java.awt.CheckboxMenuItem; +import java.awt.Choice; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dialog; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.FileDialog; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Insets; +import java.awt.Label; +import java.awt.List; +import java.awt.Menu; +import java.awt.MenuBar; +import java.awt.MenuItem; +import java.awt.Panel; +import java.awt.ScrollPane; +import java.awt.Scrollbar; +import java.awt.TextArea; +import java.awt.TextField; +import java.awt.Window; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import javax.swing.JPanel; + +public class ComponentSerializationTest extends JPanel { + private MainFrame mf; + private MainWindow mw; + private MainDialog md; + private MainFileDialog mfd; + private static final String INSTRUCTIONS = """ + A Frame, a Window, and a Dialog should appear. From the Frame's + "Serialize" menu, select "Serialize!". Another Frame, Window, and + Dialog should appear exactly on top of the existing ones. The state + and functionality of the two sets of Windows should be identical. If + any errors or exceptions appear in the log area, or if the second set of + Windows is different from the first, the test fails. Otherwise, the + test passes. + """; + + private static final ArrayList toDispose = new ArrayList<>(); + + public ComponentSerializationTest() { + mf = new MainFrame(); + toDispose.add(mf); + mw = new MainWindow(mf); + toDispose.add(mw); + md = new MainDialog(mf); + toDispose.add(md); + mfd = new MainFileDialog(mf); + toDispose.add(mfd); + } + + public static void main(String[] argc) throws InterruptedException, + InvocationTargetException { + PassFailJFrame.builder() + .title("Component Serialization Test") + .splitUI(ComponentSerializationTest::new) + .instructions(INSTRUCTIONS) + .columns(40) + .logArea() + .build() + .awaitAndCheck(); + for (Window w : toDispose) { + if (w != null) { + EventQueue.invokeAndWait(w::dispose); + } + } + } + + private void initWindow(Window w) { + w.setSize(600, 400); + w.setLayout(new FlowLayout()); + + // peered components + w.add(new Button("Button")); + w.add(new TestCanvas()); + w.add(new Checkbox("Checkbox", true)); + Choice choice = new Choice(); + choice.add("Choice 1"); + choice.add("Choice Two"); + w.add(choice); + w.add(new Label("Label")); + List list = new List(); + list.add("List 1"); + list.add("List Two"); + w.add(list); + w.add(new Scrollbar(Scrollbar.VERTICAL)); + w.add(new Scrollbar(Scrollbar.HORIZONTAL)); + ScrollPane scrollpane = new ScrollPane(); + scrollpane.add(new Button("Button in a scrollpane")); + w.add(scrollpane); + w.add(new TextArea("TextArea", 3, 30)); + w.add(new TextField("TextField")); + + // nested components + Panel panel1 = new Panel(); + panel1.setLayout(new FlowLayout()); + panel1.setBackground(Color.red); + w.add(panel1); + + panel1.add(new Button("level 2")); + + Panel panel2 = new Panel(); + panel2.setLayout(new FlowLayout()); + panel2.setBackground(Color.green); + panel1.add(panel2); + + panel2.add(new Button("level 3")); + + // lightweight components + w.add(new LWButton("LWbutton") ); + + // overlapping components + w.add(new ZOrderPanel()); + } + + class MainWindow extends Window { + public MainWindow(Frame f) { + super(f); + initWindow(this); + setLocation(650, 0); + setVisible(true); + } + } + + class MainDialog extends Dialog { + public MainDialog(Frame f) { + super(f, "MainDialog", false); + initWindow(this); + setLocation(0, 450); + setVisible(true); + } + } + + class MainFileDialog extends FileDialog { + public MainFileDialog(Frame f) { + super(f, "MainFileDialog", FileDialog.SAVE); + setLocation(650, 450); + addNotify(); + } + } + + class MainFrame extends Frame { + public MainFrame() { + super("ComponentSerializationTest"); + initWindow(this); + + Menu menu = new Menu("Serialize"); + Menu menu2 = new Menu("File"); + Menu menu3 = new Menu("Edit"); + Menu menu4 = new Menu("ReallyReallyReallyReallyReallyReallyReallyReally" + + "ReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyLong"); + menu2.setFont(new Font("SansSerif", Font.BOLD, 20)); + menu2.setEnabled(false); + menu3.setFont(new Font("Monospaced", Font.ITALIC, 18)); + menu3.setEnabled(false); + menu4.setEnabled(false); + MenuItem itemSerialize = new MenuItem("Serialize!"); + CheckboxMenuItem itemCheck = new CheckboxMenuItem("Check me"); + menu.add(itemSerialize); + menu.add(itemCheck); + MenuBar menuBar = new MenuBar(); + menuBar.add(menu); + menuBar.add(menu2); + menuBar.add(menu3); + menuBar.add(menu4); + setMenuBar(menuBar); + + itemSerialize.addActionListener(new ActionSerialize()); + + setLocation(0, 0); + setVisible(true); + } + } + + class ActionSerialize implements ActionListener { + public void actionPerformed(ActionEvent ev) { + Frame f2 = null; + Window w2 = null; + Dialog d2 = null; + FileDialog fd2 = null; + + try { + FileOutputStream fos = new FileOutputStream("tmp"); + ObjectOutputStream oos = new ObjectOutputStream(fos); + oos.writeObject(mf); + oos.writeObject(mw); + oos.writeObject(md); + oos.writeObject(mfd); + oos.flush(); + + FileInputStream fis = new FileInputStream("tmp"); + ObjectInputStream ois = new ObjectInputStream(fis); + f2 = (Frame)ois.readObject(); + w2 = (Window)ois.readObject(); + d2 = (Dialog)ois.readObject(); + fd2= (FileDialog)ois.readObject(); + } catch (Exception e) { + PassFailJFrame.log(e.getMessage()); + } + + if (f2 == null || w2 == null || d2 == null || fd2 == null) { + PassFailJFrame.log("ERROR: one of the components was not deserialized."); + PassFailJFrame.log("frame = " + f2); + PassFailJFrame.log("window = " + w2); + PassFailJFrame.log("dialog = " + d2); + PassFailJFrame.log("file dalog = " + fd2); + } + + if (f2 != null) { + toDispose.add(f2); + f2.setVisible(true); + } + if (w2 != null) { + toDispose.add(w2); + w2.setVisible(true); + } + if (d2 != null) { + toDispose.add(d2); + d2.setVisible(true); + } + if (fd2 != null) { + toDispose.add(fd2); + fd2.addNotify(); + } + } + } + + class LWButton extends Component { + String label; + int width = 100; + int height = 30; + + public LWButton(String label) { + super(); + this.label = label; + } + + public void paint(Graphics g) { + Dimension d = getSize(); + g.setColor(Color.orange); + g.fillRect(0, 0, d.width, d.height); + g.setColor(Color.black); + int x = 5; + int y = (d.height - 5); + g.drawString(label, x, y); + } + + public Dimension getPreferredSize() { + return new Dimension(width, height); + } + } + + class TestCanvas extends Canvas { + int width = 100; + int height = 100; + + public void paint(Graphics g) { + g.setColor(Color.blue); + g.fillRoundRect(10, 10, 50, 50, 15, 30); + g.setColor(Color.red); + g.fillOval(70, 70, 25, 25); + } + public Dimension getPreferredSize() { + return new Dimension(width, height); + } + } + + class ZOrderPanel extends Panel { + public ZOrderPanel() { + setLayout(null); + + Component first, second, third, fourth; + + show(); + first = makeBox("Second", Color.blue, -1); + second = makeBox("First", Color.yellow, 0); + fourth = makeBox("Fourth", Color.red, 2); + third = makeBox("Third", Color.green, 3); + remove(third); + add(third, 2); + validate(); + add(new LWButton("LWButton"), 0); + } + + public Dimension preferredSize() { + return new Dimension(260, 80); + } + + public void layout() { + int i, n; + Insets ins = insets(); + n = countComponents(); + for (i = n - 1; i >= 0; i--) { + Component p = getComponent(i); + p.reshape(ins.left + 40 * i, ins.top + 5 * i, 60, 60); + } + } + + public Component makeBox(String s, Color c, int index) { + Label l = new Label(s); + l.setBackground(c); + l.setAlignment(Label.RIGHT); + add(l, index); + validate(); + return l; + } + } +} diff --git a/test/jdk/java/awt/Component/FlickeringOnScroll/FlickeringOnScroll.java b/test/jdk/java/awt/Component/FlickeringOnScroll/FlickeringOnScroll.java new file mode 100644 index 00000000000..2119ae7bcc0 --- /dev/null +++ b/test/jdk/java/awt/Component/FlickeringOnScroll/FlickeringOnScroll.java @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6347994 + * @summary REG: Scrollbar, Choice, Checkbox flickers and grays out when scrolling, XToolkit + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual FlickeringOnScroll + */ + +import java.awt.BorderLayout; +import java.awt.Checkbox; +import java.awt.Choice; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.MenuItem; +import java.awt.Panel; +import java.awt.PopupMenu; +import java.awt.Scrollbar; +import java.awt.TextArea; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.lang.reflect.InvocationTargetException; + +public class FlickeringOnScroll extends Frame { + + static final String INSTRUCTIONS = """ + There are five components in the frame: + Scrollbars(vertical and horizontal), a Choice, + a Checkbox and a TextArea + 1) Drag the thumbs of each Scrollbar. + 2) Do the same with Choice's scrollbar. + 3) Focus on Checkbox and press left mouse button or SPACE repeatedly. + 4) Right click inside TextArea and navigate through all menu items + in PopupMenu using the arrow keys. + If you notice some component or its scrollbar flickers on + key/mouse press or drag, press Fail. Otherwise press Pass. + """; + + public FlickeringOnScroll() { + Choice ch = new Choice(); + ch.add("Praveen"); + ch.add("Mohan"); + ch.add("Rakesh"); + ch.add("Menon"); + ch.add("Girish"); + ch.add("Ramachandran"); + ch.add("Elancheran"); + ch.add("Subramanian"); + ch.add("Raju"); + ch.add("Pallath"); + ch.add("Mayank"); + ch.add("Joshi"); + ch.add("Sundar"); + ch.add("Srinivas"); + ch.add("Mandalika"); + Checkbox chb = new Checkbox ("Checkbox", false); + TextArea ta = new TextArea("Text Area"); + Panel panel = new Panel(); + PopupMenu popup = new PopupMenu("Popup"); + MenuItem mi1 = new MenuItem("mi1"); + MenuItem mi2 = new MenuItem("mi2"); + MenuItem mi3 = new MenuItem("mi3"); + MenuItem mi4 = new MenuItem("mi4"); + + setTitle("Flickering Scroll Area Testing Frame"); + setLayout(new FlowLayout()); + add(ch); + add(chb); + add(ta); + + panel.setLayout(new BorderLayout()); + panel.setPreferredSize(new Dimension(200, 200)); + add(panel); + panel.add("Center",new java.awt.Label("Scrollbar flickering test..." ,java.awt.Label.CENTER)); + panel.add("South",new Scrollbar(Scrollbar.HORIZONTAL, 0, 100, 0, 255)); + panel.add("East",new Scrollbar(Scrollbar.VERTICAL, 0, 100, 0, 255)); + + ta.add(popup); + popup.add (mi1); + popup.add (mi2); + popup.add (mi3); + popup.add (mi4); + + ta.addMouseListener(new MouseAdapter() { + public void mousePressed(MouseEvent me) { + if (me.isPopupTrigger()) { + if (popup != null) { + popup.show(me.getComponent(), me.getX(), me.getY()); + } + } + } + public void mouseReleased(MouseEvent me) { + if (me.isPopupTrigger()) { + if (popup != null) { + popup.show(me.getComponent(), me.getX(), me.getY()); + } + } + } + }); + + pack(); + } + + public static void main(String[] args) throws InterruptedException, + InvocationTargetException { + PassFailJFrame.builder() + .title("Scroll Area Flickering Repaint") + .testUI(FlickeringOnScroll::new) + .instructions(INSTRUCTIONS) + .columns(40) + .logArea() + .build() + .awaitAndCheck(); + } +} diff --git a/test/jdk/java/awt/Component/FocusRepaintTest/FocusRepaintTest.java b/test/jdk/java/awt/Component/FocusRepaintTest/FocusRepaintTest.java new file mode 100644 index 00000000000..ecffdfda613 --- /dev/null +++ b/test/jdk/java/awt/Component/FocusRepaintTest/FocusRepaintTest.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4079435 + * @summary Calling repaint() in focus handlers messes up the window. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual FocusRepaintTest + */ + +import java.awt.Button; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.lang.reflect.InvocationTargetException; + +public class FocusRepaintTest extends Frame implements FocusListener { + static final String INSTRUCTIONS = """ + Hit the tab key repeatedly in the Test window. + If any of the buttons disappear press Fail, otherwise press Pass. + """; + + public FocusRepaintTest() { + setTitle("Test"); + setLayout(new FlowLayout()); + setSize(200, 100); + Button b1 = new Button("Close"); + Button b2 = new Button("Button"); + add(b1); + add(b2); + b1.setSize(50, 30); + b2.setSize(50, 30); + b1.addFocusListener(this); + b2.addFocusListener(this); + } + + public void focusGained(FocusEvent e) { + Button b = (Button) e.getSource(); + PassFailJFrame.log("Focus gained for " + b.getLabel()); + b.repaint(); + } + + public void focusLost(FocusEvent e) { + Button b = (Button) e.getSource(); + PassFailJFrame.log("Focus lost for " + b.getLabel()); + b.repaint(); + } + + public static void main(String[] args) throws InterruptedException, + InvocationTargetException { + PassFailJFrame.builder() + .title("Focus Repaint") + .testUI(FocusRepaintTest::new) + .instructions(INSTRUCTIONS) + .columns(40) + .logArea() + .build() + .awaitAndCheck(); + } +} diff --git a/test/jdk/java/awt/Component/ListDoubleIndentTest/ListDoubleIndentTest.java b/test/jdk/java/awt/Component/ListDoubleIndentTest/ListDoubleIndentTest.java new file mode 100644 index 00000000000..4c6c1248950 --- /dev/null +++ b/test/jdk/java/awt/Component/ListDoubleIndentTest/ListDoubleIndentTest.java @@ -0,0 +1,148 @@ +/* + * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4185460 + * @summary Container list the indentation is 2x the indent param value + * @key headful + * @run main ListDoubleIndentTest + */ + +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.EventQueue; +import java.awt.Frame; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.io.IOException; +import java.io.PipedInputStream; +import java.io.PrintStream; +import java.io.PipedOutputStream; + +import java.lang.reflect.InvocationTargetException; +import java.util.Vector; + +public class ListDoubleIndentTest { + public static void main(final String[] args) throws InterruptedException, + InvocationTargetException { + EventQueue.invokeAndWait(new ListDoubleIndentTest()::performTest); + } + + public void performTest() { + boolean bReturn = false; + int iCompCount = 0; + int iNotEqual = 0; + int iIndentWrong = 0; + System.out.println("Test: Check indentation"); + Vector v = new Vector(); + String sLine; + String sReturn; + String sExpTrim; + Button b1, b2, b3, b4, b5; + Frame f = null; + + try { + f = new Frame("ListDoubleIndentTest"); + + f.add(b1 = new Button("North"), BorderLayout.NORTH, 0); + f.add(b2 = new Button("South"), BorderLayout.SOUTH, 1); + f.add(b3 = new Button("East"), BorderLayout.EAST, 2); + f.add(b4 = new Button("West"), BorderLayout.WEST, 3); + f.add(b5 = new Button("Center"), BorderLayout.CENTER, -1); + + String[] sExpected = {f.toString(), b1.toString(), b2.toString(), + b3.toString(), b4.toString(), b5.toString()}; + + iCompCount = f.getComponentCount(); + System.out.println("Component count: " + iCompCount); + + for (int j = 0; j <= 10; j++) { + PipedInputStream pin = new PipedInputStream(); + PrintStream output = new PrintStream(new PipedOutputStream(pin), true); + BufferedReader input = new BufferedReader(new InputStreamReader(pin)); + + f.list(output, j); + + output.flush(); + output.close(); + + while ((sLine = input.readLine()) != null) { + v.addElement(sLine); + } + + for (int i = 0; i < v.size(); i++) { + sReturn = (String)v.elementAt(i); + sExpTrim = sExpected[i].trim(); + + if (!(sExpTrim.equals(sReturn.trim()))) { + System.out.println("iNotEqual"); + ++iNotEqual; + } + + int iSpace = sReturn.lastIndexOf(' ') + 1; + + if (i == 0) { + System.out.println("Indent set at: " + j); + System.out.println("Indent return: " + iSpace); + if (iSpace != j) { + System.out.println("iIndentWrong1"); + ++iIndentWrong; + } + } else { + if (iSpace != (j + 1)) { + System.out.println(iSpace + "; " + j); + ++iIndentWrong; + } + } + System.out.println(sReturn); + } + v.removeAllElements(); + v.trimToSize(); + } + + if (iNotEqual == 0 && iIndentWrong == 0) { + bReturn = true; + } else { + bReturn = false; + } + + } catch(IOException e) { + bReturn = false; + System.out.println ("Unexpected Exception thrown: " + e.getMessage()); + e.printStackTrace(); + } finally { + if (f != null) { + f.dispose(); + } + } + + if (bReturn) { + System.out.println("Test for Container.list Passed"); + } else { + System.out.println("Test for Container.list Failed"); + throw new RuntimeException("Test FAILED"); + } + } +} diff --git a/test/jdk/java/awt/Component/MinMaxSizeDefensive/GetSizesTest.java b/test/jdk/java/awt/Component/MinMaxSizeDefensive/GetSizesTest.java new file mode 100644 index 00000000000..2b495487938 --- /dev/null +++ b/test/jdk/java/awt/Component/MinMaxSizeDefensive/GetSizesTest.java @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 4783989 + @summary get(Preferred|Minimum|Maximum)Size() must not return a reference. + The object copy of Dimension class needed. + @key headful + @run main GetSizesTest +*/ + +import java.awt.Button; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.Frame; +import java.lang.reflect.InvocationTargetException; + +public class GetSizesTest extends Frame { + Button b; + + public static void main(final String[] args) throws InterruptedException, + InvocationTargetException { + GetSizesTest app = new GetSizesTest(); + EventQueue.invokeAndWait(() -> { + try { + app.init(); + app.start(); + } finally { + app.dispose(); + } + }); + } + + public void init() { + b = new Button("button"); + add(b); + } + + public void start () { + setSize(200, 200); + setLocationRelativeTo(null); + setVisible(true); + validate(); + + System.out.println("Test set for Container (Frame)."); + + Dimension dimPref = getPreferredSize(); + dimPref.setSize(101, 101); + if (getPreferredSize().equals(new Dimension(101, 101))) { + throw new RuntimeException("Test Failed for: " + dimPref); + } + System.out.println("getPreferredSize() Passed."); + + Dimension dimMin = getMinimumSize(); + dimMin.setSize(101, 101); + if (getMinimumSize().equals(new Dimension(101, 101))) { + throw new RuntimeException("Test Failed for: " + dimMin); + } + System.out.println("getMinimumSize() Passed."); + + Dimension dimMax = getMaximumSize(); + dimMax.setSize(101, 101); + if (getMaximumSize().equals(new Dimension(101, 101))) { + throw new RuntimeException("Test Failed for: " + dimMax); + } + System.out.println("getMaximumSize() Passed."); + + System.out.println("Test set for Component (Button)."); + + dimPref = b.getPreferredSize(); + dimPref.setSize(33, 33); + if (b.getPreferredSize().equals(new Dimension(33, 33))) { + throw new RuntimeException("Test Failed for: " + dimPref); + } + System.out.println("getPreferredSize() Passed."); + + dimMin = b.getMinimumSize(); + dimMin.setSize(33, 33); + if (b.getMinimumSize().equals(new Dimension(33, 33))) { + throw new RuntimeException("Test Failed for: " + dimMin); + } + System.out.println("getMinimumSize() Passed."); + + dimMax = b.getMaximumSize(); + dimMax.setSize(33, 33); + if (b.getMaximumSize().equals(new Dimension(33, 33))) { + throw new RuntimeException("Test Failed for: " + dimMax); + } + System.out.println("getMaximumSize() Passed."); + System.out.println("GetSizesTest Succeeded."); + } +} diff --git a/test/jdk/java/awt/Component/PaintGlitchTest/PaintGlitchTest.java b/test/jdk/java/awt/Component/PaintGlitchTest/PaintGlitchTest.java new file mode 100644 index 00000000000..867d82d3262 --- /dev/null +++ b/test/jdk/java/awt/Component/PaintGlitchTest/PaintGlitchTest.java @@ -0,0 +1,225 @@ +/* + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4045781 + * @summary Exposed/damaged canvases don't always update correctly + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual PaintGlitchTest + */ + +import java.awt.Button; +import java.awt.Canvas; +import java.awt.Checkbox; +import java.awt.Choice; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dialog; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Label; +import java.awt.Menu; +import java.awt.MenuBar; +import java.awt.MenuItem; +import java.awt.Panel; +import java.awt.Scrollbar; +import java.awt.TextArea; +import java.awt.TextField; +import java.lang.reflect.InvocationTargetException; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.JScrollBar; +import javax.swing.JTextArea; +import javax.swing.JTextField; + +public class PaintGlitchTest extends Frame { + static final String INSTRUCTIONS = """ + 1. Click on the 'Painting Glitch Test' window and select from + its menu a content type (text, gradient, fill, + AWT components, Swing components etc.). + 2. Select 'Modal Dialog...' to create a dialog. + 3. Drag the dialog over the content very fast + for 10 seconds or so - make sure you + keep dragging while the content is painting. + 4. Verify that the area exposed by the drag (the damaged regions) + always update properly no white areas or bits of the dialog + should be left after the drag operation is + completed (i.e. after you let go of the mouse). + 5. Repeat for all other content types. + 6. If for any content type the damaged dialog is not properly + repainted press Fail. Otherwise press Pass. + """; + + public PaintGlitchTest() { + super("Painting Glitch Test"); + + TextPanel textPanel = new TextPanel(); + GradientPanel gradientPanel = new GradientPanel(); + ComponentPanel componentPanel = new ComponentPanel(); + SwingPanel swingPanel = new SwingPanel(); + + add(textPanel); + + MenuBar menubar = new MenuBar(); + Menu testMenu = new Menu("Test"); + testMenu.add(makeContentItem("Text Lines", textPanel) ); + testMenu.add(makeContentItem("Gradient Fill", gradientPanel) ); + testMenu.add(makeContentItem("AWT Components", componentPanel) ); + testMenu.add(makeContentItem("Swing Components", swingPanel) ); + testMenu.addSeparator(); + MenuItem dialogItem = new MenuItem("Modal Dialog..."); + dialogItem.addActionListener(ev -> new ObscuringDialog(PaintGlitchTest.this).show()); + testMenu.add(dialogItem); + testMenu.addSeparator(); + menubar.add(testMenu); + + setMenuBar(menubar); + setSize(400,300); + } + + public static void main(String args[]) throws InterruptedException, + InvocationTargetException { + PassFailJFrame.builder() + .title("Repaint Glitch") + .testUI(PaintGlitchTest::new) + .instructions(INSTRUCTIONS) + .columns(40) + .logArea() + .build() + .awaitAndCheck(); + } + + public MenuItem makeContentItem(String title, final Component content) { + MenuItem menuItem = new MenuItem(title); + menuItem.addActionListener( + ev -> { + remove(0); + add(content); + validate(); + } + ); + + return menuItem; + } +} + +class GradientPanel extends Canvas { + public void paint(Graphics g) { + long ms = System.currentTimeMillis(); + // just paint something that'll take a while + int x, y; + int width = getSize().width; + int height = getSize().height; + int step = 8; + + for (x = 0; x < width; x += step) { + for (y = 0; y < height; y += step) { + int red = (255 * y) / height; + int green = (255 * x * y) / (width * height); + int blue = (255 * x) / width; + + Color color = new Color(red, green, blue); + g.setColor(color); + g.fillRect(x, y, step, step); + } + } + long time = System.currentTimeMillis() - ms; + PassFailJFrame.log("GradientPanel paint took " + time + " ms"); + } + + public Dimension getPreferredSize() { + return new Dimension(200,1000); + } +} + +class TextPanel extends Canvas { + public void paint(Graphics g) { + long ms = System.currentTimeMillis(); + Font font = new Font("SanSerif", Font.ITALIC, 12); + + g.setFont(font); + // just paint something that'll take a while + int x, y; + int height = getHeight(); + int step = 16; + + for (x = y = 0; y < height; y += step) { + g.drawString(y + " : The quick brown fox jumps over the lazy dog. " + + "The rain in Spain falls mainly on the plain.", x, y); + } + long time = System.currentTimeMillis() - ms; + PassFailJFrame.log("TextPanel paint took " + time + " ms"); + } + + public Dimension getPreferredSize() { + return new Dimension(640,1000); + } +} + +class ComponentPanel extends Panel { + ComponentPanel() { + add(new Label("Label")); + add(new Button("Button")); + add(new Checkbox("Checkbox")); + Choice c = new Choice(); + c.add("choice"); + java.awt.List l = new java.awt.List(); + l.add("list"); + add(new Scrollbar()); + add(new TextField("TextField")); + add(new TextArea("TextArea")); + add(new Panel()); + add(new Canvas()); + } +} + +class SwingPanel extends JPanel { + SwingPanel() { + add(new JLabel("JLabel")); + add(new JButton("JButton")); + add(new JCheckBox("JCheckBox")); + JComboBox c = new JComboBox(); + JList l = new JList(); + add(new JScrollBar()); + add(new JTextField("This is a JTextField with some text in it to make it longer.")); + add(new JTextArea("This is a JTextArea with some text in it to make it longer.")); + } +} + +class ObscuringDialog extends Dialog { + ObscuringDialog(Frame f) { + super(f, "Obscuring Dialog"); + Button ok = new Button("OK, go away"); + ok.addActionListener(ev -> dispose()); + add(ok); + pack(); + } +} diff --git a/test/jdk/java/awt/Component/ProcessEvent/ProcessEvent.java b/test/jdk/java/awt/Component/ProcessEvent/ProcessEvent.java new file mode 100644 index 00000000000..3dfd5a04038 --- /dev/null +++ b/test/jdk/java/awt/Component/ProcessEvent/ProcessEvent.java @@ -0,0 +1,455 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4292099 + * @summary AWT Event delivery to processEvent + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual ProcessEvent + */ + +import java.awt.AWTEvent; +import java.awt.AWTEventMulticaster; +import java.awt.Adjustable; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.ItemSelectable; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.AdjustmentEvent; +import java.awt.event.AdjustmentListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.TextEvent; +import java.awt.event.TextListener; +import java.lang.reflect.InvocationTargetException; + +public class ProcessEvent extends Frame { + + static final String INSTRUCTIONS = """ + Press each of the four buttons for ActionEvent, AdjustmentEvent, + ItemEvent and TextEvent. If a message for each corresponding event + appears in the log area and says the event listener was + called, then press Pass otherwise press Fail. + """; + ActionBtn af; + AdjustmentBtn adjf; + ItemBtn itf; + TextBtn txtf; + + public ProcessEvent() { + setLayout(new FlowLayout()); + add(af = new ActionBtn()); + af.setBackground(Color.green); + + add(adjf = new AdjustmentBtn()); + adjf.setBackground(Color.green); + + add(itf = new ItemBtn()); + itf.setBackground(Color.green); + + add(txtf = new TextBtn()); + txtf.setBackground(Color.green); + + // These action listeners simply provide feedback of when + // the event is delivered properly. + af.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ae) { + PassFailJFrame.log(af.getText() + + ": action listener called: " + + ae.toString()); + } + }); + + adjf.addAdjustmentListener(new AdjustmentListener() { + public void adjustmentValueChanged(AdjustmentEvent ae) { + PassFailJFrame.log(adjf.getText() + + ": adjustment listener called: " + + ae.toString()); + } + }); + + itf.addItemListener(new ItemListener() { + public void itemStateChanged(ItemEvent e) { + PassFailJFrame.log(itf.getText() + + ": item listener called: " + + e.toString()); + } + }); + + txtf.addTextListener(new TextListener() { + public void textValueChanged(TextEvent e) { + PassFailJFrame.log(txtf.getText() + + ": text listener called: " + + e.toString()); + } + }); + + pack(); + } + + public static void main(String[] args) throws InterruptedException, + InvocationTargetException { + PassFailJFrame.builder() + .title("Process Events Test") + .testUI(ProcessEvent::new) + .instructions(INSTRUCTIONS) + .columns(40) + .logArea() + .build() + .awaitAndCheck(); + } +} + +class ButtonComponent extends Component implements ItemSelectable, Adjustable { + + transient protected TextListener textListener; + transient ActionListener actionListener; + transient AdjustmentListener adjustmentListener; + transient ItemListener itemListener; + String actionCommand = null; + + String text = null; + + public ButtonComponent(String label) { + super(); + text = label; + } + + public String getText() { + return text; + } + + public Dimension getPreferredSize() { + return new Dimension(200, 30); + } + + public Dimension getMinimumSize() { + return getPreferredSize(); + } + + public String getActionCommand() { + if (actionCommand == null) + return getText(); + else + return actionCommand; + } + + public void setActionCommand(String ac) { + actionCommand = ac; + } + + // ActionEvent listener support + + public synchronized void addActionListener(ActionListener l) { + if (l == null) { + return; + } + enableEvents(AWTEvent.ACTION_EVENT_MASK); + actionListener = AWTEventMulticaster.add(actionListener, l); + } + + public synchronized void removeActionListener(ActionListener l) { + if (l == null) { + return; + } + actionListener = AWTEventMulticaster.remove(actionListener, l); + } + + // AdjustmentEvent listener support + + public synchronized void addAdjustmentListener(AdjustmentListener l) { + if (l == null) { + return; + } + enableEvents(AWTEvent.ADJUSTMENT_EVENT_MASK); + adjustmentListener = AWTEventMulticaster.add(adjustmentListener, l); + } + + public synchronized void removeAdjustmentListener(AdjustmentListener l) { + if (l == null) { + return; + } + adjustmentListener = AWTEventMulticaster.remove(adjustmentListener, l); + } + + // ItemEvent listener support + + public synchronized void addItemListener(ItemListener l) { + if (l == null) { + return; + } + enableEvents(AWTEvent.ITEM_EVENT_MASK); + itemListener = AWTEventMulticaster.add(itemListener, l); + } + + public synchronized void removeItemListener(ItemListener l) { + if (l == null) { + return; + } + itemListener = AWTEventMulticaster.remove(itemListener, l); + } + + // TextEvent listener support + + public synchronized void addTextListener(TextListener l) { + if (l == null) { + return; + } + enableEvents(AWTEvent.TEXT_EVENT_MASK); + textListener = AWTEventMulticaster.add(textListener, l); + } + + public synchronized void removeTextListener(TextListener l) { + if (l == null) { + return; + } + textListener = AWTEventMulticaster.remove(textListener, l); + } + + // Implement the processEvent and processXXXEvent methods to + // handle reception and processing of the event types. + + protected void processEvent(AWTEvent e) { + if (e instanceof ActionEvent) { + processActionEvent((ActionEvent) e); + return; + } + if (e instanceof AdjustmentEvent) { + processAdjustmentEvent((AdjustmentEvent) e); + return; + } + if (e instanceof ItemEvent) { + processItemEvent((ItemEvent) e); + return; + } + if (e instanceof TextEvent) { + processTextEvent((TextEvent) e); + return; + } + super.processEvent(e); + } + + protected void processActionEvent(ActionEvent e) { + if (actionListener != null) { + actionListener.actionPerformed(e); + } + } + + protected void processAdjustmentEvent(AdjustmentEvent e) { + if (adjustmentListener != null) { + adjustmentListener.adjustmentValueChanged(e); + } + } + + protected void processItemEvent(ItemEvent e) { + if (itemListener != null) { + itemListener.itemStateChanged(e); + } + } + + protected void processTextEvent(TextEvent e) { + if (textListener != null) { + textListener.textValueChanged(e); + } + } + + public void paint(Graphics g) { + Dimension dim = getSize(); + g.clearRect(0, 0, dim.width, dim.height); + g.setColor(getForeground()); + g.drawString(text, 2, dim.height - 2); + } + + /** + * Returns the selected items or null if no items are selected. + */ + public Object[] getSelectedObjects() { + return null; + } + + /** + * Gets the orientation of the adjustable object. + */ + public int getOrientation() { + return 0; + } + + /** + * Gets the minimum value of the adjustable object. + */ + public int getMinimum() { + return 0; + } + + /** + * Sets the minimum value of the adjustable object. + * + * @param min the minimum value + */ + public void setMinimum(int min) { + } + + /** + * Gets the maximum value of the adjustable object. + */ + public int getMaximum() { + return 0; + } + + /** + * Sets the maximum value of the adjustable object. + * + * @param max the maximum value + */ + public void setMaximum(int max) { + } + + /** + * Gets the unit value increment for the adjustable object. + */ + public int getUnitIncrement() { + return 0; + } + + /** + * Sets the unit value increment for the adjustable object. + * + * @param u the unit increment + */ + public void setUnitIncrement(int u) { + } + + /** + * Gets the block value increment for the adjustable object. + */ + public int getBlockIncrement() { + return 0; + } + + /** + * Sets the block value increment for the adjustable object. + * + * @param b the block increment + */ + public void setBlockIncrement(int b) { + } + + /** + * Gets the length of the propertional indicator. + */ + public int getVisibleAmount() { + return 0; + } + + /** + * Sets the length of the proportionl indicator of the + * adjustable object. + * + * @param v the length of the indicator + */ + public void setVisibleAmount(int v) { + } + + /** + * Gets the current value of the adjustable object. + */ + public int getValue() { + return 0; + } + + /** + * Sets the current value of the adjustable object. This + * value must be within the range defined by the minimum and + * maximum values for this object. + * + * @param v the current value + */ + public void setValue(int v) { + } + +} + +class ActionBtn extends ButtonComponent { + public ActionBtn() { + super("ActionEvent"); + addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + ActionEvent ae = new ActionEvent(e.getSource(), + ActionEvent.ACTION_PERFORMED, + getActionCommand()); + Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(ae); + } + }); + } +} + +class AdjustmentBtn extends ButtonComponent { + public AdjustmentBtn() { + super("AdjustmentEvent"); + addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + AdjustmentEvent ae = new AdjustmentEvent((Adjustable) e.getSource(), + AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED, + 1, 1); + Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(ae); + } + }); + } +} + +class ItemBtn extends ButtonComponent { + public ItemBtn() { + super("ItemEvent"); + addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + ItemEvent ae = new ItemEvent((ItemSelectable) e.getSource(), + ItemEvent.ITEM_STATE_CHANGED, + e.getSource(), 1); + Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(ae); + } + }); + } +} + +class TextBtn extends ButtonComponent { + public TextBtn() { + super("TextEvent"); + addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + TextEvent ae = new TextEvent(e.getSource(), + TextEvent.TEXT_VALUE_CHANGED); + Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(ae); + } + }); + } +} diff --git a/test/jdk/java/awt/Component/SetFontOrBackground/SetBgrFnt.java b/test/jdk/java/awt/Component/SetFontOrBackground/SetBgrFnt.java new file mode 100644 index 00000000000..02707ad5784 --- /dev/null +++ b/test/jdk/java/awt/Component/SetFontOrBackground/SetBgrFnt.java @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 4906548 4921849 + * @summary Checks that setFont and setBackground have immediate effect + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual SetBgrFnt + */ + +import java.awt.Button; +import java.awt.Canvas; +import java.awt.Checkbox; +import java.awt.Color; +import java.awt.Font; +import java.awt.Frame; +import java.awt.GridLayout; +import java.awt.Label; +import java.lang.reflect.InvocationTargetException; + +public class SetBgrFnt extends Frame { + static final String INSTRUCTIONS = """ + 1. Press a button marked 'Switch fonts' + fonts in three components below (a Button, a Checkbox + and a Label) must change immediately. + + 2. Press a button marked 'Switch background' + background of three components and canvas must change. + MacOS is an exception - AWT buttons on macOS so not + change color so on macOS only canvas, checkbox + and a label should change background. + + If this is the behavior that you observe press Pass, + otherwise press Fail. + """; + Label la; + Button bu, bu1, bu2; + Checkbox cb; + Font font1, font2; + Canvas ca; + boolean bToggleFont = true; + boolean bToggleBg = true; + + public SetBgrFnt() { + bu = new Button("Switch fonts"); + bu1 = new Button("Switch background"); + bu2 = new Button("I'm a button"); + cb = new Checkbox("Checkbox I am"); + la = new Label("I am a label"); + ca = new Canvas(); + font1 = new Font("Serif", Font.ITALIC, 22); + font2 = new Font("SansSerif", Font.PLAIN, 10); + la.setFont(font1); + cb.setFont(font1); + bu2.setFont(font1); + bu.addActionListener(ae -> { + if (bToggleFont) { + la.setFont(font2); + cb.setFont(font2); + bu2.setFont(font2); + } else { + la.setFont(font1); + cb.setFont(font1); + bu2.setFont(font1); + } + bToggleFont = !bToggleFont; + }); + + bu1.addActionListener(ae -> { + if (bToggleBg) { + ca.setBackground(Color.YELLOW); + setBackground(Color.YELLOW); + } else { + ca.setBackground(Color.GREEN); + setBackground(Color.GREEN); + } + bToggleBg = !bToggleBg; + }); + + setLayout(new GridLayout(8, 1)); + add(bu); + add(bu1); + add(new Label()); + add("South", la); + add("South", bu2); + add("South", cb); + add("South", ca); + pack(); + } + + public static void main(String[] args) throws InterruptedException, + InvocationTargetException { + PassFailJFrame.builder() + .title("Set Font and Background Test") + .testUI(SetBgrFnt::new) + .instructions(INSTRUCTIONS) + .columns(40) + .build() + .awaitAndCheck(); + } +} diff --git a/test/jdk/java/awt/Component/ZOrderTest/ZOrderTest.java b/test/jdk/java/awt/Component/ZOrderTest/ZOrderTest.java new file mode 100644 index 00000000000..15003f753a6 --- /dev/null +++ b/test/jdk/java/awt/Component/ZOrderTest/ZOrderTest.java @@ -0,0 +1,159 @@ +/* + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4059430 + * @summary Test for component z-ordering consistency + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual ZOrderTest + */ + +import java.awt.Color; +import java.awt.Component; +import java.awt.Container; +import java.awt.Frame; +import java.awt.GridLayout; +import java.awt.Insets; +import java.awt.Label; +import java.awt.Panel; +import java.lang.reflect.InvocationTargetException; +import java.util.List; + +public class ZOrderTest { + public final static String INSTRUCTIONS = """ + The ZOrderTest creates two frames. + - Frame 1 has components added to an intermediate panel + - Frame 2 has components added directly to the frame itself + Verify that the components are in the correct z-order. Lower numbered + components should overlap higher numbered ones (e.g. component zero should + appear on top of component one). + Both frames should have the same component ordering, and this ordering should + be the same on all supported operating systems. + """; + + public static void main(String [] args) throws InterruptedException, + InvocationTargetException { + PassFailJFrame.builder() + .title("Component ZOrder Test") + .testUI(ZOrderTest::makeFrames) + .instructions(INSTRUCTIONS) + .columns(40) + .logArea() + .build() + .awaitAndCheck(); + } + + private static List makeFrames() { + Frame frame, frame2; + + // test adding components to panel on a frame + frame = new Frame("ZOrderTest(1) for 4059430"); + frame.pack(); + frame.show(); + Panel panel = new ZOrderPanel(); + frame.setBounds(0, 0, 500, 350); + frame.setLayout(new GridLayout()); + frame.add(panel); + doTest(panel); + + // test adding components directly to frame + frame2 = new ZOrderTestFrame("ZOrderTest(2) for 4059430"); + frame2.pack(); + frame2.show(); + frame2.setBounds(80, 80, 500, 350); + doTest(frame2); + + return List.of(frame, frame2); + } + + /* + * This tests various boundary conditions with z-ordering + * - inserting at the top of the z-order + * - inserting at the bottom of the z-order + * - inserting in the middle of the z-order + */ + private static void doTest(Container cont) { + Component compZero, compOne, compTwo, compThree, compFour; + + compZero = makeBox(cont, "Comp One", Color.blue, -1); + // insert on top + compOne = makeBox(cont, "Comp Zero", Color.yellow, 0); + // put at the back + compThree = makeBox(cont, "Comp Three", Color.red, 2); + // insert in last position + compTwo = makeBox(cont, "Comp Two", Color.green, 3); + // swap compTwo and compThree to correct positions + cont.remove(compTwo); + cont.add(compTwo, 2); + // one more test of adding to the end + compFour = makeBox(cont, "Comp Four", Color.magenta, -1); + // re-validate so components cascade into proper place + cont.validate(); + } + + private static Component makeBox(Container cont, String s, Color c, int index) { + Label l = new Label(s); + l.setBackground(c); + l.setAlignment(Label.RIGHT); + if (index == -1) { + cont.add(l); // semantically equivalent to -1, but why not test this too + } else { + cont.add(l, index); + } + cont.validate(); + return l; + } + + /** + * Cascades components across the container so + * that they overlap, demonstrating their z-ordering + */ + static void doCascadeLayout(Container cont) { + int i, n; + Insets ins = cont.insets(); + n = cont.countComponents(); + for (i = n - 1; i >= 0; i--) { + Component comp = cont.getComponent(i); + comp.reshape(ins.left + 75 * i, ins.top + 30 * i, 100, 100); + } + } +} + +class ZOrderPanel extends Panel { + public void layout() { + ZOrderTest.doCascadeLayout(this); + } +} + +class ZOrderTestFrame extends Frame +{ + public ZOrderTestFrame(String title) { + super(title); + } + + public void layout() { + ZOrderTest.doCascadeLayout(this); + } +} diff --git a/test/jdk/java/awt/Cursor/BlockedWindowTest/BlockedWindowTest.java b/test/jdk/java/awt/Cursor/BlockedWindowTest/BlockedWindowTest.java new file mode 100644 index 00000000000..f1313dbb742 --- /dev/null +++ b/test/jdk/java/awt/Cursor/BlockedWindowTest/BlockedWindowTest.java @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2006, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6391547 + * @summary Test if the JTextField's cursor is changed when there is a modal dialog + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual BlockedWindowTest + */ + +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.Cursor; +import java.awt.Dialog; +import java.awt.Frame; +import java.awt.TextField; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +class MyDialog extends Dialog implements ActionListener { + MyDialog(Frame owner) { + super(owner, "Modal dialog", true); + setBounds(owner.getX() + 150, owner.getY() + 150, 100, 100); + setLayout(new BorderLayout()); + Button b = new Button("Close"); + add(b, "South"); + b.addActionListener(this); + setVisible(true); + } + + public void actionPerformed(ActionEvent ae) { + setVisible(false); + this.dispose(); + } +} + +class MyFrame extends Frame implements ActionListener { + Dialog d; + + public MyFrame() { + super("ManualYesNoTest"); + Button b = new Button("Click here"); + TextField tf = new TextField("A text field"); + b.addActionListener(this); + setLayout(new BorderLayout()); + setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); + add(b, "South"); + add(tf, "North"); + setSize(300, 300); + } + + public void actionPerformed(ActionEvent ae) { + d = new MyDialog(this); + } +} + +public class BlockedWindowTest { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + Verify that the hand cursor is displayed over the window and + text cursor over TextField. + Click the button in the window to display a modal dialog. + Verify that default cursor is displayed over the window + and over TextField now. + Then close modal dialog and verify that hand cursor is + displayed over window and text cursor over TextField. + If so, press PASS, else press FAIL. + """; + + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .columns(35) + .testUI(BlockedWindowTest::createUI) + .build() + .awaitAndCheck(); + } + + public static MyFrame createUI() { + MyFrame f = new MyFrame(); + return f; + } +} diff --git a/test/jdk/java/awt/Cursor/CursorDragTest/ListDragCursor.java b/test/jdk/java/awt/Cursor/CursorDragTest/ListDragCursor.java new file mode 100644 index 00000000000..32923f1d78b --- /dev/null +++ b/test/jdk/java/awt/Cursor/CursorDragTest/ListDragCursor.java @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4313052 + * @summary Test cursor changes after mouse dragging ends + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual ListDragCursor + */ + +import java.awt.Cursor; +import java.awt.Frame; +import java.awt.List; +import java.awt.Panel; +import java.awt.TextArea; + +public class ListDragCursor { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + 1. Move mouse to the TextArea. + 2. Press the left mouse button. + 3. Drag mouse to the list. + 4. Release the left mouse button. + + If the mouse cursor starts as a Text Line Cursor and changes + to a regular Pointer Cursor, then Hand Cursor when hovering + the list, pass the test. This test fails if the cursor does + not update at all when pointing over the different components. + """; + + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(35) + .testUI(ListDragCursor::createUI) + .build() + .awaitAndCheck(); + } + + public static Frame createUI() { + Frame frame = new Frame("Cursor change after drag"); + Panel panel = new Panel(); + + List list = new List(2); + list.add("List1"); + list.add("List2"); + list.add("List3"); + list.add("List4"); + list.setCursor(new Cursor(Cursor.HAND_CURSOR)); + + TextArea textArea = new TextArea(3, 5); + textArea.setCursor(new Cursor(Cursor.TEXT_CURSOR)); + + panel.add(textArea); + panel.add(list); + + frame.add(panel); + frame.setBounds(300, 100, 300, 150); + return frame; + } +} diff --git a/test/jdk/java/awt/Cursor/CursorUpdateTest/CursorUpdateTest.java b/test/jdk/java/awt/Cursor/CursorUpdateTest/CursorUpdateTest.java new file mode 100644 index 00000000000..33e2a3cb166 --- /dev/null +++ b/test/jdk/java/awt/Cursor/CursorUpdateTest/CursorUpdateTest.java @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 5097531 + * @summary Make sure the cursor updates correctly under certain + * circumstances even when the EDT is busy + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual CursorUpdateTest + */ + +import java.awt.Button; +import java.awt.Color; +import java.awt.Component; +import java.awt.Cursor; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.Graphics; + +public class CursorUpdateTest { + final static String progress = "|/-\\"; + + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + Check the following: + 1. Cursor must be crosshair when hovering the mouse over the + blue square. + 2. Crosshair cursor must not flicker. + 3. The cursor must be "I-beam" when hovering the mouse over the + button. + 4. Click the button - it will display "Busy" message and a + rotating bar for 5 seconds. The cursor must change to + hourglass. + 5. (Windows only) While the cursor is on the button, press Alt. + The cursor must change to normal shape. Pressing Alt again + must revert it back to I-beam. + 6. Move the mouse out of the button and back onto it. The cursor + must update correctly (hourglass over the button, normal + over the frame) even when the button displays "busy". + Do not try to check (1) or (5) when the button displays + "Busy" - this is not required. + Pass if all the steps are as behave as described. Otherwise, + fail this test. + """; + + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .columns(35) + .testUI(CursorUpdateTest::createUI) + .build() + .awaitAndCheck(); + } + + public static Frame createUI() { + Frame f = new Frame(); + f.setLayout(new FlowLayout()); + Button b = new Button("Button"); + f.add(b); + b.setCursor(new Cursor(Cursor.TEXT_CURSOR)); + Component c = new MyComponent(); + f.add(c); + c.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR)); + b.addActionListener(e -> { + String oldLabel = b.getLabel(); + Cursor oldCursor = b.getCursor(); + b.setCursor(new Cursor(Cursor.WAIT_CURSOR)); + try { + for (int i = 0; i < 50; i++) { + b.setLabel("Busy " + progress.charAt(i % 4)); + Thread.sleep(100); + } + } catch (InterruptedException ex) { + } + b.setCursor(oldCursor); + b.setLabel(oldLabel); + }); + return f; + } +} + +class MyComponent extends Component { + public void paint(Graphics g) { + g.setColor(getBackground()); + g.fillRect(0, 0, getSize().width, getSize().height); + } + + public MyComponent() { + setBackground(Color.blue); + } + + public Dimension getPreferredSize() { + return new Dimension(100, 100); + } +} diff --git a/test/jdk/java/awt/Cursor/CustomCursorTest/CustomCursorTest.java b/test/jdk/java/awt/Cursor/CustomCursorTest/CustomCursorTest.java new file mode 100644 index 00000000000..32c1fdc1506 --- /dev/null +++ b/test/jdk/java/awt/Cursor/CustomCursorTest/CustomCursorTest.java @@ -0,0 +1,137 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4174035 4106384 4205805 + * @summary Test for functionality of Custom Cursor + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual CustomCursorTest + */ + +import java.awt.Color; +import java.awt.Cursor; +import java.awt.Frame; +import java.awt.Graphics2D; +import java.awt.Image; +import java.awt.Panel; +import java.awt.Point; +import java.awt.Toolkit; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; +import java.nio.file.Path; + +import javax.imageio.ImageIO; +import javax.swing.JFrame; +import javax.swing.JLabel; + +import static java.awt.image.BufferedImage.TYPE_INT_ARGB; + +public class CustomCursorTest { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + This test is for switching between a custom cursor and the + system cursor. + + 1. Click on the test window panel to change from the default + system cursor to the custom red square cursor + 2. Verify that the square cursor shows when the panel is clicked + 3. Verify that the square cursor is colored red + """; + + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .columns(35) + .testUI(CustomCursorTest::createUI) + .build() + .awaitAndCheck(); + } + + public static Frame createUI() { + JFrame f = new JFrame("Custom Cursor Test"); + CustomCursorPanel c = null; + try { + c = new CustomCursorPanel(); + } catch (IOException e) { + e.printStackTrace(); + } + + f.setIconImage(c.getImage()); + f.getContentPane().add(c); + f.setSize(400, 400); + return f; + } +} + +class CustomCursorPanel extends Panel { + Toolkit toolkit = Toolkit.getDefaultToolkit(); + Image image; + Cursor cursor; + boolean flip = false; + + public CustomCursorPanel() throws IOException { + generateRedSquareCursor(); + + image = toolkit.getImage(System.getProperty("test.classes", ".") + + java.io.File.separator + "square_cursor.gif"); + + setBackground(Color.green); + cursor = toolkit.createCustomCursor(image, new Point(0, 0), "custom"); + + JLabel c = (JLabel) add(new JLabel("click to switch between " + + "red square and default cursors")); + c.setBackground(Color.white); + c.setForeground(Color.red); + + addMouseListener(new MouseAdapter() { + public void mousePressed(MouseEvent me) { + if (!flip) { + setCursor(cursor); + flip = true; + } else { + setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); + flip = false; + } + } + }); + } + + public Image getImage() { + return image; + } + + private static void generateRedSquareCursor() throws IOException { + Path p = Path.of(System.getProperty("test.classes", ".")); + BufferedImage bImg = new BufferedImage(35, 34, TYPE_INT_ARGB); + Graphics2D cg = bImg.createGraphics(); + cg.setColor(Color.RED); + cg.fillRect(0, 0, 35, 34); + ImageIO.write(bImg, "png", new File(p + java.io.File.separator + + "square_cursor.gif")); + } +} diff --git a/test/jdk/java/awt/Cursor/HiddenDialogParentTest/HiddenDialogParentTest.java b/test/jdk/java/awt/Cursor/HiddenDialogParentTest/HiddenDialogParentTest.java new file mode 100644 index 00000000000..7450f4ec3bb --- /dev/null +++ b/test/jdk/java/awt/Cursor/HiddenDialogParentTest/HiddenDialogParentTest.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 5079694 + * @summary Test if JDialog respects setCursor + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual HiddenDialogParentTest + */ + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Cursor; + +import javax.swing.JDialog; +import javax.swing.JLabel; +import javax.swing.border.LineBorder; + +public class HiddenDialogParentTest { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + You can see a label area in the center of JDialog. + Verify that the cursor is a hand cursor in this area. + If so, press pass, else press fail. + """; + + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(35) + .testUI(HiddenDialogParentTest::createUI) + .build() + .awaitAndCheck(); + } + + public static JDialog createUI() { + JDialog dialog = new JDialog(); + dialog.setTitle("JDialog Cursor Test"); + dialog.setLayout(new BorderLayout()); + JLabel centerLabel = new JLabel("Cursor should be a hand in this " + + "label area"); + centerLabel.setBorder(new LineBorder(Color.BLACK)); + centerLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); + dialog.add(centerLabel, BorderLayout.CENTER); + dialog.setSize(300, 200); + + return dialog; + } +} diff --git a/test/jdk/java/awt/Cursor/InvalidImageCustomCursorTest/InvalidImageCustomCursorTest.java b/test/jdk/java/awt/Cursor/InvalidImageCustomCursorTest/InvalidImageCustomCursorTest.java new file mode 100644 index 00000000000..9877df342ec --- /dev/null +++ b/test/jdk/java/awt/Cursor/InvalidImageCustomCursorTest/InvalidImageCustomCursorTest.java @@ -0,0 +1,95 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4212593 + * @summary The Toolkit.createCustomCursor does not check absence of the + * image of cursor + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual InvalidImageCustomCursorTest + */ + +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.Color; +import java.awt.Cursor; +import java.awt.Frame; +import java.awt.Image; +import java.awt.Panel; +import java.awt.Point; +import java.awt.Toolkit; + +public class InvalidImageCustomCursorTest { + static Cursor cursor; + + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + Press 'Hide' button to hide (set transparent) cursor for the + green panel. Move the pointer over the green panel - pointer + should disappear. Press 'Default' button to set default cursor + for the green panel. + + If you see any exceptions or cursor is not transparent, + test failed, otherwise it passed. + """; + + Toolkit tk = Toolkit.getDefaultToolkit(); + Image image = tk.getImage("NON_EXISTING_FILE.gif"); + Point p = new Point(0, 0); + + cursor = tk.createCustomCursor(image, p, "Test"); + + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(35) + .testUI(InvalidImageCustomCursorTest::createUI) + .logArea(5) + .build() + .awaitAndCheck(); + } + + public static Frame createUI() { + Frame f = new Frame("Invalid Cursor Image Test"); + f.setLayout(new BorderLayout()); + f.setSize(200, 200); + + Button def = new Button("Default"); + Button hide = new Button("Hide"); + Panel panel = new Panel(); + + def.addActionListener(e -> panel.setCursor(Cursor.getDefaultCursor())); + hide.addActionListener(e -> panel.setCursor(cursor)); + + panel.setBackground(Color.green); + panel.setSize(100, 100); + f.add("Center", panel); + f.add("North", hide); + f.add("South", def); + + return f; + } +} diff --git a/test/jdk/java/awt/Cursor/JPanelCursorTest/JPanelCursorTest.java b/test/jdk/java/awt/Cursor/JPanelCursorTest/JPanelCursorTest.java new file mode 100644 index 00000000000..8acd622e592 --- /dev/null +++ b/test/jdk/java/awt/Cursor/JPanelCursorTest/JPanelCursorTest.java @@ -0,0 +1,122 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4114073 + * @summary Test for setCursor in a JPanel when added to a JFrame's contentPane + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual JPanelCursorTest + */ + +import java.awt.Color; +import java.awt.Cursor; +import java.awt.Dimension; +import java.awt.Graphics; + +import javax.swing.JButton; +import javax.swing.JComponent; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JSplitPane; +import javax.swing.border.BevelBorder; + +public class JPanelCursorTest { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + This test checks for setCursor in a JPanel when added to a + JFrame's contentPane. + + 1. Verify that the cursor in the left side of the test window + is a default cursor. + 2. Verify that the cursor changes to the crosshair cursor when + pointing over the button. + 3. Verify that the cursor changes to the hand cursor when in + the right side of the splitpane (and not on the button). + + If true, then pass the test. Otherwise, fail this test. + """; + + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .columns(35) + .testUI(JPanelCursorTest::createUI) + .build() + .awaitAndCheck(); + } + + public static JFrame createUI() { + JFrame frame = new JFrame(); + + JSplitPane j = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); + ExtJComponent pane = new ExtJComponent(); + + CursorBugPanel panel = new CursorBugPanel(); + + j.setLeftComponent(pane); + j.setRightComponent(panel); + j.setContinuousLayout(true); + + frame.getContentPane().add("Center", j); + pane.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR)); + frame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + frame.pack(); + return frame; + } +} + +class ExtJComponent extends JComponent { + public ExtJComponent() { + super(); + setOpaque(true); + setBackground(Color.green); + setForeground(Color.red); + setBorder(new BevelBorder(BevelBorder.RAISED)); + } + public void paintComponent(Graphics g) { + g.drawString("Default", 20, 30); + } + public Dimension getPreferredSize() { + return new Dimension(100, 100); + } +} + +class CursorBugPanel extends JPanel { + public CursorBugPanel () { + // BUG: fails to set cursor for panel + setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); + + // Create a button + JButton button = new JButton("Crosshair"); + + // Sets cursor for button, no problem + button.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); + add(button); + } + + public void paintComponent(Graphics g) { + g.drawString("Hand", 20, 60); + } +} diff --git a/test/jdk/java/awt/Cursor/NullCursorTest/NullCursorTest.java b/test/jdk/java/awt/Cursor/NullCursorTest/NullCursorTest.java new file mode 100644 index 00000000000..c2398a80eb2 --- /dev/null +++ b/test/jdk/java/awt/Cursor/NullCursorTest/NullCursorTest.java @@ -0,0 +1,154 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4111379 + * @summary Test for setting cursor to null for lightweight components + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual NullCursorTest + */ + +import java.awt.Button; +import java.awt.Color; +import java.awt.Component; +import java.awt.Container; +import java.awt.Cursor; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Rectangle; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +public class NullCursorTest { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + 1. Hover over each colored area as described: + Green area shows a CrossCursor. + Red area shows a TextCursor. + Yellow area shows a HandCursor. + 2. Click once in red area, then: + Green area shows a HandCursor. + Red area shows a BusyCursor. + Yellow area shows a HandCursor. + 3. Click again in red area, then: + Green area shows a CrossCursor. + Red area shows a HandCursor. + Yellow area shows a HandCursor. + """; + + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(35) + .testUI(NullCursorTest::createUI) + .build() + .awaitAndCheck(); + } + + public static Frame createUI() { + Frame f = new Frame("Null Cursor Test Frame"); + f.setSize(200, 200); + final Container p = f; + p.setName("parent"); + p.setLayout(null); + + final Component green = p.add(new Component() { + public void paint(Graphics g) { + Rectangle r = getBounds(); + g.setColor(Color.green); + g.fillRect(0, 0, r.width, r.height); + } + }); + green.setName("green"); + green.setBackground(Color.red); + green.setBounds(50, 50, 75, 75); + green.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); + + Container h = new Container() { + public void paint(Graphics g) { + Rectangle r = getBounds(); + g.setColor(Color.yellow); + g.fillRect(0, 0, r.width, r.height); + super.paint(g); + } + }; + h.setBounds(15, 25, 150, 150); + h.setName("container"); + h.setBackground(Color.yellow); + h.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); + final Component red = new Component() { + public void paint(Graphics g) { + Rectangle r = getBounds(); + Color c = getBackground(); + g.setColor(c); + g.fillRect(0, 0, r.width, r.height); + super.paint(g); + } + }; + red.setName("red"); + red.setBackground(Color.red); + red.setBounds(10, 10, 120, 120); + red.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); + + final Button b = (Button)h.add(new Button("Test")); + b.setBounds(10, 10, 40, 20); + h.add(red); + p.add(h); + + b.addActionListener(new ActionListener() { + boolean f = false; + public void actionPerformed(ActionEvent e) { + if (f) { + b.setCursor(null); + } else { + b.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); + } + f = !f; + } + }); + red.addMouseListener(new MouseAdapter() { + boolean f = true; + + public void mouseClicked(MouseEvent e) { + Component c = (Component)e.getSource(); + if (f) { + c.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + p.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); + green.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); + f = false; + } else { + c.setCursor(null); + p.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + green.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); + f = true; + } + } + }); + return f; + } +} diff --git a/test/jdk/java/awt/Cursor/SetCursorTest/SetCursorTest.java b/test/jdk/java/awt/Cursor/SetCursorTest/SetCursorTest.java new file mode 100644 index 00000000000..87f028eb4f6 --- /dev/null +++ b/test/jdk/java/awt/Cursor/SetCursorTest/SetCursorTest.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4160080 + * @summary Test setCursor() on lightweight components when event is generated + * by a button + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual SetCursorTest + */ + +import java.awt.Cursor; + +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JPanel; + + +public class SetCursorTest { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + This test checks for the behavior of setCursor() when called in + a JFrame's JButton action event. + + 1. Click the "OK" button in the test window. + 2. Verify that the cursor changes to the waiting cursor instead + of the default system cursor. + + If true, then pass the test. Otherwise, fail this test. + """; + + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .columns(35) + .testUI(SetCursorTest::createUI) + .build() + .awaitAndCheck(); + } + + public static myFrame createUI() { + myFrame f = new myFrame(); + return f; + } +} + +class myFrame extends JFrame { + public myFrame() { + super("SetCursor With Button Test"); + setSize(200, 200); + + final JPanel p = new JPanel(); + final JButton okButton = new JButton("OK"); + okButton.addActionListener(e -> + setCursor(new Cursor(Cursor.WAIT_CURSOR))); + + p.add(okButton); + getContentPane().add(p); + } +} diff --git a/test/jdk/java/awt/Desktop/ActionSupportTest.java b/test/jdk/java/awt/Desktop/ActionSupportTest.java new file mode 100644 index 00000000000..e5cdec0e422 --- /dev/null +++ b/test/jdk/java/awt/Desktop/ActionSupportTest.java @@ -0,0 +1,201 @@ +/* + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6255196 + * @key headful + * @summary Verifies the supported actions on different platforms. + * @library /test/lib + * @run main/othervm ActionSupportTest + */ + +import java.awt.Desktop; +import java.io.File; +import java.net.URI; +import javax.swing.JMenuBar; +import jtreg.SkippedException; + +import static java.awt.desktop.QuitStrategy.NORMAL_EXIT; + +public class ActionSupportTest { + + public static void main(String[] args) { + final File file = new File("nonExistentFile"); + final URI uri = URI.create("nonExistentSchema:anything"); + final StringBuilder error = new StringBuilder(); + + if (!Desktop.isDesktopSupported()) { + throw new SkippedException("Class java.awt.Desktop is not supported on " + + "current platform. Farther testing will not be performed"); + } + + Desktop desktop = Desktop.getDesktop(); + for (Desktop.Action action : Desktop.Action.values()) { + boolean supported = desktop.isSupported(action); + + try { + switch (action) { + case OPEN: + // if not supported, an UnsupportedOperationException will be thrown. + // if supported, other exception might be thrown. + desktop.open(file); + break; + case EDIT: + // if not supported, an UnsupportedOperationException will be thrown. + // if supported, other exception might be thrown. + desktop.edit(file); + break; + case PRINT: + // if not supported, an UnsupportedOperationException will be thrown. + // if supported, other exception might be thrown. + desktop.print(file); + break; + case MAIL: + // if not supported, an UnsupportedOperationException will be thrown. + // if supported, other exception might be thrown. + desktop.mail(uri); + break; + case BROWSE: + if (supported) { + continue; // prevent native message about strange schema + } + // if not supported, an UnsupportedOperationException will be thrown. + // if supported, other exception might be thrown. + desktop.browse(uri); + break; + case APP_EVENT_FOREGROUND: + case APP_EVENT_HIDDEN: + case APP_EVENT_REOPENED: + case APP_EVENT_SCREEN_SLEEP: + case APP_EVENT_SYSTEM_SLEEP: + case APP_EVENT_USER_SESSION: + continue; // Has no effect if SystemEventListener's sub-type + // is unsupported on the current platform. + case APP_ABOUT: + // if not supported, an UnsupportedOperationException will be thrown. + // if supported, other exception might be thrown. + desktop.setAboutHandler(e -> { + }); + break; + case APP_PREFERENCES: + // if not supported, an UnsupportedOperationException will be thrown. + // if supported, other exception might be thrown. + desktop.setPreferencesHandler(e -> { + }); + break; + case APP_OPEN_FILE: + // if not supported, an UnsupportedOperationException will be thrown. + // if supported, other exception might be thrown. + desktop.setOpenFileHandler(e -> { + }); + break; + case APP_PRINT_FILE: + // if not supported, an UnsupportedOperationException will be thrown. + // if supported, other exception might be thrown. + desktop.setPrintFileHandler(e -> { + }); + break; + case APP_OPEN_URI: + // if not supported, an UnsupportedOperationException will be thrown. + // if supported, other exception might be thrown. + desktop.setOpenURIHandler(e -> { + }); + break; + case APP_QUIT_HANDLER: + // if not supported, an UnsupportedOperationException will be thrown. + // if supported, other exception might be thrown. + desktop.setQuitHandler((e, response) -> { + }); + break; + case APP_QUIT_STRATEGY: + // if not supported, an UnsupportedOperationException will be thrown. + // if supported, other exception might be thrown. + desktop.setQuitStrategy(NORMAL_EXIT); + break; + case APP_SUDDEN_TERMINATION: + // if not supported, an UnsupportedOperationException will be thrown. + // if supported, other exception might be thrown. + desktop.enableSuddenTermination(); + break; + case APP_REQUEST_FOREGROUND: + // if not supported, an UnsupportedOperationException will be thrown. + // if supported, other exception might be thrown. + desktop.requestForeground(true); + break; + case APP_HELP_VIEWER: + if (supported) { + continue; // prevent open separate window + } + // if not supported, an UnsupportedOperationException will be thrown. + // if supported, other exception might be thrown. + desktop.openHelpViewer(); + break; + case APP_MENU_BAR: + // if not supported, an UnsupportedOperationException will be thrown. + // if supported, other exception might be thrown. + desktop.setDefaultMenuBar(new JMenuBar()); + break; + case BROWSE_FILE_DIR: + // if not supported, an UnsupportedOperationException will be thrown. + // if supported, other exception might be thrown. + desktop.browseFileDirectory(file); + break; + case MOVE_TO_TRASH: + // if not supported, an UnsupportedOperationException will be thrown. + // if supported, other exception might be thrown. + desktop.moveToTrash(file); + break; + } + // no exception has been thrown. + if (!supported) { + error.append("Action " + action.name() + " is an " + + "unsupported operation, but no exception has been thrown\n"); + } + } catch (UnsupportedOperationException uoe) { + if (!supported) { + System.out.println("Action " + action.name() + "is not supported."); + } else { + error.append("Action " + action.name() + " is a " + + "supported operation, " + + "but UnsupportedOperationException has been thrown\n"); + } + } catch (Exception e) { + if (supported) { + System.out.println("Action " + action.name() + "supported."); + } else { + error.append("Action " + action.name() + " is an " + + "unsupported operation, but " + + "UnsupportedOperationException has not been thrown\n"); + } + } + } + + if (!error.isEmpty()) { + System.err.println(error); + throw new RuntimeException("One or more tests failed. " + + "Look at the error output for details"); + } + System.out.println("Test completed"); + } +} diff --git a/test/jdk/java/awt/Desktop/BrowseTest.java b/test/jdk/java/awt/Desktop/BrowseTest.java new file mode 100644 index 00000000000..1bdccace3fc --- /dev/null +++ b/test/jdk/java/awt/Desktop/BrowseTest.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6255196 + * @summary Verifies the function of method browse(java.net.URI uri). + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual BrowseTest + */ + +import java.awt.Desktop; +import java.io.File; +import java.lang.reflect.InvocationTargetException; +import java.net.URI; +import javax.swing.JPanel; + +public class BrowseTest extends JPanel { + static final String INSTRUCTIONS = """ + This test could launch default file manager to open user's home + directory, and default web browser to show the URL of java vendor. + After test execution close the native file manager and web browser + windows if they were launched by test. + Also check output for any unexpected EXCEPTIONS, + if you see any failure messages press Fail otherwise press Pass. + """; + + public BrowseTest() { + if (!Desktop.isDesktopSupported()) { + PassFailJFrame.log("Class java.awt.Desktop is not supported on " + + "current platform. Farther testing will not be performed"); + PassFailJFrame.forcePass(); + } + + Desktop desktop = Desktop.getDesktop(); + + URI dirURI = new File(System.getProperty("user.home")).toURI(); + URI webURI = URI.create(System.getProperty("java.vendor.url", "http://www.java.com")); + boolean failed = false; + try { + PassFailJFrame.log("Try to browse " + dirURI + " ..."); + desktop.browse(dirURI); + PassFailJFrame.log("Succeed.\n"); + } catch (Exception e) { + PassFailJFrame.log("EXCEPTION: " + e.getMessage()); + } + + try { + PassFailJFrame.log("Try to browse " + webURI + " ..."); + desktop.browse(webURI); + PassFailJFrame.log("Succeed.\n"); + } catch (Exception e) { + PassFailJFrame.log("EXCEPTION: " + e.getMessage()); + } + } + + public static void main(String[] args) throws InterruptedException, + InvocationTargetException { + PassFailJFrame.builder() + .title("Browser Test") + .splitUI(BrowseTest::new) + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 1) + .columns(40) + .logArea() + .build() + .awaitAndCheck(); + } +} diff --git a/test/jdk/java/awt/Desktop/DesktopSupportTest.java b/test/jdk/java/awt/Desktop/DesktopSupportTest.java new file mode 100644 index 00000000000..ec8b82ba5ef --- /dev/null +++ b/test/jdk/java/awt/Desktop/DesktopSupportTest.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6255196 + * @key headful + * @summary Verifies if class Desktop is supported on current platform. + * @run main DesktopSupportTest + */ + +import java.awt.Desktop; + +public class DesktopSupportTest { + public static void main(String[] args) { + boolean supported = Desktop.isDesktopSupported(); + try { + Desktop desktop = Desktop.getDesktop(); + if (!supported) { + throw new RuntimeException("UnsupportedOperationException " + + "should be thrown, as this class is not supported " + + "on current platform."); + } + } catch (UnsupportedOperationException uoe) { + if (supported) { + throw new RuntimeException("UnsupportedOperationException " + + "should NOT be thrown, as this class is supported " + + "on current platform."); + } + } catch (Exception e) { + if (!supported) { + throw new RuntimeException("UnsupportedOperationException " + + "should be thrown, as this class is not supported " + + "on current platform. But " + e.getClass().getName() + + " has been thrown instead."); + } + } + } +} diff --git a/test/jdk/java/awt/Desktop/EditAndPrintTest/EditAndPrintTest.java b/test/jdk/java/awt/Desktop/EditAndPrintTest/EditAndPrintTest.java new file mode 100644 index 00000000000..3f161f7fcaf --- /dev/null +++ b/test/jdk/java/awt/Desktop/EditAndPrintTest/EditAndPrintTest.java @@ -0,0 +1,152 @@ +/* + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @key printer + * @bug 6255196 + * @summary Verifies the function of methods edit(java.io.File file) and + * print(java.io.File file) + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual EditAndPrintTest + */ + +import java.awt.Desktop; +import java.awt.Desktop.Action; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import javax.swing.JPanel; + +public class EditAndPrintTest extends JPanel { + + static final String INSTRUCTIONS = """ + This test tries to edit and print a directory, which will expectedly raise IOException. + Then this test would edit and print a .txt file, which should be successful. + After test execution close the editor if it was launched by test. + If you see any EXCEPTION messages in the output press FAIL. + """; + + public EditAndPrintTest() { + if (!Desktop.isDesktopSupported()) { + PassFailJFrame.log("Class java.awt.Desktop is not supported on " + + "current platform. Further testing will not be performed"); + PassFailJFrame.forcePass(); + } + + Desktop desktop = Desktop.getDesktop(); + + if (!desktop.isSupported(Action.PRINT) && !desktop.isSupported(Action.EDIT)) { + PassFailJFrame.log("Neither EDIT nor PRINT actions are supported. Nothing to test."); + PassFailJFrame.forcePass(); + } + + /* + * Part 1: print or edit a directory, which should throw an IOException. + */ + File userHome = new File(System.getProperty("user.home")); + try { + if (desktop.isSupported(Action.EDIT)) { + PassFailJFrame.log("Trying to edit " + userHome); + desktop.edit(userHome); + PassFailJFrame.log("No exception has been thrown for editing " + + "directory " + userHome.getPath()); + PassFailJFrame.log("Test failed."); + } else { + PassFailJFrame.log("Action EDIT is unsupported."); + } + } catch (IOException e) { + PassFailJFrame.log("Expected IOException is caught."); + } + + try { + if (desktop.isSupported(Action.PRINT)) { + PassFailJFrame.log("Trying to print " + userHome); + desktop.print(userHome); + PassFailJFrame.log("No exception has been thrown for printing " + + "directory " + userHome.getPath()); + PassFailJFrame.log("Test failed."); + } else { + PassFailJFrame.log("Action PRINT is unsupported.\n"); + } + } catch (IOException e) { + PassFailJFrame.log("Expected IOException is caught."); + } + + /* + * Part 2: print or edit a normal .txt file, which may succeed if there + * is associated application to print or edit the given file. It fails + * otherwise. + */ + // Create a temp .txt file for test. + String testFilePath = System.getProperty("java.io.tmpdir") + File.separator + "JDIC-test.txt"; + File testFile = null; + try { + PassFailJFrame.log("Creating temporary file."); + testFile = File.createTempFile("JDIC-test", ".txt", new File(System.getProperty("java.io.tmpdir"))); + testFile.deleteOnExit(); + FileWriter writer = new FileWriter(testFile); + writer.write("This is a temp file used to test print() method of Desktop."); + writer.flush(); + writer.close(); + } catch (java.io.IOException ioe){ + PassFailJFrame.log("EXCEPTION: " + ioe.getMessage()); + PassFailJFrame.forceFail("Failed to create temp file for testing."); + } + + try { + if (desktop.isSupported(Action.EDIT)) { + PassFailJFrame.log("Try to edit " + testFile); + desktop.edit(testFile); + PassFailJFrame.log("Succeed."); + } + } catch (IOException e) { + PassFailJFrame.log("EXCEPTION: " + e.getMessage()); + } + + try { + if (desktop.isSupported(Action.PRINT)) { + PassFailJFrame.log("Trying to print " + testFile); + desktop.print(testFile); + PassFailJFrame.log("Succeed."); + } + } catch (IOException e) { + PassFailJFrame.log("EXCEPTION: " + e.getMessage()); + } + } + + public static void main(String args[]) throws InterruptedException, + InvocationTargetException { + PassFailJFrame.builder() + .title("Edit and Print test") + .splitUI(EditAndPrintTest::new) + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 1) + .columns(60) + .logArea() + .build() + .awaitAndCheck(); + } +} diff --git a/test/jdk/java/awt/Desktop/MailTest.java b/test/jdk/java/awt/Desktop/MailTest.java new file mode 100644 index 00000000000..15e5c0769a0 --- /dev/null +++ b/test/jdk/java/awt/Desktop/MailTest.java @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6255196 + * @summary Verifies the function of methods mail() and mail(java.net.URI uri). + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual MailTest + */ + +import java.awt.Desktop; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.net.URI; +import javax.swing.JPanel; + +public class MailTest extends JPanel { + + static final String INSTRUCTIONS = """ + This test could launch the mail client to compose mail + with and without filling the message fields. + After test execution close the mail composing windows if they + were launched by test. + If you see any unexpected EXCEPTION messages in the output + press Fail. Otherwise press Pass. + """; + + private MailTest() { + if (!Desktop.isDesktopSupported()) { + PassFailJFrame.log("Class java.awt.Desktop is not supported on " + + "current platform. Farther testing will not be performed"); + PassFailJFrame.forcePass(); + } + + Desktop desktop = Desktop.getDesktop(); + if (!desktop.isSupported(Desktop.Action.MAIL)) { + PassFailJFrame.log("Action.MAIL is not supported."); + PassFailJFrame.forcePass(); + } + + /* + * Part 1: launch the mail composing window without a mailto URI. + */ + try { + desktop.mail(); + } catch (IOException e) { + PassFailJFrame.log("EXCEPTION: " + e.getMessage()); + } + + /* + * Part 2: launch the mail composing window with a mailto URI. + */ + URI testURI = null; + try { + testURI = new URI("mailto", "foo@bar.com?subject=test subject" + + "&cc=foocc@bar.com&body=test body", null); + desktop.mail(testURI); + } catch (IOException e) { + PassFailJFrame.log("EXCEPTION: " + e.getMessage()); + } catch (java.net.URISyntaxException use) { + // Should not reach here. + PassFailJFrame.log("EXCEPTION: " + use.getMessage()); + } + + /* + * Part 3: try to launch the mail composing window with a URI with a + * scheme which is not "mailto": + * http://java.net. + * An IOException should be thrown in this case. + */ + try { + testURI = URI.create("http://java.com"); + PassFailJFrame.log("Try to mail: " + testURI); + desktop.mail(testURI); + } catch (IllegalArgumentException e) { + PassFailJFrame.log("Caught expected IllegalArgumentException"); + } catch (IOException ioe) { + PassFailJFrame.log("EXCEPTION: " + ioe.getMessage()); + } + } + + public static void main(String[] args) throws InterruptedException, + InvocationTargetException { + PassFailJFrame.builder() + .title("Mail Test") + .splitUI(MailTest::new) + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 1) + .columns(40) + .logArea() + .build() + .awaitAndCheck(); + } +} diff --git a/test/jdk/java/awt/Desktop/OpenTest.java b/test/jdk/java/awt/Desktop/OpenTest.java new file mode 100644 index 00000000000..1ed29067d50 --- /dev/null +++ b/test/jdk/java/awt/Desktop/OpenTest.java @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6255196 + * @summary Verifies the function of method open(java.io.File file). + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual/othervm OpenTest + */ + +import java.awt.Desktop; +import java.io.File; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import javax.swing.JPanel; + +public class OpenTest extends JPanel { + + static final String INSTRUCTIONS = """ + This test could open the user's home directory and a .txt file. + After test execution, close the native application windows that + are used to open the directory and .txt file if they were launched + by the test. + If you see any unexpected EXCEPTION messages in the output press Fail. + Otherwise press Pass. + """; + + public OpenTest() { + if (!Desktop.isDesktopSupported()) { + PassFailJFrame.log("Class java.awt.Desktop is not supported on " + + "current platform. Further testing will not be performed"); + PassFailJFrame.forcePass(); + } + + Desktop desktop = Desktop.getDesktop(); + + /* + * Part 1: open a directory, which should launch the system default + * file explorer. + * + * On Windows platforms, the default file explorer is explorer; + * on UNIX platforms with Gnome installed and running, the default + * file explorer is Nautilus. + */ + File userHome = new File(System.getProperty("user.home")); + + try { + PassFailJFrame.log("Try to open " + userHome); + desktop.open(userHome); + PassFailJFrame.log("Succeed."); + } catch (IOException e) { + PassFailJFrame.log("EXCEPTION: " + e.getMessage()); + } + + /* + * Part 2: open a normal .txt file, which should launch the registered + * application for .txt files. + */ + // Create a temp .txt file for test. + File testFile = null; + try { + PassFailJFrame.log("Creating temporary file"); + testFile = File.createTempFile("JDIC-test", ".txt", + new File(System.getProperty("java.io.tmpdir"))); + testFile.deleteOnExit(); + } catch (java.io.IOException ioe) { + PassFailJFrame.log("EXCEPTION: " + ioe.getMessage()); + PassFailJFrame.log("Failed to create test file"); + } + + try { + PassFailJFrame.log("Try to open " + testFile); + desktop.open(testFile); + PassFailJFrame.log("Succeed."); + } catch (IOException e) { + PassFailJFrame.log("EXCEPTION: " + e.getMessage()); + } + } + + public static void main(String[] args) throws InterruptedException, + InvocationTargetException { + PassFailJFrame.builder() + .title("Mail Test") + .splitUI(OpenTest::new) + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 1) + .columns(40) + .logArea() + .build() + .awaitAndCheck(); + } +} diff --git a/test/jdk/java/awt/DesktopProperties/FontSmoothing.java b/test/jdk/java/awt/DesktopProperties/FontSmoothing.java new file mode 100644 index 00000000000..d3879d4893f --- /dev/null +++ b/test/jdk/java/awt/DesktopProperties/FontSmoothing.java @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 java.awt.Frame; +import java.awt.Toolkit; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; + +/* + * @test + * @bug 4808569 + * @requires (os.family == "windows") + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @summary add desktop property for the Windows XP or later font smoothing settings + * @run main/manual FontSmoothing + */ + +public class FontSmoothing { + + private static final String PROP_NAME = "win.text.fontSmoothingType"; + + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + This test should be run on Windows XP or later. + + On Windows 11: + 1. Open Run dialog by typing 'run' in search bar. + 2. Type 'cttune' and press Ok. + 3. Uncheck the "Turn On ClearType" checkbox and follow next instructions on screen. + 4. Repeat Step 1-2. + 5. Check the "Turn On ClearType" checkbox and follow next instructions on screen. + 6. Take a look at the output window to determine if the test passed or failed. + """; + + PassFailJFrame.builder() + .title("FontSmoothing Test Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(40) + .testTimeOut(5) + .testUI(FontSmoothing::createUI) + .logArea(8) + .build() + .awaitAndCheck(); + } + + private static Frame createUI() { + Frame f = new Frame("FontSmoothing Test"); + f.setSize(50, 50); + + Object value = Toolkit.getDefaultToolkit().getDesktopProperty(PROP_NAME); + PassFailJFrame.log("toolkit.getDesktopProperty: " + PROP_NAME + " = " + value + "\n"); + + Toolkit.getDefaultToolkit().addPropertyChangeListener(PROP_NAME, new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent e) { + PassFailJFrame.log("PropertyChangeEvent: " + e.getPropertyName() + + "\n old value=" + e.getOldValue() + + "\n new value=" + e.getNewValue()); + + Integer value = (Integer) Toolkit.getDefaultToolkit().getDesktopProperty(PROP_NAME); + PassFailJFrame.log("toolkit.getDesktopProperty:" + PROP_NAME + "=" + value); + + if (value.equals((Integer) e.getNewValue())) { + PassFailJFrame.log("test PASSED"); + } else { + PassFailJFrame.log("test FAILED"); + } + } + }); + return f; + } +} diff --git a/test/jdk/java/awt/DesktopProperties/ThreeDBackgroundColor.java b/test/jdk/java/awt/DesktopProperties/ThreeDBackgroundColor.java new file mode 100644 index 00000000000..26792e79a92 --- /dev/null +++ b/test/jdk/java/awt/DesktopProperties/ThreeDBackgroundColor.java @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Color; +import java.awt.Frame; +import java.awt.Toolkit; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; + +/* + * @test + * @bug 4368193 + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @requires (os.family == "windows") + * @summary Toolkit's getDesktopProperty returns stale values on Microsoft Windows + * @run main/manual ThreeDBackgroundColor + */ + +public class ThreeDBackgroundColor { + + private static final String PROP_NAME = "win.3d.backgroundColor"; + + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + On Windows 10: + 1. Open Windows Settings, in the search bar type + 'high contrast', in the list of suggestions choose option + 'Turn high contrast on or off' + 2. In the High contrast control panel click on the on/off switch + to initialize High contrast mode + 3. Wait for the High contrast mode to finish initialization + 4. Click on the same switch again to turn off High contrast mode + + On Windows 11: + 1. Open Windows settings, in the search bar type + 'Contrast Theme'. + 2. Select any value from 'Contrast themes' dropdown menu and press 'Apply'. + 3. Wait for the High contrast mode to finish initialization + 4. Select 'None' from 'Contrast themes' dropdown menu to revert the changes. + + Take a look at the output window to determine if the test passed or failed."""; + + PassFailJFrame.builder() + .title("ThreeDBackgroundColor Test Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(40) + .testTimeOut(5) + .testUI(ThreeDBackgroundColor::createUI) + .logArea(8) + .build() + .awaitAndCheck(); + } + + private static Frame createUI() { + Frame f = new Frame("ThreeDBackgroundColor Test"); + f.setSize(50, 50); + + Object value = Toolkit.getDefaultToolkit().getDesktopProperty(PROP_NAME); + PassFailJFrame.log("toolkit.getDesktopProperty:" + PROP_NAME + "=" + value); + + Toolkit.getDefaultToolkit().addPropertyChangeListener(PROP_NAME, new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent e) { + PassFailJFrame.log("PropertyChangeEvent: " + e.getPropertyName() + + "\n old value=" + e.getOldValue() + + "\n new value=" + e.getNewValue()); + + Color value = (Color) Toolkit.getDefaultToolkit().getDesktopProperty(PROP_NAME); + PassFailJFrame.log("toolkit.getDesktopProperty:" + PROP_NAME + "=" + value); + if (value.equals((Color) e.getNewValue())) { + PassFailJFrame.log("test PASSED"); + } else { + PassFailJFrame.log("test FAILED"); + } + } + }); + return f; + } +} diff --git a/test/jdk/java/awt/Dialog/DefaultIconTest.java b/test/jdk/java/awt/Dialog/DefaultIconTest.java new file mode 100644 index 00000000000..8d2ec8c406f --- /dev/null +++ b/test/jdk/java/awt/Dialog/DefaultIconTest.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 java.awt.Dialog; +import java.awt.Frame; + +/* + * @test + * @bug 4964237 + * @requires (os.family == "windows") + * @summary Win: Changing theme changes java dialogs title icon + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual DefaultIconTest + */ + +public class DefaultIconTest { + static String instructions = """ + This test shows frame and two dialogs + Change windows theme. Resizable dialog should retain default icon + Non-resizable dialog should retain no icon + Press PASS if icons look correct, FAIL otherwise + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("ShownModalDialogSerializationTest Instructions") + .instructions(instructions) + .testTimeOut(5) + .rows(10) + .columns(35) + .testUI(DefaultIconTest::createGUIs) + .build() + .awaitAndCheck(); + } + + public static Frame createGUIs() { + Frame f = new Frame("DefaultIconTest"); + f.setSize(200, 100); + Dialog d1 = new Dialog(f, "Resizable Dialog, should show default icon"); + d1.setSize(200, 100); + d1.setVisible(true); + d1.setLocation(0, 150); + Dialog d2 = new Dialog(f, "Non-resizable dialog, should have no icon"); + d2.setSize(200, 100); + d2.setVisible(true); + d2.setResizable(false); + d2.setLocation(0, 300); + return f; + } +} diff --git a/test/jdk/java/awt/Dialog/DialogIconTest/DialogIconTest.java b/test/jdk/java/awt/Dialog/DialogIconTest/DialogIconTest.java new file mode 100644 index 00000000000..06debe28fc5 --- /dev/null +++ b/test/jdk/java/awt/Dialog/DialogIconTest/DialogIconTest.java @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Dialog; +import java.awt.Frame; +import java.awt.Image; +import java.awt.Label; +import java.awt.MediaTracker; +import java.awt.Toolkit; +import java.awt.Window; +import java.util.List; + +/* + * @test + * @bug 4779641 + * @summary Test to verify that Non-resizable dialogs should not show icons + * @requires (os.family == "windows") + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual DialogIconTest + */ + +public class DialogIconTest { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + 1. This is a Windows-only test of Dialog icons + 2. You can see a frame with a swing icon and two dialogs that it + owns. The resizable dialog should have the same icon as the + frame. The non-resizable dialog should have no icon at all + 3. Press PASS if this is true, press FAIL otherwise + """; + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(35) + .testUI(initialize()) + .build() + .awaitAndCheck(); + } + + public static List initialize() { + Frame f = new Frame("Parent frame"); + f.setBounds(50, 50, 200, 200); + + Dialog dr = new Dialog(f, "Resizable Dialog"); + dr.setLocation(100, 100); + dr.add(new Label("Should inherit icon from parent")); + dr.pack(); + + Dialog dn = new Dialog(f, "NON Resizable Dialog"); + dn.setLocation(150, 150); + dn.add(new Label("Should have no icon")); + dn.pack(); + dn.setResizable(false); + + String fileName = System.getProperty("test.src") + + System.getProperty("file.separator") + "swing.small.gif"; + + Image icon = Toolkit.getDefaultToolkit().createImage(fileName); + MediaTracker tracker = new MediaTracker(f); + tracker.addImage(icon, 0); + try { + tracker.waitForAll(); + } catch (InterruptedException ie) { + throw new RuntimeException("MediaTracker addImage Interrupted!"); + } + f.setIconImage(icon); + return List.of(f, dn, dr); + } +} diff --git a/test/jdk/java/awt/Dialog/DialogIconTest/swing.small.gif b/test/jdk/java/awt/Dialog/DialogIconTest/swing.small.gif new file mode 100644 index 00000000000..14a489ff4e7 Binary files /dev/null and b/test/jdk/java/awt/Dialog/DialogIconTest/swing.small.gif differ diff --git a/test/jdk/java/awt/Dialog/DialogInitialResizability.java b/test/jdk/java/awt/Dialog/DialogInitialResizability.java new file mode 100644 index 00000000000..7ecde39c4ad --- /dev/null +++ b/test/jdk/java/awt/Dialog/DialogInitialResizability.java @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 java.awt.Dialog; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.event.ComponentEvent; +import java.awt.event.ComponentListener; + +/* + * @test + * @bug 4912551 + * @summary Checks that with resizable set to false before show() + * dialog can not be resized. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual DialogInitialResizability + */ + +public class DialogInitialResizability { + static String instructions = """ + When this test is run a dialog will display (setResizable Test). + This dialog should not be resizable. + + Additionally ensure that there are NO componentResized events in the log section. + If the above conditions are true, then Press PASS else FAIL. + """; + + private static final Dimension INITIAL_SIZE = new Dimension(400, 150); + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("DialogInitialResizability") + .instructions(instructions) + .testTimeOut(5) + .rows((int) instructions.lines().count() + 2) + .columns(40) + .testUI(DialogInitialResizability::createGUI) + .logArea() + .build() + .awaitAndCheck(); + } + + public static MyDialog createGUI() { + Frame f = new Frame("invisible dialog owner"); + + MyDialog ld = new MyDialog(f); + ld.setBounds(100, 100, INITIAL_SIZE.width, INITIAL_SIZE.height); + ld.setResizable(false); + + PassFailJFrame.log("Dialog isResizable is set to: " + ld.isResizable()); + PassFailJFrame.log("Dialog Initial Size " + ld.getSize()); + return ld; + } + + private static class MyDialog extends Dialog implements ComponentListener { + public MyDialog(Frame f) { + super(f, "setResizable test", false); + this.addComponentListener(this); + } + + public void componentResized(ComponentEvent e) { + if (!e.getComponent().getSize().equals(INITIAL_SIZE)) { + PassFailJFrame.log("Component Resized. Test Failed!!"); + } + } + + public void componentMoved(ComponentEvent e) { + } + + public void componentShown(ComponentEvent e) { + } + + public void componentHidden(ComponentEvent e) { + } + } +} diff --git a/test/jdk/java/awt/Dialog/DialogModalityTest.java b/test/jdk/java/awt/Dialog/DialogModalityTest.java new file mode 100644 index 00000000000..d8ac9e4620b --- /dev/null +++ b/test/jdk/java/awt/Dialog/DialogModalityTest.java @@ -0,0 +1,114 @@ +/* + * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.Component; +import java.awt.Dialog; +import java.awt.Event; +import java.awt.Frame; +import java.awt.Panel; +import java.awt.Window; +import java.util.List; + +/* + * @test + * @bug 4058370 + * @summary Test to verify Modality of Dialog + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual DialogModalityTest + */ + +public class DialogModalityTest { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + 1. When the test is running, there will be a Frame, a Modal Dialog + and a Window that is Modal Dialog's parent. + 2. Verify that it is impossible to bring up the menu in Frame before + closing the Modal Dialog. + """; + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(35) + .testUI(initialize()) + .build() + .awaitAndCheck(); + } + + public static List initialize() { + Frame f = new Frame("Parent Frame"); + DialogTest dlg = new DialogTest(f, "Modal Dialog"); + f.add(new Button("push me")); + f.setSize(200, 200); + f.setLocation(210, 1); + dlg.setBounds(210, 203, 200, 200); + return List.of(f, dlg); + } +} + +class DialogTest extends Dialog { + Button closeButton; + Frame parent; + + public DialogTest(Frame parent, String title) { + this(parent, title, true); + } + + public DialogTest(Frame parent, String title, boolean modal) { + super(parent, title, modal); + this.parent = parent; + setLayout(new BorderLayout()); + Panel buttonPanel = new Panel(); + closeButton = new Button("Close"); + buttonPanel.add(closeButton); + add("Center", buttonPanel); + pack(); + } + + public boolean action(Event e, Object arg) { + if (e.target == closeButton) { + Dialog dialog = null; + Component c = (Component) e.target; + + while (c != null && !(c instanceof Dialog)) { + c = c.getParent(); + } + + if (c != null) { + dialog = (Dialog) c; + } + + if (dialog == null) { + return false; + } + + dialog.setVisible(false); + dialog.dispose(); + return true; + } + return false; + } +} diff --git a/test/jdk/java/awt/Dialog/DialogResizeTest.java b/test/jdk/java/awt/Dialog/DialogResizeTest.java new file mode 100644 index 00000000000..e57a5298068 --- /dev/null +++ b/test/jdk/java/awt/Dialog/DialogResizeTest.java @@ -0,0 +1,118 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Checkbox; +import java.awt.Dialog; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.Panel; +import java.awt.TextArea; +import java.awt.event.ComponentEvent; +import java.awt.event.ComponentListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.lang.Exception; +import java.lang.String; +import java.lang.System; + +/* + * @test + * @bug 4115213 + * @summary Test to verify Checks that with resizable set to false, + * dialog can not be resized + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual DialogResizeTest + */ + +public class DialogResizeTest { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + 1. When this test is run a dialog will display (setResizable Test) + Click on the checkbox to change the dialog resizable state + 2. For both dialog resizable states (resizable, non-resizable) try to + change the size of the dialog. When isResizable is true the dialog + is resizable. When isResizable is false the dialog is non-resizable + 3. If this is the behavior that you observe, the test has passed, Press + the Pass button. Otherwise the test has failed, Press the Fail button + """; + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(40) + .testUI(initialize()) + .logArea(8) + .build() + .awaitAndCheck(); + } + + public static Dialog initialize() { + Frame f = new Frame("Owner Frame"); + MyDialog ld = new MyDialog(f); + ld.setBounds(100, 100, 400, 150); + ld.setResizable(false); + System.out.println("isResizable is set to: " + ld.isResizable()); + return ld; + } +} + +class MyDialog extends Dialog implements ItemListener { + String sText = "Tests java.awt.Dialog.setResizable method"; + TextArea ta = new TextArea(sText, 2, 40, TextArea.SCROLLBARS_NONE); + + public MyDialog(Frame f) { + + super(f, "setResizable test", false); + + Panel cbPanel = new Panel(); + cbPanel.setLayout(new FlowLayout()); + + Panel taPanel = new Panel(); + taPanel.setLayout(new FlowLayout()); + taPanel.add(ta); + + Checkbox cb = new Checkbox("Check this box to change the dialog's " + + "resizable state", null, isResizable()); + cb.setState(false); + cb.addItemListener(this); + cbPanel.add(cb); + + add("North", taPanel); + add("South", cbPanel); + pack(); + } + + public void itemStateChanged(ItemEvent evt) { + setResizable(evt.getStateChange() == ItemEvent.SELECTED); + + boolean bResizeState = isResizable(); + PassFailJFrame.log("isResizable is set to: " + bResizeState); + + if (isResizable()) { + ta.setText("dialog is resizable (isResizable = " + bResizeState + ")"); + } else { + ta.setText("dialog is NOT resizable (isResizable = " + bResizeState + ")"); + } + } +} diff --git a/test/jdk/java/awt/Dialog/DialogResizeTest2.java b/test/jdk/java/awt/Dialog/DialogResizeTest2.java new file mode 100644 index 00000000000..3124719637a --- /dev/null +++ b/test/jdk/java/awt/Dialog/DialogResizeTest2.java @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 java.awt.Button; +import java.awt.Dialog; +import java.awt.Frame; +import java.awt.GridLayout; + +/* + * @test + * @bug 4172302 + * @summary Test to make sure non-resizable Dialogs can be resized with the + * setSize() method. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual DialogResizeTest2 + */ + +public class DialogResizeTest2 { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + This tests the programmatic resizability of non-resizable Dialogs + Even when a Dialog is set to be non-resizable, it should be + programmatically resizable using the setSize() method. + + 1. Initially the Dialog will be resizable. Try using the \\"Smaller\\" + and \\"Larger\\" buttons to verify that the Dialog resizes correctly + 2. Then, click the \\"Toggle\\" button to make the Dialog non-resizable + 3. Again, verify that clicking the \\"Larger\\" and \\"Smaller\\" buttons + causes the Dialog to get larger and smaller. If the Dialog does + not change size, or does not re-layout correctly, the test FAILS + """; + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(35) + .testUI(initialize()) + .logArea(8) + .build() + .awaitAndCheck(); + } + + public static Frame initialize() { + Frame frame = new Frame("Parent Frame"); + frame.add(new Button("Button")); + frame.setSize(100, 100); + new dlg(frame).setVisible(true); + return frame; + } + + static class dlg extends Dialog { + public dlg(Frame f_) { + super(f_, "Dialog", false); + setSize(200, 200); + Button bLarger = new Button("Larger"); + bLarger.addActionListener(e -> setSize(400, 400)); + Button bSmaller = new Button("Smaller"); + bSmaller.addActionListener(e -> setSize(200, 100)); + Button bCheck = new Button("Resizable?"); + bCheck.addActionListener(e -> { + if (isResizable()) { + PassFailJFrame.log("Dialog is resizable"); + } else { + PassFailJFrame.log("Dialog is not resizable"); + } + }); + Button bToggle = new Button("Toggle"); + bToggle.addActionListener(e -> { + if (isResizable()) { + setResizable(false); + PassFailJFrame.log("Dialog is now not resizable"); + } else { + setResizable(true); + PassFailJFrame.log("Dialog is now resizable"); + } + }); + setLayout(new GridLayout(1, 4)); + add(bSmaller); + add(bLarger); + add(bCheck); + add(bToggle); + } + } +} diff --git a/test/jdk/java/awt/Dialog/FileDialogIconTest/FileDialogIconTest.java b/test/jdk/java/awt/Dialog/FileDialogIconTest/FileDialogIconTest.java new file mode 100644 index 00000000000..e8505681a82 --- /dev/null +++ b/test/jdk/java/awt/Dialog/FileDialogIconTest/FileDialogIconTest.java @@ -0,0 +1,258 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Button; +import java.awt.FileDialog; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.Image; +import java.awt.Rectangle; +import java.awt.Robot; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.image.BufferedImage; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/* + * @test + * @bug 4035189 + * @summary Test to verify that PIT File Dialog icon not matching with + * the new java icon (frame Icon) - PIT build + * @requires (os.family == "windows") + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual FileDialogIconTest + */ + +public class FileDialogIconTest { + public static Frame frame; + public static Image image; + public static List images; + static String fileBase; + + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + 1. Select the Image for a Dialog and Frame using either + Load/Save/Just Dialog. + 2. Set the Icon Image/s to Frame and Dialog. Verify that the + Icon is set for the respective Frame and Dialog. + If selected Icon is set to Frame and Dialog press PASS + else FAIL. + """; + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(35) + .testUI(initialize()) + .logArea(8) + .build() + .awaitAndCheck(); + } + + public static void setImagesToFD(java.util.List listIcon) { + FileDialogIconTest.images = listIcon; + } + + public static void setImagesToFrame(java.util.List listIcon) { + frame.setIconImages(listIcon); + } + + public static void setImageToFD(Image img) { + FileDialogIconTest.image = img; + } + + public static void setImageToFrame(Image img) { + frame.setIconImage(img); + } + + public static Frame initialize() { + frame = new Frame("FileDialogIconTest"); + Button setImageButton1 = new Button("setIconImageToFrame"); + Button setImageButton2 = new Button("setIconImageToDialog"); + Button setImageButton3 = new Button("setIconImagesToFrame"); + Button setImageButton4 = new Button("setIconImagesToDialog"); + Button setImageButton5 = new Button("setIconBufferedImagesToDialog"); + Button setImageButton6 = new Button("setIconBufferedImagesToFrame"); + + if (System.getProperty("test.src") == null) { + fileBase = ""; + } else { + fileBase = System.getProperty("test.src") + System.getProperty("file.separator"); + } + + final String fileName = fileBase + "loading-msg.gif"; + + setImageButton1.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent event) { + try { + Image image = Toolkit.getDefaultToolkit().getImage(fileName); + setImageToFrame(image); + PassFailJFrame.log("Loaded image . setting to frame"); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + + setImageButton2.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent event) { + try { + Image image = Toolkit.getDefaultToolkit().getImage(fileName); + setImageToFD(image); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + + setImageButton3.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent event) { + try { + Image image; + java.util.List list = new java.util.ArrayList(); + for (int i = 1; i <= 4; i++) { + String fileName = fileBase + "T" + i + ".gif"; + image = Toolkit.getDefaultToolkit().getImage(fileName); + PassFailJFrame.log("Loaded image " + fileName + ". setting to the list for frame"); + list.add(image); + } + setImagesToFrame(list); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + + + setImageButton4.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent event) { + try { + Image image; + List list = new ArrayList<>(); + for (int i = 1; i <= 4; i++) { + String fileName = fileBase + "T" + i + ".gif"; + image = Toolkit.getDefaultToolkit().getImage(fileName); + PassFailJFrame.log("Loaded image " + fileName + ". setting to the list for dialog"); + list.add(image); + } + setImagesToFD(list); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + + + setImageButton5.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent event) { + List list = new ArrayList<>(); + try { + Robot robot = new Robot(); + Rectangle rectangle; + for (int i = 1; i <= 4; i++) { + rectangle = new Rectangle(i * 10, i * 10, i * 10 + 40, i * 10 + 40); + java.awt.image.BufferedImage image = robot.createScreenCapture(rectangle); + robot.delay(100); + list.add(image); + } + } catch (Throwable t) { + t.printStackTrace(); + } + PassFailJFrame.log("Captured images and set to the list for dialog"); + } + }); + + setImageButton6.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent event) { + List list = new ArrayList<>(); + try { + Robot robot = new Robot(); + Rectangle rectangle; + for (int i = 1; i <= 4; i++) { + rectangle = new Rectangle(i * 10, i * 10, i * 10 + 40, i * 10 + 40); + java.awt.image.BufferedImage image = robot.createScreenCapture(rectangle); + robot.delay(100); + list.add(image); + } + } catch (Throwable t) { + t.printStackTrace(); + } + PassFailJFrame.log("Captured images and set to the list for frame"); + } + }); + + Button buttonLoad = new Button("Load Dialog"); + Button buttonSave = new Button("Save Dialog"); + Button buttonSimple = new Button("Just Dialog"); + buttonLoad.addActionListener(new MyActionListener(FileDialog.LOAD, "LOAD")); + buttonSave.addActionListener(new MyActionListener(FileDialog.SAVE, "SAVE")); + buttonSimple.addActionListener(new MyActionListener(-1, "")); + + frame.setSize(400, 400); + frame.setLayout(new FlowLayout()); + frame.add(buttonLoad); + frame.add(buttonSave); + frame.add(buttonSimple); + frame.add(setImageButton1); + frame.add(setImageButton2); + frame.add(setImageButton3); + frame.add(setImageButton4); + frame.pack(); + return frame; + } +} + +class MyActionListener implements ActionListener { + int id; + String name; + + public MyActionListener(int id, String name) { + this.id = id; + this.name = name; + } + + public void actionPerformed(ActionEvent ae) { + try { + FileDialog filedialog; + if (id == -1 && Objects.equals(name, "")) { + filedialog = new FileDialog(FileDialogIconTest.frame); + } else { + filedialog = new FileDialog(FileDialogIconTest.frame, name, id); + } + if (FileDialogIconTest.image != null) { + filedialog.setIconImage(FileDialogIconTest.image); + } + + if (FileDialogIconTest.images != null) { + filedialog.setIconImages(FileDialogIconTest.images); + } + filedialog.setVisible(true); + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/test/jdk/java/awt/Dialog/FileDialogIconTest/T1.gif b/test/jdk/java/awt/Dialog/FileDialogIconTest/T1.gif new file mode 100644 index 00000000000..24a7dea299f Binary files /dev/null and b/test/jdk/java/awt/Dialog/FileDialogIconTest/T1.gif differ diff --git a/test/jdk/java/awt/Dialog/FileDialogIconTest/T2.gif b/test/jdk/java/awt/Dialog/FileDialogIconTest/T2.gif new file mode 100644 index 00000000000..1f3fd66328b Binary files /dev/null and b/test/jdk/java/awt/Dialog/FileDialogIconTest/T2.gif differ diff --git a/test/jdk/java/awt/Dialog/FileDialogIconTest/T3.gif b/test/jdk/java/awt/Dialog/FileDialogIconTest/T3.gif new file mode 100644 index 00000000000..af6d626058a Binary files /dev/null and b/test/jdk/java/awt/Dialog/FileDialogIconTest/T3.gif differ diff --git a/test/jdk/java/awt/Dialog/FileDialogIconTest/T4.gif b/test/jdk/java/awt/Dialog/FileDialogIconTest/T4.gif new file mode 100644 index 00000000000..67876264d8f Binary files /dev/null and b/test/jdk/java/awt/Dialog/FileDialogIconTest/T4.gif differ diff --git a/test/jdk/java/awt/Dialog/FileDialogIconTest/loading-msg.gif b/test/jdk/java/awt/Dialog/FileDialogIconTest/loading-msg.gif new file mode 100644 index 00000000000..6c7570a6d84 Binary files /dev/null and b/test/jdk/java/awt/Dialog/FileDialogIconTest/loading-msg.gif differ diff --git a/test/jdk/java/awt/Dialog/FileDialogUserFilterTest.java b/test/jdk/java/awt/Dialog/FileDialogUserFilterTest.java new file mode 100644 index 00000000000..80ff9ed0bde --- /dev/null +++ b/test/jdk/java/awt/Dialog/FileDialogUserFilterTest.java @@ -0,0 +1,150 @@ +/* + * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 java.awt.Button; +import java.awt.Checkbox; +import java.awt.Component; +import java.awt.Container; +import java.awt.Event; +import java.awt.FileDialog; +import java.awt.Frame; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Label; +import java.awt.Panel; +import java.awt.TextField; +import java.io.File; +import java.io.FilenameFilter; + +/* + * @test + * @bug 4293697 4416433 4417139 4409600 + * @summary Test to verify that user filter always gets called on changing the + * directory in FileDialog + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual FileDialogUserFilterTest + */ + +public class FileDialogUserFilterTest { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + 1. Enter a mask into the field, a directory into + the field (or leave the default values). + 2. Then click the button, file dialog will appear. + Output of the user filter will be shown in the output + area. Enter several different directories to the file dialog + via double-clicking on the directory list. The output + area should show some filtering output on each directory + change. If any output was only given on dialog startup, + the test is FAILED. + 3. Look at the list of files accepted by the filter. + If some files do not match the filter, + the test is FAILED. + 4. Open dialog with an empty filter. + Enter some directories with a lot of files (like /usr/bin). + If dialog crashes the test is FAILED. + Enter the directory that contain files and other directories. + If the directories are shown in the files box along with files + then the test is FAILED. + 5. Click in checkbox 'do not use filter', make it checked. + Open dialog, enter the directory with some files. + If no files is shown in the File list box (while you are sure + there are some files there) the test is FAILED + Otherwise it is PASSED." + """; + + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(35) + .testUI(new DialogFilterTest()) + .build() + .awaitAndCheck(); + } +} + +class DialogFilterTest extends Frame implements FilenameFilter { + FileDialog fd; + static TextField tfDirectory = new TextField(); + static TextField tfFile = new TextField(); + static TextField tfFilter = new TextField(); + static Checkbox useFilterCheck = new Checkbox("do not use filter"); + + public DialogFilterTest() { + setTitle("File Dialog User Filter test"); + add("North", new Button("Load")); + Panel p = new Panel(); + p.setLayout(new GridBagLayout()); + addRow(p, new Label("directory:", Label.RIGHT), tfDirectory); + addRow(p, new Label("file:", Label.RIGHT), tfFile); + addRow(p, new Label("filter:", Label.RIGHT), tfFilter); + addRow(p, new Label(""), useFilterCheck); + tfFilter.setText(".java"); + tfDirectory.setText("."); + add("Center", p); + setSize(300, 200); + } + + static void addRow(Container cont, Component c1, Component c2) { + GridBagLayout gbl = (GridBagLayout) cont.getLayout(); + GridBagConstraints c = new GridBagConstraints(); + c.fill = GridBagConstraints.BOTH; + cont.add(c1); + gbl.setConstraints(c1, c); + + c.gridwidth = GridBagConstraints.REMAINDER; + c.weightx = 1.0; + cont.add(c2); + gbl.setConstraints(c2, c); + } + + public boolean accept(File dir, String name) { + System.out.println("File " + dir + " String " + name); + if (fd.getMode() == FileDialog.LOAD) { + return name.lastIndexOf(tfFilter.getText()) > 0; + } + return true; + } + + public boolean action(Event evt, Object what) { + boolean load = "Load".equals(what); + + if (load || "Save".equals(what)) { + fd = new FileDialog(new Frame(), null, + load ? FileDialog.LOAD : FileDialog.SAVE); + fd.setDirectory(tfDirectory.getText()); + fd.setFile(tfFile.getText()); + if (!useFilterCheck.getState()) { + fd.setFilenameFilter(this); + } + fd.setVisible(true); + tfDirectory.setText(fd.getDirectory()); + tfFile.setText(fd.getFile()); + + return true; + } + return false; + } +} diff --git a/test/jdk/java/awt/Dialog/FileDialogWrongNameCrash.java b/test/jdk/java/awt/Dialog/FileDialogWrongNameCrash.java new file mode 100644 index 00000000000..f3d83a68494 --- /dev/null +++ b/test/jdk/java/awt/Dialog/FileDialogWrongNameCrash.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Button; +import java.awt.Frame; + +/* + * @test + * @bug 4779118 + * @summary Tests that FileDialog with wrong initial file name + * doesn't crash when Open button is pressed. + * @requires (os.family == "windows") + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual FileDialogWrongNameCrash + */ + +public class FileDialogWrongNameCrash { + + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + (This is Windows only test) + 1. You should see a frame 'Frame' with button 'Load'. Press button.", + 2. You should see 'Load file' dialog, select any file and press 'Open'", + (not 'Cancel'!!!). If Java doesn't crash - press PASS, else FAIL + """; + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(35) + .testUI(initialize()) + .build() + .awaitAndCheck(); + } + + private static Frame initialize() { + Frame frame = new Frame("File Dialog Wrong Name Crash Test"); + Button fileButton = new Button("Load"); + fileButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent e) { + final java.awt.FileDialog selector = + new java.awt.FileDialog(frame); + selector.setFile("Z:\\O2 XDA\\LogiTest\\\\Testcase.xml"); + selector.setVisible(true); + } + }); + frame.add(fileButton); + frame.setSize(100, 60); + return frame; + } +} diff --git a/test/jdk/java/awt/Dialog/GetLocationTest_1.java b/test/jdk/java/awt/Dialog/GetLocationTest_1.java new file mode 100644 index 00000000000..a373f931cf7 --- /dev/null +++ b/test/jdk/java/awt/Dialog/GetLocationTest_1.java @@ -0,0 +1,129 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Color; +import java.awt.Component; +import java.awt.Dialog; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.Window; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +/* + * @test + * @bug 4168481 + * @summary Test to verify Dialog getLocation() regression on Solaris + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual GetLocationTest_1 + */ + +public class GetLocationTest_1 { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + 1. Click in in the blue square and the yellow window should come + up with the top left by the cursor + 2. If you see this correct behavior press PASS. If you see that + the yellow window location is offset by some inset, press FAIL + """; + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(35) + .testUI(initialize()) + .logArea(8) + .build() + .awaitAndCheck(); + } + + public static Dialog initialize() { + Frame f = new Frame("Owner Frame"); + ColorComponent blue = new ColorComponent(); + blue.setBackground(Color.blue); + blue.setSize(50, 50); + + final Dialog dialog = new Dialog(f, "GetLocation test"); + dialog.setLocation(300, 300); + System.out.println("Dialog location = " + dialog.getLocation()); + blue.setLocation(50, 50); + dialog.setLayout(null); + dialog.add(blue); + dialog.setSize(200, 200); + + final ColorWindow w = new ColorWindow(f); + w.setSize(50, 50); + w.setBackground(Color.yellow); + + blue.addMouseListener(new MouseAdapter() { + public void mousePressed(MouseEvent e) { + PassFailJFrame.log("Dialog location = " + dialog.getLocation()); + Point p = e.getPoint(); + Component c = e.getComponent(); + PassFailJFrame.log("Position = " + p); + convertPointToScreen(p, c); + PassFailJFrame.log("Converted to = " + p); + w.setLocation(p.x, p.y); + w.setVisible(true); + } + }); + return dialog; + } + + static class ColorComponent extends Component { + public void paint(Graphics g) { + g.setColor(getBackground()); + Rectangle bounds = getBounds(); + g.fillRect(0, 0, bounds.width, bounds.height); + } + } + + static class ColorWindow extends Window { + ColorWindow(Frame f) { + super(f); + } + + public void paint(Graphics g) { + g.setColor(getBackground()); + Rectangle bounds = getBounds(); + g.fillRect(0, 0, bounds.width, bounds.height); + } + } + + public static void convertPointToScreen(Point p, Component c) { + do { + Point b = c.getLocation(); + PassFailJFrame.log("Adding " + b + " for " + c); + p.x += b.x; + p.y += b.y; + + if (c instanceof java.awt.Window) { + break; + } + c = c.getParent(); + } while (c != null); + } +} diff --git a/test/jdk/java/awt/Dialog/HideDialogTest.java b/test/jdk/java/awt/Dialog/HideDialogTest.java new file mode 100644 index 00000000000..78d0344a6cf --- /dev/null +++ b/test/jdk/java/awt/Dialog/HideDialogTest.java @@ -0,0 +1,138 @@ +/* + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.Color; +import java.awt.Dialog; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Panel; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +/* + * @test + * @bug 4048664 4065506 4122094 4171979 + * @summary Test if Dialog can be successfully hidden, see that no other app + * comes to front, see if hide + dispose causes assertion failure + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual HideDialogTest + */ + +public class HideDialogTest { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + 1. A Frame should appear with a "test" button in it + 2. Click on the "test" button. A Dialog will appear with a "dismiss" button + and a "dismiss-with-dispose" button + 3. First, click on the "dismiss-with-dispose" button. Verify that + no assertion failure appears. + 4. Now, click on the "dismiss" button. The Dialog should go away. + 5. Repeat from (2) 10-20 times. + 6. When the dialog goes away check that the frame window does not briefly + get obscured by another app or repaint it's entire area. There should be + no flicker at all in areas obscured by the dialog. (4065506 4122094) + If there is the test fails. + 7. If the Dialog is successfully hidden each time, the test passed. If the + Dialog did not hide, the test failed (4048664). + + NOTE: When the dialog does not go away (meaning the bug has manifested itself), + the "dismiss-with-dispose" button can be used to get rid of it. + """; + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(40) + .testUI(new MyFrame()) + .build() + .awaitAndCheck(); + } +} + +class MyDialog extends Dialog { + public MyDialog(Frame f) { + super(f, "foobar", true); + setSize(200, 200); + setLayout(new BorderLayout()); + Panel p = new Panel(); + p.setLayout(new FlowLayout(FlowLayout.CENTER)); + Button okButton; + okButton = new Button("dismiss"); + p.add(okButton); + okButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + System.out.println("Calling setVisible(false)"); + setVisible(false); + } + }); + Button newButton; + p.add(newButton = new Button("dismiss-with-dispose")); + newButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + System.out.println("Calling setVisible(false) + dispose()"); + setVisible(false); + dispose(); + } + }); + add("South", p); + pack(); + } +} + +class MyFrame extends Frame implements ActionListener { + public MyFrame() { + super(); + setSize(600, 400); + setTitle("HideDialogTest"); + setLayout(new BorderLayout()); + Panel toolbar = new Panel(); + toolbar.setLayout(new FlowLayout(FlowLayout.LEFT)); + Button testButton = new Button("test"); + testButton.addActionListener(this); + toolbar.add(testButton); + add("North", toolbar); + } + + public void actionPerformed(ActionEvent e) { + String s = e.getActionCommand(); + if (s.equals("test")) { + System.out.println("Begin test"); + MyDialog d = new MyDialog(this); + d.setVisible(true); + System.out.println("End test"); + } + } + + public void paint(Graphics g) { + for (int i = 0; i < 10; i++) { + g.setColor(Color.red); + g.fillRect(0, 0, 2000, 2000); + g.setColor(Color.blue); + g.fillRect(0, 0, 2000, 2000); + } + } +} diff --git a/test/jdk/java/awt/Dialog/ModalDialogTest.java b/test/jdk/java/awt/Dialog/ModalDialogTest.java new file mode 100644 index 00000000000..aceacc9209a --- /dev/null +++ b/test/jdk/java/awt/Dialog/ModalDialogTest.java @@ -0,0 +1,147 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.Checkbox; +import java.awt.Dialog; +import java.awt.Frame; +import java.awt.Panel; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; + +/* + * @test + * @bug 4078176 + * @summary Test to verify Modal dialogs don't act modal if addNotify() + * is called before setModal(true). + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual ModalDialogTest + */ + +public class ModalDialogTest implements ActionListener { + public boolean modal = true; + Button closeBtn = new Button("Close me"); + Button createBtn = new Button("Create Dialog"); + Button createNewBtn = new Button("Create Modal Dialog"); + Button lastBtn = new Button("Show Last Dialog"); + Dialog dialog; + Dialog newDialog; + Frame testFrame; + + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + 1. Use 'Modal' checkbox to select which dialog you're + going to create - modal or non-modal. + (this checkbox affects only new created dialog but + not existing one) + 2. Use 'Create Dialog' button to create a dialog. + If you have selected 'Modal' checkbox then dialog has to + be created modal - you can make sure of that clicking + on any other control (i.e. 'Modal' checkbox) - they + should not work. + 3. Use 'Show Last Dialog' button to bring up last + created dialog - to make sure that if you show/hide + modal dialog several times it stays modal. + 4. On the appearing dialog there are two buttons: + 'Close Me' which closes the dialog, + and 'Create Modal Dialog' which creates one more + MODAL dialog just to make sure that + in situation with two modal dialogs all is fine. + 5. If created modal dialogs are really modal + (which means that they blocks the calling app) + then test is PASSED, otherwise it's FAILED." + """; + ModalDialogTest test = new ModalDialogTest(); + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(35) + .testUI(test.initialize()) + .build() + .awaitAndCheck(); + } + + public Frame initialize() { + testFrame = new Frame("Parent Frame"); + Frame frame = new Frame("Modal Dialog test"); + Panel panel = new Panel(); + panel.setLayout(new BorderLayout()); + + createBtn.addActionListener(this); + createNewBtn.addActionListener(this); + closeBtn.addActionListener(this); + lastBtn.addActionListener(this); + panel.add("Center", createBtn); + panel.add("South", lastBtn); + Checkbox cb = new Checkbox("Modal", modal); + cb.addItemListener(new ItemListener() { + public void itemStateChanged(ItemEvent e) { + modal = ((Checkbox) e.getSource()).getState(); + } + }); + panel.add("North", cb); + panel.setSize(200, 100); + + frame.add(panel); + frame.pack(); + return frame; + } + + public void actionPerformed(ActionEvent e) { + if (e.getSource() == createBtn) { + if (dialog != null) { + dialog.dispose(); + } + dialog = new Dialog(testFrame, "Modal Dialog"); + dialog.add("North", closeBtn); + dialog.add("South", createNewBtn); + createBtn.setEnabled(false); + dialog.pack(); + dialog.setModal(modal); + dialog.setVisible(true); + } else if (e.getSource() == closeBtn && dialog != null) { + createBtn.setEnabled(true); + dialog.setVisible(false); + } else if (e.getSource() == lastBtn && dialog != null) { + dialog.setVisible(true); + } else if (e.getSource() == createNewBtn && newDialog == null) { + newDialog = new Dialog(testFrame, "New Modal Dialog"); + Button clsBtn = new Button("Close Me"); + clsBtn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + newDialog.dispose(); + newDialog = null; + } + }); + newDialog.add("North", clsBtn); + newDialog.pack(); + newDialog.setModal(true); + newDialog.setVisible(true); + } + } +} diff --git a/test/jdk/java/awt/Dialog/NestedDialogTest.java b/test/jdk/java/awt/Dialog/NestedDialogTest.java new file mode 100644 index 00000000000..28fb1bc919e --- /dev/null +++ b/test/jdk/java/awt/Dialog/NestedDialogTest.java @@ -0,0 +1,312 @@ +/* + * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Button; +import java.awt.Choice; +import java.awt.Dialog; +import java.awt.FileDialog; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.GridLayout; +import java.awt.List; +import java.awt.Panel; +import java.awt.Point; +import java.awt.Window; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.util.Vector; +import java.util.Enumeration; + +/* + * @test + * @bug 4110094 4178930 4178390 + * @summary Test: Rewrite of Win modal dialogs + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual NestedDialogTest + */ + +public class NestedDialogTest { + private static Vector windows = new Vector(); + static String instructions = """ + To solve various race conditions, windows modal dialogs were rewritten. This + test exercises various modal dialog boundary conditions and checks that + previous fixes to modality are incorporated in the rewrite. + + Check the following: + - No IllegalMonitorStateException is thrown when a dialog closes + + - Open multiple nested dialogs and verify that all other windows + are disabled when modal dialog is active. + + - Check that the proper window is activated when a modal dialog closes. + + - Close nested dialogs out of order (e.g. close dialog1 before dialog2) + and verify that this works and no deadlock occurs. + + - Check that all other windows are disabled when a FileDialog is open. + + - Check that the proper window is activated when a FileDialog closes. + + - Verify that the active window nevers switches to another application + when closing dialogs, even temporarily. + + - Check that choosing Hide always sucessfully hides a dialog. You should + try this multiple times to catch any race conditions. + + - Check that the scrollbar on the Choice component in the dialog works, as opposed + to just using drag-scrolling or the cursor keys + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("NestedDialogTest") + .instructions(instructions) + .testTimeOut(5) + .rows((int) instructions.lines().count() + 2) + .columns(35) + .testUI(NestedDialogTest::createGUI) + .build() + .awaitAndCheck(); + } + + public static Frame createGUI() { + Frame frame1 = new NestedDialogTestFrame("frame0"); + Frame frame2 = new NestedDialogTestFrame("frame1"); + frame2.setLocation(100, 100); + return frame1; + } + + public static void addWindow(Window window) { + // System.out.println("Pushing window " + window); + windows.removeElement(window); + windows.addElement(window); + } + + public static void removeWindow(Window window) { + // System.out.println("Popping window " + window); + windows.removeElement(window); + } + + public static Window getWindow(int index) { + return (Window) windows.elementAt(index); + } + + public static Enumeration enumWindows() { + return windows.elements(); + } + + public static int getWindowIndex(Window win) { + return windows.indexOf(win); + } +} + +class NestedDialogTestFrame extends Frame { + NestedDialogTestFrame(String name) { + super(name); + setSize(200, 200); + show(); + + setLayout(new FlowLayout()); + Button btnDlg = new Button("Dialog..."); + add(btnDlg); + Button btnFileDlg = new Button("FileDialog..."); + add(btnFileDlg); + + addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent ev) { + System.exit(0); + } + }); + + btnDlg.addActionListener( + new ActionListener() { + public void actionPerformed(ActionEvent e) { + Dialog d1 = new SimpleDialog(NestedDialogTestFrame.this, null, true); + System.out.println("Returned from showing dialog: " + d1); + } + } + ); + + btnFileDlg.addActionListener( + new ActionListener() { + public void actionPerformed(ActionEvent e) { + FileDialog dlg = new FileDialog(NestedDialogTestFrame.this); + dlg.show(); + } + } + ); + + validate(); + } + + public void show() { + if (!isVisible()) { + NestedDialogTest.addWindow(this); + } + super.show(); + } + + public void dispose() { + NestedDialogTest.removeWindow(this); + super.dispose(); + } +} + +class SimpleDialog extends Dialog { + Button btnNested; + Button btnFileDlg; + Button btnShow; + Button btnHide; + Button btnDispose; + Button btnExit; + List listWins; + Dialog dlgPrev; + + public SimpleDialog(Frame frame, Dialog prev, boolean isModal) { + super(frame, "", isModal); + + dlgPrev = prev; + + addWindowListener(new WindowAdapter() { + public void windowActivated(WindowEvent ev) { + populateListWin(); + } + }); + + setTitle(getName()); + + Panel panelNorth = new Panel(); + panelNorth.setLayout(new GridLayout(1, 1)); + listWins = new List(); + panelNorth.add(listWins); + + Panel panelSouth = new Panel(); + panelSouth.setLayout(new FlowLayout()); + btnNested = new Button("Dialog..."); + panelSouth.add(btnNested); + btnFileDlg = new Button("FileDialog..."); + panelSouth.add(btnFileDlg); + btnShow = new Button("Show"); + panelSouth.add(btnShow); + btnHide = new Button("Hide"); + panelSouth.add(btnHide); + btnDispose = new Button("Dispose"); + panelSouth.add(btnDispose); + + Choice cbox = new Choice(); + cbox.add("Test1"); + cbox.add("Test2"); + cbox.add("Test3"); + cbox.add("Test4"); + cbox.add("Test5"); + cbox.add("Test6"); + cbox.add("Test7"); + cbox.add("Test8"); + cbox.add("Test9"); + cbox.add("Test10"); + cbox.add("Test11"); + panelSouth.add(cbox); + + validate(); + + add("Center", panelNorth); + add("South", panelSouth); + + btnNested.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + Dialog dlg = new SimpleDialog((Frame) getParent(), SimpleDialog.this, true); + System.out.println("Returned from showing dialog: " + dlg); + } + }); + + btnFileDlg.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + FileDialog dlg = new FileDialog((Frame) getParent()); + dlg.show(); + } + }); + + btnHide.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + Window wnd = getSelectedWindow(); + System.out.println(wnd); + wnd.hide(); + } + }); + + btnShow.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + getSelectedWindow().show(); + } + }); + + btnDispose.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + getSelectedWindow().dispose(); + populateListWin(); + } + }); + + pack(); + setSize(getSize().width, getSize().height * 2); + if (dlgPrev != null) { + Point pt = dlgPrev.getLocation(); + setLocation(pt.x + 30, pt.y + 50); + } + show(); + } + + private Window getSelectedWindow() { + Window window; + int index = listWins.getSelectedIndex(); + + window = NestedDialogTest.getWindow(index); + return window; + } + + private void populateListWin() { + Enumeration enumWindows = NestedDialogTest.enumWindows(); + + listWins.removeAll(); + while (enumWindows.hasMoreElements()) { + Window win = (Window) enumWindows.nextElement(); + listWins.add(win.getName()); + } + listWins.select(NestedDialogTest.getWindowIndex(this)); + } + + public void show() { + if (!isVisible()) { + NestedDialogTest.addWindow(this); + } + super.show(); + } + + public void dispose() { + NestedDialogTest.removeWindow(this); + super.dispose(); + } +} diff --git a/test/jdk/java/awt/Dialog/ShownModalDialogSerializationTest.java b/test/jdk/java/awt/Dialog/ShownModalDialogSerializationTest.java new file mode 100644 index 00000000000..b57dd2cf8f2 --- /dev/null +++ b/test/jdk/java/awt/Dialog/ShownModalDialogSerializationTest.java @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Dialog; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.Label; + +import java.awt.TextArea; +import java.io.File; +import java.io.FileOutputStream; +import java.io.ObjectOutputStream; + +/* + * @test + * @bug 4739757 + * @summary REGRESSION: Modal Dialog is not serializable after showing + * @key headful + * @run main ShownModalDialogSerializationTest + */ + +public class ShownModalDialogSerializationTest { + static volatile Frame frame; + static volatile Frame outputFrame; + static volatile Dialog dialog; + + public static void main(String[] args) throws Exception { + + EventQueue.invokeLater(ShownModalDialogSerializationTest::createTestUI); + + while (dialog == null || !dialog.isShowing()) { + Thread.sleep(500); + } + File file = new File("dialog.ser"); + FileOutputStream fos = new FileOutputStream(file); + ObjectOutputStream oos = new ObjectOutputStream(fos); + oos.writeObject(dialog); + oos.flush(); + file.delete(); + + EventQueue.invokeAndWait(ShownModalDialogSerializationTest::deleteTestUI); + } + + static void deleteTestUI() { + if (dialog != null) { + dialog.setVisible(false); + dialog.dispose(); + } + if (frame != null) { + frame.setVisible(false); + frame.dispose(); + } + if (outputFrame != null) { + outputFrame.setVisible(false); + outputFrame.dispose(); + } + } + + private static void createTestUI() { + outputFrame = new Frame("ShownModalDialogSerializationTest"); + TextArea output = new TextArea(40, 50); + outputFrame.add(output); + + frame = new Frame("invisible dialog owner"); + dialog = new Dialog(frame, "Dialog for Close", true); + dialog.add(new Label("Close This Dialog")); + outputFrame.setSize(200, 200); + outputFrame.setVisible(true); + dialog.pack(); + dialog.setVisible(true); + } +} diff --git a/test/jdk/java/awt/EventQueue/PushPopDeadlock/PushPopDeadlock.java b/test/jdk/java/awt/EventQueue/PushPopDeadlock/PushPopDeadlock.java new file mode 100644 index 00000000000..82ca5487184 --- /dev/null +++ b/test/jdk/java/awt/EventQueue/PushPopDeadlock/PushPopDeadlock.java @@ -0,0 +1,97 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4212687 + * @summary Verifies that calling EventQueue.push() and EventQueue.pop() + * does not deadlock. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual PushPopDeadlock + */ + +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.Label; +import java.awt.Robot; +import java.awt.Toolkit; + +public class PushPopDeadlock { + static int counter = 0; + static Robot robot; + static Frame f; + static Label l; + + public static void main(String[] args) throws Exception { + robot = new Robot(); + String INSTRUCTIONS = """ + Click rapidly in the Frame labeled 'Click Here!'. + The number in the Frame should continue to increase. If the number + stops increasing (remains at a constant value), the test fails. + """; + + PassFailJFrame pfJFrame = PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(35) + .testUI(PushPopDeadlock::createUI) + .build(); + PushPopDeadlock.test(); + pfJFrame.awaitAndCheck(); + } + + public static Frame createUI() { + f = new Frame("Click Here!"); + l = new Label("Counter: " + counter); + f.add(l); + f.setSize(200, 200); + return f; + } + + public static void test() { + EventQueue q = new EventQueue() { + public void push(EventQueue queue) { + super.push(queue); + pop(); + } + }; + EventQueue q2 = new EventQueue(); + + Toolkit.getDefaultToolkit().getSystemEventQueue().push(q); + + new Thread(() -> { + while (true) { + robot.delay(500); + l.setText("Counter: " + ++counter); + q.push(q2); + try { + Thread.currentThread().sleep(500); + } catch (InterruptedException e) { + return; + } + } + }).start(); + } +} diff --git a/test/jdk/java/awt/FileDialog/DoubleActionCloseX.java b/test/jdk/java/awt/FileDialog/DoubleActionCloseX.java new file mode 100644 index 00000000000..5d3feaa42ed --- /dev/null +++ b/test/jdk/java/awt/FileDialog/DoubleActionCloseX.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Button; +import java.awt.FileDialog; +import java.awt.Frame; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +/* + * @test + * @bug 6227750 + * @summary Tests that FileDialog can be closed by clicking the 'close' (X) button + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual DoubleActionCloseX + */ + +public class DoubleActionCloseX { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + NOTE: On Linux and Mac, there is no 'close'(X) button + when file dialog is visible, press Pass. + + Click the 'Open File Dialog' button to open FileDialog. + A file dialog will appear on the screen. + Click on the 'close'(X) button. + The dialog should be closed. + If not, the test failed, press Fail otherwise press Pass. + """; + + PassFailJFrame.builder() + .title("DoubleActionCloseX Instruction") + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(DoubleActionCloseX::createUI) + .build() + .awaitAndCheck(); + } + public static Frame createUI() { + Frame f = new Frame("DoubleActionCloseX Test"); + Button b = new Button("Open File Dialog"); + FileDialog fd = new FileDialog(f); + b.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + fd.setVisible(true); + } + }); + f.add(b); + f.setSize(300, 200); + return f; + } +} diff --git a/test/jdk/java/awt/FileDialog/DoubleActionESC.java b/test/jdk/java/awt/FileDialog/DoubleActionESC.java new file mode 100644 index 00000000000..748c3aeb5e4 --- /dev/null +++ b/test/jdk/java/awt/FileDialog/DoubleActionESC.java @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Button; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.FileDialog; +import java.awt.Frame; +import java.awt.Point; +import java.awt.Robot; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.InputEvent; +import java.awt.event.KeyEvent; +import java.util.concurrent.CountDownLatch; + +/* + * @test + * @bug 5097243 + * @summary Tests that FileDialog can be closed by ESC any time + * @key headful + * @run main DoubleActionESC + */ + +public class DoubleActionESC { + private static Frame f; + private static Button showBtn; + private static FileDialog fd; + private static Robot robot; + private static volatile Point p; + private static volatile Dimension d; + private static volatile CountDownLatch latch; + private static final int REPEAT_COUNT = 2; + + public static void main(String[] args) throws Exception { + latch = new CountDownLatch(1); + + robot = new Robot(); + robot.setAutoDelay(100); + try { + EventQueue.invokeAndWait(() -> { + createAndShowUI(); + }); + + robot.delay(1000); + EventQueue.invokeAndWait(() -> { + p = showBtn.getLocationOnScreen(); + d = showBtn.getSize(); + }); + + for (int i = 0; i < REPEAT_COUNT; ++i) { + Thread thread = new Thread(() -> { + robot.mouseMove(p.x + d.width / 2, p.y + d.height / 2); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + }); + thread.start(); + robot.delay(3000); + + Thread thread1 = new Thread(() -> { + robot.keyPress(KeyEvent.VK_ESCAPE); + robot.keyRelease(KeyEvent.VK_ESCAPE); + robot.waitForIdle(); + }); + thread1.start(); + robot.delay(3000); + } + + latch.await(); + if (fd.isVisible()) { + throw new RuntimeException("File Dialog is not closed"); + } + } finally { + EventQueue.invokeAndWait(() -> { + if (f != null) { + f.dispose(); + } + }); + } + } + + public static void createAndShowUI() { + f = new Frame("DoubleActionESC Test"); + showBtn = new Button("Show File Dialog"); + fd = new FileDialog(f); + showBtn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if (e.getSource() == showBtn) { + fd.setSize(200, 200); + fd.setLocation(200, 200); + fd.setVisible(true); + latch.countDown(); + } + } + }); + f.add(showBtn); + f.setSize(300, 200); + f.setLocationRelativeTo(null); + f.setVisible(true); + } +} diff --git a/test/jdk/java/awt/FileDialog/KeyboardInteractionTest.java b/test/jdk/java/awt/FileDialog/KeyboardInteractionTest.java new file mode 100644 index 00000000000..f919a8a338a --- /dev/null +++ b/test/jdk/java/awt/FileDialog/KeyboardInteractionTest.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Button; +import java.awt.FileDialog; +import java.awt.Frame; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +/* + * @test + * @bug 6259434 + * @summary PIT: Choice in FileDialog is not responding to keyboard interactions, XToolkit + * @requires (os.family == "linux") + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual KeyboardInteractionTest + */ + +public class KeyboardInteractionTest { + public static void main(String[] args) throws Exception { + System.setProperty("sun.awt.disableGtkFileDialogs", "true"); + String INSTRUCTIONS = """ + 1) Click on 'Show File Dialog' button to bring up the FileDialog window. + A file dialog will come up. + 2) You will see a text field 'Enter full path or filename'. + Right next to it, you will see a button. + Transfer the focus on this button using 'TAB'. + Make sure that the popup choice is not shown. + 3) Press 'ESC'. If file dialog isn't disposed, then the test failed. + 4) Again, click on 'Show File Dialog' to bring up the file dialog. + A file dialog will come up. + 5) You will see a text field 'Enter full path or filename'. + Right next to it, you will see a button. + Click on this button. The popup choice will appear. + 6) Look at the popup choice. Change the current item in the popup + choice by the arrow keys. + If the text in the 'Enter full path or filename' text field isn't + changed, then the test failed. + 7) The test passed. + """; + + PassFailJFrame.builder() + .title("KeyboardInteractionTest Instruction") + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(KeyboardInteractionTest::createUI) + .build() + .awaitAndCheck(); + } + + public static Frame createUI() { + Frame f = new Frame("KeyboardInteractionTest Test"); + Button b = new Button("Show File Dialog"); + FileDialog fd = new FileDialog(f); + b.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + fd.setVisible(true); + } + }); + f.add(b); + f.setSize(300, 200); + return f; + } +} diff --git a/test/jdk/java/awt/FileDialog/PathChoiceDisposeTest.java b/test/jdk/java/awt/FileDialog/PathChoiceDisposeTest.java new file mode 100644 index 00000000000..267b2a807cf --- /dev/null +++ b/test/jdk/java/awt/FileDialog/PathChoiceDisposeTest.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Button; +import java.awt.FileDialog; +import java.awt.Frame; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +/* + * @test + * @bug 6240084 + * @summary Test that disposing unfurled list by the pressing ESC + * in FileDialog is working properly on XToolkit + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual PathChoiceDisposeTest + */ + +public class PathChoiceDisposeTest { + public static void main(String[] args) throws Exception { + System.setProperty("sun.awt.disableGtkFileDialogs", "true"); + String INSTRUCTIONS = """ + 1) Click on 'Show File Dialog' button to bring up the FileDialog window. + 2) Open the directory selection choice by clicking button next to + 'Enter Path or Folder Name'. A drop-down will appear. + 3) Press 'ESC'. + 4) If you see that the dialog gets disposed and the popup + still remains on the screen, the test failed, otherwise passed. + """; + + PassFailJFrame.builder() + .title("PathChoiceDisposeTest Instruction") + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(PathChoiceDisposeTest::createUI) + .build() + .awaitAndCheck(); + } + + public static Frame createUI() { + Frame f = new Frame("PathChoiceDisposeTest Test"); + Button b = new Button("Show File Dialog"); + FileDialog fd = new FileDialog(f); + b.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + fd.setVisible(true); + } + }); + f.add(b); + f.setSize(300, 200); + return f; + } +} diff --git a/test/jdk/java/awt/FileDialog/PathChoiceWorkArrowsTest.java b/test/jdk/java/awt/FileDialog/PathChoiceWorkArrowsTest.java new file mode 100644 index 00000000000..17aee8abb80 --- /dev/null +++ b/test/jdk/java/awt/FileDialog/PathChoiceWorkArrowsTest.java @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Button; +import java.awt.FileDialog; +import java.awt.Frame; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +/* + * @test + * @bug 6240074 + * @summary Test that file drop-down field in FileDialog is working properly on XToolkit + * @requires (os.family == "linux") + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual PathChoiceWorkArrowsTest + */ + +public class PathChoiceWorkArrowsTest { + public static void main(String[] args) throws Exception { + System.setProperty("sun.awt.disableGtkFileDialogs", "true"); + String INSTRUCTIONS = """ + This is only XAWT test. + + 1) Click on 'Show File Dialog' to bring up the FileDialog window. + A file dialog would come up. + 2) Click on the button next to 'Enter folder name' field. + A drop-down will appear. After this, there are 2 scenarios. + 3) Press the down arrow one by one. You will see a '/' being + appended as soon as the current entry is removed. + Keep pressing till the last entry is reached. Now the drop-down + will stop responding to arrow keys. If yes, the test failed. + 4) Press the up arrow. The cursor will directly go to the last + entry ('/') and navigation will stop there. You will see 2 + entries being selected at the same time. + If yes, the test failed. + """; + + PassFailJFrame.builder() + .title("PathChoiceWorkArrowsTest Instruction") + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(PathChoiceWorkArrowsTest::createUI) + .build() + .awaitAndCheck(); + } + + public static Frame createUI() { + Frame f = new Frame("PathChoiceWorkArrowsTest Test"); + Button b = new Button("Show File Dialog"); + FileDialog fd = new FileDialog(f); + b.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + fd.setSize(200, 200); + fd.setLocation(200, 200); + fd.setVisible(true); + } + }); + f.add(b); + f.setSize(300, 200); + return f; + } +} diff --git a/test/jdk/java/awt/FileDialog/SavedDirInitTest.java b/test/jdk/java/awt/FileDialog/SavedDirInitTest.java new file mode 100644 index 00000000000..7a3b33f55fe --- /dev/null +++ b/test/jdk/java/awt/FileDialog/SavedDirInitTest.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Button; +import java.awt.FileDialog; +import java.awt.Frame; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +/* + * @test + * @bug 6260650 + * @summary FileDialog.getDirectory() does not return null when file dialog is cancelled + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual SavedDirInitTest + */ + +public class SavedDirInitTest { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + Click on 'Show File Dialog' button to bring up the FileDialog window. + 1) A file dialog will come up. + 2) Press 'Cancel' button to cancel the file dialog. + 3) The result (passed or failed) will be shown in the message window below. + """; + + PassFailJFrame.builder() + .title("SavedDirInitTest Instruction") + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(SavedDirInitTest::createUI) + .logArea(2) + .build() + .awaitAndCheck(); + } + + public static Frame createUI() { + Frame f = new Frame("SavedDirInitTest Test"); + Button b = new Button("Show File Dialog"); + FileDialog fd = new FileDialog(f); + b.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + fd.setVisible(true); + if (fd.getDirectory() == null && fd.getFile() == null) { + PassFailJFrame.log("TEST PASSED"); + } else { + PassFailJFrame.log("TEST FAILED. dir = " + fd.getDirectory() + + " , file = " + fd.getFile()); + } + } + }); + f.add(b); + f.setSize(300, 200); + return f; + } +} diff --git a/test/jdk/java/awt/FileDialog/TestFileDialogDupJNIRef.java b/test/jdk/java/awt/FileDialog/TestFileDialogDupJNIRef.java new file mode 100644 index 00000000000..56b6c492144 --- /dev/null +++ b/test/jdk/java/awt/FileDialog/TestFileDialogDupJNIRef.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 java.awt.Button; +import java.awt.Dialog; +import java.awt.FileDialog; +import java.awt.FlowLayout; +import java.awt.Frame; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +/* + * @test + * @bug 4906972 + * @summary Tests using of JNI reference to peer object. + * @requires (os.family == "windows") + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual TestFileDialogDupJNIRef + */ + +public class TestFileDialogDupJNIRef { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + This is a crash test. + After test started you will see 'Test Frame' with one button. + 1. Click the button to open FileDialog. + 2. Go to the dialog and choose any directory with some files in it.. + 3. Click on any file to highlight it. + 4. Click on the file again to rename. + 5. Leave the file in edit mode and click Open button + + If there was no crash the test passed, Press Pass. + """; + + PassFailJFrame.builder() + .title("TestFileDialogDupJNIRef Instruction") + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(TestFileDialogDupJNIRef::createUI) + .build() + .awaitAndCheck(); + } + + public static Frame createUI() { + Frame frame = new Frame("TestFileDialogDupJNIRef Test Frame"); + Button open = new Button("Open File Dialog"); + + open.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + FileDialog fd = new FileDialog(frame); + fd.setVisible(true); + } + }); + + frame.setLayout(new FlowLayout()); + frame.add(open); + frame.setSize(250, 70); + return frame; + } +} diff --git a/test/jdk/java/awt/Focus/ActivateFocusTest.java b/test/jdk/java/awt/Focus/ActivateFocusTest.java new file mode 100644 index 00000000000..09f5bbb172c --- /dev/null +++ b/test/jdk/java/awt/Focus/ActivateFocusTest.java @@ -0,0 +1,148 @@ +/* + * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 4369903 + * @summary Focus on window activation does not work correctly + * @key headful + * @run main ActivateFocusTest + */ + +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Toolkit; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; + +public class ActivateFocusTest { + + public static void main(final String[] args) { + ActivateFocusTest app = new ActivateFocusTest(); + app.doTest(); + } + + public void doTest() { + ActivateFocus[] af = new ActivateFocus[2]; + boolean testFailed = false; + Dimension scrSize = Toolkit.getDefaultToolkit().getScreenSize(); + for (int i = 0; i < 2; i++) { + af[i] = new ActivateFocus(i); + af[i].setLocation(i * 160 + scrSize.width / 2, scrSize.height / 2); + af[i].setVisible(true); + } + try { + Thread.sleep(5000); + } catch (InterruptedException ie) { + throw new RuntimeException("TEST FAILED - thread was interrupted"); + } + for (int i = 0; i < 2; i++) { + testFailed = (af[i].lw.focusCounter > 1); + } + if (testFailed) { + throw new RuntimeException("TEST FAILED - focus is gained more than one time"); + } else { + System.out.println("TEST PASSED"); + } + } + + } + +class ActivateFocus extends Frame { + + public LightWeight lw = null; + int num; + + public String toString() { + return ("Window " + num); + } + + public ActivateFocus(int i) { + setTitle("Window " + i); + lw = new LightWeight(i); + num=i; + addWindowListener(new WindowAdapter() { + public void windowActivated(WindowEvent e) { + if(lw != null) { + lw.requestFocus(); + } + } + }); + add(lw); + pack(); + } + + // A very simple lightweight component + class LightWeight extends Component implements FocusListener { + + boolean focused = false; + int num; + public int focusCounter = 0; + + public LightWeight(int num) { + this.num = num; + addFocusListener(this); + } + + public void paint(Graphics g) { + Dimension size = getSize(); + int w = size.width; + int h = size.height; + g.setColor(getBackground()); + g.fillRect(0, 0, w, h); + g.setColor(Color.black); + g.drawOval(0, 0, w-1, h-1); + if (focused) { + g.drawLine(w/2, 0, w/2, h); + g.drawLine(0, h/2, w, h/2); + } + + } + + public Dimension getPreferredSize() { + return new Dimension(150, 150); + } + + public void focusGained(FocusEvent e) { + focused = true; + focusCounter++; + System.out.println("focusGained on " + e.getComponent()); + repaint(); + } + + public void focusLost(FocusEvent e) { + focused = false; + System.out.println("focusLost on " + e.getComponent()); + repaint(); + } + + public String toString() { + return ("Component " + num); + } + } +} diff --git a/test/jdk/java/awt/Focus/ActivateOnProperAppContextTest.java b/test/jdk/java/awt/Focus/ActivateOnProperAppContextTest.java new file mode 100644 index 00000000000..ab083983321 --- /dev/null +++ b/test/jdk/java/awt/Focus/ActivateOnProperAppContextTest.java @@ -0,0 +1,245 @@ +/* + * Copyright (c) 2006, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +/* +* @test +* @bug 6385277 +* @key headful +* @summary Tests that activation happens on correct AppContext. +* @modules java.desktop/sun.awt +* @run main ActivateOnProperAppContextTest +*/ + +import sun.awt.AppContext; +import sun.awt.SunToolkit; + +import java.awt.Button; +import java.awt.Component; +import java.awt.Container; +import java.awt.Cursor; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.Label; +import java.awt.Point; +import java.awt.Robot; +import java.awt.Toolkit; +import java.awt.Window; +import java.awt.event.InputEvent; +import java.util.concurrent.atomic.AtomicBoolean; + +public class ActivateOnProperAppContextTest { + static Robot robot; + SunToolkit toolkit; + + ThreadGroup threadGroup = new ThreadGroup("Test_Thread_Group"); + AppContext appContext; + Frame frame; + volatile boolean passed = true; + AtomicBoolean cond = new AtomicBoolean(false); + + public static void main(String[] args) throws Exception { + ActivateOnProperAppContextTest app = new ActivateOnProperAppContextTest(); + robot = new Robot(); + app.start(); + } + + public void start() { + toolkit = (SunToolkit)Toolkit.getDefaultToolkit(); + + Runnable runnable = new Runnable() { + public void run() { + test(); + + synchronized (cond) { + cond.set(true); + cond.notifyAll(); + } + } + }; + + Thread thread = new Thread(threadGroup, runnable, "Test Thread"); + + synchronized (cond) { + + thread.start(); + + while (!cond.get()) { + try { + cond.wait(); + } catch (InterruptedException ie) { + ie.printStackTrace(); + } + } + } + + if (passed) { + System.out.println("Test passed."); + } else { + throw new TestFailedException("Test failed!"); + } + } + + void test() { + appContext = SunToolkit.createNewAppContext(); + System.out.println("Created new AppContext: " + appContext); + + frame = new Frame("ActivateOnProperAppContextTest Frame") { + public boolean isActive() { + verifyAppContext("Frame.isActive()"); + return super.isActive(); + } + public boolean isFocused() { + verifyAppContext("Frame.isFocused()"); + return super.isFocused(); + } + public boolean isFocusable() { + verifyAppContext("Frame.isFocusable()"); + return super.isFocusable(); + } + public Window getOwner() { + verifyAppContext("Frame.getOwner()"); + return super.getOwner(); + } + public boolean isEnabled() { + verifyAppContext("Frame.isEnabled()"); + return super.isEnabled(); + } + public boolean isVisible() { + verifyAppContext("Frame.isVisible()"); + return super.isVisible(); + } + public Container getParent() { + verifyAppContext("Frame.getParent()"); + return super.getParent(); + } + public Cursor getCursor() { + verifyAppContext("Frame.getCursor()"); + return super.getCursor(); + } + public Point getLocation() { + verifyAppContext("Frame.getLocation()"); + return super.getLocation(); + } + public Point getLocationOnScreen() { + verifyAppContext("Frame.getLocationOnScreen()"); + return super.getLocationOnScreen(); + } + }; + Window window = new Window(frame) { + public boolean isFocused() { + verifyAppContext("Window.isFocused()"); + return super.isFocused(); + } + public boolean isFocusable() { + verifyAppContext("Window.isFocusable()"); + return super.isFocusable(); + } + public Window getOwner() { + verifyAppContext("Window.getOwner()"); + return super.getOwner(); + } + public boolean isEnabled() { + verifyAppContext("Window.isEnabled()"); + return super.isEnabled(); + } + public boolean isVisible() { + verifyAppContext("Window.isVisible()"); + return super.isVisible(); + } + public Container getParent() { + verifyAppContext("Window.getParent()"); + return super.getParent(); + } + public Cursor getCursor() { + verifyAppContext("Window.getCursor()"); + return super.getCursor(); + } + public Point getLocation() { + verifyAppContext("Window.getLocation()"); + return super.getLocation(); + } + public Point getLocationOnScreen() { + verifyAppContext("Window.getLocationOnScreen()"); + return super.getLocationOnScreen(); + } + }; + Button button = new Button("button"); + Label label = new Label("label"); + + window.setLayout(new FlowLayout()); + window.add(button); + window.add(label); + window.setLocation(800, 0); + window.pack(); + window.setVisible(true); + + frame.setBounds(800, 100, 100, 50); + frame.setVisible(true); + + toolkit.realSync(); + + /* + * When the label is clicked in the window some of + * the owner's public method get called. + */ + clickOn(label); + } + + void verifyAppContext(String methodName) { + AppContext ac = AppContext.getAppContext(); + println(methodName + " called on AppContext: " + ac); + + if (ac != appContext) { + passed = false; + System.err.println("Test failed: " + methodName + " is called on wrong AppContext!"); + Thread.dumpStack(); + } + } + + void clickOn(Component c) { + Point p = c.getLocationOnScreen(); + Dimension d = c.getSize(); + + robot.mouseMove(p.x + (int)(d.getWidth()/2), p.y + (int)(d.getHeight()/2)); + + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.delay(20); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + + toolkit.realSync(); + } + + void println(final String msg) { + SunToolkit.executeOnEventHandlerThread(frame, new Runnable() { + public void run() { + System.out.println(msg); + } + }); + } +} + +class TestFailedException extends RuntimeException { + TestFailedException(String msg) { + super(msg); + } +} diff --git a/test/jdk/java/awt/Focus/AltTabEventsTest.java b/test/jdk/java/awt/Focus/AltTabEventsTest.java new file mode 100644 index 00000000000..15d679ce729 --- /dev/null +++ b/test/jdk/java/awt/Focus/AltTabEventsTest.java @@ -0,0 +1,151 @@ +/* + * Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4524015 + * @summary Tests that when user switches between windows using Alt-tab then the appropriate events are generated + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual AltTabEventsTest + */ + +import java.awt.Button; +import java.awt.Choice; +import java.awt.Component; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.Menu; +import java.awt.MenuBar; +import java.awt.MenuItem; +import java.awt.PopupMenu; +import java.awt.event.ActionListener; +import java.awt.event.ActionEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; + +public class AltTabEventsTest { + + private static final String INSTRUCTIONS = """ + This test verifies that when user switches between windows using Alt-tab + key combination then appropriate window events are generated. Also, when + user interacts with Menu bar, Popup menu, Choice then no excessive window + event is generated. + + After test started you will see Frame('Test for 4524015')-F1 with some + components and Frame('Another frame')-F2 with no components. + 1. Make F1 active by clicking on it. + 2. Press Alt-tab. + In the messqge dialog area you should see that + WINDOW_DEACTIVATED, WINDOW_LOST_FOCUS event were generated. + If you switched to F2 then also WINDOW_ACTIVATED, WINDOW_GAINED_FOCUS + were generated. + If no events were generated the test FAILED. + Repeat the 2) with different circumstances. + + 3. Make F1 active by clicking on it. + 4. Click on Menu bar/Button 'popup'/Choice and select some item from + the list shown. If any of the window events appeared in the output then + the test FAILED. + + else the test PASSED."""; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("AltTabEventsTest Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 5) + .columns(35) + .testUI(Test::new) + .logArea() + .build() + .awaitAndCheck(); + } + +} + + +class Test extends Frame { + PopupMenu pop; + Frame f; + + void println(String messageIn) { + PassFailJFrame.log(messageIn); + } + + public Test() { + super("Test for 4524015"); + WindowAdapter wa = new WindowAdapter() { + public void windowActivated(WindowEvent e) { + println(e.toString()); + } + public void windowDeactivated(WindowEvent e) { + println(e.toString()); + } + public void windowGainedFocus(WindowEvent e) { + println(e.toString()); + } + public void windowLostFocus(WindowEvent e) { + println(e.toString()); + } + }; + addWindowListener(wa); + addWindowFocusListener(wa); + + f = new Frame("Another frame"); + f.addWindowListener(wa); + f.addWindowFocusListener(wa); + f.setBounds(800, 300, 300, 100); + f.setVisible(true); + + setLayout(new FlowLayout()); + Button b = new Button("popup"); + add(b); + b.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + pop.show((Component)e.getSource(), 10, 10); + } + }); + Choice cho = new Choice(); + add(cho); + cho.addItem("1"); + cho.addItem("2"); + cho.addItem("3"); + + MenuBar bar = new MenuBar(); + Menu menu = new Menu("menu"); + MenuItem item = new MenuItem("first"); + menu.add(item); + item = new MenuItem("second"); + menu.add(item); + bar.add(menu); + setMenuBar(bar); + + pop = new PopupMenu(); + pop.add("1"); + pop.add("@"); + add(pop); + setSize(300, 100); + } +} + diff --git a/test/jdk/java/awt/Focus/CanvasPanelFocusOnClickTest.java b/test/jdk/java/awt/Focus/CanvasPanelFocusOnClickTest.java new file mode 100644 index 00000000000..8df21ba0f0a --- /dev/null +++ b/test/jdk/java/awt/Focus/CanvasPanelFocusOnClickTest.java @@ -0,0 +1,212 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4041703 4096228 4032657 4066152 4149866 4025223 + * @summary Ensures that an Panel/Canvas without heavyweight children + receives focus on mouse click + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual CanvasPanelFocusOnClickTest + */ + +import java.awt.Button; +import java.awt.Canvas; +import java.awt.Color; +import java.awt.Component; +import java.awt.Frame; +import java.awt.GridLayout; +import java.awt.Panel; +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; + +public class CanvasPanelFocusOnClickTest { + + private static final String INSTRUCTIONS = """ + + Click on the red Canvas. Verify that it has focus by key pressing. + Click on the yellow Panel. Verify that it has focus by key pressing. + Click on the blue heavyweight Panel (NOT ON THE BUTTON!). + Verify that it doesn't have focus by key pressing. + If two empty containers are able to the get focus by a mouse click + and the container with heavyweight children are unable to get + the focus by a mouse click which can be verified through messages in message dialog + the test passes."""; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("CanvasPanelFocusOnClickTest Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(40) + .testUI(CanvasPanelFocusOnClickTest::createTestUI) + .logArea() + .build() + .awaitAndCheck(); + } + + private static Frame createTestUI() { + Canvas canvas = new Canvas();; + Panel emptyPanel = new Panel(); + Panel panel = new Panel(); + Button buttonInPanel = new Button("BUTTON ON PANEL"); + + Frame frame = new Frame("CanvasPanelFocusOnClickTest Frame"); + frame.setLayout(new GridLayout(3, 1)); + canvas.setBackground(Color.red); + canvas.setName("RED CANVAS"); + canvas.addFocusListener(new FocusAdapter() { + public void focusGained(FocusEvent e) { + println(e.toString()); + } + public void focusLost(FocusEvent e) { + println(e.toString()); + } + }); + canvas.addKeyListener(new KeyAdapter() { + public void keyPressed(KeyEvent e) { + printKey(e); + } + + public void keyTyped(KeyEvent e) { + printKey(e); + } + + public void keyReleased(KeyEvent e) { + printKey(e); + } + }); + frame.add(canvas); + + emptyPanel.setBackground(Color.yellow); + emptyPanel.setName("YELLOW PANEL"); + emptyPanel.addFocusListener(new FocusAdapter() { + public void focusGained(FocusEvent e) { + println(e.toString()); + } + public void focusLost(FocusEvent e) { + println(e.toString()); + } + }); + emptyPanel.addKeyListener(new KeyAdapter() { + public void keyPressed(KeyEvent e) { + printKey(e); + } + + public void keyTyped(KeyEvent e) { + printKey(e); + } + + public void keyReleased(KeyEvent e) { + printKey(e); + } + }); + frame.add(emptyPanel); + + panel.setBackground(Color.blue); + panel.setName("BLUE PANEL"); + buttonInPanel.setName("BUTTON ON PANEL"); + buttonInPanel.addFocusListener(new FocusAdapter() { + public void focusGained(FocusEvent e) { + println(e.toString()); + } + public void focusLost(FocusEvent e) { + println(e.toString()); + } + }); + buttonInPanel.addKeyListener(new KeyAdapter() { + public void keyPressed(KeyEvent e) { + printKey(e); + } + + public void keyTyped(KeyEvent e) { + printKey(e); + } + + public void keyReleased(KeyEvent e) { + printKey(e); + } + }); + panel.add(buttonInPanel); + panel.addFocusListener(new FocusAdapter() { + public void focusGained(FocusEvent e) { + println(e.toString()); + } + public void focusLost(FocusEvent e) { + println(e.toString()); + } + }); + panel.addKeyListener(new KeyAdapter() { + public void keyPressed(KeyEvent e) { + printKey(e); + } + + public void keyTyped(KeyEvent e) { + printKey(e); + } + + public void keyReleased(KeyEvent e) { + printKey(e); + } + }); + frame.add(panel); + + frame.setSize(200, 200); + + return frame; + + } + + static void printKey(KeyEvent e) { + String typeStr; + switch(e.getID()) { + case KeyEvent.KEY_PRESSED: + typeStr = "KEY_PRESSED"; + break; + case KeyEvent.KEY_RELEASED: + typeStr = "KEY_RELEASED"; + break; + case KeyEvent.KEY_TYPED: + typeStr = "KEY_TYPED"; + break; + default: + typeStr = "unknown type"; + } + + Object source = e.getSource(); + if (source instanceof Component) { + typeStr += " on " + ((Component)source).getName(); + } else { + typeStr += " on " + source; + } + + println(typeStr); + } + + static void println(String messageIn) { + PassFailJFrame.log(messageIn); + } +} diff --git a/test/jdk/java/awt/Focus/ComponentLostFocusTest.java b/test/jdk/java/awt/Focus/ComponentLostFocusTest.java new file mode 100644 index 00000000000..6af8322b2cd --- /dev/null +++ b/test/jdk/java/awt/Focus/ComponentLostFocusTest.java @@ -0,0 +1,154 @@ +/* + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4982943 + * @key headful + * @summary focus lost in text fields or text areas, unable to enter characters from keyboard + * @run main ComponentLostFocusTest + */ + +import java.awt.Dialog; +import java.awt.EventQueue; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.KeyboardFocusManager; +import java.awt.Point; +import java.awt.Robot; +import java.awt.TextField; +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; +import java.awt.event.InputEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; + +public class ComponentLostFocusTest { + + static Frame frame; + static TextField tf; + static Robot r; + static Dialog dialog = null; + static volatile boolean passed; + static volatile Point loc; + static volatile int width; + static volatile int top; + + private static void createTestUI() { + + dialog = new Dialog(frame, "Dialog", true); + + frame = new Frame("ComponentLostFocusTest Frame"); + frame.setLayout(new FlowLayout()); + frame.addWindowFocusListener(new WindowAdapter() { + public void windowGainedFocus(WindowEvent e) { + System.out.println("Frame gained focus: "+e); + } + }); + tf = new TextField("Text Field"); + frame.add(tf); + frame.setSize(400,300); + frame.setVisible(true); + frame.setLocationRelativeTo(null); + frame.validate(); + } + + public static void doTest() { + System.out.println("dialog.setVisible.... "); + new Thread(new Runnable() { + public void run() { + dialog.setVisible(true); + } + }).start(); + + // The bug is that this construction leads to the redundant xRequestFocus + // By the way, the requestFocusInWindow() works fine before the fix + System.out.println("requesting.... "); + frame.requestFocus(); + + r.delay(1000); + + // Returning the focus to the initial frame will work correctly after the fix + System.out.println("disposing.... "); + dialog.dispose(); + + r.delay(1000); + + // We want to track the GAIN_FOCUS from this time + tf.addFocusListener(new FocusAdapter() { + public void focusGained(FocusEvent e) { + System.out.println("TextField gained focus: " + e); + passed = true; + } + }); + + } + + private static void doRequestFocusToTextField() { + // do activation using press title + r.mouseMove(loc.x + width / 2, loc.y + top / 2); + r.waitForIdle(); + r.mousePress(InputEvent.BUTTON1_DOWN_MASK); + r.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + r.waitForIdle(); + + // request focus to the text field + tf.requestFocus(); + } + + public static final void main(String args[]) throws Exception { + r = new Robot(); + r.setAutoDelay(100); + + EventQueue.invokeAndWait(() -> createTestUI()); + r.waitForIdle(); + r.delay(1000); + try { + EventQueue.invokeAndWait(() -> { + doTest(); + loc = frame.getLocationOnScreen(); + width = frame.getWidth(); + top = frame.getInsets().top; + }); + doRequestFocusToTextField(); + + System.out.println("Focused window: " + + KeyboardFocusManager.getCurrentKeyboardFocusManager(). + getFocusedWindow()); + System.out.println("Focus owner: " + + KeyboardFocusManager.getCurrentKeyboardFocusManager(). + getFocusOwner()); + + if (!passed) { + throw new RuntimeException("TextField got no focus! Test failed."); + } + } finally { + EventQueue.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } +} + diff --git a/test/jdk/java/awt/Focus/ConsumedKeyEventTest.java b/test/jdk/java/awt/Focus/ConsumedKeyEventTest.java new file mode 100644 index 00000000000..dda82adeec5 --- /dev/null +++ b/test/jdk/java/awt/Focus/ConsumedKeyEventTest.java @@ -0,0 +1,197 @@ +/* + * Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4700276 + * @summary Peers process KeyEvents before KeyEventPostProcessors + * @requires (os.family == "windows") + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual ConsumedKeyEventTest +*/ + +import java.awt.Canvas; +import java.awt.Component; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.KeyboardFocusManager; +import java.awt.KeyEventPostProcessor; +import java.awt.event.KeyEvent; +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +public class ConsumedKeyEventTest implements KeyEventPostProcessor { + + private static final String INSTRUCTIONS = """ + This is a Windows-only test. + When the test starts, you will see a Frame with two components in it, + components look like colored rectangles, one of them is lightweight, one is heavyweight. + Do the following: + 1. Click the mouse on the left component. + If it isn't yellow after the click (that means it doesn't have focus), the test fails. + 2. Press and release ALT key. + In the output window, the text should appear stating that those key events were consumed. + If no output appears, the test fails. + 3. Press space bar. If system menu drops down, the test fails. + 4. Click the right rectangle. + It should become red after the click. If it doesn't, it means that it didn't get the focus, and the test fails. + 5. Repeat steps 2. and 3. + 6. If the test didn't fail on any of the previous steps, the test passes."""; + + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("ConsumedKeyEventTest Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 5) + .columns(35) + .testUI(ConsumedKeyEventTest::createTestUI) + .logArea() + .build() + .awaitAndCheck(); + } + + private static Frame createTestUI() { + KeyboardFocusManager.getCurrentKeyboardFocusManager(). + addKeyEventPostProcessor((e) -> { + System.out.println("postProcessor(" + e + ")"); + // consumes all ALT-events + if (e.getKeyCode() == KeyEvent.VK_ALT) { + println("consumed " + e); + e.consume(); + return true; + } + return false; + }); + FocusRequestor requestor = new FocusRequestor(); + Frame frame = new Frame("Main Frame"); + frame.setLayout(new FlowLayout()); + + Canvas canvas = new CustomCanvas(); + canvas.addMouseListener(requestor); + frame.add(canvas); + canvas.requestFocus(); + + Component lwComp = new LWComponent(); + lwComp.addMouseListener(requestor); + frame.add(lwComp); + + frame.pack(); + + return frame; + } + + public boolean postProcessKeyEvent(KeyEvent e) { + System.out.println("postProcessor(" + e + ")"); + // consumes all ALT-events + if (e.getKeyCode() == KeyEvent.VK_ALT) { + println("consumed " + e); + e.consume(); + return true; + } + return false; + } + + static void println(String messageIn) { + PassFailJFrame.log(messageIn); + } +}// class ConsumedKeyEventTest + +class CustomCanvas extends Canvas { + CustomCanvas() { + super(); + setName("HWComponent"); + setSize(100, 100); + addFocusListener(new FocusAdapter() { + public void focusGained(FocusEvent fe) { + repaint(); + } + + public void focusLost(FocusEvent fe) { + repaint(); + } + }); + } + + public void paint(Graphics g) { + if (isFocusOwner()) { + g.setColor(Color.YELLOW); + } else { + g.setColor(Color.GREEN); + } + g.fillRect(0, 0, 100, 100); + } + +} + +class LWComponent extends Component { + LWComponent() { + super(); + setName("LWComponent"); + addFocusListener(new FocusAdapter() { + public void focusGained(FocusEvent fe) { + repaint(); + } + + public void focusLost(FocusEvent fe) { + repaint(); + } + }); + } + + public Dimension getPreferredSize() { + return new Dimension(100, 100); + } + + public void paint(Graphics g) { + if (isFocusOwner()) { + g.setColor(Color.RED); + } else { + g.setColor(Color.BLACK); + } + g.fillRect(0, 0, 100, 100); + } + +} + +class FocusRequestor extends MouseAdapter { + static int counter = 0; + public void mouseClicked(MouseEvent me) { + System.out.println("mouseClicked on " + me.getComponent().getName()); + } + public void mousePressed(MouseEvent me) { + System.out.println("mousePressed on " + me.getComponent().getName()); + me.getComponent().requestFocus(); + } + public void mouseReleased(MouseEvent me) { + System.out.println("mouseReleased on " + me.getComponent().getName()); + } +} + diff --git a/test/jdk/java/awt/Focus/DeiconifyTest.java b/test/jdk/java/awt/Focus/DeiconifyTest.java new file mode 100644 index 00000000000..e87b13b8e65 --- /dev/null +++ b/test/jdk/java/awt/Focus/DeiconifyTest.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4380809 + * @summary Focus disappears after deiconifying frame + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual DeiconifyTest +*/ + +import java.awt.Button; +import java.awt.Frame; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; + +public class DeiconifyTest { + + private static final String INSTRUCTIONS = """ + 1. Activate frame \"Main frame\" + be sure that button has focus + 2. Minimize frame and then restore it. + If the button has focus then test passed, else failed"""; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("DeiconifyTest Instructions") + .instructions(INSTRUCTIONS) + .rows((int)INSTRUCTIONS.lines().count() + 2) + .columns(35) + .testUI(DeiconifyTest::createTestUI) + .logArea() + .build() + .awaitAndCheck(); + } + + private static Frame createTestUI() { + Frame frame = new Frame("Main frame"); + Button button = new Button("button"); + button.addFocusListener(new FocusListener() { + public void focusGained(FocusEvent fe) { + println("focus gained"); + } + public void focusLost(FocusEvent fe) { + println("focus lost"); + } + }); + frame.add(button); + frame.setSize(300, 100); + + return frame; + } + + static void println(String messageIn) { + PassFailJFrame.log(messageIn); + } +} + diff --git a/test/jdk/java/awt/Focus/EmptyWindowKeyTest.java b/test/jdk/java/awt/Focus/EmptyWindowKeyTest.java new file mode 100644 index 00000000000..bbdf8ce4f38 --- /dev/null +++ b/test/jdk/java/awt/Focus/EmptyWindowKeyTest.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 4464723 + * @summary Tests simple KeyAdapter / KeyListener on an empty, focusable window + * @key headful + * @run main EmptyWindowKeyTest +*/ + +import java.awt.AWTEvent; +import java.awt.Frame; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.Robot; + +public class EmptyWindowKeyTest { + + static volatile boolean passed1, passed2; + + public static void main(String[] args) throws Exception { + Robot robot = new Robot(); + robot.setAutoDelay(100); + MainFrame mainFrame = new MainFrame(); + mainFrame.setSize(50,50); + mainFrame.addKeyListener(new KeyboardTracker()); + robot.waitForIdle(); + robot.delay(1000); + robot.keyPress(KeyEvent.VK_A); + robot.keyRelease(KeyEvent.VK_A); + robot.waitForIdle(); + robot.delay(1000); + if (!passed1 || !passed2) { + throw new RuntimeException("KeyPress/keyRelease not seen," + + "passed1 " + passed1 + " passed2 " + passed2); + } + } + + static public class KeyboardTracker extends KeyAdapter { + public KeyboardTracker() { } + public void keyTyped(KeyEvent e) {} + + public void keyPressed(KeyEvent e) { + if (e.getKeyText(e.getKeyCode()).equals("A")) { + passed1 = true; + } + } + public void keyReleased(KeyEvent e) { + if (e.getKeyText(e.getKeyCode()).equals("A")) { + passed2 = true; + } + } + } + + static public class MainFrame extends Frame { + + public MainFrame() { + super(); + enableEvents(AWTEvent.KEY_EVENT_MASK); + setVisible(true); + } + + } + +} + diff --git a/test/jdk/java/awt/Focus/FocusChangeOnResizeTest.java b/test/jdk/java/awt/Focus/FocusChangeOnResizeTest.java new file mode 100644 index 00000000000..a9fa9e5edfd --- /dev/null +++ b/test/jdk/java/awt/Focus/FocusChangeOnResizeTest.java @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +/* + * @test + * @bug 4060975 + * @summary tests that a component doesn't lose focus on resize + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual FocusChangeOnResizeTest +*/ + +import java.util.List; + +import java.awt.Button; +import java.awt.Dialog; +import java.awt.Frame; +import java.awt.GridLayout; +import java.awt.Panel; +import java.awt.TextField; +import java.awt.Window; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; + +public class FocusChangeOnResizeTest { + + private static final String INSTRUCTIONS = """ + For the Frame and the Dialog: + Press the LOWER BUTTON to resize the Frame or Dialog programmatically. + Give the focus to the LOWER BUTTON and resize the Frame or Dialog manually. + If the LOWER BUTTON always has focus after resize + (for both frame and dialog) the test passes."""; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("PopupMenu Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(35) + .testUI(FocusChangeOnResizeTest::createTestUI) + .logArea() + .build() + .awaitAndCheck(); + } + + private static List createTestUI() { + Frame frame = new Frame("FocusChangeOnResizeTest frame"); + Dialog dialog = new Dialog(frame, "Test dialog"); + frame.add(new TestPanel(frame)); + dialog.add(new TestPanel(dialog)); + frame.setBounds (150, 200, 200, 200); + dialog.setBounds (150, 500, 200, 200); + return List.of(frame, dialog); + } + + static FocusListener eventLogger = new FocusListener() { + public void focusGained(FocusEvent e) { + PassFailJFrame.log(e.toString()); + } + public void focusLost(FocusEvent e) { + PassFailJFrame.log(e.toString()); + } + }; +} + +class TestPanel extends Panel { + + TextField textField = new TextField("TEXT FIELD"); + Button button1 = new Button("UPPER BUTTON"); + Button button2 = new Button("LOWER BUTTON"); + + public TestPanel(Window parent) { + setLayout(new GridLayout(3, 1)); + add(textField); + add(button1); + add(button2); + textField.setName("TEXT FIELD"); + button1.setName("UPPER BUTTON"); + button2.setName("LOWER BUTTON"); + textField.addFocusListener(FocusChangeOnResizeTest.eventLogger); + button1.addFocusListener(FocusChangeOnResizeTest.eventLogger); + button2.addFocusListener(FocusChangeOnResizeTest.eventLogger); + + button2.addActionListener(new Resizer(parent)); + } +} + +class Resizer implements ActionListener { + Window target; + + public Resizer(Window window) { + target = window; + } + + public void actionPerformed(ActionEvent e) { + target.setSize(200, 100); + target.doLayout(); + target.pack(); + } +} + diff --git a/test/jdk/java/awt/Focus/FocusKeepTest.java b/test/jdk/java/awt/Focus/FocusKeepTest.java new file mode 100644 index 00000000000..0adc463f5d9 --- /dev/null +++ b/test/jdk/java/awt/Focus/FocusKeepTest.java @@ -0,0 +1,103 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4128659 + * @summary Tests whether a focus request will work on a focus lost event. + * @key headful + * @run main FocusKeepTest + */ + +import java.awt.BorderLayout; +import java.awt.KeyboardFocusManager; +import java.awt.Robot; +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; +import java.awt.event.KeyEvent; +import javax.swing.JFrame; +import javax.swing.JTextField; +import javax.swing.SwingUtilities; + +public class FocusKeepTest { + + static JFrame frame; + static JTextField tf; + + public static void main(String[] args) throws Exception { + Robot robot = new Robot(); + robot.setAutoDelay(100); + try { + SwingUtilities.invokeAndWait(() -> createTestUI()); + robot.waitForIdle(); + robot.delay(1000); + robot.keyPress(KeyEvent.VK_TAB); + robot.keyRelease(KeyEvent.VK_TAB); + if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() instanceof JTextField tf1) { + if (!tf1.getText().equals("TextField 1")) { + throw new RuntimeException("Focus on wrong textfield"); + } + } else { + throw new RuntimeException("Focus not on correct component"); + } + } finally { + SwingUtilities.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } + + private static void createTestUI() { + frame = new JFrame("FocusKeepTest"); + tf = new JTextField("TextField 1"); + tf.addFocusListener(new MyFocusAdapter("TextField 1")); + frame.add(tf, BorderLayout.NORTH); + + tf = new JTextField("TextField 2"); + tf.addFocusListener(new MyFocusAdapter("TextField 2")); + frame.add(tf, BorderLayout.SOUTH); + + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } + + static class MyFocusAdapter extends FocusAdapter { + private String myName; + + public MyFocusAdapter (String name) { + myName = name; + } + + public void focusLost (FocusEvent e) { + if (myName.equals ("TextField 1")) { + e.getComponent().requestFocus (); + } + } + + public void focusGained (FocusEvent e) { + } + } +} diff --git a/test/jdk/java/awt/Focus/FocusPolicyTest.java b/test/jdk/java/awt/Focus/FocusPolicyTest.java new file mode 100644 index 00000000000..3ec362acaf0 --- /dev/null +++ b/test/jdk/java/awt/Focus/FocusPolicyTest.java @@ -0,0 +1,177 @@ +/* + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 4897459 + * @key headful + * @summary The key does not switches focus in the internal frames in Swing apps. + * @run main FocusPolicyTest + */ + +import java.awt.Container; +import java.awt.Component; +import java.awt.DefaultFocusTraversalPolicy; +import java.awt.Dialog; +import java.awt.FocusTraversalPolicy; +import java.awt.Frame; +import java.awt.KeyboardFocusManager; +import java.awt.Toolkit; +import java.awt.Window; +import javax.swing.JDialog; +import javax.swing.JInternalFrame; +import javax.swing.JFrame; +import javax.swing.JWindow; +import javax.swing.LayoutFocusTraversalPolicy; + +public class FocusPolicyTest { + static int stageNum; + static FocusTraversalPolicy customPolicy = new CustomPolicy(); + final static Class awtDefaultPolicy = DefaultFocusTraversalPolicy.class; + final static Class swingDefaultPolicy = LayoutFocusTraversalPolicy.class; + + public static void main(String[] args) { + final boolean isXawt = "sun.awt.X11.XToolkit".equals(Toolkit.getDefaultToolkit().getClass().getName()); + + System.err.println("isXawt = " + isXawt); + + // 1. Check default policy + if (KeyboardFocusManager.getCurrentKeyboardFocusManager(). + getDefaultFocusTraversalPolicy().getClass() != awtDefaultPolicy) { + throw new RuntimeException("Error: stage 1: default policy is not DefaultFocusTraversalPolicy"); + } + + // 2. Check AWT top-levels policies + stageNum = 2; + checkAWTPoliciesFor(awtDefaultPolicy); + + // 3. Check Swing top-levels policies + stageNum = 3; + checkSwingPoliciesFor(swingDefaultPolicy); + + // 4. Check default policy if not XToolkit + if (!isXawt) { + if (KeyboardFocusManager.getCurrentKeyboardFocusManager(). + getDefaultFocusTraversalPolicy().getClass() != swingDefaultPolicy) { + throw new RuntimeException("Error: stage 4: default policy is not LayoutFocusTraversalPolicy"); + } + } + + // 5. Check AWT top-levels policies + // this is a bug in XAWT we should change the test as soon as + // we will be able to fix this bug. + stageNum = 5; + Class defaultPolicy = swingDefaultPolicy; + if (isXawt) { + defaultPolicy = awtDefaultPolicy; + } + checkAWTPoliciesFor(defaultPolicy); + + // Set custom policy as default + KeyboardFocusManager.getCurrentKeyboardFocusManager().setDefaultFocusTraversalPolicy(customPolicy); + + // 6. Check AWT top-levels policies for custom + stageNum = 6; + checkAWTPoliciesFor(customPolicy.getClass()); + + // 7. Check Swing top-levels policies for custom + stageNum = 7; + checkSwingPoliciesFor(customPolicy.getClass()); + + return; + } + + public static void checkAWTPoliciesFor(Class expectedPolicyClass) { + Window[] tlvs = new Window[7]; + + tlvs[0] = new Frame(""); + tlvs[1] = new Frame("", tlvs[0].getGraphicsConfiguration()); + tlvs[2] = new Window((Frame)tlvs[0]); + tlvs[3] = new Dialog((Frame)tlvs[0], "", false); + tlvs[4] = new Dialog((Frame)tlvs[0], "", false, tlvs[0].getGraphicsConfiguration()); + tlvs[5] = new Dialog((Dialog)tlvs[3], "", false); + tlvs[6] = new Dialog((Dialog)tlvs[3], "", false, tlvs[0].getGraphicsConfiguration()); + + for (int i = 0; i < 7; i++) { + Class policyClass = tlvs[i].getFocusTraversalPolicy().getClass(); + if (policyClass != expectedPolicyClass) { + throw new RuntimeException("Error: stage " + stageNum + ": " + + tlvs[i].getClass().getName() + + "'s policy is " + policyClass.getName() + + " but not " + expectedPolicyClass.getName()); + } + } + } + + public static void checkSwingPoliciesFor(Class expectedPolicyClass) { + Container[] tlvs = new Container[12]; + + tlvs[0] = new JFrame(); + tlvs[1] = new JFrame(tlvs[0].getGraphicsConfiguration()); + tlvs[2] = new JFrame(""); + tlvs[3] = new JFrame("", tlvs[0].getGraphicsConfiguration()); + tlvs[4] = new JWindow((Frame)tlvs[0]); + tlvs[5] = new JWindow((Window)tlvs[4]); + tlvs[6] = new JWindow((Window)tlvs[4], tlvs[0].getGraphicsConfiguration()); + tlvs[7] = new JDialog((Frame)tlvs[0], "", false); + tlvs[8] = new JDialog((Frame)tlvs[0], "", false, tlvs[0].getGraphicsConfiguration()); + tlvs[9] = new JDialog((Dialog)tlvs[7], "", false); + tlvs[10] = new JDialog((Dialog)tlvs[7], "", false, tlvs[0].getGraphicsConfiguration()); + tlvs[11] = new JInternalFrame("", false, false, false, false); + + for (int i = 0; i < tlvs.length; i++) { + Class policyClass = tlvs[i].getFocusTraversalPolicy().getClass(); + if (policyClass != expectedPolicyClass) { + throw new RuntimeException("Error: stage " + stageNum + + ": " + tlvs[i].getClass().getName() + + "'s policy is " + policyClass.getName() + " but not " + + expectedPolicyClass.getName()); + } + } + } + + // Dummy policy. + static class CustomPolicy extends FocusTraversalPolicy { + public Component getComponentAfter(Container focusCycleRoot, + Component aComponent) { + return null; + } + + public Component getComponentBefore(Container focusCycleRoot, + Component aComponent) { + return null; + } + + public Component getFirstComponent(Container focusCycleRoot) { + return null; + } + + public Component getLastComponent(Container focusCycleRoot) { + return null; + } + + public Component getDefaultComponent(Container focusCycleRoot) { + return null; + } + } +} diff --git a/test/jdk/java/awt/Focus/HiddenTraversalTest.java b/test/jdk/java/awt/Focus/HiddenTraversalTest.java new file mode 100644 index 00000000000..59e7f477945 --- /dev/null +++ b/test/jdk/java/awt/Focus/HiddenTraversalTest.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +/* + * @test + * @bug 4157017 + * @summary Checks whether focus can be traversed when component not visible + within parent container. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual HiddenTraversalTest +*/ + +import java.awt.Button; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.Panel; + +public class HiddenTraversalTest { + + private static final String INSTRUCTIONS = """ + Examine the Frame. If six buttons are visible, resize the frame + so that only four are visible. If fewer than six buttons are + visible, do nothing.\n + Now, repeatedly press the tab key. Focus should cycle through the + visible and invisible buttons. If after six presses of the tab + button 'Button 0' has focus, the test passes. If focus is instead + stuck at 'Button 3', the test fails."""; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("HiddenTraversalTest Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(35) + .testUI(HiddenTraversalTest::createTestUI) + .build() + .awaitAndCheck(); + } + + private static Frame createTestUI() { + Frame f = new Frame("Focus test"); + Panel p = new Panel(new FlowLayout()); + for (int i = 0; i < 6; i++) { + p.add(new Button("Button " + i)); + } + f.add(p); + f.setSize(200, 100); + return f; + } + +} + diff --git a/test/jdk/java/awt/Focus/InactiveFocusRace.java b/test/jdk/java/awt/Focus/InactiveFocusRace.java new file mode 100644 index 00000000000..efca2dbf53a --- /dev/null +++ b/test/jdk/java/awt/Focus/InactiveFocusRace.java @@ -0,0 +1,188 @@ +/* + * Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4697451 + * @summary Test that there is no race between focus component in inactive window and window activation + * @key headful + * @run main InactiveFocusRace +*/ + +import java.awt.Button; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.KeyboardFocusManager; +import java.awt.Point; +import java.awt.Robot; +import java.awt.Toolkit; +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.awt.event.InputEvent; + +public class InactiveFocusRace { + + static Frame activeFrame, inactiveFrame; + Button activeButton, inactiveButton1, inactiveButton2; + Semaphore sema; + final static int TIMEOUT = 10000; + + public static void main(String[] args) throws Exception { + try { + InactiveFocusRace test = new InactiveFocusRace(); + test.init(); + test.start(); + } finally { + if (activeFrame != null) { + activeFrame.dispose(); + } + if (inactiveFrame != null) { + inactiveFrame.dispose(); + } + } + } + + public void init() { + activeButton = new Button("active button"); + inactiveButton1 = new Button("inactive button1"); + inactiveButton2 = new Button("inactive button2"); + activeFrame = new Frame("Active frame"); + inactiveFrame = new Frame("Inactive frame"); + inactiveFrame.setLayout(new FlowLayout()); + activeFrame.add(activeButton); + inactiveFrame.add(inactiveButton1); + inactiveFrame.add(inactiveButton2); + activeFrame.pack(); + activeFrame.setLocation(300, 10); + inactiveFrame.pack(); + inactiveFrame.setLocation(300, 300); + sema = new Semaphore(); + + inactiveButton1.addFocusListener(new FocusAdapter() { + public void focusGained(FocusEvent e) { + System.err.println("Button 1 got focus"); + } + }); + inactiveButton2.addFocusListener(new FocusAdapter() { + public void focusGained(FocusEvent e) { + System.err.println("Button2 got focus"); + sema.raise(); + } + }); + activeFrame.addWindowListener(new WindowAdapter() { + public void windowActivated(WindowEvent e) { + System.err.println("Window activated"); + sema.raise(); + } + }); + } + + public void start() { + Robot robot = null; + try { + robot = new Robot(); + } catch (Exception e) { + throw new RuntimeException("Unable to create robot"); + } + + inactiveFrame.setVisible(true); + activeFrame.setVisible(true); + + // Wait for active frame to become active + try { + sema.doWait(TIMEOUT); + } catch (InterruptedException ie) { + throw new RuntimeException("Wait was interrupted"); + } + if (!sema.getState()) { + throw new RuntimeException("Frame doesn't become active on show"); + } + sema.setState(false); + + // press on second button in inactive frame + Point loc = inactiveButton2.getLocationOnScreen(); + robot.mouseMove(loc.x+5, loc.y+5); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + + // after all second button should be focus owner. + try { + sema.doWait(TIMEOUT); + } catch (InterruptedException ie) { + throw new RuntimeException("Wait was interrupted"); + } + if (!sema.getState()) { + throw new RuntimeException("Button2 didn't become focus owner"); + } + Toolkit.getDefaultToolkit().sync(); + robot.waitForIdle(); + if (!(KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() == inactiveButton2)) { + throw new RuntimeException("Button2 should be the focus owner after all"); + } + + } + +} + +class Semaphore { + boolean state = false; + int waiting = 0; + public Semaphore() { + } + public void doWait() throws InterruptedException { + synchronized(this) { + if (state) return; + waiting++; + wait(); + waiting--; + } + } + public void doWait(int timeout) throws InterruptedException { + synchronized(this) { + if (state) return; + waiting++; + wait(timeout); + waiting--; + } + } + public void raise() { + synchronized(this) { + state = true; + if (waiting > 0) { + notifyAll(); + } + } + } + public boolean getState() { + synchronized(this) { + return state; + } + } + public void setState(boolean newState) { + synchronized(this) { + state = newState; + } + } +} diff --git a/test/jdk/java/awt/Focus/InitialPrintDlgFocusTest.java b/test/jdk/java/awt/Focus/InitialPrintDlgFocusTest.java new file mode 100644 index 00000000000..cc9d0c03711 --- /dev/null +++ b/test/jdk/java/awt/Focus/InitialPrintDlgFocusTest.java @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4688591 + * @summary Tab key hangs in Native Print Dialog on win32 + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual InitialPrintDlgFocusTest + */ + +import java.awt.BorderLayout; +import java.awt.Dialog; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.JobAttributes; +import java.awt.PageAttributes; +import java.awt.PrintJob; +import java.awt.Toolkit; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.JButton; +import javax.swing.JFrame; + +public class InitialPrintDlgFocusTest { + + private static final String INSTRUCTIONS = """ + After the tests starts you will see a frame titled "PrintTest". + Press the "Print" button and the print dialog should appear. + If you are able to transfer focus between components of the Print dialog + using the TAB key, then the test passes else the test fails. + + Note: close the Print dialog before clicking on "Pass" or "Fail" buttons."""; + + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("InitialPrintDlgFocusTest Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(35) + .testUI(InitialPrintDlgFocusTest::createTestUI) + .build() + .awaitAndCheck(); + } + + private static JFrame createTestUI() { + return new PrintTest(); + + } +} + +class PrintTest extends JFrame implements ActionListener { + + JButton b; + JobAttributes jbattrib; + Toolkit tk ; + PageAttributes pgattrib; + + public PrintTest() { + setTitle("PrintTest"); + setSize(500, 400); + + b = new JButton("Print"); + jbattrib = new JobAttributes(); + tk = Toolkit.getDefaultToolkit(); + pgattrib = new PageAttributes(); + getContentPane().setLayout(new FlowLayout()); + getContentPane().add(b); + + b.addActionListener(this); + + } + + public void actionPerformed(ActionEvent ae) { + if(ae.getSource()==b) + jbattrib.setDialog(JobAttributes.DialogType.NATIVE); + + PrintJob pjob = tk.getPrintJob(this, "Printing Test", + jbattrib, pgattrib); + + } +} + diff --git a/test/jdk/java/awt/Focus/KeyStrokeTest.java b/test/jdk/java/awt/Focus/KeyStrokeTest.java new file mode 100644 index 00000000000..7c462ce8f22 --- /dev/null +++ b/test/jdk/java/awt/Focus/KeyStrokeTest.java @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 4845868 + * @summary REGRESSION: First keystroke after JDialog is closed is lost + * @key headful + * @run main KeyStrokeTest + */ + +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.Dialog; +import java.awt.Frame; +import java.awt.Robot; +import java.awt.TextField; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; + +public class KeyStrokeTest { + static boolean keyTyped; + static Frame frame; + + public static void main(String[] args) throws Exception { + try { + KeyStrokeTest test = new KeyStrokeTest(); + test.doTest(); + } finally { + if (frame != null) { + frame.dispose(); + } + } + } + + private static void doTest() throws Exception { + final Object monitor = new Object(); + frame = new Frame(); + TextField textField = new TextField() { + public void transferFocus() { + System.err.println("transferFocus()"); + final Dialog dialog = new Dialog(frame, true); + Button btn = new Button("Close It"); + btn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + System.err.println("action performed"); + dialog.setVisible(false); + } + }); + dialog.add(btn); + dialog.setSize(200, 200); + dialog.setVisible(true); + } + }; + + textField.addKeyListener(new KeyAdapter() { + public void keyTyped(KeyEvent e) { + System.err.println(e); + if (e.getKeyChar() == 'a') { + keyTyped = true; + } + + synchronized (monitor) { + monitor.notifyAll(); + } + } + }); + frame.add(textField); + frame.setSize(400, 400); + frame.setVisible(true); + + Robot robot = new Robot(); + robot.waitForIdle(); + robot.delay(1000); + robot.keyPress(KeyEvent.VK_TAB); + robot.keyRelease(KeyEvent.VK_TAB); + + robot.delay(1000); + robot.keyPress(KeyEvent.VK_SPACE); + robot.keyRelease(KeyEvent.VK_SPACE); + + robot.delay(1000); + synchronized (monitor) { + robot.keyPress(KeyEvent.VK_A); + robot.keyRelease(KeyEvent.VK_A); + monitor.wait(3000); + } + + if (!keyTyped) { + throw new RuntimeException("TEST FAILED"); + } + + System.out.println("Test passed"); + } + +} diff --git a/test/jdk/java/awt/Focus/KillFocusTest.java b/test/jdk/java/awt/Focus/KillFocusTest.java new file mode 100644 index 00000000000..f61c18971f6 --- /dev/null +++ b/test/jdk/java/awt/Focus/KillFocusTest.java @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 4402942 + * @summary After deactivation and activation of frame, focus should be restored correctlty + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual KillFocusTest +*/ + +import java.awt.Frame; +import java.awt.TextField; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; + +public class KillFocusTest { + + private static final String INSTRUCTIONS = """ + After starting the test you should see \"Test Frame\" + with the \"Click me\" text field. + Click on this text field and try to type something in it. + Make sure that the field receives focus and you can enter text in it. + Click on any non-java window. + Click on \"Click me\" text field to return focus to it + If the caret is in the text field and you are able to type + in it then press pass else press fail."""; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("KillFocusTest Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(35) + .testUI(KillFocusTest::createTestUI) + .logArea() + .build() + .awaitAndCheck(); + } + + private static Frame createTestUI() { + + Frame frame = new Frame("KillFocusTest Frame"); + TextField textField = new TextField("Click me", 10); + textField.addFocusListener(new FocusListener() { + public void focusGained(FocusEvent fe) { + PassFailJFrame.log("Focus gained"); + } + public void focusLost(FocusEvent fe) { + PassFailJFrame.log("Focus lost"); + } + }); + frame.add(textField); + frame.setSize(200, 100); + return frame; + } + + +} + diff --git a/test/jdk/java/awt/Focus/LightweightFocusLostTest.java b/test/jdk/java/awt/Focus/LightweightFocusLostTest.java new file mode 100644 index 00000000000..aff2e5e3b2e --- /dev/null +++ b/test/jdk/java/awt/Focus/LightweightFocusLostTest.java @@ -0,0 +1,261 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +/* + * @test + * @bug 4124119 + * @summary Checks that lightweight components do not lose focus after + dragging the frame by using the mouse. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual LightweightFocusLostTest +*/ + +import java.awt.AWTEvent; +import java.awt.AWTEventMulticaster; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Cursor; +import java.awt.Label; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.SystemColor; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + + +public class LightweightFocusLostTest { + + private static final String INSTRUCTIONS = """ + Steps to try to reproduce this problem: + When this test is run a window will display (Test Focus). + Click in the text field to give it the focus (a blinking cursor + will appear) and then move the frame with the mouse. The text field + (component which uses a lightweight component) should still have focus. + You should still see the blinking cursor in the text field after the + frame has been moved. If this is the behavior that you observe, the + test has passed, Press the Pass button. Otherwise the test has failed, + Press the Fail button."""; + + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("LightweightFocusLostTest Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 5) + .columns(35) + .testUI(LightweightFocusLostTest::createTestUI) + .logArea() + .build() + .awaitAndCheck(); + } + + private static Frame createTestUI() { + Frame f = new Frame("LightweightFocusLostTest"); + f.setLayout(new BorderLayout()); + String sLabel = "Lightweight component below (text field)"; + Label TFL = new Label(sLabel, Label.LEFT); + f.add(TFL, BorderLayout.NORTH); + SimpleTextField canvas = new SimpleTextField(30, 5); + f.add(canvas, BorderLayout.CENTER); + f.setSize(new Dimension(300,125)); + f.requestFocus(); + return f; + + } + +} + +class SimpleTextField extends Component implements Runnable { + int border; + int length; + Font font; + FontMetrics fontM; + char[] buffer; + int bufferIx; + + boolean hasFocus; + boolean cursorOn; + + SimpleTextField(int len, int bor) { + super(); + border = bor; + length = len; + buffer = new char[len]; + font = getFont(); + if (font == null) { + font = new Font("Dialog", Font.PLAIN, 20); + } + fontM = getFontMetrics(font); + + // Listen for key and mouse events. + this.addMouseListener(new MouseEventHandler()); + this.addFocusListener(new FocusEventHandler()); + this.addKeyListener(new KeyEventHandler()); + + // Set text cursor. + setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); + + // Start the thread that blinks the cursor. + (new Thread(this)).start(); + } + + public Dimension getMinimumSize() { + // The minimum height depends on the point size. + int w = fontM.charWidth('m') * length; + return new Dimension(w + 2 * border, fontM.getHeight() + 2 * border); + } + public Dimension getPreferredSize() { + return getMinimumSize(); + } + public Dimension getMaximumSize() { + return new Dimension(Short.MAX_VALUE, getPreferredSize().height); + } + + public boolean isFocusTraversable() { + return true; + } + + public void paint(Graphics g) { + int y = (getSize().height-fontM.getHeight())/2; + + // Clear the background using the text background color. + g.setColor(SystemColor.text); + g.fillRect(0, 0, getSize().width, getSize().height); + + g.setFont(font); + g.setColor(SystemColor.textText); + g.drawChars(buffer, 0, bufferIx, border, y + fontM.getAscent()); + + // Draw blinking cursor. + int x = fontM.charsWidth(buffer, 0, bufferIx) + border; + int w = fontM.charWidth('c'); + if (hasFocus) { + g.setColor(getForeground()); + g.fillRect(x, y, w, fontM.getHeight()); + if (cursorOn) { + if (bufferIx < buffer.length) { + g.setColor(SystemColor.text); + g.fillRect(x + 2, y + 2, w - 4, fontM.getHeight() - 4); + } + } + } + } + + // Event handlers + class MouseEventHandler extends MouseAdapter { + public void mousePressed(MouseEvent evt) { + requestFocus(); + } + } + class FocusEventHandler extends FocusAdapter { + public void focusGained(FocusEvent evt) { + PassFailJFrame.log("Focus gained: " + evt); + + hasFocus = true; + repaint(); + } + public void focusLost(FocusEvent evt) { + PassFailJFrame.log("Focus lost: " + evt); + hasFocus = false; + repaint(); + } + } + class KeyEventHandler extends KeyAdapter { + public void keyPressed(KeyEvent evt) { + switch (evt.getKeyCode()) { + case KeyEvent.VK_DELETE: + case KeyEvent.VK_BACK_SPACE: + if (bufferIx > 0) { + bufferIx--; + repaint(); + } + break; + case KeyEvent.VK_ENTER: + ActionEvent action = + new ActionEvent(SimpleTextField.this, + ActionEvent.ACTION_PERFORMED, + String.valueOf(buffer, 0, bufferIx)); + // Send contents of buffer to listeners + processEvent(action); + break; + default: + repaint(); + } + } + public void keyTyped(KeyEvent evt) { + if (bufferIx < buffer.length + && !evt.isActionKey() + && !Character.isISOControl(evt.getKeyChar())) { + buffer[bufferIx++] = evt.getKeyChar(); + } + } + } + + // Support for Action Listener. + ActionListener actionListener; + + public void addActionListener(ActionListener l) { + actionListener = AWTEventMulticaster.add(actionListener, l); + } + + // Override processEvent() to deal with ActionEvent. + protected void processEvent(AWTEvent evt) { + if (evt instanceof ActionEvent) { + processActionEvent((ActionEvent)evt); + } else { + super.processEvent(evt); + } + } + + // Supply method to process Action event. + protected void processActionEvent(ActionEvent evt) { + if (actionListener != null) { + actionListener.actionPerformed(evt); + } + } + + public void run() { + while (true) { + try { + // If component has focus, blink the cursor every 1/2 second. + Thread.sleep(500); + cursorOn = !cursorOn; + if (hasFocus) { + repaint(); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } +} + diff --git a/test/jdk/java/awt/Focus/LightweightPopupTest.java b/test/jdk/java/awt/Focus/LightweightPopupTest.java new file mode 100644 index 00000000000..bc3dd0d038b --- /dev/null +++ b/test/jdk/java/awt/Focus/LightweightPopupTest.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 4472032 + * @summary Switching between lightweight menus by horizontal arrow key works incorrect + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual LightweightPopupTest +*/ + +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JMenu; +import javax.swing.JMenuBar; +import javax.swing.JMenuItem; + +public class LightweightPopupTest { + + private static final String INSTRUCTIONS = """ + When the test starts, you will see a frame titled + 'Lightweight Popup Test', which contains a button + (titled 'JButton') and two menus ('Menu 1' and 'Menu 2'). + Make sure that both menus, when expanded, fit entirely + into the frame. Now take the following steps: + 1. Click on 'JButton' to focus it. + 2. Click 'Menu 1' to expand it. + 3. Press right arrow to select 'Menu 2'. + Now check where the focus is. If it is on 'JButton' + (you can press space bar to see if it is there), then + the test failed. If 'JButton' is not focused, then + the test passed."""; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("LightweightPopupTest Instructions") + .instructions(INSTRUCTIONS) + .rows((int)INSTRUCTIONS.lines().count() + 2) + .columns(35) + .testUI(LightweightPopupTest::createTestUI) + .build() + .awaitAndCheck(); + } + + private static JFrame createTestUI() { + + JFrame frame = new JFrame("Lightweight Popup Test"); + JButton button = new JButton("JButton"); + JMenuBar menuBar = new JMenuBar(); + JMenu menu1 = new JMenu("Menu 1"); + menu1.add(new JMenuItem("Menu Item 1")); + menu1.add(new JMenuItem("Menu Item 2")); + menuBar.add(menu1); + JMenu menu2 = new JMenu("Menu 2"); + menu2.add(new JMenuItem("Menu Item 3")); + menu2.add(new JMenuItem("Menu Item 4")); + menuBar.add(menu2); + + frame.add(button); + frame.setJMenuBar(menuBar); + frame.setSize(300, 200); + return frame; + } + +} + diff --git a/test/jdk/java/awt/Focus/MinimizeNonfocusableWindowTest.java b/test/jdk/java/awt/Focus/MinimizeNonfocusableWindowTest.java new file mode 100644 index 00000000000..3114850dc7a --- /dev/null +++ b/test/jdk/java/awt/Focus/MinimizeNonfocusableWindowTest.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6399659 + * @summary When minimizing non-focusable window focus shouldn't jump out of the focused window. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual MinimizeNonfocusableWindowTest +*/ + +import java.awt.Frame; +import java.awt.Window; +import java.util.List; + +public class MinimizeNonfocusableWindowTest { + + private static final String INSTRUCTIONS = """ + + You should see three frames: Frame-1, Frame-2 and Unfocusable. + + 1. Click Frame-1 to make it focused window, then click Frame-2. + Minimize Unfocusable frame with the mouse. If Frame-2 is still + the focused window continue testing, otherwise press FAIL. + + 2. Restore Unfocusable frame to normal state. Try to resize by dragging + its edge with left mouse button. It should be resizable. If not press + FAIL. Try the same with right mouse button. It shouldn't resize. + If it does, press FAIL, otherwise press PASS."""; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("MinimizeNonfocusableWindowTest Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 1) + .columns(40) + .testUI(MinimizeNonfocusableWindowTest::createTestUI) + .build() + .awaitAndCheck(); + } + + private static List createTestUI() { + Frame frame1 = new Frame("Frame-1"); + Frame frame2 = new Frame("Frame-2"); + Frame frame3 = new Frame("Unfocusable"); + frame1.setBounds(100, 0, 200, 100); + frame2.setBounds(100, 150, 200, 100); + frame3.setBounds(100, 300, 200, 100); + + frame3.setFocusableWindowState(false); + + return List.of(frame1, frame2, frame3); + } +} + diff --git a/test/jdk/java/awt/Focus/MixedWeightFocus.java b/test/jdk/java/awt/Focus/MixedWeightFocus.java new file mode 100644 index 00000000000..4b434e4b66d --- /dev/null +++ b/test/jdk/java/awt/Focus/MixedWeightFocus.java @@ -0,0 +1,207 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4098290 4140890 + * @summary Using non-opaque windows - popups are initially not painted correctly + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual MixedWeightFocus +*/ + +import java.util.List; +import java.awt.AWTEvent; +import java.awt.Button; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dialog; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.FlowLayout; +import java.awt.FontMetrics; +import java.awt.Graphics; +import java.awt.Panel; +import java.awt.Toolkit; +import java.awt.Window; +import java.awt.event.FocusEvent; +import java.awt.event.MouseEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; + +public class MixedWeightFocus { + + static FocusFrame f; + + private static final String INSTRUCTIONS = """ + This tests that permanent FOCUS_LOST messages are sent to lightweight + components when the focus shifts to a heavyweight component. It also + tests that components retain the focus when their parent window is + deactivated and activated. + + 1. Tab or mouse between the light and heavyweight buttons in this test + and verify that the focus rectangle on the lightweight components + disappears when focus shifts to a heavyweight button. + + 2. Activate another application then reactivate the test frame window. + Verify that the component that had the focus (light or heavy) when + the frame was deactivated regains the focus when it's reactivated. Do + the same thing for the modeless dialog. Also test this by moving the + activation between the dialog and the frame. + + 3. Verify that lightweight components with the focus in a deactivated + window draw their focus rectangles in gray instead of blue-- this indicates + they received temporary instead of permanent FOCUS_LOST events. + + NOTE: There is currently another problem with lightweight components + where if you click on one to activate its frame window, the lightweight + that previously had the focus will not get a FOCUS_LOST event. This + may manifest itself with a gray focus rectangle not getting erased. + Ignore this for now (Win32 only)."""; + + public static void main(String[] argv) throws Exception { + PassFailJFrame.builder() + .title("MixedWeightFocus Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 5) + .columns(45) + .testUI(MixedWeightFocus::createTestUI) + .build() + .awaitAndCheck(); + } + + private static List createTestUI() { + FocusFrame f = new FocusFrame(); + ModelessDialog dlg = new ModelessDialog(f); + + return List.of(f, dlg); + } +} + +class FocusFrame extends Frame { + public FocusFrame() { + super("FocusFrame"); + Panel p = new Panel(); + + p.add(new Button("button 1")); + p.add(new LightweightComp("lw 1")); + p.add(new Button("button 2")); + p.add(new LightweightComp("lw 2")); + add(p); + + pack(); + setLocation(100, 100); + + addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent ev) { + dispose(); + } + }); + } + +} + +class ModelessDialog extends Dialog { + public ModelessDialog(Frame frame) { + super(frame, "ModelessDialog", false); + setLayout( new FlowLayout() ); + add(new Button("button 1")); + add(new LightweightComp("lw 1")); + pack(); + setLocation(100, 400); + } +} + +// simple lightweight component, focus traversable, highlights upon focus +class LightweightComp extends Component { + FontMetrics fm; + String label; + private static final int FOCUS_GONE = 0; + private static final int FOCUS_TEMP = 1; + private static final int FOCUS_HAVE = 2; + int focusLevel = FOCUS_GONE; + public static int nameCounter = 0; + + public LightweightComp(String lwLabel ) { + label = lwLabel; + enableEvents(AWTEvent.FOCUS_EVENT_MASK|AWTEvent.MOUSE_EVENT_MASK); + setName("lw"+Integer.toString(nameCounter++)); + } + + public Dimension getPreferredSize() { + if (fm == null) { + fm = Toolkit.getDefaultToolkit().getFontMetrics(getFont()); + } + return new Dimension(fm.stringWidth(label) + 2, fm.getHeight() + 2); + } + + public void paint(Graphics g) { + Dimension s=getSize(); + + // erase the background + g.setColor(getBackground()); + g.fillRect(0, 0, s.width, s.height); + + g.setColor(getForeground()); + + // draw the string + g.drawString(label, 2, fm.getHeight()); + + // draw a focus rectangle + if (focusLevel > FOCUS_GONE) { + if (focusLevel == FOCUS_TEMP) { + g.setColor(Color.gray); + } else { + g.setColor(Color.blue); + } + g.drawRect(1,1,s.width-2,s.height-2); + } + } + + + public boolean isFocusTraversable() { + return true; + } + + protected void processFocusEvent(FocusEvent e) { + super.processFocusEvent(e); + if (e.getID() == FocusEvent.FOCUS_GAINED) { + focusLevel = FOCUS_HAVE; + } else { + if (e.isTemporary()) { + focusLevel = FOCUS_TEMP; + } else { + focusLevel = FOCUS_GONE; + } + } + repaint(); + } + + protected void processMouseEvent(MouseEvent e) { + + if (e.getID()==MouseEvent.MOUSE_PRESSED) { + requestFocus(); + } + super.processMouseEvent(e); + } +} diff --git a/test/jdk/java/awt/Focus/NextFocusHelperTest.java b/test/jdk/java/awt/Focus/NextFocusHelperTest.java new file mode 100644 index 00000000000..5b3015da630 --- /dev/null +++ b/test/jdk/java/awt/Focus/NextFocusHelperTest.java @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 4474893 + * @summary Component.nextFocusHelper should search for first visible focus cycle root ancst + * @key headful + * @run main NextFocusHelperTest +*/ + +import java.awt.Button; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.FlowLayout; +import java.awt.KeyboardFocusManager; +import java.awt.Panel; +import java.awt.Point; +import java.awt.Robot; +import java.awt.event.InputEvent; + +public class NextFocusHelperTest { + static Panel panel; + static Frame frame; + static Button btn1; + static Button btn3; + static Button hideButton; + + public static void main(String[] args) throws Exception { + Robot robot = new Robot(); + robot.setAutoDelay(100); + try { + EventQueue.invokeAndWait(() -> createTestUI()); + robot.waitForIdle(); + robot.delay(1000); + + Point loc = btn1.getLocationOnScreen(); + Dimension dim = btn1.getSize(); + robot.mouseMove(loc.x + dim.width/2, loc.y + dim.height/2); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.waitForIdle(); + robot.delay(500); + + Point loc1 = hideButton.getLocationOnScreen(); + Dimension dim1 = hideButton.getSize(); + robot.mouseMove(loc1.x + dim1.width/2, loc1.y + dim1.height/2); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.waitForIdle(); + + if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() + instanceof Button btn) { + if (!btn.getLabel().equals("Button 3")) { + throw new RuntimeException("Wrong button has focus"); + } + } + } finally { + EventQueue.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } + + private static void createTestUI() { + frame = new Frame("NextFocusHelperTest Frame"); + frame.setLayout(new FlowLayout()); + + panel = new Panel(); + panel.setFocusCycleRoot(true); + btn1 = new Button("Button In Panel"); + panel.add(btn1); + + hideButton = new Button("Hide Panel"); + hideButton.setFocusable(false); + hideButton.addActionListener(e -> { + panel.setVisible(false); + }); + + frame.add(new Button("Button 1")); + frame.add(panel); + frame.add(new Button("Button 3")); + frame.add(hideButton); + frame.setSize(200, 200); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } +} + diff --git a/test/jdk/java/awt/Focus/ProxiedWindowHideTest.java b/test/jdk/java/awt/Focus/ProxiedWindowHideTest.java new file mode 100644 index 00000000000..a99ec4f0a0d --- /dev/null +++ b/test/jdk/java/awt/Focus/ProxiedWindowHideTest.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 4396407 + * @summary Tests that after a proxied window is hidden, focus is being restored correctly + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual ProxiedWindowHideTest +*/ + +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.Container; +import javax.swing.Box; +import javax.swing.JComboBox; +import javax.swing.JFrame; + +public class ProxiedWindowHideTest { + + private static final String INSTRUCTIONS = """ + You will see a JFrame. + Click on JComboBox, list will expand then select any item in it. + After selection, list should collapse. + Click on Button('Push'). + If you are able to make it focused by mouse click, + (black rectangle will appear around it) the test is PASSED, + otherwise the test is FAILED."""; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("ProxiedWindowHideTest Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(35) + .testUI(ProxiedWindowHideTest::createTestUI) + .build() + .awaitAndCheck(); + } + + private static JFrame createTestUI() { + JFrame frame = new JFrame("ProxiedWindowHideTest frame"); + String[] petStrings = { "Bird", "Cat", "Dog", "Rabbit", "Pig" }; + JComboBox cb = new JComboBox(petStrings); + + cb.setLightWeightPopupEnabled(false); + Container parent = Box.createVerticalBox(); + parent.add(new Button("Push")); + parent.add(cb); + frame.add(parent, BorderLayout.CENTER); + frame.pack(); + return frame; + } + +} + diff --git a/test/jdk/java/awt/Focus/RequestInInactiveFrame.java b/test/jdk/java/awt/Focus/RequestInInactiveFrame.java new file mode 100644 index 00000000000..3297fe17501 --- /dev/null +++ b/test/jdk/java/awt/Focus/RequestInInactiveFrame.java @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6458497 + * @summary check focus requests in inactive frames + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual RequestInInactiveFrame + */ + +import java.util.ArrayList; + +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.Window; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.SwingUtilities; + +public class RequestInInactiveFrame { + + private static final String INSTRUCTIONS = """ + After the tests starts you will see two frames: \"test frame\" and \"opposite frame\" + activate the former by click on its title + Focus should be on \"press me\" button (if it's not, the test fails) + press on \"press me\" button and activate \"opposite frame\" + wait for several seconds. + Focus should either remain on button in the \"opposite frame\" + or goes to \"focus target\" button (in this case \"test frame\" should be activated + if it's not, the test failed. + Activate \"test frame\" one more time, press on \"press me\" button and switch focus + to some native window. Wait for several seconds, + If you see focus border around + \"focus target\" and \"test frame\" is not active then the test failed. + if focus transfered to that button and the frame is activated, or if there is no focus + in java - tests passed."""; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("RequestInInactiveFrame Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(40) + .testUI(RequestInInactiveFrame::createTestUI) + .build() + .awaitAndCheck(); + } + + private static ArrayList createTestUI() { + JFrame frame = new JFrame("test frame"); + final JButton btn2 = new JButton("focus target"); + JButton btn1 = new JButton("press me"); + btn1.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + System.out.println("waiting..."); + try { + Thread.sleep(3000); + } catch (InterruptedException ie) { + ie.printStackTrace(); + } + System.out.println("requesting focus"); + btn2.requestFocus(); + } + }); + frame.setLayout(new FlowLayout()); + frame.add(btn1); + frame.add(btn2); + frame.pack(); + frame.setLocation(200, 100); + + JFrame frame2 = new JFrame("opposite frame"); + JButton btn3 = new JButton("just a button"); + frame2.add(btn3); + frame2.pack(); + frame2.setLocation(200, 200); + + ArrayList list = new ArrayList<>(); + list.add(frame); + list.add(frame2); + return list; + } + +} diff --git a/test/jdk/java/awt/Focus/TestDisabledAutoTransfer.java b/test/jdk/java/awt/Focus/TestDisabledAutoTransfer.java new file mode 100644 index 00000000000..d7928b7db1c --- /dev/null +++ b/test/jdk/java/awt/Focus/TestDisabledAutoTransfer.java @@ -0,0 +1,156 @@ +/* + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +/* + * @test + * @bug 6180261 + * @summary Test that auto-transfer doesn't happen when there are pending focus requests + * @key headful + * @run main TestDisabledAutoTransfer +*/ + +import java.awt.Button; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.Point; +import java.awt.Robot; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.awt.event.InputEvent; +import java.util.concurrent.atomic.AtomicBoolean; + +public class TestDisabledAutoTransfer { + static Frame frame; + static Robot robot; + Button b1; + Button desired; + AtomicBoolean focused = new AtomicBoolean(); + ActionListener mover; + volatile Point loc; + volatile Dimension dim; + + public static void main(String[] args) throws Exception { + robot = new Robot(); + try { + TestDisabledAutoTransfer test = new TestDisabledAutoTransfer(); + test.createTestUI(); + robot.waitForIdle(); + robot.delay(1000); + test.doTest(); + } finally { + if (frame != null) { + frame.dispose(); + } + } + } + + public void createTestUI() { + frame = new Frame("TestDisabledAutoTransfer"); + frame.setLayout(new FlowLayout()); + desired = new Button("Desired"); + FocusAdapter watcher = new FocusAdapter() { + public void focusGained(FocusEvent e) { + synchronized(focused) { + focused.set(true); + } + } + }; + b1 = new Button("Press to disable"); + mover = new ActionListener() { + public void actionPerformed(ActionEvent e) { + desired.requestFocus(); + ((Component)e.getSource()).setEnabled(false); + } + }; + b1.addFocusListener(watcher); + desired.addFocusListener(watcher); + frame.add(b1); + Button misc = new Button("Next"); + frame.add(misc); + misc.addFocusListener(watcher); + frame.add(desired); + frame.setSize(200, 200); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + frame.validate(); + + } + + public void doTest() { + + loc = b1.getLocationOnScreen(); + dim = b1.getSize(); + robot.mouseMove(loc.x + dim.width / 2, loc.y + dim.height / 2); + robot.waitForIdle(); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.waitForIdle(); + b1.requestFocus(); + + try { + synchronized(focused) { + if (!focused.get()) { + focused.wait(1000); + } + } + } catch (InterruptedException ie) { + throw new RuntimeException("Test was interrupted"); + } + + if (!focused.get()) { + throw new RuntimeException("b1 didn't get focus"); + } + focused.set(false); + + b1.addActionListener(mover); + robot.mouseMove(loc.x + dim.width / 2, loc.y + dim.height / 2); + robot.waitForIdle(); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.waitForIdle(); + + try { + synchronized(focused) { + if (!focused.get()) { + focused.wait(1000); + } + } + } catch (InterruptedException ie) { + throw new RuntimeException("Test was interrupted"); + } + + if (!focused.get()) { + throw new RuntimeException("none got focus"); + } + + if (!desired.isFocusOwner()) { + throw new RuntimeException("desired didn't get focus"); + } + } + +} + diff --git a/test/jdk/java/awt/Focus/TestDisabledAutoTransferSwing.java b/test/jdk/java/awt/Focus/TestDisabledAutoTransferSwing.java new file mode 100644 index 00000000000..0793316a989 --- /dev/null +++ b/test/jdk/java/awt/Focus/TestDisabledAutoTransferSwing.java @@ -0,0 +1,165 @@ +/* + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +/* + * @test + * @bug 6180261 + * @summary Test that auto-transfer doesn't happen when there are pending focus requests + * @key headful + * @run main TestDisabledAutoTransferSwing +*/ + +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Point; +import java.awt.Robot; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.SwingUtilities; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.InputEvent; +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; +import java.util.concurrent.atomic.AtomicBoolean; + +public class TestDisabledAutoTransferSwing { + static JFrame frame; + static Robot robot; + JButton b1; + JButton desired; + AtomicBoolean focused = new AtomicBoolean(); + ActionListener mover; + volatile Point loc; + volatile Dimension dim; + + public static void main(String[] args) throws Exception { + robot = new Robot(); + try { + TestDisabledAutoTransferSwing test = new TestDisabledAutoTransferSwing(); + SwingUtilities.invokeAndWait(() -> { + test.createTestUI(); + }); + robot.waitForIdle(); + robot.delay(1000); + test.doTest(); + } finally { + SwingUtilities.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } + + public void createTestUI() { + frame = new JFrame("TestDisabledAutoTransferSwing"); + frame.setLayout (new FlowLayout ()); + desired = new JButton("Desired"); + FocusAdapter watcher = new FocusAdapter() { + public void focusGained(FocusEvent e) { + synchronized(focused) { + focused.set(true); + } + } + }; + b1 = new JButton("Press to disable"); + mover = new ActionListener() { + public void actionPerformed(ActionEvent e) { + desired.requestFocus(); + ((Component)e.getSource()).setEnabled(false); + } + }; + b1.addFocusListener(watcher); + desired.addFocusListener(watcher); + frame.add(b1); + JButton misc = new JButton("Next"); + frame.add(misc); + misc.addFocusListener(watcher); + frame.add(desired); + frame.setSize(200, 200); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + frame.validate(); + + } + + public void doTest() throws Exception { + + SwingUtilities.invokeAndWait(() -> { + loc = b1.getLocationOnScreen(); + dim = b1.getSize(); + }); + robot.mouseMove(loc.x + dim.width / 2, loc.y + dim.height / 2); + robot.waitForIdle(); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.waitForIdle(); + SwingUtilities.invokeAndWait(() -> { + b1.requestFocus(); + }); + + try { + synchronized(focused) { + if (!focused.get()) { + focused.wait(2000); + } + } + } catch (InterruptedException ie) { + throw new RuntimeException("Test was interrupted"); + } + + if (!focused.get()) { + throw new RuntimeException("b1 didn't get focus"); + } + focused.set(false); + + SwingUtilities.invokeAndWait(() -> { + b1.addActionListener(mover); + }); + robot.mouseMove(loc.x + dim.width / 2, loc.y + dim.height / 2); + robot.waitForIdle(); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.waitForIdle(); + + try { + synchronized(focused) { + if (!focused.get()) { + focused.wait(2000); + } + } + } catch (InterruptedException ie) { + throw new RuntimeException("Test was interrupted"); + } + + if (!focused.get()) { + throw new RuntimeException("none got focus"); + } + + if (!desired.isFocusOwner()) { + throw new RuntimeException("desired didn't get focus"); + } + } + +} diff --git a/test/jdk/java/awt/Focus/WindowDisposeFocusTest.java b/test/jdk/java/awt/Focus/WindowDisposeFocusTest.java new file mode 100644 index 00000000000..5e2e49147e5 --- /dev/null +++ b/test/jdk/java/awt/Focus/WindowDisposeFocusTest.java @@ -0,0 +1,98 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4257071 4228379 + * @summary Ensures that focus lost is delivered to a lightweight component + in a disposed window + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual WindowDisposeFocusTest +*/ + +import java.awt.Window; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JFrame; +import javax.swing.JPanel; + +public class WindowDisposeFocusTest { + + private static final String INSTRUCTIONS = """ + Click on "Second" + Click on close box + When dialog pops up, "Second" should no longer have focus."""; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("WindowDisposeFocusTest Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(35) + .testUI(WindowDisposeFocusTest::createTestUI) + .build() + .awaitAndCheck(); + } + + private static Window createTestUI() { + return JFCFocusBug2.test(new String[]{}); + } +} + +class JFCFocusBug2 extends JPanel { + + static public Window test(String[] args) { + final JFrame frame = new JFrame("WindowDisposeFrame"); + frame.setSize(100, 100); + frame.setVisible(true); + + final JFCFocusBug2 bug = new JFCFocusBug2(); + final JDialog dialog = new JDialog(frame, false); + dialog.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + dialog.dispose(); + JDialog dialog2 = new JDialog(frame, false); + dialog2.setContentPane(bug); + dialog2.pack(); + dialog2.setVisible(true); + } + }); + dialog.setContentPane(bug); + dialog.pack(); + dialog.setVisible(true); + return frame; + } + + public JFCFocusBug2() { + _first = new JButton("First"); + _second = new JButton("Second"); + add(_first); + add(_second); + } + + private JButton _first; + private JButton _second; +} diff --git a/test/jdk/java/awt/Focus/bug6435715.java b/test/jdk/java/awt/Focus/bug6435715.java new file mode 100644 index 00000000000..f13f731169f --- /dev/null +++ b/test/jdk/java/awt/Focus/bug6435715.java @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2006, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6435715 + * @summary JButton stops receiving the focusGained event and eventually focus is lost altogether + * @modules java.desktop/sun.awt + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug6435715 + */ + +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JPanel; + +public class bug6435715 { + + private static final String INSTRUCTIONS = """ + 1. after test started you will see frame with three buttons. Notice that focus is on Button2. + 2. Click on Button 3. Focus goes to Button3. + 3. Click on Button1 and quickly switch to another window. Via either alt/tab or + clicking another window with the mouse. + 4. After a few seconds, come back to the frame. Notice that focus is around Button2 + 5. Click at Button3. If focus remains at Button2 test failed, if focus is on Button3 - test passed."""; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("bug6435715 Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 5) + .columns(35) + .testUI(bug6435715::createTestUI) + .build() + .awaitAndCheck(); + } + + private static JFrame createTestUI() { + JFrame fr = new JFrame("FocusIssue"); + sun.awt.SunToolkit.setLWRequestStatus(fr, true); + + JPanel panel = new JPanel(); + final JButton b1 = new JButton("Button 1"); + final JButton b2 = new JButton("Button 2"); + final JButton b3 = new JButton("Button 3"); + + panel.add(b1); + panel.add(b2); + panel.add(b3); + + b1.addFocusListener(new FocusAdapter() { + public void focusGained(FocusEvent event) { + synchronized (this) { + try { + wait(1000); + } catch (Exception ex) { + ex.printStackTrace(); + } + b2.requestFocus(); + } + } + }); + fr.getContentPane().add(panel); + fr.pack(); + return fr; + } + +} diff --git a/test/jdk/java/awt/Frame/AddRemoveMenuBarTest_5.java b/test/jdk/java/awt/Frame/AddRemoveMenuBarTest_5.java new file mode 100644 index 00000000000..f5f1018c262 --- /dev/null +++ b/test/jdk/java/awt/Frame/AddRemoveMenuBarTest_5.java @@ -0,0 +1,120 @@ +/* + * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Button; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.Menu; +import java.awt.MenuBar; +import java.awt.Robot; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; + +/* + * @test + * @key headful + * @bug 4159883 + * @summary Adding/Removing a menu causes frame to unexpected small size + * @requires (os.family == "linux" | os.family == "windows") + */ + +public class AddRemoveMenuBarTest_5 { + + static Frame frame; + static MenuBar menu; + static Button btnAdd, btnRemove; + static Dimension oldSize; + + public static void main(String[] args) throws Exception { + Robot robot = new Robot(); + try { + EventQueue.invokeAndWait(AddRemoveMenuBarTest_5::initAndShowGui); + robot.waitForIdle(); + robot.delay(500); + + EventQueue.invokeAndWait(() -> { + oldSize = frame.getSize(); + changeMenubar(true); + }); + robot.waitForIdle(); + robot.delay(500); + + EventQueue.invokeAndWait(() -> { + checkSize(); + changeMenubar(false); + }); + robot.waitForIdle(); + robot.delay(500); + + EventQueue.invokeAndWait(AddRemoveMenuBarTest_5::checkSize); + } finally { + EventQueue.invokeAndWait(frame::dispose); + } + } + + public static void initAndShowGui() { + frame = new Frame(); + frame.setLocationRelativeTo(null); + frame.addWindowListener(new WindowAdapter() { + @Override + public void windowOpened(WindowEvent e) { + System.out.println("Frame size:" + frame.getSize().toString()); + System.out.println("Button size:" + btnAdd.getSize().toString()); + } + }); + frame.add("West", btnAdd = new Button("TRY:ADD")); + frame.add("East", btnRemove = new Button("TRY:REMOVE")); + + + btnAdd.addActionListener((e) -> changeMenubar(true)); + btnRemove.addActionListener((e) -> changeMenubar(false)); + frame.setSize(500, 100); + frame.setVisible(true); + } + + private static void changeMenubar(boolean enable) { + if (enable) { + menu = new MenuBar(); + menu.add(new Menu("BAAAAAAAAAAAAAAA")); + menu.add(new Menu("BZZZZZZZZZZZZZZZ")); + menu.add(new Menu("BXXXXXXXXXXXXXXX")); + } else { + menu = null; + } + frame.setMenuBar(menu); + frame.invalidate(); + frame.validate(); + + System.out.println("Frame size:" + frame.getSize().toString()); + System.out.println("Button size:" + btnAdd.getSize().toString()); + } + + private static void checkSize() { + Dimension newSize = frame.getSize(); + if (!oldSize.equals(newSize)) { + throw new RuntimeException("Frame size changed: old %s new %s" + .formatted(oldSize, newSize)); + } + } +} diff --git a/test/jdk/java/awt/Frame/DefaultFrameIconTest.java b/test/jdk/java/awt/Frame/DefaultFrameIconTest.java new file mode 100644 index 00000000000..f8b48c6df2c --- /dev/null +++ b/test/jdk/java/awt/Frame/DefaultFrameIconTest.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Dialog; +import java.awt.Frame; +import java.awt.Window; +import java.util.List; + +/* + * @test + * @bug 4240766 8259023 + * @summary Frame Icon is wrong - should be Coffee Cup or Duke image icon + * @requires (os.family == "windows") + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual DefaultFrameIconTest +*/ + +public class DefaultFrameIconTest { + + private static final String INSTRUCTIONS = """ + You should see a dialog and a frame. + If both have Coffee Cup or Duke image icon in the upper left corner, + the test passes, otherwise it fails. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("DefaultFrameIconTest Instructions") + .instructions(INSTRUCTIONS) + .columns(45) + .testUI(DefaultFrameIconTest::createAndShowUI) + .positionTestUIRightRow() + .build() + .awaitAndCheck(); + } + + private static List createAndShowUI() { + Frame testFrame = new Frame("Frame DefaultFrameIconTest"); + Dialog testDialog = new Dialog(testFrame, "Dialog DefaultFrameIconTest"); + + testDialog.setSize(250, 100); + + testFrame.setSize(250, 100); + return List.of(testFrame, testDialog); + } +} diff --git a/test/jdk/java/awt/Frame/DefaultLocationTest.java b/test/jdk/java/awt/Frame/DefaultLocationTest.java new file mode 100644 index 00000000000..dfeb5e93e3c --- /dev/null +++ b/test/jdk/java/awt/Frame/DefaultLocationTest.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.Label; + +/* + * @test + * @bug 4085599 + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @summary Test default location for frame + * @run main/manual DefaultLocationTest + */ + +public class DefaultLocationTest { + private static Frame f; + + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + A small frame containing the label 'Hello World' should + appear in the upper left hand corner of the screen. The + exact location is dependent upon the window manager. + + On Linux and Mac machines, the default location for frame + is below the taskbar or close to top-left corner. + + Upon test completion, click Pass or Fail appropriately."""; + + PassFailJFrame passFailJFrame = new PassFailJFrame("DefaultLocationTest " + + " Instructions", INSTRUCTIONS, 5, 10, 40); + EventQueue.invokeAndWait(DefaultLocationTest::createAndShowUI); + passFailJFrame.awaitAndCheck(); + } + + private static void createAndShowUI() { + f = new Frame("DefaultLocation"); + f.add("Center", new Label("Hello World")); + f.pack(); + PassFailJFrame.addTestWindow(f); + PassFailJFrame.positionTestWindow( + null, PassFailJFrame.Position.HORIZONTAL); + f.setVisible(true); + } +} diff --git a/test/jdk/java/awt/Frame/DeiconifyClipTest.java b/test/jdk/java/awt/Frame/DeiconifyClipTest.java new file mode 100644 index 00000000000..c650355f3ec --- /dev/null +++ b/test/jdk/java/awt/Frame/DeiconifyClipTest.java @@ -0,0 +1,140 @@ +/* + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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. + */ + +/* + * DeiconifyClipTest.java + * + * summary: + * + * What happens is that we call AwtWindow::UpdateInsets when + * processing WM_NCCALCSIZE delivered on programmatic deiconification. + * At this point IsIconic returns false (so UpdateInsets proceeds), + * but the rect sizes still seems to be those weird of the iconic + * state. Based on them we compute insets with top = left = 0 (and + * bottom and right that are completely bogus) and pass them to + * PaintUpdateRgn which results in incorrect clip origin. Immediately + * after that we do UpdateInsets again during WM_SIZE processing and + * get real values. + */ + +import javax.swing.BoxLayout; +import javax.swing.JFrame; +import javax.swing.SwingUtilities; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Insets; + +/* + * @test + * @bug 4792958 + * @summary Incorrect clip region after programmatic restore + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual DeiconifyClipTest +*/ + +public class DeiconifyClipTest { + private static final String INSTRUCTIONS = """ + This test creates a frame that is automatically iconified/deiconified + in a cycle. + + The test FAILS if after deiconfication the frame has a greyed-out area + in the lower-right corner. + If the frame contents is drawn completely - the test PASSES. + + Press PASS or FAIL button accordingly. + """; + + static TestFrame testFrame; + static volatile boolean shouldContinue = true; + + public static void main(String[] args) throws Exception { + PassFailJFrame passFailJFrame = PassFailJFrame.builder() + .title("DeiconifyClipTest Instructions") + .instructions(INSTRUCTIONS) + .columns(45) + .testUI(DeiconifyClipTest::createAndShowUI) + .build(); + try { + runThread(); + } finally { + passFailJFrame.awaitAndCheck(); + shouldContinue = false; + } + } + + private static void runThread() { + new Thread(() -> { + for (int i = 0; i < 1000 && shouldContinue; ++i) { + try { + Thread.sleep(3000); + SwingUtilities.invokeAndWait(() -> { + if ((testFrame.getExtendedState() & Frame.ICONIFIED) + != 0) { + testFrame.setExtendedState(Frame.NORMAL); + } else { + testFrame.setState(Frame.ICONIFIED); + } + }); + } catch (Exception ignored) { + } + } + }).start(); + } + + static Frame createAndShowUI() { + testFrame = new TestFrame(); + testFrame.getContentPane().setLayout(new BoxLayout(testFrame.getContentPane(), + BoxLayout.Y_AXIS)); + testFrame.getContentPane().setBackground(Color.yellow); + testFrame.setSize(300, 300); + return testFrame; + } + + static class TestFrame extends JFrame { + public TestFrame() { + super("DeiconifyClipTest"); + } + + // make it more visible if the clip is wrong. + public void paint(Graphics g) { + Insets b = getInsets(); + Dimension d = getSize(); + + int x = b.left; + int y = b.top; + int w = d.width - x - b.right; + int h = d.height - y - b.bottom; + + g.setColor(Color.white); + g.fillRect(0, 0, d.width, d.height); + + g.setColor(Color.green); + g.drawRect(x, y, w-1, h-1); + g.drawLine(x, y, x+w, y+h); + g.drawLine(x, y+h, x+w, y); + } + } +} diff --git a/test/jdk/java/awt/Frame/DisabledParentOfToplevel.java b/test/jdk/java/awt/Frame/DisabledParentOfToplevel.java new file mode 100644 index 00000000000..878809749d3 --- /dev/null +++ b/test/jdk/java/awt/Frame/DisabledParentOfToplevel.java @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.Point; +import java.awt.Robot; +import java.awt.Window; +import java.awt.event.InputEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +/* + * @test + * @bug 5062118 + * @key headful + * @summary Disabling of a parent should not disable Window. + * @run main DisabledParentOfToplevel + */ + +public class DisabledParentOfToplevel { + private static Button okBtn; + private static Window ww; + private static Frame parentFrame; + private static volatile Point p; + private static volatile Dimension d; + + public static void main(String[] args) throws Exception { + Robot robot = new Robot(); + robot.setAutoDelay(100); + try { + EventQueue.invokeAndWait(() -> { + createAndShowUI(); + }); + robot.delay(1000); + EventQueue.invokeAndWait(() -> { + p = okBtn.getLocationOnScreen(); + d = okBtn.getSize(); + }); + robot.mouseMove(p.x + d.width / 2, p.x + d.height / 2); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.delay(500); + if (ww.isVisible()) { + throw new RuntimeException("Window is visible but should be hidden: failure."); + } + } finally { + EventQueue.invokeAndWait(() -> { + if (parentFrame != null) { + parentFrame.dispose(); + } + }); + } + } + + private static void createAndShowUI() { + parentFrame = new Frame("parentFrame"); + parentFrame.setSize(100, 100); + parentFrame.setEnabled(false); + ww = new Window(parentFrame); + ww.setLayout(new BorderLayout()); + okBtn = new Button("Click to Close Me"); + ww.add(okBtn); + ww.setSize(250, 250); + ww.setLocation(110, 110); + okBtn.addMouseListener(new MouseAdapter() { + public void mousePressed(MouseEvent me) { + System.out.println("Pressed: close"); + ww.setVisible(false); + } + }); + parentFrame.setVisible(true); + ww.setVisible(true); + okBtn.requestFocus(); + } +} diff --git a/test/jdk/java/awt/Frame/DisposeTest.java b/test/jdk/java/awt/Frame/DisposeTest.java new file mode 100644 index 00000000000..08c0def638e --- /dev/null +++ b/test/jdk/java/awt/Frame/DisposeTest.java @@ -0,0 +1,112 @@ +/* + * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import javax.imageio.ImageIO; +import java.awt.Color; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.Menu; +import java.awt.MenuBar; +import java.awt.Rectangle; +import java.awt.Robot; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; + +/* + * @test + * @key headful + * @bug 4127271 + * @summary Tests that disposing of a Frame with MenuBar removes all traces + * of the Frame from the screen. + */ + +public class DisposeTest { + private static Frame backgroundFrame; + private static Frame testedFrame; + + private static final Rectangle backgroundFrameBounds = + new Rectangle(100, 100, 200, 200); + private static final Rectangle testedFrameBounds = + new Rectangle(150, 150, 100, 100); + + private static Robot robot; + + public static void main(String[] args) throws Exception { + robot = new Robot(); + try { + EventQueue.invokeAndWait(DisposeTest::initAndShowGui); + robot.waitForIdle(); + robot.delay(500); + EventQueue.invokeAndWait(testedFrame::dispose); + robot.waitForIdle(); + robot.delay(500); + test(); + } finally { + EventQueue.invokeAndWait(() -> { + backgroundFrame.dispose(); + testedFrame.dispose(); + }); + } + } + + private static void test() { + BufferedImage bi = robot.createScreenCapture(backgroundFrameBounds); + int redPix = Color.RED.getRGB(); + + for (int x = 0; x < bi.getWidth(); x++) { + for (int y = 0; y < bi.getHeight(); y++) { + if (bi.getRGB(x, y) != redPix) { + try { + ImageIO.write(bi, "png", + new File("failure.png")); + } catch (IOException ignored) {} + throw new RuntimeException("Test failed"); + } + } + } + } + + private static void initAndShowGui() { + backgroundFrame = new Frame("DisposeTest background"); + backgroundFrame.setUndecorated(true); + backgroundFrame.setBackground(Color.RED); + backgroundFrame.setBounds(backgroundFrameBounds); + backgroundFrame.setVisible(true); + + testedFrame = new UglyFrame(); + } + + static class UglyFrame extends Frame { + public UglyFrame() { + super("DisposeTest"); + MenuBar mb = new MenuBar(); + Menu m = new Menu("menu"); + mb.add(m); + setMenuBar(mb); + setBounds(testedFrameBounds); + setVisible(true); + } + } +} + diff --git a/test/jdk/java/awt/Frame/EmptyFrameTest.java b/test/jdk/java/awt/Frame/EmptyFrameTest.java new file mode 100644 index 00000000000..7a324a3cbc9 --- /dev/null +++ b/test/jdk/java/awt/Frame/EmptyFrameTest.java @@ -0,0 +1,99 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.Robot; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; +import javax.imageio.ImageIO; + +/* + * @test + * @bug 4237529 + * @key headful + * @summary Test repainting of an empty frame + * @run main EmptyFrameTest + */ + +public class EmptyFrameTest { + private static Frame f; + private static Robot robot; + private static volatile Point p; + private static volatile Dimension d; + private static final int TOLERANCE = 5; + public static void main(String[] args) throws Exception { + robot = new Robot(); + robot.setAutoDelay(100); + try { + EventQueue.invokeAndWait(() -> { + createAndShowUI(); + }); + robot.delay(1000); + f.setSize(50, 50); + robot.delay(500); + EventQueue.invokeAndWait(() -> { + p = f.getLocation(); + d = f.getSize(); + }); + Rectangle rect = new Rectangle(p, d); + BufferedImage img = robot.createScreenCapture(rect); + if (chkImgBackgroundColor(img)) { + try { + ImageIO.write(img, "png", new File("Frame.png")); + } catch (IOException ignored) {} + throw new RuntimeException("Frame doesn't repaint itself on resize"); + } + } finally { + EventQueue.invokeAndWait(() -> { + if (f != null) { + f.dispose(); + } + }); + } + } + + private static void createAndShowUI() { + f = new Frame("EmptyFrameTest"); + f.setUndecorated(true); + f.setBackground(Color.RED); + f.setVisible(true); + } + + private static boolean chkImgBackgroundColor(BufferedImage img) { + for (int x = 1; x < img.getWidth() - 1; ++x) { + for (int y = 1; y < img.getHeight() - 1; ++y) { + Color c = new Color(img.getRGB(x, y)); + if ((c.getRed() - Color.RED.getRed()) > TOLERANCE) { + return true; + } + } + } + return false; + } +} diff --git a/test/jdk/java/awt/Frame/FocusTest.java b/test/jdk/java/awt/Frame/FocusTest.java new file mode 100644 index 00000000000..14d194789fe --- /dev/null +++ b/test/jdk/java/awt/Frame/FocusTest.java @@ -0,0 +1,151 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Canvas; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.GridLayout; +import java.awt.Panel; +import java.awt.Window; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; + +/* + * @test + * @bug 4140293 + * @summary Tests that focus is returned to the correct Component when a Frame + * is reactivated. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual FocusTest + */ + +public class FocusTest { + private static final String INSTRUCTIONS = """ + Click on the bottom rectangle. Move the mouse slightly. + A focus rectangle should appear around the bottom rectangle. + + Now, deactivate the window and then reactivate it. + (You would click on the caption bar of another window, + and then on the caption bar of the FocusTest Frame.) + + If the focus rectangle appears again, the test passes. + If it does not appear, or appears around the top rectangle, + the test fails. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("FocusTest Instructions") + .instructions(INSTRUCTIONS) + .columns(45) + .logArea(6) + .testUI(FocusTest::createAndShowUI) + .build() + .awaitAndCheck(); + } + + private static Window createAndShowUI() { + Frame frame = new Frame("FocusTest"); + + frame.add(new FocusTestPanel()); + frame.setSize(400, 400); + + frame.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + frame.dispose(); + } + }); + + frame.validate(); + return frame; + } + + private static class FocusTestPanel extends Panel { + PassiveClient pc1 = new PassiveClient("pc1"); + PassiveClient pc2 = new PassiveClient("pc2"); + + public FocusTestPanel() { + super(); + setLayout(new GridLayout(2, 1, 10, 10)); + add(pc1); + add(pc2); + } + } + + private static class PassiveClient extends Canvas implements FocusListener { + boolean haveFocus = false; + final String name; + + PassiveClient(String name) { + super(); + this.name = name; + setSize(400, 100); + setBackground(Color.cyan); + setVisible(true); + setEnabled(true); + addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + requestFocus(); + } + }); + addFocusListener(this); + } + + public void paint(Graphics g) { + g.setColor(getBackground()); + Dimension size = getSize(); + g.fillRect(0, 0, size.width, size.height); + if (haveFocus) { + g.setColor(Color.black); + g.drawRect(0, 0, size.width - 1, size.height - 1); + g.drawRect(1, 1, size.width - 3, size.height - 3); + } + g.setColor(getForeground()); + } + + public void focusGained(FocusEvent event) { + haveFocus = true; + paint(getGraphics()); + PassFailJFrame.log("<<<< %s Got focus!! %s>>>>".formatted(this, event)); + } + + public void focusLost(FocusEvent event) { + haveFocus = false; + paint(getGraphics()); + PassFailJFrame.log("<<<< %s Lost focus!! %s>>>>".formatted(this, event)); + } + + @Override + public String toString() { + return "PassiveClient " + name; + } + } +} diff --git a/test/jdk/java/awt/Frame/FrameLayoutTest.java b/test/jdk/java/awt/Frame/FrameLayoutTest.java new file mode 100644 index 00000000000..d6e994beaac --- /dev/null +++ b/test/jdk/java/awt/Frame/FrameLayoutTest.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.Frame; + +/* + * @test + * @bug 4173503 + * @library /java/awt/regtesthelpers + * @requires (os.family == "windows") + * @build PassFailJFrame + * @summary Tests that frame layout is performed when frame is maximized from taskbar + * @run main/manual FrameLayoutTest + */ + +public class FrameLayoutTest { + + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + Right-click on the taskbar button for this test. In the menu appeared, + choose Maximize. The frame will be maximized. Check if buttons inside + the frame are laid out properly, i.e. they occupy the frame entirely. + + If so, test passes. If buttons occupy small rectangle in the top left + corner, test fails."""; + + PassFailJFrame.builder() + .title("Frame's Layout Test Instruction") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(40) + .testUI(FrameLayoutTest::createUI) + .build() + .awaitAndCheck(); + } + + private static Frame createUI() { + Frame f = new Frame("Maximize Test"); + f.add(new Button("North"), BorderLayout.NORTH); + f.add(new Button("South"), BorderLayout.SOUTH); + f.add(new Button("East"), BorderLayout.EAST); + f.add(new Button("West"), BorderLayout.WEST); + f.add(new Button("Cent"), BorderLayout.CENTER); + f.pack(); + f.setState(Frame.ICONIFIED); + return f; + } +} diff --git a/test/jdk/java/awt/Frame/FrameMenuPackTest.java b/test/jdk/java/awt/Frame/FrameMenuPackTest.java new file mode 100644 index 00000000000..c034acd8eb7 --- /dev/null +++ b/test/jdk/java/awt/Frame/FrameMenuPackTest.java @@ -0,0 +1,99 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.BorderLayout; +import java.awt.Frame; +import java.awt.Label; +import java.awt.Menu; +import java.awt.MenuBar; +import java.awt.MenuItem; +import java.awt.ScrollPane; +import java.awt.Window; +import java.util.List; + +/* + * @test + * @bug 4084766 + * @summary Test for bug(s): 4084766 + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual FrameMenuPackTest + */ + +public class FrameMenuPackTest { + private static final String INSTRUCTIONS = """ + Check that both frames that appear are properly packed with + the scrollpane visible. + """; + + public static void main(String[] argv) throws Exception { + PassFailJFrame.builder() + .title("FrameMenuPackTest Instructions") + .instructions(INSTRUCTIONS) + .columns(45) + .testUI(FrameMenuPackTest::createAndShowUI) + .positionTestUIRightRow() + .build() + .awaitAndCheck(); + } + + private static List createAndShowUI() { + // Frame without menu, packs correctly + PackedFrame f1 = new PackedFrame(false); + f1.pack(); + + // Frame with menu, doesn't pack right + PackedFrame f2 = new PackedFrame(true); + f2.pack(); + + return List.of(f1, f2); + } + + private static class PackedFrame extends Frame { + public PackedFrame(boolean withMenu) { + super("PackedFrame"); + + MenuBar menubar; + Menu fileMenu; + MenuItem foo; + ScrollPane sp; + + sp = new ScrollPane(); + sp.add(new Label("Label in ScrollPane")); + System.out.println(sp.getMinimumSize()); + + this.setLayout(new BorderLayout()); + this.add(sp, "Center"); + this.add(new Label("Label in Frame"), "South"); + + if (withMenu) { + menubar = new MenuBar(); + fileMenu = new Menu("File"); + foo = new MenuItem("foo"); + fileMenu.add(foo); + menubar.add(fileMenu); + this.setMenuBar(menubar); + } + } + } +} diff --git a/test/jdk/java/awt/Frame/FramePaintTest.java b/test/jdk/java/awt/Frame/FramePaintTest.java new file mode 100644 index 00000000000..aaa14893b34 --- /dev/null +++ b/test/jdk/java/awt/Frame/FramePaintTest.java @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.Graphics; + +/* + * @test + * @bug 4023385 + * @summary resizing a frame causes too many repaints + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual FramePaintTest +*/ + +public class FramePaintTest { + private static final String INSTRUCTIONS = """ + You should see a Frame titled "Repaint Test", filled with colored blocks. + + Resize the frame several times, both inward as well as outward. + + The blocks should move to fill the window without any flashes or + glitches which ensures that repaint is not done excessively + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("FramePaintTest Instructions") + .instructions(INSTRUCTIONS) + .columns(45) + .testUI(ResizeLW::new) + .build() + .awaitAndCheck(); + } + + static class ResizeLW extends Frame { + + public ResizeLW() { + super("Repaint Test"); + setBackground(Color.red); + setLayout(new FlowLayout()); + setSize(300, 300); + + for (int i = 0; i < 10; i++) { + add(new ColorComp(Color.blue)); + add(new ColorComp(Color.green)); + } + } + + private static class ColorComp extends Component { + public ColorComp(Color c) { + super(); + setBackground(c); + } + + public void paint(Graphics g) { + g.setColor(getBackground()); + g.fillRect(0, 0, getWidth(), getHeight()); + } + + public Dimension getPreferredSize() { + return new Dimension(50, 50); + } + } + } +} diff --git a/test/jdk/java/awt/Frame/FrameResizableTest.java b/test/jdk/java/awt/Frame/FrameResizableTest.java new file mode 100644 index 00000000000..4734ce71670 --- /dev/null +++ b/test/jdk/java/awt/Frame/FrameResizableTest.java @@ -0,0 +1,97 @@ +/* + * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Button; +import java.awt.Frame; +import java.awt.Label; +import java.awt.Panel; +import java.awt.event.ActionListener; + +/* + * @test + * @bug 1231233 + * @summary Tests whether the resizable property of a Frame is + * respected after it is set. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual FrameResizableTest + */ + +public class FrameResizableTest { + private static final String INSTRUCTIONS = """ + There is a frame with two buttons and a label. The label + reads 'true' or 'false' to indicate whether the frame can be + resized or not. + + When the first button, 'Set Resizable', is + clicked, you should be able to resize the frame. + When the second button, 'UnSet Resizable', is clicked, you should + not be able to resize the frame. + + A frame is resized in a way which depends upon the window manager (WM) running. + You may resize the frame by dragging the corner resize handles or the borders, + or you may use the title bar's resize menu items and buttons. + + Upon test completion, click Pass or Fail appropriately. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("FrameResizableTest Instructions") + .instructions(INSTRUCTIONS) + .columns(50) + .testUI(FrameResizable::new) + .build() + .awaitAndCheck(); + } + + private static class FrameResizable extends Frame { + Label label; + Button buttonResizable; + Button buttonNotResizable; + + public FrameResizable() { + super("FrameResizable"); + setResizable(false); + Panel panel = new Panel(); + + add("North", panel); + ActionListener actionListener = (e) -> { + if (e.getSource() == buttonResizable) { + setResizable(true); + } else if (e.getSource() == buttonNotResizable) { + setResizable(false); + } + label.setText("Resizable: " + isResizable()); + }; + + panel.add(buttonResizable = new Button("Set Resizable")); + panel.add(buttonNotResizable = new Button("UnSet Resizable")); + panel.add(label = new Label("Resizable: " + isResizable())); + buttonResizable.addActionListener(actionListener); + buttonNotResizable.addActionListener(actionListener); + + setSize(400, 200); + } + } +} diff --git a/test/jdk/java/awt/Frame/FrameResizeTest/FrameResizeTest_3.java b/test/jdk/java/awt/Frame/FrameResizeTest/FrameResizeTest_3.java new file mode 100644 index 00000000000..6fdef005775 --- /dev/null +++ b/test/jdk/java/awt/Frame/FrameResizeTest/FrameResizeTest_3.java @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Button; +import java.awt.Frame; +import java.awt.GridLayout; +import java.awt.Window; +import java.awt.event.ActionListener; + +/* + * @test + * @bug 4097207 + * @summary setSize() on a Frame does not resize its content + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual FrameResizeTest_3 +*/ + +public class FrameResizeTest_3 { + + private static final String INSTRUCTIONS = """ + 1. You would see a frame titled 'TestFrame' with 2 buttons + named 'setSize(500,500)' and 'setSize(400,400)' + 2. Click any button and you would see the frame resized + 3. If the buttons get resized along with the frame + (ie., to fit the frame), press Pass else press Fail. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("FrameResizeTest_3 Instructions") + .instructions(INSTRUCTIONS) + .columns(45) + .logArea(6) + .testUI(FrameResizeTest_3::createTestUI) + .build() + .awaitAndCheck(); + } + + private static Window createTestUI() { + Frame frame = new Frame("TestFrame"); + frame.setLayout(new GridLayout(2, 1)); + + Button butSize500 = new Button("setSize(500,500)"); + Button butSize400 = new Button("setSize(400,400)"); + + ActionListener actionListener = e -> { + if (e.getSource() instanceof Button) { + if (e.getSource() == butSize500) { + frame.setSize(500, 500); + PassFailJFrame.log("New bounds: " + frame.getBounds()); + } else if (e.getSource() == butSize400) { + frame.setSize(400, 400); + PassFailJFrame.log("New bounds: " + frame.getBounds()); + } + } + }; + butSize500.addActionListener(actionListener); + butSize400.addActionListener(actionListener); + frame.add(butSize500); + frame.add(butSize400); + + frame.setSize(270, 200); + return frame; + } +} diff --git a/test/jdk/java/awt/Frame/FrameResizeTest/FrameResizeTest_4.java b/test/jdk/java/awt/Frame/FrameResizeTest/FrameResizeTest_4.java new file mode 100644 index 00000000000..4428feee335 --- /dev/null +++ b/test/jdk/java/awt/Frame/FrameResizeTest/FrameResizeTest_4.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* Note that although this test makes use of Swing classes, like JFrame and */ +/* JButton, it is really an AWT test, because it tests mechanism of sending */ +/* paint events. */ + +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JPanel; +import java.awt.BorderLayout; + +/* + * @test + * @bug 4174831 + * @summary Tests that frame do not flicker on diagonal resize + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual FrameResizeTest_4 + */ + +public class FrameResizeTest_4 { + private static final String INSTRUCTIONS = """ + Try enlarging the frame diagonally. + If buttons inside frame excessively repaint themselves and flicker + while you enlarge frame, the test fails. + Otherwise, it passes. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("FrameResizeTest_4 Instructions") + .instructions(INSTRUCTIONS) + .columns(45) + .testUI(FrameResizeTest_4::createTestUI) + .build() + .awaitAndCheck(); + } + + private static JFrame createTestUI() { + JFrame f = new JFrame("FrameResizeTest_4 Flickering Frame"); + + JPanel panel = new JPanel(new BorderLayout()); + panel.add(new JButton("West"), BorderLayout.WEST); + panel.add(new JButton("East"), BorderLayout.EAST); + panel.add(new JButton("North"), BorderLayout.NORTH); + panel.add(new JButton("South"), BorderLayout.SOUTH); + panel.add(new JButton("Center"), BorderLayout.CENTER); + f.setContentPane(panel); + + f.pack(); + f.setBounds(100, 50, 300, 200); + + return f; + } +} diff --git a/test/jdk/java/awt/Frame/FrameResizeTest/FrameResizeTest_5.java b/test/jdk/java/awt/Frame/FrameResizeTest/FrameResizeTest_5.java new file mode 100644 index 00000000000..5a43b755a52 --- /dev/null +++ b/test/jdk/java/awt/Frame/FrameResizeTest/FrameResizeTest_5.java @@ -0,0 +1,105 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Button; +import java.awt.Frame; +import java.awt.GridLayout; + +/* + * @test + * @summary Test to make sure non-resizable Frames can be resized with the + * setSize() method. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual FrameResizeTest_5 +*/ + +public class FrameResizeTest_5 { + private static final String INSTRUCTIONS = """ + This tests the programmatic resizability of non-resizable Frames. + Even when a Frame is set to be non-resizable, it should still be + programmatically resizable using the setSize() method. + + Initially the Frame will be resizable. Try using the "Smaller" + and "Larger" buttons to verify that the Frame resizes correctly. + Then, click the "Toggle" button to make the Frame non-resizable. + Again, verify that clicking the "Larger" and "Smaller" buttons + causes the Frame to get larger and smaller. If the Frame does + not change size, or does not re-layout correctly, the test fails. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("FrameResizeTest_5 Instructions") + .instructions(INSTRUCTIONS) + .columns(45) + .logArea(6) + .testUI(TestFrame::new) + .build() + .awaitAndCheck(); + } + + private static class TestFrame extends Frame { + Button bLarger, bSmaller, bCheck, bToggle; + + public TestFrame() { + super("Frame Resize Test"); + setSize(200, 200); + bLarger = new Button("Larger"); + bLarger.addActionListener(e -> { + setSize(400, 400); + validate(); + }); + bSmaller = new Button("Smaller"); + bSmaller.addActionListener(e -> { + setSize(200, 100); + validate(); + }); + bCheck = new Button("Resizable?"); + bCheck.addActionListener(e -> { + if (isResizable()) { + PassFailJFrame.log("Frame is resizable"); + setResizable(true); + } else { + PassFailJFrame.log("Frame is not resizable"); + setResizable(false); + } + }); + bToggle = new Button("Toggle"); + bToggle.addActionListener(e -> { + if (isResizable()) { + PassFailJFrame.log("Frame is now not resizable"); + setResizable(false); + } else { + PassFailJFrame.log("Frame is now resizable"); + setResizable(true); + } + }); + setLayout(new GridLayout(4, 1)); + add(bSmaller); + add(bLarger); + add(bCheck); + add(bToggle); + } + } +} diff --git a/test/jdk/java/awt/Frame/FrameSetCursorTest.java b/test/jdk/java/awt/Frame/FrameSetCursorTest.java new file mode 100644 index 00000000000..98968a8fbab --- /dev/null +++ b/test/jdk/java/awt/Frame/FrameSetCursorTest.java @@ -0,0 +1,100 @@ +/* + * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.Cursor; +import java.awt.Frame; +import java.awt.Panel; +import java.awt.event.ActionListener; +import java.lang.Exception; +import java.lang.InterruptedException; +import java.lang.Object; +import java.lang.String; +import java.lang.Thread; + +/* + * @test + * @bug 4097226 + * @summary Frame.setCursor() sometimes doesn't update the cursor until user moves the mouse + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual FrameSetCursorTest + */ + +public class FrameSetCursorTest { + private static final String INSTRUCTIONS = """ + 1. Keep the instruction dialog and TestFrame side by side so that + you can read the instructions while doing the test + 2. Click on the 'Start Busy' button on the frame titled 'TestFrame' + and DO NOT MOVE THE MOUSE ANYWHERE till you complete the steps below + 3. The cursor on the TestFrame changes to busy cursor + 4. If you don't see the busy cursor press 'Fail' after + the `done sleeping` message + 5. If the busy cursor is seen, after 5 seconds the message + 'done sleeping' is displayed in the message window + 6. Check for the cursor type after the display of 'done sleeping' + 7. If the cursor on the TestFrame has changed back to default cursor + (without you touching or moving the mouse), then press 'Pass' + else if the frame still shows the busy cursor press 'Fail' + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("FrameSetCursorTest Instructions") + .instructions(INSTRUCTIONS) + .columns(45) + .testUI(FrameSetCursorTest::createAndShowUI) + .logArea(5) + .build() + .awaitAndCheck(); + + } + + static Frame createAndShowUI() { + Frame frame = new Frame("TestFrame"); + Panel panel = new Panel(); + Button busyButton = new Button("Start Busy"); + + ActionListener actionListener = event -> { + Object source = event.getSource(); + if (source == busyButton) { + frame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + try { + Thread.sleep(5000); + } catch (InterruptedException ignored) {} + PassFailJFrame.log("done sleeping"); + frame.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); + } + }; + + busyButton.addActionListener(actionListener); + panel.setLayout(new BorderLayout()); + panel.add("North", busyButton); + + frame.add(panel); + frame.pack(); + frame.setSize(200, 200); + return frame; + } +} \ No newline at end of file diff --git a/test/jdk/java/awt/Frame/FrameSetMinimumSizeTest.java b/test/jdk/java/awt/Frame/FrameSetMinimumSizeTest.java new file mode 100644 index 00000000000..929a36e773e --- /dev/null +++ b/test/jdk/java/awt/Frame/FrameSetMinimumSizeTest.java @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.Frame; + +/* + * @test + * @bug 4320050 + * @key headful + * @summary Minimum size for java.awt.Frame is not being enforced. + * @run main FrameSetMinimumSizeTest + */ + +public class FrameSetMinimumSizeTest { + private static Frame f; + private static volatile boolean passed; + + public static void main(String[] args) throws Exception { + EventQueue.invokeAndWait(() -> { + try { + createAndShowUI(); + + f.setSize(200, 200); + passed = verifyFrameSize(new Dimension(300, 300)); + isFrameSizeOk(passed); + + f.setSize(200, 400); + passed = verifyFrameSize(new Dimension(300, 400)); + isFrameSizeOk(passed); + + f.setSize(400, 200); + passed = verifyFrameSize(new Dimension(400, 300)); + isFrameSizeOk(passed); + + f.setMinimumSize(null); + + f.setSize(200, 200); + passed = verifyFrameSize(new Dimension(200, 200)); + isFrameSizeOk(passed); + } finally { + if (f != null) { + f.dispose(); + } + } + }); + } + + private static void createAndShowUI() { + f = new Frame("Minimum Size Test"); + f.setSize(300, 300); + f.setMinimumSize(new Dimension(300, 300)); + f.setVisible(true); + } + + private static boolean verifyFrameSize(Dimension expected) { + + if (f.getSize().width != expected.width || f.getSize().height != expected.height) { + return false; + } + return true; + } + + private static void isFrameSizeOk(boolean passed) { + if (!passed) { + throw new RuntimeException("Frame's setMinimumSize not honoured for the" + + " frame size: " + f.getSize()); + } + } +} diff --git a/test/jdk/java/awt/Frame/FrameVisualTest.java b/test/jdk/java/awt/Frame/FrameVisualTest.java new file mode 100644 index 00000000000..767eb0a1896 --- /dev/null +++ b/test/jdk/java/awt/Frame/FrameVisualTest.java @@ -0,0 +1,117 @@ +/* + * Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.GraphicsConfiguration; +import java.awt.GraphicsEnvironment; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.Robot; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; +import javax.imageio.ImageIO; + +/* + * @test + * @bug 4328588 + * @key headful + * @summary Non-default visual on top-level Frame should work + * @run main FrameVisualTest + */ + +public class FrameVisualTest { + private static GraphicsConfiguration[] gcs; + private static volatile Frame[] frames; + private static volatile int index; + + private static Frame f; + private static Robot robot; + private static volatile Point p; + private static volatile Dimension d; + private static final int TOLERANCE = 5; + + public static void main(String[] args) throws Exception { + gcs = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getConfigurations(); + robot = new Robot(); + robot.setAutoDelay(100); + try { + EventQueue.invokeAndWait(() -> { + createAndShowUI(); + }); + robot.delay(1000); + System.out.println("frames.length: "+frames.length); + for (index = 0; index < frames.length; index++) { + EventQueue.invokeAndWait(() -> { + p = frames[index].getLocation(); + d = frames[index].getSize(); + }); + Rectangle rect = new Rectangle(p, d); + BufferedImage img = robot.createScreenCapture(rect); + if (chkImgBackgroundColor(img)) { + try { + ImageIO.write(img, "png", new File("Frame_" + index + ".png")); + } catch (IOException ignored) {} + throw new RuntimeException("Frame visual test failed with non-white background color"); + } + } + } finally { + for (index = 0; index < frames.length; index++) { + EventQueue.invokeAndWait(() -> { + if (frames[index] != null) { + frames[index].dispose(); + } + }); + } + } + } + + private static void createAndShowUI() { + frames = new Frame[gcs.length]; + for (int i = 0; i < frames.length; i++) { + frames[i] = new Frame("Frame w/ gc " + i, gcs[i]); + frames[i].setSize(100, 100); + frames[i].setUndecorated(true); + frames[i].setBackground(Color.WHITE); + frames[i].setVisible(true); + } + } + + private static boolean chkImgBackgroundColor(BufferedImage img) { + + // scan for mid-line and if it is non-white color then return true. + for (int x = 1; x < img.getWidth() - 1; ++x) { + Color c = new Color(img.getRGB(x, img.getHeight() / 2)); + if ((c.getRed() - Color.WHITE.getRed()) > TOLERANCE && + (c.getGreen() - Color.WHITE.getGreen()) > TOLERANCE && + (c.getBlue() - Color.WHITE.getBlue()) > TOLERANCE) { + return true; + } + } + return false; + } +} + diff --git a/test/jdk/java/awt/Frame/I18NTitle.java b/test/jdk/java/awt/Frame/I18NTitle.java new file mode 100644 index 00000000000..7127fc3dfbf --- /dev/null +++ b/test/jdk/java/awt/Frame/I18NTitle.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.BorderLayout; +import java.awt.Frame; +import java.awt.Label; +import java.awt.Window; + +/* + * @test + * @bug 6269884 4929291 + * @summary Tests that title which contains mix of non-English characters is displayed correctly + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual I18NTitle + */ + +public class I18NTitle { + private static final String INSTRUCTIONS = """ + You will see a frame with some title (S. Chinese, Cyrillic and German). + Please check if non-English characters are visible and compare + the visible title with the same string shown in the label + (it should not look worse than the label). + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("I18NTitle Instructions") + .instructions(INSTRUCTIONS) + .columns(50) + .testUI(I18NTitle::createAndShowGUI) + .build() + .awaitAndCheck(); + } + + private static Window createAndShowGUI() { + String s = "\u4e2d\u6587\u6d4b\u8bd5 \u0420\u0443\u0441\u0441\u043a\u0438\u0439 Zur\u00FCck"; + Frame frame = new Frame(s); + frame.setLayout(new BorderLayout()); + Label l = new Label(s); + frame.add(l); + frame.setSize(400, 100); + return frame; + } +} diff --git a/test/jdk/java/awt/Frame/IMStatusBar.java b/test/jdk/java/awt/Frame/IMStatusBar.java new file mode 100644 index 00000000000..7e882d01c70 --- /dev/null +++ b/test/jdk/java/awt/Frame/IMStatusBar.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.BorderLayout; +import java.awt.Frame; +import java.awt.Label; +import java.awt.Panel; +import java.awt.TextField; + +/* + * @test + * @bug 4113040 + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @summary Checks that IMStatusBar does not affect Frame layout + * @run main/manual/othervm -Duser.language=ja -Duser.country=JP IMStatusBar + */ + +public class IMStatusBar { + + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + If the window appears the right size, but then resizes so that the + status field overlaps the bottom label, press Fail; otherwise press Pass. + """; + + PassFailJFrame.builder() + .title("IMStatusBar Instruction") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(40) + .testUI(IMStatusBar::createUI) + .build() + .awaitAndCheck(); + } + + private static Frame createUI() { + Frame f = new Frame(); + Panel centerPanel = new Panel(); + f.setSize(200, 200); + f.setLayout(new BorderLayout()); + f.add(new Label("Top"), BorderLayout.NORTH); + f.add(centerPanel, BorderLayout.CENTER); + f.add(new Label("Bottom"), BorderLayout.SOUTH); + centerPanel.setLayout(new BorderLayout()); + centerPanel.add(new TextField("Middle"), BorderLayout.CENTER); + centerPanel.validate(); + return f; + } +} diff --git a/test/jdk/java/awt/Frame/InitialIconifiedTest.java b/test/jdk/java/awt/Frame/InitialIconifiedTest.java new file mode 100644 index 00000000000..4a8d9595665 --- /dev/null +++ b/test/jdk/java/awt/Frame/InitialIconifiedTest.java @@ -0,0 +1,138 @@ +/* + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 javax.imageio.ImageIO; +import java.awt.Color; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.Rectangle; +import java.awt.Robot; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; + +/* + * @test + * @key headful + * @bug 4851435 + * @summary Frame is not shown initially iconified after pack + */ + +public class InitialIconifiedTest { + + private static Frame backgroundFrame; + private static Frame testedFrame; + + private static final Rectangle backgroundFrameBounds = + new Rectangle(100, 100, 200, 200); + private static final Rectangle testedFrameBounds = + new Rectangle(150, 150, 100, 100); + + private static Robot robot; + + private static final StringBuilder FAILURES = new StringBuilder(); + + public static void main(String[] args) throws Exception { + robot = new Robot(); + try { + EventQueue.invokeAndWait(InitialIconifiedTest::initAndShowBackground); + robot.waitForIdle(); + robot.delay(500); + + test(false); + test(true); + } finally { + EventQueue.invokeAndWait(() -> { + backgroundFrame.dispose(); + testedFrame.dispose(); + }); + } + + if (!FAILURES.isEmpty()) { + throw new RuntimeException(FAILURES.toString()); + } + } + + private static void test(boolean isUndecorated) throws Exception { + String prefix = isUndecorated ? "undecorated" : "decorated"; + + EventQueue.invokeAndWait(() -> initAndShowTestedFrame(isUndecorated)); + // On macos, we can observe the animation of the window from the initial + // NORMAL state to the ICONIFIED state, + // even if the window was created in the ICONIFIED state. + // The following delay is commented out to capture this animation + // robot.waitForIdle(); + // robot.delay(500); + if (!testIfIconified(prefix + "_no_extra_delay")) { + FAILURES.append("Case %s frame with no extra delay failed\n" + .formatted(isUndecorated ? "undecorated" : "decorated")); + } + + EventQueue.invokeAndWait(() -> initAndShowTestedFrame(isUndecorated)); + robot.waitForIdle(); + robot.delay(500); + if (!testIfIconified(prefix + "_with_extra_delay")) { + FAILURES.append("Case %s frame with extra delay failed\n" + .formatted(isUndecorated ? "undecorated" : "decorated")); + } + } + + private static void initAndShowBackground() { + backgroundFrame = new Frame("DisposeTest background"); + backgroundFrame.setUndecorated(true); + backgroundFrame.setBackground(Color.RED); + backgroundFrame.setBounds(backgroundFrameBounds); + backgroundFrame.setVisible(true); + } + + private static void initAndShowTestedFrame(boolean isUndecorated) { + if (testedFrame != null) { + testedFrame.dispose(); + } + testedFrame = new Frame("Should have started ICONIC"); + if (isUndecorated) { + testedFrame.setUndecorated(true); + } + testedFrame.setExtendedState(Frame.ICONIFIED); + testedFrame.setBounds(testedFrameBounds); + testedFrame.setVisible(true); + } + + private static boolean testIfIconified(String prefix) { + BufferedImage bi = robot.createScreenCapture(backgroundFrameBounds); + int redPix = Color.RED.getRGB(); + + for (int x = 0; x < bi.getWidth(); x++) { + for (int y = 0; y < bi.getHeight(); y++) { + if (bi.getRGB(x, y) != redPix) { + try { + ImageIO.write(bi, "png", + new File(prefix + "_failure.png")); + } catch (IOException ignored) {} + return false; + } + } + } + return true; + } +} diff --git a/test/jdk/java/awt/Frame/InsetCorrectionTest.java b/test/jdk/java/awt/Frame/InsetCorrectionTest.java new file mode 100644 index 00000000000..1ea6f03b24b --- /dev/null +++ b/test/jdk/java/awt/Frame/InsetCorrectionTest.java @@ -0,0 +1,102 @@ +/* + * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.Menu; +import java.awt.MenuBar; +import java.awt.MenuItem; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +/* + * @test + * @bug 4091426 + * @key headful + * @summary Test inset correction when setVisible(true) BEFORE setSize(), setLocation() + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual InsetCorrectionTest + */ + +public class InsetCorrectionTest { + private static final String INSTRUCTIONS = """ + There is a frame of size 300x300 at location (100,100). + It has a menubar with one menu, 'File', but the frame + is otherwise empty. In particular, there should be no + part of the frame that is not shown in the background color. + Upon test completion, click Pass or Fail appropriately. + """; + + private static InsetCorrection testFrame; + + public static void main(String[] args) throws Exception { + EventQueue.invokeAndWait(() -> testFrame = new InsetCorrection()); + + try { + PassFailJFrame passFailJFrame = PassFailJFrame.builder() + .title("InsetCorrectionTest Instructions") + .instructions(INSTRUCTIONS) + .columns(45) + .logArea(3) + .build(); + EventQueue.invokeAndWait(() -> + PassFailJFrame.log("frame location: " + testFrame.getBounds())); + passFailJFrame.awaitAndCheck(); + } finally { + EventQueue.invokeAndWait(testFrame::dispose); + } + } + + static class InsetCorrection extends Frame + implements ActionListener { + MenuBar mb; + Menu file; + MenuItem cause_bug_b; + + public InsetCorrection() { + super("InsetCorrection"); + mb = new MenuBar(); + file = new Menu("File"); + mb.add(file); + cause_bug_b = new MenuItem("cause bug"); + file.add(cause_bug_b); + setMenuBar(mb); + cause_bug_b.addActionListener(this); + + // Making the frame visible before setSize and setLocation() + // are being called causes sometimes strange behaviour with + // JDK1.1.5G. The frame is then sometimes to large and the + // excess areas are drawn in black. This only happens + // sometimes. + setVisible(true); + setSize(300, 300); + setLocation(100, 100); + } + + public void actionPerformed(ActionEvent e) { + setVisible(false); + setVisible(true); + } + } +} diff --git a/test/jdk/java/awt/Frame/MenuBarOffsetTest.java b/test/jdk/java/awt/Frame/MenuBarOffsetTest.java new file mode 100644 index 00000000000..65a4a8ef4bd --- /dev/null +++ b/test/jdk/java/awt/Frame/MenuBarOffsetTest.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Insets; +import java.awt.Menu; +import java.awt.MenuBar; + +/* + * @test + * @bug 4180577 + * @summary offset problems with menus in frames: (2 * 1) should be (2 * menuBarBorderSize) + * @requires (os.family == "linux" | os.family == "windows") + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual MenuBarOffsetTest +*/ + +public class MenuBarOffsetTest { + private static final String INSTRUCTIONS = """ + If a menubar containing a menubar item labeled Test appears. + in a frame, and fits within the frame, press Pass, else press Fail. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("MenuBarOffsetTest Instructions") + .instructions(INSTRUCTIONS) + .columns(45) + .testUI(FrameTest::new) + .build() + .awaitAndCheck(); + } + + private static class FrameTest extends Frame { + public FrameTest() { + super("MenuBarOffsetTest FrameTest"); + MenuBar m = new MenuBar(); + setMenuBar(m); + Menu test = m.add(new Menu("Test")); + test.add("1"); + test.add("2"); + setSize(100, 100); + } + + public void paint(Graphics g) { + setForeground(Color.red); + Insets i = getInsets(); + Dimension d = getSize(); + System.err.println(getBounds()); + System.err.println("" + i); + + g.drawRect(i.left, i.top, + d.width - i.left - i.right - 1, + d.height - i.top - i.bottom - 1); + } + } +} diff --git a/test/jdk/java/awt/Frame/MenuCrash.java b/test/jdk/java/awt/Frame/MenuCrash.java new file mode 100644 index 00000000000..f68dd4ad000 --- /dev/null +++ b/test/jdk/java/awt/Frame/MenuCrash.java @@ -0,0 +1,168 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Button; +import java.awt.CheckboxMenuItem; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.Menu; +import java.awt.MenuBar; +import java.awt.MenuItem; +import java.awt.TextField; +import java.awt.Window; +import java.awt.event.ComponentAdapter; +import java.awt.event.ComponentEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.util.List; + +/* + * @test + * @bug 4133279 + * @summary Clicking in menu in inactive frame crashes application + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual MenuCrash + */ +public class MenuCrash { + + private static final String INSTRUCTIONS = """ + Two frames will appear, alternate between frames by clicking on the + menubar of the currently deactivated frame and verify no crash occurs. + + Try mousing around the menus and choosing various items to see the menu + item name reflected in the text field. Note that CheckBoxMenuItems do + not fire action events so the check menu item (Item 03) will not change + the field. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("MenuCrash Instructions") + .instructions(INSTRUCTIONS) + .columns(45) + .testUI(MenuCrash::createAndShowUI) + .positionTestUIRightRow() + .build() + .awaitAndCheck(); + } + + + private static List createAndShowUI() { + Frame frame1 = new MenuFrame("Frame 1 MenuCrash"); + Frame frame2 = new MenuFrame("Frame 2 MenuCrash"); + + frame1.setSize(300, 200); + frame2.setSize(300, 200); + + frame1.validate(); + frame2.validate(); + + return List.of(frame1, frame2); + } + + static class MenuFrame extends Frame { + private final TextField field; + + MenuFrame(String name) { + super(name); + setLayout(new FlowLayout()); + + Button removeMenus = new Button("Remove Menus"); + removeMenus.addActionListener(ev -> remove(getMenuBar())); + + Button addMenus = new Button("Add Menus"); + addMenus.addActionListener(ev -> setupMenus()); + + add(removeMenus); + add(addMenus); + field = new TextField(20); + add(field); + + addWindowListener( + new WindowAdapter() { + public void windowActivated(WindowEvent e) { + setupMenus(); + } + } + ); + + addComponentListener( + new ComponentAdapter() { + public void componentResized(ComponentEvent e) { + System.out.println(MenuFrame.this); + } + } + ); + + pack(); + } + + private void addMenuListeners() { + MenuBar menuBar = getMenuBar(); + + for (int nMenu = 0; nMenu < menuBar.getMenuCount(); nMenu++) { + Menu menu = menuBar.getMenu(nMenu); + for (int nMenuItem = 0; nMenuItem < menu.getItemCount(); nMenuItem++) { + MenuItem item = menu.getItem(nMenuItem); + item.addActionListener(ev -> field.setText(ev.getActionCommand())); + } + } + } + + private void setupMenus() { + MenuItem miSetLabel = new MenuItem("Item 01"); + MenuItem miSetEnabled = new MenuItem("Item 02"); + CheckboxMenuItem miSetState = new CheckboxMenuItem("Item 03"); + MenuItem miAdded = new MenuItem("Item 04 Added"); + + MenuBar menuBar = new MenuBar(); + Menu menu1 = new Menu("Menu 01"); + menu1.add(miSetLabel); + menu1.add(miSetEnabled); + menu1.add(miSetState); + menuBar.add(menu1); + setMenuBar(menuBar); + + // now that the peers are created, screw + // around with the menu items + miSetLabel.setLabel("Menu 01 - SetLabel"); + miSetEnabled.setEnabled(false); + miSetState.setState(true); + menu1.add(miAdded); + menu1.remove(miAdded); + menu1.addSeparator(); + menu1.add(miAdded); + + Menu menu2 = new Menu("Menu 02"); + menuBar.add(menu2); + menuBar.remove(menu2); + menuBar.add(menu2); + menu2.add(new MenuItem("Foo")); + menu1.setLabel("Menu Number 1"); + menu2.setLabel("Menu Number 2"); + + addMenuListeners(); + } + } +} diff --git a/test/jdk/java/awt/Frame/MinimumSizeTest.java b/test/jdk/java/awt/Frame/MinimumSizeTest.java new file mode 100644 index 00000000000..cfff77be5f9 --- /dev/null +++ b/test/jdk/java/awt/Frame/MinimumSizeTest.java @@ -0,0 +1,114 @@ +/* + * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import javax.imageio.ImageIO; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.Robot; +import java.awt.Toolkit; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; + +/* + * @test + * @key headful + * @bug 1256759 + * @summary Checks that Frames with a very small size don't cause Motif + * to generate VendorShells which consume the entire desktop. + */ + +public class MinimumSizeTest { + + private static final Color BG_COLOR = Color.RED; + private static Frame backgroundFrame; + private static Frame testedFrame; + + private static Robot robot; + private static final Point location = new Point(200, 200); + private static final Point[] testPointLocations = { + new Point(100, 200), + new Point(200, 100), + new Point(450, 210), + new Point(210, 350), + }; + + public static void main(String[] args) throws Exception { + robot = new Robot(); + + try { + EventQueue.invokeAndWait(MinimumSizeTest::initAndShowGui); + robot.waitForIdle(); + robot.delay(500); + test(); + System.out.println("Test passed."); + } finally { + EventQueue.invokeAndWait(() -> { + backgroundFrame.dispose(); + testedFrame.dispose(); + }); + } + } + + private static void test() { + for (Point testLocation : testPointLocations) { + Color pixelColor = robot.getPixelColor(testLocation.x, testLocation.y); + + if (!pixelColor.equals(BG_COLOR)) { + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); + BufferedImage screenCapture = robot.createScreenCapture(new Rectangle(screenSize)); + try { + ImageIO.write(screenCapture, "png", new File("failure.png")); + } catch (IOException ignored) {} + throw new RuntimeException("Pixel color does not match expected color %s at %s" + .formatted(pixelColor, testLocation)); + } + } + } + + private static void initAndShowGui() { + backgroundFrame = new Frame("MinimumSizeTest background"); + backgroundFrame.setUndecorated(true); + backgroundFrame.setBackground(BG_COLOR); + backgroundFrame.setBounds(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize())); + backgroundFrame.setVisible(true); + + testedFrame = new MinimumSizeTestFrame(); + testedFrame.setVisible(true); + } + + private static class MinimumSizeTestFrame extends Frame { + public MinimumSizeTestFrame() { + super("MinimumSizeTest"); + setVisible(true); + setBackground(Color.BLUE); + setSize(0, 0); + setLocation(location); + } + } +} + diff --git a/test/jdk/java/awt/Frame/MultiScreenTest.java b/test/jdk/java/awt/Frame/MultiScreenTest.java new file mode 100644 index 00000000000..845f601138b --- /dev/null +++ b/test/jdk/java/awt/Frame/MultiScreenTest.java @@ -0,0 +1,485 @@ +/* + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.Canvas; +import java.awt.Choice; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.FontMetrics; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.GraphicsConfiguration; +import java.awt.GraphicsDevice; +import java.awt.GraphicsEnvironment; +import java.awt.Image; +import java.awt.Label; +import java.awt.LayoutManager; +import java.awt.Panel; +import java.awt.Rectangle; +import java.awt.RenderingHints; +import java.awt.TextField; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import java.awt.image.ColorModel; +import java.awt.image.MemoryImageSource; + +import java.util.ArrayList; +import java.util.List; + +import javax.swing.JFrame; + +import jtreg.SkippedException; + +/* + * @test + * @bug 4312921 + * @key multimon + * @library /java/awt/regtesthelpers /test/lib + * @build PassFailJFrame + * @summary Tests that no garbage is painted on primary screen with DGA + * @run main/manual MultiScreenTest + */ + +public class MultiScreenTest { + static GraphicsEnvironment ge; + static GraphicsDevice[] gs; + + public static void main(String[] args) throws Exception { + ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); + gs = ge.getScreenDevices(); + if (gs.length < 2) { + throw new SkippedException("You have only one monitor in your system - test passed"); + } + MultiScreenTest obj = new MultiScreenTest(); + String INSTRUCTIONS = + "This test is to be run only on multiscreen machine. " + + "You have " + gs.length + " monitors in your system.\n" + + "Actively drag the DitherTest frames on the secondary screen and " + + "if you see garbage appearing on your primary screen " + + "test failed otherwise it passed.";; + + PassFailJFrame.builder() + .title("MultiScreenTest Instruction") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(40) + .testUI(obj::init) + .build() + .awaitAndCheck(); + } + + public List init() { + List list = new ArrayList<>(); + for (int j = 0; j < gs.length; j++) { + GraphicsConfiguration[] gc = gs[j].getConfigurations(); + if (gc.length > 0) { + for (int i = 0; i < gc.length / 2; i++) { + JFrame f = new JFrame(gc[i]); //test JFrame( gc ) + GCCanvas c = new GCCanvas(gc[i]);//test canvas( gc ) + Rectangle gcBounds = gc[i].getBounds(); //test getBounds() + int xoffs = gcBounds.x; + int yoffs = gcBounds.y; + + f.getContentPane().add(c); + f.setTitle("Screen# " + Integer.toString(j) + ", GC#" + Integer.toString(i)); + f.setSize(300, 200); + f.setLocation(400 + xoffs, (i * 150) + yoffs);//test displaying in right location + list.add(f); + + Frame ditherfs = new Frame("DitherTest GC#" + Integer.toString(i), gc[i]); + ditherfs.setLayout(new BorderLayout()); //showDitherTest + DitherTest ditherTest = new DitherTest(gc[i]); + ditherfs.add("Center", ditherTest); + ditherfs.setBounds(300, 200, 300, 200); + ditherfs.setLocation(750 + xoffs, (i * 50) + yoffs); + ditherfs.pack(); + ditherfs.show(); + ditherTest.start(); + } + } + } + return list; + } +} + +class GCCanvas extends Canvas { + + GraphicsConfiguration gc; + Rectangle bounds; + Graphics g = this.getGraphics(); + Dimension size = getSize(); + + public GCCanvas(GraphicsConfiguration gc) { + super(gc); + this.gc = gc; + bounds = gc.getBounds(); + } + + public void paint( Graphics _g ) { + + Graphics2D g = (Graphics2D) _g; + + g.drawRect(0, 0, size.width-1, size.height-1); + g.setColor(Color.lightGray); + g.draw3DRect(1, 1, size.width-3, size.height-3, true); + + g.setColor(Color.red); + g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + + g.drawString("HELLO!", 110, 10); + + g.setColor(Color.blue); + g.drawString("ScreenSize="+Integer.toString(bounds.width)+"X"+ + Integer.toString(bounds.height), 10, 20); + g.setColor(Color.green); + g.drawString(gc.toString(), 10, 30); + g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); + + g.setColor(Color.orange); + g.fillRect(40, 20, 50, 50); + + g.setColor(Color.red); + g.drawRect(100, 20, 30, 30); + + g.setColor(Color.gray); + g.drawLine(220, 20, 280, 40); + + g.setColor(Color.cyan); + g.fillArc(150, 30, 30, 30, 0, 200); + } + + public Dimension getPreferredSize(){ + return new Dimension(300, 200); + } +} + +class DitherCanvas extends Canvas { + Image img; + static String calcString = "Calculating..."; + + GraphicsConfiguration mGC; + + public DitherCanvas(GraphicsConfiguration gc) { + super(gc); + mGC = gc; + } + + public GraphicsConfiguration getGraphicsConfig() { + return mGC; + } + + public void paint(Graphics g) { + int w = getSize().width; + int h = getSize().height; + if (img == null) { + super.paint(g); + g.setColor(Color.black); + FontMetrics fm = g.getFontMetrics(); + int x = (w - fm.stringWidth(calcString)) / 2; + int y = h / 2; + g.drawString(calcString, x, y); + } else { + g.drawImage(img, 0, 0, w, h, this); + } + } + + public void update(Graphics g) { + paint(g); + } + + public Dimension getMinimumSize() { + return new Dimension(20, 20); + } + + public Dimension getPreferredSize() { + return new Dimension(200, 200); + } + + public Image getImage() { + return img; + } + + public void setImage(Image img) { + this.img = img; + paint(getGraphics()); + } +} + +class DitherTest extends Panel implements Runnable { + final static int NOOP = 0; + final static int RED = 1; + final static int GREEN = 2; + final static int BLUE = 3; + final static int ALPHA = 4; + final static int SATURATION = 5; + + Thread runner; + + DitherControls XControls; + DitherControls YControls; + DitherCanvas canvas; + + public DitherTest(GraphicsConfiguration gc) { + String xspec, yspec; + int xvals[] = new int[2]; + int yvals[] = new int[2]; + + xspec = "red"; + yspec = "blue"; + int xmethod = colormethod(xspec, xvals); + int ymethod = colormethod(yspec, yvals); + + setLayout(new BorderLayout()); + XControls = new DitherControls(this, xvals[0], xvals[1], + xmethod, false); + YControls = new DitherControls(this, yvals[0], yvals[1], + ymethod, true); + YControls.addRenderButton(); + add("North", XControls); + add("South", YControls); + add("Center", canvas = new DitherCanvas(gc)); + } + + public void start() { + runner = new Thread(this); + runner.start(); + } + + int colormethod(String s, int vals[]) { + int method = NOOP; + + if (s == null) { + s = ""; + } + + String lower = s.toLowerCase(); + int len = 0; + if (lower.startsWith("red")) { + method = RED; + lower = lower.substring(3); + } else if (lower.startsWith("green")) { + method = GREEN; + lower = lower.substring(5); + } else if (lower.startsWith("blue")) { + method = BLUE; + lower = lower.substring(4); + } else if (lower.startsWith("alpha")) { + method = ALPHA; + lower = lower.substring(4); + } else if (lower.startsWith("saturation")) { + method = SATURATION; + lower = lower.substring(10); + } + + if (method == NOOP) { + vals[0] = 0; + vals[1] = 0; + return method; + } + + int begval = 0; + int endval = 255; + + try { + int dash = lower.indexOf('-'); + if (dash < 0) { + begval = endval = Integer.parseInt(lower); + } else { + begval = Integer.parseInt(lower.substring(0, dash)); + endval = Integer.parseInt(lower.substring(dash + 1)); + } + } catch (Exception e) { + } + + if (begval < 0) { + begval = 0; + } + if (endval < 0) { + endval = 0; + } + if (begval > 255) { + begval = 255; + } + if (endval > 255) { + endval = 255; + } + + vals[0] = begval; + vals[1] = endval; + + return method; + } + + void applymethod(int c[], int method, int step, int total, int vals[]) { + if (method == NOOP) + return; + int val = ((total < 2) + ? vals[0] + : vals[0] + ((vals[1] - vals[0]) * step / (total - 1))); + switch (method) { + case RED: + c[0] = val; + break; + case GREEN: + c[1] = val; + break; + case BLUE: + c[2] = val; + break; + case ALPHA: + c[3] = val; + break; + case SATURATION: + int max = Math.max(Math.max(c[0], c[1]), c[2]); + int min = max * (255 - val) / 255; + if (c[0] == 0) { + c[0] = min; + } + if (c[1] == 0) { + c[1] = min; + } + if (c[2] == 0) { + c[2] = min; + } + break; + } + } + + public void run() { + canvas.setImage(null); // Wipe previous image + Image img = calculateImage(); + synchronized (this) { + if (img != null && runner == Thread.currentThread()) { + canvas.setImage(img); + } + } + } + + /** + * Calculates and returns the image. Halts the calculation and returns + * null if stopped during the calculation. + */ + Image calculateImage() { + Thread me = Thread.currentThread(); + + int width = canvas.getSize().width; + int height = canvas.getSize().height; + int xvals[] = new int[2]; + int yvals[] = new int[2]; + int xmethod = XControls.getParams(xvals); + int ymethod = YControls.getParams(yvals); + int pixels[] = new int[width * height]; + int c[] = new int[4]; + int index = 0; + + for (int j = 0; j < height; j++) { + for (int i = 0; i < width; i++) { + c[0] = c[1] = c[2] = 0; + c[3] = 255; + if (xmethod < ymethod) { + applymethod(c, xmethod, i, width, xvals); + applymethod(c, ymethod, j, height, yvals); + } else { + applymethod(c, ymethod, j, height, yvals); + applymethod(c, xmethod, i, width, xvals); + } + pixels[index++] = ((c[3] << 24) | + (c[0] << 16) | + (c[1] << 8) | + (c[2] << 0)); + + } + // Poll once per row to see if we've been told to stop. + if (runner != me) { + return null; + } + } + + return createImage(new MemoryImageSource(width, height, + ColorModel.getRGBdefault(), pixels, 0, width)); + } + + public String getInfo() { + return "An interactive demonstration of dithering."; + } + + public String[][] getParameterInfo() { + String[][] info = { + {"xaxis", "{RED, GREEN, BLUE, PINK, ORANGE, MAGENTA, CYAN, WHITE, YELLOW, GRAY, DARKGRAY}", + "The color of the Y axis. Default is RED."}, + {"yaxis", "{RED, GREEN, BLUE, PINK, ORANGE, MAGENTA, CYAN, WHITE, YELLOW, GRAY, DARKGRAY}", + "The color of the X axis. Default is BLUE."} + }; + return info; + } +} + +class DitherControls extends Panel implements ActionListener { + TextField start; + TextField end; + Button button; + Choice choice; + DitherTest dt; + + static LayoutManager dcLayout = new FlowLayout(FlowLayout.CENTER, 10, 5); + + public DitherControls(DitherTest app, int s, int e, int type, + boolean vertical) { + dt = app; + setLayout(dcLayout); + add(new Label(vertical ? "Vertical" : "Horizontal")); + add(choice = new Choice()); + choice.addItem("Noop"); + choice.addItem("Red"); + choice.addItem("Green"); + choice.addItem("Blue"); + choice.addItem("Alpha"); + choice.addItem("Saturation"); + choice.select(type); + add(start = new TextField(Integer.toString(s), 4)); + add(end = new TextField(Integer.toString(e), 4)); + } + + public void addRenderButton() { + add(button = new Button("New Image")); + button.addActionListener(this); + } + + public int getParams(int vals[]) { + vals[0] = Integer.parseInt(start.getText()); + vals[1] = Integer.parseInt(end.getText()); + return choice.getSelectedIndex(); + } + + public void actionPerformed(ActionEvent e) { + if (e.getSource() == button) { + dt.start(); + } + } +} diff --git a/test/jdk/java/awt/Frame/PackTwiceTest.java b/test/jdk/java/awt/Frame/PackTwiceTest.java new file mode 100644 index 00000000000..63cd20612f0 --- /dev/null +++ b/test/jdk/java/awt/Frame/PackTwiceTest.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 java.awt.Frame; +import java.awt.TextField; + +/* + * @test + * @bug 4097744 + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @summary packing a frame twice stops it resizing + * @run main/manual PackTwiceTest + */ + +public class PackTwiceTest { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + 1. You would see a Frame titled 'TestFrame' + 2. The Frame displays a text as below: + 'I am a lengthy sentence...can you see me?' + 3. If you can see the full text without resizing the frame + using mouse, press 'Pass' else press 'Fail'."""; + + PassFailJFrame.builder() + .title("PackTwiceTest Instruction") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(40) + .testUI(PackTwiceTest::createUI) + .build() + .awaitAndCheck(); + } + + private static Frame createUI() { + Frame f = new Frame("PackTwiceTest TestFrame"); + TextField tf = new TextField(); + f.add(tf, "Center"); + tf.setText("I am a short sentence"); + f.pack(); + f.pack(); + tf.setText("I am a lengthy sentence...can you see me?"); + f.pack(); + f.requestFocus(); + return f; + } +} diff --git a/test/jdk/java/awt/GradientPaint/JerkyGradient.java b/test/jdk/java/awt/GradientPaint/JerkyGradient.java new file mode 100644 index 00000000000..dc33b9c185a --- /dev/null +++ b/test/jdk/java/awt/GradientPaint/JerkyGradient.java @@ -0,0 +1,125 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4221201 + * @summary Test where the gradient drawn should remain in sync with the + * rotating rectangle. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual JerkyGradient + */ + +import java.awt.Color; +import java.awt.Frame; +import java.awt.GradientPaint; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.Panel; +import java.awt.RenderingHints; +import java.awt.Shape; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; + +public class JerkyGradient extends Panel implements Runnable { + protected static Shape mShape; + protected static Paint mPaint; + protected static double mTheta; + static Thread animatorThread; + static BufferedImage mImg; + + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + Watch at least one full rotation of the rectangle. Check that + the gradient drawn remains in sync with the rotating + rectangle. If so, pass this test. Otherwise, fail this test. + """; + + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .columns(35) + .testUI(JerkyGradient::createUI) + .build() + .awaitAndCheck(); + } + + public static Frame createUI() { + Frame f = new Frame("Rotating Gradient Test"); + JerkyGradient jg = new JerkyGradient(); + f.add(jg); + f.setSize(200, 200); + return f; + } + + public JerkyGradient() { + mShape = new Rectangle2D.Double(60, 50, 80, 100); + mPaint = new GradientPaint(0, 0, Color.red, + 25, 25, Color.yellow, + true); + mImg = new BufferedImage(200, 200, BufferedImage.TYPE_INT_RGB); + + animatorThread = new Thread(this); + animatorThread.setPriority(Thread.MIN_PRIORITY); + animatorThread.start(); + } + + public synchronized void run() { + Thread me = Thread.currentThread(); + double increment = Math.PI / 36; + double twoPI = Math.PI * 2; + + while (animatorThread == me) { + mTheta = (mTheta + increment) % twoPI; + repaint(); + try { + wait(50); + } catch (InterruptedException ie) { + break; + } + } + } + + public void update(Graphics g) { + Graphics2D g2 = mImg.createGraphics(); + g2.setColor(getBackground()); + g2.fillRect(0, 0, 200, 200); + g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); + g2.rotate(mTheta, 100, 100); + g2.setPaint(Color.black); + g2.drawLine(100, 30, 100, 55); + g2.setPaint(mPaint); + g2.fill(mShape); + g2.setPaint(Color.black); + g2.draw(mShape); + paint(g); + g2.dispose(); + } + + public void paint(Graphics g) { + g.drawImage(mImg, 0, 0, null); + } +} diff --git a/test/jdk/java/awt/GradientPaint/ShearTest.java b/test/jdk/java/awt/GradientPaint/ShearTest.java new file mode 100644 index 00000000000..95a4e4a6dcd --- /dev/null +++ b/test/jdk/java/awt/GradientPaint/ShearTest.java @@ -0,0 +1,137 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4171820 + * @summary Checks that GradientPaint responds to shearing transforms correctly + * The gradients drawn should be parallel to the sides of the + * indicated anchor rectangle. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual ShearTest + */ + +import java.awt.Canvas; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.GradientPaint; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.GridLayout; +import java.awt.Panel; +import java.awt.Rectangle; +import java.awt.geom.AffineTransform; + +public class ShearTest { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + This test displays 2 rows each containing 4 gradient fills. Each + gradient fill is labeled depending on whether the line or lines + of the gradient should be truly vertical, truly horizontal, or + some slanted diagonal direction. The test passes if the direction + of each gradient matches its label. + """; + + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .columns(35) + .testUI(ShearTest::createUI) + .build() + .awaitAndCheck(); + } + + public static Frame createUI() { + Frame f = new Frame("Shear Gradient Test"); + f.setLayout(new GridLayout(0, 1)); + f.add(getPanelSet(false), "North"); + f.add(getPanelSet(true), "Center"); + f.setSize(500, 300); + return f; + } + + public static Panel getPanelSet(boolean horizontal) { + String direven = horizontal ? "Slanted" : "Vertical"; + String dirodd = horizontal ? "Horizontal" : "Slanted"; + + Panel p = new Panel(); + p.setLayout(new GridLayout(0, 4)); + p.add(new ShearCanvas(direven, false, horizontal, false, true)); + p.add(new ShearCanvas(dirodd, false, horizontal, true, false)); + p.add(new ShearCanvas(direven, true, horizontal, false, true)); + p.add(new ShearCanvas(dirodd, true, horizontal, true, false)); + + return p; + } + + public static class ShearCanvas extends Canvas { + public static final int GRADW = 30; + + public static final Rectangle anchor = + new Rectangle(-GRADW / 2, -GRADW / 2, GRADW, GRADW); + + public static final Color faintblue = new Color(0f, 0f, 1.0f, 0.35f); + + private AffineTransform txform; + private GradientPaint grad; + private String label; + + public ShearCanvas(String label, + boolean cyclic, boolean horizontal, + boolean shearx, boolean sheary) { + txform = new AffineTransform(); + if (shearx) { + txform.shear(-.5, 0); + } + if (sheary) { + txform.shear(0, -.5); + } + int relx = horizontal ? 0 : GRADW / 2; + int rely = horizontal ? GRADW / 2 : 0; + grad = new GradientPaint(-relx, -rely, Color.green, + relx, rely, Color.yellow, cyclic); + this.label = label; + } + + public void paint(Graphics g) { + Graphics2D g2d = (Graphics2D) g; + + AffineTransform at = g2d.getTransform(); + g2d.translate(75, 75); + g2d.transform(txform); + g2d.setPaint(grad); + g2d.fill(g.getClip()); + g2d.setColor(faintblue); + g2d.fill(anchor); + g2d.setTransform(at); + + Dimension d = getSize(); + g2d.setColor(Color.black); + g2d.drawRect(0, 0, d.width - 1, d.height - 1); + g2d.drawString(label, 5, d.height - 5); + g2d.dispose(); + } + } +} diff --git a/test/jdk/java/awt/Graphics2D/BasicStrokeValidate.java b/test/jdk/java/awt/Graphics2D/BasicStrokeValidate.java new file mode 100644 index 00000000000..251f14e5081 --- /dev/null +++ b/test/jdk/java/awt/Graphics2D/BasicStrokeValidate.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4363534 + * @summary This test verifies that setting a non-thin-line BasicStroke + * on a Graphics2D obtained from a BufferedImage will correctly validate + * the pipelines for the line-widening pipeline even if that is the only + * non-default attribute on the graphics. + * + */ + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Graphics2D; +import java.awt.image.BufferedImage; + +public class BasicStrokeValidate { + + public static final int TESTW = 100; + public static final int TESTH = 100; + + public static void main(String[] args) { + BufferedImage bi1 = createImage(false); + BufferedImage bi2 = createImage(true); + compare(bi1, bi2); // images should differ + } + + static BufferedImage createImage(boolean dashed) { + BufferedImage bi = new BufferedImage(TESTW, TESTH, BufferedImage.TYPE_INT_RGB); + Graphics2D g2d = bi.createGraphics(); + g2d.setColor(Color.white); + g2d.fillRect(0, 0, TESTW, TESTH); + g2d.setColor(Color.black); + if (dashed) { + g2d.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_SQUARE, + BasicStroke.JOIN_MITER, 10.0f, + new float[] {2.5f, 3.5f}, + 0.0f)); + } + g2d.drawRect(10, 10, TESTW-20, TESTH-20); + g2d.setStroke(new BasicStroke(10f)); + g2d.drawRect(20, 20, TESTW-40, TESTH-40); + return bi; + } + + static void compare(BufferedImage i1, BufferedImage i2) { + boolean same = true; + int w = i1.getWidth(), h = i1.getHeight(); + for (int y = 0; y < h; y++) { + for (int x = 0; x < w; x++) { + int p1 = i1.getRGB(x, y); + int p2 = i2.getRGB(x, y); + if (p1 != p2) { + same = false; + } + } + if (!same) { + break; + } + } + if (same) { + throw new RuntimeException("No difference"); + } + } +} diff --git a/test/jdk/java/awt/Graphics2D/DrawImageIAETest/DrawImageIAETest.java b/test/jdk/java/awt/Graphics2D/DrawImageIAETest/DrawImageIAETest.java new file mode 100644 index 00000000000..af7ebae72a6 --- /dev/null +++ b/test/jdk/java/awt/Graphics2D/DrawImageIAETest/DrawImageIAETest.java @@ -0,0 +1,169 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4191004 + * @summary Tests that no IllegalArgumentException is thrown when calling + * drawImage with certain conditions + * @key headful + */ + +import java.awt.AlphaComposite; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Image; +import java.awt.MediaTracker; +import java.awt.Toolkit; +import java.awt.geom.GeneralPath; +import java.awt.geom.Ellipse2D; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import javax.swing.JFrame; +import javax.swing.JPanel; + +public class DrawImageIAETest extends Frame { + + static String filename = "/duke.gif"; + private volatile Image dimg; + private volatile BufferedImage bimg; + static volatile DrawImageIAETest app; + static volatile JFrame jframe; + static volatile boolean passed = true; + static volatile Exception exception = null; + static volatile CountDownLatch imageLatch = new CountDownLatch(1); + + DrawImageIAETest(String title) { + super(title); + } + + public static void main(final String[] args) throws Exception { + EventQueue.invokeAndWait(DrawImageIAETest:: createUI); + imageLatch.await(3, TimeUnit.MILLISECONDS); + try { + if (!passed) { + throw new RuntimeException("Test FAILED: exception caught:" + exception); + } + } finally { + if (jframe != null) { + EventQueue.invokeAndWait(jframe::dispose); + } + if (app != null) { + EventQueue.invokeAndWait(app::dispose); + } + } + } + + static void createUI() { + app = new DrawImageIAETest("DrawImageIAETest"); + app.setLayout (new BorderLayout()); + app.setSize(200,200); + app.setLocationRelativeTo(null); + app.setVisible(true); + + String file; + try { + String dir = System.getProperty("test.src", + System.getProperty("user.dir")); + file = dir + filename; + } catch (Exception e) { + file = "." + filename; + } + + Image textureAlphaSource = null; + MediaTracker tracker = new MediaTracker(app); + app.dimg = Toolkit.getDefaultToolkit().getImage(file); + tracker.addImage(app.dimg, 1); + try { + tracker.waitForAll(); + imageLatch.countDown(); + } catch (Exception e) { + System.err.println("Can't load images"); + } + + if (app.dimg == null) { + passed = false; + return; + } + + jframe = new JFrame("Test DrawImageIAETest"); + jframe.setSize(300, 300); + JPanel jpanel; + jframe.getContentPane().add("Center", jpanel = new JPanel() { + public void paint(Graphics _g) { + Graphics2D g = (Graphics2D)_g; + Dimension d = getSize(); + Graphics2D g2 = app.createGraphics2D(d.width, d.height); + app.drawDemo(d.width, d.height, g2); + g2.dispose(); + g.drawImage(app.bimg, 0, 0, app); + } + }); + jpanel.setSize(140, 140); + jframe.setVisible(true); + } + + public void drawDemo(int w, int h, Graphics2D g2) { + GeneralPath p1 = new GeneralPath(); + GeneralPath p2 = new GeneralPath(); + + int dukeX = 73; + int dukeY = 26; + + double x = 118; + double y = 17; + double ew = 50; + double eh = 48; + + p1.append(new Ellipse2D.Double(x, y, ew, eh), false); + p2.append(new Rectangle2D.Double(x+5, y+5, ew-10, eh-10),false); + + g2.setClip(p1); + g2.clip(p2); + try { + g2.drawImage(dimg, dukeX, dukeY, null); + } catch (IllegalArgumentException e) { + passed = false; + exception = e; + } + } + + public Graphics2D createGraphics2D(int w, int h) { + Graphics2D g2 = null; + if (bimg == null || bimg.getWidth() != w || bimg.getHeight() != h) { + bimg = (BufferedImage) createImage(w, h); + } + g2 = bimg.createGraphics(); + g2.setBackground(getBackground()); + g2.clearRect(0, 0, w, h); + g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f)); + return g2; + } +} diff --git a/test/jdk/java/awt/Graphics2D/DrawImageIAETest/duke.gif b/test/jdk/java/awt/Graphics2D/DrawImageIAETest/duke.gif new file mode 100644 index 00000000000..ed32e0ff79b Binary files /dev/null and b/test/jdk/java/awt/Graphics2D/DrawImageIAETest/duke.gif differ diff --git a/test/jdk/java/awt/Graphics2D/ImageRendering/ImageRendering.java b/test/jdk/java/awt/Graphics2D/ImageRendering/ImageRendering.java new file mode 100644 index 00000000000..209a93e92d5 --- /dev/null +++ b/test/jdk/java/awt/Graphics2D/ImageRendering/ImageRendering.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4203598 + * @summary This test verifies that an image with transparent background can be displayed + * correctly with the red background color given. + * The correct display should be the sleeping Duke on a red background. + * + */ + +import java.awt.Color; +import java.awt.Graphics2D; +import java.awt.image.BufferedImage; +import java.io.File; +import javax.imageio.ImageIO; + +public class ImageRendering { + + public static void main(String[] args) throws Exception { + + String imgName = "snooze.gif"; + File file = new File(System.getProperty("test.src", "."), imgName); + BufferedImage image = ImageIO.read(file); + int w = image.getWidth(); + int h = image.getHeight(); + BufferedImage dest = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); + Graphics2D g2d = dest.createGraphics(); + g2d.drawImage(image, 0, 0, Color.red, null); + int redPixel = Color.red.getRGB(); + for (int y = 0; y < h; y++) { + for (int x = 0; x < w; x++) { + int srcPixel = image.getRGB(x, y); + if ((srcPixel & 0x0ff000000) == 0) { + int destPix = dest.getRGB(x, y); + if (destPix != redPixel) { + throw new RuntimeException("Not red at x=" + x + + " y=" + y + + "pix = " + Integer.toHexString(destPix)); + } + } + } + } + } +} diff --git a/test/jdk/java/awt/Graphics2D/ImageRendering/snooze.gif b/test/jdk/java/awt/Graphics2D/ImageRendering/snooze.gif new file mode 100644 index 00000000000..e357e316cdb Binary files /dev/null and b/test/jdk/java/awt/Graphics2D/ImageRendering/snooze.gif differ diff --git a/test/jdk/java/awt/Graphics2D/ScaledThinLineTest.java b/test/jdk/java/awt/Graphics2D/ScaledThinLineTest.java new file mode 100644 index 00000000000..fd4a5dd5e7c --- /dev/null +++ b/test/jdk/java/awt/Graphics2D/ScaledThinLineTest.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 4210466 4417756 + * @summary thin lines are not draw correctly under large scales + */ +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Graphics2D; +import java.awt.Shape; +import java.awt.image.BufferedImage; +import java.awt.geom.Ellipse2D; + +public class ScaledThinLineTest { + + public static void main(String[] args) { + ScaledThinLineTest c1 = new ScaledThinLineTest(200, 200); + ScaledThinLineTest c2 = new ScaledThinLineTest(1, 10000); + ScaledThinLineTest c3 = new ScaledThinLineTest(10000, 1); + ScaledThinLineTest c4 = new ScaledThinLineTest(0.01, 10000); + ScaledThinLineTest c5 = new ScaledThinLineTest(10000, 0.01); + compare(c1.bi, c2.bi); + compare(c2.bi, c3.bi); + compare(c3.bi, c4.bi); + compare(c4.bi, c5.bi); + } + + private final Shape shape; + private final double scaleX,scaleY; + private BufferedImage bi = null; + + public ScaledThinLineTest(double width, double height) { + shape = new Ellipse2D.Double(0.25*width, 0.25*height, width, height); + scaleX = 200/width; + scaleY = 200/height; + int iw = 300, ih = 300; + bi = new BufferedImage(iw, ih, BufferedImage.TYPE_INT_RGB); + Graphics2D g2 = bi.createGraphics(); + g2.setColor(Color.white); + g2.fillRect(0, 0, iw, ih); + g2.setColor(Color.black); + g2.scale(scaleX,scaleY); + g2.setStroke(new BasicStroke(0)); + g2.draw(shape); + } + + + static void compare(BufferedImage i1, BufferedImage i2) { + int w = i1.getWidth(), h = i1.getHeight(); + for (int y = 0; y < h; y++) { + for (int x = 0; x < w; x++) { + int p1 = i1.getRGB(x, y); + int p2 = i2.getRGB(x, y); + if (p1 != p2) { + System.out.println("images differ at " + x + " " + y); + } + } + } + } +} diff --git a/test/jdk/java/awt/Graphics2D/TextPerf.java b/test/jdk/java/awt/Graphics2D/TextPerf.java new file mode 100644 index 00000000000..d3e5cc2d4d0 --- /dev/null +++ b/test/jdk/java/awt/Graphics2D/TextPerf.java @@ -0,0 +1,159 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4190429 + * @key headful + * @summary In this bug, text drawing performance should be reasonable. + * And should (per string) be consistent with the size of the + * rectangle in which the string is drawn, not the rectangle + * bounding the whole window. + */ + +import java.awt.BorderLayout; +import java.awt.Canvas; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Panel; +import java.awt.RenderingHints; +import java.awt.Toolkit; +import java.awt.font.GlyphVector; +import java.awt.geom.AffineTransform; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + +public class TextPerf extends Canvas { + + static volatile CountDownLatch paintLatch = new CountDownLatch(1); + static volatile long paintTime = 5000; // causes test fail if it is not updated. + static volatile Frame frame; + + public static void main(String[] args) throws Exception { + EventQueue.invokeAndWait(TextPerf::createUI); + paintLatch.await(5, TimeUnit.SECONDS); + if (paintTime > 2000) { + throw new RuntimeException("Paint time is " + paintTime + "ms"); + } + if (frame != null) { + EventQueue.invokeAndWait(frame::dispose); + } + } + + static void createUI() { + frame = new Frame("TextPerf"); + frame.setLayout(new BorderLayout()); + TextPerf tp = new TextPerf(); + frame.add(tp, BorderLayout.CENTER); + frame.pack(); + frame.setVisible(true); + } + + public Dimension getPreferredSize() { + Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); + return new Dimension(d.width - 50, d.height - 50); + } + + static Font[] fonts = { + new Font(Font.SERIF, Font.PLAIN, 10), + new Font(Font.SANS_SERIF, Font.PLAIN, 10), + new Font(Font.MONOSPACED, Font.ITALIC, 10), + new Font(Font.SERIF, Font.PLAIN, 14), + new Font(Font.SERIF, Font.BOLD, 12), + }; + + public void paint(Graphics g1) { + + Graphics2D g = (Graphics2D)g1; + String text = "Hello,_Wgjpqy!"; + Toolkit.getDefaultToolkit().sync(); + long startTime = System.currentTimeMillis(); + FontMetrics[] cachedMetrics = new FontMetrics[fonts.length]; + Dimension size = getSize(); + int prim = 0; + int spaceWidth = 5; + Color cols[] = { Color.red, Color.blue, Color.yellow, + Color.green, Color.pink, Color.orange} ; + + for (int y = 20; y < size.height; y += 20) { + int i = 0; + for (int x = 0; x < size.width; i++) { + Font font = fonts[i % fonts.length]; + FontMetrics metrics = cachedMetrics[i % fonts.length]; + if (metrics == null) { + metrics = g.getFontMetrics(font); + cachedMetrics[i % fonts.length] = metrics; + } + + g.setFont(font); + g.setColor(cols[i % cols.length]); + switch (prim++) { + case 0: g.drawString(text, x, y); + break; + case 1: g.drawBytes(text.getBytes(), 0, text.length(), x, y); + break; + case 2: char[] chs= new char[text.length()]; + text.getChars(0,text.length(), chs, 0); + g.drawChars(chs, 0, text.length(), x, y); + break; + case 3: GlyphVector gv = font.createGlyphVector( + g.getFontRenderContext(), text); + g.drawGlyphVector(gv, (float)x, (float)y); + default: prim = 0; + } + + x += metrics.stringWidth(text) + spaceWidth; + } + } + + // Draw some transformed text to verify correct bounds calculated + AffineTransform at = AffineTransform.getTranslateInstance(50, 50); + at.scale(7.0,7.0); + at.rotate(1.0); + g.transform(at); + g.setColor(Color.black); + Font font = new Font(Font.SERIF, Font.PLAIN, 20); + RenderingHints hints = new RenderingHints(null); + hints.put(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); + g.setRenderingHints(hints); + g.setFont(font); + FontMetrics metrics = g.getFontMetrics(font); + g.drawString("Java", 5,5); + + Toolkit.getDefaultToolkit().sync(); + long endTime = System.currentTimeMillis(); + paintTime = endTime - startTime; + String msg = "repainted in " + paintTime + " milliseconds"; + System.out.println(msg); + System.out.flush(); + + paintLatch.countDown(); + } +} diff --git a/test/jdk/java/awt/GraphicsConfiguration/NonDefaultGC.java b/test/jdk/java/awt/GraphicsConfiguration/NonDefaultGC.java new file mode 100644 index 00000000000..fab80a461e2 --- /dev/null +++ b/test/jdk/java/awt/GraphicsConfiguration/NonDefaultGC.java @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4131642 + * @summary This test shows the ability to create Frames, Windows + * and Canvases with a GraphicsConfiguration. The test should show a number + * of windows with RGB stripes in according to the number of the + * GraphicsConfigurations for each screen. It also displays the size of + * the screen and the GraphicsConfiguration.toString(). + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual NonDefaultGC + */ + +import java.awt.Canvas; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.GraphicsConfiguration; +import java.awt.GraphicsDevice; +import java.awt.GraphicsEnvironment; +import java.awt.Rectangle; +import javax.swing.JFrame; +import javax.swing.SwingUtilities; + +public class NonDefaultGC { + + private static final String INSTRUCTIONS = """ + This test shows the ability to create Frames, Windows and Canvases + with a GraphicsConfiguration. + The test should show a number of windows with RGB stripes according + to the number of the GraphicsConfigurations for each screen. + The window also contains text which displays the size of the screen + and the output GraphicsConfiguration.toString(). + The test passes if every screen displays at least one such window. + """; + + public static void main(String[] argv) throws Exception { + SwingUtilities.invokeAndWait(NonDefaultGC::createUI); + PassFailJFrame.builder() + .title("GraphicsConfigurationTest") + .instructions(INSTRUCTIONS) + .testTimeOut(5) + .rows(12) + .columns(45) + .build() + .awaitAndCheck(); + + } + + private static void createUI() { + + GraphicsEnvironment ge = GraphicsEnvironment. + getLocalGraphicsEnvironment(); + GraphicsDevice[] gs = ge.getScreenDevices(); + for (int j = 0; j < gs.length; j++) { + GraphicsDevice gd = gs[j]; + GraphicsConfiguration[] gc = gd.getConfigurations(); + for (int i=0; i < gc.length; i++) { + JFrame f = new JFrame(gs[j].getDefaultConfiguration()); + PassFailJFrame.addTestWindow(f); // to ensure it is disposed. + GCCanvas c = new GCCanvas(gc[i]); + Rectangle gcBounds = gc[i].getBounds(); + int xoffs = gcBounds.x; + int yoffs = gcBounds.y; + f.getContentPane().add(c); + f.setTitle("Screen# "+ j +", GC# "+ i); + f.setSize(300, 150); + f.setLocation((i*50)+xoffs, (i*60)+yoffs); + f.show(); + } + } + } +} + +class GCCanvas extends Canvas { + + GraphicsConfiguration gc; + Rectangle bounds; + + public GCCanvas(GraphicsConfiguration gc) { + super(gc); + this.gc = gc; + bounds = gc.getBounds(); + } + + public Dimension getPreferredSize() { + return new Dimension(300, 150); + } + + public void paint(Graphics g) { + g.setColor(Color.red); + g.fillRect(0, 0, 100, 150); + g.setColor(Color.green); + g.fillRect(100, 0, 100, 150); + g.setColor(Color.blue); + g.fillRect(200, 0, 100, 150); + g.setColor(Color.black); + g.drawString("ScreenSize="+bounds.width+"X"+ bounds.height, 10, 15); + g.drawString(gc.toString(), 10, 30); + } +} diff --git a/test/jdk/java/awt/GraphicsConfiguration/Position.java b/test/jdk/java/awt/GraphicsConfiguration/Position.java new file mode 100644 index 00000000000..c2816705162 --- /dev/null +++ b/test/jdk/java/awt/GraphicsConfiguration/Position.java @@ -0,0 +1,94 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4271200 + * @summary This test should show that the default position of a Frame + * should be on the physical screen for the GraphicsConfiguration. + * The togglebutton shows and hides an empty frame on the second monitor. + * The frame should be positioned at 0, 0 and is shown and hidden by clicking the button. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual Position + */ + +import java.awt.GraphicsDevice; +import java.awt.GraphicsEnvironment; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JPanel; + +public class Position extends JPanel implements ActionListener { + + static final String INSTRUCTIONS = """ + This test should show that the default position of a Frame + should be on the physical screen for the specified GraphicsConfiguration. + There is a window "Show/Hide" button. + The button alternatively shows and hides an empty frame on the second monitor. + The frame should be positioned at 0, 0 and is shown and hidden by clicking the button. + The test passes if it behaves as described and fails otherwise. + """; + + static volatile GraphicsDevice gd[]; + static volatile JFrame secondFrame; + static volatile boolean on = true; + + public Position() { + JPanel p = new JPanel(); + JButton b = new JButton("Show/Hide Window on other screen"); + b.addActionListener(this); + p.add(b); + add(p); + } + + public void actionPerformed(ActionEvent e) { + if (secondFrame == null) { + secondFrame = new JFrame("screen1", gd[1].getDefaultConfiguration()); + secondFrame.setSize(500, 500); + PassFailJFrame.addTestWindow(secondFrame); + } + secondFrame.setVisible(on); + on = !on; + } + + public static void main(String[] args) throws Exception { + + gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices(); + if (gd.length < 2) { /* test runs only on a multi-screen environment */ + return; + } + + PassFailJFrame.builder() + .title("Screen Device Position Test") + .instructions(INSTRUCTIONS) + .testTimeOut(5) + .rows(10) + .columns(50) + .splitUIBottom(Position::new) + .build() + .awaitAndCheck(); + } +} diff --git a/test/jdk/java/awt/GraphicsEnvironment/DefaultScreenDeviceTest.java b/test/jdk/java/awt/GraphicsEnvironment/DefaultScreenDeviceTest.java new file mode 100644 index 00000000000..b59460322da --- /dev/null +++ b/test/jdk/java/awt/GraphicsEnvironment/DefaultScreenDeviceTest.java @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 java.awt.BorderLayout; +import java.awt.Button; +import java.awt.Color; +import java.awt.Frame; +import java.awt.GraphicsConfiguration; +import java.awt.GraphicsDevice; +import java.awt.GraphicsEnvironment; +import java.awt.Label; +import java.awt.Rectangle; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.util.List; + +/* + * @test + * @bug 4473671 + * @summary Test to verify GraphicsEnvironment.getDefaultScreenDevice always + * returning first screen + * @requires (os.family == "windows") + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual DefaultScreenDeviceTest + */ + +public class DefaultScreenDeviceTest { + private static Frame testFrame; + + public static void main(String[] args) throws Exception { + GraphicsEnvironment ge = GraphicsEnvironment. + getLocalGraphicsEnvironment(); + GraphicsDevice[] gds = ge.getScreenDevices(); + if (gds.length < 2) { + System.out.println("Test requires at least 2 displays"); + return; + } + + String INSTRUCTIONS = """ + 1. The test is for systems which allows primary display + selection in multiscreen systems. + Set the system primary screen to be the rightmost + (i.e. the right screen in two screen configuration) + This can be done by going to OS Display Settings + selecting the screen and checking the 'Use this device + as primary monitor' checkbox. + 2. When done, click on 'Frame on Primary Screen' button and + see where the frame will pop up + 3. If Primary Frame pops up on the primary display, + the test passed, otherwise it failed + """; + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(35) + .testUI(initialize()) + .build() + .awaitAndCheck(); + } + + private static List initialize() { + Frame frame = new Frame("Default screen device test"); + GraphicsConfiguration gc = + GraphicsEnvironment.getLocalGraphicsEnvironment(). + getDefaultScreenDevice().getDefaultConfiguration(); + + testFrame = new Frame("Primary screen frame", gc); + frame.setLayout(new BorderLayout()); + frame.setSize(200, 200); + + Button b = new Button("Frame on Primary Screen"); + b.addActionListener(e -> { + if (testFrame != null) { + testFrame.setVisible(false); + testFrame.dispose(); + } + + testFrame.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e1) { + testFrame.setVisible(false); + testFrame.dispose(); + } + }); + testFrame.add(new Label("This frame should be on the primary screen")); + testFrame.setBackground(Color.red); + testFrame.pack(); + Rectangle rect = gc.getBounds(); + testFrame.setLocation(rect.x + 100, rect.y + 100); + testFrame.setVisible(true); + }); + frame.add(b); + return List.of(testFrame, frame); + } +} diff --git a/test/jdk/java/awt/Label/ContainerValidateTest.java b/test/jdk/java/awt/Label/ContainerValidateTest.java new file mode 100644 index 00000000000..e379ebb606b --- /dev/null +++ b/test/jdk/java/awt/Label/ContainerValidateTest.java @@ -0,0 +1,169 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.Label; +import java.awt.Panel; +import java.awt.Rectangle; +import java.awt.Robot; +import java.awt.TextField; +import java.awt.event.InputEvent; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; + +/* + * @test + * @key headful + * @bug 4247913 + * @summary Tests that Label repaints after call Container.validate() + * @run main ContainerValidateTest + */ + +public class ContainerValidateTest extends Frame implements MouseListener { + private static Robot robot; + private static Panel currentPanel; + private static Button currentBtn; + private static Panel updatedPanel; + private static Label updatedLabel; + private static TextField updatedTxtField; + private static Button updatedBtn; + + private static volatile Rectangle btnBounds; + + Panel pnl1 = new Panel(); + Panel pnl2 = new Panel(); + Label lbl1 = new Label("Label 1"); + Label lbl2 = new Label("Label 2"); + TextField txt1 = new TextField("field1", 20); + TextField txt2 = new TextField("field2", 20); + Button btn1 = new Button("Swap 1"); + Button btn2 = new Button("Swap 2"); + + public static void main(String[] args) throws Exception { + robot = new Robot(); + + ContainerValidateTest containerValidate = new ContainerValidateTest(); + EventQueue.invokeAndWait(containerValidate::createAndShowUI); + robot.waitForIdle(); + robot.delay(1000); + + containerValidate.testUI(); + } + + private void createAndShowUI() { + this.setTitle("ContainerValidateTest Test"); + pnl1.add(lbl1); + pnl1.add(txt1); + pnl1.add(btn1); + + pnl2.add(lbl2); + pnl2.add(txt2); + pnl2.add(btn2); + + btn1.addMouseListener(this); + btn2.addMouseListener(this); + + this.add(pnl1, BorderLayout.CENTER); + pack(); + setLocationRelativeTo(null); + setVisible(true); + } + + private void testUI() throws Exception { + EventQueue.invokeAndWait(() -> btnBounds + = new Rectangle(btn1.getLocationOnScreen().x, + btn1.getLocationOnScreen().y, + btn1.getWidth(), + btn1.getHeight())); + for (int i= 1; i < 4 ; i++) { + EventQueue.invokeAndWait(() -> { + currentPanel = (Panel) this.getComponent(0); + currentBtn = (Button) currentPanel.getComponent(2); + }); + + robot.mouseMove(btnBounds.x + (int) btnBounds.getWidth() / 2, + btnBounds.y + (int) btnBounds.getHeight() / 2); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.waitForIdle(); + //large delay set for completion of UI validate() + robot.delay(500); + + EventQueue.invokeAndWait(() -> { + updatedPanel = (Panel) this.getComponent(0); + updatedLabel = (Label) updatedPanel.getComponent(0); + updatedTxtField = (TextField) updatedPanel.getComponent(1); + updatedBtn = (Button) updatedPanel.getComponent(2); + }); + testPanelComponents(currentBtn.getLabel()); + } + } + + private void testPanelComponents(String btnLabel) { + if (btnLabel.equals("Swap 1")) { + if (!(updatedLabel.getText().equals(lbl2.getText()) + && updatedTxtField.getText().equals(txt2.getText()) + && updatedBtn.getLabel().equals(btn2.getLabel()))) { + throw new RuntimeException("Test Failed!! Labels not repainted" + + " after Container.validate()"); + } + } else { + if (!(updatedLabel.getText().equals(lbl1.getText()) + && updatedTxtField.getText().equals(txt1.getText()) + && updatedBtn.getLabel().equals(btn1.getLabel()))) { + throw new RuntimeException("Test Failed!! Labels not repainted" + + " after Container.validate()"); + } + } + } + + @Override + public void mousePressed(MouseEvent evt) { + if (evt.getComponent() instanceof Button btn) { + if (btn.equals(btn1)) { + remove(pnl1); + add(pnl2, BorderLayout.CENTER); + } else { + remove(pnl2); + add(pnl1, BorderLayout.CENTER); + } + invalidate(); + validate(); + } + } + + @Override + public void mouseReleased(MouseEvent e) {} + + @Override + public void mouseEntered(MouseEvent e) {} + + @Override + public void mouseExited(MouseEvent e) {} + + @Override + public void mouseClicked(MouseEvent e) {} +} diff --git a/test/jdk/java/awt/LightweightComponent/LWParentMovedTest/LWParentMovedTest.java b/test/jdk/java/awt/LightweightComponent/LWParentMovedTest/LWParentMovedTest.java new file mode 100644 index 00000000000..d46af3a0d5e --- /dev/null +++ b/test/jdk/java/awt/LightweightComponent/LWParentMovedTest/LWParentMovedTest.java @@ -0,0 +1,99 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4147246 + * @summary Simple check for peer != null in Component.componentMoved + * @key headful + * @run main LWParentMovedTest + */ + +import java.awt.Button; +import java.awt.Color; +import java.awt.Container; +import java.awt.EventQueue; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.Graphics; + +public class LWParentMovedTest { + static CMTFrame f; + + // test will throw an exception and fail if lwc is null + public static void main(String[] args) throws Exception { + try { + EventQueue.invokeAndWait(() -> f = new CMTFrame()); + } finally { + if (f != null) { + EventQueue.invokeAndWait(() -> f.dispose()); + } + } + } +} + +class CMTFrame extends Frame { + Container lwc; + Button button; + + public CMTFrame() { + super("Moving LWC Test"); + setLayout(new FlowLayout()); + lwc = new LWSquare(Color.blue, 100, 100); + button = new Button(); + lwc.add(button); + add(lwc); + + setSize(400, 300); + setVisible(true); + + // queue up a bunch of COMPONENT_MOVED events + for (int i = 0; i < 1000; i++) { + lwc.setLocation(i, i); + } + + // remove heavyweight from lightweight container + lwc.remove(button); + } +} + +// +// Lightweight container +// +class LWSquare extends Container { + int width; + int height; + + public LWSquare(Color color, int w, int h) { + setBackground(color); + setLayout(new FlowLayout()); + width = w; + height = h; + setName("LWSquare-" + color.toString()); + } + + public void paint(Graphics g) { + g.setColor(getBackground()); + g.fillRect(0, 0, 1000, 1000); + } +} diff --git a/test/jdk/java/awt/LightweightComponent/LightWeightTabFocus/LightWeightTabFocus.java b/test/jdk/java/awt/LightweightComponent/LightWeightTabFocus/LightWeightTabFocus.java new file mode 100644 index 00000000000..05889580fd4 --- /dev/null +++ b/test/jdk/java/awt/LightweightComponent/LightWeightTabFocus/LightWeightTabFocus.java @@ -0,0 +1,154 @@ +/* + * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 4095214 + * @summary Test change of focus on lightweights using the tab key + * @key headful + * @run main LightWeightTabFocus + */ + +import java.awt.Button; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Point; +import java.awt.Robot; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.awt.event.InputEvent; +import java.awt.event.KeyEvent; + +public class LightWeightTabFocus { + private static Frame f; + private static LightweightButton btn1; + private static Button btn2; + private static Robot robot; + private static volatile Point point; + private static Point loc; + + public static void main(String[] args) throws Exception { + robot = new Robot(); + robot.setAutoDelay(100); + try { + EventQueue.invokeAndWait(() -> createUI()); + robot.delay(1000); + EventQueue.invokeAndWait(() -> { + loc = f.getLocation(); + point = btn2.getLocation(); + }); + robot.mouseMove(loc.x + point.x, loc.y + point.y); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + // First TAB + robot.keyPress(KeyEvent.VK_TAB); + robot.keyRelease(KeyEvent.VK_TAB); + if (!btn1.hasFocus()) { + new RuntimeException("First tab failed"); + } + // Second TAB + robot.keyPress(KeyEvent.VK_TAB); + robot.keyRelease(KeyEvent.VK_TAB); + if (!btn2.hasFocus()) { + new RuntimeException("Second tab failed"); + } + // First SHIFT+TAB + robot.keyPress(KeyEvent.VK_SHIFT); + robot.keyPress(KeyEvent.VK_TAB); + robot.delay(100); + robot.keyRelease(KeyEvent.VK_TAB); + robot.keyRelease(KeyEvent.VK_SHIFT); + if (!btn1.hasFocus()) { + new RuntimeException("First shift+tab failed"); + } + // Second SHIFT+TAB + robot.keyPress(KeyEvent.VK_SHIFT); + robot.keyPress(KeyEvent.VK_TAB); + robot.delay(100); + robot.keyRelease(KeyEvent.VK_TAB); + robot.keyRelease(KeyEvent.VK_SHIFT); + if (!btn2.hasFocus()) { + new RuntimeException("Second shift+tab failed"); + } + + } catch (Exception e) { + e.printStackTrace(); + } finally { + EventQueue.invokeAndWait(() -> { + if (f != null) { + f.dispose(); + } + }); + } + } + + private static Frame createUI() { + f = new Frame("TAB Focus Change on LW Test"); + f.setLayout(new FlowLayout()); + btn1 = new LightweightButton(); + f.add(btn1); + btn2 = new Button("Click Me To start"); + f.add(btn2); + f.pack(); + f.setVisible(true); + return f; + } +} + +class LightweightButton extends Component implements FocusListener { + boolean focus; + LightweightButton() { + focus = false; + addFocusListener(this); + } + + public Dimension getPreferredSize() + { + return new Dimension(100, 100); + } + + public void focusGained(FocusEvent e) { + focus = true; + repaint(); + } + + public void focusLost(FocusEvent e) { + focus = false; + repaint(); + } + + public void paint(Graphics g) { + if (focus) { + g.drawString("Has Focus", 10, 20); + } else { + g.drawString("Not Focused", 10, 20); + } + } + + public boolean isFocusable() { + return true; + } +} diff --git a/test/jdk/java/awt/LightweightComponent/LightweightFontTest/LightweightFontTest.java b/test/jdk/java/awt/LightweightComponent/LightweightFontTest/LightweightFontTest.java new file mode 100644 index 00000000000..4fd90656d61 --- /dev/null +++ b/test/jdk/java/awt/LightweightComponent/LightweightFontTest/LightweightFontTest.java @@ -0,0 +1,182 @@ +/* + * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4077709 4153989 + * @summary Lightweight component font settable test + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual LightweightFontTest + */ + +import java.awt.Button; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.Frame; +import java.awt.Graphics; + + +public class LightweightFontTest { + static Font desiredFont = null; + + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + [ There are 7 steps to this test ] + 1. The 2 bordered labels (Emacs vs. vi) should be in a LARGE font + (approximately 1/2 inch tall) + 2. The labels should not overlap. + 3. Each button should be large enough to contain the entire label. + 4. The labels should have red backgrounds + 5. The text in the left label should be blue and the right yellow + 6. Resize the window to make it much smaller and larger + 7. The buttons should never overlap, and they should be large + enough to contain the entire label. + (although the button may disappear if there is not enough + room in the window)" + """; + + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(35) + .testUI(LightweightFontTest::createUI) + .logArea(5) + .build() + .awaitAndCheck(); + } + + private static Frame createUI() { + Frame f = new Frame("Lightweight Font Test"); + f.setLayout(new FlowLayout()); + + desiredFont = new Font(Font.DIALOG, Font.PLAIN, 36); + Component component; + component = new BorderedLabel("Emacs or vi?"); + component.setFont(desiredFont); + component.setBackground(Color.red); + component.setForeground(Color.blue); + f.add(component); + component = new BorderedLabel("Vi or Emacs???"); + component.setFont(desiredFont); + component.setBackground(Color.red); + component.setForeground(Color.yellow); + f.add(component); + f.pack(); + return f; + } +} + +/** + * Lightweight component + */ +class BorderedLabel extends Component { + boolean superIsButton; + String labelString; + + BorderedLabel(String labelString) { + this.labelString = labelString; + + Component thisComponent = this; + superIsButton = (thisComponent instanceof Button); + if(superIsButton) { + ((Button)thisComponent).setLabel(labelString); + } + } + + public Dimension getMinimumSize() { + Dimension minSize = new Dimension(); + + if (superIsButton) { + minSize = super.getMinimumSize(); + } else { + + Graphics g = getGraphics(); + verifyFont(g); + FontMetrics metrics = g.getFontMetrics(); + + minSize.width = metrics.stringWidth(labelString) + 14; + minSize.height = metrics.getMaxAscent() + metrics.getMaxDescent() + 9; + + g.dispose(); + } + return minSize; + } + + public Dimension getPreferredSize() { + Dimension prefSize = new Dimension(); + if (superIsButton) { + prefSize = super.getPreferredSize(); + } else { + prefSize = getMinimumSize(); + } + return prefSize; + } + + public void paint(Graphics g) { + verifyFont(g); + super.paint(g); + if (superIsButton) { + return; + } + Dimension size = getSize(); + Color oldColor = g.getColor(); + + // draw border + g.setColor(getBackground()); + g.fill3DRect(0, 0, size.width, size.height, false); + g.fill3DRect(3, 3, size.width - 6, size.height - 6, true); + + // draw text + FontMetrics metrics = g.getFontMetrics(); + int centerX = size.width / 2; + int centerY = size.height / 2; + int textX = centerX - (metrics.stringWidth(labelString) / 2); + int textY = centerY + ((metrics.getMaxAscent() + + metrics.getMaxDescent()) / 2); + g.setColor(getForeground()); + g.drawString(labelString, textX, textY); + + g.setColor(oldColor); + } + + /** + * Verifies that the font is correct and prints a warning + * message and/or throws a RuntimeException if it is not. + */ + private void verifyFont(Graphics g) { + Font desiredFont = LightweightFontTest.desiredFont; + Font actualFont = g.getFont(); + if (!actualFont.equals(desiredFont)) { + PassFailJFrame.log("AWT BUG: FONT INFORMATION LOST!"); + PassFailJFrame.log(" Desired font: " + desiredFont); + PassFailJFrame.log(" Actual font: " + actualFont); + PassFailJFrame.forceFail(); + } + } +} diff --git a/test/jdk/java/awt/LightweightComponent/MultipleAddNotifyTest/MultipleAddNotifyTest.java b/test/jdk/java/awt/LightweightComponent/MultipleAddNotifyTest/MultipleAddNotifyTest.java new file mode 100644 index 00000000000..fbbc2ae6185 --- /dev/null +++ b/test/jdk/java/awt/LightweightComponent/MultipleAddNotifyTest/MultipleAddNotifyTest.java @@ -0,0 +1,118 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4058400 + * @summary Tests that calling addNotify on a lightweight component more than + * once does not break event dispatching for that component. + * @key headful + * @run main MultipleAddNotifyTest + */ + +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Robot; +import java.awt.event.InputEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +public class MultipleAddNotifyTest { + static volatile boolean passFlag; + static volatile int posX; + static volatile int posY; + static Frame f; + static LightComponent l; + + public static void main(String[] args) throws Exception { + Robot r; + try { + r = new Robot(); + r.setAutoWaitForIdle(true); + passFlag = false; + + EventQueue.invokeAndWait(() -> { + f = new Frame("Multiple addNotify Test"); + l = new LightComponent(); + f.setLayout(new FlowLayout()); + l.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + System.out.println("Mouse Clicked"); + passFlag = true; + } + }); + f.add(l); + f.addNotify(); + f.addNotify(); + + if (!l.isVisible()) { + throw new RuntimeException("Test failed. LW Component " + + "not visible."); + } + f.setSize(200, 200); + f.setLocationRelativeTo(null); + f.setVisible(true); + }); + r.waitForIdle(); + r.delay(1000); + + EventQueue.invokeAndWait(() -> { + posX = f.getX() + l.getWidth() + (l.getWidth() / 2); + posY = f.getY() + l.getHeight(); + }); + + r.mouseMove(posX, posY); + r.delay(500); + + r.mousePress(InputEvent.BUTTON1_DOWN_MASK); + r.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + r.delay(500); + + if (!passFlag) { + throw new RuntimeException("Test failed. MouseClicked event " + + "not working properly."); + } + } finally { + EventQueue.invokeAndWait(() -> { + if (f != null) { + f.dispose(); + } + }); + } + } +} + +class LightComponent extends Component { + public void paint(Graphics g) { + setSize(100, 100); + Dimension d = getSize(); + g.setColor(Color.red); + g.fillRect(0, 0, d.width, d.height); + } +} diff --git a/test/jdk/java/awt/LightweightComponent/PopupTest/PopupTest.java b/test/jdk/java/awt/LightweightComponent/PopupTest/PopupTest.java new file mode 100644 index 00000000000..beae4b4d904 --- /dev/null +++ b/test/jdk/java/awt/LightweightComponent/PopupTest/PopupTest.java @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 4476083 + * @summary Disabled components do not receive MouseEvent in Popups + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual PopupTest + */ + +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Frame; + +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JMenuItem; +import javax.swing.JPopupMenu; + +public class PopupTest { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + PopupMenus should disappear when a disabled component is + clicked. + + Step 1. Pop down the popup menu by clicking on it. + Step 2. Click on the disabled component to make the menu + disappear. + + If the menu disappears when the disabled component is clicked, + the test passes, otherwise, the test fails. + """; + + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .columns(35) + .testUI(PopupTest::createUI) + .build() + .awaitAndCheck(); + } + + private static Frame createUI() { + Frame f = new Frame("Disabled Component in Popup Test"); + f.setLayout(new BorderLayout()); + + JButton b = new JButton("step 1: press me to display menu"); + b.addActionListener(e -> { + JPopupMenu m = new JPopupMenu(); + m.add(new JMenuItem("item 1")); + m.add(new JMenuItem("item 2")); + m.add(new JMenuItem("item 3")); + m.add(new JMenuItem("item 4")); + m.add(new JMenuItem("item 5")); + m.add(new JMenuItem("item 6")); + m.show((Component) e.getSource(), 0, 10); + }); + + JLabel disabled = new JLabel("step 2: click me. the menu should be " + + "dismissed"); + disabled.setEnabled(false); + + JLabel enabled = new JLabel("step 3: there is no step 3"); + + f.add(BorderLayout.NORTH, b); + f.add(BorderLayout.CENTER, disabled); + f.add(BorderLayout.SOUTH, enabled); + f.setSize(300, 200); + return f; + } +} diff --git a/test/jdk/java/awt/List/ActionEventWhenHitEnterTest.java b/test/jdk/java/awt/List/ActionEventWhenHitEnterTest.java new file mode 100644 index 00000000000..232189ef53b --- /dev/null +++ b/test/jdk/java/awt/List/ActionEventWhenHitEnterTest.java @@ -0,0 +1,126 @@ +/* + * Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4234245 + * @summary the actionEvent is not invoked when hit enter on list. + * @key headful + * @run main ActionEventWhenHitEnterTest + */ + +import java.awt.BorderLayout; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.IllegalComponentStateException; +import java.awt.List; +import java.awt.Point; +import java.awt.Robot; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.InputEvent; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.event.KeyEvent; + +public class ActionEventWhenHitEnterTest + implements ActionListener, ItemListener { + + volatile boolean passed1; + volatile boolean passed2; + volatile Point pt; + List list; + Frame frame; + + public static void main(final String[] args) throws Exception { + ActionEventWhenHitEnterTest app = new ActionEventWhenHitEnterTest(); + app.doTest(); + } + + public ActionEventWhenHitEnterTest() { + list = new List(7); + for (int i = 0; i < 10; i++) { + list.add("Item " + i); + } + list.addItemListener(this); + list.addActionListener(this); + } + + public void actionPerformed(ActionEvent ae) { + passed1 = true; + System.out.println("--> Action event invoked: " + ae.getSource()); + } + + public void itemStateChanged(ItemEvent ie) { + passed2 = true; + System.out.println("--> Item state changed:" + ie.getSource()); + } + + public void doTest() throws Exception { + EventQueue.invokeAndWait(() -> { + frame = new Frame("ActionEventWhenHitEnterTest"); + frame.add(list); + frame.setSize(200, 200); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + }); + + try { + Robot robot = new Robot(); + robot.setAutoDelay(100); + robot.waitForIdle(); + robot.delay(1000); + + EventQueue.invokeAndWait(() -> { + pt = list.getLocationOnScreen(); + }); + + if (pt.x != 0 || pt.y != 0) { + robot.mouseMove(pt.x + list.getWidth() / 2, + pt.y + list.getHeight() / 2); + robot.waitForIdle(); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.waitForIdle(); + + robot.keyPress(KeyEvent.VK_ENTER); + robot.keyRelease(KeyEvent.VK_ENTER); + } + + robot.waitForIdle(); + } finally { + EventQueue.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + + if (!passed1 || !passed2) { + throw new RuntimeException("ActionEventWhenHitEnterTest FAILED"); + } + System.out.println("Test PASSED"); + + } + +} diff --git a/test/jdk/java/awt/List/DisabledListIsGreyTest.java b/test/jdk/java/awt/List/DisabledListIsGreyTest.java new file mode 100644 index 00000000000..ec1a2570666 --- /dev/null +++ b/test/jdk/java/awt/List/DisabledListIsGreyTest.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2006, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6354810 + * @summary Items in the list are not grayed out when disabled, XToolkit + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual DisabledListIsGreyTest +*/ + +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.List; + +public class DisabledListIsGreyTest { + + private static final String INSTRUCTIONS = """ + 1) After the test started you will see two lists. + 2) One of them is enabled, and the second is disabled. + 3) Check that the items of the disabled list are grayed. + 4) If so, the test passed. Otherwise, failed."""; + + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("DisabledListIsGreyTest Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(35) + .testUI(DisabledListIsGreyTest::createTestUI) + .build() + .awaitAndCheck(); + } + + private static Frame createTestUI() { + Frame frame = new Frame("DisabledListIsGreyTest Frame"); + frame.setLayout(new FlowLayout()); + + List list1 = new List(3); + List list2 = new List(3); + for (int i = 0; i < 5; i++) { + list1.addItem("Item " + i); + list2.addItem("Item " + i); + } + frame.add(list1); + + list2.setEnabled(false); + frame.add(list2); + frame.pack(); + return frame; + } + +} diff --git a/test/jdk/java/awt/List/HandlingKeyEventIfMousePressedTest.java b/test/jdk/java/awt/List/HandlingKeyEventIfMousePressedTest.java new file mode 100644 index 00000000000..e5c89c1df12 --- /dev/null +++ b/test/jdk/java/awt/List/HandlingKeyEventIfMousePressedTest.java @@ -0,0 +1,167 @@ +/* + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6293432 + * @summary Key events ('SPACE', 'UP', 'DOWN') aren't blocked + * if mouse is kept in 'PRESSED' state for List + * @key headful + * @run main HandlingKeyEventIfMousePressedTest + */ + +import java.awt.EventQueue; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.List; +import java.awt.Point; +import java.awt.Robot; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; +import java.awt.event.InputEvent; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.event.KeyEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseMotionAdapter; + +public class HandlingKeyEventIfMousePressedTest { + + static Frame frame; + static List list; + static volatile Point loc; + + public static void main(String[] args) throws Exception { + Robot robot = new Robot(); + robot.setAutoDelay(100); + try { + EventQueue.invokeAndWait(() -> createUI()); + robot.waitForIdle(); + robot.delay(1000); + EventQueue.invokeAndWait(() -> { + loc = list.getLocationOnScreen(); + }); + robot.mouseMove(loc.x + 10, loc.y + 10); + robot.waitForIdle(); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + + // key pressing when the mouse is kept in the 'pressed' state + robot.keyPress(KeyEvent.VK_DOWN); + robot.keyRelease(KeyEvent.VK_DOWN); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.waitForIdle(); + + int selectedIndex = list.getSelectedIndex(); + if (selectedIndex != 0) { + throw new RuntimeException("Test failed: list.getCurrentItem = " + selectedIndex); + } + } finally { + EventQueue.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } + + private static void createUI() { + frame = new Frame("HandlingKeyEventIfMousePressedTest"); + list = new List(10, false); + + list.add("111"); + list.add("222"); + list.add("333"); + list.add("444"); + frame.add(list); + + addListeners(); + + frame.setLayout(new FlowLayout()); + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } + + // added in order to have more information in failed case + private static void addListeners() { + + list.addMouseMotionListener( + new MouseMotionAdapter() { + @Override + public void mouseDragged(MouseEvent me) { + System.out.println(me); + } + + @Override + public void mouseMoved(MouseEvent me) { + System.out.println(me); + } + }); + + list.addMouseListener( + new MouseAdapter(){ + public void mousePressed(MouseEvent me) { + System.out.println(me); + } + public void mouseClicked(MouseEvent me) { + System.out.println(me); + } + public void mouseEntered(MouseEvent me) { + System.out.println(me); + } + public void mouseExited(MouseEvent me) { + System.out.println(me); + } + public void mouseReleased(MouseEvent me) { + System.out.println(me); + } + }); + + list.addActionListener( + new ActionListener() { + public void actionPerformed(ActionEvent ae) { + System.out.println(ae); + } + }); + + list.addItemListener( + new ItemListener() { + public void itemStateChanged(ItemEvent ie) { + System.out.println(ie); + } + }); + + list.addFocusListener( + new FocusAdapter() { + public void focusGained(FocusEvent fe) { + System.out.println(fe); + } + public void focusLost(FocusEvent fe) { + System.out.println(fe); + } + }); + } +} diff --git a/test/jdk/java/awt/List/HorizScrollWorkTest.java b/test/jdk/java/awt/List/HorizScrollWorkTest.java new file mode 100644 index 00000000000..6de1de1a4f2 --- /dev/null +++ b/test/jdk/java/awt/List/HorizScrollWorkTest.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2006, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6355467 + * @summary Horizontal scroll bar thumb of a List does not stay at the end + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @requires (os.family == "linux") + * @run main/manual HorizScrollWorkTest +*/ + +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.List; + +public class HorizScrollWorkTest { + + private static final String INSTRUCTIONS = """ + This is a linux only test. + Drag and drop the horizontal scroll bar thumb at the right end. + If the thumb does not stay at the right end, then the test failed. Otherwise passed."""; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("HorizScrollWorkTest Instructions") + .instructions(INSTRUCTIONS) + .rows((int)INSTRUCTIONS.lines().count() + 2) + .columns(35) + .testUI(HorizScrollWorkTest::createTestUI) + .build() + .awaitAndCheck(); + } + + private static Frame createTestUI() { + Frame frame = new Frame("HorizScrollWorkTest Frame"); + List list = new List(4); + + frame.setLayout (new FlowLayout()); + + list.add("veryyyyyyyyyyyyyyyyyyyyyyyyyy longgggggggggggggggggggggg stringggggggggggggggggggggg"); + + frame.add(list); + frame.pack(); + + return frame; + } +} diff --git a/test/jdk/java/awt/List/HorizScrollbarEraseTest.java b/test/jdk/java/awt/List/HorizScrollbarEraseTest.java new file mode 100644 index 00000000000..2601a7ed0b2 --- /dev/null +++ b/test/jdk/java/awt/List/HorizScrollbarEraseTest.java @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 4895367 + * @summary List scrolling w/ down arrow keys obscures horizontal scrollbar + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @requires (os.family == "linux") + * @run main/manual HorizScrollbarEraseTest + */ + +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.Frame; +import java.awt.GridLayout; +import java.awt.List; +import java.awt.Panel; +import java.awt.TextArea; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public class HorizScrollbarEraseTest { + + private static final String INSTRUCTIONS = """ + This is a Unix-only test. + Do the four mini-tests below. + If the horizontal scrollbar is ever erased by a rectangle + of the background color, the test FAILS. + If the horizontal scrollbars remain painted, test passes."""; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("HorizScrollbarEraseTest Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(35) + .testUI(HorizScrollbarEraseTest::createTestUI) + .build() + .awaitAndCheck(); + } + + private static Frame createTestUI() { + Frame frame = new Frame("HorizScrollbarEraseTest"); + Panel borderPanel = new Panel(); + borderPanel.setLayout(new BorderLayout()); + Button focusedButton = new Button("Focus starts here"); + borderPanel.add(focusedButton, BorderLayout.NORTH); + + Panel gridPanel = new Panel(); + gridPanel.setLayout(new GridLayout(0, 4)); + borderPanel.add(gridPanel, BorderLayout.CENTER); + + InstructionList il1 = new InstructionList("Tab to Item 2, then \n" + + "press the down" + + "arrow key to scroll down"); + il1.list.select(2); + il1.list.makeVisible(0); + gridPanel.add(il1); + + InstructionList il2 = new InstructionList("Tab to the next List,\n" + + "then press the down\n" + + "arrow key to select\n" + + "the last item."); + il2.list.select(3); + il2.list.makeVisible(0); + gridPanel.add(il2); + + InstructionList il3 = new InstructionList("Click the button to\n" + + "programmatically\n" + + "select item 3 (not showing)"); + Button selectBtn = new Button("Click Me"); + final List selectList = il3.list; + selectBtn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + selectList.select(3); + } + }); + il3.add(selectBtn, BorderLayout.CENTER); + gridPanel.add(il3); + + InstructionList il4 = new InstructionList("Click the button to\nprogrammatically\ndeselect item 3\n(not showing)"); + Button deselectBtn = new Button("Click Me"); + final List deselectList = il4.list; + deselectBtn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + deselectList.deselect(3); + } + }); + il4.add(deselectBtn, BorderLayout.CENTER); + il4.list.select(3); + il4.list.makeVisible(0); + gridPanel.add(il4); + + frame.add(borderPanel); + frame.pack(); + return frame; + + } +} + +class InstructionList extends Panel { + TextArea ta; + public List list; + + public InstructionList(String instructions) { + super(); + setLayout(new BorderLayout()); + ta = new TextArea(instructions, 6, 25, TextArea.SCROLLBARS_NONE); + ta.setFocusable(false); + list = new List(); + for (int i = 0; i < 5; i++) { + list.add("Item " + i + ", a long, long, long, long item"); + } + add(ta, BorderLayout.NORTH); + add(list, BorderLayout.SOUTH); + } +} diff --git a/test/jdk/java/awt/List/ListActionEventTest.java b/test/jdk/java/awt/List/ListActionEventTest.java new file mode 100644 index 00000000000..2cd8d04a39d --- /dev/null +++ b/test/jdk/java/awt/List/ListActionEventTest.java @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4089604 + * @summary Enter key doesn't fire List actionPerformed as specified + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual ListActionEventTest +*/ + +import java.awt.BorderLayout; +import java.awt.Frame; +import java.awt.List; +import java.awt.Panel; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; + +public class ListActionEventTest { + + private static final String INSTRUCTIONS = """ + A frame will be shown. + 1. Click any item in the list (say item 1) in the frame + 2. A message 'ItemSelected' is displayed on the message window. + 3. Press the return key on the selected item. + 4. If the text 'ActionPerformed' is displayed on the message window, + then press PASS else press FAIL."""; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("ListActionEventTest Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(35) + .testUI(ListActionEventTest::createTestUI) + .logArea() + .build() + .awaitAndCheck(); + } + + private static Frame createTestUI() { + Frame frame = new Frame("ListActionEventTest frame"); + + Panel pnl1 = new Panel(); + frame.add(pnl1); + pnl1.setLayout(new BorderLayout()); + + List list = new List(); + for (int i = 0; i < 5; i++) { + list.addItem("Item " + i); + } + pnl1.add(list); + + list.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent ev) { + PassFailJFrame.log("ActionPerformed"); + } + }); + + list.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent ev) { + PassFailJFrame.log("ItemSelected"); + } + }); + frame.pack(); + return frame; + } +} diff --git a/test/jdk/java/awt/List/ListAddPerfTest.java b/test/jdk/java/awt/List/ListAddPerfTest.java new file mode 100644 index 00000000000..7ff3eaf882c --- /dev/null +++ b/test/jdk/java/awt/List/ListAddPerfTest.java @@ -0,0 +1,99 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4117288 + * @summary JDKversion1.2beta3-J List's add() method is much slower. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual ListAddPerfTest + */ + +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.Frame; +import java.awt.List; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public class ListAddPerfTest { + + static Button button; + static List list; + + private static final String INSTRUCTIONS = """ + It is used to check the performance of List add operation. + + Instructions: + Click on the Remove All button. + The list should be cleared. + The button is now named "Add Items". + Click on the "Add Items" button. + 800 items should be added to the list. + Notice not only how fast or slow this is, but also how + 'smooth' it goes as well i.e. without any flashing. + + Press pass if the list performance is acceptable."""; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("ListAddPerfTest Instructions") + .instructions(INSTRUCTIONS) + .rows((int)INSTRUCTIONS.lines().count() + 2) + .columns(35) + .testUI(ListAddPerfTest::createTestUI) + .build() + .awaitAndCheck(); + } + + private static Frame createTestUI() { + Frame frame = new Frame("ListAddPerfTest"); + frame.setLayout(new BorderLayout()); + + button = new Button("Remove All"); + button.addActionListener((ActionEvent e) -> { + if (list.getItemCount() > 0) { + list.removeAll(); + list.invalidate(); + button.setLabel("Add Items"); + } else { + for (int i = 0; i < 800; i ++) { + list.add("My number is " + i); + } + button.setLabel("Remove All"); + } + }); + + list = new List(15); + for (int i = 0; i < 800; i ++) { + list.add("My number is " + i); + } + + frame.add("North", button); + frame.add("South", list); + + frame.pack(); + return frame; + } +} diff --git a/test/jdk/java/awt/List/ListFrameResizeTest.java b/test/jdk/java/awt/List/ListFrameResizeTest.java new file mode 100644 index 00000000000..4655e817da5 --- /dev/null +++ b/test/jdk/java/awt/List/ListFrameResizeTest.java @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4085379 + * @summary List component not properly "resized" with GridBagLayout + * @requires (os.family == "windows") + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual ListFrameResizeTest + */ + +import java.awt.Color; +import java.awt.Frame; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import java.awt.List; + +public class ListFrameResizeTest { + + private static final String INSTRUCTIONS = """ + This test is for windows only. + + 1. A Frame will appear with a List + (the List occupies the whole Frame) + 2. Minimize the Frame, the Frame is now in the Task Bar (ie.,iconified) + 3. Right click (right mouse button) the icon in the task bar + and click on the 'maximize' menuitem to maximize the Frame + 4. If you notice the List has not been resized + (ie.,if it partly occupies the Frame), then press FAIL else press PASS"."""; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("ListFrameResizeTest Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(35) + .testUI(ListFrameResizeTest::createTestUI) + .build() + .awaitAndCheck(); + } + + private static Frame createTestUI() { + wintest client = new wintest("ListFrameResizeTest Frame"); + client.resize(500, 300); + client.setBackground(Color.blue); + return client; + } + +} + +class wintest extends Frame { + private List msg; + + public wintest(String title) { + super(title); + msg = new List(); + for (int i = 0; i < 100; i++) { + msg.add("" + i); + } + + GridBagLayout gridbag = new GridBagLayout(); + GridBagConstraints constraints = new GridBagConstraints(); + + setLayout(gridbag); + + constraints.fill = GridBagConstraints.BOTH; + + constraints.anchor = GridBagConstraints.CENTER; + constraints.insets = new Insets(10, 10, 10, 10); + constraints.ipadx = 0; + constraints.ipady = 0; + constraints.weightx = 1; + constraints.weighty = 1; + constraints.gridx = 0; + constraints.gridy = 0; + constraints.gridwidth = GridBagConstraints.REMAINDER; + constraints.gridheight = GridBagConstraints.REMAINDER; + gridbag.setConstraints(msg, constraints); + add(msg); + } +} diff --git a/test/jdk/java/awt/List/MouseDraggedOriginatedByScrollBarTest.java b/test/jdk/java/awt/List/MouseDraggedOriginatedByScrollBarTest.java new file mode 100644 index 00000000000..600d38fe393 --- /dev/null +++ b/test/jdk/java/awt/List/MouseDraggedOriginatedByScrollBarTest.java @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6240151 + * @summary XToolkit: Dragging the List scrollbar initiates DnD + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual MouseDraggedOriginatedByScrollBarTest +*/ + +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.List; +import java.awt.event.MouseMotionAdapter; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +public class MouseDraggedOriginatedByScrollBarTest { + + private static final String INSTRUCTIONS = """ + 1) Click and drag the scrollbar of the list. + 2) Keep dragging till the mouse pointer goes out the scrollbar. + 3) The test failed if you see messages about events. The test passed if you don't."""; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("MouseDraggedOriginatedByScrollBarTest Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(35) + .testUI(MouseDraggedOriginatedByScrollBarTest::createTestUI) + .logArea() + .build() + .awaitAndCheck(); + } + + private static Frame createTestUI() { + Frame frame = new Frame(); + List list = new List(4, false); + + list.add("000"); + list.add("111"); + list.add("222"); + list.add("333"); + list.add("444"); + list.add("555"); + list.add("666"); + list.add("777"); + list.add("888"); + list.add("999"); + + frame.add(list); + + list.addMouseMotionListener( + new MouseMotionAdapter(){ + @Override + public void mouseDragged(MouseEvent me){ + PassFailJFrame.log(me.toString()); + } + }); + + list.addMouseListener( + new MouseAdapter() { + public void mousePressed(MouseEvent me) { + PassFailJFrame.log(me.toString()); + } + + public void mouseReleased(MouseEvent me) { + PassFailJFrame.log(me.toString()); + } + + public void mouseClicked(MouseEvent me){ + PassFailJFrame.log(me.toString()); + } + }); + + frame.setLayout(new FlowLayout()); + frame.pack(); + return frame; + } +} diff --git a/test/jdk/java/awt/List/MultiSelectionListCrashTest.java b/test/jdk/java/awt/List/MultiSelectionListCrashTest.java new file mode 100644 index 00000000000..b408a12ebba --- /dev/null +++ b/test/jdk/java/awt/List/MultiSelectionListCrashTest.java @@ -0,0 +1,89 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4201967 + * @summary tests that a multiselection list doesn't causes crash when FileDialog is invoked + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual MultiSelectionListCrashTest + */ + +import java.awt.Button; +import java.awt.FileDialog; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.List; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public class MultiSelectionListCrashTest { + + private static final String INSTRUCTIONS = """ + Press "Invoke dialog" button to invoke a FileDialog. + When it appears close it by pressing cancel button. + If all remaining frames are enabled and + page fault didn't occur the test passed. Otherwise the test failed. + + Try to invoke a FileDialog several times to verify that the bug doesn't exist."""; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("MultiSelectionListCrashTest Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(35) + .testUI(MultiSelectionListCrashTest::createTestUI) + .build() + .awaitAndCheck(); + } + + private static Frame createTestUI() { + + Frame frame = new Frame("MultiSelectionListCrashTest frame"); + Button button = new Button("Invoke dialog"); + button.addActionListener(new FileDialogInvoker(frame)); + List list = new List(4, true); + list.add("Item1"); + list.add("Item2"); + frame.setLayout(new FlowLayout()); + frame.add(button); + frame.add(list); + frame.setSize(200, 200); + return frame; + } +} + +class FileDialogInvoker implements ActionListener { + FileDialog fileDialog; + + public FileDialogInvoker(Frame frame) { + fileDialog = new FileDialog(frame); + } + + public void actionPerformed(ActionEvent e) { + fileDialog.setVisible(true); + } + +} diff --git a/test/jdk/java/awt/List/MultiSelectionListHorizScrollbar.java b/test/jdk/java/awt/List/MultiSelectionListHorizScrollbar.java new file mode 100644 index 00000000000..289cd0c2dac --- /dev/null +++ b/test/jdk/java/awt/List/MultiSelectionListHorizScrollbar.java @@ -0,0 +1,80 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4102881 + * @summary Ensure multiple selection Lists have horizontal scrollbars when necessary + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual MultiSelectionListHorizScrollbar +*/ + +import java.awt.Frame; +import java.awt.GridLayout; +import java.awt.List; + +public class MultiSelectionListHorizScrollbar { + + private static final String INSTRUCTIONS = """ + Resize the frame so that the lists are not wide enough + to fully display the lines of text they contain. + Once the lists are in this state, press pass + if both lists display an horizontal scrollbar. Otherwise press fail."""; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("MultiSelectionListHorizScrollbar Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(35) + .testUI(MultiSelectionListHorizScrollbar::createTestUI) + .build() + .awaitAndCheck(); + } + + private static Frame createTestUI() { + Frame frame = new Frame("MultiSelectionListHorizScrollbar Frame"); + List singleList = new List(3); + List multiList = new List(3, true); + + frame.setLayout(new GridLayout(1, 2)); + frame.add(singleList); + frame.add(multiList); + + singleList.addItem("This is the 1st item in the list! Does it scroll horizontally??"); + singleList.addItem("This is the 2nd item in the list! Does it scroll horizontally??"); + singleList.addItem("This is the 4th item in the list! Does it scroll horizontally??"); + singleList.addItem("This is the 5th item in the list! Does it scroll horizontally??"); + singleList.addItem("This is the 6th item in the list! Does it scroll horizontally??"); + + multiList.addItem("This is the 1st item in the list! Does it scroll horizontally??"); + multiList.addItem("This is the 2nd item in the list! Does it scroll horizontally??"); + multiList.addItem("This is the 4th item in the list! Does it scroll horizontally??"); + multiList.addItem("This is the 5th item in the list! Does it scroll horizontally??"); + multiList.addItem("This is the 6th item in the list! Does it scroll horizontally??"); + + frame.pack(); + return frame; + } +} diff --git a/test/jdk/java/awt/List/RepaintAfterResize.java b/test/jdk/java/awt/List/RepaintAfterResize.java new file mode 100644 index 00000000000..12bb584aefa --- /dev/null +++ b/test/jdk/java/awt/List/RepaintAfterResize.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6308295 + * @summary XAWTduplicate list item is displayed + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual RepaintAfterResize +*/ + +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.List; + +public class RepaintAfterResize { + + private static final String INSTRUCTIONS = """ + 1) A Frame appears with a list + 2) Resize somehow the frame using mouse + 3) Move down the vertical scrollbar of the list + 4) If you see that two selected items are displayed then the test failed. + Otherwise, the test passed."""; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("RepaintAfterResize Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(35) + .testUI(RepaintAfterResize::createTestUI) + .build() + .awaitAndCheck(); + } + + private static Frame createTestUI() { + Frame frame = new Frame("RepaintAfterResize Frame"); + List list = new List(4, false); + + frame.setLayout (new FlowLayout ()); + list.setBounds(100, 100, 100, 100); + for (int i = 0 ; i < 7 ; i++) { + list.add(" " + i); + } + frame.add(list); + list.select(3); + + frame.setSize(100, 100); + return frame; + + } +} diff --git a/test/jdk/java/awt/List/ScrollbarPositionTest.java b/test/jdk/java/awt/List/ScrollbarPositionTest.java new file mode 100644 index 00000000000..25167fa5627 --- /dev/null +++ b/test/jdk/java/awt/List/ScrollbarPositionTest.java @@ -0,0 +1,104 @@ +/* + * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4024943 + * @summary Test for position of List scrollbar when it is added + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual ScrollbarPositionTest + */ + +import java.awt.Button; +import java.awt.Frame; +import java.awt.GridLayout; +import java.awt.List; +import java.awt.Panel; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public class ScrollbarPositionTest { + static int item = 0; + static List list; + static Button addButton, delButton; + + private static final String INSTRUCTIONS = """ + Click on the "Add List Item" button many times + until the vertical scrollbar appears. + Verify that the displayed vertical scrollbar does not take the space + that was occupied by buttons before the scrollbar is shown."""; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("ScrollbarPositionTest Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(35) + .testUI(ScrollbarPositionTest::createTestUI) + .build() + .awaitAndCheck(); + } + + private static Frame createTestUI() { + Panel pan; + + Frame frame = new Frame("ScrollbarPositionTest Frame"); + frame.setLayout(new GridLayout(1, 2)); + list = new List(); + frame.add(list); + frame.add(pan = new Panel()); + pan.setLayout(new GridLayout(4, 1)); + + MyListener listener = new MyListener(); + addButton = new Button("Add List Item"); + addButton.addActionListener(listener); + pan.add(addButton); + + delButton = new Button("Delete List Item"); + delButton.addActionListener(listener); + pan.add(delButton); + + frame.pack(); + return frame; + } + + static class MyListener implements ActionListener { + public void actionPerformed(ActionEvent evt) { + if (evt.getSource() == addButton) { + String s = "item"; + for (int i = 0; i <= item; i++) { + s = s +" "+Integer.toString(i); + } + item++; + list.addItem(s); + } else if (evt.getSource() == delButton) { + int i; + if ((i = list.countItems()) > 0) { + list.delItem(i - 1); + --item; + } + } + } + } +} diff --git a/test/jdk/java/awt/List/ScrollbarPresenceTest.java b/test/jdk/java/awt/List/ScrollbarPresenceTest.java new file mode 100644 index 00000000000..d82cbb80060 --- /dev/null +++ b/test/jdk/java/awt/List/ScrollbarPresenceTest.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2006, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6336384 + * @summary ScrollBar does not show up correctly + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual ScrollbarPresenceTest +*/ + +import java.awt.Font; +import java.awt.Frame; +import java.awt.List; + +public class ScrollbarPresenceTest { + + private static final String INSTRUCTIONS = """ + You will see a list, + If a vertical scrollbar appears on the list and the list is big enough + to show all items then the test failed else the test passed."""; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("ScrollbarPresenceTest Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(35) + .testUI(ScrollbarPresenceTest::createTestUI) + .build() + .awaitAndCheck(); + } + + private static Frame createTestUI() { + Frame frame = new Frame("ScrollbarPresenceTest Frame"); + List list = new List(); + + for (int i = 0; i < 6; i++) { + list.addItem("Row " + i); + } + + list.setFont(new Font("MonoSpaced", Font.PLAIN, 12)); + list.setBounds(30, 30, 128, 104); + frame.add(list); + + frame.pack(); + return frame; + } + +} diff --git a/test/jdk/java/awt/List/SelectedItemVisibilityTest.java b/test/jdk/java/awt/List/SelectedItemVisibilityTest.java new file mode 100644 index 00000000000..53364e93771 --- /dev/null +++ b/test/jdk/java/awt/List/SelectedItemVisibilityTest.java @@ -0,0 +1,128 @@ +/* + * Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4676536 + * @summary REGRESSION: makeVisible() method of List Component does not perform + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual SelectedItemVisibilityTest + */ + +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.Label; +import java.awt.List; + +public class SelectedItemVisibilityTest { + + static List list1, list2; + static int visibleItem = 4; + static int selectedItems[] = {6, 7, 8}; + static String selectedItemsStr = ""; + + static { + for (int i = 0 ; i < selectedItems.length ; i++) { + selectedItemsStr += ""+selectedItems[i]+" "; + } + } + + private static final String INSTRUCTIONS = + "You should see two lists.\n" + + "\n" + + "list1: \n" + + "\t1. the first visible item should be " + visibleItem + + "\n\t2. the selected item should be " + selectedItems[0] + + "\n" + + "list2:\n" + + "\t1. the first visible item should be " + visibleItem + + "\n\t2. the selected items should be " + selectedItemsStr + + "\n" + + "\nIf it is so the test passed else failed."; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("SelectedItemVisibilityTest Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(35) + .testUI(SelectedItemVisibilityTest::createTestUI) + .logArea() + .build() + .awaitAndCheck(); + } + + private static Frame createTestUI() { + + Frame frame = new Frame("SelectedItemVisibilityTest Frame"); + frame.setLayout(new FlowLayout()); + + // list1 + list1 = new List(4); + for (int i = 0; i < 20; i++) { + list1.add(""+i); + } + list1.makeVisible(visibleItem); + list1.select(selectedItems[0]); + frame.add(new Label("list1:")); + frame.add(list1); + + // list2 + list2 = new List(4); + list2.setMultipleMode(true); + for (int i = 0; i < 20; i++) { + list2.add(""+i); + } + list2.makeVisible(visibleItem); + for (int i = 0 ; i < selectedItems.length ; i++) { + list2.select(selectedItems[i]); + } + frame.add(new Label("list2:")); + frame.add(list2); + frame.setSize(200, 200); + + // common output + String s; + int sel[]; + + PassFailJFrame.log("list1: "); + PassFailJFrame.log("\tgetVisibleIndex="+list1.getVisibleIndex()); + sel = list1.getSelectedIndexes(); + s = "\tgetSelectedIndexes="; + for (int i = 0 ; i < sel.length ; i++) { + s += "" + sel[i] + " "; + } + PassFailJFrame.log(s); + + PassFailJFrame.log("list2: "); + PassFailJFrame.log("\tgetVisibleIndex="+list2.getVisibleIndex()); + sel = list2.getSelectedIndexes(); + s = "\tgetSelectedIndexes="; + for (int i = 0 ; i < sel.length ; i++) { + s += "" + sel[i] + " "; + } + PassFailJFrame.log(s); + return frame; + } +} diff --git a/test/jdk/java/awt/List/SetForegroundTest.java b/test/jdk/java/awt/List/SetForegroundTest.java new file mode 100644 index 00000000000..7b22e538508 --- /dev/null +++ b/test/jdk/java/awt/List/SetForegroundTest.java @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6246467 + * @summary Tests that list works correctly if user specified foreground colors on XToolkit/Motif + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual SetForegroundTest + */ + +import java.awt.Button; +import java.awt.Component; +import java.awt.Checkbox; +import java.awt.Choice; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.Label; +import java.awt.List; +import java.awt.Panel; +import java.awt.TextArea; +import java.awt.TextField; +import java.awt.ScrollPane; + +public class SetForegroundTest { + + private static final String INSTRUCTIONS = """ + To make sure, that for each component + (Button, Checkbox, Label, List, TextArea, TextField, Choice) + in the frame, + the title exist and the color of the title is red. + If not, the test failed."""; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("SetForegroundTest Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(35) + .testUI(SetForegroundTest::createTestUI) + .build() + .awaitAndCheck(); + } + + private static Frame createTestUI() { + Frame frame = new Frame(); + ScrollPane sp = new ScrollPane() { + public Dimension getPreferredSize() { + return new Dimension(180, 180); + } + }; + Panel p = new Panel(); + Component childs[] = new Component[] {new Button("button"), + new Checkbox("checkbox"), + new Label("label"), + new List(3, false), + new TextArea("text area"), + new TextField("text field"), + new Choice()}; + + p.setLayout (new FlowLayout ()); + + sp.add(p); + + sp.validate(); + + frame.add(sp); + for (int i = 0; i < childs.length; i++){ + childs[i].setForeground(Color.red); + } + + for (int i = 0; i < childs.length; i++) { + p.add(childs[i]); + if (childs[i] instanceof List) { + ((List)childs[i]).add("list1"); + ((List)childs[i]).add("list2"); + } else if (childs[i] instanceof Choice) { + ((Choice)childs[i]).add("choice1"); + ((Choice)childs[i]).add("choice2"); + } + } + frame.pack(); + return frame; + } +} diff --git a/test/jdk/java/awt/MenuBar/CellsResize.java b/test/jdk/java/awt/MenuBar/CellsResize.java new file mode 100644 index 00000000000..64777095fa8 --- /dev/null +++ b/test/jdk/java/awt/MenuBar/CellsResize.java @@ -0,0 +1,159 @@ +/* + * Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6502052 + * @summary Menu cells must resize if font changes (XToolkit) + * @requires os.family == "linux" + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual CellsResize + */ + +import java.awt.Button; +import java.awt.Font; +import java.awt.Frame; +import java.awt.GridLayout; +import java.awt.Menu; +import java.awt.MenuBar; +import java.awt.MenuComponent; +import java.awt.MenuItem; +import java.awt.Panel; +import java.awt.PopupMenu; +import java.awt.Toolkit; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +public class CellsResize { + private static Frame frame; + private static MenuBar menuBar; + private static PopupMenu popupMenu; + private static Menu barSubMenu; + private static Menu popupSubMenu; + private static boolean fontMultiplied = false; + + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + 1. Open all nested menus in menu bar. + 2. Click on "popup-menu" button to show popup-menus. + 3. Open all nested menus in popup-menu. + 4. Click on "big-font" button (to make all menus have a + bigger font). + 5. Open all nested menus again (as described in 1, 2, 3). + 6. If all menu items use a bigger font now and their labels fit + into menu-item size, press "pass", otherwise press "fail". + """; + + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(35) + .testUI(CellsResize::createUI) + .logArea(5) + .build() + .awaitAndCheck(); + } + + public static Frame createUI () { + if (!checkToolkit()) { + new RuntimeException("Toolkit check failed."); + } + frame = new Frame("MenuBar Cell Resize Test"); + + popupMenu = new PopupMenu(); + popupMenu.add(createMenu(false)); + + frame.add(popupMenu); + + menuBar = new MenuBar(); + menuBar.add(createMenu(true)); + + frame.setMenuBar(menuBar); + + Button bp = new Button("popup-menu"); + bp.addMouseListener(new MouseAdapter() { + public void mouseReleased(MouseEvent e) { + popupMenu.show(e.getComponent(), e.getX(), e.getY()); + } + }); + + Button bf = new Button("big-font"); + bf.addMouseListener(new MouseAdapter() { + public void mouseReleased(MouseEvent e) { + bigFont(); + } + }); + + Panel panel = new Panel(); + panel.setLayout(new GridLayout(2, 1)); + panel.add(bp); + panel.add(bf); + + frame.add(panel); + frame.setSize(300, 300); + return frame; + } + + static boolean checkToolkit() { + String toolkitName = Toolkit.getDefaultToolkit().getClass().getName(); + return toolkitName.equals("sun.awt.X11.XToolkit"); + } + + static Menu createMenu(boolean bar) { + Menu menu1 = new Menu("Menu-1"); + Menu menu11 = new Menu("Menu-11"); + menu1.add(menu11); + if (bar) { + barSubMenu = menu11; + } else { + popupSubMenu = menu11; + } + menu11.add(new MenuItem("MenuItem")); + return menu1; + } + + static void bigFont() { + if (fontMultiplied) { + return; + } else { + fontMultiplied = true; + } + + multiplyFont(barSubMenu, 7); + multiplyFont(popupSubMenu, 7); + + // NOTE: if previous two are moved below following + // two, they get their font multiplied twice. + + multiplyFont(menuBar, 5); + multiplyFont(popupMenu, 5); + } + + static void multiplyFont(MenuComponent comp, int times) { + Font font = comp.getFont(); + float size = font.getSize() * times; + comp.setFont(font.deriveFont(size)); + } +} diff --git a/test/jdk/java/awt/MenuBar/MenuBarAddRemoveTest/MenuBarAddRemoveTest.java b/test/jdk/java/awt/MenuBar/MenuBarAddRemoveTest/MenuBarAddRemoveTest.java new file mode 100644 index 00000000000..fdb9f06e98c --- /dev/null +++ b/test/jdk/java/awt/MenuBar/MenuBarAddRemoveTest/MenuBarAddRemoveTest.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4028130 4112308 + * @summary Test for location of Frame/MenuBar when MenuBar is re-added + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual MenuBarAddRemoveTest + */ + +import java.awt.Button; +import java.awt.Frame; +import java.awt.Menu; +import java.awt.MenuBar; + +public class MenuBarAddRemoveTest { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + 1. Click the left mouse button on the "Re-Add MenuBar" + button several times. + 3. The Frame/MenuBar may repaint or flash, but the location + of its upper left corner should never change. + """; + + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(35) + .testUI(MenuBarAddRemoveTest::createUI) + .build() + .awaitAndCheck(); + } + + private static Frame createUI() { + Frame f = new Frame("Re-Add MenuBar Test Frame"); + Button b = new Button("Re-Add MenuBar"); + b.addActionListener(e -> f.setMenuBar(createMenuBar())); + f.setMenuBar(createMenuBar()); + f.add(b); + f.pack(); + return f; + } + + private static MenuBar createMenuBar() { + MenuBar bar = new MenuBar(); + bar.add(new Menu("foo")); + return bar; + } +} diff --git a/test/jdk/java/awt/MenuBar/MenuBarOnDisabledFrame/MenuBarOnDisabledFrame.java b/test/jdk/java/awt/MenuBar/MenuBarOnDisabledFrame/MenuBarOnDisabledFrame.java new file mode 100644 index 00000000000..06f5d96c19e --- /dev/null +++ b/test/jdk/java/awt/MenuBar/MenuBarOnDisabledFrame/MenuBarOnDisabledFrame.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6185057 + * @summary Disabling a frame does not disable the menus on the frame, on + * solaris/linux + * @requires os.family != "mac" + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual MenuBarOnDisabledFrame + */ + +import java.awt.Button; +import java.awt.Frame; +import java.awt.Menu; +import java.awt.MenuBar; +import java.awt.MenuItem; + +public class MenuBarOnDisabledFrame { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + Check if MenuBar is disabled on 'Disabled frame' + Press pass if menu bar is disabled, fail otherwise + """; + + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(35) + .testUI(MenuBarOnDisabledFrame::createUI) + .build() + .awaitAndCheck(); + } + + public static Frame createUI() { + Frame f = new Frame("Disabled frame"); + MenuBar mb = new MenuBar(); + Menu m1 = new Menu("Disabled Menu 1"); + Menu m2 = new Menu("Disabled Menu 2"); + MenuItem m11 = new MenuItem("MenuItem 1.1"); + MenuItem m21 = new MenuItem("MenuItem 2.1"); + Button b = new Button("Disabled button"); + + m1.add(m11); + m2.add(m21); + mb.add(m1); + mb.add(m2); + f.setMenuBar(mb); + f.add(b); + f.setEnabled(false); + f.setSize(300, 300); + return f; + } +} diff --git a/test/jdk/java/awt/MenuBar/MenuBarRemoveMenu/MenuBarRemoveMenuTest.java b/test/jdk/java/awt/MenuBar/MenuBarRemoveMenu/MenuBarRemoveMenuTest.java new file mode 100644 index 00000000000..098065d1361 --- /dev/null +++ b/test/jdk/java/awt/MenuBar/MenuBarRemoveMenu/MenuBarRemoveMenuTest.java @@ -0,0 +1,93 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4275848 + * @summary Tests that MenuBar is painted correctly after its submenu is removed + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual MenuBarRemoveMenuTest + */ + +import java.awt.Button; +import java.awt.Frame; +import java.awt.GridLayout; +import java.awt.Menu; +import java.awt.MenuBar; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public class MenuBarRemoveMenuTest implements ActionListener { + private static MenuBar menubar; + private static Button removeButton; + private static Button addButton; + + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + Press "Remove menu" button. If you see that both menus + disappeared, the test failed. Otherwise try to add and remove + menu several times to verify that the test passed. Every time + you press "Remove menu" button only one menu should go away. + """; + + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(35) + .testUI(MenuBarRemoveMenuTest::createUI) + .build() + .awaitAndCheck(); + } + + private static Frame createUI() { + Frame frame = new Frame(); + menubar = new MenuBar(); + removeButton = new Button("Remove menu"); + addButton = new Button("Add menu"); + removeButton.addActionListener(new MenuBarRemoveMenuTest()); + addButton.addActionListener(new MenuBarRemoveMenuTest()); + addButton.setEnabled(false); + menubar.add(new Menu("menu")); + menubar.add(new Menu("menu")); + frame.setMenuBar(menubar); + frame.setLayout(new GridLayout(1, 2)); + frame.add(removeButton); + frame.add(addButton); + frame.pack(); + return frame; + } + + public void actionPerformed(ActionEvent e) { + if (e.getSource() == removeButton) { + menubar.remove(0); + removeButton.setEnabled(false); + addButton.setEnabled(true); + } else { + menubar.add(new Menu("menu")); + removeButton.setEnabled(true); + addButton.setEnabled(false); + } + } +} diff --git a/test/jdk/java/awt/MenuBar/MenuBarVisuals/MenuBarVisuals.java b/test/jdk/java/awt/MenuBar/MenuBarVisuals/MenuBarVisuals.java new file mode 100644 index 00000000000..7663dd0d99b --- /dev/null +++ b/test/jdk/java/awt/MenuBar/MenuBarVisuals/MenuBarVisuals.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6180416 + * @summary Tests MenuBar and drop down menu visuals + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual MenuBarVisuals + */ + +import java.awt.Frame; +import java.awt.Menu; +import java.awt.MenuBar; +import java.awt.MenuItem; +import java.awt.MenuShortcut; +import java.awt.event.KeyEvent; + +public class MenuBarVisuals { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + Look at the MenuBar and traverse the menus using mouse and + keyboard. Then check if following is showing correctly: + 1. Mnemonic label Ctrl+A is NOT drawn for Menu 1/Submenu 1.1 + 2. Mnemonic label Ctrl+B is drawn for + Menu 1/Submenu 1.1/Item 1.1.1 + 3. Mnemonic label Ctrl+C is drawn for Menu1/Item 1.2 + Press PASS if Menu is drawing correctly, FAIL otherwise. + """; + + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(35) + .testUI(MenuBarVisuals::createUI) + .build() + .awaitAndCheck(); + } + + private static Frame createUI() { + Frame f = new Frame("MenuBar Visuals Test"); + MenuBar mb = new MenuBar(); + Menu menu1 = new Menu("Menu 1"); + Menu submenu11 = new Menu("Submenu 1.1"); + MenuItem item111 = new MenuItem("Item 1.1.1"); + MenuItem item112 = new MenuItem("Item 1.1.2"); + MenuItem item12 = new MenuItem("Item 1.2"); + Menu menu2 = new Menu("Menu 2"); + MenuItem item21 = new MenuItem("Item 2.1"); + MenuItem item22 = new MenuItem("Item 2.2"); + item111.setShortcut(new MenuShortcut(KeyEvent.VK_B, false)); + submenu11.add(item111); + submenu11.add(item112); + submenu11.setShortcut(new MenuShortcut(KeyEvent.VK_A, false)); + menu1.add(submenu11); + item12.setShortcut(new MenuShortcut(KeyEvent.VK_C, false)); + menu1.add(item12); + mb.add(menu1); + menu2.add(item21); + menu2.add(item22); + mb.add(menu2); + f.setMenuBar(mb); + f.setSize(300, 300); + return f; + } +} diff --git a/test/jdk/java/awt/MenuBar/MenuNPE/MenuNPE.java b/test/jdk/java/awt/MenuBar/MenuNPE/MenuNPE.java new file mode 100644 index 00000000000..a7a3a348011 --- /dev/null +++ b/test/jdk/java/awt/MenuBar/MenuNPE/MenuNPE.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 5005194 + * @summary Frame.remove(getMenuBar()) throws NPE if the frame doesn't + * have a menu bar + * @key headful + * @run main MenuNPE + */ + +import java.awt.Frame; +import java.awt.Menu; +import java.awt.MenuBar; +import java.awt.MenuItem; + +public class MenuNPE { + private static Frame frame; + public static void main(String[] args) throws Exception { + try { + frame = new Frame("Menu NPE"); + MenuBar menuBar = new MenuBar(); + Menu menu1 = new Menu("Menu 01"); + MenuItem menuLabel = new MenuItem("Item 01"); + menu1.add(menuLabel); + menuBar.add(menu1); + frame.setMenuBar(menuBar); + frame.setSize(200, 200); + frame.setVisible(true); + frame.validate(); + frame.remove(frame.getMenuBar()); + frame.remove(frame.getMenuBar()); + System.out.println("Test passed."); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (frame != null) { + frame.dispose(); + } + } + } +} diff --git a/test/jdk/java/awt/MenuBar/SetHelpMenuTest/SetHelpMenuTest.java b/test/jdk/java/awt/MenuBar/SetHelpMenuTest/SetHelpMenuTest.java new file mode 100644 index 00000000000..fcfc3e80ed3 --- /dev/null +++ b/test/jdk/java/awt/MenuBar/SetHelpMenuTest/SetHelpMenuTest.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4275843 + * @summary MenuBar doesn't display all of its Menus correctly on Windows + * @requires os.family == "windows" + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual SetHelpMenuTest + */ + +import java.awt.Frame; +import java.awt.Menu; +import java.awt.MenuBar; +import java.awt.MenuItem; + +public class SetHelpMenuTest { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + An empty frame should be visible. When focused, the MenuBar + should have 5 menus ("one", "two", "three", "Help 2", + "four"). If so, then the test passed. Otherwise, the test + failed. + """; + + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(35) + .testUI(SetHelpMenuTest::createUI) + .build() + .awaitAndCheck(); + } + + private static Frame createUI() { + Frame f = new Frame("Help MenuBar Test"); + f.setSize(100, 100); + + MenuBar mb = new MenuBar(); + Menu h1, h2; + + f.setMenuBar(mb); + mb.add(createMenu("one", false)); + mb.add(createMenu("two", false)); + mb.add(createMenu("three", true)); + + mb.add(h1 = createMenu("Help 1", false)); // h1 is HelpMenu + mb.setHelpMenu(h1); + + mb.add(h2 = createMenu("Help 2", false)); // h2 replaced h1 + mb.setHelpMenu(h2); + + mb.add(createMenu("four", false)); + + return f; + } + + private static Menu createMenu(String name, boolean tearOff) { + Menu m = new Menu(name, tearOff); + m.add(new MenuItem(name + " item 1")); + m.add(new MenuItem(name + " item 2")); + m.add(new MenuItem(name + " item 3")); + return m; + } +} diff --git a/test/jdk/java/awt/MenuBar/SetMBarWhenHidden/SetMBarWhenHidden.java b/test/jdk/java/awt/MenuBar/SetMBarWhenHidden/SetMBarWhenHidden.java new file mode 100644 index 00000000000..67eefe48942 --- /dev/null +++ b/test/jdk/java/awt/MenuBar/SetMBarWhenHidden/SetMBarWhenHidden.java @@ -0,0 +1,92 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4105881 + * @summary Sets the menu bar while frame window is hidden, then shows + frame again + * @key headful + * @run main SetMBarWhenHidden + */ + +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.Menu; +import java.awt.MenuBar; +import java.awt.Rectangle; + +// test case for 4105881: FRAME.SETSIZE() DOESN'T WORK FOR SOME SOLARIS WITH +// JDK115+CASES ON +public class SetMBarWhenHidden { + private static Frame f; + private static Rectangle startBounds; + private static Rectangle endBounds; + + public static void main(String[] args) throws Exception { + try { + EventQueue.invokeAndWait(() -> { + f = new Frame("Set MenuBar When Hidden Test"); + Menu file; + Menu edit; + MenuBar menubar = new MenuBar(); + file = new Menu("File"); + menubar.add(file); + edit = new Menu("Edit"); + menubar.add(edit); + edit.setEnabled(false); + f.setMenuBar(menubar); + f.setSize(200, 200); + startBounds = f.getBounds(); + System.out.println("About to call setVisible(false)"); + f.setVisible(false); + System.out.println("About to call setSize(500, 500)"); + f.setSize(500, 500); + // create a new menubar and add + MenuBar menubar1 = new MenuBar(); + menubar1.add(file); + menubar1.add(edit); + System.out.println("About to call setMenuBar"); + f.setMenuBar(menubar1); + System.out.println("About to call setVisible(true)"); + f.setVisible(true); + endBounds = f.getBounds(); + }); + if (startBounds.getHeight() > endBounds.getHeight() && + startBounds.getWidth() > endBounds.getWidth()) { + throw new RuntimeException("Test failed. Frame size didn't " + + "change.\nStart: " + startBounds + "\n" + + "End: " + endBounds); + } else { + System.out.println("Test passed.\nStart: " + startBounds + + "\nEnd: " + endBounds); + } + } finally { + EventQueue.invokeAndWait(() -> { + if (f != null) { + f.dispose(); + } + }); + } + } +} diff --git a/test/jdk/java/awt/MenuItem/GiantFontTest.java b/test/jdk/java/awt/MenuItem/GiantFontTest.java new file mode 100644 index 00000000000..f1e352373bb --- /dev/null +++ b/test/jdk/java/awt/MenuItem/GiantFontTest.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Font; +import java.awt.Frame; +import java.awt.Menu; +import java.awt.MenuBar; +import java.awt.MenuItem; + +/* + * @test + * @bug 4700350 + * @requires os.family != "mac" + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @summary Tests menu item font is big + * @run main/manual GiantFontTest + */ + +public class GiantFontTest { + + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + A frame with one menu will appear. + On Linux, the menu's (present on menu bar) font should + be quite large (48 point). + If not, test fails. + + On Windows, the menu's (present on menu bar) font + should be normal size. + If the menu text is clipped by the title bar, or is painted over + the title bar or client area, the test fails. + + On both Windows and Linux, the menu items in the popup + menu should be large. + + If so, test passes."""; + + PassFailJFrame.builder() + .title("GiantFontTest") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(40) + .testUI(GiantFontTest::createAndShowUI) + .build() + .awaitAndCheck(); + } + + private static Frame createAndShowUI() { + Font giantFont = new Font("Dialog", Font.PLAIN, 48); + Frame f = new Frame("GiantFontTest"); + MenuBar mb = new MenuBar(); + Menu m = new Menu("My font is too big!"); + m.setFont(giantFont); + for (int i = 0; i < 5; i++) { + m.add(new MenuItem("Some MenuItems")); + } + mb.add(m); + f.setMenuBar(mb); + f.setSize(450, 400); + return f; + } +} diff --git a/test/jdk/java/awt/MenuItem/LotsOfMenuItemsTest.java b/test/jdk/java/awt/MenuItem/LotsOfMenuItemsTest.java new file mode 100644 index 00000000000..7a528205d27 --- /dev/null +++ b/test/jdk/java/awt/MenuItem/LotsOfMenuItemsTest.java @@ -0,0 +1,117 @@ +/* + * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Frame; +import java.awt.Menu; +import java.awt.MenuBar; +import java.awt.MenuItem; +import java.awt.event.ComponentAdapter; +import java.awt.event.ComponentEvent; + +/* + * @test + * @bug 4175790 + * @requires os.family == "windows" + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @summary Win32: Running out of command ids for menu items + * @run main/manual LotsOfMenuItemsTest + */ + +public class LotsOfMenuItemsTest extends ComponentAdapter { + private static final int NUM_WINDOWS = 400; + private static TestFrame firstFrame; + + public static void main(String[] args) throws Exception { + LotsOfMenuItemsTest obj = new LotsOfMenuItemsTest(); + String INSTRUCTIONS = """ + This test creates lots of frames with menu bars. + When it's done you will see two frames. + Try to select menu items from each of them. + + If everything seems to work - test passed. + Click "Pass" button in the test harness window. + + If test crashes on you - test failed."""; + + PassFailJFrame.builder() + .title("LotsOfMenuItemsTest") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(40) + .testUI(obj::createAndShowUI) + .build() + .awaitAndCheck(); + } + + private Frame createAndShowUI() { + firstFrame = new TestFrame("First frame"); + firstFrame.addComponentListener(this); + return firstFrame; + } + + @Override + public void componentShown(ComponentEvent e) { + final int x = firstFrame.getX(); + final int y = firstFrame.getY() + firstFrame.getHeight() + 8; + TestFrame testFrame; + for (int i = 1; i < NUM_WINDOWS - 1; ++i) { + testFrame = new TestFrame("Running(" + i + ")...", x, y); + testFrame.setVisible(false); + testFrame.dispose(); + } + testFrame = new TestFrame("Last Frame", x, y); + PassFailJFrame.addTestWindow(testFrame); + } + + private static class TestFrame extends Frame { + static int n = 0; + + public TestFrame(String title) { + this(title, 0, 0, false); + } + + public TestFrame(String s, int x, int y) { + this(s, x, y, true); + } + + private TestFrame(String title, int x, int y, boolean visible) { + super(title); + MenuBar mb = new MenuBar(); + for (int i = 0; i < 10; ++i) { + Menu m = new Menu("Menu_" + (i + 1)); + for (int j = 0; j < 20; ++j) { + MenuItem mi = new MenuItem("Menu item " + ++n); + m.add(mi); + } + mb.add(m); + } + setMenuBar(mb); + setLocation(x, y); + setSize(450, 150); + if (visible) { + setVisible(true); + } + } + } +} diff --git a/test/jdk/java/awt/MenuItem/MenuSetFontTest.java b/test/jdk/java/awt/MenuItem/MenuSetFontTest.java new file mode 100644 index 00000000000..9a4e8f85839 --- /dev/null +++ b/test/jdk/java/awt/MenuItem/MenuSetFontTest.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Font; +import java.awt.Frame; +import java.awt.Menu; +import java.awt.MenuBar; +import java.awt.MenuItem; + +/* + * @test + * @bug 4066657 8009454 + * @requires os.family != "mac" + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @summary Tests that setting a font on the Menu with MenuItem takes effect. + * @run main/manual MenuSetFontTest + */ + +public class MenuSetFontTest { + + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + Look at the menu in the upper left corner of the 'SetFont Test' frame. + Click on the "File" menu. You will see "menu item" item. + Press Pass if menu item is displayed using bold and large font, + otherwise press Fail. + If you do not see menu at all, press Fail."""; + + PassFailJFrame.builder() + .title("MenuSetFontTest") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(40) + .testUI(MenuSetFontTest::createAndShowUI) + .build() + .awaitAndCheck(); + } + + private static Frame createAndShowUI() { + Frame frame = new Frame("SetFont Test"); + MenuBar menuBar = new MenuBar(); + Menu menu = new Menu("File"); + MenuItem item = new MenuItem("menu item"); + menu.add(item); + menuBar.add(menu); + menuBar.setFont(new Font(Font.MONOSPACED, Font.BOLD, 24)); + frame.setMenuBar(menuBar); + frame.setSize(300, 200); + return frame; + } +} diff --git a/test/jdk/java/awt/MenuItem/NullOrEmptyStringLabelTest.java b/test/jdk/java/awt/MenuItem/NullOrEmptyStringLabelTest.java new file mode 100644 index 00000000000..79d4c02ad24 --- /dev/null +++ b/test/jdk/java/awt/MenuItem/NullOrEmptyStringLabelTest.java @@ -0,0 +1,105 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.Frame; +import java.awt.Menu; +import java.awt.MenuBar; +import java.awt.MenuItem; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +/* + * @test + * @bug 4251036 + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @summary MenuItem setLabel(null/"") behaves differently under Win32 and Solaris + * @run main/manual NullOrEmptyStringLabelTest + */ + +public class NullOrEmptyStringLabelTest { + + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + The bug is reproducible under Win32 and Solaris. + Setting 'null' and "" as a label of menu item + should set blank label on all platforms according to the specification. + But under Solaris setting "" as a label of menu item used to + cause some garbage to be set as label. + Under Win32 setting 'null' as a label used to result in + throwing NullPointerException. + + If you see any of these things happen test fails otherwise + it passes."""; + + PassFailJFrame.builder() + .title("NullOrEmptyStringLabelTest") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(40) + .testUI(NullOrEmptyStringLabelTest::createAndShowUI) + .build() + .awaitAndCheck(); + } + + private static Frame createAndShowUI() { + Frame frame = new Frame("Null Or Empty String Label Test"); + Menu menu = new Menu("Menu"); + MenuItem mi = new MenuItem("Item"); + MenuBar mb = new MenuBar(); + Button button1 = new Button("Set MenuItem label to 'null'"); + Button button2 = new Button("Set MenuItem label to \"\""); + Button button3 = new Button("Set MenuItem label to 'text'"); + button1.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent ev) { + System.out.println("Setting MenuItem label to null"); + mi.setLabel(null); + } + }); + button2.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent ev) { + System.out.println("Setting MenuItem label to \"\""); + mi.setLabel(""); + } + }); + button3.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent ev) { + System.out.println("Setting MenuItem label to 'text'"); + mi.setLabel("text"); + } + }); + menu.add(mi); + mb.add(menu); + frame.add(button1, BorderLayout.NORTH); + frame.add(button2, BorderLayout.CENTER); + frame.add(button3, BorderLayout.SOUTH); + frame.setMenuBar(mb); + frame.setSize(200, 135); + return frame; + } +} diff --git a/test/jdk/java/awt/MenuItem/UnicodeMenuItemTest.java b/test/jdk/java/awt/MenuItem/UnicodeMenuItemTest.java new file mode 100644 index 00000000000..b73fe954af6 --- /dev/null +++ b/test/jdk/java/awt/MenuItem/UnicodeMenuItemTest.java @@ -0,0 +1,91 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Frame; +import java.awt.Menu; +import java.awt.MenuBar; +import java.awt.MenuItem; + +/* + * @test + * @bug 4099695 + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @summary menu items with Unicode labels treated as separators + * @run main/manual UnicodeMenuItemTest + */ + +public class UnicodeMenuItemTest { + + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + Click on the "Menu" on the top-left corner of frame. + + The menu should have four entries: + 1) a row of five unicode characters: \u00c4\u00cb\u00cf\u00d6\u00dc + 2) a menu separator + 3) a unicode character: \u012d + 4) a unicode character: \u022d + + If the menu items look like the list above, the test passes. + It is okay if the unicode characters look like empty boxes + or something - as long as they are not separators. + + If either of the last two menu items show up as separators, + the test FAILS. + + Press 'Pass' if above instructions hold good else press 'Fail'."""; + + PassFailJFrame.builder() + .title("UnicodeMenuItemTest") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(40) + .testUI(UnicodeMenuItemTest::createAndShowUI) + .build() + .awaitAndCheck(); + } + private static Frame createAndShowUI() { + Frame frame = new Frame("Unicode MenuItem Test"); + MenuBar mb = new MenuBar(); + Menu m = new Menu("Menu"); + + MenuItem mi1 = new MenuItem("\u00c4\u00cb\u00cf\u00d6\u00dc"); + m.add(mi1); + + MenuItem separator = new MenuItem("-"); + m.add(separator); + + MenuItem mi2 = new MenuItem("\u012d"); + m.add(mi2); + + MenuItem mi3 = new MenuItem("\u022d"); + m.add(mi3); + + mb.add(m); + + frame.setMenuBar(mb); + frame.setSize(450, 150); + return frame; + } +} diff --git a/test/jdk/java/awt/MenuShortcut/ActionCommandTest.java b/test/jdk/java/awt/MenuShortcut/ActionCommandTest.java new file mode 100644 index 00000000000..bd1648cdc2c --- /dev/null +++ b/test/jdk/java/awt/MenuShortcut/ActionCommandTest.java @@ -0,0 +1,111 @@ +/* + * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4079449 + * @key headful + * @summary MenuItem objects return null if they are activated by shortcut + */ + +import java.awt.Dialog; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.Menu; +import java.awt.MenuBar; +import java.awt.MenuItem; +import java.awt.MenuShortcut; +import java.awt.Point; +import java.awt.Robot; +import java.awt.TextArea; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.InputEvent; +import java.awt.event.KeyEvent; + +import static java.awt.event.KeyEvent.VK_CONTROL; +import static java.awt.event.KeyEvent.VK_META; + +public class ActionCommandTest implements ActionListener { + + static volatile Frame frame; + static volatile boolean event = false; + static volatile boolean failed = false; + static final String ITEMTEXT = "Testitem"; + + static void createUI() { + frame = new Frame("ActionCommand Menu Shortcut Test"); + MenuBar mb = new MenuBar(); + Menu m = new Menu("Test"); + MenuItem mi = new MenuItem(ITEMTEXT, new MenuShortcut(KeyEvent.VK_T)); + mi.addActionListener(new ActionCommandTest()); + m.add(mi); + mb.add(m); + frame.setMenuBar(mb); + frame.setBounds(50, 400, 200, 200); + frame.setVisible(true); + } + + public static void main(String[] args ) throws Exception { + + EventQueue.invokeAndWait(ActionCommandTest::createUI); + try { + Robot robot = new Robot(); + + robot.waitForIdle(); + robot.delay(2000); + + // Ensure window has focus + Point p = frame.getLocationOnScreen(); + robot.mouseMove(p.x + frame.getWidth() / 2, p.y + frame.getHeight() / 2); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.waitForIdle(); + robot.delay(2000); + + // invoke short cut. + robot.keyPress(KeyEvent.VK_T); + robot.delay(50); + robot.keyRelease(KeyEvent.VK_T); + robot.waitForIdle(); + robot.delay(2000); + } finally { + if (frame != null) { + EventQueue.invokeAndWait(frame::dispose); + } + } + if (failed) { + throw new RuntimeException("No actioncommand"); + } + } + + // Since no ActionCommand is set, this should be the menuitem's label. + public void actionPerformed(ActionEvent e) { + event = true; + String s = e.getActionCommand(); + if (s == null || !s.equals(ITEMTEXT)) { + failed = true; + } + } + +} diff --git a/test/jdk/java/awt/MenuShortcut/CheckMenuShortcut.java b/test/jdk/java/awt/MenuShortcut/CheckMenuShortcut.java new file mode 100644 index 00000000000..cebb42f1b55 --- /dev/null +++ b/test/jdk/java/awt/MenuShortcut/CheckMenuShortcut.java @@ -0,0 +1,139 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4167811 + * @summary tests that shortcuts work for Checkbox menu items + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual CheckMenuShortcut +*/ + +import java.awt.CheckboxMenuItem; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.Insets; +import java.awt.Menu; +import java.awt.MenuBar; +import java.awt.MenuItem; +import java.awt.MenuShortcut; +import java.awt.Panel; +import java.awt.Rectangle; +import java.awt.TextArea; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.event.KeyEvent; + +public class CheckMenuShortcut implements ActionListener, ItemListener { + + static final String INSTRUCTIONS = """ + A window that contains a text area will be displayed. + The window will have a menu labeled 'Window Menu'. Click on the menu to see its items. + + The two menu items should have shortcuts which in order are : Ctrl-A, Ctrl-I. + On macOS these will be Command-A, Command-I. + + If the second item only has the label 'checkbox item' and no shortcut + ie none of Ctrl-I or Ctrl-i, or Command-I or Command-i on macOS painted on it, the test FAILS. + + The same second item - labeled 'checkbox item' is in fact a Checkbox menu item. + The menu item should NOT be checked (eg no tick mark). + + Dismiss the menu by clicking inside the window, do not select any of menu items. + After that press Ctrl-i, (Command-i on macOS). + + After that click on the menu again. If the second menu item 'checkbox item' is now + checked, the test PASSES, if it is not checked, the test FAILS. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("CheckboxMenuItem Shortcut Test Instructions") + .instructions(INSTRUCTIONS) + .columns(60) + .logArea() + .testUI(CheckMenuShortcut::createUI) + .build() + .awaitAndCheck(); + } + + + static Frame createUI() { + + MenuBar mainMenu; + Menu menu; + MenuItem action; + CheckboxMenuItem item; + TextArea pane; + + boolean isMac = System.getProperty("os.name").startsWith("Mac"); + String ctrlA = (isMac) ? "Command-A" : "Ctrl-A"; + String ctrlI = (isMac) ? "Command-I" : "Ctrl-I"; + + CheckMenuShortcut cms = new CheckMenuShortcut(); + Frame frame = new Frame("CheckMenuShortcut"); + + mainMenu = new MenuBar(); + menu = new Menu("Window Menu"); + + action = new MenuItem("action"); + action.setShortcut(new MenuShortcut(KeyEvent.VK_A, false)); + action.addActionListener(cms); + action.setActionCommand("action"); + menu.add(action); + + item = new CheckboxMenuItem("checkbox item", false); + item.setShortcut(new MenuShortcut(KeyEvent.VK_I,false)); + item.addItemListener(cms); + item.addActionListener(cms); + menu.add(item); + + mainMenu.add(menu); + + frame.setMenuBar(mainMenu); + + pane = new TextArea(ctrlA + " -- action menu test\n", 10, 40, TextArea.SCROLLBARS_VERTICAL_ONLY); + Dimension mySize = frame.getSize(); + Insets myIns = frame.getInsets(); + pane.setBounds(new Rectangle(mySize.width - myIns.left - myIns.right, + mySize.height - myIns.top - myIns.bottom)); + pane.setLocation(myIns.left,myIns.top); + frame.add(pane); + + pane.append(ctrlI + " -- item menu test\n"); + + frame.pack(); + return frame; + } + + public void itemStateChanged(ItemEvent evt) { + PassFailJFrame.log("Got item: " + evt.getItem() + "\n"); + } + + public void actionPerformed(ActionEvent evt) { + PassFailJFrame.log("Got action: " + evt.getActionCommand() + "\n"); + } +} diff --git a/test/jdk/java/awt/MenuShortcut/FunctionKeyShortcut.java b/test/jdk/java/awt/MenuShortcut/FunctionKeyShortcut.java new file mode 100644 index 00000000000..960de08bd2d --- /dev/null +++ b/test/jdk/java/awt/MenuShortcut/FunctionKeyShortcut.java @@ -0,0 +1,140 @@ +/* + * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4034665 + * @key headful + * @summary Function keys should work correctly as shortcuts + */ + +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.Menu; +import java.awt.MenuBar; +import java.awt.MenuItem; +import java.awt.MenuShortcut; +import java.awt.Point; +import java.awt.Robot; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.InputEvent; +import java.awt.event.KeyEvent; + +import static java.awt.event.KeyEvent.VK_CONTROL; +import static java.awt.event.KeyEvent.VK_META; + +public class FunctionKeyShortcut implements ActionListener { + + static volatile Frame frame; + static volatile boolean event = false; + static volatile boolean failed = false; + + static final boolean isMac = System.getProperty("os.name").contains("OS X"); + + static void createUI() { + frame = new Frame("Function Key Menu Shortcut Test"); + MenuBar mb = new MenuBar(); + Menu m = new Menu("Test"); + MenuItem mi1 = new MenuItem("Function key 1", new MenuShortcut(KeyEvent.VK_F1)); + MenuItem mi2 = new MenuItem("Function key 2", new MenuShortcut(KeyEvent.VK_F2)); + MenuItem mi3 = new MenuItem("Function key 3", new MenuShortcut(KeyEvent.VK_F3)); + MenuItem mi4 = new MenuItem("Function key 4", new MenuShortcut(KeyEvent.VK_F4)); + MenuItem mi5 = new MenuItem("Function key 5", new MenuShortcut(KeyEvent.VK_F5)); + MenuItem mi6 = new MenuItem("Function key 6", new MenuShortcut(KeyEvent.VK_F6)); + MenuItem mi7 = new MenuItem("Function key 7", new MenuShortcut(KeyEvent.VK_F7)); + MenuItem mi8 = new MenuItem("Function key 8", new MenuShortcut(KeyEvent.VK_F8)); + MenuItem mi9 = new MenuItem("Function key 8", new MenuShortcut(KeyEvent.VK_F9)); + + FunctionKeyShortcut fks = new FunctionKeyShortcut(); + mi1.addActionListener(fks); + mi2.addActionListener(fks); + mi3.addActionListener(fks); + mi4.addActionListener(fks); + mi5.addActionListener(fks); + mi6.addActionListener(fks); + mi7.addActionListener(fks); + mi8.addActionListener(fks); + mi9.addActionListener(fks); + + m.add(mi1); + m.add(mi2); + m.add(mi3); + m.add(mi4); + m.add(mi5); + m.add(mi6); + m.add(mi7); + m.add(mi8); + m.add(mi9); + + mb.add(m); + frame.setMenuBar(mb); + frame.setBounds(50,400,200,200); + frame.setVisible(true); + } + + public static void main(String[] args ) throws Exception { + + EventQueue.invokeAndWait(FunctionKeyShortcut::createUI); + try { + Robot robot = new Robot(); + + robot.waitForIdle(); + robot.delay(2000); + + // Ensure window has focus + Point p = frame.getLocationOnScreen(); + robot.mouseMove(p.x + frame.getWidth() / 2, p.y + frame.getHeight() / 2); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.waitForIdle(); + robot.delay(2000); + + int mod = (isMac) ? KeyEvent.VK_META : KeyEvent.VK_CONTROL; + robot.keyPress(mod); + robot.keyPress(KeyEvent.VK_F1); + robot.delay(50); + robot.keyRelease(KeyEvent.VK_F1); + robot.keyRelease(mod); + robot.waitForIdle(); + robot.delay(2000); + } finally { + if (frame != null) { + EventQueue.invokeAndWait(frame::dispose); + } + } + if (!event || failed) { + throw new RuntimeException("No actioncommand"); + } + } + + public void actionPerformed(ActionEvent e) { + System.out.println("Got " + e); + String s = e.getActionCommand(); + event = true; + if (s == null || !s.equals("Function key 1")) { + failed = true; + } + } + +} diff --git a/test/jdk/java/awt/MenuShortcut/MenuItemShortcutReplaceTest.java b/test/jdk/java/awt/MenuShortcut/MenuItemShortcutReplaceTest.java new file mode 100644 index 00000000000..fe59d1a02ef --- /dev/null +++ b/test/jdk/java/awt/MenuShortcut/MenuItemShortcutReplaceTest.java @@ -0,0 +1,111 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4080225 + * @summary A replaced menu shortcut does not draw in the menu. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual MenuItemShortcutReplaceTest + */ + +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.Frame; +import java.awt.Menu; +import java.awt.MenuBar; +import java.awt.MenuItem; +import java.awt.MenuShortcut; +import java.awt.Panel; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; + +/* + * Manual test because visual verification of the shortcut being painted is required. + */ + +public class MenuItemShortcutReplaceTest implements ActionListener { + + static boolean isMac = System.getProperty("os.name").startsWith("Mac"); + static String shortcut = (isMac) ? "Cmd" : "Ctrl"; + static String instructions = + "1. On the frame 'MenuItem Shortcut Replace Test' click on the Menu 'Click here'.\n" + + " You will see a MenuItem 'MenuItem1' with the shortcut key displayed as" + + " '" + shortcut + "+M'.\n" + + "2. Click the 'Change Shortcutkey' button.\n" + + "3. Now click on the Menu again to see the MenuItem.\n" + + "4. If the shortcut key displayed near the MenuItem is changed to " + + "'" + shortcut + "+C', press 'Pass' else press 'Fail'"; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("MenuItem Shortcut Replace Test Instructions") + .instructions(instructions) + .columns(60) + .logArea() + .testUI(MenuItemShortcutReplaceTest::createUI) + .build() + .awaitAndCheck(); + + } + + static volatile Button change; + static volatile MenuItem mi; + static volatile MenuShortcut ms; + + static Frame createUI() { + Frame frame = new Frame("MenuItem Shortcut Replace Test"); + MenuBar mb = new MenuBar(); + change = new Button("Change ShortcutKey"); + Panel p = new Panel(); + p.add(change); + MenuItemShortcutReplaceTest misrt = new MenuItemShortcutReplaceTest(); + change.addActionListener(misrt); + Menu m = new Menu("Click here"); + mb.add(m); + mi = new MenuItem("MenuItem1"); + m.add(mi); + mi.addActionListener(misrt); + frame.setMenuBar(mb); + //Set the shortcut key for the menuitem + ms = new MenuShortcut(KeyEvent.VK_M); + mi.setShortcut(ms); + frame.add(p, BorderLayout.SOUTH); + frame.setSize(300, 300); + return frame; + } + + public void actionPerformed(ActionEvent e) { + //change the shortcut key + if (e.getSource() == change) { + ms = new MenuShortcut(KeyEvent.VK_C); + mi.setShortcut(ms); + PassFailJFrame.log("Shortcut key set to "+shortcut+"C"); + } + if (e.getSource() == mi) { + PassFailJFrame.log("MenuItem Selected"); + } + } +} diff --git a/test/jdk/java/awt/Mouse/DoubleClickTest.java b/test/jdk/java/awt/Mouse/DoubleClickTest.java new file mode 100644 index 00000000000..037332a4098 --- /dev/null +++ b/test/jdk/java/awt/Mouse/DoubleClickTest.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Event; +import java.awt.Frame; +import java.awt.Panel; +import java.awt.TextArea; + +/* + * @test + * @bug 4092370 + * @summary Test to verify double click + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual DoubleClickTest + */ + +public class DoubleClickTest { + static TextArea ta = new TextArea("", 10, 40); + + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + 1. Double click on the red area. + 2. Verify that the event reports click_count > 1 on + Double-Click. If click_count shows only 1 for every + Double-Clicks then test FAILS, else test PASS. + """; + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(35) + .testUI(initialize()) + .build() + .awaitAndCheck(); + } + + public static Frame initialize() { + Frame frame = new Frame("Double-click Test"); + frame.setLayout(new BorderLayout()); + frame.add("East", new MyPanel(ta)); + frame.add("West", ta); + frame.setSize(200, 200); + return frame; + } +} + +class MyPanel extends Panel { + TextArea ta; + + MyPanel(TextArea ta) { + this.ta = ta; + setBackground(Color.red); + } + + public Dimension getPreferredSize() { + return new Dimension(50, 50); + } + + + public boolean mouseDown(Event event, int x, int y) { + ta.append("event click count= " + event.clickCount + "\n"); + return false; + } +} diff --git a/test/jdk/java/awt/Mouse/MouseClickCount.java b/test/jdk/java/awt/Mouse/MouseClickCount.java new file mode 100644 index 00000000000..a63d24fcb9f --- /dev/null +++ b/test/jdk/java/awt/Mouse/MouseClickCount.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Frame; +import java.awt.TextArea; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +/* + * @test + * @bug 4199397 + * @summary Test to mouse click count + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual MouseClickCount + */ + +public class MouseClickCount { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + 1. Clicking on Frame panel quickly will produce clickCount larger than 1 + in the TextArea the count is printed for each mouse click + 2. Verify that a left-button click followed by a right button click quickly + will not generate 1, 2, i.e. it's not considered a double clicking. + """; + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(35) + .testUI(initialize()) + .build() + .awaitAndCheck(); + } + + private static Frame initialize() { + Frame f = new Frame("Mouse Click Count Test"); + final TextArea ta = new TextArea(); + f.add("South", ta); + f.addMouseListener(new MouseAdapter() { + public void mousePressed(MouseEvent e) { + if (e.getClickCount() == 1) ta.append("\n1"); + else ta.append(", " + e.getClickCount()); + } + }); + f.setSize(300, 500); + return f; + } +} diff --git a/test/jdk/java/awt/Mouse/MouseDragEnterExitTest.java b/test/jdk/java/awt/Mouse/MouseDragEnterExitTest.java new file mode 100644 index 00000000000..b2d8e446ffc --- /dev/null +++ b/test/jdk/java/awt/Mouse/MouseDragEnterExitTest.java @@ -0,0 +1,117 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Frame; +import java.awt.Panel; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.List; + +/* + * @test + * @bug 4141361 + * @summary Test to Ensures that mouse enter / exit is delivered to a new + * frame or component during a drag + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual MouseDragEnterExitTest + */ + +public class MouseDragEnterExitTest { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + Click on the blue frame, drag to the white frame, and back + You should get enter/exit messages for the frames when dragging + """; + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(35) + .testUI(MouseEvents.initialize()) + .logArea(8) + .build() + .awaitAndCheck(); + } +} + +class MouseEvents extends Frame { + static int WITH_WIDGET = 0; + + public MouseEvents(int mode) { + super("Mouse Drag Enter/Exit Test"); + setSize(300, 300); + + addMouseListener(new MouseAdapter() { + @Override + public void mouseEntered(MouseEvent e) { + PassFailJFrame.log("Frame MOUSE_ENTERED" + ": " + " " + + e.getX() + " " + e.getY()); + } + + @Override + public void mouseExited(MouseEvent e) { + PassFailJFrame.log("Frame MOUSE_EXITED" + ": " + " " + + e.getX() + " " + e.getY()); + } + }); + + if (mode == WITH_WIDGET) { + setLayout(new BorderLayout()); + add("Center", new SimplePanel()); + } + } + + public static List initialize() { + MouseEvents m = new MouseEvents(MouseEvents.WITH_WIDGET); + m.setLocation(500, 300); + MouseEvents t = new MouseEvents(MouseEvents.WITH_WIDGET + 1); + t.setLocation(200, 200); + return List.of(m, t); + } +} + +class SimplePanel extends Panel { + public SimplePanel() { + super(); + setName("Test Panel"); + addMouseListener(new MouseAdapter() { + @Override + public void mouseEntered(MouseEvent e) { + PassFailJFrame.log("Panel MOUSE_ENTERED" + ": " + " " + + e.getX() + " " + e.getY()); + } + + @Override + public void mouseExited(MouseEvent e) { + PassFailJFrame.log("Panel MOUSE_EXITED" + ": " + " " + + e.getX() + " " + e.getY()); + } + }); + setSize(100, 100); + setBackground(Color.blue); + } +} + diff --git a/test/jdk/java/awt/Mouse/MouseDragTest.java b/test/jdk/java/awt/Mouse/MouseDragTest.java new file mode 100644 index 00000000000..cb8be7b0de2 --- /dev/null +++ b/test/jdk/java/awt/Mouse/MouseDragTest.java @@ -0,0 +1,215 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Canvas; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.event.MouseMotionAdapter; +import java.awt.event.MouseMotionListener; + +/* + * @test + * @bug 4035189 + * @summary Test to verify that Drag events go to wrong component + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual MouseDragTest + */ + +class HeavySquare extends Canvas { + private final Color colorNormal; + private boolean gotADragEvent; + + public HeavySquare(Color color) { + colorNormal = color; + setBackground(colorNormal); + new MouseChecker(this); + addMouseMotionListener(new DragAdapter()); + addMouseListener(new PressReleaseAdapter()); + } + + class DragAdapter extends MouseMotionAdapter { + public void mouseDragged(MouseEvent ev) { + if (gotADragEvent) + return; + + Point mousePt = ev.getPoint(); + Dimension csize = getSize(); + boolean inBounds = + (mousePt.x >= 0 && mousePt.x <= csize.width && + mousePt.y >= 0 && mousePt.y <= csize.height); + if (!inBounds) { + setBackground(Color.green); + } + gotADragEvent = true; + } + } + + class PressReleaseAdapter extends MouseAdapter { + public void mousePressed(MouseEvent ev) { + gotADragEvent = false; + } + + public void mouseReleased(MouseEvent ev) { + setBackground(colorNormal); + } + } + + public Dimension preferredSize() { + return new Dimension(50, 50); + } +} + +class MouseFrame extends Frame { + public MouseFrame() { + super("MouseDragTest"); + new MouseChecker(this); + setLayout(new FlowLayout()); + add(new HeavySquare(Color.red)); + add(new HeavySquare(Color.blue)); + setBounds(new Rectangle(20, 20, 400, 300)); + } +} + +public class MouseDragTest { + static Frame TestFrame; + + public MouseDragTest() { + TestFrame = new MouseFrame(); + } + + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + 1. A frame with two boxes will appear. Click and drag _very_ quickly + off one of the components. You will know you were quick enough + when the component you dragged off of turns green + 2. Repeat this several times on both boxes, ensuring you get them + to turn green. The components should revert to their original + color when you release the mouse + 3. The test FAILS if the component doesn't revert to original + color, else PASS. + """; + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(35) + .testUI(new MouseFrame()) + .build() + .awaitAndCheck(); + } +} + +class MouseChecker implements MouseListener, MouseMotionListener { + private boolean isPressed = false; + private MouseEvent evPrev = null; + private MouseEvent evPrevPrev = null; + + public MouseChecker(Component comp) { + comp.addMouseListener(this); + comp.addMouseMotionListener(this); + } + + private void recordEv(MouseEvent ev) { + evPrevPrev = evPrev; + evPrev = ev; + } + + private synchronized void failure(String str) { + PassFailJFrame.forceFail("Test Failed : "+str); + } + + public void mouseClicked(MouseEvent ev) { + if (!(evPrev.getID() == MouseEvent.MOUSE_RELEASED && + evPrevPrev.getID() == MouseEvent.MOUSE_PRESSED)) { + failure("Got mouse click without press/release preceding."); + } + recordEv(ev); + } + + public void mousePressed(MouseEvent ev) { + recordEv(ev); + if (isPressed) { + failure("Got two mouse presses without a release."); + } + isPressed = true; + } + + public void mouseReleased(MouseEvent ev) { + recordEv(ev); + if (!isPressed) { + failure("Got mouse release without being pressed."); + } + isPressed = false; + } + + public void mouseEntered(MouseEvent ev) { + recordEv(ev); + Point mousePt = ev.getPoint(); + Component comp = (Component) ev.getSource(); + Dimension size = comp.getSize(); + boolean inBounds = + (mousePt.x >= 0 && mousePt.x <= size.width && + mousePt.y >= 0 && mousePt.y <= size.height); + + if (!inBounds) { + failure("Got mouse entered, but mouse not inside component."); + } + } + + public void mouseExited(MouseEvent ev) { + recordEv(ev); + Point mousePt = ev.getPoint(); + Component comp = (Component) ev.getSource(); + if (comp instanceof Frame) { + return; + } + Dimension size = comp.getSize(); + boolean isOnChild = (comp != comp.getComponentAt(mousePt)); + boolean inBounds = + (mousePt.x >= 0 && mousePt.x <= size.width && + mousePt.y >= 0 && mousePt.y <= size.height); + if (!isOnChild && inBounds) { + failure("Got mouse exit, but mouse still inside component."); + } + } + + public void mouseDragged(MouseEvent ev) { + recordEv(ev); + if (!isPressed) { + failure("Got drag without a press first."); + } + } + + public void mouseMoved(MouseEvent ev) { + recordEv(ev); + } +} diff --git a/test/jdk/java/awt/Mouse/MouseEnterExitTest.java b/test/jdk/java/awt/Mouse/MouseEnterExitTest.java new file mode 100644 index 00000000000..059ad5c0548 --- /dev/null +++ b/test/jdk/java/awt/Mouse/MouseEnterExitTest.java @@ -0,0 +1,174 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Color; +import java.awt.Component; +import java.awt.Container; +import java.awt.Cursor; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Robot; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; + +/* + * @test + * @bug 4050138 + * @key headful + * @summary Test to verify Lightweight components don't get + * enter/exit during drags + * @run main MouseEnterExitTest + */ + +class LWSquare extends Container { + int width; + int height; + + public LWSquare(Color color, int w, int h) { + setBackground(color); + setLayout(new FlowLayout()); + width = w; + height = h; + addMouseListener(new EnterExitAdapter(this)); + setName("LWSquare-" + color.toString()); + } + + public void paint(Graphics g) { + g.setColor(getBackground()); + g.fillRect(0, 0, getSize().width, getSize().height); + super.paint(g); + } + + public Dimension getPreferredSize() { + return new Dimension(width, height); + } + + public Cursor getCursor() { + return new Cursor(Cursor.CROSSHAIR_CURSOR); + } +} + +class MouseFrame extends Frame { + public LWSquare lw; + + public MouseFrame() { + super("MouseEnterExitTest"); + setLayout(new FlowLayout()); + + lw = new LWSquare(Color.red, 75, 75); + add(lw); + setBounds(50, 50, 300, 200); + setVisible(true); + System.out.println(getInsets()); + + addMouseListener(new EnterExitAdapter(this)); + addWindowListener( + new WindowAdapter() { + public void windowClosing(WindowEvent ev) { + dispose(); + } + } + ); + addKeyListener( + new KeyAdapter() { + public void keyPressed(KeyEvent ev) { + MouseEnterExitTest.getFrame().setTitle("MouseEnterExitTest"); + } + } + ); + } +} + + +public class MouseEnterExitTest { + static MouseFrame testFrame; + + public static void main(String[] args) throws Exception { + Robot robot = new Robot(); + + robot.setAutoDelay(100); + try { + EventQueue.invokeAndWait(() -> testFrame = new MouseFrame()); + if (testFrame.lw.getBackground() != Color.red) { + throw new RuntimeException("Initial Background color not matching"); + } + robot.waitForIdle(); + robot.delay(100); + EventQueue.invokeAndWait(() -> robot.mouseMove( + testFrame.getLocationOnScreen().x + testFrame.getSize().width / 2, + testFrame.getLocationOnScreen().y + testFrame.getSize().height / 2)); + robot.waitForIdle(); + robot.delay(100); + + if (testFrame.lw.getBackground() != Color.green) { + throw new RuntimeException("Initial Background color not matching"); + } + EventQueue.invokeAndWait(() -> robot.mouseMove( + testFrame.getLocationOnScreen().x + testFrame.getSize().width * 2, + testFrame.getLocationOnScreen().y + testFrame.getSize().height / 2)); + robot.waitForIdle(); + robot.delay(100); + + if (testFrame.lw.getBackground() != Color.red) { + throw new RuntimeException("Initial Background color not matching"); + } + } finally { + EventQueue.invokeAndWait(() -> { + if (testFrame != null) { + testFrame.dispose(); + } + }); + } + } + + public static Frame getFrame() { + return testFrame; + } +} + +class EnterExitAdapter extends MouseAdapter { + Component compToColor; + Color colorNormal; + + EnterExitAdapter(Component comp) { + compToColor = comp; + colorNormal = comp.getBackground(); + } + + public void mouseEntered(MouseEvent ev) { + compToColor.setBackground(Color.green); + compToColor.repaint(); + } + + public void mouseExited(MouseEvent ev) { + compToColor.setBackground(colorNormal); + compToColor.repaint(); + } +} diff --git a/test/jdk/java/awt/Mouse/MouseEnterExitTest2.java b/test/jdk/java/awt/Mouse/MouseEnterExitTest2.java new file mode 100644 index 00000000000..e09ac333447 --- /dev/null +++ b/test/jdk/java/awt/Mouse/MouseEnterExitTest2.java @@ -0,0 +1,140 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.GridLayout; +import java.awt.Rectangle; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; + +/* + * @test + * @bug 4150851 + * @summary Tests enter and exit events when a lightweight component is on a border + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual MouseEnterExitTest2 + */ + +public class MouseEnterExitTest2 { + + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + 1. Verify that white component turns black whenever mouse enters the frame, + except when it enters the red rectangle. + 2. When the mouse enters the red part of the frame the component should stay white. + """; + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(35) + .testUI(EntryExitTest.initialize()) + .build() + .awaitAndCheck(); + } +} + +class EntryExitTest extends Component { + boolean inWin; + + public Dimension getPreferredSize() { + return new Dimension(200, 150); + } + + public void paint(Graphics g) { + Color c1, c2; + String s; + if (inWin) { + c1 = Color.black; + c2 = Color.white; + s = "IN"; + } else { + c2 = Color.black; + c1 = Color.white; + s = "OUT"; + } + g.setColor(c1); + Rectangle r = getBounds(); + g.fillRect(0, 0, r.width, r.height); + g.setColor(c2); + g.drawString(s, r.width / 2, r.height / 2); + } + + public static Frame initialize() { + EntryExitTest test = new EntryExitTest(); + MouseListener frameEnterExitListener = new MouseAdapter() { + public void mouseEntered(MouseEvent e) { + test.inWin = true; + test.repaint(); + } + + public void mouseExited(MouseEvent e) { + test.inWin = false; + test.repaint(); + } + }; + + Frame f = new Frame("Mouse Modifier Test"); + + f.add(test); + Component jc = new Component() { + public Dimension getPreferredSize() { + return new Dimension(100, 50); + } + + public void paint(Graphics g) { + Dimension d = getSize(); + g.setColor(Color.red); + g.fillRect(0, 0, d.width, d.height); + } + }; + final Container cont = new Container() { + public Dimension getPreferredSize() { + return new Dimension(100, 100); + } + }; + cont.setLayout(new GridLayout(2, 1)); + cont.add(jc); + jc.addMouseListener(new MouseAdapter() { + public void mouseEntered(MouseEvent e) { + //System.out.println("Component entered"); + } + public void mouseExited(MouseEvent e) { + //System.out.println("Component exited"); + } + }); + + f.add(cont, BorderLayout.NORTH); + f.addMouseListener(frameEnterExitListener); + f.pack(); + return f; + } +} diff --git a/test/jdk/java/awt/Mouse/MouseEnterExitTest3.java b/test/jdk/java/awt/Mouse/MouseEnterExitTest3.java new file mode 100644 index 00000000000..d5096d7acf0 --- /dev/null +++ b/test/jdk/java/awt/Mouse/MouseEnterExitTest3.java @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 java.awt.Button; +import java.awt.Frame; +import java.awt.GridLayout; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import javax.swing.JButton; + +/* + * @test + * @bug 4431868 + * @summary Tests that hw container doesn't receive mouse enter/exit events when mouse + * is moved between its lw and hw children + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual MouseEnterExitTest3 + */ + +public class MouseEnterExitTest3 { + static final Button button = new Button("Button"); + static final JButton jbutton = new JButton("JButton"); + static final Frame frame = new Frame("Mouse Enter/Exit Test"); + + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + 1. Move the mouse between Button and JButton + 2. Verify that the frame doesn't receive enter/exit events + (Enter/exit events are dumped to the area below) + 4. If you see enter/exit events dumped the test fails + """; + + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(35) + .testUI(initialize()) + .logArea(4) + .build() + .awaitAndCheck(); + } + + final static MouseListener listener = new MouseAdapter() { + public void mouseEntered(MouseEvent e) { + PassFailJFrame.log(e.toString()); + } + + public void mouseExited(MouseEvent e) { + PassFailJFrame.log(e.toString()); + } + }; + + public static Frame initialize() { + frame.setLayout(new GridLayout(2, 1)); + frame.add(button); + frame.add(jbutton); + frame.addMouseListener(listener); + frame.pack(); + return frame; + } +} diff --git a/test/jdk/java/awt/Mouse/MouseEnterExitTest4.java b/test/jdk/java/awt/Mouse/MouseEnterExitTest4.java new file mode 100644 index 00000000000..2ee3993ae4e --- /dev/null +++ b/test/jdk/java/awt/Mouse/MouseEnterExitTest4.java @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 java.awt.Button; +import java.awt.Color; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.Robot; +import java.awt.Window; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; + +/* + * @test + * @bug 4431868 + * @key headful + * @summary Tests that window totally obscured by its child doesn't receive + * enter/exit events when located over another frame + * @run main MouseEnterExitTest4 + */ + +public class MouseEnterExitTest4 { + static Button button = new Button("Button"); + static Frame frame = new Frame("Mouse Enter/Exit test"); + static Window window = new Window(frame); + static MouseListener listener = new MouseAdapter() { + public void mouseEntered(MouseEvent e) { + throw new RuntimeException("Test failed due to Mouse Enter event"); + } + + public void mouseExited(MouseEvent e) { + throw new RuntimeException("Test failed due to Mouse Exit event"); + } + }; + + public static void main(String[] args) throws Exception { + Robot robot = new Robot(); + + robot.setAutoDelay(100); + try { + EventQueue.invokeAndWait(() -> { + button.setBackground(Color.red); + window.add(button); + frame.setBounds(100, 100, 300, 300); + window.setBounds(200, 200, 100, 100); + window.addMouseListener(listener); + window.setVisible(true); + frame.setVisible(true); + }); + robot.waitForIdle(); + robot.delay(200); + EventQueue.invokeAndWait(() -> robot.mouseMove( + frame.getLocationOnScreen().x + frame.getSize().width / 2, + frame.getLocationOnScreen().y + frame.getSize().height / 2)); + robot.waitForIdle(); + robot.delay(200); + EventQueue.invokeAndWait(() -> robot.mouseMove( + window.getLocationOnScreen().x + window.getSize().width * 2, + window.getLocationOnScreen().y + window.getSize().height / 2)); + robot.waitForIdle(); + robot.delay(500); + System.out.println("Test Passed"); + + } finally { + EventQueue.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + if (window != null) { + window.dispose(); + } + }); + } + } +} diff --git a/test/jdk/java/awt/Mouse/MousePressedTest.java b/test/jdk/java/awt/Mouse/MousePressedTest.java new file mode 100644 index 00000000000..721d69bd5dd --- /dev/null +++ b/test/jdk/java/awt/Mouse/MousePressedTest.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Container; +import java.awt.GridLayout; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JRadioButton; +import javax.swing.JScrollPane; +import javax.swing.JToggleButton; + +/* + * @test + * @bug 4268759 + * @summary Tests whether clicking on the edge of a lightweight button + * causes sticking behavior + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual MousePressedTest + */ + +public class MousePressedTest { + + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + 1. Click and hold on the very bottom border (2-pixel-wide border) of the + JButton. Then drag the mouse straight down out of the JButton and + into the JRadioButton, and release the mouse button + 2. If the component remains highlighted as if the mouse button is still + down, the test fails + """; + + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(35) + .testUI(initialize()) + .build() + .awaitAndCheck(); + } + + public static JFrame initialize() { + JFrame f = new JFrame("JButton Test"); + JPanel p = new JPanel(); + p.setLayout(new GridLayout(2, 2)); + JButton b = new JButton("JButton"); + p.add(b); + JCheckBox cb = new JCheckBox("JCheckBox"); + p.add(cb); + JRadioButton rb = new JRadioButton("JRadioButton"); + p.add(rb); + p.add(new JToggleButton("JToggleButton")); + + JScrollPane j = new JScrollPane(p, + JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, + JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); + + Container c = f.getContentPane(); + c.setLayout(new GridLayout(1, 1)); + c.add(j); + f.pack(); + return f; + } +} diff --git a/test/jdk/java/awt/MouseInfo/ContainerResizeMousePositionTest.java b/test/jdk/java/awt/MouseInfo/ContainerResizeMousePositionTest.java new file mode 100644 index 00000000000..72aa4d93a5c --- /dev/null +++ b/test/jdk/java/awt/MouseInfo/ContainerResizeMousePositionTest.java @@ -0,0 +1,141 @@ +/* + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 java.awt.BorderLayout; +import java.awt.Button; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.Point; +import java.awt.Robot; +import java.awt.event.ComponentAdapter; +import java.awt.event.ComponentEvent; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + +/* + * @test + * @key headful + * @bug 4009555 + * @summary Unit test for a new method in Container class: getMousePosition(boolean) + * while Container resized. + */ + +public class ContainerResizeMousePositionTest { + private static Frame frame; + private static Button button; + private static Robot robot; + private static volatile Point frameLocation; + private static volatile Point newLoc; + private static boolean testSucceeded = false; + + private static final CountDownLatch eventCaught = new CountDownLatch(1); + + public static void main(String[] args) throws Exception { + try { + robot = new Robot(); + EventQueue.invokeAndWait(() -> createAndShowUI()); + robot.waitForIdle(); + robot.delay(1000); + testUI(); + } finally { + EventQueue.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } + + private static void createAndShowUI() { + frame = new Frame("Testing getMousePosition() after resize"); + button = new Button("Button"); + frame.setLayout(new BorderLayout()); + frame.add(button); + frame.setSize(200, 200); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } + + private static void testUI() throws Exception { + EventQueue.invokeAndWait(() -> { + frameLocation = frame.getLocationOnScreen(); + newLoc = new Point(frame.getWidth() + 10, frame.getHeight() + 10); + }); + + robot.mouseMove(frameLocation.x + newLoc.x, frameLocation.y + newLoc.y); + EventQueue.invokeAndWait(() -> { + button.addComponentListener(new ResizeAdapter()); + frame.setSize(frame.getWidth() * 2, frame.getHeight() * 2); + frame.validate(); + }); + robot.waitForIdle(); + robot.delay(500); + + if (!eventCaught.await(2, TimeUnit.SECONDS)) { + throw new RuntimeException("componentResized Event isn't" + + " received within a timeout"); + } + + if (!testSucceeded) { + throw new RuntimeException("Container.getMousePosition(boolean)" + + " returned incorrect result while Container resized"); + } + } + + static class ResizeAdapter extends ComponentAdapter { + int testStageCounter = 0; + @Override + public void componentResized(ComponentEvent e) { + Point pTrue = frame.getMousePosition(true); + if (frame.getMousePosition(false) == null) { + testStageCounter++; + System.out.println(""" + TEST STAGE 1 PASSED: + Container.getMousePosition(false) + returned NULL over Child Component + during resize. + """); + } + if (pTrue != null) { + testStageCounter++; + System.out.println(""" + TEST STAGE 2 PASSED: + Container.getMousePosition(true) + returned NON-NULL over Child Component + during resize. + """); + } + if (pTrue != null && pTrue.x == newLoc.x && pTrue.y == newLoc.y) { + testStageCounter++; + System.out.println(""" + TEST STAGE 3 PASSED: + Container.getMousePosition(true) + returned correct result over Child Component + during resize. + """); + } + testSucceeded = testStageCounter == 3; + eventCaught.countDown(); + } + } +} diff --git a/test/jdk/java/awt/Panel/PanelRepaint/PanelRepaint.java b/test/jdk/java/awt/Panel/PanelRepaint/PanelRepaint.java new file mode 100644 index 00000000000..da8de3947be --- /dev/null +++ b/test/jdk/java/awt/Panel/PanelRepaint/PanelRepaint.java @@ -0,0 +1,455 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4148078 + * @summary Repainting problems in scrolled panel + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual PanelRepaint + */ + +import java.awt.Button; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.Panel; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.Scrollbar; +import java.awt.TextField; +import java.awt.event.AdjustmentEvent; +import java.awt.event.AdjustmentListener; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; + +public class PanelRepaint extends Panel implements FocusListener { + static ScrollPanel sPanel; + static Panel panel; + + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + Using scrollbars or tab keys to scroll the panel and + the panel is messy sometimes, e.g. one row bumps into + another. If all components painted correctly, the test passes. + Otherwise, the test fails. + """; + + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .columns(35) + .testUI(PanelRepaint::createUI) + .build() + .awaitAndCheck(); + } + + public static Frame createUI() { + Frame f = new Frame("Panel Repaint Test"); + f.setLayout(new FlowLayout()); + f.setSize(620, 288); + PanelRepaint pr = new PanelRepaint(); + + panel = new Panel(); + panel.setLayout(null); + panel.setSize(500, 500); + sPanel = new ScrollPanel(panel); + + Button btn = new Button("Open"); + pr.addComp(btn); + btn.setBounds(400, 10, 60, 20); + btn.setActionCommand("OPEN"); + + Button btn1 = new Button("Close"); + pr.addComp(btn1); + btn1.setBounds(400, 50, 60, 20); + btn1.setActionCommand("CLOSE"); + + TextField t1 = new TextField("1"); + pr.addComp(t1); + t1.setBounds(10, 10, 100, 20); + TextField t2 = new TextField("2"); + pr.addComp(t2); + t2.setBounds(10, 50, 100, 20); + TextField t3 = new TextField("3"); + pr.addComp(t3); + t3.setBounds(10, 90, 100, 20); + TextField t4 = new TextField("4"); + pr.addComp(t4); + t4.setBounds(10, 130, 100, 20); + TextField t5 = new TextField("5"); + pr.addComp(t5); + t5.setBounds(10, 170, 100, 20); + TextField t6 = new TextField("6"); + pr.addComp(t6); + t6.setBounds(10, 210, 100, 20); + TextField t7 = new TextField("7"); + pr.addComp(t7); + t7.setBounds(10, 250, 100, 20); + TextField t8 = new TextField("8"); + pr.addComp(t8); + t8.setBounds(10, 290, 100, 20); + TextField t9 = new TextField("9"); + pr.addComp(t9); + t9.setBounds(10, 330, 100, 20); + + TextField t11 = new TextField("1"); + pr.addComp(t11); + t11.setBounds(120, 10, 100, 20); + TextField t12 = new TextField("2"); + pr.addComp(t12); + t12.setBounds(120, 50, 100, 20); + TextField t13 = new TextField("3"); + pr.addComp(t13); + t13.setBounds(120, 90, 100, 20); + TextField t14 = new TextField("4"); + pr.addComp(t14); + t14.setBounds(120, 130, 100, 20); + TextField t15 = new TextField("5"); + pr.addComp(t15); + t15.setBounds(120, 170, 100, 20); + TextField t16 = new TextField("6"); + pr.addComp(t16); + t16.setBounds(120, 210, 100, 20); + TextField t17 = new TextField("7"); + pr.addComp(t17); + t17.setBounds(120, 250, 100, 20); + TextField t18 = new TextField("8"); + pr.addComp(t18); + t18.setBounds(120, 290, 100, 20); + TextField t19 = new TextField("9"); + pr.addComp(t19); + t19.setBounds(120, 330, 100, 20); + + + TextField t21 = new TextField("1"); + pr.addComp(t21); + t21.setBounds(240, 10, 100, 20); + TextField t22 = new TextField("2"); + pr.addComp(t22); + t22.setBounds(240, 50, 100, 20); + TextField t23 = new TextField("3"); + pr.addComp(t23); + t23.setBounds(240, 90, 100, 20); + TextField t24 = new TextField("4"); + pr.addComp(t24); + t24.setBounds(240, 130, 100, 20); + TextField t25 = new TextField("5"); + pr.addComp(t25); + t25.setBounds(240, 170, 100, 20); + TextField t26 = new TextField("6"); + pr.addComp(t26); + t26.setBounds(240, 210, 100, 20); + TextField t27 = new TextField("7"); + pr.addComp(t27); + t27.setBounds(240, 250, 100, 20); + TextField t28 = new TextField("8"); + pr.addComp(t28); + t28.setBounds(240, 290, 100, 20); + TextField t29 = new TextField("9"); + pr.addComp(t29); + t29.setBounds(240, 330, 100, 20); + + pr.add(sPanel); + f.add(pr); + sPanel.setBounds(100, 100, 500, 250); + sPanel.doLayout(); + return f; + } + + public void addComp(Component c) { + panel.add(c); + c.addFocusListener(this); + } + + public void focusGained(FocusEvent e) { + sPanel.showComponent(e.getComponent()); + } + + public void focusLost(FocusEvent e) { + } +} + +class ScrollPanel extends Panel implements AdjustmentListener { + /** + * Constructor + */ + public ScrollPanel(Component c) { + setLayout(null); + setBackground(Color.lightGray); + add(hScroll = new Scrollbar(Scrollbar.HORIZONTAL)); + add(vScroll = new Scrollbar(Scrollbar.VERTICAL)); + add(square = new Panel()); + square.setBackground(Color.lightGray); + add(c); + } + + /** + * Scroll up/down/left/right to show the component specified + * + * @param comp is the component to be shown + */ + public void showComponent(Component comp) { + Component view = getComponent(3); + Rectangle viewRect = view.getBounds(); + Rectangle scrollRect = getBounds(); + Rectangle rect = comp.getBounds(); + while (comp != null) { + Component parent = comp.getParent(); + if (parent == null || parent == view) { + break; + } + Point p = parent.getLocation(); + rect.x += p.x; + rect.y += p.y; + comp = parent; + } + + int i = viewRect.y + rect.y; + int j = (viewRect.y + rect.y + rect.height + ScrollPanel.H_HEIGHT) + - (scrollRect.height); + + if (i < 0) { + vertUpdate(i); + } else if (j > 0) { + vertUpdate(j); + } + + i = viewRect.x + rect.x; + j = (viewRect.x + rect.x + rect.width + (V_WIDTH * 2)) - (scrollRect.width); + + if (i < 0) { + horzUpdate(i); + } else if (j > 0) { + horzUpdate(j); + } + } + + /** + * Returns the panel component of ScrollPanel + * + * @return the panel component of ScrollPanel + */ + public Component getScrolled() { + return getComponent(3); + } + + /** + * updates the scroll panel vertically with value i passed + * + * @param i the value to be updated with + */ + public void vertUpdate(int i) { + update(true, vScroll.getValue() + i); + } + + /** + * updates the scroll panel horizontally with value i passed + * + * @param i the value to be updated with + */ + public void horzUpdate(int i) { + update(false, hScroll.getValue() + i); + } + + /** + * updates the scroll panel vertically if bVert is true else horizontally + * + * @param n is the value + */ + public void update(boolean bVert, int n) { + if (n < 0) n = 0; + if (bVert) { + if (n > max.height) { + n = max.height; + } + if (offset.y != n) { + offset.y = n; + vScroll.setValue(n); + } + } else { + if (n > max.width) { + n = max.width; + } + if (offset.x != n) { + offset.x = n; + hScroll.setValue(n); + } + } + getScrolled().setLocation(-offset.x, -offset.y); + } + + /** + * Implementation of AdjustmentListener + */ + public void adjustmentValueChanged(AdjustmentEvent e) { + boolean bVert = e.getSource() == vScroll; + update(bVert, e.getValue()); + } + + /** + * Reimplementation of Component Methods + */ + public void addNotify() { + super.addNotify(); + vScroll.addAdjustmentListener(this); + hScroll.addAdjustmentListener(this); + } + + public void removeNotify() { + super.removeNotify(); + vScroll.removeAdjustmentListener(this); + hScroll.removeAdjustmentListener(this); + } + + public void setBounds(int x, int y, int w, int h) { + super.setBounds(x, y, w, h); + doLayout(); + } + + public void doLayout() { + Component c = getScrolled(); + Dimension d = c.getSize(); + if (d.width == 0 || d.height == 0) { + d = c.getPreferredSize(); + } + vert = 0; + horz = 0; + Dimension m = getSize(); + if (d.height > m.height || isScroll(true, m.height - horz, 0, d.height)) { + vert = V_WIDTH; + } + if (d.width + vert > m.width || isScroll(false, m.width - vert, 0, d.width)) { + horz = H_HEIGHT; + } + if (d.height + horz > m.height || isScroll(true, m.height - horz, 0, d.height)) { + vert = V_WIDTH; + } + if (d.width + vert > m.width || isScroll(false, m.width - vert, 0, d.width)) { + horz = H_HEIGHT; + } + if (horz != 0) { + if (m.width <= 0) { + m.width = 1; + } + hScroll.setBounds(0, m.height - H_HEIGHT, m.width - vert, H_HEIGHT); + hScroll.setValues(offset.x, m.width - vert, 0, d.width); + int i = d.width / 10; + if (i < 2) { + i = 2; + } + hScroll.setBlockIncrement(i); + i = d.width / 50; + if (i < 1) { + i = 1; + } + hScroll.setUnitIncrement(i); + max.width = d.width; + hScroll.setVisible(true); + } else { + offset.x = 0; + } + if (vert != 0) { + if (m.height <= 0) { + m.height = 1; + } + vScroll.setBounds(m.width - V_WIDTH, 0, V_WIDTH, m.height - horz); + vScroll.setValues(offset.y, m.height - horz, 0, d.height); + int i = d.height / 10; + if (i < 2) i = 2; + vScroll.setBlockIncrement(i); + i = d.height / 50; + if (i < 1) i = 1; + vScroll.setUnitIncrement(i); + max.height = d.height; + vScroll.setVisible(true); + } else { + offset.y = 0; + } + if (horz != 0 && vert != 0) { + square.setBounds(m.width - V_WIDTH, m.height - H_HEIGHT, V_WIDTH, H_HEIGHT); + square.setVisible(true); + } else { + square.setVisible(false); + } + c.setBounds(-offset.x, -offset.y, d.width, d.height); + c.repaint(); + updateScroll(true, offset.y); + updateScroll(false, offset.x); + } + + public Dimension getPreferredSize() { + return getScrolled().getPreferredSize(); + } + + public Dimension getMinimumSize() { + return getScrolled().getMinimumSize(); + } + + boolean isScroll(boolean bVert, int visible, int min, int max) { + int tot = max - min; + int net = tot - visible; + if (net <= 0) { + return false; + } + return true; + } + + void updateScroll(boolean bVert, int n) { + Component c = getScrolled(); + Dimension d = c.getSize(); + Dimension m = getSize(); + m.width -= vert; + m.height -= horz; + if (bVert) { + if (n >= 0 && d.height > m.height) { + if (n + m.height > d.height) + n = d.height - m.height; + } else + n = 0; + update(true, n); + } else { + if (n >= 0 && d.width > m.width) { + if (n + m.width > d.width) + n = d.width - m.width; + } else + n = 0; + update(false, n); + } + } + + static Scrollbar hScroll; + static Scrollbar vScroll; + static int vert = 0; + static int horz = 0; + + static Point offset = new Point(); + static Dimension max = new Dimension(); + // ScrollTimer timer; + static Component square; + final static int V_WIDTH = 17; + final static int H_HEIGHT = 17; +} diff --git a/test/jdk/java/awt/PopupMenu/ActivePopupCrashTest.java b/test/jdk/java/awt/PopupMenu/ActivePopupCrashTest.java new file mode 100644 index 00000000000..51c12964e62 --- /dev/null +++ b/test/jdk/java/awt/PopupMenu/ActivePopupCrashTest.java @@ -0,0 +1,220 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.Label; +import java.awt.Menu; +import java.awt.MenuBar; +import java.awt.MenuItem; +import java.awt.Panel; +import java.awt.Point; +import java.awt.PopupMenu; +import java.awt.Robot; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.InputEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +import java.util.Hashtable; + +/* + * @test + * @bug 4214550 + * @summary Tests that there is no seg fault on repeatedly showing + * PopupMenu by right-clicking Label, Panel or Button + * @key headful + * @run main ActivePopupCrashTest + */ + +public class ActivePopupCrashTest { + private static Frame f; + private static Label l; + private static Button b; + private static Panel p; + + private static volatile Point labelCenter; + private static volatile Point buttonCenter; + private static volatile Point panelCenter; + + public static void main(String[] args) throws Exception { + final int REPEAT_COUNT = 5; + try { + Robot robot = new Robot(); + robot.setAutoDelay(50); + EventQueue.invokeAndWait(ActivePopupCrashTest::createAndShowUI); + robot.delay(1000); + + EventQueue.invokeAndWait(() -> { + labelCenter = getCenterPoint(l); + buttonCenter = getCenterPoint(b); + panelCenter = getCenterPoint(p); + }); + + for (int i = 0; i < REPEAT_COUNT; i++) { + robot.mouseMove(labelCenter.x, labelCenter.y); + robot.mousePress(InputEvent.BUTTON3_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON3_DOWN_MASK); + + robot.mouseMove(buttonCenter.x, buttonCenter.y); + robot.mousePress(InputEvent.BUTTON3_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON3_DOWN_MASK); + + robot.mouseMove(panelCenter.x, panelCenter.y); + robot.mousePress(InputEvent.BUTTON3_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON3_DOWN_MASK); + } + + // To close the popup, otherwise test fails on windows with timeout error + robot.mouseMove(panelCenter.x - 5, panelCenter.y - 5); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + } finally { + EventQueue.invokeAndWait(() -> { + if (f != null) { + f.dispose(); + } + }); + } + } + + private static Point getCenterPoint(Component component) { + Point p = component.getLocationOnScreen(); + Dimension size = component.getSize(); + return new Point(p.x + size.width / 2, p.y + size.height / 2); + } + + public static void createAndShowUI() { + f = new Frame("ActivePopupCrashTest Test"); + MenuItem item = new MenuItem("file-1"); + item.addActionListener(ActivePopupCrashTest::logActionEvent); + Menu m = new Menu("file"); + m.add(item); + item = new MenuItem("file-2"); + m.add(item); + MenuBar mb = new MenuBar(); + mb.add(m); + + f.setMenuBar(mb); + f.setSize(200, 200); + f.setLayout(new BorderLayout()); + + l = new Label("label"); + addPopup(l, "label"); + f.add(l, BorderLayout.NORTH); + + p = new Panel(); + addPopup(p, "panel"); + f.add(p, BorderLayout.CENTER); + + b = new Button("button"); + addPopup(b, "button"); + f.add(b, BorderLayout.SOUTH); + + f.setSize(400, 300); + f.setLocationRelativeTo(null); + f.setVisible(true); + } + + static void addPopup(Component c, String name) { + PopupMenu pm = new PopupMenu(); + MenuItem mi = new MenuItem(name + "-1"); + mi.addActionListener(ActivePopupCrashTest::logActionEvent); + pm.add(mi); + + mi = new MenuItem(name + "-2"); + pm.add(mi); + + setHash(c, pm); + c.add(pm); + c.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + mouseAction("mouseClicked", e); + } + + @Override + public void mousePressed(MouseEvent e) { + mouseAction("mousePressed", e); + } + + @Override + public void mouseReleased(MouseEvent e) { + mouseAction("mouseReleased", e); + } + }); + } + + static void logActionEvent(ActionEvent e) { + System.out.println("actionPerformed, event=" + e + ", mod=" + getMods(e)); + System.out.println("command=" + e.getActionCommand()); + System.out.println("param=" + e.paramString()); + System.out.println("source=" + e.getSource()); + } + + static String getMods(ActionEvent e) { return getMods(e.getModifiers()); } + + static String getMods(MouseEvent e) { return getMods(e.getModifiers()); } + + static String getMods(int mods) { + String modstr = ""; + if ((mods & ActionEvent.SHIFT_MASK) == ActionEvent.SHIFT_MASK) { + modstr += (" SHIFT"); + } else if ((mods & ActionEvent.ALT_MASK) == ActionEvent.ALT_MASK) { + modstr += (" ALT"); + } else if ((mods & ActionEvent.CTRL_MASK) == ActionEvent.CTRL_MASK) { + modstr += (" CTRL"); + } else if ((mods & ActionEvent.META_MASK) == ActionEvent.META_MASK) { + modstr += (" META"); + } + return modstr; + } + + static void mouseAction(String which, MouseEvent e) { + Component c = e.getComponent(); + System.out.println(which + " e = " + e + " , mods = " + getMods(e) + + " , component = " + c); + if (e.isPopupTrigger()) { + System.out.println("isPopup"); + PopupMenu pm = getHash(c); + pm.show(c, c.getWidth() / 2, c.getHeight() / 2); + } + } + + static Hashtable popupTable = new Hashtable<>(); + + static void setHash(Component c, PopupMenu p) { + popupTable.put(c, p); + } + + static PopupMenu getHash(Component c) { + return popupTable.get(c); + } + +} diff --git a/test/jdk/java/awt/PopupMenu/KeyTraversalCrash.java b/test/jdk/java/awt/PopupMenu/KeyTraversalCrash.java new file mode 100644 index 00000000000..4d1d4e8f831 --- /dev/null +++ b/test/jdk/java/awt/PopupMenu/KeyTraversalCrash.java @@ -0,0 +1,126 @@ +/* + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.Label; +import java.awt.Menu; +import java.awt.MenuItem; +import java.awt.Point; +import java.awt.PopupMenu; +import java.awt.Robot; + +import java.awt.event.InputEvent; +import java.awt.event.KeyEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +/* + * @test + * @bug 5021183 + * @summary Tests Key Traversal doesn't crash PopupMenu + * @key headful + * @run main KeyTraversalCrash + */ + +public class KeyTraversalCrash { + private static Frame f; + private static Label label; + + private static volatile Point loc; + private static volatile Dimension dim; + + public static void main(String[] args) throws Exception { + try { + Robot robot = new Robot(); + robot.setAutoDelay(100); + EventQueue.invokeAndWait(KeyTraversalCrash::createAndShowUI); + robot.delay(1000); + + EventQueue.invokeAndWait(() -> { + loc = label.getLocationOnScreen(); + dim = label.getSize(); + }); + + robot.mouseMove(loc.x + 20, loc.y + 20); + robot.mousePress(InputEvent.BUTTON3_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON3_DOWN_MASK); + + robot.mouseMove(loc.x + 25, loc.y + 25); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + + robot.keyPress(KeyEvent.VK_LEFT); + robot.keyRelease(KeyEvent.VK_LEFT); + + robot.keyPress(KeyEvent.VK_DOWN); + robot.keyRelease(KeyEvent.VK_DOWN); + + // To close the popup, otherwise test fails on windows with timeout error + robot.mouseMove(loc.x + dim.width - 20, loc.y + dim.height - 20); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + } finally { + EventQueue.invokeAndWait(() -> { + if (f != null) { + f.dispose(); + } + }); + } + } + + public static void createAndShowUI() { + f = new Frame("KeyTraversalCrash Test"); + final PopupMenu popup = new PopupMenu(); + for (int i = 0; i < 10; i++) { + Menu menu = new Menu("Menu " + i); + for(int j = 0; j < 10; j++) { + MenuItem menuItem = new MenuItem("MenuItem " + j); + menu.add(menuItem); + } + popup.add(menu); + } + label = new Label("Label"); + f.add(label); + f.add(popup); + label.addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(MouseEvent me) { + if (me.isPopupTrigger()) { + popup.show(me.getComponent(), me.getX(), me.getY()); + } + } + + @Override + public void mouseReleased(MouseEvent me) { + if (me.isPopupTrigger()) { + popup.show(me.getComponent(), me.getX(), me.getY()); + } + } + }); + f.setSize(200, 200); + f.setLocationRelativeTo(null); + f.setVisible(true); + } +} diff --git a/test/jdk/java/awt/PopupMenu/MultiplePopupMenusTest.java b/test/jdk/java/awt/PopupMenu/MultiplePopupMenusTest.java new file mode 100644 index 00000000000..f939186ca07 --- /dev/null +++ b/test/jdk/java/awt/PopupMenu/MultiplePopupMenusTest.java @@ -0,0 +1,86 @@ +/* + * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.AWTEvent; +import java.awt.Button; +import java.awt.Frame; +import java.awt.MenuItem; +import java.awt.PopupMenu; + +import java.awt.event.MouseEvent; + +/* + * @test + * @bug 4186663 4265525 + * @summary Tests that multiple PopupMenus cannot appear at the same time + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual MultiplePopupMenusTest + */ + +public class MultiplePopupMenusTest { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + Click the right mouse button on the button + If multiple popups appear at the same time the + test fails else passes. + """; + + PassFailJFrame.builder() + .title("MultiplePopupMenusTest Instruction") + .instructions(INSTRUCTIONS) + .columns(30) + .testUI(MultiplePopupMenusTest::createUI) + .build() + .awaitAndCheck(); + } + + private static Frame createUI() { + Frame fr = new Frame("MultiplePopupMenusTest Test"); + TestButton button = new TestButton("button"); + fr.add(button); + fr.setSize(200, 200); + return fr; + } + + static class TestButton extends Button { + public TestButton(String title) { + super(title); + enableEvents(AWTEvent.MOUSE_EVENT_MASK); + } + + @Override + public void processMouseEvent(MouseEvent e) { + if (e.isPopupTrigger()) { + for (int i = 0; i < 10; i++) { + PopupMenu pm = new PopupMenu("Popup " + i); + pm.add(new MenuItem("item 1")); + pm.add(new MenuItem("item 2")); + add(pm); + pm.show(this, e.getX() + i * 5, e.getY() + i * 5); + } + } + super.processMouseEvent(e); + } + } +} diff --git a/test/jdk/java/awt/PopupMenu/PeripheryOfScreen.java b/test/jdk/java/awt/PopupMenu/PeripheryOfScreen.java new file mode 100644 index 00000000000..b169a7d9692 --- /dev/null +++ b/test/jdk/java/awt/PopupMenu/PeripheryOfScreen.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Button; +import java.awt.Frame; +import java.awt.MenuItem; +import java.awt.PopupMenu; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +/* + * @test + * @bug 6267162 + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @summary Popup Menu gets hidden below the screen when opened near the periphery + * of the screen, XToolkit Test if popup menu window is adjusted on screen + * when trying to show outside + * @run main/manual PeripheryOfScreen + */ + +public class PeripheryOfScreen { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + Click on the button to show popup menu in the center of + frame. Move frame beyond the edge of screen and click on + button to show the popup menu and see if popup menu is + adjusted to the edge. + + Press Pass if popup menu behaves as per instruction, otherwise + press Fail. + """; + + PassFailJFrame.builder() + .title("PeripheryOfScreen Instruction") + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(PeripheryOfScreen::createUI) + .build() + .awaitAndCheck(); + } + + private static Frame createUI () { + Frame f = new Frame("PeripheryOfScreen Test frame"); + Button b = new Button("Click to show popup menu"); + PopupMenu pm = new PopupMenu("Test menu"); + MenuItem i = new MenuItem("Click me"); + pm.add(i); + b.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + pm.show(f, 100, 100); + } + }); + f.add(b); + f.add(pm); + f.setSize(300, 200); + f.toFront(); + return f; + } +} diff --git a/test/jdk/java/awt/PopupMenu/PopupHangTest.java b/test/jdk/java/awt/PopupMenu/PopupHangTest.java new file mode 100644 index 00000000000..bfdf6bf2abe --- /dev/null +++ b/test/jdk/java/awt/PopupMenu/PopupHangTest.java @@ -0,0 +1,258 @@ +/* + * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +/* + * @test + * @bug 4145193 + * @summary Mouse event activates multiple pull-down menus when testing Oracle app + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual PopupHangTest +*/ + +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Label; +import java.awt.MenuItem; +import java.awt.PopupMenu; +import java.awt.event.FocusEvent; +import java.awt.event.KeyEvent; +import java.awt.event.MouseEvent; +import java.awt.event.FocusListener; +import java.awt.event.KeyListener; +import java.awt.event.MouseListener; +import java.awt.event.MouseMotionListener; + +public class PopupHangTest { + private static final String INSTRUCTIONS = """ + 2 areas yellow and red should be seen. + + Clicking in these areas should cause a menu to popup. See if you can + get the menu to stay up and grab all input. One way to do this is to + click and hold the mouse to popup the menu, move away/outside of the + menu and release the mouse. At that point, the input is grabbed and + the *only* way out is to hit the escape key. Try this on both areas. + + To make things worse, when the popup menu is up, click repeatedly on + the LightWeight component area. Hit escape. Do you see multiple menus appearing ? + + If you do not see either of the two problems above, the problem is fixed. + Press pass, else press Fail"""; + + static Frame frame; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("PopupHangTest") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(45) + .testUI(PopupHangTest::createUI) + .logArea() + .build() + .awaitAndCheck(); + } + + private static Frame createUI() { + TestMenuButton m1; + TestHeavyButton m2; + frame = new Frame(); + + frame.setLayout (new BorderLayout ()); + + m1 = new TestMenuButton("LightWeight component"); + m1.setBackground(Color.yellow); + + m2 = new TestHeavyButton("HeavyWeight component"); + m2.setBackground(Color.red); + + frame.add("North", m1); + frame.add("South", m2); + + m1.requestFocus(); + frame.setSize(200, 110); + return frame; + } + +} + +class TestMenuButton extends Component implements MouseListener, + MouseMotionListener, + KeyListener, + FocusListener { + + PopupMenu popupMenu = null; + String name; + + TestMenuButton(String name) { + PopupMenu menu = popupMenu = new PopupMenu("Popup"); + menu.add(new MenuItem("item 1")); + menu.add(new MenuItem("item 2")); + menu.add(new MenuItem("item 3")); + this.add(menu); + this.name = name; + addMouseListener(this); + addMouseMotionListener(this); + addKeyListener(this); + addFocusListener(this); + } + + void println(String messageIn) { + PassFailJFrame.log(messageIn); + } + + public void mouseClicked(MouseEvent event) { + /* + popupMenu.show(this, event.getX(), event.getY()); + */ + } + public void mousePressed(MouseEvent event) { + println("TestMenuButton.mousePressed() called !!"); + popupMenu.show(this, event.getX(), event.getY()); + } + public void mouseReleased(MouseEvent event) { + println("TestMenuButton.mouseReleased() called !!"); + } + public void mouseEntered(MouseEvent event) { + println("TestMenuButton.mouseEntered() called !!"); + requestFocus(); + } + public void mouseExited(MouseEvent event) { + } + + public void mouseDragged(MouseEvent event) { + println("TestMenuButton.mouseDragged() called !!"); + } + public void mouseMoved(MouseEvent event) { + println("TestMenuButton.mouseMoved() called !!"); + } + + public void keyPressed(KeyEvent event) { + println("TestMenuButton.keyPressed() called !!"); + } + public void keyReleased(KeyEvent event) { + println("TestMenuButton.keyReleased() called !!"); + } + public void keyTyped(KeyEvent event) { + println("TestMenuButton.keyTyped() called !!"); + } + + + public void focusGained(FocusEvent e){ + println("TestMenuButton.focusGained():" + e); + } + public void focusLost(FocusEvent e){ + println("TestMenuButton.focusLost():" + e); + } + + + public void paint(Graphics g) { + Dimension d = getSize(); + + g.setColor(getBackground()); + g.fillRect(0, 0, d.width-1, d.height-1); + + g.setColor(Color.black); + g.drawString(name, 15, 15); + } + + public Dimension getPreferredSize() { + return (new Dimension(200, 50)); + } + +} + +class TestHeavyButton extends Label implements MouseListener, + MouseMotionListener, + KeyListener, + FocusListener { + + PopupMenu popupMenu = null; + String name; + + TestHeavyButton(String name) { + super(name); + PopupMenu menu = popupMenu = new PopupMenu("Popup"); + menu.add(new MenuItem("item 1")); + menu.add(new MenuItem("item 2")); + menu.add(new MenuItem("item 3")); + this.add(menu); + this.name = name; + addMouseListener(this); + addMouseMotionListener(this); + addKeyListener(this); + addFocusListener(this); + } + + void println(String messageIn) { + PassFailJFrame.log(messageIn); + } + + public void mouseClicked(MouseEvent event) { + /* + popupMenu.show(this, event.getX(), event.getY()); + */ + } + public void mousePressed(MouseEvent event) { + println("TestHeavyButton.mousePressed() called !!"); + popupMenu.show(this, event.getX(), event.getY()); + } + public void mouseReleased(MouseEvent event) { + println("TestHeavyButton.mouseReleased() called !!"); + } + public void mouseEntered(MouseEvent event) { + println("TestHeavyButton.mouseEntered() called !!"); + requestFocus(); + } + public void mouseExited(MouseEvent event) { + } + + public void mouseDragged(MouseEvent event) { + println("TestHeavyButton.mouseDragged() called !!"); + } + public void mouseMoved(MouseEvent event) { + println("TestHeavyButton.mouseMoved() called !!"); + } + + public void keyPressed(KeyEvent event) { + println("TestHeavyButton.keyPressed() called !!"); + } + public void keyReleased(KeyEvent event) { + println("TestHeavyButton.keyReleased() called !!"); + } + public void keyTyped(KeyEvent event) { + println("TestHeavyButton.keyTyped() called !!"); + } + + public void focusGained(FocusEvent e){ + println("TestHeavyButton.focusGained():" + e); + } + public void focusLost(FocusEvent e){ + println("TestHeavyButton.focusLost():" + e); + } + +} + diff --git a/test/jdk/java/awt/PopupMenu/PopupLeadingSeparatorTest.java b/test/jdk/java/awt/PopupMenu/PopupLeadingSeparatorTest.java new file mode 100644 index 00000000000..c9274e9b807 --- /dev/null +++ b/test/jdk/java/awt/PopupMenu/PopupLeadingSeparatorTest.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Component; +import java.awt.Frame; +import java.awt.Font; +import java.awt.MenuItem; +import java.awt.PopupMenu; + +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +/* + * @test + * @bug 4169155 + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @summary Popup menus get a leading separator on Motif system + * @run main/manual PopupLeadingSeparatorTest + */ + +public class PopupLeadingSeparatorTest { + public static void main(String[] args) throws Exception { + PopupLeadingSeparatorTest obj = new PopupLeadingSeparatorTest(); + String INSTRUCTIONS = """ + Press mouse button on the frame. Popup menu without leading + separator should appear. + If a PopupMenu behaves same, press Pass, else press Fail. + """; + + PassFailJFrame.builder() + .title("PopupLeadingSeparatorTest Instruction") + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(obj::createUI) + .build() + .awaitAndCheck(); + } + + private Frame createUI() { + Frame f = new Frame("PopupLeadingSeparatorTest Test"); + PopupMenu popupMenu = new PopupMenu("Popup Menu Title"); + popupMenu.add(new MenuItem("Item1")); + PopupMenu cascadeMenu = new PopupMenu("Multifont menu"); + cascadeMenu.add(new MenuItem("Item1")); + MenuItem item2 = new MenuItem("Item2"); + item2.setFont(new Font("Serif", Font.BOLD, 36)); + cascadeMenu.add(item2); + + popupMenu.add(cascadeMenu); + f.add(popupMenu); + f.setSize(300, 150); + f.addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(MouseEvent evt) { + popupMenu.show((Component) evt.getSource(), evt.getX(), evt.getY()); + } + }); + return f; + } +} diff --git a/test/jdk/java/awt/PopupMenu/PopupMenuCrash.java b/test/jdk/java/awt/PopupMenu/PopupMenuCrash.java new file mode 100644 index 00000000000..7ba738b21d2 --- /dev/null +++ b/test/jdk/java/awt/PopupMenu/PopupMenuCrash.java @@ -0,0 +1,106 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.Label; +import java.awt.MenuItem; +import java.awt.PopupMenu; + +import java.awt.event.InputEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +/* + * @test + * @bug 4281273 + * @summary PopupMenu crashed in Java. Simplified testcase. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @requires (os.family == "windows") + * @run main/manual PopupMenuCrash + */ + +public class PopupMenuCrash { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + This tests a windows specific problem. + When you see a frame titled "PopupMenuCrash Test", right-click on it + several times for a few seconds. Then wait about 10 seconds before the + PopupMenus start to appear. Then dispose them one by one by clicking on them. + When PopupMenus do not appear anymore, press Pass. + In case of a failure, you'll see a crash. + """; + + PassFailJFrame.builder() + .title("PopupMenuCrash Instruction") + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(PopupMenuCrash::createUI) + .build() + .awaitAndCheck(); + } + + private static Frame createUI() { + final Frame f = new Frame("PopupMenuCrash Test"); + f.setLayout(new FlowLayout()); + f.add(new Label("Press right mouse button inside this frame.")); + f.add(new Label("A pop-up menu should appear.")); + f.addMouseListener(new MouseAdapter() { + PopupMenu popup; + boolean firstPress = true; + + @Override + public void mousePressed(MouseEvent evt) { + if (firstPress) { + firstPress = false; + try { + Thread.sleep(10000); + } catch (InterruptedException ignored) { + } + } + + if ((evt.getModifiers() & InputEvent.BUTTON3_MASK) != 0) { + popup = new PopupMenu("Popup Menu Title"); + MenuItem mi = new MenuItem("MenuItem"); + popup.add(mi); + f.add(popup); + popup.show(evt.getComponent(), evt.getX(), evt.getY()); + } + } + + @Override + public void mouseReleased(MouseEvent evt) { + if ((evt.getModifiers() & InputEvent.BUTTON3_MASK) != 0) { + if (popup != null) { + f.remove(popup); + popup = null; + } + } + } + }); + + f.setSize(400, 350); + return f; + } +} diff --git a/test/jdk/java/awt/PopupMenu/PopupMenuShowTest.java b/test/jdk/java/awt/PopupMenu/PopupMenuShowTest.java new file mode 100644 index 00000000000..b36fdc5d19c --- /dev/null +++ b/test/jdk/java/awt/PopupMenu/PopupMenuShowTest.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.Label; +import java.awt.MenuItem; +import java.awt.PopupMenu; + +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +/* + * @test + * @bug 4168006 4196790 + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @summary Popup menu test fails on x86/Solaris 2.6 combination. + * @run main/manual PopupMenuShowTest + */ + +public class PopupMenuShowTest { + public static void main(String[] args) throws Exception { + PopupMenuShowTest obj = new PopupMenuShowTest(); + String INSTRUCTIONS = """ + Press the right mouse button in the PopupTest window. + If a PopupMenu appears, press Pass, else press Fail. + """; + + PassFailJFrame.builder() + .title("PopupMenuShowTest Instruction") + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(obj::createUI) + .build() + .awaitAndCheck(); + } + + private Frame createUI() { + Frame f = new Frame("PopupMenuShowTest Test"); + f.setLayout(new FlowLayout()); + f.add(new Label("Press right mouse button inside this frame.")); + f.add(new Label("A pop-up menu should appear.")); + PopupMenu popupMenu = new PopupMenu("Popup Menu Title"); + MenuItem mi = new MenuItem("Menu Item"); + popupMenu.add(mi); + f.add(popupMenu); + f.setSize(400, 350); + f.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + popupMenu.show(e.getComponent(), e.getX(), e.getY()); + } + }); + return f; + } +} diff --git a/test/jdk/java/awt/PopupMenu/PopupMenuVisuals.java b/test/jdk/java/awt/PopupMenu/PopupMenuVisuals.java new file mode 100644 index 00000000000..3aa437e4845 --- /dev/null +++ b/test/jdk/java/awt/PopupMenu/PopupMenuVisuals.java @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +/* + * @test + * @bug 6180413 6184485 6267144 + * @summary test for popup menu visual bugs in XAWT + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual PopupMenuVisuals +*/ + +import java.awt.Button; +import java.awt.CheckboxMenuItem; +import java.awt.Frame; +import java.awt.Menu; +import java.awt.MenuItem; +import java.awt.MenuShortcut; +import java.awt.PopupMenu; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; + +public class PopupMenuVisuals { + private static final String INSTRUCTIONS = """ + This test should show a button 'Popup'. + Click on the button. A popup menu should be shown. + If following conditions are met: + - Menu is disabled + - Menu has caption 'Popup menu' (only applicable for linux) + - Menu items don't show shortcuts + + Click Pass else click Fail."""; + + static PopupMenu pm; + static Frame frame; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("PopupMenu Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(35) + .testUI(PopupMenuVisuals::createTestUI) + .build() + .awaitAndCheck(); + } + + static class Listener implements ActionListener { + public void actionPerformed(ActionEvent e) { + pm.show(frame, 0, 0); + } + } + + private static Frame createTestUI() { + Button b = new Button("Popup"); + pm = new PopupMenu("Popup menu"); + MenuItem mi1 = new MenuItem("Item 1"); + CheckboxMenuItem mi2 = new CheckboxMenuItem("Item 2"); + CheckboxMenuItem mi3 = new CheckboxMenuItem("Item 3"); + Menu sm = new Menu("Submenu"); + + //Get things going. Request focus, set size, et cetera + frame = new Frame("PopupMenuVisuals"); + frame.setSize (200,200); + frame.validate(); + + frame.add(b); + b.addActionListener(new Listener()); + mi1.setShortcut(new MenuShortcut(KeyEvent.VK_A)); + pm.add(mi1); + pm.add(mi2); + pm.add(mi3); + pm.add(sm); + sm.add(new MenuItem("Item")); + pm.setEnabled(false); + mi3.setState(true); + frame.add(pm); + return frame; + } + +} diff --git a/test/jdk/java/awt/PopupMenu/PopupMenuWithMenuBar.java b/test/jdk/java/awt/PopupMenu/PopupMenuWithMenuBar.java new file mode 100644 index 00000000000..1a927e29f84 --- /dev/null +++ b/test/jdk/java/awt/PopupMenu/PopupMenuWithMenuBar.java @@ -0,0 +1,103 @@ +/* + * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Frame; +import java.awt.Menu; +import java.awt.MenuBar; +import java.awt.MenuItem; +import java.awt.PopupMenu; + +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +/* + * @test + * @bug 4038140 + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @summary Test for functionality of PopupMenuWithMenuBar + * @run main/manual PopupMenuWithMenuBar + */ + +public class PopupMenuWithMenuBar { + public static void main(String[] args) throws Exception { + PopupMenuWithMenuBar obj = new PopupMenuWithMenuBar(); + String INSTRUCTIONS = """ + There was a bug that prevented the popup menu from appearing properly + (if even at all) for a frame window when there is also a menu bar. + + Right click inside the frame window to display the popup window. If + the popup menu appears normally, then the test is successful and the + bug has been fixed."""; + + PassFailJFrame.builder() + .title("PopupMenuWithMenuBar Instruction") + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(obj::createUI) + .build() + .awaitAndCheck(); + } + + private Frame createUI() { + Frame f = new Frame("PopupMenuWithMenuBar Test"); + f.setBounds(10, 10, 300, 250); + MenuBar menuBar = new MenuBar(); + Menu fileMenu = createFileMenu(); + menuBar.add(fileMenu); + f.setMenuBar(menuBar); + PopupMenu popupMenu = createPopupMenu(); + f.add(popupMenu); + f.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + popupMenu.show(f, e.getX(), e.getY()); + } + }); + return f; + } + + private Menu createFileMenu() { + String[] menu1Labels = new String[] + {"Save As", "Save As", "Quit"}; + MenuItem menuItem; + Menu returnMenu = new Menu("File"); + for (int menu1Index = 0; menu1Index < menu1Labels.length; menu1Index++) { + menuItem = new MenuItem(menu1Labels[menu1Index]); + returnMenu.add(menuItem); + } + return returnMenu; + } + + private PopupMenu createPopupMenu() { + String[] popupLabels = new String[] + {"Popup 1", "Popup 2", "Quit"}; + MenuItem menuItem; + PopupMenu returnMenu = new PopupMenu("Popups"); + for (int popupIndex = 0; popupIndex < popupLabels.length; popupIndex++) { + menuItem = new MenuItem(popupLabels[popupIndex]); + returnMenu.add(menuItem); + } + return returnMenu; + } +} diff --git a/test/jdk/java/awt/PopupMenu/PopupOnButton.java b/test/jdk/java/awt/PopupMenu/PopupOnButton.java new file mode 100644 index 00000000000..581714bf76a --- /dev/null +++ b/test/jdk/java/awt/PopupMenu/PopupOnButton.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Button; +import java.awt.Component; +import java.awt.Frame; +import java.awt.MenuItem; +import java.awt.PopupMenu; + +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +/* + * @test + * @bug 4181790 + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @summary Tests a popup menu on a button. + * @run main/manual PopupOnButton + */ + +public class PopupOnButton { + public static void main(String[] args) throws Exception { + PopupOnButton obj = new PopupOnButton(); + String INSTRUCTIONS = """ + Right-click on the button. + Popup Menu should appear and behave fine. + If a PopupMenu appears, press Pass, else press Fail. + """; + + PassFailJFrame.builder() + .title("PopupOnButton Instruction") + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(obj::createUI) + .build() + .awaitAndCheck(); + } + + private Frame createUI() { + Frame f = new Frame("PopupOnButton Test"); + Button b = new Button("button with popup menu"); + PopupMenu m = new PopupMenu("popup"); + m.add(new MenuItem("item1")); + m.add(new MenuItem("item2")); + m.add(new MenuItem("item3")); + b.add(m); + b.addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + if (e.isPopupTrigger()) { + m.show((Component) e.getSource(), e.getX(), e.getY()); + } + } + + @Override + public void mouseReleased(MouseEvent e) { + if (e.isPopupTrigger()) { + m.show((Component) e.getSource(), e.getX(), e.getY()); + } + } + }); + + f.add(b); + f.setSize(200, 150); + return f; + } + } diff --git a/test/jdk/java/awt/PopupMenu/StressTest.java b/test/jdk/java/awt/PopupMenu/StressTest.java new file mode 100644 index 00000000000..221aa252aa0 --- /dev/null +++ b/test/jdk/java/awt/PopupMenu/StressTest.java @@ -0,0 +1,142 @@ +/* + * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Component; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.MenuItem; +import java.awt.Panel; +import java.awt.Point; +import java.awt.PopupMenu; +import java.awt.Robot; + +import java.awt.event.InputEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +/* + * @test + * @bug 4083400 + * @key headful + * @summary Tests that excessive popping up and down does not crash or + * throw an exception. + * @run main StressTest + */ + +public class StressTest { + private static Frame fr; + private static PopupTestPanel panel; + + private static volatile Point panelCenter; + + public static void main(String[] args) throws Exception { + final int REPEAT_COUNT = 5; + try { + Robot robot = new Robot(); + robot.setAutoDelay(50); + EventQueue.invokeAndWait(StressTest::createAndShowUI); + robot.delay(1000); + + EventQueue.invokeAndWait(() -> { + Point loc = panel.getLocationOnScreen(); + Dimension dim = panel.getSize(); + panelCenter = new Point(loc.x + dim.width / 2, loc.y + dim.height / 2); + }); + + for (int i = 0; i < REPEAT_COUNT; i++) { + robot.mouseMove(panelCenter.x + i * 2, panelCenter.y + i * 2); + + robot.mousePress(InputEvent.BUTTON3_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON3_DOWN_MASK); + + robot.mouseMove(panelCenter.x - i * 2, panelCenter.y - i * 2); + + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + } + } finally { + EventQueue.invokeAndWait(() -> { + if (fr != null) { + fr.dispose(); + } + }); + } + } + + public static void createAndShowUI() { + fr = new Frame("PopupMenu Test"); + panel = new PopupTestPanel(); + fr.add(panel); + fr.setSize(300, 200); + fr.setVisible(true); + } + + static class PopupTestPanel extends Panel { + + static class Item extends MenuItem { + public Item(String text) { + super(text); + } + + public boolean isEnabled() { + try { + Thread.sleep(100); + } catch (InterruptedException ignored) { + } + return super.isEnabled(); + } + } + + final PopupMenu popup; + + public PopupTestPanel() { + popup = new PopupMenu(); + popup.add(new Item("Soap")); + popup.add(new Item("Sponge")); + popup.add(new Item("Flannel")); + popup.add(new Item("Mat")); + popup.add(new Item("Towel")); + add(popup); + addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + if (e.isPopupTrigger()) { + showPopup(e); + } + } + + @Override + public void mouseReleased(MouseEvent e) { + if (e.isPopupTrigger()) { + showPopup(e); + } + } + + private void showPopup(MouseEvent e) { + popup.show((Component) e.getSource(), e.getX(), e.getY()); + } + }); + } + } +} diff --git a/test/jdk/java/awt/PrintJob/PrintCompatibilityTest.java b/test/jdk/java/awt/PrintJob/PrintCompatibilityTest.java new file mode 100644 index 00000000000..a2433f45547 --- /dev/null +++ b/test/jdk/java/awt/PrintJob/PrintCompatibilityTest.java @@ -0,0 +1,446 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Button; +import java.awt.Canvas; +import java.awt.Checkbox; +import java.awt.Choice; +import java.awt.Color; +import java.awt.Component; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Insets; +import java.awt.JobAttributes; +import java.awt.Label; +import java.awt.List; +import java.awt.Menu; +import java.awt.MenuBar; +import java.awt.MenuItem; +import java.awt.PageAttributes; +import java.awt.Panel; +import java.awt.PrintJob; +import java.awt.Scrollbar; +import java.awt.ScrollPane; +import java.awt.TextArea; +import java.awt.TextField; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.awt.JobAttributes.DialogType; +import java.awt.PageAttributes.OriginType; + +import java.util.Enumeration; +import java.util.Properties; + +/* + * @test + * @bug 4247583 + * @key printer + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @summary Tests that the old Properties API still works + * @run main/manual PrintCompatibilityTest + */ + +public class PrintCompatibilityTest { + + public static void main(String[] args) throws Exception { + + String INSTRUCTIONS = """ + A frame window will appear. + Choose 'Print to Printer...' from the 'Print' menu. Make sure that you print + to a printer, not a file. Examine the output and verify that the frame and all + the components in it get printed properly. + + Known problems: + * The text in the second row of the menubar is not indented correctly. + + You can also use the 'Print to Screen...' command for a quick manual check that + printing works, but this is only for debugging purposes."""; + + PassFailJFrame.builder() + .title("PrintComponentTest Test Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(60) + .testTimeOut(10) + .testUI(new MainFrame()) + .logArea(8) + .build() + .awaitAndCheck(); + } +} + +class MainFrame extends Frame { + private LWContainer lwc; + + public MainFrame() { + super("PrintCompatibilityTest"); + + setSize(800, 400); + setLayout(new FlowLayout()); + + // peered components + Button button = new Button("Button"); + button.setFont(new Font("Dialog", Font.PLAIN, 12)); + add(button); + add(new TestCanvas()); + Checkbox cbox = new Checkbox("Checkbox", true); + cbox.setFont(new Font("DialogInput", Font.PLAIN, 12)); + add(cbox); + Choice choice = new Choice(); + choice.add("Choice 1"); + choice.add("Choice Two"); + choice.setFont(new Font("Monospaced", Font.PLAIN, 12)); + add(choice); + Label label = new Label("Label"); + label.setFont(new Font("Serif", Font.PLAIN, 12)); + add(label); + List list = new List(); + list.add("List 1"); + list.add("List Two"); + list.setFont(new Font("SansSerif", Font.PLAIN, 12)); + add(list); + add(new Scrollbar(Scrollbar.VERTICAL) ); + add(new Scrollbar(Scrollbar.HORIZONTAL) ); + ScrollPane scrollpane = new ScrollPane(); + Button spButton = new Button("Button in a scrollpane"); + spButton.setFont(new Font("Monospaced", Font.PLAIN, 12)); + scrollpane.add(spButton); + add(scrollpane); + TextArea textarea = new TextArea("TextArea", 3, 30); + textarea.setFont(new Font("Dialog", Font.ITALIC, 10)); + add(textarea); + TextField textfield = new TextField("TextField"); + textfield.setFont(new Font("DialogInput", Font.ITALIC, 10)); + add(textfield); + + // nested components + Panel panel1 = new Panel(); + panel1.setLayout(new FlowLayout()); + panel1.setBackground(Color.red); + this.add(panel1); + + Button p1Button = new Button("level 2"); + p1Button.setFont(new Font("Monospaced", Font.ITALIC, 10)); + panel1.add(p1Button); + + Panel panel2 = new Panel(); + panel2.setLayout(new FlowLayout()); + panel2.setBackground(Color.green); + panel1.add(panel2); + + Button p2Button = new Button("level 3"); + p2Button.setFont(new Font("Serif", Font.ITALIC, 10)); + panel2.add(p2Button); + + + // lightweight components + LWButton lwbutton = new LWButton("LWbutton"); + lwbutton.setFont(new Font("SansSerif", Font.ITALIC, 10)); + add(lwbutton); + + lwc = new LWContainer("LWContainerLWContainerLWContainerLWContainerLWContainerLWContainerLWContainerLWContainerLWContainerLWContainerLWContainerLWContainerLWContainer"); + lwc.setFont(new Font("Monospaced", Font.ITALIC, 10)); + add(lwc); + Button lwcButton1 = new Button("HW Button 1"); + Button lwcButton2 = new Button("HW Button 2"); + LWButton lwcButton3 = new LWButton("LW Button"); + lwcButton1.setFont(new Font("Dialog", Font.BOLD, 14)); + lwcButton2.setFont(new Font("DialogInput", Font.BOLD, 14)); + lwcButton3.setFont(new Font("Monospaced", Font.BOLD, 14)); + lwc.add(lwcButton1); + lwc.add(lwcButton2); + lwc.add(lwcButton3); + + // overlapping components + add(new ZOrderPanel()); + + /////////////////////// + + Menu menu = new Menu("Print"); + Menu menu2 = new Menu("File"); + Menu menu3 = new Menu("Edit"); + Menu menu4 = new Menu("ReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyLong"); + menu2.setFont(new Font("SansSerif", Font.BOLD, 20)); + menu2.setEnabled(false); + menu3.setFont(new Font("Monospaced", Font.ITALIC, 18)); + menu3.setEnabled(false); + menu4.setEnabled(false); + MenuItem itemPrinter = new MenuItem("Print to Printer..."); + MenuItem itemScreen = new MenuItem("Print to Screen..."); + menu.add(itemPrinter); + menu.add(itemScreen); + MenuBar menuBar = new MenuBar(); + menuBar.add( menu ); + menuBar.add( menu2 ); + menuBar.add( menu3 ); + menuBar.add( menu4 ); + setMenuBar(menuBar); + + itemPrinter.addActionListener( new ActionPrint() ); + itemScreen.addActionListener( new ActionPrintToScreen() ); + setVisible(true); + } + + static void printProps(Properties props) + { + Enumeration propNames = props.propertyNames(); + while (propNames.hasMoreElements()) { + String propName = (String)propNames.nextElement(); + PassFailJFrame.log( propName + " = " + props.getProperty(propName)); + } + } + + class ActionPrint implements ActionListener { + private final int ITERATIONS = 1; + private Properties props = new Properties(); + + public void actionPerformed(ActionEvent ev) { + PassFailJFrame.log("About to show print dialog..."); + printProps(props); + PrintJob pj = getToolkit().getPrintJob( + MainFrame.this, "Print test!", props); + if (pj == null) { + return; + } + Dimension d = pj.getPageDimension(); + PassFailJFrame.log("About to print..."); + PassFailJFrame.log("Dimensions: " + d); + printProps(props); + + // For xor mode set, there is a printing issue with number of copies to be print. + // So, ITERATIONS are changed to 1 from 3. + // So, for now the XOR related code is commented out. + + //boolean xor = false; + + for (int i = 0; i < ITERATIONS; i++) { + Graphics g = pj.getGraphics(); + g.setColor(Color.red); + //if (xor) { + // g.setXORMode(Color.blue); + //} + g.translate(13, 13); + printAll(g); + g.dispose(); + //xor = (xor) ? false : true; + } + + // For xor mode set, LWC components don't get printed. + // So, for now the code is commented out and separate bug + // (JDK-8340495) is filed to handle it. + + // one more page so that we can test printing a lightweight + // at the top of the hierarchy (BugId 4212564) + //Graphics g = pj.getGraphics(); + //g.setColor(Color.red); + //g.translate(13, 13); + //lwc.printAll(g); + //g.dispose(); + // end 4212564 + + pj.end(); + } + } + + class ActionPrintToScreen implements ActionListener { + public void actionPerformed(ActionEvent ev) { + PrintFrame printFrame = new PrintFrame(MainFrame.this); + printFrame.show(); + Graphics g = printFrame.getGraphics(); + g.setColor(Color.red); + printAll(g); + g.dispose(); + } + } + + // Frame window that displays results of printing + // main window to a screen Graphics-- useful for + // quick testing of printing + class PrintFrame extends Frame + { + private Component printComponent; + public PrintFrame( Component c ) + { + super("Print to Screen"); + printComponent = c ; + addWindowListener( new WindowAdapter() { + public void windowClosing(WindowEvent ev) { + setVisible(false); + dispose(); + } + } + ); + setSize(printComponent.getSize()); + setResizable(false); + } + + public void paint( Graphics g ) { + printComponent.printAll(g); + } + } + + class LWButton extends Component { + String label; + int width = 100; + int height = 30; + + public LWButton(String label) { + super(); + this.label = label; + } + + public void paint(Graphics g) { + Dimension d = getSize(); + g.setColor(Color.orange); + g.setFont(getFont()); + g.fillRect(0, 0, d.width, d.height); + g.setColor(Color.black); + int x = 5; + int y = (d.height - 5); + g.drawString(label, x, y); + } + + public Dimension getPreferredSize() + { + return new Dimension(width, height); + } + } + + class LWContainer extends Container { + String label; + int width = 300; + int height = 100; + + public LWContainer(String label) { + super(); + this.label = label; + setLayout(new FlowLayout()); + } + + public void paint(Graphics g) { + super.paint(g); + Dimension d = getSize(); + g.setColor(Color.green); + g.setFont(getFont()); + g.drawLine(0, 0, d.width - 1, 0); + g.drawLine(d.width - 1, 0, d.width - 1, d.height - 1); + g.drawLine(d.width - 1, d.height - 1, 0, d.height - 1); + g.drawLine(0, d.height - 1, 0, 0); + g.setColor(Color.black); + int x = 5; + int y = (d.height - 5); + g.drawString(label, x, y); + } + + public Dimension getPreferredSize() + { + return new Dimension(width, height); + } + } + + class TestCanvas extends Canvas { + int width = 100; + int height = 100; + + public void paint(Graphics g) { + g.setColor(Color.blue); + g.fillRoundRect(10, 10, 50, 50, 15, 30); + g.setColor(Color.red); + g.fillOval(70, 70, 25, 25); + } + public Dimension getPreferredSize() { + return new Dimension(width, height); + } + } + + class ZOrderPanel extends Panel + { + ZOrderPanel() + { + setLayout(null); + + Component first, second, third, fourth; + + setVisible(true); + // add first component + first = makeBox("Second", Color.blue, + new Font("Serif", Font.BOLD, 14), + -1); + // insert on top + second = makeBox("First", Color.yellow, + new Font("SansSerif", Font.BOLD, 14), + 0); + // put at the back + fourth = makeBox("Fourth", Color.red, + new Font("Monospaced", Font.BOLD, 14), + 2); + // insert in last position + third = makeBox("Third", Color.green, + new Font("Dialog", Font.PLAIN, 12), + 3); + // swap third and fourth to correct positions + remove(third); + add(third, 2); + // re-validate so third and fourth peers change position + validate(); + // now make things really interesting with a lightweight + // component at the top of the z-order, that should print + // _below_ the native guys to match the screen... + add(new LWButton("LWButton"), 0); + } + + public Dimension preferredSize() + { + return new Dimension(260, 80); + } + + public void layout() + { + int i, n; + Insets ins = getInsets(); + n = getComponentCount(); + for (i = n-1; i >= 0; i--) { + Component p = getComponent(i); + p.setBounds(ins.left + 40 * i, ins.top + 5 * i, 60, 60); + } + } + + public Component makeBox(String s, Color c, Font f, int index) + { + Label l = new Label(s); + l.setBackground(c); + l.setAlignment(Label.RIGHT); + l.setFont(f); + add(l, index); + validate(); + return l; + } + } +} diff --git a/test/jdk/java/awt/PrintJob/PrintComponentTest.java b/test/jdk/java/awt/PrintJob/PrintComponentTest.java new file mode 100644 index 00000000000..d568c5a4279 --- /dev/null +++ b/test/jdk/java/awt/PrintJob/PrintComponentTest.java @@ -0,0 +1,486 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Button; +import java.awt.Canvas; +import java.awt.Checkbox; +import java.awt.Choice; +import java.awt.Color; +import java.awt.Component; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Insets; +import java.awt.JobAttributes; +import java.awt.Label; +import java.awt.List; +import java.awt.Menu; +import java.awt.MenuBar; +import java.awt.MenuItem; +import java.awt.PageAttributes; +import java.awt.Panel; +import java.awt.PrintJob; +import java.awt.Scrollbar; +import java.awt.ScrollPane; +import java.awt.TextArea; +import java.awt.TextField; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.awt.JobAttributes.DialogType; +import java.awt.PageAttributes.OriginType; + + +/* + * @test + * @bug 4111262 4035285 4038900 4046147 4049680 4084038 4100004 4105875 + * @bug 4117502 4037486 4068433 4128031 4151161 4151707 4155884 4212564 + * @bug 4025626 4029565 4034365 4036068 4040622 4061890 4067405 4086256 + * @bug 4113827 4116722 4121984 4145350 4146510 4172659 4179886 4218471 + * @bug 4219657 4227128 4242308 4245917 4265746 + * @key printer + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @summary Test printing of lightweight (and heavyweight) components + * @run main/manual PrintComponentTest + */ + +public class PrintComponentTest { + public static void main(String[] args) throws Exception { + + String INSTRUCTIONS = """ + A frame window will appear. + Choose 'Print to Printer...' from the 'Print' menu. Examine the output + and verify that the frame and all the components in it get printed properly. + + Print using both 'Portrait' and 'Landscape' orientation. + Verify that the paper dimensions printed to standard error + are exactly inverted. + (That is, if the output for 'Portrait' is + "Dimensions: java.awt.Dimension[width=612,height=792]" then the output + for 'Landscape' should be "Dimensions: java.awt.Dimension[width=792, height=612].) + + Now, attempt to print a second time. When the print dialog box appears, + however, cancel the print request. + Verify that _no_ output is sent to standard error. + + You should attempt to print with both the native and common print dialogs, + as well as with no dialog. + Note that on Linux the native and common print dialogs are identical. + + On Windows, the common print dialog communicates with the printer to + determine supported paper sizes and duplex capability. + Verify that these constraints are properly enforced in the common dialog + for the target printer. + + Known problems: + * The text in the second row of the menubar is not indented + correctly. + + You can also use the 'Print to Screen...' command for a quick manual + check that printing works, but this is only for debugging purposes."""; + + PassFailJFrame.builder() + .title("PrintComponentTest Test Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(60) + .testTimeOut(10) + .testUI(new MainFrame()) + .logArea(8) + .build() + .awaitAndCheck(); + } +} + +class MainFrame extends Frame { + private LWContainer lwc; + + public MainFrame() { + super("PrintComponentTest"); + + setSize(800, 400); + setLayout(new FlowLayout()); + + // peered components + Button button = new Button("Button"); + button.setFont(new Font("Dialog", Font.PLAIN, 12)); + add(button); + add(new TestCanvas()); + Checkbox cbox = new Checkbox("Checkbox", true); + cbox.setFont(new Font("DialogInput", Font.PLAIN, 12)); + add(cbox); + Choice choice = new Choice(); + choice.add("Choice 1"); + choice.add("Choice Two"); + choice.setFont(new Font("Monospaced", Font.PLAIN, 12)); + add(choice); + Label label = new Label("Label"); + label.setFont(new Font("Serif", Font.PLAIN, 12)); + add(label); + List list = new List(); + list.add("List 1"); + list.add("List Two"); + list.setFont(new Font("SansSerif", Font.PLAIN, 12)); + add(list); + add(new Scrollbar(Scrollbar.VERTICAL) ); + add(new Scrollbar(Scrollbar.HORIZONTAL) ); + ScrollPane scrollpane = new ScrollPane(); + Button spButton = new Button("Button in a scrollpane"); + spButton.setFont(new Font("Monospaced", Font.PLAIN, 12)); + scrollpane.add(spButton); + add(scrollpane); + TextArea textarea = new TextArea("TextArea", 3, 30); + textarea.setFont(new Font("Dialog", Font.ITALIC, 10)); + add(textarea); + TextField textfield = new TextField("TextField"); + textfield.setFont(new Font("DialogInput", Font.ITALIC, 10)); + add(textfield); + + // nested components + Panel panel1 = new Panel(); + panel1.setLayout(new FlowLayout()); + panel1.setBackground(Color.red); + this.add(panel1); + + Button p1Button = new Button("level 2"); + p1Button.setFont(new Font("Monospaced", Font.ITALIC, 10)); + panel1.add(p1Button); + + Panel panel2 = new Panel(); + panel2.setLayout(new FlowLayout()); + panel2.setBackground(Color.green); + panel1.add(panel2); + + Button p2Button = new Button("level 3"); + p2Button.setFont(new Font("Serif", Font.ITALIC, 10)); + panel2.add(p2Button); + + + // lightweight components + LWButton lwbutton = new LWButton("LWbutton"); + lwbutton.setFont(new Font("SansSerif", Font.ITALIC, 10)); + add(lwbutton); + + lwc = new LWContainer("LWContainerLWContainerLWContainerLWContainerLWContainerLWContainerLWContainerLWContainerLWContainerLWContainerLWContainerLWContainerLWContainer"); + lwc.setFont(new Font("Monospaced", Font.ITALIC, 10)); + add(lwc); + Button lwcButton1 = new Button("HW Button 1"); + Button lwcButton2 = new Button("HW Button 2"); + LWButton lwcButton3 = new LWButton("LW Button"); + lwcButton1.setFont(new Font("Dialog", Font.BOLD, 14)); + lwcButton2.setFont(new Font("DialogInput", Font.BOLD, 14)); + lwcButton3.setFont(new Font("Monospaced", Font.BOLD, 14)); + lwc.add(lwcButton1); + lwc.add(lwcButton2); + lwc.add(lwcButton3); + + // overlapping components + add(new ZOrderPanel()); + + /////////////////////// + + Menu menu = new Menu("Print"); + Menu menu2 = new Menu("File"); + Menu menu3 = new Menu("Edit"); + Menu menu4 = new Menu("ReallyReallyReallyReallyReallyReallyReallyReally" + + "ReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReally" + + "ReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyLong"); + menu2.setFont(new Font("SansSerif", Font.BOLD, 20)); + menu2.setEnabled(false); + menu3.setFont(new Font("Monospaced", Font.ITALIC, 18)); + menu3.setEnabled(false); + menu4.setEnabled(false); + MenuItem itemJFC = + new MenuItem("Print to Printer with Cross-Platform Dialog..."); + itemJFC.setActionCommand("common"); + MenuItem itemNative = + new MenuItem("Print to Printer with Native Dialog..."); + itemNative.setActionCommand("native"); + MenuItem itemBackground = + new MenuItem("Print to Printer in Background"); + itemBackground.setActionCommand("none"); + MenuItem itemScreen = new MenuItem("Print to Screen..."); + menu.add(itemJFC); + menu.add(itemNative); + menu.add(itemBackground); + menu.add(itemScreen); + MenuBar menuBar = new MenuBar(); + menuBar.add( menu ); + menuBar.add( menu2 ); + menuBar.add( menu3 ); + menuBar.add( menu4 ); + setMenuBar(menuBar); + + ActionPrint actionPrint = new ActionPrint(); + + itemJFC.addActionListener( actionPrint ); + itemNative.addActionListener( actionPrint ); + itemBackground.addActionListener( actionPrint ); + itemScreen.addActionListener( new ActionPrintToScreen() ); + } + + class ActionPrint implements ActionListener { + private final int ITERATIONS = 1; + private PageAttributes pageAttributes = new PageAttributes(); + private JobAttributes jobAttributes = new JobAttributes(); + + public void actionPerformed(ActionEvent ev) { + DialogType dialog; + if (ev.getActionCommand().equals("common")) { + dialog = DialogType.COMMON; + } else if (ev.getActionCommand().equals("native")) { + dialog = DialogType.NATIVE; + } else { + dialog = DialogType.NONE; + } + jobAttributes.setDialog(dialog); + pageAttributes.setOrigin(OriginType.PRINTABLE); + System.err.println(jobAttributes); + System.err.println(pageAttributes); + + PassFailJFrame.log("About to show print dialog..."); + + PrintJob pj = getToolkit().getPrintJob( + MainFrame.this, "Print test!", jobAttributes, pageAttributes); + if (pj == null) { + return; + } + Dimension d = pj.getPageDimension(); + PassFailJFrame.log("About to print..."); + PassFailJFrame.log("Dimensions: " + d); + System.err.println(jobAttributes); + System.err.println(pageAttributes); + + // For xor mode set, there is a printing issue with number of copies to be print. + // So, ITERATIONS are changed to 1 from 3. + // So, for now the XOR related code is commented out. + + //boolean xor = false; + + for (int i = 0; i < ITERATIONS; i++) { + Graphics g = pj.getGraphics(); + g.setColor(Color.red); + //if (xor) { + // g.setXORMode(Color.blue); + //} + printAll(g); + g.dispose(); + //xor = (xor) ? false : true; + } + + // For xor mode set, LWC components don't get printed. + // So, for now the code is commented out and separate bug + // (JDK-8340495) is filed to handle it. + + // one more page so that we can test printing a lightweight + // at the top of the hierarchy (BugId 4212564) + //Graphics g = pj.getGraphics(); + //g.setColor(Color.red); + //lwc.printAll(g); + //g.dispose(); + // end 4212564 + + pj.end(); + } + } + + class ActionPrintToScreen implements ActionListener { + public void actionPerformed(ActionEvent ev) { + PrintFrame printFrame = new PrintFrame(MainFrame.this); + printFrame.show(); + Graphics g = printFrame.getGraphics(); + g.setColor(Color.red); + printAll(g); + g.dispose(); + } + } + + // Frame window that displays results of printing + // main window to a screen Graphics-- useful for + // quick testing of printing + class PrintFrame extends Frame + { + private Component printComponent; + public PrintFrame( Component c ) + { + super("Print to Screen"); + printComponent = c ; + addWindowListener( new WindowAdapter() { + public void windowClosing(WindowEvent ev) { + setVisible(false); + dispose(); + } + } + ); + setSize(printComponent.getSize()); + setResizable(false); + } + + public void paint( Graphics g ) { + printComponent.printAll(g); + } + } + + class LWButton extends Component { + String label; + int width = 100; + int height = 30; + + public LWButton(String label) { + super(); + this.label = label; + } + + public void paint(Graphics g) { + Dimension d = getSize(); + g.setColor(Color.orange); + g.setFont(getFont()); + g.fillRect(0, 0, d.width, d.height); + g.setColor(Color.black); + int x = 5; + int y = (d.height - 5); + g.drawString(label, x, y); + } + + public Dimension getPreferredSize() + { + return new Dimension(width, height); + } + } + + class LWContainer extends Container { + String label; + int width = 300; + int height = 100; + + public LWContainer(String label) { + super(); + this.label = label; + setLayout(new FlowLayout()); + } + + public void paint(Graphics g) { + super.paint(g); + Dimension d = getSize(); + g.setColor(Color.green); + g.setFont(getFont()); + g.drawLine(0, 0, d.width - 1, 0); + g.drawLine(d.width - 1, 0, d.width - 1, d.height - 1); + g.drawLine(d.width - 1, d.height - 1, 0, d.height - 1); + g.drawLine(0, d.height - 1, 0, 0); + g.setColor(Color.black); + int x = 5; + int y = (d.height - 5); + g.drawString(label, x, y); + } + + public Dimension getPreferredSize() + { + return new Dimension(width, height); + } + } + + class TestCanvas extends Canvas { + int width = 100; + int height = 100; + + public void paint(Graphics g) { + g.setColor(Color.blue); + g.fillRoundRect(10, 10, 50, 50, 15, 30); + g.setColor(Color.red); + g.fillOval(70, 70, 25, 25); + } + public Dimension getPreferredSize() { + return new Dimension(width, height); + } + } + + class ZOrderPanel extends Panel + { + ZOrderPanel() + { + setLayout(null); + + Component first, second, third, fourth; + + setVisible(true); + // add first component + first = makeBox("Second", Color.blue, + new Font("Serif", Font.BOLD, 14), + -1); + // insert on top + second = makeBox("First", Color.yellow, + new Font("SansSerif", Font.BOLD, 14), + 0); + // put at the back + fourth = makeBox("Fourth", Color.red, + new Font("Monospaced", Font.BOLD, 14), + 2); + // insert in last position + third = makeBox("Third", Color.green, + new Font("Dialog", Font.PLAIN, 12), + 3); + // swap third and fourth to correct positions + remove(third); + add(third, 2); + // re-validate so third and fourth peers change position + validate(); + // now make things really interesting with a lightweight + // component at the top of the z-order, that should print + // _below_ the native guys to match the screen... + add(new LWButton("LWButton"), 0); + } + + public Dimension preferredSize() + { + return new Dimension(260, 80); + } + + public void layout() + { + int i, n; + Insets ins = getInsets(); + n = getComponentCount(); + for (i = n-1; i >= 0; i--) { + Component p = getComponent(i); + p.setBounds(ins.left + 40 * i, ins.top + 5 * i, 60, 60); + } + } + + public Component makeBox(String s, Color c, Font f, int index) + { + Label l = new Label(s); + l.setBackground(c); + l.setAlignment(Label.RIGHT); + l.setFont(f); + add(l, index); + validate(); + return l; + } + } +} diff --git a/test/jdk/java/awt/PrintJob/ScaledImagePrintingTest.java b/test/jdk/java/awt/PrintJob/ScaledImagePrintingTest.java new file mode 100644 index 00000000000..838c9210e30 --- /dev/null +++ b/test/jdk/java/awt/PrintJob/ScaledImagePrintingTest.java @@ -0,0 +1,102 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Button; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Image; +import java.awt.PrintJob; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +/* + * @test + * @bug 4257962 + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @summary tests that scaled images are printed at resolution greater than 72dpi + * @run main/manual ScaledImagePrintingTest + */ + +public class ScaledImagePrintingTest { + + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + Press 'Print' button from the test UI. + + The test will bring up a print dialog. Select a printer and proceed. + Verify that the output is a series of a horizontal lines in a + rectangular box in the center of the page. + + If output is as mentioned above, press Pass else Fail."""; + + PassFailJFrame.builder() + .title("ScaledImagePrintingTest Test Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(40) + .testTimeOut(5) + .testUI(ScaledImagePrintingTest::createUI) + .logArea(8) + .build() + .awaitAndCheck(); + } + + private static Frame createUI() { + Frame frame = new Frame("ResolutionTest"); + Button b = new Button("Print"); + b.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + PrintJob pj = frame.getToolkit().getPrintJob(frame, "ResolutionTest", null); + PassFailJFrame.log("Printing code started."); + if (pj != null) { + Graphics g = pj.getGraphics(); + g.setColor(Color.black); + int w = 200; + int h = 200; + Image image = frame.createImage(w, h); + Graphics imageGraphics = image.getGraphics(); + Dimension d = pj.getPageDimension(); + imageGraphics.setColor(Color.black); + for (int i = 0; i < h; i += 20) { + imageGraphics.drawLine(0, i, w, i); + } + g.translate(d.width / 2, d.height / 2); + g.drawImage(image, -w / 8, -h / 8, w / 4, h / 4, frame); + g.setColor(Color.black); + g.drawRect(-w / 4, -h / 4, w / 2, h / 2); + imageGraphics.dispose(); + g.dispose(); + pj.end(); + } + PassFailJFrame.log("Printing code finished."); + } + }); + frame.add(b); + frame.setSize(50, 50); + return frame; + } +} diff --git a/test/jdk/java/awt/Robot/CreateScreenCapture.java b/test/jdk/java/awt/Robot/CreateScreenCapture.java new file mode 100644 index 00000000000..8060240ba8f --- /dev/null +++ b/test/jdk/java/awt/Robot/CreateScreenCapture.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4292503 + * @summary OutOfMemoryError with lots of Robot.createScreenCapture + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @requires (os.family == "linux") + * @run main/manual CreateScreenCapture +*/ + +import java.awt.Dialog; +import java.awt.Frame; +import java.awt.Image; +import java.awt.Rectangle; +import java.awt.Robot; +import java.awt.TextArea; + +public class CreateScreenCapture { + + static TextArea messageText; + + private static final String INSTRUCTIONS = """ + This test is linux only! + Once you see these instructions, run 'top' program. + Watch for java process. + The memory size used by this process should stop growing after several steps. + Numbers of steps test is performing are displayed in output window. + After 5-7 steps the size taken by the process should become stable. + If this happens, then test passed otherwise test failed. + + Small oscillations of the memory size are, however, acceptable."""; + + public static void main(String[] args) throws Exception { + Robot robot = new Robot(); + PassFailJFrame passFail = new PassFailJFrame(INSTRUCTIONS); + Dialog dialog = new Dialog(new Frame(), "Instructions"); + messageText = new TextArea("", 5, 80, TextArea.SCROLLBARS_BOTH); + dialog.add(messageText); + PassFailJFrame.addTestWindow(dialog); + PassFailJFrame.positionTestWindow(dialog, PassFailJFrame.Position.HORIZONTAL); + dialog.setSize(200, 300); + dialog.setVisible(true); + Rectangle rect = new Rectangle(0, 0, 1000, 1000); + for (int i = 0; i < 100; i++) { + Image image = robot.createScreenCapture(rect); + image.flush(); + image = null; + robot.delay(200); + log("step #" + i); + } + passFail.awaitAndCheck(); + } + + private static void log(String messageIn) { + messageText.append(messageIn + "\n"); + } +} + diff --git a/test/jdk/java/awt/Robot/RobotScrollTest.java b/test/jdk/java/awt/Robot/RobotScrollTest.java new file mode 100644 index 00000000000..20dc9f2f4eb --- /dev/null +++ b/test/jdk/java/awt/Robot/RobotScrollTest.java @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 4374578 + * @summary Test robot wheel scrolling of Text + * @requires (os.family == "Windows") | (os.family == "linux") + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual RobotScrollTest +*/ + +import java.awt.Frame; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.Robot; +import java.awt.TextArea; + +public class RobotScrollTest { + + static TextArea ta; + static Robot robot; + + private static final String INSTRUCTIONS = """ + 0. DON'T TOUCH ANYTHING! + 1. This test is for Windows and Linux only. + 2. Just sit back, and watch the Robot move the mouse to the TextArea. + 3. Once the pointer is on the text area, the Robot will use the mouse wheel + to scroll the text. + If the text scrolled, press PASS, else, press FAIL."""; + + public static void main(String[] args) throws Exception { + robot = new Robot(); + robot.setAutoDelay(100); + PassFailJFrame passFail = new PassFailJFrame(INSTRUCTIONS); + createTestUI(); + passFail.awaitAndCheck(); + } + + private static void createTestUI() { + Frame f = new Frame("RobotScrollTest"); + ta = new TextArea(); + for (int i = 0; i < 100; i++) { + ta.append(i + "\n"); + } + f.add(ta); + f.setLocation(0, 400); + f.pack(); + PassFailJFrame.addTestWindow(f); + PassFailJFrame.positionTestWindow(f, PassFailJFrame.Position.HORIZONTAL); + f.setVisible(true); + doTest(); + } + + private static void doTest() { + robot.waitForIdle(); + robot.delay(1000); + // get loc of TextArea + Point taAt = ta.getLocationOnScreen(); + // get bounds of button + Rectangle bounds = ta.getBounds(); + + // move mouse to middle of button + robot.mouseMove(taAt.x + bounds.width / 2, + taAt.y + bounds.height / 2); + + // rotate wheel a few times + for (int j = 1; j < 8; j++) { + for (int k = 0; k < 5; k++) { + robot.mouseWheel(j); + } + + for (int k = 0; k < 5; k++) { + robot.mouseWheel(-1 * j); + } + } + } + +} + diff --git a/test/jdk/java/awt/TextField/CaretPositionTest/CaretPositionTest.java b/test/jdk/java/awt/TextField/CaretPositionTest/CaretPositionTest.java new file mode 100644 index 00000000000..56a39758874 --- /dev/null +++ b/test/jdk/java/awt/TextField/CaretPositionTest/CaretPositionTest.java @@ -0,0 +1,104 @@ +/* + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.AWTException; +import java.awt.Button; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.Point; +import java.awt.Robot; +import java.awt.TextField; +import java.awt.event.InputEvent; +import java.lang.reflect.InvocationTargetException; + +/* + * @test + * @bug 4038580 + * @key headful + * @requires os.family != "windows" + * @summary Caret position not accurate in presence of selected areas + * @run main CaretPositionTest + */ + +public class CaretPositionTest extends Frame { + private TextField text_field; + private Button caretpos_button; + private Point onScreen; + private Dimension size; + String text = "12 45 789"; + private static volatile int position = -1; + + public static void main(String[] args) throws InterruptedException, + InvocationTargetException, AWTException { + CaretPositionTest test = new CaretPositionTest(); + EventQueue.invokeAndWait(test::setupGUI); + try { + test.test(); + if (position != 9) { + throw new RuntimeException("Caret position should be at the end of the string"); + } + } finally { + EventQueue.invokeAndWait(test::dispose); + } + } + + public void setupGUI() { + setLocationRelativeTo(null); + setTitle("CaretPositionTest"); + setLayout(new FlowLayout()); + text_field = new TextField(text, 9); + caretpos_button=new Button("CaretPosition"); + add(text_field); + add(caretpos_button); + pack(); + setVisible(true); + toFront(); + } + + public void test() throws AWTException, InterruptedException, + InvocationTargetException { + EventQueue.invokeAndWait(() -> { + onScreen = text_field.getLocationOnScreen(); + size = text_field.getSize(); + }); + Robot robot = new Robot(); + robot.setAutoDelay(50); + robot.delay(1000); + int y = onScreen.y + (size.height / 2); + robot.mouseMove(onScreen.x + (size.width / 2), y); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseMove(onScreen.x + 3, y); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + for (int x = onScreen.x + 5; x < onScreen.x + size.width; x += 2) { + robot.mouseMove(x, y); + } + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.waitForIdle(); + EventQueue.invokeAndWait(() -> { + position = text_field.getCaretPosition(); + }); + } +} diff --git a/test/jdk/java/awt/TextField/GetTextTest/GetTextTest.java b/test/jdk/java/awt/TextField/GetTextTest/GetTextTest.java new file mode 100644 index 00000000000..ab5aebc11d4 --- /dev/null +++ b/test/jdk/java/awt/TextField/GetTextTest/GetTextTest.java @@ -0,0 +1,104 @@ +/* + * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4100188 + * @key headful + * @summary Make sure that TextFields contain all of, + * and exactly, the text that was entered into them. + * @run main GetTextTest + */ + +import java.awt.AWTException; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.Label; +import java.awt.Point; +import java.awt.Robot; +import java.awt.TextField; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.InputEvent; +import java.awt.event.KeyEvent; +import java.lang.reflect.InvocationTargetException; + +public class GetTextTest extends Frame implements ActionListener { + private final String s = "test string"; + private volatile String ac; + private TextField t; + private Point location; + private Dimension size; + + public void setupGUI() { + setLayout(new FlowLayout(FlowLayout.LEFT)); + + t = new TextField(s, 32); + add(new Label("Hit after text")); + add(t); + t.addActionListener(this); + setLocationRelativeTo(null); + pack(); + setVisible(true); + } + + public void actionPerformed(ActionEvent evt) { + ac = evt.getActionCommand(); + } + + public void performTest() throws AWTException, InterruptedException, + InvocationTargetException { + EventQueue.invokeAndWait(() -> { + location = t.getLocationOnScreen(); + size = t.getSize(); + }); + Robot robot = new Robot(); + robot.setAutoDelay(50); + robot.delay(1000); + robot.waitForIdle(); + robot.mouseMove(location.x + size.width - 3, location.y + (size.height / 2)); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.delay(1000); + robot.waitForIdle(); + robot.keyPress(KeyEvent.VK_ENTER); + robot.keyRelease(KeyEvent.VK_ENTER); + robot.delay(1000); + if (!s.equals(ac)) { + throw new RuntimeException("Action command should be the same as text field content"); + } + } + + public static void main(String[] args) throws InterruptedException, + InvocationTargetException, AWTException { + GetTextTest test = new GetTextTest(); + EventQueue.invokeAndWait(test::setupGUI); + try { + test.performTest(); + } finally { + EventQueue.invokeAndWait(test::dispose); + } + } +} diff --git a/test/jdk/java/awt/TextField/SetBoundsTest/SetBoundsTest.java b/test/jdk/java/awt/TextField/SetBoundsTest/SetBoundsTest.java new file mode 100644 index 00000000000..e37f69232eb --- /dev/null +++ b/test/jdk/java/awt/TextField/SetBoundsTest/SetBoundsTest.java @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Button; +import java.awt.Color; +import java.awt.Container; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.GridLayout; +import java.awt.Panel; +import java.awt.ScrollPane; +import java.awt.TextArea; +import java.awt.TextField; +import java.lang.reflect.InvocationTargetException; + +/* + * @test + * @bug 6198290 6277332 + * @summary TextField painting is broken when placed on a Scrollpane, XToolkit + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual SetBoundsTest + */ + +public class SetBoundsTest extends Frame { + + private static final String INSTRUCTIONS = """ + 1) Make active a frame with a scrollpane and a few components. + 2) Please, focus attention on the text components + placed on the upper half of the frame + 3) Make sure, that the scrollbar of the frame + have the same position during the test. + 4) Bring focus to TextField, try deleting the text. + If the text never gets erased, the test failed + 5) Bring focus to TextArea, try deleting the text. + If the text never gets erased, the test failed + 6) Please, focus attention on the text components + placed on the lower half of the frame + 7) Try input something into TextField. + If you can not input anything into TextField, the test failed + 8) Try input something into TextArea. + If you can not input anything into TextArea, the test failed + 9) The test passed + """; + + public SetBoundsTest() { + setTitle("SetBoundsTest Test Frame"); + setLayout(new GridLayout(2, 1)); + Panel hw = new Panel(); + ScrollPane sp = new ScrollPane(ScrollPane.SCROLLBARS_AS_NEEDED); + Container lw = new Container(); + fill(hw); + fill(lw); + + sp.add(hw); + add(sp); + add(lw); + + setSize(600, 600); + sp.setScrollPosition(20, 0); + + } + + private void fill(Container c) { + Button button = new Button("button"); + c.add(button); + button.setBackground(new Color(0xd3ceac)); + button.setForeground(new Color(0x000000)); + button.move(60, 80); + button.resize(400, 60); + button.show(true); + + TextField textfield = new TextField("textfield"); + c.add(textfield); + textfield.setBackground(new Color(0xd3ceac)); + textfield.setForeground(new Color(0x000000)); + textfield.move(60, 20); + textfield.resize(400, 40); + textfield.show(true); + + TextArea textarea = new TextArea("textarea"); + c.add(textarea); + textarea.setBackground(new Color(0xd3ceac)); + textarea.setForeground(new Color(0x000000)); + textarea.move(60, 80); + textarea.resize(400, 60); + textarea.show(true); + + c.setLayout (new FlowLayout()); + } + + public static void main(String[] args) throws InterruptedException, + InvocationTargetException { + PassFailJFrame.builder() + .title("Set Bounds Test Instructions") + .instructions(INSTRUCTIONS) + .testUI(SetBoundsTest::new) + .rows((int) INSTRUCTIONS.lines().count() + 1) + .columns(40) + .build() + .awaitAndCheck(); + } +} diff --git a/test/jdk/java/awt/TextField/SetEchoCharTest.java b/test/jdk/java/awt/TextField/SetEchoCharTest.java new file mode 100644 index 00000000000..d5cb71975e6 --- /dev/null +++ b/test/jdk/java/awt/TextField/SetEchoCharTest.java @@ -0,0 +1,178 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Button; +import java.awt.EventQueue; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.Label; +import java.awt.Point; +import java.awt.Robot; +import java.awt.TextField; +import java.awt.Toolkit; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.StringSelection; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.InputEvent; +import java.awt.event.KeyEvent; + +import jdk.test.lib.Platform; + +/* + * @test + * @bug 4124697 + * @key headful + * @summary Make sure that after setting and then changing the echo + * character again, the TextField continues to function as expected. + * @library /test/lib + * @build jdk.test.lib.Platform + * @run main SetEchoCharTest + */ + +public class SetEchoCharTest { + private static Frame frame; + private static Robot robot; + private static TextField tfPassword; + private static Button btn1; + private static Button btn2; + private static volatile Point btn1Loc; + private static volatile Point btn2Loc; + + private static final String CHANGE = "Change echo char"; + private static final String PRINT = "Print text"; + private static final String INITIAL_TEXT = "DefaultPwd"; + private static final String CHANGED_TEXT = "NewPwd"; + private static final char NEW_ECHO_CHAR = '*'; + + public static void main(String[] args) throws Exception { + try { + robot = new Robot(); + robot.setAutoWaitForIdle(true); + robot.setAutoDelay(50); + + EventQueue.invokeAndWait(() -> createAndShowUI()); + robot.waitForIdle(); + robot.delay(1000); + + testEchoChar(); + robot.waitForIdle(); + robot.delay(200); + + testNewEchoChar(); + robot.waitForIdle(); + robot.delay(200); + } finally { + EventQueue.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } + + private static void createAndShowUI() { + frame = new Frame("SetEchoCharTest"); + frame.setLayout(new FlowLayout()); + + Label label = new Label("Pwd:"); + tfPassword = new TextField(INITIAL_TEXT, 10); + tfPassword.setEchoChar('X'); + tfPassword.addActionListener((ActionListener) e -> { + if (e.getActionCommand().equals(CHANGED_TEXT)) { + //check the 2nd condition only if ActionEvent + //is triggered by changed text + if (!(tfPassword.getText().equals(CHANGED_TEXT) + && tfPassword.getEchoChar() == NEW_ECHO_CHAR)) { + throw new RuntimeException("Test Failed!!! TextField not working" + + " as expected after echo char change"); + } + } + }); + frame.add(label); + frame.add(tfPassword); + + btn1 = new Button(PRINT); + btn1.addActionListener(new BtnActionListener()); + frame.add(btn1); + + btn2 = new Button(CHANGE); + btn2.addActionListener(new BtnActionListener()); + frame.add(btn2); + frame.setSize(200,200); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } + + private static void testEchoChar() throws Exception { + EventQueue.invokeAndWait(() -> { + btn1Loc = btn1.getLocationOnScreen(); + btn2Loc = btn2.getLocationOnScreen(); + }); + + robot.mouseMove(btn1Loc.x + btn1.getWidth() / 2, + btn1Loc.y + btn1.getHeight() / 2); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.delay(1000); + + robot.mouseMove(btn2Loc.x + btn2.getWidth() / 2, + btn2Loc.y + btn2.getHeight() / 2); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.delay(1000); + } + + private static void testNewEchoChar() { + StringSelection stringSelection = new StringSelection(CHANGED_TEXT); + Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); + clipboard.setContents(stringSelection, stringSelection); + + int ctrlKey = Platform.isOSX() ? KeyEvent.VK_META : KeyEvent.VK_CONTROL; + robot.keyPress(ctrlKey); + robot.keyPress(KeyEvent.VK_V); + robot.keyRelease(KeyEvent.VK_V); + robot.keyRelease(ctrlKey); + + robot.keyPress(KeyEvent.VK_ENTER); + robot.keyRelease(KeyEvent.VK_ENTER); + } + + private static class BtnActionListener implements ActionListener { + public void actionPerformed(ActionEvent evt) { + String ac = evt.getActionCommand(); + if (CHANGE.equals(ac)) { + tfPassword.setText(""); + tfPassword.setEchoChar(NEW_ECHO_CHAR); + tfPassword.requestFocus(); + } + if (PRINT.equals(ac)) { + if (!tfPassword.getText().equals(INITIAL_TEXT)) { + throw new RuntimeException("Test Failed!!!" + + " Initial text not as expected"); + } + } + } + } +} + diff --git a/test/jdk/java/awt/TextField/SetEchoCharTest3/SetEchoCharTest3.java b/test/jdk/java/awt/TextField/SetEchoCharTest3/SetEchoCharTest3.java new file mode 100644 index 00000000000..10779365def --- /dev/null +++ b/test/jdk/java/awt/TextField/SetEchoCharTest3/SetEchoCharTest3.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4222122 + * @summary TextField.setEchoCharacter() seems to be broken + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual SetEchoCharTest3 + */ + +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.Label; +import java.awt.TextField; +import java.lang.reflect.InvocationTargetException; + +public class SetEchoCharTest3 extends Frame { + static String INSTRUCTIONS = """ + Type in the text field and "*" characters should echo. + If only one "*" echoes and then the system beeps after + the second character is typed, then press Fail, otherwise press Pass. + """; + public SetEchoCharTest3() { + setLayout(new FlowLayout()); + add(new Label("Enter text:")); + TextField tf = new TextField(15); + tf.setEchoChar('*'); + add(tf); + pack(); + } + + public static void main(String[] args) throws InterruptedException, + InvocationTargetException { + PassFailJFrame.builder() + .title("Set Echo Char Test 3") + .testUI(SetEchoCharTest3::new) + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 1) + .columns(40) + .build() + .awaitAndCheck(); + } +} diff --git a/test/jdk/java/awt/TextField/SetEchoCharTest4/SetEchoCharTest4.java b/test/jdk/java/awt/TextField/SetEchoCharTest4/SetEchoCharTest4.java new file mode 100644 index 00000000000..c1cc07afac0 --- /dev/null +++ b/test/jdk/java/awt/TextField/SetEchoCharTest4/SetEchoCharTest4.java @@ -0,0 +1,101 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Button; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.TextField; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.lang.reflect.InvocationTargetException; + +/* + * @test + * @bug 4226580 + * @summary TextField with echoChar add+remove+add seems to be broken + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual SetEchoCharTest4 + */ + +public class SetEchoCharTest4 extends Frame implements ActionListener { + TextField tf1 = new TextField(8); + TextField tf2 = new TextField(8); + TextField tf3 = new TextField(8); + Button b = new Button("Click Several Times"); + + static final String INSTRUCTIONS = """ + Type in the first text field and * characters will echo. + Type in the second text field and $ characters will echo. + Type in the third text field and # characters will echo. + + Hit the button several times. All characters should remain + the same and the test should not crash. + + Make sure the actual text matches what you typed in for each field. + Press Pass if everything's ok, otherwise Fail + """; + + public SetEchoCharTest4() { + setLayout(new FlowLayout()); + tf1.setEchoChar('*'); + tf2.setEchoChar('$'); + tf3.setEchoChar('#'); + addStuff(); + b.addActionListener(this); + setSize (200,200); + } + + private void addStuff() { + add(tf1); + add(tf2); + add(tf3); + add(b); + } + + public void actionPerformed(ActionEvent ae) { + PassFailJFrame.log("TextField1 = " + tf1.getText()); + PassFailJFrame.log("TextField2 = " + tf2.getText()); + PassFailJFrame.log("TextField3 = " + tf3.getText()); + PassFailJFrame.log("--------------"); + setVisible(false); + remove(tf1); + remove(tf2); + remove(tf3); + remove(b); + addStuff(); + } + + public static void main(String[] args) throws InterruptedException, + InvocationTargetException { + PassFailJFrame.builder() + .title("Set Echo Character Test") + .testUI(SetEchoCharTest4::new) + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 1) + .columns(40) + .logArea() + .build() + .awaitAndCheck(); + } +} diff --git a/test/jdk/java/awt/TextField/SetEchoCharWordOpsTest.java b/test/jdk/java/awt/TextField/SetEchoCharWordOpsTest.java new file mode 100644 index 00000000000..825c21fdc96 --- /dev/null +++ b/test/jdk/java/awt/TextField/SetEchoCharWordOpsTest.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.FlowLayout; +import java.awt.Label; +import java.awt.TextField; +import javax.swing.JPanel; + +import jdk.test.lib.Platform; + +/* + * @test + * @bug 6191897 + * @summary Verifies that ctrl+left/right does not move word-by-word in a TextField + * with echo character set + * @library /java/awt/regtesthelpers /test/lib + * @build PassFailJFrame jdk.test.lib.Platform + * @run main/manual SetEchoCharWordOpsTest + */ + +public class SetEchoCharWordOpsTest { + + public static void main(String[] args) throws Exception { + String selectAllKey; + String moveKeys; + String selectKeys; + + if (Platform.isOSX()) { + selectAllKey = "Cmd + A"; + moveKeys = "Alt + Right/Left"; + selectKeys = "Shift + Alt + Right/Left"; + } else { + selectAllKey = "Ctrl + A"; + moveKeys = "Ctrl + Right/Left"; + selectKeys = "Shift + Ctrl + Right/Left"; + } + + String instructions = + "The password field (in the bottom panel) in this test contains" + + " a few words (3 words).\n" + + "Move the focus to the text field and press " + selectAllKey + ".\n" + + "Try moving the caret word-by-word with " + moveKeys + " or" + + " extending selection with " + selectKeys + "." + + " You should NOT be able to do that.\n\n" + + "If you are able to move the caret word-by-word press FAIL," + + " else press PASS."; + + PassFailJFrame.builder() + .title("SetEchoCharClipboard Instructions") + .instructions(instructions) + .rows((int) instructions.lines().count() + 3) + .columns(45) + .splitUIBottom(SetEchoCharWordOpsTest::createAndShowUI) + .build() + .awaitAndCheck(); + } + + + private static JPanel createAndShowUI() { + JPanel jPanel = new JPanel(); + TextField tf = new TextField("one two three", 15); + Label tfLabel = new Label("Password Field:"); + + jPanel.setLayout(new FlowLayout()); + tf.setEchoChar('*'); + jPanel.add(tfLabel); + jPanel.add(tf); + return jPanel; + } +} diff --git a/test/jdk/java/awt/TextField/SetPasswordTest/SetPasswordTest.java b/test/jdk/java/awt/TextField/SetPasswordTest/SetPasswordTest.java new file mode 100644 index 00000000000..cff5e375017 --- /dev/null +++ b/test/jdk/java/awt/TextField/SetPasswordTest/SetPasswordTest.java @@ -0,0 +1,105 @@ +/* + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Button; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.TextField; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.lang.reflect.InvocationTargetException; + +/* + * @test + * @bug 4084454 + * @summary Make sure that you can set the text in a "password mode" + * text field and that it echoes as the current echo char. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual SetPasswordTest + */ + +public class SetPasswordTest extends Frame implements ActionListener { + private String setText = "Set text"; + private String getText = "Get text"; + private TextField tfPassword; + + static final String INSTRUCTIONS = """ + The purpose of this test is to ensure that when using a textField for + password entry that text set programmatically is not shown in the clear. + + We also test "pasting" text into the text field. + + 1. Press the "Set Text" button + Text should appear as '*' chars + - if the string "secret" appears then the test is failed. + 2. Use the mouse to select (highlight) all the text and press the DELETE key + 3. Use the system's copy/paste functionality to copy a text string from the + desktop or this window, and paste it into the text field. + 4. Text should appear in the text field as '*' chars + - if the string you pasted appears then the test is failed. + 5. press the "Get Text" button and the string you pasted + should be printed in the log area + - if it prints echo symbols instead the test is failed. + """; + + public SetPasswordTest() { + setLayout(new FlowLayout()); + tfPassword = new TextField("Initial text", 30); + tfPassword.setEchoChar('*'); + add(tfPassword); + + Button b1 = new Button(setText); + b1.addActionListener(this); + add(b1); + + Button b2 = new Button(getText); + b2.addActionListener(this); + add(b2); + pack(); + } + + public void actionPerformed(ActionEvent evt) { + String ac = evt.getActionCommand(); + if (setText.equals(ac)) { + tfPassword.setText("secret"); + } + + if (getText.equals(ac)) { + PassFailJFrame.log("Text: \"" + tfPassword.getText() + "\""); + } + } + + public static void main(String[] args) throws InterruptedException, + InvocationTargetException { + PassFailJFrame.builder() + .title("Set Password Test") + .testUI(SetPasswordTest::new) + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 1) + .columns(40) + .logArea() + .build() + .awaitAndCheck(); + } +} diff --git a/test/jdk/java/awt/TextField/ZeroEchoCharTest/ZeroEchoCharTest.java b/test/jdk/java/awt/TextField/ZeroEchoCharTest/ZeroEchoCharTest.java new file mode 100644 index 00000000000..274cec22572 --- /dev/null +++ b/test/jdk/java/awt/TextField/ZeroEchoCharTest/ZeroEchoCharTest.java @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Button; +import java.awt.Frame; +import java.awt.GridLayout; +import java.awt.TextField; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.lang.reflect.InvocationTargetException; + +/* + * @test + * @bug 4307281 + * @summary verify that after setting the echo char to 0 disguises are + * removed and user input is echoed to the screen unchanged. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual ZeroEchoCharTest + */ + +public class ZeroEchoCharTest extends Frame implements ActionListener { + private final TextField textfield = new TextField(); + private final Button button1 = new Button("Set echo char to *"); + private final Button button2 = new Button("Set echo char to 0"); + static final String INSTRUCTIONS = """ + 1.Type in the text field. The user input must be echoed unchanged. + 2.Set echo char to '*' by pressing the corresponding button. + If all characters in the text field aren't immediately replaced + with '*', the test fails. + 3.Set echo char to 0 by pressing the corresponding button. + If disguises in the text field don't immediately revert to + the original characters, the test fails. + 4.Type in the text field. If the input is echoed unchanged, + the test passes. Otherwise, the test fails. + """; + + public ZeroEchoCharTest() { + button1.addActionListener(this); + button2.addActionListener(this); + + setLayout(new GridLayout(3, 1)); + + add(textfield); + add(button1); + add(button2); + pack(); + } + + public void actionPerformed(ActionEvent event) { + if (event.getSource() == button1) { + textfield.setEchoChar('*'); + } else if (event.getSource() == button2) { + textfield.setEchoChar((char)0); + } + } + + public static void main(String[] args) throws InterruptedException, + InvocationTargetException { + PassFailJFrame.builder() + .title("Zero Echo Char Test") + .testUI(ZeroEchoCharTest::new) + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 1) + .columns(40) + .build() + .awaitAndCheck(); + } +} diff --git a/test/jdk/java/awt/TrayIcon/ClearPrevImageTest.java b/test/jdk/java/awt/TrayIcon/ClearPrevImageTest.java new file mode 100644 index 00000000000..e97f645bec5 --- /dev/null +++ b/test/jdk/java/awt/TrayIcon/ClearPrevImageTest.java @@ -0,0 +1,126 @@ +/* + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.AWTException; +import java.awt.Color; +import java.awt.EventQueue; +import java.awt.Graphics2D; +import java.awt.Image; +import java.awt.RenderingHints; +import java.awt.SystemTray; +import java.awt.TrayIcon; +import java.awt.image.BufferedImage; + +import jtreg.SkippedException; + +/* + * @test + * @bug 6267936 + * @library /java/awt/regtesthelpers /test/lib + * @build PassFailJFrame jtreg.SkippedException + * @summary Tests that the previous image in TrayIcon is cleared + * when a new image is set + * @run main/manual ClearPrevImageTest + */ + +public class ClearPrevImageTest { + private static SystemTray tray; + private static TrayIcon icon; + private static final String INSTRUCTIONS = """ + This test checks that the previous image in TrayIcon is cleared + when a new image is set. + + When the test starts, a RED square TrayIcon is added + to the SystemTray (also, called Taskbar Status Area in MS Windows, + Notification Area in, GNOME and System Tray in KDE). + + You should see it change into YELLOW after 5 seconds. + If you still see RED TrayIcon after 5 seconds, + press FAIL, otherwise press PASS + """; + + + public static void main(String[] args) throws Exception { + if (!SystemTray.isSupported()) { + throw new SkippedException("Test not applicable as" + + " System Tray not supported"); + } + + PassFailJFrame passFailJFrame + = PassFailJFrame.builder() + .title("TrayIcon Change Test Instructions") + .instructions(INSTRUCTIONS) + .columns(40) + .build(); + + EventQueue.invokeAndWait(ClearPrevImageTest::createAndShowTrayIcon); + try { + changeTrayIcon(); + passFailJFrame.awaitAndCheck(); + } catch (Exception e) { + throw new RuntimeException("Test failed: ", e); + } finally { + EventQueue.invokeAndWait(() -> { + if (tray != null) { + tray.remove(icon); + } + }); + } + } + + private static void createAndShowTrayIcon() { + Image img1 = createIcon(Color.RED); + tray = SystemTray.getSystemTray(); + icon = new TrayIcon(img1); + icon.setImageAutoSize(true); + + try { + tray.add(icon); + } catch (AWTException e) { + throw new RuntimeException("Error while adding" + + " icon to system tray", e); + } + } + + private static void changeTrayIcon() { + try { + Thread.sleep(5000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + Image img2 = createIcon(Color.YELLOW); + icon.setImage(img2); + } + + private static Image createIcon(Color color) { + BufferedImage image = new BufferedImage(16, 16, + BufferedImage.TYPE_INT_ARGB); + Graphics2D g = image.createGraphics(); + g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, + RenderingHints.VALUE_TEXT_ANTIALIAS_ON); + g.setColor(color); + g.fillRect(0, 0, 16, 16); + g.dispose(); + return image; + } +} diff --git a/test/jdk/java/awt/TrayIcon/FocusLostAfterTrayTest.java b/test/jdk/java/awt/TrayIcon/FocusLostAfterTrayTest.java new file mode 100644 index 00000000000..bd831ce94e4 --- /dev/null +++ b/test/jdk/java/awt/TrayIcon/FocusLostAfterTrayTest.java @@ -0,0 +1,136 @@ +/* + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.AWTException; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.Graphics2D; +import java.awt.RenderingHints; +import java.awt.SystemTray; +import java.awt.TextArea; +import java.awt.TrayIcon; +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; +import java.awt.image.BufferedImage; + +import jtreg.SkippedException; + +/* + * @test + * @bug 6269309 + * @library /java/awt/regtesthelpers /test/lib + * @build PassFailJFrame jtreg.SkippedException + * @summary Tests that focus is transferred properly back + * to toplevel after clicking on a tray icon. + * @run main/manual FocusLostAfterTrayTest + */ + +public class FocusLostAfterTrayTest { + private static SystemTray tray; + private static TrayIcon icon; + + private static final String INSTRUCTIONS = """ + This test checks that focus is transferred properly back + to top-level after clicking on a tray icon. + + When the test starts, a Frame with a text area & a RED tray icon + are shown. If you don't see a tray icon please make sure that + the tray area (also called Taskbar Status Area on MS Windows + Notification Area on Gnome or System Tray on KDE) is visible. + + Click with a mouse inside a text area and make sure that it has + received input focus. Then click on the tray icon and then back + on the text area and verify that it has input focus again. Repeat + the last step several times. Ensure that the text area always + has the input focus and there are no "FOCUS LOST" event + for text area in the log section. + + If above is true, Press PASS, else FAIL. + """; + + public static void main(String[] args) throws Exception { + if (!SystemTray.isSupported()) { + throw new SkippedException("Test not applicable as" + + " System Tray not supported"); + } + + try { + PassFailJFrame.builder() + .title("FocusLostAfterTrayTest Instructions") + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(FocusLostAfterTrayTest::createAndShowTrayIcon) + .logArea() + .build() + .awaitAndCheck(); + } finally { + EventQueue.invokeAndWait(() -> { + if (tray != null) { + tray.remove(icon); + } + }); + } + } + + private static Frame createAndShowTrayIcon() { + Frame frame = new Frame("FocusLostAfterTrayTest"); + frame.setBounds(100, 300, 200, 200); + frame.setLayout(new BorderLayout()); + TextArea ta = new TextArea(); + ta.addFocusListener(new FocusAdapter() { + @Override + public void focusGained(FocusEvent e) { + PassFailJFrame.log("FOCUS GAINED: " + + e.getComponent().getClass().toString()); + } + @Override + public void focusLost(FocusEvent e) { + PassFailJFrame.log("FOCUS LOST !! " + + e.getComponent().getClass().toString()); + } + }); + frame.add(ta); + + BufferedImage image = new BufferedImage(16, 16, + BufferedImage.TYPE_INT_ARGB); + Graphics2D g = image.createGraphics(); + g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, + RenderingHints.VALUE_TEXT_ANTIALIAS_ON); + g.setColor(Color.RED); + g.fillRect(0, 0, 16, 16); + g.dispose(); + tray = SystemTray.getSystemTray(); + icon = new TrayIcon(image); + icon.setImageAutoSize(true); + + try { + tray.add(icon); + } catch (AWTException e) { + throw new RuntimeException("Error while adding" + + " icon to system tray", e); + } + return frame; + } +} diff --git a/test/jdk/java/awt/TrayIcon/MouseMoveTest.java b/test/jdk/java/awt/TrayIcon/MouseMoveTest.java new file mode 100644 index 00000000000..51d80ff127b --- /dev/null +++ b/test/jdk/java/awt/TrayIcon/MouseMoveTest.java @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.AWTException; +import java.awt.Color; +import java.awt.EventQueue; +import java.awt.Graphics; +import java.awt.SystemTray; +import java.awt.TrayIcon; +import java.awt.event.MouseEvent; +import java.awt.event.MouseMotionAdapter; +import java.awt.image.BufferedImage; + +import jtreg.SkippedException; + +/* + * @test + * @bug 6267980 + * @summary PIT:Spurious MouseMoved events are triggered by Tray Icon + * @library /java/awt/regtesthelpers /test/lib + * @build PassFailJFrame jtreg.SkippedException + * @run main/manual MouseMoveTest + */ + +public class MouseMoveTest { + private static SystemTray tray; + private static TrayIcon icon; + private static final String INSTRUCTIONS = """ + 1) You will see a tray icon (white square) in notification area, + 2) Move mouse pointer to the icon and leave it somewhere inside the icon, + 3) Verify that MOUSE_MOVE events are NOT triggered after you have STOPPED + moving mouse. + 4) If events are still triggered Press FAIL else PASS. + """; + + public static void main(String[] args) throws Exception { + if (!SystemTray.isSupported()) { + throw new SkippedException("Test not applicable as" + + " System Tray not supported"); + } + + PassFailJFrame passFailJFrame + = PassFailJFrame.builder() + .title("TrayIcon Change Test Instructions") + .instructions(INSTRUCTIONS) + .columns(45) + .logArea() + .build(); + + try { + EventQueue.invokeAndWait(MouseMoveTest::createAndShowTrayIcon); + passFailJFrame.awaitAndCheck(); + } finally { + EventQueue.invokeAndWait(() -> { + if (tray != null) { + tray.remove(icon); + } + }); + } + } + + private static void createAndShowTrayIcon() { + BufferedImage img = new BufferedImage(32, 32, + BufferedImage.TYPE_INT_ARGB); + Graphics g = img.createGraphics(); + g.setColor(Color.WHITE); + g.fillRect(0, 0, 32, 32); + g.dispose(); + + tray = SystemTray.getSystemTray(); + icon = new TrayIcon(img); + icon.setImageAutoSize(true); + + icon.addMouseMotionListener(new MouseMotionAdapter() { + public void mouseMoved(MouseEvent me){ + PassFailJFrame.log(me.toString()); + } + }); + + try { + tray.add(icon); + } catch (AWTException e) { + throw new RuntimeException("Error while adding" + + " icon to system tray", e); + } + } +} diff --git a/test/jdk/java/awt/TrayIcon/TrayIconKeySelectTest.java b/test/jdk/java/awt/TrayIcon/TrayIconKeySelectTest.java new file mode 100644 index 00000000000..5e41f546382 --- /dev/null +++ b/test/jdk/java/awt/TrayIcon/TrayIconKeySelectTest.java @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.AWTException; +import java.awt.Color; +import java.awt.EventQueue; +import java.awt.Graphics; +import java.awt.SystemTray; +import java.awt.TrayIcon; +import java.awt.image.BufferedImage; + +import jtreg.SkippedException; + +/* + * @test + * @bug 6267943 + * @requires (os.family == "windows") + * @library /java/awt/regtesthelpers /test/lib + * @build PassFailJFrame jtreg.SkippedException + * @summary Tests the possibility of selecting a tray icon with the keyboard. + * @run main/manual TrayIconKeySelectTest + */ + +public class TrayIconKeySelectTest { + private static SystemTray tray; + private static TrayIcon icon; + private static final String INSTRUCTIONS = """ + Tests that TrayIcon is selectable with the keyboard + When the test is started you will see three-color icon + in the system tray. + + 1. Bring the focus to the icon with TAB. Press ENTER key. + - One or more ActionEvent should be generated + (see the output area of the test) + + 2. Bring the focus again to the icon. Press SPACE key twice. + - One or more ActionEvent should be generated. + + 3. Bring the focus again to the icon. Click on the icon with + the LEFT mouse button twice. + - One or more ActionEvent should be generated. + + 4. Again bring the focus to the icon. Click on the icon with + the LEFT mouse button just once. + - NO ActionEvent should be generated. + + 5. Repeat the 4th step with other mouse buttons. + + If all the above are true press PASS, else FAIL + """; + + public static void main(String[] args) throws Exception { + if (!SystemTray.isSupported()) { + throw new SkippedException("Test not applicable as" + + " System Tray not supported"); + } + PassFailJFrame passFailJFrame; + try { + passFailJFrame + = PassFailJFrame.builder() + .title("TrayIconKeySelectTest Instructions") + .instructions(INSTRUCTIONS) + .columns(40) + .logArea() + .build(); + + EventQueue.invokeAndWait(TrayIconKeySelectTest::createAndShowTrayIcon); + passFailJFrame.awaitAndCheck(); + } finally { + EventQueue.invokeAndWait(() -> { + if (tray != null) { + tray.remove(icon); + } + }); + } + } + + private static void createAndShowTrayIcon() { + BufferedImage im = new BufferedImage(16, 16, + BufferedImage.TYPE_INT_ARGB); + Graphics gr = im.createGraphics(); + gr.setColor(Color.white); + gr.fillRect(0, 0, 16, 5); + gr.setColor(Color.blue); + gr.fillRect(0, 5, 16, 10); + gr.setColor(Color.red); + gr.fillRect(0, 10, 16, 16); + gr.dispose(); + + tray = SystemTray.getSystemTray(); + icon = new TrayIcon(im); + icon.setImageAutoSize(true); + icon.addActionListener(e -> PassFailJFrame.log(e.toString())); + + try { + tray.add(icon); + } catch (AWTException e) { + throw new RuntimeException("Error while adding" + + " icon to system tray", e); + } + } +} diff --git a/test/jdk/java/awt/TrayIcon/TrayIconTest.java b/test/jdk/java/awt/TrayIcon/TrayIconTest.java new file mode 100644 index 00000000000..c78f6c134fe --- /dev/null +++ b/test/jdk/java/awt/TrayIcon/TrayIconTest.java @@ -0,0 +1,613 @@ +/* + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.AWTException; +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.Checkbox; +import java.awt.CheckboxGroup; +import java.awt.Choice; +import java.awt.Color; +import java.awt.Container; +import java.awt.EventQueue; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.Graphics2D; +import java.awt.GridLayout; +import java.awt.Image; +import java.awt.Insets; +import java.awt.Label; +import java.awt.MenuItem; +import java.awt.Panel; +import java.awt.PopupMenu; +import java.awt.RenderingHints; +import java.awt.SystemTray; +import java.awt.TextField; +import java.awt.Toolkit; +import java.awt.TrayIcon; +import java.awt.TrayIcon.MessageType; +import java.awt.event.ActionEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseMotionAdapter; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.awt.image.BufferedImage; +import java.beans.PropertyChangeEvent; +import java.util.HashMap; +import java.util.Map; +import jtreg.SkippedException; + +/* + * @test + * @key headful + * @bug 4310333 + * @library /java/awt/regtesthelpers /test/lib + * @build PassFailJFrame jtreg.SkippedException + * @summary A unit test for TrayIcon RFE + * @run main/manual TrayIconTest + */ + +public class TrayIconTest { + private static SystemTray tray; + static Frame frame = new Frame("TrayIcon Test"); + private static final String INSTRUCTIONS = """ + The test frame contains CheckboxGroup of tray icons. + A selected checkbox represents the TrayIcon (or null + TrayIcon) whose functionality is currently tested. + + If you are under Linux make sure your Application Panel has + System Tray (on Gnome it is called Notification Area). + + Perform all the cases (1-7) documented below. + + CASE 1: Testing ADD/REMOVE/PropertyChange functionality. + -------------------------------------------------------- + 1. Select null TrayIcon and pressAdd button: + - NullPointerException should be thrown. + 2. Select some of the valid TrayIcons and press Add button: + - The selected TrayIcon should appear in the SystemTray. + - PropertyChangeEvent should be fired (the property is + an array of TrayIcons added to the system tray). + 3. Press Add button again: + - IllegalArgumentException should be thrown. + - No PropertyChangeEvent should be fired. + 4. Press Remove button: + - The TrayIcon should disappear from the SystemTray. + - PropertyChangeEvent should be fired. + 5. Press Remove button again: + - It should have no effect. + - No PropertyChangeEvent should be fired. + 6. Add all the valid TrayIcons (by selecting everyone and pressing Add + button): + - All the TrayIcons should appear in the SystemTray. + - PropertyChangeEvent should be fired on each adding. + 7. Remove all the TrayIcons (again by selecting everyone and pressing + Remove): + - All the TrayIcons should disappear from the SystemTray. + - PropertyChangeEvent should be fired on each removing. + 8. Not for Windows! Remove the system tray (Notification Area) from + the desktop. Try to add some valid TrayIcon: + - AWTException should be thrown. + - No PropertyChangeEvent should be fired. + 9. Not for Windows! Add the system tray back to the desktop. Add all the + valid TrayIcons: + - All the TrayIcons should appear in the system tray. + - PropertyChangeEvent should be fired on each adding. + 11. Not for Windows! Remove the system tray from the desktop: + - All the TrayIcons should disappear. + - PropertyChangeEvent should be fired for each TrayIcon + removal. + - PropertyChangeEvent should be fired for SystemTray removal. + 12. Add the system tray and go to the next step. + - All the TrayIcons should appear again. + - PropertyChangeEvent should be fired for SystemTray addition. + - PropertyChangeEvent shouldn't be fired for TrayIcon removal. + + CASE 2: Testing RESIZE functionality. + ------------------------------------- + 1. Select some of the TrayIcons and add it. Then press resize button: + - The TrayIcon selected should be resized to fit the area it occupies. + 2. Press resize button again: + - The TrayIcon should be resized to the original size. + 3. Repeat the 1-2 steps for other TrayIcons: + - The TrayIcons should be resized appropriately. + + CASE 3: Testing EVENTS functionality + --------------------------------- + 1. Select some of the TrayIcons and add it. Select MouseEvent from the + group of checkboxes at the top-right of the test frame. + Click on the TrayIcon in the SystemTray: + - MOUSE_PRESSED MOUSE_RELEASED and MOUSE_CLICKED events should be + generated. + 2. Press mouse inside the TrayIcon dragging mouse and releasing it. + - Make sure that MOUSE_CLICKED event is not triggered. + 3. Click on the TrayIcon with different modification keys: + - there should be appropriate modifiers in the events. + 4. Keep clicking on the TrayIcon: + - there should be correct absolute coordinates in the events. + 5. Only for Windows! Focus the system tray using keyboard: + - press WIN key once to bring up the start menu then press ESC once to + close the menu the focus should be on the start button + - press TAB key for several times until you focus on the system + tray then use ARROW keys to move to the TrayIcon + - press ENTER or SPACE should trigger ACTION_PERFORMED message + make sure that mouse events are not triggered. + 6. Select MouseMotionEvent checkbox. Move mouse over the TrayIcon: + - MOUSE_MOVED event should be generated. It should contain + correct coordinates. + 7. Deselect both the checkboxes and then select AWTEventListener. + Click on the TrayIcon and then move mouse over it: + - Appropriate mouse events should be generated (catched by the + AWTEventListener). + 8. Deselect all the checkboxes and go to the following step. + + CASE 4: Testing DISPLAY MESSAGE functionality. + ---------------------------------------------- + 1. Select some of the TrayIcons and add it. Then press Display message + button: + - A balloon message should appear near the TrayIcon. + 2. After the message is displayed wait for some period: + - The message window should be closed automatically. + 3. Display the message again. Close it by pressing X in its top-right + corner: + - The message window should be closed immediately. + 4. Display the message again. Click inside it: + - The message should be closed an ACTION_PERFORMED event should be + generated with correct information and an Ok dialog should appear. + Close the dialog. + 5. Select a message type from the Type choice and display the message + again: + - It should contain an icon appropriate to the message type selected + or no icon if NONE is selected. + 6. Change the content of the Message and Caption text fields and + display the message: + - The message content should be changed in the accordance with the text + typed. + 7. Not for Windows! Type some too long or too short text for the Caption + and Message: + - The message should process the text correctly. The long text should + be cut. + 8. Not for Windows! Type null in the Message text field and display + the message: + - The message body should contain no text. + 9. Type null in the Caption text field and display the message: + - The message caption should contain no text. + 10. Type null in the both Message and Caption fields and display + the message: + - NullPointerException should be generated and no message should be + displayed. + 11. Try to hide the taskbar. Click Display message for several times. + Then restore the taskbar. Click on the TrayIcon: + - No message should appear. + Try to display the message once more: + - It should appear appropriately. + 12. Try to display the message for other TrayIcons: + - The messages should be displayed appropriately. + + CASE 5: Testing POPUP MENU functionality. + ----------------------------------------- + 1. Add some TrayIcon to the system tray. Press Set button in the + Popup menu test area. Trigger the popup menu for the TrayIcon with + the mouse: + - A popup menu should appear. Make sure it behaves properly. + - Make sure the 'duke.gif' image is animated while the popup menu is shown. + 2. Press Remove button for the popup menu and try to trigger it again: + - No popup menu should appear. + 3. Perform 1-2 steps for other TrayIcons: + - Make sure the popup menu behaves properly. + 4. Add more than one TrayIcons to the system tray. Press Set button in + the PopupMenu test area for some of the TrayIcon added. Trigger + the popup menu for this TrayIcon: + - A popup menu should appear properly. + 5. Try to set the popup menu to the same TrayIcon again: + - It should have no effect + 6. Try to set the popup menu for other TrayIcons you've added to the system + tray: + - for each one IllegalArgumentException should be thrown. + + CASE 6: Testing TOOLTIP functionality. + -------------------------------------- + 1. Type something in the Tooltip text field and press Set button. + Then move mouse cursor over the TrayIcon and wait for a second: + - A tooltip should appear containing the text typed. + 2. Show a tooltip again and keep your mouse over the TrayIcon for some period: + - The tooltip should disappear automatically. + 3. Show a tooltip again and leave the TrayIcon: + - The tooltip should disappear immediately. + 4. Type null in the Tooltip field and press set then move your + mouse to the SystemTray: + - The tooltip shouldn't appear. + 5. Type something too long in the Tooltip field and show the tooltip: + - The tooltip text should be cut. + + CASE 7: Testing ACTION functionality. + ------------------------------------- + 1. Add some TrayIcon to the system tray. Double click it with the left mouse + button: + - An ACTION_PERFORMED event should be generated. + 2. Double click the TrayIcon with the left mouse button several times: + - Several ACTION_PERFORMED events should be generated + - Make sure that the time-stamp of each event ('when' field) is increased. + + If all the above cases work as expected Press PASS else FAIL. + """; + + public static void main(String[] args) throws Exception { + if (!SystemTray.isSupported()) { + throw new SkippedException("Test not applicable as" + + " System Tray not supported"); + } + try { + PassFailJFrame.builder() + .title("TrayIconTest Instructions") + .instructions(INSTRUCTIONS) + .columns(50) + .rows(40) + .testUI(TrayIconTest::createAndShowUI) + .logArea(10) + .build() + .awaitAndCheck(); + + } finally { + EventQueue.invokeAndWait(() -> { + if (tray != null) { + //Remove any remaining tray icons before ending the test. + TrayIcon[] icons = tray.getTrayIcons(); + for (TrayIcon icon : icons) { + tray.remove(icon); + } + } + }); + } + } + + private static Frame createAndShowUI() { + final TrayIconControl ctrl = new TrayIconControl(); + frame.setLayout(new BorderLayout()); + frame.add(ctrl.cont, BorderLayout.CENTER); + frame.setBackground(Color.LIGHT_GRAY); + + frame.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + ctrl.dispose(); + } + }); + + frame.pack(); + return frame; + } + + private static class TrayIconControl { + final String RED_ICON = "RED ICON"; + final String BLUE_ICON = "BLUE ICON"; + final String GREEN_ICON = "GREEN ICON"; + + CheckboxGroup cbg = new CheckboxGroup(); + Button addButton = new PackedButton(" Add "); + Button remButton = new PackedButton("Remove"); + Button resizeButton = new PackedButton("Resize"); + Button balloonButton = new PackedButton("Display message"); + Choice balloonChoice = new Choice(); + String[] balloonTypes = new String[] { "ERROR", "WARNING", "INFO", "NONE" }; + + TextField balloonText = new TextField( + "A TrayIcon can generate various MouseEvents and" + + " supports adding corresponding listeners to receive" + + " notification of these events. TrayIcon processes" + + " some of the events by itself. For example," + + " by default, when the right-mouse click", 70); + TextField balloonCaption = new TextField("TrayIcon", 70); + + MessageType[] typeArr = new MessageType[] { MessageType.ERROR, MessageType.WARNING, + MessageType.INFO, MessageType.NONE }; + Checkbox mouseListenerCbox = new Checkbox("MouseEvent"); + Checkbox motionListenerCbox = new Checkbox(" MouseMotionEvent"); + Checkbox awtListenerCbox = new Checkbox(" AWTEventListener"); + TextField tipText = new TextField("TrayIcon", 50); + Button tipButton = new PackedButton("Set"); + Button setPopupButton = new PackedButton("Set"); + Button remPopupButton = new PackedButton("Remove"); + + PopupMenu popupMenu = new PopupMenu(); + + Map resToObjMap = new HashMap<>(); + + Container cont = new Container(); + + TrayIconControl() { + Toolkit.getDefaultToolkit().addAWTEventListener(e -> { + if (e.getSource() instanceof TrayIcon && awtListenerCbox.getState()) { + PassFailJFrame.log(e.toString()); + } + }, MouseEvent.MOUSE_EVENT_MASK | MouseEvent.MOUSE_MOTION_EVENT_MASK | + ActionEvent.ACTION_EVENT_MASK); + + cont.setLayout(new GridLayout(4, 1)); + + Container raw1 = new Container(); + raw1.setLayout(new GridLayout(1, 4)); + cont.add(raw1); + + InsetsPanel cbgPanel = new InsetsPanel(); + cbgPanel.setLayout(new GridLayout(4, 1)); + Checkbox nullCbox = new Checkbox("null", cbg, true); + Checkbox redCbox = new Checkbox(RED_ICON, cbg, false); + Checkbox blueCbox = new Checkbox(BLUE_ICON, cbg, false); + Checkbox greenCbox = new Checkbox(GREEN_ICON, cbg, false); + cbgPanel.add(nullCbox); + cbgPanel.add(redCbox); + cbgPanel.add(blueCbox); + cbgPanel.add(greenCbox); + cbgPanel.addTo(raw1); + + InsetsPanel addremPanel = new InsetsPanel(); + addremPanel.setLayout(new BorderLayout()); + addremPanel.add(addButton.getParent(), BorderLayout.NORTH); + addremPanel.add(remButton.getParent(), BorderLayout.SOUTH); + addremPanel.addTo(raw1); + + InsetsPanel resizePanel = new InsetsPanel(); + resizePanel.add(resizeButton); + resizePanel.addTo(raw1); + + InsetsPanel lstPanel = new InsetsPanel(); + lstPanel.setLayout(new GridLayout(3, 1)); + lstPanel.add(mouseListenerCbox); + lstPanel.add(motionListenerCbox); + lstPanel.add(awtListenerCbox); + lstPanel.addTo(raw1); + + Container raw2 = new Container(); + raw2.setLayout(new BorderLayout()); + cont.add(raw2); + + InsetsPanel balloonPanel = new InsetsPanel(); + balloonPanel.setLayout(new BorderLayout()); + balloonPanel.add(balloonButton.getParent(), BorderLayout.NORTH); + Container bc = new Container(); + bc.setLayout(new FlowLayout()); + bc.add(new Label(" Type:")); + bc.add(balloonChoice); + balloonPanel.add(bc, BorderLayout.SOUTH); + balloonPanel.addTo(raw2, BorderLayout.WEST); + + InsetsPanel blnTextPanel = new InsetsPanel(); + blnTextPanel.setLayout(new GridLayout(2, 2)); + Container c1 = new Panel(); + c1.setLayout(new FlowLayout()); + blnTextPanel.add(c1); + c1.add(new Label("Message:")); + c1.add(balloonText); + + Container c2 = new Panel(); + c2.setLayout(new FlowLayout()); + blnTextPanel.add(c2); + c2.add(new Label("Caption:")); + c2.add(balloonCaption); + blnTextPanel.addTo(raw2, BorderLayout.CENTER); + + + Container raw3 = new Container(); + raw3.setLayout(new BorderLayout()); + cont.add(raw3); + + InsetsPanel popupPanel = new InsetsPanel(); + popupPanel.setLayout(new FlowLayout()); + popupPanel.add(new Label("Popup menu:")); + popupPanel.add(setPopupButton); + popupPanel.add(remPopupButton); + popupPanel.addTo(raw3); + + + Container raw4 = new Container(); + raw4.setLayout(new BorderLayout()); + cont.add(raw4); + + InsetsPanel tipPanel = new InsetsPanel(); + tipPanel.setLayout(new FlowLayout()); + tipPanel.add(new Label("Tooltip:")); + tipPanel.add(tipText); + tipPanel.add(tipButton); + tipPanel.addTo(raw4); + + addButton.addActionListener(e -> { + try { + tray.add(getCurIcon()); + } catch (NullPointerException npe) { + if (npe.getMessage() == null) { + PassFailJFrame.log("Probably wrong path to the images."); + throw npe; // if wrong images path was set + } + PassFailJFrame.log(npe.toString()); + } catch (IllegalArgumentException iae) { + PassFailJFrame.log(iae.toString()); + } catch (AWTException ise) { + PassFailJFrame.log(ise.toString()); + } + }); + remButton.addActionListener(e -> tray.remove(getCurIcon())); + + resizeButton.addActionListener( + e -> getCurIcon().setImageAutoSize(!getCurIcon().isImageAutoSize())); + + balloonButton.addActionListener(e -> { + String text = null, caption = null; + if (balloonText.getText().compareToIgnoreCase("null") != 0) { + text = balloonText.getText(); + } + if (balloonCaption.getText().compareToIgnoreCase("null") != 0) { + caption = balloonCaption.getText(); + } + try { + getCurIcon().displayMessage(caption, text, typeArr[balloonChoice.getSelectedIndex()]); + } catch (NullPointerException npe) { + PassFailJFrame.log(npe.toString()); + } + }); + + tipButton.addActionListener(e -> { + String tip = null; + if (tipText.getText().compareToIgnoreCase("null") != 0) { + tip = tipText.getText(); + } + getCurIcon().setToolTip(tip); + }); + + setPopupButton.addActionListener(e -> { + try { + getCurIcon().setPopupMenu(popupMenu); + } catch (IllegalArgumentException iae) { + PassFailJFrame.log(iae.toString()); + } + }); + + remPopupButton.addActionListener(e -> getCurIcon().setPopupMenu(null)); + for (String s: balloonTypes) { + balloonChoice.add(s); + } + + init(); + } + + void init() { + tray = SystemTray.getSystemTray(); + tray.addPropertyChangeListener("trayIcons", + e -> printPropertyChangeEvent(e)); + + tray.addPropertyChangeListener("systemTray", + e -> printPropertyChangeEvent(e)); + + configureTrayIcon(RED_ICON); + configureTrayIcon(BLUE_ICON); + configureTrayIcon(GREEN_ICON); + + for (String s: balloonTypes) { + popupMenu.add(new MenuItem(s)); + } + } + + void printPropertyChangeEvent(PropertyChangeEvent e) { + String name = e.getPropertyName(); + Object oldValue = e.getOldValue(); + Object newValue = e.getNewValue(); + + PassFailJFrame.log("PropertyChangeEvent[name=" + name + + ",oldValue=" + oldValue + ",newValue=" + newValue + "]"); + } + + void configureTrayIcon(String icon) { + Color color = Color.WHITE; + switch (icon) { + case "RED ICON" -> color = Color.RED; + case "BLUE ICON" -> color = Color.BLUE; + case "GREEN ICON" -> color = Color.GREEN; + } + Image image = createIcon(color); + TrayIcon trayIcon = new TrayIcon(image); + + trayIcon.addMouseListener(new MouseAdapter() { + public void mousePressed(MouseEvent e) { + if (mouseListenerCbox.getState()) + PassFailJFrame.log(e.toString()); + } + public void mouseReleased(MouseEvent e) { + if (mouseListenerCbox.getState()) + PassFailJFrame.log(e.toString()); + } + public void mouseClicked(MouseEvent e) { + if (mouseListenerCbox.getState()) + PassFailJFrame.log(e.toString()); + } + }); + trayIcon.addMouseMotionListener(new MouseMotionAdapter() { + public void mouseMoved(MouseEvent e) { + if (motionListenerCbox.getState()) + PassFailJFrame.log(e.toString()); + } + }); + trayIcon.addActionListener(e -> PassFailJFrame.log(e.toString())); + + resToObjMap.remove(icon); + resToObjMap.put(icon, trayIcon); + } + + String getCurImgName() { + return cbg.getSelectedCheckbox().getLabel(); + } + + TrayIcon getCurIcon() { + return resToObjMap.get(getCurImgName()); + } + + public void dispose() { + tray.remove(getCurIcon()); + } + + private static Image createIcon(Color color) { + BufferedImage image = new BufferedImage(16, 16, + BufferedImage.TYPE_INT_ARGB); + Graphics2D g = image.createGraphics(); + g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, + RenderingHints.VALUE_TEXT_ANTIALIAS_ON); + g.setColor(color); + g.fillRect(0, 0, 16, 16); + g.dispose(); + return image; + } + + } + + private static class InsetsPanel extends Panel { + Container parent = new Container() { + public Insets getInsets() { + return new Insets(2, 2, 2, 2); + } + }; + + InsetsPanel() { + parent.setLayout(new BorderLayout()); + setBackground(new Color(240, 240, 240)); + } + + void addTo(Container c) { + parent.add(this); + c.add(parent); + } + + void addTo(Container c, String pos) { + parent.add(this); + c.add(parent, pos); + } + } + + private static class PackedButton extends Button { + Container parent = new Container(); + PackedButton(String l) { + super(l); + parent.setLayout(new FlowLayout()); + parent.add(this); + } + } +} + diff --git a/test/jdk/java/awt/Window/BadConfigure/BadConfigure.java b/test/jdk/java/awt/Window/BadConfigure/BadConfigure.java new file mode 100644 index 00000000000..a25ab9b91b9 --- /dev/null +++ b/test/jdk/java/awt/Window/BadConfigure/BadConfigure.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6261336 + * @summary Tests that Choice inside ScrollPane opens at the right location + * after resize + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual BadConfigure +*/ + +import java.awt.BorderLayout; +import java.awt.Choice; +import java.awt.Frame; + +public class BadConfigure +{ + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + Please resize the BadConfigure window using the left border. + Now click on choice. Its popup will be opened. + Please verify that the popup is opened right under the choice. + """; + + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .columns(35) + .testUI(initialize()) + .build() + .awaitAndCheck(); + } + + private static Frame initialize() { + Frame f = new Frame("BadConfigure"); + f.setLayout(new BorderLayout()); + Choice ch = new Choice(); + f.add(ch, BorderLayout.NORTH); + ch.add("One"); + ch.add("One"); + ch.add("One"); + ch.add("One"); + ch.add("One"); + ch.add("One"); + f.setSize(200, 200); + f.validate(); + return f; + } +} diff --git a/test/jdk/java/awt/Window/InvalidFocusLostEventTest/InvalidFocusLostEventTest.java b/test/jdk/java/awt/Window/InvalidFocusLostEventTest/InvalidFocusLostEventTest.java new file mode 100644 index 00000000000..569d59f146d --- /dev/null +++ b/test/jdk/java/awt/Window/InvalidFocusLostEventTest/InvalidFocusLostEventTest.java @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 4397883 + * @summary Tests that non-focusable Window doesn't grab focus + * @key headful + * @run main InvalidFocusLostEventTest + */ + +import java.awt.Button; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.KeyboardFocusManager; +import java.awt.Point; +import java.awt.Robot; +import java.awt.Window; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.InputEvent; + +public class InvalidFocusLostEventTest implements ActionListener { + private static Frame f; + private static Button b; + private static KeyboardFocusManager fm; + private static volatile Point bp; + private static volatile int width, height; + private static Robot robot; + + public static void main(String[] args) throws Exception { + try { + InvalidFocusLostEventTest test = new InvalidFocusLostEventTest(); + EventQueue.invokeAndWait(() -> test.createUI()); + runTest(); + // we should check focus after all events are processed, + // since focus transfers are asynchronous + robot.waitForIdle(); + if (fm.getFocusOwner() != b) { + throw new RuntimeException("Failed: focus was lost"); + } + } finally { + EventQueue.invokeAndWait(() -> { + if (f != null) { + f.dispose(); + } + }); + } + } + + private void createUI() { + f = new Frame("InvalidFocusLostEventTest"); + b = new Button("Press me"); + fm = KeyboardFocusManager.getCurrentKeyboardFocusManager(); + b.addActionListener(this); + f.add(b); + f.pack(); + f.setLocationRelativeTo(null); + f.setVisible(true); + } + + private static void runTest() throws Exception { + robot = new Robot(); + robot.setAutoDelay(100); + robot.setAutoWaitForIdle(true); + EventQueue.invokeAndWait(() -> { + bp = b.getLocationOnScreen(); + width = b.getWidth(); + height = b.getHeight(); + }); + robot.mouseMove(bp.x + width / 2, bp.y + height / 2 ); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + } + + public void actionPerformed(ActionEvent ev) { + // pop up a non-focusable window + Window win = new Window(f); + win.setFocusableWindowState(false); + } +} diff --git a/test/jdk/java/awt/Window/LocationByPlatform/TestLocationByPlatform.java b/test/jdk/java/awt/Window/LocationByPlatform/TestLocationByPlatform.java new file mode 100644 index 00000000000..33b9d048ef2 --- /dev/null +++ b/test/jdk/java/awt/Window/LocationByPlatform/TestLocationByPlatform.java @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6318630 + * @summary Test that location by platform works + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual TestLocationByPlatform + */ + +import java.awt.BorderLayout; +import java.awt.Canvas; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.Graphics; + +public class TestLocationByPlatform { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + You should see two frames. One has locationByPlatform set, it + should be displayed somewhere on the screen most probably without + intersecting other Frames or stacked over normal frame with some + offset. Another has its location explicitly set to (0, 450). + Please verify that the frames are located correctly on the screen. + + Also verify that the picture inside of frames looks the same + and consists of red descending triangle occupying exactly the bottom + half of the frame. Make sure that there is a blue rectangle exactly + surrounding the client area of frame with no pixels between it and + the frame's decorations. Press Pass if this all is true, + otherwise press Fail. + """; + + PassFailJFrame passFailJFrame = PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .rows(13) + .columns(40) + .build(); + EventQueue.invokeAndWait(TestLocationByPlatform::createUI); + passFailJFrame.awaitAndCheck(); + } + private static void createUI() { + Frame frame = new Frame("Normal"); + frame.setLocation(0, 450); + Canvas c = new MyCanvas(); + frame.add(c, BorderLayout.CENTER); + frame.pack(); + PassFailJFrame.addTestWindow(frame); + frame.setVisible(true); + + frame = new Frame("Location by platform"); + frame.setLocationByPlatform(true); + c = new MyCanvas(); + frame.add(c, BorderLayout.CENTER); + frame.pack(); + PassFailJFrame.addTestWindow(frame); + frame.setVisible(true); + } + + static class MyCanvas extends Canvas { + @Override + public Dimension getPreferredSize() { + return new Dimension(400, 400); + } + + @Override + public void paint(Graphics g) { + g.setColor(Color.red); + for (int i = 399; i >= 0; i--) { + g.drawLine(400 - i - 1, 400 - i - 1, + 400 - i - 1, 399); + } + g.setColor(Color.blue); + g.drawLine(0, 0, 399, 0); + g.drawLine(0, 0, 0, 399); + g.drawLine(0, 399, 399, 399); + g.drawLine(399, 0, 399, 399); + } + } +} diff --git a/test/jdk/java/awt/Window/LocationByPlatformWithControls/TestLocationByPlatformWithControls.java b/test/jdk/java/awt/Window/LocationByPlatformWithControls/TestLocationByPlatformWithControls.java new file mode 100644 index 00000000000..bfdba97e4eb --- /dev/null +++ b/test/jdk/java/awt/Window/LocationByPlatformWithControls/TestLocationByPlatformWithControls.java @@ -0,0 +1,270 @@ +/* + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 4102292 + * @summary Tests that location by platform works with other APIs + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual TestLocationByPlatformWithControls + */ + +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.Checkbox; +import java.awt.Frame; +import java.awt.Label; +import java.awt.Panel; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.util.Vector; + +public class TestLocationByPlatformWithControls extends Frame + implements ActionListener, ItemListener { + Panel northP; + Panel centerP; + Checkbox undecoratedCB; + Checkbox defaultLocationCB; + Checkbox visibleCB; + Checkbox iconifiedCB; + Checkbox maximizedCB; + Button createB; + Button packB; + Button moveB; + Button resizeB; + Button reshapeB; + Button disposeB; + Vector frames; + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + This test is to check that LocationByPlatform works with other + controls API. + 1) Create New Frame by clicking on "Create" Button in + "TestLocationByPlatformWithControls" window. + 2) Initially this Frame will not be visible, Click on checkbox + "LocationByPlatform" to set default platform location for the frame + and then click on checkbox "Visible" to see that Frame is displayed + at default offsets. + 3) Now you can play with different controls like Iconified, + Maximized, Pack, Move, Resize and Reshape to verify that these + controls work properly with the Frame. + 4) At the end dispose the Frame by clicking on "Dispose" button. + 5) Also we can do verify this for Undecorated Frame but for that we + need to follow same steps but in step 2 before we click on checkbox + "Visible", select "Undecorated" checkbox along with + "LocationByPlatform". + 6) If everything works properly test is passed, otherwise failed. + """; + + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(TestLocationByPlatformWithControls::new) + .logArea(4) + .build() + .awaitAndCheck(); + } + + public TestLocationByPlatformWithControls() { + northP = new Panel(); + centerP = new Panel(); + + undecoratedCB = new Checkbox("Undecorated"); + defaultLocationCB = new Checkbox("LocationByPlatform"); + visibleCB = new Checkbox("Visible"); + iconifiedCB = new Checkbox("Iconified"); + maximizedCB = new Checkbox("Maximized"); + + createB = new Button("Create"); + packB = new Button("Pack"); + moveB = new Button("Move"); + resizeB = new Button("Resize"); + reshapeB = new Button("Reshape"); + disposeB = new Button("Dispose"); + + frames = new Vector(10); + this.setTitle("TestLocationByPlatformWithControls"); + this.setLayout(new BorderLayout()); + this.add(northP, BorderLayout.NORTH); + + northP.add(new Label("New Frame")); + + createB.addActionListener(this); + northP.add(createB); + + centerP.setEnabled(false); + this.add(centerP, BorderLayout.CENTER); + + centerP.add(new Label("Last Frame")); + + centerP.add(defaultLocationCB); + defaultLocationCB.addItemListener(this); + + centerP.add(undecoratedCB); + undecoratedCB.addItemListener(this); + + centerP.add(iconifiedCB); + iconifiedCB.addItemListener(this); + + centerP.add(maximizedCB); + maximizedCB.addItemListener(this); + + centerP.add(visibleCB); + visibleCB.addItemListener(this); + + packB.addActionListener(this); + centerP.add(packB); + + moveB.addActionListener(this); + centerP.add(moveB); + + resizeB.addActionListener(this); + centerP.add(resizeB); + + reshapeB.addActionListener(this); + centerP.add(reshapeB); + + disposeB.addActionListener(this); + centerP.add(disposeB); + this.pack(); + } + + public void actionPerformed(ActionEvent e) { + if (e.getSource() == createB) { + Frame frame = new Frame(); + frame.setSize(200, 200); + frames.add(frame); + updateControls(frame); + Panel panel = new Panel(); + frame.add(panel); + panel.add(new Button ("Test Button")); + panel.add(new Button ("Test Button 1")); + panel.add(new Button ("Test Button 2")); + panel.add(new Button ("Test Button 3")); + centerP.setEnabled(true); + return; + } + + if (frames.isEmpty()) { + return; + } + + Frame last = (Frame)frames.lastElement(); + + if (e.getSource() == packB) { + last.pack(); + } else + if (e.getSource() == moveB) { + int x = (int)(Math.random() * 200); + int y = (int)(Math.random() * 200); + last.setLocation(x, y); + } else + if (e.getSource() == resizeB) { + int w = (int)(Math.random() * 200); + int h = (int)(Math.random() * 200); + last.setSize(w, h); + } else + if (e.getSource() == reshapeB) { + int x = (int)(Math.random() * 200); + int y = (int)(Math.random() * 200); + int w = (int)(Math.random() * 200); + int h = (int)(Math.random() * 200); + last.setBounds(x, y, w, h); + } else + if (e.getSource() == disposeB) { + last.dispose(); + frames.remove(frames.size() - 1); + if (frames.isEmpty()) { + updateControls(null); + centerP.setEnabled(false); + return; + } + last = (Frame)frames.lastElement(); + } + updateControls(last); + } + + public void updateControls(Frame f) { + undecoratedCB.setState(f != null ? + f.isUndecorated() : false); + defaultLocationCB.setState(f != null ? + f.isLocationByPlatform() : false); + visibleCB.setState(f != null ? + f.isVisible() : false); + iconifiedCB.setState(f != null ? + (f.getExtendedState() & Frame.ICONIFIED) != 0 : false); + maximizedCB.setState(f != null ? + (f.getExtendedState() & Frame.MAXIMIZED_BOTH) != 0 : false); + } + + public void itemStateChanged(ItemEvent e) { + Frame last = (Frame)frames.lastElement(); + try { + boolean state = e.getStateChange() == ItemEvent.SELECTED; + if (e.getSource() == visibleCB) { + last.setVisible(state); + } else + if (e.getSource() == defaultLocationCB) { + last.setLocationByPlatform(state); + } else + if (e.getSource() == undecoratedCB) { + last.setUndecorated(state); + } else + if (e.getSource() == iconifiedCB) { + if (state) { + last.setExtendedState(last.getExtendedState() | + Frame.ICONIFIED); + } else { + last.setExtendedState(last.getExtendedState() & + ~Frame.ICONIFIED); + } + } else + if (e.getSource() == maximizedCB) { + if (state) { + last.setExtendedState(last.getExtendedState() | + Frame.MAXIMIZED_BOTH); + } else { + last.setExtendedState(last.getExtendedState() & + ~Frame.MAXIMIZED_BOTH); + } + } + } catch (Throwable ex) { + PassFailJFrame.log(ex.getMessage()); + } finally { + updateControls(last); + } + } + + @Override + public void dispose() { + while (!frames.isEmpty()) { + Frame last = (Frame)frames.lastElement(); + last.dispose(); + frames.remove(frames.size() - 1); + } + } +} diff --git a/test/jdk/java/awt/Window/NoResizeEvent/NoResizeEvent.java b/test/jdk/java/awt/Window/NoResizeEvent/NoResizeEvent.java new file mode 100644 index 00000000000..50b264acde9 --- /dev/null +++ b/test/jdk/java/awt/Window/NoResizeEvent/NoResizeEvent.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 4942457 + * @key headful + * @summary Verifies that filtering of resize events on native level works. + * I.E.after Frame is shown no additional resize events are generated. + * @library /java/awt/patchlib ../../regtesthelpers + * @build java.desktop/java.awt.Helper + * @build Util + * @run main NoResizeEvent + */ + +import test.java.awt.regtesthelpers.Util; + +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.event.ComponentAdapter; +import java.awt.event.ComponentEvent; + +public class NoResizeEvent { + //Mutter can send window insets too late, causing additional resize events. + private static final boolean IS_MUTTER = Util.getWMID() == Util.MUTTER_WM; + private static final int RESIZE_COUNT_LIMIT = IS_MUTTER ? 5 : 3; + private static Frame frame; + static int resize_count = 0; + + public static void main(String[] args) throws Exception { + try { + EventQueue.invokeAndWait(() -> createUI()); + } finally { + EventQueue.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + if (resize_count > RESIZE_COUNT_LIMIT) { + throw new RuntimeException("Resize event arrived: " + + resize_count + " times."); + } + } + } + + private static void createUI() { + frame = new Frame("NoResizeEvent"); + frame.addComponentListener(new ComponentAdapter() { + public void componentResized(ComponentEvent e) { + System.out.println(e); + resize_count++; + } + }); + frame.setVisible(true); + + try { + Thread.sleep(3000); + } catch (InterruptedException ie) { + } + System.out.println("Resize count: " + resize_count); + } +} diff --git a/test/jdk/java/awt/Window/OwnedWindowShowTest/OwnedWindowShowTest.java b/test/jdk/java/awt/Window/OwnedWindowShowTest/OwnedWindowShowTest.java new file mode 100644 index 00000000000..c8b5ad4a619 --- /dev/null +++ b/test/jdk/java/awt/Window/OwnedWindowShowTest/OwnedWindowShowTest.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4177156 + * @key headful + * @summary Tests that multiple level of window ownership doesn't cause + * NullPointerException when showing a Window + * @run main OwnedWindowShowTest + */ + +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.Window; + +public class OwnedWindowShowTest { + public static void main(String[] args) throws Exception { + EventQueue.invokeAndWait(OwnedWindowShowTest::runTest); + } + + static void runTest() { + Frame parent = new Frame("OwnedWindowShowTest"); + try { + Window owner = new Window(parent); + Window window = new Window(owner); + // Showing a window with multiple levels of ownership + // should not throw NullPointerException + window.setVisible(true); + } finally { + parent.dispose(); + } + } +} diff --git a/test/jdk/java/awt/Window/OwnedWindowsLeak/OwnedWindowsLeak.java b/test/jdk/java/awt/Window/OwnedWindowsLeak/OwnedWindowsLeak.java index cb20a2f2732..91d277a2284 100644 --- a/test/jdk/java/awt/Window/OwnedWindowsLeak/OwnedWindowsLeak.java +++ b/test/jdk/java/awt/Window/OwnedWindowsLeak/OwnedWindowsLeak.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,7 +28,7 @@ @summary Tests that windows are removed from owner's child windows list @modules java.desktop/java.awt:open @author art: area=awt.toplevel - @run main/othervm -mx128m OwnedWindowsLeak + @run main/othervm -Xmx128m OwnedWindowsLeak */ import java.awt.Frame; diff --git a/test/jdk/java/awt/Window/ProxyCrash/PopupProxyCrash.java b/test/jdk/java/awt/Window/ProxyCrash/PopupProxyCrash.java new file mode 100644 index 00000000000..b17b934a702 --- /dev/null +++ b/test/jdk/java/awt/Window/ProxyCrash/PopupProxyCrash.java @@ -0,0 +1,192 @@ +/* + * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 4381561 + * @key headful + * @summary Tests that when we show the popup window AWT doesn't crash due to + * the problems with focus proxy window code + * @run main PopupProxyCrash + */ + +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.Color; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.Font; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Panel; +import java.awt.Point; +import java.awt.Robot; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.InputEvent; + +import javax.swing.Box; +import javax.swing.JComboBox; +import javax.swing.JTextField; +import javax.swing.plaf.basic.BasicComboBoxUI; +import javax.swing.plaf.basic.BasicComboPopup; +import javax.swing.plaf.basic.ComboPopup; + +public class PopupProxyCrash implements ActionListener { + private static JTextField jtf; + private static Button tf; + private static Panel panel; + private static Font[] fonts; + private static Robot robot; + + private static JComboBox cb; + + private static MyComboBoxUI comboBoxUI; + private static Frame frame; + private static int TEST_COUNT = 10; + public static void main(String[] args) throws Exception { + try { + robot = new Robot(); + robot.setAutoDelay(100); + EventQueue.invokeAndWait(() -> createUI()); + robot.waitForIdle(); + runTest(); + } finally { + EventQueue.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } + + private static void createUI() { + frame = new Frame("PopupProxyCrash"); + Font dialog = new Font("Dialog", Font.PLAIN, 12); + Font serif = new Font("Serif", Font.PLAIN, 12); + Font monospaced = new Font("Monospaced", Font.PLAIN, 12); + + fonts = new Font[] { dialog, serif, monospaced }; + + cb = new JComboBox(fonts); + + cb.setLightWeightPopupEnabled(false); + comboBoxUI = new MyComboBoxUI(); + cb.setUI(comboBoxUI); + jtf = new JTextField("JTextField"); + jtf.setFont(fonts[1]); + tf = new Button("TextField"); + tf.setFont(fonts[1]); + cb.addActionListener(new PopupProxyCrash()); + + panel = new Panel() { + public Dimension getPreferredSize() { + return new Dimension(100, 20); + } + public void paint(Graphics g) { + System.out.println("Painting with font " + getFont()); + g.setColor(Color.white); + g.fillRect(0, 0, getWidth(), getHeight()); + g.setColor(Color.black); + g.setFont(getFont()); + g.drawString("LightWeight", 10, 10); + } + }; + panel.setFont(fonts[1]); + + Container parent = Box.createVerticalBox(); + parent.add(jtf); + parent.add(tf); + parent.add(panel); + parent.add(cb); + + frame.add(parent, BorderLayout.CENTER); + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } + + private static Point getComboBoxLocation() throws Exception { + final Point[] result = new Point[1]; + + EventQueue.invokeAndWait(() -> { + Point point = cb.getLocationOnScreen(); + Dimension size = cb.getSize(); + + point.x += size.width / 2; + point.y += size.height / 2; + result[0] = point; + }); + return result[0]; + } + + private static Point getItemPointToClick(final int item) throws Exception { + final Point[] result = new Point[1]; + + EventQueue.invokeAndWait(() -> { + BasicComboPopup popup = (BasicComboPopup)comboBoxUI.getComboPopup(); + Point point = popup.getLocationOnScreen(); + Dimension size = popup.getSize(); + + int step = size.height / fonts.length; + point.x += size.width / 2; + point.y += step / 2 + step * item; + result[0] = point; + }); + return result[0]; + } + + static void runTest() throws Exception { + for (int i = 0; i < TEST_COUNT; i++) { + Point point = getComboBoxLocation(); + robot.mouseMove(point.x, point.y); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.waitForIdle(); + robot.delay(500); + + point = getItemPointToClick(i % fonts.length); + robot.mouseMove(point.x, point.y); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.waitForIdle(); + robot.delay(500); + } + } + public void actionPerformed(ActionEvent ae) { + System.out.println("Font selected"); + Font font = fonts[((JComboBox)ae.getSource()).getSelectedIndex()]; + + tf.setFont(font); + jtf.setFont(font); + panel.setFont(font); + panel.repaint(); + } + + private static class MyComboBoxUI extends BasicComboBoxUI { + public ComboPopup getComboPopup() { + return popup; + } + } +} diff --git a/test/jdk/java/awt/Window/ResizeTest/ResizeTest.java b/test/jdk/java/awt/Window/ResizeTest/ResizeTest.java new file mode 100644 index 00000000000..a9191f8bd05 --- /dev/null +++ b/test/jdk/java/awt/Window/ResizeTest/ResizeTest.java @@ -0,0 +1,80 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4225955 + * @summary Tests that focus lost is delivered to a lightweight component + * in a disposed window + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual ResizeTest + */ + +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.Dialog; +import java.awt.Frame; + +public class ResizeTest +{ + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + 1) Push button A to create modal dialog 2. + 2) Resize dialog 2, then click button B to hide it. + 3) Push button A again. Dialog B should be packed to its original + size. + 4) Push button B again to hide, and A to reshow. + Dialog B should still be the same size, then test is passed, + otherwise failed. + 5) Push button B to hide the modal dialog and then select pass/fail. + """; + + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(ResizeTest::createUI) + .build() + .awaitAndCheck(); + } + + private static Frame createUI() { + Frame f = new Frame("1"); + Dialog d = new Dialog(f, "2", true); + d.setLocationRelativeTo(null); + Button b2 = new Button("B"); + b2.addActionListener(e -> d.setVisible(false)); + d.setLayout(new BorderLayout()); + d.add(b2, BorderLayout.CENTER); + + Button b = new Button("A"); + f.add(b, BorderLayout.CENTER); + b.addActionListener(e -> { + d.pack(); + d.setVisible(true); + }); + f.pack(); + return f; + } +} diff --git a/test/jdk/java/awt/Window/ShowWindowTest/ShowWindowTest.java b/test/jdk/java/awt/Window/ShowWindowTest/ShowWindowTest.java new file mode 100644 index 00000000000..4857929c94e --- /dev/null +++ b/test/jdk/java/awt/Window/ShowWindowTest/ShowWindowTest.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4084997 + * @summary See if Window can be created without its size explicitly set + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual ShowWindowTest + */ + +import java.awt.Button; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.Label; +import java.awt.Window; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public class ShowWindowTest implements ActionListener +{ + private static Window window; + private static Button showButton; + private static Button hideButton; + + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + 1. You should see a Frame with a "Show" and a "Hide" button in it. + 2. Click on the "Show" button. A window with a "Hello World" Label + should appear + 3. If the window does not appear, the test failed, otherwise passed. + """; + + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(ShowWindowTest::createUI) + .build() + .awaitAndCheck(); + } + + private static Frame createUI() { + Frame frame = new Frame("ShowWindowTest"); + frame.setLayout(new FlowLayout()); + frame.setSize(100,100); + frame.add(showButton = new Button("Show")); + frame.add(hideButton = new Button("Hide")); + + ActionListener handler = new ShowWindowTest(); + showButton.addActionListener(handler); + hideButton.addActionListener(handler); + + window = new Window(frame); + window.add("Center", new Label("Hello World")); + window.setLocationRelativeTo(null); + return frame; + } + + public void actionPerformed(ActionEvent e) { + if (e.getSource() == showButton) { + window.pack(); + window.setVisible(true); + } else if (e.getSource() == hideButton) + window.setVisible(false); + } +} diff --git a/test/jdk/java/awt/Window/WindowToFrontTest/WindowToFrontTest.java b/test/jdk/java/awt/Window/WindowToFrontTest/WindowToFrontTest.java new file mode 100644 index 00000000000..e6bbadcb546 --- /dev/null +++ b/test/jdk/java/awt/Window/WindowToFrontTest/WindowToFrontTest.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 4488209 + * @summary JFrame toFront causes the entire frame to be repainted, causes UI + * to flash + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual WindowToFrontTest + */ + +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public class WindowToFrontTest implements ActionListener { + static Frame frame; + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + 1) Click the "toFront" button, this causes the + "WindowToFrontTest" frame to move front and gets repainted + completely. + 2) Move "WindowToFrontTest" window and continue to click on "toFront + multiple times. If the "WindowToFrontTest" Frame content is not + drawn properly and continues to blink, test is failed + otherwise passed. + """; + + PassFailJFrame passFailJFrame = PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .rows(13) + .columns(40) + .build(); + EventQueue.invokeAndWait(() -> createUI()); + passFailJFrame.awaitAndCheck(); + } + + private static void createUI() { + frame = new Frame("WindowToFrontTest"); + frame.setLayout(new BorderLayout()); + frame.setSize(512, 512); + PassFailJFrame.addTestWindow(frame); + frame.setVisible(true); + + Frame buttonFrame = new Frame("Test Button"); + Button push = new Button("toFront"); + push.addActionListener(new WindowToFrontTest()); + buttonFrame.add(push); + buttonFrame.pack(); + PassFailJFrame.addTestWindow(buttonFrame); + buttonFrame.setVisible(true); + } + + public void actionPerformed(ActionEvent e) { + frame.toFront(); + } +} diff --git a/test/jdk/java/awt/Window/bug4189244.java b/test/jdk/java/awt/Window/bug4189244.java new file mode 100644 index 00000000000..df37d2fce0e --- /dev/null +++ b/test/jdk/java/awt/Window/bug4189244.java @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4189244 + * @summary Swing Popup menu is not being refreshed (cleared) under a Dialog + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @requires (os.family == "windows") + * @run main/manual bug4189244 +*/ + +import java.awt.BorderLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JMenuItem; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JPopupMenu; + +public class bug4189244 { + + private static final String INSTRUCTIONS = """ + This is Windows only test! + + Click right button on frame to show popup menu. + (menu should be placed inside frame otherwise bug is not reproducible) + click on any menu item (dialog will be shown). + close dialog. + if you see part of popupmenu, under dialog, before it is closed, + then test failed, else passed."""; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("bug4189244 Instructions") + .instructions(INSTRUCTIONS) + .rows((int)INSTRUCTIONS.lines().count() + 2) + .columns(35) + .testUI(bug4189244::createTestUI) + .build() + .awaitAndCheck(); + } + + + private static JFrame createTestUI() { + RefreshBug panel = new RefreshBug(); + JFrame frame = new JFrame("Popup refresh bug"); + + frame.add(panel, BorderLayout.CENTER); + panel.init(); + frame.setSize(400, 400); + return frame; + } +} + +class RefreshBug extends JPanel implements ActionListener { + JPopupMenu _jPopupMenu = new JPopupMenu(); + + public void init() { + JMenuItem menuItem; + JButton jb = new JButton("Bring the popup here and select an item"); + + this.add(jb, BorderLayout.CENTER); + + for(int i = 1; i < 10; i++) { + menuItem = new JMenuItem("Item " + i); + menuItem.addActionListener(this); + _jPopupMenu.add(menuItem); + } + + MouseListener ml = new MouseAdapter() { + public void mouseReleased(MouseEvent e) { + if (e.isPopupTrigger()) { + _jPopupMenu.show(e.getComponent(), + e.getX(), e.getY()); + } + } + }; + this.addMouseListener(ml); + + jb.addMouseListener(ml); + + } + + // An action is requested by the user + public void actionPerformed(java.awt.event.ActionEvent e) { + JOptionPane.showMessageDialog(this, + "Check if there is some popup left under me\n"+ + "if not, retry and let the popup appear where i am", + "WARNING", + JOptionPane.WARNING_MESSAGE); + + } +} diff --git a/test/jdk/java/awt/color/XAWTDifference/XAWTColors.jpg b/test/jdk/java/awt/color/XAWTDifference/XAWTColors.jpg new file mode 100644 index 00000000000..f53b30407cc Binary files /dev/null and b/test/jdk/java/awt/color/XAWTDifference/XAWTColors.jpg differ diff --git a/test/jdk/java/awt/color/XAWTDifference/XAWTDifference.java b/test/jdk/java/awt/color/XAWTDifference/XAWTDifference.java new file mode 100644 index 00000000000..ef0f5aacf44 --- /dev/null +++ b/test/jdk/java/awt/color/XAWTDifference/XAWTDifference.java @@ -0,0 +1,223 @@ +/* + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Button; +import java.awt.Canvas; +import java.awt.Checkbox; +import java.awt.Choice; +import java.awt.Component; +import java.awt.Frame; +import java.awt.GridLayout; +import java.awt.Image; +import java.awt.Label; +import java.awt.Menu; +import java.awt.MenuBar; +import java.awt.MenuItem; +import java.awt.Panel; +import java.awt.PopupMenu; +import java.awt.ScrollPane; +import java.awt.Scrollbar; +import java.awt.TextArea; +import java.awt.TextField; +import java.awt.Window; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +import javax.swing.ImageIcon; +import javax.swing.JLabel; + +/* + * @test + * @bug 5092883 6513478 7154025 + * @requires (os.family == "linux") + * @summary REGRESSION: SystemColor class gives back wrong values under Linux + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual XAWTDifference + */ + +public class XAWTDifference { + + private static final String INSTRUCTIONS = """ + You would see a frame with title "XAWTDifference Test Frame". + + Test Frame (1) + + a) It has three columns in it. The 1st one with ordinary components. + The 2nd one with disabled components. + The 3rd one with uneditable components (only text components + are there). Verify that the difference between different states + is visible. + + Standard Frame (2) + + b) You would also see a frame named StandardFrame (2) + with a lot of components in it. Actually this is just a jpg-image + in a frame. Verify that every component in the frame (1) looks + similar to the same component in (2). + + They might differ in colors and be darker or brighter but + the whole picture should be the same. + + c) Also check the color of the MenuBar Items in the MenuBar and + the PopupMenu assigned to TextArea. + As you can't compare the colors of menu items with the picture + so just look if the are adequate enough. + """; + private static final int HGAP = 20; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(XAWTDifference::createAndShowUI) + .positionTestUI(XAWTDifference::positionMultiTestUI) + .build() + .awaitAndCheck(); + } + + private static Panel addComponentsIntoPanel(boolean enabled, boolean editable) { + TextField tf = new TextField("TextField"); + TextArea ta = new TextArea("TextArea", 10, 10); + + Choice levelChooser = new Choice(); + levelChooser.add("Item #1"); + levelChooser.add("Item #2"); + + Button b = new Button("BUTTON"); + Label label = new Label("LABEL"); + java.awt.List list = new java.awt.List(4, false); + list.add("one"); + list.add("two"); + list.add("three"); + + Checkbox chb = new Checkbox(); + Scrollbar sb = new Scrollbar(Scrollbar.HORIZONTAL); + ScrollPane sp = new ScrollPane(ScrollPane.SCROLLBARS_ALWAYS); + sp.add(new TextArea("this is a textarea in scrollpane")); + sp.setSize(200, 200); + Canvas canvas = new Canvas(); + canvas.setSize(100, 100); + + //add popup menu to Button + final PopupMenu pm = new PopupMenu(); + MenuItem i1 = new MenuItem("Item1"); + MenuItem i2 = new MenuItem("Item2"); + MenuItem i3 = new MenuItem("Item3"); + i3.setEnabled(false); + pm.add(i1); + pm.add(i2); + pm.add(i3); + canvas.add(pm); + + ta.add(pm); + ta.addMouseListener(new MouseAdapter() { + public void mousePressed(MouseEvent me) { + if (me.isPopupTrigger()) { + pm.show(me.getComponent(), me.getX(), me.getY()); + } + } + }); + + ArrayList componentList = new ArrayList<>(); + + componentList.add(tf); + componentList.add(ta); + if (editable){ + componentList.add(levelChooser); + componentList.add(b); + componentList.add(label); + componentList.add(list); + componentList.add(chb); + componentList.add(sb); + componentList.add(sp); + componentList.add(canvas); + } else { + tf.setEditable(false); + ta.setEditable(false); + } + + Panel panel = new Panel(); + panel.setLayout(new GridLayout(0, 1)); + for (Component c : componentList) { + if (!enabled) { + c.setEnabled(false); + } + panel.add(c); + } + return panel; + } + + private static List createAndShowUI() { + Frame testFrame = new Frame("XAWTDifference Test Frame"); + StandardFrame standardFrame = new StandardFrame("StandardFrame"); + standardFrame.pack(); + + testFrame.setLayout(new GridLayout(1, 3)); + testFrame.add(addComponentsIntoPanel(true, true)); + testFrame.add(addComponentsIntoPanel(false, true)); + testFrame.add(addComponentsIntoPanel(true, false)); + + MenuItem mi1 = new MenuItem("Item1"); + MenuItem mi2 = new MenuItem("Item2"); + MenuItem mi3 = new MenuItem("Disabled Item3"); + mi3.setEnabled(false); + + MenuBar mb = new MenuBar(); + Menu enabledMenu = new Menu("Enabled Menu"); + Menu disabledMenu = new Menu("Disabled Menu"); + disabledMenu.setEnabled(false); + mb.add(enabledMenu); + mb.add(disabledMenu); + enabledMenu.add(mi1); + enabledMenu.add(mi2); + enabledMenu.add(mi3); + + testFrame.setMenuBar(mb); + testFrame.setSize(standardFrame.getWidth(), standardFrame.getHeight()); + return List.of(testFrame, standardFrame); + } + + private static void positionMultiTestUI(List windows, + PassFailJFrame.InstructionUI instructionUI) { + int x = instructionUI.getLocation().x + instructionUI.getSize().width + HGAP; + for (Window w : windows) { + w.setLocation(x, instructionUI.getLocation().y); + x += w.getWidth() + HGAP; + } + } + + private static class StandardFrame extends Frame { + public StandardFrame(String name) { + super(name); + String testPath = System.getProperty("test.src", "."); + Panel panel = new Panel(); + panel.add(new JLabel(new ImageIcon(testPath + File.separator + "XAWTColors.jpg"))); + add(panel); + } + } +} diff --git a/test/jdk/java/awt/dnd/CustomDragCursorTest.java b/test/jdk/java/awt/dnd/CustomDragCursorTest.java new file mode 100644 index 00000000000..9e5e006b31c --- /dev/null +++ b/test/jdk/java/awt/dnd/CustomDragCursorTest.java @@ -0,0 +1,289 @@ +/* + * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 java.awt.Button; +import java.awt.Component; +import java.awt.Cursor; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.GridLayout; +import java.awt.Panel; +import java.awt.Point; +import java.awt.Robot; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.Transferable; +import java.awt.datatransfer.UnsupportedFlavorException; +import java.awt.dnd.DnDConstants; +import java.awt.dnd.DragGestureEvent; +import java.awt.dnd.DragGestureListener; +import java.awt.dnd.DragSource; +import java.awt.dnd.DragSourceDragEvent; +import java.awt.dnd.DragSourceDropEvent; +import java.awt.dnd.DragSourceEvent; +import java.awt.dnd.DragSourceListener; +import java.awt.dnd.DropTarget; +import java.awt.dnd.DropTargetContext; +import java.awt.dnd.DropTargetDragEvent; +import java.awt.dnd.DropTargetDropEvent; +import java.awt.dnd.DropTargetEvent; +import java.awt.dnd.DropTargetListener; +import java.awt.event.InputEvent; +import java.awt.event.KeyEvent; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; + +/* + * @test + * @bug 4451328 + * @summary tests that a custom drag cursor is not changed + to the default drag cursor + * @key headful + * @run main CustomDragCursorTest + */ + +public class CustomDragCursorTest { + private static Frame frame; + private static final DragSourcePanel dragSourcePanel = new DragSourcePanel(); + private static final DropTargetPanel dropTargetPanel = new DropTargetPanel(); + + private static volatile Point srcPoint; + private static volatile Point dstPoint; + private static volatile boolean passed = true; + + public static void main(String[] args) throws Exception { + try { + Robot robot = new Robot(); + EventQueue.invokeAndWait(CustomDragCursorTest::createAndShowUI); + robot.waitForIdle(); + robot.delay(1000); + + EventQueue.invokeAndWait(() -> { + Point p = dragSourcePanel.getLocationOnScreen(); + Dimension d = dragSourcePanel.getSize(); + p.translate(d.width / 2, d.height / 2); + srcPoint = p; + + p = dropTargetPanel.getLocationOnScreen(); + d = dropTargetPanel.getSize(); + p.translate(d.width / 2, d.height / 2); + dstPoint = p; + }); + + robot.mouseMove(srcPoint.x, srcPoint.y); + robot.keyPress(KeyEvent.VK_CONTROL); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + for (; !srcPoint.equals(dstPoint); + srcPoint.translate(sign(dstPoint.x - srcPoint.x), + sign(dstPoint.y - srcPoint.y))) { + robot.mouseMove(srcPoint.x, srcPoint.y); + robot.delay(10); + } + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.keyRelease(KeyEvent.VK_CONTROL); + robot.waitForIdle(); + robot.delay(1000); + + if (!passed) { + throw new RuntimeException("Custom drag cursor changed to default."); + } + } finally { + EventQueue.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } + + private static void createAndShowUI() { + frame = new Frame("CustomDragCursorTest"); + frame.setLayout(new GridLayout(2, 1)); + frame.add(dragSourcePanel); + frame.add(dropTargetPanel); + frame.setLocationRelativeTo(null); + frame.setSize(300, 400); + frame.setVisible(true); + } + + public static void failed() { + passed = false; + } + + private static int sign(int n) { + return Integer.compare(n, 0); + } + + private static class DragSourceButton extends Button implements Serializable, + Transferable, + DragGestureListener, + DragSourceListener { + private final DataFlavor dataflavor = + new DataFlavor(Button.class, "DragSourceButton"); + private final Cursor dragCursor = new Cursor(Cursor.HAND_CURSOR); + + public DragSourceButton() { + this("DragSourceButton"); + } + + public DragSourceButton(String str) { + super(str); + + DragSource ds = DragSource.getDefaultDragSource(); + ds.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_COPY, + this); + } + + public void dragGestureRecognized(DragGestureEvent dge) { + dge.startDrag(dragCursor, this, this); + } + + public void dragEnter(DragSourceDragEvent dsde) { + if (!dragCursor.equals(dsde.getDragSourceContext().getCursor())) { + CustomDragCursorTest.failed(); + } + } + + public void dragExit(DragSourceEvent dse) { + if (!dragCursor.equals(dse.getDragSourceContext().getCursor())) { + CustomDragCursorTest.failed(); + } + } + + public void dragOver(DragSourceDragEvent dsde) { + if (!dragCursor.equals(dsde.getDragSourceContext().getCursor())) { + CustomDragCursorTest.failed(); + } + } + + public void dragDropEnd(DragSourceDropEvent dsde) { + if (!dragCursor.equals(dsde.getDragSourceContext().getCursor())) { + CustomDragCursorTest.failed(); + } + } + + public void dropActionChanged(DragSourceDragEvent dsde) { + if (!dragCursor.equals(dsde.getDragSourceContext().getCursor())) { + CustomDragCursorTest.failed(); + } + } + + public Object getTransferData(DataFlavor flavor) + throws UnsupportedFlavorException, IOException { + + if (!isDataFlavorSupported(flavor)) { + throw new UnsupportedFlavorException(flavor); + } + + Object retObj; + + ByteArrayOutputStream baoStream = new ByteArrayOutputStream(); + ObjectOutputStream ooStream = new ObjectOutputStream(baoStream); + ooStream.writeObject(this); + + ByteArrayInputStream baiStream = new ByteArrayInputStream(baoStream.toByteArray()); + ObjectInputStream ois = new ObjectInputStream(baiStream); + try { + retObj = ois.readObject(); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + throw new RuntimeException(e.toString()); + } + + return retObj; + } + + public DataFlavor[] getTransferDataFlavors() { + return new DataFlavor[] { dataflavor }; + } + + public boolean isDataFlavorSupported(DataFlavor dflavor) { + return dataflavor.equals(dflavor); + } + } + + private static class DragSourcePanel extends Panel { + + final Dimension preferredDimension = new Dimension(200, 100); + + public DragSourcePanel() { + setLayout(new GridLayout(1, 1)); + add(new DragSourceButton()); + } + + public Dimension getPreferredSize() { + return preferredDimension; + } + } + + private static class DropTargetPanel extends Panel implements DropTargetListener { + + final Dimension preferredDimension = new Dimension(200, 100); + + public DropTargetPanel() { + setDropTarget(new DropTarget(this, this)); + } + + public Dimension getPreferredSize() { + return preferredDimension; + } + + public void dragEnter(DropTargetDragEvent dtde) {} + + public void dragExit(DropTargetEvent dte) {} + + public void dragOver(DropTargetDragEvent dtde) {} + + public void dropActionChanged(DropTargetDragEvent dtde) {} + + public void drop(DropTargetDropEvent dtde) { + DropTargetContext dtc = dtde.getDropTargetContext(); + + if ((dtde.getSourceActions() & DnDConstants.ACTION_COPY) != 0) { + dtde.acceptDrop(DnDConstants.ACTION_COPY); + } else { + dtde.rejectDrop(); + } + + DataFlavor[] dfs = dtde.getCurrentDataFlavors(); + Component comp = null; + + if(dfs != null && dfs.length >= 1) { + Transferable transfer = dtde.getTransferable(); + + try { + comp = (Component)transfer.getTransferData(dfs[0]); + } catch (Throwable e) { + e.printStackTrace(); + dtc.dropComplete(false); + } + } + dtc.dropComplete(true); + add(comp); + } + } +} diff --git a/test/jdk/java/awt/dnd/DnDAcceptanceTest/DnDAcceptanceTest.java b/test/jdk/java/awt/dnd/DnDAcceptanceTest/DnDAcceptanceTest.java new file mode 100644 index 00000000000..700187f9dce --- /dev/null +++ b/test/jdk/java/awt/dnd/DnDAcceptanceTest/DnDAcceptanceTest.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Frame; +import java.awt.Panel; + +/* + * @test + * @bug 4166541 4225247 4297663 + * @summary Tests Basic DnD functionality + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual DnDAcceptanceTest + */ + +public class DnDAcceptanceTest { + private static final String INSTRUCTIONS = """ + When test runs a Frame which contains a yellow button labeled + "Drag ME!" and a RED Panel will appear. + + Click on the button and drag to the red panel. + When the mouse enters the red panel + during the drag the panel should turn yellow. + + Release the mouse button, panel should turn red again and + a yellow button labeled Drag ME! should appear inside the panel. + You should be able to repeat this operation multiple times. + + If above is true press PASS, else press FAIL. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .columns(38) + .testUI(DnDAcceptanceTest::createUI) + .build() + .awaitAndCheck(); + } + + private static Frame createUI() { + Frame frame = new Frame("DnDAcceptanceTest"); + Panel mainPanel; + Component dragSource, dropTarget; + + frame.setSize(400, 400); + frame.setLayout(new BorderLayout()); + + mainPanel = new Panel(); + mainPanel.setLayout(new BorderLayout()); + + mainPanel.setBackground(Color.BLACK); + + dropTarget = new DnDTarget(Color.RED, Color.YELLOW); + dragSource = new DnDSource("Drag ME!"); + + mainPanel.add(dragSource, "North"); + mainPanel.add(dropTarget, "Center"); + frame.add(mainPanel, BorderLayout.CENTER); + frame.setAlwaysOnTop(true); + return frame; + } +} diff --git a/test/jdk/java/awt/dnd/DnDAcceptanceTest/DnDSource.java b/test/jdk/java/awt/dnd/DnDAcceptanceTest/DnDSource.java new file mode 100644 index 00000000000..a35ccd9ee12 --- /dev/null +++ b/test/jdk/java/awt/dnd/DnDAcceptanceTest/DnDSource.java @@ -0,0 +1,155 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Button; +import java.awt.Color; +import java.awt.Container; +import java.awt.Toolkit; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.Transferable; +import java.awt.datatransfer.UnsupportedFlavorException; +import java.awt.dnd.DnDConstants; +import java.awt.dnd.MouseDragGestureRecognizer; +import java.awt.dnd.DragGestureEvent; +import java.awt.dnd.DragGestureListener; +import java.awt.dnd.DragSource; +import java.awt.dnd.DragSourceDragEvent; +import java.awt.dnd.DragSourceDropEvent; +import java.awt.dnd.DragSourceEvent; +import java.awt.dnd.DragSourceListener; +import java.awt.dnd.InvalidDnDOperationException; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; + +class DnDSource extends Button implements Transferable, + DragGestureListener, + DragSourceListener { + private DataFlavor df; + private transient int dropAction; + + DnDSource(String label) { + super(label); + Toolkit.getDefaultToolkit().createDragGestureRecognizer(MouseDragGestureRecognizer.class, + DragSource.getDefaultDragSource(), + this, DnDConstants.ACTION_COPY, this); + setBackground(Color.yellow); + setForeground(Color.blue); + df = new DataFlavor(DnDSource.class, "DnDSource"); + } + + public void dragGestureRecognized(DragGestureEvent dge) { + System.err.println("starting Drag"); + try { + dge.startDrag(null, this, this); + } catch (InvalidDnDOperationException e) { + e.printStackTrace(); + } + } + + public void dragEnter(DragSourceDragEvent dsde) { + System.err.println("[Source] dragEnter"); + dsde.getDragSourceContext().setCursor(DragSource.DefaultCopyDrop); + } + + public void dragOver(DragSourceDragEvent dsde) { + System.err.println("[Source] dragOver"); + dropAction = dsde.getDropAction(); + System.out.println("dropAction = " + dropAction); + } + + public void dragGestureChanged(DragSourceDragEvent dsde) { + System.err.println("[Source] dragGestureChanged"); + dropAction = dsde.getDropAction(); + System.out.println("dropAction = " + dropAction); + } + + public void dragExit(DragSourceEvent dsde) { + System.err.println("[Source] dragExit"); + dsde.getDragSourceContext().setCursor(null); + } + + public void dragDropEnd(DragSourceDropEvent dsde) { + System.err.println("[Source] dragDropEnd"); + } + + public void dropActionChanged(DragSourceDragEvent dsde) { + System.err.println("[Source] dropActionChanged"); + dropAction = dsde.getDropAction(); + System.out.println("dropAction = " + dropAction); + } + + public DataFlavor[] getTransferDataFlavors() { + return new DataFlavor[] {df}; + } + + public boolean isDataFlavorSupported(DataFlavor sdf) { + return df.equals(sdf); + } + + public Object getTransferData(DataFlavor tdf) throws UnsupportedFlavorException, IOException { + + Object copy = null; + + if (!df.equals(tdf)) { + throw new UnsupportedFlavorException(tdf); + } + Container parent = getParent(); + switch (dropAction) { + case DnDConstants.ACTION_COPY: + try { + copy = this.clone(); + } catch (CloneNotSupportedException e) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + ObjectOutputStream oos = new ObjectOutputStream(baos); + + oos.writeObject(this); + ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); + ObjectInputStream ois = new ObjectInputStream(bais); + try { + copy = ois.readObject(); + } catch (ClassNotFoundException cnfe) { + // do nothing + } + } + + parent.add(this); + return copy; + + case DnDConstants.ACTION_MOVE: + synchronized(this) { + if (parent != null) parent.remove(this); + } + return this; + + case DnDConstants.ACTION_LINK: + return this; + + default: + //throw new IOException("bad operation"); + return this; // workaround for: 4135456 getDropAction() always return 0 + } + } +} diff --git a/test/jdk/java/awt/dnd/DnDAcceptanceTest/DnDTarget.java b/test/jdk/java/awt/dnd/DnDAcceptanceTest/DnDTarget.java new file mode 100644 index 00000000000..d147741f0d2 --- /dev/null +++ b/test/jdk/java/awt/dnd/DnDAcceptanceTest/DnDTarget.java @@ -0,0 +1,115 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Button; +import java.awt.Color; +import java.awt.Panel; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.Transferable; +import java.awt.datatransfer.UnsupportedFlavorException; +import java.awt.dnd.DnDConstants; +import java.awt.dnd.DropTarget; +import java.awt.dnd.DropTargetContext; +import java.awt.dnd.DropTargetDragEvent; +import java.awt.dnd.DropTargetDropEvent; +import java.awt.dnd.DropTargetEvent; +import java.awt.dnd.DropTargetListener; +import java.io.IOException; + +class DnDTarget extends Panel implements DropTargetListener { + Color bgColor; + Color htColor; + + DnDTarget(Color bgColor, Color htColor) { + super(); + this.bgColor = bgColor; + this.htColor = htColor; + setBackground(bgColor); + setDropTarget(new DropTarget(this, this)); + } + + public void dragEnter(DropTargetDragEvent e) { + System.err.println("[Target] dragEnter"); + e.acceptDrag(DnDConstants.ACTION_COPY); + setBackground(htColor); + repaint(); + } + + public void dragOver(DropTargetDragEvent e) { + System.err.println("[Target] dragOver"); + e.acceptDrag(DnDConstants.ACTION_COPY); + } + + public void dragExit(DropTargetEvent e) { + System.err.println("[Target] dragExit"); + setBackground(bgColor); + repaint(); + } + + public void drop(DropTargetDropEvent dtde) { + System.err.println("[Target] drop"); + DropTargetContext dtc = dtde.getDropTargetContext(); + + if ((dtde.getSourceActions() & DnDConstants.ACTION_COPY) != 0) { + dtde.acceptDrop(DnDConstants.ACTION_COPY); + } else { + dtde.rejectDrop(); + return; + } + + DataFlavor[] dfs = dtde.getCurrentDataFlavors(); + if (dfs != null && dfs.length >= 1) { + Transferable transfer = dtde.getTransferable(); + Object obj; + try { + obj = transfer.getTransferData(dfs[0]); + } catch (IOException | UnsupportedFlavorException ex) { + System.err.println(ex.getMessage()); + dtc.dropComplete(false); + return; + } + + if (obj != null) { + Button button; + try { + button = (Button) obj; + } catch (Exception e) { + System.err.println(e.getMessage()); + dtc.dropComplete(false); + return; + } + add(button); + repaint(); + } + } + setBackground(bgColor); + invalidate(); + validate(); + repaint(); + dtc.dropComplete(true); + } + + public void dropActionChanged(DropTargetDragEvent e) { + System.err.println("[Target] dropActionChanged"); + } +} diff --git a/test/jdk/java/awt/dnd/DnDClipboardDeadlockTest.java b/test/jdk/java/awt/dnd/DnDClipboardDeadlockTest.java new file mode 100644 index 00000000000..ab2bff8ecc5 --- /dev/null +++ b/test/jdk/java/awt/dnd/DnDClipboardDeadlockTest.java @@ -0,0 +1,441 @@ +/* + * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 4388802 + * @summary tests that clipboard operations during drag-and-drop don't deadlock + * @key headful + * @run main DnDClipboardDeadlockTest + */ + +import java.awt.AWTEvent; +import java.awt.AWTException; +import java.awt.Button; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.GridLayout; +import java.awt.List; +import java.awt.Panel; +import java.awt.Point; +import java.awt.Robot; +import java.awt.Toolkit; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.StringSelection; +import java.awt.datatransfer.Transferable; +import java.awt.dnd.DnDConstants; +import java.awt.dnd.DragGestureEvent; +import java.awt.dnd.DragGestureListener; +import java.awt.dnd.DragSource; +import java.awt.dnd.DragSourceDragEvent; +import java.awt.dnd.DragSourceDropEvent; +import java.awt.dnd.DragSourceEvent; +import java.awt.dnd.DragSourceListener; +import java.awt.dnd.DropTarget; +import java.awt.dnd.DropTargetContext; +import java.awt.dnd.DropTargetDragEvent; +import java.awt.dnd.DropTargetDropEvent; +import java.awt.dnd.DropTargetEvent; +import java.awt.dnd.DropTargetListener; +import java.awt.event.AWTEventListener; +import java.awt.event.InputEvent; +import java.awt.event.KeyEvent; +import java.awt.event.MouseEvent; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.Serializable; + +public class DnDClipboardDeadlockTest { + + public static final int CODE_NOT_RETURNED = -1; + public static final int CODE_OK = 0; + public static final int CODE_FAILURE = 1; + + private int returnCode = CODE_NOT_RETURNED; + + final Frame frame = new Frame(); + Robot robot = null; + Panel panel = null; + + public static void main(String[] args) throws Exception { + DnDClipboardDeadlockTest test = new DnDClipboardDeadlockTest(); + if (args.length == 4) { + test.run(args); + } else { + test.start(); + } + } + + public void run(String[] args) throws InterruptedException, AWTException { + try { + if (args.length != 4) { + throw new RuntimeException("Incorrect command line arguments."); + } + + int x = Integer.parseInt(args[0]); + int y = Integer.parseInt(args[1]); + int w = Integer.parseInt(args[2]); + int h = Integer.parseInt(args[3]); + + Transferable t = new StringSelection("TEXT"); + panel = new DragSourcePanel(t); + + frame.setTitle("DragSource frame"); + frame.setLocation(300, 200); + frame.add(panel); + frame.pack(); + frame.setVisible(true); + + Util.waitForInit(); + + Point sourcePoint = panel.getLocationOnScreen(); + Dimension d = panel.getSize(); + sourcePoint.translate(d.width / 2, d.height / 2); + + Point targetPoint = new Point(x + w / 2, y + h / 2); + + robot = new Robot(); + + if (!Util.pointInComponent(robot, sourcePoint, panel)) { + throw new RuntimeException("WARNING: Cannot locate source panel"); + } + + robot.mouseMove(sourcePoint.x, sourcePoint.y); + robot.keyPress(KeyEvent.VK_CONTROL); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + for (; !sourcePoint.equals(targetPoint); + sourcePoint.translate(sign(targetPoint.x - sourcePoint.x), + sign(targetPoint.y - sourcePoint.y))) { + robot.mouseMove(sourcePoint.x, sourcePoint.y); + Thread.sleep(10); + } + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.keyRelease(KeyEvent.VK_CONTROL); + if (frame != null) { + frame.dispose(); + } + + } catch (Throwable e) { + e.printStackTrace(); + throw new RuntimeException(e); + } + } // run() + + public static int sign(int n) { + return n < 0 ? -1 : n == 0 ? 0 : 1; + } + + public void start() { + panel = new DropTargetPanel(); + + frame.setTitle("DropTarget frame"); + frame.setLocation(10, 200); + frame.add(panel); + + frame.pack(); + frame.setVisible(true); + + try { + Util.waitForInit(); + + Point p = panel.getLocationOnScreen(); + Dimension d = panel.getSize(); + + try { + Robot robot = new Robot(); + Point center = new Point(p); + center.translate(d.width / 2, d.height / 2); + if (!Util.pointInComponent(robot, center, panel)) { + System.err.println("WARNING: Cannot locate target panel"); + return; + } + } catch (AWTException awte) { + awte.printStackTrace(); + return; + } + + String javaPath = System.getProperty("java.home", ""); + String command = javaPath + File.separator + "bin" + + File.separator + "java -cp " + + System.getProperty("java.class.path", ".") + + " DnDClipboardDeadlockTest " + + p.x + " " + p.y + " " + d.width + " " + d.height; + + Process process = Runtime.getRuntime().exec(command); + returnCode = process.waitFor(); + + InputStream errorStream = process.getErrorStream(); + int count = errorStream.available(); + if (count > 0) { + byte[] b = new byte[count]; + errorStream.read(b); + System.err.println("========= Child VM System.err ========"); + System.err.print(new String(b)); + System.err.println("======================================"); + } + + } catch (Throwable e) { + e.printStackTrace(); + } + switch (returnCode) { + case CODE_NOT_RETURNED: + System.err.println("Child VM: failed to start"); + break; + case CODE_OK: + System.err.println("Child VM: normal termination"); + break; + case CODE_FAILURE: + System.err.println("Child VM: abnormal termination"); + break; + } + if (returnCode != CODE_OK) { + throw new RuntimeException("The test failed."); + } + if (frame != null) { + frame.dispose(); + } + } // start() +} // class DnDClipboardDeadlockTest + +class Util implements AWTEventListener { + private static final Toolkit tk = Toolkit.getDefaultToolkit(); + private static final Object SYNC_LOCK = new Object(); + private Component clickedComponent = null; + private static final int PAINT_TIMEOUT = 10000; + private static final int MOUSE_RELEASE_TIMEOUT = 10000; + private static final Util util = new Util(); + + static { + tk.addAWTEventListener(util, 0xFFFFFFFF); + } + + private void reset() { + clickedComponent = null; + } + + public void eventDispatched(AWTEvent e) { + if (e.getID() == MouseEvent.MOUSE_RELEASED) { + clickedComponent = (Component) e.getSource(); + synchronized (SYNC_LOCK) { + SYNC_LOCK.notifyAll(); + } + } + } + + public static boolean pointInComponent(Robot robot, Point p, Component comp) + throws InterruptedException { + return util.isPointInComponent(robot, p, comp); + } + + private boolean isPointInComponent(Robot robot, Point p, Component comp) + throws InterruptedException { + tk.sync(); + robot.waitForIdle(); + reset(); + robot.mouseMove(p.x, p.y); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + synchronized (SYNC_LOCK) { + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + SYNC_LOCK.wait(MOUSE_RELEASE_TIMEOUT); + } + + Component c = clickedComponent; + + while (c != null && c != comp) { + c = c.getParent(); + } + + return c == comp; + } + + public static void waitForInit() throws InterruptedException { + final Frame f = new Frame() { + public void paint(Graphics g) { + dispose(); + synchronized (SYNC_LOCK) { + SYNC_LOCK.notifyAll(); + } + } + }; + f.setBounds(600, 400, 200, 200); + synchronized (SYNC_LOCK) { + f.setVisible(true); + SYNC_LOCK.wait(PAINT_TIMEOUT); + } + tk.sync(); + } +} + +class DragSourceButton extends Button implements Serializable, + DragGestureListener, + DragSourceListener { + static final Clipboard systemClipboard = + Toolkit.getDefaultToolkit().getSystemClipboard(); + final Transferable transferable; + + public DragSourceButton(Transferable t) { + super("DragSourceButton"); + + this.transferable = t; + DragSource ds = DragSource.getDefaultDragSource(); + ds.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_COPY, + this); + } + + public void dragGestureRecognized(DragGestureEvent dge) { + dge.startDrag(null, transferable, this); + } + + public void dragEnter(DragSourceDragEvent dsde) { + } + + public void dragExit(DragSourceEvent dse) { + } + + public void dragOver(DragSourceDragEvent dsde) { + try { + Transferable t = systemClipboard.getContents(null); + if (t.isDataFlavorSupported(DataFlavor.stringFlavor)) { + String str = (String) t.getTransferData(DataFlavor.stringFlavor); + } + systemClipboard.setContents(new StringSelection("SOURCE"), null); + } catch (IOException ioe) { + ioe.printStackTrace(); + if (!ioe.getMessage().equals("Owner failed to convert data")) { + throw new RuntimeException("Owner failed to convert data"); + } + } catch (IllegalStateException e) { + // IllegalStateExceptions do not indicate a bug in this case. + // They result from concurrent modification of system clipboard + // contents by the parent and child processes. + // These exceptions are numerous, so we avoid dumping their + // backtraces to prevent blocking child process io, which + // causes test failure on timeout. + } catch (Exception e) { + e.printStackTrace(); + } + } + + public void dragDropEnd(DragSourceDropEvent dsde) { + System.exit(DnDClipboardDeadlockTest.CODE_OK); + } + + public void dropActionChanged(DragSourceDragEvent dsde) { + } +} + +class DragSourcePanel extends Panel { + + final Dimension preferredDimension = new Dimension(200, 200); + + public DragSourcePanel(Transferable t) { + setLayout(new GridLayout(1, 1)); + add(new DragSourceButton(t)); + } + + public Dimension getPreferredSize() { + return preferredDimension; + } +} + +class DropTargetPanel extends Panel implements DropTargetListener { + + static final Clipboard systemClipboard = + Toolkit.getDefaultToolkit().getSystemClipboard(); + final Dimension preferredDimension = new Dimension(200, 200); + + public DropTargetPanel() { + setBackground(Color.green); + setDropTarget(new DropTarget(this, this)); + setLayout(new GridLayout(1, 1)); + } + + public Dimension getPreferredSize() { + return preferredDimension; + } + + public void dragEnter(DropTargetDragEvent dtde) { + dtde.acceptDrag(DnDConstants.ACTION_COPY); + } + + public void dragExit(DropTargetEvent dte) { + } + + public void dragOver(DropTargetDragEvent dtde) { + dtde.acceptDrag(DnDConstants.ACTION_COPY); + try { + Transferable t = systemClipboard.getContents(null); + if (t.isDataFlavorSupported(DataFlavor.stringFlavor)) { + String str = (String) t.getTransferData(DataFlavor.stringFlavor); + } + systemClipboard.setContents(new StringSelection("TARGET"), null); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public void drop(DropTargetDropEvent dtde) { + DropTargetContext dtc = dtde.getDropTargetContext(); + + if ((dtde.getSourceActions() & DnDConstants.ACTION_COPY) != 0) { + dtde.acceptDrop(DnDConstants.ACTION_COPY); + } else { + dtde.rejectDrop(); + return; + } + + removeAll(); + final List list = new List(); + add(list); + + Transferable t = dtde.getTransferable(); + DataFlavor[] dfs = t.getTransferDataFlavors(); + + for (int i = 0; i < dfs.length; i++) { + + DataFlavor flavor = dfs[i]; + String str = null; + + if (DataFlavor.stringFlavor.equals(flavor)) { + try { + str = (String) t.getTransferData(flavor); + } catch (Exception e) { + e.printStackTrace(); + } + } + + list.add(str + ":" + flavor.getMimeType()); + } + + dtc.dropComplete(true); + validate(); + } + + public void dropActionChanged(DropTargetDragEvent dtde) { + } +} diff --git a/test/jdk/java/awt/dnd/DnDCursorCrashTest.java b/test/jdk/java/awt/dnd/DnDCursorCrashTest.java new file mode 100644 index 00000000000..7b1f4483ef9 --- /dev/null +++ b/test/jdk/java/awt/dnd/DnDCursorCrashTest.java @@ -0,0 +1,231 @@ +/* + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4343300 + * @summary tests that drag attempt doesn't cause crash when + * custom cursor is used + * @key headful + * @run main DnDCursorCrashTest + */ + +import java.awt.Button; +import java.awt.Component; +import java.awt.Cursor; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.GridLayout; +import java.awt.Panel; +import java.awt.Robot; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.Transferable; +import java.awt.datatransfer.UnsupportedFlavorException; +import java.awt.dnd.DnDConstants; +import java.awt.dnd.DragGestureEvent; +import java.awt.dnd.DragGestureListener; +import java.awt.dnd.DragSource; +import java.awt.dnd.DragSourceDragEvent; +import java.awt.dnd.DragSourceDropEvent; +import java.awt.dnd.DragSourceEvent; +import java.awt.dnd.DragSourceListener; +import java.awt.dnd.DropTarget; +import java.awt.dnd.DropTargetContext; +import java.awt.dnd.DropTargetDragEvent; +import java.awt.dnd.DropTargetDropEvent; +import java.awt.dnd.DropTargetEvent; +import java.awt.dnd.DropTargetListener; +import java.awt.event.InputEvent; +import java.awt.event.KeyEvent; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; + +public class DnDCursorCrashTest { + static final Frame frame = new Frame(); + static final DragSourcePanel dragSourcePanel = new DragSourcePanel(); + static final DropTargetPanel dropTargetPanel = new DropTargetPanel(); + + public static void main(String[] args) throws Exception { + try { + EventQueue.invokeAndWait(() -> { + frame.setTitle("DnD Cursor Test Frame"); + frame.setLocation(200, 200); + frame.setLayout(new GridLayout(2, 1)); + frame.add(dragSourcePanel); + frame.add(dropTargetPanel); + frame.pack(); + frame.setVisible(true); + }); + + Robot robot = new Robot(); + robot.delay(1000); + robot.mouseMove(250, 250); + robot.keyPress(KeyEvent.VK_CONTROL); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + for (int y = 250; y < 350; y += 5) { + robot.mouseMove(250, y); + robot.delay(100); + } + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.keyRelease(KeyEvent.VK_CONTROL); + } finally { + if (frame != null) { + EventQueue.invokeAndWait(() -> frame.dispose()); + } + } + } +} + +class DragSourceButton extends Button implements Serializable, + Transferable, + DragGestureListener, + DragSourceListener { + private final DataFlavor dataflavor = + new DataFlavor(Button.class, "DragSourceButton"); + + public DragSourceButton() { + this("DragSourceButton"); + } + + public DragSourceButton(String str) { + super(str); + + DragSource ds = DragSource.getDefaultDragSource(); + ds.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_COPY, + this); + } + + public void dragGestureRecognized(DragGestureEvent dge) { + dge.startDrag(new Cursor(Cursor.HAND_CURSOR), this, this); + } + + public void dragEnter(DragSourceDragEvent dsde) {} + + public void dragExit(DragSourceEvent dse) {} + + public void dragOver(DragSourceDragEvent dsde) {} + + public void dragDropEnd(DragSourceDropEvent dsde) {} + + public void dropActionChanged(DragSourceDragEvent dsde) {} + + public Object getTransferData(DataFlavor flavor) + throws UnsupportedFlavorException, IOException { + + if (!isDataFlavorSupported(flavor)) { + throw new UnsupportedFlavorException(flavor); + } + + Object retObj; + + ByteArrayOutputStream baoStream = new ByteArrayOutputStream(); + ObjectOutputStream ooStream = new ObjectOutputStream(baoStream); + ooStream.writeObject(this); + + ByteArrayInputStream baiStream = new ByteArrayInputStream(baoStream.toByteArray()); + ObjectInputStream ois = new ObjectInputStream(baiStream); + try { + retObj = ois.readObject(); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + throw new RuntimeException(e.toString()); + } + + return retObj; + } + + public DataFlavor[] getTransferDataFlavors() { + return new DataFlavor[] { dataflavor }; + } + + public boolean isDataFlavorSupported(DataFlavor dflavor) { + return dataflavor.equals(dflavor); + } +} + +class DragSourcePanel extends Panel { + + final Dimension preferredDimension = new Dimension(200, 100); + + public DragSourcePanel() { + setLayout(new GridLayout(1, 1)); + add(new DragSourceButton()); + } + + public Dimension getPreferredSize() { + return preferredDimension; + } +} + +class DropTargetPanel extends Panel implements DropTargetListener { + + final Dimension preferredDimension = new Dimension(200, 100); + + public DropTargetPanel() { + setDropTarget(new DropTarget(this, this)); + } + + public Dimension getPreferredSize() { + return preferredDimension; + } + + public void dragEnter(DropTargetDragEvent dtde) {} + + public void dragExit(DropTargetEvent dte) {} + + public void dragOver(DropTargetDragEvent dtde) {} + + public void dropActionChanged(DropTargetDragEvent dtde) {} + + public void drop(DropTargetDropEvent dtde) { + DropTargetContext dtc = dtde.getDropTargetContext(); + + if ((dtde.getSourceActions() & DnDConstants.ACTION_COPY) != 0) { + dtde.acceptDrop(DnDConstants.ACTION_COPY); + } else { + dtde.rejectDrop(); + } + + DataFlavor[] dfs = dtde.getCurrentDataFlavors(); + Component comp = null; + + if (dfs != null && dfs.length >= 1) { + Transferable transfer = dtde.getTransferable(); + + try { + comp = (Component)transfer.getTransferData(dfs[0]); + } catch (Throwable e) { + e.printStackTrace(); + dtc.dropComplete(false); + } + } + dtc.dropComplete(true); + + add(comp); + } +} diff --git a/test/jdk/java/awt/dnd/DnDHTMLToOutlookTest/DnDHTMLToOutlookTest.java b/test/jdk/java/awt/dnd/DnDHTMLToOutlookTest/DnDHTMLToOutlookTest.java new file mode 100644 index 00000000000..8a39ce53705 --- /dev/null +++ b/test/jdk/java/awt/dnd/DnDHTMLToOutlookTest/DnDHTMLToOutlookTest.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Frame; +import java.awt.Panel; + + +/* + * @test + * @bug 6392086 + * @summary Tests dnd to another screen + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual DnDHTMLToOutlookTest + */ + +public class DnDHTMLToOutlookTest { + + private static final String INSTRUCTIONS = """ + The window contains a yellow button. Click on the button + to copy HTML from DnDSource.html file into the clipboard or drag + HTML context. Paste into or drop over the HTML capable editor in + external application such as Outlook, Word. + + When the mouse enters the editor, cursor should change to indicate + that copy operation is about to happen and then release the mouse + button. HTML text without tags should appear inside the document. + + You should be able to repeat this operation multiple times. + If the above is true Press PASS else FAIL. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(DnDHTMLToOutlookTest::createAndShowUI) + .build() + .awaitAndCheck(); + } + + private static Frame createAndShowUI() { + Frame frame = new Frame("DnDHTMLToOutlookTest"); + Panel mainPanel; + Component dragSource; + + mainPanel = new Panel(); + mainPanel.setLayout(new BorderLayout()); + + mainPanel.setBackground(Color.YELLOW); + dragSource = new DnDSource("Drag ME (HTML)!"); + + mainPanel.add(dragSource, BorderLayout.CENTER); + frame.add(mainPanel); + frame.setSize(200, 200); + return frame; + } +} diff --git a/test/jdk/java/awt/dnd/DnDHTMLToOutlookTest/DnDSource.html b/test/jdk/java/awt/dnd/DnDHTMLToOutlookTest/DnDSource.html new file mode 100644 index 00000000000..0f1b9751dec --- /dev/null +++ b/test/jdk/java/awt/dnd/DnDHTMLToOutlookTest/DnDSource.html @@ -0,0 +1,25 @@ + + +

                    DnDHTMLToOutlookTest
                    HTML Drag & Paste problem

                    +

                    if you see the bold header above without HTML tags and without StartHTML as the first word, press PASS

                    diff --git a/test/jdk/java/awt/dnd/DnDHTMLToOutlookTest/DnDSource.java b/test/jdk/java/awt/dnd/DnDHTMLToOutlookTest/DnDSource.java new file mode 100644 index 00000000000..58f17e9415c --- /dev/null +++ b/test/jdk/java/awt/dnd/DnDHTMLToOutlookTest/DnDSource.java @@ -0,0 +1,142 @@ +/* + * Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Button; +import java.awt.Color; +import java.awt.Toolkit; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.Transferable; +import java.awt.datatransfer.UnsupportedFlavorException; +import java.awt.dnd.DnDConstants; +import java.awt.dnd.DragGestureEvent; +import java.awt.dnd.DragGestureListener; +import java.awt.dnd.DragSource; +import java.awt.dnd.DragSourceDragEvent; +import java.awt.dnd.DragSourceDropEvent; +import java.awt.dnd.DragSourceEvent; +import java.awt.dnd.DragSourceListener; +import java.awt.dnd.InvalidDnDOperationException; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Paths; + +class DnDSource extends Button implements Transferable, + DragGestureListener, + DragSourceListener { + private DataFlavor m_df; + private transient int m_dropAction; + private ByteArrayInputStream m_data = null; + + DnDSource(String label) { + super(label); + setBackground(Color.yellow); + setForeground(Color.blue); + setSize(200, 120); + + try { + m_df = new DataFlavor("text/html; Class=" + InputStream.class.getName() + "; charset=UTF-8"); + } catch (Exception e) { + e.printStackTrace(); + } + + DragSource dragSource = new DragSource(); + dragSource.createDefaultDragGestureRecognizer( + this, + DnDConstants.ACTION_COPY_OR_MOVE, + this + ); + dragSource.addDragSourceListener(this); + + String dir = System.getProperty("test.src", "."); + + try { + m_data = new ByteArrayInputStream(Files.readAllBytes( + Paths.get(dir, "DnDSource.html"))); + m_data.mark(m_data.available()); + addActionListener( + new ActionListener(){ + public void actionPerformed(ActionEvent ae){ + Toolkit.getDefaultToolkit().getSystemClipboard() + .setContents( DnDSource.this, null); + } + } + ); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public void dragGestureRecognized(DragGestureEvent dge) { + System.err.println("starting Drag"); + try { + dge.startDrag(null, this, this); + } catch (InvalidDnDOperationException e) { + e.printStackTrace(); + } + } + + public void dragEnter(DragSourceDragEvent dsde) { + System.err.println("[Source] dragEnter"); + } + + public void dragOver(DragSourceDragEvent dsde) { + System.err.println("[Source] dragOver"); + m_dropAction = dsde.getDropAction(); + System.out.println("m_dropAction = " + m_dropAction); + } + + public void dragExit(DragSourceEvent dsde) { + System.err.println("[Source] dragExit"); + } + + public void dragDropEnd(DragSourceDropEvent dsde) { + System.err.println("[Source] dragDropEnd"); + } + + public void dropActionChanged(DragSourceDragEvent dsde) { + System.err.println("[Source] dropActionChanged"); + m_dropAction = dsde.getDropAction(); + System.out.println("m_dropAction = " + m_dropAction); + } + + public DataFlavor[] getTransferDataFlavors() { + return new DataFlavor[] {m_df}; + } + + public boolean isDataFlavorSupported(DataFlavor sdf) { + System.err.println("[Source] isDataFlavorSupported" + m_df.equals(sdf)); + return m_df.equals(sdf); + } + + public Object getTransferData(DataFlavor tdf) throws UnsupportedFlavorException { + if (!m_df.equals(tdf)) { + throw new UnsupportedFlavorException(tdf); + } + System.err.println("[Source] Ok"); + m_data.reset(); + return m_data; + } +} diff --git a/test/jdk/java/awt/dnd/DnDRemoveFocusOwnerCrashTest.java b/test/jdk/java/awt/dnd/DnDRemoveFocusOwnerCrashTest.java new file mode 100644 index 00000000000..1fc7c2e82b8 --- /dev/null +++ b/test/jdk/java/awt/dnd/DnDRemoveFocusOwnerCrashTest.java @@ -0,0 +1,233 @@ +/* + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4357905 + * @summary Tests that removal of the focus owner component during + * drop processing doesn't cause crash + * @key headful + * @run main DnDRemoveFocusOwnerCrashTest + */ + +import java.awt.Button; +import java.awt.Component; +import java.awt.EventQueue; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.Panel; +import java.awt.Point; +import java.awt.Robot; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.Transferable; +import java.awt.datatransfer.UnsupportedFlavorException; +import java.awt.dnd.DnDConstants; +import java.awt.dnd.DragGestureEvent; +import java.awt.dnd.DragGestureListener; +import java.awt.dnd.DragSource; +import java.awt.dnd.DragSourceDragEvent; +import java.awt.dnd.DragSourceDropEvent; +import java.awt.dnd.DragSourceEvent; +import java.awt.dnd.DragSourceListener; +import java.awt.dnd.DropTarget; +import java.awt.dnd.DropTargetContext; +import java.awt.dnd.DropTargetDragEvent; +import java.awt.dnd.DropTargetDropEvent; +import java.awt.dnd.DropTargetEvent; +import java.awt.dnd.DropTargetListener; +import java.awt.event.InputEvent; +import java.awt.event.KeyEvent; +import java.io.Serializable; + +public class DnDRemoveFocusOwnerCrashTest { + public static final int FRAME_ACTIVATION_TIMEOUT = 1000; + public static Frame frame; + public static Robot robot; + public static DragSourceButton dragSourceButton; + static volatile Point p; + + public static void main(String[] args) throws Exception { + try { + robot = new Robot(); + robot.setAutoWaitForIdle(true); + robot.delay(FRAME_ACTIVATION_TIMEOUT); + EventQueue.invokeAndWait(() -> { + frame = new Frame(); + dragSourceButton = new DragSourceButton(); + DropTargetPanel dropTargetPanel = + new DropTargetPanel(dragSourceButton); + frame.add(new Button("Test")); + frame.setTitle("Remove Focus Owner Test Frame"); + frame.setLocation(200, 200); + frame.add(dropTargetPanel); + frame.pack(); + frame.setVisible(true); + }); + + robot.waitForIdle(); + robot.delay(FRAME_ACTIVATION_TIMEOUT); + + EventQueue.invokeAndWait(() -> { + p = dragSourceButton.getLocationOnScreen(); + p.translate(10, 10); + }); + + robot.delay(FRAME_ACTIVATION_TIMEOUT); + robot.mouseMove(p.x, p.y); + robot.delay(FRAME_ACTIVATION_TIMEOUT); + robot.keyPress(KeyEvent.VK_CONTROL); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + for (int dy = 0; dy < 50; dy++) { + robot.mouseMove(p.x, p.y + dy); + robot.delay(10); + } + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.keyRelease(KeyEvent.VK_CONTROL); + } finally { + EventQueue.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } + + static class DragSourceButton extends Button implements Serializable, + Transferable, + DragGestureListener, + DragSourceListener { + + private static DataFlavor dataflavor; + + static { + try { + dataflavor = + new DataFlavor(DataFlavor.javaJVMLocalObjectMimeType); + dataflavor.setHumanPresentableName("Local Object Flavor"); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + throw new ExceptionInInitializerError(); + } + } + + public DragSourceButton() { + this("DragSourceButton"); + } + + public DragSourceButton(String str) { + super(str); + + DragSource ds = DragSource.getDefaultDragSource(); + ds.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_COPY, + this); + } + + public void dragGestureRecognized(DragGestureEvent dge) { + dge.startDrag(null, this, this); + } + + public void dragEnter(DragSourceDragEvent dsde) { + } + + public void dragExit(DragSourceEvent dse) { + } + + public void dragOver(DragSourceDragEvent dsde) { + } + + public void dragDropEnd(DragSourceDropEvent dsde) { + } + + public void dropActionChanged(DragSourceDragEvent dsde) { + } + + public Object getTransferData(DataFlavor flavor) + throws UnsupportedFlavorException { + + if (!isDataFlavorSupported(flavor)) { + throw new UnsupportedFlavorException(flavor); + } + + return this; + } + + public DataFlavor[] getTransferDataFlavors() { + return new DataFlavor[]{dataflavor}; + } + + public boolean isDataFlavorSupported(DataFlavor dflavor) { + return dataflavor.equals(dflavor); + } + } + + static class DropTargetPanel extends Panel implements DropTargetListener { + + public DropTargetPanel(DragSourceButton button) { + setLayout(new FlowLayout(FlowLayout.CENTER, 50, 50)); + add(button); + setDropTarget(new DropTarget(this, this)); + } + + public void dragEnter(DropTargetDragEvent dtde) { + } + + public void dragExit(DropTargetEvent dte) { + } + + public void dragOver(DropTargetDragEvent dtde) { + } + + public void dropActionChanged(DropTargetDragEvent dtde) { + } + + public void drop(DropTargetDropEvent dtde) { + removeAll(); + + DropTargetContext dtc = dtde.getDropTargetContext(); + + if ((dtde.getSourceActions() & DnDConstants.ACTION_COPY) != 0) { + dtde.acceptDrop(DnDConstants.ACTION_COPY); + } else { + dtde.rejectDrop(); + } + + DataFlavor[] dfs = dtde.getCurrentDataFlavors(); + Component comp = null; + + if (dfs != null && dfs.length >= 1) { + Transferable transfer = dtde.getTransferable(); + + try { + comp = (Component) transfer.getTransferData(dfs[0]); + } catch (Throwable e) { + e.printStackTrace(); + dtc.dropComplete(false); + } + } + dtc.dropComplete(true); + + add(comp); + validate(); + } + } +} diff --git a/test/jdk/java/awt/dnd/DnDToWordpadTest.java b/test/jdk/java/awt/dnd/DnDToWordpadTest.java new file mode 100644 index 00000000000..181a6ee873a --- /dev/null +++ b/test/jdk/java/awt/dnd/DnDToWordpadTest.java @@ -0,0 +1,237 @@ +/* + * Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6362095 + * @summary Tests basic DnD functionality to a wordpad + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual DnDToWordpadTest + */ + +import java.awt.Button; +import java.awt.Color; +import java.awt.Component; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Image; +import java.awt.Panel; +import java.awt.Toolkit; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.Transferable; +import java.awt.datatransfer.UnsupportedFlavorException; +import java.awt.dnd.DnDConstants; +import java.awt.dnd.DragGestureEvent; +import java.awt.dnd.DragGestureListener; +import java.awt.dnd.DragSource; +import java.awt.dnd.DragSourceDragEvent; +import java.awt.dnd.DragSourceDropEvent; +import java.awt.dnd.DragSourceEvent; +import java.awt.dnd.DragSourceListener; +import java.awt.dnd.InvalidDnDOperationException; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; +import java.nio.file.Path; + +import javax.imageio.ImageIO; + +import static java.awt.image.BufferedImage.TYPE_INT_ARGB; + +public class DnDToWordpadTest { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + The test window contains a yellow button. Click on the button + to copy image into the clipboard or drag the image. + Paste or drop the image over Wordpad (when the mouse + enters the Wordpad during the drag, the application + should change the cursor to indicate that a copy operation is + about to happen; release the mouse button). + An image of a red rectangle should appear inside the document. + You should be able to repeat this operation multiple times. + Please, click "Pass" if above conditions are true, + otherwise click "Fail". + """; + + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .columns(35) + .testUI(DnDToWordpadTest::createUI) + .build() + .awaitAndCheck(); + } + + public static Frame createUI() { + Frame f = new Frame("DnD To WordPad Test"); + Panel mainPanel; + Component dragSource; + + mainPanel = new Panel(); + mainPanel.setLayout(null); + + mainPanel.setBackground(Color.black); + try { + dragSource = new DnDSource("Drag ME!"); + mainPanel.add(dragSource); + f.add(mainPanel); + } catch (IOException e) { + e.printStackTrace(); + } + + f.setSize(200, 200); + return f; + } +} + +class DnDSource extends Button implements Transferable, + DragGestureListener, + DragSourceListener { + private DataFlavor m_df; + private transient int m_dropAction; + private Image m_img; + + DnDSource(String label) throws IOException { + super(label); + + setBackground(Color.yellow); + setForeground(Color.blue); + setSize(200, 120); + + m_df = DataFlavor.imageFlavor; + + DragSource dragSource = new DragSource(); + dragSource.createDefaultDragGestureRecognizer( + this, + DnDConstants.ACTION_COPY_OR_MOVE, + this + ); + dragSource.addDragSourceListener(this); + + // Create test gif image to drag + Path p = Path.of(System.getProperty("test.classes", ".")); + BufferedImage bImg = new BufferedImage(79, 109, TYPE_INT_ARGB); + Graphics2D cg = bImg.createGraphics(); + cg.setColor(Color.RED); + cg.fillRect(0, 0, 79, 109); + ImageIO.write(bImg, "png", new File(p + java.io.File.separator + + "DnDSource_Red.gif")); + + m_img = Toolkit.getDefaultToolkit() + .getImage(System.getProperty("test.classes", ".") + + java.io.File.separator + "DnDSource_Red.gif"); + + addActionListener( + ae -> Toolkit.getDefaultToolkit().getSystemClipboard().setContents( + (Transferable) DnDSource.this, + null + ) + ); + } + + public void paint(Graphics g) { + g.drawImage(m_img, 10, 10, null); + } + + /** + * a Drag gesture has been recognized + */ + + public void dragGestureRecognized(DragGestureEvent dge) { + System.err.println("starting Drag"); + try { + dge.startDrag(null, this, this); + } catch (InvalidDnDOperationException e) { + e.printStackTrace(); + } + } + + /** + * as the hotspot enters a platform dependent drop site + */ + + public void dragEnter(DragSourceDragEvent dsde) { + System.err.println("[Source] dragEnter"); + } + + /** + * as the hotspot moves over a platform dependent drop site + */ + + public void dragOver(DragSourceDragEvent dsde) { + System.err.println("[Source] dragOver"); + m_dropAction = dsde.getDropAction(); + System.out.println("m_dropAction = " + m_dropAction); + } + + /** + * as the operation changes + */ + + public void dragGestureChanged(DragSourceDragEvent dsde) { + System.err.println("[Source] dragGestureChanged"); + m_dropAction = dsde.getDropAction(); + System.out.println("m_dropAction = " + m_dropAction); + } + + /** + * as the hotspot exits a platform dependent drop site + */ + + public void dragExit(DragSourceEvent dsde) { + System.err.println("[Source] dragExit"); + } + + /** + * as the operation completes + */ + + public void dragDropEnd(DragSourceDropEvent dsde) { + System.err.println("[Source] dragDropEnd"); + } + + public void dropActionChanged(DragSourceDragEvent dsde) { + System.err.println("[Source] dropActionChanged"); + m_dropAction = dsde.getDropAction(); + System.out.println("m_dropAction = " + m_dropAction); + } + + public DataFlavor[] getTransferDataFlavors() { + return new DataFlavor[]{m_df}; + } + + public boolean isDataFlavorSupported(DataFlavor sdf) { + System.err.println("[Source] isDataFlavorSupported" + m_df.equals(sdf)); + return m_df.equals(sdf); + } + + public Object getTransferData(DataFlavor tdf) throws UnsupportedFlavorException { + if (!m_df.equals(tdf)) { + throw new UnsupportedFlavorException(tdf); + } + System.err.println("[Source] Ok"); + return m_img; + } +} diff --git a/test/jdk/java/awt/dnd/DragExitBeforeDropTest.java b/test/jdk/java/awt/dnd/DragExitBeforeDropTest.java new file mode 100644 index 00000000000..2ef778a18ba --- /dev/null +++ b/test/jdk/java/awt/dnd/DragExitBeforeDropTest.java @@ -0,0 +1,257 @@ +/* + * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 java.awt.Button; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.GridLayout; +import java.awt.Panel; +import java.awt.Point; +import java.awt.Robot; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.Transferable; +import java.awt.datatransfer.UnsupportedFlavorException; +import java.awt.dnd.DnDConstants; +import java.awt.dnd.DragGestureEvent; +import java.awt.dnd.DragGestureListener; +import java.awt.dnd.DragSource; +import java.awt.dnd.DragSourceDragEvent; +import java.awt.dnd.DragSourceDropEvent; +import java.awt.dnd.DragSourceEvent; +import java.awt.dnd.DragSourceListener; +import java.awt.dnd.DropTarget; +import java.awt.dnd.DropTargetContext; +import java.awt.dnd.DropTargetDragEvent; +import java.awt.dnd.DropTargetDropEvent; +import java.awt.dnd.DropTargetEvent; +import java.awt.dnd.DropTargetListener; +import java.awt.event.InputEvent; +import java.awt.event.KeyEvent; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; + +/* + * @test + * @bug 4395290 + * @key headful + * @summary tests that dragExit() is not called before drop() + */ + +public class DragExitBeforeDropTest { + private static Frame frame; + private static final DragSourceButton dragSourceButton = new DragSourceButton(); + private static final DropTargetPanel dropTargetPanel = new DropTargetPanel(); + private static volatile Point srcPoint; + private static volatile Point dstPoint; + + public static void main(String[] args) throws Exception { + try { + Robot robot = new Robot(); + EventQueue.invokeAndWait(DragExitBeforeDropTest::createAndShowUI); + robot.waitForIdle(); + robot.delay(1000); + + EventQueue.invokeAndWait(() -> { + Point p = dragSourceButton.getLocationOnScreen(); + Dimension d = dragSourceButton.getSize(); + p.translate(d.width / 2, d.height / 2); + srcPoint = p; + + p = dropTargetPanel.getLocationOnScreen(); + d = dropTargetPanel.getSize(); + p.translate(d.width / 2, d.height / 2); + dstPoint = p; + }); + + robot.mouseMove(srcPoint.x, srcPoint.y); + robot.keyPress(KeyEvent.VK_CONTROL); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + for (; !srcPoint.equals(dstPoint); + srcPoint.translate(sign(dstPoint.x - srcPoint.x), + sign(dstPoint.y - srcPoint.y))) { + robot.mouseMove(srcPoint.x, srcPoint.y); + robot.delay(10); + } + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.keyRelease(KeyEvent.VK_CONTROL); + robot.waitForIdle(); + robot.delay(1000); + + if (!dropTargetPanel.getStatus()) { + throw new RuntimeException("The test failed: dragExit()" + + " is called before drop()"); + } + } finally { + EventQueue.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } + + private static void createAndShowUI() { + frame = new Frame("DragExitBeforeDropTest"); + frame.setLayout(new GridLayout(2, 1)); + frame.add(dragSourceButton); + frame.add(dropTargetPanel); + frame.setLocationRelativeTo(null); + frame.setSize(300, 400); + frame.setVisible(true); + } + + public static int sign(int n) { + return Integer.compare(n, 0); + } + + private static class DragSourceButton extends Button implements Serializable, + Transferable, + DragGestureListener, + DragSourceListener { + private final DataFlavor dataflavor = + new DataFlavor(Button.class, "DragSourceButton"); + + public DragSourceButton() { + this("DragSourceButton"); + } + + public DragSourceButton(String str) { + super(str); + + DragSource ds = DragSource.getDefaultDragSource(); + ds.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_COPY, + this); + } + + public void dragGestureRecognized(DragGestureEvent dge) { + dge.startDrag(null, this, this); + } + + public void dragEnter(DragSourceDragEvent dsde) {} + + public void dragExit(DragSourceEvent dse) {} + + public void dragOver(DragSourceDragEvent dsde) {} + + public void dragDropEnd(DragSourceDropEvent dsde) {} + + public void dropActionChanged(DragSourceDragEvent dsde) {} + + public Object getTransferData(DataFlavor flavor) + throws UnsupportedFlavorException, IOException { + + if (!isDataFlavorSupported(flavor)) { + throw new UnsupportedFlavorException(flavor); + } + + Object retObj; + + ByteArrayOutputStream baoStream = new ByteArrayOutputStream(); + ObjectOutputStream ooStream = new ObjectOutputStream(baoStream); + ooStream.writeObject(this); + + ByteArrayInputStream baiStream = + new ByteArrayInputStream(baoStream.toByteArray()); + ObjectInputStream ois = new ObjectInputStream(baiStream); + try { + retObj = ois.readObject(); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + throw new RuntimeException(e.toString()); + } + + return retObj; + } + + public DataFlavor[] getTransferDataFlavors() { + return new DataFlavor[] { dataflavor }; + } + + public boolean isDataFlavorSupported(DataFlavor dflavor) { + return dataflavor.equals(dflavor); + } + } + + private static class DropTargetPanel extends Panel implements DropTargetListener { + + final Dimension preferredDimension = new Dimension(200, 100); + volatile boolean testPassed = true; + + public DropTargetPanel() { + setDropTarget(new DropTarget(this, this)); + } + + public boolean getStatus() { + return testPassed; + } + + public Dimension getPreferredSize() { + return preferredDimension; + } + + public void dragEnter(DropTargetDragEvent dtde) {} + + public void dragExit(DropTargetEvent dte) { + testPassed = false; + } + + public void dragOver(DropTargetDragEvent dtde) {} + + public void dropActionChanged(DropTargetDragEvent dtde) {} + + public void drop(DropTargetDropEvent dtde) { + DropTargetContext dtc = dtde.getDropTargetContext(); + + if ((dtde.getSourceActions() & DnDConstants.ACTION_COPY) != 0) { + dtde.acceptDrop(DnDConstants.ACTION_COPY); + } else { + dtde.rejectDrop(); + } + + DataFlavor[] dfs = dtde.getCurrentDataFlavors(); + Component comp = null; + + if(dfs != null && dfs.length >= 1) { + Transferable transfer = dtde.getTransferable(); + + try { + comp = (Component)transfer.getTransferData(dfs[0]); + } catch (Throwable e) { + e.printStackTrace(); + dtc.dropComplete(false); + } + } + dtc.dropComplete(true); + add(comp); + } + } +} + + + diff --git a/test/jdk/java/awt/dnd/DragSourceMotionListenerTest.java b/test/jdk/java/awt/dnd/DragSourceMotionListenerTest.java new file mode 100644 index 00000000000..25bf7ef03fd --- /dev/null +++ b/test/jdk/java/awt/dnd/DragSourceMotionListenerTest.java @@ -0,0 +1,242 @@ +/* + * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 java.awt.AWTEvent; +import java.awt.Component; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.GridLayout; +import java.awt.Panel; +import java.awt.Point; +import java.awt.Robot; +import java.awt.Toolkit; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.StringSelection; +import java.awt.datatransfer.Transferable; +import java.awt.dnd.DnDConstants; +import java.awt.dnd.DragGestureListener; +import java.awt.dnd.DragSource; +import java.awt.dnd.DragSourceAdapter; +import java.awt.dnd.DragSourceDragEvent; +import java.awt.dnd.DragSourceDropEvent; +import java.awt.dnd.DropTarget; +import java.awt.dnd.DropTargetAdapter; +import java.awt.dnd.DropTargetDropEvent; +import java.awt.dnd.DropTargetListener; +import java.awt.event.AWTEventListener; +import java.awt.event.InputEvent; +import java.awt.event.KeyEvent; +import java.awt.event.MouseEvent; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + +/* + * @test + * @key headful + * @bug 4422345 + * @summary tests that DragSourceMotionListeners work correctly and + DragSourceEvents position is correct + */ + +public class DragSourceMotionListenerTest implements AWTEventListener { + static class TestPanel extends Panel { + final Dimension preferredDimension = new Dimension(200, 200); + public Dimension getPreferredSize() { + return preferredDimension; + } + } + + private static Frame frame; + private static final Panel source = new TestPanel(); + private static final Panel target = new TestPanel(); + private static final DragSource ds = DragSource.getDefaultDragSource(); + private static volatile CountDownLatch mouseReleaseEvent; + + static volatile boolean passedTest1 = false; + static volatile boolean passedTest2 = false; + + private static final Point testPoint1 = new Point(); + private static final Point testPoint2 = new Point(); + private static volatile Point srcPoint; + private static volatile Point dstOutsidePoint; + private static volatile Point dstInsidePoint; + + private static final Transferable t = new StringSelection("TEXT"); + private static final DragGestureListener gestureListener = e -> e.startDrag(null, t); + + private static final DragSourceAdapter sourceAdapter = new DragSourceAdapter() { + public void dragMouseMoved(DragSourceDragEvent dsde) { + if (Math.abs(dsde.getX() - testPoint1.getX()) < 5) { + passedTest1 = true; + } + } + + public void dragDropEnd(DragSourceDropEvent dsde) { + if (Math.abs(dsde.getX() - testPoint2.getX()) < 5) { + passedTest2 = true; + } + } + }; + + private static final DropTargetListener targetAdapter = new DropTargetAdapter() { + public void drop(DropTargetDropEvent e) { + e.acceptDrop(DnDConstants.ACTION_COPY); + try { + final Transferable t = e.getTransferable(); + final String str = + (String) t.getTransferData(DataFlavor.stringFlavor); + e.dropComplete(true); + } catch (Exception ex) { + ex.printStackTrace(); + e.dropComplete(false); + } + } + }; + + private static final DropTarget dropTarget = new DropTarget(target, targetAdapter); + Component clickedComponent = null; + + private void createAndShowUI() { + frame = new Frame("DragSourceMotionListenerTest"); + ds.addDragSourceListener(sourceAdapter); + ds.addDragSourceMotionListener(sourceAdapter); + ds.createDefaultDragGestureRecognizer(source, DnDConstants.ACTION_COPY, gestureListener); + target.setDropTarget(dropTarget); + + frame.setLayout(new GridLayout(1, 2)); + + frame.add(source); + frame.add(target); + + Toolkit.getDefaultToolkit() + .addAWTEventListener(this, AWTEvent.MOUSE_EVENT_MASK); + frame.pack(); + frame.setVisible(true); + } + + public static void main(String[] args) throws Exception { + try { + Robot robot = new Robot(); + robot.setAutoDelay(10); + + DragSourceMotionListenerTest dsmObj = new DragSourceMotionListenerTest(); + EventQueue.invokeAndWait(dsmObj::createAndShowUI); + robot.waitForIdle(); + robot.delay(1000); + + EventQueue.invokeAndWait(() -> { + srcPoint = getPoint(source, 1); + + dstOutsidePoint = getPoint(frame, 3); + testPoint1.setLocation(dstOutsidePoint); + + dstInsidePoint = getPoint(target, 1); + testPoint2.setLocation(dstInsidePoint); + }); + robot.waitForIdle(); + + if (!dsmObj.pointInComponent(robot, srcPoint, source)) { + throw new RuntimeException("WARNING: Couldn't locate source panel."); + } + + if (!dsmObj.pointInComponent(robot, dstInsidePoint, target)) { + throw new RuntimeException("WARNING: Couldn't locate target panel."); + } + + robot.mouseMove(srcPoint.x, srcPoint.y); + robot.keyPress(KeyEvent.VK_CONTROL); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + for (; !srcPoint.equals(dstOutsidePoint); + srcPoint.translate(sign(dstOutsidePoint.x - srcPoint.x), + sign(dstOutsidePoint.y - srcPoint.y))) { + robot.mouseMove(srcPoint.x, srcPoint.y); + } + + for (int i = 0; i < 10; i++) { + robot.mouseMove(srcPoint.x, srcPoint.y++); + } + + for (;!srcPoint.equals(dstInsidePoint); + srcPoint.translate(sign(dstInsidePoint.x - srcPoint.x), + sign(dstInsidePoint.y - srcPoint.y))) { + robot.mouseMove(srcPoint.x, srcPoint.y); + } + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.keyRelease(KeyEvent.VK_CONTROL); + robot.waitForIdle(); + robot.delay(1000); + + if (!passedTest1) { + throw new RuntimeException("Failed first test."); + } + + if (!passedTest2) { + throw new RuntimeException("Failed second test."); + } + } finally { + EventQueue.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } + + private static Point getPoint(Container container, int multiple) { + Point p = container.getLocationOnScreen(); + Dimension d = container.getSize(); + p.translate(multiple * d.width / 2, d.height / 2); + return p; + } + + public static int sign(int n) { + return Integer.compare(n, 0); + } + + public void eventDispatched(AWTEvent e) { + if (e.getID() == MouseEvent.MOUSE_RELEASED) { + clickedComponent = (Component)e.getSource(); + mouseReleaseEvent.countDown(); + } + } + + boolean pointInComponent(Robot robot, Point p, Component comp) throws Exception { + robot.waitForIdle(); + clickedComponent = null; + mouseReleaseEvent = new CountDownLatch(1); + robot.mouseMove(p.x, p.y); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + if (!mouseReleaseEvent.await(2, TimeUnit.SECONDS)) { + throw new RuntimeException("Mouse Release Event not received"); + } + + Component c = clickedComponent; + while (c != null && c != comp) { + c = c.getParent(); + } + return c == comp; + } +} diff --git a/test/jdk/java/awt/dnd/DragThresholdTest.java b/test/jdk/java/awt/dnd/DragThresholdTest.java new file mode 100644 index 00000000000..bcb3bbf91c2 --- /dev/null +++ b/test/jdk/java/awt/dnd/DragThresholdTest.java @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 java.awt.EventQueue; +import java.awt.Frame; +import java.awt.Panel; +import java.awt.Point; +import java.awt.Robot; +import java.awt.dnd.DnDConstants; +import java.awt.dnd.DragGestureListener; +import java.awt.dnd.DragSource; +import java.awt.event.InputEvent; +import java.awt.event.MouseEvent; +import java.awt.event.MouseMotionAdapter; + +/* + @test + @key headful + @bug 4415175 + @summary tests DragSource.getDragThreshold() and + that the AWT default drag gesture recognizers + honor the drag gesture motion threshold +*/ + +public class DragThresholdTest { + private static Frame frame; + private static Panel panel; + private static MouseEvent lastMouseEvent; + private static volatile boolean failed; + private static volatile Point startPoint; + private static volatile Point endPoint; + + public static void main(String[] args) throws Exception { + try { + Robot robot = new Robot(); + + EventQueue.invokeAndWait(DragThresholdTest::createAndShowDnD); + robot.waitForIdle(); + robot.delay(1000); + + EventQueue.invokeAndWait(() -> { + Point p = panel.getLocationOnScreen(); + p.translate(50, 50); + startPoint = p; + endPoint = new Point(p.x + 2 * DragSource.getDragThreshold(), + p.y + 2 * DragSource.getDragThreshold()); + }); + + robot.mouseMove(startPoint.x, startPoint.y); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + for (Point p = new Point(startPoint); !p.equals(endPoint); + p.translate(sign(endPoint.x - p.x), + sign(endPoint.y - p.y))) { + robot.mouseMove(p.x, p.y); + robot.delay(100); + } + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.waitForIdle(); + robot.delay(200); + + if (failed) { + throw new RuntimeException("drag gesture recognized too early"); + } + } finally { + EventQueue.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } + + private static void createAndShowDnD() { + frame = new Frame("DragThresholdTest"); + panel = new Panel(); + // Mouse motion listener mml is added to the panel first. + // We rely on it that this listener will be called first. + panel.addMouseMotionListener(new MouseMotionAdapter() { + public void mouseDragged(MouseEvent evt) { + lastMouseEvent = evt; + System.out.println(evt); + } + }); + frame.add(panel); + frame.setSize(200, 200); + frame.setLocationRelativeTo(null); + + DragGestureListener dgl = dge -> { + Point dragOrigin = dge.getDragOrigin(); + int diffx = Math.abs(dragOrigin.x - lastMouseEvent.getX()); + int diffy = Math.abs(dragOrigin.y - lastMouseEvent.getY()); + System.out.println("dragGestureRecognized(): " + + " diffx=" + diffx + " diffy=" + diffy + + " DragSource.getDragThreshold()=" + + DragSource.getDragThreshold()); + if (diffx <= DragSource.getDragThreshold() && + diffy <= DragSource.getDragThreshold()) { + failed = true; + System.out.println("drag gesture recognized too early!"); + } + }; + + // Default drag gesture recognizer is a mouse motion listener. + // It is added to the panel second. + new DragSource().createDefaultDragGestureRecognizer( + panel, + DnDConstants.ACTION_COPY_OR_MOVE, dgl); + frame.setVisible(true); + } + + private static int sign(int n) { + return Integer.compare(n, 0); + } +} diff --git a/test/jdk/java/awt/dnd/DragToAnotherScreenTest.java b/test/jdk/java/awt/dnd/DragToAnotherScreenTest.java new file mode 100644 index 00000000000..89f18061845 --- /dev/null +++ b/test/jdk/java/awt/dnd/DragToAnotherScreenTest.java @@ -0,0 +1,169 @@ +/* + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Frame; +import java.awt.GraphicsDevice; +import java.awt.GraphicsEnvironment; +import java.awt.Label; +import java.awt.Toolkit; +import java.awt.Window; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.StringSelection; +import java.awt.datatransfer.Transferable; +import java.awt.dnd.DnDConstants; +import java.awt.dnd.DragGestureListener; +import java.awt.dnd.DragSource; +import java.awt.dnd.DropTarget; +import java.awt.dnd.DropTargetAdapter; +import java.awt.dnd.DropTargetDropEvent; +import java.util.List; + +import javax.swing.JOptionPane; + +/* + * @test + * @bug 6179157 + * @key multimon + * @summary Tests dnd to another screen + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual DragToAnotherScreenTest + */ + +public class DragToAnotherScreenTest { + private static Label label0; + private static Label label1; + private static final int HGAP = 20; + + private static final String INSTRUCTIONS = """ + The following test is applicable for Single as well + as Multi-monitor screens. + + It is a semi-automated test, the test will prompt + the user whether the drag and drop action was successful or not + and automatically PASS/FAIL the test. + + If on multi-monitor screens then please position + the drag and drop windows on different screens. + + If you can not move the mouse from the frame "Drag Source" + to the frame "Drop Target" press PASS, + else proceed to the next step. + + Drag the label "Drag me" and drop it on the + label "Drop on me". + + If you can not drag to the second label (for example + if you can not drag across screens) press FAIL. + + After the drag and drop action, the test displays + Success/Failure msg in JOptionPane. + Click on OK button and the test is configured to + automatically PASS/FAIL. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .columns(35) + .testUI(DragToAnotherScreenTest::createAndShowUI) + .positionTestUI(DragToAnotherScreenTest::positionMultiTestUI) + .logArea(10) + .build() + .awaitAndCheck(); + } + + private static List createAndShowUI() { + PassFailJFrame.log("----- System Configuration ----"); + PassFailJFrame.log("Toolkit:" + Toolkit.getDefaultToolkit() + .getClass() + .getName()); + + GraphicsDevice[] gd = GraphicsEnvironment.getLocalGraphicsEnvironment() + .getScreenDevices(); + if (gd.length == 1) { + PassFailJFrame.log("Single Monitor"); + } else { + PassFailJFrame.log("Multi-Monitor"); + } + PassFailJFrame.log("--------------"); + PassFailJFrame.log("Test logs:\n"); + Frame frame0 = new Frame("Drag Source", gd[0].getDefaultConfiguration()); + frame0.setSize(300, 300); + label0 = new Label("Drag me"); + frame0.add(label0); + + Frame frame1 = new Frame("Drop Target", gd[(gd.length > 1 ? 1 : 0)].getDefaultConfiguration()); + frame1.setSize(300, 300); + label1 = new Label("Drop on me"); + frame1.add(label1); + + DragGestureListener dragGestureListener = dge -> dge.startDrag(null, new StringSelection(label0.getText()), null); + new DragSource().createDefaultDragGestureRecognizer(label0, + DnDConstants.ACTION_COPY, dragGestureListener); + + DropTargetAdapter dropTargetAdapter = new DropTargetAdapter() { + public void drop(DropTargetDropEvent dtde) { + Transferable t = dtde.getTransferable(); + if (t.isDataFlavorSupported(DataFlavor.stringFlavor)) { + dtde.acceptDrop(DnDConstants.ACTION_COPY); + try { + String str = (String) t.getTransferData(DataFlavor.stringFlavor); + label1.setText(str); + JOptionPane.showMessageDialog(frame0, + "getTransferData was successful", + "Test Passed", JOptionPane.PLAIN_MESSAGE); + } catch (Exception e) { + dtde.dropComplete(false); + e.printStackTrace(); + PassFailJFrame.log("getTransferData() Failed"); + JOptionPane.showMessageDialog(frame0, + "getTransferData() Failed", + "Test Failed", JOptionPane.ERROR_MESSAGE); + PassFailJFrame.forceFail("getTransferData() Failed"); + } + dtde.dropComplete(true); + } else { + dtde.rejectDrop(); + PassFailJFrame.log("stringFlavor is not supported by Transferable"); + JOptionPane.showMessageDialog(frame0, + "stringFlavor is not supported by Transferable", + "Test Failed", JOptionPane.ERROR_MESSAGE); + PassFailJFrame.forceFail("stringFlavor is not supported by Transferable"); + } + } + }; + new DropTarget(label1, dropTargetAdapter); + return List.of(frame0, frame1); + } + + private static void positionMultiTestUI(List windows, + PassFailJFrame.InstructionUI instructionUI) { + int x = instructionUI.getLocation().x + instructionUI.getSize().width + HGAP; + for (Window w : windows) { + w.setLocation(x, instructionUI.getLocation().y); + x += w.getWidth() + HGAP; + } + } +} diff --git a/test/jdk/java/awt/dnd/DropActionChangeTest.java b/test/jdk/java/awt/dnd/DropActionChangeTest.java index 7cb1019a44d..2bfbb44bbfd 100644 --- a/test/jdk/java/awt/dnd/DropActionChangeTest.java +++ b/test/jdk/java/awt/dnd/DropActionChangeTest.java @@ -21,17 +21,17 @@ * questions. */ -import javax.swing.JFrame; import java.awt.AWTEvent; import java.awt.Component; import java.awt.EventQueue; import java.awt.Frame; import java.awt.Panel; import java.awt.Point; +import java.awt.Rectangle; import java.awt.Robot; +import java.awt.Toolkit; import java.awt.datatransfer.StringSelection; import java.awt.dnd.DnDConstants; -import java.awt.dnd.DragGestureEvent; import java.awt.dnd.DragGestureListener; import java.awt.dnd.DragSource; import java.awt.dnd.DragSourceAdapter; @@ -43,9 +43,13 @@ import java.awt.dnd.DropTargetDragEvent; import java.awt.dnd.DropTargetDropEvent; import java.awt.dnd.DropTargetListener; import java.awt.event.AWTEventListener; -import java.awt.event.MouseEvent; import java.awt.event.InputEvent; import java.awt.event.KeyEvent; +import java.awt.event.MouseEvent; +import java.io.File; +import java.util.concurrent.atomic.AtomicReference; +import javax.imageio.ImageIO; +import javax.swing.JFrame; /* @test @@ -56,28 +60,24 @@ import java.awt.event.KeyEvent; */ public class DropActionChangeTest extends JFrame implements AWTEventListener { - Robot robot; - Frame frame; + private static Robot robot; + private static Frame frame; + private static volatile DropActionChangeTest test; Panel panel; private volatile boolean failed; private volatile boolean dropEnd; private volatile Component clickedComponent; private final Object LOCK = new Object(); - static final int FRAME_ACTIVATION_TIMEOUT = 3000; - static final int DROP_COMPLETION_TIMEOUT = 5000; + static final int DROP_COMPLETION_TIMEOUT = 8000; static final int MOUSE_RELEASE_TIMEOUT = 2000; public static void main(String[] args) throws Exception { - DropActionChangeTest test = new DropActionChangeTest(); + EventQueue.invokeAndWait(() -> test = new DropActionChangeTest()); EventQueue.invokeAndWait(test::init); try { test.start(); } finally { - EventQueue.invokeAndWait(() -> { - if (test.frame != null) { - test.frame.dispose(); - } - }); + EventQueue.invokeAndWait(DropActionChangeTest::disposeFrame); } } @@ -97,10 +97,12 @@ public class DropActionChangeTest extends JFrame implements AWTEventListener { final DragSourceListener dsl = new DragSourceAdapter() { public void dragDropEnd(DragSourceDropEvent e) { - System.err.println("DragSourseListener.dragDropEnd(): " + + System.err.println("DragSourceListener.dragDropEnd(): " + "drop action=" + e.getDropAction()); if (e.getDropAction() != DnDConstants.ACTION_MOVE) { - System.err.println("FAILURE: wrong drop action:" + e.getDropAction()); + System.err.println("FAILURE: wrong drop action:" + + e.getDropAction() + ", It should be " + + DnDConstants.ACTION_MOVE); failed = true; } synchronized (LOCK) { @@ -110,11 +112,7 @@ public class DropActionChangeTest extends JFrame implements AWTEventListener { } }; - DragGestureListener dgl = new DragGestureListener() { - public void dragGestureRecognized(DragGestureEvent dge) { - dge.startDrag(null, new StringSelection("test"), dsl); - } - }; + DragGestureListener dgl = dge -> dge.startDrag(null, new StringSelection("test"), dsl); new DragSource().createDefaultDragGestureRecognizer(panel, DnDConstants.ACTION_COPY_OR_MOVE, dgl); @@ -142,11 +140,25 @@ public class DropActionChangeTest extends JFrame implements AWTEventListener { frame.setVisible(true); } + private static void disposeFrame() { + if (frame != null) { + frame.dispose(); + } + if (test != null) { + test.dispose(); + } + } + public void start() { try { robot = new Robot(); + robot.setAutoDelay(100); + robot.waitForIdle(); + robot.delay(500); - Point startPoint = panel.getLocationOnScreen(); + AtomicReference startPointRef = new AtomicReference<>(); + EventQueue.invokeAndWait(()-> startPointRef.set(panel.getLocationOnScreen())); + Point startPoint = startPointRef.get(); startPoint.translate(50, 50); if (!pointInComponent(robot, startPoint, panel)) { @@ -163,15 +175,18 @@ public class DropActionChangeTest extends JFrame implements AWTEventListener { synchronized (LOCK) { robot.keyPress(KeyEvent.VK_CONTROL); robot.mouseMove(startPoint.x, startPoint.y); - robot.mousePress(InputEvent.BUTTON1_MASK); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); Util.doDrag(robot, startPoint, medPoint); + robot.delay(500); robot.keyRelease(KeyEvent.VK_CONTROL); Util.doDrag(robot, medPoint, endPoint); - robot.mouseRelease(InputEvent.BUTTON1_MASK); + robot.delay(500); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); LOCK.wait(DROP_COMPLETION_TIMEOUT); } if (!dropEnd) { - System.err.println("DragSourseListener.dragDropEnd() was not called, returning"); + captureScreen("No_Drop_End_"); + System.err.println("DragSourceListener.dragDropEnd() was not called, returning"); return; } } catch (Throwable e) { @@ -179,10 +194,22 @@ public class DropActionChangeTest extends JFrame implements AWTEventListener { } if (failed) { - throw new RuntimeException("wrong drop action!"); + captureScreen("Wrong_Drop_Action_"); + throw new RuntimeException("Wrong drop action!"); } - System.err.println("test passed!"); + System.err.println("Test passed!"); + } + + private static void captureScreen(String str) { + try { + final Rectangle screenBounds = new Rectangle( + Toolkit.getDefaultToolkit().getScreenSize()); + ImageIO.write(robot.createScreenCapture(screenBounds), "png", + new File(str + "Failure_Screen.png")); + } catch (Exception e) { + e.printStackTrace(); + } } public void reset() { @@ -203,9 +230,9 @@ public class DropActionChangeTest extends JFrame implements AWTEventListener { robot.waitForIdle(); reset(); robot.mouseMove(p.x, p.y); - robot.mousePress(InputEvent.BUTTON1_MASK); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); synchronized (LOCK) { - robot.mouseRelease(InputEvent.BUTTON1_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); LOCK.wait(MOUSE_RELEASE_TIMEOUT); } @@ -227,15 +254,11 @@ class Util { } public static void doDrag(Robot robot, Point startPoint, Point endPoint) { + robot.waitForIdle(); for (Point p = new Point(startPoint); !p.equals(endPoint); p.translate(Util.sign(endPoint.x - p.x), Util.sign(endPoint.y - p.y))) { robot.mouseMove(p.x, p.y); - try { - Thread.sleep(100); - } catch (InterruptedException e) { - e.printStackTrace(); - } } } -} +} \ No newline at end of file diff --git a/test/jdk/java/awt/dnd/NonAsciiFilenames.java b/test/jdk/java/awt/dnd/NonAsciiFilenames.java new file mode 100644 index 00000000000..b508350c05e --- /dev/null +++ b/test/jdk/java/awt/dnd/NonAsciiFilenames.java @@ -0,0 +1,158 @@ +/* + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4187490 + * @summary Verify that Non-ASCII file names can be dragged and dropped + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual NonAsciiFilenames + */ + +import java.awt.Color; +import java.awt.datatransfer.DataFlavor; +import java.awt.dnd.DnDConstants; +import java.awt.dnd.DropTarget; +import java.awt.dnd.DropTargetDragEvent; +import java.awt.dnd.DropTargetDropEvent; +import java.awt.dnd.DropTargetEvent; +import java.awt.dnd.DropTargetListener; +import java.io.File; +import java.util.AbstractList; + +import javax.swing.JFrame; +import javax.swing.JLabel; + +public class NonAsciiFilenames { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + This test must be run on an OS which does not use ISO 8859-1 + as its default encoding. + + Open a native file browsing application, such as Windows + Explorer. Try to find a file whose name uses non-ISO 8859-1 + characters. Create a file and name it such that it contains + non-ISO 8859-1 characters (For ex. é, à, ö, €, ¥). Drag + the file from the native application and drop it on the test + Frame. If the file name appears normally, then the test passes. + If boxes or question marks appear for characters, or if you see + the word "Error", then the test fails. + """; + + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .columns(35) + .testUI(NonAsciiFilenames::createUI) + .build() + .awaitAndCheck(); + } + + public static JFrame createUI() { + JFrame frame = new JFrame(); + frame.setTitle("DropLabel test"); + frame.getContentPane().add(new DropLabel("Drop here")); + frame.setSize(300, 100); + return frame; + } +} + +class DropLabel extends JLabel implements DropTargetListener { + public DropLabel(String s) { + setText(s); + new DropTarget(this, DnDConstants.ACTION_COPY, this, true); + showDrop(false); + } + + private void showDrop(boolean b) { + setForeground(b ? Color.white : Color.black); + } + + /** + * Configure to desired flavor of dropped data. + */ + private DataFlavor getDesiredFlavor() { + return DataFlavor.javaFileListFlavor; + } + + /** + * Check to make sure that the contains the expected object types. + */ + private void checkDroppedData(Object data) { + System.out.println("Got data: " + data.getClass().getName()); + if (data instanceof AbstractList) { + AbstractList files = (AbstractList) data; + if (((File) files.get(0)).isFile()) + setText(((File) files.get(0)).toString()); + else + setText("Error: not valid file: " + + ((File) files.get(0)).toString()); + } else { + System.out.println("Error: wrong type of data dropped"); + } + } + + private boolean isDragOk(DropTargetDragEvent e) { + boolean canDrop = false; + try { + canDrop = e.isDataFlavorSupported(getDesiredFlavor()); + } catch (Exception ex) { + } + + if (canDrop) + e.acceptDrag(DnDConstants.ACTION_COPY); + else + e.rejectDrag(); + showDrop(canDrop); + return canDrop; + } + + public void dragEnter(DropTargetDragEvent e) { + isDragOk(e); + } + + + public void dragOver(DropTargetDragEvent e) { + isDragOk(e); + } + + public void dropActionChanged(DropTargetDragEvent e) { + isDragOk(e); + } + + public void dragExit(DropTargetEvent e) { + showDrop(false); + } + + public void drop(DropTargetDropEvent e) { + try { + e.acceptDrop(DnDConstants.ACTION_COPY); + checkDroppedData(e.getTransferable(). + getTransferData(getDesiredFlavor())); + } catch (Exception err) { + } + e.dropComplete(true); + showDrop(false); + } +} diff --git a/test/jdk/java/awt/dnd/RejectDragTest.java b/test/jdk/java/awt/dnd/RejectDragTest.java new file mode 100644 index 00000000000..c65612436bc --- /dev/null +++ b/test/jdk/java/awt/dnd/RejectDragTest.java @@ -0,0 +1,174 @@ +/* + * Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.Point; +import java.awt.Robot; +import java.awt.datatransfer.StringSelection; +import java.awt.dnd.DnDConstants; +import java.awt.dnd.DragGestureListener; +import java.awt.dnd.DragSource; +import java.awt.dnd.DragSourceAdapter; +import java.awt.dnd.DragSourceDragEvent; +import java.awt.dnd.DragSourceDropEvent; +import java.awt.dnd.DragSourceEvent; +import java.awt.dnd.DragSourceListener; +import java.awt.dnd.DropTarget; +import java.awt.dnd.DropTargetAdapter; +import java.awt.dnd.DropTargetDragEvent; +import java.awt.dnd.DropTargetDropEvent; +import java.awt.event.InputEvent; + +/* + * @test + * @key headful + * @bug 4407521 + * @summary Tests that DragSourceListener.dragEnter() and + DragSourceListener.dragOver() are not called after + drag rejecting, but DragSourceListener.dragExit() is. + */ + +public class RejectDragTest { + private static Frame frame; + private static Robot robot; + private static volatile boolean dragEnterCalled; + private static volatile boolean dragOverCalled; + private static volatile boolean dragExitCalledAtFirst; + private static volatile Point startPoint; + private static volatile Point endPoint; + + public static void main(String[] args) throws Exception { + try { + robot = new Robot(); + + EventQueue.invokeAndWait(RejectDragTest::createAndShowUI); + robot.waitForIdle(); + robot.delay(1000); + + EventQueue.invokeAndWait(RejectDragTest::addDnDListeners); + robot.waitForIdle(); + + testDnD(); + robot.waitForIdle(); + robot.delay(200); + } finally { + EventQueue.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } + + private static void addDnDListeners() { + final DragSourceListener dragSourceListener = new DragSourceAdapter() { + private boolean first = true; + + public void dragEnter(DragSourceDragEvent dsde) { + first = false; + dragEnterCalled = true; + } + + public void dragExit(DragSourceEvent dse) { + if (first) { + dragExitCalledAtFirst = true; + first = false; + } + } + + public void dragDropEnd(DragSourceDropEvent dsde) { + first = false; + } + + public void dragOver(DragSourceDragEvent dsde) { + first = false; + dragOverCalled = true; + } + + public void dropActionChanged(DragSourceDragEvent dsde) { + first = false; + } + }; + + DragGestureListener dragGestureListener = + dge -> dge.startDrag(null, new StringSelection("OKAY"), + dragSourceListener); + new DragSource().createDefaultDragGestureRecognizer(frame, + DnDConstants.ACTION_COPY, + dragGestureListener); + + DropTargetAdapter dropTargetListener = new DropTargetAdapter() { + public void dragEnter(DropTargetDragEvent dtde) { + dtde.rejectDrag(); + } + + public void drop(DropTargetDropEvent dtde) { + dtde.rejectDrop(); + } + }; + + new DropTarget(frame, dropTargetListener); + } + + private static void createAndShowUI() { + frame = new Frame("RejectDragTest"); + frame.setSize(200, 200); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } + + private static void testDnD() throws Exception { + EventQueue.invokeAndWait(() -> { + Point start = frame.getLocationOnScreen(); + start.translate(50, 50); + startPoint = start; + + Point end = new Point(start); + end.translate(150, 150); + endPoint = end; + }); + + robot.mouseMove(startPoint.x, startPoint.y); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + for (Point p = new Point(startPoint); !p.equals(endPoint); + p.translate(sign(endPoint.x - p.x), + sign(endPoint.y - p.y))) { + robot.mouseMove(p.x, p.y); + robot.delay(30); + } + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + + if (dragEnterCalled || dragOverCalled) { + throw new RuntimeException("Test failed: " + + (dragEnterCalled ? "DragSourceListener.dragEnter() was called; " : "") + + (dragOverCalled ? "DragSourceListener.dragOver() was called; " : "") + + (!dragExitCalledAtFirst ? "DragSourceListener.dragExit() was not " + + "called immediately after rejectDrag() " : "")); + } + } + + public static int sign(int n) { + return Integer.compare(n, 0); + } +} diff --git a/test/jdk/java/awt/dnd/URLDragTest.java b/test/jdk/java/awt/dnd/URLDragTest/URLDragTest.java similarity index 100% rename from test/jdk/java/awt/dnd/URLDragTest.java rename to test/jdk/java/awt/dnd/URLDragTest/URLDragTest.java diff --git a/test/jdk/java/awt/dnd/WinMoveFileToShellTest.java b/test/jdk/java/awt/dnd/WinMoveFileToShellTest.java new file mode 100644 index 00000000000..5ae7dd3890d --- /dev/null +++ b/test/jdk/java/awt/dnd/WinMoveFileToShellTest.java @@ -0,0 +1,131 @@ +/* + * Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Frame; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.Transferable; +import java.awt.datatransfer.UnsupportedFlavorException; +import java.awt.dnd.DnDConstants; +import java.awt.dnd.DragGestureListener; +import java.awt.dnd.DragSource; +import java.awt.dnd.DragSourceAdapter; +import java.awt.dnd.DragSourceDropEvent; +import java.awt.dnd.DragSourceListener; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +/* + * @test + * @bug 4414739 + * @requires (os.family == "windows") + * @summary verifies that getDropSuccess() returns correct value for moving + a file from a Java drag source to the Windows shell + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual WinMoveFileToShellTest + */ + +public class WinMoveFileToShellTest { + private static final String INSTRUCTIONS = """ + Drag from the frame titled "Drag Frame" and drop on to Windows Desktop. + After Drag and Drop, check for "Drop Success" status in the log area. + If "Drop Success" is true press PASS else FAIL. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(WinMoveFileToShellTest::createAndShowUI) + .logArea(5) + .build() + .awaitAndCheck(); + } + + private static Frame createAndShowUI() { + Frame frame = new Frame("Drag Frame"); + final DragSourceListener dsl = new DragSourceAdapter() { + public void dragDropEnd(DragSourceDropEvent e) { + PassFailJFrame.log("Drop Success: " + e.getDropSuccess()); + } + }; + + DragGestureListener dgl = dge -> { + File file = new File(System.getProperty("test.classes", ".") + + File.separator + "move.me"); + try { + file.createNewFile(); + } catch (IOException exc) { + exc.printStackTrace(); + } + ArrayList list = new ArrayList<>(); + list.add(file); + dge.startDrag(null, new FileListSelection(list), dsl); + }; + + new DragSource().createDefaultDragGestureRecognizer(frame, + DnDConstants.ACTION_MOVE, dgl); + frame.setSize(200, 100); + return frame; + } + + private static class FileListSelection implements Transferable { + private static final int FL = 0; + + private static final DataFlavor[] flavors = + new DataFlavor[] { DataFlavor.javaFileListFlavor }; + + + private List data; + + public FileListSelection(List data) { + this.data = data; + } + + public DataFlavor[] getTransferDataFlavors() { + return flavors.clone(); + } + + public boolean isDataFlavorSupported(DataFlavor flavor) { + for (DataFlavor dataFlavor : flavors) { + if (flavor.equals(dataFlavor)) { + return true; + } + } + return false; + } + + public Object getTransferData(DataFlavor flavor) + throws UnsupportedFlavorException, IOException + { + if (flavor.equals(flavors[FL])) { + return data; + } else { + throw new UnsupportedFlavorException(flavor); + } + } + } +} diff --git a/test/jdk/java/awt/event/KeyEvent/FunctionKeyTest.java b/test/jdk/java/awt/event/KeyEvent/FunctionKeyTest.java index 02e7a890d83..78043cb5abd 100644 --- a/test/jdk/java/awt/event/KeyEvent/FunctionKeyTest.java +++ b/test/jdk/java/awt/event/KeyEvent/FunctionKeyTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,6 +31,18 @@ import java.awt.Label; import java.awt.Robot; import java.awt.TextArea; import java.awt.event.KeyEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.CyclicBarrier; +import java.util.concurrent.TimeoutException; +import java.util.concurrent.atomic.AtomicReference; + +import static java.awt.Event.KEY_ACTION; +import static java.awt.Event.KEY_ACTION_RELEASE; +import static java.util.concurrent.TimeUnit.SECONDS; /* * @test @@ -39,35 +51,38 @@ import java.awt.event.KeyEvent; * @key headful */ -public class FunctionKeyTest { - private static FunctionKeyTester frame; +public final class FunctionKeyTest { + private static Frame frame; private static Robot robot; - static volatile boolean keyPressReceived; - static volatile boolean keyReleaseReceived; + private static final CyclicBarrier keyPress = new CyclicBarrier(2); + private static final CyclicBarrier keyRelease = new CyclicBarrier(2); - static final StringBuilder failures = new StringBuilder(); + private static final CountDownLatch frameActivated = new CountDownLatch(1); - private static void testKey(int keyCode, String keyText) { - keyPressReceived = false; - keyReleaseReceived = false; + private static final List failures = new ArrayList<>(4); + private static final AtomicReference edtException = new AtomicReference<>(); + private static void testKey(int keyCode, String keyText) throws Exception { robot.keyPress(keyCode); - - if (!keyPressReceived) { - failures.append(keyText).append(" key press is not received\n"); + try { + keyPress.await(2, SECONDS); + } catch (TimeoutException e) { + keyPress.reset(); + failures.add(new Error(keyText + " key press is not received", e)); } robot.keyRelease(keyCode); - - if (!keyReleaseReceived) { - failures.append(keyText).append(" key release is not received\n"); + try { + keyRelease.await(2, SECONDS); + } catch (TimeoutException e) { + keyRelease.reset(); + failures.add(new Error(keyText + " key release is not received", e)); } } public static void main(String[] args) throws Exception { robot = new Robot(); - robot.setAutoWaitForIdle(true); robot.setAutoDelay(150); try { @@ -75,11 +90,20 @@ public class FunctionKeyTest { frame = new FunctionKeyTester(); frame.setSize(200, 200); frame.setLocationRelativeTo(null); + frame.addWindowListener(new WindowAdapter() { + @Override + public void windowActivated(WindowEvent e) { + System.out.println("frame.windowActivated"); + frameActivated.countDown(); + } + }); frame.setVisible(true); }); - robot.waitForIdle(); - robot.delay(1000); + if (!frameActivated.await(2, SECONDS)) { + throw new Error("Frame wasn't activated"); + } + robot.delay(100); testKey(KeyEvent.VK_F11, "F11"); testKey(KeyEvent.VK_F12, "F12"); @@ -91,46 +115,69 @@ public class FunctionKeyTest { }); } - if (failures.isEmpty()) { - System.out.println("Passed"); - } else { - throw new RuntimeException(failures.toString()); + if (!failures.isEmpty()) { + System.err.println("Failures detected:"); + failures.forEach(System.err::println); + if (edtException.get() != null) { + System.err.println("\nException on EDT:"); + edtException.get().printStackTrace(); + } + System.err.println(); + throw new RuntimeException("Test failed: " + failures.get(0).getMessage(), + failures.get(0)); + } + + if (edtException.get() != null) { + throw new RuntimeException("Test failed because of exception on EDT", + edtException.get()); + } + } + + private static final class FunctionKeyTester extends Frame { + Label l = new Label ("NULL"); + Button b = new Button("button"); + TextArea log = new TextArea(); + + FunctionKeyTester() { + super("Function Key Test"); + this.setLayout(new BorderLayout()); + this.add(BorderLayout.NORTH, l); + this.add(BorderLayout.SOUTH, b); + this.add(BorderLayout.CENTER, log); + log.setFocusable(false); + log.setEditable(false); + l.setBackground(Color.red); + setSize(200, 200); + } + + @Override + @SuppressWarnings("deprecation") + public boolean handleEvent(Event e) { + String message = "e.id=" + e.id + "\n"; + System.out.print(message); + log.append(message); + + try { + switch (e.id) { + case KEY_ACTION + -> keyPress.await(); + case KEY_ACTION_RELEASE + -> keyRelease.await(); + } + } catch (Exception ex) { + if (!edtException.compareAndSet(null, ex)) { + edtException.get().addSuppressed(ex); + } + } + + return super.handleEvent(e); + } + + @Override + @SuppressWarnings("deprecation") + public boolean keyDown(Event e, int key) { + l.setText("e.key=" + e.key); + return false; } } } - -class FunctionKeyTester extends Frame { - Label l = new Label ("NULL"); - Button b = new Button(); - TextArea log = new TextArea(); - - FunctionKeyTester() { - super("Function Key Test"); - this.setLayout(new BorderLayout()); - this.add(BorderLayout.NORTH, l); - this.add(BorderLayout.SOUTH, b); - this.add(BorderLayout.CENTER, log); - log.setFocusable(false); - log.setEditable(false); - l.setBackground(Color.red); - setSize(200, 200); - } - - public boolean handleEvent(Event e) { - String message = "e.id=" + e.id + "\n"; - System.out.print(message); - log.append(message); - - switch (e.id) { - case 403 -> FunctionKeyTest.keyPressReceived = true; - case 404 -> FunctionKeyTest.keyReleaseReceived = true; - } - - return super.handleEvent(e); - } - - public boolean keyDown(Event e, int key) { - l.setText("e.key=" + Integer.valueOf(e.key).toString()); - return false; - } -} diff --git a/test/jdk/java/awt/event/KeyEvent/KeyTyped/Numpad1KeyTyped.java b/test/jdk/java/awt/event/KeyEvent/KeyTyped/Numpad1KeyTyped.java new file mode 100644 index 00000000000..a944be85581 --- /dev/null +++ b/test/jdk/java/awt/event/KeyEvent/KeyTyped/Numpad1KeyTyped.java @@ -0,0 +1,178 @@ +/* + * Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Frame; +import java.awt.Robot; +import java.awt.TextField; +import java.awt.Toolkit; +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.util.concurrent.CountDownLatch; + +import jdk.test.lib.Platform; + +import static java.util.concurrent.TimeUnit.SECONDS; + +/* + * @test + * @bug 4724007 + * @key headful + * @summary Tests that KeyTyped events are fired for the Numpad1 key + * @library /test/lib + * @build jdk.test.lib.Platform + * @run main Numpad1KeyTyped + */ +public final class Numpad1KeyTyped extends FocusAdapter implements KeyListener { + + private static final String ORIGINAL = "0123456789"; + private static final String EXPECTED = "10123456789"; + + private final CountDownLatch typedNum1 = new CountDownLatch(1); + private final CountDownLatch focusGained = new CountDownLatch(1); + + public static void main(String[] args) throws Exception { + Numpad1KeyTyped test = new Numpad1KeyTyped(); + test.start(); + } + + private void start() throws Exception { + Toolkit toolkit = Toolkit.getDefaultToolkit(); + Boolean oldState = null; + + Robot robot = new Robot(); + robot.setAutoDelay(100); + + Frame frame = new Frame("Numpad1KeyTyped"); + TextField tf = new TextField(ORIGINAL, 20); + frame.add(tf); + tf.addKeyListener(this); + + tf.addFocusListener(this); + + frame.setSize(300, 100); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + tf.requestFocusInWindow(); + + if (!focusGained.await(2, SECONDS)) { + throw new RuntimeException("TextField didn't receive focus"); + } + robot.waitForIdle(); + + try { + // Move cursor to start of TextField + robot.keyPress(KeyEvent.VK_HOME); + robot.keyRelease(KeyEvent.VK_HOME); + robot.waitForIdle(); + + if (Platform.isLinux()) { + // Press but don't release NumLock + robot.keyPress(KeyEvent.VK_NUM_LOCK); + } + if (Platform.isWindows()) { + oldState = toolkit.getLockingKeyState(KeyEvent.VK_NUM_LOCK); + toolkit.setLockingKeyState(KeyEvent.VK_NUM_LOCK, true); + } + + // Press and release Numpad-1 + robot.keyPress(KeyEvent.VK_NUMPAD1); + robot.keyRelease(KeyEvent.VK_NUMPAD1); + + if (!typedNum1.await(2, SECONDS)) { + throw new RuntimeException("TextField didn't receive keyTyped('1') - too slow"); + } + + final String text = tf.getText(); + if (!text.equals(EXPECTED)) { + throw new RuntimeException("Test FAILED: wrong string '" + + text + "' vs " + + "expected '" + EXPECTED + "'"); + } + System.out.println("Test PASSED"); + } finally { + if (Platform.isLinux()) { + // "release" + "press and release" NumLock to disable numlock + robot.keyRelease(KeyEvent.VK_NUM_LOCK); + robot.keyPress(KeyEvent.VK_NUM_LOCK); + robot.keyRelease(KeyEvent.VK_NUM_LOCK); + } + if (oldState != null) { + toolkit.setLockingKeyState(KeyEvent.VK_NUM_LOCK, oldState); + } + + frame.dispose(); + } + } + + @Override + public void focusGained(FocusEvent e) { + System.out.println("tf.focusGained"); + focusGained.countDown(); + } + + @Override + public void keyPressed(KeyEvent evt) { + printKey(evt); + } + + @Override + public void keyTyped(KeyEvent evt) { + printKey(evt); + + int keychar = evt.getKeyChar(); + if (keychar == '1') { + typedNum1.countDown(); + } + } + + @Override + public void keyReleased(KeyEvent evt) { + printKey(evt); + System.out.println(); + } + + private static void printKey(KeyEvent evt) { + int id = evt.getID(); + if (id != KeyEvent.KEY_TYPED + && id != KeyEvent.KEY_PRESSED + && id != KeyEvent.KEY_RELEASED) { + + System.out.println("Other Event"); + return; + } + + System.out.println("params= " + evt.paramString() + " \n" + + "KeyChar: " + evt.getKeyChar() + " = " + (int) evt.getKeyChar() + + " KeyCode: " + evt.getKeyCode() + + " Modifiers: " + evt.getModifiersEx()); + + if (evt.isActionKey()) { + System.out.println(" Action Key"); + } + + System.out.println("keyText= " + KeyEvent.getKeyText(evt.getKeyCode()) + "\n"); + } + +} diff --git a/test/jdk/java/awt/font/FontScaling/RotatedScaledFontTest.java b/test/jdk/java/awt/font/FontScaling/RotatedScaledFontTest.java new file mode 100644 index 00000000000..3e17bbd92c1 --- /dev/null +++ b/test/jdk/java/awt/font/FontScaling/RotatedScaledFontTest.java @@ -0,0 +1,149 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Color; +import java.awt.Font; +import java.awt.Graphics2D; +import java.awt.Rectangle; +import java.awt.geom.AffineTransform; +import java.awt.image.BufferedImage; +import java.io.File; + +import javax.imageio.ImageIO; + +/* + * @test + * @bug 8339974 + * @summary Verifies that text draws correctly using scaled and rotated fonts. + */ +public class RotatedScaledFontTest { + + public static void main(String[] args) throws Exception { + test(0); + test(1); + test(2); + test(3); + test(4); + } + + private static void test(int quadrants) throws Exception { + + int size = 2000; + int center = size / 2; + Font base = new Font("SansSerif", Font.PLAIN, 10); + BufferedImage image = new BufferedImage(size, size, BufferedImage.TYPE_BYTE_BINARY); + Graphics2D g2d = image.createGraphics(); + + try { + for (int scale = 1; scale <= 100; scale++) { + AffineTransform at = AffineTransform.getQuadrantRotateInstance(quadrants); + at.scale(scale, scale); + Font font = base.deriveFont(at); + g2d.setColor(Color.WHITE); + g2d.fillRect(0, 0, image.getWidth(), image.getHeight()); + g2d.setColor(Color.BLACK); + g2d.setFont(font); + g2d.drawString("TEST", center, center); + Rectangle bounds = findTextBoundingBox(image); + if (bounds == null) { + saveImage("bounds", image); + throw new RuntimeException("Text missing: scale=" + scale + + ", quadrants=" + quadrants + ", center=" + center); + } + boolean horizontal = (bounds.width > bounds.height); + boolean expectedHorizontal = (quadrants % 2 == 0); + if (horizontal != expectedHorizontal) { + saveImage("orientation", image); + throw new RuntimeException("Wrong orientation: scale=" + scale + + ", quadrants=" + quadrants + ", center=" + center + + ", bounds=" + bounds + ", horizontal=" + horizontal + + ", expectedHorizontal=" + expectedHorizontal); + } + if (!roughlyEqual(center, bounds.x, scale) && !roughlyEqual(center, bounds.x + bounds.width, scale)) { + saveImage("xedge", image); + throw new RuntimeException("No x-edge at center: scale=" + scale + + ", quadrants=" + quadrants + ", center=" + center + + ", bounds=" + bounds); + } + if (!roughlyEqual(center, bounds.y, scale) && !roughlyEqual(center, bounds.y + bounds.height, scale)) { + saveImage("yedge", image); + throw new RuntimeException("No y-edge at center: scale=" + scale + + ", quadrants=" + quadrants + ", center=" + center + + ", bounds=" + bounds); + } + } + } finally { + g2d.dispose(); + } + } + + private static Rectangle findTextBoundingBox(BufferedImage image) { + int minX = Integer.MAX_VALUE; + int minY = Integer.MAX_VALUE; + int maxX = Integer.MIN_VALUE; + int maxY = Integer.MIN_VALUE; + int width = image.getWidth(); + int height = image.getHeight(); + int[] rowPixels = new int[width]; + for (int y = 0; y < height; y++) { + image.getRGB(0, y, width, 1, rowPixels, 0, width); + for (int x = 0; x < width; x++) { + boolean white = (rowPixels[x] == -1); + if (!white) { + if (x < minX) { + minX = x; + } + if (y < minY) { + minY = y; + } + if (x > maxX) { + maxX = x; + } + if (y > maxY) { + maxY = y; + } + } + } + } + if (minX != Integer.MAX_VALUE) { + return new Rectangle(minX, minY, maxX - minX, maxY - minY); + } else { + return null; + } + } + + private static boolean roughlyEqual(int x1, int x2, int scale) { + return Math.abs(x1 - x2) <= Math.ceil(scale / 2d) + 1; // higher scale = higher allowed variance + } + + private static void saveImage(String name, BufferedImage image) { + try { + String dir = System.getProperty("test.classes", "."); + String path = dir + File.separator + name + ".png"; + File file = new File(path); + ImageIO.write(image, "png", file); + } catch (Exception e) { + // we tried, and that's enough + } + } +} diff --git a/test/jdk/java/awt/geom/Arc2D/Arc2DHitTest.java b/test/jdk/java/awt/geom/Arc2D/Arc2DHitTest.java new file mode 100644 index 00000000000..de6b39d5c6f --- /dev/null +++ b/test/jdk/java/awt/geom/Arc2D/Arc2DHitTest.java @@ -0,0 +1,100 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4178123 + * @summary Verifies that the Arc2D.contains(point) methods work correctly. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual Arc2DHitTest + */ + +import java.awt.Color; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Panel; +import java.awt.Point; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.geom.Arc2D; + +public class Arc2DHitTest { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + This test displays an arc figure and lets the user click on it. + The arc will initially be drawn in red and only when the user clicks + within the arc in the window it will be redrawn into green otherwise + it should stay red. + + For convenience, the point being tested is drawn in black. Note + that rounding in the arc rendering routines may cause points near + the boundary of the arc to render incorrectly. Allow for a pixel + or two of leeway near the boundary. + """; + + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(initialize()) + .build() + .awaitAndCheck(); + } + private static Frame initialize() { + Frame f = new Frame("Arc2DHitTest"); + ArcHitPanel panel = new ArcHitPanel(); + f.add(panel); + f.setSize(300, 250); + return f; + } +} + +class ArcHitPanel extends Panel { + private Arc2D arc; + private Point hit; + public ArcHitPanel() { + arc = new Arc2D.Float(10, 10, 100, 100, 0, 120, Arc2D.PIE); + this.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + hit = e.getPoint(); + repaint(); + } + }); + } + + @Override + public void paint(Graphics g) { + Graphics2D g2 = (Graphics2D) g; + g2.setColor(Color.white); + g2.fill(g2.getClipBounds()); + g2.setColor((hit != null && arc.contains(hit)) + ? Color.green : Color.red); + g2.fill(arc); + if (hit != null) { + g2.setColor(Color.black); + g2.fillRect(hit.x, hit.y, 1, 1); + } + } +} diff --git a/test/jdk/java/awt/geom/Arc2D/BoundsBug.java b/test/jdk/java/awt/geom/Arc2D/BoundsBug.java new file mode 100644 index 00000000000..a17f45f9dad --- /dev/null +++ b/test/jdk/java/awt/geom/Arc2D/BoundsBug.java @@ -0,0 +1,123 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4197746 + * @summary Verifies that the getBounds2D method of Arc2D returns the + * correct result. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual BoundsBug + */ + +import java.awt.Color; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Panel; +import java.awt.RenderingHints; +import java.awt.Shape; +import java.awt.geom.Arc2D; +import java.awt.geom.Ellipse2D; +import java.awt.geom.GeneralPath; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; + +public class BoundsBug { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + This test displays three figures and draws the outline of their + bounding boxes. The bounding boxes should correctly encompass + the 3 figures. + + This test also paints two highlight rectangles at the ends of the + angular extents of the arc. The two highlights should correctly + appear at the outer circumference of the arc where the radii lines + from its center intersect that circumference. + """; + + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(initialize()) + .build() + .awaitAndCheck(); + } + private static Frame initialize() { + Frame f = new Frame("BoundsBug"); + ArcPanel panel = new ArcPanel(); + f.add(panel); + f.setSize(300, 250); + return f; + } +} + +class ArcPanel extends Panel { + protected void drawPoint(Graphics2D g2, Point2D p) { + g2.setColor(Color.green); + g2.fill(new Rectangle2D.Double(p.getX() - 5, p.getY() - 5, 10, 10)); + } + + protected void drawShapeAndBounds(Graphics2D g2, Shape s) { + g2.setColor(Color.orange); + g2.fill(s); + g2.setColor(Color.black); + g2.draw(s); + + Rectangle2D r = s.getBounds2D(); + g2.setColor(Color.gray); + g2.draw(r); + } + + @Override + public void paint(Graphics g) { + Graphics2D g2 = (Graphics2D)g; + g2.setColor(Color.white); + g2.fill(g.getClipBounds()); + g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); + + // Create some interesting shapes. + Ellipse2D ellipse = new Ellipse2D.Float(20, 40, 60, 80); + Arc2D arc = new Arc2D.Float(60, 40, 100, 120, + -30, -40, Arc2D.PIE); + GeneralPath path = new GeneralPath(GeneralPath.WIND_EVEN_ODD); + path.moveTo(0, 0); + path.lineTo(75, -25); + path.lineTo(25, 75); + path.lineTo(0, 25); + path.lineTo(100, 50); + path.lineTo(50, 0); + path.lineTo(25, 50); + path.closePath(); + // Now draw them and their bounds rectangles. + drawShapeAndBounds(g2, ellipse); + drawShapeAndBounds(g2, arc); + drawPoint(g2, arc.getStartPoint()); + drawPoint(g2, arc.getEndPoint()); + g2.translate(180, 65); + drawShapeAndBounds(g2, path); + } +} diff --git a/test/jdk/java/awt/geom/Area/Translate.java b/test/jdk/java/awt/geom/Area/Translate.java new file mode 100644 index 00000000000..7519f1753bc --- /dev/null +++ b/test/jdk/java/awt/geom/Area/Translate.java @@ -0,0 +1,122 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4183373 + * @summary Verifies that the translated Area objects display correctly + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual Translate + */ + +import java.awt.BorderLayout; +import java.awt.CardLayout; +import java.awt.Color; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Image; +import java.awt.Panel; +import java.awt.Rectangle; +import java.awt.geom.AffineTransform; +import java.awt.geom.Area; +import java.awt.geom.Rectangle2D; + +public class Translate { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + This test displays two sets of rectangular figures. The two sets + should be displayed one on top of the other and should be lined + up vertically with each other. If the two sets of figures are + not directly above and below each other then the test fails + """; + + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .columns(35) + .testUI(initialize()) + .build() + .awaitAndCheck(); + } + private static Frame initialize() { + Frame f = new Frame("Translate"); + TranslatePanel panel = new TranslatePanel(); + f.add(panel); + f.setSize(300, 250); + return f; + } +} + +class TranslatePanel extends Panel { + private static Image bufferedImage; + private static Area a1, a2, a3; + + public TranslatePanel() { + a1 = new Area(new Rectangle2D.Double(20.0, 20.0, 60.0, 60.0)); + + a2 = new Area((Area) a1.clone()); + a2.subtract(new Area(new Rectangle2D.Double(30.0, 30.0, 40.0, 40.0))); + + a3 = new Area((Area) a2.clone()); + a3.add(new Area(new Rectangle2D.Double(40.0, 40.0, 20.0, 20.0))); + + AffineTransform at2 = new AffineTransform(); + at2.translate(100.0, 0.0); + a2.transform(at2); + + AffineTransform at3 = new AffineTransform(); + at3.translate(200.0, 0.0); + a3.transform(at3); + } + private void paintRects(Graphics2D g2) { + Rectangle clip = g2.getClipBounds(); + g2.setColor(Color.white); + g2.fillRect(clip.x, clip.y, clip.width, clip.height); + g2.setPaint(Color.red); + g2.fill(a1); + g2.setPaint(Color.yellow); + g2.fill(a2); + g2.setPaint(Color.blue); + g2.fill(a3); + } + + @Override + public void paint(Graphics g) { + if (bufferedImage == null) { + bufferedImage = createImage(300, 100); + Graphics big = bufferedImage.getGraphics(); + // Notice that if you remove the translate() call, it works fine. + big.translate(-1, -1); + big.setClip(1, 1, 300, 100); + paintRects((Graphics2D)big); + big.translate(1, 1); + } + paintRects((Graphics2D)g); + g.drawImage(bufferedImage, 1, 100, this); + g.setColor(Color.black); + g.drawString("From offscreen image (with translate):", 10, 95); + g.drawString(" (should line up with rectangles above)", 10, 110); + } +} diff --git a/test/jdk/java/awt/grab/CursorTest.java b/test/jdk/java/awt/grab/CursorTest.java new file mode 100644 index 00000000000..f08008cbd8f --- /dev/null +++ b/test/jdk/java/awt/grab/CursorTest.java @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2006, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6364746 6400007 + * @summary Cursor should be changed correctly while Swing menu is open (input is grabbed). + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual CursorTest +*/ + +import java.awt.FlowLayout; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JMenu; +import javax.swing.JMenuBar; +import javax.swing.JMenuItem; +import javax.swing.JPanel; +import javax.swing.JTextField; +import javax.swing.SwingUtilities; + +public class CursorTest { + + static final String INSTRUCTIONS = """ + After the test starts you will see a frame titled "Cursor Test Window", + with two menus in the menubar (menu1 and menu2), and a textfield and + a button, labeled "JButton". + 1. Open menu1 (it should be small and fit within the border of the frame), + 2. Verify that the pointer image (cursor) is the default desktop cursor. + 3. Move the mouse over the text field - the cursor should change its shape to caret, + 4. Move the mouse over the button - the cursor should be default one, + 5. Move the mouse to the border of the frame - cursor should be a resize one + (exact shape is dependent on the border you move over), + 6. Move the mouse out of the frame - cursor should be default one, + 7. Perform steps 2-6 in reverse order (after this the mouse should be over the open menu1), + 8. Open menu2, it should be big enough to not fit within the frame, + 9. Repeat steps 2-7 (you should end up with mouse over opened menu2 :), + 10. Close the menu. + 11. If on every step the cursor was as described, press Pass, press Fail otherwise. + """; + + static JFrame createUI() { + + JButton but = new JButton("JButton"); + JPanel panel = new JPanel(); + JTextField jtf = new JTextField("JTextField", 20); + + JFrame.setDefaultLookAndFeelDecorated(true); + JFrame frame = new JFrame("Cursor Test Window"); + frame.setLayout(new FlowLayout()); + panel.add(but); + + frame.getContentPane().add(jtf); + frame.getContentPane().add(panel); + + JMenu menu1 = new JMenu("menu1"); + menu1.add(new JMenuItem("menu1,item1")); + JMenuBar mb = new JMenuBar(); + mb.add(menu1); + JMenu menu2 = new JMenu("menu2"); + for (int i = 0; i < 10; i++) { + menu2.add(new JMenuItem("menu2,item"+i)); + } + mb.add(menu2); + frame.setJMenuBar(mb); + frame.pack(); + return frame; + } + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("Cursor Test") + .instructions(INSTRUCTIONS) + .columns(60) + .testUI(CursorTest::createUI) + .build() + .awaitAndCheck(); + + } +} diff --git a/test/jdk/java/awt/grab/SystemMenuTest.java b/test/jdk/java/awt/grab/SystemMenuTest.java new file mode 100644 index 00000000000..07676b31911 --- /dev/null +++ b/test/jdk/java/awt/grab/SystemMenuTest.java @@ -0,0 +1,141 @@ +/* + * Copyright (c) 2006, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6364741 + * @key headful + * @requires (os.family == "windows") + * @summary REG: Using frame's menu actions does not make swing menu disappear on WinXP, + * since Mustang-b53 + */ + +import java.awt.event.InputEvent; +import java.awt.event.KeyEvent; +import java.awt.Point; +import java.awt.Robot; +import javax.swing.JFrame; +import javax.swing.JMenu; +import javax.swing.JMenuBar; +import javax.swing.JMenuItem; +import javax.swing.SwingUtilities; +import javax.swing.event.MenuEvent; +import javax.swing.event.MenuListener; + +public class SystemMenuTest implements MenuListener { + + static volatile JMenu menu; + static volatile JMenu sub_menu; + static volatile JFrame frame; + + static volatile int selectCount = 0; + static volatile int deselectCount = 0; + static volatile boolean failed = false; + static volatile String reason = "none"; + + static void createUI() { + SystemMenuTest smt = new SystemMenuTest(); + sub_menu = new JMenu("SubMenu"); + sub_menu.addMenuListener(smt); + sub_menu.add(new JMenuItem("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")); + sub_menu.add(new JMenuItem("BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB")); + menu = new JMenu("Menu"); + menu.addMenuListener(smt); + menu.add(sub_menu); + JMenuBar mb = new JMenuBar(); + mb.add(menu); + + frame = new JFrame("JFrame"); + frame.setJMenuBar(mb); + frame.pack(); + frame.setVisible(true); + } + + public static void main(String[] args) throws Exception { + + Robot robot = new Robot(); + + SwingUtilities.invokeAndWait(SystemMenuTest::createUI); + + try { + robot.waitForIdle(); + robot.delay(2000); + + Point p = menu.getLocationOnScreen(); + robot.mouseMove(p.x + menu.getWidth() / 2, p.y + menu.getHeight() / 2); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.waitForIdle(); + robot.delay(2000); + + p = sub_menu.getLocationOnScreen(); + robot.mouseMove(p.x + sub_menu.getWidth() / 2, p.y + sub_menu.getHeight() /2 ); + robot.mousePress(InputEvent.BUTTON1_MASK); + robot.mouseRelease(InputEvent.BUTTON1_MASK); + robot.waitForIdle(); + robot.delay(2000); + + // Alt-Space to invoke System Menu, should close Swing menus. + robot.keyPress(KeyEvent.VK_ALT); + robot.keyPress(KeyEvent.VK_SPACE); + robot.delay(50); + robot.keyRelease(KeyEvent.VK_SPACE); + robot.keyRelease(KeyEvent.VK_ALT); + robot.waitForIdle(); + robot.delay(2000); + + if (selectCount != 2 || deselectCount != 2) { + throw new RuntimeException("unexpected selection count " + selectCount + ", " + deselectCount); + } + if (failed) { + throw new RuntimeException("Failed because " + reason); + } + } finally { + if (frame != null) { + SwingUtilities.invokeAndWait(frame::dispose); + } + } + } + + public void menuCanceled(MenuEvent e) { + System.out.println("cancelled"+e.getSource()); + } + + public void menuDeselected(MenuEvent e) { + deselectCount++; + if (selectCount != 2) { + failed = true; + reason = "deselect without two selects"; + } + System.out.println("deselected"+e.getSource()); + } + + public void menuSelected(MenuEvent e) { + if (deselectCount != 0) { + failed = true; + reason = "select without non-zero deselects"; + } + selectCount++; + System.out.println("selected"+e.getSource()); + } +} diff --git a/test/jdk/java/awt/image/BufferedImage/GrayAATextTest.java b/test/jdk/java/awt/image/BufferedImage/GrayAATextTest.java new file mode 100644 index 00000000000..a484dd392eb --- /dev/null +++ b/test/jdk/java/awt/image/BufferedImage/GrayAATextTest.java @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4309915 + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @summary Check that Antialiased text drawn on a BYTE_GRAY image + * resolves the color correctly + * @run main/manual GrayAATextTest + */ + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Panel; +import java.awt.RenderingHints; +import java.awt.image.BufferedImage; + +public class GrayAATextTest extends Panel { + + public static final int WIDTH = 600; + public static final int HEIGHT = 200; + + private static final String INSTRUCTIONS = """ + All of the strings in a given column should be drawn + in the same color. If the bug is present, then the + Antialiased strings will all be of a fixed color that + is not the same as the other strings in their column."""; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("GrayAATextTest Instructions") + .instructions(INSTRUCTIONS) + .rows((int)INSTRUCTIONS.lines().count() + 2) + .columns(35) + .testUI(GrayAATextTest::createTestUI) + .build() + .awaitAndCheck(); + } + + public void paint(Graphics g) { + BufferedImage bi = new BufferedImage(WIDTH, HEIGHT, + BufferedImage.TYPE_BYTE_GRAY); + Graphics2D g2d = bi.createGraphics(); + g2d.setFont(new Font("Helvetica", Font.PLAIN, 24)); + g2d.setColor(Color.white); + g2d.fillRect(0, 0, WIDTH / 2, HEIGHT); + drawText(g2d, Color.black, "Black", 25); + drawText(g2d, Color.lightGray, "Light Gray", 175); + g2d.setColor(Color.black); + g2d.fillRect(WIDTH / 2, 0, WIDTH / 2, HEIGHT); + drawText(g2d, Color.white, "White", 325); + drawText(g2d, Color.lightGray, "Light Gray", 475); + g2d.dispose(); + g.drawImage(bi, 0, 0, null); + } + + public void drawText(Graphics2D g2d, Color c, String colorname, int x) { + g2d.setColor(c); + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_OFF); + g2d.drawString(colorname, x, 50); + g2d.drawString("Aliased", x, 100); + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); + g2d.drawString("Antialiased", x, 150); + } + + public Dimension getPreferredSize() { + return new Dimension(WIDTH, HEIGHT); + } + + private static Frame createTestUI() { + Frame f = new Frame("GrayAATextTest Frame"); + f.add(new GrayAATextTest()); + f.setSize(WIDTH, HEIGHT); + return f; + } +} diff --git a/test/jdk/java/awt/image/GrayAlpha.java b/test/jdk/java/awt/image/GrayAlpha.java new file mode 100644 index 00000000000..cf477c26385 --- /dev/null +++ b/test/jdk/java/awt/image/GrayAlpha.java @@ -0,0 +1,175 @@ +/* + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 4243044 + * @summary This test should show two windows filled with checker + * board pattern. The transparency should runs from left to right from + * total transparent to total opaque. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual GrayAlpha + */ + +import java.util.List; +import java.awt.Frame; +import java.awt.color.ColorSpace; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.geom.AffineTransform; +import java.awt.image.BufferedImage; +import java.awt.image.ColorModel; +import java.awt.image.ComponentColorModel; +import java.awt.image.DataBuffer; +import java.awt.image.Raster; +import java.awt.image.WritableRaster; +import java.awt.Point; +import java.awt.Panel; +import java.awt.Transparency; +import java.awt.Window; + +public class GrayAlpha extends Panel { + + private static final String INSTRUCTIONS = """ + This test should show two windows filled with checker board + vpattern. The transparency should runs from left to right from + totally transparent to totally opaque. If either the pattern or + the transparency is not shown correctly, click Fail, otherwise + click Pass."""; + + BufferedImage bi; + AffineTransform identityTransform = new AffineTransform(); + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("GrayAlpha Instructions") + .instructions(INSTRUCTIONS) + .rows((int)INSTRUCTIONS.lines().count() + 2) + .columns(35) + .testUI(GrayAlpha::createTestUI) + .build() + .awaitAndCheck(); + } + + + public GrayAlpha(int width, int height, + boolean hasAlpha, boolean isAlphaPremultiplied, + boolean useRGB) { + boolean isAlphaPremuliplied = true; + int bands = useRGB ? 3 : 1; + bands = hasAlpha ? bands + 1 : bands; + + ColorSpace cs = useRGB ? + ColorSpace.getInstance(ColorSpace.CS_sRGB) : + ColorSpace.getInstance(ColorSpace.CS_GRAY); + int transparency = hasAlpha ? + Transparency.TRANSLUCENT : Transparency.OPAQUE; + int[] bits = new int[bands]; + for (int i = 0; i < bands; i++) { + bits[i] = 8; + } + + ColorModel cm = new ComponentColorModel(cs, + bits, + hasAlpha, + isAlphaPremultiplied, + transparency, + DataBuffer.TYPE_BYTE); + WritableRaster wr = + Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE, + width, height, bands, + new Point(0, 0)); + + for (int b = 0; b < bands; b++) { + for (int y = 0; y < height; y++) { + for (int x = 0; x < width; x++) { + int s; + + if (b != bands - 1 || !hasAlpha) { + // Gray band(s), fill with a checkerboard pattern + if (((x / 10) % 2) == ((y / 10) % 2)) { + s = 255; + } else { + s = 0; + } + if (isAlphaPremultiplied) { + int alpha = (x*255)/(width - 1); + s = (s*alpha)/255; + } + } else { + // Alpha band, increase opacity left to right + s = (x*255)/(width - 1); + } + + wr.setSample(x, y, b, s); + } + } + } + + this.bi = new BufferedImage(cm, wr, isAlphaPremultiplied, null); + } + + public Dimension getPreferredSize() { + return new Dimension(bi.getWidth(), bi.getHeight()); + } + + public void paint(Graphics g) { + if (bi != null) { + ((Graphics2D)g).drawImage(bi, 0, 0, null); + } + } + + public static Frame makeFrame(String title, + int x, int y, int width, int height, + boolean hasAlpha, + boolean isAlphaPremultiplied, + boolean useRGB) { + Frame f = new Frame(title); + f.add(new GrayAlpha(width, height, + hasAlpha, isAlphaPremultiplied, useRGB)); + f.pack(); + f.setLocation(x, y); + return f; + } + + private static List createTestUI() { + int width = 200; + int height = 200; + + int x = 100; + int y = 100; + + Frame f1 = makeFrame("Gray (non-premultiplied)", + x, y, width, height, + true, false, false); + x += width + 20; + + Frame f2 = makeFrame("Gray (premultiplied)", + x, y, width, height, + true, true, false); + + return List.of(f1, f2); + } +} diff --git a/test/jdk/java/awt/image/ImageOffsetTest.java b/test/jdk/java/awt/image/ImageOffsetTest.java new file mode 100644 index 00000000000..c1d4c3931de --- /dev/null +++ b/test/jdk/java/awt/image/ImageOffsetTest.java @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4259548 + * @summary tests that MemoryImageSource correctly handles images with offsets + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual ImageOffsetTest + */ + +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Image; +import java.awt.Panel; +import java.awt.Toolkit; +import java.awt.image.ColorModel; +import java.awt.image.IndexColorModel; +import java.awt.image.MemoryImageSource; + +public class ImageOffsetTest { + + static int height = 100; + static int width = 100; + static int levels = 3; + static IndexColorModel cm; + static Image image; + static boolean first = true; + + static byte[] db = new byte[height * width * levels] ; + + private static final String INSTRUCTIONS = """ + If on the appeared 'Test frame' all color squares are of one color + test failed, otherwise it's passed."""; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("ImageOffsetTest") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(35) + .testUI(ImageOffsetTest::createUI) + .build() + .awaitAndCheck(); + } + + private static Frame createUI() { + Frame frame = new Frame("ImageOffset Frame"); + frame.add(new Panel() { + public void paint(Graphics g) { + for ( int i=0 ; i<3 ; i++ ) { + g.drawImage( + generateBuggyImage(i * width * height), 10 + i * 110, 10, null); + } + } + }); + frame.setSize(400, 200); + frame.setLocation(300, 200); + createColorModel(); + int l = 0; + for (int k = 0; k < levels; k++) { + for (int i = 0; i < height; i++) { + for (int j = 0; j < width; j++) { + if( k == 0) { + db[l] = (byte)(70 & 0xff) ; + } + if (k == 1) { + db[l] = (byte)(150 & 0xff) ; + } + if (k == 2) { + db[l] = (byte)(230 & 0xff) ; + } + l++ ; + } + } + } + return frame; + } + + private static void createColorModel() { + byte[] red = new byte[256]; + byte[] green = new byte[256]; + byte[] blue = new byte[256]; + + for (int i = 0; i < 256; i++) { + red[i] = (byte)(i & 0xff); + //green[i] = (byte)( i & 0xff ) ; + blue[i] = (byte)( i & 0xff ) ; + //commented out green so I could get purple + } + + cm = new IndexColorModel( 8, 256, red, green, blue ) ; + } + + private static Image generateBuggyImage(int offset) { + // Initialize the database, Three slices, different shades of grey + // Here the image is created using the offset, + return Toolkit.getDefaultToolkit().createImage( + new MemoryImageSource(width, height, (ColorModel)cm, + db, offset, width)); + } +} diff --git a/test/jdk/java/awt/image/TransformImage.java b/test/jdk/java/awt/image/TransformImage.java new file mode 100644 index 00000000000..30af3d27f55 --- /dev/null +++ b/test/jdk/java/awt/image/TransformImage.java @@ -0,0 +1,111 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4090743 + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @summary Make sure that there is no garbage drawn on the rotated image + * @run main/manual TransformImage + */ + +import java.net.URL; +import java.net.MalformedURLException; +import java.awt.Canvas; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.geom.AffineTransform; +import java.awt.Image; +import java.awt.image.ImageObserver; +import java.awt.MediaTracker; +import java.awt.Toolkit; + +public class TransformImage extends Canvas { + static Image image; + + private static final String INSTRUCTIONS = """ + The rotated image should be drawn without garbage."""; + + public static void main(String[] argv) throws Exception { + PassFailJFrame.builder() + .title("TransformImage Instructions") + .instructions(INSTRUCTIONS) + .rows(5) + .columns(35) + .testUI(TransformImage::createTestUI) + .build() + .awaitAndCheck(); + } + + private static Frame createTestUI() { + Frame f = new Frame(); + String dir = System.getProperty("test.src"); + String sep = System.getProperty("file.separator"); + if (dir == null) { + dir = "."; + } + image = Toolkit.getDefaultToolkit().getImage(dir+sep+"duke.gif"); + f.add(new TransformImage()); + + f.pack(); + return f; + } + + public Dimension getPreferredSize() { + return new Dimension (256, 256); + } + + public Dimension getMinimumSize() { + return getPreferredSize(); + } + + public void paint(Graphics g) { + int w, h; + java.awt.Graphics2D g2d = (Graphics2D) g; + AffineTransform at = new AffineTransform(); + + MediaTracker mt = new MediaTracker(this); + mt.addImage(image, 0); + try { + mt.waitForAll(); + } catch (InterruptedException e) { + System.err.println("can't track"); + return; + } + w = image.getWidth(this); + h = image.getHeight(this); + g2d.drawImage(image, 0, 0, this); + g2d.drawRect(0, 0, w, h); + + double rad = .5; + at.rotate(-rad); + g2d.setTransform(at); + g2d.drawImage(image, 0, 100, this); + g2d.drawRect(0, 100, w, h); + } +} diff --git a/test/jdk/java/awt/image/duke.gif b/test/jdk/java/awt/image/duke.gif new file mode 100644 index 00000000000..ed32e0ff79b Binary files /dev/null and b/test/jdk/java/awt/image/duke.gif differ diff --git a/test/jdk/java/awt/regtesthelpers/PassFailJFrame.java b/test/jdk/java/awt/regtesthelpers/PassFailJFrame.java index dd94081c354..41c5fdf8ccd 100644 --- a/test/jdk/java/awt/regtesthelpers/PassFailJFrame.java +++ b/test/jdk/java/awt/regtesthelpers/PassFailJFrame.java @@ -24,6 +24,7 @@ import java.awt.AWTException; import java.awt.BorderLayout; import java.awt.Dimension; +import java.awt.FlowLayout; import java.awt.Font; import java.awt.GraphicsConfiguration; import java.awt.GraphicsDevice; @@ -44,6 +45,7 @@ import java.awt.image.RenderedImage; import java.io.File; import java.io.IOException; import java.lang.reflect.InvocationTargetException; +import java.nio.file.Paths; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -69,24 +71,88 @@ import javax.swing.JScrollPane; import javax.swing.JSplitPane; import javax.swing.JTextArea; import javax.swing.Timer; +import javax.swing.border.Border; import javax.swing.text.JTextComponent; import javax.swing.text.html.HTMLEditorKit; import javax.swing.text.html.StyleSheet; import static java.util.Collections.unmodifiableList; +import static javax.swing.BorderFactory.createEmptyBorder; import static javax.swing.SwingUtilities.invokeAndWait; import static javax.swing.SwingUtilities.isEventDispatchThread; /** - * Provides a framework for manual tests to display test instructions and - * Pass/Fail buttons. + * A framework for manual tests to display test instructions and + * Pass / Fail buttons. The framework automatically + * creates a frame to display the instructions, provides buttons + * to select the test result, and handles test timeout. + * + *

                    + * The instruction UI frame displays a timer at the top which indicates + * how much time is left. The timer can be paused using the Pause + * button to the right of the time; the title of the button changes to + * Resume. To resume the timer, use the Resume button. + * + *

                    + * In the center, the instruction UI frame displays instructions for the + * tester. The instructions can be either plain text or HTML. If the + * text of the instructions starts with {@code ""}, the + * instructions are displayed as HTML, as supported by Swing, which + * provides richer formatting options. *

                    - * Instructions for the user can be either plain text or HTML as supported - * by Swing. If the instructions start with {@code }, the - * instructions are displayed as HTML. + * The instructions are displayed in a text component with word-wrapping + * so that there's no horizontal scroll bar. If the text doesn't fit, a + * vertical scroll bar is shown. Use {@code rows} and {@code columns} + * parameters to change the size of this text component. + * If possible, choose the number of rows and columns so that + * the instructions fit and no scroll bars are shown. + * + *

                    + * At the bottom, the instruction UI frame displays the + * Pass and Fail buttons. The tester clicks either Pass + * or Fail button to finish the test. When the tester clicks the + * Fail button, the framework displays a dialog box prompting for + * a reason why the test fails. The tester enters the reason and clicks + * OK to close the dialog and fail the test, + * or simply closes the dialog to fail the test without providing any reason. + * + *

                    + * If you enable the screenshot feature, a Screenshot button is + * added to the right of the Fail button. The tester can choose either + * Capture Full Screen (default) or Capture Frames and click the + * Screenshot button to take a screenshot. + * If there are multiple screens, screenshots of each screen are created. + * If the tester selects the Capture Frames mode, screenshots of all + * the windows or frames registered in the {@code PassFailJFrame} framework + * are created. + * + *

                    + * If you enable a log area, the instruction UI frame adds a text component + * to display log messages below the buttons. + * Use {@link #log(String) log}, {@link #logSet(String) logSet} + * and {@link #logClear() logClear} static methods of {@code PassFailJFrame} + * to add or clear messages from the log area. + * + *

                    + * After you create an instance of {@code PassFailJFrame}, call the + * {@link #awaitAndCheck() awaitAndCheck} method to stop the current thread + * (usually the main thread) and wait until the tester clicks + * either Pass or Fail button, + * or until the test times out. *

                    + * The call to the {@code awaitAndCheck} method is usually the last + * statement in the {@code main} method of your test. + * If the test fails, an exception is thrown to signal the failure to jtreg. + * The test fails if the tester clicks the Fail button, + * if the timeout occurs, + * or if any window or frame is closed. + *

                    + * Before returning from {@code awaitAndCheck}, the framework disposes of + * all the windows and frames. + * + *

                    Sample Manual Test

                    * A simple test would look like this: - *
                    {@code
                    + * {@snippet id='sampleManualTestCode' lang='java':
                      * public class SampleManualTest {
                      *     private static final String INSTRUCTIONS =
                      *             "Click Pass, or click Fail if the test failed.";
                    @@ -94,7 +160,7 @@ import static javax.swing.SwingUtilities.isEventDispatchThread;
                      *     public static void main(String[] args) throws Exception {
                      *         PassFailJFrame.builder()
                      *                       .instructions(INSTRUCTIONS)
                    - *                       .testUI(() -> createTestUI())
                    + *                       .testUI(SampleManualTest::createTestUI)
                      *                       .build()
                      *                       .awaitAndCheck();
                      *     }
                    @@ -105,39 +171,87 @@ import static javax.swing.SwingUtilities.isEventDispatchThread;
                      *         return testUI;
                      *     }
                      * }
                    - * }
                    + * } *

                    - * The above example uses the {@link Builder Builder} to set the parameters of - * the instruction frame. It is the recommended way. + * The above example uses the {@link Builder Builder} class to set + * the parameters of the instruction frame. + * It is the recommended way. + * *

                    - * The framework will create instruction UI, it will call - * the provided {@code createTestUI} on the Event Dispatch Thread (EDT), - * and it will automatically position the test UI and make it visible. + * The framework will create an instruction UI frame, it will call + * the provided {@code createTestUI} on the Event Dispatch Thread (EDT), + * and it will automatically position the test UI frame and make it visible. + * + *

                    + * Add the following jtreg tags before the test class declaration + * {@snippet : + * /* + * * @test + * * @summary Sample manual test + * * @library /java/awt/regtesthelpers + * * @build PassFailJFrame + * * @run main/manual SampleManualTest + * } + * and the closing comment tag */. *

                    + * The {@code @library} tag points to the location of the + * {@code PassFailJFrame} class in the source code; + * the {@code @build} tag makes jtreg compile the {@code PassFailJFrame} class, + * and finally the {@code @run} tag specifies it is a manual + * test and the class to run. + * + *

                    Using {@code Builder}

                    + * Use methods of the {@link Builder Builder} class to set or change + * parameters of {@code PassFailJFrame} and its instruction UI: + *
                      + *
                    • {@link Builder#title(String) title} sets + * the title of the instruction UI + * (the default is {@value #TITLE});
                    • + *
                    • {@link Builder#testTimeOut(long) testTimeOut} sets + * the timeout of the test + * (the default is {@value #TEST_TIMEOUT});
                    • + *
                    • {@link Builder#rows(int) rows} and + * {@link Builder#columns(int) columns} control the size + * the text component which displays the instructions + * (the default number of rows is the number of lines in the text + * of the instructions, + * the default number of columns is {@value #COLUMNS});
                    • + *
                    • {@link Builder#logArea() logArea} adds a log area;
                    • + *
                    • {@link Builder#screenCapture() screenCapture} + * enables screenshots.
                    • + *
                    + * + *

                    Using {@code testUI} and {@code splitUI}

                    * The {@code Builder.testUI} methods accept interfaces which create one window * or a list of windows if the test needs multiple windows, * or directly a single window, an array of windows or a list of windows. *

                    - * For simple test UI, use {@code Builder.splitUI}, or explicitly - * {@code Builder.splitUIRight} or {@code Builder.splitUIBottom} with - * a {@code PanelCreator}. The framework will call the provided - * {@code createUIPanel} to create the component with test UI and + * For simple test UI, use {@link Builder#splitUI(PanelCreator) splitUI}, + * or explicitly + * {@link Builder#splitUIRight(PanelCreator) splitUIRight} or + * {@link Builder#splitUIBottom(PanelCreator) splitUIBottom} with + * a {@link PanelCreator PanelCreator}. + * The framework will call the provided + * {@code createUIPanel} method to create the component with test UI and * will place it as the right or bottom component in a split pane * along with instruction UI. *

                    + * Note: support for multiple windows is incomplete. + * + *

                    Obsolete Sample Test

                    * Alternatively, use one of the {@code PassFailJFrame} constructors to * create an object, then create secondary test UI, register it * with {@code PassFailJFrame}, position it and make it visible. * The following sample demonstrates it: - *
                    {@code
                    - * public class SampleOldManualTest {
                    + * {@snippet id='obsoleteSampleTestCode' lang='java':
                    + * public class ObsoleteManualTest {
                      *     private static final String INSTRUCTIONS =
                      *             "Click Pass, or click Fail if the test failed.";
                      *
                      *     public static void main(String[] args) throws Exception {
                      *         PassFailJFrame passFail = new PassFailJFrame(INSTRUCTIONS);
                      *
                    - *         SwingUtilities.invokeAndWait(() -> createTestUI());
                    + *         SwingUtilities.invokeAndWait(ObsoleteManualTest::createTestUI);
                      *
                      *         passFail.awaitAndCheck();
                      *     }
                    @@ -150,31 +264,54 @@ import static javax.swing.SwingUtilities.isEventDispatchThread;
                      *         testUI.setVisible(true);
                      *     }
                      * }
                    - * }
                    + * } *

                    - * Use methods of the {@code Builder} class or constructors of the - * {@code PassFailJFrame} class to control other parameters: - *

                      - *
                    • the title of the instruction UI,
                    • - *
                    • the timeout of the test,
                    • - *
                    • the size of the instruction UI via rows and columns, and
                    • - *
                    • to add a log area
                    • , - *
                    • to enable screenshots.
                    • - *
                    + * This sample uses {@link #PassFailJFrame(String) a constructor} of + * {@code PassFailJFrame} to create its instance, + * there are several overloads provided which allow changing other parameters. + *

                    + * When you use the constructors, you have to explicitly create + * your test UI window on EDT. After you create the window, + * you need to register it with the framework using + * {@link #addTestWindow(Window) addTestWindow} + * to ensure the window is disposed of when the test completes. + * Before showing the window, you have to call + * {@link #positionTestWindow(Window, Position) positionTestWindow} + * to position the test window near the instruction UI frame provided + * by the framework. And finally you have to explicitly show the test UI + * window by calling {@code setVisible(true)}. + *

                    + * To avoid the complexity, use the {@link Builder Builder} class + * which provides a streamlined way to configure and create an + * instance of {@code PassFailJFrame}. + *

                    + * Consider updating tests which use {@code PassFailJFrame} constructors to + * use the builder pattern. */ public final class PassFailJFrame { - private static final String TITLE = "Test Instruction Frame"; + /** A default title for the instruction frame. */ + private static final String TITLE = "Test Instructions"; + + /** A default test timeout. */ private static final long TEST_TIMEOUT = 5; + + /** A default number of rows for displaying the test instructions. */ private static final int ROWS = 10; + /** A default number of columns for displaying the test instructions. */ private static final int COLUMNS = 40; + /** + * A gap between windows. + */ + public static final int WINDOW_GAP = 8; + /** * Prefix for the user-provided failure reason. */ private static final String FAILURE_REASON = "Failure Reason:\n"; /** - * The failure reason message when the user didn't provide one. + * The failure reason message when the user doesn't provide one. */ private static final String EMPTY_REASON = "(no reason provided)"; @@ -212,90 +349,172 @@ public final class PassFailJFrame { public enum Position {HORIZONTAL, VERTICAL, TOP_LEFT_CORNER} - public PassFailJFrame(String instructions) throws InterruptedException, - InvocationTargetException { + /** + * Constructs a frame which displays test instructions and + * the Pass / Fail buttons with the given instructions, and + * the default timeout of {@value #TEST_TIMEOUT} minutes, + * the default title of {@value #TITLE} and + * the default values of {@value #ROWS} and {@value #COLUMNS} + * for rows and columns. + *

                    + * See {@link #PassFailJFrame(String,String,long,int,int,boolean)} for + * more details. + * + * @param instructions the instructions for the tester + * + * @throws InterruptedException if the current thread is interrupted + * while waiting for EDT to finish creating UI components + * @throws InvocationTargetException if an exception is thrown while + * creating UI components on EDT + */ + public PassFailJFrame(String instructions) + throws InterruptedException, InvocationTargetException { this(instructions, TEST_TIMEOUT); } - public PassFailJFrame(String instructions, long testTimeOut) throws - InterruptedException, InvocationTargetException { + /** + * Constructs a frame which displays test instructions and + * the Pass / Fail buttons + * with the given instructions and timeout as well as + * the default title of {@value #TITLE} + * and the default values of {@value #ROWS} and {@value #COLUMNS} + * for rows and columns. + *

                    + * See {@link #PassFailJFrame(String,String,long,int,int,boolean)} for + * more details. + * + * @param instructions the instructions for the tester + * @param testTimeOut the test timeout in minutes + * + * @throws InterruptedException if the current thread is interrupted + * while waiting for EDT to finish creating UI components + * @throws InvocationTargetException if an exception is thrown while + * creating UI components on EDT + */ + public PassFailJFrame(String instructions, long testTimeOut) + throws InterruptedException, InvocationTargetException { this(TITLE, instructions, testTimeOut); } + /** + * Constructs a frame which displays test instructions and + * the Pass / Fail buttons + * with the given title, instructions and timeout as well as + * the default values of {@value #ROWS} and {@value #COLUMNS} + * for rows and columns. + * The screenshot feature is not enabled, if you use this constructor. + *

                    + * See {@link #PassFailJFrame(String,String,long,int,int,boolean)} for + * more details. + * + * @param title the title of the instruction frame + * @param instructions the instructions for the tester + * @param testTimeOut the test timeout in minutes + * + * @throws InterruptedException if the current thread is interrupted + * while waiting for EDT to finish creating UI components + * @throws InvocationTargetException if an exception is thrown while + * creating UI components on EDT + */ public PassFailJFrame(String title, String instructions, - long testTimeOut) throws InterruptedException, - InvocationTargetException { + long testTimeOut) + throws InterruptedException, InvocationTargetException { this(title, instructions, testTimeOut, ROWS, COLUMNS); } /** - * Constructs a JFrame with a given title & serves as test instructional - * frame where the user follows the specified test instruction in order - * to test the test case & mark the test pass or fail. If the expected - * result is seen then the user click on the 'Pass' button else click - * on the 'Fail' button and the reason for the failure should be - * specified in the JDialog JTextArea. + * Constructs a frame which displays test instructions and + * the Pass / Fail buttons + * with the given title, instructions, timeout, number of rows and columns. + * The screenshot feature is not enabled, if you use this constructor. + *

                    + * See {@link #PassFailJFrame(String,String,long,int,int,boolean)} for + * more details. * - * @param title title of the Frame. - * @param instructions the instruction for the tester on how to test - * and what is expected (pass) and what is not - * expected (fail). - * @param testTimeOut test timeout where time is specified in minutes. - * @param rows number of visible rows of the JTextArea where the - * instruction is show. - * @param columns Number of columns of the instructional - * JTextArea - * @throws InterruptedException exception thrown when thread is - * interrupted + * @param title the title of the instruction frame + * @param instructions the instructions for the tester + * @param testTimeOut the test timeout in minutes + * @param rows the number of rows for the text component + * which displays test instructions + * @param columns the number of columns for the text component + * which displays test instructions + * + * @throws InterruptedException if the current thread is interrupted + * while waiting for EDT to finish creating UI components * @throws InvocationTargetException if an exception is thrown while - * creating the test instruction frame on - * EDT + * creating UI components on EDT */ - public PassFailJFrame(String title, String instructions, long testTimeOut, - int rows, int columns) throws InterruptedException, - InvocationTargetException { + public PassFailJFrame(String title, String instructions, + long testTimeOut, + int rows, int columns) + throws InterruptedException, InvocationTargetException { this(title, instructions, testTimeOut, rows, columns, false); } /** - * Constructs a JFrame with a given title & serves as test instructional - * frame where the user follows the specified test instruction in order - * to test the test case & mark the test pass or fail. If the expected - * result is seen then the user click on the 'Pass' button else click - * on the 'Fail' button and the reason for the failure should be - * specified in the JDialog JTextArea. + * Constructs a frame which displays test instructions and + * the Pass / Fail buttons + * as well as supporting UI components with the given title, instructions, + * timeout, number of rows and columns, + * and screen capture functionality. + * All the UI components are created on the EDT, so it is safe to call + * the constructor on the main thread. *

                    - * The test instruction frame also provides a way for the tester to take - * a screenshot (full screen or individual frame) if this feature - * is enabled by passing {@code true} as {@code enableScreenCapture} - * parameter. + * After you create a test UI window, register the window using + * {@link #addTestWindow(Window) addTestWindow} for disposal, and + * position it close to the instruction frame using + * {@link #positionTestWindow(Window, Position) positionTestWindow}. + * As the last step, make your test UI window visible. + *

                    + * Call the {@link #awaitAndCheck() awaitAndCheck} method on the instance + * of {@code PassFailJFrame} when you set up the testing environment. + *

                    + * If the tester clicks the Fail button, a dialog prompting for + * a description of the problem is displayed, and then an exception + * is thrown which fails the test. + * If the tester clicks the Pass button, the test completes + * successfully. + * If the timeout occurs or the instruction frame is closed, + * the test fails. + *

                    + * The {@code rows} and {@code columns} parameters control + * the size of a text component which displays the instructions. + * The preferred size of the instructions is calculated by + * creating {@code new JTextArea(rows, columns)}. + *

                    + * If you enable screenshots by setting the {@code screenCapture} + * parameter to {@code true}, a Screenshot button is added. + * Clicking the Screenshot button takes screenshots of + * all the monitors or all the windows registered with + * {@code PassFailJFrame}. * - * @param title title of the Frame. - * @param instructions the instruction for the tester on how to test - * and what is expected (pass) and what is not - * expected (fail). - * @param testTimeOut test timeout where time is specified in minutes. - * @param rows number of visible rows of the JTextArea where the - * instruction is show. - * @param columns Number of columns of the instructional - * JTextArea - * @param enableScreenCapture if set to true, 'Capture Screen' button & its - * associated UIs are added to test instruction - * frame - * @throws InterruptedException exception thrown when thread is - * interrupted + * @param title the title of the instruction frame + * @param instructions the instructions for the tester + * @param testTimeOut the test timeout in minutes + * @param rows the number of rows for the text component + * which displays test instructions + * @param columns the number of columns for the text component + * which displays test instructions + * @param screenCapture if set to {@code true}, enables screen capture + * functionality + * + * @throws InterruptedException if the current thread is interrupted + * while waiting for EDT to finish creating UI components * @throws InvocationTargetException if an exception is thrown while - * creating the test instruction frame on - * EDT + * creating UI components on EDT + * + * @see JTextArea#JTextArea(int,int) JTextArea(int rows, int columns) + * @see Builder Builder */ - public PassFailJFrame(String title, String instructions, long testTimeOut, + public PassFailJFrame(String title, String instructions, + long testTimeOut, int rows, int columns, - boolean enableScreenCapture) + boolean screenCapture) throws InterruptedException, InvocationTargetException { invokeOnEDT(() -> createUI(title, instructions, testTimeOut, rows, columns, - enableScreenCapture)); + screenCapture)); } /** @@ -348,11 +567,9 @@ public final class PassFailJFrame { builder.positionWindows .positionTestWindows(unmodifiableList(builder.testWindows), builder.instructionUIHandler)); - } else if (builder.testWindows.size() == 1) { + } else { Window window = builder.testWindows.get(0); positionTestWindow(window, builder.position); - } else { - positionTestWindow(null, builder.position); } } showAllWindows(); @@ -447,6 +664,8 @@ public final class PassFailJFrame { boolean addLogArea, int logAreaRows) { JPanel main = new JPanel(new BorderLayout()); + main.setBorder(createFrameBorder()); + timeoutHandlerPanel = new TimeoutHandlerPanel(testTimeOut); main.add(timeoutHandlerPanel, BorderLayout.NORTH); @@ -455,7 +674,11 @@ public final class PassFailJFrame { : configurePlainText(instructions, rows, columns); text.setEditable(false); - main.add(new JScrollPane(text), BorderLayout.CENTER); + JPanel textPanel = new JPanel(new BorderLayout()); + textPanel.setBorder(createEmptyBorder(GAP, 0, GAP, 0)); + textPanel.add(new JScrollPane(text), BorderLayout.CENTER); + + main.add(textPanel, BorderLayout.CENTER); JButton btnPass = new JButton("Pass"); btnPass.addActionListener((e) -> { @@ -469,7 +692,8 @@ public final class PassFailJFrame { timeoutHandlerPanel.stop(); }); - JPanel buttonsPanel = new JPanel(); + JPanel buttonsPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, + GAP, 0)); buttonsPanel.add(btnPass); buttonsPanel.add(btnFail); @@ -480,10 +704,12 @@ public final class PassFailJFrame { if (addLogArea) { logArea = new JTextArea(logAreaRows, columns); logArea.setEditable(false); + logArea.setBorder(createTextBorder()); Box buttonsLogPanel = Box.createVerticalBox(); buttonsLogPanel.add(buttonsPanel); + buttonsLogPanel.add(Box.createVerticalStrut(GAP)); buttonsLogPanel.add(new JScrollPane(logArea)); main.add(buttonsLogPanel, BorderLayout.SOUTH); @@ -501,6 +727,7 @@ public final class PassFailJFrame { JTextArea text = new JTextArea(instructions, rows, columns); text.setLineWrap(true); text.setWrapStyleWord(true); + text.setBorder(createTextBorder()); return text; } @@ -522,6 +749,29 @@ public final class PassFailJFrame { return text; } + /** A default gap between components. */ + private static final int GAP = 4; + + /** + * Creates a default border for frames or dialogs. + * It uses the default gap of {@value GAP}. + * + * @return the border for frames and dialogs + */ + private static Border createFrameBorder() { + return createEmptyBorder(GAP, GAP, GAP, GAP); + } + + /** + * Creates a border set to text area. + * It uses the default gap of {@value GAP}. + * + * @return the border for text area + */ + private static Border createTextBorder() { + return createEmptyBorder(GAP, GAP, GAP, GAP); + } + /** * Creates a test UI window. @@ -587,7 +837,7 @@ public final class PassFailJFrame { * @param testWindows the list of test windows * @param instructionUI information about the instruction frame */ - void positionTestWindows(List testWindows, + void positionTestWindows(List testWindows, InstructionUI instructionUI); } @@ -735,7 +985,7 @@ public final class PassFailJFrame { private static JComponent createCapturePanel() { JComboBox screenShortType = new JComboBox<>(CaptureType.values()); - JButton capture = new JButton("ScreenShot"); + JButton capture = new JButton("Screenshot"); capture.addActionListener((e) -> captureScreen((CaptureType) screenShortType.getSelectedItem())); @@ -747,7 +997,7 @@ public final class PassFailJFrame { private enum CaptureType { FULL_SCREEN("Capture Full Screen"), - WINDOWS("Capture Individual Frame"); + WINDOWS("Capture Frames"); private final String type; CaptureType(String type) { @@ -873,26 +1123,30 @@ public final class PassFailJFrame { * Requests the description of the test failure reason from the tester. */ private static void requestFailureReason() { - final JDialog dialog = new JDialog(frame, "Test Failure ", true); - dialog.setTitle("Failure reason"); - JPanel jPanel = new JPanel(new BorderLayout()); - JTextArea jTextArea = new JTextArea(5, 20); + final JDialog dialog = new JDialog(frame, "Failure reason", true); + + JTextArea reason = new JTextArea(5, 20); + reason.setBorder(createTextBorder()); JButton okButton = new JButton("OK"); okButton.addActionListener((ae) -> { - String text = jTextArea.getText(); + String text = reason.getText(); setFailureReason(FAILURE_REASON + (!text.isEmpty() ? text : EMPTY_REASON)); dialog.setVisible(false); }); - jPanel.add(new JScrollPane(jTextArea), BorderLayout.CENTER); - - JPanel okayBtnPanel = new JPanel(); + JPanel okayBtnPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, + GAP, 0)); + okayBtnPanel.setBorder(createEmptyBorder(GAP, 0, 0, 0)); okayBtnPanel.add(okButton); - jPanel.add(okayBtnPanel, BorderLayout.SOUTH); - dialog.add(jPanel); + JPanel main = new JPanel(new BorderLayout()); + main.setBorder(createFrameBorder()); + main.add(new JScrollPane(reason), BorderLayout.CENTER); + main.add(okayBtnPanel, BorderLayout.SOUTH); + + dialog.add(main); dialog.setLocationRelativeTo(frame); dialog.pack(); dialog.setVisible(true); @@ -925,13 +1179,13 @@ public final class PassFailJFrame { switch (position) { case HORIZONTAL: - int newX = ((screenSize.width / 2) - frame.getWidth()); + int newX = (((screenSize.width + WINDOW_GAP) / 2) - frame.getWidth()); frame.setLocation((newX + screenInsets.left), (frame.getY() + screenInsets.top)); break; case VERTICAL: - int newY = ((screenSize.height / 2) - frame.getHeight()); + int newY = (((screenSize.height + WINDOW_GAP) / 2) - frame.getHeight()); frame.setLocation((frame.getX() + screenInsets.left), (newY + screenInsets.top)); break; @@ -979,13 +1233,13 @@ public final class PassFailJFrame { switch (position) { case HORIZONTAL: case TOP_LEFT_CORNER: - testWindow.setLocation((frame.getX() + frame.getWidth() + 5), + testWindow.setLocation((frame.getX() + frame.getWidth() + WINDOW_GAP), frame.getY()); break; case VERTICAL: testWindow.setLocation(frame.getX(), - (frame.getY() + frame.getHeight() + 5)); + (frame.getY() + frame.getHeight() + WINDOW_GAP)); break; } } @@ -1111,9 +1365,10 @@ public final class PassFailJFrame { /** * Adds a {@code message} to the log area, if enabled by - * {@link Builder#logArea()} or {@link Builder#logArea(int)}. + * {@link Builder#logArea() logArea()} or + * {@link Builder#logArea(int) logArea(int)}. * - * @param message to log + * @param message the message to log */ public static void log(String message) { System.out.println("PassFailJFrame: " + message); @@ -1122,7 +1377,8 @@ public final class PassFailJFrame { /** * Clears the log area, if enabled by - * {@link Builder#logArea()} or {@link Builder#logArea(int)}. + * {@link Builder#logArea() logArea()} or + * {@link Builder#logArea(int) logArea(int)}. */ public static void logClear() { System.out.println("\nPassFailJFrame: log cleared\n"); @@ -1131,7 +1387,9 @@ public final class PassFailJFrame { /** * Replaces the log area content with provided {@code text}, if enabled by - * {@link Builder#logArea()} or {@link Builder#logArea(int)}. + * {@link Builder#logArea() logArea()} or + * {@link Builder#logArea(int) logArea(int)}. + * * @param text new text for the log area */ public static void logSet(String text) { @@ -1182,11 +1440,45 @@ public final class PassFailJFrame { return this; } + /** + * Sets the number of rows for displaying the instruction text. + * The default value is the number of lines in the text plus 1: + * {@code ((int) instructions.lines().count() + 1)}. + * + * @param rows the number of rows for instruction text + * @return this builder + */ public Builder rows(int rows) { this.rows = rows; return this; } + private int getDefaultRows() { + return (int) instructions.lines().count() + 1; + } + + /** + * Adds a certain number of rows for displaying the instruction text. + * + * @param rowsAdd the number of rows to add to the number of rows + * @return this builder + * @see #rows + */ + public Builder rowsAdd(int rowsAdd) { + if (rows == 0) { + rows = getDefaultRows(); + } + rows += rowsAdd; + + return this; + } + + /** + * Sets the number of columns for displaying the instruction text. + * + * @param columns the number of columns for instruction text + * @return this builder + */ public Builder columns(int columns) { this.columns = columns; return this; @@ -1250,6 +1542,101 @@ public final class PassFailJFrame { return this; } + + /** + * Adds an implementation of {@link PositionWindows PositionWindows} + * which the framework will use to position multiple test UI windows. + * + * @param positionWindows an implementation of {@code PositionWindows} + * to position multiple test UI windows + * @return this builder + * @throws IllegalArgumentException if the {@code positionWindows} + * parameter is {@code null} + * @throws IllegalStateException if the {@code positionWindows} field + * is already set + */ + public Builder positionTestUI(PositionWindows positionWindows) { + if (positionWindows == null) { + throw new IllegalArgumentException("positionWindows parameter can't be null"); + } + if (this.positionWindows != null) { + throw new IllegalStateException("PositionWindows is already set"); + } + this.positionWindows = positionWindows; + return this; + } + + /** + * Positions the test UI windows in a row to the right of + * the instruction frame. The top of the windows is aligned to + * that of the instruction frame. + * + * @return this builder + */ + public Builder positionTestUIRightRow() { + return position(Position.HORIZONTAL) + .positionTestUI(WindowLayouts::rightOneRow); + } + + /** + * Positions the test UI windows in a column to the right of + * the instruction frame. The top of the first window is aligned to + * that of the instruction frame. + * + * @return this builder + */ + public Builder positionTestUIRightColumn() { + return position(Position.HORIZONTAL) + .positionTestUI(WindowLayouts::rightOneColumn); + } + + /** + * Positions the test UI windows in a column to the right of + * the instruction frame centering the stack of the windows. + * + * @return this builder + */ + public Builder positionTestUIRightColumnCentered() { + return position(Position.HORIZONTAL) + .positionTestUI(WindowLayouts::rightOneColumnCentered); + } + + /** + * Positions the test UI windows in a row to the bottom of + * the instruction frame. The left of the first window is aligned to + * that of the instruction frame. + * + * @return this builder + */ + public Builder positionTestUIBottomRow() { + return position(Position.VERTICAL) + .positionTestUI(WindowLayouts::bottomOneRow); + } + + /** + * Positions the test UI windows in a row to the bottom of + * the instruction frame centering the row of the windows. + * + * @return this builder + */ + public Builder positionTestUIBottomRowCentered() { + return position(Position.VERTICAL) + .positionTestUI(WindowLayouts::bottomOneRowCentered); + } + + /** + * Positions the test UI windows in a column to the bottom of + * the instruction frame. The left of the first window is aligned to + * that of the instruction frame. + * + * @return this builder + */ + public Builder positionTestUIBottomColumn() { + return position(Position.VERTICAL) + .positionTestUI(WindowLayouts::bottomOneColumn); + } + + /** * Adds a {@code WindowListCreator} which the framework will use * to create a list of test UI windows. @@ -1352,6 +1739,7 @@ public final class PassFailJFrame { return this; } + /** * Adds a {@code PanelCreator} which the framework will use * to create a component with test UI and display it in a split pane. @@ -1443,9 +1831,41 @@ public final class PassFailJFrame { return new PassFailJFrame(this); } + /** + * Returns the file name of the test, if the {@code test.file} property + * is defined, concatenated with {@code " - "} which serves as a prefix + * to the default instruction frame title; + * or an empty string if the {@code test.file} property is not defined. + * + * @return the prefix to the default title: + * either the file name of the test or an empty string + * + * @see jtreg + * test-specific system properties and environment variables + */ + private static String getTestFileNamePrefix() { + String testFile = System.getProperty("test.file"); + if (testFile == null) { + return ""; + } + + return Paths.get(testFile).getFileName().toString() + + " - "; + } + + /** + * Validates the state of the builder and + * expands parameters that have no assigned values + * to their default values. + * + * @throws IllegalStateException if no instructions are provided, + * or if {@code PositionWindows} implementation is + * provided but neither window creator nor + * test window list are set + */ private void validate() { if (title == null) { - title = TITLE; + title = getTestFileNamePrefix() + TITLE; } if (instructions == null || instructions.isEmpty()) { @@ -1458,7 +1878,7 @@ public final class PassFailJFrame { } if (rows == 0) { - rows = ROWS; + rows = getDefaultRows(); } if (columns == 0) { diff --git a/test/jdk/java/awt/regtesthelpers/WindowLayouts.java b/test/jdk/java/awt/regtesthelpers/WindowLayouts.java new file mode 100644 index 00000000000..4368e3a5943 --- /dev/null +++ b/test/jdk/java/awt/regtesthelpers/WindowLayouts.java @@ -0,0 +1,237 @@ +/* + * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Component; +import java.awt.Dimension; +import java.awt.GraphicsConfiguration; +import java.awt.Insets; +import java.awt.Point; +import java.awt.Window; +import java.util.List; + +import static java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment; +import static java.awt.Toolkit.getDefaultToolkit; + +/** + * A utility class which provides standard window layouts for multi-window + * manual tests using the {@link PassFailJFrame} framework. + * The layout methods {@code right-} and {@code bottom-} implement the + * {@link PassFailJFrame.PositionWindows PositionWindows} interface and + * can be used directly or via builder methods. + *

                    + * There are several helper methods, such as + * {@link #getScreenCenter() getScreenCenter}, which could help you + * implement customized windows layouts. + */ +public final class WindowLayouts { + + /** Private constructor to prevent instantiating the utility class. */ + private WindowLayouts() { + } + + /** A gap between windows. (Local copy makes expressions shorter.) */ + private static final int WINDOW_GAP = PassFailJFrame.WINDOW_GAP; + + /** + * Lays out the window list in one row to the right of + * the instruction frame. The top of the windows is aligned to + * that of the instruction frame. + * + * @param windows the list of windows to lay out + * @param instructionUI information about the instruction frame + */ + public static void rightOneRow(final List windows, + final PassFailJFrame.InstructionUI instructionUI) { + layoutRow(instructionUI.getLocation().x + + instructionUI.getSize().width + + WINDOW_GAP, + instructionUI.getLocation().y, + windows); + } + + /** + * Lays out the window list in one column to the right of + * the instruction frame. The top of the first window is aligned to + * that of the instruction frame. + * + * @param windows the list of windows to lay out + * @param instructionUI information about the instruction frame + */ + public static void rightOneColumn(final List windows, + final PassFailJFrame.InstructionUI instructionUI) { + layoutColumn(instructionUI.getLocation().x + + instructionUI.getSize().width + + WINDOW_GAP, + instructionUI.getLocation().y, + windows); + } + + /** + * Lays out the window list in one column to the right of + * the instruction frame centering the stack of the windows. + * + * @param windows the list of windows to lay out + * @param instructionUI information about the instruction frame + */ + public static void rightOneColumnCentered(final List windows, + final PassFailJFrame.InstructionUI instructionUI) { + layoutColumn(instructionUI.getLocation().x + + instructionUI.getSize().width + + WINDOW_GAP, + getScreenCenter().y + - getWindowListHeight(windows) / 2, + windows); + } + + + /** + * Lays out the window list in one row to the bottom of + * the instruction frame. The left of the first window is aligned to + * that of the instruction frame. + * + * @param windows the list of windows to lay out + * @param instructionUI information about the instruction frame + */ + public static void bottomOneRow(final List windows, + final PassFailJFrame.InstructionUI instructionUI) { + layoutRow(instructionUI.getLocation().x, + instructionUI.getLocation().y + + instructionUI.getSize().height + + WINDOW_GAP, + windows); + } + + /** + * Lays out the window list in one row to the bottom of + * the instruction frame centering the row of the windows. + * + * @param windows the list of windows to lay out + * @param instructionUI information about the instruction frame + */ + public static void bottomOneRowCentered(final List windows, + final PassFailJFrame.InstructionUI instructionUI) { + layoutRow(getScreenCenter().x + - getWindowListWidth(windows) / 2, + instructionUI.getLocation().y + + instructionUI.getSize().height + + WINDOW_GAP, + windows); + } + + /** + * Lays out the window list in one column to the bottom of + * the instruction frame. The left of the first window is aligned to + * that of the instruction frame. + * + * @param windows the list of windows to lay out + * @param instructionUI information about the instruction frame + */ + public static void bottomOneColumn(final List windows, + final PassFailJFrame.InstructionUI instructionUI) { + layoutColumn(instructionUI.getLocation().x, + instructionUI.getLocation().y + + instructionUI.getSize().height + + WINDOW_GAP, + windows); + } + + + /** + * Lays out the window list in one row starting at + * ({@code x0}, {@code y}). + * + * @param x0 the starting x coordinate of the windows + * @param y the y coordinate of the windows + * @param windows the list of windows to lay out + */ + public static void layoutRow(final int x0, + final int y, + final List windows) { + int x = x0; + for (Window w : windows) { + w.setLocation(x, y); + x += w.getWidth() + WINDOW_GAP; + } + } + + /** + * Lays out the window list in one column starting at + * ({@code x}, {@code y0}). + * + * @param x the x coordinate of the windows + * @param y0 the starting y coordinate of the windows + * @param windows the list of windows to lay out + */ + public static void layoutColumn(final int x, + final int y0, + final List windows) { + int y = y0; + for (Window w : windows) { + w.setLocation(x, y); + y += w.getHeight() + WINDOW_GAP; + } + } + + + /** + * {@return the center point of the main screen} + */ + public static Point getScreenCenter() { + GraphicsConfiguration gc = getLocalGraphicsEnvironment() + .getDefaultScreenDevice() + .getDefaultConfiguration(); + Dimension size = gc.getBounds() + .getSize(); + Insets insets = getDefaultToolkit() + .getScreenInsets(gc); + + return new Point((size.width - insets.left - insets.right) / 2, + (size.height - insets.top - insets.bottom) / 2); + } + + /** + * {@return width of the windows in the list, taking into account + * the gap between windows} + * + * @param windows the list of windows to get the width of + */ + public static int getWindowListWidth(final List windows) { + return windows.stream() + .mapToInt(Component::getWidth) + .sum() + + WINDOW_GAP * (windows.size() - 1); + } + + /** + * {@return height of the windows in the list, taking into account + * the gap between windows} + * + * @param windows the list of windows to get the height of + */ + public static int getWindowListHeight(final List windows) { + return windows.stream() + .mapToInt(Component::getHeight) + .sum() + + WINDOW_GAP * (windows.size() - 1); + } +} diff --git a/test/jdk/java/beans/Introspector/8159696/UnloadClassBeanInfo.java b/test/jdk/java/beans/Introspector/8159696/UnloadClassBeanInfo.java index 8c77b3565a8..0d9775d50d6 100644 --- a/test/jdk/java/beans/Introspector/8159696/UnloadClassBeanInfo.java +++ b/test/jdk/java/beans/Introspector/8159696/UnloadClassBeanInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,7 +38,7 @@ import java.util.Arrays; * @bug 8159696 * @library /javax/swing/regtesthelpers * @compile ./stub/Stub.java - * @run main/othervm -mx32M UnloadClassBeanInfo + * @run main/othervm -Xmx32M UnloadClassBeanInfo */ public class UnloadClassBeanInfo { diff --git a/test/jdk/java/beans/Introspector/Test5102804.java b/test/jdk/java/beans/Introspector/Test5102804.java index d5b38ea10d0..0563b1d306d 100644 --- a/test/jdk/java/beans/Introspector/Test5102804.java +++ b/test/jdk/java/beans/Introspector/Test5102804.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,8 +25,7 @@ * @test * @bug 5102804 * @summary Tests memory leak - * @author Sergey Malenkov - * @run main/othervm -ms16m -mx16m Test5102804 + * @run main/othervm -Xms16m -Xmx16m Test5102804 */ import java.beans.BeanInfo; diff --git a/test/jdk/java/beans/Introspector/Test8027905.java b/test/jdk/java/beans/Introspector/Test8027905.java index 60318f34555..8ebf1c59574 100644 --- a/test/jdk/java/beans/Introspector/Test8027905.java +++ b/test/jdk/java/beans/Introspector/Test8027905.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,8 +27,7 @@ import java.beans.PropertyDescriptor; * @test * @bug 8027905 * @summary Tests that GC does not affect a property type - * @author Sergey Malenkov - * @run main/othervm -mx16m Test8027905 + * @run main/othervm -Xmx16m Test8027905 */ public class Test8027905 { diff --git a/test/jdk/java/beans/XMLEncoder/Test4646747.java b/test/jdk/java/beans/XMLEncoder/Test4646747.java index 61f7c41c882..467a0153228 100644 --- a/test/jdk/java/beans/XMLEncoder/Test4646747.java +++ b/test/jdk/java/beans/XMLEncoder/Test4646747.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,8 +25,7 @@ * @test * @bug 4646747 * @summary Tests that persistence delegate is correct after memory stress - * @author Mark Davidson - * @run main/othervm -ms16m -mx16m Test4646747 + * @run main/othervm -Xms16m -Xmx16m Test4646747 */ import java.beans.DefaultPersistenceDelegate; diff --git a/test/jdk/java/foreign/TestMappedHandshake.java b/test/jdk/java/foreign/TestMappedHandshake.java new file mode 100644 index 00000000000..46fb4fb45fb --- /dev/null +++ b/test/jdk/java/foreign/TestMappedHandshake.java @@ -0,0 +1,142 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @requires vm.flavor != "zero" + * @modules java.base/jdk.internal.vm.annotation java.base/jdk.internal.misc + * @key randomness + * @run testng/othervm TestMappedHandshake + * @run testng/othervm -Xint TestMappedHandshake + * @run testng/othervm -XX:TieredStopAtLevel=1 TestMappedHandshake + * @run testng/othervm -XX:-TieredCompilation TestMappedHandshake + */ + +import java.io.File; +import java.io.IOException; +import java.lang.foreign.Arena; +import java.lang.foreign.MemorySegment; +import java.nio.channels.FileChannel; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.StandardOpenOption; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; + +import org.testng.annotations.Test; + +import static org.testng.Assert.*; + +public class TestMappedHandshake { + + static final int SEGMENT_SIZE = 1_000_000; + static final int ACCESS_START_DELAY_MILLIS = 100; + static final int POST_ACCESS_DELAY_MILLIS = 1; + static final int TIMED_RUN_TIME_SECONDS = 10; + static final int MAX_EXECUTOR_WAIT_SECONDS = 20; + + static final int NUM_ACCESSORS = 5; + + static final Path tempPath; + + static { + try { + File file = File.createTempFile("buffer", "txt"); + file.deleteOnExit(); + tempPath = file.toPath(); + Files.write(file.toPath(), new byte[SEGMENT_SIZE], StandardOpenOption.WRITE); + + } catch (IOException ex) { + throw new ExceptionInInitializerError(ex); + } + } + + @Test + public void testHandshake() throws InterruptedException, IOException { + try (FileChannel fileChannel = FileChannel.open(tempPath, StandardOpenOption.READ, StandardOpenOption.WRITE) ; + Arena arena = Arena.ofShared()) { + MemorySegment segment = fileChannel.map(FileChannel.MapMode.READ_WRITE, 0L, SEGMENT_SIZE, arena); + ExecutorService accessExecutor = Executors.newFixedThreadPool(NUM_ACCESSORS + 1); + // start handshaker + accessExecutor.execute(new Handshaker()); + Thread.sleep(ACCESS_START_DELAY_MILLIS); + // start accessors + for (int i = 0 ; i < NUM_ACCESSORS ; i++) { + accessExecutor.execute(new MappedSegmentAccessor(segment)); + } + + accessExecutor.shutdown(); + assertTrue(accessExecutor.awaitTermination(MAX_EXECUTOR_WAIT_SECONDS, TimeUnit.SECONDS)); + } + } + + static abstract class TimedAction implements Runnable { + @Override + public void run() { + long start = System.currentTimeMillis(); + while (true) { + try { + doAction(); + } catch (Throwable ex) { + // ignore + } finally { + long elapsed = System.currentTimeMillis() - start; + if (elapsed > TIMED_RUN_TIME_SECONDS * 1000) { + break; + } + } + } + } + + abstract void doAction() throws Throwable; + } + + static class MappedSegmentAccessor extends TimedAction { + + final MemorySegment segment; + + MappedSegmentAccessor(MemorySegment segment) { + this.segment = segment; + } + + @Override + void doAction() throws Throwable { + segment.load(); + Thread.sleep(POST_ACCESS_DELAY_MILLIS); + segment.isLoaded(); + Thread.sleep(POST_ACCESS_DELAY_MILLIS); + segment.unload(); + Thread.sleep(POST_ACCESS_DELAY_MILLIS); + segment.force(); + } + } + + static class Handshaker extends TimedAction { + + @Override + public void doAction() { + Arena.ofShared().close(); + } + } +} diff --git a/test/jdk/java/foreign/TestMismatch.java b/test/jdk/java/foreign/TestMismatch.java index 9549b2508ff..f50621e3415 100644 --- a/test/jdk/java/foreign/TestMismatch.java +++ b/test/jdk/java/foreign/TestMismatch.java @@ -29,7 +29,9 @@ import java.lang.foreign.Arena; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; +import java.util.Random; import java.util.concurrent.atomic.AtomicReference; import java.lang.foreign.MemorySegment; @@ -122,6 +124,68 @@ public class TestMismatch { } } + @Test + public void random() { + try (var arena = Arena.ofConfined()) { + var rnd = new Random(42); + for (int size = 1; size < 64; size++) { + // Repeat a fair number of rounds + for (int i = 0; i < 147; i++) { + var src = arena.allocate(size); + // The dst segment might be zero to eight bytes longer + var dst = arena.allocate(size + rnd.nextInt(8 + 1)); + // Fill the src with random data + for (int j = 0; j < size; j++) { + src.set(ValueLayout.JAVA_BYTE, j, randomByte(rnd)); + } + // copy the random data from src to dst + dst.copyFrom(src); + // Fill the rest (if any) of the dst with random data + for (long j = src.byteSize(); j < dst.byteSize(); j++) { + dst.set(ValueLayout.JAVA_BYTE, j, randomByte(rnd)); + } + + if (rnd.nextBoolean()) { + // In this branch, we inject one or more deviating bytes + int beginDiff = rnd.nextInt(size); + int endDiff = rnd.nextInt(beginDiff, size); + for (int d = beginDiff; d <= endDiff; d++) { + byte existing = dst.get(ValueLayout.JAVA_BYTE, d); + // Make sure we never get back the same value + byte mutatedValue; + do { + mutatedValue = randomByte(rnd); + } while (existing == mutatedValue); + dst.set(ValueLayout.JAVA_BYTE, d, mutatedValue); + } + + // They are not equal and differs in position beginDiff + assertEquals(src.mismatch(dst), beginDiff); + assertEquals(dst.mismatch(src), beginDiff); + } else { + // In this branch, there is no injection + + if (src.byteSize() == dst.byteSize()) { + // The content matches and they are of equal size + assertEquals(src.mismatch(dst), -1); + assertEquals(dst.mismatch(src), -1); + } else { + // The content matches but they are of different length + // Remember, the size of src is always smaller or equal + // to the size of dst. + assertEquals(src.mismatch(dst), src.byteSize()); + assertEquals(dst.mismatch(src), src.byteSize()); + } + } + } + } + } + } + + static byte randomByte(Random rnd) { + return (byte) rnd.nextInt(Byte.MIN_VALUE, Byte.MAX_VALUE + 1); + } + @Test(dataProvider = "slices") public void testDifferentValues(MemorySegment s1, MemorySegment s2) { out.format("testDifferentValues s1:%s, s2:%s\n", s1, s2); diff --git a/test/jdk/java/foreign/TestSegmentCopy.java b/test/jdk/java/foreign/TestSegmentCopy.java index 88636bf5420..9a4500b2f5a 100644 --- a/test/jdk/java/foreign/TestSegmentCopy.java +++ b/test/jdk/java/foreign/TestSegmentCopy.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,7 +30,6 @@ import java.lang.foreign.Arena; import java.lang.foreign.MemorySegment; import java.lang.foreign.ValueLayout; -import java.lang.invoke.MethodHandles; import java.lang.invoke.VarHandle; import java.nio.ByteOrder; import java.util.ArrayList; @@ -76,6 +75,94 @@ public class TestSegmentCopy { } } + @Test(dataProvider = "conjunctSegments") + public void testCopy5ArgInvariants(MemorySegment src, MemorySegment dst) { + assertThrows(IndexOutOfBoundsException.class, () -> MemorySegment.copy(src, 0, dst, 0, -1)); + assertThrows(IndexOutOfBoundsException.class, () -> MemorySegment.copy(src, -1, dst, 0, src.byteSize())); + assertThrows(IndexOutOfBoundsException.class, () -> MemorySegment.copy(src, 0, dst, -1, src.byteSize())); + assertThrows(IndexOutOfBoundsException.class, () -> MemorySegment.copy(src, 1, dst, 0, src.byteSize())); + assertThrows(IndexOutOfBoundsException.class, () -> MemorySegment.copy(src, 0, dst, 1, src.byteSize())); + } + + @Test(dataProvider = "conjunctSegments") + public void testConjunctCopy7ArgRight(MemorySegment src, MemorySegment dst) { + testConjunctCopy(src, 0, dst, 1, CopyOp.of7Arg()); + } + + @Test(dataProvider = "conjunctSegments") + public void testConjunctCopy5ArgRight(MemorySegment src, MemorySegment dst) { + testConjunctCopy(src, 0, dst, 1, CopyOp.of5Arg()); + } + + @Test(dataProvider = "conjunctSegments") + public void testConjunctCopy7ArgLeft(MemorySegment src, MemorySegment dst) { + testConjunctCopy(src, 1, dst, 0, CopyOp.of7Arg()); + } + + @Test(dataProvider = "conjunctSegments") + public void testConjunctCopy5ArgLeft(MemorySegment src, MemorySegment dst) { + testConjunctCopy(src, 1, dst, 0, CopyOp.of5Arg()); + } + + void testConjunctCopy(MemorySegment src, long srcOffset, MemorySegment dst, long dstOffset, CopyOp op) { + if (src.byteSize() < 4 || src.address() != dst.address()) { + // Only test larger segments where the skew is zero + return; + } + + try (var arena = Arena.ofConfined()) { + // Create a disjoint segment for expected behavior + MemorySegment disjoint = arena.allocate(dst.byteSize()); + disjoint.copyFrom(src); + op.copy(src, srcOffset, disjoint, dstOffset, 3); + byte[] expected = disjoint.toArray(JAVA_BYTE); + + // Do a conjoint copy + op.copy(src, srcOffset, dst, dstOffset, 3); + byte[] actual = dst.toArray(JAVA_BYTE); + + assertEquals(actual, expected); + } + } + + @FunctionalInterface + interface CopyOp { + void copy(MemorySegment src, long srcOffset, MemorySegment dst, long dstOffset, long bytes); + + static CopyOp of5Arg() { + return MemorySegment::copy; + } + + static CopyOp of7Arg() { + return (MemorySegment src, long srcOffset, MemorySegment dst, long dstOffset, long bytes) -> + MemorySegment.copy(src, JAVA_BYTE, srcOffset, dst, JAVA_BYTE, dstOffset, bytes); + } + + } + + @Test(dataProvider = "segmentKinds") + public void testByteCopySizes(SegmentKind kind1, SegmentKind kind2) { + + record Offsets(int src, int dst){} + + for (Offsets offsets : List.of(new Offsets(3, 7), new Offsets(7, 3))) { + for (int size = 0; size < 513; size++) { + MemorySegment src = kind1.makeSegment(size + offsets.src()); + MemorySegment dst = kind2.makeSegment(size + offsets.dst()); + //prepare source slice + for (int i = 0; i < size; i++) { + src.set(JAVA_BYTE, i + offsets.src(), (byte) i); + } + //perform copy + MemorySegment.copy(src, offsets.src(), dst, offsets.dst(), size); + //check that copy actually worked + for (int i = 0; i < size; i++) { + assertEquals(dst.get(JAVA_BYTE, i + offsets.dst()), (byte) i); + } + } + } + } + @Test(expectedExceptions = IllegalArgumentException.class, dataProvider = "segmentKinds") public void testReadOnlyCopy(SegmentKind kind1, SegmentKind kind2) { MemorySegment s1 = kind1.makeSegment(TEST_BYTE_SIZE); @@ -277,6 +364,28 @@ public class TestSegmentCopy { return cases.toArray(Object[][]::new); } + @DataProvider + static Object[][] conjunctSegments() { + List cases = new ArrayList<>(); + for (SegmentKind kind : SegmentKind.values()) { + // Different paths might be taken in the implementation depending on the + // size, type, and address of the underlying segments. + for (int len : new int[]{0, 1, 7, 512}) { + for (int offset : new int[]{-1, 0, 1}) { + MemorySegment segment = kind.makeSegment(len + 2); + MemorySegment src = segment.asSlice(1 + offset, len); + MemorySegment dst = segment.asSlice(1, len); + for (int i = 0; i < len; i++) { + src.set(JAVA_BYTE, i, (byte) i); + } + // src = 0, 1, ... , len-1 + cases.add(new Object[]{src, dst}); + } + } + } + return cases.toArray(Object[][]::new); + } + @DataProvider static Object[][] types() { return Arrays.stream(Type.values()) diff --git a/test/jdk/java/foreign/TestUpcallStress.java b/test/jdk/java/foreign/TestUpcallStress.java new file mode 100644 index 00000000000..40607746856 --- /dev/null +++ b/test/jdk/java/foreign/TestUpcallStress.java @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @requires jdk.foreign.linker != "FALLBACK" + * @requires (os.arch == "aarch64" | os.arch=="riscv64") & os.name == "Linux" + * @requires os.maxMemory > 4G + * @modules java.base/jdk.internal.foreign + * @build NativeTestHelper CallGeneratorHelper TestUpcallBase + * @bug 8337753 + * + * @run testng/othervm/timeout=3200 + * -Xcheck:jni + * -XX:+IgnoreUnrecognizedVMOptions + * -XX:-VerifyDependencies + * --enable-native-access=ALL-UNNAMED + * -Dgenerator.sample.factor=17 + * TestUpcallStress + */ + +import java.lang.foreign.Arena; +import java.lang.foreign.FunctionDescriptor; +import java.lang.foreign.MemorySegment; + +import org.testng.annotations.Test; + +import java.lang.invoke.MethodHandle; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.atomic.AtomicReference; +import java.util.concurrent.*; +import java.util.function.Consumer; + +public class TestUpcallStress extends TestUpcallBase { + + static { + System.loadLibrary("TestUpcall"); + } + + @Test(dataProvider="functions", dataProviderClass=CallGeneratorHelper.class) + public void testUpcallsStress(int count, String fName, Ret ret, List paramTypes, + List fields) throws Throwable { + ExecutorService executor = Executors.newFixedThreadPool(16); + for (int threadIdx = 0; threadIdx < 16; threadIdx++) { + executor.submit(() -> { + for (int iter = 0; iter < 10000; iter++) { + List> returnChecks = new ArrayList<>(); + List> argChecks = new ArrayList<>(); + MemorySegment addr = findNativeOrThrow(fName); + try (Arena arena = Arena.ofConfined()) { + FunctionDescriptor descriptor = function(ret, paramTypes, fields); + MethodHandle mh = downcallHandle(LINKER, addr, arena, descriptor); + AtomicReference capturedArgs = new AtomicReference<>(); + Object[] args = makeArgs(capturedArgs, arena, descriptor, returnChecks, argChecks, 0); + + Object res = mh.invokeWithArguments(args); + + if (ret == Ret.NON_VOID) { + returnChecks.forEach(c -> c.accept(res)); + } + + Object[] capturedArgsArr = capturedArgs.get(); + for (int i = 0; i < capturedArgsArr.length; i++) { + argChecks.get(i).accept(capturedArgsArr[i]); + } + } catch (Throwable ex) { + throw new AssertionError(ex); + } + } + }); + } + // This shutdownNow is 'wrong', since it doesn't wait for tasks to terminate, + // but it seems to be the only way to reproduce the race of JDK-8337753 + executor.shutdownNow(); + } +} diff --git a/test/jdk/java/foreign/largestub/TestLargeStub.java b/test/jdk/java/foreign/largestub/TestLargeStub.java index eaf82648778..e4dcb325c8f 100644 --- a/test/jdk/java/foreign/largestub/TestLargeStub.java +++ b/test/jdk/java/foreign/largestub/TestLargeStub.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,29 +25,39 @@ * @test * @library ../ * @modules java.base/jdk.internal.foreign - * @run testng/othervm --enable-native-access=ALL-UNNAMED TestLargeStub + * @run junit/othervm --enable-native-access=ALL-UNNAMED TestLargeStub */ -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import java.lang.foreign.FunctionDescriptor; import java.lang.foreign.Linker; import java.lang.foreign.MemoryLayout; +import java.lang.foreign.ValueLayout; import java.util.stream.Stream; +import static org.junit.jupiter.params.provider.Arguments.arguments; + public class TestLargeStub extends NativeTestHelper { + private static final int DOWNCALL_AVAILABLE_SLOTS = 248; + private static final int UPCALL_AVAILABLE_SLOTS = 250; + MemoryLayout STRUCT_LL = MemoryLayout.structLayout( C_LONG_LONG, C_LONG_LONG ); // 16 byte struct triggers return buffer usage on SysV - @Test - public void testDowncall() { + @ParameterizedTest + @MethodSource("layouts") + public void testDowncall(ValueLayout layout, int numSlots) { // Link a handle with a large number of arguments, to try and overflow the code buffer Linker.nativeLinker().downcallHandle( FunctionDescriptor.of(STRUCT_LL, - Stream.generate(() -> C_DOUBLE).limit(124).toArray(MemoryLayout[]::new)), + Stream.generate(() -> layout).limit(DOWNCALL_AVAILABLE_SLOTS / numSlots).toArray(MemoryLayout[]::new)), Linker.Option.captureCallState("errno")); } @@ -62,11 +72,21 @@ public class TestLargeStub extends NativeTestHelper { Linker.Option.critical(true)); } - @Test - public void testUpcall() { + @ParameterizedTest + @MethodSource("layouts") + public void testUpcall(ValueLayout layout, int numSlots) { // Link a handle with a large number of arguments, to try and overflow the code buffer Linker.nativeLinker().downcallHandle( FunctionDescriptor.of(STRUCT_LL, - Stream.generate(() -> C_DOUBLE).limit(125).toArray(MemoryLayout[]::new))); + Stream.generate(() -> layout).limit(UPCALL_AVAILABLE_SLOTS / numSlots).toArray(MemoryLayout[]::new))); + } + + private static Stream layouts() { + return Stream.of( + arguments(C_INT, 1), + arguments(C_LONG_LONG, 2), + arguments(C_FLOAT, 1), + arguments(C_DOUBLE, 2) + ); } } diff --git a/test/jdk/java/io/File/GetCanonicalPath.java b/test/jdk/java/io/File/GetCanonicalPath.java index e54227e44b4..d69e90fbbfc 100644 --- a/test/jdk/java/io/File/GetCanonicalPath.java +++ b/test/jdk/java/io/File/GetCanonicalPath.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,17 +22,21 @@ */ /* @test - * @bug 4899022 + * @bug 4899022 8003887 * @summary Look for erroneous representation of drive letter * @run junit GetCanonicalPath */ import java.io.File; import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; import java.util.ArrayList; import java.util.List; import java.util.stream.Stream; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.EnabledOnOs; import org.junit.jupiter.api.condition.OS; @@ -122,4 +126,88 @@ public class GetCanonicalPath { String path = new File("c:/").getCanonicalPath(); assertFalse(path.length() > 3, "Drive letter incorrectly represented"); } + + // Create a File with the given pathname and return the File as a Path + private static Path createFile(String pathname) throws IOException { + File file = new File(pathname); + file.deleteOnExit(); + return file.toPath(); + } + + private static boolean supportsLinks = true; + private static String linkMessage; + + private static Path link; + private static Path sublink; + private static Path subsub; + + @BeforeAll + static void createSymlinks() throws IOException { + final String DIR = "dir"; + final String SUBDIR = "subdir"; + final String TARGET = "target.txt"; + final String LINK = "link"; + final String SUBLINK = "sublink"; + final String FILE = "file.txt"; + + // Create directories dir/subdir + Path dir = createFile(DIR); + Path subdir = createFile(dir.resolve(SUBDIR).toString()); + Files.createDirectories(subdir); + + // Create file dir/subdir/target.txt + Path target = createFile(subdir.resolve(TARGET).toString()); + Files.createFile(target); + + // Create symbolic link link -> dir + link = createFile(Path.of(LINK).toString()); + try { + Files.createSymbolicLink(link, dir); + } catch (UnsupportedOperationException | IOException x) { + if (OS.WINDOWS.isCurrentOs()) { + supportsLinks = false; + linkMessage = "\"" + x.getMessage() + "\""; + return; + } else { + throw x; + } + } + + sublink = createFile(Path.of(DIR, SUBDIR, SUBLINK).toString()); + Path file = createFile(Path.of(DIR, SUBDIR, FILE).toString()); + Files.createFile(file); + + // Create symbolic link dir/subdir/sublink -> file.txt + Files.createSymbolicLink(sublink, Path.of(FILE)); + sublink.toFile().deleteOnExit(); + + subsub = createFile(Path.of(LINK, SUBDIR, SUBLINK).toString()); + } + + @Test + void linkToDir() throws IOException { + Assumptions.assumeTrue(supportsLinks, linkMessage); + + // Check link evaluates to dir + assertEquals(link.toRealPath().toString(), + link.toFile().getCanonicalPath()); + } + + @Test + void linkToFile() throws IOException { + Assumptions.assumeTrue(supportsLinks, linkMessage); + + // Check sublink evaluates to file.txt + assertEquals(sublink.toRealPath().toString(), + sublink.toFile().getCanonicalPath()); + } + + @Test + void linkToFileInSubdir() throws IOException { + Assumptions.assumeTrue(supportsLinks, linkMessage); + + // Check link/subdir/sublink evaluates to dir/subdir/file.txt + assertEquals(subsub.toRealPath().toString(), + subsub.toFile().getCanonicalPath()); + } } diff --git a/test/jdk/java/lang/Math/HyperbolicTests.java b/test/jdk/java/lang/Math/HyperbolicTests.java index cf583ed7b5f..4534396ee06 100644 --- a/test/jdk/java/lang/Math/HyperbolicTests.java +++ b/test/jdk/java/lang/Math/HyperbolicTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -969,6 +969,400 @@ public class HyperbolicTests { failures += testTanhCaseWithUlpDiff(d, 1.0, 2.5); } + failures += testTanhAdditionalTests(); + + return failures; + } + + /** + * Test accuracy of {Math, StrictMath}.tanh using quad precision + * tanh implementation as the reference. There are additional tests. + * The specified accuracy is 2.5 ulps. + * + */ + static int testTanhAdditionalTests() { + int failures = 0; + /* + * Array elements below are generated using a quad precision tanh + * implementation (libquadmath). Rounded to a double, the quad result + * *should* be correctly rounded, unless we are quite unlucky. + * Assuming the quad value is a correctly rounded double, the + * allowed error is 3.0 ulps instead of 2.5 since the quad + * value rounded to double can have its own 1/2 ulp error. + */ + double[][] testCases = { + // x tanh(x) + {1.09951162777600024414062500000000000e+12, 1.00000000000000000000000000000000000e+00}, + {1.56250000000000416333634234433702659e-02, 1.56237285584089068255495133849899136e-02}, + {1.61254882812500000000000000000000000e+01, 9.99999999999980293529906376885389048e-01}, + {2.53165043529127054000582575099542737e-01, 2.47891535884497437358843835970604812e-01}, + {2.05669906337718799704816774465143681e+00, 9.67821952180774991463712302156014956e-01}, + {8.73243486124784240587359818164259195e+00, 9.99999947984421044859570034536492937e-01}, + {1.35302734375000000000000000000000000e+00, 8.74765946489987955543753077657414741e-01}, + {7.51299319580434721288497712521348149e-01, 6.35923468395323117288273690770900477e-01}, + {9.53088818012631927567568368431238923e-02, 9.50213381512267711017656118902912332e-02}, + {7.64443165964961757197215774795040488e-01, 6.43686625696507143760198874608796949e-01}, + {9.80772770147126660145175947036477737e-02, 9.77640088885469645387119927980991050e-02}, + {8.00000000000000044408920985006261617e-01, 6.64036770267848988511881426480887109e-01}, + {6.58800443825626694943631278533757722e-03, 6.58790912948844334160953310959647563e-03}, + {3.50634723606509357551885841530747712e+00, 9.98200861366828007281302037717336212e-01}, + {8.80951107580675074615328412619419396e-01, 7.06895478355484050029724917425086249e-01}, + {9.41693953354077795125931515940465033e-01, 7.35999567964351009171211613664845735e-01}, + {4.86714106743433794211028953213826753e-01, 4.51604571680788935707314000261162601e-01}, + {4.99999999970896114032115065128891729e-01, 4.62117157237121073362068671381593592e-01}, + {1.27999999999999971578290569595992565e+02, 1.00000000000000000000000000000000000e+00}, + {1.00000000000000022204460492503130808e+00, 7.61594155955764981372495044941331753e-01}, + {1.09951162777600024414062500000000000e+12, 1.00000000000000000000000000000000000e+00}, + {5.00000000000000777156117237609578297e-01, 4.62117157260010369694985045764006657e-01}, + {3.90625000000001474514954580286030250e-03, 3.90623013190635482599726614938805467e-03}, + {1.56250000000000659194920871186695877e-02, 1.56237285584089311057499113400637264e-02}, + {1.25000000000001332267629550187848508e-01, 1.24353001771597519720531117125519878e-01}, + {1.56250000000005169475958410885141348e-02, 1.56237285584093820237573019342883109e-02}, + {2.00000000000022737367544323205947876e+00, 9.64027580075832948084133680630298643e-01}, + {6.25000000000080352391407245704613160e-02, 6.24187467475205184231888372622987839e-02}, + {2.50000000000049737991503207013010979e-01, 2.44918662403755883728363950973251081e-01}, + {2.50000000000454747350886464118957520e-01, 2.44918662404136598540089724354621762e-01}, + {7.81250000001537658889105841808486730e-03, 7.81234105817638947180855590780540396e-03}, + {8.00000000002179945113311987370252609e+00, 9.99999774929675899622836792366347278e-01}, + {8.00000000002182787284255027770996094e+00, 9.99999774929675899635630557632573807e-01}, + {1.00000000004506106598967107856879011e+00, 7.61594155974689379640247120538425632e-01}, + {5.00000000024432678102925819985102862e-01, 4.62117157279224782806433798595181278e-01}, + {5.00000000124148025193449029757175595e-01, 4.62117157357645691462301850285961295e-01}, + {1.25000000043655745685100555419921875e-01, 1.24353001814576875736126314329404676e-01}, + {1.56250130385160446166992187500000000e-02, 1.56237415937421937398207048034470765e-02}, + {6.25000596046447753906250000000000000e-02, 6.24188061199314157260056878713262148e-02}, + {6.25001570879248902201652526855468750e-02, 6.24189032234056148184566765458350515e-02}, + {3.12509536743164062500000000000000000e-02, 3.12407841896026978197614959195842857e-02}, + {1.00024414062500000000000000000000000e+00, 7.61696669690972358277739369649969500e-01}, + {1.25091552734375000000000000000000000e-01, 1.24443137738349286849917747910445080e-01}, + {6.25703578334750876166481248219497502e-02, 6.24888301519391612116796252071905868e-02}, + {2.52525252525252597024518763646483421e-01, 2.47290965006585965880182136581880733e-01}, + {1.00000000164410457817454336293394590e-03, 9.99999668310902934017090322313224382e-04}, + {1.00000000966720672609944209341392707e-03, 9.99999676333997058845099107943491685e-04}, + {5.13687551499984795810860305209644139e-01, 4.72813376851263299460550751434331149e-01}, + {1.03125000000000000000000000000000000e+00, 7.74409187434213568286703209738132986e-01}, + {1.03372912114974835340319714305223897e+00, 7.75399652279487427958938283855319050e-01}, + {8.73243486124791523650401359191164374e+00, 9.99999947984421044867146689152891277e-01}, + {5.46364074509520181166521979321260005e-01, 4.97790203319363272413440879555555135e-01}, + {5.48776992118357842542764046811498702e-01, 4.99603030846724465253358333732665160e-01}, + {8.62884521484375000000000000000000000e-03, 8.62863106199946057455229821459862778e-03}, + {5.56840723899044820477399753144709393e-01, 5.05629619734278492036257594911833276e-01}, + {1.12042968912429174999090264464030042e+00, 8.07718324543002512898290101804260243e-01}, + {2.80761718750000000000000000000000000e-01, 2.73609921989813966516244201735889906e-01}, + {4.50982142857161694138312668655999005e+00, 9.99758010610690750512553927515350523e-01}, + {1.79803946803892764072507759465224808e-02, 1.79784572761372499903768063141254578e-02}, + {2.90674624105783541150316295897937380e-01, 2.82755618405959946459876962574827861e-01}, + {3.00000000019552404140199541870970279e-01, 2.91312612469484033539387970973996561e-01}, + {1.52306844600212459850396840010944288e-01, 1.51139964502163284820786391222343666e-01}, + {1.21913138136517762433186362613923848e+00, 8.39397762830401796350294214789399315e-01}, + {1.91612901016097944562055488404439529e-02, 1.91589453912240029886209020645693670e-02}, + {1.23194037796136601770058405236341059e+00, 8.43141232466373734055029303451281784e-01}, + {5.14544145441922751160745974630117416e+00, 9.99932120037417992977353814124626761e-01}, + {1.29608715898613313655118872702587396e+00, 8.60712461444305632100271902930674052e-01}, + {1.35302734375000000000000000000000000e+00, 8.74765946489987955543753077657414741e-01}, + {6.89141205308152926534148718928918242e-01, 5.97430012402391408227990740295335202e-01}, + {2.16702398900134561576802383342510439e-02, 2.16668484172600518601166701940771309e-02}, + {6.95330121814107471323040954302996397e-01, 6.01395252733578654705526153849150843e-01}, + {1.70127028180982076566857275068400668e-04, 1.70127026539641570641832179464678521e-04}, + {6.98731899876564921392230189667316154e-01, 6.03562246839061712657431798989209285e-01}, + {2.82308042901865396956395670713391155e+00, 9.92962754889608618611084237181745775e-01}, + {8.85009765625000000000000000000000000e-02, 8.82706391518277914218106043840064600e-02}, + {1.44086021505376304929768593865446746e+00, 8.93870759190524111186764508137227647e-01}, + {4.52708479240923750142044923450157512e-02, 4.52399464814195843886615749285771251e-02}, + {7.42434201630502221824770003877347335e-01, 6.30613596749571014884527941122811076e-01}, + {7.47314453125000000000000000000000000e-01, 6.33544059591028741704251380359792317e-01}, + {2.33572976827208893257914468222224968e-02, 2.33530509808936286709795071423335732e-02}, + {7.51392746195329142011587464367039502e-01, 6.35979110106607807348963004903609067e-01}, + {7.51649175412362091641682582121575251e-01, 6.36131796640758591543062918907122080e-01}, + {7.62560692649938864917658065678551793e-01, 6.42582785959772486552828548950126373e-01}, + {7.64660852335945273594575155584607273e-01, 6.43814099671361386286313072270915932e-01}, + {1.92871093750000000000000000000000000e-01, 1.90514597602311764623059750704793759e-01}, + {2.43864313521849479515779535176989157e-02, 2.43815983142663741885939851467013521e-02}, + {3.97705078125000000000000000000000000e-01, 3.77983627858614640283948547303348236e-01}, + {7.98034667968750000000000000000000000e-01, 6.62936606884708330125541187161682941e-01}, + {7.99316406250000000000000000000000000e-01, 6.63654430152659513562528989372441102e-01}, + {1.99890136718750000000000000000000000e-01, 1.97269734600247465099938891830640889e-01}, + {2.00000000008910994164779140191967599e-01, 1.97375320233467849151455260287892058e-01}, + {4.00000000093461316463816501709516160e-01, 3.79948962335194012629557116519596150e-01}, + {2.00000000069810862646235705142316874e-01, 1.97375320291995240418209079080646997e-01}, + {1.00000000056612609045103567950718571e-01, 9.96679946810060529704707312198636589e-02}, + {1.00000000080404896629637789828848327e-01, 9.96679947045619948897444345018478492e-02}, + {1.66666666666666696272613990004174411e+00, 9.31109608667577693190680177920119455e-01}, + {1.31034851074218750000000000000000000e-02, 1.31027351970209980614612589861988504e-02}, + {8.43444227005861080215254332870244980e-01, 6.87629045782656322925865941652078512e-01}, + {4.25596815032856623517432126391213387e-01, 4.01634947321531793299729470086813678e-01}, + {8.54614885269050605920426733064232394e-01, 6.93472710492835200064966331725774025e-01}, + {8.63777419830865200722769259300548583e-01, 6.98198780318331041148483592329099127e-01}, + {2.70117449276632004551146337689715438e-02, 2.70051772786722224566765342032635559e-02}, + {2.16282487792377908775165451515931636e-01, 2.12971988592557031781365419455581001e-01}, + {1.73204653003120601084674490266479552e+00, 9.39297315789076214802641716736658105e-01}, + {2.71436010781672190650404274947504746e-02, 2.71369367992428389623549774823710978e-02}, + {8.69092640155437079485523099720012397e-01, 7.00912831250687651307196017605464473e-01}, + {2.78015136718750000000000000000000000e-02, 2.77943530651526982827985645341156701e-02}, + {9.10156250000000000000000000000000000e-01, 7.21207240669352050307412688531998165e-01}, + {2.27787862235060922788676407435559668e-01, 2.23928183342045426304404589794035157e-01}, + {5.71524498377538048288215577485971153e-02, 5.70903033991663026980553749418981725e-02}, + {3.66406250000000000000000000000000000e+00, 9.98687254335130669671645868977829517e-01}, + {5.72863132979952241474741470028675394e-02, 5.72237295373843844708720164610859507e-02}, + {1.15265335196343660095763539175095502e-01, 1.14757558082362397172277983632352767e-01}, + {9.22871508732805212460448274214286357e-01, 7.27253018562057912939305739474564638e-01}, + {1.44882202148437500000000000000000000e-02, 1.44872065663080247568859985337817684e-02}, + {2.33459472656250000000000000000000000e-01, 2.29308506606965514793638071915067313e-01}, + {4.67608948699241744328958247933769599e-01, 4.36265367328226513916944408221096440e-01}, + {2.34375000000000000000000000000000000e-01, 2.30175711032132981819570603563403063e-01}, + {2.93977526337722387672624080323657836e-02, 2.93892867747176836833509722656208701e-02}, + {1.89257812500000000000000000000000000e+00, 9.55597542193888546329823463414294394e-01}, + {2.95798696005085230698039566732404637e-02, 2.95712454656271068251835101101858187e-02}, + {1.89360756176453159937977943627629429e+00, 9.55686843743833788059988471898348142e-01}, + {4.74943000289441419337066463413066231e-01, 4.42184502480986035803118250513914071e-01}, + {4.76562500000000000000000000000000000e-01, 4.43486412595195826790440814160101630e-01}, + {9.59027831303091549131067949929274619e-01, 7.43842915769532264613887042424467929e-01}, + {3.09784640940728682456661857713697827e-02, 3.09685582448730820784897541732374591e-02}, + {1.98437499999999977795539507496869192e+00, 9.62906870975765387287608356129776957e-01}, + {9.97205648659918675313917901803506538e-01, 7.60418100316000600203658397859135661e-01}, + {3.90291213989257769131913100579822640e-03, 3.90289232268659551022766662201699736e-03}, + {3.90481948852539019131913100579822640e-03, 3.90479964225138860483705936617354227e-03}, + {3.12423706054687500000000000000000000e-02, 3.12322094954161727499363714231262395e-02}, + {3.90535406768321947598709975579822640e-03, 3.90533421325712750455622728849037270e-03}, + {7.81154632568359288263826201159645279e-03, 7.81138744204279466358299901763388375e-03}, + {1.24999789521095569511111023075500270e-01, 1.24352794547462473786771370350680283e-01}, + {9.99999444341875043384959553804947063e-01, 7.61593922593510941370556728778707492e-01}, + {9.99999895691871532044103787484345958e-01, 7.61594112149023829770882693858011645e-01}, + {2.49999998130078865399283927217766177e-01, 2.44918660645955495851244772320875652e-01}, + {2.49999998603016110321206610933586489e-01, 2.44918661090523528987141309434443089e-01}, + {4.99999999970896114032115065128891729e-01, 4.62117157237121073362068671381593592e-01}, + {9.99999999999829358721115113439736888e-01, 7.61594155955693223160706417649502130e-01}, + {3.12499999999979183318288278314867057e-02, 3.12398314460291771315638233977623908e-02}, + {6.24999999999973701592104191604448715e-02, 6.24187467475098948954758673929811576e-02}, + {9.99999999999998556710067987296497449e-01, 7.61594155955764281974719327416526334e-01}, + {1.27999999999999971578290569595992565e+02, 1.00000000000000000000000000000000000e+00}, + {3.44827586206896546938693859374325257e-02, 3.44690977543900329082306735053903756e-02}, + {6.89655172413793093877387718748650514e-02, 6.88563859490195017187269420471893052e-02}, + {1.03448275862068964081608157812297577e-01, 1.03080829858086020470241143281488892e-01}, + {1.37931034482758618775477543749730103e-01, 1.37062928881132531260309423128680656e-01}, + {1.72413793103448287347134737501619384e-01, 1.70725445282084714146447066718646674e-01}, + {2.06896551724137955918791931253508665e-01, 2.03994088403983264406130799853712156e-01}, + {2.41379310344827624490449125005397946e-01, 2.36798141876826809207868665407968027e-01}, + {2.75862068965517293062106318757287227e-01, 2.69071023201531202536913498454407638e-01}, + {3.10344827586206961633763512509176508e-01, 3.00750767242988858303859696730149916e-01}, + {3.44827586206896630205420706261065789e-01, 3.31780427497542984412066808006924260e-01}, + {3.79310344827586298777077900012955070e-01, 3.62108391409330839416919529705937418e-01}, + {4.13793103448275967348735093764844351e-01, 3.91688608393346163715111892758489641e-01}, + {4.48275862068965635920392287516733631e-01, 4.20480731486975012003415012347372452e-01}, + {4.82758620689655304492049481268622912e-01, 4.48450175615929701255698232730127770e-01}, + {5.17241379310344973063706675020512193e-01, 4.75568097261544496368767486763625886e-01}, + {5.51724137931034586124212637514574453e-01, 5.01811301809605377924874787743959204e-01}, + {5.86206896551724199184718600008636713e-01, 5.27162086020673527345538794213535134e-01}, + {6.20689655172413812245224562502698973e-01, 5.51608023880856575817362987825134405e-01}, + {6.55172413793103425305730524996761233e-01, 5.75141704579102279221464447290041163e-01}, + {6.89655172413793038366236487490823492e-01, 5.97760431534850182076591161239096491e-01}, + {7.24137931034482651426742449984885752e-01, 6.19465891301270655454827665546029664e-01}, + {7.58620689655172264487248412478948012e-01, 6.40263800834536321750527885396253899e-01}, + {7.93103448275861877547754374973010272e-01, 6.60163541092833363676687202005166905e-01}, + {8.27586206896551490608260337467072532e-01, 6.79177784255529339466238655218797135e-01}, + {8.62068965517241103668766299961134791e-01, 6.97322121077226884958095667604561029e-01}, + {8.96551724137930716729272262455197051e-01, 7.14614694054361357412620518070189428e-01}, + {9.31034482758620329789778224949259311e-01, 7.31075841220047215751737025073520835e-01}, + {9.65517241379309942850284187443321571e-01, 7.46727754527182387965057729340710925e-01}, + {9.99999999999999555910790149937383831e-01, 7.61594155955764701613384757931622516e-01}, + {1.26765060022822940149670320537600000e+30, 1.00000000000000000000000000000000000e+00}, + {1.33436905287182034855574634496000000e+30, 1.00000000000000000000000000000000000e+00}, + {1.40108750551541129561478948454400000e+30, 1.00000000000000000000000000000000000e+00}, + {1.46780595815900224267383262412800000e+30, 1.00000000000000000000000000000000000e+00}, + {1.53452441080259318973287576371200000e+30, 1.00000000000000000000000000000000000e+00}, + {1.60124286344618413679191890329600000e+30, 1.00000000000000000000000000000000000e+00}, + {1.66796131608977508385096204288000000e+30, 1.00000000000000000000000000000000000e+00}, + {1.73467976873336603091000518246400000e+30, 1.00000000000000000000000000000000000e+00}, + {1.80139822137695697796904832204800000e+30, 1.00000000000000000000000000000000000e+00}, + {1.86811667402054792502809146163200000e+30, 1.00000000000000000000000000000000000e+00}, + {1.93483512666413887208713460121600000e+30, 1.00000000000000000000000000000000000e+00}, + {2.00155357930772981914617774080000000e+30, 1.00000000000000000000000000000000000e+00}, + {2.06827203195132076620522088038400000e+30, 1.00000000000000000000000000000000000e+00}, + {2.13499048459491171326426401996800000e+30, 1.00000000000000000000000000000000000e+00}, + {2.20170893723850266032330715955200000e+30, 1.00000000000000000000000000000000000e+00}, + {2.26842738988209360738235029913600000e+30, 1.00000000000000000000000000000000000e+00}, + {2.33514584252568455444139343872000000e+30, 1.00000000000000000000000000000000000e+00}, + {2.40186429516927550150043657830400000e+30, 1.00000000000000000000000000000000000e+00}, + {2.46858274781286644855947971788800000e+30, 1.00000000000000000000000000000000000e+00}, + {2.53530120045645739561852285747200000e+30, 1.00000000000000000000000000000000000e+00}, + {1.60693804425899027554196209234116260e+60, 1.00000000000000000000000000000000000e+00}, + {1.69151373079893703825155926128281056e+60, 1.00000000000000000000000000000000000e+00}, + {1.77608941733888380096115643022445853e+60, 1.00000000000000000000000000000000000e+00}, + {1.86066510387883056367075359916610649e+60, 1.00000000000000000000000000000000000e+00}, + {1.94524079041877732638035076810775445e+60, 1.00000000000000000000000000000000000e+00}, + {2.02981647695872408908994793704940241e+60, 1.00000000000000000000000000000000000e+00}, + {2.11439216349867085179954510599105038e+60, 1.00000000000000000000000000000000000e+00}, + {2.19896785003861761450914227493269834e+60, 1.00000000000000000000000000000000000e+00}, + {2.28354353657856437721873944387434630e+60, 1.00000000000000000000000000000000000e+00}, + {2.36811922311851113992833661281599426e+60, 1.00000000000000000000000000000000000e+00}, + {2.45269490965845790263793378175764222e+60, 1.00000000000000000000000000000000000e+00}, + {2.53727059619840466534753095069929019e+60, 1.00000000000000000000000000000000000e+00}, + {2.62184628273835142805712811964093815e+60, 1.00000000000000000000000000000000000e+00}, + {2.70642196927829819076672528858258611e+60, 1.00000000000000000000000000000000000e+00}, + {2.79099765581824495347632245752423407e+60, 1.00000000000000000000000000000000000e+00}, + {2.87557334235819171618591962646588203e+60, 1.00000000000000000000000000000000000e+00}, + {2.96014902889813847889551679540753000e+60, 1.00000000000000000000000000000000000e+00}, + {3.04472471543808524160511396434917796e+60, 1.00000000000000000000000000000000000e+00}, + {3.12930040197803200431471113329082592e+60, 1.00000000000000000000000000000000000e+00}, + {3.21387608851797876702430830223247388e+60, 1.00000000000000000000000000000000000e+00}, + {1.07150860718626732094842504906000181e+301, 1.00000000000000000000000000000000000e+00}, + {1.12790379703817606470289337889334663e+301, 1.00000000000000000000000000000000000e+00}, + {1.18429898689008480845736170872669145e+301, 1.00000000000000000000000000000000000e+00}, + {1.24069417674199355221183003856003627e+301, 1.00000000000000000000000000000000000e+00}, + {1.29708936659390229596629836839338109e+301, 1.00000000000000000000000000000000000e+00}, + {1.35348455644581103972076669822672591e+301, 1.00000000000000000000000000000000000e+00}, + {1.40987974629771978347523502806007073e+301, 1.00000000000000000000000000000000000e+00}, + {1.46627493614962852722970335789341555e+301, 1.00000000000000000000000000000000000e+00}, + {1.52267012600153727098417168772676037e+301, 1.00000000000000000000000000000000000e+00}, + {1.57906531585344601473864001756010519e+301, 1.00000000000000000000000000000000000e+00}, + {1.63546050570535475849310834739345001e+301, 1.00000000000000000000000000000000000e+00}, + {1.69185569555726350224757667722679483e+301, 1.00000000000000000000000000000000000e+00}, + {1.74825088540917224600204500706013965e+301, 1.00000000000000000000000000000000000e+00}, + {1.80464607526108098975651333689348447e+301, 1.00000000000000000000000000000000000e+00}, + {1.86104126511298973351098166672682928e+301, 1.00000000000000000000000000000000000e+00}, + {1.91743645496489847726544999656017410e+301, 1.00000000000000000000000000000000000e+00}, + {1.97383164481680722101991832639351892e+301, 1.00000000000000000000000000000000000e+00}, + {2.03022683466871596477438665622686374e+301, 1.00000000000000000000000000000000000e+00}, + {2.08662202452062470852885498606020856e+301, 1.00000000000000000000000000000000000e+00}, + {2.14301721437253345228332331589355338e+301, 1.00000000000000000000000000000000000e+00}, + {4.94065645841246544176568792868221372e-324, 4.94065645841246544176568792868221372e-324}, + {4.94065645841246544176568792868221372e-324, 4.94065645841246544176568792868221372e-324}, + {4.99999999999999944488848768742172979e-01, 4.62117157260009714845699443492203290e-01}, + {5.00000000000000000000000000000000000e-01, 4.62117157260009758502318483643672557e-01}, + {5.00000000000000111022302462515654042e-01, 4.62117157260009845815556563946604302e-01}, + {5.49306144334054669009503868437604979e-01, 4.99999999999999867483910937482244858e-01}, + {5.49306144334054780031806330953259021e-01, 4.99999999999999950750637784368995452e-01}, + {5.49306144334054891054108793468913063e-01, 5.00000000000000034017364631255736851e-01}, + {2.19999999999999964472863211994990706e+01, 9.99999999999999999844377355177323009e-01}, + {2.20000000000000000000000000000000000e+01, 9.99999999999999999844377355177324068e-01}, + {2.20000000000000035527136788005009294e+01, 9.99999999999999999844377355177325223e-01}, + {6.93147180559945397249066445510834455e-01, 6.00000000000000056212373967393698031e-01}, + {6.93147180559945286226763982995180413e-01, 5.99999999999999985158100391383682202e-01}, + {6.93147180559945175204461520479526371e-01, 5.99999999999999914103826815373657032e-01}, + {3.46573590279972698624533222755417228e-01, 3.33333333333333372369704144023402903e-01}, + {3.46573590279972643113381991497590207e-01, 3.33333333333333323026458605127557235e-01}, + {3.46573590279972587602230760239763185e-01, 3.33333333333333273683213066231709688e-01}, + {1.73286795139986349312266611377708614e-01, 1.71572875253809923708199182915954510e-01}, + {1.73286795139986321556690995748795103e-01, 1.71572875253809896769671427846052946e-01}, + {1.73286795139986293801115380119881593e-01, 1.71572875253809869831143672776151118e-01}, + {8.66433975699931746561333056888543069e-02, 8.64272337258898029408455765418952337e-02}, + {8.66433975699931607783454978743975516e-02, 8.64272337258897891667202185946638536e-02}, + {8.66433975699931469005576900599407963e-02, 8.64272337258897753925948606474324374e-02}, + {4.33216987849965873280666528444271535e-02, 4.32946174993891841617996586480128793e-02}, + {4.33216987849965803891727489371987758e-02, 4.32946174993891772359121833444914284e-02}, + {4.33216987849965734502788450299703982e-02, 4.32946174993891703100247080409699774e-02}, + {2.16608493924982936640333264222135767e-02, 2.16574623262262954492383391751347008e-02}, + {2.16608493924982901945863744685993879e-02, 2.16574623262262919814187163069359478e-02}, + {2.16608493924982867251394225149851991e-02, 2.16574623262262885135990934387371889e-02}, + {2.16608493924982867251394225149851991e-02, 2.16574623262262885135990934387371889e-02}, + {2.16608493924982901945863744685993879e-02, 2.16574623262262919814187163069359478e-02}, + {2.16608493924982936640333264222135767e-02, 2.16574623262262954492383391751347008e-02}, + {4.33216987849965734502788450299703982e-02, 4.32946174993891703100247080409699774e-02}, + {4.33216987849965803891727489371987758e-02, 4.32946174993891772359121833444914284e-02}, + {4.33216987849965873280666528444271535e-02, 4.32946174993891841617996586480128793e-02}, + {8.66433975699931469005576900599407963e-02, 8.64272337258897753925948606474324374e-02}, + {8.66433975699931607783454978743975516e-02, 8.64272337258897891667202185946638536e-02}, + {8.66433975699931746561333056888543069e-02, 8.64272337258898029408455765418952337e-02}, + {1.73286795139986293801115380119881593e-01, 1.71572875253809869831143672776151118e-01}, + {1.73286795139986321556690995748795103e-01, 1.71572875253809896769671427846052946e-01}, + {1.73286795139986349312266611377708614e-01, 1.71572875253809923708199182915954510e-01}, + {3.46573590279972587602230760239763185e-01, 3.33333333333333273683213066231709688e-01}, + {3.46573590279972643113381991497590207e-01, 3.33333333333333323026458605127557235e-01}, + {3.46573590279972698624533222755417228e-01, 3.33333333333333372369704144023402903e-01}, + {6.93147180559945175204461520479526371e-01, 5.99999999999999914103826815373657032e-01}, + {6.93147180559945286226763982995180413e-01, 5.99999999999999985158100391383682202e-01}, + {6.93147180559945397249066445510834455e-01, 6.00000000000000056212373967393698031e-01}, + {7.09782712893383859409368596971035004e+02, 1.00000000000000000000000000000000000e+00}, + {7.09782712893383973096206318587064743e+02, 1.00000000000000000000000000000000000e+00}, + {7.09782712893384086783044040203094482e+02, 1.00000000000000000000000000000000000e+00}, + {7.41782712893384086783044040203094482e+02, 1.00000000000000000000000000000000000e+00}, + {7.41782712893383973096206318587064743e+02, 1.00000000000000000000000000000000000e+00}, + {7.41782712893383859409368596971035004e+02, 1.00000000000000000000000000000000000e+00}, + {7.10475860073943749739555642008781433e+02, 1.00000000000000000000000000000000000e+00}, + {7.10475860073943863426393363624811172e+02, 1.00000000000000000000000000000000000e+00}, + {7.10475860073943977113231085240840912e+02, 1.00000000000000000000000000000000000e+00}, + {7.09782712893384086783044040203094482e+02, 1.00000000000000000000000000000000000e+00}, + {7.09782712893383973096206318587064743e+02, 1.00000000000000000000000000000000000e+00}, + {7.09782712893383859409368596971035004e+02, 1.00000000000000000000000000000000000e+00}, + {9.22337203685477478400000000000000000e+18, 1.00000000000000000000000000000000000e+00}, + {9.22337203685477580800000000000000000e+18, 1.00000000000000000000000000000000000e+00}, + {9.22337203685477785600000000000000000e+18, 1.00000000000000000000000000000000000e+00}, + {1.34217727999999985098838806152343750e+08, 1.00000000000000000000000000000000000e+00}, + {1.34217728000000000000000000000000000e+08, 1.00000000000000000000000000000000000e+00}, + {1.34217728000000029802322387695312500e+08, 1.00000000000000000000000000000000000e+00}, + {1.67772159999999981373548507690429688e+07, 1.00000000000000000000000000000000000e+00}, + {1.67772160000000000000000000000000000e+07, 1.00000000000000000000000000000000000e+00}, + {1.67772160000000037252902984619140625e+07, 1.00000000000000000000000000000000000e+00}, + {3.19999999999999964472863211994990706e+01, 9.99999999999999999999999999679237812e-01}, + {3.20000000000000000000000000000000000e+01, 9.99999999999999999999999999679237812e-01}, + {3.20000000000000071054273576010018587e+01, 9.99999999999999999999999999679237812e-01}, + {1.59999999999999982236431605997495353e+01, 9.99999999999974671668901811879331665e-01}, + {1.60000000000000000000000000000000000e+01, 9.99999999999974671668901811969315927e-01}, + {1.60000000000000035527136788005009294e+01, 9.99999999999974671668901812149284547e-01}, + {7.99999999999999911182158029987476766e+00, 9.99999774929675889809619027791781323e-01}, + {8.00000000000000000000000000000000000e+00, 9.99999774929675889810018832956368404e-01}, + {8.00000000000000177635683940025046468e+00, 9.99999774929675889810818443285542469e-01}, + {3.99999999999999955591079014993738383e+00, 9.99329299739067043196741615068852355e-01}, + {4.00000000000000000000000000000000000e+00, 9.99329299739067043792243344341724993e-01}, + {4.00000000000000088817841970012523234e+00, 9.99329299739067044983246802887468536e-01}, + {1.99999999999999977795539507496869192e+00, 9.64027580075816868258779231952432911e-01}, + {2.00000000000000000000000000000000000e+00, 9.64027580075816883946413724100923171e-01}, + {2.00000000000000044408920985006261617e+00, 9.64027580075816915321682708397883469e-01}, + {9.99999999999999888977697537484345958e-01, 7.61594155955764841492939901436512668e-01}, + {1.00000000000000000000000000000000000e+00, 7.61594155955764888119458282604793657e-01}, + {1.00000000000000022204460492503130808e+00, 7.61594155955764981372495044941331753e-01}, + {4.99999999999999944488848768742172979e-01, 4.62117157260009714845699443492203290e-01}, + {5.00000000000000000000000000000000000e-01, 4.62117157260009758502318483643672557e-01}, + {5.00000000000000111022302462515654042e-01, 4.62117157260009845815556563946604302e-01}, + {2.49999999999999972244424384371086489e-01, 2.44918662403709103187147915631612892e-01}, + {2.50000000000000000000000000000000000e-01, 2.44918662403709129277801131491016945e-01}, + {2.50000000000000055511151231257827021e-01, 2.44918662403709181459107563209824042e-01}, + {1.24999999999999986122212192185543245e-01, 1.24353001771596194391460985792144305e-01}, + {1.25000000000000000000000000000000000e-01, 1.24353001771596208054647275805892707e-01}, + {1.25000000000000027755575615628913511e-01, 1.24353001771596235381019855833389378e-01}, + {6.24999999999999930611060960927716224e-02, 6.24187467475125075782836114480350829e-02}, + {6.25000000000000000000000000000000000e-02, 6.24187467475125144901428911942113317e-02}, + {6.25000000000000138777878078144567553e-02, 6.24187467475125283138614506865638292e-02}, + {3.12499999999999965305530480463858112e-02, 3.12398314460312533021176543496182149e-02}, + {3.12500000000000000000000000000000000e-02, 3.12398314460312567681786791091369499e-02}, + {3.12500000000000069388939039072283776e-02, 3.12398314460312637003007286281744168e-02}, + {1.56249999999999982652765240231929056e-02, 1.56237285584088634680488027509294906e-02}, + {1.56250000000000000000000000000000000e-02, 1.56237285584088652023488311762919065e-02}, + {1.56250000000000034694469519536141888e-02, 1.56237285584088686709488880270167445e-02}, + {6.10351562499999932237364219655972875e-05, 6.10351561742087681889301535131725312e-05}, + {6.10351562500000000000000000000000000e-05, 6.10351561742087749651937063040263414e-05}, + {6.10351562500000135525271560688054251e-05, 6.10351561742087885177208118857339557e-05}, + {9.31322574615478412227423430871540641e-10, 9.31322574615478411958158908556102005e-10}, + {9.31322574615478515625000000000000000e-10, 9.31322574615478515355735477684561274e-10}, + {9.31322574615478722420153138256918718e-10, 9.31322574615478722150888615941479902e-10}, + {2.77555756156289104291028806826931429e-17, 2.77555756156289104291028806826931349e-17}, + {2.77555756156289135105907917022705078e-17, 2.77555756156289135105907917022704998e-17}, + {2.77555756156289196735666137414252376e-17, 2.77555756156289196735666137414252322e-17}, + {1.79769313486231570814527423731704357e+308, 1.00000000000000000000000000000000000e+00}, + {1.79769313486231570814527423731704357e+308, 1.00000000000000000000000000000000000e+00}, + {1.79769313486231570814527423731704357e+308, 1.00000000000000000000000000000000000e+00}, + {1.79769313486231550856124328384506240e+308, 1.00000000000000000000000000000000000e+00}, + {3.14159265358979311599796346854418516e+00, 9.96272076220749943353314537833579484e-01}, + {1.57079632679489655799898173427209258e+00, 9.17152335667274336647462811870662140e-01}, + {1.00000000000000022204460492503130808e+00, 7.61594155955764981372495044941331753e-01}, + {1.00000000000000000000000000000000000e+00, 7.61594155955764888119458282604793657e-01}, + {9.99999999999999888977697537484345958e-01, 7.61594155955764841492939901436512668e-01}, + {7.85398163397448278999490867136046290e-01, 6.55794202632672418203926030568705821e-01}, + {2.22507385850720187715587855857894824e-308, 2.22507385850720187715587855857894824e-308}, + {2.22507385850720138309023271733240406e-308, 2.22507385850720138309023271733240406e-308}, + {2.22507385850720088902458687608585989e-308, 2.22507385850720088902458687608585989e-308}, + {2.22507385850720039495894103483931571e-308, 2.22507385850720039495894103483931571e-308}, + {9.88131291682493088353137585736442745e-324, 9.88131291682493088353137585736442745e-324}, + {4.94065645841246544176568792868221372e-324, 4.94065645841246544176568792868221372e-324}, + }; + + for (int i = 0; i < testCases.length; i++) { + double[] testCase = testCases[i]; + failures += testTanhCaseWithUlpDiff(testCase[0], + testCase[1], + 3.0); + } + return failures; } diff --git a/test/jdk/java/lang/String/CountNonZeroAscii.java b/test/jdk/java/lang/String/CountNonZeroAscii.java new file mode 100644 index 00000000000..d4b8a4fb1eb --- /dev/null +++ b/test/jdk/java/lang/String/CountNonZeroAscii.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, Alibaba Group Holding Limited. 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.internal.access.JavaLangAccess; +import jdk.internal.access.SharedSecrets; + +import java.nio.charset.StandardCharsets; +import java.util.Arrays; + +/* + * @test + * @modules java.base/jdk.internal.access + * @summary test latin1 String countNonZeroAscii + * @run main/othervm -XX:+CompactStrings CountNonZeroAscii + * @run main/othervm -XX:-CompactStrings CountNonZeroAscii + */ +public class CountNonZeroAscii { + private static final JavaLangAccess JLA = SharedSecrets.getJavaLangAccess(); + + public static void main(String [] args) { + byte[] bytes = new byte[1000]; + + Arrays.fill(bytes, (byte) 'A'); + String s = new String(bytes, StandardCharsets.ISO_8859_1); + assertEquals(bytes.length, JLA.countNonZeroAscii(s)); + + for (int i = 0; i < bytes.length; i++) { + for (int j = Byte.MIN_VALUE; j <= 0; j++) { + bytes[i] = (byte) j; + s = new String(bytes, StandardCharsets.ISO_8859_1); + assertEquals(i, JLA.countNonZeroAscii(s)); + } + bytes[i] = (byte) 'A'; + } + } + + static void assertEquals(int expected, int actual) { + if (expected != actual) { + throw new AssertionError("Expected " + expected + " but got " + actual); + } + } +} diff --git a/test/jdk/java/lang/StringBuffer/HugeCapacity.java b/test/jdk/java/lang/StringBuffer/HugeCapacity.java index e3c98496c50..d1ff51dddb2 100644 --- a/test/jdk/java/lang/StringBuffer/HugeCapacity.java +++ b/test/jdk/java/lang/StringBuffer/HugeCapacity.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,11 +21,14 @@ * questions. */ +import jdk.internal.util.ArraysSupport; + /** * @test * @bug 8218227 * @summary StringBuilder/StringBuffer constructor throws confusing * NegativeArraySizeException + * @modules java.base/jdk.internal.util * @requires (sun.arch.data.model == "64" & os.maxMemory >= 8G) * @run main/othervm -Xms6G -Xmx6G HugeCapacity */ @@ -43,7 +46,7 @@ public class HugeCapacity { private static void testHugeInitialString() { try { - String str = "Z".repeat(Integer.MAX_VALUE - 8); + String str = "Z".repeat(ArraysSupport.SOFT_MAX_ARRAY_LENGTH); StringBuffer sb = new StringBuffer(str); } catch (OutOfMemoryError ignore) { } catch (Throwable unexpected) { diff --git a/test/jdk/java/lang/StringBuilder/HugeCapacity.java b/test/jdk/java/lang/StringBuilder/HugeCapacity.java index a584ce1f07a..a81f1614fe5 100644 --- a/test/jdk/java/lang/StringBuilder/HugeCapacity.java +++ b/test/jdk/java/lang/StringBuilder/HugeCapacity.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,11 +21,14 @@ * questions. */ +import jdk.internal.util.ArraysSupport; + /** * @test * @bug 8149330 8218227 * @summary Capacity should not get close to Integer.MAX_VALUE unless * necessary + * @modules java.base/jdk.internal.util * @requires (sun.arch.data.model == "64" & os.maxMemory >= 8G) * @run main/othervm -Xms6G -Xmx6G -XX:+CompactStrings HugeCapacity true * @run main/othervm -Xms6G -Xmx6G -XX:-CompactStrings HugeCapacity false @@ -75,7 +78,7 @@ public class HugeCapacity { private static void testHugeInitialString() { try { - String str = "Z".repeat(Integer.MAX_VALUE - 8); + String str = "Z".repeat(ArraysSupport.SOFT_MAX_ARRAY_LENGTH); StringBuilder sb = new StringBuilder(str); } catch (OutOfMemoryError ignore) { } catch (Throwable unexpected) { diff --git a/test/jdk/java/lang/Thread/virtual/BigStackChunk.java b/test/jdk/java/lang/Thread/virtual/BigStackChunk.java new file mode 100644 index 00000000000..1e76856d3c0 --- /dev/null +++ b/test/jdk/java/lang/Thread/virtual/BigStackChunk.java @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test id=default + * @bug 8335362 + * @summary Test virtual thread usage with big stackChunks + * @requires vm.continuations + * @run junit/othervm BigStackChunk + */ + +import java.util.concurrent.locks.ReentrantLock; + +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; + +class BigStackChunk { + + void recurse(int cnt, ReentrantLock rlock) { + int i1 = cnt; + int i2 = i1 + 1; + int i3 = i2 + 1; + int i4 = i3 + 1; + int i5 = i4 + 1; + int i6 = i5 + 1; + int i7 = i6 + 1; + long ll = 2 * (long)i1; + float ff = ll + 1.2f; + double dd = ff + 1.3D; + + if (cnt > 0) { + recurse(cnt - 1, rlock); + } else { + rlock.lock(); + rlock.unlock(); + } + } + + @Test + void bigStackChunkTest() throws Exception { + int VTHREAD_CNT = Runtime.getRuntime().availableProcessors(); + ReentrantLock rlock = new ReentrantLock(); + Thread[] vthreads = new Thread[VTHREAD_CNT]; + + rlock.lock(); + for (int i = 0; i < VTHREAD_CNT; i++) { + vthreads[i] = Thread.ofVirtual().start(() -> { + // Set up things so that half of the carriers will commit lots of + // pages in the stack while running the mounted vthread and half + // will just commit very few ones. + if (Math.random() < 0.5) { + recurse(300, rlock); + } else { + recurse(1, rlock); + } + }); + } + await(vthreads[0], Thread.State.WAITING); + // Now we expect that some vthread that recursed a lot is mounted on + // a carrier that previously run a vthread that didn't recurse at all. + rlock.unlock(); + + for (int i = 0; i < VTHREAD_CNT; i++) { + vthreads[i].join(); + } + } + + private void await(Thread thread, Thread.State expectedState) throws InterruptedException { + Thread.State state = thread.getState(); + while (state != expectedState) { + assertTrue(state != Thread.State.TERMINATED, "Thread has terminated"); + Thread.sleep(10); + state = thread.getState(); + } + } +} \ No newline at end of file diff --git a/test/jdk/java/lang/Thread/virtual/JfrEvents.java b/test/jdk/java/lang/Thread/virtual/JfrEvents.java index 539ac2104ed..bc952331f64 100644 --- a/test/jdk/java/lang/Thread/virtual/JfrEvents.java +++ b/test/jdk/java/lang/Thread/virtual/JfrEvents.java @@ -25,7 +25,7 @@ * @test * @summary Basic test for JFR jdk.VirtualThreadXXX events * @requires vm.continuations - * @modules jdk.jfr java.base/java.lang:+open + * @modules jdk.jfr java.base/java.lang:+open jdk.management * @library /test/lib * @run junit/othervm --enable-native-access=ALL-UNNAMED JfrEvents */ @@ -50,7 +50,7 @@ import jdk.jfr.consumer.RecordedEvent; import jdk.jfr.consumer.RecordingFile; import jdk.test.lib.thread.VThreadPinner; -import jdk.test.lib.thread.VThreadRunner; +import jdk.test.lib.thread.VThreadRunner; // ensureParallelism requires jdk.management import jdk.test.lib.thread.VThreadScheduler; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.BeforeAll; diff --git a/test/jdk/java/lang/Thread/virtual/MonitorEnterExit.java b/test/jdk/java/lang/Thread/virtual/MonitorEnterExit.java index d1f2bf0c1bf..c2389ab7ddd 100644 --- a/test/jdk/java/lang/Thread/virtual/MonitorEnterExit.java +++ b/test/jdk/java/lang/Thread/virtual/MonitorEnterExit.java @@ -24,7 +24,7 @@ /* * @test id=default * @summary Test virtual thread with monitor enter/exit - * @modules java.base/java.lang:+open + * @modules java.base/java.lang:+open jdk.management * @library /test/lib * @run junit/othervm --enable-native-access=ALL-UNNAMED MonitorEnterExit */ @@ -43,7 +43,7 @@ import java.util.stream.IntStream; import java.util.stream.Stream; import jdk.test.lib.thread.VThreadPinner; -import jdk.test.lib.thread.VThreadRunner; +import jdk.test.lib.thread.VThreadRunner; // ensureParallelism requires jdk.management import jdk.test.lib.thread.VThreadScheduler; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.BeforeAll; diff --git a/test/jdk/java/lang/Thread/virtual/MonitorWaitNotify.java b/test/jdk/java/lang/Thread/virtual/MonitorWaitNotify.java index 5f730dbbf0a..81f1c1ea97f 100644 --- a/test/jdk/java/lang/Thread/virtual/MonitorWaitNotify.java +++ b/test/jdk/java/lang/Thread/virtual/MonitorWaitNotify.java @@ -24,7 +24,7 @@ /* * @test id=default * @summary Test virtual threads using Object.wait/notifyAll - * @modules java.base/java.lang:+open + * @modules java.base/java.lang:+open jdk.management * @library /test/lib * @run junit/othervm --enable-native-access=ALL-UNNAMED MonitorWaitNotify */ @@ -46,8 +46,7 @@ import java.util.stream.Stream; import java.util.stream.Collectors; import jdk.test.lib.thread.VThreadScheduler; -import jdk.test.lib.thread.VThreadRunner; -import jdk.test.lib.thread.VThreadRunner; +import jdk.test.lib.thread.VThreadRunner; // ensureParallelism requires jdk.management import jdk.test.lib.thread.VThreadPinner; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.BeforeAll; diff --git a/test/jdk/java/lang/Thread/virtual/ThreadAPI.java b/test/jdk/java/lang/Thread/virtual/ThreadAPI.java index 3bb5c75a1b5..cda302f391f 100644 --- a/test/jdk/java/lang/Thread/virtual/ThreadAPI.java +++ b/test/jdk/java/lang/Thread/virtual/ThreadAPI.java @@ -25,7 +25,7 @@ * @test id=default * @bug 8284161 8286788 8321270 * @summary Test Thread API with virtual threads - * @modules java.base/java.lang:+open + * @modules java.base/java.lang:+open jdk.management * @library /test/lib * @run junit/othervm --enable-native-access=ALL-UNNAMED ThreadAPI */ @@ -33,7 +33,7 @@ /* * @test id=no-vmcontinuations * @requires vm.continuations - * @modules java.base/java.lang:+open + * @modules java.base/java.lang:+open jdk.management * @library /test/lib * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:-VMContinuations * --enable-native-access=ALL-UNNAMED ThreadAPI @@ -62,7 +62,7 @@ import java.util.stream.Stream; import java.nio.channels.Selector; import jdk.test.lib.thread.VThreadPinner; -import jdk.test.lib.thread.VThreadRunner; +import jdk.test.lib.thread.VThreadRunner; // ensureParallelism requires jdk.management import jdk.test.lib.thread.VThreadScheduler; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.BeforeAll; diff --git a/test/jdk/java/lang/Thread/virtual/VirtualThreadPinnedEventThrows.java b/test/jdk/java/lang/Thread/virtual/VirtualThreadPinnedEventThrows.java index 0c5f1c3d6b4..2d822655428 100644 --- a/test/jdk/java/lang/Thread/virtual/VirtualThreadPinnedEventThrows.java +++ b/test/jdk/java/lang/Thread/virtual/VirtualThreadPinnedEventThrows.java @@ -24,7 +24,7 @@ /** * @test * @summary Test parking when pinned and emitting the JFR VirtualThreadPinnedEvent throws - * @modules java.base/java.lang:+open java.base/jdk.internal.event + * @modules java.base/java.lang:+open java.base/jdk.internal.event jdk.management * @library /test/lib * @compile/module=java.base jdk/internal/event/VirtualThreadPinnedEvent.java * @run junit/othervm --enable-native-access=ALL-UNNAMED VirtualThreadPinnedEventThrows @@ -36,7 +36,7 @@ import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.locks.LockSupport; import jdk.internal.event.VirtualThreadPinnedEvent; -import jdk.test.lib.thread.VThreadRunner; +import jdk.test.lib.thread.VThreadRunner; // ensureParallelism requires jdk.management import jdk.test.lib.thread.VThreadPinner; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.BeforeAll; diff --git a/test/jdk/java/lang/Thread/virtual/stress/GetStackTraceALotWhenBlocking.java b/test/jdk/java/lang/Thread/virtual/stress/GetStackTraceALotWhenBlocking.java index a5aea9ee398..5e15ea083e4 100644 --- a/test/jdk/java/lang/Thread/virtual/stress/GetStackTraceALotWhenBlocking.java +++ b/test/jdk/java/lang/Thread/virtual/stress/GetStackTraceALotWhenBlocking.java @@ -26,7 +26,7 @@ * @summary Stress test Thread.getStackTrace on virtual threads that are blocking or * blocked on monitorenter * @requires vm.debug != true - * @modules java.base/java.lang:+open + * @modules jdk.management * @library /test/lib * @run main/othervm GetStackTraceALotWhenBlocking 500000 */ @@ -34,7 +34,7 @@ /* * @test * @requires vm.debug == true & vm.continuations - * @modules java.base/java.lang:+open + * @modules jdk.management * @library /test/lib * @run main/othervm/timeout=300 GetStackTraceALotWhenBlocking 50000 */ @@ -42,7 +42,7 @@ import java.time.Instant; import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.atomic.AtomicBoolean; -import jdk.test.lib.thread.VThreadRunner; +import jdk.test.lib.thread.VThreadRunner; // ensureParallelism requires jdk.management public class GetStackTraceALotWhenBlocking { diff --git a/test/jdk/java/lang/Thread/virtual/stress/GetStackTraceALotWhenPinned.java b/test/jdk/java/lang/Thread/virtual/stress/GetStackTraceALotWhenPinned.java index d7e6c3a8de4..260446a1e3d 100644 --- a/test/jdk/java/lang/Thread/virtual/stress/GetStackTraceALotWhenPinned.java +++ b/test/jdk/java/lang/Thread/virtual/stress/GetStackTraceALotWhenPinned.java @@ -26,7 +26,7 @@ * @bug 8322818 * @summary Stress test Thread.getStackTrace on a virtual thread that is pinned * @requires vm.debug != true - * @modules java.base/java.lang:+open + * @modules jdk.management * @library /test/lib * @run main/othervm --enable-native-access=ALL-UNNAMED GetStackTraceALotWhenPinned 500000 */ @@ -34,7 +34,7 @@ /* * @test * @requires vm.debug == true - * @modules java.base/java.lang:+open + * @modules jdk.management * @library /test/lib * @run main/othervm/timeout=300 --enable-native-access=ALL-UNNAMED GetStackTraceALotWhenPinned 200000 */ @@ -42,7 +42,7 @@ import java.time.Instant; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.locks.LockSupport; -import jdk.test.lib.thread.VThreadRunner; +import jdk.test.lib.thread.VThreadRunner; // ensureParallelism requires jdk.management import jdk.test.lib.thread.VThreadPinner; public class GetStackTraceALotWhenPinned { diff --git a/test/jdk/java/lang/invoke/BigArityTest.java b/test/jdk/java/lang/invoke/BigArityTest.java index 338903f3163..2dba056a183 100644 --- a/test/jdk/java/lang/invoke/BigArityTest.java +++ b/test/jdk/java/lang/invoke/BigArityTest.java @@ -24,7 +24,7 @@ /* @test * @summary High arity invocations * @compile BigArityTest.java - * @run junit/othervm/timeout=2500 -XX:+IgnoreUnrecognizedVMOptions -XX:-VerifyDependencies -esa -DBigArityTest.ITERATION_COUNT=1 test.java.lang.invoke.BigArityTest + * @run junit/othervm/timeout=2500 -XX:+IgnoreUnrecognizedVMOptions -XX:-VerifyDependencies -XX:CompileCommand=memlimit,*.*,0 -esa -DBigArityTest.ITERATION_COUNT=1 test.java.lang.invoke.BigArityTest */ package test.java.lang.invoke; diff --git a/test/jdk/java/lang/invoke/TestLambdaFormCustomization.java b/test/jdk/java/lang/invoke/TestLambdaFormCustomization.java new file mode 100644 index 00000000000..60ba4af590e --- /dev/null +++ b/test/jdk/java/lang/invoke/TestLambdaFormCustomization.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.lang.invoke.MethodHandles; +import java.lang.invoke.VarHandle; +import java.util.ArrayList; + +/** + * @test + * @bug 8340812 + * @summary Verify that LambdaForm customization via MethodHandle::updateForm is thread safe. + * @run main TestLambdaFormCustomization + * @run main/othervm -Djava.lang.invoke.MethodHandle.CUSTOMIZE_THRESHOLD=0 TestLambdaFormCustomization + */ +public class TestLambdaFormCustomization { + + String str = "test"; + static final String value = "test" + 42; + + // Trigger concurrent LambdaForm customization for VarHandle invokers + void test() throws NoSuchFieldException, IllegalAccessException { + VarHandle varHandle = MethodHandles.lookup().in(getClass()).findVarHandle(getClass(), "str", String.class); + + ArrayList threads = new ArrayList<>(); + for (int threadIdx = 0; threadIdx < 10; threadIdx++) { + threads.add(new Thread(() -> { + for (int i = 0; i < 1000; i++) { + varHandle.compareAndExchange(this, value, value); + varHandle.compareAndExchange(this, value, value); + varHandle.compareAndExchange(this, value, value); + } + })); + } + threads.forEach(Thread::start); + threads.forEach(t -> { + try { + t.join(); + } catch (Throwable e) { + throw new IllegalStateException(e); + } + }); + } + + public static void main(String[] args) throws Exception { + TestLambdaFormCustomization t = new TestLambdaFormCustomization(); + for (int i = 0; i < 4000; ++i) { + t.test(); + } + } +} diff --git a/test/jdk/java/lang/management/MemoryMXBean/LowMemoryTest2.java b/test/jdk/java/lang/management/MemoryMXBean/LowMemoryTest2.java index 917e8226bb1..de1b22c4075 100644 --- a/test/jdk/java/lang/management/MemoryMXBean/LowMemoryTest2.java +++ b/test/jdk/java/lang/management/MemoryMXBean/LowMemoryTest2.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,7 +36,7 @@ * @bug 4982128 * @summary Test low memory detection of non-heap memory pool * - * @run main/othervm/timeout=600 -noclassgc -XX:MaxMetaspaceSize=32m + * @run main/othervm/timeout=600 -Xnoclassgc -XX:MaxMetaspaceSize=32m * LowMemoryTest2 */ @@ -45,7 +45,7 @@ * @bug 4982128 * @summary Test low memory detection of non-heap memory pool * - * @run main/othervm/timeout=600 -noclassgc -XX:MaxMetaspaceSize=16m + * @run main/othervm/timeout=600 -Xnoclassgc -XX:MaxMetaspaceSize=16m * -XX:CompressedClassSpaceSize=4m LowMemoryTest2 */ diff --git a/test/jdk/java/lang/management/MemoryMXBean/MemoryUtil.java b/test/jdk/java/lang/management/MemoryMXBean/MemoryUtil.java index 55605c6c1c4..5fae7468b79 100644 --- a/test/jdk/java/lang/management/MemoryMXBean/MemoryUtil.java +++ b/test/jdk/java/lang/management/MemoryMXBean/MemoryUtil.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -56,6 +56,8 @@ public class MemoryUtil { (pool.isUsageThresholdSupported() ? pool.getUsageThreshold() : -1)); System.out.println(INDENT + "ThresholdCount: " + (pool.isUsageThresholdSupported() ? pool.getUsageThresholdCount() : -1)); + System.out.println(INDENT + "CollectionThresholdCount: " + + (pool.isCollectionUsageThresholdSupported() ? pool.getCollectionUsageThresholdCount() : -1)); System.out.print(INDENT + "Manager = ["); String[] mgrs = pool.getMemoryManagerNames(); for (int i = 0; i < mgrs.length; i++) { diff --git a/test/jdk/java/lang/management/MemoryMXBean/RunUtil.java b/test/jdk/java/lang/management/MemoryMXBean/RunUtil.java index e94bc6c3c2c..314aab44c4b 100644 --- a/test/jdk/java/lang/management/MemoryMXBean/RunUtil.java +++ b/test/jdk/java/lang/management/MemoryMXBean/RunUtil.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -73,6 +73,7 @@ public class RunUtil { } opts.addAll(Arrays.asList(testOpts)); opts.add(main); + opts.add("trace"); OutputAnalyzer output = ProcessTools.executeProcess(opts.toArray(new String[0])); output.shouldHaveExitValue(0); diff --git a/test/jdk/java/lang/management/ThreadMXBean/Locks.java b/test/jdk/java/lang/management/ThreadMXBean/Locks.java index a9c45887780..5b4d360ae21 100644 --- a/test/jdk/java/lang/management/ThreadMXBean/Locks.java +++ b/test/jdk/java/lang/management/ThreadMXBean/Locks.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -422,6 +422,9 @@ public class Locks { lock + " expected to have owner"); } for (ThreadInfo info1 : infos) { + if (info1 == null) { + continue; // Missing thread, e.g. completed. Ignore. + } if (info1.getThreadId() == threadId) { ownerInfo = info1; break; diff --git a/test/jdk/java/lang/management/ThreadMXBean/VirtualThreadDeadlocks.java b/test/jdk/java/lang/management/ThreadMXBean/VirtualThreadDeadlocks.java index d4da6073337..91b31c41be3 100644 --- a/test/jdk/java/lang/management/ThreadMXBean/VirtualThreadDeadlocks.java +++ b/test/jdk/java/lang/management/ThreadMXBean/VirtualThreadDeadlocks.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,7 @@ * @bug 8284161 8287103 * @summary Test ThredMXBean.findMonitorDeadlockedThreads with cycles of * platform and virtual threads in deadlock - * @modules java.base/java.lang:+open java.management + * @modules java.management jdk.management * @library /test/lib * @run main/othervm VirtualThreadDeadlocks PP * @run main/othervm VirtualThreadDeadlocks PV @@ -36,7 +36,7 @@ /** * @test id=no-vmcontinuations * @requires vm.continuations - * @modules java.base/java.lang:+open java.management + * @modules java.management jdk.management * @library /test/lib * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-VMContinuations VirtualThreadDeadlocks PP * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-VMContinuations VirtualThreadDeadlocks PV @@ -48,7 +48,7 @@ import java.lang.management.ThreadMXBean; import java.util.Arrays; import java.util.concurrent.CyclicBarrier; import java.util.stream.Stream; -import jdk.test.lib.thread.VThreadRunner; +import jdk.test.lib.thread.VThreadRunner; // ensureParallelism requires jdk.management public class VirtualThreadDeadlocks { private static final Object LOCK1 = new Object(); diff --git a/test/jdk/java/lang/ref/SoftReference/Pin.java b/test/jdk/java/lang/ref/SoftReference/Pin.java index 5416b0f575a..35aa4d9a512 100644 --- a/test/jdk/java/lang/ref/SoftReference/Pin.java +++ b/test/jdk/java/lang/ref/SoftReference/Pin.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,9 +24,7 @@ /* @test * @bug 4076287 * @summary Invoking get on a SoftReference shouldn't pin the referent - * @run main/othervm -ms16m -mx16m Pin - * @author Peter Jones - * @author Mark Reinhold + * @run main/othervm -Xms16m -Xmx16m Pin */ diff --git a/test/jdk/java/lang/reflect/Generics/TestMissingTypeVariable.java b/test/jdk/java/lang/reflect/Generics/TestMissingTypeVariable.java new file mode 100644 index 00000000000..64f1457bdf7 --- /dev/null +++ b/test/jdk/java/lang/reflect/Generics/TestMissingTypeVariable.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @library /test/lib + * @bug 8337302 + * @enablePreview + * @summary Tests that an exception is thrown if a type variable is not declared + */ + +import jdk.test.lib.ByteCodeLoader; + +import java.lang.classfile.ClassFile; +import java.lang.classfile.Signature; +import java.lang.classfile.attribute.SignatureAttribute; +import java.lang.constant.ClassDesc; +import java.lang.reflect.AccessFlag; +import java.lang.reflect.Type; + +public class TestMissingTypeVariable { + + public static void main(String[] args) throws Exception { + ClassFile cf = ClassFile.of(); + byte[] bytes = cf.build( + ClassDesc.of("sample.MissingVariable"), + classBuilder -> { + classBuilder.withSuperclass(ClassDesc.of("java.lang.Object")); + classBuilder.withFlags(AccessFlag.PUBLIC); + classBuilder.withField("f", + ClassDesc.of("java.lang.Object"), + fieldBuilder -> fieldBuilder.withFlags(AccessFlag.PUBLIC).with(SignatureAttribute.of(Signature.parseFrom("TA;")))); + }); + /* + package sample; + public class MissingVariable { + public A f; // undeclared type variable + } + */ + Class missing = ByteCodeLoader.load("sample.MissingVariable", bytes); + try { + Type type = missing.getField("f").getGenericType(); + throw new IllegalStateException("Expected TypeNotPresentException but got: " + type); + } catch (TypeNotPresentException e) { + if (!"A".equals(e.typeName())) { + throw new IllegalStateException("Unexpected name: " + e.typeName()); + } + } + } +} diff --git a/test/jdk/java/math/BigInteger/MutableBigIntegerShiftTests.java b/test/jdk/java/math/BigInteger/MutableBigIntegerShiftTests.java new file mode 100644 index 00000000000..e64cae480d3 --- /dev/null +++ b/test/jdk/java/math/BigInteger/MutableBigIntegerShiftTests.java @@ -0,0 +1,191 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import jdk.test.lib.RandomFactory; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.junit.jupiter.params.provider.Arguments; + +import java.math.BigInteger; +import java.math.MutableBigIntegerBox; +import java.util.Arrays; +import java.util.Random; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static java.math.MutableBigIntegerBox.*; + +/** + * @test + * @bug 8336274 + * @summary Tests for correctness of MutableBigInteger.leftShift(int) + * @library /test/lib + * @build jdk.test.lib.RandomFactory + * @build java.base/java.math.MutableBigIntegerBox + * @key randomness + * @run junit MutableBigIntegerShiftTests + */ +public class MutableBigIntegerShiftTests { + + private static final int ORDER_SMALL = 60; + private static final int ORDER_MEDIUM = 100; + + private static final Random random = RandomFactory.getRandom(); + + private static int[] orders() { + return new int[] { ORDER_SMALL, ORDER_MEDIUM }; + } + + @ParameterizedTest + @MethodSource("orders") + public void shift(int order) { + for (int i = 0; i < 100; i++) { + test(fetchNumber(order), random.nextInt(200)); + } + } + + @ParameterizedTest + @MethodSource("pathTargetedCases") + public void test(MutableBigIntegerBox x, int n) { + leftShiftAssertions(x, n); + } + + private static Arguments[] pathTargetedCases() { + return new Arguments[] { + // intLen == 0 + Arguments.of(MutableBigIntegerBox.ZERO, + random.nextInt(33)), + // intLen != 0 && n <= leadingZeros + Arguments.of(new MutableBigIntegerBox(new int[] { (int) random.nextLong(1L, 1L << 16) }), + random.nextInt(1, 17)), + // intLen != 0 && n > leadingZeros && nBits <= leadingZeros && value.length < newLen && nBits == 0 + Arguments.of(new MutableBigIntegerBox(new int[] { (int) random.nextLong(1L, 1L << 32) }), + 32), + // intLen != 0 && n > leadingZeros && nBits <= leadingZeros && value.length < newLen && nBits != 0 + Arguments.of(new MutableBigIntegerBox(new int[] { (int) random.nextLong(1L, 1L << 16) }), + 32 + random.nextInt(1, 17)), + // intLen != 0 && n > leadingZeros && nBits <= leadingZeros && value.length >= newLen && nBits == 0 + // && newOffset != offset + Arguments.of(new MutableBigIntegerBox(new int[] { random.nextInt(), (int) random.nextLong(1L, 1L << 32) }, 1, 1), + 32), + // intLen != 0 && n > leadingZeros && nBits <= leadingZeros && value.length >= newLen && nBits == 0 + // && newOffset == offset + Arguments.of(new MutableBigIntegerBox(new int[] { (int) random.nextLong(1L, 1L << 32), random.nextInt() }, 0, 1), + 32), + // intLen != 0 && n > leadingZeros && nBits <= leadingZeros && value.length >= newLen && nBits != 0 + // && newOffset != offset + Arguments.of(new MutableBigIntegerBox(new int[] { random.nextInt(), (int) random.nextLong(1L, 1L << 16) }, 1, 1), + 32 + random.nextInt(1, 17)), + // intLen != 0 && n > leadingZeros && nBits <= leadingZeros && value.length >= newLen && nBits != 0 + // && newOffset == offset + Arguments.of(new MutableBigIntegerBox(new int[] { (int) random.nextLong(1L, 1L << 16), random.nextInt() }, 0, 1), + 32 + random.nextInt(1, 17)), + // intLen != 0 && n > leadingZeros && nBits > leadingZeros && value.length < newLen + Arguments.of(new MutableBigIntegerBox(new int[] { (int) random.nextLong(1L << 15, 1L << 32) }), + random.nextInt(17, 32)), + // intLen != 0 && n > leadingZeros && nBits > leadingZeros && value.length >= newLen && newOffset != offset + Arguments.of(new MutableBigIntegerBox(new int[] { random.nextInt(), (int) random.nextLong(1L << 15, 1L << 32) }, 1, 1), + random.nextInt(17, 32)), + // intLen != 0 && n > leadingZeros && nBits > leadingZeros && value.length >= newLen && newOffset == offset + Arguments.of(new MutableBigIntegerBox(new int[] { (int) random.nextLong(1L << 15, 1L << 32), random.nextInt() }, 0, 1), + random.nextInt(17, 32)), + }; + } + + private static void leftShiftAssertions(MutableBigIntegerBox x, int n) { + MutableBigIntegerBox xShifted = x.shiftLeft(n); + assertEquals(x.multiply(new MutableBigIntegerBox(BigInteger.TWO.pow(n))), xShifted); + assertEquals(x, xShifted.shiftRight(n)); + } + + /* + * Get a random or boundary-case number. This is designed to provide + * a lot of numbers that will find failure points, such as max sized + * numbers, empty MutableBigIntegers, etc. + * + * If order is less than 2, order is changed to 2. + */ + private static MutableBigIntegerBox fetchNumber(int order) { + int numType = random.nextInt(8); + MutableBigIntegerBox result = null; + if (order < 2) order = 2; + + int[] val; + switch (numType) { + case 0: // Empty + result = MutableBigIntegerBox.ZERO; + break; + + case 1: // One + result = MutableBigIntegerBox.ONE; + break; + + case 2: // All bits set in number + int numInts = (order + 31) >> 5; + int[] fullBits = new int[numInts]; + Arrays.fill(fullBits, -1); + + fullBits[0] &= -1 >>> -order; + result = new MutableBigIntegerBox(fullBits); + break; + + case 3: // One bit in number + result = MutableBigIntegerBox.ONE.shiftLeft(random.nextInt(order)); + break; + + case 4: // Random bit density + val = new int[(order + 31) >> 5]; + int iterations = random.nextInt(order); + for (int i = 0; i < iterations; i++) { + int bitIdx = random.nextInt(order); + val[bitIdx >> 5] |= 1 << bitIdx; + } + result = new MutableBigIntegerBox(val); + break; + case 5: // Runs of consecutive ones and zeros + result = ZERO; + int remaining = order; + int bit = random.nextInt(2); + while (remaining > 0) { + int runLength = Math.min(remaining, random.nextInt(order)); + result = result.shiftLeft(runLength); + if (bit > 0) + result = result.add(ONE.shiftLeft(runLength).subtract(ONE)); + remaining -= runLength; + bit = 1 - bit; + } + break; + case 6: // random bits with trailing space + int len = random.nextInt((order + 31) >> 5) + 1; + int offset = random.nextInt(len); + val = new int[len << 1]; + for (int i = 0; i < val.length; i++) + val[i] = random.nextInt(); + result = new MutableBigIntegerBox(val, offset, len); + break; + default: // random bits + result = new MutableBigIntegerBox(new BigInteger(order, random)); + } + + return result; + } +} diff --git a/test/jdk/java/math/BigInteger/java.base/java/math/MutableBigIntegerBox.java b/test/jdk/java/math/BigInteger/java.base/java/math/MutableBigIntegerBox.java new file mode 100644 index 00000000000..1f82e449198 --- /dev/null +++ b/test/jdk/java/math/BigInteger/java.base/java/math/MutableBigIntegerBox.java @@ -0,0 +1,180 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.math; + +import java.util.Arrays; + +/** + * A class for tests. + */ +public class MutableBigIntegerBox { + + /** + * Constant zero + */ + public static final MutableBigIntegerBox ZERO = new MutableBigIntegerBox(new MutableBigInteger()); + + /** + * Constant one + */ + public static final MutableBigIntegerBox ONE = new MutableBigIntegerBox(MutableBigInteger.ONE); + + /** + * Constant two + */ + public static final MutableBigIntegerBox TWO = new MutableBigIntegerBox(new MutableBigInteger(2)); + + private MutableBigInteger val; + + MutableBigIntegerBox(MutableBigInteger val) { + this.val = val; + } + + /** + * Construct MutableBigIntegerBox from magnitude, starting from + * offset and with a length of intLen ints. + * The value is normalized. + * @param mag the magnitude + * @param offset the offset where the value starts + * @param intLen the length of the value, in int words. + */ + public MutableBigIntegerBox(int[] mag, int offset, int intLen) { + this(new MutableBigInteger(mag)); + val.offset = offset; + val.intLen = intLen; + val.normalize(); + } + + /** + * Construct MutableBigIntegerBox from magnitude. + * The value is normalized. + * @param mag the magnitude + */ + public MutableBigIntegerBox(int[] mag) { + this(mag, 0, mag.length); + } + + /** + * Construct MutableBigIntegerBox from BigInteger val + * @param val the value + */ + public MutableBigIntegerBox(BigInteger val) { + this(val.mag); + } + + /** + * Returns the bit length of this MutableBigInteger value + * @return the bit length of this MutableBigInteger value + */ + public long bitLength() { + return val.bitLength(); + } + + /** + * Return {@code this << n} + * @return {@code this << n} + * @param n the shift + */ + public MutableBigIntegerBox shiftLeft(int n) { + MutableBigIntegerBox res = new MutableBigIntegerBox(val.value.clone(), val.offset, val.intLen); + res.val.safeLeftShift(n); + return res; + } + + /** + * Return {@code this >> n} + * @return {@code this >> n} + * @param n the shift + */ + public MutableBigIntegerBox shiftRight(int n) { + MutableBigInteger res = new MutableBigInteger(val); + res.safeRightShift(n); + return new MutableBigIntegerBox(res); + } + + /** + * Return this + addend + * @return this + addend + * @param addend the addend + */ + public MutableBigIntegerBox add(MutableBigIntegerBox addend) { + MutableBigInteger res = new MutableBigInteger(val); + res.add(addend.val); + return new MutableBigIntegerBox(res); + } + + /** + * Return this - subtraend + * @return this - subtraend + * @param subtraend the subtraend + */ + public MutableBigIntegerBox subtract(MutableBigIntegerBox subtraend) { + MutableBigInteger res = new MutableBigInteger(val); + res.subtract(subtraend.val); + return new MutableBigIntegerBox(res); + } + + /** + * Return this * multiplier + * @return this * multiplier + * @param multiplier the multiplier + */ + public MutableBigIntegerBox multiply(MutableBigIntegerBox multiplier) { + MutableBigInteger res = new MutableBigInteger(); + if (!(val.isZero() || multiplier.val.isZero())) + val.multiply(multiplier.val, res); + + return new MutableBigIntegerBox(res); + } + + /** + * Compare the magnitude of two MutableBigIntegers. Returns -1, 0 or 1 + * as this is numerically less than, equal to, or greater than {@code b}. + * @return -1, 0 or 1 as this is numerically less than, equal to, or + * greater than {@code b}. + * @param b the value to compare + */ + public int compare(MutableBigIntegerBox b) { + return val.compare(b.val); + } + + /** + * Compares this MutableBigIntegerBox with the specified Object for equality. + * + * @param x Object to which this MutableBigIntegerBox is to be compared. + * @return {@code true} if and only if the specified Object is a + * MutableBigIntegerBox whose value is numerically equal to this MutableBigIntegerBox. + */ + @Override + public boolean equals(Object x) { + return (x instanceof MutableBigIntegerBox xInt) + && Arrays.equals(val.value, val.offset, val.offset + val.intLen, + xInt.val.value, xInt.val.offset, xInt.val.offset + xInt.val.intLen); + } + + @Override + public String toString() { + return val.toString(); + } +} diff --git a/test/jdk/java/net/InetAddress/ptr/Lookup.java b/test/jdk/java/net/InetAddress/ptr/Lookup.java index 79c53190c24..1248916023e 100644 --- a/test/jdk/java/net/InetAddress/ptr/Lookup.java +++ b/test/jdk/java/net/InetAddress/ptr/Lookup.java @@ -114,6 +114,9 @@ public class Lookup { // Now check that a reverse lookup will succeed with the dual stack. InetAddress ia = InetAddress.getByName(addr); String name = ia.getHostName(); + // output details of dual stack lookup by address + System.out.println("dual stack lookup for addr " + addr + " returned IP address " + ia); + System.out.println(" with hostname " + name); System.out.println("(default) " + addr + "--> " + name + " (reversed IPv4: " + ipv4Reversed + ")"); diff --git a/test/jdk/java/net/Socket/SocketImplTest.java b/test/jdk/java/net/Socket/SocketImplTest.java deleted file mode 100644 index 28f49b26183..00000000000 --- a/test/jdk/java/net/Socket/SocketImplTest.java +++ /dev/null @@ -1,186 +0,0 @@ -/* - * Copyright (c) 2002, 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 java.applet.Applet; -import java.io.*; -import java.net.*; - -/** - * Simple Applet for exposing the Socket constructor - * bug. - */ -public class SocketImplTest extends Applet { - - static public void main(String[] args) { - System.setSecurityManager(new SecurityManager()); - SocketImplTest s = new SocketImplTest(); - s.init(); - s.start(); - } - - - /** - * A no-op SocketImpl descendant. - */ - class MySocketImpl extends SocketImpl { - protected void accept(SocketImpl impl) throws IOException { - } - - protected int available(){ - return 0; - } - - protected void bind(InetAddress host, int port){ - } - - protected void close(){ - } - - protected void connect(InetAddress address, int port){ - } - - protected void connect(String host, int port){ - } - - protected void connect(SocketAddress a, int t) throws IOException { - } - - - protected void create(boolean stream){ - } - - protected InputStream getInputStream(){ - return null; - } - - protected OutputStream getOutputStream(){ - return null; - } - - protected void listen(int backlog){ - } - - public Object getOption(int optID){ - return null; - } - - public void setOption(int optID, Object value){ - } - - protected void sendUrgentData(int i){ - } - } - - class MyDatagramSocketImpl extends DatagramSocketImpl { - protected void create() throws SocketException { - } - - protected void bind(int lport, InetAddress laddr) throws SocketException { - } - - protected void send(DatagramPacket p) throws IOException { - } - - protected int peek(InetAddress i) throws IOException { - return 0; - } - - protected int peekData(DatagramPacket p) throws IOException { - return 0; - } - - protected void receive(DatagramPacket p) throws IOException { - } - - protected void setTTL(byte ttl) throws IOException { - } - - protected byte getTTL() throws IOException { - return 0; - } - - protected void setTimeToLive(int ttl) throws IOException { - } - - protected int getTimeToLive() throws IOException { - return 0; - } - - protected void join(InetAddress inetaddr) throws IOException { - } - - protected void leave(InetAddress inetaddr) throws IOException { - } - - protected void joinGroup(SocketAddress mcastaddr, NetworkInterface netIf) - throws IOException { - } - - protected void leaveGroup(SocketAddress mcastaddr, NetworkInterface netIf) - throws IOException { - } - - protected void close() { - } - - public Object getOption(int optID){ - return null; - } - - public void setOption(int optID, Object value){ - } - - } - - /** - * A no-op Socket descendant. - */ - class MySocket extends Socket { - public MySocket(SocketImpl impl) throws IOException { - super(impl); - } - } - - class MyDatagramSocket extends DatagramSocket { - public MyDatagramSocket(DatagramSocketImpl impl) { - super(impl); - } - } - - /** - * Our test case entrypoint. Generates - * a SecurityException. - */ - public void init(){ - MySocketImpl socketImpl = new MySocketImpl(); - MyDatagramSocketImpl dgramSocketImpl = new MyDatagramSocketImpl(); - - try{ - MySocket socko = new MySocket(socketImpl); - MyDatagramSocket dsock = new MyDatagramSocket(dgramSocketImpl); - } catch(IOException ioex){ - System.err.println(ioex); - } catch(SecurityException sec) { - throw new RuntimeException("Failed. Creation of socket throwing SecurityException: "); - } - } -} diff --git a/test/jdk/java/net/Socket/UdpSocket.java b/test/jdk/java/net/Socket/UdpSocket.java index a15f9255b45..5d13c1f916a 100644 --- a/test/jdk/java/net/Socket/UdpSocket.java +++ b/test/jdk/java/net/Socket/UdpSocket.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,6 +47,8 @@ import static org.testng.Assert.*; @Test public class UdpSocket { + private static final int MAX_RETRIES = 3; + /** * Test using the Socket API to send/receive datagrams */ @@ -133,16 +135,21 @@ public class UdpSocket { } - private Socket newUdpSocket() throws IOException { - Socket s = null; - - try { - s = new Socket(InetAddress.getLoopbackAddress(), 8000, false); - } catch (BindException unexpected) { - System.out.println("BindException caught retry Socket creation"); - s = new Socket(InetAddress.getLoopbackAddress(), 8000, false); + private Socket newUdpSocket() throws IOException, InterruptedException { + BindException unexpected = null; + for (int i=0; i < MAX_RETRIES; i++) { + try { + return new Socket(InetAddress.getLoopbackAddress(), 8000, false); + } catch (BindException be) { + unexpected = be; + if (i != MAX_RETRIES - 1) { + System.out.printf("BindException caught: retry Socket creation [%s/%s]%n", + i + 1, MAX_RETRIES); + Thread.sleep(10 + 10 * i); + } + } } - return s; + throw unexpected; } private void closeAll(Deque sockets) throws IOException { diff --git a/test/jdk/java/net/ipv6tests/Tests.java b/test/jdk/java/net/ipv6tests/Tests.java index 398a3e71693..7a6917a6038 100644 --- a/test/jdk/java/net/ipv6tests/Tests.java +++ b/test/jdk/java/net/ipv6tests/Tests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -123,7 +123,8 @@ public class Tests { } dprintln ("dest2 = " + dest2); - + dprintln ("sender endpoint = " + s1.getLocalSocketAddress()); + dprintln ("echo endpoint = " + s2.getLocalSocketAddress()); DatagramPacket r1 = new DatagramPacket (new byte[256], 256); DatagramPacket r2 = new DatagramPacket (new byte[256], 256); diff --git a/test/jdk/java/nio/Buffer/Chew.java b/test/jdk/java/nio/Buffer/Chew.java index b1afeabc472..30932be526a 100644 --- a/test/jdk/java/nio/Buffer/Chew.java +++ b/test/jdk/java/nio/Buffer/Chew.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,7 @@ * @summary Ensure that direct memory can be unreserved * as the reserving thread sleeps * - * @run main/othervm -mx16M Chew + * @run main/othervm -Xmx16M Chew */ import java.nio.*; diff --git a/test/jdk/java/nio/charset/CharsetDecoder/XcodeOverflow.java b/test/jdk/java/nio/charset/CharsetDecoder/XcodeOverflow.java index 7570da3945c..197b61c0ac5 100644 --- a/test/jdk/java/nio/charset/CharsetDecoder/XcodeOverflow.java +++ b/test/jdk/java/nio/charset/CharsetDecoder/XcodeOverflow.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,7 @@ * @summary Make sure IAE is not thrown on `int` overflow, turning negative * size. The test should either not throw any Throwable, or an OOME * with real Java heap space error (not "exceeds VM limit"). + * @modules java.base/jdk.internal.util * @requires sun.arch.data.model == "64" * @run junit/othervm XcodeOverflow */ @@ -37,6 +38,7 @@ import java.nio.charset.CharacterCodingException; import java.nio.charset.StandardCharsets; import java.util.stream.Stream; +import jdk.internal.util.ArraysSupport; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; import org.junit.jupiter.params.provider.Arguments; @@ -44,8 +46,8 @@ import org.junit.jupiter.params.provider.Arguments; public class XcodeOverflow { private static Stream sizes() { return Stream.of( - // SOFT_MAX_ARRAY_LENGTH: copied from ArraysSupport. No overflow; no OOME. - Arguments.of(Integer.MAX_VALUE - 8), + // No overflow; no OOME. + Arguments.of(ArraysSupport.SOFT_MAX_ARRAY_LENGTH), // overflow case: OOME w/ "Java heap space" is thrown on decoding Arguments.of(Integer.MAX_VALUE - 1000000) diff --git a/test/jdk/java/nio/charset/spi/CharsetProviderAsModuleTest.java b/test/jdk/java/nio/charset/spi/CharsetProviderAsModuleTest.java new file mode 100644 index 00000000000..ba6aae234c6 --- /dev/null +++ b/test/jdk/java/nio/charset/spi/CharsetProviderAsModuleTest.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8340404 + * @summary Check that a CharsetProvider SPI can be deployed as a module + * @build provider/* + * @run main/othervm CharsetProviderAsModuleTest + */ + +import java.nio.charset.Charset; + +public class CharsetProviderAsModuleTest { + + // Basic test ensures that our BAZ charset is loaded via the BazProvider + public static void main(String[] args) { + var cs = Charset.availableCharsets(); + Charset bazCs; + // check provider is providing BAZ via charsets() + if (!cs.containsKey("BAZ")) { + throw new RuntimeException("SPI BazProvider did not provide BAZ Charset"); + } else { + bazCs = cs.get("BAZ"); + // check provider is in a named module + if (!bazCs.getClass().getModule().isNamed()) { + throw new RuntimeException("BazProvider is not a named module"); + } + var aliases = bazCs.aliases(); + // check BAZ cs aliases were loaded correctly + if (!aliases.contains("BAZ-1") || !aliases.contains("BAZ-2")) { + throw new RuntimeException("BAZ Charset did not provide correct aliases"); + } + // check provider implements charsetForName() + if (!bazCs.equals(Charset.forName("BAZ"))) { + throw new RuntimeException("SPI BazProvider provides bad charsetForName()"); + } + } + } +} diff --git a/test/jdk/java/nio/charset/spi/provider/module-info.java b/test/jdk/java/nio/charset/spi/provider/module-info.java new file mode 100644 index 00000000000..5cfe6db92db --- /dev/null +++ b/test/jdk/java/nio/charset/spi/provider/module-info.java @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +module provider { + provides java.nio.charset.spi.CharsetProvider with spi.BazProvider; +} diff --git a/test/jdk/java/nio/charset/spi/provider/spi/BazProvider.java b/test/jdk/java/nio/charset/spi/provider/spi/BazProvider.java new file mode 100644 index 00000000000..7def239e64c --- /dev/null +++ b/test/jdk/java/nio/charset/spi/provider/spi/BazProvider.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package spi; + +import java.nio.charset.Charset; +import java.nio.charset.CharsetDecoder; +import java.nio.charset.CharsetEncoder; +import java.nio.charset.spi.CharsetProvider; +import java.util.Collections; +import java.util.Iterator; + +// Provides some simple BAZ related attributes to our provider +public class BazProvider extends CharsetProvider { + + @Override + public Iterator charsets() { + return Collections.singleton(new BazCharset()).iterator(); + } + + @Override + public Charset charsetForName(String charsetName) { + if (charsetName.equals("BAZ")) { + return new BazCharset(); + } else { + return null; + } + } + + public static class BazCharset extends Charset { + + public BazCharset() { + super("BAZ", new String[] { "BAZ-1", "BAZ-2" }); + } + + // Overrides to satisfy Charset + @Override + public boolean contains(Charset cs) { + return false; + } + + @Override + public CharsetDecoder newDecoder() { + return null; + } + + @Override + public CharsetEncoder newEncoder() { + return null; + } + } +} diff --git a/test/jdk/java/nio/file/Files/Links.java b/test/jdk/java/nio/file/Files/Links.java index a87647e08a6..23059b0829a 100644 --- a/test/jdk/java/nio/file/Files/Links.java +++ b/test/jdk/java/nio/file/Files/Links.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,7 +22,7 @@ */ /* @test - * @bug 4313887 6838333 6863864 + * @bug 4313887 6838333 6863864 8340329 * @summary Unit test for java.nio.file.Files createSymbolicLink, * readSymbolicLink, and createLink methods * @library .. @@ -45,7 +45,7 @@ public class Links { } /** - * Exercise createSymbolicLink and readLink methods + * Exercise createSymbolicLink and readSymbolicLink methods */ static void testSymLinks(Path dir) throws IOException { final Path link = dir.resolve("link"); @@ -131,6 +131,27 @@ public class Links { Files.deleteIfExists(mydir); Files.deleteIfExists(link); } + + // Check message of NotLinkException + try { + Files.createDirectory(mydir); + + try { + Path mytarget = Files.readSymbolicLink(mydir); + } catch (NotLinkException expected) { + String filename = mydir.getFileName().toString(); + String message = expected.getMessage(); + boolean okay = message.contains(filename); + if (!okay) { + System.err.println("Message \"" + message + "\"" + + " does not contain the filename \"" + + filename + "\""); + assertTrue(okay); + } + } + } finally { + Files.deleteIfExists(mydir); + } } /** diff --git a/test/jdk/java/nio/file/Path/ToRealPath.java b/test/jdk/java/nio/file/Path/ToRealPath.java index 64f75124d0f..474b1417197 100644 --- a/test/jdk/java/nio/file/Path/ToRealPath.java +++ b/test/jdk/java/nio/file/Path/ToRealPath.java @@ -33,6 +33,8 @@ import java.io.IOException; import java.io.UncheckedIOException; import java.nio.file.Files; import java.nio.file.Path; +import java.util.HashSet; +import java.util.Set; import jdk.test.lib.Platform; @@ -51,6 +53,7 @@ public class ToRealPath { static final Path SUBDIR; static final Path FILE; static final Path LINK; + static final Set extraDeletions; static { try { @@ -59,6 +62,7 @@ public class ToRealPath { FILE = Files.createFile(DIR.resolve("foo")); LINK = DIR.resolve("link"); SUPPORTS_LINKS = TestUtil.supportsSymbolicLinks(DIR); + extraDeletions = new HashSet(); } catch (IOException e) { throw new UncheckedIOException(e); } @@ -154,8 +158,15 @@ public class ToRealPath { System.out.println("p: " + p); Path path = LINK.resolve(p); System.out.println("path: " + path); + if (Platform.isWindows() && Files.notExists(path)) { + Files.createFile(path); + extraDeletions.add(path); + } System.out.println("no follow: " + path.toRealPath(NOFOLLOW_LINKS)); - assertEquals(path.toRealPath(NOFOLLOW_LINKS), path); + if (Platform.isWindows()) + assertTrue(Files.isSameFile(path.toRealPath(NOFOLLOW_LINKS), path)); + else + assertEquals(path.toRealPath(NOFOLLOW_LINKS), path); Files.delete(sub); Files.delete(sub.getParent()); @@ -177,8 +188,15 @@ public class ToRealPath { Path p = Path.of("aaa", "..", "..", "bbb", "..", "..", "out.txt"); Path path = DIR.resolve(p); System.out.println("path: " + path); + if (Platform.isWindows() && Files.notExists(path)) { + Files.createFile(path); + extraDeletions.add(path); + } System.out.println("no follow: " + path.toRealPath(NOFOLLOW_LINKS)); - assertEquals(path.toRealPath(NOFOLLOW_LINKS), path); + if (Platform.isWindows()) + assertTrue(Files.isSameFile(path.toRealPath(NOFOLLOW_LINKS), path)); + else + assertEquals(path.toRealPath(NOFOLLOW_LINKS), path); System.out.println(path.toRealPath()); Files.delete(sub); @@ -235,5 +253,7 @@ public class ToRealPath { Files.delete(FILE); Files.delete(SUBDIR); Files.delete(DIR); + for (Path p : extraDeletions) + Files.deleteIfExists(p); } } diff --git a/test/jdk/java/nio/file/attribute/BasicFileAttributeView/CreationTime.java b/test/jdk/java/nio/file/attribute/BasicFileAttributeView/CreationTime.java index ad85da7ae63..65e801b0a9f 100644 --- a/test/jdk/java/nio/file/attribute/BasicFileAttributeView/CreationTime.java +++ b/test/jdk/java/nio/file/attribute/BasicFileAttributeView/CreationTime.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024 Alibaba Group Holding Limited. 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 @@ -25,18 +26,18 @@ * @bug 8011536 8151430 8316304 8334339 * @summary Basic test for creationTime attribute on platforms/file systems * that support it, tests using /tmp directory. - * @library ../.. /test/lib - * @build jdk.test.lib.Platform - * @run main CreationTime + * @library ../.. /test/lib /java/foreign + * @build jdk.test.lib.Platform NativeTestHelper + * @run main/othervm/native --enable-native-access=ALL-UNNAMED CreationTime */ /* @test id=cwd * @summary Basic test for creationTime attribute on platforms/file systems * that support it, tests using the test scratch directory, the test * scratch directory maybe at diff disk partition to /tmp on linux. - * @library ../.. /test/lib - * @build jdk.test.lib.Platform - * @run main CreationTime . + * @library ../.. /test/lib /java/foreign + * @build jdk.test.lib.Platform NativeTestHelper + * @run main/othervm/native --enable-native-access=ALL-UNNAMED CreationTime . */ import java.lang.foreign.Linker; @@ -51,8 +52,6 @@ import jtreg.SkippedException; public class CreationTime { - private static final java.io.PrintStream err = System.err; - /** * Reads the creationTime attribute */ @@ -78,14 +77,9 @@ public class CreationTime { FileTime creationTime = creationTime(file); Instant now = Instant.now(); if (Math.abs(creationTime.toMillis()-now.toEpochMilli()) > 10000L) { - System.out.println("creationTime.toMillis() == " + creationTime.toMillis()); - // If the file system doesn't support birth time, then skip this test - if (creationTime.toMillis() == 0) { - throw new SkippedException("birth time not support for: " + file); - } else { - err.println("File creation time reported as: " + creationTime); - throw new RuntimeException("Expected to be close to: " + now); - } + System.err.println("creationTime.toMillis() == " + creationTime.toMillis()); + System.err.println("File creation time reported as: " + creationTime); + throw new RuntimeException("Expected to be close to: " + now); } /** @@ -107,7 +101,12 @@ public class CreationTime { } } else if (Platform.isLinux()) { // Creation time read depends on statx system call support - supportsCreationTimeRead = Linker.nativeLinker().defaultLookup().find("statx").isPresent(); + try { + supportsCreationTimeRead = CreationTimeHelper. + linuxIsCreationTimeSupported(file.toAbsolutePath().toString()); + } catch (Throwable e) { + supportsCreationTimeRead = false; + } // Creation time updates are not supported on Linux supportsCreationTimeWrite = false; } @@ -122,8 +121,11 @@ public class CreationTime { Instant plusHour = Instant.now().plusSeconds(60L * 60L); Files.setLastModifiedTime(file, FileTime.from(plusHour)); FileTime current = creationTime(file); - if (!current.equals(creationTime)) + if (!current.equals(creationTime)) { + System.err.println("current = " + current); + System.err.println("creationTime = " + creationTime); throw new RuntimeException("Creation time should not have changed"); + } } /** diff --git a/test/jdk/java/nio/file/attribute/BasicFileAttributeView/CreationTimeHelper.java b/test/jdk/java/nio/file/attribute/BasicFileAttributeView/CreationTimeHelper.java new file mode 100644 index 00000000000..592aeba322d --- /dev/null +++ b/test/jdk/java/nio/file/attribute/BasicFileAttributeView/CreationTimeHelper.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2024 Alibaba Group Holding Limited. 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 java.lang.foreign.Arena; +import java.lang.foreign.FunctionDescriptor; +import java.lang.foreign.Linker; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.SymbolLookup; +import java.lang.foreign.ValueLayout; +import java.lang.invoke.MethodHandle; + +public class CreationTimeHelper extends NativeTestHelper { + + static { + System.loadLibrary("CreationTimeHelper"); + } + + final static Linker abi = Linker.nativeLinker(); + static final SymbolLookup lookup = SymbolLookup.loaderLookup(); + final static MethodHandle methodHandle = abi. + downcallHandle(lookup.findOrThrow("linuxIsCreationTimeSupported"), + FunctionDescriptor.of(C_BOOL, C_POINTER)); + + // Helper so as to determine birth time support or not on Linux. + // Support is determined in a two-step process: + // 1. Determine if `statx` system call is available. If available proceed, + // otherwise return false. + // 2. Perform an actual `statx` call on the given file and check for birth + // time support in the mask returned from the call. This is needed, + // since some file systems, like nfs/tmpfs etc., don't support birth + // time even though the `statx` system call is available. + static boolean linuxIsCreationTimeSupported(String file) throws Throwable { + if (!abi.defaultLookup().find("statx").isPresent()) { + return false; + } + try (var arena = Arena.ofConfined()) { + MemorySegment s = arena.allocateFrom(file); + return (boolean)methodHandle.invokeExact(s); + } + } +} diff --git a/test/jdk/java/nio/file/attribute/BasicFileAttributeView/libCreationTimeHelper.c b/test/jdk/java/nio/file/attribute/BasicFileAttributeView/libCreationTimeHelper.c new file mode 100644 index 00000000000..fb518b3b701 --- /dev/null +++ b/test/jdk/java/nio/file/attribute/BasicFileAttributeView/libCreationTimeHelper.c @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2024 Alibaba Group Holding Limited. 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. + */ +#include "export.h" +#include +#if defined(__linux__) +#include +#include +#include +#include +#include +#ifndef STATX_BASIC_STATS +#define STATX_BASIC_STATS 0x000007ffU +#endif +#ifndef STATX_BTIME +#define STATX_BTIME 0x00000800U +#endif +#ifndef RTLD_DEFAULT +#define RTLD_DEFAULT RTLD_LOCAL +#endif +#ifndef AT_SYMLINK_NOFOLLOW +#define AT_SYMLINK_NOFOLLOW 0x100 +#endif +#ifndef AT_FDCWD +#define AT_FDCWD -100 +#endif + +/* + * Timestamp structure for the timestamps in struct statx. + */ +struct my_statx_timestamp { + __int64_t tv_sec; + __uint32_t tv_nsec; + __int32_t __reserved; +}; + +/* + * struct statx used by statx system call on >= glibc 2.28 + * systems + */ +struct my_statx +{ + __uint32_t stx_mask; + __uint32_t stx_blksize; + __uint64_t stx_attributes; + __uint32_t stx_nlink; + __uint32_t stx_uid; + __uint32_t stx_gid; + __uint16_t stx_mode; + __uint16_t __statx_pad1[1]; + __uint64_t stx_ino; + __uint64_t stx_size; + __uint64_t stx_blocks; + __uint64_t stx_attributes_mask; + struct my_statx_timestamp stx_atime; + struct my_statx_timestamp stx_btime; + struct my_statx_timestamp stx_ctime; + struct my_statx_timestamp stx_mtime; + __uint32_t stx_rdev_major; + __uint32_t stx_rdev_minor; + __uint32_t stx_dev_major; + __uint32_t stx_dev_minor; + __uint64_t __statx_pad2[14]; +}; + +typedef int statx_func(int dirfd, const char *restrict pathname, int flags, + unsigned int mask, struct my_statx *restrict statxbuf); + +static statx_func* my_statx_func = NULL; +#endif //#defined(__linux__) + +// static boolean linuxIsCreationTimeSupported(char* file) +EXPORT bool linuxIsCreationTimeSupported(char* file) { +#if defined(__linux__) + struct my_statx stx = {0}; + int ret, atflag = AT_SYMLINK_NOFOLLOW; + unsigned int mask = STATX_BASIC_STATS | STATX_BTIME; + + my_statx_func = (statx_func*) dlsym(RTLD_DEFAULT, "statx"); + if (my_statx_func == NULL) { + return false; + } + + if (file == NULL) { + printf("input file error!\n"); + return false; + } + + ret = my_statx_func(AT_FDCWD, file, atflag, mask, &stx); + if (ret != 0) { + return false; + } + // On some systems where statx is available but birth time might still not + // be supported as it's file system specific. The only reliable way to + // check for supported or not is looking at the filled in STATX_BTIME bit + // in the returned statx buffer mask. + if ((stx.stx_mask & STATX_BTIME) != 0) + return true; + return false; +#else + return false; +#endif +} diff --git a/test/jdk/java/security/SecureRandom/ThreadSafe.java b/test/jdk/java/security/SecureRandom/ThreadSafe.java index 174f3253c5f..b0975678e96 100644 --- a/test/jdk/java/security/SecureRandom/ThreadSafe.java +++ b/test/jdk/java/security/SecureRandom/ThreadSafe.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,33 +21,46 @@ * questions. */ +import static jdk.test.lib.Utils.runAndCheckException; + +import java.lang.Override; import java.security.Provider; import java.security.SecureRandom; import java.security.SecureRandomSpi; +import java.util.List; import java.util.Map; /* * @test - * @bug 7004967 + * @library /test/lib + * @bug 7004967 8329754 * @summary SecureRandom should be more explicit about threading */ + public class ThreadSafe { public static void main(String[] args) throws Exception { Provider p = new P(); NoSync.test(SecureRandom.getInstance("S1", p), 5, 5); - try { - NoSync.test(SecureRandom.getInstance("S2", p), 5, 5); - throw new Exception("Failed"); - } catch (RuntimeException re) { - // Good - } + NoSync.test(SecureRandom.getInstance("AliasS1", p), 5, 5); + + runAndCheckException( + () -> NoSync.test(SecureRandom.getInstance("S2", p), 5, 5), + RuntimeException.class); + + runAndCheckException( + () -> NoSync.test(SecureRandom.getInstance("AliasS2", p), 5, 5), + RuntimeException.class); + NoSync.test(SecureRandom.getInstance("S3", p), 5, 5); - try { - NoSync.test(SecureRandom.getInstance("S4", p), 5, 5); - throw new Exception("Failed"); - } catch (RuntimeException re) { - // Good - } + NoSync.test(SecureRandom.getInstance("AliasS3", p), 5, 5); + + runAndCheckException( + () -> NoSync.test(SecureRandom.getInstance("S4", p), 5, 5), + RuntimeException.class); + + runAndCheckException( + () -> NoSync.test(SecureRandom.getInstance("AliasS4", p), 5, 5), + RuntimeException.class); } public static class P extends Provider { @@ -58,28 +71,36 @@ public class ThreadSafe { // Good. No attribute. put("SecureRandom.S1", S.class.getName()); + // Good. Alias of S1, should pass because S1 is not marked as ThreadSafe + put("Alg.alias.SecureRandom.AliasS1", "S1"); + // Bad. Boasting ThreadSafe but isn't put("SecureRandom.S2", S.class.getName()); put("SecureRandom.S2 ThreadSafe", "true"); + //Bad. Alias of S2, should fail because S2 is marked as ThreadSafe + put("alg.Alias.SecureRandom.AliasS2", "S2"); + // Good. No attribute. putService(new Service(this, "SecureRandom", "S3", - S.class.getName(), null, null)); + S.class.getName(), List.of("AliasS3"), null)); // Bad. Boasting ThreadSafe but isn't putService(new Service(this, "SecureRandom", "S4", - S.class.getName(), null, Map.of("ThreadSafe", "true"))); + S.class.getName(), List.of("AliasS4"), Map.of("ThreadSafe", "true"))); } } // This implementation is not itself thread safe. public static class S extends SecureRandomSpi { - @java.lang.Override + + @Override protected void engineSetSeed(byte[] seed) { return; } private volatile boolean inCall = false; + @Override protected void engineNextBytes(byte[] bytes) { if (inCall) { diff --git a/test/jdk/java/security/Security/ConfigFileTest.java b/test/jdk/java/security/Security/ConfigFileTest.java index b9264b937ec..caf657005e1 100644 --- a/test/jdk/java/security/Security/ConfigFileTest.java +++ b/test/jdk/java/security/Security/ConfigFileTest.java @@ -21,155 +21,907 @@ * questions. */ +import com.sun.net.httpserver.HttpExchange; +import com.sun.net.httpserver.HttpServer; import jdk.test.lib.Utils; import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.ProcessTools; +import jdk.test.lib.util.FileUtils; +import sun.net.www.ParseUtil; +import java.io.Closeable; import java.io.IOException; +import java.io.OutputStream; +import java.io.PrintWriter; import java.io.UncheckedIOException; -import java.nio.file.*; - -import java.security.Provider; +import java.lang.reflect.Method; +import java.net.HttpURLConnection; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.net.URI; +import java.nio.CharBuffer; +import java.nio.file.Files; +import java.nio.file.InvalidPathException; +import java.nio.file.Path; +import java.nio.file.StandardCopyOption; +import java.nio.file.StandardOpenOption; import java.security.Security; +import java.time.Instant; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; -import java.util.Optional; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.stream.Stream; /* * @test - * @summary Throw error if default java.security file is missing - * @bug 8155246 8292297 8292177 8281658 + * @summary Tests security properties passed through java.security, + * java.security.properties or included from other properties files. + * @bug 8155246 8292297 8292177 8281658 8319332 + * @modules java.base/sun.net.www * @library /test/lib * @run main ConfigFileTest */ + public class ConfigFileTest { + static final String SEPARATOR_THIN = "----------------------------"; - private static final String EXPECTED_DEBUG_OUTPUT = - "Initial security property: crypto.policy=unlimited"; - - private static final String UNEXPECTED_DEBUG_OUTPUT = - "Initial security property: postInitTest=shouldNotRecord"; - - private static boolean overrideDetected = false; - - private static Path COPY_JDK_DIR = Path.of("./jdk-8155246-tmpdir"); - private static Path COPIED_JAVA = COPY_JDK_DIR.resolve("bin", "java"); + private static void printTestHeader(String testName) { + System.out.println(); + System.out.println(SEPARATOR_THIN); + System.out.println(testName); + System.out.println(SEPARATOR_THIN); + System.out.println(); + } public static void main(String[] args) throws Exception { - Path copyJdkDir = Path.of("./jdk-8155246-tmpdir"); - Path copiedJava = Optional.of( - Path.of(copyJdkDir.toString(), "bin", "java")) - .orElseThrow(() -> new RuntimeException("Unable to locate new JDK") - ); - - if (args.length == 1) { - // set up is complete. Run code to exercise loading of java.security - Provider[] provs = Security.getProviders(); + if (args.length == 1 && Executor.RUNNER_ARG.equals(args[0])) { + // Executed by a test-launched JVM. + // Force the initialization of java.security.Security. + Security.getProviders(); Security.setProperty("postInitTest", "shouldNotRecord"); - System.out.println(Arrays.toString(provs) + "NumProviders: " + provs.length); + System.out.println(FilesManager.LAST_FILE_PROP_NAME + ": " + + Security.getProperty(FilesManager.LAST_FILE_PROP_NAME)); + assertTestSecuritySetPropertyShouldNotInclude(); } else { - Files.createDirectory(copyJdkDir); - Path jdkTestDir = Path.of(Optional.of(System.getProperty("test.jdk")) - .orElseThrow(() -> new RuntimeException("Couldn't load JDK Test Dir")) - ); - - copyJDK(jdkTestDir, copyJdkDir); - String extraPropsFile = Path.of(System.getProperty("test.src"), "override.props").toString(); - - // sanity test -XshowSettings:security option - exerciseShowSettingsSecurity(buildCommand("-cp", System.getProperty("test.classes"), - "-Djava.security.debug=all", "-XshowSettings:security", "ConfigFileTest", "runner")); - - // exercise some debug flags while we're here - // regular JDK install - should expect success - exerciseSecurity(0, "java", - buildCommand("-cp", System.getProperty("test.classes"), - "-Djava.security.debug=all", "-Djavax.net.debug=all", "ConfigFileTest", "runner")); - - // given an overriding security conf file that doesn't exist, we shouldn't - // overwrite the properties from original/master security conf file - exerciseSecurity(0, "SUN version", - buildCommand("-cp", System.getProperty("test.classes"), - "-Djava.security.debug=all", "-Djavax.net.debug=all", - "-Djava.security.properties==file:///" + extraPropsFile + "badFileName", - "ConfigFileTest", "runner")); - - // test JDK launch with customized properties file - exerciseSecurity(0, "NumProviders: 6", - buildCommand("-cp", System.getProperty("test.classes"), - "-Djava.security.debug=all", "-Djavax.net.debug=all", - "-Djava.security.properties==file:///" + extraPropsFile, - "ConfigFileTest", "runner")); - - // delete the master conf file - Files.delete(Path.of(copyJdkDir.toString(), "conf", - "security","java.security")); - - // launch JDK without java.security file being present or specified - exerciseSecurity(1, "Error loading java.security file", - buildCommand("-cp", System.getProperty("test.classes"), - "-Djava.security.debug=all", "-Djavax.net.debug=all", - "ConfigFileTest", "runner")); - - // test the override functionality also. Should not be allowed since - // "security.overridePropertiesFile=true" Security property is missing. - exerciseSecurity(1, "Error loading java.security file", - buildCommand("-cp", System.getProperty("test.classes"), - "-Djava.security.debug=all", "-Djavax.net.debug=all", - "-Djava.security.properties==file:///" + extraPropsFile, "ConfigFileTest", "runner")); - - if (!overrideDetected) { - throw new RuntimeException("Override scenario not seen"); + // Executed by the test JVM. + try (FilesManager filesMgr = new FilesManager()) { + for (Method m : ConfigFileTest.class.getDeclaredMethods()) { + if (m.getName().startsWith("test")) { + printTestHeader(m.getName()); + Executor.run(m, filesMgr); + } + } } } } - private static ProcessBuilder buildCommand(String... command) { - ArrayList args = new ArrayList<>(); - args.add(COPIED_JAVA.toString()); - Collections.addAll(args, Utils.prependTestJavaOpts(command)); - return new ProcessBuilder(args); - } + /* + * Success cases + */ - private static void exerciseSecurity(int exitCode, String output, ProcessBuilder process) throws Exception { - OutputAnalyzer oa = ProcessTools.executeProcess(process); - oa.shouldHaveExitValue(exitCode) - .shouldContain(output); - - // extra checks on debug output - if (exitCode != 1) { - if (oa.getStderr().contains("overriding other security properties files!")) { - overrideDetected = true; - // master file is not in use - only provider properties are set in custom file - oa.shouldContain("security.provider.2=SunRsaSign") - .shouldNotContain(EXPECTED_DEBUG_OUTPUT) - .shouldNotContain(UNEXPECTED_DEBUG_OUTPUT); - } else { - oa.shouldContain(EXPECTED_DEBUG_OUTPUT) - .shouldNotContain(UNEXPECTED_DEBUG_OUTPUT); - } - } - } - - // exercise the -XshowSettings:security launcher - private static void exerciseShowSettingsSecurity(ProcessBuilder process) throws Exception { - OutputAnalyzer oa = ProcessTools.executeProcess(process); - oa.shouldHaveExitValue(0) + static void testShowSettings(Executor ex, FilesManager filesMgr) + throws Exception { + // Sanity test passing the -XshowSettings:security option. + ex.addJvmArg("-XshowSettings:security"); + ex.setMasterFile(filesMgr.newMasterFile()); + ex.assertSuccess(); + ex.getOutputAnalyzer() .shouldContain("Security properties:") .shouldContain("Security provider static configuration:") .shouldContain("Security TLS configuration"); } - private static void copyJDK(Path src, Path dst) throws Exception { - Files.walk(src) - .skip(1) - .forEach(file -> { + static void testIncludeBasic(Executor ex, FilesManager filesMgr) + throws Exception { + PropsFile masterFile = filesMgr.newMasterFile(); + ExtraPropsFile extraFile = filesMgr.newExtraFile(); + PropsFile file0 = filesMgr.newFile("file0.properties"); + PropsFile file1 = filesMgr.newFile("dir1/file1.properties"); + PropsFile file2 = filesMgr.newFile("dir1/dir2/file2.properties"); + + masterFile.addAbsoluteInclude(file0); + extraFile.addRelativeInclude(file2); + file2.addAbsoluteInclude(file1); + + ex.setMasterFile(masterFile); + ex.setExtraFile(extraFile, Executor.ExtraMode.FILE_URI, false); + ex.assertSuccess(); + } + + static void testRepeatedInclude(Executor ex, FilesManager filesMgr) + throws Exception { + PropsFile masterFile = filesMgr.newMasterFile(); + PropsFile file0 = filesMgr.newFile("file0.properties"); + PropsFile file1 = filesMgr.newFile("dir1/file1.properties"); + + masterFile.addAbsoluteInclude(file0); + masterFile.addAbsoluteInclude(file1); + masterFile.addAbsoluteInclude(file0); + file1.addRelativeInclude(file0); + + ex.setMasterFile(masterFile); + ex.assertSuccess(); + } + + static void testIncludeWithOverrideAll(Executor ex, FilesManager filesMgr) + throws Exception { + PropsFile masterFile = filesMgr.newMasterFile(); + ExtraPropsFile extraFile = filesMgr.newExtraFile(); + PropsFile file0 = filesMgr.newFile("file0.properties"); + PropsFile file1 = filesMgr.newFile("dir1/file1.properties"); + + masterFile.addRelativeInclude(file0); + extraFile.addAbsoluteInclude(file1); + + ex.setMasterFile(masterFile); + ex.setExtraFile(extraFile, Executor.ExtraMode.HTTP_SERVED, true); + ex.assertSuccess(); + } + + static void extraPropertiesByHelper(Executor ex, FilesManager filesMgr, + Executor.ExtraMode mode) throws Exception { + ExtraPropsFile extraFile = filesMgr.newExtraFile(); + PropsFile file0 = filesMgr.newFile("file0.properties"); + + extraFile.addRelativeInclude(file0); + + ex.setMasterFile(filesMgr.newMasterFile()); + ex.setExtraFile(extraFile, mode, true); + ex.assertSuccess(); + } + + static void testExtraPropertiesByPathAbsolute(Executor ex, + FilesManager filesMgr) throws Exception { + extraPropertiesByHelper(ex, filesMgr, Executor.ExtraMode.PATH_ABS); + } + + static void testExtraPropertiesByPathRelative(Executor ex, + FilesManager filesMgr) throws Exception { + extraPropertiesByHelper(ex, filesMgr, Executor.ExtraMode.PATH_REL); + } + + static void specialCharsIncludes(Executor ex, FilesManager filesMgr, + char specialChar, Executor.ExtraMode extraMode, + boolean useRelativeIncludes) throws Exception { + String suffix = specialChar + ".properties"; + ExtraPropsFile extraFile; + PropsFile file0, file1; + try { + extraFile = filesMgr.newExtraFile("extra" + suffix); + file0 = filesMgr.newFile("file0" + suffix); + file1 = filesMgr.newFile("file1" + suffix); + } catch (InvalidPathException ipe) { + // The platform encoding may not allow to create files with some + // special characters. Skip the test in these cases. + return; + } + + if (useRelativeIncludes) { + extraFile.addRelativeInclude(file0); + } else { + extraFile.addAbsoluteInclude(file0); + } + extraFile.addAbsoluteInclude(file1); + + ex.setMasterFile(filesMgr.newMasterFile()); + ex.setExtraFile(extraFile, extraMode, false); + ex.assertSuccess(); + } + + static void testUnicodeIncludes1(Executor ex, FilesManager filesMgr) + throws Exception { + specialCharsIncludes(ex, filesMgr, '\u2022', + Executor.ExtraMode.PATH_ABS, true); + } + + static void testUnicodeIncludes2(Executor ex, FilesManager filesMgr) + throws Exception { + specialCharsIncludes(ex, filesMgr, '\u2022', + Executor.ExtraMode.FILE_URI, true); + } + + static void testUnicodeIncludes3(Executor ex, FilesManager filesMgr) + throws Exception { + // Backward compatibility check. Malformed URLs such as + // file:/tmp/extra•.properties are supported for the extra file. + // However, relative includes are not allowed in these cases. + specialCharsIncludes(ex, filesMgr, '\u2022', + Executor.ExtraMode.RAW_FILE_URI1, false); + } + + static void testUnicodeIncludes4(Executor ex, FilesManager filesMgr) + throws Exception { + // Backward compatibility check. Malformed URLs such as + // file:///tmp/extra•.properties are supported for the extra file. + // However, relative includes are not allowed in these cases. + specialCharsIncludes(ex, filesMgr, '\u2022', + Executor.ExtraMode.RAW_FILE_URI2, false); + } + + static void testSpaceIncludes1(Executor ex, FilesManager filesMgr) + throws Exception { + specialCharsIncludes(ex, filesMgr, ' ', + Executor.ExtraMode.PATH_ABS, true); + } + + static void testSpaceIncludes2(Executor ex, FilesManager filesMgr) + throws Exception { + specialCharsIncludes(ex, filesMgr, ' ', + Executor.ExtraMode.FILE_URI, true); + } + + static void testSpaceIncludes3(Executor ex, FilesManager filesMgr) + throws Exception { + // Backward compatibility check. Malformed URLs such as + // file:/tmp/extra .properties are supported for the extra file. + // However, relative includes are not allowed in these cases. + specialCharsIncludes(ex, filesMgr, ' ', + Executor.ExtraMode.RAW_FILE_URI1, false); + } + + static void testSpaceIncludes4(Executor ex, FilesManager filesMgr) + throws Exception { + // Backward compatibility check. Malformed URLs such as + // file:///tmp/extra .properties are supported for the extra file. + // However, relative includes are not allowed in these cases. + specialCharsIncludes(ex, filesMgr, ' ', + Executor.ExtraMode.RAW_FILE_URI2, false); + } + + static void notOverrideOnFailureHelper(Executor ex, FilesManager filesMgr, + String nonExistentExtraFile) throws Exception { + // An overriding extra properties file that does not exist + // should not erase properties from the master file. + ex.setIgnoredExtraFile(nonExistentExtraFile, true); + ex.setMasterFile(filesMgr.newMasterFile()); + ex.assertSuccess(); + ex.getOutputAnalyzer().shouldContain("unable to load security " + + "properties from " + nonExistentExtraFile); + } + + static void testNotOverrideOnEmptyFailure(Executor ex, + FilesManager filesMgr) throws Exception { + notOverrideOnFailureHelper(ex, filesMgr, ""); + ex.getOutputAnalyzer() + .shouldContain("Empty extra properties file path"); + } + + static void testNotOverrideOnURLFailure(Executor ex, FilesManager filesMgr) + throws Exception { + notOverrideOnFailureHelper(ex, filesMgr, + "file:///nonExistentFile.properties"); + } + + static void testNotOverrideOnPathFailure(Executor ex, FilesManager filesMgr) + throws Exception { + notOverrideOnFailureHelper(ex, filesMgr, "nonExistentFile.properties"); + } + + static void testNotOverrideOnDirFailure(Executor ex, FilesManager filesMgr) + throws Exception { + notOverrideOnFailureHelper(ex, filesMgr, "file:///"); + ex.getOutputAnalyzer().shouldContain("Is a directory"); + } + + static void testNotOverrideOnBadFileURLFailure(Executor ex, + FilesManager filesMgr) throws Exception { + notOverrideOnFailureHelper(ex, filesMgr, "file:///%00"); + } + + static void testDisabledExtraPropertiesFile(Executor ex, + FilesManager filesMgr) throws Exception { + PropsFile masterFile = filesMgr.newMasterFile(); + PropsFile file0 = filesMgr.newFile("file0.properties"); + + masterFile.addRawProperty("security.overridePropertiesFile", "false"); + + ex.setMasterFile(masterFile); + ex.setIgnoredExtraFile(file0.path.toString(), true); + ex.assertSuccess(); + } + + static final String SECURITY_SET_PROP_FILE_PATH = + "testSecuritySetPropertyShouldNotInclude.propsFilePath"; + + static void testSecuritySetPropertyShouldNotInclude(Executor ex, + FilesManager filesMgr) throws Exception { + PropsFile masterFile = filesMgr.newMasterFile(); + PropsFile file0 = filesMgr.newFile("file0.properties"); + + ex.addSystemProp(SECURITY_SET_PROP_FILE_PATH, file0.path.toString()); + ex.setMasterFile(masterFile); + ex.assertSuccess(); + } + + static void assertTestSecuritySetPropertyShouldNotInclude() { + // This check is executed by the launched JVM. + String propsFilePath = System.getProperty(SECURITY_SET_PROP_FILE_PATH); + if (propsFilePath != null) { + String name = Path.of(propsFilePath).getFileName().toString(); + String setPropInvokeRepr = "Security.setProperty(\"include\", " + + "\"" + propsFilePath + "\")"; + try { + Security.setProperty("include", propsFilePath); + throw new RuntimeException(setPropInvokeRepr + " was " + + "expected to throw IllegalArgumentException."); + } catch (IllegalArgumentException expected) {} + if (FilesManager.APPLIED_PROP_VALUE.equals( + Security.getProperty(name))) { + throw new RuntimeException(setPropInvokeRepr + " caused " + + "a file inclusion."); + } + try { + Security.getProperty("include"); + throw new RuntimeException("Security.getProperty(\"include\")" + + " was expected to throw IllegalArgumentException."); + } catch (IllegalArgumentException expected) {} + } + } + + /* + * Error cases + */ + + static void testCannotResolveRelativeFromHTTPServed(Executor ex, + FilesManager filesMgr) throws Exception { + ExtraPropsFile extraFile = filesMgr.newExtraFile(); + PropsFile file0 = filesMgr.newFile("file0.properties"); + + extraFile.addRelativeInclude(file0); + + ex.setMasterFile(filesMgr.newMasterFile()); + ex.setExtraFile(extraFile, Executor.ExtraMode.HTTP_SERVED, true); + ex.assertError("InternalError: Cannot resolve '" + file0.fileName + + "' relative path when included from a non-regular " + + "properties file (e.g. HTTP served file)"); + } + + static void testCannotIncludeCycles(Executor ex, FilesManager filesMgr) + throws Exception { + PropsFile masterFile = filesMgr.newMasterFile(); + PropsFile file0 = filesMgr.newFile("file0.properties"); + PropsFile file1 = filesMgr.newFile("dir1/file1.properties"); + + // Includes chain: master -> file0 -> file1 -> master. + file1.addRelativeInclude(masterFile); + file0.addRelativeInclude(file1); + masterFile.addRelativeInclude(file0); + + ex.setMasterFile(masterFile); + ex.assertError( + "InternalError: Cyclic include of '" + masterFile.path + "'"); + } + + static void testCannotIncludeURL(Executor ex, FilesManager filesMgr) + throws Exception { + PropsFile masterFile = filesMgr.newMasterFile(); + ExtraPropsFile extraFile = filesMgr.newExtraFile(); + + masterFile.addRawProperty("include", extraFile.url.toString()); + + ex.setMasterFile(masterFile); + ex.assertError("InternalError: Unable to include 'http://127.0.0.1:"); + } + + static void testCannotIncludeNonexistentFile(Executor ex, + FilesManager filesMgr) throws Exception { + PropsFile masterFile = filesMgr.newMasterFile(); + + String nonexistentPath = "/nonExistentFile.properties"; + masterFile.addRawProperty("include", nonexistentPath); + + ex.setMasterFile(masterFile); + ex.assertError( + "InternalError: Unable to include '" + nonexistentPath + "'"); + } + + static void testMustHaveMasterFile(Executor ex, FilesManager filesMgr) + throws Exception { + // Launch a JDK without a master java.security file present. + ex.assertError("InternalError: Error loading java.security file"); + } + + static void testMustHaveMasterFileEvenWithExtraFile(Executor ex, + FilesManager filesMgr) throws Exception { + // Launch a JDK without a master java.security file present, but with an + // extra file passed. Since the "security.overridePropertiesFile=true" + // security property is missing, it should fail anyway. + ex.setExtraFile( + filesMgr.newExtraFile(), Executor.ExtraMode.FILE_URI, true); + ex.assertError("InternalError: Error loading java.security file"); + } +} + +sealed class PropsFile permits ExtraPropsFile { + protected static final class Include { + final PropsFile propsFile; + final String value; + + private Include(PropsFile propsFile, String value) { + this.propsFile = propsFile; + this.value = value; + } + + static Include of(PropsFile propsFile) { + return new Include(propsFile, propsFile.path.toString()); + } + + static Include of(PropsFile propsFile, String value) { + return new Include(propsFile, value); + } + } + + protected final List includes = new ArrayList<>(); + protected final PrintWriter writer; + protected boolean includedFromExtra = false; + final String fileName; + final Path path; + + PropsFile(String fileName, Path path) throws IOException { + this.fileName = fileName; + this.path = path; + this.writer = new PrintWriter(Files.newOutputStream(path, + StandardOpenOption.CREATE, StandardOpenOption.APPEND), true); + } + + private static String escape(String text, boolean escapeSpace) { + StringBuilder sb = new StringBuilder(text.length()); + CharBuffer cb = CharBuffer.wrap(text); + while (cb.hasRemaining()) { + char c = cb.get(); + if (c == '\\' || escapeSpace && c == ' ') { + sb.append('\\'); + } + if (Character.UnicodeBlock.of(c) == + Character.UnicodeBlock.BASIC_LATIN) { + sb.append(c); + } else { + sb.append("\\u%04x".formatted((int) c)); + } + } + return sb.toString(); + } + + private void addRawProperty(String key, String value, String sep) { + writer.println(escape(key, true) + sep + escape(value, false)); + } + + protected void addIncludeDefinition(Include include) { + if (include.propsFile instanceof ExtraPropsFile) { + throw new RuntimeException("ExtraPropsFile should not be included"); + } + includes.add(include); + addRawProperty("include", include.value, " "); + } + + void addComment(String comment) { + writer.println("# " + comment); + } + + void addRawProperty(String key, String value) { + addRawProperty(key, value, "="); + } + + void addAbsoluteInclude(PropsFile propsFile) { + addIncludeDefinition(Include.of(propsFile)); + } + + void addRelativeInclude(PropsFile propsFile) { + addIncludeDefinition(Include.of(propsFile, + path.getParent().relativize(propsFile.path).toString())); + } + + void assertApplied(OutputAnalyzer oa) { + oa.shouldContain(Executor.INITIAL_PROP_LOG_MSG + fileName + "=" + + FilesManager.APPLIED_PROP_VALUE); + for (Include include : includes) { + include.propsFile.assertApplied(oa); + oa.shouldContain("processing include: '" + include.value + "'"); + oa.shouldContain("finished processing " + include.propsFile.path); + } + } + + void assertWasOverwritten(OutputAnalyzer oa) { + oa.shouldNotContain(Executor.INITIAL_PROP_LOG_MSG + fileName + "=" + + FilesManager.APPLIED_PROP_VALUE); + for (Include include : includes) { + if (!include.propsFile.includedFromExtra) { + include.propsFile.assertWasOverwritten(oa); + } + oa.shouldContain("processing include: '" + include.value + "'"); + oa.shouldContain("finished processing " + include.propsFile.path); + } + } + + void markAsIncludedFromExtra() { + includedFromExtra = true; + for (Include include : includes) { + include.propsFile.markAsIncludedFromExtra(); + } + } + + PropsFile getLastFile() { + return includes.isEmpty() ? + this : includes.getLast().propsFile.getLastFile(); + } + + void close() { + writer.close(); + } +} + +final class ExtraPropsFile extends PropsFile { + private final Map systemProps = new LinkedHashMap<>(); + final URI url; + + ExtraPropsFile(String fileName, URI url, Path path) throws IOException { + super(fileName, path); + this.url = url; + } + + @Override + protected void addIncludeDefinition(Include include) { + if (includes.isEmpty()) { + String propName = "props.fileName"; + systemProps.put(propName, include.propsFile.fileName); + include = Include.of(include.propsFile, + include.value.replace(include.propsFile.fileName, + "${props.none}${" + propName + "}")); + } + include.propsFile.markAsIncludedFromExtra(); + super.addIncludeDefinition(include); + } + + Map getSystemProperties() { + return Collections.unmodifiableMap(systemProps); + } +} + +final class FilesManager implements Closeable { + private static final Path ROOT_DIR = + Path.of(ConfigFileTest.class.getSimpleName()).toAbsolutePath(); + private static final Path PROPS_DIR = ROOT_DIR.resolve("properties"); + private static final Path JDK_DIR = ROOT_DIR.resolve("jdk"); + private static final Path MASTER_FILE = + JDK_DIR.resolve("conf/security/java.security"); + private static final Path MASTER_FILE_TEMPLATE = + MASTER_FILE.resolveSibling("java.security.template"); + static final String JAVA_EXECUTABLE = + JDK_DIR.resolve("bin/java").toString(); + static final String LAST_FILE_PROP_NAME = "last-file"; + static final String APPLIED_PROP_VALUE = "applied"; + + private final List createdFiles; + private final Set fileNamesInUse; + private final HttpServer httpServer; + private final URI serverUri; + private final long masterFileLines; + + FilesManager() throws Exception { + createdFiles = new ArrayList<>(); + fileNamesInUse = new HashSet<>(); + httpServer = HttpServer.create( + new InetSocketAddress(InetAddress.getLoopbackAddress(), 0), 0); + httpServer.createContext("/", this::handleRequest); + InetSocketAddress address = httpServer.getAddress(); + httpServer.start(); + serverUri = new URI("http", null, address.getHostString(), + address.getPort(), null, null, null); + copyJDK(); + try (Stream s = Files.lines(MASTER_FILE_TEMPLATE)) { + masterFileLines = s.count(); + } + } + + private static void copyJDK() throws Exception { + Path testJDK = Path.of(Objects.requireNonNull( + System.getProperty("test.jdk"), "unspecified test.jdk")); + if (!Files.exists(testJDK)) { + throw new RuntimeException("test.jdk -> nonexistent JDK"); + } + Files.createDirectories(JDK_DIR); + try (Stream pathStream = Files.walk(testJDK)) { + pathStream.skip(1).forEach((Path file) -> { try { - Files.copy(file, dst.resolve(src.relativize(file)), StandardCopyOption.COPY_ATTRIBUTES); + Files.copy(file, JDK_DIR.resolve(testJDK.relativize(file)), + StandardCopyOption.COPY_ATTRIBUTES); } catch (IOException ioe) { throw new UncheckedIOException(ioe); } }); + } + Files.move(MASTER_FILE, MASTER_FILE_TEMPLATE); + } + + private void handleRequest(HttpExchange x) throws IOException { + String rawPath = x.getRequestURI().getRawPath(); + Path f = ROOT_DIR.resolve(x.getRequestURI().getPath().substring(1)); + int statusCode; + byte[] responseBody; + // Check for unescaped space, unresolved parent or backward slash. + if (rawPath.matches("^.*( |(\\.|%2[Ee]){2}|\\\\|%5[Cc]).*$")) { + statusCode = HttpURLConnection.HTTP_BAD_REQUEST; + responseBody = new byte[0]; + } else if (Files.isRegularFile(f)) { + x.getResponseHeaders().add("Content-type", "text/plain"); + statusCode = HttpURLConnection.HTTP_OK; + responseBody = Files.readAllBytes(f); + } else { + statusCode = HttpURLConnection.HTTP_NOT_FOUND; + responseBody = new byte[0]; + } + System.out.println("[" + Instant.now() + "] " + + getClass().getSimpleName() + ": " + + x.getRequestMethod() + " " + rawPath + " -> " + + statusCode + " (" + responseBody.length + " bytes)"); + try (OutputStream responseStream = x.getResponseBody()) { + x.sendResponseHeaders(statusCode, responseBody.length); + responseStream.write(responseBody); + } + } + + @FunctionalInterface + private interface PropsFileBuilder { + PropsFile build(String fileName, Path path) throws IOException; + } + + private PropsFile newFile(Path path, PropsFileBuilder builder) + throws IOException { + String fileName = path.getFileName().toString(); + if (!fileNamesInUse.add(fileName)) { + // Names must be unique in order for the special + // property = to work. + throw new RuntimeException(fileName + " is repeated"); + } + Files.createDirectories(path.getParent()); + PropsFile propsFile = builder.build(fileName, path); + propsFile.addComment("Property to determine if this properties file " + + "was parsed and not overwritten:"); + propsFile.addRawProperty(fileName, APPLIED_PROP_VALUE); + propsFile.addComment(ConfigFileTest.SEPARATOR_THIN); + propsFile.addComment("Property to be overwritten by every properties " + + "file (master, extra or included):"); + propsFile.addRawProperty(LAST_FILE_PROP_NAME, fileName); + propsFile.addComment(ConfigFileTest.SEPARATOR_THIN); + createdFiles.add(propsFile); + return propsFile; + } + + PropsFile newFile(String relPathStr) throws IOException { + return newFile(PROPS_DIR.resolve(relPathStr), PropsFile::new); + } + + PropsFile newMasterFile() throws IOException { + Files.copy(MASTER_FILE_TEMPLATE, MASTER_FILE); + return newFile(MASTER_FILE, PropsFile::new); + } + + ExtraPropsFile newExtraFile() throws IOException { + return newExtraFile("extra.properties"); + } + + ExtraPropsFile newExtraFile(String extraFileName) throws IOException { + return (ExtraPropsFile) newFile(PROPS_DIR.resolve(extraFileName), + (fileName, path) -> { + URI uri = serverUri.resolve(ParseUtil.encodePath( + ROOT_DIR.relativize(path).toString())); + return new ExtraPropsFile(fileName, uri, path); + }); + } + + void reportCreatedFiles() throws IOException { + for (PropsFile propsFile : createdFiles) { + System.err.println(); + System.err.println(propsFile.path.toString()); + System.err.println(ConfigFileTest.SEPARATOR_THIN.repeat(3)); + try (Stream lines = Files.lines(propsFile.path)) { + long lineNumber = 1L; + Iterator it = lines.iterator(); + while (it.hasNext()) { + String line = it.next(); + if (!propsFile.path.equals(MASTER_FILE) || + lineNumber > masterFileLines) { + System.err.println(line); + } + lineNumber++; + } + } + System.err.println(); + } + } + + void clear() throws IOException { + if (!createdFiles.isEmpty()) { + for (PropsFile propsFile : createdFiles) { + propsFile.close(); + Files.delete(propsFile.path); + } + FileUtils.deleteFileTreeUnchecked(PROPS_DIR); + createdFiles.clear(); + fileNamesInUse.clear(); + } + } + + @Override + public void close() throws IOException { + clear(); + httpServer.stop(0); + FileUtils.deleteFileTreeUnchecked(ROOT_DIR); + } +} + +final class Executor { + enum ExtraMode { + HTTP_SERVED, FILE_URI, RAW_FILE_URI1, RAW_FILE_URI2, PATH_ABS, PATH_REL + } + static final String RUNNER_ARG = "runner"; + static final String INITIAL_PROP_LOG_MSG = "Initial security property: "; + private static final String OVERRIDING_LOG_MSG = + "overriding other security properties files!"; + private static final String[] ALWAYS_UNEXPECTED_LOG_MSGS = { + "java.lang.AssertionError", + INITIAL_PROP_LOG_MSG + "postInitTest=shouldNotRecord", + INITIAL_PROP_LOG_MSG + "include=", + }; + private static final Path CWD = Path.of(".").toAbsolutePath(); + private static final String JAVA_SEC_PROPS = "java.security.properties"; + private static final String CLASS_PATH = Objects.requireNonNull( + System.getProperty("test.classes"), "unspecified test.classes"); + private static final String DEBUG_ARG = + "-Xrunjdwp:transport=dt_socket,address=localhost:8000,suspend=y"; + private final Map systemProps = new LinkedHashMap<>( + Map.of("java.security.debug", "all", "javax.net.debug", "all", + // Ensure we get UTF-8 debug outputs in Windows: + "stderr.encoding", "UTF-8", "stdout.encoding", "UTF-8")); + private final List jvmArgs = new ArrayList<>( + List.of(FilesManager.JAVA_EXECUTABLE, "-enablesystemassertions", + // Uncomment DEBUG_ARG to debug test-launched JVMs: + "-classpath", CLASS_PATH//, DEBUG_ARG + )); + private PropsFile masterPropsFile; + private ExtraPropsFile extraPropsFile; + private boolean expectedOverrideAll = false; + private OutputAnalyzer oa; + + static void run(Method m, FilesManager filesMgr) throws Exception { + try { + m.invoke(null, new Executor(), filesMgr); + } catch (Throwable e) { + filesMgr.reportCreatedFiles(); + throw e; + } finally { + filesMgr.clear(); + } + } + + void addSystemProp(String key, String value) { + systemProps.put(key, value); + } + + private void setRawExtraFile(String extraFile, boolean overrideAll) { + addSystemProp(JAVA_SEC_PROPS, (overrideAll ? "=" : "") + extraFile); + } + + void setMasterFile(PropsFile masterPropsFile) { + this.masterPropsFile = masterPropsFile; + } + + void setExtraFile(ExtraPropsFile extraPropsFile, ExtraMode mode, + boolean overrideAll) { + this.extraPropsFile = extraPropsFile; + expectedOverrideAll = overrideAll; + setRawExtraFile(switch (mode) { + case HTTP_SERVED -> extraPropsFile.url.toString(); + case FILE_URI -> extraPropsFile.path.toUri().toString(); + case RAW_FILE_URI1 -> "file:" + extraPropsFile.path; + case RAW_FILE_URI2 -> "file://" + + (extraPropsFile.path.startsWith("/") ? "" : "/") + + extraPropsFile.path; + case PATH_ABS -> extraPropsFile.path.toString(); + case PATH_REL -> CWD.relativize(extraPropsFile.path).toString(); + }, overrideAll); + } + + void setIgnoredExtraFile(String extraPropsFile, boolean overrideAll) { + setRawExtraFile(extraPropsFile, overrideAll); + expectedOverrideAll = false; + } + + void addJvmArg(String arg) { + jvmArgs.add(arg); + } + + private void execute(boolean successExpected) throws Exception { + List command = new ArrayList<>(jvmArgs); + Collections.addAll(command, Utils.getTestJavaOpts()); + addSystemPropertiesAsJvmArgs(command); + command.add(ConfigFileTest.class.getSimpleName()); + command.add(RUNNER_ARG); + oa = ProcessTools.executeProcess(new ProcessBuilder(command)); + oa.shouldHaveExitValue(successExpected ? 0 : 1); + for (String output : ALWAYS_UNEXPECTED_LOG_MSGS) { + oa.shouldNotContain(output); + } + } + + private void addSystemPropertiesAsJvmArgs(List command) { + Map allSystemProps = new LinkedHashMap<>(systemProps); + if (extraPropsFile != null) { + allSystemProps.putAll(extraPropsFile.getSystemProperties()); + } + for (Map.Entry e : allSystemProps.entrySet()) { + command.add("-D" + e.getKey() + "=" + e.getValue()); + } + } + + void assertSuccess() throws Exception { + execute(true); + + // Ensure every file was processed by checking a unique property used as + // a flag. Each file defines =applied. + // + // For example: + // + // file0 + // --------------- + // file0=applied + // include file1 + // + // file1 + // --------------- + // file1=applied + // + // The assertion would be file0 == applied AND file1 == applied. + // + if (extraPropsFile != null) { + extraPropsFile.assertApplied(oa); + } + if (expectedOverrideAll) { + // When overriding with an extra file, check that neither + // the master file nor its includes are visible. + oa.shouldContain(OVERRIDING_LOG_MSG); + masterPropsFile.assertWasOverwritten(oa); + } else { + oa.shouldNotContain(OVERRIDING_LOG_MSG); + masterPropsFile.assertApplied(oa); + } + + // Ensure the last included file overwrote a fixed property. Each file + // defines last-file=. + // + // For example: + // + // file0 + // --------------- + // last-file=file0 + // include file1 + // + // file1 + // --------------- + // last-file=file1 + // + // The assertion would be last-file == file1. + // + PropsFile lastFile = (extraPropsFile == null ? + masterPropsFile : extraPropsFile).getLastFile(); + oa.shouldContain(FilesManager.LAST_FILE_PROP_NAME + "=" + + lastFile.fileName); + oa.stdoutShouldContain(FilesManager.LAST_FILE_PROP_NAME + ": " + + lastFile.fileName); + } + + void assertError(String message) throws Exception { + execute(false); + oa.shouldContain(message); + } + + OutputAnalyzer getOutputAnalyzer() { + return oa; } } diff --git a/test/jdk/java/security/Security/override.props b/test/jdk/java/security/Security/override.props deleted file mode 100644 index d0190f576fd..00000000000 --- a/test/jdk/java/security/Security/override.props +++ /dev/null @@ -1,7 +0,0 @@ -# exercise ServiceLoader and legacy (class load) approach -security.provider.1=sun.security.provider.Sun -security.provider.2=SunRsaSign -security.provider.3=sun.security.ssl.SunJSSE -security.provider.4=com.sun.crypto.provider.SunJCE -security.provider.5=SunJGSS -security.provider.6=SunSASL \ No newline at end of file diff --git a/test/jdk/java/security/Security/signedfirst/DynStatic.java b/test/jdk/java/security/Security/signedfirst/DynStatic.java index 59e30de5462..17fab4cac5b 100644 --- a/test/jdk/java/security/Security/signedfirst/DynStatic.java +++ b/test/jdk/java/security/Security/signedfirst/DynStatic.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,6 @@ import java.io.File; import java.nio.file.Path; import java.nio.file.Paths; -import java.util.List; import jdk.test.lib.compiler.CompilerUtils; import jdk.test.lib.process.ProcessTools; @@ -52,9 +51,8 @@ public class DynStatic { Paths.get(TEST_SRC, "DynSignedProvFirst.java"); private static final Path STATIC_SRC = Paths.get(TEST_SRC, "StaticSignedProvFirst.java"); - - private static final String STATIC_PROPS = - Paths.get(TEST_SRC, "Static.props").toString(); + private static final Path STATIC_PROPS = + Paths.get(TEST_SRC, "Static.props"); public static void main(String[] args) throws Exception { @@ -89,7 +87,7 @@ public class DynStatic { // Run the StaticSignedProvFirst test program ProcessTools.executeTestJava("-classpath", TEST_CLASSES.toString() + File.pathSeparator + "exp.jar", - "-Djava.security.properties=file:" + STATIC_PROPS, + "-Djava.security.properties=" + STATIC_PROPS.toUri(), "StaticSignedProvFirst") .shouldContain("test passed"); } diff --git a/test/jdk/java/util/ArrayList/SortingModCount.java b/test/jdk/java/util/ArrayList/SortingModCount.java new file mode 100644 index 00000000000..394c74cf444 --- /dev/null +++ b/test/jdk/java/util/ArrayList/SortingModCount.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.util.ArrayList; +import java.util.Collections; +import java.util.ConcurrentModificationException; +import java.util.List; + +/** + * @test + * @bug 8340572 + * @summary ConcurrentModificationException when sorting ArrayList sublists + */ + +public class SortingModCount { + public static void main(String[] args) { + testSortingSubListsDoesNotIncrementModCount(); + testSortingListDoesIncrementModCount(); + } + + private static void testSortingSubListsDoesNotIncrementModCount() { + List l = new ArrayList<>(List.of(1, 2, 3, 4)); + var a = l.subList(0, 2); + var b = l.subList(2, 4); + Collections.sort(a); + Collections.sort(b); + } + + private static void testSortingListDoesIncrementModCount() { + List l = new ArrayList<>(List.of(1, 2, 3, 4)); + var b = l.subList(2, 4); + Collections.sort(l); + try { + Collections.sort(b); + throw new Error("expected ConcurrentModificationException not thrown"); + } catch (ConcurrentModificationException expected) { + } + } +} diff --git a/test/jdk/java/util/Base64/TestEncodingDecodingLength.java b/test/jdk/java/util/Base64/TestEncodingDecodingLength.java index ce6d0db4adc..452f11ebea9 100644 --- a/test/jdk/java/util/Base64/TestEncodingDecodingLength.java +++ b/test/jdk/java/util/Base64/TestEncodingDecodingLength.java @@ -21,6 +21,7 @@ * questions. */ +import jdk.internal.util.ArraysSupport; import org.junit.jupiter.api.Test; import java.lang.reflect.InvocationTargetException; @@ -37,6 +38,7 @@ import static org.junit.jupiter.api.Assertions.fail; * Base64.Decoder.decode behavior with large, (Integer.MAX_VALUE) sized * input array/buffer. Tests the private methods "encodedOutLength" and * "decodedOutLength". + * @modules java.base/jdk.internal.util * @run junit/othervm --add-opens java.base/java.util=ALL-UNNAMED TestEncodingDecodingLength */ @@ -45,7 +47,7 @@ import static org.junit.jupiter.api.Assertions.fail; public class TestEncodingDecodingLength { // A value large enough to test the desired memory conditions in encode and decode - private static final int LARGE_MEM_SIZE = Integer.MAX_VALUE - 8; + private static final int LARGE_MEM_SIZE = ArraysSupport.SOFT_MAX_ARRAY_LENGTH; private static final Base64.Decoder DECODER = Base64.getDecoder(); private static final Base64.Encoder ENCODER = Base64.getEncoder(); diff --git a/test/jdk/java/util/List/ListDefaults.java b/test/jdk/java/util/List/ListDefaults.java index c29d2243f41..8c9e7e3f613 100644 --- a/test/jdk/java/util/List/ListDefaults.java +++ b/test/jdk/java/util/List/ListDefaults.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -50,7 +50,7 @@ import java.util.function.Predicate; /** * @test * @summary Unit tests for extension methods on List - * @bug 8023367 8037106 + * @bug 8023367 8037106 8325679 * @library ../Collection/testlibrary * @build CollectionAsserts CollectionSupplier ExtendsAbstractList * @run testng ListDefaults diff --git a/test/jdk/java/util/PluggableLocale/DateFormatProviderTest.java b/test/jdk/java/util/PluggableLocale/DateFormatProviderTest.java index 876fe3526cf..4e3fdfbaf7a 100644 --- a/test/jdk/java/util/PluggableLocale/DateFormatProviderTest.java +++ b/test/jdk/java/util/PluggableLocale/DateFormatProviderTest.java @@ -31,7 +31,7 @@ * java.base/sun.util.resources * @build com.foobar.Utils * com.foo.* - * @run main/othervm -Djava.locale.providers=CLDR,SPI DateFormatProviderTest + * @run main/othervm/timeout=300 -Djava.locale.providers=CLDR,SPI DateFormatProviderTest */ import java.text.DateFormat; diff --git a/test/jdk/java/util/TimeZone/DefaultTimeZoneTest.html b/test/jdk/java/util/TimeZone/DefaultTimeZoneTest.html deleted file mode 100644 index 1fa0659ed63..00000000000 --- a/test/jdk/java/util/TimeZone/DefaultTimeZoneTest.html +++ /dev/null @@ -1,74 +0,0 @@ - - - - - - Disable Auto-adjust Daylight Saving Time Test - - - -This applet tests the platform time zone detection on all platforms (Part I) -and on/off of DST adjustment on Windows (Part II). - -Part I: - -Observe the displayed Time zone ID and the local time. If you can change -the platform time zone setting, try several time zones. If both the ID and -the local time, including the time zone name and its time zone offset, are -always correct, Part I passes. Note that some time zone IDs have their -aliases that may be displayed. For example, "US/Pacific" is an alias of -"America/Los_Angeles". - -If you are running this applet in non-English locale, the time zone names -can be displayed in the local language and English by pushing the -English/Local button. - -If platform time zones are NOT detected correctly, press the Fail button -to finish this applet. - -If this platform is Windows, proceed to Part II. Otherwise, press the Pass -button to finish this applet. - -Part II: - -Note that Part II may require the Administrator privilege to change -Windows setting. - - 1. Open the Date and Time control panel. - 2. Select any time zone where daylight saving time is *currently* in effect, - such as "(GMT-08:00) Pacific Time (US & Canada); Tijuana", - "(GMT+10:00) Canberra, Melbourne, Sydney", and Apply. - 3. Observe the local time on the control panel (Date&Time pane) and - the applet local time should be the same (daylight time). - 4. Clear "Automatically adjust clock for daylight saving changes" and Apply. - 5. Observe the two local times should be the same (standard time). - 6. Select "Automatically adjust clock for daylight saving changes" and Apply. - -If the local time in the control panel and applet are always the same, -then this test passes. Press the Pass or Fail button based on the Part II -result and finish this applet. - - - - diff --git a/test/jdk/java/util/TimeZone/DefaultTimeZoneTest.java b/test/jdk/java/util/TimeZone/DefaultTimeZoneTest.java index a6d3ac50866..4dd644d58b5 100644 --- a/test/jdk/java/util/TimeZone/DefaultTimeZoneTest.java +++ b/test/jdk/java/util/TimeZone/DefaultTimeZoneTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,85 +24,94 @@ /* * @test * @bug 4296930 5033603 7092679 - * @summary Make sure that Java runtime detects the platform time zone - * correctly. Also make sure that the system time zone detection code - * detects the "Automatically adjust clock for daylight saving - * changes" setting correctly on Windows. - * @run applet/manual=yesno DefaultTimeZoneTest.html + * @summary Ensure that Java detects the platform time zone correctly, even + * if changed during runtime. Also ensure that the system time zone detection code + * detects the "Automatically adjust clock for daylight saving changes" setting + * correctly on Windows. This is a manual test dependent on making changes to + * the platform setting of the machine and thus cannot be automated. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual DefaultTimeZoneTest */ -import javax.swing.*; -import java.awt.*; -import java.awt.event.*; -import java.text.*; -import java.util.*; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Window; +import java.lang.reflect.InvocationTargetException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.TimeZone; -public class DefaultTimeZoneTest extends JApplet implements Runnable { - static final String FORMAT = "yyyy-MM-dd HH:mm:ss zzzz (XXX)"; - JLabel tzid; - JLabel label; - SimpleDateFormat sdf = new SimpleDateFormat(FORMAT); - JButton button = new JButton("English"); - Thread clock; - boolean english = false; +public class DefaultTimeZoneTest { - @Override - public void init() { - tzid = new JLabel("Time zone ID: " + sdf.getTimeZone().getID(), SwingConstants.CENTER); - tzid.setAlignmentX(Component.CENTER_ALIGNMENT); - label = new JLabel(sdf.format(new Date()), SwingConstants.CENTER); - label.setAlignmentX(Component.CENTER_ALIGNMENT); - button.addActionListener(new ActionListener() { - @Override - @SuppressWarnings("deprecation") - public void actionPerformed(ActionEvent e) { - english = (english == false); - Locale loc = english ? Locale.US : Locale.getDefault(); - sdf = new SimpleDateFormat(FORMAT, loc); - button.setLabel(!english ? "English" : "Local"); - } - }); - button.setAlignmentX(Component.CENTER_ALIGNMENT); - JPanel panel = new JPanel(); - panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS)); - panel.add(Box.createRigidArea(new Dimension(0, 10))); - panel.add(tzid); - panel.add(Box.createRigidArea(new Dimension(0, 5))); - panel.add(label); - panel.add(Box.createRigidArea(new Dimension(0, 10))); + private static final SimpleDateFormat SDF = + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss zzzz (XXX)"); + private static final String INSTRUCTIONS = + """ + Tests the platform time zone detection on all platforms. + (Part I) and on/off of DST adjustment on Windows (Part II). + + Part I: + Observe the displayed Time zone ID and the local time. + Change the platform time zone setting, then click the + "Update Time Zone" button. If the ID and local time + update correctly, part I passes, otherwise press fail. Note that + some time zone IDs have their aliases that may be displayed. + For example, "US/Pacific" is an alias of "America/Los_Angeles". + If this platform is Windows, proceed to Part II. Otherwise, press + the Pass button to complete this test. + + Part II: + Note that Part II may require the Administrator privilege to change + Windows setting. + + 1. Open the Settings app and navigate to Time & Language > Date & Time + 2. Select any time zone where daylight saving time is *currently* + in effect, such as "(GMT-08:00) Pacific Time (US & Canada); + Tijuana", "(GMT+10:00) Canberra, Melbourne, Sydney", and Apply. + 3. After pressing "Update Time Zone" button, observe that the local + time on the Settings app and the test local time are the same (daylight time). + 4. Turn off "Adjust for daylight saving time automatically" + 5. Observe the two local times should be the same (standard time). + 6. Turn on "Adjust for daylight saving time automatically" + + If the local time in the Settings app and test window are always the same, + then this test passes. Press the Pass or Fail button based on the Part II + result and complete the test. + """; + + public static void main(String[] args) + throws InterruptedException, InvocationTargetException { + // Force platform time zone as default time zone + TimeZone.setDefault(null); + System.setProperty("user.timezone", ""); + // Construct test window + PassFailJFrame.builder() + .title("DefaultTimeZoneTest Instructions") + .testUI(createTest()) + .instructions(INSTRUCTIONS) + .build().awaitAndCheck(); + } + + private static Window createTest() { + var contents = new JFrame("DefaultTimeZoneTest"); + var label = new JLabel(SDF.format(new Date())); + var panel = new JPanel(); + var button = new JButton("Update Time Zone"); panel.add(button); - getContentPane().add(panel); - } - - @Override - public void start() { - clock = new Thread(this); - clock.start(); - } - - @Override - public void stop() { - clock = null; - } - - @Override - public void run() { - Thread me = Thread.currentThread(); - - while (clock == me) { - // Reset the default time zone so that - // TimeZone.getDefault will detect the platform time zone - TimeZone.setDefault(null); - System.setProperty("user.timezone", ""); + contents.setSize(350, 250); + contents.add(label, BorderLayout.NORTH); + contents.add(panel, BorderLayout.CENTER); + // Update default time zone on button click + button.addActionListener(e -> { TimeZone tz = TimeZone.getDefault(); - sdf.setTimeZone(tz); - tzid.setText("Time zone ID: " + tz.getID()); - label.setText(sdf.format(new Date())); - repaint(); - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - } - } + SDF.setTimeZone(tz); + label.setText(SDF.format(new Date())); + contents.repaint(); + }); + return contents; } } diff --git a/test/jdk/java/util/concurrent/tck/ArrayDeque8Test.java b/test/jdk/java/util/concurrent/tck/ArrayDeque8Test.java index eb606b0c781..fb21ebfed36 100644 --- a/test/jdk/java/util/concurrent/tck/ArrayDeque8Test.java +++ b/test/jdk/java/util/concurrent/tck/ArrayDeque8Test.java @@ -36,6 +36,7 @@ import java.util.ArrayDeque; import java.util.Collections; import java.util.Spliterator; +import jdk.internal.util.ArraysSupport; import junit.framework.Test; public class ArrayDeque8Test extends JSR166TestCase { @@ -86,7 +87,7 @@ public class ArrayDeque8Test extends JSR166TestCase { return; final Item e = fortytwo; - final int maxArraySize = Integer.MAX_VALUE - 8; + final int maxArraySize = ArraysSupport.SOFT_MAX_ARRAY_LENGTH; assertThrows(OutOfMemoryError.class, () -> new ArrayDeque(Integer.MAX_VALUE)); diff --git a/test/jdk/java/util/concurrent/tck/JSR166TestCase.java b/test/jdk/java/util/concurrent/tck/JSR166TestCase.java index 451864bcf5d..19897fa0785 100644 --- a/test/jdk/java/util/concurrent/tck/JSR166TestCase.java +++ b/test/jdk/java/util/concurrent/tck/JSR166TestCase.java @@ -38,7 +38,7 @@ * @test id=default * @summary Conformance testing variant of JSR-166 tck tests. * @build * - * @modules java.management + * @modules java.management java.base/jdk.internal.util * @run junit/othervm/timeout=1000 JSR166TestCase */ @@ -47,7 +47,7 @@ * @summary Conformance testing variant of JSR-166 tck tests * with java security manager set to allow. * @build * - * @modules java.management + * @modules java.management java.base/jdk.internal.util * @run junit/othervm/timeout=1000 -Djava.security.manager=allow JSR166TestCase */ @@ -56,7 +56,7 @@ * @summary Test implementation details variant of JSR-166 * tck tests with ForkJoinPool common parallelism. * @build * - * @modules java.management + * @modules java.management java.base/jdk.internal.util * @run junit/othervm/timeout=1000 * --add-opens java.base/java.util.concurrent=ALL-UNNAMED * --add-opens java.base/java.lang=ALL-UNNAMED @@ -78,7 +78,7 @@ * JSR-166 tck tests apart from ForkJoinPool common * parallelism. * @build * - * @modules java.management + * @modules java.management java.base/jdk.internal.util * @run junit/othervm/timeout=1000 * --add-opens java.base/java.util.concurrent=ALL-UNNAMED * --add-opens java.base/java.lang=ALL-UNNAMED diff --git a/test/jdk/java/util/logging/TestMainAppContext.java b/test/jdk/java/util/logging/TestMainAppContext.java index 49f371aa321..0bfcbbad9d8 100644 --- a/test/jdk/java/util/logging/TestMainAppContext.java +++ b/test/jdk/java/util/logging/TestMainAppContext.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,8 +46,8 @@ public class TestMainAppContext { rootTG = rootTG.getParent(); } - ThreadGroup tg = new ThreadGroup(rootTG, "FakeApplet"); - final Thread t1 = new Thread(tg, "createNewAppContext") { + ThreadGroup tg = new ThreadGroup(rootTG, "main"); + final Thread t1 = new Thread(tg, "child") { @Override public void run() { try { diff --git a/test/jdk/java/util/zip/ZipFile/CenSizeMaximum.java b/test/jdk/java/util/zip/ZipFile/CenSizeMaximum.java new file mode 100644 index 00000000000..a63464eb72b --- /dev/null +++ b/test/jdk/java/util/zip/ZipFile/CenSizeMaximum.java @@ -0,0 +1,246 @@ +/* + * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* @test + * @bug 8341595 + * @modules java.base/jdk.internal.util + * @summary Verify that ZipFile can read from a ZIP file with a maximally large CEN size + * @run junit/othervm/manual -Xmx2500M CenSizeMaximum + */ + +import jdk.internal.util.ArraysSupport; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; + +import java.io.*; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.nio.channels.FileChannel; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.StandardOpenOption; +import java.util.Arrays; +import java.util.EnumSet; +import java.util.zip.ZipEntry; +import java.util.zip.ZipException; +import java.util.zip.ZipFile; +import java.util.zip.ZipOutputStream; + +import static org.junit.jupiter.api.Assertions.*; + +public class CenSizeMaximum { + + // Maximum allowed CEN size allowed by the ZipFile implementation + static final int MAX_CEN_SIZE = ArraysSupport.SOFT_MAX_ARRAY_LENGTH; + + /** + * From the APPNOTE.txt specification: + * 4.4.10 file name length: (2 bytes) + * 4.4.11 extra field length: (2 bytes) + * 4.4.12 file comment length: (2 bytes) + * + * The length of the file name, extra field, and comment + * fields respectively. The combined length of any + * directory record and these three fields SHOULD NOT + * generally exceed 65,535 bytes. + *. + * Create a maximum extra field which does not exceed 65,535 bytes + */ + static final int MAX_EXTRA_FIELD_SIZE = 65_535 - ZipFile.CENHDR; + + // Tag for the 'unknown' field type, specified in APPNOTE.txt 'Third party mappings' + static final short UNKNOWN_ZIP_TAG = (short) 0x9902; + + // The size of one CEN header, including the name and the extra field + static final int CEN_HEADER_SIZE = ZipFile.CENHDR + MAX_EXTRA_FIELD_SIZE; + + // The size of the extra data field header (tag id + data block length) + static final int EXTRA_FIELD_HEADER_SIZE = 2 * Short.BYTES; + + // Zip file to create for testing + private Path hugeZipFile = Path.of("cen-size-on-limit.zip"); + + /** + * Clean up ZIP file created in this test + */ + @AfterEach + public void cleanup() throws IOException { + //Files.deleteIfExists(hugeZipFile); + } + + /** + * Validates that ZipFile opens a ZIP file with a CEN size close + * to the {@link #MAX_CEN_SIZE} implementation limit. + * + * @throws IOException if an unexpected IO error occurs + */ + @Test + public void maximumCenSize() throws IOException { + int numCenHeaders = zipWithWithExactCenSize(MAX_CEN_SIZE, true, false); + try (var zf = new ZipFile(hugeZipFile.toFile())) { + assertEquals(numCenHeaders, zf.size()); + } + } + + /** + * Validates that ZipFile rejects a ZIP where the last CEN record + * overflows the CEN size and the END header CENTOT field is smaller + * than the actual number of headers + * + * @throws IOException if an unexpected IO error occurs + */ + @Test + public void lastCENHeaderBadSize() throws IOException { + int numCenHeaders = zipWithWithExactCenSize(1024, true, true); + ZipException zipException = assertThrows(ZipException.class, () -> { + try (var zf = new ZipFile(hugeZipFile.toFile())) { + assertEquals(numCenHeaders, zf.size()); + } + }); + assertEquals("invalid CEN header (bad header size)", zipException.getMessage()); + + } + + /** + * Produce a ZIP file with an exact CEN size. To minimize the number of CEN headers + * written, maximally large, empty extra data blocks are written sparsely. + * + * @param cenSize the exact CEN size of the ZIP file to produce + * @param invalidateEndTotal whether to decrement the END header's TOT field by one + * @return the number of CEN headers produced + * @throws IOException if an unexpected IO error occurs + */ + private int zipWithWithExactCenSize(long cenSize, boolean invalidateEndTotal, boolean overflowLastCEN) + throws IOException { + // Sanity check + assertTrue(cenSize <= MAX_CEN_SIZE); + + // The number of CEN headers we need to write + int numCenHeaders = (int) (cenSize / CEN_HEADER_SIZE) + 1; + // Size if all extra data fields were of maximum size + long overSized = numCenHeaders * (long) CEN_HEADER_SIZE; + // Length to trim from the first CEN's extra data + int negativPadding = (int) (overSized - cenSize); + int firstExtraSize = MAX_EXTRA_FIELD_SIZE - negativPadding; + + // Sanity check + long computedCenSize = (numCenHeaders -1L ) * CEN_HEADER_SIZE + ZipEntry.CENHDR + firstExtraSize; + assertEquals(computedCenSize, cenSize); + + // A CEN header, followed by the four-bytes extra data header + ByteBuffer cenHeader = createCENHeader(); + // An END header + ByteBuffer endHeader = createENDHeader(); + // Update the END header + if (invalidateEndTotal) { + // To trigger countCENHeaders + endHeader.putShort(ZipEntry.ENDTOT, (short) (numCenHeaders -1 & 0xFFFF)); + } else { + endHeader.putShort(ZipEntry.ENDTOT, (short) (numCenHeaders & 0xFFFF)); + } + // Update CEN size and offset fields + endHeader.putInt(ZipEntry.ENDSIZ, (int) (cenSize & 0xFFFFFFFFL)); + endHeader.putInt(ZipEntry.ENDOFF, 0); + + // When creating a sparse file, the file must not already exit + Files.deleteIfExists(hugeZipFile); + + // Open a FileChannel for writing a sparse file + EnumSet options = EnumSet.of(StandardOpenOption.CREATE_NEW, + StandardOpenOption.WRITE, + StandardOpenOption.SPARSE); + + try (FileChannel channel = FileChannel.open(hugeZipFile, options)) { + // Write CEN headers + for (int i = 0; i < numCenHeaders; i++) { + // The first CEN header has trimmed extra data + int extraSize = i == 0 ? firstExtraSize : MAX_EXTRA_FIELD_SIZE; + if (overflowLastCEN && i == numCenHeaders - 1) { + // make last CEN header overflow the CEN size + cenHeader.putShort(ZipEntry.CENNAM, Short.MAX_VALUE); + } + // update elen field + cenHeader.putShort(ZipEntry.CENEXT, (short) (extraSize & 0xFFFF)); + // update data block len of the extra field header + short dlen = (short) ((extraSize - EXTRA_FIELD_HEADER_SIZE) & 0xFFFF); + cenHeader.putShort(ZipEntry.CENHDR + Short.BYTES, dlen); + // Write the CEN header plus the four-byte extra header + channel.write(cenHeader.rewind()); + // Sparse "write" of the extra data block + channel.position(channel.position() + extraSize - EXTRA_FIELD_HEADER_SIZE); + } + // Sanity check + assertEquals(cenSize, channel.position()); + // Write the END header + channel.write(endHeader.rewind()); + } + return numCenHeaders; + } + + // Creates a ByteBuffer representing a CEN header with a trailing extra field header + private ByteBuffer createCENHeader() throws IOException { + byte[] bytes = smallZipfile(); + ByteBuffer buf = ByteBuffer.wrap(bytes).order(ByteOrder.LITTLE_ENDIAN); + int endOff = bytes.length - ZipEntry.ENDHDR; + int cenSize = buf.getInt(endOff + ZipEntry.ENDSIZ); + int cenOff = buf.getInt(endOff + ZipEntry.ENDOFF); + return ByteBuffer.wrap( + Arrays.copyOfRange(bytes, cenOff, cenOff + ZipEntry.CENHDR + EXTRA_FIELD_HEADER_SIZE) + ).order(ByteOrder.LITTLE_ENDIAN); + } + + // Creates a ByteBuffer representing an END header + private ByteBuffer createENDHeader() throws IOException { + byte[] bytes = smallZipfile(); + ByteBuffer buf = ByteBuffer.wrap(bytes).order(ByteOrder.LITTLE_ENDIAN); + int endOff = bytes.length - ZipEntry.ENDHDR; + return ByteBuffer.wrap( + Arrays.copyOfRange(bytes, endOff, endOff + ZipEntry.ENDHDR) + ).order(ByteOrder.LITTLE_ENDIAN); + } + + // Create a byte array with a minimal ZIP file + private static byte[] smallZipfile() throws IOException { + var out = new ByteArrayOutputStream(); + try (var zo = new ZipOutputStream(out)) { + ZipEntry entry = new ZipEntry(""); + entry.setExtra(makeDummyExtraField()); + zo.putNextEntry(entry); + } + return out.toByteArray(); + } + + // Create a minimally sized extra field + private static byte[] makeDummyExtraField() { + byte[] extra = new byte[EXTRA_FIELD_HEADER_SIZE]; + // Little-endian ByteBuffer for updating the header fields + ByteBuffer buffer = ByteBuffer.wrap(extra).order(ByteOrder.LITTLE_ENDIAN); + + // We use the 'unknown' tag, specified in APPNOTE.TXT, 4.6.1 Third party mappings' + buffer.putShort(UNKNOWN_ZIP_TAG); + + // Size of the actual (empty) data + buffer.putShort((short) 0); + return extra; + } +} diff --git a/test/jdk/java/util/zip/ZipFile/CenSizeTooLarge.java b/test/jdk/java/util/zip/ZipFile/CenSizeTooLarge.java index 4336377e0c8..e3f0b20fce8 100644 --- a/test/jdk/java/util/zip/ZipFile/CenSizeTooLarge.java +++ b/test/jdk/java/util/zip/ZipFile/CenSizeTooLarge.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,10 +23,12 @@ /* @test * @bug 8272746 + * @modules java.base/jdk.internal.util * @summary Verify that ZipFile rejects a ZIP with a CEN size which does not fit in a Java byte array * @run junit CenSizeTooLarge */ +import jdk.internal.util.ArraysSupport; import org.junit.Before; import org.junit.Test; @@ -34,9 +36,7 @@ import java.io.*; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.channels.FileChannel; -import java.nio.charset.StandardCharsets; import java.time.LocalDateTime; -import java.util.Arrays; import java.util.zip.ZipEntry; import java.util.zip.ZipException; import java.util.zip.ZipFile; @@ -46,8 +46,12 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; public class CenSizeTooLarge { + + // Entry names produced in this test are fixed-length + public static final int NAME_LENGTH = 10; + // Maximum allowed CEN size allowed by the ZipFile implementation - static final int MAX_CEN_SIZE = Integer.MAX_VALUE - ZipFile.ENDHDR - 1; + static final int MAX_CEN_SIZE = ArraysSupport.SOFT_MAX_ARRAY_LENGTH; /** * From the APPNOTE.txt specification: @@ -59,11 +63,10 @@ public class CenSizeTooLarge { * fields respectively. The combined length of any * directory record and these three fields SHOULD NOT * generally exceed 65,535 bytes. - * - * Since ZipOutputStream does not enforce the 'combined length' clause, - * we simply use 65,535 (0xFFFF) for the purpose of this test. + *. + * Create a maximum extra field which does not exceed 65,535 bytes */ - static final int MAX_EXTRA_FIELD_SIZE = 65_535; + static final int MAX_EXTRA_FIELD_SIZE = 65_535 - ZipFile.CENHDR - NAME_LENGTH; // Data size (unsigned short) // Field size minus the leading header 'tag' and 'data size' fields (2 bytes each) @@ -72,9 +75,6 @@ public class CenSizeTooLarge { // Tag for the 'unknown' field type, specified in APPNOTE.txt 'Third party mappings' static final short UNKNOWN_ZIP_TAG = (short) 0x9902; - // Entry names produced in this test are fixed-length - public static final int NAME_LENGTH = 10; - // Use a shared LocalDateTime on all entries to save processing time static final LocalDateTime TIME_LOCAL = LocalDateTime.now(); @@ -84,16 +84,16 @@ public class CenSizeTooLarge { // The number of entries needed to exceed the MAX_CEN_SIZE static final int NUM_ENTRIES = (MAX_CEN_SIZE / CEN_HEADER_SIZE) + 1; - // Helps SparseOutputStream detect write of the last CEN entry - private static final String LAST_CEN_COMMENT = "LastCEN"; - private static final byte[] LAST_CEN_COMMENT_BYTES = LAST_CEN_COMMENT.getBytes(StandardCharsets.UTF_8); - // Expected ZipException message when the CEN does not fit in a Java byte array private static final String CEN_TOO_LARGE_MESSAGE = "invalid END header (central directory size too large)"; // Zip file to create for testing private File hugeZipFile; + private static final byte[] EXTRA_BYTES = makeLargeExtraField(); + // Helps SparseOutputStream detect write of the last CEN entry + private static final byte[] LAST_EXTRA_BYTES = makeLargeExtraField(); + /** * Create a zip file with a CEN size which does not fit within a Java byte array */ @@ -125,23 +125,18 @@ public class CenSizeTooLarge { // Set the time/date field for faster processing entry.setTimeLocal(TIME_LOCAL); - if (i == NUM_ENTRIES -1) { - // Help SparseOutputStream detect the last CEN entry write - entry.setComment(LAST_CEN_COMMENT); - } // Add the entry zip.putNextEntry(entry); - - } // Finish writing the last entry zip.closeEntry(); // Before the CEN headers are written, set the extra data on each entry - byte[] extra = makeLargeExtraField(); for (ZipEntry entry : entries) { - entry.setExtra(extra); + entry.setExtra(EXTRA_BYTES); } + // Help SparseOutputSream detect the last entry + entries[entries.length-1].setExtra(LAST_EXTRA_BYTES); } } @@ -165,7 +160,7 @@ public class CenSizeTooLarge { * Data Size (Two byte short) * Data Block (Contents depend on field type) */ - private byte[] makeLargeExtraField() { + private static byte[] makeLargeExtraField() { // Make a maximally sized extra field byte[] extra = new byte[MAX_EXTRA_FIELD_SIZE]; // Little-endian ByteBuffer for updating the header fields @@ -203,7 +198,7 @@ public class CenSizeTooLarge { // but instead simply advance the position, creating a sparse file channel.position(position); // Check for last CEN record - if (Arrays.equals(LAST_CEN_COMMENT_BYTES, 0, LAST_CEN_COMMENT_BYTES.length, b, off, len)) { + if (b == LAST_EXTRA_BYTES) { // From here on, write actual bytes sparse = false; } diff --git a/test/jdk/java/util/zip/ZipFile/EndOfCenValidation.java b/test/jdk/java/util/zip/ZipFile/EndOfCenValidation.java index 51ed2c28c12..7adcfb9c128 100644 --- a/test/jdk/java/util/zip/ZipFile/EndOfCenValidation.java +++ b/test/jdk/java/util/zip/ZipFile/EndOfCenValidation.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,13 +23,17 @@ /* @test * @bug 8272746 + * @modules java.base/jdk.internal.util * @summary Verify that ZipFile rejects files with CEN sizes exceeding the implementation limit - * @run testng/othervm EndOfCenValidation + * @run junit/othervm EndOfCenValidation */ -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; +import jdk.internal.util.ArraysSupport; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; import java.io.*; import java.nio.ByteBuffer; @@ -41,12 +45,13 @@ import java.nio.file.Path; import java.nio.file.StandardOpenOption; import java.util.Arrays; import java.util.EnumSet; +import java.util.HexFormat; import java.util.zip.ZipEntry; import java.util.zip.ZipException; import java.util.zip.ZipFile; import java.util.zip.ZipOutputStream; -import static org.testng.Assert.*; +import static org.junit.jupiter.api.Assertions.*; /** * This test augments {@link TestTooManyEntries}. It creates sparse ZIPs where @@ -68,7 +73,7 @@ public class EndOfCenValidation { private static final int ENDSIZ = ZipFile.ENDSIZ; // Offset of CEN size field within ENDHDR private static final int ENDOFF = ZipFile.ENDOFF; // Offset of CEN offset field within ENDHDR // Maximum allowed CEN size allowed by ZipFile - private static int MAX_CEN_SIZE = Integer.MAX_VALUE - ENDHDR - 1; + private static final int MAX_CEN_SIZE = ArraysSupport.SOFT_MAX_ARRAY_LENGTH; // Expected message when CEN size does not match file size private static final String INVALID_CEN_BAD_SIZE = "invalid END header (bad central directory size)"; @@ -76,6 +81,8 @@ public class EndOfCenValidation { private static final String INVALID_CEN_BAD_OFFSET = "invalid END header (bad central directory offset)"; // Expected message when CEN size is too large private static final String INVALID_CEN_SIZE_TOO_LARGE = "invalid END header (central directory size too large)"; + // Expected message when total entry count is too large + private static final String INVALID_BAD_ENTRY_COUNT = "invalid END header (total entries count too large)"; // A valid ZIP file, used as a template private byte[] zipBytes; @@ -84,7 +91,7 @@ public class EndOfCenValidation { * Create a valid ZIP file, used as a template * @throws IOException if an error occurs */ - @BeforeTest + @BeforeEach public void setup() throws IOException { zipBytes = templateZip(); } @@ -93,7 +100,7 @@ public class EndOfCenValidation { * Delete big files after test, in case the file system did not support sparse files. * @throws IOException if an error occurs */ - @AfterTest + @AfterEach public void cleanup() throws IOException { Files.deleteIfExists(CEN_TOO_LARGE_ZIP); Files.deleteIfExists(INVALID_CEN_SIZE); @@ -111,11 +118,11 @@ public class EndOfCenValidation { Path zip = zipWithModifiedEndRecord(size, true, 0, CEN_TOO_LARGE_ZIP); - ZipException ex = expectThrows(ZipException.class, () -> { + ZipException ex = assertThrows(ZipException.class, () -> { new ZipFile(zip.toFile()); }); - assertEquals(ex.getMessage(), INVALID_CEN_SIZE_TOO_LARGE); + assertEquals(INVALID_CEN_SIZE_TOO_LARGE, ex.getMessage()); } /** @@ -131,11 +138,11 @@ public class EndOfCenValidation { Path zip = zipWithModifiedEndRecord(size, false, 0, INVALID_CEN_SIZE); - ZipException ex = expectThrows(ZipException.class, () -> { + ZipException ex = assertThrows(ZipException.class, () -> { new ZipFile(zip.toFile()); }); - assertEquals(ex.getMessage(), INVALID_CEN_BAD_SIZE); + assertEquals(INVALID_CEN_BAD_SIZE, ex.getMessage()); } /** @@ -151,11 +158,138 @@ public class EndOfCenValidation { Path zip = zipWithModifiedEndRecord(size, true, 100, BAD_CEN_OFFSET_ZIP); - ZipException ex = expectThrows(ZipException.class, () -> { + ZipException ex = assertThrows(ZipException.class, () -> { new ZipFile(zip.toFile()); }); - assertEquals(ex.getMessage(), INVALID_CEN_BAD_OFFSET); + assertEquals(INVALID_CEN_BAD_OFFSET, ex.getMessage()); + } + + /** + * Validate that a 'Zip64 End of Central Directory' record (the END header) + * where the value of the 'total entries' field is larger than what fits + * in the CEN size is rejected. + * + * @throws IOException if an error occurs + */ + @ParameterizedTest + @ValueSource(longs = { + -1, // Negative + Long.MIN_VALUE, // Very negative + 0x3B / 3L - 1, // Cannot fit in test ZIP's CEN + MAX_CEN_SIZE / 3 + 1, // Too large to allocate int[] entries array + Long.MAX_VALUE // Unreasonably large + }) + public void shouldRejectBadTotalEntries(long totalEntries) throws IOException { + /** + * A small ZIP using the ZIP64 format. + * + * ZIP created using: "echo -n hello | zip zip64.zip -" + * Hex encoded using: "cat zip64.zip | xxd -ps" + * + * The file has the following structure: + * + * 0000 LOCAL HEADER #1 04034B50 + * 0004 Extract Zip Spec 2D '4.5' + * 0005 Extract OS 00 'MS-DOS' + * 0006 General Purpose Flag 0000 + * 0008 Compression Method 0000 'Stored' + * 000A Last Mod Time 5947AB78 'Mon Oct 7 21:27:48 2024' + * 000E CRC 363A3020 + * 0012 Compressed Length FFFFFFFF + * 0016 Uncompressed Length FFFFFFFF + * 001A Filename Length 0001 + * 001C Extra Length 0014 + * 001E Filename '-' + * 001F Extra ID #0001 0001 'ZIP64' + * 0021 Length 0010 + * 0023 Uncompressed Size 0000000000000006 + * 002B Compressed Size 0000000000000006 + * 0033 PAYLOAD hello. + * + * 0039 CENTRAL HEADER #1 02014B50 + * 003D Created Zip Spec 1E '3.0' + * 003E Created OS 03 'Unix' + * 003F Extract Zip Spec 2D '4.5' + * 0040 Extract OS 00 'MS-DOS' + * 0041 General Purpose Flag 0000 + * 0043 Compression Method 0000 'Stored' + * 0045 Last Mod Time 5947AB78 'Mon Oct 7 21:27:48 2024' + * 0049 CRC 363A3020 + * 004D Compressed Length 00000006 + * 0051 Uncompressed Length FFFFFFFF + * 0055 Filename Length 0001 + * 0057 Extra Length 000C + * 0059 Comment Length 0000 + * 005B Disk Start 0000 + * 005D Int File Attributes 0001 + * [Bit 0] 1 Text Data + * 005F Ext File Attributes 11B00000 + * 0063 Local Header Offset 00000000 + * 0067 Filename '-' + * 0068 Extra ID #0001 0001 'ZIP64' + * 006A Length 0008 + * 006C Uncompressed Size 0000000000000006 + * + * 0074 ZIP64 END CENTRAL DIR 06064B50 + * RECORD + * 0078 Size of record 000000000000002C + * 0080 Created Zip Spec 1E '3.0' + * 0081 Created OS 03 'Unix' + * 0082 Extract Zip Spec 2D '4.5' + * 0083 Extract OS 00 'MS-DOS' + * 0084 Number of this disk 00000000 + * 0088 Central Dir Disk no 00000000 + * 008C Entries in this disk 0000000000000001 + * 0094 Total Entries 0000000000000001 + * 009C Size of Central Dir 000000000000003B + * 00A4 Offset to Central dir 0000000000000039 + * + * 00AC ZIP64 END CENTRAL DIR 07064B50 + * LOCATOR + * 00B0 Central Dir Disk no 00000000 + * 00B4 Offset to Central dir 0000000000000074 + * 00BC Total no of Disks 00000001 + * + * 00C0 END CENTRAL HEADER 06054B50 + * 00C4 Number of this disk 0000 + * 00C6 Central Dir Disk no 0000 + * 00C8 Entries in this disk 0001 + * 00CA Total Entries 0001 + * 00CC Size of Central Dir 0000003B + * 00D0 Offset to Central Dir FFFFFFFF + * 00D4 Comment Length 0000 + */ + + byte[] zipBytes = HexFormat.of().parseHex(""" + 504b03042d000000000078ab475920303a36ffffffffffffffff01001400 + 2d010010000600000000000000060000000000000068656c6c6f0a504b01 + 021e032d000000000078ab475920303a3606000000ffffffff01000c0000 + 00000001000000b011000000002d010008000600000000000000504b0606 + 2c000000000000001e032d00000000000000000001000000000000000100 + 0000000000003b000000000000003900000000000000504b060700000000 + 740000000000000001000000504b050600000000010001003b000000ffff + ffff0000 + """.replaceAll("\n","")); + + // Buffer to manipulate the above ZIP + ByteBuffer buf = ByteBuffer.wrap(zipBytes).order(ByteOrder.LITTLE_ENDIAN); + // Offset of the 'total entries' in the 'ZIP64 END CENTRAL DIR' record + // Update ZIP64 entry count to a value which cannot possibly fit in the small CEN + buf.putLong(0x94, totalEntries); + // The corresponding END field needs the ZIP64 magic value + buf.putShort(0xCA, (short) 0xFFFF); + // Write the ZIP to disk + Path zipFile = Path.of("bad-entry-count.zip"); + Files.write(zipFile, zipBytes); + + // Verify that the END header is rejected + ZipException ex = assertThrows(ZipException.class, () -> { + try (var zf = new ZipFile(zipFile.toFile())) { + } + }); + + assertEquals(INVALID_BAD_ENTRY_COUNT, ex.getMessage()); } /** diff --git a/test/jdk/java/util/zip/ZipFile/ReadAfterClose.java b/test/jdk/java/util/zip/ZipFile/ReadAfterClose.java new file mode 100644 index 00000000000..a083daf7668 --- /dev/null +++ b/test/jdk/java/util/zip/ZipFile/ReadAfterClose.java @@ -0,0 +1,128 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* @test + @bug 8340684 + @summary Verify unspecified, but long-standing behavior when reading + from an input stream obtained using ZipFile::getInputStream after + the ZipFile has been closed. + @run junit ReadAfterClose + */ + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.stream.Stream; +import java.util.zip.CRC32; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; +import java.util.zip.ZipOutputStream; + +import static org.junit.jupiter.api.Assertions.assertThrows; + +public class ReadAfterClose { + + // ZIP file used in this test + private Path zip = Path.of("read-after-close.zip"); + + /** + * Create a sample ZIP file for use by this test + * @throws IOException if an unexpected IOException occurs + */ + @BeforeEach + public void setUp() throws IOException { + byte[] content = "hello".repeat(1000).getBytes(StandardCharsets.UTF_8); + try (OutputStream out = Files.newOutputStream(zip); + ZipOutputStream zo = new ZipOutputStream(out)) { + { + zo.putNextEntry(new ZipEntry("deflated.txt")); + zo.write(content); + } + { + ZipEntry entry = new ZipEntry("stored.txt"); + entry.setMethod(ZipEntry.STORED); + CRC32 crc = new CRC32(); + crc.update(content); + entry.setCrc(crc.getValue()); + entry.setSize(content.length); + zo.putNextEntry(entry); + zo.write(content); + } + } + } + + /** + * Delete the ZIP file produced by this test + * @throws IOException if an unexpected IOException occurs + */ + @AfterEach + public void cleanup() throws IOException { + Files.deleteIfExists(zip); + } + + /** + * Produce arguments with a variation of stored / deflated entries, + * and read behavior before closing the ZipFile. + * @return + */ + public static Stream arguments() { + return Stream.of( + Arguments.of("stored.txt", true), + Arguments.of("stored.txt", false), + Arguments.of("deflated.txt", true), + Arguments.of("deflated.txt", false) + ); + } + /** + * Attempting to read from an InputStream obtained by ZipFile.getInputStream + * after the backing ZipFile is closed should throw IOException + * + * @throws IOException if an unexpected IOException occurs + */ + @ParameterizedTest + @MethodSource("arguments") + public void readAfterClose(String entryName, boolean readFirst) throws IOException { + // Retain a reference to an input stream backed by a closed ZipFile + InputStream in; + try (ZipFile zf = new ZipFile(zip.toFile())) { + in = zf.getInputStream(new ZipEntry(entryName)); + // Optionally consume a single byte from the stream before closing + if (readFirst) { + in.read(); + } + } + + assertThrows(IOException.class, () -> { + in.read(); + }); + } +} \ No newline at end of file diff --git a/test/jdk/java/util/zip/ZipOutputStream/ZipOutputStreamMaxCenHdrTest.java b/test/jdk/java/util/zip/ZipOutputStream/ZipOutputStreamMaxCenHdrTest.java new file mode 100644 index 00000000000..286e043c225 --- /dev/null +++ b/test/jdk/java/util/zip/ZipOutputStream/ZipOutputStreamMaxCenHdrTest.java @@ -0,0 +1,169 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* @test + * @bug 8336025 + * @summary Verify that ZipOutputStream throws a ZipException when the + * CEN header size + name length + comment length + extra length exceeds + * 65,535 bytes + * @run junit ZipOutputStreamMaxCenHdrTest + */ +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; + +import java.io.*; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Arrays; +import java.util.zip.ZipEntry; +import java.util.zip.ZipException; +import java.util.zip.ZipFile; +import java.util.zip.ZipOutputStream; + +import static org.junit.jupiter.api.Assertions.*; + +public class ZipOutputStreamMaxCenHdrTest { + + // CEN header size + name length + comment length + extra length + // should not exceed 65,535 bytes per the PKWare APP.NOTE + // 4.4.10, 4.4.11, & 4.4.12. + static final int MAX_COMBINED_CEN_HEADER_SIZE = 0xFFFF; + + // Maximum possible size of name length + comment length + extra length + // for entries in order to not exceed 65,489 bytes minus 46 bytes for the CEN + // header length + static final int MAX_NAME_COMMENT_EXTRA_SIZE = + MAX_COMBINED_CEN_HEADER_SIZE - ZipFile.CENHDR; + + // Tag for the 'unknown' field type, specified in APPNOTE.txt 'Third party mappings' + static final short UNKNOWN_ZIP_TAG = (short) 0x9902; + + // ZIP file to be used by the tests + static final Path ZIP_FILE = Path.of("maxCENHdrTest.zip"); + + /** + * Clean up prior to test run + * + * @throws IOException if an error occurs + */ + @BeforeEach + public void startUp() throws IOException { + Files.deleteIfExists(ZIP_FILE); + } + + /** + * Validate a ZipException is thrown when the combined CEN Header, name + * length, comment length, and extra data length exceeds 65,535 bytes when + * the ZipOutputStream is closed. + */ + @ParameterizedTest + @ValueSource(ints = {MAX_COMBINED_CEN_HEADER_SIZE, + MAX_COMBINED_CEN_HEADER_SIZE - 1, + MAX_NAME_COMMENT_EXTRA_SIZE, + MAX_NAME_COMMENT_EXTRA_SIZE - 1}) + void setCommentTest(int length) throws IOException { + boolean expectZipException = length > MAX_NAME_COMMENT_EXTRA_SIZE; + final byte[] bytes = new byte[length]; + Arrays.fill(bytes, (byte) 'a'); + ZipEntry zipEntry = new ZipEntry(""); + // The comment length will trigger the ZipException + zipEntry.setComment(new String(bytes, StandardCharsets.UTF_8)); + boolean receivedException = writeZipEntry(zipEntry, expectZipException); + assertEquals(receivedException, expectZipException); + } + + /** + * Validate an ZipException is thrown when the combined CEN Header, name + * length, comment length, and extra data length exceeds 65,535 bytes when + * the ZipOutputStream is closed. + */ + @ParameterizedTest + @ValueSource(ints = {MAX_COMBINED_CEN_HEADER_SIZE, + MAX_COMBINED_CEN_HEADER_SIZE - 1, + MAX_NAME_COMMENT_EXTRA_SIZE, + MAX_NAME_COMMENT_EXTRA_SIZE - 1}) + void setNameTest(int length) throws IOException { + boolean expectZipException = length > MAX_NAME_COMMENT_EXTRA_SIZE; + final byte[] bytes = new byte[length]; + Arrays.fill(bytes, (byte) 'a'); + // The name length will trigger the ZipException + ZipEntry zipEntry = new ZipEntry(new String(bytes, StandardCharsets.UTF_8)); + boolean receivedException = writeZipEntry(zipEntry, expectZipException); + assertEquals(receivedException, expectZipException); + } + + /** + * Validate an ZipException is thrown when the combined CEN Header, name + * length, comment length, and extra data length exceeds 65,535 bytes when + * the ZipOutputStream is closed. + */ + @ParameterizedTest + @ValueSource(ints = {MAX_COMBINED_CEN_HEADER_SIZE, + MAX_COMBINED_CEN_HEADER_SIZE - 1, + MAX_NAME_COMMENT_EXTRA_SIZE, + MAX_NAME_COMMENT_EXTRA_SIZE - 1}) + void setExtraTest(int length) throws IOException { + boolean expectZipException = length > MAX_NAME_COMMENT_EXTRA_SIZE; + final byte[] bytes = new byte[length]; + // Little-endian ByteBuffer for updating the header fields + ByteBuffer buffer = ByteBuffer.wrap(bytes).order(ByteOrder.LITTLE_ENDIAN); + // We use the 'unknown' tag, specified in APPNOTE.TXT, 4.6.1 Third party mappings' + buffer.putShort(UNKNOWN_ZIP_TAG); + // Size of the actual (empty) data + buffer.putShort((short) (length - 2 * Short.BYTES)); + ZipEntry zipEntry = new ZipEntry(""); + // The extra data length will trigger the ZipException + zipEntry.setExtra(bytes); + boolean receivedException = writeZipEntry(zipEntry, expectZipException); + assertEquals(receivedException, expectZipException); + } + + /** + * Write a single Zip entry using ZipOutputStream + * @param zipEntry the ZipEntry to write + * @param expectZipException true if a ZipException is expected, false otherwse + * @return true if a ZipException was thrown + * @throws IOException if an error occurs + */ + private static boolean writeZipEntry(ZipEntry zipEntry, boolean expectZipException) + throws IOException { + boolean receivedException = false; + try (ZipOutputStream zos = new ZipOutputStream( + new BufferedOutputStream(Files.newOutputStream(ZIP_FILE)))) { + zos.putNextEntry(zipEntry); + if (expectZipException) { + ZipException ex = assertThrows(ZipException.class, zos::close); + assertTrue(ex.getMessage().matches(".*bad header size.*"), + "Unexpected ZipException message: " + ex.getMessage()); + receivedException = true; + } + } catch (Exception e) { + throw new RuntimeException("Received Unexpected Exception", e); + } + return receivedException; + } +} diff --git a/test/jdk/javax/management/ObjectName/SerialCompatRemovedTest.java b/test/jdk/javax/management/ObjectName/SerialCompatRemovedTest.java new file mode 100644 index 00000000000..3a63e593472 --- /dev/null +++ b/test/jdk/javax/management/ObjectName/SerialCompatRemovedTest.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8334165 + * @summary Test that jmx.serial.form is not recognised. + * + * @run main/othervm -Djmx.serial.form=1.0 SerialCompatRemovedTest + * @run main/othervm SerialCompatRemovedTest + */ + +import java.io.*; +import java.util.*; +import javax.management.ObjectName; + +public class SerialCompatRemovedTest { + + public static void main(String[] args) throws Exception { + ObjectStreamClass osc = ObjectStreamClass.lookup(ObjectName.class); + // Serial form has no fields, uses writeObject, so we should never see + // non-zero field count here: + if (osc.getFields().length != 0) { + throw new Exception("ObjectName using old serial form?: fields: " + + Arrays.asList(osc.getFields())); + } + } +} + diff --git a/test/jdk/javax/management/ObjectName/SerialCompatTest.java b/test/jdk/javax/management/ObjectName/SerialCompatTest.java deleted file mode 100644 index 14b8720987b..00000000000 --- a/test/jdk/javax/management/ObjectName/SerialCompatTest.java +++ /dev/null @@ -1,263 +0,0 @@ -/* - * Copyright (c) 2004, 2015, 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. - */ - -/* - * @test - * @bug 6211220 6616825 - * @summary Test that jmx.serial.form=1.0 works for ObjectName - * @author Eamonn McManus, Daniel Fuchs - * - * @run clean SerialCompatTest - * @run build SerialCompatTest - * @run main/othervm -Djdk.jmx.mbeans.allowNonPublic=true -Djmx.serial.form=1.0 SerialCompatTest - */ - -import java.io.*; -import java.util.*; -import javax.management.ObjectName; - -public class SerialCompatTest { - - public static void check6211220() throws Exception { - - ObjectName on = new ObjectName("a:b=c"); - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - ObjectOutputStream oos = new ObjectOutputStream(bos); - oos.writeObject(on); - oos.close(); - byte[] bytes = bos.toByteArray(); - ByteArrayInputStream bis = new ByteArrayInputStream(bytes); - ObjectInputStream ois = new ObjectInputStream(bis); - ObjectName on1 = (ObjectName) ois.readObject(); - - // if the bug is present, these will get NullPointerException - for (int i = 0; i <= 11; i++) { - String msg = "6211220 case(" + i + ")"; - try { - switch (i) { - case 0: - check(msg, on1.getDomain().equals("a")); - break; - case 1: - check(msg, on1.getCanonicalName().equals("a:b=c")); - break; - case 2: - check(msg, on1.getKeyPropertyListString() - .equals("b=c")); - break; - case 3: - check(msg, on1.getCanonicalKeyPropertyListString() - .equals("b=c")); - break; - case 4: - check(msg, on1.getKeyProperty("b").equals("c")); - break; - case 5: - check(msg, on1.getKeyPropertyList() - .equals(Collections.singletonMap("b", "c"))); - break; - case 6: - check(msg, !on1.isDomainPattern()); - break; - case 7: - check(msg, !on1.isPattern()); - break; - case 8: - check(msg, !on1.isPropertyPattern()); - break; - case 9: - check(msg, on1.equals(on)); - break; - case 10: - check(msg, on.equals(on1)); - break; - case 11: - check(msg, on1.apply(on)); - break; - default: - throw new Exception(msg + ": Test incorrect"); - } - } catch (Exception e) { - System.out.println(msg + ": Test failed with exception:"); - e.printStackTrace(System.out); - failed = true; - } - } - - if (failed) { - throw new Exception("Some tests for 6211220 failed"); - } else { - System.out.println("All tests for 6211220 passed"); - } - } - - static void checkName(String testname, ObjectName on) - throws Exception { - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - ObjectOutputStream oos = new ObjectOutputStream(bos); - oos.writeObject(on); - oos.close(); - byte[] bytes = bos.toByteArray(); - ByteArrayInputStream bis = new ByteArrayInputStream(bytes); - ObjectInputStream ois = new ObjectInputStream(bis); - ObjectName on1 = (ObjectName) ois.readObject(); - // if the bug is present, these will get NullPointerException - for (int i = 0; i <= 11; i++) { - String msg = testname + " case(" + i + ")"; - try { - switch (i) { - case 0: - check(msg, on1.getDomain().equals(on.getDomain())); - break; - case 1: - check(msg, on1.getCanonicalName(). - equals(on.getCanonicalName())); - break; - case 2: - check(msg, on1.getKeyPropertyListString(). - equals(on.getKeyPropertyListString())); - break; - case 3: - check(msg, on1.getCanonicalKeyPropertyListString(). - equals(on.getCanonicalKeyPropertyListString())); - break; - case 4: - for (Object ko : on1.getKeyPropertyList().keySet()) { - final String key = (String) ko; - check(msg, on1.getKeyProperty(key). - equals(on.getKeyProperty(key))); - } - for (Object ko : on.getKeyPropertyList().keySet()) { - final String key = (String) ko; - check(msg, on1.getKeyProperty(key). - equals(on.getKeyProperty(key))); - } - case 5: - check(msg, on1.getKeyPropertyList() - .equals(on.getKeyPropertyList())); - break; - case 6: - check(msg, on1.isDomainPattern()==on.isDomainPattern()); - break; - case 7: - check(msg, on1.isPattern() == on.isPattern()); - break; - case 8: - check(msg, - on1.isPropertyPattern()==on.isPropertyPattern()); - break; - case 9: - check(msg, on1.equals(on)); - break; - case 10: - check(msg, on.equals(on1)); - break; - case 11: - if (!on.isPattern()) { - check(msg, on1.apply(on)); - } - break; - default: - throw new Exception("Test incorrect: case: " + i); - } - } catch (Exception e) { - System.out.println("Test (" + i + ") failed with exception:"); - e.printStackTrace(System.out); - failed = true; - } - } - - } - private static String[] names6616825 = { - "a:b=c", "a:b=c,*", "*:*", ":*", ":b=c", ":b=c,*", - "a:*,b=c", ":*", ":*,b=c", "*x?:k=\"x\\*z\"", "*x?:k=\"x\\*z\",*", - "*x?:*,k=\"x\\*z\"", "*x?:k=\"x\\*z\",*,b=c" - }; - - static void check6616825() throws Exception { - System.out.println("Testing 616825"); - for (String n : names6616825) { - final ObjectName on; - try { - on = new ObjectName(n); - } catch (Exception x) { - failed = true; - System.out.println("Unexpected failure for 6616825 [" + n + - "]: " + x); - x.printStackTrace(System.out); - continue; - } - try { - checkName("616825 " + n, on); - } catch (Exception x) { - failed = true; - System.out.println("6616825 failed for [" + n + "]: " + x); - x.printStackTrace(System.out); - } - } - - if (failed) { - throw new Exception("Some tests for 6616825 failed"); - } else { - System.out.println("All tests for 6616825 passed"); - } - } - - public static void main(String[] args) throws Exception { - /* Check that we really are in jmx.serial.form=1.0 mode. - The property is frozen the first time the ObjectName class - is referenced so checking that it is set to the correct - value now is not enough. */ - ObjectStreamClass osc = ObjectStreamClass.lookup(ObjectName.class); - if (osc.getFields().length != 6) { - throw new Exception("Not using old serial form: fields: " + - Arrays.asList(osc.getFields())); - // new serial form has no fields, uses writeObject - } - - try { - check6211220(); - } catch (Exception x) { - System.err.println(x.getMessage()); - } - try { - check6616825(); - } catch (Exception x) { - System.err.println(x.getMessage()); - } - - if (failed) { - throw new Exception("Some tests failed"); - } else { - System.out.println("All tests passed"); - } - } - - private static void check(String msg, boolean condition) { - if (!condition) { - new Throwable("Test failed " + msg).printStackTrace(System.out); - failed = true; - } - } - private static boolean failed; -} diff --git a/test/jdk/javax/net/ssl/DTLS/TEST.properties b/test/jdk/javax/net/ssl/DTLS/TEST.properties index ceb6c8c9c42..a50cba09c0f 100644 --- a/test/jdk/javax/net/ssl/DTLS/TEST.properties +++ b/test/jdk/javax/net/ssl/DTLS/TEST.properties @@ -6,3 +6,4 @@ modules = \ java.security.jgss/sun.security.krb5.internal:+open \ java.security.jgss/sun.security.krb5.internal.ktab \ java.base/sun.security.util +maxOutputSize = 2500000 diff --git a/test/jdk/javax/print/PostScriptRotatedScaledFontTest.java b/test/jdk/javax/print/PostScriptRotatedScaledFontTest.java new file mode 100644 index 00000000000..e6e274f7cac --- /dev/null +++ b/test/jdk/javax/print/PostScriptRotatedScaledFontTest.java @@ -0,0 +1,211 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Font; +import java.awt.Graphics; +import java.awt.geom.AffineTransform; +import java.awt.geom.Rectangle2D; +import java.awt.print.PageFormat; +import java.awt.print.Printable; +import java.awt.print.PrinterException; +import java.io.ByteArrayOutputStream; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.List; + +import javax.print.Doc; +import javax.print.DocFlavor; +import javax.print.DocPrintJob; +import javax.print.SimpleDoc; +import javax.print.StreamPrintService; +import javax.print.StreamPrintServiceFactory; +import javax.print.event.PrintJobAdapter; +import javax.print.event.PrintJobEvent; + +/* + * @test + * @bug 8339974 + * @summary Verifies that text prints correctly using scaled and rotated fonts. + */ +public class PostScriptRotatedScaledFontTest { + + public static void main(String[] args) throws Exception { + test(0); + test(1); + test(2); + test(3); + test(4); + } + + private static void test(int quadrants) throws Exception { + + DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE; + String mime = "application/postscript"; + StreamPrintServiceFactory[] factories = StreamPrintServiceFactory.lookupStreamPrintServiceFactories(flavor, mime); + if (factories.length == 0) { + throw new RuntimeException("Unable to find PostScript print service factory"); + } + + StreamPrintServiceFactory factory = factories[0]; + + // required to trigger "text-as-shapes" code path in + // PSPathGraphics.drawString(String, float, float, Font, FontRenderContext, float) + // for *all* text, not just text that uses a transformed font + String shapeText = "sun.java2d.print.shapetext"; + System.setProperty(shapeText, "true"); + + try { + for (int scale = 1; scale <= 100; scale++) { + + ByteArrayOutputStream output = new ByteArrayOutputStream(); + StreamPrintService service = factory.getPrintService(output); + DocPrintJob job = service.createPrintJob(); + + PrintJobMonitor monitor = new PrintJobMonitor(); + job.addPrintJobListener(monitor); + + Printable printable = new TestPrintable(scale, quadrants); + Doc doc = new SimpleDoc(printable, flavor, null); + job.print(doc, null); + monitor.waitForJobToFinish(); + + byte[] ps = output.toByteArray(); + Rectangle2D.Double bounds = findTextBoundingBox(ps); + if (bounds == null) { + throw new RuntimeException("Text missing: scale=" + scale + + ", quadrants=" + quadrants); + } + + boolean horizontal = (bounds.width > bounds.height); + boolean expectedHorizontal = (quadrants % 2 == 0); + if (horizontal != expectedHorizontal) { + throw new RuntimeException("Wrong orientation: scale=" + scale + + ", quadrants=" + quadrants + ", bounds=" + bounds + + ", expectedHorizontal=" + expectedHorizontal + + ", horizontal=" + horizontal); + } + } + } finally { + System.clearProperty(shapeText); + } + } + + // very basic, uses moveto ("x y M"), lineto ("x y L"), and curveto ("x1 y1 x2 y2 x3 y3 C") + private static Rectangle2D.Double findTextBoundingBox(byte[] ps) { + double minX = Double.MAX_VALUE; + double minY = Double.MAX_VALUE; + double maxX = Double.MIN_VALUE; + double maxY = Double.MIN_VALUE; + boolean pastPageClip = false; + List< String > lines = new String(ps, StandardCharsets.ISO_8859_1).lines().toList(); + for (String line : lines) { + if (!pastPageClip) { + pastPageClip = "WC".equals(line); + continue; + } + String[] values = line.split(" "); + if (values.length == 3 || values.length == 7) { + String cmd = values[values.length - 1]; + if ("M".equals(cmd) || "L".equals(cmd) || "C".equals(cmd)) { + String sx = values[values.length - 3]; + String sy = values[values.length - 2]; + double x = Double.parseDouble(sx); + double y = Double.parseDouble(sy); + if (x < minX) { + minX = x; + } + if (y < minY) { + minY = y; + } + if (x > maxX) { + maxX = x; + } + if (y > maxY) { + maxY = y; + } + } + } + } + if (minX != Double.MAX_VALUE) { + return new Rectangle2D.Double(minX, minY, maxX - minX, maxY - minY); + } else { + return null; + } + } + + private static final class TestPrintable implements Printable { + private final int scale; + private final int quadrants; + public TestPrintable(int scale, int quadrants) { + this.scale = scale; + this.quadrants = quadrants; + } + @Override + public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException { + if (pageIndex > 0) { + return NO_SUCH_PAGE; + } + AffineTransform at = AffineTransform.getQuadrantRotateInstance(quadrants); + at.scale(scale, scale); + Font base = new Font("SansSerif", Font.PLAIN, 10); + Font font = base.deriveFont(at); + graphics.setFont(font); + graphics.drawString("TEST", 300, 300); + return PAGE_EXISTS; + } + } + + private static class PrintJobMonitor extends PrintJobAdapter { + private boolean finished; + @Override + public void printJobCanceled(PrintJobEvent pje) { + finished(); + } + @Override + public void printJobCompleted(PrintJobEvent pje) { + finished(); + } + @Override + public void printJobFailed(PrintJobEvent pje) { + finished(); + } + @Override + public void printJobNoMoreEvents(PrintJobEvent pje) { + finished(); + } + private synchronized void finished() { + finished = true; + notify(); + } + public synchronized void waitForJobToFinish() { + try { + while (!finished) { + wait(); + } + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + } + } +} diff --git a/test/jdk/javax/print/PrintServiceLookup/FlushCustomClassLoader.java b/test/jdk/javax/print/PrintServiceLookup/FlushCustomClassLoader.java index 4ec95fb7535..c16fe0e5a82 100644 --- a/test/jdk/javax/print/PrintServiceLookup/FlushCustomClassLoader.java +++ b/test/jdk/javax/print/PrintServiceLookup/FlushCustomClassLoader.java @@ -36,7 +36,7 @@ import javax.print.PrintServiceLookup; * @summary Tests custom class loader cleanup * @library /javax/swing/regtesthelpers * @build Util - * @run main/timeout=60/othervm -mx32m FlushCustomClassLoader + * @run main/timeout=60/othervm -Xmx32m FlushCustomClassLoader */ public final class FlushCustomClassLoader { diff --git a/test/jdk/javax/sound/sampled/Clip/AudioContentHandlers.java b/test/jdk/javax/sound/sampled/Clip/AudioContentHandlers.java index c287ee061db..cb0875a5320 100644 --- a/test/jdk/javax/sound/sampled/Clip/AudioContentHandlers.java +++ b/test/jdk/javax/sound/sampled/Clip/AudioContentHandlers.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,7 +46,7 @@ import static javax.sound.sampled.AudioFileFormat.Type.WAVE; * @test * @bug 8204454 * @summary URL.getContent() should return AudioClip for supported formats - * @run main/othervm -mx128m AudioContentHandlers + * @run main/othervm -Xmx128m AudioContentHandlers */ public final class AudioContentHandlers { diff --git a/test/jdk/javax/swing/JButton/SwingButtonResizeTestWithOpenGL.java b/test/jdk/javax/swing/JButton/SwingButtonResizeTestWithOpenGL.java index 96ef9edc571..5b21c07f71e 100644 --- a/test/jdk/javax/swing/JButton/SwingButtonResizeTestWithOpenGL.java +++ b/test/jdk/javax/swing/JButton/SwingButtonResizeTestWithOpenGL.java @@ -99,6 +99,7 @@ public class SwingButtonResizeTestWithOpenGL { frame.setLocation(200, 200); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); button.setPreferredSize(new Dimension(300, 300)); + button.setFocusPainted(false); button.addFocusListener(new FocusAdapter() { public void focusGained(FocusEvent fe) { focusGainedLatch.countDown(); @@ -124,9 +125,8 @@ public class SwingButtonResizeTestWithOpenGL { try { robot = new Robot(); - robot.setAutoWaitForIdle(true); - robot.setAutoDelay(200); - + robot.waitForIdle(); + robot.delay(1000); if (focusGainedLatch.await(3, TimeUnit.SECONDS)) { System.out.println("Button focus gained..."); } else { @@ -142,17 +142,18 @@ public class SwingButtonResizeTestWithOpenGL { // some platforms may not support maximize frame if (frame.getToolkit().isFrameStateSupported( JFrame.MAXIMIZED_BOTH)) { - robot.waitForIdle(); // maximize frame from normal size frame.setExtendedState(JFrame.MAXIMIZED_BOTH); System.out.println("Frame is maximized"); robot.waitForIdle(); + robot.delay(100); if (frame.getToolkit().isFrameStateSupported(JFrame.NORMAL)) { System.out.println("Frame is back to normal"); // resize from maximum size to normal frame.setExtendedState(JFrame.NORMAL); - + robot.waitForIdle(); + robot.delay(100); // capture image of JButton after resize System.out.println( "Getting image of JButton after resize..image2"); @@ -209,9 +210,8 @@ public class SwingButtonResizeTestWithOpenGL { } private void disposeFrame() { - if (frame != null) { + if(frame != null) { frame.dispose(); - frame = null; } } diff --git a/test/jdk/javax/swing/JColorChooser/Test4887836.java b/test/jdk/javax/swing/JColorChooser/Test4887836.java index 4043dbdd88a..82a09c46085 100644 --- a/test/jdk/javax/swing/JColorChooser/Test4887836.java +++ b/test/jdk/javax/swing/JColorChooser/Test4887836.java @@ -26,10 +26,12 @@ import java.awt.Font; import javax.swing.JColorChooser; import javax.swing.UIManager; +import jtreg.SkippedException; + /* * @test * @bug 4887836 - * @library /java/awt/regtesthelpers + * @library /java/awt/regtesthelpers /test/lib * @build PassFailJFrame * @summary Checks for white area under the JColorChooser Swatch tab * @run main/manual Test4887836 @@ -38,6 +40,13 @@ import javax.swing.UIManager; public class Test4887836 { public static void main(String[] args) throws Exception { + + // ColorChooser UI design is different for GTK L&F. + // There is no Swatches tab available for GTK L&F, skip the testing. + if (UIManager.getLookAndFeel().getName().contains("GTK")) { + throw new SkippedException("Test not applicable for GTK L&F"); + } + String instructions = """ If you do not see white area under the \"Swatches\" tab, then test passed, otherwise it failed."""; @@ -45,9 +54,7 @@ public class Test4887836 { PassFailJFrame.builder() .title("Test4759306") .instructions(instructions) - .rows(5) .columns(40) - .testTimeOut(10) .testUI(Test4887836::createColorChooser) .build() .awaitAndCheck(); diff --git a/test/jdk/javax/swing/JFileChooser/6396844/TwentyThousandTest.java b/test/jdk/javax/swing/JFileChooser/6396844/TwentyThousandTest.java index afc2fc41bc4..757d21278b1 100644 --- a/test/jdk/javax/swing/JFileChooser/6396844/TwentyThousandTest.java +++ b/test/jdk/javax/swing/JFileChooser/6396844/TwentyThousandTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,7 +30,7 @@ * @library ../../regtesthelpers * @modules java.desktop/sun.java2d * @build Util - * @run main/othervm/timeout=1000 -mx128m TwentyThousandTest + * @run main/othervm/timeout=1000 -Xmx128m TwentyThousandTest */ import sun.java2d.Disposer; diff --git a/test/jdk/javax/swing/JFileChooser/bug4587721.java b/test/jdk/javax/swing/JFileChooser/bug4587721.java new file mode 100644 index 00000000000..408f4e47f49 --- /dev/null +++ b/test/jdk/javax/swing/JFileChooser/bug4587721.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4587721 + * @summary Tests if JFileChooser details view chops off text + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4587721 + */ + +import java.awt.Font; +import java.util.Enumeration; + +import javax.swing.JFileChooser; +import javax.swing.UIDefaults; +import javax.swing.UIManager; +import javax.swing.plaf.FontUIResource; +import javax.swing.plaf.metal.MetalLookAndFeel; + +public class bug4587721 { + + public static void main(String[] args) throws Exception { + UIManager.setLookAndFeel(new MetalLookAndFeel()); + + String instructions = """ + Click on the Details button in JFileChooser Window. + If the filename text is chopped off by height, + then Press FAIL else Press PASS. + """; + + PassFailJFrame.builder() + .title("bug4587721") + .instructions(instructions) + .columns(40) + .testUI(bug4587721::createUI) + .build() + .awaitAndCheck(); + } + + public static JFileChooser createUI() { + setFonts(); + JFileChooser fc = new JFileChooser(); + return fc; + } + + public static void setFonts() { + UIDefaults defaults = UIManager.getDefaults(); + Enumeration keys = defaults.keys(); + while (keys.hasMoreElements()) { + Object key = keys.nextElement(); + if (defaults.get(key) instanceof Font) + UIManager.put(key, new FontUIResource(new Font("Courier", Font.BOLD, 30))); + } + } +} diff --git a/test/jdk/javax/swing/JOptionPane/6464022/bug6464022.java b/test/jdk/javax/swing/JOptionPane/6464022/bug6464022.java index 8b3a8a07531..152bc7eecbf 100644 --- a/test/jdk/javax/swing/JOptionPane/6464022/bug6464022.java +++ b/test/jdk/javax/swing/JOptionPane/6464022/bug6464022.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,7 +29,7 @@ * @author Pavel Porvatov * @library ../../regtesthelpers * @build Util - * @run main/othervm -mx128m bug6464022 + * @run main/othervm -Xmx128m bug6464022 */ import javax.swing.*; diff --git a/test/jdk/javax/swing/JTabbedPane/8007563/Test8007563.java b/test/jdk/javax/swing/JTabbedPane/8007563/Test8007563.java deleted file mode 100644 index 25d3ad41eca..00000000000 --- a/test/jdk/javax/swing/JTabbedPane/8007563/Test8007563.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright (c) 2015, 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 java.awt.*; -import java.util.ArrayList; -import java.util.concurrent.CountDownLatch; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JTabbedPane; - -import static javax.swing.UIManager.*; -import static javax.swing.SwingUtilities.*; - -/* - * @test - * @key headful - * @bug 8007563 - * @summary Tests JTabbedPane background - * @author Sergey Malenkov - */ - -public class Test8007563 implements Runnable { - private static final ArrayList LIST = new ArrayList<>(); - private static final LookAndFeelInfo[] INFO = getInstalledLookAndFeels(); - private static final CountDownLatch LATCH = new CountDownLatch(INFO.length); - private static Robot ROBOT; - - public static void main(String[] args) throws Exception { - ROBOT = new Robot(); - invokeLater(new Test8007563()); - LATCH.await(); - if (!LIST.isEmpty()) { - throw new Error(LIST.toString()); - } - } - - private static void addOpaqueError(boolean opaque) { - LIST.add(getLookAndFeel().getName() + " opaque=" + opaque); - } - - private static boolean updateLookAndFeel() { - int index = (int) LATCH.getCount() - 1; - if (index >= 0) { - try { - LookAndFeelInfo info = INFO[index]; - System.err.println("L&F: " + info.getName()); - setLookAndFeel(info.getClassName()); - return true; - } catch (Exception exception) { - exception.printStackTrace(); - } - } - return false; - } - - private JFrame frame; - private JTabbedPane pane; - - public void run() { - if (this.frame == null) { - if (!updateLookAndFeel()) { - return; - } - this.pane = new JTabbedPane(); - this.pane.setOpaque(false); - this.pane.setBackground(Color.RED); - for (int i = 0; i < 3; i++) { - this.pane.addTab("Tab " + i, new JLabel("Content area " + i)); - } - this.frame = new JFrame(getClass().getSimpleName()); - this.frame.getContentPane().setBackground(Color.BLUE); - this.frame.add(this.pane); - this.frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); - this.frame.setSize(400, 200); - this.frame.setLocationRelativeTo(null); - this.frame.setVisible(true); - } else { - Point point = new Point(this.pane.getWidth() - 2, 2); - convertPointToScreen(point, this.pane); - Color actual = ROBOT.getPixelColor(point.x, point.y); - - boolean opaque = this.pane.isOpaque(); - Color expected = opaque - ? this.pane.getBackground() - : this.frame.getContentPane().getBackground(); - - if (!expected.equals(actual)){ - addOpaqueError(opaque); - } - if (!opaque) { - this.pane.setOpaque(true); - this.pane.repaint(); - } else { - this.frame.dispose(); - this.frame = null; - this.pane = null; - LATCH.countDown(); - } - - } - SecondaryLoop secondaryLoop = - Toolkit.getDefaultToolkit().getSystemEventQueue() - .createSecondaryLoop(); - new Thread() { - @Override - public void run() { - try { - Thread.sleep(200); - } catch (InterruptedException e) { - } - secondaryLoop.exit(); - invokeLater(Test8007563.this); - } - }.start(); - secondaryLoop.enter(); - } -} diff --git a/test/jdk/javax/swing/JTabbedPane/TestJTabbedPaneBackgroundColor.java b/test/jdk/javax/swing/JTabbedPane/TestJTabbedPaneBackgroundColor.java new file mode 100644 index 00000000000..d4bed5ac2da --- /dev/null +++ b/test/jdk/javax/swing/JTabbedPane/TestJTabbedPaneBackgroundColor.java @@ -0,0 +1,137 @@ +/* + * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Point; +import java.awt.Robot; +import java.util.ArrayList; + +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JTabbedPane; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; +import javax.swing.UnsupportedLookAndFeelException; + +/* + * @test + * @key headful + * @bug 8007563 + * @summary Tests JTabbedPane background + */ + +public class TestJTabbedPaneBackgroundColor { + private static ArrayList lafList = new ArrayList<>(); + private static JFrame frame; + private static JTabbedPane pane; + private static Robot robot; + private static volatile Dimension dim; + private static volatile Point loc; + + public static void main(String[] args) throws Exception { + robot = new Robot(); + + for (UIManager.LookAndFeelInfo laf : + UIManager.getInstalledLookAndFeels()) { + System.out.println("Testing: " + laf.getName()); + setLookAndFeel(laf); + + try { + SwingUtilities.invokeAndWait(TestJTabbedPaneBackgroundColor::createAndShowUI); + robot.waitForIdle(); + robot.delay(500); + + SwingUtilities.invokeAndWait(() -> { + loc = pane.getLocationOnScreen(); + dim = pane.getSize(); + }); + + loc = new Point(loc.x + dim.width - 2, loc.y + 2); + doTesting(loc, laf); + + if (!pane.isOpaque()) { + pane.setOpaque(true); + pane.repaint(); + } + robot.waitForIdle(); + robot.delay(500); + + doTesting(loc, laf); + + } finally { + SwingUtilities.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } + if (!lafList.isEmpty()) { + throw new RuntimeException(lafList.toString()); + } + } + + private static void setLookAndFeel(UIManager.LookAndFeelInfo laf) { + try { + UIManager.setLookAndFeel(laf.getClassName()); + } catch (UnsupportedLookAndFeelException ignored) { + System.out.println("Unsupported LAF: " + laf.getClassName()); + } catch (ClassNotFoundException | InstantiationException + | IllegalAccessException e) { + throw new RuntimeException(e); + } + } + + private static void createAndShowUI() { + pane = new JTabbedPane(); + pane.setOpaque(false); + pane.setBackground(Color.RED); + for (int i = 0; i < 3; i++) { + pane.addTab("Tab " + i, new JLabel("Content area " + i)); + } + frame = new JFrame("Test Background Color"); + frame.getContentPane().setBackground(Color.BLUE); + frame.add(pane); + frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + frame.setSize(400, 200); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } + + private static void doTesting(Point p, UIManager.LookAndFeelInfo laf) { + boolean isOpaque = pane.isOpaque(); + Color actual = robot.getPixelColor(p.x, p.y); + Color expected = isOpaque + ? pane.getBackground() + : frame.getContentPane().getBackground(); + + if (!expected.equals(actual)) { + addOpaqueError(laf.getName(), isOpaque); + } + } + + private static void addOpaqueError(String lafName, boolean opaque) { + lafList.add(lafName + " opaque=" + opaque); + } +} diff --git a/test/jdk/javax/swing/ProgressMonitor/ProgressMonitorEscapeKeyPress.java b/test/jdk/javax/swing/ProgressMonitor/ProgressMonitorEscapeKeyPress.java index 4ea1f48ae7a..77fac43d262 100644 --- a/test/jdk/javax/swing/ProgressMonitor/ProgressMonitorEscapeKeyPress.java +++ b/test/jdk/javax/swing/ProgressMonitor/ProgressMonitorEscapeKeyPress.java @@ -29,66 +29,64 @@ * @run main ProgressMonitorEscapeKeyPress */ -import java.awt.AWTException; -import java.awt.EventQueue; -import java.awt.Robot; -import java.awt.event.KeyEvent; + import javax.swing.JFrame; import javax.swing.ProgressMonitor; import javax.swing.SwingUtilities; +import java.awt.Robot; +import java.awt.event.KeyEvent; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; public class ProgressMonitorEscapeKeyPress { + static volatile int counter = 0; static ProgressMonitor monitor; - static int counter = 0; - static TestThread robotThread; + static TestThread testThread; static JFrame frame; + static CountDownLatch progressLatch; + static Robot robot; public static void main(String[] args) throws Exception { - - createTestUI(); - - monitor = new ProgressMonitor(frame, "Progress", null, 0, 100); - - robotThread = new TestThread(); - robotThread.start(); - - for (counter = 0; counter <= 100; counter += 10) { - Thread.sleep(1000); - - EventQueue.invokeAndWait(new Runnable() { - @Override - public void run() { - if (!monitor.isCanceled()) { - monitor.setProgress(counter); - System.out.println("Progress bar is in progress"); - } - } - }); - - if (monitor.isCanceled()) { - break; + try { + progressLatch = new CountDownLatch(20); + createTestUI(); + robot = new Robot(); + robot.setAutoDelay(50); + robot.setAutoWaitForIdle(true); + testThread = new TestThread(); + testThread.start(); + Thread.sleep(100); + if (progressLatch.await(15, TimeUnit.SECONDS)) { + System.out.println("Progress monitor completed 20%, lets press Esc..."); + robot.keyPress(KeyEvent.VK_ESCAPE); + robot.keyRelease(KeyEvent.VK_ESCAPE); + System.out.println("ESC pressed...."); + } else { + System.out.println("Failure : No status available from Progress monitor..."); + throw new RuntimeException( + "Can't get the status from Progress monitor even after waiting too long.."); } - } - disposeTestUI(); - - if (counter >= monitor.getMaximum()) { - throw new RuntimeException("Escape key did not cancel the ProgressMonitor"); + if (counter >= monitor.getMaximum()) { + throw new RuntimeException("Escape key did not cancel the ProgressMonitor"); + } + System.out.println("Test Passed..."); + } finally { + disposeTestUI(); } } - private static void createTestUI() throws Exception { - SwingUtilities.invokeAndWait(new Runnable() { - @Override - public void run() { - frame = new JFrame("Test"); - frame.setSize(300, 300); - frame.setLocationByPlatform(true); - frame.setVisible(true); - }}); - } + private static void createTestUI() throws Exception { + SwingUtilities.invokeAndWait(() -> { + frame = new JFrame("Test"); + frame.setSize(300, 300); + monitor = new ProgressMonitor(frame, "Progress", "1", 0, 100); + frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + frame.setLocationByPlatform(true); + }); + } private static void disposeTestUI() throws Exception { @@ -100,26 +98,25 @@ public class ProgressMonitorEscapeKeyPress { class TestThread extends Thread { - - Robot testRobot; - - TestThread() throws AWTException { - super(); - testRobot = new Robot(); - } - @Override public void run() { - try { - // Sleep for 5 seconds - so that the ProgressMonitor starts - Thread.sleep(5000); - - // Press and release Escape key - testRobot.keyPress(KeyEvent.VK_ESCAPE); - testRobot.delay(20); - testRobot.keyRelease(KeyEvent.VK_ESCAPE); - } catch (InterruptedException ex) { - throw new RuntimeException("Exception in TestThread"); + System.out.println("TestThread started........."); + for (ProgressMonitorEscapeKeyPress.counter = 0; + ProgressMonitorEscapeKeyPress.counter <= 100; + ProgressMonitorEscapeKeyPress.counter += 1) { + ProgressMonitorEscapeKeyPress.robot.delay(100); + ProgressMonitor monitor = ProgressMonitorEscapeKeyPress.monitor; + if (!monitor.isCanceled()) { + monitor.setNote("" + ProgressMonitorEscapeKeyPress.counter); + monitor.setProgress(ProgressMonitorEscapeKeyPress.counter); + ProgressMonitorEscapeKeyPress.progressLatch.countDown(); + System.out.println("Progress bar is in progress....." + + ProgressMonitorEscapeKeyPress.counter + "%"); + } + if (monitor.isCanceled()) { + System.out.println("$$$$$$$$$$$$$$$ Monitor canceled"); + break; + } } } } diff --git a/test/jdk/javax/swing/UI/UnninstallUIMemoryLeaks/UnninstallUIMemoryLeaks.java b/test/jdk/javax/swing/UI/UnninstallUIMemoryLeaks/UnninstallUIMemoryLeaks.java index c3bb610bb87..d6cd1fddaa6 100644 --- a/test/jdk/javax/swing/UI/UnninstallUIMemoryLeaks/UnninstallUIMemoryLeaks.java +++ b/test/jdk/javax/swing/UI/UnninstallUIMemoryLeaks/UnninstallUIMemoryLeaks.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -225,7 +225,7 @@ public final class UnninstallUIMemoryLeaks { private static Process runProcess(LookAndFeelInfo laf) throws Exception { ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( - "-Dswing.defaultlaf=" + laf.getClassName(), "-mx9m", + "-Dswing.defaultlaf=" + laf.getClassName(), "-Xmx9m", "-XX:+HeapDumpOnOutOfMemoryError", UnninstallUIMemoryLeaks.class.getSimpleName(), "mark"); return ProcessTools.startProcess(laf.getName(), pb); diff --git a/test/jdk/javax/swing/UIDefaults/6795356/bug6795356.java b/test/jdk/javax/swing/UIDefaults/6795356/bug6795356.java index 7be773a2c63..7ff527cc19d 100644 --- a/test/jdk/javax/swing/UIDefaults/6795356/bug6795356.java +++ b/test/jdk/javax/swing/UIDefaults/6795356/bug6795356.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,7 +28,7 @@ * @author Alexander Potochkin * @library ../../regtesthelpers * @build Util - * @run main/othervm -mx128m bug6795356 + * @run main/othervm -Xmx128m bug6795356 */ import java.lang.ref.WeakReference; diff --git a/test/jdk/javax/swing/border/TestTitledBorderLeak.java b/test/jdk/javax/swing/border/TestTitledBorderLeak.java index 259a2f60c29..ea7c1e2a2fd 100644 --- a/test/jdk/javax/swing/border/TestTitledBorderLeak.java +++ b/test/jdk/javax/swing/border/TestTitledBorderLeak.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ import javax.swing.border.TitledBorder; * @summary Verifies TitledBorder's memory leak * @library /javax/swing/regtesthelpers * @build Util - * @run main/timeout=60/othervm -mx32m TestTitledBorderLeak + * @run main/timeout=60/othervm -Xmx32m TestTitledBorderLeak */ public final class TestTitledBorderLeak { diff --git a/test/jdk/javax/swing/plaf/basic/BasicSliderUI/bug4419255.java b/test/jdk/javax/swing/plaf/basic/BasicSliderUI/bug4419255.java new file mode 100644 index 00000000000..eb23901f60d --- /dev/null +++ b/test/jdk/javax/swing/plaf/basic/BasicSliderUI/bug4419255.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 java.awt.Color; +import javax.swing.JColorChooser; +import javax.swing.UIManager; + +import jtreg.SkippedException; + +/* + * @test + * @bug 4419255 + * @library /java/awt/regtesthelpers /test/lib + * @build PassFailJFrame + * @summary Tests if Metal Slider's thumb isn't clipped + * @run main/manual bug4419255 + */ + +public class bug4419255 { + + public static void main(String[] args) throws Exception { + + // ColorChooser UI design is different for GTK L&F. + // There is no RGB tab available for GTK L&F, skip the testing. + if (UIManager.getLookAndFeel().getName().contains("GTK")) { + throw new SkippedException("Test not applicable for GTK L&F"); + } + String instructions = """ + Choose RGB tab. If sliders' thumbs are painted correctly + (top is not clipped, black line is visible), + then test passed. Otherwise it failed."""; + + PassFailJFrame.builder() + .title("bug4419255") + .instructions(instructions) + .columns(40) + .testUI(bug4419255::createColorChooser) + .build() + .awaitAndCheck(); + } + + private static JColorChooser createColorChooser() { + return new JColorChooser(Color.BLUE); + } +} diff --git a/test/jdk/javax/swing/regtesthelpers/Util.java b/test/jdk/javax/swing/regtesthelpers/Util.java index 4724fa200d6..5f81384028e 100644 --- a/test/jdk/javax/swing/regtesthelpers/Util.java +++ b/test/jdk/javax/swing/regtesthelpers/Util.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -82,7 +82,7 @@ public class Util { /** * Fills the heap until OutOfMemoryError occurs. This method is useful for * WeakReferences removing. To minimize the amount of filled memory the - * test should provide reasonable heap size via -mx option. + * test should provide reasonable heap size via -Xmx option. */ public static void generateOOME() { List bigLeak = new LinkedList(); diff --git a/test/jdk/jdk/classfile/ConstantDescSymbolsTest.java b/test/jdk/jdk/classfile/ConstantDescSymbolsTest.java index 7c97c9dd5a9..b5d3ba5d584 100644 --- a/test/jdk/jdk/classfile/ConstantDescSymbolsTest.java +++ b/test/jdk/jdk/classfile/ConstantDescSymbolsTest.java @@ -23,11 +23,14 @@ /* * @test - * @bug 8304031 8338406 + * @bug 8304031 8338406 8338546 * @summary Testing handling of various constant descriptors in ClassFile API. + * @modules java.base/jdk.internal.constant + * java.base/jdk.internal.classfile.impl * @run junit ConstantDescSymbolsTest */ +import java.lang.classfile.constantpool.ConstantPoolBuilder; import java.lang.constant.ClassDesc; import java.lang.constant.DynamicConstantDesc; import java.lang.constant.MethodHandleDesc; @@ -36,8 +39,14 @@ import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodType; import java.util.function.Supplier; import java.lang.classfile.ClassFile; +import java.util.stream.Stream; + +import jdk.internal.classfile.impl.AbstractPoolEntry; +import jdk.internal.constant.ConstantUtils; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import static java.lang.classfile.ClassFile.ACC_PUBLIC; import static java.lang.constant.ConstantDescs.*; @@ -102,4 +111,58 @@ final class ConstantDescSymbolsTest { assertEquals(DEFAULT_NAME, cb.name); assertEquals(CondyBoot.class, cb.type); } + + static Stream classOrInterfaceEntries() { + return Stream.of( + CD_Object, CD_Float, CD_Long, CD_String, ClassDesc.of("Ape"), + CD_String.nested("Whatever"), CD_MethodHandles_Lookup, ClassDesc.ofInternalName("one/Two"), + ClassDesc.ofDescriptor("La/b/C;"), ConstantDescSymbolsTest.class.describeConstable().orElseThrow(), + CD_Boolean, CD_ConstantBootstraps, CD_MethodHandles + ); + } + + @ParameterizedTest + @MethodSource("classOrInterfaceEntries") + void testConstantPoolBuilderClassOrInterfaceEntry(ClassDesc cd) { + assertTrue(cd.isClassOrInterface()); + ConstantPoolBuilder cp = ConstantPoolBuilder.of(); + var internal = ConstantUtils.dropFirstAndLastChar(cd.descriptorString()); + + // 1. ClassDesc + var ce = cp.classEntry(cd); + assertSame(cd, ce.asSymbol(), "Symbol propagation on create"); + + // 1.1. Bare addition + assertTrue(ce.name().equalsString(internal), "Adding to bare pool"); + + // 1.2. Lookup existing + assertSame(ce, cp.classEntry(cd), "Finding by identical CD"); + + // 1.3. Lookup existing - equal but different ClassDesc + var cd1 = ClassDesc.ofDescriptor(cd.descriptorString()); + assertSame(ce, cp.classEntry(cd1), "Finding by another equal CD"); + + // 1.3.1. Lookup existing - equal but different ClassDesc, equal but different string + var cd2 = ClassDesc.ofDescriptor("" + cd.descriptorString()); + assertSame(ce, cp.classEntry(cd2), "Finding by another equal CD"); + + // 1.4. Lookup existing - with utf8 internal name + var utf8 = cp.utf8Entry(internal); + assertSame(ce, cp.classEntry(utf8), "Finding CD by UTF8"); + + // 2. ClassEntry exists, no ClassDesc + cp = ConstantPoolBuilder.of(); + utf8 = cp.utf8Entry(internal); + ce = cp.classEntry(utf8); + var found = cp.classEntry(cd); + assertSame(ce, found, "Finding non-CD CEs with CD"); + assertEquals(cd, ce.asSymbol(), "Symbol propagation on find"); + + // 3. Utf8Entry exists, no ClassEntry + cp = ConstantPoolBuilder.of(); + utf8 = cp.utf8Entry(internal); + ce = cp.classEntry(cd); + assertSame(utf8, ce.name(), "Reusing existing utf8 entry"); + assertEquals(cd, ce.asSymbol(), "Symbol propagation on create with utf8"); + } } diff --git a/test/jdk/jdk/classfile/InstructionValidationTest.java b/test/jdk/jdk/classfile/InstructionValidationTest.java new file mode 100644 index 00000000000..17210e1173b --- /dev/null +++ b/test/jdk/jdk/classfile/InstructionValidationTest.java @@ -0,0 +1,182 @@ +/* + * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8341277 + * @summary Testing ClassFile instruction argument validation. + * @run junit InstructionValidationTest + */ + +import java.lang.classfile.*; +import java.lang.classfile.constantpool.ClassEntry; +import java.lang.classfile.constantpool.ConstantPoolBuilder; +import java.lang.classfile.instruction.*; +import java.util.List; +import java.util.function.ObjIntConsumer; +import java.util.stream.Stream; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.function.Executable; + +import static java.lang.constant.ConstantDescs.*; +import static org.junit.jupiter.api.Assertions.*; +import static java.lang.classfile.Opcode.*; +import static org.junit.jupiter.api.Assertions.assertThrows; + +class InstructionValidationTest { + + @Test + void testArgumentConstant() { + assertDoesNotThrow(() -> ConstantInstruction.ofArgument(SIPUSH, 0)); + assertDoesNotThrow(() -> ConstantInstruction.ofArgument(SIPUSH, Short.MIN_VALUE)); + assertDoesNotThrow(() -> ConstantInstruction.ofArgument(SIPUSH, Short.MAX_VALUE)); + assertDoesNotThrow(() -> ConstantInstruction.ofArgument(BIPUSH, 0)); + assertDoesNotThrow(() -> ConstantInstruction.ofArgument(BIPUSH, Byte.MIN_VALUE)); + assertDoesNotThrow(() -> ConstantInstruction.ofArgument(BIPUSH, Byte.MAX_VALUE)); + + assertThrows(IllegalArgumentException.class, () -> ConstantInstruction.ofArgument(SIPUSH, (int) Short.MIN_VALUE - 1)); + assertThrows(IllegalArgumentException.class, () -> ConstantInstruction.ofArgument(SIPUSH, (int) Short.MAX_VALUE + 1)); + assertThrows(IllegalArgumentException.class, () -> ConstantInstruction.ofArgument(BIPUSH, (int) Byte.MIN_VALUE - 1)); + assertThrows(IllegalArgumentException.class, () -> ConstantInstruction.ofArgument(BIPUSH, (int) Byte.MAX_VALUE + 1)); + } + + /** + * Tests the bad slot argument IAE for load, store, increment, and ret. + */ + @Test + void testSlots() { + record Result(boolean shouldFail, int slot) { + } + + List badSlots = List.of(-1, 72694, -42, 0x10000, Integer.MIN_VALUE, Integer.MAX_VALUE); + List u2OnlySlots = List.of(0x100, 1000, 0xFFFF); + List u1Slots = List.of(0, 2, 15, 0xFF); + + List badU1Slots = Stream.concat(badSlots.stream(), u2OnlySlots.stream()).toList(); + List u2Slots = Stream.concat(u1Slots.stream(), u2OnlySlots.stream()).toList(); + List u2Cases = Stream.concat( + badSlots.stream().map(i -> new Result(true, i)), + u2Slots.stream().map(i -> new Result(false, i)) + ).toList(); + List u1Cases = Stream.concat( + badU1Slots.stream().map(i -> new Result(true, i)), + u1Slots.stream().map(i -> new Result(false, i)) + ).toList(); + List nonIntrinsicValues = Stream.of(badSlots, u2Slots, u1Slots).mapMulti(List::forEach) + .filter(i -> i < 0 || i > 3).toList(); + + Label[] capture = new Label[1]; + ClassFile.of().build(CD_Object, clb -> clb.withMethodBody("test", MTD_void, 0, cob -> { + capture[0] = cob.startLabel(); + cob.return_(); + })); + Label dummyLabel = capture[0]; + + List> cbFactories = List.of( + CodeBuilder::aload, + CodeBuilder::iload, + CodeBuilder::lload, + CodeBuilder::dload, + CodeBuilder::fload, + CodeBuilder::astore, + CodeBuilder::istore, + CodeBuilder::lstore, + CodeBuilder::dstore, + CodeBuilder::fstore + ); + + for (var r : u2Cases) { + var fails = r.shouldFail; + var i = r.slot; + for (var fac : cbFactories) { + //check(fails, () -> execute(cob -> fac.accept(cob, i))); + } + for (TypeKind tk : TypeKind.values()) { + if (tk == TypeKind.VOID) + continue; + //check(fails, () -> execute(cob -> cob.loadLocal(tk, i))); + //check(fails, () -> execute(cob -> cob.storeLocal(tk, i))); + check(fails, () -> LoadInstruction.of(tk, i)); + check(fails, () -> StoreInstruction.of(tk, i)); + } + //check(fails, () -> execute(cob -> cob.iinc(i, 1))); + check(fails, () -> IncrementInstruction.of(i, 1)); + check(fails, () -> DiscontinuedInstruction.RetInstruction.of(i)); + check(fails, () -> DiscontinuedInstruction.RetInstruction.of(RET_W, i)); + check(fails, () -> LocalVariable.of(i, "test", CD_Object, dummyLabel, dummyLabel)); + check(fails, () -> LocalVariableType.of(i, "test", Signature.of(CD_Object), dummyLabel, dummyLabel)); + } + + for (var r : u1Cases) { + var fails = r.shouldFail; + var i = r.slot; + for (var u1Op : List.of(ALOAD, ILOAD, LLOAD, FLOAD, DLOAD)) + check(fails, () -> LoadInstruction.of(u1Op, i)); + for (var u1Op : List.of(ASTORE, ISTORE, LSTORE, FSTORE, DSTORE)) + check(fails, () -> StoreInstruction.of(u1Op, i)); + check(fails, () -> DiscontinuedInstruction.RetInstruction.of(RET, i)); + } + + for (var i : nonIntrinsicValues) { + for (var intrinsicOp : List.of(ALOAD_0, ILOAD_0, LLOAD_0, FLOAD_0, DLOAD_0, ALOAD_1, ILOAD_1, LLOAD_1, FLOAD_1, DLOAD_1, + ALOAD_2, ILOAD_2, LLOAD_2, FLOAD_2, DLOAD_2, ALOAD_3, ILOAD_3, LLOAD_3, FLOAD_3, DLOAD_3)) { + assertThrows(IllegalArgumentException.class, () -> LoadInstruction.of(intrinsicOp, i)); + } + for (var intrinsicOp : List.of(ASTORE_0, ISTORE_0, LSTORE_0, FSTORE_0, DSTORE_0, ASTORE_1, ISTORE_1, LSTORE_1, FSTORE_1, DSTORE_1, + ASTORE_2, ISTORE_2, LSTORE_2, FSTORE_2, DSTORE_2, ASTORE_3, ISTORE_3, LSTORE_3, FSTORE_3, DSTORE_3)) { + assertThrows(IllegalArgumentException.class, () -> StoreInstruction.of(intrinsicOp, i)); + } + } + } + + static void check(boolean fails, Executable exec) { + if (fails) { + assertThrows(IllegalArgumentException.class, exec); + } else { + assertDoesNotThrow(exec); + } + } + + @Test + void testIincConstant() { + IncrementInstruction.of(0, 2); + IncrementInstruction.of(0, Short.MAX_VALUE); + IncrementInstruction.of(0, Short.MIN_VALUE); + assertThrows(IllegalArgumentException.class, () -> IncrementInstruction.of(0, Short.MAX_VALUE + 1)); + assertThrows(IllegalArgumentException.class, () -> IncrementInstruction.of(0, Short.MIN_VALUE - 1)); + } + + @Test + void testNewMultiArrayDimension() { + ClassEntry ce = ConstantPoolBuilder.of().classEntry(CD_Class); + NewMultiArrayInstruction.of(ce, 1); + NewMultiArrayInstruction.of(ce, 13); + NewMultiArrayInstruction.of(ce, 0xFF); + assertThrows(IllegalArgumentException.class, () -> NewMultiArrayInstruction.of(ce, 0)); + assertThrows(IllegalArgumentException.class, () -> NewMultiArrayInstruction.of(ce, 0x100)); + assertThrows(IllegalArgumentException.class, () -> NewMultiArrayInstruction.of(ce, -1)); + assertThrows(IllegalArgumentException.class, () -> NewMultiArrayInstruction.of(ce, Integer.MIN_VALUE)); + assertThrows(IllegalArgumentException.class, () -> NewMultiArrayInstruction.of(ce, Integer.MAX_VALUE)); + } +} diff --git a/test/jdk/jdk/classfile/LimitsTest.java b/test/jdk/jdk/classfile/LimitsTest.java index 9c7b8d9e72d..a1899ac1c84 100644 --- a/test/jdk/jdk/classfile/LimitsTest.java +++ b/test/jdk/jdk/classfile/LimitsTest.java @@ -28,6 +28,7 @@ * @run junit LimitsTest */ import java.lang.classfile.Attributes; +import java.lang.classfile.constantpool.PoolEntry; import java.lang.constant.ClassDesc; import java.lang.constant.ConstantDescs; import java.lang.constant.MethodTypeDesc; @@ -36,12 +37,10 @@ import java.lang.classfile.Opcode; import java.lang.classfile.attribute.CodeAttribute; import java.lang.classfile.attribute.LineNumberInfo; import java.lang.classfile.attribute.LineNumberTableAttribute; -import java.lang.classfile.attribute.LocalVariableInfo; import java.lang.classfile.attribute.LocalVariableTableAttribute; import java.lang.classfile.constantpool.ConstantPoolBuilder; import java.lang.classfile.constantpool.ConstantPoolException; import java.lang.classfile.constantpool.IntegerEntry; -import java.lang.classfile.instruction.LocalVariable; import java.util.List; import jdk.internal.classfile.impl.BufWriterImpl; @@ -113,13 +112,13 @@ class LimitsTest { @Test void testInvalidClassEntry() { assertThrows(ConstantPoolException.class, () -> ClassFile.of().parse(new byte[]{(byte)0xCA, (byte)0xFE, (byte)0xBA, (byte)0xBE, - 0, 0, 0, 0, 0, 2, ClassFile.TAG_METHODREF, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}).thisClass()); + 0, 0, 0, 0, 0, 2, PoolEntry.TAG_METHODREF, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}).thisClass()); } @Test void testInvalidUtf8Entry() { var cp = ClassFile.of().parse(new byte[]{(byte)0xCA, (byte)0xFE, (byte)0xBA, (byte)0xBE, - 0, 0, 0, 0, 0, 3, ClassFile.TAG_INTEGER, 0, 0, 0, 0, ClassFile.TAG_NAMEANDTYPE, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}).constantPool(); + 0, 0, 0, 0, 0, 3, PoolEntry.TAG_INTEGER, 0, 0, 0, 0, PoolEntry.TAG_NAME_AND_TYPE, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}).constantPool(); assertTrue(cp.entryByIndex(1) instanceof IntegerEntry); //parse valid int entry first assertThrows(ConstantPoolException.class, () -> cp.entryByIndex(2)); } diff --git a/test/jdk/jdk/classfile/OneToOneTest.java b/test/jdk/jdk/classfile/OneToOneTest.java index 4e21cbebbe3..779e357ff9b 100644 --- a/test/jdk/jdk/classfile/OneToOneTest.java +++ b/test/jdk/jdk/classfile/OneToOneTest.java @@ -24,16 +24,11 @@ /* * @test * @summary Testing ClassFile class writing and reading. + * @bug 8339368 * @run junit OneToOneTest */ import java.lang.constant.ClassDesc; - -import static java.lang.classfile.ClassFile.ACC_PUBLIC; -import static java.lang.classfile.ClassFile.ACC_STATIC; -import static java.lang.constant.ConstantDescs.*; import java.lang.constant.MethodTypeDesc; -import java.util.List; - import java.lang.reflect.AccessFlag; import java.lang.classfile.ClassModel; import java.lang.classfile.ClassFile; @@ -41,22 +36,20 @@ import java.lang.classfile.Instruction; import java.lang.classfile.Label; import java.lang.classfile.MethodModel; import java.lang.classfile.attribute.SourceFileAttribute; -import static org.junit.jupiter.api.Assertions.*; +import java.lang.classfile.instruction.*; +import java.util.List; + import org.junit.jupiter.api.Test; -import java.lang.classfile.instruction.ConstantInstruction; -import java.lang.classfile.instruction.StoreInstruction; -import java.lang.classfile.instruction.BranchInstruction; -import java.lang.classfile.instruction.LoadInstruction; -import java.lang.classfile.instruction.OperatorInstruction; -import java.lang.classfile.instruction.FieldInstruction; -import java.lang.classfile.instruction.InvokeInstruction; - +import static java.lang.classfile.ClassFile.ACC_PUBLIC; +import static java.lang.classfile.ClassFile.ACC_STATIC; +import static java.lang.classfile.Opcode.*; +import static java.lang.constant.ConstantDescs.*; import static helpers.TestConstants.CD_PrintStream; import static helpers.TestConstants.CD_System; import static helpers.TestConstants.MTD_INT_VOID; import static helpers.TestConstants.MTD_VOID; -import static java.lang.classfile.Opcode.*; +import static org.junit.jupiter.api.Assertions.*; class OneToOneTest { @@ -156,4 +149,36 @@ class OneToOneTest { } assertTrue(found); } + + @Test + void testJava5ClassWriteRead() { + MethodModel mm = ClassFile.of().parse(ClassFile.of().build(ClassDesc.of("MyClass"), clb -> clb + .withVersion(ClassFile.JAVA_5_VERSION, 0) + .withMethodBody("switches", MTD_void, ACC_STATIC, cob -> { + Label l1 = cob.newLabel(), l2 = cob.newLabel(), l3 = cob.newLabel(), l4 = cob.newLabel(); + cob.iconst_0() + .tableswitch(l1, List.of(SwitchCase.of(0, l2))) + .labelBinding(l1) + .nop() + .labelBinding(l2) + .iconst_0() + .lookupswitch(l3, List.of(SwitchCase.of(0, l4))) + .labelBinding(l3) + .nop() + .labelBinding(l4) + .return_(); + }))).methods().getFirst(); + var it = mm.code().orElseThrow().iterator(); + while (!(it.next() instanceof ConstantInstruction)); + assertTrue(it.next() instanceof TableSwitchInstruction tsi + && it.next() instanceof LabelTarget lt1 && lt1.label().equals(tsi.defaultTarget()) + && it.next() instanceof NopInstruction + && it.next() instanceof LabelTarget lt2 && lt2.label().equals(tsi.cases().getFirst().target()) + && it.next() instanceof ConstantInstruction + && it.next() instanceof LookupSwitchInstruction lsi + && it.next() instanceof LabelTarget lt3 && lt3.label().equals(lsi.defaultTarget()) + && it.next() instanceof NopInstruction + && it.next() instanceof LabelTarget lt4 && lt4.label().equals(lsi.cases().getFirst().target()), + () -> mm.code().get().elementList().toString()); + } } diff --git a/test/jdk/jdk/classfile/OpcodesValidationTest.java b/test/jdk/jdk/classfile/OpcodesValidationTest.java deleted file mode 100644 index 2470fcf132c..00000000000 --- a/test/jdk/jdk/classfile/OpcodesValidationTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @summary Testing ClassFile constant instruction argument validation. - * @run junit OpcodesValidationTest - */ -import java.lang.classfile.instruction.ConstantInstruction; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.*; -import static java.lang.classfile.Opcode.*; - -class OpcodesValidationTest { - - @Test - void testArgumentConstant() { - assertDoesNotThrow(() -> ConstantInstruction.ofArgument(SIPUSH, 0)); - assertDoesNotThrow(() -> ConstantInstruction.ofArgument(SIPUSH, Short.MIN_VALUE)); - assertDoesNotThrow(() -> ConstantInstruction.ofArgument(SIPUSH, Short.MAX_VALUE)); - assertDoesNotThrow(() -> ConstantInstruction.ofArgument(BIPUSH, 0)); - assertDoesNotThrow(() -> ConstantInstruction.ofArgument(BIPUSH, Byte.MIN_VALUE)); - assertDoesNotThrow(() -> ConstantInstruction.ofArgument(BIPUSH, Byte.MAX_VALUE)); - - assertThrows(IllegalArgumentException.class, () -> ConstantInstruction.ofArgument(SIPUSH, (int)Short.MIN_VALUE - 1)); - assertThrows(IllegalArgumentException.class, () -> ConstantInstruction.ofArgument(SIPUSH, (int)Short.MAX_VALUE + 1)); - assertThrows(IllegalArgumentException.class, () -> ConstantInstruction.ofArgument(BIPUSH, (int)Byte.MIN_VALUE - 1)); - assertThrows(IllegalArgumentException.class, () -> ConstantInstruction.ofArgument(BIPUSH, (int)Byte.MAX_VALUE + 1)); - } -} diff --git a/test/jdk/jdk/classfile/OptionsTest.java b/test/jdk/jdk/classfile/OptionsTest.java index fda155cfd2a..4c9525f0f7f 100644 --- a/test/jdk/jdk/classfile/OptionsTest.java +++ b/test/jdk/jdk/classfile/OptionsTest.java @@ -62,7 +62,7 @@ class OptionsTest { @MethodSource("corpus") void testAttributesProcessingOptionOnTransform(Path path) throws Exception { testNoUnstable(path, ClassFile.of().parse( - ClassFile.of(ClassFile.AttributesProcessingOption.DROP_UNSTABLE_ATRIBUTES).transformClass( + ClassFile.of(ClassFile.AttributesProcessingOption.DROP_UNSTABLE_ATTRIBUTES).transformClass( ClassFile.of().parse(path), ClassTransform.transformingMethodBodies(CodeTransform.ACCEPT_ALL)))); } diff --git a/test/jdk/jdk/classfile/StackMapsTest.java b/test/jdk/jdk/classfile/StackMapsTest.java index 09be56f0de2..1ccd7255ed4 100644 --- a/test/jdk/jdk/classfile/StackMapsTest.java +++ b/test/jdk/jdk/classfile/StackMapsTest.java @@ -385,9 +385,9 @@ class StackMapsTest { StackMapTableAttribute.of(List.of( StackMapFrameInfo.of(f2, List.of(), - List.of(StackMapFrameInfo.SimpleVerificationTypeInfo.ITEM_LONG)), + List.of(StackMapFrameInfo.SimpleVerificationTypeInfo.LONG)), StackMapFrameInfo.of(f3, - List.of(StackMapFrameInfo.SimpleVerificationTypeInfo.ITEM_LONG), + List.of(StackMapFrameInfo.SimpleVerificationTypeInfo.LONG), List.of())))); } )); diff --git a/test/jdk/jdk/classfile/UtilTest.java b/test/jdk/jdk/classfile/UtilTest.java index 5ed04180919..6ba7e146b03 100644 --- a/test/jdk/jdk/classfile/UtilTest.java +++ b/test/jdk/jdk/classfile/UtilTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,11 +23,25 @@ /* * @test + * @bug 8338546 * @summary Testing ClassFile Util. + * @library java.base + * @modules java.base/jdk.internal.constant + * java.base/jdk.internal.classfile.impl + * @build java.base/jdk.internal.classfile.impl.* * @run junit UtilTest */ +import java.lang.classfile.Opcode; import java.lang.constant.MethodTypeDesc; +import java.util.Arrays; +import java.util.concurrent.CopyOnWriteArrayList; +import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; + + +import jdk.internal.classfile.impl.RawBytecodeHelper; import jdk.internal.classfile.impl.Util; +import jdk.internal.classfile.impl.UtilAccess; +import jdk.internal.constant.ConstantUtils; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; @@ -76,4 +90,65 @@ class UtilTest { private void assertSlots(String methodDesc, int slots) { assertEquals(Util.parameterSlots(MethodTypeDesc.ofDescriptor(methodDesc)), slots); } + + @Test + void testPow31() { + int p = 1; + // Our calculation only prepares up to 65536, + // max length of CP Utf8 + 1 + for (int i = 0; i <= 65536; i++) { + final int t = i; + assertEquals(p, Util.pow31(i), () -> "31's power to " + t); + p *= 31; + } + } + + @ParameterizedTest + @ValueSource(classes = { + Long.class, + Object.class, + Util.class, + Test.class, + CopyOnWriteArrayList.class, + AtomicReferenceFieldUpdater.class + }) + void testInternalNameHash(Class type) { + var cd = type.describeConstable().orElseThrow(); + assertEquals(ConstantUtils.binaryToInternal(type.getName()).hashCode(), Util.internalNameHash(cd.descriptorString())); + } + + // Ensures the initialization statement of the powers array is filling in the right values + @Test + void testPowersArray() { + int[] powers = new int[64]; + for (int i = 1, k = 31; i <= 7; i++, k *= 31) { + int t = powers[UtilAccess.powersIndex(i, 0)] = k; + + for (int j = 1; j < UtilAccess.significantOctalDigits(); j++) { + t *= t; + t *= t; + t *= t; + powers[UtilAccess.powersIndex(i, j)] = t; + } + } + + assertArrayEquals(powers, UtilAccess.powersTable()); + } + + @Test + void testOpcodeLengthTable() { + var lengths = new byte[0x100]; + Arrays.fill(lengths, (byte) -1); + for (var op : Opcode.values()) { + if (!op.isWide()) { + lengths[op.bytecode()] = (byte) op.sizeIfFixed(); + } else { + // Wide pseudo-opcodes have double the length as normal variants + // Must match logic in checkSpecialInstruction() + assertEquals(op.sizeIfFixed(), lengths[op.bytecode() & 0xFF] * 2, op + " size"); + } + } + + assertArrayEquals(lengths, RawBytecodeHelper.LENGTHS); + } } diff --git a/test/jdk/jdk/classfile/VerifierSelfTest.java b/test/jdk/jdk/classfile/VerifierSelfTest.java index d0943d2eee9..b6a2f08c9ec 100644 --- a/test/jdk/jdk/classfile/VerifierSelfTest.java +++ b/test/jdk/jdk/classfile/VerifierSelfTest.java @@ -29,6 +29,7 @@ * @run junit VerifierSelfTest */ import java.io.IOException; +import java.lang.classfile.constantpool.PoolEntry; import java.lang.constant.ClassDesc; import static java.lang.constant.ConstantDescs.*; import java.lang.invoke.MethodHandleInfo; @@ -116,7 +117,7 @@ class VerifierSelfTest { void testInvalidClassNameEntry() { var cc = ClassFile.of(); var bytes = cc.parse(new byte[]{(byte)0xCA, (byte)0xFE, (byte)0xBA, (byte)0xBE, - 0, 0, 0, 0, 0, 2, ClassFile.TAG_INTEGER, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}); + 0, 0, 0, 0, 0, 2, PoolEntry.TAG_INTEGER, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}); assertTrue(cc.verify(bytes).stream().anyMatch(e -> e.getMessage().contains("expected ClassEntry"))); } diff --git a/test/jdk/jdk/classfile/helpers/ClassRecord.java b/test/jdk/jdk/classfile/helpers/ClassRecord.java index 329e41fa0f4..e7a239015f6 100644 --- a/test/jdk/jdk/classfile/helpers/ClassRecord.java +++ b/test/jdk/jdk/classfile/helpers/ClassRecord.java @@ -22,21 +22,13 @@ */ package helpers; -import java.io.IOException; -import java.io.StringWriter; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.RecordComponent; import java.math.BigInteger; import java.nio.charset.StandardCharsets; -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; import java.util.HashSet; -import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.NoSuchElementException; import java.util.Objects; import java.util.Set; import java.util.function.Function; @@ -53,9 +45,10 @@ import java.lang.classfile.instruction.*; import static java.util.stream.Collectors.toMap; import static java.util.stream.Collectors.toSet; -import static java.lang.classfile.ClassFile.*; import static java.lang.classfile.Attributes.*; +import static java.lang.classfile.constantpool.PoolEntry.*; import static helpers.ClassRecord.CompatibilityFilter.By_ClassBuilder; +import static jdk.internal.classfile.impl.RawBytecodeHelper.*; /** * ClassRecord @@ -916,17 +909,17 @@ public record ClassRecord( CpFieldRefRecord.ofFieldRefEntry((FieldRefEntry) cpInfo); case TAG_METHODREF -> CpMethodRefRecord.ofMethodRefEntry((MethodRefEntry) cpInfo); - case TAG_INTERFACEMETHODREF -> + case TAG_INTERFACE_METHODREF -> CpInterfaceMethodRefRecord.ofInterfaceMethodRefEntry((InterfaceMethodRefEntry) cpInfo); - case TAG_NAMEANDTYPE -> + case TAG_NAME_AND_TYPE -> CpNameAndTypeRecord.ofNameAndTypeEntry((NameAndTypeEntry) cpInfo); - case TAG_METHODHANDLE -> + case TAG_METHOD_HANDLE -> CpMethodHandleRecord.ofMethodHandleEntry((MethodHandleEntry) cpInfo); - case TAG_METHODTYPE -> + case TAG_METHOD_TYPE -> new CpMethodTypeRecord(((MethodTypeEntry) cpInfo).descriptor().stringValue()); - case TAG_CONSTANTDYNAMIC -> + case TAG_DYNAMIC -> CpConstantDynamicRecord.ofConstantDynamicEntry((ConstantDynamicEntry) cpInfo); - case TAG_INVOKEDYNAMIC -> + case TAG_INVOKE_DYNAMIC -> CpInvokeDynamicRecord.ofInvokeDynamicEntry((InvokeDynamicEntry) cpInfo); case TAG_MODULE -> new CpModuleRecord(((ModuleEntry) cpInfo).name().stringValue()); diff --git a/test/jdk/jdk/classfile/java.base/jdk/internal/classfile/impl/UtilAccess.java b/test/jdk/jdk/classfile/java.base/jdk/internal/classfile/impl/UtilAccess.java new file mode 100644 index 00000000000..27cefd6d944 --- /dev/null +++ b/test/jdk/jdk/classfile/java.base/jdk/internal/classfile/impl/UtilAccess.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.internal.classfile.impl; + +public final class UtilAccess { + public static int significantOctalDigits() { + return Util.SIGNIFICANT_OCTAL_DIGITS; + } + + public static int powersIndex(int digit, int index) { + return Util.powersIndex(digit, index); + } + + public static int[] powersTable() { + return Util.powers; + } + + public static int reverse31() { + return Util.INVERSE_31; + } +} diff --git a/test/jdk/jdk/incubator/vector/Byte128VectorTests.java b/test/jdk/jdk/incubator/vector/Byte128VectorTests.java index 11f45b24c8e..77d0dd20974 100644 --- a/test/jdk/jdk/incubator/vector/Byte128VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Byte128VectorTests.java @@ -67,6 +67,14 @@ public class Byte128VectorTests extends AbstractVectorTest { static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 128); + static void assertArraysStrictlyEquals(byte[] r, byte[] a) { + for (int i = 0; i < a.length; i++) { + if (r[i] != a[i]) { + Assert.fail("at index #" + i + ", expected = " + a[i] + ", actual = " + r[i]); + } + } + } + interface FUnOp { byte apply(byte a); } @@ -231,25 +239,6 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - static void assertInsertArraysEquals(byte[] r, byte[] a, byte element, int index, int start, int end) { - int i = start; - try { - for (; i < end; i += 1) { - if(i%SPECIES.length() == index) { - Assert.assertEquals(r[i], element); - } else { - Assert.assertEquals(r[i], a[i]); - } - } - } catch (AssertionError e) { - if (i%SPECIES.length() == index) { - Assert.assertEquals(r[i], element, "at index #" + i); - } else { - Assert.assertEquals(r[i], a[i], "at index #" + i); - } - } - } - static void assertRearrangeArraysEquals(byte[] r, byte[] a, int[] order, int vector_len) { int i = 0, j = 0; try { @@ -704,21 +693,6 @@ public class Byte128VectorTests extends AbstractVectorTest { - interface FBinArrayOp { - byte apply(byte[] a, int b); - } - - static void assertArraysEquals(byte[] r, byte[] a, FBinArrayOp f) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a, i)); - } - } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a,i), "at index #" + i); - } - } - interface FGatherScatterOp { byte[] apply(byte[] a, int ix, int[] b, int iy); } @@ -1212,10 +1186,6 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - static byte get(byte[] a, int i) { - return (byte) a[i]; - } - static final IntFunction fr = (vl) -> { int length = BUFFER_REPS * vl; return new byte[length]; @@ -3748,22 +3718,23 @@ public class Byte128VectorTests extends AbstractVectorTest { assertReductionBoolArraysEquals(r, mask, Byte128VectorTests::allTrue); } - @Test(dataProvider = "byteUnaryOpProvider") - static void withByte128VectorTests(IntFunction fa) { + @Test(dataProvider = "byteBinaryOpProvider") + static void withByte128VectorTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - av.withLane((j++ & (SPECIES.length()-1)), (byte)(65535+i)).intoArray(r, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) & (SPECIES.length() - 1); } } - for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { - assertInsertArraysEquals(r, a, (byte)(65535+i), (j++ & (SPECIES.length()-1)), i , i + SPECIES.length()); - } + assertArraysStrictlyEquals(r, a); } static boolean testIS_DEFAULT(byte a) { @@ -4698,7 +4669,7 @@ public class Byte128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Byte128VectorTests::get); + assertArraysStrictlyEquals(r, a); } @Test(dataProvider = "byteUnaryOpProvider") diff --git a/test/jdk/jdk/incubator/vector/Byte256VectorTests.java b/test/jdk/jdk/incubator/vector/Byte256VectorTests.java index c050ab1daa8..31e38f633ff 100644 --- a/test/jdk/jdk/incubator/vector/Byte256VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Byte256VectorTests.java @@ -67,6 +67,14 @@ public class Byte256VectorTests extends AbstractVectorTest { static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 256); + static void assertArraysStrictlyEquals(byte[] r, byte[] a) { + for (int i = 0; i < a.length; i++) { + if (r[i] != a[i]) { + Assert.fail("at index #" + i + ", expected = " + a[i] + ", actual = " + r[i]); + } + } + } + interface FUnOp { byte apply(byte a); } @@ -231,25 +239,6 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - static void assertInsertArraysEquals(byte[] r, byte[] a, byte element, int index, int start, int end) { - int i = start; - try { - for (; i < end; i += 1) { - if(i%SPECIES.length() == index) { - Assert.assertEquals(r[i], element); - } else { - Assert.assertEquals(r[i], a[i]); - } - } - } catch (AssertionError e) { - if (i%SPECIES.length() == index) { - Assert.assertEquals(r[i], element, "at index #" + i); - } else { - Assert.assertEquals(r[i], a[i], "at index #" + i); - } - } - } - static void assertRearrangeArraysEquals(byte[] r, byte[] a, int[] order, int vector_len) { int i = 0, j = 0; try { @@ -704,21 +693,6 @@ public class Byte256VectorTests extends AbstractVectorTest { - interface FBinArrayOp { - byte apply(byte[] a, int b); - } - - static void assertArraysEquals(byte[] r, byte[] a, FBinArrayOp f) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a, i)); - } - } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a,i), "at index #" + i); - } - } - interface FGatherScatterOp { byte[] apply(byte[] a, int ix, int[] b, int iy); } @@ -1212,10 +1186,6 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - static byte get(byte[] a, int i) { - return (byte) a[i]; - } - static final IntFunction fr = (vl) -> { int length = BUFFER_REPS * vl; return new byte[length]; @@ -3748,22 +3718,23 @@ public class Byte256VectorTests extends AbstractVectorTest { assertReductionBoolArraysEquals(r, mask, Byte256VectorTests::allTrue); } - @Test(dataProvider = "byteUnaryOpProvider") - static void withByte256VectorTests(IntFunction fa) { + @Test(dataProvider = "byteBinaryOpProvider") + static void withByte256VectorTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - av.withLane((j++ & (SPECIES.length()-1)), (byte)(65535+i)).intoArray(r, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) & (SPECIES.length() - 1); } } - for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { - assertInsertArraysEquals(r, a, (byte)(65535+i), (j++ & (SPECIES.length()-1)), i , i + SPECIES.length()); - } + assertArraysStrictlyEquals(r, a); } static boolean testIS_DEFAULT(byte a) { @@ -4698,7 +4669,7 @@ public class Byte256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Byte256VectorTests::get); + assertArraysStrictlyEquals(r, a); } @Test(dataProvider = "byteUnaryOpProvider") diff --git a/test/jdk/jdk/incubator/vector/Byte512VectorTests.java b/test/jdk/jdk/incubator/vector/Byte512VectorTests.java index 4498714a170..9204c3ed1ad 100644 --- a/test/jdk/jdk/incubator/vector/Byte512VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Byte512VectorTests.java @@ -67,6 +67,14 @@ public class Byte512VectorTests extends AbstractVectorTest { static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 512); + static void assertArraysStrictlyEquals(byte[] r, byte[] a) { + for (int i = 0; i < a.length; i++) { + if (r[i] != a[i]) { + Assert.fail("at index #" + i + ", expected = " + a[i] + ", actual = " + r[i]); + } + } + } + interface FUnOp { byte apply(byte a); } @@ -231,25 +239,6 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - static void assertInsertArraysEquals(byte[] r, byte[] a, byte element, int index, int start, int end) { - int i = start; - try { - for (; i < end; i += 1) { - if(i%SPECIES.length() == index) { - Assert.assertEquals(r[i], element); - } else { - Assert.assertEquals(r[i], a[i]); - } - } - } catch (AssertionError e) { - if (i%SPECIES.length() == index) { - Assert.assertEquals(r[i], element, "at index #" + i); - } else { - Assert.assertEquals(r[i], a[i], "at index #" + i); - } - } - } - static void assertRearrangeArraysEquals(byte[] r, byte[] a, int[] order, int vector_len) { int i = 0, j = 0; try { @@ -704,21 +693,6 @@ public class Byte512VectorTests extends AbstractVectorTest { - interface FBinArrayOp { - byte apply(byte[] a, int b); - } - - static void assertArraysEquals(byte[] r, byte[] a, FBinArrayOp f) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a, i)); - } - } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a,i), "at index #" + i); - } - } - interface FGatherScatterOp { byte[] apply(byte[] a, int ix, int[] b, int iy); } @@ -1212,10 +1186,6 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - static byte get(byte[] a, int i) { - return (byte) a[i]; - } - static final IntFunction fr = (vl) -> { int length = BUFFER_REPS * vl; return new byte[length]; @@ -3748,22 +3718,23 @@ public class Byte512VectorTests extends AbstractVectorTest { assertReductionBoolArraysEquals(r, mask, Byte512VectorTests::allTrue); } - @Test(dataProvider = "byteUnaryOpProvider") - static void withByte512VectorTests(IntFunction fa) { + @Test(dataProvider = "byteBinaryOpProvider") + static void withByte512VectorTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - av.withLane((j++ & (SPECIES.length()-1)), (byte)(65535+i)).intoArray(r, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) & (SPECIES.length() - 1); } } - for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { - assertInsertArraysEquals(r, a, (byte)(65535+i), (j++ & (SPECIES.length()-1)), i , i + SPECIES.length()); - } + assertArraysStrictlyEquals(r, a); } static boolean testIS_DEFAULT(byte a) { @@ -4698,7 +4669,7 @@ public class Byte512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Byte512VectorTests::get); + assertArraysStrictlyEquals(r, a); } @Test(dataProvider = "byteUnaryOpProvider") diff --git a/test/jdk/jdk/incubator/vector/Byte64VectorTests.java b/test/jdk/jdk/incubator/vector/Byte64VectorTests.java index 9fb90a5fdd3..9af640a3133 100644 --- a/test/jdk/jdk/incubator/vector/Byte64VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Byte64VectorTests.java @@ -67,6 +67,14 @@ public class Byte64VectorTests extends AbstractVectorTest { static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 64); + static void assertArraysStrictlyEquals(byte[] r, byte[] a) { + for (int i = 0; i < a.length; i++) { + if (r[i] != a[i]) { + Assert.fail("at index #" + i + ", expected = " + a[i] + ", actual = " + r[i]); + } + } + } + interface FUnOp { byte apply(byte a); } @@ -231,25 +239,6 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - static void assertInsertArraysEquals(byte[] r, byte[] a, byte element, int index, int start, int end) { - int i = start; - try { - for (; i < end; i += 1) { - if(i%SPECIES.length() == index) { - Assert.assertEquals(r[i], element); - } else { - Assert.assertEquals(r[i], a[i]); - } - } - } catch (AssertionError e) { - if (i%SPECIES.length() == index) { - Assert.assertEquals(r[i], element, "at index #" + i); - } else { - Assert.assertEquals(r[i], a[i], "at index #" + i); - } - } - } - static void assertRearrangeArraysEquals(byte[] r, byte[] a, int[] order, int vector_len) { int i = 0, j = 0; try { @@ -704,21 +693,6 @@ public class Byte64VectorTests extends AbstractVectorTest { - interface FBinArrayOp { - byte apply(byte[] a, int b); - } - - static void assertArraysEquals(byte[] r, byte[] a, FBinArrayOp f) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a, i)); - } - } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a,i), "at index #" + i); - } - } - interface FGatherScatterOp { byte[] apply(byte[] a, int ix, int[] b, int iy); } @@ -1212,10 +1186,6 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - static byte get(byte[] a, int i) { - return (byte) a[i]; - } - static final IntFunction fr = (vl) -> { int length = BUFFER_REPS * vl; return new byte[length]; @@ -3748,22 +3718,23 @@ public class Byte64VectorTests extends AbstractVectorTest { assertReductionBoolArraysEquals(r, mask, Byte64VectorTests::allTrue); } - @Test(dataProvider = "byteUnaryOpProvider") - static void withByte64VectorTests(IntFunction fa) { + @Test(dataProvider = "byteBinaryOpProvider") + static void withByte64VectorTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - av.withLane((j++ & (SPECIES.length()-1)), (byte)(65535+i)).intoArray(r, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) & (SPECIES.length() - 1); } } - for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { - assertInsertArraysEquals(r, a, (byte)(65535+i), (j++ & (SPECIES.length()-1)), i , i + SPECIES.length()); - } + assertArraysStrictlyEquals(r, a); } static boolean testIS_DEFAULT(byte a) { @@ -4698,7 +4669,7 @@ public class Byte64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Byte64VectorTests::get); + assertArraysStrictlyEquals(r, a); } @Test(dataProvider = "byteUnaryOpProvider") diff --git a/test/jdk/jdk/incubator/vector/ByteMaxVectorTests.java b/test/jdk/jdk/incubator/vector/ByteMaxVectorTests.java index 44b47293444..1c0d5362b53 100644 --- a/test/jdk/jdk/incubator/vector/ByteMaxVectorTests.java +++ b/test/jdk/jdk/incubator/vector/ByteMaxVectorTests.java @@ -72,6 +72,14 @@ public class ByteMaxVectorTests extends AbstractVectorTest { static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / Max); + static void assertArraysStrictlyEquals(byte[] r, byte[] a) { + for (int i = 0; i < a.length; i++) { + if (r[i] != a[i]) { + Assert.fail("at index #" + i + ", expected = " + a[i] + ", actual = " + r[i]); + } + } + } + interface FUnOp { byte apply(byte a); } @@ -236,25 +244,6 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - static void assertInsertArraysEquals(byte[] r, byte[] a, byte element, int index, int start, int end) { - int i = start; - try { - for (; i < end; i += 1) { - if(i%SPECIES.length() == index) { - Assert.assertEquals(r[i], element); - } else { - Assert.assertEquals(r[i], a[i]); - } - } - } catch (AssertionError e) { - if (i%SPECIES.length() == index) { - Assert.assertEquals(r[i], element, "at index #" + i); - } else { - Assert.assertEquals(r[i], a[i], "at index #" + i); - } - } - } - static void assertRearrangeArraysEquals(byte[] r, byte[] a, int[] order, int vector_len) { int i = 0, j = 0; try { @@ -709,21 +698,6 @@ public class ByteMaxVectorTests extends AbstractVectorTest { - interface FBinArrayOp { - byte apply(byte[] a, int b); - } - - static void assertArraysEquals(byte[] r, byte[] a, FBinArrayOp f) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a, i)); - } - } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a,i), "at index #" + i); - } - } - interface FGatherScatterOp { byte[] apply(byte[] a, int ix, int[] b, int iy); } @@ -1217,10 +1191,6 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - static byte get(byte[] a, int i) { - return (byte) a[i]; - } - static final IntFunction fr = (vl) -> { int length = BUFFER_REPS * vl; return new byte[length]; @@ -3753,22 +3723,23 @@ public class ByteMaxVectorTests extends AbstractVectorTest { assertReductionBoolArraysEquals(r, mask, ByteMaxVectorTests::allTrue); } - @Test(dataProvider = "byteUnaryOpProvider") - static void withByteMaxVectorTests(IntFunction fa) { + @Test(dataProvider = "byteBinaryOpProvider") + static void withByteMaxVectorTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - av.withLane((j++ & (SPECIES.length()-1)), (byte)(65535+i)).intoArray(r, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) & (SPECIES.length() - 1); } } - for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { - assertInsertArraysEquals(r, a, (byte)(65535+i), (j++ & (SPECIES.length()-1)), i , i + SPECIES.length()); - } + assertArraysStrictlyEquals(r, a); } static boolean testIS_DEFAULT(byte a) { @@ -4703,7 +4674,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, ByteMaxVectorTests::get); + assertArraysStrictlyEquals(r, a); } @Test(dataProvider = "byteUnaryOpProvider") diff --git a/test/jdk/jdk/incubator/vector/Double128VectorTests.java b/test/jdk/jdk/incubator/vector/Double128VectorTests.java index 81c915ba7cf..4efeb8f2059 100644 --- a/test/jdk/jdk/incubator/vector/Double128VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Double128VectorTests.java @@ -71,6 +71,16 @@ public class Double128VectorTests extends AbstractVectorTest { static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 128); + static void assertArraysStrictlyEquals(double[] r, double[] a) { + for (int i = 0; i < a.length; i++) { + long ir = Double.doubleToRawLongBits(r[i]); + long ia = Double.doubleToRawLongBits(a[i]); + if (ir != ia) { + Assert.fail(String.format("at index #%d, expected = %016X, actual = %016X", i, ia, ir)); + } + } + } + interface FUnOp { double apply(double a); } @@ -248,25 +258,6 @@ relativeError)); } } - static void assertInsertArraysEquals(double[] r, double[] a, double element, int index, int start, int end) { - int i = start; - try { - for (; i < end; i += 1) { - if(i%SPECIES.length() == index) { - Assert.assertEquals(r[i], element); - } else { - Assert.assertEquals(r[i], a[i]); - } - } - } catch (AssertionError e) { - if (i%SPECIES.length() == index) { - Assert.assertEquals(r[i], element, "at index #" + i); - } else { - Assert.assertEquals(r[i], a[i], "at index #" + i); - } - } - } - static void assertRearrangeArraysEquals(double[] r, double[] a, int[] order, int vector_len) { int i = 0, j = 0; try { @@ -795,21 +786,6 @@ relativeError)); } } - interface FBinArrayOp { - double apply(double[] a, int b); - } - - static void assertArraysEquals(double[] r, double[] a, FBinArrayOp f) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a, i)); - } - } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a,i), "at index #" + i); - } - } - interface FGatherScatterOp { double[] apply(double[] a, int ix, int[] b, int iy); } @@ -1356,26 +1332,16 @@ relativeError)); } static double cornerCaseValue(int i) { - switch(i % 7) { - case 0: - return Double.MAX_VALUE; - case 1: - return Double.MIN_VALUE; - case 2: - return Double.NEGATIVE_INFINITY; - case 3: - return Double.POSITIVE_INFINITY; - case 4: - return Double.NaN; - case 5: - return (double)0.0; - default: - return (double)-0.0; - } - } - - static double get(double[] a, int i) { - return (double) a[i]; + return switch(i % 8) { + case 0 -> Double.MAX_VALUE; + case 1 -> Double.MIN_VALUE; + case 2 -> Double.NEGATIVE_INFINITY; + case 3 -> Double.POSITIVE_INFINITY; + case 4 -> Double.NaN; + case 5 -> Double.longBitsToDouble(0x7FF123456789ABCDL); + case 6 -> (double)0.0; + default -> (double)-0.0; + }; } static final IntFunction fr = (vl) -> { @@ -2602,22 +2568,23 @@ relativeError)); Double128VectorTests::FIRST_NONZEROReduceMasked, Double128VectorTests::FIRST_NONZEROReduceAllMasked); } - @Test(dataProvider = "doubleUnaryOpProvider") - static void withDouble128VectorTests(IntFunction fa) { + @Test(dataProvider = "doubleBinaryOpProvider") + static void withDouble128VectorTests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - av.withLane((j++ & (SPECIES.length()-1)), (double)(65535+i)).intoArray(r, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) & (SPECIES.length() - 1); } } - for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { - assertInsertArraysEquals(r, a, (double)(65535+i), (j++ & (SPECIES.length()-1)), i , i + SPECIES.length()); - } + assertArraysStrictlyEquals(r, a); } static boolean testIS_DEFAULT(double a) { @@ -3507,7 +3474,7 @@ relativeError)); } } - assertArraysEquals(r, a, Double128VectorTests::get); + assertArraysStrictlyEquals(r, a); } @Test(dataProvider = "doubleUnaryOpProvider") diff --git a/test/jdk/jdk/incubator/vector/Double256VectorTests.java b/test/jdk/jdk/incubator/vector/Double256VectorTests.java index 5824941d806..04b0e7dc0d6 100644 --- a/test/jdk/jdk/incubator/vector/Double256VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Double256VectorTests.java @@ -71,6 +71,16 @@ public class Double256VectorTests extends AbstractVectorTest { static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 256); + static void assertArraysStrictlyEquals(double[] r, double[] a) { + for (int i = 0; i < a.length; i++) { + long ir = Double.doubleToRawLongBits(r[i]); + long ia = Double.doubleToRawLongBits(a[i]); + if (ir != ia) { + Assert.fail(String.format("at index #%d, expected = %016X, actual = %016X", i, ia, ir)); + } + } + } + interface FUnOp { double apply(double a); } @@ -248,25 +258,6 @@ relativeError)); } } - static void assertInsertArraysEquals(double[] r, double[] a, double element, int index, int start, int end) { - int i = start; - try { - for (; i < end; i += 1) { - if(i%SPECIES.length() == index) { - Assert.assertEquals(r[i], element); - } else { - Assert.assertEquals(r[i], a[i]); - } - } - } catch (AssertionError e) { - if (i%SPECIES.length() == index) { - Assert.assertEquals(r[i], element, "at index #" + i); - } else { - Assert.assertEquals(r[i], a[i], "at index #" + i); - } - } - } - static void assertRearrangeArraysEquals(double[] r, double[] a, int[] order, int vector_len) { int i = 0, j = 0; try { @@ -795,21 +786,6 @@ relativeError)); } } - interface FBinArrayOp { - double apply(double[] a, int b); - } - - static void assertArraysEquals(double[] r, double[] a, FBinArrayOp f) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a, i)); - } - } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a,i), "at index #" + i); - } - } - interface FGatherScatterOp { double[] apply(double[] a, int ix, int[] b, int iy); } @@ -1356,26 +1332,16 @@ relativeError)); } static double cornerCaseValue(int i) { - switch(i % 7) { - case 0: - return Double.MAX_VALUE; - case 1: - return Double.MIN_VALUE; - case 2: - return Double.NEGATIVE_INFINITY; - case 3: - return Double.POSITIVE_INFINITY; - case 4: - return Double.NaN; - case 5: - return (double)0.0; - default: - return (double)-0.0; - } - } - - static double get(double[] a, int i) { - return (double) a[i]; + return switch(i % 8) { + case 0 -> Double.MAX_VALUE; + case 1 -> Double.MIN_VALUE; + case 2 -> Double.NEGATIVE_INFINITY; + case 3 -> Double.POSITIVE_INFINITY; + case 4 -> Double.NaN; + case 5 -> Double.longBitsToDouble(0x7FF123456789ABCDL); + case 6 -> (double)0.0; + default -> (double)-0.0; + }; } static final IntFunction fr = (vl) -> { @@ -2602,22 +2568,23 @@ relativeError)); Double256VectorTests::FIRST_NONZEROReduceMasked, Double256VectorTests::FIRST_NONZEROReduceAllMasked); } - @Test(dataProvider = "doubleUnaryOpProvider") - static void withDouble256VectorTests(IntFunction fa) { + @Test(dataProvider = "doubleBinaryOpProvider") + static void withDouble256VectorTests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - av.withLane((j++ & (SPECIES.length()-1)), (double)(65535+i)).intoArray(r, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) & (SPECIES.length() - 1); } } - for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { - assertInsertArraysEquals(r, a, (double)(65535+i), (j++ & (SPECIES.length()-1)), i , i + SPECIES.length()); - } + assertArraysStrictlyEquals(r, a); } static boolean testIS_DEFAULT(double a) { @@ -3507,7 +3474,7 @@ relativeError)); } } - assertArraysEquals(r, a, Double256VectorTests::get); + assertArraysStrictlyEquals(r, a); } @Test(dataProvider = "doubleUnaryOpProvider") diff --git a/test/jdk/jdk/incubator/vector/Double512VectorTests.java b/test/jdk/jdk/incubator/vector/Double512VectorTests.java index 895cf243eb7..ad03b8b5c7b 100644 --- a/test/jdk/jdk/incubator/vector/Double512VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Double512VectorTests.java @@ -71,6 +71,16 @@ public class Double512VectorTests extends AbstractVectorTest { static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 512); + static void assertArraysStrictlyEquals(double[] r, double[] a) { + for (int i = 0; i < a.length; i++) { + long ir = Double.doubleToRawLongBits(r[i]); + long ia = Double.doubleToRawLongBits(a[i]); + if (ir != ia) { + Assert.fail(String.format("at index #%d, expected = %016X, actual = %016X", i, ia, ir)); + } + } + } + interface FUnOp { double apply(double a); } @@ -248,25 +258,6 @@ relativeError)); } } - static void assertInsertArraysEquals(double[] r, double[] a, double element, int index, int start, int end) { - int i = start; - try { - for (; i < end; i += 1) { - if(i%SPECIES.length() == index) { - Assert.assertEquals(r[i], element); - } else { - Assert.assertEquals(r[i], a[i]); - } - } - } catch (AssertionError e) { - if (i%SPECIES.length() == index) { - Assert.assertEquals(r[i], element, "at index #" + i); - } else { - Assert.assertEquals(r[i], a[i], "at index #" + i); - } - } - } - static void assertRearrangeArraysEquals(double[] r, double[] a, int[] order, int vector_len) { int i = 0, j = 0; try { @@ -795,21 +786,6 @@ relativeError)); } } - interface FBinArrayOp { - double apply(double[] a, int b); - } - - static void assertArraysEquals(double[] r, double[] a, FBinArrayOp f) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a, i)); - } - } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a,i), "at index #" + i); - } - } - interface FGatherScatterOp { double[] apply(double[] a, int ix, int[] b, int iy); } @@ -1356,26 +1332,16 @@ relativeError)); } static double cornerCaseValue(int i) { - switch(i % 7) { - case 0: - return Double.MAX_VALUE; - case 1: - return Double.MIN_VALUE; - case 2: - return Double.NEGATIVE_INFINITY; - case 3: - return Double.POSITIVE_INFINITY; - case 4: - return Double.NaN; - case 5: - return (double)0.0; - default: - return (double)-0.0; - } - } - - static double get(double[] a, int i) { - return (double) a[i]; + return switch(i % 8) { + case 0 -> Double.MAX_VALUE; + case 1 -> Double.MIN_VALUE; + case 2 -> Double.NEGATIVE_INFINITY; + case 3 -> Double.POSITIVE_INFINITY; + case 4 -> Double.NaN; + case 5 -> Double.longBitsToDouble(0x7FF123456789ABCDL); + case 6 -> (double)0.0; + default -> (double)-0.0; + }; } static final IntFunction fr = (vl) -> { @@ -2602,22 +2568,23 @@ relativeError)); Double512VectorTests::FIRST_NONZEROReduceMasked, Double512VectorTests::FIRST_NONZEROReduceAllMasked); } - @Test(dataProvider = "doubleUnaryOpProvider") - static void withDouble512VectorTests(IntFunction fa) { + @Test(dataProvider = "doubleBinaryOpProvider") + static void withDouble512VectorTests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - av.withLane((j++ & (SPECIES.length()-1)), (double)(65535+i)).intoArray(r, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) & (SPECIES.length() - 1); } } - for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { - assertInsertArraysEquals(r, a, (double)(65535+i), (j++ & (SPECIES.length()-1)), i , i + SPECIES.length()); - } + assertArraysStrictlyEquals(r, a); } static boolean testIS_DEFAULT(double a) { @@ -3507,7 +3474,7 @@ relativeError)); } } - assertArraysEquals(r, a, Double512VectorTests::get); + assertArraysStrictlyEquals(r, a); } @Test(dataProvider = "doubleUnaryOpProvider") diff --git a/test/jdk/jdk/incubator/vector/Double64VectorTests.java b/test/jdk/jdk/incubator/vector/Double64VectorTests.java index 4414e36b0de..9321215c3de 100644 --- a/test/jdk/jdk/incubator/vector/Double64VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Double64VectorTests.java @@ -71,6 +71,16 @@ public class Double64VectorTests extends AbstractVectorTest { static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 64); + static void assertArraysStrictlyEquals(double[] r, double[] a) { + for (int i = 0; i < a.length; i++) { + long ir = Double.doubleToRawLongBits(r[i]); + long ia = Double.doubleToRawLongBits(a[i]); + if (ir != ia) { + Assert.fail(String.format("at index #%d, expected = %016X, actual = %016X", i, ia, ir)); + } + } + } + interface FUnOp { double apply(double a); } @@ -248,25 +258,6 @@ relativeError)); } } - static void assertInsertArraysEquals(double[] r, double[] a, double element, int index, int start, int end) { - int i = start; - try { - for (; i < end; i += 1) { - if(i%SPECIES.length() == index) { - Assert.assertEquals(r[i], element); - } else { - Assert.assertEquals(r[i], a[i]); - } - } - } catch (AssertionError e) { - if (i%SPECIES.length() == index) { - Assert.assertEquals(r[i], element, "at index #" + i); - } else { - Assert.assertEquals(r[i], a[i], "at index #" + i); - } - } - } - static void assertRearrangeArraysEquals(double[] r, double[] a, int[] order, int vector_len) { int i = 0, j = 0; try { @@ -795,21 +786,6 @@ relativeError)); } } - interface FBinArrayOp { - double apply(double[] a, int b); - } - - static void assertArraysEquals(double[] r, double[] a, FBinArrayOp f) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a, i)); - } - } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a,i), "at index #" + i); - } - } - interface FGatherScatterOp { double[] apply(double[] a, int ix, int[] b, int iy); } @@ -1356,26 +1332,16 @@ relativeError)); } static double cornerCaseValue(int i) { - switch(i % 7) { - case 0: - return Double.MAX_VALUE; - case 1: - return Double.MIN_VALUE; - case 2: - return Double.NEGATIVE_INFINITY; - case 3: - return Double.POSITIVE_INFINITY; - case 4: - return Double.NaN; - case 5: - return (double)0.0; - default: - return (double)-0.0; - } - } - - static double get(double[] a, int i) { - return (double) a[i]; + return switch(i % 8) { + case 0 -> Double.MAX_VALUE; + case 1 -> Double.MIN_VALUE; + case 2 -> Double.NEGATIVE_INFINITY; + case 3 -> Double.POSITIVE_INFINITY; + case 4 -> Double.NaN; + case 5 -> Double.longBitsToDouble(0x7FF123456789ABCDL); + case 6 -> (double)0.0; + default -> (double)-0.0; + }; } static final IntFunction fr = (vl) -> { @@ -2602,22 +2568,23 @@ relativeError)); Double64VectorTests::FIRST_NONZEROReduceMasked, Double64VectorTests::FIRST_NONZEROReduceAllMasked); } - @Test(dataProvider = "doubleUnaryOpProvider") - static void withDouble64VectorTests(IntFunction fa) { + @Test(dataProvider = "doubleBinaryOpProvider") + static void withDouble64VectorTests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - av.withLane((j++ & (SPECIES.length()-1)), (double)(65535+i)).intoArray(r, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) & (SPECIES.length() - 1); } } - for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { - assertInsertArraysEquals(r, a, (double)(65535+i), (j++ & (SPECIES.length()-1)), i , i + SPECIES.length()); - } + assertArraysStrictlyEquals(r, a); } static boolean testIS_DEFAULT(double a) { @@ -3507,7 +3474,7 @@ relativeError)); } } - assertArraysEquals(r, a, Double64VectorTests::get); + assertArraysStrictlyEquals(r, a); } @Test(dataProvider = "doubleUnaryOpProvider") diff --git a/test/jdk/jdk/incubator/vector/DoubleMaxVectorTests.java b/test/jdk/jdk/incubator/vector/DoubleMaxVectorTests.java index 271d1f12aba..a6b80376196 100644 --- a/test/jdk/jdk/incubator/vector/DoubleMaxVectorTests.java +++ b/test/jdk/jdk/incubator/vector/DoubleMaxVectorTests.java @@ -76,6 +76,16 @@ public class DoubleMaxVectorTests extends AbstractVectorTest { static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / Max); + static void assertArraysStrictlyEquals(double[] r, double[] a) { + for (int i = 0; i < a.length; i++) { + long ir = Double.doubleToRawLongBits(r[i]); + long ia = Double.doubleToRawLongBits(a[i]); + if (ir != ia) { + Assert.fail(String.format("at index #%d, expected = %016X, actual = %016X", i, ia, ir)); + } + } + } + interface FUnOp { double apply(double a); } @@ -253,25 +263,6 @@ relativeError)); } } - static void assertInsertArraysEquals(double[] r, double[] a, double element, int index, int start, int end) { - int i = start; - try { - for (; i < end; i += 1) { - if(i%SPECIES.length() == index) { - Assert.assertEquals(r[i], element); - } else { - Assert.assertEquals(r[i], a[i]); - } - } - } catch (AssertionError e) { - if (i%SPECIES.length() == index) { - Assert.assertEquals(r[i], element, "at index #" + i); - } else { - Assert.assertEquals(r[i], a[i], "at index #" + i); - } - } - } - static void assertRearrangeArraysEquals(double[] r, double[] a, int[] order, int vector_len) { int i = 0, j = 0; try { @@ -800,21 +791,6 @@ relativeError)); } } - interface FBinArrayOp { - double apply(double[] a, int b); - } - - static void assertArraysEquals(double[] r, double[] a, FBinArrayOp f) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a, i)); - } - } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a,i), "at index #" + i); - } - } - interface FGatherScatterOp { double[] apply(double[] a, int ix, int[] b, int iy); } @@ -1361,26 +1337,16 @@ relativeError)); } static double cornerCaseValue(int i) { - switch(i % 7) { - case 0: - return Double.MAX_VALUE; - case 1: - return Double.MIN_VALUE; - case 2: - return Double.NEGATIVE_INFINITY; - case 3: - return Double.POSITIVE_INFINITY; - case 4: - return Double.NaN; - case 5: - return (double)0.0; - default: - return (double)-0.0; - } - } - - static double get(double[] a, int i) { - return (double) a[i]; + return switch(i % 8) { + case 0 -> Double.MAX_VALUE; + case 1 -> Double.MIN_VALUE; + case 2 -> Double.NEGATIVE_INFINITY; + case 3 -> Double.POSITIVE_INFINITY; + case 4 -> Double.NaN; + case 5 -> Double.longBitsToDouble(0x7FF123456789ABCDL); + case 6 -> (double)0.0; + default -> (double)-0.0; + }; } static final IntFunction fr = (vl) -> { @@ -2607,22 +2573,23 @@ relativeError)); DoubleMaxVectorTests::FIRST_NONZEROReduceMasked, DoubleMaxVectorTests::FIRST_NONZEROReduceAllMasked); } - @Test(dataProvider = "doubleUnaryOpProvider") - static void withDoubleMaxVectorTests(IntFunction fa) { + @Test(dataProvider = "doubleBinaryOpProvider") + static void withDoubleMaxVectorTests(IntFunction fa, IntFunction fb) { double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - av.withLane((j++ & (SPECIES.length()-1)), (double)(65535+i)).intoArray(r, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) & (SPECIES.length() - 1); } } - for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { - assertInsertArraysEquals(r, a, (double)(65535+i), (j++ & (SPECIES.length()-1)), i , i + SPECIES.length()); - } + assertArraysStrictlyEquals(r, a); } static boolean testIS_DEFAULT(double a) { @@ -3512,7 +3479,7 @@ relativeError)); } } - assertArraysEquals(r, a, DoubleMaxVectorTests::get); + assertArraysStrictlyEquals(r, a); } @Test(dataProvider = "doubleUnaryOpProvider") diff --git a/test/jdk/jdk/incubator/vector/Float128VectorTests.java b/test/jdk/jdk/incubator/vector/Float128VectorTests.java index a634aeffe54..6bad9098544 100644 --- a/test/jdk/jdk/incubator/vector/Float128VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Float128VectorTests.java @@ -71,6 +71,16 @@ public class Float128VectorTests extends AbstractVectorTest { static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 128); + static void assertArraysStrictlyEquals(float[] r, float[] a) { + for (int i = 0; i < a.length; i++) { + int ir = Float.floatToRawIntBits(r[i]); + int ia = Float.floatToRawIntBits(a[i]); + if (ir != ia) { + Assert.fail(String.format("at index #%d, expected = %08X, actual = %08X", i, ia, ir)); + } + } + } + interface FUnOp { float apply(float a); } @@ -248,25 +258,6 @@ relativeError)); } } - static void assertInsertArraysEquals(float[] r, float[] a, float element, int index, int start, int end) { - int i = start; - try { - for (; i < end; i += 1) { - if(i%SPECIES.length() == index) { - Assert.assertEquals(r[i], element); - } else { - Assert.assertEquals(r[i], a[i]); - } - } - } catch (AssertionError e) { - if (i%SPECIES.length() == index) { - Assert.assertEquals(r[i], element, "at index #" + i); - } else { - Assert.assertEquals(r[i], a[i], "at index #" + i); - } - } - } - static void assertRearrangeArraysEquals(float[] r, float[] a, int[] order, int vector_len) { int i = 0, j = 0; try { @@ -795,21 +786,6 @@ relativeError)); } } - interface FBinArrayOp { - float apply(float[] a, int b); - } - - static void assertArraysEquals(float[] r, float[] a, FBinArrayOp f) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a, i)); - } - } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a,i), "at index #" + i); - } - } - interface FGatherScatterOp { float[] apply(float[] a, int ix, int[] b, int iy); } @@ -1367,26 +1343,16 @@ relativeError)); } static float cornerCaseValue(int i) { - switch(i % 7) { - case 0: - return Float.MAX_VALUE; - case 1: - return Float.MIN_VALUE; - case 2: - return Float.NEGATIVE_INFINITY; - case 3: - return Float.POSITIVE_INFINITY; - case 4: - return Float.NaN; - case 5: - return (float)0.0; - default: - return (float)-0.0; - } - } - - static float get(float[] a, int i) { - return (float) a[i]; + return switch(i % 8) { + case 0 -> Float.MAX_VALUE; + case 1 -> Float.MIN_VALUE; + case 2 -> Float.NEGATIVE_INFINITY; + case 3 -> Float.POSITIVE_INFINITY; + case 4 -> Float.NaN; + case 5 -> Float.intBitsToFloat(0x7F812345); + case 6 -> (float)0.0; + default -> (float)-0.0; + }; } static final IntFunction fr = (vl) -> { @@ -2613,22 +2579,23 @@ relativeError)); Float128VectorTests::FIRST_NONZEROReduceMasked, Float128VectorTests::FIRST_NONZEROReduceAllMasked); } - @Test(dataProvider = "floatUnaryOpProvider") - static void withFloat128VectorTests(IntFunction fa) { + @Test(dataProvider = "floatBinaryOpProvider") + static void withFloat128VectorTests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - av.withLane((j++ & (SPECIES.length()-1)), (float)(65535+i)).intoArray(r, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) & (SPECIES.length() - 1); } } - for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { - assertInsertArraysEquals(r, a, (float)(65535+i), (j++ & (SPECIES.length()-1)), i , i + SPECIES.length()); - } + assertArraysStrictlyEquals(r, a); } static boolean testIS_DEFAULT(float a) { @@ -3518,7 +3485,7 @@ relativeError)); } } - assertArraysEquals(r, a, Float128VectorTests::get); + assertArraysStrictlyEquals(r, a); } @Test(dataProvider = "floatUnaryOpProvider") diff --git a/test/jdk/jdk/incubator/vector/Float256VectorTests.java b/test/jdk/jdk/incubator/vector/Float256VectorTests.java index d9509ff3152..e714ace5a78 100644 --- a/test/jdk/jdk/incubator/vector/Float256VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Float256VectorTests.java @@ -71,6 +71,16 @@ public class Float256VectorTests extends AbstractVectorTest { static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 256); + static void assertArraysStrictlyEquals(float[] r, float[] a) { + for (int i = 0; i < a.length; i++) { + int ir = Float.floatToRawIntBits(r[i]); + int ia = Float.floatToRawIntBits(a[i]); + if (ir != ia) { + Assert.fail(String.format("at index #%d, expected = %08X, actual = %08X", i, ia, ir)); + } + } + } + interface FUnOp { float apply(float a); } @@ -248,25 +258,6 @@ relativeError)); } } - static void assertInsertArraysEquals(float[] r, float[] a, float element, int index, int start, int end) { - int i = start; - try { - for (; i < end; i += 1) { - if(i%SPECIES.length() == index) { - Assert.assertEquals(r[i], element); - } else { - Assert.assertEquals(r[i], a[i]); - } - } - } catch (AssertionError e) { - if (i%SPECIES.length() == index) { - Assert.assertEquals(r[i], element, "at index #" + i); - } else { - Assert.assertEquals(r[i], a[i], "at index #" + i); - } - } - } - static void assertRearrangeArraysEquals(float[] r, float[] a, int[] order, int vector_len) { int i = 0, j = 0; try { @@ -795,21 +786,6 @@ relativeError)); } } - interface FBinArrayOp { - float apply(float[] a, int b); - } - - static void assertArraysEquals(float[] r, float[] a, FBinArrayOp f) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a, i)); - } - } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a,i), "at index #" + i); - } - } - interface FGatherScatterOp { float[] apply(float[] a, int ix, int[] b, int iy); } @@ -1367,26 +1343,16 @@ relativeError)); } static float cornerCaseValue(int i) { - switch(i % 7) { - case 0: - return Float.MAX_VALUE; - case 1: - return Float.MIN_VALUE; - case 2: - return Float.NEGATIVE_INFINITY; - case 3: - return Float.POSITIVE_INFINITY; - case 4: - return Float.NaN; - case 5: - return (float)0.0; - default: - return (float)-0.0; - } - } - - static float get(float[] a, int i) { - return (float) a[i]; + return switch(i % 8) { + case 0 -> Float.MAX_VALUE; + case 1 -> Float.MIN_VALUE; + case 2 -> Float.NEGATIVE_INFINITY; + case 3 -> Float.POSITIVE_INFINITY; + case 4 -> Float.NaN; + case 5 -> Float.intBitsToFloat(0x7F812345); + case 6 -> (float)0.0; + default -> (float)-0.0; + }; } static final IntFunction fr = (vl) -> { @@ -2613,22 +2579,23 @@ relativeError)); Float256VectorTests::FIRST_NONZEROReduceMasked, Float256VectorTests::FIRST_NONZEROReduceAllMasked); } - @Test(dataProvider = "floatUnaryOpProvider") - static void withFloat256VectorTests(IntFunction fa) { + @Test(dataProvider = "floatBinaryOpProvider") + static void withFloat256VectorTests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - av.withLane((j++ & (SPECIES.length()-1)), (float)(65535+i)).intoArray(r, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) & (SPECIES.length() - 1); } } - for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { - assertInsertArraysEquals(r, a, (float)(65535+i), (j++ & (SPECIES.length()-1)), i , i + SPECIES.length()); - } + assertArraysStrictlyEquals(r, a); } static boolean testIS_DEFAULT(float a) { @@ -3518,7 +3485,7 @@ relativeError)); } } - assertArraysEquals(r, a, Float256VectorTests::get); + assertArraysStrictlyEquals(r, a); } @Test(dataProvider = "floatUnaryOpProvider") diff --git a/test/jdk/jdk/incubator/vector/Float512VectorTests.java b/test/jdk/jdk/incubator/vector/Float512VectorTests.java index 83326abe54e..f3c5a316c79 100644 --- a/test/jdk/jdk/incubator/vector/Float512VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Float512VectorTests.java @@ -71,6 +71,16 @@ public class Float512VectorTests extends AbstractVectorTest { static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 512); + static void assertArraysStrictlyEquals(float[] r, float[] a) { + for (int i = 0; i < a.length; i++) { + int ir = Float.floatToRawIntBits(r[i]); + int ia = Float.floatToRawIntBits(a[i]); + if (ir != ia) { + Assert.fail(String.format("at index #%d, expected = %08X, actual = %08X", i, ia, ir)); + } + } + } + interface FUnOp { float apply(float a); } @@ -248,25 +258,6 @@ relativeError)); } } - static void assertInsertArraysEquals(float[] r, float[] a, float element, int index, int start, int end) { - int i = start; - try { - for (; i < end; i += 1) { - if(i%SPECIES.length() == index) { - Assert.assertEquals(r[i], element); - } else { - Assert.assertEquals(r[i], a[i]); - } - } - } catch (AssertionError e) { - if (i%SPECIES.length() == index) { - Assert.assertEquals(r[i], element, "at index #" + i); - } else { - Assert.assertEquals(r[i], a[i], "at index #" + i); - } - } - } - static void assertRearrangeArraysEquals(float[] r, float[] a, int[] order, int vector_len) { int i = 0, j = 0; try { @@ -795,21 +786,6 @@ relativeError)); } } - interface FBinArrayOp { - float apply(float[] a, int b); - } - - static void assertArraysEquals(float[] r, float[] a, FBinArrayOp f) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a, i)); - } - } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a,i), "at index #" + i); - } - } - interface FGatherScatterOp { float[] apply(float[] a, int ix, int[] b, int iy); } @@ -1367,26 +1343,16 @@ relativeError)); } static float cornerCaseValue(int i) { - switch(i % 7) { - case 0: - return Float.MAX_VALUE; - case 1: - return Float.MIN_VALUE; - case 2: - return Float.NEGATIVE_INFINITY; - case 3: - return Float.POSITIVE_INFINITY; - case 4: - return Float.NaN; - case 5: - return (float)0.0; - default: - return (float)-0.0; - } - } - - static float get(float[] a, int i) { - return (float) a[i]; + return switch(i % 8) { + case 0 -> Float.MAX_VALUE; + case 1 -> Float.MIN_VALUE; + case 2 -> Float.NEGATIVE_INFINITY; + case 3 -> Float.POSITIVE_INFINITY; + case 4 -> Float.NaN; + case 5 -> Float.intBitsToFloat(0x7F812345); + case 6 -> (float)0.0; + default -> (float)-0.0; + }; } static final IntFunction fr = (vl) -> { @@ -2613,22 +2579,23 @@ relativeError)); Float512VectorTests::FIRST_NONZEROReduceMasked, Float512VectorTests::FIRST_NONZEROReduceAllMasked); } - @Test(dataProvider = "floatUnaryOpProvider") - static void withFloat512VectorTests(IntFunction fa) { + @Test(dataProvider = "floatBinaryOpProvider") + static void withFloat512VectorTests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - av.withLane((j++ & (SPECIES.length()-1)), (float)(65535+i)).intoArray(r, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) & (SPECIES.length() - 1); } } - for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { - assertInsertArraysEquals(r, a, (float)(65535+i), (j++ & (SPECIES.length()-1)), i , i + SPECIES.length()); - } + assertArraysStrictlyEquals(r, a); } static boolean testIS_DEFAULT(float a) { @@ -3518,7 +3485,7 @@ relativeError)); } } - assertArraysEquals(r, a, Float512VectorTests::get); + assertArraysStrictlyEquals(r, a); } @Test(dataProvider = "floatUnaryOpProvider") diff --git a/test/jdk/jdk/incubator/vector/Float64VectorTests.java b/test/jdk/jdk/incubator/vector/Float64VectorTests.java index efae7f1fc3c..378c2ae783f 100644 --- a/test/jdk/jdk/incubator/vector/Float64VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Float64VectorTests.java @@ -71,6 +71,16 @@ public class Float64VectorTests extends AbstractVectorTest { static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 64); + static void assertArraysStrictlyEquals(float[] r, float[] a) { + for (int i = 0; i < a.length; i++) { + int ir = Float.floatToRawIntBits(r[i]); + int ia = Float.floatToRawIntBits(a[i]); + if (ir != ia) { + Assert.fail(String.format("at index #%d, expected = %08X, actual = %08X", i, ia, ir)); + } + } + } + interface FUnOp { float apply(float a); } @@ -248,25 +258,6 @@ relativeError)); } } - static void assertInsertArraysEquals(float[] r, float[] a, float element, int index, int start, int end) { - int i = start; - try { - for (; i < end; i += 1) { - if(i%SPECIES.length() == index) { - Assert.assertEquals(r[i], element); - } else { - Assert.assertEquals(r[i], a[i]); - } - } - } catch (AssertionError e) { - if (i%SPECIES.length() == index) { - Assert.assertEquals(r[i], element, "at index #" + i); - } else { - Assert.assertEquals(r[i], a[i], "at index #" + i); - } - } - } - static void assertRearrangeArraysEquals(float[] r, float[] a, int[] order, int vector_len) { int i = 0, j = 0; try { @@ -795,21 +786,6 @@ relativeError)); } } - interface FBinArrayOp { - float apply(float[] a, int b); - } - - static void assertArraysEquals(float[] r, float[] a, FBinArrayOp f) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a, i)); - } - } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a,i), "at index #" + i); - } - } - interface FGatherScatterOp { float[] apply(float[] a, int ix, int[] b, int iy); } @@ -1367,26 +1343,16 @@ relativeError)); } static float cornerCaseValue(int i) { - switch(i % 7) { - case 0: - return Float.MAX_VALUE; - case 1: - return Float.MIN_VALUE; - case 2: - return Float.NEGATIVE_INFINITY; - case 3: - return Float.POSITIVE_INFINITY; - case 4: - return Float.NaN; - case 5: - return (float)0.0; - default: - return (float)-0.0; - } - } - - static float get(float[] a, int i) { - return (float) a[i]; + return switch(i % 8) { + case 0 -> Float.MAX_VALUE; + case 1 -> Float.MIN_VALUE; + case 2 -> Float.NEGATIVE_INFINITY; + case 3 -> Float.POSITIVE_INFINITY; + case 4 -> Float.NaN; + case 5 -> Float.intBitsToFloat(0x7F812345); + case 6 -> (float)0.0; + default -> (float)-0.0; + }; } static final IntFunction fr = (vl) -> { @@ -2613,22 +2579,23 @@ relativeError)); Float64VectorTests::FIRST_NONZEROReduceMasked, Float64VectorTests::FIRST_NONZEROReduceAllMasked); } - @Test(dataProvider = "floatUnaryOpProvider") - static void withFloat64VectorTests(IntFunction fa) { + @Test(dataProvider = "floatBinaryOpProvider") + static void withFloat64VectorTests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - av.withLane((j++ & (SPECIES.length()-1)), (float)(65535+i)).intoArray(r, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) & (SPECIES.length() - 1); } } - for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { - assertInsertArraysEquals(r, a, (float)(65535+i), (j++ & (SPECIES.length()-1)), i , i + SPECIES.length()); - } + assertArraysStrictlyEquals(r, a); } static boolean testIS_DEFAULT(float a) { @@ -3518,7 +3485,7 @@ relativeError)); } } - assertArraysEquals(r, a, Float64VectorTests::get); + assertArraysStrictlyEquals(r, a); } @Test(dataProvider = "floatUnaryOpProvider") diff --git a/test/jdk/jdk/incubator/vector/FloatMaxVectorTests.java b/test/jdk/jdk/incubator/vector/FloatMaxVectorTests.java index fdd3e042f77..a2dc38413ec 100644 --- a/test/jdk/jdk/incubator/vector/FloatMaxVectorTests.java +++ b/test/jdk/jdk/incubator/vector/FloatMaxVectorTests.java @@ -76,6 +76,16 @@ public class FloatMaxVectorTests extends AbstractVectorTest { static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / Max); + static void assertArraysStrictlyEquals(float[] r, float[] a) { + for (int i = 0; i < a.length; i++) { + int ir = Float.floatToRawIntBits(r[i]); + int ia = Float.floatToRawIntBits(a[i]); + if (ir != ia) { + Assert.fail(String.format("at index #%d, expected = %08X, actual = %08X", i, ia, ir)); + } + } + } + interface FUnOp { float apply(float a); } @@ -253,25 +263,6 @@ relativeError)); } } - static void assertInsertArraysEquals(float[] r, float[] a, float element, int index, int start, int end) { - int i = start; - try { - for (; i < end; i += 1) { - if(i%SPECIES.length() == index) { - Assert.assertEquals(r[i], element); - } else { - Assert.assertEquals(r[i], a[i]); - } - } - } catch (AssertionError e) { - if (i%SPECIES.length() == index) { - Assert.assertEquals(r[i], element, "at index #" + i); - } else { - Assert.assertEquals(r[i], a[i], "at index #" + i); - } - } - } - static void assertRearrangeArraysEquals(float[] r, float[] a, int[] order, int vector_len) { int i = 0, j = 0; try { @@ -800,21 +791,6 @@ relativeError)); } } - interface FBinArrayOp { - float apply(float[] a, int b); - } - - static void assertArraysEquals(float[] r, float[] a, FBinArrayOp f) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a, i)); - } - } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a,i), "at index #" + i); - } - } - interface FGatherScatterOp { float[] apply(float[] a, int ix, int[] b, int iy); } @@ -1372,26 +1348,16 @@ relativeError)); } static float cornerCaseValue(int i) { - switch(i % 7) { - case 0: - return Float.MAX_VALUE; - case 1: - return Float.MIN_VALUE; - case 2: - return Float.NEGATIVE_INFINITY; - case 3: - return Float.POSITIVE_INFINITY; - case 4: - return Float.NaN; - case 5: - return (float)0.0; - default: - return (float)-0.0; - } - } - - static float get(float[] a, int i) { - return (float) a[i]; + return switch(i % 8) { + case 0 -> Float.MAX_VALUE; + case 1 -> Float.MIN_VALUE; + case 2 -> Float.NEGATIVE_INFINITY; + case 3 -> Float.POSITIVE_INFINITY; + case 4 -> Float.NaN; + case 5 -> Float.intBitsToFloat(0x7F812345); + case 6 -> (float)0.0; + default -> (float)-0.0; + }; } static final IntFunction fr = (vl) -> { @@ -2618,22 +2584,23 @@ relativeError)); FloatMaxVectorTests::FIRST_NONZEROReduceMasked, FloatMaxVectorTests::FIRST_NONZEROReduceAllMasked); } - @Test(dataProvider = "floatUnaryOpProvider") - static void withFloatMaxVectorTests(IntFunction fa) { + @Test(dataProvider = "floatBinaryOpProvider") + static void withFloatMaxVectorTests(IntFunction fa, IntFunction fb) { float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - av.withLane((j++ & (SPECIES.length()-1)), (float)(65535+i)).intoArray(r, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) & (SPECIES.length() - 1); } } - for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { - assertInsertArraysEquals(r, a, (float)(65535+i), (j++ & (SPECIES.length()-1)), i , i + SPECIES.length()); - } + assertArraysStrictlyEquals(r, a); } static boolean testIS_DEFAULT(float a) { @@ -3523,7 +3490,7 @@ relativeError)); } } - assertArraysEquals(r, a, FloatMaxVectorTests::get); + assertArraysStrictlyEquals(r, a); } @Test(dataProvider = "floatUnaryOpProvider") diff --git a/test/jdk/jdk/incubator/vector/Int128VectorTests.java b/test/jdk/jdk/incubator/vector/Int128VectorTests.java index 25d656af7da..1ee0bbc3197 100644 --- a/test/jdk/jdk/incubator/vector/Int128VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Int128VectorTests.java @@ -67,6 +67,14 @@ public class Int128VectorTests extends AbstractVectorTest { static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 128); + static void assertArraysStrictlyEquals(int[] r, int[] a) { + for (int i = 0; i < a.length; i++) { + if (r[i] != a[i]) { + Assert.fail("at index #" + i + ", expected = " + a[i] + ", actual = " + r[i]); + } + } + } + interface FUnOp { int apply(int a); } @@ -231,25 +239,6 @@ public class Int128VectorTests extends AbstractVectorTest { } } - static void assertInsertArraysEquals(int[] r, int[] a, int element, int index, int start, int end) { - int i = start; - try { - for (; i < end; i += 1) { - if(i%SPECIES.length() == index) { - Assert.assertEquals(r[i], element); - } else { - Assert.assertEquals(r[i], a[i]); - } - } - } catch (AssertionError e) { - if (i%SPECIES.length() == index) { - Assert.assertEquals(r[i], element, "at index #" + i); - } else { - Assert.assertEquals(r[i], a[i], "at index #" + i); - } - } - } - static void assertRearrangeArraysEquals(int[] r, int[] a, int[] order, int vector_len) { int i = 0, j = 0; try { @@ -704,21 +693,6 @@ public class Int128VectorTests extends AbstractVectorTest { - interface FBinArrayOp { - int apply(int[] a, int b); - } - - static void assertArraysEquals(int[] r, int[] a, FBinArrayOp f) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a, i)); - } - } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a,i), "at index #" + i); - } - } - interface FGatherScatterOp { int[] apply(int[] a, int ix, int[] b, int iy); } @@ -1172,10 +1146,6 @@ public class Int128VectorTests extends AbstractVectorTest { } } - static int get(int[] a, int i) { - return (int) a[i]; - } - static final IntFunction fr = (vl) -> { int length = BUFFER_REPS * vl; return new int[length]; @@ -3792,22 +3762,23 @@ public class Int128VectorTests extends AbstractVectorTest { assertReductionBoolArraysEquals(r, mask, Int128VectorTests::allTrue); } - @Test(dataProvider = "intUnaryOpProvider") - static void withInt128VectorTests(IntFunction fa) { + @Test(dataProvider = "intBinaryOpProvider") + static void withInt128VectorTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - av.withLane((j++ & (SPECIES.length()-1)), (int)(65535+i)).intoArray(r, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) & (SPECIES.length() - 1); } } - for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { - assertInsertArraysEquals(r, a, (int)(65535+i), (j++ & (SPECIES.length()-1)), i , i + SPECIES.length()); - } + assertArraysStrictlyEquals(r, a); } static boolean testIS_DEFAULT(int a) { @@ -4742,7 +4713,7 @@ public class Int128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Int128VectorTests::get); + assertArraysStrictlyEquals(r, a); } @Test(dataProvider = "intUnaryOpProvider") diff --git a/test/jdk/jdk/incubator/vector/Int256VectorTests.java b/test/jdk/jdk/incubator/vector/Int256VectorTests.java index 7420c7842d5..5257af21c94 100644 --- a/test/jdk/jdk/incubator/vector/Int256VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Int256VectorTests.java @@ -67,6 +67,14 @@ public class Int256VectorTests extends AbstractVectorTest { static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 256); + static void assertArraysStrictlyEquals(int[] r, int[] a) { + for (int i = 0; i < a.length; i++) { + if (r[i] != a[i]) { + Assert.fail("at index #" + i + ", expected = " + a[i] + ", actual = " + r[i]); + } + } + } + interface FUnOp { int apply(int a); } @@ -231,25 +239,6 @@ public class Int256VectorTests extends AbstractVectorTest { } } - static void assertInsertArraysEquals(int[] r, int[] a, int element, int index, int start, int end) { - int i = start; - try { - for (; i < end; i += 1) { - if(i%SPECIES.length() == index) { - Assert.assertEquals(r[i], element); - } else { - Assert.assertEquals(r[i], a[i]); - } - } - } catch (AssertionError e) { - if (i%SPECIES.length() == index) { - Assert.assertEquals(r[i], element, "at index #" + i); - } else { - Assert.assertEquals(r[i], a[i], "at index #" + i); - } - } - } - static void assertRearrangeArraysEquals(int[] r, int[] a, int[] order, int vector_len) { int i = 0, j = 0; try { @@ -704,21 +693,6 @@ public class Int256VectorTests extends AbstractVectorTest { - interface FBinArrayOp { - int apply(int[] a, int b); - } - - static void assertArraysEquals(int[] r, int[] a, FBinArrayOp f) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a, i)); - } - } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a,i), "at index #" + i); - } - } - interface FGatherScatterOp { int[] apply(int[] a, int ix, int[] b, int iy); } @@ -1172,10 +1146,6 @@ public class Int256VectorTests extends AbstractVectorTest { } } - static int get(int[] a, int i) { - return (int) a[i]; - } - static final IntFunction fr = (vl) -> { int length = BUFFER_REPS * vl; return new int[length]; @@ -3792,22 +3762,23 @@ public class Int256VectorTests extends AbstractVectorTest { assertReductionBoolArraysEquals(r, mask, Int256VectorTests::allTrue); } - @Test(dataProvider = "intUnaryOpProvider") - static void withInt256VectorTests(IntFunction fa) { + @Test(dataProvider = "intBinaryOpProvider") + static void withInt256VectorTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - av.withLane((j++ & (SPECIES.length()-1)), (int)(65535+i)).intoArray(r, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) & (SPECIES.length() - 1); } } - for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { - assertInsertArraysEquals(r, a, (int)(65535+i), (j++ & (SPECIES.length()-1)), i , i + SPECIES.length()); - } + assertArraysStrictlyEquals(r, a); } static boolean testIS_DEFAULT(int a) { @@ -4742,7 +4713,7 @@ public class Int256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Int256VectorTests::get); + assertArraysStrictlyEquals(r, a); } @Test(dataProvider = "intUnaryOpProvider") diff --git a/test/jdk/jdk/incubator/vector/Int512VectorTests.java b/test/jdk/jdk/incubator/vector/Int512VectorTests.java index ccd2bb7a5c9..6d4633cc7ae 100644 --- a/test/jdk/jdk/incubator/vector/Int512VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Int512VectorTests.java @@ -67,6 +67,14 @@ public class Int512VectorTests extends AbstractVectorTest { static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 512); + static void assertArraysStrictlyEquals(int[] r, int[] a) { + for (int i = 0; i < a.length; i++) { + if (r[i] != a[i]) { + Assert.fail("at index #" + i + ", expected = " + a[i] + ", actual = " + r[i]); + } + } + } + interface FUnOp { int apply(int a); } @@ -231,25 +239,6 @@ public class Int512VectorTests extends AbstractVectorTest { } } - static void assertInsertArraysEquals(int[] r, int[] a, int element, int index, int start, int end) { - int i = start; - try { - for (; i < end; i += 1) { - if(i%SPECIES.length() == index) { - Assert.assertEquals(r[i], element); - } else { - Assert.assertEquals(r[i], a[i]); - } - } - } catch (AssertionError e) { - if (i%SPECIES.length() == index) { - Assert.assertEquals(r[i], element, "at index #" + i); - } else { - Assert.assertEquals(r[i], a[i], "at index #" + i); - } - } - } - static void assertRearrangeArraysEquals(int[] r, int[] a, int[] order, int vector_len) { int i = 0, j = 0; try { @@ -704,21 +693,6 @@ public class Int512VectorTests extends AbstractVectorTest { - interface FBinArrayOp { - int apply(int[] a, int b); - } - - static void assertArraysEquals(int[] r, int[] a, FBinArrayOp f) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a, i)); - } - } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a,i), "at index #" + i); - } - } - interface FGatherScatterOp { int[] apply(int[] a, int ix, int[] b, int iy); } @@ -1172,10 +1146,6 @@ public class Int512VectorTests extends AbstractVectorTest { } } - static int get(int[] a, int i) { - return (int) a[i]; - } - static final IntFunction fr = (vl) -> { int length = BUFFER_REPS * vl; return new int[length]; @@ -3792,22 +3762,23 @@ public class Int512VectorTests extends AbstractVectorTest { assertReductionBoolArraysEquals(r, mask, Int512VectorTests::allTrue); } - @Test(dataProvider = "intUnaryOpProvider") - static void withInt512VectorTests(IntFunction fa) { + @Test(dataProvider = "intBinaryOpProvider") + static void withInt512VectorTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - av.withLane((j++ & (SPECIES.length()-1)), (int)(65535+i)).intoArray(r, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) & (SPECIES.length() - 1); } } - for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { - assertInsertArraysEquals(r, a, (int)(65535+i), (j++ & (SPECIES.length()-1)), i , i + SPECIES.length()); - } + assertArraysStrictlyEquals(r, a); } static boolean testIS_DEFAULT(int a) { @@ -4742,7 +4713,7 @@ public class Int512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Int512VectorTests::get); + assertArraysStrictlyEquals(r, a); } @Test(dataProvider = "intUnaryOpProvider") diff --git a/test/jdk/jdk/incubator/vector/Int64VectorTests.java b/test/jdk/jdk/incubator/vector/Int64VectorTests.java index 26201745ad4..7bd1543ed5c 100644 --- a/test/jdk/jdk/incubator/vector/Int64VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Int64VectorTests.java @@ -67,6 +67,14 @@ public class Int64VectorTests extends AbstractVectorTest { static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 64); + static void assertArraysStrictlyEquals(int[] r, int[] a) { + for (int i = 0; i < a.length; i++) { + if (r[i] != a[i]) { + Assert.fail("at index #" + i + ", expected = " + a[i] + ", actual = " + r[i]); + } + } + } + interface FUnOp { int apply(int a); } @@ -231,25 +239,6 @@ public class Int64VectorTests extends AbstractVectorTest { } } - static void assertInsertArraysEquals(int[] r, int[] a, int element, int index, int start, int end) { - int i = start; - try { - for (; i < end; i += 1) { - if(i%SPECIES.length() == index) { - Assert.assertEquals(r[i], element); - } else { - Assert.assertEquals(r[i], a[i]); - } - } - } catch (AssertionError e) { - if (i%SPECIES.length() == index) { - Assert.assertEquals(r[i], element, "at index #" + i); - } else { - Assert.assertEquals(r[i], a[i], "at index #" + i); - } - } - } - static void assertRearrangeArraysEquals(int[] r, int[] a, int[] order, int vector_len) { int i = 0, j = 0; try { @@ -704,21 +693,6 @@ public class Int64VectorTests extends AbstractVectorTest { - interface FBinArrayOp { - int apply(int[] a, int b); - } - - static void assertArraysEquals(int[] r, int[] a, FBinArrayOp f) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a, i)); - } - } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a,i), "at index #" + i); - } - } - interface FGatherScatterOp { int[] apply(int[] a, int ix, int[] b, int iy); } @@ -1172,10 +1146,6 @@ public class Int64VectorTests extends AbstractVectorTest { } } - static int get(int[] a, int i) { - return (int) a[i]; - } - static final IntFunction fr = (vl) -> { int length = BUFFER_REPS * vl; return new int[length]; @@ -3792,22 +3762,23 @@ public class Int64VectorTests extends AbstractVectorTest { assertReductionBoolArraysEquals(r, mask, Int64VectorTests::allTrue); } - @Test(dataProvider = "intUnaryOpProvider") - static void withInt64VectorTests(IntFunction fa) { + @Test(dataProvider = "intBinaryOpProvider") + static void withInt64VectorTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - av.withLane((j++ & (SPECIES.length()-1)), (int)(65535+i)).intoArray(r, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) & (SPECIES.length() - 1); } } - for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { - assertInsertArraysEquals(r, a, (int)(65535+i), (j++ & (SPECIES.length()-1)), i , i + SPECIES.length()); - } + assertArraysStrictlyEquals(r, a); } static boolean testIS_DEFAULT(int a) { @@ -4742,7 +4713,7 @@ public class Int64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Int64VectorTests::get); + assertArraysStrictlyEquals(r, a); } @Test(dataProvider = "intUnaryOpProvider") diff --git a/test/jdk/jdk/incubator/vector/IntMaxVectorTests.java b/test/jdk/jdk/incubator/vector/IntMaxVectorTests.java index 612dc5080e2..71d1ce594f9 100644 --- a/test/jdk/jdk/incubator/vector/IntMaxVectorTests.java +++ b/test/jdk/jdk/incubator/vector/IntMaxVectorTests.java @@ -72,6 +72,14 @@ public class IntMaxVectorTests extends AbstractVectorTest { static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / Max); + static void assertArraysStrictlyEquals(int[] r, int[] a) { + for (int i = 0; i < a.length; i++) { + if (r[i] != a[i]) { + Assert.fail("at index #" + i + ", expected = " + a[i] + ", actual = " + r[i]); + } + } + } + interface FUnOp { int apply(int a); } @@ -236,25 +244,6 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - static void assertInsertArraysEquals(int[] r, int[] a, int element, int index, int start, int end) { - int i = start; - try { - for (; i < end; i += 1) { - if(i%SPECIES.length() == index) { - Assert.assertEquals(r[i], element); - } else { - Assert.assertEquals(r[i], a[i]); - } - } - } catch (AssertionError e) { - if (i%SPECIES.length() == index) { - Assert.assertEquals(r[i], element, "at index #" + i); - } else { - Assert.assertEquals(r[i], a[i], "at index #" + i); - } - } - } - static void assertRearrangeArraysEquals(int[] r, int[] a, int[] order, int vector_len) { int i = 0, j = 0; try { @@ -709,21 +698,6 @@ public class IntMaxVectorTests extends AbstractVectorTest { - interface FBinArrayOp { - int apply(int[] a, int b); - } - - static void assertArraysEquals(int[] r, int[] a, FBinArrayOp f) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a, i)); - } - } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a,i), "at index #" + i); - } - } - interface FGatherScatterOp { int[] apply(int[] a, int ix, int[] b, int iy); } @@ -1177,10 +1151,6 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - static int get(int[] a, int i) { - return (int) a[i]; - } - static final IntFunction fr = (vl) -> { int length = BUFFER_REPS * vl; return new int[length]; @@ -3797,22 +3767,23 @@ public class IntMaxVectorTests extends AbstractVectorTest { assertReductionBoolArraysEquals(r, mask, IntMaxVectorTests::allTrue); } - @Test(dataProvider = "intUnaryOpProvider") - static void withIntMaxVectorTests(IntFunction fa) { + @Test(dataProvider = "intBinaryOpProvider") + static void withIntMaxVectorTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - av.withLane((j++ & (SPECIES.length()-1)), (int)(65535+i)).intoArray(r, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) & (SPECIES.length() - 1); } } - for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { - assertInsertArraysEquals(r, a, (int)(65535+i), (j++ & (SPECIES.length()-1)), i , i + SPECIES.length()); - } + assertArraysStrictlyEquals(r, a); } static boolean testIS_DEFAULT(int a) { @@ -4747,7 +4718,7 @@ public class IntMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, IntMaxVectorTests::get); + assertArraysStrictlyEquals(r, a); } @Test(dataProvider = "intUnaryOpProvider") diff --git a/test/jdk/jdk/incubator/vector/Long128VectorTests.java b/test/jdk/jdk/incubator/vector/Long128VectorTests.java index 5ebc7f2c673..bcec2dee9fe 100644 --- a/test/jdk/jdk/incubator/vector/Long128VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Long128VectorTests.java @@ -67,6 +67,14 @@ public class Long128VectorTests extends AbstractVectorTest { static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 128); + static void assertArraysStrictlyEquals(long[] r, long[] a) { + for (int i = 0; i < a.length; i++) { + if (r[i] != a[i]) { + Assert.fail("at index #" + i + ", expected = " + a[i] + ", actual = " + r[i]); + } + } + } + interface FUnOp { long apply(long a); } @@ -188,25 +196,6 @@ public class Long128VectorTests extends AbstractVectorTest { } } - static void assertInsertArraysEquals(long[] r, long[] a, long element, int index, int start, int end) { - int i = start; - try { - for (; i < end; i += 1) { - if(i%SPECIES.length() == index) { - Assert.assertEquals(r[i], element); - } else { - Assert.assertEquals(r[i], a[i]); - } - } - } catch (AssertionError e) { - if (i%SPECIES.length() == index) { - Assert.assertEquals(r[i], element, "at index #" + i); - } else { - Assert.assertEquals(r[i], a[i], "at index #" + i); - } - } - } - static void assertRearrangeArraysEquals(long[] r, long[] a, int[] order, int vector_len) { int i = 0, j = 0; try { @@ -661,21 +650,6 @@ public class Long128VectorTests extends AbstractVectorTest { - interface FBinArrayOp { - long apply(long[] a, int b); - } - - static void assertArraysEquals(long[] r, long[] a, FBinArrayOp f) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a, i)); - } - } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a,i), "at index #" + i); - } - } - interface FGatherScatterOp { long[] apply(long[] a, int ix, int[] b, int iy); } @@ -1199,10 +1173,6 @@ public class Long128VectorTests extends AbstractVectorTest { } } - static long get(long[] a, int i) { - return (long) a[i]; - } - static final IntFunction fr = (vl) -> { int length = BUFFER_REPS * vl; return new long[length]; @@ -3814,22 +3784,23 @@ public class Long128VectorTests extends AbstractVectorTest { assertReductionBoolArraysEquals(r, mask, Long128VectorTests::allTrue); } - @Test(dataProvider = "longUnaryOpProvider") - static void withLong128VectorTests(IntFunction fa) { + @Test(dataProvider = "longBinaryOpProvider") + static void withLong128VectorTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - av.withLane((j++ & (SPECIES.length()-1)), (long)(65535+i)).intoArray(r, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) & (SPECIES.length() - 1); } } - for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { - assertInsertArraysEquals(r, a, (long)(65535+i), (j++ & (SPECIES.length()-1)), i , i + SPECIES.length()); - } + assertArraysStrictlyEquals(r, a); } static boolean testIS_DEFAULT(long a) { @@ -4694,7 +4665,7 @@ public class Long128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Long128VectorTests::get); + assertArraysStrictlyEquals(r, a); } @Test(dataProvider = "longUnaryOpProvider") diff --git a/test/jdk/jdk/incubator/vector/Long256VectorTests.java b/test/jdk/jdk/incubator/vector/Long256VectorTests.java index b7b66008917..e8f2fb1301c 100644 --- a/test/jdk/jdk/incubator/vector/Long256VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Long256VectorTests.java @@ -67,6 +67,14 @@ public class Long256VectorTests extends AbstractVectorTest { static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 256); + static void assertArraysStrictlyEquals(long[] r, long[] a) { + for (int i = 0; i < a.length; i++) { + if (r[i] != a[i]) { + Assert.fail("at index #" + i + ", expected = " + a[i] + ", actual = " + r[i]); + } + } + } + interface FUnOp { long apply(long a); } @@ -188,25 +196,6 @@ public class Long256VectorTests extends AbstractVectorTest { } } - static void assertInsertArraysEquals(long[] r, long[] a, long element, int index, int start, int end) { - int i = start; - try { - for (; i < end; i += 1) { - if(i%SPECIES.length() == index) { - Assert.assertEquals(r[i], element); - } else { - Assert.assertEquals(r[i], a[i]); - } - } - } catch (AssertionError e) { - if (i%SPECIES.length() == index) { - Assert.assertEquals(r[i], element, "at index #" + i); - } else { - Assert.assertEquals(r[i], a[i], "at index #" + i); - } - } - } - static void assertRearrangeArraysEquals(long[] r, long[] a, int[] order, int vector_len) { int i = 0, j = 0; try { @@ -661,21 +650,6 @@ public class Long256VectorTests extends AbstractVectorTest { - interface FBinArrayOp { - long apply(long[] a, int b); - } - - static void assertArraysEquals(long[] r, long[] a, FBinArrayOp f) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a, i)); - } - } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a,i), "at index #" + i); - } - } - interface FGatherScatterOp { long[] apply(long[] a, int ix, int[] b, int iy); } @@ -1199,10 +1173,6 @@ public class Long256VectorTests extends AbstractVectorTest { } } - static long get(long[] a, int i) { - return (long) a[i]; - } - static final IntFunction fr = (vl) -> { int length = BUFFER_REPS * vl; return new long[length]; @@ -3814,22 +3784,23 @@ public class Long256VectorTests extends AbstractVectorTest { assertReductionBoolArraysEquals(r, mask, Long256VectorTests::allTrue); } - @Test(dataProvider = "longUnaryOpProvider") - static void withLong256VectorTests(IntFunction fa) { + @Test(dataProvider = "longBinaryOpProvider") + static void withLong256VectorTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - av.withLane((j++ & (SPECIES.length()-1)), (long)(65535+i)).intoArray(r, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) & (SPECIES.length() - 1); } } - for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { - assertInsertArraysEquals(r, a, (long)(65535+i), (j++ & (SPECIES.length()-1)), i , i + SPECIES.length()); - } + assertArraysStrictlyEquals(r, a); } static boolean testIS_DEFAULT(long a) { @@ -4694,7 +4665,7 @@ public class Long256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Long256VectorTests::get); + assertArraysStrictlyEquals(r, a); } @Test(dataProvider = "longUnaryOpProvider") diff --git a/test/jdk/jdk/incubator/vector/Long512VectorTests.java b/test/jdk/jdk/incubator/vector/Long512VectorTests.java index 65edac9114c..022f1490fcc 100644 --- a/test/jdk/jdk/incubator/vector/Long512VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Long512VectorTests.java @@ -67,6 +67,14 @@ public class Long512VectorTests extends AbstractVectorTest { static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 512); + static void assertArraysStrictlyEquals(long[] r, long[] a) { + for (int i = 0; i < a.length; i++) { + if (r[i] != a[i]) { + Assert.fail("at index #" + i + ", expected = " + a[i] + ", actual = " + r[i]); + } + } + } + interface FUnOp { long apply(long a); } @@ -188,25 +196,6 @@ public class Long512VectorTests extends AbstractVectorTest { } } - static void assertInsertArraysEquals(long[] r, long[] a, long element, int index, int start, int end) { - int i = start; - try { - for (; i < end; i += 1) { - if(i%SPECIES.length() == index) { - Assert.assertEquals(r[i], element); - } else { - Assert.assertEquals(r[i], a[i]); - } - } - } catch (AssertionError e) { - if (i%SPECIES.length() == index) { - Assert.assertEquals(r[i], element, "at index #" + i); - } else { - Assert.assertEquals(r[i], a[i], "at index #" + i); - } - } - } - static void assertRearrangeArraysEquals(long[] r, long[] a, int[] order, int vector_len) { int i = 0, j = 0; try { @@ -661,21 +650,6 @@ public class Long512VectorTests extends AbstractVectorTest { - interface FBinArrayOp { - long apply(long[] a, int b); - } - - static void assertArraysEquals(long[] r, long[] a, FBinArrayOp f) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a, i)); - } - } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a,i), "at index #" + i); - } - } - interface FGatherScatterOp { long[] apply(long[] a, int ix, int[] b, int iy); } @@ -1199,10 +1173,6 @@ public class Long512VectorTests extends AbstractVectorTest { } } - static long get(long[] a, int i) { - return (long) a[i]; - } - static final IntFunction fr = (vl) -> { int length = BUFFER_REPS * vl; return new long[length]; @@ -3814,22 +3784,23 @@ public class Long512VectorTests extends AbstractVectorTest { assertReductionBoolArraysEquals(r, mask, Long512VectorTests::allTrue); } - @Test(dataProvider = "longUnaryOpProvider") - static void withLong512VectorTests(IntFunction fa) { + @Test(dataProvider = "longBinaryOpProvider") + static void withLong512VectorTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - av.withLane((j++ & (SPECIES.length()-1)), (long)(65535+i)).intoArray(r, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) & (SPECIES.length() - 1); } } - for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { - assertInsertArraysEquals(r, a, (long)(65535+i), (j++ & (SPECIES.length()-1)), i , i + SPECIES.length()); - } + assertArraysStrictlyEquals(r, a); } static boolean testIS_DEFAULT(long a) { @@ -4694,7 +4665,7 @@ public class Long512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Long512VectorTests::get); + assertArraysStrictlyEquals(r, a); } @Test(dataProvider = "longUnaryOpProvider") diff --git a/test/jdk/jdk/incubator/vector/Long64VectorTests.java b/test/jdk/jdk/incubator/vector/Long64VectorTests.java index 7b1c65716aa..fe886bf93d8 100644 --- a/test/jdk/jdk/incubator/vector/Long64VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Long64VectorTests.java @@ -67,6 +67,14 @@ public class Long64VectorTests extends AbstractVectorTest { static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 64); + static void assertArraysStrictlyEquals(long[] r, long[] a) { + for (int i = 0; i < a.length; i++) { + if (r[i] != a[i]) { + Assert.fail("at index #" + i + ", expected = " + a[i] + ", actual = " + r[i]); + } + } + } + interface FUnOp { long apply(long a); } @@ -188,25 +196,6 @@ public class Long64VectorTests extends AbstractVectorTest { } } - static void assertInsertArraysEquals(long[] r, long[] a, long element, int index, int start, int end) { - int i = start; - try { - for (; i < end; i += 1) { - if(i%SPECIES.length() == index) { - Assert.assertEquals(r[i], element); - } else { - Assert.assertEquals(r[i], a[i]); - } - } - } catch (AssertionError e) { - if (i%SPECIES.length() == index) { - Assert.assertEquals(r[i], element, "at index #" + i); - } else { - Assert.assertEquals(r[i], a[i], "at index #" + i); - } - } - } - static void assertRearrangeArraysEquals(long[] r, long[] a, int[] order, int vector_len) { int i = 0, j = 0; try { @@ -661,21 +650,6 @@ public class Long64VectorTests extends AbstractVectorTest { - interface FBinArrayOp { - long apply(long[] a, int b); - } - - static void assertArraysEquals(long[] r, long[] a, FBinArrayOp f) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a, i)); - } - } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a,i), "at index #" + i); - } - } - interface FGatherScatterOp { long[] apply(long[] a, int ix, int[] b, int iy); } @@ -1199,10 +1173,6 @@ public class Long64VectorTests extends AbstractVectorTest { } } - static long get(long[] a, int i) { - return (long) a[i]; - } - static final IntFunction fr = (vl) -> { int length = BUFFER_REPS * vl; return new long[length]; @@ -3814,22 +3784,23 @@ public class Long64VectorTests extends AbstractVectorTest { assertReductionBoolArraysEquals(r, mask, Long64VectorTests::allTrue); } - @Test(dataProvider = "longUnaryOpProvider") - static void withLong64VectorTests(IntFunction fa) { + @Test(dataProvider = "longBinaryOpProvider") + static void withLong64VectorTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - av.withLane((j++ & (SPECIES.length()-1)), (long)(65535+i)).intoArray(r, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) & (SPECIES.length() - 1); } } - for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { - assertInsertArraysEquals(r, a, (long)(65535+i), (j++ & (SPECIES.length()-1)), i , i + SPECIES.length()); - } + assertArraysStrictlyEquals(r, a); } static boolean testIS_DEFAULT(long a) { @@ -4694,7 +4665,7 @@ public class Long64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Long64VectorTests::get); + assertArraysStrictlyEquals(r, a); } @Test(dataProvider = "longUnaryOpProvider") diff --git a/test/jdk/jdk/incubator/vector/LongMaxVectorTests.java b/test/jdk/jdk/incubator/vector/LongMaxVectorTests.java index 06f5814e533..b77d6eeb118 100644 --- a/test/jdk/jdk/incubator/vector/LongMaxVectorTests.java +++ b/test/jdk/jdk/incubator/vector/LongMaxVectorTests.java @@ -72,6 +72,14 @@ public class LongMaxVectorTests extends AbstractVectorTest { static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / Max); + static void assertArraysStrictlyEquals(long[] r, long[] a) { + for (int i = 0; i < a.length; i++) { + if (r[i] != a[i]) { + Assert.fail("at index #" + i + ", expected = " + a[i] + ", actual = " + r[i]); + } + } + } + interface FUnOp { long apply(long a); } @@ -193,25 +201,6 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - static void assertInsertArraysEquals(long[] r, long[] a, long element, int index, int start, int end) { - int i = start; - try { - for (; i < end; i += 1) { - if(i%SPECIES.length() == index) { - Assert.assertEquals(r[i], element); - } else { - Assert.assertEquals(r[i], a[i]); - } - } - } catch (AssertionError e) { - if (i%SPECIES.length() == index) { - Assert.assertEquals(r[i], element, "at index #" + i); - } else { - Assert.assertEquals(r[i], a[i], "at index #" + i); - } - } - } - static void assertRearrangeArraysEquals(long[] r, long[] a, int[] order, int vector_len) { int i = 0, j = 0; try { @@ -666,21 +655,6 @@ public class LongMaxVectorTests extends AbstractVectorTest { - interface FBinArrayOp { - long apply(long[] a, int b); - } - - static void assertArraysEquals(long[] r, long[] a, FBinArrayOp f) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a, i)); - } - } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a,i), "at index #" + i); - } - } - interface FGatherScatterOp { long[] apply(long[] a, int ix, int[] b, int iy); } @@ -1204,10 +1178,6 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - static long get(long[] a, int i) { - return (long) a[i]; - } - static final IntFunction fr = (vl) -> { int length = BUFFER_REPS * vl; return new long[length]; @@ -3819,22 +3789,23 @@ public class LongMaxVectorTests extends AbstractVectorTest { assertReductionBoolArraysEquals(r, mask, LongMaxVectorTests::allTrue); } - @Test(dataProvider = "longUnaryOpProvider") - static void withLongMaxVectorTests(IntFunction fa) { + @Test(dataProvider = "longBinaryOpProvider") + static void withLongMaxVectorTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - av.withLane((j++ & (SPECIES.length()-1)), (long)(65535+i)).intoArray(r, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) & (SPECIES.length() - 1); } } - for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { - assertInsertArraysEquals(r, a, (long)(65535+i), (j++ & (SPECIES.length()-1)), i , i + SPECIES.length()); - } + assertArraysStrictlyEquals(r, a); } static boolean testIS_DEFAULT(long a) { @@ -4699,7 +4670,7 @@ public class LongMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, LongMaxVectorTests::get); + assertArraysStrictlyEquals(r, a); } @Test(dataProvider = "longUnaryOpProvider") diff --git a/test/jdk/jdk/incubator/vector/Short128VectorTests.java b/test/jdk/jdk/incubator/vector/Short128VectorTests.java index c9fe21f8125..2a82ada044e 100644 --- a/test/jdk/jdk/incubator/vector/Short128VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Short128VectorTests.java @@ -67,6 +67,14 @@ public class Short128VectorTests extends AbstractVectorTest { static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 128); + static void assertArraysStrictlyEquals(short[] r, short[] a) { + for (int i = 0; i < a.length; i++) { + if (r[i] != a[i]) { + Assert.fail("at index #" + i + ", expected = " + a[i] + ", actual = " + r[i]); + } + } + } + interface FUnOp { short apply(short a); } @@ -231,25 +239,6 @@ public class Short128VectorTests extends AbstractVectorTest { } } - static void assertInsertArraysEquals(short[] r, short[] a, short element, int index, int start, int end) { - int i = start; - try { - for (; i < end; i += 1) { - if(i%SPECIES.length() == index) { - Assert.assertEquals(r[i], element); - } else { - Assert.assertEquals(r[i], a[i]); - } - } - } catch (AssertionError e) { - if (i%SPECIES.length() == index) { - Assert.assertEquals(r[i], element, "at index #" + i); - } else { - Assert.assertEquals(r[i], a[i], "at index #" + i); - } - } - } - static void assertRearrangeArraysEquals(short[] r, short[] a, int[] order, int vector_len) { int i = 0, j = 0; try { @@ -704,21 +693,6 @@ public class Short128VectorTests extends AbstractVectorTest { - interface FBinArrayOp { - short apply(short[] a, int b); - } - - static void assertArraysEquals(short[] r, short[] a, FBinArrayOp f) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a, i)); - } - } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a,i), "at index #" + i); - } - } - interface FGatherScatterOp { short[] apply(short[] a, int ix, int[] b, int iy); } @@ -1202,10 +1176,6 @@ public class Short128VectorTests extends AbstractVectorTest { } } - static short get(short[] a, int i) { - return (short) a[i]; - } - static final IntFunction fr = (vl) -> { int length = BUFFER_REPS * vl; return new short[length]; @@ -3739,22 +3709,23 @@ public class Short128VectorTests extends AbstractVectorTest { assertReductionBoolArraysEquals(r, mask, Short128VectorTests::allTrue); } - @Test(dataProvider = "shortUnaryOpProvider") - static void withShort128VectorTests(IntFunction fa) { + @Test(dataProvider = "shortBinaryOpProvider") + static void withShort128VectorTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - av.withLane((j++ & (SPECIES.length()-1)), (short)(65535+i)).intoArray(r, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) & (SPECIES.length() - 1); } } - for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { - assertInsertArraysEquals(r, a, (short)(65535+i), (j++ & (SPECIES.length()-1)), i , i + SPECIES.length()); - } + assertArraysStrictlyEquals(r, a); } static boolean testIS_DEFAULT(short a) { @@ -4689,7 +4660,7 @@ public class Short128VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Short128VectorTests::get); + assertArraysStrictlyEquals(r, a); } @Test(dataProvider = "shortUnaryOpProvider") diff --git a/test/jdk/jdk/incubator/vector/Short256VectorTests.java b/test/jdk/jdk/incubator/vector/Short256VectorTests.java index a39ec0126d4..69a8432acef 100644 --- a/test/jdk/jdk/incubator/vector/Short256VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Short256VectorTests.java @@ -67,6 +67,14 @@ public class Short256VectorTests extends AbstractVectorTest { static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 256); + static void assertArraysStrictlyEquals(short[] r, short[] a) { + for (int i = 0; i < a.length; i++) { + if (r[i] != a[i]) { + Assert.fail("at index #" + i + ", expected = " + a[i] + ", actual = " + r[i]); + } + } + } + interface FUnOp { short apply(short a); } @@ -231,25 +239,6 @@ public class Short256VectorTests extends AbstractVectorTest { } } - static void assertInsertArraysEquals(short[] r, short[] a, short element, int index, int start, int end) { - int i = start; - try { - for (; i < end; i += 1) { - if(i%SPECIES.length() == index) { - Assert.assertEquals(r[i], element); - } else { - Assert.assertEquals(r[i], a[i]); - } - } - } catch (AssertionError e) { - if (i%SPECIES.length() == index) { - Assert.assertEquals(r[i], element, "at index #" + i); - } else { - Assert.assertEquals(r[i], a[i], "at index #" + i); - } - } - } - static void assertRearrangeArraysEquals(short[] r, short[] a, int[] order, int vector_len) { int i = 0, j = 0; try { @@ -704,21 +693,6 @@ public class Short256VectorTests extends AbstractVectorTest { - interface FBinArrayOp { - short apply(short[] a, int b); - } - - static void assertArraysEquals(short[] r, short[] a, FBinArrayOp f) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a, i)); - } - } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a,i), "at index #" + i); - } - } - interface FGatherScatterOp { short[] apply(short[] a, int ix, int[] b, int iy); } @@ -1202,10 +1176,6 @@ public class Short256VectorTests extends AbstractVectorTest { } } - static short get(short[] a, int i) { - return (short) a[i]; - } - static final IntFunction fr = (vl) -> { int length = BUFFER_REPS * vl; return new short[length]; @@ -3739,22 +3709,23 @@ public class Short256VectorTests extends AbstractVectorTest { assertReductionBoolArraysEquals(r, mask, Short256VectorTests::allTrue); } - @Test(dataProvider = "shortUnaryOpProvider") - static void withShort256VectorTests(IntFunction fa) { + @Test(dataProvider = "shortBinaryOpProvider") + static void withShort256VectorTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - av.withLane((j++ & (SPECIES.length()-1)), (short)(65535+i)).intoArray(r, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) & (SPECIES.length() - 1); } } - for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { - assertInsertArraysEquals(r, a, (short)(65535+i), (j++ & (SPECIES.length()-1)), i , i + SPECIES.length()); - } + assertArraysStrictlyEquals(r, a); } static boolean testIS_DEFAULT(short a) { @@ -4689,7 +4660,7 @@ public class Short256VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Short256VectorTests::get); + assertArraysStrictlyEquals(r, a); } @Test(dataProvider = "shortUnaryOpProvider") diff --git a/test/jdk/jdk/incubator/vector/Short512VectorTests.java b/test/jdk/jdk/incubator/vector/Short512VectorTests.java index 5453c19149c..8e892a8a48e 100644 --- a/test/jdk/jdk/incubator/vector/Short512VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Short512VectorTests.java @@ -67,6 +67,14 @@ public class Short512VectorTests extends AbstractVectorTest { static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 512); + static void assertArraysStrictlyEquals(short[] r, short[] a) { + for (int i = 0; i < a.length; i++) { + if (r[i] != a[i]) { + Assert.fail("at index #" + i + ", expected = " + a[i] + ", actual = " + r[i]); + } + } + } + interface FUnOp { short apply(short a); } @@ -231,25 +239,6 @@ public class Short512VectorTests extends AbstractVectorTest { } } - static void assertInsertArraysEquals(short[] r, short[] a, short element, int index, int start, int end) { - int i = start; - try { - for (; i < end; i += 1) { - if(i%SPECIES.length() == index) { - Assert.assertEquals(r[i], element); - } else { - Assert.assertEquals(r[i], a[i]); - } - } - } catch (AssertionError e) { - if (i%SPECIES.length() == index) { - Assert.assertEquals(r[i], element, "at index #" + i); - } else { - Assert.assertEquals(r[i], a[i], "at index #" + i); - } - } - } - static void assertRearrangeArraysEquals(short[] r, short[] a, int[] order, int vector_len) { int i = 0, j = 0; try { @@ -704,21 +693,6 @@ public class Short512VectorTests extends AbstractVectorTest { - interface FBinArrayOp { - short apply(short[] a, int b); - } - - static void assertArraysEquals(short[] r, short[] a, FBinArrayOp f) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a, i)); - } - } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a,i), "at index #" + i); - } - } - interface FGatherScatterOp { short[] apply(short[] a, int ix, int[] b, int iy); } @@ -1202,10 +1176,6 @@ public class Short512VectorTests extends AbstractVectorTest { } } - static short get(short[] a, int i) { - return (short) a[i]; - } - static final IntFunction fr = (vl) -> { int length = BUFFER_REPS * vl; return new short[length]; @@ -3739,22 +3709,23 @@ public class Short512VectorTests extends AbstractVectorTest { assertReductionBoolArraysEquals(r, mask, Short512VectorTests::allTrue); } - @Test(dataProvider = "shortUnaryOpProvider") - static void withShort512VectorTests(IntFunction fa) { + @Test(dataProvider = "shortBinaryOpProvider") + static void withShort512VectorTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - av.withLane((j++ & (SPECIES.length()-1)), (short)(65535+i)).intoArray(r, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) & (SPECIES.length() - 1); } } - for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { - assertInsertArraysEquals(r, a, (short)(65535+i), (j++ & (SPECIES.length()-1)), i , i + SPECIES.length()); - } + assertArraysStrictlyEquals(r, a); } static boolean testIS_DEFAULT(short a) { @@ -4689,7 +4660,7 @@ public class Short512VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Short512VectorTests::get); + assertArraysStrictlyEquals(r, a); } @Test(dataProvider = "shortUnaryOpProvider") diff --git a/test/jdk/jdk/incubator/vector/Short64VectorTests.java b/test/jdk/jdk/incubator/vector/Short64VectorTests.java index 8ba47569595..97658d4257d 100644 --- a/test/jdk/jdk/incubator/vector/Short64VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Short64VectorTests.java @@ -67,6 +67,14 @@ public class Short64VectorTests extends AbstractVectorTest { static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 64); + static void assertArraysStrictlyEquals(short[] r, short[] a) { + for (int i = 0; i < a.length; i++) { + if (r[i] != a[i]) { + Assert.fail("at index #" + i + ", expected = " + a[i] + ", actual = " + r[i]); + } + } + } + interface FUnOp { short apply(short a); } @@ -231,25 +239,6 @@ public class Short64VectorTests extends AbstractVectorTest { } } - static void assertInsertArraysEquals(short[] r, short[] a, short element, int index, int start, int end) { - int i = start; - try { - for (; i < end; i += 1) { - if(i%SPECIES.length() == index) { - Assert.assertEquals(r[i], element); - } else { - Assert.assertEquals(r[i], a[i]); - } - } - } catch (AssertionError e) { - if (i%SPECIES.length() == index) { - Assert.assertEquals(r[i], element, "at index #" + i); - } else { - Assert.assertEquals(r[i], a[i], "at index #" + i); - } - } - } - static void assertRearrangeArraysEquals(short[] r, short[] a, int[] order, int vector_len) { int i = 0, j = 0; try { @@ -704,21 +693,6 @@ public class Short64VectorTests extends AbstractVectorTest { - interface FBinArrayOp { - short apply(short[] a, int b); - } - - static void assertArraysEquals(short[] r, short[] a, FBinArrayOp f) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a, i)); - } - } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a,i), "at index #" + i); - } - } - interface FGatherScatterOp { short[] apply(short[] a, int ix, int[] b, int iy); } @@ -1202,10 +1176,6 @@ public class Short64VectorTests extends AbstractVectorTest { } } - static short get(short[] a, int i) { - return (short) a[i]; - } - static final IntFunction fr = (vl) -> { int length = BUFFER_REPS * vl; return new short[length]; @@ -3739,22 +3709,23 @@ public class Short64VectorTests extends AbstractVectorTest { assertReductionBoolArraysEquals(r, mask, Short64VectorTests::allTrue); } - @Test(dataProvider = "shortUnaryOpProvider") - static void withShort64VectorTests(IntFunction fa) { + @Test(dataProvider = "shortBinaryOpProvider") + static void withShort64VectorTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - av.withLane((j++ & (SPECIES.length()-1)), (short)(65535+i)).intoArray(r, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) & (SPECIES.length() - 1); } } - for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { - assertInsertArraysEquals(r, a, (short)(65535+i), (j++ & (SPECIES.length()-1)), i , i + SPECIES.length()); - } + assertArraysStrictlyEquals(r, a); } static boolean testIS_DEFAULT(short a) { @@ -4689,7 +4660,7 @@ public class Short64VectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, Short64VectorTests::get); + assertArraysStrictlyEquals(r, a); } @Test(dataProvider = "shortUnaryOpProvider") diff --git a/test/jdk/jdk/incubator/vector/ShortMaxVectorTests.java b/test/jdk/jdk/incubator/vector/ShortMaxVectorTests.java index 7b00638878d..0857c13ef3c 100644 --- a/test/jdk/jdk/incubator/vector/ShortMaxVectorTests.java +++ b/test/jdk/jdk/incubator/vector/ShortMaxVectorTests.java @@ -72,6 +72,14 @@ public class ShortMaxVectorTests extends AbstractVectorTest { static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / Max); + static void assertArraysStrictlyEquals(short[] r, short[] a) { + for (int i = 0; i < a.length; i++) { + if (r[i] != a[i]) { + Assert.fail("at index #" + i + ", expected = " + a[i] + ", actual = " + r[i]); + } + } + } + interface FUnOp { short apply(short a); } @@ -236,25 +244,6 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - static void assertInsertArraysEquals(short[] r, short[] a, short element, int index, int start, int end) { - int i = start; - try { - for (; i < end; i += 1) { - if(i%SPECIES.length() == index) { - Assert.assertEquals(r[i], element); - } else { - Assert.assertEquals(r[i], a[i]); - } - } - } catch (AssertionError e) { - if (i%SPECIES.length() == index) { - Assert.assertEquals(r[i], element, "at index #" + i); - } else { - Assert.assertEquals(r[i], a[i], "at index #" + i); - } - } - } - static void assertRearrangeArraysEquals(short[] r, short[] a, int[] order, int vector_len) { int i = 0, j = 0; try { @@ -709,21 +698,6 @@ public class ShortMaxVectorTests extends AbstractVectorTest { - interface FBinArrayOp { - short apply(short[] a, int b); - } - - static void assertArraysEquals(short[] r, short[] a, FBinArrayOp f) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a, i)); - } - } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a,i), "at index #" + i); - } - } - interface FGatherScatterOp { short[] apply(short[] a, int ix, int[] b, int iy); } @@ -1207,10 +1181,6 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - static short get(short[] a, int i) { - return (short) a[i]; - } - static final IntFunction fr = (vl) -> { int length = BUFFER_REPS * vl; return new short[length]; @@ -3744,22 +3714,23 @@ public class ShortMaxVectorTests extends AbstractVectorTest { assertReductionBoolArraysEquals(r, mask, ShortMaxVectorTests::allTrue); } - @Test(dataProvider = "shortUnaryOpProvider") - static void withShortMaxVectorTests(IntFunction fa) { + @Test(dataProvider = "shortBinaryOpProvider") + static void withShortMaxVectorTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - av.withLane((j++ & (SPECIES.length()-1)), (short)(65535+i)).intoArray(r, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) & (SPECIES.length() - 1); } } - for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { - assertInsertArraysEquals(r, a, (short)(65535+i), (j++ & (SPECIES.length()-1)), i , i + SPECIES.length()); - } + assertArraysStrictlyEquals(r, a); } static boolean testIS_DEFAULT(short a) { @@ -4694,7 +4665,7 @@ public class ShortMaxVectorTests extends AbstractVectorTest { } } - assertArraysEquals(r, a, ShortMaxVectorTests::get); + assertArraysStrictlyEquals(r, a); } @Test(dataProvider = "shortUnaryOpProvider") diff --git a/test/jdk/jdk/incubator/vector/templates/Kernel-With-Op.template b/test/jdk/jdk/incubator/vector/templates/Kernel-With-Op.template index 95d74b84860..261535317c6 100644 --- a/test/jdk/jdk/incubator/vector/templates/Kernel-With-Op.template +++ b/test/jdk/jdk/incubator/vector/templates/Kernel-With-Op.template @@ -1,10 +1,13 @@ $type$[] a = fa.apply(SPECIES.length()); + $type$[] b = fb.apply(SPECIES.length()); $type$[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { $abstractvectortype$ av = $abstractvectortype$.fromArray(SPECIES, a, i); - av.withLane((j++ \& (SPECIES.length()-1)), ($type$)(65535+i)).intoArray(r, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) \& (SPECIES.length() - 1); } } diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Get-op.template b/test/jdk/jdk/incubator/vector/templates/Unit-Get-op.template index ec311693f4c..b60ff50076e 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Get-op.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Get-op.template @@ -2,5 +2,5 @@ @Test(dataProvider = "$type$UnaryOpProvider") static void get$vectorteststype$(IntFunction<$type$[]> fa) { [[KERNEL]] - assertArraysEquals(r, a, $vectorteststype$::get); + assertArraysStrictlyEquals(r, a); } diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-With-Op.template b/test/jdk/jdk/incubator/vector/templates/Unit-With-Op.template index c41bd05f20e..5a889ceb8b9 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-With-Op.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-With-Op.template @@ -1,9 +1,7 @@ - @Test(dataProvider = "$type$UnaryOpProvider") - static void with$vectorteststype$(IntFunction<$type$ []> fa) { + @Test(dataProvider = "$type$BinaryOpProvider") + static void with$vectorteststype$(IntFunction<$type$ []> fa, IntFunction<$type$ []> fb) { [[KERNEL]] - for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { - assertInsertArraysEquals(r, a, ($type$)(65535+i), (j++ & (SPECIES.length()-1)), i , i + SPECIES.length()); - } + assertArraysStrictlyEquals(r, a); } diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-header.template b/test/jdk/jdk/incubator/vector/templates/Unit-header.template index 38ab6178244..42440881771 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-header.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-header.template @@ -105,6 +105,26 @@ public class $vectorteststype$ extends AbstractVectorTest { static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / $bits$); + static void assertArraysStrictlyEquals($type$[] r, $type$[] a) { + for (int i = 0; i < a.length; i++) { +#if[FP] + $bitstype$ ir = $Wideboxtype$.$type$ToRaw$Bitstype$Bits(r[i]); + $bitstype$ ia = $Wideboxtype$.$type$ToRaw$Bitstype$Bits(a[i]); + if (ir != ia) { +#if[Float] + Assert.fail(String.format("at index #%d, expected = %08X, actual = %08X", i, ia, ir)); +#else[Float] + Assert.fail(String.format("at index #%d, expected = %016X, actual = %016X", i, ia, ir)); +#end[Float] + } +#else[FP] + if (r[i] != a[i]) { + Assert.fail("at index #" + i + ", expected = " + a[i] + ", actual = " + r[i]); + } +#end[FP] + } + } + interface FUnOp { $type$ apply($type$ a); } @@ -314,25 +334,6 @@ relativeError)); } } - static void assertInsertArraysEquals($type$[] r, $type$[] a, $type$ element, int index, int start, int end) { - int i = start; - try { - for (; i < end; i += 1) { - if(i%SPECIES.length() == index) { - Assert.assertEquals(r[i], element); - } else { - Assert.assertEquals(r[i], a[i]); - } - } - } catch (AssertionError e) { - if (i%SPECIES.length() == index) { - Assert.assertEquals(r[i], element, "at index #" + i); - } else { - Assert.assertEquals(r[i], a[i], "at index #" + i); - } - } - } - static void assertRearrangeArraysEquals($type$[] r, $type$[] a, int[] order, int vector_len) { int i = 0, j = 0; try { @@ -863,21 +864,6 @@ relativeError)); } #end[FP] - interface FBinArrayOp { - $type$ apply($type$[] a, int b); - } - - static void assertArraysEquals($type$[] r, $type$[] a, FBinArrayOp f) { - int i = 0; - try { - for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a, i)); - } - } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a,i), "at index #" + i); - } - } - interface FGatherScatterOp { $type$[] apply($type$[] a, int ix, int[] b, int iy); } @@ -1472,22 +1458,20 @@ relativeError)); static $type$ cornerCaseValue(int i) { #if[FP] - switch(i % 7) { - case 0: - return $Wideboxtype$.MAX_VALUE; - case 1: - return $Wideboxtype$.MIN_VALUE; - case 2: - return $Wideboxtype$.NEGATIVE_INFINITY; - case 3: - return $Wideboxtype$.POSITIVE_INFINITY; - case 4: - return $Wideboxtype$.NaN; - case 5: - return ($type$)0.0; - default: - return ($type$)-0.0; - } + return switch(i % 8) { + case 0 -> $Wideboxtype$.MAX_VALUE; + case 1 -> $Wideboxtype$.MIN_VALUE; + case 2 -> $Wideboxtype$.NEGATIVE_INFINITY; + case 3 -> $Wideboxtype$.POSITIVE_INFINITY; + case 4 -> $Wideboxtype$.NaN; +#if[Float] + case 5 -> Float.intBitsToFloat(0x7F812345); +#else[Float] + case 5 -> Double.longBitsToDouble(0x7FF123456789ABCDL); +#end[Float] + case 6 -> ($type$)0.0; + default -> ($type$)-0.0; + }; #else[FP] switch(i % 5) { case 0: @@ -1504,10 +1488,6 @@ relativeError)); #end[FP] } - static $type$ get($type$[] a, int i) { - return ($type$) a[i]; - } - static final IntFunction<$type$[]> fr = (vl) -> { int length = BUFFER_REPS * vl; return new $type$[length]; diff --git a/test/jdk/jdk/internal/loader/URLClassPath/ClassnameCharTest.java b/test/jdk/jdk/internal/loader/URLClassPath/ClassnameCharTest.java index 9e14957ef62..85987ef6f5e 100644 --- a/test/jdk/jdk/internal/loader/URLClassPath/ClassnameCharTest.java +++ b/test/jdk/jdk/internal/loader/URLClassPath/ClassnameCharTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -95,9 +95,9 @@ public class ClassnameCharTest { server.stop(0); } } - // the class loader code was copied from the now deleted AppletClassLoader + static class MyURLClassLoader extends URLClassLoader { - private URL base; /* applet code base URL */ + private URL base; /* code base URL */ private CodeSource codesource; /* codesource for the base URL */ private AccessControlContext acc; MyURLClassLoader(URL base) { diff --git a/test/jdk/jdk/internal/platform/docker/TestDockerBasic.java b/test/jdk/jdk/internal/platform/docker/TestDockerBasic.java index 5518943a6e6..e236292de98 100644 --- a/test/jdk/jdk/internal/platform/docker/TestDockerBasic.java +++ b/test/jdk/jdk/internal/platform/docker/TestDockerBasic.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2022, Red Hat, Inc. + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +27,7 @@ * @bug 8293540 * @summary Verify that -XshowSettings:system works * @key cgroups - * @requires docker.support + * @requires container.support * @library /test/lib * @run main/timeout=360 TestDockerBasic */ diff --git a/test/jdk/jdk/internal/platform/docker/TestDockerCpuMetrics.java b/test/jdk/jdk/internal/platform/docker/TestDockerCpuMetrics.java index f08e80c76f4..4d452f20eef 100644 --- a/test/jdk/jdk/internal/platform/docker/TestDockerCpuMetrics.java +++ b/test/jdk/jdk/internal/platform/docker/TestDockerCpuMetrics.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,7 @@ import jdk.test.lib.containers.docker.DockerTestUtils; * @test * @key cgroups * @summary Test JDK Metrics class when running inside docker container - * @requires docker.support + * @requires container.support * @library /test/lib * @modules java.base/jdk.internal.platform * @build MetricsCpuTester diff --git a/test/jdk/jdk/internal/platform/docker/TestDockerMemoryMetrics.java b/test/jdk/jdk/internal/platform/docker/TestDockerMemoryMetrics.java index 416e91bec5c..e8dc616b5e7 100644 --- a/test/jdk/jdk/internal/platform/docker/TestDockerMemoryMetrics.java +++ b/test/jdk/jdk/internal/platform/docker/TestDockerMemoryMetrics.java @@ -32,7 +32,7 @@ import jdk.test.lib.process.OutputAnalyzer; * @test * @key cgroups * @summary Test JDK Metrics class when running inside docker container - * @requires docker.support + * @requires container.support * @library /test/lib * @modules java.base/jdk.internal.platform * @build MetricsMemoryTester diff --git a/test/jdk/jdk/internal/platform/docker/TestGetFreeSwapSpaceSize.java b/test/jdk/jdk/internal/platform/docker/TestGetFreeSwapSpaceSize.java index 92f3364da10..204d7a215d8 100644 --- a/test/jdk/jdk/internal/platform/docker/TestGetFreeSwapSpaceSize.java +++ b/test/jdk/jdk/internal/platform/docker/TestGetFreeSwapSpaceSize.java @@ -1,5 +1,6 @@ /* * Copyright (C) 2020, 2022 THL A29 Limited, a Tencent company. All rights reserved. + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +26,7 @@ * @test * @key cgroups * @bug 8242480 - * @requires docker.support + * @requires container.support * @library /test/lib * @build GetFreeSwapSpaceSize * @run driver TestGetFreeSwapSpaceSize diff --git a/test/jdk/jdk/internal/platform/docker/TestLimitsUpdating.java b/test/jdk/jdk/internal/platform/docker/TestLimitsUpdating.java index 22e03293c48..1544088f688 100644 --- a/test/jdk/jdk/internal/platform/docker/TestLimitsUpdating.java +++ b/test/jdk/jdk/internal/platform/docker/TestLimitsUpdating.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2023, Red Hat, Inc. + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -28,7 +29,7 @@ * @bug 8308090 * @key cgroups * @summary Test container limits updating as they get updated at runtime without restart - * @requires docker.support + * @requires container.support * @library /test/lib * @modules java.base/jdk.internal.platform * @build LimitUpdateChecker diff --git a/test/jdk/jdk/internal/platform/docker/TestPidsLimit.java b/test/jdk/jdk/internal/platform/docker/TestPidsLimit.java index 6c6ff76fa99..9fedeb55234 100644 --- a/test/jdk/jdk/internal/platform/docker/TestPidsLimit.java +++ b/test/jdk/jdk/internal/platform/docker/TestPidsLimit.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2021 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -27,7 +27,7 @@ * @key cgroups * @summary Test JDK Metrics class when running inside a docker container with limited pids * @bug 8266490 - * @requires docker.support + * @requires container.support * @library /test/lib * @build TestPidsLimit * @run driver TestPidsLimit diff --git a/test/jdk/jdk/internal/platform/docker/TestSystemMetrics.java b/test/jdk/jdk/internal/platform/docker/TestSystemMetrics.java index 854d24b2279..93efff64cc4 100644 --- a/test/jdk/jdk/internal/platform/docker/TestSystemMetrics.java +++ b/test/jdk/jdk/internal/platform/docker/TestSystemMetrics.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,7 @@ * @test * @key cgroups * @summary Test JDK Metrics class when running inside docker container - * @requires docker.support + * @requires container.support * @library /test/lib * @modules java.base/jdk.internal.platform * @run main TestSystemMetrics diff --git a/test/jdk/jdk/internal/platform/docker/TestUseContainerSupport.java b/test/jdk/jdk/internal/platform/docker/TestUseContainerSupport.java index 7a2f77b3ce4..6a96514771c 100644 --- a/test/jdk/jdk/internal/platform/docker/TestUseContainerSupport.java +++ b/test/jdk/jdk/internal/platform/docker/TestUseContainerSupport.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2020, Red Hat, Inc. + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +25,7 @@ /* * @test * @summary UseContainerSupport flag should reflect Metrics being available - * @requires docker.support + * @requires container.support * @library /test/lib * @modules java.base/jdk.internal.platform * @build CheckUseContainerSupport diff --git a/test/jdk/jdk/internal/vm/Continuation/Scoped.java b/test/jdk/jdk/internal/vm/Continuation/Scoped.java index b034243d596..1bad8e4aebd 100644 --- a/test/jdk/jdk/internal/vm/Continuation/Scoped.java +++ b/test/jdk/jdk/internal/vm/Continuation/Scoped.java @@ -74,27 +74,27 @@ public class Scoped { frames = cont.stackWalker().walk(fs -> fs.map(StackWalker.StackFrame::getMethodName).collect(Collectors.toList())); System.out.println("No scope: " + frames); - assertEquals(frames, cont.isDone() ? List.of() : Arrays.asList("yield0", "yield", "lambda$bar$14", "run", "enter0", "enter", "yield0", "run", "bar", "lambda$foo$8", "run", "enter0", "enter", "yield0", "run", "foo", "lambda$test1$0", "run", "enter0", "enter")); + assertEquals(frames, cont.isDone() ? List.of() : Arrays.asList("yield0", "yield", "lambda$bar$0", "run", "enter0", "enter", "yield0", "run", "bar", "lambda$foo$0", "run", "enter0", "enter", "yield0", "run", "foo", "lambda$test1$0", "run", "enter0", "enter")); frames = cont.stackWalker(EnumSet.noneOf(StackWalker.Option.class), A).walk(fs -> fs.map(StackWalker.StackFrame::getMethodName).collect(Collectors.toList())); System.out.println("A: " + frames); - assertEquals(frames, cont.isDone() ? List.of() : Arrays.asList("yield0", "yield", "lambda$bar$14", "run", "enter0", "enter", "yield0", "run", "bar", "lambda$foo$8", "run", "enter0", "enter", "yield0", "run", "foo", "lambda$test1$0", "run", "enter0", "enter")); + assertEquals(frames, cont.isDone() ? List.of() : Arrays.asList("yield0", "yield", "lambda$bar$0", "run", "enter0", "enter", "yield0", "run", "bar", "lambda$foo$0", "run", "enter0", "enter", "yield0", "run", "foo", "lambda$test1$0", "run", "enter0", "enter")); frames = cont.stackWalker(EnumSet.noneOf(StackWalker.Option.class), B).walk(fs -> fs.map(StackWalker.StackFrame::getMethodName).collect(Collectors.toList())); System.out.println("B: " + frames); - assertEquals(frames, cont.isDone() ? List.of() : Arrays.asList("yield0", "yield", "lambda$bar$14", "run", "enter0", "enter", "yield0", "run", "bar", "lambda$foo$8", "run", "enter0", "enter")); + assertEquals(frames, cont.isDone() ? List.of() : Arrays.asList("yield0", "yield", "lambda$bar$0", "run", "enter0", "enter", "yield0", "run", "bar", "lambda$foo$0", "run", "enter0", "enter")); frames = cont.stackWalker(EnumSet.noneOf(StackWalker.Option.class), C).walk(fs -> fs.map(StackWalker.StackFrame::getMethodName).collect(Collectors.toList())); System.out.println("C: " + frames); - assertEquals(frames, cont.isDone() ? List.of() : Arrays.asList("yield0", "yield", "lambda$bar$14", "run", "enter0", "enter")); + assertEquals(frames, cont.isDone() ? List.of() : Arrays.asList("yield0", "yield", "lambda$bar$0", "run", "enter0", "enter")); frames = cont.stackWalker(EnumSet.noneOf(StackWalker.Option.class), K).walk(fs -> fs.map(StackWalker.StackFrame::getMethodName).collect(Collectors.toList())); System.out.println("K: " + frames); - assertEquals(frames, cont.isDone() ? List.of() : Arrays.asList("yield0", "yield", "lambda$bar$14", "run", "enter0", "enter", "yield0", "run", "bar", "lambda$foo$8", "run", "enter0", "enter", "yield0", "run", "foo", "lambda$test1$0", "run", "enter0", "enter")); + assertEquals(frames, cont.isDone() ? List.of() : Arrays.asList("yield0", "yield", "lambda$bar$0", "run", "enter0", "enter", "yield0", "run", "bar", "lambda$foo$0", "run", "enter0", "enter", "yield0", "run", "foo", "lambda$test1$0", "run", "enter0", "enter")); frames = cont.stackWalker(EnumSet.noneOf(StackWalker.Option.class), null).walk(fs -> fs.map(StackWalker.StackFrame::getMethodName).collect(Collectors.toList())); System.out.println("null: " + frames); - assertEquals(frames, cont.isDone() ? List.of() : Arrays.asList("yield0", "yield", "lambda$bar$14", "run", "enter0", "enter", "yield0", "run", "bar", "lambda$foo$8", "run", "enter0", "enter", "yield0", "run", "foo", "lambda$test1$0", "run", "enter0", "enter")); + assertEquals(frames, cont.isDone() ? List.of() : Arrays.asList("yield0", "yield", "lambda$bar$0", "run", "enter0", "enter", "yield0", "run", "bar", "lambda$foo$0", "run", "enter0", "enter", "yield0", "run", "foo", "lambda$test1$0", "run", "enter0", "enter")); } assertEquals(res.get(), 2); } @@ -119,23 +119,23 @@ public class Scoped { List frames = StackWalker.getInstance().walk(fs -> fs.map(StackWalker.StackFrame::getMethodName).collect(Collectors.toList())); - assertEquals(frames.subList(0, 18), Arrays.asList("lambda$bar$14", "run", "enter0", "enter", "run", "bar", "lambda$foo$8", "run", "enter0", "enter", "run", "foo", "lambda$test1$0", "run", "enter0", "enter", "run", "test1")); + assertEquals(frames.subList(0, 18), Arrays.asList("lambda$bar$0", "run", "enter0", "enter", "run", "bar", "lambda$foo$0", "run", "enter0", "enter", "run", "foo", "lambda$test1$0", "run", "enter0", "enter", "run", "test1")); frames = StackWalkerHelper.getInstance(C).walk(fs -> fs.map(StackWalker.StackFrame::getMethodName).collect(Collectors.toList())); - assertEquals(frames, Arrays.asList("lambda$bar$14", "run", "enter0", "enter")); + assertEquals(frames, Arrays.asList("lambda$bar$0", "run", "enter0", "enter")); frames = StackWalkerHelper.getInstance(B).walk(fs -> fs.map(StackWalker.StackFrame::getMethodName).collect(Collectors.toList())); - assertEquals(frames, Arrays.asList("lambda$bar$14", "run", "enter0", "enter", "run", "bar", "lambda$foo$8", "run", "enter0", "enter")); + assertEquals(frames, Arrays.asList("lambda$bar$0", "run", "enter0", "enter", "run", "bar", "lambda$foo$0", "run", "enter0", "enter")); frames = StackWalkerHelper.getInstance(A).walk(fs -> fs.map(StackWalker.StackFrame::getMethodName).collect(Collectors.toList())); - assertEquals(frames, Arrays.asList("lambda$bar$14", "run", "enter0", "enter", "run", "bar", "lambda$foo$8", "run", "enter0", "enter", "run", "foo", "lambda$test1$0", "run", "enter0", "enter")); + assertEquals(frames, Arrays.asList("lambda$bar$0", "run", "enter0", "enter", "run", "bar", "lambda$foo$0", "run", "enter0", "enter", "run", "foo", "lambda$test1$0", "run", "enter0", "enter")); frames = StackWalkerHelper.getInstance(K).walk(fs -> fs.map(StackWalker.StackFrame::getMethodName).collect(Collectors.toList())); - assertEquals(frames.subList(0, 18), Arrays.asList("lambda$bar$14", "run", "enter0", "enter", "run", "bar", "lambda$foo$8", "run", "enter0", "enter", "run", "foo", "lambda$test1$0", "run", "enter0", "enter", "run", "test1")); + assertEquals(frames.subList(0, 18), Arrays.asList("lambda$bar$0", "run", "enter0", "enter", "run", "bar", "lambda$foo$0", "run", "enter0", "enter", "run", "foo", "lambda$test1$0", "run", "enter0", "enter", "run", "test1")); long r = b+1; }); diff --git a/test/jdk/jdk/jfr/api/event/TestGetDuration.java b/test/jdk/jdk/jfr/api/event/TestGetDuration.java index c3242ea90c7..b25969198ed 100644 --- a/test/jdk/jdk/jfr/api/event/TestGetDuration.java +++ b/test/jdk/jdk/jfr/api/event/TestGetDuration.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -87,7 +87,7 @@ public class TestGetDuration { Events.hasEvents(testEvents); for (RecordedEvent re : testEvents) { int id = re.getValue("id"); - Asserts.assertEquals(re.getDuration(), Duration.between(re.getStartTime(), re.getEndTime())); + Asserts.assertEquals(re.getDuration(), re.getStartTime().until(re.getEndTime())); switch (id) { case DURATIONAL_EVENT_ID: Asserts.assertTrue(!re.getDuration().isNegative() && !re.getDuration().isZero()); @@ -111,7 +111,7 @@ public class TestGetDuration { List recordedEvents = Events.fromRecording(r); Events.hasEvents(recordedEvents); for (RecordedEvent re : recordedEvents) { - Asserts.assertEquals(re.getDuration(), Duration.between(re.getStartTime(), re.getEndTime())); + Asserts.assertEquals(re.getDuration(), re.getStartTime().until(re.getEndTime())); switch (re.getEventType().getName()) { case EventNames.JVMInformation: Asserts.assertTrue(re.getDuration().isZero()); diff --git a/test/jdk/jdk/jfr/api/recording/misc/TestGetStream.java b/test/jdk/jdk/jfr/api/recording/misc/TestGetStream.java index dd936101caa..3b353d0968b 100644 --- a/test/jdk/jdk/jfr/api/recording/misc/TestGetStream.java +++ b/test/jdk/jdk/jfr/api/recording/misc/TestGetStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -88,7 +88,7 @@ public class TestGetStream { } private static void printTimeStamp(String name, Instant t) { - Duration s = Duration.between(offset, t); + Duration s = offset.until(t); System.out.println(name + ": " + (s.getSeconds() * 1_000_000_000L + s.getNano())); } diff --git a/test/jdk/jdk/jfr/api/recording/options/TestDuration.java b/test/jdk/jdk/jfr/api/recording/options/TestDuration.java index 6a2ef2c30cd..8f231ab77a0 100644 --- a/test/jdk/jdk/jfr/api/recording/options/TestDuration.java +++ b/test/jdk/jdk/jfr/api/recording/options/TestDuration.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -53,7 +53,7 @@ public class TestDuration { Instant afterStop = Instant.now(); Asserts.assertLessThanOrEqual(r.getStopTime(), afterStop, "getStopTime() > afterStop"); - long durationMillis = Duration.between(afterStart, r.getStopTime()).toMillis(); + long durationMillis = afterStart.until(r.getStopTime()).toMillis(); // Performance of test servers varies too much to make a strict check of actual duration. // We only check that recording stops before timeout of 20 seconds. diff --git a/test/jdk/jdk/jfr/api/recording/state/TestStateDuration.java b/test/jdk/jdk/jfr/api/recording/state/TestStateDuration.java index bdf620fa1b3..5e8ef60b367 100644 --- a/test/jdk/jdk/jfr/api/recording/state/TestStateDuration.java +++ b/test/jdk/jdk/jfr/api/recording/state/TestStateDuration.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -55,7 +55,7 @@ public class TestStateDuration { System.out.println("Waiting for recording to reach STOPPED state"); CommonHelper.waitForRecordingState(r, RecordingState.STOPPED); Instant stop = Instant.now(); - Duration measuredDuration = Duration.between(start, stop); + Duration measuredDuration = start.until(stop); System.out.println("Recording stopped at " + stop + ". Measured duration " + measuredDuration); // Timer task uses System.currentMillis, and java.time uses other source. Duration deltaDueToClockNotInSync = Duration.ofMillis(100); diff --git a/test/jdk/jdk/jfr/api/recording/state/TestStateScheduleStart.java b/test/jdk/jdk/jfr/api/recording/state/TestStateScheduleStart.java index ddeee64a7b4..3708ded56f1 100644 --- a/test/jdk/jdk/jfr/api/recording/state/TestStateScheduleStart.java +++ b/test/jdk/jdk/jfr/api/recording/state/TestStateScheduleStart.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -55,7 +55,7 @@ public class TestStateScheduleStart { // Test servers vary too much in performance to make an accurate check. // We only check that we don't time out after 20 seconds. Instant started = Instant.now(); - long millis = Duration.between(start, started).toMillis(); + long millis = start.until(started).toMillis(); System.out.println("Recording started at " + started + ". Delta millis=" + millis + ", expected about 2000"); verifyIllegalState(() -> r.start(), "double start()"); diff --git a/test/jdk/jdk/jfr/event/compiler/TestCompilerCompile.java b/test/jdk/jdk/jfr/event/compiler/TestCompilerCompile.java index 8d070db8262..e13bcaa80b5 100644 --- a/test/jdk/jdk/jfr/event/compiler/TestCompilerCompile.java +++ b/test/jdk/jdk/jfr/event/compiler/TestCompilerCompile.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,7 +41,7 @@ import jdk.test.whitebox.WhiteBox; * @test * @key jfr * @requires vm.hasJFR - * @requires vm.compMode!="Xint" + * @requires vm.compMode == "Xmixed" * @library /test/lib * @build jdk.test.whitebox.WhiteBox * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox diff --git a/test/jdk/jdk/jfr/event/compiler/TestCompilerInlining.java b/test/jdk/jdk/jfr/event/compiler/TestCompilerInlining.java index 56005fa7458..b13fa714109 100644 --- a/test/jdk/jdk/jfr/event/compiler/TestCompilerInlining.java +++ b/test/jdk/jdk/jfr/event/compiler/TestCompilerInlining.java @@ -57,7 +57,7 @@ import static java.lang.constant.ConstantDescs.INIT_NAME; * @key jfr * @summary Verifies that corresponding JFR events are emitted in case of inlining. * @requires vm.hasJFR - * + * @requires vm.compMode == "Xmixed" * @requires vm.opt.Inline == true | vm.opt.Inline == null * @library /test/lib * @modules jdk.jfr diff --git a/test/jdk/jdk/jfr/event/compiler/TestDeoptimization.java b/test/jdk/jdk/jfr/event/compiler/TestDeoptimization.java index 32c634fc59a..bd6d57b3176 100644 --- a/test/jdk/jdk/jfr/event/compiler/TestDeoptimization.java +++ b/test/jdk/jdk/jfr/event/compiler/TestDeoptimization.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -51,8 +51,9 @@ class Dummy { * @key jfr * @summary sanity test for Deoptimization event, depends on Compilation event * @requires vm.hasJFR - * @requires vm.compMode != "Xint" + * @requires vm.compMode == "Xmixed" * @requires vm.flavor == "server" & (vm.opt.TieredStopAtLevel == 4 | vm.opt.TieredStopAtLevel == null) + * @requires vm.opt.StressUnstableIfTraps == null | !vm.opt.StressUnstableIfTraps * @library /test/lib * @build jdk.test.whitebox.WhiteBox * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox diff --git a/test/jdk/jdk/jfr/event/gc/collection/TestGCCauseWithG1ConcurrentMark.java b/test/jdk/jdk/jfr/event/gc/collection/TestGCCauseWithG1ConcurrentMark.java index bd3a7f63a8a..e0ea218a07f 100644 --- a/test/jdk/jdk/jfr/event/gc/collection/TestGCCauseWithG1ConcurrentMark.java +++ b/test/jdk/jdk/jfr/event/gc/collection/TestGCCauseWithG1ConcurrentMark.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,7 +41,7 @@ public class TestGCCauseWithG1ConcurrentMark { String[] vmFlags = {"-XX:+UseG1GC", "-XX:+ExplicitGCInvokesConcurrent"}; String[] gcNames = {GCHelper.gcG1New, GCHelper.gcG1Old, GCHelper.gcG1Full}; String[] gcCauses = {"Metadata GC Threshold", "G1 Evacuation Pause", "G1 Preventive Collection", - "G1 Compaction Pause", "System.gc()"}; + "G1 Compaction Pause", "CodeCache GC Threshold", "System.gc()"}; GCGarbageCollectionUtil.test(testID, vmFlags, gcNames, gcCauses); } } diff --git a/test/jdk/jdk/jfr/event/gc/collection/TestGCCauseWithG1FullCollection.java b/test/jdk/jdk/jfr/event/gc/collection/TestGCCauseWithG1FullCollection.java index 072c3905baf..308a544adeb 100644 --- a/test/jdk/jdk/jfr/event/gc/collection/TestGCCauseWithG1FullCollection.java +++ b/test/jdk/jdk/jfr/event/gc/collection/TestGCCauseWithG1FullCollection.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,7 +41,7 @@ public class TestGCCauseWithG1FullCollection { String[] vmFlags = {"-XX:+UseG1GC"}; String[] gcNames = {GCHelper.gcG1New, GCHelper.gcG1Old, GCHelper.gcG1Full}; String[] gcCauses = {"Metadata GC Threshold", "G1 Evacuation Pause", "G1 Preventive Collection", - "G1 Compaction Pause", "System.gc()"}; + "G1 Compaction Pause", "CodeCache GC Threshold", "System.gc()"}; GCGarbageCollectionUtil.test(testID, vmFlags, gcNames, gcCauses); } } diff --git a/test/jdk/jdk/jfr/event/gc/collection/TestGCCauseWithParallelOld.java b/test/jdk/jdk/jfr/event/gc/collection/TestGCCauseWithParallelOld.java index 4d8f697d837..16217c0cbe1 100644 --- a/test/jdk/jdk/jfr/event/gc/collection/TestGCCauseWithParallelOld.java +++ b/test/jdk/jdk/jfr/event/gc/collection/TestGCCauseWithParallelOld.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,8 @@ public class TestGCCauseWithParallelOld { String testID = "ParallelOld"; String[] vmFlags = {"-XX:+UseParallelGC"}; String[] gcNames = {GCHelper.gcParallelScavenge, GCHelper.gcParallelOld}; - String[] gcCauses = {"Allocation Failure", "System.gc()", "GCLocker Initiated GC"}; + String[] gcCauses = {"Allocation Failure", "System.gc()", "GCLocker Initiated GC", + "CodeCache GC Threshold"}; GCGarbageCollectionUtil.test(testID, vmFlags, gcNames, gcCauses); } } diff --git a/test/jdk/jdk/jfr/event/gc/collection/TestGCCauseWithSerial.java b/test/jdk/jdk/jfr/event/gc/collection/TestGCCauseWithSerial.java index 403bd077585..344c61043a2 100644 --- a/test/jdk/jdk/jfr/event/gc/collection/TestGCCauseWithSerial.java +++ b/test/jdk/jdk/jfr/event/gc/collection/TestGCCauseWithSerial.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,8 @@ public class TestGCCauseWithSerial { String testID = "Serial"; String[] vmFlags = {"-XX:+UseSerialGC"}; String[] gcNames = {GCHelper.gcDefNew, GCHelper.gcSerialOld}; - String[] gcCauses = {"Allocation Failure", "System.gc()", "GCLocker Initiated GC"}; + String[] gcCauses = {"Allocation Failure", "System.gc()", "GCLocker Initiated GC", + "CodeCache GC Threshold"}; GCGarbageCollectionUtil.test(testID, vmFlags, gcNames, gcCauses); } } diff --git a/test/jdk/jdk/jfr/event/runtime/TestThreadCpuTimeEvent.java b/test/jdk/jdk/jfr/event/runtime/TestThreadCpuTimeEvent.java index a3ebb1550db..a6520614eab 100644 --- a/test/jdk/jdk/jfr/event/runtime/TestThreadCpuTimeEvent.java +++ b/test/jdk/jdk/jfr/event/runtime/TestThreadCpuTimeEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -93,7 +93,7 @@ public class TestThreadCpuTimeEvent { barrier.await(); Instant start = Instant.now(); counter = 0; - while ((Duration.between(start, Instant.now()).compareTo(runTime) < 0) || + while ((start.until(Instant.now()).compareTo(runTime) < 0) || (counter < cpuConsumerMinCount)) { counter++; } diff --git a/test/jdk/jdk/management/VirtualThreadSchedulerMXBean/VirtualThreadSchedulerMXBeanTest.java b/test/jdk/jdk/management/VirtualThreadSchedulerMXBean/VirtualThreadSchedulerMXBeanTest.java new file mode 100644 index 00000000000..b256d2b89ab --- /dev/null +++ b/test/jdk/jdk/management/VirtualThreadSchedulerMXBean/VirtualThreadSchedulerMXBeanTest.java @@ -0,0 +1,309 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8338890 + * @summary Basic test for jdk.management.VirtualThreadSchedulerMXBean + * @requires vm.continuations + * @modules jdk.management + * @library /test/lib + * @run junit/othervm VirtualThreadSchedulerMXBeanTest + */ + +import java.lang.management.ManagementFactory; +import java.util.concurrent.Executors; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.function.IntPredicate; +import java.util.function.LongPredicate; +import java.util.stream.Stream; +import java.util.stream.IntStream; +import javax.management.MBeanServer; +import jdk.management.VirtualThreadSchedulerMXBean; + +import jdk.test.lib.thread.VThreadRunner; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assumptions.*; + +class VirtualThreadSchedulerMXBeanTest { + + /** + * VirtualThreadSchedulerMXBean objects to test. + */ + private static Stream managedBeans() throws Exception { + var bean1 = ManagementFactory.getPlatformMXBean(VirtualThreadSchedulerMXBean.class); + + MBeanServer server = ManagementFactory.getPlatformMBeanServer(); + var bean2 = ManagementFactory.newPlatformMXBeanProxy(server, + "jdk.management:type=VirtualThreadScheduler", + VirtualThreadSchedulerMXBean.class); + + return Stream.of(bean1, bean2); + } + + /** + * Test default parallelism. + */ + @ParameterizedTest + @MethodSource("managedBeans") + void testDefaultParallelism(VirtualThreadSchedulerMXBean bean) { + assertEquals(Runtime.getRuntime().availableProcessors(), bean.getParallelism()); + } + + /** + * Test increasing parallelism. + */ + @ParameterizedTest + @MethodSource("managedBeans") + void testIncreaseParallelism(VirtualThreadSchedulerMXBean bean) throws Exception { + assumeFalse(Thread.currentThread().isVirtual(), "Main thread is a virtual thread"); + + final int parallelism = bean.getParallelism(); + try (var executor = Executors.newVirtualThreadPerTaskExecutor()) { + var done = new AtomicBoolean(); + Runnable busyTask = () -> { + while (!done.get()) { + Thread.onSpinWait(); + } + }; + + try { + // saturate + IntStream.range(0, parallelism).forEach(_ -> executor.submit(busyTask)); + awaitPoolSizeGte(bean, parallelism); + awaitMountedVirtualThreadCountGte(bean, parallelism); + + // increase parallelism + for (int k = 1; k <= 4; k++) { + int newParallelism = parallelism + k; + bean.setParallelism(newParallelism); + executor.submit(busyTask); + + // pool size and mounted virtual thread should increase + awaitPoolSizeGte(bean, newParallelism); + awaitMountedVirtualThreadCountGte(bean, newParallelism); + } + } finally { + done.set(true); + } + } finally { + bean.setParallelism(parallelism); // restore + } + } + + /** + * Test reducing parallelism. + */ + @ParameterizedTest + @MethodSource("managedBeans") + void testReduceParallelism(VirtualThreadSchedulerMXBean bean) throws Exception { + assumeFalse(Thread.currentThread().isVirtual(), "Main thread is a virtual thread"); + + final int parallelism = bean.getParallelism(); + try (var executor = Executors.newVirtualThreadPerTaskExecutor()) { + var done = new AtomicBoolean(); + var sleep = new AtomicBoolean(); + + // spin when !sleep + Runnable busyTask = () -> { + while (!done.get()) { + if (sleep.get()) { + try { + Thread.sleep(10); + } catch (InterruptedException e) { } + } else { + Thread.onSpinWait(); + } + } + }; + + try { + // increase parallelism + saturate + int highParallelism = parallelism + 4; + bean.setParallelism(highParallelism); + IntStream.range(0, highParallelism).forEach(_ -> executor.submit(busyTask)); + + // mounted virtual thread count should increase to highParallelism. + // Sample the count at highParallelism a few times. + for (int i = 0; i < 5; i++) { + Thread.sleep(100); + awaitMountedVirtualThreadCountEq(bean, highParallelism); + } + + // reduce parallelism and workload + int lowParallelism = Math.clamp(parallelism / 2, 1, parallelism); + bean.setParallelism(lowParallelism); + sleep.set(true); + + // mounted virtual thread count should reduce to lowParallelism or less. + // Sample the count at lowParallelism or less a few times. + for (int i = 0; i < 5; i++) { + Thread.sleep(100); + awaitMountedVirtualThreadCountLte(bean, lowParallelism); + } + + // increase workload + sleep.set(false); + + // mounted virtual thread count should not exceed lowParallelism. + // Sample the count at lowParallelism a few times. + for (int i = 0; i < 5; i++) { + Thread.sleep(100); + awaitMountedVirtualThreadCountEq(bean, lowParallelism); + } + + } finally { + done.set(true); + } + } finally { + bean.setParallelism(parallelism); // restore + } + } + + /** + * Test getPoolSize. + */ + @ParameterizedTest + @MethodSource("managedBeans") + void testPoolSize(VirtualThreadSchedulerMXBean bean) { + assertTrue(bean.getPoolSize() >= 0); + VThreadRunner.run(() -> { + assertTrue(Thread.currentThread().isVirtual()); + assertTrue(bean.getPoolSize() >= 1); + }); + } + + /** + * Test getMountedVirtualThreadCount. + */ + @ParameterizedTest + @MethodSource("managedBeans") + void testMountedVirtualThreadCount(VirtualThreadSchedulerMXBean bean) { + assertTrue(bean.getMountedVirtualThreadCount() >= 0); + VThreadRunner.run(() -> { + assertTrue(Thread.currentThread().isVirtual()); + assertTrue(bean.getMountedVirtualThreadCount() >= 1); + }); + } + + /** + * Test getQueuedVirtualThreadCount. + */ + @ParameterizedTest + @MethodSource("managedBeans") + void testQueuedVirtualThreadCount(VirtualThreadSchedulerMXBean bean) throws Exception { + assumeFalse(Thread.currentThread().isVirtual(), "Main thread is a virtual thread"); + + try (var executor = Executors.newVirtualThreadPerTaskExecutor()) { + var done = new AtomicBoolean(); + Runnable busyTask = () -> { + while (!done.get()) { + Thread.onSpinWait(); + } + }; + + try { + // saturate + int parallelism = bean.getParallelism(); + IntStream.range(0, parallelism).forEach(_ -> executor.submit(busyTask)); + awaitMountedVirtualThreadCountGte(bean, parallelism); + + // start 5 virtual threads, their tasks will be queued to execute + for (int i = 0; i < 5; i++) { + executor.submit(() -> { }); + } + assertTrue(bean.getQueuedVirtualThreadCount() >= 5); + } finally { + done.set(true); + } + } + } + + /** + * Waits for pool size >= target to be true. + */ + void awaitPoolSizeGte(VirtualThreadSchedulerMXBean bean, int target) throws InterruptedException { + awaitPoolSize(bean, ps -> ps >= target, ">= " + target); + } + + /** + * Waits for the mounted virtual thread count >= target to be true. + */ + void awaitMountedVirtualThreadCountGte(VirtualThreadSchedulerMXBean bean, + long target) throws InterruptedException { + awaitMountedVirtualThreadCount(bean, c -> c >= target, ">= " + target); + } + + /** + * Waits for the mounted virtual thread count <= target to be true. + */ + void awaitMountedVirtualThreadCountLte(VirtualThreadSchedulerMXBean bean, + long target) throws InterruptedException { + awaitMountedVirtualThreadCount(bean, c -> c <= target, "<= " + target); + } + + /** + * Waits for the mounted virtual thread count == target to be true. + */ + void awaitMountedVirtualThreadCountEq(VirtualThreadSchedulerMXBean bean, + long target) throws InterruptedException { + awaitMountedVirtualThreadCount(bean, c -> c == target, "== " + target); + } + + /** + * Waits until evaluating the given predicte on the pool size is true. + */ + void awaitPoolSize(VirtualThreadSchedulerMXBean bean, + IntPredicate predicate, + String reason) throws InterruptedException { + int poolSize = bean.getPoolSize(); + if (!predicate.test(poolSize)) { + System.err.format("poolSize = %d, await %s ...%n", poolSize, reason); + while (!predicate.test(poolSize)) { + Thread.sleep(10); + poolSize = bean.getPoolSize(); + } + System.err.format("poolSize = %d%n", poolSize); + } + } + + /** + * Waits until evaluating the given predicte on the mounted thread count is true. + */ + void awaitMountedVirtualThreadCount(VirtualThreadSchedulerMXBean bean, + LongPredicate predicate, + String reason) throws InterruptedException { + long count = bean.getMountedVirtualThreadCount(); + if (!predicate.test(count)) { + System.err.format("mountedVirtualThreadCount = %d, await %s ...%n", count, reason); + while (!predicate.test(count)) { + Thread.sleep(10); + count = bean.getMountedVirtualThreadCount(); + } + System.err.format("mountedVirtualThreadCount = %d%n", count); + } + } +} \ No newline at end of file diff --git a/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/CAInterop.java b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/CAInterop.java index ab04391b1f3..2bfd3ea7603 100644 --- a/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/CAInterop.java +++ b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/CAInterop.java @@ -26,7 +26,7 @@ * @bug 8189131 * @summary Interoperability tests with Actalis CA * Before this test set to manual, the original timeout - * value if 180 + * value is 180 * @library /test/lib * @build jtreg.SkippedException ValidatePathWithURL CAInterop * @run main/othervm/manual -Djava.security.debug=certpath,ocsp @@ -535,6 +535,28 @@ * @run main/othervm/manual -Djava.security.debug=certpath CAInterop globalsigne46 CRL */ +/* + * @test id=ssltlsrootecc2022 + * @bug 8341057 + * @summary Interoperability tests with SSL TLS 2022 root CAs + * @library /test/lib + * @build jtreg.SkippedException ValidatePathWithURL CAInterop + * @run main/othervm/manual -Djava.security.debug=certpath,ocsp CAInterop ssltlsrootecc2022 DEFAULT + * @run main/othervm/manual -Djava.security.debug=certpath,ocsp -Dcom.sun.security.ocsp.useget=false CAInterop ssltlsrootecc2022 DEFAULT + * @run main/othervm/manual -Djava.security.debug=certpath CAInterop ssltlsrootecc2022 CRL + */ + +/* + * @test id=ssltlsrootrsa2022 + * @bug 8341057 + * @summary Interoperability tests with SSL TLS 2022 root CAs + * @library /test/lib + * @build jtreg.SkippedException ValidatePathWithURL CAInterop + * @run main/othervm/manual -Djava.security.debug=certpath,ocsp CAInterop ssltlsrootrsa2022 DEFAULT + * @run main/othervm/manual -Djava.security.debug=certpath,ocsp -Dcom.sun.security.ocsp.useget=false CAInterop ssltlsrootrsa2022 DEFAULT + * @run main/othervm/manual -Djava.security.debug=certpath CAInterop ssltlsrootrsa2022 CRL + */ + /** * Collection of certificate validation tests for interoperability with external CAs. * These tests are marked as manual as they depend on external infrastructure and may fail @@ -713,6 +735,13 @@ public class CAInterop { new CATestURLs("https://valid.e46.roots.globalsign.com", "https://revoked.e46.roots.globalsign.com"); + case "ssltlsrootecc2022" -> + new CATestURLs("https://test-root-2022-ecc.ssl.com", + "https://revoked-root-2022-ecc.ssl.com"); + case "ssltlsrootrsa2022" -> + new CATestURLs("https://test-root-2022-rsa.ssl.com", + "https://revoked-root-2022-rsa.ssl.com"); + default -> throw new RuntimeException("No test setup found for: " + alias); }; } diff --git a/test/jdk/sun/awt/font/CacheFlushTest.java b/test/jdk/sun/awt/font/CacheFlushTest.java new file mode 100644 index 00000000000..f3b32931275 --- /dev/null +++ b/test/jdk/sun/awt/font/CacheFlushTest.java @@ -0,0 +1,106 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4286726 + * @summary Java2D raster printing: large text may overflow glyph cache. + * Draw a large glyphvector, the 'A' glyph should appear and not get flushed. +*/ + +import java.awt.Color; +import java.awt.Font; +import java.awt.Graphics2D; +import java.awt.RenderingHints; +import java.awt.font.FontRenderContext; +import java.awt.font.GlyphVector; +import java.awt.geom.Point2D; +import java.awt.image.BufferedImage; +import java.util.HashMap; + +/** + * Draw a very large glyphvector on a surface. + * If the cache was flushed the first glyph is not rendered. + * Note: the implementation no longer uses glyphs for rendering large text, + * but in principle the test is still useful. + */ +public class CacheFlushTest { + + static final int WIDTH = 400, HEIGHT = 600; + static final int FONTSIZE = 250; + static final String TEST = "ABCDEFGHIJKLMNOP"; + static final HashMap HINTS = new HashMap<>(); + + static { + HINTS.put(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); + HINTS.put(RenderingHints.KEY_TEXT_ANTIALIASING, + RenderingHints.VALUE_TEXT_ANTIALIAS_ON); + HINTS.put(RenderingHints.KEY_FRACTIONALMETRICS, + RenderingHints.VALUE_FRACTIONALMETRICS_ON); + } + + public static void main(String args[]) { + BufferedImage bi = new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_INT_RGB); + + Graphics2D g2d = bi.createGraphics(); + g2d.addRenderingHints(HINTS); + g2d.setColor(Color.white); + g2d.fillRect(0, 0, WIDTH, HEIGHT); + g2d.setColor(Color.black); + + FontRenderContext frc = g2d.getFontRenderContext(); + Font font = new Font(Font.DIALOG, Font.PLAIN, 250); + GlyphVector gv = font.createGlyphVector(frc, TEST); + + /* Set the positions of all but the first glyph to be offset vertically but + * FONTSIZE pixels. So if the first glyph "A" is not flushed we can tell this + * by checking for non-white pixels in the range for the default y offset of 0 + * from the specified y location. + */ + Point2D.Float pt = new Point2D.Float(20f, FONTSIZE); + for (int i = 1; i < gv.getNumGlyphs(); ++i) { + gv.setGlyphPosition(i, pt); + pt.x += 25f; + pt.y = FONTSIZE; + } + g2d.drawGlyphVector(gv, 20, FONTSIZE); + /* Now expect to find at least one black pixel in the rect (0,0) -> (WIDTH, FONTSIZE) */ + boolean found = false; + int blackPixel = Color.black.getRGB(); + for (int y = 0; y < FONTSIZE; y++) { + for (int x = 0; x < WIDTH; x++) { + if (bi.getRGB(x, y) == blackPixel) { + found = true; + break; + } + } + if (found == true) { + break; + } + } + if (!found) { + throw new RuntimeException("NO BLACK PIXELS"); + } + } +} diff --git a/test/jdk/sun/awt/font/TestArabicHebrew.java b/test/jdk/sun/awt/font/TestArabicHebrew.java new file mode 100644 index 00000000000..61cbe931c32 --- /dev/null +++ b/test/jdk/sun/awt/font/TestArabicHebrew.java @@ -0,0 +1,215 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4198081 + * @key headful + * @summary Arabic characters should appear instead of boxes and be correctly shaped. + * Hebrew characters should appear instead of boxes. + * Test is made headful so there's no excuse for test systems not having the fonts. + */ + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.GridLayout; +import java.awt.Font; +import java.awt.Frame; +import java.awt.Panel; +import java.awt.font.FontRenderContext; +import java.awt.font.GlyphVector; +import java.awt.geom.Rectangle2D; + +public class TestArabicHebrew extends Panel { + + static volatile Frame frame; + static volatile Font font = new Font(Font.DIALOG, Font.PLAIN, 36); + + static void createUI() { + frame = new Frame("Test Arabic/Hebrew"); + frame.setLayout(new BorderLayout()); + TestArabicHebrew panel = new TestArabicHebrew(); + frame.add(panel, BorderLayout.CENTER); + frame.pack(); + frame.setVisible(true); + } + + public static void main(String args[]) throws Exception { + EventQueue.invokeAndWait(TestArabicHebrew::createUI); + try { + checkStrings(); + } finally { + if (frame != null && args.length == 0) { + EventQueue.invokeAndWait(frame::dispose); + } + } + } + + static void checkString(String script, String str) { + int index = font.canDisplayUpTo(str); + if (index != -1) { + throw new RuntimeException("Cannot display char " + index + " for " + script); + } + } + + static void checkStrings() { + checkString("Arabic", arabic); + checkString("Hebrew", hebrew); + checkString("Latin-1 Supplement", latin1sup); + } + + // Table of arabic unicode characters - minimal support level + // Includes arabic chars from basic block up to 0652 and + // corresponding shaped characters from the arabic + // extended-B block from fe80 to fefc (does include lam-alef + // ligatures). + // Does not include arabic-indic digits nor "arabic extended" + // range. + + static final String arabic = + "\u060c\u061b\u061f\u0621\u0622\u0623\u0624\u0625\u0626\u0627" + + "\u0628\u0629\u062a\u062b\u062c\u062d\u062e\u062f\u0630\u0631" + + "\u0632\u0633\u0634\u0635\u0636\u0637\u0638\u0639\u063a\u0640" + + "\u0641\u0642\u0643\u0644\u0645\u0646\u0647\u0648\u0649\u064a" + + "\u064b\u064c\u064d\u064e\u064f\u0650\u0651\u0652\ufe80\ufe81" + + "\ufe82\ufe83\ufe84\ufe85\ufe86\ufe87\ufe88\ufe89\ufe8a\ufe8b" + + "\ufe8c\ufe8d\ufe8e\ufe8f\ufe90\ufe91\ufe92\ufe93\ufe94\ufe95" + + "\ufe96\ufe97\ufe98\ufe99\ufe9a\ufe9b\ufe9c\ufe9d\ufe9e\ufe9f" + + "\ufea0\ufea1\ufea2\ufea3\ufea4\ufea5\ufea6\ufea7\ufea8\ufea9" + + "\ufeaa\ufeab\ufeac\ufead\ufeae\ufeaf\ufeb0\ufeb1\ufeb2\ufeb3" + + "\ufeb4\ufeb5\ufeb6\ufeb7\ufeb8\ufeb9\ufeba\ufebb\ufebc\ufebd" + + "\ufebe\ufebf\ufec0\ufec1\ufec2\ufec3\ufec4\ufec5\ufec6\ufec7" + + "\ufec8\ufec9\ufeca\ufecb\ufecc\ufecd\ufece\ufecf\ufed0\ufed1" + + "\ufed2\ufed3\ufed4\ufed5\ufed6\ufed7\ufed8\ufed9\ufeda\ufedb" + + "\ufedc\ufedd\ufede\ufedf\ufee0\ufee1\ufee2\ufee3\ufee4\ufee5" + + "\ufee6\ufee7\ufee8\ufee9\ufeea\ufeeb\ufeec\ufeed\ufeee\ufeef" + + "\ufef0\ufef1\ufef2\ufef3\ufef4\ufef5\ufef6\ufef7\ufef8\ufef9" + + "\ufefa\ufefb\ufefc"; + + // hebrew table includes all characters in hebrew block + + static final String hebrew = + "\u0591\u0592\u0593\u0594\u0595\u0596\u0597\u0598\u0599\u059a" + + "\u059b\u059c\u059d\u059e\u059f\u05a0\u05a1\u05a3\u05a4\u05a5" + + "\u05a6\u05a7\u05a8\u05a9\u05aa\u05ab\u05ac\u05ad\u05ae\u05af" + + "\u05b0\u05b1\u05b2\u05b3\u05b4\u05b5\u05b6\u05b7\u05b8\u05b9" + + "\u05bb\u05bc\u05bd\u05be\u05bf\u05c0\u05c1\u05c2\u05c3\u05c4" + + "\u05d0\u05d1\u05d2\u05d3\u05d4\u05d5\u05d6\u05d7\u05d8\u05d9" + + "\u05da\u05db\u05dc\u05dd\u05de\u05df\u05e0\u05e1\u05e2\u05e3" + + "\u05e4\u05e5\u05e6\u05e7\u05e8\u05e9\u05ea\u05f0\u05f1\u05f2" + + "\u05f3\u05f4"; + + // latin 1 supplement table includes all non-control characters + // in this range. Included because of comment in code that claims + // some problems displaying this range with some SJIS fonts. + + static final String latin1sup = + "\u00a0\u00a1\u00a2\u00a3\u00a4\u00a5\u00a6\u00a7" + + "\u00a8\u00a9\u00aa\u00ab\u00ac\u00ad\u00ae\u00af\u00b0\u00b1" + + "\u00b2\u00b3\u00b4\u00b5\u00b6\u00b7\u00b8\u00b9\u00ba\u00bb" + + "\u00bc\u00bd\u00be\u00bf\u00c0\u00c1\u00c2\u00c3\u00c4\u00c5" + + "\u00c6\u00c7\u00c8\u00c9\u00ca\u00cb\u00cc\u00cd\u00ce\u00cf" + + "\u00d0\u00d1\u00d2\u00d3\u00d4\u00d5\u00d6\u00d7\u00d8\u00d9" + + "\u00da\u00db\u00dc\u00dd\u00de\u00df\u00e0\u00e1\u00e2\u00e3" + + "\u00e4\u00e5\u00e6\u00e7\u00e8\u00e9\u00ea\u00eb\u00ec\u00ed" + + "\u00ee\u00ef\u00f0\u00f1\u00f2\u00f3\u00f4\u00f5\u00f6\u00f7" + + "\u00f8\u00f9\u00fa\u00fb\u00fc\u00fd\u00fe\u00ff"; + + public TestArabicHebrew() { + setLayout(new GridLayout(3, 1)); + + FontRenderContext frc = new FontRenderContext(null, false, false); + add(new SubGlyphPanel("Arabic", arabic, font, frc)); + add(new SubGlyphPanel("Hebrew", hebrew, font, frc)); + add(new SubGlyphPanel("Latin-1 Supplement", latin1sup, font, frc)); + } + + static class SubGlyphPanel extends Panel { + String title; + Dimension extent; + GlyphVector[] vectors; + + static final int kGlyphsPerLine = 20; + + SubGlyphPanel(String title, String chars, Font font, FontRenderContext frc) { + + this.title = title; + setBackground(Color.white); + + double width = 0; + double height = 0; + + int max = chars.length(); + vectors = new GlyphVector[(max + kGlyphsPerLine - 1) / kGlyphsPerLine]; + for (int i = 0; i < vectors.length; i++) { + int start = i * 20; + int limit = Math.min(max, (i + 1) * kGlyphsPerLine); + String substr = ""; + for (int j = start; j < limit; ++j) { + substr = substr.concat(chars.charAt(j) + " "); + } + GlyphVector gv = font.createGlyphVector(frc, substr); + vectors[i] = gv; + Rectangle2D bounds = gv.getLogicalBounds(); + + width = Math.max(width, bounds.getWidth()); + height += bounds.getHeight(); + } + + extent = new Dimension((int)(width + 1), (int)(height + 1 + 30)); // room for title + + setSize(getPreferredSize()); + } + + public Dimension getPreferredSize() { + return new Dimension(extent); + } + + public Dimension getMinimumSize() { + return getPreferredSize(); + } + + public Dimension getMaximumSize() { + return getPreferredSize(); + } + + public void paint(Graphics g) { + Graphics2D g2d = (Graphics2D)g; + + g.drawString(title, 10, 20); + + float x = 10; + float y = 30; + for (int i = 0; i < vectors.length; ++i) { + GlyphVector gv = vectors[i]; + Rectangle2D bounds = gv.getLogicalBounds(); + g2d.drawGlyphVector(gv, x, (float)(y - bounds.getY())); + y += bounds.getHeight(); + } + } + } +} diff --git a/test/jdk/sun/awt/font/TestDevTransform.java b/test/jdk/sun/awt/font/TestDevTransform.java new file mode 100644 index 00000000000..2783401c0f2 --- /dev/null +++ b/test/jdk/sun/awt/font/TestDevTransform.java @@ -0,0 +1,174 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4269775 8341535 + * @summary Check that different text rendering APIs agree + */ + +/** + * Draw into an image rendering the same text string nine different + * ways: as a TextLayout, a simple String, and a GlyphVector, each + * with three different x scale factors. The expectation is that each + * set of three strings would appear the same although offset in y to + * avoid overlap. The bug was that the y positions of the individual characters + * of the TextLayout and GlyphVector were wrong, so the strings appeared + * to be rendered at different angles. + */ + +import java.awt.Color; +import java.awt.Font; +import java.awt.Graphics2D; +import java.awt.RenderingHints; +import java.awt.font.FontRenderContext; +import java.awt.font.GlyphVector; +import java.awt.font.TextLayout; +import java.awt.geom.AffineTransform; +import java.awt.image.BufferedImage; +import javax.imageio.ImageIO; +import java.io.File; +import java.util.HashMap; + +public class TestDevTransform { + + static HashMap hints = new HashMap<>(); + + static { + hints.put(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); + hints.put(RenderingHints.KEY_TEXT_ANTIALIASING, + RenderingHints.VALUE_TEXT_ANTIALIAS_ON); + hints.put(RenderingHints.KEY_FRACTIONALMETRICS, + RenderingHints.VALUE_FRACTIONALMETRICS_ON); + } + + static String test = "This is only a test"; + static double angle = Math.PI / 6.0; // Rotate 30 degrees + static final int W = 400, H = 400; + + static void draw(Graphics2D g2d, TextLayout layout, + float x, float y, float scalex) { + AffineTransform saveTransform = g2d.getTransform(); + g2d.translate(x, y); + g2d.rotate(angle); + g2d.scale(scalex, 1f); + layout.draw(g2d, 0f, 0f); + g2d.setTransform(saveTransform); + } + + static void draw(Graphics2D g2d, String string, + float x, float y, float scalex) { + AffineTransform saveTransform = g2d.getTransform(); + g2d.translate(x, y); + g2d.rotate(angle); + g2d.scale(scalex, 1f); + g2d.drawString(string, 0f, 0f); + g2d.setTransform(saveTransform); + } + + static void draw(Graphics2D g2d, GlyphVector gv, + float x, float y, float scalex) { + AffineTransform saveTransform = g2d.getTransform(); + g2d.translate(x, y); + g2d.rotate(angle); + g2d.scale(scalex, 1f); + g2d.drawGlyphVector(gv, 0f, 0f); + g2d.setTransform(saveTransform); + } + + static void init(Graphics2D g2d) { + g2d.setColor(Color.white); + g2d.fillRect(0, 0, W, H); + g2d.setColor(Color.black); + g2d.scale(1.481f, 1.481); // Convert to 108 dpi + g2d.addRenderingHints(hints); + Font font = new Font(Font.DIALOG, Font.PLAIN, 12); + g2d.setFont(font); + } + + static void compare(BufferedImage bi1, String name1, BufferedImage bi2, String name2) throws Exception { + int nonWhite1 = 0; + int nonWhite2 = 0; + int differences = 0; + int whitePixel = Color.white.getRGB(); + for (int x = 0; x < bi1.getWidth(); x++) { + for (int y = 0; y < bi1.getHeight(); y++) { + int pix1 = bi1.getRGB(x, y); + int pix2 = bi2.getRGB(x, y); + if (pix1 != whitePixel) { nonWhite1++; } + if (pix2 != whitePixel) { nonWhite2++; } + if (bi1.getRGB(x, y) != bi2.getRGB(x, y)) { + differences++; + } + } + } + int nonWhite = (nonWhite1 < nonWhite2) ? nonWhite1 : nonWhite2; + if (differences > 0 && ((nonWhite / differences) < 20)) { + ImageIO.write(bi1, "png", new File(name1 + ".png")); + ImageIO.write(bi2, "png", new File(name2 + ".png")); + System.err.println("nonWhite image 1 = " + nonWhite1); + System.err.println("nonWhite image 2 = " + nonWhite2); + System.err.println("Number of non-white differing pixels=" + differences); + throw new RuntimeException("Different rendering: " + differences + " pixels differ."); + } + } + + public static void main(String args[]) throws Exception { + + BufferedImage tl_Image = new BufferedImage(W, H, BufferedImage.TYPE_INT_RGB); + { + Graphics2D tl_g2d = tl_Image.createGraphics(); + init(tl_g2d); + FontRenderContext frc = tl_g2d.getFontRenderContext(); + // Specify font from graphics to be sure it is the same as the other cases. + TextLayout tl = new TextLayout(test, tl_g2d.getFont(), frc); + draw(tl_g2d, tl, 10f, 12f, 3.0f); + draw(tl_g2d, tl, 10f, 24f, 1.0f); + draw(tl_g2d, tl, 10f, 36f, 0.33f); + } + + BufferedImage st_Image = new BufferedImage(400, 400, BufferedImage.TYPE_INT_RGB); + { + Graphics2D st_g2d = st_Image.createGraphics(); + init(st_g2d); + draw(st_g2d, test, 10f, 12f, 3.0f); + draw(st_g2d, test, 10f, 24f, 1.0f); + draw(st_g2d, test, 10f, 36f, .33f); + } + + BufferedImage gv_Image = new BufferedImage(400, 400, BufferedImage.TYPE_INT_RGB); + { + Graphics2D gv_g2d = gv_Image.createGraphics(); + init(gv_g2d); + FontRenderContext frc = gv_g2d.getFontRenderContext(); + GlyphVector gv = gv_g2d.getFont().createGlyphVector(frc, test); + draw(gv_g2d, gv, 10f, 12f, 3.0f); + draw(gv_g2d, gv, 10f, 24f, 1.0f); + draw(gv_g2d, gv, 10f, 36f, .33f); + } + + compare(tl_Image, "textlayout", st_Image, "string"); + compare(gv_Image, "glyphvector", st_Image, "string"); + } +} diff --git a/test/jdk/sun/awt/image/BytePackedRaster/DitherTest.java b/test/jdk/sun/awt/image/BytePackedRaster/DitherTest.java new file mode 100644 index 00000000000..29b42b49fe7 --- /dev/null +++ b/test/jdk/sun/awt/image/BytePackedRaster/DitherTest.java @@ -0,0 +1,147 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4184283 + * @summary Checks rendering of dithered byte packed image does not crash. + */ + +import java.awt.Color; +import java.awt.Component; +import java.awt.Graphics2D; +import java.awt.Image; +import java.awt.image.BufferedImage; +import java.awt.image.ColorModel; +import java.awt.image.IndexColorModel; +import java.awt.image.MemoryImageSource; +import java.awt.image.WritableRaster; + +public class DitherTest extends Component { + + final static int NOOP = 0; + final static int RED = 1; + final static int GREEN = 2; + final static int BLUE = 3; + final static int ALPHA = 4; + final static int SATURATION = 5; + + final static byte red[] = {(byte)0, (byte)132, (byte)0, (byte)132, (byte)0, (byte)132, + (byte)0, (byte)198, (byte)198, (byte)165, (byte)255, (byte)165, (byte)132, + (byte)255, (byte)0, (byte)255}; + + final static byte green[] = {(byte)0, (byte)0, (byte)130, (byte)130, (byte)0, + (byte)0, (byte)130, (byte)195, (byte)223, (byte)203, (byte)251, (byte)162, + (byte)132, (byte)0, (byte)255, (byte)255}; + + final static byte blue[] = {(byte)0, (byte)0, (byte)0, (byte)0, (byte)132, (byte)132, + (byte)132, (byte)198, (byte)198, (byte)247, (byte)247, (byte)165, (byte)132, + (byte)0, (byte)0, (byte)0}; + + static IndexColorModel cm16 = new IndexColorModel( 4, 16, red, green, blue); + + + public static void main(String args[]) { + + int imageWidth = 256; + int imageHeight = 256; + WritableRaster raster = cm16.createCompatibleWritableRaster(imageWidth, imageHeight); + BufferedImage intermediateImage = new BufferedImage(cm16, raster, false, null); + Image calculatedImage = calculateImage(); + + Graphics2D ig = intermediateImage.createGraphics(); + // Clear background and fill a red rectangle just to prove that we can draw on intermediateImage + ig.setColor(Color.white); + ig.fillRect(0,0,imageWidth,imageHeight); + ig.drawImage(calculatedImage, 0, 0, imageWidth, imageHeight, null); + ig.setColor(Color.red); + ig.fillRect(0,0,5,5); + + BufferedImage destImage = new BufferedImage(imageWidth, imageWidth, BufferedImage.TYPE_INT_RGB); + Graphics2D dg = destImage.createGraphics(); + dg.drawImage(intermediateImage, 0, 0, imageWidth, imageHeight, null); + } + + private static void applymethod(int c[], int method, int step, int total, int vals[]) { + if (method == NOOP) + return; + int val = ((total < 2) + ? vals[0] + : vals[0] + ((vals[1] - vals[0]) * step / (total - 1))); + switch (method) { + case RED: + c[0] = val; + break; + case GREEN: + c[1] = val; + break; + case BLUE: + c[2] = val; + break; + case ALPHA: + c[3] = val; + break; + case SATURATION: + int max = Math.max(Math.max(c[0], c[1]), c[2]); + int min = max * (255 - val) / 255; + if (c[0] == 0) c[0] = min; + if (c[1] == 0) c[1] = min; + if (c[2] == 0) c[2] = min; + break; + } + } + + private static Image calculateImage() { + + int xvals[] = { 0, 255 }; + int yvals[] = { 0, 255 }; + int xmethod = RED; + int ymethod = BLUE; + int width = 256; + int height = 256; + int pixels[] = new int[width * height]; + int c[] = new int[4]; + int index = 0; + for (int j = 0; j < height; j++) { + for (int i = 0; i < width; i++) { + c[0] = c[1] = c[2] = 0; + c[3] = 255; + if (xmethod < ymethod) { + applymethod(c, xmethod, i, width, xvals); + applymethod(c, ymethod, j, height, yvals); + } else { + applymethod(c, ymethod, j, height, yvals); + applymethod(c, xmethod, i, width, xvals); + } + pixels[index++] = ((c[3] << 24) | + (c[0] << 16) | + (c[1] << 8) | + (c[2] << 0)); + } + } + + DitherTest dt = new DitherTest(); + return dt.createImage(new MemoryImageSource(width, height, ColorModel.getRGBdefault(), pixels, 0, width)); + } +} + diff --git a/test/jdk/sun/awt/image/BytePackedRaster/MultiOp.java b/test/jdk/sun/awt/image/BytePackedRaster/MultiOp.java new file mode 100644 index 00000000000..2c396792548 --- /dev/null +++ b/test/jdk/sun/awt/image/BytePackedRaster/MultiOp.java @@ -0,0 +1,108 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4213160 + * @summary Should generate a black image + */ + +import java.awt.Color; +import java.awt.Graphics2D; +import java.awt.image.BufferedImage; +import java.awt.image.ColorModel; +import java.awt.image.DataBuffer; +import java.awt.image.DataBufferByte; +import java.awt.image.IndexColorModel; +import java.awt.image.Raster; +import java.awt.image.WritableRaster; +import java.awt.geom.AffineTransform; + +public class MultiOp { + + public static void main(String[] argv) { + + int width = 256; + int height = 256; + + int pixelBits = 2; // 1, 2, 4, or 8 + // 1 and 8 make the code throw ImagingOpException, 2 and 4 + // make the code SEGV on Sol. + + byte[] lut1Arr = new byte[] {0, (byte)255 }; + byte[] lut2Arr = new byte[] {0, (byte)85, (byte)170, (byte)255}; + byte[] lut4Arr = new byte[] {0, (byte)17, (byte)34, (byte)51, + (byte)68, (byte)85,(byte) 102, (byte)119, + (byte)136, (byte)153, (byte)170, (byte)187, + (byte)204, (byte)221, (byte)238, (byte)255}; + byte[] lut8Arr = new byte[256]; + for (int i = 0; i < 256; i++) { + lut8Arr[i] = (byte)i; + } + + // Create the binary image + int bytesPerRow = width * pixelBits / 8; + byte[] imageData = new byte[height * bytesPerRow]; + ColorModel cm = null; + + switch (pixelBits) { + case 1: + cm = new IndexColorModel(pixelBits, lut1Arr.length, + lut1Arr, lut1Arr, lut1Arr); + break; + case 2: + cm = new IndexColorModel(pixelBits, lut2Arr.length, + lut2Arr, lut2Arr, lut2Arr); + break; + case 4: + cm = new IndexColorModel(pixelBits, lut4Arr.length, + lut4Arr, lut4Arr, lut4Arr); + break; + case 8: + cm = new IndexColorModel(pixelBits, lut8Arr.length, + lut8Arr, lut8Arr, lut8Arr); + break; + default: + {new Exception("Invalid # of bit per pixel").printStackTrace();} + } + + DataBuffer db = new DataBufferByte(imageData, imageData.length); + WritableRaster r = Raster.createPackedRaster(db, width, height, + pixelBits, null); + BufferedImage srcImage = new BufferedImage(cm, r, false, null); + + BufferedImage destImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); + Graphics2D g = destImage.createGraphics(); + AffineTransform af = AffineTransform.getScaleInstance(.5, .5); + // This draw image is the problem + g.drawImage(srcImage, af, null); + int blackPixel = Color.black.getRGB(); + for (int x = 0; x < width; x++) { + for (int y = 0; y < height; y++) { + if (destImage.getRGB(x, y) != blackPixel) { + throw new RuntimeException("Not black"); + } + } + } + } +} diff --git a/test/jdk/sun/awt/image/ImageRepresentation/ByteBinaryBitmask.java b/test/jdk/sun/awt/image/ImageRepresentation/ByteBinaryBitmask.java new file mode 100644 index 00000000000..26edca7f09b --- /dev/null +++ b/test/jdk/sun/awt/image/ImageRepresentation/ByteBinaryBitmask.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4673490 + * @summary This test verifies that Toolkit images with a 1-bit + * IndexColorModel (known as ByteBinary) and a transparent index are rendered properly. + */ + +import java.awt.Color; +import java.awt.Graphics2D; + +import java.awt.image.BufferedImage; +import java.awt.image.IndexColorModel; + +public class ByteBinaryBitmask { + + public static void main(String argv[]) throws Exception { + + /* Create the image */ + int w = 16, h = 16; + byte[] bw = { (byte)255, (byte)0, }; + IndexColorModel icm = new IndexColorModel(1, 2, bw, bw, bw, 0); + BufferedImage img = new BufferedImage(w, h, BufferedImage.TYPE_BYTE_BINARY, icm); + Graphics2D g2d = img.createGraphics(); + g2d.setColor(Color.white); + g2d.fillRect(0, 0, w, h); + g2d.setColor(Color.black); + int xoff = 5; + g2d.fillRect(xoff, 5, 1, 10); // 1 pixel wide + + int dw = 200, dh = 50; + BufferedImage dest = new BufferedImage(dw, dh, BufferedImage.TYPE_INT_RGB); + Graphics2D g = dest.createGraphics(); + g.setColor(Color.green); + g.fillRect(0, 0, dw, dh); + int x1 = 10; + int x2 = 50; + int x3 = 90; + int x4 = 130; + g.drawImage(img, x1, 10, null); + g.drawImage(img, x2, 10, null); + g.drawImage(img, x3, 10, null); + g.drawImage(img, x4, 10, null); + + int blackPix = Color.black.getRGB(); + for (int y = 0; y < dh; y++) { + boolean isBlack = false; + for (int x = 0; x < dw; x++) { + int rgb = dest.getRGB(x, y); + if (rgb == blackPix) { + /* Src image has a one pixel wide vertical rect at off "xoff" and + * this is drawn at x1/x2/x3/x4) so the sum of those are the x locations + * to expect black. + */ + if (x != (x1 + xoff) && x != (x2 + xoff) && x != (x3 + xoff) && x!= (x4 + xoff)) { + throw new RuntimeException("wrong x location: " +x); + } + if (isBlack) { + throw new RuntimeException("black after black"); + } + } + isBlack = rgb == blackPix; + } + } + } +} diff --git a/test/jdk/sun/awt/image/ImageRepresentation/CustomSourceCM.java b/test/jdk/sun/awt/image/ImageRepresentation/CustomSourceCM.java new file mode 100644 index 00000000000..c56b4ef88c8 --- /dev/null +++ b/test/jdk/sun/awt/image/ImageRepresentation/CustomSourceCM.java @@ -0,0 +1,142 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 4192756 + * @summary Tests that using a non-default colormodel generates correct images under 16/24 bit mode + */ + +import java.awt.Color; +import java.awt.Component; +import java.awt.Graphics2D; +import java.awt.Image; +import java.awt.image.BufferedImage; +import java.awt.image.ColorModel; +import java.awt.image.DirectColorModel; +import java.awt.image.ComponentColorModel; +import java.awt.image.MemoryImageSource; +import java.util.Arrays; + +/* + * NOTE: This bug only appears under specific conditions. If the background of + * the surface is red, then you are not running under the conditions necessary + * to test for the regression so the results of this test will be inconclusive. + * + * The test should be run under any of the following screen depths/surfaces: + * + * 15-bit, otherwise known as 555 RGB or 32768 (thousands) colors + * 16-bit, otherwise known as 565 RGB or 65536 (thousands) colors + * 24-bit, otherwise known as 16777216 (millions) colors + * + * The test draws 2 rectangles. Both rectangles should be half black (left) + * and half blue (right). If the top rectangle is all black, the test fails. + * If the background is red, the results are inconclusive (see above). +*/ + +public class CustomSourceCM extends Component { + + public static int IMG_W = 80; + public static int IMG_H = 30; + + static void test(int imageType) { + + int w = IMG_W + 20; + int h = IMG_H * 2 + 40; + BufferedImage bi = new BufferedImage(w, h, imageType); + + DirectColorModel dcm; + + /* the next dozen lines or so are intended to help + * ascertain if the destination surface is of the type + * that exhibited the original bug, making the background + * white in those cases. It is not strictly necessary. + * It is only for a manual tester to be able to tell by looking. + * The real test is the check for black and blue later on. + */ + Graphics2D g = bi.createGraphics(); + g.setColor(Color.red); + g.fillRect(0, 0, w, h); + + ColorModel cm = bi.getColorModel(); + if (cm instanceof ComponentColorModel) { + g.setColor(Color.white); + g.fillRect(0, 0, w, h); + } else if (cm instanceof DirectColorModel) { + dcm = (DirectColorModel) cm; + if (dcm.getPixelSize() < 24) { + g.setColor(Color.white); + g.fillRect(0, 0, w, h); + } + } + + // Construct a ColorModel and data for a 16-bit 565 image... + dcm = new DirectColorModel(16, 0x1f, 0x7e0, 0xf800); + + // Create an image which is black on the left, blue on the right. + int[] pixels = new int[IMG_W * IMG_H]; + int blue = dcm.getBlueMask(); + int off = 0; + for (int y = 0; y < IMG_H; y++) { + Arrays.fill(pixels, off, off+IMG_W/2, 0); + Arrays.fill(pixels, off+IMG_W/2, off+IMG_W, blue); + off += IMG_W; + } + MemoryImageSource mis = new MemoryImageSource(IMG_W, IMG_H, dcm, + pixels, 0, IMG_W); + CustomSourceCM comp = new CustomSourceCM(); + Image img = comp.createImage(mis); + + // Draw the image on to the surface. + g.drawImage(img, 10, 10, null); + + // Create a similar effect with 2 fillrects, below the image. + g.setColor(Color.black); + g.fillRect(10, 60, IMG_W/2, IMG_H); + g.setColor(Color.blue); + g.fillRect(10+IMG_W/2, 60, IMG_W/2, IMG_H); + + // Now sample points in the image to confirm they are the expected color. + int bluePix = Color.blue.getRGB(); + int blackPix = Color.black.getRGB(); + int black_topLeft = bi.getRGB(10+IMG_W/4, 10+IMG_H/2); + int blue_topRight = bi.getRGB(10+IMG_W*3/4, 10+IMG_H/2); + int black_bottomLeft = bi.getRGB(10+IMG_W/4, 60+IMG_H/2); + int blue_bottomRight = bi.getRGB(10+IMG_W*3/4, 60+IMG_H/2); + if ((black_topLeft != blackPix) || (black_bottomLeft != blackPix) || + (blue_topRight != bluePix) || (blue_bottomRight != bluePix)) { + + String fileName = "failed " + imageType + ".png"; + try { + javax.imageio.ImageIO.write(bi, "png", new java.io.File(fileName)); + } catch (Exception e) { }; + throw new RuntimeException("unexpected colors"); + } + } + + public static void main(String argv[]) { + test(BufferedImage.TYPE_USHORT_555_RGB); + test(BufferedImage.TYPE_USHORT_565_RGB); + test(BufferedImage.TYPE_3BYTE_BGR); + } +} diff --git a/test/jdk/sun/awt/windows/TestPen.java b/test/jdk/sun/awt/windows/TestPen.java new file mode 100644 index 00000000000..25b7304bdc8 --- /dev/null +++ b/test/jdk/sun/awt/windows/TestPen.java @@ -0,0 +1,102 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4277201 + * @summary verifies that invoking a fill on a brand new Graphics object + * does not stroke the shape in addition to filling it + * @key headful + */ + +/* + * This test case tests for a problem with initializing GDI graphics + * contexts (HDCs) where a pen is left installed in the graphics object + * even though the AWT believes that there is no Pen installed. The + * result is that when you try to fill a shape, GDI will both fill and + * stroke it. +*/ + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Panel; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.Robot; +import java.awt.image.BufferedImage; + +public class TestPen extends Panel { + + static volatile TestPen pen; + static volatile Frame frame; + + public TestPen() { + setForeground(Color.black); + setBackground(Color.white); + } + + public Dimension getPreferredSize() { + return new Dimension(200, 200); + } + + public void paint(Graphics g) { + g.setColor(Color.green); + g.fillOval(50, 50, 100, 100); + } + + static void createUI() { + frame = new Frame(); + pen = new TestPen(); + frame.add(pen); + frame.pack(); + frame.setVisible(true); + } + + public static void main(String argv[]) throws Exception { + try { + EventQueue.invokeAndWait(TestPen::createUI); + Robot robot = new Robot(); + robot.waitForIdle(); + robot.delay(2000); + Point p = pen.getLocationOnScreen(); + Dimension d = pen.getSize(); + Rectangle r = new Rectangle(p.x + 1, p.y + 1, d.width - 2, d.height - 2); + BufferedImage bi = robot.createScreenCapture(r); + int blackPixel = Color.black.getRGB(); + for (int y = 0; y < bi.getHeight(); y++ ) { + for (int x = 0; x < bi.getWidth(); x++ ) { + if (bi.getRGB(x, y) == blackPixel) { + throw new RuntimeException("Black pixel !"); + } + } + } + } finally { + if (frame != null) { + EventQueue.invokeAndWait(frame::dispose); + } + } + } +} diff --git a/test/jdk/sun/java2d/Disposer/TestDisposerLeak.java b/test/jdk/sun/java2d/Disposer/TestDisposerLeak.java index 0fcf8cdda08..bdab5ffb5fb 100644 --- a/test/jdk/sun/java2d/Disposer/TestDisposerLeak.java +++ b/test/jdk/sun/java2d/Disposer/TestDisposerLeak.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,7 +31,7 @@ import sun.java2d.DisposerRecord; * @test * @bug 8129457 * @summary Check Disposer disposes all objects without any memory leaks - * @run main/othervm -mx128m TestDisposerLeak + * @run main/othervm -Xmx128m TestDisposerLeak * @modules java.desktop/sun.java2d */ public final class TestDisposerLeak { diff --git a/test/jdk/sun/java2d/Disposer/TestDisposerRace.java b/test/jdk/sun/java2d/Disposer/TestDisposerRace.java index b78966f1200..cbb594d7a1f 100644 --- a/test/jdk/sun/java2d/Disposer/TestDisposerRace.java +++ b/test/jdk/sun/java2d/Disposer/TestDisposerRace.java @@ -33,7 +33,7 @@ import sun.java2d.DisposerRecord; * @test * @bug 8289208 * @summary Verifies Disposer robustness in a multi-threaded environment. - * @run main/othervm -mx128m TestDisposerRace + * @run main/othervm -Xmx128m TestDisposerRace * @modules java.desktop/sun.java2d */ public final class TestDisposerRace { diff --git a/test/jdk/sun/java2d/GdiRendering/GdiBlitOffscreenTest.java b/test/jdk/sun/java2d/GdiRendering/GdiBlitOffscreenTest.java new file mode 100644 index 00000000000..99cb2bcd106 --- /dev/null +++ b/test/jdk/sun/java2d/GdiRendering/GdiBlitOffscreenTest.java @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4725045 + * @key headful + * @summary verifies that there are no artifacts due to using + * GDI for copies to the back buffer (GDI should only be used + * for copies to the screen) + * @run main GdiBlitOffscreenTest +*/ + +import java.awt.Color; +import java.awt.Graphics; +import java.awt.Image; +import java.awt.Point; +import java.awt.Robot; +import java.awt.image.BufferedImage; +import javax.swing.JComponent; +import javax.swing.JFrame; +import javax.swing.SwingUtilities; + +public class GdiBlitOffscreenTest { + + static volatile JFrame f; + static final int imageW = 100, imageH = 100, FW = 500, FH = 500; + static volatile BufferedImage greenImage; + + public static void main(String[] args) throws Exception { + + // First, create an image. + greenImage = new BufferedImage(imageW, imageH, + BufferedImage.TYPE_INT_RGB); + Graphics redG = greenImage.getGraphics(); + redG.setColor(Color.green); + redG.fillRect(0, 0, imageW, imageH); + redG.setColor(Color.white); + redG.drawString("Passed!", 30, 80); + + Robot robot = new Robot(); + try { + SwingUtilities.invokeAndWait(GdiBlitOffscreenTest::createUI); + robot.delay(1000); + robot.waitForIdle(); + Point p = f.getLocationOnScreen(); + Color c = robot.getPixelColor(p.x+FW/2, p.y+FH/2); + if (!c.equals(Color.green)) { + throw new RuntimeException("Color is " + c); + } + } finally { + if (f != null) { + SwingUtilities.invokeAndWait(f::dispose); + } + } + } + + private static void createUI() { + f = new JFrame("GdiBlitOffscreenTest"); + f.setSize(FW, FH); + f.setVisible(true); + + // copy the image to the window. + Graphics g = f.getGraphics(); + g.drawImage(greenImage, 0, 0, null); + + // Now, get on with the rest of the test + JComponent app = new GdiBlitOffscreenTestComponent(imageW, imageH, greenImage); + app.setSize(500, 500); + f.getContentPane().add(app); + f.validate(); + f.repaint(); + } +} + +class GdiBlitOffscreenTestComponent extends JComponent { + + int imageW, imageH; + Image theImage; + + public GdiBlitOffscreenTestComponent(int imageW, int imageH, + Image theImage) + { + this.theImage = theImage; + this.imageW = imageW; + this.imageH = imageH; + } + + public void paintComponent(Graphics g) { + int imageX = (getWidth() - imageW) / 2; + int imageY = (getHeight() - imageH) / 2; + g.setColor(Color.blue); + g.fillRect(0, 0, getWidth(), getHeight()); + g.setColor(Color.red); + g.fillRect(imageX, imageY, imageW, imageH); + g.setColor(Color.white); + g.drawString("Failed!", imageX + 30, imageY + 80); + g.drawImage(theImage, imageX, imageY, null); + } + +} diff --git a/test/jdk/sun/java2d/GdiRendering/GdiLockTest.java b/test/jdk/sun/java2d/GdiRendering/GdiLockTest.java new file mode 100644 index 00000000000..ea2111f9d2e --- /dev/null +++ b/test/jdk/sun/java2d/GdiRendering/GdiLockTest.java @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4693644 + * @summary verifies that there are no artifacts due to copying with GDI + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual GdiLockTest +*/ + +import java.awt.Color; +import java.awt.Component; +import java.awt.Frame; +import java.awt.Graphics; + +public class GdiLockTest { + + static final String INSTRUCTIONS = """ + A window will open up next to these instructions. + The text you see in that window should blink on and off. + If it never disappears, then the test has failed. + """; + + public static void main(String[] argv) throws Exception { + PassFailJFrame.builder() + .title("GdiLockTest") + .instructions(INSTRUCTIONS) + .testTimeOut(5) + .rows(5) + .columns(45) + .testUI(GdiLockTest::createUI) + .build() + .awaitAndCheck(); + } + + private static Frame createUI() { + Frame f = new Frame("GdiLockTest"); + f.setSize(300, 300); + GdiLockTestComponent test = new GdiLockTestComponent(); + Thread t = new Thread(test); + f.add(test); + t.start(); + return f; + } +} + +class GdiLockTestComponent extends Component implements Runnable { + + boolean textVisible = true; + + public void paint(Graphics g) { + g.setColor(Color.white); + g.fillRect(0, 0, getWidth(), getHeight()); + g.setColor(Color.black); + if (!textVisible) { + g.setClip(200, 200, 300, 300); + } + g.drawString("This text should be blinking", 10, 30); + if (!textVisible) { + g.setClip(0, 0, getWidth(), getHeight()); + } + } + + public void run() { + while (true) { + repaint(); + textVisible = !textVisible; + try { + Thread.sleep(500); + } catch (Exception e) {} + } + } +} diff --git a/test/jdk/sun/java2d/SunGraphics2D/DrawRoundRect0Bug.java b/test/jdk/sun/java2d/SunGraphics2D/DrawRoundRect0Bug.java new file mode 100644 index 00000000000..09b6b3e0b3f --- /dev/null +++ b/test/jdk/sun/java2d/SunGraphics2D/DrawRoundRect0Bug.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 4515761 + * @summary verify that drawRoundRect produces correct output for 0 w/h + */ + +import java.awt.Color; +import static java.awt.Color.*; +import java.awt.Graphics2D; +import java.awt.image.BufferedImage; + +public class DrawRoundRect0Bug { + + public static void main(String argv[]) { + BufferedImage img = new BufferedImage(250, 250, BufferedImage.TYPE_INT_RGB); + Graphics2D g = img.createGraphics(); + + g.setColor(white); + g.fillRect(0, 0, img.getWidth(), img.getHeight()); + + g.setColor(green); + g.drawLine(150, 90, 150, 110); + if (img.getRGB(150, 100) != green.getRGB()) { + throw new RuntimeException("Vertical line not green"); + } + + g.setColor(blue); + g.drawRoundRect(160, 90, 0, 20, 4, 4); + if (img.getRGB(160, 100) != blue.getRGB()) { + throw new RuntimeException("Vertical (ie zero width) round rect not blue"); + } + + g.setColor(green); + g.drawLine(150, 140, 170, 140); + if (img.getRGB(160, 140) != green.getRGB()) { + throw new RuntimeException("Horizontal line not green"); + } + + g.setColor(blue); + g.drawRoundRect(150, 150, 20, 0, 4, 4); + if (img.getRGB(160, 150) != blue.getRGB()) { + throw new RuntimeException("Horizontal (ie zero height) round rect not blue"); + } + } + +} diff --git a/test/jdk/sun/java2d/SunGraphics2D/RevalidateBug.java b/test/jdk/sun/java2d/SunGraphics2D/RevalidateBug.java new file mode 100644 index 00000000000..068dd78284b --- /dev/null +++ b/test/jdk/sun/java2d/SunGraphics2D/RevalidateBug.java @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4652373 + * @summary verify that SunGraphics2D survives surface revalidation + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual RevalidateBug + * @requires (os.family == "windows") + */ + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.GradientPaint; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Insets; +import java.awt.Rectangle; +import javax.swing.JComponent; +import javax.swing.JFrame; + +public class RevalidateBug { + + private static final String INSTRUCTIONS = """ + This bug only reproduces on Windows systems with a task manager that can lock the computer. + + This test draws a grayscale gradient in a window. + + After the gradient becomes visible above, use ctrl-alt-del to bring up + the task manager and lock the computer. + Then unlock the computer and the gradient should be repainted to pass. + + If the gradient does not appear after unlocking (or if the test gets + an error on its own after unlocking the computer) then it fails. + """; + + public static void main(String[] argv) throws Exception { + PassFailJFrame.builder() + .title("RevalidateBug") + .instructions(INSTRUCTIONS) + .testTimeOut(5) + .rows(12) + .columns(50) + .testUI(RevalidateBug::createUI) + .build() + .awaitAndCheck(); + } + + private static JFrame createUI() { + + JComponent comp = new JComponent() { + + protected void paintComponent(Graphics g) { + super.paintComponent(g); + System.out.println("paintComponent"); + Graphics2D g2d = (Graphics2D) g; + + Insets insets = getInsets(); + Rectangle rect = + new Rectangle(insets.left, insets.top, + getWidth() - insets.right - insets.left, + getHeight() - insets.top - insets.bottom); + g2d.setPaint(new GradientPaint(rect.x, rect.y, Color.white, + rect.x + rect.width, rect.y, Color.black)); + + System.out.println(rect + " w:" + getWidth() + " h:"+getHeight()); + + g2d.fillRect(0, 0, getWidth(), getHeight()); + } + + public Dimension getPreferredSize() { + return new Dimension(500, 500); + } + }; + + JFrame f = new JFrame("RevalidateTest"); + f.add(comp); + f.pack(); + return f; + } + +} diff --git a/test/jdk/sun/java2d/SunGraphics2D/ScaledPolyTest.java b/test/jdk/sun/java2d/SunGraphics2D/ScaledPolyTest.java new file mode 100644 index 00000000000..65bb912785b --- /dev/null +++ b/test/jdk/sun/java2d/SunGraphics2D/ScaledPolyTest.java @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 4516037 + * @summary verify that scaled Polygons honor the transform + */ + +import java.awt.Color; +import static java.awt.Color.*; +import java.awt.Graphics2D; +import java.awt.Polygon; +import java.awt.image.BufferedImage; + +public class ScaledPolyTest { + + public static void main(String[] args) { + + Polygon poly = new Polygon(); + poly.addPoint(20, 10); + poly.addPoint(30, 30); + poly.addPoint(10, 30); + poly.addPoint(20, 10); + + int height = 300; + int width = 300; + BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); + Graphics2D g2d = bi.createGraphics(); + g2d.setColor(Color.white); + g2d.fillRect(0, 0, bi.getWidth(), bi.getHeight()); + + g2d.translate(10, 10); + g2d.scale(2, 2); + g2d.setColor(Color.yellow); + g2d.fill(poly); + g2d.setColor(Color.blue); + g2d.draw(poly); + + /* + * Examine each row of the image. + * If the stroked polygon is correctly aligned on the filled polygon, + * if there is anything except white on the line, + * the transition will always be white+->blue+->yellow*->blue*->white+ + */ + int bluePix = blue.getRGB(); + int yellowPix = yellow.getRGB(); + int whitePix = white.getRGB(); + for (int y = 0; y < height; y++ ) { + int x = 0; + int pix = whitePix; + + while (pix == whitePix && x < width) pix = bi.getRGB(x++, y); + if (pix == whitePix && x == width) continue; // all white row. + + if (pix != bluePix) throw new RuntimeException("Expected blue"); + + while (pix == bluePix) pix = bi.getRGB(x++, y); + + if (pix == yellowPix) { + while (pix == yellowPix) pix = bi.getRGB(x++, y); + if (pix != bluePix) throw new RuntimeException("Expected blue"); + while (pix == bluePix) pix = bi.getRGB(x++, y); + if (pix != whitePix) throw new RuntimeException("Expected white"); + } + + while (pix == whitePix && x < width) pix = bi.getRGB(x++, y); + if (pix == whitePix && x == width) { + continue; + } else { + throw new RuntimeException("Expected white to finish the row"); + } + } + } +} diff --git a/test/jdk/sun/java2d/loops/ARGBBgToRGB.java b/test/jdk/sun/java2d/loops/ARGBBgToRGB.java new file mode 100644 index 00000000000..55764af2c13 --- /dev/null +++ b/test/jdk/sun/java2d/loops/ARGBBgToRGB.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4238978 + * @summary This test verifies that the correct blitting loop is being used. + * The correct output should have a yellow border on the top and + * left sides of a red box. The incorrect output would have only + * a red box -- no yellow border." + */ + +import java.awt.Color; +import java.awt.Graphics2D; +import java.awt.image.BufferedImage; + +public class ARGBBgToRGB { + + public static void main(String[] argv) { + BufferedImage bi = new BufferedImage(256, 256, BufferedImage.TYPE_INT_ARGB); + Graphics2D big = bi.createGraphics(); + big.setColor(Color.red); + big.fillRect(30, 30, 150, 150); + + BufferedImage bi2 = new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB); + Graphics2D big2 = bi2.createGraphics(); + big2.drawImage(bi, 0, 0, Color.yellow, null); + + int expectYellowPix = bi2.getRGB(0, 0); + int expectRedPix = bi2.getRGB(50, 50); + if ((expectYellowPix != Color.yellow.getRGB()) || + (expectRedPix != Color.red.getRGB())) + { + throw new RuntimeException("Unexpected colors " + expectYellowPix + " " + expectRedPix); + } + } +} diff --git a/test/jdk/sun/java2d/loops/CopyNegative.java b/test/jdk/sun/java2d/loops/CopyNegative.java new file mode 100644 index 00000000000..0b8296918ac --- /dev/null +++ b/test/jdk/sun/java2d/loops/CopyNegative.java @@ -0,0 +1,103 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4188744 + * @summary This test verifies that copyArea performs correctly for negative offset values. + * The correct output shows that the text area is moved to the left and down, + * leaving some garbage on the right and the top. + * The incorrect copy would show the text area garbled and no text is legible. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual CopyNegative + */ + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Image; +import java.awt.Panel; + +public class CopyNegative extends Panel { + + private static final String INSTRUCTIONS = """ + This test verifies that copyArea performs correctly for negative offset values. + The test draws text in an image, then copies the contents repeatedly. + The correct output shows that the text is moved to the left and down, + leaving some garbage on the top / right and some legible text at the bottom left. + The incorrect copy would show the whole text area garbled and no text is legible. + """; + + public static void main(String[] argv) throws Exception { + PassFailJFrame.builder() + .title("CopyNegativeTest") + .instructions(INSTRUCTIONS) + .testUI(CopyNegative::createUI) + .testTimeOut(5) + .rows(10) + .columns(50) + .build() + .awaitAndCheck(); + } + + Image img; + + static final int W = 200, H = 200; + + static Frame createUI() { + Frame f = new Frame("CopyNegative"); + f.add(new CopyNegative()); + f.pack(); + return f; + } + + public Dimension getPreferredSize() { + return new Dimension(W, H); + } + + private void doCopy() { + Graphics g = img.getGraphics(); + g.setColor(Color.white); + g.fillRect(0, 0, W, H); + g.setColor(Color.black); + String text = "Some Text To Display, it is long enough to fill the entire display line."; + StringBuffer sb = new StringBuffer(text); + + for (int i = 1; i < 50; i++) { + g.drawString(sb.toString(), 5,20 * i - 10); + sb.insert(0, Integer.toString(i)); + } + for (int i = 0 ; i < 20 ; i++ ) { + g.copyArea(0, 0, W, H, -3, 3); + } + } + + public void paint(Graphics g) { + img = createImage(W, H); + doCopy(); + g.drawImage(img, 0, 0, this); + } + +} diff --git a/test/jdk/sun/java2d/loops/DitheredSolidFill.java b/test/jdk/sun/java2d/loops/DitheredSolidFill.java new file mode 100644 index 00000000000..509b0bbe3b2 --- /dev/null +++ b/test/jdk/sun/java2d/loops/DitheredSolidFill.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 4181172 + * @summary Confirm that solid white fill is not dithered on an 8-bit indexed surface. + * The test draws two areas filled with white solid color. + * The upper left square is filled in aliasing mode and + * the lower right square is filled in anti-aliasing mode. + */ + +import java.awt.Color; +import java.awt.Graphics2D; +import java.awt.RenderingHints; +import java.awt.image.BufferedImage; + +public class DitheredSolidFill { + + public static void main(String args[]) { + BufferedImage bi = new BufferedImage(120, 120, BufferedImage.TYPE_BYTE_INDEXED); + Graphics2D g2D = bi.createGraphics(); + + g2D.setColor(Color.black); + g2D.fillRect(0, 0, 100, 100); + + g2D.setColor(Color.white); + g2D.fillRect(5, 5, 40, 40); + checkPixels(bi, 5, 5, 40, 40); + + g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + g2D.fillRect(55, 55, 40, 40); + checkPixels(bi, 55, 55, 40, 40); + } + + static void checkPixels(BufferedImage bi, int x, int y, int w, int h) { + // pixel can be off white, but must be the same in all cases. + int expectedPix = bi.getRGB(x, y); + for (int x0 = x; x0 < x + w; x0++) { + for (int y0 = y; y0 < y + h; y0++) { + if (bi.getRGB(x0, y0) != expectedPix) { + try { + javax.imageio.ImageIO.write(bi, "png", new java.io.File("failed.png")); + } catch (Exception e) { + } + throw new RuntimeException("Not expected pix : " + + Integer.toHexString(bi.getRGB(x0, y0)) + + " at " + x0 + "," + y0); + } + } + } + } +} diff --git a/test/jdk/sun/java2d/loops/OffsetCalculationTest.java b/test/jdk/sun/java2d/loops/OffsetCalculationTest.java new file mode 100644 index 00000000000..fe30107f22a --- /dev/null +++ b/test/jdk/sun/java2d/loops/OffsetCalculationTest.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + @test + @bug 4236576 + @summary tests that a BufferedImage in TYPE_3BYTE_BGR format is correctly + drawn when there is an offset between the Graphics clip bounds + and the clip box of the underlying device context. + @run main OffsetCalculationTest +*/ + +import java.awt.Color; +import java.awt.Graphics2D; +import java.awt.Rectangle; +import java.awt.image.BufferedImage; +import java.awt.image.DataBuffer; + +public class OffsetCalculationTest { + + public static void main(String[] args) { + BufferedImage srcImage = new BufferedImage(500, 500, BufferedImage.TYPE_3BYTE_BGR); + + DataBuffer buffer = srcImage.getRaster().getDataBuffer(); + for (int i = 2; i < buffer.getSize(); i+=3) { + // setting each pixel to blue via the data buffer elements. + buffer.setElem(i - 2, 0xff); + buffer.setElem(i - 1, 0); + buffer.setElem(i, 0); + } + + int w = 200, h = 200; + BufferedImage destImage = new BufferedImage(w, h, BufferedImage.TYPE_3BYTE_BGR); + Graphics2D g = destImage.createGraphics(); + Rectangle r = new Rectangle(0, 0, w, h); + g.setClip(r.x - 1, r.y, r.width + 1, r.height); + g.drawImage(srcImage, 0, 0, null); + + int bluepix = Color.blue.getRGB(); + for (int y = 0; y < w; y++) { + for (int x = 0; x < h; x++) { + if (destImage.getRGB(x, y) != bluepix) { + throw new RuntimeException("Not Blue"); + } + } + } + } +} diff --git a/test/jdk/sun/java2d/loops/XORClearRect.java b/test/jdk/sun/java2d/loops/XORClearRect.java new file mode 100644 index 00000000000..f5c30581cf1 --- /dev/null +++ b/test/jdk/sun/java2d/loops/XORClearRect.java @@ -0,0 +1,93 @@ +/* + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4088173 + * @summary This interactive test verifies that the XOR mode is not affecting + * the clearRect() call. The correct output looks like: + * + * \ / + * \ / + * The backgound is blue. + * The lines outside the central rectangle are green. + * The central rectangle is also blue (the result of clearRect()) + * / \ + * / \ + * + * @key headful + * @run main XORClearRect + */ + +import java.awt.Color; +import java.awt.EventQueue; +import java.awt.Graphics; +import java.awt.Frame; +import java.awt.Panel; +import java.awt.Point; +import java.awt.Robot; + +public class XORClearRect extends Panel { + + public static void main(String args[]) throws Exception { + EventQueue.invokeAndWait(XORClearRect::createUI); + try { + Robot robot = new Robot(); + robot.waitForIdle(); + robot.delay(2000); + Point p = frame.getLocationOnScreen(); + int pix = robot.getPixelColor(p.x + 100, p.y + 100).getRGB(); + if (pix != Color.blue.getRGB()) { + throw new RuntimeException("Not blue"); + } + } finally { + if (frame != null) { + EventQueue.invokeAndWait(frame::dispose); + } + } + } + + static volatile Frame frame; + + static void createUI() { + frame = new Frame("XORClearRect"); + frame.setBackground(Color.blue); + XORClearRect xor = new XORClearRect(); + frame.add(xor); + frame.setSize(200,200); + frame.setVisible(true); + } + + public XORClearRect() { + setBackground(Color.blue); + } + + public void paint(Graphics g) { + g.setColor(Color.green); + g.drawLine(0,0,200,200); + g.drawLine(0,200,200,0); + g.setXORMode(Color.blue); + g.clearRect(50,50,100,100); //expecting the rectangle to be filled + // with the background color (blue) + } +} diff --git a/test/jdk/sun/java2d/marlin/CrashTest.java b/test/jdk/sun/java2d/marlin/CrashTest.java index b5283fdf332..5b9632caafe 100644 --- a/test/jdk/sun/java2d/marlin/CrashTest.java +++ b/test/jdk/sun/java2d/marlin/CrashTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,9 +35,9 @@ import javax.imageio.ImageIO; /** * @test * @summary Simple crash rendering test using huge GeneralPaths with the Marlin renderer - * @run main/othervm -mx512m CrashTest + * @run main/othervm -Xmx512m CrashTest * @ignore tests that take a long time and consumes 5Gb memory - * @run main/othervm -ms4g -mx4g CrashTest -slow + * @run main/othervm -Xms4g -Xmx4g CrashTest -slow */ public class CrashTest { diff --git a/test/jdk/sun/java2d/pipe/DrawImageBgTest.java b/test/jdk/sun/java2d/pipe/DrawImageBgTest.java new file mode 100644 index 00000000000..962529dc956 --- /dev/null +++ b/test/jdk/sun/java2d/pipe/DrawImageBgTest.java @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4532352 + * @summary This test verifies that the specified background color is rendered + * in the special case of: + * Graphics.drawImage(Image img, int dx1, int dy1, int dx2, int dy2, + * int sx1, int sy1, int sx2, int sy2, + * Color bgColor, ImageObserver observer) + * where no scaling takes place because the source and destination + * bounds have the same width and height. + */ + +import java.io.File; +import java.awt.Color; +import java.awt.Graphics2D; +import java.awt.image.BufferedImage; +import javax.imageio.ImageIO; + +public class DrawImageBgTest { + + public static void main(String argv[]) throws Exception { + + int dx, dy, dw, dh; + int sx, sy, sw, sh; + + int iw = 250, ih = 250; + String sep = System.getProperty("file.separator"); + String dir = System.getProperty("test.src", "."); + String prefix = dir+sep; + BufferedImage img = ImageIO.read(new File(prefix + "duke.gif")); + BufferedImage dest = new BufferedImage(iw, ih, BufferedImage.TYPE_INT_RGB); + + Graphics2D g = dest.createGraphics(); + g.setColor(Color.blue); + g.fillRect(0, 0, iw, ih); + + // source and destination dimensions are different, results in scaling + dx = 10; + dy = 10; + dw = 100; + dh = 200; + sx = 10; + sy = 10; + sw = 50; + sh = 100; + g.drawImage(img, + dx, dy, dx + dw, dy + dh, + sx, sy, sx + sw, sy + sh, + Color.yellow, null); + + int pix1 = dest.getRGB(dx + 1, dy + 1); + + // source and destination dimensions are the same, no scaling + dx = 120; + dy = 10; + sx = 10; + sy = 10; + sw = dw = 50; + sh = dh = 100; + g.drawImage(img, + dx, dy, dx + dw, dy + dh, + sx, sy, sx + sw, sy + sh, + Color.yellow, null); + + int pix2 = dest.getRGB(dx + 1, dy + 1); + int yellow = Color.yellow.getRGB(); + + if (pix1 != yellow || pix2 != yellow) { + ImageIO.write(dest, "gif", new File("op.gif")); + throw new RuntimeException("pix1=" + Integer.toHexString(pix1) + + " pix2=" + Integer.toHexString(pix2)); + } + } +} diff --git a/test/jdk/sun/java2d/pipe/duke.gif b/test/jdk/sun/java2d/pipe/duke.gif new file mode 100644 index 00000000000..ed32e0ff79b Binary files /dev/null and b/test/jdk/sun/java2d/pipe/duke.gif differ diff --git a/test/jdk/sun/management/jdp/DynamicLauncher.java b/test/jdk/sun/management/jdp/DynamicLauncher.java index 9102fe32a94..b79672211b1 100644 --- a/test/jdk/sun/management/jdp/DynamicLauncher.java +++ b/test/jdk/sun/management/jdp/DynamicLauncher.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,6 +37,8 @@ import java.util.UUID; */ public abstract class DynamicLauncher { + private static final int MAX_RETRY_ATTEMPTS = 10; + final String jdpName = UUID.randomUUID().toString(); OutputAnalyzer output; int jmxPort; @@ -52,7 +54,7 @@ public abstract class DynamicLauncher { try { output.shouldNotContain("Port already in use"); } catch (RuntimeException e) { - if (retries < 3) { + if (retries < MAX_RETRY_ATTEMPTS) { retries++; tryAgain = true; } diff --git a/test/jdk/sun/management/jmxremote/bootstrap/JMXInterfaceBindingTest.java b/test/jdk/sun/management/jmxremote/bootstrap/JMXInterfaceBindingTest.java index c062f7c75b8..61359084297 100644 --- a/test/jdk/sun/management/jmxremote/bootstrap/JMXInterfaceBindingTest.java +++ b/test/jdk/sun/management/jmxremote/bootstrap/JMXInterfaceBindingTest.java @@ -52,7 +52,7 @@ public class JMXInterfaceBindingTest { public static final int JMX_PORT_RANGE_UPPER = 9200; public static final int JMX_PORT_RANGE_LOWER_SSL = 9201; // 9200 might be RMI Port public static final int JMX_PORT_RANGE_UPPER_SSL = 9300; - private static final int MAX_RETRY_ATTEMTS = 10; + private static final int MAX_RETRY_ATTEMPTS = 10; public static final String READY_MSG = "MainThread: Ready for connections"; public static final String TEST_CLASS = JMXAgentInterfaceBinding.class.getSimpleName(); public static final String KEYSTORE_LOC = System.getProperty("test.src", ".") + @@ -159,7 +159,7 @@ public class JMXInterfaceBindingTest { System.err.println("Retrying the test for " + name); } needRetry = runTest(); - } while (needRetry && (attempts++ < MAX_RETRY_ATTEMTS)); + } while (needRetry && (attempts++ < MAX_RETRY_ATTEMPTS)); if (testFailed) { int exitValue = output.getExitValue(); diff --git a/test/jdk/sun/net/www/ParseUtil_6380332.java b/test/jdk/sun/net/www/ParseUtil_6380332.java index a517742f2c4..bd0331d52bd 100644 --- a/test/jdk/sun/net/www/ParseUtil_6380332.java +++ b/test/jdk/sun/net/www/ParseUtil_6380332.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,12 +22,13 @@ */ /* @test - * @summary SunTea applet fails to load under Mustang + * @summary Ensure ParseUtil.toURI does not fail when port number is -1 * @bug 6380332 * @modules java.base/sun.net.www */ import sun.net.www.ParseUtil; + import java.net.URI; import java.net.URL; diff --git a/test/jdk/sun/net/www/protocol/http/B6296310.java b/test/jdk/sun/net/www/protocol/http/B6296310.java index dbb3ead18c5..867b4edaf32 100644 --- a/test/jdk/sun/net/www/protocol/http/B6296310.java +++ b/test/jdk/sun/net/www/protocol/http/B6296310.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,7 +27,8 @@ * @library /test/lib * @run main/othervm B6296310 * @run main/othervm -Djava.net.preferIPv6Addresses=true B6296310 - * @summary REGRESSION: AppletClassLoader.getResourceAsStream() behaviour is wrong in some cases + * @summary Prevent NPE in HttpURLConnection.getInputStream0() when + * content length is 0 */ import java.io.IOException; diff --git a/test/jdk/sun/net/www/protocol/http/ResponseCacheStream.java b/test/jdk/sun/net/www/protocol/http/ResponseCacheStream.java index 841279fa76d..2fba6d8ab75 100644 --- a/test/jdk/sun/net/www/protocol/http/ResponseCacheStream.java +++ b/test/jdk/sun/net/www/protocol/http/ResponseCacheStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,7 @@ * @bug 6262486 * @library /test/lib * @run main/othervm -Dhttp.keepAlive=false ResponseCacheStream - * @summary COMPATIBILITY: jagex_com - Monkey Puzzle applet fails to load + * @summary Ensure HttpInputStream resets properly when cache is in use */ import java.io.ByteArrayOutputStream; diff --git a/test/jdk/sun/rmi/transport/tcp/disableMultiplexing/DisableMultiplexing.java b/test/jdk/sun/rmi/transport/tcp/disableMultiplexing/DisableMultiplexing.java index 4a8748ab253..253f166cae4 100644 --- a/test/jdk/sun/rmi/transport/tcp/disableMultiplexing/DisableMultiplexing.java +++ b/test/jdk/sun/rmi/transport/tcp/disableMultiplexing/DisableMultiplexing.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* @test * @bug 4183204 * @summary The RMI runtime should fail to export a remote object on a TCP - * port for an applet or application that does not have permission to listen + * port for an application that does not have permission to listen * on that port, rather than engage in the deprecated "multiplexing protocol". * @author Peter Jones * diff --git a/test/jdk/sun/security/ec/ed/TestEdOps.java b/test/jdk/sun/security/ec/ed/TestEdOps.java index 6ef1446db46..82b7f2c507f 100644 --- a/test/jdk/sun/security/ec/ed/TestEdOps.java +++ b/test/jdk/sun/security/ec/ed/TestEdOps.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,7 +40,7 @@ import java.security.spec.*; import java.util.Arrays; import java.util.HexFormat; -import sun.security.provider.SHAKE256; +import sun.security.provider.SHA3.SHAKE256; public class TestEdOps { diff --git a/test/jdk/sun/security/lib/cacerts/VerifyCACerts.java b/test/jdk/sun/security/lib/cacerts/VerifyCACerts.java index 83427f1a33a..d64c5d7c52b 100644 --- a/test/jdk/sun/security/lib/cacerts/VerifyCACerts.java +++ b/test/jdk/sun/security/lib/cacerts/VerifyCACerts.java @@ -19,17 +19,16 @@ * 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 8189131 8198240 8191844 8189949 8191031 8196141 8204923 8195774 8199779 * 8209452 8209506 8210432 8195793 8216577 8222089 8222133 8222137 8222136 * 8223499 8225392 8232019 8234245 8233223 8225068 8225069 8243321 8243320 * 8243559 8225072 8258630 8259312 8256421 8225081 8225082 8225083 8245654 * 8305975 8304760 8307134 8295894 8314960 8317373 8317374 8318759 8319187 - * 8321408 8316138 + * 8321408 8316138 8341057 * @summary Check root CA entries in cacerts file */ import java.io.ByteArrayInputStream; @@ -48,12 +47,12 @@ public class VerifyCACerts { + File.separator + "security" + File.separator + "cacerts"; // The numbers of certs now. - private static final int COUNT = 110; + private static final int COUNT = 112; // SHA-256 of cacerts, can be generated with // shasum -a 256 cacerts | sed -e 's/../&:/g' | tr '[:lower:]' '[:upper:]' | cut -c1-95 private static final String CHECKSUM - = "BD:80:65:81:68:E5:6C:51:64:ED:B9:08:53:9F:BB:2F:D9:6C:5D:D4:06:D4:16:59:39:10:8E:F8:24:81:8B:78"; + = "21:68:E7:16:5B:94:23:D2:60:5C:BB:F2:AF:C1:66:5C:EC:36:BC:20:FF:5C:54:AF:91:D1:2C:38:AE:55:D3:27"; // Hex formatter to upper case with ":" delimiter private static final HexFormat HEX = HexFormat.ofDelimiter(":").withUpperCase(); @@ -282,6 +281,10 @@ public class VerifyCACerts { "4F:A3:12:6D:8D:3A:11:D1:C4:85:5A:4F:80:7C:BA:D6:CF:91:9D:3A:5A:88:B0:3B:EA:2C:63:72:D9:3C:40:C9"); put("globalsigne46 [jdk]", "CB:B9:C4:4D:84:B8:04:3E:10:50:EA:31:A6:9F:51:49:55:D7:BF:D2:E2:C6:B4:93:01:01:9A:D6:1D:9F:50:58"); + put("ssltlsrootecc2022 [jdk]", + "C3:2F:FD:9F:46:F9:36:D1:6C:36:73:99:09:59:43:4B:9A:D6:0A:AF:BB:9E:7C:F3:36:54:F1:44:CC:1B:A1:43"); + put("ssltlsrootrsa2022 [jdk]", + "8F:AF:7D:2E:2C:B4:70:9B:B8:E0:B3:36:66:BF:75:A5:DD:45:B5:DE:48:0F:8E:A8:D4:BF:E6:BE:BC:17:F2:ED"); } }; diff --git a/test/jdk/sun/security/pkcs11/Provider/RequiredMechCheck.cfg b/test/jdk/sun/security/pkcs11/Provider/RequiredMechCheck.cfg new file mode 100644 index 00000000000..906e4a3a362 --- /dev/null +++ b/test/jdk/sun/security/pkcs11/Provider/RequiredMechCheck.cfg @@ -0,0 +1,14 @@ +name = NSS + +showInfo = true + +slot = 1 + +library = ${pkcs11test.nss.lib} + +disabledMechanisms = { + CKM_SHA224_HMAC + CKM_SHA256_HMAC +} + +nssArgs = "configdir='${pkcs11test.nss.db}' certPrefix='' keyPrefix=''" diff --git a/test/jdk/sun/security/pkcs11/Provider/RequiredMechCheck.java b/test/jdk/sun/security/pkcs11/Provider/RequiredMechCheck.java new file mode 100644 index 00000000000..11fb562a825 --- /dev/null +++ b/test/jdk/sun/security/pkcs11/Provider/RequiredMechCheck.java @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8335288 + * @library /test/lib .. + * @modules jdk.crypto.cryptoki + * @summary check that if any required mech is unavailable, then the + * mechanism will be unavailable as well. + * @run testng/othervm RequiredMechCheck + */ +import java.nio.file.Path; +import java.security.Provider; +import java.security.NoSuchAlgorithmException; +import javax.crypto.Cipher; +import javax.crypto.Mac; +import javax.crypto.SecretKeyFactory; + +import jtreg.SkippedException; +import org.testng.SkipException; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class RequiredMechCheck extends PKCS11Test { + + private static record TestData(String serviceType, String algo, + boolean disabled) {} + + private static TestData[] testValues = { + new TestData("MAC", "HmacPBESHA1", false), + new TestData("MAC", "HmacPBESHA224", true), + new TestData("MAC", "HmacPBESHA256", true), + new TestData("MAC", "HmacPBESHA384", false), + new TestData("MAC", "HmacPBESHA512", false), + new TestData("SKF", "PBEWithHmacSHA1AndAES_128", false), + new TestData("SKF", "PBEWithHmacSHA224AndAES_128", true), + new TestData("SKF", "PBEWithHmacSHA256AndAES_128", true), + new TestData("SKF", "PBEWithHmacSHA384AndAES_128", false), + new TestData("SKF", "PBEWithHmacSHA512AndAES_128", false), + new TestData("CIP", "PBEWithHmacSHA1AndAES_128", false), + new TestData("CIP", "PBEWithHmacSHA224AndAES_128", true), + new TestData("CIP", "PBEWithHmacSHA256AndAES_128", true), + new TestData("CIP", "PBEWithHmacSHA384AndAES_128", false), + new TestData("CIP", "PBEWithHmacSHA512AndAES_128", false), + }; + + @BeforeClass + public void setUp() throws Exception { + Path configPath = Path.of(BASE).resolve("RequiredMechCheck.cfg"); + System.setProperty("CUSTOM_P11_CONFIG", configPath.toString()); + } + + @Test + public void test() throws Exception { + try { + main(new RequiredMechCheck()); + } catch (SkippedException se) { + throw new SkipException("One or more tests are skipped"); + } + } + + public void main(Provider p) throws Exception { + for (TestData td : testValues) { + String desc = td.serviceType + " " + td.algo; + Object t; + try { + switch (td.serviceType) { + case "MAC": + t = Mac.getInstance(td.algo, p); + break; + case "SKF": + t = SecretKeyFactory.getInstance(td.algo, p); + break; + case "CIP": + t = Cipher.getInstance(td.algo, p); + break; + default: + throw new RuntimeException("Unsupported Test Type!"); + } + + if (td.disabled) { + throw new RuntimeException("Fail, no NSAE for " + desc); + } else { + System.out.println("Ok, getInstance() works for " + desc); + } + } catch (NoSuchAlgorithmException e) { + if (td.disabled) { + System.out.println("Ok, NSAE thrown for " + desc); + } else { + throw new RuntimeException("Unexpected Ex for " + desc, e); + } + } + } + } +} diff --git a/test/jdk/sun/security/provider/MessageDigest/SHAKEsqueeze.java b/test/jdk/sun/security/provider/MessageDigest/SHAKEsqueeze.java new file mode 100644 index 00000000000..5cdcce00e35 --- /dev/null +++ b/test/jdk/sun/security/provider/MessageDigest/SHAKEsqueeze.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8338587 + * @summary Ensure squeeze and digest always have the same output + * @library /test/lib + * @modules java.base/sun.security.provider + */ + +import jdk.test.lib.Asserts; +import jdk.test.lib.security.SeededSecureRandom; +import sun.security.provider.SHA3; + +import java.io.ByteArrayOutputStream; +import java.util.Arrays; + +public class SHAKEsqueeze { + public static void main(String[] args) throws Exception { + var r = SeededSecureRandom.one(); + var atlast = 0; + // Random test on SHAKE + for (var i = 0; i < 1_000_000; i++) { + var s = new SHA3.SHAKE256(0); + var in = new ByteArrayOutputStream(); + while (r.nextBoolean()) { + var b = r.nBytes(r.nextInt(200)); + if (b.length > 0 && r.nextBoolean()) { + // Test update(b) + s.update(b[0]); + in.write(b[0]); + } else if (r.nextBoolean()) { + // Test update(byte[]) + s.update(b); + in.write(b); + } else { + // Test update(byte[], offset, len) + var prepend = r.nextInt(100); + var append = r.nextInt(100); + var bb = new byte[prepend + b.length + append]; + r.nextBytes(bb); + System.arraycopy(b, 0, bb, prepend, b.length); + s.update(bb, prepend, b.length); + in.write(b); + } + } + + // Squeeze for multiple times + var out = new ByteArrayOutputStream(); + do { + var n = r.nextInt(200); + out.write(s.squeeze(n)); + } while (out.size() == 0 || r.nextBoolean()); + var b1 = out.toByteArray(); + + // Digest for one time + var s2 = new SHA3.SHAKE256(b1.length); + s2.update(in.toByteArray()); + var b2 = s2.digest(); + + atlast = Arrays.hashCode(b2) * 17 + atlast; + Asserts.assertEqualsByteArray(b1, b2); + } + // Just to provide a visual clue to show that the same + // SeededSecureRandom seed results in same final result + // so that the test can be exactly reproduced. + System.out.println("Final hash: " + atlast); + } +} diff --git a/test/jdk/sun/security/provider/NamedEdDSA.java b/test/jdk/sun/security/provider/NamedEdDSA.java new file mode 100644 index 00000000000..4d0e3e9228a --- /dev/null +++ b/test/jdk/sun/security/provider/NamedEdDSA.java @@ -0,0 +1,239 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8340327 + * @modules java.base/sun.security.ec.ed + * java.base/sun.security.ec.point + * java.base/sun.security.jca + * java.base/sun.security.provider + * @library /test/lib + */ + +import jdk.test.lib.Asserts; +import jdk.test.lib.Utils; +import sun.security.ec.ed.EdDSAOperations; +import sun.security.ec.ed.EdDSAParameters; +import sun.security.ec.point.AffinePoint; +import sun.security.jca.JCAUtil; +import sun.security.provider.NamedKeyFactory; +import sun.security.provider.NamedKeyPairGenerator; +import sun.security.provider.NamedSignature; + +import java.security.*; +import java.security.spec.EdDSAParameterSpec; +import java.security.spec.NamedParameterSpec; +import java.util.Arrays; +import java.util.List; + +public class NamedEdDSA { + + public static class ProviderImpl extends Provider { + public ProviderImpl() { + super("Named", "0", ""); + put("KeyPairGenerator.EdDSA", EdDSAKeyPairGenerator.class.getName()); + put("KeyPairGenerator.Ed25519", EdDSAKeyPairGenerator.Ed25519.class.getName()); + put("KeyPairGenerator.Ed448", EdDSAKeyPairGenerator.Ed448.class.getName()); + put("KeyFactory.EdDSA", EdDSAKeyFactory.class.getName()); + put("KeyFactory.Ed25519", EdDSAKeyFactory.Ed25519.class.getName()); + put("KeyFactory.Ed448", EdDSAKeyFactory.Ed448.class.getName()); + put("Signature.EdDSA", EdDSASignature.class.getName()); + put("Signature.Ed25519", EdDSASignature.Ed25519.class.getName()); + put("Signature.Ed448", EdDSASignature.Ed448.class.getName()); + } + } + + public static class EdDSASignature extends NamedSignature { + public EdDSASignature() { + super("EdDSA", "Ed25519", "Ed448"); + } + + protected EdDSASignature(String pname) { + super("EdDSA", pname); + } + + public static class Ed25519 extends EdDSASignature { + public Ed25519() { + super("Ed25519"); + } + } + + public static class Ed448 extends EdDSASignature { + public Ed448() { + super("Ed448"); + } + } + + @Override + public byte[] implSign(String name, byte[] sk, Object sk2, byte[] msg, SecureRandom sr) throws SignatureException { + return getOps(name).sign(plain, sk, msg); + } + + @Override + public boolean implVerify(String name, byte[] pk, Object pk2, byte[] msg, byte[] sig) throws SignatureException { + return getOps(name).verify(plain, (AffinePoint) pk2, pk, msg, sig); + } + + @Override + public Object implCheckPublicKey(String name, byte[] pk) throws InvalidKeyException { + return getOps(name).decodeAffinePoint(InvalidKeyException::new, pk); + } + } + + public static class EdDSAKeyFactory extends NamedKeyFactory { + public EdDSAKeyFactory() { + super("EdDSA", "Ed25519", "Ed448"); + } + + protected EdDSAKeyFactory(String pname) { + super("EdDSA", pname); + } + + public static class Ed25519 extends EdDSAKeyFactory { + public Ed25519() { + super("Ed25519"); + } + } + + public static class Ed448 extends EdDSAKeyFactory { + public Ed448() { + super("Ed448"); + } + } + } + + public static class EdDSAKeyPairGenerator extends NamedKeyPairGenerator { + public EdDSAKeyPairGenerator() { + super("EdDSA", "Ed25519", "Ed448"); + } + + protected EdDSAKeyPairGenerator(String pname) { + super("EdDSA", pname); + } + + public static class Ed25519 extends EdDSAKeyPairGenerator { + public Ed25519() { + super("Ed25519"); + } + } + + public static class Ed448 extends EdDSAKeyPairGenerator { + public Ed448() { + super("Ed448"); + } + } + + @Override + public byte[][] implGenerateKeyPair(String pname, SecureRandom sr) { + sr = sr == null ? JCAUtil.getDefSecureRandom() : sr; + var op = getOps(pname); + var sk = op.generatePrivate(sr); + var point = op.computePublic(sk); + byte[] encodedPoint = point.getY().toByteArray(); + reverse(encodedPoint); + // array may be too large or too small, depending on the value + encodedPoint = Arrays.copyOf(encodedPoint, op.getParameters().getKeyLength()); + // set the high-order bit of the encoded point + byte msb = (byte) (point.isXOdd() ? 0x80 : 0); + encodedPoint[encodedPoint.length - 1] |= msb; + return new byte[][] { encodedPoint, sk }; + } + + private static void swap(byte[] arr, int i, int j) { + byte tmp = arr[i]; + arr[i] = arr[j]; + arr[j] = tmp; + } + + private static void reverse(byte [] arr) { + int i = 0; + int j = arr.length - 1; + + while (i < j) { + swap(arr, i, j); + i++; + j--; + } + } + } + + private static EdDSAOperations getOps(String pname) { + var op = switch (pname) { + case "Ed25519" -> e2; + case "Ed448" -> e4; + default -> throw new AssertionError("unknown pname " + pname); + }; + return op; + } + + static final EdDSAParameterSpec plain = new EdDSAParameterSpec(false); + static final EdDSAOperations e2, e4; + static { + try { + e2 = new EdDSAOperations(EdDSAParameters.getBySize(AssertionError::new, 255)); + e4 = new EdDSAOperations(EdDSAParameters.getBySize(AssertionError::new, 448)); + } catch (Exception e) { + throw new AssertionError(e); + } + } + + public static void main(String[] args) throws Exception { + var ps = List.of(new ProviderImpl(), Security.getProvider("SunEC")); + for (var p1 : ps) { + for (var p2 : ps) { + for (var p3 : ps) { + test(p1, p2, p3); + } + } + } + } + + static void test(Provider p1, Provider p2, Provider p3) throws Exception { + System.out.println(p1.getName() + " " + p2.getName() + " " + p3.getName()); + var g = KeyPairGenerator.getInstance("EdDSA", p1); + g.initialize(NamedParameterSpec.ED448); + var kp = g.generateKeyPair(); + var s1 = Signature.getInstance("EdDSA", p2); + var s2 = Signature.getInstance("EdDSA", p3); + var f1 = KeyFactory.getInstance("EdDSA", p2); + var f2 = KeyFactory.getInstance("EdDSA", p3); + var sk = (PrivateKey) f1.translateKey(kp.getPrivate()); + var pk = (PublicKey) f2.translateKey(kp.getPublic()); + // sign and verify twice to make sure the key is intact + s1.initSign(sk); + var sig1 = s1.sign(); + s1.initSign(sk); + var sig2 = s1.sign(); + // EdDSA signing is deterministic + Asserts.assertEqualsByteArray(sig1, sig2); + s2.initVerify(pk); + Asserts.assertTrue(s2.verify(sig1)); + s2.initVerify(pk); + Asserts.assertTrue(s2.verify(sig2)); + // No parameters defined + s1.setParameter(null); + Utils.runAndCheckException(() -> s1.setParameter(NamedParameterSpec.ED448), + InvalidAlgorithmParameterException.class); + } +} diff --git a/test/jdk/sun/security/provider/NamedKeyFactoryTest.java b/test/jdk/sun/security/provider/NamedKeyFactoryTest.java new file mode 100644 index 00000000000..1ca179bc046 --- /dev/null +++ b/test/jdk/sun/security/provider/NamedKeyFactoryTest.java @@ -0,0 +1,261 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8340327 + * @modules java.base/sun.security.x509 + * java.base/sun.security.pkcs + * java.base/sun.security.provider + * java.base/sun.security.util + * @library /test/lib + */ +import jdk.test.lib.Asserts; +import jdk.test.lib.Utils; +import jdk.test.lib.security.SeededSecureRandom; +import sun.security.pkcs.NamedPKCS8Key; +import sun.security.provider.NamedKeyFactory; +import sun.security.provider.NamedKeyPairGenerator; +import sun.security.util.RawKeySpec; +import sun.security.x509.NamedX509Key; + +import java.security.*; +import java.security.spec.*; + +public class NamedKeyFactoryTest { + + private static final SeededSecureRandom RAND = SeededSecureRandom.one(); + + public static void main(String[] args) throws Exception { + Security.addProvider(new ProviderImpl()); + + var g = KeyPairGenerator.getInstance("sHA"); + var g2 = KeyPairGenerator.getInstance("ShA-256"); + var g5 = KeyPairGenerator.getInstance("SHa-512"); + var kf = KeyFactory.getInstance("ShA"); + var kf2 = KeyFactory.getInstance("Sha-256"); + var kf5 = KeyFactory.getInstance("Sha-512"); + + checkKeyPair(g.generateKeyPair(), "SHA", "SHA-256"); + checkKeyPair(g2.generateKeyPair(), "SHA", "SHA-256"); + checkKeyPair(g5.generateKeyPair(), "SHA", "SHA-512"); + + checkKeyPair(g.generateKeyPair(), "SHA", "SHA-256"); + checkKeyPair(g2.generateKeyPair(), "SHA", "SHA-256"); + checkKeyPair(g5.generateKeyPair(), "SHA", "SHA-512"); + + Utils.runAndCheckException(() -> g.initialize(NamedParameterSpec.ED448), + InvalidAlgorithmParameterException.class); // wrong pname + Utils.runAndCheckException(() -> g.initialize(new NamedParameterSpec("SHA-384")), + InvalidAlgorithmParameterException.class); // wrong pname + + Utils.runAndCheckException(() -> g5.initialize(new NamedParameterSpec("SHA-256")), + InvalidAlgorithmParameterException.class); // diff pname + g5.initialize(new NamedParameterSpec("SHA-512")); + + g.initialize(new NamedParameterSpec("sHA-512")); + checkKeyPair(g.generateKeyPair(), "SHA", "SHA-512"); + g.initialize(new NamedParameterSpec("ShA-256")); + checkKeyPair(g.generateKeyPair(), "SHA", "SHA-256"); + + var pk = new NamedX509Key("sHa", "ShA-256", RAND.nBytes(2)); + var sk = new NamedPKCS8Key("sHa", "SHa-256", RAND.nBytes(2)); + checkKey(pk, "sHa", "ShA-256"); + checkKey(sk, "sHa", "SHa-256"); + + Asserts.assertEquals("X.509", pk.getFormat()); + Asserts.assertEquals("PKCS#8", sk.getFormat()); + + var pkSpec = kf.getKeySpec(pk, X509EncodedKeySpec.class); + var skSpec = kf.getKeySpec(sk, PKCS8EncodedKeySpec.class); + + kf2.getKeySpec(pk, X509EncodedKeySpec.class); + kf2.getKeySpec(sk, PKCS8EncodedKeySpec.class); + Utils.runAndCheckException(() -> kf5.getKeySpec(pk, X509EncodedKeySpec.class), + InvalidKeySpecException.class); // wrong KF + Utils.runAndCheckException(() -> kf5.getKeySpec(sk, PKCS8EncodedKeySpec.class), + InvalidKeySpecException.class); + Utils.runAndCheckException(() -> kf.getKeySpec(pk, PKCS8EncodedKeySpec.class), + InvalidKeySpecException.class); // wrong KeySpec + Utils.runAndCheckException(() -> kf.getKeySpec(sk, X509EncodedKeySpec.class), + InvalidKeySpecException.class); + + checkKey(kf.generatePublic(pkSpec), "SHA", "SHA-256"); + Utils.runAndCheckException(() -> kf.generatePrivate(pkSpec), + InvalidKeySpecException.class); + + checkKey(kf.generatePrivate(skSpec), "SHA", "SHA-256"); + Utils.runAndCheckException(() -> kf.generatePublic(skSpec), + InvalidKeySpecException.class); + + checkKey(kf2.generatePrivate(skSpec), "SHA", "SHA-256"); + checkKey(kf2.generatePublic(pkSpec), "SHA", "SHA-256"); + + Utils.runAndCheckException(() -> kf5.generatePublic(pkSpec), + InvalidKeySpecException.class); // wrong KF + Utils.runAndCheckException(() -> kf5.generatePublic(skSpec), + InvalidKeySpecException.class); + + // The private RawKeySpec and unnamed RAW EncodedKeySpec + var prk = kf.getKeySpec(pk, RawKeySpec.class); + Asserts.assertEqualsByteArray(prk.getKeyArr(), pk.getRawBytes()); + var prk2 = kf.getKeySpec(pk, EncodedKeySpec.class); + Asserts.assertEquals("RAW", prk2.getFormat()); + Asserts.assertEqualsByteArray(prk.getKeyArr(), prk2.getEncoded()); + + Asserts.assertEqualsByteArray(kf2.generatePublic(prk).getEncoded(), pk.getEncoded()); + Utils.runAndCheckException(() -> kf.generatePublic(prk), InvalidKeySpecException.class); // no pname + Asserts.assertEqualsByteArray(kf2.generatePublic(prk2).getEncoded(), pk.getEncoded()); + Utils.runAndCheckException(() -> kf.generatePublic(prk2), InvalidKeySpecException.class); // no pname + + var srk = kf.getKeySpec(sk, RawKeySpec.class); + Asserts.assertEqualsByteArray(srk.getKeyArr(), sk.getRawBytes()); + var srk2 = kf.getKeySpec(sk, EncodedKeySpec.class); + Asserts.assertEquals("RAW", srk2.getFormat()); + Asserts.assertEqualsByteArray(srk2.getEncoded(), sk.getRawBytes()); + + Asserts.assertEqualsByteArray(kf2.generatePrivate(srk).getEncoded(), sk.getEncoded()); + Utils.runAndCheckException(() -> kf.generatePrivate(srk), InvalidKeySpecException.class); // no pname + Asserts.assertEqualsByteArray(kf2.generatePrivate(srk2).getEncoded(), sk.getEncoded()); + Utils.runAndCheckException(() -> kf.generatePrivate(srk2), InvalidKeySpecException.class); // no pname + + var pk1 = new PublicKey() { + public String getAlgorithm() { return "SHA"; } + public String getFormat() { return "RAW"; } + public byte[] getEncoded() { return RAND.nBytes(2); } + }; + var pk2 = new PublicKey() { + public String getAlgorithm() { return "sHA-256"; } + public String getFormat() { return "RAW"; } + public byte[] getEncoded() { return RAND.nBytes(2); } + }; + var pk3 = new PublicKey() { + public String getAlgorithm() { return "SHA"; } + public String getFormat() { return "RAW"; } + public byte[] getEncoded() { return RAND.nBytes(2); } + public AlgorithmParameterSpec getParams() { return new NamedParameterSpec("sHA-256"); } + }; + + checkKey(kf2.translateKey(pk1), "SHA", "SHA-256"); + checkKey(kf.translateKey(pk2), "SHA", "SHA-256"); + checkKey(kf.translateKey(pk3), "SHA", "SHA-256"); + + Utils.runAndCheckException(() -> kf.translateKey(pk1), InvalidKeyException.class); + Utils.runAndCheckException(() -> kf5.translateKey(pk2), InvalidKeyException.class); + Utils.runAndCheckException(() -> kf5.translateKey(pk3), InvalidKeyException.class); + + var sk1 = new PrivateKey() { + public String getAlgorithm() { return "SHA"; } + public String getFormat() { return "RAW"; } + public byte[] getEncoded() { return RAND.nBytes(2); } + }; + var sk2 = new PrivateKey() { + public String getAlgorithm() { return "sHA-256"; } + public String getFormat() { return "RAW"; } + public byte[] getEncoded() { return RAND.nBytes(2); } + }; + var sk3 = new PrivateKey() { + public String getAlgorithm() { return "SHA"; } + public String getFormat() { return "RAW"; } + public byte[] getEncoded() { return RAND.nBytes(2); } + public AlgorithmParameterSpec getParams() { return new NamedParameterSpec("sHA-256"); } + }; + + checkKey(kf2.translateKey(sk1), "SHA", "SHA-256"); + checkKey(kf.translateKey(sk2), "SHA", "SHA-256"); + checkKey(kf.translateKey(sk3), "SHA", "SHA-256"); + + Utils.runAndCheckException(() -> kf.translateKey(sk1), InvalidKeyException.class); + Utils.runAndCheckException(() -> kf5.translateKey(sk2), InvalidKeyException.class); + Utils.runAndCheckException(() -> kf5.translateKey(sk3), InvalidKeyException.class); + } + + static void checkKeyPair(KeyPair kp, String algName, String toString) { + checkKey(kp.getPrivate(), algName, toString); + checkKey(kp.getPublic(), algName, toString); + } + + static void checkKey(Key k, String algName, String pname) { + Asserts.assertEquals(algName, k.getAlgorithm()); + Asserts.assertTrue(k.toString().contains(pname)); + if (k instanceof AsymmetricKey ak && ak.getParams() instanceof NamedParameterSpec nps) { + Asserts.assertEquals(pname, nps.getName()); + } + } + + // Provider + + public static class ProviderImpl extends Provider { + public ProviderImpl() { + super("P", "1", "..."); + put("KeyFactory.SHA", KF.class.getName()); + put("KeyFactory.SHA-256", KF1.class.getName()); + put("KeyFactory.SHA-512", KF2.class.getName()); + put("KeyPairGenerator.SHA", KPG.class.getName()); + put("KeyPairGenerator.SHA-256", KPG1.class.getName()); + put("KeyPairGenerator.SHA-512", KPG2.class.getName()); + } + } + public static class KF extends NamedKeyFactory { + public KF() { + super("SHA", "SHA-256", "SHA-512"); + } + } + public static class KF1 extends NamedKeyFactory { + public KF1() { + super("SHA", "SHA-256"); + } + } + public static class KF2 extends NamedKeyFactory { + public KF2() { + super("SHA", "SHA-512"); + } + } + public static class KPG extends NamedKeyPairGenerator { + public KPG() { + super("SHA", "SHA-256", "SHA-512"); + } + + public KPG(String pname) { + super("SHA", pname); + } + + @Override + public byte[][] implGenerateKeyPair(String name, SecureRandom sr) { + var out = new byte[2][]; + out[0] = RAND.nBytes(name.endsWith("256") ? 2 : 4); + out[1] = RAND.nBytes(name.endsWith("256") ? 2 : 4); + return out; + } + } + public static class KPG1 extends KPG { + public KPG1() { + super("SHA-256"); + } + } + public static class KPG2 extends KPG { + public KPG2() { + super("SHA-512"); + } + } +} diff --git a/test/jdk/sun/security/provider/SecureRandom/StrongSecureRandom.java b/test/jdk/sun/security/provider/SecureRandom/StrongSecureRandom.java index bdd3ab0a4b9..1c6d515e4f0 100644 --- a/test/jdk/sun/security/provider/SecureRandom/StrongSecureRandom.java +++ b/test/jdk/sun/security/provider/SecureRandom/StrongSecureRandom.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,13 +23,16 @@ /* * @test - * @bug 6425477 8141039 + * @bug 6425477 8141039 8324648 + * @library /test/lib * @summary Better support for generation of high entropy random numbers * @run main StrongSecureRandom */ import java.security.*; import java.util.*; +import static jdk.test.lib.Asserts.assertTrue; + /** * This test assumes that the standard Sun providers are installed. */ @@ -89,6 +92,27 @@ public class StrongSecureRandom { ba = sr.generateSeed(1); sr.nextBytes(ba); sr.setSeed(ba); + + testParamsUnsupported("NativePRNG"); + testParamsUnsupported("NativePRNGNonBlocking"); + testParamsUnsupported("NativePRNGBlocking"); + } + + private static void testParamsUnsupported(String alg) throws NoSuchAlgorithmException { + System.out.println("Testing that " + alg + " does not support params"); + + try { + SecureRandom.getInstance(alg, new SecureRandomParameters() {}); + throw new RuntimeException("Params should not be supported"); + } catch (NoSuchAlgorithmException nsae) { + Throwable cause = nsae.getCause(); + if (cause instanceof IllegalArgumentException) { + assertTrue(cause.getMessage().contains("Unsupported params"), + "Unexpected error message: " + cause.getMessage()); + } else { + throw nsae; + } + } } private static void testStrongInstance(boolean expected) throws Exception { diff --git a/test/jdk/sun/security/ssl/Stapling/StatusResponseManager.java b/test/jdk/sun/security/ssl/Stapling/StatusResponseManager.java index 58ebb5b876a..5555363374c 100644 --- a/test/jdk/sun/security/ssl/Stapling/StatusResponseManager.java +++ b/test/jdk/sun/security/ssl/Stapling/StatusResponseManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 8046321 + * @bug 8046321 8339403 * @library ../../../../java/security/testlibrary * @build CertificateBuilder SimpleOCSPServer * @run main/othervm -Djavax.net.debug=ssl:respmgr java.base/sun.security.ssl.StatusResponseManagerTests diff --git a/test/jdk/sun/security/ssl/Stapling/java.base/sun/security/ssl/StatusResponseManagerTests.java b/test/jdk/sun/security/ssl/Stapling/java.base/sun/security/ssl/StatusResponseManagerTests.java index f6b0d1f10e2..b210cfb26ea 100644 --- a/test/jdk/sun/security/ssl/Stapling/java.base/sun/security/ssl/StatusResponseManagerTests.java +++ b/test/jdk/sun/security/ssl/Stapling/java.base/sun/security/ssl/StatusResponseManagerTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -82,6 +82,7 @@ public class StatusResponseManagerTests { put("Clear StatusResponseManager cache", testClearSRM); put("Basic OCSP_MULTI fetch test", testOcspMultiFetch); put("Test Cache Expiration", testCacheExpiry); + put("Test Interrupt while fetching", forceInterruptMainThread); }}; // Create the CAs and OCSP responders @@ -262,6 +263,38 @@ public class StatusResponseManagerTests { } }; + public static final TestCase forceInterruptMainThread = new TestCase() { + @Override + public Map.Entry runTest() { + StatusResponseManager srm = new StatusResponseManager(); + Boolean pass = Boolean.FALSE; + String message = null; + CertStatusRequest oReq = OCSPStatusRequest.EMPTY_OCSP; + + try { + // Force the interrupt flag to be set on the thread that + // performs the invokeAll in the SRM. + Thread.currentThread().interrupt(); + + // Get OCSP responses for non-root certs in the chain + Map responseMap = srm.get( + CertStatusRequestType.OCSP, oReq, chain, 5000, + TimeUnit.MILLISECONDS); + if (Thread.currentThread().isInterrupted()) { + pass = Boolean.TRUE; + message = "Thread is in expected interrupted state."; + } else { + message = "Missing expectedInterruptedException."; + } + message += " Number of SRM entries: " + responseMap.size(); + } catch (Exception exc) { + message = "Unexpected exception: " + exc; + } + + return new AbstractMap.SimpleEntry<>(pass, message); + } + }; + /** * Creates the PKI components necessary for this test, including * Root CA, Intermediate CA and SSL server certificates, the keystores diff --git a/test/jdk/sun/security/ssl/X509TrustManagerImpl/Symantec/Distrust.java b/test/jdk/sun/security/ssl/X509TrustManagerImpl/Symantec/Distrust.java deleted file mode 100644 index ba008c68cdc..00000000000 --- a/test/jdk/sun/security/ssl/X509TrustManagerImpl/Symantec/Distrust.java +++ /dev/null @@ -1,292 +0,0 @@ -/* - * Copyright (c) 2018, 2022, 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 java.io.*; -import java.math.BigInteger; -import java.security.*; -import java.security.cert.*; -import java.time.*; -import java.util.*; -import javax.net.ssl.*; -import sun.security.validator.Validator; -import sun.security.validator.ValidatorException; - -import jdk.test.lib.security.SecurityUtils; - -/** - * @test - * @bug 8207258 8216280 - * @summary Check that TLS Server certificates chaining back to distrusted - * Symantec roots are invalid - * @library /test/lib - * @modules java.base/sun.security.validator - * @run main/othervm Distrust after policyOn invalid - * @run main/othervm Distrust after policyOff valid - * @run main/othervm Distrust before policyOn valid - * @run main/othervm Distrust before policyOff valid - */ - -public class Distrust { - - private static final String TEST_SRC = System.getProperty("test.src", "."); - private static CertificateFactory cf; - - // Each of the roots have a test certificate chain stored in a file - // named "-chain.pem". - private static String[] rootsToTest = new String[] { - "geotrustprimarycag2", "geotrustprimarycag3", - "geotrustuniversalca", "thawteprimaryrootca", "thawteprimaryrootcag2", - "thawteprimaryrootcag3", "verisignclass3g3ca", "verisignclass3g4ca", - "verisignclass3g5ca", "verisignuniversalrootca" }; - - // Each of the subCAs with a delayed distrust date have a test certificate - // chain stored in a file named "-chain.pem". - private static String[] subCAsToTest = new String[]{"appleistca8g1"}; - - // A date that is after the restrictions take affect - private static final Date APRIL_17_2019 = - Date.from(LocalDate.of(2019, 4, 17) - .atStartOfDay(ZoneOffset.UTC) - .toInstant()); - - // A date that is a second before the restrictions take affect - private static final Date BEFORE_APRIL_17_2019 = - Date.from(LocalDate.of(2019, 4, 17) - .atStartOfDay(ZoneOffset.UTC) - .minusSeconds(1) - .toInstant()); - - // A date that is after the subCA restrictions take affect - private static final Date JANUARY_1_2020 = - Date.from(LocalDate.of(2020, 1, 1) - .atStartOfDay(ZoneOffset.UTC) - .toInstant()); - - // A date that is a second before the subCA restrictions take affect - private static final Date BEFORE_JANUARY_1_2020 = - Date.from(LocalDate.of(2020, 1, 1) - .atStartOfDay(ZoneOffset.UTC) - .minusSeconds(1) - .toInstant()); - - public static void main(String[] args) throws Exception { - - cf = CertificateFactory.getInstance("X.509"); - - boolean before = args[0].equals("before"); - boolean policyOn = args[1].equals("policyOn"); - boolean isValid = args[2].equals("valid"); - - if (!policyOn) { - // disable policy (default is on) - Security.setProperty("jdk.security.caDistrustPolicies", ""); - } - - Date notBefore = before ? BEFORE_APRIL_17_2019 : APRIL_17_2019; - - X509TrustManager pkixTM = getTMF("PKIX", null); - X509TrustManager sunX509TM = getTMF("SunX509", null); - for (String test : rootsToTest) { - System.err.println("Testing " + test); - X509Certificate[] chain = loadCertificateChain(test); - - testTM(sunX509TM, chain, notBefore, isValid); - testTM(pkixTM, chain, notBefore, isValid); - } - - // test chain if params are passed to TrustManager - System.err.println("Testing verisignuniversalrootca with params"); - testTM(getTMF("PKIX", getParams()), - loadCertificateChain("verisignuniversalrootca"), - notBefore, isValid); - - // test code-signing chain (should be valid as restrictions don't apply) - System.err.println("Testing verisignclass3g5ca code-signing chain"); - Validator v = Validator.getInstance(Validator.TYPE_PKIX, - Validator.VAR_CODE_SIGNING, - getParams()); - // set validation date so this will still pass when cert expires - v.setValidationDate(new Date(1544197375493l)); - v.validate(loadCertificateChain("verisignclass3g5ca-codesigning")); - - // test chains issued through subCAs - notBefore = before ? BEFORE_JANUARY_1_2020 : JANUARY_1_2020; - for (String test : subCAsToTest) { - System.err.println("Testing " + test); - X509Certificate[] chain = loadCertificateChain(test); - - testTM(sunX509TM, chain, notBefore, isValid); - testTM(pkixTM, chain, notBefore, isValid); - } - } - - private static X509TrustManager getTMF(String type, - PKIXBuilderParameters params) throws Exception { - TrustManagerFactory tmf = TrustManagerFactory.getInstance(type); - if (params == null) { - tmf.init((KeyStore)null); - } else { - tmf.init(new CertPathTrustManagerParameters(params)); - } - TrustManager[] tms = tmf.getTrustManagers(); - for (TrustManager tm : tms) { - X509TrustManager xtm = (X509TrustManager)tm; - return xtm; - } - throw new Exception("No TrustManager for " + type); - } - - private static PKIXBuilderParameters getParams() throws Exception { - PKIXBuilderParameters pbp = - new PKIXBuilderParameters(SecurityUtils.getCacertsKeyStore(), - new X509CertSelector()); - pbp.setRevocationEnabled(false); - return pbp; - } - - private static void testTM(X509TrustManager xtm, X509Certificate[] chain, - Date notBefore, boolean valid) throws Exception { - // Check if TLS Server certificate (the first element of the chain) - // is issued after the specified notBefore date (should be rejected - // unless distrust property is false). To do this, we need to - // fake the notBefore date since none of the test certs are issued - // after then. - chain[0] = new DistrustedTLSServerCert(chain[0], notBefore); - - try { - xtm.checkServerTrusted(chain, "ECDHE_RSA"); - if (!valid) { - throw new Exception("chain should be invalid"); - } - } catch (CertificateException ce) { - // expired TLS certificates should not be treated as failure - if (expired(ce)) { - System.err.println("Test is N/A, chain is expired"); - return; - } - if (valid) { - throw new Exception("Unexpected exception, chain " + - "should be valid", ce); - } - if (ce instanceof ValidatorException) { - ValidatorException ve = (ValidatorException)ce; - if (ve.getErrorType() != ValidatorException.T_UNTRUSTED_CERT) { - ce.printStackTrace(System.err); - throw new Exception("Unexpected exception: " + ce); - } - } else { - throw new Exception("Unexpected exception: " + ce); - } - } - } - - // check if a cause of exception is an expired cert - private static boolean expired(CertificateException ce) { - if (ce instanceof CertificateExpiredException) { - return true; - } - Throwable t = ce.getCause(); - while (t != null) { - if (t instanceof CertificateExpiredException) { - return true; - } - t = t.getCause(); - } - return false; - } - - private static X509Certificate[] loadCertificateChain(String name) - throws Exception { - try (InputStream in = new FileInputStream(TEST_SRC + File.separator + - name + "-chain.pem")) { - Collection certs = - (Collection)cf.generateCertificates(in); - return certs.toArray(new X509Certificate[0]); - } - } - - private static class DistrustedTLSServerCert extends X509Certificate { - private final X509Certificate cert; - private final Date notBefore; - DistrustedTLSServerCert(X509Certificate cert, Date notBefore) { - this.cert = cert; - this.notBefore = notBefore; - } - public Set getCriticalExtensionOIDs() { - return cert.getCriticalExtensionOIDs(); - } - public byte[] getExtensionValue(String oid) { - return cert.getExtensionValue(oid); - } - public Set getNonCriticalExtensionOIDs() { - return cert.getNonCriticalExtensionOIDs(); - } - public boolean hasUnsupportedCriticalExtension() { - return cert.hasUnsupportedCriticalExtension(); - } - public void checkValidity() throws CertificateExpiredException, - CertificateNotYetValidException { - // always pass - } - public void checkValidity(Date date) throws CertificateExpiredException, - CertificateNotYetValidException { - // always pass - } - public int getVersion() { return cert.getVersion(); } - public BigInteger getSerialNumber() { return cert.getSerialNumber(); } - public Principal getIssuerDN() { return cert.getIssuerDN(); } - public Principal getSubjectDN() { return cert.getSubjectDN(); } - public Date getNotBefore() { return notBefore; } - public Date getNotAfter() { return cert.getNotAfter(); } - public byte[] getTBSCertificate() throws CertificateEncodingException { - return cert.getTBSCertificate(); - } - public byte[] getSignature() { return cert.getSignature(); } - public String getSigAlgName() { return cert.getSigAlgName(); } - public String getSigAlgOID() { return cert.getSigAlgOID(); } - public byte[] getSigAlgParams() { return cert.getSigAlgParams(); } - public boolean[] getIssuerUniqueID() { - return cert.getIssuerUniqueID(); - } - public boolean[] getSubjectUniqueID() { - return cert.getSubjectUniqueID(); - } - public boolean[] getKeyUsage() { return cert.getKeyUsage(); } - public int getBasicConstraints() { return cert.getBasicConstraints(); } - public byte[] getEncoded() throws CertificateEncodingException { - return cert.getEncoded(); - } - public void verify(PublicKey key) throws CertificateException, - InvalidKeyException, NoSuchAlgorithmException, - NoSuchProviderException, SignatureException { - cert.verify(key); - } - public void verify(PublicKey key, String sigProvider) throws - CertificateException, InvalidKeyException, NoSuchAlgorithmException, - NoSuchProviderException, SignatureException { - cert.verify(key, sigProvider); - } - public PublicKey getPublicKey() { return cert.getPublicKey(); } - public String toString() { return cert.toString(); } - } -} diff --git a/test/jdk/sun/security/ssl/X509TrustManagerImpl/Entrust/Distrust.java b/test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/Distrust.java similarity index 54% rename from test/jdk/sun/security/ssl/X509TrustManagerImpl/Entrust/Distrust.java rename to test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/Distrust.java index a9a47bf834c..18178f65ec1 100644 --- a/test/jdk/sun/security/ssl/X509TrustManagerImpl/Entrust/Distrust.java +++ b/test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/Distrust.java @@ -25,7 +25,7 @@ import java.io.*; import java.math.BigInteger; import java.security.*; import java.security.cert.*; -import java.time.*; +import java.time.ZonedDateTime; import java.util.*; import javax.net.ssl.*; import sun.security.validator.Validator; @@ -34,95 +34,80 @@ import sun.security.validator.ValidatorException; import jdk.test.lib.security.SecurityUtils; /** - * @test - * @bug 8337664 - * @summary Check that TLS Server certificates chaining back to distrusted - * Entrust roots are invalid - * @library /test/lib - * @modules java.base/sun.security.validator - * @run main/othervm Distrust after policyOn invalid - * @run main/othervm Distrust after policyOff valid - * @run main/othervm Distrust before policyOn valid - * @run main/othervm Distrust before policyOff valid + * Helper class that provides methods to facilitate testing of distrusted roots. */ - -public class Distrust { +public final class Distrust { private static final String TEST_SRC = System.getProperty("test.src", "."); private static CertificateFactory cf; - // Each of the roots have a test certificate chain stored in a file - // named "-chain.pem". - private static String[] rootsToTest = new String[] { - "entrustevca", "entrustrootcaec1", "entrustrootcag2", "entrustrootcag4", - "entrust2048ca", "affirmtrustcommercialca", "affirmtrustnetworkingca", - "affirmtrustpremiumca", "affirmtrustpremiumeccca" }; + private final boolean before; + private final boolean policyOn; + private final boolean isValid; - // A date that is after the restrictions take effect - private static final Date NOVEMBER_1_2024 = - Date.from(LocalDate.of(2024, 11, 1) - .atStartOfDay(ZoneOffset.UTC) - .toInstant()); - - // A date that is a second before the restrictions take effect - private static final Date BEFORE_NOVEMBER_1_2024 = - Date.from(LocalDate.of(2024, 11, 1) - .atStartOfDay(ZoneOffset.UTC) - .minusSeconds(1) - .toInstant()); - - public static void main(String[] args) throws Exception { - - cf = CertificateFactory.getInstance("X.509"); - - boolean before = args[0].equals("before"); - boolean policyOn = args[1].equals("policyOn"); - boolean isValid = args[2].equals("valid"); + public Distrust(String[] args) { + before = args[0].equals("before"); + policyOn = args[1].equals("policyOn"); + isValid = args[2].equals("valid"); if (!policyOn) { // disable policy (default is on) Security.setProperty("jdk.security.caDistrustPolicies", ""); } + } - Date notBefore = before ? BEFORE_NOVEMBER_1_2024 : NOVEMBER_1_2024; + public Date getNotBefore(ZonedDateTime distrustDate) { + ZonedDateTime notBefore = before ? distrustDate.minusSeconds(1) : distrustDate; + return Date.from(notBefore.toInstant()); + } - X509TrustManager pkixTM = getTMF("PKIX", null); - X509TrustManager sunX509TM = getTMF("SunX509", null); - for (String test : rootsToTest) { + public void testCodeSigningChain(String certPath, String name, Date validationDate) + throws Exception { + System.err.println("Testing " + name + " code-signing chain"); + Validator v = Validator.getInstance(Validator.TYPE_PKIX, + Validator.VAR_CODE_SIGNING, + getParams()); + // set validation date so this will still pass when cert expires + v.setValidationDate(validationDate); + v.validate(loadCertificateChain(certPath, name)); + } + + public void testCertificateChain(String certPath, Date notBefore, X509TrustManager[] tms, + String... tests) throws Exception { + for (String test : tests) { System.err.println("Testing " + test); - X509Certificate[] chain = loadCertificateChain(test); + X509Certificate[] chain = loadCertificateChain(certPath, test); - testTM(sunX509TM, chain, notBefore, isValid); - testTM(pkixTM, chain, notBefore, isValid); + for (X509TrustManager tm : tms) { + testTM(tm, chain, notBefore, isValid); + } } } - private static X509TrustManager getTMF(String type, - PKIXBuilderParameters params) throws Exception { + public X509TrustManager getTMF(String type, PKIXBuilderParameters params) throws Exception { TrustManagerFactory tmf = TrustManagerFactory.getInstance(type); if (params == null) { - tmf.init((KeyStore)null); + tmf.init((KeyStore) null); } else { tmf.init(new CertPathTrustManagerParameters(params)); } TrustManager[] tms = tmf.getTrustManagers(); for (TrustManager tm : tms) { - X509TrustManager xtm = (X509TrustManager)tm; - return xtm; + return (X509TrustManager) tm; } - throw new Exception("No TrustManager for " + type); + throw new RuntimeException("No TrustManager for " + type); } - private static PKIXBuilderParameters getParams() throws Exception { + public PKIXBuilderParameters getParams() throws Exception { PKIXBuilderParameters pbp = - new PKIXBuilderParameters(SecurityUtils.getCacertsKeyStore(), - new X509CertSelector()); + new PKIXBuilderParameters(SecurityUtils.getCacertsKeyStore(), + new X509CertSelector()); pbp.setRevocationEnabled(false); return pbp; } - private static void testTM(X509TrustManager xtm, X509Certificate[] chain, - Date notBefore, boolean valid) throws Exception { + public void testTM(X509TrustManager xtm, X509Certificate[] chain, + Date notBefore, boolean valid) { // Check if TLS Server certificate (the first element of the chain) // is issued after the specified notBefore date (should be rejected // unless distrust property is false). To do this, we need to @@ -130,67 +115,54 @@ public class Distrust { // after then. chain[0] = new DistrustedTLSServerCert(chain[0], notBefore); + // Wrap the intermediate and root CA certs in NonExpiringTLSServerCert + // so it will never throw a CertificateExpiredException + for (int i = 1; i < chain.length; i++) { + chain[i] = new NonExpiringTLSServerCert(chain[i]); + } + try { xtm.checkServerTrusted(chain, "ECDHE_RSA"); if (!valid) { - throw new Exception("chain should be invalid"); + throw new RuntimeException("chain should be invalid"); } } catch (CertificateException ce) { - // expired TLS certificates should not be treated as failure - if (expired(ce)) { - System.err.println("Test is N/A, chain is expired"); - return; - } if (valid) { - throw new Exception("Unexpected exception, chain " + - "should be valid", ce); + throw new RuntimeException("Unexpected exception, chain " + + "should be valid", ce); } if (ce instanceof ValidatorException) { - ValidatorException ve = (ValidatorException)ce; + ValidatorException ve = (ValidatorException) ce; if (ve.getErrorType() != ValidatorException.T_UNTRUSTED_CERT) { ce.printStackTrace(System.err); - throw new Exception("Unexpected exception: " + ce); + throw new RuntimeException("Unexpected exception: " + ce); } } else { - throw new Exception("Unexpected exception: " + ce); + throw new RuntimeException(ce); } } } - // check if a cause of exception is an expired cert - private static boolean expired(CertificateException ce) { - if (ce instanceof CertificateExpiredException) { - return true; - } - Throwable t = ce.getCause(); - while (t != null) { - if (t instanceof CertificateExpiredException) { - return true; - } - t = t.getCause(); - } - return false; - } - - private static X509Certificate[] loadCertificateChain(String name) + private X509Certificate[] loadCertificateChain(String certPath, String name) throws Exception { - try (InputStream in = new FileInputStream(TEST_SRC + File.separator + - name + "-chain.pem")) { + if (cf == null) { + cf = CertificateFactory.getInstance("X.509"); + } + try (InputStream in = new FileInputStream(TEST_SRC + File.separator + certPath + + File.separator + name + "-chain.pem")) { Collection certs = - (Collection)cf.generateCertificates(in); + (Collection) cf.generateCertificates(in); return certs.toArray(new X509Certificate[0]); } } - private static class DistrustedTLSServerCert extends X509Certificate { + private static class NonExpiringTLSServerCert extends X509Certificate { private final X509Certificate cert; - private final Date notBefore; - DistrustedTLSServerCert(X509Certificate cert, Date notBefore) { + NonExpiringTLSServerCert(X509Certificate cert) { this.cert = cert; - this.notBefore = notBefore; } public Set getCriticalExtensionOIDs() { - return cert.getCriticalExtensionOIDs(); + return cert.getCriticalExtensionOIDs(); } public byte[] getExtensionValue(String oid) { return cert.getExtensionValue(oid); @@ -201,19 +173,17 @@ public class Distrust { public boolean hasUnsupportedCriticalExtension() { return cert.hasUnsupportedCriticalExtension(); } - public void checkValidity() throws CertificateExpiredException, - CertificateNotYetValidException { + public void checkValidity() { // always pass } - public void checkValidity(Date date) throws CertificateExpiredException, - CertificateNotYetValidException { + public void checkValidity(Date date) { // always pass } public int getVersion() { return cert.getVersion(); } public BigInteger getSerialNumber() { return cert.getSerialNumber(); } public Principal getIssuerDN() { return cert.getIssuerDN(); } public Principal getSubjectDN() { return cert.getSubjectDN(); } - public Date getNotBefore() { return notBefore; } + public Date getNotBefore() { return cert.getNotBefore(); } public Date getNotAfter() { return cert.getNotAfter(); } public byte[] getTBSCertificate() throws CertificateEncodingException { return cert.getTBSCertificate(); @@ -234,16 +204,25 @@ public class Distrust { return cert.getEncoded(); } public void verify(PublicKey key) throws CertificateException, - InvalidKeyException, NoSuchAlgorithmException, - NoSuchProviderException, SignatureException { + InvalidKeyException, NoSuchAlgorithmException, + NoSuchProviderException, SignatureException { cert.verify(key); } public void verify(PublicKey key, String sigProvider) throws - CertificateException, InvalidKeyException, NoSuchAlgorithmException, - NoSuchProviderException, SignatureException { + CertificateException, InvalidKeyException, NoSuchAlgorithmException, + NoSuchProviderException, SignatureException { cert.verify(key, sigProvider); } public PublicKey getPublicKey() { return cert.getPublicKey(); } public String toString() { return cert.toString(); } } + + private static class DistrustedTLSServerCert extends NonExpiringTLSServerCert { + private final Date notBefore; + DistrustedTLSServerCert(X509Certificate cert, Date notBefore) { + super(cert); + this.notBefore = notBefore; + } + public Date getNotBefore() { return notBefore; } + } } diff --git a/test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/Entrust.java b/test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/Entrust.java new file mode 100644 index 00000000000..809674e8f20 --- /dev/null +++ b/test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/Entrust.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.io.File; +import java.time.*; +import java.util.*; +import javax.net.ssl.*; + +/** + * @test + * @bug 8337664 8341059 + * @summary Check that TLS Server certificates chaining back to distrusted + * Entrust roots are invalid + * @library /test/lib + * @modules java.base/sun.security.validator + * @run main/othervm Entrust after policyOn invalid + * @run main/othervm Entrust after policyOff valid + * @run main/othervm Entrust before policyOn valid + * @run main/othervm Entrust before policyOff valid + */ + +public class Entrust { + + private static final String certPath = "chains" + File.separator + "entrust"; + + // Each of the roots have a test certificate chain stored in a file + // named "-chain.pem". + private static String[] rootsToTest = new String[]{ + "entrustevca", "entrustrootcaec1", "entrustrootcag2", "entrustrootcag4", + "entrust2048ca", "affirmtrustcommercialca", "affirmtrustnetworkingca", + "affirmtrustpremiumca", "affirmtrustpremiumeccca"}; + + // Date when the restrictions take effect + private static final ZonedDateTime DISTRUST_DATE = + LocalDate.of(2024, 11, 12).atStartOfDay(ZoneOffset.UTC); + + public static void main(String[] args) throws Exception { + Distrust distrust = new Distrust(args); + + X509TrustManager[] tms = new X509TrustManager[]{ + distrust.getTMF("PKIX", null), + distrust.getTMF("SunX509", null) + }; + + Date notBefore = distrust.getNotBefore(DISTRUST_DATE); + distrust.testCertificateChain(certPath, notBefore, tms, rootsToTest); + } +} diff --git a/test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/Symantec.java b/test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/Symantec.java new file mode 100644 index 00000000000..4e099a8de8d --- /dev/null +++ b/test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/Symantec.java @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import javax.net.ssl.X509TrustManager; +import java.io.File; +import java.time.*; +import java.util.*; + + +/** + * @test + * @bug 8207258 8216280 + * @summary Check that TLS Server certificates chaining back to distrusted + * Symantec roots are invalid + * @library /test/lib + * @modules java.base/sun.security.validator + * @run main/othervm Symantec after policyOn invalid + * @run main/othervm Symantec after policyOff valid + * @run main/othervm Symantec before policyOn valid + * @run main/othervm Symantec before policyOff valid + */ + +public class Symantec { + + private static final String certPath = "chains" + File.separator + "symantec"; + + // Each of the roots have a test certificate chain stored in a file + // named "-chain.pem". + private static final String[] rootsToTest = new String[]{ + "geotrustprimarycag2", "geotrustprimarycag3", "geotrustuniversalca", + "thawteprimaryrootca", "thawteprimaryrootcag2", "thawteprimaryrootcag3", + "verisignclass3g3ca", "verisignclass3g4ca", "verisignclass3g5ca", + "verisignuniversalrootca" + }; + + // Each of the subCAs with a delayed distrust date have a test certificate + // chain stored in a file named "-chain.pem". + private static String[] subCAsToTest = new String[]{"appleistca8g1"}; + + // Date when the restrictions take effect + private static final ZonedDateTime ROOTS_DISTRUST_DATE = + LocalDate.of(2019, 4, 17).atStartOfDay(ZoneOffset.UTC); + + // Date when the subCA restrictions take effect + private static final ZonedDateTime SUBCA_DISTRUST_DATE = + LocalDate.of(2020, 1, 1).atStartOfDay(ZoneOffset.UTC); + + public static void main(String[] args) throws Exception { + Distrust distrust = new Distrust(args); + X509TrustManager[] tms = new X509TrustManager[]{ + distrust.getTMF("PKIX", null), + distrust.getTMF("SunX509", null) + }; + + // test chains issued through roots + Date notBefore = distrust.getNotBefore(ROOTS_DISTRUST_DATE); + distrust.testCertificateChain(certPath, notBefore, tms, rootsToTest); + + // test chain if params are passed to TrustManager + System.err.println("Testing verisignuniversalrootca with params"); + X509TrustManager[] tmsParams = new X509TrustManager[]{ + distrust.getTMF("PKIX", distrust.getParams()) + }; + distrust.testCertificateChain(certPath, notBefore, tmsParams, + "verisignuniversalrootca"); + + // test code-signing chain (should be valid as restrictions don't apply) + Date validationDate = new Date(1544197375493L); + distrust.testCodeSigningChain(certPath, "verisignclass3g5ca-codesigning", validationDate); + + // test chains issued through subCAs + notBefore = distrust.getNotBefore(SUBCA_DISTRUST_DATE); + distrust.testCertificateChain(certPath, notBefore, tms, subCAsToTest); + } +} diff --git a/test/jdk/sun/security/ssl/X509TrustManagerImpl/Entrust/affirmtrustcommercialca-chain.pem b/test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/chains/entrust/affirmtrustcommercialca-chain.pem similarity index 100% rename from test/jdk/sun/security/ssl/X509TrustManagerImpl/Entrust/affirmtrustcommercialca-chain.pem rename to test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/chains/entrust/affirmtrustcommercialca-chain.pem diff --git a/test/jdk/sun/security/ssl/X509TrustManagerImpl/Entrust/affirmtrustnetworkingca-chain.pem b/test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/chains/entrust/affirmtrustnetworkingca-chain.pem similarity index 100% rename from test/jdk/sun/security/ssl/X509TrustManagerImpl/Entrust/affirmtrustnetworkingca-chain.pem rename to test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/chains/entrust/affirmtrustnetworkingca-chain.pem diff --git a/test/jdk/sun/security/ssl/X509TrustManagerImpl/Entrust/affirmtrustpremiumca-chain.pem b/test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/chains/entrust/affirmtrustpremiumca-chain.pem similarity index 100% rename from test/jdk/sun/security/ssl/X509TrustManagerImpl/Entrust/affirmtrustpremiumca-chain.pem rename to test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/chains/entrust/affirmtrustpremiumca-chain.pem diff --git a/test/jdk/sun/security/ssl/X509TrustManagerImpl/Entrust/affirmtrustpremiumeccca-chain.pem b/test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/chains/entrust/affirmtrustpremiumeccca-chain.pem similarity index 100% rename from test/jdk/sun/security/ssl/X509TrustManagerImpl/Entrust/affirmtrustpremiumeccca-chain.pem rename to test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/chains/entrust/affirmtrustpremiumeccca-chain.pem diff --git a/test/jdk/sun/security/ssl/X509TrustManagerImpl/Entrust/entrust2048ca-chain.pem b/test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/chains/entrust/entrust2048ca-chain.pem similarity index 100% rename from test/jdk/sun/security/ssl/X509TrustManagerImpl/Entrust/entrust2048ca-chain.pem rename to test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/chains/entrust/entrust2048ca-chain.pem diff --git a/test/jdk/sun/security/ssl/X509TrustManagerImpl/Entrust/entrustevca-chain.pem b/test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/chains/entrust/entrustevca-chain.pem similarity index 100% rename from test/jdk/sun/security/ssl/X509TrustManagerImpl/Entrust/entrustevca-chain.pem rename to test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/chains/entrust/entrustevca-chain.pem diff --git a/test/jdk/sun/security/ssl/X509TrustManagerImpl/Entrust/entrustrootcaec1-chain.pem b/test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/chains/entrust/entrustrootcaec1-chain.pem similarity index 100% rename from test/jdk/sun/security/ssl/X509TrustManagerImpl/Entrust/entrustrootcaec1-chain.pem rename to test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/chains/entrust/entrustrootcaec1-chain.pem diff --git a/test/jdk/sun/security/ssl/X509TrustManagerImpl/Entrust/entrustrootcag2-chain.pem b/test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/chains/entrust/entrustrootcag2-chain.pem similarity index 100% rename from test/jdk/sun/security/ssl/X509TrustManagerImpl/Entrust/entrustrootcag2-chain.pem rename to test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/chains/entrust/entrustrootcag2-chain.pem diff --git a/test/jdk/sun/security/ssl/X509TrustManagerImpl/Entrust/entrustrootcag4-chain.pem b/test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/chains/entrust/entrustrootcag4-chain.pem similarity index 100% rename from test/jdk/sun/security/ssl/X509TrustManagerImpl/Entrust/entrustrootcag4-chain.pem rename to test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/chains/entrust/entrustrootcag4-chain.pem diff --git a/test/jdk/sun/security/ssl/X509TrustManagerImpl/Symantec/appleistca8g1-chain.pem b/test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/chains/symantec/appleistca8g1-chain.pem similarity index 100% rename from test/jdk/sun/security/ssl/X509TrustManagerImpl/Symantec/appleistca8g1-chain.pem rename to test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/chains/symantec/appleistca8g1-chain.pem diff --git a/test/jdk/sun/security/ssl/X509TrustManagerImpl/Symantec/geotrustprimarycag2-chain.pem b/test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/chains/symantec/geotrustprimarycag2-chain.pem similarity index 100% rename from test/jdk/sun/security/ssl/X509TrustManagerImpl/Symantec/geotrustprimarycag2-chain.pem rename to test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/chains/symantec/geotrustprimarycag2-chain.pem diff --git a/test/jdk/sun/security/ssl/X509TrustManagerImpl/Symantec/geotrustprimarycag3-chain.pem b/test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/chains/symantec/geotrustprimarycag3-chain.pem similarity index 100% rename from test/jdk/sun/security/ssl/X509TrustManagerImpl/Symantec/geotrustprimarycag3-chain.pem rename to test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/chains/symantec/geotrustprimarycag3-chain.pem diff --git a/test/jdk/sun/security/ssl/X509TrustManagerImpl/Symantec/geotrustuniversalca-chain.pem b/test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/chains/symantec/geotrustuniversalca-chain.pem similarity index 100% rename from test/jdk/sun/security/ssl/X509TrustManagerImpl/Symantec/geotrustuniversalca-chain.pem rename to test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/chains/symantec/geotrustuniversalca-chain.pem diff --git a/test/jdk/sun/security/ssl/X509TrustManagerImpl/Symantec/thawteprimaryrootca-chain.pem b/test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/chains/symantec/thawteprimaryrootca-chain.pem similarity index 100% rename from test/jdk/sun/security/ssl/X509TrustManagerImpl/Symantec/thawteprimaryrootca-chain.pem rename to test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/chains/symantec/thawteprimaryrootca-chain.pem diff --git a/test/jdk/sun/security/ssl/X509TrustManagerImpl/Symantec/thawteprimaryrootcag2-chain.pem b/test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/chains/symantec/thawteprimaryrootcag2-chain.pem similarity index 100% rename from test/jdk/sun/security/ssl/X509TrustManagerImpl/Symantec/thawteprimaryrootcag2-chain.pem rename to test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/chains/symantec/thawteprimaryrootcag2-chain.pem diff --git a/test/jdk/sun/security/ssl/X509TrustManagerImpl/Symantec/thawteprimaryrootcag3-chain.pem b/test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/chains/symantec/thawteprimaryrootcag3-chain.pem similarity index 100% rename from test/jdk/sun/security/ssl/X509TrustManagerImpl/Symantec/thawteprimaryrootcag3-chain.pem rename to test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/chains/symantec/thawteprimaryrootcag3-chain.pem diff --git a/test/jdk/sun/security/ssl/X509TrustManagerImpl/Symantec/verisignclass3g3ca-chain.pem b/test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/chains/symantec/verisignclass3g3ca-chain.pem similarity index 100% rename from test/jdk/sun/security/ssl/X509TrustManagerImpl/Symantec/verisignclass3g3ca-chain.pem rename to test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/chains/symantec/verisignclass3g3ca-chain.pem diff --git a/test/jdk/sun/security/ssl/X509TrustManagerImpl/Symantec/verisignclass3g4ca-chain.pem b/test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/chains/symantec/verisignclass3g4ca-chain.pem similarity index 100% rename from test/jdk/sun/security/ssl/X509TrustManagerImpl/Symantec/verisignclass3g4ca-chain.pem rename to test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/chains/symantec/verisignclass3g4ca-chain.pem diff --git a/test/jdk/sun/security/ssl/X509TrustManagerImpl/Symantec/verisignclass3g5ca-chain.pem b/test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/chains/symantec/verisignclass3g5ca-chain.pem similarity index 100% rename from test/jdk/sun/security/ssl/X509TrustManagerImpl/Symantec/verisignclass3g5ca-chain.pem rename to test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/chains/symantec/verisignclass3g5ca-chain.pem diff --git a/test/jdk/sun/security/ssl/X509TrustManagerImpl/Symantec/verisignclass3g5ca-codesigning-chain.pem b/test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/chains/symantec/verisignclass3g5ca-codesigning-chain.pem similarity index 100% rename from test/jdk/sun/security/ssl/X509TrustManagerImpl/Symantec/verisignclass3g5ca-codesigning-chain.pem rename to test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/chains/symantec/verisignclass3g5ca-codesigning-chain.pem diff --git a/test/jdk/sun/security/ssl/X509TrustManagerImpl/Symantec/verisignuniversalrootca-chain.pem b/test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/chains/symantec/verisignuniversalrootca-chain.pem similarity index 100% rename from test/jdk/sun/security/ssl/X509TrustManagerImpl/Symantec/verisignuniversalrootca-chain.pem rename to test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/chains/symantec/verisignuniversalrootca-chain.pem diff --git a/test/jdk/sun/security/tools/jarsigner/RemovedFiles.java b/test/jdk/sun/security/tools/jarsigner/RemovedFiles.java new file mode 100644 index 00000000000..598e25a9a70 --- /dev/null +++ b/test/jdk/sun/security/tools/jarsigner/RemovedFiles.java @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8309841 + * @summary Jarsigner should print a warning if an entry is removed + * @library /test/lib + */ + +import jdk.test.lib.SecurityTools; +import jdk.test.lib.util.JarUtils; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.jar.Attributes; +import java.util.jar.Manifest; + +public class RemovedFiles { + + private static final String NONEXISTENT_ENTRIES_FOUND + = "This jar contains signed entries for files that do not exist. See the -verbose output for more details."; + + public static void main(String[] args) throws Exception { + JarUtils.createJarFile( + Path.of("a.jar"), + Path.of("."), + Files.writeString(Path.of("a"), "a"), + Files.writeString(Path.of("b"), "b")); + SecurityTools.keytool("-genkeypair -storepass changeit -keystore ks -alias x -dname CN=x -keyalg ed25519"); + SecurityTools.jarsigner("-storepass changeit -keystore ks a.jar x"); + + // All is fine at the beginning. + SecurityTools.jarsigner("-verify a.jar") + .shouldNotContain(NONEXISTENT_ENTRIES_FOUND); + + // Remove an entry after signing. There will be a warning. + JarUtils.deleteEntries(Path.of("a.jar"), "a"); + SecurityTools.jarsigner("-verify a.jar") + .shouldContain(NONEXISTENT_ENTRIES_FOUND); + SecurityTools.jarsigner("-verify -verbose a.jar") + .shouldContain(NONEXISTENT_ENTRIES_FOUND) + .shouldContain("Warning: nonexistent signed entries: [a]"); + + // Remove one more entry. + JarUtils.deleteEntries(Path.of("a.jar"), "b"); + SecurityTools.jarsigner("-verify a.jar") + .shouldContain(NONEXISTENT_ENTRIES_FOUND); + SecurityTools.jarsigner("-verify -verbose a.jar") + .shouldContain(NONEXISTENT_ENTRIES_FOUND) + .shouldContain("Warning: nonexistent signed entries: [a, b]"); + + // Re-sign will not clear the warning. + SecurityTools.jarsigner("-storepass changeit -keystore ks a.jar x"); + SecurityTools.jarsigner("-verify a.jar") + .shouldContain(NONEXISTENT_ENTRIES_FOUND); + + // Unfortunately, if there is a non-file entry in manifest, there will be + // a false alarm. See https://bugs.openjdk.org/browse/JDK-8334261. + var man = new Manifest(); + man.getMainAttributes().putValue("Manifest-Version", "1.0"); + man.getEntries().computeIfAbsent("Hello", _ -> new Attributes()) + .putValue("Foo", "Bar"); + JarUtils.createJarFile(Path.of("b.jar"), + man, + Path.of("."), + Path.of("a")); + SecurityTools.jarsigner("-storepass changeit -keystore ks b.jar x"); + SecurityTools.jarsigner("-verbose -verify b.jar") + .shouldContain("Warning: nonexistent signed entries: [Hello]") + .shouldContain(NONEXISTENT_ENTRIES_FOUND); + + } +} diff --git a/test/jdk/sun/security/tools/keytool/GenKeyPairSigner.java b/test/jdk/sun/security/tools/keytool/GenKeyPairSigner.java index 52ca1ead82c..84cfcd7cb17 100644 --- a/test/jdk/sun/security/tools/keytool/GenKeyPairSigner.java +++ b/test/jdk/sun/security/tools/keytool/GenKeyPairSigner.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -84,7 +84,7 @@ public class GenKeyPairSigner { System.out.println("Generating an XDH cert with -signer option"); SecurityTools.keytool("-keystore ks -storepass changeit " + "-genkeypair -keyalg XDH -alias e1 -dname CN=E1 -signer ca") - .shouldContain("Generating 255 bit XDH key pair and a certificate (Ed25519) issued by with a validity of 90 days") + .shouldContain("Generating 255 bit X25519 key pair and a certificate (Ed25519) issued by with a validity of 90 days") .shouldContain("for: CN=E1") .shouldHaveExitValue(0); @@ -118,7 +118,7 @@ public class GenKeyPairSigner { .shouldContain("Alias name: e1") .shouldContain("Certificate chain length: 2") .shouldContain("Signature algorithm name: Ed25519") - .shouldContain("Subject Public Key Algorithm: 255-bit XDH key") + .shouldContain("Subject Public Key Algorithm: 255-bit X25519 key") .shouldHaveExitValue(0); // check to make sure that cert's AKID is created from the SKID of the signing cert @@ -150,7 +150,7 @@ public class GenKeyPairSigner { System.out.println("Generating an X448 cert with -signer option"); SecurityTools.keytool("-keystore ks -storepass changeit " + "-genkeypair -keyalg X448 -alias e2 -dname CN=E2 -sigalg SHA384withRSA -signer ca2") - .shouldContain("Generating 448 bit XDH key pair and a certificate (SHA384withRSA) issued by with a validity of 90 days") + .shouldContain("Generating 448 bit X448 key pair and a certificate (SHA384withRSA) issued by with a validity of 90 days") .shouldContain("for: CN=E2") .shouldHaveExitValue(0); @@ -177,7 +177,7 @@ public class GenKeyPairSigner { "-list -v") .shouldContain("Alias name: e2") .shouldContain("Signature algorithm name: SHA384withRSA") - .shouldContain("Subject Public Key Algorithm: 448-bit XDH key") + .shouldContain("Subject Public Key Algorithm: 448-bit X448 key") .shouldHaveExitValue(0); kt("-genkeypair -keyalg DSA -alias ca3 -dname CN=CA3 -ext bc:c ", @@ -249,7 +249,7 @@ public class GenKeyPairSigner { SecurityTools.keytool("-keystore ksjks -storepass changeit -storetype jks " + "-genkeypair -keyalg XDH -alias e1 -dname CN=E1 " + "-keypass e1keypass -signer ca1 -signerkeypass ca1keypass") - .shouldContain("Generating 255 bit XDH key pair and a certificate (SHA256withDSA) issued by with a validity of 90 days") + .shouldContain("Generating 255 bit X25519 key pair and a certificate (SHA256withDSA) issued by with a validity of 90 days") .shouldContain("for: CN=E1") .shouldContain("The generated certificate #2 of 3 uses a 1024-bit DSA key which is considered a security risk") .shouldContain("The generated certificate #3 of 3 uses a 1024-bit RSA key which is considered a security risk") @@ -285,7 +285,7 @@ public class GenKeyPairSigner { .shouldContain("Alias name: e1") .shouldContain("Certificate chain length: 3") .shouldContain("Signature algorithm name: SHA256withDSA") - .shouldContain("Subject Public Key Algorithm: 255-bit XDH key") + .shouldContain("Subject Public Key Algorithm: 255-bit X25519 key") .shouldHaveExitValue(0); } diff --git a/test/jdk/sun/security/tools/keytool/TestImportPass.java b/test/jdk/sun/security/tools/keytool/TestImportPass.java new file mode 100644 index 00000000000..adf8dba8415 --- /dev/null +++ b/test/jdk/sun/security/tools/keytool/TestImportPass.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8339347 + * @summary Test keytool -importpass with password input from System.in for + * the non-terminal console + * @library /test/lib + * @run main TestImportPass + */ + +import jdk.test.lib.SecurityTools; + +public class TestImportPass { + public static void main(String[] args) throws Throwable { + SecurityTools.setResponse("pass123"); + SecurityTools.keytool("-importpass -keystore ks.p12 -storepass changeit " + + "-storetype pkcs12 -alias newentry") + .shouldNotContain("Enter the password to be stored:") + .shouldHaveExitValue(0); + + SecurityTools.keytool("-list -keystore ks.p12 -storepass changeit " + + "-v") + .shouldContain("Alias name: newentry") + .shouldHaveExitValue(0); + } +} diff --git a/test/jdk/sun/security/validator/samedn.sh b/test/jdk/sun/security/validator/samedn.sh index 6a30b147157..a38d6e70990 100644 --- a/test/jdk/sun/security/validator/samedn.sh +++ b/test/jdk/sun/security/validator/samedn.sh @@ -1,5 +1,5 @@ # -# Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2010, 2024, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -62,10 +62,11 @@ $KT -genkeypair -alias ca1 -dname CN=CA -keyalg rsa -sigalg md5withrsa -ext bc - $KT -genkeypair -alias ca2 -dname CN=CA -keyalg rsa -sigalg sha1withrsa -ext bc -startdate -1y $KT -genkeypair -alias user -dname CN=User -keyalg rsa -# 2. Signing: ca -> user +# 2. Signing: ca -> user. The startdate is set to 1 minute in the past to ensure the certificate +# is valid at the time of validation and to prevent any issues with timing discrepancies -$KT -certreq -alias user | $KT -gencert -rfc -alias ca1 > samedn1.certs -$KT -certreq -alias user | $KT -gencert -rfc -alias ca2 > samedn2.certs +$KT -certreq -alias user | $KT -gencert -rfc -alias ca1 -startdate -1M > samedn1.certs +$KT -certreq -alias user | $KT -gencert -rfc -alias ca2 -startdate -1M > samedn2.certs # 3. Append the ca file diff --git a/test/jdk/sun/tools/jcmd/TestJcmdPIDSubstitution.java b/test/jdk/sun/tools/jcmd/TestJcmdPIDSubstitution.java index 4af5bf1ff67..f6b9718a28b 100644 --- a/test/jdk/sun/tools/jcmd/TestJcmdPIDSubstitution.java +++ b/test/jdk/sun/tools/jcmd/TestJcmdPIDSubstitution.java @@ -51,6 +51,8 @@ public class TestJcmdPIDSubstitution { verifyOutputFilenames("GC.heap_dump", FILENAME); if (Platform.isLinux()) { verifyOutputFilenames("Compiler.perfmap", FILENAME); + } + if (Platform.isLinux() || Platform.isWindows()) { verifyOutputFilenames("System.dump_map", "-F=%s".formatted(FILENAME)); } } diff --git a/test/jdk/sun/util/calendar/zi/Month.java b/test/jdk/sun/util/calendar/zi/Month.java index cb60b8d4411..bab909f7637 100644 --- a/test/jdk/sun/util/calendar/zi/Month.java +++ b/test/jdk/sun/util/calendar/zi/Month.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,11 +21,6 @@ * questions. */ -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - /** * Month enum handles month related manipulation. * @@ -47,15 +42,6 @@ enum Month { private final String abbr; - private static final Map abbreviations - = new HashMap(12); - - static { - for (Month m : Month.values()) { - abbreviations.put(m.abbr, m); - } - } - private Month(String abbr) { this.abbr = abbr; } @@ -70,11 +56,22 @@ enum Month { * @return the Month value */ static Month parse(String name) { - Month m = abbreviations.get(name); - if (m != null) { - return m; - } - return null; + int len = name.length(); + + if (name.regionMatches(true, 0, "January", 0, len)) return Month.JANUARY; + if (name.regionMatches(true, 0, "February", 0, len)) return Month.FEBRUARY; + if (name.regionMatches(true, 0, "March", 0, len)) return Month.MARCH; + if (name.regionMatches(true, 0, "April", 0, len)) return Month.APRIL; + if (name.regionMatches(true, 0, "May", 0, len)) return Month.MAY; + if (name.regionMatches(true, 0, "June", 0, len)) return Month.JUNE; + if (name.regionMatches(true, 0, "July", 0, len)) return Month.JULY; + if (name.regionMatches(true, 0, "August", 0, len)) return Month.AUGUST; + if (name.regionMatches(true, 0, "September", 0, len)) return Month.SEPTEMBER; + if (name.regionMatches(true, 0, "October", 0, len)) return Month.OCTOBER; + if (name.regionMatches(true, 0, "November", 0, len)) return Month.NOVEMBER; + if (name.regionMatches(true, 0, "December", 0, len)) return Month.DECEMBER; + + throw new IllegalArgumentException("Unknown month: " + name); } /** diff --git a/test/jdk/sun/util/calendar/zi/RuleDay.java b/test/jdk/sun/util/calendar/zi/RuleDay.java index bc730944b4c..9cd81c1e524 100644 --- a/test/jdk/sun/util/calendar/zi/RuleDay.java +++ b/test/jdk/sun/util/calendar/zi/RuleDay.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,11 +21,6 @@ * questions. */ -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - /** * RuleDay class represents the value of the "ON" field. The day of * week values start from 1 following the {@link java.util.Calendar} @@ -34,13 +29,6 @@ import java.util.Map; * @since 1.4 */ class RuleDay { - private static final Map abbreviations = new HashMap(7); - static { - for (DayOfWeek day : DayOfWeek.values()) { - abbreviations.put(day.getAbbr(), day); - } - } - private String dayName = null; private DayOfWeek dow; private boolean lastOne = false; @@ -166,13 +154,23 @@ class RuleDay { return sign + toString(d); } - private static DayOfWeek getDOW(String abbr) { - return abbreviations.get(abbr); + private static DayOfWeek getDOW(String name) { + int len = name.length(); + + if (name.regionMatches(true, 0, "Monday", 0, len)) return DayOfWeek.MONDAY; + if (name.regionMatches(true, 0, "Tuesday", 0, len)) return DayOfWeek.TUESDAY; + if (name.regionMatches(true, 0, "Wednesday", 0, len)) return DayOfWeek.WEDNESDAY; + if (name.regionMatches(true, 0, "Thursday", 0, len)) return DayOfWeek.THURSDAY; + if (name.regionMatches(true, 0, "Friday", 0, len)) return DayOfWeek.FRIDAY; + if (name.regionMatches(true, 0, "Saturday", 0, len)) return DayOfWeek.SATURDAY; + if (name.regionMatches(true, 0, "Sunday", 0, len)) return DayOfWeek.SUNDAY; + + throw new IllegalArgumentException("Unknown day-of-week: " + name); } /** * Converts the specified day of week value to the day-of-week - * name defined in {@link java.util.Calenda}. + * name defined in {@link java.util.Calendar}. * @param dow 1-based day of week value * @return the Calendar day of week name with "Calendar." prefix. * @throws IllegalArgumentException if the specified dow value is out of range. diff --git a/test/jdk/sun/util/calendar/zi/RuleRec.java b/test/jdk/sun/util/calendar/zi/RuleRec.java index 6d9d4905d6a..e6e18773d16 100644 --- a/test/jdk/sun/util/calendar/zi/RuleRec.java +++ b/test/jdk/sun/util/calendar/zi/RuleRec.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -168,12 +168,13 @@ class RuleRec { rec.toYear = Integer.parseInt(token); } catch (NumberFormatException e) { // it's not integer - if ("min".equals(token) || "minimum".equals(token)) { + int len = token.length(); + if (token.regionMatches(true, 0, "minimum", 0, len)) { rec.fromYear = Zoneinfo.getMinYear(); - } else if ("max".equals(token) || "maximum".equals(token)) { + } else if (token.regionMatches(true, 0, "maximum", 0, len)) { rec.toYear = Integer.MAX_VALUE; rec.isLastRule = true; - } else if ("only".equals(token)) { + } else if (token.regionMatches(true, 0, "only", 0, len)) { rec.toYear = rec.fromYear; } else { Main.panic("invalid year value: "+token); diff --git a/test/jdk/sun/util/calendar/zi/Zoneinfo.java b/test/jdk/sun/util/calendar/zi/Zoneinfo.java index f395101d865..e125ad2cb87 100644 --- a/test/jdk/sun/util/calendar/zi/Zoneinfo.java +++ b/test/jdk/sun/util/calendar/zi/Zoneinfo.java @@ -240,8 +240,9 @@ class Zoneinfo { continue; } String token = tokens.nextToken(); + int len = token.length(); - if (continued || "Zone".equals(token)) { + if (continued || token.regionMatches(true, 0, "Zone", 0, len)){ if (zone == null) { if (!tokens.hasMoreTokens()) { panic("syntax error: zone no more token"); @@ -268,7 +269,7 @@ class Zoneinfo { } zone = null; } - } else if ("Rule".equals(token)) { + } else if (token.regionMatches(true, 0, "Rule", 0, len)) { if (!tokens.hasMoreTokens()) { panic("syntax error: rule no more token"); } @@ -281,7 +282,7 @@ class Zoneinfo { RuleRec rrec = RuleRec.parse(tokens); rrec.setLine(line); rule.add(rrec); - } else if ("Link".equals(token)) { + } else if (token.regionMatches(true, 0, "Link", 0, len)) { // Link try { String name1 = tokens.nextToken(); diff --git a/test/jdk/tools/jimage/JImageToolTest.java b/test/jdk/tools/jimage/JImageToolTest.java index feb6a56a968..b1006c89679 100644 --- a/test/jdk/tools/jimage/JImageToolTest.java +++ b/test/jdk/tools/jimage/JImageToolTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,7 @@ import jdk.test.lib.process.ProcessTools; public class JImageToolTest { private static void jimage(String... jimageArgs) throws Exception { ArrayList args = new ArrayList<>(); - args.add("-ms64m"); + args.add("-Xms64m"); args.add("jdk.tools.jimage.Main"); args.addAll(Arrays.asList(jimageArgs)); diff --git a/test/jdk/tools/jpackage/macosx/SigningOptionsTest.java b/test/jdk/tools/jpackage/macosx/SigningOptionsTest.java index 9db836af992..fee874da2e8 100644 --- a/test/jdk/tools/jpackage/macosx/SigningOptionsTest.java +++ b/test/jdk/tools/jpackage/macosx/SigningOptionsTest.java @@ -91,8 +91,17 @@ public final class SigningOptionsTest { new String[]{"--type"}, "Option [--mac-installer-sign-identity] is not valid with type"}, // --app-content and --type app-image + // JDK-8340802: "codesign" may or may not fail if additional + // content is specified based on macOS version. For example on + // macOS 15 aarch64 "codesign" will not fail with additional content. + // Since we only need to check that warning is displayed when + // "codesign" fails and "--app-content" is provided, lets fail + // "codesign" for some better reason like identity which does not + // exists. {"Hello", - new String[]{"--app-content", TEST_DUKE}, + new String[]{"--app-content", TEST_DUKE, + "--mac-sign", + "--mac-app-image-sign-identity", "test-identity"}, null, "\"codesign\" failed and additional application content" + " was supplied via the \"--app-content\" parameter."}, diff --git a/test/jdk/tools/jpackage/share/AppContentTest.java b/test/jdk/tools/jpackage/share/AppContentTest.java index b31a6e637b2..a343e20d8a7 100644 --- a/test/jdk/tools/jpackage/share/AppContentTest.java +++ b/test/jdk/tools/jpackage/share/AppContentTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,6 +34,7 @@ import java.util.Arrays; import java.util.Collection; import java.util.List; +import jdk.internal.util.OSVersion; /** * Tests generation of packages with input folder containing empty folders. @@ -48,6 +49,7 @@ import java.util.List; * @build jdk.jpackage.test.* * @build AppContentTest * @modules jdk.jpackage/jdk.jpackage.internal + * @modules java.base/jdk.internal.util * @run main/othervm/timeout=720 -Xmx512m jdk.jpackage.test.Main * --jpt-run=AppContentTest */ @@ -81,6 +83,17 @@ public class AppContentTest { @Test public void test() throws Exception { + // On macOS signing may or may not work for modified app bundles. + // It works on macOS 15 and up, but fails on macOS below 15. + final int expectedJPackageExitCode; + final boolean isMacOS15 = (OSVersion.current().compareTo( + new OSVersion(15, 0, 0)) > 0); + if (testPathArgs.contains(TEST_BAD) || (TKit.isOSX() && !isMacOS15)) { + expectedJPackageExitCode = 1; + } else { + expectedJPackageExitCode = 0; + } + new PackageTest().configureHelloApp() .addInitializer(cmd -> { for (String arg : testPathArgs) { @@ -99,9 +112,7 @@ public class AppContentTest { } }) - // On macOS we always signing app image and signing will fail, since - // test produces invalid app bundle. - .setExpectedExitCode(testPathArgs.contains(TEST_BAD) || TKit.isOSX() ? 1 : 0) + .setExpectedExitCode(expectedJPackageExitCode) .run(); } } diff --git a/test/jdk/tools/launcher/HelpFlagsTest.java b/test/jdk/tools/launcher/HelpFlagsTest.java index 15c6c101dd0..0e8bc345ddc 100644 --- a/test/jdk/tools/launcher/HelpFlagsTest.java +++ b/test/jdk/tools/launcher/HelpFlagsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2018, 2020 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -45,7 +45,6 @@ public class HelpFlagsTest extends TestHelper { // Tools that should not be tested because a usage message is pointless. static final String[] TOOLS_NOT_TO_TEST = { - "appletviewer", // deprecated, don't test "jaccessinspector", // gui, don't test, win only "jaccessinspector-32", // gui, don't test, win-32 only "jaccesswalker", // gui, don't test, win only diff --git a/test/jdk/tools/launcher/MultipleJRERemoved.java b/test/jdk/tools/launcher/MultipleJRERemoved.java deleted file mode 100644 index 551ffc885f2..00000000000 --- a/test/jdk/tools/launcher/MultipleJRERemoved.java +++ /dev/null @@ -1,214 +0,0 @@ -/* - * Copyright (c) 2014, 2015, 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. - */ - -/** - * @test - * @bug 8067437 - * @summary Verify Multiple JRE version support has been removed. - * @modules jdk.compiler - * jdk.zipfs - * @build TestHelper - * @run main MultipleJRERemoved - */ - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.nio.file.Files; -import java.util.*; -import java.util.jar.Attributes; -import java.util.jar.JarOutputStream; -import java.util.jar.Manifest; -import java.util.regex.Pattern; -import java.util.stream.Collectors; -import java.util.stream.Stream; -import java.util.zip.ZipEntry; - -public class MultipleJRERemoved extends TestHelper { - - public static final String VERSION_JAR = "version.jar"; - public static final String PRINT_VERSION_CLASS = "PrintVersion"; - private final File javaFile = new File(PRINT_VERSION_CLASS + ".java"); - private final File clsFile = new File(PRINT_VERSION_CLASS + ".class"); - - private MultipleJRERemoved() { - } - - /** - * @param args the command line arguments - * @throws java.io.FileNotFoundException - */ - public static void main(String[] args) throws Exception { - MultipleJRERemoved a = new MultipleJRERemoved(); - a.run(args); - } - - /** - * Check all combinations of flags: "-version:", "-jre-restrict-search", "-jre-no-restrict-search". Test expects to see errors. - */ - @Test - public void allFlagCombinations() throws IOException { - final Pattern newLine = Pattern.compile("\n"); - createJar(Collections.emptyMap()); - - for (Flag flag1 : Flag.values()) { - for (Flag flag2 : Flag.values()) { - for (Flag flag3 : Flag.values()) { - List flags = Stream.of(flag1, flag2, flag3) - .filter(f -> !Flag.EMPTY.equals(f)) - .collect(Collectors.toList()); - - if (flags.size() == 0) continue; - - List flagValues = flags.stream() - .map(Flag::value) - .collect(Collectors.toList()); - - List errorMessages = flags.stream() - .map(Flag::errorMessage) - .flatMap(newLine::splitAsStream) - .collect(Collectors.toList()); - - List jarCmd = new ArrayList<>(); - jarCmd.add(javaCmd); - jarCmd.addAll(flagValues); - jarCmd.add("-jar"); - jarCmd.add("version.jar"); - - check(jarCmd, errorMessages); - - List cmd = new ArrayList<>(); - cmd.add(javaCmd); - cmd.addAll(flagValues); - cmd.add(PRINT_VERSION_CLASS); - - check(cmd, errorMessages); - } - } - } - } - - private void check(List cmd, List errorMessages) { - TestResult tr = doExec(cmd.toArray(new String[cmd.size()])); - tr.checkNegative(); - tr.isNotZeroOutput(); - errorMessages.forEach(tr::contains); - - if (!tr.testStatus) { - System.out.println(tr); - throw new RuntimeException("test case: failed\n" + cmd); - } - } - - /** - * Verifies that java -help output doesn't contain information about "mJRE" flags. - */ - @Test - public void javaHelp() { - TestResult tr = doExec(javaCmd, "-help"); - tr.checkPositive(); - tr.isNotZeroOutput(); - tr.notContains("-version:"); - tr.notContains("-jre-restrict-search"); - tr.notContains("-jre-no-restrict-search"); - tr.notContains("-no-jre-restrict-search"); //it's not a typo in flag name. - if (!tr.testStatus) { - System.out.println(tr); - throw new RuntimeException("Failed. java -help output contains obsolete flags.\n"); - } - } - - /** - * Verifies that java -jar version.jar output ignores "mJRE" manifest directives. - */ - @Test - public void manifestDirectives() throws IOException { - Map manifest = new TreeMap<>(); - manifest.put("JRE-Version", "1.8"); - manifest.put("JRE-Restrict-Search", "1.8"); - createJar(manifest); - - TestResult tr = doExec(javaCmd, "-jar", VERSION_JAR); - tr.checkPositive(); - tr.contains(System.getProperty("java.version")); - if (!tr.testStatus) { - System.out.println(tr); - throw new RuntimeException("Failed.\n"); - } - } - - private void emitFile() throws IOException { - List scr = new ArrayList<>(); - scr.add("public class PrintVersion {"); - scr.add(" public static void main(String... args) {"); - scr.add(" System.out.println(System.getProperty(\"java.version\"));"); - scr.add(" }"); - scr.add("}"); - createFile(javaFile, scr); - compile(javaFile.getName()); - } - - private void createJar(Map manifestAttributes) throws IOException { - emitFile(); - - Manifest manifest = new Manifest(); - final Attributes mainAttributes = manifest.getMainAttributes(); - mainAttributes.putValue("Manifest-Version", "1.0"); - mainAttributes.putValue("Main-Class", PRINT_VERSION_CLASS); - manifestAttributes.forEach(mainAttributes::putValue); - - try (JarOutputStream jar = new JarOutputStream(new FileOutputStream(VERSION_JAR), manifest)) { - jar.putNextEntry(new ZipEntry(PRINT_VERSION_CLASS + ".class")); - jar.write(Files.readAllBytes(clsFile.toPath())); - jar.closeEntry(); - } finally { - javaFile.delete(); - } - } - - private enum Flag { - EMPTY("", ""), - VERSION("-version:1.9", "Error: Specifying an alternate JDK/JRE version is no longer supported.\n" + - "The use of the flag '-version:' is no longer valid.\n" + - "Please download and execute the appropriate version."), - JRE_RESTRICT_SEARCH("-jre-restrict-search", "Error: Specifying an alternate JDK/JRE is no longer supported.\n" + - "The related flags -jre-restrict-search | -jre-no-restrict-search are also no longer valid."), - JRE_NO_RESTRICT_SEARCH("-jre-no-restrict-search", "Error: Specifying an alternate JDK/JRE is no longer supported.\n" + - "The related flags -jre-restrict-search | -jre-no-restrict-search are also no longer valid."); - private final String flag; - private final String errorMessage; - - Flag(String flag, String errorMessage) { - this.flag = flag; - this.errorMessage = errorMessage; - } - - String value() { - return flag; - } - - String errorMessage() { - return errorMessage; - } - } -} diff --git a/test/jdk/tools/launcher/VersionCheck.java b/test/jdk/tools/launcher/VersionCheck.java index 8ce636c4af7..539af8698d4 100644 --- a/test/jdk/tools/launcher/VersionCheck.java +++ b/test/jdk/tools/launcher/VersionCheck.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -67,7 +67,6 @@ public class VersionCheck extends TestHelper { // tools that do not accept -version static final String[] BLACKLIST_VERSION = { - "appletviewer", "controlpanel", "jaccessinspector", "jaccessinspector-32", diff --git a/test/jtreg-ext/requires/VMProps.java b/test/jtreg-ext/requires/VMProps.java index 49cc6e14311..465c641d442 100644 --- a/test/jtreg-ext/requires/VMProps.java +++ b/test/jtreg-ext/requires/VMProps.java @@ -128,11 +128,11 @@ public class VMProps implements Callable> { map.put("vm.graal.enabled", this::isGraalEnabled); // jdk.hasLibgraal is true if the libgraal shared library file is present map.put("jdk.hasLibgraal", this::hasLibgraal); - // vm.libgraal.enabled is true if libgraal is used as JIT - map.put("vm.libgraal.enabled", this::isLibgraalEnabled); + map.put("vm.libgraal.jit", this::isLibgraalJIT); map.put("vm.compiler1.enabled", this::isCompiler1Enabled); map.put("vm.compiler2.enabled", this::isCompiler2Enabled); - map.put("docker.support", this::dockerSupport); + map.put("container.support", this::containerSupport); + map.put("systemd.support", this::systemdSupport); map.put("vm.musl", this::isMusl); map.put("release.implementor", this::implementor); map.put("jdk.containerized", this::jdkContainerized); @@ -384,7 +384,9 @@ public class VMProps implements Callable> { vmOptFinalFlag(map, "CriticalJNINatives"); vmOptFinalFlag(map, "EnableJVMCI"); vmOptFinalFlag(map, "EliminateAllocations"); + vmOptFinalFlag(map, "UnlockExperimentalVMOptions"); vmOptFinalFlag(map, "UseCompressedOops"); + vmOptFinalFlag(map, "UseLargePages"); vmOptFinalFlag(map, "UseVectorizedMismatchIntrinsic"); vmOptFinalFlag(map, "ZGenerational"); } @@ -477,12 +479,14 @@ public class VMProps implements Callable> { } String CCP_DISABLED = "-XX:-UseCompressedClassPointers"; String G1GC_ENABLED = "-XX:+UseG1GC"; + String PARALLELGC_ENABLED = "-XX:+UseParallelGC"; + String SERIALGC_ENABLED = "-XX:+UseSerialGC"; for (String opt : jtropts.split(",")) { if (opt.equals(CCP_DISABLED)) { return false; } if (opt.startsWith(GC_PREFIX) && opt.endsWith(GC_SUFFIX) && - !opt.equals(G1GC_ENABLED)) { + !opt.equals(G1GC_ENABLED) && !opt.equals(PARALLELGC_ENABLED) && !opt.equals(SERIALGC_ENABLED)) { return false; } } @@ -558,8 +562,8 @@ public class VMProps implements Callable> { * * @return true if libgraal is used as JIT compiler. */ - protected String isLibgraalEnabled() { - return "" + Compiler.isLibgraalEnabled(); + protected String isLibgraalJIT() { + return "" + Compiler.isLibgraalJIT(); } /** @@ -581,16 +585,16 @@ public class VMProps implements Callable> { } /** - * A simple check for docker support + * A simple check for container support * - * @return true if docker is supported in a given environment + * @return true if container is supported in a given environment */ - protected String dockerSupport() { - log("Entering dockerSupport()"); + protected String containerSupport() { + log("Entering containerSupport()"); boolean isSupported = false; if (Platform.isLinux()) { - // currently docker testing is only supported for Linux, + // currently container testing is only supported for Linux, // on certain platforms String arch = System.getProperty("os.arch"); @@ -606,17 +610,38 @@ public class VMProps implements Callable> { } } - log("dockerSupport(): platform check: isSupported = " + isSupported); + log("containerSupport(): platform check: isSupported = " + isSupported); if (isSupported) { try { - isSupported = checkDockerSupport(); + isSupported = checkProgramSupport("checkContainerSupport()", Container.ENGINE_COMMAND); } catch (Exception e) { isSupported = false; } } - log("dockerSupport(): returning isSupported = " + isSupported); + log("containerSupport(): returning isSupported = " + isSupported); + return "" + isSupported; + } + + /** + * A simple check for systemd support + * + * @return true if systemd is supported in a given environment + */ + protected String systemdSupport() { + log("Entering systemdSupport()"); + + boolean isSupported = Platform.isLinux(); + if (isSupported) { + try { + isSupported = checkProgramSupport("checkSystemdSupport()", "systemd-run"); + } catch (Exception e) { + isSupported = false; + } + } + + log("systemdSupport(): returning isSupported = " + isSupported); return "" + isSupported; } @@ -654,17 +679,17 @@ public class VMProps implements Callable> { }); } - private boolean checkDockerSupport() throws IOException, InterruptedException { - log("checkDockerSupport(): entering"); - ProcessBuilder pb = new ProcessBuilder("which", Container.ENGINE_COMMAND); + private boolean checkProgramSupport(String logString, String cmd) throws IOException, InterruptedException { + log(logString + ": entering"); + ProcessBuilder pb = new ProcessBuilder("which", cmd); Map logFileNames = - redirectOutputToLogFile("checkDockerSupport(): which " + Container.ENGINE_COMMAND, - pb, "which-container"); + redirectOutputToLogFile(logString + ": which " + cmd, + pb, "which-cmd"); Process p = pb.start(); p.waitFor(10, TimeUnit.SECONDS); int exitValue = p.exitValue(); - log(String.format("checkDockerSupport(): exitValue = %s, pid = %s", exitValue, p.pid())); + log(String.format("%s: exitValue = %s, pid = %s", logString, exitValue, p.pid())); if (exitValue != 0) { printLogfileContent(logFileNames); } diff --git a/test/langtools/ProblemList.txt b/test/langtools/ProblemList.txt index 28926af0254..6ac84faaf7d 100644 --- a/test/langtools/ProblemList.txt +++ b/test/langtools/ProblemList.txt @@ -61,7 +61,6 @@ tools/javac/annotations/typeAnnotations/referenceinfos/Lambda.java tools/javac/annotations/typeAnnotations/referenceinfos/NestedTypes.java 8057687 generic-all emit correct byte code an attributes for type annotations tools/javac/warnings/suppress/TypeAnnotations.java 8057683 generic-all improve ordering of errors with type annotations tools/javac/modules/SourceInSymlinkTest.java 8180263 windows-all fails when run on a subst drive -tools/javac/patterns/Exhaustiveness.java 8326616 generic-all intermittently timeout ########################################################################### # diff --git a/test/langtools/jdk/javadoc/doclet/testHtmlDocument/TestHtmlDocument.java b/test/langtools/jdk/javadoc/doclet/testHtmlDocument/TestHtmlDocument.java index 9a9b20541c8..03adf00ca73 100644 --- a/test/langtools/jdk/javadoc/doclet/testHtmlDocument/TestHtmlDocument.java +++ b/test/langtools/jdk/javadoc/doclet/testHtmlDocument/TestHtmlDocument.java @@ -70,19 +70,19 @@ public class TestHtmlDocument extends JavadocTester { // Generate the HTML output using the HTML document generation within doclet. public static String generateHtmlTree() { // Document type for the HTML document - HtmlTree html = new HtmlTree(HtmlTag.HTML); - HtmlTree head = new HtmlTree(HtmlTag.HEAD); - HtmlTree title = new HtmlTree(HtmlTag.TITLE); + HtmlTree html = HtmlTree.of(HtmlTag.HTML); + HtmlTree head = HtmlTree.of(HtmlTag.HEAD); + HtmlTree title = HtmlTree.of(HtmlTag.TITLE); // String content within the document TextBuilder titleContent = new TextBuilder("Markup test"); title.add(titleContent); head.add(title); // Test META tag - HtmlTree meta = new HtmlTree(HtmlTag.META); + HtmlTree meta = HtmlTree.of(HtmlTag.META); meta.put(HtmlAttr.NAME, "keywords"); meta.put(HtmlAttr.CONTENT, "testContent"); head.add(meta); - HtmlTree link = new HtmlTree(HtmlTag.LINK); + HtmlTree link = HtmlTree.of(HtmlTag.LINK); link.put(HtmlAttr.REL, "testRel"); link.put(HtmlAttr.HREF, "testLink.html"); head.add(link); @@ -90,10 +90,10 @@ public class TestHtmlDocument extends JavadocTester { // Comment within the document Comment bodyMarker = new Comment("======== START OF BODY ========"); html.add(bodyMarker); - HtmlTree body = new HtmlTree(HtmlTag.BODY); + HtmlTree body = HtmlTree.of(HtmlTag.BODY); Comment pMarker = new Comment("======== START OF PARAGRAPH ========"); body.add(pMarker); - HtmlTree p = new HtmlTree(HtmlTag.P); + HtmlTree p = HtmlTree.of(HtmlTag.P); TextBuilder bodyContent = new TextBuilder( "This document is generated from sample source code and HTML " + "files with examples of a wide variety of Java language constructs: packages, " + @@ -106,24 +106,24 @@ public class TestHtmlDocument extends JavadocTester { TextBuilder pContent = new TextBuilder(" to out a link."); p.add(pContent); body.add(p); - HtmlTree p1 = new HtmlTree(HtmlTag.P); + HtmlTree p1 = HtmlTree.of(HtmlTag.P); // Test another version of A tag. - HtmlTree anchor = new HtmlTree(HtmlTag.A); + HtmlTree anchor = HtmlTree.of(HtmlTag.A); anchor.put(HtmlAttr.HREF, "testLink.html"); anchor.put(HtmlAttr.ID, "Another version of a tag"); p1.add(anchor); body.add(p1); // Test for empty tags. - HtmlTree dl = new HtmlTree(HtmlTag.DL); + HtmlTree dl = HtmlTree.of(HtmlTag.DL); html.add(dl); // Test for empty nested tags. - HtmlTree dlTree = new HtmlTree(HtmlTag.DL); - dlTree.add(new HtmlTree(HtmlTag.DT)); - dlTree.add(new HtmlTree (HtmlTag.DD)); + HtmlTree dlTree = HtmlTree.of(HtmlTag.DL); + dlTree.add(HtmlTree.of(HtmlTag.DT)); + dlTree.add(HtmlTree.of (HtmlTag.DD)); html.add(dlTree); - HtmlTree dlDisplay = new HtmlTree(HtmlTag.DL); - dlDisplay.add(new HtmlTree(HtmlTag.DT)); - HtmlTree dd = new HtmlTree (HtmlTag.DD); + HtmlTree dlDisplay = HtmlTree.of(HtmlTag.DL); + dlDisplay.add(HtmlTree.of(HtmlTag.DT)); + HtmlTree dd = HtmlTree.of (HtmlTag.DD); TextBuilder ddContent = new TextBuilder("Test DD"); dd.add(ddContent); dlDisplay.add(dd); @@ -132,7 +132,7 @@ public class TestHtmlDocument extends JavadocTester { body.add(emptyString); Comment emptyComment = new Comment(""); body.add(emptyComment); - HtmlTree hr = new HtmlTree(HtmlTag.HR); + HtmlTree hr = HtmlTree.of(HtmlTag.HR); body.add(hr); html.add(body); HtmlDocument htmlDoc = new HtmlDocument(html); diff --git a/test/langtools/jdk/javadoc/doclet/testMarkdown/TestMarkdownCodeBlocks.java b/test/langtools/jdk/javadoc/doclet/testMarkdown/TestMarkdownCodeBlocks.java index 8f1c76b9e47..dda8a76868e 100644 --- a/test/langtools/jdk/javadoc/doclet/testMarkdown/TestMarkdownCodeBlocks.java +++ b/test/langtools/jdk/javadoc/doclet/testMarkdown/TestMarkdownCodeBlocks.java @@ -486,4 +486,107 @@ public class TestMarkdownCodeBlocks extends JavadocTester {
                    NullPointerException - if other is null
                    """); } + + @Test + public void testLeadingCodeBlock(Path base) throws Exception { + Path src = base.resolve("src"); + tb.writeJavaFiles(src, + """ + package p; + /// Leading code block + /// Lorum ipsum. + public class C { } + """); + + javadoc("-d", base.resolve("api").toString(), + "--no-platform-links", + "--source-path", src.toString(), + "p"); + checkExit(Exit.OK); + + // check first sentence is empty in package summary file + checkOutput("p/package-summary.html", true, + """ + +
                     
                    """); + + checkOutput("p/C.html", true, + """ +
                    Leading code block
                    +                    
                    +

                    Lorum ipsum.

                    """); + + } + + @Test + public void testTrailingCodeBlock(Path base) throws Exception { + Path src = base.resolve("src"); + tb.writeJavaFiles(src, + """ + package p; + /// Lorum ipsum. + /// + /// Trailing code block + public class C { } + """); + + javadoc("-d", base.resolve("api").toString(), + "--no-platform-links", + "--source-path", src.toString(), + "p"); + checkExit(Exit.OK); + + checkOutput("p/C.html", true, + """ +

                    Lorum ipsum.

                    +
                    Trailing code block
                    +                    
                    +
                    """); + } + + // this example is derived from the test case in JDK-8338525 + @Test + public void testLeadingTrailingCodeBlockWithAnnotations(Path base) throws Exception { + Path src = base.resolve("src"); + tb.writeJavaFiles(src, + """ + package p; + public class C { + /// @Override + /// void m() {} + /// + /// Plain text + /// + /// @Override + /// void m() {} + public void m() {} + }"""); + + javadoc("-d", base.resolve("api").toString(), + "--no-platform-links", + "--source-path", src.toString(), + "p"); + checkExit(Exit.OK); + + checkOutput("p/C.html", true, + """ +
                    void
                    +
                    m()
                    +
                     
                    """, + """ +
                    public \ + void m()
                    +
                    @Override
                    +                    void m() {}
                    +                    
                    +

                    Plain text

                    +
                    @Override
                    +                    void m() {}
                    +                    
                    +
                    """); + + } } diff --git a/test/langtools/jdk/javadoc/doclet/testVoidHtmlElements/TestVoidHtmlElements.java b/test/langtools/jdk/javadoc/doclet/testVoidHtmlElements/TestVoidHtmlElements.java index bd44fe88141..518ecebd704 100644 --- a/test/langtools/jdk/javadoc/doclet/testVoidHtmlElements/TestVoidHtmlElements.java +++ b/test/langtools/jdk/javadoc/doclet/testVoidHtmlElements/TestVoidHtmlElements.java @@ -55,7 +55,7 @@ public class TestVoidHtmlElements { } private static void check(HtmlTag htmlTag) { - boolean elementIsVoid = new HtmlTree(htmlTag).isVoid(); + boolean elementIsVoid = HtmlTree.of(htmlTag).isVoid(); boolean elementHasNoEndTag = htmlTag.endKind == HtmlTag.EndKind.NONE; if (elementIsVoid != elementHasNoEndTag) { throw new AssertionError(htmlTag + ", " + elementIsVoid + ", " + elementHasNoEndTag); diff --git a/test/langtools/jdk/javadoc/tool/subpackageNoModules/SubpackageNoModules.java b/test/langtools/jdk/javadoc/tool/subpackageNoModules/SubpackageNoModules.java new file mode 100644 index 00000000000..164ec1f19e4 --- /dev/null +++ b/test/langtools/jdk/javadoc/tool/subpackageNoModules/SubpackageNoModules.java @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8325090 + * @summary javadoc fails when -subpackages option is used with non-modular -source + * @modules jdk.javadoc/jdk.javadoc.internal.api + * jdk.javadoc/jdk.javadoc.internal.tool + * @library /tools/lib + * @build toolbox.TestRunner toolbox.ToolBox + * @run main SubpackageNoModules + */ + +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import toolbox.*; +import toolbox.Task.Expect; + +public class SubpackageNoModules extends TestRunner { + + final ToolBox tb = new ToolBox(); + + public SubpackageNoModules() { + super(System.err); + } + + public static void main(String[] args) throws Exception { + SubpackageNoModules t = new SubpackageNoModules(); + t.runTests(m -> new Object[] { Paths.get(m.getName()) }); + } + + @Test + public void testSubpackageNoModules(Path base) throws Exception { + Files.createDirectories(base); + tb.writeFile(base.resolve("pkg/A.java"), "package pkg;\npublic class A {}\n"); + + Path outDir = base.resolve("out"); + Files.createDirectory(outDir); + // Combine -subpackages option with -source release that doesn't support modules + new JavadocTask(tb) + .outdir(outDir) + .sourcepath(base) + .options("-source", "8", + "-subpackages", "pkg") + .run(Expect.SUCCESS); + // Check for presence of generated docs + if (!Files.isRegularFile(outDir.resolve("pkg/A.html"))) { + error("File not found: " + outDir.resolve("pkg/A.html")); + } + } +} diff --git a/test/langtools/jdk/jshell/ExceptionMessageTest.java b/test/langtools/jdk/jshell/ExceptionMessageTest.java index 9f8b53f1563..fe8eec57739 100644 --- a/test/langtools/jdk/jshell/ExceptionMessageTest.java +++ b/test/langtools/jdk/jshell/ExceptionMessageTest.java @@ -26,6 +26,7 @@ * @bug 8185108 * @summary Test exception().getMessage() in events returned by eval() * @run testng ExceptionMessageTest + * @key intermittent */ import java.util.HashMap; diff --git a/test/langtools/tools/javac/ImportModule.java b/test/langtools/tools/javac/ImportModule.java index f38b77062e2..dc1ed9bd0c1 100644 --- a/test/langtools/tools/javac/ImportModule.java +++ b/test/langtools/tools/javac/ImportModule.java @@ -797,4 +797,50 @@ public class ImportModule extends TestRunner { } } + + @Test + public void testImportModuleNoModules(Path base) throws Exception { + Path current = base.resolve("."); + Path src = current.resolve("src"); + Path classes = current.resolve("classes"); + tb.writeJavaFiles(src, + """ + package test; + import module java.base; + public class Test { + List l; + } + """); + + Files.createDirectories(classes); + + List actualErrors = new JavacTask(tb) + .options("--release", "8", + "-XDshould-stop.at=FLOW", + "-XDdev", + "-XDrawDiagnostics") + .outdir(classes) + .files(tb.findJavaFiles(src)) + .run(Task.Expect.FAIL) + .writeAll() + .getOutputLines(Task.OutputKind.DIRECT); + + List expectedErrors = List.of( + "- compiler.warn.option.obsolete.source: 8", + "- compiler.warn.option.obsolete.target: 8", + "- compiler.warn.option.obsolete.suppression", + "Test.java:2:8: compiler.err.preview.feature.disabled.plural: (compiler.misc.feature.module.imports)", + "Test.java:2:1: compiler.err.import.module.not.found: java.base", + "Test.java:4:5: compiler.err.cant.resolve.location: kindname.class, List, , , (compiler.misc.location: kindname.class, test.Test, null)", + "3 errors", + "3 warnings" + ); + + if (!Objects.equals(expectedErrors, actualErrors)) { + throw new AssertionError("Incorrect Output, expected: " + expectedErrors + + ", actual: " + out); + + } + } + } diff --git a/test/langtools/tools/javac/MethodParameters/LambdaTest.out b/test/langtools/tools/javac/MethodParameters/LambdaTest.out index b03cc76a97b..36b91b5e36d 100644 --- a/test/langtools/tools/javac/MethodParameters/LambdaTest.out +++ b/test/langtools/tools/javac/MethodParameters/LambdaTest.out @@ -1,7 +1,7 @@ class LambdaTest -- LambdaTest.() LambdaTest.foo(i) -LambdaTest.lambda$static$1(arg0)/*synthetic*/ -LambdaTest.lambda$static$0(arg0, arg1)/*synthetic*/ +LambdaTest.lambda$static$0(arg0)/*synthetic*/ +LambdaTest.lambda$static$1(arg0, arg1)/*synthetic*/ static interface LambdaTest$I -- inner LambdaTest$I.m(x) diff --git a/test/langtools/tools/javac/MethodParameters/LocalClassTest.out b/test/langtools/tools/javac/MethodParameters/LocalClassTest.out index 3b95739e74a..7b0028e1fb0 100644 --- a/test/langtools/tools/javac/MethodParameters/LocalClassTest.out +++ b/test/langtools/tools/javac/MethodParameters/LocalClassTest.out @@ -1,7 +1,7 @@ class LocalClassTest$1 -- anon LocalClassTest$1.(final this$0/*implicit*/, final j, final val$i/*synthetic*/) class LocalClassTest$1CapturingLocal$1 -- anon -LocalClassTest$1CapturingLocal$1.(final this$0/*implicit*/, final val$val$i/*synthetic*/) +LocalClassTest$1CapturingLocal$1.(final this$0/*implicit*/, final val$i/*synthetic*/) LocalClassTest$1CapturingLocal$1.test() class LocalClassTest$1CapturingLocal -- inner LocalClassTest$1CapturingLocal.(final this$0/*implicit*/, final j, final val$i/*synthetic*/) diff --git a/test/langtools/tools/javac/T6435291/T.jcod b/test/langtools/tools/javac/T6435291/T.jcod deleted file mode 100644 index 9175f4f4041..00000000000 --- a/test/langtools/tools/javac/T6435291/T.jcod +++ /dev/null @@ -1,320 +0,0 @@ -class T { - 0xCAFEBABE; - 0; // minor version - 49; // version - [73] { // Constant Pool - ; // first element is empty - Utf8 "T"; // #1 at 0x0A - class #1; // #2 at 0x1A - Utf8 "Ljava/lang/Enum;"; // #3 at 0x1D - Utf8 "java/lang/Enum"; // #4 at 0x41 - class #4; // #5 at 0x52 - Utf8 "T.java"; // #6 at 0x55 - Utf8 "T1"; // #7 at 0x61 - Utf8 "LT;"; // #8 at 0x66 - Utf8 "T2"; // #9 at 0x78 - Utf8 "T3"; // #10 at 0x7D - Utf8 "myName"; // #11 at 0x82 - Utf8 "Ljava/lang/String;"; // #12 at 0x8B - Utf8 "$VALUES"; // #13 at 0xA0 - Utf8 "[LT;"; // #14 at 0xAA - Utf8 "values"; // #15 at 0xBD - Utf8 "()[LT;"; // #16 at 0xC6 - NameAndType #13 #14; // #17 at 0xDB - Field #2 #17; // #18 at 0xE0 - class #14; // #19 at 0xE5 - Utf8 "clone"; // #20 at 0xE8 - Utf8 "()Ljava/lang/Object;"; // #21 at 0xF0 - NameAndType #20 #21; // #22 at 0x0107 - Method #19 #22; // #23 at 0x010C - Utf8 "valueOf"; // #24 at 0x0111 - Utf8 "(Ljava/lang/String;)LT;"; // #25 at 0x011B - Utf8 "(Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/Enum;"; // #26 at 0x0141 - NameAndType #24 #26; // #27 at 0x0179 - Method #5 #27; // #28 at 0x017E - Utf8 "name"; // #29 at 0x0183 - Utf8 "getName"; // #30 at 0x018A - Utf8 "()Ljava/lang/String;"; // #31 at 0x0194 - NameAndType #11 #12; // #32 at 0x01AB - Field #2 #32; // #33 at 0x01B0 - Utf8 "this"; // #34 at 0x01B5 - Utf8 ""; // #35 at 0x01BC - Utf8 "(Ljava/lang/String;ILjava/lang/String;)V"; // #36 at 0x01C5 - Utf8 "LNotNull;"; // #37 at 0x01F0 - Utf8 "java/lang/IllegalArgumentException"; // #38 at 0x0216 - class #38; // #39 at 0x023B - Utf8 "Argument 0 for @NotNull parameter of T. must not be null"; // #40 at 0x023E - String #40; // #41 at 0x028B - Utf8 "(Ljava/lang/String;)V"; // #42 at 0x028E - NameAndType #35 #42; // #43 at 0x02A6 - Method #39 #43; // #44 at 0x02AB - Utf8 "(Ljava/lang/String;I)V"; // #45 at 0x02B0 - NameAndType #35 #45; // #46 at 0x02C9 - Method #5 #46; // #47 at 0x02CE - Utf8 ""; // #48 at 0x02D3 - Utf8 "()V"; // #49 at 0x02DE - String #7; // #50 at 0x02E4 - Utf8 "type1"; // #51 at 0x02E7 - String #51; // #52 at 0x02EF - NameAndType #35 #36; // #53 at 0x02F2 - Method #2 #53; // #54 at 0x02F7 - NameAndType #7 #8; // #55 at 0x02FC - Field #2 #55; // #56 at 0x0301 - String #9; // #57 at 0x0306 - Utf8 "type2"; // #58 at 0x0309 - String #58; // #59 at 0x0311 - NameAndType #9 #8; // #60 at 0x0314 - Field #2 #60; // #61 at 0x0319 - String #10; // #62 at 0x031E - Utf8 "type3"; // #63 at 0x0321 - String #63; // #64 at 0x0329 - NameAndType #10 #8; // #65 at 0x032C - Field #2 #65; // #66 at 0x0331 - Utf8 "Code"; // #67 at 0x0336 - Utf8 "LineNumberTable"; // #68 at 0x033D - Utf8 "LocalVariableTable"; // #69 at 0x034F - Utf8 "Signature"; // #70 at 0x0364 - Utf8 "RuntimeInvisibleParameterAnnotations"; // #71 at 0x0370 - Utf8 "SourceFile"; // #72 at 0x0397 - } // Constant Pool - - 0x4031; // access - #2;// this_cpx - #5;// super_cpx - - [0] { // Interfaces - } // Interfaces - - [5] { // fields - { // Member at 0x03AE - 0x4019; // access - #7; // name_cpx - #8; // sig_cpx - [0] { // Attributes - } // Attributes - } // Member - ; - { // Member at 0x03B6 - 0x4019; // access - #9; // name_cpx - #8; // sig_cpx - [0] { // Attributes - } // Attributes - } // Member - ; - { // Member at 0x03BE - 0x4019; // access - #10; // name_cpx - #8; // sig_cpx - [0] { // Attributes - } // Attributes - } // Member - ; - { // Member at 0x03C6 - 0x0012; // access - #11; // name_cpx - #12; // sig_cpx - [0] { // Attributes - } // Attributes - } // Member - ; - { // Member at 0x03CE - 0x101A; // access - #13; // name_cpx - #14; // sig_cpx - [0] { // Attributes - } // Attributes - } // Member - } // fields - - [5] { // methods - { // Member at 0x03D8 - 0x0019; // access - #15; // name_cpx - #16; // sig_cpx - [1] { // Attributes - Attr(#67, 34) { // Code at 0x03E0 - 1; // max_stack - 0; // max_locals - Bytes[10]{ - 0xB20012B60017C000; - 0x13B0; - }; - [0] { // Traps - } // end Traps - [1] { // Attributes - Attr(#68, 6) { // LineNumberTable at 0x03FC - [1] { // LineNumberTable - 0 9; // at 0x0408 - } - } // end LineNumberTable - } // Attributes - } // end Code - } // Attributes - } // Member - ; - { // Member at 0x0408 - 0x0009; // access - #24; // name_cpx - #25; // sig_cpx - [1] { // Attributes - Attr(#67, 52) { // Code at 0x0410 - 2; // max_stack - 1; // max_locals - Bytes[10]{ - 0x12022AB8001CC000; - 0x02B0; - }; - [0] { // Traps - } // end Traps - [2] { // Attributes - Attr(#69, 12) { // LocalVariableTable at 0x042C - [1] { // LocalVariableTable - 0 10 29 12 0; // at 0x043E - } - } // end LocalVariableTable - ; - Attr(#68, 6) { // LineNumberTable at 0x043E - [1] { // LineNumberTable - 0 9; // at 0x044A - } - } // end LineNumberTable - } // Attributes - } // end Code - } // Attributes - } // Member - ; - { // Member at 0x044A - 0x0001; // access - #30; // name_cpx - #31; // sig_cpx - [1] { // Attributes - Attr(#67, 47) { // Code at 0x0452 - 1; // max_stack - 1; // max_locals - Bytes[5]{ - 0x2AB40021B0; - }; - [0] { // Traps - } // end Traps - [2] { // Attributes - Attr(#69, 12) { // LocalVariableTable at 0x0469 - [1] { // LocalVariableTable - 0 5 34 8 0; // at 0x047B - } - } // end LocalVariableTable - ; - Attr(#68, 6) { // LineNumberTable at 0x047B - [1] { // LineNumberTable - 0 17; // at 0x0487 - } - } // end LineNumberTable - } // Attributes - } // end Code - } // Attributes - } // Member - ; - { // Member at 0x0487 - 0x0002; // access - #35; // name_cpx - #36; // sig_cpx - [3] { // Attributes - Attr(#67, 86) { // Code at 0x048F - 3; // max_stack - 4; // max_locals - Bytes[26]{ - 0x2BC7000DBB002759; - 0x1229B7002CBF2A2B; - 0x1CB7002F2A2DB500; - 0x21B1; - }; - [0] { // Traps - } // end Traps - [2] { // Attributes - Attr(#69, 22) { // LocalVariableTable at 0x04BB - [2] { // LocalVariableTable - 14 12 34 8 0; // at 0x04CD - 14 12 29 12 3; // at 0x04D7 - } - } // end LocalVariableTable - ; - Attr(#68, 14) { // LineNumberTable at 0x04D7 - [3] { // LineNumberTable - 14 20; // at 0x04E3 - 20 21; // at 0x04E7 - 25 22; // at 0x04EB - } - } // end LineNumberTable - } // Attributes - } // end Code - ; - Attr(#70, 2) { // Signature at 0x04EB - #42; - } // end Signature - ; - Attr(#71, 11) { // RuntimeInvisibleParameterAnnotations at 0x04F3 - [3]b { // parameters - [1] { // annotations - { // annotation - #37; - [0] { // element_value_pairs - } // element_value_pairs - } // annotation - } - ; - [0] { // annotations - } - ; - [0] { // annotations - } - } - } // end RuntimeInvisibleParameterAnnotations - } // Attributes - } // Member - ; - { // Member at 0x0504 - 0x0008; // access - #48; // name_cpx - #49; // sig_cpx - [1] { // Attributes - Attr(#67, 107) { // Code at 0x050C - 5; // max_stack - 0; // max_locals - Bytes[71]{ - 0xBB00025912320312; - 0x34B70036B30038BB; - 0x000259123904123B; - 0xB70036B3003DBB00; - 0x0259123E051240B7; - 0x0036B3004206BD00; - 0x025903B200385359; - 0x04B2003D535905B2; - 0x004253B30012B1; - }; - [0] { // Traps - } // end Traps - [1] { // Attributes - Attr(#68, 18) { // LineNumberTable at 0x0565 - [4] { // LineNumberTable - 0 10; // at 0x0571 - 15 11; // at 0x0575 - 30 12; // at 0x0579 - 45 9; // at 0x057D - } - } // end LineNumberTable - } // Attributes - } // end Code - } // Attributes - } // Member - } // methods - - [2] { // Attributes - Attr(#70, 2) { // Signature at 0x057F - #3; - } // end Signature - ; - Attr(#72, 2) { // SourceFile at 0x0587 - #6; - } // end SourceFile - } // Attributes -} // end class T diff --git a/test/langtools/tools/javac/T6435291/T6435291.java b/test/langtools/tools/javac/T6435291/T6435291.java deleted file mode 100644 index 33c6038b697..00000000000 --- a/test/langtools/tools/javac/T6435291/T6435291.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2006, 2018, 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. - */ - -/** - * @test - * @bug 6435291 - * @summary javac shouldn't throw NPE while compiling invalid RuntimeInvisibleParameterAnnotations - * @author Wei Tao - * @modules jdk.compiler/com.sun.tools.javac.api - * jdk.compiler/com.sun.tools.javac.code - * jdk.compiler/com.sun.tools.javac.comp - * jdk.compiler/com.sun.tools.javac.main - * jdk.compiler/com.sun.tools.javac.util - * @build T - * @run main/othervm T6435291 - */ - -import com.sun.tools.javac.api.JavacTaskImpl; -import com.sun.tools.javac.code.ClassFinder.BadClassFile; -import com.sun.tools.javac.code.Symtab; -import com.sun.tools.javac.util.Names; -import javax.tools.ToolProvider; - -public class T6435291 { - public static void main(String... args) { - javax.tools.JavaCompiler tool = ToolProvider.getSystemJavaCompiler(); - JavacTaskImpl task = (JavacTaskImpl)tool.getTask(null, null, null, null, null, null); - Symtab syms = Symtab.instance(task.getContext()); - Names names = Names.instance(task.getContext()); - task.ensureEntered(); - try { - syms.enterClass(syms.unnamedModule, names.fromString("T")).complete(); - } catch (BadClassFile e) { - System.err.println("Passed: expected completion failure " + e.getClass().getName()); - return; - } catch (Exception e) { - throw new RuntimeException("Failed: unexpected exception"); - } - throw new RuntimeException("Failed: no error reported"); - } -} diff --git a/test/langtools/tools/javac/T8019486/WrongLNTForLambdaTest.java b/test/langtools/tools/javac/T8019486/WrongLNTForLambdaTest.java index 24c9b81c964..4ddc40fa231 100644 --- a/test/langtools/tools/javac/T8019486/WrongLNTForLambdaTest.java +++ b/test/langtools/tools/javac/T8019486/WrongLNTForLambdaTest.java @@ -136,15 +136,15 @@ public class WrongLNTForLambdaTest { checkClassFile(new File(Paths.get(System.getProperty("user.dir"), "Foo.class").toUri()), "lambda$bar$0", simpleLambdaExpectedLNT); checkClassFile(new File(Paths.get(System.getProperty("user.dir"), - "Foo.class").toUri()), "lambda$variablesInLambdas$1", lambdaWithVarsExpectedLNT); + "Foo.class").toUri()), "lambda$variablesInLambdas$0", lambdaWithVarsExpectedLNT); checkClassFile(new File(Paths.get(System.getProperty("user.dir"), "Foo$1FooBar.class").toUri()), "run", insideLambdaWithVarsExpectedLNT); checkClassFile(new File(Paths.get(System.getProperty("user.dir"), - "Foo.class").toUri()), "lambda$variablesInLambdas$2", lambdaVoid2VoidExpectedLNT); + "Foo.class").toUri()), "lambda$variablesInLambdas$1", lambdaVoid2VoidExpectedLNT); checkClassFile(new File(Paths.get(System.getProperty("user.dir"), "Foo.class").toUri()), "$deserializeLambda$", deserializeExpectedLNT); checkClassFile(new File(Paths.get(System.getProperty("user.dir"), - "Foo.class").toUri()), "lambda$variablesInLambdas$3", lambdaBridgeExpectedLNT); + "Foo.class").toUri()), "lambda$variablesInLambdas$2", lambdaBridgeExpectedLNT); checkClassFile(new File(Paths.get(System.getProperty("user.dir"), "Foo.class").toUri()), "assignLambda", assignmentExpectedLNT); checkClassFile(new File(Paths.get(System.getProperty("user.dir"), diff --git a/test/langtools/tools/javac/annotations/parameter/ParameterAnnotations.java b/test/langtools/tools/javac/annotations/parameter/ParameterAnnotations.java new file mode 100644 index 00000000000..395765fcb80 --- /dev/null +++ b/test/langtools/tools/javac/annotations/parameter/ParameterAnnotations.java @@ -0,0 +1,699 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8024694 8334870 + * @summary Check javac can handle various Runtime(In)VisibleParameterAnnotations attribute combinations + * @enablePreview + * @library /tools/lib + * @modules jdk.compiler/com.sun.tools.javac.api + * jdk.compiler/com.sun.tools.javac.main + * jdk.compiler/com.sun.tools.javac.util + * @build toolbox.ToolBox toolbox.JavacTask + * @run main ParameterAnnotations +*/ + +import java.io.OutputStream; +import java.lang.classfile.ClassFile; +import java.lang.classfile.ClassModel; +import java.lang.classfile.ClassTransform; +import java.lang.classfile.MethodBuilder; +import java.lang.classfile.MethodElement; +import java.lang.classfile.MethodTransform; +import java.lang.classfile.attribute.MethodParametersAttribute; +import java.lang.classfile.attribute.RuntimeInvisibleParameterAnnotationsAttribute; +import java.lang.classfile.attribute.RuntimeVisibleParameterAnnotationsAttribute; +import java.lang.classfile.attribute.SignatureAttribute; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; +import javax.annotation.processing.AbstractProcessor; +import javax.annotation.processing.RoundEnvironment; +import javax.annotation.processing.SupportedAnnotationTypes; +import javax.lang.model.SourceVersion; +import javax.lang.model.element.ExecutableElement; +import javax.lang.model.element.TypeElement; +import javax.lang.model.element.VariableElement; +import javax.lang.model.util.ElementFilter; + +import toolbox.TestRunner; +import toolbox.JavacTask; +import toolbox.Task; +import toolbox.ToolBox; + +public class ParameterAnnotations extends TestRunner { + + ToolBox tb; + + public static void main(String... args) throws Exception { + new ParameterAnnotations().runTests(); + } + + ParameterAnnotations() { + super(System.err); + tb = new ToolBox(); + } + + public void runTests() throws Exception { + runTests(m -> new Object[] { Paths.get(m.getName()) }); + } + + @Test + public void testEnum(Path base) throws Exception { + //not parameterized: + doTest(base, + """ + import java.lang.annotation.*; + public enum E { + A(0); + E(@Visible @Invisible long i) {} + } + @Retention(RetentionPolicy.RUNTIME) + @interface Visible {} + @interface Invisible {} + """, + "E", + MethodTransform.ACCEPT_ALL, + "@Invisible @Visible long"); + //parameterized: + doTest(base, + """ + import java.lang.annotation.*; + public enum E { + A(0); + E(@Visible @Invisible long i) {} + } + @Retention(RetentionPolicy.RUNTIME) + @interface Visible {} + @interface Invisible {} + """, + "E", + MethodTransform.ACCEPT_ALL, + "@Invisible @Visible long"); + //not parameterized, and no Signature attribute: + doTest(base, + """ + import java.lang.annotation.*; + public enum E { + A(0); + E(@Visible @Invisible long i) {} + } + @Retention(RetentionPolicy.RUNTIME) + @interface Visible {} + @interface Invisible {} + """, + "E", + NO_SIGNATURE, + "java.lang.String, int, @Invisible @Visible long"); + //not parameterized, and no Signature and MethodParameters attribute: + doTest(base, + """ + import java.lang.annotation.*; + public enum E { + A(0); + E(@Visible @Invisible long i) {} + } + @Retention(RetentionPolicy.RUNTIME) + @interface Visible {} + @interface Invisible {} + """, + "E", + NO_SIGNATURE_NO_METHOD_PARAMETERS, + "java.lang.String, int, @Invisible @Visible long"); + } + + @Test + public void testInnerClass(Path base) throws Exception { + doTest(base, + """ + import java.lang.annotation.*; + public class T { + public class I { + public I(@Visible @Invisible long l) {} + public String toString() { + return T.this.toString(); //force outer this capture + } + } + } + @Retention(RetentionPolicy.RUNTIME) + @interface Visible {} + @interface Invisible {} + """, + "T$I", + MethodTransform.ACCEPT_ALL, + "@Invisible @Visible long"); + doTest(base, + """ + import java.lang.annotation.*; + public class T { + public class I { + public I(@Visible @Invisible long l) {} + public String toString() { + return T.this.toString(); //force outer this capture + } + } + } + @Retention(RetentionPolicy.RUNTIME) + @interface Visible {} + @interface Invisible {} + """, + "T$I", + MethodTransform.ACCEPT_ALL, + "@Invisible @Visible long"); + doTest(base, + """ + import java.lang.annotation.*; + public class T { + public class I { + public I(@Visible @Invisible long l) {} + public String toString() { + return T.this.toString(); //force outer this capture + } + } + } + @Retention(RetentionPolicy.RUNTIME) + @interface Visible {} + @interface Invisible {} + """, + "T$I", + NO_SIGNATURE, + "@Invisible @Visible long"); + doTest(base, + """ + import java.lang.annotation.*; + public class T { + public class I { + public I(@Visible @Invisible long l) {} + public String toString() { + return T.this.toString(); //force outer this capture + } + } + } + @Retention(RetentionPolicy.RUNTIME) + @interface Visible {} + @interface Invisible {} + """, + "T$I", + NO_SIGNATURE_NO_METHOD_PARAMETERS, + "@Invisible @Visible long"); + } + + @Test + public void testCapturingLocal(Path base) throws Exception { + doTest(base, + """ + import java.lang.annotation.*; + public class T { + public void test(int i) { + class I { + public I(@Visible @Invisible long l) {} + public String toString() { + return T.this.toString() + i; //force outer this capture + } + } + } + } + @Retention(RetentionPolicy.RUNTIME) + @interface Visible {} + @interface Invisible {} + """, + "T$1I", + MethodTransform.ACCEPT_ALL, + "@Invisible @Visible long"); + doTest(base, + """ + import java.lang.annotation.*; + public class T { + public void test(int i) { + class I { + public I(@Visible @Invisible long l) {} + public String toString() { + return T.this.toString() + i; //force outer this capture + } + } + } + } + @Retention(RetentionPolicy.RUNTIME) + @interface Visible {} + @interface Invisible {} + """, + "T$1I", + MethodTransform.ACCEPT_ALL, + "@Invisible @Visible long"); + doTest(base, + """ + import java.lang.annotation.*; + public class T { + public void test(int i) { + class I { + public I(@Visible @Invisible long l) {} + public String toString() { + return T.this.toString() + i; //force outer this capture + } + } + } + } + @Retention(RetentionPolicy.RUNTIME) + @interface Visible {} + @interface Invisible {} + """, + "T$1I", + NO_SIGNATURE, + "T, @Invisible @Visible long, int"); + doTest(base, + """ + import java.lang.annotation.*; + public class T { + public void test(int i) { + class I { + public I(@Visible @Invisible long l) {} + public String toString() { + return T.this.toString() + i; //force outer this capture + } + } + } + } + @Retention(RetentionPolicy.RUNTIME) + @interface Visible {} + @interface Invisible {} + """, + "T$1I", + NO_SIGNATURE_NO_METHOD_PARAMETERS, + "T, @Invisible @Visible long, int"); + doTest(base, + """ + import java.lang.annotation.*; + public class T { + { + int i = 0; + class I { + public I(@Visible @Invisible long l) {} + public String toString() { + return T.this.toString() + i; //force outer this capture + } + } + } + } + @Retention(RetentionPolicy.RUNTIME) + @interface Visible {} + @interface Invisible {} + """, + "T$1I", + MethodTransform.ACCEPT_ALL, + "@Invisible @Visible long"); + doTest(base, + """ + import java.lang.annotation.*; + public class T { + { + int i = 0; + class I { + public I(@Visible @Invisible long l) {} + public String toString() { + return T.this.toString() + i; //force outer this capture + } + } + } + } + @Retention(RetentionPolicy.RUNTIME) + @interface Visible {} + @interface Invisible {} + """, + "T$1I", + MethodTransform.ACCEPT_ALL, + "@Invisible @Visible long"); + doTest(base, + """ + import java.lang.annotation.*; + public class T { + { + int i = 0; + class I { + public I(@Visible @Invisible long l) {} + public String toString() { + return T.this.toString() + i; //force outer this capture + } + } + } + } + @Retention(RetentionPolicy.RUNTIME) + @interface Visible {} + @interface Invisible {} + """, + "T$1I", + NO_SIGNATURE, + "T, @Invisible @Visible long, int"); + doTest(base, + """ + import java.lang.annotation.*; + public class T { + { + int i = 0; + class I { + public I(@Visible @Invisible long l) {} + public String toString() { + return T.this.toString() + i; //force outer this capture + } + } + } + } + @Retention(RetentionPolicy.RUNTIME) + @interface Visible {} + @interface Invisible {} + """, + "T$1I", + NO_SIGNATURE_NO_METHOD_PARAMETERS, + "T, @Invisible @Visible long, int"); + } + + @Test + public void testSyntheticTests(Path base) throws Exception { + //Signature attribute will defined one parameter, but the + //Runtime(In)VisibleParameterAnnotations will define 3 parameters: + doTest(base, + """ + import java.lang.annotation.*; + public class T { + public void test(int i) { + class I { + public I(@Visible @Invisible long l) {} + public String toString() { + return T.this.toString() + i; //force outer this capture + } + } + } + } + @Retention(RetentionPolicy.RUNTIME) + @interface Visible {} + @interface Invisible {} + """, + "T$1I", + new MethodTransform() { + @Override + public void accept(MethodBuilder builder, MethodElement element) { + if (element instanceof RuntimeInvisibleParameterAnnotationsAttribute annos) { + assert annos.parameterAnnotations().size() == 1; + builder.accept(RuntimeInvisibleParameterAnnotationsAttribute.of(List.of(List.of(), annos.parameterAnnotations().get(0), List.of()))); + } else if (element instanceof RuntimeVisibleParameterAnnotationsAttribute annos) { + assert annos.parameterAnnotations().size() == 1; + builder.accept(RuntimeVisibleParameterAnnotationsAttribute.of(List.of(List.of(), annos.parameterAnnotations().get(0), List.of()))); + } else { + builder.accept(element); + } + } + }, + "@Invisible @Visible long"); + //no Signature attribute, no synthetic parameters, + //but less entries in Runtime(In)VisibleParameterAnnotations than parameters + //no way to map anything: + doTest(base, + """ + import java.lang.annotation.*; + public class T { + public T(int i, @Visible @Invisible long l, String s) {} + } + @Retention(RetentionPolicy.RUNTIME) + @interface Visible {} + @interface Invisible {} + """, + "T", + new MethodTransform() { + @Override + public void accept(MethodBuilder builder, MethodElement element) { + if (element instanceof RuntimeInvisibleParameterAnnotationsAttribute annos) { + assert annos.parameterAnnotations().size() == 3; + builder.accept(RuntimeInvisibleParameterAnnotationsAttribute.of(List.of(annos.parameterAnnotations().get(1)))); + } else if (element instanceof RuntimeVisibleParameterAnnotationsAttribute annos) { + assert annos.parameterAnnotations().size() == 3; + builder.accept(RuntimeVisibleParameterAnnotationsAttribute.of(List.of(annos.parameterAnnotations().get(1)))); + } else { + builder.accept(element); + } + } + }, + "int, long, java.lang.String", + "- compiler.warn.runtime.invisible.parameter.annotations: T.class", + "1 warning"); + //no Signature attribute, no synthetic parameters, + //but more entries in Runtime(In)VisibleParameterAnnotations than parameters + //no way to map anything: + doTest(base, + """ + import java.lang.annotation.*; + public class T { + public T(@Visible @Invisible long l) {} + } + @Retention(RetentionPolicy.RUNTIME) + @interface Visible {} + @interface Invisible {} + """, + "T", + new MethodTransform() { + @Override + public void accept(MethodBuilder builder, MethodElement element) { + if (element instanceof RuntimeInvisibleParameterAnnotationsAttribute annos) { + assert annos.parameterAnnotations().size() == 1; + builder.accept(RuntimeInvisibleParameterAnnotationsAttribute.of(List.of(List.of(), annos.parameterAnnotations().get(0), List.of()))); + } else if (element instanceof RuntimeVisibleParameterAnnotationsAttribute annos) { + assert annos.parameterAnnotations().size() == 1; + builder.accept(RuntimeVisibleParameterAnnotationsAttribute.of(List.of(List.of(), annos.parameterAnnotations().get(0), List.of()))); + } else { + builder.accept(element); + } + } + }, + "long", + "- compiler.warn.runtime.invisible.parameter.annotations: T.class", + "1 warning"); + //mismatched lengths on RuntimeVisibleParameterAnnotations and + //RuntimeInvisibleParameterAnnotations: + doTest(base, + """ + import java.lang.annotation.*; + public class T { + public T(@Visible @Invisible long l) {} + } + @Retention(RetentionPolicy.RUNTIME) + @interface Visible {} + @interface Invisible {} + """, + "T", + new MethodTransform() { + @Override + public void accept(MethodBuilder builder, MethodElement element) { + if (element instanceof RuntimeInvisibleParameterAnnotationsAttribute annos) { + assert annos.parameterAnnotations().size() == 1; + builder.accept(annos); //keep intact + } else if (element instanceof RuntimeVisibleParameterAnnotationsAttribute annos) { + assert annos.parameterAnnotations().size() == 1; + builder.accept(RuntimeVisibleParameterAnnotationsAttribute.of(List.of(List.of(), annos.parameterAnnotations().get(0), List.of()))); + } else { + builder.accept(element); + } + } + }, + "long", + "- compiler.warn.runtime.visible.invisible.param.annotations.mismatch: T.class", + "1 warning"); + } + + @Test + public void testRecord(Path base) throws Exception { + //implicit constructor: + doTest(base, + """ + import java.lang.annotation.*; + public record R(int i, @Visible @Invisible long l, String s) { + } + @Retention(RetentionPolicy.RUNTIME) + @interface Visible {} + @interface Invisible {} + """, + "R", + MethodTransform.ACCEPT_ALL, + "int, @Invisible @Visible long, java.lang.String"); + doTest(base, + """ + import java.lang.annotation.*; + public record R(int i, @Visible @Invisible long l, String s) { + } + @Retention(RetentionPolicy.RUNTIME) + @interface Visible {} + @interface Invisible {} + """, + "R", + NO_SIGNATURE, + "int, @Invisible @Visible long, java.lang.String"); + doTest(base, + """ + import java.lang.annotation.*; + public record R(int i, @Visible @Invisible long l, String s) { + } + @Retention(RetentionPolicy.RUNTIME) + @interface Visible {} + @interface Invisible {} + """, + "R", + NO_SIGNATURE_NO_METHOD_PARAMETERS, + "int, @Invisible @Visible long, java.lang.String"); + //compact constructor: + doTest(base, + """ + import java.lang.annotation.*; + public record R(int i, @Visible @Invisible long l, String s) { + public R {} + } + @Retention(RetentionPolicy.RUNTIME) + @interface Visible {} + @interface Invisible {} + """, + "R", + MethodTransform.ACCEPT_ALL, + "int, @Invisible @Visible long, java.lang.String"); + doTest(base, + """ + import java.lang.annotation.*; + public record R(int i, @Visible @Invisible long l, String s) { + public R {} + } + @Retention(RetentionPolicy.RUNTIME) + @interface Visible {} + @interface Invisible {} + """, + "R", + NO_SIGNATURE, + "int, @Invisible @Visible long, java.lang.String"); + doTest(base, + """ + import java.lang.annotation.*; + public record R(int i, @Visible @Invisible long l, String s) { + public R {} + } + @Retention(RetentionPolicy.RUNTIME) + @interface Visible {} + @interface Invisible {} + """, + "R", + NO_SIGNATURE_NO_METHOD_PARAMETERS, + "int, @Invisible @Visible long, java.lang.String"); + } + + private MethodTransform NO_SIGNATURE = + MethodTransform.dropping(element -> element instanceof SignatureAttribute); + + private MethodTransform NO_SIGNATURE_NO_METHOD_PARAMETERS = + MethodTransform.dropping(element -> element instanceof SignatureAttribute || + element instanceof MethodParametersAttribute); + + private void doTest(Path base, String code, String binaryNameToCheck, + MethodTransform changeConstructor, String expectedOutput, + String... expectedDiagnostics) throws Exception { + Path current = base.resolve("."); + Path src = current.resolve("src"); + Path classes = current.resolve("classes"); + tb.writeJavaFiles(src, code); + + Files.createDirectories(classes); + + new JavacTask(tb) + .outdir(classes) + .files(tb.findJavaFiles(src)) + .run(Task.Expect.SUCCESS) + .writeAll(); + + Path classfile = classes.resolve(binaryNameToCheck + ".class"); + ClassFile cf = ClassFile.of(); + + ClassModel model = cf.parse(classfile); + + byte[] newClassFile = cf.transformClass(model, + ClassTransform.transformingMethods(m -> m.methodName() + .equalsString(""), + changeConstructor)); + + try (OutputStream out = Files.newOutputStream(classfile)) { + out.write(newClassFile); + } + + Task.Result result = new JavacTask(tb) + .options("-classpath", classes.toString(), + "-processor", TestAP.class.getName(), + "-XDrawDiagnostics", + "-Xlint:classfile") + .outdir(classes) + .classes(binaryNameToCheck) + .run(Task.Expect.SUCCESS) + .writeAll(); + List out = result.getOutputLines(Task.OutputKind.STDOUT); + if (!out.equals(List.of(expectedOutput))) { + throw new AssertionError("Expected: " + List.of(expectedOutput) + ", but got: " + out); + } + List diagnostics = + new ArrayList<>(result.getOutputLines(Task.OutputKind.DIRECT)); + diagnostics.remove(""); + if (!diagnostics.equals(List.of(expectedDiagnostics))) { + throw new AssertionError("Expected: " + List.of(expectedDiagnostics) + ", but got: " + diagnostics); + } + } + + @SupportedAnnotationTypes("*") + public static final class TestAP extends AbstractProcessor { + + @Override + public boolean process(Set annotations, RoundEnvironment roundEnv) { + for (TypeElement clazz : ElementFilter.typesIn(roundEnv.getRootElements())) { + for (ExecutableElement el : ElementFilter.constructorsIn(clazz.getEnclosedElements())) { + String sep = ""; + + for (VariableElement p : el.getParameters()) { + System.out.print(sep); + if (!p.getAnnotationMirrors().isEmpty()) { + System.out.print(p.getAnnotationMirrors() + .stream() + .map(m -> m.toString()) + .collect(Collectors.joining(" "))); + System.out.print(" "); + } + System.out.print(p.asType()); + sep = ", "; + } + + System.out.println(); + } + } + + return false; + } + + @Override + public SourceVersion getSupportedSourceVersion() { + return SourceVersion.latest(); + } + + } +} diff --git a/test/langtools/tools/javac/classfiles/attributes/EnclosingMethod/EnclosingMethodTest.java b/test/langtools/tools/javac/classfiles/attributes/EnclosingMethod/EnclosingMethodTest.java index b555014bebe..f15771840f5 100644 --- a/test/langtools/tools/javac/classfiles/attributes/EnclosingMethod/EnclosingMethodTest.java +++ b/test/langtools/tools/javac/classfiles/attributes/EnclosingMethod/EnclosingMethodTest.java @@ -245,7 +245,6 @@ public class EnclosingMethodTest extends TestResult { // anonymous and local classes in lambda @ExpectedEnclosingMethod( info = "EnclosingLambda in EnclosingMethodTest", - enclosingMethod = "", enclosingClazz = EnclosingMethodTest.class ) class EnclosingLambda { @@ -325,7 +324,6 @@ public class EnclosingMethodTest extends TestResult { // anonymous and local classes in lambda @ExpectedEnclosingMethod( info = "EnclosingLambda in notEnclosing01", - enclosingMethod = "", enclosingClazz = notEnclosing01.class ) class EnclosingLambda { @@ -382,7 +380,6 @@ public class EnclosingMethodTest extends TestResult { // anonymous and local classes in lambda @ExpectedEnclosingMethod( info = "EnclosingLambda in notEnclosing02", - enclosingMethod = "", enclosingClazz = notEnclosing02.class ) class EnclosingLambda { @@ -460,7 +457,6 @@ public class EnclosingMethodTest extends TestResult { // anonymous and local classes in lambda @ExpectedEnclosingMethod( info = "EnclosingLambda in notEnclosing03", - enclosingMethod = "", enclosingClazz = notEnclosing03.class ) class EnclosingLambda { @@ -517,7 +513,6 @@ public class EnclosingMethodTest extends TestResult { // anonymous and local classes in lambda @ExpectedEnclosingMethod( info = "EnclosingLambda in notEnclosing04", - enclosingMethod = "", enclosingClazz = notEnclosing04.class ) class EnclosingLambda { diff --git a/test/langtools/tools/javac/diags/examples.not-yet.txt b/test/langtools/tools/javac/diags/examples.not-yet.txt index b2603338509..329e716a780 100644 --- a/test/langtools/tools/javac/diags/examples.not-yet.txt +++ b/test/langtools/tools/javac/diags/examples.not-yet.txt @@ -55,7 +55,8 @@ compiler.misc.bad.constant.range # bad class file compiler.misc.bad.constant.value # bad class file compiler.misc.bad.enclosing.class # bad class file compiler.misc.bad.enclosing.method # bad class file -compiler.misc.bad.runtime.invisible.param.annotations # bad class file +compiler.warn.runtime.invisible.parameter.annotations # bad class file +compiler.warn.runtime.visible.invisible.param.annotations.mismatch # bad class file compiler.misc.bad.signature # bad class file compiler.misc.bad.requires.flag # bad class file compiler.misc.bad.utf8.byte.sequence.at # bad class file diff --git a/test/langtools/tools/javac/doctree/DocCommentTester.java b/test/langtools/tools/javac/doctree/DocCommentTester.java index f14dde2e567..d418005745a 100644 --- a/test/langtools/tools/javac/doctree/DocCommentTester.java +++ b/test/langtools/tools/javac/doctree/DocCommentTester.java @@ -1043,8 +1043,9 @@ public class DocCommentTester { .replaceAll("(\\{@value\\s+[^}]+)\\s+(})", "$1$2"); } + // See comment in MarkdownTest for explanation of dummy and Override String normalizeFragment(String s) { - return s.replaceAll("\n[ \t]+@(?!([@*]|dummy))", "\n@"); + return s.replaceAll("\n[ \t]+@(?!([@*]|(dummy|Override)))", "\n@"); } int copyLiteral(String s, int start, StringBuilder sb) { diff --git a/test/langtools/tools/javac/doctree/MarkdownTest.java b/test/langtools/tools/javac/doctree/MarkdownTest.java index 8da9e6ed44c..3ec23076db9 100644 --- a/test/langtools/tools/javac/doctree/MarkdownTest.java +++ b/test/langtools/tools/javac/doctree/MarkdownTest.java @@ -40,6 +40,7 @@ * In the tests for code spans and code blocks, "@dummy" is used as a dummy inline * or block tag to verify that it is skipped as part of the code span or code block. * In other words, "@dummy" should appear as a literal part of the Markdown content. + * ("@Override" is also treated the same way, as a commonly found annotation.) * Conversely, standard tags are used to verify that a fragment of text is not being * skipped as a code span or code block. In other words, they should be recognized as tags * and not skipped as part of any Markdown content. @@ -409,6 +410,32 @@ DocComment[DOC_COMMENT, pos:0 RawText[MARKDOWN, pos:85, .] block tags: empty ] +*/ + + /// Indented Code Block + /// Lorum ipsum. + void indentedCodeBlock_leading() { } +/* +DocComment[DOC_COMMENT, pos:0 + firstSentence: empty + body: 1 + RawText[MARKDOWN, pos:0, ____Indented_Code_Block|Lorum_ipsum.] + block tags: empty +] +*/ + + /// Lorum ipsum. + /// + /// Indented Code Block + void indentedCodeBlock_trailing() { } +/* +DocComment[DOC_COMMENT, pos:0 + firstSentence: 1 + RawText[MARKDOWN, pos:0, Lorum_ipsum.] + body: 1 + RawText[MARKDOWN, pos:18, Indented_Code_Block] + block tags: empty +] */ ///123. @@ -613,5 +640,24 @@ DocComment[DOC_COMMENT, pos:0 ] */ +// The following test case is derived from the test case in JDK-8338525. + + /// @Override + /// void m() { } + /// + /// Plain text + /// + /// @Override + /// void m() { } + void leadingTrailingCodeBlocksWithAnnos() { } +/* +DocComment[DOC_COMMENT, pos:0 + firstSentence: empty + body: 1 + RawText[MARKDOWN, pos:0, ____@Override|____void_m()_{_}||...||____@Override|____void_m()_{_}] + block tags: empty +] +*/ + } diff --git a/test/langtools/tools/javac/generics/ParametricException.java b/test/langtools/tools/javac/generics/parametricException/ParametricException.java similarity index 100% rename from test/langtools/tools/javac/generics/ParametricException.java rename to test/langtools/tools/javac/generics/parametricException/ParametricException.java diff --git a/test/langtools/tools/javac/lambda/CaptureVarOrder.java b/test/langtools/tools/javac/lambda/CaptureVarOrder.java new file mode 100644 index 00000000000..0bfa061cb4f --- /dev/null +++ b/test/langtools/tools/javac/lambda/CaptureVarOrder.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8336492 + * @summary Regression in lambda serialization + */ + +public class CaptureVarOrder { + static Object m(String s, int i, Object o) { + return new Object() { + final byte B = 0; + void g() { System.out.println(s + i + B + o); } + }; + } + + static Runnable r(String s, int i, Object o) { + final byte B = 0; + return () -> System.out.println(s + i + B + o); + } + + public static void main(String[] args) throws ReflectiveOperationException { + CaptureVarOrder.class.getDeclaredMethod("lambda$r$0", String.class, int.class, Object.class); + m("", 1, null).getClass().getDeclaredConstructor(String.class, int.class, Object.class); + } +} diff --git a/test/langtools/tools/javac/lambda/SerializedLambdaInLocalClass.java b/test/langtools/tools/javac/lambda/SerializedLambdaInLocalClass.java new file mode 100644 index 00000000000..c015182f449 --- /dev/null +++ b/test/langtools/tools/javac/lambda/SerializedLambdaInLocalClass.java @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8336492 + * @summary Regression in lambda serialization + */ + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; +import java.util.function.*; + +public class SerializedLambdaInLocalClass { + + public static void main(String[] args) { + SerializedLambdaInLocalClass s = new SerializedLambdaInLocalClass(); + s.test(s::f_lambda_in_anon); + s.test(s::f_lambda_in_local); + s.test(s::f_lambda_in_lambda); + } + + void test(IntFunction> fSupplier) { + try { + F f = fSupplier.apply(42).get(); + var baos = new ByteArrayOutputStream(); + // write + try (var oos = new ObjectOutputStream(baos)) { + oos.writeObject(f); + } + byte[] bytes = baos.toByteArray(); + var bais = new ByteArrayInputStream(bytes); + // read + try (var ois = new ObjectInputStream(bais)) { + F f2 = (F)ois.readObject(); + if (f2.getValue() != f.getValue()) { + throw new AssertionError(String.format("Found: %d, expected %d", f2.getValue(), f.getValue())); + } + } + } catch (IOException | ClassNotFoundException ex) { + throw new AssertionError(ex); + } + } + + interface F extends Serializable { + int getValue(); + } + + Supplier f_lambda_in_anon(int x) { + return new Supplier() { + @Override + public F get() { + return () -> x; + } + }; + } + + Supplier f_lambda_in_local(int x) { + class FSupplier implements Supplier { + @Override + public F get() { + return () -> x; + } + } + return new FSupplier(); + } + + Supplier f_lambda_in_lambda(int x) { + return () -> () -> x; + } +} diff --git a/test/langtools/tools/javac/processing/model/type/BasicAnnoTests.java b/test/langtools/tools/javac/processing/model/type/BasicAnnoTests.java index acd91eac8c7..904e4e78cad 100644 --- a/test/langtools/tools/javac/processing/model/type/BasicAnnoTests.java +++ b/test/langtools/tools/javac/processing/model/type/BasicAnnoTests.java @@ -41,6 +41,8 @@ import java.io.Serializable; import java.lang.annotation.Annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Repeatable; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import java.lang.reflect.Method; import java.util.ArrayList; @@ -93,13 +95,15 @@ public class BasicAnnoTests extends JavacTestingAbstractProcessor { private static final Map> nameToAnnotation = Map.ofEntries(new NameToAnnotationEntry("java.lang.Override", Override.class), new NameToAnnotationEntry("java.lang.annotation.Repeatable", Repeatable.class), + new NameToAnnotationEntry("java.lang.annotation.Retention", Target.class), new NameToAnnotationEntry("java.lang.annotation.Target", Target.class), new NameToAnnotationEntry("BasicAnnoTests.Test", BasicAnnoTests.Test.class), new NameToAnnotationEntry("BasicAnnoTests.Tests",BasicAnnoTests.Tests.class), new NameToAnnotationEntry("BasicAnnoTests.TA", BasicAnnoTests.TA.class), new NameToAnnotationEntry("BasicAnnoTests.TB", BasicAnnoTests.TB.class), new NameToAnnotationEntry("BasicAnnoTests.TC", BasicAnnoTests.TC.class), - new NameToAnnotationEntry("BasicAnnoTests.TCs", BasicAnnoTests.TCs.class)); + new NameToAnnotationEntry("BasicAnnoTests.TCs", BasicAnnoTests.TCs.class), + new NameToAnnotationEntry("BasicAnnoTests.TD", BasicAnnoTests.TD.class)); static class NameToAnnotationEntry extends AbstractMap.SimpleEntry> { public NameToAnnotationEntry(String key, Class entry) { @@ -520,6 +524,12 @@ public class BasicAnnoTests extends JavacTestingAbstractProcessor { TC[] value(); } + @Target(ElementType.TYPE_USE) + @Retention(RetentionPolicy.RUNTIME) + public @interface TD { + int value(); + } + // Test cases // TODO: add more cases for arrays @@ -657,6 +667,10 @@ public class BasicAnnoTests extends JavacTestingAbstractProcessor { @Test(posn=1, annoType=TA.class, expect="23") public Set<@TA(23) ? super Object> f9; + @Test(posn=0, annoType=TA.class, expect="1") + @Test(posn=0, annoType=TD.class, expect="2") + public @TA(1) @TD(2) int f10; + // Test type use annotations on uses of type variables @Test(posn=6, annoType = TA.class, expect = "25") @Test(posn=6, annoType = TB.class, expect = "26") diff --git a/test/langtools/tools/javac/processing/model/util/types/TestInvalidInputs.java b/test/langtools/tools/javac/processing/model/util/types/TestInvalidInputs.java new file mode 100644 index 00000000000..47b11bbbba8 --- /dev/null +++ b/test/langtools/tools/javac/processing/model/util/types/TestInvalidInputs.java @@ -0,0 +1,230 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8340721 8341483 + * @summary Test invalid inputs to javax.lang.model.util.Types methods + * @library /tools/javac/lib + * @modules java.compiler + * @build JavacTestingAbstractProcessor TestInvalidInputs + * @compile -processor TestInvalidInputs -proc:only TestInvalidInputs.java + */ + +import java.util.*; +import javax.annotation.processing.*; +import javax.lang.model.element.*; +import javax.lang.model.type.*; +import javax.lang.model.util.*; + +/** + * Test if exceptions are thrown for invalid arguments as expected. + */ +public class TestInvalidInputs extends JavacTestingAbstractProcessor { + + // Reference types are ArrayType, DeclaredType, ErrorType, NullType, and TypeVariable + + private TypeMirror objectType; // Notable DeclaredType + private TypeMirror stringType; // Another notable DeclaredType + private ArrayType arrayType; + // private ErrorType errorType; // skip for now + private ExecutableType executableType; + private IntersectionType intersectionType; + + private NoType noTypeVoid; + private NoType noTypeNone; + private NoType noTypePackage; + private NoType noTypeModule; + + private NullType nullType; + private PrimitiveType primitiveType; + private UnionType unionType; + private WildcardType wildcardType; + + /** + * Check expected behavior on classes and packages. + */ + public boolean process(Set annotations, + RoundEnvironment roundEnv) { + if (!roundEnv.processingOver()) { + initializeTypes(); + + // isSubType + // isAssignable + // contains + // directSupertypes + testUnboxedType(); + // capture + // getPrimitiveType + // getNoType + testGetArrayType(); + testGetWildcardType(); + // getDeclaredType + // getDeclaredType (overload) + // asMemberOf + } + return true; + } + + void initializeTypes() { + objectType = elements.getTypeElement("java.lang.Object").asType(); + stringType = elements.getTypeElement("java.lang.String").asType(); + + arrayType = types.getArrayType(objectType); // Object[] + executableType = extractExecutableType(); + intersectionType = extractIntersectionType(); + + noTypeVoid = types.getNoType(TypeKind.VOID); + noTypeNone = types.getNoType(TypeKind.NONE); + noTypePackage = (NoType)(elements.getPackageElement("java.lang").asType()); + noTypeModule = (NoType)(elements.getModuleElement("java.base").asType()); + + nullType = types.getNullType(); + primitiveType = types.getPrimitiveType(TypeKind.DOUBLE); + // unionType; // more work here + wildcardType = types.getWildcardType(objectType, null); + + return; + } + + ExecutableType extractExecutableType() { + var typeElement = elements.getTypeElement("TestInvalidInputs.InvalidInputsHost"); + for (var method : ElementFilter.methodsIn(typeElement.getEnclosedElements())) { + if ("foo7".equals(method.getSimpleName().toString())) { + return (ExecutableType)method.asType(); + } + } + throw new RuntimeException("Expected method not found"); + } + + IntersectionType extractIntersectionType() { + var typeElement = elements.getTypeElement("TestInvalidInputs.InvalidInputsHost"); + for (var method : ElementFilter.methodsIn(typeElement.getEnclosedElements())) { + if ("foo9".equals(method.getSimpleName().toString())) { + return (IntersectionType) ((TypeVariable)method.getReturnType()).getUpperBound(); + } + } + throw new RuntimeException("Expected method not found"); + } + + /* + * Class to host inputs for testing. + */ + class InvalidInputsHost { + // Use a method to get an ExecutableType + public static String foo7(int arg) {return null;} + + // Type variable with intersection type + public static S foo9() {return null;} + } + + /** + * @throws IllegalArgumentException if the given type has no + * unboxing conversion, including for types that are not + * {@linkplain ReferenceType reference types} + */ + void testUnboxedType() { + // Only DeclaredType's for wrapper classes should have unboxing conversions defined. + + // Reference types are ArrayType, DeclaredType, ErrorType, NullType, TypeVariable + // non-reference: ExecutableType, IntersectionType, NoType, PrimitiveType, UnionType, WildcardType + var invalidInputs = + List.of(primitiveType, executableType, + objectType, stringType, arrayType, + intersectionType, /*unionType, */ + noTypeVoid, noTypeNone, noTypePackage, noTypeModule, + nullType, + wildcardType); + + for (TypeMirror tm : invalidInputs) { + try { + PrimitiveType pt = types.unboxedType(tm); + shouldNotReach(tm); + } catch(IllegalArgumentException iae) { + ; // Expected + } + } + return; + } + + private void shouldNotReach(TypeMirror tm) { + throw new RuntimeException("Should not reach " + tm + + " " + tm.getKind()); + } + + /** + * @throws IllegalArgumentException if bounds are not valid, + * including for types that are not {@linkplain ReferenceType + * reference types} + */ + void testGetWildcardType() { + // Reference types are ArrayType, DeclaredType, ErrorType, NullType, TypeVariable + // non-reference: ExecutableType, IntersectionType, NoType, PrimitiveType, UnionType, WildcardType + var invalidInputs = + List.of(primitiveType, executableType, + intersectionType, /*unionType, */ + noTypeVoid, noTypeNone, noTypePackage, noTypeModule, + nullType, + wildcardType); + + for (TypeMirror tm : invalidInputs) { + try { + WildcardType wc1 = types.getWildcardType(tm, null); + shouldNotReach(tm); + } catch(IllegalArgumentException iae) { + ; // Expected + } + + try { + WildcardType wc2 = types.getWildcardType(null, tm); + shouldNotReach(tm); + } catch(IllegalArgumentException iae) { + ; // Expected + } + } + return; + } + + /** + * @throws IllegalArgumentException if the component type is not valid for + * an array. All valid types are {@linkplain ReferenceType + * reference types} or {@linkplain PrimitiveType primitive types}. + * Invalid types include null, executable, package, module, and wildcard types. + */ + void testGetArrayType() { + var invalidInputs = + List.of(executableType, + noTypeVoid, noTypeNone, noTypePackage, noTypeModule, + nullType, + /*unionType, */ wildcardType); + + for (TypeMirror tm : invalidInputs) { + try { + ArrayType arrayType = types.getArrayType(tm); + shouldNotReach(tm); + } catch(IllegalArgumentException iae) { + ; // Expected + } + } + } +} diff --git a/test/langtools/tools/javac/resolve/MethodAmbiguityCrash1.java b/test/langtools/tools/javac/resolve/MethodAmbiguityCrash1.java new file mode 100644 index 00000000000..9e2b7e10080 --- /dev/null +++ b/test/langtools/tools/javac/resolve/MethodAmbiguityCrash1.java @@ -0,0 +1,23 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8337980 + * @summary Test compiler crash due to failure to resolve method ambiguity + * @compile/fail/ref=MethodAmbiguityCrash1.out -XDrawDiagnostics MethodAmbiguityCrash1.java + */ +public class MethodAmbiguityCrash1 { + + public interface A { + int op(); + } + + public abstract static class B { + abstract int op(); + } + + public abstract static class C extends B implements A { + + public static int test() { + return op(); // compile should fail here + } + } +} diff --git a/test/langtools/tools/javac/resolve/MethodAmbiguityCrash1.out b/test/langtools/tools/javac/resolve/MethodAmbiguityCrash1.out new file mode 100644 index 00000000000..ab94e965d59 --- /dev/null +++ b/test/langtools/tools/javac/resolve/MethodAmbiguityCrash1.out @@ -0,0 +1,2 @@ +MethodAmbiguityCrash1.java:20:20: compiler.err.non-static.cant.be.ref: kindname.method, op() +1 error diff --git a/test/langtools/tools/javac/resolve/MethodAmbiguityCrash2.java b/test/langtools/tools/javac/resolve/MethodAmbiguityCrash2.java new file mode 100644 index 00000000000..9886e91a7f3 --- /dev/null +++ b/test/langtools/tools/javac/resolve/MethodAmbiguityCrash2.java @@ -0,0 +1,26 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8337980 + * @summary Test compiler crash due to failure to resolve method ambiguity + * @compile/fail/ref=MethodAmbiguityCrash2.out -XDrawDiagnostics MethodAmbiguityCrash2.java + */ +public class MethodAmbiguityCrash2 { + + public interface A { + int op(); + } + + public abstract static class B { + public abstract int op(); + } + + public abstract static class C extends B implements A { + + public C(int x) { + } + + public C() { + this(op()); // compile should fail here + } + } +} diff --git a/test/langtools/tools/javac/resolve/MethodAmbiguityCrash2.out b/test/langtools/tools/javac/resolve/MethodAmbiguityCrash2.out new file mode 100644 index 00000000000..ace3ffce9cd --- /dev/null +++ b/test/langtools/tools/javac/resolve/MethodAmbiguityCrash2.out @@ -0,0 +1,2 @@ +MethodAmbiguityCrash2.java:23:18: compiler.err.cant.ref.before.ctor.called: op() +1 error diff --git a/test/langtools/tools/javac/tree/PrettyCharLiteral.java b/test/langtools/tools/javac/tree/PrettyCharLiteral.java new file mode 100644 index 00000000000..eced3209607 --- /dev/null +++ b/test/langtools/tools/javac/tree/PrettyCharLiteral.java @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2024, Google LLC. 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 8340568 + * @summary Incorrect escaping of single quotes when pretty-printing character literals + * @modules jdk.compiler/com.sun.tools.javac.api + * jdk.compiler/com.sun.tools.javac.file + * jdk.compiler/com.sun.tools.javac.tree + * jdk.compiler/com.sun.tools.javac.util + */ + +import com.sun.tools.javac.file.JavacFileManager; +import com.sun.tools.javac.tree.Pretty; +import com.sun.tools.javac.tree.TreeMaker; +import com.sun.tools.javac.util.Context; + +import java.io.IOException; +import java.io.StringWriter; + +public class PrettyCharLiteral { + public static void main(String... args) throws Exception { + new PrettyCharLiteral().run(); + } + + private final TreeMaker make; + + private PrettyCharLiteral() { + Context ctx = new Context(); + JavacFileManager.preRegister(ctx); + this.make = TreeMaker.instance(ctx); + } + + void run() throws Exception { + assertEquals( + prettyPrintLiteral('\''), + """ + '\\'' + """.trim()); + assertEquals( + prettyPrintLiteral('"'), + """ + '"' + """.trim()); + assertEquals( + prettyPrintLiteral("'"), + """ + "'" + """.trim()); + assertEquals( + prettyPrintLiteral("\""), + """ + "\\"" + """.trim()); + } + + private void assertEquals(String actual, String expected) { + if (!actual.equals(expected)) { + throw new AssertionError("expected: " + expected + ", actual: " + actual); + } + } + + private String prettyPrintLiteral(Object value) throws IOException { + StringWriter sw = new StringWriter(); + new Pretty(sw, true).printExpr(make.Literal(value)); + return sw.toString(); + } +} diff --git a/test/langtools/tools/javac/warnings/Serial.java b/test/langtools/tools/javac/warnings/Serial/Serial.java similarity index 100% rename from test/langtools/tools/javac/warnings/Serial.java rename to test/langtools/tools/javac/warnings/Serial/Serial.java diff --git a/test/langtools/tools/javac/warnings/Serial.out b/test/langtools/tools/javac/warnings/Serial/Serial.out similarity index 100% rename from test/langtools/tools/javac/warnings/Serial.out rename to test/langtools/tools/javac/warnings/Serial/Serial.out diff --git a/test/lib-test/jdk/test/lib/util/JarUtilsTest.java b/test/lib-test/jdk/test/lib/util/JarUtilsTest.java new file mode 100644 index 00000000000..eb9dced3256 --- /dev/null +++ b/test/lib-test/jdk/test/lib/util/JarUtilsTest.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* @test + * @bug 8309841 + * @summary Unit Test for a common Test API in jdk.test.lib.util.JarUtils + * @library /test/lib + */ + +import jdk.test.lib.Asserts; +import jdk.test.lib.util.JarUtils; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Set; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; +import java.util.stream.Collectors; + +public class JarUtilsTest { + public static void main(String[] args) throws Exception { + Files.createDirectory(Path.of("bx")); + JarUtils.createJarFile(Path.of("a.jar"), + Path.of("."), + Files.writeString(Path.of("a"), ""), + Files.writeString(Path.of("b1"), ""), + Files.writeString(Path.of("b2"), ""), + Files.writeString(Path.of("bx/x"), ""), + Files.writeString(Path.of("c"), ""), + Files.writeString(Path.of("e1"), ""), + Files.writeString(Path.of("e2"), "")); + checkContent("a", "b1", "b2", "bx/x", "c", "e1", "e2"); + + JarUtils.deleteEntries(Path.of("a.jar"), "a"); + checkContent("b1", "b2", "bx/x", "c", "e1", "e2"); + + // Note: b* covers everything starting with b, even bx/x + JarUtils.deleteEntries(Path.of("a.jar"), "b*"); + checkContent("c", "e1", "e2"); + + // d* does not match + JarUtils.deleteEntries(Path.of("a.jar"), "d*"); + checkContent("c", "e1", "e2"); + + // multiple patterns + JarUtils.deleteEntries(Path.of("a.jar"), "d*", "e*"); + checkContent("c"); + } + + static void checkContent(String... expected) throws IOException { + try (var jf = new JarFile("a.jar")) { + Asserts.assertEquals(Set.of(expected), + jf.stream().map(JarEntry::getName).collect(Collectors.toSet())); + } + } +} diff --git a/test/lib/jdk/test/lib/Container.java b/test/lib/jdk/test/lib/Container.java index e0ca4851e14..83fd265980f 100644 --- a/test/lib/jdk/test/lib/Container.java +++ b/test/lib/jdk/test/lib/Container.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2019, Red Hat Inc. + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,9 +24,9 @@ package jdk.test.lib; public class Container { - // Use this property to specify docker location on your system. + // Use this property to specify container runtime location (e.g. docker) on your system. // E.g.: "/usr/local/bin/docker". We define this constant here so - // that it can be used in VMProps as well which checks docker support + // that it can be used in VMProps as well which checks container support // via this command public static final String ENGINE_COMMAND = System.getProperty("jdk.test.container.command", "docker"); diff --git a/test/lib/jdk/test/lib/containers/systemd/SystemdRunOptions.java b/test/lib/jdk/test/lib/containers/systemd/SystemdRunOptions.java new file mode 100644 index 00000000000..5f5d513a8b2 --- /dev/null +++ b/test/lib/jdk/test/lib/containers/systemd/SystemdRunOptions.java @@ -0,0 +1,152 @@ +/* + * Copyright (c) 2024, Red Hat, Inc. + * 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. + */ + +package jdk.test.lib.containers.systemd; + +import static jdk.test.lib.Asserts.assertNotNull; + +import java.util.ArrayList; +import java.util.Collections; + + +// This class represents options for running java inside systemd slices +// in test environment. +public class SystemdRunOptions { + public ArrayList javaOpts = new ArrayList<>(); + public String classToRun; // class or "-version" + public ArrayList classParams = new ArrayList<>(); + public String memoryLimit; // used in slice for MemoryLimit property + public String cpuLimit; // used in slice for CPUQuota property + public String sliceName; // name of the slice (nests CPU in memory) + public String sliceDMemoryLimit; // used in jdk_internal.slice.d + public String sliceDCpuLimit; // used in jdk_internal.slice.d + + /** + * Convenience constructor for most common use cases in testing. + * @param classToRun a class to run, or "-version" + * @param javaOpts java options to use + * + * @return Default docker run options + */ + public SystemdRunOptions(String classToRun, String... javaOpts) { + this.classToRun = classToRun; + Collections.addAll(this.javaOpts, javaOpts); + this.sliceName = defaultSliceName(); + } + + private static String defaultSliceName() { + // Create a unique name for a systemd slice + // jtreg guarantees that test.name is unique among all concurrently executing + // tests. For example, if you have two test roots: + // + // $ find test -type f + // test/foo/TEST.ROOT + // test/foo/my/TestCase.java + // test/bar/TEST.ROOT + // test/bar/my/TestCase.java + // $ jtreg -concur:2 test/foo test/bar + // + // jtreg will first run all the tests under test/foo. When they are all finished, then + // jtreg will run all the tests under test/bar. So you will never have two concurrent + // test cases whose test.name is "my/TestCase.java" + String testname = System.getProperty("test.name"); + assertNotNull(testname, "must be set by jtreg"); + testname = testname.replace(".java", ""); + testname = testname.replace("/", "_"); + testname = testname.replace("\\", "_"); + testname = testname.replace("-", "_"); + + // Example: + // Memory: "test_containers_systemd_TestMemoryAwareness" + // CPU: "test_containers_systemd_TestMemoryAwareness-cpu" => derived + return testname; + } + + /** + * The memory limit set with a .slice file in the systemd + * config directory. + * + * @param memLimit The memory limit to set (e.g. 1000M). + * @return The run options. + */ + public SystemdRunOptions memoryLimit(String memLimit) { + this.memoryLimit = memLimit; + return this; + } + + /** + * The memory limit to set in the top-level jdk_internal.slice.d + * systemd config directory. + * + * @param memoryLimit The memory limit to set. + * @return The run options. + */ + public SystemdRunOptions sliceDMemoryLimit(String memoryLimit) { + this.sliceDMemoryLimit = memoryLimit; + return this; + } + + /** + * The CPU limit set with a .slice file in the systemd + * config directory. + * + * @param cpuLimit + * @return The run options. + */ + public SystemdRunOptions cpuLimit(String cpuLimit) { + this.cpuLimit = cpuLimit; + return this; + } + + /** + * The Cpu limit set in the top-level jdk_internal.slice.d + * systemd config directory. + * + * @param cpuLimit The CPU limit to set to. + * @return The run options. + */ + public SystemdRunOptions sliceDCpuLimit(String cpuLimit) { + this.sliceDCpuLimit = cpuLimit; + return this; + } + + public SystemdRunOptions sliceName(String name) { + this.sliceName = name; + return this; + } + + public SystemdRunOptions addJavaOpts(String... opts) { + Collections.addAll(javaOpts, opts); + return this; + } + + public SystemdRunOptions addClassOptions(String... opts) { + Collections.addAll(classParams,opts); + return this; + } + + public boolean hasSliceDLimit() { + return this.sliceDMemoryLimit != null || + this.sliceDCpuLimit != null; + } +} diff --git a/test/lib/jdk/test/lib/containers/systemd/SystemdTestUtils.java b/test/lib/jdk/test/lib/containers/systemd/SystemdTestUtils.java new file mode 100644 index 00000000000..9acff93aaca --- /dev/null +++ b/test/lib/jdk/test/lib/containers/systemd/SystemdTestUtils.java @@ -0,0 +1,376 @@ +/* + * Copyright (c) 2024, Red Hat, Inc. + * 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. + */ + +package jdk.test.lib.containers.systemd; + +import java.io.FileWriter; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.NoSuchFileException; +import java.nio.file.Path; +import java.nio.file.StandardOpenOption; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import jdk.internal.platform.Metrics; +import jdk.test.lib.Platform; +import jdk.test.lib.Utils; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.util.FileUtils; +import jtreg.SkippedException; + +public class SystemdTestUtils { + + private static final String CGROUPS_PROVIDER = Metrics.systemMetrics().getProvider(); + private static boolean CGROUPS_V2 = "cgroupv2".equals(CGROUPS_PROVIDER); + public static boolean RUN_AS_USER = !Platform.isRoot() && CGROUPS_V2; + private static final String SLICE_NAMESPACE_PREFIX = "jdk_internal"; + private static final String SLICE_D_MEM_CONFIG_FILE = "memory-limit.conf"; + private static final String SLICE_D_CPU_CONFIG_FILE = "cpu-limit.conf"; + private static final String USER_HOME = System.getProperty("user.home"); + private static final Path SYSTEMD_CONFIG_HOME_ROOT = Path.of("/", "etc", "systemd", "system"); + private static final Path SYSTEMD_CONFIG_HOME_USER = Path.of(USER_HOME, ".config", "systemd", "user"); + private static final Path SYSTEMD_CONFIG_HOME = Platform.isRoot() ? SYSTEMD_CONFIG_HOME_ROOT : SYSTEMD_CONFIG_HOME_USER; + + // Specifies how many lines to copy from child STDOUT to main test output. + // Having too many lines in the main test output will result + // in JT harness trimming the output, and can lead to loss of useful + // diagnostic information. + private static final int MAX_LINES_TO_COPY_FOR_CHILD_STDOUT = 100; + + public record ResultFiles(Path memory, Path cpu, Path sliceDotDDir) {} + + /** + * Create commonly used options with the class to be launched inside the + * systemd slice + * + * @param testClass The test class or {@code -version} + * @return The basic options. + */ + public static SystemdRunOptions newOpts(String testClass) { + return new SystemdRunOptions(testClass, + "-Xlog:os+container=trace", + "-cp", + Utils.TEST_CLASSES); + } + + /** + * Run Java inside a systemd slice with specified parameters and options. + * + * @param opts The systemd slice options when running java + * @return An OutputAnalyzer of the output of the command than ran. + * @throws Exception If something went wrong. + * @throws SkippedException If the test cannot be run (i.e. non-root user + * on cgroups v1). + */ + public static OutputAnalyzer buildAndRunSystemdJava(SystemdRunOptions opts) throws Exception, SkippedException { + if (!Platform.isRoot() && !CGROUPS_V2) { + throw new SkippedException("Systemd tests require root on cgroup v1. Test skipped!"); + } + ResultFiles files = SystemdTestUtils.buildSystemdSlices(opts); + + try { + return SystemdTestUtils.systemdRunJava(opts); + } finally { + cleanupFiles(files); + } + } + + private static void cleanupFiles(ResultFiles files) throws IOException { + try { + if (files.memory() != null) { + Files.delete(files.memory()); + } + if (files.cpu() != null) { + Files.delete(files.cpu()); + } + if (files.sliceDotDDir() != null) { + FileUtils.deleteFileTreeUnchecked(files.sliceDotDDir()); + } + } catch (NoSuchFileException e) { + // ignore + } + } + + private static OutputAnalyzer systemdRunJava(SystemdRunOptions opts) throws Exception { + return execute(buildJavaCommand(opts)); + } + + /** + * Create systemd slice files under /etc/systemd/system. + * + * The JDK will then run within that slice as provided by the SystemdRunOptions. + * + * @param runOpts The systemd slice options to use when running the test. + * @return The systemd slice files (for cleanup-purposes later). + * @throws Exception + */ + private static ResultFiles buildSystemdSlices(SystemdRunOptions runOpts) throws Exception { + String sliceName = sliceName(runOpts); + String sliceNameCpu = sliceNameCpu(runOpts); + + // Generate systemd slices for cpu/memory + String memorySliceContent = getMemorySlice(runOpts, sliceName); + String cpuSliceContent = getCpuSlice(runOpts, sliceName); + + // Ensure base directory exists + Files.createDirectories(SYSTEMD_CONFIG_HOME); + Path sliceDotDDir = null; + if (runOpts.hasSliceDLimit()) { + String dirName = String.format("%s.slice.d", SLICE_NAMESPACE_PREFIX); + sliceDotDDir = SYSTEMD_CONFIG_HOME.resolve(Path.of(dirName)); + // Using createDirectories since we only need to ensure the directory + // exists. Ignore it if already existent. + Files.createDirectories(sliceDotDDir); + + if (runOpts.sliceDMemoryLimit != null) { + Path memoryConfig = sliceDotDDir.resolve(Path.of(SLICE_D_MEM_CONFIG_FILE)); + Files.writeString(memoryConfig, + getMemoryDSliceContent(runOpts), + StandardOpenOption.TRUNCATE_EXISTING, + StandardOpenOption.CREATE); + } + if (runOpts.sliceDCpuLimit != null) { + Path cpuConfig = sliceDotDDir.resolve(Path.of(SLICE_D_CPU_CONFIG_FILE)); + Files.writeString(cpuConfig, + getCPUDSliceContent(runOpts), + StandardOpenOption.TRUNCATE_EXISTING, + StandardOpenOption.CREATE); + } + } + + Path memory, cpu; + try { + // memory slice + memory = SYSTEMD_CONFIG_HOME.resolve(Path.of(sliceFileName(sliceName))); + // cpu slice nested in memory + cpu = SYSTEMD_CONFIG_HOME.resolve(Path.of(sliceFileName(sliceNameCpu))); + Files.writeString(memory, memorySliceContent); + Files.writeString(cpu, cpuSliceContent); + } catch (IOException e) { + throw new AssertionError("Failed to write systemd slice files"); + } + + systemdDaemonReload(cpu, memory, sliceDotDDir); + + return new ResultFiles(memory, cpu, sliceDotDDir); + } + + private static String sliceName(SystemdRunOptions runOpts) { + // Slice name may include '-' which is a hierarchical slice indicator. + // Replace '-' with '_' to avoid side-effects. + return SLICE_NAMESPACE_PREFIX + "-" + runOpts.sliceName.replace("-", "_"); + } + + private static String sliceNameCpu(SystemdRunOptions runOpts) { + String slice = sliceName(runOpts); + return String.format("%s-cpu", slice); + } + + private static void systemdDaemonReload(Path cpu, Path memory, Path sliceDdir) throws Exception { + List daemonReload = systemCtl(); + daemonReload.add("daemon-reload"); + + if (execute(daemonReload).getExitValue() != 0) { + if (RUN_AS_USER) { + cleanupFiles(new ResultFiles(cpu, memory, sliceDdir)); + // When run as user the systemd user manager needs to be + // accessible and working. This is usually the case when + // connected via SSH or user login, but may not work for + // sessions set up via 'su ' or similar. + // In that case, 'systemctl --user status' usually doesn't + // work. There is no other option than skip the test. + String msg = "Service user@.service not properly configured. " + + "Skipping the test!"; + throw new SkippedException(msg); + } else { + throw new AssertionError("Failed to reload systemd daemon"); + } + } + } + + private static List systemCtl() { + return commandWithUser("systemctl"); + } + + /** + * 'baseCommand' or 'baseCommand --user' as list, depending on the cgroups + * version and running user. + * + * @return 'baseCommand' if we are the root user, 'systemctl --user' if + * the current user is non-root and we are on cgroups v2. Note: + * Cgroups v1 and non-root is not possible as tests are skipped then. + */ + private static List commandWithUser(String baseCommand) { + List command = new ArrayList<>(); + command.add(baseCommand); + if (RUN_AS_USER) { + command.add("--user"); + } + return command; + } + + private static String getCpuSlice(SystemdRunOptions runOpts, String sliceName) { + String basicSliceFormat = getBasicSliceFormat(); + return String.format(basicSliceFormat, sliceName, getCPUSliceContent(runOpts)); + } + + private static String getCPUSliceContent(SystemdRunOptions runOpts) { + String format = basicCPUContentFormat(); + return String.format(format, runOpts.cpuLimit); + } + + private static String getMemorySlice(SystemdRunOptions runOpts, String sliceName) { + String basicSliceFormat = getBasicSliceFormat(); + return String.format(basicSliceFormat, sliceName, getMemorySliceContent(runOpts)); + } + + private static String getMemoryDSliceContent(SystemdRunOptions runOpts) { + String format = "[Slice]\n" + basicMemoryContentFormat(); + return String.format(format, runOpts.sliceDMemoryLimit); + } + + private static String getCPUDSliceContent(SystemdRunOptions runOpts) { + String format = "[Slice]\n" + basicCPUContentFormat(); + return String.format(format, runOpts.sliceDCpuLimit); + } + + private static String basicCPUContentFormat() { + return """ + CPUAccounting=true + CPUQuota=%s + """; + } + + private static String basicMemoryContentFormat() { + return """ + MemoryAccounting=true + MemoryLimit=%s + """; + } + + private static String getMemorySliceContent(SystemdRunOptions runOpts) { + String format = basicMemoryContentFormat(); + + return String.format(format, runOpts.memoryLimit); + } + + private static String getBasicSliceFormat() { + return """ + [Unit] + Description=OpenJDK Tests Slice for %s + Before=slices.target + + [Slice] + %s + """; + } + + private static String sliceFileName(String sliceName) { + return String.format("%s.slice", sliceName); + } + + /** + * Build the java command to run inside a systemd slice + * + * @param SystemdRunOptions options for running the systemd slice test + * + * @return command + * @throws Exception + */ + private static List buildJavaCommand(SystemdRunOptions opts) throws Exception { + // systemd-run [--user] --slice .slice --scope + List javaCmd = systemdRun(); + javaCmd.add("--slice"); + javaCmd.add(sliceFileName(sliceNameCpu(opts))); + javaCmd.add("--scope"); + javaCmd.add(Path.of(Utils.TEST_JDK, "bin", "java").toString()); + javaCmd.addAll(opts.javaOpts); + javaCmd.add(opts.classToRun); + javaCmd.addAll(opts.classParams); + return javaCmd; + } + + private static List systemdRun() { + return commandWithUser("systemd-run"); + } + + /** + * Execute a specified command in a process, report diagnostic info. + * + * @param command to be executed + * @return The output from the process + * @throws Exception + */ + private static OutputAnalyzer execute(List command) throws Exception { + return execute(command.toArray(String[]::new)); + } + + /** + * Execute a specified command in a process, report diagnostic info. + * + * @param command to be executed + * @return The output from the process + * @throws Exception + */ + private static OutputAnalyzer execute(String... command) throws Exception { + ProcessBuilder pb = new ProcessBuilder(command); + System.out.println("[COMMAND]\n" + Utils.getCommandLine(pb)); + + Process p = pb.start(); + long pid = p.pid(); + OutputAnalyzer output = new OutputAnalyzer(p); + + int max = MAX_LINES_TO_COPY_FOR_CHILD_STDOUT; + String stdout = output.getStdout(); + String stdoutLimited = limitLines(stdout, max); + System.out.println("[STDERR]\n" + output.getStderr()); + System.out.println("[STDOUT]\n" + stdoutLimited); + if (stdout != stdoutLimited) { + System.out.printf("Child process STDOUT is limited to %d lines\n", + max); + } + + String stdoutLogFile = String.format("systemd-stdout-%d.log", pid); + writeOutputToFile(stdout, stdoutLogFile); + System.out.println("Full child process STDOUT was saved to " + stdoutLogFile); + + return output; + } + + private static void writeOutputToFile(String output, String fileName) throws Exception { + try (FileWriter fw = new FileWriter(fileName)) { + fw.write(output, 0, output.length()); + } + } + + private static String limitLines(String buffer, int nrOfLines) { + List l = Arrays.asList(buffer.split("\\R")); + if (l.size() < nrOfLines) { + return buffer; + } + + return String.join("\n", l.subList(0, nrOfLines)); + } +} diff --git a/test/lib/jdk/test/lib/process/OutputAnalyzer.java b/test/lib/jdk/test/lib/process/OutputAnalyzer.java index 24bb18e3d4b..3c5be74558b 100644 --- a/test/lib/jdk/test/lib/process/OutputAnalyzer.java +++ b/test/lib/jdk/test/lib/process/OutputAnalyzer.java @@ -40,7 +40,8 @@ public final class OutputAnalyzer { private static final String jvmwarningmsg = ".* VM warning:.*"; - private static final String deprecatedmsg = ".* VM warning:.* deprecated.*"; + private static final String VM_DEPRECATED_MSG = ".* VM warning:.* deprecated.*"; + private static final String OTHER_DEPRECATED_MSG = "^WARNING: .* is deprecated.*"; private static final String FATAL_ERROR_PAT = "# A fatal error has been detected.*"; @@ -182,7 +183,7 @@ public final class OutputAnalyzer { * If stderr was not empty */ public OutputAnalyzer stderrShouldBeEmptyIgnoreDeprecatedWarnings() { - if (!getStderr().replaceAll(deprecatedmsg + "\\R", "").isEmpty()) { + if (!getStderrNoDeprecatedWarnings().isEmpty()) { reportDiagnosticSummary(); throw new RuntimeException("stderr was not empty"); } @@ -603,6 +604,15 @@ public final class OutputAnalyzer { return buffer.getStderr(); } + /** + * Get the contents of the stderr buffer, with known deprecation warning patterns removed + * + * @return stderr buffer, with known deprecation warnings removed + */ + public String getStderrNoDeprecatedWarnings() { + return getStderr().replaceAll(VM_DEPRECATED_MSG + "\\R", "").replaceAll(OTHER_DEPRECATED_MSG + "\\R", ""); + } + /** * Get the process exit value * @@ -689,7 +699,7 @@ public final class OutputAnalyzer { * @throws RuntimeException If the pattern was not found */ public OutputAnalyzer stderrShouldMatchIgnoreDeprecatedWarnings(String pattern) { - String stderr = getStderr().replaceAll(deprecatedmsg + "\\R", ""); + String stderr = getStderrNoDeprecatedWarnings(); Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stderr); if (!matcher.find()) { reportDiagnosticSummary(); diff --git a/test/lib/jdk/test/lib/security/SeededSecureRandom.java b/test/lib/jdk/test/lib/security/SeededSecureRandom.java index f897677390e..305a91c41d2 100644 --- a/test/lib/jdk/test/lib/security/SeededSecureRandom.java +++ b/test/lib/jdk/test/lib/security/SeededSecureRandom.java @@ -65,4 +65,10 @@ public class SeededSecureRandom extends SecureRandom { rnd.nextBytes(out); return out; } + + public byte[] nBytes(int n) { + var out = new byte[n]; + nextBytes(out); + return out; + } } diff --git a/test/lib/jdk/test/lib/thread/TestThreadFactory.java b/test/lib/jdk/test/lib/thread/TestThreadFactory.java new file mode 100644 index 00000000000..ac5a6b74909 --- /dev/null +++ b/test/lib/jdk/test/lib/thread/TestThreadFactory.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.test.lib.thread; + +import java.util.concurrent.ThreadFactory; + +/* + This factory is used to start new threads in tests. + It supports creation of virtual threads when jtreg test.thread.factory plugin is enabled. +*/ + +public class TestThreadFactory { + + private static ThreadFactory threadFactory = "Virtual".equals(System.getProperty("test.thread.factory")) + ? virtualThreadFactory() : platformThreadFactory(); + + public static Thread newThread(Runnable task) { + return threadFactory.newThread(task); + } + + public static Thread newThread(Runnable task, String name) { + Thread t = threadFactory.newThread(task); + t.setName(name); + return t; + } + + private static ThreadFactory platformThreadFactory() { + return Thread.ofPlatform().factory(); + } + + private static ThreadFactory virtualThreadFactory() { + return Thread.ofVirtual().factory(); + } +} diff --git a/test/lib/jdk/test/lib/thread/VThreadRunner.java b/test/lib/jdk/test/lib/thread/VThreadRunner.java index ba69496a047..1b09e5e0d12 100644 --- a/test/lib/jdk/test/lib/thread/VThreadRunner.java +++ b/test/lib/jdk/test/lib/thread/VThreadRunner.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,10 +23,10 @@ package jdk.test.lib.thread; -import java.lang.reflect.Field; +import java.lang.management.ManagementFactory; import java.time.Duration; -import java.util.concurrent.ForkJoinPool; import java.util.concurrent.atomic.AtomicReference; +import jdk.management.VirtualThreadSchedulerMXBean; /** * Helper class to support tests running tasks in a virtual thread. @@ -133,39 +133,36 @@ public class VThreadRunner { run(null, 0, task); } - /** - * Returns the virtual thread scheduler. - */ - private static ForkJoinPool defaultScheduler() { - try { - var clazz = Class.forName("java.lang.VirtualThread"); - var field = clazz.getDeclaredField("DEFAULT_SCHEDULER"); - field.setAccessible(true); - return (ForkJoinPool) field.get(null); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - /** * Sets the virtual thread scheduler's target parallelism. + * + *

                    Tests using this method should use "{@code @modules jdk.management}" to help + * test selection. + * * @return the previous parallelism level */ public static int setParallelism(int size) { - return defaultScheduler().setParallelism(size); + var bean = ManagementFactory.getPlatformMXBean(VirtualThreadSchedulerMXBean.class); + int parallelism = bean.getParallelism(); + bean.setParallelism(size); + return parallelism; } /** * Ensures that the virtual thread scheduler's target parallelism is at least * the given size. If the target parallelism is less than the given size then * it is changed to the given size. + * + *

                    Tests using this method should use "{@code @modules jdk.management}" to help + * test selection. + * * @return the previous parallelism level */ public static int ensureParallelism(int size) { - ForkJoinPool pool = defaultScheduler(); - int parallelism = pool.getParallelism(); + var bean = ManagementFactory.getPlatformMXBean(VirtualThreadSchedulerMXBean.class); + int parallelism = bean.getParallelism(); if (size > parallelism) { - pool.setParallelism(size); + bean.setParallelism(size); } return parallelism; } diff --git a/test/lib/jdk/test/lib/util/ForceGC.java b/test/lib/jdk/test/lib/util/ForceGC.java index 19bbef1f7e4..e3587b9a2be 100644 --- a/test/lib/jdk/test/lib/util/ForceGC.java +++ b/test/lib/jdk/test/lib/util/ForceGC.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -78,29 +78,30 @@ public class ForceGC { ReferenceQueue queue = new ReferenceQueue<>(); Object obj = new Object(); PhantomReference ref = new PhantomReference<>(obj, queue); - obj = null; - Reference.reachabilityFence(obj); - Reference.reachabilityFence(ref); + try { + obj = null; - int retries = (int)(timeout / 200); - for (; retries >= 0; retries--) { - if (booleanSupplier.getAsBoolean()) { - return true; - } - - System.gc(); - - try { - // The remove() will always block for the specified milliseconds - // if the reference has already been removed from the queue. - // But it is fine. For most cases, the 1st GC is sufficient - // to trigger and complete the cleanup. - queue.remove(200L); - } catch (InterruptedException ie) { - // ignore, the loop will try again + int retries = (int) (timeout / 200); + for (; retries >= 0; retries--) { + if (booleanSupplier.getAsBoolean()) { + return true; + } + + System.gc(); + + try { + // The remove() will always block for the specified milliseconds + // if the reference has already been removed from the queue. + // But it is fine. For most cases, the 1st GC is sufficient + // to trigger and complete the cleanup. + queue.remove(200L); + } catch (InterruptedException ie) { + // ignore, the loop will try again + } } + } finally { + Reference.reachabilityFence(ref); } - return booleanSupplier.getAsBoolean(); } } diff --git a/test/lib/jdk/test/lib/util/JarUtils.java b/test/lib/jdk/test/lib/util/JarUtils.java index e1b3ccac19f..3aa4ada5197 100644 --- a/test/lib/jdk/test/lib/util/JarUtils.java +++ b/test/lib/jdk/test/lib/util/JarUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -320,6 +320,57 @@ public final class JarUtils { updateJar(src, dest, Map.of(JarFile.MANIFEST_NAME, bout.toByteArray())); } + /** + * Remove entries from a ZIP file. + * + * Each entry can be a name or a name ending with "*". + * + * @return number of removed entries + * @throws IOException if there is any I/O error + */ + public static int deleteEntries(Path jarfile, String... patterns) + throws IOException { + Path tmpfile = Files.createTempFile("jar", "jar"); + int count = 0; + + try (OutputStream out = Files.newOutputStream(tmpfile); + JarOutputStream jos = new JarOutputStream(out)) { + try (JarFile jf = new JarFile(jarfile.toString())) { + Enumeration jentries = jf.entries(); + top: while (jentries.hasMoreElements()) { + JarEntry jentry = jentries.nextElement(); + String name = jentry.getName(); + for (String pattern : patterns) { + if (pattern.endsWith("*")) { + if (name.startsWith(pattern.substring( + 0, pattern.length() - 1))) { + // Go directly to next entry. This + // one is not written into `jos` and + // therefore removed. + count++; + continue top; + } + } else { + if (name.equals(pattern)) { + // Same as above + count++; + continue top; + } + } + } + // No pattern matched, file retained + jos.putNextEntry(copyEntry(jentry)); + jf.getInputStream(jentry).transferTo(jos); + } + } + } + + // replace the original JAR file + Files.move(tmpfile, jarfile, StandardCopyOption.REPLACE_EXISTING); + + return count; + } + private static void updateEntry(JarOutputStream jos, String name, Object content) throws IOException { if (content instanceof Boolean) { diff --git a/test/lib/jdk/test/whitebox/WhiteBox.java b/test/lib/jdk/test/whitebox/WhiteBox.java index 607e9552945..8883e8332d5 100644 --- a/test/lib/jdk/test/whitebox/WhiteBox.java +++ b/test/lib/jdk/test/whitebox/WhiteBox.java @@ -769,6 +769,7 @@ public class WhiteBox { public native void printOsInfo(); public native long hostPhysicalMemory(); public native long hostPhysicalSwap(); + public native int hostCPUs(); // Decoder public native void disableElfSectionCache(); diff --git a/test/lib/jdk/test/whitebox/code/Compiler.java b/test/lib/jdk/test/whitebox/code/Compiler.java index 2f8447700d5..69d79ab9d71 100644 --- a/test/lib/jdk/test/whitebox/code/Compiler.java +++ b/test/lib/jdk/test/whitebox/code/Compiler.java @@ -91,12 +91,12 @@ public class Compiler { /** * Check if libgraal is used as JIT compiler. * - * libraal is enabled if isGraalEnabled is true and: + * libraal JIT is enabled if isGraalEnabled is true and: * - UseJVMCINativeLibrary flag is true * * @return true if libgraal is used as JIT compiler. */ - public static boolean isLibgraalEnabled() { + public static boolean isLibgraalJIT() { if (!isGraalEnabled()) { return false; } diff --git a/test/micro/org/openjdk/bench/java/io/DataOutputStreamBench.java b/test/micro/org/openjdk/bench/java/io/DataOutputStreamBench.java new file mode 100644 index 00000000000..34568110dde --- /dev/null +++ b/test/micro/org/openjdk/bench/java/io/DataOutputStreamBench.java @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2024, Alibaba Group Holding Limited. 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. + */ + +package org.openjdk.bench.java.io; + +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.infra.Blackhole; + +import java.io.*; +import java.nio.charset.StandardCharsets; +import java.util.HexFormat; +import java.util.concurrent.TimeUnit; + +@BenchmarkMode(Mode.AverageTime) +@OutputTimeUnit(TimeUnit.MICROSECONDS) +@Fork(2) +@Measurement(iterations = 6, time = 1) +@Warmup(iterations = 4, time = 2) +@State(Scope.Thread) +public class DataOutputStreamBench { + + @Param({"ascii", "utf8_2_bytes", "utf8_3_bytes", "emoji"}) + public String charType; + + ByteArrayOutputStream bytesOutput; + DataOutputStream dataOutput; + ObjectOutputStream objectOutput; + String[] strings; + + @Setup(Level.Trial) + public void setup() throws Exception { + byte[] bytes = HexFormat.of().parseHex( + switch (charType) { + case "ascii" -> "78"; + case "utf8_2_bytes" -> "c2a9"; + case "utf8_3_bytes" -> "e6b8a9"; + case "emoji" -> "e29da3efb88f"; + default -> throw new IllegalArgumentException("bad charType: " + charType); + } + ); + String s = new String(bytes, 0, bytes.length, StandardCharsets.UTF_8); + strings = new String[128]; + for (int i = 0; i < strings.length; i++) { + strings[i] = "A".repeat(i).concat(s.repeat(i)); + } + + bytesOutput = new ByteArrayOutputStream(1024 * 64); + dataOutput = new DataOutputStream(bytesOutput); + objectOutput = new ObjectOutputStream(bytesOutput); + } + + @Benchmark + public void dataOutwriteUTF(Blackhole bh) throws Exception { + bytesOutput.reset(); + for (var s : strings) { + dataOutput.writeUTF(s); + } + dataOutput.flush(); + bh.consume(bytesOutput.size()); + } + + @Benchmark + public void objectWriteUTF(Blackhole bh) throws Exception { + bytesOutput.reset(); + for (var s : strings) { + objectOutput.writeUTF(s); + } + objectOutput.flush(); + bh.consume(bytesOutput.size()); + } +} diff --git a/test/micro/org/openjdk/bench/java/lang/classfile/Utf8EntryWriteTo.java b/test/micro/org/openjdk/bench/java/lang/classfile/Utf8EntryWriteTo.java new file mode 100644 index 00000000000..a124b079268 --- /dev/null +++ b/test/micro/org/openjdk/bench/java/lang/classfile/Utf8EntryWriteTo.java @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, Alibaba Group Holding Limited. 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. + */ +package org.openjdk.bench.java.lang.classfile; + +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.BenchmarkMode; +import org.openjdk.jmh.annotations.Fork; +import org.openjdk.jmh.annotations.Measurement; +import org.openjdk.jmh.annotations.Mode; +import org.openjdk.jmh.annotations.OutputTimeUnit; +import org.openjdk.jmh.annotations.Param; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.Setup; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.annotations.Warmup; +import org.openjdk.jmh.infra.Blackhole; + +import java.lang.classfile.constantpool.ConstantPoolBuilder; +import java.lang.classfile.constantpool.ClassEntry; +import java.lang.classfile.*; +import java.lang.constant.*; +import java.nio.charset.StandardCharsets; +import java.util.HexFormat; +import java.util.concurrent.TimeUnit; +import java.util.function.Consumer; + +import static java.lang.classfile.ClassFile.*; +import static java.lang.constant.ConstantDescs.*; + +import jdk.internal.classfile.impl.*; +/** + * Test various operations on + */ +@BenchmarkMode(Mode.AverageTime) +@OutputTimeUnit(TimeUnit.NANOSECONDS) +@Warmup(iterations = 1, time = 2) +@Measurement(iterations = 3, time = 1) +@Fork(jvmArgsAppend = "--enable-preview", value = 3) +@State(Scope.Thread) +public class Utf8EntryWriteTo { + static final ClassDesc STRING_BUILDER = ClassDesc.ofDescriptor("Ljava/lang/StringBuilder;"); + static final MethodTypeDesc MTD_append = MethodTypeDesc.of(STRING_BUILDER, CD_String); + static final MethodTypeDesc MTD_String = MethodTypeDesc.of(CD_String); + static final ClassDesc CLASS_DESC = ClassDesc.ofDescriptor("Lorg/openjdk/bench/java/lang/classfile/String$$StringConcat;"); + + @Param({"ascii", "utf8_2_bytes", "utf8_3_bytes", "emoji"}) + public String charType; + ConstantPoolBuilder poolBuilder; + ClassEntry thisClass; + + @Setup + public void setup() throws Exception { + byte[] bytes = HexFormat.of().parseHex( + switch (charType) { + case "ascii" -> "78"; + case "utf8_2_bytes" -> "c2a9"; + case "utf8_3_bytes" -> "e6b8a9"; + case "emoji" -> "e29da3efb88f"; + default -> throw new IllegalArgumentException("bad charType: " + charType); + } + ); + String s = new String(bytes, 0, bytes.length, StandardCharsets.UTF_8); + String[] constants = new String[128]; + for (int i = 0; i < constants.length; i++) { + constants[i] = "A".repeat(i).concat(s); + } + + poolBuilder = ConstantPoolBuilder.of(); + thisClass = poolBuilder.classEntry(CLASS_DESC); + for (var c : constants) { + poolBuilder.utf8Entry(c); + } + } + + @Benchmark + public void writeTo(Blackhole bh) { + bh.consume(ClassFile + .of() + .build(thisClass, poolBuilder, (ClassBuilder clb) -> {})); + } +} diff --git a/test/micro/org/openjdk/bench/java/lang/foreign/LoopOverNonConstantAsType.java b/test/micro/org/openjdk/bench/java/lang/foreign/LoopOverNonConstantAsType.java new file mode 100644 index 00000000000..1fbe431b2f2 --- /dev/null +++ b/test/micro/org/openjdk/bench/java/lang/foreign/LoopOverNonConstantAsType.java @@ -0,0 +1,138 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.bench.java.lang.foreign; + +import java.lang.foreign.Arena; +import java.lang.foreign.MemorySegment; + +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.BenchmarkMode; +import org.openjdk.jmh.annotations.CompilerControl; +import org.openjdk.jmh.annotations.Fork; +import org.openjdk.jmh.annotations.Measurement; +import org.openjdk.jmh.annotations.Mode; +import org.openjdk.jmh.annotations.OutputTimeUnit; +import org.openjdk.jmh.annotations.Param; +import org.openjdk.jmh.annotations.Setup; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.annotations.TearDown; +import org.openjdk.jmh.annotations.Warmup; +import sun.misc.Unsafe; + +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; +import java.lang.reflect.Proxy; +import java.net.URL; +import java.net.URLClassLoader; +import java.util.Arrays; +import java.util.concurrent.TimeUnit; + +import static java.lang.foreign.ValueLayout.*; + +@BenchmarkMode(Mode.AverageTime) +@Warmup(iterations = 5, time = 500, timeUnit = TimeUnit.MILLISECONDS) +@Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS) +@State(org.openjdk.jmh.annotations.Scope.Thread) +@OutputTimeUnit(TimeUnit.MILLISECONDS) +@Fork(value = 3, jvmArgsAppend = { "-XX:-TieredCompilation" }) +public class LoopOverNonConstantAsType extends JavaLayouts { + + static final Unsafe unsafe = Utils.unsafe; + + static final int ELEM_SIZE = 1_000_000; + static final int CARRIER_SIZE = (int)JAVA_LONG.byteSize(); + static final int ALLOC_SIZE = ELEM_SIZE * CARRIER_SIZE; + + @Param({"false", "true"}) + public boolean asTypeCompiled; + + Arena arena; + MemorySegment segment; + long unsafe_addr; + + @Setup + public void setup() { + unsafe_addr = unsafe.allocateMemory(ALLOC_SIZE); + for (int i = 0; i < ELEM_SIZE; i++) { + unsafe.putInt(unsafe_addr + (i * CARRIER_SIZE) , i); + } + arena = Arena.ofConfined(); + segment = arena.allocate(ALLOC_SIZE, 1); + for (int i = 0; i < ELEM_SIZE; i++) { + VH_INT.set(segment, (long) i, i); + } + if (asTypeCompiled) { + compileAsType(); + } + } + + public interface T { } + + static final int TYPE_SIZE = 100; + static final Class[] types; + + static { + types = new Class[TYPE_SIZE]; + ClassLoader customLoader = new URLClassLoader(new URL[0], LoopOverNonConstantAsType.class.getClassLoader()); + for (int i = 0 ; i < TYPE_SIZE ; i++) { + types[i] = Proxy.newProxyInstance(customLoader, + new Class[] { T.class }, (_, _, _) -> null).getClass(); + } + } + + void compileAsType() { + for (Class type : types) { + MethodHandle handle = MethodHandles.zero(Object.class); + Class[] args = new Class[254]; + Arrays.fill(args, Object.class); + handle = MethodHandles.dropArguments(handle, 0, args); + for (int j = 0; j < args.length ; j++) { + handle = handle.asType(handle.type().changeParameterType(j, type)); + } + } + } + + @TearDown + public void tearDown() { + arena.close(); + unsafe.freeMemory(unsafe_addr); + } + + @Benchmark + public long unsafe_loop() { + long res = 0; + for (int i = 0; i < ELEM_SIZE; i ++) { + res += unsafe.getLong(unsafe_addr + (i * CARRIER_SIZE)); + } + return res; + } + + @Benchmark + public long segment_loop() { + long sum = 0; + for (int i = 0; i < ELEM_SIZE; i++) { + sum += segment.get(JAVA_LONG, i * CARRIER_SIZE); + } + return sum; + } +} diff --git a/test/micro/org/openjdk/bench/java/lang/foreign/SegmentBulkCopy.java b/test/micro/org/openjdk/bench/java/lang/foreign/SegmentBulkCopy.java new file mode 100644 index 00000000000..22ef139aac0 --- /dev/null +++ b/test/micro/org/openjdk/bench/java/lang/foreign/SegmentBulkCopy.java @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +package org.openjdk.bench.java.lang.foreign; + +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.BenchmarkMode; +import org.openjdk.jmh.annotations.Fork; +import org.openjdk.jmh.annotations.Measurement; +import org.openjdk.jmh.annotations.Mode; +import org.openjdk.jmh.annotations.OutputTimeUnit; +import org.openjdk.jmh.annotations.Param; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.Setup; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.annotations.Warmup; + +import java.lang.foreign.Arena; +import java.lang.foreign.MemorySegment; +import java.nio.ByteBuffer; +import java.util.concurrent.TimeUnit; + +@BenchmarkMode(Mode.AverageTime) +@Warmup(iterations = 5, time = 500, timeUnit = TimeUnit.MILLISECONDS) +@Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS) +@State(Scope.Thread) +@OutputTimeUnit(TimeUnit.NANOSECONDS) +@Fork(value = 3) +public class SegmentBulkCopy { + + @Param({"2", "3", "4", "5", "6", "7", "8", "64", "512", + "4096", "32768", "262144", "2097152", "16777216", "134217728"}) + public int ELEM_SIZE; + + byte[] srcArray; + byte[] dstArray; + MemorySegment heapSrcSegment; + MemorySegment heapDstSegment; + MemorySegment nativeSrcSegment; + MemorySegment nativeDstSegment; + ByteBuffer srcBuffer; + ByteBuffer dstBuffer; + + @Setup + public void setup() { + srcArray = new byte[ELEM_SIZE]; + dstArray = new byte[ELEM_SIZE]; + heapSrcSegment = MemorySegment.ofArray(srcArray); + heapDstSegment = MemorySegment.ofArray(dstArray); + nativeSrcSegment = Arena.ofAuto().allocate(ELEM_SIZE); + nativeDstSegment = Arena.ofAuto().allocate(ELEM_SIZE); + srcBuffer = ByteBuffer.wrap(srcArray); + dstBuffer = ByteBuffer.wrap(dstArray); + } + + @Benchmark + public void arrayCopy() { + System.arraycopy(srcArray, 0, dstArray, 0, ELEM_SIZE); + } + + @Benchmark + public void bufferCopy() { + dstBuffer.put(srcBuffer); + } + + @Fork(value = 3, jvmArgsAppend = {"-Djava.lang.foreign.native.threshold.power.copy=31"}) + @Benchmark + public void heapSegmentCopyJava() { + MemorySegment.copy(heapSrcSegment, 0, heapDstSegment, 0, ELEM_SIZE); + } + + @Fork(value = 3, jvmArgsAppend = {"-Djava.lang.foreign.native.threshold.power.copy=0"}) + @Benchmark + public void heapSegmentCopyUnsafe() { + MemorySegment.copy(heapSrcSegment, 0, heapDstSegment, 0, ELEM_SIZE); + } + + @Fork(value = 3, jvmArgsAppend = {"-Djava.lang.foreign.native.threshold.power.copy=31"}) + @Benchmark + public void nativeSegmentCopyJava() { + MemorySegment.copy(nativeSrcSegment, 0, nativeDstSegment, 0, ELEM_SIZE); + } + + @Fork(value = 3, jvmArgsAppend = {"-Djava.lang.foreign.native.threshold.power.copy=0"}) + @Benchmark + public void nativeSegmentCopyUnsafe() { + MemorySegment.copy(nativeSrcSegment, 0, nativeDstSegment, 0, ELEM_SIZE); + } + +} diff --git a/test/micro/org/openjdk/bench/java/lang/foreign/TestFill.java b/test/micro/org/openjdk/bench/java/lang/foreign/SegmentBulkFill.java similarity index 69% rename from test/micro/org/openjdk/bench/java/lang/foreign/TestFill.java rename to test/micro/org/openjdk/bench/java/lang/foreign/SegmentBulkFill.java index 78719f03bc3..95ca7228969 100644 --- a/test/micro/org/openjdk/bench/java/lang/foreign/TestFill.java +++ b/test/micro/org/openjdk/bench/java/lang/foreign/SegmentBulkFill.java @@ -48,13 +48,10 @@ import java.util.concurrent.TimeUnit; @State(Scope.Thread) @OutputTimeUnit(TimeUnit.NANOSECONDS) @Fork(value = 3) -public class TestFill { +public class SegmentBulkFill { - @Param({"0", "1", "2", "3", "4", "5", "6", "7", - "8", "9", "10", "11", "12", "13", "14", "15", - "16", "17", "18", "19", "20", "21", "22", "23", - "24", "25", "26", "27", "28", "29", "30", "31", - "32", "128", "256", "384", "511", "512"}) + @Param({"2", "3", "4", "5", "6", "7", "8", "64", "512", + "4096", "32768", "262144", "2097152", "16777216", "134217728"}) public int ELEM_SIZE; byte[] array; @@ -73,22 +70,43 @@ public class TestFill { } @Benchmark - public void arrays_fill() { + public void arraysFill() { Arrays.fill(array, (byte) 0); } + @Fork(value = 3, jvmArgsAppend = {"-Djava.lang.foreign.native.threshold.power.fill=31"}) @Benchmark - public void heap_segment_fill() { + public void heapSegmentFillJava() { heapSegment.fill((byte) 0); } + @Fork(value = 3, jvmArgsAppend = {"-Djava.lang.foreign.native.threshold.power.fill=0"}) @Benchmark - public void native_segment_fill() { + public void heapSegmentFillUnsafe() { + heapSegment.fill((byte) 0); + } + + @Fork(value = 3, jvmArgsAppend = {"-Djava.lang.foreign.native.threshold.power.fill=31"}) + @Benchmark + public void nativeSegmentFillJava() { nativeSegment.fill((byte) 0); } + @Fork(value = 3, jvmArgsAppend = {"-Djava.lang.foreign.native.threshold.power.fill=0"}) @Benchmark - public void unaligned_segment_fill() { + public void nativeSegmentFillUnsafe() { + nativeSegment.fill((byte) 0); + } + + @Fork(value = 3, jvmArgsAppend = {"-Djava.lang.foreign.native.threshold.power.fill=31"}) + @Benchmark + public void unalignedSegmentFillJava() { + unalignedSegment.fill((byte) 0); + } + + @Fork(value = 3, jvmArgsAppend = {"-Djava.lang.foreign.native.threshold.power.fill=0"}) + @Benchmark + public void unalignedSegmentFillUnsafe() { unalignedSegment.fill((byte) 0); } diff --git a/test/micro/org/openjdk/bench/java/lang/foreign/SegmentBulkMismatch.java b/test/micro/org/openjdk/bench/java/lang/foreign/SegmentBulkMismatch.java new file mode 100644 index 00000000000..5656b2f6b9f --- /dev/null +++ b/test/micro/org/openjdk/bench/java/lang/foreign/SegmentBulkMismatch.java @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +package org.openjdk.bench.java.lang.foreign; + +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.BenchmarkMode; +import org.openjdk.jmh.annotations.Fork; +import org.openjdk.jmh.annotations.Measurement; +import org.openjdk.jmh.annotations.Mode; +import org.openjdk.jmh.annotations.OutputTimeUnit; +import org.openjdk.jmh.annotations.Param; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.Setup; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.annotations.Warmup; + +import java.lang.foreign.Arena; +import java.lang.foreign.MemorySegment; +import java.util.Arrays; +import java.util.Random; +import java.util.concurrent.TimeUnit; + +import static java.lang.foreign.ValueLayout.*; + +@BenchmarkMode(Mode.AverageTime) +@Warmup(iterations = 5, time = 500, timeUnit = TimeUnit.MILLISECONDS) +@Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS) +@State(Scope.Thread) +@OutputTimeUnit(TimeUnit.NANOSECONDS) +@Fork(value = 3) +public class SegmentBulkMismatch { + + @Param({"2", "3", "4", "5", "6", "7", "8", "64", "512", + "4096", "32768", "262144", "2097152", "16777216", "134217728"}) + public int ELEM_SIZE; + + MemorySegment srcNative; + MemorySegment dstNative; + byte[] srcArray; + byte[] dstArray; + MemorySegment srcHeap; + MemorySegment dstHeap; + + @Setup + public void setup() { + // Always use the same alignment regardless of size + srcNative = Arena.ofAuto().allocate(ELEM_SIZE,16); + dstNative = Arena.ofAuto().allocate(ELEM_SIZE, 16); + var rnd = new Random(42); + for (int i = 0; i < ELEM_SIZE; i++) { + srcNative.set(JAVA_BYTE, i, (byte) rnd.nextInt(Byte.MIN_VALUE, Byte.MAX_VALUE)); + } + dstNative.copyFrom(srcNative); + srcArray = srcNative.toArray(JAVA_BYTE); + dstArray = dstNative.toArray(JAVA_BYTE); + srcHeap = MemorySegment.ofArray(srcArray); + dstHeap = MemorySegment.ofArray(dstArray); + } + + @Fork(value = 3, jvmArgsAppend = {"-Djava.lang.foreign.native.threshold.power.mismatch=31"}) + @Benchmark + public long nativeSegmentJava() { + return srcNative.mismatch(dstNative); + } + + @Fork(value = 3, jvmArgsAppend = {"-Djava.lang.foreign.native.threshold.power.mismatch=31"}) + @Benchmark + public long heapSegmentJava() { + return srcHeap.mismatch(dstHeap); + } + + @Fork(value = 3, jvmArgsAppend = {"-Djava.lang.foreign.native.threshold.power.mismatch=0"}) + @Benchmark + public long nativeSegmentUnsafe() { + return srcNative.mismatch(dstNative); + } + + @Fork(value = 3, jvmArgsAppend = {"-Djava.lang.foreign.native.threshold.power.mismatch=0"}) + @Benchmark + public long heapSegmentUnsafe() { + return srcHeap.mismatch(dstHeap); + } + + @Benchmark + public long array() { + return Arrays.mismatch(srcArray, dstArray); + } + +} + diff --git a/test/micro/org/openjdk/bench/java/lang/reflect/Proxy/ProxyBench.java b/test/micro/org/openjdk/bench/java/lang/reflect/proxy/ProxyBench.java similarity index 100% rename from test/micro/org/openjdk/bench/java/lang/reflect/Proxy/ProxyBench.java rename to test/micro/org/openjdk/bench/java/lang/reflect/proxy/ProxyBench.java diff --git a/test/micro/org/openjdk/bench/java/lang/reflect/Proxy/ProxyPerf.java b/test/micro/org/openjdk/bench/java/lang/reflect/proxy/ProxyGeneratorBench.java similarity index 57% rename from test/micro/org/openjdk/bench/java/lang/reflect/Proxy/ProxyPerf.java rename to test/micro/org/openjdk/bench/java/lang/reflect/proxy/ProxyGeneratorBench.java index 22fe4d3ef28..33934317300 100644 --- a/test/micro/org/openjdk/bench/java/lang/reflect/Proxy/ProxyPerf.java +++ b/test/micro/org/openjdk/bench/java/lang/reflect/proxy/ProxyGeneratorBench.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,6 @@ import java.util.List; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; -import org.openjdk.jmh.annotations.CompilerControl; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; @@ -36,37 +35,29 @@ import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Warmup; -import org.openjdk.jmh.infra.Blackhole; - import java.lang.reflect.InvocationHandler; -import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import java.lang.reflect.Modifier; import java.util.concurrent.TimeUnit; /** * Benchmark measuring java.lang.reflect.ProxyGenerator.generateProxyClass. * It bypasses the cache of proxies to measure the time to construct a proxy. */ -@Warmup(iterations = 5) -@Measurement(iterations = 10) -@Fork(value = 1) +@Warmup(iterations = 5, time = 2) +@Measurement(iterations = 5, time = 2) +@Fork(value = 1, jvmArgsPrepend = "--add-opens=java.base/java.lang.reflect=ALL-UNNAMED") @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) @State(Scope.Thread) -public class ProxyPerf { +public class ProxyGeneratorBench { /** * Sample results from a Dell T7610. * Benchmark Mode Cnt Score Error Units * ProxyPerf.genIntf_1 avgt 10 35325.428 +/- 780.459 ns/op - * ProxyPerf.genIntf_1_V49 avgt 10 34309.423 +/- 727.188 ns/op * ProxyPerf.genStringsIntf_3 avgt 10 46600.366 +/- 663.812 ns/op - * ProxyPerf.genStringsIntf_3_V49 avgt 10 45911.817 +/- 1598.536 ns/op * ProxyPerf.genZeroParams avgt 10 33245.048 +/- 437.988 ns/op - * ProxyPerf.genZeroParams_V49 avgt 10 32954.254 +/- 1041.932 ns/op - * ProxyPerf.getPrimsIntf_2 avgt 10 43987.819 +/- 837.443 ns/op - * ProxyPerf.getPrimsIntf_2_V49 avgt 10 42863.462 +/- 1193.480 ns/op + * ProxyPerf.genPrimsIntf_2 avgt 10 43987.819 +/- 837.443 ns/op */ public interface Intf_1 { @@ -84,7 +75,6 @@ public class ProxyPerf { public String m2String(String s1, String s2); } - private InvocationHandler handler; private ClassLoader classloader; private Method proxyGen; private Method proxyGenV49; @@ -92,19 +82,11 @@ public class ProxyPerf { @Setup public void setup() { try { - handler = (Object proxy, Method method, Object[] args) -> null; classloader = ClassLoader.getSystemClassLoader(); Class proxyGenClass = Class.forName("java.lang.reflect.ProxyGenerator"); proxyGen = proxyGenClass.getDeclaredMethod("generateProxyClass", ClassLoader.class, String.class, java.util.List.class, int.class); proxyGen.setAccessible(true); - - // Init access to the old Proxy generator - Class proxyGenClassV49 = Class.forName("java.lang.reflect.ProxyGenerator_v49"); - proxyGenV49 = proxyGenClassV49.getDeclaredMethod("generateProxyClass", - String.class, java.util.List.class, int.class); - proxyGenV49.setAccessible(true); - } catch (Exception ex) { ex.printStackTrace(); throw new RuntimeException("ProxyClass setup fails", ex); @@ -112,51 +94,35 @@ public class ProxyPerf { } @Benchmark - public void genZeroParams(Blackhole bh) throws Exception { + public Object genZeroParams() throws Exception { List> interfaces = List.of(Runnable.class); - bh.consume(proxyGen.invoke(null, classloader, "ProxyImpl", interfaces, 1)); + return proxyGen.invoke(null, classloader, "ProxyImpl", interfaces, 1); } @Benchmark - public void genIntf_1(Blackhole bh) throws Exception { + public Object genIntf_1() throws Exception { List> interfaces = List.of(Intf_1.class); - bh.consume(proxyGen.invoke(null, classloader, "ProxyImpl", interfaces, 1)); + return proxyGen.invoke(null, classloader, "ProxyImpl", interfaces, 1); } @Benchmark - public void getPrimsIntf_2(Blackhole bh) throws Exception { + public Object genPrimsIntf_2() throws Exception { List> interfaces = List.of(Intf_2.class); - bh.consume(proxyGen.invoke(null, classloader, "ProxyImpl", interfaces, 1)); + return proxyGen.invoke(null, classloader, "ProxyImpl", interfaces, 1); } + @Benchmark - public void genStringsIntf_3(Blackhole bh) throws Exception { + public Object genStringsIntf_3() throws Exception { List> interfaces = List.of(Intf_3.class); - bh.consume(proxyGen.invoke(null, classloader, "ProxyImpl", interfaces, 1)); + return proxyGen.invoke(null, classloader, "ProxyImpl", interfaces, 1); } - // Generate using the V49inal generator for comparison - - @Benchmark - public void genZeroParams_V49(Blackhole bh) throws Exception { - List> interfaces = List.of(Runnable.class); - bh.consume(proxyGenV49.invoke(null, "ProxyImpl", interfaces, 1)); + public static void main(String... args) throws Exception { + var benchmark = new ProxyGeneratorBench(); + benchmark.setup(); + benchmark.genZeroParams(); + benchmark.genIntf_1(); + benchmark.genPrimsIntf_2(); + benchmark.genStringsIntf_3(); } - - @Benchmark - public void genIntf_1_V49(Blackhole bh) throws Exception { - List> interfaces = List.of(Intf_1.class); - bh.consume(proxyGenV49.invoke(null, "ProxyImpl", interfaces, 1)); - } - - @Benchmark - public void getPrimsIntf_2_V49(Blackhole bh) throws Exception { - List> interfaces = List.of(Intf_2.class); - bh.consume(proxyGenV49.invoke(null, "ProxyImpl", interfaces, 1)); - } - @Benchmark - public void genStringsIntf_3_V49(Blackhole bh) throws Exception { - List> interfaces = List.of(Intf_3.class); - bh.consume(proxyGenV49.invoke(null, "ProxyImpl", interfaces, 1)); - } - } diff --git a/test/micro/org/openjdk/bench/java/util/zip/ZipFileOpen.java b/test/micro/org/openjdk/bench/java/util/zip/ZipFileOpen.java index e450fcfe9a0..4f6ae6373ec 100644 --- a/test/micro/org/openjdk/bench/java/util/zip/ZipFileOpen.java +++ b/test/micro/org/openjdk/bench/java/util/zip/ZipFileOpen.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -107,4 +107,13 @@ public class ZipFileOpen { zf.close(); zf2.close(); } + + // Provide a simple one-off run without JMH dependencies enable simple debugging, + // diagnostics and dual-purposing this micro as a startup test. + public static void main(String... args) throws Exception { + var bench = new ZipFileOpen(); + bench.size = 1024*4; + bench.beforeRun(); + bench.openCloseZipFile(); + } } diff --git a/test/micro/org/openjdk/bench/javax/crypto/full/AESGCMBench.java b/test/micro/org/openjdk/bench/javax/crypto/full/AESGCMBench.java index e46f50678ef..8355e4aed72 100644 --- a/test/micro/org/openjdk/bench/javax/crypto/full/AESGCMBench.java +++ b/test/micro/org/openjdk/bench/javax/crypto/full/AESGCMBench.java @@ -35,7 +35,7 @@ import javax.crypto.spec.GCMParameterSpec; public class AESGCMBench extends BenchBase { - @Param({"128"}) + @Param({"128", "192", "256"}) int keyLength; public static final int IV_MODULO = 16; diff --git a/test/micro/org/openjdk/bench/javax/crypto/full/BenchBase.java b/test/micro/org/openjdk/bench/javax/crypto/full/BenchBase.java index 0c5df20d9cb..94c8ef30ea5 100644 --- a/test/micro/org/openjdk/bench/javax/crypto/full/BenchBase.java +++ b/test/micro/org/openjdk/bench/javax/crypto/full/BenchBase.java @@ -45,7 +45,7 @@ public abstract class BenchBase extends CryptoBase { int keyLength = 256; // Default data sizes for full tests - @Param({"1024", "1500", "4096", "16384"}) + @Param({"128", "256", "512", "1024", "1500", "4096", "16384"}) int dataSize; static final int IV_BUFFER_SIZE = 36; diff --git a/test/micro/org/openjdk/bench/jdk/classfile/CodeAttributeTools.java b/test/micro/org/openjdk/bench/jdk/classfile/CodeAttributeTools.java index 4cf578889d1..4239f70504b 100644 --- a/test/micro/org/openjdk/bench/jdk/classfile/CodeAttributeTools.java +++ b/test/micro/org/openjdk/bench/jdk/classfile/CodeAttributeTools.java @@ -23,24 +23,21 @@ package org.openjdk.bench.jdk.classfile; import java.io.IOException; +import java.lang.classfile.Attributes; import java.lang.constant.ClassDesc; import java.net.URI; -import java.nio.ByteBuffer; import java.nio.file.FileSystems; import java.nio.file.Files; -import java.util.Iterator; import java.util.ArrayList; import java.util.List; import java.lang.classfile.ClassFile; import java.lang.classfile.ClassReader; -import java.lang.classfile.MethodModel; -import java.lang.classfile.constantpool.ConstantPool; import java.lang.classfile.constantpool.ConstantPoolBuilder; import java.lang.constant.MethodTypeDesc; import jdk.internal.classfile.impl.AbstractPseudoInstruction; -import jdk.internal.classfile.impl.CodeImpl; import jdk.internal.classfile.impl.LabelContext; import jdk.internal.classfile.impl.ClassFileImpl; +import jdk.internal.classfile.impl.RawBytecodeHelper; import jdk.internal.classfile.impl.SplitConstantPool; import jdk.internal.classfile.impl.StackCounter; import jdk.internal.classfile.impl.StackMapGenerator; @@ -70,7 +67,7 @@ public class CodeAttributeTools { String methodName, MethodTypeDesc methodDesc, boolean isStatic, - ByteBuffer bytecode, + RawBytecodeHelper.CodeRange bytecode, ConstantPoolBuilder constantPool, List handlers) {} @@ -85,15 +82,14 @@ public class CodeAttributeTools { var thisCls = clm.thisClass().asSymbol(); var cp = new SplitConstantPool((ClassReader)clm.constantPool()); for (var m : clm.methods()) { - m.code().ifPresent(com -> { - var bb = ByteBuffer.wrap(((CodeImpl)com).contents()); + m.findAttribute(Attributes.code()).ifPresent(com -> { data.add(new GenData( (LabelContext)com, thisCls, m.methodName().stringValue(), m.methodTypeSymbol(), (m.flags().flagsMask() & ClassFile.ACC_STATIC) != 0, - bb.slice(8, bb.getInt(4)), + RawBytecodeHelper.of(com.codeArray()), cp, com.exceptionHandlers().stream().map(eh -> (AbstractPseudoInstruction.ExceptionCatchImpl)eh).toList())); }); @@ -112,7 +108,7 @@ public class CodeAttributeTools { d.methodName(), d.methodDesc(), d.isStatic(), - d.bytecode().rewind(), + d.bytecode(), (SplitConstantPool)d.constantPool(), (ClassFileImpl)ClassFile.of(), d.handlers())); @@ -127,7 +123,7 @@ public class CodeAttributeTools { d.methodName(), d.methodDesc(), d.isStatic(), - d.bytecode().rewind(), + d.bytecode(), (SplitConstantPool)d.constantPool(), d.handlers())); } diff --git a/test/micro/org/openjdk/bench/jdk/classfile/ConstantPoolBuildingClassEntry.java b/test/micro/org/openjdk/bench/jdk/classfile/ConstantPoolBuildingClassEntry.java new file mode 100644 index 00000000000..0f8bf0449af --- /dev/null +++ b/test/micro/org/openjdk/bench/jdk/classfile/ConstantPoolBuildingClassEntry.java @@ -0,0 +1,164 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.bench.jdk.classfile; + +import java.lang.classfile.constantpool.ConstantPoolBuilder; +import java.lang.constant.ClassDesc; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.concurrent.TimeUnit; + +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.infra.Blackhole; + +import static java.lang.constant.ConstantDescs.*; + +import static org.openjdk.bench.jdk.classfile.TestConstants.*; + +/** + * Tests constant pool builder lookup performance for ClassEntry. + * Note that ClassEntry is available only for reference types. + */ +@Warmup(iterations = 3) +@Measurement(iterations = 5) +@OutputTimeUnit(TimeUnit.MILLISECONDS) +@BenchmarkMode(Mode.Throughput) +@Fork(value = 1, jvmArgsAppend = {"--enable-preview"}) +@State(Scope.Benchmark) +public class ConstantPoolBuildingClassEntry { + // JDK-8338546 + ConstantPoolBuilder builder; + List classDescs; + List nonIdenticalClassDescs; + List internalNames; + List nonDuplicateClassDescs; + List nonDuplicateInternalNames; + int size; + + @Setup(Level.Iteration) + public void setup() { + builder = ConstantPoolBuilder.of(); + // Note these can only be reference types, no primitives + classDescs = List.of( + CD_Byte, CD_Object, CD_Long.arrayType(), CD_String, CD_String, CD_Object, CD_Short, + CD_MethodHandle, CD_MethodHandle, CD_Object, CD_Character, CD_List, CD_ArrayList, + CD_List, CD_Set, CD_Integer, CD_Object.arrayType(), CD_Enum, CD_Object, CD_MethodHandles_Lookup, + CD_Long, CD_Set, CD_Object, CD_Character, CD_Integer, CD_System, CD_String, CD_String, + CD_CallSite, CD_Collection, CD_List, CD_Collection, CD_String, CD_int.arrayType() + ); + size = classDescs.size(); + nonIdenticalClassDescs = classDescs.stream().map(cd -> { + var ret = ClassDesc.ofDescriptor(new String(cd.descriptorString())); + ret.hashCode(); // pre-compute hash code for cd + return ret; + }).toList(); + internalNames = classDescs.stream().map(cd -> { + // also sets up builder + cd.hashCode(); // pre-computes hash code for cd + var ce = builder.classEntry(cd); + var ret = ce.name().stringValue(); + ret.hashCode(); // pre-computes hash code for stringValue + return ret; + }).toList(); + nonDuplicateClassDescs = List.copyOf(new LinkedHashSet<>(classDescs)); + nonDuplicateInternalNames = nonDuplicateClassDescs.stream().map(cd -> + builder.classEntry(cd).asInternalName()).toList(); + } + + // Copied from jdk.internal.classfile.impl.Util::toInternalName + // to reduce internal dependencies + public static String toInternalName(ClassDesc cd) { + var desc = cd.descriptorString(); + if (desc.charAt(0) == 'L') + return desc.substring(1, desc.length() - 1); + throw new IllegalArgumentException(desc); + } + + /** + * Looking up with identical ClassDesc objects. Happens in bytecode generators reusing + * constant CD_Xxx. + */ + @Benchmark + public void identicalLookup(Blackhole bh) { + for (var cd : classDescs) { + bh.consume(builder.classEntry(cd)); + } + } + + /** + * Looking up with non-identical ClassDesc objects. Happens in bytecode generators + * using ad-hoc Class.describeConstable().orElseThrow() or other parsed ClassDesc. + * Cannot use identity fast path compared to {@link #identicalLookup}. + */ + @Benchmark + public void nonIdenticalLookup(Blackhole bh) { + for (var cd : nonIdenticalClassDescs) { + bh.consume(builder.classEntry(cd)); + } + } + + /** + * Looking up with internal names. Closest to ASM behavior. + * Baseline for {@link #identicalLookup}. + */ + @Benchmark + public void internalNameLookup(Blackhole bh) { + for (var name : internalNames) { + bh.consume(builder.classEntry(builder.utf8Entry(name))); + } + } + + /** + * The default implementation provided by {@link ConstantPoolBuilder#classEntry(ClassDesc)}. + * Does substring so needs to rehash and has no caching, should be very slow. + */ + @Benchmark + public void oldStyleLookup(Blackhole bh) { + for (var cd : classDescs) { + var s = cd.isClassOrInterface() ? toInternalName(cd) : cd.descriptorString(); + bh.consume(builder.classEntry(builder.utf8Entry(s))); + } + } + + /** + * Measures performance of creating new class entries in new constant pools with symbols. + */ + @Benchmark + public void freshCreationWithDescs(Blackhole bh) { + var cp = ConstantPoolBuilder.of(); + for (var cd : nonDuplicateClassDescs) { + bh.consume(cp.classEntry(cd)); + } + } + + /** + * Measures performance of creating new class entries in new constant pools with internal names. + */ + @Benchmark + public void freshCreationWithInternalNames(Blackhole bh) { + var cp = ConstantPoolBuilder.of(); + for (var name : nonDuplicateInternalNames) { + bh.consume(cp.classEntry(cp.utf8Entry(name))); + } + } +} diff --git a/test/micro/org/openjdk/bench/jdk/classfile/Write.java b/test/micro/org/openjdk/bench/jdk/classfile/Write.java index b8bc9605559..6e041cf6436 100644 --- a/test/micro/org/openjdk/bench/jdk/classfile/Write.java +++ b/test/micro/org/openjdk/bench/jdk/classfile/Write.java @@ -62,6 +62,15 @@ import static org.openjdk.bench.jdk.classfile.TestConstants.*; "--enable-preview", "--add-exports", "java.base/jdk.internal.classfile.impl=ALL-UNNAMED"}) public class Write { + static final int REPEATS = 40; + static final String[] METHOD_NAMES; + static { + var names = new String[REPEATS]; + for (int xi = 0; xi < REPEATS; ++xi) { + names[xi] = "main" + ((xi == 0) ? "" : "" + xi); + } + METHOD_NAMES = names; + } static String checkFileAsm = "/tmp/asw/MyClass.class"; static String checkFileBc = "/tmp/byw/MyClass.class"; static boolean writeClassAsm = Files.exists(Paths.get(checkFileAsm).getParent()); @@ -90,8 +99,8 @@ public class Write { mv.visitEnd(); } - for (int xi = 0; xi < 40; ++xi) { - MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC+Opcodes.ACC_STATIC, "main"+ ((xi==0)? "" : ""+xi), "([Ljava/lang/String;)V", null, null); + for (int xi = 0; xi < REPEATS; ++xi) { + MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC+Opcodes.ACC_STATIC, METHOD_NAMES[xi], "([Ljava/lang/String;)V", null, null); mv.visitCode(); Label loopTop = new Label(); Label loopEnd = new Label(); @@ -141,13 +150,13 @@ public class Write { cb.withVersion(52, 0); cb.with(SourceFileAttribute.of(cb.constantPool().utf8Entry(("MyClass.java")))) .withMethod(INIT_NAME, MTD_void, 0, mb -> mb - .withCode(codeb -> codeb.loadLocal(REFERENCE, 0) - .invoke(INVOKESPECIAL, CD_Object, INIT_NAME, MTD_void, false) - .return_(VOID) + .withCode(codeb -> codeb.aload(0) + .invokespecial(CD_Object, INIT_NAME, MTD_void) + .return_() ) ); - for (int xi = 0; xi < 40; ++xi) { - cb.withMethod("main" + ((xi == 0) ? "" : "" + xi), MTD_void_StringArray, + for (int xi = 0; xi < REPEATS; ++xi) { + cb.withMethod(METHOD_NAMES[xi], MTD_void_StringArray, ACC_PUBLIC | ACC_STATIC, mb -> mb.withCode(c0 -> { java.lang.classfile.Label loopTop = c0.newLabel(); @@ -180,54 +189,6 @@ public class Write { return bytes; } - @Benchmark - @BenchmarkMode(Mode.Throughput) - public byte[] jdkTreePrimitive() { - - byte[] bytes = ClassFile.of().build(CD_MyClass, cb -> { - cb.withFlags(AccessFlag.PUBLIC); - cb.withVersion(52, 0); - cb.with(SourceFileAttribute.of(cb.constantPool().utf8Entry(("MyClass.java")))) - .withMethod(INIT_NAME, MTD_void, 0, - mb -> mb.withCode(codeb -> codeb.loadLocal(REFERENCE, 0) - .invokespecial(CD_Object, INIT_NAME, MTD_void, false) - .return_() - ) - ); - for (int xi = 0; xi < 40; ++xi) { - cb.withMethod("main" + ((xi == 0) ? "" : "" + xi), MTD_void_StringArray, - ACC_PUBLIC | ACC_STATIC, - mb -> mb.withCode(c0 -> { - java.lang.classfile.Label loopTop = c0.newLabel(); - java.lang.classfile.Label loopEnd = c0.newLabel(); - int vFac = 1; - int vI = 2; - c0.iconst_1() // 0 - .istore(1) // 1 - .iconst_1() // 2 - .istore(2) // 3 - .labelBinding(loopTop) - .iload(2) // 4 - .bipush(10) // 5 - .if_icmpge(loopEnd) // 6 - .iload(1) // 7 - .iload(2) // 8 - .imul() // 9 - .istore(1) // 10 - .iinc(2, 1) // 11 - .goto_(loopTop) // 12 - .labelBinding(loopEnd) - .getstatic(CD_System, "out", CD_PrintStream) // 13 - .iload(1) - .invokevirtual(CD_PrintStream, "println", MTD_void_int) // 15 - .return_(); - })); - } - }); - if (writeClassBc) writeClass(bytes, checkFileBc); - return bytes; - } - private void writeClass(byte[] bytes, String fn) { try { FileOutputStream out = new FileOutputStream(fn); diff --git a/test/micro/org/openjdk/bench/vm/compiler/TypeVectorOperations.java b/test/micro/org/openjdk/bench/vm/compiler/TypeVectorOperations.java index 9d4f6260440..a3e4445664c 100644 --- a/test/micro/org/openjdk/bench/vm/compiler/TypeVectorOperations.java +++ b/test/micro/org/openjdk/bench/vm/compiler/TypeVectorOperations.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,6 +38,9 @@ public abstract class TypeVectorOperations { @Param({"512", /* "1024", */ "2048"}) public int COUNT; + private boolean[] boolsA; + private boolean[] boolsB; + private boolean[] resZ; private byte[] bytesA; private byte[] bytesB; private byte[] resB; @@ -58,6 +61,9 @@ public abstract class TypeVectorOperations { @Setup public void init() { + boolsA = new boolean[COUNT]; + boolsB = new boolean[COUNT]; + resZ = new boolean[COUNT]; bytesA = new byte[COUNT]; bytesB = new byte[COUNT]; resB = new byte[COUNT]; @@ -73,6 +79,8 @@ public abstract class TypeVectorOperations { resF = new float[COUNT]; for (int i = 0; i < COUNT; i++) { + boolsA[i] = r.nextBoolean(); + boolsB[i] = r.nextBoolean(); shorts[i] = (short) r.nextInt(Short.MAX_VALUE + 1); ints[i] = r.nextInt(); longs[i] = r.nextLong(); @@ -366,6 +374,13 @@ public abstract class TypeVectorOperations { } } + @Benchmark + public void andZ() { + for (int i = 0; i < COUNT; i++) { + resZ[i] = boolsA[i] & boolsB[i]; + } + } + @Benchmark @Fork(jvmArgsPrepend = {"-XX:+UseCMoveUnconditionally", "-XX:+UseVectorCmov"}) public void cmoveD() { diff --git a/test/micro/org/openjdk/bench/vm/compiler/VectorReduction2.java b/test/micro/org/openjdk/bench/vm/compiler/VectorReduction2.java new file mode 100644 index 00000000000..5ec34a0423f --- /dev/null +++ b/test/micro/org/openjdk/bench/vm/compiler/VectorReduction2.java @@ -0,0 +1,1454 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.bench.vm.compiler; + +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.infra.*; + +import java.util.concurrent.TimeUnit; +import java.util.Random; + +@BenchmarkMode(Mode.AverageTime) +@OutputTimeUnit(TimeUnit.NANOSECONDS) +@State(Scope.Thread) +@Warmup(iterations = 2, time = 1, timeUnit = TimeUnit.SECONDS) +@Measurement(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS) +public abstract class VectorReduction2 { + @Param({"2048"}) + public int SIZE; + + private byte[] in1B; + private byte[] in2B; + private byte[] in3B; + private char[] in1C; + private char[] in2C; + private char[] in3C; + private short[] in1S; + private short[] in2S; + private short[] in3S; + + private int[] in1I; + private int[] in2I; + private int[] in3I; + private long[] in1L; + private long[] in2L; + private long[] in3L; + + private float[] in1F; + private float[] in2F; + private float[] in3F; + private double[] in1D; + private double[] in2D; + private double[] in3D; + + @Param("0") + private int seed; + private Random r = new Random(seed); + + private static int globalResI; + + @Setup + public void init() { + in1B = new byte[SIZE]; + in2B = new byte[SIZE]; + in3B = new byte[SIZE]; + in1C = new char[SIZE]; + in2C = new char[SIZE]; + in3C = new char[SIZE]; + in1S = new short[SIZE]; + in2S = new short[SIZE]; + in3S = new short[SIZE]; + + in1I = new int[SIZE]; + in2I = new int[SIZE]; + in3I = new int[SIZE]; + in1L = new long[SIZE]; + in2L = new long[SIZE]; + in3L = new long[SIZE]; + + in1F = new float[SIZE]; + in2F = new float[SIZE]; + in3F = new float[SIZE]; + in1D = new double[SIZE]; + in2D = new double[SIZE]; + in3D = new double[SIZE]; + + for (int i = 0; i < SIZE; i++) { + in1B[i] = (byte)r.nextInt(); + in2B[i] = (byte)r.nextInt(); + in3B[i] = (byte)r.nextInt(); + in1C[i] = (char)r.nextInt(); + in2C[i] = (char)r.nextInt(); + in3C[i] = (char)r.nextInt(); + in1S[i] = (short)r.nextInt(); + in2S[i] = (short)r.nextInt(); + in3S[i] = (short)r.nextInt(); + + in1I[i] = r.nextInt(); + in2I[i] = r.nextInt(); + in3I[i] = r.nextInt(); + in1L[i] = r.nextLong(); + in2L[i] = r.nextLong(); + in3L[i] = r.nextLong(); + + in1F[i] = r.nextFloat(); + in2F[i] = r.nextFloat(); + in3F[i] = r.nextFloat(); + in1D[i] = r.nextDouble(); + in2D[i] = r.nextDouble(); + in3D[i] = r.nextDouble(); + } + } + + // Naming convention: + // How much work? + // - simple: val = a[i] + // - dotprod: val = a[i] * b[i] + // - big: val = (a[i] * b[i]) + (a[i] * c[i]) + (b[i] * c[i]) + // Reduction operator: + // - and: acc &= val + // - or: acc |= val + // - xor: acc ^= val + // - add: acc += val + // - mul: acc *= val + // - min: acc = min(acc, val) + // - max: acc = max(acc, val) + + // ---------byte***Simple ------------------------------------------------------------ + @Benchmark + public void byteAndSimple(Blackhole bh) { + byte acc = (byte)0xFF; // neutral element + for (int i = 0; i < SIZE; i++) { + byte val = in1B[i]; + acc &= val; + } + bh.consume(acc); + } + + @Benchmark + public void byteOrSimple(Blackhole bh) { + byte acc = 0; // neutral element + for (int i = 0; i < SIZE; i++) { + byte val = in1B[i]; + acc |= val; + } + bh.consume(acc); + } + + @Benchmark + public void byteXorSimple(Blackhole bh) { + byte acc = 0; // neutral element + for (int i = 0; i < SIZE; i++) { + byte val = in1B[i]; + acc ^= val; + } + bh.consume(acc); + } + + @Benchmark + public void byteAddSimple(Blackhole bh) { + byte acc = 0; // neutral element + for (int i = 0; i < SIZE; i++) { + byte val = in1B[i]; + acc += val; + } + bh.consume(acc); + } + + @Benchmark + public void byteMulSimple(Blackhole bh) { + byte acc = 1; // neutral element + for (int i = 0; i < SIZE; i++) { + byte val = in1B[i]; + acc *= val; + } + bh.consume(acc); + } + + @Benchmark + public void byteMinSimple(Blackhole bh) { + byte acc = Byte.MAX_VALUE; // neutral element + for (int i = 0; i < SIZE; i++) { + byte val = in1B[i]; + acc = (byte)Math.min(acc, val); + } + bh.consume(acc); + } + + @Benchmark + public void byteMaxSimple(Blackhole bh) { + byte acc = Byte.MIN_VALUE; // neutral element + for (int i = 0; i < SIZE; i++) { + byte val = in1B[i]; + acc = (byte)Math.max(acc, val); + } + bh.consume(acc); + } + + // ---------byte***DotProduct ------------------------------------------------------------ + @Benchmark + public void byteAndDotProduct(Blackhole bh) { + byte acc = (byte)0xFF; // neutral element + for (int i = 0; i < SIZE; i++) { + byte val = (byte)(in1B[i] * in2B[i]); + acc &= val; + } + bh.consume(acc); + } + + @Benchmark + public void byteOrDotProduct(Blackhole bh) { + byte acc = 0; // neutral element + for (int i = 0; i < SIZE; i++) { + byte val = (byte)(in1B[i] * in2B[i]); + acc |= val; + } + bh.consume(acc); + } + + @Benchmark + public void byteXorDotProduct(Blackhole bh) { + byte acc = 0; // neutral element + for (int i = 0; i < SIZE; i++) { + byte val = (byte)(in1B[i] * in2B[i]); + acc ^= val; + } + bh.consume(acc); + } + + @Benchmark + public void byteAddDotProduct(Blackhole bh) { + byte acc = 0; // neutral element + for (int i = 0; i < SIZE; i++) { + byte val = (byte)(in1B[i] * in2B[i]); + acc += val; + } + bh.consume(acc); + } + + @Benchmark + public void byteMulDotProduct(Blackhole bh) { + byte acc = 1; // neutral element + for (int i = 0; i < SIZE; i++) { + byte val = (byte)(in1B[i] * in2B[i]); + acc *= val; + } + bh.consume(acc); + } + + @Benchmark + public void byteMinDotProduct(Blackhole bh) { + byte acc = Byte.MAX_VALUE; // neutral element + for (int i = 0; i < SIZE; i++) { + byte val = (byte)(in1B[i] * in2B[i]); + acc = (byte)Math.min(acc, val); + } + bh.consume(acc); + } + + @Benchmark + public void byteMaxDotProduct(Blackhole bh) { + byte acc = Byte.MIN_VALUE; // neutral element + for (int i = 0; i < SIZE; i++) { + byte val = (byte)(in1B[i] * in2B[i]); + acc = (byte)Math.max(acc, val); + } + bh.consume(acc); + } + + // ---------byte***Big ------------------------------------------------------------ + @Benchmark + public void byteAndBig(Blackhole bh) { + byte acc = (byte)0xFF; // neutral element + for (int i = 0; i < SIZE; i++) { + byte val = (byte)((in1B[i] * in2B[i]) + (in1B[i] * in3B[i]) + (in2B[i] * in3B[i])); + acc &= val; + } + bh.consume(acc); + } + + @Benchmark + public void byteOrBig(Blackhole bh) { + byte acc = 0; // neutral element + for (int i = 0; i < SIZE; i++) { + byte val = (byte)((in1B[i] * in2B[i]) + (in1B[i] * in3B[i]) + (in2B[i] * in3B[i])); + acc |= val; + } + bh.consume(acc); + } + + @Benchmark + public void byteXorBig(Blackhole bh) { + byte acc = 0; // neutral element + for (int i = 0; i < SIZE; i++) { + byte val = (byte)((in1B[i] * in2B[i]) + (in1B[i] * in3B[i]) + (in2B[i] * in3B[i])); + acc ^= val; + } + bh.consume(acc); + } + + @Benchmark + public void byteAddBig(Blackhole bh) { + byte acc = 0; // neutral element + for (int i = 0; i < SIZE; i++) { + byte val = (byte)((in1B[i] * in2B[i]) + (in1B[i] * in3B[i]) + (in2B[i] * in3B[i])); + acc += val; + } + bh.consume(acc); + } + + @Benchmark + public void byteMulBig(Blackhole bh) { + byte acc = 1; // neutral element + for (int i = 0; i < SIZE; i++) { + byte val = (byte)((in1B[i] * in2B[i]) + (in1B[i] * in3B[i]) + (in2B[i] * in3B[i])); + acc *= val; + } + bh.consume(acc); + } + + @Benchmark + public void byteMinBig(Blackhole bh) { + byte acc = Byte.MAX_VALUE; // neutral element + for (int i = 0; i < SIZE; i++) { + byte val = (byte)((in1B[i] * in2B[i]) + (in1B[i] * in3B[i]) + (in2B[i] * in3B[i])); + acc = (byte)Math.min(acc, val); + } + bh.consume(acc); + } + + @Benchmark + public void byteMaxBig(Blackhole bh) { + byte acc = Byte.MIN_VALUE; // neutral element + for (int i = 0; i < SIZE; i++) { + byte val = (byte)((in1B[i] * in2B[i]) + (in1B[i] * in3B[i]) + (in2B[i] * in3B[i])); + acc = (byte)Math.max(acc, val); + } + bh.consume(acc); + } + + // ---------char***Simple ------------------------------------------------------------ + @Benchmark + public void charAndSimple(Blackhole bh) { + char acc = (char)0xFFFF; // neutral element + for (int i = 0; i < SIZE; i++) { + char val = in1C[i]; + acc &= val; + } + bh.consume(acc); + } + + @Benchmark + public void charOrSimple(Blackhole bh) { + char acc = 0; // neutral element + for (int i = 0; i < SIZE; i++) { + char val = in1C[i]; + acc |= val; + } + bh.consume(acc); + } + + @Benchmark + public void charXorSimple(Blackhole bh) { + char acc = 0; // neutral element + for (int i = 0; i < SIZE; i++) { + char val = in1C[i]; + acc ^= val; + } + bh.consume(acc); + } + + @Benchmark + public void charAddSimple(Blackhole bh) { + char acc = 0; // neutral element + for (int i = 0; i < SIZE; i++) { + char val = in1C[i]; + acc += val; + } + bh.consume(acc); + } + + @Benchmark + public void charMulSimple(Blackhole bh) { + char acc = 1; // neutral element + for (int i = 0; i < SIZE; i++) { + char val = in1C[i]; + acc *= val; + } + bh.consume(acc); + } + + @Benchmark + public void charMinSimple(Blackhole bh) { + char acc = Character.MAX_VALUE; // neutral element + for (int i = 0; i < SIZE; i++) { + char val = in1C[i]; + acc = (char)Math.min(acc, val); + } + bh.consume(acc); + } + + @Benchmark + public void charMaxSimple(Blackhole bh) { + char acc = Character.MIN_VALUE; // neutral element + for (int i = 0; i < SIZE; i++) { + char val = in1C[i]; + acc = (char)Math.max(acc, val); + } + bh.consume(acc); + } + + // ---------char***DotProduct ------------------------------------------------------------ + @Benchmark + public void charAndDotProduct(Blackhole bh) { + char acc = (char)0xFFFF; // neutral element + for (int i = 0; i < SIZE; i++) { + char val = (char)(in1C[i] * in2C[i]); + acc &= val; + } + bh.consume(acc); + } + + @Benchmark + public void charOrDotProduct(Blackhole bh) { + char acc = 0; // neutral element + for (int i = 0; i < SIZE; i++) { + char val = (char)(in1C[i] * in2C[i]); + acc |= val; + } + bh.consume(acc); + } + + @Benchmark + public void charXorDotProduct(Blackhole bh) { + char acc = 0; // neutral element + for (int i = 0; i < SIZE; i++) { + char val = (char)(in1C[i] * in2C[i]); + acc ^= val; + } + bh.consume(acc); + } + + @Benchmark + public void charAddDotProduct(Blackhole bh) { + char acc = 0; // neutral element + for (int i = 0; i < SIZE; i++) { + char val = (char)(in1C[i] * in2C[i]); + acc += val; + } + bh.consume(acc); + } + + @Benchmark + public void charMulDotProduct(Blackhole bh) { + char acc = 1; // neutral element + for (int i = 0; i < SIZE; i++) { + char val = (char)(in1C[i] * in2C[i]); + acc *= val; + } + bh.consume(acc); + } + + @Benchmark + public void charMinDotProduct(Blackhole bh) { + char acc = Character.MAX_VALUE; // neutral element + for (int i = 0; i < SIZE; i++) { + char val = (char)(in1C[i] * in2C[i]); + acc = (char)Math.min(acc, val); + } + bh.consume(acc); + } + + @Benchmark + public void charMaxDotProduct(Blackhole bh) { + char acc = Character.MIN_VALUE; // neutral element + for (int i = 0; i < SIZE; i++) { + char val = (char)(in1C[i] * in2C[i]); + acc = (char)Math.max(acc, val); + } + bh.consume(acc); + } + + // ---------char***Big ------------------------------------------------------------ + @Benchmark + public void charAndBig(Blackhole bh) { + char acc = (char)0xFFFF; // neutral element + for (int i = 0; i < SIZE; i++) { + char val = (char)((in1C[i] * in2C[i]) + (in1C[i] * in3C[i]) + (in2C[i] * in3C[i])); + acc &= val; + } + bh.consume(acc); + } + + @Benchmark + public void charOrBig(Blackhole bh) { + char acc = 0; // neutral element + for (int i = 0; i < SIZE; i++) { + char val = (char)((in1C[i] * in2C[i]) + (in1C[i] * in3C[i]) + (in2C[i] * in3C[i])); + acc |= val; + } + bh.consume(acc); + } + + @Benchmark + public void charXorBig(Blackhole bh) { + char acc = 0; // neutral element + for (int i = 0; i < SIZE; i++) { + char val = (char)((in1C[i] * in2C[i]) + (in1C[i] * in3C[i]) + (in2C[i] * in3C[i])); + acc ^= val; + } + bh.consume(acc); + } + + @Benchmark + public void charAddBig(Blackhole bh) { + char acc = 0; // neutral element + for (int i = 0; i < SIZE; i++) { + char val = (char)((in1C[i] * in2C[i]) + (in1C[i] * in3C[i]) + (in2C[i] * in3C[i])); + acc += val; + } + bh.consume(acc); + } + + @Benchmark + public void charMulBig(Blackhole bh) { + char acc = 1; // neutral element + for (int i = 0; i < SIZE; i++) { + char val = (char)((in1C[i] * in2C[i]) + (in1C[i] * in3C[i]) + (in2C[i] * in3C[i])); + acc *= val; + } + bh.consume(acc); + } + + @Benchmark + public void charMinBig(Blackhole bh) { + char acc = Character.MAX_VALUE; // neutral element + for (int i = 0; i < SIZE; i++) { + char val = (char)((in1C[i] * in2C[i]) + (in1C[i] * in3C[i]) + (in2C[i] * in3C[i])); + acc = (char)Math.min(acc, val); + } + bh.consume(acc); + } + + @Benchmark + public void charMaxBig(Blackhole bh) { + char acc = Character.MIN_VALUE; // neutral element + for (int i = 0; i < SIZE; i++) { + char val = (char)((in1C[i] * in2C[i]) + (in1C[i] * in3C[i]) + (in2C[i] * in3C[i])); + acc = (char)Math.max(acc, val); + } + bh.consume(acc); + } + + // ---------short***Simple ------------------------------------------------------------ + @Benchmark + public void shortAndSimple(Blackhole bh) { + short acc = (short)0xFFFF; // neutral element + for (int i = 0; i < SIZE; i++) { + short val = in1S[i]; + acc &= val; + } + bh.consume(acc); + } + + @Benchmark + public void shortOrSimple(Blackhole bh) { + short acc = 0; // neutral element + for (int i = 0; i < SIZE; i++) { + short val = in1S[i]; + acc |= val; + } + bh.consume(acc); + } + + @Benchmark + public void shortXorSimple(Blackhole bh) { + short acc = 0; // neutral element + for (int i = 0; i < SIZE; i++) { + short val = in1S[i]; + acc ^= val; + } + bh.consume(acc); + } + + @Benchmark + public void shortAddSimple(Blackhole bh) { + short acc = 0; // neutral element + for (int i = 0; i < SIZE; i++) { + short val = in1S[i]; + acc += val; + } + bh.consume(acc); + } + + @Benchmark + public void shortMulSimple(Blackhole bh) { + short acc = 1; // neutral element + for (int i = 0; i < SIZE; i++) { + short val = in1S[i]; + acc *= val; + } + bh.consume(acc); + } + + @Benchmark + public void shortMinSimple(Blackhole bh) { + short acc = Short.MAX_VALUE; // neutral element + for (int i = 0; i < SIZE; i++) { + short val = in1S[i]; + acc = (short)Math.min(acc, val); + } + bh.consume(acc); + } + + @Benchmark + public void shortMaxSimple(Blackhole bh) { + short acc = Short.MIN_VALUE; // neutral element + for (int i = 0; i < SIZE; i++) { + short val = in1S[i]; + acc = (short)Math.max(acc, val); + } + bh.consume(acc); + } + + // ---------short***DotProduct ------------------------------------------------------------ + @Benchmark + public void shortAndDotProduct(Blackhole bh) { + short acc = (short)0xFFFF; // neutral element + for (int i = 0; i < SIZE; i++) { + short val = (short)(in1S[i] * in2S[i]); + acc &= val; + } + bh.consume(acc); + } + + @Benchmark + public void shortOrDotProduct(Blackhole bh) { + short acc = 0; // neutral element + for (int i = 0; i < SIZE; i++) { + short val = (short)(in1S[i] * in2S[i]); + acc |= val; + } + bh.consume(acc); + } + + @Benchmark + public void shortXorDotProduct(Blackhole bh) { + short acc = 0; // neutral element + for (int i = 0; i < SIZE; i++) { + short val = (short)(in1S[i] * in2S[i]); + acc ^= val; + } + bh.consume(acc); + } + + @Benchmark + public void shortAddDotProduct(Blackhole bh) { + short acc = 0; // neutral element + for (int i = 0; i < SIZE; i++) { + short val = (short)(in1S[i] * in2S[i]); + acc += val; + } + bh.consume(acc); + } + + @Benchmark + public void shortMulDotProduct(Blackhole bh) { + short acc = 1; // neutral element + for (int i = 0; i < SIZE; i++) { + short val = (short)(in1S[i] * in2S[i]); + acc *= val; + } + bh.consume(acc); + } + + @Benchmark + public void shortMinDotProduct(Blackhole bh) { + short acc = Short.MAX_VALUE; // neutral element + for (int i = 0; i < SIZE; i++) { + short val = (short)(in1S[i] * in2S[i]); + acc = (short)Math.min(acc, val); + } + bh.consume(acc); + } + + @Benchmark + public void shortMaxDotProduct(Blackhole bh) { + short acc = Short.MIN_VALUE; // neutral element + for (int i = 0; i < SIZE; i++) { + short val = (short)(in1S[i] * in2S[i]); + acc = (short)Math.max(acc, val); + } + bh.consume(acc); + } + + // ---------short***Big ------------------------------------------------------------ + @Benchmark + public void shortAndBig(Blackhole bh) { + short acc = (short)0xFFFF; // neutral element + for (int i = 0; i < SIZE; i++) { + short val = (short)((in1S[i] * in2S[i]) + (in1S[i] * in3S[i]) + (in2S[i] * in3S[i])); + acc &= val; + } + bh.consume(acc); + } + + @Benchmark + public void shortOrBig(Blackhole bh) { + short acc = 0; // neutral element + for (int i = 0; i < SIZE; i++) { + short val = (short)((in1S[i] * in2S[i]) + (in1S[i] * in3S[i]) + (in2S[i] * in3S[i])); + acc |= val; + } + bh.consume(acc); + } + + @Benchmark + public void shortXorBig(Blackhole bh) { + short acc = 0; // neutral element + for (int i = 0; i < SIZE; i++) { + short val = (short)((in1S[i] * in2S[i]) + (in1S[i] * in3S[i]) + (in2S[i] * in3S[i])); + acc ^= val; + } + bh.consume(acc); + } + + @Benchmark + public void shortAddBig(Blackhole bh) { + short acc = 0; // neutral element + for (int i = 0; i < SIZE; i++) { + short val = (short)((in1S[i] * in2S[i]) + (in1S[i] * in3S[i]) + (in2S[i] * in3S[i])); + acc += val; + } + bh.consume(acc); + } + + @Benchmark + public void shortMulBig(Blackhole bh) { + short acc = 1; // neutral element + for (int i = 0; i < SIZE; i++) { + short val = (short)((in1S[i] * in2S[i]) + (in1S[i] * in3S[i]) + (in2S[i] * in3S[i])); + acc *= val; + } + bh.consume(acc); + } + + @Benchmark + public void shortMinBig(Blackhole bh) { + short acc = Short.MAX_VALUE; // neutral element + for (int i = 0; i < SIZE; i++) { + short val = (short)((in1S[i] * in2S[i]) + (in1S[i] * in3S[i]) + (in2S[i] * in3S[i])); + acc = (short)Math.min(acc, val); + } + bh.consume(acc); + } + + @Benchmark + public void shortMaxBig(Blackhole bh) { + short acc = Short.MIN_VALUE; // neutral element + for (int i = 0; i < SIZE; i++) { + short val = (short)((in1S[i] * in2S[i]) + (in1S[i] * in3S[i]) + (in2S[i] * in3S[i])); + acc = (short)Math.max(acc, val); + } + bh.consume(acc); + } + + // ---------int***Simple ------------------------------------------------------------ + @Benchmark + public void intAndSimple(Blackhole bh) { + int acc = 0xFFFFFFFF; // neutral element + for (int i = 0; i < SIZE; i++) { + int val = in1I[i]; + acc &= val; + } + bh.consume(acc); + } + + @Benchmark + public void intOrSimple(Blackhole bh) { + int acc = 0; // neutral element + for (int i = 0; i < SIZE; i++) { + int val = in1I[i]; + acc |= val; + } + bh.consume(acc); + } + + @Benchmark + public void intXorSimple(Blackhole bh) { + int acc = 0; // neutral element + for (int i = 0; i < SIZE; i++) { + int val = in1I[i]; + acc ^= val; + } + bh.consume(acc); + } + + @Benchmark + public void intAddSimple(Blackhole bh) { + int acc = 0; // neutral element + for (int i = 0; i < SIZE; i++) { + int val = in1I[i]; + acc += val; + } + bh.consume(acc); + } + + @Benchmark + public void intMulSimple(Blackhole bh) { + int acc = 1; // neutral element + for (int i = 0; i < SIZE; i++) { + int val = in1I[i]; + acc *= val; + } + bh.consume(acc); + } + + @Benchmark + public void intMinSimple(Blackhole bh) { + int acc = Integer.MAX_VALUE; // neutral element + for (int i = 0; i < SIZE; i++) { + int val = in1I[i]; + acc = Math.min(acc, val); + } + bh.consume(acc); + } + + @Benchmark + public void intMaxSimple(Blackhole bh) { + int acc = Integer.MIN_VALUE; // neutral element + for (int i = 0; i < SIZE; i++) { + int val = in1I[i]; + acc = Math.max(acc, val); + } + bh.consume(acc); + } + + // ---------int***DotProduct ------------------------------------------------------------ + @Benchmark + public void intAndDotProduct(Blackhole bh) { + int acc = 0xFFFFFFFF; // neutral element + for (int i = 0; i < SIZE; i++) { + int val = in1I[i] * in2I[i]; + acc &= val; + } + bh.consume(acc); + } + + @Benchmark + public void intOrDotProduct(Blackhole bh) { + int acc = 0; // neutral element + for (int i = 0; i < SIZE; i++) { + int val = in1I[i] * in2I[i]; + acc |= val; + } + bh.consume(acc); + } + + @Benchmark + public void intXorDotProduct(Blackhole bh) { + int acc = 0; // neutral element + for (int i = 0; i < SIZE; i++) { + int val = in1I[i] * in2I[i]; + acc ^= val; + } + bh.consume(acc); + } + + @Benchmark + public void intAddDotProduct(Blackhole bh) { + int acc = 0; // neutral element + for (int i = 0; i < SIZE; i++) { + int val = in1I[i] * in2I[i]; + acc += val; + } + bh.consume(acc); + } + + @Benchmark + public void intMulDotProduct(Blackhole bh) { + int acc = 1; // neutral element + for (int i = 0; i < SIZE; i++) { + int val = in1I[i] * in2I[i]; + acc *= val; + } + bh.consume(acc); + } + + @Benchmark + public void intMinDotProduct(Blackhole bh) { + int acc = Integer.MAX_VALUE; // neutral element + for (int i = 0; i < SIZE; i++) { + int val = in1I[i] * in2I[i]; + acc = Math.min(acc, val); + } + bh.consume(acc); + } + + @Benchmark + public void intMaxDotProduct(Blackhole bh) { + int acc = Integer.MIN_VALUE; // neutral element + for (int i = 0; i < SIZE; i++) { + int val = in1I[i] * in2I[i]; + acc = Math.max(acc, val); + } + bh.consume(acc); + } + + // ---------int***Big ------------------------------------------------------------ + @Benchmark + public void intAndBig(Blackhole bh) { + int acc = 0xFFFFFFFF; // neutral element + for (int i = 0; i < SIZE; i++) { + int val = (in1I[i] * in2I[i]) + (in1I[i] * in3I[i]) + (in2I[i] * in3I[i]); + acc &= val; + } + bh.consume(acc); + } + + @Benchmark + public void intOrBig(Blackhole bh) { + int acc = 0; // neutral element + for (int i = 0; i < SIZE; i++) { + int val = (in1I[i] * in2I[i]) + (in1I[i] * in3I[i]) + (in2I[i] * in3I[i]); + acc |= val; + } + bh.consume(acc); + } + + @Benchmark + public void intXorBig(Blackhole bh) { + int acc = 0; // neutral element + for (int i = 0; i < SIZE; i++) { + int val = (in1I[i] * in2I[i]) + (in1I[i] * in3I[i]) + (in2I[i] * in3I[i]); + acc ^= val; + } + bh.consume(acc); + } + + @Benchmark + public void intAddBig(Blackhole bh) { + int acc = 0; // neutral element + for (int i = 0; i < SIZE; i++) { + int val = (in1I[i] * in2I[i]) + (in1I[i] * in3I[i]) + (in2I[i] * in3I[i]); + acc += val; + } + bh.consume(acc); + } + + @Benchmark + public void intMulBig(Blackhole bh) { + int acc = 1; // neutral element + for (int i = 0; i < SIZE; i++) { + int val = (in1I[i] * in2I[i]) + (in1I[i] * in3I[i]) + (in2I[i] * in3I[i]); + acc *= val; + } + bh.consume(acc); + } + + @Benchmark + public void intMinBig(Blackhole bh) { + int acc = Integer.MAX_VALUE; // neutral element + for (int i = 0; i < SIZE; i++) { + int val = (in1I[i] * in2I[i]) + (in1I[i] * in3I[i]) + (in2I[i] * in3I[i]); + acc = Math.min(acc, val); + } + bh.consume(acc); + } + + @Benchmark + public void intMaxBig(Blackhole bh) { + int acc = Integer.MIN_VALUE; // neutral element + for (int i = 0; i < SIZE; i++) { + int val = (in1I[i] * in2I[i]) + (in1I[i] * in3I[i]) + (in2I[i] * in3I[i]); + acc = Math.max(acc, val); + } + bh.consume(acc); + } + + // ---------long***Simple ------------------------------------------------------------ + @Benchmark + public void longAndSimple(Blackhole bh) { + long acc = 0xFFFFFFFFFFFFFFFFL; // neutral element + for (int i = 0; i < SIZE; i++) { + long val = in1L[i]; + acc &= val; + } + bh.consume(acc); + } + + @Benchmark + public void longOrSimple(Blackhole bh) { + long acc = 0; // neutral element + for (int i = 0; i < SIZE; i++) { + long val = in1L[i]; + acc |= val; + } + bh.consume(acc); + } + + @Benchmark + public void longXorSimple(Blackhole bh) { + long acc = 0; // neutral element + for (int i = 0; i < SIZE; i++) { + long val = in1L[i]; + acc ^= val; + } + bh.consume(acc); + } + + @Benchmark + public void longAddSimple(Blackhole bh) { + long acc = 0; // neutral element + for (int i = 0; i < SIZE; i++) { + long val = in1L[i]; + acc += val; + } + bh.consume(acc); + } + + @Benchmark + public void longMulSimple(Blackhole bh) { + long acc = 1; // neutral element + for (int i = 0; i < SIZE; i++) { + long val = in1L[i]; + acc *= val; + } + bh.consume(acc); + } + + @Benchmark + public void longMinSimple(Blackhole bh) { + long acc = Long.MAX_VALUE; // neutral element + for (int i = 0; i < SIZE; i++) { + long val = in1L[i]; + acc = Math.min(acc, val); + } + bh.consume(acc); + } + + @Benchmark + public void longMaxSimple(Blackhole bh) { + long acc = Long.MIN_VALUE; // neutral element + for (int i = 0; i < SIZE; i++) { + long val = in1L[i]; + acc = Math.max(acc, val); + } + bh.consume(acc); + } + + // ---------long***DotProduct ------------------------------------------------------------ + @Benchmark + public void longAndDotProduct(Blackhole bh) { + long acc = 0xFFFFFFFFFFFFFFFFL; // neutral element + for (int i = 0; i < SIZE; i++) { + long val = in1L[i] * in2L[i]; + acc &= val; + } + bh.consume(acc); + } + + @Benchmark + public void longOrDotProduct(Blackhole bh) { + long acc = 0; // neutral element + for (int i = 0; i < SIZE; i++) { + long val = in1L[i] * in2L[i]; + acc |= val; + } + bh.consume(acc); + } + + @Benchmark + public void longXorDotProduct(Blackhole bh) { + long acc = 0; // neutral element + for (int i = 0; i < SIZE; i++) { + long val = in1L[i] * in2L[i]; + acc ^= val; + } + bh.consume(acc); + } + + @Benchmark + public void longAddDotProduct(Blackhole bh) { + long acc = 0; // neutral element + for (int i = 0; i < SIZE; i++) { + long val = in1L[i] * in2L[i]; + acc += val; + } + bh.consume(acc); + } + + @Benchmark + public void longMulDotProduct(Blackhole bh) { + long acc = 1; // neutral element + for (int i = 0; i < SIZE; i++) { + long val = in1L[i] * in2L[i]; + acc *= val; + } + bh.consume(acc); + } + + @Benchmark + public void longMinDotProduct(Blackhole bh) { + long acc = Long.MAX_VALUE; // neutral element + for (int i = 0; i < SIZE; i++) { + long val = in1L[i] * in2L[i]; + acc = Math.min(acc, val); + } + bh.consume(acc); + } + + @Benchmark + public void longMaxDotProduct(Blackhole bh) { + long acc = Long.MIN_VALUE; // neutral element + for (int i = 0; i < SIZE; i++) { + long val = in1L[i] * in2L[i]; + acc = Math.max(acc, val); + } + bh.consume(acc); + } + + // ---------long***Big ------------------------------------------------------------ + @Benchmark + public void longAndBig(Blackhole bh) { + long acc = 0xFFFFFFFFFFFFFFFFL; // neutral element + for (int i = 0; i < SIZE; i++) { + long val = (in1L[i] * in2L[i]) + (in1L[i] * in3L[i]) + (in2L[i] * in3L[i]); + acc &= val; + } + bh.consume(acc); + } + + @Benchmark + public void longOrBig(Blackhole bh) { + long acc = 0; // neutral element + for (int i = 0; i < SIZE; i++) { + long val = (in1L[i] * in2L[i]) + (in1L[i] * in3L[i]) + (in2L[i] * in3L[i]); + acc |= val; + } + bh.consume(acc); + } + + @Benchmark + public void longXorBig(Blackhole bh) { + long acc = 0; // neutral element + for (int i = 0; i < SIZE; i++) { + long val = (in1L[i] * in2L[i]) + (in1L[i] * in3L[i]) + (in2L[i] * in3L[i]); + acc ^= val; + } + bh.consume(acc); + } + + @Benchmark + public void longAddBig(Blackhole bh) { + long acc = 0; // neutral element + for (int i = 0; i < SIZE; i++) { + long val = (in1L[i] * in2L[i]) + (in1L[i] * in3L[i]) + (in2L[i] * in3L[i]); + acc += val; + } + bh.consume(acc); + } + + @Benchmark + public void longMulBig(Blackhole bh) { + long acc = 1; // neutral element + for (int i = 0; i < SIZE; i++) { + long val = (in1L[i] * in2L[i]) + (in1L[i] * in3L[i]) + (in2L[i] * in3L[i]); + acc *= val; + } + bh.consume(acc); + } + + @Benchmark + public void longMinBig(Blackhole bh) { + long acc = Long.MAX_VALUE; // neutral element + for (int i = 0; i < SIZE; i++) { + long val = (in1L[i] * in2L[i]) + (in1L[i] * in3L[i]) + (in2L[i] * in3L[i]); + acc = Math.min(acc, val); + } + bh.consume(acc); + } + + @Benchmark + public void longMaxBig(Blackhole bh) { + long acc = Long.MIN_VALUE; // neutral element + for (int i = 0; i < SIZE; i++) { + long val = (in1L[i] * in2L[i]) + (in1L[i] * in3L[i]) + (in2L[i] * in3L[i]); + acc = Math.max(acc, val); + } + bh.consume(acc); + } + + // ---------float***Simple ------------------------------------------------------------ + @Benchmark + public void floatAddSimple(Blackhole bh) { + float acc = 0; // neutral element + for (int i = 0; i < SIZE; i++) { + float val = in1F[i]; + acc += val; + } + bh.consume(acc); + } + + @Benchmark + public void floatMulSimple(Blackhole bh) { + float acc = 1; // neutral element + for (int i = 0; i < SIZE; i++) { + float val = in1F[i]; + acc *= val; + } + bh.consume(acc); + } + + @Benchmark + public void floatMinSimple(Blackhole bh) { + float acc = Float.MAX_VALUE; // neutral element + for (int i = 0; i < SIZE; i++) { + float val = in1F[i]; + acc = Math.min(acc, val); + } + bh.consume(acc); + } + + @Benchmark + public void floatMaxSimple(Blackhole bh) { + float acc = Float.MIN_VALUE; // neutral element + for (int i = 0; i < SIZE; i++) { + float val = in1F[i]; + acc = Math.max(acc, val); + } + bh.consume(acc); + } + + // ---------float***DotProduct ------------------------------------------------------------ + @Benchmark + public void floatAddDotProduct(Blackhole bh) { + float acc = 0; // neutral element + for (int i = 0; i < SIZE; i++) { + float val = in1F[i] * in2F[i]; + acc += val; + } + bh.consume(acc); + } + + @Benchmark + public void floatMulDotProduct(Blackhole bh) { + float acc = 1; // neutral element + for (int i = 0; i < SIZE; i++) { + float val = in1F[i] * in2F[i]; + acc *= val; + } + bh.consume(acc); + } + + @Benchmark + public void floatMinDotProduct(Blackhole bh) { + float acc = Float.MAX_VALUE; // neutral element + for (int i = 0; i < SIZE; i++) { + float val = in1F[i] * in2F[i]; + acc = Math.min(acc, val); + } + bh.consume(acc); + } + + @Benchmark + public void floatMaxDotProduct(Blackhole bh) { + float acc = Float.MIN_VALUE; // neutral element + for (int i = 0; i < SIZE; i++) { + float val = in1F[i] * in2F[i]; + acc = Math.max(acc, val); + } + bh.consume(acc); + } + + // ---------float***Big ------------------------------------------------------------ + @Benchmark + public void floatAddBig(Blackhole bh) { + float acc = 0; // neutral element + for (int i = 0; i < SIZE; i++) { + float val = (in1F[i] * in2F[i]) + (in1F[i] * in3F[i]) + (in2F[i] * in3F[i]); + acc += val; + } + bh.consume(acc); + } + + @Benchmark + public void floatMulBig(Blackhole bh) { + float acc = 1; // neutral element + for (int i = 0; i < SIZE; i++) { + float val = (in1F[i] * in2F[i]) + (in1F[i] * in3F[i]) + (in2F[i] * in3F[i]); + acc *= val; + } + bh.consume(acc); + } + + @Benchmark + public void floatMinBig(Blackhole bh) { + float acc = Float.MAX_VALUE; // neutral element + for (int i = 0; i < SIZE; i++) { + float val = (in1F[i] * in2F[i]) + (in1F[i] * in3F[i]) + (in2F[i] * in3F[i]); + acc = Math.min(acc, val); + } + bh.consume(acc); + } + + @Benchmark + public void floatMaxBig(Blackhole bh) { + float acc = Float.MIN_VALUE; // neutral element + for (int i = 0; i < SIZE; i++) { + float val = (in1F[i] * in2F[i]) + (in1F[i] * in3F[i]) + (in2F[i] * in3F[i]); + acc = Math.max(acc, val); + } + bh.consume(acc); + } + + // ---------double***Simple ------------------------------------------------------------ + @Benchmark + public void doubleAddSimple(Blackhole bh) { + double acc = 0; // neutral element + for (int i = 0; i < SIZE; i++) { + double val = in1D[i]; + acc += val; + } + bh.consume(acc); + } + + @Benchmark + public void doubleMulSimple(Blackhole bh) { + double acc = 1; // neutral element + for (int i = 0; i < SIZE; i++) { + double val = in1D[i]; + acc *= val; + } + bh.consume(acc); + } + + @Benchmark + public void doubleMinSimple(Blackhole bh) { + double acc = Double.MAX_VALUE; // neutral element + for (int i = 0; i < SIZE; i++) { + double val = in1D[i]; + acc = Math.min(acc, val); + } + bh.consume(acc); + } + + @Benchmark + public void doubleMaxSimple(Blackhole bh) { + double acc = Double.MIN_VALUE; // neutral element + for (int i = 0; i < SIZE; i++) { + double val = in1D[i]; + acc = Math.max(acc, val); + } + bh.consume(acc); + } + + // ---------double***DotProduct ------------------------------------------------------------ + @Benchmark + public void doubleAddDotProduct(Blackhole bh) { + double acc = 0; // neutral element + for (int i = 0; i < SIZE; i++) { + double val = in1D[i] * in2D[i]; + acc += val; + } + bh.consume(acc); + } + + @Benchmark + public void doubleMulDotProduct(Blackhole bh) { + double acc = 1; // neutral element + for (int i = 0; i < SIZE; i++) { + double val = in1D[i] * in2D[i]; + acc *= val; + } + bh.consume(acc); + } + + @Benchmark + public void doubleMinDotProduct(Blackhole bh) { + double acc = Double.MAX_VALUE; // neutral element + for (int i = 0; i < SIZE; i++) { + double val = in1D[i] * in2D[i]; + acc = Math.min(acc, val); + } + bh.consume(acc); + } + + @Benchmark + public void doubleMaxDotProduct(Blackhole bh) { + double acc = Double.MIN_VALUE; // neutral element + for (int i = 0; i < SIZE; i++) { + double val = in1D[i] * in2D[i]; + acc = Math.max(acc, val); + } + bh.consume(acc); + } + + // ---------double***Big ------------------------------------------------------------ + @Benchmark + public void doubleAddBig(Blackhole bh) { + double acc = 0; // neutral element + for (int i = 0; i < SIZE; i++) { + double val = (in1D[i] * in2D[i]) + (in1D[i] * in3D[i]) + (in2D[i] * in3D[i]); + acc += val; + } + bh.consume(acc); + } + + @Benchmark + public void doubleMulBig(Blackhole bh) { + double acc = 1; // neutral element + for (int i = 0; i < SIZE; i++) { + double val = (in1D[i] * in2D[i]) + (in1D[i] * in3D[i]) + (in2D[i] * in3D[i]); + acc *= val; + } + bh.consume(acc); + } + + @Benchmark + public void doubleMinBig(Blackhole bh) { + double acc = Double.MAX_VALUE; // neutral element + for (int i = 0; i < SIZE; i++) { + double val = (in1D[i] * in2D[i]) + (in1D[i] * in3D[i]) + (in2D[i] * in3D[i]); + acc = Math.min(acc, val); + } + bh.consume(acc); + } + + @Benchmark + public void doubleMaxBig(Blackhole bh) { + double acc = Double.MIN_VALUE; // neutral element + for (int i = 0; i < SIZE; i++) { + double val = (in1D[i] * in2D[i]) + (in1D[i] * in3D[i]) + (in2D[i] * in3D[i]); + acc = Math.max(acc, val); + } + bh.consume(acc); + } + + @Fork(value = 1, jvmArgsPrepend = {"-XX:+UseSuperWord"}) + public static class WithSuperword extends VectorReduction2 {} + + @Fork(value = 1, jvmArgsPrepend = {"-XX:-UseSuperWord"}) + public static class NoSuperword extends VectorReduction2 {} +} + diff --git a/test/micro/org/openjdk/bench/vm/compiler/x86/BasicRules.java b/test/micro/org/openjdk/bench/vm/compiler/x86/BasicRules.java index 35a346d3ed8..4b04e168f16 100644 --- a/test/micro/org/openjdk/bench/vm/compiler/x86/BasicRules.java +++ b/test/micro/org/openjdk/bench/vm/compiler/x86/BasicRules.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,8 @@ import java.util.concurrent.TimeUnit; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.infra.Blackhole; +import java.util.Random; + @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) @State(Scope.Thread) @@ -38,6 +40,16 @@ public class BasicRules { static final int INT_IMM = 100; static final long LONG_IMM = 100; + @Setup(Level.Iteration) + public void setup() { + Random random = new Random(1000); + + for (int i = 0; i < 1024; i++) { + INT_ARRAY[i] = random.nextInt(); + LONG_ARRAY[i] = random.nextLong(); + } + } + @Benchmark public void andL_rReg_imm255(Blackhole bh) { for (int i = 0; i < LONG_ARRAY.length; i++) { @@ -125,5 +137,12 @@ public class BasicRules { bh.consume(LONG_ARRAY[i] - LONG_IMM); } } + + @Benchmark + public void cmovL_imm_01(Blackhole bh) { + for (int i = 0; i < INT_ARRAY.length; i++) { + bh.consume(INT_ARRAY[i] > 0 ? 1L : 0L); + } + } } diff --git a/test/micro/org/openjdk/bench/vm/lang/LockUnlock.java b/test/micro/org/openjdk/bench/vm/lang/LockUnlock.java index 3ed862e8218..39c8569532e 100644 --- a/test/micro/org/openjdk/bench/vm/lang/LockUnlock.java +++ b/test/micro/org/openjdk/bench/vm/lang/LockUnlock.java @@ -309,10 +309,11 @@ public class LockUnlock { } /** - * With two threads lockObject1 will be contended so should be - * inflated. + * With three threads lockObject1 will be contended so should be + * inflated. Three threads is also needed to ensure a high level + * of code coverage in the locking code. */ - @Threads(2) + @Threads(3) @Benchmark public void testContendedLock() { synchronized (lockObject1) {